Index: /tags/Mars_V0-8-5/Mars/.rootrc
===================================================================
--- /tags/Mars_V0-8-5/Mars/.rootrc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/.rootrc	(revision 9661)
@@ -0,0 +1,45 @@
+#############################################################################
+#                                                                           #
+# This is the path where root seraches for macros                           #
+# to execute (eg. .x merpp.C)                                               #
+#                                                                           #
+#############################################################################
+
+Unix.*.Root.MacroPath:       .:./macros
+
+#############################################################################
+#                                                                           #
+# This is the path where the dynamic loader (eg. gSystem->Load("mars.so")   #
+# is searching for the shared objects                                       #
+#                                                                           #
+#############################################################################
+
+Unix.*.Root.DynamicPath:     .:./lib
+
+#############################################################################
+#                                                                           #
+# This is the name of the logon macro (executed at root startup) and the    #
+# logoff macro (executed when quiting root)                                 #
+#                                                                           #
+#############################################################################
+
+Rint.Logon:                  rootlogon.C
+Rint.Logoff:                 rootlogoff.C
+
+#############################################################################
+#                                                                           #
+# This is used if you want to use the root documentation facility to        #
+# create the documentation of the code out of the code                      #
+#                                                                           #
+#############################################################################
+
+Root.Html.DescriptionStyle:  Doc++
+
+Root.Html.Author:            !   Author(s):
+Root.Html.Copyright:         !   Copyright
+Root.Html.Modified:          !   Modified:
+Root.Html.Description        // ----
+
+Root.Html.Root:              http://root.cern.ch/root/htmldoc/
+Root.Html.HomePage:          http://magic.astro.uni-wuerzburg.de/mars/
+Root.Html.SearchEngine:      http://magic.astro.uni-wuerzburg.de/mars/search.html
Index: /tags/Mars_V0-8-5/Mars/Changelog
===================================================================
--- /tags/Mars_V0-8-5/Mars/Changelog	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/Changelog	(revision 9661)
@@ -0,0 +1,6546 @@
+
+Please  do  not write behind the end of line tag so that it is  possible
+to   send  a   Changelog   file  to  a  line  printer  directly.  Thanks.
+
+For your entries please follow EXACTLY this style:
+
+_yyyy/mm/dd:_[Your Name]
+_
+___*_filename:
+_____-_description
+_
+___*_filename2, filename3:
+_____-_description
+_
+_
+_
+
+While an underscore is a placeholder for a white-space or an empty line.
+
+                                                 -*-*- END OF LINE -*-*-
+
+
+ 2004/08/05: Thomas Bretz
+
+   * mastro/MAstroCatalog.[h,cc]:
+     - changed return type of AddObject to Bool_t
+     - changed Reading member function to use AddObject
+
+   * msignal/MArrivalTime.h:
+     - Added missing ClassDef
+
+
+
+ 2004/08/05: Robert Wagner
+
+   * mastro/MAstroCatalog.[h,cc]
+     - Added MAstroCatalog::AddObject, functionality to insert single
+       objects manually; needed for mtemp/mmpi/MSourceDirections
+
+
+
+ 2004/08/05: Thomas Bretz
+
+   * manalysis/MGeomApply.cc, mimage/MCameraSmooth.[h,cc]:
+     - removed dependancy on MBlindPixel
+
+   * macros/sql/readrbk.C, msql/MSQLServer.cc:
+     - fixed some memory leaks - the result of TSQLServer::Query
+       must be deleted
+
+   * mbase/MTaskInteractive.cc:
+     - added some comments
+
+   * mmain/MBrowser.cc:
+     - fixed a bug which caused '/data/MAGIC' not to be shown in
+       the dir-list
+
+   * mmc/MMcEvt.hxx:
+     - added some more particle ids
+
+   * msql/MSQLServer.[h,cc]:
+     - some improvements to the user interface
+
+   * macros/sql/filldotrun.C:
+     - added
+
+
+
+ 2004/08/04: Markus Gaug
+
+   * msignal/MExtractFixedWindowSpline.cc
+     - replaced delete's of the array by a delete [].
+
+   * mjobs/MJCalibration.cc
+     - replaced default time extractor by MExtractTimeFastSpline
+
+   * mbadpixels/MBadPixelsPix.cc
+     - updated the class description
+
+
+
+ 2004/08/04: Thomas Bretz
+
+   * manalysis/MBlindPixels.[h,cc], manalysis/MBlindPixelCalc.[h,cc], 
+     manalysis/MBlindPixelCalc2.[h,cc]:
+     - as discussed some weeks ago the classes have been removed
+
+   * manalysis/Makefile, manalysis/AnalysisLinkDef.h:
+     - removed the MBlind* entries
+
+   * star.cc, mmain/MEventDisplay.cc, mmain/MOnlineDisplay.cc, 
+     mmain/MAnalysis.cc, mfileio/MCT1ReadPreProc.[h,cc]:
+     - removed usage of MBlind*
+     - MBadPixel* TO BE ADDED
+
+   * merpp.cc:
+     - moved interpretation of command line options to MLog
+     - added a check for unknown options
+
+   * manalysis/MCameraData.[h,cc]:
+     - added some comments
+     - fixed some errors in the documentation
+     - changed ClassDef to 1
+     - changed the new algorithms such that any number of different
+       pixel-sizes are supported
+     - small modifications to the sanity checks
+
+   * mbadpixels/MBadPixelsTreat.h:
+     - fixed the argument type of SetNumMinNeighbors
+
+   * mbase/MArgs.cc:
+     - comment updated
+
+   * mbase/MEvtLoop.cc:
+     - added reading and writing of fLog environment
+
+   * mbase/MLog.[h,cc]:
+     - added Reading and writing Environment (ReadEnv, WriteEnv)
+     - added a function to setup MLog from command line arguments
+
+   * mbase/MTaskInteractive.[h,cc]:
+     - added an example
+
+   * mbase/MTime.cc:
+     - added a warning for the SetTimeFormat usage
+
+   * mimage/MImgCleanStd.[h,cc]:
+     - some updates to the old comments
+     - NEW COMMENTS FOR SCALED CLEANING STILL MISSING!
+     - implemented scaled image cleaning
+     - replaced usage of MSigmabar by MPedPhotCam for democratic cleaning
+
+   * manalysisct1, manalysisct1/Makefile, 
+     manalysisct1/AnalysisCT1LinkDef.h:
+     - new
+
+   * manalysis/MCT1*, mfileio/structures.h, mfileio/MCT1Read*.[h,cc]:
+     - moved to new directory manalysisct1
+
+   * manalysis/Makefile, manalysis/AnalysisLinkDef.h:
+     - updated
+     - removed MPad because long time ago changed discuseed were not made
+       (it doesn't compile anymore, because MBlindPixels is missing now)
+
+   * mfileio/Makefile, mfileio/FileIOLinkDef.h:
+     - updated
+
+   * mbase/MLog.cc:
+     - added missing kMustCleanup bit of fPlugins
+
+   * mbadpixels/MBadPixelsPix.h:
+     - added easier access to the information whether a pixel is unsuitable
+       or unreliable
+
+   * mbadpixels/MBadPixelsTreat.[h,cc]:
+     - added SloppyTreatment
+
+
+
+ 2004/08/03: Hendrik Bartko
+
+   * manalysis/MCameraData.[h,cc]
+     - Added new function CalcCleaningLevel2 to take into account that
+       the pedestal RMS does not scale with the inverse square root of
+       the pixel area for the calculation of the cleaning levels.
+     - Added new function CalcCleaningLevelDemocratic. It calculates
+       the cleaning levels for the democratic image cleaning directly
+       from the average values of MPedPhotCam instead of using 
+       MSigmabar.
+
+
+
+ 2004/08/03: Thomas Bretz
+
+   * macros/sql:
+     - new directory
+
+   * macros/sql/readrbk.C:
+     - new macro
+
+   * mjobs/MJExtractSignal.cc:
+     - fixed missing initialisation of fExtractor, fExtractorTime
+
+
+
+ 2004/07/30: Robert Wagner
+
+   * mastro/MAstroCamera.[h,cc]
+     - Added method FillStarList() which fills a TList with objects
+       of type MStarLocalPos for all stars found from the catalog
+       matching specified criteria (FOV, magnitude limit, position)
+     - Lines involving MStarLocalPos have been commented out for
+       the time being since MStarLocalPos is not part of standard
+       MARS yet!
+
+   * mtemp/MStarLocalPos.[h,cc]
+     - Added handling of the minuit error matrix elements to
+       MStarLocalPos::MSetFitValues
+     - Added member variables to hold error matrix elements
+     - Added getters for error matrix elements
+     - Expected star position is painted by Paint, too.
+     - Error matrix elements are printed by Print, too.
+
+
+
+ 2004/07/28: Javi Lopez
+
+   * mhist/MHCamera.[h,cc]
+     - Added new argument to CntCamContent() funtion to select to count
+       the events above or bellow a certain discriminator level.
+
+
+
+ 2004/07/20: Florian Goebel
+
+   * mpedestal/MPedestalPix.[h,cc]
+     - added: 
+      + fPedestalABoffset: difference between pedestal mean of odd slices
+                           and the total pedestal mean (fPedestal)                
+      + fNumEvents:        number of times, the Process was executed          
+                           (to estimate the error of pedestal)
+
+   * mpedestal/MPedestalCam.cc
+     - calculate error using pixel vise fNumEvents
+
+   * mpedestal/MPedCalcFromLoGain.[h,cc]
+   * mpedestal/Makefile
+   * mpedestal/PedestalLinkDef.h
+     - added class which calculates pedestal values from the low gain
+       slices of a data run
+     - it also calculates the ABoffset values and fills MPedestalPix
+       accordingly
+
+   * macros/ScanPulseABPed.C
+     - macro plotting the pulse shape using MPedCalcFromLoGain
+       and correcting for the AB 150 MHz clock noise.
+
+   * msignal/MExtractSignalABcorr.[h,cc]
+   * msignal/Makefile
+   * msignal/SignalLinkDef.h
+     - example for signal extractor class similar to MExtractSignal 
+       correcting for ABoffset which allows to use odd number of slices
+
+   * macros/ScanExtractSignalABCorr.C
+     - macro using MExtractSignalABcorr
+
+
+
+ 2004/07/16: Markus Gaug
+
+   * msignal/MExtractFixedWindowSpline.cc
+     - replace the delete's by delete [].
+
+   * mcalib/MHCalibrationChargeCam.cc
+     - remove some obsolete commented code
+
+   * mcalib/MHCalibrationChargeBlindPix.[h,cc]
+     - derive only from MHGausEvents and not additionally from 
+       MHCalibrationChargePix
+     - Additional setter for MCalibrationChargeBlindPix, used by 
+       MHCalibrationChargeBlindCam
+     - Getter for fSinglePheCut
+     - adapted Draw for the "datacheck" option
+     - use variable histogram range depending on whether amplitude
+       or integral has been extracted
+
+   * mcalib/MCalibrationChargeBlindCam.[h,cc]
+   * mcalib/MHCalibrationChargeBlindCam.[h,cc]
+   * mcalib/Makefile
+   * mcalib/CalibLinkDef.h
+     - two new classes for the treatment of various blind pixels in the 
+       camera
+
+   * mcalib/MCalibrationChargeCalc.[h,cc]
+     - adapted to use of various blind pixels
+
+
+
+ 2004/07/15: Markus Gaug
+
+   * mcalib/MHCalibrationChargeCam.[h,cc]
+     - hard coded the reference lines for the DataCheck Display. 
+       Should be faster and easier to read than the TArrayF's. 
+
+   * mcalib/MCalibrationChargeCalc.[h,cc]
+     - removed obsolete pointer to MEvtTime
+     - fixed bug in calculation of RMS for FFactor of inner pixels
+       in case that the fit does not converge. 
+     - introduced blind pixel and PIN Diode result flags for later
+       output or storage in DB.
+
+
+
+ 2004/07/14: Hendrik Bartko
+
+   * mpedestal/MPedPhotCam.[h,cc]
+     - added average areas and sectors (in analogy MPedestalCam)
+     - added new function InitAreas(const UInt_t i)
+     - added new function InitSectors(const UInt_t i)
+     - added new function GetNumAreas()
+     - added new function GetNumSectors()
+     - added new function ReCalc, computes the average values for the
+       sectors from all pixels which are not marked 
+       MBadPixelsPix::kUnsuitableRun
+
+   * mpedestal/MPedPhotPix.[h,cc]
+     - added a variable for the number of events from which the 
+       pedestals are computed
+
+   * manalysis/MGeomApply.cc
+     - changed initialization of MPedPhotCam
+
+   * msignal/MExtractTimeHighestIntegral.cc
+     - implemented the time calculation respective to the zero FADC
+       time sample, not respective to the first sample of the chosen
+       range
+
+   * msignal/MArrivalTimeCalc2.cc
+     - implemented the time calculation respective to the zero FADC
+       time sample, not respective to the first sample of the chosen
+       range
+
+
+
+ 2004/07/14: Markus Gaug
+
+   * msignal/MExtractedSignalBlindPixel.[h,cc]
+     - added new function GetNumBlindPixels()
+     - added more comments
+
+   * msignal/MExtractBlindPixel.[h,cc]
+     - adapted to new configuration of now three blind pixels
+     - runs with run number smaller than 31693 are treated in the old way
+     - runs with run number higher than 31693 have no more NSB filter, 
+       but possibility to choose between integral or amplitude (with spline) 
+       extraction. Default is amplitude.
+
+   * mcalib/MHCalibrationChargeBlindPix.[h,cc]
+     - use the variable fPixId to design an ID to the class. 
+       Later, a new class MHCalibrationChargeBlindCam can host 
+       the different blind pixels as individual 
+       MHCalibrationChargeBlindPix. 
+     - Default ID is 0 which is also default in MExtractedSignalBlindPix
+     - for current code, nothing has thus changed so far...
+
+   * msignal/MExtractAmplitudeSpline.cc
+     - fixed a bug causing a segmentation violation in the destructor 
+       (array dimension was not respected correctly)
+
+   * mcalib/MHGausEvents.cc
+     - removed an inconsistency in the naming of fHPowerProbability which 
+       can cause a memory leak (I hope, this was the cause of some of the 
+       leaks we had, but I'm not sure).
+     - removed the setting of fPixId to -1 in the Clear()
+
+
+
+ 2004/06/30: Thomas Bretz
+
+   * mbase/MEvtLoop.[h,cc]:
+     - overwrite ReadEnv with a new function taking the
+       name of the setup file as argument
+
+   * mjobs/MJPedestal.[h,cc]:
+     - added setup file name as argument to 
+
+   * mjobs/MJPedestal.[h,cc]:
+     - implemented a new data member fEnv
+     - implemented new setter SetEnv
+     - some small changes towards setup files
+     - some simplifications to line drawing
+
+   * msignal/MExtractor.[h,cc]:
+     - added ReadEnv member function
+     - removed obsolete virtual qualifiers in header
+     - simplified usage of Form()
+
+   * mraw/MRawFileWrite.[h,cc]:
+     - moved writing of RunHeaders from PreProcess to new ReInit
+
+
+
+ 2004/06/29: Thomas Bretz
+
+   * mpedestal/MPedCalcFromData.[h,cc]
+     - changed data member names according to coding rules
+
+
+
+ 2004/06/25: Pepe Flix
+
+   * mpedestal/MPedCalcFromData.[h,cc]
+     - added class to evaluate pedestal mean/RMS from real data events.
+       Low Gain samples used when no switch to LG happened.
+
+   * macros/PedCalcFromData.C
+     - added macro that uses the class to evaluate pedestals from real
+       data.
+
+
+
+ 2004/06/23: Markus Gaug
+
+   * macros/calibration.C
+     - added flag to skip the testing
+     - added calibration of pedestal files and creation of F2-files.
+
+   * macros/bootcampstandardanalysis.C
+     - updated to use MJExtractSignal
+
+   * mcalib/MHGausEvents.cc
+     - give a unique name to fHPowerProbability, otherwise 
+       MH::ProjectArray will use an existing one. 
+ 
+
+
+ 2004/06/18: Markus Gaug
+
+   * manalysis/MHPedestalCam.[h,cc]
+     - use flag to choose if one wants to re-normalize the histogram 
+       results
+
+   * mhist/MHCamera.[h,cc]
+     - added one argument to CntCamContent to tell if event above or 
+       below threshold have to be counted. Default is above, like before
+     - added one argument to Projection and ProjectionS giving the number 
+       of bins as argument (default 50 like before)
+
+   * mcalib/MCalibrationChargeCalc.cc
+     - replaced extraction of mean number of photo-electrons and mean 
+       F-Factor by a Gauss fit (instead of mean and RMS). Set the 
+       limit for deviating F-Factor from 3.5 to 4.5. This should reduce 
+       the number of uncalibrated pixels below 50 again (which was not 
+       the case in the last weeks). 
+
+   * mcalib/MHGausEvents.h
+     - make DrawEvents() public
+
+   * mcalib/MHCalibrationChargeLoGainPix.cc
+     - upper histogram limit lowered for the better visibility in the 
+       data check.
+
+   * mcalib/MHCalibrationChargeCam.[h,cc]
+     - adapted Draw for the datacheck
+
+   * mcalib/MHCalibrationChargeBlindPix.[h,cc]
+     - adapted for various blind pixels
+     - adapted Draw for the datacheck
+
+   * msignal/MExtractor.[h,cc]
+   * msignal/MExtractFixedWindow.[h,cc]
+   * msignal/MExtractSlidingWindow.[h,cc]
+   * msignal/MExtractFixedWindowPeakSearch.[h,cc]
+   * msignal/MExtractFixedWindowSpline.[h,cc]
+     - made sum in FindSignal() float which is now the variable used by 
+       the majority of the extractors.
+
+   * msignal/MExtractAmplitudeSpline.[h,cc]
+     - new extractor calculating the amplitude using a spline. 
+
+   * mcalib/MCalibrationPix.[h,cc]
+   * mcalib/MCalibrationChargePix.[h,cc]
+   * mcalib/MCalibrationChargeCalc.[h,cc]
+     - added debug flags and output on debug
+
+   * mbadpixels/MBadPixelsCam.cc
+     - enlarged the Print-function
+
+
+
+ 2004/06/17: Markus Gaug
+
+   * mjobs/MJPedestal.[h,cc]
+     - adapted display for the datacheck
+
+   * mcalib/MHCalibrationChargeCam.[h,cc]
+     - new function Draw for the datacheck
+     - new clone function for the DrawClone
+  
+   * mcalib/MHCalibrationCam.h
+     - make clone function virtual
+
+   * mjobs/MJCalibration.cc
+     - adapted display for the datacheck    
+  
+   * mcalib/MHGausEvents.h
+     - two new getters for fFirst and fLast
+
+   * mhist/MHCamera.h
+     - make SetUsed() and Fill(x,w) public. It is now possible to use the 
+       Fill-function together with the SetUsed(idx), when no 
+       SetCamContent(...) is available. 
+       Previously, only a Fill(x,y,w) was public, with x and y positions 
+       in the camera. 
+
+  * mjobs/MJPedestal.[h,cc]
+    - updated the data-check display
+
+
+
+ 2004/06/12: Abelardo Moralejo
+
+   * manalysis/MMcCalibrationUpdate.cc
+   * mcalib/MMcCalibrationCalc.[h,cc]
+     - Fixed mistake in the calibration which occurred only when 
+       different light collection efficiency was simulated for outer 
+       pixels.
+
+   * manalysis/MMcCalibrationUpdate.[h,cc]
+     - Adapted to the possibility of having different light collection
+       efficiencies in inner and outer pixels. For now we assume that the
+       dependence with incidence angle on the camera plane is the same
+       for both types of pixels.
+
+
+
+ 2004/06/12: Markus Gaug
+
+   * msignal/MExtractFixedWindow.cc 
+     - output the number and exact range of extraction to *fLog in the 
+       ReInit(), like it is done by MPedCalcPedRun
+
+   * macros/bootcampstandardanalysis.C
+     - exchanged MArrivalTimeCalc2 in 4th loop by timeext (defined 
+       in the beginning)
+
+
+
+ 2004/06/11: Markus Gaug
+
+   * mpedestals/MPedCalcPedRun.cc
+     - set the default upper range to 29, because otherwise the extraction
+       window will be made too small in case that more than 14 "high-gain" 
+       slices shall be extracted. This is a bugfix! It calculated wrong 
+       pedestals in case that the user says: SetRange(a,b), where b is 
+       bigger than 14 in combination with SetWindowSize(x) where x is bigger 
+       than 14 as well (instead of : SetRange(a,b,c,d), where 
+       everything went fine). However, the intention of the last months 
+       changes was to allow exactly also the first possibility. 
+
+   * mjobs/MJCalibration.cc
+     - put run 27474 in list of unavailable runs (see runbook)
+
+
+
+ 2004/06/08: Markus Gaug
+
+   * mhist/MHCamera.cc
+     - reduce number of default bins in AzimuthProfile
+     - use MatchSector in AzimuthProfile, like in RadialProfile
+
+   * mcalib/MCalibrationChargeCalc.cc
+     - fix lower limit for deviation F-Factor to 1.1. This discarts a 
+       smaller number of especially outer pixels in some runs taken with
+       the CT1 pulser box.
+
+
+
+ 2004/06/07: Markus Gaug
+
+   * mcalib/MHCalibrationCam.h
+     - add a function GetSize()
+
+   * msignal/MExtractTimeFastSpline.cc
+     - fixed a bug introduced on 1.6. and accelerate it a bit. 
+
+
+
+ 2004/06/04: Markus Gaug
+
+   * mcalib/MHGausEvents.cc
+     - some small modifications in the way the axes are drawn and their
+       titles are drawn.
+
+
+
+ 2004/06/03: Martin Merck
+
+   * msignal/MArrivalTimeCam.h
+   * msignal/MArrivalTime.h
+   * msignal/MArrivalTimePix.h
+   * msignal/MExtractedSignalCam.h
+   * msignal/MExtractedSignalPix.h
+   * msignal/MExtractedSignalPINDiode.h
+   * msignal/MExtractedSignalBlindPixel.h
+     - Set version in ClassDef to 1 for the streamer.
+
+   * msignal/SignalLinkDef.h
+     - Added a + at the pragma for MExtractedSignalCam and 
+       MExtractedSignalPix for consistency.
+
+   * msjobs/MExtractSignal.[h,cc]
+     - Added methods to set the Extractor and TimeExtractor to be
+       used when extracting the signal.
+
+
+ 
+ 2004/06/03: Markus Gaug
+
+   * mhist/MHCamera.[h,cc]
+   * mjobs/MJCalibration.cc
+     - added functions AzimuthProfile and DrawAzimuthProfile, same 
+       like the RadialProfile functions, only with azimuth instead of 
+       radius.
+
+   * mcalib/MCalibrationCam.[h,cc]
+     - replace fNumHiGainFADCSlices and fNumLoGainFADCSlices by a 
+       TArrayF and increment ClassDef by 1 for the streamer.
+
+   * mcalib/MCalibrationChargeCalc.cc
+     - found a small bug making a difference in the number of valid 
+       pixels with the blind PIxel method and the ffactor method. Now
+       fixed. (The difference was usually a couple of pixels)
+
+   * msignal/MExtractTime.h
+     - make members protected instead of private in order to allow 
+       classes to derive from it
+
+   * msignal/MExtractFixedWindow.cc
+     - added some documentation
+
+   * msignal/MExtractFixedWindowSpline.[h,cc]
+   * msignal/Makefile
+   * msignal/SignalLinkDef.h
+     - new fast spline signal extractor
+
+
+ 
+ 2004/06/02: Antonio Stamerra
+
+   * mtrigger/*:
+     - added directory and new classes to correctly handle the 
+	trigger-report string from report file. 
+	Not yet into the Makefile.
+
+
+
+ 2004/06/01: Thomas Bretz
+
+   * mbase/MLog.[h,cc]:
+     - some changes to Lock/UnLock of mutices. Necessary for Cosy.
+
+
+
+ 2004/06/01: Abelardo Moralejo
+
+   * msignal/MExtractFixedWindowPeakSearch.[h,cc]
+     - Added variable fLowGainPeakShift and setter. It allows to shift
+       the integration window for low gain with respect to the one of
+       the high gain. By default its value is 0 (corresponding to a 
+       total delay of 15 slices) so that default behaviour of the
+       extractor is the same as before.
+
+
+
+ 2004/06/01: Markus Gaug
+ 
+   * mjobs/MJCalibration.cc
+     - small change in the way the "full display" is displayed
+
+   * mcalib/MHCalibrationChargeBlindPix.cc
+   * mcalib/MHCalibrationChargePix.cc
+     - replace Draw(opt) by Draw(). This make the histograms reappear 
+       again, although I have no idea why. A printout of the opt gives 
+       always empty. 
+
+   * mcalib/MCalibrationQEPix.cc
+     - put Eckarts transmission of the plexiglass into the class 
+       documentation
+
+   * msignal/MExtractTimeFastSpline.cc
+     - fixed some smaller bugs affecting a small part of the signals
+
+
+ 2004/05/31: Hendrik Bartko
+
+   * msignal/MArrivalTimeCalc2.cc
+     - fixed a bug in pointer arithmetics found by Florian.
+
+
+
+ 2004/05/31: Raquel de los Reyes
+
+   * macros/DAQDataCheck.C
+     - committed the macro to check the raw data and display the quality
+       plots.
+
+
+
+ 2004/05/30: Markus Gaug
+
+   * mcalib/MCalibrationQEPix.[h,cc]
+     - added more documentation (plots)
+     - separated calls for light guides eff. , QE, and coll. eff.
+   
+   * mcalib/MCalibrationChargeCalc.[h,cc]
+     - fixed a small bug in the calculation of the error on the number 
+       of photons with the F-Factor method, did not include the division
+       by number of pixels for the precision of the QE. This does not 
+       affect the general analysis. 
+
+   * mjobs/MJCalibration.cc
+     - added runnumber 26924 to list of runs without clear colour in 
+       the file name. 
+
+
+
+ 2004/05/28: Markus Gaug
+
+   * macros/calibration.C
+     - make the macro compilable with possibility to run it in batch 
+       mode. 
+
+   * msignal/MExtractor.cc
+     - put an additional check in case that the number of FADC slices 
+       in the run header is smaller or equal to 0.
+
+
+
+ 2004/05/27: Javier Rico
+
+   * mbase/MDirIter.h 
+     - remove unneeded ResetIter method (Reset does all the job)
+
+   * mjobs/MJCalibration.cc
+     - change call to the removed MDirIter::ResetIter for Reset
+	
+
+
+ 2004/05/27: Markus Gaug
+
+   * mcalib/MHCalibrationChargeBlindPix.[h,cc]
+     - put some protection against zero-division in fitFuncMichele
+
+   * mcalib/MCalibrationChargeBlindPix.[h,cc]
+     - set flag to distinguish between coated and un-coated blind pixel
+     - increase ClassDef number by one.
+
+   * mcalib/MCalibrationQEPix.[h,cc]
+     - set a global variable CollEfficiency and LightguidesEfficiency. 
+       The more precise result for the QE calculated with 
+       the F-Factor method differs now by about 5% (while the statistical
+       error remains around 20%). 
+
+   * mcalib/MCalibrationChargeCalc.cc
+     - write the number of photons directy into MCalibrationChargeCam. 
+       These numbers would otherwise have to be assembled by different 
+       parts in separate code. 
+
+
+
+ 2004/05/27: Thomas Bretz
+ 
+   * mastro/MAstroCatalog.cc
+     - removed a statement after '#endif'
+
+   * mastro/MAstroCamera.h
+     - removed obsolete empty function which (believing the Changelog)
+       are not there at all!
+
+   * mbase/MDirIter.[h,cc]:
+     - moved code of Reset() funtion to source file
+     - added more comments to Reset function
+
+
+
+ 2004/05/26: Martin Merck
+
+   * mbase/MDirIter.cc
+     - changed MatchFilter to allow for filenames containing a '+'
+       character.
+
+
+
+ 2004/05/26: Markus Gaug
+
+   * mjobs/MJCalibration.[h,cc]
+     - set MCalibrationChargeBlindPix and MCalibrationChargePINDiode as 
+       data members and store them in the output of WriteResult()
+
+   * mcalib/MCalibrationQEPix.cc
+   * mcalib/MCalibrationChargeCalc.cc
+     - several small bugs fixed concerning calibration with the blind
+       pixel or the PIN Diode
+
+   * mjobs/MGCamDisplays.[h,cc]
+   * mhist/MHCamera.[h,cc]
+     - put the last function (CamDraw) of MGCamDisplays into MHCamera
+       and removed MGCamDisplays.
+
+   * mjobs/MJPedestal.[h,cc]
+   * mjobs/MJCalibration.[h,cc]
+   * mjobs/MJExtractCalibTest.[h,cc]
+     - don't derive from MGCamDisplays any more.
+
+   * msignal/MExtractBlindPixel.cc
+     - adjusted some default numbers for the current blind pixel
+
+   * msignal/MExtractedSignalBlindPixel.[h,cc]
+     - set extracted signal from UInt_t to Int_t (sometimes, less
+       than 0)
+
+   * mcalib/MCalibrationCam.h
+   * mcalib/MHCalibrationCam.h
+     - make destructors virtual. 
+
+   * mcalib/MHCalibrationCam.[h,cc]
+     - create a copy contructor
+
+
+
+ 2004/05/26: Javier Rico
+
+   * mbase/MDirIter.h
+     - Add method to reset the internal TIter iterator 
+
+   * mjobs/MJCalibration.cc
+     - In FindColorReset method, reset the file iterator before looping
+
+   * mimage/MNewImagePar.cc
+     - Add output lines in Print(const MGeomCam &geom) method for 
+       fInnerLeakage1, fInnerLeakage2 and fInnerSize
+
+
+
+ 2004/05/25: Raquel de los Reyes and Thomas Bretz
+
+   * mjobs/MJCalibration.cc
+     - uncommented the line to read .raw files.
+
+   * mraw/MRawFileRead.cc
+     - changed the PreProcess and Process functions to allow the analysis
+       of .raw files.
+
+   * mfileio/MReadReports.cc
+     - changed the Process function to read the updated root files.
+
+
+
+ 2004/05/25: Markus Gaug
+
+   * mjobs/MJCalibration.[h,cc]
+     - add possibility to switch on and off the blind pixel or pin diode
+       calibration
+     - fixed a small bug in reading the MCalibrationRelTimeCam when the
+       times calibration has been switched off.
+
+   * mjobs/MExtractSignal.[h,cc]
+     - made changes in MProcessFileP such that it fits with the new 
+       calibration. THIS IS ONLY A TEMPORARY SOLUTION. PEDESTALS AND 
+       DATA FILES MUST BE TREATED EQUALLY! OTHERWISE THERE IS NOT 
+       MATCHING FOR THE HIT CLEANING!!!
+
+   * mjobs/MJExtractCalibTest.[h,cc]
+     - implement switch to use or not the cosmics filter
+
+ 
+   * mcalib/MHCalibrationTestPix.cc
+     - enlarged the dynamic range of the histograms for the high-int. 
+       pulses
+
+
+
+ 2004/05/24: Javier Rico
+
+   * mpedestal/MPedPhotCalc.cc
+     - Correct a bug that made pedestals be assigned to the wrong pixel
+
+   * mimage/MNewImagePar.[h,cc]
+     - add getters and output lines in Print() method for 
+       fInnerLeakage1, fInnerLeakage2 and fInnerSize
+
+
+
+ 2004/05/24: Markus Gaug
+
+   * mcalib/MCalibrationChargePix.cc
+     - reduce limit in number of phe's from 5 to 1. since some pulses 
+       have less than 5 phe's now.
+
+   * mcalib/MHCalibrationTestCam.[h,cc]
+     - number of photons/area are now stored in TArray's in order to 
+       retrieve them easier in later processing from stored files.
+
+   * mcalib/MCalibrationCam.cc
+     - initialize AverageAreas and AverageSectors with the number of 
+       aidx and sector as SetPixId()
+
+   * mcalib/MCalibrationChargeCam.[h,cc]
+     - small modification in the Print()
+     - introduce data members to store the average number of photons by 
+       the three methods
+
+   * mcalib/MCalibrationChargeCalc.cc
+     - calculate the limits for acceptance of number of photo-electrons
+       for the calculation of the mean by normal mean instead of weighted 
+       mean. There were too many outliers still present in the weighted
+       mean such to modify the result by a sizeable amount.
+     - do not discard unreliable pixels any more in calculation of 
+       mean number of phe.s In some runs, there is simply too many of 
+       them in order to get reliable results.
+
+   * mpedestals/MPedCalcPedRun.cc
+     - put a condition if number of pixels in area index or in sector 
+       is zero, don't calculate av. pedestal and av. pedRMS of this part.
+
+
+
+ 2004/05/22: Markus Gaug
+
+   * mjobs/MJPedestal.[h,cc]
+   * mjobs/MJCalibration.[h,cc]
+   * mjobs/MJExtractCalibTest.[h,cc]
+     - replaced the TString GetOutputFile() functions by const char* 
+       GetOutputFile(). This apparenty caused a memory leak which is now 
+       removed.
+
+   * mcalib/MCalibrationChargePix.cc
+     - fixed bug calculating the reduced sigma for low-gain events: 
+       the electronics Ped.RMS was taken from Hi-gain pedestal events and 
+       too high. It is now divided by the factor 10. conversion between 
+       both samples, but this value is probably too optimistic. Needs 
+       more detailed studies, but does not exclude as many pixels as 
+       before. 
+
+   * mcalib/MHCalibrationChargePix.h
+   * mcalib/MHGausEvents.h
+     - put fSaturated from MHCalibrationChargePix into MHGausEvents
+
+   * mcalib/MHCalibrationChargeCam.[h,cc]
+   * mcalib/MHCalibrationCam.h
+     - put fNumHiGainSaturated and fNumLoGainSaturated from 
+       MHCalibrationChargeCam into MHCalibrationCam
+
+   * mcalib/MHCalibrationRelTimeCam.[h,cc]
+     - set flags fSaturated in order to distinguish if the hi-gain or 
+       the low-gain time has been extracted. 
+
+   * mcalib/MHCalibrationCam.cc
+     - remove cloning of all pixels on the Clone() function. This caused 
+       the need for three times more memory during runtime than now. It 
+       should not affect the current macros.
+
+   * macros/calibration.C
+     - added a debug switch with which you can print out Object
+       Allocation (like suggested by TBretz).
+
+   * mcalib/MCalibrationRelTimeCalc.[h,cc]
+     - replaced the relative limit for acceptance of the time resolution 
+       by an absolute limit
+     - set up output statistics logging (data written into DB)
+
+   * mcalib/MCalibrationChargeCalc.[h,cc]
+     - moved limit for acceptance of number of phe;s from 5 to 8
+     - set up output statistics logging (data written into DB)
+
+   * mjobs/MJCalibration.cc
+     - set up output statistics logging (data written into DB)
+
+
+
+ 2004/05/22: Abelardo Moralejo
+
+   * macros/calibrate_data.C
+     - removed wrong call to MPedCalcPedRun::SetExtractor, which does
+       not exist (should use MJPedestal like calibration.C, instead of 
+       a normal loop)
+
+   * msignal/MExtractFixedWindowPeakSearch.[h,cc]
+     - changed name of variable fOffsetFromPeak to fOffsetFromWindow
+       to avoid confusion.
+     - introduced initialization to 0 of startslice and sat in FindPeak
+     - changed initialization of maxsumhi in Process from 0 to -1e6
+
+
+
+ 2004/05/20: Raquel de los Reyes
+ 
+   * mraw/MRawRead.h
+   * mraw/Makefile
+   * msql/Makefile
+     - changed the inheritance of MRawRead class from MTask to MRead to
+       implement the AddFiles(MDirIter &) function in MRawFileRead class.
+
+   * mraw/MRawFileRead.[h,cc]
+     - implemented a second argument to the AddFile function and skip 
+       adding NULL files in the constructor.
+
+   * mjobs/MJPedestal.cc
+     - uncommented the line to allow the analysis of .raw files.
+
+
+
+ 2004/05/20: Markus Gaug
+ 
+   * mjobs/MJPedestal.cc
+     - put MGeomCamMagic into the plist (MGeomApply complained not to 
+       find the GeomCam(
+
+   * msignal/MExtractFixedWindowPeakSearch.cc
+     - fixed a bug affecting signals with late arrival times which use 
+       the variable fHiLoLast. 
+     - set back fgOffsetFromPeak from peak to 1 (instead of 2). Abelardo 
+       explained that this variable is not strictly the offset from the 
+       peak but the offset from the peak search window. 
+
+
+
+ 2004/05/19: Markus Gaug
+ 
+   * mcalib/MCalibrationChargeCam.cc
+     - replaced a small bug in Print() which gave a segmentation 
+       violation	
+
+   * mjobs/MJCalibration.cc
+     - use cosmics filter only for CT1 pulser runs
+
+
+
+ 2004/05/19: Abelardo Moralejo
+
+   * mbase/MGMap.cc
+     - replaced rint by TMath::Nint() (my Mac did not recognize the 
+       former)
+
+
+
+ 2004/05/19: Abelardo Moralejo
+
+   * macros/starmc2.C
+     - added third argument in adding MPointingPos to the output:
+       write.AddContainer("MPointingPos",  "Events", kFALSE);
+       If not exisiting in the input file, it is simply ignored.
+
+
+
+ 2004/05/15: Thomas Bretz
+
+   * mastro/MAstroCatalog.[h,cc]:
+     - changed Form to MString for thread safty
+     - fixed a bug which caused the construtor to crash in batch-mode
+     - added option argument to PaintImg
+
+   * mbase/MGMap.[h,cc]:
+     - added many new static member function to draw figures
+
+   * mbase/MParContainer.cc:
+     - changed Form to MString for thread safty
+
+   * mbase/MString.[h,cc]:
+     - added
+
+   * mbase/Makefile, mbase/BaseLinkDef.h:
+     - added MString
+
+
+
+ 2004/05/15: Markus Gaug
+
+   * msignal/MArrivalTimePix.h
+   * msignal/MArrivalTimeCam.cc
+     - introduced functin GetHiGainSaturation() in MArrivalTimePix.h
+     - added type in GetPixelContent() which asks for Hi-Gain saturation
+       and return the hi-gain time or the low-gain time, correspondingly.
+
+   * mbase/MGMap.cc
+     - fixed two bugs which did not complile under gcc 3.3.x introduced
+       by TB.
+
+
+
+ 2004/05/12: Markus Gaug
+
+   * msignal/MExtractTime.[h,cc]
+     - introduced intrinsic delay of low-gain, as measured by Florian. 
+
+   * mjobs/MJCalibration.cc
+   * mjobs/MJExtractCalibTest.cc
+     - fixed some errors in the storage of the rel. times.
+
+   * mjobs/MJExtractCalibTest.cc
+     - put the cosmics filter which was forgotten
+
+   * mcalib/MCalibrate.h
+     - changed default from Blindpixel to Ffactor     
+
+
+
+ 2004/05/12: Thomas Bretz
+
+   * mona.cc:
+     - changed names
+
+   * macros/sumcurrents.C:
+     - changed units from nA to \\mu A
+
+   *: mastro/MAstroCamera.[h,cc]:
+     - added '=' Draw option
+     - use fMapG directly
+
+   * mastro/MAstroCatalog.[h,cc]:
+     - added support to read and write a compressed catalog
+     - changed TExMap to new MGMap
+     - added support for HeasarcPPM catalog
+     - added PaintImg to paint catalog into a bitmap (used in
+       starguider software)
+     - don't clone MObservatory copy the contents
+     - changed type of dx and dy in DrawLine from Double to Int
+     - fixed drawig of the tooltip corresponding to the grid
+       (some were missing, some were existing twice)
+     - Now AddPrimitives takes fLimMag into account
+
+   * mhbase/MFillH.cc:
+     - added a const-qualifier
+
+   * mhist/MHCamera.cc:
+     - fixed a bug which caused SetPalette in the constructor to crash
+
+   * mbase/MGMap.[h,cc]:
+     - added
+
+   * mbase/Makefile, mbase/BaseLinkDef.h:
+     - added MGMap
+
+
+
+ 2004/05/11: Thomas Bretz
+
+   * mraw/MRawEvtHeader.cc:
+     - added a check whether the file has finished or not after
+     reading the first bytes.
+
+
+
+ 2004/05/10: Marcos Lopez
+
+   * mmontecarlo/MMcEnergyEst.cc: 
+     - In static void fcn(...), fixed the following bugs which caused a
+       "segmentation violation":
+     - Replace: MTaskList *tlist  = evtloop->GetTaskList()
+       by:      MTaskList *tlist = (MTaskList*)plist->FindObject("MTaskList")
+     - And get the pointer *eval to MParamterD("MFitResult"), after 
+       the excution of the Eventloop and not before it (since that object is 
+       created when calling the PreProcess).
+
+
+
+ 2004/05/10: Thomas Bretz
+
+   * mraw/MRawEvtHeader.[h,cc]:
+     - changed return type of ReadEvt from int to Int_t
+     - Enhanced output in case of invalid time
+
+   * mraw/MRawRead.cc:
+     - fixed the return type of ReadEvt (was bool instead of int)
+       which confused merpp completely in case of invalid times
+
+
+
+ 2004/05/10: Markus Gaug
+
+   * macros/calibrate_data.C
+     - updated setting of arr. time extractor
+
+
+
+ 2004/05/09: Thomas Bretz
+
+   * Makefile:
+     - added workaround for Mac to create so- and dynlib-object
+
+   * Makefile.conf.darwin:
+     - added necessary option to create both kind of files
+
+   * Makefile.conf.linux:
+     - changed the options to create so-object only
+
+   * Makefile.rules:
+     - added DYLIB to rmbin
+
+   * mraw/MRawEvtData.cc:
+     - changed some output
+
+   * mraw/MRawEvtHeader.[h,cc]:
+     - skip the rest of the header if the time is invalid. Otherwise
+       merpps force-mode will corrupt the data when further processing
+     - implemented GetNumBytes returning the size of the header
+
+
+
+ 2004/05/08: Thomas Bretz
+
+   * mona.cc:
+     - some changes to make it work again
+
+   * mraw/MRawSocketRead.cc:
+     - fixed the sync with what DAQ sends
+
+
+
+ 2004/05/07: Markus Gaug
+
+   * mcalib/MHCalibrationChargeHiGainPix.cc
+   * mcalib/MHCalibrationChargeLoGainPix.cc
+     - take out half of the bins for the hists in order to save memory  
+
+   * mjobs/MExtractCalibTest.cc
+     - include write-out of the containers in the loop
+
+   * mjobs/MJCalibration.cc
+     - take runs 20660 and 20661 into the list of known runs with colour
+       green.
+
+   * mpedestal/MPedCalcPedRun.[h,cc]
+     - make the arrays fSum and fSum2 doubles. This is necessary since 
+       rounding errors of the floats introduced significant errors in the 
+       RMS! 
+     - introduced one condition about possible window sizes of 0.
+
+
+
+ 2004/05/06: Markus Gaug
+
+   * htmldoc/images/PedestalStudyInner.gif
+   * htmldoc/images/PedestalStudyOuter.gif
+     - two gifs used for the documentation of MPedCalcPedRun  
+
+   * mpedestal/MPedCalcPedRun.cc
+     - updated documentation
+
+   * macros/pedestalstudies.C
+     - updated to the latest version of MPedCalcPedRun
+
+   * macros/bootcampstandardanalysis.C
+     - updated to the latest changes in the ArrivalTime Extraction
+
+
+
+ 2004/05/05: Markus Gaug
+
+   * mcalib/MHGausEvents.cc
+     - removed some warning saying "Cannot create Fourier spectrum"
+
+   * mcalib/MCalibrationChargePix.cc
+     - loosened the limits somewhat for calibration with the low-gain
+     - introduced different electronic noise for inner and outer pixels
+       (like seen in the data)
+
+   * mpedestal/MPedCalcPedRun.cc
+     - fixed a small inconsistency in case that the range goes out of 
+       the high-gain samples and reaches into the low-gain samples. In 
+       that case, the last slice of the high-gain was not taken (but the 
+       window size correctly)
+ 
+   * mjobs/MJExtractCalibTest.[h,cc]
+     - included setters for the time extractor
+
+   * mcalib/MCalibrationChargeCalc.cc
+     - set default of fgPheErrLimit from 4 sigma to 5.
+
+   * mcalib/Makefile
+   * mcalib/CalibLinkDef.h
+   * mcalib/MHCalibrationTestTimeCam.[h,cc]
+   * mcalib/MHCalibrationTestTimeCam.[h,cc]
+     - analogue to MHCalibrationTestCam, two classes to test the 
+       output of the calibration.
+
+   * mcalib/MHCalibrationCam.cc
+     - in InitHists, exclude only pixels with kUnsuitableRun, instead of 
+       all (IsBad())
+
+   * msignal/Makefile
+   * msignal/SignalLinkDef.h
+   * msignal/MExtractTimeFastSpline.[h,cc]
+     - new fast spline extractor for the equally spaced time slices. 
+       Searches for the position of the half maximum between maximum and 
+       pedestal. About 6 times faster than MArrivalTimeCalc
+
+   * mjobs/MJCalibration.cc
+     - changed names of the MHCameras to contain run name
+
+
+
+ 2004/05/04: Raquel de los Reyes
+ 
+   * mbase/MRunIter.[h,cc]
+     - Added a flag and a set function to read .raw files. 
+       The default option is set to read .root files.
+
+
+
+ 2004/05/04: Javier Rico
+ 
+   * mcalib/MCalibrate.cc
+     - when calibrating using kNONE, weight by the pixel area
+
+
+
+ 2004/05/04: Thomas Bretz
+ 
+   * macros/MagicHillas.C, macros/comprob.C, macros/derotatedc.C, 
+     macros/dohtml.C, macros/evtrate.C, macros/merpp.C, 
+     macros/pixfirerate.C, macros/pixsatrate.C, macros/plot.C, 
+     macros/plot2.C, macros/pointing.C, macros/readMagic.C, 
+     macros/rootlogon.C, macros/runbook.C, macros/sectorvstime.C, 
+     macros/star.C, macros/sumcurrents.C, macros/tar.C, 
+     macros/testenv.C, macros/weights.C:
+     - updated documentation
+
+   * mastro/MAstroCamera.[h,cc]:
+     - added member function to read MC .def files for mirror geometry
+     - added GetDiffZdAz
+
+   * mastro/MObservatory.[h,cc]:
+     - added Copy-member function
+
+   * mbase/MLog.[h,cc]:
+     - updated handling of mutices
+     - added a new mutex to lock the stream
+
+   * mhist/MHCamera.[h,cc]:
+     - added functionality to linear deform the camera display
+       (to correct for abberation)
+
+   * mtools/MFFT.cc:
+     - added more documentation
+
+   * mbase/MTime.[h,cc]:
+     - renamed overloaded Set-function to SetMjd. There were some
+       trouble with the interpreter and the new naming is more
+       intuitive.
+
+
+
+ 2004/05/04: Markus Gaug
+ 
+   * mcalib/MHCalibrationChargeBlindPix.cc
+     - intialized the 2 vectors differently, now they don't give 
+       warnings any more.
+
+   * msignal/MExtractor.cc
+   * msignal/MExtractFixedWindow.cc
+     - put one initialization to 0 into the MExtractor
+
+   * mastro/MAstroCatalog.h
+     - make AlignCoordinates() protected, in order to compile
+
+   * mcalib/MHGausEvents.cc
+     - took out fEvents(0) and fHGausHist() from constructor
+
+   * msignal/MExtractor.cc
+   * msignal/MExtractPINDiode.cc
+     - fixed StreamPrimitive
+
+   * msignal/MExtractBlindPixel.[h,cc]
+     - deriving from MExtractor, possibility to filter NSB events
+
+ 
+
+ 2004/05/03: Thomas Bretz
+
+   * mbase/MRunIter.cc:
+     - AddRuns(char*) added some const-qualifiers
+     - replaced deprecated if-else-if by continue- and return-
+       constructions
+
+
+
+ 2004/05/03: Javier Lopez
+ 
+   * mbadpixels/MBadPixelsPix.[h,cc]
+     - put another enum for hardware malfunctionning. Started to be 
+       filled with kHVNotNominal
+
+
+
+ 2004/05/03: Markus Gaug
+
+   * mcalib/MHCalibrationBlindPix.[h,cc]
+     - removed a "->" behind the comment
+     - Create a TVector in Draw only if the array is not zero
+
+   * mraw/MRawEvtPixelIter.cc
+     - corrected bug in GetIdxMaxLoGainSamples() which looped over 
+       one slice too much 
+	end = fLoGainPos + fNumLoGainSamples + 1 replaced by:
+	end = fLoGainPos + fNumLoGainSamples
+
+   * msignal/MTimeExtractor.[h,cc]
+   * msignal/MExtractTime.[h,cc]
+     - changed name for alphabetical display in dox
+
+   * mjobs/MJCalibration.[h,cc]
+   * msignal/MExtractTimeSpline.h
+   * msignal/MExtractTimeHighestIntegral.h
+     - changed name of base class to MExtractTime
+
+   * mcalib/MCalibrationCam.[h,cc]
+   * mcalib/MCalibrationChargeCam.[h,cc]
+   * mcalib/MCalibrationRelTimeCam.[h,cc]
+     - put the number of unsuitable and unreliable pixels in the base
+       class
+
+   * mcalib/MCalibrationRelTimeCalc.[h,cc]
+     - fixed a bug calculating the average time resolution
+ 
+   * mpedestals/MPedestalPix.[h,cc]
+     - add a dedicated fValid flag in order to be able to discard pixels 	 
+       from outside (e.g. from MBadPixelsCam)
+
+   * mpedestals/MPedCalcPedRun.[h,cc]
+     - catch badpixels cam from parameter list, if existing and set 
+       corresponding pixels to not valid in MPedestalPix
+
+   * mjobs/MGCamDisplays.[h,cc]
+   * mhist/MHCamera.[h,cc]
+     - put DrawProjection and DrawRadialProfile in MHCamera
+
+   * macros/dohtml.C
+     - include directory mfit and macros calibration.C and 
+       bootcampstandardanalysis.C
+     - take out pixvstime.C which does not exist
+
+   * msignal/MExtractFixedWindow.[h,cc]
+   * msignal/MExtractSlidingWindow.[h,cc]
+   * msignal/MExtractFixedWindowPeakSearch.[h,cc]
+   * msignal/MExtractor.[h,cc]
+   * msignal/MExtractPINDiode.[h,cc]
+   * msignal/MExtractTime.[h,cc]
+     - set number of slices not in base class, but in derived one. 
+       Like this, extractors setting their signal in other containers 
+       don't have a conflict with the ReInit() in MExtractor.
+
+
+
+ 2004/05/01: Thomas Bretz
+
+   * macros/rootlogon.C:
+     - ignore MARSSYS if libmars.so is found in the current path
+
+   * mastro/MObservatory.cc:
+     - small change to coordinates
+
+   * mbase/MLog.[h,cc]:
+     - enhanced output in case of problem with mutices
+
+   * mtemp/TempIncl.h, mtemp/TemlLinkDef.h:
+     - removed everything
+
+   * Makefile*, */Makefile
+     - changed all to support mtemp/mifae and similar
+
+
+
+ 2004/05/01: Abelardo Moralejo
+
+   * mmain/MEventDisplay.cc
+     - changed back integration range for MC to 0-14 slices to avoid 
+       confusions.
+
+
+
+ 2004/05/01: Markus Gaug
+
+   * macros/dohtml.C
+     - include directory mpedestal
+
+   * msignal/MExtractFixedWindow.[h,cc]
+   * msignal/MExtractSlidingWindow.[h,cc]
+   * msignal/MExtractFixedWindowPeakSearch.[h,cc]
+   * msignal/MExtractor.[h,cc]
+     - include the possibility to set the range for the hi-gain outside
+       the range of MRawEvtPixelIter::GetNumHiGainSamples() and to take 
+       the "low-gain" slices instead. This is necessary for the March 
+       data!
+
+   * mjobs/MJCalibration.[h,cc]
+     - accept arrival time extractors deriving from MTimeExtractor
+
+
+
+ 2004/04/30: Thomas Bretz
+
+   * mastro/MAstroCamera.[h,cc]:
+     - removed obsolete TList data member (use a argument in
+       GetStarList instead)
+
+   * mbase/MTime.h:
+     - added 'istream &operator<<(istream &in, MTime &t)'
+
+   * mbase/BaseLinkDef.h:
+     - added new operator
+
+
+
+ 2004/04/30: Daniela Dorner
+  
+   * macros/pointing.C
+     - implemented plot: Control Deviation vs Time
+     - rearranged plots
+
+
+
+ 2004/04/30: Markus Gaug
+
+   * mcalib/MCalibrationRelTimeCalc.[h,cc]
+     - new class to treat rel. times after fits
+
+   * mcalib/MCalibrationChargeCalc.[h,cc]
+     - search for outliers in the total F-Factor and set a flag in 
+       MBadPixelsPix
+
+   * mcalib/MCalibrationRelTimeCam.h
+     - new TArrayIs to store number of unsuitable and unreliable pixels
+   
+
+   * mbadpixels/MBadPixelsPix.h
+     - two new flags added: kDeviatingFFactor and kDeviationTimeResolution
+  
+   * mcalib/MHCalibrationRelTimePix.[h,cc]
+     - take out commented part of code related to re-normalization
+
+   * mcalib/MHCalibrationCam.[h,cc]
+     - retrieve the used run numbers in order to store them in teh 
+       histogram titles to help transparency of the displays
+
+   * mcalib/MHCalibrationRelTimeCam.[h,cc]
+     - Getter and Setter for the reference pixel
+
+   * mcalib/MCalibrate.cc
+     - make error of nphot to be taken from square root of absolute 
+       number of photons instead of number of photons, otherwise 
+       NaN's are obtained
+
+   * msignal/MExtractPINDiode.[h,cc]
+     - now deriving from MExtractor
+
+   * msignal/Makefile
+   * msignal/SignalLinkDef.h
+   * msignal/MExtractTimeSpline.[h,cc]
+   * msignal/MExtractTimeHighestIntegral.[h,cc]
+     - replacements for MArrivalTimeCalc and MArrivalTimeCalc2
+
+   * mjobs/MJCalibration.[h,cc]
+     - Set time extractor by pointer 
+
+
+
+ 2004/04/29: Thomas Bretz
+
+   * mbase/MTask.cc:
+     - fixed behaviour of GetNumExecutions. Because of a root bug
+       Count returns a number which is to high by 1.
+
+
+
+ 2004/04/29: Abelardo Moralejo
+
+   * mmc/MMcEvt.hxx
+     - Added minor comment (explanation of fPassPhotCone).
+
+   * mmc/MMcRunHeader.[hxx,cxx]
+     - Removed obsolete parameters fSourceOffsetTheta, fSourceOffsetPhi
+     - Updated class version to 5.
+
+
+
+ 2004/04/29: Nadia Tonello
+
+   * mbadpixels/MBadPixelsTreat.h
+     - changed enums {.. BIT(1), ... BIT(2), ... BIT(3) } in {1,2,3}
+       to have the right behaviour of the flags (and of SetProcessRMS)
+
+   * manalysis/MCT1PointingCorrCalc.[h,cc]
+     - added pointing correction for 1ES1959
+
+
+
+ 2004/04/29: Markus Gaug
+
+   * msignal/MArrivalTimePix.[h,cc]
+     - removed flag fLoGainUsed which is not used at all
+
+   * msignal/MTimeExtractor.[h,cc]
+     - new base class for arrival time extractors
+   
+   * msignal/Makefile
+   * msignal/SignalLinkDef.h
+   * msignal/MExtractTimeSpline.[h,cc]
+     - replacement of MArrivalTimeCalc, derived from MTimeExtractor
+
+
+   * msignal/MExtractor.h
+     - make SetRange virtual
+     - check for range w.r.t. ranges given in the run header in ReInit
+
+   * msignal/MExtractFixedWindow.[h,cc]
+   * msignal/MExtractSlidingWindow.[h,cc]
+   * msignal/MExtractFixedWindowPeakSearch.[h,cc]
+     - overload the SetRange() function in order to do the necessary 
+       checks of the range there. Slight differences in every extractor
+       because of the floating windows.
+
+
+   * mpedestals/MPedCalcPedRun.[h,cc]
+     - add the possibility to set ranges and extraction windows. Default
+       is what has always been
+
+
+   * mjobs/MJPedestals.[h,cc]
+     - add the possibility to set a signal extractor which gives the 
+       extraction ranges to MPedCalcPedRun
+     - derive from MHCamDisplays
+
+   * mcalib/MCalibrationChargeCam.cc
+     - updated the Print() a little
+
+
+ 2004/04/29: Javier Rico
+
+   * mbase/MRunIter.cc
+     - Remove AddRuns(const char*,const char*) dependence on length of 
+       first character chain
+
+	
+ 2004/04/28: Javier Rico
+
+   * mbase/MRunIter.[h,cc]
+     - include function to read runs specified in a character chain
+       with the format, e.g., run1,run2-run3,run4-run5,...
+
+
+
+ 2004/04/28: Abelardo Moralejo
+
+   * macros/starmc.C
+     - adapted to change in MC calibration: replaced 
+       MMcCalibrationCalc::GetHist by GetHistADC2PhotEl and 
+       GetHistPhot2PhotEl.
+
+
+
+ 2004/04/28: Markus Gaug
+ 
+   * mjobs/MGCamDisplays.cc
+   * mjobs/MJCalibration.cc
+     - introduced new "fit" flag in DrawProjection allowing to draw 
+       two separate pad with the (fitted) histograms for inner and 
+       outer pixels. This is displayed by MJCalibration if the 
+       kNormalDisplay option is chosen (default).
+
+   * mjobs/MJCalibration.h
+     - took out the const of GetBadPixels() in order to allow compilation
+       of macros/bootcampstandardanalysis.C. This will change again soon 
+       when mjobs/MJExtraction is updated and used there. 
+
+   * msignal/MArrivalTimeCalc.[h,cc]
+     - remove the ReInit() which calls to an MGeomCam which is later not 
+       used
+
+   * macros/calibrate_data.C
+     - fixed a bug in loop 3 taking the default QE Cam instead of the 
+       one filled by MJCalibration 
+
+   * msignal/MExtractor.[h,cc]
+     - new base class for signal extractors
+
+   * msignal/Makefile	
+   * msignal/SignalLinkDef.h	
+   * msignal/MExtractFixedWindow.[h,cc]
+   * msignal/MExtractSlidindWindow.[h,cc]
+   * msignal/MExtractFixedWindowPeakSearch.[h,cc]
+     - replacements for MExtractSignal, MExtractSignal2, MExtractSignal3
+
+   * macros/calibration.C
+   * macros/calibrate_data.C
+   * macros/pedphotcalc.C
+   * macros/bootcampstandardanalysis.C
+     - adapted to new extractors
+
+   * mbadpixels/MBadPixelsPix.h
+     - set back the old definition of IsOK(), namely no information 
+       available
+
+
+
+ 2004/04/27: Raquel de los Reyes
+
+   * mhvstime/MHVsTime.cc
+     - added a line in the Fill function to avoid empty time events.
+
+
+
+ 2004/04/27: Abelardo Moralejo
+
+   * mcalib/MMcCalibrationCalc.[h,cc]
+     - added histogram which stores the conversion of photons before 
+       the plexiglas to photoelectrons hitting first dynode.
+
+   * macros/mccalibrate.C
+     - added MPointingPosCalc to the tasklist to create and fill an 
+       MPointingPos object, and later write it to the Events tree of 
+       the calibrated MC files. Added some comments and simplified
+       some lines. One more histogram from MMcCalibrationCalc (see
+       above) is now written to the output.
+
+   * macros/starmc2.C
+     - added the writing of MPointingPos to output star file.
+
+
+
+ 2004/04/27: Markus Gaug
+
+   * mjobs/MJCalibration.[h,cc]
+     - put the three camera drawing facilities into a separate base 
+       class MGCamDisplays
+
+   * mjobs/MGCamDisplays.[h,cc]
+   * mjobs/Makefile
+   * mjobs/JobsLinkDef.h
+     - camera drawing facilities: CamDraw, DrawProjection and 
+       DrawRadialProfile, used by all jobs
+
+   * mjobs/MJExtractCalibTest.[h,cc]
+   * mjobs/Makefile
+   * mjobs/MJobsLinkDef.h
+     - new class to test the calibration results
+
+   * mcalib/MCalibrationChargeCalc.cc
+     - set unsuitable pixels to excluded in MCalibrationChargePix, which 
+       will not display them in the status display
+
+   * mjobs/MJCalibration.cc
+     - take out display of previously excluded pixels 
+
+   * mbadpixels/MBadPixelsCam.cc
+     - set val to 1 in case that GetPixelContent is true, before display 
+       was not correct
+
+   * macros/calibration.C
+     - added the test class MJExtractCalibTest
+
+
+
+ 2004/04/27: Abelardo Moralejo
+
+   * mhistmc/MHMcCollectionArea.[h,cc]
+     - Added fMCAreaRadius and setter to allow changing the radius of
+       the circular area in which MC events are produced. Useful for
+       instance for stereo configuration studies. By default it is 300 m
+       as was assumed before.
+
+
+
+ 2004/04/26: Markus Gaug
+
+   * mcalib/MHCalibrationTestPix.[h,cc]
+   * mcalib/MHCalibrationTestCam.[h,cc]
+   * mcalib/Makefile
+   * mcalib/CalibLinkDef.h
+     - two new histogram classes to perform claibraion checks, will be 
+       especially useful for the data-check.
+
+   * mcalib/MCalibrationQEPix.cc
+     - found a bug in the setting of validity flags of colours. This 
+       made the QE used for calibration uncorrect by about a factor 1.5 
+       for the outer pixels if only one colour is used for calibration.
+
+   * mjobs/MJCalibration.[h,cc]
+     - moved colour finder from the macros into this class with the 
+       function FindColor()
+     - had to add ~MJCalibration() {} because otherwise, I get a 
+       segmentation violation in the destructor, the debugger says in 
+       some TString. Maybe it's because of the GetDescriptor() in  
+       ~MParContainer() ?
+
+   * macros/calibration.C
+   * macros/calibrate_data.C
+   * macros/pedphotcalc.C
+   * macros/bootcampstandardanalysis.C
+     - removed function FindColor()
+
+   * mcalib/MCalibrationCam.h
+     - make Init() and InitSize() virtual
+
+   * mcalib/MCalibrationChargeCam.[h,cc]
+     - introduce two TArrayI's for the number of uncalibrated and 
+       unreliable pixels.
+
+   * mcalib/MCalibrationChargeCalc.[h,cc]
+     - calculate and store the above numbers.
+
+   * mbadpixels/MBadPixelsPix.[h,cc]
+   * mbadpixels/MBadPixelsCam.cc
+     - removed bits: kHiGainNotCalibrated and kLoGainNotCalibrated
+     - added bits: kDeviatingFFactor, kConversionHiLoNotValid
+     - removed functions: IsCalibrationResultOK() 
+	and IsCalibrationSignalOK()
+     - changed function IsOK() such that it returns false only if 
+       the pixels is not suitable (run or evt)
+
+   * mcalib/MCalibrate.cc
+   * mcalib/MCalibrateRelTime.cc
+     - exchanged query for IsCalibrationResultOK() to 
+       IsUnsuitableRun(MBadPixelsPix::kUnsuitableRun). This includes 
+       now the oscillating pixels (which are sometimes many!!)
+
+   * mcalib/MHCalibrationRelTimePix.cc
+     - commented re-normalization to ns in Renorm()
+     - introduced Getter to fFADCSliceWidth
+
+   * mcalib/MHCalibrationRelTimeCam.cc
+     - renorm to ns in GetPixelsContent()
+     --> now, calibration in MCalibrateRelTimes is consistent
+
+
+
+ 2004/04/26: Abelardo Moralejo
+
+   * manalysis/MMcCalibrationUpdate.cc
+     - changed from 1 to 10 the "dummy" value of conversion high to low 
+       gain for old camera 0.6 files. Usually these files have no low 
+       gain at all, but there was a patched version of the program 
+       which did have low gain (with a gain 10 lower than hg).
+
+
+
+ 2004/04/25: Abelardo Moralejo
+
+   * mbadpixels/MBadPixelsTreat.cc
+     - Change in line 204:    if ((*fBadPixels)[i].IsBad()) by
+       if ((*fBadPixels)[j].IsBad())   The way it was done, it never
+       worked, because the check on whether the neighbour pixels
+       were OK was performed on the same pixel to be treated (i), which 
+       is obviously not OK. The same problem fixed in the interpolation 
+       of pedestals. Amazingly, this error would have shown up in any
+       test of the class.... I assume it must have been commited 
+       completely untested.
+
+     - In InterpolateSignal: moved division of summed charge over 
+       number of pixels : put it after the check of the number of 
+       valid neighbours to avoid division by 0.
+
+
+
+ 2004/04/23: Markus Gaug
+
+   * mcalib/MHCalibrationCam.cc
+     - fixed a bug in the ReInit() for the number of average events in 
+       each area index and sector
+
+
+ 2004/04/23: Thomas Bretz
+
+   * */Makefile:
+     - added some more mpedestal
+
+   * mreport/MReportRun.cc:
+     - changed to work with the latest version of report-files
+       --> This will make it incompatible with older report files
+           (for this use older Mars versions for merpping)
+
+   * mbase/MStatusDisplay.[h,cc]:
+     - added combo-box to surf through tabs in MARS-tab
+
+
+
+ 2004/04/22: Nadia Tonello
+
+   * mcalib/MCalibrateData.cc
+     - changed request for MBadPixelsPix::IsCalibrationResultOK() for 
+       MBadPixelsPix::IsUnsuitable(MBadPixelsPix::kUnsuitableRun)
+
+
+
+ 2004/04/22: Thomas Bretz
+
+   * mhist/MHCamera.[h,cc]:
+     - implemented SetUsed
+
+   * merpp.cc:
+     - added "-ff" and interleave mode - both not execcively tested yet
+
+   * mhbase/MFillH.cc:
+     - added a missing 'endl'
+
+   * mraw/MRawCrateData.[h,cc], mraw/MRawEvtData.[h,cc],
+     mraw/MRawEvtHeader.[h,cc]
+     - added SkipEvt (the number of skipped bytes is untested)
+
+   * mraw/MRawEvtHeader.[h,cc]
+     - return kCONTINUE if time is invalid
+
+   * mraw/MRawFileRead.[h,cc]:
+     - implemented AddFile feature - first draft!
+     - added feature to skip events
+
+   * mraw/MRawFileWrite.h:
+     - changed default compression level corresponding to merpp to 2
+
+   * mraw/MRawRead.[h,cc]:
+     - added fForceMode flag to be able to suppress event errors
+
+   * mbadpixels/MBadPixelsTreat.[h,cc]:
+     - changes such that the pedestal interpolation is now done
+       only in ReInit. If you need the old behaviour call
+       SetProcessRMS()
+
+   Another step towards less mess:
+   
+   * MMcPedestalCopy.[h,cc], MMcPedestalNSBAdd.[h,cc],
+     MPedPhotCalc.[h,cc], MPedPhotCam.[h,cc], MPedPhotPix.[h,cc],
+     MPedCalcPedRun.[h,cc], MPedestalCam.[h,cc],
+     MPedestalPix.[h,cc]:
+     - moved from manalysis to mpedestal
+
+   * mpedestal/Makefile, mpedestal/PedestalLinkDef.h,
+     mpedestal/PedestalIncl.h:
+     - added
+
+   * manalysis/Makefile, manalysis/AnalysisLinkDef.h,
+     manalysis/AnalysisIncl.h:
+     - removed files above
+
+   * mbadpixels/Makefile:
+     - added mpedestals
+
+   * Makefile:
+     - added mpedestals
+
+
+ 2004/04/22: Antonio Stamerra
+
+   * mmain/MEventDisplay.cc
+     - Added new tab "Trigger" adding a new MHEvent (evt9), 
+	filled through the MMcTriggerLvl2 container.
+	A new MFillH task for evt9 and MMcTriggerLvl2Calc task 
+	have been added. 
+
+   * mhist/MHEvent.[h,cc]
+     - Added new event type kEvtTrigPix
+
+   * manalysis/MMcTriggerLvl2.[h,cc]
+     - The class now inherits from MCamEvent
+     - Added the methods GetPixelContent and DrawPixelContent (from MCamEvent)
+     - Added the method IsPixelInTrigger that returns kTRUE if a pixels 
+	is in the trigger region
+
+   * manalysis/MMcTriggerLvl2Calc.[h,cc]
+     - Added the methods CheckRunType and ReInit to check if the file is MC.
+
+   * mhistmc/Makefile
+     - Added the include for mgui
+
+
+ 2004/04/22: Markus Gaug
+
+   * mcalib/MCalibrate.[h,cc]
+     - introduced flat-fielding of charges for the muon calibration, 
+       accessible with SetCalibrationMode(kFlatCharge)
+
+   * manalysis/MPedCalcPedRun.cc
+     - added a SetReadyToSave() at the end of PostProcess
+   
+   * mjobs/Makefile
+     - added include of mraw
+
+   * mjobs/MJCalibration.cc
+     - added MRawFileRead for option SetDataCheck()
+
+   * mjobs/MJPedestal.cc
+     - added MRawFileRead for option SetDataCheck()
+
+
+ 2004/04/21: Thomas Bretz
+
+   * mbase/MTask.cc,  mbase/MTaskList.cc:
+     - let MTask in list fTaskProcess to be used as a counter
+
+   * mdata/MDataChain.[h,cc]:
+     - added some treatments for combinations of +/- signs
+
+   * mfbase/MFilterList.[h,cc]:
+     - added a new constructor to simplyfy filter-inversions
+
+   * mfileio/MReadReports.cc:
+     - added comment
+
+   * mhbase/MBinning.[h,cc]:
+     - added new constructor to simplify calls in macros
+
+   * mhbase/MFillH.[h,cc]:
+     - added fDrawOption to be used in MStatusDisplay
+
+   * mhist/MHFalseSource.cc:
+     - added comment
+
+
+
+ 2004/04/20: Thomas Bretz
+
+   * macros/derotatedc.C
+     - added tutorial macro plotting derotated dc currents
+
+   * mhist/MHCamEventRot.[h,cc]:
+     - added histogram to be filled with derotated MCamEvents
+
+
+
+ 2004/04/18: Abelardo Moralejo
+
+   * mgeom/MGeomCam.h
+     - Update class version to 4 (necessary after M. Gaug's change 
+       of the type of member fMaxRadius.
+
+
+
+ 2004/04/16: Abelardo Moralejo
+
+   * mcalib/MCalibrationQEPix.[h,cc]
+     - Added fAverageQE. Same role as gkDefaultAverageQE, but can be 
+       changed via SetAverageQE. Made public GetAverageQE and 
+       GetAverageQERelVar (this changes needed for MC).
+
+   * mcalib/MMcCalibrationCalc.[h,cc]
+   * manalysis/MMcCalibrationUpdate.[h,cc]
+     - Adapted to M. Gaug's changes in calibration classes. Behaviour
+       has been tested to be the same as before those changes. Now the
+       conversion factor from ADC counts to photoelectrons, and the
+       average QE (photons->photoelectrons) are calculated independently 
+       (and later combined by MCalibrate to obtain the conversion 
+       ADC->photons).
+
+   * mmain/MEventDisplay.cc, macros/mccalibrate.C, starmc.C
+     - Added call to MExtractSignal::SetSaturationLimit(240)  Affects 
+       only MC display. This was necessary because if electronic noise
+       is simulated in the FADC, sometimes saturated slices look not
+       saturated due to negative fluctuations, so it is better to set 
+       the saturation limit at a safe value (240 ADC counts). Changed 
+       signal integration range (only for MC), now from slices 5 to 10.
+
+   * msignal/MExtractSignal3.[h,cc]
+     - Changed name of function SetRange for the more adecquate 
+       "SetWindows". No change in behaviour of the function.
+
+
+
+ 2004/04/16: Markus Gaug
+
+   * msignal/MExtractSignal.cc
+     - commited proposed larger default window from fgLast = 10 to 
+       fgLast = 14, because in March the pulses have moved to later 
+       arrival times.
+     - removed some inconsistency with slice numbering in FindSignal() 
+       from pixel.GetHiGainSamples()+fHiGainFirst-1 to 
+       pixel.GetHiGainSamples()+fHiGainFirst and also for the low gain
+
+   * msignal/MExtractSignal2.cc
+     - committed the proposed smaller window egdes from fgFirst=0 to 
+       fgFirst = 3, because in March some of the high-gain pulses reach 
+       into the "low-gain samples" and mislead thus sliding window to 
+       be maximized on the tail of the high-gain pulse.
+
+   * mcalib/MHPedestalPix.cc
+     - fixed a bug which made normalization to values per slice not happen
+
+   * macros/pedestalstudies.C
+     - fixed and documented
+
+
+
+ 2004/04/15: Markus Gaug
+
+   * macros/calibration.C
+     - added a function FindColor() to extract the colour by filename, 
+       works if there is indeed a colour or if the run nubmer is smaller 
+       than 20000 -> take ct1
+
+   * macros/bootcampstandardanalysis.C
+   * macros/pedphotcalc.C
+   * macros/calibrate_data.C
+     - updated the macro to the cvs-standard used at the Udine bootcamp
+
+   * mcalib/MCalibrateRelTimes.[h,cc]
+   * mcalib/Makefile
+   * mcalib/CalibLinkDef.h
+     - new class to calibrate the relative times
+
+   * manalysis/MGeomApply.cc
+     - added MArrivalTime::Init()
+
+   * msignal/MArrivalTime.[h,cc]
+     - added array fDataErr
+ 
+   * macros/rootlogon.C
+     - added directories mbadpixels and mjobs
+
+   * mcalib/MCalibrationQEPix.cc 
+     - set the fAvNorm variables to 1 in Clean()
+
+   * manalysis/MPedPhotCalc.[h,cc]
+     - included possibility to use an MBadPixelsCam
+
+
+
+ 2004/04/14: Thomas Bretz
+
+   * manalysis/MCerPhotEvt.[h,cc]:
+     - fixed a bug which caused a missing last pixel (in most cases
+       Index 576)
+
+   * manalysis/MCerPhotPix.cc:
+     - fixed output in Print
+
+   * macros/mccalibrate.C, mmain/MEventDisplay.cc:
+     - added missing SetCalibrationMethod
+
+   * mbadpixels/MBadPixelsCam.[h,cc]:
+     - added copy constructor
+
+   * mbadpixels/MBadPixelsMerge.cc:
+     - added comments
+
+   * mraw/MRawRunHeader.[h,cc]:
+     - added new run-type (kRTPointRun=7)
+
+   * mmain/MEventDisplay.cc:
+     - fixed the broken cleaning levels
+
+
+
+ 2004/04/14: Markus Gaug
+  
+   * mcalib/MCalibrationQEPix.cc
+     - found a bug in the calculation of the error, fixed
+
+   * macros/mccalibrate.C, mmain/MEventDisplay.cc:
+     - replaced SetCalibrationMethod by SetCalibrationMode
+
+   * htmldoc/images/CalibClasses.gif
+   * htmldoc/images/RelTimeClasses.gif
+     - two schemes used in the class descriptions
+
+   * mcalib/MHCalibrationCam.[h,cc]
+     - included function GetAverageAreas() and GetAverageSectors() like 
+       in MCalibrationCam
+
+   * mjobs/MJCalibration.[h,cc]
+     - included calibration of rel.Times, to be chosen with a flag 
+       RelTimeCalibration()
+     - signal extractor and arrival time extractor can be chosen by 
+       flags as well (see Class description)
+
+
+   * mbadpixels/MBadPixelsCam.cc
+     - add two new types in GetPixelContent, add documentation of 
+       GetPixelContent
+
+   * msignal/MArrivalTimeCalc2.cc
+     - commented the warning for pixels with lowgain saturation
+
+
+
+ 2004/04/13: Markus Gaug
+
+   * macros/dohtml.C
+     - included directory mbadpixels
+
+   * mcalib/MCalibrationPix.[h,cc]
+     - add functions GetHiLoMeansDivided(), GetHiLoSigmasDivided() and 
+       errors
+
+   * mcalib/MCalibrationChargeCam.[h,cc]
+     - removed hi-vs.Lo histograms (come into a separate MIntensityCam) 
+     - updated GetPixelContents
+     - updated class documentation
+
+   * mgeom/MGeomMirror.h
+     - include <TVector3.h>, otherwise it does not compile on my machine  
+
+   * mjobs/MJPedestals.cc
+   * mjobs/MJCalibration.cc
+     - replaced MBadPixelsMerge by MParList.AddToList(fBadPixels) until 
+       bug in MBadPixelsMerge is resolved (see bugtracker).
+
+   * mcalib/MHCalibrationChargePINDiode.cc
+     - return in Draw() if histogram is empty (otherwise segm. violation 
+       in eventloop
+
+   * msignal/MExtractedSignalCam.cc
+     - intialize variables by default to 0. 
+
+   * mcalib/MHCalibrationChargeCam.[h,cc]
+     - pointer to fSig is not stored, somehow, when running MJCalibration
+       Don't know why. Removed and stored some variables instead
+
+   * mjobs/MJCalibration.[h,cc]
+     - updated documentation, updated QE Cam
+     - set the pulser colour (now obligatory)
+     - set the possibility to choose different displays
+ 
+   * mcalib/MCalibrationChargeCalc.cc
+     - set the pulser colour (now obligatory)
+
+   * mcalib/MCalibrationChargePix.[h,cc]
+     - put GetRSigmaPerCharge into this class
+
+
+
+ 2004/04/13: Thomas Bretz
+
+   * mastro/MAstroCamera.cc, mastro/MAstroCatalog.[h,cc]:
+     - enhanced comments
+     - added some new features
+     
+   * mbase/MAGIC.h:
+     - removed some empty lines
+     
+   * mfileio/MWriteRootFile.cc:
+     - fixed a compiler warning
+     
+   * mgeom/MGeomCorsikaCT.h:
+     - removed obsolete include of TArrayF
+
+   * mgeom/MGeomMirror.[h,cc]:
+     - replaced fReflector by *fReflector
+
+   * mmain/MGDisplayAdc.cc:
+     - fixed a bug which caused the wrong histogram entry to be
+       displayed
+
+
+
+ 2004/04/10: Markus Gaug
+  
+   * macros/dohtml.C
+     - included directory mjobs
+
+   * mjobs/MJCalibration.[h,cc]
+     - added and updated documentation (not yet ready)
+
+   * htmldoc/images/CalibClasses.gif
+     - scheme of the calibration classes, used for documentation in 
+       MJCalibration.cc
+
+
+
+ 2004/04/10: Thomas Bretz
+
+   * mastro/MAstroCatalog.[h,cc], mastro/MAstroCamera.[h,cc]:
+     - added comments
+
+   * macros/starfield.C:
+     - added
+
+   * mastro/Makefile, mastro/AstroLinkDef.h
+     - added MAstroCamera
+
+
+
+ 2004/04/09: Markus Gaug
+
+   * mcalib/MHCalibrationChargePINDiode.[h,cc]	
+   * mcalib/MHCalibrationChargeCam.[h,cc]	
+   * mcalib/MHCalibrationChargeCalc.[h,cc]	
+     - put abs. time consistency check from MCalibrationChargeCalc into 
+       MHCalibrationChargePINDiode and MHCalibrationChargeCam
+
+   * mcalib/MHCalibrationCam.[h,cc]	
+   * mcalib/MHCalibrationChargeCalc.[h,cc]	
+     - number of used FADC slices also stored in MHCalibrationCam, 
+       MHCalibrationChargeCalc needs no pointer to the signal extractors
+       any more -> removed
+
+   * mcalib/MCalibrationChargePINDiode.[h,cc]	
+   * mcalib/MCalibrationChargeBlindPix.[h,cc]	
+   * mcalib/MCalibrationCam.[h,cc]	
+     - put a default pulser color kNONE
+
+   * manalysis/MPedestalCam.[h,cc]
+   * manalysis/MPedCalcPedRun.[h,cc]
+   * manalysis/MGeomApply.cc
+     - added average pixels in the way like it is done in MCalibrationCam
+
+
+
+ 2004/04/08: Thomas Bretz
+
+   * mfbase/MF.cc:
+     - optimized output
+
+   * mfbase/MFilterList.cc:
+     - added some comments
+
+   * mfileio/MReadMarsFile.[h,cc], mfileio/MReadTree.[h,cc]:
+     - added SortFiled-option -- RAQUEL, this is for you!
+
+   * mfileio/MWriteRootFile.cc:
+     - class AddSerialNumber in AddContainer
+
+   * mhist/MHFalseSource.[h,cc]:
+     - optimized setting of hist maximum
+     - added more source dependant cuts
+     - changed display layout
+     - scale number of entries to correct for different acceptance
+       (not perfect, but the best I can currently do)
+
+   * mimage/MHHillasExt.[h,cc]:
+     - added new histogram for fMaxDist
+
+   * mimage/MHNewImagePar.[h,cc]:
+     - added new histograms for Used/CoreArea
+
+   * mimage/MHillasCalc.cc:
+     - optimized output
+
+   * mimage/MHillasExt.cc:
+     - fMaxDist got a sign
+
+   * mimage/MNewImagePar.[h,cc]:
+     - enhanced comments
+     - added new Print() member function
+
+   * macros/readCT1.C, macros/readMagic.C, mmain/MEventDisplay.cc:
+     - forward geomcam to newimgepar.Print()
+
+
+
+ 2004/04/08: Markus Gaug
+
+   * mcalib/MCalibrationChargeCalc.[h,cc]
+   * mcalib/MCalibrationChargeCam.[h,cc]
+   * mcalib/MCalibrationChargePix.[h,cc]
+   * mcalib/MCalibrationChargeBlindPix.[h,cc]
+   * mcalib/MCalibrationChargePINDiode.[h,cc]
+     - put calculation of photon fluxes with the three methods into 
+       MCalibrationChargeCalc
+     - reorganized calculations in a better readable way (hopefully!)
+
+   * mbase/MAGIC.h
+   * mcalib/MCalibrationCam.[h,cc]
+   * mcalib/MCalibrationQECam.[h,cc]
+   * mcalib/MCalibrationQEPix.[h,cc]
+     - put PulserColor_t away from MAGIC.h into MCalibrationCam
+     - full implementation of the QE-calibration from MCalibrationQEPix
+
+   * msignal/MExtractBlindPixel.cc
+     - removed warning about low-gain saturation of Blind pixel
+
+   * mcalib/MCalibrate.[h,cc]
+   * mcalib/MCalibrateData.[h,cc]
+   * mcalib/MMcCalibrationCalc.[h,cc]
+   * manalysis/MMcCalibrationUpdate.[h,cc]
+     - conversion factors now separated into FADC2phe and then into 
+       call to average Quantum efficiency. 
+
+
+ 2004/04/07: Markus Gaug
+
+   * mcalib/MHGausEvents.[h,cc]
+     - added fBlackout events
+
+
+
+ 2004/04/06: Thomas Bretz
+
+   * mcalib/MCalibrationCam.[h,cc]:
+     - simplified call to initialization by new function Init()
+
+   * mcalib/MH*.cc:
+     - fixed some warnings (comparision between signed and unsigned)
+
+   * manalysis/MGeomApply.cc:
+     - use new Init-funtion of MCalibrationCam
+
+   * mastro/MAstro.cc:
+     - some fixes to the conversion functions
+
+   * mastro/MAstroCamera.[h,cc]:
+     - added comments
+     - changed argument type of AddPrimitives
+     
+   * mastro/MAstroCatalog.[h,cc]:
+     - many changes to make it possible to overlay the
+       catalog on top of a 2D histogram
+     
+   * mbase/MEvtLoop.cc:
+     - fixed estimation of run-time
+
+   * mbase/MMath.[h,cc]:
+     - added member functions for signed significances
+
+   * mbase/MParContainer.cc:
+     - changed GetterMethod() to support double reference data mebers
+
+   * mbase/MStatusDisplay.cc:
+     - removed some obsolete debug outputs
+
+   * mbase/MTask.[h,cc]:
+     - removed fNumExecutions, fStopwatch already counts the calls
+     - slight chagnes to output of PrintStatistics
+
+   * mbase/MTaskList.[h,cc]:
+     - slight chagnes to output of PrintStatistics
+     
+   * mbase/MTime.cc:
+     - removed +TwoPi from GetGmst
+
+   * mcamera/MCameraAUX.h, mcamera/MCameraHV.h, mcamera/MCameraLV.h,
+     mcamera/MCameraLid.h, mcamera/MCameraLids.h,
+     mcamera/MCameraPowerSupply.h:
+     - added missing Getter functions
+
+   * mcamera/MCameraHV.h:
+     - removed obsolete data-meber fMean
+
+   * mdata/DataLinkDef.h:
+     - added MDataFormula
+
+   * mdata/MDataChain.cc, mdata/Makefile:
+     - enhanced dosumentation
+     - implemented use of multi argument functions
+     - added ^-operator
+
+   * mdata/MDataList.[h,cc]:
+     - added ^-operator
+     - enhanced IsValid
+
+   * mfbase/MFilterList.cc:
+     - changed a warn-output to inf
+
+   * mgeom/MGeomCam.[h,cc]:
+     - added getter returning index corresponding to XY
+
+   * mgeom/MGeomPix.[h,cc]:
+     - added getter IsInside
+
+   * mhist/MHCamera.cc:
+     - Return 0 in GetMean if no entries
+
+   * mhist/MHFalseSource.[h,cc]:
+     - removed conversion stuff (mm/deg) 
+     - slight change to calculation of significance
+     - added dist-cuts
+     - added histogram showing number of entries
+     - added display of catalog
+
+   * mhist/MHStarMap.cc:
+     - added comment
+     
+   * mimage/MHillasExt.[h,cc]:
+     - changed class version to 3
+     - added new data-member fMaxDist
+     
+   * mimage/MNewImagePar.[h,cc]:
+     - added new data member fUsedArea and fCoreArea
+
+   * mmc/MMcConfigRunHeader.h:
+     - readded GetMirrors (WHY WAS IT GONE?)
+
+   * mpointing/MPointingPos.[h,cc]
+     - implemented Getter to get coordinates in rad
+     
+   * mpointing/MSrcPosCalc.[h,cc]:
+     - fixed direction of rotation
+     - for the moment do use fTime
+
+
+
+ 2004/04/06: Markus Gaug
+ 
+   * mcalib/MCalibrationChargePix.[h,cc]
+     - change names of the GetLoGain*() functions to 
+       GetConvertedLoGain*() for better clarity
+
+   * mcalib/MCalibrationChargeCam.[h,cc]
+     - updated and enlarged documentation
+
+   * mcalib/MHCalibrationChargeCam.cc
+   * mcalib/MHCalibrationRelTimeCam.cc
+     - set the arrays by use of memset
+     - initialize TObjArrays with the Init-Function
+
+
+ 2004/04/05: Markus Gaug
+
+   * msignal/MExtractedSignalPINDiode.h
+     - new function GetLastUsedSlice()
+
+   * mcalib/MCalibrationChargeCalc.[h,cc],
+   * mcalib/MCalibrationChargeCam.cc:
+     - holds also pointers to MExtractedSignalPINDiode and 
+       MExtractedSignalBlindPixel and does the checks inside the task 
+       (instead of inside the containers)
+
+   * mcalib/MCalibrationChargeBlindPix.[h,cc],
+   * mcalib/MCalibrationChargePINDiode.[h,cc]:
+     - updated and enlarged documentation
+
+   * mcalib/MHCalibrationChargePINDiode.cc
+   * mcalib/MHCalibrationChargeCam.[h,cc]
+     - rename Setter for fMeanVar from SetMeanErr() to SetMeanVar()
+     - rename arrays of fAverageSigmaErr to AverageSigmaVar
+
+   * mcalib/MCalibrationPix.[h,cc]
+   * mcalib/MCalibrationChargePix.[h,cc]
+   * mcalib/MCalibrationChargeBlindPix.[h,cc]
+   * mcalib/MCalibrationChargePINDiode.[h,cc]
+     - add Getters to the relative variance
+
+   * mcalib/MHGausEvents.[h,cc]
+   * mcalib/MCalibrationPix.[h,cc]
+   * mcalib/MHCalibrationCam.cc
+     - add to Pickup also Blackout events
+
+
+ 2004/04/05: Nadia Tonello
+
+   * mbadpixels/MBadPixelsTreat.cc
+     - In Unmap(): replaced SetPixelUnused with SetPixelUnmapped 
+
+
+
+ 2004/04/02: Markus Gaug
+
+   * mcalib/MCalibrationPix.[h,cc], mcalib/MCalibrationCam.[h,cc],
+     mcalib/MCalibrationQEPix.[h,cc], mcalib/MCalibrationQECam.[h,cc],
+     mcalib/MCalibrationRelTimeCam.[h,cc],
+     mcalib/MCalibrationRelTimePix.[h,cc]:
+     - updated and enlarged documentation
+
+   * mcalib/MHGausEvents.[h,cc], mcalib/MHPedestalPix.[h,cc],
+     mcalib/MHCalibrationChargePix.[h,cc],
+     mcalib/MHCalibrationChargeHiGainPix.[h,cc],
+     mcalib/MHCalibrationChargeLoGainPix.[h,cc],
+     mcalib/MHCalibrationChargeBlindPix.[h,cc],
+     mcalib/MHCalibrationChargePINDiode.[h,cc]:
+     - put fPixId, fPickup, fPickupLimt, CountPickup(), RepeatFit() and 
+       ChangeHistId() into MHGausEvents (before in the derived classes)
+     - put fChargeNbins, fChargeFirst, fChargeLast, 
+
+   * mcalib/MHCalibrationRelTimePix.[h,cc]:
+     - put fRelTimeNbins, fRelTimeFirst, fRelTimeLast together 
+       into MHGausEvents as fNbins, fFirst and fLast
+
+   * mcalib/MHCalibrationRelTimePix.[h,cc]:
+     - remove Renormalization to time slices. Need to think about 
+       more direct way to implement
+
+   * mcalib/MHPedestalCam.[h,cc], mcalib/MHCalibrationCam.[h,cc],
+     mcalib/MHCalibrationChargeCam.[h,cc],
+     mcalib/MHCalibrationRelTimeCam.[h,cc]:
+     - put most of the functionality into the base class MHCalibrationCam
+     - derived classes overload the functions SetupHists, ReInitHists, 
+       FillHists, FinalizeHists and FinalizeBadPixels. 
+     - functions FitHiGainArrays, FitLoGainArrays, FitHiGainHists, 
+       FitLoGainHists and InitHists can be used from base class. 
+
+   * mcalib/MCalibrationPix.[h,cc], mcalib/MCalibrationChargePix.[h,cc],
+     mcalib/MCalibrationRelTimePix.[h,cc]:
+     - put most of the functionality into the base class MCalibrationPix
+     - other two classes derive now from MCalibrationPix
+
+   * mcalib/MCalibrationCam.[h,cc], mcalib/MCalibrationChargeCam.[h,cc]
+     mcalib/MCalibrationRelTimeCam.[h,cc]:
+     - put most of the functionality into the base class MCalibrationCam
+     - other two classes derive now from MCalibrationCam
+     - calls to MCalibration*Cam[i] now have to cast!
+
+   * mcalib/MCalibrate.cc, mcalib/MCalibrateData.cc,
+   * mcalib/MMcCalibrateCalc.cc, manalysis/MMcCalibrationUpdate.cc,
+   * mcalib/MCalibrationChargeCalc.cc:
+     - cast calls to MCalibration*Cam[i]
+
+   * manalysis/MGeomApply.cc
+     - add initialization MCalibrationRelTimeCam
+     - add intialization of average pixels
+
+
+
+ 2004/04/02: Abelardo Moralejo
+
+   * msignal/MExtractSignal3.[h,cc]
+     - added. Alternative method for signal extraction. Uses sliding 
+       window from event to event, but a common window for all pixels 
+       in an event.
+
+   * msignal/Makefile, SignalLinkDef.h
+     - added MExtractSignal3.
+
+
+
+ 2004/04/02: Markus Gaug
+
+   * mbadpixels/MBadPixelsPix.h
+     - added kRelTimeNotFitted and kRelTimeOscillating to Calibration_t 
+       enum
+ 
+   * mcalib/MCalibrationCam.[h,cc], mcalib/MCalibrationPix.[h,cc],
+     mcalib/Makefile, mcalib/CalibLinkDef.h:
+     - two new base classes for general calibration storage containers,
+       contain average pixel storage functionality
+
+   * mcalib/MCalibrationRelTimeCam.[h,cc],
+     mcalib/MCalibrationRelTimePix.[h,cc]:
+     - new storage container for the rel. time calibration results, derive
+       from MCalibrationPix, MCalibrationCam
+
+
+
+ 2004/04/01: Markus Gaug
+
+   * msignal/MArrivalTimeCalc.[h,cc]
+     - set fSaturationLimit as a variable with default (instead of 0xff)
+
+   * mcalib/MHCalibrationChargeCam.[h,cc]
+     mcalib/MCalibrationChargeCam.[h,cc]
+     mcalib/MCalibrationChargeCalc.cc, manalysis/MGeomApply.cc:
+     - add average pixels per sector
+
+   * mcalib/MHGausEvents.[h,cc], mcalib/MHCalibrationChargePix.[h,cc],
+     mcalib/MHCalibrationRelTimePix.[h,cc]:
+     - moved BypassFit() function to MHGausEvents
+
+   * mcalib/MHCalibrationChargeCam.[h,cc]:
+     - updated and enlarged documentation
+     - derives now from mcalib/MHCalibrationCam
+
+   * mcalib/MCalibrationChargePix.[h,cc]:
+     - removed flag kLoGainSaturation, because it is already in MBadPixelsPix
+
+   * mcalib/MCalibrationCam.[h,cc], mcalib/Makefile, mcalib/CalibLinkDef.h:
+     - new base class for all MHCalibration*Cam object, contains the average
+       pixel functionality
+
+
+
+ 2004/03/31: Markus Gaug
+
+   * mcalib/MHCalibrationChargeCam.[h,cc],
+     mcalib/MCalibrationChargeCam.[h,cc],
+     mcalib/MCalibrationChargeCalc.cc, manalysis/MGeomApply.cc:
+     - make the average pixel independent on camera geometry, i.e.
+       one average pixel per MGeomPix::Aidx
+
+
+
+ 2004/03/31: Abelardo Moralejo
+
+   * mmc/MMcConfigRunHeader.[h,cc]
+     - updated to current version (3) in camera program. Added member
+       fLightCollectionFactorOuter so that we can store the data on 
+       the simulatedlight collection efficiency (light guides + 
+       plexiglas +...) as a function of incidence angle for outer and 
+       inner pixels independently. Added getters for this information
+       on light collection efficiency.
+
+
+
+ 2004/03/30: Markus Gaug
+ 
+   * mcalib/MHGausEvents.[h,cc],
+     mcalib/MHCalibrationChargePix.[h,cc],
+     mcalib/MHCalibrationChargeHiGainPix.[h,cc],
+     mcalib/MHCalibrationChargeLoGainPix.[h,cc],
+     mcalib/MHCalibrationChargeBlindPix.[h,cc],
+     mcalib/MHCalibrationChargePINDiode.[h,cc],
+     mcalib/MHCalibrationRelTimeCam.[h,cc],
+     mcalib/MHCalibrationRelTimePix.[h,cc],
+     mcalib/MHPedestalPix.[h,cc],
+     mcalib/MHPedestalCam.[h,cc]:
+     - updated and enlarged documentation
+
+
+
+ 2004/03/30: Abelardo Moralejo
+
+   * mmc/MMcFadcHeader.hxx
+     - updated to current version (4) in camera program.
+
+
+
+ 2004/03/29: Markus Gaug
+  
+   * manalysis/MSourcePosFromStarPos.cc
+     - replaced fabs(ival) by TMath::Abs(ival)
+
+   * mbadpixels/MBadPixelsPix.h
+     - adopt treatment of UnCalibrated_t like the one in Unsuitable_t 
+
+   * mbadpixels/MBadPixelsPix.cc
+     - put some documentation in the header
+
+   * mcalib/MHCalibrationChargeCam.cc
+     mcalib/MCalibrationChargeCam.cc
+     mbadpixels/MBadPixelsCam.cc
+     - adopt to new style in MBadPixelsPix.h
+
+   * mcalib/MCalibrationChargeCalc.[h,cc]
+     mcalib/MCalibrationChargePix.[h,cc]
+     - move consistency checks from Pix to Calc
+
+   * mcalib/MHGausEvents.[h,cc]
+     - fixed axes for event and fourier spectrum Draw
+
+   * mcalib/MHCalibrationChargePix.[h,cc] 
+     mcalib/MHCalibrationChargeCam.[h,cc] 
+     - moved definition of pulser frequency to MHCalibrationChargeCam
+
+
+
+ 2004/03/24: Thomas Bretz
+
+   * mbase/MMath.cc:
+     - now SignificanceLiMa returns 0 in case sum==0
+
+
+
+ 2004/03/23: Thomas Bretz
+
+   * mbase/MContinue.cc, mhbase/MH.cc:
+     - changed a warning message to an inf-message
+
+   * mfileio/MReadTree.cc:
+     - added an additional logging message when adding files to a
+       chain successfully.
+
+   * mbase/MProgressBar.cc:
+     - fixed initial size
+
+   * mastro/MAstro.[h,cc]:
+     - changed the code for the rotation angle back to its original
+       shape. The definition I tried to introduced was already
+       correctly implemented (assuming that sin is the x-component
+       of the vector I had it wrong in my mind twice, using
+       atan2(y,x) everywhere I did recognize it...)
+
+   * mreport/MReport.cc:
+     - fixed a bug which caused a crash when the time is not valid
+
+   * mhist/MHStarMap.cc, mpointing/MSrcPosCalc.cc:
+     - fixed: v.Roatete() must be v=v.Rotate()
+     - MHStarMap no waorks also without MSrcPosCam, MPointingPos
+       or MObservatory (leaving out the corresponding translations)
+
+
+
+ 2004/03/22: Markus Gaug
+
+   * mfileio/Makefile, mimage/Makefile
+     - mpointing included
+
+
+
+ 2004/03/22: Thomas Bretz
+ 
+   * mpointing/MSrcPosCalc.[h,cc], MSrcPosCam.[h,cc]: 
+     - added
+     
+   * mastro/MAstro.[h,cc]:
+     - added code to calculate rotationangle previously in MObservatory
+     - changed definition of rotation angle such, that it is now 
+       180deg if Ra and Az grid is parallel
+
+   * mastro/MAstroCatalog.[h,cc]:
+     - fixes and enhancements to the display (such as misscalculated
+       number of grid lines, title display, etc)
+     - enhancements to the output
+     - generalized creation of grid - for further usage
+
+   * mastro/MAstroSky2Local.[h,cc]:
+     - replaced calculation of rotation angle by the function in
+       MAstro
+
+   * mastro/MObservatory.[h,cc]:
+     - small changes to Print output
+     - moved code for calculation of rotation angle to MAstro
+
+   * mbase/MEvtLoop.cc:
+     - do not output number of events per second if no events processed
+     
+   * mbase/MParList.cc:
+     - updated some comments
+     
+   * mfileio/MCT1ReadAscii.cc, mfileio/MCT1ReadPreProc.cc,
+     mfileio/MReadRflFile.cc, mraw/MRawFileRead.cc,
+     mreport/MReportFileRead.cc:
+     - output error string if file cannot be opened
+     
+   * mfileio/MReadTree.cc:
+     - output name of chain which is scanned
+
+   * mimage/MConcentration.cc:
+     - replaced loop by iterator
+     - removed obsolete (unused) variables
+     
+   * mimage/MHNewImagePar.[h,cc]:
+     - fixed display colors
+
+   * mpointing/MPointingPos.[h,cc]:
+     - added member function to calculate rotation angle
+     - added comments
+
+   * mpointing/Makefile:
+     - added include MAstro
+
+   * manalysis/MSrcPosCam.[h,cc]:
+     - moved to mpointing
+
+   * mpointing/MSrcPosCalc.[h,cc]:
+     - added: Derotates a star in the camera into MSrcPosCam
+
+   * mpointing/Makefile, mpointing/PointingLinkDef.h:
+     - added MSrcPosCam
+     - added MSrcPosCalc
+
+   * manalysis/Makefile, manalysis/AnalysisLinkDef.h:
+     - removed MSrcPosCam
+
+   * mmain/Makefile:
+     - added include for mpointing
+
+   * manalysis/AnalysisIncl.h:
+     - removed TVector2
+
+   * mbase/MParContainer.h:
+     - added new abstract virtual member function SetVariables
+       (to be used in fits)
+     - addeed some text to class description
+
+   * mdata/MData.cc:
+     - added comment
+     
+   * mdata/MDataArray.[h,cc], mdata/MDataElement.h,
+     mdata/MDataList.[h,cc], mdata/MDataMember.h,
+     mfbase/MFDataMember.[h,cc], mfbase/MFilterList.[h,cc]:
+     - added SetVariables
+
+   * mdata/MDataChain.[h,cc]:
+     - added support for indexed variables [i]
+     - added SetVariables
+
+   * mdata/MDataValue.[h,cc]: 
+     - added support for variable values (through SetVariables)
+     - added support for an index
+     - added SetVariables
+
+   * mfbase/MF.[h,cc]:
+     - removed support for {}. This case is now detected
+       automatically
+     - added SetVariables
+     - added support for expressiond like 
+       "MHillas.fLength<2*MHillas.fWidth"
+
+   * mfbase/MFDataChain.[h,cc]:
+     - added fCond data member
+     - addednew constructor to support fCond
+     - added support for new condition type
+     - adapted Print and GetRule
+
+   * mimage/MNewImagePar.[h,cc]:
+     - added some comments
+
+   * mhist/MHStarMap.[h,cc]: 
+     - fixed to use the correct MPointingPos instead of the
+       deprecated MMcEvt. Use MPointingPosCalc to copy the
+       pointing position from MMcEvt to MPointingPos
+
+   * mbase/MMath.[h,cc]:
+     - added, which currently only implements calculation of
+       significance and Li/Ma significance
+
+   * mbase/Makefile, mbase/BaseLinkDef.h:
+     - added MMath
+
+
+
+ 2004/03/19: Markus Gaug
+
+   * mcalib/MHCalibrationChargePix.cc
+     - added some style to the default Draw in order to see the 
+       label and axis titles better
+
+   * mcalib/MHCalibrationChargeCam.[h,cc]
+     - store and display more information on the average pxiels
+
+   * mcalib/MCalibrationCam.cc
+     - the GetPixelContent flag were not correct any more, fixed them 
+       
+   * macros/calibration.C
+     - fixed GetPixelContent flags
+     - draw radial profile of the variables
+
+   * mjobs/MJCalibration.cc
+     - fixed GetPixelContent flags
+     - introduced RadialProfile for some displays
+     - removed some not so important displays
+
+   * manalysis/MGeomApply.cc
+     - included MCalibrationQECam to be initialized
+
+   * mcalib/MCalibrationChargePix.[h,cc],
+     mcalib/MCalibrationQEPix.[h,cc]:
+     - replace DefinePixId by SetPixId
+   
+   * mcalib/MCalibrationChargeCalc.[h,cc]
+     - added MCalibrationQECam
+     - cleaned the code up a little
+     - give more information at the end
+
+   * mcalib/MCalibrationChargePix.[h,cc]
+     - took out fNumLoGainSampels whihc is not needed any more because 
+       conversion is only done in the getters
+     - Canceled function ApplyLoGainConversion (for same reason)
+
+   * msignal/MExtractSignal2.cc
+     - remove uncommented piece of code
+
+   * msignal/MExtractSignal.cc, msignal/MExtractSignal2.cc:
+     - remove warning about pixel with low gain saturation, 
+       now in MBadPixelsPix
+
+   * mbadpixels/MBadPixelsPix.[h,cc], mcalib/MCalibrationChargeCam.cc:
+     - added new flag: kDeviatingNumPhes
+
+   * mcalib/MCalibrationChargePix.cc
+     - check for mean arr. time in last bin replaced by check in last 
+       two bins
+
+   * mcalib/MCalibrationChargePix.[h,cc], 
+     mcalib/MCalibrationChargeCam.cc,
+     mcalib/MHCalibrationChargeCam.cc:
+     - removed flag kHiGainFitted, kLoGainFitted, since they are
+       available from MBadPixelsPix
+
+   * macros/calibration.C, macros/calibrate_data.C
+     - a few flags from MCalibrationChargeCam::GetPixelContent were wrong, 
+       corrected them
+
+
+
+ 2004/03/18: Raquel de los Reyes
+
+   * macros/DAQDataCheck.C
+     - macro to check the data from the DAQ system (.raw files).
+
+
+
+ 2004/03/18: Thomas Bretz
+ 
+   * manalysis/AnalysisIncl.h:
+     - added TVector2
+
+   * manalysis/MSrcPosCam.[h,cc]:
+     - added Getter/Setter using TVector2
+
+   * mhbase/MH.cc:
+     - fixed GetMinimumGT for TH2 and TH3
+
+   * mpointing/MPointingPos.h:
+     - added Getter/Setter for Ra/Dec
+
+   * mpointing/MPointingPosCalc.cc:
+     - fill Ra/Dec into MPointingPos
+
+
+
+ 2004/03/18: Markus Gaug
+
+   * mgeom/MGeomCam.[h,cc]
+     - replace fMaxRadius by a TArrayF of pixel area types
+     - new TArrayF fMinRadius of each pixel area type
+     - backward compatibility should be given, 
+       call to GetMaxRadius() returns the value for the whole camera
+       (which corresponds to the previous value for the Magic camera)
+
+   * mimage/MConcentration.cc
+     - fixed on flog to fLog in order to compile
+
+
+
+ 2004/03/17: Thomas Bretz
+
+   * mastro/MAstroCatalog.[h,cc]:
+     - some simplifications and changes
+
+   * mastro/MAstroCatalog.[h,cc]:
+     - some simplifications and changes
+
+   * mastro/MAstroSky2Local.[h,cc]:
+     - rotation matrix from sky to local coordinates
+     - added
+
+   * mastro/Makefile, mastro/AstroLinkDef.h:
+     - MAstroSky2Local added
+
+   * mraw/MRawEvtPixelIter.cc:
+     - GetIdxMaxLoGainSample(const Byte_t lofirst) const
+       accelerated and fixed (the first slice was compared to itself
+       and the last slice was not taken into account)
+
+   * manalysis/MCerPhotAnal2.cc:
+     - fixed a bug in the new treatment of lo-gains
+
+   * mhvstime/MHPixVsTime.cc:
+     - fixed missing initialization of fTypeErr in constructor
+
+   * mimage/MHillas.[h,cc]:
+     - implemented member function which returns MeanX/Y as TVector2
+
+   * mimage/ImageIncl.h:
+     - added TVector2
+
+   * manalysis/MCerPhotEvt.[h,cc]:
+     - fixed a bug in AddPixels which - in some special circumstances -
+       cutted pixels with high pixel indices
+
+
+
+ 2004/03/17: Antonio Stamerra
+
+   * macros/datatrigcheck.C
+     - added macro for time and trigger data-checking
+
+
+
+ 2004/03/17: Abelardo Moralejo
+
+   * manalysis/MSourcePosfromStarPos.cc
+     - added cast fabs((Double_t)ival), line 703. Otherwise it does not
+       compile.
+
+   * macros/starmc.C
+     - added parameter accepted_fraction to select fraction of events 
+       to be processed (useful to make smaller outputs).
+
+
+
+ 2004/03/17: Wolfgang Wittek
+
+   * manalysis/MSigmabar.[h,cc]
+     - correct calculation of sector, which was wrong 
+
+
+
+ 2004/03/16: Markus Gaug
+ 
+   * mhist/MHCamera.[h,cc]
+     - added function RadialProfile which returns a TProfile of the 
+       value along the radius from the camera center
+
+
+
+ 2004/03/16: Oscar Blanch Bigas
+
+   * mimage/MConcentration.[h,cc]
+     - new class for Concentration stuff.
+     - It computes and stores Concentration 1-8
+
+   * mimage/MNewImagePar.[h,cc]
+     - New Concentration stuff is moved to MConcentration.
+
+   * mimage/MHillasCalc.[h,cc], Makefile, ImageLinkDef.h
+     - Modifications needed to support and compile new 
+       MConcentration class.
+
+
+
+ 2004/03/16: Thomas Bretz
+
+   * mjobs/MJ*.[h,cc]
+     - removed some obsolete comments
+     - removed projections from Directory (SetDirectory(0))
+
+
+
+ 2004/03/16: Wolfgang Wittek
+
+   * manalysis/MSigmabar.[h,cc]
+     - calculate sigmabar as mean of individual pedestalRMS
+       instead of            sqrt of mean pedestalRMS^2
+
+
+
+ 2004/03/16: Oscar Blanch
+
+   * mimage/MNewImagePar.[h,cc]
+     - New variables members added: fInnerSize, fInnerLeakage[1,2],
+       fConc[3-8].
+     - It is only ready for Magic Camera geometry. It has to be done
+       MGeomCam base.
+     - The version ahs not been updated since it was done on the 
+       2004/03/10 by Abelardo.
+
+
+
+ 2004/03/15: Markus Gaug 
+
+   * mcalib/MCalibrationChargePix.[h,cc],
+     mcalib/MCalibrationChargeCam.[h,cc],
+     mcalib/MCalibrationChargeCalc.cc:
+   - conversion from hi- to logain now not applied until the value is 
+     exported outside the class. This is necessary for the error 
+     propagation in the F-Factor method: In the calculation of the 
+     number of Phe, the conversion factors cancel out and do not 
+     enlarge the errors 
+   - pixels with number of phe's outside the range defined by 
+     fPheFFactorRelErrLimit are not any more declared as: 
+     MCalibrationChargePix::IsFFactorMethodValid() == kFALSE , 
+     but instead as:
+     MBadPixelsPix::IsSuitableRun(MBadPixelsPix::kUnreliableRun) == kTRUE,
+     Like this, everybody is allowed to calibrate pixels which give 
+     no reasonable results in the calibration without bothering that
+     too many pixels fall out. Enjoy!
+   - In that procedure, the classes passed _internally_ from calculation
+     of sigmas to calculation of variances which saves all the useless 
+     square rooting.
+   - took out pointers to MCalibrationChargeBlindPix and 
+     MCalibrationChargePINDiode in MCalibrationChargeCam.
+
+
+
+ 2004/03/15: Abelardo Moralejo
+
+   * mmc/MMcEvt.hxx
+     - added getter function for fZFirstInteraction
+
+
+
+ 2004/03/15: Wolfgang Wittek
+
+   * mastro/MObservatory.[h,cc]
+     - remove bugs in RotationAngle(theta, phi, sin, cos)
+       replaced
+         cos = sinl + cosl*cosp /denom;
+       by
+         cos = (sinl - cosl*cosp) /denom;
+
+
+
+ 2004/03/15: Thomas Bretz
+
+   * mastro/MObservatory.[h,cc]:
+     - implemented RotationAngle(ra, dec, time)
+
+   * mbase/MTask.[h,cc]:
+     - implemented usage of a TStopwatch to retriev time consumtion
+       informations
+     - changed PrintStatistics not to print classes having no
+       Process() function
+
+   * mbase/MTaskList.[h,cc], mfileio/MReadReports.[h,cc]:
+     - changed PrintStatistics according to changes in MTask
+
+   * mraw/MRawEvtHeader.cc:
+     - added a comment to Fill member function
+
+   * manalysis/MCerPhotEvt.[h,cc]:
+     - added fLut.Set to FixSize and resize fLut by a factor of 2
+       instead of +1 which acelerates creation of all pixels a lot
+
+   * mbadpixels/MBadPixelsPix.cc:
+     - fixed a typo
+
+   * mfilter/MFSoftwareTrigger.cc:
+     - made statistics output meaning independant of usage of filter!
+
+   * mhbase/MFill.[h,cc]:
+     - added possibility to give tab a different name
+
+   * mhist/MHCamera.cc:
+     - fixed a bug when determin scale for same-option
+
+   * mjobs/MJCalibration.cc:
+     - changed tab names for MFillH
+
+   * mjobs/MJExtactSignal.cc:
+     - added MRawEvtHeader to output
+
+   * mbase/MStatusDisplay.[h,cc]:
+     - changed displayed year
+     - read and store MStatusArray to and from files
+
+   * mfileio/MReadTree.cc:
+     - enhanced output
+
+   * mmain/MCameraDisplay.cc, mmain/MEventDisplay.[h,cc]:
+     - added preliminary mode to display F1/F2/F3-files
+
+   * mbase/MStatusArray.[h,cc]:
+     - added
+
+   * mbase/Makefile, mbase/BaseLinkDef.h:
+     - added MStatusArray
+
+   * mhits/MHCamera.[h,cc], mgui/MHexagon.[h,cc]:
+     - improved drawing MHCamera with 'same' option
+
+
+
+ 2004/03/13: Markus Gaug 
+
+   * mcalib/MCalibrationChargeCalc.cc, mcalib/MCalibrationChargeCam.cc,
+     mcalib/MCalibrationChargePix.[h,cc], 
+     mcalib/MHCalibrationChargeCam.cc,
+     mcalib/MHCalibrationChargeLoGainPix.cc:
+     - fixed Low Gain calibration
+
+   * mcalib/MHGausEvents.cc:
+     - changed default fit prob. limit from 0.005 to 0.001
+
+   * mbadpixels/MBadPixelsPix.h :
+     - IsCalibrationResultOK does not ask for FitOK any more
+
+   * mcalib/MHCalibrationChargeCam.cc:
+     - replaced Rel. Err. Limit for outliers in Phe's from 5 sigma to 7
+
+   * mraw/MRawEvtPixelIter.[h,cc]:
+     - function GetIdxMaxLoGainSamples can be called optionally with 
+       offset (because first "loGain" samples are often in reality 
+       hiGain with high values.
+
+
+
+ 2004/03/12: Sebastian Raducci
+
+   * manalysis/Makefile
+     - added mastro in the include directories
+
+
+
+ 2004/03/12: Thomas Bretz
+
+   * merpp.cc:
+     - added 'force' option
+
+   * manalysis/MCerPhotAnal2.cc:
+     - extract pedestal and pedestal rms from lo-gain if hi-gain not
+       above a certain athreshold 
+
+   * mastro/MAstroCatalog.[h,c]:
+     - added text argument to DrawStar
+
+   * mbase/MStatusDisplay.cc:
+     - some small changes to output of SaveAsPS
+
+   * mfilter/MFCosmics.cc:
+     - changed output of filter statistics
+
+   * mbadpixels/MBadPixelsTreat.[h,cc]:
+     - fixed some problems with the code - now it should work like
+       expected
+     - added a new member function to be able to change the number
+       of required neighbors
+
+
+
+ 2004/03/12: Wolfgang Wittek
+
+   * manalysis/Makefile
+     - include 'mastro'
+
+   * manalysis/MSourcePosfromStarPos.[h,cc]
+     - include MObservatory.h
+     - call member function Rotationangle() of MObservatory
+
+
+
+ 2004/03/12: Markus Gaug
+
+   * mjobs/MJCalibration.cc
+     - updated call in displays to the corr. Cams.
+
+   * macros/calibrate_data.C
+     - macro to study calibrate and study data used in Munich and IFAE
+
+
+
+ 2004/03/12: Antonio Stamerra
+
+   * mraw/MRawEvtHeader.[h,cc]
+     - Added the method GetTriggerID() to decode the trigger pattern.
+
+
+
+ 2004/03/11: Abelardo Moralejo
+
+   * mimage/MHillasCalc.cc
+     - Added some printout in PostProcess, to better express the reasons
+       for which the reconstruction of some events did not succeed.
+
+
+
+ 2004/03/11: Thomas Bretz
+
+   * status.cc:
+     - updated
+
+   * manalysis/MCerPhotAnal2.cc:
+     - removed an obsolete debug output
+
+   * mhist/MHCamera.[h,cc]:
+     - added same-option to camera display
+
+  * mbadpixels/MBadPixelsCalc.[h,cc], mbadpixels/MBadPixelsTreat.[h,cc]:
+     - implemented functionality of MBlindPixelsCalc2
+
+   * mbadpixels/MBadPixelsCam.[h,cc], mbadpixels/MBadPixelsPix.[h,cc],
+     mbadpixels/MMcBadPixelsSet.cc, mcalib/MCalibrationChargeCalc.cc,
+     mcalib/MCalibrationChargePix.cc, mcalib/MHCalibrationChargeCam.cc:
+     - replaced several Set/GetUnsuitable* by a single member function
+
+
+
+ 2004/03/11: Markus Gaug
+
+   * mbadpixels/MBadPixelsPix.h
+     - removed bits about validity of calibration methods
+     - IsCalibrationResultOK asks also from IsSuitableRun
+
+   * mbadpixels/MBadPixelsCam.cc
+     - updated GetPixelContent
+     - added Print function
+
+   * mcalib/MCalibrationChargeCam.[h,cc]
+     mcalib/MCalibrationChargePix.h, mcalib/MCalibrationChargeCalc.cc:
+     - removed pointers to MGeomCam and MBadPixelsCam in MCalibrationChargeCam
+     - use two loops over pixels in order to determine mean flux of phe;s to 
+       discard pixels far outside the normal distribution
+
+   * mcalib/MCalibrate.cc
+     - added case that no MBadPixelsCam is available.
+
+   * mcalib/MHCalibrationChargeCam.cc
+     - adapted to new MBadPixelsPix::SetUnsuitable function
+
+
+ 2004/03/10: Abelardo Moralejo
+
+   * manalysis/MCerPhotPix.[h,cc]
+     - Added member fIsHGSaturated, and setter/getter functions. 
+       Updated class version to 4.
+
+   * mcalib/MCalibrate.cc, MCalibrateData.cc
+     - Added setting of MCerPhotPix.fIsHGSaturated if one or more HG
+       slices saturate.
+
+   * mimage/MNewImagePar.[h,cc]
+     - Added member fNumHGSaturatedPixels to count the number of pixels 
+       in which high gain saturates. Added getter funciton for it. 
+       Updated class version to 3.
+
+
+
+ 2004/03/10: Markus Gaug
+
+   * mcalib/MCalibrationChargeCalc.cc,
+     mcalib/MCalibrationChargePix.[h,cc],
+     mcalib/MCalibrationChargeCam.[h,cc]:
+     - calculation of conversion factor with F-Factor method from 
+       same mean number of photons, derived from weighted mean number 
+       of photo-electrons from inner and outer pixels, respectively
+
+   * mjobs/MJPedestal.cc, mjobs/MJCalibration.cc, macros/calibration.C:
+     - fixed the projections (did only display inner pixels up to now)
+
+   * macros/calibration.C
+     - small bug fixed in display of rel. arrival times
+       ( used MArrivalTimeCam instead of MHCalibrationRelTimeCam)
+
+   * mbadpixels/MBadPixelsCam.cc
+     - replaced some InitSize(idx) by InitSize(idx+1) in order not to crash
+       to program when reading from an ascii-file.
+
+   * mbadpixels/MBadPixelsCalc.cc
+     - replaced one SetUnsuitableRun(....) by the new version without 
+       argument.
+
+
+
+ 2004/03/10: Thomas Bretz
+
+   * mfilter/MFSoftwareTrigger.[h,cc]:
+     - changed to support also a predifined number of NN
+
+   * mastro/MAstroCatalog.[h,cc]:
+     - many enhancements
+     - many speed improvements
+
+   * mbadpixels/MBadPixelsPix.[h,cc]:
+     - fixed
+
+
+
+ 2004/03/10: Ester Aliu
+
+   * mtemp/MIslands.[h,cc]
+     - New MParContainer to hold information about islands
+       (number of islands, pixels in each Island, Signal/Noise of
+	each Island).
+
+   * mtemp/MIslandCalc.[h,cc]
+     - New MTask to count and characterize Islands.
+
+
+
+ 2004/03/09: Thomas Bretz
+
+   * Makefile.rules:
+     - replaced *.o by $(...) for building archives
+
+   * mjobs/MJCalibration.cc:
+     - exchanged  apply  and merge task
+
+   * mjobs/MJCalibration.h, mjobs/MJExtractSignal.h, mjobs/MJPedestal.h:
+     - fixed some const-qualifiers
+
+   * mcalib/MHCalibrationChargeBlindPix.cc, 
+     mcalib/MHCalibrationChargeCam.cc,
+     mcalib/MHCalibrationChargePINDiode.cc
+     - removed some obsolete output when calling FindCreateObj
+     - changed some 'not found' output messages to be 'Mars-compliant'
+     - replaced some gLog by *fLog
+
+
+
+ 2004/03/08: Markus Gaug
+   
+   * mbadpixels/MBadPixelsPix.h
+     - small modifications for better readability
+     - remove Getters for calibration methods
+     - added flag "UnReliableRun" in fInfo[0]
+
+   * mcalib/MHCalibrationChargeCam.cc, mcalib/MCalibrationChargePix.cc:
+     - fill MBadPixelsPix with UnReliableRun or UnSuitableRun when 
+       calibration does not succeed.
+
+   * mcalib/MCalibrationChargeCam.cc
+     - displaying saturation also for not-valid pixels in GetPixelContent
+
+   * msignal/MExtractedSignalCam.[h,cc], msignal/MExtractSignal.[h,cc],
+     msignal/MExtractSignal2.[h,cc], mananlysis/MHPedestalCam.cc,
+     mcalib/MCalibrationChargeCalc.[h,cc]:
+     - in SetUsedFADCSlices, also the window (hi-and logain) is set. 
+       This because MExtractSignal2 set the whole window which was much 
+       bigger than the actually used one. This bug is now removed.
+
+
+
+ 2004/03/08: Thomas Bretz
+
+   * merpp.cc:
+     - fixed a bug in the screen output
+
+   * mgeom/MGeomMirror.cc:
+     - added comment
+
+   * mmc/MMcConfigRunHeader.h:
+     - added member function GetMirrors
+
+
+
+ 2004/03/08: Abelardo Moralejo
+
+   * macros/starmc.C, starmcstereo.C, mccalibrate.C 
+      - adapted to m. Gaug's changes: now one MBadPixelsCam containers is 
+        added for each telescope to the parameter list.
+
+   * mmain/MEventDisplay.cc, Makefile
+     - added MBadPixelsCam to par list, and mbadpixels/ to includes.
+       Necessary due to changes in MCalibrate.
+
+
+
+ 2004/03/06: Markus Gaug
+
+   * macros/calibration.C
+     - adapted call to MHCamera::ProjectionS to the new version
+
+   * mcalib/Makefile
+     - include directory mbadpixels
+
+   * manalysis/Makefile
+     - include directory mbadpixels
+
+   * mcalib/MCalibrationChargeCalc.[h,cc]
+     - include MBadPixelsCam
+     - remove exclusion of pixels from ascii-file
+       (now accessible from MBadPixelsCam)
+
+   * mcalib/MCalibrationChargePix.[h,cc]
+     - include MBadPixelsCam
+
+   * mcalib/MCalibrationChargeCam.[h,cc]
+     - include MBadPixelsCam
+
+   * mcalib/MHCalibrationChargeCam.[h,cc]
+     - include MBadPixelsCam
+     - include one additional MBadPixelsPix for the average inner and 
+       outer pixel, respectively
+
+   * mcalib/MHCalibrationChargePix.[h,cc]
+     - make fSaturated and fPickup a Float_t (for average pixel)
+
+   * mbadpixels/MBadPixelsPix.h
+     - include the CalibrationType_t infos
+     - exchange "SetUnsuitable" by "SetUnsuitableRun"
+
+   * mbadpixels/MBadPixelsCam.cc, mbadpixels/MMcBadPixelsSet.cc:
+     - exchange "SetUnsuitable" by "SetUnsuitableRun"
+
+   * mbadpixels/MBadPixelsCalc.cc:
+     - exchange "SetUnsuitable" by "SetUnsuitableEvt"
+
+   * manalysis/MGeomApply.cc
+     - remove obsolete MArrivalTime
+     - add MBadPixelsCam
+
+   * mcalib/MCalibrate.[h,cc], mcalib/MCalibrateData.[h,cc]
+     - implemented calls to MBadPixelsCam
+
+   * macros/calibration.C, macros/bootcampstandardanalysis.C,
+     macros/pedphotcalc.C
+     - implemented calls to MBadPixelsCam
+
+   * mjobs/MJCalibration.cc
+     - call to MBadPixelsCam
+
+
+
+ 2004/03/05: Nadia Tonello
+
+   * manalysis/MBlindPixelsCalc2.[h,cc], manalysis/AnalysisLinkDef.h,
+     manalysis/Makefile
+     - Temporary class added (will be included in mbadpixels/ soon)
+     - All the functions of MBlindPixelCalc are kept(with small improvements)
+     - New function added: SetCheckPedestalRms
+
+   * manalysis/MCerPhotPix.h
+     - Status Unmapped added (not include the pixel in the cleaned image)
+
+   * mimage/MImgCleanStd.cc 
+     - Checks for Unmapped status added 
+
+   * mastro/MAstroCatalog.cc, msql/MSQLServer.cc:
+     - include <stdlib.h> to solve compilation error
+
+
+
+ 2004/03/05: Sebastian Raducci
+
+   * msignal/MArrivalTimeCalc.cc
+     - fixed a little bug (exchanged a - with a + in the Calc() method)
+
+
+
+ 2004/03/05: Markus Gaug
+
+   * mcalib/MCalibraitonChargeCalc.cc
+     - remove some runheader line: 
+	if (runheader->IsMonteCarloRun())
+            return kTRUE;
+       which gave always true since this week, don't know why.
+     - added some information in class description
+
+
+
+ 2004/03/04: Sebastian Raducci
+  
+   * msignal/MArrivalTimeCalc.cc
+     - fixed a memory leak (the spline was not deleted...)
+
+
+
+ 2004/03/04: Thomas Bretz
+
+   * mgeom/MGeomCam.[h,cc]:
+     - added new data member fNumAreas
+     - added new function CalcNumAreas
+     - increased class version to 3
+
+   * mgeom/MGeomCamMagic.cc:
+     - added setting of area index
+
+   * mgeom/MGeomPix.[h,cc]:
+     - added fAidx data member
+     - added getter function fAidx
+     - increased class version to 3
+
+   * macros/sectorvstime.C:
+     - added example of how to plot the evolution of a sector vs time
+
+   * mhist/MHVsTime.[h,cc], mhist/MHPixVsTime.[h,cc]:
+     - moved to mhvstime
+
+   * mhvstime/MHSectorVsTime.[h,cc]:
+     - added
+
+   * Makefile:
+     - added mhvstime
+
+   * mhvstime/Makefile, mhvstime/HVsTimeLinkDef.h, 
+     mhvstime/HVsTimeIncl.h:
+     - added
+
+   * mhist/Makefile, mhist/HistLinkDef.h, 
+     - removed MHVsTime
+     - removed MHPixVsTime
+
+   * macros/rootlogon.C, macros/dohtml.C:
+     - added new directory mhvstime
+
+   * msignal/MExtractSignal.cc, msignal/MExtractSignal2.cc:
+     - changes such, that it doesn't crash if signal has no lo-gain
+       (This might still give wrong results!)
+
+   * macros/dohtml.C:
+     - added pixvstime.C
+     - added sectorvstime.C
+
+   * manalysis/MMcCalibrationUpdate.cc:
+     - some changes on file consistency check done by Abelardo,
+       he may comment on it
+
+   * mhist/MHCamera.[h,cc]:
+     - changed to support also dividing the camera in pixels area indices
+
+   * mhist/MHEvent.cc:
+     - minor change
+
+   * mjobs/MJPedestal.cc:
+     - adapted to changes in MHCamera
+
+   * mastro/MAstroCatalog.[h,cc]:
+     - added preliminary catalog
+
+   * mastro/Makefile, mastro/AstroLinkDef.h:
+     - added MAstroCatalog
+
+
+
+ 2004/03/03: Thomas Bretz
+
+   * mgeom/MGeomCam.cc:
+     - give a name and title also if the default constructor is used
+
+   * mgeom/MGeomMirror.[h,cc]:
+     - added member function GetReflection
+     - added persistent data member fReflector
+
+   * mjobs/MJCalibration.cc, mjobs/MJExtractSignal.cc, mjobs/MJPedestal.cc:
+     - fixed a typo in the output
+
+   * mraw/MRawFileWrite.cc:
+     - added the missing '.' to MRawRunHeader. Because of the design of
+       MReadTree this is backward compatible
+
+   * mraw/MRawRunHeader.h:
+     - removed last change from Abelardo. '>255' is the correct 
+       check for MC files following the definition that all MC files
+       have run types >255 which was made in the past. 
+
+   * manalysis/MCerPhotAnal.[h,cc], manalysis/MCerPhotAnal2.[h,cc]:
+     - created ReInit member function to hold all code (moved from
+       PreProcess) accessing the run header. The run header is not
+       available in PreProcess. That it was working before was only
+       by chance, because the run type is initialized with 65535 which
+       is != 255 but not >255.
+
+
+
+ 2004/03/03: Sebastian Raducci
+
+   * msignal/MArrivalTimeCalc.cc
+     - The calculation of the arrival times is made only when needed
+       (when the HalfMax is over the pedestal)
+
+   * mtools/MCubicSpline.cc
+     - Commented out an annoying warn
+
+
+
+ 2004/03/03: Abelardo Moralejo
+
+   * mraw/MRawRunHeader.h
+     - Replaced
+         Bool_t IsMonteCarloRun() const { return fRunType>0x00ff; }  by
+         Bool_t IsMonteCarloRun() const { return (fRunType==0x0100); }
+     since the latter is the exact translation of what the function
+     intends to do. I do not know why, but the display of real data 
+     did not work with the upper line!
+
+   * mgeom/MGeomCam.cc
+     - Undid yesterday change! I do not know why, display completely 
+       fails after that change, both for old and new camera files. 
+       Put back fPixels[i] = new MGeomPix; in constructor.
+
+
+
+ 2004/03/02: Abelardo Moralejo
+
+   * mmc/MMcCorsikaRunHeader.[h,cc]
+     - Added operator [] to get references to the objects in 
+       TObjArray fTelescopes.
+     - Added Print() function.
+     - Added GetNumCT() function.
+     - Replaced
+          fTelescopes[i]= new MGeomCorsikaCT;   
+       by
+          MGeomCorsikaCT* dummy = new  MGeomCorsikaCT();
+          fTelescopes.Add(dummy);
+
+   * mgeom/MGeomCorsikaCT.[h,cc]
+     - Added getter functions for telescope coordinates.
+     - Added Print() function.
+
+   * mgeom/MGeomCam.cc  => NOTE: this change was undone later!
+     - Replaced
+          fPixels[i] = new MGeomPix;   
+       by
+          MGeomPix* dummy = new MGeomPix();
+          fPixels.Add(dummy);
+
+
+
+ 2004/03/02: Thomas Bretz
+
+   * mcalib/MCalibrateData.cc:
+     - removed usage of MGeomCam (you have MGeomApply for this!)
+
+
+
+ 2004/03/01: Nadia Tonello
+
+   * manalysis/MCerPhotEvt.cc
+     - TObject *MCerPhotEvtIter::Next() now returns Used pixels 
+	only if fUsedonly=kTRUE, otherwise it returns all the pixels 
+	in the array  
+ 
+
+
+ 2004/03/01: Sebastian Raducci
+
+   * msignal/MArrivalTimeCalc.[cc,h]
+     - now the arrival time is at the half max of the spline:
+       half max = (maximum - pedestal)/2
+   
+   * mmain/MEventDisplay.cc
+     - fixed an include (from MArrivalTime.h to MArrivalTimeCam.h)
+
+
+
+ 2004/03/01: Wolfgang Wittek
+  
+   * mhist/MHStarMap.[h,cc]
+     - remove bugs
+     - change GetRotationAngle() such that it can be called from outside
+
+
+
+ 2004/03/01: Thomas Bretz
+
+   * Makefile:
+     - enhanced all calls to subsequent makes by '-f Makefile' to
+       make sure the correct Makefile is called
+
+   * merpp.cc:
+     - enhanced interpretation of time
+     - fixed a bug in determin the file-type
+
+   * mbase/MTime.[h,cc]:
+     - added GetGmst() member function
+
+   * mastro/MAstro.[h,cc]:
+     - added Coordinate2Angle
+     - added AngularDistance
+     - implemented UT2GMST
+     - replaced defined by TMath::Pi()
+
+   * mastro/MObservatory.[h,cc]:
+     - added data members for sin-/cos-component of latitude
+     - added calculation of rotation angle
+
+   * mhist/MHStarMap.[h,cc]:
+     - changes to use MObservatory member function
+
+   * manalysis/MCerPhotAnal.cc, manalysis/MCerPhotAnal2.cc,
+     manalysis/MCerPhotCalc.cc, manalysis/MMcCalibrationUpdate.cc,
+     manalysis/MMcPedestalCopy.cc, manalysis/MMcPedestalNSBAdd.cc,
+     manalysis/MPedCalcPedRun.cc, manalysis/MPedPhotCalc.cc,
+     mcalib/MCalibrationChargeCalc.cc, mcalib/MMcCalibrationCalc.cc
+     - changed to use IsMonteCarloRun() now
+
+   * manalysis/MMcCalibrationUpdate.cc:
+     - unified output to log-stream
+     - replaced sqrt by TMath::Sqrt
+
+   * mcalib/MCalibrationChargeCalc.cc:
+     - unified output to log-stream
+     - removed .Data() from TString where obsolete
+     - fixed memory leak using gSystem->ExpandPathName
+
+   * mpointing/MPointingPosCalc.cc, mraw/MRawFileWrite.cc:
+     - adde class name to used kRT*/kTT* enums
+
+   * mraw/MRawEvtHeader.h:
+     - made enum data member of class
+
+   * mraw/MRawRunHeader.[h,cc]:
+     - made kMagicNumber and kMaxFormatVersion a static data
+       member of the class
+     - added IsMonteCarloRun member function
+
+
+
+ 2004/02/27: Markus Gaug
+   
+   * mjobs/MJPedestal.cc, mjobs/MJCalibration.cc, macros/calibration.C:
+     - put in call to MHCamera::Projection the name of the calling 
+       class, otherwise the projected hsitogram will be overwritten by 
+       an empyt one.
+
+   * mcalib/MHCalibrationChargePix.[h,cc],
+     mcalib/MHCalibrationHiGainChargePix.[h,cc],
+     mcalib/MHCalibrationLoGainChargePix.[h,cc]:
+     - histogram name setting and title setting moved to constructor, 
+       Functions Init and ChangeHistId derive directly from 
+       MHcalibrationChargePix
+
+   * mcalib/MHCalibrationChargeCam.[h,cc],
+     mcalib/MCalibrationChargeCam.[h,cc],
+     mcalib/MCalibrationChargeCalc.[h,cc]:
+     - introduced "average inner" and "average outer" higain and logain 
+       pixels.
+
+
+
+ 2004/02/27: Raducci Sebastian 
+
+   * mhist/Makefile
+     - added mastro in the include list
+
+
+
+ 2004/02/27: Abelardo Moralejo
+
+   * mmain/MEventDisplay.cc
+     - replaced in fill8 obsolete MArrivalTime with MArrivalTimeCam.
+     - Updated display of MC data: removed MCerPhotCalc, and replaced 
+       it by MExtractSignal+MMcCalibrationUpdate+MCalibrate. Now
+       MPedPhotCam is filled and all the camera display tabs are shown 
+       correctly (most were not working for MC events since a while 
+       ago).
+
+   * mmain/Makefile
+     - Added mcalib to list of include directories.
+
+   * manalysis/MMcCalibrationUpdate.[h,cc]
+     - Added member variable Bool_t fOuterPixelsScaling, which is 
+       kTRUE by default. If set to kFALSE, MCalibrationCam is filled 
+       such that MCerPhotEvt will later be filled with the signal as it 
+       is, not corrected for the (possibly) different gain of the outer 
+       pixels electronic chain. This option was necessary to allow for
+       the change in the camera display (see above).
+
+   * macros/starmc.C
+     - added (optional) division of output into two, for use as train 
+       and test samples in g/h separation studies.
+
+
+
+ 2004/02/26: Hendrik Bartko
+
+   * macros/dohtml.C
+     - included the path msignals/
+
+
+
+ 2004/02/26: Abelardo Moralejo
+
+   * macros/starmcstereo.C
+     - changed filters to divide data between train and test sample for
+       gamma hadron separation studies. Now we use the modulus operator
+       applied to (Corsika) event number:
+         MF filter1("{MMcEvt;1.fEvtNumber%2}<0.5");
+         MF filter2("{MMcEvt;1.fEvtNumber%2}>0.5");
+     - cleaned up a bit the way the CT coordinates are fed to the task
+       MStereoCalc.
+     - Changed default FADC integration range (center range to adapt to 
+       new camera).
+
+
+
+ 2004/02/26: Thomas Bretz
+
+   * mhist/MHCamera.cc:
+     - fixed a function description
+
+   * mreport/MReport.cc, mreport/MReportFileRead.cc:
+     - introduced return case -1
+
+   * Makefile.rules:
+     - remove all dependancy files when calling 'rmdep'
+
+   * mbase/MAGIC.h, mmc/MMcEvt.hxx:
+     - moved ParticleId_t to MMcEvt
+     - implemented MMcEvt::GetParticleName
+     - implemented MMcEvt::GetEnergyStr
+
+   * mfilter/MFGeomag.cc, mfilter/MFParticleId.cc, mhist/MHCompProb.cc,
+     mhist/MHEvent.cc, mhist/MHHadronness.cc, 
+     mmontecarlo/MMcTriggerRateCalc.cc, mranforest/MHRanForest.cc:
+     - fixed usage of ParticleId_t
+
+   * msignal/Makefile:
+     - removed obsolete includes
+
+   * mastro/Makefile, mastro/AstroLinkDef.h, mastro/MAstro.[h,cc],
+     mastro/MObservatory.[h,cc]:
+     - added
+
+   * mbase/MAstro.[h,cc]:
+     - removed
+
+   * mbase/Makefile, mbase/BaseLinkDef.h:
+     - removed MAstro
+
+   * Makefile:
+     - added mastro
+     - added msql
+     - added mfbase
+
+   * mtemp/MObservatory.[h,cc], mtemp/MObservatoryLocation.[h,cc]:
+     - removed
+
+   * merpp.cc:
+     - added Sql support
+     
+   * mraw/MRawFileRead.h:
+     - added GetFileName
+
+   * msql/Makefile, msql/SqlLinkDef.h, msql/SqlIncl.h, 
+     MSQLServer.[h,cc], MSqlInsertRun.[h,cc]:
+     - added
+
+   * mfilter/MF.[h,cc], mfilter/MFDataChain.[h,cc], 
+     mfilter/MFDataMember.[h,cc], mfilter/MFEventSelector.[h,cc],
+     mfilter/MFEventSelector2.[h,cc], mfilter/MFRealTimePeriod.[h,cc]:
+       - moved to mfbase
+
+   * mfbase/Makefile, mfbase/FBaseLinkDef.h, mfbase/FBaseIncl.h:
+     - added
+
+   * merpp.cc:
+     - implemented control of gDebug (root debugging)
+
+   * mfileio/MWriteAsciiFile.[h,cc], mfileio/MWriteFile.[h,cc],
+     mfileio/MWriteRootFile.[h,cc]:
+     - implemented CheckAndWrite return value
+
+   * mfileio/MWriteRootFile.cc:
+     - fixed updating already existing branches (eg concatenating report
+       files)
+
+   * macros/dohtml.C, macros/rootlogon.C:
+     - added mastro
+     - added mfbase
+     - added msql
+
+   * mraw/MRawEvtHeader.h:
+     - implemented GetNumTrigLvl1
+     - implemented GetNumTrigLvl2
+
+
+
+ 2004/02/25: Markus Gaug
+
+   * mcalib/MExtractBlindPixel.[h,cc],
+     mcalib/MExtractPINDiode.[h,cc],
+     mcalib/MExtractedSignalBlindPixel.[h,cc],
+     mcalib/MExtractedSignalPINDiode.[h,cc],
+     mcalib/Makefile, msignal/Makefile, mcalib/CalibLinkDef.h,
+     msignal/SignalLinkDef.h:
+     - moved blindpixel and PINdiode extractors to msignal
+
+
+   * mcalib/MCalibrationQECam.[h,cc], mcalib/MCalibrationQEPix.[h,cc]:
+     - two new classes to hold the quantum efficieny information of the 
+       calibration
+
+   * msignal/MArrivalTimeCalc.[h,cc]
+     - fill now MArrivalTimePix instead of MArrivalTime
+
+   * mcalib/MHCalibrationChargeCam.cc
+     - display only valid pixels for the corr. values in GetPixelContent
+
+   * mcalib/MHCalibrationRelTimeCam.cc
+     - is now filled from MArrivalTimeCam instead of MArrivalTime
+
+   * macros/calibration.C
+     - divided into two macros: calibration.C using the MJPedestal
+       standard procedure and   pedestalstudies.C using the old
+       procedures
+    
+   * macros/pedestalstudies.C
+     - new macro containing the first previous part of calibration.C
+
+   * mcalib/MCalibrationChargeBlindPix.h,
+     mcalib/MCalibrationChargePINDiode.h, mbase/MAGIC.h,
+     mjobs/MJCalibration.cc:
+     - definition of PulserColot_t in MAGIC.h. 
+
+
+
+ 2004/02/25: Hendrik Bartko
+  
+   * macros/rootlogon.C
+     - set the include path also to msignals/
+
+   * manalysis/MExtractSignal.[h,cc], manalysis/MExtractSignal2.[h,cc],
+     manalysis/MExtractedSignalCam.[h,cc],
+     manalysis/MExtractedSignalPix.[h,cc],
+     manalysis/MArrivalTime.[h,cc], manalysis/MArrivalTimeCalc.[h,cc],
+     manalysis/MArrivalTimeCalc2.[h,cc]:
+     - removed
+     
+   * manalysis/Makefile, manalysis/AnalysisLinkDef.h:			
+     - removed classes mentioned above
+
+   * msignal/MExtractSignal.[h,cc], msignal/MExtractSignal2.[h,cc],
+     msignal/MExtractedSignalCam.[h,cc],
+     msignal/MExtractedSignalPix.[h,cc],
+     msignal/MArrivalTime.[h,cc], msignal/MArrivalTimeCalc.[h,cc],
+     msignal/MArrivalTimeCalc2.[h,cc]:
+     - added
+
+   * msignal/Makefile, msignal/AnalysisLinkDef.h:			
+     - added classes mentioned above
+     
+   * mfilter/Makefile, mcalib/Makefile, mjobs/Makefile, mmain/Makefile:
+     - added include msignal
+    
+
+
+
+ 2004/02/25: Wolfgang Wittek
+  
+   * mcalib/MCalibrateData.[h,cc]
+     - initialize size for MPedPhotCam
+
+
+
+ 2004/02/24: Wolfgang Wittek
+
+   * manalysis/MSourcPosfromStarPos.[h,cc]
+     - change member function SetSourceAndStarPosition() to expect sky
+       coordinates in the standard units
+     - generalize to more than 1 star
+     - the class is not yet fully tested
+
+   * mfilter/MFSelBasic.[h,cc]
+     - change default values of cuts
+
+
+
+ 2004/02/24: Markus Gaug
+
+   * mjobs/MJCalibration.cc, macros/calibration.C,
+     macros/bootcampstandardanalysis.C, macros/pedphotcalc.C:
+     - added MCalibrationChargeBlindPix to plist
+     - added new filling of histograms with MFillH
+     - changed SetPulserColor to MCalibrationChargeBlindPix and 
+       MCalibrationChargePINDiode
+
+   * mcalib/MHCalibrationChargeBlindPix.[h,cc]:
+     - receives a pointer to MCalibrationChargePINDiode which is filled 
+       with the results and told to calculate the fluxes in the 
+       Finalize function
+     - is filled via MFillH from MExtractBlindPixel
+     - SetPulserColor directly in this class
+
+   * mcalib/MCalibrationChargeBlindPix.[h,cc]
+     - new storage container of the blind pxiel resutls, replaces 
+       MCalibrationBlindPix
+
+   * mcalib/MCalibrationChargeCalc.[h,cc]:
+     - does not fill the histograms any more, but does ony the 
+       calculations in the postprocess. No pointer to MExtractPINDidoe
+       or MExtractBlindPixel any more.
+
+   * mcalib/MCalibrationChargePix.cc
+     - discovered an error in the calculation of phe's in 
+       CalcFFactorMethod(). The average QE was applied twice. 
+       This error had been introduced on 13/02/04
+     - loosened criterium convFFactorRelErrLimit from 0.1 to 0.2
+     - CalcFFactor asks for IsChargeValid before calculating anything
+
+   * mcalib/MCalibrationChargePINDiode.[h,cc]
+     - added function SetFluxOutsidePlexiglassAvailable
+     - SetPulserColor directly in this class
+
+   * mcalib/MCalibrationChargeCam.cc
+     - removed function SetPulserColor from here 
+
+   * mcalib/MCalibrationPINDiode.[h,cc], mcalib/MHCalibrationConfig.h,
+     mcalib/MHCalibrationPINDiode.[h,cc],
+     mcalib/MCalibrationBlindPix.[h,cc],
+     mcalib/MHCalibrationBlindPixel.[h,cc]:
+     - removed since obsolote 
+
+   * mcalib/MHCalibrationChargePix.cc
+     - make fPickup an Int_t
+
+   * mcalib/MCalibrate.cc
+     - test validity of every calibration method before retrieving
+       conversion factors
+
+   * mcalib/MHGausEvents.[h,cc]
+     - add possibility to set fit ranges in call to FitGaus
+     - make function CreateXaxis protected 
+
+
+
+ 2004/02/23: Markus Gaug
+
+   * mraw/MRawEvtPixelIter.h
+     - include GetNumHiGainSamples and GetNumLoGainSamples
+
+   * mcalib/MExtractedSignalBlindPixel.h, 
+     mcalib/MExtractBlindPixel.[h,cc]:
+     - included storage of pedestal
+
+   * mcalib/MHGausEvents.[h,cc]
+     - make the fit functions protected
+
+
+
+ 2004/02/22: Markus Gaug
+
+   * mfilter/MFCosmics.[h,cc]
+     - fMaxNumEmpty changed from absolute number to relative number of 
+       pixels
+
+   * mcalib/MHGausEvents.h
+     - remove the "->" from the pointers which are initialized only 
+       in certain cases. The streamer did not work in case that 
+       MFGausFit was left at the NULL pointer.
+
+
+
+ 2004/02/21: Markus Gaug
+
+   * manalysis/MExtractedSignalPix.[h,cc]
+     - changed variable fIsLoGainUsed to fLoGainUsed
+     - added function GetNumHiGainSaturated()
+
+
+ 2004/02/20: Markus Gaug
+
+   * mcalib/MHCalibrationChargeHiGainPix.[h,cc], mcalib/Makefile,
+     mcalib/MHCalibrationChargeLoGainPix.[h,cc],
+     mcalib/CalibLinkDef.h
+     - new class to replace MHCalibrationPixel, 
+       based on MHCalibrationChargePix
+
+   * mcalib/MCalibrationChargeCalc.[h,cc]
+     mcalib/MCalibrationChargeCam.[h,cc]
+     mcalib/MCalibrationChargePix.[h,cc]
+     mcalib/MCalibrationChargePINDiode.[h,cc]
+     mcalib/MCalibrationCalc.[h,cc], mcalib/MCalibrationCam.[h,cc],
+     mcalib/MCalibrationPINDiode.[h,cc]:
+     - added the "charge" versions, remove the old ones. The histograms 
+       should be filled in the MH... versions independently of 
+       MCalibrationChargeCalc. This is fully realized for the PIN Didoe 
+       now and will later be so for the pixels and the blind pixel. 
+
+   * mcalib/MHCalibrationChargePINDiode.[h,cc]
+     - receives a pointer to MCalibrationChargePINDiode which is filled 
+       with the results and told to calculate the fluxes in the 
+       Finalize function
+
+   * mcalib/MCalibrate.[h,cc], mcalib/MCalibrateData.[h,cc],
+     mcalib/MMcCalibrationCalc.[h,cc], mjobs/MJCalibration.[h,cc],
+     manalysis/MMcCalibrationUpdate.[h,cc],
+     mjobs/MJExtractSignal.[h,cc], manalysis/MGeomApply.cc,
+     mcalib/Makefile, mcalib/CalibLinkDef.h, macros/calibration.C,
+     macros/bootcampstandardanalysis.C,
+     macros/pedphotcalc.C:
+    - replace MCalibrationCam by MCalibrationChargeCam
+    - replace MCalibrationCalc by MCalibrationChargeCalc
+
+
+
+ 2004/02/19: Markus Gaug
+
+   * mcalib/MCalibrationPix.[h,cc], mcalib/MCalibrationCam.cc,
+     mcalib/MCalibrate.cc, mcalib/MCalibrateDate.cc,
+     manalysis/MMcCalibrationUpdate.cc:
+     - standardized naming of variables containing "Error", this also affected 
+       the calling functions MCalibrate, MMcCalibrationUpdate and MCalibrateData
+
+   * mcalib/MCalibrationCam.cc, mcalib/MCalibrationPix.cc,
+     mcalib/MCalibrationCalc.cc, mcalib/MCalibrate.cc,
+     mcalib/MCalibrateData.cc, mcalib/MCalibrationConfig.h:
+     - took out some configuration numbers and put them directly into 
+       the class
+     - remove completely MCalibrationConfig.h
+
+
+
+ 2004/02/19: Abelardo Moralejo
+
+   * mhist/MHEvent.[h,cc]:
+     - Changed names of Event "types" to make them more descriptive.
+       Former kEvtSignal is now called kEvtSignalDensity, and indicates
+       pixel content scaled by area. Added kEvtSignalRaw, which 
+       corresponds to pixel content (with no scaling) in whatever units
+       (this depends on how the MHEvent object is filled!). The default
+       constructor initializes type=kEvtSignalRaw.
+
+   * mmain/MEventDisplay.cc
+     - Changed filling of evt1 and evt2. Now they are filled with raw 
+       content of MCerPhotEvt. Since in MEventDisplay, MCerPhotEvt is
+       still filled uncalibrated (hence in ADC counts), this means that 
+       what will be now shown in Mars' camera display is now the signal 
+       in each pixel without scaling with pixel area. Given that the 
+       default flat fielding is such that equal light density 
+       corresponds to equal absolute signal (in ADC counts), this is 
+       more reasonable, and allows to check for instance how the 
+       relative pixel gains are adjusted by looking at calibration 
+       events. To be FIXED: there is however an "inconsistency" in 
+       MEventDisplay, and it is that MCerPhotEvt is still used to keep
+       uncalibrated signals. To be replaced by MExtractedSignalCam?
+
+
+
+ 2004/02/19: Thomas Bretz
+
+   * manalysis/MCerPhotEvt.h:
+     - added operator= to MCerPhotEvtIter -- is this correct?
+
+   * mhist/MHCamera.[h,cc]:
+     - added member function to calculate minimum content and 
+       maximum content for a single sector
+     - Added possibility to get a projection for a single sector.
+     - GetMinimum/GetMaximum now only takes used pixels into account
+       (you can request all pixels using a different member function)
+     - fixed projection (projection only took pixels with contents!=0
+       instead of 'used' pixels
+     - Don't call Sumw2() anymore for projection
+
+   * mjobs/MJPedestal.cc:
+     - added MPedestalCam to output again - MPedestalCam was fixed
+       yesterday
+     - Added Histograms for the two camera halves
+
+
+
+ 2004/02/18: Markus Gaug
+
+    * macros/calibration.C
+      - fixed a buggy display of the F-Factor method
+
+    * mcalib/MCalibrationCalc.cc
+      - calculate the F-Factor method already in the post-Process
+
+    * mcalib/MCalibrationPix.h
+      - move CalcFFactorMethod to public
+
+
+
+ 2004/02/18: Abelardo Moralejo
+
+    * mtools/MCubicSpline.cc
+      - in Init, corrected initialization of arrays temp and ysd, which
+	was done with n-1 elements instead of n.
+
+    * mgui/MHexagon.cc
+      - added comment explaining the algorithm.
+      - changed explicit values of Sin and Cos 60 degrees by const
+	variables (more readable).
+
+
+
+ 2004/02/18: Hendrik Bartko
+
+   * msignal/:
+     - removed the backup files *~
+     - removed the object files *.o
+     - removed the files SignalCint.*
+
+    * mgui/MHexagon.cc
+      - added comment explaining the algorithm.
+
+
+
+ 2004/02/18: Thomas Bretz
+
+   * manalysis/MPedestalCam.[h,cc]:
+     - Changed order of derivements - seems to be VERY important!
+     - changed GetSize from UInt_t to Int_t which is the type
+       of TClonesArray::GetSize() !
+
+   * mfileio/MReadReports.cc:
+     - skip trees with no entries
+
+   * mgui/MCamEvent.cc:
+     - added a comment
+
+   * mhbase/MFillH.cc:
+     - in case SetupFill returns kFALSE and kCanSkip is set
+       Skip task
+
+   * mraw/MRawFileRead.cc:
+     - don't print warning in case of none executions
+
+   * manalysis/MArrivalTimeCalc2.cc:
+     - added some const-qualifiers
+
+
+
+ 2004/02/17: Raquel de los Reyes
+
+   * macros/CCDataCheck.C
+     - Added some improvements in the plots.
+
+
+
+ 2004/02/17: Abelardo Moralejo
+
+   * macros/readrfl.C
+     - Added missing gPad->cd(1), otherwise the display of events was
+       not updated.
+
+   * mgui/MHexagon.cc
+     - DistanceToPrimitive(Float_t px, Float_t py) Changed check of
+       whether px,py is inside the pixel or not. Previous algorithm 
+       was just an approximation.
+
+
+
+ 2004/02/17: Raquel de los Reyes
+
+   * mcamera/MCameraHV.h
+     - Now it derives from a MCamEvent class and implemented the
+       GetPixContent() and DrawPixelContent() functions. Added the 
+       GetMean function to get the mean HV settings of the camera.
+
+   * macros/CCDataCheck.C
+     - Added the HV settings plots.
+
+
+
+ 2004/02/17: Hendrik Bartko
+
+   * msignal:
+     - new: directory for all signal and time extraction classes
+
+   * msignal/MArrivalTimeCam.[h,cc], manalysis/Makefile, 
+     msignal/AnalysisLinkDef.h, MGeomApply.cc:
+     - new: Storage Container for the ArrivalTime in the camera
+   
+   * msignal/MArrivalTimePix.[h,cc], manalysis/Makefile, 
+     msignal/AnalysisLinkDef.h:
+     - new: Storage Container for ArrivalTime information of one pixel
+
+   * msignal/Makefile, SignalCint.[h,cc], SignalDep.d, SignalIncl.h, 
+     SignalLinkDef.h
+     - auxiliary files for msignal directory
+
+   * manalysis/MArrivalTimeCalc2.[h,cc]:
+     - added functionality to compute error of the extracted ArrivalTime
+     - calculated ArrivalTime is stored in MArrivalTimeCam
+
+   * manalysis/MGeomApply.cc
+     - geometry is applied to MArrivalTimeCam
+
+   * Makefile:
+     - directory msignal is included
+
+
+
+ 2004/02/17: Sebastian Raducci
+
+  * mtools/MCubicSpline.[h,cc]
+    - little corrections in minimums evalustion methods
+    - changed constructors (they require the fadc slices to be const)
+
+  * macros/spline.C
+    - changed according to the MCubicSpline new constructors 
+
+  * manalysis/MArrivalTimeCalc.[h,cc]
+    - changed to use the MCubicSpline class intead of the TSpline class
+    - warning: now the arrival time is again the maximum of the spline,
+      soon it will be changed to half maximum
+
+
+
+ 2004/02/17: Wolfgang Wittek
+
+  * manalysis/MSourcPosfromStarPos.[h,cc]
+    - new class; calculates the position of the source in the camera from
+                 the position of a star in the camera and puts it into
+                 MSrcPosCam
+
+
+
+ 2004/02/16: Abelardo Moralejo
+
+   * mcalib/MMcCalibrationCalc.cc
+     - Fixed two typos in screen output.
+
+
+
+ 2004/02/16: Markus Gaug
+
+   * mcalib/MCalibrationPix.cc
+     - documentation from David's email added
+     - EffectiveQE decreased from 0.2 to 0.18 (see documentation)
+
+   * mcalib/Makefile, mcalib/CalibLinkDef.h:
+     - added MExtractBlindPixel and MExtractedSignalBlindPixel
+
+   * mcalib/MExtractBlindPixel.[h,cc]
+     - new signal extractor for the Blind Pixel
+
+   * mcalib/MExtractedSignalBlindPixel.[h,cc]
+     - new container for the extracted signal of the BlindPixel
+
+   * mcalib/MCalibrationCalc.[h,cc]
+     - does not extract signal from Blind Pixel any more, searches 
+       for MExtractedSignalBlindPixel and fills the hists from there
+  
+   * macros/calibration.C, macros/bootcampstandardanalysis.C,
+     macros/pedphotcalc.C, mjobs/MJCalibration.cc:
+     - introduce the blind pixel and PIN diode extraction in the macro
+
+   * manalysis/MPedestalCam.h 
+     - changed type of fTotalEntries from ULong_t to UInt_t 
+     - fixed documentation of fTotalEntries
+
+   * manalysis/MPedCalcPedRun.h 
+     - changed type of fNumSamplesTot from ULong_t to UInt_t 
+
+   * mcalib/MHGausEvents.h
+     - changed type of fCurrentSize from ULong_t to UInt_t 
+    
+   * mcalib/MCalibrationConfig.h
+     - removed gkConversionHiLo and gkConversionHiLoErr which is now
+       directly in the class MCalibrationPix 
+
+
+
+ 2004/02/16: Thomas Bretz
+
+   * manalysis/AnalysisLinkDef.h:
+     - added missing MCerPhotEvtIter
+
+   * merpp.cc:
+     - added possible usage of database
+
+   * star.cc:
+     - moved source code into new class MJStar - preliminary
+
+   * manalysis/MCerPhotPix.cc:
+     - updated class header
+     - fixed Print-output
+
+   * mbase/MAGIC.h:
+     - removed definition of MLog
+
+   * mbase/MArgs.h:
+     - removed include of MAGIC.h
+
+   * mbase/MLog.h:
+     - added extern definition of gLog
+
+   * mbase/MParContainer.[h,cc]:
+     - move body of constructors to source file
+
+   * mcalib/MCalibrate.cc, mcalib/MCalibrateData.cc,
+     mraw/MRawCrateArray.cc, mraw/MRawCrateData.cc,
+     mraw/MRawEvtData.cc, mraw/MRawEvtHeader.cc, mraw/MRawRead.cc,
+     mraw/MRawEvtPixelIter.cc, mraw/MRawFileWrite.cc:
+     - fixed documentation header
+
+   * mcalib/MMcCalibrationCalc.[h,cc]:
+     - fixed documentation header
+     - fixed usage of FindCreateObj and FindObject
+     - removed data member to count entries (use histogram instead)
+     - use TH1 function Integral instead of doing it manually
+
+   * mfilter/MFCosmics.cc:
+     - fixed documentation
+
+   * mimage/MHillas.cc, mimage/MImgCleanStd.cc,
+     mimage/MNewImagePar.[h,cc]:
+     - replaced for-loops by Iterators
+
+   * mraw/MRawFileRead.cc, mraw/MRawSocketRead.cc:
+     - fixed documentation header
+     - check return value of MRawRunHeader::ReadEvt
+
+   * mraw/mraw/MRawRunHeader.[h,cc]:
+     - fixed documentation header
+     - added return value to MRawRunHeader::ReadEvt
+     - added constant number for max format version - preliminary 
+       (should by a static data member)
+
+   * mcalib/MHCalibrationPINDiode.cc:
+     - do not delete pointers in the destructor which are already
+       deleted in the base class
+     - reset histograms in Clear()
+
+   * mcalib/MHCalibrationPixel.cc:
+     - after deletion of instances in Clear() initialize pointer to NULL
+
+   * mcalib/MCalibrationCalc.cc, mcalib/MHCalibrationBlindPixel.cc:
+     - fixed usage of logging stream output levels
+
+   * manalysis/MPedCalcPedRun.[h,cc]:
+     - removed obsolete fSignals
+
+     - removed obsolete fNumPixels
+
+   * manalysis/MPedestalCam.h:
+     - added '->' to fArray
+
+   * mfileio/MWriteRootFile.cc:
+     - changed some output to make debugging easier
+
+   * mjobs/MJCalibration.cc:
+     - fixed a bug in drawing
+
+   * mjobs/MJExtractSignal.cc:
+     - removed MPedestalCam from MWriteRootFile output.
+       When creating the branch it crashes - reason unknown I'll
+       investigate further
+
+
+
+ 2004/02/16: Markus Gaug
+
+   * mcalib/Makefile, mcalib/CalibLinkDef.h, macros/calibration.C:
+     - added MHCalibrationRelTimePix
+
+   * mcalib/MHCalibrationRelTimePix.[h,cc],
+     mcalib/MHCalibrationRelTimeCam.[h,cc]:
+     - new classes to fit and display the relative arrival times. 
+     - filled from MArrivalTime	
+     - need: MFillH("MHCalibrationRelTimeCam","MArrivalTime")
+
+   * manalysis/MCalibrationCalc.cc
+     - take out all uncommented code referring to the relative arrival time
+
+   * manalysis/MArrivalTime.h 
+     - changed function GetNumPixels to GetSize
+
+   * macros/bootcampstandardanalysis.C, macros/pedphotcalc.C
+     - included cosmics rejection which was in MCalibrationCalc before
+
+
+
+ 2004/02/14: Markus Gaug
+
+   * mcalib/Makefile, mcalib/CalibLinkDef.h:
+     - added MHCalibrationChargePINDiode
+
+   * mcalib/MHCalibrationChargePINDiode.[h,cc]
+     - new class to fill the PIN Diode histograms. Derives from 
+       MHCalibrationChargePix and is filled with MFillH from the 
+       container MExtractedSignalPINDiode. 
+       Will replace MHCalibrationPINDiode entirely soon.
+
+   * mcalib/MHCalibrationChargePix.[h,cc]
+     - new base class for the calibration charges histogram pixel. 
+       Derives from MH and can be filled with the MH with the MH 
+       functions. 
+
+   * mcalib/MExtractPINDiode.[h,cc]
+     - new signal extractor for the PIN Diode
+
+   * mcalib/MExtractedSignalPINDiode.[h,cc]
+     - new container for the extracted signal of the PIN Diode
+
+   * mcalib/MCalibrationCalc.[h,cc]
+     - remove the PIN Diode signal extraction 
+
+   * manalysis/MHPedestalPix.[h,cc]
+     - new version of MHPedestalPixel, deriving from MHGausEvents.
+
+   * manalysis/MHPedestalPixel.[h,cc]
+     - old version removed, since obsolete (and erroneous)
+
+   * manalysis/MHPedestalCam.[h,cc]
+     - histogramming part of MPedestalCam now in own class 
+
+   * manalysis/MPedestalPix.h
+     - removed include of MHPedestalPixel
+
+   * macros/calibration.C 
+     - changed pedestal displays accordingly
+
+   * mjobs/MJPedestal.h
+     - class TCanvas included (did not compile otherwise)
+
+   * mhbase/MH.cc
+     - included call to FindGoodLimits(..) in CutEdges()
+     - axe from pointer to reference
+     - "CutEdges" renamed to "StripZeros"
+ 
+   * manalysis/MHPedestalPixel.cc, mcalib/MHCalibrationPixel.cc,
+     mcalib/MHCalibrationBlindPixel.cc:
+     - "CutEdges" renamed to "StripZeros"
+
+   * mcalib/MHGausEvent.[h,cc], mcalib/Makefile, mcalib/CalibLinkDef.h:
+     - replaced by the improved version: MHGausEvents.[h,cc]
+
+
+
+ 2004/02/14: Thomas Bretz
+
+   * manalysis/MCerPhotEvt.[h,cc]:
+     - added 'Iterator' facility, this will replace some for-loops
+       in the near future
+     
+   * mbase/MTime.[h,cc]:
+     - added a more powerfull interface to get and interprete the
+       MTime contents as string
+     - added a new constructor
+
+   * mreport/MReportTrigger.h:
+     - fixed GetPixContent
+
+   * mtools/MCubicCoeff.cc, mtools/MCubicSpline.[h,cc]:
+     - many small changes to simple details (like order of includes)
+     - some speed improvements
+     - many small simplifications
+     - changed parts of the code to be more C++ like (eg Iterators
+       instead of for-loops)
+     - disentangles some if-cases
+     - replaced some math.h function by TMath::
+     - removed data-member fN (obsolete with iterators)
+
+
+
+ 2004/02/13: Wolfgang Wittek
+
+   * mcalib/MCalibrateData.[h,cc]
+     - new class; 
+       like MCalibrate, but in ReInit it fills the MPedPhot container
+       using informations from MPedestal, MExtracteSignalCam and 
+       MCalibrationCam
+
+   * mcalib/Makefile, mcalib/CalibLinkDef.h
+     - added MCalibrateData
+
+   * manalysis/MPedestalWorkaround.[h,cc]
+     - create MMcEvt container and fill with theta = 10.0
+     - set pedestalRMS = 0. if it is > 10.0
+
+   * manalysis/MSupercuts.[h,cc]
+     - change default values of parameters
+
+   * manalysis/MSupercutsCalc.[h,cc]
+     - change dNOMLOGSIZE from 4.1 to 5.0
+
+   * mhist/MHBlindPixels.[h,cc]
+     - change MPedestalCam to MPedPhotCam
+
+   * mhist/MHSigmaTheta.[h,cc]
+     - automatic binning for pixel number doesn't work
+       use default binning
+
+
+
+ 2004/02/13: Markus Gaug
+
+   * mcalib/MCalibrationPix.[h,cc]
+     - added variables gkAverageQE, gkAverageQEErr, and fAverageQE, 
+       fAverageQEErr
+     - gkAverageQE initializes to 0.2 (according to David)
+     - gkAverageQEErr initializes to 0.02 (dito)
+     - added new member function: SetAverageQE
+     - call to GetMeanConversionFFactorMethod returns: 
+       fMeanConversionFFactorMethod/fAverageQE. 
+     - call to GetErrorConversionFFactorMethod returns: 
+       errors of fMeanConversionFFactorMethod and fAverageQEErr added 
+       quadratically
+
+   * mcalib/Makefile
+     - split into two parts one comment line 
+
+
+ 2004/02/13: Thomas Bretz
+
+   * mbadpixels/MBadPixelsTreat.[h.cc]:
+     - added for new bad pixel treatment
+
+   * mbadpixels/Makefile, mbadpixels/BadPixelsLinkDef.h:
+     - added MBadPixelsTreat
+
+   * merpp.cc:
+     - changed the name of the "DC" tree to "Currents" to make
+       MReportRead work correctly with this tree
+
+   * mbase/MTime.[h,cc]:
+     - Changed UpDMagicTime to support nanosec instead of millisec
+     - exchanged Reset() by Clear() not to clear the yy/mm/dd 
+       information away in an eventloop
+
+   * mraw/MRawEvtHeader.[h,cc]:
+     - implemented decoding of the time-stamp for raw-data files
+       with version>2. Thanks to Marcos.
+
+   * mraw/MRawRead.[h,c]:
+     - pipe file version number to MRawEvtHeader::ReadEvt
+     - create fake time for file-version<3
+
+   * macros/readMagic.C:
+     - changed to use MInteractiveTask
+
+   * mbase/MPrint.cc:
+     - fixed debugging level of some output
+     
+   * mhist/MHCamera.[h,cc]:
+     - fixed handling in AddNotify (necessayr due to change of
+       inheritance from MCamEvent)
+     - replaced cout by gLog
+     - added fNotify to list of cleanups
+
+   * mhist/MHEvent.cc, mjobs/MJCalibration.cc,
+     mjobs/MJPedestal.cc:
+     - fixed usage of AddNotify
+
+   * mfileio/MReadReports.cc:
+     - use a different way to determin whether the tree is a valid tree,
+       skip invalid trees
+       
+   * mfileio/MReadTree.cc:
+     - added another sanity check at the beginning of PreProcess
+     
+   * mhbase/MFillH.[h,cc]:
+     - added bit kCanSkip which skips MFillH in case the necessary container
+       wasn't found.
+     - cd into the corresponding canvas before filling the MH
+
+
+
+ 2004/02/12: Markus Gaug
+ 
+   * mbase/MArray.[h,cc]:
+     - changed name of StripZeros
+
+   * mcalib/MHGausEvent.cc:
+     - corrected call to StripZeros
+
+   * mcalib/MCalibrationPix.[h,cc]
+     - implemented dummy for combined method
+
+   * mcalib/MCalibrate.[h,cc]
+     - implemented a dummy for calibration factor 1. (requested by
+       Javier Rico)
+     - implemented combined method
+     - check for valid methods moved to ReInit
+
+   * mcalib/MCalibrationCalc.cc
+     - removed initialization of non-used nsamples
+
+   * mcalib/MHCalibrationPixel.[h,cc], mcalib/MCalibrationPix.[h,cc],
+     mcalib/MCalibrationCalc.[h,cc]
+     macros/calibration.C
+     - implemented new histograms: 
+       HSinglePheFADCSlices and HPedestalFADCSlices
+       They are filled with the FADC slice values of either a s.phe. 
+       event or a pedestal event. The decision is taken with the 
+       variable: MCalibrationCalc::fBlindPixelSinglePheCut, to be set 
+       with a setter 
+
+   * mtools/MFFT.[h,cc]
+     - PowerSpectrumDensity of TArrayI implemented
+
+
+
+ 2004/02/12: Thomas Bretz
+ 
+   * mbase/MArray.[h,cc]:
+     - changed argument of CutEdges from pointer to reference
+
+   * mgeom/MGeomPix.h:
+     - fixed calculation of area of pixel. It was too big for a 
+       factor of 2
+
+   * mjobs/MJCalibration.cc:
+     - slight change of name of a MHCamera
+
+   * manalysis/MExtractSignal.cc:
+     - slight change to the creation of the satpixels list
+     
+   * mcalib/MHCalibrationBlindPixel.cc, mcalib/MHCalibrationPixel.cc,
+     mcalib/MHGausEvent.cc:
+     - corrected call to ProjectArray
+     - corrected call to CutEdges
+     
+   * mfilter/MFCosmics.[h,cc]:
+     - small fixes to logging output
+     - small simplification to return statement
+     - declared CosmicsRejection const
+
+   * mhbase/MH.[h,cc]:
+     - changed argument of ProjectArray from pointer to reference
+     - added missing calcualtion of minimum
+     - removed obsolete SetEntries
+     - changed SetDirectory from NULL to gROOT
+
+
+
+ 2004/02/12: Javier L�ez
+
+   * macros/pointspreadfunction.C
+     - added new macro that fits with a 2D gaussian the DC spot for an 
+       star. It gives you the RMS of the PSF and the center of the star,
+       very useful for misspointing studies.
+
+
+
+ 2004/02/11: Hendrik Bartko
+
+   * manalysis/MExtractSignal2.cc:
+     - introduced a validity check for the set-function of the window 
+       size (even number of slices, WindowSize < NumberSlices)
+
+   * manalysis/MArrivalTimeCalc2.[h,cc], manalysis/Makefile, 
+     manalysis/AnalysisLinkDef.h:
+     - new: introduced the calculation of the arrival time as the signal 
+       weighted mean of the time slices in the maximum window
+
+
+
+ 2004/02/11: Markus Gaug
+
+   * mcalib/MCalibrationCalc.cc:
+     - the blind pixel signal extractor introduced one week ago, counted 
+       one FADC slice too little, thus the normalization w.r.t. pedestals 
+       was wrong. Now corrected.
+
+   * manalysis/MExtractSignal.cc, manalysis/MExtractSignal2.cc:
+     - when "WARNING - Lo Gain saturated" occurs, display also the
+       corr. pixel numbers.
+
+   * mbase/MArray.[h,cc]:
+     - introduced function to cut array edges with zeros. 
+       (Thomas, should we keep it there or move it to another class? )
+
+   * mcalib/MCalibrationCalc.[h,cc]:
+     - new function SetBlindPixelRange to set start and end of FADC slices 
+       used for the blind pixel signal extraction. 
+     - remove fEvents which are not necessary any more after the shift 
+       to MFCosmics.
+
+   * mcalib/MHCalibration(Blind)Pixel.[h,cc]:
+     - show the fourier spectrum now with axes in frequency [Hz] instead 
+       of inverted events. 
+
+   * mcalib/MHGausEvent.[h,cc], mcalib/Makefile, mcalib/CalibLinkDef.h:
+     - new base class for all kind of events with variables having a 
+       Gaussian distribution. Will serve as base class for the 
+       existing and new calibration histogram classes. 
+
+
+
+ 2004/02/11: Abelardo Moralejo
+
+   * mmain/MEventDisplay.cc
+     - Switched order of MMcPedestalCopy and MCerPhotCalc in tasklist:
+       MMcPedestalCopy must be executed earlier!
+
+
+
+ 2004/02/10: Raquel de los Reyes
+
+   * mhist/MHPixVsTime.[h,cc]:
+     - Added a default draw function and replaced the TGraph object 
+       by a pointer to a TGraph object.
+
+   * mreport/MReportTrigger.h:
+     - Now it dereives from a MCamEvent class and implemented the
+       GetPixContent() and DrawPixelContent() functions.
+
+   * maccros/CCDataCheck.C:
+     - An update of the previous macro. New plots: subsystems status and
+       macrocells trigger.
+
+
+
+ 2004/02/10: Markus Gaug
+
+   * mcalib/MCalibrationCam.cc:
+     - fixed documentation
+
+   * mhbase/MH.[h,cc]:
+     - new function ProjectArray
+
+   * mcalib/MHCalibrationPixel.[h,cc],
+     mcalib/MHCalibrationBlindPixel.[h,cc]:
+     - use ProjectArray from MH to plot the projection of the fourier 
+       spectrum
+
+   * mfilter/MFCosmics.[h,cc], mfilter/Makefile,
+     mfilter/FilterLinkDef.h:
+     - new filter removing cosmics, the same as in MCalibrationCalc
+       where it was removed now. 
+       Call: MFCosmics cosmics; 
+             MContinue cont(&cosmics); 
+             tlist.AddToList(&cont);
+
+   * mcalib/MCalibrationCalc.[h,cc]:
+     - removed cosmics rejection from there
+ 
+   * macros/calibration.C, mjobs/MJCalibration.cc:
+     - changed cosmics rejection to the filter algorithm
+
+
+
+ 2004/02/09: Markus Gaug
+
+   * mcalib/MCalibrationBlindPix.[h,cc]:
+     - added histogram to display the average in FADC slices of all 
+       single and double phe events
+
+   * mcalib/MCalibrationCalc.cc:
+     - fill histograms of single-phe events with higain and logain
+       sampls
+
+   * mcalib/MCalibrationCam.[h,cc], mcalib/MCalibrationCalc.cc,
+     mcalib/MCalibrationConfig.h:
+     - take all pixel areas out of MGeomPix::GetA(), remove all previous
+       areas 
+     - calculate photon fluxes from blind pixel and PIN diode, use 
+       area only to fill the conversion factors in MCalibrationPix 
+
+
+   * mcalib/MJCalibration.cc:
+     - display of number of photons for Blindpixel and PIN Diode Method 
+       changed to display of photon flux which is the actually 
+       calculated quantity
+
+
+
+ 2004/02/09: Thomas Bretz
+
+   * mbadpixels/*:
+     - added
+
+   * Makefile:
+     - added MBadPixels
+
+   * manalysis/MGeomApply.cc:
+     - fixed class description
+
+   * mjobs/MJCalibration.[h,cc], mjobs/MJExtractSignal.[h,cc]:
+     - added bad pixel treatment
+
+   * mjobs/MJPedestal.[h,cc]:
+     - reorganized order of functions
+     - removed a nonsense scrren output (some BLABABLA or so)
+
+   * mjobs/Makefile:
+     - added include for mbadpixels
+
+   * mmain/MBrowser.cc:
+     - do not call construtor of TGTReeLBEntry if pic0=0
+
+
+
+ 2004/02/09: Raquel de los Reyes
+
+   * mcamera/MCameraLids.h, mreport/MReportCamera.h
+     - Added the "Get" functions to access the private data 
+       members of the class.
+
+
+
+ 2004/02/09: Markus Gaug
+
+   * MMcCalibrationUpdate.cc, MCalibrate.cc, MCalibrationPix.cc,
+     MCalibrationPix.h:
+     - replace MCalibrationPix->IsChargeFitValid() by IsChargeValid()
+       because we can calibrate with the histogram mean and RMS even 
+       if the fit is not OK. Thus, there is a question: IsFitted() and 
+       IsChargeValid(), i.e. does the charge make any sense? 
+
+   * MCalibrationCam.cc, MCalibrationConfig.h, MCalibrationCalc.cc:
+     - found serious bug in calculation of conversion factors for the 
+       outer pixels: 
+       GetMeanConversionBlindPixelMethod and 
+       GetMeanConversionPINDiodeMethod 
+       did not correct for the area of the outer pixel, this did only 
+       MCalibrationCam::GetPixelContent which is not used by MCalibrate
+
+
+
+ 2004/02/06: Markus Gaug
+
+   * mgeom/MGeomCam.h 
+     - replaced in Comment of fPixRatio: 
+       "ratio between size of pixel idx and pixel 0" by
+       "ratio between size of pixel 0 and pixel idx" 
+
+   * manalysis/MPedestalCam.cc
+     - catch calls to MHPedestalPixel in case that they are not filled 
+       This led previous calls to segmentation violations
+     - remove include of MHExtractedSignalPix
+ 
+   * manalysis/MHExtractedSignalPix.[h,cc]
+     - is everything in MHPedestalPixel, so removed it again
+
+   * mjobs/MJPedestal.cc
+     - put the projections into Display()
+     - correct the input of Display (0: pedestal, 1: pedestalerror, 
+                                     2: pedRMS, 3: pedRMSerror)
+
+   * manalysis/MHPedestalPixel.cc
+     - increased number of bins in for charges plot
+
+   * mtools/MFFT.[h,cc]
+     - possibility to have PSD directly from TArray
+
+   * mjobs/MJCalibration.[h,cc]
+     - fixed displays
+     - replaced MExtractSignal by MExtractSignal2
+
+   * mcalib/MHCalibrationPixel.[h,cc], mcalib/MHCalibrationBlindPixel.[h,cc],
+     mcalib/MCalibrationPix.[h,cc], mcalib/MCalibrationBlindPix.[h,cc],
+     mcalib/MCalibrationPINDiode.[h,cc], mcalib/MHCalibrationPINDiode.[h,cc]:
+     - remove histograms MHChargevsN..., now keep TArrays directly
+     - check for oscillations for all pixels (and you will not trust 
+       your eyes when you look at the results :-((((
+
+   * mcalib/MCalibrationCalc.[h,cc]
+     - remove ArrivalTime -> go to separate class
+     - remove BlindPixel and PIN Diode overflow, now handled directly 
+       inside the corr. classes. 
+     - remove SkipTimeFits -> go the arrival time class
+
+   * mcalib/MCalibrationCam.h
+     - new getters for number of photons
+     - removed timeslicewidth -> go the corr. time containers
+
+   * mcalib/MCalibrationCam.cc
+     - removed times of GetPixelContent
+     - added OscillationChecks in GetPixelContent
+
+   * manalysis/MMcCalibrationUpdate.cc
+     - remove calpix.SkipTimeFits which is now obsolet
+
+   * macros/calibration.C
+     - all previous changes now in this macro.
+     - (NB: Thomas, du brauchst in MJCalibration nicht mehr aendern, 
+       das ging diesmal in einem Aufwasch)
+
+
+
+ 2004/02/06: Thomas Bretz
+
+   * mhist/MHPixVsTime.[h,cc]:
+     - changed such that you can set the name of the time container now 
+
+   * mraw/MRawRunHeader.[h,cc]:
+     - added GetMaxPixId()
+
+   * mraw/MRawEvtData.cc:
+     - fixed wrong size calculation for fABflags
+
+
+
+ 2004/02/06: Oscar Blanch
+
+   * mmc/MFadcDefine.h && mmc/MMcFadcHeader.cxx
+     - We cahnged the name (and values) of the global variable
+        MFADC_RESPONSE_AMPLITUDE to  MFADC_RESPONSE_INTEGRAL
+
+
+
+ 2004/02/05: Markus Gaug
+
+   * mcalib/MHCalibrationPixel.[h,cc]
+     - put an NDF limit for the fit
+     - removed all TStrings and replace them by Form(..)
+     - Check for nan's of all returned fit values
+
+   * mcalib/MCalibrationPix.[h,cc], mcalib/MCalibrationCam.cc:
+     - reshuffled HiLoGainConversion, calculation of F-Factor method, 
+     - calculation of total F-Factor of the readout.
+
+   * mcalib/MCalibrationCam.cc
+     - include relative times to display with GetPixelContent
+
+   * mcalib/MCalibrationCalc.[h,cc]
+     - flag to skip Hi-Lo Calibration
+     - Hi-LO Graph not filled any more after overflow of ChargevsN
+     - fill the blind pixel differently from the rest of pixels
+
+   * mcalib/MCalibrate.cc:
+     - call to const MCalibrationPix &pix replaced by MCalibrationPix &pix
+
+   * manalysis/MArrivalTimeCalc.cc
+     - default step width 100 ps. 
+     - look for half maximum (at rising edge)
+
+   * manalysis/MExtractSignal.[h,cc]
+     - removed uncommented code (arrival time)
+     - set start byte back by one like it was before TB's changes 
+       (does not affect the calculation of number of FADC slices)
+
+   * manalysis/MExtractSignal2.[h,cc]
+     - removed uncommented code (arrival time)
+
+   * manalysis/MHPedestalPixel.[h,cc]
+     - is now filled with total pedestals (not per slice), but results are 
+       renormalized to values per slice (this is not to screw up with the 
+       pedestal RMS and the derived uncertainties)
+     - new function Renorm(nslices)
+
+   * manalysis/MPedestalCam.[h,cc]
+     - introduced function Clone() (like proposed by TB)
+     - call to MHPedestalPixel operator() not const any more
+     - take out lots of uncommented code 
+     - found bug in initialization of hists. SetupFill is called in 
+       PreProcess, therefore, TObjArray is not yet enlarged there. 
+       Now, InitUseHists is called in Fill
+     - MHPedestalPixel is now filled with total pedestals (not per slice), 
+	but results are 
+       renormalized to values per slice (this is not to screw up with the 
+       pedestal RMS and the derived uncertainties)
+
+   * manalysis/MPedCalcPedRun.cc
+     - added author
+     - split calculation of RMS into two steps to make it more clear to 
+       the user
+
+   * macros/calibration.C
+     - found bug introduced two days ago, namely calculating pedestlas with 
+       MExtractSignal2 which is now fixed
+     - Skip HiLoConversionCalibration
+
+
+
+ 2004/02/05: Abelardo Moralejo
+
+   * macros/starmc2.C
+     - added 3rd argument, "kFALSE", to call of MWriteRootFile::Add
+       for both MMcEvt and MMcRunHeader since these containers are
+       not present in real data. Name of macro is no longer adequate if
+       we will use it for calibrated real data (to be changed if so).
+
+
+
+ 2004/02/05: Sebastian Raducci
+
+   * mtools/MCubicSpline.[h,cc]
+     - added
+     - this class will take the place of the TSpline class to 
+       calculate arrival times
+
+   * mtools/MCubicCoeff.[h,cc]
+     - added
+     - this class is used by MCubicSpline to store coefficients
+
+   * macros/spline.C
+     - added
+     - test macro. Shows how to use the MCubicSpline class
+     - it could be used to test the methods of the Spline class
+
+
+
+ 2004/02/05: Thomas Bretz
+
+   * mmain/MBrowser.cc:
+     - fixed a double deletion of a TGLayoutHints
+
+
+
+ 2004/02/04: Markus Gaug
+
+   * mmain/MBrowser.cc:
+     - corrected TGTReeLBEntry for TGTreeLBEntry
+
+
+
+ 2004/02/04: Thomas Bretz
+ 
+   * manalysis/MExtractSignal2.cc:
+     - don't allow odd numbers for the window size
+
+   * mfilter/MFilterList.cc:
+     - corrected a wrong logging message
+
+   * mmain/MBrowser.cc:
+     - added '/data/MAGIC' as shortcut in the combo box
+     
+   * mraw/MRawEvtPixelIter.cc:
+     - optimized calculation of MaxIdx
+
+
+
+ 2004/02/04: Abelardo Moralejo
+
+  * macros/starmc2.C
+    - removed unnecessary variables BinsHigh, BinsLow
+
+
+
+ 2004/02/04: Markus Gaug
+
+  * manalysis/MPedestalCam.[h,cc], manalysis/MPedestalPix.[h,cc],
+    manalysis/MPedCalcPedRun.[h,cc], manalysis/MHPedestalPixel.[h,cc],
+    macros/calibration.C:
+    - histograms are now filled with MFillH as proposed and coded by 
+      Thomas Bretz. Some modifications had to be done, however. 
+    - Class to hold MHPedestalPixel is still MPedestalCam
+    - MPedCalcPedRun does nothing any more (except from what is was 
+      doing before)
+
+  * manalysis/MExtractSignal.cc
+    - remove uncommented code
+
+  * mcalib/MCalibrationCalc.[h,cc]
+    - modified way to handle histogram overflow: Now flags are set and 
+      ChargevsN histogram is not tried to be filled subsequently
+
+
+
+ 2004/02/03: Markus Gaug
+ 
+   * manalysis/MHExtractedSignalPix.[h,cc]
+     - added Thomas B. modified version of MHPedestalPixel. Later will 
+       remove MHPedestalPixel
+
+   * manalysis/MCalibrationPix.[h,cc], manalysis/MHCalibrationPixel.[h,cc],
+     manalysis/MCalibrationCam.cc, macros/calibration.C:
+     - now split completely absolute and relative times. Absolute 
+       times are not fitted, but their histogram mean and rms are 
+       returned.
+
+
+
+ 2004/02/03: Thomas Bretz
+
+   * mfileio/MReadTree.cc:
+     - fixed handling of -1 entries in AddFile: root 3.10/02 crashed
+
+   * manalysis/MExtractSignal.[h,cc]:
+     - moved code to extract the signal from Process to
+       new member function FindSignal, I left the arrival time 
+       extraction as commented-out code in the code just as a 
+       demonstration to do this very fast.
+
+
+
+ 2004/02/02: Markus Gaug
+
+  * manalysis/MPedCalcPedRun.cc
+    - corrected formulae in Class description
+
+  * mcalib/MCalibration.[h,cc], mcalib/MHCalibration.[h,cc],
+    manalysis/MMcCalibrationUpdate.cc:
+    - calculate relative times and absolute times. Fit only 
+      the relative ones. 
+
+
+
+ 2004/02/02: Abelardo Moralejo
+
+   * manalysis/MMcCalibrationUpdate.cc, MMcPedestalCopy.cc
+     - removed file type check (MC or data) from PreProcess since now
+       run headers are not yet known at that point.
+
+   * mcalib/MMcCalibrationCalc.cc
+     - same as above.
+
+   * NEWS
+     - updated.
+
+
+
+ 2004/02/02: Thomas Bretz
+
+   * manalysis/MExtractSignal2.[h,cc]:
+     - added new task which takes a given number of slices with the
+       highest integral content as signal.
+
+   * manalysis/Makefile, manalysis/AnalysisLinkDef.h:
+     - added MExtractSignal2
+
+
+
+ 2004/01/30: Abelardo Moralejo
+
+   * macros/starmc.C
+     - changed default FADC integration range (more adequate for coming
+       camera version).
+
+   * macros/mccalibrate.C, starmc2.C
+     - added. First macro transforms input files from camera simulation
+       into files with pixel data already calibrated in photons. The 
+       second reads in an already calibrated data file and produces an 
+       output file with Hillas parameters. Both together do the same as
+       starmc.C, but it is convenient to have files containing 
+       calibrated pixel information.
+
+
+
+ 2004/01/30: Thomas Bretz
+ 
+   * mbase/MDirIter.h:
+     - added GetNumEntries
+
+   * mhist/MHEvent.cc:
+     - added a dynamic_cast from MParContainer to MCamEvent to get the
+       correct pointer to the correct base-class.
+
+   * mbase/MStatusDisplay.cc:
+     - In EventInfo check whether gPad==0
+     
+   * mfileio/MReadMarsFile.cc:
+     - removed reading RunHeaders from PreProcess, this resulted
+       in strange behaviour of writing RunHeaders
+     - fixed consistency check for RunType accordingly
+
+   * mfilter/MFilterList.cc:
+     - do not skip adding filter if only a filter with the same name 
+       exists
+       
+   * mraw/MRawFileRead.cc:
+     - added an output message if run header is not accessible
+     
+   * mraw/MRawRunHeader.[h,cc]:
+     - initialize fRunType to new enum kRTNone
+
+   * mfilter/MFGeomag.cc:
+     - set fResult to kFALSE at the beginning of Process
+     - according to this removed setting fResult=kFALSE before return
+     - replaced some float by Float_t
+     - added some const-qualifiers
+     - replaced (rig<0.5/pr*R*(r2-r1)+r1) by (rig-r1)*pr<rnd
+       with rnd = R * (r2-r1)/2 to make sure that we cannot
+       devide by 0
+
+   * manalysis/MPedCalcPedRun.cc:
+     - added some comments
+
+   * Makefile:
+     - added mjobs
+
+   * mjobs/*:
+     - added
+
+   * mbase/Makefile, mbase/BaseLinkDef.h:
+     - added MRunIter
+
+   * mbase/MRunIter.[h,cc]:
+     - added
+
+
+
+ 2004/01/30: Markus Gaug
+
+   * manalysis/MPedestalCam.h
+     - added function IsUsedHists()
+
+   * manalysis/MPedestalCam.cc
+     - modified GetPixelContent
+
+   * manalysis/MPedestalCam.cc, manalysis/MPedCalcPedRun.cc:
+     - include storage of number of used FADC slices to compare later 
+       the pedestal per slice ( and sigma per slice)
+     - return relative differences in GetPixelContent
+
+   * mcalib/MCalibrationCalc.[h,cc], mcalib/MHCalibrationBlindPixel.[h,cc]:
+     - fBlindPixelId and fPINDiodeId now like in PedestalCam
+     - fill Blind Pixel with information about its fitted pedestal if 
+       available
+     - initialize charges histogram with a bigger range
+     - use pedestal information to constrain the pedestal fit ranges
+
+   * manalysis/MHPedestalPixel.cc
+     - initialize charges histogram with a bigger range
+
+   * macros/calibration.C
+     - SetRange of MExtractSignal to 1,14 (see emails of yesterday)
+     - apply new GetPixelContents of MPedestalCam (more calculations 
+       and displays of errors, correction for different FADC slice 
+       number)
+
+   * manalysis/MExtractSignal.cc
+     - not access to MArrivalTime any more. The same information is 
+       stored in MRawEvt->GetPixelContent(...)
+
+   * manalysis/MCalibrationCalc.cc
+     - retrieve default arrival time from MRawEvt 
+
+   * manalysis/MCalibrationBlindPix.cc, manalysis/MCalibrationPix.cc
+     - check for NaN's in fit results
+
+
+
+ 2004/01/29: Abelardo Moralejo
+
+   * mfileio/MWriteFile.h
+     - added missing declaration of ReInit
+
+   * manalysis/MMcCalibrationUpdate.cc
+     - added call to MCalibrationCam::SetBlindPixelMethodValid(kTRUE) 
+       to adapt to recent changes in MCalibrate.
+
+
+
+ 2004/01/29: Thomas Bretz
+
+   * manalysis/MArrivalTime.h, manalysis/MCameraData.h,
+     manalysis/MCerPhotEvt.h, manalysis/MExtractSignalCam.h,
+     manalysis/MPedPhotCam.h, manalysis/MPedestalCam.h,
+     mcalib/MCalibrationCam.h, mcamera/MCameraDC.h,
+     mraw/MRawEvtData.h, mreflector/MRflEvtData.h:
+     - split derivement into MParContainer and MCamEvent
+
+   * manalysis/MExtractSignalCam.[h,cc]:
+     - removed obsolete MExtractSignal::ReInit
+     - added -> to fArray
+
+   * mbase/MParList.h:
+     - added a new bit kIsProcessing
+     
+   * mbase/MTaskList.cc:
+     - fixed the handling of kDoNotReset and the bahaviour of
+       SetReadyToSave, such that it is possible to write all
+       headers 
+
+   * mfileio/MWriteFile.cc:
+     - added ReInit which also calls CheckAndWrite
+     
+   * mgui/MCamEvent.h:
+     - does not derive from MParContainer anymore
+
+
+
+ 2004/01/29: Markus Gaug
+
+   * mcalib/MCalibrationCalc.[h,cc], mcalib/MCalibrationCam.[h,cc], 
+     mcalib/MCalibrationConfig.h
+     - put gkCalibrationBlindPixelId and gkCalibrationPINDiodeId 
+       directly into the corresponding classes.
+
+
+
+ 2004/01/29: Nicola Galante
+
+   * mhistmc/MHMcTriggerLvl2.[h,cc]:
+     - In method MHMcTriggerLvl2::GetHistByName(const TString name) 
+       added string checking to return also 
+       fHistCellPseudoSize, fHistCellPseudoSizeNorm
+       and fHistCellPseudoSizeEnergy.
+     - Added inline functions GetHistCellPseudoSize() and 
+       GetHistCellPseudoSizeNorm().
+
+
+
+ 2004/01/28: Javier Rico
+
+   * mcalib/MCalibrate.[h.cc]
+     - include possibility to select the calibration method to be used
+
+
+
+ 2004/01/28: Markus Gaug
+
+   * mcalib/MCalibrate.[h.cc]
+     - corrected Int_t ReInit() to Bool_t ReInit(MParList *pList)
+
+   * mcalib/MCalibrationCalc.[h,cc], mcalib/MCalibrationCam.[h,cc]:
+     - included flags to indicate if Blind Pixel Method or PIn Diode 
+       method was OK. Up to now, program stopped, if one of the two 
+       methods was chosen but not able to being executed.
+
+   * manalysis/MArrivalTimeCalc.cc, manalysis/MExtractSignals.cc,
+     manalysis/MGeomApply.cc:
+     - put all missing InitSize(npixels) into MGeomApply	 
+
+   * manalysis/MPedCalcPedRun.[h,cc], manalysis/MPedestalCam.[h,cc],
+     manalysis/MPedestalPix.[h,cc], manalysis/MHPedestalPixel.[h,cc],
+     manalysis/Makefile, manalysis/AnalysisLinkDef.h:
+     - include possibility to fit the pedestals with Gaussian. 
+     - old methods are not affected. 
+     - add new method with MPedCalcPedRun::SetUseHists()
+
+
+
+ 2004/01/28: Abelardo Moralejo
+
+   * mcalib/MMcCalibration.cc
+     - fixed wrong variable type in call to TH1F constructor (number of
+       bins is now integer), which resulted in a compilation warning.
+
+
+
+ 2004/01/28: Thomas Bretz
+
+   * manalysis/MPedestalCam.cc:
+     - removed unwanted CheckBound from operators. CheckBounds is ONLY
+       ment for really old MC files and will be removed in the future
+       anyhow.
+
+   * mcalib/MHCalibrationPixel.h:
+     - removed obsolete include of MFFT 
+
+   * manalysis/MCerPhotAnal.cc, manalysis/MCerPhotCalc.cc,
+     manalysis/MPedestalCam.[h,cc]:
+     - removed use of obsolete MPedestalCam::CheckBounds. This was
+       a workaround for a 'bug' in very old camera files, which is not
+       necessary anymore.
+
+   * manalysis/MCerPhotAnal2.[h,cc]:
+     - replaced MPedestalCam by MPedPhotCam
+     
+   * manalysis/MExtractSignal.cc:
+     - some small simplification to the signal extraction
+     - removed some obsolete variables
+     - replaced for by while
+     - removed obsolete casts
+     
+   * mmain/MEventDisplay.cc:
+     - gave names to the filters
+     - removed adding MHCamera to fList because it was deleted twice
+
+   * mhist/MHCamera.cc:
+     - fixed usage of fPainter in Paint() - title was not updated 
+       correctly
+
+
+
+ 2004/01/28: Sebastian Raducci
+
+   * manalysis/MArrivalTime.[h,cc]:
+     - removed all the code relative to the cluster evaluation
+
+
+
+ 2004/01/27: Markus Gaug
+ 
+   * manalysis/MPedestalPix.cc:
+     - initialize default values to 0 instead of -1.
+
+   * manalysis/MPedestalCam.[h,cc]:
+     - include CheckBounds, also in operator[]
+
+   * mcalib/MCalibrationCam.[h,cc]:
+     - apparently, there was a reference to InitSize(UInt_t i) instead 
+       of InitSize(Int_t i), where compiler complained, now changed
+ 
+   * mcalib/MHCalibration*, mcalib/MCalibration*:
+     - fixed all Clear()'s, Reset()'s, direct intializers
+
+
+
+ 2004/01/27: Thomas Bretz
+
+   * mdata/MDataChain.cc:
+     - added '%' to supported operators
+
+
+
+ 2004/01/26: Nicola Galante
+
+   * manalysis/MMcTriggerLvl2.[cc,h]:
+
+     - Defined some static constants to avoid ugly "magic numbers"
+       in arrays: gsNCells, gsNTrigPixels,
+       gsNPixInCell, gsNLutInCell, gsNPixInLut, fNumPixCell.
+     - Added method 
+       MMcTriggerLvl2::GetCellCompactPixel(int cell, MGeomCam *fCam)
+       which computes compact pixels into a given L2T macrocell.
+     - Added method 
+       MMcTriggerLvl2::CalcBiggerCellPseudoSize() 
+       which computes fCellPseudoSize, the maximum Pseudo Size into L2T 
+       macrocells
+     - Added method 
+       MMcTriggerLvl2::GetCellPseudoSize() const 
+       which returns fCellPseudoSize
+     - Added method 
+       MMcTriggerLvl2::IsPixelInCell(Int_t pixel, Int_t cell),
+       which controls whether a pixel belongs to a given L2T cell.
+     - Added method 
+       MMcTriggerLvl2::GetMaxCell() const 
+       which returns fMaxCell, the cell with the maximum 
+       fCellPseudoSize.
+
+
+
+ 2004/01/26: Markus Gaug, Michele Doro
+
+   * manalysis/MArrivalTime.[h,cc], manalysis/MArrivalTimeCalc.[h,cc]:
+     - moved calculation of arrival time from MArrivalTime to 
+       MArrivalTimeCalc. MArrivalTime does not do any Process-job
+       anymore
+     - TSpline5 now on stack. 
+     - function to set the stepsize
+
+   * mcalib/MHCalibrationBlindPixel.[h,cc]:
+     - force mu_{0} in Blind Pixel Fit to be around 0 in fKPoisson4
+     - implement combined Polya fit and Michele's back-scattered electron
+       fit 
+
+   * mcalib/MHCalibrationPixel.[h,cc], mcalib/MCalibrationPix.cc,
+     mcalib/MCalibrationPINDiode.cc:
+     - combine FitChargeHiGain and FitChargeLoGain into one function
+
+   * macros/calibration.C
+     - improve double gauss fit a bit
+
+
+
+ 2004/01/26: Thomas Bretz
+
+   * mraw/MRawEvtPixelIter.[h,cc]:
+     - removed member function GetNumPixels. For more details see mantis.
+
+   * manalysis/MArrivalTime.[h,cc]:
+     - reorganized includes
+     - fixed InitSize and ClearArray (now Reset) to fit MParContainer
+       definition
+     - for the moment removed usage of fPixelChecked - THIS WILL CRASH YOUR
+       PROGRAM
+
+   * manalysis/MArrivalTimeCalc.[h,cc]:
+     - reorganized includes
+     - removed many obsolete code, exspecially copy&paste relicts!
+     - fixed usage of InitSize
+     - removed CleanArray. Reset() is called automatically before Process()
+
+   * manalysis/MExtractedSignalCam.[h,cc]:
+     - added SetLogStream
+     - removed obsolete include MGeomCam
+     - replaced PrintOut by Print
+     - added const-qualifiers to all Getters
+     - fixed documentation
+     
+   * manalysis/MExtractedSignalPix.[h,cc]:
+     - replaced PrintOut by Print
+     - fixed documentation
+
+   * manalysis/MEventRateCalc.cc, manalysis/MPedCalcPedRun.cc:
+     - replaced memset by Reset()
+
+
+
+ 2004/01/24: Abelardo Moralejo
+
+   * macros/starmcstereo.C
+     - Added. Example of how to run the analysis chain for MC files
+       containing simulation of stereo systems of 2 telescopes.
+
+   * mcalib/MCalibrate.cc
+     - Added check that value of signal from MExtractedSignalPix is not
+       the default (error) value. In such a case, the signal in 
+       MCerPhotEvt is now set to 0. Before, all pixels got very high
+       values in MCerPhotEvt in case the MRawEvtData object for the
+       event was missing in the file. This happened in MC files, in 
+       which in some circumstances an event is written without the
+       pixel information (for instance, when running stereo simulations
+       the pixel data is missing for non-triggered telescopes, but the
+       event headers are present).
+
+
+
+ 2004/01/23: Markus Gaug
+
+   * manalysis/MExtractSignal.[h,cc], manalysis/MExtractedSignalPix.[h,cc],
+     manalysis/MArrivalTime.[h,cc], mcalib/MCalibrationBlindPix.h,
+     mcalib/MHCalibrationBlindPixel.[h,cc], mcalib/MCalibrationPINDiode.h,
+     mcalib/MHCalibrationPINDiode.[h,cc], mcalib/MCalibrationPix.[h,cc],
+     mcalib/MHCalibrationPixel.[h,cc], mcalib/MCalibrationCalc.[h,cc]:
+     - use MArrivalTime for Storage (or calculation) of time
+       in MExtractSignal
+     - pass from TH1I histos to TH1F for times
+
+   * mcalib/MCalibrationBlindPix.h, mcalib/MHCalibrationBlindPixel.[h,cc],
+     mcalib/MCalibrationPix.[h,cc], mcalib/MHCalibrationPixel.[h,cc],
+     mcalib/MCalibrationCalc.[h,cc]:
+     - clean up  setters 
+     - pass to bit-fields for all flags
+
+   * mcalib/MCalibrationCam.cc
+     - exclude Blind Pixel from Camera display
+     - do not fill &val when return kFALSE
+
+   * macros/calibration.C
+     - include functions to exclude the blind pixel, 
+       calculation of times and quality checks
+
+
+
+ 2004/01/23: Abelardo Moralejo
+
+   * mcalib/MCalibrate.cc, manalysis/MExtractSignal.cc
+     - Added support (using AddSerialNumber) for stereo MC files.
+
+
+
+ 2004/01/23: Thomas Bretz
+
+   * mbase/MAstro.cc:
+     - Fixed calculation of MJD. In Ymd2Mjd a plus should be a minus.
+
+   * mreport/MReport*.[h,cc]:
+     - changed all classes to return Int_t instead of Bool_t in 
+       InterpreteBody
+     - changed MReportFileRead such, that a wrong line results in
+       skipping the line instead of abort reading.
+
+   * manalysis/MExtractSignal.cc:
+     - do not print information for each pixel - it's too much.
+     
+   * mbase/MStatusDisplay.cc:
+     - when reading a status display do not display tabs with
+       the same name than one which is already existing.
+       
+   * mcalib/MCalibrate.cc:
+     - directly store pointer to pixel when setting saturation flag
+     
+   * mcamera/MCameraDC.cc:
+     - fixed some comments
+     
+   * mhist/MHCamEvent.cc:
+     - fixed a crash when no geometry was available
+
+   * mhist/MHCamera.[h,cc]:
+     - removed obsolete member function SetPix
+
+   * mbase/MStatusDisplay.[h,cc]:
+     - added EventInfo member function
+     - implemented preliminary redirection of GetObjectInfo to
+       StatusLine2 -> An own status line for this is missing
+
+   * manalysis/MExtractSignal.[h,cc]:
+     - implemented StreamPrimitive
+     - changed deafults to be static const data members
+     
+   * manalysis/MGeomApply.[h,cc]:
+     - implemented StreamPrimitive
+
+
+
+ 2004/01/23: Abelardo Moralejo
+
+   * manalysis/MMcCalibrationUpdate.[h,cc] 
+     - Added check to guarantee that the FADC simulation parameters of
+       all read files (those used for calibration and those analyzed) 
+       are the same.
+     - Added missing support for analysis of stereo files.
+
+   * mcalib/MMcCalibrationCalc.cc
+     - Removed obsolete FIXME comment.
+     - Added missing support for analysis of stereo files.
+
+
+ 2004/01/23: Raquel de los Reyes
+
+   * macros/CCDataCheck.C
+     - Added the temperature distribution of the optical links
+       and the plots of the LV power supplies.
+   * mcamera/MCameraLV.h
+     - Added the "Get" functions to access the private data 
+       members of the class.
+
+
+ 2004/01/22: Abelardo Moralejo
+
+   * manalysis/MMcCalibrationUpdate.[h,cc]
+     - Now ratio of high to low gain is taken from MCalibrationCam if
+       it existed previously in the parameter list, instead of being
+       read again from the MMcFadcHeader. Removed Setter function for
+       fADC2PhInner, no longer necessary. Fixed error regarding the 
+       pedestal conversion to photons (did not read conversion factor
+       from preexisting MCalibrationCam object).
+
+   * mcalib/MMcCalibrationCalc.cc
+     - Changed parameters of the histogram, and also the quantity being 
+       histogrammed. Check that input data come from a noiseless camera
+       file before proceeding to do the calibration. Introduced lower
+       size in cut for calibration. Now rhe calibration constant is not
+       calculated from the mean of photons/ADC counts, but from the peak
+       of the histogram.
+
+   * macros/starmc.C
+     - Introduced new scheme. Now there are two loops over two different
+       sets of files. First loop calculates the calibration constants,
+       second one does the analysis. Introduced comments. Now the 
+       histogram used in the light calibration is written to the output
+       file.
+
+
+
+ 2004/01/22: Thomas Bretz
+
+   * mcalib/MCalibrate.[h,cc], mcalib/MCalibrationCam.[h,cc],
+     mcalib/MCalibrationBlindPix.[h,cc], mcalib/MCalibrationCalc.[h,cc],
+     mcalib/MCalibrationPix.[h,cc], mcalib/MCalibrationPINDiode.[h,cc],
+     mcalib/MCalibrationBlindPixel.[h,cc], 
+     mcalib/MHCalibrationPixel.[h,cc], mcalib/MMcCalibrationCalc.[h,cc],
+     mcalib/MHCalibrationBlindPixel.[h,cc], 
+     mcalib/MHCalibrationPINDiode.[h,cc]:
+     - cleaned up includes
+
+
+
+ 2004/01/22: Raquel de los Reyes
+
+   * macros/CCDataCheck.C
+     - macro to check the data from the central control (.rep files).
+
+
+
+ 2004/01/22: Markus Gaug
+
+   * macros/calibration.C
+     - made MStatusDisplay 3 bit smaller
+
+   * manalysis/MExtractSignal.cc
+     - put fSignals->SetUsedFADCSlices into PreProcess
+
+   * manalysis/MPedCalcPedRun.cc
+     - calculate PedRMS as RMS of the sums, later renormalized to units 
+       of RMS/slice (eliminate the wrong effect of odd and even slices)
+
+   * mcalib/MCalibrationCalc.cc
+     - if bit SkipBlindPixelFit is set, now number of photons outside 
+       plexiglass is not intended to be calculated any more (previous
+       bug)
+     - exclude excluded pixels in eventloop
+	
+   * mcalib/MHCalibrationBlindPixel.[h,cc]
+     - move functions to pointer again (otherwise, Clone will give 
+       strange results)
+
+
+
+ 2004/01/21: Abelardo Moralejo
+
+   * mcalib/MMcCalibrationCalc.[h,cc]
+     - Added. First version of the task intended to calculate the
+       conversion factors from ADC counts to photons in the MC. It has
+       a different aim than the recently renamed class 
+       "MMcCalibrationUpdate" (which takes care that the correct 
+       pedestals and conversion factors are supplied to each event, but 
+       does not really calculate anything).
+
+   * mcalib/Makefile, CalibLinkDef.h
+     - Added new class MMcCalibrationCalc
+
+   * manalysis/MMcCalibrationUpdate.[h,cc]
+     - Now the container MCalibrationCam is not created or modified if
+       it is found that one such container already exists in the 
+       Parameter list (from a previous calibration).
+
+
+
+ 2004/01/21: Thomas Bretz
+
+   * mraw/MRawRead.cc:
+     - restore the fake time for all runs (current time stamp in
+       the data seems to be toally nonsense)
+ 
+   * mraw/MRawEvtHeader.cc:
+     - removed decoding of real time (current time stamp in the data
+       seems to be toally nonsense)
+
+
+
+ 2004/01/21: Abelardo Moralejo
+
+   * mmc/MMcEvt.hxx
+     - Uncommented 6 Getter functions (those regarding the number of 
+       photons surviving the different stages of simulation).
+
+   * manalysis/MMcCalibrationUpdate.[h,cc]
+     - Added (see below).
+
+   * manalysis/MMcCalibrationCalc.[h,cc]
+     - Removed: changed name of this class to MMcCalibrationUpdate, 
+       which is more representative of what it really does. Moved 
+       the filling of the MCalibrationCam container from Process to 
+       ReInit, since it does not change on an event by event basis.
+       Simplified PreProcess (MCalibrationCam was searched for twice).
+       Updated class description and comments.
+
+   * manalysis/Makefile, AnalysisLinkDef.h
+     - Adapted to change above
+
+   * macros/starmc.C
+     - Adapted to change above. Changed also task instance name from 
+       mccalibcalc to mccalibupdate.
+
+
+
+ 2004/01/21: Raquel de los Reyes
+
+   * mreport/MReportCC.h, mreport/MReportTrigger.h, mcamera/MCameraHV.h 
+     and mcamera/MCameraCalibration.h
+     - Added the "Get" functions (e.g GetStatus() for fStatus) to access 
+       the private data members of the class.
+
+
+
+ 2004/01/20: Thomas Hengstebeck
+
+   * mranforest/MRanForestCalc.[h,cc]
+     - Added member functions Grow (training of RF) and Fill (reading in
+       trained forest from file) which simplify macros. 
+       One just needs to call them instead of using MRanForestGrow and 
+       MRanForestFill (and the related training and fill loops) in a
+       macro.
+
+
+
+ 2004/01/20: Abelardo moralejo
+
+   * manalysis/MMcCalibrationCalc.cc
+     - removed call to MCalibrationPix::SetPedestal, which was not 
+       needed.
+
+
+
+ 2004/01/20: Thomas Bretz
+
+   * Makefile:
+     - replaced 'make' by '$(MAKE)'
+     
+   * Makefile.rules:
+     - added Makefile itself to dependencies
+     
+   * mbase/MTask.cc:
+     - added comment about ReInit
+
+   * mhbase/MH.cc:
+     - do not clear pad in DrawClone if 'same' option given
+
+   * mhist/MHVsTime.cc:
+     - evaluate 'same' option
+
+   * mfileio/MReadCurrents.[h,cc]:
+     - obsolete, removed
+
+   * manalysis/MCerPhotEvt.cc, manalysis/MCerPhotPix.cc:
+     - added some comments
+
+
+
+ 2004/01/20: Abelardo moralejo
+
+  * mcalib/MHCalibrationPINDiode.cc
+    - Added call to SetDirecory(0) for histograms fHErrCharge, 
+      fHPCharge, fHPTime.
+
+  * manalysis/MCerPhotPix.h: 
+    - Changed position of declaration of fIsSaturated to be the last 
+      private variable. Otherwise, since in the constructor it is 
+      initialized in the last place, a warning is displayed upon
+      compilation in some systems.
+
+
+
+ 2004/01/20: Markus Gaug
+  * mcalib/Makefile, manalysis/Makefile:
+    - include directory ../mtools
+ 
+  * mtools/MFFT.[h,cc]
+    - class inherits from TObject now
+
+
+
+ 2004/01/19: Markus Gaug
+
+  * mcalib/MHCalibrationBlindPixel.[h,cc]
+    - fixed a bug in fFitLegend due to which program crashed by calls 
+      to DrawClone
+    - Modified way to change the fit function
+
+  * mcalib/MHCalibrationPixel.[h,cc]
+    - reordered function calls
+    - removed SetupFill
+
+  * mcalib/MHCalibrationPINDiode.h
+    - reordered function calls
+
+  * mcalib/MCalibrationPix.[h,cc]
+    - limits to define fFitValid now as variables in class
+
+  * mcalib/MCalibrationCam.[h,cc]
+    - reordered function calls
+    - incorporate option to exclude pixels 
+
+  * mcalib/MCalibrationBlindPix.h
+    - Modified way to change the fit function
+
+  * mcalib/MCalibrationCalc.[h,cc]
+    - Modified way to change the fit function
+    - incorporate option to exclude pixels from configuration file
+
+  * macros/calibration.C
+    - Modified way to change the fit function
+    - incorporate option to exclude pixels from configuration file
+
+
+
+ 2004/01/19: Javier Rico
+
+   * manalysis/MPedCalcPedRun.cc, manalysis/MPedPhotCalc.cc
+     - Added documentation of member functions
+
+
+
+ 2004/01/19: Abelardo Moralejo
+
+   * manalysis/MCerPhotPix.[h,cc]
+     - Added fIsSaturated to flag whether low gain of the pixel is
+       saturated. Added corresponding getter and setter functions.
+       Updated ClassDef to version 2.
+
+   * mcalib/MCalibrate.cc
+     - Set the new saturation flag of MCerPhotPix to kTRUE if at least 
+       one low gain FADC slice is saturated.
+
+   * mimage/MNewImagePar.[h,cc]
+     - Added new member variable fNumSaturatedPixels to count how many
+       pixels were saturated. Updated ClassDef to version 2.
+
+
+
+ 2004/01/19: Thomas Bretz
+
+   * manalysis/MPedPhotCalc.[cc,h]:
+     - fixed order of includes
+     - removed obsolete forward declarations
+     - removed obsolete data member fNumPixels (stored already twice in
+       the two TArrayF)
+     - fixed some small bugs in the documentation
+
+   * manalysis/MPedCalcPedRun.cc:
+     - updated my eMail address
+
+
+
+ 2004/01/19: Javier Rico
+
+   * macros/dohtml.C, NEWS
+     - include some missing info
+
+
+
+ 2004/01/19: Abelardo Moralejo
+
+   * manalysis/MExtractedSignalPix.h
+     - added GetNumLoGainSaturated()
+
+
+
+ 2004/01/19: Markus Gaug
+
+   * macros/dohtml.C
+     - include calibration.C
+	
+   * manalysis/MExtractSignal.cc
+     - warning of logain saturation now only once per event (out of loop)
+
+   * mcalib/MCalibrationCalc.cc, mcalib/MCalibrationPix.[h,cc]
+     - new Flag fExcluded to indicate if pixel has been excluded from 
+       further analysis
+
+
+
+ 2004/01/16: Javier Rico & Pepe Flix
+
+   * manalysis/MPedPhotCalc.[cc,h]
+     - added
+     - new class for the evaluation of pedestals in units of photons
+       using the extracted signal from pedestal runs and calibration
+       constants defined in MCalibrate
+
+   * manalysis/AnalysisLinkDef.h,  manalysis/Makefile
+     - added entries for MPedPhotCalc
+
+   * macros/pedphotcalc.C
+     - added
+     - example on how to use MPedPhotCalc task
+
+
+
+ 2004/01/16: Markus Gaug
+
+   * mcalib/MCalibrationFits.h 
+     - removed and incorporated in MHCalibrationBlindPixel.h
+
+   * mcalib/MHCalibrationBlindPixel.[h,cc], mcalib/MHCalibrationConfig.h,
+     mcalib/MCalibrationBlindPix.h:
+     - incorporate Fit functions
+     - fixed a bug due to which DrawClone crashed when class was used 
+       in a compiled macro
+
+   * mcalib/MCalibrationCalc.cc, mcalib/MCalibrationPix.cc,
+     mcalib/MCalibrationBlindPix.cc, mcalib/MCalibrationPINDiode.cc,
+     mcalib/MCalibrationCam.cc, mcalib/MHCalibrationBlindPixel.cc,
+     mcalib/MHCalibrationPixel.cc:
+     - fixed the warns and errs in fLog's
+
+
+
+ 2004/01/16: Abelardo Moralejo
+
+   * manalysis/MMcCalibrationCalc.cc
+     - TMath::Max() is no longer used because it did not compile in some 
+       systems for unkown reasons. I replaced it by a safer (and may be 
+       slower) code.
+     - Added calpix.SetFitValid();
+
+   * mhist/MHEvent.cc
+     - In MHEvent::Fill, fixed: second parameter of SetCamContent must 
+       be 1 in case of RMS:
+        case kEvtPedestalRMS:
+           fHist->SetCamContent(*(MCamEvent*)par, 1);
+
+
+
+ 2004/01/15: Abelardo Moralejo
+
+   * macros/starmc.C
+     - Added. Version of star showing new chain to get Hillas 
+       parameters (with Size calibrated in photons) from MC files.
+
+
+
+ 2004/01/15: Javier Rico
+	
+   * manalysis/MPedCalcPedRun.[h,cc]
+     - optimize the running time
+     - add (some) documentation
+     - correct treatment for the case of several input files 
+
+   * macros/pedvsevent.C
+     - added
+     - draw pedestal mean and rms vs event# for input pixel# and run 
+       file, and compares them to the global pedestal mean and rms 
+
+
+
+ 2004/01/15: Raquel de los Reyes
+
+   * mhist/MHCamEvent.cc, mhist/MHCamera.cc
+     - changed the MHCamEvent::SetupFill and MHCamera::GetBinError
+       functions to compute the estimation of the error of the
+       mean. It can be done calling to the function
+       MCamEvent::SetBit(MHCamera::kVariance) in the macro
+
+
+
+ 2004/01/15: Markus Gaug
+
+   * mhist/MHCamera.[h,cc]
+     - incorporate Thomas's changes
+     - replace void CreateProjection() by TH1D *Projection(const char*)
+
+   * macros/calibration.C
+     - replace MHCamera->Draw("proj") by MHCamera->Projection()
+     - produce better fits to the projection
+
+   * manalysis/MSimulatedAnnealing.[h,cc], 
+     mhist/MHSimulatedAnnealing.[h,cc]:
+     - moved to directory mtools
+     - MSimulatedAnnealing now inherits from TObject
+
+   * manalysis/Makefile, manalysis/AnalysisLinkDef.h,
+     mhist/Makefile, mhist/HistLinkDef.h:
+     - removed MSimulatedAnnealing
+     - removed MHSimulatedAnnealing
+
+   * mtools/Makefile, mtools/AnalysisLinkDef.h:
+     - added MSimulatedAnnealing
+     - added MHSimulatedAnnealing
+
+
+
+ 2004/01/15: Thomas Bretz
+
+   * manalysis/AnalysisLinkDef.h:
+     - removed MCurrents
+
+   * mhist/MHCamera.[h,cc]:
+     - added member function Projection
+     - removed fYproj
+
+   * mreport/MReport*.*:
+     - added more comments
+
+
+
+ 2004/01/14: Markus Gaug
+  
+   * mtools/MFFT.[h,cc]
+     - new class to perform Fast Fourier Transforms
+
+   * mtools/Makefile
+   * mtools/ToolsLinkDef.h
+     - include MFFT
+
+   * manalysis/MExtractedSignalCam.h
+     - removed variables fNumHiGainSamples and fNumLoGainSamples
+     - function SetNumUsedFADCSlices replaced by SetUsedFADCSlices
+
+   * manalysis/MExtractSignal.cc
+     - updated call to SetUsedFADCSlices
+
+
+
+ 2004/01/14: Abelardo Moralejo
+
+   * manalysis/MMcCalibrationCalc.cc:
+     - set pedestal rms per FADC slice to 0.01 counts in case it is 0.
+       This can happen (depending on camera simulation parameters), and
+       rms = 0 later resulted in the pixel being eliminated in the 
+       image cleaning.
+
+
+
+ 2004/01/14: Thomas Bretz
+
+   * Makefile:
+     - replaced old style Makefile.depend by directory specific
+       dependancy files
+       
+   * Makefile.rules:
+     - changed obsolete '.cc.o' style to newer style '%.o: %.c'
+     - added rule to make dependency files
+     - added rule to remove dependancy files.
+     - added rmdep as prerequisite to clean
+     - include dependency file
+
+   * mbase/Makefile, mcalib/Makefile, mcamera/Makefile,
+     mdata/Makefile, mfileio/Makefile, mfilter/Makefile,
+     mgeom/Makefile, mgui/Makefile, mhbase/Makefile, 
+     mhist/Makefile, mhistmc/Makefile, mimage/Makefile,
+     mmain/Makefile, mmc/Makefile, mmontecarlo/Makefile,
+     mpointing/Makefile, mranforest/Makefile, mraw/Makefile,
+     mreflector/Makefile, mreport/Makefile, mtemp/Makefile,
+     mtools/Makefile:
+     - removed clean-rule, use the one in Makefile.rules instead
+
+   * mreport/Makefile, mreport/ReportLinkDef.h:
+     - added MReportHelp
+
+   * mreport/MReportFileRead.cc:
+     - moved code from MReportHelp to new file
+     - removed usage of MReport class completely
+
+   * mfilter/MFGeomag.[h,cc]:
+     - fixed a bug which causes MFGeomag to fail if MARSSYS is not set
+     - changed the second loop from 0->1151 to 1152->2304
+     - removed dummy arrays used for reading
+     - output filename in case of 'file not found'
+     - removed obsolete data members
+     - removed obsolete Init function
+     - removed forbidden underscore from member variable
+     - changed wrong 0/1 in allocation of fResult into kFALSE/TRUE
+
+   * mbase/MStatusDisplay.[h,cc]:
+     - added new member function Open
+     - added new menu entry kFileOpen
+     - changed UpdatePSheader algorithm (the old one was much too slow)
+
+   * manalysis/MCurrents.[h,cc]:
+     - removed (old outdated)
+
+   * manalysis/Makefile, manalysis/AnalysisLinkDef.h:
+     - removed MCurrents
+
+
+
+ 2004/01/14: Wolfgang Wittek
+
+   * macros/ONOFFAnalysis.C:
+     - current version
+
+   * mhist/MHSigmaTheta.[h,cc]:
+     - replace MPedestalCam by MPedPhotCam
+
+   * manalysis/MPad.[h,cc], manalysus/MSigmabar.[h,cc],
+     manalysus/MSigmabarCalc.[h,cc], manalysus/MCT1PadONOFF.[h,cc],
+     manalysus/MCT1PadSchweizer.[h,cc], manalysus/MPadding.[h,cc]:
+     - replace MPedestalCam by MPedPhotCam
+
+   * manalysis/MPedPhotPix.[h,cc]
+     - uncomment SetRms()
+
+
+
+ 2004/01/13: Markus Gaug
+ 
+   * manalysis/MExtractSignal.h
+     - seems that the reduced light intensity of the CT1 Pulser
+       results in broader pulses -> Set Default time slices to [3,10]
+
+   * mhist/MHCamera.cc
+     - make Stat Window in option 'proj' bigger
+     - add comment line at beginning of Draw()
+
+   * mcalib/MHCalibrationBlindPixel.[h.cc]
+     - add Function DrawClone()
+     - fix bug in calculation of integral (GetIntegral("width"))
+     - restrict parameters tighter
+     - declare fit as not valid, if less than 100 events 
+       in single photo-electron peak
+
+   * mcalib/MCalibrationFits.h, mcalib/MHCalibrationBlindPixel.[h.cc]
+     - fit now with fixed normalization
+
+   * mcalib/MHCalibrationPixel.[h.cc]
+     - new function IsEmpty()
+     - Time fit accepted if ChiSquare less than 30. (instead of 20.)
+
+   * mcalib/MCalibrationPix.[h.cc]
+     - F-Factor corrected and added error
+     - Histograms not fitted if they are empty
+     - rejection criteria of fitted charges now > 5 PedRMS (instead 3)
+
+   * mcalib/MCalibrationCam.cc
+     - Square Root of Reduced Sigmas not taken, if they are < 0.
+     - Reduced Sigma / Charge squared replaced by reduced sigma / charge
+
+   * mcalib/MCalibrationCalc.cc
+     - Blind Pixel is not additionally treated as normal pixel any more
+     - Blind Pixel Draw replaced by DrawClone
+
+   * macros/calibration.C
+     - took out some unused code
+     - some default axis labelling corrected
+
+
+
+ 2004/01/13: Abelardo Moralejo
+
+   * manalysis/MMcPedestalCopy.cc
+     - added check of whether input file is a MC file before executing 
+       the PreProcess.
+
+
+
+ 2004/01/13: Wolfgang Wittek
+
+   * macros/ONOFFAnalysis.C, macros/ONAnalysis.C:
+     - change macro to handle also MC events with finite sigmabar
+
+   * manalysis/MPadOn.[h,cc]:
+     - deleted, is replaced by MPad
+
+   * manalysis/MPadOnOFF.[h,cc]:
+     - deleted, is replaced by MPad
+
+   * manalysis/MPad.[h,cc]:
+     - new class, replacing MPadON and MPadONOFF
+     - handle also MC events with finite sigmabar
+
+   * manalysis/Makefile, manalysis/AnalysisLinkDef.h:
+     - replace MPadON and MPadONOFF by MPad
+
+
+
+ 2004/01/13: Thomas Bretz
+
+   * mraw/MRawRunHeader.[h,cc]:
+     - implemented new member function GetRunTypeStr
+
+   * Changelog.03: 
+     - added (contains entries of 2003)
+
+   * Changelog:
+     - removed entries of 2003
+
+   * mfilter/MFGeomag.cc:
+     - simplified open/close of input files
+
+   * manalysis/MEventRate.[h,cc], manalysis/MEventRateCalc.cc:
+     - added some comments
+     - added new member function GetError
+
+   * Makefile:
+     - updated 'make dox' output for convinience
+
+   * macros/dohtml.C:
+     - do not print Info's
+     - added mcamera
+     - added mpointing
+     - added mreport
+
+   * mreport/MReportCurrents.cc, mreport/MReportDAQ.cc:
+     - removed some obsolete comments (these comments confused THtml)
+
+   * manalysis/MCameraData.[h,cc], mfileio/MCT1ReadAscii.[h,cc],
+     mfileio/MCT1ReadPreProc.[h,cc], mfilter/MFCT1SelBasic.cc,
+     mfilter/MFSelBasic.cc, mhist/MHCamera.cc, mhist/MHEvent.[h,cc],
+     mimage/MImgCleanStd.[h,cc], mimage/MImgCleanTGB.[h,cc],
+     mmain/MAnalysis.cc, mmain/MEventDisplay.cc:
+     - replaced MPedestalCam by MPedPhotCam
+     - removed some obsolete includes
+
+   * mbase/BaseLinkDef.h, mbase/Makefile:
+     - added MLogPlugin
+     - added MLogHtml
+
+   * mbase/MLog.[h,cc]:
+     - added use of plugins
+
+   * mbase/MLogPlugin.[h,cc], mbase/MLogHtml.[h,cc]:
+     - added
+
+   * mbase/MStatusDisplay.[h,cc]:
+     - added a Save-As dialog
+
+
+
+ 2004/01/12: Thomas Bretz
+
+   * macros/rootlogon.C:
+     - added mcamera to include path
+     - added mpointing to include path
+     - added mreport to include path
+     
+   * mbase/MLog.cc:
+     - updated my eMail address
+     
+   * mbase/MParContainer.h:
+     - added Read member function
+     
+   * mbase/MStatusDisplay.[h,cc]:
+     - changed size of ps-paper
+     - added a user defined bottom line to the ps-files
+     - added name (currently unused)
+     - added title (used as possible bottom line in ps-file)
+     
+   * mraw/MRawRunHeader.cc:
+     - added some comments
+
+   * status.cc:
+     - set name of input as bottom line of status display
+
+
+
+ 2004/01/12: Abelardo Moralejo
+
+   * mimage/MStereoPar.cc
+     - fixed mistake: now fSourceY = scale1*hillas1.GetMeanY() + ...
+       instead of         fSourceY = scale2*hillas1.GetMeanY() + ...
+       Bug had no effect unless scale1 != scale2 (-> telescopes of 
+       different size).
+
+
+
+ 2004/01/12: Markus Gaug
+
+   * manalysis/MExtractSignal.[h,cc]
+     - take out some uncommented code 
+     - replace logainshift by two independent variables: 
+       logainfirst, logainlast
+     - because in most data, maximum occurs in slice 4, shift default 
+       from slices 4-9 to slices 3-8.
+
+   * manalysis/MExtractedSignalPix.[h,cc]
+     - took out some uncommented code
+     - new initializers: instead of -1. now 99999.9
+
+
+
+ 2004/01/09: Markus Gaug
+
+   * mcalib/MCalibrationCam.[h,cc]
+     - take out 1-dim histos because we can use 
+       the projections in MHCamera (s.b.)
+
+   * mcalib/MHCalibrationBlindPixel.h
+     - make the fit by default quiet
+
+   * mcalib/MHCalibrationPixel.[h,cc]
+   * mcalib/MCalibrationPix.[h,cc]
+     - Ranges of time slices stored independently for HiGain and LoGain
+       in order to allow consecutive checks
+
+   * mhist/MHCamera.[h.cc]
+     - add the possibility to call a Draw("proj") which will 
+       draw a Y-Projection of the histogram
+
+   * macros/calibration.C
+     - apply the drawing of the projections and fit them
+
+   * mcalib/MCalibrationCalc.cc
+     - catch the possibility of a calibration file, 
+       unintendedly being a pedestal or cosmic file. 
+       Program now exits with an error before doing the fits
+
+   * mcalib/MCalibrationPix.[h,cc]
+     - fixed a bug in calculation of fFitValid. 
+       before, a call to IsFitValid() always returned false
+
+
+
+ 2004/01/09: Javier Lpez
+
+   * macros/bootcampstandardanalysis.C
+     - added new macro that holds the main scheleton discussed in the 
+       december bootcamp in Wuerzburg. It runs first over a pedestal
+       run, then over a calibration run, again over the pedestal run
+       to compute de pedestal in number of photons and finally over a
+       data run to calibrate the data.
+
+
+
+ 2004/01/06: Sebastian Raducci
+   
+   * manalysis/MArrivalTime.[h,cc]
+     - added new method to calculate photon arrival times. It uses the
+       TSpline5 Root Class to interpolate the Fadc Slices. The time is
+       the abscissa value of the absolute maximum of the interpolation
+     - added new method to find clusters with similar arrival times.
+       For now it's a preliminary version. It simply search for adiacent
+       pixels having the same arrival time (color).
+
+   * manalysis/MArrivalTimeCalc.[h,cc]
+     - modified the Process() method according to the changes in the
+       Arrival Time Cointainer
+
+   * mmain/MEventDisplay.cc
+     - added new tab in the camera event display to show the arrival
+       time. This arrival time is calculated with the spline method
+     - the old Arrival Time pad now it's called Max Slice Idx, because
+       it's only the index of the slice with the max content.
+   
+   * mhist/MHEvent.[h,cc]
+     - added new fType in te enumeration to handle the arrival time
+       histos
Index: /tags/Mars_V0-8-5/Mars/Changelog.02
===================================================================
--- /tags/Mars_V0-8-5/Mars/Changelog.02	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/Changelog.02	(revision 9661)
@@ -0,0 +1,5677 @@
+                                                 -*-*- END OF LINE -*-*-
+
+ 2002/12/13: Abelardo Moralejo
+
+    * manalysis/MSigmabar.cc
+      - added cast in first arguments in calls to TMath::Min and
+        TMath::Max otherwise, we got a compilation error in Alpha
+        machines.
+
+
+
+ 2002/12/13: Oscar blanch
+
+    * mgeom/MGeomMirror.[h,cc]
+      - function SetMirrorDeviations added
+
+
+
+ 2002/12/09: Robert Wagner
+
+    * manalysis/MSigmabar.[cc,h]:
+      - added
+
+    * manalysis/MSigmabarCalc.[cc,h]:
+      - added
+
+    * manalysis/MSigmabarParam.[cc,h]:
+      - added
+      - preliminary version for CT1 test
+
+    * manalysis/MApplyPadding.[cc,h]:
+      - added
+
+    * mhist/MHSigmabarTheta.[cc,h]:
+      - added
+
+    * mhist/MHSigmabarPixel.[cc,h]:
+      - added
+      - preliminary version for CT1 test
+
+    * mtemp/MObservatoryLocation.[cc,h]:
+      - added
+
+    * mtemp/MVPObject.[cc,h]:
+      - added
+
+    * mtemp/MVPPlotter.[cc,h]:
+      - added
+
+    * mtemp/MVPTime.[cc,h]:
+      - added
+	
+    * mtemp/TempIncl.h, mtemp/TempLinkDef.h, mtemp/Makefile:
+      - added above mentioned classes
+
+    * mhist/HistLinkDef.h, mhist/Histfile:
+      - added above mentioned classes
+
+    * manalysis/AnalysisLinkDef.h, manalysis/Makefile:
+      - added above mentioned classes
+
+
+
+ 2002/11/25: Thomas Bretz
+
+   * mgui/MCamDisplay.cc:
+     - fixed a bug when sprintf the pointer to the char-array, only
+       took place on alphas.
+
+   * macros/multidimdist2.C:
+     - renamed eventloops (instances had same names)
+     - fixed a type in PrintStatistics (the gamma statistics
+       were printed two times)
+
+   * mbase/MEvtLoop.cc:
+     - take the lowest value (entries from MRead or user input)
+       for the progress bar
+     - reset the progress bar
+
+   * mbase/MFilter.h:
+     - added 'private'
+
+   * meventdisp/MGCamDisplay.[h,cc], meventdisp/MGEvtDisplay.[h,cc],
+     meventdisp/MGFadcDisp.[h,cc], mmain/MMonteCarlo.[h,cc],
+     mmain/MAnalysis.[h,cc], mmain/MBrowser.[h,cc], 
+     mmain/MCameraDisplay.[h,cc], mmain/MDataCheck.[h,cc],
+     mmain/MEvtDisp.[h,cc], mmain/MMars.cc:
+     - changed from TTransientFrame to TMainFrame (with this I
+       get decorations, eg. Close Button)
+
+   * meventdisp/MGEvtDisplay.cc:
+     - Update the layout each time the fEvtInfo has changed
+
+   * mfileio/MCT1ReadAscii.cc, mfileio/MCT1ReadPreProc.cc:
+     - delete return of gSystem->ExpandPathName
+
+   * mfileio/MCT1ReadPreProc.[h,cc]:
+     - added output of Time
+     - added usage of Selector
+     - changed MTask basics to be private
+
+   * mfileio/MRead.[h,cc]:
+     - added comment about selector
+     - added Selector-stuff
+
+   * mfileio/MReadMarsFile.[h,cc], mfileio/MReadTree.[h,cc]:
+     - added 'entries' argument to AddFile
+
+   * mfileio/MReadTree.[h,cc]:
+     - added workaround for a root bug when a file doesn't exist
+     - changed AddFiles to use Add(TChain*)
+     - changed to use Selector
+
+   * mfilter/MF.cc:
+     - Set debug level to suppress output when MFDataChain is created
+
+   * mfilter/MFEventSelector.h:
+     - changed Pre//PostProcess to private
+     
+   * mfilter/MF.cc, mfilter/MFilterList.cc:
+     - changed the use of Pre//PostProcess to CallPre//PostProcess
+   
+   * mhist/MBinning.[h,cc]:
+     - changed comments
+     - added SetEdgesCos
+
+   * mhist/MFillH.[h,cc]:
+     - added GetBinCenterLog
+
+   * mhist/MH3.h:
+     - added default argument to GetHistByName
+
+   * mhist/MHAlphaEnergyTheta.[h,cc], mhist/MHAlphaEnergyTime.h,
+     mhist/MHEffOnTime.[h,cc], mhist/MHEffOnTimeTheta.h,
+     mhist/MHEffOnTimeTime.h, mhist/MHFlux.[h,cc], mhist/MHGamma.[h,cc],
+     mhist/MHMcEnergyMigration.h, mhist/MHThetabarTheta.[h,cc],
+     mhist/MHThetabarTime.h:
+     - changed the output
+     - changed the algorithms to be more modular (more usage of member
+       function)
+     - changed ClassDef to 0
+     - fixed some small bugs (access of TArray[n])
+
+   * mhist/MHHadronness.[h,cc]:
+     - removed shortest distance to (0,1) stuff
+
+   * mhist/MHMcCollectionArea.h:
+     - changed Fill to Double_t
+
+   * mhist/MHTimeDiffTheta.[h,cc], mhist/MHTimeDiffTime.[h,cc]:
+     - in a first draft changed to use 200ns timing of CT1
+     - changed ClassDef to 0
+
+
+
+ 2002/11/22: Thomas Bretz
+
+   * macros/threshold.C:
+     - Simplified the new writing routine
+
+   * mbase/MLog.h:
+     - added a Getter-function for the debug level
+
+   * mbase/MTaskList.cc: 
+     - added another debugging output
+
+   * mfilter/MF.[h,cc]:
+     - made the automatically created chain names unique
+
+   * mfilter/MFDataChain.cc:
+     - corrected the GetRule stuff ({} were missing)
+
+   * mhist/MH3.cc:
+     - added MBinning as class type to FindObject
+     - added BinningHist (without the X) as binning name for a 1D histogram
+
+   * mfileio/MReadMarsFile.cc:
+     - corrected typo
+
+   * mfileio/MCT1ReadPreProc.cc:
+     - fixed a warning
+
+
+
+ 2002/11/22: Abelardo Moralejo
+
+   * macros/threshold.C:
+     - Added 2nd argument to write an output file containing the 
+       energy spectrum histogram.
+
+
+
+ 2002/11/21: Thomas Bretz
+
+   * mbase/MAGIC.h, mbase/MEvtLoop.[h,cc], MTask.cc, MTaskList.cc:
+     - introduced kERROR to stop an eventloop with an error
+
+   * mbase/MTask.h:
+     - made SetFilter virtual
+
+   * mbase/MTaskList.[h,cc]:
+     - added new member function AddToListBefore/After
+     - split the code of the AddToList function into CheckAddToList
+
+   * manalysis/MMultiDimDistCalc.cc:
+     - introduced usage of kERROR in case the matrix is not posdef.
+
+   * macros/collarea.C:
+     - some simplifications
+
+   * mhist/MHMcRate.h, mhist/MHMcIntRate.h, mhist/MHEnergyTime.h,
+     mhist/MHEnergyTheta.h, mfileio/MCTReadPreProc.cc, mfileio/MChain.h,
+     mfileio/MReadMarsFile.h, mfileio/MReadTree.cc, mfileio/MWriteAsciiFile.h,
+     mfileio/MWriteRoootFile.[h,cc], manalysis/MMatrixLoop.h, 
+     manalysis/MEnergyEstimate.h, mbase/MGGroupFrame.h, mbase/MGTask.h,
+     mfilter/MFParticleId.h:
+     - updated documentation
+
+   * mfileio/MCT1ReadPreProc.cc:
+     - Changed MSrcPosCam name from Source to MSrcPosCam
+     - changed the way the MC data is filled into the MC container
+     - updated algorithm to read preproc files
+
+   * mfileio/MReadMarsFile.cc:
+     - printed a warning to the screen in case Camera=V0.5
+
+   * mfileio/structures.h:
+     - changed to version 0.6
+
+   * mmc/MMcEvt.hxx:
+     - added GetTelescopePhi
+     - added GetTelescopeTheta
+
+   * mdata/MDataChain.[h,cc]:
+     - added 'sqr'
+
+   * mfilter/MF.[h,cc]:
+     - added support for MFDataChain
+
+   * mfilter/MFDataChain.[h,cc]:
+     - added
+
+   * mfilter/Makefile, mfilter/FilterLinkDef.h:
+     - added MFDataChain
+
+
+
+ 2002/11/20: Thomas Bretz
+
+   * macros/dohtml.C:
+     - fixed a typo
+
+   * mmain/MAnalysis.cc:
+     - removed the Anti-Source from the hillas calculation
+
+   * mhist/MHFadcPix.[h,cc], mhist/MHFadcCam.[h,cc],
+     mmain/MDataCheck.[h,cc]:
+     - added enhancement for displaying sum of FADC slices
+
+
+
+ 2002/11/20: Abelardo Moralejo
+
+   * macros/collarea.C:
+     - Introduced check before opening output file to avoid annoying 
+       error message.
+
+
+
+ 2002/11/19: Abelardo Moralejo
+
+   * macros/collarea.C:
+     - Removed some strange pieces of text which somehow got into the
+       file (anyone knows how?)
+
+
+
+ 2002/11/19: Thomas Bretz
+
+   * mmain/MMonteCarlo.cc:
+     - exchanged MReadTree with MReadMarsFile for collection area calculation
+ 
+   * mmontecarlo/MMcCollectionAreaCalc.cc:
+     - fixed the uninitialized fTheta
+
+   * macros/MagicHillas.C:
+     - removed the unnecessary second MHillasSrcCalc
+     - removed also the corresponding AddToList for the tasklist
+
+   * mhist/MH.cc:
+     - make FindGoodLimits work
+
+
+
+ 2002/11/19: Abelardo Moralejo
+
+   * macros/collarea.C:
+     - Added 2nd argument to write an output file containing the 
+       collection area histogram.
+
+
+
+ 2002/11/18: Abelardo Moralejo
+
+   * mmain/MMars.cc:
+     - Corrected typo on Mars starting screen.
+
+   * mhist/MHMcCollectionArea.cc:
+     - Added comment.
+
+   * manalysis/MImgCleanStd.cc:
+     - implemented "democratic cleaning" (cut value proportional to square
+       root of pixel area) according to Wolfgang's suggestion.
+
+   * macros/MagicHillas.C:
+     - added missing declaration MHillasSrcCalc csrc2;
+
+   * mgeom/MGeomPix.cc:
+     - fixed some typos in comments
+
+
+
+ 2002/11/18: Thomas Bretz
+
+   * macros/CT1Hillas.C:
+     - changed MWRiteRootFile to write the histograms only
+     - renamed HillasSource to MHillasSrc
+
+   * macros/MagicHillas.C:
+     - removed all anti source stuff (corresponding to star.C)
+     - changed MWRiteRootFile to write the histograms only
+     - renamed HillasSource to MHillasSrc
+
+   * macros/estfit.C:
+     - renamed HillasSource to MHillasSrc
+
+   * macros/estimate.C:
+     - renamed HillasSource to MHillasSrc
+     - changed to display more interesting histograms
+
+   * multidimdist.C:
+     - added Theta
+     - added Alpha
+
+   * macros/star.C
+     - removed wrong HillasSource
+     - added MSrcPosCam
+
+   * starplot.C:
+     - removed all anti source stuff (corresponding to star.C)
+     - renamed HillasSource to MHillasSrc
+
+   * macros/multidimdist2.C:
+     - fixed a typo
+     - added Alpha and Theta
+
+   * mbase/MTime.h:
+     - added minus-operator
+
+   * mdata/MDataChain.[h,cc]:
+     - added floor
+
+   * mhist/MFillH.[h,cc]:
+     - moved MMap and MMap support MHArray
+
+   * mhist/MHArray.[h,cc]:
+     - added MMap
+     - added MMap-support
+     - added legend
+     - added more draw options
+
+   * mhist/MHFadcCam.[h,cc]:
+     - added Fill(const MRawEvtData*)
+     - added const getter functions
+
+   * mhist/MHFadcPix.h:
+     - added const getter functions
+
+   * mmc/MMcCorsikaRunHeader.[h,cc]:
+     - removed underscores from names
+     - removed empty destructor
+
+   * manalysis/MPedestalCalc.[h,cc]:
+     - added (not yet to LinkDef.h and Makefile)
+
+   * mgeom/MGeomMirror.[h,cc], mgeom/MGeomPMT.[h,cc], 
+     mmc/MMcConfigRunHeader.[h,cc], mmc/MMcCorsikaRunHeader.[h,cc]:
+     - changed comments
+     - added missing manalysis-dir (strange!)
+
+   * macros/dohtml.C:
+     - added new macros
+
+
+
+ 2002/11/16: Abelardo Moralejo
+
+   * mmc/MMcCorsikaRunHeader.cc:
+     - added default destructor
+
+
+
+ 2002/11/15: Thomas Bretz
+
+   * mmc/MMcCorsikaRunHeader.[h,cc]:
+     - small changes
+
+   * mmc/McLinkDef.h:
+     - added missing MMcCorsikaRunHeader
+
+
+
+ 2002/11/15: Oscar Blanch
+
+   * mmc/MMcCorsikaRunHeader.[h,cc]:
+     - added
+
+
+
+ 2002/11/14: Thomas Bretz
+
+   * mmain/MAnalysis.cc, mmain/MMonteCarlo.cc, mmain/MDataCheck.cc:
+     - removed SetProgressBar of reader
+
+   * mhist/MHFlux.cc:
+     - localized some variables
+     - get rid of old c-style sprintf
+     - return errorflag in Parab as return value!
+
+   * mgeom/MGeomPMT.cc, mgeom/MGeomMirror.cc:
+     - removed redefinition of a default argument
+
+   * mhist/MHMcIntRate.cc, mhist/MHMcCollectionArea.[h,cc]: 
+     - changed the error calculation according to a suggestion from Raquel
+
+   * mmontecarlo/MMcCollectionAreaCalc.cc: 
+     - for collection area: MMcTrig isn't needed if all showers are
+       triggered showers
+
+   * mmc/MMcConfigRunHeader.cc:
+     - made function definition identical to function declaration
+
+   * macros/star.C:
+     - removed anti source for the moment
+
+   * macros/multidimdist2.C:
+     - added
+
+   * macros/comprob.C, macros/multidimdist.C:
+     - changed to use MHillasSrc instead of HillasSource
+
+   * mhist/MHHadronness.cc:
+     - changed the output of Print a bit
+
+
+
+ 2002/11/13: Thomas Bretz
+
+   * mfilter/MFEventSelector.[h,cc]:
+     - if total number of events read from file the selector worked only for
+       one eventloop - fixed.
+     - changed MReadMarsFile to MRead
+
+   * mbase/MContinue.cc:
+     - fixed a typo
+
+   * mbase/MEvtLoop.cc, meventdisp/MGEvtDisplay.cc:
+     - renamed MReadMarsFile/MReadTree to MRead
+
+   * mfileio/FileIOLinkDef.h, mfileio/Makefile:
+     - added MRead
+
+   * mfileio/MRead.[h,cc]:
+     - added
+
+   * mfileio/MReadMarsFile.[h,cc], mfileio/MReadTree.[h,cc]:
+     - renamed from MReadMarsFile to MRead
+     - derived from MRead
+     - removed progressbar support from MReadTree
+
+   * mfileio/MWriteRootFile.cc:
+     - added a info output
+
+   * mfileio/MCT1ReadPreProc.[h,cc]:
+     - changed to work much much better :)
+
+   * mgeom/GeomLinkDef.h, mmc/McLinkDef.h:
+     - added missing LinkDefs (helllo Oscar!)
+
+   * mgeom/MGeomCamCT1.cc:
+     - mirrored the CT1 camera in x (CT1 default)
+
+   * mgeom/MGeomMirror.[h,cc]:
+     - some small changes
+   
+   * mgeom/MGeomPMT.[h,cc]:
+     - changed usage of TArrayF from pointer to reference
+
+   * mgui/MCamDisplay.cc:
+     - fixed a crash at delete when the user closed a automatically
+       created canvas
+
+   * mhist/MHFadcCam.[h,cc]:
+     - implemented ResetHistograms
+
+   * mhist/MHMatrix.[h,cc]:
+     - implemented ReduceNumberOfRows (preliminary, untested)
+
+   * mmc/MMcConfigRunHeader.[h,cc]:
+     - some small changes
+     - changed usage of TArrayF from pointer to reference
+
+
+
+ 2002/11/11: Thomas Bretz
+
+   * manalysis/MHillas.cc:
+     - moved division by size before test of number of used pixels
+
+   * mfileio/MCT1ReadPreProc.cc:
+     - added a eof-conditional
+
+   * mhist/MH3.cc:
+     - added a 'nonew' option to DrawClone
+
+   * mhist/MHHadronness.cc:
+     - check for NaN in Fill
+
+
+
+ 2002/11/08: Oscar Blanch
+
+   * mgeom/MGeomPMT.[h,cc]:
+     - added
+     - Information about simulated QE
+
+   * mgeom/MGeomMirror.[h,cc]:
+     - added
+     - Mirrors properties
+
+   * mgeom/Makefile:
+     - modified to compile new classes
+
+   * mmc/MMcConfigRunHeader.[h,cc]:
+     - added
+
+   * mmc/Makefile:
+     - modified to compile new classes
+
+
+
+ 2002/11/08: Thomas Bretz
+
+   * mhist/MHMatrix.cc:
+     - implemented a zero suppression
+
+
+
+ 2002/11/07: Thomas Bretz
+
+   * mfilter/Makefile, mfilter/FilterLinkDef.h:
+     - added MFEventSelector
+
+   * mfilter/MFEventSelector.[h,cc]:
+     - added
+
+   * mfilter/MF.[h,cc]:
+     - made gsDef[Name,Title] a static const member
+
+   * manalysis/MMultiDimDistCalc.cc:
+     - changed the default function to kernel
+
+
+
+ 2002/11/07: Oscar Blanch
+   * mmc/MMcEvt.[hxx,cxx]
+     - Some new variable from the reflector header event.
+     - Class version switched to 2
+
+   * mmc/MMcRunHeader.[hxx,cxx]
+     - Varible member fOpticLinksNoise has been introduced
+     - Class version switched to 3
+
+
+ 2002/11/07: Wolfgang Wittek
+
+   * mhist/MHFlux.[h,cc]
+     - changed to avoid warnings : "member initializers will be re-ordered
+                                    to match declaration order"
+
+
+
+ 2002/11/06: Thomas Bretz
+
+   * Makfile.conf.osf5.1:
+     - added
+
+   * mhist/MHMatrix.cc:
+     - changed all math.h functions or similar to TMath
+     - added 2*pow(rows, 1/(4+cols))^2 as the standard kernel window
+
+   * mfileio/MCT1ReadPreProc.cc:
+     - corrected the reading routines
+
+   * mfileio/*.cc:
+     - changed my eMail address
+
+   * mfileio/structures.h:
+     - small changes to make it architecture independant
+
+
+
+ 2002/11/04: Thomas Bretz
+
+   * macros/estimate.C, macros/estfit.C:
+     - added
+     
+   * mfileio/structures.h, mfileio/defines.h:
+     - added from CT1 PreProc 0.5
+
+   * mfileio/MCT1ReadPreProc.[h,cc]:
+     - added 
+
+   * mhist/MHArray.[h,cc]:
+     - added
+
+   * Makefile:
+     - changed the order of the libs to make the linker happy
+     
+   * manalysis/MBlindPixelCalc.[h,cc]:
+     - changed to be able to use also an existing MBlindPixels from the 
+       parlist
+     - changed to use the pixel Id instead of its index number from the evt
+
+   * manalysis/MCameraSmooth.cc:
+     - changed to use the pixel Id instead of its index number from the evt
+       
+   * manalysis/MCerPhotEvt.[h,cc]:
+     - added GetPixById member function
+
+   * manalysis/MCompProbCalc.[h,cc]:
+     - changed Hadroness to Hadronness
+   
+   * manalysis/MHillasExt.cc:
+     - fixed a typo in a comment
+
+   * mbase/MParContainer.[h,cc]:
+     - added New-virtual member function
+
+   * mbase/MTask.[h,cc]:
+     - changed AddToBranchList so that it also accepts comma seperated
+       lists (only when using TString)
+       
+   * mdata/MData.[h,cc], mdata/MDataArray.[h,cc], mdata/MDataChain.[h,cc],
+     mdata/MDataElement.[h,cc], mdata/MDataList.[h,cc]
+     - updated comments
+     - added new GetDataMember member function
+     
+   * mdata/MDataArray.[h,cc]:
+     - added new member function AddEntry(MData*)
+     
+   * mfileio/FileIOLinkDef.h, mfileio/Makefile:
+     - added MCT1ReadPreProc
+     
+   * mfileio/MCT1ReadAscii.cc:
+     - removed fNphot->Clear() (automatically called for each event by
+       Reset();
+       
+   * mhist/HistLinkDef.h, mhist/Makefile:
+     - added MHArray
+     
+   * mhist/MFillH.[h,cc]:
+     - made work with arrays of histograms (MHArray) the mapping is
+       done by a preliminary class MMap
+       
+   * mhist/MH.[h,cc]:
+     - implemented GetHistByName virtual function
+     - implemented GetDataMember virtual function
+     - small changes to debug output
+     
+   * mhist/MH3.[h,cc]:
+     - implemented usage of GetDataMember for AddBranchToList
+     - implemented GetHistByName
+     - implemented New to be used in MHArray
+
+   * mhist/MHAlphaEnergyTheta.h, mhist/MHAlphaEnergyTime.h,
+     mhist/MHEnergyTheta.h, mhist/MHEnergyTime.h,
+     mhist/MHHillas.[h,cc], mhist/MHHillasExt.[h,cc],
+     mhist/MHHillasSrc.[h,cc], mhist/MHMcDifRate.h,
+     mhist/MHMcEfficiency.h, mhist/MHMcEfficiencyEnergy.h,
+     mhist/MHMcEfficiencyImpact.h, mhist/MHMcEnergy.[h,cc],
+     mhist/MHMcEnergyImpact.h, mhist/MHMcEnergyMigration.h,
+     mhist/MHMcIntRate.h, mhist/MHStarMap.h, mhist/MHThetabarTheta.h,
+     mhist/MHThetabarTime.h, mhist/MHTimeDiffTheta.h, 
+     mhist/MHTimeDiffTime.h:
+     - implemented GetHistByName
+   
+   * mhist/MHHadronness.[h,cc]:
+     - some small changes and checks
+     - changed histogram io from standard pointer to '->'
+
+   * mhist/MHMatrix.cc:
+     - updated comments
+     - implemented GetDataMembers
+
+
+
+ 2002/10/31: Thomas Bretz
+
+   * mfileio/MReadTree.cc:
+     - enhanced the validity of the fNuMEntries workaround from
+       3.02.06 to 3.07.01
+
+   * manalysis/MBlindPixelCalc.h, mhist/MBinning.h:
+     - added an explicit cast to get rid of a compiler warning on Alpha
+
+   * mhist/MH.cc:
+     - removed an unused variable to get rid of a compiler warning on Alpha
+
+
+
+ 2002/10/31: Wolfgang Wittek
+
+   * mhist/MHFlux.[h,cc]:
+     - type of fVarname and fUnit changed from char* to TString
+
+
+
+ 2002/10/30: Thomas Bretz
+
+   * mhist/MHMatrix.cc:
+     - changed the return value for the kernel method from log to -log
+     - fixed a typo in an error message
+     - fixed a crash in case the matrix is singular
+
+   * mhist/MMultiDimDistCalc.cc:
+     - check whether calculation of the distance succeeded
+
+   * mfileio/MReadTree.[h,cc]:
+     - implementation which makes sure, that the number of events returned 
+       by GetEntries always is the correct value.
+     - removed const from the GetEntries definition
+     - mainly use GetEntries now instead of fNumEntries
+
+   * manalysis/MCameraSmooth.cc:
+     - removed include of MMcRunHeader
+
+
+
+ 2002/10/29: Thomas Bretz
+
+   * manalysis/MHadroness.[h,cc]:
+     - renamed to MHadronness
+
+   * mhist/MHHadroness.[h,cc]:
+     - renamed to MHHadronness
+     - small changes to the graphical and text output
+
+   * manalysis/Makefile, manalysis/AnalysisLinkDef.h, macros/multidimdist.C,
+     manalysis/MMultiDimDistCalc.[h,cc], macros/comprob.C,
+     mhist/Makefile, mhist/HistLinkDef.h:
+     - changed Hadroness to Hadronness
+
+   * manalysis/MCerPhotAnal.cc:
+     - small changes to the code layout
+
+
+
+ 2002/10/24: Thomas Bretz
+
+   * macros/multidimdist.C:
+     - some changes to make it work with the latest version of Mars
+
+   * mhist/MHMatrix.cc:
+     - changed the Print member function to be more flexible
+
+   * mhist/MHHadroness.[h,cc]:
+     - changed fQfac from TH to TGraph
+     - changed the Qfactor-plot x-axis from Hadronness to Gamma-Acceptance
+
+   * mgui/MCamDisplay.cc:
+     - changed ratio from ratio to sqrt(ratio) in GetColorError
+
+   * mhist/MH3.cc:
+     - changed plotted errors from spread/sqrt(n) to spread
+
+
+
+ 2002/10/19: Abelardo Moralejo
+
+   * manalysis/MCerPhotCalc.cc
+     - Added check of whether a pixel has all its FADC slices empty before
+       subtracting pedestal.
+
+
+
+ 2002/10/18: Thomas Bretz
+
+   * mfileio/MWriteRootFile.cc
+     - make sure that the tree is created in the corresponding file
+
+
+
+ 2002/10/17: Thomas Bretz
+
+   * mraw/MRawEvtPixelIter.[h,cc]
+     - added function to get the sum of squares of the samples
+
+
+
+ 2002/10/16: Abelardo Moralejo
+
+   * manalysis/MCerPhotCalc2.[h,cc], MCerPhotCalc.[h,cc]
+     - Class MCerPhotCalc2 renamed MCerPhotCalc (they were redundant).
+     - Now the default pixel treatment is the same as originally: add 
+       all FADC slices
+
+   * macros/MagicHillas.C
+     - changed accordingly to changes above.
+
+
+
+ 2002/10/16: Thomas Bretz
+
+   * macros/readMagic.C:
+     - added MPrint for MRawEvtHeader
+     - changed to MPrint to new Skip-Style
+
+   * manalysis/MHillasCalc.cc, manalysis/MHillasSrcCalc.cc:
+     - corrected output stream in case of hex or setfill was used
+
+   * mbase/MPrint.[h,cc]:
+     - introduced new behaviour of PreProcess (EnableSkip)
+
+   * mbase/MTaskList.cc:
+     - fixed a bug in Process which caused Histograms to be written
+       after each event
+
+   * meventdisp/MGEvtDisplay.cc:
+     - introduced printing of MRawEvtHeader
+
+   * mmc/MMcEvt.cxx:
+     - some small changes
+     - changed Print output from cout to fLog
+     - changes to the default values
+
+   * mraw/MRawEvtHeader.[h,cc]:
+     - removed the second empty line after Print
+     - added Getter-function for the DAQEvtNumber
+
+   * macros/star.C, macros/starplot.C, macros/threshold.C, macros/trigrate.C,
+     macros/plot.C, macros/plot2.C, macros/MagicHillas.C, macros/CT1Hillas.C,
+     macros/collarea.C:
+     - added ProgressBar
+
+   * macros/flux.C:
+     - fixed some coding bugs (redeclaration of Draw, Draw starting with a
+       capital)
+
+   * macros/MagicHillas.C:
+     - fixed some typos
+
+
+
+ 2002/10/15: Thomas Bretz
+
+   * mbase/MContinue.[h,cc]:
+     - added
+     
+   * Makefile:
+     - added some comments
+     
+   * macros/readMagic.C:
+     - replaced MHillas by MHillasExt
+     - print also MC Information
+
+   * manalysis/MCerPhotEvt.[h,cc]:
+     - use MGeomCam::GetPixRatio
+     - added GetRatio[Min,Max]
+     - added GetErrorPhot[Min,Max]
+
+   * manalysis/MHillas.[h,cc], manalysis/MHillasExt.[h,cc],
+     manalysis/MHillasSrc.[h,cc]:
+     - return error codes
+     - don't display any error message or warning
+
+   * manalysis/MHillasCalc.[h,cc], manalysis/MHillasSrcCalc.[h,cc]:
+     - evaluate error codes returned by MHillas::Calc
+     - added Postprocess
+
+   * manalysis/MMcPedestalCopy.cc:
+     - removed obsolete comment
+
+   * manalysis/MMcPedestalNSBAdd.cc:
+     - added include MGeomPix
+
+   * manalysis/MPedestalCam.[h,cc]:
+     - moved some stuff from header file to source file
+       to get rid of some includes in the header file
+     - adde GetSize
+     - added GetMean[Min,Max]
+
+   * manalysis/MPedestalPix.[h,cc]:
+     - added Clear
+     - added IsValid
+
+   * mbase/BaseLinkDef.h, mbase/Makefile:
+     - added MContinue
+     
+   * mbase/MClone.h:
+     - added GetObject
+
+   * mbase/MEvtLoop.[h,cc]:
+     - added SetProgressBar II
+
+   * mbase/MTask.[h,cc], mbase/MTaskList.[h,cc]:
+     - enhanced some comments
+     - print the name of the filter in PrintStatistic
+     - made the def name and title a static member
+     
+   * meventdisp/MGCamDisplay.[h,cc]:
+     - added displays for: Errors, Phot/Err, Levels and Pedestals
+     
+   * meventdisp/MGEvtDisplay.cc:
+     - Some simplifications
+     - introduced AddTab
+   
+   * mfileio/MCT1ReadAscii.cc:
+     - added include MPedestalPix
+     
+   * mgeom/MGeomCam.[h,cc]:
+     - added GetPixRatio
+
+   * mgui/MCamDisplay.[h,cc]:
+     - added possibilities to display: errors, ratios, levels and pedestals
+
+   * mhist/MHHillasSrc.cc:
+     - some small changes if mmdeg=0
+     
+   * mhist/MHStarMap.cc:
+     - anhanced displayed radius from 2/3r to 5/6r
+
+   * mmain/MMars.[h,cc]:
+     - changed layout
+     - added comments to display
+
+   * mmain/MProgressBar.cc:
+     - added some comments
+
+   * manalysis/MImgCleanStd.cc:
+     - pixels with to many 'used' neighbors are left used
+
+
+ 2002/10/14: Abelardo Moralejo
+
+   * manalysis/McerPhotCalc.cc, manalysis/MCerPhotCalc2.cc
+     - Initialized fEnableFix (before, bad pedestal subtraction if
+       reading camera 0.4 root files)
+
+
+ 2002/10/09: Abelardo Moralejo
+
+   * mhist/MHMcRate.cc:
+     - fixed a bug in total rate calculation (results change very little, 
+       only a 0.2 percent at most)
+
+
+ 2002/09/16: Thomas Bretz
+
+   * mtools/MagicSnake.cc:
+     - removed some debugging output
+     - fixed a small bug in the initialization
+
+
+
+ 2002/09/16: Thomas Bretz
+
+   * manalysis/MCerPhotPix.cc:
+     - shortened output
+
+   * mbase/MEvtLoop.cc:
+     - added a better progressbar support, if MReadTree or MReadMarsFile
+       exists in the Tasklist 
+
+   * mbase/MTaskList.cc:
+     - fixed a bug which caused MParList::Reset not to be called anymore
+       as soon as kCONTINUE was called once.
+
+   * mfileio/MReadTree.[h,cc]:
+     - added AddFiles member function
+
+   * mmain/MProgressBar.[h,cc]:
+     - added as a simple Progress meter for eventloops
+
+   * mmain/Makefile, mmain/MainLinkDef.h:
+     - added MProgressBar
+
+   * manalysis/MHillas.cc:
+     - removed warning in case of no photons. problems with Thomas' files.
+
+   * mbase/Makefile:
+     - added mfileio
+
+
+
+ 2002/09/16: Thomas Bretz
+
+   * macros/rootlogon.C:
+     - added SetMakeSharedLib to make it work correctly on linux
+
+   * manalysis/AnalysisLinkDef.h, manalysis/Makefile:
+     - added MEnergyEstParam
+     - added MMatrixLoop
+
+   * manalysis/MEnergyEstParam.[h,cc], manalysis/MMatrixLoop.[h,cc]:
+     - added
+
+   * manalysis/MEnergyEst.h:
+     - added fImpact provisionally
+     - changed to 'no-storage'
+
+   * manalysis/MHillas.[h,cc], manalysis/MHillasExt.[h,cc],
+     manalysis/MHillasSrc.[h,cc]:
+     - added set function to support Thomas Schweitzers Image files
+
+   * mbase/MFilter.cc:
+     - small changes to output
+
+   * mbase/MLog.[h,cc]:
+     - added IsNull to switch off output completely
+
+   * mbase/MParList.[h,cc]:
+     - added Remove function
+     - added IsOwner function
+     - changes to SavePrimitive
+     - kDoNotReset-support
+
+   * mbase/MTaskList.cc:
+     - make sure, that in sub-tasklist the parameterlist isn't reset
+
+   * mdata/MDataLinkDef.h, mdata/Makefile:
+     - added MDataElement
+     - added mhist-path
+
+   * mdata/MDataChain.[h,cc]:
+     - added support for MDataElement
+
+   * mhist/MH3.[h,cc]:
+     - added enums for log-scale
+     - set logscale automatic when drawing
+     - added 'only' option to draw functions
+     - set colors when 'col' option is given
+
+   * mhist/MHHillas.cc:
+     - better hist range for fCenter
+
+   * mhist/MHMatrix.[h,cc]:
+     - made default name and title a static class member
+     - changed AddColumn now returning the new comlumn index
+     - added Fill to fill Matrix from file
+     - added locking
+     - added IsValid
+     - added GetNumRows
+     - added SetNumRow
+     - added []-operator
+     - added GetNumRow
+
+   * mhist/MHStarMap.cc:
+     - fixed some comments
+
+   * mbase/MEvtLoop.[h,cc], MParContainer.[h,cc]:
+     - added support for writing two or more Evtloops into one macro
+
+
+
+ 2002/09/02: Thomas Bretz
+
+   * mhist/MHMatrix.[h,cc]:
+     - added GetIndexdOfSortedColumn
+     - added SortMatrixByColumn
+
+   * mhist/HistIncl.h:
+     - added TArrayI.h (for MHMatrix.h)
+
+
+
+ 2002/08/19: Thomas Bretz
+
+   * mhist/MHillasExt.cc:
+     - removed a wrong 2 in the calculation of fAsym
+
+
+
+ 2002/08/16: Thomas Bretz
+
+   * mhist/MFillH.cc:
+     - if not title is given create a default title from the names
+
+   * mhist/MHHillas.cc, mhist/MHHillasExt.cc:
+     - use the new MH::Draw[Copy] function
+     - added names to the histograms in MHHillasExt
+
+   * manalysis/MCerPhotPix.h:
+     - unimportant change
+
+   * manalysis/MImgCleanStd.cc:
+     - added comment
+
+   * mhist/MH.[h,cc]:
+     - added function to draw two histograms in one pad with
+       a layout of two stat boxes and a legend: Draw[Copy]
+     - added comments
+     - added another sanity check in SetBinning(TH1*,TH1*)
+
+
+
+ 2002/08/14: Thomas Bretz
+
+   * mbase/MTask.[h,cc], mbase/MTaskList.[h,cc]:
+     - added second argument to PrintStatistics
+
+
+
+
+
+ 2002/08/12: Thomas Bretz
+
+   * manalysis/MBlindPixelCalc.[h,cc]:
+     - fixed a typo in the SetUseCentralPixel
+     - only use pixels without starlight for interpolation
+
+
+
+ 2002/08/09: Thomas Bretz
+
+   * mbase/MIter.[h,cc]:
+     - added
+
+   * mbase/BaseLinkDef.h, mbase/Makefile:
+     - added MIter
+
+   * mdata/MDataChain.cc:
+     - added sanity check in StreamPrimitive
+
+   * mfilter/MF.[h,cc]:
+     - fixed StreamPrimitive
+     - don'w stream standard name and title.
+     - added default constructor
+
+   * mfilter/MFDataMeber.cc:
+     - strip spces from value before returning GetRule
+
+   * mfilter/MFilterList.[h,cc]:
+     - fixed StreamPrimitive
+     - don't stream standard name and title.
+
+
+
+ 2002/08/08: Thomas Bretz
+
+   * manalysis/MHillasSrc.cc:
+     - use double dist instead of single fDist for calculation
+
+   * manalysis/MMultiDimDistCalc.[h,cc]:
+     - added support for the kernel method
+     - added stream primitive
+     - changed version number to 1
+     - adapted to new MHMatrix (using MDataArray)
+
+   * mdata/MDataArray.[h,cc]:
+     - added
+
+   * mdata/DataLinkDef.h, madata/Makefile:
+     - added MDataArray
+
+   * mfileio/MWriteRootFile.cc:
+     - fixed some bugs in StreamPrimitive
+     - StreamPrimtive doesn't write the default name/title anymore
+
+   * mhist/MHMatrix.[h,cc]:
+     - replaced the Arrays for the rules by a MDataArray
+     - implemented StreamPrimitive
+     - implement the use of the kernel function for num<0
+     - multiply fM2 by nevts-1
+     - added sanity check in case of dists[i]<0
+
+   * mhist/MHHillas.[h,cc]:
+     - added fUsedPix, fCorePix
+     - added fUsedPix, fCorePix to plots
+     - changed layout of plots
+     - changed name and title of MakeDefCanvas
+
+   * mhist/MHHillasSrc.[h,cc]:
+     - changed plot of Alpha from fabs(fAlpha) to fAlpha
+     - changed name and title of MakeDefCanvas
+
+   * mhist/MHillasExt.[h,cc]:
+     - changed layout of plots
+     - changed name and title of MakeDefCanvas
+     - made independant of MHillas
+     - exchanged the usage of the Fill-argument (MHillasExt) and the
+       stored pointer (MHillasSrc)
+     - changed the default binning of asym to be symmetric
+
+   * mbase/MTask.cc:
+     - fixed wrong streaming of filter name
+
+   * macros/starplot.C:
+     - added
+
+   * macros/dohtml.C:
+     - added starplot.C
+
+   * macros/MagicHillas.C, macros/CT1Hillas.C:
+     - changed to use new stylish Hillas Histograms
+
+   * macros/star.C:
+     - changed to interpolate pixels around hot spots
+     - write Sourcs and AntoSource to RunHeaders
+
+
+
+ 2002/08/07: Thomas Bretz
+
+   * macros/dohtml.C:
+     - added missing paths
+
+   * manalysis/MBlindPixelCalc.[h,cc]:
+     - replaced booleans by fFlags
+     - added StreamPrimitive
+     - changed version number to 1
+
+   * manalysis/MHillasSrcCalc.[h,cc]:
+     - added correct initializations for the pointers
+     - made the pointers persistent
+
+   * manalysis/MImgCleanStd.cc, manalysis/MSrcPosCam.cc,
+     mfileio/MWriteRootFile.cc:
+     - don't stream name and title if not necessary
+
+   * mbase/MEvtLoop.[h,cc]:
+     - added some output
+     - added print function
+     - added gListOfPrimitives to delete BIT(15) of streamed containers
+     - Added default argument for Read and Write
+
+   * mbase/MParContainer.cc:
+     - added usage of gListOfPrimitives
+
+   * mbase/MParList.cc, mbase/MTaskList.cc, mhist/MBinning.cc:
+     - fixed a bug when only the title is different from the default
+
+   * mhist/MHHillas.cc:
+     - fixed the wrong usage of ApplyBinning for the 2D-Hist fCenter
+
+
+
+ 2002/08/06: Thomas Bretz
+
+   * mhist/MHHillas.cc:
+     - fixed setting of binning for fCamera
+
+   * mhist/MH.cc, mhist/MBinning.cc:
+     - added sanity check in ApplyBinning and Apply
+
+   * mbase/MFilterList.[h,cc]:
+     - moved to mfilter
+
+   * mbase/Makefile, mbase/BaseLinkDef.h, 
+     mfilter/Makefile, mfilter/FilterLinkDef.h:
+     - changed accordingly
+
+
+
+ 2002/08/05: Thomas Bretz
+
+   * mbase/MEvtLoop.[h,cc]:
+     - added a warning in case of duplicate names in the lists
+     - added orresponding member functions (HasDuplicateNames)
+     - added some sanity checks, checking for an open file
+
+   * mbase/MFilter.[h,cc]:
+     - added GetRule virtual member function
+
+   * mbase/MFilterList.[h,cc]:
+     - added GetRule 
+     - added StreamPrimitive
+     - added name and title to the constructor
+     - set version number to 1
+
+   * mbase/MTask.h:
+     - removed const qualifiers from fFilter (seems, that the root io
+       doesn't like it)
+
+   * mdata/MDataChain.[h,cc], mdata/MDataList.[h,cc], mdata/MDataMember.[h,cc],
+     mdata/MDataValue.[h,cc]:
+     - set class version to 1
+     - added default constructor if missing
+     - added fDataMember to MDataMember (formaly fName isn't stored)
+
+   * mfilter/MF.[h,cc], mfilter/MFAlpha.[h,cc], mfilter/MFDataMember.[h,cc],
+     mfilter/MFParticleId.[h,cc], mfilter/MFTriggerLvl1.[h,cc]:
+     - added StreamPrimitive
+     - removed const qualifiers from data members
+     - added the "!" to the data member storing the result
+     - added GetRule
+
+   * mhist/MFillH.[h,cc]:
+     - fixed some small bugs in StreamPrimitive
+
+   * mhist/MH3.[h,cc]:
+     - added the missing const-qualifier of StreamPrimitive
+
+   * mbase/MParContainer.[h,cc]:
+     - implemented setting a unique id in SavePrimitive
+     - imnplemented GetUniqueID 
+     
+   * manalysis/MHillasSrcCalc.cc, manalysis/MImgCleanStd.cc,
+     manalysis/MSrcPosCam.cc, mbase/MEvtLoop.cc, mbase/MParList.cc,
+     mbase/MTaskList.cc, mfileio/MReadTree.cc, mfileio/MWriteRootFile.cc,
+     mhist/MF.cc, mfilter/MFAlpha.cc, mfilter/MFDataMember.cc,
+     mfilter/MFParticleId.cc, mfilter/MFTriggerLvl1.cc, mhist/MBinning.cc,
+     mhist/MFillH.cc, mhist/MH3.cc:
+     - changed the 'instance' name to the UniqueName
+     - in some files: implemented a static constant name and title, which
+       is used to descide whether the name and/or title should be stream
+       in the constructor-call in StreamPrimitive
+
+
+
+ 2002/08/06: Wolfgang Wittek
+
+   * mbase/MTask.cc:
+     - redefinition of default argument in MTask::SavePrimitive removed
+
+
+
+ 2002/08/02: Thomas Bretz
+
+   * manalysis/MHillasSrcCalc.[h,cc], manalysis/MImgCleanStd.cc,
+     manalysis/MSrcPosCam.cc, mbase/MParContainer.[h,cc],
+     mfileio/MReadTree.cc, mfileio/MWriteRootFile.cc, mhist/MBinning.cc:
+     - added comments
+
+   * manalysis/MSrcPosCam.cc, mfileio/MWriteRootFile.cc, mhist/MFillH.cc:
+     - fixed a missing " in SavePrimitive
+
+   * mbase/MTask.[h,cc], mhist/MBinning.[h,cc], mhist/MH3.[h,cc]:
+     - implemented SavePrimitive
+
+   * mbase/MEvtLoop.[h,cc]:
+     - added MakeMacro
+     - added Read and Write
+
+   * mbase/MParContainer.[h,cc], mbase/MParList.[h,cc], 
+     mbase/MTaskList.[h,cc]:
+     - added GetNames, SetNames virtual functions
+
+   * mdata/MData.[h,cc], mdata/MDataChain.[h,cc], mdata/MDataList.[h,cc],
+     mdata/MDataValue.[h,cc], mdata/MDataMember.[h,cc]:
+     - implemented GetRule
+     - move Code from Print to GetRule
+     - removed Print
+
+   * mhist/MH3.[h,cc]:
+     - implemented default constructor
+
+   * manalysis/MHillasSrcCalc.[h,cc], manalysis/MImgCleanStd.[h,cc],
+     manalysis/MSrcPosCam.[h,cc], mbase/MParList.[h,cc], mbase/MTask.h,
+     mbase/MTaskList.[h,cc], mfileio/MReadTree.[h,cc], 
+     mfileio/MWriteRootFile.[h,cc], mhist/MBinning.[h,cc], 
+     mhist/MFillH.[h,cc], mhist/MH3.[h,cc]:
+     - renamed SavePrimitive to StreamPrimitive
+     - implemented more accurate streaming
+     - removed some "//!" from the data members
+
+   * mbase/MParContainer.[h,cc]:
+     - new virtual function StreamPrimitive
+     - implemented flag whether this container has been streamed already
+
+   * mbase/MTask.[h,cc]:
+     - corrected streaming of primitive to stream filters correctly
+     - increased version number to 1
+
+   * mhist/MBinning.[h,cc]:
+     - move SetEdges and SetEdgesLog to the source file
+     - implemented a flag telling something about the type of the binning
+
+
+
+ 2002/08/01: Thomas Bretz
+
+   * manalysis/MHillasSrcCalc.[h,cc], manalysis/MImgCleanStd.[h,cc],
+     manalysis/MSrcPosCam.[h,cc], mbase/MEvtLoop.[h,cc], 
+     mbase/MParContainer.[h,cc], mbase/MParList.[h,cc],
+     mbase/MTaskList.[h,cc], mfileio/MReadTree.[h,cc],
+     mfileio/MWriteRootFile.[h,cc], mhist/MFillH.[h,cc]:
+     - added SavePrimitive
+
+   * mbase/MEvtLoop.h, mbase/MParList.h, mbase/MTaskList.h,
+     mfileio/MReadMarsFile.h, mfileio/MReadTree.h, 
+     mfileio/MWriteRootFile.h, mhist/MFillH.h:
+     - changed from ClassVersion 0 to ClassVersion 1
+   
+   * mfileio/FileIOLinkDef.h:
+     - added MChain
+
+   * mfileio/MReadMarsFile.cc, mfileio/MReadTree.cc, 
+     mfileio/MWriteRootFile.cc, mhist/MFillH.cc:
+     - added default constructor
+
+   * mfileio/MReadTree.cc:
+     - moved MChain to its own file
+
+   * mfileio/MWriteRootFile.cc:
+     - added default constructor to MRootFileBranch
+     - changed Version number from 0 to 1
+
+   * mfileio/Makefile, mfileio/FileIOLinkDef.h:
+     - MChain added
+
+   * mfileio/MChain.[h,cc]:
+     - added (from MReadTree.cc)
+
+   * manalysis/MHillas.[h,cc]:
+     - don't draw ellipse if values are invalid
+     - add used and core pixels to Print-output
+
+   * manalysis/MHillasExt.cc:
+     - reordered some comments
+
+   * mdata/MDataChain.[h,cc]:
+     - fixed a bug causing usage of '-' sometime not to work
+     - added handling of '+' sign
+
+   * mfileio/MReadTree.h:
+     - changed some comments
+
+   * mhist/MBinning.[h,cc]:
+     - added Apply
+
+   * mhist/MHHillas.[h,cc], mhist/MHHillasSrc.[h,cc], 
+     mhist/MHHillasExt.[h,cc]:
+     - added default binning (usefull for the Magic Camera)
+     - some changes to the layout
+     - added support for the sign in MHHillasExt
+
+   * manalysis/MBlindPixelCalc.[h,cc]:
+     - added the possibility to use the interpolation of the
+       surrounding pixels
+     - clean the array with the blind pixel IDs at any ReInit
+
+   * manalysis/MBlindPixels.h:
+     - IsBlind now checks also for the validity of the array
+
+   * manalysis/MCerPhotPix.h:
+     - added Set-function
+
+   * manalysis/MHillas.cc:
+     - Don't ouput a warning if fSize==0 or fNumUsedPixels<0
+       (happens too often)
+
+   * manalysis/MCameraSmooth.[h,cc]:
+     - added
+
+   * manalysis/Makefile, manalysis/AnalysisLinkDef.h:
+     - added MCameraSmooth
+
+
+
+ 2002/07/31: Thomas Bretz
+
+   * mgeom/MGeomPix.[h,cc]:
+     - added bits to flag pixel sin the two most outer rings
+     - added IsInOutermostRing and IsInOuterRing member function
+     - added CheckOuterRing mebmber function
+     - set the bit for the most outer ring in the member function to
+       initialize the next neighbors.
+
+   * mgeom/MGeomCam.[h,cc]:
+     - added InitOuterRing to initialize the bits for the secendmost 
+       outer ring
+
+   * mgeom/MGeomCamMagic.cc:
+     - Call InitOuterRing
+
+   * manalysis/MHillasExt.[h,cc]:
+     - removed AsciiRead member function
+     - reset fConc/fConc1 to -1 instead of 0
+     - replaced float by Float_t
+     - replaced Float_t for m3x/y, dzx and dzy by Double_t
+     - replaced maxpixx and maxpixy by maxpixid
+     - added somew new calculations (still in comments)
+     - scaled nphot by the ratio of the area of the current pixel to
+       the pixel with id zero to make a fair comparison in the maxpix
+       findinng
+
+   * manalysis/MSrcPosCam.[h,cc]:
+     - removed AsciiRead/Write member function
+
+   * manalysis/MImgCleanStd.cc:
+     - changed ispixused array size from max to max+1
+
+   * macros/MagicHillas.C:
+     - use the default binning of the histograms
+
+   * mhist/MH.[h,cc]:
+     - changed argument of SetBinning from TArrayD* to TArrayD&
+     - added ScaleArray
+     - added ScaleAxis
+     - proved that ScaleAxis is really working
+     - Added ApplyBinning
+
+   * mhist/MHHillas.[h,cc], mhist/MHHillasSrc.[h,cc]:
+     - corrected the default binning
+     - take use of MH::ApplyBinning
+     - don't stop execution if no binning was found (take default)
+     - made sure, that rescaling of the axis is working properly
+
+
+
+ 2002/07/29: Thomas Bretz
+
+   * manalysis/MImgCleanStd.[h,cc]:
+     - changed ispixused from static size to dynamicly allocated size
+       (thanks to Markus Gaug)
+
+
+
+ 2002/07/29: Thomas Bretz
+
+   * mhist/MH.[h,cc]:
+     - added FindGoodLimits (taken from TTreePlayer)
+     - added GetMinimumGT
+
+   * mbase/MAGIC.h:
+     - removed kPI (redefinition in TVector2.h)
+
+   * mbase/BaseLinkDef.h:
+     - removed kPI (redefinition in TVector2.h)
+
+
+
+ 2002/07/26: Abelardo Moralejo
+
+   * mhist/MH.cc
+     - Fix: removed default arguments of ScaleAxis(...)  (did not 
+       compile on alphas).
+
+
+
+ 2002/07/25: Abelardo Moralejo
+
+   * manalysis/MCerPhotCalc2.[h,cc]:
+     - Changed fWeight into a TArrayF to make the class usable for
+       any number of FADC slices.
+     - added procedure SetDefaultWeights for initialization.
+
+   * macros/MagicHillas.C: 
+     - changed accordingly
+
+
+
+ 2002/07/25: Wolfgang Wittek, Thomas Bretz
+
+   * mhist/MHHillas.[h,cc], mhist/MHHillasSrc.[h,cc]:
+     - added some more histograms showing the new parameters.
+
+   * mhist/MH.[h,cc]:
+     - added ScaleAxis member functions
+
+
+
+ 2002/07/25: Thomas Bretz
+
+   * mtools, mtools/Makefile, mtools/ToolsLinkDef.h, mtools/ToolsIncl.h:
+     - added
+
+   * mgeom, mgeom/Makefile, mgeom/GeomLinkDef.h, mgeom/GeomIncl.h:
+     - added
+
+   * Makefile:
+     - mtools added
+     - mgeom added
+
+   * mtools/MagicCivilization.[h,cc], mtools/MagicDomino.[h,cc],
+     mtools/MagicShow.[h,cc], mtools/MagicSnake.[h,cc]:
+     - added
+
+   * mgui/MineSweeper.[h,cc]:
+     - moved to mtools
+
+   * mgui/MGeom*.[h,cc]:
+     - moved to mgeom
+
+   * mgeom/MGeomCamMagic.cc:
+     - corrected 48(!) wrong entries in the Next Neighbor table
+
+   * mmain/Makefile, eventdisp/Makefile:
+     - added mgeom
+
+   * mgui/Makefile, mgui/LinkDef.h, mhist/Makefile, manalysis/Makefile:
+     - removed MGeom* and MineSweeper
+
+   * macros/rootlogon.C:
+     - added new include paths
+
+   * manalysis/MCerPhotEvt.cc, mgeom/MGeomCam.cc:
+     - removed include of MHexagon
+
+
+
+ 2002/07/23: Thomas Bretz
+
+   * mgui/MineSweeper.cc, mgui/MCamDisplay.cc:
+     - fixed a bug which could caused the destructor of the created canvas
+       not to be called if the object was deleted.
+
+   * mgui/MCamDisplay.h:
+     - some reordering
+
+   * mgui/MHexagon.cc:
+     - return the correct distance to primitive
+     - do a sanity check in DistancetoPrimitive
+
+   * mhist/HistLinkDef.h:
+     - added missing classes
+
+
+
+ 2002/07/23: Wolfgang Wittek, Thomas Bretz
+
+   * manalysis/MHillas.cc, manalysis/MHillasSrc.cc:
+     - replaced algorithms by the ones from the corresponding TDAS note
+     - made results of calculations (hopefully) more accurate
+     - added some output warnings and sanity checks
+     - changed the default parameters in the Reset function
+
+   * manalysis/MHillasSrc.[h,cc]:
+     - added fCosDeltaAlpha
+     - made Calc returning a Bool_t
+
+   * manalysis/MHillasSrcCalc.cc:
+     - make use of the return value of MHillasSrc::Calc 
+
+
+
+ 2002/07/22: Abelardo Moralejo
+
+   * manalysis/MCerPhotCalc2.[h,cc]:
+     -added procedure SetWeights.
+
+   * macros/MagicHillas.C:
+     -added example on how to use MCerPhotCalc2
+
+
+
+ 2002/07/22: Thomas Bretz
+
+   * mgui/MCamDisplay.cc:
+     - removed some unecessary includes
+     - replaced *fPixels by *this
+
+   * mgui/MineSweeper.[h,cc]:
+     - added more comments
+     - removed some unnecessary includes
+     - replaced enum constants for colors by the root ones
+     - added gInterpreter->DeleteGlobal(this)
+     - removed the deletion of the self-allocated fDrawingPad
+     - added kUserBits, replacing kBitMask
+
+
+
+ 2002/07/16: Thomas Bretz
+
+   * macros/plot.C, macros/plot2.C, macros/star.C, macros/comprob.C:
+     - updated the comments in the macros
+     
+   * mgui/MHexagon.cc:
+     - added a sanity check in DistanceToPrimitive
+
+   * mgui/MCamDisplay.[h,cc]:
+     - added DistanceToPrimitive
+     - declared virtual functions as virtual (easier to read in the Dox)
+
+   * mfileio/MWriteAsciiFile.[h,cc]:
+     - renamed AddContainer and AddRule to AddColumn and AddColumns
+
+   * macros/MagicHillas.C:
+     - adopted to new names of MWriteAsciiFile member functions
+
+
+
+ 2002/07/16: Wolfgang Wittek
+
+   * new 
+     ---
+     mhist    : MHEffOnTime     (replaces MHEffOnTimeTime and
+                                          MHEffOnTimeTheta)
+                MHThetabarTheta (forgotten to comit last time)
+                MHThetabarTime  (forgotten to comit last time)
+                MHGamma         (makes the subtraction SRC-ASRC and
+                                 counts the events with alpha<alpha0)
+
+   * modified 
+     --------
+     Mars     : Makefile.conf.general 
+                Changelog
+
+
+     mhist    : Makefile
+                HistLinkDef.h 
+                MHFlux             (performs the flux calculation)
+
+                MHAlphaEnergyTheta (replace BinningAlpha by BinningAlphaFlux)
+                MHAlphaEnergyTime  (replace BinningAlpha by BinningAlphaFlux)
+
+     macros   : flux.C       (replace some code by MHGamma,
+                              replace MHEffOnTimeTime and MHEffOnTimeTheta
+                              by MHEffOnTime)
+
+   * removed
+     -------
+     mhist    : MHEffOnTimeTime
+                MHEffOnTimeTheta
+
+
+
+ 2002/07/15: Abelardo Moralejo
+
+   * manalysis/MCerPhotCalc2.[h,cc]
+     - converted fWeight into a static variable.
+
+
+
+ 2002/07/11: Thomas Bretz
+
+   * mgui/MGeomCamCT1.cc:
+     - fixed a bug in the NN-Table (127 doesn't exist, 126 missing)
+
+   * mgui/MCamDisplay.cc:
+     - changed some gPad to fDrawingPad
+     - added kNoContextMenu and kCannotPick flags for the Primitives
+     - scaled the size of the pixel numbers text with the pixel radius
+
+   * mgui/MineSweeper.[h,cc]:
+     - added
+
+   * mgui/Makefile, mgui/GuiLinkDef.h:
+     - added MineSweeper
+
+   * Makefile:
+     - added missing mfileio
+
+
+
+ 2002/07/11: Abelardo Moralejo
+
+   * manalysis/MCerPhotCalc2.[h,cc]
+     - new class to compute nphe weighting FADC slices.
+
+
+
+ 2002/07/10: Oscar Blanch
+
+   * manalysis/MCerPhotAnal.[h,cc]
+     - new class to compute nphe. First version.
+
+
+
+ 2002/07/10: Abelardo Moralejo
+
+   * macros/MagicHillas.C:
+     -added MMcEvt container to hillas.root output
+
+
+
+ 2002/07/10: Thomas Bretz
+
+   * mmain/Makefile:
+     - added -I../mfileio
+
+   * manalysis/MCerPhotPix.h:
+     - renamed IsCorePixel to IsPixelCore
+     - renamed SetCorePixel to SetPixelCore
+
+   * manalysis/MHillas.[h,cc]:
+     - added fNumCorePixel
+     - added fNumUsedPixel
+
+   * manalysis/MImgCleanStd.cc, manalysis/MCerPhotEvt.cc:
+     - renamed IsCorePixel and SetCorePixel
+
+
+
+ 2002/07/08: Thomas Bretz
+
+   * macros/rootlogon.C:
+     - added include pathes for ACLIC
+
+   * mfileio, mfileio/FileIOLinkDef.h, mfileio/FileIOIncl.h, 
+     mfileio/Makefile:
+     - new directory
+
+   * mbase/MWriteAsciiFile.[h,cc], mbase/MWriteRootFile.[h,cc],
+     mbase/MReadTree.[h,cc], mbase/MReadMarsFile.[h,cc],
+     manalysis/MCT1ReadAscii.[h,cc]:
+     - moved to mfileio
+
+   * mbase/Makefile, mbase/BaseLinkDef.h, mbase/BaseIncl.h,
+     manalysis/Makefile, manalysis/AnalysisLinkDef.h, 
+     manalysis/AnalysisIncl.h, meventdisp/Makefile:
+     - changed accordingly
+
+   * meventdisp/MGCamDisplay.cc:
+     - cd to right canvas before drawing camera display
+
+   * meventdisp/MGEvtDisplay.[h,cc]:
+     - added the "Geometry"-Tab
+     - added MC informations to gui
+
+   * mgui/MCamDisplay.[h,cc]:
+     - added DrawPixelNumbers
+     - added buttons to change the palette online
+
+   * mgui/MHexagon.h:
+     - added Getter functions
+
+   * macros/MagicHillas.C:
+     - added read.DisableAutoScheme()
+
+   * mhist/MH.[h,cc]:
+     - changed Fill to be non abstract anymore
+
+
+
+ 2002/07/04: Abelardo Moralejo
+
+   * macros/trigrate.C:
+     - Introduced some style improvements suggested by T. Bretz.
+
+
+
+ 2002/07/04: Abelardo Moralejo
+
+   * mmontecarlo/MMcTriggerRateCalc.h,cc:
+     - Now the dimension of fTrigger is set dynamically, to allow
+       the processing of files with an arbitrarily large number of 
+       trigger conditions inside.
+
+   * macros/trigrate.C:
+     - Adapted the macro to changes above, and added a third argument:
+       the name of a file containing pure NSB events from which the
+       accidental trigger rate is calculated. Previously, this had to 
+       be introduced in the macro by hand by the user.
+
+
+
+ 2002/06/14: Thomas Bretz
+
+   * mhist/MBinning.cc:
+     - Initialize the binning with 10 edges from 0 to 1
+
+
+
+ 2002/06/13: Thomas Bretz
+
+   * mdata/MData.cc:
+     - changed ostream.h to ofstream.h to make it compile on alpha
+
+
+
+ 2002/06/10: Thomas Bretz
+
+   * mbase/MReadMarsFile.cc:
+     - changed name of fRun to ReadRunHeaders
+
+   * mbase/MReadTree.cc:
+     - changed output to show name of class
+
+   * macros/plot.C:
+     - added
+
+   * macros/plot2.C:
+     - added
+
+   * manalysis/MHillas.cc:
+     - changed atan2 to atan for fDelta
+
+   * mbase/MAGIC.h, mbase/BaseLinkDef.h:
+     - changed definitions for Particle Id to enum
+
+   * mbase/MGList.cc:
+     - IsA()->InheritsFrom() replaced with InheritsFrom()
+
+   * mbase/MWriteAsciiFile.cc:
+     - IsA()->InheritsFrom() replaced with InheritsFrom()
+     - removed some debug outputs
+
+   * mbase/MDataChain.[h,cc]:
+     - implemented sign '-'
+
+   * mhist/MH.h:
+     - changed default canvas size to 580x435
+
+   * mhist/MHHadroness.cc:
+     - added some more output to Print
+
+   * mhist/MHMatrix.h:
+     - changed some i,j to x,y
+     - removed fabs from distance calculation
+     - added sqrt to distance calculation
+
+   * mmc/MMcEvt.cxx:
+     - changed output of Print
+
+
+
+ 2002/06/06: Thomas Bretz
+
+   * manalysis/MHillasSrc.cc:
+     - changed atan2 to atan for fAlpha
+
+
+
+ 2002/06/05: Thomas Bretz
+
+   * mbase/MWriteAsciiFile.[h,cc]:
+     - changed the code completely to support rules (data chains), too.
+       the interface stayed the same.
+
+   * mdata/MDataChain.cc, mhist/MHMatrix.cc:
+     - added math.h for alpha compilers
+
+   * mbase/MParContainer.h:
+     - changes IsReadyToSave to const
+
+   * mdata/MData.[h,cc]:
+     - added AsciiWrite
+
+   * mdata/MDataChain.[h,cc], mdata/MDataList.[h,cc], mdata/MDataValue.h:
+     - added IsReadyToSave
+
+   * mdata/MDataMember.[h,cc]:
+     - added a new constructor
+     - added IsReadyToSave
+
+
+
+ 2002/06/04: Thomas Bretz
+
+   * mhist/MHCompProb.[h,cc]:
+     - added
+
+   * mhist/MHMatrix.cc:
+     - corrected some bugs in the algorithm to calculate the distance
+
+   * mhist/Makefile:
+     - added -I../mmc
+
+   * mbase/Makefile:
+     - added -I../mdata
+
+   * mhist/MHHadroness.cc:
+     - some changes to the layout of the drawn histograms
+
+
+
+ 2002/06/03: Thomas Bretz
+
+   * mhist/MHCompProb.[h,cc]:
+     - added
+
+   * mhist/MHHadroness.[h,cc]:
+     - added
+
+   * mhist/HistLinkDef.h, mhist/Makefile:
+     - added MHCompProb
+     - added MHHadroness
+
+   * mhist/MFillH.cc:
+     - added a info-output
+
+   * mhist/MH3.cc:
+     - excluded temporary profiles from directory
+
+   * mhist/MHMatrix.[h,cc]:
+     - added code to calculate multi-dimensional distances
+     - added comments
+
+   * mbase/MAGIC.h:
+     - changed kGAMMA to 1
+
+   * mbase/MParList.[h,cc]:
+     - added Replace-function
+
+   * mbase/MReadMarsFile.[h,cc]:
+     - added correct seeking for the run headers
+
+   * mbase/MReadTree.[h,cc]:
+     - added GetFileIndex()
+
+   * mbase/MTaskList.cc:
+     - changed fTasksProcess.Delete() to fTasksProcess.Clear()
+
+   * mbase/MWriteAsciiFile.[h,cc]:
+     - added some code for future usage (in comments)
+
+   * mbase/MLogo.[h,cc]:
+     - added (not in use)
+
+   * mfilter/MFParticleId.[h,cc]:
+     - added
+
+   * mfilter/Makefile, mfilter/FilterLinkDef.h:
+     - added MFParticleId
+
+   * manalysis/MHadroness.[h,cc]:
+     - added
+
+   * manalysis/MCompProbCalc.[h,cc]:
+     - added
+
+   * manalysis/MMultiDimDistCalc.[h,cc]:
+     - added
+                                                           
+   * manalysis/AnalysisLinkDef.h, manalysis/Makefile:
+     - added MHadroness
+     - added MCompProbCalc
+     - added MMultiDimDistCalc
+
+   * manalysis/Makefile:
+     - added ../mdata
+     - added ../mhist
+
+   * macros/star.C:
+     - added
+
+   * macros/comprob.C:
+     - added
+
+   * macros/multidimdist.C:
+     - added
+  
+  * macros/dohtml.C:
+     - added star.C
+     - added comprob.C
+     - added multidimdist.C
+
+  * mdata/MData.h:
+     - added ()-operator
+
+  * mdata/MDataList.cc:
+     - removed 'all' modifier in Print-statement
+
+  * mdata/MDataChain.[h,cc]:
+     - added default constructor
+
+  * mdata/MReadTree.cc:
+     - fixed a root bug for root versions<3.03/00 (the open file in
+       the TChain was not deleted (closed))           
+
+   * mbase/MReadMarsFile.[h,cc]:
+     - store parlist instead of tasklist
+     - check for run types between files
+     - check for used reflector version (because of a bug in the program)
+
+   * mmc/MMcRunheader.hxx:
+     - added GetReflVersion()
+
+   * mmontecarlo/MMcTriggerRateCalc.cc:
+     - changed particle Id numbers to predefined constants
+
+
+
+ 2002/05/29: Thomas Bretz
+
+   * mhist/MHMatrix.[h,cc]:
+     - added
+
+   * mhist/HistLinkDef.h, mhist/Makefile
+     - added MHMatrix
+
+   * mhist/MH.h:
+     - added Finalize-function prototype to be called at the end of
+       the eventloop
+
+   * mhist/MFillH.cc:
+     - added call to Finalize-function to in PostProcess
+
+   * mhist/MH3.cc:
+     - removed old includes
+
+   * mhist/MDataChain.cc:
+     - fixed a harmfull bug in the constructor. fOperatorType wasn't
+       correctly initialized
+
+   * mhist/MDataMember.cc:
+     - added some output in case of failures
+
+   * mgui/MGeomCam.[h,cc]:
+     - renamed fMm2Deg to fConvMm2Deg to be consistent with the Getter
+       function name
+
+
+
+ 2002/05/13: Thomas Bretz
+
+   * mbase/MReadTree.cc:
+     - changed the Notify-workaround from GetEntry to LoadTree.
+
+   * mfilter/MFDataMember.[h,cc]:
+     - changed class to use MDataMember instead of a direct access to
+       TMethodCall
+
+   * mfilter/Makefile:
+     - added path to mdata
+
+
+
+ 2002/05/06: Thomas Bretz
+
+   * mbase/MReadMarsFile.cc, mbase/MReadTree.cc, mbase/MTaskList.cc:
+     - implemented usage of the return value of the Notofy function
+
+   * mdata/MDataChain.[h,cc]:
+     - implemented single-argument operators (like abs or exp)
+
+
+
+ 2002/05/03: Thomas Bretz
+
+   * mars.cc:
+     - changed version to 0.8
+     - added logo stuff
+
+   * merpp.cc:
+     - changed usage-output
+
+   * mgui/MCamDisplay.cc, mgui/MGeomCam.cc, mgui/MGeomCamCT1.cc, 
+     mgui/MGeomCamMagic.cc, mgui/MHexagon.cc, mhist/MBinning.cc,
+     mhist/MFillH.cc, mhist/MH.cc, mhist/MHAlphaEnergyTheta.cc,
+     mhist/MHAlphaEnergyTime.cc, mhist/MHEffOnTimeTheta.cc,
+     mhist/MHEffOnTimeTime.cc, mhist/MHEnergyTheta.cc, MHEnergyTime.cc,
+     mhist/MHMcCollectionArea.cc, mhist/MHStarMap.cc, mmain/MMars.cc,
+     mmontecarlo/MMcCollectionAreaCalc.cc
+     - changed mail address
+     - added missing copyright notices
+     - added missing class description
+
+   * mbase/MWriteRootFile.cc, mbase/MWriteAsciiFile.cc:
+     - added AddToBranch call to AddContainer(const char*, const char*)
+
+
+
+ 2002/04/30: Thomas Bretz
+
+   * macros/MagicHillas.C:
+     - made eventloop infinite
+
+   * macros/tar.C:
+     - implemented some sanity checks (existing files)
+
+   * mgui/MCamDisplay.[h,cc]:
+     - changed to use DeepSea palette in root versions newer than 3.01/05
+     - fixed a bug which caused the destructor to do strange thing
+       (the uncloned fGeomCam was deleted)
+     - implemented a more accurate deletion of the objects in the
+       TClonesArrays by using TClonesArray::Delete
+     - Implemented deletion of automatically created TCanvas
+     - Implemented a sanity check in Draw and DrawPhotNum
+
+   * macros/readCT1.C, macros/readMagic.C:
+     - changed to Handling of the gui and keyboard input
+     - implemented the filename as function argument
+
+   * manalysis/MCT1ReadAscii.cc:
+     - Expanded filename to support filnames containing '~'
+
+   * mhist/MH3.h:
+     - removed 'const' to make 0.7 root 3.01/06 compatible
+
+   * mdata/MDataMember.cc, mdata/MDataValue.cc, mdata/MDataChain.cc:
+     - removed a 'redefinition of default argument'
+
+   * mdata/MFDataMember.cc:
+     - fixed a bug in the process function (second switch was never reached)
+
+
+
+ 2002/04/29: Thomas Bretz
+
+   * macros/tar.C:
+     - added
+
+   * Makefile:
+     - changed "make tar" to use macros/tar.C and root
+
+
+
+ 2002/04/29: Wolfgang Wittek
+
+   * mhist/Makefile, mhist/HistLinkDef.h 
+     - MHThetabarTheta and MHThetabarTime were added
+
+   * mhist/MHThetabarTheta.[h,cc], mhist/MHThetabarTime.[h,cc]:
+     - added
+
+   * mhist/MHMcEnergyMigration.[h,cc]:
+     - added
+
+
+
+ 2002/04/27: Oscar Blanch
+
+   * mmc/MMcRunHedaer.cxx, mmc/MMcTrig.cxx, mmc/MMcTrigHeader:
+     - description of variables that have been introduced in the second
+       version of this Containers.
+
+
+
+ 2002/04/26: Thomas Bretz
+
+   * mhist/MHFadcCam.cc:
+     - start numbering of pixels with 1
+
+   * mhist/MHFadcPix.[h,cc]:
+     - overloaded clone to get rid of the histograms in any directory
+     - removed some unnecessary StrDup calls
+     - changed binning (Thanks to Abelardo)
+
+   * mdata/MData.[h,cc]:
+     - documentation added
+     - implemented a new abstract member function: IsValid
+
+   * mdata/MDataChain.cc, mdata/MDataList.cc:
+     - changed logging output
+     - documentation added
+
+   * mdata/MDataList.h, mdata/MDataMember.h, mdata/MDataValue.h:
+     - implemented IsValid
+
+   * mdata/MDataMember.cc:
+     - Don't preprocess if fCall is already available
+     - documentation added
+
+   * mdata/MDataValue.cc:
+     - documentation added
+
+   * mhist/MHMcDifRate.h, mhist/MHMcEfficiency.h, 
+     mhist/MHMcEfficiencyEnergy.h, mhist/MHMcEfficiencyImpact.h, 
+     mhist/MHMcEnergyImpact.h:
+     - corrected class description
+
+   * mbase/MParList.cc:
+     - fixed a bug in CreateObjList
+
+
+
+ 2002/04/25: Thomas Bretz
+
+   * mmontecarlo/MMcCollectionAreaCalc.[h,cc]:
+     - counts now the number of simulated showers
+     - implemented some sanity checks (corsika version, etc)
+
+   * mhist/MMcCollectionArea.[h,cc]:
+     - added a first implementation of a calculation using only triggered
+       events
+
+   * mhist/MH.[h,cc]:
+     - changed the first argument in SetBinning (according to the number
+       of axis) to TH2 or TH3
+
+   * mhist/MH2.cc:
+     - changed the first argument in SetBinning (according to the number
+       of axis) to TH2 or TH3
+
+   * macros/collarea.C:
+     - replaces MReadTree by MReadMarsFile
+
+   * mmc/MMcRunHeader.hxx:
+     - added GetAllEvtsTriggered
+
+
+
+ 2002/04/24: Thomas Bretz
+
+   * mbase/MReadTree.cc:
+     - made use of TBranch::GetClassName root version dependant 
+
+   * manalysis/MCerPhotCalc.[h,cc]:
+     - added a fix (ped.mean - 0.5) for files from camera with version <= 40
+
+   * mmc/MMcRunHeader.hxx:
+     - added some Getter functions
+
+   * mdata/MDataChain.cc:
+     - use rule as a title if no title ios given
+
+   * mhist/MH3.[h,cc]:
+     - added usage of Data-Chains
+     - added a profiling option to the draw functions
+     - use the title (rule) of the data-chain as axis title
+
+   * mhist/Makefile:
+     - added mdata-path
+
+   * mbase/MParContainer.h:
+     - changed some output in GetterFunction
+
+
+
+ 2002/04/24: Wolfgang Wittek
+
+   * Work was done on the calculation of photon fluxes as a function of
+     Theta and as a function of time. The work is still in progress.
+
+   * macros/wowflux.C
+     - the macr0 was added (extended and improved version of flux.C)
+     - the macro steers the calculation of photon fluxes as a function
+       of Theta and time
+     - the macro is not yet complete; testing and developing is going on
+
+   * mhist/MHAlphaEnergyTheta.[h,cc], mhist/MHAlphaEnergyTime.[h,cc],
+     mhist/MHEffOnTimeTheta.[h,cc], mhist/MHEffOnTimeTime.[h,cc],
+     mhist/MHTimeDiffTheta.[h,cc], mhist/MHTimeDiffTime.[h,cc]:
+     - documentation was added 
+     - histogram axes were labeled
+
+   * mhist/MHEffOnTimeTheta.cc:
+     - range in which the fit of the distribution of time differences
+       is to be performed has been calculated
+     - new histograms were added (chi2/NDF, lambda, N0del)
+
+
+
+ 2002/04/23: Thomas Bretz
+
+   * madata/Makefile, mdata/DataIncl.h, mdata/DataLinkDef.h,
+     mdata/MData.[h,cc], mdata/MDataValue.[h,cc], mdata/MDataList.[h,cc],
+     mdata/MDataChain.[h,cc], mdata/MDataMember.[h,cc]:
+     - added
+
+   * mmc/MMcEvt.[hxx,cxx]:
+     - added correct units for fImpact
+
+
+
+ 2002/04/22: Thomas Bretz
+
+   * Makefile:
+     - added a chapter how to compile mars using shared libraries
+
+   * NEWS:
+     - updated
+ 
+   * mfilter/MF.[h,cc]:
+     - added 
+
+   * mfilter/MFDataMember.[h,cc]:
+     - added 
+
+   * mhist/MH3.[h,cc]:
+     - added 
+
+   * mhist/MHHillasExt.[h,cc]:
+     - added 
+     
+   * macros/rootlogon.C:
+     - added make() function
+     - splitted rootlogon()
+     
+   * mbase/MFilterList.cc:
+     - fixed a bug in the constructor
+     - small changes to the print function
+     
+   * mbase/MParContainer.[h,cc]:
+     - Added GetterMethod-Function
+
+   * mbase/MParList.cc:
+     - Added a security check in case no def. constructor of the new class 
+       is available
+     - changed print function
+     
+   * mbase/MReadTree.cc:
+     - changed so that the class type of the branch is used for creation of 
+       a new object instead of its name
+
+   * mbase/MTaskList.[h,cc]:
+     - fixed the check for the Process function. Only base classes
+       of first order have been checked
+       
+   * mfilter/FilterLinkDef.h, mfilter/Makefile:
+     - added MF, MFDataMember
+
+   * mhist/HistLinkDef.h, mhist/MFillH.cc:
+     - added MH3, MHHillasExt
+
+   * mhist/MFillH.cc:
+     - small changes
+
+   * mhist/MH.[h,cc]:
+     - changed name handling in MakeDefCanvas to TString
+
+   * mhist/MHHillas.cc:
+     - exchanged Get*axis()->SetTitle with Set*Title()
+     
+   * mhist/MHHillas.h:
+     - made SetMm2Deg virtual (for MHHillasExt)
+
+   * mhist/MHStarMap.[h,cc]:
+     - changed layout from mm to deg
+
+   * mhist/MHHillasSrc.cc:
+     - fixed a bug which made it unpossible to display fDist in degrees
+
+
+
+ 2002/04/19: Thomas Bretz
+
+   * mbase/MTaskList.cc:
+     - fixed a heavy bug which caused PreProcess to crash (GetListOfBases
+       return a List of TBaseClasses not a List of TClass objects)
+     - added a security check to Process whether we have something to process or not.
+
+   * macros/CT1Hillas.C:
+     - changed to the new Hillas classes
+
+   * macros/readCT1.C:
+     - fixed a bug causing readCT1.C to crash when reading the first event 
+       being a pedestal event
+
+
+
+ 2002/04/17: Thomas Bretz
+
+   * mbase/MParContainer.cc:
+     - case label TMethodCall::kOther changed to default to get rid of
+       some warnings in newer root's (missing case label kString)
+
+   * mbase/MAGIC.h:
+     - changed defintion of Glog so that it now works on Alpha machines, too.
+
+
+
+ 2002/04/16: Thomas Bretz
+
+   * mhist/MHHillas.cc:
+     - Fixed a 'redefinition of default argument' on alpha
+
+
+
+ 2002/04/15: Thomas Bretz
+
+   * mgui/MGeomCam.cc:
+     - Added SetReadyToSave to Constructor
+
+   * mhist/MH.cc:
+     - Added some #ifdef conditionals for a fix in root
+
+   * mfilter/MFAlpha.[h,cc]:
+     - made IsExpressionTrue inline
+
+
+
+ 2002/04/05: Thomas Bretz
+
+   * mmain/MDataCheck.cc:
+     - exchanged order in call to MFillH constructor
+     - made eventloop infinite (only 300 events have been processed)
+
+   * mbase/MEvtLoop.h:
+     - added GetTaskList
+
+   * mbase/MTaskList.[h,cc]:
+     - introduced fTasksProcess which contains only the tasks
+       which overloads the process function so that processing
+       tasks doesn't waste time if a tasks doesn't have the process
+       function
+
+   * mgui/MGeomPix.[h,cc]:
+     - corrected calculation of pixel area
+
+
+
+ 2002/04/04: Thomas Bretz
+
+   * mbase/MLog.cc:
+     - stripped last character (CR) from output redirected to GUI    
+
+
+
+ 2002/03/21: Thomas Bretz
+
+   * mhists/MH.cc:
+     - TAxis::Set resets the axis title so I implemented a workaround
+       in SetBinning so that the axis title survives.
+
+   * mhists/MHEffOnTimeTheta.cc, MHEffOnTimeTime.cc:
+     - replaced Get*axis()->SetTitle() by Set*Title()
+     - corrected the Name in MakeDefCanvas
+
+
+
+ 2002/03/20: Thomas Bretz
+
+   * macros/flux.C:
+     - fixed a small bug (thanks to Wolfgang)
+
+   * mhist/MHHillas.[h,cc]:
+     - added more scaling options
+     - added setting for scaling factor
+
+   * mhist/MHStarMap.cc:
+     - changed sign of t (due to a mail of Wolfgang)
+
+   * mhist/MHTimeDiff*.cc:
+     - removed an implicit down-cast (TH1D --> TH1)
+
+
+
+ 2002/03/15: Oscar Blanch
+
+   * mmc/McLinkDef.h
+     - Automatic scheme evolution for all MC format classes.
+       It has been checked that it keeps compatibility with old files.
+
+   * mmc/MTriggerDefine.h
+     - Enlarge number of trigger pixels.
+
+   * mmc/MTrigger.[cxx,hxx]
+     - Trigger zone has been enlarged. Now information about status
+       of the pixel is saved for all Camera pixels.
+     - Old files can still be read but becareful when one looks at the
+       data member fPixelsFirst which is an array of different size for
+       the new and old files.
+     - ClassDef version upgraded to 2.
+
+   * mmc/MTriggerHedaer.[cxx,hxx]
+     - Member data fElecNoiseTrig, which has information about the 
+       electronic noise in the trigger chain, has been introduced.
+     - Trigger zone has been enlarged. Now information about status
+       of the pixel is saved for all Camera pixels.
+     - Old files can still be read but becareful when one looks at the
+       data member fThreshold which is an array of diferent size for
+       the new and old files.
+     - ClassDef version upgraded to 2.	
+
+
+
+ 2002/03/13: Oscar Blanch
+
+   * mmc/MMcRunHeader.[cxx,hxx]
+     -  Several new variable members have been added
+     -  Version number updated to 2
+
+
+
+ 2002/03/12: Thomas Bretz
+
+   * mmontecarlo/MMcTimeGenerate.cc (thanks to Wolfgang):
+     - removed wrong comment for Process
+     - changed Int_t to UInt_t (more readable)
+     - replaced unit: ms -> 0.1ms
+
+
+
+ 2002/03/08: Thomas Bretz
+
+   * manalysis/MHillasSrc.[h,cc]:
+     - added fHeadTail
+     - changed version number to 2.
+
+
+
+ 2002/03/07: Thomas Bretz
+
+   * mbase/MParContainer.[h,cc], MWriteAsciiFile.[h,cc]:
+     - added a scale value which can be used in case you are writing
+       single data mambers
+
+
+
+ 2002/03/04: Thomas Bretz
+
+   * mbase/MParContainer.cc:
+     - changed AsciiWrite so that only base classes with a version
+       id > 0 are written (important for MParContainer)
+
+
+
+ 2002/03/01: Thomas Bretz
+
+   * mhist/MHMcEfficiencyEnergy.[h,cc], mhist/MHMcEfficiencyImpact.[h,cc],
+     mhist/MHMcDifRate.[h,cc], mhist/MHMcIntRate.[h,cc]:
+     - added
+
+   * mhist/Makefile, mhist/HistLinkDef.h:
+     - added MHMcEfficiencyEnergy and MHMcEfficiencyImpact
+     - added MHMcDifRate and MHMcIntRate
+
+   * mhist/MHMcCollectionArea.[h,cc]:
+     - changed instantiation of collection area histogram
+     - added settings for the binning
+     - replaced division by root function
+     - added Calc-functions
+     - added GetHist
+
+   * mhist/MHMcEfficiency.[h,cc]:
+     - changed pointers in Calc functions to references
+
+
+
+
+
+ 2002/02/28: Thomas Bretz
+
+   * mhist/MHMcEnergyImpact.[h,cc], mhist/MHMcEfficiency.[h,cc]:
+     - added
+     
+   * mhist/Makefile, mhist/HistLinkDef.h:
+     - added MHMcEnergyImpact and MHMcEfficiency
+
+   * mhist/*.cc:
+     - repaced some *&-> casts by &.
+
+   * mhist/MHMcCollectionArea.[h,cc]:
+     - changed to be able to use new MHMcEfficiency.
+
+
+
+ 2002/02/21: Abelardo Moralejo
+
+   * manalysis/MHillasExt.cc :
+     - added #include <math.h>  (else, fabs not recognized by OSF)
+
+
+
+ 2002/02/21: Thomas Bretz
+ 
+   * manalysis/MHillas.[h,cc]:
+     - changed fMeanx and fMeany to fMeanX and fMeanY to match the names
+       of the getter functions, needed by TDataMember::GetterMethod
+     - commented out WriteAscii (replaced by more general in MParContainer
+       and MWriteAsciiFile)
+
+    * manalysis/MHillasSrc.[h,cc], mmc/MMcEvt.[hxx, cxx]:
+      - commented out WriteAscii (replaced by more general in MParContainer
+        and MWriteAsciiFile)
+
+    * manalysis/MHillasExt.[h,cc]:
+      - added necessary Getter Methods
+     
+    * mbase/MFilterList.cc:
+      - removed a nonsens comment
+    
+    * mbase/MGList.cc:
+      - relay on the bugfix for DynamicCast
+    
+    * mbase/MParContainer.[h,cc]:
+      - implemented WriteDataMember to have a more general interface
+        for readable output.
+      - changed ofstream to a more general ostream
+  
+    * mbase/MWriteAsciiFile.[cc,h]:
+      - generalized ascii writer to be able to write single data members
+
+
+
+ 2002/02/13: Thomas Bretz
+
+   * Makefile:
+     - made 'make dox' dependant on existance of shared object
+
+
+     
+ 2002/02/13: Thomas Bretz
+
+   * macros/MagicHillas.C, mhist/MHHillas.[h,cc], mhist/MHHillasSrc.[h,cc]:
+     - implemented variable binning (MBinning)
+     - implemented conversion to degrees (thanks to rudy)
+     
+   * mgui/MGeomCam.[h,cc], mgui/MGeomCamCT1.cc, mgui/MGeomCamMagic.cc:
+     - implemented fMm2Deg and fCamDist
+
+
+
+ 2002/01/23: Thomas Bretz
+
+   * macros/flux.C:
+     - fixed some bugs
+     - uncommented all drawing
+     
+   * mhist/MBinning.h:
+     - changed SetEdges(TArrayD)
+     
+   * mhist/MH.cc:
+     - SetBinning(..., TAxis*,...) didn't work. Corrected.
+     
+   * mhist/MHAlphaEnergyTheta.cc, mhist/MHAlphaEnergyTime.cc,
+     mhist/MHEffOnTimeTheta.cc, mhist/MHEffOnTimeTime.cc,
+     mhist/MHTimeDiffTheta.cc, mhist/MHTimeDiffTime.cc:
+     - changed wrong titles, names, etc.
+     - changed way of drawing projections
+     - fixed usage of MH::SetBinning(TH1*)
+
+
+     
+ 2002/01/22: Thomas Bretz
+ 
+   * mhist/MHHillasSrc.[h,cc], mhist/MHFadcCam.[h,cc]:
+     - changed return type of Fill to Bool_t
+   
+   * mfilter/MFAlpha.[h,cc]:
+     - added
+
+   * mfilter/MFill.[h,cc]:
+     - implemented a new calling style which allows you to let MFillH
+       create the necessary histogram objects
+
+   * mmain/MAnalysis.cc, macros/MagicHillas.C:
+     - changed to new stylish MHillas parameter containers
+
+   * meventdisp/MGEvtDisplay.cc, mgui/MCamDisplay.cc,
+     mmain/MDataCheck.[h,cc]:
+     - fixed a warning in red hat linux
+  
+   * mfilter/FilterLinkDef.h, mfilter/Makefile:
+     - added MFAlpha
+  
+   * mhist/MHHillas.[h,cc], mhist/MHHillasSrc.[h,cc]:
+     - added SetupFill and usage of MBinning objects
+
+   * manalysis/MEnergyEst.[h,cc], manalysis/MEnergyEstimate.[h,cc],
+     mhist/MHTimeDiffTime.[h,cc], mhist/MHEnergyTheta.[h,cc],
+     mhist/MHEnergyTime.[h,cc], mhist/MHAlphaEnergyTheta.[h,cc],
+     mhist/MHAlphaEnergyTime.[h,cc], mhist/MHTimeDiffTheta.[h,cc],
+     mmontecarlo/MMcTimeGenerate.[h,cc]:
+     - added
+
+   * manalysis/Makefile:
+     - added MEnergyEst.cc
+     - added MEnergyEstimate.cc
+   
+   * mbase/MFilter.[h,cc], mfilter/MF*.[h,cc]:
+     - added name and title to constructor
+
+   * macros/flux.C:
+     - added
+
+
+
+ 2002/01/21: Thomas Bretz
+ 
+   * mbase/MReadMarsFile.cc, mbase/MReadTree.[h,cc]:
+     - implemented GetFileName
+
+   * mmc/MMcEvt.[hxx,cxx]
+     - implemented WriteAscii
+   
+   * mgui/MGeomPix.h:
+     - implemented first version of GetA
+
+   * mhist/MBinning.h:
+     - small changes to formulas
+     
+   * mhist/MH.[h,cc]:
+     - implemented SetBinnign functions
+
+   * macros/readMagic.C:
+     - removed MPedestalCam
+
+
+
+ 2002/01/19: Thomas Bretz
+ 
+   * mbase/MParContainer.cc:
+     - generalized virtual function AsciiWrite
+   
+   * changed to fit new MHillas inhertance model:
+     - manalysis/MHillas.[h,cc]
+     - manalysis/MHillasCalc.[h,cc]
+     - mhist/MHHillas.[h,cc]
+     - mhist/MHStarMap.[h,cc]
+
+   * added to fit new MHillas inhertance model:
+     - manalysis/MSrcPosCam.[h,cc]
+     - manalysis/MHillasSrc.[h,cc]
+     - manalysis/MHillasSrcCalc.[h,cc]
+     - manalysis/MHillasExt.[h,cc]
+     - mhist/MHHillasSrc.[h,cc]
+
+   * manalysis/MCerPhotEvt.[cc,h]:
+     - introduced weighting with pixel size in GetNumPhotonsMin
+     - introduced weighting with pixel size in GetNumPhotonsMax
+
+   * mgui/MCamDisplay.cc:
+     - weight the displayed color with the pixel size
+
+
+
+ 2002/01/18: Thomas Bretz
+ 
+   * mhist/MBinning.[h,cc]:
+     - added (not yet in Makefile)
+   
+   * mbase/MWriteAsciiFile.cc:
+     - fixed a bug: replaced GetSize by GetEntries
+     
+   * mbase/MReadTree.cc:
+     - changed EnableBranch to accept "Master.Sub" also
+
+
+
+ 2002/01/16: Thomas Bretz
+ 
+   * mars.cc:
+     - changed version number to 0.7
+
+   * NEWS:
+     - changed current version to 0.7
+
+   * manalysis/MMcPedestalNSBAdd.cc:
+     - small changes to output
+ 
+   * mbase/MParList.[h,cc]:
+     - added FindObject with class type argument
+   
+   * mbase/MWriteAsciiFile.cc
+     - replaced call to InheritsFrom by new FindObject
+ 
+ 
+ 
+ 2002/01/15: Thomas Bretz
+
+   * manalysis/MBlindPixelCalc.[h,cc]:
+     - added more comments
+     - removed a debug statement
+    
+   * manalysis/MBlindPixels.[h,cc]:
+     - added more comments
+    
+   * manalysis/MCerPhotCalc.cc:
+     - changed the warning output
+    
+   * manalysis/MMcPedestalCopy.h:
+     - added comments
+    
+   * manalysis/MMcPedestalNSBAdd.[h,cc]:
+     - added comments
+     - changed call to AddedToBranchList
+    
+   * mbase/MWriteAsciiFile.cc:
+     - added comments
+    
+   * mmc/MMcRunHeader.[hxx,cxx]:
+     - made getter const
+
+   * meventdisp/MGCamDisplay.cc:
+     - updated to use MBlindPixelCalc
+
+   * mbase/MEvtLoop.cc:
+     - replaced wrong "MTasklist" by "MTaskList"
+
+
+
+ 2002/01/14: Thomas Bretz
+ 
+   * manalysis/MMcPedestalCopy.cc, manalysis/MMcPedestalNSBAdd.cc:
+     - added comments
+
+   * mbase/MReadMarsFile.cc:
+     - changed output when switching to new file
+     
+   * meventdisp/MGFadcDisp.cc:
+     - made char array in constructor const
+     - changed char-array to TString
+
+   * mmain/MBrowser.[h,cc]:
+     - changed char-arrays to TString
+
+   * mmain/MDataCheck.[h,cc]:
+     - made char array in constructor const
+     
+   * Makefile.conf.linux, Makefile.conf.linux-gnu:
+     - changed to O5
+     
+   * mbase/MEvtLoop.cc:
+     - check for inheritance from MTaskList
+
+   * manalysis/MPedestalCopy.cc, manalysis/MPedestalNSBAdd.cc:
+     - small changes
+   
+   * mbase/MWriteAsciiFile.[h,cc]:
+     - changed to be able to write more than one container in a line
+
+
+
+ 2002/01/11: Oscar Blanch Bigas
+
+   * mmain/MAnalysis.cc:
+     - added MBlindPixelCalc step.
+
+   * macros/trigrate.C:
+     - the list of MHMcRate is created using from and to instead of
+       only dimension. Otherwise the case of a single trigger option is
+       not well treated.
+
+   * mhist/MHMcRate.[h,cc]:
+     - added funtion members SetFlux and SetIncidentRate and small
+       modification in CalcRate member function
+
+   * mmontecarlo/MMcTriggerRateCalc.cc:
+     - now this task sets the parameters to know the incident particle
+       flux using MHMcRate::SetFlux. The value are decided by the task
+       itself depending on the fPartId.
+
+   * manalysis/MBlindPixelCalc.cc:
+     - rename MMcRunHeader:GetStarFieldDe to MMcRunHeader:GetStarFieldDec. 
+
+   * mmc/MMcRunHeader.[hxx, cxx]:
+     - rename MMcRunHeader:GetStarFieldDe to MMcRunHeader:GetStarFieldDec. 
+
+
+
+ 2002/01/10: Oscar Blanch Bigas
+
+   * mbase/Makefile:
+     - added -I../MRawFormat in the included directories for compile
+       and link. It was needed to use this Makefile to compile the
+       files inside the drectory while compiling Monte Carlo programs.
+
+   * mraw/Makefile:
+     - added -I../MBase in the included directories for compile
+       and link. It was needed to use this Makefile to compile the
+       files inside the drectory while compiling Monte Carlo programs.
+
+   * mbase/Makefile:
+     - added -I../MBase- in the included directories for compile
+       and link. It was needed to use this Makefile to compile the
+       files inside the drectory while compiling Monte Carlo programs.
+
+   * mbase/MReadTree.cc:
+     - changed #include "../mraw/MRawEvtData.h" by #include
+       "MRawEvtData.h" to remove dependencies on the directory tree naming.
+
+
+
+ 2002/01/09: Oscar Blanch Bigas
+   
+   * manalysis/MPedestalCam.[h,cc]:
+     - added CheckBounds function to check that program does not try to
+       access pedestal outside the camera size.
+
+   * manalysis/MCerPhotCalc.h:
+     - Member data const MPedestalCam *fPedestals -> MPedestalCam
+     *fPedestals.
+
+   * manalysis/MCerPhotCalc.cc:
+     - Sanity check to avoid searching to pedestals outside the camera
+       size has been added.
+
+   * mmc/MMcRunHeader.[h,cxx]:
+     - added functions GetStarField[De,Ra].
+
+   * manalysis/MBlindPixels.[h,cc]:
+     - new containet that has a list of pixels that should not be used
+       in the analysis for any reason (corrupted, star in them, ...).
+
+   * manalysis/MBlindPixelCalc.[h,cc]:
+     - It is a task used to set up the list of blind pixels. Currently
+       it recognises the CrabNebula starfield and then switch off the
+       Theta Taury pixels. Blind pixels can be also introduced through
+       the macro or analysis program.
+
+   * manalysis/Makefile:
+     - added MBlindPixels and MBlinPixelCalc.
+
+   * manalysis/AnalysisLinkDef.h:
+     - added MBlindPixels and MBlinPixelCalc.
+
+   * macros/MagicHillas.C:
+     - added MBlindPixelCalc to avoid bias results due to Star Field
+       NSB.
+
+   * macros/readMagic.C:
+     - added MBlindPixelCalc to avoid bias results due to Star Field NSB while
+       computing the Hillas parameters.
+
+
+
+ 2001/12/19: Thomas Bretz
+  
+   * mbase/MEvtLoop.cc:
+     - added #ifdef directive to make it work on older root also
+      
+   * mbase/MReadTree.cc:
+     - added #ifdef directive to get rid of the memory leak in prior
+       root 3.02/* versions
+	    
+   * macros/MagicHillas.C, macros/readMagic.C, meventdisp/MGCamDisplay.cc,
+     mmain/MAnalysis.cc:
+     - changes MMcPedestalNSB to MMcPedestalNSBAdd
+     
+   * manalysis/MMcPedestalCopy.[h,cc], manalysis/MMcPedestalNSBAdd.[h,cc]:
+     - reorganized ReInit, PreProcess.
+     - moved some code from ReInit to PreProcess to make the code
+       simpler. At the moment we don't intend to change the 
+       objects in the parlist while runtime.
+
+   * manalysis/MMcPedestalNSB.[h,cc]:
+     - removed
+
+   * mbase/MReadMarsFile.cc:
+     - read the first run header twice. To make it available in the
+       PreProcess of all tasks
+   
+   * mbase/MTaskList.cc:
+     - fixed a bug in the ReInit function. The ReInits where calles with 
+       a NULL-pointer
+
+
+
+ 2001/12/18: Oscar Blanch
+								 
+   * manalysis/Makefile:
+     - Removed MMcPedestalNSB from compilation and added
+       MMcPedestalNSBAdd.
+
+   * manalysis/AnalysisLinkDefine.h:
+     - Removed MMcPedestalNSB from class list and added
+       MMcPedestalNSBAdd.
+
+   * manalysis/MMcPedestalCopy.[h,cc]
+     - added ReInit function.
+     - move all actions needed to redo for each run from PreProcess
+       to ReInit
+     - fix bug of Pedestal and Pedestal fluctuaions correspondence.
+
+   * manalysis/MMcPedestalNSBAdd.[h,cc]
+     - new name for old MMcPedestalNSB.[h,cc]
+     - added ReInit function.
+     - move all actions needed to redo for each run from PreProcess
+       to ReInit
+     - information about pixel size is used from MGeomCam.
+
+   * manalysis/MCerPhotCalc.[h,cc]
+     - remove fNumLoGainFadcSlices and fNumHiGainFadcSlices members
+     - fix bug of Pedestal and Pedestal fluctuaions correspondence.
+
+
+ 2001/12/18: Thomas Bretz
+ 
+   * manalysis/MMcPedestalCopy.cc:
+     - changed output
+     
+   * manalysis/MMcPedestalNSB.cc:
+     - changed output
+     - simplified initialization in PreProcess
+     
+   * mbase/MAGIC.h:
+     - added kSKIP
+     
+   * mbase/MParList.cc:
+     - added a check for the correct inheritance in FindCreateObj
+   
+   * mbase/MTask.cc:
+     - added support for kSKIP in PreProcess
+
+   * mbase/MTaskList.[h,cc]
+     - added support for kSKIP in PreProcess
+     - added Remove function (private)
+
+
+
+ 2001/12/17: Thomas Bretz
+ 
+   * .rootrc:
+     - added Root.Html.DescriptionStyle
+     - added Root.Html.SearchEngine
+     
+   * macros/dohtml.C:
+     - changed to use THtml (root >= 3.02/06 only)
+     
+   * manalysis/Makefile:
+     - changed order to get rid of some wranings
+   
+   * mbase/BaseLinkDef.h:
+     - removed MHtml
+     
+   * mbase/MEvtLoop.cc:
+     - exchanged gSystem->ProcessEvents() by gClient->ProcessEventsFor()
+       to make gui update faster
+       
+   * mbase/MGList.cc:
+     - added a missing sanity check (workaround for a root bug)
+     
+   * mbase/MReadTree.cc:
+     - uncomment EnableBranchCoosing for AutoEnablingScheme
+       (don't know why there was a comment which made things realy slow)
+     - changed the auto enabling scheme, so that a branch isn't enabled
+       more than once. This doesn't hurt, but the output may confuse the
+       users.
+       
+    * mbase/MTask.cc:
+      - added a simple not really necessary check whether the branch is
+        already in the list
+        
+    * mbase/MWriteRootFile.cc:
+      - changed kFillTree to a local const
+      
+    * mbase/Makefile:
+      - removed MHtml.cc
+    
+    * mfilter/MFTriggerLvl1.cc:
+      - changed AddBranchToList to use the correct container name
+
+
+
+ 2001/12/14: Thomas Bretz
+ 
+   * mbase/MReadMarsFile.[h,cc], mbase/MReadFild.[h,cc]:
+     - corrected handling of ReInit/Notify (at the moment I assume 
+       one run per file)
+     - made sure, that we don't get memory leaks when using MReadTree 
+       more than once because the pointer to the pointer isn't deleted.
+     - added a small class MChain which enhances TChain by a function to
+       reset fTree. This is used to control when notification are
+       happening
+
+   * mbase/MTask.cc:
+     - reset the number of executions before the preprocessing
+
+
+
+ 2001/12/11: Thomas Bretz
+
+   * mbase/MGGroupFrame.cc:
+     - removed default arguments from source file
+
+   * mbase/MGList.cc:
+     - changed cast in IsExisting to ?:
+
+   * NEWS:
+     - changed
+
+   * manalysis/MCerPhotCalc.cc, mfilter/MTriggerLvl1.cc,
+     mmontecarlo/MMcCollectionAreaCalc.cc,
+     mmontacarlo/MMcThresholdCalc.cc,
+     MMcTriggerRateCalc.cc:
+     - added Masterbranch name to AddToBranchList
+
+   * manalysis/MMcPedestalCopy.cc:
+     - added Masterbranch name to AddToBranchList
+     - fixed a bug in the branch name
+
+   * mbase/MGList.[h,cc]:
+     - added a better output if a picture wasn't found
+
+   * mbase/MReadTree.[h,cc]:
+     - added support for branches with master branch names to auto scheme
+       (first the complete branch name is tried and if this isn't found
+        only the subbranch name is used to enable the branch)
+
+   * mbase/MWriteRootFile.cc:
+     - appended a '.' to all newly create branches
+
+   * mmain/MBrowser.cc, mmain/MMars.cc:
+     - add the gui elements only if the corresponding picture was found
+
+   * mmain/MMars.[h,cc]:
+     - removed fPic1
+     - removed fPic2
+     - changed TList to MGList
+
+   * mraw/MRawFileWrite.cc:
+     - added a '.' to all branch names
+
+   * mbase/MTask.[h,cc]:
+     - added Prototype for ReInit-function
+
+   * mbase/MTaskList.[h,cc]:
+     - implemented ReInit for a task list
+
+   * mhist/MHFadcCam.h:
+     - added '->' to fArray
+
+
+
+ 2001/12/10: Thomas Bretz
+
+   * mmc/*.hxx:
+     - Changed MPARCONTAINER_H to MARS_MParContainer
+
+   * meventdisp/MGCamDisplay.cc:
+     - added MMcPedestalCopy to task list
+     - added MMcPedestalNSB  to task list
+
+   * mmain/MAnalysis.cc:
+     - added MMcPedestalCopy to task list
+     - added MMcPedestalNSB  to task list
+     - changed reader from MReadTree to MReadMarsFile
+
+   * meventdisp/MGEvtDisplay.cc:
+     - changed reader from MReadTree to MReadMarsFile
+
+   * macros/MagicHillas.C, macros/readMagic.C:
+     - removed unnecessary MReadTree
+
+
+
+ 2001/11/28: Oscar Blanch Bigas
+
+   * mbase/MReadMarsFile.cc:
+     - Added process of fRun = new MReadTree("RunHeaders", fname),
+       needed to read RunHeaders tree information.
+
+   * manalysis/MCerPhotCalc.h:
+     - Added fNumLoGainFadcSlices and fNumHiGainFadcSlices member
+       variables because they are needed for Pedestal substraction.
+
+   * manalysis/MCerPhotCalc.h:
+     - Change in the methode to substract the pedestal. The new
+       methode is valid either for MC data and real data but only for
+       the current integration (GetSumHiGainSamples()).
+
+   * macros/readMagic.C:
+     - Added several tasks in the task list:
+	     MReadMarsFile to read  RunHeaders Tree
+	     MPedestalCopy and MPedestalNSB to treat correctly pedestals.
+
+   * macros/MagicHillas.C:
+     - Added several tasks in the task list:
+	     MReadMarsFile to read  RunHeaders Tree
+	     MPedestalCopy and MPedestalNSB to treat correctly pedestals.
+
+   * mmc/MMcRunHeader.hxx:
+     - Added GetNumPheFromDNSB().
+
+   * mmc/MMcFadcHeader.hxx:
+     - Added GetAmplitud().
+
+   * manalysis/MMcPedestalNSB.h / .cc:
+     - New class which adds to the pedestal rms the contribution from
+      the diffuse NSB.
+
+   * manalysis/Makefile:
+     - New class MMcPedestalNSB added.
+
+   * manalysis/AnalysisLinkDefine.
+     - New class MMcPedestalNSB added.
+
+
+
+ 2001/11/16: Thomas Bretz
+
+   * mhist/MHMcCollectionArea.cc:
+     - set the ReadyToSave bit in CalcEfficiency.
+
+   * mmontecarlo/MMcThresholdCalc.cc:
+     - set the ReadyToSave bit after the calculation has been finished.
+
+   * mhist/MHMcRate.cc:
+     - set the ReadyToSave bit in CalcRate
+
+
+
+ 2001/11/16: Thomas Bretz
+
+   * mbase/MEvtLoop.cc:
+     - removed clock.Print()
+
+   * mbase/MGList.[cc,h]:
+     - added support for TGPictures
+
+   * mbase/MReadTree.[h,cc]:
+     - set ReadyToSave-bit only if reading was successfull
+     - made SetReadyToSave private
+
+   * mbase/MTaskList.cc:
+     - corrected a small bug in the output
+
+   * mbase/MWriteRootFile.cc:
+     - added a workaround in Print (don't know why it fails for me)
+     - removed fTrees.SetOwner()
+
+   * mbase/MTask.cc:
+     - removed include of TOrdCollection, TMethod
+     - some changes to the output
+
+   * mbase/MParContainer.h:
+     - removed old comments
+
+   * mmain/MAnalysis.cc, mmain/MCameraDisplay.cc, mmain/MDataCheck.cc,
+     mmain/MEvtDisp.cc, mmain/MMonteCarlo.cc:
+     - changed Widget IDs to root style enums
+     - moved enumerations in the range below 0x100
+
+   * mmain/MBrowser.[h,cc]:
+     - removed some of the member variables, accessed via MGList now
+     - changed TList to MGList
+     - added a file-filter combo-box
+
+   * mars.cc:
+     - changed output
+
+
+
+ 2001/11/15: Thomas Bretz
+
+   * mbase/MArray.cc, mbase/MArrayB.cc,mbase/MArrayS.cc,
+     mbase/MClone.cc, mbase/MEvtLoop.cc, mbase/MFilter.cc,
+     mbase/MFilterList.cc, mbase/MGGroupFrame.cc, mbase/MGList.cc,
+     mbase/MGTask.cc, mbase/MInputStreamID.cc, mbase/MLog.cc,
+     mbase/MLogManip.cc, mbase/MParContainer.cc, mbase/MParList.cc,
+     mbase/MPrint.cc, mbase/MReadMarsFile.cc, mbase/MReadTree.cc,
+     mbase/MTime.cc, mbase/MWriteAsciiFile.cc, mbase/MWriteFile.cc,
+     mbase/MWriteRootFile.cc, manalysis/MCT1ReadAscii.cc,
+     manalysis/MCerPhotCalc.cc, manalysis/MHillas.cc,
+     manalysis/MHillasCalc.cc, manalysis/MMcPedestalCopy.cc,
+     manalysis/MPedCalcPedRun.cc, manalysis/MPedestalCam.cc,
+     manalysis/MPedestalPix.cc, manalysis/MCerPhotEvt.cc,
+     manalysis/MCerPhotPix.cc, manalysis/MImgCleanStd.cc,
+     manalysis/MImgCleanStd.cc, mdatacheck/MDumlEvtHeader.cc,
+     mdatacheck/MGDisplayAdc.cc, meventdisp/MGCamDisplay.cc,
+     meventdisp/MGEvtDisplay.cc, meventdisp/MGFadcDisp.cc,
+     mfilter/MFTriggerLvl1.cc, mgui/MGeomCam.cc, mgui/MGeomCamMagic.cc,
+     mgui/MGeomCamCT1.cc, mgui/MgeomPix.cc, mgui/Mhexagon.cc,
+     hist/MFillH.cc, mhist/MH.cc, mhist/MHFadcCam.cc, mhist/MHFadcPix.cc,
+     hist/MHHillas.cc, mhist/MHMcCollectionArea.cc, mhist/MHMcEnergy.cc,
+     mhist/MHMcRate.cc, mhist/MHStarMap.cc, mmain/MAnalysis.cc,
+     mmain/MBrowser.cc, mmain/MCameraDisplay.cc, mmain/MDataCheck.cc,
+     mmain/MEvtDisp.cc, mmain/MMars.cc, mmain/MMonteCarlo.cc,
+     mmontcarlo/MMcCollectionAreaCalc.cc, mmontecarlo/MMcThresholdCalc.cc,
+     mmontecarlo/MMcTriggerRateCalc.cc, mraw/MrawCrateArray.cc,
+     mraw/MRawCrateData.cc, mraw/MRawEvtData.cc, mraw/MRawEvtHeader.cc
+     mraw/MRawEvtPixelIter.cc, mraw/MRawEvtFileRead.cc, 
+     mraw/MRawEvtFileWrite.cc, mraw/MRawEvtRunHeader.cc
+     - changed mailing address of author according to THtml of root 3.02
+
+   * mbase/MClone.cc, mbase/MEvtLoop.cc, mbase/MFilterList.cc,
+     mbase/MGTask.cc, mbase/MParContainer.cc, mbase/MParList.cc,
+     mbase/MPrint.cc, mbase/MReadMarsFile.cc, mbase/MReadTree.cc,
+     mbase/MWriteAsciiFile.cc, mbase/MWriteFile.cc,
+     mbase/MWriteRootFile.cc, manalysis/MCerPhotEvt.cc, 
+     manalysis/MCerPhotPix.cc, manalysis/MImgCleanStd.cc,
+     mgui/MGeomCam.cc, mgui/MGeomCamMagic.cc, mgui/MGeomCamCT1.cc, 
+     mgui/MgeomPix.cc, mgui/Mhexagon.cc, hist/MFillH.cc, mhist/MHMcEnergy.cc,
+     mhist/MHMcRate.cc, mmontcarlo/MMcCollectionAreaCalc.cc,
+     mmontecarlo/MMcThresholdCalc.cc, mmontecarlo/MMcTriggerRateCalc.cc
+     mraw/MRawCrateData.cc, mraw/MRawEvtData.cc, mraw/MRawEvtHeader.cc
+     mraw/MRawEvtPixelIter.cc, mraw/MRawEvtFileRead.cc, 
+     mraw/MRawEvtFileWrite.cc, mraw/MRawEvtRunHeader.cc
+     - changed output to new style logging (verbosity level introduced)
+
+   * mbase/MGTask.h:
+     - added default to CreateGui
+
+   * mbase/MLog.cc
+     - chnaged comparision between output and debug level from >= to >
+
+   * mbase/MLogManip.h:
+     - added defintions for debug levels
+
+   * mbase/MReadTree.[h,cc]:
+      - added support for filters
+      - SetReadyToSave added
+      - Print added
+
+   * mbase/MTaskList.[h,cc], MTask.[h,cc]:
+     - changed TOrCollection to TList, because TList can be stored in a 
+       root file.
+
+   * mbase/MTask.[h,cc]:
+     - added GetFilter function (used in MReadTree)
+
+   * manalysis/MImgCleanStd.cc:
+     - same changed to the GUI layout
+     - added Print member function
+
+   * meventdisp/MGCamDisplay.cc:
+     - added group frame around some gui elements
+
+   * mfilter/MFTriggerLvl1.cc:
+     - fixed missing Init call
+     - added missing AddToBranchList call
+
+   * mars.cc:
+     - added command line option to set the verbosity level
+
+   * merpp.cc:
+     - added setup for highest verbosity level
+
+
+
+ 2001/11/14: Thomas Bretz
+
+   * macros/dohtml.C:
+     - added missing path to mfilter
+   
+   * manalysis/MHillas.cc:
+     - changed the degree symbol back to 'deg', it seems that the code
+       for it isn't common
+   
+   * mhist/MH.cc:
+     - added comment for MakeDefCanvas
+
+   * mhist/MHFadcCam.[h,cc]:
+     - removed old comments (SaveHist)
+
+   * mhist/MHHillas.cc:
+     - changed the Name of fAlpha back. Symbols are nonsens in the name.
+     
+   * mbase/MGList.[h,cc], mbase/MGTask.[h,cc], mbase/MGGroupFrame.[h,cc]:
+     - added
+
+   * Makefile.conf.linux, Makefile.conf.linux-gnu:
+     - changed to O3
+     - added -fnonnull-objects
+     - added -Woverloaded-virtual
+
+   * macros/readCT1.C, macros/readMagic.C:
+     - changed to use MClone
+
+   * manalysis/MImgCleanStd.[h,cc]:
+     - derived from TGTask
+     - added CreateGuiElements 
+     - added ProcessMessage
+
+   * mbase/BaseLinkDef.h, mbase/Makefile:
+     - added MGTask
+     - added MGList
+     - added MGGroupFrame
+
+   * mbase/MInputStreamID.cc:
+     - rmoved old comment
+
+   * mbase/MParContainer.[h,cc]:
+     - changed output
+     - made Hash const
+     - added GetDiscriptor
+
+   * mbase/MParList.[h,cc]:
+     - made FindObject const correct (see TObject)
+
+   * mbase/MTask.[h,cc]:
+     - changed output to use GetDescriptor
+     - made Call* functions virtual (used in TGTask)
+
+   * mbase/MTaskList.[h,cc]:
+     - made FindObject const correct (see TObject)
+     - changed output to use GetDescriptor
+
+   * mbase/MTime.cc:
+     - code reformatting
+
+   * mbase/MWriteRootFile.cc:
+     - small changes in output
+
+   * mgui/MHexagon.cc:
+     - changed output according to TEllipse and similar
+     - made ls const
+
+   * mhist/MFillH.cc:
+     - changed output to use GetDescriptor
+
+   * mmain/MAnalysis.[h,cc]:
+     - changed to use new GUI of MImgCleanStd
+
+   * mraw/MRawEvtData.cc:
+     - small changes to output
+     - better sanity check for non existing fRunHeader
+
+
+
+ 2001/11/09: Thomas Bretz
+
+   * mars.cc, merp.cc, macros/rootlogon.C:
+     - added MArray::Class()->IgnoreTObjectStreamer();
+
+
+
+ 2001/11/08: Thomas Bretz
+
+   * meventdisp/MGCamDisplay.cc:
+     - changed enums to root style
+     - get rid of the problem of button deletion by adding the buttons 
+       as first entries to the list
+
+   * mmain/MMonteCarlo.cc:
+     - changed enums to root style
+     - get rid of the problem of button deletion by adding the buttons 
+       as first entries to the list
+
+   * manalysis/MCerPhotCalc.cc, manalysis/MPedCalcPedRun.cc,
+     mhist/MHFadcCam.cc:
+     - removed 'Fadc' from function names
+
+   * manalysis/MCerPhotEvt.[h,cc]:
+     - made AddPixel inline
+   
+   * manalysis/MMcPedestalCopy.cc:
+     - added output
+
+   * manalysis/MPedestalCam.cc:
+     - removed FIXME
+
+   * Makefile's:
+     - some reordering
+     - changed to the output
+
+   * mbase/MReadTree.cc:
+     - removed setting of AutoDel-flag (this was not intended and doesn't
+       work for a TChain, yet)
+
+   * meventdisp/MGCamDisplay.cc, meventdisp/MGFadcDisp.cc:
+     - moved SetWMSizeHints to base class
+
+   * meventdisp/MGEvtDisplay.cc:
+     - added a random move and the SetWMSizeHints
+
+   * mhist/MHHillas.cc:
+     - replaced some text by Latex-formulas
+
+   * mmain/MBrowser.cc:
+     - added a menu entry for opening a TBrowser
+     - added a random move
+
+   * mmain/MMars.[h,cc]:
+     - changed enums to root style
+     - moved size specification from header to source
+     - changed SetWMSizeHints call
+
+   * mraw/MrawEvtPixelIter.[h,cc]:
+     - added fNum[Hi,Lo]GainSamples to make GetSum* faster
+     - removed 'Fadc' from function names
+
+
+
+ 2001/11/07: Thomas Bretz
+
+   * Makefile:
+     - changed order in 'mrproper'
+
+   * manalysis/MCT1ReadAscii.cc, manalysis/MCerPhotCalc.cc:
+     - added InitSize
+
+   * manalysis/MCerPhotEvt.[h,cc]:
+     - introduces InitSize to speed up things
+     - changed []-operator to an unchecked access
+
+   * manalysis/MPedestalCam.h:
+     - changed ExpandCreateFast to ExpandCreate (due to lack of good dox)
+     - changed []-operator to an unchecked access
+
+   * mbase/MEvtLoop.cc:
+     - changed 'total' to 'real' time.
+
+   * mgui/MGeomCam.[h,cc]:
+     - moved []-operator code back to class definition, due to runtime speed
+     - changed []-operator to an unchecked access
+
+   * mhist/MHHillas.cc:
+     - changed 'degree' to Latex-style
+
+   * manalysis/MImgCleanStd.cc:
+     - we are now initialising an array holding the used pixel to prevent
+       looping through all pixel thousands of times
+       (MCerPhotEvt::IsPixelUsed)
+
+   * mbase/MWriteAsciiFile.cc:
+     - enhanced the documentation
+
+   * mmain/MBrowser.[h,cc]:
+     - enhanced the functionality to display the filename
+     - improved the layout
+
+   * mmain/MMars.cc:
+     - added calling of 'netscape' for the two picture buttons
+
+
+
+ 2001/11/06: Thomas Bretz
+
+   * mbase/MReadMarsFile.[h,cc]:
+     - added
+
+   * manalysis/MMcPedestalCopy.[h,cc]:
+     - moved copying to PreProcess
+     - removed Process
+
+   * mbase/Makefile, mbase/BaseLinkDef.h
+     - added MReadMarsFile
+
+   * mbase/MReadTree.[h,cc]:
+     - added a list of TObjects to be called when file in the chain 
+       is changed
+
+   * Makefile.conf.linux, Makefile.conf.linux-gnu:
+     - removed -g flag
+
+   * mraw/MRawRunHeader.h:
+     - fixed return type of GetNumEvents
+
+   * mraw/MRawCrateArray.[h,cc]:
+     - added SetSize which takes care of the size of the array
+     - changed the access to an unchecked one
+
+   * mraw/MRawCrateData.h
+     - derives from MParContainer now
+
+   * mraw/MRawEvtData.[h,cc]:
+     - made Print const
+     - changed so, that the arrays are dreed and allocated only
+       as less as possible
+
+   * mraw/MRawFileRead.[h,cc]:
+     - changed to support faster I/O of MRawEvtData and MRawCrateArray
+     - added sanity check (warning) to PostProcess
+
+   * mraw/MRawFileWrite.cc:
+     - removed deletion of trees (done by ~TFile)
+     - switched of AutoSave by use of a big size
+     - removed '.' from Branch names (each tree contains only one master
+       branch with equal subbranches)
+
+   * macros/readCT1.C:
+     - fixed a small bug
+
+   * manalysis/MCerPhotCalc.cc:
+     - removed Clear from Process (done by Reset now)
+
+   * manalysis/MCerPhotEvt.[h,cc]:
+     - added reset-function
+     - some small changes to the code layout
+
+   * mmc/MMcFadcHeader.[h,cc], mmc/MMcTrig.[h,cc]:
+     - chenged constructor to support fName and fTitle
+
+   * mbase/MReadTree.cc:
+     - removes '.' from a branch name now before searching/creating the object
+
+
+
+ 2001/11/01: Thomas Bretz
+ 
+   * mbase/MParContainer.cc:
+     - removed 'newname' from TObject::Clone call.
+
+   * mbase/MParContainer.h:
+     - layout changes
+
+   * mbase/MParList.h:
+     - changed destructor definition to virtual
+
+   * mbase/MReadTree.[h,cc]:
+     - added initialization for fProgress
+     - changed output
+     - move some code to new functions
+     - branch enabling now checks for the existance of the branch
+     - veto branch disables the corresponding sub branches now physically
+     - changed comments
+
+   * mdatacheck/MGDisplayAdc.cc:
+     - added some sanity checks
+
+   * meventdisp/MGCamDisplay.cc, meventdisp/MGEvtDisplay.[h,cc],
+     meventdisp/MGFadcDisp.cc:
+     - moved some code to MGEvtDisplay
+
+   * mhist/MFillH.cc:
+     - added warning to comment
+
+   * mhist/MHFadcCam.[h,cc]:
+     - added Clone-function. It seems, that this is necessary since 
+       root 3.01
+
+   * mhist/MHFadcPix.cc:
+     - changed axis titles
+
+   * mmain/MAnalysis.cc:
+     - added progress bar
+
+   * mmain/MBrowser.[h,cc]:
+     - added layout hints to fTop1,2,3
+     - adde Create/DestroyProgrssBar
+
+   * mmain/MDataCheck.cc:
+     - changes to the layout
+     - disable auto scheme
+     - added progress bar
+
+   * mmain/MMonteCarlo.[h,cc]:
+     - layout changes
+     - added progress bar
+     
+   * mraw/MRawEvtData.cc:
+     - new sanity check in Draw
+
+
+
+ 2001/11/01: Thomas Bretz
+
+   * macros/MagicHillas.C:
+     - changed Draw to DrawClone
+
+   * manalysis/MCerPhotPix.h:
+     - some layout changes
+
+   * mbase/MParList.cc: 
+     - fixed a bug in the dstructor which causes the d'tor to crash when
+       the owner bit was set
+     - changed some TCollection loop to macro ForEach
+
+   * mbase/MTaskList.cc:
+     - changed some TCollection loop to macro ForEach
+
+   * meventdisp/MGEvtDisplay.[h,cc]:
+     - added filemenu
+
+   * mgui/MCamDisplay.[h,cc], mgui/MHexagon.[h,cc]:
+     - added SavePrimitive function
+
+   * mhist/MHHillas.cc:
+     - changed 'deg' to '°'
+
+   * mmain/MDataCheck.cc:
+     - changed name of enums for buttons
+
+   * Makefile.conf.osf1:
+     - added some more exclusion flags to get rid of to much informations
+
+   * Makefile:
+     - changed flags of tar from '-cvf' to 'cvf' so that it runs on alpha, too
+
+   * mbase/MAGIC.h:
+     - put brackets around defines, to make it compile on alpha
+
+   * mbase/MEvtLoop.cc, mbase/MParList.cc, mbase/MTask.cc, 
+     mgui/MGeomCam.cc, mhist/MHFadcPix.cc, mmc/MMcTrig.cxx:
+     - removed inline statement, to make it link on alpha
+
+
+
+ 2001/10/31: Thomas Bretz
+
+   * Makefile:             
+     - changed MrProper output   
+
+   * Makefile.conf.general, Makefile.conf.linux,
+     Makefile.conf.linux-gnu, Makefile.conf.osf:
+     - added ARCHDEF environment
+
+   * manalysis/MHillas.[h,cc]:
+     - added units
+
+   * mbase/BaseLinkDef.h:
+     - added '+' for MTime
+
+   * mbase/MAGIC.h:
+     - let Linux find gLog when creating dictionary
+
+   * mbase/MHtml.h:
+     - removed include of TNamed
+
+   * */Makefile
+     - reordered *.cc filed to get rid of some 'rootcint' warnings
+
+   * mgui/MCamDisplay.cc:
+     - added SetBorderMode(0)
+   
+   * mgui/MHexagon.[h,cc]:
+     - changed Print-output to fit into two lines
+     - made Print appear in the context menu
+
+   * merpp.cc:
+     - Added MParContainer::Class()->IgnoreTObjectStreamer()
+
+   * mbase/MEvtLoop.[h,cc],  mbase/MReadTree.[h,cc],
+     mmain/MAnalysis.[h,cc]:
+     - added support for a progressbar
+
+   * mbase/MFilterList.h:
+     - added SetOwner-support
+
+   * mbase/MLogManip.h:
+     - added 'dec' manipulator to dbginf
+
+   * mbase/MTask.h:
+     - added GetNumExecutions
+
+   * mraw/RawLinkDef.h:
+     - added '+' for MRawEvtPixelIter, MRawCrateArray, MRawCrateData and
+       MRawFile[Read,Write]
+
+
+
+ 2001/10/30: Thomas Bretz
+
+   * macros/MagicHillas.C
+     - removed precreated objects
+
+   * macros/readCt1.C:
+     - fixed a bug (-> instead of .)
+
+   * *LinDef.h:
+     - added a '+' to all 'new' classes. 'new' means, that the object
+       is not yet used in Monte Carlo Files.
+
+   * *.h:
+     - changed defines from CLASS_H to MARS_Class type (like root)
+
+   * MMcPedestalCopy.[h,cc]:
+     - added AddToBranchList stamements
+
+   * manalysis/MPedestalPix.h, manalysis/MCerPhotPix.h, mgui/MGeomPix.h:
+     - changed derivement from TObject to MParContainer to be sure
+       fBits are not written, without specifying this for any TObject
+       derived class
+
+
+
+ 2001/10/29: Thomas Bretz
+
+   * Makefile.rules:
+     - changed the output
+
+   * macros/rootlogon.C:
+     - Added IgnorTObjectStreamer
+
+   * manalysis/MCT1ReadAscii.cc:
+     - changed fFileNames to a TList of TNamed objects
+
+   * mbase/MArray.h:
+     - removed include of MArray.h
+
+   * mbase/MParContainer.[h,cc]:
+     - changed fName, fTitle from pointer to static object
+     - Changed ClassVersion to 0
+
+   * mbase/MParList.[h,cc]:
+     - changed fName, fTitle from pointer to static object
+     - changed include of TObjArray to a forward declaration
+       (for faster compilation)
+     - simplified the code
+
+   * mbase/MInputStreamID.[h,cc]:
+     - changed fStreamId from char* to TString
+     - Changed ClassVersion to 0
+ 
+   * mbase/MReadTree.[h,cc]:
+     - changed veto-list to an array of TNamed objects
+     - implemented auto enabeling
+
+   * mbase/MTask.[h,cc]:
+     - implemented fListOfBranches for auto enabeling
+     
+   * mbase/MTaskList.[h,cc]:
+     - changed fName, fTitle from pointer to static object
+     - changed include of TObjArray to a forward declaration
+       (for faster compilation)
+
+   * mbase/MWriteRootFile.cc:
+     - changed fName, fTitle from pointer to static object
+     - set splitlevel in TTree::Branch to default
+     - changed kSaveNow to kFillTree
+
+   * mhist/MFillH.cc:
+     - changed fName, fTitle from pointer to static object
+     - check inharitance from MH
+
+   * mhist/MH.[h,cc]:
+     - changed fName, fTitle from pointer to static object
+     - implementation of simplified static MakeDefCanvas
+
+   * mhist/MHFadcCam.h:
+     - removed include of TH1
+
+   * mhist/MHFadcPix.[h,cc]:
+     - implemented persistent pixid
+     - get rid of 'fixed string sizes'
+     - Delete histograms from file structure (SetDirectory)
+     - changed Root's MakeDefCanvas to TH1::MakeDefCanvas
+     - removed include of TH1
+
+   * mhist/MHHillas.cc
+     - changed fName, fTitle from pointer to static object
+     - Delete histograms from file structure (SetDirectory)
+     - changed Root's MakeDefCanvas to TH1::MakeDefCanvas
+     - changed DrawClone to DrawCopy
+
+   * mhist/MHMcCollectionArea.[h,cc]:
+     - changed fName, fTitle from pointer to static object
+     - Delete histograms from file structure (SetDirectory)
+     - changed Root's MakeDefCanvas to TH1::MakeDefCanvas
+     - changed DrawClone to DrawCopy
+     - changed binning to log scale
+     - removed include of TH1
+
+   * mhist/MHMcEnergy.cc, mhist/MHStarMap.cc:
+     - changed fName, fTitle from pointer to static object
+     - Delete histograms from file structure (SetDirectory)
+     - changed Root's MakeDefCanvas to TH1::MakeDefCanvas
+
+   * manalysis/MCerPhotEvt.cc, manalysis/MHillas.cc, 
+     manalysis/MHillasCalc.cc, manalysis/MImgCleanStd.cc, 
+     manalysis/MMcPedestalCopy.cc, manalysis/MPedestalCam.cc,
+     mbase/MClone.cc, mbase/MPrint.cc, mbase/MTime.h,
+     mbase/MWriteAsciiFile.cc, mgui/MGeomCam.cc, mhist/MHFadcCam.cc, 
+     mhist/MHMcRate.cc, mmc/MMcTrig.cxx, mraw/MRawCrateArray.cc, 
+     mraw/MRawEvtData.cc, mraw/MRawEvtHeader.cc, mraw/MRawFileRead.cc:
+     - changed fName, fTitle from pointer to static object
+
+   * manalysis/MCerPhotCalc.cc, manalysis/MPedCalcPedRun.cc, 
+     mmontecarlo/MMcThresholdCalc.[h,cc], 
+     mmontecarlo/MMcTriggerRateCalc.[h,cc], 
+     mmontecarlo/MMcCollectionAreaCalc.[h,cc]:
+     - changed fName, fTitle from pointer to static object
+     - changed to use auto enabling scheme
+
+   * macros/threshold.C, macros/collarea.C, macros/trigrate.C:
+     - removed UseLeaf
+
+   * macros/CT1Hillas.C, macros/readMagic.C:
+     - made run again
+
+   * mraw/MRawFileWrite.cc:
+     - changed fName, fTitle from pointer to static object
+     - changed TTree::Branch to use default split level (99)
+     - added the missing important '.' to the Branch names!
+
+   * mraw/MRawRunHeader.[h,cc]:
+     - changed fName, fTitle from pointer to static object
+     - implemented enum for Run Type
+
+
+
+ 2001/10/26: Thomas Bretz
+
+   * Makefile.rules:
+     - changed output
+
+   * readraw.cc:
+     - changed name and description in TROOT
+     - removed argument in MMcEvt::Print()
+
+   * manalysis/MCerPhotEvt.[h,cc], manalysis/MCerPhotPix.[h,cc],
+     manalysis/MHillas.[h,cc], mmc/MMcEvt.[hxx,cxx],
+     mmc/MMcFadcHeader.[hxx,cxx], mmc/MMcTrig.[hxx,cxx],
+     mmc/MMcTrigHeader.[hxx,cxx]:
+     - according to root 3.01 made Print const
+
+   * mbase/BaseLinkDef.h:
+     - added MPrint
+
+   * mbase/MPrint.[h,cc]:
+     - added
+
+   * mbase/MClone.[h,cc]:
+     - changed MParContainer to a more general TObject
+
+   * mbase/Makefile:
+     - MPrint.cc added
+
+   * meventdisp/MGCamDisplay.[h,cc], meventdisp/MGEvtDisplay.[h,cc],
+     meventdisp/MGFadcDisp.[h,cc]:
+     - introduced fInitOk for the case PreProcessing failed
+
+   * mmain/MMonteCarlo.cc:
+     - added correction for use of several trigger conditions
+     - speedup threshold calc by usage of UseLeaf
+
+   * magiclogo.xpm, marslogo.xpm:
+     - changed
+
+   * mmain/MMonteCarlo.cc:
+     - added a workaround for the <TClass::TClass> no dictionary for MMc*
+       problem
+
+   * mbase/MWriteRootFile.[h,cc]:
+     - simplified code by removing MRootFileTree class
+
+   * mbase/MLog.cc:
+     - changed char[len+1] to 'new' statement
+
+
+
+
+ 2001/10/23: Thomas Bretz
+
+   * mbase/MLog.[h,cc]:
+     - replaced usage of tmpnam by mkstemp
+
+   * mgui/MCamDisplay.[h,cc]:
+     - Paint function added which maintains the aspect ratio of the image
+     - DrawPhotErr removed
+     - removed gPad->Clear, so that we can draw into pads not only
+       canvases
+
+   * mhist/MFillHFadc.[h,cc], mhist/MFillHHillas.[h,cc],
+     mhist/MFillHStarMap.[h,cc]:
+     - removed
+
+   * mmontecarlo/MMcTriggerRateCalc.[h,cc]:
+     - removed unused spectral index and flux
+
+   * mmontecarlo/MMcThesholdCalc.[h,cc],:
+     mbase/MParList.[h,cc]:
+     - fixed the Dimension handling
+
+   * mmontecarlo/MMcTriggerRateCalc.[h,cc],
+     - fixed the Dimension handling
+     - added destructor
+
+   * macros/trigrate.C:
+     - fixed some small things
+     - accelerated by use of MReadTree::UseLeaf
+
+   * mhist/MHMcCollectionArea.h:
+     - changed default argument of DrawClone from NULL to "".
+       NULL caused the interpreter to crash.
+
+   * mbase/MFilterList.[h,cc], mbase/MParContainer.[h,cc],
+     mbase/MParList.[h.cc], mbase/MTime.[h,cc],
+     mgui/MGeomCam.[h,cc], mgui/MGeomPix.[h,cc],
+     mgui/MHexagon.[h,cc], mhist/MHMcEnergy.[h,cc],
+     mhist/MHMcRate.[h,cc], mraw/MRawCrateData.[h,cc],
+     mraw/MRawEvtHeader.[h,cc], mraw/MRawRunHeader.[h,cc]:
+     - according to root 3.01 I made Print() const
+
+   * mdatacheck/MViewAdcSoectra.[h,cc], mdatacheck/MShowSpect.[h,cc]:
+     - removed
+
+   * mbase/MReadTree.cc:
+     - removed default argument from GetEntry-call
+
+   * mbase/MTask.[h,cc]:
+     - introduced mapping function for (Pre/Post)&Process
+     - according to root 3.01 I made Print() const
+     - added PrintStatistics
+     - added call counter
+
+   * mbase/MTaskList.[h,cc]:
+     - adapted to new MTask mapping functions
+     - according to root 3.01 I made Print() const
+     - added PrintStatistics
+     - moved some functionality to MTask-Mapper functions
+
+   * mmain/MMonteCarlo.cc:
+     - adapted to some changes in other classes
+     - some small simplifications
+     - accelerated, by use of UseLeaf
+     - workaround for the ButtonGroup/Button delete bug
+
+   * mmain/MAnalysis.cc:
+     - workaround for the ButtonGroup/Button delete bug
+
+
+
+ 2001/10/23: Thomas Bretz
+
+   * macros/dohtml.C:
+     - changed macro names
+
+   * macros/getCollArea.C:
+     - renamed to collarea.C
+     - make use of new fast MReadTree
+
+   * macros/getRate.C:
+     - renamed to trigrate.C
+
+   * macros/getThreshold.C:
+     - renamed to threshold.C
+
+   * Makefile.depend:
+     - removed
+
+   * mgui/MCamDisplay.[h,cc]:
+     - fixed wrong usage of new operator in TClonesArray
+     - the aspect ratio of the Canvas is used now to display geometries
+       correctly (no 'small CT1 camera anymore)
+     - replaced include of MCerPhotPix by a forward declaration
+     - replaced include of MHexagon by a forward declaration
+
+   * mgui/MGeomCam.[h,cc]:
+     - added GetMaxRadius()-function
+     - added CalcMaxRadius()-function
+     - replaced include of MGeomPix by a forward declaration
+     - replaced include of TObjArray by a forward declaration
+
+   * mgui/MGeomCamMagic.cc, mgui/MGeomCamCT1.cc:
+     - call CalcMaxRadius in the constructor
+
+
+
+ 2001/10/22: Thomas Bretz
+
+   * mhist/MH*.[h,cc]:
+     - changed DrawClone according to root 3.01/06 to 'const'
+
+
+
+ 2001/10/16: Thomas Bretz
+
+   * mbase/MReadTree.[h,cc]:
+     - added some output statements
+     - added comments
+     - added UseLeaf
+     - changed AddFile to Int_t
+     - simplified GetEntry call
+
+   * mgui/MGeomCam.[h,cc], MGeomCamCT1.[h,cc], MGeomCamMagic.[h,cc]:
+     - added come comments
+     - removed Draw-function
+   
+   * mars.cc:
+     - Changed name of TROOT object to 'mars'
+
+   * merpp.cc:
+     - changed name of TROOT object to 'merpp'
+     - added some more ouput
+
+   * mbase/MBaseLinkDef.h:
+     - added MRootFileBranch
+     - added MRootFileTree
+
+   * mgui/MGeomPix.cc, mbase/MClone.cc, mraw/MRawRunHeader.cc:
+     - added comments
+
+   * mbase/MEvtLoop.cc:
+     - added missing include
+     - added another time output
+
+   * mbase/MWriteRootFile.cc:
+     - added ClassImp
+   
+   * mhist/MFillH.cc, mmontecarlo/MMcCollectionAreaCalc.cc:
+     - changed output
+   
+   * mhist/MHMcCollectionArea.cc:
+     - small fixes
+     - changed error calculation according to Ciro
+
+   * macros/CT1Hillas.C:
+     - fixes some bugs (typos)
+
+
+
+ 2001/10/05: Thomas Bretz
+
+   * manalysis/MHillas.cc, manalysis/MImgCleanStd.cc, mbase/MClone.[h,cc],
+     mbase/MFilterList.h, mbase/MWriteFile.h, mbase/MWriteRootFile.h,
+     mdatacheck/MGDisplayAdc.cc, meventdisp/MGCamDisplay.cc, 
+     meventdisp/MGCamDisplay.h, meventdisp/MGEvtDisplay.h,
+     mgui/MGeomPix.h, mhist/MFillH.h, mhist/MHHillas.h,
+     mmain/MAnalysis.h, mmain/MBrowser.h, mmain/MCameraDisplay.h,
+     mmain/MDataCheck.h, mmain/MEvtDisp.h, mmain/MMonteCarlo.h,
+     mraw/MRawFileRead.cc
+     - comments updated
+     
+   * mbase/MFilter.[h,cc]:
+     - made IsExpressionTrue abstract
+     
+   * meventdisp/MGEvtDisplay.cc:
+     - fixed a bug that only every second event was displayed
+
+   * meventdisp/MGFadcDisp.[h,cc]:
+     - reorganized code (changing pixel number drawed the histogram twice)
+     
+   * mgui/MCamDisplay.[h,cc]:
+     - added fDrawingPad to make sure that all output goes into the same pad
+     
+   * mhist/HistLinkDef.h, mhist/Makefile:
+     - removed old MFillH* classes
+
+
+
+ 2001/10/02: Thomas Bretz
+
+   * mbase/MClone.[h,cc],
+     meventdisp/MGCamDisplay.[h,cc],
+     meventdisp/MGEvtDisplay.[h,cc],
+     mmain/MCameraDisplay.[h,cc]:
+     - added
+     
+   * macros/readMagic.C:
+     - fixed a  "'->' and '.' mixed bug"
+     
+   * manalysis/MCT1ReadAscii.cc:
+     - added initialisation of fIn
+     
+   * manalysis/MCerPhotEvt.[h,cc]:
+     - made IsPixelExisting const
+     - made IsPixelCore const
+     - made IsPixelUsed const
+     - made GetNumPhotons[Min,Max] const
+
+   * mbase/BaseLinkDef.h, mbase/Makefile:
+     - added MClone
+     
+   * mbase/MEvtLoop.[h,cc], mbase/MParList.[h,cc], mbase/MTaskList.[h,cc]:
+     - added SetOwner-support
+     
+   * mdatacheck/DataCheckLinkDef.h, mdatacheck/Makefile:
+     - removed MShowSpect
+     - removed MViewAdcSpect
+     
+   * mdatacheck/MDumpEvtHeader.cc:
+     - added missing descriptions
+     
+   * mdatacheck/MGDisplayAdc.[h,cc]:
+     - small changes
+     
+   * meventdisp/EvtDispLinkDef.h:
+     - added MGEvtDisplay
+     - added MGCamDisplay
+     
+   * meventdisp/MGFadcDisp.[h,cc]:
+     - derived from MGEvtDisplay
+     - most of the code moved to MGEvtDisplay to support MGCamDisplay, too
+     
+   * meventdisp/Makefile:
+     - added MGCamDisplay
+     
+   * mgui/MCamDisplay.[h,cc]:
+     - cleaned
+     - reorganized
+     
+   * mgui/MHexagon.cc:
+     - added missing descriptions
+     
+   * mhist/MHFadcPix.cc:
+     - reorganized some code in the constructor which creates the 'names'
+     
+   * mhist/MHHillas.cc, mhist/MHMcCollectionArea.cc, 
+     mhist/MHMcEnergy.cc, mhist/MHStarMap.cc:
+     - Draw-function supports a default canvas now
+   
+   * mmain/MDataCheck.cc:
+     - added/rorganized comments
+     - removed usage of MViewAdcSpectra
+     
+   * mmain/MMars.[h,cc]:
+     - added new "Camera Display" Button
+     
+   * mmain/MainLinkDef.h, mmain/Makefile:
+     - added MCameraDisplay
+
+
+
+ 2001/09/28: Thomas Bretz
+
+   * macros/getRate.C:
+     - changed TObjArray to a non-pointer object
+     - added Printing of the result at the end of the macro
+     
+   * mhist/MHMcCollectionArea.[h,cc], mhist/MHMcEnergy.[h,cc]:
+     - added DrawClone
+     
+   * mhist/MHMcRate.[h,cc]:
+     - added a dummy for DrawClone
+     
+   * mmain/MMonteCarlo.[cc, h]:
+     - added Gui elements
+     - added CalculateCollectionArea (not yet tested)
+     - added CalculateTriggerRate (not yet tested)
+     - added Threshold (not yet tested)
+
+   * mmontecarlo/MMcTriggerRateCalc.cc:
+     - removed output stuff from PostProcessing
+
+   * meventdisp/MGFadcDisp.[h,cc], mdatacheck/MGDisplayAdc.[h,cc]:
+     - reorganized code (constructor)
+     - reorganized deletion of gui objects
+     - fixed many, many memory leaks
+
+
+
+ 2001/09/27: Thomas Bretz
+
+   * mmain/MBrowser.cc:
+     - added comments
+
+   * mmain/MAnalysis.[h,cc]:
+     - added entry field for cleaning levels
+     - restructured code a bit
+
+   * mhist/MFillH.cc:
+     - fixed missing initialization of member variables in Init
+
+   * mhist/MHHillas.[h,cc]:
+     - Added comments
+     - Added DrawClone
+     - Removed kCanDelete bits from Draw function
+
+   * mhist/MHStarMap.[h,cc]:
+     - Added comments
+     - Added DrawClone
+     - moved some code from the Draw-functions to PrepareDrawing
+
+
+
+ 2001/09/26: Thomas Bretz
+
+   * mmain/MMars.[cc,h], mmain/MBrowser.[cc,h], MDataCheck.[cc,h],
+     mmain/MEvtDisp.[cc,h], mmain/MMonteCarlo.[cc,h]:
+     - reorganized code (constructor)
+     - reorganized deletion of gui objects
+     - fixed many, many memory leaks
+     - small changes in layout
+
+   * mmain/MAnalysis.[h,cc]:
+     - added
+
+   * macros/*:
+     - added Copyright notice
+     - added some small sanity checks
+
+   * macros/MagicHillas.C:
+     - fixed '->' bug
+     - changed MFillHStarMap to MFillH
+     
+   * mbase/MReadTree.cc, mraw/MRawFileWrite.cc:
+     - removed an old debug statement
+     
+   * mmain/MMars.cc:
+     - added new Analysis functionality
+     
+   * mmain/MainLinkDef.h:
+     - addded MAnalysis
+     
+   * mmain/Makefile:
+     - added MAnalysis.cc
+     
+   * mmc/McLinkDef.h:
+     - removed nonsens define statement
+
+
+
+ 2001/09/25: Thomas Bretz
+
+   * Makefile:
+     - changed make tar so that 'CVS/Root' isn't added to the tar-file anymore
+       It contains the origin (CVSROOT) of the repository and my confuse
+       people triing to commit changed files from such an archive to
+       the repository
+       
+   * mmain/MBrowser.[cc,h]:
+     - reorganized code (constructor)
+     - reorganized deletion of gui objects
+     - fixed many, many memory leaks
+
+   * mmain/MMars.[cc,h]:
+     - reorganized code (constructor)
+     - reorganized deletion of gui objects
+     - fixed many, many memory leaks
+
+
+
+ 2001/09/20: Thomas Bretz
+
+   * mbase/MLog.[h,cc]:
+     - made working with Cosy
+     - fixed gui stuff to work like expected
+
+   * manalysis/MCerPhotPix.h:
+     - replaced TROOT.h by MAGIC.h
+
+   * mfilter/MFTriggerLvl1.h:
+     - added description
+
+
+
+ 2001/09/20: Thomas Bretz
+
+   * released Version 0.4
+
+   * mevtdisp/MGFadcDisp.cc, mmain/MMars.cc:
+     - switched to root version >= 3.00
+     
+   * Makefile.conf.linux:
+     - added to support the new Linux distributions
+
+   * .rootrc:
+     - removed references to MARSSYS
+
+
+
+ 2001/09/13: Thomas Bretz
+ 
+   * Makefile.conf.linux-gnu:
+     - removed "-Woverloaded-virtual". it doesn't really help
+
+
+
+ 2001/08/02: Thomas Bretz
+
+   * macros/getRate.C:
+     - make use of new stylish lists of containers
+
+
+   * macros/CT1Hillas.C, macros/getCollArea.C:
+     - make use of return value of Eventloop
+
+   * macros/merpp.C:
+     - changed return type to void
+
+
+
+ 2001/07/23: Thomas Bretz
+ 
+   * mbase/MParList.cc:
+     - redifinition of default argument: fixed
+
+
+
+ 2001/07/23: Thomas Bretz
+ 
+   * mmontecarlo/MMcThresholdCalc.[cc,h]:
+     - changed PreProcess action to new stylish lists of containers
+
+   * mhist/Makefile:
+     - removed MEnergies.cc
+
+   * mhist/HistLinkDef.h:
+     - removed MEnergies.cc
+   
+   * mbase/MReadTree.cc:
+     - removed a bug which causes MReadTree to show strange behaviour.
+       We cannot use GetBranch()->SetAddress() we have to use
+       SetBranchAddress.
+       
+   * macros/MagicHillas.C:
+     - changed to new stylish histogram fillers.
+
+   * mhist/MHMcRate.cc:
+     - some simplifications to the constructors
+     - some accelerations of the rate calculation
+     
+   * mhist/MHHillas.C:
+     - added axis descriptions (thanks to Rudy)
+
+
+
+ 2001/07/20: Thomas Bretz
+ 
+   * mhist/MH.cc:
+     - added comments
+
+   * mhist/MFillH.cc:
+     - added comments
+
+   * mbase/MParList.[h,cc]:
+     - Added AddToList from a TObjArray
+     - Added GetClassName
+     - Added GetObjName
+     - Added FindObjectList
+     - Added FindCreateObjList
+     - Added CreateObjList
+
+   * mhist/MHMcEnergies.[h,cc]:
+     - deleted
+
+   * mhist/MHMcEnergy.[h,cc]:
+     - rewrote constructor in a way that MHMcEnergies isn't needed anymore
+     - added a SetName function which replaces the old constructor somehow
+
+   * macros/getThreshold.C:
+     - make use of some new features
+
+
+
+ 2001/07/19: Thomas Bretz
+ 
+   * mbase/MEvtLoop.cc:
+     - added comments
+     
+   * mbase/MTaskList.cc:
+     - changed the wrong 'break' for kCONTINUE into 'return kTRUE'
+     
+   * mhist/MH.[cc,h]
+     - added
+
+   * mhist/MFillH.[cc,h]
+     - added
+     - in principal MFillHHillas, MFillHFadc and MFillHStarMap
+       can be deleted now
+     
+   * mhist/HistLinkDef.h:
+     - added MH
+     - added MFillH
+     
+   * mhist/MFillHFadc.cc:
+     - moved source for filling to corresponding histogram class
+     
+   * mhist/MFillHHillas.cc:
+     - included MHillas.h
+     
+   * mhist/MHFadcCam.[cc, h]:
+     - added Fill
+     - made FillHi, FillLo private
+     
+   * mhist/MHHillas.[cc, h], mhist/MHStarMap.[h,cc]:
+     - changed Fill function to new style
+     - derived class from MH
+
+   * mhist/Makefile:
+     - added MH.cc
+     - added MFillH.cc
+
+
+
+ 2001/07/18: Oscar Blanch
+ 
+   * macros/getRate.C:
+     - Macro to compute the trigger rate from a MonteCarlo file
+
+   * mhist/MHMcRate.[h,cc]:
+     - Container to store trigger rate information
+     - Draw() functin member to be implemented
+
+   * mmontecarlo/MMcTriggerRateCalc.[h,cc]:
+     - Task to compute trigger rate
+
+
+
+ 2001/07/13: Thomas Bretz
+
+   * mbase/MEvtLoop.[h,cc]:
+     - Added a result value to Eventloop to be able to detect if the
+       execution was successfull
+     - changes postProcess to return the return value from 
+       MTaskList::PostProcess
+     
+   * mbase/MParList.cc:
+     - FindCreateObj removes now a 'dot' from the end of an indexed
+       object name like "Events;7."
+     
+   * mbase/MReadTree.cc:
+     - small changes to the output
+
+   * mbase/MTask.[h,cc]:
+     - added Preprocessed flag. This enables the tasklist to only postprocess
+       already preprocessed tasks
+
+   * mbase/MTaskList.cc:
+     - don't postprocess non preprocessed tasks
+   
+   * mhist/MHMcCollectionArea.cc:
+     - added descriptions to histrograms
+     - changed names of histograms
+     - added drawing of canvas to Draw-functions
+
+   * mhist/MHMcEnergy.[h,cc]:
+     - added variables to store the calculated result
+     - changed names and titles of histogram
+     - added axis titles to histogram
+     - moved result calculation into fit-function
+
+   * mmontecarlo/MMcCollectionAreaCalc.cc:
+     - added name of input container to be able to process another
+       container than "MMcTrig"
+
+   * mmontecarlo/MMcThresholdCalc.cc:
+     - removed trailing dot from container name creation
+   
+   * mhist/MMcThresholdCalc.cc:
+     - removed a wrong '.' behind the number when processing more than
+       one trigger condition
+
+   * mraw/MRawRunHeader.cc:
+     - added "Monte Carlo Data" as runtype
+
+
+
+ 2001/07/10: Thomas Bretz
+
+   * mhist/MHMcEnergy.h:
+     - renamed SetBins to SetNumBins
+     
+   * mmontecarlo/MMcThresholdCalc.cc:
+     - changed style of comments
+     - moved sqrt(2) from Postprocess to header.
+     
+   * mmontecarlo/MMcEnerHisto.[cc,h], mmontecarlo/MMcEnerThre.[cc,h], 
+     mmontecarlo/MMcEnerThreCalc.[cc,h]:
+     - removed
+
+   * mmontecarlo/MCollArea.[cc,h], mmontecarlo/MCollAreaTrigger.[cc,h]:
+     - removed
+
+
+
+ 2001/07/09: Thomas Bretz
+ 
+   * mbase/MParList.cc:
+     - made handling of already existing containers in AddToList a bit 
+       more convinient
+     
+   * mbase/MTaskList.[h,cc]:
+     - added come comments
+     - made handling of already existing tasks in AddToList a bit 
+       more convinient
+     - Added name-argument to constructor
+     
+   * mraw/MRawFileRead.[cc, h]:
+     - move file-open check from constructor to PreProcess
+     - added variable for filename
+     
+   * mraw/MRawFileWrite.[cc,h]:
+     - moved fOut->Write from PostProcess to destructor
+     - removed PostProcess
+
+
+
+ 2001/07/06: Thomas Bretz
+ 
+   * mfilter/FilterIncl.h, mfilter/FilterLinkDef.h, 
+     mfilter/MFTriggerLvl1.[h,cc], mfilter/mfilter/Makefile:
+     - added
+     
+   * Makefile
+     - mfilter added
+     
+   * Makefile.conf.linux-gnu:
+     - added some warning options
+     
+   * Makefile.conf.osf1:
+     - enhanced warnings
+     
+   * manalysis/MCerPhotEvt.cc:
+     - removed a small buf from the constructor
+     
+   * BaseLinkDef.h:
+     - added MFilter
+     - added MFilterList
+     
+   * mbase/MLog.[h,cc]:
+     - added a non-empty copy constructor to make cxx happy
+     
+   * mbase/MParList.[h,cc]:
+     - added second overload-function FindObject
+   
+   * mbase/MTask.h:
+     - added all Filter stuff
+     
+   * mbase/MTaskList.cc:
+     - changed debug output
+     - added filter-stuff to Process
+     
+   * mbase/MTaskList.h:
+     - changed Print default option from NULL to ""
+     
+   * mbase/Makefile:
+     - added MFilter
+     - added MFilterList
+   
+   * mhist/MFillHFadc.cc:
+     removed a small bug in the PreProcessing
+   
+   * manalysis/MCerPhotEvt.h, manalysis/MHillas.cc, manalysis/MHillas.h, 
+     manalysis/MImgCleanStd.cc, manalysis/MPedestalCam.h, mgui/MGeomCam.h,
+     mhist/MFillHHillas.h, manalysis/MHillasCalc.h, manalysis/MCerPhotCalc.h,
+     manalysis/MImgCleanStd.h, mhist/MFillHStarMap.h, mhist/MHHillas.cc,
+     mhist/MHHillas.h, mhist/MHStarMap.cc, mhist/MHStarMap.h,
+     mmc/MMcFadcHeader.hxx, mmc/MMcFadcHeader.hxx, mmc/MMcTrig.hxx,
+     mmontecarlo/MMcThresholdCalc.h:
+     - made more const-correct
+
+   * manalysis/MCT1ReadAscii.cc, manalysis/MCerPhotCalc.cc, 
+     manalysis/MHillasCalc.cc, manalysis/MImgCleanStd.cc,
+     manalysis/MMcPedestalCopy.cc, manalysis/MPedCalcPedRun.cc,
+     mhist/MFillHFadc.cc, mhist/MFillHHillas.cc, mhist/MFillHStarMap.cc,
+     mmontecarlo/MMcThresholdCalc.cc, mraw/MRawFileRead.cc,
+     mraw/MRawFileWrite.cc:
+     - added comments
+
+   * manalysis/MCT1ReadAscii.cc, manalysis/MCerPhotCalc.cc, 
+     manalysis/MCerPhotPix.cc, manalysis/MHillas.cc,
+     manalysis/MHillasCalc.cc, manalysis/MImgCleanStd.cc, 
+     manalysis/MMcPedestalCopy.cc, manalysis/MMcPedestalCopy.h,
+     manalysis/MPedCalcPedRun.cc, manalysis/MPedestalCam.cc, 
+     manalysis/MPedestalPix.cc,
+     mbase/MArray.cc, mbase/MArrayB.cc, mbase/MArrayS.cc, mbase/MEvtLoop.cc, 
+     mbase/MLog.cc, mbase/MParList.cc, mbase/MReadTree.cc, mbase/MTask.cc, 
+     mbase/MTime.cc, mbase/MWriteAsciiFile.cc, mbase/MWriteFile.cc, 
+     mbase/MWriteRootFile.cc,
+     mhist/MFillHFadc.cc, mhist/MFillHFadc.cc, mhist/MFillHHillas.cc,
+     mhist/MFillHStarMap.cc, mhist/MHFadcCam.cc, mhist/MHFadcPix.cc,
+     mhist/MHHillas.cc, mhist/MHMcCollectionArea.cc, mhist/MHMcEnergies.cc,
+     mhist/MHMcEnergy.cc, mhist/MHStarMap.cc, mraw/MRawCrateArray.cc,
+     mraw/MRawCrateData.cc, mraw/MRawEvtData.cc, mraw/MRawEvtHeader.cc,
+     mraw/MRawEvtPixelIter.cc, mraw/MRawFileRead.cc,
+     mraw/MRawFileWrite.cc, mraw/MRawRunHeader.cc:
+     - added semicolon after ClassImp to make my editor happy
+
+   * mmain/MEvtDisp.cc:
+     - removed a wrong comma in the enumerations
+     
+   * mmontecarlo/MMcThresholdCalc.cc:
+     - made compile on osf by removing brackets in new steatement (constructor)
+     
+
+
+ 2001/07/05: Thomas Bretz
+
+   * macros/CT1Hillas.C:
+     - changed the wrong pointers to dots.
+     
+   * macros/getThreshold.C:
+     - added some comments
+     - removed the canvas creation
+     - drawing replaced by a loop
+     - changed trigger conditions to 1 (should work with any MC file)
+     
+   * macros/readMagic.C:
+     - changed the event counter to the number of the event in the file
+     - removed icound
+     
+   * manalysis/MPedCalcPedRun.cc, manalysis/MCerPhotCalc.cc,
+     mbase/MParContainer.cc, mbase/MParContainer.h, mbase/MParList.cc,
+     mbase/MParList.h, mbase/MTaskList.cc, mbase/MWriteAsciiFile.cc,
+     mbase/MWriteRootFile.cc, mhist/MFillHFadc.cc, mhist/MFillHHillas.cc,
+     mhist/MFillHStarMap.cc,
+     - changed HasChanged to ReadyToSave
+     
+   * mbase/MReadTree.cc:
+     - added some comments
+     
+   * mhist/MHMcEnergies.h:
+     - fixed bug in []-operator
+     
+   * mhist/MHMcEnergy.cc:
+     - added canvas creation to draw function
+   
+   * mmontecarlo/MMcThresholdCalc.cc:
+     - fixed a bug in the constructor
+ 
+ 
+ 
+ 2001/06/20: Thomas Bretz
+ 
+   * macros/merpp.C:
+     - fixed type in comment
+     
+   * manalysis/MHillas.cc:
+     - fixed 'FIXME' comment
+   
+   * mbase/MWriteFile.[h,cc]:
+     - added
+  
+   * mbase/MWriteRootFile.[h,cc]:
+     - added
+   
+   * mbase/BaseLinkDef.h:
+     - Added MWriteFile
+     - Added MWriteRootFile
+   
+   * mbase/MEvtLoop.cc:
+     - fixed the counting in the eventloop
+     
+   * mbase/MWriteAsciiFile.[h,cc]:
+     - changed class that it is based on MWriteFile now
+   
+   * mbase/Makefile:
+     - added MWriteFile
+     - added MWriteRootFile
+   
+   * mhist/MFillHFadc.[h,cc]:
+     - added set for HasChanged (new PostProcess)
+   
+   * mhist/MFillHHillas.cc:
+     - added set for HasChanged (new PostProcess)
+   
+   * mhist/MFillHStarMap.cc:
+     - added set for HasChanged (new PostProcess)
+
+   * mhist/MHHillas.cc:
+     - Set kCanDelete to make sure, that the histograms are deleted
+       together with the canvas
+     
+   * mraw/MRawFileWrite.[h,cc]:
+     - changed the handling of opening, closing and checking file
+
+
+
+ 2001/06/13: Thomas Bretz
+
+   * ./.../*.h:
+     - added some comments and corrected some descriptions.
+     
+   * mbase/MParContainer.[h,cc]:
+     - added a 'dummy' function for AsciiRead, AsciiWrite
+
+   * mbase/MWriteAsciiFile.[h,cc]:
+     - added new constructor (specify directly the pointer to the class)
+
+   * mgui/MHexagon.cc:
+     - made Copy-function more readable
+
+   * mgui/MParContainer.cc:
+     - made Copy-function more readable
+
+   * mhist/MHMcEnergies.[h,cc]:
+     - files added as a container to make handling of several MHMcEnergy easier
+   
+   * mbase/MAGIC.h:
+     - encapsulated include of TROOT
+
+   * mbase/MTaskList.cc:
+     - added SetHasChange and Reset to PostProcess
+
+   * mhist/HistLinkDef.h
+     - added MHMcEnergies
+     
+   * mhist/MHMcEnergy.[h,cc]:
+     - added name and title to constructor
+     - added number to name of container
+   
+   * mmontecarlo/MMcThresholdCalc.cc:
+     - corrected typo in creation of the container names
+   
+   * mraw/MRawEvtData.cc:
+     - Set kCanDelete in Draw function
+
+
+
+ 2001/06/12: Thomas Bretz
+
+   * mmontecarlo/MMcEnerThreCalc.[cc,h] 
+     - copied to mmontecarlo/MMcThresholdCalc.[cc,h]
+
+   * mmontecarlo/MMcEnerThreHistos.[h,cc]
+     - copied to mmhist/MHMcEnergy.[h,cc]
+
+   * mbase/Makefile:
+     - added MWriteAsciiFile.cc
+   
+   * mhist/HistIncl.h:
+     - added TF1.h
+
+   * mhist/HistLinkDef.h:
+     - added MHMcEnergy
+ 
+   * mhist/Makefile
+     - added MHMcEnergy
+   
+   * mmontecarlo/MCollArea.h:
+     - fixed typo in ifndef
+   
+   * mmontecarlo/Makefile:
+     - added MMcThresholdCalc.cc
+     - removed MMcEnerHisto.cc
+     - removed MMcEnerThre.cc
+     - removed MMcEnerThreCalc.cc
+
+   * mmontecarlo/MonteCarloLinkDef.h:
+     - added MMcThresholdCalc.cc
+     - removed MMcEnerHisto.cc
+     - removed MMcEnerThre.cc
+     - removed MMcEnerThreCalc.cc
+ 
+   * mbase/MWriteAsciiFile.[h,cc]: 
+     - added
+
+   * manalysis/MCT1ReadAscii.h: 
+     - removed fFileName from class definition
+ 
+   * manalysis/MCerPhotCalc.cc: 
+     - use of SetHasChanged added
+ 
+   * manalysis/MHillas.[h,cc]: 
+     - Reset added
+     - AsciiRead added
+     - AsciiWrite added
+     - use of SetHasChanged added
+
+   * manalysis/MPedCalcPedRun.[h,cc]:
+     - made fNumHiGainSamples a class member
+     - renamed some member functions
+     - made the 'internal' member functions private
+     - added SetHasChanged
+     - made these functions const
+     
+   * mbase/BaseLinkDef.h
+     - MWriteAsciiFile added
+   
+   * mbase/MEvtLoop.cc:
+     - some small changes to the logging output
+   
+   * mbase/MParContainer.cc:
+     - fHasChanged added 
+   
+   * mbase/MParContainer.h:
+     - Reset prototype added
+     - HasChanged added
+     - SetHasChanged added
+   
+   * mbase/MParList.[cc,h]:
+     - SetHasChanged added
+     - Reset added
+   
+   * mbase/MTaskList.cc:
+     - Process: call SetHasChanged before looping
+     - Process: call Reset before looping
+   
+   * mbase/MTaskList.h:
+     - fParList added to class definition
+
+
+
+ 2001/04/27: Thomas Bretz
+
+   * macros/merpp.C:
+     - made the merpp-macro Mars 0.3 compatible
+
+
+
+ 2001/04/19: Thomas Bretz
+
+   * mbase/MParList.cc:
+     - added stripping of the string after last semicolon (classname)
+
+   * mbase/MReadTree.cc:
+     - added Veto funtionality to PreProcess
+     - added HasVeto
+     - added fVetoList
+     - added VetoBranch
+
+
+
+ 2001/04/18: Thomas Bretz
+
+   * mbase/MHtml.[cc.h]:
+     - Added
+     
+   * mbase/*.cc:
+     - changed comments of member functions to new MHtml-Style
+
+
+
+ 2001/04/09: Thomas Bretz
+
+   * mbase/MParList.cc:
+     - Added the possibility to specify a different object name in
+       FindCreateObj
+
+   * .rootrc:
+     - changed the style for the html documentation
+    
+   * macros/dohtml.C:
+     - added SetXwho
+    
+   * (*.cc):
+     - added the copyright comment block
+  
+   * mgui/MGeomCamMagic.cc:
+     - added some comments to all these numbers
+  
+   * mraw/MRawEvtPixelIter.h:
+     - added Jump member function which jumps directly to the pixel with a
+       given id
+      
+
+
+ 2001/04/09: Thomas Bretz
+
+   * mgui/MGeomPix.cc:
+     - fixed a small error in SetNeighbors (thanks to Oscar)
+     
+   * mgui/MGFadcDisp.[h,cc]:
+     - Fixed many small errors which caused the display to display nonsens
+       in some situations
+
+
+
+ 2001/04/04: Thomas Bretz
+
+   * mraw/MRawEvtData.[cc,h]:
+     - changed wrong return type of GetNumPixels to UShort_t
+
+   * mmain/MBrowser.[cc,h]:
+     - made the dialog somehow work like it should
+
+
+
+ 2001/04/03: Thomas Bretz
+
+   * manalysis/MCT1ReadAscii.cc:
+     - the pedestal values read from the file are now stored in MeanRms 
+       instead of Sigma
+   
+   * manalysis/MCerPhotCalc.cc:
+     - The pedestal mean Rms is used as the pixel error
+   
+   * MImgCleanStd.cc:
+     - CleanStep1: the '<' was replaced by a '<=' to clean also pixels 
+       with value=noise=0
+     
+   * MMcPedestalCopy.cc:
+     - All the pedestal values are now filled in (are they calculated correctly?)
+   
+   * mgui/MGeomCamMagic.cc:
+     - Forgot to initialize the Nextneighbors of the Magic Camera
+       (thanks to Oscar)
+     
+   * mhist/MHStarMap.cc:
+     - I changed the model of the display (colors and bin width) to
+       get a 'better' result
+
+
+
+ 2001/04/02: Thomas Bretz
+ 
+   * mraw/MRawEvtHeader.h, mraw/MRawFileWrite.cc:
+     - added constants (kTT*) for trigger type
+   
+   * manalysis/MImgCleanStd.[h,cc]:
+     - added changeable cleaning levels
+ 
+   * manalysis/MHillas.cc:
+     - added some more sanity checks to the calculation
+     
+   * manalysis/MCT1ReadAscii.[h,cc]:
+     - added some kind of chain feature (AddFile) to process more than one file
+ 
+   * mgui/MGeomPix.[h,c]:
+     - added interface to pixel neighbors
+ 
+   * mgui/MGeomCamCT1.[cc,h], mgui/MGeomCamMagic.[cc,h]:
+     - creates the neighbor geomtry now, too
+ 
+   * manalysis/MImgCleanStd.[cc,h]:
+     - switched to new stylish neighbors from MGeomCam
+
+
+
+ 2001/03/30: Thomas Bretz
+ 
+   * mdatacheck/MH*, mdatacheck/MFillH*:
+     - moved to mhist
+   
+   * mraw/MrawEvtPixelIter:
+     - IsLoGain -> HasLoGain
+   
+   * mgui/MG*:
+     - renamed
+     - moved to mmain
+     - move Browser functionality to MBrowser
+ 
+   * mmain/, mhist:
+     - new
+
+
+
+ 2001/03/21: Thomas Bretz
+                            
+   * manalysis/MHillas.[h,cc]:
+     - fixed some minor errors, added sanity check (N<2) to Calc
+
+   * manalysis/MFillHHillas.cc:
+     - skip event if Hillas calculations fails
+     
+   * macros/getCollArea.C, macros/readMagic.C, 
+     mdatacheck/MViewAdcSpectra.cc, meventdisp/MGFadcDisp.cc:
+     - changed order in MReadTree constructor
+
+   * manalysis/MCT1ReadAscii.[h,cc]:
+     - changed to use MPedestalCam
+     
+   * manalysis/MCT1Pedestals.[h,cc]:
+     - removed
+     
+   * manalysis/Makefile, manalysis/AnalysisLinkDef.h:
+     - removed MCT1Pedestals
+     
+   * mbase/BaseLinkDef.h:
+     - added const values from Magic.h
+     
+   * mbase/MLogManip.h:
+     - changed style of dbginf
+   
+   * mbase/MParList.cc:
+     - make use of dbginf
+     
+   * mbase/MReadTree.[h,cc]:
+     - switched from a TTree to a TChain object
+     - chnaged order of variables of the constructor
+
+
+
+ 2001/03/21: Thomas Bretz
+                                                                  
+   * macros/CT1Hillas.C, manalysis/MImgCleanStd.cc, manalysis/MImgCleanStd.h,
+     manalysis/MMcPedestalCopy.cc, manalysis/MMcPedestalCopy.h,
+     manalysis/MCerPhotCalc.h, manalysis/MCerPhotCalc.cc, mdatacheck/MHHillas.h,
+     mdatacheck/MHHillas.cc, mdatacheck/MFillHFadc.cc, mdatacheck/MFillHFadc.h,
+     mdatacheck/MHFadcCam.cc, mdatacheck/MHFadcCam.h, mdatacheck/MHFadcPix.cc,
+     mdatacheck/MHFadcPix.h, mdatacheck/MFillHHillas.cc, 
+     mdatacheck/MFillHHillas.h
+     - added
+
+   * mdatacheck/MHistosAdc.[h,cc]:
+     - replaced by MHFadc[Cam,Pix]
+
+   * mdatacheck/MFillAdcSpect.[h,cc]:
+     - replaced by MFillHFadc
+
+   * macros/readCT1.C:
+     - uses the new classes now
+     - calculates and displays hillas
+
+   * manalysis/AnalysisLinkDef.h:
+     - added MCerPhotCalc, MImgCleanStd, MMcPedestalCopy
+
+   * manalysis/MCT1ReadAscii.cc:
+     - PreProcess uses FindCreateObj now
+
+   * manalysis/MCerPhotEvt.cc, manalysis/MPedestalCam.cc:
+     - changed the new back to 'new with placement'
+
+   * manalysis/MCerPhotEvt.[h, cc]:
+     - removed cleaning from this class
+
+   * manalysis/MHillas.cc:
+     - some small changes in the naming inside Calc()
+
+   * manalysis/MHillas.h:
+     - added Get-functions
+     
+   * manalysis/MPedestalCam.h:
+     - added InitSize-function
+     
+   * manalysis/MPedestalPix.h:
+     - made Get-functions const
+     
+   * manalysis/Makefile:
+     - added MMcPedestalCopy, MImgCleanStd, MCerPhotCalc
+     
+   * mbase/MLogManip.h:
+     - "l." before line number
+     
+   * mbase/MParList.cc:
+     - added the autodelete feature for automatically created classes
+     
+   * mdatacheck/DataCheckLinkDef.h:
+     - added MHFadc[Cam,Pix], MHHillas
+     - removed MHistosAdc
+     - added MFillHFadc, MFillHHillas
+     
+   * mdatacheck/MGDisplayAdc.[h,cc], MShowSpect.[h,cc],
+     mdatacheck/MViewAdcSpectra.[h,cc], :
+     - changed from MHistaosAdc to MHFadcCam
+     
+   * mdatacheck/Makefile:
+     - added MFillHFadc.cc, MFillHHillas.cc
+     - removed MFillAdcSpect.cc
+
+   * manalysis/MCT1ReadAscii.h, mbase/MEvtLoop.h, mbase/MLog.h,
+     mbase/MParList.h, mbase/MReadTree.h, mbase/MTask.h,
+     mbase/MTaskList.h, mdatacheck/MDumpEvtHeader.h,
+     meventdisp/MGFadcDisp.h, mgui/MCamDisplay.h,
+     mgui/MCamNeighbor.h, mgui/MGDataCheckMain.h,
+     mgui/MGEventDispMain.h, mgui/MGMarsMain.h,
+     mgui/MGMonteCarloMain.h, mgui/MGPrototyp.h, mgui/MHexagon.h,
+     mmontecarlo/MCollAreaTrigger.h, mraw/MRawEvtPixelIter.h,
+     mraw/MRawFileRead.h, mraw/MRawFileWrite.h:
+     - set version number to '0' (no i/o for this class)
+
+   * mgui/MGeomCamCT1.cc:
+     - new claculation algorith for the CT1 camera. It is more
+       exact in the camera plain
+       
+   * mgui/MHexagon.cc:
+     - removed Draw-function (it is inherited from TObject)
+     
+   * mmc/MMcFadcHeader.hxx:
+     - Added get-functions
+     
+
+
+
+ 2001/03/20: Thomas Bretz
+                                                                  
+   * manalysis/MPedestalPix.[h,cc], manalysis/MPedestalCam.[h,cc],
+     manalysis/MHillas.[h,cc], manalysis/MHillasCalc.[h,cc],
+     mgui/MGeomCamCT1.[h,cc], mgui/MGeomCamMagic.[h,cc]
+     - added
+
+   * macros/readCT1.C:
+     - added calculation of Hillas parameters
+     - changed from pointers to objects
+
+   * manalysis/AnalysisLinkDef.h, manalysis/Makefile:
+     - added MPedestalPix/Cam, MHillas, MHillasCalc
+
+   * manalysis/MCerPhotEvt.[h,cc]:
+     - removed fType
+     - commented out Draw function - should be fixed soon
+     - renamed *Nb* to *Num*
+     - renamed Get[Min,Max]NumPhotons to GetNumPhontons[Min,Max]
+
+   * meventdisp/MGFadcDisp.[h,cc]:
+     - changed parameter of ReadinEvent to unsigned
+
+   * mgui/GuiLinkDef.h, mgui/Makefile:
+     - added MGeomCamCT1, MGeomCamMagic
+
+   * mgui/MCamDisplay.[h,cc]:
+     - changed constructor argument from int to MGeomCam
+     - renamed *Nb* to *Num*
+
+   * mgui/MGeomCam.[h,cc]:
+     - removed all camara specific stuff
+     - MGeomCam is now used as a base class for the classes
+       MGeomCam[Magic,CT1] which are containing the camera specific stuff
+
+   * mgui/MGeomPix.h:
+     - added Set function
+
+
+
+ 2001/03/02: Thomas Bretz
+   
+   * manalysis/Makefile, mdatacheck/Makefile, meventdisp/Makefile,
+     mgui/Makefile: 
+     - new
+   
+   * mbase/MParList.[cc,h]: 
+     - Added FindCreateObj member function
+     - added a name to the constructor
+ 
+   * mbase/MReadTree.cc: 
+     - changed to use FindCreateObj
+
+   * mdatacheck/MDumpEvtHeader.cc: 
+     - removed fPixelIter from member list
+     - changed cout to *fLog
+   
+   * mdatacheck/MViewAdcSpectra.cc:
+     - removed a HUGE memory leak. All the objects in the list (and the
+       lists itself were NEVER deleted)
+   
+   * mdatacheck/MFillAdcSpect.cc
+     - removed fPixelIter from member list
+     - changed cout to *fLog
+     - changed to use FindCreateObj
+     - changed high and low to hi and lo
+   
+   * mdatacheck/MShowSpect.cc
+     - changed cout to *fLog
+     - added a name to the constructor
+   
+   * mraw/MRawFileRead.cc:
+     - changed to use FindCreateObj
+   
+   * mdatacheck/MGDisplayAdc.[h,cc]: 
+     - added some new member functions to make code more clear
+     - removed fHists from the destructor
+   
+   * mdatacheck/MHistosAdc.h:
+     - changed high and low to hi and lo
+
+   * macros/dohtml.C:
+     - added manalysis
+
+
+
+ 2001/03/01: Thomas Bretz
+
+   * Makefile: 
+     - added headers to dependencies
+ 
+   * Makefile.rules: 
+     - added headers to dependencies
+ 
+   * merpp.cc: 
+     - changed from pointers to objects
+     - added compression level support
+ 
+   * readraw.cc: 
+     - removed unnecessary includes
+ 
+   * mbase/MArray*.*: 
+     - changed all Int_t to UInt_t
+ 
+   * mbase/MLogManip.h: 
+     - changed name of __DINF__ to dbginf
+ 
+   * mraw/MRawCrateData.[h,cc], mraw/MRawEvtHeader.[h,cc],
+     mraw/MRawRunHeader.[h,cc]: 
+     - changed ifstream to istream
+     
+   * mraw/MRawEvtData.cc: 
+     - changed the reading, which speeds up merpp by a factor of 10
+   
+   * mraw/MRawEvtData.h: 
+     - added flag to InitArrays and DeletePixels 
+       (not yet used)
+
+   * mraw/MRawFileRead.h: 
+     - removed pParList from parameter list
+ 
+   * manalysis/AnalysisLinkDef.h
+     - removed MReadCT1Ascii, added MCT1ReadAscii
+     - added MCT1Pedestals
+   
+   * manalysis/MCerPhotEvt.[h,cc]:
+     - changed the constructor a little bit
+     - rewrote Print() to make it a bit more readable
+     - moved MCerphotPix to new File
+     - added many lines of comments
+     - exchanged old stylish new call with new stylish(=) one
+     - replaced all accesses to fPixels with the [] operator to make this
+       lines more readable
+     - made all variable declarations const-correct,
+     - I changed the style of the cleaning method from if(a){if()b{if(c){}}}
+       to if(!a)continue; if(!b)continue if(!c) continue; to make it more
+       compact, readable and easier to understand
+     - renamed the Boolean-functions to Is* to get a stricter structure
+     - replaced mapping function to access the pixel list entries by the new 
+       operator to get rid of more than the necessary number of member 
+       functions without loosing speed or readability
+     - renamed GetMinimum/MaximumPhoton to GetMin/MaxNumPhotons to be 
+       more exact
+   
+   * mgui/MCamGeom.* splitted and changed to MGeomCam/Pix:
+     - added a new operator to access the TObjArray
+     - removed unnecessary code from CreateCT1
+ 
+   * mbase/MAGIC.h: 
+     - added kPI
+ 
+   * mbase/MReadTree.cc: 
+     - added some comments
+ 
+   * mgui/MCamDisplay.[h,cc]: 
+     - added some comments, reordered a bit the calls in the constructor 
+       to get a 'straight forward structure', MGeomCam is now only
+       locally used where it is needed, replaced access to the 
+       TClonesArrays by new member-function to get a more readable code,
+       replaced old stylish new call with new stylish one, made
+       variable decleration const-correct, introduced a new member function
+       to set the pixel color, renamed the overloaded Draw functions to
+       DrawPhotons, DrawPhotErr to prevent missunderstatements, changed
+       the 'layout' of GetColor to make it easier to understand the algorithm,
+   
+   * mgui/MCamNeighbor.[h, cc]:
+     - changed to new log-interface
+     - exchanged -9999 by -1
+     - skipped the exits
+     - you must check for -1 one in any case
+     - this means a warning should be enough
+   
+   * mgui/MHexagon.[h,cc]:
+     - added new constructor whcih uses a MGeomPix-object
+
+
+
+ 2001/02/28: Thomas Bretz
+
+   * mbase/MParList.[h,cc]: 
+      - changed return type of FindObject back to TObject
+      - it seems so, that some compilers don't like overriding the
+        return type of a virtual member function
+
+
+
+ 2001/02/23: Thomas Bretz
+
+   * mraw/MRawEvtPixelIter.h: 
+      - added GetSum* functions
+
+   * mbase/MParList.[h,cc]: 
+      - Removed unnecessary fNext-stuff
+
+
+
+ 2001/02/22: Thomas Bretz
+
+   * merpp.cc, readraw.cc, mbase/MParContainer.cc, mbase/MParList.cc,
+     mbase/MParList.h, mbase/MReadTree.cc, mbase/MTask.cc, mbase/MTask.h,
+     mbase/MTaskList.cc, mbase/MTime.cc, mdatacheck/MDumpEvtHeader.cc,
+     mdatacheck/MShowSpect.cc, meventdisp/MGFadcDisp.cc, mgui/MGPrototyp.h,
+     mmc/MHeaderTrig.cxx, mraw/MRawCrateArray.cc, mraw/MRawEvtData.cc,
+     mraw/MRawEvtHeader.cc, mraw/MRawFileRead.cc, mraw/MRawFileWrite.cc,
+     mraw/MRawRunHeader.cc:
+      - exchanged cout with the new logging style (gLog, *fLog)
+
+   * mraw/MRawEvtData.cc: 
+      - added 'dec' option to Print
+  
+   * mmc/MHeaderTrig.cxx, mmc/MMcEvt.cxx, mmc/MMcTrig.cxx:
+      - small changes to the Print funtions
+
+
+
+ 2001/02/21: Thomas Bretz
+
+   * MRawEvtData.cc: 
+      - Changed ReadEvt according to the new raw binary format 2001/02/20
+     
+   * Added MLog.[h,cc], MLogManip.[h,cc]
+   
+   * Adde SetStreamer and fLog to the MParContainer base class
+   
+   * Derived MEvtLoop from MParContainer
+
+   * Makefile: 
+      - added 'tar'
+
+   * mbase/BaseIncl.h: 
+      - added fstream.h, TGListBox.h
+ 
+   * mbase/BaseLinkDef.h: 
+      - added pragma for gLog and MLog
+ 
+   * mbase/MAGIC.h: 
+      - added forward definition for gLog
+ 
+   * mbase/MEvtLoop.cc: 
+      - exchanged cout with *fLog
+      - added statements to provide log-facility to all tasks als parameter 
+        containers
+    
+   * mbase/MEvtLoop.h: 
+      - Small changes
+  
+   * mbase/MParContainer.h: 
+      - Added definitions necessary for use of Log-Facility
+  
+   * mbase/MParList.[h,cc]: 
+      - Added SetLogStream
+  
+   * mbase/MTask.h: 
+      - added fLog
+  
+   * mbase/MTaskList.[h,cc]: 
+      - added SetLogStream
+  
+   * mbase/Makefile: 
+      - Added MLog.cc, MLogManip.cc
+
+
+
+ 2001/02/19: Harald Kornmayer	
+
+  *  implemented the Image Cleaning a la CT1 to the class MCerPhotEvt
+  
+  *  changed the readCT1.C file to show the effects of the image cleaning
+     a la CT1
+
+  *  changed 
+	mgui/MCamNeighbor.cc
+	mananlysis/MCerPhotEvt.cc  .h 
+	macros/readCT1.C
+
+
+
+ 2001/02/19: Thomas Bretz
+
+   * MParContainer.h added prototypes for AsciiRead/Write
+
+   * .rootrc added
+
+   * MEvtLoop.[h,cc]: 
+      - split eventloop in its three parts, this should be used for 
+        debugging only.
+
+
+
+ 2001/02/06: Harald Kornmayer
+
+   *  the first running version with a eventdisplay. Now we are able
+      to display an Event on the photo electron level. To do this, run
+      the macro "macros/readCT1.C" after changing the file name. 
+
+      changed: 
+	macros/readCT1.C
+	manalysis/MNphotEvent.cc, manalysis/MNphotEvent.h
+	analysis/MReadCT1Ascii.cc
+	mgui/MCamDisplay.cc, mgui/MCamDisplay.h
+
+
+
+ 2001/01/23: Harald Kornmayer
+
+   *  the integration of the class FadcDisp in the mars enviroment
+      and further developments in the display
+
+      changed: 
+	meventdisp/MGFadcDisp.h
+	meventdisp/MGFadcDisp.cc
+	mgui/GuiIncl.h
+	mgui/GuiLinkDef.h
+	mgui/MGMarsMain.cc
+	mgui/MGPrototyp.cc
+	mgui/MGPrototyp.h
+	mgui/Makefile
+
+      added: 
+	mgui/MGEventDispMain.h
+	mgui/MGEventDispMain.cc
+
+
+
+ 2001/01/22: Harald Kornmayer
+
+   *  started with the development of a EventDisplay Utitliy. 
+      Therefore I added the following files. 
+
+      meventdisp/EvtDispIncl.h
+      meventdisp/EvtDispLinkDef.h
+      meventdisp/MGFadcDisp.cc
+      meventdisp/MGFadcDisp.h
+      meventdisp/Makefile
+
+      Also a few of the older files where slightly changed. 
+      ./Makefile
+      ./Makefile.rules
+      mraw/MRawEvtData.
+      
+
+
+ 2001/01/19: Thomas Bretz
+
+    * mmc/*.hxx:
+       - changed include of MDefineTrigger.h back
+
+
+
+ 2001/01/19: Oscar Blanch
+
+    * mmc/MTriggerDefine.h:
+       - added
+
+
+
+ 2001/01/18: Thomas Bretz
+
+    * Makefile:
+       - mmc-library added
+
+    * Makefile.conf.general:
+       - Added definition of __MARS__
+
+    * Makefile.rules:
+       - Added definitions to rootcint
+
+    * Oscar added the McFormat subdir of the Monte Carlo as mmc
+
+    * mmc/MMcEvt.h:
+       - renamed to MMcEvt.hxx
+
+    * mmc/*.hxx:
+       - added necessary defintions from MDefineTrigger.h
+
+    * mmc/Makefile, mmc/McLinkDef.h, mmc/McIncl.h, mmc/readme.txt:
+       - added
+
+    * mmc/LinkDef.h:
+       - removed
+
+
+
+ 2001/01/17: Thomas Bretz
+
+    * Makefile:
+       - Exchanged explicit rules to make library by implicit ones
+       - The shared object works now. I exchanged the libraries with the object
+         files. But I don't know why the libraries don't work.
+
+    * Makefile.conf.linux-gnu:
+       - replaced CC with gcc (instead of g++)
+
+    * mdatacheck/DataCheckLinkDef.h:
+       - removed unused statements
+
+    * mraw/RawLinkDef.h:
+       - added globals
+
+    * mraw/MerppLinkDef.h:
+       - removed unused file
+
+
+
+ 2001/01/12: Thomas Bretz
+
+    * MLinkDef.h, MIncl.h, marslogo.xpm, magiclogo.xpm:
+       - added
+
+    * LinkDef.h:
+       - removed
+
+    * Makefile:
+       - Added CINT, mrproper
+
+    * mbase/Makefile, mraw/Makefile, mgui/Makefile, mdatacheck/Makefile:
+       - included makefile.general, Makefile.rules,
+       - removes corresponding lines
+
+    * mdatacheck/MDumpEvtHeader.[h,cc], mdatacheck/MFillAdcSpect.[cc,h],
+      mdatacheck/MFillAdcSpect.[h,cc], mdatacheck/MGDisplayAdc.[cc,h],
+      mdatacheck/MHistsosAdc.[h,cc], mdatacheck.MShowSpect.[cc,h]
+       - changed include statements
+
+    * mgui/MGDataCheckMain.[cc,h], mgui/MGMarsMain.[cc,h]
+       - changed include statements
+       - move enum from h to cc
+       - removed comma operator from delete statements (nonsense)
+
+
+
+ 2001/01/11: Harald Kornmayer
+
+    * ./
+      readraw.cc, Makefile, Makefile.rules, LinkDef.h, MParList.cc, MReadTree.cc,
+      MReadTree.h, mbase/Makefile, mraw/Makefile
+       - small changes in this files. Not really critical.
+
+    * mars.cc
+       - added the main file for the gui
+
+    * mgui/
+      GuiIncl.h, MGMarsMain.cc, GuiLinkDef.h, MGMarsMain.h, MGDataCheckMain.cc,
+      Makefile, MGDataCheckMain.h
+       - added the subdir mgui and this files
+
+    * mdatacheck/
+      DataCheckIncl.h, DataCheckLinkDef.h, MHistosAdc.cc, MHistosAdc.h,
+      MDumpEvtHeader.cc, MDumpEvtHeader.h, MShowSpect.cc, MShowSpect.h,
+      MFillAdcSpect.cc, MFillAdcSpect.h, MViewAdcSpectra.cc, MViewAdcSpectra.h,
+      MGDisplayAdc.cc, MGDisplayAdc.h, Makefile
+       - added the subdir mdatacheck and this files
+
+
+
+ 2000/12/28: Thomas Bretz
+
+    * merpp.cc, MArray.cc, MArray.h, MArrayB.cc, MArrayB.h, MArrayS.cc,
+      MArrayS.h, MEvtLoop.cc, MEvtLoop.h, MInputStreamID.cc, MInputStreamID.h,
+      MParContainer.cc, MParContainer.h, MParList.cc, MParList.h, MReadTree.cc,
+      MTask.cc, MTask.h, MTaskList.cc, MTaskList.h, MTime.cc, MTime.h:
+       - Added changes some comments.
+
+    * MLoopEvt.cc, MLoopEvt.h:
+       - Removed
+
+
+
+ 2000/12/22 - Thomas Bretz:
+
+    * readraw.cc:
+       - changed some comments and the Root-Name of the program
+       - added check for the existance of the file
+       - changed name of numbers of entries from iEnt to nent
+
+    * dohtml.C:
+       - changed title of converted macros
+
+    * MRawEvtData.cc:
+       - added a commet in Draw()
+
+    * MRawEvtPixelIter.[h,cc]:
+       - Added the comment header of the file
+       - removed inheritance from TIterator (not needed)
+       - some changes to get it work (the one in the repository was untested
+         and not working)
+       - changed calling style of iterator from do...while to while-loop
+       - changed some comments
+
+    * MRawRunHeader.cc:
+       - added some comments
+
+    * Changelog, News: added
+
+    * test.C: removed
Index: /tags/Mars_V0-8-5/Mars/Changelog.03
===================================================================
--- /tags/Mars_V0-8-5/Mars/Changelog.03	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/Changelog.03	(revision 9661)
@@ -0,0 +1,7211 @@
+
+ 2003/12/23: Abelardo Moralejo
+
+   * manalysis/MExtractedSignalPix.cc
+     - in Clear(), initialized fExtractedSignalHiGain to 0 instead 
+       of -1. In MC files run without noise, the ADC info of pixels 
+       with no C-photons is missing. Later noise will be added to all 
+       pixels in the padding, and "empty" ones must have a 0 before 
+       the addition of this noise.
+
+   * manalysis/MGeomApply.cc
+     - initialized size of MPedPhotCam.
+
+   * manalysis/MMcCalibrationCalc.[cc,h]
+     - Removed setter function SetConversionHiLo: the ratio from high 
+       to low gain is now read from MMcFadcHeader, and set in ReInit.
+     - Fixed bug: fADC2PhOuter was initialized before the MMcFadcHeader
+       was available. Now it is done in ReInit.
+     - fPedPhotCam is now initialized in PreProcess and not in ReInit.
+     - fGeom is now set in ReInit (there should be one MGeomCam per
+       run header in the camera file).
+
+   * mmc/MMcFadcHeader.hxx
+     - added getter function GetLow2HighGain()
+
+
+
+ 2003/12/23: Thomas Bretz
+
+   * manalysis/MPedCalcPedRun.[h,cc]:
+     - removed fCounter
+     - replaced by GetNumExecutions()
+
+   * mraw/MRaw*:
+     - some changes and debug output for the upcomming time-stamp
+     - a fix to broken reading
+
+
+
+ 2003/12/23: Wolfgang Wittek
+
+   * macros/ONAnalysis.C
+     - new macro for the MAGIC analysis, corresponding to CT1Analysis.C
+
+   * macros/AnalyseCT1.C
+     - deleted because outdated
+
+   * manalysis/MPadOn.[h,cc]
+     - new class for the MAGIC analysis, corresponding to MCT1PadSchweizer
+
+   * manalysis/MPadOnOFF.[h,cc]
+     - minor changes (printouts)
+
+   * manalysis/MPedestalWorkaround.[h,cc]
+     - put zenith angle into MMcEvt
+
+   * manalysis/Makefile, manalysis/AnalysisLinkDef.h
+     - added MPadON
+
+   * mmc/MMcEvt.hxx
+     - add member function SetTelescopeTheta(), SetTelescopePhi()
+
+
+
+ 2003/12/22: Thomas Bretz
+ 
+   * manalysis/MCT1FindSupercuts.cc, manalysis/MFindSupercuts.cc:
+     - replaced MFRandomSplit by MFEventSelector
+   
+   * mfilter/FilterLinkDef.h, mfilter/Makefile:
+     - removed MFRandomSplit (functionality already implemented
+       in MFEventSelector)
+       
+   * mfilter/MFEventSelector.[h,cc]:
+     - did some cosmetics
+     - removed some obsolete data members
+     - added some comments
+     
+   * mfilter/MFEventSelector2.[h,cc]:
+     - added some comments
+
+   * macros/dohtml.C, macros/rootlogon.C:
+     - added mcalib
+     - added mhbase
+     
+   * macros/estfit.C:
+     - get chisq from MParameterD
+     
+   * manalysis/MEventRateCalc.cc:
+     - added comments
+     
+   * mbase/MParContainer.h:
+     - added a comment
+     
+   * mhist/MHCamera.h:
+     - added default argument for DrawClone
+     
+   * mmontecarlo/MMcEnergyEst.cc:
+     - use an MParameterD instead of accessing MChisqEval
+     
+   * mtools/MChisqEval.[h,cc]:
+     - write result to an MParameterD
+
+   * mtools/MTFillMatrix.[h,cc]:
+     - some more features
+
+
+
+ 2003/12/21: Thomas Bretz
+
+   * mcalib:
+     - new directory containing all MCalib* and MHCalib* classes
+
+   * manalysis/MCalib*:
+     - moved to mcalib
+
+   * mhist/MHCalib*:
+     - moved to mcalib
+
+   * Makefile:
+     - added mcalib
+
+   * manalysis/Makefile, manalysis/AnalysisLinkDef.h:
+     - removed MCalib*
+
+   * mhist/Makefile, mhist/HistLinkDef.h:
+     - removed MHCalib*
+
+   * mhbase:
+     - new directory containing base classes for histogram stuff
+
+   * mhist/MFillH.[h,cc], mhist/MBinning.[h,cc], mhist/MWeight.[h,cc],
+     mhist/MH.[h,cc], mhist/MH3.[h,cc], mhist/MHArray.[h,cc],
+     mhist/MHMatrix.[h,cc]:
+     - moved to mhbase
+
+   * mhist/Makefile, mhist/HistLinkDef.h:
+     - removed MFillH, MBinning, MWeight, MH, MH3, MHMatrix and MHArray
+
+   * */Makefile:
+     - updated include paths accordingly
+
+
+
+ 2003/12/20: Abelardo Moralejo
+
+   * manalysis/MMcCalibration.[h,cc]
+     - adapted to changes in calibration classes. Removed SetADC2PhOuter
+       (ratio of inner to outer can be found from MMcFadcHeader).
+
+   * mananalysis/MCalibrate.cc
+     - commented out check of sizes of MExtractedSignal and 
+       MCalibrationCam (they are different in MC when no noise is 
+       simulated).
+
+   * mmc/MMcFadcHeader.hxx
+     - added getter function for fAmplitudOuter.
+
+
+
+ 2003/12/20: Thomas Bretz
+
+   * Makefile:
+     - added an option to statically link the programs (for
+       debugging)
+       
+   * merpp.cc, readdaq.cc, readraw.cc:
+     - small changes to the command line options
+       (the aim is a generalization)
+
+   * manalysis/MCalibrate.[h,cc]:
+     - removed leading '//' from class description
+     - removed usage of MGeomCam (it is obsolete here)
+     - small changes to make the output fit the 'standard'
+     - take the number of pixels from the containers, added a
+       consistency check
+     - added many small comment about future development
+     - added some const-qualifiers
+     - removed the 'unused/empty' pixels. They are obsolete and not
+       wanted at all.
+     - changed pixid to pixidx
+
+   * manalysis/MCalibrationPix.h:
+     - sorted member functions
+     - added some const qualifiers
+     - added many small comment about future development
+
+   * manalysis/MExtractSignal.[h,cc]:
+     - removed arguments from constructor
+     - added corresponding member functions
+       + the convetion is to have only vital arguments in the
+         construtor and member functions to change the default
+     - removed obsolete PostProcess
+     ! PLEASE update you code accordingly.
+     
+   * manalysis/MExtractedSignalCam.h, manalysis/MExtractedSignalPix.h:
+     - added corresponding member functions
+   
+   * mbase/MArgs.[h,cc]:
+     - added some comments
+     - added options/arguments to Print
+     - added GetNumOptions
+     - added GetNumEntries
+     - added HasOnly
+     - added HasOnlyAndRemove
+     
+   * mbase/MEvtLoop.[h,cc]:
+     - removed leading '//' from class description
+     - replaced INT_MAX by kMaxUInt
+     - changed meaning of eventloop argument:
+       now 0 means all-events instead of -1
+     - forward tlist-name from Eventloop to PreProcess
+   
+   * mbase/MTime.[h,cc]:
+     - added UpdMagicTime
+
+   * mfilter/MFEventSelector2.cc:
+     - replaced INT_MAX by kMaxUInt
+     
+   * mmain/MEventDisplay.[h,cc]:
+     - make use of MEvtLoop::GetTaskList()
+     - removed GetReader
+     
+   * mmontecarlo/MMcEnergyEst.cc:
+     - removed leading '//' from class description
+     
+   * mranforest/MRanTree.cc:
+     - removed leading '//' from class description
+     - replaced 1e20 by FLT_MAX
+   
+   * mraw/MRawEvtHeader.[h,cc], mraw/MRawFileRead.cc,
+     mraw/MRawRead.[h,cc], mraw/MRawRunHeader.cc,
+     mraw/MRawSocketRead.cc:
+     - added decoding of time from event header - UNTESTED!
+     
+   * mreport/MReportRun.h:
+     - set class verseion to 0 -- not ment for writing at the
+       moment
+
+   * mtools/MTMinuit.[h,cc]:
+     - added (will replace MMinuitInterface soon)
+
+   * mtools/ToolsLinkDef.h, mtools/Makefile:
+     - added MTMinuit
+
+
+
+ 2003/12/19: Markus Gaug, Michele Doro
+
+   * manalysis/MExtractSignal.[h,cc], manalysis/MCalibrate.[h,cc],
+     manalysis/MCalibrationCalc.[h,cc], manalysis/MCalibrationPix.[h,cc]:
+     - Treatment of the conversion factors between HI Gain and Lo Gain
+       is now done in the MCalibrationPix. 
+
+       MExtractSignal does not convert anymore, but MCalibrate searches 
+       the conversion factor from MCalibrationPix.
+       This allows for different conversion factors for every pixel.
+
+
+
+ 2003/12/18: Abelardo Moralejo
+
+   * manalysis/Makefile, AnalysisLinkDef.h
+     - Added missing classes MPedPhotCam, MPedPhotPix
+
+   * manalysis/MMcCalibrationCalc.[h,cc]
+     - Changed names of conversion factors, because their meaning 
+       changed from "ADC->photoelectrons" to "ADC->photons before 
+       the PM". Added some comments. Added calls to MCalibrationPix::
+       SetBlindPixelMethodValid() and SetConversionBlindPixelMethod()
+
+   * manalysis/MCalibrate.cc
+     - Corrected variable names: Convertion -> Conversion, and also
+       removed the "f" at the beginning of local (non-member) variables.
+     - Added fGeomCam, fPedPhotCam (created in the PreProcess).
+
+
+
+ 2003/12/18: Markus Gaug, Michele Doro
+
+   * manalysis/MExtractSignal.[h,cc]
+     - introduced a third argument in the constructor: Byte_t logainshift
+
+   * manalysis/MCalibrationCam.cc
+   * manalysis/MCalibrationPix.cc
+     - introduced error calculation for the F-Factor method
+
+   * manalysis/MCalibrate.cc
+     - replace pix.IsValid by pix.IsBlindPixelMethodValid() which more 
+       what is checked exactly
+  
+   * macros/calibration.C
+     - display now the errors in the F-Factor method correctly	
+
+   * mhist/MHCalibrationPixel.[h,cc]
+     - before declaring a calibration factor as valid, check if the 
+       mean fitted arrival time is not in the first or last time bin
+
+
+
+ 2003/12/18: Abelardo Moralejo
+
+   * manalysis/MCalibrate.cc
+     - Changed  "if (!fCalibrations)" to "if (!fGeomCam)" in 
+       preprocess (this was a cut-and-paste error).
+     - In Process: added "fCerPhotEvt->AddPixel(pixid, 0., 0.)" before
+       setting pixel pixid to unused, in case !pix.IsValid()
+       May be removing both commands (adding the pixel and setting it 
+       to unused would have the same effect). 
+
+
+
+ 2003/12/18: Thomas Bretz
+
+   * mfilter/MFSoftwareTrigger.[h,cc]:
+     - added - code taken from M[CT1]SelBasic
+
+   * mfilter/Makefile, mfilter/FilterLinkDef.h:
+     - added MFSoftwareTrigger
+
+   * manalysis/MExtractedSignalPix.h:
+     - added missing const-qualifier IsLoGainUsed
+
+   * mreport/MReportFileRead.[h,cc]:
+     - added support for line counter
+
+   * mreport/MReportRun.[h,cc]:
+     - added preliminary version to decode the Start/Stop run tags
+       in the report files.
+
+   * mreport/Makefile, mreport/ReportLinkDef.h:
+     - added MReportRun
+
+   * merpp.cc:
+     - added a first implementation to be able searching report
+       files for the run number
+
+   * mdata/MDataMember.[h,cc]:
+     - implemented a way to determin whether the data member is 
+       a floating point value or an integer
+
+   * mfilter/MFDataMember.[h,cc]:
+     - use the information to treat integer values more accuratly
+
+   * mbase/MAGIC.h:
+     - change minimum root version to 3.05/06
+
+   * mtools/MTFillMatrix.cc:
+     - added a check whether the file name is valid
+
+
+
+ 2003/12/18: Abelardo Moralejo
+
+   * mmc/MMcConfigRunHeader.[h,cc]
+     - Removed some obsolete parameters no longer used in reflector 
+       simulation since version 0.6.
+     - Updated version number to 2 !
+     - Added getter and setter functions for fPointSpread (allows 
+       camera simulation to change the value whenever the spot is made
+       bigger to fit the data).
+
+
+ 2003/12/17: Abelardo Moralejo
+
+   * manalysis/MExtractSignal.cc
+     - put SetNumPixelUsedFADCSlices into the ReInit, otherwise they 
+       are not accessible for MCalibrationCalc
+
+   * manalysis/MCalibration*
+   * mhist/MHCalibration*
+     - many small changes, mostly cosmetic
+
+
+
+ 2003/12/17: Abelardo Moralejo
+
+   * mbase/MAGIC.h:
+     - added kELECTRON, kPOSITRON to type ParticleId_t;
+
+   * mfilter/MFGeomag.cc:
+     - added kPOSITRON and kELECTRON as possible particle ids.
+     - added fResult = 0 for the case kGAMMA,  !fGamm_elec, to let
+       real gammas be accepted by the filter.
+
+
+
+ 2003/12/17: Thomas Bretz
+
+   * mreport/MReportCC.[h,cc]:
+     - added report storing weather data
+
+   * mreport/Makefile, mreport/ReportLinkDef.h:
+     - added MReportCC
+
+   * mtools/Makefile, mtools/ToolsLinkDef.h:
+     - added MTFillMatrix
+
+   * mtools/MTFillMatrix.[h,cc]:
+     - added
+
+   * mfilter/MFEventSelector2.[h,cc]:
+     - removed fUseOrigDistrib --> use a reference histogram with 
+       0 Entries instead.
+
+   * manalysis/MCT1FindSupercuts.[h,cc], manalysis/MFindSupercuts.[h,cc]:
+     - removed fUseOrigDistrib accoring to href.GetEntries()==0 used in
+       MFEventSelector2 and MFillMatrix
+
+   * macros/CT1Analysis.C, macros/ONOFFAnalysis.C, 
+     macros/ONOFFCT1Analysis.C:
+     - tried to make fUseOrigDistrib-stuff working again
+
+   * mhist/MHCamera.[h,cc]:
+     - implemented kVariance
+
+
+
+ 2003/12/16: Javi Lopez
+
+   * manalysis/MCalibrate.[h,cc]
+     - new classe that takes the integrated charge from MExtractedSignal
+       container and apply the calibration constants stored in
+       MCalibrationCam container storing the number of photons in
+       MCerPhotEvt.
+
+
+
+ 2003/12/16: Thomas Bretz
+
+   * mhist/MHSimulatedAnnealing.[h,cc], 
+     mhist/MSimulatedAnnealing.[h,cc]:
+     - fixed includes
+
+
+
+ 2003/12/12: Markus Gaug 
+
+   * manalysis/MSimulatedAnnealing.[h,cc]
+   * mhist/MHSimulatedAnnealing.[h,cc]
+     - new classes to do a minimization after the Simulated Annealing 
+       procedure. Please do make dox and look into the class documentation
+       to know how to use it
+
+   * manalysis/Makefile
+   * mhist/Makefile
+   * manalysis/AnalysisLinkDef.h
+   * mhist/HistLinkDef.h
+     - added the SimulatedAnnealing Classes
+
+
+
+ 2003/12/12: Markus Gaug / Michele Doro
+
+   * manalysis/MCalibrationCam.[h,cc]
+   * manalysis/MCalibrationPix.[h,cc]
+   * manalysis/MCalibrationBlindPix.[h,cc]
+   * manalysis/MCalibrationConfig.[h,cc]
+     - bug found transforming the number of photons from the blind pixel 
+       to the inner pixel. The previous results were wrong by a factor 2
+     - PIN Diode formally included
+     - Code better documented in MCalibrationCam
+
+
+
+ 2003/12/15: Thomas Bretz
+
+   * mraw/MRawRead.[h,cc]:
+     - added
+
+   * mraw/Makefile, mraw/RawLinkDef.h:
+     - added MRawRead
+
+   * mraw/MRawSocketRead.[h,cc], mraw/MRawFileRead.[h,cc]:
+     - changed such, that it derives from MRawRead now
+
+   * mfilter/MFAntiFilter.[h,cc]:
+     - removed. This function is implemented in MFilterList
+
+   * merpp.cc:
+     - enhanced to support start/stop time
+
+   * manalysis/MEventRateCalc.cc:
+     - removed some stuff which was commented out
+     
+   * mbase/MTime.cc:
+     - small change to GetString
+     
+   * mhist/MHCamera.cc:
+     - made the inverse deep blue dea palette the default
+       (FIXME: Make this a resource)
+     
+   * mreport/MReport.[h,cc]:
+     - added MTime arguments to Interprete
+     
+   * mreport/MReportFileRead.[h,cc]:
+     - added MTime arguments to Interprete
+     - added fStart/fStop data member
+
+
+
+ 2003/12/15: Abelardo Moralejo
+
+   * mgeom/MGeomCam.h
+     - made the CalcPixRatio function public.
+
+   * manalysis/MGeomApply.cc
+     - call the CalcPixRatio of the MGeomCam object. Workaround to 
+       allow the analysis of some files from a beta version of camera 
+       0.7 in which the array containing pixel ratios was not 
+       initialized.
+
+
+
+
+
+ 2003/12/12: Markus Gaug / Michele Doro
+
+   * manalysis/MCalibrationCam.cc
+     - did not compile because of a wrong command to MCalibrationPix, 
+       now corrected
+
+
+
+ 2003/12/12: Nadia Tonello
+
+   * mimage/MImgCleanStd.cc
+     - now the cleaning of rings>1 is done symmetrically around the core
+       pixels (bug solved)  
+
+
+
+ 2003/12/12: Abelardo Moralejo
+
+   * manalysis/MMcCalibrationCalc.[h,cc]
+     - added fADC2PheInner, fADC2PheOuter and setter functions. Put 
+       these values into MCalibrationCam. Look for MExtractedSignalCam
+       to check which gain branch has been used (relevant for the
+       conversion factor) for each pixel.
+
+
+
+ 2003/12/12: Markus Gaug
+	
+   * manalysis/MExtractSignal.[h,cc]
+     - now with constructor allowing to set the first and last used
+       time slice
+     - (default like before)
+     - extract number of pixels from MGeomCam
+
+
+
+ 2003/12/12: Sabrina Stark
+  
+   * mfilter/MFSelBasic.[h,cc]
+     - new class for MAGIC analysis, corresponding to MFCT1SelBasic	
+
+   * mfilter/MFSelStandard.[h,cc]
+     - new class for MAGIC analysis, corresponding to MFCT1SelStandard	
+
+   * mfilter/MFSelFinal.[h,cc]
+     - new class for MAGIC analysis, corresponding to MFCT1SelFinal	
+
+   * mfilter/Makefile, mfilter/FilterLinkDef.h
+     - include MFSelBasic, MFSelStandard, MFSelFinal	
+
+   * manalysis/MPadONOFF.[h,cc]
+     - new class for MAGIC analysis, corresponding to MPadONOFF		
+
+   * manalysis/MSupercuts.[h,cc]
+     - new class for MAGIC analysis, corresponding to MCT1Supercuts		
+   
+   * manalysis/MSupercutsCalc.[h,cc]
+     - new class for MAGIC analysis, corresponding to MCT1SupercutsCalc		
+   
+   * manalysis/MFindSupercuts.[h,cc]
+     - new class for MAGIC analysis, corresponding to MCT1FindSupercuts		
+
+   * manalysis/MPedestalWorkaround.[h,cc]
+     - temporary task for MAGIC analysis to copy pedestal values and
+ 	RMS from MPedPhotCam to MPedestalCam	
+
+   * manalysis/Makefile, manalysis/AnalysisLinkDef.h
+     - include MPadONOFF, MSupercuts, MSupercutsCalc, MFindSupercuts,
+	MPedestalWorkaround	
+	
+   * mhist/MHSupercuts.[h,cc]
+     - new class for MAGIC analysis, corresponding to MHCT1Supercuts		
+
+   * mhist/Makefile, mhist/HistLinkDef.h
+     - include MHSupercuts
+
+   * macros/ONOFFAnalysis.C:
+     - adaption of ONOFFCT1Analysis to apply on Magic data
+	
+	
+ 
+ 2003/12/12: Markus Gaug
+
+   * manalysis/MExtractedSignalPix:
+     - Added fTailArrivalTime
+
+   * manalysis/MExtractSignals:
+     - SetArrivalTimes modified to 3 arguments (sorry!)
+
+
+
+ 2003/12/11: Sebastian Raducci & Villi Scalzotto
+
+   * manalysis/MArrivalTime.[h,cc]
+     - Added (new container)
+     - Preliminary version: do not use it
+
+   * manalysis/MArrivalTimeCalc.[h,cc]
+     - Added (new task)
+
+   * mraw/MRawEvtPixelIter.[h,cc]
+     - Added new method GetIdxMaxHiLoGainSample()
+   
+   * mraw/MRawEvtData.cc
+     - Added new case in GetPixelContent() method 
+
+   * mmain/MEventDisplay.cc
+     - Added new tab in the camera event display to show the arrival
+       time.
+
+   * mhist/MHEvent.[h,cc]
+     - Added new fType in the enumeration to handle the arrival time
+       histos
+
+
+ 2003/12/11: Abelardo Moralejo
+
+   * manalysis/MGeomApply.cc
+     - Initialize size of the MCalibrationCam object according to 
+       camera geometry.
+
+   * manalysis/MMcCalibrationCalc.[h,cc]
+     - Added. First draft of a class to get the calibration 
+       constants for the analysis of MC events.
+
+   * manalysis/Makefile, AnalysisLinkDef.h
+     - Added new class MMcCalibrationCalc
+
+
+ 2003/12/11: Markus Gaug
+
+   * manalysis/MExtractSignal, MExtractedSignalPix
+     - Store number of used FADC slices (HIGain, LoGAin)
+     - calculate signal with only 6 most significant slices (2 before, 
+       4 after the maximum)
+
+   * mhist/MHCalibrationBlindPixel:
+     - do the consistency check fitting the pedestal
+
+   * mhist/MHCalibrationPixel:
+     - store Hi Gain vs. Lo Gain values to extract the conversion
+       factor
+
+   * manalysis/MCalibrationPix:
+   * manalysis/MCalibrationCam:
+     - separate Hi Gain and Lo Gain
+     - include return of PIN Diode measurement
+
+
+
+ 2003/12/11: Thomas Bretz
+
+   * mbase/MTime.[h,cc]:
+     - small change to GetString
+     - added ReadBinary
+     
+   * mraw/MRawCrateData.[h,c], mraw/MRawFileRead.cc, 
+     mraw/MRawEvtData.[h,cc], mraw/MRawEvtPixelIter.[h,cc],
+     mraw/MRawRunHeader.[h,cc], mraw/MRawSocketRead.cc,
+     mraw/MRawCrateArray.[h,cc]:
+     - adapted to new DAQ file format Version 2
+     - changed ClassDef version accordingly
+
+   * mraw/RawIncl.h:
+     - added TArrayC
+
+   * mfileio/MCT1ReadPreProc.cc:
+     - tried to change reading CT1 data accordingly
+
+
+
+ 2003/12/10: Thomas Bretz
+
+   * manalysis/MPedPhotPix.[h,cc], manalysis/MPedPhotCam.[h,cc]:
+     - added
+
+   * merpp.cc:
+     - added support for dc report files
+     
+   * mcamera/CameraLinkDef.h, mcamera/Makefile:
+     - added MCameraDC
+     
+   * mhist/MHVsTime.cc:
+     - fixed a missing initialisation
+
+   * mraw/MRawFileRead.cc:
+     - fixed wrong MRawEvtTime name
+     
+   * mreport/MReport.cc:
+     - fixed reading of dc files
+     
+   * mreport/MReportCurrents.[h,cc]:
+     - do not store currents here. store it in MCameraDC
+     
+   * mreport/MReportFileRead.[h,cc]:
+     - added SetHasNoHeader and kHasNoHeader
+
+   * macros/readcurrents.C:
+     - fixed accordingly
+
+   * macros/sumcurrents.C:
+     - fixed accordingly
+
+
+
+ 2003/12/09: Markus Gaug
+
+   * mhist/MHCamera.[h,cc]:
+     - added SetCamError to set errors in the camera
+
+   * mhist/MHCalibration*:
+     - all hists doubles to separate High Gain and Low Gain
+
+   * manalysis/MCalibration*
+     - separate Hi Gain and Lo Gain
+     - use MExtractedSignalCam to extract charges
+
+   * manalysis/MExtractSignals.[h,cc]:
+     - new class to extract signals
+
+   * manalysis/MExtractedSignalCam.[h,cc]:
+     - new class to hold extracted signals
+
+   * manalysis/MExtractedSignalPix.[h,cc]:
+     - new class to hold extracted signals for pixel
+
+   * manalysis/Makefile
+   * manalysis/AnalysisLinkDef:
+     - contain MExtractedSignalCam, MExtractedSignalPix, MExtractedSignal
+
+   * macros/calibration.C
+     - EventDisplay which allows to get plot by clicking on pixel
+
+
+
+ 2003/12/08: Thomas Bretz
+
+   * mraw/MRawFileRead.cc:
+     - implemented an artificial time-stamp for the current data
+
+   * star.cc, macros/star.C:
+     - works now with MC files and real data.
+
+   * mimage/MHillas.[h.cc], mimage/MHillasExt.[h.cc], 
+     mimage/MHillasSrc.[h.cc]:
+     - implemented member functions Print(const MGeomCam&)
+
+   * macros/readMagic.C, macros/readCT1.C, mmain/MEventDisplay.cc:
+     - changed to display deg instead of millimeters
+
+   * manalysis/MEventRateCalc.[h,cc], manalysis/MEventRate.[h,cc]:
+     - updated algorithm
+
+   * macros/evtrate.C:
+     - tutorial how to calculate event rate added
+
+
+
+ 2003/12/07: Thomas Bretz
+
+   * mbase/MTime.[h,cc]:
+     - added some new member function
+     - fixed wrong calculations
+     - moved all stand-alone operators into class
+     
+   * mhist/MHPixVsTime.cc, mhist/MHVsTime.cc:
+     - fixed MTime handling
+
+   * Makefile.rules:
+     - removed obsolete $(HEADERS) from rule for $(LIB)
+     - added $(CINT)LinkDef.h for rule for $(CINT)Cint.cc
+     
+   * mbase/BaseLinkDef.h:
+     - added operator<<(ostream&, MTime&)
+     
+   * mmain/MOnlineDump.cc:
+     - fixed a small bug using MTime
+
+
+
+ 2003/12/05: Abelardo Moralejo
+ 
+   * mhistmc/MHMcCollectionArea.cc
+     - removed wrong comment in MHMcCollectionArea::CalcEfficiency2
+
+
+
+ 2003/12/05: Thomas Bretz
+
+   * mpointing/*:
+     - added
+
+   * Makefile:
+     - added mpointing
+
+   * NEWS:
+     - updated
+
+   * mbase/MTime.[h,cc]:
+     - complere rewrite of the data members
+     - ClassDef=3
+
+   * mfileio/MCT1ReadPreProc.cc, mfileio/MReadCurrents.cc,
+     mfileio/MReadReports.cc, mhist/MHPixVsTime.cc,
+     mhist/MHVsTime.cc, mmain/MOnlineDump.cc,
+     mmontecarlo/MMcTimeGenerate.cc, mreport/MReport.cc,
+     manalysis/MEventRateCalc.cc:
+     - adapted to new MTime
+
+   * mfileio/MReadReports.[h,cc]:
+     - added the possibility to enable Auto Scheme
+     - delete the TChains when removed
+
+   * mfileio/MWriteRootFile.[h,cc]:
+     - automaticalle create title for Trees
+     - added a 'Must-Have' flag for the added containers
+
+   * mreport/MReportCamera.h:
+     - added //! to all pointers
+
+   * mtools/MAstro.[h,cc]:
+     - added calculations from and to MJD
+     - moved to mbase
+
+   * mfileio/Makefile, mfileio/FileIOLinkDef.h:
+     - removed MReadCurrent
+
+   * readdaq.cc:
+     - changed to display board information on request 
+       (MRawCrateArray)
+
+   * mfileio/MReadMarsFile.cc:
+     - small changes to output
+     
+   * mfileio/MReadReports.[h,cc]:
+     - added 'Master' tree as a workaround for reading RunHeaders
+     
+   * mfileio/MReadTree.cc:
+     - call Notify() of all members of fNotify in Notify()
+     
+   * mraw/MRawCrateArray.[h,cc]:
+     - added Print() member function
+     
+
+
+
+ 2003/12/04: Markus Gaug
+
+   * manalysis/MCalibration*
+     - implemented some of Thomas Bretz suggestions to make the code
+       nicer
+     - implemented the possibility to have cosmics in the calibration
+       data and remove it
+     - implemented the conversion factors for the blind pixel method
+
+   * mhist/MHCalibration*
+     - implemented some of Thomas Bretz suggestions to make the code
+       nicer
+     - implemented the possibility to have cosmics in the calibration
+       data and still fit it
+
+   * macros/calibration.C
+     - MStatusDisplay of calibration histograms a little bit more readable
+
+
+
+ 2003/12/03: Abelardo Moralejo
+
+   * mimage/MStereoCalc.cc
+     - Fixed typo in the PreProcess (fmcevt1 was initialized a second
+       time, instead of fmcevt2).
+
+
+
+ 2003/12/02: Abelardo Moralejo
+
+   * mimage/MStereoCalc.[h,cc]
+     - changed names of variables (removed underscores). Use new
+       function MTask::AddSerialNumber  (see below).
+
+
+
+ 2003/12/02: Thomas Bretz
+ 
+   * mfilter/MFEventSelector2.[h,cc]:
+     - fixed and reorganized screen output
+     - added some small comments to the code
+     - moved some code from Process() to the new private function Select
+     - fixed uncounted events (underflow bins were not counted)
+     - renamed nonsens fErrors to fCounter
+     - fixed usage of fDisplay
+
+   * manalysis/MEventRate.[h,cc], manalysis/MEventRateCalc.[h,cc], 
+     mfileio/MReadReports.[h,cc], mreport/MReport*.[h,cc],
+     mcamera/MCamera*.[h,cc]:
+     - fixed and added comments.
+
+   * mbase/MTask.h:
+     - added static member functions AddSerialNumber to simplify 
+       using different Serial numbers.
+
+   * macros/readrep.C:
+     - updated to be an example for more functionality
+
+
+
+ 2003/12/01: Markus Gaug
+ 
+   * macros/calibration.C:
+     - adjusted some parameters
+
+   * manalysis/MCalibrationCalc.cc:
+     - cosmics are now skipped from the fit
+
+   * manalysis/MCalibrationPix:
+     - cosmics are now skipped from the fit
+
+   * mhist/MHCalibrationPixel:
+     - cosmics are now skipped from the fit
+
+   * manalysis/Makefile
+     - MPedCalcPedRun was not in Makefile
+
+   * manalysis/AnalysisLinkDef
+     - MPedCalcPedRun was not in AnalysisLinkDef
+
+
+
+ 2003/12/01: Thomas Bretz
+
+   * Makefile:
+     - added readdaq
+ 
+   * mona.cc:
+     - moved MOnlineDump behind hfilla/../d
+     
+   * macros/readrep.C:
+     - removed obsolete piece of code
+     - added 'writer'
+     - added code to read from file
+     
+   * mbase/MStatusDisplay.cc:
+     - removed obsolete workaround in HandleEvent. Found the bug
+       in MEventDisplay
+       
+   * mmain/MEventDisplay.cc:
+     - fixed a crash when switching to a tab without canvas
+     
+   * mmain/MOnlineDisplay.[h,cc]:
+     - removed obsolete code
+     
+   * mmain/MOnlineDump.cc:
+     - set maximum and minimum of 'sum' histogram to 0 and 15
+     
+   * mtemp/MObservatory.cc:
+     - changed telescope position (kMagic1) according to new data from GPS clock
+
+   * readraw.cc:
+     - changed includes
+     
+   * mbase/MPrint.[h,cc]:
+     - added kSeperator
+
+   * mbase/MTime.[h,cc]:
+     - added SetTime(const TTime&)
+
+   * mraw/MRawEvtHeader.cc:
+     - added 'nogains' option to Print
+     
+   * readdaq.cc:
+     - added
+
+   * mfilter/MFilterList.cc:
+     - added class description
+
+   * mfilter/FilterLinkDef.h, mfilter/Makefile:
+     - removed obsolete MFAntiFilter (for a replacement see
+       class-description of MFilterList)
+       
+   * mfilter/MFRandomSplit.[h,cc]:
+     - fixed missing manipulators in fLog stream
+     - reset values in constructor which are out of range
+     - changed output in PostProcess according to the style in MHillasCalc etc.
+     - changed nonsense derivement from MF to MFilter
+
+   * mhist/MHCamera.[h,cc]:
+     - added DrawClone to get rid of the usage of gROOT->GetSelectedPad.
+       this resulted in some trouble in the past. If it will make more
+       trouble than before we can remove it again - please report problems.
+
+
+
+ 2003/12/1: Abelardo Moralejo
+
+   * mimage/MStereoPar.cc
+     - Added calculation of fCT1Impact2, fCT2Impact2, the estimates of
+       impact parameter using the a priori assumption that the events
+       come from a point source located at the center of the camera.
+
+
+
+ 2003/11/27: Wolfgang Wittek
+
+   * mfilter/MFEventSelector2.cc
+     - if number of requested events is too high reduce it to the maximum
+       number possible
+     - introduce the flag 'fUseOrigDistribution'; if it is set to kTRUE 
+       (by SetOrigDistribution()) the original distribution will be used
+       as the nominal distribution
+     - added member functions SetUseOrigDistribution()
+     - added member functions SetHistOrig()
+
+   * mfilter/MFRandomSplit.[h,cc]
+     - a filter which gives fResult = kTRUE with a certain probability
+
+   * mfilter/MFAntiFilter.[h,cc]
+     - a filter which checks the result of a given filter and returns 
+       the opposite result;
+       Thomas : could you please add a code which puts the filter whose 
+                result is checked into the task list ?
+
+   * mfilter/Makefile, mfilter/FilterLinkDef.h
+     - add MFRandomSplit and MFAntiFilter
+
+   * manalysis/MCT1FindSupercuts.[h,cc]
+     - in 'DefineTrainMatrix', 'DefineTestMatrix', and 
+       'DefineTrainTestMatrix()' :
+       replace call to 'MFEventSelector' by call to 'MFEventSelector2'
+     - add member function SetUseOrigDistribution(Bool_t b);
+       if b = kTRUE the events for the training and test samples are
+       selected randomnly from the input file
+
+
+
+ 2003/11/27: Abelardo Moralejo
+
+   * mdata/MDataChain.cc:
+     - added ';' as a possible alphanumeric character in the data 
+       string, to support the use of variables from MC stereo files
+       where the parameter containers for each telescope are tagged 
+       with a ';' followed by the telescope number. 
+
+
+
+ 2003/11/26: Thomas Bretz
+
+   * mhist/MHVsTime.[h,cc]:
+     - implemented usage of Event number
+
+   * mhist/MHPixVsTime.[h,cc]:
+     - implemented usage of time (untested - may not work)
+
+
+
+ 2003/11/25: Thomas Bretz
+ 
+   * mgeom/MGeomMirror.h:
+     - added Getter functions for Mirror Center and Mirror 
+       Normal vector
+
+
+
+ 2003/11/25: Abelardo Moralejo
+
+   * mimage/MStereoPar.[h,cc]
+   * mimage/MStereoCalc.[h,cc]
+     - Added. First version of some calculations for the data analysis
+       of two-telescope configurations (estimation of shower direction
+       and core position).
+   * mimage/Makefile, ImageLinkDef.h
+     - Updated accordingly.
+
+
+
+ 2003/11/23: Thomas Bretz
+
+   * star.cc:
+     - fixed a typo
+     
+   * manalysis/MCerPhotCalc.cc:
+     - fixed logging stream
+     
+   * mbase/MStatusDisplay.[h,cc]:
+     - made fLog available to derived classes
+     - added Reset()-function
+     - added some debug messages to CloseWindow()
+     - put 'return' back into HandleConfigureNotify (fixes the
+       problem with the random size of the Mona display)
+     - added a new workaround in HandleEvent which fixed a crash
+       when switching back to the 'main' tab in MEventDisplay
+       This is NOT understood!
+     - changed bit 14/15 to 15/16. BIT(14) is used in TGMainFrame
+       already
+     - fixed a typo. Must be kTabPrint instead of kFilePrint
+     
+   * mfilter/MFRealTimePeriod.h:
+     - added Setter for timeout
+     
+   * mhist/MHCamEvent.cc:
+     - fill the rms for each event. This may be switched off by
+       a status bit in the future for speed reasons.
+       
+   * mhist/MHCamera.[h,cc]:
+     - removed Profile() from GetMaximum/GetMinimum if no
+       autoscale is done
+     - added 'content' Draw option
+     - when kNoLegend is set draw the legend showing the size
+     
+   * mhist/MHEvent.cc:
+     - fixed a typo: GetNumEvents() --> GetRunNumber()
+     
+   * mhist/MHTriggerLvl0.cc:
+     - small changes to output
+     
+   * mraw/MRawSocketRead.[h,cc]:
+     - renamed fRawEvtTime to fTime
+     - changed 'MRawEvtTime' to 'MTime'
+     - added some debugging output in case of kContinue
+
+   * mmain/MOnlineDump.[h,cc], mmain/MOnlineDisplay.[h,cc]:
+     - added
+
+   * mmain/MainLinkDef.h, mmain/Makefile:
+     - added MOnlineDump
+     - added MOnlineDisplay
+
+   * mona.cc:
+     - updated
+
+   * manalysis/MEventRate.[h,cc], manalysis/MEventRateCalc.[h,cc]:
+     - added
+
+   * manalysis/AnalysisLinkDef.h, manalysis/Makefile:
+     - added MEventRateCalc
+     - added MEventRate
+
+   * mgeom/MGeomMirror.h:
+     - fixed comments in the header - must be in one line!
+
+   * mreport/MReport.h:
+     - adde Getter-function for fState
+
+   * mreport/MReportDrive.[h,cc]:
+     - added GetAbsError() (preliminary!)
+
+
+
+ 2003/11/22: Thomas Bretz
+
+   * mreport/MReportCamera.cc:
+     - implemented real reading
+     - changed some loops to poinbter arithmetics
+
+   * mreport/Makefile:
+     - added mcamera
+
+   * merpp.cc:
+     - implemented preliminary support for report-files
+     
+   * star.cc:
+     - small changes to handling of update-mode
+     
+   * mbase/MParList.cc:
+     - fixed a wrong output
+     
+   * mbase/MTask.cc:
+     - fixed AddToBranchList(TString&)
+     
+   * mbase/MTime.[h,cc]:
+     - setfill only once
+     - fixed ()-operator
+     - removed nonsens GetTime()
+     
+   * mcamera/MCameraAUX.h, mcamera/MCameraCalibration.h,
+     mcamera/MCameraCooling.h, mcamera/MCameraHV.h,
+     mcamera/MCameraLV.h, mcamera/MCameraLid.h,
+     mcamera/MCameraLids.h, mcamera/MCameraPowerSupply.h:
+     - set version in ClassDef to 1
+
+   * mcamera/MCameraCooling.h:
+     - added Getter-functions
+
+   * mcamera/MCameraLV.h:
+     - changed fHumidity to Byte_t
+
+   * mcamera/MCameraLid.h:
+     - derived from MParContainer instead of TObject
+     
+   * mfileio/FileIOLinkDef.h, mfileio/Makefile:
+     - added MReadReports
+
+   * mfileio/MReadReports.[h.cc]:
+     - added
+
+   * mfileio/MReadTree.h:
+     - added MReadReports as friend class to allow access to fChain
+
+   * mfileio/MWriteRootFile.cc:
+     - fixed output (didn't have the correct debug flags)
+     
+   * mhist/HistLinkDef.h, mhist/Makefile:
+     - added MHVsTime
+
+   * mhist/MHVsTime.[h,cc];
+     - added 
+     
+   * mhist/MFillH.cc:
+     - add eveything I know to BranchList
+     
+   * mraw/MRawFileWrite.[h,cc]:
+     - changed name of MTime from MRawEvtTime to MTime
+     - changed Tree names to:
+       + Events
+       + Pedestals
+       + Calibration
+     
+   * mreport/MReportTrigger.[h,cc]:
+     - fixed accoring to a discussion with Riccardo
+     - changed version number in ClassDef to 1
+
+   * mreport/Makefile:
+     - added mcamera
+
+   * macros/rootlogon.C:
+     - added colors
+     - changed the search path for libmars.so a bit
+     
+   * mdata/MDataList.[h,cc]:
+     - added support for '%'
+
+   * mhist/MHCamera.[h,cc]:
+     - removed DrawPixelIndices and DrawSectorIndices
+     - replaced by new Draw-options: 'sectorindex' and 'pixelindex'
+     - put together in PaintIndices
+     
+   * mmain/MEventDisplay.cc:
+     - added Sectors to tabs
+     - code for adding tab was in class twice (removed in
+       ReadinFirstEvent, uses AddGeometryTabs instead)
+       
+   * mreport/MReport.[h,cc]:  
+     - prpared to read new DC-REPORT files
+     
+   * mreport/MReportDrive.[h,cc]:
+     - removed debug 'D'
+     - added Getter-functions
+
+
+
+ 2003/11/21: Thomas Bretz
+
+   * mraw/MRawEvtData.cc:
+     - added type 3 and 4 to GetPixContent
+
+   * status.cc:
+     - added display of average index of slice witg maximum value
+     - implemented a scheme to exit the application and to 
+       leave it open when the loop is finished.
+       
+   * macros/status.C:
+     - added maximum index histogram
+     
+   * mbase/MStatusDisplay.[h,cc]:
+     - implemented kExitLoopOnExit and kExitLoopOnClose
+     
+   * mcamera/CameraLinkDef.h:
+     - added missing MCameraAUX and MCameraLid
+     
+   * mhist/MHCamEvent.[h,cc]:
+     - added fRms
+     
+   * mhist/MHCamera.cc:
+     - added error when printing pixel contents
+     
+   * mhist/MHTriggerLvl0.[h,cc]:
+     - use MHCamera::kProfile
+     - renamed PrintOutLayers to PrintOutliers
+     
+   * mmain/MEventDisplay.cc:
+     - made 'Mini-Canvas' working in all Tabs by catching kCM_TAB
+
+   * mhist/MFillH.[h,cc], mhist/MH.[h,cc]:
+     - implemented ReInit
+
+   * mbase/MParList.cc:
+     - implemented more sanity check whether a class can be created 
+
+   * Makefile:
+     - added mcamera
+     - added mreport
+     - added status
+     - added OBJS and MCint.o to the shared object
+     
+   * macros/readCT1.C:
+     - do not add non-existing geomcam to parlist
+     - add geomapl to tasklist
+     
+   * mcamera/MCameraCalibration.h, mcamera/MCameraCooling.h,
+     mcamera/MCameraHV.h, mcamera/MCameraLV.h, 
+     mcamera/MCameraLid.h, mcamera/MCameraLids.h,
+     mcamera/MCameraPowerSupply.h, mreport/MReportCamera.h:
+     - changed according to discussion with Pepe
+
+   * mtools/Makefile, mtools/ToolsLinkDef.h:
+     - added MAstro
+     
+   * mtools/MAstro.[h,cc]:
+     - added
+
+   * macros/readMagic.C, macros/readCT1.C:
+     - changed to display relative signal (which is compared to the
+       cleaning levels) and the cleaning levels
+
+
+
+ 2003/11/20: Markus Gaug
+
+   * macros/calibration.C
+     - all variables are now plotted in camera displays
+
+   * manalysis/MCalibrationPix:
+     - replaced fErrT by fSigmaT
+
+   * manalysis/MCalibrationCam.cc:
+     - replaced fErrT by fSigmaT
+
+   * mhist/MHCalibrationPix.cc:
+     - replaced GetErrT by GetSigmaT()
+
+
+
+ 2003/11/20: Wolfgang Wittek
+
+   * mimage/M2dimFunctionFit.[h,cc]
+     - removed; will be replaced by MFun2Fit.[h,cc]
+
+   * mimage/M2dimFunction.[h,cc]
+     - removed; will be replaced by MFunc2.[h,cc]
+
+   * mimage/MH2dimFunction.[h,cc]
+     - removed; will be replaced by MHFunc2.[h,cc]
+      
+
+
+
+ 2003/11/19: Markus Gaug
+
+   * manalysis/MCalibrationPix:
+     - new functions: GetPed(), GetPedRms(), GetQProb()
+     - new variable: fQProb
+
+   * manalysis/MCalibrationCam.cc:
+     - function GetPixelContent enlarged
+
+   * manalysis/MCalibrationCalc:
+     - function ReInit added like in MPedCalcPedRun
+
+
+
+ 2003/11/19: Thomas Bretz
+
+   * mreport/MReport.[h,cc]:
+     - replaced FindTime by SetupReading
+     - removed SetTime
+     
+   * mreport/MReportFileRead.cc:
+     - replaced SetTime by SetupReading
+
+   * mreport/MReportCamera.[h,cc]:
+     - use new stuff
+
+   * mcamera/*:
+     - added
+
+
+
+
+
+ 2003/11/19: Markus Gaug
+
+   * manalysis/MPedCalcPedRun:
+     - implemented function ReInit
+     - implemented pointer fRunheader
+     - fNumHiGainSamples now called from fRunHeader inside ReInit
+     - Now, fNumHiGainSamples gets right number, instead of inf
+
+   * mhist/MHCalibrationConig:
+     - gkStartQlast changed from 5000 to 10000.
+
+
+
+ 2003/11/18: Thomas Bretz
+
+   * mars.cc:
+     - changed Usage to standard Usage
+     
+   * merpp.cc, mona.cc, readraw.cc, star.cc, status.cc,
+     mbase/MArgs.[h,cc]:
+     - removed const-qualifier for argv
+     
+   * mbase/MTask.cc:
+     - fixed a bug in PrintStatistics (setfill was not set)
+     
+   * mbase/MTaskList.cc:
+     - simplified PrintStatistics
+   
+   * mbase/MTime.h:
+     - added Getter
+     
+   * mfileio/MReadTree.cc:
+     - remove a leading "*" when checking whether a branch which 
+       should be enabled exists
+       
+   * mfileio/MWriteRootFile.cc:
+     - fixed a crash when Print is called and GetTree() returns NULL
+     
+   * mhist/MHEvent.cc:
+     - implemented more levels (MeV, GeV, etc) for energy display
+     
+   * mraw/MRawSocketRead.cc:
+     - removed some obsolete comment
+     
+   * mreport/MReport.[h,cc]:
+     - added FindTime
+     - removed an invalid line (ReadAngle) in the header file
+     - Set class version to 1
+     - do not write fTime '//!'
+     
+   * mreport/MReportFileRead.cc:
+     - fixed handling of MTimes
+
+   * mhist/MH.cc:
+     - added some const qualifiers in CutEdges
+
+
+
+ 2003/11/18: Abelardo Moralejo
+
+   * mmc/MMcEvt.cxx:
+     - Fixed missing initialization of fLongitmax
+
+
+
+ 2003/11/18: Markus Gaug
+
+   * manalysis/MCalibrationCalc: 
+     - performs the eventloop and fills the calibration classes
+
+   * manalysis/MCalibrationCam: 
+     - holds the classes: MCalibrationPix and MCalibrationBlindPix
+       and MCalibrationPINDiode
+     - one MCalibrationPix per pixel
+
+   * manalysis/MCalibrationPix:
+     - holds the fit results and conversion factors, etc per pixel
+     - hold histograms MHCalibrationPixel
+
+   * manalysis/MCalibrationBlindPix:
+     - holds fit results and derived number of photons, etc
+     - hold histogram MHCalibrationBlindPixel
+
+   * manalysis/MCalibrationPINDiode:
+     - holds fit results and derived number of photons, etc
+     - hold histogram MHCalibrationPINDiode
+
+   * mhist/MHCalibrationPix:
+     - histograms with sum of charges, time slices and reduced
+       charges vs. event number
+     - fit functions
+
+   * mhist/MHCalibrationPixel:
+     - histograms with sum of charges, time slices and reduced
+       charges vs. event number
+     - fit functions
+
+   * mhist/MHCalibrationBlindPixel:
+     - histograms with sum of charges, time slices and reduced
+       charges vs. event number
+     - fit functions
+
+   * mhist/MHCalibrationPINDiode:
+     - histograms with sum of charges, time slices and reduced
+       charges vs. event number
+     - fit functions
+
+   * mhist/MH:
+     - new function: CutEdges
+
+   * macros/calibration.C
+     - simple macro showing the functionning
+
+
+
+ 2003/11/17: Thomas Bretz
+ 
+   * mbase/MLog.cc:
+     - replaced pthread_mutex by a TMutex
+     - renamed fgui to fGui
+     - renamed fout to fOut
+     
+   * mbase/MStatusDisplay.cc:
+     - removed ==13 using TryLock() (this was wrong)
+
+   * mreport/*
+     - added
+
+   * macros/readrep.C:
+     - added
+
+   * merpp.cc, readraw.cc:
+     - added option -?/-h
+     
+   * mona.cc:
+     - added MOnlineDump-class
+     - added port as a commandline option
+     - added commandline options
+     
+   * status.cc:
+     - added option -?/-h
+     - added filter to support MC and DAQ files
+     
+   * mdata/MDataChain.[h,cc]:
+     - added kERound
+
+   * mfilter/FilterLinkDef.h, mfilter/Makefile:
+     - added MFRealTimePeriod
+     
+   * mgeom/MGeomCam.h:
+     - added InitGeometry
+     
+   * mgeom/MGeomCamCT1.cc, mgeom/MGeomCamCT1Daniel.cc,
+     mgeom/MGeomCamECO1000.cc, mgeom/MGeomCamECO1000HG.cc,
+     mgeom/MGeomCamMagic.cc, mgeom/MGeomCamMagic919.cc,
+     mgeom/MGeomCamMagicHG.cc:
+     - replaced Calc* by InitGeometry
+     
+   * mmain/MEventDisplay.cc:
+     - added a filter to support MC and real files
+     
+   * mmain/Makefile:
+     - added mdata and mfilter
+     
+   * mraw/MRawFileRead.cc:
+     - close file in PostProcess
+     
+   * mraw/MRawRunHeader.h:
+     - added a comment
+     
+   * mraw/RawIncl.h:
+     - removed some obsolete includes
+
+   * mhist/MH*:
+     - cleaned up many includes
+
+
+
+ 2003/11/15: Thomas Bretz, Abelardo Moralejo
+
+   * mhist/MH.h: 
+     - added fSerialNumber data member 
+
+   * mhist/MFillH.cc:
+     - distribute serial number to the MH object to be filled
+
+   * mranforest/MHRanForest.cc, mhist/MHHadronness.cc:
+     - added serial number to the MMcEvt container (does nothing unless
+       SetSerialNumber has been called for the corresponding MFillH)
+       This is intended to allow the use of Random Forest with MC
+       multi-telescope files.
+
+   * NEWS: 
+     - updated.
+
+
+
+ 2003/11/14: Abelardo Moralejo
+
+   * mfilter/MF.cc:
+     - added the possibility of using in the filter parameters from a
+       multi-telescope MC camera file, where master branches for each
+       telescope are tagged with ;i  being i  the number of telescope.
+       The change consists in the addittion in MF::IsAlNum of ';' as 
+       a possible alphanumeric character in the string.
+
+
+
+ 2003/11/13: Thomas Bretz
+
+   * macros/readCT1.C:
+     - fixed to work with the new MHCamera::Draw (see Mantis)
+     - changed to display event and cleaned event
+     
+   * macros/readMagic.C:
+     - fixed to work with the new MHCamera::Draw (see Mantis)
+
+   * mhist/MHEvent.cc:
+     - fixed display of the energy (see Mantis)
+     
+   * mmain/MEventDisplay.cc:
+     - fixed usage of small canvas with new MHCamera::Draw
+
+
+
+ 2003/11/11: Rudy Bock
+  
+   * mfilter/MFGeomag.[h,cc]:
+     - added a new class which reads two ASCII files (for +ve and -ve
+       particles) from the mfilter directory, and filters out 
+       low-energy charged Monte Carlo particles which do not reach the
+       earth's surface. Tables are from Adrian Biland. A method is
+       included which allows treating gammas as electrons (i.e. rejects
+       low energy particles).
+
+
+
+ 2003/11/11: Nicola Galante
+
+   * mhistmc/MHMcTriggerLvl2.[h,cc]:
+     - Removed 'const' qualifier for the returned object of the
+       method (TH1 *)MHMcTriggerLvl2::GetHistByName(const TString name)
+
+
+
+ 2003/11/10: Nicola Galante
+
+   * mhistmc/MHMcTriggerLvl2.[h,cc]:
+     - Changed return value of method MHMcTriggerLvl2::GetHistByName()
+       Now it returns a (TH1 *), no more a (TObject *), in order to keep
+       formal compatibility with the overloaded method of the mother
+       class TH1 *MH::GetHistByName(TString name)
+
+
+
+
+ 2003/11/10: Thomas Bretz
+  
+   * macros/dohtml.C:
+     - added mreflector
+     - removed mdatacheck
+     - removed mventdisp
+
+   * mbase/MEvtLoop.[h,cc]:
+     - removed instantiation of gListOfPrimitives
+     
+   * mbase/MGGroupFrame.h:
+     - minor change
+     
+   * mbase/MLog.cc:
+     - added a comment
+     
+   * mbase/MParContainer.[h,cc]:
+     - removed include MEvtLoop.h
+     - added instantiation of gListOfPrimitves
+     
+   * mbase/MReadSocket.[h,cc]:
+     - added more functionality
+     - added comments
+     - added Open() Close()
+     
+   * mbase/MTask.cc:
+     - removed obsolete include for MGGroupFrame
+
+   * mfilter/MFRealTimePeriod.h:
+     - initialize fTime with 0
+     
+   * mhist/MHCamEvent.cc, mhist/MHEvent.cc, mhist/MHTriggerLvl0.cc:
+     - removed creation of additional pad in Draw
+     
+   * mhist/MHCamera.cc:
+     - added creating of additional pad in Draw
+     - added some comments
+     
+   * mraw/MRawSocketRead.[h,cc]:
+     - added comments
+     - added fPort data member
+     - take MStatusDisplay status into account
+     - SetStausLine2 added
+     - removed obsolete include of iosfwd
+
+   * Makefile:
+     - changed makedepend line size
+     - renamed shared object from mars.so to libmars.so
+     - moved shared object from lib-directory to mars root directory
+     - make all executables load the shared object instead of statically 
+       linking
+     - removed mdatacheck
+
+   * Makefile.conf.darwin, Makefile.conf.linux, Makefile.conf.linux-gnu,
+     Makefile.conf.osf1, Makefile.conf.osf5.1:
+     - removed obsolete SUBDIRS in MARS_LIB
+     
+   * mars.cc:
+     - do not show logo if command line arguments are wrong
+
+   * macros/rootlogon.C:
+     - load libmars.so instead of lib/mars.so
+     - added mreflector to include path
+     - removed mdatacheck from include path
+     - removed mventdisp from include path
+     
+   * mmain/MStatusDisplay.[h,cc]:
+     - secure UpdateTab with a TMutex
+     - do not use MGTextView for root versions >= 3.02.05
+     - fixed a crash when all tabs where deleted, no tab was active
+       anymore
+     - show when updating postscript header
+
+   * mmain/MStatusDisplay.[h,cc], mmain/MSearch.[h,cc], mmain/MGMenu.[h,cc],
+     mmain/MSearch.[h,cc]:
+     - moved to mbase
+
+   * mmain/Makefile, mmain/MainLinkDef.h:
+     - removed MStatusDisplay
+     - removed MSearch
+     - removed MGMenu
+     - removed MProgressBar
+     - added MGDisplayAdc
+
+   * mbase/Makefile, mbase/MainLinkDef.h:
+     - added MStatusDisplay
+     - added MSearch
+     - added MGMenu
+     - added MProgressBar
+
+   * mdatacheck/Makefile, mdatacheck/DataCheckLinkDef.h:
+     - removed MGDisplayAdc
+
+   * meventdisp/Makefile, meventdisp/DataCheckLinkDef.h:
+     - removed MGCamDisplay
+     - removed MGEvtDisplay
+
+   * mdatacheck/MGDisplayAdc.[h,cc]:
+     - moved to mmain
+
+   * mona.cc:
+     - added ChangeContextMenus
+     - adapted to new MRawSocketRead interface
+     - assigned names to different tasks
+     - swiched off progress bar (temporarily)
+     - moved status display into thread
+     - exit thread by Exit() (seems to be necessary)
+     - added preliminary workaround for mssing RootPlugin
+
+   * mmain/MAnalysis.cc:
+     - removed external display
+     - added MStatusDisplay
+     
+   * mmain/MMonteCarlo.cc:
+     - old workaround (MMcEvt) obsolete
+
+   * mmain/MAnalysis.cc:
+     - do not call DisableAutoScheme
+     
+   * mmain/MCameraDisplay.cc:
+     - minor changes
+
+   * mgui/MCamDisplay.[h,cc], mmain/MEvtDisp.[h,cc],
+     meventdisp/MGCamDisplay.[h,cc], MGEvtDisplay.[h,cc],
+     meventdisp/MGFadcDisp.[h,cc], meventdisp/EvtDispIncl.h, 
+     meventdisp/EvtDispLinkDef.h, meventdisp/Makefile, meventdisp:
+     - removed (obsolete)
+
+   * mmain/MGDisplayAdc.[h,cc]:
+     - added ClassDef/ClassImp
+
+   * manalysis/MBlindPixelCalc.[h,cc]:
+     - corrected interpolation of all values (thanks to Nadia)
+     - fixed algorithm for pixels not existing yet
+
+   * manalysis/MCerPhotEvt.h:
+     - added return value to AddPixel
+
+
+
+ 2003/11/08: Nicola Galante
+
+   * mhistmc/MHMcTriggerLvl2.[cc,h]:
+     - Changed binning of histograms fHistLutPseudoSize, 
+       fHistLutPseudoSizeNorm, fHistSizeBiggerCell, 
+       fHistSizeBiggerCellNorm to fix an overflow bug
+     - In method GetHistByName(const TString name): changed the class 
+       of the returned object, now it returns a (TObject *), no more 
+       a (TH1F *), in order to return either (TH1 *) than (TH2 *); 
+       changed the order by which it checks the name of the
+       histogram in order to fix a bug in the lexing
+
+   * macros/triglvl2.C:
+     - Added some instruction to write all the MMcTriggerLvl2 histograms into
+       a TFile 
+
+
+
+ 2003/11/07: Thomas Bretz
+  
+   * mmain/MCameraDisplay.cc:
+     - changed MGCamDisplay to MEventDisplay
+     
+   * mmain/MMars.cc:
+     - removed 'Event Display' button
+     - removed MEvtDisp
+
+   * mmain/MEventDisplay.[h,cc], mhist/MHEvent.[h,cc]:
+     - added
+
+   * mmain/Makefile, mmain/MainLinkDef.h:
+     - removed MEvtDisp
+     - added MEventDisplay
+
+   * Makefile:
+     - removed mevtdisp
+
+   * mhist/Makefile, mhist/HistLinkDef.h:
+     - added MHEvent
+
+   * Makefile, Makefile.rules:
+     - automatically create dependancies
+
+   * NEWS:
+     - updated
+     
+   * mhist/MHCamera.[h,cc]:
+     - implemented kNoLegend=BIT(20)
+     - Clear pad before drawing Camera
+
+   * mmain/MStatusDisplay.cc:
+     - print when updating ps-header
+
+   * status.cc:
+     - added (not yet in Makefile)
+
+   * manalysis/MMcPedestalCopy.[h,cc]:
+     - made sure, that MPedestalCam is in the list 
+     
+   * mraw/MRawEvtData.cc:
+     - set the maximum/minimum of the fadc histograms
+     
+   * mraw/MRawEvtPixelIter.[h,cc]:
+     - added a fixes for the case that fData->fLoGainPixId->GetArray()=NULL
+
+   * manalysis/Makefile, manalysis/AnalysisLinkDef.h:
+     - added MCameraData
+
+   * manalysis/MCameraData.[h,cc]:
+     - added
+     
+   * mhist/MHEvent.[h,cc]:
+     - fixed display of levels
+     - fixed unallowed characters
+     
+   * mimage/MImgCleanStd.[h,cc]:
+     - moved the calculation for signal/noise to MCameraData
+     
+   * mmain/MEventDisplay.cc:
+     - added display for cleaning data and levels
+
+
+
+ 2003/11/06: Antonio Stamerra
+
+   * manalysis/MMcTriggerLvl2.cc
+     - Removed annoying warning message and put it in the Print method.
+
+
+
+ 2003/11/05: Wolfgang Wittek
+
+   * macros/CT1Analysis.C, macros/ONOFFCT1Analysis.C:
+     - current versions of the macros for the analysis of CT1 data
+ 
+   * manalysis/MMarquardt.[h,cc]:
+     - very pleliminary version of a class performing a minimization 
+       using the Marquardt method
+
+   * mimage/M2dimFunctionFit.[h,cc]
+     - very pleliminary version of a class which fits a 2-dim function
+       to the shower image using the maximum likelihood method 
+
+   * mimage/M2dimFunction.[h,cc]:
+     - very pleliminary version of a container which contains the
+       parameters of the 2-dim function describing the shower image
+
+   * mimage/MH2dimFunction.[h,cc]
+     - very pleliminary version of a container holding the histograms
+       for the parameters of the 2-dim function describing the shower
+       image
+
+
+
+ 2003/11/05: Marcos Lopez
+  
+   * mmontecarlo/MMcWeightEnergySpecCalc.[h,cc]
+     - Now, if the new spectrum for the MC showers is a power law, we
+       don't convert it to a TF1 function.
+     - Changed the constructor for the case in which the new spectrum
+       is passed as a TF1 function. Now we pass the TF1 object by
+       reference.
+     - Thanks to the suggestions of T. Bretz, added three more
+       constructors to give the possibility of passing the shape of the
+       new spectrum in other different ways. Now, if the new spectrum
+       that you want for the MC showers is different from a power law,
+       you can specify its shape either with a TF1 function, with a
+       string (char*), or with a general C++ function defined by your
+       own. 
+     - In function Reinit(): added a sanity check to prevent from
+       dividing by zero.
+     - In PreProcess(): removed an unnecessary sentence.
+     - Fixed a compiling error which appeared under gcc 3.3
+	
+   * macros/weights.C
+     - addapted to show the new features introduced. 
+
+
+
+ 2003/11/05: Thomas Bretz
+  
+   * mbase/MTask.cc:
+     - initialize fSerialNumber=0
+
+   * mhist/MHCamera.cc:
+     - removed some obsolete IsUsed(idx) checks when filling the histogram
+     - ExecuteEvent now plots in the same canvas all the time
+
+   * mmain/MStatusDisplay.[h,cc]:
+     - added new data member fUserFrame
+     - added new member function AddUserFrame
+     - made call to ProcessEvent() and similar thread safe by
+       checking whether we run in the main thread or not.
+     - Set the progress bar range to (0,1)
+     - Added member function to set progress bar position
+     - updated comments
+     - added some workarounds for root bugs in TCanvas (sometimes
+       they call gPad->cd() indirectly when gPad==NULL)
+     - Fixed thread safety of UpdateTab()
+     - Fixed some crashes in case fTab==NULL
+     - Tried to make HandleConfigureNotify more flexible to allow
+       the new fUserFrame to work correctly - needs still some
+       investigations
+     - made fList a protected data member 
+     - added new member function Update()
+
+
+
+ 2003/11/04: Thomas Bretz
+  
+   * mmontecarlo/MMcTimeGenerate.cc:
+     - adapted to changes in MTime
+
+   * mgeom/MGeomCam.[h,cc]:
+     - precalculate pix ratio (and square root of it) for faster
+       calculations. This makes sense, because these values are
+       needed at least n times (while n is the number of pixels)
+       per event. Which results in billions of calculations already
+       for some events.
+     - implemented CalcPixRatio to do the precalculation
+     - changed class version of MGeomCam from 1 to 2
+
+   * mgeom/MGeomCamCT1.cc, mgeom/MGeomCamCT1Daniel.cc, 
+     mgeom/MGeomCamECO1000.cc, mgeom/MGeomCamMagic919.cc,
+     mgeom/MGeomCamECO1000HG.cc, mgeom/MGeomCamMagic.cc,
+     mgeom/MGeomCamMagicHG.cc:
+     - implemented CalcPixRatio to do the precalculation
+     - some simple code cleanup (removed obsolete comments, etc)
+   
+   * mgeom/MGeomPix.[h,cc]:
+     - replaces tan(60deg) by a build-in constant (fgTan60)
+     - pre calculate the area of the pixel in the constructor
+       (for speed reasons, see pixratio aboive)
+     - added fA
+     - changed version number from 1 to 2
+
+   * mimage/MImgCleanStd.cc, mimage/MImgCleanTGB.cc:
+     - directly use MGeomCam::GetPixRatioSqrt() now
+
+   * mraw/MRawSocketRead.cc:
+     - updated comment header
+     - updated class description
+     - removed obsolete fMutex, Lock() and UnLock()
+     - moved code from Do() to Process()
+     - added comments
+
+   * meventdisp/MGCamDisplay.cc:
+     - replaced MHillas:Clear() by Removing from ListOfPrimitives
+     
+   * mimage/MHillas.[h,cc]:
+     - removed fEllipse
+     - removed the Draw function
+     - added a correct Paint() function
+
+   * Makefile:
+     - added star
+     
+   * macros/star.C:
+     - removed obsolete MSrcPosCam (will be created automatically)
+     - made the macro work with a telescope serial number
+     
+   * mbase/MParContainer.[h,cc]:
+     - moved GetDescriptor to source file and added a function 
+       description
+     - changed GetDesciptor to be virtual
+       
+   * mbase/MTask.[h,cc]:
+     - added new data member fSerialNumber
+     - changed version number from 1 to 2
+     - added GetDescriptor aware of the serial number
+     - added Getter and Setter for serial number
+     - made StreamPrimitive serial number aware
+     
+   * mbase/MTaskList.[h,cc]:
+     - overwrote SetSerialNumber
+
+   * mfileio/MReadTree.cc:
+     - changed a C-cast to a C++-cast
+     
+   * mfileio/MWriteRootFile.h:
+     - changed BIT(16) to BIT(17). UPDATE mode was not working
+       with newer root versions, because BIT(16) was used already
+       
+   * manalysis/MBlindPixelCalc.cc, manalysis/MCerPhotCalc.cc,
+     manalysis/MGeomApply.cc, manalysis/MMcPedestalCopy.cc,
+     manalysis/MMcPedestalNSBAdd.cc, manalysis/MSigmabarCalc.cc,
+     mimage/MHillasCalc.cc, mimage/MHillasSrcCalc.cc, 
+     mimage/MImgCleanStd.cc:
+     - made serial number aware
+     
+   * mraw/MRawFileWrite.cc:
+     - automatically add .root extension
+
+   * star.cc:
+     - added
+
+
+
+ 2003/11/03: Thomas Bretz
+  
+   * manalysis/MMcPedestalCopy.[h,cc], manalysis/MMcPedestalNSBAdd.[h,cc]:
+     - fixed such, that it now works correctly with non-MC files
+     - moved container requests from PreProcess to ReInit
+     - removed some obsolete data members - made them locally
+     
+   * manalysis/MMcPedestalRead.[h,cc]:
+     - removed
+     
+   * mbase/MEvtLoop.cc:
+     - replaced the gApplication->InheritsFrom(TRint::Class())
+       workaround for thread safty by the more correct check
+       whether we are running in the main Thread (TThread::Self())
+     - added double-cast to TProgressBar::SetPosition
+       
+   * mbase/MTask.h:
+     - added the missing const-qualifier to GetNumExecutions
+     
+   * mbase/MTaskList.cc:
+     - fixed a typo in the output
+     
+   * mimage/MHillasCalc.[h,cc]:
+     - replaced TArrayC by TArrayL to support huge number of events
+     - added PrintSkipped
+     - added comments to the data members
+
+   * mars.cc:
+     - added code for a possible use of a TGApplication
+       (in comments)
+
+   * merpp.cc, readraw.cc:
+     - unified with the other executables (StartUpMessage, etc)
+     - removed TROOT-object
+     - readraw.cc: added more functionality
+
+   * mraw/MRawEvtData.cc:
+     - changed positions of 'fush' in Print() (this confused 'more'
+       because 'more' also counts the ANSI color codes to determin
+       the line-length)
+
+   * mhistmc/MHMcCollectionArea.cc:
+     - added UseCurrentStyle such that the axis labels are displayed
+
+   * mbase/MTime.[h,cc]:
+     - removed fTimeStamp
+     - increased version number
+     - changed Print() function
+     - removed obsolete functions and constructors
+     - fixed copy constructor
+     
+   * mfileio/MCT1ReadPreProc.cc:
+     - replaced SetTime by SetCT1Time
+     
+   * mhist/MHAlphaEnergyTime.cc, mhist/MHEnergyTime.cc,
+     mhist/MHThetabarTime.cc, mhist/MHTimeDiffTheta.cc,
+     mhist/MHTimeDiffTime.cc:
+     - adapted to changes in MTime
+     
+   * mraw/MRawEvtHeader.cc:
+     - adapted to changes in MTime
+     - minor change to output in Print()
+
+
+
+ 2003/10/31: Marcos Lopez
+
+   * mhist/MFillH.cc:
+     - Fixed a bug in function PreProcess(MParList *pList). Inside the 
+       conditional sentence "if (!fWeight && !fWeightName.IsNull())",  
+       fWeight never pointed to the object MWeight recoverd from the 
+       parameter list.
+
+   * mhistmc/MHMcEnergyImpact.cc:
+     - In the Fill function, pass the weight to the histogram fHist.
+
+   * mmontecarlo/MMcWeightEnergySpecCalc.[h,cc]:
+     - Added new class for changing the energy spectrum of the showers 
+       simulated with Corsika to a different one, be using weights   
+			
+   * mmontecarlo/Makefile, MonteCarloLinkDef.h
+      - Added the new class.
+ 
+   * macros/weights.C
+      - Added macro showing how to transform the spectrum of the MC showers.
+
+
+
+
+
+ 2003/10/31: Thomas Bretz
+
+   * mars.cc:
+     - change TGApllication back to TApplication (TGApplication doesn't
+       load the TVirtualPad plugin by default) DISPLAY must be set
+       manually if it is not set.
+
+
+
+ 2003/10/30: Antonio Stamerra
+
+   * manalysis/MMcTriggerLvl2.[h,cc]
+     - Added method CalcTriggerPattern to check which x-NN compact
+       pattern the event satisfies. The variable member fTriggerPattern 
+       contains the number x (x=3,4,5,6,7). 
+     - Inline function GetTriggerPattern added.
+
+   * manalysis/MMcTriggerLvl2Calc.cc
+     - Added call to the MMcTriggerLvl2::CalcTriggerPattern in Process().
+
+
+
+ 2003/10/30: Thomas Bretz
+
+   * manalysis/MCerPhotEvt.[h,cc]:
+     - fixed a bug in the new Lut-stuff. Sometimes pixels where
+       considered existing, because there where no mark for 
+       empty entries in the Lut.
+     - all loops ignored pixel with index 0 and used it as reference
+       pixel - this is wrong, because pixel 0 must not exist at all.
+       Now all loops are starting with pixel 0.
+
+   * mimage/MImgCleanStd.[h,cc]:
+     - renamed various local variables from 'id' to 'idx'
+     - in clean step 4 we assumed that a pixel with idx2 is existing
+       - this is a dangerous assumption. It is checked now.
+
+
+
+ 2003/10/29: Thomas Bretz
+  
+   * manalysis/AnalysisLinkDef.h, manalysis/Makefile:
+     - removed MMcPedestalRead
+
+   * manalysis/MMcPedestalCopy.[h,cc]:
+     - merged functionality of MMcPedestalRead into it
+     - do not remove itself from the tasklist, but check 
+       the file type for each file again.
+     - added const-qualifiers in the class header
+       
+   * manalysis/MMcPedestalNSBAdd.[h,cc]:
+     - don't do something if camera file version is < 0.7
+     - do not remove itself from the tasklist, but check 
+       the file type for each file again.
+     - added const-qualifiers in the class header
+     
+   * mgui/MCamEvent.cc:
+     - added a comment
+     
+   * mimage/MHillasCalc.[h,cc]:
+     - replaced the fixed size array fErrors by a dynamic size array
+       (TArrayC) to make sure, that people get a warning on the
+       screen if the reprogram the error handling and write
+       into an unallowed index.
+
+
+
+ 2003/10/28: Thomas Bretz
+  
+   * macros/readCT1.C:
+     - fixed to work with the correct geometry
+     
+   * macros/readMagic.C:
+     - fixed - was crashing
+     
+   * macros/tar.C:
+     - exclude 'Tag' files from tar
+     
+   * manalysis/MGeomApply.[h,cc]:
+     - replaced constructor by SetGeometry (constructor was
+       not unique)
+
+   * mbase/MEvtLoop.[h,cc]:
+     - set fProgress already when setting fDisplay (gives the
+       possibility to overwrite fProgress)
+     - removed 'entries' from ProcessGuiEvents (moved to fNumEvents)
+     - Set ProgressBar position in percent instead of event number
+     - Set progress bar range from 0 to 1
+     
+   * mbase/MReadSocket.cc:
+     - fixed to treat timeout correctly
+     - replaces usleep() by gSystem->Sleep()
+
+   * mbase/MTime.h:
+     - added SetTime(ULong_t) (support for gSystem->Now())
+     - added SetTime(Double_t)
+     - added operator()
+     - fixed all comparison operators to use time instead of
+       time lo/hi - will be removed soon
+       
+   * mimage/MHHillasSrc.cc:
+     - delete 3rd Pad
+     
+   * mraw/MRawEvtData.cc:
+     - when drawing print gPad
+
+
+
+ 2003/10/28: Wolfgang Wittek
+
+   * manalysis/MCT1PadONOFF.cc
+     - replace GetMeanRms() by GetPedestalRms()
+     - replace SetMeanRms() by SetPedestalRms()
+     - reactivate code which was commented out by tgb
+       (no compilation errors on Alpha OSF)
+
+   * manalysis/AnalysisLinkDef.h, manalysis/Makefile
+     - put back MCT1PadONOFF
+
+   * macros/CT1Analysis.C, macros/ONOFFCT1Analysis.C
+     - current versions of macros for the analysis of CT1 data
+
+
+
+ 2003/10/26: Oscar Blanch Bigas
+
+   * mmc/MMcFadcHeader.[cc,h]
+     - Added variable member that has the sigma of the electronic noise
+       that goes with the same value to both FADC gains (fDigitalNoise)
+     - Class version has been changed from 2 to 3.
+
+
+
+ 2003/10/24: Abelardo Moralejo
+
+   * manalysis/MMcPedestalRead.[cc,h]
+     - Added. In coming camera version (0.7) the pedestal sigma per 
+       FADC slice is calculated by the camera simulation at run time, 
+       then written to the output file. This class reads in the pedestal
+       mean and sigma to be later used in the analysis (for tail cuts 
+       mainly). This task will replace MMcPedestalCopy and 
+       MMcPedestalNSBAdd for camera >= 0.7 files, for which the second
+       class would produce wrong results.
+
+
+
+ 2003/10/23: Abelardo Moralejo
+
+   * mhistmc/MHMcEnergyMigration.cc
+     - Changed the Draw procedure: with new root versions (3.04, 3.05)
+       the result of the used drawing options was different from what 
+       we had in 3.02, and the graphics output had become unreadable. 
+       Replacing some Draw() calls by DrawCopy() has solved the problem.
+
+
+
+ 2003/10/23: Thomas Bretz
+
+   * macros/star.C:
+     - replaced geometry by the task MGeomApply
+
+   * manalysis/MCerPhotCalc.cc:
+     - fixed typo
+
+
+
+ 2003/10/22: Thomas Bretz
+  
+   * mars.cc:
+     - replaced TApplication by TGApplication
+     - removed TROOT
+     - reset Batch mode in any case
+     
+   * meventdisp/MGCamDisplay.cc:
+     - use new MHCamera::SetLevels to display cleaning levels
+     
+   * mhist/MHCamera.[h,cc]:
+     - removed FillLevels - obsolete
+     - added SetLevels instead
+
+
+ 2003/10/21: Wolfgang Wittek
+
+  * manalysis/MMatrixLoop.[h,cc]
+    - member function PreProcess() put from .h to .cc
+
+  * mhist/MHMatrix.[h,cc]
+    - member function SetNumRow() put from .h to .cc
+
+
+
+ 2003/10/20: Thomas Bretz
+
+   * mraw/MRawEvtPixelIter.[h,cc]:
+     - changed name of member function from GetNumMax[Hi,Lo]GainSamples
+       to GetIdxMax[Hi,Lo]GainSamples
+  
+   * manalysis/MMcPedestalCopy.cc:
+     - changed GetPedestalRms to GetElecNoise to make Mars compile with
+       the changes done in MMcFadcHeader
+
+   * mmc/MMcTrig.cxx:
+     - changed <iostream.h> to <iostream> according to C++
+
+   * mhistmc/MHMcTriggerLvl2.[h,cc]:
+     - MHMcTriggerLvl2::GetHistByName removed const-qualifier and 
+       changed return type to TH1 according to definition in MH.
+
+   * macros/status.C:
+     - use MDirIter instead of a single file name
+     - adde MHTriggerLvl0
+     - Simplified macro by using PrintOutliers
+
+   * mhist/MHCamEvent.[h,cc]:
+     - renamed PrintOutlayers to PrintOutliers
+     - Divide pad only into two subpads
+
+   * mfilter/MF.cc:
+     - added comment about '=='
+
+   * mhist/MHMatrix.cc:
+     - removed some pieces of code which preserved the contents
+       of a matrix when resizing. This is done by root now.
+
+   * mfilter/MFRealTimePeriod.[h,cc]:
+     - added
+
+   * mfilter/Makefile, mfilter/FilterLinkDef.h:
+     - added MFRealTimePeriod
+
+   * mars.cc:
+     - moved Start-up-message to StartUpMessage()
+
+   * manalysis/MBlindPixelCalc.h, manalysis/MCT1FindSupercuts.cc,
+     manalysis/MCerPhotAnal.h:
+     - minor changes
+
+   * mhist/MHCamera.[h,cc]:
+     - added Profile-option (display contents/entries)
+     - added Freeze-option  (ignore filling data into the histogram)
+     - added UseCurrentStyle to get the y-axis back
+     - overwrite DrawCopy
+
+   * manalysis/MCerPhotEvt.[h,cc]:
+     - added fLut to accelerate searching an index a lot, this should
+       be backward compatible to old class versions
+     - increased class version to 2
+     - removed all searches for indices - replaced by GetPixById
+     - GetPixById no uses the look-up-table, which is much much faster
+       and still searches the array if the fLut size is 0 which might
+       be because of a class version 1 object is read from a file -
+       according to Rene this should work.
+
+   * manalysis/MPedestalCam.[h,cc]:
+     - replaced a C-cast by a C++ static_cast
+
+   * mhist/MH.[h,cc]:
+     - renamed them from Draw/DrawCopy to DrawSame/DrawSameCopy
+
+   * mraw/MRawEvtData.[h,cc]:
+     - changed arrays to '//->'
+     - overwrote Copy() member function
+
+   * mhist/MFillH.[h,cc]:
+     - added GetCanvas()
+
+   * mhist/MHHadronness.cc, mimage/MHHillasExt.cc,
+     mimage/MHNewImagePar.cc:
+     - changed Draw to DrawSame
+
+   * mhist/MHCamEvent.cc:
+     - use new MHCamera profile mode
+
+   * mbase/MEvtLoop.cc, mmain/MStatusDisplay.cc:
+     - check whether application is TRint to make mone thread safe
+       This is necessary not to call ProcessEvents() twice at the
+       same time!
+
+
+
+ 2003/10/17: Oscar Blanch
+
+   * mmc/MMcFadcHeader.[cxx,hxx]:
+     - Added variable members to store the pedestal sigma from thte
+       camera simulation porgram: fPedesSigmaHigh fPedesSigmaLow
+
+   * mmc/MMcRunHeader.cxx:
+     - fill fNumEvts with number of stored events
+
+   * mmc/MTriggerDefine.h:
+     - Trigger zone for CT1 cameras up to 126 pixels
+
+   * mgeom/MGeomMirror.cc:
+     - fixed bug in filling axis desviation
+
+
+
+ 2003/10/15: Thomas Bretz
+
+   * Makefile.conf.general:
+     - added libThread to support mona
+     
+   * manalysis/MCerPhotAnal2.cc:
+     - changed comments
+     - accelerated the code a bit by using pointer arithmetic
+     
+   * mbase/BaseLinkDef.h, mbase/Makefile:
+     - added MReadSocket
+
+   * mbase/MReadSocket.[h,cc]:
+     - added MReadSocket
+     
+   * mbase/MEvtLoop.cc:
+     - fixed some crashes in ProcessGuiEvents
+     
+   * mbase/MFilter.cc:
+     - changed header
+     
+   * mbase/MTime.h:
+     - added operator double() 
+
+   * mimage/MHillas.cc:
+     - changed the comments about corrxy
+     
+   * mmain/MStatusDisplay.[h,cc]:
+     - added many comments
+     - added kFileClose stuff
+     - added AddRawTab
+     - added thread handling in UpdateTab
+     - fixed deletion in case the pointer is on heap
+     - added date/time to ps-output
+     
+   * mraw/MRawEvtHeader.cc:
+     - added some comments about the total number of bytes read
+     
+   * mraw/MRawRunHeader.[h,cc]:
+     - added some comments about the total number of bytes read
+     - fixed treating files with 0xc0c1 as Magic-Number
+     - added GetNumTotalBytes
+
+   * mraw/Makefile, mraw/RawLinkDef.h:
+     - added MRawSocketRead
+
+   * mraw/MRawSocketRead.[h,cc]:
+     - added
+
+   * mona.cc:
+     - added
+
+
+
+ 2003/10/05: Abelardo Moralejo
+
+   * macros/star.C:
+     - returned to revision 1.9 (I had committed by mistake a private 
+       version of the macro, sorry!)
+
+
+
+ 2003/10/04: Thomas Bretz
+
+   * macros/MagicHillas.C, macros/pedestalvstime.C, macros/pixfirerate.C,
+     macros/pixsatrate.C, macros/readCT1.C, macros/readMagic.C,
+     macros/starplot.C, macros/status.C, macros/sumevents.C,
+     macros/sumeventserr.C, macros/sumeventsrms.C, macros/sumpedestalrms.C,
+     macros/sumpedestals.C, mmain/MDataCheck.cc:
+     - added MGeomApply
+     
+   * manalysis/AnalysisLinkDef.h, manalysis/Makefile:
+     - added MGeomApply
+
+   * manalysis/MBlindPixelCalc.cc:
+     - for buid-in pixel numbers added a check whether the geometry
+       is mathcing
+       
+   * manalysis/MCerPhotCalc.cc, manalysis/MMcPedestalCopy.cc, 
+     manalysis/MMcPedestalNSBAdd.cc, meventdisp/MGCamDisplay.[h,cc],
+     meventdisp/MGEvtDisplay.[h,cc], mhist/MHFadcCam.cc:
+     - fixed that it can deal with variable size arrays
+
+   * manalysis/MGeomApply.[h,cc]:
+     - added. This task will take care of different geometries
+
+   * manalysis/MPedestalCam.cc:
+     - initialize array with size 1
+     - do not call new operator
+     
+   * mbase/MArgs.cc, mbase/MDirIter.cc:
+     - added comments
+     
+   * mdatacheck/MGDisplayAdc.cc:
+     - fixed a small bug in setting slider position for different geometries
+     
+   * mfileio/MWriteRootFile.cc:
+     - automatically append '.root' to file name
+     
+   * mhist/MHCamera.cc:
+     - added Init function
+     - moved parts of the construtor to Init function
+     - added default constructor
+     - added possibility to change geometry after creation by SetGeometry
+     - added many sanity checks (fNcells<=1)
+
+
+
+ 2003/10/02: Thomas Bretz
+
+   * mraw/MRawEvtData.cc:
+     - changed Draw so that also lo-gains are displayed.2
+
+
+
+ 2003/10/01: Nicola Galante
+
+   * mhistmc/MHMcTriggerLvl2.[h,cc]:
+     - in method MHMcTriggerLvl2::Fill added filling of 2D histograms
+       of fLutPseudoSize vs. energy and of fSizeBiggerCell vs. energy
+     - modified method MHMcTriggerLvl2::GetHistByName which now
+       can return any histogram (data member) of the class
+       MHMcTriggerLvl2 (now it returns a (TObject *) not a (TH1F *))
+     - Updated option list of the methid MHMcTriggerLvl2::DrawClone
+
+   * macros/triglvl2.C:
+     - Updated according with changes in class MHMcTriggerLvl2
+
+
+
+ 2003/09/30: Robert Wagner
+
+   * mfileio/MCT1ReadPreProc.cc
+     - undone change from 2003/09/26
+     - MJD is filled in fTime.Duration
+
+
+
+ 2003/09/29: Nicola Galante & Antonio Stamerra
+
+   * mmc/MMcTrig.cxx:
+     - Fixed a bug in function IsPixelFired():  the binary shift, introduced 
+       by T.B. to replace "pow" for power of two, was wrong. 
+       The correct operator to be used is "<<" and not ">>"! 
+
+   * manalysis/MMcTriggerLvl2.[h,cc]:
+     - Added method "CalcEnergy(MMcEvt *)" used to get correlation between
+       energy and size.
+     - Removed graphical functions "Drawcell" and "DrawLvl1"
+     - Fixed bug in the pixcell setting (pixel numbering in the cell starts 
+       from 0 but gsPixelInLut starts from 1).   
+     - Fixed bug in the "check" variable.	
+
+   * manalysis/MMcTriggerCalc.[h,cc]:
+     - Added call to MMcTriggerLvl2::CalcEnergy() in Process() 
+     - Removed 'const' from fMcEvt declaration	
+
+   * mhistmc/MHMcTriggerLvl2.[h,cc]:
+     - Added method "Draw2DHist" (draw correlation between
+       energy and size)
+     - Fixed bug in "DrawClone" function (histogram normalization)
+
+   * macros/triglvl2.C:
+     - Fixed a bug in the task list order to apply correctly the filters
+     - Now it writes on disk a root file with some histograms
+
+
+
+ 2003/09/26: Robert Wagner
+
+   * mfileio/MCT1ReadPreProc.cc
+     - provisionally pass complete event time to fTime container,
+       units are MJDs instead of seconds for the time being
+
+
+
+ 2003/09/25: Abelardo Moralejo
+
+   * macros/MagicHillas.C, star.C
+     - Added cast: TArrayF w(15,(Float_t*)x) to get rid of warning.
+
+
+
+ 2003/09/24: Abelardo Moralejo
+
+   * macros/MagicHillas.C, star.C
+     - Added const qualifier to TArrayF w(15,x); I got a crash due to
+       this missing qualifier when changing some code in MCerPhotCalc
+       (not yet submitted).
+
+   * macros/CT1Hillas.C
+     - removed code containing TArrayF w(15,x) (which was commented)
+       since it made no sense for CT1.
+
+
+
+ 2003/09/24: Wolfgang Wittek
+
+   * mfilter/MFEventSelector2.[h,cc]
+     - execution statistics added
+
+   * mhist/MHFindSignificance.cc
+     - add fHist->UseCurrentStyle()
+       to get the y-axis + labels drawn
+
+   * mhist/MHMatrix.h
+     - replace   Int_t fNumRow  //!   
+            by   Int_t fNumRow  //
+       because otherwise fNumRow is not defined when MHMatrix object is read in
+       after it had been written out
+
+   * mhist/MHCT1Supercuts.cc
+     - change title of object
+
+   * manalysis/MMinuitInterface.cc
+     - add arguments maxcalls and tolerance to SIMPLEX call
+
+   * manalysis/MCT1SupercutsCalc.[h,cc]
+     - add variables asymmetry, conc, leakage
+
+   * manalysis/MCT1Supercuts.[h,cc]
+     - add variables asymmetry, conc, leakage
+     - add TArrayD fStepsizes (initial step sizes for the parameters)
+
+   * manalysis/MCT1FindSupercuts.cc
+     - replace MGeomCamCT1Daniel by MGeomCamCT1
+     - arguments 'parSCinit', 'params' and 'steps' added in FindParams() ;
+         parSCinit is the name of the file containing the initial
+         values of the parameters
+         'params' and 'steps' are the initial values in case parSCinit == ""
+     - add member functions GetMatrixTrain() and GetMatrixTest()
+     - remove member function WriteMatrix()
+       because it didn't work; now the matrices are written out in
+       DefineTrainMatrix(), DefineTestMatri() and DefineTrainTestMatrix()
+
+   * macros/CT1EgyEst.C
+     - don't use Daniel's energy estimator
+
+   * mmontecarlo/MMcEnergyEst.cc
+     - extend printout of comments
+
+
+
+ 2003/09/17: Abelardo Moralejo
+
+   * manalysis MCerPhotCalc.cc:
+     - in warning about saturating low gains in pixels: changed the 
+       'if' by a 'switch' and slightly corrected text of warning (no 
+       change in performance or results).
+
+
+
+ 2003/09/16: Abelardo Moralejo
+
+   * manalysis MCerPhotCalc.[h,cc]:
+     - added the low gain treatment. It has first been implemented by
+       TB, and the version I submit is a slightly modified one. If any 
+       high gain FADC slice is saturated, we switch to low gain. If low 
+       gain is also saturated, the signal is nevertheless calculated 
+       ("truncated" of course), and a warning is displayed reporting 
+       the number of saturated pixels in the current event. 
+       Fixed also the calculation of the mean pixel pedestal (added 
+       variable fSumWeights), which previously would not work correctly 
+       in the case that one sets weights different from 0 or 1 in the 
+       array fWeight (which was anyway not done up to now, as far as I 
+       know). It would be necessary to add to the parameters of the 
+       analyzed events the number of saturated pixels in some way. 
+       In the MC files produced with camera versions 0.6 or earlier, no
+       low gain is simulated, and saturation of high gain is not 
+       correctly implemented, so this should not introduce any change
+       in the analysis of present or old MC files.
+
+
+
+ 2003/09/12: Thomas Bretz
+ 
+   * mimage/MHillasSrc.cc:
+     - fixed the NaN-problem in the calculation of Alpha. More 
+       information can be found in the comments there.
+
+   * mhist/MHFadcCam.[h,cc]:
+     - skip MC events which have no FADC information stored
+     - better output in case of changes in the number of slices
+     - added size argument to constructor to support ECO100, too.
+     - removed all fixed numbers and replaced them by the corresponding
+       function
+     - fixed pixel numbering to be consistent with the software pixel
+       numbering in the rest of Mars
+
+   * mhist/MHFadcPix.[h,cc]:
+     - fixed the missing y-axis (UseCurrentStyle()) 
+     - fixed pixel numbering by changing default arument of pixid in
+       constructor from 0 to -1
+
+   * mmain/MDataCheck.cc
+     - added 'Time Spectra of Cosmics' button
+     - added size argument to instatiation of MHFadcCam
+
+
+
+ 2003/09/10: Thomas Bretz
+ 
+   * mdata/MDataChain.[h,cc]:
+     - added log2, acosh, asinh, atanh, ceil, isnan and finite
+     - changed math.h callings to TMath:: namespace to be more
+       consistent
+       
+   * mhist/MHMatrix.[h,cc]:
+     - added RemoveInvalidRows member function to get rid of rows
+       containing invalid numbers (nan, inf)
+
+   * mraw/MRawEvtHeader.cc:
+     - fixed variable types calculating the time (ns, s, m and h)
+       to get rid of some compiler warnings, casting the values 
+       for-, back- and forward only wasts computing time.
+
+
+
+ 2003/09/08: Abelardo Moralejo
+
+   * mhist/MHOnSubtraction.cc: 
+     - added some casts in the arguments of function calls, to get rid 
+       of compilation warnings due to mismatch of variable type 
+       (variables: lowerBin, upperBin). Corrected order of arguments in 
+       TH1D constructor of fSignificanceHist (number of bins and bin 
+       limits).
+
+   * mraw/MRawEvtHeader.cc:
+     - Added casts to arguments of fTime->SetTime(h, m, s, ns) to get 
+       rid of compilation warnings.
+
+   * mhist/MHCamera.cc:
+     - Changed calls to abs and fabs by TMath::Abs. At least in RH7.2 
+       with gcc2.96, abs() was not recognized.
+
+
+
+ 2003/09/07: Abelardo Moralejo
+
+   * manalysis/MCerPhotCalc.cc:
+     - removed normalization of array fWeight introduced on 30/06. For
+       now, this array is intended only to select the FADC slices which
+       we want to integrate to get the signal. The use of this feature
+       of MCerPhotCalc is explained in the example macro MagicHillas.C
+       The array fWeight must contain 0's and 1's. If we normalize
+       these values, the signal units is no longer ADC counts (but 
+       "average ADC counts per slice"). As David realized, this was the 
+       reason for the discrepancies in the gamma/hadron separation 
+       results we were observing lately. The meaning of Size was 
+       different among the different people working on the subject, and 
+       hence, when we compared samples with a given Size cut we were
+       actually comparing different energy ranges.
+
+     - Turned fSumQuadWeights to its original meaning, the quadratic 
+       sum (square root of the sum of the squares) of the values in the 
+       fWeight array. Why was this changed?? (sqrt removed) Only because 
+       of the name of the variable??
+
+     - Changed the calculation of the mean pedestal to fit the meaning
+       of fSumQuadWeights.
+
+     - Moved the call to ScalePedestals() to the end of the ReInit 
+       function. Formerly it was called before the setting of the 
+       variable fEnableFix, and then the mean pedestal in each FADC 
+       slice was wrong by 0.5 units... once more: please Thomas B, 
+       be careful with these kind of changes.
+
+
+
+ 2003/08/27: Thomas Bretz
+
+   * mhist/MH3.cc:
+     - fixed missing UseCurrentStyle for newer root versions
+
+
+
+ 2003/08/26: Thomas Bretz
+
+   * mimage/MHHillas.cc, mimage/MHHillas.cc, mimage/MHHillasExt.cc,
+     mimage/MHNewImagePar.cc:
+     - fixed missing UseCurrentStyle for newer root versions
+
+
+
+ 2003/08/26: Wolfgang Wittek
+
+    * manalysis/MCT1FindSupercuts.cc
+      - set size of fStep, fLimlo, fLimup, fFix
+      - in 'fcnsupercuts' : get total number of parameters by calling 'mnstat'
+
+    * manalysis/MCT1Supercuts.[h,cc]
+      - extend error printout
+
+    * manalysis/MMinuitInterface.cc
+      - do not delete the Minuit object because it will still be used
+
+    * mhist/MHFindSignificance.cc
+      - formulaBackg was wrong
+
+
+
+ 2003/08/26: Robert Wagner
+
+    * mraw/MRawRunHeader.h
+      - Added Setter for MJD
+
+    * mfileio/MCT1ReadPreProc.cc
+      - Fill MJD from Preproc run header in fRawRunHeader 
+
+
+
+ 2003/08/22: Wolfgang Wittek
+
+    * mhistmc/MHMcCT1CollectionArea.cc
+      - change selection of theta bin in 'CalcEfficiency()'
+        (to be mored flexible in choosing the theta binnning)
+
+
+
+ 2003/08/21: Thomas Bretz
+
+   * manalysis/MCT1FindSupercuts.[h,cc], manalysis/MCT1Supercuts.[h,cc], 
+     manalysis/MCT1SupercutsCalc.[h,cc], manalysis/MMinuitInterface.[h,cc],
+     mhist/MHFindSignificance.[h,cc]: 
+     - changed some variables and member functions with respect to an upcoming
+       Minimization Class
+     - simplified some calls
+     - replaced fixed size arrays by variable size arrays
+     - added some sanity checks
+     - simplified some variable usage
+
+   * mhist/MHCT1Supercuts.[h,cc]:
+     - removed obsolete SetupFill
+
+
+
+ 2003/08/20: Thomas Bretz
+
+   * mhist/MHCamEvent.[h,cc]:
+     - added PrintOutlayers
+     
+   * mhist/MHHadronness.cc:
+     - changed PrintOutput
+     - set some Grids in plots
+     
+   * mhist/MHMatrix.cc:
+     - removed obsolete call to MEvtLoop::SetName
+     - Changed name to something more intuitive
+     
+   * mranforest/MRanForest.cc, mranforest/MRanTree.h:
+     - removed ^M
+     
+   * mranforest/MRanTree.cc:
+     - removed obsolete check for gRandom
+     - replaced mvar*numdata by a new variable mn
+
+
+
+ 2003/08/19: Thomas Hengstebeck
+
+   * mranforest/MRanForest.cc:
+     Removed error in calculation of fDataRang in CreateDataSort().
+     In the loop where fDataRang is set, the local variable v must 
+     be used with indices n1 and n2.   
+
+
+
+
+ 2003/08/19: Wolfgang Wittek
+
+    * manalysis/MCT1Supercuts.[h,cc]
+      - new class
+      - container for the supercut parameters
+
+    * manalysis/MCT1SupercutsCalc.[h,cc]
+      - get supercut parameters from container 'MCT1Supercuts'
+
+    * manalysis/MCT1FindSupercuts.[h,cc]
+      - new class
+      - optimizes the parameters for the supercuts
+
+    * manalysis/MMinuitInterface.[h,cc]
+      - new class
+      - interface for Minuit
+
+    * manalysis/Makefile
+                AnalysisLinkDef.h
+      - include MCT1FindSupercuts
+                MMinuitInterface
+
+    * mhist/MH3.cc
+      - reset fHist in SetupFill();
+        this is necessary if the same MH3 object is used in more than one 
+        eventloop 
+
+    * mhist/MHMatrix.cc
+      - give name to the event loop
+
+    * mhist/MHFindSignificance.[h,cc]
+      - new class
+      - calculates the significance of the gamma signal in the alpha plot      
+
+    * mhist/MHCT1Supercuts.[h,cc]
+      - new class
+      - plots various quantities during the optimization of the supercuts
+
+    * mhist/Makefile
+            HistLinkDef.h
+      - MHFindSignificance included
+      - MHCT1Supercuts included
+
+
+
+ 2003/08/01: Thomas Bretz
+
+   * mhist/MHCamera.[h,cc]:
+     - added Fill(x, y, w)
+     - renamed GetStats to GetStatisticBox
+     
+   * mhist/MHStarMap.[h,cc]:
+     - include TH2 moved to source file
+
+   * mranforest/MRanForest.[h,cc], mranforest/MRanTree.[h,cc]:
+     - do not use all the data numbers and dimensions in thousands
+       of arguments if the data is available eg from the size of an array
+     - removed obsolete variables from header
+     - many small simplifications
+     - removed some obsolete variables from functions
+     - added many const qualifiers
+     - localized many more variables
+     
+   * mranforest/MRanForestFill.[h,cc]:
+     - default fNumTrees set to -1 tree (all trees)
+
+   * manalysis/MBlindPixelCalc.[h,cc]:
+     - interpolate Pedestal, too
+     - Only count 'valid' pixels
+     
+   * mfileio/MRead.[h,cc]:
+     - enhanced AddFiles
+     
+   * mhist/MHCamEvent.[h,cc]:
+     - Added PrintOutlayers
+
+   * mhist/MHCamera.[h,cc]:
+     - added GetNumPixels
+     - added default to GetMean and GetRMS
+
+   * mhist/MHTriggerLvl0.[h,cc]:
+     - added PrintOutlayers
+
+   * merpp.cc:
+     - added more arguments
+     - replace .raw by .root if no root file given
+     - automatic extension adding
+     
+   * mbase/MEvtLoop.[h,cc]:
+     - added estimated run time
+     - in Process: Changes type of rc from Bool_t to Int_t 
+     
+   * mmain/MStatusDisplay.cc:
+     - changed order in Tab-menu
+     
+   * mraw/MRawFileRead.cc:
+     - consistency check for 0xc0c1 files
+     
+   * mraw/MRawRunHeader.cc:
+     - initialize variables
+     - added 0xc0c1 support
+
+
+     
+ 2003/07/29: Thomas Bretz
+ 
+   * manalysis/MBlindPixelCalc.cc:
+     - count only pixel which contents are adde
+     
+   * mbase/MArgs.cc:
+     - added namespace
+     
+   * mbase/MDirIter.h:
+     - added rec-argument to constructor
+     
+   * mfileio/MCT1ReadPreProc.[h,cc], mfileio/MReadRflFile.[h,cc]:
+     - adapted to virtual base function
+     
+   * mfileio/MRead.[h,cc]:
+     - added AddFiles(MDirIter&)
+     - changed AddFile to virtual
+     
+   * mfileio/MReadTree.cc:
+     - use AddFile in the constructor
+     
+   * mhist/MH.[h,cc]:
+     - remove 'nonew' from option
+     
+   * mhist/MHHadronness.[h,cc]:
+     - added GetHadronness
+     - changed output
+     
+   * mhist/MHMatrix.[h,cc]:
+     - use TMatrixRow in shuffle
+     - added ReduceRows
+     - use default for PrintStatistics
+     - removed graphics from Fill - will crash in batch mode
+     
+   * mimage/ImageLinkDef.h, mimage/Makefile:
+     - added MImgCleanTGB
+     
+   * mimage/MCameraSmooth.h:
+     - fixed a typo
+     
+   * mmain/MStatusDisplay.cc:
+     - added sanity check to HasCanvas
+     
+   * mranforest/MHRanForest.cc, mranforest/MHRanForestGini.cc:
+     - fixed a crashed caused by GetMaximum in newer root versions
+     - optimized some small pieces of code
+     - SetRangeUser removed, problems with newer root verion using
+       roots auto-scale instead
+       
+   * mranforest/MRanForest.cc:
+     - do not use variables in arguments which can be used locally
+     - replaced pow(,2) by faster and more accurate val*val
+     - test gRandom at the beginning of the function
+     - changed output
+     - removed TArray::Reset. Not necerry at many places. Instatiation
+       already initializes array with 0s
+     - Use a const reference to the matrices instead of a copy!
+     - Removed some unnecessary castings
+     - added some const qualifiers
+     - removed fErr from data members (obsolete)
+     
+   * mranforest/MRanForestCalc.cc:
+     - fixed a typo in the comments
+     
+   * mranforest/MRanTree.[h,cc]:
+     - do not use variables in arguments which can be used locally
+     - localized some variables
+     - test gRandom at the beginning of the function
+     - added some const qualifiers
+     - removed TArray::Reset. Not necerry at many places. Instatiation
+       already initializes array with 0s
+     - added some overwrites of TreeHad
+
+
+
+ 2003/07/17: Oscar Blanch
+
+   * mmc/MMcCorsikaRunHeader.[h,cc]
+     - add member data fNumTelesope
+     - add member data fTelescopes
+     - add member data fViewconeAngles[2]
+     - add member function Fill_CT
+     - version increased 2 -> 3
+
+   * mmc/MMcRunHeader.[hxx,cxx]
+     - add member data fImpactMax
+     - modify member function Fill
+     - version increased 3 -> 4
+
+   * mmc/MMcFadcHeadr.[hxx,cxx]
+     - add member data f[Ampl,Fwhm]Outer
+     - add member data fLow2HighGain
+     - modify member function Set[Ampl,Fwhm]
+     - add member function SetLow2High
+
+   * mmc/Mdefine.h, MFadcDefine.h, MTriggerDefine.h
+     - MFADC_CHANNELS, CAMERA_PIXELS, TRIGGER_PIXELS -> 3500
+
+   * mgeom/MGeomCorsikaCT.[h,cc]
+     - new class with information of CT location in Corsika simulation
+
+   * mgeom/Makefile, GeomLinkDef.h
+     - add new class
+
+
+
+
+
+ 2003/07/14: Wolfgang Wittek
+
+    * mhist/MHOnSubtraction.[h,cc]
+      - add member function GetSignificance()
+
+    * mhist/MHMatrix.cc
+      - add MProgressBar in Fill()
+
+    * mmontecarlo/MMcEnergyEst.h
+      - add member functions GetNumCoeffA()
+                             GetNumCoeffB()
+
+    * mfilter/MCT1SelBasic.[h,cc]
+      - remove runs 601, 613, 614 for MC gamma
+
+    * manalysis/MCT1SupercutsCalc.cc
+      - remove bug (dd2)
+      - set fMatrix = NULL in constructor
+
+    * mgeom.MGeomCamCT1Daniel.[h,cc]
+      - new; Daniel's CT1 geometry
+
+    * mgeom/Makefile
+            GeomLinkDef.h
+
+
+
+ 2003/07/14: Oscar Blanch
+
+    * mgeom/MGeomCamMagic919.[h,cc]
+      - Geometry for a Magic camera with 919 small pixels
+
+    * mgeom/[Makefile, GeomLinkDef.h]
+      - Compiling the above mentioned geometry
+
+
+
+ 2003/07/13: Thomas Bretz
+
+    * mbase/MArgs.[h,cc]:
+      - fixed compile problem with root 3.02/07
+
+    * meventdisp/MGCamDisplay.cc, mevtdisp/MGEvtDislay.cc:
+      - fixed missing MHCamera::SetOptStat
+
+
+
+ 2003/07/12: Thomas Bretz
+ 
+   * mhistmc/MHMcCT1CollectionArea.[h,cc]:
+     - made the enum as FillType_t a public member of the class
+
+   * macros/CT1collarea.C
+     - Updated accordingly. Can somebody please check whether it
+       still works.
+ 
+   * mbase/MArgs.h:
+     - added some comment
+     
+   * mraw/MRawRunHeader.cc:
+     - added an 'inf' to the log-stream
+  
+   * macros/status.C:
+     - added some more plots
+     - added some sanity chacks
+
+   * macros/sumevents.C, macros/sumeventserr.C, macros/sumeventsrms.C
+     macros/sumpedestalrms.C, macros/sumpedestals.C:
+     - fixed SetOptStat
+     
+   * manalysis/MBlindPixelCalc.[h,cc]:
+     - removed dangerous SetPixels(int, short*)
+     - changed Id to Idx
+     - fixed a bug in SetPixels which caused crashes
+     - renamed SetPixels to SetPixelIndices
+
+   * mhist/MHCamera.[h,cc]:
+     - removed SetOptStat and fOptStat - found a better solution
+     - fixed DistancetoPrimitive to show TPaveStat correctly
+     - Use GetPainter() instead of an own THistPainter
+
+   * mmain/MStatusDisplay.cc:
+     - some small changes to the layout
+
+
+
+ 2003/07/11: Wolfgang Wittek
+
+   * mhist/MHMatrix.cc
+     - add tlist.PrintStatistics() after event loop
+
+
+
+ 2003/07/08: Abelardo Moralejo
+
+   * mmc/MMcEvt.hxx
+     - Uncommented the getter function for fCoreX and fCoreY (is there
+       any reason why they were commented out?). Added Getter functions
+       for the parameters of the longitudinal fit to the particle 
+       distribution of the shower.
+
+
+
+ 2003/07/08: Wolfgang Wittek
+
+   * macros/CT1EgyEst.C:
+     - de-comment filters 
+     - add PrintStatistics after event loop
+
+   * manalysis/MEnergyEstParamDanielMkn421.[h,cc]
+     - new; calculates estimated energy using Daniel's parametrization
+       and parameter values for Mkn421
+
+   * manalysis/AnalysisLinkDef.h
+               Makefile
+     - include MEnergyEstParamDanielMkn421
+
+   * manalysis/MCT1SupercutsCalc.[h,cc]
+     - add MHillasSrc.fAlpha to fMap
+     - add member functions SetParams(Double_t *par)
+                            GetParams(Double_t *par)
+
+
+
+ 2003/07/06: Abelardo Moralejo
+
+   * mhistmc/MHMcCT1CollectionArea.[h,cc]
+     - Added possibility of using a logarithmic or linear scale in
+       energy. The function MHMcCT1CollectionArea::SetEaxis sets
+       what should be filled in the energy axis (either the energy 
+       or its decimal logarithm).
+
+   * macros/CT1collarea.C
+     - Added example on how to use the new function 
+       MHMcCT1CollectionArea::SetEaxis
+
+
+
+ 2003/07/06: Thomas Bretz
+ 
+   * Makefile:
+     - replaced '-shared' by $(DYNLIB)
+     
+   * Makefile.conf.linux, Makefile.conf.linux-gnu,
+     Makefile.conf.osf1, Makefile.conf.osf5.1:
+     - added DYNLIB
+     
+   * Makefile.conf.darwin:
+     - added
+   
+   * mgui/MCamEvent.cc:
+     - removed obsolete include
+     
+   * mgui/Makefile:
+     - removed obsolete include dirs
+     
+   * mhist/MHCamera.cc:
+     - fixes for root 3.05/01
+     
+   * mraw/MRawEvtData.cc:
+     - added type 1 and 2 to GetPixContent
+     
+   * mraw/MRawEvtPixelIter.[h,cc]:
+     - added GetMax[Hi,Lo]GainSample
+
+   * macros/pixsatrate.C:
+     - added
+
+   * Makefile.conf.general:
+     - added -lHistPainter
+     
+   * NEWS:
+     - updated
+     
+   * macros/pixsatrate.C:
+     - added Saturation rate of lo gains
+     
+   * macros/sumevents.C, macros/sumeventserr.C,
+     macros/sumpedestalrms.C, macros/sumpedestals.C:
+     - fixed axis titles
+     - use new SetOptStat
+     
+   * manalysis/MCerPhotAnal2.[h,cc]:
+     - count and print number of skipped events
+     
+   * meventdisp/MGCamDisplay.cc:
+     - fixed a 'division by zero'
+     
+   * mhist/MHCamEvent.cc, mhist/MHTriggerLvl0.cc:
+     - take name from MHCamEvent if fNameEvt not available
+     
+   * mhist/MHCamera.[h,cc]:
+     - use THistPainter to Draw title and statistics box
+     - added fOptStat
+     - added GetMean
+     - added GetRMS
+     - some modification for a better layout
+     
+   * mraw/MRawEvtHeader.cc:
+     - calculate time from clock ticks
+
+   * mbase/MArgs.[h,cc]:
+     - added
+
+   * mbase/Makefile:
+     - MArgs.cc added
+
+   * mbase/BaseLinkDef.h:
+     - MArgs, MArgsEntry added
+
+   * merpp.cc:
+     - added '-v' option
+     - changes to use MArgs
+
+
+
+
+
+ 2003/07/04: Wolfgang Wittek
+
+   * macros/CT1EgyEst.C
+     - add TCanvas and cd() before calling Draw()
+
+   * mhistmc/MHMcEnergyMigration.cc
+     - swap first 2 arguments of fHist.Fill and fHist2.Fill
+
+
+
+ 2003/07/03: Abelardo Moralejo
+
+   * mhistmc/MHMcCT1CollectionArea.cc
+     - Added code to allow the calculation of CT1 collection areas 
+       at 55 and 65 degrees (from the events in DK's MC library)
+
+   * macros/CT1collarea.C
+     - Changed binning in theta to include high ZAs
+
+
+
+ 2003/07/01: Thomas Bretz
+
+  * manalysis/MCerPhotAnal2.cc:
+    - fixed some problems with the lo-gains
+  
+  * mraw/MRawEvtPixelIter.cc:
+    - Determin the maximum sample of the lo gains from the end.
+
+
+
+ 2003/07/01: Abelardo Moralejo
+
+   * macros/CT1collarea.C
+     - changed "const TArrayD xed(10,xedge);"  to:
+	       "const TArrayD xed; xed.Set(10,xedge);"
+       (and the same for yed). Otherwise, a funny Error message was 
+       printed about TArrayD, although everything worked.
+
+   * mhistmc/MHMcCT1CollectionArea.cc
+     - added some comments and made code more readable and more simple
+       to make it easier the addition of the necessary changes to allow 
+       the use of MC data (from D.Kranich) at zenith angles 55 and 65 
+       degrees.
+
+
+
+ 2003/07/01: Wolfgang Wittek
+
+   * manalysis/MSigmabar.cc, manalysis/MCT1PadSchweizer.cc,
+     manalysis/MCT1PadONOFF.cc, mhist/MHSigmaTheta.cc:
+     - change code because GetPixRatio returns area(pixel_zero)/area(pixel)
+                                       and not area(pixel)/area(pixel_zero)
+
+   * macros/CT1Analysis.C, macros/ONOFFCT1Analysis.C
+     - current versions of CT1 macros
+
+   * macros/unfold.C, macros/fluxunfold.C
+     - macros for testing the unfolding within root
+
+
+
+ 2003/06/30: Thomas Bretz
+ 
+   * macros/pixfirerate.C:
+     - changed to new style
+     
+   * manalysis/MCerPhotCalc.cc:
+     - scale weight so that sum=1
+     
+   * mhist/MHCamera.h:
+     - small change
+
+   * mmontecarlo/MMcCollectionAreaCalc.cc:
+     - small simplifications
+
+
+
+ 2003/06/27: Abelardo Moralejo
+
+   * mmontecarlo/MMcCollectionAreaCalc.[h,cc],
+     mhistmc/MHMcCollectionAreaCalc.[h,cc]:
+     - Adapted to allow their use with multiple files containing
+       MC data generated with diffferent energy spectra, even with
+       camera files which have only triggered events inside. Now the
+       histogram containing all showers (before trigger) is filled
+       in the ReInit function, and calculation of collection area
+       is done by CalcEfficiency2(). Some simplifications and cleaning 
+       are still possible.
+
+
+
+ 2003/06/27: Thomas Bretz
+ 
+   * macros/sumevents.C, macros/sumpedestals.C:
+     - some small changes
+     
+   * manalysis/MPedestalCam.cc:
+     - return pixel as used if the value is valid (>=0)
+     
+   * mhist/HistLinkDef.h, mhist/Makefile:
+     - MHPixVsTime added (Name is preliminary)
+
+   * mhist/MHCamEvent.cc:
+     - removed including MGeomPix
+     
+   * mhist/MHCamera.h:
+     - in SetCamContent copy also number of entries
+     
+   * mraw/MRawEvtData.cc:
+     - fixed to support correct pixel numbering
+     
+   * mhist/MHPixVsTime.[h,cc]:
+     - added
+
+   * mhist/MHCamera.cc:
+     - changed output of labels for color axis
+
+   * mfileio/MCT1ReadPreproc.cc:
+     - small simplification
+
+
+
+ 2003/06/27: Abelardo Moralejo
+
+   * mhistmc/MHMcCT1CollectionArea.cc:
+     - Added comments, changed theta angle corresponding to first bin to
+       adapt it to new standard theta-bin definition. This was the reason
+       for the missing area at low theta.
+
+   * macros/CT1collectionArea.C, macros/CT1EgyEst.C:
+     - Changed theta binnings to adapt them to the new standard.
+
+
+
+ 2003/06/26: Abelardo Moralejo
+
+   * macros/CT1EgyEst.C:
+     - Added to the argument list of CT1EEst the binnings in theta
+       and energy. Commented out the MLog.h and MLogManip.h, headers,
+       otherwise it does not run (don't know why). Commented out filters 
+       (my test file does not contain hadronness), please uncomment 
+       them to run on files with hadronness info.
+
+   * mhistmc/MHMcEnergyMigration.cc:
+     - exchanged axes of E_est and E_MC in the 3-d histograms.
+
+   * mfileio/MCT1ReadAscii.cc, mfileio/MCT1ReadPreProc.cc,
+     mhist/MHSigmaPixel.cc, mfileio/MHSigmaTheta.cc,
+     mimage/MImgCleanStd.cc:
+     - adapted to new function names in MPedestalPix (please Thomas
+       check these, I had to do it to make Mars compile)
+
+
+
+ 2003/06/26: Thomas Bretz
+
+  * macros/CT1EgyEst.C:
+    - converted from dos to unix type
+
+   * macros/rootlogon.C:
+     - removed "-fno-rtti" from options for Aclic
+     
+   * mbase/MLog.h:
+     - added a comment
+     
+   * mgeom/MGeomCam.[h,cc], mgeom/MGeomPix.[h,cc],
+     mgeom/MGeomCamCT1.cc, mgeom/MGeomCamECO1000.cc,
+     mgeom/MGeomCamECO1000HG.cc, mgeom/MGeomCamMagicHG.cc:
+     - added support for sectors
+   
+   * megom/MGeomCamMagic.[h,cc]:
+     - added sectors
+     
+   * mhist/MHCamera.[h,cc]:
+     - convert Option_t in Paint to lower case
+     - remove 'hist' if detected from Option_t 
+     - check for min==max
+     - added DrawSectorIndices()
+     - added TArrayC to AddCamContent
+     - added TArrayC to SetCamContent
+     - simplified DistancetoPrimitive
+     
+   * mraw/MRawEvtData.cc:
+     - simplified Draw by converting option string to lower case
+     
+   * mraw/MRawEvtPixelIter.[h,cc]:
+     - added GetNumMaxLoGainSample
+
+   * manalysis/MCT1PadSchweizer.cc, manalysis/MMcPedestalNSBAdd.cc,
+     manalysis/MSigmabar.cc:
+     - adapted to new function names in MPedestalPix
+     
+   * manalysis/MCerPhotAnal.cc:
+     - adapted to new function names in MPedestalPix
+     - fixed to work with real data and monte carlo data
+     - preliminarily removed error of pedestal and pedestalrms
+     
+   * manalysis/MCerPhotCalc.[h,cc]:
+     - adapted to new function names in MPedestalPix
+     - fixed to work with real data and monte carlo data
+   
+   * manalysis/MMcPedestalCopy.cc, manalysis/MPedCalcPedRun.[h,cc]:
+     - adapted to new function names in MPedestalPix
+     - preliminarily removed error of pedestal and pedestalrms
+ 
+   * manalysis/MPedestalCam.[h,cc]:
+     - adapted to new function names in MPedestalPix
+     - preliminarily removed error of pedestal and pedestalrms
+     - fixed GetPixelContent (do not return Pedestal*PixRatio)
+     
+   * manalysis/MPedestalPix.[h,cc]:
+     - removed old variables
+     - introduced Pedestal for pedestal
+     - introduced pedestalRMS for the rms of the pedestal
+     - error of both values still missing
+     
+   * meventdisp/MGCamDisplay.cc:
+     - fixed display, displays now:
+       + Number Of Photons
+       + Pedestal
+       + PedestalRMS
+       + Number of Photons/PedestalRMS
+       
+   * mimage/MImgCleanStd.[h,cc]:
+     - fixed image cleaning in the sense that erronously the error
+       of the number of photons was used instead of the error of
+       the PMT offset (pedestal)
+     - introduced some debugging option
+     
+   * mmontecarlo/MMcCollectionAreaCalc.cc:
+     - minor change
+
+   * macros/sumevents.C, macros/sumpedestals.C:
+     - added
+
+   * mhist/MHCamEvent.cc:
+     - do not scale with 100
+
+   * mhist/MHCamera.cc:
+     - fixed displaying number of entries when used 
+       SetCamContent(MHCamera&)
+
+
+
+ 2003/06/25: Thomas Bretz
+
+   * mgeom/MGeomCam.cc:
+     - fixed the description of GetPixRatio
+
+
+
+ 2003/06/25: Abelardo Moralejo
+
+   * mimage/MImgCleanStd.cc:
+     - Changed name of variable "ratio" to "factor", wherever it meant
+       the square root of the ratio between the area of an inner pixel
+       and the current pixel (it was confusing).
+
+
+
+ 2003/06/24: Thomas Bretz
+
+   * manalysis/MCT1SupercutsCalc.[h,cc]:
+     - implemented Mapping for Supercuts
+     - changed data member arrays to TArrayD
+     
+   * manalysis/MEnergyEstParam.h:
+     - added a comment
+
+   * mhist/MHHadronness.[h,cc]:
+     - implemented mapping
+     - implemented calculating Acc_g/sqrt(Acc_h) for filtercuts
+
+   * macros/status.C:
+     - removed MSrcPosCam
+
+   * mevtdisp/MGCamDisplay.cc:
+     - display ellipse in all canvas'
+
+   * macros/readrfl.C:
+     - adapted
+
+   * manalysis/MMcTriggerLvl2.cc, meventdisp/MGEvtDisplay.cc,
+     mraw/MRawEvtPixelIter.cc:
+     - adapted
+   
+   * mgui/MCamEvent.[h,cc], mhist/MHCamEvent.[h,cc]:
+     - more comments
+     
+   * mgui/MHexagon.[h,cc]:
+     - removed obsolete destructor
+
+   * mhist/MHCamera.[h,cc]:
+     - removed fPhotons
+     - removed ShowRflEvent
+     - added comments
+     
+   * mhist/MHTriggerLvl0.cc:
+     - fixed comments
+     
+   * mraw/MRawEvtData.cc:
+     - some small changes
+     
+   * mreflector/MRflEvtData.[h,cc]:
+     - implemented Paint function
+
+   * meventdisp/MGCamDisplay.cc:
+     - Set Name and title of MHCamera instances
+      
+   * mraw/MRawEvtData.cc:
+     - fixed a degug level problem
+
+   * mgui/MHexagon.[h,cc]:
+     - fixed CopyConstructor
+
+   * mbase/MLog.cc:
+     - fixed a bug in NoColor mode
+
+
+
+ 2003/06/23: Thomas Bretz
+ 
+   * manalysis/MBlindPixelCalc.[h,cc], manalysis/MCT1PadONOFF.[h,cc],
+     manalysis/MCT1PadSchweizer.[h,cc], manalysis/MCompProbCalc.[h,cc],
+     manalysis/MCT1PointingCorrCalc.[h,cc], manalysis/MEnergyEstimate.[h,cc],
+     manalysis/MCT1SupercutsCalc.[h,cc], manalysis/MEnergyEstParam.[h,cc],
+     manalysis/MFiltercutsCalc.[cc,h], manalysis/MMatrixLoop.[h,cc],
+     manalysis/MMcPedestalCopy.[h,cc], manalysis/MMcPedestalNSBAdd.[h,cc],
+     manalysis/MMcTriggerLvl2Calc.[h,cc], manalysis/MPadding.[h,cc],
+     manalysis/MMultiDimDistCalc.[h,cc], manalysis/MPedCalcPedRun.[h,cc],
+     manalysis/MPedestalCalc.[h,cc], manalysis/MPointingCorr.[h,cc],
+     mbase/MClone.[h,cc], mbase/MGTask.[h,cc], mbase/MPrint.[h,cc],
+     mbase/MTask.[h,cc], mbase/MTaskInteractive.[h,cc], 
+     mbase/MTaskList.[h,cc], mtools/MChisqEval.[h,cc],
+     mbase/MContinue.[h,cc], mdatacheck/MDumpEvtHeader.[h,cc]
+     mfileio/MCT1ReadAscii.[h,cc], mfileio/MCT1ReadPreProc.[h,cc],
+     mfileio/MReadCurrents.[h,cc], mfileio/MReadMarsFile.[h,cc],
+     mfileio/MReadRflFile.[h,cc], mfilter/MF.[h,cc], 
+     mfilter/MFAlpha.[h,cc], mfilter/MFCT1SelBasic.[h,cc],
+     mfilter/MFCT1SelFinal.[h,cc], mfilter/MFCT1SelStandard.[h,cc],
+     mfilter/MFDataChain.[h,cc], mfilter/MFDataMember.[h,cc],
+     mfilter/MFEnergySlope.[h,cc], mfilter/MFEventSelector.[h,cc],
+     mfilter/MFEventSelector2.[h,cc], mfilter/MFParticleId.[h,cc],
+     mfilter/MFTriggerLvl1.[h,cc], mfilter/MFTriggerLvl2.[h,cc],
+     mfilter/MFilterList.[h,cc], mhist/MFillH.[h,cc], 
+     mimage/MCameraSmooth.[h,cc], mimage/MHillasCalc.[h,cc],
+     mimage/MHillasSrcCalc.[h,cc], mimage/MImgCleanStd.[h,cc],
+     mimage/MNewImageParCalc.[h,cc], mmontecarlo/MMcThresholdCalc.[h,cc], 
+     mranforest/MRanForestCalc.[h,cc], mranforest/MRanForestFill.[h,cc]
+     mmontecarlo/MMcTimeGenerate.[h,cc], mranforest/MRanForestGrow.[h,cc],
+     mmontecarlo/MMcCollectionAreaCalc.[h,cc], mraw/MRawFileWrite.[h,cc],
+     mmontecarlo/MMcTriggerRateCalc.[h,cc], mraw/MRawFileRead.[h,cc],
+     manalysis/MSigmabarCalc.[h,cc], manalysis/MCerPhotAnal.[h,cc],
+     manalysis/MCerPhotCalc.[h,cc]:
+     - changed Bool_t in *Process to Int_t to support newer root
+       versions correctly - PRELIMINARY (will be replaced by
+       enums in the future)
+       
+   * manalysis/MCerPhotEvt.[h,cc]:
+     - added case 3 and 4 to GetPixelContent
+     - changed definition of GetPixelContent
+
+   * manalysis/MCurrents.[h,cc], manalysis/MPedestalCam.[h,cc]:  
+     - changed definition of GetPixelContent
+
+   * manalysis/MFiltercutsCalc.[h,cc]:
+     - Added list to ListOfCleanups, and set kMustCleanup for list
+     - Set kMustCleanup for external filters
+
+   * mbase/MEvtLoop.[h,cc]:
+     - added to ListOfCleanups
+     - Set kMustCleanup for parlist, progressbar and display
+     - added some checks for root's Batch-Mode
+     - no need for checking ListOfSpecials for fDisplay (this is now
+       handled through the Cleanups)
+     - No need for kFileExit anymore (this can now be handles through 
+       the Cleanups)
+     - added recursiveRemove to support Cleanups
+     - added SetDisplay to set kMustCleanup for fDisplay
+
+   * mbase/MTaskList.cc, mdata/MDataArray.cc, mdata/MDataList.cc,
+     mfilter/MFilterList.cc:
+     - added lists to ListOfCleanups
+     - Set kMustCleanup for the lists
+
+   * mbase/MParList.[h,cc]:
+     - added lists to ListOfCleanups
+     - Set kMustCleanup for the lists
+     - added kCanDelete option to destructor
+     - set kMustCleanup for all containers added to thelist
+   
+   * mdatacheck/DataCheckLinkDef.h, mdatacheck/Makefile:
+     - removed unnecessary MDumpEvtHeader
+     
+   * mbase/MContinue.[h,cc]:
+     - added SetDisplay to support setting display for the filter
+     - added SetLogStream to support setting logstream for the filter
+     
+   * mfilter/MFCT1SelBasic.cc, mfilter/MFCT1SelFinal.cc, 
+     mfilter/MFCT1SelStandard.cc:
+     - added Set-function to simplify Process
+     
+   * mgui/MCamEvent.[h,cc]:
+     - changed GetPixelContent definition
+     
+   * mhist/MH.cc:
+     - fixed Draw(TH1&, TH1&) and DrawCopy layout for newer root versions
+
+   * mimage/MImgCleanStd.cc:
+     - fixed a bug in the access to ispixused-array (GetNeighbor 
+       could exceed maximum entries.
+       
+   * mmain/MStatusDisplay.[h,cc]:
+     - preliminary fixes to support root's batch mode
+     - removed adding MStatusDisplay to ListOfCleanups
+     - changed code updating the Canvas'
+     - exit now handled by Cleanups, so this can be deleted immediatly
+     
+   * mraw/MRawEvtData.[h,cc]:
+     - changed definition of GetPixelContent
+     - added code to GetPixelContent
+
+   * mraw/MRawEvtPixelIter.[h,cc]:
+     - returns GetNumMaxHiGainSample
+
+   * mreflector/MRflEvtData.[h,cc]:
+     - use static_cast in GetPhoton
+     - added GetPixelContent
+
+   * mhist/MHTriggerLvl0.[h,cc], MHmhist/Camera.[h,cc], 
+     mhist/MHCamEvent.[h,cc]:
+     - added
+
+   * manalysis/MSigmabar.cc:
+     - unimportant simplification
+     
+   * manalysis/MSigmabarCalc.cc:
+     - added a preliminary workaround to support files without MMcEvt
+     - make use of FLT_MAX
+     
+   * mgeom/MGeomCam.[h,cc]:
+     - Moved fPixels from pointer to an instance
+     - removed destructor
+     - use static_cast on operator[]
+     - Use ForEach macro in CheckOuterRing
+
+   * mhist/MHSigmaTheta.cc:
+     - added a preliminary workaround to support files without MMcEvt
+ 
+   * manalysis/AnalysisLinkDef.h, manalysis/Makefile:
+     - removed MCT1PadONOFF
+     
+   * manalysis/MCerPhotEvt.h:
+     - added //-> to fPixels
+
+   * meventdisp/Makefile:
+     - added -I../mhist
+
+   * manalysis/MMcTriggerLvl2.[h,cc], meventdisp/MGCamDisplay.[h,cc]:
+     - replaced MCamDisplay by MHCamera
+
+   * mgui/GuiLinkDef.h, mgui/Makefile:
+     - removed MCamDisplay
+     
+   * mhist/HistLinkDef.h, mhist/Makefile:
+     - removed MHCerPhotEvt
+     - removed MHCurrents
+     - removed MHTrigLvl0
+     - removed MHOnSubtraction
+     - added MHCamera
+     - added MHCamEvent
+
+   * macros/sumcurrents.C:
+     - adapted to changes
+     - added filename to canvas
+  
+   * macros/readMagic.C, macros/readCT1.C, macros/status.C,
+     macros/readcurrents.C, macros/readrfl.C:
+     - adapted to changes
+     
+   * mbase/MAGIC.h:
+     - replaced extern by R__EXTERN
+
+   * mbase/MParContainer.[h,cc]:
+     - added a non empty destructor with some debug options
+
+   * mbase/MPrint.cc:
+     - fixed a bug (used kSKIP instead of kSkip)
+
+
+
+ 2003/06/19: Thomas Bretz
+ 
+   * mgui/MCamDisplay.[h,cc]:
+     - fixed color palette when loading MCamDisplay
+
+   * mevtdisp/MGEvtDisplay.cc:
+     - fixed a bug in ProcessMessage, 'Exit' still doesn't work.
+
+
+
+ 2003/06/18: Thomas Bretz
+
+   * macros/sumcurrents.C:
+     - added MDirIter support
+     - fixed the rel. error calculation
+     - some small corrections to the layout
+     
+   * mhist/MHCurrents.cc:
+     - changed histogram name
+     - added axis titles
+
+   * mbase/MLog.cc:
+     - include iomanip onstead of MLogManip
+
+   * mbase/MLogManip.h:
+     - replaced preprocessor defintions for all, warn, inf, err and dbg
+       by const variable declarations
+     - fixed dynamic_casts
+
+   * macros/merpp.C:
+     - made capable of more than one directory
+     
+   * mmain/MStatusDisplay.cc:
+     - removed an unsused variable
+
+   * Makefile.conf.osf1, Makefile.conf.osf5.1:
+     - added definitions for __USE_STD_IOSTREAM and R__ANSISTREAM
+       tp be able to compile on Alphas again
+       
+   * manalysis/MCT1PadONOFF.cc:
+     - included math.h
+     - commented out some code to be able to compile on Alpha - FIXME
+     
+   * mbase/MDirIter.h:
+     - fixed a bug in the definition of MatchFilter
+
+   * mraw/MRawFileWrite.h:
+     - default mode changed from UPDATE to RECREATE
+     - default compression level changed from 9 to 1
+
+   * mraw/MRawEvtData.[h,cc]:
+     - fixed to skip non connected pixels
+     
+   * mraw/MRawRunHeader.[h,cc]:
+     - added GetNumConnectedPixels
+
+
+
+
+ 2003/06/17: Oscar Blanch
+
+  * mgeom/MGeomCamECO1000HG.cc
+    - fixed a bug in NN table
+
+  * mgeom/MGeomCamMagicHG.[h,cc]
+    - New geometry for a high granularity hipothetic Magic camera
+
+  * mgeom/Makefile and mgeom/GeomLinkDef.h
+    - Introduction of MGeomMagicHG class.
+
+
+
+ 2003/06/17: Thomas Bretz
+
+   * meventdisp/MGEvtDisplay.cc:
+     - fixed a bug which caused a endlessloop
+
+   * mmain/MStatusDisplay.cc:
+     - fixed UpdatePSHeader for gcc 3.* and Suse 8.2
+
+   * manalysis/MCurrents.h:
+     - fixed a bug in the const operator[]
+
+   * mgui/MCamDisplay.[h,cc]:
+     - set ClassDef to 1 so that the camera display can be written into
+       a root file
+     - fixed destructor (didn't fit default constructor)
+     - implemented FillRandom for test cases
+
+   * mgui/MHexagon.h
+     - set ClassDef to 1 so that the camera display can be written into
+       a root file
+
+
+
+ 2003/06/16: Thomas Bretz
+
+   * mhist/MHOnSubtraction.cc:
+     - worked around the non compiling source file
+
+   * merpp.cc:
+     - set compression level default = 1
+
+   * macros/readCT1.C, macros/readMagic.C, macros/readcurrents.C,
+     meventdisp/MGCamDisplay.cc
+     - adapted to new MCamDisplay and MCamEvent
+
+   * macros/sumcurrents.C:
+     - enhanced
+
+   * manalysis/MCerPhotCalc.[h, cc]:
+     - simplified algorithm
+
+   * manalysis/MCerPhotEvt.[h,cc], manalysis/MCurrents.[h,cc],
+     manalysis/MPedestalCam.[h,cc]:
+     - derived from MCamEvent
+     
+   * manalysis/MMcPedestalNSBAdd.cc:
+     - minor change
+     
+   * mbase/BaseLinkDef.h, mbase/Makefile:
+     - added MDirIter
+
+   * mbase/MDirIter.[h,cc]:
+     - added
+     
+   * mbase/MParList.cc:
+     - enhnced some output
+
+   * mbase/MTaskInteractive.cc:
+     - fixed a bug
+     
+   * mbase/MTaskList.cc:
+     - added handling of gui events for Pre- and PostProcess
+     
+   * mgeom/MGeomPix.cc:
+     - added a comment
+     
+   * mgui/MCamDisplay.[h,cc] -  PRELIMINARY:
+     - added a notification list
+     - fixed SetRange if pad is not the main pad
+     - new Fill functions using MCamEvent, removed old ones 
+     
+   * mhist/MFillH.cc:
+     - check for the existance of the canvas
+     
+   * mhist/MHCerPhotEvt.cc:
+     - take usage of MCamEvent
+
+   * mhist/MHCurrents.cc:
+     - take usage of MCamEvent
+     - added rms
+     
+   * mmain/MStatusDisplay.[h,cc]:
+     - added "Reset" and "Remove Tab" to menu bar
+
+   * mraw/MRawEvtData.[h,cc]:
+     - draw hi- and logains
+     - derived from MCamEvent
+     
+   * mraw/MRawEvtPixelIter.[h,cc]:
+     - added GetVarHiGainSamples
+
+   * mraw/Makefile:
+     - added -I../mgui - PRELIMINARY
+
+   * mhist/MH.cc:
+     - fixed Draw(TH1&,TH1&) for newer root versions
+
+   * mhist/MHHadronness.cc:
+     - fixed call to fGraph->SetMaximum(1) for newer root versions
+
+   * mmain/MStatusDisplay.cc:
+     - fixed for gcc 3.* and newer root versions
+     
+
+
+
+ 2003/06/13: Robert Wagner
+   * mhist/MHOnSubtraction.cc
+     - removed casts from double to Double_t found by gcc 3.3
+     - added MHOnSubtraction::CalcLightCurve, a methods towards a 
+       lightcurve 
+
+
+
+ 2003/06/13: Thomas Bretz (making Mars work with gcc 3.3 on Suse 8.2)
+
+   * Makefile.conf.linux:
+     - removed nonull-objects, Wtraditional and Wnested-externs
+       due to warnings in gcc 3.3
+     
+   * *:
+     - added 'using namespace std;'
+     - exchanged *.h C++ headers by correct headers (like <fstream>)
+     - replaced forward declarations of streams by <iosfwd>
+
+   * manalysis/MCerPhotAnal.cc:
+     - cast arguments of sqrt to correct type
+     - corrected argument type for SetPedestalRms
+     
+   * manalysis/MCurrents.h:
+     - const operator[] uses 'this' now
+     
+   * manalysis/MEnergyEstParam.[h,cc], manalysis/MSigmabarParam.[h,cc]:
+     - fixed definition of Print
+
+   * manalysis/MMcPedestalCopy.cc, manalysis/MPedCalcPedRun.cc,
+     mgui/MCamDisplay.cc, mmontecarlo/MMcThresholdCalc.cc:
+     - cast arguments of sqrt to correct type
+
+   * manalysis/MMultiDimDistCalc.cc:
+     - changed type of numg/numh to Int_t
+     
+   * mbase/BaseLinkDef.h:
+     - removed pragma for __omanip_debug
+
+   * mbase/MLog.[h,cc]:
+     - fixed copy constructor
+     - removed usage of mkstemp -- TO BE FIXED
+
+   * mbase/MLogManip.[h,cc]:
+     - completely replaced
+
+   * mdata/MDataArray.cc:
+     - fixed variable type ncols (Double_t -> Int_t)
+   
+   * mdata/MDataChain.cc:
+     - fixed argument type of gRandom->Integer()
+   
+   * meventdisp/MGEvtDisplay.[h,cc]:
+     - implemented skiping of  events which have 0 Pixels
+     
+   * mfileio/MCT1ReadPreProc.cc:
+     - fixed conversion for istream::read from Byte_t* to char*
+     - fixed argument type in Fill (fmcsize_phel)
+     
+   * mfileio/MChain.h:
+     - ResetTree must also set fTreeNumber to -1 due to changes in
+       TChain::LoadTree
+
+   * mfilter/MFAlpha.[h,cc]:
+      fixed type of Alpha in Init (Float_t instead of Int_t)
+      
+   * mfilter/MFEventSelector2.[h,cc]:
+     - renamed Read member function to ReadDistribution
+     
+   * mfilter/MFilterList.h:
+     - fixed overloading of GetRule
+     
+   * mhist/MBinning.cc, mhist/MH3.cc:
+     - removed default argument in source file
+
+   * mhist/MHArray.cc:
+      fixed type of sstyle (Stat_t -> Int_t)
+      
+   * mhist/MHCerPhotEvt.[h,cc], mhist/MHCurrents.[h,cc]:
+     - fixed definition of Clear()
+     
+   * mhist/MHFadcCam.[h,cc]:
+     - renamed Reset to ResetEntry
+     
+   * mhistmc/MHMcEnergy.cc:
+     - fixed argument type of log
+   
+   * mhistmc/MHMcRate.cc:
+     - cast argument of pow() to correct type
+   
+   * mimage/MHillas.cc:
+     - replaced default value for MeanX and MeanY by 0
+
+   * mmain/MMars.cc:
+     - fixed argument type in TGLayoutHints
+
+   * mmain/MStatusDisplay.cc:
+     - fixed some argument types
+     - for the moment removed the update of the ps-header
+
+   * mmc/MMcTrig.cxx:
+     - use binary shift instead of pow for power of two
+
+   * mmontecarlo/MMcEnergyEst.[h,cc]:
+     - declared fcn as static
+     - fixed definition of Print
+
+   * mmontecarlo/MMcTimeGenerate.cc:
+     - fixed argument type of SetTime
+   
+   * mmontecarlo/MMcTriggerRateCalc.[h,cc]:
+     - fixed definition of Draw
+
+   * mfileio/MReadRflFile.cc, mraw/MRawCrateData.cc, mraw/MRawEvtData.cc,
+     mraw/MRawEvtHeader.cc, mraw/MRawRunHeader.cc:
+     - fixed conversion for istream::read from Byte_t* to char*
+
+   * mreflector/MRflEvtData.cc, mreflector/MRflSinglePhoton.cc:
+     - fixed definition of Print
+
+
+
+ 2003/06/13: Robert Wagner
+   * mhist/MHOnSubtraction.cc
+     - Improvements in output
+
+
+
+ 2003/06/12: Thomas Bretz
+
+   * mgui/MCamDisplay.h:
+     - added //*MENU* to SetAutoScale, SetMinimum, SetMaximum
+
+
+
+ 2003/06/11: Robert Wagner
+
+   * mhist/MHOnSubtraction.[h,cc]
+     - Some bugfixes, e.g. concerning binning of result histograms
+     - Improvements in output
+
+
+
+
+
+ 2003/06/09: Wolfgang Wittek
+
+   * macros/CT1Analysis.C
+     - replace MPadSchweizer by MCT1PadSchweizer
+
+   * macros/ONOFFCT1Analysis.C
+     - current version of the macro for the analysis using ON, OFF and MC data
+
+   * manalysis/MPadSchweizer.[h,cc]
+               MPadONOFF.[h,cc]
+     - delete
+
+   * manalysis/MCT1PadSchweizer.[h,cc]
+               MCT1PadONOFF.[h,cc]
+     - add
+
+   * manalysis/Makefile
+               AnalysisLinkdef.h
+     - replace MPadSchweizer and MPadONOFF
+       by MCT1PadSchweizer and MCT1PadONOFF     
+
+
+
+ 2003/06/06: Robert Wagner
+
+   * mhist/MHOnSubtraction.[h,cc]
+     - Class for extracting a gamma signal from on data only. Works
+       on fully differential data in Alpha, Energy and Theta as well
+       as on single Alpha plots. Experimental version, expect
+       functionality but code still optimized for debugging purposes
+
+   * mhist/MHAlphaEnergyTheta.cc
+     - Fill signed alpha value instead of absolute value
+
+
+
+ 2003/06/06: Wolfgang Wittek
+
+   * macros/optPad.C
+     - macro for testing the optimal padding
+
+
+
+ 2003/06/05: Abelardo Moralejo
+
+   * mhist/MHTrigLvl0.[h,cc]:
+     - added. This is intended to find "hot" pixels firing too often
+       or pixels firing too rarely. Very preliminar!
+
+   * macros/pixfirerate.C:
+     - added. An example on how to use the class above.
+
+   * mhist/Makefile, HistLinkDef.h :
+     added new class.
+
+
+
+ 2003/06/05: Thomas Bretz
+
+   * mbase/MEvtLoop.cc:
+     - fixed some typos in the comments
+     
+   * meventdisp/MGCamDisplay.cc:
+     - added MHillasSrc to eventloop
+     
+   * meventdisp/MGEvtDisplay.cc:
+     - print MC informations to screen, too
+     
+   * mfileio/MReadCurrents.cc:
+     - added a comment
+     
+   * mhist/MHCerPhotEvt.h:
+     - removed typo
+     
+   * mimage/MHillasSrcCalc.cc:
+     - create a default source if now source is available
+
+
+
+ 2003/06/03: Thomas Bretz
+ 
+   * macros/readcurrents.C:
+     - display currents in Log-Scale
+
+   * mgui/MCamDisplay.[h,cc]:
+     - introduced fMinimum
+     - introduced fMaximum
+     - introduced fData
+     - removed Set-functions
+     - introduced Update()
+     - introduced Log-Scale
+
+   * macros/readCT1.C:
+     - fixed a typo
+
+   * mbase/MTaskInteractive.[h,cc]:
+     - added
+     
+   * mbase/Makefile, mbase/BaseLinkDef.h:
+     - added MTaskInteractive
+
+   * mhist/MHCurrents.[h,cc]:
+     - added (PRELIMINARY)
+
+   * mhist/Makefile, mhist/HistLinkDef.h:
+     - added MHCurrents
+
+   * mgui/MCamDisplay.[h,cc]:
+     - changed number of ItemsLegend to display the maximum, too
+
+   * macros/sumcurrents.C:
+     - added
+
+
+
+ 2003/06/03: Wolfgang Wittek
+
+   * mfileio/MCT1ReadPreProc.[h,cc]
+     - reset blind pixels for each event
+       (because they may have been changed by the padding)
+
+   * macros/ONOFFCT1Analysis.C
+     - will be the macro for the CT1 analysis using ON and OFF data
+
+   * manalysis/MPadONOFF.[h,cc]
+     - new class
+     - class for the padding of ON/OFF data
+
+   * manalysis/MPadSchweizer.[h,cc]
+     - remove fBlinds->Clear() because the resetting of the
+       blind pixels is now done in MCT1ReadPreProc
+
+
+
+ 2003/06/02: Thomas Bretz
+
+   * manalysis/AnalysisLinkDef.h, manalysis/Makefile:
+     - added MCurrents
+     
+   * manalysis/MCerPhotEvt.[h,cc]:
+     - added MGeomCam argument to GetRatioMin/Max
+     
+   * mfileio/FileIOLinkDef.h, mfileio/Makefile:
+     - added MReadCurrents
+
+   * mfileio/MReadCurrents.[h,cc]:
+     - added
+     
+   * manalysis/MCurrents.[h,cc]:
+     - added
+     
+   * mgui/MCamDisplay.[h,cc]:
+     - added current support
+
+   * mbase/MTime.h:
+     - preliminary changes to support currents
+     
+   * mhist/MH.[h,cc]:
+     - added usescreenfactor to MakeDefCanvas
+
+
+
+ 2003/05/30: Wolfgang Wittek
+
+   * macros/CT1Analysis.C
+     - current version of the CT1Analysis.C macro for the analysis of
+       CT1 data using ON and MC data
+
+
+
+ 2003/05/27: Thomas Bretz
+
+   * mreflector/Makefile:
+     - removed obsolete includes
+
+   * mbase/MLogManip.h:
+     - for the moment removed dbg<< from dbginf again
+
+   * mimage/MHNewImagePar.cc:
+     - security check in fill
+
+   * mmain/MAnalysis.cc:
+     - fixed filling of MHNewImagePar
+
+
+
+ 2003/05/26: Wolfgang Wittek
+
+   * mfileio/MCT1ReadPreProc.cc
+     - put back :  if (event.spixsig_10thphot[i]==0)
+                         continue;
+ 
+   * manalysis/MPadSchweizer.cc
+     - add pixels to MCerPhotEvt which are not yet in;
+       set their number of photons equal to zero
+
+
+
+ 2003/05/26: Thomas Bretz
+
+   * mhist/MHCerPhotEvt.cc, mfileio/MCT1ReadAscii.cc:
+     - InitSize --> FixSize
+
+   * manalysis/MMcPedestalNSBAdd.cc:
+     - fixed a typo (* instead of /)
+
+
+
+ 2003/05/23: Abelardo Moralejo
+
+   * mreflector/Makefile:
+     - added (was missing)
+
+
+
+ 2003/05/23: Thomas Bretz
+
+   * Makefile:
+     - added mreflector
+     
+   * manalysis/MCerPhotAnal.cc, manalysis/MCerPhotCalc.cc:
+     - use FixSize instead of InitSize
+     
+   * manalysis/MCerPhotEvt.[h,cc]:
+     - replaced InitSize by FixSize (seems to be more logical)
+     
+   * manalysis/MMcPedestalNSBAdd.cc:
+     - replaced GetR by GetPixRatio
+
+   * manalysis/MPedestalCam.cc:
+     - replaced GetEntries by GetEntriesFast
+     
+   * mfileio/FileIOLinkDef.h, mfileio/Makefile:
+     - added MReadRflFile
+
+   * mgeom/MGeomCam.[h,cc], mgeom/MGeomPix.[h,cc], 
+     mgeom/MGeomCamMagic.[h,cc]:
+     - replaced R by D
+
+   * mgui/MCamDisplay.[h,cc]:
+     - added TClonesArray to display reflector events
+     - added FillRflEvent
+     - added ShowRflEvent
+     - adapted Paint function
+     
+   * mgui/MHexagon.[h,cc]:
+     - replaced GetR by GetD
+     - added DistanceToPrimitive (capital T)
+     
+   * mgui/Makefile:
+     - added mreflector
+
+   * mfileio/MReadRflFile.[h,cc]:
+     - added
+
+   * mreflector, mreflector/Makefile, mreflector/ReflectorLinkDef.h,
+     mreflector/MRflEvtData.[h,cc], mreflector/MRflSinglePhoton.[h,cc]:
+     mreflector/MRflEvtHeader.[h,cc], mreflector/MRflRunHeader.[h,cc]:
+     - added
+
+   * macros/readRfl.C:
+     - added
+
+
+
+ 2003/05/22: Abelardo Moralejo
+
+   * mhist/MHMatrix.[h,cc]
+     - add member function ShuffleRows() to randomize the order of the
+       matrix rows. This is useful for instance for the random forest, 
+       (See RanForest.C) when we feed a hadron training sample with 
+       both protons and helium nuclei: if they are ordered (first all
+       events of one type, then those of the other) the method does not
+       seem to work well. Any other kind of ordering might be harmful 
+       as well (in theta, phi or whatever).
+
+
+
+ 2003/05/22: Wolfgang Wittek
+
+   * mfileio/MCT1ReadPreProc.[h,cc]
+     - add member function DiscreteTheta
+     - discretize the Theta according to the binning in Theta
+       (for data and MC)
+       original Theta is stored in the container "ThetaOrig"
+       the discretized Theta is stored in MMcEvt.fTelescopeTheta
+
+
+
+ 2003/05/21: Thomas Bretz
+
+   * mfileio/MReadTree.cc:
+     - changed text of a warning
+     - removed obsolete comment
+     
+   * mfileio/MWriteRootFile.[h,cc]:
+     - changed Print function to support kIsNewTree flag
+     - changed BIT(15) to BIT(16) because it is already used by TBranch
+
+
+
+ 2003/05/21: Wolfgang Wittek
+
+   * mhist/MHBlindPixels.[h,cc]
+     - change 1D histogram into 2D histogram (pixel Id vs. Theta)
+     - add 2D histogram : no.of blind pixels vs. Theta
+
+   * mhist/MHSigmaTheta.cc
+     - correct "BinningPix"
+
+   * manalysis/MPadSchweizer.[h,cc]
+     - add simulation of blind pixels
+
+   * mhist/MHMatrix.cc
+     - in DefRefMatrix : allow variable bin size for 'hth' and 'hthd'
+
+
+
+ 2003/05/20: Oscar Blanch Bigas
+
+   * mgeom/MGeomCamECO1000HG.[h,cc]
+     - new files for ECO1000 camera geometry with pixels
+       of half angualr size.
+
+   * mgeom/Mkefile:
+     - added MGeomCamECO1000HG.[h,cc] files
+
+   * mgeom/GeomLinkDef.h
+      - added class MGeomCamECO1000HG
+
+
+
+ 2003/05/20: Thomas Bretz
+
+   * mbase/MLog.h:
+     - added Separator member function
+     
+   * mfileio/MReadMarsFile.cc:
+     - moved output in Notify to MReadTree::Notify
+     - call MReadTree:Notify in Notify
+     
+   * mfileio/MReadTree.[h,cc]:
+     - do not try to delete a Baddress if it is NULL ("*")
+     - added CheckBranchSize member function
+     - added the size consistency check to Notify
+     
+   * mfileio/MWriteRootFile.cc:
+     - mini changes to Print-output
+     
+   * mfilter/MF.[h,cc]:
+     - added Print-function
+     
+   * mraw/MRawEvtPixelIter.h:
+     - removed wrong EOL characters
+
+   * macros/multidimdist2.C:
+     - made variable names unique
+
+   * macros/star.C:
+     - added sigmabar
+
+   * macros/status.C:
+     - added sigmabar
+     - added MHSigmaTheta
+
+   * manalysis/AnalysisLinkDef.h, manalysis/Makefile:
+     - added MFiltercutsCalc
+
+   * manalysis/MFiltercutsCalc.[h,cc]:
+     - added
+
+
+ 2003/05/19: Thomas Bretz
+
+   * mgui/MCamDisplay.cc:
+     - removed an unused variable.
+
+   * Makefile.rules:
+     - fixed Mr.Proper
+
+   * mbase/MEvtLoop.cc, mbase/MParList.cc, mbase/MTaskList.cc,
+     mfileio/MReadTree.cc, mfileio/MWriteRootFile.cc:
+     - use new manipulator 'underline'
+
+   * mbase/MLog.cc:
+     - added new underlining
+     - added blue color for debugging
+     
+   * mbase/MLogManip.[h,cc]:
+     - added underline
+     - added dbg and increased all other debug(n) levels by one
+     
+   * mbase/MParContainer.h:
+     - made fDisplay persistent (workaround for a obsolete warning in
+       root 3.02/07)
+
+   * mfileio/MWriteRootFile.[h,cc]:
+     - fixed a bug introduced when implementing UPDATE mode,
+       kIsNewTree set for TTree
+
+
+
+ 2003/05/16: Abelardo Moralejo
+
+   * mmontecarlo/MMcEnergyEst.[h,cc]
+     - Added SetCoeff
+
+
+
+ 2003/05/16: Thomas Bretz
+
+   * mfilter/MFEventSelector2.[h,cc]:
+     - added
+
+   * mfilter/Makefile, mfilter/FilterLinkDef.h:
+     - added MFEventSelector2
+
+   * mbase/MContinue.cc:
+     - SetDisplay for filter
+     - Set LogStream for filter
+     
+   * mbase/MEvtLoop.cc:
+     - don't use pointer to fTasklist in PostProcess if not initialized
+     - do not execute Process if fTasklist is not initialized
+     
+   * mbase/MTask.[h,cc]:
+     - overwrite SetDisplay (set also display of attached filter
+     
+   * mbase/MTaskList.cc:
+     - minor changes 
+     
+   * mdata/MDataChain.[h,cc]:
+     - implemented ParseDataMember to support constants
+
+   * mfileio/MCT1ReadPreProc.[h,cc]:
+     - added fNumFile to support Rewind
+     - added Rewind
+     
+   * mfileio/MRead.[h,cc]:
+     - new virtual function Rewind
+     
+   * mfileio/MReadMarsFile.[h,cc]:
+     - added Rewind
+     
+   * mfileio/MReadTree.[h,cc]:
+     - added Rewind
+     - fixed a missing 'else' in AddFile
+     
+   * mhist/MBinning.[h,cc]:
+     - added SetEdges(TAxis&)
+     - added SetEdges(TH1&, char)
+
+   * mhist/MFillH.[h,cc]:
+     - added bit kDoNotDisplay
+     
+   * mhist/MH.h:
+     - added a comment
+     
+   * mhist/MH3.[h,cc]:
+     - implemented GetRule
+     - implemented GetNbins
+     - implemented FindFixBin
+     
+   * mimage/MHHillasSrc.cc:
+     - replaced gPad->cd(4) by savepad
+
+   * mmain/MStatusDisplay.[h,cc]:
+     - fixed locked mode for loop-in-loop cases
+
+
+
+ 2003/05/15: Wolfgang Wittek
+
+   * macros/CT1EgyEst.C
+     - replace "energyest.root" by paramout
+
+
+
+ 2003/05/14: Wolfgang Wittek
+
+   * macros/CT1env.rc
+     - CT1env replaced by CT1env.rc
+
+   * mranforest/MRanForestCalc.cc
+     - exchange arguments in 
+       FindCreateObj("MHadronness", fHadronnessName)
+
+
+
+ 2003/05/13: Thomas Bretz
+
+   * mdata/MDataArray.[h,cc]:
+     - addeed GetData and >>-operator to fill a TVector from the array
+     
+   * manalysis/MMultiDimDistCalc.cc:
+     - use new >>-operator from MDataArray
+     
+   * mranforest/MRanForest.[h,cc]:
+     - TVector& in CalcHadronness declared const
+     - added a const qualifier to 'Float_t sum'
+     - removed Reset() from a TIter declaration (done by the TIter 
+       constructor)
+     
+   * mranforest/MRanForestCalc.cc:
+     - fill TVector with new >>-operator of MDataArray
+     
+   * mranforest/MRanTree.[h,cc]:
+     - removed obsolete returns at the end of some functions
+     - TVector& in TreeHad declared const
+     - changed if to ?:-operator in TreeHad
+     - TreeHad() calls TreeHad(const TVector &) now (code is not
+       implemented twice)
+
+
+
+ 2003/05/12: Abelardo Moralejo
+
+   * mhistmc/MHMcEnergyMigration.cc
+     - Draw(): fixed axis label in one plot.
+
+
+
+ 2003/05/12: Thomas Bretz
+
+   * mmain/MStatusDisplay.[h,cc]:
+     - implemented UpdatePSHeader
+
+
+
+ 2003/05/10: Thomas Bretz
+
+   * Makefile.rules:
+     - implemented diff
+     
+   * NEWS:
+     - changed
+     
+   * manalysis/MCT1SupercutsCalc.cc:
+     - fixed variable names
+     
+   * mbase/MParContainer.cc:
+     - replaces IsA()->GetName() by ClassName()
+     
+   * mbase/Makefile:
+     - removed obsolete include paths
+     
+   * mdata/MDataArray.[h,cc]:
+     - new member function GetRule(int)
+
+   * mgui/MCamDisplay.[h,cc]:
+     - implemented GetObjectInfo
+
+   * mhist/MH.[h,cc]:
+     - implemented ProjectionX
+     - implemented ProjectionY
+     - implemented FindObjectInPad
+     
+   * mhist/MHSigmaTheta.[h,cc]:
+     - implemented Paint
+     
+   * mmain/MStatusDisplay.[h,cc]:
+     - implemented kFileCanvas
+     - implemented kFileBrowser
+
+
+
+ 2003/05/09: Abelardo Moralejo
+
+   * mhistmc/MHMcEnergyMigration.[h,cc]
+     - Added histograms, changed Draw() to display them. Still 
+       provisional, many changes in the whole part of the energy 
+       estimator are needed.
+
+   * macros/CT1EEst.C, CT1EnergyEst.C
+     - Removed
+
+   * macros/CT1EgyEst.C
+     - Added example on how to use the energy estimation for CT1.
+       Very provisional!
+
+
+
+ 2003/05/09: Wolfgang Wittek
+
+   * manalysis/MCT1SupercutsCalc.cc
+     - add SetReadyToSave()
+
+
+
+ 2003/05/09: Thomas Bretz
+
+   * mbase/MLog.cc:
+     - do not underline if eNoColors is set
+     - fixed abug in Output() (last character missing when flushed)
+     - same when flushing to the GUI
+     
+   * mbase/MLogManip.cc:
+     - removed an obsolete comment
+     
+   * mfileio/MReadTree.cc:
+     - print warning in case no files could be added to chain
+     
+   * mfilter/MFDataChain.h:
+     - fixed code layout
+     
+   * mimage/MHHillasSrc.h:
+     - added Paint
+     
+   * mimage/MHillasCalc.[h,cc]:
+     - changed default title
+
+   * Makefile:
+     - added rule 'diff'
+
+   * mhist/MHMatrix.cc:
+     - compressed some debug outputs
+
+   * manalysis/MSigmabar.[h,cc]:
+     - deleted the fCalcPixNum variable (not used).
+
+   * macros/star.C, macros/starct1.C:
+     - updated
+
+   * mhist/MBinning.cc:
+     - fixed SetBinningCos
+     
+   * mhist/MHSigmaTheta.[h,cc]:
+     - in setting of binnings changes npix+1 to npix 
+       (SetEdges takes the number of _bins_ as argument)
+     - fixed titles (LaTeX style)
+     - added default binning (may have to be changed for Magic)
+     - removed obsolete destructor
+     - removed default canvas size of 900x900
+     - temporarily removed SetLogy() for first pad. I'm searching
+       for a solution to put it in again when using the status display
+
+
+
+ 2003/05/08: Thomas Bretz
+
+   * Makefile.rules:
+     - fixed the rmhtml bug
+
+   * macros/collarea.C:
+     - changed to use MStatusDisplay
+     
+   * manalysis/MCT1SupercutsCalc.cc: 
+     - fixed a typo
+     
+   * mbase/MEvtLoop.[h,cc], mbase/MTaskList.[h,cc]:
+     - added FindTask member functions
+     
+   * mbase/MLog.cc:
+     - do not crop logging to GUI to 1000 lines anymore
+
+   * mdata/MDataChain.cc:
+     - use GetRule() in the constructor instead of Print()
+     
+   * mdata/MDataElement.cc, mfilter/MFDataChain.cc:
+     - do not return str+"something"
+     
+   * mhist/MH.[h,cc]:
+     - fixed a bug in DrawCopy(TH1*,TH1*)
+     - overwrite Clone function and do not add TH1 to gDirectory 
+       when cloning MH classes
+     
+   * mimage/MHHillas.cc, mimage/MHHillasSrc.cc:
+     - adde a sanity check to Fill
+     
+   * mimage/MHHillasSrc.cc:
+     - do not set the log scale before we have entries in the histogram
+
+
+
+ 2003/05/08: Abelardo Moralejo
+
+   * mimage/MImgCleanStd.cc
+     - extended comment on standard cleaning. Removed an obsolete 
+       comment.
+
+   * mhistmc/MHMcCollectionAreaCalc.cc
+     - Changed binning of histograms, so that the collection area
+       can be calculated also between 5 and 10 GeV (for pulsar studies)
+
+
+
+ 2003/05/07: Nadia Tonello
+
+   * manalysis/MCT1PointingCorrCalc.[h,cc]
+     - deleted the fMcEvt variable (not used).
+
+
+ 2003/05/07: Thomas Bretz
+
+   * mmain/Makefile, mmain/MainLinkDef.h:
+     - added MSearch
+     
+   * mmain/MSearch.[h,cc]:
+     - added
+
+   * mmmain/MStatusDisplay.[h,cc]:
+     - implemented Search
+
+   * mhist/MHSigmaTheta.cc:
+     - removed borders around the pads (Draw)
+
+   * mfileio/MCT1ReadPreProc.cc:
+     - do not output the run number twice!
+
+   * mimage/MHillasExt.[h,cc]:
+     - changed ClassDef to 2
+     - updated comments
+
+   * mimage/MNewImagePar.cc:
+     - updated comments
+
+
+
+ 2003/05/07: Abelardo Moralejo
+
+   * mranforest/Makefile
+     - fixed typo.
+
+
+
+ 2003/05/06: Abelardo Moralejo
+ 
+   * mhistmc/MHMcCollectionArea.cc
+     - Added:  delete &pally
+
+   * mfilter/MFCT1SelFinal.cc
+     - changed FindObject("MGeomCam") to 
+       FindCreateObj("MGeomCamCT1","MGeomCam")
+
+   * mhistmc/MHMcCollectionArea.cc
+     - in procedure Calc(TH2D &hsel, TH2D &hall) : changed the 
+       calculation of maximum impact parameter. Now it looks for
+       the non-empty bin of histogram "hall" with highest impact 
+       parameter. The code could not work as it was before, but this 
+       had influence only when running over camera files containing all 
+       events, including non-triggers (while we usually run over files
+       containing only triggers).
+
+
+
+ 2003/05/06: Thomas Bretz
+ 
+   * manalysis/MRan*, mhist/MHRan*:
+     - moved to new directory mranforest
+     
+   * mranforest, mranforest/Makefile, mranforest/RanForestLinkDef.h,
+     mranforest/RanForestIncl.h:
+     - added
+
+   * manalysis/Makefile, manalysis/AnalysisLinkDef.h:
+     - removed MRan*
+
+   * mhist/Makefile, mhist/HistLinkDef.h:
+     - removed MHRan*
+
+   * Makefile:
+     - mranforest added
+
+   * mbase/MLog.cc:
+     - sanity check in MLog::Output (len>0)
+
+   * mimage/MImgCleanStd.cc:
+     - adapted path to html images
+
+   * htmldoc/*:
+     - moved to new path htmldoc/images
+
+   * Makefile.rules:
+     - corrected rule rmhtmldoc
+     
+   * NEWS:
+     - updated
+
+   * macros/dohtml.C, macros/rootlogon.C:
+     - added mranforest
+
+   * mbase/MEvtLoop.cc:
+     - fixed a typo
+     
+   * mhist/HistLinkDef.h
+
+
+
+ 2003/05/05: Nadia Tonello
+
+   * mfilter/MFCT1SelStandard.cc
+     - correct the default name of fImgParName
+	("MNewImgPar") => ("MNewImagePar")
+
+
+
+ 2003/05/05: Thomas Bretz
+ 
+   * mbase/MEvtLoop.cc:
+     - underline Instatiation Message
+     - small change to a warning output
+     
+   * mbase/MLog.[h,cc]:
+     - added stuff for underlining
+     - changed from TGListBox to TGViewText
+     
+   * mmain/MStatusDisplay.[h,cc]:
+     - changed fLogBox from TGListBox to TGViewText
+     - added menu 'Log'
+     - changed division of status line to 'Goldener Schnitt'
+
+   * mhist/MHHadronness.cc, mhist/MHCerPhotEvt.cc, mhist/MHStarMap.cc,
+     mimage/MHHillas.cc:
+     - fixed 'redifinion of default argument'
+
+   * mbase/Makefile, mfileio/Makefile:
+     - moved first source file to second position to get rid of crashes
+       of rootcint on our Alpha
+
+   * mimage/MNewImagePar.cc:
+     - removed maxpixid (not used)
+
+   * manalysis/MRanTree.cc:
+     - replaced ostream.h by iostream.h
+
+   * manalysis/MPadding.h:
+     - added a missing const qualifier in the definition of 'Padding'
+
+   * mmontecarlo/MMcEnergyEst.cc:
+     - added math.h
+
+   * Makefile, mbase/Makefile, mmain/Makefile:
+     - changed order (linking on our Alpha failed)
+
+   * mbase/MLog.h:
+     - don't include iostream.h if __CINT__ (crashes rootcint on our
+       alpha)
+
+
+
+ 2003/05/05: Wolfgang Wittek
+
+   * manalysis/MPadSChweizer.cc
+     - delete histograms in destructor
+
+
+
+ 2003/05/02: Thomas Bretz
+
+   * Makefile.conf.general, Makefile.conf.linux, Makefile.conf.linux-gnu,
+     Makefile.conf.osf1, Makefile.conf.osf5.1:
+     - added MARSDEFINES, MARSFLAGS, MARSLIBS
+     
+   * mars.cc:
+     - replaces HAVE_LOGO by HAVE_XPM
+ 
+   * NEWS:
+     - updated
+     
+   * mbase/MLogo.cc:
+     - replaces marslogo_neu by marslogo
+     - encapsulated in HAVE_XPM
+     
+   * mbase/Makefile:
+     - added MLogo.cc
+     
+   * mmain/MGMenu.cc:
+     - fixed the 'KeyAutoRepeat' bug
+
+   * manalysis/MCerPhotEvt.[h,cc:
+     - added RemoveUnusedPixels
+     
+   * manalysis/MSigmabar.cc:
+     - small simplification for compiler optimization
+     
+   * mbase/MEvtLoop.cc:
+     - changed output to fDisplay
+     - changed behaviour in case of a failed PostProcess
+     
+   * mbase/MLog.[h,cc]:
+     - added flushing and tab conversion to GUI
+     - added color support
+     
+   * mbase/MParList.cc:
+     - replaced some *Iter by MIter
+
+   * mbase/MTask.cc, mbase/MTaskList.cc:
+     - added output to fDisplay
+     - replaced some *Iter by MIter
+     
+   * mhist/MH.cc:
+     - don't add clones to directory
+     
+   * mimage/MImgCleanStd.[h,cc]:
+     - replaced divisiond by multiplications
+     - fixed StreamePrimitive
+     - do not allow 0 rings
+     
+   * mmain/MStatusDisplay.[h,cc]:
+     - added writing gif
+     - added writing C
+     - changes SaveAs to non-const (added output to status lines)
+     - replaced TGLabels by TGStatusBar
+
+
+
+ 2003/04/30: Wolfgang Wittek
+
+   * manalysis/MPadSchweizer.[h,cc]
+     - reorder histograms
+
+   * mhist/MHSigmaTheta.[h,cc]
+     - remove last 3 plots (otherwise get segmentation violation ???)
+
+   * mimage/MHNewImagePar.[h,cc]
+     - change range of leakage to be plotted
+       (want to see also leakage=0)
+
+
+
+ 2003/04/30: Nadia Tonello
+
+   * manalysis/MCerPhotPix.[h,cc]:
+     - deleted Bool_t fIsUsed and substituted with 
+	the condition: fRing>0 in the functions
+	Bool_t IsPixelUsed() const{return fRing>0;}
+	void   SetPixelUsed()  { fRing = 1;}
+	void   SetPixelUnused(){ fRing = 0;}
+
+
+
+ 2003/04/29: Wolfgang Wittek
+
+   * mhist/MHSigmaTheta.[h,cc]:
+     - ClassDef( ,0) -> ClassDef( , 1)
+     - minor corrections in Draw()
+
+
+
+ 2003/04/29: Thomas Bretz
+ 
+   * mfilter/MFCT1SelBasic.[h,cc], mfilter/MFCT1SelFinal.[h,cc],
+     mfilter/MFCT1SelStandard.[h,cc]:
+     - reordered includes
+     - removed MHillas from constructor (if present)
+     - added corresponding Setter-methods
+     - added many const qualifiers
+     - removed some obsolete data members
+     - made some member functions private
+     - only store fMm2Deg, not the pointer to MGeomCam
+     - don't use the CT1 camera build in... (to be discussed)
+     - fixed MHillas, MHillasExt and MNewImagePar stuff
+
+   * mimage/MImgCleanStd.[h,cc]:
+     - added Nadia to the list of authors
+     - added pngs for the formulars
+     
+   * htmldoc, htmldoc/MImgCleanStd-f1.png, htmldoc/MImgCleanStd-f2.png:
+     - added
+
+   * manalysis/MCT1SupercutsCalc.[h,cc]:
+     - changed the default "MHillasExt" to "MHillas"
+
+   * mbase/MEvtLoop.cc:
+     - fixed a bug in ProcessGuiEvents
+
+   * mhist/MH*.[h,cc], mhistmc/MH*.[h,cc], mimage/MH*.[h,cc]:
+     - changed "Double_t w" in Fill to "const Stat_t w"
+     - added weight in some classes to TH::Fill
+
+   * mbase/MHtml.[h,cc]:
+     - removed
+
+   * mfileio/MCT1ReadPreProc.cc:
+     - removed the dependance on a MBinning in Theta.
+
+
+
+ 2003/04/29: Abelardo Moralejo
+
+   * mmontecarlo/MMcCollectionareaCalc.[h,cc]
+     - Now the energy limits and spectral slope used in Corsika are
+       read from the run header. Warning: impact parameter is still
+       fixed (I changed it from 400 m to 300 m, our present MC 
+       production default). Added warning message about this. 
+       Collection areas calculated up to now with the new MC library 
+       are overestimated by a ~77% ! This class will be removed in 
+       the future and replaced by MFillH.
+
+   * mhistmc/MHMcCollectionArea.[h,cc]
+     - Adapted to the change of MMcCollectionAreaCalc. Added arguments
+       to CalcEfficiency.
+
+
+
+ 2003/04/28: Nadia Tonello 
+
+   * mimage/MImgCleanStd.[h,cc]
+     - added the option kDemocratic using sigmabar of the inner pixels
+     - added the option to select the number of rings of pixels 
+       to analyze around the core pixels 
+     - added documentation
+
+   * manalysis/MCerPhotPix.[h,cc]
+     - added fRing and Get-Set functions 
+
+
+
+ 2003/04/28: Oscar Blanch
+
+   * mgeom/MGeomCamECO1000.[h,cc]
+     - New files for ECO 1000 camera geometry.
+
+   * mgeom/GeomLinkDef.h
+     - Added class MGeomCamECO1000
+
+   * mgeom/Makefile 
+     - Added class MGeomCamECO1000
+
+
+
+ 2003/04/28: Abelardo Moralejo
+
+   * mmontecarlo/MMcEnergyEst.[h,cc]
+     - Lots of fixes after Thomas suggestions. Now cuts are not part
+       of the class, but introduced via a new MFilter* member. Changed
+       all Char_t* for TString. Changed own TMiniut pointer by gMinuit.
+       Removed couts and used fLog instead. Function fcn is no longer
+       declared external.
+
+
+
+ 2003/04/28: Thomas Bretz
+
+   * NEWS:
+     - updated
+     
+   * manalysis/MBlindPixelCalc.cc:
+     - use Are of pixles while interpolating
+     
+   * mbase/MEvtLoop.cc:
+     - output speed in Evts/s to fDisplay
+     
+   * mbase/MGGroupFrame.h:
+     - fixed a typo
+     
+   * mbase/MTask.[h,cc]:
+     - Added OverwritesProcess
+     
+   * mbase/MTaskList.[h,cc]:
+     - removed CheckClassForProcess
+     - replaced by MTask::OverwritesProcess
+     
+   * mhist/MFillH.cc:
+     - only draw something if the class overwrites the Draw function
+   
+   * mhist/MH.[h,cc]:
+     - added OverwritesDraw
+     - added a higher maximum, lower minimum to Draw(TH1, TH1)
+     - changed default size 
+   
+   * mhist/MHMatrix.cc:
+     - mini change
+     
+   * mimage/MHHillas.[h,cc]:
+     - removed fUsedPix
+     - removed fCorePix
+     
+   * mimage/MHHillasExt.[h,cc]:
+     - removed fHConc
+     - removed fHConc1
+     - changed default name to MHillasExt
+     
+   * mimage/MHNewImagePar.[h,cc]:
+     - added fHistConc
+     - added fHistConc1
+     - added fHistUsedPix
+     - added fHistCorePix
+     
+   * mimage/MHillas.cc:
+     - removed fNumCorePixels
+     - removed fNumUsedPixels
+     - made fCosDelta writable
+     - made fSinDelta writable
+     - made GetSinDelta() public
+     - made GetCosDelta() public
+      
+   * mimage/MHillasExt.[h,cc]:
+     - removed fConc
+     - removed fConc1
+     - changed default name to MHillasExt
+     - derives from MParContainer now instead of MHillas
+     
+   * mimage/MNewImagePar.[h,cc]:
+     - added fNumCorePixels
+     - added fNumUsedPixels
+     - added fConc
+     - added fConc1
+   
+   * mimage/MNewImageParCalc.[h,cc]:
+     - removed
+
+   * mimage/MHillasCalc.[h,cc]:
+     - changed so, that it can calc MHillas, MHillasExt and MNewImagePar
+
+   * mimage/MHillasSrc.cc:
+     - sqrt(tand*tand+1) replaced by 1/CosDelta    
+
+   * mmain/MStatusDisplay.[h,cc]:
+     - added second argument to SetLogStream
+
+   * mhist/MHAlphaEnergyTheta.[h,cc], mhist/MHAlphaEnergyTime.[h,cc],
+     mhist/MHCerPhotEvt.[h,cc], mhist/MHEffOnTime.[h,cc],
+     mhist/MHEffOnTimeTheta.[h,cc], mhist/MHEffOnTimeTime.[h,cc],
+     mhist/MHEnergyTheta.[h,cc], mhist/MHEnergyTime.[h,cc],
+     mhist/MHFlux.[h,cc], mhist/MHMatrix.[h,cc],
+     mhist/MHSigmaTheta.[h,cc], mhistmc/MHMcCollectionArea.[h,cc],
+     mhistmc/MHMcDifRate.[h,cc], mhistmc/MHMcEfficiency.[h,cc],
+     mhistmc/MHMcEfficiencyEnergy.[h,cc], mhistmc/MHMcEfficiencyImpact.[h,cc],
+     mhistmc/MHMcEnergy.[h,cc], mhistmc/MHMcEnergyImpact.[h,cc],
+     mhistmc/MHMcEnergyMigration.[h,cc], mhistmc/MHMcRate.[h,cc]:
+     - removed DrawClone
+     - fixed Draw
+
+   * macros/MagicHillas.C, macros/star.C:
+     - removed MHillasExt (not necessary anymore)
+     - added MNewImagePar
+     
+   * macros/readCT1.C, macros/readMagic.C, meventdisp/MGCamDisplay.cc,
+     mmain/MAnalysis.cc:
+     - added MHillasExt to be displayed
+     - added MNewImagePar to be displayed
+
+   * manalysis/MCT1SupercutsCalc.[h,cc]:
+     - removed empty destructor
+     - fixed output in PreProcess
+     - changed MHillasExt to MHillas
+
+
+
+
+
+ 2003/04/28: Wolfgang Wittek
+
+   * manalysis/MPadSchweizer.[h,cc]
+     - extend documentation
+     - remove histograms which are also made by MHSigmaTheta
+     - minor modifications
+
+
+
+ 2003/04/25: Thomas Bretz
+
+   * mfilter/MFEnergySlope.cc:
+     - removed obsolete PostProcess
+
+   * mdatacheck/MGDisplayAdc.cc:
+     - fixed a bug which caused nothing to beeing displayed if only
+       the Hi gains where existing (Exists->HasHi)
+
+   * mhist/MH.cc:
+     - small change to GetNewPad
+
+   * mhistmc/MHMcEnergyMigration.h:
+     - fixed the includes
+
+   * mgui/MCamDisplay.cc:
+     - changed autoscaling (max<1:max=1 --> max==min:max=min+1)
+
+   * manalysis/MBlindPixelCalc.cc:
+     - interpolate: take pixel area into account
+
+   * mhist/MHSigmaTheta.h:
+     - removed nonsense GetSigmaThetaByName(const TString name)
+     - removed nonsense GetSigmaPixThetaByName(const TString name)
+     - removed nonsense GetDiffPixThetaByName(const TString name)
+     
+   * manalysis/MPadSchweizer.cc:
+     - fixed naming
+     - fixed usage of operators
+     - added some const qualifiers
+     - replaced 'int OK' by 'Bool_t ok'
+     - fixed wrong usage floating point value 0
+
+   * mimage/MImgCleanStd.cc:
+     - moved ratio to the other side of the condition (don't divide
+       if it is not necessary)
+
+
+
+ 2003/04/24: Abelardo Moralejo
+
+   * macros/rootlogon.C
+     - added gInterpreter->AddIncludePath(dir+"mhistmc");
+
+
+
+ 2003/04/24: Thomas Bretz
+
+   * macros/rootlogon.C:
+     - added mimage
+
+   * macros/dohtml.C:
+     - added mhistmc
+     - added mimage
+     - added status.C
+
+   * mfilter/MFCT1Supercuts.[h,cc]:
+     - removed
+
+   * manalysis/MPadSchweizer.[h,cc]:
+     - renamed arguments of SetHistograms to Mars style
+     - removed default argument for SetHistograms (usage would result
+       in a crash)
+     - removed empty destructor
+
+   * mhistmc/MHMcTriggerLvl2.h:
+     - removed the wrong f in GetHistf
+
+   * manalysis/MSigmabarParam.h:
+     - added const qualifiers to getters
+
+   * mfileio/MWriteRootFile.[h,cc]:
+     - fixed support for UPDATE
+
+   * mfilter/MFEnergySlope.cc:
+     - cleaned
+     - removed empty PostProcess
+     
+   * mhist/MHCerPhotEvt.cc:
+     - removed ratio from Fill
+
+   * mhist/MH.h:
+     - fixed a bug in the overloading of DrawClone
+
+   * mimage/MHillasSrc.[h,cc], mimage/MHHillasSrc.[h,cc]:
+     - like suggested by Wolfgang: removed Head-Tail
+
+   * mbase/MEvtLoop.cc:
+     - fixed a bug in the progress bar update at the end of the loop
+
+
+
+ 2003/04/24: Wolfgang Wittek
+
+    * mfilter/MFCT1SelFinal.cc
+      - small correction in output
+
+    * mhistmc/MHMcCT1CollectionArea.cc
+      - plot all 3 histograms in DrawClone()
+
+    * manalysis/MPadSchweizer.[h,cc]
+      - cleanup as proposed by Thomas
+      - new member function SetHistograms() to set the pointers to the
+        histograms to be used in the padding
+
+
+
+ 2003/04/24: Antonio Stamerra
+
+    * mhistmc/MHMcTriggerLvl2.[h,cc]
+      - renamed some variable (hf->fHist)
+      - added fHist*Norm and fFNorm in the destructor
+
+    * manalysis/MMcTriggerLvl2.[h,cc]
+      - added CalcCompactPixel() public method
+      - implemented CalcPseudoSize method (still under construction...)
+      - added inline method SetNewCamera(), used in the costructor
+      - renamed global variables pixels_in_cell->gsPixelsInCell 
+        and pixels_in_lut->gsPixelsInLut
+      - added destructor
+
+
+
+ 2003/04/23: Thomas Bretz
+
+   * mhist/MHCerPhotEvt.[h,cc]:
+     - updated dox
+
+   * manalysis/MCT1SupercutsCalc.h, manalysis/MPadSchweizer.h:
+     - ClassDef -> 0
+
+   * NEWS:
+     - updated
+     
+   * mfileio/MWriteRootFile.[hcc]:
+     - fixed the missing function of UPDATE files
+     
+   * mhist/MFillH.[h,cc]:
+     - implemented fWeight
+     - adapted StreamPrimitive
+     - changed fCanvas to //!
+     - changed class version umber from 1 to 2
+   
+   * mhist/MH.[h,cc], mhist/MHAlphaEnergyTheta.[h,cc],
+     mhist/MHAlphaEnergyTime.[h,cc], mhist/MHArray.[h,cc],
+     mhist/MHBlindPixels.[h,cc], mhist/MHCompProb.[h,cc],
+     mhist/MHEffOnTime.[h,cc], mhist/MHEffOnTimeTheta.[h,cc],
+     mhist/MHEffOnTimeTime.[h,cc], mhist/MHEnergyTheta.[h,cc],
+     mhist/MHFadcCam.[h,cc], mhist/MHFlux.[h,cc],
+     mhist/MHGamma.[h,cc], mhist/MHHadronness.[h,cc],
+     mhist/MHMatrix.[h,cc], mhist/MHRanForest.[h,cc],
+     mhist/MHRanForestGini.[h,cc], mhist/MHSigmaPixel.[h,cc],
+     mhist/MHSigmaTheta.[h,cc], mhist/MHSigmabarTheta.[h,cc],
+     mhist/MHStarMap.[h,cc], mhist/MHThetabarTheta.[h,cc],
+     mhist/MHThetabarTime.[h,cc], mhist/MHTimeDiffTheta.[h,cc],
+     mhist/MHTimeDiffTime.[h,cc], mhistmc/MHMcCT1CollectionArea.[h,cc],
+     mhistmc/MHMcEnergyImpact.[h,cc], mhistmc/MHMcEnergyMigration.[h,cc]
+     mhistmc/MHMcTriggerLvl2.[h,cc], mimage/MHHillas.[h,cc],
+     mimage/MHHillasExt.[h,cc], mimage/MHHillasSrc.[h,cc],
+     mimage/MHNewImagePar.[h,cc]:
+     - added second (weight) argument to Fill
+     - in some headers: removed obvious virtual
+     - removed some dummy Fill function (not necessary anymore)
+     
+
+
+ 2003/04/23: Abelardo Moralejo
+
+    * mhistmc/MHMcCT1CollectionArea.[h,cc]
+      - Now the class inherits from MH instead of directly from 
+       	MParContainer. Implemented SetupFill, so that the binning
+	definitions are read from the parlist.
+
+    * mmontecarlo/MMcCT1CollectionAreaCalc.[h,cc]
+      - Removed. This class was superfluous, since the same job 
+ 	can be done using MFillH.
+
+    * mmontecarlo/Makefile, MontecarloLinkDef.h
+      - removed class MMcCT1CollectionAreaCalc.
+
+    * macros/CT1collarea.C
+      - adapted to changes above.
+
+    * mmc/MMcRunHeader.[hxx,cxx], mmc/MMCEvt.[hxx,cxx]
+      - added comment in class description about the definition of
+	the azimuth angle phi in the MC classes.
+
+
+ 2003/04/23: Antonio Stamerra
+
+    * mfilter/MFEnergySlope.[h,cc]
+      - added new filter class to select events according to a given
+	energy slope 
+
+    * mfilter/Makefile, mfilter/FilterLinkDef.h
+      - modified accordingly (added MFEnergySlope)
+
+    * manalysis/MMcTriggerLvl2Calc.cc 
+      - removed call to the MHMcTriggerLvl2->Fill() in Process()
+
+    * macros/triglvl2.C 
+      - added example of the MFEnergySlope filter
+      - added filling of histos from MHMcTriggerLvl2
+
+
+ 2003/04/22: Abelardo Moralejo
+
+    * mmontecarlo/Makefile, MontecarloLinkDef.h
+      - added MMcEnergyEst
+      - added necessary include directories.
+
+    * mmontecarlo/MMcEnergyEst.cc
+      - added filterhadrons.SetHadronnessName(fHadronnessName) to
+        inform the filter about the name of the hadronness container
+        to be used in the cuts.
+
+    * mfilter/MFCT1SelFinal.[h,cc]
+      - added the possibility to cut also in Dist.
+
+
+
+ 2003/04/22: Thomas Bretz
+
+    * mhist/MHHadronness.[h,cc]:
+      - changed to support MStatusDisplay
+
+    * manalysis/MApplyPadding.[h,cc]:
+      - removed
+
+    * mhist/MHMcCT1CollectionArea.[h,cc], 
+      mhist/MHMcCollectionArea.[h,cc], mhist/MHMcDifRate.[h,cc], 
+      mhist/MHMcEfficiency.[h,cc], mhist/MHMcEfficiencyEnergy.[h,cc], 
+      mhist/MHMcEnergy.[h,cc], mhist/MHMcEnergyImpact.[h,cc], 
+      mhist/MHMcEnergyMigration.[h,cc], mhist/MHMcIntRate.[h,cc], 
+      mhist/MHMcRate.[h,cc], mhist/MHMcTriggerLvl2.[h,cc]:
+      - moved to new directory mhistmc
+    
+    * mhistmc, mhistmc/Makefile, mhistmc/HistMcLinkDef.h:
+      - new
+
+    * mhist/Makefile, mhist/HistLinkDef.h:
+      - removed MHMc*
+      
+    * mhistmc/MHMcCollectionArea.[h,cc]:
+      - changed to fit requirements of MStatusDisplay
+
+    * Makefile:
+      - added mhistmc
+
+    * mmain/MStatusDisplay.cc:
+      - SetNoContextMenu(Bool_t flag) removed default argument
+
+    * mmain/Makefile:
+      - added -I../mhistmc
+
+   * mhist/MWeight.[h,cc]:
+     - added
+     
+   * mhist/HistLinkDef.h:
+     - added MWeight
+     
+   * mhist/MH.h:
+     - removed some debugging stuff
+
+
+
+ 2003/04/22: Abelardo Moralejo
+
+   * mmontecarlo/MMcEnergyMigration.[h,cc]
+     - Removed. It was not necessary, since the same job can be done 
+       with the already existing task MFillH.
+
+   * mhist/MHMcEnergyMigration.h
+     - Changed ClassDef(MHMcEnergyMigration, 0) 
+       to ClassDef(MHMcEnergyMigration, 1) to allow writing the 
+       histograms to disk.
+
+
+
+ 2003/04/21: Thomas Bretz
+
+   * manalysis/MBlindPixels.h:
+     - IsBlind -> const
+     
+   * mhist/HistLinkDef.h, mhist/Makefile:
+     - added MHBlindPixels
+   
+   * mhist/MH.[h,cc]:
+     - changed the two DrawClone functions to one.
+     
+   * mhist/MHHadronness.[h,cc]:
+     - changed to fit the requirements of MStatusDisplay
+     
+   * mhist/MHMatrix.cc:
+     - SetDirectory(NULL) for all histograms created
+
+   * mhist/MHSigmaTheta.cc:
+     - removed fNpix    (is already in MHHillas)
+     - removed fBlindId (--> MHBlindPixels)
+
+   * mhist/MHBlindPixels.[h,cc]:
+     - new
+
+   * macros/plot.C:
+     - Added MStatusDisplay support
+     
+   * macros/status.C:
+     - added MHNewImagePar
+     - added MHHadronness
+
+   * manalysis/MBlindPixelCalc.cc:
+     - updated class reference
+     
+   * meventdisp/MGCamDisplay.[h,cc]:
+     - fixed
+     
+   * meventdisp/MGEvtDisplay.cc:
+     - changed function adding the tab
+     
+   * mgui/MCamDisplay.cc, mhist/MHCerPhotEvt.cc:
+     - as a preliminary solution removed inner pad
+
+   * mhist/MFillH.cc:
+     - make sure canvas is updated correctly in PostProcess
+
+   * mhist/MH.cc:
+     - changed DrawCopy(TH1, TH1) and Draw(TH1, TH1) to fit the new needs
+       display the range correctly and exchanged the two stat boxes
+   
+   * mhist/MH3.cc:
+     - fixed a bug in the default constructor
+     - removed DrawClone
+     - updated Draw function
+     
+   * mhist/MHMcIntRate.[h,cc], mhist/MHRanForest.[h,cc],
+     mhist/MHRanForestGini.[h,cc], mhist/MHSigmaPixel.[h,cc],
+     mhist/MHSigmaTheta.[h,cc], mhist/MHSigmabarTheta.[h,cc],
+     mhist/MHThetabarTheta.[h,cc], mhist/MHThetabarTime.[h,cc],
+     mhist/MHTimeDiffTheta.[h,cc], mhist/MHTimeDiffTime.[h,cc],
+     mimage/MHNewImagePar.[h,cc]:
+     - removed old DrawClone
+     - updated Draw function
+     - replaced some titles by latex titles in some classes
+
+   * mimage/MHNewImagePar.[h,cc], mimage/MNewImagePar.[h,cc]:
+     - removed scaling stuff
+
+   * mmain/MStatusDisplay.cc:
+     - fixed some minor bugs
+
+
+
+ 2003/04/20: Thomas Bretz
+
+   * Makefile:
+     - exchanged mbase and mmain
+   
+   * Makefile.conf.general:
+     - added MARSVER
+   
+   * mars.cc:
+     - use MARSVER
+   
+   * macros/readMagic.C:
+     - updated to work with the new MH-stuff
+     
+   * macros/status.C:
+     - added
+     
+   * manalysis/MBlindPixelCalc.cc, manalysis/MCerPhotCalc.cc,
+     manalysis/MMcPedestalCopy.ccm, manalysis/MMcPedestalNSBAdd.cc,
+     mfileio/MReadMarsFile.cc, mimage/MHillasCalc.cc,
+     mimage/MImgCleanStd.cc:
+     - changed def. title
+   
+   * manalysis/MCT1PointingCorrCalc.h:
+     - minor change
+     
+   * manalysis/MCerPhotEvt.[h,cc]:
+     - don't use unused pixels for calculation of min/max
+     - added Scale member function
+   
+   * manalysis/MCerPhotPix.h:
+     - added Scale inline function
+     
+   * mbase/MEvtLoop.[h,cc], mbase/MParContainer.[h,cc],
+     mbase/MParList.[h,cc], mbase/MTaskList.[h,cc],
+     mfileio/MReadMarsFile.cc, mhist/MFillH.[h,cc]:
+     - implemented use of fDisplay 
+   
+   * mbase/MParContainer.h:
+     - Don't display name and class name if it is the same (GetDescriptor)
+
+   * meventdisp/MGCamDisplay.[h,cc]:
+     - made working with new MH-stuff
+   
+   * mfileio/Makefile:
+     - added -I../mmain
+   
+   * mgeom/MGeomCam.[h,cc]:
+     - added Clone function
+
+   * mgeom/MGeomCamCT1.cc, mgeom/MGeomCamMagic.cc:
+     - commented out informal output at constructor
+   
+   * mgui/MCamDisplay.[h,cc], mhist/MHStarMap.[h,cc], 
+     mimage/MHH*.[h,cc]:
+     - changed to be more root oriented
+   
+   * mgui/MHexagon.cc:
+     - small changes
+     
+   * mgui/Makefile:
+     - added mhist
+     
+   * mhist/MH.[h,cc]:
+     - changed to be more root oriented
+     - removed border
+     - added DrawClone
+     - GetNewPad
+
+   * mhist/MH3.cc:
+     - removed some strange debug output
+     
+   * mhist/MHCerPhotEvt.[h,cc]:
+     - fixed some bug
+     - made working with fDisplay
+   
+   * mhist/Makefile:
+     - added mmain
+     
+   * mmain/MProgressBar.cc:
+     - fixed a typo
+     
+   * mmain/MStatusDisplay.[h,cc]:
+     - new implementation
+     
+   * mmain/MainLinkDef.h, mmain/Makefile:
+     - added MStatusDisplay
+     - added MGMenu
+
+   * mmain/MGMenu.[h,cc]:
+     - added
+
+
+
+ 2003/04/19: Abelardo Moralejo
+
+   * mmontecarlo/MMcEnergyEst.[h,cc]
+     - Added. Contains routine for optimization of parameters of 
+       energy estimator.
+
+   * mmontecarlo/MMcEnergyMigration.[h,cc]
+     - Added. Task to fill the energy migration matrix histograms 
+       contained in class MHMcEnergyMigration.
+
+
+
+ 2003/04/17: Wolfgang Wittek
+
+   * mhist/MBinning.[h,cc]
+     - replace      for (int i=1; i<fEdges.GetSize()-1; i++)
+            by      for (int i=1; i<fEdges.GetSize(); i++)
+
+
+
+ 2003/04/17: Wolfgang Wittek
+
+   * mfileio/MCT1ReadPreProc.cc
+     - removed : if (theta > pi/2) continue;
+       otherwise get inconsistency between no.of read events 
+       and no.of events after filter
+     - write into MCerPhotEvt also pixels with zero no. of photons
+
+   * manalysis/MSigmabar.cc
+     - correct wrong argument in call to memset
+
+   * manalysis/MPadSchweizer.cc
+     - pad also pixels with zero no.of photons
+
+   * mhist/MHSigmaTheta.[h,cc]
+     - add plot of no.of used pixels in MCerPhotEvt
+     - add plot of Id of blind pixel
+
+
+
+ 2003/04/14: Wolfgang Wittek
+ 
+  * manalysis/Makefile
+              AnalysisLinkDef.h
+    - MNewImagePar and MNewImageParCalc removed
+    
+
+
+
+ 2003/04/12: Thomas Bretz
+
+   * mmain/MStatusDisplay.[h,cc]:
+     - added
+
+   * manalysis/MPadding.[h,cc]:
+     - simplified includes
+     - changed some code (discussed with Robert)
+     - fixed comments in header
+     - changed ClassDef to 0
+     - changed output to Mars style
+     - fixed the memory leak of fHSigmabarMax
+     - replaced TRandom by gRandom
+     - removed usage of ->operator
+
+   * manalysis/MApplyPadding.[h,cc]:
+     - replaced fRnd by gRandom
+     - used MH::SetBinning
+     - use telescope theta instead of theta
+     - removed usage of ->operator
+     - removed PostProcess
+     
+   * manalysis/MPadSchweizer.cc:
+     - fixed outputs in PreProcess
+
+   * manalysis/MSigmabar.[h,cc]:
+     - added Reset member function
+     - usage of memset
+     - don't skip NumPhotons==0 
+     - changes discussed with Robert
+     - small simplifications in loops
+     - some fixes to the output
+
+   * manalysis/MSigmabarCalc.[h,cc]:
+     - fixed outputs
+     - some small simplifications
+     - moved test for theta<120deg to MCT1ReadPreProc
+
+   * mfileio/MCT1ReadPreProc.[h,cc]:
+     - skip events with theta>90deg
+
+   * mhist/MHSigmaPixel.[h,cc]:
+     - fixes to the screen output
+     - simplified usage of MBinning
+
+   * mhist/MHSigmaTheta.[h,cc]:
+     - fixes to the screen output
+     - simplified usage of MBinning
+     - lower cased upper case local variables   
+     - removed DrawClone from Finalize (call from macro or executable)
+
+   * mhist/MHSigmabarTheta.[h,cc]:
+     - fixes to the screen output
+     
+   * mhist/MHStarMap.cc:
+     - added some const qualifiers
+
+   * mhist/MHHadronnes.cc:
+     - removed output of function name in Finalize because this
+       information is already available on the screen.
+
+   * manalysis/MCT1PointingCorrCalc.h:
+     - changed ClassDef to 0
+     - removed empty PostProcess
+     - fixes to the screen output in PreProcess
+     - changed the order of the arguments in the constructor
+       (name, title to the end)
+
+   * manalysis/MMultiDimDistCalc.cc:
+     - added two const qualifiers
+     
+   * mtemp/MObservatory.cc:
+     - changed Magic1 coordinates to CT1 GPS.
+
+
+
+ 2003/04/12: Wolfgang Wittek
+
+   * manalysis/MCT1PointingCorrCalc.[h,cc]
+     - replaces MPointingCorr.[h,cc]
+
+   * manalysis/AnalysisLinkDef.h
+               Makefile
+
+   * mbase/MFilter.h
+     - set ClassDef(MFilter,1)
+
+   * mhist/MHHadronness.[h,cc]
+     - improve warning printout
+
+   * mhist/MHMatrix.[h,cc]
+     - type of 3rd argument of member function Fill
+       changed from 'MF' to 'MFilter'
+
+
+
+ 2003/04/11: Thomas Bretz
+
+   * macros/readMagic.C:
+     - replaced GetEventNum by GetNumEntry
+     
+   * manalysis/MCT1SupercutsCalc.cc:
+     - fixed constructor (no default for fHadronnessName)
+     - missing fHadronness->SetReadyToSave added
+     
+   * manalysis/MMultiDimDistCalc.cc:
+     - missing fHadronness->SetReadyToSave added
+    
+   * manalysis/MParameters.cc:
+     - changed title
+
+   * mfilter/MFCT1SelFinal.h:
+     - set ClassDef to 0
+   
+   * mimage/Makefile:
+     - fixed a typo
+     
+   * mraw/MRawEvtData.cc:
+     - fixed Pixel assignment (i->ipos, fPosInArray++)
+
+
+
+ 2003/04/10: Thomas Bretz                 
+ 
+   * mbase/MContinue.[h,cc]:
+     - changed, so that also a filter given as a pointer is added to
+       the tasklist automatically
+     - added SetInverted
+     - added IsInverted
+ 
+   * mbase/MTaskList.[h,cc]:
+     - added RemoveFromList-function
+
+   * merpp.cc:
+     - fixed typo
+     
+   * mbase/MFilter.[h,cc]:
+     - removed unnecessary base functions for Pre//PostProcess
+     - added SetInverted
+     - added IsInverted
+   
+   * mbase/MTask.cc, mfileio/MCT1ReadPreProc.cc, mfileio/MReadTree.cc,
+     mfilter/MF.cc, mfilter/MFilterList.cc
+     - implemented IsConditionalTrue to support inverted filters
+
+   * mhist/MHHadronness.cc:
+     - removed unnecessary check
+
+   * meventdisp/MGFadcDisp.cc:
+     - remove all IDs in listbox
+     - add entries sorted
+
+   * manalysis/MImgCleanStd.[h,cc], manalysis/MCameraSmooth.[h,cc], 
+     manalysis/MHillas.[h,cc], manalysis/MHillasSrc.[h,cc],
+     manalysis/MHillasSrc.[h,cc], manalysis/MHillasCalc.[h,cc],
+     manalysis/MNewImagePar.[h,cc], manalysis/MNewImageParCalc.[h,cc],
+     mhist/MHHillas.[h,cc], mhist/MHHillasSrc.[h,cc], 
+     mhist/MHHillasExt.[h,cc], mhist/MHNewImagePar.[h,cc]:
+     - moved to new directory mimage
+   
+   * mimage/Makefile, mimage/ImageLinkDef.h, mimage/ImageIncl.h:
+     - new
+   
+   * Makefile:
+     - added mimage
+   
+   * manalysis/AnalysisLinkDef.h, manalysis/Makefile
+     mhist/HistLinkDef.h, mhist/Makefile:
+     - removed moved files
+
+   * manalysis/Makefile, manalysis/AnalysisLinkDef.h,
+     mhist/Makefile, mhist/AnalysisLinkDef.h, mmain/Makefile,
+     mfilter/Makefile, meventdisp/Makefile, mgui/Makefile:
+     - adapted
+
+
+
+ 2003/04/09: Thomas Bretz
+ 
+   * manalysis/MCT1SupercutsCalc.[h,cc]:
+     - moved last changes from MFCT1Supercuts to MCT1SupercutsCalc
+
+   * mhist/MHMcTriggerLvl2.[h,cc]:
+     - fixed a warning
+     - removed global variables
+
+
+
+ 2003/04/09: Abelardo Moralejo
+
+   * manalysis/MHillasSrc.cc
+     - changed comment about meaning of fCosDeltaAlpha
+
+
+
+ 2003/04/08: Thomas Hengstebeck
+ 
+   * mhist/MHRanForest.cc, mhist/MHRanForestGini.cc
+     - removed gStyle->SetOptStat(10), gStyle settings should be 
+       done by the user himself  
+
+
+
+ 2003/04/08: Abelardo Moralejo
+
+   * manalysis/MImgCleanStd.cc
+     - Fixed "democratic" cleaning: now tail cut is proportional 
+       to pixel area instead of pixel radius as (erroneously) was 
+       before.
+
+   * NEWS
+     - Changed comment on image cleaning.
+
+
+
+ 2003/04/08: Thomas Bretz
+
+   * mhist/MHHadronness.cc:
+     - no check for sump==0 and sumg==0 in loop necessary anymore
+
+   * Changelog, Changelog.02:
+     - moved everything before 1/2003 to Changelog.02
+
+
+
+ 2003/04/08: Wolfgang Wittek
+
+   * mfilter/MFCT1SelFinal.[h,cc]
+     - add new member function SetHadronnessName()
+
+   * mhist/MHHadronness.[h,cc]
+     - reset to SetOptStat(111100)
+     - correct acceptance
+
+   * manalysis/MMultiDimDistCalc.[h,cc]
+     - swap arguments in FindCreateObj
+
+
+
+ 2003/04/08: Nicola Galante and Antonio Stamerra
+
+   * mhist/MHMcTriggerLvl2.[h,cc]
+      - New class added (histograms for the MMcTriggerLvl2 class)
+
+   * mhist/Makefile
+     - Added MHMcTrigggerLvl2 in SRCFILES
+
+   * manalysis/Makefile
+     - Reintroduced MMcTriggerLvl2 and MMcTriggerLvl2Calc 
+       (they were removed!!)
+
+   * manalysis/MMcTriggerLvl2.h
+     - 'const' added in inline functions Get****
+
+   * manalysis/MMcTriggerLvl2Calc.cc
+     - added call to Fill method of MHMcTriggerLvl2
+
+   * macros/triglvl2.C
+     - updated to have histograms with MHMcTriggerLvl2
+
+   * macros/dohtml.C
+     - added triglvl2.C
+
+   * NEWS
+     - new comment on L2T selection classes
+
+ 2003/04/08: Wolfgang Wittek
+
+   * mfilter/Makefile
+             FilterLinkDef.h
+     - MFCT1Supercuts removed
+
+   * manalysis/MMultiDimDistCalc.h
+     - set ClassDef(MMultiDimDistCalc,1)
+
+   * manalysis/MCT1SupercutsCalc.[h,cc]
+     - new; replaces MFCT1Supercuts in mfilter
+
+   * manalysis/Makefile
+               AnalysisLinkDef.h
+
+
+
+ 2003/04/07: Thomas Bretz
+
+   * Makefile:
+     - changed order
+     
+   * manalysis/MMultiDimDistCalc.[h,cc]:
+     - fixed default title
+     - simplified code
+     - added fHadronnessName
+
+   * manalysis/MRanForestCalc.[h,cc]:
+     - added fHadronnessName
+   
+   * mbase/MAGIC.h:
+     - fixed a bug with rootcint
+     
+   * meventdisp/MGFadcDisp.cc:
+     - fixed a variable name
+
+   * mhist/MHHadronness.cc:
+     - removed many old comments
+     - simplified some code
+     - uses argument in Fill now
+
+   * mmain/MMonteCarlo.cc:
+     - some code simplification
+     - fixed a warning 
+
+   * macros/dohtml.C:
+     - added testenv.C
+
+   * readraw.cc:
+     - simplified
+   
+   * mraw/MRawEvtData.cc:
+     - fixed a bug in the draw function (the drawn pixel has not been the
+       one with the given Id, but simply the i-th entry in the array)
+
+   * mfilter/MFCT1Supercuts.[h,cc]:
+     - changed naming style of variables
+     - changes array access
+
+   * mhist/MHFadcCam.[h,cc]:
+     - added HasHi
+     - added Exists
+
+   * mmain/MDataCheck.cc:
+     - removed unimplemented buttons
+
+   * mdatacheck/MGDisplayAdc.[h,cc]:
+     - tried to implement some unimplemented buttons
+     - don't display non existing (empty) histograms in list
+
+
+
+ 2003/04/04: Thomas Bretz
+
+   * mtools/MagicReversi.[h,cc]:
+     - added support for Number of Players
+     - added instructions
+     - added support for Esc key
+
+   * mbase/MAGIC.h:
+     - added version check to MAGIC.h
+
+
+
+ 2003/04/04: Wolfgang Wittek
+
+   * mfilter/Makefile
+            /FilterLinkDef.h
+     - added MFCT1SelBasic, MFCT1SelStandard, MFCT1SelFinal,
+             MFCT1Supercuts
+
+   * mfilter/MFCT1SelBasic.[h,cc]
+            /MFCT1SelStandard.[h,cc]
+            /MFCT1SelFinal.[h,cc]
+     - new; they replace manalysis/MSelBasic.[h,cc]
+                                  /MSelStandard.[h,cc]
+                                  /MSelFinal.[h,cc]
+ 
+   * mfilter/MFCT1Supercuts.[h,cc]
+     - new (supercuts from Daniel for CT1 Mkn421 2001 data)
+
+   * manalysis/MSelBasic.[h,cc]
+              /MSelStandard.[h,cc]
+              /MSelFinal.[h,cc]
+     - deleted
+
+   * manalysis/Makefile
+               AnalysisLinkDef.h
+     - MSelBasic, MSelStandard, MSelFinal removed
+
+   * mfileio/MCT1ReadPreProc.[h,cc]
+     - smeare theta only for MC events
+
+   // The following is not yet commited !!!!!!!!!!!!!
+   * Mars/Makefile
+     - in SUBDIRS put mfilter before manalysis
+       (otherwise get link error)
+
+
+
+ 2003/04/03: Abelardo Moralejo
+
+   * mmontecarlo/MMcTriggerRateCalc.cc:
+     - added #include <math.h> for compilation on alpha (otherwise 
+       floor() is unkown)
+
+
+
+ 2003/04/03: Thomas Bretz
+
+   * macros/testenv.C:
+     - added
+
+   * mbase/MEvtLopp.cc, mbase/MParContainer.[h,cc], 
+     mbase/MParList.cc, mbase/MTaskList.cc:
+     - changed the stuff for reading steering card - didn't really
+       work like expected
+
+   * mhist/MHMatrix.cc, mfileio/MRead.cc, manalysis/MImgCleanStd.cc:
+     - adapted ReadEnv
+
+   * mhist/MHMatrix.[h,cc]:
+     - added ReadEnv
+     
+   * mfileio/MCT1ReadPreProc.[h,cc]:
+     - base SmearTheta on new FindLoEndge
+     - simplified
+   
+   * mhist/MBinning.h:
+     - added FindBinLoEdge
+     - added FindBinHiEdge
+
+   * mdata/MDataArray.[h,cc]:
+     - added Clear
+     - added Delete
+
+   * mbase/MEvtLoop.cc:
+     - added output of the name
+   
+   * mbase/MLog.[h,cc]:
+     - don't use any pthread stuff if _REENTRANT is not defined
+   
+   * mfileio/MRead.cc, mhist/MHMatrix.cc:
+     - fixed waring for unreachable statement
+   
+   * mhist/MHArray.cc:
+     - fixed: redifinition of default argument
+     
+
+
+
+ 2003/04/02: Abelardo Moralejo
+
+   * mmc/MMcTrigHeader.hxx
+     - added threshold>0 check in the calculation of 
+       GetMeanThreshold
+
+   * mmontecarlo/MMcTriggerRateCalc.cc
+     - The check of the MC spectral index value is now done by 
+       comparing integers instead of real numbers.
+     - Found out with GREAT surprise that the graphical output
+       has been completely commented out by someone(?) because it 
+       produced a memory leak. Also the function comment did not 
+       match the rules (my fault; is it correct now?) This commenting 
+       out has not been logged to this file, as far as I can see. This
+       is rather unkind, I thought that when somebody finds some bug or
+       messy code, he should either correct and commit it (and log the 
+       change here) and/or inform the author of the mistake to correct 
+       it. Please try to do so in the future instead of simply 
+       commenting out useful code!
+
+   * mdata/MDataValue.h
+     - added default constructor (otherwise, no constant values 
+       can be used in the parameters used in the random forest 
+       separation)
+
+
+
+
+ 2003/04/02: Wolfgang Wittek
+
+   * mfileio/Makefile
+     - mhist added, because MBinning is used in MCT1ReadPreproc
+
+   * mfileio/MCT1ReadPreProc.[h,cc]
+     - new member function SmearTheta
+     - store smeared  Theta in MMcEvt::fTelescopeTheta
+       store original Theta in MParameterD container "ThetaOrig"
+       store fhourangle     in MParameterD container "HourAngle"
+
+   * manalysis/MPointingCorr.[h,cc]
+     - get hour angle from ParameterD container "HourAngle"
+
+   * manalysis/MSelBasic.[h,cc]
+               MSelStandard.[h,cc]
+               MSelFinal.[h,cc]
+     - new member functions SetCuts()
+
+
+
+ 2003/04/01: Abelardo Moralejo
+
+   * macros/CT1EnergyEst.C
+     - added argument (maximum dist parameter), changed (reduced) output 
+       histograms, added writing to (and reading from) a file the energy 
+       estimation parameters and the histograms. Added comments.
+
+   * manalysis/MEnergyEstParam.[h,cc]
+     - added member function GetCoeff. Changed comment.
+
+
+
+ 2003/03/31: Thomas Bretz
+
+   * manalysis/MParameters.[h,cc]:
+     - added
+
+   * manalysis/AnalysisLinkDef.h, manalysis/Makefile:
+     - added MParameters, MParameterD, MParameterI
+
+   * mhist/MHArray.[h,cc]:
+     - added default constructor
+     - added Set-function
+     - added Init function
+     - moved code from constructors to Set and Init
+ 
+   * Makefile.conf.linux:
+     - removed -fno-rtti to make it compatible with root 3.04.02
+   
+   * NEWS:
+     - changed
+   
+   * manalysis/MImgCleanStd.[h,cc]:
+     - added SetLvl1
+     - added SetLvl2
+     - added ReadEnv
+   
+   * manalysis/MNewImagePar.[h,cc]:
+     - removed unnecessary fHillas data member
+     - removed unnecessary fSrcPos data member
+     - removed unnecessary Set/GetSrcPos 
+   
+   * manalysis/MNewImageParCalc.[h,cc]:
+     - removed unnecessary SetSrcPos 
+     - removed const-qualifier from fGeomCam, fCerPhotEvt
+       (trouble with root 3.02/06)
+   
+   * manalysis/MRanForest.cc:
+     - changed cout-output
+     
+   * manalysis/MSigmabar.cc:
+     - changed Area to area (local variable)
+
+   * mbase/MEvtLoop.[h,cc]:
+     - added evtloop name to constructor (default=Evtloop)
+     - adapted StreamPrimitive
+     - added ReadEnv
+     - added WriteEnv
+     
+   * mbase/MParContainer.[h,cc]:
+     - removed TROOT.h
+     - fixed const-qualifier for Copy-function for root>3.04.01
+     - added ReadEnv
+     - added WriteEnv
+     - added IsEnvDefined
+     - added GetEnvValue
+     
+   * mbase/MParList.[h,cc], mbase/MTaskList.[h,cc]:
+     - added ReadEnv
+     - added WriteEnv
+   
+   * mfileio/MCT1ReadAscii.[h,cc], mfileio/MCT1ReadPreProc.[h,cc]:
+     - changed AddFile declaration to declaration in MRead
+     - added return value to AddFile
+     
+   * mfileio/MRead.[h,cc]:
+     - added template for AddFile
+     - added ReadEnv
+     
+   * mgui/MHexagon.[h,cc]:
+     - fixed const-qualifier for Copy-function for root>3.04.01
+   
+   * mhist/MH.cc:
+     - fixed the FindGoodLimit stuff for root> 3.04.01
+     
+   * mhist/MHRanForest.[h,cc], mhist/MHRanForestGini.[h,cc]:
+     - removed unnecessary casts
+     - fixed a copilation error with root 3.04.01 (kFullDotlarge 
+       doesn't exist)
+     - removed second Draw (one should not add something twice to 
+       the pad)
+       
+   * mmontecarlo/MMcTriggerRateCalc.cc:
+     - changes to the header
+     - changes to the fLog stuff
+     - added a cast to get rid of a warning
+     
+   * mtools/Makefile, mtools/ToolsLinkDef.h:
+     - added MagicReversi
+   
+   * mtools/MagicRevers.[h,cc]:
+     - added
+
+
+
+ 2003/03/28: Thomas Bretz
+
+   * mbase/MParContainer.h:
+     - added kEnableGraphicalOutput
+     - added EnableGraphicalOutput
+     - added IsGraphicalOutputEnabled
+   
+   * mbase/MParList.h:
+     - changed BIT(15) to BIT(17)
+   
+   * mhist/MH.[h,cc]:
+     - SetBinning(TH1*, TH1*) --> SetBinning(TH1*, const TH1*)
+   
+   * mhist/MH3.h:
+     - changed BIT(15) to BIT(17)
+     - changed BIT(16) to BIT(18)
+     - changed BIT(17) to BIT(19)
+
+   * mhist/MHMatrix.[h,cc]:
+     - added DrawDefRefInfo
+     - added CopyCrop
+     - added GetRandomArrayI
+     - changed DefRefMatrix to support the above
+     - fixed a bug in DefRefMatrix (evtcount2 in the last loop
+       instead of evtcount1)
+     - Don't do anything in the finalization if the matrix has the correct
+       dimensions
+     - fixed comment of DefRefMatrix
+     - changed number of first column from 1 to 0
+     - changed BIT(16) to BIT(17)
+
+
+
+ 2003/03/28: Wolfgang Wittek
+
+    * mhist/MHMatrix.cc
+      - DefRefMatrix: if nmaxevts>fM.GetNrows() set 
+        nmaxevts = fM.GetNrows()
+
+    * manalysis/MSelBasic.[h,cc]
+      - better output
+
+    * manalysis/MSelStandard.[h,cc]
+      - different cut in DIST
+
+    * mfileio/MCT1ReadPreProc.[h,cc]
+      - store hour angle in variable fOtherCphFraction
+
+    * manalysis/MHillasSrcCalc.h
+      - replace in 'SetInput'         fHillasName  = hilname;
+                    by                fHillasInput = hilname;        
+
+    * manalysis/MNewImagePar.[h,cc]
+               /MNewImageParCalc.[h,cc]
+      - new; calculates new image parameters
+
+    * mhist/MHNewImagePar.[h,cc]
+      - new; plots new image parameters              
+
+    * manalysis/AnalysisLinkDef.h
+      manalysis/Makefile
+
+    * mhist/HistLinkDef.h
+      mhist/Makefile
+
+
+
+ 2003/03/27: Thomas Hengstebeck
+
+    * manalysis/MRanForest.[h,cc]
+      - allocation of TObjArray fForest moved to constructor.
+      - use of gRandom 
+
+    * manalysis/MRanTree.[h,cc]
+      - use of gRandom
+    
+    * macros/RanForest.C
+      - gRandom initialized as TRandom3 object.
+ 
+
+
+ 2003/03/25: Abelardo Moralejo
+
+    * macros/mergecamera.C
+      - added warning to prevent dangerous misuse of this macro.
+
+
+
+ 2003/03/25: Wolfgang Wittek
+
+    * mhist/MHStarMap.[h,cc]
+      - use constant step size along the main axis of the ellipse
+
+    * manalysis/MPointingCorr.[h,cc]
+      - new class for calculating the pointing correction
+
+    * mmc/MMcEvt.hxx
+      - add GetOtherCphFraction()
+
+    * manalysis/Makefile
+
+    * manalysis/AnalysisLinkDef.h
+
+
+
+ 2003/03/24: Abelardo Moralejo
+
+    * manalysis/MEnergyEstParam.cc
+      - now energy estimation (for CT1) is done using the same model 
+	as in D.Krannich's thesis.
+
+
+
+ 2003/03/24: Thomas Bretz
+
+    * manalysis/MHillasSrcCalc.[h,cc]:
+      - removed last argument in constructor, replaced by SetInput
+
+    * mfilter/MFEventSelector.[h,cc]:
+      - removed unnecessary last argument
+
+
+
+ 2003/03/21: Thomas Hengstebeck
+ 
+    * manalysis/MRanTree.[h,cc]
+      - new; parameter container to store a single random tree
+
+    * manalysis/MRanForest.[h,cc]
+      - new; parameter container to store complete forest
+
+    * manalysis/MRanForestGrow.[h,cc]
+      - new; task to grow trees (training)
+
+    * manalysis/MRanForestCalc.[h,cc]
+      - new; task to calculate hadronness using random forest
+
+    * manalysis/MRanForestFill.[h,cc]
+      - new; task to read in the trees of the random forest
+
+    * manalysis/Makefile, manalysis/HistLinkDef.h:
+      - added MRanTree, MRanForest, MRanForestGrow, MRanForestCalc, 
+        MRanForestFill
+
+    * mhist/MHRanForest.[h,cc]
+      - new; histogram showing variance of estimated hadronness as 
+        function of no. of combined trees 
+
+    * mhist/MHRanForestGini.[h,cc]
+      - new; histogram showing mean decrease in Gini-index as function 
+        of RF-input-parameters
+
+    * mhist/Makefile, mhist/HistLinkDef.h:
+      - added MHRanForest, MHRanForestHillas
+
+    * macros/RanForest.C
+      - new; g/h-separation by Random Forest-method
+
+    * macros/RanForest2.C
+      - new; reading in saved random forest (using MRanForestFill)
+
+
+
+ 2003/03/21: Abelardo Moralejo
+
+    * mhist/MHMatrix.[h,cc]:
+      - Added third argument (a filter) to the second instantiation 
+	of the Fill procedure.
+
+    * macros/CT1EnergyEst.C:
+      - Example of the parameter calculation and use of the energy 
+	estimation method for CT1.
+
+
+
+ 2003/03/21: Thomas Bretz
+
+    * manalysis/MEnergyEstParam.[h,cc]
+      - Added StopMapping and Print functions.
+
+    * manalysis/MSel*.h:
+      -	set default for HilName to MHillas
+      -	set default for HilNameSrc to MHillasSrc
+
+    * mfileio/MCT1ReadPreProc.[h,cc]:
+      - do not flood the output with all events from the first run
+      - output meaningfull text instead of variable names
+      - removed a 'goto'!
+      - changed savePedRMS according to the coding conventions to
+        fPedRMS and the array of fixed size to a TArrayF
+    
+    * mbase/MEvtLoop.cc:
+      - added a events counter which counts the real number of 
+        processed events.
+
+    * mdata/MDataChain.[h,cc]:
+      - implemented random numbers
+      - implemented a conversion from degrees to radians and vice versa
+
+
+
+ 2003/03/20: Thomas Bretz
+
+    * mfilter/MF.[h,cc]:
+      -	changed fFilter (already used in base class MTask) to fF
+
+
+
+ 2003/03/19: Abelardo Moralejo
+
+    * macros/CT1collarea.C:
+      -	Added filter to cut in hadronness (now available in new version
+        of root CT1 Monte Carlo file from Wolfgang).
+
+
+
+ 2003/03/19: Robert Wagner
+
+    * mhist/MH3.cc:
+      - changed MH3::New() such that constructor according to Thomas'
+        previous changes is supported
+
+
+
+ 2003/03/19: Thomas Bretz
+
+    * mhist/MH3.[h,cc]:
+      - changed default constructor to support different dimensions
+
+    * mhist/MHArray.[h,cc]:
+      - added AddHistogram
+
+    * meventdisp/MGEvtDisplay.cc, mfileio/MReadTree.[h,cc],
+      meventdisp/MReadMarsFile.cc:
+      - changed MReadTree::GetEventNum to MReadTree::GetNumEntry
+
+    * macros/estfit.C:
+      - adopted to new MChisqEval
+
+    * mtools/MChisqEval.[h,cc]:
+      - added
+
+    * mtools/Makefile, mtools/ToolsLinkDef.h:
+      - added MChisqEval
+
+    * manalysis/MEnergyEstParam.[h,cc]:
+      - slight changes
+    
+    * mfileio/MCT1ReadPreProc.cc:
+      - changed name to MRead
+
+
+
+ 2003/03/18: Thomas Bretz
+
+    * mfileio/MReadTree.cc:
+      - fixed a bug in the AddFile function
+
+    * mhist/MHMatrix.[h,cc]:
+      - implemented a request of Th. Hengstebeck: Let DefRefMatrix
+        return the 'unused' events
+
+
+
+ 2003/03/18: Abelardo Moralejo
+
+    * mhist/MHMcCT1CollectionArea.[h,cc]
+      - Added arguments in constructor: number of bins and ranges of the 
+	x-axis (energy) of the 2-d histograms. Changed type of binning:
+	now the x-axis is log10(energy) and bins have equal width.
+
+    * macros/CT1collarea.C
+      - The MHMcCT1CollectionArea object is now created and added to the 
+       	parlist so that  we can choose the binning. Changed the way 
+       	histograms are written to the output file.
+
+
+
+ 2003/03/13: Abelardo moralejo
+
+    * mhist/MHMcCT1CollectionArea.[h,cc]
+      - Added for calculations of collection area for CT1.Contains three
+        2-d histograms with axis energy vs theta angle: one histogram for
+        all events, one for analyzed events, one for the collection area.
+
+    * mmontecarlo/MMcCT1CollectionAreaCalc.[h,cc]
+      - Added for the same reason. 
+
+    * macros/CT1collarea.C
+      - Uses the above classes
+
+
+
+ 2003/03/12: Abelardo Moralejo
+
+    * macros/mergecamera.C
+      - Added. Merges several MC camera output files into a single file.
+
+
+
+ 2003/03/08: Wolfgang Wittek
+
+    * macros/AnalyseCT1.C
+      - for the CT1 data analysis
+
+    * mhist/MHMatrix.[h,cc]
+      - let refcolumn start at 1 (not at 0)
+
+    * mhist/MHSigmaTheta.[h,cc]
+      - Draw replaced by DrawCopy
+      - add SetDirectory(NULL)
+
+    * manalysis/MSelBasic.[h,cc]
+                MSelStandard.[h,cc]
+                MSelFinal.[h,cc]
+      - more detailed output for errors
+      - bugs removed
+      
+    * manalysis/MPadSchweizer.[h,cc]
+      - add SetDirectory(NULL)
+      - add fErrors
+
+    * mfilter/MFEventSelector.[h,cc]
+      - add fErrors
+
+    * manalysis/MMultiDimDistCalc.[h,cc]
+      - check division by zero
+
+    * mhist/MHHadronness.[h,cc]
+      - check division by zero
+      - normalize distributions of hadronness
+
+    * mfileio/MCT1ReadPreProc.[h,cc]
+      - add event number (event.isecs_since_midday)
+      - change definition of "fIsMcFile", 
+        because outpars.bmontecarlo is set wrongly sometimes
+      - copy pedestalRMS for each event from the header information
+      - check for the presence of a footer record even after reading 
+        a run header
+
+    * mmc/MMcEvt.[hxx,cxx]:
+      - add GetEvtNumber()
+
+
+
+ 2003/02/27: Abelardo Moralejo
+
+    * mmontecarlo/MMcTriggerRateCalc.cc:
+      - Fixed: MMCTrigHeader could not be found in the case of camera
+	files containing single trigger condition.
+
+    * macros/trigrate.C
+      - no plot is made in the case of single trigger condition.
+
+    * mhist/MHMcRate.[h,cc]
+      - Added member fTriggerCondNum to keep track of what trigger
+        condition corresponds to each MHMcRate object, for the case of
+        files with more	than one condition (when running camera in 
+        trigger_loop mode). Added also Set and Get procedures for nre 
+        member.
+
+    * mmain/MMonteCarlo.cc
+      - Fixed bug: matrix BgR was created with dimension "dim", a number
+        which can be negative. Put "num" instead of "dim".
+
+
+
+ 2003/02/25: Thomas Bretz
+
+    * mbase/MParContainer.cc:
+      - small simplification for Cosy
+    
+    * mbase/MLog.cc:
+      - allow a maximum of 1000 lines in the gui
+
+
+
+ 2003/02/25: Abelardo Moralejo
+
+    * mmontecarlo/MMcTriggerRateCalc.[h,cc]
+      - Added axis labels in graphic output
+      - Added Get function for rate histograms
+
+    * macros/trigrate.C
+      - Added output file with rate histograms
+
+
+
+ 2003/02/24: Abelardo Moralejo
+
+    * mmontecarlo/MMcTriggerRateCalc.[h,cc]
+      - Fixed mistake when analysing camera files containing all
+        events (including non-triggers): fShowers was always zero.
+      - Added reading of MMcTrigHeaders in ReInit
+      - Added procedure Draw for graphics output: rate versus
+        discriminator threshold (useful for camera files with several
+        trigger conditions).
+
+    * macros/trigrate.C
+      - Added some explanations. Style improvements in function
+        GetNSBEvents. Added call to MMcTriggerRateCalc::Draw
+
+    * mhist/MHMcRate.[h,cc]
+      - Added GetTriggerRate() and GetTriggerRateError()
+      - Added members fMultiplicity and fMeanThreshold, with their
+        corresponding Set and Get functions
+      - Added info on discriminator threshold and L1 trigger
+        multiplicity on the printout.
+
+    * mmc/MMcTrigHeader.hxx
+      - Added GetMultiplicity() and GetMeanThreshold()
+
+
+ 2003/02/22: Wolfgang Wittek
+
+    * mhist/Makefile
+      - MHSigmaTheta added
+
+    * mhist/HistLinkDef.h
+      - MHSigmaTheta added
+
+    * mhist/MHSigmaTheta.[h,cc]
+      - type inconsistency removed
+
+
+
+ 2003/02/21: Abelardo Moralejo
+
+    * mmontecarlo/MMcTriggerRateCalc.[h,cc]
+      - adapted to new camera files, added warnings.
+      - added ReInit procedure to read relevant info from from the
+        run headers
+
+    * mhist/MHMcRate.[h,cc]
+      - adapted accordingly. Added Set functions for several members.
+
+    * mmc/MMcCorsikaRunHeader.h
+      - added Get functions for fELowLim, fEUppLim and fSlopeSpec.
+
+    * mmain/MMontecarlo.cc, macros/trigrate.C
+      - adapted to changes above, changed MReadTree to MReadMarsFile to
+	be able to read the run headers.
+
+
+
+ 2003/02/21: Antonio Stamerra 
+
+    * manalysis/MMcTriggerLvl2.[cc|h]
+      - new data member fCompactNN needed to define a compact pixels
+      - new inline functions SetCompactNN and GetCompactNN 
+      - Method Calc(int neighpix) -> Calc(). The value of neighpix
+	is read from fCompactNN
+
+    * manalysis/MMcTriggerLvl2Calc.[cc|h]
+      - Check on fCompactNN added in the PreProcess
+
+    * macros/triglvl2.C
+      - Set of fCompactNN added
+
+
+
+ 2003/02/21: Wolfgang Wittek
+
+    * manalysis/MSelFinal.[h,cc]
+      - 'const' removed from pointers
+
+    * macros/AnalyseCT1.C
+      - macro for the CT1 analysis (work in progress)
+
+
+
+ 2003/02/20: Wolfgang Wittek
+
+    * manalysis/Makefile
+      - add MSelFinal
+
+    * manalysis/AnalysisLinkDef.h
+      - add MSelFinal
+
+    * manalysis/MPadSchweizer.[h,cc]
+      - slight modification of padding procedure
+
+    * manalysis/MSigmabarCalc.[h,cc]
+      - 'const' removed from pointers
+
+    * mhist/MHMatrix.[h,cc]
+
+    * mhist/MHSigmaTheta.[h,cc]
+
+
+
+ 2003/02/20: Abelardo Moralejo
+
+    * mhist/MH.cc
+      - Removed call to TGaxis::Optimize for compilation under root 
+        versions > 3.03, since in them this procedure is no longer 
+        existing. I did this to allow compilation under root_3.04,
+        since earlier versions has a bug which prevents from
+        plotting in the simple way some variables in a tree
+        (example: fConc and others in the output  of star.C). This
+        is a temporal fix, I guess something will have to
+	substitute the call to Optimize...
+
+
+
+ 2003/02/20: Antonio Stamerra 
+
+    * manalysis/MMcTriggerLvl2.[cc|h]
+      - new; replaces MTrigLvl2.[cc|h]
+      - new data members: fLutPseudoSize, fPseudoSize.
+      - functions renamed:
+			GetLutPseudoSize -> CalcBiggerLutPseudoSize
+			GetBiggerFiredCell -> CalcBiggerFiredCell
+      - new inline functions: GetLutPseudoSize(), GetPseudoSize().	
+      - new member functions: 
+		Calc(); CalcPseudoSize (not yet implemented)
+      - Redefined Print() function as a TObject.
+      - pixels_in_cell and pixels_in_lut redefined as static data 
+        members
+
+    * manalysis/MMcTriggerLvl2Calc.[cc|h]
+      - new; replaces MTrigLvl2FillTask.[cc|h]
+      - creation and filling of histograms commented
+      - Process() calls the MMcTriggerLvl2::Calc()           
+ 
+    * mfilter/MFTriggerLvl2.[h|cc]
+      - new class to select events using MMcTriggerLvl2 data members.
+
+    * macros/triglvl2.C
+      - added example to use the MFTriggerLvl2 filter.
+
+
+
+ 2003/02/19: Wolfgang Wittek
+
+    * manalysis/MSelBasic.[h,cc]
+      - new; evaluates the Basic Cuts (after the calibration) 
+
+    * manalysis/MSelStandard.[h,cc]
+      - new; evaluates the Standard Cuts 
+        (after the calculation of the image parameters and before the 
+         calculation of the hadronness)
+
+    * manalysis/MHillasCalc.[h,cc]
+      - replace
+              fHillas = (MHillas*)pList->FindCreateObj(fHilName);
+        by          
+              fHillas = (MHillas*)pList->FindCreateObj("MHillas",
+                                                       fHilName);
+        in order to allow MHillas containers with a name 
+                                  different from "MHillas"
+
+    * mhist/MHHillasExt.[h,cc]
+      - replace
+               TObject *obj = plist->FindObject("MHillas");
+        by          
+               TObject *obj = plist->FindObject(fHilName, "MHillas");
+        in order to allow MHillas containers with a name 
+                                  different from "MHillas"
+      - add a 3rd argument in the constructor : fHilName
+
+    * manalysis/MHillasSrcCalc.[h,cc]
+      - add new argument for constructor:
+                the name of the MHillas input container
+        in order to allow MHillas input containers with a name
+                                  different from "MHillas"     
+
+    * mhist/MHMatrix.[h,cc]
+      - add member function DefRefMatrix();
+        it defines the reference sample for the g/h separation;
+        the selection of events for the reference sample can be made
+        such that the distribution of a certain variable (for example
+        Theta) agrees with a target distribution.
+
+    * mfilter/MFEventSelector.[h,cc]
+      - add new argument for constructor:
+                the name of the read object
+        in order to allow also read objects which have a name
+        different from
+           "MRead"        
+
+
+
+ 2003/02/18: Thomas Bretz
+ 
+    * mfileio/MReadTree.cc:
+      - added a fix for a bug in the workaround using wildcards
+
+
+
+ 2003/02/14: Thomas Bretz
+ 
+    * mtemp/MObservatory.[h,cc]:
+      - added
+
+
+
+ 2003/02/10: Abelardo Moralejo
+
+    * Makefile.conf.osf1
+      - Added -lpthread to compilation flags (otherwise linking fails
+        in alfa)
+
+    * manalysis/Makefile, AnalysisLinkDef.h
+      - Changed MApplyPadding for MPadding
+
+
+
+ 2003/02/07: Wolfgang Wittek
+
+    * mhist/MHSigmaTheta.[h,cc]
+      - new; 2D distribution : Theta, Sigmabar
+             3D distribution : Theta, pixel number, Sigma
+             3D distribution : Theta, pixel number, Sigma^2-Sigmabar^2
+        these histograms may be used for the padding
+
+    * manalysis/MPadding.[h,cc]
+      - new; replaces MApplyPadding.[h,cc] 
+             some errors removed               
+
+    * manalysis/MSigmabar.[h,cc]
+      - new definition of Sigmabar (only relevant for MAGIC) 
+      - add in member function 'Calc' a 3rd argument : 'const
+        MCerPhotEvt &evt'
+      - calculate sigmabar for 'MCerPhotEvt' pixels
+      - in member function 'Calc' return Float_t fSigmabar instead of
+        Bool_t
+      - copies of objects replaced by references
+
+    * manalysis/MSigmabarCalc.[h,cc]
+      - fSig->Calc(*fCam, *fPed)         replaced by
+        fSig->Calc(*fCam, *fPed, *fEvt)
+      - change type of result of fSig->Calc from Bool_t to Float_t
+
+    * mfileio/MCT1ReadPreProc.cc
+      - add in member function PreProcess() the initialization of the
+        total number of pixels :
+                               fPedest->InitSize(iMAXNUMPIX);
+      - remove statements that cannot be reached ('break' after 
+        'return')
+
+    * manalysis/MPadSchweizer.[h,cc]
+      - alternative to MPadding
+      - does the padding ala Thomas Schweizer 
+
+
+
+ 2003/02/06: Thomas Bretz
+
+    * mgeom/MGeomCam.[h,cc]:
+      - fixed a warning (GetPixRatio(int) --> GetPixRatio(Uint)
+
+
+
+ 2003/02/07: Antonio Stamerra 
+
+    * manalysis/MTrigLvl2.[cc|h]
+      - added new function 
+	MTrigLvl2::GetLutCompactPixel(int cell, int lut, int 
+        neighpix=2) which calculates the number of compact pixel
+        in one lut 
+      - added new function GetLutPseudoSize(int neighpix=2) which
+        calculates the lut-pseudosize 
+      - added static data member pixel_in_lut
+      - merging of the PrintCell and PrintStatus functions in a single 
+	Print(int cell) function	
+      - Added comments using the standard layout
+      - some small changes following Thomas comments (memset, *fLog) 	
+
+
+
+ 2003/02/06: Thomas Bretz
+
+    * mbase/MLog.[h,cc]:
+      - serialized the GUI output (problems with mutithreded prgs,
+        eg Cosy)
+
+    * mtemp/MObservatoryLocation.[h,cc], mtemp/MVPObject.[h,cc],
+      mtemp/MVPPlotter.[h,cc]:
+      - added changes discussed in Wuerzburg
+   
+    * mfileio/MCT1ReadPreProc.cc:
+      - some simplifications
+
+
+
+ 2003/01/31: Antonio Stamerra & Marcos Lopez
+
+    * mgui/MCamDisplay.[cc|h]
+      - Added a new function MCamDisplay::SetPix(const Int_t pixnum, 
+        const Int_t color, Float_t min, Float_t max) which just set the 
+        color of a given pixel 
+
+    * created two new classes for simulating the second level trigger 
+      in the directory manalysis:
+      - MTrigLvl2.[cc|h]         // Implement the Lvl2 topology and
+                                 // selection strategies
+      - MTrigLvl2FillTask.[cc|h] // For a given MMc event, fill the
+                                 // MTrigLvl2 with the Lvl1 trigger 
+                                 // information 
+
+    * manalysis/Makefile
+      - Added -I../mgui
+
+    * Added macro macros/triglvl2.C which uses the above classes.
+
+
+
+ 2003/01/27: Robert Wagner
+
+    * mfileio/MCT1ReadPreProc.[cc|h]
+      - Added call of MTaskList::ReInit after processing of new 
+        run header
+      - Filling of MC container complies to Oscar's changes of 
+        MMcEvt.[hxx,cxx] dated 2003/01/20
+      - Added filling of run number in MRawRunHeader object while
+        processing a new run header
+
+
+
+ 2003/01/23: Robert Wagner
+
+    * manalyis/MSigmabarCalc.cc
+      - MSigmabarCalc::Process()
+        Replaced fMcEvt->GetTheta() by fMcEvt->GetTelescopeTheta()
+
+
+
+ 2003/01/20: Oscar Blanch
+  
+    * mmc/MMcEvt.[hxx,cxx]
+      - Data members: fElecCphFraction, fMuonCphFraction, 
+        fOtherCphFraction have been introduced.
+      - Class version updated to 3.
+
+    * mmc/MMcCorsikaRunHeader.[h.cc]
+      - Data members: fWobbleMode and fAtmosphericModel introduced.
+      - Class version updated to 2.
+
+
+
+ 2003/01/19: Thomas Bretz
+
+    * manalysis/MCerPhotCalc.[h,cc]:
+      - slight changes, mainly to the layout
+
+    * manalysis/MCerPhotEvt.[h,cc]:
+      - some small changes to make the code a bit faster
+
+    * manalysis/MCerPhotPix.[h,cc]:
+      - added AddNumPhotons
+
+    * mbase/MContinue.[h,cc]:
+      - changed comments
+      - enhanced functionality and fixed some small bugs
+
+    * mbase/Makefile:
+      - added mfilter to paths (to be fixed)
+
+    * mfileio/MCT1ReadPreProc.cc:
+      - Init fNumEvents = 0
+
+    * mgeom/MGeomCam.cc:
+      - return 0 Ratio if the pixel number exceeds the number of pixels
+
+   * mgui/MCamDisplay.[h,cc]:
+     - added sanity check for the maximum number of pixels
+     - added functions to set the three different palettes
+     - removed the buttons
+     - fixed the context menu display
+   
+    * mhist/HistLinkDef.h, mhist/Makefile:
+      - added MHCerPhotEvt
+
+    * mhist/MHCerPhotEvt.[h,cc]:
+      - added
+     
+    * mhist/MFillH.cc:
+      - changed the initialization of fParContainer from pList to NULL
+   
+    * mhist/MHHillasExt.cc:
+      - fixed a smallo bug when filling the histograms (crached when scaling
+        under some circumstances)
+   
+    * mhist/MHStarMap.cc:
+      - added a warning output
+
+    * mmontecarlo/MMcCollectionAreaCalc.cc:
+      - added a check for impact=NaN (some MC Files have this)
+
+
+
+ 2003/01/17: Robert Wagner
+
+    * manalysis/MApplyPadding.cc
+      - bugfix: Effective number of used pixels taken from
+        MCerPhotEvt container, not from MPedestalCam
+
+
+
+ 2003/01/16: Wolfgang Wittek
+
+    * mhist/MHMatrix.[h,cc]
+      - member function MHMatrix::Read added
+        the function calls TObject::Read(name) and SetName(name)
+
+
+
+ 2003/01/15: Wolfgang Wittek
+
+    * mdata/MDataMember.cc
+      - in MDataMember::PreProcess()
+              "if (fCall)" replaced by "if (fCall && !fObject)"
+        The additional condition "&& !fObject" is to make sure that read 
+        MDataMembers works correctly.
+
+
+
+ 2003/01/08: Oscar Blanch Bigas
+
+   * mgeom/MGeomMirror.[h,cc]
+     - Varible members to store mirror reflectivities have been
+       introduced: fReflectivity and fWavelength.
+     - Member function to set reflectivity added: SetReflectivity
+     - Member function to set TArrayF size: SetArraySize
+     - Class version number changed to 2.
Index: /tags/Mars_V0-8-5/Mars/MIncl.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/MIncl.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/MIncl.h	(revision 9661)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-8-5/Mars/MLinkDef.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/MLinkDef.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/MLinkDef.h	(revision 9661)
@@ -0,0 +1,7 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/Makefile
===================================================================
--- /tags/Mars_V0-8-5/Mars/Makefile	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/Makefile	(revision 9661)
@@ -0,0 +1,145 @@
+##################################################################
+#
+#   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 test mona status
+PROGRAMS = readdaq readraw merpp star status mars mona
+SOLIB    = libmars.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 = mbase \
+	  mastro \
+	  mmain \
+          mfbase \
+          mfilter \
+          mdata \
+          mhbase \
+          mhvstime \
+          mhist \
+          manalysis \
+          msignal \
+          mbadpixels \
+	  mcalib \
+          mpedestal \
+          mfileio \
+          mreflector \
+          mgeom \
+          msql \
+          mimage \
+          mmontecarlo \
+          mmc \
+          mraw \
+          mcamera \
+          mpointing \
+          mreport \
+          mgui \
+          mranforest \
+          mhistmc \
+          mjobs \
+          mtools
+
+#LIBRARIES = $(SUBDIRS:%=lib/lib%.a)
+LIBRARIES = $(SUBDIRS:=.a)
+MRPROPERS = $(SUBDIRS:=.mrproper)
+CLEANERS  = $(SUBDIRS:=.clean)
+LIBS      = $(SOLIB)
+
+#------------------------------------------------------------------------------
+.SUFFIXES: .c .cc .h .o 
+
+SRCFILES =
+
+############################################################
+all: $(SOLIB) $(PROGRAMS)
+	@echo " Done. "
+	@echo " "
+
+static: LIBS=$(SUBDIRS:=/*.o) $(OBJS)
+#static: rmlib $(LIBRARIES) $(PROGRAMS)
+static: $(LIBRARIES) $(PROGRAMS)
+	@echo " Done. "
+	@echo " "
+
+include Makefile.rules
+
+#
+# Use $(CXX) -v ... for a more verbose output
+#
+# ROOTGLIBS must be there - why? How can I link the libraries?
+$(SOLIB): $(LIBRARIES) $(OBJS) $(HEADERS)
+	@echo " Linking shared object $(SOLIB) ..."
+	$(CXX) $(CXXFLAGS) $(SOFLAG) $(OBJS) $(SUBDIRS:=/*.o) $(ROOTGLIBS) -o $@
+
+# This is a special workaround to create the shared object (bundle, plugin)
+# for root and the dynlib (to be linked with the executable) on Mac OSX
+ifneq ($(OSTYPE),darwin)
+$(PROGRAMS): $(SOLIB) $(PROGRAMS:=.o)
+	@echo " Linking $@ ..." 
+	$(CXX) $(CXXFLAGS) $(ROOTGLIBS) $(SOLIB) $@.o $(MARS_LIB) -o $@
+else
+$(DYLIB): $(LIBRARIES) $(OBJS) $(HEADERS)
+	@echo " Linking dylib $(DYLIB) ..."
+	$(CXX) $(CXXFLAGS) $(DYFLAG) $(OBJS) $(SUBDIRS:=/*.o) $(ROOTGLIBS) -o $@
+
+$(PROGRAMS): $(DYLIB) $(PROGRAMS:=.o)
+	@echo " Linking mac executable $@ ..." 
+	$(CXX) $(CXXFLAGS) $(ROOTGLIBS) $(DYLIB) $@.o $(MARS_LIB) -o $@
+endif
+
+dox: $(SOLIB)
+	@echo
+	@echo " Creating html documentation and logfile dohtml.log..."
+	rm -f dohtml.log
+	root -b -q dohtml.C 2>&1 >> dohtml.log | tee -a dohtml.log
+	@echo " done."
+	@echo
+
+#clean:	rmcint rmobjs rmdep 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
+
+#Makefile.depend:
+#	(! find ./ Makefile.depend -maxdepth 1 -empty 2> /dev/null && \
+#	echo " Generating dependancies into Makefile.depend" && \
+#	makedepend -- $(INCLUDES) -- $(PROGRAMS:=.cc) $(SRCS) $(SUBDIRS:=/*.cc) -w1024 -f- 2> /dev/null | grep -v Cint | grep -v "/usr/" > Makefile.depend && \
+#	echo " ") || find -maxdepth 0 -true > /dev/null
+#
+#depend:	Makefile.depend	
+
+# @endcode
Index: /tags/Mars_V0-8-5/Mars/Makefile.conf.darwin
===================================================================
--- /tags/Mars_V0-8-5/Mars/Makefile.conf.darwin	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/Makefile.conf.darwin	(revision 9661)
@@ -0,0 +1,48 @@
+##################################################################
+#
+# config.mk
+#
+# @file        config.mk
+# 
+##################################################################
+# @maintitle
+
+# @code
+
+# compilers
+
+CC       = gcc
+CXX      = g++
+F77      = f77
+AR       = ar -src
+
+#
+#  ----->>>   settings for compilation
+#
+OPTIM    = -O5 -Wall -fno-exceptions -fPIC -Wpointer-arith -Wcast-align -Wconversion -Wstrict-prototypes -Wmissing-prototypes -Woverloaded-virtual
+# ggc 3.2: removed -fnonnull-objects -Wtraditional -Wnested-externs
+DEBUG    = 
+ARCHDEF  = -D__LINUX__
+
+# For Mac OSX we need to kind of shared objects. One which can be plugged
+# into root (bundle) and one which can be linked to the executables (dynlib)
+SOFLAG   = -bundle -flat_namespace -Xlinker -bind_at_load
+DYFLAG   = -dynamiclib -single_module -flat_namespace
+
+DYLIB    = $(SOLIB:.so=.dylib)
+
+# For debugging information use '-g'
+# For producing gmon.out use    '-pg'
+
+#MARS_LIB = -Llib $(SUBDIRS:%=-l%) $(MARSLIBS)
+MARS_LIB = -Llib $(MARSLIBS)
+INCLUDES = -I. $(SUBDIRS:%=-I%)
+
+# uncomment this for quiet compilation
+
+.SILENT:
+
+# @endcode
+##EOF
+
+
Index: /tags/Mars_V0-8-5/Mars/Makefile.conf.general
===================================================================
--- /tags/Mars_V0-8-5/Mars/Makefile.conf.general	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/Makefile.conf.general	(revision 9661)
@@ -0,0 +1,27 @@
+#
+#  ----->>>   root libraries
+#
+
+ROOTVER    =  `root-config --version`
+ROOTLIBS   =  `root-config --libs` -lMinuit -lHistPainter -lThread
+ROOTGLIBS  =  `root-config --glibs` -lMinuit -lHistPainter -lThread
+ROOTCFLAGS =  `root-config --cflags`
+
+#
+#  compiler flags
+#
+
+#
+# You can use this flags to further costumize compilation:
+#   export MARSDEFINES="-DHAVE_DARKBACKGROUND -DHAVE_XPM"
+#   export MARSFLAGS=
+#   export MARSLIBS="-lX11 -lXpm -L/usr/X11R6/lib"
+#
+DEFINES	 = -DMARSVER=\"0.8.5\" -D__MARS__ -DROOTVER=\"$(ROOTVER)\" $(ARCHDEF) $(MARSDEFINES)
+
+CXXFLAGS = $(ROOTCFLAGS) $(INCLUDES) $(OPTIM) $(DEBUG) $(DEFINES)
+CFLAGS   = $(CXXFLAGS) $(MARSFLAGS)
+FFLAGS   = $(CXXFLAGS)
+
+HEADERS  = $($(subst .cxx,.cc,SRCFILES):.cc=.h)
+OBJS     = $($(subst .cxx,.cc,SRCFILES):.cc=.o) $(CINT)Cint.o
Index: /tags/Mars_V0-8-5/Mars/Makefile.conf.linux
===================================================================
--- /tags/Mars_V0-8-5/Mars/Makefile.conf.linux	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/Makefile.conf.linux	(revision 9661)
@@ -0,0 +1,34 @@
+##################################################################
+#
+# config.mk
+#
+# @file        config.mk
+# 
+##################################################################
+
+# compilers
+
+CC       = gcc
+CXX      = g++
+F77      = f77
+AR       = ar -rc
+
+#
+#  ----->>>   settings for compilation
+#
+OPTIM    = -O5 -Wall -fno-exceptions -fPIC -Wpointer-arith -Wcast-align -Wconversion -Wstrict-prototypes -Wmissing-prototypes -Woverloaded-virtual
+# ggc 3.2: removed -fnonnull-objects -Wtraditional -Wnested-externs
+DEBUG    = 
+ARCHDEF  = -D__LINUX__
+SOFLAG   = -shared
+
+# For debugging information use '-g'
+# For producing gmon.out use    '-pg' (needs static linking)
+
+#MARS_LIB = -Llib $(SUBDIRS:%=-l%) $(MARSLIBS)
+MARS_LIB = -Llib $(MARSLIBS)
+INCLUDES = -I. $(SUBDIRS:%=-I%)
+
+# uncomment this for quiet compilation
+
+.SILENT:
Index: /tags/Mars_V0-8-5/Mars/Makefile.conf.linux-gnu
===================================================================
--- /tags/Mars_V0-8-5/Mars/Makefile.conf.linux-gnu	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/Makefile.conf.linux-gnu	(revision 9661)
@@ -0,0 +1,45 @@
+##################################################################
+#
+# 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__
+DYNLIB   = -shared
+
+# To be tested:
+# OPTIM    = -pipe  
+# OPTIM2   = -fomit-frame-pointer -ffast-math -march=i686 -mcpu=i686
+
+# For debugging information use '-g'
+# For producing gmon.out use    '-pg'
+
+#MARS_LIB = -Llib $(SUBDIRS:%=-l%)  $(MARSLIBS)
+MARS_LIB = -Llib  $(MARSLIBS)
+INCLUDES = -I. $(SUBDIRS:%=-I%)
+
+# uncomment this for quiet compilation
+
+.SILENT:
+
+# @endcode
+##EOF
+
+
Index: /tags/Mars_V0-8-5/Mars/Makefile.conf.osf1
===================================================================
--- /tags/Mars_V0-8-5/Mars/Makefile.conf.osf1	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/Makefile.conf.osf1	(revision 9661)
@@ -0,0 +1,42 @@
+##################################################################
+#
+# 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 -lpthread
+DEBUG    = -g  -w0 -msg_display_tag -msg_disable castqualtyp,undpreid,unrfunprm,extrasemi,intconlosbit,nonfundec,partovrd,stoclsnotfirst,boolexprconst
+ARCHDEF  = -D__OSF__ -D__USE_STD_IOSTREAM -DR__ANSISTREAM
+DYNLIB   = -shared
+
+#MARS_LIB = -Llib $(SUBDIRS/*/-l&)  $(MARSLIBS)
+MARS_LIB = -Llib $(MARSLIBS)
+INCLUDES = -I. $(SUBDIRS/*/-I&)
+
+# uncomment this for quiet compilation
+
+.SILENT:
+
+# @endcode
+##EOF
+
+
+
Index: /tags/Mars_V0-8-5/Mars/Makefile.conf.osf5.1
===================================================================
--- /tags/Mars_V0-8-5/Mars/Makefile.conf.osf5.1	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/Makefile.conf.osf5.1	(revision 9661)
@@ -0,0 +1,41 @@
+##################################################################
+#
+# config.mk
+#
+# @file        config.mk
+# 
+##################################################################
+# @maintitle
+
+# @code
+
+#
+# compilers
+#
+
+CC       = cc
+CXX      = cxx
+F77      = f77
+AR       = ar -c -r
+
+#
+#  ----->>>   settings for compilation
+#
+
+OPTIM    = -O2 -ieee -arch host
+DEBUG    = -g3  -w0 -msg_display_tag -msg_disable castqualtyp,undpreid,unrfunprm,extrasemi,intconlosbit,nonfundec,partovrd,stoclsnotfirst,boolexprconst
+ARCHDEF  = -D__OSF__ -D__USE_STD_IOSTREAM -DR__ANSISTREAM
+DYNLIB   = -shared
+
+#MARS_LIB = -Llib $(SUBDIRS/*/-l&)  $(MARSLIBS)
+MARS_LIB = -Llib $(MARSLIBS)
+INCLUDES = -I. $(SUBDIRS/*/-I&)
+
+# uncomment this for quiet compilation
+
+.SILENT:
+
+# @endcode
+##EOF
+
+
Index: /tags/Mars_V0-8-5/Mars/Makefile.rules
===================================================================
--- /tags/Mars_V0-8-5/Mars/Makefile.rules	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/Makefile.rules	(revision 9661)
@@ -0,0 +1,92 @@
+include $(CINT)Dep.d
+
+$(MRPROPERS):
+	@echo " Doing Mr.Proper in $(@:.mrproper=)"
+	(cd $(@:.mrproper=); ($(MAKE) -f Makefile mrproper > /dev/null); cd ..;) 
+
+$(CLEANERS):
+	@echo "Cleaning $(@:.clean=):"
+	(cd $(@:.clean=); $(MAKE) -f Makefile clean; cd ..;) 
+
+$(LIBRARIES):
+	@echo " Calling make in $(@:.a=)"
+	(cd $*; $(MAKE) -f Makefile all)
+
+$(LIB): $(OBJS) $(CINT)Cint.o
+	@echo " - Building Library $(LIB)"
+	$(CXX) $(CXXFLAGS) $(DYNLIB) $(OBJS) $(CINT)Cint.o -o $(LIB)
+	@echo " "
+
+$(CINT)Cint.cc: $(HEADERS) $(CINT)LinkDef.h
+	@echo " - Generating dictionary $(CINT)Cint.cc"
+	$(ROOTSYS)/bin/rootcint -f $(CINT)Cint.cc \
+	-c $(INCLUDES) $(DEFINES) $(HEADERS) $(CINT)Incl.h $(CINT)LinkDef.h 
+
+%.d:	
+	@echo " - Generating dependencies" $@
+	$(ROOTSYS)/bin/rmkdepend -f- -Y -w 3000 -- $(INCLUDES) -- $(SRCFILES) 2> /dev/null | \
+         sed 's/^\(.*\).o:/$@ \1.o:/' > $@
+	echo "$@: Makefile" >> $@
+
+%.o:	%.cxx
+	@echo " - Compiling" $<
+	$(CXX) $(CXXFLAGS) -c $< -o $@
+
+%.o:	%.cc
+	@echo " - Compiling" $<
+	$(CXX) $(CXXFLAGS) -c $< -o $@
+
+%.o:	 %.c
+	@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
+
+rmdep:	
+	@echo " Removing dependency files..."
+	@rm -f *Dep.d */*Dep.d
+
+rmcore:	
+	@echo " Removing core files..."
+	@rm -f core*
+
+rmbin:	
+	@echo " Removing binary files..."
+	@rm -f $(PROGRAMS) $(SOLIB) $(DYLIB) 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/examples
+	rm -rf htmldoc/src
+	ls htmldoc/* | grep "htmldoc/" | grep -v images | grep -v CVS | xargs rm -f
+
+clean:	rmcint rmobjs rmdep rmcore rmlib
+
+cflags: 
+	@echo $(INCLUDES) $(CXXFLAGS)
+
+diff:
+	@cvs diff | grep -v "^? " > mars.diff
Index: /tags/Mars_V0-8-5/Mars/NEWS
===================================================================
--- /tags/Mars_V0-8-5/Mars/NEWS	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/NEWS	(revision 9661)
@@ -0,0 +1,613 @@
+                                                               -*-*- END -*-*-
+ *** Version <cvs>
+
+   - new macros for database interaction: filldotrun.C
+
+
+
+ *** Version 0.8.5 (2004/08/06)
+ 
+   - new Signal Extractors: MExtractFixedWindowSpline 
+                         nd MExtractAmplitudeSpline
+
+   - implementes interleave in merpp to be able to merpp parts of a file
+
+   - implemented force-functionality to merpp
+
+   - star display to display star catalogs (MAstroCatalog)
+
+   - star display to 'mirror' stars to the camera (MAstroCamera)
+
+   - implemented a new cleaning option which allows cleaning scaled with
+     the real ratio of the rms depending on the pixel size, not only the
+     square root of the pixelsize (MImgCleanStd, MCameraData)
+
+   - removed obsolete MBlind* classes
+
+   - Signal extractor taking the AB flag into account implemented (this makes
+     an odd number of slices for signal extraction possible
+     (MExtractSignalABcorr)
+
+   - implemented a class extracting the pedestal from the raw-data (events)
+     itself using empty lo-gain (MpedCalcFromLoGain)
+
+   - Added mean values to MPedPhotCam
+
+   - Added Makefile for Darwin (this OS is NOT officially supported!)
+
+
+
+ *** Version 0.8.4 (2004/04/19)
+
+   - new fast arrival time extractor using cubic splines: 
+     MExtractTimeFastSpline
+
+   - implementes multi-argument support in MDataChain
+     ("pow(a, b)")
+
+   - implemented double reference support in MDataChain
+     ("MCameraLV.fPowerSupplyA.fVoltagePos5V")
+
+   - added support in MF for expressiond like 
+     "MHillas.fWidth<2*<MHillas.fLength"
+
+   - MDataChain is now able to support variables like [0], [1], ...
+     which can be used in fit functions as parameters. The interface
+     is implemented through the new virtual function 
+     MParContainer::SetVariables
+
+   - added new class MArrivalTimeCam/MArrivalTimePix:
+     Storage containers to hold the ArrivalTime of the camera/pixel
+
+   - added new classes for the calibration of relative arrival times:
+     MCalibrationRelTimePix and MCalibrationRelTimeCam
+  
+   - added new classes to extract the signal of the blind pixel and the 
+     PIN Diode separately: MExtractBlindPixel and MExtractPINDiode
+
+   - added new classes for the bad-pixels treatment (MBadPixels*)
+     which are more powerfull than the old ones (MBlindPixel*)
+     and will replace them.
+
+   - added filter against cosmics: MFCosmics
+
+   - added new class MArrivalTimeCalc2:
+     Calculates the arrival time as the signal weighted mean of the time 
+     slices in the maximum window
+
+   - added a new macro call pointspreadfucntion.C that fits with a 2D 
+     gaussian the DC spot for an star. It gives you the RMS of
+     the PSF and the center of the star, very useful for misspointing 
+     studies.
+
+   - added support for multi-telescope camera files. Added classes 
+     MStereoCalc and MStereoPar, classes to calculate and store shower
+     parameters calculated from the data of two telescopes, for the MC
+     studies regarding the MAGIC clone.
+
+   - added MMcCalibrationCalc, MMcCalibrationUpdate, classes to obtain
+     MC data calibrated in photons instead of ADC counts.
+
+   - added three macros to show the calibration and analysis chain of 
+     MC data. The macro starmc.C does both calibration and analysis, producing
+     an output containing Hillas parameters for each event. The macro 
+     mccalibrate.C does just the calibration and writes out a file containing
+     pixel information in photons instead of FADC data. The macro starmc2.C
+     reads in such a file and produces an output with Hillas parameters.
+
+   - added MPedPhotCalc to compute pedestals in units of photons, see
+     macro pedphotcalc.C
+
+   - added all class to perform the calibration, see macro calibration.C
+
+   - added class MFFT to perform Fast Fourier Transforms
+
+   - added class MSimulatedAnnealing to perform simulated annealing 
+     minimizations
+
+   - added new macro bootcampstandardanalysis.C which holds the skeleton
+     of the analysis chain discussed in the december bootcamp. 
+
+   - added support for DAQ raw data file format V2
+
+   - implemented an arbitrary time stamp for the events from raw-data
+     files with file version<3. It is calculated from the run number, 
+     the date of start and the FADC clock tick from the first module
+
+   - implemented the correct decoding of the event time-stamp
+     coming from the DAQ for raw-data files with file-version>2
+
+   - added a new classes storing the pedestals in units of photons: 
+     MPedPhotPix, MPedPhotCam
+
+   - added support for DC current files from the camera control
+
+   - added support for start- and stop-time when merpping report files
+
+   - added MReportCC storing the weather data from the CC-REPORT
+
+   - added class to fill trainings and test matrices (MTFillMatrix)
+
+   - added a filter performing a software trigger (MFSoftwareTrigger)
+
+   - Added classes to perform parts of the standard analysis (Jobs):
+     + MJPedestals
+     + MJCalibration
+     + MJExtractSignal
+     Note: All of them are preliminary!
+
+   - Added Iterator to iterate over files giving only the run-number
+
+   - Added class (MHSectorVsTime) and example (sectorvstime.C) to plot
+     the evolution of a sector vs time
+
+
+
+ *** Version 0.8.3 (2003/12/05)
+
+   - adapted Random Forest classes to allow the use with MC
+     multi-telescope files which can be produced with the coming
+     camera version 0.7.
+
+   - added classes to read and interprete central control report files
+     (Directory: mreport, Base-Class: MReport, Reader: MReportFileRead, ...)
+
+   - enhanced merpp (the executable) to support .raw and .rep files.
+
+   - added classes for light calibration (MCalibration* and 
+     MHCalibration*) by Markus Gaug. Further work has to be and will
+     be done soon.
+
+   - Added a preliminary 'synchronizer' (MReadReports) which will 
+     replace MReadMarsFile as soon as it is finished.
+
+   - Added a tutorial macro demonstrating how report files are merpped
+     and how they can be read from the root file in the correct order
+     of time (readrep.C)
+
+   - Added a generalized histogram (similar to MH3) called MVsTime
+     which allows to plot variables (or rules - MDataChain - of
+     variables) vs time. For an example have a look at tempvstime.C.
+
+   - Changed the name of the event trees:
+       + Events    --> Events
+       + PedEvents --> Pedestals
+       + CalEvents --> Calibration
+
+  - changed name of MTime in the event trees from MRawEvtTime to MTime
+
+  - added displaying the sector indices to the mars event display
+
+  - Magic Online Analysis (MOnA) implemented in a first version
+    (see mona.cc, MOnlineDump and MOnlineDisplay)
+
+  - added classes to calculate event rate
+    (preliminary: MEventRateCalc, MEventRate)
+
+  - added new executable 'readdaq' to read *.raw files from the DAQ directly
+
+  - added classes dealing with the telescope pointing position (MPointing*)
+
+  - implemented the 'final' Mars time stamp based on some experiences with
+    the new 'Synchonizer'
+
+
+
+ *** Version 0.8.2 (2003/11/10)
+
+   - accelerated standard analysis by a factor of 6-8 ...
+     + doing precalculations in MGeomCam for the pixel area ratio
+     + creating a look up table for the single pixels in MCerPhotEvt
+
+   - added task to calculates weights in case you want to 'change'
+     the energy spectrum of a monte carlo file 
+     (MMcWeightEnergySpecCalc - Great work from Marcos Lopez Moya)
+
+   - added a new executable star which implements the
+     star.C macro as precompiled executable. Currently a flexible
+     setup is not possible, but a 'input card' setup will follow.
+
+   - Starting to implement Multi-Telescope-Support based on the 
+     upcomming camera version 0.7. The base for a general support
+     is implemented and the star-functionality is proven to work.
+
+   - Replaced Event-Display in and Camera-Display in the Mars GUI
+     executable by a more convinient display base on MStatusDisplay.
+
+   - fixed the algorithm for the blind pixel treatment (MBlindPixelCalc)
+
+
+
+ *** Version 0.8.1 (2003/10/20)
+   
+   - added signal subtraction for pure on data by means of fitting
+     the background in the off region or by performing a combined
+     signal/background fit. Provides necessary histograms for
+     obtaining energy spectra and a light curve.
+
+   - added classes to perform and study the selection of the 
+     2nd Level Trigger on MC data (example in triglvl2.C macro)
+
+   - added pedestal calculation
+
+   - implemented "democratic cleaning" (tail cut value proportional 
+     to pixel area) according to Wolfgang's suggestion.
+
+   - added Sigmabar treatment (calculation and basic histogramming)
+
+   - added basic routines to apply padding
+
+   - added first implementation of MARS-based source visibility plotter
+     (needs to be linked against slalib, preliminary version)
+
+   - enhanced functionality of data chains: random numbers, conversion
+     functions and access to MHMatrix objects
+   
+   - fixed some bugs in the CT1 Preproc file reader, which gave wrong
+     numbers under certain circumstances (runs with 0 events included)
+
+   - fixed a bug in the general filter MF (didn't work on some systems
+     at all)
+   
+   - fixed a bug in chaining files, which caused the analysis to crash or
+     ignore files
+
+   - implemented more geometry classes describing the parameters used
+     to simulate the PMT camera
+
+   - added new Monte Carlo classes containing the setup of the different
+     programs in the MC chain.
+
+   - added a (preliminary) general task to evaluate chi-square of a given
+     parameter in an eventloop.
+
+   - first implementation of a container describing the observatory
+     location (Long, Lat, etc)
+   
+   - added Random Forest - method for g/h-separation
+
+   - made compatible with the latest PRO version of root (3.04/02 and 3.05/07)
+     (this means, that it is compiling, but not yet fully tested)
+
+   - added a new status display which can show the present status
+     of histograms while an eventloop is running (MStatusDisplay,
+     an example can be found at status.C)
+
+   - reorganized directories:
+     classes describing the image              --> mimage
+     classes containing Monte Carlo Histograms --> mhistmc
+     classes for Random Forest method          --> mranforest
+
+   - added (event-)weights to fill histograms
+
+   - colors in logging output to screen
+
+   - changes to the Image Parameter declaration:
+       + moved fConc, fConc1 from MHillasSrc to MNewImagePar
+       + moved fNumUsedPix, fNumCorePix from MHillas to MNewImagePar
+       + MHillasExt now derives from MParContainer instead of MHillas
+     --> Files written with the old definition are more or less unreadable
+
+   - reading of reflector files
+
+   - display data from reflector files in the camera
+
+   - implemented currents (and display them in the camera)
+
+   - logarithmic scale in camera
+
+   - added class to iterate through directory contents (MDirIter)
+
+
+
+ *** Version 0.8 (2002/11/18)
+
+   - added all subdirectories as Include-Paths for ACLIC (s. rootlogon.C)
+
+   - corrected 48(!) wrong entries in the Next Neighbor table of the
+     Magic Camera (all in the inner part of the outer ring, mostly 
+     missing a single NN)
+
+   - Fixed a bug in the table describing the Next Neighbours of the
+     CT1 camera (a pixel 127 doesn't exist and the pixel 126 didn't
+     have any neighbour)
+
+   - changed trigrate.C: now it calculates the pure NSB triggers from
+     a camera file (generated with no showers), so there is no need
+     to introduce them by hand in the BgR array (for more details
+     please ask Abelardo)
+
+   - added MHHadronness (and MHadronness) as a general facility to evaluate
+     the quality of a gamma-hadron seperation method
+
+   - changed MWriteAsciiFile to accept rules (MDataChain)
+
+   - Calls to MWriteAsciiFile::AddContainer and MWriteAsciiFile::AddRule
+     must be replaced by calles to MWriteAsciiFile::AddColumn and
+     MWriteAsciiFile::AddColumns. Be carefull, the arguments have slightly
+     changed.
+
+   - Implemented generalized event-matrices (one row per event)
+     (MHMatrix)
+
+   - implemented the one dimensional composite probabilities
+     (MHCompProb, MCompProbCalc, comprob.C)
+
+   - implemented the Multidimensional Distances (Next Neighbours, Kernel)
+     (MMultiDimDistCalc, multidimdist.C, multidimdist2.C, MHMatrix)
+
+   - Added a camera display displaying the pixel numbers to the
+     event display gui.
+
+   - Added Monte Carlo Informations to event display gui
+
+   - Changed the camera display to display the pixel numbering
+   
+   - Added three buttons to the camera display to change the palette
+
+   - Added the number of used and core pixels after image cleaning
+     to MHillas
+
+   - Changed the algorithm used in MHillas according to TDAS 02-03
+
+   - Changed the Alpha range according to TDAS 02-03 to [-90°,90°]
+
+   - Changed the algorithm used in MHillasSrc according to TDAS 02-03
+
+   - Added fCosDeltaAlpha to MHillasSrc
+
+   - The numbers of photons used to calculate fConc and fConc1 in
+     MHillasExt are now scaled with the pixel size, so that one get
+     a four times smaller value for the bigger pixels in the outer ring.
+
+   - added new task to smooth the camera contents (MCameraSmooth)
+
+   - added possibility to use interpolated pixel values for blind pixels
+     instead of removing it completely from the analysis
+
+   - Implemented the possibility to save the whole eventloop with
+     its setup to a file. This information can be read and from
+     it you can (re)create a Macro. See MEvtLoop::Read, MEvtLoop::Write
+     and MEvtLoop::MakeMacro. If you find something not working, please
+     report - this stuff is still in a beta phase.
+
+   - MBlindPixelCalc set all Ceta-Tauri pixels to unused not only for the
+     file having crab starfield, but also for all following files - fixed
+
+   - MTaskList::PrintStatistics can now be instructud to print also the
+     title, too: use PrintStatistics(0, kTRUE)
+
+   - Changed the image cleaning so that pixels with to many 'used'
+     neighbors are left used (to get rid of 'holes' in events)
+
+   - Introduced more output to the camera displays
+
+   - Added an array of histograms (eg one hist per run), MHArray
+
+   - Added a _preliminary_ version of the reader for CT1 PreProc files
+     (MCT1ReadPreProc)
+
+   - Fixed the error calculation of MHMCollectionArea and MHMcIntRate
+     (thanks to Raquel)
+
+   - added the first energy estimator (MEnergyEstParam, estimate.C,
+     estfit.C) using a parametrization
+
+   - Added some new Monte Carlo paremeter containers used to store
+     setup information from the MC chain (MMcConfigRunHeader, 
+     MMcCorsikaRunHeader, MGeomPMT, MGeomMirror)
+
+
+
+ *** Version 0.7 (2002/04/30)
+ 
+   - added a bugfix to MCerPhotCalc. In older camera versions (<=40)
+     the pedestal mean value was saved incorrectly. For files from
+     this versions we substract 0.5 from the pedestal mean.
+     WARNING: This may effect your results, so don't wonder...
+
+   - First implementation of an algorithm using only triggered events
+     for the collection area calculation
+
+   - Ascii Output can now also be used for parameter containers which
+     doesn't overload MParCointainer::AsciiWrite
+
+   - The Ascii Output is now also capable of writing single data members
+     of one container
+
+   - You are now able to change the order of the values written to the
+     ascii file
+
+   - You can now specify a conversion factor for each data member written
+     to an ascii file. This may be usefull to change the units of the 
+     data member (eg. degrees instead of millimeters in case of the 
+     hillas parameters)
+
+   - Replaced old MHillas by a new structure which allows you to extend
+     the parameters stored in MHillas very easily:
+     see MHillas and MHillasExt
+
+   - Added classes to handle source dependancy of image parameters:
+     see MHillasSrc
+
+   - Added container (MBinning) to have a standard input for the binning
+     in different histograms (eg. the Energy bins should be the same in
+     all histograms)
+
+   - Changed Hillas histograms from mm to deg
+
+   - Added the flexible binning to the hillas histograms
+
+   - Added a filter for the alpha parameter (MFAlpha)
+
+   - It is now possible to write single data members of a class object to
+     an output stream instead of the whole container only
+
+   - Added a generalized filter for a data member:
+     MFDataMember filter("MHillas.fWidth", '<', 0.5);
+
+   - Added a generalized Filter parser for more difficult filter rules
+     MF filter("MHillas.fWidth<0.5 && MHillas.fLength>0.5");
+
+   - Added new Monte Carlo histograms:
+     MHMcEnergyImpact and MHMcEfficiency
+
+   - Added many new histograms needed for the flux calculation.
+
+   - Added a generalized histograms which can fill and show up to three
+     data members in either a one-, two- or three-dimensional histogram, eg:
+     MH3 mh3("MHillas.fWidth", "MHillas.fLength");
+
+   - Added:
+       * calculation of <Theta> as a function of Theta (MHThetabarTheta)
+       * calculation of <Theta> as a function of time (MHThetabarTime)
+     they are needed in the flux calculation in 
+     order to select for a given bin in Theta (or time) the appropriate 
+     effective collection area, which is assumed to be given as a function 
+     of Theta and the true energy
+
+   - Added calculation of the migration matrix in the energy 
+     (MHMcEnergyMigration):
+     the migration matrix describes the migration from the true (E_true)
+     to the estimated energy (E_est); it is needed to determine the
+     distribution of E_true from the measured distribution of E_est 
+     by unfolding
+
+   - changed the color palette in the camera display to DeapSea.
+
+
+
+ *** Version 0.6 (2002/01/15)
+
+   - Introduce the option of disable pixels (MBlindPixels and
+     MBlindPixelCalc) for the analysis (eg MHillasCalc) to be 
+     able to deal with Star Field NSB.
+
+   - Fixed a bug in the pedestals substraction
+
+   - Introduced verbosity levels
+
+   - Introduced a task (MReadMarsFile) which reads the RunHeader tree, too.
+
+   - Fixed several bugs in MFTriggerLvl1 which caused to filter not to
+     work correctly (thanks to Abelardo)
+
+   - Introduced correct treatment of the diffuse Night Sky Background 
+     and NSB (MMcPedestalNSB)
+
+   - Corrected treatment of the electronic noise (MMcPedestalCopy)
+
+   - Introduced MMcRunHeaders which contains monte carlo run informations
+
+   - Added a 'Print'-Task (MPrint) which calls the Print function
+     of a parameter container for each event
+
+   - Removed MHtml (was replaced by THtml of root 3.02) in dohtml.C
+
+   - changes to be more efficient with root 3.02/06
+
+   - root 3.02/06 fixes:
+     + the memory leak when reading MRawEvtData
+     + loosing more time than necessary to update the progress bar
+
+   - MWriteAsciiFile is now capable of writing more than one container
+     in a line. For example: To be able to write Monte Carlo and 
+     Hillas values (energy and alpha) in one line.
+
+
+
+ *** Version 0.5 (2001/11/06)
+
+   - Added new GUI functionality (Analysis)
+
+   - Added a camera display to be able to display events in the camera
+     together with the calculated hillas ellipse
+
+   - Added a 'Clone'-Task (MClone) which can clone a parameter container
+     object at any state of the analysis, so that the output are several
+     states
+
+   - Fixed a bug in the collection area error calculation 
+     (Thanks to Ciro and Abelardo)
+
+   - Fixed a bug which causes merpp to crash in some environments
+
+   - Implemented auto enabling scheme for Branches to speed up reading
+     a lot (see MReadTree and MTask)
+
+   - Fixed a bug in the Histogram classes which caused histograms to
+     be written to a file by MWriteRootFile without request
+
+   - changed the object I/O from the old stylish root I/O to the new
+     'auto evolution scheme' This was done only for classes which are not
+     yet used in Monte Carlo files, so that these files are still readable.
+
+   - Added support for a progress bar in MEvtLoop and MReadTree 
+     (see the Analysis Window in Mars for an example)
+
+   - Fixed a bug in the package creation which disturbed the conversion
+     between a mars version unpacked from a tar file and the repository.
+
+   - Changed the code to writer merpped (converted into root format)
+     raw files, to get faster (around 10%)
+
+
+
+ *** Version 0.4 (2001/09/20)
+
+    - This release is made to compile on a root version >= 3.00
+
+    - Fixed a bug which causes MReadTree to read the first file only
+
+    - Added a task to compute the trigger rate (MMcTriggerRateCalc)
+ 
+    - Added a task to write a container to an Ascii file (MWriteAsciiFile)
+
+    - Added a task to write several container to a root file (MWriteRootFile)
+    
+    - Added calculation of the Enegry Threshold (MMcThresholdCalc)
+    
+    - Added calculation of the collection area (MMcCollectionAreaCalc)
+    
+    - fixed some bugs in the Hillas calculation
+    
+    - added filters to be able to control the task execution dependent on
+      a parameter (for example: the number of level 1 triggers in a MC-file)
+
+
+
+ *** Version 0.3 (2001/04/23)
+	
+    - Many demo macros added    
+  
+    - MCT1ReadAscii is now able to handle more than one file (s. ::AddFile)
+    
+    - Hillas Calculation added
+    
+    - Standard image cleaning available
+    
+    - MReadTree is now able to handle more than one file
+      (Remark: of the same structure)
+    
+    - Now we are able to display events in a first version of the
+      Camera event display. To do this we must run the macro 
+      "macros/readCT1.C" to read data from CT1. 
+
+
+
+ *** Version 0.2 (2001/01/24)
+ 
+    - First Implementation of a Gui to read the raw data. Start the
+      gui with the command mars. 
+
+
+
+ *** Version 0.1 (2000/12/20)
+ 
+    - First official release 0.1
+    
+    - Changes:
+    
+       + changed calling style of MRawPixelIterator from do...while to 
+         while-loop
+
Index: /tags/Mars_V0-8-5/Mars/lib/lib.txt
===================================================================
--- /tags/Mars_V0-8-5/Mars/lib/lib.txt	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/lib/lib.txt	(revision 9661)
@@ -0,0 +1,1 @@
+Directory for libraries while compiling
Index: /tags/Mars_V0-8-5/Mars/macros/CCDataCheck.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/CCDataCheck.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/CCDataCheck.C	(revision 9661)
@@ -0,0 +1,1454 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Raquel de los Reyes, 02/2004 <mailto:reyes@gae.ucm.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== *//////////////////////////////////////////////////////////////////////////////
+//
+// This macro made the check of the central control files (.rep files).
+// It displays 9 tabs:
+//   - Drive system
+//   - Camera status
+//   - HV of power supplies and HV settings
+//   - DC of power supplies 
+//   - LV power supplies
+//   - Cooling system
+//   - Trigger system
+//   - Trigger macrocells
+//   - Weather station
+//
+////////////////////////////////////////////////////////////////////////////
+
+void CCDataCheck(const TString filename="CC_2004_04_28.root", const TString directory="/home/raquel/")
+{
+
+  //
+  // If you want to run the macro in batch mode, set batchmode to kTRUE
+  //
+  Bool_t batchmode = kFALSE;
+
+  if(!batchmode)
+    {
+      MStatusDisplay *d = new MStatusDisplay;
+      d->SetTitle(filename);
+      d->SetLogStream(&gLog, kTRUE);            // Disables output to stdout
+    }
+
+  //
+  // Create a empty Parameter List and an empty Task List
+  // The tasklist is identified in the eventloop by its name
+  //
+  MParList  plist;
+  
+  MTaskList tlist;
+  plist.AddToList(&tlist);
+
+  //
+  // Now setup the tasks and tasklist:
+  // ---------------------------------
+  //
+
+  // Set all the MHVsTime classes:
+  // Drive system
+  MHVsTime hZd("MReportDrive.fNominalZd");
+  hZd.SetName("Zd");
+  MHVsTime hAz("MReportDrive.fNominalAz");
+  hAz.SetName("Az");
+  MHVsTime hDState("MReportDrive.fState");
+  hDState.SetName("State");
+  // HV power supplies
+  MHVsTime hHVA("MCameraHV.fVoltageA");
+  hHVA.SetName("HVA");
+  MHVsTime hHVB("MCameraHV.fVoltageB");
+  hHVB.SetName("HVB");
+  MHVsTime hCA("MCameraHV.fCurrentA");
+  hCA.SetName("CA");
+  MHVsTime hCB("MCameraHV.fCurrentB");
+  hCB.SetName("CB");
+  // LV power supplies
+  MHVsTime hLVTemp("MCameraLV.fTemp");
+  hLVTemp.SetName("LVTemp");
+  MHVsTime hLVHum("MCameraLV.fHumidity");
+  hLVHum.SetName("LVHum");
+  MHVsTime hLVStatus("MCameraHV.fStatus");
+  hLVStatus.SetName("LVStatus");
+  MHVsTime hLVRPS("MCameraLV.fRequestPowerSupply");
+  hLVRPS.SetName("LVRPS");
+  // Cooling system
+  MHVsTime hTCenter("MCameraCooling.fTempCenter");
+  hTCenter.SetName("TCenter");
+  MHVsTime hTWall("MCameraCooling.fTempWall");
+  hTWall.SetName("TWall");
+  MHVsTime hTWater("MCameraCooling.fTempWater");
+  hTWater.SetName("TWater");
+  MHVsTime hTOptLink("MCameraCooling.fTempOptLink");
+  hTOptLink.SetName("TOptLink");
+  MHVsTime hHWall("MCameraCooling.fHumWall");
+  hHWall.SetName("HWall");
+  MHVsTime hHCenter("MCameraCooling.fHumCenter");
+  hHCenter.SetName("HCenter");
+  // Weather station
+  MHVsTime hCCHum("MReportCC.fHumidity");
+  hCCHum.SetName("CCHum");
+  MHVsTime hCCTemp("MReportCC.fTemperature");
+  hCCTemp.SetName("CCTemp");
+  MHVsTime hCCWS("MReportCC.fWindSpeed");
+  hCCWS.SetName("CCWS");
+  MHVsTime hCCSR("MReportCC.fSolarRadiation");
+  hCCSR.SetName("CCSR");
+  // Trigger system
+  MHVsTime hTrigBL2("MReportTrigger.fL2BeforePrescaler");
+  hTrigBL2.SetName("TrigBL2");
+  MHVsTime hTrigAL2("MReportTrigger.fL2AfterPrescaler");
+  hTrigAL2.SetName("TrigAL2");
+  MHVsTime hTrigStatus("MReportTrigger.fState");
+  hTrigStatus.SetName("TrigStatus");
+  // Camera status
+  MHVsTime hCamStatus("MReportCamera.fState");
+  hCamStatus.SetName("CamStatus");
+  MHVsTime hCamSentStatus("MReportCamera.fStatus");
+  hCamSentStatus.SetName("CamSentStatus");
+  MHVsTime hCamStatusDC("MReportCamera.fStatusDC");
+  hCamStatusDC.SetName("CamDCStatus");
+  MHVsTime hHVStatus("MCameraHV.fStatus");
+  hHVStatus.SetName("HVStatus");
+  MHVsTime hLidsStatus("MCameraLids.fStatus");
+  hLidsStatus.SetName("LidsStatus");
+  MHVsTime hCoolStatus("MCameraCooling.fStatus");
+  hCoolStatus.SetName("CoolingStatus");
+  MHVsTime hCamMean("MCameraHV.fMean");
+  hCamMean.SetName("CameraMean");
+
+  // Reads the trees of the root file and the analysed branches
+  MReadReports read;
+  read.AddTree("Drive");
+  read.AddTree("Camera");
+  read.AddTree("CC");
+  read.AddTree("Trigger");
+  read.AddFile(directory+filename);     // after the reading of the trees!!!
+  read.AddToBranchList("MReportDrive.*");
+  read.AddToBranchList("MCameraHV.*");
+  read.AddToBranchList("MCameraLV.*");
+  read.AddToBranchList("MCameraCooling.*");
+  read.AddToBranchList("MReportCC.*");
+  read.AddToBranchList("MReportTrigger.*");
+  read.AddToBranchList("MReportCamera.*");
+  read.AddToBranchList("MCameraLids.*");
+
+  MGeomApply geomapl;
+  tlist.AddToList(&geomapl);
+
+  // Set of MHCamEvents classes
+  MHCamEvent HVdisplay("CamHV","Camera mean HV settings");
+  HVdisplay.SetBit(MHCamera::kVariance);
+  plist.AddToList(&HVdisplay);
+
+  // Set of MHPixVsTime classes (Trigger macroscells)
+  MHPixVsTime htrigmc1(0,"TrigMacrocell1");
+  htrigmc1.SetNameTime("MTimeTrigger");
+  plist.AddToList(&htrigmc1);
+  MHPixVsTime htrigmc2(1,"TrigMacrocell2");
+  htrigmc2.SetNameTime("MTimeTrigger");
+  plist.AddToList(&htrigmc2);
+  MHPixVsTime htrigmc3(2,"TrigMacrocell3");
+  htrigmc3.SetNameTime("MTimeTrigger");
+  plist.AddToList(&htrigmc3);
+  MHPixVsTime htrigmc4(3,"TrigMacrocell4");
+  htrigmc4.SetNameTime("MTimeTrigger");
+  plist.AddToList(&htrigmc4);
+  MHPixVsTime htrigmc5(4,"TrigMacrocell5");
+  htrigmc5.SetNameTime("MTimeTrigger");
+  plist.AddToList(&htrigmc5);
+  MHPixVsTime htrigmc6(5,"TrigMacrocell6");
+  htrigmc6.SetNameTime("MTimeTrigger");
+  plist.AddToList(&htrigmc6);
+  MHPixVsTime htrigmc7(6,"TrigMacrocell7");
+  htrigmc7.SetNameTime("MTimeTrigger");
+  plist.AddToList(&htrigmc7);
+  MHPixVsTime htrigmc8(7,"TrigMacrocell8");
+  htrigmc8.SetNameTime("MTimeTrigger");
+  plist.AddToList(&htrigmc8);
+  MHPixVsTime htrigmc9(8,"TrigMacrocell9");
+  htrigmc9.SetNameTime("MTimeTrigger");
+  plist.AddToList(&htrigmc9);
+  MHPixVsTime htrigmc10(9,"TrigMacrocell10");
+  htrigmc10.SetNameTime("MTimeTrigger");
+  plist.AddToList(&htrigmc10);
+  MHPixVsTime htrigmc11(10,"TrigMacrocell11");
+  htrigmc11.SetNameTime("MTimeTrigger");
+  plist.AddToList(&htrigmc11);
+  MHPixVsTime htrigmc12(11,"TrigMacrocell12");
+  htrigmc12.SetNameTime("MTimeTrigger");
+  plist.AddToList(&htrigmc12);
+  MHPixVsTime htrigmc13(12,"TrigMacrocell13");
+  htrigmc13.SetNameTime("MTimeTrigger");
+  plist.AddToList(&htrigmc13);
+  MHPixVsTime htrigmc14(13,"TrigMacrocell14");
+  htrigmc14.SetNameTime("MTimeTrigger");
+  plist.AddToList(&htrigmc14);
+  MHPixVsTime htrigmc15(14,"TrigMacrocell15");
+  htrigmc15.SetNameTime("MTimeTrigger");
+  plist.AddToList(&htrigmc15);
+  MHPixVsTime htrigmc16(15,"TrigMacrocell16");
+  htrigmc16.SetNameTime("MTimeTrigger");
+  plist.AddToList(&htrigmc16);
+  MHPixVsTime htrigmc17(16,"TrigMacrocell17");
+  htrigmc17.SetNameTime("MTimeTrigger");
+  plist.AddToList(&htrigmc17);
+  MHPixVsTime htrigmc18(17,"TrigMacrocell18");
+  htrigmc18.SetNameTime("MTimeTrigger");
+  plist.AddToList(&htrigmc18);
+  MHPixVsTime htrigmc19(18,"TrigMacrocell19");
+  htrigmc19.SetNameTime("MTimeTrigger");
+  plist.AddToList(&htrigmc19);
+
+  // Set of MH3 classes
+  MH3 hError("MReportDrive.GetAbsError*60");
+  hError.SetName("DeltaH");
+  MBinning bins("BinningDeltaH");
+  bins.SetEdges(18, 0, 3.6);
+  plist.AddToList(&bins);
+  MH3 hError2("MReportDrive.fNominalZd","MReportDrive.GetAbsError*60");
+  hError2.SetName("DeltaHvsZd");
+  MBinning bins2("BinningDeltaHvsZdX");
+  MBinning bins3("BinningDeltaHvsZdY");
+  bins2.SetEdges(90, 0, 90);
+  bins3.SetEdges(18, 0, 3.6);
+  plist.AddToList(&bins2);
+  plist.AddToList(&bins3);
+  MH3 hTempOptLink("MCameraCooling.fTempOptLink");
+  hTempOptLink.SetName("TOptLink");
+  MBinning bins4("BinningTOptLinkX");
+  bins4.SetEdges(50, 0, 50);
+  plist.AddToList(&bins4);
+  MH3 hTrigZd("MReportDrive.fNominalZd","MReportTrigger.fL2AfterPrescaler");
+  hTrigZd.SetName("TrigZd");
+  MBinning bins5("BinningTrigZdX");
+  bins5.SetEdges(90, 0, 90);
+  plist.AddToList(&bins5);
+  MBinning bins6("BinningTrigZdY");
+  bins6.SetEdges(10000, 0, 15000);
+  plist.AddToList(&bins6);
+
+
+  // Fill all the MH classes defined before
+  MFillH fillZd(&hZd,             "MTimeDrive");
+  MFillH fillAz(&hAz,             "MTimeDrive");
+  MFillH fillError(&hError);
+  MFillH fillDState(&hDState,     "MTimeDrive");
+  MFillH fillError2(&hError2);
+  MFillH fillHVA(&hHVA,           "MTimeCamera");
+  MFillH fillHVB(&hHVB,           "MTimeCamera");
+  MFillH fillCA(&hCA,             "MTimeCamera");
+  MFillH fillCB(&hCB,             "MTimeCamera");
+  MFillH fillLVTemp(&hLVTemp,     "MTimeCamera");
+  MFillH fillLVHum(&hLVHum,       "MTimeCamera");
+  MFillH fillLVStatus(&hLVStatus, "MTimeCamera");
+  MFillH fillLVRPS(&hLVRPS,       "MTimeCamera");
+  MFillH fillTCenter(&hTCenter,   "MTimeCamera");
+  MFillH fillTWall(&hTWall,       "MTimeCamera");
+  MFillH fillTWater(&hTWater,     "MTimeCamera");
+  MFillH fillTOptLink(&hTOptLink, "MTimeCamera");
+  MFillH fillTempOptLink(&hTempOptLink);
+  MFillH fillHWall(&hHWall,       "MTimeCamera");
+  MFillH fillHCenter(&hHCenter,   "MTimeCamera");
+  MFillH fillCCHum(&hCCHum,       "MTimeCC");
+  MFillH fillCCTemp(&hCCTemp,     "MTimeCC");
+  MFillH fillCCWS(&hCCWS,         "MTimeCC");
+  MFillH fillCCSR(&hCCSR,         "MTimeCC");
+  MFillH fillTrigBL2(&hTrigBL2,   "MTimeTrigger");
+  MFillH fillTrigAL2(&hTrigAL2,   "MTimeTrigger");
+  MFillH fillTrigStatus(&hTrigStatus,   "MTimeTrigger");
+  MFillH fillTrigZd(&hTrigZd);
+  MFillH fillCamStatus(&hCamStatus,"MTimeCamera");
+  MFillH fillCamSentStatus(&hCamSentStatus,"MTimeCamera");
+  MFillH fillCamStatusDC(&hCamStatusDC, "MTimeCamera");
+  MFillH fillHVStatus(&hHVStatus, "MTimeCamera");
+  MFillH fillLidsStatus(&hLidsStatus, "MTimeCamera");
+  MFillH fillCoolStatus(&hCoolStatus, "MTimeCamera");
+  MFillH filltrigmc1("TrigMacrocell1","MReportTrigger");
+  MFillH filltrigmc2("TrigMacrocell2","MReportTrigger");
+  MFillH filltrigmc3("TrigMacrocell3","MReportTrigger");
+  MFillH filltrigmc4("TrigMacrocell4","MReportTrigger");
+  MFillH filltrigmc5("TrigMacrocell5","MReportTrigger");
+  MFillH filltrigmc6("TrigMacrocell6","MReportTrigger");
+  MFillH filltrigmc7("TrigMacrocell7","MReportTrigger");
+  MFillH filltrigmc8("TrigMacrocell8","MReportTrigger");
+  MFillH filltrigmc9("TrigMacrocell9","MReportTrigger");
+  MFillH filltrigmc10("TrigMacrocell10","MReportTrigger");
+  MFillH filltrigmc11("TrigMacrocell11","MReportTrigger");
+  MFillH filltrigmc12("TrigMacrocell12","MReportTrigger");
+  MFillH filltrigmc13("TrigMacrocell13","MReportTrigger");
+  MFillH filltrigmc14("TrigMacrocell14","MReportTrigger");
+  MFillH filltrigmc15("TrigMacrocell15","MReportTrigger");
+  MFillH filltrigmc16("TrigMacrocell16","MReportTrigger");
+  MFillH filltrigmc17("TrigMacrocell17","MReportTrigger");
+  MFillH filltrigmc18("TrigMacrocell18","MReportTrigger");
+  MFillH filltrigmc19("TrigMacrocell19","MReportTrigger");
+  MFillH fillcammean(&hCamMean,"MTimeCamera");
+  MFillH fillHVD(&HVdisplay,"MCameraHV");
+
+  // Do not display the result given by the default draw function
+  fillZd.SetBit(MFillH::kDoNotDisplay);
+  fillAz.SetBit(MFillH::kDoNotDisplay);
+  fillError.SetBit(MFillH::kDoNotDisplay);
+  fillDState.SetBit(MFillH::kDoNotDisplay);
+  fillError2.SetBit(MFillH::kDoNotDisplay);
+  fillHVA.SetBit(MFillH::kDoNotDisplay);
+  fillHVB.SetBit(MFillH::kDoNotDisplay);
+  fillCA.SetBit(MFillH::kDoNotDisplay);
+  fillCB.SetBit(MFillH::kDoNotDisplay);
+  fillLVTemp.SetBit(MFillH::kDoNotDisplay);
+  fillLVHum.SetBit(MFillH::kDoNotDisplay);
+  fillLVStatus.SetBit(MFillH::kDoNotDisplay);
+  fillLVRPS.SetBit(MFillH::kDoNotDisplay);
+  fillTCenter.SetBit(MFillH::kDoNotDisplay);
+  fillTWall.SetBit(MFillH::kDoNotDisplay);
+  fillTWater.SetBit(MFillH::kDoNotDisplay);
+  fillTOptLink.SetBit(MFillH::kDoNotDisplay);
+  fillTempOptLink.SetBit(MFillH::kDoNotDisplay);
+  fillHWall.SetBit(MFillH::kDoNotDisplay);
+  fillHCenter.SetBit(MFillH::kDoNotDisplay);
+  fillCCHum.SetBit(MFillH::kDoNotDisplay);
+  fillCCTemp.SetBit(MFillH::kDoNotDisplay);
+  fillCCWS.SetBit(MFillH::kDoNotDisplay);
+  fillCCSR.SetBit(MFillH::kDoNotDisplay);
+  fillTrigBL2.SetBit(MFillH::kDoNotDisplay);
+  fillTrigAL2.SetBit(MFillH::kDoNotDisplay);
+  fillTrigStatus.SetBit(MFillH::kDoNotDisplay);
+  fillTrigZd.SetBit(MFillH::kDoNotDisplay);
+  fillCamStatus.SetBit(MFillH::kDoNotDisplay);
+  fillCamSentStatus.SetBit(MFillH::kDoNotDisplay);
+  fillCamStatusDC.SetBit(MFillH::kDoNotDisplay);
+  fillHVStatus.SetBit(MFillH::kDoNotDisplay);
+  fillLidsStatus.SetBit(MFillH::kDoNotDisplay);
+  fillCoolStatus.SetBit(MFillH::kDoNotDisplay);
+  filltrigmc1.SetBit(MFillH::kDoNotDisplay);
+  filltrigmc2.SetBit(MFillH::kDoNotDisplay);
+  filltrigmc3.SetBit(MFillH::kDoNotDisplay);
+  filltrigmc4.SetBit(MFillH::kDoNotDisplay);
+  filltrigmc5.SetBit(MFillH::kDoNotDisplay);
+  filltrigmc6.SetBit(MFillH::kDoNotDisplay);
+  filltrigmc7.SetBit(MFillH::kDoNotDisplay);
+  filltrigmc8.SetBit(MFillH::kDoNotDisplay);
+  filltrigmc9.SetBit(MFillH::kDoNotDisplay);
+  filltrigmc10.SetBit(MFillH::kDoNotDisplay);
+  filltrigmc11.SetBit(MFillH::kDoNotDisplay);
+  filltrigmc12.SetBit(MFillH::kDoNotDisplay);
+  filltrigmc13.SetBit(MFillH::kDoNotDisplay);
+  filltrigmc14.SetBit(MFillH::kDoNotDisplay);
+  filltrigmc15.SetBit(MFillH::kDoNotDisplay);
+  filltrigmc16.SetBit(MFillH::kDoNotDisplay);
+  filltrigmc17.SetBit(MFillH::kDoNotDisplay);
+  filltrigmc18.SetBit(MFillH::kDoNotDisplay);
+  filltrigmc19.SetBit(MFillH::kDoNotDisplay);
+  fillcammean.SetBit(MFillH::kDoNotDisplay);
+  fillHVD.SetBit(MFillH::kDoNotDisplay);
+
+  // Skip the fill function is there is no tree entries
+  fillZd.SetBit(MFillH::kCanSkip);
+  fillAz.SetBit(MFillH::kCanSkip);
+  fillError.SetBit(MFillH::kCanSkip);
+  fillDState.SetBit(MFillH::kCanSkip);
+  fillError2.SetBit(MFillH::kCanSkip);
+  fillHVA.SetBit(MFillH::kCanSkip);
+  fillHVB.SetBit(MFillH::kCanSkip);
+  fillCA.SetBit(MFillH::kCanSkip);
+  fillCB.SetBit(MFillH::kCanSkip);
+  fillLVTemp.SetBit(MFillH::kCanSkip);
+  fillLVHum.SetBit(MFillH::kCanSkip);
+  fillLVStatus.SetBit(MFillH::kCanSkip);
+  fillLVRPS.SetBit(MFillH::kCanSkip);
+  fillTCenter.SetBit(MFillH::kCanSkip);
+  fillTWall.SetBit(MFillH::kCanSkip);
+  fillTWater.SetBit(MFillH::kCanSkip);
+  fillTOptLink.SetBit(MFillH::kCanSkip);
+  fillTempOptLink.SetBit(MFillH::kCanSkip);
+  fillHWall.SetBit(MFillH::kCanSkip);
+  fillHCenter.SetBit(MFillH::kCanSkip);
+  fillCCHum.SetBit(MFillH::kCanSkip);
+  fillCCTemp.SetBit(MFillH::kCanSkip);
+  fillCCWS.SetBit(MFillH::kCanSkip);
+  fillCCSR.SetBit(MFillH::kCanSkip);
+  fillTrigBL2.SetBit(MFillH::kCanSkip);
+  fillTrigAL2.SetBit(MFillH::kCanSkip);
+  fillTrigStatus.SetBit(MFillH::kCanSkip);
+  fillTrigZd.SetBit(MFillH::kCanSkip);
+  fillCamStatus.SetBit(MFillH::kCanSkip);
+  fillCamSentStatus.SetBit(MFillH::kCanSkip);
+  fillCamStatusDC.SetBit(MFillH::kCanSkip);
+  fillHVStatus.SetBit(MFillH::kCanSkip);
+  fillLidsStatus.SetBit(MFillH::kCanSkip);
+  fillCoolStatus.SetBit(MFillH::kCanSkip);
+  filltrigmc1.SetBit(MFillH::kCanSkip);
+  filltrigmc2.SetBit(MFillH::kCanSkip);
+  filltrigmc3.SetBit(MFillH::kCanSkip);
+  filltrigmc4.SetBit(MFillH::kCanSkip);
+  filltrigmc5.SetBit(MFillH::kCanSkip);
+  filltrigmc6.SetBit(MFillH::kCanSkip);
+  filltrigmc7.SetBit(MFillH::kCanSkip);
+  filltrigmc8.SetBit(MFillH::kCanSkip);
+  filltrigmc9.SetBit(MFillH::kCanSkip);
+  filltrigmc10.SetBit(MFillH::kCanSkip);
+  filltrigmc11.SetBit(MFillH::kCanSkip);
+  filltrigmc12.SetBit(MFillH::kCanSkip);
+  filltrigmc13.SetBit(MFillH::kCanSkip);
+  filltrigmc14.SetBit(MFillH::kCanSkip);
+  filltrigmc15.SetBit(MFillH::kCanSkip);
+  filltrigmc16.SetBit(MFillH::kCanSkip);
+  filltrigmc17.SetBit(MFillH::kCanSkip);
+  filltrigmc18.SetBit(MFillH::kCanSkip);
+  filltrigmc19.SetBit(MFillH::kCanSkip);
+  fillcammean.SetBit(MFillH::kCanSkip);
+  fillHVD.SetBit(MFillH::kCanSkip);
+
+  // Add all the task to the task list
+  tlist.AddToList(&read);
+  tlist.AddToList(&fillZd,       "Drive");
+  tlist.AddToList(&fillAz,       "Drive");
+  tlist.AddToList(&fillError,    "Drive");
+  tlist.AddToList(&fillDState,   "Drive");
+  tlist.AddToList(&fillError2,   "Drive");
+  tlist.AddToList(&fillHVA,      "Camera");
+  tlist.AddToList(&fillHVB,      "Camera");
+  tlist.AddToList(&fillCA,       "Camera");
+  tlist.AddToList(&fillCB,       "Camera");
+  tlist.AddToList(&fillLVTemp,   "Camera");
+  tlist.AddToList(&fillLVHum,    "Camera");
+  tlist.AddToList(&fillLVStatus, "Camera");
+  tlist.AddToList(&fillLVRPS,    "Camera");
+  tlist.AddToList(&fillTCenter,  "Camera");
+  tlist.AddToList(&fillTWall,    "Camera");
+  tlist.AddToList(&fillTWater,   "Camera");
+  tlist.AddToList(&fillTOptLink, "Camera");
+  tlist.AddToList(&fillTempOptLink, "Camera");
+  tlist.AddToList(&fillHWall,    "Camera");
+  tlist.AddToList(&fillHCenter,  "Camera");
+  tlist.AddToList(&fillCCHum,    "CC");
+  tlist.AddToList(&fillCCTemp,   "CC");
+  tlist.AddToList(&fillCCWS,     "CC");
+  tlist.AddToList(&fillCCSR,     "CC");
+  tlist.AddToList(&fillTrigBL2,  "Trigger");
+  tlist.AddToList(&fillTrigAL2,  "Trigger");
+  tlist.AddToList(&fillTrigStatus,  "Trigger");
+  tlist.AddToList(&fillTrigZd);
+  tlist.AddToList(&fillCamStatus,  "Camera");
+  tlist.AddToList(&fillCamSentStatus,  "Camera");
+  tlist.AddToList(&fillCamStatusDC,"Camera");
+  tlist.AddToList(&fillHVStatus,"Camera");
+  tlist.AddToList(&fillLidsStatus,"Camera");
+  tlist.AddToList(&fillCoolStatus,"Camera");
+  tlist.AddToList(&filltrigmc1, "Trigger");
+  tlist.AddToList(&filltrigmc2, "Trigger");
+  tlist.AddToList(&filltrigmc3, "Trigger");
+  tlist.AddToList(&filltrigmc4, "Trigger");
+  tlist.AddToList(&filltrigmc5, "Trigger");
+  tlist.AddToList(&filltrigmc6, "Trigger");
+  tlist.AddToList(&filltrigmc7, "Trigger");
+  tlist.AddToList(&filltrigmc8, "Trigger");
+  tlist.AddToList(&filltrigmc9, "Trigger");
+  tlist.AddToList(&filltrigmc10, "Trigger");
+  tlist.AddToList(&filltrigmc11, "Trigger");
+  tlist.AddToList(&filltrigmc12, "Trigger");
+  tlist.AddToList(&filltrigmc13, "Trigger");
+  tlist.AddToList(&filltrigmc14, "Trigger");
+  tlist.AddToList(&filltrigmc15, "Trigger");
+  tlist.AddToList(&filltrigmc16, "Trigger");
+  tlist.AddToList(&filltrigmc17, "Trigger");
+  tlist.AddToList(&filltrigmc18, "Trigger");
+  tlist.AddToList(&filltrigmc19, "Trigger");
+  tlist.AddToList(&fillcammean, "Camera");
+  tlist.AddToList(&fillHVD);
+
+  //
+  // Create and setup the eventloop
+  //
+  MEvtLoop evtloop;
+  evtloop.SetParList(&plist);
+  if(!batchmode)
+    evtloop.SetDisplay(d);
+    
+  //
+  // Execute your analysis
+  //
+  if (!evtloop.Eventloop())
+    return;
+ 
+  tlist.PrintStatistics();
+
+  gStyle->SetPadGridX(kTRUE);
+  gStyle->SetPadGridY(kTRUE);
+  gStyle->SetCanvasColor(kWhite);
+  MHVsTime *clone1;
+  TGraph *g;
+  TH1 *hist;
+  TH1 *hist2;
+  TAxis *axey;
+  TAxis *axex;
+  MH3 *mh3;
+  MHPixVsTime *pixclone1;
+  MHCamera *Sum;
+  //
+  // Drive report (pointing.C from T. Bretz)
+  //
+  if ((d = evtloop.GetDisplay()))
+    TCanvas &c1 = d.AddTab("DRIVE SYSTEM");
+  else
+    TCanvas *c1 = new TCanvas();
+  // ************* Plot the telescope tracking positions on the sky ***********
+  TGraph *g1 = hZd.GetGraph();
+  TGraph *g2 = hAz.GetGraph();
+  TPad *p = new TPad("", "",0,0.05,0.6,0.95);
+  p->Draw();
+  p->cd();
+  gPad->SetTheta(-90);
+  gPad->SetPhi(90);
+  gPad->SetBorderMode(0);
+  gStyle->SetOptStat(0);
+  TH2F h("pol", "Telescope Tracking Positions on the Sky", 16, 0, 1, 9, 0, 1);
+  h.DrawClone("surf1pol");
+  gPad->Modified();
+  gPad->Update();
+  TView *view = gPad->GetView();
+  if (!view)
+    {
+      cout << "No View!" << endl;
+      return;
+    }
+  Double_t *zd=g1->GetY();
+  Double_t *az=g2->GetY();
+  Double_t old[2] = {0,0};
+  for (int i=0; i<g1->GetN(); i++)
+    {
+      az[i] += 180;
+      az[i] *= TMath::Pi()/180;
+      Double_t x[3] = { zd[i]*cos(az[i])/90, zd[i]*sin(az[i])/90, 0};
+      Double_t y[3];
+      view->WCtoNDC(x, y);
+      if (old[0]!=0 && old[1]!=1)
+        {
+	  TLine *l = new TLine(y[0], y[1], old[0], old[1]);
+	  l->SetLineColor(kBlue);
+	  l->Draw();
+        }
+      TMarker *m = new TMarker(y[0], y[1], kFullDotMedium);
+      m->SetMarkerColor(i==g1->GetN()-1 ? kGreen : kRed);
+      m->Draw();
+      old[0] = y[0];
+      old[1] = y[1];
+    }
+  // ---------------------- Control deviation of the motors -------------------
+  c1->cd();
+  p = new TPad("", "", 0.6, 0, 1, 0.29);
+  p->Draw();
+  p->cd();
+  gStyle->SetOptStat(1110);
+  gStyle->SetStatFormat(".2g");
+  mh3 = (MH3*)hError.DrawClone("nonew");
+  mh3->GetHist()->SetXTitle("\\Delta [arcmin]");
+  mh3->GetHist()->SetYTitle("");
+  mh3->GetHist()->SetTitle("Control deviation of the motors");
+  mh3->GetHist()->SetStats(1);
+  mh3->GetHist()->SetLabelSize(0.06,"X");
+  mh3->GetHist()->SetLabelSize(0.06,"Y");
+  mh3->GetHist()->SetTitleSize(0.06,"X");
+  TLine ln;
+  ln.SetLineColor(kGreen);
+  ln.DrawLine(0.5*360*60/16384., 0, 0.5*360*60/16384., hError.GetHist()->GetMaximum());
+  ln.SetLineColor(kYellow);
+  ln.DrawLine(1.0*360*60/16384., 0, 1.0*360*60/16384., hError.GetHist()->GetMaximum());
+  ln.SetLineColor(kRed);
+  ln.DrawLine(2.0*360*60/16384., 0, 2.0*360*60/16384., hError.GetHist()->GetMaximum());
+  // ---------------------- Plot the drive status vs time ---------------------
+  c1->cd();
+  p = new TPad("", "", 0.6, 0.29, 1, 0.42);
+  p->Draw();
+  p->cd();
+  MHVsTime *hvt = (MHVsTime*)hDState.DrawClone("nonew");
+  hvt->GetGraph()->SetMarkerStyle(kFullDotSmall);
+  if (hvt->GetGraph()->GetN())
+    {
+      hist = hvt->GetGraph()->GetHistogram();
+      TAxis *axey = hist->GetYaxis();
+      TAxis *axex = hist->GetXaxis();
+      hist->GetXaxis()->SetTimeFormat("%H:%M %F1995-01-01 00:00:00");
+      hist->SetXTitle("Time");
+      hist->SetYTitle("");
+      hist->SetTitle("");
+      hist->SetLabelSize(0.1,"X");
+      hist->SetTitleSize(0.06,"X");
+      hist->SetStats(0);
+      hist->SetMinimum(-0.5);
+      hist->SetMaximum(4.5);
+      axey->Set(5, -0.5, 4.5);
+      axey->SetBinLabel(axey->FindFixBin(0), "Error");
+      axey->SetBinLabel(axey->FindFixBin(1), "Stopped");
+      axey->SetBinLabel(axey->FindFixBin(3), "Moving");
+      axey->SetBinLabel(axey->FindFixBin(4), "Tracking");
+      axey->SetLabelSize(0.15);
+      axex->SetLabelSize(0.08);
+      axex->SetTitleSize(0.09);
+      axex->SetTitleOffset(0.45);
+    }  
+  // --------------- Control deviation of the motors vs zenith angle ----------
+  c1->cd();
+  p = new TPad("", "", 0.6, 0.71, 1, 1);
+  p->Draw();
+  p->cd();
+  gStyle->SetOptStat(1110);
+  gStyle->SetStatFormat(".2g");
+  mh3 = (MH3*)hError2.DrawClone("nonew");
+  mh3->GetHist()->SetXTitle("Zd [\\circ]");
+  mh3->GetHist()->SetYTitle("\\Delta [arcmin]");
+  mh3->GetHist()->SetTitle("Control deviation of the motors");
+  mh3->GetHist()->SetLabelSize(0.06,"X");
+  mh3->GetHist()->SetLabelSize(0.06,"Y");
+  mh3->GetHist()->SetTitleSize(0.06,"X");
+  mh3->GetHist()->SetTitleSize(0.06,"Y");
+  mh3->GetHist()->SetStats(1);
+  mh3->GetHist()->Draw("box");
+  // -------------------------- Zenith angle vs time --------------------------
+  c1->cd();
+  p = new TPad("", "", 0.6, 0.42, 1, 0.71);
+  p->Draw();
+  p->cd();
+  gPad->SetBorderMode(0);
+  hvt = (MHVsTime*)hZd.DrawClone("nonew");
+  hvt->GetGraph()->SetMarkerStyle(kFullDotSmall);
+  if (hvt->GetGraph()->GetN())
+    {
+      hvt->GetGraph()->GetHistogram()->GetXaxis()->SetTimeFormat("%H:%M %F1995-01-01 00:00:00");
+      hvt->GetGraph()->GetHistogram()->SetXTitle("Time");
+      hvt->GetGraph()->GetHistogram()->SetYTitle("Zd [\\circ]");
+      hvt->GetGraph()->GetHistogram()->SetTitle("Zd vs. Time");
+      hvt->GetGraph()->GetHistogram()->SetLabelSize(0.06,"X");
+      hvt->GetGraph()->GetHistogram()->SetTitleSize(0.06,"X");
+      hvt->GetGraph()->GetHistogram()->SetLabelSize(0.06,"Y");
+      hvt->GetGraph()->GetHistogram()->SetTitleSize(0.06,"Y");
+      hvt->GetGraph()->GetHistogram()->SetStats(0);
+    }
+  
+  
+  //
+  // Camera report 
+  // 
+  // **************************** CAMERA STATUS ********************
+  if ((d = evtloop.GetDisplay()))
+    TCanvas &c2 = d.AddTab("CAMERA STATUS");
+  else
+    TCanvas *c2 = new TCanvas();
+  c2->Divide(1,2);
+  c2->cd(1);
+  g = hCamStatus.GetGraph();
+  g->SetMarkerStyle(kFullDotSmall);
+  g->SetTitle("Camera status");
+  clone1 = (MHVsTime*)hCamStatus.DrawClone("nonew");
+  if(clone1->GetGraph()->GetN())
+    {
+      hist = clone1->GetGraph()->GetHistogram();
+      axey = hist->GetYaxis();
+      hist->SetMinimum(-0.5);
+      hist->SetMaximum(9.5);
+      axey->Set(10,-0.5,9.5);
+      axey->SetBinLabel(axey->FindFixBin(0),"EROR");
+      axey->SetBinLabel(axey->FindFixBin(1),"ALARM");
+      axey->SetBinLabel(axey->FindFixBin(2),"BLOCKED!");
+      axey->SetBinLabel(axey->FindFixBin(3),"WARM!");
+      axey->SetBinLabel(axey->FindFixBin(4),"HOT");
+      axey->SetBinLabel(axey->FindFixBin(5),"HVRAMPING");
+      axey->SetBinLabel(axey->FindFixBin(6),"OK");
+      axey->SetBinLabel(axey->FindFixBin(7),"INIT");
+      axey->SetBinLabel(axey->FindFixBin(8),"SHUTD");
+      axey->SetBinLabel(axey->FindFixBin(9),"N/A");
+      hist->SetLabelSize(0.04,"X");
+      hist->SetLabelSize(0.05,"Y");
+      hist->GetXaxis()->SetTimeFormat("%H:%M %F1995-01-01 00:00:00");
+      hist->SetXTitle("Time");
+      hist->SetYTitle("");
+    }
+  c2->cd(2);
+  g = hLidsStatus.GetGraph();
+  g->SetMarkerStyle(kFullDotSmall);
+  g->SetTitle("Camera Lids status");
+  clone1 = (MHVsTime*)hLidsStatus.DrawClone("nonew");
+  if(clone1->GetGraph()->GetN())
+    {
+      hist = clone1->GetGraph()->GetHistogram();
+      axey = hist->GetYaxis();
+      hist->SetMinimum(-0.5);
+      hist->SetMaximum(9.5);
+      axey->Set(10,-0.5,9.5);
+      axey->SetBinLabel(axey->FindFixBin(0),"Error");
+      axey->SetBinLabel(axey->FindFixBin(1),"SafetyLimit");
+      axey->SetBinLabel(axey->FindFixBin(4),"Closed");
+      axey->SetBinLabel(axey->FindFixBin(5),"Opened");
+      axey->SetBinLabel(axey->FindFixBin(6),"Moving");
+      axey->SetBinLabel(axey->FindFixBin(7),"Stopped");
+      axey->SetBinLabel(axey->FindFixBin(9),"n/a");
+      hist->SetLabelSize(0.04,"X");
+      hist->SetLabelSize(0.06,"Y");
+      hist->GetXaxis()->SetTimeFormat("%H:%M %F1995-01-01 00:00:00");
+      hist->SetXTitle("Time");
+      hist->SetYTitle("");
+    }
+  // ************************* HV of power supplies ***************************
+  if ((d = evtloop.GetDisplay()))
+    TCanvas &c3 = d.AddTab("CAMERA HV");
+  else
+    TCanvas *c3 = new TCanvas();
+  c3->Divide(2,2);
+  c3->cd(1);
+  // --------------- Power supplies  and HV settings --------------------------
+  TLegend *legHV = new TLegend(0.75,0.85,0.99,0.99);
+  g = hHVA.GetGraph();
+  g->SetMarkerColor(2);
+  g->SetLineColor(2);
+  g->SetTitle("Voltages of power supplies and camera settings");
+  legHV->AddEntry(g,"PS A (hvps1)","l");
+  clone1 = (MHVsTime*)hHVA.DrawClone("nonew");
+  if(clone1->GetGraph()->GetN())
+    {
+      hist = clone1->GetGraph()->GetHistogram();
+      hist->GetXaxis()->SetTimeFormat("%H:%M %F1995-01-01 00:00:00");
+      hist->SetXTitle("Time");
+      hist->SetYTitle("High voltage [V]");
+      hist->SetLabelSize(0.04,"X");
+      hist->SetMinimum(0);
+    }
+  g = hHVB.GetGraph();
+  g->SetMarkerColor(3);
+  g->SetLineColor(3);
+  legHV->AddEntry(g,"PS B (hvps2)","l");
+  clone1 = (MHVsTime*)hHVB.DrawClone("nonewsame");
+  g = hCamMean.GetGraph();
+  g->SetMarkerColor(4);
+  g->SetLineColor(4);
+  legHV->AddEntry(g,"Camera mean HV","l");
+  clone1 = (MHVsTime*)hCamMean.DrawClone("nonewsame");
+  legHV->DrawClone();
+ // ---------------------------- HV status -----------------------------------
+  c3->cd(2);
+  g = hHVStatus.GetGraph();
+  g->SetMarkerStyle(kFullDotSmall);
+  g->SetTitle("Camera HV status");
+  clone1 = (MHVsTime*)hHVStatus.DrawClone("nonew");
+  if(clone1->GetGraph()->GetN())
+    {
+      hist = clone1->GetGraph()->GetHistogram();
+      axey = hist->GetYaxis();
+      hist->SetMinimum(-0.5);
+      hist->SetMaximum(9.5);
+      axey->Set(10,-0.5,9.5);
+      axey->SetBinLabel(axey->FindFixBin(0),"Error");
+      axey->SetBinLabel(axey->FindFixBin(1),"Mismatch");
+      axey->SetBinLabel(axey->FindFixBin(2),"Trip");
+      axey->SetBinLabel(axey->FindFixBin(3),"Ramping");
+      axey->SetBinLabel(axey->FindFixBin(4),"Off");
+      axey->SetBinLabel(axey->FindFixBin(5),"Nominal");
+      axey->SetBinLabel(axey->FindFixBin(6),"LimCurrentWarning");
+      axey->SetBinLabel(axey->FindFixBin(9),"n/a");
+      hist->SetLabelSize(0.04,"X");
+      hist->SetLabelSize(0.05,"Y");
+      hist->GetXaxis()->SetTimeFormat("%H:%M %F1995-01-01 00:00:00");
+      hist->SetXTitle("Time");
+      hist->SetYTitle("");
+    }
+  // ---------------------------- HV settings ---------------------------------
+  c3->cd(3);
+  Sum = (MHCamera*)HVdisplay.GetHistByName("sum");
+  TVirtualPad *c = gPad;
+  c->cd(1);
+  gPad->SetBorderMode(0);
+  Sum->SetYTitle("Mean");
+  Sum->DrawClone("pixelindex"); 
+  c3->cd(4);
+  gPad->SetBorderMode(0);
+  Sum->SetYTitle("Mean HV settings");
+  Sum->DrawClone("EPhist");
+
+  // ******************** Currents of power supplies *******************
+  if ((d = evtloop.GetDisplay()))
+    TCanvas &c4 = d.AddTab("CAMERA DC");
+  else
+    TCanvas *c4 = new TCanvas();
+ // ----------------------------- Power supplies ------------------------------
+  c4->Divide(1,2);
+  c4->cd(1);
+  TLegend *legC = new TLegend(0.85,0.75,0.99,0.99);
+  g = hCA.GetGraph();
+  g->SetMarkerColor(2);
+  g->SetLineColor(2);
+  g->SetTitle("Currents of power supplies");
+  legC->AddEntry(g,"PS A (curr1)","l");
+  clone1 = (MHVsTime*)hCA.DrawClone("nonew");
+  if(clone1->GetGraph()->GetN())
+    {
+      hist = clone1->GetGraph()->GetHistogram();
+      hist->GetXaxis()->SetTimeFormat("%H:%M %F1995-01-01 00:00:00");
+      hist->SetXTitle("Time");
+      hist->SetYTitle("Current [mA]");
+      hist->SetLabelSize(0.04,"X");
+      hist->SetMinimum(0);
+    }
+  g = hCB.GetGraph();
+  g->SetMarkerColor(3);
+  g->SetLineColor(3);
+  legC->AddEntry(g,"PS B (curr2)","l");
+  clone1 = (MHVsTime*)hCB.DrawClone("nonewsame");
+  legC->DrawClone();
+  c4->cd(2);
+  g = hCamStatusDC.GetGraph();
+  g->SetMarkerStyle(kFullDotSmall);
+  g->SetTitle("Camera DC status");
+  clone1 = (MHVsTime*)hCamStatusDC.DrawClone("nonew");
+  if(clone1->GetGraph()->GetN())
+    {
+      hist = clone1->GetGraph()->GetHistogram();
+      axey = hist->GetYaxis();
+      hist->SetMinimum(-0.5);
+      hist->SetMaximum(9.5);
+      axey->Set(10,-0.5,9.5);
+      axey->SetBinLabel(axey->FindFixBin(0),"Error");
+      axey->SetBinLabel(axey->FindFixBin(1),"Alarm");
+      axey->SetBinLabel(axey->FindFixBin(3),"Hot");
+      axey->SetBinLabel(axey->FindFixBin(5),"Ok");
+      axey->SetBinLabel(axey->FindFixBin(6),"Warm");
+      axey->SetBinLabel(axey->FindFixBin(9),"n/a");
+      hist->SetLabelSize(0.09,"Y");
+      hist->SetLabelSize(0.04,"X");
+      hist->GetXaxis()->SetTimeFormat("%H:%M %F1995-01-01 00:00:00");
+      hist->SetXTitle("Time");
+      hist->SetYTitle("");
+    }
+
+
+  // ***************************** LV power supplies **************************
+  if ((d = evtloop.GetDisplay()))
+    TCanvas &c5 = d.AddTab("CAMERA LV");
+  else
+    TCanvas *c5 = new TCanvas();
+  c5->Divide(2,2);
+  c5->cd(1);
+  g = hLVTemp.GetGraph();
+  g->SetMarkerColor(2);
+  g->SetLineColor(2);
+  g->SetTitle("LV temperature");
+  clone1 = (MHVsTime*)hLVTemp.DrawClone("nonew");
+  if(clone1->GetGraph()->GetN())
+    {
+      hist = clone1->GetGraph()->GetHistogram();
+      hist->GetXaxis()->SetTimeFormat("%H:%M %F1995-01-01 00:00:00");
+      hist->SetXTitle("Time");
+      hist->SetYTitle("Temperature [\\circ]");
+      hist->SetLabelSize(0.04,"X");
+    }
+  c5->cd(2);
+  g = hLVHum.GetGraph();
+  g->SetMarkerColor(4);
+  g->SetLineColor(4);
+  g->SetTitle("LV humidity");
+  clone1 = (MHVsTime*)hLVHum.DrawClone("nonew");
+  if(clone1->GetGraph()->GetN())
+    {
+      hist = clone1->GetGraph()->GetHistogram();
+      hist->GetXaxis()->SetTimeFormat("%H:%M %F1995-01-01 00:00:00");
+      hist->SetXTitle("Time");
+      hist->SetYTitle("Humidity [%]");
+      hist->SetLabelSize(0.04,"X");
+    }
+  c5->cd(3);
+  g = hLVStatus.GetGraph();
+  g->SetMarkerStyle(kFullDotSmall);
+  g->SetTitle("LV status");
+  clone1 = (MHVsTime*)hLVStatus.DrawClone("nonew");
+  if(clone1->GetGraph()->GetN())
+    {
+      hist = clone1->GetGraph()->GetHistogram();
+      axey = hist->GetYaxis();
+      hist->SetMinimum(-0.5);
+      hist->SetMaximum(9.5);
+      axey->Set(10,-0.5,9.5);
+      axey->SetBinLabel(axey->FindFixBin(0),"Error");
+      axey->SetBinLabel(axey->FindFixBin(1),"Alarm");
+      axey->SetBinLabel(axey->FindFixBin(2),"Trip");
+      axey->SetBinLabel(axey->FindFixBin(4),"Off");
+      axey->SetBinLabel(axey->FindFixBin(5),"On");
+      axey->SetBinLabel(axey->FindFixBin(9),"n/a");
+      hist->SetLabelSize(0.04,"X");
+      hist->SetLabelSize(0.05,"Y");
+      hist->GetXaxis()->SetTimeFormat("%H:%M %F1995-01-01 00:00:00");
+      hist->SetXTitle("Time");
+      hist->SetYTitle("");
+    }
+  c5->cd(4);
+  g = hLVRPS.GetGraph();
+  g->SetMarkerStyle(kFullDotSmall);
+  g->SetTitle("LV request power supply");
+  clone1 = (MHVsTime*)hLVRPS.DrawClone("nonew");
+  if(clone1->GetGraph()->GetN())
+    {
+      hist = clone1->GetGraph()->GetHistogram();
+      hist->GetXaxis()->SetTimeFormat("%H:%M %F1995-01-01 00:00:00");
+      hist->SetXTitle("Time");
+      hist->SetYTitle("");
+      hist->SetLabelSize(0.04,"X");
+      axey = hist->GetYaxis();
+      hist->SetMinimum(-0.5);
+      hist->SetMaximum(1.5);
+      axey->Set(2, -0.5, 1.5);
+      axey->SetBinLabel(axey->FindFixBin(0), "OFF");
+      axey->SetBinLabel(axey->FindFixBin(1), "ON");
+    }
+  // ****************************** Cooling ***********************************
+  if ((d = evtloop.GetDisplay()))
+    TCanvas &c6 = d.AddTab("COOLING SYSTEM");
+  else
+    TCanvas *c6 = new TCanvas();
+  gStyle->SetPadGridX(kTRUE);
+  gStyle->SetPadGridY(kTRUE);
+  c6->Divide(2,2);
+  c6->cd(1);
+  // -------------------------- Camera temperatures ---------------------------
+  TLegend *legtemp = new TLegend(0.75,0.80,0.99,0.99);
+  g = hTCenter.GetGraph();
+  g->SetMarkerColor(8);
+  g->SetLineColor(8);
+  g->SetTitle("Camera temperature");
+  legtemp->AddEntry(g,"camera center","l");
+  clone1 = (MHVsTime*)hTCenter.DrawClone("nonew");
+  if(clone1->GetGraph()->GetN())
+    {
+      hist = clone1->GetGraph()->GetHistogram();
+      hist->GetXaxis()->SetTimeFormat("%H:%M %F1995-01-01 00:00:00");
+      hist->SetXTitle("Time");
+      hist->SetYTitle("Temperature [\\circ C]");
+      hist->SetLabelSize(0.04,"X");
+      hist->SetMinimum(0);
+    }
+  g = hTWall.GetGraph();
+  g->SetMarkerColor(12);
+  g->SetLineColor(12);
+  legtemp->AddEntry(g,"camera wall","l");
+  clone1 = (MHVsTime*)hTWall.DrawClone("nonewsame");
+  g = hTWater.GetGraph();
+  g->SetMarkerColor(4);
+  g->SetLineColor(4);
+  legtemp->AddEntry(g,"water deposit","l");
+  clone1 = (MHVsTime*)hTWater.DrawClone("nonewsame");
+  g = hTOptLink.GetGraph();
+  g->SetMarkerColor(2);
+  g->SetLineColor(2);
+  legtemp->AddEntry(g,"optical links","l");
+  clone1 = (MHVsTime*)hTOptLink.DrawClone("nonewsame");
+  legtemp->DrawClone();
+  c6->cd(2);
+  g = hCoolStatus.GetGraph();
+  g->SetMarkerStyle(kFullDotSmall);
+  g->SetTitle("Camera cooling status");
+  clone1 = (MHVsTime*)hCoolStatus.DrawClone("nonew");
+  if(clone1->GetGraph()->GetN())
+    {
+      hist = clone1->GetGraph()->GetHistogram();
+      axey = hist->GetYaxis();
+      hist->SetMinimum(-0.5);
+      hist->SetMaximum(9.5);
+      axey->Set(10,-0.5,9.5);
+      axey->SetBinLabel(axey->FindFixBin(0),"Error");
+      axey->SetBinLabel(axey->FindFixBin(1),"Alarm");
+      axey->SetBinLabel(axey->FindFixBin(4),"Off");
+      axey->SetBinLabel(axey->FindFixBin(5),"Ok");
+      axey->SetBinLabel(axey->FindFixBin(6),"Temp.Warning");
+      axey->SetBinLabel(axey->FindFixBin(7),"Cond.Warning");
+      axey->SetBinLabel(axey->FindFixBin(9),"n/a");
+      hist->SetLabelSize(0.04,"X");
+      hist->SetLabelSize(0.05,"Y");
+      hist->GetXaxis()->SetTimeFormat("%H:%M %F1995-01-01 00:00:00");
+      hist->SetXTitle("Time");
+      hist->SetYTitle("");
+    }
+  // ------------------------- Camera relative humidity -----------------------
+  c6->cd(3);
+  TLegend *leghum = new TLegend(0.75,0.85,0.99,0.99);
+  g = hHCenter.GetGraph();
+  g->SetMarkerColor(8);
+  g->SetLineColor(8);
+  g->SetTitle("Camera relative humidity");
+  leghum->AddEntry(g,"camera center","l");
+  clone1 = (MHVsTime*)hHCenter.DrawClone("nonew");
+  if(clone1->GetGraph()->GetN())
+    {
+      hist = clone1->GetGraph()->GetHistogram();
+      hist->GetXaxis()->SetTimeFormat("%H:%M %F1995-01-01 00:00:00");
+      hist->SetXTitle("Time");
+      hist->SetYTitle("Relative humidity [%]");
+      hist->SetLabelSize(0.04,"X");
+      hist->SetMaximum(50);
+      hist->SetMinimum(0);
+    }
+  g = hHWall.GetGraph();
+  g->SetMarkerColor(12);
+  g->SetLineColor(12);
+  leghum->AddEntry(g,"camera wall","l");
+  clone1 = (MHVsTime*)hHWall.DrawClone("nonewsame");
+  leghum->DrawClone();
+  // ---------------------- Temperature distribution --------------------------
+  c6->cd(4);
+  hist = hTempOptLink.GetHistByName("TOptLink");
+  hist->SetXTitle("Temperature [\\circ C]");
+  hist->SetYTitle("");
+  hist->SetLineColor(2);
+  hist->SetTitle("Distribution of opt. links temperature");
+  hist->SetLabelSize(0.04,"X");
+  hist->SetStats(0);
+  mh3 = (MH3*)hTempOptLink.DrawClone("nonew");
+  //
+  // **************************** Trigger report ******************************
+  //
+  if ((d = evtloop.GetDisplay()))
+    TCanvas &c7 = d.AddTab("TRIGGER SYSTEM");
+  else
+    TCanvas *c7 = new TCanvas();
+  c7->Divide(1,3);
+  c7->cd(1);
+  gStyle->SetPadGridX(kTRUE);
+  gStyle->SetPadGridY(kTRUE);
+  gPad->SetLogy();
+  TLegend *legtrig = new TLegend(0.85,0.85,0.99,0.99);
+  g = hTrigBL2.GetGraph();
+  g->SetMarkerStyle(kFullDotSmall);
+  g->SetMarkerColor(2);
+  g->SetLineColor(2);
+  g->SetTitle("L2 trigger rate");
+  legtrig->AddEntry(g,"Before prescaler","l");
+  clone1 = (MHVsTime*)hTrigBL2.DrawClone("nonew");
+  if(clone1->GetGraph()->GetN())
+    {
+      hist = clone1->GetGraph()->GetHistogram();
+      hist->SetMinimum(1);
+      hist->GetXaxis()->SetTimeFormat("%H:%M %F1995-01-01 00:00:00");
+      hist->SetLabelSize(0.06,"X");
+      hist->SetLabelSize(0.06,"Y");
+      hist->SetTitleSize(0.06,"X");
+      hist->SetTitleSize(0.06,"Y");
+      hist->SetXTitle("Time");
+      hist->SetYTitle("L2 trigger rate [Hz]"); 
+    }
+  g = hTrigAL2.GetGraph();
+  g->SetMarkerColor(4);
+  g->SetLineColor(4);
+  legtrig->AddEntry(g,"After prescaler","l");
+  clone1 = (MHVsTime*)hTrigAL2.DrawClone("nonewsame");
+  legtrig->DrawClone();
+   c7->cd(2);
+   gPad->SetLogy();
+   hist = hTrigZd.GetHistByName("TrigZd");
+   hist->SetLabelSize(0.06,"X");
+   hist->SetLabelSize(0.06,"Y");
+   hist->SetTitleSize(0.06,"X");
+   hist->SetTitleSize(0.06,"Y");
+   hist->SetXTitle("Zenith angle[\\circ]");
+   hist->SetYTitle("Trigger rate [Hz]");
+   hist->SetMarkerColor(4);
+   hist->SetTitle("L2 trigger rate after prescaler");
+   hist->SetStats(0);
+   mh3 = (MH3*)hTrigZd.DrawClone("nonew");
+   hist->SetMinimum(1);
+   c7->cd(3);
+   g = hTrigStatus.GetGraph();
+   g->SetMarkerStyle(kFullDotSmall);
+   g->SetTitle("Trigger status");
+   clone1 = (MHVsTime*)hTrigStatus.DrawClone("nonew");
+   if(clone1->GetGraph()->GetN())
+     {
+       hist = clone1->GetGraph()->GetHistogram();
+       axey = hist->GetYaxis();
+       hist->SetMinimum(-0.5);
+       hist->SetMaximum(5.5);
+       axey->Set(6,-0.5,5.5);
+       axey->SetBinLabel(axey->FindFixBin(0),"Error");
+       axey->SetBinLabel(axey->FindFixBin(1),"Idle");
+       axey->SetBinLabel(axey->FindFixBin(2),"Loading");
+       axey->SetBinLabel(axey->FindFixBin(3),"Ready");
+       axey->SetBinLabel(axey->FindFixBin(4),"Active");
+       axey->SetBinLabel(axey->FindFixBin(5),"Stopped");
+       hist->SetLabelSize(0.07,"Y");
+       hist->SetLabelSize(0.06,"X");
+       hist->SetTitleSize(0.06,"X");
+       hist->GetXaxis()->SetTimeFormat("%H:%M %F1995-01-01 00:00:00");
+       hist->SetXTitle("Time");
+       hist->SetYTitle("");
+     }
+  // ***************************** Trigger of macrocells **********************
+  if ((d = evtloop.GetDisplay()))
+    TCanvas &c8 = d.AddTab("TRIG. MACROCELLs");
+  else
+    TCanvas *c8 = new TCanvas();
+  c8->Divide(2,2);
+  c8->cd(1);
+  gPad->SetLogy();
+  TLegend *legtrig = new TLegend(0.80,0.80,0.99,0.99);
+  g = htrigmc1.GetGraph();
+  g->SetMarkerStyle(kFullDotSmall);
+  g->SetMarkerColor(2);
+  g->SetLineColor(2);
+  g->SetTitle("Trigger rate of macrocell 1 : (maximum)");
+  pixclone1 = (MHPixVsTime*)htrigmc1.DrawClone("nonew");
+  if(clone1->GetGraph()->GetN())
+    {
+      hist = htrigmc1->GetGraph()->GetHistogram();
+      if(hist->GetMaximum()<g->GetHistogram()->GetMaximum())
+	hist->SetMaximum(g->GetHistogram()->GetMaximum());
+      hist->SetMinimum(1);
+      hist->GetXaxis()->SetTimeFormat("%H:%M %F1995-01-01 00:00:00");
+      hist->SetXTitle("Time");
+      hist->SetYTitle("Trigger [Hz]");
+      hist->SetLabelSize(0.04,"X");
+      hist->SetLabelSize(0.05,"Y");
+    }
+  legtrig->AddEntry(hist,Form("Mc 1: %3.0e",hist->GetMaximum()),"p");
+  legtrig->DrawClone();
+  c8->cd(2);
+  gPad->SetLogy();
+  TLegend *legtrig = new TLegend(0.80,0.70,0.99,0.99);
+  g = htrigmc2.GetGraph();
+  g->SetMarkerStyle(kFullDotSmall);
+  g->SetMarkerColor(2);
+  g->SetTitle("Trigger rate of macrocells 2-7 : (maximum)");
+  pixclone1 = (MHPixVsTime*)htrigmc2.DrawClone("nonew");
+  if(clone1->GetGraph()->GetN())
+    {
+      hist = pixclone1->GetGraph()->GetHistogram();
+      if(hist->GetMaximum()<g->GetHistogram()->GetMaximum())
+	hist->SetMaximum(g->GetHistogram()->GetMaximum());
+      hist->SetMinimum(1);
+      hist->GetXaxis()->SetTimeFormat("%H:%M %F1995-01-01 00:00:00");
+      hist->SetXTitle("Time");
+      hist->SetYTitle("Trigger [Hz]");
+      hist->SetLabelSize(0.04,"X");
+      hist->SetLabelSize(0.05,"Y");
+    }
+  legtrig->AddEntry(hist,Form("Mc 2: %3.0e",hist->GetMaximum()),"p");
+  g=htrigmc3.GetGraph();
+  g->SetMarkerStyle(kFullDotSmall);
+  g->SetMarkerColor(3);
+  if(htrigmc3.GetGraph()->GetN())
+  {
+      if(hist->GetMaximum()<g->GetHistogram()->GetMaximum())
+	  hist->SetMaximum(g->GetHistogram()->GetMaximum());
+      legtrig->AddEntry(g,Form("Mc 3: %3.0e",g->GetHistogram()->GetMaximum()),"p");
+  }
+  pixclone1 = (MHPixVsTime*)htrigmc3.DrawClone("nonewsame");
+  g=htrigmc4.GetGraph();
+  g->SetMarkerStyle(kFullDotSmall);
+  g->SetMarkerColor(4);
+  if(htrigmc4.GetGraph()->GetN())
+  {
+      if(hist->GetMaximum()<g->GetHistogram()->GetMaximum())
+	  hist->SetMaximum(g->GetHistogram()->GetMaximum());
+      legtrig->AddEntry(g,Form("Mc 4: %3.0e",g->GetHistogram()->GetMaximum()),"p");
+  }
+  pixclone1 = (MHPixVsTime*)htrigmc4.DrawClone("nonewsame");
+  g=htrigmc5.GetGraph();
+  g->SetMarkerStyle(kFullDotSmall);
+  g->SetMarkerColor(5);
+  if(htrigmc5.GetGraph()->GetN())
+  {
+      legtrig->AddEntry(g,Form("Mc 5: %3.0e",g->GetHistogram()->GetMaximum()),"p");
+      if(hist->GetMaximum()<g->GetHistogram()->GetMaximum())
+	  hist->SetMaximum(g->GetHistogram()->GetMaximum());
+  }
+  pixclone1 = (MHPixVsTime*)htrigmc5.DrawClone("nonewsame");
+  g=htrigmc6.GetGraph();
+  g->SetMarkerStyle(kFullDotSmall);
+  g->SetMarkerColor(6);
+  if(htrigmc6.GetGraph()->GetN())
+  {
+      legtrig->AddEntry(g,Form("Mc 6: %3.0e",g->GetHistogram()->GetMaximum()),"p");
+      if(hist->GetMaximum()<g->GetHistogram()->GetMaximum())
+	  hist->SetMaximum(g->GetHistogram()->GetMaximum());
+  }
+  pixclone1 = (MHPixVsTime*)htrigmc6.DrawClone("nonewsame");
+  g=htrigmc7.GetGraph();
+  g->SetMarkerStyle(kFullDotSmall);
+  g->SetMarkerColor(7);
+  if(htrigmc7.GetGraph()->GetN())
+  {
+      legtrig->AddEntry(g,Form("Mc 7: %3.0e",g->GetHistogram()->GetMaximum()),"p");
+      if(hist->GetMaximum()<g->GetHistogram()->GetMaximum())
+	  hist->SetMaximum(g->GetHistogram()->GetMaximum());
+  }
+  pixclone1 = (MHPixVsTime*)htrigmc7.DrawClone("nonewsame");
+  legtrig->DrawClone();
+  c8->cd(3);
+  gPad->SetLogy();
+  TLegend *legtrig = new TLegend(0.80,0.70,0.99,0.99);
+  g = htrigmc8.GetGraph();
+  g->SetMarkerStyle(kFullDotSmall);
+  g->SetMarkerColor(2);
+  g->SetTitle("Trigger rate of macrocells 8-13 : (maximum)");
+  if(htrigmc8.GetGraph()->GetN())
+  {
+      legtrig->AddEntry(g,Form("Mc 8: %3.0e",g->GetHistogram()->GetMaximum()),"p");
+      if(hist->GetMaximum()<g->GetHistogram()->GetMaximum())
+	  hist->SetMaximum(g->GetHistogram()->GetMaximum());
+  }
+  pixclone1 = (MHPixVsTime*)htrigmc8.DrawClone("nonew");
+  if(clone1->GetGraph()->GetN())
+    {
+	hist = pixclone1->GetGraph()->GetHistogram();
+      if(hist->GetMaximum()<g->GetHistogram()->GetMaximum())
+	hist->SetMaximum(g->GetHistogram()->GetMaximum());
+      hist->SetMinimum(1);
+      hist->GetXaxis()->SetTimeFormat("%H:%M %F1995-01-01 00:00:00");
+      hist->SetXTitle("Time");
+      hist->SetYTitle("Trigger [Hz]");
+      hist->SetLabelSize(0.04,"X");
+      hist->SetLabelSize(0.05,"Y");
+    }
+  g=htrigmc9.GetGraph();
+  g->SetMarkerStyle(kFullDotSmall);
+  g->SetMarkerColor(3);
+  if(htrigmc9.GetGraph()->GetN())
+  {
+      legtrig->AddEntry(g,Form("Mc 9: %3.0e",g->GetHistogram()->GetMaximum()),"p");
+      if(hist->GetMaximum()<g->GetHistogram()->GetMaximum())
+	  hist->SetMaximum(g->GetHistogram()->GetMaximum());
+  }
+  pixclone1 = (MHPixVsTime*)htrigmc9.DrawClone("nonewsame");
+  g=htrigmc10.GetGraph();
+  g->SetMarkerStyle(kFullDotSmall);
+  g->SetMarkerColor(4);
+  if(htrigmc10.GetGraph()->GetN())
+  {
+      legtrig->AddEntry(g,Form("Mc 10: %3.0e",g->GetHistogram()->GetMaximum()),"p");
+      if(hist->GetMaximum()<g->GetHistogram()->GetMaximum())
+	  hist->SetMaximum(g->GetHistogram()->GetMaximum());
+  }
+  pixclone1 = (MHPixVsTime*)htrigmc10.DrawClone("nonewsame");
+  g=htrigmc11.GetGraph();
+  g->SetMarkerStyle(kFullDotSmall);
+  g->SetMarkerColor(5);
+  if(htrigmc11.GetGraph()->GetN())
+  {
+      legtrig->AddEntry(g,Form("Mc 11: %3.0e",g->GetHistogram()->GetMaximum()),"p");
+      if(hist->GetMaximum()<g->GetHistogram()->GetMaximum())
+	  hist->SetMaximum(g->GetHistogram()->GetMaximum());
+  }
+  pixclone1 = (MHPixVsTime*)htrigmc11.DrawClone("nonewsame");
+  g=htrigmc12.GetGraph();
+  g->SetMarkerStyle(kFullDotSmall);
+  g->SetMarkerColor(6);
+  if(htrigmc12.GetGraph()->GetN())
+  {
+      legtrig->AddEntry(g,Form("Mc 12: %3.0e",g->GetHistogram()->GetMaximum()),"p");
+      if(hist->GetMaximum()<g->GetHistogram()->GetMaximum())
+	  hist->SetMaximum(g->GetHistogram()->GetMaximum());
+  }
+  pixclone1 = (MHPixVsTime*)htrigmc12.DrawClone("nonewsame");
+  g=htrigmc13.GetGraph();
+  g->SetMarkerStyle(kFullDotSmall);
+  g->SetMarkerColor(7);
+  if(htrigmc13.GetGraph()->GetN())
+  {
+      legtrig->AddEntry(g,Form("Mc 13: %3.0e",g->GetHistogram()->GetMaximum()),"p");
+      if(hist->GetMaximum()<g->GetHistogram()->GetMaximum())
+	  hist->SetMaximum(g->GetHistogram()->GetMaximum());
+  }
+  pixclone1 = (MHPixVsTime*)htrigmc13.DrawClone("nonewsame");
+  legtrig->DrawClone();
+  c8->cd(4);
+  gPad->SetLogy();
+  TLegend *legtrig = new TLegend(0.80,0.70,0.99,0.99);
+  TGraph *g = htrigmc14.GetGraph();
+  g->SetMarkerStyle(kFullDotSmall);
+  g->SetMarkerColor(2);
+  if(htrigmc14.GetGraph()->GetN())
+      legtrig->AddEntry(g,Form("Mc 14: %3.0e",g->GetHistogram()->GetMaximum()),"p");
+  g->SetTitle("Trigger rate of macrocells 14-19 : (maximum)");
+  pixclone1 = (MHPixVsTime*)htrigmc14.DrawClone("nonew");
+  if(clone1->GetGraph()->GetN())
+    {
+      hist = pixclone1->GetGraph()->GetHistogram();
+      if(hist->GetMaximum()<g->GetHistogram()->GetMaximum())
+	hist->SetMaximum(g->GetHistogram()->GetMaximum());
+      hist->SetMinimum(1);
+      hist->GetXaxis()->SetTimeFormat("%H:%M %F1995-01-01 00:00:00");
+      hist->SetXTitle("Time");
+      hist->SetYTitle("Trigger [Hz]");
+      hist->SetLabelSize(0.04,"X");
+      hist->SetLabelSize(0.05,"Y");
+    }
+  g=htrigmc15.GetGraph();
+  g->SetMarkerStyle(kFullDotSmall);
+  g->SetMarkerColor(3);
+  if(htrigmc15.GetGraph()->GetN())
+  {
+      legtrig->AddEntry(g,Form("Mc 15: %3.0e",g->GetHistogram()->GetMaximum()),"p");
+      if(hist->GetMaximum()<g->GetHistogram()->GetMaximum())
+	  hist->SetMaximum(g->GetHistogram()->GetMaximum());
+  }
+  pixclone1 = (MHPixVsTime*)htrigmc15.DrawClone("nonewsame");
+  g=htrigmc16.GetGraph();
+  g->SetMarkerStyle(kFullDotSmall);
+  g->SetMarkerColor(4);
+  if(htrigmc16.GetGraph()->GetN())
+  {
+      legtrig->AddEntry(g,Form("Mc 16: %3.0e",g->GetHistogram()->GetMaximum()),"p");
+      if(hist->GetMaximum()<g->GetHistogram()->GetMaximum())
+	  hist->SetMaximum(g->GetHistogram()->GetMaximum());
+  }
+  pixclone1 = (MHPixVsTime*)htrigmc16.DrawClone("nonewsame");
+  g=htrigmc17.GetGraph();
+  g->SetMarkerStyle(kFullDotSmall);
+  g->SetMarkerColor(5);
+  if(htrigmc17.GetGraph()->GetN())
+  {
+      legtrig->AddEntry(g,Form("Mc 17: %3.0e",g->GetHistogram()->GetMaximum()),"p");
+      if(hist->GetMaximum()<g->GetHistogram()->GetMaximum())
+	  hist->SetMaximum(g->GetHistogram()->GetMaximum());
+  }
+  pixclone1 = (MHPixVsTime*)htrigmc17.DrawClone("nonewsame");
+  g=htrigmc18.GetGraph();
+  g->SetMarkerStyle(kFullDotSmall);
+  g->SetMarkerColor(6);
+  if(htrigmc18.GetGraph()->GetN())
+  {
+      legtrig->AddEntry(g,Form("Mc 18: %3.0e",g->GetHistogram()->GetMaximum()),"p");
+      if(hist->GetMaximum()<g->GetHistogram()->GetMaximum())
+	  hist->SetMaximum(g->GetHistogram()->GetMaximum());
+  }
+  pixclone1 = (MHPixVsTime*)htrigmc18.DrawClone("nonewsame");
+  g=htrigmc19.GetGraph();
+  g->SetMarkerStyle(kFullDotSmall);
+  g->SetMarkerColor(7);
+  if(htrigmc19.GetGraph()->GetN())
+  {
+      legtrig->AddEntry(g,Form("Mc 19: %3.0e",g->GetHistogram()->GetMaximum()),"p");
+      if(hist->GetMaximum()<g->GetHistogram()->GetMaximum())
+	  hist->SetMaximum(g->GetHistogram()->GetMaximum());
+  }
+  pixclone1 = (MHPixVsTime*)htrigmc19.DrawClone("nonewsame");
+  legtrig->DrawClone();
+
+  //
+  // *************************** Weather station ******************************
+  //
+  if ((d = evtloop.GetDisplay()))
+    TCanvas &c9 = d.AddTab("WEATHER STATION");
+  else
+    TCanvas *c9 = new TCanvas();
+  c9->Divide(2,2);
+  // ----------------------- Relative humidity --------------------------------
+  c9->cd(1);
+  g = hCCHum.GetGraph();
+  g->SetMarkerStyle(kFullDotSmall);
+  g->SetMarkerColor(4);
+  g->SetLineColor(4);
+  g->SetTitle("Relative humidity outside");
+  clone1 = (MHVsTime*)hCCHum.DrawClone("nonew");
+  if(clone1->GetGraph()->GetN())
+    {
+      hist = clone1->GetGraph()->GetHistogram();
+      hist->GetXaxis()->SetTimeFormat("%H:%M %F1995-01-01 00:00:00");
+      hist->SetXTitle("Time");
+      hist->SetYTitle("Humidity [%]"); 
+    }
+  // -------------------------- Temperature -----------------------------------
+  c9->cd(2);
+  g = hCCTemp.GetGraph();
+  g->SetMarkerStyle(kFullDotSmall);
+  g->SetMarkerColor(2);
+  g->SetLineColor(2);
+  g->SetTitle("Temperature outside");
+  clone1 = (MHVsTime*)hCCTemp.DrawClone("nonew");
+  if(clone1->GetGraph()->GetN())
+    {
+      hist = clone1->GetGraph()->GetHistogram();
+      hist->GetXaxis()->SetTimeFormat("%H:%M %F1995-01-01 00:00:00");
+      hist->SetXTitle("Time");
+      hist->SetYTitle("Temperature [\\circ C]"); 
+    }
+  // --------------------------- Wind speed -----------------------------------
+  c9->cd(3);
+  g = hCCWS.GetGraph();
+  g->SetMarkerStyle(kFullDotSmall);
+  g->SetMarkerColor(3);
+  g->SetLineColor(3);
+  g->SetTitle("Wind speed outside");
+  clone1 = (MHVsTime*)hCCWS.DrawClone("nonew");
+  if(clone1->GetGraph()->GetN())
+    {
+      hist = clone1->GetGraph()->GetHistogram();
+      hist->GetXaxis()->SetTimeFormat("%H:%M %F1995-01-01 00:00:00");
+      hist->SetXTitle("Time");
+      hist->SetYTitle("Wind speed [km/h]"); 
+    }
+  // -------------------------- Solar radiation -------------------------------
+  c9->cd(4);
+  g = hCCSR.GetGraph();
+  g->SetMarkerStyle(kFullDotSmall);
+  g->SetMarkerColor(9);
+  g->SetLineColor(9);
+  g->SetTitle("Solar radiation outside");
+  clone1 = (MHVsTime*)hCCSR.DrawClone("nonew");
+  if(clone1->GetGraph()->GetN())
+    {
+      hist = clone1->GetGraph()->GetHistogram();
+      hist->GetXaxis()->SetTimeFormat("%H:%M %F1995-01-01 00:00:00");
+      hist->SetXTitle("Time");
+      hist->SetYTitle("Solar radiation [W/m^2]"); 
+    }
+
+  // Save data in a postscriptfile (filename.ps)
+  TString file;
+  if (filename.Last('.')>0)
+    file = filename(0, filename.Last('.')); 
+
+  // Make sure the display hasn't been deleted by the user while the
+  // eventloop was running.
+  if ((d = evtloop.GetDisplay()))
+      d->SaveAsPS(directory+file+".ps");
+  else
+    {
+      c1->Print(directory+file+".ps(");
+      c2->Print(directory+file+".ps");
+      c3->Print(directory+file+".ps");
+      c4->Print(directory+file+".ps");
+      c5->Print(directory+file+".ps");
+      c6->Print(directory+file+".ps");
+      c7->Print(directory+file+".ps");
+      c8->Print(directory+file+".ps");
+      c9->Print(directory+file+".ps)");
+    }
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/macros/CT1Analysis.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/CT1Analysis.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/CT1Analysis.C	(revision 9661)
@@ -0,0 +1,3381 @@
+
+#include "CT1EgyEst.C"
+
+#include "MBinning.h"
+#include "MBlindPixelCalc.h"
+#include "MContinue.h"
+#include "MCT1PointingCorrCalc.h"
+
+#include "MFCT1SelBasic.h"
+#include "MFCT1SelStandard.h"
+#include "MFCT1SelFinal.h"
+#include "MFillH.h"
+
+#include "MHillasCalc.h"
+#include "MHillasSrcCalc.h"
+#include "MImgCleanStd.h"
+
+#include "MParList.h"
+#include "MSigmabarCalc.h"
+#include "MSrcPosCam.h"
+#include "MTaskList.h"
+#include "MWriteRootFile.h"
+
+//#include "TH3D.h"
+
+
+void InitBinnings(MParList *plist)
+{
+        gLog << "InitBinnings" << endl;
+
+        //--------------------------------------------
+        MBinning *binse = new MBinning("BinningE");
+        //binse->SetEdgesLog(30, 1.0e2, 1.0e5);
+
+	//This is Daniel's binning in energy:
+        binse->SetEdgesLog(14, 296.296, 86497.6);
+        plist->AddToList(binse);
+
+        //--------------------------------------------
+
+        MBinning *binssize = new MBinning("BinningSize");
+        binssize->SetEdgesLog(50, 10, 1.0e5);
+        plist->AddToList(binssize);
+
+        MBinning *binsdistc = new MBinning("BinningDist");
+        binsdistc->SetEdges(50, 0, 1.4);
+        plist->AddToList(binsdistc);
+
+        MBinning *binswidth = new MBinning("BinningWidth");
+        binswidth->SetEdges(50, 0, 1.0);
+        plist->AddToList(binswidth);
+
+        MBinning *binslength = new MBinning("BinningLength");
+        binslength->SetEdges(50, 0, 1.0);
+        plist->AddToList(binslength);
+
+        MBinning *binsalpha = new MBinning("BinningAlpha");
+        binsalpha->SetEdges(100, -100, 100);
+        plist->AddToList(binsalpha);
+
+        MBinning *binsasym = new MBinning("BinningAsym");
+        binsasym->SetEdges(50, -1.5, 1.5);
+        plist->AddToList(binsasym);
+
+        MBinning *binsm3l = new MBinning("BinningM3Long");
+        binsm3l->SetEdges(50, -1.5, 1.5);
+        plist->AddToList(binsm3l);
+
+        MBinning *binsm3t = new MBinning("BinningM3Trans");
+        binsm3t->SetEdges(50, -1.5, 1.5);
+        plist->AddToList(binsm3t);
+
+   
+        //.....
+        MBinning *binsb = new MBinning("BinningSigmabar");
+        binsb->SetEdges( 100,  0.0,  5.0);
+        plist->AddToList(binsb);
+
+        MBinning *binth = new MBinning("BinningTheta");
+        // this is Daniel's binning in theta
+        //Double_t yedge[8] = 
+        //  {9.41, 16.22, 22.68, 28.64, 34.03, 38.84, 43.08, 44.99};
+        // this is our binning
+        Double_t yedge[9] = 
+                       {0.0, 17.5, 23.5, 29.5, 35.5, 42., 50., 60., 70.};
+        TArrayD yed;
+        yed.Set(9,yedge);
+        binth->SetEdges(yed);
+        plist->AddToList(binth);
+
+        MBinning *bincosth = new MBinning("BinningCosTheta");
+        Double_t zedge[9]; 
+        for (Int_t i=0; i<9; i++)
+	{
+          zedge[8-i] = cos(yedge[i]/kRad2Deg);
+	}
+        TArrayD zed;
+        zed.Set(9,zedge);
+        bincosth->SetEdges(zed);
+        plist->AddToList(bincosth);
+
+        MBinning *binsdiff = new MBinning("BinningDiffsigma2");
+        binsdiff->SetEdges(100, -5.0, 20.0);
+        plist->AddToList(binsdiff);
+
+        // robert ----------------------------------------------
+        MBinning *binsalphaf = new MBinning("BinningAlphaFlux");
+        binsalphaf->SetEdges(100, -100, 100);
+        plist->AddToList(binsalphaf);
+
+	MBinning *binsdifftime = new MBinning("BinningTimeDiff");
+	binsdifftime->SetEdges(50, 0, 10);
+	plist->AddToList(binsdifftime);
+
+	MBinning *binstime = new MBinning("BinningTime");
+	binstime->SetEdges(50, 44500, 61000);
+	plist->AddToList(binstime);
+}
+
+
+void DeleteBinnings(MParList *plist)
+{
+        gLog << "DeleteBinnings" << endl;
+
+        TObject *bin;
+
+        //--------------------------------------------
+        bin = plist->FindObject("BinningE");
+        if (bin) delete bin;
+
+        //--------------------------------------------
+
+        bin = plist->FindObject("BinningSize");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningDist");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningWidth");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningLength");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningAlpha");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningAsym");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningM3Long");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningM3Trans");
+        if (bin) delete bin;
+
+        //.....
+        bin = plist->FindObject("BinningSigmabar");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningTheta");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningCosTheta");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningDiffsigma2");
+        if (bin) delete bin;
+
+
+        // robert ----------------------------------------------
+        bin = plist->FindObject("BinningAlphaFlux");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningTimeDiff");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningTime");
+        if (bin) delete bin;
+}
+
+
+//************************************************************************
+void CT1Analysis()
+{
+
+  gLog << "Entry CT1Analysis()" << endl;
+
+      gLog.SetNoColors();
+
+      if (gRandom)
+        delete gRandom;
+      gRandom = new TRandom3(0);
+
+      //-----------------------------------------------
+      const char *offfile = "~magican/ct1test/wittek/offdata.preproc"; 
+
+      //const char *onfile  = "~magican/ct1test/wittek/mkn421_on.preproc"; 
+      const char *onfile  = "~magican/ct1test/wittek/mkn421_00-01"; 
+
+      const char *mcfile  = "~magican/ct1test/wittek/mkn421_mc_pedrms_0.001.preproc";
+      //-----------------------------------------------
+
+      // path for input for Mars
+      TString inPath = "~magican/ct1test/wittek/marsoutput/optionC/";
+
+      // path for output from Mars
+      TString outPath = "~magican/ct1test/wittek/marsoutput/optionC/";
+
+      //-----------------------------------------------
+
+      //TEnv env("macros/CT1env.rc");
+      //Bool_t printEnv = kFALSE;
+
+    //************************************************************************
+
+    // Job A_ON : read ON data
+    //  - generate sigmabar vs. Theta plot; 
+    //  - write root file for ON data (ON1.root);
+
+    Bool_t JobA_ON = kFALSE;  
+    Bool_t WHistON = kFALSE;   // write out histogram sigmabar vs. Theta ?
+    Bool_t WON1    = kFALSE;   // write out root file ON1.root ?
+
+
+    // Job A_MC : read MC gamma data, 
+    //  - read sigmabar vs. Theta plot from ON data  
+    //  - do padding; 
+    //  - write root file for MC gammas (MC1.root);
+
+    Bool_t JobA_MC  = kFALSE;  
+    Bool_t WMC1     = kFALSE;  // write out root file MC1.root ?
+
+
+    // Job B_RF_UP : read ON1.root (or MC1.root) file 
+    //  - if RTrainRF = TRUE : read in training matrices for hadrons and gammas
+    //  - if CTrainRF = TRUE : create  training matrices for hadrons and gammas
+    //  - if RTree    = TRUE : read in trees, otherwise create trees
+    //  - calculate hadroness for method of RANDOM FOREST
+    //  - update the input files with the hadroness (==>ON2.root or MC2.root)
+
+    Bool_t JobB_RF_UP  = kFALSE;  
+    Bool_t CTrainRF    = kFALSE;  // create matrices of training events
+    Bool_t RTrainRF    = kFALSE;  // read in matrices of training events
+    Bool_t RTree       = kFALSE;  // read in trees (otherwise grow them)
+    Bool_t WRF         = kFALSE;  // update input root file ?
+
+
+
+
+    // Job B_SC_UP : read ON2.root (or MC2.root) file 
+    //  - depending on WParSC : create (or read in) supercuts parameter values
+    //  - calculate hadroness for the SUPERCUTS
+    //  - update the input files with the hadroness (==>ON3.root or MC3.root)
+
+    Bool_t JobB_SC_UP  = kFALSE;
+    Bool_t CMatrix     = kFALSE;  // create training and test matrices 
+    Bool_t RMatrix     = kFALSE;  // read training and test matrices from file
+    Bool_t WOptimize   = kFALSE;  // do optimization using the training sample
+                                  // and write supercuts parameter values 
+                                  // onto the file parSCfile
+    Bool_t RTest       = kFALSE;  // test the supercuts using the test matrix
+    Bool_t WSC         = kFALSE;  // update input root file ?
+
+
+
+    // Job C: 
+    //  - read ON3.root and MC3.root files
+    //    which should have been updated to contain the hadronnesses  
+    //    for the method of 
+    //              RF
+    //              SUPERCUTS and
+    //  - produce Neyman-Pearson plots
+
+    Bool_t JobC  = kFALSE;  
+
+
+    // Job D :  
+    //  - select g/h separation method XX
+    //  - read ON3 (or MC3) root file
+    //  - apply cuts in hadronness
+    //  - make plots
+
+    Bool_t JobD  = kFALSE;  
+
+
+
+
+    // Job E_XX : extended version of E_XX (including flux plots)  
+    //  - select g/h separation method XX
+    //  - read MC root file 
+    //  - calculate eff. collection area
+    //  - optimize energy estimator
+    //  - read ON root file 
+    //  - apply final cuts
+    //  - calculate flux
+    //  - write root file for ON data after final cuts 
+
+
+    Bool_t JobE_XX  = kTRUE;  
+    Bool_t CCollArea= kFALSE;  // calculate eff. collection areas
+    Bool_t OEEst    = kFALSE;  // optimize energy estimator
+    Bool_t WEX      = kTRUE;  // update root file  ?
+    Bool_t WRobert  = kTRUE;  // write out Robert's file  ?
+
+
+
+    //************************************************************************
+
+    
+  //---------------------------------------------------------------------
+  // Job A_ON
+  //=========
+    // read ON data file 
+
+    //  - produce the 2D-histogram "sigmabar versus Theta" 
+    //    (SigmaTheta_ON.root) for ON data
+    //    (to be used for the padding of the MC gamma data)
+
+    //  - write a file of ON events (ON1.root) 
+    //    (after the standard cuts, before the g/h separation)
+    //    (to be used together with the corresponding MC gamma file (MC1.root)
+    //     for the optimization of the g/h separation)
+
+
+ if (JobA_ON)
+ {
+    gLog << "=====================================================" << endl;
+    gLog << "Macro CT1Analysis : Start of Job A_ON" << endl;
+    gLog << "" << endl;
+    gLog << "Macro CT1Analysis : JobA_ON, WHistON, WON1 = " 
+         << (JobA_ON ? "kTRUE" : "kFALSE")  << ",  " 
+         << (WHistON ? "kTRUE" : "kFALSE")  << ",  " 
+         << (WON1    ? "kTRUE" : "kFALSE")  << endl;
+
+
+    // name of input root file
+    TString filenamein(onfile);
+
+    // name of output root file
+    TString outNameImage = outPath;
+    outNameImage += "ON";
+    outNameImage += "1.root";
+
+    //--------------------------------------------------
+    // use for padding sigmabar vs. Theta from ON data
+    TString typeHist = "ON";
+    gLog << "typeHist = " << typeHist << endl;
+
+    // name of file to conatin the histograms for the padding
+    TString outNameSigTh = outPath;
+    outNameSigTh += "SigmaTheta_";
+    outNameSigTh += typeHist;
+    outNameSigTh += ".root";
+
+
+    //-----------------------------------------------------------
+    MTaskList tliston;
+    MParList pliston;
+
+    char *sourceName = "MSrcPosCam";
+    MSrcPosCam source(sourceName);
+
+    // geometry is needed in  MHHillas... classes 
+    MGeomCam *fGeom = 
+             (MGeomCam*)pliston->FindCreateObj("MGeomCamCT1", "MGeomCam");
+
+    //-------------------------------------------
+    // create the tasks which should be executed 
+    //
+
+    MCT1ReadPreProc read(filenamein);
+
+    MCT1PointingCorrCalc pointcorr(sourceName, "MCT1PointingCorrCalc", 
+                                               "MCT1PointingCorrCalc");
+    MBlindPixelCalc blind;
+    blind.SetUseBlindPixels();
+
+    MFCT1SelBasic selbasic;
+    MContinue contbasic(&selbasic);
+    contbasic.SetName("SelBasic");
+
+    MFillH fillblind("BlindPixels[MHBlindPixels]", "MBlindPixels");
+    fillblind.SetName("HBlind");
+
+    MSigmabarCalc sigbarcalc;
+
+    MFillH fillsigtheta ("SigmaTheta[MHSigmaTheta]", "MMcEvt");
+    fillsigtheta.SetName("HSigmaTheta");
+
+    MImgCleanStd    clean; 
+
+
+    // calculation of  image parameters ---------------------
+    TString fHilName    = "MHillas";
+    TString fHilNameExt = "MHillasExt";
+    TString fHilNameSrc = "MHillasSrc";
+    TString fImgParName = "MNewImagePar";
+
+    MHillasCalc    hcalc;
+    hcalc.SetNameHillas(fHilName);
+    hcalc.SetNameHillasExt(fHilNameExt);
+    hcalc.SetNameNewImgPar(fImgParName);
+
+    MHillasSrcCalc hsrccalc(sourceName, fHilNameSrc);
+    hsrccalc.SetInput(fHilName);
+
+    MFillH hfill1("MHHillas",    fHilName);
+    hfill1.SetName("HHillas");
+
+    MFillH hfill2("MHStarMap",   fHilName);
+    hfill2.SetName("HStarMap");
+
+    MFillH hfill3("MHHillasExt",   fHilNameSrc);
+    hfill3.SetName("HHillasExt");
+
+    MFillH hfill4("MHHillasSrc",   fHilNameSrc);
+    hfill4.SetName("HHillasSrc");
+
+    MFillH hfill5("MHNewImagePar", fImgParName);
+    hfill5.SetName("HNewImagePar");
+    // --------------------------------------------------
+
+    MFCT1SelStandard selstandard(fHilNameSrc);
+    selstandard.SetHillasName(fHilName);
+    selstandard.SetImgParName(fImgParName);
+    selstandard.SetCuts(92, 4, 60, 0.4, 1.05, 0.0, 0.0);
+    MContinue contstandard(&selstandard);
+    contstandard.SetName("SelStandard");
+
+      //MWriteRootFile &write = *(new MWriteRootFile(outNameImage));
+      MWriteRootFile write(outNameImage, "RECREATE");
+
+      write.AddContainer("MRawRunHeader", "RunHeaders");
+      write.AddContainer("MTime",         "Events");
+      write.AddContainer("MMcEvt",        "Events");
+      write.AddContainer("ThetaOrig",     "Events");
+      write.AddContainer("MSrcPosCam",    "Events");
+      write.AddContainer("MSigmabar",     "Events");
+      write.AddContainer("MHillas",       "Events");
+      write.AddContainer("MHillasExt",    "Events");
+      write.AddContainer("MHillasSrc",    "Events");
+      write.AddContainer("MNewImagePar",  "Events");
+
+
+    //$$$$$$$$$$$$$$$$$$$$$$$$$$$$
+    //MF daniel( "(MRawRunHeader.fRunNumber<13167)||(MRawRunHeader.fRunNumber>13167)" );
+    //MContinue contdaniel(&daniel);
+    //$$$$$$$$$$$$$$$$$$$$$$$$$$$$
+
+
+    //*****************************
+    // entries in MParList
+    
+    pliston.AddToList(&tliston);
+    InitBinnings(&pliston);
+
+    pliston.AddToList(&source);
+
+
+    //*****************************
+    // entries in MTaskList
+    
+    tliston.AddToList(&read);
+
+    //$$$$$$$$$$$$$$$$
+    //tliston.AddToList(&contdaniel);
+    //$$$$$$$$$$$$$$$$
+
+    tliston.AddToList(&pointcorr);
+    tliston.AddToList(&blind);
+
+    tliston.AddToList(&contbasic);
+    tliston.AddToList(&fillblind);
+    tliston.AddToList(&sigbarcalc);
+    tliston.AddToList(&fillsigtheta);
+    tliston.AddToList(&clean);
+
+    tliston.AddToList(&hcalc);
+    tliston.AddToList(&hsrccalc);
+
+    tliston.AddToList(&hfill1);
+    tliston.AddToList(&hfill2);
+    tliston.AddToList(&hfill3);
+    tliston.AddToList(&hfill4);
+    tliston.AddToList(&hfill5);
+
+    tliston.AddToList(&contstandard);
+    if (WON1)
+      tliston.AddToList(&write);
+
+    //*****************************
+
+    //-------------------------------------------
+    // Execute event loop
+    //
+    MProgressBar bar;
+    MEvtLoop evtloop;
+    evtloop.SetParList(&pliston);
+    //evtloop.ReadEnv(env, "", printEnv);
+    evtloop.SetProgressBar(&bar);
+    //if (WON1)
+    //  evtloop.Write();
+
+    Int_t maxevents = -1;
+    if ( !evtloop.Eventloop(maxevents) )
+        return;
+
+    tliston.PrintStatistics(0, kTRUE);
+
+
+    //-------------------------------------------
+    // Display the histograms
+
+    pliston.FindObject("SigmaTheta", "MHSigmaTheta")->DrawClone();
+
+    pliston.FindObject("BlindPixels", "MHBlindPixels")->DrawClone();
+
+    pliston.FindObject("MHHillas")->DrawClone();
+    pliston.FindObject("MHHillasExt")->DrawClone();
+    pliston.FindObject("MHHillasSrc")->DrawClone();
+    pliston.FindObject("MHNewImagePar")->DrawClone();
+    pliston.FindObject("MHStarMap")->DrawClone();
+
+
+
+    //-------------------------------------------
+    // Write histograms onto a file
+  if (WHistON)
+  {
+      MHSigmaTheta *sigtheta = 
+            (MHSigmaTheta*)pliston.FindObject("SigmaTheta");
+
+      MHBlindPixels *blindpixels = 
+            (MHBlindPixels*)pliston.FindObject("BlindPixels");
+      if (!sigtheta  ||  !blindpixels)
+	{
+          gLog << "Object 'SigmaTheta' or 'BlindPixels' not found" << endl;
+          return;
+	}
+      TH2D *fHSigTh    = sigtheta->GetSigmaTheta();
+      TH3D *fHSigPixTh = sigtheta->GetSigmaPixTheta();
+      TH3D *fHDifPixTh = sigtheta->GetDiffPixTheta();
+
+      TH2D *fHBlindId  = blindpixels->GetBlindId();
+      TH2D *fHBlindN   = blindpixels->GetBlindN();
+
+
+      TFile outfile(outNameSigTh, "RECREATE");
+      fHSigTh->Write();
+      fHSigPixTh->Write();
+      fHDifPixTh->Write();
+     
+      fHBlindId->Write();
+      fHBlindN->Write();
+
+      gLog << "" << endl;
+      gLog << "File " << outNameSigTh << " was written out" << endl;
+  }
+
+
+    DeleteBinnings(&pliston);
+
+    gLog << "Macro CT1Analysis : End of Job A_ON" << endl;
+    gLog << "===================================================" << endl;
+ }
+
+
+  //---------------------------------------------------------------------
+   // Job A_MC
+   //=========
+
+    // read MC gamma data  
+
+    //    - to pad them
+    //      (using the 2D-histogram "sigmabar versus Theta" 
+    //       (SigmaTheta_ON.root)  of the ON data)
+
+    //    - to write a file of padded MC gamma events (MC1.root)
+    //      (after the standard cuts, before the g/h separation)
+    //      (to be used together with the corresponding hadron file
+    //       for the optimization of the g/h separation)
+
+
+ if (JobA_MC)
+ {
+    gLog << "=====================================================" << endl;
+    gLog << "Macro CT1Analysis : Start of Job A_MC" << endl;
+
+    gLog << "" << endl;
+    gLog << "Macro CT1Analysis : JobA_MC, WMC1 = " 
+         << (JobA_MC ? "kTRUE" : "kFALSE")  << ",  " 
+         << (WMC1    ? "kTRUE" : "kFALSE")  << endl;
+
+
+    // name of input root file
+    TString filenamein(mcfile);
+
+    // name of output root file
+    TString outNameImage = outPath;
+    outNameImage += "MC";
+    outNameImage += "1.root";
+
+    //------------------------------------------------
+    // use for padding sigmabar vs. Theta from ON data
+    TString typeHist = "ON";
+    gLog << "typeHist = " << typeHist << endl;
+
+    // name of file containing the histograms for the padding
+    TString outNameSigTh = outPath;
+    outNameSigTh += "SigmaTheta_";
+    outNameSigTh += typeHist;
+    outNameSigTh += ".root";
+
+
+    //------------------------------------
+    // Get the histograms "2D-ThetaSigmabar"
+    // and                "3D-ThetaPixSigma"
+    // and                "3D-ThetaPixDiff"
+    // and                "2D-IdBlindPixels"
+    // and                "2D-NBlindPixels"
+
+
+      gLog << "Reading in file " << outNameSigTh << endl;
+
+      TFile *infile = new TFile(outNameSigTh);
+      infile->ls();
+
+      TH2D *fHSigmaTheta = 
+      (TH2D*) gROOT->FindObject("2D-ThetaSigmabar");
+      if (!fHSigmaTheta)
+	{
+          gLog << "Object '2D-ThetaSigmabar' not found on root file" << endl;
+          return;
+	}
+      gLog << "Object '2D-ThetaSigmabar' was read in" << endl;
+
+      TH3D *fHSigmaPixTheta = 
+      (TH3D*) gROOT->FindObject("3D-ThetaPixSigma");
+      if (!fHSigmaPixTheta)
+	{
+          gLog << "Object '3D-ThetaPixSigma' not found on root file" << endl;
+          return;
+	}
+      gLog << "Object '3D-ThetaPixSigma' was read in" << endl;
+
+      TH3D *fHDiffPixTheta = 
+      (TH3D*) gROOT->FindObject("3D-ThetaPixDiff");
+      if (!fHDiffPixTheta)
+	{
+          gLog << "Object '3D-ThetaPixDiff' not found on root file" << endl;
+          return;
+	}
+      gLog << "Object '3D-ThetaPixDiff' was read in" << endl;
+
+
+      TH2D *fHIdBlindPixels = 
+      (TH2D*) gROOT->FindObject("2D-IdBlindPixels");
+      if (!fHIdBlindPixels)
+	{
+          gLog << "Object '2D-IdBlindPixels' not found on root file" << endl;
+          return;
+	}
+      gLog << "Object '2D-IdBlindPixels' was read in" << endl;
+
+      TH2D *fHNBlindPixels = 
+      (TH2D*) gROOT->FindObject("2D-NBlindPixels");
+      if (!fHNBlindPixels)
+	{
+          gLog << "Object '2D-NBlindPixels' not found on root file" << endl;
+          return;
+	}
+      gLog << "Object '2D-NBlindPixels' was read in" << endl;
+
+    //------------------------------------
+
+    MTaskList tlist;
+    MParList plist;
+
+    char *sourceName = "MSrcPosCam";
+    MSrcPosCam source(sourceName);
+
+
+    // geometry is needed in  MHHillas... classes 
+    MGeomCam *fGeom = 
+             (MGeomCam*)plist->FindCreateObj("MGeomCamCT1", "MGeomCam");
+
+    //-------------------------------------------
+    // create the tasks which should be executed 
+    //
+
+    MCT1ReadPreProc read(filenamein);
+
+    MBlindPixelCalc blindbeforepad;
+    blindbeforepad.SetUseBlindPixels();
+    blindbeforepad.SetName("BlindBeforePadding");
+
+    MBlindPixelCalc blind;
+    blind.SetUseBlindPixels();
+    blind.SetName("BlindAfterPadding");
+
+    MFCT1SelBasic selbasic;
+    MContinue contbasic(&selbasic);
+    contbasic.SetName("SelBasic");
+
+
+    // There are 2 options for Thomas Schweizer's padding
+    //     fPadFlag = 1   get Sigmabar from fHSigmaTheta
+    //                    and Sigma    from fHDiffPixTheta
+    //     fPadFlag = 2   get Sigma    from fHSigmaPixTheta
+    
+    MCT1PadSchweizer padthomas("MCT1PadSchweizer","Task for the padding (Schweizer)");
+    padthomas.SetHistograms(fHSigmaTheta, fHSigmaPixTheta, fHDiffPixTheta,
+                            fHIdBlindPixels, fHNBlindPixels);
+    padthomas.SetPadFlag(1);
+
+    MFillH fillblind("MCBlindPixels[MHBlindPixels]", "MBlindPixels");
+    fillblind.SetName("HBlind");
+
+
+    //...........................................
+
+    MSigmabarCalc sigbarcalc;
+
+    MFillH fillsigtheta ("MCSigmaTheta[MHSigmaTheta]", "MMcEvt");
+    fillsigtheta.SetName("HSigmaTheta");
+
+    MImgCleanStd    clean; 
+
+    // calculation of  image parameters ---------------------
+    TString fHilName    = "MHillas";
+    TString fHilNameExt = "MHillasExt";
+    TString fHilNameSrc = "MHillasSrc";
+    TString fImgParName = "MNewImagePar";
+
+    MHillasCalc    hcalc;
+    hcalc.SetNameHillas(fHilName);
+    hcalc.SetNameHillasExt(fHilNameExt);
+    hcalc.SetNameNewImgPar(fImgParName);
+
+    MHillasSrcCalc hsrccalc(sourceName, fHilNameSrc);
+    hsrccalc.SetInput(fHilName);
+
+
+    MFillH hfill1("MHHillas",    fHilName);
+    hfill1.SetName("HHillas");
+
+    MFillH hfill2("MHStarMap",   fHilName);
+    hfill2.SetName("HStarMap");
+
+    MFillH hfill3("MHHillasExt",   fHilNameSrc);
+    hfill3.SetName("HHillasExt");
+
+    MFillH hfill4("MHHillasSrc",   fHilNameSrc);
+    hfill4.SetName("HHillasSrc");
+
+    MFillH hfill5("MHNewImagePar", fImgParName);
+    hfill5.SetName("HNewImagePar");
+    // --------------------------------------------------
+
+    MFCT1SelStandard selstandard(fHilNameSrc);
+    selstandard.SetHillasName(fHilName);
+    selstandard.SetImgParName(fImgParName);
+    selstandard.SetCuts(92, 4, 60, 0.4, 1.05, 0.0, 0.0);
+    MContinue contstandard(&selstandard);
+    contstandard.SetName("SelStandard");
+
+
+      //MWriteRootFile &write = *(new MWriteRootFile(outNameImage));
+      MWriteRootFile write(outNameImage, "RECREATE");
+
+      write.AddContainer("MRawRunHeader", "RunHeaders");
+      write.AddContainer("MTime",         "Events");
+      write.AddContainer("MMcEvt",        "Events");
+      write.AddContainer("ThetaOrig",     "Events");
+      write.AddContainer("MSrcPosCam",    "Events");
+      write.AddContainer("MSigmabar",     "Events");
+      write.AddContainer("MHillas",       "Events");
+      write.AddContainer("MHillasExt",    "Events");
+      write.AddContainer("MHillasSrc",    "Events");
+      write.AddContainer("MNewImagePar",  "Events");
+
+
+
+    //*****************************
+    // entries in MParList
+
+    plist.AddToList(&tlist);
+    InitBinnings(&plist);
+
+    plist.AddToList(&source);
+
+
+    //*****************************
+    // entries in MTaskList
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&blindbeforepad);
+    tlist.AddToList(&padthomas);
+    tlist.AddToList(&blind);
+
+    tlist.AddToList(&contbasic);
+    tlist.AddToList(&fillblind);
+    tlist.AddToList(&sigbarcalc);
+    tlist.AddToList(&fillsigtheta);
+    tlist.AddToList(&clean);
+
+    tlist.AddToList(&hcalc);
+    tlist.AddToList(&hsrccalc);
+
+    tlist.AddToList(&hfill1);
+    tlist.AddToList(&hfill2);
+    tlist.AddToList(&hfill3);
+    tlist.AddToList(&hfill4);
+    tlist.AddToList(&hfill5);
+
+    tlist.AddToList(&contstandard);
+    if (WMC1)
+      tlist.AddToList(&write);
+
+    //*****************************
+
+
+    //-------------------------------------------
+    // Execute event loop
+    //
+    MProgressBar bar;
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+    //evtloop.ReadEnv(env, "", printEnv);
+    evtloop.SetProgressBar(&bar);
+    //if (WMC1)    
+    //  evtloop.Write();
+
+    Int_t maxevents = -1;
+    //Int_t maxevents = 1000;
+    if ( !evtloop.Eventloop(maxevents) )
+        return;
+
+    tlist.PrintStatistics(0, kTRUE);
+
+
+    //-------------------------------------------
+    // Display the histograms
+    //
+
+    plist.FindObject("MCSigmaTheta",  "MHSigmaTheta")->DrawClone();
+    plist.FindObject("MCBlindPixels", "MHBlindPixels")->DrawClone();
+
+    plist.FindObject("MHHillas")->DrawClone();
+    plist.FindObject("MHHillasExt")->DrawClone();
+    plist.FindObject("MHHillasSrc")->DrawClone();
+    plist.FindObject("MHNewImagePar")->DrawClone();
+    plist.FindObject("MHStarMap")->DrawClone();
+
+
+
+    DeleteBinnings(&plist);
+
+    gLog << "Macro CT1Analysis : End of Job A_MC" 
+         << endl;
+    gLog << "=========================================================" 
+         << endl;
+ }
+
+
+
+  //---------------------------------------------------------------------
+  // Job B_RF_UP
+  //============
+
+
+    //  - create (or read in) the matrices of training events for gammas 
+    //    and hadrons
+    //  - create (or read in) the trees
+    //  - then read ON1.root (or MC1.root) file 
+    //  - calculate the hadroness for the method of RANDOM FOREST
+    //  - update input root file with the hadroness
+
+
+ if (JobB_RF_UP)
+ {
+    gLog << "=====================================================" << endl;
+    gLog << "Macro CT1Analysis : Start of Job B_RF_UP" << endl;
+
+    gLog << "" << endl;
+    gLog << "Macro CT1Analysis : JobB_RF_UP, RTrainRF, CTrainRF, RTree, WRF = "
+         << (JobB_RF_UP ? "kTRUE" : "kFALSE")  << ",  " 
+         << (RTrainRF ?   "kTRUE" : "kFALSE")  << ",  " 
+         << (CTrainRF ?   "kTRUE" : "kFALSE")  << ",  " 
+         << (RTree ?      "kTRUE" : "kFALSE")  << ",  "
+         << (WRF ?        "kTRUE" : "kFALSE")  << endl;
+
+
+    //--------------------------------------------
+    // parameters for the random forest
+    Int_t NumTrees = 100;
+    Int_t NumTry   =   3;
+    Int_t NdSize   =   1;
+
+
+    TString hadRFName = "HadRF";
+    Float_t maxhadronness =  0.23;
+    Float_t maxalpha      =  20.0;
+    Float_t maxdist       =  10.0;
+
+    TString fHilName    = "MHillas"; 
+    TString fHilNameExt = "MHillasExt"; 
+    TString fHilNameSrc = "MHillasSrc"; 
+    TString fImgParName = "MNewImagePar"; 
+
+
+    TString extin  = "1.root";
+    TString extout = "2.root";
+
+    //--------------------------------------------
+    // for the analysis using ON data only set typeMatrixHadrons = "ON"
+    //                        ON and OFF data                    = "OFF"
+    TString typeMatrixHadrons = "ON";
+    gLog << "typeMatrixHadrons = " << typeMatrixHadrons << endl;
+
+
+    // file to be updated (ON, OFF or MC)
+
+    //TString typeInput = "ON";
+    TString typeInput = "OFF";
+    //TString typeInput = "MC";
+    gLog << "typeInput = " << typeInput << endl;
+
+    // name of input root file
+    TString NameData = outPath;
+    NameData += typeInput;
+    TString inNameData(NameData);
+    inNameData += extin;
+    gLog << "inNameData = " << inNameData << endl; 
+
+    // name of output root file
+    TString outNameData(NameData);
+    outNameData += extout;
+    gLog << "outNameData = " << outNameData << endl; 
+
+    //--------------------------------------------
+    // files to be read for generating 
+    //    - the matrices of training events
+    //    - and the root files of training and test events
+
+
+    // "hadrons" :
+    TString filenameHad = outPath;
+    filenameHad += typeMatrixHadrons;
+    filenameHad += extin;
+    Int_t howManyHadronsTrain = 12000;
+    Int_t howManyHadronsTest  = 12000;
+    gLog << "filenameHad = "    << filenameHad << ",   howManyHadronsTrain = "
+         << howManyHadronsTrain << ",   howManyHadronsTest = "
+         << howManyHadronsTest  << endl; 
+    
+
+    // "gammas" :
+    TString filenameMC = outPath;
+    filenameMC += "MC";
+    filenameMC += extin;
+    Int_t howManyGammasTrain = 12000;
+    Int_t howManyGammasTest  = 12000;
+    gLog << "filenameMC = "    << filenameMC << ",   howManyGammasTrain = "
+         << howManyGammasTrain << ",   howManyGammasTest = "
+         << howManyGammasTest  << endl; 
+    
+    //--------------------------------------------
+    // files for the matrices of training events 
+
+    TString NameGammas = outPath;
+    NameGammas += "RFmatrix_gammas_Train_";
+    NameGammas += "MC";
+    NameGammas += extin;
+
+    TString NameHadrons = outPath;
+    NameHadrons += "RFmatrix_hadrons_Train_";
+    NameHadrons += typeMatrixHadrons;
+    NameHadrons += extin;
+
+
+    //--------------------------------------------
+    // root files for the training events 
+
+    TString NameGammasTrain = outPath;
+    NameGammasTrain += "RF_gammas_Train_";
+    NameGammasTrain += "MC";
+    TString inNameGammasTrain(NameGammasTrain);    
+    inNameGammasTrain += extin;
+    TString outNameGammasTrain(NameGammasTrain);    
+    outNameGammasTrain += extout;
+
+
+    TString NameHadronsTrain = outPath;
+    NameHadronsTrain += "RF_hadrons_Train_";
+    NameHadronsTrain += typeMatrixHadrons;
+    TString inNameHadronsTrain(NameHadronsTrain);    
+    inNameHadronsTrain += extin;
+    TString outNameHadronsTrain(NameHadronsTrain);    
+    outNameHadronsTrain += extout;
+
+
+    //--------------------------------------------
+    // root files for the test events 
+
+    TString NameGammasTest = outPath;
+    NameGammasTest += "RF_gammas_Test_";
+    NameGammasTest += "MC";
+    TString inNameGammasTest(NameGammasTest);    
+    inNameGammasTest += extin;
+    TString outNameGammasTest(NameGammasTest);    
+    outNameGammasTest += extout;
+
+    TString NameHadronsTest = outPath;
+    NameHadronsTest += "RF_hadrons_Test_";
+    NameHadronsTest += typeMatrixHadrons;
+    TString inNameHadronsTest(NameHadronsTest);    
+    inNameHadronsTest += extin;
+    TString outNameHadronsTest(NameHadronsTest);    
+    outNameHadronsTest += extout;
+
+    //--------------------------------------------------------------------
+
+
+    MHMatrix matrixg("MatrixGammas");
+    matrixg.EnableGraphicalOutput();
+
+    matrixg.AddColumn("cos(MMcEvt.fTelescopeTheta)");
+    matrixg.AddColumn("MSigmabar.fSigmabar");
+    matrixg.AddColumn("log10(MHillas.fSize)");
+    matrixg.AddColumn("MHillasSrc.fDist");
+    matrixg.AddColumn("MHillas.fWidth");
+    matrixg.AddColumn("MHillas.fLength");
+    matrixg.AddColumn("log10(MHillas.fSize/(MHillas.fWidth*MHillas.fLength))");
+    matrixg.AddColumn("sgn(MHillasSrc.fCosDeltaAlpha)*(MHillasExt.fM3Long)");
+    matrixg.AddColumn("MNewImagePar.fConc");
+    matrixg.AddColumn("MNewImagePar.fLeakage1");
+
+    MHMatrix matrixh("MatrixHadrons");
+    matrixh.EnableGraphicalOutput();
+
+    matrixh.AddColumns(matrixg.GetColumns());
+
+    //--------------------------------------------
+    // file of trees of the random forest 
+
+    TString outRF = outPath;
+    outRF += "RF.root";
+
+
+   //*************************************************************************
+   // read in matrices of training events
+if (RTrainRF)
+  {
+    const char* mtxName = "MatrixGammas";
+
+    gLog << "" << endl;
+    gLog << "========================================================" << endl;
+    gLog << "Get matrix for (gammas)" << endl;
+    gLog << "matrix name        = " << mtxName << endl;
+    gLog << "name of root file  = " << NameGammas << endl;
+    gLog << "" << endl;
+
+
+    // read in the object with the name 'mtxName' from file 'NameGammas'
+    //
+    TFile fileg(NameGammas); 
+
+    matrixg.Read(mtxName);
+    matrixg.Print("SizeCols");
+
+
+    //***************************************************************** 
+
+    const char* mtxName = "MatrixHadrons";
+
+    gLog << "" << endl;
+    gLog << "========================================================" << endl;
+    gLog << " Get matrix for (hadrons)" << endl;
+    gLog << "matrix name        = " << mtxName << endl;
+    gLog << "name of root file  = " << NameHadrons << endl;
+    gLog << "" << endl;
+
+
+    // read in the object with the name 'mtxName' from file 'NameHadrons'
+    //
+    TFile fileh(NameHadrons); 
+
+    matrixh.Read(mtxName);
+    matrixh.Print("SizeCols");
+  }
+
+
+   //*************************************************************************
+   // create matrices of training events
+   // and root files of training and test events
+ 
+if (CTrainRF)
+  {
+    gLog << "" << endl;
+    gLog << "========================================================" << endl;
+    gLog << " Create matrices of training events and root files of training and test events" 
+         << endl;
+    gLog << " Gammas :" << endl;
+    gLog << "---------" << endl;
+
+    MParList  plistg;
+    MTaskList tlistg;
+
+    MReadMarsFile  readg("Events", filenameMC);
+    readg.DisableAutoScheme();
+
+    TString mgname("costhg");
+    MBinning bing("Binning"+mgname);
+    bing.SetEdges(10, 0., 1.0);
+
+    MH3 gref("cos(MMcEvt.fTelescopeTheta)");
+    gref.SetName(mgname);
+    MH::SetBinning(&gref.GetHist(), &bing);
+    //for (Int_t i=1; i<=gref.GetNbins(); i++)
+    //  gref.GetHist().SetBinContent(i, 1.0);
+
+    MFEventSelector2 selectorg(gref);
+    selectorg.SetNumMax(howManyGammasTrain+howManyGammasTest);
+    selectorg.SetName("selectGammasTrainTest");
+    selectorg.SetInverted();
+    //selectorg.SetUseOrigDistribution(kTRUE);
+
+    MContinue contg(&selectorg);
+    contg.SetName("ContGammas");
+
+    Double_t probg = ( (Double_t) howManyGammasTrain )
+                   / ( (Double_t)(howManyGammasTrain+howManyGammasTest) );
+    MFRandomSplit splitg(probg);
+
+    MFillH fillmatg("MatrixGammas");
+    fillmatg.SetFilter(&splitg);
+    fillmatg.SetName("fillGammas");
+
+    //-----------------------
+    // for writing the root files of training and test events
+    // for gammas
+    
+    MWriteRootFile writetraing(inNameGammasTrain, "RECREATE");
+    writetraing.SetName("WriteGammasTrain");
+    writetraing.SetFilter(&splitg);
+
+      writetraing.AddContainer("MRawRunHeader", "RunHeaders");
+      writetraing.AddContainer("MTime",         "Events");
+      writetraing.AddContainer("MMcEvt",        "Events");
+      writetraing.AddContainer("ThetaOrig",     "Events");
+      writetraing.AddContainer("MSrcPosCam",    "Events");
+      writetraing.AddContainer("MSigmabar",     "Events");
+      writetraing.AddContainer("MHillas",       "Events");
+      writetraing.AddContainer("MHillasExt",    "Events");
+      writetraing.AddContainer("MHillasSrc",    "Events");
+      writetraing.AddContainer("MNewImagePar",  "Events");
+
+    MContinue contgtrain(&splitg);
+    contgtrain.SetName("ContGammaTrain");
+
+    MWriteRootFile writetestg(inNameGammasTest, "RECREATE");
+    writetestg.SetName("WriteGammasTest");
+
+      writetestg.AddContainer("MRawRunHeader", "RunHeaders");
+      writetestg.AddContainer("MTime",         "Events");
+      writetestg.AddContainer("MMcEvt",        "Events");
+      writetestg.AddContainer("ThetaOrig",     "Events");
+      writetestg.AddContainer("MSrcPosCam",    "Events");
+      writetestg.AddContainer("MSigmabar",     "Events");
+      writetestg.AddContainer("MHillas",       "Events");
+      writetestg.AddContainer("MHillasExt",    "Events");
+      writetestg.AddContainer("MHillasSrc",    "Events");
+      writetestg.AddContainer("MNewImagePar",  "Events");
+
+    //-----------------------
+    
+    //*****************************   fill gammas   ***  
+    // entries in MParList
+    
+    plistg.AddToList(&tlistg);
+    InitBinnings(&plistg);
+
+    plistg.AddToList(&matrixg);
+
+    //*****************************
+    // entries in MTaskList
+    
+    tlistg.AddToList(&readg);
+    tlistg.AddToList(&contg);
+
+    tlistg.AddToList(&splitg);
+    tlistg.AddToList(&fillmatg);
+    tlistg.AddToList(&writetraing);
+    tlistg.AddToList(&contgtrain);
+
+    tlistg.AddToList(&writetestg);
+
+    //*****************************
+
+    MProgressBar matrixbar;
+    MEvtLoop evtloopg;
+    evtloopg.SetName("FillGammaMatrix");
+    evtloopg.SetParList(&plistg);
+    //evtloopg.ReadEnv(env, "", printEnv);
+    evtloopg.SetProgressBar(&matrixbar);
+
+    Int_t maxevents = -1;
+    if (!evtloopg.Eventloop(maxevents))
+        return;
+
+    tlistg.PrintStatistics(0, kTRUE);
+
+    matrixg.Print("SizeCols");
+    Int_t generatedgTrain = matrixg.GetM().GetNrows();
+    if ( fabs(generatedgTrain-howManyGammasTrain) > 
+                                    3.0*sqrt(howManyGammasTrain) )
+    {
+      gLog << "ONOFFCT1Analysis.C : no.of generated gamma training events (" 
+           << generatedgTrain << ") is incompatible with the no.of requested events (" 
+           << howManyGammasTrain << ")" << endl;   
+    }
+
+
+    Int_t generatedgTest = writetestg.GetNumExecutions();
+    if ( fabs(generatedgTest-howManyGammasTest) > 
+                                    3.0*sqrt(howManyGammasTest) )
+    {
+      gLog << "ONOFFCT1Analysis.C : no.of generated gamma test events (" 
+           << generatedgTest << ") is incompatible with the no.of requested events (" 
+           << howManyGammasTest << ")" << endl;   
+    }
+
+    //*****************************   fill hadrons   ***  
+    gLog << "---------------------------------------------------------------"
+         << endl;
+    gLog << " Hadrons :" << endl;
+    gLog << "----------" << endl;
+
+    MParList  plisth;
+    MTaskList tlisth;
+
+    MReadMarsFile  readh("Events", filenameHad);
+    readh.DisableAutoScheme();
+
+    TString mhname("costhh");
+    MBinning binh("Binning"+mhname);
+    binh.SetEdges(10, 0., 1.0);
+
+    //MH3 href("cos(MMcEvt.fTelescopeTheta)");
+    //href.SetName(mhname);
+    //MH::SetBinning(&href.GetHist(), &binh);
+    //for (Int_t i=1; i<=href.GetNbins(); i++)
+    //  href.GetHist().SetBinContent(i, 1.0);
+
+    //use the original distribution from the gammas
+    MH3 &href = *(selectorg.GetHistOrig());
+
+    MFEventSelector2 selectorh(href);
+    selectorh.SetNumMax(howManyHadronsTrain+howManyHadronsTest);
+    selectorh.SetName("selectHadronsTrainTest");
+    selectorh.SetInverted();
+
+    MContinue conth(&selectorh);
+    conth.SetName("ContHadrons");
+
+    Double_t probh = ( (Double_t) howManyHadronsTrain )
+                   / ( (Double_t)(howManyHadronsTrain+howManyHadronsTest) );
+    MFRandomSplit splith(probh);
+
+    MFillH fillmath("MatrixHadrons");
+    fillmath.SetFilter(&splith);
+    fillmath.SetName("fillHadrons");
+
+    //-----------------------
+    // for writing the root files of training and test events
+    // for hadrons
+    
+    MWriteRootFile writetrainh(inNameHadronsTrain, "RECREATE");
+    writetrainh.SetName("WriteHadronsTrain");
+    writetrainh.SetFilter(&splith);
+
+      writetrainh.AddContainer("MRawRunHeader", "RunHeaders");
+      writetrainh.AddContainer("MTime",         "Events");
+      writetrainh.AddContainer("MMcEvt",        "Events");
+      writetrainh.AddContainer("ThetaOrig",     "Events");
+      writetrainh.AddContainer("MSrcPosCam",    "Events");
+      writetrainh.AddContainer("MSigmabar",     "Events");
+      writetrainh.AddContainer("MHillas",       "Events");
+      writetrainh.AddContainer("MHillasExt",    "Events");
+      writetrainh.AddContainer("MHillasSrc",    "Events");
+      writetrainh.AddContainer("MNewImagePar",  "Events");
+
+    MContinue conthtrain(&splith);
+
+    MWriteRootFile writetesth(inNameHadronsTest, "RECREATE");
+    writetesth.SetName("WriteHadronsTest");
+
+      writetesth.AddContainer("MRawRunHeader", "RunHeaders");
+      writetesth.AddContainer("MTime",         "Events");
+      writetesth.AddContainer("MMcEvt",        "Events");
+      writetesth.AddContainer("ThetaOrig",     "Events");
+      writetesth.AddContainer("MSrcPosCam",    "Events");
+      writetesth.AddContainer("MSigmabar",     "Events");
+      writetesth.AddContainer("MHillas",       "Events");
+      writetesth.AddContainer("MHillasExt",    "Events");
+      writetesth.AddContainer("MHillasSrc",    "Events");
+      writetesth.AddContainer("MNewImagePar",  "Events");
+
+
+    //*****************************  
+    // entries in MParList
+    
+    plisth.AddToList(&tlisth);
+    InitBinnings(&plisth);
+
+    plisth.AddToList(&matrixh);
+
+    //*****************************
+    // entries in MTaskList
+    
+    tlisth.AddToList(&readh);
+    tlisth.AddToList(&conth);
+
+    tlisth.AddToList(&splith);
+    tlisth.AddToList(&fillmath);
+    tlisth.AddToList(&writetrainh);
+    tlisth.AddToList(&conthtrain);
+
+    tlisth.AddToList(&writetesth);
+
+    //*****************************
+
+    MProgressBar matrixbar;
+    MEvtLoop evtlooph;
+    evtlooph.SetName("FillHadronMatrix");
+    evtlooph.SetParList(&plisth);
+    //evtlooph.ReadEnv(env, "", printEnv);
+    evtlooph.SetProgressBar(&matrixbar);
+
+    Int_t maxevents = -1;
+    if (!evtlooph.Eventloop(maxevents))
+        return;
+
+    tlisth.PrintStatistics(0, kTRUE);
+
+    matrixh.Print("SizeCols");
+    Int_t generatedhTrain = matrixh.GetM().GetNrows();
+    if ( fabs(generatedhTrain-howManyHadronsTrain) > 
+                                    3.0*sqrt(howManyHadronsTrain) )
+    {
+      gLog << "ONOFFCT1Analysis.C : no.of generated hadron training events (" 
+           << generatedhTrain << ") is incompatible with the no.of requested events (" 
+           << howManyHadronsTrain << ")" << endl;   
+    }
+
+
+    Int_t generatedhTest = writetesth.GetNumExecutions();
+    if ( fabs(generatedhTest-howManyHadronsTest) > 
+                                    3.0*sqrt(howManyHadronsTest) )
+    {
+      gLog << "ONOFFCT1Analysis.C : no.of generated gamma test events (" 
+           << generatedhTest << ") is incompatible with the no.of requested events (" 
+           << howManyHadronsTest << ")" << endl;   
+    }
+
+
+    //*****************************************************  
+
+
+    // write out matrices of training events 
+
+    gLog << "" << endl;
+    gLog << "========================================================" << endl;
+    gLog << "Write out matrices of training events" << endl;
+
+
+      //-------------------------------------------
+      // "gammas"
+      gLog << "Gammas :" << endl;    
+      matrixg.Print("SizeCols");
+
+      TFile writeg(NameGammas, "RECREATE", "");
+      matrixg.Write();
+
+      gLog << "" << endl;
+      gLog << "Macro CT1Analysis : matrix of training events for gammas written onto file "
+           << NameGammas << endl;
+
+      //-------------------------------------------
+      // "hadrons"
+      gLog << "Hadrons :" << endl;    
+      matrixh.Print("SizeCols");
+
+      TFile writeh(NameHadrons, "RECREATE", "");
+      matrixh.Write();
+
+      gLog << "" << endl;
+      gLog << "Macro CT1Analysis : matrix of training events for hadrons written onto file "
+           << NameHadrons << endl;
+
+  }
+   //**********   end of creating matrices of training events   ***********
+
+
+    MRanForest *fRanForest;
+    MRanTree *fRanTree;
+    //-----------------------------------------------------------------
+    // read in the trees of the random forest 
+    if (RTree)
+    {
+      MParList plisttr;
+      MTaskList tlisttr;
+      plisttr.AddToList(&tlisttr);
+
+      MReadTree readtr("TREE", outRF);
+      readtr.DisableAutoScheme();
+
+      MRanForestFill rffill;
+      rffill.SetNumTrees(NumTrees);
+
+      // list of tasks for the loop over the trees
+
+      tlisttr.AddToList(&readtr);
+      tlisttr.AddToList(&rffill);
+
+      //-------------------
+      // Execute tree loop
+      //
+      MEvtLoop evtlooptr;
+      evtlooptr.SetName("ReadRFTrees");
+      evtlooptr.SetParList(&plisttr);
+      if (!evtlooptr.Eventloop())
+        return;
+
+      tlisttr.PrintStatistics(0, kTRUE);
+
+      gLog << "ONOFFCT1Analysis : RF trees were read in from file "
+           << outRF << endl;
+
+    // get adresses of objects which are used in the next eventloop
+    fRanForest = (MRanForest*)plisttr->FindObject("MRanForest");
+    if (!fRanForest)
+    {
+        gLog << err << dbginf << "MRanForest not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fRanTree = (MRanTree*)plisttr->FindObject("MRanTree");
+    if (!fRanTree)                                  
+    {                                                                          
+        gLog << err << dbginf << "MRanTree not found... aborting." << endl;    
+        return kFALSE;
+    }
+
+    }
+
+    //-----------------------------------------------------------------
+    // grow the trees of the random forest (event loop = tree loop)
+
+    if (!RTree)
+    {
+
+    gLog << "" << endl;
+    gLog << "========================================================" << endl;
+    gLog << "Macro CT1Analysis : start growing trees" << endl;
+
+    MTaskList tlist2;
+    MParList plist2;
+    plist2.AddToList(&tlist2);
+
+    plist2.AddToList(&matrixg);
+    plist2.AddToList(&matrixh);
+
+    MRanForestGrow rfgrow2;
+    rfgrow2.SetNumTrees(NumTrees);
+    rfgrow2.SetNumTry(NumTry);
+    rfgrow2.SetNdSize(NdSize);
+
+    MWriteRootFile rfwrite2(outRF);
+    rfwrite2.AddContainer("MRanTree", "TREE");
+
+    MFillH fillh2("MHRanForestGini");
+
+    // list of tasks for the loop over the trees
+    
+    tlist2.AddToList(&rfgrow2);
+    tlist2.AddToList(&rfwrite2);
+    tlist2.AddToList(&fillh2);
+
+    //-------------------
+    // Execute tree loop
+    //
+    MEvtLoop treeloop;
+    treeloop.SetName("GrowRFTrees");
+    treeloop.SetParList(&plist2);
+
+    if ( !treeloop.Eventloop() )
+        return;
+
+    tlist2.PrintStatistics(0, kTRUE);
+
+    plist2.FindObject("MHRanForestGini")->DrawClone();
+
+
+    // get adresses of objects which are used in the next eventloop
+    fRanForest = (MRanForest*)plist2->FindObject("MRanForest");
+    if (!fRanForest)
+    {
+        gLog << err << dbginf << "MRanForest not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fRanTree = (MRanTree*)plist2->FindObject("MRanTree");
+    if (!fRanTree)                                  
+    {                                                                          
+        gLog << err << dbginf << "MRanTree not found... aborting." << endl;    
+        return kFALSE;
+    }
+
+    }
+    // end of growing the trees of the random forest
+    //-----------------------------------------------------------------
+
+
+    //-----------------------------------------------------------------
+    // Update the root files with the RF hadronness
+    //
+
+ if (WRF)
+  {
+    //TString fileName(inNameHadronsTrain);
+    //TString outName(outNameHadronsTrain);
+
+    //TString fileName(inNameHadronsTest);
+    //TString outName(outNameHadronsTest);
+
+    //TString fileName(inNameGammasTrain);
+    //TString outName(outNameGammasTrain);
+
+    //TString fileName(inNameGammasTest);
+    //TString outName(outNameGammasTest);
+
+    TString fileName(inNameData);
+    TString outName(outNameData);
+
+
+
+    gLog << "" << endl;
+    gLog << "========================================================" << endl;
+    gLog << "Update root file '" <<  fileName 
+         << "' with the RF hadronness; ==> " << outName << endl;
+
+   
+    MTaskList tliston;
+    MParList pliston;
+
+
+    // geometry is needed in  MHHillas... classes 
+    MGeomCam *fGeom = 
+             (MGeomCam*)pliston->FindCreateObj("MGeomCamCT1", "MGeomCam");
+
+    //-------------------------------------------
+    // create the tasks which should be executed 
+    //
+
+    MReadMarsFile read("Events", fileName);
+    read.DisableAutoScheme();
+
+
+    //.......................................................................
+    // calculate hadronnes for method of RANDOM FOREST
+
+
+    MRanForestCalc rfcalc;
+    rfcalc.SetHadronnessName(hadRFName);
+
+
+    //.......................................................................
+
+      //MWriteRootFile write(outName, "UPDATE");
+      MWriteRootFile write(outName, "RECREATE");
+
+      write.AddContainer("MRawRunHeader", "RunHeaders");
+      write.AddContainer("MTime",         "Events");
+      write.AddContainer("MMcEvt",        "Events");
+      write.AddContainer("ThetaOrig",     "Events");
+      write.AddContainer("MSrcPosCam",    "Events");
+      write.AddContainer("MSigmabar",     "Events");
+      write.AddContainer("MHillas",       "Events");
+      write.AddContainer("MHillasExt",    "Events");
+      write.AddContainer("MHillasSrc",    "Events");
+      write.AddContainer("MNewImagePar",  "Events");
+
+      write.AddContainer(hadRFName,       "Events");
+
+    //-----------------------------------------------------------------
+
+
+    MFCT1SelFinal selfinalgh(fHilNameSrc);
+    selfinalgh.SetCuts(maxhadronness, 100.0, maxdist);
+    selfinalgh.SetHadronnessName(hadRFName);
+    selfinalgh.SetName("SelFinalgh");
+    MContinue contfinalgh(&selfinalgh);
+    contfinalgh.SetName("ContSelFinalgh");
+
+    MFillH fillranfor("MHRanForest");
+    fillranfor.SetName("HRanForest");
+
+    MFillH fillhadrf("hadRF[MHHadronness]", hadRFName);
+    fillhadrf.SetName("HhadRF");
+
+    MFCT1SelFinal selfinal(fHilNameSrc);
+    selfinal.SetCuts(maxhadronness, maxalpha, maxdist);
+    selfinal.SetHadronnessName(hadRFName);
+    selfinal.SetName("SelFinal");
+    MContinue contfinal(&selfinal);
+    contfinal.SetName("ContSelFinal");
+
+    TString mh3name = "abs(Alpha)";
+    MBinning binsalphaabs("Binning"+mh3name);
+    binsalphaabs.SetEdges(50, -2.0, 98.0);
+
+    MH3 alphaabs("abs(MHillasSrc.fAlpha)");
+    alphaabs.SetName(mh3name);
+    MFillH alpha(&alphaabs);
+    alpha.SetName("FillAlphaAbs");
+
+
+    MFillH hfill1("MHHillas",    fHilName);
+    hfill1.SetName("HHillas");
+
+    MFillH hfill2("MHStarMap",   fHilName);
+    hfill2.SetName("HStarMap");
+
+    MFillH hfill3("MHHillasExt",    fHilNameSrc);
+    hfill3.SetName("HHillasExt");
+    
+    MFillH hfill4("MHHillasSrc",   fHilNameSrc);
+    hfill4.SetName("HHillasSrc");    
+
+    MFillH hfill5("MHNewImagePar", fImgParName);
+    hfill5.SetName("HNewImagePar");
+
+    //*****************************
+    // entries in MParList
+
+    pliston.AddToList(&tliston);
+    InitBinnings(&pliston);
+
+    pliston.AddToList(fRanForest);
+    pliston.AddToList(fRanTree);
+
+    pliston.AddToList(&binsalphaabs);
+    pliston.AddToList(&alphaabs);
+
+
+    //*****************************
+    // entries in MTaskList
+    
+    tliston.AddToList(&read);
+
+    tliston.AddToList(&rfcalc);
+    tliston.AddToList(&fillranfor);
+    tliston.AddToList(&fillhadrf);
+
+    tliston.AddToList(&write);
+    tliston.AddToList(&contfinalgh);
+
+    tliston.AddToList(&alpha);
+    tliston.AddToList(&hfill1);
+    tliston.AddToList(&hfill2);
+    tliston.AddToList(&hfill3);
+    tliston.AddToList(&hfill4);
+    tliston.AddToList(&hfill5);
+
+    tliston.AddToList(&contfinal);
+
+    //*****************************
+
+    //-------------------------------------------
+    // Execute event loop
+    //
+    MProgressBar bar;
+    MEvtLoop evtloop;
+    evtloop.SetName("UpdateRootFile");
+    evtloop.SetParList(&pliston);
+    evtloop.SetProgressBar(&bar);
+
+    Int_t maxevents = -1;
+    if ( !evtloop.Eventloop(maxevents) )
+        return;
+
+    tliston.PrintStatistics(0, kTRUE);
+
+
+    //-------------------------------------------
+    // Display the histograms
+    //
+    pliston.FindObject("MHRanForest")->DrawClone();
+    pliston.FindObject("hadRF", "MHHadronness")->DrawClone();
+    pliston.FindObject("hadRF", "MHHadronness")->Print();
+
+    pliston.FindObject("MHHillas")->DrawClone();
+    pliston.FindObject("MHHillasExt")->DrawClone();
+    pliston.FindObject("MHHillasSrc")->DrawClone();
+    pliston.FindObject("MHNewImagePar")->DrawClone();
+    pliston.FindObject("MHStarMap")->DrawClone();
+
+
+     //-------------------------------------------
+    // fit alpha distribution to get the number of excess events and
+    // calculate significance of gamma signal in the alpha plot
+  
+    MH3* absalpha = (MH3*)(pliston.FindObject(mh3name, "MH3"));
+    TH1  &alphaHist = absalpha->GetHist();
+    alphaHist.SetXTitle("|alpha|  [\\circ]");
+    alphaHist.SetName("alpha-macro");
+
+    Double_t alphasig = 13.1;
+    Double_t alphamin = 30.0;
+    Double_t alphamax = 90.0;
+    Int_t    degree   =    2;
+    Double_t significance = -99.0;
+    Bool_t   drawpoly  = kTRUE;
+    Bool_t   fitgauss  = kTRUE;
+    Bool_t   print     = kTRUE;
+
+    MHFindSignificance findsig;
+    findsig.SetRebin(kTRUE);
+    findsig.SetReduceDegree(kFALSE);
+
+    findsig.FindSigma(&alphaHist, alphamin, alphamax, degree, 
+                        alphasig, drawpoly, fitgauss, print);
+    significance = findsig.GetSignificance();
+    Float_t alphasi = findsig.GetAlphasi();
+
+    gLog << "For file '" << fileName << "' : " << endl;
+    gLog << "Significance of gamma signal after supercuts : "
+         << significance << " (for |alpha| < " << alphasi << " degrees)" 
+         << endl;
+
+    findsig.SigmaVsAlpha(&alphaHist, alphamin, alphamax, degree, print);
+
+    //-------------------------------------------
+
+
+    DeleteBinnings(&pliston);
+  }
+
+    gLog << "Macro CT1Analysis : End of Job B_RF_UP" << endl;
+    gLog << "=======================================================" << endl;
+ }
+  //---------------------------------------------------------------------
+
+
+  //---------------------------------------------------------------------
+  // Job B_SC_UP
+  //============
+
+    //  - create (or read in) optimum supercuts parameter values
+    //
+    //  - calculate the hadroness for the supercuts
+    //
+    //  - update input root file, including the hadroness
+
+
+ if (JobB_SC_UP)
+ {
+    gLog << "=====================================================" << endl;
+    gLog << "Macro CT1Analysis : Start of Job B_SC_UP" << endl;
+
+    gLog << "" << endl;
+    gLog << "Macro CT1Analysis : JobB_SC_UP, CMatrix, RMatrix, WOptimize, RTest, WSC = "
+         << (JobB_SC_UP ? "kTRUE" : "kFALSE")  << ",  " 
+         << (CMatrix    ? "kTRUE" : "kFALSE")  << ",  "
+         << (RMatrix    ? "kTRUE" : "kFALSE")  << ",  "
+         << (WOptimize  ? "kTRUE" : "kFALSE")  << ",  "
+         << (RTest      ? "kTRUE" : "kFALSE")  << ",  "
+         << (WSC        ? "kTRUE" : "kFALSE")  << endl;
+
+
+    //--------------------------------------------
+    // file which contains the initial parameter values for the supercuts 
+    // if parSCinit ="" the initial values are taken from the constructor of
+    //                  MCT1Supercuts
+
+    TString parSCinit = outPath;
+    //parSCinit += "parSC_1709d";
+    parSCinit = "";
+
+    gLog << "parSCinit = " << parSCinit << endl;
+
+    //---------------
+    // file onto which the optimal parameter values for the supercuts 
+    // are written
+
+    TString parSCfile = outPath;
+    parSCfile += "parSC_2310a";
+
+    gLog << "parSCfile = " << parSCfile << endl;
+
+    //--------------------------------------------
+    // file to be updated (either ON or MC)
+
+    //TString typeInput = "ON";
+    //TString typeInput = "OFF";
+    TString typeInput = "MC";
+    gLog << "typeInput = " << typeInput << endl;
+
+    // name of input root file
+    TString filenameData = outPath;
+    filenameData += typeInput;
+    filenameData += "2.root";
+    gLog << "filenameData = " << filenameData << endl; 
+
+    // name of output root file
+    TString outNameImage = outPath;
+    outNameImage += typeInput;
+    outNameImage += "3.root";
+    
+
+    //TString outNameImage = filenameData;
+
+    gLog << "outNameImage = " << outNameImage << endl; 
+
+    //--------------------------------------------
+    // files to be read for optimizing the supercuts
+    // 
+    // for the training
+    TString filenameTrain = outPath;
+    filenameTrain += "ON";
+    filenameTrain += "1.root";
+    Int_t howManyTrain = 800000;
+    gLog << "filenameTrain = " << filenameTrain << ",   howManyTrain = "
+         << howManyTrain  << endl; 
+
+    // for testing
+    TString filenameTest = outPath;
+    filenameTest += "ON";
+    filenameTest += "1.root";
+    Int_t howManyTest = 800000;
+
+    gLog << "filenameTest = " << filenameTest << ",   howManyTest = "
+         << howManyTest  << endl; 
+    
+
+    //--------------------------------------------
+    // files to contain the matrices (generated from filenameTrain and
+    //                                               filenameTest)
+    // 
+    // for the training
+    TString fileMatrixTrain = outPath;
+    fileMatrixTrain += "MatrixTrainSC";
+    fileMatrixTrain += ".root";
+    gLog << "fileMatrixTrain = " << fileMatrixTrain << endl; 
+
+    // for testing
+    TString fileMatrixTest = outPath;
+    fileMatrixTest += "MatrixTestSC";
+    fileMatrixTest += ".root";
+    gLog << "fileMatrixTest = " << fileMatrixTest << endl; 
+
+    
+
+    //---------------------------------------------------------------------
+    // Training and test matrices :
+    // - either create them and write them onto a file
+    // - or read them from a file
+
+
+    MCT1FindSupercuts findsuper;
+    findsuper.SetFilenameParam(parSCfile);
+    findsuper.SetHadronnessName("HadSC");
+    //findsuper.SetUseOrigDistribution(kTRUE);
+
+    //--------------------------
+    // create matrices and write them onto files 
+    if (CMatrix)
+    {
+      TString mname("costheta");
+      MBinning bin("Binning"+mname);
+      bin.SetEdges(10, 0., 1.0);
+
+      MH3 mh3("cos(MMcEvt.fTelescopeTheta)");
+      mh3.SetName(mname);
+      MH::SetBinning(&mh3.GetHist(), &bin);
+      //for (Int_t i=1; i<=mh3.GetNbins(); i++)
+      //  mh3.GetHist().SetBinContent(i, 1.0);
+
+
+      if (filenameTrain == filenameTest)
+      {
+        if ( !findsuper.DefineTrainTestMatrix(
+                              filenameTrain,   mh3, 
+                              howManyTrain,    howManyTest,  
+                              fileMatrixTrain, fileMatrixTest)     )
+        {
+          *fLog << "CT1Analysis.C : DefineTrainTestMatrix failed" << endl;
+          return;
+        }
+
+      }
+      else
+      {
+        if ( !findsuper.DefineTrainMatrix(filenameTrain, mh3,
+                                          howManyTrain,  fileMatrixTrain) )
+        {
+          *fLog << "CT1Analysis.C : DefineTrainMatrix failed" << endl;
+          return;
+        }
+
+	if ( !findsuper.DefineTestMatrix( filenameTest, mh3, 
+                                          howManyTest,  fileMatrixTest)  )
+        {
+          *fLog << "CT1Analysis.C : DefineTestMatrix failed" << endl;
+          return;
+        }
+      }
+     }
+
+    //--------------------------
+    // read matrices from files
+    //                              
+
+    if (RMatrix)
+      findsuper.ReadMatrix(fileMatrixTrain, fileMatrixTest);
+    //--------------------------
+
+
+
+    //---------------------------------------------------------------------
+    // optimize supercuts using the training sample
+    // 
+    // the initial values are taken 
+    //     - from the file parSCinit (if != "")
+    //     - or from the arrays params and steps (if their sizes are != 0)
+    //     - or from the MCT1Supercuts constructor
+
+
+if (WOptimize)
+  {
+    gLog << "CT1Analysis.C : optimize the supercuts using the training matrix" 
+         << endl;
+
+    TArrayD params(0);
+    TArrayD steps(0);
+  
+    if (parSCinit == "")
+    {
+      Double_t vparams[104] = {
+      // LengthUp
+	0.315585,  0.001455, 0.203198, 0.005532, -0.001670, -0.020362,
+	0.007388, -0.013463,
+      // LengthLo
+        0.151530,  0.028323, 0.510707, 0.053089,  0.013708,  2.357993,
+	0.000080, -0.007157,
+      // WidthUp
+        0.145412, -0.001771, 0.054462, 0.022280, -0.009893,  0.056353,
+        0.020711, -0.016703,
+      // WidthLo
+        0.089187, -0.006430, 0.074442, 0.003738, -0.004256, -0.014101,
+        0.006126, -0.002849,
+      // DistUp
+        1.787943,  0.0,      2.942310, 0.199815,  0.0,       0.249909,
+        0.189697,  0.0,
+      // DistLo
+        0.589406,  0.0,     -0.083964,-0.007975,  0.0,       0.045374,
+       -0.001750,  0.0,
+      // AsymUp
+        1.e10,     0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // AsymLo
+       -1.e10,     0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // ConcUp
+        1.e10,     0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // ConcLo
+       -1.e10,     0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // Leakage1Up
+        1.e10,     0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // Leakage1Lo
+       -1.e10,     0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // AlphaUp
+	13.12344,  0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0                                                 };
+
+      Double_t vsteps[104] = {
+      // LengthUp
+        0.03,      0.0002,   0.02,     0.0006,    0.0002,    0.002,
+        0.0008,    0.002,
+      // LengthLo
+        0.02,      0.003,    0.05,     0.006,     0.002,     0.3,
+        0.0001,    0.0008,
+      // WidthUp
+        0.02,      0.0002,   0.006,    0.003,     0.002,     0.006,
+        0.002,     0.002,
+      // WidthLo
+        0.009,     0.0007,   0.008,    0.0004,    0.0005,    0.002,
+        0.0007,    0.003,
+      // DistUp
+        0.2,       0.0,      0.3,      0.02,      0.0,       0.03,
+        0.02,      0.0
+      // DistLo
+        0.06,      0.0,      0.009,    0.0008,    0.0,       0.005,
+        0.0002,    0.0
+      // AsymUp  
+        0.0,       0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // AsymLo  
+        0.0,       0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // ConcUp  
+        0.0,       0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // ConcLo  
+        0.0,       0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // Leakage1Up  
+        0.0,       0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // Leakage1Lo  
+        0.0,       0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // AlphaUp  
+        0.0,       0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0                                                 };
+
+      params.Set(104, vparams);
+      steps.Set (104, vsteps );
+    }
+
+    Bool_t rf;
+    rf = findsuper.FindParams(parSCinit, params, steps);
+
+    if (!rf) 
+    {
+       gLog << "CT1Analysis.C : optimization of supercuts failed" << endl;
+       return;
+    }
+  }
+
+    //--------------------------------------
+    // test the supercuts on the test sample
+    //    
+
+ if (RTest)
+ {
+    gLog << "CT1Analysis.C : test the supercuts on the test matrix" << endl;
+    Bool_t rt = findsuper.TestParams();
+    if (!rt) 
+    {
+       gLog << "CT1Analysis.C : test of supercuts on the test matrix failed" 
+            << endl;
+    }
+
+ }
+
+
+    //-----------------------------------------------------------------
+    // Update the input files with the SC hadronness
+    //
+
+ if (WSC)
+ {
+    gLog << "" << endl;
+    gLog << "========================================================" << endl;
+    gLog << "Update input file '" <<  filenameData 
+         << "' with the SC hadronness" << endl;
+
+
+    //----------------------------------------------------
+    // read in optimum parameter values for the supercuts
+
+    TFile inparam(parSCfile);
+    MCT1Supercuts scin;
+    scin.Read("MCT1Supercuts");
+    inparam.Close();
+
+    gLog << "Parameter values for supercuts were read in from file '"
+         << parSCfile << "'" << endl;
+
+    TArrayD supercutsPar;
+    supercutsPar =  scin.GetParameters();
+
+    TArrayD supercutsStep;
+    supercutsStep =  scin.GetStepsizes();
+
+    gLog << "Parameter values for supercuts : " << endl;
+    for (Int_t i=0; i<supercutsPar.GetSize(); i++)
+    {
+      gLog << supercutsPar[i] << ",  ";
+    }
+    gLog << endl;
+
+    gLog << "Step values for supercuts : " << endl;
+    for (Int_t i=0; i<supercutsStep.GetSize(); i++)
+    {
+      gLog << supercutsStep[i] << ",  ";
+    }
+    gLog << endl;
+
+
+    //----------------------------------------------------
+    MTaskList tliston;
+    MParList pliston;
+
+    // set the parameters of the supercuts
+    MCT1Supercuts supercuts;
+    supercuts.SetParameters(supercutsPar);
+    gLog << "parameter values for the supercuts used for updating the input file ' " 
+         << filenameData << "'" << endl;
+    supercutsPar = supercuts.GetParameters();
+    for (Int_t i=0; i<supercutsPar.GetSize(); i++)
+    {
+      gLog << supercutsPar[i] << ",  ";
+    }
+    gLog << endl;
+
+
+    // geometry is needed in  MHHillas... classes 
+    MGeomCam *fGeom = 
+             (MGeomCam*)pliston->FindCreateObj("MGeomCamCT1", "MGeomCam");
+
+    //-------------------------------------------
+    // create the tasks which should be executed 
+    //
+
+    MReadMarsFile read("Events", filenameData);
+    read.DisableAutoScheme();
+
+    TString fHilName    = "MHillas"; 
+    TString fHilNameExt = "MHillasExt"; 
+    TString fHilNameSrc = "MHillasSrc"; 
+    TString fImgParName = "MNewImagePar"; 
+
+
+    //.......................................................................
+    // calculation of hadroness for the supercuts
+    // (=0.25 if fullfilled, =0.75 otherwise)
+
+    TString hadSCName = "HadSC";
+    MCT1SupercutsCalc sccalc(fHilName, fHilNameSrc);
+    sccalc.SetHadronnessName(hadSCName);
+
+
+    //.......................................................................
+
+
+      //MWriteRootFile write(outNameImage, "UPDATE");
+      //MWriteRootFile write = new MWriteRootFile(outNameImage, "RECREATE");
+
+    
+      MWriteRootFile write(outNameImage, "RECREATE");
+
+      write.AddContainer("MRawRunHeader", "RunHeaders");
+      write.AddContainer("MTime",         "Events");
+      write.AddContainer("MMcEvt",        "Events");
+      write.AddContainer("ThetaOrig",     "Events");
+      write.AddContainer("MSrcPosCam",    "Events");
+      write.AddContainer("MSigmabar",     "Events");
+      write.AddContainer("MHillas",       "Events");
+      write.AddContainer("MHillasExt",    "Events");
+      write.AddContainer("MHillasSrc",    "Events");
+      write.AddContainer("MNewImagePar",  "Events");
+
+      write.AddContainer("HadRF",         "Events");
+      write.AddContainer(hadSCName,       "Events");
+    
+
+    //-----------------------------------------------------------------
+    // geometry is needed in  MHHillas... classes 
+    MGeomCam *fGeom = 
+             (MGeomCam*)pliston->FindCreateObj("MGeomCamCT1", "MGeomCam");
+
+    Float_t maxhadronness =  0.40;
+    Float_t maxalpha      =  20.0;
+    Float_t maxdist       =  10.0;
+
+    MFCT1SelFinal selfinalgh(fHilNameSrc);
+    selfinalgh.SetCuts(maxhadronness, 100.0, maxdist);
+    selfinalgh.SetHadronnessName(hadSCName);
+    selfinalgh.SetName("SelFinalgh");
+    MContinue contfinalgh(&selfinalgh);
+    contfinalgh.SetName("ContSelFinalgh");
+
+    MFillH fillhadsc("hadSC[MHHadronness]", hadSCName);
+    fillhadsc.SetName("HhadSC");
+
+    MFCT1SelFinal selfinal(fHilNameSrc);
+    selfinal.SetCuts(maxhadronness, maxalpha, maxdist);
+    selfinal.SetHadronnessName(hadSCName);
+    selfinal.SetName("SelFinal");
+    MContinue contfinal(&selfinal);
+    contfinal.SetName("ContSelFinal");
+
+    TString mh3name = "abs(Alpha)";
+    MBinning binsalphaabs("Binning"+mh3name);
+    binsalphaabs.SetEdges(50, -2.0, 98.0);
+
+    MH3 alphaabs("abs(MHillasSrc.fAlpha)");
+    alphaabs.SetName(mh3name);
+
+    TH1  &alphahist = alphaabs->GetHist();
+
+    MFillH alpha(&alphaabs);
+    alpha.SetName("FillAlphaAbs");
+
+    MFillH hfill1("MHHillas",    fHilName);
+    hfill1.SetName("HHillas");
+
+    MFillH hfill2("MHStarMap",   fHilName);
+    hfill2.SetName("HStarMap");
+
+    MFillH hfill3("MHHillasExt",    fHilNameSrc);
+    hfill3.SetName("HHillasExt");
+    
+    MFillH hfill4("MHHillasSrc",   fHilNameSrc);
+    hfill4.SetName("HHillasSrc");    
+
+    MFillH hfill5("MHNewImagePar", fImgParName);
+    hfill5.SetName("HNewImagePar");
+
+    //*****************************
+    // entries in MParList
+
+    pliston.AddToList(&tliston);
+    InitBinnings(&pliston);
+
+    pliston.AddToList(&supercuts);
+
+    pliston.AddToList(&binsalphaabs);
+    pliston.AddToList(&alphaabs);
+
+    //*****************************
+    // entries in MTaskList
+    
+    tliston.AddToList(&read);
+
+    tliston.AddToList(&sccalc);
+    tliston.AddToList(&fillhadsc);
+
+    tliston.AddToList(&write);
+    tliston.AddToList(&contfinalgh);
+
+    tliston.AddToList(&alpha);
+    tliston.AddToList(&hfill1);
+    tliston.AddToList(&hfill2);
+    tliston.AddToList(&hfill3);
+    tliston.AddToList(&hfill4);
+    tliston.AddToList(&hfill5);
+
+    tliston.AddToList(&contfinal);
+
+    //*****************************
+
+    //-------------------------------------------
+    // Execute event loop
+    //
+    MProgressBar bar;
+    MEvtLoop evtloop;
+    evtloop.SetParList(&pliston);
+    evtloop.SetProgressBar(&bar);
+
+    Int_t maxevents = -1;
+    if ( !evtloop.Eventloop(maxevents) )
+        return;
+
+    tliston.PrintStatistics(0, kTRUE);
+
+
+    //-------------------------------------------
+    // Display the histograms
+    //
+    pliston.FindObject("hadSC", "MHHadronness")->DrawClone();
+
+    pliston.FindObject("MHHillas")->DrawClone();
+    pliston.FindObject("MHHillasExt")->DrawClone();
+    pliston.FindObject("MHHillasSrc")->DrawClone();
+    pliston.FindObject("MHNewImagePar")->DrawClone();
+    pliston.FindObject("MHStarMap")->DrawClone();
+
+     //-------------------------------------------
+    // fit alpha distribution to get the number of excess events and
+    // calculate significance of gamma signal in the alpha plot
+  
+    MH3* absalpha = (MH3*)(pliston.FindObject(mh3name, "MH3"));
+    TH1  &alphaHist = absalpha->GetHist();
+    alphaHist.SetXTitle("|alpha|  [\\circ]");
+    alphaHist.SetName("alpha-macro");
+
+    Double_t alphasig = 13.1;
+    Double_t alphamin = 30.0;
+    Double_t alphamax = 90.0;
+    Int_t    degree   =    2;
+    Double_t significance = -99.0;
+    Bool_t   drawpoly  = kTRUE;
+    Bool_t   fitgauss  = kTRUE;
+    Bool_t   print     = kTRUE;
+
+    MHFindSignificance findsig;
+    findsig.SetRebin(kTRUE);
+    findsig.SetReduceDegree(kFALSE);
+
+    findsig.FindSigma(&alphaHist, alphamin, alphamax, degree, 
+                        alphasig, drawpoly, fitgauss, print);
+    significance = findsig.GetSignificance();
+    Float_t alphasi = findsig.GetAlphasi();
+
+    gLog << "For file '" << filenameData << "' : " << endl;
+    gLog << "Significance of gamma signal after supercuts : "
+         << significance << " (for |alpha| < " << alphasi << " degrees)" 
+         << endl;
+
+    findsig.SigmaVsAlpha(&alphaHist, alphamin, alphamax, degree, print);
+
+    //-------------------------------------------
+
+    DeleteBinnings(&pliston);
+ }
+
+
+    gLog << "Macro CT1Analysis : End of Job B_SC_UP" << endl;
+    gLog << "=======================================================" << endl;
+ }
+  //---------------------------------------------------------------------
+
+
+
+  //---------------------------------------------------------------------
+  // Job C  
+  //======
+
+    //  - read ON1 and MC1 data files  
+    //    which should have been updated to contain the hadronnesses
+    //    for the method of Random Forest and for the SUPERCUTS
+    //  - produce Neyman-Pearson plots
+ 
+ if (JobC)
+ {
+    gLog << "=====================================================" << endl;
+    gLog << "Macro CT1Analysis : Start of Job C" << endl;
+
+    gLog << "" << endl;
+    gLog << "Macro CT1Analysis : JobC = " 
+         << (JobC       ? "kTRUE" : "kFALSE")  << endl;
+
+
+    // name of input data file
+    TString filenameData = outPath;
+    filenameData += "ON";
+    filenameData += "3.root";
+    gLog << "filenameData = " << filenameData << endl;
+
+    // name of input MC file
+    TString filenameMC = outPath;
+    filenameMC += "MC";
+    filenameMC += "3.root";
+    gLog << "filenameMC   = " << filenameMC   << endl;
+
+
+    //-----------------------------------------------------------------
+
+    MTaskList tliston;
+    MParList pliston;
+
+
+    // geometry is needed in  MHHillas... classes 
+    MGeomCam *fGeom = 
+             (MGeomCam*)pliston->FindCreateObj("MGeomCamCT1", "MGeomCam");
+
+    //-------------------------------------------
+    // create the tasks which should be executed 
+    //
+
+    MReadMarsFile read("Events", filenameMC);
+    read.AddFile(filenameData);
+    read.DisableAutoScheme();
+
+
+    //.......................................................................
+    // names of hadronness containers
+
+    //TString hadNNName = "HadNN";
+    TString hadSCName = "HadSC";
+    TString hadRFName = "HadRF";
+
+    //.......................................................................
+
+
+    TString fHilName    = "MHillas"; 
+    TString fHilNameExt = "MHillasExt"; 
+    TString fHilNameSrc = "MHillasSrc"; 
+    TString fImgParName = "MNewImagePar"; 
+
+    Float_t maxhadronness =  0.40;
+    Float_t maxalpha      =  20.0;
+    Float_t maxdist       =  10.0;
+
+    MFCT1SelFinal selfinalgh(fHilNameSrc);
+    selfinalgh.SetCuts(maxhadronness, 100.0, maxdist);
+    selfinalgh.SetHadronnessName(hadSCName);
+    selfinalgh.SetName("SelFinalgh");
+    MContinue contfinalgh(&selfinalgh);
+    contfinalgh.SetName("ContSelFinalgh");
+
+    //MFillH fillhadnn("hadNN[MHHadronness]", hadNNName);
+    //fillhadnn.SetName("HhadNN");
+    MFillH fillhadsc("hadSC[MHHadronness]", hadSCName);
+    fillhadsc.SetName("HhadSC");
+    MFillH fillhadrf("hadRF[MHHadronness]", hadRFName);
+    fillhadrf.SetName("HhadRF");
+
+    MFCT1SelFinal selfinal(fHilNameSrc);
+    selfinal.SetCuts(maxhadronness, maxalpha, maxdist);
+    selfinal.SetHadronnessName(hadSCName);
+    selfinal.SetName("SelFinal");
+    MContinue contfinal(&selfinal);
+    contfinal.SetName("ContSelFinal");
+
+
+    MFillH hfill1("MHHillas",    fHilName);
+    hfill1.SetName("HHillas");
+
+    MFillH hfill2("MHStarMap",   fHilName);
+    hfill2.SetName("HStarMap");
+
+    MFillH hfill3("MHHillasExt",    fHilNameSrc);
+    hfill3.SetName("HHillasExt");
+    
+    MFillH hfill4("MHHillasSrc",   fHilNameSrc);
+    hfill4.SetName("HHillasSrc");    
+
+    MFillH hfill5("MHNewImagePar", fImgParName);
+    hfill5.SetName("HNewImagePar");
+
+
+    //*****************************
+    // entries in MParList
+
+    pliston.AddToList(&tliston);
+    InitBinnings(&pliston);
+
+
+    //*****************************
+    // entries in MTaskList
+    
+    tliston.AddToList(&read);
+
+    //tliston.AddToList(&fillhadnn);
+    tliston.AddToList(&fillhadsc);
+    tliston.AddToList(&fillhadrf);
+   
+    tliston.AddToList(&contfinalgh);
+    tliston.AddToList(&hfill1);
+    tliston.AddToList(&hfill2);
+    tliston.AddToList(&hfill3);
+    tliston.AddToList(&hfill4);
+    tliston.AddToList(&hfill5);
+
+    tliston.AddToList(&contfinal);
+
+    //*****************************
+
+    //-------------------------------------------
+    // Execute event loop
+    //
+    MProgressBar bar;
+    MEvtLoop evtloop;
+    evtloop.SetParList(&pliston);
+    evtloop.SetProgressBar(&bar);
+
+    Int_t maxevents = -1;
+    //Int_t maxevents = 35000;
+    if ( !evtloop.Eventloop(maxevents) )
+        return;
+
+    tliston.PrintStatistics(0, kTRUE);
+
+
+    //-------------------------------------------
+    // Display the histograms
+    //
+
+    //pliston.FindObject("hadNN", "MHHadronness")->DrawClone();
+    pliston.FindObject("hadSC", "MHHadronness")->DrawClone();
+    pliston.FindObject("hadRF", "MHHadronness")->DrawClone();
+
+    pliston.FindObject("MHHillas")->DrawClone();
+    pliston.FindObject("MHHillasExt")->DrawClone();
+    pliston.FindObject("MHHillasSrc")->DrawClone();
+    pliston.FindObject("MHNewImagePar")->DrawClone();
+    pliston.FindObject("MHStarMap")->DrawClone();
+
+    DeleteBinnings(&pliston);
+
+    gLog << "Macro CT1Analysis : End of Job C" << endl;
+    gLog << "===================================================" << endl;
+ }
+
+
+  //---------------------------------------------------------------------
+  // Job D
+  //======
+
+    //  - select g/h separation method XX
+    //  - read ON2 (or MC2) root file 
+    //  - apply cuts in hadronness
+    //  - make plots
+
+
+ if (JobD)
+ {
+    gLog << "=====================================================" << endl;
+    gLog << "Macro CT1Analysis : Start of Job D" << endl;
+
+    gLog << "" << endl;
+    gLog << "Macro CT1Analysis : JobD = " 
+         << (JobD        ? "kTRUE" : "kFALSE")  << endl;
+
+
+    // type of data to be analysed
+    TString typeData = "ON";
+    //TString typeData = "OFF";
+    //TString typeData = "MC";
+    gLog << "typeData = " << typeData << endl;
+
+    TString ext      = "3.root";
+
+
+    //------------------------------
+    // selection of g/h separation method
+    // and definition of final selections
+
+    //TString XX("SC");
+    TString XX("RF");
+    TString fhadronnessName("Had");
+    fhadronnessName += XX;
+    gLog << "fhadronnessName = " << fhadronnessName << endl;
+
+    // maximum values of the hadronness, |ALPHA| and DIST
+    Float_t maxhadronness   = 0.233;
+    Float_t maxalpha        = 20.0;
+    Float_t maxdist         = 10.0;
+    gLog << "Maximum values of hadronness, |ALPHA| and DIST = "
+         << maxhadronness << ",  " << maxalpha << ",  " 
+         << maxdist << endl;
+
+
+    //------------------------------
+    // name of data file to be analysed
+    TString filenameData(outPath);
+    filenameData += typeData;
+    filenameData += ext;
+    gLog << "filenameData = " << filenameData << endl;
+
+
+
+    //*************************************************************************
+    //
+    // Analyse the data
+    //
+
+    MTaskList tliston;
+    MParList pliston;
+
+    // geometry is needed in  MHHillas... classes 
+    MGeomCam *fGeom = 
+             (MGeomCam*)pliston->FindCreateObj("MGeomCamCT1", "MGeomCam");
+
+
+    TString fHilName    = "MHillas"; 
+    TString fHilNameExt = "MHillasExt"; 
+    TString fHilNameSrc = "MHillasSrc"; 
+    TString fImgParName = "MNewImagePar"; 
+
+    //-------------------------------------------
+    // create the tasks which should be executed 
+    //
+
+    MReadMarsFile read("Events", filenameData);
+    read.DisableAutoScheme();
+
+
+    //-----------------------------------------------------------------
+    // geometry is needed in  MHHillas... classes 
+    MGeomCam *fGeom = 
+             (MGeomCam*)pliston->FindCreateObj("MGeomCamCT1", "MGeomCam");
+
+    MFCT1SelFinal selfinalgh(fHilNameSrc);
+    selfinalgh.SetCuts(maxhadronness, 100.0, maxdist);
+    selfinalgh.SetHadronnessName(fhadronnessName);
+    selfinalgh.SetName("SelFinalgh");
+    MContinue contfinalgh(&selfinalgh);
+    contfinalgh.SetName("ContSelFinalgh");
+
+    MFillH fillhadsc("hadSC[MHHadronness]", "HadSC");
+    fillhadsc.SetName("HhadSC");
+    MFillH fillhadrf("hadRF[MHHadronness]", "HadRF");
+    fillhadrf.SetName("HhadRF");
+
+    TString mh3name = "abs(Alpha)";
+    MBinning binsalphaabs("Binning"+mh3name);
+    binsalphaabs.SetEdges(50, -2.0, 98.0);
+
+    MH3 alphaabs("abs(MHillasSrc.fAlpha)");
+    alphaabs.SetName(mh3name);
+
+    TH1  &alphahist = alphaabs->GetHist();
+
+    MFillH alpha(&alphaabs);
+    alpha.SetName("FillAlphaAbs");
+
+    MFillH hfill1("MHHillas",    fHilName);
+    hfill1.SetName("HHillas");
+
+    MFillH hfill2("MHStarMap",   fHilName);
+    hfill2.SetName("HStarMap");
+
+    MFillH hfill3("MHHillasExt",   fHilNameSrc);
+    hfill3.SetName("HHillasExt");    
+
+    MFillH hfill4("MHHillasSrc",   fHilNameSrc);
+    hfill4.SetName("HHillasSrc");    
+
+    MFillH hfill5("MHNewImagePar", fImgParName);
+    hfill5.SetName("HNewImagePar");    
+
+    MFCT1SelFinal selfinal(fHilNameSrc);
+    selfinal.SetCuts(maxhadronness, maxalpha, maxdist);
+    selfinal.SetHadronnessName(fhadronnessName);
+    selfinal.SetName("SelFinal");
+    MContinue contfinal(&selfinal);
+    contfinal.SetName("ContSelFinal");
+
+
+    //*****************************
+    // entries in MParList
+
+    pliston.AddToList(&tliston);
+    InitBinnings(&pliston);
+    pliston.AddToList(&binsalphaabs);
+    pliston.AddToList(&alphaabs);
+
+    //*****************************
+    // entries in MTaskList
+    
+    tliston.AddToList(&read);
+
+    tliston.AddToList(&contfinalgh);
+
+    tliston.AddToList(&fillhadsc);
+    tliston.AddToList(&fillhadrf);
+
+    tliston.AddToList(&alpha);
+    tliston.AddToList(&hfill1);
+    tliston.AddToList(&hfill2);
+    tliston.AddToList(&hfill3);
+    tliston.AddToList(&hfill4);
+    tliston.AddToList(&hfill5);
+
+    tliston.AddToList(&contfinal);
+
+    //*****************************
+
+    //-------------------------------------------
+    // Execute event loop
+    //
+    MProgressBar bar;
+    MEvtLoop evtloop;
+    evtloop.SetParList(&pliston);
+    evtloop.SetProgressBar(&bar);
+
+    Int_t maxevents = -1;
+    //Int_t maxevents = 10000;
+    if ( !evtloop.Eventloop(maxevents) )
+        return;
+
+    tliston.PrintStatistics(0, kTRUE);
+
+
+    //-------------------------------------------
+    // Display the histograms
+    //
+
+    pliston.FindObject("hadRF", "MHHadronness")->DrawClone();
+    pliston.FindObject("hadSC", "MHHadronness")->DrawClone();
+
+    pliston.FindObject("MHHillas")->DrawClone();
+    pliston.FindObject("MHHillasExt")->DrawClone();
+    pliston.FindObject("MHHillasSrc")->DrawClone();
+    pliston.FindObject("MHNewImagePar")->DrawClone();
+    pliston.FindObject("MHStarMap")->DrawClone();
+
+
+    //-------------------------------------------
+
+    // fit alpha distribution to get the number of excess events and
+    // calculate significance of gamma signal in the alpha plot
+  
+    MH3* absalpha = (MH3*)(pliston.FindObject(mh3name, "MH3"));
+    TH1  &alphaHist = absalpha->GetHist();
+    alphaHist.SetXTitle("|alpha|  [\\circ]");
+    alphaHist.SetName("alpha-JobD");
+
+    Double_t alphasig = 13.1;
+    Double_t alphamin = 30.0;
+    Double_t alphamax = 90.0;
+    Int_t    degree   =    2;
+    Double_t significance = -99.0;
+    Bool_t   drawpoly  = kTRUE;
+    Bool_t   fitgauss  = kTRUE;
+    Bool_t   print     = kTRUE;
+
+    MHFindSignificance findsig;
+    findsig.SetRebin(kTRUE);
+    findsig.SetReduceDegree(kFALSE);
+
+    findsig.FindSigma(&alphaHist, alphamin, alphamax, degree, 
+                        alphasig, drawpoly, fitgauss, print);
+    significance = findsig.GetSignificance();
+    Float_t alphasi = findsig.GetAlphasi();
+
+    gLog << "For file '" << filenameData << "' : " << endl;
+    gLog << "Significance of gamma signal after supercuts : "
+         << significance << " (for |alpha| < " << alphasi << " degrees)" 
+         << endl;
+
+    findsig.SigmaVsAlpha(&alphaHist, alphamin, alphamax, degree, print);
+
+    //-------------------------------------------
+
+
+    DeleteBinnings(&pliston);
+
+    gLog << "Macro CT1Analysis : End of Job D" << endl;
+    gLog << "=======================================================" << endl;
+ }
+  //---------------------------------------------------------------------
+
+
+
+
+  //---------------------------------------------------------------------
+  // Job E_XX
+  //=========
+
+    //  - select g/h separation method XX
+    //  - read MC_XX2.root file 
+    //  - calculate eff. collection area
+    //  - read ON_XX2.root file 
+    //  - apply final cuts
+    //  - calculate flux
+    //  - write root file for ON data after final cuts (ON_XX3.root))
+
+
+ if (JobE_XX)
+ {
+    gLog << "=====================================================" << endl;
+    gLog << "Macro CT1Analysis : Start of Job E_XX" << endl;
+
+    gLog << "" << endl;
+    gLog << "Macro CT1Analysis : JobE_XX, CCollArea, OEEst, WEX = " 
+         << (JobE_XX ? "kTRUE" : "kFALSE")  << ",  " 
+         << (CCollArea?"kTRUE" : "kFALSE")  << ",  " 
+         << (OEEst ?   "kTRUE" : "kFALSE")  << ",  " 
+         << (WEX     ? "kTRUE" : "kFALSE")  << endl;
+
+
+    // type of data to be analysed
+    //TString typeData = "ON";
+    //TString typeData = "OFF";
+    TString typeData = "MC";
+    gLog << "typeData = " << typeData << endl;
+
+    TString typeMC   = "MC";
+    TString ext      = "3.root";
+    TString extout   = "4.root";
+
+    //------------------------------
+    // selection of g/h separation method
+    // and definition of final selections
+
+    //TString XX("SC");
+    TString XX("RF");
+    TString fhadronnessName("Had");
+    fhadronnessName += XX;
+    gLog << "fhadronnessName = " << fhadronnessName << endl;
+
+    // maximum values of the hadronness, |ALPHA| and DIST
+    Float_t maxhadronness   = 0.23;
+    Float_t maxalpha        = 20.0;
+    Float_t maxdist         = 10.0;
+    gLog << "Maximum values of hadronness, |ALPHA| and DIST = "
+         << maxhadronness << ",  " << maxalpha << ",  " 
+         << maxdist << endl;
+
+    //------------------------------
+    // name of MC file to be used for optimizing the energy estimator
+    TString filenameOpt(outPath);
+    filenameOpt += typeMC;
+    filenameOpt += ext; 
+    gLog << "filenameOpt = " << filenameOpt << endl;
+
+    //------------------------------
+    // name of file containing the parameters of the energy estimator
+    TString energyParName(outPath);
+    energyParName += "energyest_";
+    energyParName += XX;
+    energyParName += ".root";
+    gLog << "energyParName = " << energyParName << endl;
+
+    //------------------------------
+    // name of MC file to be used for calculating the eff. collection areas
+    TString filenameArea(outPath);
+    filenameArea += typeMC;
+    filenameArea += ext; 
+    gLog << "filenameArea = " << filenameArea << endl;
+
+    //------------------------------
+    // name of file containing the eff. collection areas
+    TString collareaName(outPath);
+    collareaName += "area_";
+    collareaName += XX;
+    collareaName += ".root";
+    gLog << "collareaName = " << collareaName << endl;
+
+    //------------------------------
+    // name of data file to be analysed
+    TString filenameData(outPath);
+    filenameData += typeData;
+    filenameData += ext;
+    gLog << "filenameData = " << filenameData << endl;
+
+    //------------------------------
+    // name of output data file (after the final cuts)
+    TString filenameDataout(outPath);
+    filenameDataout += typeData;
+    filenameDataout += "_";
+    filenameDataout += XX;
+    filenameDataout += extout;
+    gLog << "filenameDataout = " << filenameDataout << endl;
+
+    //------------------------------
+    // name of file containing histograms for flux calculastion
+    TString filenameResults(outPath);
+    filenameResults += typeData;
+    filenameResults += "Results_";
+    filenameResults += XX;
+    filenameResults += extout;
+    gLog << "filenameResults = " << filenameResults << endl;
+
+
+    //====================================================================
+
+    MHMcCT1CollectionArea collarea;
+    collarea.SetEaxis(MHMcCT1CollectionArea::kLinear);
+
+    MParList  parlist;
+    InitBinnings(&parlist);
+
+  if (CCollArea)
+  {
+    gLog << "-----------------------------------------------" << endl;
+    gLog << "Start calculation of effective collection areas" << endl;
+
+
+    MTaskList tasklist;
+
+    //---------------------------------------
+    // Setup the tasks to be executed
+    //
+    MReadMarsFile reader("Events", filenameArea);
+    reader.DisableAutoScheme();
+
+    MFCT1SelFinal cuthadrons;
+    cuthadrons.SetHadronnessName(fhadronnessName);
+    cuthadrons.SetCuts(maxhadronness, maxalpha, maxdist);
+
+    MContinue conthadrons(&cuthadrons);
+
+
+    MFillH filler("MHMcCT1CollectionArea", "MMcEvt");
+    filler.SetName("CollectionArea");
+
+    //********************************
+    // entries in MParList
+
+    parlist.AddToList(&tasklist);
+
+    parlist.AddToList(&collarea);
+
+    //********************************
+    // entries in MTaskList
+
+    tasklist.AddToList(&reader);   
+    tasklist.AddToList(&conthadrons);
+    tasklist.AddToList(&filler);
+
+    //********************************
+
+    //-----------------------------------------
+    // Execute event loop
+    //
+    MEvtLoop magic;
+    magic.SetParList(&parlist);
+
+    MProgressBar bar;
+    magic.SetProgressBar(&bar);
+    if (!magic.Eventloop())
+        return;
+
+    tasklist.PrintStatistics(0, kTRUE);
+
+    // Calculate effective collection areas 
+    // and display the histograms
+    //
+    //MHMcCT1CollectionArea *collarea = 
+    //     (MHMcCT1CollectionArea*)parlist.FindObject("MHMcCT1CollectionArea");
+    collarea.CalcEfficiency();
+    collarea.DrawClone();
+
+
+
+    //---------------------------------------------
+    // Write histograms to a file 
+    //
+
+    TFile f(collareaName, "RECREATE");
+    //collarea.GetHist()->Write();
+    //collarea.GetHAll()->Write();
+    //collarea.GetHSel()->Write();
+    collarea.Write();
+
+    f.Close();
+
+    gLog << "Collection area plots written onto file " << collareaName << endl;
+
+    gLog << "Calculation of effective collection areas done" << endl;
+    gLog << "-----------------------------------------------" << endl;    
+    //------------------------------------------------------------------
+  }
+
+  if (!CCollArea)
+  {
+    gLog << "-----------------------------------------------" << endl;
+    gLog << "Read in effective collection areas from file " 
+         << collareaName << endl;
+
+    TFile collfile(collareaName);
+    collfile.ls();
+    collarea.Read("MHMcCT1CollectionArea");
+    collarea.DrawClone();
+
+    gLog << "Effective collection areas were read in from file " 
+         << collareaName << endl;
+    gLog << "-----------------------------------------------" << endl;    
+  }
+
+
+    // save binnings for call to CT1EEst
+    MBinning *binsE     = (MBinning*)parlist.FindObject("BinningE");
+    if (!binsE)
+	{
+          gLog << "Object 'BinningE' not found in MParList" << endl;
+          return;
+	}
+    MBinning *binsTheta = (MBinning*)parlist.FindObject("BinningTheta");
+    if (!binsTheta)
+	{
+          gLog << "Object 'BinningTheta' not found in MParList" << endl;
+          return;
+	}
+
+    //-------------------------------------
+    TString fHilName    = "MHillas"; 
+    TString fHilNameExt = "MHillasExt"; 
+    TString fHilNameSrc = "MHillasSrc"; 
+    TString fImgParName = "MNewImagePar"; 
+
+
+ if (OEEst)
+ { 
+   //===========================================================
+    //
+    // Optimization of energy estimator
+    //
+    gLog << "Macro CT1Analysis.C : calling CT1EEst" << endl;
+
+    TString inpath("");
+    TString outpath("");
+    Int_t howMany = 2000;
+    CT1EEst(inpath,   filenameOpt,   outpath, energyParName, 
+            fHilName, fHilNameSrc,   fhadronnessName,
+            howMany,  maxhadronness, maxalpha, maxdist,
+            binsE, binsTheta);
+    gLog << "Macro CT1Analysis.C : returning from CT1EEst" << endl;
+ }
+
+ if (WEX)
+ {
+    //-----------------------------------------------------------
+    //
+    // Read in parameters of energy estimator ("MMcEnergyEst")
+    //                   and migration matrix ("MHMcEnergyMigration")
+    //
+    gLog << "================================================================"
+         << endl;
+    gLog << "Macro CT1Analysis.C : read parameters of energy estimator and migration matrix from file '"
+         << energyParName << "'" << endl;
+    TFile enparam(energyParName);
+    enparam.ls();
+    MMcEnergyEst mcest("MMcEnergyEst"); 
+    mcest.Read("MMcEnergyEst");
+
+    //MMcEnergyEst &mcest = *((MMcEnergyEst*)gROOT->FindObject("MMcEnergyEst"));
+    gLog << "Parameters of energy estimator were read in" << endl;
+
+
+    gLog << "Read in Migration matrix" << endl;   
+
+    MHMcEnergyMigration mighiston("MHMcEnergyMigration");
+    mighiston.Read("MHMcEnergyMigration");
+    //MHMcEnergyMigration &mighiston = 
+    //      *((MHMcEnergyMigration*)gROOT->FindObject("MHMcEnergyMigration"));
+
+    gLog << "Migration matrix was read in" << endl;
+
+
+    TArrayD parA(mcest.GetNumCoeffA());
+    TArrayD parB(mcest.GetNumCoeffB());
+    for (Int_t i=0; i<parA.GetSize(); i++)
+      parA[i] = mcest.GetCoeff(i);
+    for (Int_t i=0; i<parB.GetSize(); i++)
+      parB[i] = mcest.GetCoeff( i+parA.GetSize() );
+
+    //*************************************************************************
+    //
+    // Analyse the data
+    //
+    gLog << "============================================================"
+         << endl;
+    gLog << "Analyse the data" << endl;
+
+    MTaskList tliston;
+    MParList pliston;
+
+    // geometry is needed in  MHHillas... classes 
+    MGeomCam *fGeom = 
+             (MGeomCam*)pliston->FindCreateObj("MGeomCamCT1", "MGeomCam");
+
+
+    //-------------------------------------------
+    // create the tasks which should be executed 
+    //
+
+    MReadMarsFile read("Events", filenameData);
+    read.DisableAutoScheme();
+
+    //.......................................................................
+
+      gLog << "CT1Analysis.C : write root file '" << filenameDataout 
+           << "'" << endl;
+   
+      //MWriteRootFile &write = *(new MWriteRootFile(filenameDataout));
+
+
+      MWriteRootFile write(filenameDataout, "RECREATE");
+
+      write.AddContainer("MRawRunHeader", "RunHeaders");
+      write.AddContainer("MTime",         "Events");
+      write.AddContainer("MMcEvt",        "Events");
+      write.AddContainer("ThetaOrig",     "Events");
+      write.AddContainer("MSrcPosCam",    "Events");
+      write.AddContainer("MSigmabar",     "Events");
+      write.AddContainer("MHillas",       "Events");
+      write.AddContainer("MHillasExt",    "Events");
+      write.AddContainer("MHillasSrc",    "Events");
+      write.AddContainer("MNewImagePar",  "Events");
+
+      //write.AddContainer("HadNN",         "Events");
+      write.AddContainer("HadSC",         "Events");
+      write.AddContainer("HadRF",         "Events");
+
+      write.AddContainer("MEnergyEst",    "Events");
+
+
+    //-----------------------------------------------------------------
+    // geometry is needed in  MHHillas... classes 
+    MGeomCam *fGeom = 
+             (MGeomCam*)pliston->FindCreateObj("MGeomCamCT1", "MGeomCam");
+
+    MFCT1SelFinal selfinalgh(fHilNameSrc);
+    selfinalgh.SetCuts(maxhadronness, 100.0, maxdist);
+    selfinalgh.SetHadronnessName(fhadronnessName);
+    selfinalgh.SetName("SelFinalgh");
+    MContinue contfinalgh(&selfinalgh);
+    contfinalgh.SetName("ContSelFinalgh");
+
+    //MFillH fillhadnn("hadNN[MHHadronness]", "HadNN");
+    //fillhadnn.SetName("HhadNN");
+    MFillH fillhadsc("hadSC[MHHadronness]", "HadSC");
+    fillhadsc.SetName("HhadSC");
+    MFillH fillhadrf("hadRF[MHHadronness]", "HadRF");
+    fillhadrf.SetName("HhadRF");
+
+    //---------------------------
+    // calculate estimated energy
+
+    MEnergyEstParam eeston(fHilName);
+    eeston.Add(fHilNameSrc);
+
+    eeston.SetCoeffA(parA);
+    eeston.SetCoeffB(parB);
+
+    //---------------------------
+    // calculate estimated energy using Daniel's parameters
+
+    //MEnergyEstParamDanielMkn421 eeston(fHilName);
+    //eeston.Add(fHilNameSrc);
+    //eeston.SetCoeffA(parA);
+    //eeston.SetCoeffB(parB);
+
+
+    //---------------------------
+
+
+    MFillH hfill1("MHHillas",    fHilName);
+    hfill1.SetName("HHillas");
+
+    MFillH hfill2("MHStarMap",   fHilName);
+    hfill2.SetName("HStarMap");
+
+    MFillH hfill3("MHHillasExt",   fHilNameSrc);
+    hfill3.SetName("HHillasExt");    
+
+    MFillH hfill4("MHHillasSrc",   fHilNameSrc);
+    hfill4.SetName("HHillasSrc");    
+
+    MFillH hfill5("MHNewImagePar", fImgParName);
+    hfill5.SetName("HNewImagePar");    
+
+    //---------------------------
+    // new from Robert
+
+    MFillH hfill6("MHTimeDiffTheta", "MMcEvt");
+    hfill6.SetName("HTimeDiffTheta");
+
+    MFillH hfill6a("MHTimeDiffTime", "MMcEvt");
+    hfill6a.SetName("HTimeDiffTime");
+
+    MFillH hfill7("MHAlphaEnergyTheta", fHilNameSrc);
+    hfill7.SetName("HAlphaEnergyTheta");
+
+    MFillH hfill7a("MHAlphaEnergyTime", fHilNameSrc);
+    hfill7a.SetName("HAlphaEnergyTime");
+
+    MFillH hfill7b("MHThetabarTime", fHilNameSrc);
+    hfill7b.SetName("HThetabarTime");
+
+    MFillH hfill7c("MHEnergyTime", "MMcEvt");
+    hfill7c.SetName("HEnergyTime");
+
+
+    //---------------------------
+
+    MFCT1SelFinal selfinal(fHilNameSrc);
+    selfinal.SetCuts(maxhadronness, maxalpha, maxdist);
+    selfinal.SetHadronnessName(fhadronnessName);
+    selfinal.SetName("SelFinal");
+    MContinue contfinal(&selfinal);
+    contfinal.SetName("ContSelFinal");
+
+
+    //*****************************
+    // entries in MParList
+
+    pliston.AddToList(&tliston);
+    InitBinnings(&pliston);
+
+
+    //*****************************
+    // entries in MTaskList
+    
+    tliston.AddToList(&read);
+
+    // robert      
+    tliston.AddToList(&hfill6);   //timediff
+    tliston.AddToList(&hfill6a);   //timediff
+
+    tliston.AddToList(&contfinalgh);
+    tliston.AddToList(&eeston);
+
+    tliston.AddToList(&write);
+
+    //tliston.AddToList(&fillhadnn);
+    tliston.AddToList(&fillhadsc);
+    tliston.AddToList(&fillhadrf);
+
+    tliston.AddToList(&hfill1);
+    tliston.AddToList(&hfill2);
+    tliston.AddToList(&hfill3);
+    tliston.AddToList(&hfill4);
+    tliston.AddToList(&hfill5);
+
+    //robert
+    tliston.AddToList(&hfill7);
+    tliston.AddToList(&hfill7a);
+    tliston.AddToList(&hfill7b);
+    tliston.AddToList(&hfill7c);
+
+    tliston.AddToList(&contfinal);
+
+    //*****************************
+
+    //-------------------------------------------
+    // Execute event loop
+    //
+    MProgressBar bar;
+    MEvtLoop evtloop;
+    evtloop.SetParList(&pliston);
+    evtloop.SetProgressBar(&bar);
+
+    Int_t maxevents = -1;
+    if ( !evtloop.Eventloop(maxevents) )
+        return;
+
+    tliston.PrintStatistics(0, kTRUE);
+
+
+    //-------------------------------------------
+    // Display the histograms
+    //
+
+    //pliston.FindObject("hadNN", "MHHadronness")->DrawClone();
+
+    gLog << "before hadRF" << endl;
+    pliston.FindObject("hadRF", "MHHadronness")->DrawClone();
+
+    gLog << "before hadSC" << endl;
+    pliston.FindObject("hadSC", "MHHadronness")->DrawClone();
+
+    gLog << "before MHHillas" << endl;
+    pliston.FindObject("MHHillas")->DrawClone();
+
+    gLog << "before MHHillasExt" << endl;
+    pliston.FindObject("MHHillasExt")->DrawClone();
+
+    gLog << "before MHHillasSrc" << endl;
+    pliston.FindObject("MHHillasSrc")->DrawClone();
+
+    gLog << "before MHNewImagePar" << endl;
+    pliston.FindObject("MHNewImagePar")->DrawClone();
+
+    gLog << "before MHStarMap" << endl;
+    pliston.FindObject("MHStarMap")->DrawClone();
+
+    gLog << "before DeleteBinnings" << endl;
+
+    DeleteBinnings(&pliston);
+
+    gLog << "before Robert's code" << endl;
+
+
+//rwagner write all relevant histograms onto a file
+
+  if (WRobert)
+  {
+    gLog << "=======================================================" << endl;
+    gLog << "Write results onto file '" << filenameResults << "'" << endl;
+
+    TFile outfile(filenameResults,"recreate");
+
+    MHHillasSrc* hillasSrc = 
+      (MHHillasSrc*)(pliston->FindObject("MHHillasSrc"));
+        TH1F* alphaHist = (TH1F*)(hillasSrc->GetHistAlpha());
+    alphaHist->Write();
+    gLog << "Alpha plot has been written out" << endl;    
+
+
+    MHAlphaEnergyTheta* aetH = 
+      (MHAlphaEnergyTheta*)(pliston->FindObject("MHAlphaEnergyTheta"));
+    TH3D* aetHist = (TH3D*)(aetH->GetHist());
+    aetHist->SetName("aetHist");
+    aetHist->Write();
+    gLog << "AlphaEnergyTheta plot has been written out" << endl;    
+
+    MHAlphaEnergyTime* aetH2 = 
+      (MHAlphaEnergyTime*)(pliston->FindObject("MHAlphaEnergyTime"));
+    TH3D* aetHist2 = (TH3D*)(aetH2->GetHist());
+    aetHist2->SetName("aetimeHist");
+//     aetHist2->DrawClone();
+    aetHist2->Write();
+    gLog << "AlphaEnergyTime plot has been written out" << endl;    
+
+    MHThetabarTime* tbt = 
+      (MHThetabarTime*)(pliston->FindObject("MHThetabarTime"));
+    TProfile* tbtHist = (TProfile*)(tbt->GetHist());
+    tbtHist->SetName("tbtHist");
+    tbtHist->Write();
+    gLog << "ThetabarTime plot has been written out" << endl;    
+
+    MHEnergyTime* ent = 
+      (MHEnergyTime*)(pliston->FindObject("MHEnergyTime"));
+    TH2D* entHist = (TH2D*)(ent->GetHist());
+    entHist->SetName("entHist");
+    entHist->Write();
+    gLog << "EnergyTime plot has been written out" << endl;    
+    
+    MHTimeDiffTheta *time = (MHTimeDiffTheta*)pliston.FindObject("MHTimeDiffTheta");
+    TH2D* timeHist = (TH2D*)(time->GetHist());
+    timeHist->SetName("MHTimeDiffTheta");
+    timeHist->SetTitle("Time diffs");
+    timeHist->Write();
+    gLog << "TimeDiffTheta plot has been written out" << endl;    
+
+
+    MHTimeDiffTime *time2 = (MHTimeDiffTime*)pliston.FindObject("MHTimeDiffTime");
+    TH2D* timeHist2 = (TH2D*)(time2->GetHist());
+    timeHist2->SetName("MHTimeDiffTime");
+    timeHist2->SetTitle("Time diffs");
+    timeHist2->Write();
+    gLog << "TimeDiffTime plot has been written out" << endl;    
+
+//rwagner write also collareas to same file
+    collarea->GetHist()->Write();
+    collarea->GetHAll()->Write();
+    collarea->GetHSel()->Write();
+    gLog << "Effective collection areas have been written out" << endl;        
+
+//rwagner todo: write alpha_cut, type of g/h sep (RF, SC, NN), type of data
+//rwagner (ON/OFF/MC), MJDmin, MJDmax to this file
+
+    gLog << "before closing outfile" << endl;
+
+    //outfile.Close();
+    gLog << "Results were written onto file '" << filenameResults 
+         << "'" << endl;
+    gLog << "=======================================================" << endl;
+  }
+
+  }
+
+    gLog << "Macro CT1Analysis : End of Job E_XX" << endl;
+    gLog << "=======================================================" << endl;
+ }
+  //---------------------------------------------------------------------
+
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/macros/CT1EgyEst.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/CT1EgyEst.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/CT1EgyEst.C	(revision 9661)
@@ -0,0 +1,331 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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,  09/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!              Abelardo Moralejo, 03/2003 <mailto:moralejo@pd.infn.it>
+!              Wolfgang Wittek,   04/2003 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MGeomCamCT1.h"
+#include "MFEventSelector.h"
+#include "MReadTree.h"
+#include "MFCT1SelFinal.h"
+#include "MHMatrix.h"
+#include "MEnergyEstParam.h"
+//#include "MEnergyEstParamDanielMkn421.h"
+#include "MMatrixLoop.h"
+#include "MChisqEval.h"
+
+/*
+#include "MLog.h"
+#include "MLogManip.h"
+*/
+
+void CT1EgyEst()
+{
+  //  TString inPath        = "~magican/ct1test/wittek/marsoutput/optionA/";
+  TString inPath        = "./";
+  TString fileNameIn    = "MC1.root";
+
+  //  TString outPath       = "~magican/ct1test/wittek/marsoutput/optionA/";
+  TString outPath       = "./";
+  TString energyParName = "energyest.root";
+ 
+  TString hilName    = "MHillas";
+  TString hilSrcName = "MHillasSrc";
+
+  //  TString hadronnessName = "MHadronness";
+  TString hadronnessName = "HadNN";
+
+  //  Int_t howMany = 10000;
+  Int_t howMany = 2000;
+
+  Float_t maxhadronness = 0.3;
+  Float_t maxalpha      = 20.0;
+  Float_t maxdist       = 1.;
+
+  MBinning BinningE("BinningE");
+  MBinning BinningTheta("BinningTheta");
+  BinningE.SetEdgesLog(50, 500, 50000.);
+
+  const Double_t yedge[7] = {0.0, 17.5, 23.5, 29.5, 35.5, 42., 50.};
+  const TArrayD yed(7,yedge);
+  BinningTheta.SetEdges(yed);
+
+  CT1EEst(inPath,  fileNameIn, 
+	  outPath, energyParName, 
+	  hilName, hilSrcName,    hadronnessName, 
+	  howMany, maxhadronness, maxalpha, maxdist, 
+	  &BinningE, &BinningTheta);
+}
+
+//------------------------------------------------------------------------
+//
+// Arguments of CT1EEst :
+// ------------------------
+//
+// inPath,  fileNameIn       path and name of input file (MC gamma events)
+// outPath, energyParName    path and name of file containing the parameters
+//                           of the energy estimator
+// hilName, hilSrcName       names of "MHillas" and "MHillasSrc" containers
+// hadronnessName            name of container holding the hadronness
+// howMany                   no.of events to be read from input file
+// maxhadronness             maximum value of hadronness to be accepted
+// maxalpha                  maximum value of |ALPHA| to be accepted
+// maxdist                   maximum value of DIST (degrees) to be accepted
+//
+
+void CT1EEst(TString inPath,  TString fileNameIn, 
+	     TString outPath, TString energyParName,
+	     TString hilName, TString hilSrcName, TString hadronnessName,
+	     Int_t howMany, 
+	     Float_t maxhadronness, Float_t maxalpha, Float_t maxdist,
+	     MBinning* binsE, MBinning* binsTheta)
+{
+  cout << "================================================================"
+       << endl;
+  cout << "Start of energy estimation part" << endl;
+  cout << "" << endl;
+  cout << "CT1EEst input values : " << endl;
+  cout << "---------------------- " << endl;
+  cout << "inPath, fileNameIn = " 
+       <<  inPath << ",  " << fileNameIn << endl;
+  cout << "outPath, energyParName = " 
+       <<  outPath << ",  " << energyParName << endl;
+  cout << "hilName, hilSrcName, hadronnessName = " << hilName << ",  "
+       << hilSrcName << ",  " << hadronnessName << endl;
+  cout << "howMany, maxhadronness, maxalpha, maxdist = " << howMany << ",  "
+       << maxhadronness << ",  " << maxalpha << ",  " << maxdist << endl;
+  cout << "" << endl;
+
+
+  //==========================================================================
+  // Start of Part 1 (determination of the parameters of the energy estimator)
+  //
+
+  //-----------------------------------------------------------------------
+  // Fill events into a MHMatrix, 
+  // to be used later in the minimization by MINUIT
+  //
+
+  MMcEnergyEst Optimize;
+
+  TString inputfile(outPath);
+  inputfile += fileNameIn;
+  Optimize.SetInFile(inputfile);
+
+  TString paramout(outPath);
+  paramout += energyParName;
+  Optimize.SetOutFile(paramout);
+
+  
+  MFCT1SelFinal filterhadrons;
+  filterhadrons.SetHadronnessName(hadronnessName);
+  filterhadrons.SetCuts(maxhadronness, maxalpha, maxdist);
+  filterhadrons.SetInverted();
+  Optimize.SetEventFilter(&filterhadrons);
+  
+
+  Optimize.SetNevents(howMany);
+
+  //
+  // Find the optimal parameters for the energy estimator:
+  //
+  Optimize.FindParams();
+
+  cout << "--------------------------------------" << endl;
+  cout << "Write parameters of energy estimator onto file '" 
+       << paramout << endl;
+  cout << "--------------------------------------" << endl;
+
+  Optimize.Print();
+
+  TFile out(paramout, "recreate");
+  Optimize.SetReadyToSave();
+  Optimize.Write();
+  out.Close();
+
+  //
+  // END of Part 1
+  //==========================================================================
+
+
+
+  //==========================================================================
+  // Start of Part 2 (test quality of energy estimation)
+  //
+  //
+
+  //--------------------------------------------
+  // Read the parameters of the energy estimator 
+  //
+
+  TString paramin(outPath);
+  paramin += energyParName;
+
+  TFile enparam(paramin);
+  MMcEnergyEst mcest;
+  mcest.Read("MMcEnergyEst");
+  enparam.Close();
+
+  cout << "--------------------------------------" << endl;
+  cout << "Read parameters of energy estimator from file '" 
+       << paramin << endl;
+
+  TArrayD parA(5);
+  TArrayD parB(7);
+
+  for (Int_t i=0; i<parA.GetSize(); i++)
+    parA[i] = mcest.GetCoeff(i);
+  for (Int_t i=0; i<parB.GetSize(); i++)
+    parB[i] = mcest.GetCoeff(i+parA.GetSize());
+
+  //-----------------------------------------------
+  // Create energy estimator task, add necessary containers and 
+  // initialize parameters read from file:
+  //
+
+  MEnergyEstParam eest2(hilName);
+  eest2.Add(hilSrcName);
+
+  eest2.SetCoeffA(parA);
+  eest2.SetCoeffB(parB);
+
+  // estimate energy using Daniel's parameters
+  //MEnergyEstParamDanielMkn421 eest2(hilName);
+  //eest2.Add(hilSrcName);
+
+
+  //=======================================================================
+  // Setup the event loop
+  //
+  cout << "--------------------------------------" << endl;
+  cout << "Setup event loop for checking quality of energy estimation" << endl;
+
+
+  MTaskList tlist2;
+  MParList  parlist2;  
+
+  //-----------------------------------------------
+  // Read events
+  //
+
+  TString inputfile(inPath);
+  inputfile += fileNameIn;
+
+  cout << "Read events from file '" << inputfile << "'" << endl;    
+  MReadTree read2("Events");
+  read2.AddFile(inputfile);
+  read2.DisableAutoScheme();
+
+
+  //-----------------------------------------------
+  // Select events
+  //
+  
+  cout << "Select events with hadronness < " << maxhadronness 
+	<< " and |alpha| < " << maxalpha << endl; 
+  MFCT1SelFinal hcut2;
+  hcut2.SetHadronnessName(hadronnessName); hcut2;
+  hcut2.SetCuts(maxhadronness, maxalpha, maxdist);
+
+  MContinue cont(&hcut2);
+  
+  //-----------------------------------------------
+  // Create Object MHMcEnergyMigration containing useful histograms,
+  // and task MHMcEnergyMigration to fill them:
+  //
+
+  //MHMcEnergyMigration mighist;
+
+  MFillH migfill("MHMcEnergyMigration", "MMcEvt");
+
+  MBinning BinningDE("BinningDE");
+  MBinning BinningImpact("BinningImpact");
+ 
+  BinningDE.SetEdges(60, -1.2, 1.2);
+  BinningImpact.SetEdges(50, 0., 400.);
+
+  //********************************
+  // Entries in MParList
+
+  parlist2.AddToList(&tlist2);
+  //parlist2.AddToList(&mighist);
+  parlist2.AddToList(binsE);
+  parlist2.AddToList(binsTheta);
+  parlist2.AddToList(&BinningDE);
+  parlist2.AddToList(&BinningImpact);
+
+  //********************************
+  // Entries in MTaskList
+
+  tlist2.AddToList(&read2);
+  tlist2.AddToList(&cont);
+  tlist2.AddToList(&eest2);
+  tlist2.AddToList(&migfill);
+
+  //-----------------------------------------------
+  cout << "Event loop was setup" << endl; 
+  MProgressBar bar;
+
+  MEvtLoop evtloop2;
+  evtloop2.SetProgressBar(&bar);
+  evtloop2.SetParList(&parlist2);
+
+  if (!evtloop2.Eventloop())
+    return;
+
+  tlist2.PrintStatistics(0, kTRUE);
+
+  MHMcEnergyMigration &mighist = 
+    *(MHMcEnergyMigration*)parlist2->FindObject("MHMcEnergyMigration");
+  if (!&mighist)
+  {
+    cout << "CT1EgyEst.C : object 'MHMcEnergyMigration' not found ... aborting"
+         << endl;
+    return;
+  }
+
+  TString paramout(outPath);
+  paramout += energyParName;
+
+  TFile out2(paramout, "UPDATE");
+  mighist.Write();
+  out2.Close();
+
+  TCanvas *c = new TCanvas;
+  c->cd();
+  mighist.Draw();
+
+  cout << "Quality histograms and migration matrix were added onto the file '" << paramout << endl;
+  cout << endl;
+  cout << "End of energy estimation part" << endl;
+  cout << "================================================================" << endl;
+  //
+  // End of Part 2 (test quality of energy estimation)
+  //==========================================================================
+  //
+
+  return;
+
+}
Index: /tags/Mars_V0-8-5/Mars/macros/CT1Hillas.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/CT1Hillas.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/CT1Hillas.C	(revision 9661)
@@ -0,0 +1,169 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz et al,  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+
+void CT1Hillas(const char *filename)
+{
+    //
+    // This is a demonstration program which calculates the Hillas
+    // parameter out of a Magic root file (raw data file).
+    //
+
+    //
+    // Create a empty Parameter List and an empty Task List
+    // The tasklist is identified in the eventloop by its name
+    //
+    MParList plist;
+
+
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    //
+    // The geometry container must be created by yourself to make sure
+    // that you don't choos a wrong geometry by chance
+    //
+    MGeomCamCT1 geomcam;
+    plist.AddToList(&geomcam);
+
+    //
+    // Use this if you want to change the binning of one of
+    // the histograms. You can use:
+    // BinningConc, BinningConc1, BinningAsym, BinningM3Long,
+    // BinningM3Trans, BinningWidth, BinningLength, BinningDist,
+    // BinningHeadTail, BinningAlpha, BinningSize, BinningDelta,
+    // BinningPixels and BinningCamera
+    //
+    // For more information see MBinning and the corresponding
+    // histograms
+    //
+    // MBinning binsalpha("BinningAlpha");
+    // binsalpha.SetEdges(90, 0, 90);       // 90 bins from 0 to 90 deg
+    // plist.AddToList(&binsalpha);
+
+    // MBinning binssize("BinningSize");
+    // binssize.SetEdgesLog(50, 1, 1e7);
+    // plist.AddToList(&binssize);
+
+    //
+    // Craete the object which hlods the source positions in the camera
+    // plain in respect to which the image parameters will be calculated.
+    // For real data the containers will be filled by a task.
+    //
+    MSrcPosCam source("Source")
+    source.SetXY(0, 0);
+    plist.AddToList(&source);
+
+    //
+    // Now setup the tasks and tasklist:
+    //
+    //  1) read in the data from a ct1 ascii file   MCTReadAscii
+    //  2) clean the image                          MImgCleanStd
+    //  3) calculate hillas                         MHillasCalc
+    //  4) fill the hillas into the histograms      MFillHHillas
+    //
+    MCT1ReadAscii read("../data/CT1_97_on1.dat");
+    //read.AddFile("../data/CT1_97_off1.dat");
+
+    MMcPedestalCopy pcopy;
+    MMcPedestalNSBAdd pnsb;
+
+    MCerPhotCalc ncalc;
+
+    MCameraSmooth   smooth;
+    MImgCleanStd    clean;
+    MBlindPixelCalc blind;
+    //
+    // Instead of unmapping the pixels you can also
+    //
+    // blind.SetUseInterpolation();
+    // blind.SetUseCetralPixel();
+    //
+    MHillasCalc    hcalc;
+    MHillasSrcCalc csrc1("Source",  "HillasSource");
+
+    //
+    // Uncomment this two line if you want to use MHillasExt instead
+    // of MHillas
+    //
+    //MHillasExt hext;
+    //plist.AddToList(&hext);
+
+    MFillH hfill1("MHHillas", "MHillas");
+    MFillH hfill2("MHHillasExt");
+    MFillH hfill3("MHStarMap", "MHillas");
+    MFillH hfill4("HistExtSource [MHHillasExt]", "HillasSource");
+    MFillH hfill5("HistSource [MHHillasSrc]", "HillasSource");
+
+    MWriteRootFile write("hillas.root");
+    write.AddContainer("MHStarMap");
+    write.AddContainer("MHHillas");
+    write.AddContainer("MHHillasExt");
+    write.AddContainer("HistSource");
+    write.AddContainer("HistExtSource");
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&pcopy);
+    tlist.AddToList(&pnsb);
+    tlist.AddToList(&ncalc);
+    tlist.AddToList(&clean);
+    tlist.AddToList(&blind);
+
+    tlist.AddToList(&hcalc);
+    tlist.AddToList(&csrc1);
+    tlist.AddToList(&csrc2);
+
+    tlist.AddToList(&hfill1);
+    tlist.AddToList(&hfill2);
+    tlist.AddToList(&hfill3);
+    tlist.AddToList(&hfill4);
+    tlist.AddToList(&hfill5);
+    tlist.AddToList(&write);
+
+    //
+    // Create and setup the eventloop
+    //
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    //
+    // Execute your analysis
+    //
+    MProgressBar bar;
+    evtloop.SetProgressBar(&bar);
+    if (!evtloop.Eventloop())
+        return;
+
+    tlist.PrintStatistics();
+
+    //
+    // After the analysis is finished we can display the histograms
+    //
+    plist.FindObject("MHHillas")->DrawClone();
+    plist.FindObject("MHHillasExt")->DrawClone();
+    plist.FindObject("MHStarMap")->DrawClone();
+    plist.FindObject("HistSource")->DrawClone();
+    plist.FindObject("HistExtSource")->DrawClone();
+}
+
Index: /tags/Mars_V0-8-5/Mars/macros/CT1collarea.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/CT1collarea.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/CT1collarea.C	(revision 9661)
@@ -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)
+!   Author(s): Abelardo Moralejo 4/2003 <mailto:moralejo@pd.infn.it>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+void CT1collarea(TString filename="MC_SC4.root", TString outname="")
+{ 
+
+    //
+    // 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);
+    reader.DisableAutoScheme();
+
+    MHMcCT1CollectionArea collarea;
+
+    MBinning binsx("BinningE");
+
+    /*
+    Double_t xedge[15] = {2.47712, 2.64345, 2.82607, 3., 3.17609, 3.35218, 3.52892, 3.70415, 3.88024, 4.05652, 4.23274, 4.40875, 4.58478, 4.76080, 4.90309};
+    const TArrayD xed;
+    xed.Set(15,xedge);
+    binsx.SetEdges(xed);
+    collarea.SetEaxis(MHMcCollectionArea::kLog10);
+    */
+
+    //
+    // SetEaxis tells MHMcCT1CollectionArea whether the variable to histogram
+    // is the Energy (argument is kEnergy) or its decimal logarithm 
+    // (kLog10Energy). Of course this depends on how the energy binning is 
+    // defined via the object binsx. 
+    //
+    binsx.SetEdgesLog(14,300,1.e5);
+    collarea.SetEaxis(MHMcCT1CollectionArea::kLinear);
+
+
+    MBinning binsy("BinningTheta");
+    const Double_t yedge[9] = {0.0, 17.5, 23.5, 29.5, 35.5, 42., 50., 60., 70.};
+    const TArrayD yed;
+    yed.Set(9,yedge);
+    binsy.SetEdges(yed);
+
+    parlist.AddToList(&collarea);
+    parlist.AddToList(&binsx);
+    parlist.AddToList(&binsy);
+
+    tasklist.AddToList(&reader);   
+
+    MF filterhadrons("HadSC.fHadronness<0.3 && {abs(MHillasSrc.fAlpha)} < 13.1");
+    tasklist.AddToList(&filterhadrons);
+
+
+    MFillH filler("MHMcCT1CollectionArea","MMcEvt");
+    filler.SetFilter(&filterhadrons);
+    tasklist.AddToList(&filler);
+
+    //
+    // set up the loop for the processing
+    //
+    MEvtLoop magic;
+    magic.SetParList(&parlist);
+
+    //
+    // Start to loop over all events
+    //
+    MProgressBar bar;
+    magic.SetProgressBar(&bar);
+    if (!magic.Eventloop())
+        return;
+
+    tasklist.PrintStatistics();
+
+    collarea.CalcEfficiency();
+
+    //
+    // Now the histogram we wanted to get out of the data is
+    // filled and can be displayed
+    //
+    collarea.DrawClone();
+
+    //
+    // Write histogram to a file in case an output
+    // filename has been supplied
+    //
+    if (outname.IsNull())
+        return;
+
+    TFile f(outname,"recreate");
+    collarea.GetHist()->Write();
+    collarea.GetHAll()->Write();
+    collarea.GetHSel()->Write();
+}
+
Index: /tags/Mars_V0-8-5/Mars/macros/CT1env.rc
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/CT1env.rc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/CT1env.rc	(revision 9661)
@@ -0,0 +1,38 @@
+# Environment file for CT1 analysis
+#----------------------------------
+
+#-----------------------------------------------------------
+# Setup Matrix columns for all jobs and all MHMatrix objects
+#
+
+MHMatrix.Column0: cos(MMcEvt.fTelescopeTheta)
+MHMatrix.Column1: MSigmabar.fSigmabar
+MHMatrix.Column2: log10(MHillas.fSize)
+MHMatrix.Column3: MHillasSrc.fDist
+MHMatrix.Column4: MHillas.fWidth
+MHMatrix.Column5: MHillas.fLength
+MHMatrix.Column6: log10(MHillas.fSize/(MHillas.fWidth*MHillas.fLength))
+MHMatrix.Column7: sgn(MHillasSrc.fCosDeltaAlpha)*(MHillasExt.fM3Long)
+MHMatrix.Column8: MNewImagePar.fConc
+MHMatrix.Column9: MNewImagePar.fLeakage1
+
+
+#-----------------------------------------------------------
+# Setup Files for Job1
+# 
+##Job1.MRead.File0: rootfile1.root
+##Job1.MRead.File1: rootfiles*.root
+##Job1.MRead.File2: rootfile3.root
+
+#-----------------------------------------------------------
+# Setup Files for Job2
+# 
+##Job2.MRead.File0: otherrootfile.root
+
+#
+# Setup columns for a matrix called MatrixGammas in Job2
+#
+##Job2.MatrixGammas.Column0: MHillasSrc.fDist
+##Job2.MatrixGammas.Column1: sin(MMcEvt.fTelescopePhi)
+
+#-----------------------------------------------------------
Index: /tags/Mars_V0-8-5/Mars/macros/DAQDataCheck.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/DAQDataCheck.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/DAQDataCheck.C	(revision 9661)
@@ -0,0 +1,313 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Raquel de los Reyes, 05/2004 <mailto:reyes@gae.ucm.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+/////////////////////////////////////////////////////////////////////////////
+//
+// This macro makes the check of the DAQ files (.raw files).
+//
+// The only argument to the macro is the directory with the night raw files
+// (ended with "/"). The macro sorts the entries in alphabetical order;
+// it then joins all the consecutive pedestal, calibration and data runs 
+// and analyses all of them together. Data runs are taken consecutively
+// until it finds a run of other type (pedestal or calibration) or a data run 
+// from another source. When a given source has no previous pedestal and/or
+// calibration runs, the macro takes the most recent ones. 
+//
+// The analysis is done through the jobs classes MJPedestal and MJCalibration.
+//
+///////////////////////////////////////////////////////////////////////////
+void DataAnalysis(const Int_t prun1,const Int_t prun2,
+		  const Int_t crun1,const Int_t crun2,
+		  const Int_t drun1,const Int_t drun2,
+		  const TString inpath,
+		  const TString outdir)
+{
+
+  // Check if no pedestal runs has been detected
+  if(prun1==0)
+  {
+      cout << "No pedestal run(s)!!!"<< endl;
+      break;
+  }
+
+  gStyle->SetOptStat(1);
+  gStyle->SetOptFit();
+
+  MRunIter pruns;
+  MRunIter cruns;
+  MRunIter druns;
+  //
+  // Set the filter of MRunIter to .raw files
+  pruns.SetRawFile(kTRUE);
+  cruns.SetRawFile(kTRUE);
+  druns.SetRawFile(kTRUE);
+
+  //
+  // Check if you are analyzing more than one file
+  if(prun1==prun2)
+    pruns.AddRun(prun1,inpath);
+  else
+    pruns.AddRuns(prun1,prun2,inpath);
+  if(crun1==crun2)
+    cruns.AddRun(crun1,inpath);
+  else
+    cruns.AddRuns(crun1,crun2,inpath);
+  if(drun1==drun2)
+    druns.AddRun(drun1,inpath);
+  else
+    druns.AddRuns(drun1,drun2,inpath);
+
+  // 
+  // Set up the source run-range
+  //
+  TRegexp type("_[A-Z]_");
+  TString source = "";
+  if(pruns.GetNumRuns()!=0)
+    source = pruns.Next();
+  source = source(source.Index(type)+3,source.Length());
+  source.Remove(source.Last('_'),source.Length());
+
+  TString title = outdir+source+"_"+prun2+"-"+crun2+"-"+drun2+".ps";
+
+  MStatusDisplay *d = new MStatusDisplay;
+  d->SetTitle(title);
+  d->SetLogStream(&gLog, kTRUE);
+
+  TObject::SetObjectStat(kTRUE);
+ 
+  //
+  // Choose the signal Extractor:
+  //
+  //  MExtractFixedWindowPeakSearch extractor;
+  //  MExtractSlidingWindow  extractor;
+   MExtractFixedWindow    extractor;
+ 
+  //
+  // Set Ranges or Windows
+  //
+   extractor.SetRange(3,14,3,14);
+  //  extractor.SetWindows(8,8);
+ 
+  //
+  // Choose the arrival time Extractor:
+  //
+  //  MExtractTimeHighestIntegral timeext;
+  MExtractTimeFastSpline timeext;
+  //
+  // Set Ranges or Windows
+  //
+  timeext.SetRange(2,12,4,14);
+
+  // ************************ GENERAL CONTAINERS  *************************
+  MBadPixelsCam     badcam;
+  MGeomCamMagic     geomcam;
+  MGeomApply        geomapl;
+  MCalibrationQECam qecam;  
+
+  // **********************************************************************
+  // ***************************** PEDESTALS ******************************
+  // **********************************************************************
+  if(pruns.GetNumRuns()==0)
+    {
+      cout << "Warning, no entries found in pedestal run(s)!!!"<< endl;
+      break;
+    }
+
+  MJPedestal pedloop;
+  pedloop.SetExtractor(&extractor);           
+  pedloop.SetInput(&pruns);
+  pedloop.SetDisplay(d);
+  pedloop.SetBadPixels(badcam);
+  //
+  // If you want to run the data-check on RAW DATA!!!, choose:
+  pedloop.SetDataCheck(kTRUE);
+
+  //
+  // Execute first analysis
+  //
+  cout << "*************************" << endl;
+  cout << "** COMPUTING PEDESTALS **" << endl;
+  cout << "*************************" << endl;
+  if (!pedloop.Process())
+    return;
+
+  //
+  // Save display into a postcript file
+  //
+  d->SaveAsPS(outdir+source+"_"+prun2+"-"+crun2+"-"+drun2+".ps");
+
+  // **********************************************************************
+  // ***************************** CALIBRATION ****************************
+  // **********************************************************************
+  if(cruns.GetNumRuns()==0)
+    {
+      cout << "Warning, no entries found in calibration run(s)!!!"<< endl;
+      break;
+    }
+
+  //
+  // Tell if you want to calibrate times:
+  //
+  static const  Bool_t useTimes = kTRUE;
+
+  MJCalibration calloop;
+  //
+  // If you want to run the data-check on RAW DATA!!!, choose:
+  calloop.SetDataCheck();
+  //
+  // If you want to see the data-check plots only, choose:
+  calloop.SetDataCheckDisplay();
+
+  calloop.SetRelTimeCalibration(useTimes);
+  calloop.SetExtractor(&extractor);
+  calloop.SetTimeExtractor(&timeext);
+  calloop.SetInput(&cruns);
+  calloop.SetDisplay(d);
+  calloop.SetQECam(qecam);
+  calloop.SetBadPixels(pedloop.GetBadPixels());            
+
+  //
+  // Execute first analysis
+  //
+  cout << "***************************" << endl;
+  cout << "** COMPUTING CALIBRATION **" << endl;
+  cout << "***************************" << endl;
+  if (!calloop.Process(pedloop.GetPedestalCam()))
+    return;
+
+  //
+  // Save display into a postcript file
+  //
+  d->SaveAsPS(outdir+source+"_"+prun2+"-"+crun2+"-"+drun2+".ps");
+
+
+}
+
+void DAQDataCheck(const TString directory="/remote/bigdown/data/Magic-DATA/Period014/rawdata/2004_02_17/",const TString outdir="./")
+{
+
+  MDirIter iter;
+  iter.AddDirectory(directory,"*.raw");
+
+  TString str=iter.Next();
+
+  TList list;
+  while(!str.IsNull())
+    {
+      list.Add(new TNamed(str,""));
+      str=iter.Next();
+    }
+  list.Sort();
+
+  TIter Next(&list);
+
+  TString fName="file.raw";
+
+  TRegexp run("_[0-9][0-9][0-9][0-9][0-9]_");
+  TRegexp type("_[A-Z]_");
+
+  Int_t pedrun1=0, pedrun2=0;
+  Int_t calrun1=0, calrun2=0;
+  Int_t datarun1=0, datarun2=0;
+
+  TString source="";
+
+  TObject o*;
+  o=Next();
+  fName = o->GetName();  // absolut path
+
+  while(!fName.IsNull())
+    {
+
+      source = fName(fName.Index(type)+3,fName.Length());
+      source.Remove(source.Last('_'),source.Length());
+
+      // Pedestal runs
+      if(fName.Contains("_P_"))
+	pedrun1=atoi(fName(fName.Index(run)+1,5).Data());
+      pedrun2=pedrun1;
+
+      while(fName.Contains("_P_")&&fName.Contains(source))
+	{
+	  pedrun2=atoi(fName(fName.Index(run)+1,5).Data());
+	  o=Next();
+	  if(!o)
+	    {
+	      fName="";
+	      break;
+	    }
+	  fName = o->GetName(); 
+	}
+
+      // Calibration runs
+      if(fName.Contains("_C_"))//||(!fName.Contains(source)))
+	calrun1=atoi(fName(fName.Index(run)+1,5).Data());
+//      else
+//	  calrun1=0; 
+      calrun2=calrun1;
+
+      while(fName.Contains("_C_")&&fName.Contains(source))
+	{
+	  calrun2=atoi(fName(fName.Index(run)+1,5).Data());
+	  o=Next();
+	  if(!o)
+	    {
+	      fName = "";
+	      break;
+	    }
+	  fName = o->GetName(); 
+	}
+
+      // Data runs
+      if(fName.Contains("_D_"))//||(!fName.Contains(source)))
+	datarun1=atoi(fName(fName.Index(run)+1,5).Data());
+      else
+	  datarun1=0; 
+      datarun2=datarun1;
+
+      while(fName.Contains("_D_")&&fName.Contains(source))
+	{
+	  datarun2=atoi(fName(fName.Index(run)+1,5).Data());
+	  o=Next();
+	  if(!o)
+	    {
+	      fName = "";
+	      break;
+	    }
+	  fName = o->GetName(); 
+	}
+
+//        cout << pedrun1 << "\t"<<pedrun2 << endl;
+//        cout << calrun1 << "\t"<<calrun2 << endl;
+//        cout << datarun1 << "\t"<<datarun2 << endl;
+
+      DataAnalysis(pedrun1,pedrun2,calrun1,calrun2,datarun1,datarun2,directory,outdir);
+
+      cout << "----------------------------------------------" << endl;
+
+    }
+
+}
+
+
+
Index: /tags/Mars_V0-8-5/Mars/macros/MagicHillas.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/MagicHillas.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/MagicHillas.C	(revision 9661)
@@ -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@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////////
+//
+// MagicHillas.C
+// =============
+//
+// This is a demonstration program which calculates image (Hillas +)
+// parameters using as input a Merpp output file (raw data).
+// All parameters are written to an output file called hillas.root. Also
+// filles histograms are displayed.
+// For the calculation an arbitrary signal extractor (MCerPhotAnal2/Calc)
+// is used.
+//
+///////////////////////////////////////////////////////////////////////////
+
+void MagicHillas(const char *filename="~/data/Gamma_20_N*.root")
+{
+    //
+    // Create a empty Parameter List and an empty Task List
+    // The tasklist is identified in the eventloop by its name
+    //
+    MParList plist;
+
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    //
+    // Use this if you want to change the binning of one of
+    // the histograms. You can use:
+    // BinningConc, BinningConc1, BinningAsym, BinningM3Long,
+    // BinningM3Trans, BinningWidth, BinningLength, BinningDist,
+    // BinningHeadTail, BinningAlpha, BinningSize, BinningDelta,
+    // BinningPixels and BinningCamera
+    //
+    // For more information see MBinning and the corresponding
+    // histograms
+    //
+    // MBinning binsalpha("BinningAlpha");
+    // binsalpha.SetEdges(90, 0, 90);       // 90 bins from 0 to 90 deg
+    // plist.AddToList(&binsalpha);
+
+    // MBinning binssize("BinningSize");
+    // binssize.SetEdgesLog(50, 1, 1e7);
+    // plist.AddToList(&binssize);
+
+    //
+    // Craete the object which hlods the source positions in the camera
+    // plain in respect to which the image parameters will be calculated.
+    // For real data the containers will be filled by a task.
+    //
+    MSrcPosCam source;
+    source.SetReadyToSave();
+    plist.AddToList(&source);
+
+    //
+    // Now setup the tasks and tasklist:
+    // ---------------------------------
+    //
+    // The first argument is the tree you want to read.
+    //   Events:     Cosmic ray events
+    //   PedEvents:  Pedestal Events
+    //   CalEvents:  Calibration Events
+    //
+    MReadMarsFile read("Events", filename);
+    read.DisableAutoScheme();
+
+    // Setup a task which makes sure that all used arrays have
+    // the correct size
+    MGeomApply geomapl;
+
+    // tasks used if MC files are detected to calculate pedestals
+    MMcPedestalCopy pcopy;
+    MMcPedestalNSBAdd pnsb;
+
+    // calculate the signal in a very simple way
+    // for real adat files use MCerPhotAnal2 instead which also
+    // calculates the pedestal.
+    MCerPhotCalc ncalc;
+    //
+    //  Alternative photon calculation:
+    //  Example: use only 2nd to 6th FADC slices for photon calculation:
+    //
+    //    const Float_t x[15]={0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+    //    const TArrayF w(15,(Float_t*)x);
+    //    ncalc.SetWeights(w);
+    //
+
+    // setup image cleaning and blind pixel treatment
+    MImgCleanStd    clean;
+    MBlindPixelCalc blind;
+
+    //
+    // Instead of unmapping the pixels you can also (The use of this
+    // class is deprecated, it will be replaced by MBadPixels*)
+    //
+    // blind.SetUseInterpolation();
+    // blind.SetUseCetralPixel();
+    //
+
+    // setup tasks to calculate image parameters
+    MHillasCalc    hcalc;
+    MHillasSrcCalc csrc1;
+
+    // setup tasks to fill histograms
+    MFillH hfill1("MHHillas", "MHillas");
+    MFillH hfill2("MHHillasExt");
+    MFillH hfill3("MHStarMap", "MHillas");
+    MFillH hfill4("HistExtSource [MHHillasExt]", "MHillasSrc");
+    MFillH hfill5("HistSource [MHHillasSrc]", "MHillasSrc");
+    MFillH hfill6("MHNewImagePar");
+
+    // setup task to write containers to a file
+    MWriteRootFile write("hillas.root");
+    write.AddContainer("MHStarMap");
+    write.AddContainer("MHHillas");
+    write.AddContainer("MHHillasExt");
+    write.AddContainer("HistSource");
+    write.AddContainer("HistExtSource");
+    write.AddContainer("MHNewImagePar");
+
+    // Setup the contents of zour tasklist
+    tlist.AddToList(&read);
+    tlist.AddToList(&geomapl);
+    tlist.AddToList(&pcopy);
+    tlist.AddToList(&pnsb);
+    tlist.AddToList(&ncalc);
+    tlist.AddToList(&clean);
+    tlist.AddToList(&blind);
+
+    tlist.AddToList(&hcalc);
+    tlist.AddToList(&csrc1);
+
+    tlist.AddToList(&hfill1);
+    tlist.AddToList(&hfill2);
+    tlist.AddToList(&hfill3);
+    tlist.AddToList(&hfill4);
+    tlist.AddToList(&hfill5);
+    tlist.AddToList(&hfill6);
+    tlist.AddToList(&write);
+
+    //
+    // Create and setup the eventloop
+    //
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    //
+    // Execute your analysis
+    //
+    MProgressBar bar;
+    evtloop.SetProgressBar(&bar);
+    if (!evtloop.Eventloop())
+        return;
+
+    tlist.PrintStatistics();
+
+    //
+    // After the analysis is finished we can display the histograms
+    //
+    plist.FindObject("MHHillas")->DrawClone();
+    plist.FindObject("MHHillasExt")->DrawClone();
+    plist.FindObject("MHStarMap")->DrawClone();
+    plist.FindObject("HistSource")->DrawClone();
+    plist.FindObject("HistExtSource")->DrawClone();
+    plist.FindObject("MHNewImagePar")->DrawClone();
+}
+
Index: /tags/Mars_V0-8-5/Mars/macros/ONAnalysis.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/ONAnalysis.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/ONAnalysis.C	(revision 9661)
@@ -0,0 +1,3447 @@
+
+//#include "MagicEgyEst.C"
+
+void InitBinnings(MParList *plist)
+{
+        gLog << "InitBinnings" << endl;
+
+        //--------------------------------------------
+        MBinning *binse = new MBinning("BinningE");
+        //binse->SetEdgesLog(30, 1.0e2, 1.0e5);
+
+	//This is Daniel's binning in energy:
+        binse->SetEdgesLog(14, 296.296, 86497.6);
+        plist->AddToList(binse);
+
+        //--------------------------------------------
+
+        MBinning *binssize = new MBinning("BinningSize");
+        binssize->SetEdgesLog(50, 10, 1.0e5);
+        plist->AddToList(binssize);
+
+        MBinning *binsdistc = new MBinning("BinningDist");
+        binsdistc->SetEdges(50, 0, 1.4);
+        plist->AddToList(binsdistc);
+
+        MBinning *binswidth = new MBinning("BinningWidth");
+        binswidth->SetEdges(50, 0, 1.0);
+        plist->AddToList(binswidth);
+
+        MBinning *binslength = new MBinning("BinningLength");
+        binslength->SetEdges(50, 0, 1.0);
+        plist->AddToList(binslength);
+
+        MBinning *binsalpha = new MBinning("BinningAlpha");
+        binsalpha->SetEdges(100, -100, 100);
+        plist->AddToList(binsalpha);
+
+        MBinning *binsasym = new MBinning("BinningAsym");
+        binsasym->SetEdges(50, -1.5, 1.5);
+        plist->AddToList(binsasym);
+
+        MBinning *binsm3l = new MBinning("BinningM3Long");
+        binsm3l->SetEdges(50, -1.5, 1.5);
+        plist->AddToList(binsm3l);
+
+        MBinning *binsm3t = new MBinning("BinningM3Trans");
+        binsm3t->SetEdges(50, -1.5, 1.5);
+        plist->AddToList(binsm3t);
+
+   
+        //.....
+        MBinning *binsb = new MBinning("BinningSigmabar");
+        binsb->SetEdges( 100,  0.0,  5.0);
+        plist->AddToList(binsb);
+
+        MBinning *binth = new MBinning("BinningTheta");
+        // this is Daniel's binning in theta
+        //Double_t yedge[8] = 
+        //  {9.41, 16.22, 22.68, 28.64, 34.03, 38.84, 43.08, 44.99};
+        // this is our binning
+        Double_t yedge[9] = 
+                       {0.0, 17.5, 23.5, 29.5, 35.5, 42., 50., 60., 70.};
+        TArrayD yed;
+        yed.Set(9,yedge);
+        binth->SetEdges(yed);
+        plist->AddToList(binth);
+
+        MBinning *bincosth = new MBinning("BinningCosTheta");
+        Double_t zedge[9]; 
+        for (Int_t i=0; i<9; i++)
+	{
+          zedge[8-i] = cos(yedge[i]/kRad2Deg);
+	}
+        TArrayD zed;
+        zed.Set(9,zedge);
+        bincosth->SetEdges(zed);
+        plist->AddToList(bincosth);
+
+        MBinning *binsdiff = new MBinning("BinningDiffsigma2");
+        binsdiff->SetEdges(100, -5.0, 20.0);
+        plist->AddToList(binsdiff);
+
+        // robert ----------------------------------------------
+        MBinning *binsalphaf = new MBinning("BinningAlphaFlux");
+        binsalphaf->SetEdges(100, -100, 100);
+        plist->AddToList(binsalphaf);
+
+	MBinning *binsdifftime = new MBinning("BinningTimeDiff");
+	binsdifftime->SetEdges(50, 0, 10);
+	plist->AddToList(binsdifftime);
+
+	MBinning *binstime = new MBinning("BinningTime");
+	binstime->SetEdges(50, 44500, 61000);
+	plist->AddToList(binstime);
+}
+
+
+void DeleteBinnings(MParList *plist)
+{
+        gLog << "DeleteBinnings" << endl;
+
+        TObject *bin;
+
+        //--------------------------------------------
+        bin = plist->FindObject("BinningE");
+        if (bin) delete bin;
+
+        //--------------------------------------------
+
+        bin = plist->FindObject("BinningSize");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningDist");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningWidth");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningLength");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningAlpha");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningAsym");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningM3Long");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningM3Trans");
+        if (bin) delete bin;
+
+        //.....
+        bin = plist->FindObject("BinningSigmabar");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningTheta");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningCosTheta");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningDiffsigma2");
+        if (bin) delete bin;
+
+
+        // robert ----------------------------------------------
+        bin = plist->FindObject("BinningAlphaFlux");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningTimeDiff");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningTime");
+        if (bin) delete bin;
+}
+
+
+//************************************************************************
+void ONAnalysis()
+{
+
+  gLog << "Entry ONAnalysis()" << endl;
+
+      gLog.SetNoColors();
+
+      if (gRandom)
+        delete gRandom;
+      gRandom = new TRandom3(0);
+
+      //-----------------------------------------------
+      const char *offfile = 
+      "/.magic/data14a/crab_2003Nov/rootdata/2003_11_29/*OffCrab1*.root"; 
+
+      const char *onfile  = 
+      "/.magic/data14a/crab_2003Nov/rootdata/2003_11_29/*Crab-Nebula*.root"; 
+      const char *onfile1  = 
+      "/.magic/data14a/crab_2003Nov/rootdata/2003_11_30/*CrabNebula*.root"; 
+
+      const char *mcfile  = 
+            "/data/MAGIC/mc_eth/magLQE_3/gh/0/0/G_M0_00_0_550*.root";
+      //-----------------------------------------------
+
+      // path for input for Mars
+      TString inPath =  "/.magic/data14a/wittek/ONAnalysis/";
+
+      // path for output from Mars
+      TString outPath = "/.magic/data14a/wittek/ONAnalysis/";
+
+      //-----------------------------------------------
+
+      //TEnv env("macros/CT1env.rc");
+      //Bool_t printEnv = kFALSE;
+
+    //************************************************************************
+
+    // Job A_ON : read ON data
+    //  - generate sigmabar vs. Theta plot; 
+    //  - write root file for ON data (ON1.root);
+
+    Bool_t JobA_ON = kTRUE;  
+    Bool_t WHistON = kFALSE;   // write out histogram sigmabar vs. Theta ?
+    Bool_t WON1    = kFALSE;   // write out root file ON1.root ?
+
+
+    // Job A_MC : read MC gamma data, 
+    //  - read sigmabar vs. Theta plot from ON data  
+    //  - do padding; 
+    //  - write root file for MC gammas (MC1.root);
+
+    Bool_t JobA_MC  = kFALSE;  
+    Bool_t WMC1     = kFALSE;  // write out root file MC1.root ?
+
+
+    // Job B_RF_UP : read ON1.root (or MC1.root) file 
+    //  - if RTrainRF = TRUE : read in training matrices for hadrons and gammas
+    //  - if CTrainRF = TRUE : create  training matrices for hadrons and gammas
+    //  - if RTree    = TRUE : read in trees, otherwise create trees
+    //  - calculate hadroness for method of RANDOM FOREST
+    //  - update the input files with the hadroness (==>ON2.root or MC2.root)
+
+    Bool_t JobB_RF_UP  = kFALSE;  
+    Bool_t CTrainRF    = kFALSE;  // create matrices of training events
+    Bool_t RTrainRF    = kFALSE;  // read in matrices of training events
+    Bool_t RTree       = kFALSE;  // read in trees (otherwise grow them)
+    Bool_t WRF         = kFALSE;  // update input root file ?
+
+
+
+
+    // Job B_SC_UP : read ON2.root (or MC2.root) file 
+    //  - depending on WParSC : create (or read in) supercuts parameter values
+    //  - calculate hadroness for the SUPERCUTS
+    //  - update the input files with the hadroness (==>ON3.root or MC3.root)
+
+    Bool_t JobB_SC_UP  = kFALSE;
+    Bool_t CMatrix     = kFALSE;  // create training and test matrices 
+    Bool_t RMatrix     = kFALSE;  // read training and test matrices from file
+    Bool_t WOptimize   = kFALSE;  // do optimization using the training sample
+                                  // and write supercuts parameter values 
+                                  // onto the file parSCfile
+    Bool_t RTest       = kFALSE;  // test the supercuts using the test matrix
+    Bool_t WSC         = kFALSE;  // update input root file ?
+
+
+
+    // Job C: 
+    //  - read ON3.root and MC3.root files
+    //    which should have been updated to contain the hadronnesses  
+    //    for the method of 
+    //              RF
+    //              SUPERCUTS and
+    //  - produce Neyman-Pearson plots
+
+    Bool_t JobC  = kFALSE;  
+
+
+    // Job D :  
+    //  - select g/h separation method XX
+    //  - read ON3 (or MC3) root file
+    //  - apply cuts in hadronness
+    //  - make plots
+
+    Bool_t JobD  = kFALSE;  
+
+
+
+
+    // Job E_XX : extended version of E_XX (including flux plots)  
+    //  - select g/h separation method XX
+    //  - read MC root file 
+    //  - calculate eff. collection area
+    //  - optimize energy estimator
+    //  - read ON root file 
+    //  - apply final cuts
+    //  - calculate flux
+    //  - write root file for ON data after final cuts 
+
+
+    Bool_t JobE_XX  = kFALSE;  
+    Bool_t CCollArea= kFALSE;  // calculate eff. collection areas
+    Bool_t OEEst    = kFALSE;  // optimize energy estimator
+    Bool_t WEX      = kFALSE;  // update root file  ?
+    Bool_t WRobert  = kFALSE;  // write out Robert's file  ?
+
+
+
+    //************************************************************************
+
+    
+  //---------------------------------------------------------------------
+  // Job A_ON
+  //=========
+    // read ON data file 
+
+    //  - produce the 2D-histogram "sigmabar versus Theta" 
+    //    (SigmaTheta_ON.root) for ON data
+    //    (to be used for the padding of the MC gamma data)
+
+    //  - write a file of ON events (ON1.root) 
+    //    (after the standard cuts, before the g/h separation)
+    //    (to be used together with the corresponding MC gamma file (MC1.root)
+    //     for the optimization of the g/h separation)
+
+
+ if (JobA_ON)
+ {
+    gLog << "=====================================================" << endl;
+    gLog << "Macro ONAnalysis : Start of Job A_ON" << endl;
+    gLog << "" << endl;
+    gLog << "Macro ONAnalysis : JobA_ON, WHistON, WON1 = " 
+         << (JobA_ON ? "kTRUE" : "kFALSE")  << ",  " 
+         << (WHistON ? "kTRUE" : "kFALSE")  << ",  " 
+         << (WON1    ? "kTRUE" : "kFALSE")  << endl;
+
+
+    // name of input root file
+    TString filenamein(onfile);
+    TString filenamein1(onfile1);
+
+    // name of output root file
+    TString outNameImage = outPath;
+    outNameImage += "ON";
+    outNameImage += "1.root";
+
+    //--------------------------------------------------
+    // use for padding sigmabar vs. Theta from ON data
+    TString typeHist = "ON";
+    gLog << "typeHist = " << typeHist << endl;
+
+    // name of file to conatin the histograms for the padding
+    TString outNameSigTh = outPath;
+    outNameSigTh += "SigmaTheta_";
+    outNameSigTh += typeHist;
+    outNameSigTh += ".root";
+
+
+    //-----------------------------------------------------------
+    MTaskList tliston;
+    MParList pliston;
+
+    char *sourceName = "MSrcPosCam";
+    MSrcPosCam source(sourceName);
+
+    // geometry is needed in  MHHillas... classes 
+    MGeomCam *fGeom = 
+             (MGeomCam*)pliston->FindCreateObj("MGeomCamMagic", "MGeomCam");
+
+    //-------------------------------------------
+    // create the tasks which should be executed 
+    //
+
+    TFile test("/.magic/data14a/crab_2003Nov/rootdata/2003_11_29/20031128_03127_P_Crab-Nebula_E.root");
+    test.ls();
+
+    //MCT1ReadPreProc read(filenamein);
+    MReadMarsFile  read("Events", filenamein);
+    read.ls();
+    read.AddFile(filenamein1);    
+    read.DisableAutoScheme();
+
+    //---------------------
+    MF selectCrabNebula
+        ("(MRawRunHeader.fRunNumber>3126 && MRawRunHeader.fRunNumber<3216)||(MRawRunHeader.fRunNumber>3283 && MRawRunHeader.fRunNumber<3335)||(MRawRunHeader.fRunNumber>3339 && MRawRunHeader.fRunNumber<3417)");
+    selectCrabNebula.SetInverted();
+
+    MF selectOffCrab1
+        ("(MRawRunHeader.fRunNumber>3215 && MRawRunHeader.fRunNumber<3275)||(MRawRunHeader.fRunNumber>3416 && MRawRunHeader.fRunNumber<3444)");
+    selectOffCrab1.SetInverted();
+
+    MF selectMrk421
+        ("(MRawRunHeader.fRunNumber>3443 && MRawRunHeader.fRunNumber<3490)");
+    selectMrk421.SetInverted();
+                
+    MContinue contCrabNebula(&selectCrabNebula);
+    MContinue contOffCrab1(&selectOffCrab1);
+    MContinue contMrk421(&selectMrk421);
+
+
+    //..............................
+    MGeomApply        apply;
+    MMcPedestalCopy   pcopy;
+    MMcPedestalNSBAdd pnsb;
+
+    MPedestalWorkaround waround;
+
+    // a way to find out whether one is dealing with MC :
+    MFDataMember fMC("MRawRunHeader.fRunType", '>', 255.5);  // MC
+    fMC.SetName("Select MC");
+    MFDataMember fDa("MRawRunHeader.fRunType", '<', 255.5);  // data
+    fDa.SetName("Select Data");
+
+    MCerPhotCalc      ncalc;
+    ncalc.SetFilter(&fMC);
+    MCerPhotAnal2     nanal;
+    nanal.SetFilter(&fDa);
+    //..............................
+
+
+    //MPointingCorrCalc pointcorr(sourceName, "MPointingCorrCalc", 
+    //                                         "MPointingCorrCalc");
+    MBlindPixelCalc blind;
+    blind.SetUseBlindPixels();
+
+    MFSelBasic selbasic;
+    MContinue contbasic(&selbasic);
+    contbasic.SetName("SelBasic");
+
+    MFillH fillblind("BlindPixels[MHBlindPixels]", "MBlindPixels");
+    fillblind.SetName("HBlind");
+
+    MSigmabarCalc sigbarcalc;
+
+    MFillH fillsigtheta ("SigmaTheta[MHSigmaTheta]", "MMcEvt");
+    fillsigtheta.SetName("HSigmaTheta");
+
+    MImgCleanStd    clean; 
+
+
+    // calculation of  image parameters ---------------------
+    TString fHilName    = "MHillas";
+    TString fHilNameExt = "MHillasExt";
+    TString fHilNameSrc = "MHillasSrc";
+    TString fImgParName = "MNewImagePar";
+
+    MHillasCalc    hcalc;
+    hcalc.SetNameHillas(fHilName);
+    hcalc.SetNameHillasExt(fHilNameExt);
+    hcalc.SetNameNewImgPar(fImgParName);
+
+    MHillasSrcCalc hsrccalc(sourceName, fHilNameSrc);
+    hsrccalc.SetInput(fHilName);
+
+    MFillH hfill1("MHHillas",    fHilName);
+    hfill1.SetName("HHillas");
+
+    MFillH hfill2("MHStarMap",   fHilName);
+    hfill2.SetName("HStarMap");
+
+    MFillH hfill3("MHHillasExt",   fHilNameSrc);
+    hfill3.SetName("HHillasExt");
+
+    MFillH hfill4("MHHillasSrc",   fHilNameSrc);
+    hfill4.SetName("HHillasSrc");
+
+    MFillH hfill5("MHNewImagePar", fImgParName);
+    hfill5.SetName("HNewImagePar");
+    // --------------------------------------------------
+
+    MFSelStandard selstandard(fHilNameSrc);
+    selstandard.SetHillasName(fHilName);
+    selstandard.SetImgParName(fImgParName);
+    selstandard.SetCuts(92, 4, 60, 0.4, 1.05, 0.0, 0.0);
+    MContinue contstandard(&selstandard);
+    contstandard.SetName("SelStandard");
+
+      //MWriteRootFile &write = *(new MWriteRootFile(outNameImage));
+      MWriteRootFile write(outNameImage, "RECREATE");
+
+      write.AddContainer("MRawRunHeader", "RunHeaders");
+      write.AddContainer("MTime",         "Events");
+      write.AddContainer("MMcEvt",        "Events");
+      write.AddContainer("ThetaOrig",     "Events");
+      write.AddContainer("MSrcPosCam",    "Events");
+      write.AddContainer("MSigmabar",     "Events");
+      write.AddContainer("MHillas",       "Events");
+      write.AddContainer("MHillasExt",    "Events");
+      write.AddContainer("MHillasSrc",    "Events");
+      write.AddContainer("MNewImagePar",  "Events");
+
+
+    //$$$$$$$$$$$$$$$$$$$$$$$$$$$$
+    //MF daniel( "(MRawRunHeader.fRunNumber<13167)||(MRawRunHeader.fRunNumber>13167)" );
+    //MContinue contdaniel(&daniel);
+    //$$$$$$$$$$$$$$$$$$$$$$$$$$$$
+
+
+    //*****************************
+    // entries in MParList
+    
+    pliston.AddToList(&tliston);
+    InitBinnings(&pliston);
+
+    pliston.AddToList(&source);
+
+
+    //*****************************
+    // entries in MTaskList
+    
+    tliston.AddToList(&read);
+    tliston.AddToList(&contCrabNebula);
+
+    //......................
+    tliston.AddToList(&fMC);
+    tliston.AddToList(&fDa);
+    tliston.AddToList(&apply);
+    tliston.AddToList(&pcopy);
+    //tliston.AddToList(&waround);
+
+    tliston.AddToList(&pnsb);
+    tliston.AddToList(&ncalc);
+    tliston.AddToList(&nanal);
+    //......................
+
+    //tliston.AddToList(&pointcorr);
+    tliston.AddToList(&blind);
+    tliston.AddToList(&contbasic);
+
+    tliston.AddToList(&fillblind);
+    tliston.AddToList(&sigbarcalc);
+    tliston.AddToList(&fillsigtheta);
+    tliston.AddToList(&clean);
+
+    tliston.AddToList(&hcalc);
+    tliston.AddToList(&hsrccalc);
+
+    tliston.AddToList(&hfill1);
+    tliston.AddToList(&hfill2);
+    tliston.AddToList(&hfill3);
+    tliston.AddToList(&hfill4);
+    tliston.AddToList(&hfill5);
+
+    tliston.AddToList(&contstandard);
+    if (WON1)
+      tliston.AddToList(&write);
+
+    //*****************************
+
+    //-------------------------------------------
+    // Execute event loop
+    //
+    MProgressBar bar;
+    MEvtLoop evtloop;
+    evtloop.SetParList(&pliston);
+    //evtloop.ReadEnv(env, "", printEnv);
+    evtloop.SetProgressBar(&bar);
+    //if (WON1)
+    //  evtloop.Write();
+
+    Int_t maxevents = -1;
+    if ( !evtloop.Eventloop(maxevents) )
+        return;
+
+    tliston.PrintStatistics(0, kTRUE);
+
+
+    //-------------------------------------------
+    // Display the histograms
+
+    pliston.FindObject("SigmaTheta", "MHSigmaTheta")->DrawClone();
+
+    pliston.FindObject("BlindPixels", "MHBlindPixels")->DrawClone();
+
+    pliston.FindObject("MHHillas")->DrawClone();
+    pliston.FindObject("MHHillasExt")->DrawClone();
+    pliston.FindObject("MHHillasSrc")->DrawClone();
+    pliston.FindObject("MHNewImagePar")->DrawClone();
+    pliston.FindObject("MHStarMap")->DrawClone();
+
+
+
+    //-------------------------------------------
+    // Write histograms onto a file
+  if (WHistON)
+  {
+      MHSigmaTheta *sigtheta = 
+            (MHSigmaTheta*)pliston.FindObject("SigmaTheta");
+
+      MHBlindPixels *blindpixels = 
+            (MHBlindPixels*)pliston.FindObject("BlindPixels");
+      if (!sigtheta  ||  !blindpixels)
+	{
+          gLog << "Object 'SigmaTheta' or 'BlindPixels' not found" << endl;
+          return;
+	}
+      TH2D *fHSigTh    = sigtheta->GetSigmaTheta();
+      TH3D *fHSigPixTh = sigtheta->GetSigmaPixTheta();
+      TH3D *fHDifPixTh = sigtheta->GetDiffPixTheta();
+
+      TH2D *fHBlindId  = blindpixels->GetBlindId();
+      TH2D *fHBlindN   = blindpixels->GetBlindN();
+
+
+      TFile outfile(outNameSigTh, "RECREATE");
+      fHSigTh->Write();
+      fHSigPixTh->Write();
+      fHDifPixTh->Write();
+     
+      fHBlindId->Write();
+      fHBlindN->Write();
+
+      gLog << "" << endl;
+      gLog << "File " << outNameSigTh << " was written out" << endl;
+  }
+
+
+    DeleteBinnings(&pliston);
+
+    gLog << "Macro ONAnalysis : End of Job A_ON" << endl;
+    gLog << "===================================================" << endl;
+ }
+
+
+  //---------------------------------------------------------------------
+   // Job A_MC
+   //=========
+
+    // read MC gamma data  
+
+    //    - to pad them
+    //      (using the 2D-histogram "sigmabar versus Theta" 
+    //       (SigmaTheta_ON.root)  of the ON data)
+
+    //    - to write a file of padded MC gamma events (MC1.root)
+    //      (after the standard cuts, before the g/h separation)
+    //      (to be used together with the corresponding hadron file
+    //       for the optimization of the g/h separation)
+
+
+ if (JobA_MC)
+ {
+    gLog << "=====================================================" << endl;
+    gLog << "Macro ONAnalysis : Start of Job A_MC" << endl;
+
+    gLog << "" << endl;
+    gLog << "Macro ONAnalysis : JobA_MC, WMC1 = " 
+         << (JobA_MC ? "kTRUE" : "kFALSE")  << ",  " 
+         << (WMC1    ? "kTRUE" : "kFALSE")  << endl;
+
+
+    // name of input root file
+    TString filenamein(mcfile);
+
+    // name of output root file
+    TString outNameImage = outPath;
+    outNameImage += "MC";
+    outNameImage += "1.root";
+
+    //------------------------------------------------
+    // use for padding sigmabar vs. Theta from ON data
+    TString typeHist = "ON";
+    gLog << "typeHist = " << typeHist << endl;
+
+    // name of file containing the histograms for the padding
+    TString outNameSigTh = outPath;
+    outNameSigTh += "SigmaTheta_";
+    outNameSigTh += typeHist;
+    outNameSigTh += ".root";
+
+
+    //------------------------------------
+    // Get the histograms "2D-ThetaSigmabar"
+    // and                "3D-ThetaPixSigma"
+    // and                "3D-ThetaPixDiff"
+    // and                "2D-IdBlindPixels"
+    // and                "2D-NBlindPixels"
+
+
+      gLog << "Reading in file " << outNameSigTh << endl;
+
+      TFile *infile = new TFile(outNameSigTh);
+      infile->ls();
+
+      TH2D *fHSigmaTheta = 
+      (TH2D*) gROOT->FindObject("2D-ThetaSigmabar");
+      if (!fHSigmaTheta)
+	{
+          gLog << "Object '2D-ThetaSigmabar' not found on root file" << endl;
+          return;
+	}
+      gLog << "Object '2D-ThetaSigmabar' was read in" << endl;
+
+      TH3D *fHSigmaPixTheta = 
+      (TH3D*) gROOT->FindObject("3D-ThetaPixSigma");
+      if (!fHSigmaPixTheta)
+	{
+          gLog << "Object '3D-ThetaPixSigma' not found on root file" << endl;
+          return;
+	}
+      gLog << "Object '3D-ThetaPixSigma' was read in" << endl;
+
+      TH3D *fHDiffPixTheta = 
+      (TH3D*) gROOT->FindObject("3D-ThetaPixDiff");
+      if (!fHDiffPixTheta)
+	{
+          gLog << "Object '3D-ThetaPixDiff' not found on root file" << endl;
+          return;
+	}
+      gLog << "Object '3D-ThetaPixDiff' was read in" << endl;
+
+
+      TH2D *fHIdBlindPixels = 
+      (TH2D*) gROOT->FindObject("2D-IdBlindPixels");
+      if (!fHIdBlindPixels)
+	{
+          gLog << "Object '2D-IdBlindPixels' not found on root file" << endl;
+          return;
+	}
+      gLog << "Object '2D-IdBlindPixels' was read in" << endl;
+
+      TH2D *fHNBlindPixels = 
+      (TH2D*) gROOT->FindObject("2D-NBlindPixels");
+      if (!fHNBlindPixels)
+	{
+          gLog << "Object '2D-NBlindPixels' not found on root file" << endl;
+          return;
+	}
+      gLog << "Object '2D-NBlindPixels' was read in" << endl;
+
+    //------------------------------------
+
+    MTaskList tlist;
+    MParList plist;
+
+    char *sourceName = "MSrcPosCam";
+    MSrcPosCam source(sourceName);
+
+
+    // geometry is needed in  MHHillas... classes 
+    MGeomCam *fGeom = 
+             (MGeomCam*)plist->FindCreateObj("MGeomCamMagic", "MGeomCam");
+
+    //-------------------------------------------
+    // create the tasks which should be executed 
+    //
+
+    //MCT1ReadPreProc read(filenamein);
+    MReadMarsFile  read("Events", filenamein);
+    read.DisableAutoScheme();
+
+    //..............................
+    MGeomApply        apply;
+    MMcPedestalCopy   pcopy;
+    MMcPedestalNSBAdd pnsb;
+
+    MPedestalWorkaround waround;
+
+    // a way to find out whether one is dealing with MC :
+    MFDataMember fMC("MRawRunHeader.fRunType", '>', 255.5);  // MC
+    fMC.SetName("Select MC");
+    MFDataMember fDa("MRawRunHeader.fRunType", '<', 255.5);  // data
+    fDa.SetName("Select Data");
+
+    MCerPhotCalc      ncalc;
+    ncalc.SetFilter(&fMC);
+    MCerPhotAnal2     nanal;
+    nanal.SetFilter(&fDa);
+    //..............................
+
+    MBlindPixelCalc blindbeforepad;
+    blindbeforepad.SetUseBlindPixels();
+    blindbeforepad.SetName("BlindBeforePadding");
+
+    MBlindPixelCalc blind;
+    blind.SetUseBlindPixels();
+    blind.SetName("BlindAfterPadding");
+
+    MFSelBasic selbasic;
+    MContinue contbasic(&selbasic);
+    contbasic.SetName("SelBasic");
+
+    MPad padthomas("MPad","Task for the padding");
+    padthomas.MergeONMC(fHSigmaThetaMC, fHDiffPixThetaMC, fHSigmaPixThetaMC,
+                        fHIdBlindPixelsMC, fHNBlindPixelsMC,
+                        fHSigmaThetaON, fHDiffPixThetaON, fHSigmaPixThetaON,
+                        fHIdBlindPixelsON, fHNBlindPixelsON);
+
+    MFillH fillblind("MCBlindPixels[MHBlindPixels]", "MBlindPixels");
+    fillblind.SetName("HBlind");
+
+
+    //...........................................
+
+    MSigmabarCalc sigbarcalc;
+
+    MFillH fillsigtheta ("MCSigmaTheta[MHSigmaTheta]", "MMcEvt");
+    fillsigtheta.SetName("HSigmaTheta");
+
+    MImgCleanStd    clean; 
+
+    // calculation of  image parameters ---------------------
+    TString fHilName    = "MHillas";
+    TString fHilNameExt = "MHillasExt";
+    TString fHilNameSrc = "MHillasSrc";
+    TString fImgParName = "MNewImagePar";
+
+    MHillasCalc    hcalc;
+    hcalc.SetNameHillas(fHilName);
+    hcalc.SetNameHillasExt(fHilNameExt);
+    hcalc.SetNameNewImgPar(fImgParName);
+
+    MHillasSrcCalc hsrccalc(sourceName, fHilNameSrc);
+    hsrccalc.SetInput(fHilName);
+
+
+    MFillH hfill1("MHHillas",    fHilName);
+    hfill1.SetName("HHillas");
+
+    MFillH hfill2("MHStarMap",   fHilName);
+    hfill2.SetName("HStarMap");
+
+    MFillH hfill3("MHHillasExt",   fHilNameSrc);
+    hfill3.SetName("HHillasExt");
+
+    MFillH hfill4("MHHillasSrc",   fHilNameSrc);
+    hfill4.SetName("HHillasSrc");
+
+    MFillH hfill5("MHNewImagePar", fImgParName);
+    hfill5.SetName("HNewImagePar");
+    // --------------------------------------------------
+
+    MFSelStandard selstandard(fHilNameSrc);
+    selstandard.SetHillasName(fHilName);
+    selstandard.SetImgParName(fImgParName);
+    selstandard.SetCuts(92, 4, 60, 0.4, 1.05, 0.0, 0.0);
+    MContinue contstandard(&selstandard);
+    contstandard.SetName("SelStandard");
+
+
+      //MWriteRootFile &write = *(new MWriteRootFile(outNameImage));
+      MWriteRootFile write(outNameImage, "RECREATE");
+
+      write.AddContainer("MRawRunHeader", "RunHeaders");
+      write.AddContainer("MTime",         "Events");
+      write.AddContainer("MMcEvt",        "Events");
+      write.AddContainer("ThetaOrig",     "Events");
+      write.AddContainer("MSrcPosCam",    "Events");
+      write.AddContainer("MSigmabar",     "Events");
+      write.AddContainer("MHillas",       "Events");
+      write.AddContainer("MHillasExt",    "Events");
+      write.AddContainer("MHillasSrc",    "Events");
+      write.AddContainer("MNewImagePar",  "Events");
+
+
+
+    //*****************************
+    // entries in MParList
+
+    plist.AddToList(&tlist);
+    InitBinnings(&plist);
+
+    plist.AddToList(&source);
+
+
+    //*****************************
+    // entries in MTaskList
+
+    tlist.AddToList(&read);
+
+    //......................
+    tlist.AddToList(&fMC);
+    tlist.AddToList(&fDa);
+    tlist.AddToList(&apply);
+    tlist.AddToList(&pcopy);
+    //tlist.AddToList(&waround);
+
+    tlist.AddToList(&pnsb);
+    tlist.AddToList(&ncalc);
+    tlist.AddToList(&nanal);
+    //......................
+
+    tlist.AddToList(&blindbeforepad);
+    tlist.AddToList(&padthomas);
+    tlist.AddToList(&blind);
+
+    tlist.AddToList(&contbasic);
+    tlist.AddToList(&fillblind);
+    tlist.AddToList(&sigbarcalc);
+    tlist.AddToList(&fillsigtheta);
+    tlist.AddToList(&clean);
+
+    tlist.AddToList(&hcalc);
+    tlist.AddToList(&hsrccalc);
+
+    tlist.AddToList(&hfill1);
+    tlist.AddToList(&hfill2);
+    tlist.AddToList(&hfill3);
+    tlist.AddToList(&hfill4);
+    tlist.AddToList(&hfill5);
+
+    tlist.AddToList(&contstandard);
+    if (WMC1)
+      tlist.AddToList(&write);
+
+    //*****************************
+
+
+    //-------------------------------------------
+    // Execute event loop
+    //
+    MProgressBar bar;
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+    //evtloop.ReadEnv(env, "", printEnv);
+    evtloop.SetProgressBar(&bar);
+    //if (WMC1)    
+    //  evtloop.Write();
+
+    Int_t maxevents = -1;
+    //Int_t maxevents = 1000;
+    if ( !evtloop.Eventloop(maxevents) )
+        return;
+
+    tlist.PrintStatistics(0, kTRUE);
+
+
+    //-------------------------------------------
+    // Display the histograms
+    //
+
+    plist.FindObject("MCSigmaTheta",  "MHSigmaTheta")->DrawClone();
+    plist.FindObject("MCBlindPixels", "MHBlindPixels")->DrawClone();
+
+    plist.FindObject("MHHillas")->DrawClone();
+    plist.FindObject("MHHillasExt")->DrawClone();
+    plist.FindObject("MHHillasSrc")->DrawClone();
+    plist.FindObject("MHNewImagePar")->DrawClone();
+    plist.FindObject("MHStarMap")->DrawClone();
+
+
+
+    DeleteBinnings(&plist);
+
+    gLog << "Macro ONAnalysis : End of Job A_MC" 
+         << endl;
+    gLog << "=========================================================" 
+         << endl;
+ }
+
+
+
+  //---------------------------------------------------------------------
+  // Job B_RF_UP
+  //============
+
+
+    //  - create (or read in) the matrices of training events for gammas 
+    //    and hadrons
+    //  - create (or read in) the trees
+    //  - then read ON1.root (or MC1.root) file 
+    //  - calculate the hadroness for the method of RANDOM FOREST
+    //  - update input root file with the hadroness
+
+
+ if (JobB_RF_UP)
+ {
+    gLog << "=====================================================" << endl;
+    gLog << "Macro ONAnalysis : Start of Job B_RF_UP" << endl;
+
+    gLog << "" << endl;
+    gLog << "Macro ONAnalysis : JobB_RF_UP, RTrainRF, CTrainRF, RTree, WRF = "
+         << (JobB_RF_UP ? "kTRUE" : "kFALSE")  << ",  " 
+         << (RTrainRF ?   "kTRUE" : "kFALSE")  << ",  " 
+         << (CTrainRF ?   "kTRUE" : "kFALSE")  << ",  " 
+         << (RTree ?      "kTRUE" : "kFALSE")  << ",  "
+         << (WRF ?        "kTRUE" : "kFALSE")  << endl;
+
+
+    //--------------------------------------------
+    // parameters for the random forest
+    Int_t NumTrees = 100;
+    Int_t NumTry   =   3;
+    Int_t NdSize   =   1;
+
+
+    TString hadRFName = "HadRF";
+    Float_t maxhadronness =  0.23;
+    Float_t maxalpha      =  20.0;
+    Float_t maxdist       =  10.0;
+
+    TString fHilName    = "MHillas"; 
+    TString fHilNameExt = "MHillasExt"; 
+    TString fHilNameSrc = "MHillasSrc"; 
+    TString fImgParName = "MNewImagePar"; 
+
+
+    TString extin  = "1.root";
+    TString extout = "2.root";
+
+    //--------------------------------------------
+    // for the analysis using ON data only set typeMatrixHadrons = "ON"
+    //                        ON and OFF data                    = "OFF"
+    TString typeMatrixHadrons = "ON";
+    gLog << "typeMatrixHadrons = " << typeMatrixHadrons << endl;
+
+
+    // file to be updated (ON, OFF or MC)
+
+    //TString typeInput = "ON";
+    TString typeInput = "OFF";
+    //TString typeInput = "MC";
+    gLog << "typeInput = " << typeInput << endl;
+
+    // name of input root file
+    TString NameData = outPath;
+    NameData += typeInput;
+    TString inNameData(NameData);
+    inNameData += extin;
+    gLog << "inNameData = " << inNameData << endl; 
+
+    // name of output root file
+    TString outNameData(NameData);
+    outNameData += extout;
+    gLog << "outNameData = " << outNameData << endl; 
+
+    //--------------------------------------------
+    // files to be read for generating 
+    //    - the matrices of training events
+    //    - and the root files of training and test events
+
+
+    // "hadrons" :
+    TString filenameHad = outPath;
+    filenameHad += typeMatrixHadrons;
+    filenameHad += extin;
+    Int_t howManyHadronsTrain = 12000;
+    Int_t howManyHadronsTest  = 12000;
+    gLog << "filenameHad = "    << filenameHad << ",   howManyHadronsTrain = "
+         << howManyHadronsTrain << ",   howManyHadronsTest = "
+         << howManyHadronsTest  << endl; 
+    
+
+    // "gammas" :
+    TString filenameMC = outPath;
+    filenameMC += "MC";
+    filenameMC += extin;
+    Int_t howManyGammasTrain = 12000;
+    Int_t howManyGammasTest  = 12000;
+    gLog << "filenameMC = "    << filenameMC << ",   howManyGammasTrain = "
+         << howManyGammasTrain << ",   howManyGammasTest = "
+         << howManyGammasTest  << endl; 
+    
+    //--------------------------------------------
+    // files for the matrices of training events 
+
+    TString NameGammas = outPath;
+    NameGammas += "RFmatrix_gammas_Train_";
+    NameGammas += "MC";
+    NameGammas += extin;
+
+    TString NameHadrons = outPath;
+    NameHadrons += "RFmatrix_hadrons_Train_";
+    NameHadrons += typeMatrixHadrons;
+    NameHadrons += extin;
+
+
+    //--------------------------------------------
+    // root files for the training events 
+
+    TString NameGammasTrain = outPath;
+    NameGammasTrain += "RF_gammas_Train_";
+    NameGammasTrain += "MC";
+    TString inNameGammasTrain(NameGammasTrain);    
+    inNameGammasTrain += extin;
+    TString outNameGammasTrain(NameGammasTrain);    
+    outNameGammasTrain += extout;
+
+
+    TString NameHadronsTrain = outPath;
+    NameHadronsTrain += "RF_hadrons_Train_";
+    NameHadronsTrain += typeMatrixHadrons;
+    TString inNameHadronsTrain(NameHadronsTrain);    
+    inNameHadronsTrain += extin;
+    TString outNameHadronsTrain(NameHadronsTrain);    
+    outNameHadronsTrain += extout;
+
+
+    //--------------------------------------------
+    // root files for the test events 
+
+    TString NameGammasTest = outPath;
+    NameGammasTest += "RF_gammas_Test_";
+    NameGammasTest += "MC";
+    TString inNameGammasTest(NameGammasTest);    
+    inNameGammasTest += extin;
+    TString outNameGammasTest(NameGammasTest);    
+    outNameGammasTest += extout;
+
+    TString NameHadronsTest = outPath;
+    NameHadronsTest += "RF_hadrons_Test_";
+    NameHadronsTest += typeMatrixHadrons;
+    TString inNameHadronsTest(NameHadronsTest);    
+    inNameHadronsTest += extin;
+    TString outNameHadronsTest(NameHadronsTest);    
+    outNameHadronsTest += extout;
+
+    //--------------------------------------------------------------------
+
+
+    MHMatrix matrixg("MatrixGammas");
+    matrixg.EnableGraphicalOutput();
+
+    matrixg.AddColumn("cos(MMcEvt.fTelescopeTheta)");
+    matrixg.AddColumn("MSigmabar.fSigmabar");
+    matrixg.AddColumn("log10(MHillas.fSize)");
+    matrixg.AddColumn("MHillasSrc.fDist");
+    matrixg.AddColumn("MHillas.fWidth");
+    matrixg.AddColumn("MHillas.fLength");
+    matrixg.AddColumn("log10(MHillas.fSize/(MHillas.fWidth*MHillas.fLength))");
+    matrixg.AddColumn("sgn(MHillasSrc.fCosDeltaAlpha)*(MHillasExt.fM3Long)");
+    matrixg.AddColumn("MNewImagePar.fConc");
+    matrixg.AddColumn("MNewImagePar.fLeakage1");
+
+    MHMatrix matrixh("MatrixHadrons");
+    matrixh.EnableGraphicalOutput();
+
+    matrixh.AddColumns(matrixg.GetColumns());
+
+    //--------------------------------------------
+    // file of trees of the random forest 
+
+    TString outRF = outPath;
+    outRF += "RF.root";
+
+
+   //*************************************************************************
+   // read in matrices of training events
+if (RTrainRF)
+  {
+    const char* mtxName = "MatrixGammas";
+
+    gLog << "" << endl;
+    gLog << "========================================================" << endl;
+    gLog << "Get matrix for (gammas)" << endl;
+    gLog << "matrix name        = " << mtxName << endl;
+    gLog << "name of root file  = " << NameGammas << endl;
+    gLog << "" << endl;
+
+
+    // read in the object with the name 'mtxName' from file 'NameGammas'
+    //
+    TFile fileg(NameGammas); 
+
+    matrixg.Read(mtxName);
+    matrixg.Print("SizeCols");
+
+
+    //***************************************************************** 
+
+    const char* mtxName = "MatrixHadrons";
+
+    gLog << "" << endl;
+    gLog << "========================================================" << endl;
+    gLog << " Get matrix for (hadrons)" << endl;
+    gLog << "matrix name        = " << mtxName << endl;
+    gLog << "name of root file  = " << NameHadrons << endl;
+    gLog << "" << endl;
+
+
+    // read in the object with the name 'mtxName' from file 'NameHadrons'
+    //
+    TFile fileh(NameHadrons); 
+
+    matrixh.Read(mtxName);
+    matrixh.Print("SizeCols");
+  }
+
+
+   //*************************************************************************
+   // create matrices of training events
+   // and root files of training and test events
+ 
+if (CTrainRF)
+  {
+    gLog << "" << endl;
+    gLog << "========================================================" << endl;
+    gLog << " Create matrices of training events and root files of training and test events" 
+         << endl;
+    gLog << " Gammas :" << endl;
+    gLog << "---------" << endl;
+
+    MParList  plistg;
+    MTaskList tlistg;
+
+    MReadMarsFile  readg("Events", filenameMC);
+    readg.DisableAutoScheme();
+
+    TString mgname("costhg");
+    MBinning bing("Binning"+mgname);
+    bing.SetEdges(10, 0., 1.0);
+
+    MH3 gref("cos(MMcEvt.fTelescopeTheta)");
+    gref.SetName(mgname);
+    MH::SetBinning(&gref.GetHist(), &bing);
+    for (Int_t i=1; i<=gref.GetNbins(); i++)
+      gref.GetHist().SetBinContent(i, 1.0);
+
+    MFEventSelector2 selectorg(gref);
+    selectorg.SetNumMax(howManyGammasTrain+howManyGammasTest);
+    selectorg.SetName("selectGammasTrainTest");
+    selectorg.SetInverted();
+    selectorg.SetUseOrigDistribution(kTRUE);
+
+    MContinue contg(&selectorg);
+    contg.SetName("ContGammas");
+
+    Double_t probg = ( (Double_t) howManyGammasTrain )
+                   / ( (Double_t)(howManyGammasTrain+howManyGammasTest) );
+    MFRandomSplit splitg(probg);
+
+    MFillH fillmatg("MatrixGammas");
+    fillmatg.SetFilter(&splitg);
+    fillmatg.SetName("fillGammas");
+
+    //-----------------------
+    // for writing the root files of training and test events
+    // for gammas
+    
+    MWriteRootFile writetraing(inNameGammasTrain, "RECREATE");
+    writetraing.SetName("WriteGammasTrain");
+    writetraing.SetFilter(&splitg);
+
+      writetraing.AddContainer("MRawRunHeader", "RunHeaders");
+      writetraing.AddContainer("MTime",         "Events");
+      writetraing.AddContainer("MMcEvt",        "Events");
+      writetraing.AddContainer("ThetaOrig",     "Events");
+      writetraing.AddContainer("MSrcPosCam",    "Events");
+      writetraing.AddContainer("MSigmabar",     "Events");
+      writetraing.AddContainer("MHillas",       "Events");
+      writetraing.AddContainer("MHillasExt",    "Events");
+      writetraing.AddContainer("MHillasSrc",    "Events");
+      writetraing.AddContainer("MNewImagePar",  "Events");
+
+    MContinue contgtrain(&splitg);
+    contgtrain.SetName("ContGammaTrain");
+
+    MWriteRootFile writetestg(inNameGammasTest, "RECREATE");
+    writetestg.SetName("WriteGammasTest");
+
+      writetestg.AddContainer("MRawRunHeader", "RunHeaders");
+      writetestg.AddContainer("MTime",         "Events");
+      writetestg.AddContainer("MMcEvt",        "Events");
+      writetestg.AddContainer("ThetaOrig",     "Events");
+      writetestg.AddContainer("MSrcPosCam",    "Events");
+      writetestg.AddContainer("MSigmabar",     "Events");
+      writetestg.AddContainer("MHillas",       "Events");
+      writetestg.AddContainer("MHillasExt",    "Events");
+      writetestg.AddContainer("MHillasSrc",    "Events");
+      writetestg.AddContainer("MNewImagePar",  "Events");
+
+    //-----------------------
+    
+    //*****************************   fill gammas   ***  
+    // entries in MParList
+    
+    plistg.AddToList(&tlistg);
+    InitBinnings(&plistg);
+
+    plistg.AddToList(&matrixg);
+
+    //*****************************
+    // entries in MTaskList
+    
+    tlistg.AddToList(&readg);
+    tlistg.AddToList(&contg);
+
+    tlistg.AddToList(&splitg);
+    tlistg.AddToList(&fillmatg);
+    tlistg.AddToList(&writetraing);
+    tlistg.AddToList(&contgtrain);
+
+    tlistg.AddToList(&writetestg);
+
+    //*****************************
+
+    MProgressBar matrixbar;
+    MEvtLoop evtloopg;
+    evtloopg.SetName("FillGammaMatrix");
+    evtloopg.SetParList(&plistg);
+    //evtloopg.ReadEnv(env, "", printEnv);
+    evtloopg.SetProgressBar(&matrixbar);
+
+    Int_t maxevents = -1;
+    if (!evtloopg.Eventloop(maxevents))
+        return;
+
+    tlistg.PrintStatistics(0, kTRUE);
+
+    matrixg.Print("SizeCols");
+    Int_t generatedgTrain = matrixg.GetM().GetNrows();
+    if ( fabs(generatedgTrain-howManyGammasTrain) > 
+                                    3.0*sqrt(howManyGammasTrain) )
+    {
+      gLog << "Macro ONAnalysis.C : no.of generated gamma training events (" 
+           << generatedgTrain << ") is incompatible with the no.of requested events (" 
+           << howManyGammasTrain << ")" << endl;   
+    }
+
+
+    Int_t generatedgTest = writetestg.GetNumExecutions();
+    if ( fabs(generatedgTest-howManyGammasTest) > 
+                                    3.0*sqrt(howManyGammasTest) )
+    {
+      gLog << "Macro ONAnalysis.C : no.of generated gamma test events (" 
+           << generatedgTest << ") is incompatible with the no.of requested events (" 
+           << howManyGammasTest << ")" << endl;   
+    }
+
+    //*****************************   fill hadrons   ***  
+    gLog << "---------------------------------------------------------------"
+         << endl;
+    gLog << " Hadrons :" << endl;
+    gLog << "----------" << endl;
+
+    MParList  plisth;
+    MTaskList tlisth;
+
+    MReadMarsFile  readh("Events", filenameHad);
+    readh.DisableAutoScheme();
+
+    TString mhname("costhh");
+    MBinning binh("Binning"+mhname);
+    binh.SetEdges(10, 0., 1.0);
+
+    //MH3 href("cos(MMcEvt.fTelescopeTheta)");
+    //href.SetName(mhname);
+    //MH::SetBinning(&href.GetHist(), &binh);
+    //for (Int_t i=1; i<=href.GetNbins(); i++)
+    //  href.GetHist().SetBinContent(i, 1.0);
+
+    //use the original distribution from the gammas
+    MH3 &href = *(selectorg.GetHistOrig());
+
+    MFEventSelector2 selectorh(href);
+    selectorh.SetNumMax(howManyHadronsTrain+howManyHadronsTest);
+    selectorh.SetName("selectHadronsTrainTest");
+    selectorh.SetInverted();
+
+    MContinue conth(&selectorh);
+    conth.SetName("ContHadrons");
+
+    Double_t probh = ( (Double_t) howManyHadronsTrain )
+                   / ( (Double_t)(howManyHadronsTrain+howManyHadronsTest) );
+    MFRandomSplit splith(probh);
+
+    MFillH fillmath("MatrixHadrons");
+    fillmath.SetFilter(&splith);
+    fillmath.SetName("fillHadrons");
+
+    //-----------------------
+    // for writing the root files of training and test events
+    // for hadrons
+    
+    MWriteRootFile writetrainh(inNameHadronsTrain, "RECREATE");
+    writetrainh.SetName("WriteHadronsTrain");
+    writetrainh.SetFilter(&splith);
+
+      writetrainh.AddContainer("MRawRunHeader", "RunHeaders");
+      writetrainh.AddContainer("MTime",         "Events");
+      writetrainh.AddContainer("MMcEvt",        "Events");
+      writetrainh.AddContainer("ThetaOrig",     "Events");
+      writetrainh.AddContainer("MSrcPosCam",    "Events");
+      writetrainh.AddContainer("MSigmabar",     "Events");
+      writetrainh.AddContainer("MHillas",       "Events");
+      writetrainh.AddContainer("MHillasExt",    "Events");
+      writetrainh.AddContainer("MHillasSrc",    "Events");
+      writetrainh.AddContainer("MNewImagePar",  "Events");
+
+    MContinue conthtrain(&splith);
+
+    MWriteRootFile writetesth(inNameHadronsTest, "RECREATE");
+    writetesth.SetName("WriteHadronsTest");
+
+      writetesth.AddContainer("MRawRunHeader", "RunHeaders");
+      writetesth.AddContainer("MTime",         "Events");
+      writetesth.AddContainer("MMcEvt",        "Events");
+      writetesth.AddContainer("ThetaOrig",     "Events");
+      writetesth.AddContainer("MSrcPosCam",    "Events");
+      writetesth.AddContainer("MSigmabar",     "Events");
+      writetesth.AddContainer("MHillas",       "Events");
+      writetesth.AddContainer("MHillasExt",    "Events");
+      writetesth.AddContainer("MHillasSrc",    "Events");
+      writetesth.AddContainer("MNewImagePar",  "Events");
+
+
+    //*****************************  
+    // entries in MParList
+    
+    plisth.AddToList(&tlisth);
+    InitBinnings(&plisth);
+
+    plisth.AddToList(&matrixh);
+
+    //*****************************
+    // entries in MTaskList
+    
+    tlisth.AddToList(&readh);
+    tlisth.AddToList(&conth);
+
+    tlisth.AddToList(&splith);
+    tlisth.AddToList(&fillmath);
+    tlisth.AddToList(&writetrainh);
+    tlisth.AddToList(&conthtrain);
+
+    tlisth.AddToList(&writetesth);
+
+    //*****************************
+
+    MProgressBar matrixbar;
+    MEvtLoop evtlooph;
+    evtlooph.SetName("FillHadronMatrix");
+    evtlooph.SetParList(&plisth);
+    //evtlooph.ReadEnv(env, "", printEnv);
+    evtlooph.SetProgressBar(&matrixbar);
+
+    Int_t maxevents = -1;
+    if (!evtlooph.Eventloop(maxevents))
+        return;
+
+    tlisth.PrintStatistics(0, kTRUE);
+
+    matrixh.Print("SizeCols");
+    Int_t generatedhTrain = matrixh.GetM().GetNrows();
+    if ( fabs(generatedhTrain-howManyHadronsTrain) > 
+                                    3.0*sqrt(howManyHadronsTrain) )
+    {
+      gLog << "Macro ONAnalysis.C : no.of generated hadron training events (" 
+           << generatedhTrain << ") is incompatible with the no.of requested events (" 
+           << howManyHadronsTrain << ")" << endl;   
+    }
+
+
+    Int_t generatedhTest = writetesth.GetNumExecutions();
+    if ( fabs(generatedhTest-howManyHadronsTest) > 
+                                    3.0*sqrt(howManyHadronsTest) )
+    {
+      gLog << "Macro ONAnalysis.C : no.of generated gamma test events (" 
+           << generatedhTest << ") is incompatible with the no.of requested events (" 
+           << howManyHadronsTest << ")" << endl;   
+    }
+
+
+    //*****************************************************  
+
+
+    // write out matrices of training events 
+
+    gLog << "" << endl;
+    gLog << "========================================================" << endl;
+    gLog << "Write out matrices of training events" << endl;
+
+
+      //-------------------------------------------
+      // "gammas"
+      gLog << "Gammas :" << endl;    
+      matrixg.Print("SizeCols");
+
+      TFile writeg(NameGammas, "RECREATE", "");
+      matrixg.Write();
+
+      gLog << "" << endl;
+      gLog << "Macro ONAnalysis : matrix of training events for gammas written onto file "
+           << NameGammas << endl;
+
+      //-------------------------------------------
+      // "hadrons"
+      gLog << "Hadrons :" << endl;    
+      matrixh.Print("SizeCols");
+
+      TFile writeh(NameHadrons, "RECREATE", "");
+      matrixh.Write();
+
+      gLog << "" << endl;
+      gLog << "Macro ONAnalysis : matrix of training events for hadrons written onto file "
+           << NameHadrons << endl;
+
+  }
+   //**********   end of creating matrices of training events   ***********
+
+
+    MRanForest *fRanForest;
+    MRanTree *fRanTree;
+    //-----------------------------------------------------------------
+    // read in the trees of the random forest 
+    if (RTree)
+    {
+      MParList plisttr;
+      MTaskList tlisttr;
+      plisttr.AddToList(&tlisttr);
+
+      MReadTree readtr("TREE", outRF);
+      readtr.DisableAutoScheme();
+
+      MRanForestFill rffill;
+      rffill.SetNumTrees(NumTrees);
+
+      // list of tasks for the loop over the trees
+
+      tlisttr.AddToList(&readtr);
+      tlisttr.AddToList(&rffill);
+
+      //-------------------
+      // Execute tree loop
+      //
+      MEvtLoop evtlooptr;
+      evtlooptr.SetName("ReadRFTrees");
+      evtlooptr.SetParList(&plisttr);
+      if (!evtlooptr.Eventloop())
+        return;
+
+      tlisttr.PrintStatistics(0, kTRUE);
+
+      gLog << "ONAnalysis : RF trees were read in from file "
+           << outRF << endl;
+
+    // get adresses of objects which are used in the next eventloop
+    fRanForest = (MRanForest*)plisttr->FindObject("MRanForest");
+    if (!fRanForest)
+    {
+        gLog << err << dbginf << "MRanForest not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fRanTree = (MRanTree*)plisttr->FindObject("MRanTree");
+    if (!fRanTree)                                  
+    {                                                                          
+        gLog << err << dbginf << "MRanTree not found... aborting." << endl;    
+        return kFALSE;
+    }
+
+    }
+
+    //-----------------------------------------------------------------
+    // grow the trees of the random forest (event loop = tree loop)
+
+    if (!RTree)
+    {
+
+    gLog << "" << endl;
+    gLog << "========================================================" << endl;
+    gLog << "Macro ONAnalysis : start growing trees" << endl;
+
+    MTaskList tlist2;
+    MParList plist2;
+    plist2.AddToList(&tlist2);
+
+    plist2.AddToList(&matrixg);
+    plist2.AddToList(&matrixh);
+
+    MRanForestGrow rfgrow2;
+    rfgrow2.SetNumTrees(NumTrees);
+    rfgrow2.SetNumTry(NumTry);
+    rfgrow2.SetNdSize(NdSize);
+
+    MWriteRootFile rfwrite2(outRF);
+    rfwrite2.AddContainer("MRanTree", "TREE");
+
+    MFillH fillh2("MHRanForestGini");
+
+    // list of tasks for the loop over the trees
+    
+    tlist2.AddToList(&rfgrow2);
+    tlist2.AddToList(&rfwrite2);
+    tlist2.AddToList(&fillh2);
+
+    //-------------------
+    // Execute tree loop
+    //
+    MEvtLoop treeloop;
+    treeloop.SetName("GrowRFTrees");
+    treeloop.SetParList(&plist2);
+
+    if ( !treeloop.Eventloop() )
+        return;
+
+    tlist2.PrintStatistics(0, kTRUE);
+
+    plist2.FindObject("MHRanForestGini")->DrawClone();
+
+
+    // get adresses of objects which are used in the next eventloop
+    fRanForest = (MRanForest*)plist2->FindObject("MRanForest");
+    if (!fRanForest)
+    {
+        gLog << err << dbginf << "MRanForest not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fRanTree = (MRanTree*)plist2->FindObject("MRanTree");
+    if (!fRanTree)                                  
+    {                                                                          
+        gLog << err << dbginf << "MRanTree not found... aborting." << endl;    
+        return kFALSE;
+    }
+
+    }
+    // end of growing the trees of the random forest
+    //-----------------------------------------------------------------
+
+
+    //-----------------------------------------------------------------
+    // Update the root files with the RF hadronness
+    //
+
+ if (WRF)
+  {
+    //TString fileName(inNameHadronsTrain);
+    //TString outName(outNameHadronsTrain);
+
+    //TString fileName(inNameHadronsTest);
+    //TString outName(outNameHadronsTest);
+
+    //TString fileName(inNameGammasTrain);
+    //TString outName(outNameGammasTrain);
+
+    //TString fileName(inNameGammasTest);
+    //TString outName(outNameGammasTest);
+
+    TString fileName(inNameData);
+    TString outName(outNameData);
+
+
+
+    gLog << "" << endl;
+    gLog << "========================================================" << endl;
+    gLog << "Update root file '" <<  fileName 
+         << "' with the RF hadronness; ==> " << outName << endl;
+
+   
+    MTaskList tliston;
+    MParList pliston;
+
+
+    // geometry is needed in  MHHillas... classes 
+    MGeomCam *fGeom = 
+             (MGeomCam*)pliston->FindCreateObj("MGeomCamMagic", "MGeomCam");
+
+    //-------------------------------------------
+    // create the tasks which should be executed 
+    //
+
+    MReadMarsFile read("Events", fileName);
+    read.DisableAutoScheme();
+
+
+    //.......................................................................
+    // calculate hadronnes for method of RANDOM FOREST
+
+
+    MRanForestCalc rfcalc;
+    rfcalc.SetHadronnessName(hadRFName);
+
+
+    //.......................................................................
+
+      //MWriteRootFile write(outName, "UPDATE");
+      MWriteRootFile write(outName, "RECREATE");
+
+      write.AddContainer("MRawRunHeader", "RunHeaders");
+      write.AddContainer("MTime",         "Events");
+      write.AddContainer("MMcEvt",        "Events");
+      write.AddContainer("ThetaOrig",     "Events");
+      write.AddContainer("MSrcPosCam",    "Events");
+      write.AddContainer("MSigmabar",     "Events");
+      write.AddContainer("MHillas",       "Events");
+      write.AddContainer("MHillasExt",    "Events");
+      write.AddContainer("MHillasSrc",    "Events");
+      write.AddContainer("MNewImagePar",  "Events");
+
+      write.AddContainer(hadRFName,       "Events");
+
+    //-----------------------------------------------------------------
+
+
+    MFSelFinal selfinalgh(fHilNameSrc);
+    selfinalgh.SetCuts(maxhadronness, 100.0, maxdist);
+    selfinalgh.SetHadronnessName(hadRFName);
+    selfinalgh.SetName("SelFinalgh");
+    MContinue contfinalgh(&selfinalgh);
+    contfinalgh.SetName("ContSelFinalgh");
+
+    MFillH fillranfor("MHRanForest");
+    fillranfor.SetName("HRanForest");
+
+    MFillH fillhadrf("hadRF[MHHadronness]", hadRFName);
+    fillhadrf.SetName("HhadRF");
+
+    MFSelFinal selfinal(fHilNameSrc);
+    selfinal.SetCuts(maxhadronness, maxalpha, maxdist);
+    selfinal.SetHadronnessName(hadRFName);
+    selfinal.SetName("SelFinal");
+    MContinue contfinal(&selfinal);
+    contfinal.SetName("ContSelFinal");
+
+    TString mh3name = "abs(Alpha)";
+    MBinning binsalphaabs("Binning"+mh3name);
+    binsalphaabs.SetEdges(50, -2.0, 98.0);
+
+    MH3 alphaabs("abs(MHillasSrc.fAlpha)");
+    alphaabs.SetName(mh3name);
+    MFillH alpha(&alphaabs);
+    alpha.SetName("FillAlphaAbs");
+
+
+    MFillH hfill1("MHHillas",    fHilName);
+    hfill1.SetName("HHillas");
+
+    MFillH hfill2("MHStarMap",   fHilName);
+    hfill2.SetName("HStarMap");
+
+    MFillH hfill3("MHHillasExt",    fHilNameSrc);
+    hfill3.SetName("HHillasExt");
+    
+    MFillH hfill4("MHHillasSrc",   fHilNameSrc);
+    hfill4.SetName("HHillasSrc");    
+
+    MFillH hfill5("MHNewImagePar", fImgParName);
+    hfill5.SetName("HNewImagePar");
+
+    //*****************************
+    // entries in MParList
+
+    pliston.AddToList(&tliston);
+    InitBinnings(&pliston);
+
+    pliston.AddToList(fRanForest);
+    pliston.AddToList(fRanTree);
+
+    pliston.AddToList(&binsalphaabs);
+    pliston.AddToList(&alphaabs);
+
+
+    //*****************************
+    // entries in MTaskList
+    
+    tliston.AddToList(&read);
+
+    tliston.AddToList(&rfcalc);
+    tliston.AddToList(&fillranfor);
+    tliston.AddToList(&fillhadrf);
+
+    tliston.AddToList(&write);
+    tliston.AddToList(&contfinalgh);
+
+    tliston.AddToList(&alpha);
+    tliston.AddToList(&hfill1);
+    tliston.AddToList(&hfill2);
+    tliston.AddToList(&hfill3);
+    tliston.AddToList(&hfill4);
+    tliston.AddToList(&hfill5);
+
+    tliston.AddToList(&contfinal);
+
+    //*****************************
+
+    //-------------------------------------------
+    // Execute event loop
+    //
+    MProgressBar bar;
+    MEvtLoop evtloop;
+    evtloop.SetName("UpdateRootFile");
+    evtloop.SetParList(&pliston);
+    evtloop.SetProgressBar(&bar);
+
+    Int_t maxevents = -1;
+    if ( !evtloop.Eventloop(maxevents) )
+        return;
+
+    tliston.PrintStatistics(0, kTRUE);
+
+
+    //-------------------------------------------
+    // Display the histograms
+    //
+    pliston.FindObject("MHRanForest")->DrawClone();
+    pliston.FindObject("hadRF", "MHHadronness")->DrawClone();
+    pliston.FindObject("hadRF", "MHHadronness")->Print();
+
+    pliston.FindObject("MHHillas")->DrawClone();
+    pliston.FindObject("MHHillasExt")->DrawClone();
+    pliston.FindObject("MHHillasSrc")->DrawClone();
+    pliston.FindObject("MHNewImagePar")->DrawClone();
+    pliston.FindObject("MHStarMap")->DrawClone();
+
+
+     //-------------------------------------------
+    // fit alpha distribution to get the number of excess events and
+    // calculate significance of gamma signal in the alpha plot
+  
+    MH3* absalpha = (MH3*)(pliston.FindObject(mh3name, "MH3"));
+    TH1  &alphaHist = absalpha->GetHist();
+    alphaHist.SetXTitle("|alpha|  [\\circ]");
+    alphaHist.SetName("alpha-macro");
+
+    Double_t alphasig = 13.1;
+    Double_t alphamin = 30.0;
+    Double_t alphamax = 90.0;
+    Int_t    degree   =    2;
+    Double_t significance = -99.0;
+    Bool_t   drawpoly  = kTRUE;
+    Bool_t   fitgauss  = kTRUE;
+    Bool_t   print     = kTRUE;
+
+    MHFindSignificance findsig;
+    findsig.SetRebin(kTRUE);
+    findsig.SetReduceDegree(kFALSE);
+
+    findsig.FindSigma(&alphaHist, alphamin, alphamax, degree, 
+                        alphasig, drawpoly, fitgauss, print);
+    significance = findsig.GetSignificance();
+    Float_t alphasi = findsig.GetAlphasi();
+
+    gLog << "For file '" << fileName << "' : " << endl;
+    gLog << "Significance of gamma signal after supercuts : "
+         << significance << " (for |alpha| < " << alphasi << " degrees)" 
+         << endl;
+
+    findsig.SigmaVsAlpha(&alphaHist, alphamin, alphamax, degree, print);
+
+    //-------------------------------------------
+
+
+    DeleteBinnings(&pliston);
+  }
+
+    gLog << "Macro ONAnalysis : End of Job B_RF_UP" << endl;
+    gLog << "=======================================================" << endl;
+ }
+  //---------------------------------------------------------------------
+
+
+  //---------------------------------------------------------------------
+  // Job B_SC_UP
+  //============
+
+    //  - create (or read in) optimum supercuts parameter values
+    //
+    //  - calculate the hadroness for the supercuts
+    //
+    //  - update input root file, including the hadroness
+
+
+ if (JobB_SC_UP)
+ {
+    gLog << "=====================================================" << endl;
+    gLog << "Macro ONAnalysis : Start of Job B_SC_UP" << endl;
+
+    gLog << "" << endl;
+    gLog << "Macro ONAnalysis : JobB_SC_UP, CMatrix, RMatrix, WOptimize, RTest, WSC = "
+         << (JobB_SC_UP ? "kTRUE" : "kFALSE")  << ",  " 
+         << (CMatrix    ? "kTRUE" : "kFALSE")  << ",  "
+         << (RMatrix    ? "kTRUE" : "kFALSE")  << ",  "
+         << (WOptimize  ? "kTRUE" : "kFALSE")  << ",  "
+         << (RTest      ? "kTRUE" : "kFALSE")  << ",  "
+         << (WSC        ? "kTRUE" : "kFALSE")  << endl;
+
+
+    //--------------------------------------------
+    // file which contains the initial parameter values for the supercuts 
+    // if parSCinit ="" the initial values are taken from the constructor of
+    //                  MSupercuts
+
+    TString parSCinit = outPath;
+    //parSCinit += "parSC_1709d";
+    parSCinit = "";
+
+    gLog << "parSCinit = " << parSCinit << endl;
+
+    //---------------
+    // file onto which the optimal parameter values for the supercuts 
+    // are written
+
+    TString parSCfile = outPath;
+    parSCfile += "parSC_2310a";
+
+    gLog << "parSCfile = " << parSCfile << endl;
+
+    //--------------------------------------------
+    // file to be updated (either ON or MC)
+
+    //TString typeInput = "ON";
+    //TString typeInput = "OFF";
+    TString typeInput = "MC";
+    gLog << "typeInput = " << typeInput << endl;
+
+    // name of input root file
+    TString filenameData = outPath;
+    filenameData += typeInput;
+    filenameData += "2.root";
+    gLog << "filenameData = " << filenameData << endl; 
+
+    // name of output root file
+    TString outNameImage = outPath;
+    outNameImage += typeInput;
+    outNameImage += "3.root";
+    
+
+    //TString outNameImage = filenameData;
+
+    gLog << "outNameImage = " << outNameImage << endl; 
+
+    //--------------------------------------------
+    // files to be read for optimizing the supercuts
+    // 
+    // for the training
+    TString filenameTrain = outPath;
+    filenameTrain += "ON";
+    filenameTrain += "1.root";
+    Int_t howManyTrain = 800000;
+    gLog << "filenameTrain = " << filenameTrain << ",   howManyTrain = "
+         << howManyTrain  << endl; 
+
+    // for testing
+    TString filenameTest = outPath;
+    filenameTest += "ON";
+    filenameTest += "1.root";
+    Int_t howManyTest = 800000;
+
+    gLog << "filenameTest = " << filenameTest << ",   howManyTest = "
+         << howManyTest  << endl; 
+    
+
+    //--------------------------------------------
+    // files to contain the matrices (generated from filenameTrain and
+    //                                               filenameTest)
+    // 
+    // for the training
+    TString fileMatrixTrain = outPath;
+    fileMatrixTrain += "MatrixTrainSC";
+    fileMatrixTrain += ".root";
+    gLog << "fileMatrixTrain = " << fileMatrixTrain << endl; 
+
+    // for testing
+    TString fileMatrixTest = outPath;
+    fileMatrixTest += "MatrixTestSC";
+    fileMatrixTest += ".root";
+    gLog << "fileMatrixTest = " << fileMatrixTest << endl; 
+
+    
+
+    //---------------------------------------------------------------------
+    // Training and test matrices :
+    // - either create them and write them onto a file
+    // - or read them from a file
+
+
+    MFindSupercuts findsuper;
+    findsuper.SetFilenameParam(parSCfile);
+    findsuper.SetHadronnessName("HadSC");
+    findsuper.SetUseOrigDistribution(kTRUE);
+
+    //--------------------------
+    // create matrices and write them onto files 
+    if (CMatrix)
+    {
+      TString mname("costheta");
+      MBinning bin("Binning"+mname);
+      bin.SetEdges(10, 0., 1.0);
+
+      MH3 mh3("cos(MMcEvt.fTelescopeTheta)");
+      mh3.SetName(mname);
+      MH::SetBinning(&mh3.GetHist(), &bin);
+      for (Int_t i=1; i<=mh3.GetNbins(); i++)
+        mh3.GetHist().SetBinContent(i, 1.0);
+
+
+      if (filenameTrain == filenameTest)
+      {
+        if ( !findsuper.DefineTrainTestMatrix(
+                              filenameTrain,   mh3, 
+                              howManyTrain,    howManyTest,  
+                              fileMatrixTrain, fileMatrixTest)     )
+        {
+          *fLog << "Macro ONAnalysis.C : DefineTrainTestMatrix failed" << endl;
+          return;
+        }
+
+      }
+      else
+      {
+        if ( !findsuper.DefineTrainMatrix(filenameTrain, mh3,
+                                          howManyTrain,  fileMatrixTrain) )
+        {
+          *fLog << "Macro ONAnalysis.C : DefineTrainMatrix failed" << endl;
+          return;
+        }
+
+	if ( !findsuper.DefineTestMatrix( filenameTest, mh3, 
+                                          howManyTest,  fileMatrixTest)  )
+        {
+          *fLog << "Macro ONAnalysis.C : DefineTestMatrix failed" << endl;
+          return;
+        }
+      }
+     }
+
+    //--------------------------
+    // read matrices from files
+    //                              
+
+    if (RMatrix)
+      findsuper.ReadMatrix(fileMatrixTrain, fileMatrixTest);
+    //--------------------------
+
+
+
+    //---------------------------------------------------------------------
+    // optimize supercuts using the training sample
+    // 
+    // the initial values are taken 
+    //     - from the file parSCinit (if != "")
+    //     - or from the arrays params and steps (if their sizes are != 0)
+    //     - or from the MSupercuts constructor
+
+
+if (WOptimize)
+  {
+    gLog << "Macro ONAnalysis.C : optimize the supercuts using the training matrix" 
+         << endl;
+
+    TArrayD params(0);
+    TArrayD steps(0);
+  
+    if (parSCinit == "")
+    {
+      Double_t vparams[104] = {
+      // LengthUp
+	0.315585,  0.001455, 0.203198, 0.005532, -0.001670, -0.020362,
+	0.007388, -0.013463,
+      // LengthLo
+        0.151530,  0.028323, 0.510707, 0.053089,  0.013708,  2.357993,
+	0.000080, -0.007157,
+      // WidthUp
+        0.145412, -0.001771, 0.054462, 0.022280, -0.009893,  0.056353,
+        0.020711, -0.016703,
+      // WidthLo
+        0.089187, -0.006430, 0.074442, 0.003738, -0.004256, -0.014101,
+        0.006126, -0.002849,
+      // DistUp
+        1.787943,  0.0,      2.942310, 0.199815,  0.0,       0.249909,
+        0.189697,  0.0,
+      // DistLo
+        0.589406,  0.0,     -0.083964,-0.007975,  0.0,       0.045374,
+       -0.001750,  0.0,
+      // AsymUp
+        1.e10,     0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // AsymLo
+       -1.e10,     0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // ConcUp
+        1.e10,     0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // ConcLo
+       -1.e10,     0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // Leakage1Up
+        1.e10,     0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // Leakage1Lo
+       -1.e10,     0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // AlphaUp
+	13.12344,  0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0                                                 };
+
+      Double_t vsteps[104] = {
+      // LengthUp
+        0.03,      0.0002,   0.02,     0.0006,    0.0002,    0.002,
+        0.0008,    0.002,
+      // LengthLo
+        0.02,      0.003,    0.05,     0.006,     0.002,     0.3,
+        0.0001,    0.0008,
+      // WidthUp
+        0.02,      0.0002,   0.006,    0.003,     0.002,     0.006,
+        0.002,     0.002,
+      // WidthLo
+        0.009,     0.0007,   0.008,    0.0004,    0.0005,    0.002,
+        0.0007,    0.003,
+      // DistUp
+        0.2,       0.0,      0.3,      0.02,      0.0,       0.03,
+        0.02,      0.0
+      // DistLo
+        0.06,      0.0,      0.009,    0.0008,    0.0,       0.005,
+        0.0002,    0.0
+      // AsymUp  
+        0.0,       0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // AsymLo  
+        0.0,       0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // ConcUp  
+        0.0,       0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // ConcLo  
+        0.0,       0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // Leakage1Up  
+        0.0,       0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // Leakage1Lo  
+        0.0,       0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // AlphaUp  
+        0.0,       0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0                                                 };
+
+      params.Set(104, vparams);
+      steps.Set (104, vsteps );
+    }
+
+    Bool_t rf;
+    rf = findsuper.FindParams(parSCinit, params, steps);
+
+    if (!rf) 
+    {
+       gLog << "Macro ONAnalysis.C : optimization of supercuts failed" << endl;
+       return;
+    }
+  }
+
+    //--------------------------------------
+    // test the supercuts on the test sample
+    //    
+
+ if (RTest)
+ {
+    gLog << "Macro ONAnalysis.C : test the supercuts on the test matrix" << endl;
+    Bool_t rt = findsuper.TestParams();
+    if (!rt) 
+    {
+       gLog << "Macro ONAnalysis.C : test of supercuts on the test matrix failed" 
+            << endl;
+    }
+
+ }
+
+
+    //-----------------------------------------------------------------
+    // Update the input files with the SC hadronness
+    //
+
+ if (WSC)
+ {
+    gLog << "" << endl;
+    gLog << "========================================================" << endl;
+    gLog << "Update input file '" <<  filenameData 
+         << "' with the SC hadronness" << endl;
+
+
+    //----------------------------------------------------
+    // read in optimum parameter values for the supercuts
+
+    TFile inparam(parSCfile);
+    MSupercuts scin;
+    scin.Read("MSupercuts");
+    inparam.Close();
+
+    gLog << "Parameter values for supercuts were read in from file '"
+         << parSCfile << "'" << endl;
+
+    TArrayD supercutsPar;
+    supercutsPar =  scin.GetParameters();
+
+    TArrayD supercutsStep;
+    supercutsStep =  scin.GetStepsizes();
+
+    gLog << "Parameter values for supercuts : " << endl;
+    for (Int_t i=0; i<supercutsPar.GetSize(); i++)
+    {
+      gLog << supercutsPar[i] << ",  ";
+    }
+    gLog << endl;
+
+    gLog << "Step values for supercuts : " << endl;
+    for (Int_t i=0; i<supercutsStep.GetSize(); i++)
+    {
+      gLog << supercutsStep[i] << ",  ";
+    }
+    gLog << endl;
+
+
+    //----------------------------------------------------
+    MTaskList tliston;
+    MParList pliston;
+
+    // set the parameters of the supercuts
+    MSupercuts supercuts;
+    supercuts.SetParameters(supercutsPar);
+    gLog << "parameter values for the supercuts used for updating the input file ' " 
+         << filenameData << "'" << endl;
+    supercutsPar = supercuts.GetParameters();
+    for (Int_t i=0; i<supercutsPar.GetSize(); i++)
+    {
+      gLog << supercutsPar[i] << ",  ";
+    }
+    gLog << endl;
+
+
+    // geometry is needed in  MHHillas... classes 
+    MGeomCam *fGeom = 
+             (MGeomCam*)pliston->FindCreateObj("MGeomCamMagic", "MGeomCam");
+
+    //-------------------------------------------
+    // create the tasks which should be executed 
+    //
+
+    MReadMarsFile read("Events", filenameData);
+    read.DisableAutoScheme();
+
+    TString fHilName    = "MHillas"; 
+    TString fHilNameExt = "MHillasExt"; 
+    TString fHilNameSrc = "MHillasSrc"; 
+    TString fImgParName = "MNewImagePar"; 
+
+
+    //.......................................................................
+    // calculation of hadroness for the supercuts
+    // (=0.25 if fullfilled, =0.75 otherwise)
+
+    TString hadSCName = "HadSC";
+    MSupercutsCalc sccalc(fHilName, fHilNameSrc);
+    sccalc.SetHadronnessName(hadSCName);
+
+
+    //.......................................................................
+
+
+      //MWriteRootFile write(outNameImage, "UPDATE");
+      //MWriteRootFile write = new MWriteRootFile(outNameImage, "RECREATE");
+
+    
+      MWriteRootFile write(outNameImage, "RECREATE");
+
+      write.AddContainer("MRawRunHeader", "RunHeaders");
+      write.AddContainer("MTime",         "Events");
+      write.AddContainer("MMcEvt",        "Events");
+      write.AddContainer("ThetaOrig",     "Events");
+      write.AddContainer("MSrcPosCam",    "Events");
+      write.AddContainer("MSigmabar",     "Events");
+      write.AddContainer("MHillas",       "Events");
+      write.AddContainer("MHillasExt",    "Events");
+      write.AddContainer("MHillasSrc",    "Events");
+      write.AddContainer("MNewImagePar",  "Events");
+
+      write.AddContainer("HadRF",         "Events");
+      write.AddContainer(hadSCName,       "Events");
+    
+
+    //-----------------------------------------------------------------
+    // geometry is needed in  MHHillas... classes 
+    MGeomCam *fGeom = 
+             (MGeomCam*)pliston->FindCreateObj("MGeomCamMagic", "MGeomCam");
+
+    Float_t maxhadronness =  0.40;
+    Float_t maxalpha      =  20.0;
+    Float_t maxdist       =  10.0;
+
+    MFSelFinal selfinalgh(fHilNameSrc);
+    selfinalgh.SetCuts(maxhadronness, 100.0, maxdist);
+    selfinalgh.SetHadronnessName(hadSCName);
+    selfinalgh.SetName("SelFinalgh");
+    MContinue contfinalgh(&selfinalgh);
+    contfinalgh.SetName("ContSelFinalgh");
+
+    MFillH fillhadsc("hadSC[MHHadronness]", hadSCName);
+    fillhadsc.SetName("HhadSC");
+
+    MFSelFinal selfinal(fHilNameSrc);
+    selfinal.SetCuts(maxhadronness, maxalpha, maxdist);
+    selfinal.SetHadronnessName(hadSCName);
+    selfinal.SetName("SelFinal");
+    MContinue contfinal(&selfinal);
+    contfinal.SetName("ContSelFinal");
+
+    TString mh3name = "abs(Alpha)";
+    MBinning binsalphaabs("Binning"+mh3name);
+    binsalphaabs.SetEdges(50, -2.0, 98.0);
+
+    MH3 alphaabs("abs(MHillasSrc.fAlpha)");
+    alphaabs.SetName(mh3name);
+
+    TH1  &alphahist = alphaabs->GetHist();
+
+    MFillH alpha(&alphaabs);
+    alpha.SetName("FillAlphaAbs");
+
+    MFillH hfill1("MHHillas",    fHilName);
+    hfill1.SetName("HHillas");
+
+    MFillH hfill2("MHStarMap",   fHilName);
+    hfill2.SetName("HStarMap");
+
+    MFillH hfill3("MHHillasExt",    fHilNameSrc);
+    hfill3.SetName("HHillasExt");
+    
+    MFillH hfill4("MHHillasSrc",   fHilNameSrc);
+    hfill4.SetName("HHillasSrc");    
+
+    MFillH hfill5("MHNewImagePar", fImgParName);
+    hfill5.SetName("HNewImagePar");
+
+    //*****************************
+    // entries in MParList
+
+    pliston.AddToList(&tliston);
+    InitBinnings(&pliston);
+
+    pliston.AddToList(&supercuts);
+
+    pliston.AddToList(&binsalphaabs);
+    pliston.AddToList(&alphaabs);
+
+    //*****************************
+    // entries in MTaskList
+    
+    tliston.AddToList(&read);
+
+    tliston.AddToList(&sccalc);
+    tliston.AddToList(&fillhadsc);
+
+    tliston.AddToList(&write);
+    tliston.AddToList(&contfinalgh);
+
+    tliston.AddToList(&alpha);
+    tliston.AddToList(&hfill1);
+    tliston.AddToList(&hfill2);
+    tliston.AddToList(&hfill3);
+    tliston.AddToList(&hfill4);
+    tliston.AddToList(&hfill5);
+
+    tliston.AddToList(&contfinal);
+
+    //*****************************
+
+    //-------------------------------------------
+    // Execute event loop
+    //
+    MProgressBar bar;
+    MEvtLoop evtloop;
+    evtloop.SetParList(&pliston);
+    evtloop.SetProgressBar(&bar);
+
+    Int_t maxevents = -1;
+    if ( !evtloop.Eventloop(maxevents) )
+        return;
+
+    tliston.PrintStatistics(0, kTRUE);
+
+
+    //-------------------------------------------
+    // Display the histograms
+    //
+    pliston.FindObject("hadSC", "MHHadronness")->DrawClone();
+
+    pliston.FindObject("MHHillas")->DrawClone();
+    pliston.FindObject("MHHillasExt")->DrawClone();
+    pliston.FindObject("MHHillasSrc")->DrawClone();
+    pliston.FindObject("MHNewImagePar")->DrawClone();
+    pliston.FindObject("MHStarMap")->DrawClone();
+
+     //-------------------------------------------
+    // fit alpha distribution to get the number of excess events and
+    // calculate significance of gamma signal in the alpha plot
+  
+    MH3* absalpha = (MH3*)(pliston.FindObject(mh3name, "MH3"));
+    TH1  &alphaHist = absalpha->GetHist();
+    alphaHist.SetXTitle("|alpha|  [\\circ]");
+    alphaHist.SetName("alpha-macro");
+
+    Double_t alphasig = 13.1;
+    Double_t alphamin = 30.0;
+    Double_t alphamax = 90.0;
+    Int_t    degree   =    2;
+    Double_t significance = -99.0;
+    Bool_t   drawpoly  = kTRUE;
+    Bool_t   fitgauss  = kTRUE;
+    Bool_t   print     = kTRUE;
+
+    MHFindSignificance findsig;
+    findsig.SetRebin(kTRUE);
+    findsig.SetReduceDegree(kFALSE);
+
+    findsig.FindSigma(&alphaHist, alphamin, alphamax, degree, 
+                        alphasig, drawpoly, fitgauss, print);
+    significance = findsig.GetSignificance();
+    Float_t alphasi = findsig.GetAlphasi();
+
+    gLog << "For file '" << filenameData << "' : " << endl;
+    gLog << "Significance of gamma signal after supercuts : "
+         << significance << " (for |alpha| < " << alphasi << " degrees)" 
+         << endl;
+
+    findsig.SigmaVsAlpha(&alphaHist, alphamin, alphamax, degree, print);
+
+    //-------------------------------------------
+
+    DeleteBinnings(&pliston);
+ }
+
+
+    gLog << "Macro ONAnalysis : End of Job B_SC_UP" << endl;
+    gLog << "=======================================================" << endl;
+ }
+  //---------------------------------------------------------------------
+
+
+
+  //---------------------------------------------------------------------
+  // Job C  
+  //======
+
+    //  - read ON1 and MC1 data files  
+    //    which should have been updated to contain the hadronnesses
+    //    for the method of Random Forest and for the SUPERCUTS
+    //  - produce Neyman-Pearson plots
+ 
+ if (JobC)
+ {
+    gLog << "=====================================================" << endl;
+    gLog << "Macro ONAnalysis : Start of Job C" << endl;
+
+    gLog << "" << endl;
+    gLog << "Macro ONAnalysis : JobC = " 
+         << (JobC       ? "kTRUE" : "kFALSE")  << endl;
+
+
+    // name of input data file
+    TString filenameData = outPath;
+    filenameData += "ON";
+    filenameData += "3.root";
+    gLog << "filenameData = " << filenameData << endl;
+
+    // name of input MC file
+    TString filenameMC = outPath;
+    filenameMC += "MC";
+    filenameMC += "3.root";
+    gLog << "filenameMC   = " << filenameMC   << endl;
+
+
+    //-----------------------------------------------------------------
+
+    MTaskList tliston;
+    MParList pliston;
+
+
+    // geometry is needed in  MHHillas... classes 
+    MGeomCam *fGeom = 
+             (MGeomCam*)pliston->FindCreateObj("MGeomCamMagic", "MGeomCam");
+
+    //-------------------------------------------
+    // create the tasks which should be executed 
+    //
+
+    MReadMarsFile read("Events", filenameMC);
+    read.AddFile(filenameData);
+    read.DisableAutoScheme();
+
+
+    //.......................................................................
+    // names of hadronness containers
+
+    //TString hadNNName = "HadNN";
+    TString hadSCName = "HadSC";
+    TString hadRFName = "HadRF";
+
+    //.......................................................................
+
+
+    TString fHilName    = "MHillas"; 
+    TString fHilNameExt = "MHillasExt"; 
+    TString fHilNameSrc = "MHillasSrc"; 
+    TString fImgParName = "MNewImagePar"; 
+
+    Float_t maxhadronness =  0.40;
+    Float_t maxalpha      =  20.0;
+    Float_t maxdist       =  10.0;
+
+    MFSelFinal selfinalgh(fHilNameSrc);
+    selfinalgh.SetCuts(maxhadronness, 100.0, maxdist);
+    selfinalgh.SetHadronnessName(hadSCName);
+    selfinalgh.SetName("SelFinalgh");
+    MContinue contfinalgh(&selfinalgh);
+    contfinalgh.SetName("ContSelFinalgh");
+
+    //MFillH fillhadnn("hadNN[MHHadronness]", hadNNName);
+    //fillhadnn.SetName("HhadNN");
+    MFillH fillhadsc("hadSC[MHHadronness]", hadSCName);
+    fillhadsc.SetName("HhadSC");
+    MFillH fillhadrf("hadRF[MHHadronness]", hadRFName);
+    fillhadrf.SetName("HhadRF");
+
+    MFSelFinal selfinal(fHilNameSrc);
+    selfinal.SetCuts(maxhadronness, maxalpha, maxdist);
+    selfinal.SetHadronnessName(hadSCName);
+    selfinal.SetName("SelFinal");
+    MContinue contfinal(&selfinal);
+    contfinal.SetName("ContSelFinal");
+
+
+    MFillH hfill1("MHHillas",    fHilName);
+    hfill1.SetName("HHillas");
+
+    MFillH hfill2("MHStarMap",   fHilName);
+    hfill2.SetName("HStarMap");
+
+    MFillH hfill3("MHHillasExt",    fHilNameSrc);
+    hfill3.SetName("HHillasExt");
+    
+    MFillH hfill4("MHHillasSrc",   fHilNameSrc);
+    hfill4.SetName("HHillasSrc");    
+
+    MFillH hfill5("MHNewImagePar", fImgParName);
+    hfill5.SetName("HNewImagePar");
+
+
+    //*****************************
+    // entries in MParList
+
+    pliston.AddToList(&tliston);
+    InitBinnings(&pliston);
+
+
+    //*****************************
+    // entries in MTaskList
+    
+    tliston.AddToList(&read);
+
+    //tliston.AddToList(&fillhadnn);
+    tliston.AddToList(&fillhadsc);
+    tliston.AddToList(&fillhadrf);
+   
+    tliston.AddToList(&contfinalgh);
+    tliston.AddToList(&hfill1);
+    tliston.AddToList(&hfill2);
+    tliston.AddToList(&hfill3);
+    tliston.AddToList(&hfill4);
+    tliston.AddToList(&hfill5);
+
+    tliston.AddToList(&contfinal);
+
+    //*****************************
+
+    //-------------------------------------------
+    // Execute event loop
+    //
+    MProgressBar bar;
+    MEvtLoop evtloop;
+    evtloop.SetParList(&pliston);
+    evtloop.SetProgressBar(&bar);
+
+    Int_t maxevents = -1;
+    //Int_t maxevents = 35000;
+    if ( !evtloop.Eventloop(maxevents) )
+        return;
+
+    tliston.PrintStatistics(0, kTRUE);
+
+
+    //-------------------------------------------
+    // Display the histograms
+    //
+
+    //pliston.FindObject("hadNN", "MHHadronness")->DrawClone();
+    pliston.FindObject("hadSC", "MHHadronness")->DrawClone();
+    pliston.FindObject("hadRF", "MHHadronness")->DrawClone();
+
+    pliston.FindObject("MHHillas")->DrawClone();
+    pliston.FindObject("MHHillasExt")->DrawClone();
+    pliston.FindObject("MHHillasSrc")->DrawClone();
+    pliston.FindObject("MHNewImagePar")->DrawClone();
+    pliston.FindObject("MHStarMap")->DrawClone();
+
+    DeleteBinnings(&pliston);
+
+    gLog << "Macro ONAnalysis : End of Job C" << endl;
+    gLog << "===================================================" << endl;
+ }
+
+
+  //---------------------------------------------------------------------
+  // Job D
+  //======
+
+    //  - select g/h separation method XX
+    //  - read ON2 (or MC2) root file 
+    //  - apply cuts in hadronness
+    //  - make plots
+
+
+ if (JobD)
+ {
+    gLog << "=====================================================" << endl;
+    gLog << "Macro ONAnalysis : Start of Job D" << endl;
+
+    gLog << "" << endl;
+    gLog << "Macro ONAnalysis : JobD = " 
+         << (JobD        ? "kTRUE" : "kFALSE")  << endl;
+
+
+    // type of data to be analysed
+    TString typeData = "ON";
+    //TString typeData = "OFF";
+    //TString typeData = "MC";
+    gLog << "typeData = " << typeData << endl;
+
+    TString ext      = "3.root";
+
+
+    //------------------------------
+    // selection of g/h separation method
+    // and definition of final selections
+
+    //TString XX("SC");
+    TString XX("RF");
+    TString fhadronnessName("Had");
+    fhadronnessName += XX;
+    gLog << "fhadronnessName = " << fhadronnessName << endl;
+
+    // maximum values of the hadronness, |ALPHA| and DIST
+    Float_t maxhadronness   = 0.233;
+    Float_t maxalpha        = 20.0;
+    Float_t maxdist         = 10.0;
+    gLog << "Maximum values of hadronness, |ALPHA| and DIST = "
+         << maxhadronness << ",  " << maxalpha << ",  " 
+         << maxdist << endl;
+
+
+    //------------------------------
+    // name of data file to be analysed
+    TString filenameData(outPath);
+    filenameData += typeData;
+    filenameData += ext;
+    gLog << "filenameData = " << filenameData << endl;
+
+
+
+    //*************************************************************************
+    //
+    // Analyse the data
+    //
+
+    MTaskList tliston;
+    MParList pliston;
+
+    // geometry is needed in  MHHillas... classes 
+    MGeomCam *fGeom = 
+             (MGeomCam*)pliston->FindCreateObj("MGeomCamMagic", "MGeomCam");
+
+
+    TString fHilName    = "MHillas"; 
+    TString fHilNameExt = "MHillasExt"; 
+    TString fHilNameSrc = "MHillasSrc"; 
+    TString fImgParName = "MNewImagePar"; 
+
+    //-------------------------------------------
+    // create the tasks which should be executed 
+    //
+
+    MReadMarsFile read("Events", filenameData);
+    read.DisableAutoScheme();
+
+
+    //-----------------------------------------------------------------
+    // geometry is needed in  MHHillas... classes 
+    MGeomCam *fGeom = 
+             (MGeomCam*)pliston->FindCreateObj("MGeomCamMagic", "MGeomCam");
+
+    MFSelFinal selfinalgh(fHilNameSrc);
+    selfinalgh.SetCuts(maxhadronness, 100.0, maxdist);
+    selfinalgh.SetHadronnessName(fhadronnessName);
+    selfinalgh.SetName("SelFinalgh");
+    MContinue contfinalgh(&selfinalgh);
+    contfinalgh.SetName("ContSelFinalgh");
+
+    MFillH fillhadsc("hadSC[MHHadronness]", "HadSC");
+    fillhadsc.SetName("HhadSC");
+    MFillH fillhadrf("hadRF[MHHadronness]", "HadRF");
+    fillhadrf.SetName("HhadRF");
+
+    TString mh3name = "abs(Alpha)";
+    MBinning binsalphaabs("Binning"+mh3name);
+    binsalphaabs.SetEdges(50, -2.0, 98.0);
+
+    MH3 alphaabs("abs(MHillasSrc.fAlpha)");
+    alphaabs.SetName(mh3name);
+
+    TH1  &alphahist = alphaabs->GetHist();
+
+    MFillH alpha(&alphaabs);
+    alpha.SetName("FillAlphaAbs");
+
+    MFillH hfill1("MHHillas",    fHilName);
+    hfill1.SetName("HHillas");
+
+    MFillH hfill2("MHStarMap",   fHilName);
+    hfill2.SetName("HStarMap");
+
+    MFillH hfill3("MHHillasExt",   fHilNameSrc);
+    hfill3.SetName("HHillasExt");    
+
+    MFillH hfill4("MHHillasSrc",   fHilNameSrc);
+    hfill4.SetName("HHillasSrc");    
+
+    MFillH hfill5("MHNewImagePar", fImgParName);
+    hfill5.SetName("HNewImagePar");    
+
+    MFSelFinal selfinal(fHilNameSrc);
+    selfinal.SetCuts(maxhadronness, maxalpha, maxdist);
+    selfinal.SetHadronnessName(fhadronnessName);
+    selfinal.SetName("SelFinal");
+    MContinue contfinal(&selfinal);
+    contfinal.SetName("ContSelFinal");
+
+
+    //*****************************
+    // entries in MParList
+
+    pliston.AddToList(&tliston);
+    InitBinnings(&pliston);
+    pliston.AddToList(&binsalphaabs);
+    pliston.AddToList(&alphaabs);
+
+    //*****************************
+    // entries in MTaskList
+    
+    tliston.AddToList(&read);
+
+    tliston.AddToList(&contfinalgh);
+
+    tliston.AddToList(&fillhadsc);
+    tliston.AddToList(&fillhadrf);
+
+    tliston.AddToList(&alpha);
+    tliston.AddToList(&hfill1);
+    tliston.AddToList(&hfill2);
+    tliston.AddToList(&hfill3);
+    tliston.AddToList(&hfill4);
+    tliston.AddToList(&hfill5);
+
+    tliston.AddToList(&contfinal);
+
+    //*****************************
+
+    //-------------------------------------------
+    // Execute event loop
+    //
+    MProgressBar bar;
+    MEvtLoop evtloop;
+    evtloop.SetParList(&pliston);
+    evtloop.SetProgressBar(&bar);
+
+    Int_t maxevents = -1;
+    //Int_t maxevents = 10000;
+    if ( !evtloop.Eventloop(maxevents) )
+        return;
+
+    tliston.PrintStatistics(0, kTRUE);
+
+
+    //-------------------------------------------
+    // Display the histograms
+    //
+
+    pliston.FindObject("hadRF", "MHHadronness")->DrawClone();
+    pliston.FindObject("hadSC", "MHHadronness")->DrawClone();
+
+    pliston.FindObject("MHHillas")->DrawClone();
+    pliston.FindObject("MHHillasExt")->DrawClone();
+    pliston.FindObject("MHHillasSrc")->DrawClone();
+    pliston.FindObject("MHNewImagePar")->DrawClone();
+    pliston.FindObject("MHStarMap")->DrawClone();
+
+
+    //-------------------------------------------
+
+    // fit alpha distribution to get the number of excess events and
+    // calculate significance of gamma signal in the alpha plot
+  
+    MH3* absalpha = (MH3*)(pliston.FindObject(mh3name, "MH3"));
+    TH1  &alphaHist = absalpha->GetHist();
+    alphaHist.SetXTitle("|alpha|  [\\circ]");
+    alphaHist.SetName("alpha-JobD");
+
+    Double_t alphasig = 13.1;
+    Double_t alphamin = 30.0;
+    Double_t alphamax = 90.0;
+    Int_t    degree   =    2;
+    Double_t significance = -99.0;
+    Bool_t   drawpoly  = kTRUE;
+    Bool_t   fitgauss  = kTRUE;
+    Bool_t   print     = kTRUE;
+
+    MHFindSignificance findsig;
+    findsig.SetRebin(kTRUE);
+    findsig.SetReduceDegree(kFALSE);
+
+    findsig.FindSigma(&alphaHist, alphamin, alphamax, degree, 
+                        alphasig, drawpoly, fitgauss, print);
+    significance = findsig.GetSignificance();
+    Float_t alphasi = findsig.GetAlphasi();
+
+    gLog << "For file '" << filenameData << "' : " << endl;
+    gLog << "Significance of gamma signal after supercuts : "
+         << significance << " (for |alpha| < " << alphasi << " degrees)" 
+         << endl;
+
+    findsig.SigmaVsAlpha(&alphaHist, alphamin, alphamax, degree, print);
+
+    //-------------------------------------------
+
+
+    DeleteBinnings(&pliston);
+
+    gLog << "Macro ONAnalysis : End of Job D" << endl;
+    gLog << "=======================================================" << endl;
+ }
+  //---------------------------------------------------------------------
+
+
+
+
+  //---------------------------------------------------------------------
+  // Job E_XX
+  //=========
+
+    //  - select g/h separation method XX
+    //  - read MC_XX2.root file 
+    //  - calculate eff. collection area
+    //  - read ON_XX2.root file 
+    //  - apply final cuts
+    //  - calculate flux
+    //  - write root file for ON data after final cuts (ON_XX3.root))
+
+
+ if (JobE_XX)
+ {
+    gLog << "=====================================================" << endl;
+    gLog << "Macro ONAnalysis : Start of Job E_XX" << endl;
+
+    gLog << "" << endl;
+    gLog << "Macro 
+Analysis : JobE_XX, CCollArea, OEEst, WEX = " 
+         << (JobE_XX ? "kTRUE" : "kFALSE")  << ",  " 
+         << (CCollArea?"kTRUE" : "kFALSE")  << ",  " 
+         << (OEEst ?   "kTRUE" : "kFALSE")  << ",  " 
+         << (WEX     ? "kTRUE" : "kFALSE")  << endl;
+
+
+    // type of data to be analysed
+    //TString typeData = "ON";
+    //TString typeData = "OFF";
+    TString typeData = "MC";
+    gLog << "typeData = " << typeData << endl;
+
+    TString typeMC   = "MC";
+    TString ext      = "3.root";
+    TString extout   = "4.root";
+
+    //------------------------------
+    // selection of g/h separation method
+    // and definition of final selections
+
+    //TString XX("SC");
+    TString XX("RF");
+    TString fhadronnessName("Had");
+    fhadronnessName += XX;
+    gLog << "fhadronnessName = " << fhadronnessName << endl;
+
+    // maximum values of the hadronness, |ALPHA| and DIST
+    Float_t maxhadronness   = 0.23;
+    Float_t maxalpha        = 20.0;
+    Float_t maxdist         = 10.0;
+    gLog << "Maximum values of hadronness, |ALPHA| and DIST = "
+         << maxhadronness << ",  " << maxalpha << ",  " 
+         << maxdist << endl;
+
+    //------------------------------
+    // name of MC file to be used for optimizing the energy estimator
+    TString filenameOpt(outPath);
+    filenameOpt += typeMC;
+    filenameOpt += ext; 
+    gLog << "filenameOpt = " << filenameOpt << endl;
+
+    //------------------------------
+    // name of file containing the parameters of the energy estimator
+    TString energyParName(outPath);
+    energyParName += "energyest_";
+    energyParName += XX;
+    energyParName += ".root";
+    gLog << "energyParName = " << energyParName << endl;
+
+    //------------------------------
+    // name of MC file to be used for calculating the eff. collection areas
+    TString filenameArea(outPath);
+    filenameArea += typeMC;
+    filenameArea += ext; 
+    gLog << "filenameArea = " << filenameArea << endl;
+
+    //------------------------------
+    // name of file containing the eff. collection areas
+    TString collareaName(outPath);
+    collareaName += "area_";
+    collareaName += XX;
+    collareaName += ".root";
+    gLog << "collareaName = " << collareaName << endl;
+
+    //------------------------------
+    // name of data file to be analysed
+    TString filenameData(outPath);
+    filenameData += typeData;
+    filenameData += ext;
+    gLog << "filenameData = " << filenameData << endl;
+
+    //------------------------------
+    // name of output data file (after the final cuts)
+    TString filenameDataout(outPath);
+    filenameDataout += typeData;
+    filenameDataout += "_";
+    filenameDataout += XX;
+    filenameDataout += extout;
+    gLog << "filenameDataout = " << filenameDataout << endl;
+
+    //------------------------------
+    // name of file containing histograms for flux calculastion
+    TString filenameResults(outPath);
+    filenameResults += typeData;
+    filenameResults += "Results_";
+    filenameResults += XX;
+    filenameResults += extout;
+    gLog << "filenameResults = " << filenameResults << endl;
+
+
+    //====================================================================
+
+    MHMcCT1CollectionArea collarea;
+    collarea.SetEaxis(MHMcCT1CollectionArea::kLinear);
+
+    MParList  parlist;
+    InitBinnings(&parlist);
+
+  if (CCollArea)
+  {
+    gLog << "-----------------------------------------------" << endl;
+    gLog << "Start calculation of effective collection areas" << endl;
+
+
+    MTaskList tasklist;
+
+    //---------------------------------------
+    // Setup the tasks to be executed
+    //
+    MReadMarsFile reader("Events", filenameArea);
+    reader.DisableAutoScheme();
+
+    MFSelFinal cuthadrons;
+    cuthadrons.SetHadronnessName(fhadronnessName);
+    cuthadrons.SetCuts(maxhadronness, maxalpha, maxdist);
+
+    MContinue conthadrons(&cuthadrons);
+
+
+    MFillH filler("MHMcCT1CollectionArea", "MMcEvt");
+    filler.SetName("CollectionArea");
+
+    //********************************
+    // entries in MParList
+
+    parlist.AddToList(&tasklist);
+
+    parlist.AddToList(&collarea);
+
+    //********************************
+    // entries in MTaskList
+
+    tasklist.AddToList(&reader);   
+    tasklist.AddToList(&conthadrons);
+    tasklist.AddToList(&filler);
+
+    //********************************
+
+    //-----------------------------------------
+    // Execute event loop
+    //
+    MEvtLoop magic;
+    magic.SetParList(&parlist);
+
+    MProgressBar bar;
+    magic.SetProgressBar(&bar);
+    if (!magic.Eventloop())
+        return;
+
+    tasklist.PrintStatistics(0, kTRUE);
+
+    // Calculate effective collection areas 
+    // and display the histograms
+    //
+    //MHMcCT1CollectionArea *collarea = 
+    //     (MHMcCT1CollectionArea*)parlist.FindObject("MHMcCT1CollectionArea");
+    collarea.CalcEfficiency();
+    collarea.DrawClone();
+
+
+
+    //---------------------------------------------
+    // Write histograms to a file 
+    //
+
+    TFile f(collareaName, "RECREATE");
+    //collarea.GetHist()->Write();
+    //collarea.GetHAll()->Write();
+    //collarea.GetHSel()->Write();
+    collarea.Write();
+
+    f.Close();
+
+    gLog << "Collection area plots written onto file " << collareaName << endl;
+
+    gLog << "Calculation of effective collection areas done" << endl;
+    gLog << "-----------------------------------------------" << endl;    
+    //------------------------------------------------------------------
+  }
+
+  if (!CCollArea)
+  {
+    gLog << "-----------------------------------------------" << endl;
+    gLog << "Read in effective collection areas from file " 
+         << collareaName << endl;
+
+    TFile collfile(collareaName);
+    collfile.ls();
+    collarea.Read("MHMcCT1CollectionArea");
+    collarea.DrawClone();
+
+    gLog << "Effective collection areas were read in from file " 
+         << collareaName << endl;
+    gLog << "-----------------------------------------------" << endl;    
+  }
+
+
+    // save binnings for call to CT1EEst
+    MBinning *binsE     = (MBinning*)parlist.FindObject("BinningE");
+    if (!binsE)
+	{
+          gLog << "Object 'BinningE' not found in MParList" << endl;
+          return;
+	}
+    MBinning *binsTheta = (MBinning*)parlist.FindObject("BinningTheta");
+    if (!binsTheta)
+	{
+          gLog << "Object 'BinningTheta' not found in MParList" << endl;
+          return;
+	}
+
+    //-------------------------------------
+    TString fHilName    = "MHillas"; 
+    TString fHilNameExt = "MHillasExt"; 
+    TString fHilNameSrc = "MHillasSrc"; 
+    TString fImgParName = "MNewImagePar"; 
+
+
+ if (OEEst)
+ { 
+   //===========================================================
+    //
+    // Optimization of energy estimator
+    //
+    gLog << "Macro ONAnalysis.C : calling CT1EEst" << endl;
+
+    TString inpath("");
+    TString outpath("");
+    Int_t howMany = 2000;
+    CT1EEst(inpath,   filenameOpt,   outpath, energyParName, 
+            fHilName, fHilNameSrc,   fhadronnessName,
+            howMany,  maxhadronness, maxalpha, maxdist,
+            binsE, binsTheta);
+    gLog << "Macro ONAnalysis.C : returning from CT1EEst" << endl;
+ }
+
+ if (WEX)
+ {
+    //-----------------------------------------------------------
+    //
+    // Read in parameters of energy estimator ("MMcEnergyEst")
+    //                   and migration matrix ("MHMcEnergyMigration")
+    //
+    gLog << "================================================================"
+         << endl;
+    gLog << "Macro ONAnalysis.C : read parameters of energy estimator and migration matrix from file '"
+         << energyParName << "'" << endl;
+    TFile enparam(energyParName);
+    enparam.ls();
+    MMcEnergyEst mcest("MMcEnergyEst"); 
+    mcest.Read("MMcEnergyEst");
+
+    //MMcEnergyEst &mcest = *((MMcEnergyEst*)gROOT->FindObject("MMcEnergyEst"));
+    gLog << "Parameters of energy estimator were read in" << endl;
+
+
+    gLog << "Read in Migration matrix" << endl;   
+
+    MHMcEnergyMigration mighiston("MHMcEnergyMigration");
+    mighiston.Read("MHMcEnergyMigration");
+    //MHMcEnergyMigration &mighiston = 
+    //      *((MHMcEnergyMigration*)gROOT->FindObject("MHMcEnergyMigration"));
+
+    gLog << "Migration matrix was read in" << endl;
+
+
+    TArrayD parA(mcest.GetNumCoeffA());
+    TArrayD parB(mcest.GetNumCoeffB());
+    for (Int_t i=0; i<parA.GetSize(); i++)
+      parA[i] = mcest.GetCoeff(i);
+    for (Int_t i=0; i<parB.GetSize(); i++)
+      parB[i] = mcest.GetCoeff( i+parA.GetSize() );
+
+    //*************************************************************************
+    //
+    // Analyse the data
+    //
+    gLog << "============================================================"
+         << endl;
+    gLog << "Analyse the data" << endl;
+
+    MTaskList tliston;
+    MParList pliston;
+
+    // geometry is needed in  MHHillas... classes 
+    MGeomCam *fGeom = 
+             (MGeomCam*)pliston->FindCreateObj("MGeomCamMagic", "MGeomCam");
+
+
+    //-------------------------------------------
+    // create the tasks which should be executed 
+    //
+
+    MReadMarsFile read("Events", filenameData);
+    read.DisableAutoScheme();
+
+    //.......................................................................
+
+      gLog << "Macro ONAnalysis.C : write root file '" << filenameDataout 
+           << "'" << endl;
+   
+      //MWriteRootFile &write = *(new MWriteRootFile(filenameDataout));
+
+
+      MWriteRootFile write(filenameDataout, "RECREATE");
+
+      write.AddContainer("MRawRunHeader", "RunHeaders");
+      write.AddContainer("MTime",         "Events");
+      write.AddContainer("MMcEvt",        "Events");
+      write.AddContainer("ThetaOrig",     "Events");
+      write.AddContainer("MSrcPosCam",    "Events");
+      write.AddContainer("MSigmabar",     "Events");
+      write.AddContainer("MHillas",       "Events");
+      write.AddContainer("MHillasExt",    "Events");
+      write.AddContainer("MHillasSrc",    "Events");
+      write.AddContainer("MNewImagePar",  "Events");
+
+      //write.AddContainer("HadNN",         "Events");
+      write.AddContainer("HadSC",         "Events");
+      write.AddContainer("HadRF",         "Events");
+
+      write.AddContainer("MEnergyEst",    "Events");
+
+
+    //-----------------------------------------------------------------
+    // geometry is needed in  MHHillas... classes 
+    MGeomCam *fGeom = 
+             (MGeomCam*)pliston->FindCreateObj("MGeomCamMagic", "MGeomCam");
+
+    MFSelFinal selfinalgh(fHilNameSrc);
+    selfinalgh.SetCuts(maxhadronness, 100.0, maxdist);
+    selfinalgh.SetHadronnessName(fhadronnessName);
+    selfinalgh.SetName("SelFinalgh");
+    MContinue contfinalgh(&selfinalgh);
+    contfinalgh.SetName("ContSelFinalgh");
+
+    //MFillH fillhadnn("hadNN[MHHadronness]", "HadNN");
+    //fillhadnn.SetName("HhadNN");
+    MFillH fillhadsc("hadSC[MHHadronness]", "HadSC");
+    fillhadsc.SetName("HhadSC");
+    MFillH fillhadrf("hadRF[MHHadronness]", "HadRF");
+    fillhadrf.SetName("HhadRF");
+
+    //---------------------------
+    // calculate estimated energy
+
+    MEnergyEstParam eeston(fHilName);
+    eeston.Add(fHilNameSrc);
+
+    eeston.SetCoeffA(parA);
+    eeston.SetCoeffB(parB);
+
+    //---------------------------
+    // calculate estimated energy using Daniel's parameters
+
+    //MEnergyEstParamDanielMkn421 eeston(fHilName);
+    //eeston.Add(fHilNameSrc);
+    //eeston.SetCoeffA(parA);
+    //eeston.SetCoeffB(parB);
+
+
+    //---------------------------
+
+
+    MFillH hfill1("MHHillas",    fHilName);
+    hfill1.SetName("HHillas");
+
+    MFillH hfill2("MHStarMap",   fHilName);
+    hfill2.SetName("HStarMap");
+
+    MFillH hfill3("MHHillasExt",   fHilNameSrc);
+    hfill3.SetName("HHillasExt");    
+
+    MFillH hfill4("MHHillasSrc",   fHilNameSrc);
+    hfill4.SetName("HHillasSrc");    
+
+    MFillH hfill5("MHNewImagePar", fImgParName);
+    hfill5.SetName("HNewImagePar");    
+
+    //---------------------------
+    // new from Robert
+
+    MFillH hfill6("MHTimeDiffTheta", "MMcEvt");
+    hfill6.SetName("HTimeDiffTheta");
+
+    MFillH hfill6a("MHTimeDiffTime", "MMcEvt");
+    hfill6a.SetName("HTimeDiffTime");
+
+    MFillH hfill7("MHAlphaEnergyTheta", fHilNameSrc);
+    hfill7.SetName("HAlphaEnergyTheta");
+
+    MFillH hfill7a("MHAlphaEnergyTime", fHilNameSrc);
+    hfill7a.SetName("HAlphaEnergyTime");
+
+    MFillH hfill7b("MHThetabarTime", fHilNameSrc);
+    hfill7b.SetName("HThetabarTime");
+
+    MFillH hfill7c("MHEnergyTime", "MMcEvt");
+    hfill7c.SetName("HEnergyTime");
+
+
+    //---------------------------
+
+    MFSelFinal selfinal(fHilNameSrc);
+    selfinal.SetCuts(maxhadronness, maxalpha, maxdist);
+    selfinal.SetHadronnessName(fhadronnessName);
+    selfinal.SetName("SelFinal");
+    MContinue contfinal(&selfinal);
+    contfinal.SetName("ContSelFinal");
+
+
+    //*****************************
+    // entries in MParList
+
+    pliston.AddToList(&tliston);
+    InitBinnings(&pliston);
+
+
+    //*****************************
+    // entries in MTaskList
+    
+    tliston.AddToList(&read);
+
+    // robert      
+    tliston.AddToList(&hfill6);   //timediff
+    tliston.AddToList(&hfill6a);   //timediff
+
+    tliston.AddToList(&contfinalgh);
+    tliston.AddToList(&eeston);
+
+    tliston.AddToList(&write);
+
+    //tliston.AddToList(&fillhadnn);
+    tliston.AddToList(&fillhadsc);
+    tliston.AddToList(&fillhadrf);
+
+    tliston.AddToList(&hfill1);
+    tliston.AddToList(&hfill2);
+    tliston.AddToList(&hfill3);
+    tliston.AddToList(&hfill4);
+    tliston.AddToList(&hfill5);
+
+    //robert
+    tliston.AddToList(&hfill7);
+    tliston.AddToList(&hfill7a);
+    tliston.AddToList(&hfill7b);
+    tliston.AddToList(&hfill7c);
+
+    tliston.AddToList(&contfinal);
+
+    //*****************************
+
+    //-------------------------------------------
+    // Execute event loop
+    //
+    MProgressBar bar;
+    MEvtLoop evtloop;
+    evtloop.SetParList(&pliston);
+    evtloop.SetProgressBar(&bar);
+
+    Int_t maxevents = -1;
+    if ( !evtloop.Eventloop(maxevents) )
+        return;
+
+    tliston.PrintStatistics(0, kTRUE);
+
+
+    //-------------------------------------------
+    // Display the histograms
+    //
+
+    //pliston.FindObject("hadNN", "MHHadronness")->DrawClone();
+
+    gLog << "before hadRF" << endl;
+    pliston.FindObject("hadRF", "MHHadronness")->DrawClone();
+
+    gLog << "before hadSC" << endl;
+    pliston.FindObject("hadSC", "MHHadronness")->DrawClone();
+
+    gLog << "before MHHillas" << endl;
+    pliston.FindObject("MHHillas")->DrawClone();
+
+    gLog << "before MHHillasExt" << endl;
+    pliston.FindObject("MHHillasExt")->DrawClone();
+
+    gLog << "before MHHillasSrc" << endl;
+    pliston.FindObject("MHHillasSrc")->DrawClone();
+
+    gLog << "before MHNewImagePar" << endl;
+    pliston.FindObject("MHNewImagePar")->DrawClone();
+
+    gLog << "before MHStarMap" << endl;
+    pliston.FindObject("MHStarMap")->DrawClone();
+
+    gLog << "before DeleteBinnings" << endl;
+
+    DeleteBinnings(&pliston);
+
+    gLog << "before Robert's code" << endl;
+
+
+//rwagner write all relevant histograms onto a file
+
+  if (WRobert)
+  {
+    gLog << "=======================================================" << endl;
+    gLog << "Write results onto file '" << filenameResults << "'" << endl;
+
+    TFile outfile(filenameResults,"recreate");
+
+    MHHillasSrc* hillasSrc = 
+      (MHHillasSrc*)(pliston->FindObject("MHHillasSrc"));
+        TH1F* alphaHist = (TH1F*)(hillasSrc->GetHistAlpha());
+    alphaHist->Write();
+    gLog << "Alpha plot has been written out" << endl;    
+
+
+    MHAlphaEnergyTheta* aetH = 
+      (MHAlphaEnergyTheta*)(pliston->FindObject("MHAlphaEnergyTheta"));
+    TH3D* aetHist = (TH3D*)(aetH->GetHist());
+    aetHist->SetName("aetHist");
+    aetHist->Write();
+    gLog << "AlphaEnergyTheta plot has been written out" << endl;    
+
+    MHAlphaEnergyTime* aetH2 = 
+      (MHAlphaEnergyTime*)(pliston->FindObject("MHAlphaEnergyTime"));
+    TH3D* aetHist2 = (TH3D*)(aetH2->GetHist());
+    aetHist2->SetName("aetimeHist");
+//     aetHist2->DrawClone();
+    aetHist2->Write();
+    gLog << "AlphaEnergyTime plot has been written out" << endl;    
+
+    MHThetabarTime* tbt = 
+      (MHThetabarTime*)(pliston->FindObject("MHThetabarTime"));
+    TProfile* tbtHist = (TProfile*)(tbt->GetHist());
+    tbtHist->SetName("tbtHist");
+    tbtHist->Write();
+    gLog << "ThetabarTime plot has been written out" << endl;    
+
+    MHEnergyTime* ent = 
+      (MHEnergyTime*)(pliston->FindObject("MHEnergyTime"));
+    TH2D* entHist = (TH2D*)(ent->GetHist());
+    entHist->SetName("entHist");
+    entHist->Write();
+    gLog << "EnergyTime plot has been written out" << endl;    
+    
+    MHTimeDiffTheta *time = (MHTimeDiffTheta*)pliston.FindObject("MHTimeDiffTheta");
+    TH2D* timeHist = (TH2D*)(time->GetHist());
+    timeHist->SetName("MHTimeDiffTheta");
+    timeHist->SetTitle("Time diffs");
+    timeHist->Write();
+    gLog << "TimeDiffTheta plot has been written out" << endl;    
+
+
+    MHTimeDiffTime *time2 = (MHTimeDiffTime*)pliston.FindObject("MHTimeDiffTime");
+    TH2D* timeHist2 = (TH2D*)(time2->GetHist());
+    timeHist2->SetName("MHTimeDiffTime");
+    timeHist2->SetTitle("Time diffs");
+    timeHist2->Write();
+    gLog << "TimeDiffTime plot has been written out" << endl;    
+
+//rwagner write also collareas to same file
+    collarea->GetHist()->Write();
+    collarea->GetHAll()->Write();
+    collarea->GetHSel()->Write();
+    gLog << "Effective collection areas have been written out" << endl;        
+
+//rwagner todo: write alpha_cut, type of g/h sep (RF, SC, NN), type of data
+//rwagner (ON/OFF/MC), MJDmin, MJDmax to this file
+
+    gLog << "before closing outfile" << endl;
+
+    //outfile.Close();
+    gLog << "Results were written onto file '" << filenameResults 
+         << "'" << endl;
+    gLog << "=======================================================" << endl;
+  }
+
+  }
+
+    gLog << "Macro ONAnalysis : End of Job E_XX" << endl;
+    gLog << "=======================================================" << endl;
+ }
+  //---------------------------------------------------------------------
+
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/macros/ONOFFAnalysis.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/ONOFFAnalysis.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/ONOFFAnalysis.C	(revision 9661)
@@ -0,0 +1,3634 @@
+
+//#include "MagicEgyEst.C"
+
+
+void InitBinnings(MParList *plist)
+{
+        gLog << "InitBinnings" << endl;
+
+        //--------------------------------------------
+        MBinning *binse = new MBinning("BinningE");
+        //binse->SetEdgesLog(30, 1.0e2, 1.0e5);
+
+	//This is Daniel's binning in energy:
+        binse->SetEdgesLog(14, 296.296, 86497.6);
+        plist->AddToList(binse);
+
+        //--------------------------------------------
+
+        MBinning *binssize = new MBinning("BinningSize");
+        binssize->SetEdgesLog(50, 10, 1.0e5);
+        plist->AddToList(binssize);
+
+        MBinning *binsdistc = new MBinning("BinningDist");
+        binsdistc->SetEdges(50, 0, 1.4);
+        plist->AddToList(binsdistc);
+
+        MBinning *binswidth = new MBinning("BinningWidth");
+        binswidth->SetEdges(50, 0, 1.0);
+        plist->AddToList(binswidth);
+
+        MBinning *binslength = new MBinning("BinningLength");
+        binslength->SetEdges(50, 0, 1.0);
+        plist->AddToList(binslength);
+
+        MBinning *binsalpha = new MBinning("BinningAlpha");
+        binsalpha->SetEdges(100, -100, 100);
+        plist->AddToList(binsalpha);
+
+        MBinning *binsasym = new MBinning("BinningAsym");
+        binsasym->SetEdges(50, -1.5, 1.5);
+        plist->AddToList(binsasym);
+
+        MBinning *binsm3l = new MBinning("BinningM3Long");
+        binsm3l->SetEdges(50, -1.5, 1.5);
+        plist->AddToList(binsm3l);
+
+        MBinning *binsm3t = new MBinning("BinningM3Trans");
+        binsm3t->SetEdges(50, -1.5, 1.5);
+        plist->AddToList(binsm3t);
+
+   
+        //.....
+        MBinning *binsb = new MBinning("BinningSigmabar");
+        binsb->SetEdges( 100,  0.0,  50.0);
+        plist->AddToList(binsb);
+
+        MBinning *binth = new MBinning("BinningTheta");
+        // this is Daniel's binning in theta
+        //Double_t yedge[8] = 
+        //  {9.41, 16.22, 22.68, 28.64, 34.03, 38.84, 43.08, 44.99};
+        // this is our binning
+        Double_t yedge[9] = 
+                       {0.0, 17.5, 23.5, 29.5, 35.5, 42., 50., 60., 70.};
+        TArrayD yed;
+        yed.Set(9,yedge);
+        binth->SetEdges(yed);
+        plist->AddToList(binth);
+
+        MBinning *bincosth = new MBinning("BinningCosTheta");
+        Double_t zedge[9]; 
+        for (Int_t i=0; i<9; i++)
+	{
+          zedge[8-i] = cos(yedge[i]/kRad2Deg);
+	}
+        TArrayD zed;
+        zed.Set(9,zedge);
+        bincosth->SetEdges(zed);
+        plist->AddToList(bincosth);
+
+        MBinning *binsdiff = new MBinning("BinningDiffsigma2");
+        binsdiff->SetEdges(100, -300.0, 500.0);
+        plist->AddToList(binsdiff);
+
+        // robert ----------------------------------------------
+        MBinning *binsalphaf = new MBinning("BinningAlphaFlux");
+        binsalphaf->SetEdges(100, -100, 100);
+        plist->AddToList(binsalphaf);
+
+	MBinning *binsdifftime = new MBinning("BinningTimeDiff");
+	binsdifftime->SetEdges(50, 0, 10);
+	plist->AddToList(binsdifftime);
+
+	MBinning *binstime = new MBinning("BinningTime");
+	binstime->SetEdges(50, 44500, 61000);
+	plist->AddToList(binstime);
+}
+
+
+void DeleteBinnings(MParList *plist)
+{
+        gLog << "DeleteBinnings" << endl;
+
+        TObject *bin;
+
+        //--------------------------------------------
+        bin = plist->FindObject("BinningE");
+        if (bin) delete bin;
+
+        //--------------------------------------------
+
+        bin = plist->FindObject("BinningSize");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningDist");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningWidth");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningLength");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningAlpha");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningAsym");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningM3Long");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningM3Trans");
+        if (bin) delete bin;
+
+        //.....
+        bin = plist->FindObject("BinningSigmabar");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningTheta");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningCosTheta");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningDiffsigma2");
+        if (bin) delete bin;
+
+
+        // robert ----------------------------------------------
+        bin = plist->FindObject("BinningAlphaFlux");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningTimeDiff");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningTime");
+        if (bin) delete bin;
+}
+
+
+
+//************************************************************************
+void ONOFFAnalysis()
+{
+      gLog.SetNoColors();
+
+      if (gRandom)
+        delete gRandom;
+      gRandom = new TRandom3(0);
+
+      //-----------------------------------------------
+      //TString tag = "040126";
+      TString tag = "040127";
+      //TString tag = "040215";
+
+      //const char *offfile = "~magican/ct1test/wittek/offdata.preproc"; 
+      //const char *offfile = "20040126_OffCrab_"; 
+      //const char *offfile  = "*.OFF";
+      //const char *offfile  = "12776.OFF";
+      // 27 Jan 04
+      //const char *offfile  = "12*.OFF";
+      // 26 Jan 04
+      //const char *offfile  = "*.OFF";
+      // 15 Feb 04
+      const char *offfile  = "*.OFF";
+
+
+      //const char *onfile  = "~magican/ct1test/wittek/mkn421_on.preproc"; 
+      //      const char *onfile  = "~magican/ct1test/wittek/mkn421_00-01"; 
+      //const char *onfile  = "20040126_Crab_";
+      //const char *onfile  = "MCerPhot_output";
+      //const char *onfile  = "*.ON";
+      const char *onfile  = "1216*.ON";
+      // 27 Jan 04
+      //const char *onfile  = "12*.ON";
+      // 26 Jan 04
+      //const char *onfile  = "*.ON";
+      // 15 Feb 04
+      //const char *onfile  = "*.ON";
+
+
+     const char *mcfile  = "/data/MAGIC/mc_eth/magLQE_3/gh/0/0/G_M0_00_0_550*.root";
+      //const char *mcfile  = "/data/MAGIC/mc_eth/magLQE_4/gh/0/0/G_M0_00_0_550*.root";
+      //const char *mcfile  = "/data/MAGIC/mc_eth/magLQE_5/gh/0/0/G_M0_00_0_550*.root";
+      //-----------------------------------------------
+
+      // path for input for Mars
+      //TString inPath = "/.magic/magicserv01/scratch/";
+      //TString inPath = "/mnt/data17a/hbartko/";
+      //TString inPath = "~wittek/datacrab_feb04/";
+      //TString inPath = "~wittek/datacrab_26feb04/";
+     //TString inPath = "/.magic/magicserv01/scratch/David/CalibratedRuns/";
+     // 26 Jan 04, Hendrik
+     if (tag == "040126")
+       TString inPath = "/.magic/magicserv01/scratch/calibrated26/";
+
+     // 27 Jan 04, Hendrik
+     if (tag == "040127")
+        TString inPath = "/.magic/magicserv01/scratch/calibrated/";
+
+     // 27 Jan 04, David
+     //if (tag == "040127")
+     //TString inPath = "/mnt/magicserv01/scratch/David/CalibratedData/Crab/2004_01_27/";
+
+     // 15 Feb 04, David
+     if (tag == "040215")
+       TString inPath = "/mnt/magicserv01/scratch/David/CalibratedData/Crab/2004_02_15/";
+   
+
+      // path for output from Mars
+      //TString outPath = "~wittek/datacrab_feb04/";
+     //TString outPath = "~wittek/datacrab_01march04/";
+      TString outPath = "~wittek/datacrab_19mar04/";
+
+      //-----------------------------------------------
+
+      //TEnv env("macros/CT1env.rc");
+      //Bool_t printEnv = kFALSE;
+
+    //************************************************************************
+
+    // Job A : 
+    //  - produce MHSigmaTheta plots for ON, OFF and MC data
+    //  - write out (or read in) these MHSigmaTheta plots
+    //  - read ON (or OFF or MC) data
+    //  - pad the events; 
+    //  - write root file for ON (or OFF or MC) data (ON1.root, ...);
+
+    Bool_t JobA    = kTRUE;  
+    Bool_t GPad    = kFALSE;    // generate padding histograms?
+    Bool_t WPad    = kFALSE;   // write out padding histograms ?
+    Bool_t RPad    = kFALSE;   // read in padding histograms ?
+    Bool_t Wout    = kTRUE;   // write out root file ON1.root 
+                               // (or OFF1.root or MC1.root)?
+
+
+    // Job B_RF_UP : read ON1.root (OFF1.root or MC1.root) file 
+    //  - if CTrainRF = TRUE : create matrices of training events
+    //                         and root files of training and test events
+    //  - if RTrainRF = TRUE : read in training matrices for hadrons and gammas
+    //  - if RTree    = TRUE : read in trees, otherwise create trees
+    //  - calculate hadroness for method of RANDOM FOREST
+    //  - update the input files with the hadronesses (ON2.root, OFF2.root
+    //     or MC2.root)
+
+    Bool_t JobB_RF_UP  = kFALSE;  
+    Bool_t CTrainRF    = kFALSE;  // create  matrices of training events
+                                  // and root files of training and test events
+    Bool_t RTrainRF    = kFALSE;  // read in matrices of training events
+    Bool_t RTree       = kFALSE;  // read in trees (otherwise grow them)
+    Bool_t WRF         = kFALSE;  // update input root file ?
+
+
+    // Job B_SC_UP : read ON2.root (or MC2.root) file 
+    //  - depending on WParSC : create (or read in) supercuts parameter values
+    //  - calculate hadroness for the SUPERCUTS
+    //  - update the input files with the hadroness (==>ON3.root or MC3.root)
+
+    Bool_t JobB_SC_UP  = kFALSE;
+    Bool_t CMatrix     = kFALSE;  // create training and test matrices 
+    Bool_t RMatrix     = kFALSE;  // read training and test matrices from file
+    Bool_t WOptimize   = kFALSE;  // do optimization using the training sample
+                                  // and write supercuts parameter values 
+                                  // onto the file parSCfile
+    Bool_t RTest       = kFALSE;  // test the supercuts using the test matrix
+    Bool_t WSC         = kFALSE;  // update input root file ?
+
+
+    // Job C: 
+    //  - read ON3.root and MC3.root files
+    //    which should have been updated to contain the hadronnesses  
+    //    for the method of 
+    //              RF
+    //              SUPERCUTS and
+    //  - produce Neyman-Pearson plots
+
+    Bool_t JobC  = kFALSE;  
+
+
+    // Job D :  
+    //  - select g/h separation method XX
+    //  - read ON3 (or MC3) root file
+    //  - apply cuts in hadronness
+    //  - make plots
+
+    Bool_t JobD  = kFALSE;  
+
+
+
+    // Job E_XX : extended version of E_XX (including flux plots)  
+    //  - select g/h separation method XX
+    //  - read MC root file 
+    //  - calculate eff. collection area
+    //  - optimize energy estimator
+    //  - read ON root file 
+    //  - apply final cuts
+    //  - calculate flux
+    //  - write root file for ON data after final cuts 
+
+
+    Bool_t JobE_XX  = kFALSE;  
+    Bool_t CCollArea= kFALSE;  // calculate eff. collection areas
+    Bool_t OEEst    = kFALSE;  // optimize energy estimator
+    Bool_t WEX      = kFALSE;  // update root file  ?
+    Bool_t WRobert  = kFALSE;  // write out Robert's file  ?
+
+
+
+    //************************************************************************
+
+    
+  //---------------------------------------------------------------------
+  // Job A
+  //=========
+
+    //  - produce the histograms "sigmabar versus Theta", etc. 
+    //    for ON, OFF and MC data (to be used for the padding)
+    //
+    //  - write root file of padded ON (OFF, MC) events (ON1.root, ...) 
+    //    (after the standard cuts, before the g/h separation)
+
+
+ if (JobA)
+ {
+    gLog << "=====================================================" << endl;
+    gLog << "Macro ONOFFAnalysis : Start of Job A" << endl;
+    gLog << "" << endl;
+    gLog << "Macro ONOFFAnalysis : JobA, WPad, RPad, Wout = " 
+         << (JobA ? "kTRUE" : "kFALSE")  << ",  " 
+         << (WPad ? "kTRUE" : "kFALSE")  << ",  " 
+         << (RPad ? "kTRUE" : "kFALSE")  << ",  " 
+         << (Wout ? "kTRUE" : "kFALSE")  << endl;
+    
+
+    //--------------------------------------------------
+    // names of ON and OFF files to be read
+    // for generating the histograms to be used in the padding 
+
+
+    TString fileON  = inPath;
+    fileON += onfile;
+    fileON += ".root";
+
+    TString fileOFF = inPath;
+    fileOFF += offfile;
+    fileOFF += ".root";
+
+    TString fileMC  = mcfile;
+    fileMC += mcfile;
+    fileMC += ".root";
+
+    gLog << "fileON, fileOFF, fileMC = " << fileON << ",  " 
+         << fileOFF << ",  " << fileMC   << endl;
+
+    // name of file to conatin the histograms for the padding
+    TString outNameSigTh = outPath;
+    outNameSigTh += "SigmaTheta";
+    outNameSigTh += ".root";
+
+    //--------------------------------------------------
+    // type of data to be padded 
+    TString typeInput = "ON";
+    //TString typeInput = "OFF";
+    //TString typeInput = "MC";
+    gLog << "typeInput = " << typeInput << endl;
+
+
+    // name of input root file
+    if (typeInput == "ON")
+      TString filenamein(fileON);
+    else if (typeInput == "OFF")
+      TString filenamein(fileOFF);
+    else if (typeInput == "MC")
+      TString filenamein(fileMC);
+    gLog << "data to be padded : " << filenamein << endl;
+
+    // name of output root file
+    //if (typeInput == "ON")
+    //  TString file(onfile);
+    //else if (typeInput == "OFF")
+    //  TString file(offfile);
+    //else if (typeInput == "MC")
+    //  TString file(mcfile);
+
+    TString outNameImage = outPath;
+    outNameImage += tag;
+    outNameImage += "Hillas";
+    outNameImage += typeInput;
+    outNameImage += "1.root";
+    gLog << "padded data to be written onto : " << outNameImage << endl;
+
+    //--------------------------------------------------
+
+    //************************************************************
+    // generate histograms to be used in the padding
+    // 
+    // read ON, OFF and MC data files
+    // generate (or read in) the padding histograms for ON and OFF data
+    //                       and merge these histograms
+
+    MPad pad;
+    pad.SetName("MPad");
+    pad.SetDataType(typeInput);
+
+    // generate the padding histograms
+    if (GPad)
+    {
+      gLog << "=====================================================" << endl;
+      gLog << "Start generating the padding histograms" << endl;
+      //-----------------------------------------
+      // ON events
+
+      gLog << "-----------" << endl;
+      gLog << "ON events :" << endl;
+      gLog << "-----------" << endl;
+
+      MTaskList tliston;
+      MParList pliston;
+
+    MReadMarsFile  readON("Events", fileON);
+    readON.DisableAutoScheme();
+    //MCT1ReadPreProc readON(fileON);
+
+      //MFSelBasic selthetaon;
+      //selthetaon.SetCuts(-100.0, 29.5, 35.5);
+      //MContinue contthetaon(&selthetaon);
+
+      MBlindPixelCalc blindon;
+      blindon.SetUseBlindPixels();
+
+      MFSelBasic selbasicon;
+      MContinue contbasicon(&selbasicon);
+
+      MHBlindPixels blindON("BlindPixelsON");
+      MFillH fillblindON("BlindPixelsON[MHBlindPixels]", "MBlindPixels");
+      fillblindON.SetName("FillBlind");
+
+      MSigmabarCalc sigbarcalcon;
+
+      MHSigmaTheta sigthON("SigmaThetaON");
+      MFillH fillsigthetaON ("SigmaThetaON[MHSigmaTheta]", "MMcEvt");
+      fillsigthetaON.SetName("FillSigTheta");    
+ 
+      //*****************************
+      // entries in MParList
+    
+      pliston.AddToList(&tliston);
+      InitBinnings(&pliston);
+      pliston.AddToList(&blindON);
+      pliston.AddToList(&sigthON);
+
+
+      //*****************************
+      // entries in MTaskList
+    
+      tliston.AddToList(&readON);
+      //tliston.AddToList(&contthetaon);
+
+      tliston.AddToList(&blindon);
+
+      tliston.AddToList(&contbasicon);
+      tliston.AddToList(&fillblindON);
+      tliston.AddToList(&sigbarcalcon);
+      tliston.AddToList(&fillsigthetaON);
+
+      MProgressBar baron;
+      MEvtLoop evtloopon;
+      evtloopon.SetParList(&pliston);
+      evtloopon.SetProgressBar(&baron);
+
+      Int_t maxeventson = -1;
+      //Int_t maxeventson = 10000;
+      if ( !evtloopon.Eventloop(maxeventson) )
+          return;
+
+      tliston.PrintStatistics(0, kTRUE);
+
+      blindON.DrawClone();
+      sigthON.DrawClone();
+
+      // save the histograms for the padding
+      TH2D *sigthon     = sigthON.GetSigmaTheta();
+      TH3D *sigpixthon  = sigthON.GetSigmaPixTheta();
+      TH3D *diffpixthon = sigthON.GetDiffPixTheta();
+
+      TH2D *blindidthon = blindON.GetBlindId();
+      TH2D *blindnthon  = blindON.GetBlindN();
+
+      //-----------------------------------------
+      // OFF events
+
+      gLog << "------------" << endl;
+      gLog << "OFF events :" << endl;
+      gLog << "------------" << endl;
+
+      MTaskList tlistoff;
+      MParList plistoff;
+
+    MReadMarsFile  readOFF("Events", fileOFF);
+    readOFF.DisableAutoScheme();
+    //      MCT1ReadPreProc readOFF(fileOFF);
+
+      MFSelBasic selthetaoff;
+      selthetaoff.SetCuts(-100.0, 29.5, 35.5);
+      MContinue contthetaoff(&selthetaoff);
+
+      MBlindPixelCalc blindoff;
+      blindoff.SetUseBlindPixels();
+
+      MFSelBasic selbasicoff;
+      MContinue contbasicoff(&selbasicoff);
+
+      MHBlindPixels blindOFF("BlindPixelsOFF");
+      MFillH fillblindOFF("BlindPixelsOFF[MHBlindPixels]", "MBlindPixels");
+      fillblindOFF.SetName("FillBlindOFF");
+
+      MSigmabarCalc sigbarcalcoff;
+
+      MHSigmaTheta sigthOFF("SigmaThetaOFF");
+      MFillH fillsigthetaOFF ("SigmaThetaOFF[MHSigmaTheta]", "MMcEvt");
+      fillsigthetaOFF.SetName("FillSigThetaOFF");     
+
+      //*****************************
+      // entries in MParList
+    
+      plistoff.AddToList(&tlistoff);
+      InitBinnings(&plistoff);
+      plistoff.AddToList(&blindOFF);
+      plistoff.AddToList(&sigthOFF);
+
+
+      //*****************************
+      // entries in MTaskList
+    
+      tlistoff.AddToList(&readOFF);
+      //tlistoff.AddToList(&contthetaoff);
+
+      tlistoff.AddToList(&blindoff);
+
+      tlistoff.AddToList(&contbasicoff);
+      tlistoff.AddToList(&fillblindOFF);
+      tlistoff.AddToList(&sigbarcalcoff);
+      tlistoff.AddToList(&fillsigthetaOFF);
+
+      MProgressBar baroff;
+      MEvtLoop evtloopoff;
+      evtloopoff.SetParList(&plistoff);
+      evtloopoff.SetProgressBar(&baroff);
+
+      Int_t maxeventsoff = -1;
+      //Int_t maxeventsoff = 20000;
+      if ( !evtloopoff.Eventloop(maxeventsoff) )
+          return;
+
+      tlistoff.PrintStatistics(0, kTRUE);
+
+      blindOFF.DrawClone();
+      sigthOFF.DrawClone();
+
+      // save the histograms for the padding
+      TH2D *sigthoff     = sigthOFF.GetSigmaTheta();
+      TH3D *sigpixthoff  = sigthOFF.GetSigmaPixTheta();
+      TH3D *diffpixthoff = sigthOFF.GetDiffPixTheta();
+
+      TH2D *blindidthoff = blindOFF.GetBlindId();
+      TH2D *blindnthoff  = blindOFF.GetBlindN();
+
+
+      //-----------------------------------------
+      // MC events
+
+      gLog << "------------" << endl;
+      gLog << "MC events :" << endl;
+      gLog << "------------" << endl;
+
+      MTaskList tlistmc;
+      MParList plistmc;
+
+    MReadMarsFile  readMC("Events", fileMC);
+    readMC.DisableAutoScheme();
+    //      MCT1ReadPreProc readMC(fileMC);
+
+      MFSelBasic selthetamc;
+      selthetamc.SetCuts(-100.0, 29.5, 35.5);
+      MContinue contthetamc(&selthetamc);
+
+      MBlindPixelCalc blindmc;
+      blindmc.SetUseBlindPixels();
+
+      MFSelBasic selbasicmc;
+      MContinue contbasicmc(&selbasicmc);
+
+      MHBlindPixels blindMC("BlindPixelsMC");
+      MFillH fillblindMC("BlindPixelsMC[MHBlindPixels]", "MBlindPixels");
+      fillblindMC.SetName("FillBlindMC");
+
+      MSigmabarCalc sigbarcalcmc;
+
+      MHSigmaTheta sigthMC("SigmaThetaMC");
+      MFillH fillsigthetaMC ("SigmaThetaMC[MHSigmaTheta]", "MMcEvt");
+      fillsigthetaMC.SetName("FillSigThetaMC");     
+
+      //*****************************
+      // entries in MParList
+    
+      plistmc.AddToList(&tlistmc);
+      InitBinnings(&plistmc);
+      plistmc.AddToList(&blindMC);
+      plistmc.AddToList(&sigthMC);
+
+
+      //*****************************
+      // entries in MTaskList
+    
+      tlistmc.AddToList(&readMC);
+      //tlistmc.AddToList(&contthetamc);
+
+      tlistmc.AddToList(&blindmc);
+
+      tlistmc.AddToList(&contbasicmc);
+      tlistmc.AddToList(&fillblindMC);
+      tlistmc.AddToList(&sigbarcalcmc);
+      tlistmc.AddToList(&fillsigthetaMC);
+
+      MProgressBar barmc;
+      MEvtLoop evtloopmc;
+      evtloopmc.SetParList(&plistmc);
+      evtloopmc.SetProgressBar(&barmc);
+
+      Int_t maxeventsmc = -1;
+      //Int_t maxeventsmc = 20000;
+      if ( !evtloopmc.Eventloop(maxeventsmc) )
+          return;
+
+      tlistmc.PrintStatistics(0, kTRUE);
+
+      blindMC.DrawClone();
+      sigthMC.DrawClone();
+
+      // save the histograms for the padding
+      TH2D *sigthmc     = sigthMC.GetSigmaTheta();
+      TH3D *sigpixthmc  = sigthMC.GetSigmaPixTheta();
+      TH3D *diffpixthmc = sigthMC.GetDiffPixTheta();
+
+      TH2D *blindidthmc = blindMC.GetBlindId();
+      TH2D *blindnthmc  = blindMC.GetBlindN();
+
+
+      //-----------------------------------------
+
+      gLog << "End of generating the padding histograms" << endl;
+      gLog << "=====================================================" << endl;
+
+      pad.MergeONOFFMC(sigthmc,      diffpixthmc,  sigpixthmc, 
+                       blindidthmc,  blindnthmc,
+                       sigthon,      diffpixthon,  sigpixthon, 
+                       blindidthon,  blindnthon,
+                       sigthoff,     diffpixthoff, sigpixthoff, 
+                       blindidthoff, blindnthoff);
+
+
+      if (WPad)
+      {
+        // write the padding histograms onto a file  ---------
+        pad.WritePaddingDist(outNameSigTh);     
+      }
+    }
+
+    // read the padding histograms ---------------------------
+    if (RPad)
+    {
+      pad.ReadPaddingDist(outNameSigTh);
+    }
+
+
+    //************************************************************
+
+  if (Wout)
+  {
+    gLog << "=====================================================" << endl;
+    gLog << "Start the padding" << endl;
+
+    //-----------------------------------------------------------
+    MTaskList tliston;
+    MParList pliston;
+
+    MObservatory observ;
+
+    char *sourceName = "MSrcPosCam";
+    MSrcPosCam source(sourceName);
+
+    // geometry is needed in  MHHillas... classes 
+    MGeomCam *fGeom = 
+             (MGeomCam*)pliston->FindCreateObj("MGeomCamMagic", "MGeomCam");
+
+    //-------------------------------------------
+    // create the tasks which should be executed 
+    //
+
+    MReadMarsFile read("Events", filenamein);
+    read.DisableAutoScheme();
+
+    MGeomApply        apply;
+
+    //MPedestalWorkaround waround;
+
+    // a way to find out whether one is dealing with MC :
+    MFDataMember f1("MRawRunHeader.fRunType", '>', 255.5);  // MC
+    f1.SetName("Select MC");
+    MFDataMember f2("MRawRunHeader.fRunType", '<', 255.5);  // data
+    f2.SetName("Select Data");
+
+    //if (typeInput ==  "ON")
+    //{
+    //   MCT1PointingCorrCalc pointcorr(sourceName, "MCT1PointingCorrCalc", 
+    //                                             "MCT1PointingCorrCalc");
+    //}
+    MSourcePosfromStarPos sourcefromstar;
+    if (typeInput == "ON")
+    {
+      sourcefromstar.SetSourceAndStarPosition(
+                               "Crab", 22,  0, 52, 5, 34, 32.0,
+      			   "Zeta-Tau", 21,  8, 33, 5, 37, 38.7);
+      sourcefromstar.AddStar("Tau114", 21, 56, 13, 5, 27, 38.1);
+      //sourcefromstar.AddFile("~wittek/datacrab_26feb04/positionsOn.4.txt",0);
+
+      if(inPath == "/.magic/magicserv01/scratch/calibrated/")
+      {
+        sourcefromstar.AddFile("~wittek/datacrab_26feb04/positions2stars.txt", 0);
+        //sourcefromstar.AddFile("~wittek/datacrab_26feb04/positionsNoStar.txt", 0);
+      }
+      else if(inPath == "/.magic/magicserv01/scratch/calibrated26/")
+        sourcefromstar.AddFile("~wittek/datacrab_26feb04/stars_2004_01_26", 0);
+
+      else if(inPath == "/mnt/magicserv01/scratch/David/CalibratedData/Crab/2004_02_15/")
+        sourcefromstar.AddFile("~wittek/datacrab_26feb04/positions040215.txt", 0);
+    }
+    else if (typeInput == "OFF")
+    {
+      if(inPath == "/.magic/magicserv01/scratch/calibrated/")
+        sourcefromstar.AddFile("~wittek/datacrab_26feb04/positionsOff.txt", 0);
+      else if(inPath == "/.magic/magicserv01/scratch/calibrated26/")
+        sourcefromstar.AddFile("~wittek/datacrab_26feb04/positions_2004_01_26", 0);
+      else if(inPath == "/mnt/magicserv01/scratch/David/CalibratedData/Crab/2004_02_15")
+        sourcefromstar.AddFile("~wittek/datacrab_26feb04/positions040215.txt", 0);
+    }
+
+
+    //MBlindPixelCalc blindbeforepad;
+    //blindbeforepad.SetUseBlindPixels();
+    //blindbeforepad.SetName("BlindBeforePadding");
+
+    //MBlindPixelCalc blind;
+    //blind.SetUseBlindPixels();
+    //blind.SetUseInterpolation();
+    //blind.SetName("BlindAfterPadding");
+
+    MSigmabarCalc sigbar;
+
+    //MBadPixelCalcRms blind;
+    MBlindPixelsCalc2 blind;
+    //blind.SetUseBlindPixels();
+    blind.SetUseInterpolation();
+    blind.SetCheckPedestalRms();
+    blind.SetName("BlindAfterPadding");
+
+    MFSelBasic selbasic;
+    MContinue contbasic(&selbasic);
+    contbasic.SetName("SelBasic");
+
+    MFillH fillblind("BlindPixels[MHBlindPixels]", "MBlindPixels");
+    fillblind.SetName("HBlind");
+
+    MSigmabarCalc sigbarcalc;
+
+    MFillH fillsigtheta ("SigmaTheta[MHSigmaTheta]", "MMcEvt");
+    fillsigtheta.SetName("HSigmaTheta");
+
+    MImgCleanStd    clean(3.0, 2.5);
+    //clean.SetMethod(MImgCleanStd::kDemocratic);
+    clean.SetCleanRings(3); 
+
+
+    // calculation of  image parameters ---------------------
+    TString fHilName    = "MHillas";
+    TString fHilNameExt = "MHillasExt";
+    TString fHilNameSrc = "MHillasSrc";
+    TString fImgParName = "MNewImagePar";
+
+    MHillasCalc    hcalc;
+    hcalc.SetNameHillas(fHilName);
+    hcalc.SetNameHillasExt(fHilNameExt);
+    hcalc.SetNameNewImgPar(fImgParName);
+
+    MHillasSrcCalc hsrccalc(sourceName, fHilNameSrc);
+    hsrccalc.SetInput(fHilName);
+
+    MFillH hfill1("MHHillas",    fHilName);
+    hfill1.SetName("HHillas");
+
+    MFillH hfill2("MHStarMap",   fHilName);
+    hfill2.SetName("HStarMap");
+
+    MFillH hfill3("MHHillasExt",   fHilNameSrc);
+    hfill3.SetName("HHillasExt");
+
+    MFillH hfill4("MHHillasSrc",   fHilNameSrc);
+    hfill4.SetName("HHillasSrc");
+
+    MFillH hfill5("MHNewImagePar", fImgParName);
+    hfill5.SetName("HNewImagePar");
+    // --------------------------------------------------
+
+    MFSelStandard selstandard(fHilNameSrc);
+    selstandard.SetHillasName(fHilName);
+    selstandard.SetImgParName(fImgParName);
+    selstandard.SetCuts(200, 5, 200, 0.0, 5.0, 0.1, 0.07);
+    MContinue contstandard(&selstandard);
+    contstandard.SetName("SelStandard");
+
+    
+      MWriteRootFile write(outNameImage);
+
+      write.AddContainer("MRawRunHeader", "RunHeaders");
+      //write.AddContainer("MMcRunHeader",  "RunHeaders", kFALSE);
+      //write.AddContainer("MTime",         "Events");
+      write.AddContainer("MMcEvt",        "Events");
+      //write.AddContainer("ThetaOrig",     "Events");
+      write.AddContainer("MSrcPosCam",    "Events");
+      write.AddContainer("MSigmabar",     "Events");
+      write.AddContainer("MHillas",       "Events");
+      write.AddContainer("MHillasExt",    "Events");
+      write.AddContainer("MHillasSrc",    "Events");
+      write.AddContainer("MNewImagePar",  "Events");
+    
+
+    //*****************************
+    // entries in MParList
+    
+    pliston.AddToList(&tliston);
+    pliston.AddToList(&observ);
+    InitBinnings(&pliston);
+
+    pliston.AddToList(&source);
+
+    //*****************************
+    // entries in MTaskList
+    
+    tliston.AddToList(&read);
+
+    //tliston.AddToList(&f1);
+    //tliston.AddToList(&f2);
+    tliston.AddToList(&apply);
+    //tliston.AddToList(&waround);
+    tliston.AddToList(&sourcefromstar);
+
+    //tliston.AddToList(&blindbeforepad);
+    //  tliston.AddToList(&pad); 
+    //  if (typeInput ==  "ON")
+    //  tliston.AddToList(&pointcorr);
+
+    tliston.AddToList(&sigbar);
+    tliston.AddToList(&blind);
+    tliston.AddToList(&contbasic);
+
+    tliston.AddToList(&fillblind);
+    //tliston.AddToList(&sigbarcalc);
+    tliston.AddToList(&fillsigtheta);
+    tliston.AddToList(&clean);
+
+    tliston.AddToList(&hcalc);
+    tliston.AddToList(&hsrccalc);
+
+    tliston.AddToList(&hfill1);
+    tliston.AddToList(&hfill2);
+    tliston.AddToList(&hfill3);
+    tliston.AddToList(&hfill4);
+    tliston.AddToList(&hfill5);
+
+    tliston.AddToList(&contstandard);
+    tliston.AddToList(&write);
+
+    //*****************************
+
+    //-------------------------------------------
+    // Execute event loop
+    //
+    MProgressBar bar;
+    MEvtLoop evtloop;
+    evtloop.SetParList(&pliston);
+    //evtloop.ReadEnv(env, "", printEnv);
+    evtloop.SetProgressBar(&bar);
+    //  evtloop.Write();
+
+    Int_t maxevents = -1;
+    //Int_t maxevents = 1000;
+    if ( !evtloop.Eventloop(maxevents) )
+        return;
+
+    tliston.PrintStatistics(0, kTRUE);
+
+
+    //-------------------------------------------
+    // Display the histograms
+
+    pliston.FindObject("SigmaTheta", "MHSigmaTheta")->DrawClone();
+    pliston.FindObject("BlindPixels", "MHBlindPixels")->DrawClone();
+
+    pliston.FindObject("MHHillas")->DrawClone();
+    pliston.FindObject("MHHillasExt")->DrawClone();
+    pliston.FindObject("MHHillasSrc")->DrawClone();
+    pliston.FindObject("MHNewImagePar")->DrawClone();
+    pliston.FindObject("MHStarMap")->DrawClone();
+
+    //DeleteBinnings(&pliston);
+
+      gLog << "End of padding" << endl;
+      gLog << "=====================================================" << endl;
+  }  
+
+
+    gLog << "Macro ONOFFAnalysis : End of Job A" << endl;
+    gLog << "===================================================" << endl;
+ }
+
+
+
+
+
+  //---------------------------------------------------------------------
+  // Job B_RF_UP
+  //============
+
+
+    //  - create (or read in) the matrices of training events for gammas 
+    //    and hadrons
+    //  - create (or read in) the trees
+    //  - then read ON1.root (or MC1.root) file 
+    //  - calculate the hadroness for the method of RANDOM FOREST
+    //  - update input root file with the hadroness
+
+
+ if (JobB_RF_UP)
+ {
+    gLog << "=====================================================" << endl;
+    gLog << "Macro ONOFFAnalysis : Start of Job B_RF_UP" << endl;
+
+    gLog << "" << endl;
+    gLog << "Macro ONOFFAnalysis : JobB_RF_UP, RTrainRF, CTrainRF, RTree, WRF = "
+         << (JobB_RF_UP ? "kTRUE" : "kFALSE")  << ",  " 
+         << (RTrainRF ?   "kTRUE" : "kFALSE")  << ",  " 
+         << (CTrainRF ?   "kTRUE" : "kFALSE")  << ",  " 
+         << (RTree ?      "kTRUE" : "kFALSE")  << ",  "
+         << (WRF ?        "kTRUE" : "kFALSE")  << endl;
+
+
+    //--------------------------------------------
+    // parameters for the random forest
+    Int_t NumTrees = 100;
+    Int_t NumTry   =   3;
+    Int_t NdSize   =   1;
+
+
+    TString hadRFName = "HadRF";
+    Float_t maxhadronness =  0.23;
+    Float_t maxalpha      =  20.0;
+    Float_t maxdist       =  10.0;
+
+    TString fHilName    = "MHillas"; 
+    TString fHilNameExt = "MHillasExt"; 
+    TString fHilNameSrc = "MHillasSrc"; 
+    TString fImgParName = "MNewImagePar"; 
+
+
+    TString extin  = "1.root";
+    TString extout = "2.root";
+
+    //--------------------------------------------
+    // for the analysis using ON data only set typeMatrixHadrons = "ON"
+    //                        ON and OFF data                    = "OFF"
+    TString typeMatrixHadrons = "OFF";
+    gLog << "typeMatrixHadrons = " << typeMatrixHadrons << endl;
+
+
+    // file to be updated (ON, OFF or MC)
+
+    //TString typeInput = "ON";
+    TString typeInput = "OFF";
+    //TString typeInput = "MC";
+    gLog << "typeInput = " << typeInput << endl;
+
+    // name of input root file
+    TString NameData = outPath;
+    NameData += typeInput;
+    TString inNameData(NameData);
+    inNameData += extin;
+    gLog << "inNameData = " << inNameData << endl; 
+
+    // name of output root file
+    TString outNameData(NameData);
+    outNameData += extout;
+    gLog << "outNameData = " << outNameData << endl; 
+
+    //--------------------------------------------
+    // files to be read for generating 
+    //    - the matrices of training events
+    //    - and the root files of training and test events
+
+
+    // "hadrons" :
+    TString filenameHad = outPath;
+    filenameHad += typeMatrixHadrons;
+    filenameHad += extin;
+    Int_t howManyHadronsTrain = 12000;
+    Int_t howManyHadronsTest  = 12000;
+    gLog << "filenameHad = "    << filenameHad << ",   howManyHadronsTrain = "
+         << howManyHadronsTrain << ",   howManyHadronsTest = "
+         << howManyHadronsTest  << endl; 
+    
+
+    // "gammas" :
+    TString filenameMC = outPath;
+    filenameMC += "MC";
+    filenameMC += extin;
+    Int_t howManyGammasTrain = 12000;
+    Int_t howManyGammasTest  = 12000;
+    gLog << "filenameMC = "    << filenameMC << ",   howManyGammasTrain = "
+         << howManyGammasTrain << ",   howManyGammasTest = "
+         << howManyGammasTest  << endl; 
+    
+    //--------------------------------------------
+    // files for the matrices of training events 
+
+    TString NameGammas = outPath;
+    NameGammas += "RFmatrix_gammas_Train_";
+    NameGammas += "MC";
+    NameGammas += extin;
+
+    TString NameHadrons = outPath;
+    NameHadrons += "RFmatrix_hadrons_Train_";
+    NameHadrons += typeMatrixHadrons;
+    NameHadrons += extin;
+
+
+    //--------------------------------------------
+    // root files for the training events 
+
+    TString NameGammasTrain = outPath;
+    NameGammasTrain += "RF_gammas_Train_";
+    NameGammasTrain += "MC";
+    TString inNameGammasTrain(NameGammasTrain);    
+    inNameGammasTrain += extin;
+    TString outNameGammasTrain(NameGammasTrain);    
+    outNameGammasTrain += extout;
+
+
+    TString NameHadronsTrain = outPath;
+    NameHadronsTrain += "RF_hadrons_Train_";
+    NameHadronsTrain += typeMatrixHadrons;
+    TString inNameHadronsTrain(NameHadronsTrain);    
+    inNameHadronsTrain += extin;
+    TString outNameHadronsTrain(NameHadronsTrain);    
+    outNameHadronsTrain += extout;
+
+
+    //--------------------------------------------
+    // root files for the test events 
+
+    TString NameGammasTest = outPath;
+    NameGammasTest += "RF_gammas_Test_";
+    NameGammasTest += "MC";
+    TString inNameGammasTest(NameGammasTest);    
+    inNameGammasTest += extin;
+    TString outNameGammasTest(NameGammasTest);    
+    outNameGammasTest += extout;
+
+    TString NameHadronsTest = outPath;
+    NameHadronsTest += "RF_hadrons_Test_";
+    NameHadronsTest += typeMatrixHadrons;
+    TString inNameHadronsTest(NameHadronsTest);    
+    inNameHadronsTest += extin;
+    TString outNameHadronsTest(NameHadronsTest);    
+    outNameHadronsTest += extout;
+
+    //--------------------------------------------------------------------
+
+
+    MHMatrix matrixg("MatrixGammas");
+    matrixg.EnableGraphicalOutput();
+
+    matrixg.AddColumn("cos(MMcEvt.fTelescopeTheta)");
+    matrixg.AddColumn("MSigmabar.fSigmabar");
+    matrixg.AddColumn("log10(MHillas.fSize)");
+    matrixg.AddColumn("MHillasSrc.fDist");
+    matrixg.AddColumn("MHillas.fWidth");
+    matrixg.AddColumn("MHillas.fLength");
+    matrixg.AddColumn("log10(MHillas.fSize/(MHillas.fWidth*MHillas.fLength))");
+    matrixg.AddColumn("sgn(MHillasSrc.fCosDeltaAlpha)*(MHillasExt.fM3Long)");
+    matrixg.AddColumn("MNewImagePar.fConc");
+    matrixg.AddColumn("MNewImagePar.fLeakage1");
+
+    MHMatrix matrixh("MatrixHadrons");
+    matrixh.EnableGraphicalOutput();
+
+    matrixh.AddColumns(matrixg.GetColumns());
+
+    //--------------------------------------------
+    // file of trees of the random forest 
+
+    TString outRF = outPath;
+    outRF += "RF.root";
+
+
+   //*************************************************************************
+   // read in matrices of training events
+if (RTrainRF)
+  {
+    const char* mtxName = "MatrixGammas";
+
+    gLog << "" << endl;
+    gLog << "========================================================" << endl;
+    gLog << "Get matrix for (gammas)" << endl;
+    gLog << "matrix name        = " << mtxName << endl;
+    gLog << "name of root file  = " << NameGammas << endl;
+    gLog << "" << endl;
+
+
+    // read in the object with the name 'mtxName' from file 'NameGammas'
+    //
+    TFile fileg(NameGammas); 
+
+    matrixg.Read(mtxName);
+    matrixg.Print("SizeCols");
+
+
+    //***************************************************************** 
+
+    const char* mtxName = "MatrixHadrons";
+
+    gLog << "" << endl;
+    gLog << "========================================================" << endl;
+    gLog << " Get matrix for (hadrons)" << endl;
+    gLog << "matrix name        = " << mtxName << endl;
+    gLog << "name of root file  = " << NameHadrons << endl;
+    gLog << "" << endl;
+
+
+    // read in the object with the name 'mtxName' from file 'NameHadrons'
+    //
+    TFile fileh(NameHadrons); 
+
+    matrixh.Read(mtxName);
+    matrixh.Print("SizeCols");
+  }
+
+
+   //*************************************************************************
+   // create matrices of training events
+   // and root files of training and test events
+ 
+if (CTrainRF)
+  {
+    gLog << "" << endl;
+    gLog << "========================================================" << endl;
+    gLog << " Create matrices of training events and root files of training and test events" 
+         << endl;
+    gLog << " Gammas :" << endl;
+    gLog << "---------" << endl;
+
+    MParList  plistg;
+    MTaskList tlistg;
+
+    MReadMarsFile  readg("Events", filenameMC);
+    readg.DisableAutoScheme();
+
+    TString mgname("costhg");
+    MBinning bing("Binning"+mgname);
+    bing.SetEdges(10, 0., 1.0);
+
+    MH3 gref("cos(MMcEvt.fTelescopeTheta)");
+    gref.SetName(mgname);
+    MH::SetBinning(&gref.GetHist(), &bing);
+    //for (Int_t i=1; i<=gref.GetNbins(); i++)
+    //  gref.GetHist().SetBinContent(i, 1.0);
+
+    MFEventSelector2 selectorg(gref);
+    selectorg.SetNumMax(howManyGammasTrain+howManyGammasTest);
+    selectorg.SetName("selectGammasTrainTest");
+    selectorg.SetInverted();
+    //selectorg.SetUseOrigDistribution(kTRUE);
+
+    MContinue contg(&selectorg);
+    contg.SetName("ContGammas");
+
+    Double_t probg = ( (Double_t) howManyGammasTrain )
+                   / ( (Double_t)(howManyGammasTrain+howManyGammasTest) );
+    MFRandomSplit splitg(probg);
+
+    MFillH fillmatg("MatrixGammas");
+    fillmatg.SetFilter(&splitg);
+    fillmatg.SetName("fillGammas");
+
+    //-----------------------
+    // for writing the root files of training and test events
+    // for gammas
+    
+    MWriteRootFile writetraing(inNameGammasTrain, "RECREATE");
+    writetraing.SetName("WriteGammasTrain");
+    writetraing.SetFilter(&splitg);
+
+      writetraing.AddContainer("MRawRunHeader", "RunHeaders");
+      writetraing.AddContainer("MTime",         "Events");
+      writetraing.AddContainer("MMcEvt",        "Events");
+      writetraing.AddContainer("ThetaOrig",     "Events");
+      writetraing.AddContainer("MSrcPosCam",    "Events");
+      writetraing.AddContainer("MSigmabar",     "Events");
+      writetraing.AddContainer("MHillas",       "Events");
+      writetraing.AddContainer("MHillasExt",    "Events");
+      writetraing.AddContainer("MHillasSrc",    "Events");
+      writetraing.AddContainer("MNewImagePar",  "Events");
+
+    MContinue contgtrain(&splitg);
+    contgtrain.SetName("ContGammaTrain");
+
+    MWriteRootFile writetestg(inNameGammasTest, "RECREATE");
+    writetestg.SetName("WriteGammasTest");
+
+      writetestg.AddContainer("MRawRunHeader", "RunHeaders");
+      writetestg.AddContainer("MTime",         "Events");
+      writetestg.AddContainer("MMcEvt",        "Events");
+      writetestg.AddContainer("ThetaOrig",     "Events");
+      writetestg.AddContainer("MSrcPosCam",    "Events");
+      writetestg.AddContainer("MSigmabar",     "Events");
+      writetestg.AddContainer("MHillas",       "Events");
+      writetestg.AddContainer("MHillasExt",    "Events");
+      writetestg.AddContainer("MHillasSrc",    "Events");
+      writetestg.AddContainer("MNewImagePar",  "Events");
+
+    //-----------------------
+    
+    //*****************************   fill gammas   ***  
+    // entries in MParList
+    
+    plistg.AddToList(&tlistg);
+    InitBinnings(&plistg);
+
+    plistg.AddToList(&matrixg);
+
+    //*****************************
+    // entries in MTaskList
+    
+    tlistg.AddToList(&readg);
+    tlistg.AddToList(&contg);
+
+    tlistg.AddToList(&splitg);
+    tlistg.AddToList(&fillmatg);
+    tlistg.AddToList(&writetraing);
+    tlistg.AddToList(&contgtrain);
+
+    tlistg.AddToList(&writetestg);
+
+    //*****************************
+
+    MProgressBar matrixbar;
+    MEvtLoop evtloopg;
+    evtloopg.SetName("FillGammaMatrix");
+    evtloopg.SetParList(&plistg);
+    //evtloopg.ReadEnv(env, "", printEnv);
+    evtloopg.SetProgressBar(&matrixbar);
+
+    Int_t maxevents = -1;
+    if (!evtloopg.Eventloop(maxevents))
+        return;
+
+    tlistg.PrintStatistics(0, kTRUE);
+
+    matrixg.Print("SizeCols");
+    Int_t generatedgTrain = matrixg.GetM().GetNrows();
+    if ( fabs(generatedgTrain-howManyGammasTrain) > 
+                                    3.0*sqrt(howManyGammasTrain) )
+    {
+      gLog << "ONOFFAnalysis.C : no.of generated gamma training events (" 
+           << generatedgTrain << ") is incompatible with the no.of requested events (" 
+           << howManyGammasTrain << ")" << endl;   
+    }
+
+
+    Int_t generatedgTest = writetestg.GetNumExecutions();
+    if ( fabs(generatedgTest-howManyGammasTest) > 
+                                    3.0*sqrt(howManyGammasTest) )
+    {
+      gLog << "ONOFFAnalysis.C : no.of generated gamma test events (" 
+           << generatedgTest << ") is incompatible with the no.of requested events (" 
+           << howManyGammasTest << ")" << endl;   
+    }
+
+    //*****************************   fill hadrons   ***  
+    gLog << "---------------------------------------------------------------"
+         << endl;
+    gLog << " Hadrons :" << endl;
+    gLog << "----------" << endl;
+
+    MParList  plisth;
+    MTaskList tlisth;
+
+    MReadMarsFile  readh("Events", filenameHad);
+    readh.DisableAutoScheme();
+
+    TString mhname("costhh");
+    MBinning binh("Binning"+mhname);
+    binh.SetEdges(10, 0., 1.0);
+
+    //MH3 href("cos(MMcEvt.fTelescopeTheta)");
+    //href.SetName(mhname);
+    //MH::SetBinning(&href.GetHist(), &binh);
+    //for (Int_t i=1; i<=href.GetNbins(); i++)
+    //  href.GetHist().SetBinContent(i, 1.0);
+
+    //use the original distribution from the gammas
+    MH3 &href = *(selectorg.GetHistOrig());
+
+    MFEventSelector2 selectorh(href);
+    selectorh.SetNumMax(howManyHadronsTrain+howManyHadronsTest);
+    selectorh.SetName("selectHadronsTrainTest");
+    selectorh.SetInverted();
+
+    MContinue conth(&selectorh);
+    conth.SetName("ContHadrons");
+
+    Double_t probh = ( (Double_t) howManyHadronsTrain )
+                   / ( (Double_t)(howManyHadronsTrain+howManyHadronsTest) );
+    MFRandomSplit splith(probh);
+
+    MFillH fillmath("MatrixHadrons");
+    fillmath.SetFilter(&splith);
+    fillmath.SetName("fillHadrons");
+
+    //-----------------------
+    // for writing the root files of training and test events
+    // for hadrons
+    
+    MWriteRootFile writetrainh(inNameHadronsTrain, "RECREATE");
+    writetrainh.SetName("WriteHadronsTrain");
+    writetrainh.SetFilter(&splith);
+
+      writetrainh.AddContainer("MRawRunHeader", "RunHeaders");
+      writetrainh.AddContainer("MTime",         "Events");
+      writetrainh.AddContainer("MMcEvt",        "Events");
+      writetrainh.AddContainer("ThetaOrig",     "Events");
+      writetrainh.AddContainer("MSrcPosCam",    "Events");
+      writetrainh.AddContainer("MSigmabar",     "Events");
+      writetrainh.AddContainer("MHillas",       "Events");
+      writetrainh.AddContainer("MHillasExt",    "Events");
+      writetrainh.AddContainer("MHillasSrc",    "Events");
+      writetrainh.AddContainer("MNewImagePar",  "Events");
+
+    MContinue conthtrain(&splith);
+
+    MWriteRootFile writetesth(inNameHadronsTest, "RECREATE");
+    writetesth.SetName("WriteHadronsTest");
+
+      writetesth.AddContainer("MRawRunHeader", "RunHeaders");
+      writetesth.AddContainer("MTime",         "Events");
+      writetesth.AddContainer("MMcEvt",        "Events");
+      writetesth.AddContainer("ThetaOrig",     "Events");
+      writetesth.AddContainer("MSrcPosCam",    "Events");
+      writetesth.AddContainer("MSigmabar",     "Events");
+      writetesth.AddContainer("MHillas",       "Events");
+      writetesth.AddContainer("MHillasExt",    "Events");
+      writetesth.AddContainer("MHillasSrc",    "Events");
+      writetesth.AddContainer("MNewImagePar",  "Events");
+
+
+    //*****************************  
+    // entries in MParList
+    
+    plisth.AddToList(&tlisth);
+    InitBinnings(&plisth);
+
+    plisth.AddToList(&matrixh);
+
+    //*****************************
+    // entries in MTaskList
+    
+    tlisth.AddToList(&readh);
+    tlisth.AddToList(&conth);
+
+    tlisth.AddToList(&splith);
+    tlisth.AddToList(&fillmath);
+    tlisth.AddToList(&writetrainh);
+    tlisth.AddToList(&conthtrain);
+
+    tlisth.AddToList(&writetesth);
+
+    //*****************************
+
+    MProgressBar matrixbar;
+    MEvtLoop evtlooph;
+    evtlooph.SetName("FillHadronMatrix");
+    evtlooph.SetParList(&plisth);
+    //evtlooph.ReadEnv(env, "", printEnv);
+    evtlooph.SetProgressBar(&matrixbar);
+
+    Int_t maxevents = -1;
+    if (!evtlooph.Eventloop(maxevents))
+        return;
+
+    tlisth.PrintStatistics(0, kTRUE);
+
+    matrixh.Print("SizeCols");
+    Int_t generatedhTrain = matrixh.GetM().GetNrows();
+    if ( fabs(generatedhTrain-howManyHadronsTrain) > 
+                                    3.0*sqrt(howManyHadronsTrain) )
+    {
+      gLog << "ONOFFAnalysis.C : no.of generated hadron training events (" 
+           << generatedhTrain << ") is incompatible with the no.of requested events (" 
+           << howManyHadronsTrain << ")" << endl;   
+    }
+
+
+    Int_t generatedhTest = writetesth.GetNumExecutions();
+    if ( fabs(generatedhTest-howManyHadronsTest) > 
+                                    3.0*sqrt(howManyHadronsTest) )
+    {
+      gLog << "ONOFFAnalysis.C : no.of generated gamma test events (" 
+           << generatedhTest << ") is incompatible with the no.of requested events (" 
+           << howManyHadronsTest << ")" << endl;   
+    }
+
+
+    //*****************************************************  
+
+
+    // write out matrices of training events 
+
+    gLog << "" << endl;
+    gLog << "========================================================" << endl;
+    gLog << "Write out matrices of training events" << endl;
+
+
+      //-------------------------------------------
+      // "gammas"
+      gLog << "Gammas :" << endl;    
+      matrixg.Print("SizeCols");
+
+      TFile writeg(NameGammas, "RECREATE", "");
+      matrixg.Write();
+
+      gLog << "" << endl;
+      gLog << "Macro ONOFFAnalysis : matrix of training events for gammas written onto file "
+           << NameGammas << endl;
+
+      //-------------------------------------------
+      // "hadrons"
+      gLog << "Hadrons :" << endl;    
+      matrixh.Print("SizeCols");
+
+      TFile writeh(NameHadrons, "RECREATE", "");
+      matrixh.Write();
+
+      gLog << "" << endl;
+      gLog << "Macro ONOFFAnalysis : matrix of training events for hadrons written onto file "
+           << NameHadrons << endl;
+
+  }
+   //**********   end of creating matrices of training events   ***********
+
+
+    MRanForest *fRanForest;
+    MRanTree *fRanTree;
+    //-----------------------------------------------------------------
+    // read in the trees of the random forest 
+    if (RTree)
+    {
+      MParList plisttr;
+      MTaskList tlisttr;
+      plisttr.AddToList(&tlisttr);
+
+      MReadTree readtr("TREE", outRF);
+      readtr.DisableAutoScheme();
+
+      MRanForestFill rffill;
+      rffill.SetNumTrees(NumTrees);
+
+      // list of tasks for the loop over the trees
+
+      tlisttr.AddToList(&readtr);
+      tlisttr.AddToList(&rffill);
+
+      //-------------------
+      // Execute tree loop
+      //
+      MEvtLoop evtlooptr;
+      evtlooptr.SetName("ReadRFTrees");
+      evtlooptr.SetParList(&plisttr);
+      if (!evtlooptr.Eventloop())
+        return;
+
+      tlisttr.PrintStatistics(0, kTRUE);
+
+      gLog << "ONOFFAnalysis : RF trees were read in from file "
+           << outRF << endl;
+
+    // get adresses of objects which are used in the next eventloop
+    fRanForest = (MRanForest*)plisttr->FindObject("MRanForest");
+    if (!fRanForest)
+    {
+        gLog << err << dbginf << "MRanForest not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fRanTree = (MRanTree*)plisttr->FindObject("MRanTree");
+    if (!fRanTree)                                  
+    {                                                                          
+        gLog << err << dbginf << "MRanTree not found... aborting." << endl;    
+        return kFALSE;
+    }
+
+    }
+
+    //-----------------------------------------------------------------
+    // grow the trees of the random forest (event loop = tree loop)
+
+    if (!RTree)
+    {
+
+    gLog << "" << endl;
+    gLog << "========================================================" << endl;
+    gLog << "Macro ONOFFAnalysis : start growing trees" << endl;
+
+    MTaskList tlist2;
+    MParList plist2;
+    plist2.AddToList(&tlist2);
+
+    plist2.AddToList(&matrixg);
+    plist2.AddToList(&matrixh);
+
+    MRanForestGrow rfgrow2;
+    rfgrow2.SetNumTrees(NumTrees);
+    rfgrow2.SetNumTry(NumTry);
+    rfgrow2.SetNdSize(NdSize);
+
+    MWriteRootFile rfwrite2(outRF);
+    rfwrite2.AddContainer("MRanTree", "TREE");
+
+    MFillH fillh2("MHRanForestGini");
+
+    // list of tasks for the loop over the trees
+    
+    tlist2.AddToList(&rfgrow2);
+    tlist2.AddToList(&rfwrite2);
+    tlist2.AddToList(&fillh2);
+
+    //-------------------
+    // Execute tree loop
+    //
+    MEvtLoop treeloop;
+    treeloop.SetName("GrowRFTrees");
+    treeloop.SetParList(&plist2);
+
+    if ( !treeloop.Eventloop() )
+        return;
+
+    tlist2.PrintStatistics(0, kTRUE);
+
+    plist2.FindObject("MHRanForestGini")->DrawClone();
+
+
+    // get adresses of objects which are used in the next eventloop
+    fRanForest = (MRanForest*)plist2->FindObject("MRanForest");
+    if (!fRanForest)
+    {
+        gLog << err << dbginf << "MRanForest not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fRanTree = (MRanTree*)plist2->FindObject("MRanTree");
+    if (!fRanTree)                                  
+    {                                                                          
+        gLog << err << dbginf << "MRanTree not found... aborting." << endl;    
+        return kFALSE;
+    }
+
+    }
+    // end of growing the trees of the random forest
+    //-----------------------------------------------------------------
+
+
+    //-----------------------------------------------------------------
+    // Update the root files with the RF hadronness
+    //
+
+ if (WRF)
+  {
+    //TString fileName(inNameHadronsTrain);
+    //TString outName(outNameHadronsTrain);
+
+    //TString fileName(inNameHadronsTest);
+    //TString outName(outNameHadronsTest);
+
+    //TString fileName(inNameGammasTrain);
+    //TString outName(outNameGammasTrain);
+
+    //TString fileName(inNameGammasTest);
+    //TString outName(outNameGammasTest);
+
+    TString fileName(inNameData);
+    TString outName(outNameData);
+
+
+
+    gLog << "" << endl;
+    gLog << "========================================================" << endl;
+    gLog << "Update root file '" <<  fileName 
+         << "' with the RF hadronness; ==> " << outName << endl;
+
+   
+    MTaskList tliston;
+    MParList pliston;
+
+
+    // geometry is needed in  MHHillas... classes 
+    MGeomCam *fGeom = 
+             (MGeomCam*)pliston->FindCreateObj("MGeomCamMagic", "MGeomCam");
+
+    //-------------------------------------------
+    // create the tasks which should be executed 
+    //
+
+    MReadMarsFile read("Events", fileName);
+    read.DisableAutoScheme();
+
+
+    //.......................................................................
+    // calculate hadronnes for method of RANDOM FOREST
+
+
+    MRanForestCalc rfcalc;
+    rfcalc.SetHadronnessName(hadRFName);
+
+
+    //.......................................................................
+
+      //MWriteRootFile write(outName, "UPDATE");
+      MWriteRootFile write(outName, "RECREATE");
+
+      write.AddContainer("MRawRunHeader", "RunHeaders");
+      write.AddContainer("MTime",         "Events");
+      write.AddContainer("MMcEvt",        "Events");
+      write.AddContainer("ThetaOrig",     "Events");
+      write.AddContainer("MSrcPosCam",    "Events");
+      write.AddContainer("MSigmabar",     "Events");
+      write.AddContainer("MHillas",       "Events");
+      write.AddContainer("MHillasExt",    "Events");
+      write.AddContainer("MHillasSrc",    "Events");
+      write.AddContainer("MNewImagePar",  "Events");
+
+      write.AddContainer(hadRFName,       "Events");
+
+    //-----------------------------------------------------------------
+
+
+    MFSelFinal selfinalgh(fHilNameSrc);
+    selfinalgh.SetCuts(maxhadronness, 100.0, maxdist);
+    selfinalgh.SetHadronnessName(hadRFName);
+    selfinalgh.SetName("SelFinalgh");
+    MContinue contfinalgh(&selfinalgh);
+    contfinalgh.SetName("ContSelFinalgh");
+
+    MFillH fillranfor("MHRanForest");
+    fillranfor.SetName("HRanForest");
+
+    MFillH fillhadrf("hadRF[MHHadronness]", hadRFName);
+    fillhadrf.SetName("HhadRF");
+
+    MFSelFinal selfinal(fHilNameSrc);
+    selfinal.SetCuts(maxhadronness, maxalpha, maxdist);
+    selfinal.SetHadronnessName(hadRFName);
+    selfinal.SetName("SelFinal");
+    MContinue contfinal(&selfinal);
+    contfinal.SetName("ContSelFinal");
+
+    TString mh3name = "abs(Alpha)";
+    MBinning binsalphaabs("Binning"+mh3name);
+    binsalphaabs.SetEdges(50, -2.0, 98.0);
+
+    MH3 alphaabs("abs(MHillasSrc.fAlpha)");
+    alphaabs.SetName(mh3name);
+    MFillH alpha(&alphaabs);
+    alpha.SetName("FillAlphaAbs");
+
+
+    MFillH hfill1("MHHillas",    fHilName);
+    hfill1.SetName("HHillas");
+
+    MFillH hfill2("MHStarMap",   fHilName);
+    hfill2.SetName("HStarMap");
+
+    MFillH hfill3("MHHillasExt",    fHilNameSrc);
+    hfill3.SetName("HHillasExt");
+    
+    MFillH hfill4("MHHillasSrc",   fHilNameSrc);
+    hfill4.SetName("HHillasSrc");    
+
+    MFillH hfill5("MHNewImagePar", fImgParName);
+    hfill5.SetName("HNewImagePar");
+
+    //*****************************
+    // entries in MParList
+
+    pliston.AddToList(&tliston);
+    InitBinnings(&pliston);
+
+    pliston.AddToList(fRanForest);
+    pliston.AddToList(fRanTree);
+
+    pliston.AddToList(&binsalphaabs);
+    pliston.AddToList(&alphaabs);
+
+
+    //*****************************
+    // entries in MTaskList
+    
+    tliston.AddToList(&read);
+
+    tliston.AddToList(&rfcalc);
+    tliston.AddToList(&fillranfor);
+    tliston.AddToList(&fillhadrf);
+
+    tliston.AddToList(&write);
+    tliston.AddToList(&contfinalgh);
+
+    tliston.AddToList(&alpha);
+    tliston.AddToList(&hfill1);
+    tliston.AddToList(&hfill2);
+    tliston.AddToList(&hfill3);
+    tliston.AddToList(&hfill4);
+    tliston.AddToList(&hfill5);
+
+    tliston.AddToList(&contfinal);
+
+    //*****************************
+
+    //-------------------------------------------
+    // Execute event loop
+    //
+    MProgressBar bar;
+    MEvtLoop evtloop;
+    evtloop.SetName("UpdateRootFile");
+    evtloop.SetParList(&pliston);
+    evtloop.SetProgressBar(&bar);
+
+    Int_t maxevents = -1;
+    if ( !evtloop.Eventloop(maxevents) )
+        return;
+
+    tliston.PrintStatistics(0, kTRUE);
+
+
+    //-------------------------------------------
+    // Display the histograms
+    //
+    pliston.FindObject("MHRanForest")->DrawClone();
+    pliston.FindObject("hadRF", "MHHadronness")->DrawClone();
+    pliston.FindObject("hadRF", "MHHadronness")->Print();
+
+    pliston.FindObject("MHHillas")->DrawClone();
+    pliston.FindObject("MHHillasExt")->DrawClone();
+    pliston.FindObject("MHHillasSrc")->DrawClone();
+    pliston.FindObject("MHNewImagePar")->DrawClone();
+    pliston.FindObject("MHStarMap")->DrawClone();
+
+
+     //-------------------------------------------
+    // fit alpha distribution to get the number of excess events and
+    // calculate significance of gamma signal in the alpha plot
+  
+    MH3* absalpha = (MH3*)(pliston.FindObject(mh3name, "MH3"));
+    TH1  &alphaHist = absalpha->GetHist();
+    alphaHist.SetXTitle("|alpha|  [\\circ]");
+    alphaHist.SetName("alpha-macro");
+
+    Double_t alphasig = 13.1;
+    Double_t alphamin = 30.0;
+    Double_t alphamax = 90.0;
+    Int_t    degree   =    2;
+    Double_t significance = -99.0;
+    Bool_t   drawpoly  = kTRUE;
+    Bool_t   fitgauss  = kTRUE;
+    Bool_t   print     = kTRUE;
+
+    MHFindSignificance findsig;
+    findsig.SetRebin(kTRUE);
+    findsig.SetReduceDegree(kFALSE);
+
+    findsig.FindSigma(&alphaHist, alphamin, alphamax, degree, 
+                        alphasig, drawpoly, fitgauss, print);
+    significance = findsig.GetSignificance();
+    Float_t alphasi = findsig.GetAlphasi();
+
+    gLog << "For file '" << fileName << "' : " << endl;
+    gLog << "Significance of gamma signal after supercuts : "
+         << significance << " (for |alpha| < " << alphasi << " degrees)" 
+         << endl;
+
+    findsig.SigmaVsAlpha(&alphaHist, alphamin, alphamax, degree, print);
+
+    //-------------------------------------------
+
+
+    DeleteBinnings(&pliston);
+  }
+
+    gLog << "Macro ONOFFAnalysis : End of Job B_RF_UP" << endl;
+    gLog << "=======================================================" << endl;
+ }
+  //---------------------------------------------------------------------
+
+
+  //---------------------------------------------------------------------
+  // Job B_SC_UP
+  //============
+
+    //  - create (or read in) optimum supercuts parameter values
+    //
+    //  - calculate the hadroness for the supercuts
+    //
+    //  - update input root file, including the hadroness
+
+
+ if (JobB_SC_UP)
+ {
+    gLog << "=====================================================" << endl;
+    gLog << "Macro ONOFFAnalysis : Start of Job B_SC_UP" << endl;
+
+    gLog << "" << endl;
+    gLog << "Macro ONOFFAnalysis : JobB_SC_UP, CMatrix, RMatrix, WOptimize, RTest, WSC = "
+         << (JobB_SC_UP ? "kTRUE" : "kFALSE")  << ",  " 
+         << (CMatrix    ? "kTRUE" : "kFALSE")  << ",  "
+         << (RMatrix    ? "kTRUE" : "kFALSE")  << ",  "
+         << (WOptimize  ? "kTRUE" : "kFALSE")  << ",  "
+         << (RTest      ? "kTRUE" : "kFALSE")  << ",  "
+         << (WSC        ? "kTRUE" : "kFALSE")  << endl;
+
+
+    //--------------------------------------------
+    // file which contains the initial parameter values for the supercuts 
+    // if parSCinit ="" the initial values are taken from the constructor of
+    //                  MSupercuts
+
+    TString parSCinit = outPath;
+    //parSCinit += "parSC_060204";
+    //parSCinit = "parSC_240204a";
+    parSCinit = "";
+
+    if (parSCinit != "")
+    {
+      gLog << "Initial values of parameters are taken from file '" 
+           << parSCinit << "'" << endl;
+    }
+    else
+    {
+      gLog << "Initial values of parameters are taken from the constructor of MSupercuts" 
+           << endl;
+    }
+
+
+    //---------------
+    // file onto which the optimal parameter values for the supercuts 
+    // are written
+
+    TString parSCfile = outPath;
+    parSCfile += "parSC_050304a";
+
+    gLog << "parSCfile = " << parSCfile << endl;
+
+    //--------------------------------------------
+    // file to be updated (either ON or MC)
+
+    TString typeInput = "ON";
+    //TString typeInput = "OFF";
+    //TString typeInput = "MC";
+    gLog << "typeInput = " << typeInput << endl;
+
+    if (typeInput == "ON")
+      TString file(onfile);
+    else if (typeInput == "OFF")
+      TString file(offfile);
+    else if (typeInput == "MC")
+      TString file(mcfile);
+
+    // name of input root file
+    TString filenameData = outPath;
+    filenameData += file;
+    filenameData += "Hillas";
+    filenameData += typeInput;
+    filenameData += "1c.root";
+    gLog << "filenameData = " << filenameData << endl; 
+
+    // name of output root file
+    TString outNameImage = outPath;
+    outNameImage += file;
+    outNameImage += "Hillas";
+    outNameImage += typeInput;
+    outNameImage += "2c.root";
+    
+
+    //TString outNameImage = filenameData;
+
+    gLog << "outNameImage = " << outNameImage << endl; 
+
+    //--------------------------------------------
+    // files to be read for optimizing the supercuts
+    // 
+    // for the training
+    TString filenameTrain = outPath;
+    filenameTrain += onfile;
+    filenameTrain += "Hillas";
+    filenameTrain += typeInput;
+    filenameTrain += "1.root";
+    Int_t howManyTrain = 20000;
+    gLog << "filenameTrain = " << filenameTrain << ",   howManyTrain = "
+         << howManyTrain  << endl; 
+
+    // for testing
+    TString filenameTest = outPath;
+    filenameTest += onfile;
+    filenameTest += "Hillas";
+    filenameTest += typeInput;
+    filenameTest += "1.root";
+    Int_t howManyTest = 20000;
+
+    gLog << "filenameTest = " << filenameTest << ",   howManyTest = "
+         << howManyTest  << endl; 
+    
+
+    //--------------------------------------------
+    // files to contain the matrices (generated from filenameTrain and
+    //                                               filenameTest)
+    // 
+    // for the training
+    TString fileMatrixTrain = outPath;
+    fileMatrixTrain += "MatrixTrainSC";
+    fileMatrixTrain += ".root";
+    gLog << "fileMatrixTrain = " << fileMatrixTrain << endl; 
+
+    // for testing
+    TString fileMatrixTest = outPath;
+    fileMatrixTest += "MatrixTestSC";
+    fileMatrixTest += ".root";
+    gLog << "fileMatrixTest = " << fileMatrixTest << endl; 
+
+    
+
+    //---------------------------------------------------------------------
+    // Training and test matrices :
+    // - either create them and write them onto a file
+    // - or read them from a file
+
+
+    MFindSupercuts findsuper;
+    findsuper.SetFilenameParam(parSCfile);
+    findsuper.SetHadronnessName("HadSC");
+    //findsuper.SetUseOrigDistribution(kTRUE);
+
+    //--------------------------
+    // create matrices and write them onto files 
+    if (CMatrix)
+    {
+      TString mname("costheta");
+      MBinning bin("Binning"+mname);
+      bin.SetEdges(10, 0., 1.0);
+
+      MH3 mh3("cos(MMcEvt.fTelescopeTheta)");
+      mh3.SetName(mname);
+      MH::SetBinning(&mh3.GetHist(), &bin);
+      //for (Int_t i=1; i<=mh3.GetNbins(); i++)
+      //  mh3.GetHist().SetBinContent(i, 1.0);
+
+
+      if (filenameTrain == filenameTest)
+      {
+        if ( !findsuper.DefineTrainTestMatrix(
+                              filenameTrain,   mh3, 
+                              howManyTrain,    howManyTest,  
+                              fileMatrixTrain, fileMatrixTest)     )
+        {
+          *fLog << "MagicAnalysis.C : DefineTrainTestMatrix failed" << endl;
+          return;
+        }
+
+      }
+      else
+      {
+        if ( !findsuper.DefineTrainMatrix(filenameTrain, mh3,
+                                          howManyTrain,  fileMatrixTrain) )
+        {
+          *fLog << "MagicAnalysis.C : DefineTrainMatrix failed" << endl;
+          return;
+        }
+
+	if ( !findsuper.DefineTestMatrix( filenameTest, mh3, 
+                                          howManyTest,  fileMatrixTest)  )
+        {
+          *fLog << "MagicAnalysis.C : DefineTestMatrix failed" << endl;
+          return;
+        }
+      }
+     }
+
+    //--------------------------
+    // read matrices from files
+    //                              
+
+    if (RMatrix)
+      findsuper.ReadMatrix(fileMatrixTrain, fileMatrixTest);
+    //--------------------------
+
+
+
+    //---------------------------------------------------------------------
+    // optimize supercuts using the training sample
+    // 
+    // the initial values are taken 
+    //     - from the file parSCinit (if != "")
+    //     - or from the arrays params and steps (if their sizes are != 0)
+    //     - or from the MSupercuts constructor
+
+
+if (WOptimize)
+  {
+    gLog << "MagicAnalysis.C : optimize the supercuts using the training matrix" 
+         << endl;
+
+    TArrayD params(0);
+    TArrayD steps(0);
+  
+
+    if (parSCinit == "")
+    {
+      /*
+      Double_t vparams[104] = {
+      // LengthUp
+	0.2,       0.,       0.,       0.,        0.,        0.0,
+	0.,        0.,
+      // LengthLo
+        0.,        0.,       0.,       0.,        0.,        0.0,
+	0.,        0.,
+      // WidthUp
+        0.1,       0.,       0.,       0.,        0.,        0.0,
+	0.,        0.,
+      // WidthLo
+        0.,        0.,       0.,       0.,        0.,        0.0,
+	0.,        0.,
+      // DistUp
+        0.,        0.,       0.,       0.,        0.,        0.0,
+	0.,        0.,
+      // DistLo
+        0.,        0.,       0.,       0.,        0.,        0.0,
+	0.,        0.,
+      // AsymUp
+        1.e10,     0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // AsymLo
+       -1.e10,     0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // ConcUp
+        1.e10,     0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // ConcLo
+       -1.e10,     0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // Leakage1Up
+        1.e10,     0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // Leakage1Lo
+       -1.e10,     0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // AlphaUp
+	13.12344,  0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0                                                 };
+
+      Double_t vsteps[104] = {
+      // LengthUp
+	0.02,      0.,       0.,       0.,        0.,        0.0,
+	0.,        0.,
+      // LengthLo
+        0.,        0.,       0.,       0.,        0.,        0.0,
+	0.,        0.,
+      // WidthUp
+        0.01,      0.,       0.,       0.,        0.,        0.0,
+	0.,        0.,
+      // WidthLo
+        0.,        0.,       0.,       0.,        0.,        0.0,
+	0.,        0.,
+      // DistUp
+        0.,        0.,       0.,       0.,        0.,        0.0,
+	0.,        0.,
+      // DistLo
+        0.,        0.,       0.,       0.,        0.,        0.0,
+	0.,        0.,
+      // AsymUp
+        0.0,       0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // AsymLo
+        0.0,       0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // ConcUp
+        0.0,       0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // ConcLo
+        0.0,       0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // Leakage1Up
+        0.0,       0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // Leakage1Lo
+        0.0,       0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // AlphaUp
+	0.0,       0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0                                                 };
+      */
+
+
+      Double_t vparams[104] = {
+      // LengthUp
+	0.315585,  0.001455, 0.203198, 0.005532, -0.001670, -0.020362,
+	0.007388, -0.013463,
+      // LengthLo
+        0.151530,  0.028323, 0.510707, 0.053089,  0.013708,  2.357993,
+	0.000080, -0.007157,
+      // WidthUp
+        0.145412, -0.001771, 0.054462, 0.022280, -0.009893,  0.056353,
+        0.020711, -0.016703,
+      // WidthLo
+        0.089187, -0.006430, 0.074442, 0.003738, -0.004256, -0.014101,
+        0.006126, -0.002849,
+      // DistUp
+        1.787943,  0.0,      2.942310, 0.199815,  0.0,       0.249909,
+        0.189697,  0.0,
+      // DistLo
+        0.589406,  0.0,     -0.083964,-0.007975,  0.0,       0.045374,
+       -0.001750,  0.0,
+      // AsymUp
+        1.e10,     0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // AsymLo
+       -1.e10,     0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // ConcUp
+        1.e10,     0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // ConcLo
+       -1.e10,     0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // Leakage1Up
+        1.e10,     0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // Leakage1Lo
+       -1.e10,     0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // AlphaUp
+	13.12344,  0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0                                                 };
+
+      Double_t vsteps[104] = {
+      // LengthUp
+        0.03,      0.0002,   0.02,     0.0006,    0.0002,    0.002,
+        0.0008,    0.002,
+      // LengthLo
+        0.02,      0.003,    0.05,     0.006,     0.002,     0.3,
+        0.0001,    0.0008,
+      // WidthUp
+        0.02,      0.0002,   0.006,    0.003,     0.002,     0.006,
+        0.002,     0.002,
+      // WidthLo
+        0.009,     0.0007,   0.008,    0.0004,    0.0005,    0.002,
+        0.0007,    0.003,
+      // DistUp
+        0.2,       0.0,      0.3,      0.02,      0.0,       0.03,
+        0.02,      0.0
+      // DistLo
+        0.06,      0.0,      0.009,    0.0008,    0.0,       0.005,
+        0.0002,    0.0
+      // AsymUp  
+        0.0,       0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // AsymLo  
+        0.0,       0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // ConcUp  
+        0.0,       0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // ConcLo  
+        0.0,       0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // Leakage1Up  
+        0.0,       0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // Leakage1Lo  
+        0.0,       0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // AlphaUp  
+        0.0,       0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0                                                 };
+
+ 
+      params.Set(104, vparams);
+      steps.Set (104, vsteps );
+    }
+
+    Bool_t rf;
+    rf = findsuper.FindParams(parSCinit, params, steps);
+
+    if (!rf) 
+    {
+       gLog << "MagicAnalysis.C : optimization of supercuts failed" << endl;
+       return;
+    }
+  }
+
+    //--------------------------------------
+    // test the supercuts on the test sample
+    //    
+
+ if (RTest)
+ {
+    gLog << "MagicAnalysis.C : test the supercuts on the test matrix" << endl;
+    Bool_t rt = findsuper.TestParams();
+    if (!rt) 
+    {
+       gLog << "MagicAnalysis.C : test of supercuts on the test matrix failed" 
+            << endl;
+    }
+
+ }
+
+
+    //-----------------------------------------------------------------
+    // Update the input files with the SC hadronness
+    //
+
+ if (WSC)
+ {
+    gLog << "" << endl;
+    gLog << "========================================================" << endl;
+    gLog << "Update input file '" <<  filenameData 
+         << "' with the SC hadronness" << endl;
+
+
+    //----------------------------------------------------
+    // read in optimum parameter values for the supercuts
+
+    TFile inparam(parSCfile);
+    MSupercuts scin;
+    scin.Read("MSupercuts");
+    inparam.Close();
+
+    gLog << "Parameter values for supercuts were read in from file '"
+         << parSCfile << "'" << endl;
+
+    TArrayD supercutsPar;
+    supercutsPar =  scin.GetParameters();
+
+    TArrayD supercutsStep;
+    supercutsStep =  scin.GetStepsizes();
+
+    gLog << "Parameter values for supercuts : " << endl;
+    for (Int_t i=0; i<supercutsPar.GetSize(); i++)
+    {
+      gLog << supercutsPar[i] << ",  ";
+    }
+    gLog << endl;
+
+    gLog << "Step values for supercuts : " << endl;
+    for (Int_t i=0; i<supercutsStep.GetSize(); i++)
+    {
+      gLog << supercutsStep[i] << ",  ";
+    }
+    gLog << endl;
+
+
+    //----------------------------------------------------
+    MTaskList tliston;
+    MParList pliston;
+
+    // set the parameters of the supercuts
+    MSupercuts supercuts;
+    supercuts.SetParameters(supercutsPar);
+    gLog << "parameter values for the supercuts used for updating the input file ' " 
+         << filenameData << "'" << endl;
+    supercutsPar = supercuts.GetParameters();
+    for (Int_t i=0; i<supercutsPar.GetSize(); i++)
+    {
+      gLog << supercutsPar[i] << ",  ";
+    }
+    gLog << endl;
+
+
+    // geometry is needed in  MHHillas... classes 
+    MGeomCam *fGeom = 
+             (MGeomCam*)pliston->FindCreateObj("MGeomCamMagic", "MGeomCam");
+
+    //-------------------------------------------
+    // create the tasks which should be executed 
+    //
+
+    MReadMarsFile read("Events", filenameData);
+    read.DisableAutoScheme();
+
+    TString fHilName    = "MHillas"; 
+    TString fHilNameExt = "MHillasExt"; 
+    TString fHilNameSrc = "MHillasSrc"; 
+    TString fImgParName = "MNewImagePar"; 
+
+
+    //.......................................................................
+    // calculation of hadroness for the supercuts
+    // (=0.25 if fullfilled, =0.75 otherwise)
+
+    TString hadSCName = "HadSC";
+    MSupercutsCalc sccalc(fHilName, fHilNameSrc);
+    sccalc.SetHadronnessName(hadSCName);
+
+
+    //.......................................................................
+
+
+      //MWriteRootFile write(outNameImage, "UPDATE");
+      //MWriteRootFile write = new MWriteRootFile(outNameImage, "RECREATE");
+
+    
+      MWriteRootFile write(outNameImage, "RECREATE");
+
+      write.AddContainer("MRawRunHeader", "RunHeaders");
+      //write.AddContainer("MTime",         "Events");
+      write.AddContainer("MMcEvt",        "Events");
+      //write.AddContainer("ThetaOrig",     "Events");
+      write.AddContainer("MSrcPosCam",    "Events");
+      write.AddContainer("MSigmabar",     "Events");
+      write.AddContainer("MHillas",       "Events");
+      write.AddContainer("MHillasExt",    "Events");
+      write.AddContainer("MHillasSrc",    "Events");
+      write.AddContainer("MNewImagePar",  "Events");
+
+      //write.AddContainer("HadRF",         "Events");
+      write.AddContainer(hadSCName,       "Events");
+    
+
+    //-----------------------------------------------------------------
+    // geometry is needed in  MHHillas... classes 
+    MGeomCam *fGeom = 
+             (MGeomCam*)pliston->FindCreateObj("MGeomCamMagic", "MGeomCam");
+
+    Float_t maxhadronness =  0.40;
+    Float_t maxalpha      =  20.0;
+    Float_t maxdist       =  10.0;
+
+    MFSelFinal selfinalgh(fHilNameSrc);
+    selfinalgh.SetCuts(maxhadronness, 100.0, maxdist);
+    selfinalgh.SetHadronnessName(hadSCName);
+    selfinalgh.SetName("SelFinalgh");
+    MContinue contfinalgh(&selfinalgh);
+    contfinalgh.SetName("ContSelFinalgh");
+
+    MFillH fillhadsc("hadSC[MHHadronness]", hadSCName);
+    fillhadsc.SetName("HhadSC");
+
+    MFSelFinal selfinal(fHilNameSrc);
+    selfinal.SetCuts(maxhadronness, maxalpha, maxdist);
+    selfinal.SetHadronnessName(hadSCName);
+    selfinal.SetName("SelFinal");
+    MContinue contfinal(&selfinal);
+    contfinal.SetName("ContSelFinal");
+
+    TString mh3name = "abs(Alpha)";
+    MBinning binsalphaabs("Binning"+mh3name);
+    binsalphaabs.SetEdges(50, -2.0, 98.0);
+
+    MH3 alphaabs("abs(MHillasSrc.fAlpha)");
+    alphaabs.SetName(mh3name);
+
+    TH1  &alphahist = alphaabs->GetHist();
+
+    MFillH alpha(&alphaabs);
+    alpha.SetName("FillAlphaAbs");
+
+    MFillH hfill1("MHHillas",    fHilName);
+    hfill1.SetName("HHillas");
+
+    MFillH hfill2("MHStarMap",   fHilName);
+    hfill2.SetName("HStarMap");
+
+    MFillH hfill3("MHHillasExt",    fHilNameSrc);
+    hfill3.SetName("HHillasExt");
+    
+    MFillH hfill4("MHHillasSrc",   fHilNameSrc);
+    hfill4.SetName("HHillasSrc");    
+
+    MFillH hfill5("MHNewImagePar", fImgParName);
+    hfill5.SetName("HNewImagePar");
+
+    //*****************************
+    // entries in MParList
+
+    pliston.AddToList(&tliston);
+    InitBinnings(&pliston);
+
+    pliston.AddToList(&supercuts);
+
+    pliston.AddToList(&binsalphaabs);
+    pliston.AddToList(&alphaabs);
+
+    //*****************************
+    // entries in MTaskList
+    
+    tliston.AddToList(&read);
+
+    tliston.AddToList(&sccalc);
+    tliston.AddToList(&fillhadsc);
+
+    tliston.AddToList(&write);
+    tliston.AddToList(&contfinalgh);
+
+    tliston.AddToList(&alpha);
+    tliston.AddToList(&hfill1);
+    tliston.AddToList(&hfill2);
+    tliston.AddToList(&hfill3);
+    tliston.AddToList(&hfill4);
+    tliston.AddToList(&hfill5);
+
+    tliston.AddToList(&contfinal);
+
+    //*****************************
+
+    //-------------------------------------------
+    // Execute event loop
+    //
+    MProgressBar bar;
+    MEvtLoop evtloop;
+    evtloop.SetParList(&pliston);
+    evtloop.SetProgressBar(&bar);
+
+    Int_t maxevents = -1;
+    if ( !evtloop.Eventloop(maxevents) )
+        return;
+
+    tliston.PrintStatistics(0, kTRUE);
+
+
+    //-------------------------------------------
+    // Display the histograms
+    //
+    pliston.FindObject("hadSC", "MHHadronness")->DrawClone();
+
+    pliston.FindObject("MHHillas")->DrawClone();
+    pliston.FindObject("MHHillasExt")->DrawClone();
+    pliston.FindObject("MHHillasSrc")->DrawClone();
+    pliston.FindObject("MHNewImagePar")->DrawClone();
+    pliston.FindObject("MHStarMap")->DrawClone();
+
+     //-------------------------------------------
+    // fit alpha distribution to get the number of excess events and
+    // calculate significance of gamma signal in the alpha plot
+  
+    MH3* absalpha = (MH3*)(pliston.FindObject(mh3name, "MH3"));
+    TH1  &alphaHist = absalpha->GetHist();
+    alphaHist.SetXTitle("|alpha|  [\\circ]");
+    alphaHist.SetName("alpha-macro");
+
+    Double_t alphasig = 13.1;
+    Double_t alphamin = 30.0;
+    Double_t alphamax = 90.0;
+    Int_t    degree   =    2;
+    Double_t significance = -99.0;
+    Bool_t   drawpoly  = kTRUE;
+    Bool_t   fitgauss  = kTRUE;
+    Bool_t   print     = kTRUE;
+
+    MHFindSignificance findsig;
+    findsig.SetRebin(kTRUE);
+    findsig.SetReduceDegree(kFALSE);
+
+    findsig.FindSigma(&alphaHist, alphamin, alphamax, degree, 
+                        alphasig, drawpoly, fitgauss, print);
+    significance = findsig.GetSignificance();
+    Float_t alphasi = findsig.GetAlphasi();
+
+    gLog << "For file '" << filenameData << "' : " << endl;
+    gLog << "Significance of gamma signal after supercuts : "
+         << significance << " (for |alpha| < " << alphasi << " degrees)" 
+         << endl;
+
+    findsig.SigmaVsAlpha(&alphaHist, alphamin, alphamax, degree, print);
+
+    //-------------------------------------------
+
+    DeleteBinnings(&pliston);
+ }
+
+
+    gLog << "Macro ONOFFAnalysis : End of Job B_SC_UP" << endl;
+    gLog << "=======================================================" << endl;
+ }
+  //---------------------------------------------------------------------
+
+
+
+  //---------------------------------------------------------------------
+  // Job C  
+  //======
+
+    //  - read ON1 and MC1 data files  
+    //    which should have been updated to contain the hadronnesses
+    //    for the method of Random Forest and for the SUPERCUTS
+    //  - produce Neyman-Pearson plots
+ 
+ if (JobC)
+ {
+    gLog << "=====================================================" << endl;
+    gLog << "Macro ONOFFAnalysis : Start of Job C" << endl;
+
+    gLog << "" << endl;
+    gLog << "Macro ONOFFAnalysis : JobC = " 
+         << (JobC ? "kTRUE" : "kFALSE")  << endl;
+
+
+
+    TString ext("2.root");
+    TString extout("2.root");
+
+    TString typeHadrons("OFF");
+    TString typeGammas("MC");
+
+    //--------------------------------------------
+    // name of input data file
+    TString NameData = outPath;
+    NameData += typeHadrons;
+    TString inNameData(NameData);
+    inNameData += ext;
+    gLog << "inNameData   = " << inNameData   << endl;
+
+    // name of input MC file
+    TString NameMC = outPath;
+    NameMC += typeGammas;
+    TString inNameMC(NameMC);
+    inNameMC += ext;
+    gLog << "inNameMC   = " << inNameMC   << endl;
+
+
+    //--------------------------------------------
+    // root files for the training events 
+
+
+
+    TString NameGammasTrain = outPath;
+    NameGammasTrain += "RF_gammas_Train_";
+    NameGammasTrain += typeGammas;
+    TString outNameGammasTrain(NameGammasTrain);    
+    outNameGammasTrain += extout;
+
+
+    TString NameHadronsTrain = outPath;
+    NameHadronsTrain += "RF_hadrons_Train_";
+    NameHadronsTrain += typeHadrons;
+    TString outNameHadronsTrain(NameHadronsTrain);    
+    outNameHadronsTrain += extout;
+
+
+    //--------------------------------------------
+    // root files for the test events 
+
+    TString NameGammasTest = outPath;
+    NameGammasTest += "RF_gammas_Test_";
+    NameGammasTest += typeGammas;
+    TString outNameGammasTest(NameGammasTest);    
+    outNameGammasTest += extout;
+
+    TString NameHadronsTest = outPath;
+    NameHadronsTest += "RF_hadrons_Test_";
+    NameHadronsTest += typeHadrons;
+    TString outNameHadronsTest(NameHadronsTest);    
+    outNameHadronsTest += extout;
+
+    //--------------------------------------------------------------------
+
+    //TString filenameData(inNameData);
+    //TString filenameMC(inNameMC);
+
+    //TString filenameData(outNameHadronsTrain);
+    //TString filenameMC(outNameGammasTrain);
+
+    TString filenameData(outNameHadronsTest);
+    TString filenameMC(outNameGammasTest);
+
+    gLog << "filenameData = " << filenameData << endl;
+    gLog << "filenameMC   = " << filenameMC   << endl;
+
+    //-----------------------------------------------------------------
+
+    MTaskList tliston;
+    MParList pliston;
+
+
+    // geometry is needed in  MHHillas... classes 
+    MGeomCam *fGeom = 
+             (MGeomCam*)pliston->FindCreateObj("MGeomCamMagic", "MGeomCam");
+
+    //-------------------------------------------
+    // create the tasks which should be executed 
+    //
+
+    MReadMarsFile read("Events", filenameMC);
+    read.AddFile(filenameData);
+    read.DisableAutoScheme();
+
+
+    //.......................................................................
+    // names of hadronness containers
+
+    TString hadSCName = "HadSC";
+    TString hadRFName = "HadRF";
+
+    //.......................................................................
+
+
+    TString fHilName    = "MHillas"; 
+    TString fHilNameExt = "MHillasExt"; 
+    TString fHilNameSrc = "MHillasSrc"; 
+    TString fImgParName = "MNewImagePar"; 
+
+    Float_t maxhadronness =  0.40;
+    Float_t maxalpha      =  20.0;
+    Float_t maxdist       =  10.0;
+
+    MFSelFinal selfinalgh(fHilNameSrc);
+    selfinalgh.SetCuts(maxhadronness, 100.0, maxdist);
+    selfinalgh.SetHadronnessName(hadRFName);
+    selfinalgh.SetName("SelFinalgh");
+    MContinue contfinalgh(&selfinalgh);
+    contfinalgh.SetName("ContSelFinalgh");
+
+
+    //MFillH fillhadsc("hadSC[MHHadronness]", hadSCName);
+    //fillhadsc.SetName("HhadSC");
+    MFillH fillhadrf("hadRF[MHHadronness]", hadRFName);
+    fillhadrf.SetName("HhadRF");
+
+    MFSelFinal selfinal(fHilNameSrc);
+    selfinal.SetCuts(maxhadronness, maxalpha, maxdist);
+    selfinal.SetHadronnessName(hadRFName);
+    selfinal.SetName("SelFinal");
+    MContinue contfinal(&selfinal);
+    contfinal.SetName("ContSelFinal");
+
+
+    MFillH hfill1("MHHillas",    fHilName);
+    hfill1.SetName("HHillas");
+
+    MFillH hfill2("MHStarMap",   fHilName);
+    hfill2.SetName("HStarMap");
+
+    MFillH hfill3("MHHillasExt",    fHilNameSrc);
+    hfill3.SetName("HHillasExt");
+    
+    MFillH hfill4("MHHillasSrc",   fHilNameSrc);
+    hfill4.SetName("HHillasSrc");    
+
+    MFillH hfill5("MHNewImagePar", fImgParName);
+    hfill5.SetName("HNewImagePar");
+
+
+    //*****************************
+    // entries in MParList
+
+    pliston.AddToList(&tliston);
+    InitBinnings(&pliston);
+
+
+    //*****************************
+    // entries in MTaskList
+    
+    tliston.AddToList(&read);
+
+    //tliston.AddToList(&fillhadsc);
+    tliston.AddToList(&fillhadrf);
+   
+    tliston.AddToList(&contfinalgh);
+    tliston.AddToList(&hfill1);
+    tliston.AddToList(&hfill2);
+    tliston.AddToList(&hfill3);
+    tliston.AddToList(&hfill4);
+    tliston.AddToList(&hfill5);
+
+    tliston.AddToList(&contfinal);
+
+    //*****************************
+
+    //-------------------------------------------
+    // Execute event loop
+    //
+    MProgressBar bar;
+    MEvtLoop evtloop;
+    evtloop.SetParList(&pliston);
+    evtloop.SetProgressBar(&bar);
+
+    Int_t maxevents = -1;
+    //Int_t maxevents = 35000;
+    if ( !evtloop.Eventloop(maxevents) )
+        return;
+
+    tliston.PrintStatistics(0, kTRUE);
+
+
+    //-------------------------------------------
+    // Display the histograms
+    //
+
+    //pliston.FindObject("hadSC", "MHHadronness")->DrawClone();
+    pliston.FindObject("hadRF", "MHHadronness")->DrawClone();
+
+    pliston.FindObject("MHHillas")->DrawClone();
+    pliston.FindObject("MHHillasExt")->DrawClone();
+    pliston.FindObject("MHHillasSrc")->DrawClone();
+    pliston.FindObject("MHNewImagePar")->DrawClone();
+    pliston.FindObject("MHStarMap")->DrawClone();
+
+    DeleteBinnings(&pliston);
+
+    gLog << "Macro ONOFFAnalysis : End of Job C" << endl;
+    gLog << "===================================================" << endl;
+ }
+
+
+
+  //---------------------------------------------------------------------
+  // Job D
+  //======
+
+    //  - select g/h separation method XX
+    //  - read ON2 (or MC2) root file 
+    //  - apply cuts in hadronness
+    //  - make plots
+
+
+ if (JobD)
+ {
+    gLog << "=====================================================" << endl;
+    gLog << "Macro ONOFFAnalysis : Start of Job D" << endl;
+
+    gLog << "" << endl;
+    gLog << "Macro ONOFFAnalysis : JobD = " 
+         << (JobD        ? "kTRUE" : "kFALSE")  << endl;
+
+
+    // type of data to be analysed
+    TString typeData = "ON";
+    //TString typeData = "OFF";
+    //TString typeData = "MC";
+    gLog << "typeData = " << typeData << endl;
+
+    TString ext      = "3.root";
+
+
+    //------------------------------
+    // selection of g/h separation method
+    // and definition of final selections
+
+    //TString XX("SC");
+    TString XX("RF");
+    TString fhadronnessName("Had");
+    fhadronnessName += XX;
+    gLog << "fhadronnessName = " << fhadronnessName << endl;
+
+    // maximum values of the hadronness, |ALPHA| and DIST
+    Float_t maxhadronness   = 0.233;
+    Float_t maxalpha        = 20.0;
+    Float_t maxdist         = 10.0;
+    gLog << "Maximum values of hadronness, |ALPHA| and DIST = "
+         << maxhadronness << ",  " << maxalpha << ",  " 
+         << maxdist << endl;
+
+
+    //------------------------------
+    // name of data file to be analysed
+    TString filenameData(outPath);
+    filenameData += typeData;
+    filenameData += ext;
+    gLog << "filenameData = " << filenameData << endl;
+
+
+
+    //*************************************************************************
+    //
+    // Analyse the data
+    //
+
+    MTaskList tliston;
+    MParList pliston;
+
+    // geometry is needed in  MHHillas... classes 
+    MGeomCam *fGeom = 
+             (MGeomCam*)pliston->FindCreateObj("MGeomCamMagic", "MGeomCam");
+
+
+    TString fHilName    = "MHillas"; 
+    TString fHilNameExt = "MHillasExt"; 
+    TString fHilNameSrc = "MHillasSrc"; 
+    TString fImgParName = "MNewImagePar"; 
+
+    //-------------------------------------------
+    // create the tasks which should be executed 
+    //
+
+    MReadMarsFile read("Events", filenameData);
+    read.DisableAutoScheme();
+
+
+    //-----------------------------------------------------------------
+    // geometry is needed in  MHHillas... classes 
+    MGeomCam *fGeom = 
+             (MGeomCam*)pliston->FindCreateObj("MGeomCamMagic", "MGeomCam");
+
+    MFSelFinal selfinalgh(fHilNameSrc);
+    selfinalgh.SetCuts(maxhadronness, 100.0, maxdist);
+    selfinalgh.SetHadronnessName(fhadronnessName);
+    selfinalgh.SetName("SelFinalgh");
+    MContinue contfinalgh(&selfinalgh);
+    contfinalgh.SetName("ContSelFinalgh");
+
+    MFillH fillhadsc("hadSC[MHHadronness]", "HadSC");
+    fillhadsc.SetName("HhadSC");
+    MFillH fillhadrf("hadRF[MHHadronness]", "HadRF");
+    fillhadrf.SetName("HhadRF");
+
+    TString mh3name = "abs(Alpha)";
+    MBinning binsalphaabs("Binning"+mh3name);
+    binsalphaabs.SetEdges(50, -2.0, 98.0);
+
+    MH3 alphaabs("abs(MHillasSrc.fAlpha)");
+    alphaabs.SetName(mh3name);
+
+    TH1  &alphahist = alphaabs->GetHist();
+
+    MFillH alpha(&alphaabs);
+    alpha.SetName("FillAlphaAbs");
+
+    MFillH hfill1("MHHillas",    fHilName);
+    hfill1.SetName("HHillas");
+
+    MFillH hfill2("MHStarMap",   fHilName);
+    hfill2.SetName("HStarMap");
+
+    MFillH hfill3("MHHillasExt",   fHilNameSrc);
+    hfill3.SetName("HHillasExt");    
+
+    MFillH hfill4("MHHillasSrc",   fHilNameSrc);
+    hfill4.SetName("HHillasSrc");    
+
+    MFillH hfill5("MHNewImagePar", fImgParName);
+    hfill5.SetName("HNewImagePar");    
+
+    MFSelFinal selfinal(fHilNameSrc);
+    selfinal.SetCuts(maxhadronness, maxalpha, maxdist);
+    selfinal.SetHadronnessName(fhadronnessName);
+    selfinal.SetName("SelFinal");
+    MContinue contfinal(&selfinal);
+    contfinal.SetName("ContSelFinal");
+
+
+    //*****************************
+    // entries in MParList
+
+    pliston.AddToList(&tliston);
+    InitBinnings(&pliston);
+    pliston.AddToList(&binsalphaabs);
+    pliston.AddToList(&alphaabs);
+
+    //*****************************
+    // entries in MTaskList
+    
+    tliston.AddToList(&read);
+
+    tliston.AddToList(&contfinalgh);
+
+    tliston.AddToList(&fillhadsc);
+    tliston.AddToList(&fillhadrf);
+
+    tliston.AddToList(&alpha);
+    tliston.AddToList(&hfill1);
+    tliston.AddToList(&hfill2);
+    tliston.AddToList(&hfill3);
+    tliston.AddToList(&hfill4);
+    tliston.AddToList(&hfill5);
+
+    tliston.AddToList(&contfinal);
+
+    //*****************************
+
+    //-------------------------------------------
+    // Execute event loop
+    //
+    MProgressBar bar;
+    MEvtLoop evtloop;
+    evtloop.SetParList(&pliston);
+    evtloop.SetProgressBar(&bar);
+
+    Int_t maxevents = -1;
+    //Int_t maxevents = 10000;
+    if ( !evtloop.Eventloop(maxevents) )
+        return;
+
+    tliston.PrintStatistics(0, kTRUE);
+
+
+    //-------------------------------------------
+    // Display the histograms
+    //
+
+    pliston.FindObject("hadRF", "MHHadronness")->DrawClone();
+    pliston.FindObject("hadSC", "MHHadronness")->DrawClone();
+
+    pliston.FindObject("MHHillas")->DrawClone();
+    pliston.FindObject("MHHillasExt")->DrawClone();
+    pliston.FindObject("MHHillasSrc")->DrawClone();
+    pliston.FindObject("MHNewImagePar")->DrawClone();
+    pliston.FindObject("MHStarMap")->DrawClone();
+
+
+    //-------------------------------------------
+
+    // fit alpha distribution to get the number of excess events and
+    // calculate significance of gamma signal in the alpha plot
+  
+    MH3* absalpha = (MH3*)(pliston.FindObject(mh3name, "MH3"));
+    TH1  &alphaHist = absalpha->GetHist();
+    alphaHist.SetXTitle("|alpha|  [\\circ]");
+    alphaHist.SetName("alpha-JobD");
+
+    Double_t alphasig = 13.1;
+    Double_t alphamin = 30.0;
+    Double_t alphamax = 90.0;
+    Int_t    degree   =    2;
+    Double_t significance = -99.0;
+    Bool_t   drawpoly  = kTRUE;
+    Bool_t   fitgauss  = kTRUE;
+    Bool_t   print     = kTRUE;
+
+    MHFindSignificance findsig;
+    findsig.SetRebin(kTRUE);
+    findsig.SetReduceDegree(kFALSE);
+
+    findsig.FindSigma(&alphaHist, alphamin, alphamax, degree, 
+                        alphasig, drawpoly, fitgauss, print);
+    significance = findsig.GetSignificance();
+    Float_t alphasi = findsig.GetAlphasi();
+
+    gLog << "For file '" << filenameData << "' : " << endl;
+    gLog << "Significance of gamma signal after supercuts : "
+         << significance << " (for |alpha| < " << alphasi << " degrees)" 
+         << endl;
+
+    findsig.SigmaVsAlpha(&alphaHist, alphamin, alphamax, degree, print);
+
+    //-------------------------------------------
+
+
+    DeleteBinnings(&pliston);
+
+    gLog << "Macro ONOFFAnalysis : End of Job D" << endl;
+    gLog << "=======================================================" << endl;
+ }
+  //---------------------------------------------------------------------
+
+
+
+
+
+  //---------------------------------------------------------------------
+  // Job E_XX
+  //=========
+
+    //  - select g/h separation method XX
+    //  - read MC_XX2.root file 
+    //  - calculate eff. collection area
+    //  - read ON_XX2.root file 
+    //  - apply final cuts
+    //  - calculate flux
+    //  - write root file for ON data after final cuts (ON_XX3.root))
+
+
+ if (JobE_XX)
+ {
+    gLog << "=====================================================" << endl;
+    gLog << "Macro ONOFFAnalysis : Start of Job E_XX" << endl;
+
+    gLog << "" << endl;
+    gLog << "Macro ONOFFAnalysis : JobE_XX, CCollArea, OEEst, WEX = " 
+         << (JobE_XX ? "kTRUE" : "kFALSE")  << ",  " 
+         << (CCollArea?"kTRUE" : "kFALSE")  << ",  " 
+         << (OEEst ?   "kTRUE" : "kFALSE")  << ",  " 
+         << (WEX     ? "kTRUE" : "kFALSE")  << endl;
+
+
+    // type of data to be analysed
+    //TString typeData = "ON";
+    //TString typeData = "OFF";
+    TString typeData = "MC";
+    gLog << "typeData = " << typeData << endl;
+
+    TString typeMC   = "MC";
+    TString ext      = "3.root";
+    TString extout   = "4.root";
+
+    //------------------------------
+    // selection of g/h separation method
+    // and definition of final selections
+
+    //TString XX("SC");
+    TString XX("RF");
+    TString fhadronnessName("Had");
+    fhadronnessName += XX;
+    gLog << "fhadronnessName = " << fhadronnessName << endl;
+
+    // maximum values of the hadronness, |ALPHA| and DIST
+    Float_t maxhadronness   = 0.23;
+    Float_t maxalpha        = 20.0;
+    Float_t maxdist         = 10.0;
+    gLog << "Maximum values of hadronness, |ALPHA| and DIST = "
+         << maxhadronness << ",  " << maxalpha << ",  " 
+         << maxdist << endl;
+
+    //------------------------------
+    // name of MC file to be used for optimizing the energy estimator
+    TString filenameOpt(outPath);
+    filenameOpt += typeMC;
+    filenameOpt += ext; 
+    gLog << "filenameOpt = " << filenameOpt << endl;
+
+    //------------------------------
+    // name of file containing the parameters of the energy estimator
+    TString energyParName(outPath);
+    energyParName += "energyest_";
+    energyParName += XX;
+    energyParName += ".root";
+    gLog << "energyParName = " << energyParName << endl;
+
+    //------------------------------
+    // name of MC file to be used for calculating the eff. collection areas
+    TString filenameArea(outPath);
+    filenameArea += typeMC;
+    filenameArea += ext; 
+    gLog << "filenameArea = " << filenameArea << endl;
+
+    //------------------------------
+    // name of file containing the eff. collection areas
+    TString collareaName(outPath);
+    collareaName += "area_";
+    collareaName += XX;
+    collareaName += ".root";
+    gLog << "collareaName = " << collareaName << endl;
+
+    //------------------------------
+    // name of data file to be analysed
+    TString filenameData(outPath);
+    filenameData += typeData;
+    filenameData += ext;
+    gLog << "filenameData = " << filenameData << endl;
+
+    //------------------------------
+    // name of output data file (after the final cuts)
+    TString filenameDataout(outPath);
+    filenameDataout += typeData;
+    filenameDataout += "_";
+    filenameDataout += XX;
+    filenameDataout += extout;
+    gLog << "filenameDataout = " << filenameDataout << endl;
+
+    //------------------------------
+    // name of file containing histograms for flux calculastion
+    TString filenameResults(outPath);
+    filenameResults += typeData;
+    filenameResults += "Results_";
+    filenameResults += XX;
+    filenameResults += extout;
+    gLog << "filenameResults = " << filenameResults << endl;
+
+
+    //====================================================================
+
+    MHMcCollectionArea collarea;
+    collarea.SetEaxis(MHMcCollectionArea::kLinear);
+
+    MParList  parlist;
+    InitBinnings(&parlist);
+
+  if (CCollArea)
+  {
+    gLog << "-----------------------------------------------" << endl;
+    gLog << "Start calculation of effective collection areas" << endl;
+
+
+    MTaskList tasklist;
+
+    //---------------------------------------
+    // Setup the tasks to be executed
+    //
+    MReadMarsFile reader("Events", filenameArea);
+    reader.DisableAutoScheme();
+
+    MFSelFinal cuthadrons;
+    cuthadrons.SetHadronnessName(fhadronnessName);
+    cuthadrons.SetCuts(maxhadronness, maxalpha, maxdist);
+
+    MContinue conthadrons(&cuthadrons);
+
+
+    MFillH filler("MHMcCollectionArea", "MMcEvt");
+    filler.SetName("CollectionArea");
+
+    //********************************
+    // entries in MParList
+
+    parlist.AddToList(&tasklist);
+
+    parlist.AddToList(&collarea);
+
+    //********************************
+    // entries in MTaskList
+
+    tasklist.AddToList(&reader);   
+    tasklist.AddToList(&conthadrons);
+    tasklist.AddToList(&filler);
+
+    //********************************
+
+    //-----------------------------------------
+    // Execute event loop
+    //
+    MEvtLoop magic;
+    magic.SetParList(&parlist);
+
+    MProgressBar bar;
+    magic.SetProgressBar(&bar);
+    if (!magic.Eventloop())
+        return;
+
+    tasklist.PrintStatistics(0, kTRUE);
+
+    // Calculate effective collection areas 
+    // and display the histograms
+    //
+    //MHMcCollectionArea *collarea = 
+    //     (MHMcCollectionArea*)parlist.FindObject("MHMcCollectionArea");
+    collarea.CalcEfficiency();
+    collarea.DrawClone();
+
+
+
+    //---------------------------------------------
+    // Write histograms to a file 
+    //
+
+    TFile f(collareaName, "RECREATE");
+    //collarea.GetHist()->Write();
+    //collarea.GetHAll()->Write();
+    //collarea.GetHSel()->Write();
+    collarea.Write();
+
+    f.Close();
+
+    gLog << "Collection area plots written onto file " << collareaName << endl;
+
+    gLog << "Calculation of effective collection areas done" << endl;
+    gLog << "-----------------------------------------------" << endl;    
+    //------------------------------------------------------------------
+  }
+
+  if (!CCollArea)
+  {
+    gLog << "-----------------------------------------------" << endl;
+    gLog << "Read in effective collection areas from file " 
+         << collareaName << endl;
+
+    TFile collfile(collareaName);
+    collfile.ls();
+    collarea.Read("MHMcCollectionArea");
+    collarea.DrawClone();
+
+    gLog << "Effective collection areas were read in from file " 
+         << collareaName << endl;
+    gLog << "-----------------------------------------------" << endl;    
+  }
+
+
+    // save binnings for call to MagicEEst
+    MBinning *binsE     = (MBinning*)parlist.FindObject("BinningE");
+    if (!binsE)
+	{
+          gLog << "Object 'BinningE' not found in MParList" << endl;
+          return;
+	}
+    MBinning *binsTheta = (MBinning*)parlist.FindObject("BinningTheta");
+    if (!binsTheta)
+	{
+          gLog << "Object 'BinningTheta' not found in MParList" << endl;
+          return;
+	}
+
+    //-------------------------------------
+    TString fHilName    = "MHillas"; 
+    TString fHilNameExt = "MHillasExt"; 
+    TString fHilNameSrc = "MHillasSrc"; 
+    TString fImgParName = "MNewImagePar"; 
+
+
+ if (OEEst)
+ { 
+   //===========================================================
+    //
+    // Optimization of energy estimator
+    //
+    gLog << "Macro ONOFFAnalysis.C : calling MagicEEst" << endl;
+
+    TString inpath("");
+    TString outpath("");
+    Int_t howMany = 2000;
+    MagicEEst(inpath,   filenameOpt,   outpath, energyParName, 
+            fHilName, fHilNameSrc,   fhadronnessName,
+            howMany,  maxhadronness, maxalpha, maxdist,
+            binsE, binsTheta);
+    gLog << "Macro ONOFFAnalysis.C : returning from MagicEEst" << endl;
+ }
+
+ if (WEX)
+ {
+    //-----------------------------------------------------------
+    //
+    // Read in parameters of energy estimator ("MMcEnergyEst")
+    //                   and migration matrix ("MHMcEnergyMigration")
+    //
+    gLog << "================================================================"
+         << endl;
+    gLog << "Macro ONOFFAnalysis.C : read parameters of energy estimator and migration matrix from file '"
+         << energyParName << "'" << endl;
+    TFile enparam(energyParName);
+    enparam.ls();
+    MMcEnergyEst mcest("MMcEnergyEst"); 
+    mcest.Read("MMcEnergyEst");
+
+    //MMcEnergyEst &mcest = *((MMcEnergyEst*)gROOT->FindObject("MMcEnergyEst"));
+    gLog << "Parameters of energy estimator were read in" << endl;
+
+
+    gLog << "Read in Migration matrix" << endl;   
+
+    MHMcEnergyMigration mighiston("MHMcEnergyMigration");
+    mighiston.Read("MHMcEnergyMigration");
+    //MHMcEnergyMigration &mighiston = 
+    //      *((MHMcEnergyMigration*)gROOT->FindObject("MHMcEnergyMigration"));
+
+    gLog << "Migration matrix was read in" << endl;
+
+
+    TArrayD parA(mcest.GetNumCoeffA());
+    TArrayD parB(mcest.GetNumCoeffB());
+    for (Int_t i=0; i<parA.GetSize(); i++)
+      parA[i] = mcest.GetCoeff(i);
+    for (Int_t i=0; i<parB.GetSize(); i++)
+      parB[i] = mcest.GetCoeff( i+parA.GetSize() );
+
+    //*************************************************************************
+    //
+    // Analyse the data
+    //
+    gLog << "============================================================"
+         << endl;
+    gLog << "Analyse the data" << endl;
+
+    MTaskList tliston;
+    MParList pliston;
+
+    // geometry is needed in  MHHillas... classes 
+    MGeomCam *fGeom = 
+             (MGeomCam*)pliston->FindCreateObj("MGeomCamMagic", "MGeomCam");
+
+
+    //-------------------------------------------
+    // create the tasks which should be executed 
+    //
+
+    MReadMarsFile read("Events", filenameData);
+    read.DisableAutoScheme();
+
+    //.......................................................................
+
+      gLog << "MagicAnalysis.C : write root file '" << filenameDataout 
+           << "'" << endl;
+   
+      //MWriteRootFile &write = *(new MWriteRootFile(filenameDataout));
+
+
+      MWriteRootFile write(filenameDataout, "RECREATE");
+
+      write.AddContainer("MRawRunHeader", "RunHeaders");
+      write.AddContainer("MTime",         "Events");
+      write.AddContainer("MMcEvt",        "Events");
+      write.AddContainer("ThetaOrig",     "Events");
+      write.AddContainer("MSrcPosCam",    "Events");
+      write.AddContainer("MSigmabar",     "Events");
+      write.AddContainer("MHillas",       "Events");
+      write.AddContainer("MHillasExt",    "Events");
+      write.AddContainer("MHillasSrc",    "Events");
+      write.AddContainer("MNewImagePar",  "Events");
+
+      //write.AddContainer("HadNN",         "Events");
+      write.AddContainer("HadSC",         "Events");
+      write.AddContainer("HadRF",         "Events");
+
+      write.AddContainer("MEnergyEst",    "Events");
+
+
+    //-----------------------------------------------------------------
+    // geometry is needed in  MHHillas... classes 
+    MGeomCam *fGeom = 
+             (MGeomCam*)pliston->FindCreateObj("MGeomCamMagic", "MGeomCam");
+
+    MFSelFinal selfinalgh(fHilNameSrc);
+    selfinalgh.SetCuts(maxhadronness, 100.0, maxdist);
+    selfinalgh.SetHadronnessName(fhadronnessName);
+    selfinalgh.SetName("SelFinalgh");
+    MContinue contfinalgh(&selfinalgh);
+    contfinalgh.SetName("ContSelFinalgh");
+
+    //MFillH fillhadnn("hadNN[MHHadronness]", "HadNN");
+    //fillhadnn.SetName("HhadNN");
+    MFillH fillhadsc("hadSC[MHHadronness]", "HadSC");
+    fillhadsc.SetName("HhadSC");
+    MFillH fillhadrf("hadRF[MHHadronness]", "HadRF");
+    fillhadrf.SetName("HhadRF");
+
+    //---------------------------
+    // calculate estimated energy
+
+    MEnergyEstParam eeston(fHilName);
+    eeston.Add(fHilNameSrc);
+
+    eeston.SetCoeffA(parA);
+    eeston.SetCoeffB(parB);
+
+    //---------------------------
+    // calculate estimated energy using Daniel's parameters
+
+    //MEnergyEstParamDanielMkn421 eeston(fHilName);
+    //eeston.Add(fHilNameSrc);
+    //eeston.SetCoeffA(parA);
+    //eeston.SetCoeffB(parB);
+
+
+    //---------------------------
+
+
+    MFillH hfill1("MHHillas",    fHilName);
+    hfill1.SetName("HHillas");
+
+    MFillH hfill2("MHStarMap",   fHilName);
+    hfill2.SetName("HStarMap");
+
+    MFillH hfill3("MHHillasExt",   fHilNameSrc);
+    hfill3.SetName("HHillasExt");    
+
+    MFillH hfill4("MHHillasSrc",   fHilNameSrc);
+    hfill4.SetName("HHillasSrc");    
+
+    MFillH hfill5("MHNewImagePar", fImgParName);
+    hfill5.SetName("HNewImagePar");    
+
+    //---------------------------
+    // new from Robert
+
+    MFillH hfill6("MHTimeDiffTheta", "MMcEvt");
+    hfill6.SetName("HTimeDiffTheta");
+
+    MFillH hfill6a("MHTimeDiffTime", "MMcEvt");
+    hfill6a.SetName("HTimeDiffTime");
+
+    MFillH hfill7("MHAlphaEnergyTheta", fHilNameSrc);
+    hfill7.SetName("HAlphaEnergyTheta");
+
+    MFillH hfill7a("MHAlphaEnergyTime", fHilNameSrc);
+    hfill7a.SetName("HAlphaEnergyTime");
+
+    MFillH hfill7b("MHThetabarTime", fHilNameSrc);
+    hfill7b.SetName("HThetabarTime");
+
+    MFillH hfill7c("MHEnergyTime", "MMcEvt");
+    hfill7c.SetName("HEnergyTime");
+
+
+    //---------------------------
+
+    MFSelFinal selfinal(fHilNameSrc);
+    selfinal.SetCuts(maxhadronness, maxalpha, maxdist);
+    selfinal.SetHadronnessName(fhadronnessName);
+    selfinal.SetName("SelFinal");
+    MContinue contfinal(&selfinal);
+    contfinal.SetName("ContSelFinal");
+
+
+    //*****************************
+    // entries in MParList
+
+    pliston.AddToList(&tliston);
+    InitBinnings(&pliston);
+
+
+    //*****************************
+    // entries in MTaskList
+    
+    tliston.AddToList(&read);
+
+    // robert      
+    tliston.AddToList(&hfill6);   //timediff
+    tliston.AddToList(&hfill6a);   //timediff
+
+    tliston.AddToList(&contfinalgh);
+    tliston.AddToList(&eeston);
+
+    tliston.AddToList(&write);
+
+    //tliston.AddToList(&fillhadnn);
+    tliston.AddToList(&fillhadsc);
+    tliston.AddToList(&fillhadrf);
+
+    tliston.AddToList(&hfill1);
+    tliston.AddToList(&hfill2);
+    tliston.AddToList(&hfill3);
+    tliston.AddToList(&hfill4);
+    tliston.AddToList(&hfill5);
+
+    //robert
+    tliston.AddToList(&hfill7);
+    tliston.AddToList(&hfill7a);
+    tliston.AddToList(&hfill7b);
+    tliston.AddToList(&hfill7c);
+
+    tliston.AddToList(&contfinal);
+
+    //*****************************
+
+    //-------------------------------------------
+    // Execute event loop
+    //
+    MProgressBar bar;
+    MEvtLoop evtloop;
+    evtloop.SetParList(&pliston);
+    evtloop.SetProgressBar(&bar);
+
+    Int_t maxevents = -1;
+    if ( !evtloop.Eventloop(maxevents) )
+        return;
+
+    tliston.PrintStatistics(0, kTRUE);
+
+
+    //-------------------------------------------
+    // Display the histograms
+    //
+
+    //pliston.FindObject("hadNN", "MHHadronness")->DrawClone();
+
+    gLog << "before hadRF" << endl;
+    pliston.FindObject("hadRF", "MHHadronness")->DrawClone();
+
+    gLog << "before hadSC" << endl;
+    pliston.FindObject("hadSC", "MHHadronness")->DrawClone();
+
+    gLog << "before MHHillas" << endl;
+    pliston.FindObject("MHHillas")->DrawClone();
+
+    gLog << "before MHHillasExt" << endl;
+    pliston.FindObject("MHHillasExt")->DrawClone();
+
+    gLog << "before MHHillasSrc" << endl;
+    pliston.FindObject("MHHillasSrc")->DrawClone();
+
+    gLog << "before MHNewImagePar" << endl;
+    pliston.FindObject("MHNewImagePar")->DrawClone();
+
+    gLog << "before MHStarMap" << endl;
+    pliston.FindObject("MHStarMap")->DrawClone();
+
+    gLog << "before DeleteBinnings" << endl;
+
+    DeleteBinnings(&pliston);
+
+    gLog << "before Robert's code" << endl;
+
+
+//rwagner write all relevant histograms onto a file
+
+  if (WRobert)
+  {
+    gLog << "=======================================================" << endl;
+    gLog << "Write results onto file '" << filenameResults << "'" << endl;
+
+    TFile outfile(filenameResults,"recreate");
+
+    MHHillasSrc* hillasSrc = 
+      (MHHillasSrc*)(pliston->FindObject("MHHillasSrc"));
+        TH1F* alphaHist = (TH1F*)(hillasSrc->GetHistAlpha());
+    alphaHist->Write();
+    gLog << "Alpha plot has been written out" << endl;    
+
+
+    MHAlphaEnergyTheta* aetH = 
+      (MHAlphaEnergyTheta*)(pliston->FindObject("MHAlphaEnergyTheta"));
+    TH3D* aetHist = (TH3D*)(aetH->GetHist());
+    aetHist->SetName("aetHist");
+    aetHist->Write();
+    gLog << "AlphaEnergyTheta plot has been written out" << endl;    
+
+    MHAlphaEnergyTime* aetH2 = 
+      (MHAlphaEnergyTime*)(pliston->FindObject("MHAlphaEnergyTime"));
+    TH3D* aetHist2 = (TH3D*)(aetH2->GetHist());
+    aetHist2->SetName("aetimeHist");
+//     aetHist2->DrawClone();
+    aetHist2->Write();
+    gLog << "AlphaEnergyTime plot has been written out" << endl;    
+
+    MHThetabarTime* tbt = 
+      (MHThetabarTime*)(pliston->FindObject("MHThetabarTime"));
+    TProfile* tbtHist = (TProfile*)(tbt->GetHist());
+    tbtHist->SetName("tbtHist");
+    tbtHist->Write();
+    gLog << "ThetabarTime plot has been written out" << endl;    
+
+    MHEnergyTime* ent = 
+      (MHEnergyTime*)(pliston->FindObject("MHEnergyTime"));
+    TH2D* entHist = (TH2D*)(ent->GetHist());
+    entHist->SetName("entHist");
+    entHist->Write();
+    gLog << "EnergyTime plot has been written out" << endl;    
+    
+    MHTimeDiffTheta *time = (MHTimeDiffTheta*)pliston.FindObject("MHTimeDiffTheta");
+    TH2D* timeHist = (TH2D*)(time->GetHist());
+    timeHist->SetName("MHTimeDiffTheta");
+    timeHist->SetTitle("Time diffs");
+    timeHist->Write();
+    gLog << "TimeDiffTheta plot has been written out" << endl;    
+
+
+    MHTimeDiffTime *time2 = (MHTimeDiffTime*)pliston.FindObject("MHTimeDiffTime");
+    TH2D* timeHist2 = (TH2D*)(time2->GetHist());
+    timeHist2->SetName("MHTimeDiffTime");
+    timeHist2->SetTitle("Time diffs");
+    timeHist2->Write();
+    gLog << "TimeDiffTime plot has been written out" << endl;    
+
+//rwagner write also collareas to same file
+    collarea->GetHist()->Write();
+    collarea->GetHAll()->Write();
+    collarea->GetHSel()->Write();
+    gLog << "Effective collection areas have been written out" << endl;        
+
+//rwagner todo: write alpha_cut, type of g/h sep (RF, SC, NN), type of data
+//rwagner (ON/OFF/MC), MJDmin, MJDmax to this file
+
+    gLog << "before closing outfile" << endl;
+
+    //outfile.Close();
+    gLog << "Results were written onto file '" << filenameResults 
+         << "'" << endl;
+    gLog << "=======================================================" << endl;
+  }
+
+  }
+
+    gLog << "Macro ONOFFAnalysis : End of Job E_XX" << endl;
+    gLog << "=======================================================" << endl;
+ }
+  //---------------------------------------------------------------------
+
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/macros/ONOFFCT1Analysis.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/ONOFFCT1Analysis.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/ONOFFCT1Analysis.C	(revision 9661)
@@ -0,0 +1,3310 @@
+
+
+#include "CT1EgyEst.C"
+
+
+void InitBinnings(MParList *plist)
+{
+        gLog << "InitBinnings" << endl;
+
+        //--------------------------------------------
+        MBinning *binse = new MBinning("BinningE");
+        //binse->SetEdgesLog(30, 1.0e2, 1.0e5);
+
+	//This is Daniel's binning in energy:
+        binse->SetEdgesLog(14, 296.296, 86497.6);
+        plist->AddToList(binse);
+
+        //--------------------------------------------
+
+        MBinning *binssize = new MBinning("BinningSize");
+        binssize->SetEdgesLog(50, 10, 1.0e5);
+        plist->AddToList(binssize);
+
+        MBinning *binsdistc = new MBinning("BinningDist");
+        binsdistc->SetEdges(50, 0, 1.4);
+        plist->AddToList(binsdistc);
+
+        MBinning *binswidth = new MBinning("BinningWidth");
+        binswidth->SetEdges(50, 0, 1.0);
+        plist->AddToList(binswidth);
+
+        MBinning *binslength = new MBinning("BinningLength");
+        binslength->SetEdges(50, 0, 1.0);
+        plist->AddToList(binslength);
+
+        MBinning *binsalpha = new MBinning("BinningAlpha");
+        binsalpha->SetEdges(100, -100, 100);
+        plist->AddToList(binsalpha);
+
+        MBinning *binsasym = new MBinning("BinningAsym");
+        binsasym->SetEdges(50, -1.5, 1.5);
+        plist->AddToList(binsasym);
+
+        MBinning *binsm3l = new MBinning("BinningM3Long");
+        binsm3l->SetEdges(50, -1.5, 1.5);
+        plist->AddToList(binsm3l);
+
+        MBinning *binsm3t = new MBinning("BinningM3Trans");
+        binsm3t->SetEdges(50, -1.5, 1.5);
+        plist->AddToList(binsm3t);
+
+   
+        //.....
+        MBinning *binsb = new MBinning("BinningSigmabar");
+        binsb->SetEdges( 100,  0.0,  5.0);
+        plist->AddToList(binsb);
+
+        MBinning *binth = new MBinning("BinningTheta");
+        // this is Daniel's binning in theta
+        //Double_t yedge[8] = 
+        //  {9.41, 16.22, 22.68, 28.64, 34.03, 38.84, 43.08, 44.99};
+        // this is our binning
+        Double_t yedge[9] = 
+                       {0.0, 17.5, 23.5, 29.5, 35.5, 42., 50., 60., 70.};
+        TArrayD yed;
+        yed.Set(9,yedge);
+        binth->SetEdges(yed);
+        plist->AddToList(binth);
+
+        MBinning *bincosth = new MBinning("BinningCosTheta");
+        Double_t zedge[9]; 
+        for (Int_t i=0; i<9; i++)
+	{
+          zedge[8-i] = cos(yedge[i]/kRad2Deg);
+	}
+        TArrayD zed;
+        zed.Set(9,zedge);
+        bincosth->SetEdges(zed);
+        plist->AddToList(bincosth);
+
+        MBinning *binsdiff = new MBinning("BinningDiffsigma2");
+        binsdiff->SetEdges(100, -5.0, 20.0);
+        plist->AddToList(binsdiff);
+
+        // robert ----------------------------------------------
+        MBinning *binsalphaf = new MBinning("BinningAlphaFlux");
+        binsalphaf->SetEdges(100, -100, 100);
+        plist->AddToList(binsalphaf);
+
+	MBinning *binsdifftime = new MBinning("BinningTimeDiff");
+	binsdifftime->SetEdges(50, 0, 10);
+	plist->AddToList(binsdifftime);
+
+	MBinning *binstime = new MBinning("BinningTime");
+	binstime->SetEdges(50, 44500, 61000);
+	plist->AddToList(binstime);
+}
+
+
+void DeleteBinnings(MParList *plist)
+{
+        gLog << "DeleteBinnings" << endl;
+
+        TObject *bin;
+
+        //--------------------------------------------
+        bin = plist->FindObject("BinningE");
+        if (bin) delete bin;
+
+        //--------------------------------------------
+
+        bin = plist->FindObject("BinningSize");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningDist");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningWidth");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningLength");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningAlpha");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningAsym");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningM3Long");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningM3Trans");
+        if (bin) delete bin;
+
+        //.....
+        bin = plist->FindObject("BinningSigmabar");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningTheta");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningCosTheta");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningDiffsigma2");
+        if (bin) delete bin;
+
+
+        // robert ----------------------------------------------
+        bin = plist->FindObject("BinningAlphaFlux");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningTimeDiff");
+        if (bin) delete bin;
+
+        bin = plist->FindObject("BinningTime");
+        if (bin) delete bin;
+}
+
+
+
+//************************************************************************
+void ONOFFCT1Analysis()
+{
+      gLog.SetNoColors();
+
+      if (gRandom)
+        delete gRandom;
+      gRandom = new TRandom3(0);
+
+      //-----------------------------------------------
+      const char *offfile = "~magican/ct1test/wittek/offdata.preproc"; 
+
+      //const char *onfile  = "~magican/ct1test/wittek/mkn421_on.preproc"; 
+      const char *onfile  = "~magican/ct1test/wittek/mkn421_00-01"; 
+
+      const char *mcfile  = "~magican/ct1test/wittek/mkn421_mc_pedrms_0.001.preproc";
+      //-----------------------------------------------
+
+      // path for input for Mars
+      TString inPath = "~magican/ct1test/wittek/marsoutput/optionD/";
+
+      // path for output from Mars
+      TString outPath = "~magican/ct1test/wittek/marsoutput/optionD/";
+
+      //-----------------------------------------------
+
+      //TEnv env("macros/CT1env.rc");
+      //Bool_t printEnv = kFALSE;
+
+    //************************************************************************
+
+    // Job A : 
+    //  - produce MHSigmaTheta plots for ON and OFF data
+    //  - write out (or read in) these MHSigmaTheta plots
+    //  - read ON (or OFF or MC) data
+    //  - pad the events; 
+    //  - write root file for ON (or OFF or MC) data (ON1.root, ...);
+
+    Bool_t JobA    = kFALSE;  
+    Bool_t WPad    = kFALSE;   // write out padding histograms ?
+    Bool_t RPad    = kFALSE;   // read in padding histograms ?
+    Bool_t Wout    = kFALSE;   // write out root file ON1.root 
+                               // (or OFF1.root or MC1.root)?
+
+
+    // Job B_RF_UP : read ON1.root (OFF1.root or MC1.root) file 
+    //  - if CTrainRF = TRUE : create matrices of training events
+    //                         and root files of training and test events
+    //  - if RTrainRF = TRUE : read in training matrices for hadrons and gammas
+    //  - if RTree    = TRUE : read in trees, otherwise create trees
+    //  - calculate hadroness for method of RANDOM FOREST
+    //  - update the input files with the hadronesses (ON2.root, OFF2.root
+    //     or MC2.root)
+
+    Bool_t JobB_RF_UP  = kFALSE;  
+    Bool_t CTrainRF    = kFALSE;  // create  matrices of training events
+                                  // and root files of training and test events
+    Bool_t RTrainRF    = kFALSE;  // read in matrices of training events
+    Bool_t RTree       = kFALSE;  // read in trees (otherwise grow them)
+    Bool_t WRF         = kFALSE;  // update input root file ?
+
+
+    // Job B_SC_UP : read ON2.root (or MC2.root) file 
+    //  - depending on WParSC : create (or read in) supercuts parameter values
+    //  - calculate hadroness for the SUPERCUTS
+    //  - update the input files with the hadroness (==>ON3.root or MC3.root)
+
+    Bool_t JobB_SC_UP  = kTRUE;
+    Bool_t CMatrix     = kTRUE;  // create training and test matrices 
+    Bool_t RMatrix     = kFALSE;  // read training and test matrices from file
+    Bool_t WOptimize   = kFALSE;  // do optimization using the training sample
+                                  // and write supercuts parameter values 
+                                  // onto the file parSCfile
+    Bool_t RTest       = kFALSE;  // test the supercuts using the test matrix
+    Bool_t WSC         = kFALSE;  // update input root file ?
+
+
+    // Job C: 
+    //  - read ON3.root and MC3.root files
+    //    which should have been updated to contain the hadronnesses  
+    //    for the method of 
+    //              RF
+    //              SUPERCUTS and
+    //  - produce Neyman-Pearson plots
+
+    Bool_t JobC  = kFALSE;  
+
+
+    // Job D :  
+    //  - select g/h separation method XX
+    //  - read ON3 (or MC3) root file
+    //  - apply cuts in hadronness
+    //  - make plots
+
+    Bool_t JobD  = kFALSE;  
+
+
+
+    // Job E_XX : extended version of E_XX (including flux plots)  
+    //  - select g/h separation method XX
+    //  - read MC root file 
+    //  - calculate eff. collection area
+    //  - optimize energy estimator
+    //  - read ON root file 
+    //  - apply final cuts
+    //  - calculate flux
+    //  - write root file for ON data after final cuts 
+
+
+    Bool_t JobE_XX  = kFALSE;  
+    Bool_t CCollArea= kFALSE;  // calculate eff. collection areas
+    Bool_t OEEst    = kFALSE;  // optimize energy estimator
+    Bool_t WEX      = kFALSE;  // update root file  ?
+    Bool_t WRobert  = kFALSE;  // write out Robert's file  ?
+
+
+
+    //************************************************************************
+
+    
+  //---------------------------------------------------------------------
+  // Job A
+  //=========
+    // read ON data file 
+
+    //  - produce the 2D-histogram "sigmabar versus Theta" 
+    //    (SigmaTheta_ON.root) for ON data
+    //    (to be used for the padding of the MC gamma data)
+
+    //  - write a file of ON events (ON1.root) 
+    //    (after the standard cuts, before the g/h separation)
+    //    (to be used together with the corresponding MC gamma file (MC1.root)
+    //     for the optimization of the g/h separation)
+
+
+ if (JobA)
+ {
+    gLog << "=====================================================" << endl;
+    gLog << "Macro CT1Analysis : Start of Job A" << endl;
+    gLog << "" << endl;
+    gLog << "Macro CT1Analysis : JobA, WPad, RPad, Wout = " 
+         << (JobA ? "kTRUE" : "kFALSE")  << ",  " 
+         << (WPad ? "kTRUE" : "kFALSE")  << ",  " 
+         << (RPad ? "kTRUE" : "kFALSE")  << ",  " 
+         << (Wout ? "kTRUE" : "kFALSE")  << endl;
+    
+
+    //--------------------------------------------------
+    // names of ON and OFF files to be read
+    // for generating the histograms to be used in the padding 
+    TString fileON  = onfile;
+    TString fileOFF = offfile;
+    gLog << "fileON, fileOFF = " << fileON << ",  " << fileOFF << endl;
+
+    // name of file to conatin the histograms for the padding
+    TString outNameSigTh = outPath;
+    outNameSigTh += "SigmaTheta";
+    outNameSigTh += ".root";
+
+    //--------------------------------------------------
+    // type of data to be padded 
+    //TString typeInput = "ON";
+    //TString typeInput = "OFF";
+    TString typeInput = "MC";
+    gLog << "typeInput = " << typeInput << endl;
+
+
+    // name of input root file
+    if (typeInput == "ON")
+      TString filenamein(onfile);
+    else if (typeInput == "OFF")
+      TString filenamein(offfile);
+    else if (typeInput == "MC")
+      TString filenamein(mcfile);
+    gLog << "data to be padded : " << filenamein << endl;
+
+    // name of output root file
+    TString outNameImage = outPath;
+    outNameImage += typeInput;
+    outNameImage += "1.root";
+    gLog << "padded data to be written onto : " << outNameImage << endl;
+
+    //--------------------------------------------------
+
+    //************************************************************
+    // generate histograms to be used in the padding
+    // 
+    // read ON and OFF data files
+    // generate (or read in) the padding histograms for ON and OFF data
+    //                       and merge these histograms
+
+    MCT1PadONOFF pad;
+    pad.SetName("MCT1PadONOFF");
+    pad.SetPadFlag(1);
+    pad.SetDataType(typeInput);
+
+    // generate the padding histograms
+    if (!RPad)
+    {
+      gLog << "=====================================================" << endl;
+      gLog << "Start generating the padding histograms" << endl;
+      //-----------------------------------------
+      // ON events
+
+      gLog << "-----------" << endl;
+      gLog << "ON events :" << endl;
+      gLog << "-----------" << endl;
+
+      MTaskList tliston;
+      MParList pliston;
+
+      MCT1ReadPreProc readON(fileON);
+
+      //MFCT1SelBasic selthetaon;
+      //selthetaon.SetCuts(-100.0, 29.5, 35.5);
+      //MContinue contthetaon(&selthetaon);
+
+      MBlindPixelCalc blindon;
+      blindon.SetUseBlindPixels();
+
+      MFCT1SelBasic selbasicon;
+      MContinue contbasicon(&selbasicon);
+
+      MHBlindPixels blindON("BlindPixelsON");
+      MFillH fillblindON("BlindPixelsON[MHBlindPixels]", "MBlindPixels");
+      fillblindON.SetName("FillBlind");
+
+      MSigmabarCalc sigbarcalcon;
+
+      MHSigmaTheta sigthON("SigmaThetaON");
+      MFillH fillsigthetaON ("SigmaThetaON[MHSigmaTheta]", "MMcEvt");
+      fillsigthetaON.SetName("FillSigTheta");    
+ 
+      //*****************************
+      // entries in MParList
+    
+      pliston.AddToList(&tliston);
+      InitBinnings(&pliston);
+      pliston.AddToList(&blindON);
+      pliston.AddToList(&sigthON);
+
+
+      //*****************************
+      // entries in MTaskList
+    
+      tliston.AddToList(&readON);
+      //tliston.AddToList(&contthetaon);
+
+      tliston.AddToList(&blindon);
+
+      tliston.AddToList(&contbasicon);
+      tliston.AddToList(&fillblindON);
+      tliston.AddToList(&sigbarcalcon);
+      tliston.AddToList(&fillsigthetaON);
+
+      MProgressBar baron;
+      MEvtLoop evtloopon;
+      evtloopon.SetParList(&pliston);
+      evtloopon.SetProgressBar(&baron);
+
+      Int_t maxeventson = -1;
+      //Int_t maxeventson = 10000;
+      if ( !evtloopon.Eventloop(maxeventson) )
+          return;
+
+      tliston.PrintStatistics(0, kTRUE);
+
+      blindON.DrawClone();
+      sigthON.DrawClone();
+
+      // save the histograms for the padding
+      TH2D *sigthon     = sigthON.GetSigmaTheta();
+      TH3D *sigpixthon  = sigthON.GetSigmaPixTheta();
+      TH3D *diffpixthon = sigthON.GetDiffPixTheta();
+
+      TH2D *blindidthon = blindON.GetBlindId();
+      TH2D *blindnthon  = blindON.GetBlindN();
+
+      //-----------------------------------------
+      // OFF events
+
+      gLog << "------------" << endl;
+      gLog << "OFF events :" << endl;
+      gLog << "------------" << endl;
+
+      MTaskList tlistoff;
+      MParList plistoff;
+
+      MCT1ReadPreProc readOFF(fileOFF);
+
+      MFCT1SelBasic selthetaoff;
+      selthetaoff.SetCuts(-100.0, 29.5, 35.5);
+      MContinue contthetaoff(&selthetaoff);
+
+      MBlindPixelCalc blindoff;
+      blindoff.SetUseBlindPixels();
+
+      MFCT1SelBasic selbasicoff;
+      MContinue contbasicoff(&selbasicoff);
+
+      MHBlindPixels blindOFF("BlindPixelsOFF");
+      MFillH fillblindOFF("BlindPixelsOFF[MHBlindPixels]", "MBlindPixels");
+      fillblindOFF.SetName("FillBlindOFF");
+
+      MSigmabarCalc sigbarcalcoff;
+
+      MHSigmaTheta sigthOFF("SigmaThetaOFF");
+      MFillH fillsigthetaOFF ("SigmaThetaOFF[MHSigmaTheta]", "MMcEvt");
+      fillsigthetaOFF.SetName("FillSigThetaOFF");     
+
+      //*****************************
+      // entries in MParList
+    
+      plistoff.AddToList(&tlistoff);
+      InitBinnings(&plistoff);
+      plistoff.AddToList(&blindOFF);
+      plistoff.AddToList(&sigthOFF);
+
+
+      //*****************************
+      // entries in MTaskList
+    
+      tlistoff.AddToList(&readOFF);
+      //tlistoff.AddToList(&contthetaoff);
+
+      tlistoff.AddToList(&blindoff);
+
+      tlistoff.AddToList(&contbasicoff);
+      tlistoff.AddToList(&fillblindOFF);
+      tlistoff.AddToList(&sigbarcalcoff);
+      tlistoff.AddToList(&fillsigthetaOFF);
+
+      MProgressBar baroff;
+      MEvtLoop evtloopoff;
+      evtloopoff.SetParList(&plistoff);
+      evtloopoff.SetProgressBar(&baroff);
+
+      Int_t maxeventsoff = -1;
+      //Int_t maxeventsoff = 20000;
+      if ( !evtloopoff.Eventloop(maxeventsoff) )
+          return;
+
+      tlistoff.PrintStatistics(0, kTRUE);
+
+      blindOFF.DrawClone();
+      sigthOFF.DrawClone();
+
+      // save the histograms for the padding
+      TH2D *sigthoff     = sigthOFF.GetSigmaTheta();
+      TH3D *sigpixthoff  = sigthOFF.GetSigmaPixTheta();
+      TH3D *diffpixthoff = sigthOFF.GetDiffPixTheta();
+
+      TH2D *blindidthoff = blindOFF.GetBlindId();
+      TH2D *blindnthoff  = blindOFF.GetBlindN();
+
+
+      //-----------------------------------------
+
+      gLog << "End of generating the padding histograms" << endl;
+      gLog << "=====================================================" << endl;
+
+      pad.MergeHistograms(sigthon,     sigthoff,
+                          sigpixthon,  sigpixthoff,
+                          diffpixthon, diffpixthoff,
+                          blindidthon, blindidthoff,
+                          blindnthon,  blindnthoff);
+
+      if (WPad)
+      {
+        // write the padding histograms onto a file  ---------
+        pad.WriteTargetDist(outNameSigTh);     
+      }
+    }
+
+    // read the padding histograms ---------------------------
+    if (RPad)
+    {
+      pad.ReadTargetDist(outNameSigTh);
+    }
+
+
+    //************************************************************
+
+  if (Wout)
+  {
+    gLog << "=====================================================" << endl;
+    gLog << "Start the padding" << endl;
+
+    //-----------------------------------------------------------
+    MTaskList tliston;
+    MParList pliston;
+
+    char *sourceName = "MSrcPosCam";
+    MSrcPosCam source(sourceName);
+
+    // geometry is needed in  MHHillas... classes 
+    MGeomCam *fGeom = 
+             (MGeomCam*)pliston->FindCreateObj("MGeomCamCT1", "MGeomCam");
+
+    //-------------------------------------------
+    // create the tasks which should be executed 
+    //
+
+    MCT1ReadPreProc read(filenamein);
+
+    MFCT1SelBasic seltheta;
+    seltheta.SetCuts(-100.0, 29.5, 35.5);
+    MContinue conttheta(&seltheta);
+
+    if (typeInput ==  "ON")
+    {
+      MCT1PointingCorrCalc pointcorr(sourceName, "MCT1PointingCorrCalc", 
+                                                 "MCT1PointingCorrCalc");
+    }
+
+    MBlindPixelCalc blindbeforepad;
+    blindbeforepad.SetUseBlindPixels();
+    blindbeforepad.SetName("BlindBeforePadding");
+
+    MBlindPixelCalc blind;
+    blind.SetUseBlindPixels();
+    blind.SetName("BlindAfterPadding");
+
+    MFCT1SelBasic selbasic;
+    MContinue contbasic(&selbasic);
+    contbasic.SetName("SelBasic");
+
+    MFillH fillblind("BlindPixels[MHBlindPixels]", "MBlindPixels");
+    fillblind.SetName("HBlind");
+
+    MSigmabarCalc sigbarcalc;
+
+    MFillH fillsigtheta ("SigmaTheta[MHSigmaTheta]", "MMcEvt");
+    fillsigtheta.SetName("HSigmaTheta");
+
+    MImgCleanStd    clean; 
+
+
+    // calculation of  image parameters ---------------------
+    TString fHilName    = "MHillas";
+    TString fHilNameExt = "MHillasExt";
+    TString fHilNameSrc = "MHillasSrc";
+    TString fImgParName = "MNewImagePar";
+
+    MHillasCalc    hcalc;
+    hcalc.SetNameHillas(fHilName);
+    hcalc.SetNameHillasExt(fHilNameExt);
+    hcalc.SetNameNewImgPar(fImgParName);
+
+    MHillasSrcCalc hsrccalc(sourceName, fHilNameSrc);
+    hsrccalc.SetInput(fHilName);
+
+    MFillH hfill1("MHHillas",    fHilName);
+    hfill1.SetName("HHillas");
+
+    MFillH hfill2("MHStarMap",   fHilName);
+    hfill2.SetName("HStarMap");
+
+    MFillH hfill3("MHHillasExt",   fHilNameSrc);
+    hfill3.SetName("HHillasExt");
+
+    MFillH hfill4("MHHillasSrc",   fHilNameSrc);
+    hfill4.SetName("HHillasSrc");
+
+    MFillH hfill5("MHNewImagePar", fImgParName);
+    hfill5.SetName("HNewImagePar");
+    // --------------------------------------------------
+
+    MFCT1SelStandard selstandard(fHilNameSrc);
+    selstandard.SetHillasName(fHilName);
+    selstandard.SetImgParName(fImgParName);
+    selstandard.SetCuts(92, 4, 60, 0.4, 1.05, 0.0, 0.0);
+    MContinue contstandard(&selstandard);
+    contstandard.SetName("SelStandard");
+
+
+      MWriteRootFile write(outNameImage);
+
+      write.AddContainer("MRawRunHeader", "RunHeaders");
+      write.AddContainer("MTime",         "Events");
+      write.AddContainer("MMcEvt",        "Events");
+      write.AddContainer("ThetaOrig",     "Events");
+      write.AddContainer("MSrcPosCam",    "Events");
+      write.AddContainer("MSigmabar",     "Events");
+      write.AddContainer("MHillas",       "Events");
+      write.AddContainer("MHillasExt",    "Events");
+      write.AddContainer("MHillasSrc",    "Events");
+      write.AddContainer("MNewImagePar",  "Events");
+
+
+    //*****************************
+    // entries in MParList
+    
+    pliston.AddToList(&tliston);
+    InitBinnings(&pliston);
+
+    pliston.AddToList(&source);
+
+
+    //*****************************
+    // entries in MTaskList
+    
+    tliston.AddToList(&read);
+    //tliston.AddToList(&conttheta);
+
+    tliston.AddToList(&blindbeforepad);
+    tliston.AddToList(&pad);
+    if (typeInput ==  "ON")
+      tliston.AddToList(&pointcorr);
+    tliston.AddToList(&blind);
+
+    tliston.AddToList(&contbasic);
+    tliston.AddToList(&fillblind);
+    tliston.AddToList(&sigbarcalc);
+    tliston.AddToList(&fillsigtheta);
+    tliston.AddToList(&clean);
+
+    tliston.AddToList(&hcalc);
+    tliston.AddToList(&hsrccalc);
+
+    tliston.AddToList(&hfill1);
+    tliston.AddToList(&hfill2);
+    tliston.AddToList(&hfill3);
+    tliston.AddToList(&hfill4);
+    tliston.AddToList(&hfill5);
+
+    tliston.AddToList(&contstandard);
+    tliston.AddToList(&write);
+
+    //*****************************
+
+    //-------------------------------------------
+    // Execute event loop
+    //
+    MProgressBar bar;
+    MEvtLoop evtloop;
+    evtloop.SetParList(&pliston);
+    //evtloop.ReadEnv(env, "", printEnv);
+    evtloop.SetProgressBar(&bar);
+    //  evtloop.Write();
+
+    Int_t maxevents = -1;
+    //Int_t maxevents = 1000;
+    if ( !evtloop.Eventloop(maxevents) )
+        return;
+
+    tliston.PrintStatistics(0, kTRUE);
+
+
+    //-------------------------------------------
+    // Display the histograms
+
+    pliston.FindObject("SigmaTheta", "MHSigmaTheta")->DrawClone();
+    pliston.FindObject("BlindPixels", "MHBlindPixels")->DrawClone();
+
+    pliston.FindObject("MHHillas")->DrawClone();
+    pliston.FindObject("MHHillasExt")->DrawClone();
+    pliston.FindObject("MHHillasSrc")->DrawClone();
+    pliston.FindObject("MHNewImagePar")->DrawClone();
+    pliston.FindObject("MHStarMap")->DrawClone();
+
+    DeleteBinnings(&pliston);
+
+      gLog << "End of padding" << endl;
+      gLog << "=====================================================" << endl;
+  }  
+
+
+    gLog << "Macro CT1Analysis : End of Job A" << endl;
+    gLog << "===================================================" << endl;
+ }
+
+
+
+
+
+  //---------------------------------------------------------------------
+  // Job B_RF_UP
+  //============
+
+
+    //  - create (or read in) the matrices of training events for gammas 
+    //    and hadrons
+    //  - create (or read in) the trees
+    //  - then read ON1.root (or MC1.root) file 
+    //  - calculate the hadroness for the method of RANDOM FOREST
+    //  - update input root file with the hadroness
+
+
+ if (JobB_RF_UP)
+ {
+    gLog << "=====================================================" << endl;
+    gLog << "Macro CT1Analysis : Start of Job B_RF_UP" << endl;
+
+    gLog << "" << endl;
+    gLog << "Macro CT1Analysis : JobB_RF_UP, RTrainRF, CTrainRF, RTree, WRF = "
+         << (JobB_RF_UP ? "kTRUE" : "kFALSE")  << ",  " 
+         << (RTrainRF ?   "kTRUE" : "kFALSE")  << ",  " 
+         << (CTrainRF ?   "kTRUE" : "kFALSE")  << ",  " 
+         << (RTree ?      "kTRUE" : "kFALSE")  << ",  "
+         << (WRF ?        "kTRUE" : "kFALSE")  << endl;
+
+
+    //--------------------------------------------
+    // parameters for the random forest
+    Int_t NumTrees = 100;
+    Int_t NumTry   =   3;
+    Int_t NdSize   =   1;
+
+
+    TString hadRFName = "HadRF";
+    Float_t maxhadronness =  0.23;
+    Float_t maxalpha      =  20.0;
+    Float_t maxdist       =  10.0;
+
+    TString fHilName    = "MHillas"; 
+    TString fHilNameExt = "MHillasExt"; 
+    TString fHilNameSrc = "MHillasSrc"; 
+    TString fImgParName = "MNewImagePar"; 
+
+
+    TString extin  = "1.root";
+    TString extout = "2.root";
+
+    //--------------------------------------------
+    // for the analysis using ON data only set typeMatrixHadrons = "ON"
+    //                        ON and OFF data                    = "OFF"
+    TString typeMatrixHadrons = "OFF";
+    gLog << "typeMatrixHadrons = " << typeMatrixHadrons << endl;
+
+
+    // file to be updated (ON, OFF or MC)
+
+    //TString typeInput = "ON";
+    TString typeInput = "OFF";
+    //TString typeInput = "MC";
+    gLog << "typeInput = " << typeInput << endl;
+
+    // name of input root file
+    TString NameData = outPath;
+    NameData += typeInput;
+    TString inNameData(NameData);
+    inNameData += extin;
+    gLog << "inNameData = " << inNameData << endl; 
+
+    // name of output root file
+    TString outNameData(NameData);
+    outNameData += extout;
+    gLog << "outNameData = " << outNameData << endl; 
+
+    //--------------------------------------------
+    // files to be read for generating 
+    //    - the matrices of training events
+    //    - and the root files of training and test events
+
+
+    // "hadrons" :
+    TString filenameHad = outPath;
+    filenameHad += typeMatrixHadrons;
+    filenameHad += extin;
+    Int_t howManyHadronsTrain = 12000;
+    Int_t howManyHadronsTest  = 12000;
+    gLog << "filenameHad = "    << filenameHad << ",   howManyHadronsTrain = "
+         << howManyHadronsTrain << ",   howManyHadronsTest = "
+         << howManyHadronsTest  << endl; 
+    
+
+    // "gammas" :
+    TString filenameMC = outPath;
+    filenameMC += "MC";
+    filenameMC += extin;
+    Int_t howManyGammasTrain = 12000;
+    Int_t howManyGammasTest  = 12000;
+    gLog << "filenameMC = "    << filenameMC << ",   howManyGammasTrain = "
+         << howManyGammasTrain << ",   howManyGammasTest = "
+         << howManyGammasTest  << endl; 
+    
+    //--------------------------------------------
+    // files for the matrices of training events 
+
+    TString NameGammas = outPath;
+    NameGammas += "RFmatrix_gammas_Train_";
+    NameGammas += "MC";
+    NameGammas += extin;
+
+    TString NameHadrons = outPath;
+    NameHadrons += "RFmatrix_hadrons_Train_";
+    NameHadrons += typeMatrixHadrons;
+    NameHadrons += extin;
+
+
+    //--------------------------------------------
+    // root files for the training events 
+
+    TString NameGammasTrain = outPath;
+    NameGammasTrain += "RF_gammas_Train_";
+    NameGammasTrain += "MC";
+    TString inNameGammasTrain(NameGammasTrain);    
+    inNameGammasTrain += extin;
+    TString outNameGammasTrain(NameGammasTrain);    
+    outNameGammasTrain += extout;
+
+
+    TString NameHadronsTrain = outPath;
+    NameHadronsTrain += "RF_hadrons_Train_";
+    NameHadronsTrain += typeMatrixHadrons;
+    TString inNameHadronsTrain(NameHadronsTrain);    
+    inNameHadronsTrain += extin;
+    TString outNameHadronsTrain(NameHadronsTrain);    
+    outNameHadronsTrain += extout;
+
+
+    //--------------------------------------------
+    // root files for the test events 
+
+    TString NameGammasTest = outPath;
+    NameGammasTest += "RF_gammas_Test_";
+    NameGammasTest += "MC";
+    TString inNameGammasTest(NameGammasTest);    
+    inNameGammasTest += extin;
+    TString outNameGammasTest(NameGammasTest);    
+    outNameGammasTest += extout;
+
+    TString NameHadronsTest = outPath;
+    NameHadronsTest += "RF_hadrons_Test_";
+    NameHadronsTest += typeMatrixHadrons;
+    TString inNameHadronsTest(NameHadronsTest);    
+    inNameHadronsTest += extin;
+    TString outNameHadronsTest(NameHadronsTest);    
+    outNameHadronsTest += extout;
+
+    //--------------------------------------------------------------------
+
+
+    MHMatrix matrixg("MatrixGammas");
+    matrixg.EnableGraphicalOutput();
+
+    matrixg.AddColumn("cos(MMcEvt.fTelescopeTheta)");
+    matrixg.AddColumn("MSigmabar.fSigmabar");
+    matrixg.AddColumn("log10(MHillas.fSize)");
+    matrixg.AddColumn("MHillasSrc.fDist");
+    matrixg.AddColumn("MHillas.fWidth");
+    matrixg.AddColumn("MHillas.fLength");
+    matrixg.AddColumn("log10(MHillas.fSize/(MHillas.fWidth*MHillas.fLength))");
+    matrixg.AddColumn("sgn(MHillasSrc.fCosDeltaAlpha)*(MHillasExt.fM3Long)");
+    matrixg.AddColumn("MNewImagePar.fConc");
+    matrixg.AddColumn("MNewImagePar.fLeakage1");
+
+    MHMatrix matrixh("MatrixHadrons");
+    matrixh.EnableGraphicalOutput();
+
+    matrixh.AddColumns(matrixg.GetColumns());
+
+    //--------------------------------------------
+    // file of trees of the random forest 
+
+    TString outRF = outPath;
+    outRF += "RF.root";
+
+
+   //*************************************************************************
+   // read in matrices of training events
+if (RTrainRF)
+  {
+    const char* mtxName = "MatrixGammas";
+
+    gLog << "" << endl;
+    gLog << "========================================================" << endl;
+    gLog << "Get matrix for (gammas)" << endl;
+    gLog << "matrix name        = " << mtxName << endl;
+    gLog << "name of root file  = " << NameGammas << endl;
+    gLog << "" << endl;
+
+
+    // read in the object with the name 'mtxName' from file 'NameGammas'
+    //
+    TFile fileg(NameGammas); 
+
+    matrixg.Read(mtxName);
+    matrixg.Print("SizeCols");
+
+
+    //***************************************************************** 
+
+    const char* mtxName = "MatrixHadrons";
+
+    gLog << "" << endl;
+    gLog << "========================================================" << endl;
+    gLog << " Get matrix for (hadrons)" << endl;
+    gLog << "matrix name        = " << mtxName << endl;
+    gLog << "name of root file  = " << NameHadrons << endl;
+    gLog << "" << endl;
+
+
+    // read in the object with the name 'mtxName' from file 'NameHadrons'
+    //
+    TFile fileh(NameHadrons); 
+
+    matrixh.Read(mtxName);
+    matrixh.Print("SizeCols");
+  }
+
+
+   //*************************************************************************
+   // create matrices of training events
+   // and root files of training and test events
+ 
+if (CTrainRF)
+  {
+    gLog << "" << endl;
+    gLog << "========================================================" << endl;
+    gLog << " Create matrices of training events and root files of training and test events" 
+         << endl;
+    gLog << " Gammas :" << endl;
+    gLog << "---------" << endl;
+
+    MParList  plistg;
+    MTaskList tlistg;
+
+    MReadMarsFile  readg("Events", filenameMC);
+    readg.DisableAutoScheme();
+
+    TString mgname("costhg");
+    MBinning bing("Binning"+mgname);
+    bing.SetEdges(10, 0., 1.0);
+
+    MH3 gref("cos(MMcEvt.fTelescopeTheta)");
+    gref.SetName(mgname);
+    MH::SetBinning(&gref.GetHist(), &bing);
+    //for (Int_t i=1; i<=gref.GetNbins(); i++)
+    //  gref.GetHist().SetBinContent(i, 1.0);
+
+    MFEventSelector2 selectorg(gref);
+    selectorg.SetNumMax(howManyGammasTrain+howManyGammasTest);
+    selectorg.SetName("selectGammasTrainTest");
+    selectorg.SetInverted();
+    //selectorg.SetUseOrigDistribution(kTRUE);
+
+    MContinue contg(&selectorg);
+    contg.SetName("ContGammas");
+
+    Double_t probg = ( (Double_t) howManyGammasTrain )
+                   / ( (Double_t)(howManyGammasTrain+howManyGammasTest) );
+    MFRandomSplit splitg(probg);
+
+    MFillH fillmatg("MatrixGammas");
+    fillmatg.SetFilter(&splitg);
+    fillmatg.SetName("fillGammas");
+
+    //-----------------------
+    // for writing the root files of training and test events
+    // for gammas
+    
+    MWriteRootFile writetraing(inNameGammasTrain, "RECREATE");
+    writetraing.SetName("WriteGammasTrain");
+    writetraing.SetFilter(&splitg);
+
+      writetraing.AddContainer("MRawRunHeader", "RunHeaders");
+      writetraing.AddContainer("MTime",         "Events");
+      writetraing.AddContainer("MMcEvt",        "Events");
+      writetraing.AddContainer("ThetaOrig",     "Events");
+      writetraing.AddContainer("MSrcPosCam",    "Events");
+      writetraing.AddContainer("MSigmabar",     "Events");
+      writetraing.AddContainer("MHillas",       "Events");
+      writetraing.AddContainer("MHillasExt",    "Events");
+      writetraing.AddContainer("MHillasSrc",    "Events");
+      writetraing.AddContainer("MNewImagePar",  "Events");
+
+    MContinue contgtrain(&splitg);
+    contgtrain.SetName("ContGammaTrain");
+
+    MWriteRootFile writetestg(inNameGammasTest, "RECREATE");
+    writetestg.SetName("WriteGammasTest");
+
+      writetestg.AddContainer("MRawRunHeader", "RunHeaders");
+      writetestg.AddContainer("MTime",         "Events");
+      writetestg.AddContainer("MMcEvt",        "Events");
+      writetestg.AddContainer("ThetaOrig",     "Events");
+      writetestg.AddContainer("MSrcPosCam",    "Events");
+      writetestg.AddContainer("MSigmabar",     "Events");
+      writetestg.AddContainer("MHillas",       "Events");
+      writetestg.AddContainer("MHillasExt",    "Events");
+      writetestg.AddContainer("MHillasSrc",    "Events");
+      writetestg.AddContainer("MNewImagePar",  "Events");
+
+    //-----------------------
+    
+    //*****************************   fill gammas   ***  
+    // entries in MParList
+    
+    plistg.AddToList(&tlistg);
+    InitBinnings(&plistg);
+
+    plistg.AddToList(&matrixg);
+
+    //*****************************
+    // entries in MTaskList
+    
+    tlistg.AddToList(&readg);
+    tlistg.AddToList(&contg);
+
+    tlistg.AddToList(&splitg);
+    tlistg.AddToList(&fillmatg);
+    tlistg.AddToList(&writetraing);
+    tlistg.AddToList(&contgtrain);
+
+    tlistg.AddToList(&writetestg);
+
+    //*****************************
+
+    MProgressBar matrixbar;
+    MEvtLoop evtloopg;
+    evtloopg.SetName("FillGammaMatrix");
+    evtloopg.SetParList(&plistg);
+    //evtloopg.ReadEnv(env, "", printEnv);
+    evtloopg.SetProgressBar(&matrixbar);
+
+    Int_t maxevents = -1;
+    if (!evtloopg.Eventloop(maxevents))
+        return;
+
+    tlistg.PrintStatistics(0, kTRUE);
+
+    matrixg.Print("SizeCols");
+    Int_t generatedgTrain = matrixg.GetM().GetNrows();
+    if ( fabs(generatedgTrain-howManyGammasTrain) > 
+                                    3.0*sqrt(howManyGammasTrain) )
+    {
+      gLog << "ONOFFCT1Analysis.C : no.of generated gamma training events (" 
+           << generatedgTrain << ") is incompatible with the no.of requested events (" 
+           << howManyGammasTrain << ")" << endl;   
+    }
+
+
+    Int_t generatedgTest = writetestg.GetNumExecutions();
+    if ( fabs(generatedgTest-howManyGammasTest) > 
+                                    3.0*sqrt(howManyGammasTest) )
+    {
+      gLog << "ONOFFCT1Analysis.C : no.of generated gamma test events (" 
+           << generatedgTest << ") is incompatible with the no.of requested events (" 
+           << howManyGammasTest << ")" << endl;   
+    }
+
+    //*****************************   fill hadrons   ***  
+    gLog << "---------------------------------------------------------------"
+         << endl;
+    gLog << " Hadrons :" << endl;
+    gLog << "----------" << endl;
+
+    MParList  plisth;
+    MTaskList tlisth;
+
+    MReadMarsFile  readh("Events", filenameHad);
+    readh.DisableAutoScheme();
+
+    TString mhname("costhh");
+    MBinning binh("Binning"+mhname);
+    binh.SetEdges(10, 0., 1.0);
+
+    //MH3 href("cos(MMcEvt.fTelescopeTheta)");
+    //href.SetName(mhname);
+    //MH::SetBinning(&href.GetHist(), &binh);
+    //for (Int_t i=1; i<=href.GetNbins(); i++)
+    //  href.GetHist().SetBinContent(i, 1.0);
+
+    //use the original distribution from the gammas
+    MH3 &href = *(selectorg.GetHistOrig());
+
+    MFEventSelector2 selectorh(href);
+    selectorh.SetNumMax(howManyHadronsTrain+howManyHadronsTest);
+    selectorh.SetName("selectHadronsTrainTest");
+    selectorh.SetInverted();
+
+    MContinue conth(&selectorh);
+    conth.SetName("ContHadrons");
+
+    Double_t probh = ( (Double_t) howManyHadronsTrain )
+                   / ( (Double_t)(howManyHadronsTrain+howManyHadronsTest) );
+    MFRandomSplit splith(probh);
+
+    MFillH fillmath("MatrixHadrons");
+    fillmath.SetFilter(&splith);
+    fillmath.SetName("fillHadrons");
+
+    //-----------------------
+    // for writing the root files of training and test events
+    // for hadrons
+    
+    MWriteRootFile writetrainh(inNameHadronsTrain, "RECREATE");
+    writetrainh.SetName("WriteHadronsTrain");
+    writetrainh.SetFilter(&splith);
+
+      writetrainh.AddContainer("MRawRunHeader", "RunHeaders");
+      writetrainh.AddContainer("MTime",         "Events");
+      writetrainh.AddContainer("MMcEvt",        "Events");
+      writetrainh.AddContainer("ThetaOrig",     "Events");
+      writetrainh.AddContainer("MSrcPosCam",    "Events");
+      writetrainh.AddContainer("MSigmabar",     "Events");
+      writetrainh.AddContainer("MHillas",       "Events");
+      writetrainh.AddContainer("MHillasExt",    "Events");
+      writetrainh.AddContainer("MHillasSrc",    "Events");
+      writetrainh.AddContainer("MNewImagePar",  "Events");
+
+    MContinue conthtrain(&splith);
+
+    MWriteRootFile writetesth(inNameHadronsTest, "RECREATE");
+    writetesth.SetName("WriteHadronsTest");
+
+      writetesth.AddContainer("MRawRunHeader", "RunHeaders");
+      writetesth.AddContainer("MTime",         "Events");
+      writetesth.AddContainer("MMcEvt",        "Events");
+      writetesth.AddContainer("ThetaOrig",     "Events");
+      writetesth.AddContainer("MSrcPosCam",    "Events");
+      writetesth.AddContainer("MSigmabar",     "Events");
+      writetesth.AddContainer("MHillas",       "Events");
+      writetesth.AddContainer("MHillasExt",    "Events");
+      writetesth.AddContainer("MHillasSrc",    "Events");
+      writetesth.AddContainer("MNewImagePar",  "Events");
+
+
+    //*****************************  
+    // entries in MParList
+    
+    plisth.AddToList(&tlisth);
+    InitBinnings(&plisth);
+
+    plisth.AddToList(&matrixh);
+
+    //*****************************
+    // entries in MTaskList
+    
+    tlisth.AddToList(&readh);
+    tlisth.AddToList(&conth);
+
+    tlisth.AddToList(&splith);
+    tlisth.AddToList(&fillmath);
+    tlisth.AddToList(&writetrainh);
+    tlisth.AddToList(&conthtrain);
+
+    tlisth.AddToList(&writetesth);
+
+    //*****************************
+
+    MProgressBar matrixbar;
+    MEvtLoop evtlooph;
+    evtlooph.SetName("FillHadronMatrix");
+    evtlooph.SetParList(&plisth);
+    //evtlooph.ReadEnv(env, "", printEnv);
+    evtlooph.SetProgressBar(&matrixbar);
+
+    Int_t maxevents = -1;
+    if (!evtlooph.Eventloop(maxevents))
+        return;
+
+    tlisth.PrintStatistics(0, kTRUE);
+
+    matrixh.Print("SizeCols");
+    Int_t generatedhTrain = matrixh.GetM().GetNrows();
+    if ( fabs(generatedhTrain-howManyHadronsTrain) > 
+                                    3.0*sqrt(howManyHadronsTrain) )
+    {
+      gLog << "ONOFFCT1Analysis.C : no.of generated hadron training events (" 
+           << generatedhTrain << ") is incompatible with the no.of requested events (" 
+           << howManyHadronsTrain << ")" << endl;   
+    }
+
+
+    Int_t generatedhTest = writetesth.GetNumExecutions();
+    if ( fabs(generatedhTest-howManyHadronsTest) > 
+                                    3.0*sqrt(howManyHadronsTest) )
+    {
+      gLog << "ONOFFCT1Analysis.C : no.of generated gamma test events (" 
+           << generatedhTest << ") is incompatible with the no.of requested events (" 
+           << howManyHadronsTest << ")" << endl;   
+    }
+
+
+    //*****************************************************  
+
+
+    // write out matrices of training events 
+
+    gLog << "" << endl;
+    gLog << "========================================================" << endl;
+    gLog << "Write out matrices of training events" << endl;
+
+
+      //-------------------------------------------
+      // "gammas"
+      gLog << "Gammas :" << endl;    
+      matrixg.Print("SizeCols");
+
+      TFile writeg(NameGammas, "RECREATE", "");
+      matrixg.Write();
+
+      gLog << "" << endl;
+      gLog << "Macro CT1Analysis : matrix of training events for gammas written onto file "
+           << NameGammas << endl;
+
+      //-------------------------------------------
+      // "hadrons"
+      gLog << "Hadrons :" << endl;    
+      matrixh.Print("SizeCols");
+
+      TFile writeh(NameHadrons, "RECREATE", "");
+      matrixh.Write();
+
+      gLog << "" << endl;
+      gLog << "Macro CT1Analysis : matrix of training events for hadrons written onto file "
+           << NameHadrons << endl;
+
+  }
+   //**********   end of creating matrices of training events   ***********
+
+
+    MRanForest *fRanForest;
+    MRanTree *fRanTree;
+    //-----------------------------------------------------------------
+    // read in the trees of the random forest 
+    if (RTree)
+    {
+      MParList plisttr;
+      MTaskList tlisttr;
+      plisttr.AddToList(&tlisttr);
+
+      MReadTree readtr("TREE", outRF);
+      readtr.DisableAutoScheme();
+
+      MRanForestFill rffill;
+      rffill.SetNumTrees(NumTrees);
+
+      // list of tasks for the loop over the trees
+
+      tlisttr.AddToList(&readtr);
+      tlisttr.AddToList(&rffill);
+
+      //-------------------
+      // Execute tree loop
+      //
+      MEvtLoop evtlooptr;
+      evtlooptr.SetName("ReadRFTrees");
+      evtlooptr.SetParList(&plisttr);
+      if (!evtlooptr.Eventloop())
+        return;
+
+      tlisttr.PrintStatistics(0, kTRUE);
+
+      gLog << "ONOFFCT1Analysis : RF trees were read in from file "
+           << outRF << endl;
+
+    // get adresses of objects which are used in the next eventloop
+    fRanForest = (MRanForest*)plisttr->FindObject("MRanForest");
+    if (!fRanForest)
+    {
+        gLog << err << dbginf << "MRanForest not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fRanTree = (MRanTree*)plisttr->FindObject("MRanTree");
+    if (!fRanTree)                                  
+    {                                                                          
+        gLog << err << dbginf << "MRanTree not found... aborting." << endl;    
+        return kFALSE;
+    }
+
+    }
+
+    //-----------------------------------------------------------------
+    // grow the trees of the random forest (event loop = tree loop)
+
+    if (!RTree)
+    {
+
+    gLog << "" << endl;
+    gLog << "========================================================" << endl;
+    gLog << "Macro CT1Analysis : start growing trees" << endl;
+
+    MTaskList tlist2;
+    MParList plist2;
+    plist2.AddToList(&tlist2);
+
+    plist2.AddToList(&matrixg);
+    plist2.AddToList(&matrixh);
+
+    MRanForestGrow rfgrow2;
+    rfgrow2.SetNumTrees(NumTrees);
+    rfgrow2.SetNumTry(NumTry);
+    rfgrow2.SetNdSize(NdSize);
+
+    MWriteRootFile rfwrite2(outRF);
+    rfwrite2.AddContainer("MRanTree", "TREE");
+
+    MFillH fillh2("MHRanForestGini");
+
+    // list of tasks for the loop over the trees
+    
+    tlist2.AddToList(&rfgrow2);
+    tlist2.AddToList(&rfwrite2);
+    tlist2.AddToList(&fillh2);
+
+    //-------------------
+    // Execute tree loop
+    //
+    MEvtLoop treeloop;
+    treeloop.SetName("GrowRFTrees");
+    treeloop.SetParList(&plist2);
+
+    if ( !treeloop.Eventloop() )
+        return;
+
+    tlist2.PrintStatistics(0, kTRUE);
+
+    plist2.FindObject("MHRanForestGini")->DrawClone();
+
+
+    // get adresses of objects which are used in the next eventloop
+    fRanForest = (MRanForest*)plist2->FindObject("MRanForest");
+    if (!fRanForest)
+    {
+        gLog << err << dbginf << "MRanForest not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fRanTree = (MRanTree*)plist2->FindObject("MRanTree");
+    if (!fRanTree)                                  
+    {                                                                          
+        gLog << err << dbginf << "MRanTree not found... aborting." << endl;    
+        return kFALSE;
+    }
+
+    }
+    // end of growing the trees of the random forest
+    //-----------------------------------------------------------------
+
+
+    //-----------------------------------------------------------------
+    // Update the root files with the RF hadronness
+    //
+
+ if (WRF)
+  {
+    //TString fileName(inNameHadronsTrain);
+    //TString outName(outNameHadronsTrain);
+
+    //TString fileName(inNameHadronsTest);
+    //TString outName(outNameHadronsTest);
+
+    //TString fileName(inNameGammasTrain);
+    //TString outName(outNameGammasTrain);
+
+    //TString fileName(inNameGammasTest);
+    //TString outName(outNameGammasTest);
+
+    TString fileName(inNameData);
+    TString outName(outNameData);
+
+
+
+    gLog << "" << endl;
+    gLog << "========================================================" << endl;
+    gLog << "Update root file '" <<  fileName 
+         << "' with the RF hadronness; ==> " << outName << endl;
+
+   
+    MTaskList tliston;
+    MParList pliston;
+
+
+    // geometry is needed in  MHHillas... classes 
+    MGeomCam *fGeom = 
+             (MGeomCam*)pliston->FindCreateObj("MGeomCamCT1", "MGeomCam");
+
+    //-------------------------------------------
+    // create the tasks which should be executed 
+    //
+
+    MReadMarsFile read("Events", fileName);
+    read.DisableAutoScheme();
+
+
+    //.......................................................................
+    // calculate hadronnes for method of RANDOM FOREST
+
+
+    MRanForestCalc rfcalc;
+    rfcalc.SetHadronnessName(hadRFName);
+
+
+    //.......................................................................
+
+      //MWriteRootFile write(outName, "UPDATE");
+      MWriteRootFile write(outName, "RECREATE");
+
+      write.AddContainer("MRawRunHeader", "RunHeaders");
+      write.AddContainer("MTime",         "Events");
+      write.AddContainer("MMcEvt",        "Events");
+      write.AddContainer("ThetaOrig",     "Events");
+      write.AddContainer("MSrcPosCam",    "Events");
+      write.AddContainer("MSigmabar",     "Events");
+      write.AddContainer("MHillas",       "Events");
+      write.AddContainer("MHillasExt",    "Events");
+      write.AddContainer("MHillasSrc",    "Events");
+      write.AddContainer("MNewImagePar",  "Events");
+
+      write.AddContainer(hadRFName,       "Events");
+
+    //-----------------------------------------------------------------
+
+
+    MFCT1SelFinal selfinalgh(fHilNameSrc);
+    selfinalgh.SetCuts(maxhadronness, 100.0, maxdist);
+    selfinalgh.SetHadronnessName(hadRFName);
+    selfinalgh.SetName("SelFinalgh");
+    MContinue contfinalgh(&selfinalgh);
+    contfinalgh.SetName("ContSelFinalgh");
+
+    MFillH fillranfor("MHRanForest");
+    fillranfor.SetName("HRanForest");
+
+    MFillH fillhadrf("hadRF[MHHadronness]", hadRFName);
+    fillhadrf.SetName("HhadRF");
+
+    MFCT1SelFinal selfinal(fHilNameSrc);
+    selfinal.SetCuts(maxhadronness, maxalpha, maxdist);
+    selfinal.SetHadronnessName(hadRFName);
+    selfinal.SetName("SelFinal");
+    MContinue contfinal(&selfinal);
+    contfinal.SetName("ContSelFinal");
+
+    TString mh3name = "abs(Alpha)";
+    MBinning binsalphaabs("Binning"+mh3name);
+    binsalphaabs.SetEdges(50, -2.0, 98.0);
+
+    MH3 alphaabs("abs(MHillasSrc.fAlpha)");
+    alphaabs.SetName(mh3name);
+    MFillH alpha(&alphaabs);
+    alpha.SetName("FillAlphaAbs");
+
+
+    MFillH hfill1("MHHillas",    fHilName);
+    hfill1.SetName("HHillas");
+
+    MFillH hfill2("MHStarMap",   fHilName);
+    hfill2.SetName("HStarMap");
+
+    MFillH hfill3("MHHillasExt",    fHilNameSrc);
+    hfill3.SetName("HHillasExt");
+    
+    MFillH hfill4("MHHillasSrc",   fHilNameSrc);
+    hfill4.SetName("HHillasSrc");    
+
+    MFillH hfill5("MHNewImagePar", fImgParName);
+    hfill5.SetName("HNewImagePar");
+
+    //*****************************
+    // entries in MParList
+
+    pliston.AddToList(&tliston);
+    InitBinnings(&pliston);
+
+    pliston.AddToList(fRanForest);
+    pliston.AddToList(fRanTree);
+
+    pliston.AddToList(&binsalphaabs);
+    pliston.AddToList(&alphaabs);
+
+
+    //*****************************
+    // entries in MTaskList
+    
+    tliston.AddToList(&read);
+
+    tliston.AddToList(&rfcalc);
+    tliston.AddToList(&fillranfor);
+    tliston.AddToList(&fillhadrf);
+
+    tliston.AddToList(&write);
+    tliston.AddToList(&contfinalgh);
+
+    tliston.AddToList(&alpha);
+    tliston.AddToList(&hfill1);
+    tliston.AddToList(&hfill2);
+    tliston.AddToList(&hfill3);
+    tliston.AddToList(&hfill4);
+    tliston.AddToList(&hfill5);
+
+    tliston.AddToList(&contfinal);
+
+    //*****************************
+
+    //-------------------------------------------
+    // Execute event loop
+    //
+    MProgressBar bar;
+    MEvtLoop evtloop;
+    evtloop.SetName("UpdateRootFile");
+    evtloop.SetParList(&pliston);
+    evtloop.SetProgressBar(&bar);
+
+    Int_t maxevents = -1;
+    if ( !evtloop.Eventloop(maxevents) )
+        return;
+
+    tliston.PrintStatistics(0, kTRUE);
+
+
+    //-------------------------------------------
+    // Display the histograms
+    //
+    pliston.FindObject("MHRanForest")->DrawClone();
+    pliston.FindObject("hadRF", "MHHadronness")->DrawClone();
+    pliston.FindObject("hadRF", "MHHadronness")->Print();
+
+    pliston.FindObject("MHHillas")->DrawClone();
+    pliston.FindObject("MHHillasExt")->DrawClone();
+    pliston.FindObject("MHHillasSrc")->DrawClone();
+    pliston.FindObject("MHNewImagePar")->DrawClone();
+    pliston.FindObject("MHStarMap")->DrawClone();
+
+
+     //-------------------------------------------
+    // fit alpha distribution to get the number of excess events and
+    // calculate significance of gamma signal in the alpha plot
+  
+    MH3* absalpha = (MH3*)(pliston.FindObject(mh3name, "MH3"));
+    TH1  &alphaHist = absalpha->GetHist();
+    alphaHist.SetXTitle("|alpha|  [\\circ]");
+    alphaHist.SetName("alpha-macro");
+
+    Double_t alphasig = 13.1;
+    Double_t alphamin = 30.0;
+    Double_t alphamax = 90.0;
+    Int_t    degree   =    2;
+    Double_t significance = -99.0;
+    Bool_t   drawpoly  = kTRUE;
+    Bool_t   fitgauss  = kTRUE;
+    Bool_t   print     = kTRUE;
+
+    MHFindSignificance findsig;
+    findsig.SetRebin(kTRUE);
+    findsig.SetReduceDegree(kFALSE);
+
+    findsig.FindSigma(&alphaHist, alphamin, alphamax, degree, 
+                        alphasig, drawpoly, fitgauss, print);
+    significance = findsig.GetSignificance();
+    Float_t alphasi = findsig.GetAlphasi();
+
+    gLog << "For file '" << fileName << "' : " << endl;
+    gLog << "Significance of gamma signal after supercuts : "
+         << significance << " (for |alpha| < " << alphasi << " degrees)" 
+         << endl;
+
+    findsig.SigmaVsAlpha(&alphaHist, alphamin, alphamax, degree, print);
+
+    //-------------------------------------------
+
+
+    DeleteBinnings(&pliston);
+  }
+
+    gLog << "Macro CT1Analysis : End of Job B_RF_UP" << endl;
+    gLog << "=======================================================" << endl;
+ }
+  //---------------------------------------------------------------------
+
+
+  //---------------------------------------------------------------------
+  // Job B_SC_UP
+  //============
+
+    //  - create (or read in) optimum supercuts parameter values
+    //
+    //  - calculate the hadroness for the supercuts
+    //
+    //  - update input root file, including the hadroness
+
+
+ if (JobB_SC_UP)
+ {
+    gLog << "=====================================================" << endl;
+    gLog << "Macro CT1Analysis : Start of Job B_SC_UP" << endl;
+
+    gLog << "" << endl;
+    gLog << "Macro CT1Analysis : JobB_SC_UP, CMatrix, RMatrix, WOptimize, RTest, WSC = "
+         << (JobB_SC_UP ? "kTRUE" : "kFALSE")  << ",  " 
+         << (CMatrix    ? "kTRUE" : "kFALSE")  << ",  "
+         << (RMatrix    ? "kTRUE" : "kFALSE")  << ",  "
+         << (WOptimize  ? "kTRUE" : "kFALSE")  << ",  "
+         << (RTest      ? "kTRUE" : "kFALSE")  << ",  "
+         << (WSC        ? "kTRUE" : "kFALSE")  << endl;
+
+
+    //--------------------------------------------
+    // file which contains the initial parameter values for the supercuts 
+    // if parSCinit ="" the initial values are taken from the constructor of
+    //                  MCT1Supercuts
+
+    TString parSCinit = outPath;
+    //parSCinit += "parSC_1709d";
+    parSCinit = "";
+
+    gLog << "parSCinit = " << parSCinit << endl;
+
+    //---------------
+    // file onto which the optimal parameter values for the supercuts 
+    // are written
+
+    TString parSCfile = outPath;
+    parSCfile += "parSC_2310a";
+
+    gLog << "parSCfile = " << parSCfile << endl;
+
+    //--------------------------------------------
+    // file to be updated (either ON or MC)
+
+    //TString typeInput = "ON";
+    //TString typeInput = "OFF";
+    TString typeInput = "MC";
+    gLog << "typeInput = " << typeInput << endl;
+
+    // name of input root file
+    TString filenameData = outPath;
+    filenameData += typeInput;
+    filenameData += "2.root";
+    gLog << "filenameData = " << filenameData << endl; 
+
+    // name of output root file
+    TString outNameImage = outPath;
+    outNameImage += typeInput;
+    outNameImage += "3.root";
+    
+
+    //TString outNameImage = filenameData;
+
+    gLog << "outNameImage = " << outNameImage << endl; 
+
+    //--------------------------------------------
+    // files to be read for optimizing the supercuts
+    // 
+    // for the training
+    TString filenameTrain = outPath;
+    filenameTrain += "ON";
+    filenameTrain += "1.root";
+    Int_t howManyTrain = 800000;
+    gLog << "filenameTrain = " << filenameTrain << ",   howManyTrain = "
+         << howManyTrain  << endl; 
+
+    // for testing
+    TString filenameTest = outPath;
+    filenameTest += "ON";
+    filenameTest += "1.root";
+    Int_t howManyTest = 800000;
+
+    gLog << "filenameTest = " << filenameTest << ",   howManyTest = "
+         << howManyTest  << endl; 
+    
+
+    //--------------------------------------------
+    // files to contain the matrices (generated from filenameTrain and
+    //                                               filenameTest)
+    // 
+    // for the training
+    TString fileMatrixTrain = outPath;
+    fileMatrixTrain += "MatrixTrainSC";
+    fileMatrixTrain += ".root";
+    gLog << "fileMatrixTrain = " << fileMatrixTrain << endl; 
+
+    // for testing
+    TString fileMatrixTest = outPath;
+    fileMatrixTest += "MatrixTestSC";
+    fileMatrixTest += ".root";
+    gLog << "fileMatrixTest = " << fileMatrixTest << endl; 
+
+    
+
+    //---------------------------------------------------------------------
+    // Training and test matrices :
+    // - either create them and write them onto a file
+    // - or read them from a file
+
+
+    MCT1FindSupercuts findsuper;
+    findsuper.SetFilenameParam(parSCfile);
+    findsuper.SetHadronnessName("HadSC");
+    //findsuper.SetUseOrigDistribution(kTRUE);
+
+    //--------------------------
+    // create matrices and write them onto files 
+    if (CMatrix)
+    {
+      TString mname("costheta");
+      MBinning bin("Binning"+mname);
+      bin.SetEdges(10, 0., 1.0);
+
+      MH3 mh3("cos(MMcEvt.fTelescopeTheta)");
+      mh3.SetName(mname);
+      MH::SetBinning(&mh3.GetHist(), &bin);
+      //for (Int_t i=1; i<=mh3.GetNbins(); i++)
+      //  mh3.GetHist().SetBinContent(i, 1.0);
+
+
+      if (filenameTrain == filenameTest)
+      {
+        if ( !findsuper.DefineTrainTestMatrix(
+                              filenameTrain,   mh3, 
+                              howManyTrain,    howManyTest,  
+                              fileMatrixTrain, fileMatrixTest)     )
+        {
+          *fLog << "CT1Analysis.C : DefineTrainTestMatrix failed" << endl;
+          return;
+        }
+
+      }
+      else
+      {
+        if ( !findsuper.DefineTrainMatrix(filenameTrain, mh3,
+                                          howManyTrain,  fileMatrixTrain) )
+        {
+          *fLog << "CT1Analysis.C : DefineTrainMatrix failed" << endl;
+          return;
+        }
+
+	if ( !findsuper.DefineTestMatrix( filenameTest, mh3, 
+                                          howManyTest,  fileMatrixTest)  )
+        {
+          *fLog << "CT1Analysis.C : DefineTestMatrix failed" << endl;
+          return;
+        }
+      }
+     }
+
+    //--------------------------
+    // read matrices from files
+    //                              
+
+    if (RMatrix)
+      findsuper.ReadMatrix(fileMatrixTrain, fileMatrixTest);
+    //--------------------------
+
+
+
+    //---------------------------------------------------------------------
+    // optimize supercuts using the training sample
+    // 
+    // the initial values are taken 
+    //     - from the file parSCinit (if != "")
+    //     - or from the arrays params and steps (if their sizes are != 0)
+    //     - or from the MCT1Supercuts constructor
+
+
+if (WOptimize)
+  {
+    gLog << "CT1Analysis.C : optimize the supercuts using the training matrix" 
+         << endl;
+
+    TArrayD params(0);
+    TArrayD steps(0);
+  
+    if (parSCinit == "")
+    {
+      Double_t vparams[104] = {
+      // LengthUp
+	0.315585,  0.001455, 0.203198, 0.005532, -0.001670, -0.020362,
+	0.007388, -0.013463,
+      // LengthLo
+        0.151530,  0.028323, 0.510707, 0.053089,  0.013708,  2.357993,
+	0.000080, -0.007157,
+      // WidthUp
+        0.145412, -0.001771, 0.054462, 0.022280, -0.009893,  0.056353,
+        0.020711, -0.016703,
+      // WidthLo
+        0.089187, -0.006430, 0.074442, 0.003738, -0.004256, -0.014101,
+        0.006126, -0.002849,
+      // DistUp
+        1.787943,  0.0,      2.942310, 0.199815,  0.0,       0.249909,
+        0.189697,  0.0,
+      // DistLo
+        0.589406,  0.0,     -0.083964,-0.007975,  0.0,       0.045374,
+       -0.001750,  0.0,
+      // AsymUp
+        1.e10,     0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // AsymLo
+       -1.e10,     0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // ConcUp
+        1.e10,     0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // ConcLo
+       -1.e10,     0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // Leakage1Up
+        1.e10,     0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // Leakage1Lo
+       -1.e10,     0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // AlphaUp
+	13.12344,  0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0                                                 };
+
+      Double_t vsteps[104] = {
+      // LengthUp
+        0.03,      0.0002,   0.02,     0.0006,    0.0002,    0.002,
+        0.0008,    0.002,
+      // LengthLo
+        0.02,      0.003,    0.05,     0.006,     0.002,     0.3,
+        0.0001,    0.0008,
+      // WidthUp
+        0.02,      0.0002,   0.006,    0.003,     0.002,     0.006,
+        0.002,     0.002,
+      // WidthLo
+        0.009,     0.0007,   0.008,    0.0004,    0.0005,    0.002,
+        0.0007,    0.003,
+      // DistUp
+        0.2,       0.0,      0.3,      0.02,      0.0,       0.03,
+        0.02,      0.0
+      // DistLo
+        0.06,      0.0,      0.009,    0.0008,    0.0,       0.005,
+        0.0002,    0.0
+      // AsymUp  
+        0.0,       0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // AsymLo  
+        0.0,       0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // ConcUp  
+        0.0,       0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // ConcLo  
+        0.0,       0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // Leakage1Up  
+        0.0,       0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // Leakage1Lo  
+        0.0,       0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0,
+      // AlphaUp  
+        0.0,       0.0,      0.0,      0.0,       0.0,       0.0,
+        0.0,       0.0                                                 };
+
+      params.Set(104, vparams);
+      steps.Set (104, vsteps );
+    }
+
+    Bool_t rf;
+    rf = findsuper.FindParams(parSCinit, params, steps);
+
+    if (!rf) 
+    {
+       gLog << "CT1Analysis.C : optimization of supercuts failed" << endl;
+       return;
+    }
+  }
+
+    //--------------------------------------
+    // test the supercuts on the test sample
+    //    
+
+ if (RTest)
+ {
+    gLog << "CT1Analysis.C : test the supercuts on the test matrix" << endl;
+    Bool_t rt = findsuper.TestParams();
+    if (!rt) 
+    {
+       gLog << "CT1Analysis.C : test of supercuts on the test matrix failed" 
+            << endl;
+    }
+
+ }
+
+
+    //-----------------------------------------------------------------
+    // Update the input files with the SC hadronness
+    //
+
+ if (WSC)
+ {
+    gLog << "" << endl;
+    gLog << "========================================================" << endl;
+    gLog << "Update input file '" <<  filenameData 
+         << "' with the SC hadronness" << endl;
+
+
+    //----------------------------------------------------
+    // read in optimum parameter values for the supercuts
+
+    TFile inparam(parSCfile);
+    MCT1Supercuts scin;
+    scin.Read("MCT1Supercuts");
+    inparam.Close();
+
+    gLog << "Parameter values for supercuts were read in from file '"
+         << parSCfile << "'" << endl;
+
+    TArrayD supercutsPar;
+    supercutsPar =  scin.GetParameters();
+
+    TArrayD supercutsStep;
+    supercutsStep =  scin.GetStepsizes();
+
+    gLog << "Parameter values for supercuts : " << endl;
+    for (Int_t i=0; i<supercutsPar.GetSize(); i++)
+    {
+      gLog << supercutsPar[i] << ",  ";
+    }
+    gLog << endl;
+
+    gLog << "Step values for supercuts : " << endl;
+    for (Int_t i=0; i<supercutsStep.GetSize(); i++)
+    {
+      gLog << supercutsStep[i] << ",  ";
+    }
+    gLog << endl;
+
+
+    //----------------------------------------------------
+    MTaskList tliston;
+    MParList pliston;
+
+    // set the parameters of the supercuts
+    MCT1Supercuts supercuts;
+    supercuts.SetParameters(supercutsPar);
+    gLog << "parameter values for the supercuts used for updating the input file ' " 
+         << filenameData << "'" << endl;
+    supercutsPar = supercuts.GetParameters();
+    for (Int_t i=0; i<supercutsPar.GetSize(); i++)
+    {
+      gLog << supercutsPar[i] << ",  ";
+    }
+    gLog << endl;
+
+
+    // geometry is needed in  MHHillas... classes 
+    MGeomCam *fGeom = 
+             (MGeomCam*)pliston->FindCreateObj("MGeomCamCT1", "MGeomCam");
+
+    //-------------------------------------------
+    // create the tasks which should be executed 
+    //
+
+    MReadMarsFile read("Events", filenameData);
+    read.DisableAutoScheme();
+
+    TString fHilName    = "MHillas"; 
+    TString fHilNameExt = "MHillasExt"; 
+    TString fHilNameSrc = "MHillasSrc"; 
+    TString fImgParName = "MNewImagePar"; 
+
+
+    //.......................................................................
+    // calculation of hadroness for the supercuts
+    // (=0.25 if fullfilled, =0.75 otherwise)
+
+    TString hadSCName = "HadSC";
+    MCT1SupercutsCalc sccalc(fHilName, fHilNameSrc);
+    sccalc.SetHadronnessName(hadSCName);
+
+
+    //.......................................................................
+
+
+      //MWriteRootFile write(outNameImage, "UPDATE");
+      //MWriteRootFile write = new MWriteRootFile(outNameImage, "RECREATE");
+
+    
+      MWriteRootFile write(outNameImage, "RECREATE");
+
+      write.AddContainer("MRawRunHeader", "RunHeaders");
+      write.AddContainer("MTime",         "Events");
+      write.AddContainer("MMcEvt",        "Events");
+      write.AddContainer("ThetaOrig",     "Events");
+      write.AddContainer("MSrcPosCam",    "Events");
+      write.AddContainer("MSigmabar",     "Events");
+      write.AddContainer("MHillas",       "Events");
+      write.AddContainer("MHillasExt",    "Events");
+      write.AddContainer("MHillasSrc",    "Events");
+      write.AddContainer("MNewImagePar",  "Events");
+
+      write.AddContainer("HadRF",         "Events");
+      write.AddContainer(hadSCName,       "Events");
+    
+
+    //-----------------------------------------------------------------
+    // geometry is needed in  MHHillas... classes 
+    MGeomCam *fGeom = 
+             (MGeomCam*)pliston->FindCreateObj("MGeomCamCT1", "MGeomCam");
+
+    Float_t maxhadronness =  0.40;
+    Float_t maxalpha      =  20.0;
+    Float_t maxdist       =  10.0;
+
+    MFCT1SelFinal selfinalgh(fHilNameSrc);
+    selfinalgh.SetCuts(maxhadronness, 100.0, maxdist);
+    selfinalgh.SetHadronnessName(hadSCName);
+    selfinalgh.SetName("SelFinalgh");
+    MContinue contfinalgh(&selfinalgh);
+    contfinalgh.SetName("ContSelFinalgh");
+
+    MFillH fillhadsc("hadSC[MHHadronness]", hadSCName);
+    fillhadsc.SetName("HhadSC");
+
+    MFCT1SelFinal selfinal(fHilNameSrc);
+    selfinal.SetCuts(maxhadronness, maxalpha, maxdist);
+    selfinal.SetHadronnessName(hadSCName);
+    selfinal.SetName("SelFinal");
+    MContinue contfinal(&selfinal);
+    contfinal.SetName("ContSelFinal");
+
+    TString mh3name = "abs(Alpha)";
+    MBinning binsalphaabs("Binning"+mh3name);
+    binsalphaabs.SetEdges(50, -2.0, 98.0);
+
+    MH3 alphaabs("abs(MHillasSrc.fAlpha)");
+    alphaabs.SetName(mh3name);
+
+    TH1  &alphahist = alphaabs->GetHist();
+
+    MFillH alpha(&alphaabs);
+    alpha.SetName("FillAlphaAbs");
+
+    MFillH hfill1("MHHillas",    fHilName);
+    hfill1.SetName("HHillas");
+
+    MFillH hfill2("MHStarMap",   fHilName);
+    hfill2.SetName("HStarMap");
+
+    MFillH hfill3("MHHillasExt",    fHilNameSrc);
+    hfill3.SetName("HHillasExt");
+    
+    MFillH hfill4("MHHillasSrc",   fHilNameSrc);
+    hfill4.SetName("HHillasSrc");    
+
+    MFillH hfill5("MHNewImagePar", fImgParName);
+    hfill5.SetName("HNewImagePar");
+
+    //*****************************
+    // entries in MParList
+
+    pliston.AddToList(&tliston);
+    InitBinnings(&pliston);
+
+    pliston.AddToList(&supercuts);
+
+    pliston.AddToList(&binsalphaabs);
+    pliston.AddToList(&alphaabs);
+
+    //*****************************
+    // entries in MTaskList
+    
+    tliston.AddToList(&read);
+
+    tliston.AddToList(&sccalc);
+    tliston.AddToList(&fillhadsc);
+
+    tliston.AddToList(&write);
+    tliston.AddToList(&contfinalgh);
+
+    tliston.AddToList(&alpha);
+    tliston.AddToList(&hfill1);
+    tliston.AddToList(&hfill2);
+    tliston.AddToList(&hfill3);
+    tliston.AddToList(&hfill4);
+    tliston.AddToList(&hfill5);
+
+    tliston.AddToList(&contfinal);
+
+    //*****************************
+
+    //-------------------------------------------
+    // Execute event loop
+    //
+    MProgressBar bar;
+    MEvtLoop evtloop;
+    evtloop.SetParList(&pliston);
+    evtloop.SetProgressBar(&bar);
+
+    Int_t maxevents = -1;
+    if ( !evtloop.Eventloop(maxevents) )
+        return;
+
+    tliston.PrintStatistics(0, kTRUE);
+
+
+    //-------------------------------------------
+    // Display the histograms
+    //
+    pliston.FindObject("hadSC", "MHHadronness")->DrawClone();
+
+    pliston.FindObject("MHHillas")->DrawClone();
+    pliston.FindObject("MHHillasExt")->DrawClone();
+    pliston.FindObject("MHHillasSrc")->DrawClone();
+    pliston.FindObject("MHNewImagePar")->DrawClone();
+    pliston.FindObject("MHStarMap")->DrawClone();
+
+     //-------------------------------------------
+    // fit alpha distribution to get the number of excess events and
+    // calculate significance of gamma signal in the alpha plot
+  
+    MH3* absalpha = (MH3*)(pliston.FindObject(mh3name, "MH3"));
+    TH1  &alphaHist = absalpha->GetHist();
+    alphaHist.SetXTitle("|alpha|  [\\circ]");
+    alphaHist.SetName("alpha-macro");
+
+    Double_t alphasig = 13.1;
+    Double_t alphamin = 30.0;
+    Double_t alphamax = 90.0;
+    Int_t    degree   =    2;
+    Double_t significance = -99.0;
+    Bool_t   drawpoly  = kTRUE;
+    Bool_t   fitgauss  = kTRUE;
+    Bool_t   print     = kTRUE;
+
+    MHFindSignificance findsig;
+    findsig.SetRebin(kTRUE);
+    findsig.SetReduceDegree(kFALSE);
+
+    findsig.FindSigma(&alphaHist, alphamin, alphamax, degree, 
+                        alphasig, drawpoly, fitgauss, print);
+    significance = findsig.GetSignificance();
+    Float_t alphasi = findsig.GetAlphasi();
+
+    gLog << "For file '" << filenameData << "' : " << endl;
+    gLog << "Significance of gamma signal after supercuts : "
+         << significance << " (for |alpha| < " << alphasi << " degrees)" 
+         << endl;
+
+    findsig.SigmaVsAlpha(&alphaHist, alphamin, alphamax, degree, print);
+
+    //-------------------------------------------
+
+    DeleteBinnings(&pliston);
+ }
+
+
+    gLog << "Macro CT1Analysis : End of Job B_SC_UP" << endl;
+    gLog << "=======================================================" << endl;
+ }
+  //---------------------------------------------------------------------
+
+
+
+  //---------------------------------------------------------------------
+  // Job C  
+  //======
+
+    //  - read ON1 and MC1 data files  
+    //    which should have been updated to contain the hadronnesses
+    //    for the method of Random Forest and for the SUPERCUTS
+    //  - produce Neyman-Pearson plots
+ 
+ if (JobC)
+ {
+    gLog << "=====================================================" << endl;
+    gLog << "Macro CT1Analysis : Start of Job C" << endl;
+
+    gLog << "" << endl;
+    gLog << "Macro CT1Analysis : JobC = " 
+         << (JobC ? "kTRUE" : "kFALSE")  << endl;
+
+
+
+    TString ext("2.root");
+    TString extout("2.root");
+
+    TString typeHadrons("OFF");
+    TString typeGammas("MC");
+
+    //--------------------------------------------
+    // name of input data file
+    TString NameData = outPath;
+    NameData += typeHadrons;
+    TString inNameData(NameData);
+    inNameData += ext;
+    gLog << "inNameData   = " << inNameData   << endl;
+
+    // name of input MC file
+    TString NameMC = outPath;
+    NameMC += typeGammas;
+    TString inNameMC(NameMC);
+    inNameMC += ext;
+    gLog << "inNameMC   = " << inNameMC   << endl;
+
+
+    //--------------------------------------------
+    // root files for the training events 
+
+
+
+    TString NameGammasTrain = outPath;
+    NameGammasTrain += "RF_gammas_Train_";
+    NameGammasTrain += typeGammas;
+    TString outNameGammasTrain(NameGammasTrain);    
+    outNameGammasTrain += extout;
+
+
+    TString NameHadronsTrain = outPath;
+    NameHadronsTrain += "RF_hadrons_Train_";
+    NameHadronsTrain += typeHadrons;
+    TString outNameHadronsTrain(NameHadronsTrain);    
+    outNameHadronsTrain += extout;
+
+
+    //--------------------------------------------
+    // root files for the test events 
+
+    TString NameGammasTest = outPath;
+    NameGammasTest += "RF_gammas_Test_";
+    NameGammasTest += typeGammas;
+    TString outNameGammasTest(NameGammasTest);    
+    outNameGammasTest += extout;
+
+    TString NameHadronsTest = outPath;
+    NameHadronsTest += "RF_hadrons_Test_";
+    NameHadronsTest += typeHadrons;
+    TString outNameHadronsTest(NameHadronsTest);    
+    outNameHadronsTest += extout;
+
+    //--------------------------------------------------------------------
+
+    //TString filenameData(inNameData);
+    //TString filenameMC(inNameMC);
+
+    //TString filenameData(outNameHadronsTrain);
+    //TString filenameMC(outNameGammasTrain);
+
+    TString filenameData(outNameHadronsTest);
+    TString filenameMC(outNameGammasTest);
+
+    gLog << "filenameData = " << filenameData << endl;
+    gLog << "filenameMC   = " << filenameMC   << endl;
+
+    //-----------------------------------------------------------------
+
+    MTaskList tliston;
+    MParList pliston;
+
+
+    // geometry is needed in  MHHillas... classes 
+    MGeomCam *fGeom = 
+             (MGeomCam*)pliston->FindCreateObj("MGeomCamCT1", "MGeomCam");
+
+    //-------------------------------------------
+    // create the tasks which should be executed 
+    //
+
+    MReadMarsFile read("Events", filenameMC);
+    read.AddFile(filenameData);
+    read.DisableAutoScheme();
+
+
+    //.......................................................................
+    // names of hadronness containers
+
+    TString hadSCName = "HadSC";
+    TString hadRFName = "HadRF";
+
+    //.......................................................................
+
+
+    TString fHilName    = "MHillas"; 
+    TString fHilNameExt = "MHillasExt"; 
+    TString fHilNameSrc = "MHillasSrc"; 
+    TString fImgParName = "MNewImagePar"; 
+
+    Float_t maxhadronness =  0.40;
+    Float_t maxalpha      =  20.0;
+    Float_t maxdist       =  10.0;
+
+    MFCT1SelFinal selfinalgh(fHilNameSrc);
+    selfinalgh.SetCuts(maxhadronness, 100.0, maxdist);
+    selfinalgh.SetHadronnessName(hadRFName);
+    selfinalgh.SetName("SelFinalgh");
+    MContinue contfinalgh(&selfinalgh);
+    contfinalgh.SetName("ContSelFinalgh");
+
+
+    //MFillH fillhadsc("hadSC[MHHadronness]", hadSCName);
+    //fillhadsc.SetName("HhadSC");
+    MFillH fillhadrf("hadRF[MHHadronness]", hadRFName);
+    fillhadrf.SetName("HhadRF");
+
+    MFCT1SelFinal selfinal(fHilNameSrc);
+    selfinal.SetCuts(maxhadronness, maxalpha, maxdist);
+    selfinal.SetHadronnessName(hadRFName);
+    selfinal.SetName("SelFinal");
+    MContinue contfinal(&selfinal);
+    contfinal.SetName("ContSelFinal");
+
+
+    MFillH hfill1("MHHillas",    fHilName);
+    hfill1.SetName("HHillas");
+
+    MFillH hfill2("MHStarMap",   fHilName);
+    hfill2.SetName("HStarMap");
+
+    MFillH hfill3("MHHillasExt",    fHilNameSrc);
+    hfill3.SetName("HHillasExt");
+    
+    MFillH hfill4("MHHillasSrc",   fHilNameSrc);
+    hfill4.SetName("HHillasSrc");    
+
+    MFillH hfill5("MHNewImagePar", fImgParName);
+    hfill5.SetName("HNewImagePar");
+
+
+    //*****************************
+    // entries in MParList
+
+    pliston.AddToList(&tliston);
+    InitBinnings(&pliston);
+
+
+    //*****************************
+    // entries in MTaskList
+    
+    tliston.AddToList(&read);
+
+    //tliston.AddToList(&fillhadsc);
+    tliston.AddToList(&fillhadrf);
+   
+    tliston.AddToList(&contfinalgh);
+    tliston.AddToList(&hfill1);
+    tliston.AddToList(&hfill2);
+    tliston.AddToList(&hfill3);
+    tliston.AddToList(&hfill4);
+    tliston.AddToList(&hfill5);
+
+    tliston.AddToList(&contfinal);
+
+    //*****************************
+
+    //-------------------------------------------
+    // Execute event loop
+    //
+    MProgressBar bar;
+    MEvtLoop evtloop;
+    evtloop.SetParList(&pliston);
+    evtloop.SetProgressBar(&bar);
+
+    Int_t maxevents = -1;
+    //Int_t maxevents = 35000;
+    if ( !evtloop.Eventloop(maxevents) )
+        return;
+
+    tliston.PrintStatistics(0, kTRUE);
+
+
+    //-------------------------------------------
+    // Display the histograms
+    //
+
+    //pliston.FindObject("hadSC", "MHHadronness")->DrawClone();
+    pliston.FindObject("hadRF", "MHHadronness")->DrawClone();
+
+    pliston.FindObject("MHHillas")->DrawClone();
+    pliston.FindObject("MHHillasExt")->DrawClone();
+    pliston.FindObject("MHHillasSrc")->DrawClone();
+    pliston.FindObject("MHNewImagePar")->DrawClone();
+    pliston.FindObject("MHStarMap")->DrawClone();
+
+    DeleteBinnings(&pliston);
+
+    gLog << "Macro CT1Analysis : End of Job C" << endl;
+    gLog << "===================================================" << endl;
+ }
+
+
+
+  //---------------------------------------------------------------------
+  // Job D
+  //======
+
+    //  - select g/h separation method XX
+    //  - read ON2 (or MC2) root file 
+    //  - apply cuts in hadronness
+    //  - make plots
+
+
+ if (JobD)
+ {
+    gLog << "=====================================================" << endl;
+    gLog << "Macro CT1Analysis : Start of Job D" << endl;
+
+    gLog << "" << endl;
+    gLog << "Macro CT1Analysis : JobD = " 
+         << (JobD        ? "kTRUE" : "kFALSE")  << endl;
+
+
+    // type of data to be analysed
+    TString typeData = "ON";
+    //TString typeData = "OFF";
+    //TString typeData = "MC";
+    gLog << "typeData = " << typeData << endl;
+
+    TString ext      = "3.root";
+
+
+    //------------------------------
+    // selection of g/h separation method
+    // and definition of final selections
+
+    //TString XX("SC");
+    TString XX("RF");
+    TString fhadronnessName("Had");
+    fhadronnessName += XX;
+    gLog << "fhadronnessName = " << fhadronnessName << endl;
+
+    // maximum values of the hadronness, |ALPHA| and DIST
+    Float_t maxhadronness   = 0.233;
+    Float_t maxalpha        = 20.0;
+    Float_t maxdist         = 10.0;
+    gLog << "Maximum values of hadronness, |ALPHA| and DIST = "
+         << maxhadronness << ",  " << maxalpha << ",  " 
+         << maxdist << endl;
+
+
+    //------------------------------
+    // name of data file to be analysed
+    TString filenameData(outPath);
+    filenameData += typeData;
+    filenameData += ext;
+    gLog << "filenameData = " << filenameData << endl;
+
+
+
+    //*************************************************************************
+    //
+    // Analyse the data
+    //
+
+    MTaskList tliston;
+    MParList pliston;
+
+    // geometry is needed in  MHHillas... classes 
+    MGeomCam *fGeom = 
+             (MGeomCam*)pliston->FindCreateObj("MGeomCamCT1", "MGeomCam");
+
+
+    TString fHilName    = "MHillas"; 
+    TString fHilNameExt = "MHillasExt"; 
+    TString fHilNameSrc = "MHillasSrc"; 
+    TString fImgParName = "MNewImagePar"; 
+
+    //-------------------------------------------
+    // create the tasks which should be executed 
+    //
+
+    MReadMarsFile read("Events", filenameData);
+    read.DisableAutoScheme();
+
+
+    //-----------------------------------------------------------------
+    // geometry is needed in  MHHillas... classes 
+    MGeomCam *fGeom = 
+             (MGeomCam*)pliston->FindCreateObj("MGeomCamCT1", "MGeomCam");
+
+    MFCT1SelFinal selfinalgh(fHilNameSrc);
+    selfinalgh.SetCuts(maxhadronness, 100.0, maxdist);
+    selfinalgh.SetHadronnessName(fhadronnessName);
+    selfinalgh.SetName("SelFinalgh");
+    MContinue contfinalgh(&selfinalgh);
+    contfinalgh.SetName("ContSelFinalgh");
+
+    MFillH fillhadsc("hadSC[MHHadronness]", "HadSC");
+    fillhadsc.SetName("HhadSC");
+    MFillH fillhadrf("hadRF[MHHadronness]", "HadRF");
+    fillhadrf.SetName("HhadRF");
+
+    TString mh3name = "abs(Alpha)";
+    MBinning binsalphaabs("Binning"+mh3name);
+    binsalphaabs.SetEdges(50, -2.0, 98.0);
+
+    MH3 alphaabs("abs(MHillasSrc.fAlpha)");
+    alphaabs.SetName(mh3name);
+
+    TH1  &alphahist = alphaabs->GetHist();
+
+    MFillH alpha(&alphaabs);
+    alpha.SetName("FillAlphaAbs");
+
+    MFillH hfill1("MHHillas",    fHilName);
+    hfill1.SetName("HHillas");
+
+    MFillH hfill2("MHStarMap",   fHilName);
+    hfill2.SetName("HStarMap");
+
+    MFillH hfill3("MHHillasExt",   fHilNameSrc);
+    hfill3.SetName("HHillasExt");    
+
+    MFillH hfill4("MHHillasSrc",   fHilNameSrc);
+    hfill4.SetName("HHillasSrc");    
+
+    MFillH hfill5("MHNewImagePar", fImgParName);
+    hfill5.SetName("HNewImagePar");    
+
+    MFCT1SelFinal selfinal(fHilNameSrc);
+    selfinal.SetCuts(maxhadronness, maxalpha, maxdist);
+    selfinal.SetHadronnessName(fhadronnessName);
+    selfinal.SetName("SelFinal");
+    MContinue contfinal(&selfinal);
+    contfinal.SetName("ContSelFinal");
+
+
+    //*****************************
+    // entries in MParList
+
+    pliston.AddToList(&tliston);
+    InitBinnings(&pliston);
+    pliston.AddToList(&binsalphaabs);
+    pliston.AddToList(&alphaabs);
+
+    //*****************************
+    // entries in MTaskList
+    
+    tliston.AddToList(&read);
+
+    tliston.AddToList(&contfinalgh);
+
+    tliston.AddToList(&fillhadsc);
+    tliston.AddToList(&fillhadrf);
+
+    tliston.AddToList(&alpha);
+    tliston.AddToList(&hfill1);
+    tliston.AddToList(&hfill2);
+    tliston.AddToList(&hfill3);
+    tliston.AddToList(&hfill4);
+    tliston.AddToList(&hfill5);
+
+    tliston.AddToList(&contfinal);
+
+    //*****************************
+
+    //-------------------------------------------
+    // Execute event loop
+    //
+    MProgressBar bar;
+    MEvtLoop evtloop;
+    evtloop.SetParList(&pliston);
+    evtloop.SetProgressBar(&bar);
+
+    Int_t maxevents = -1;
+    //Int_t maxevents = 10000;
+    if ( !evtloop.Eventloop(maxevents) )
+        return;
+
+    tliston.PrintStatistics(0, kTRUE);
+
+
+    //-------------------------------------------
+    // Display the histograms
+    //
+
+    pliston.FindObject("hadRF", "MHHadronness")->DrawClone();
+    pliston.FindObject("hadSC", "MHHadronness")->DrawClone();
+
+    pliston.FindObject("MHHillas")->DrawClone();
+    pliston.FindObject("MHHillasExt")->DrawClone();
+    pliston.FindObject("MHHillasSrc")->DrawClone();
+    pliston.FindObject("MHNewImagePar")->DrawClone();
+    pliston.FindObject("MHStarMap")->DrawClone();
+
+
+    //-------------------------------------------
+
+    // fit alpha distribution to get the number of excess events and
+    // calculate significance of gamma signal in the alpha plot
+  
+    MH3* absalpha = (MH3*)(pliston.FindObject(mh3name, "MH3"));
+    TH1  &alphaHist = absalpha->GetHist();
+    alphaHist.SetXTitle("|alpha|  [\\circ]");
+    alphaHist.SetName("alpha-JobD");
+
+    Double_t alphasig = 13.1;
+    Double_t alphamin = 30.0;
+    Double_t alphamax = 90.0;
+    Int_t    degree   =    2;
+    Double_t significance = -99.0;
+    Bool_t   drawpoly  = kTRUE;
+    Bool_t   fitgauss  = kTRUE;
+    Bool_t   print     = kTRUE;
+
+    MHFindSignificance findsig;
+    findsig.SetRebin(kTRUE);
+    findsig.SetReduceDegree(kFALSE);
+
+    findsig.FindSigma(&alphaHist, alphamin, alphamax, degree, 
+                        alphasig, drawpoly, fitgauss, print);
+    significance = findsig.GetSignificance();
+    Float_t alphasi = findsig.GetAlphasi();
+
+    gLog << "For file '" << filenameData << "' : " << endl;
+    gLog << "Significance of gamma signal after supercuts : "
+         << significance << " (for |alpha| < " << alphasi << " degrees)" 
+         << endl;
+
+    findsig.SigmaVsAlpha(&alphaHist, alphamin, alphamax, degree, print);
+
+    //-------------------------------------------
+
+
+    DeleteBinnings(&pliston);
+
+    gLog << "Macro CT1Analysis : End of Job D" << endl;
+    gLog << "=======================================================" << endl;
+ }
+  //---------------------------------------------------------------------
+
+
+
+
+
+  //---------------------------------------------------------------------
+  // Job E_XX
+  //=========
+
+    //  - select g/h separation method XX
+    //  - read MC_XX2.root file 
+    //  - calculate eff. collection area
+    //  - read ON_XX2.root file 
+    //  - apply final cuts
+    //  - calculate flux
+    //  - write root file for ON data after final cuts (ON_XX3.root))
+
+
+ if (JobE_XX)
+ {
+    gLog << "=====================================================" << endl;
+    gLog << "Macro CT1Analysis : Start of Job E_XX" << endl;
+
+    gLog << "" << endl;
+    gLog << "Macro CT1Analysis : JobE_XX, CCollArea, OEEst, WEX = " 
+         << (JobE_XX ? "kTRUE" : "kFALSE")  << ",  " 
+         << (CCollArea?"kTRUE" : "kFALSE")  << ",  " 
+         << (OEEst ?   "kTRUE" : "kFALSE")  << ",  " 
+         << (WEX     ? "kTRUE" : "kFALSE")  << endl;
+
+
+    // type of data to be analysed
+    //TString typeData = "ON";
+    //TString typeData = "OFF";
+    TString typeData = "MC";
+    gLog << "typeData = " << typeData << endl;
+
+    TString typeMC   = "MC";
+    TString ext      = "3.root";
+    TString extout   = "4.root";
+
+    //------------------------------
+    // selection of g/h separation method
+    // and definition of final selections
+
+    //TString XX("SC");
+    TString XX("RF");
+    TString fhadronnessName("Had");
+    fhadronnessName += XX;
+    gLog << "fhadronnessName = " << fhadronnessName << endl;
+
+    // maximum values of the hadronness, |ALPHA| and DIST
+    Float_t maxhadronness   = 0.23;
+    Float_t maxalpha        = 20.0;
+    Float_t maxdist         = 10.0;
+    gLog << "Maximum values of hadronness, |ALPHA| and DIST = "
+         << maxhadronness << ",  " << maxalpha << ",  " 
+         << maxdist << endl;
+
+    //------------------------------
+    // name of MC file to be used for optimizing the energy estimator
+    TString filenameOpt(outPath);
+    filenameOpt += typeMC;
+    filenameOpt += ext; 
+    gLog << "filenameOpt = " << filenameOpt << endl;
+
+    //------------------------------
+    // name of file containing the parameters of the energy estimator
+    TString energyParName(outPath);
+    energyParName += "energyest_";
+    energyParName += XX;
+    energyParName += ".root";
+    gLog << "energyParName = " << energyParName << endl;
+
+    //------------------------------
+    // name of MC file to be used for calculating the eff. collection areas
+    TString filenameArea(outPath);
+    filenameArea += typeMC;
+    filenameArea += ext; 
+    gLog << "filenameArea = " << filenameArea << endl;
+
+    //------------------------------
+    // name of file containing the eff. collection areas
+    TString collareaName(outPath);
+    collareaName += "area_";
+    collareaName += XX;
+    collareaName += ".root";
+    gLog << "collareaName = " << collareaName << endl;
+
+    //------------------------------
+    // name of data file to be analysed
+    TString filenameData(outPath);
+    filenameData += typeData;
+    filenameData += ext;
+    gLog << "filenameData = " << filenameData << endl;
+
+    //------------------------------
+    // name of output data file (after the final cuts)
+    TString filenameDataout(outPath);
+    filenameDataout += typeData;
+    filenameDataout += "_";
+    filenameDataout += XX;
+    filenameDataout += extout;
+    gLog << "filenameDataout = " << filenameDataout << endl;
+
+    //------------------------------
+    // name of file containing histograms for flux calculastion
+    TString filenameResults(outPath);
+    filenameResults += typeData;
+    filenameResults += "Results_";
+    filenameResults += XX;
+    filenameResults += extout;
+    gLog << "filenameResults = " << filenameResults << endl;
+
+
+    //====================================================================
+
+    MHMcCT1CollectionArea collarea;
+    collarea.SetEaxis(MHMcCT1CollectionArea::kLinear);
+
+    MParList  parlist;
+    InitBinnings(&parlist);
+
+  if (CCollArea)
+  {
+    gLog << "-----------------------------------------------" << endl;
+    gLog << "Start calculation of effective collection areas" << endl;
+
+
+    MTaskList tasklist;
+
+    //---------------------------------------
+    // Setup the tasks to be executed
+    //
+    MReadMarsFile reader("Events", filenameArea);
+    reader.DisableAutoScheme();
+
+    MFCT1SelFinal cuthadrons;
+    cuthadrons.SetHadronnessName(fhadronnessName);
+    cuthadrons.SetCuts(maxhadronness, maxalpha, maxdist);
+
+    MContinue conthadrons(&cuthadrons);
+
+
+    MFillH filler("MHMcCT1CollectionArea", "MMcEvt");
+    filler.SetName("CollectionArea");
+
+    //********************************
+    // entries in MParList
+
+    parlist.AddToList(&tasklist);
+
+    parlist.AddToList(&collarea);
+
+    //********************************
+    // entries in MTaskList
+
+    tasklist.AddToList(&reader);   
+    tasklist.AddToList(&conthadrons);
+    tasklist.AddToList(&filler);
+
+    //********************************
+
+    //-----------------------------------------
+    // Execute event loop
+    //
+    MEvtLoop magic;
+    magic.SetParList(&parlist);
+
+    MProgressBar bar;
+    magic.SetProgressBar(&bar);
+    if (!magic.Eventloop())
+        return;
+
+    tasklist.PrintStatistics(0, kTRUE);
+
+    // Calculate effective collection areas 
+    // and display the histograms
+    //
+    //MHMcCT1CollectionArea *collarea = 
+    //     (MHMcCT1CollectionArea*)parlist.FindObject("MHMcCT1CollectionArea");
+    collarea.CalcEfficiency();
+    collarea.DrawClone();
+
+
+
+    //---------------------------------------------
+    // Write histograms to a file 
+    //
+
+    TFile f(collareaName, "RECREATE");
+    //collarea.GetHist()->Write();
+    //collarea.GetHAll()->Write();
+    //collarea.GetHSel()->Write();
+    collarea.Write();
+
+    f.Close();
+
+    gLog << "Collection area plots written onto file " << collareaName << endl;
+
+    gLog << "Calculation of effective collection areas done" << endl;
+    gLog << "-----------------------------------------------" << endl;    
+    //------------------------------------------------------------------
+  }
+
+  if (!CCollArea)
+  {
+    gLog << "-----------------------------------------------" << endl;
+    gLog << "Read in effective collection areas from file " 
+         << collareaName << endl;
+
+    TFile collfile(collareaName);
+    collfile.ls();
+    collarea.Read("MHMcCT1CollectionArea");
+    collarea.DrawClone();
+
+    gLog << "Effective collection areas were read in from file " 
+         << collareaName << endl;
+    gLog << "-----------------------------------------------" << endl;    
+  }
+
+
+    // save binnings for call to CT1EEst
+    MBinning *binsE     = (MBinning*)parlist.FindObject("BinningE");
+    if (!binsE)
+	{
+          gLog << "Object 'BinningE' not found in MParList" << endl;
+          return;
+	}
+    MBinning *binsTheta = (MBinning*)parlist.FindObject("BinningTheta");
+    if (!binsTheta)
+	{
+          gLog << "Object 'BinningTheta' not found in MParList" << endl;
+          return;
+	}
+
+    //-------------------------------------
+    TString fHilName    = "MHillas"; 
+    TString fHilNameExt = "MHillasExt"; 
+    TString fHilNameSrc = "MHillasSrc"; 
+    TString fImgParName = "MNewImagePar"; 
+
+
+ if (OEEst)
+ { 
+   //===========================================================
+    //
+    // Optimization of energy estimator
+    //
+    gLog << "Macro CT1Analysis.C : calling CT1EEst" << endl;
+
+    TString inpath("");
+    TString outpath("");
+    Int_t howMany = 2000;
+    CT1EEst(inpath,   filenameOpt,   outpath, energyParName, 
+            fHilName, fHilNameSrc,   fhadronnessName,
+            howMany,  maxhadronness, maxalpha, maxdist,
+            binsE, binsTheta);
+    gLog << "Macro CT1Analysis.C : returning from CT1EEst" << endl;
+ }
+
+ if (WEX)
+ {
+    //-----------------------------------------------------------
+    //
+    // Read in parameters of energy estimator ("MMcEnergyEst")
+    //                   and migration matrix ("MHMcEnergyMigration")
+    //
+    gLog << "================================================================"
+         << endl;
+    gLog << "Macro CT1Analysis.C : read parameters of energy estimator and migration matrix from file '"
+         << energyParName << "'" << endl;
+    TFile enparam(energyParName);
+    enparam.ls();
+    MMcEnergyEst mcest("MMcEnergyEst"); 
+    mcest.Read("MMcEnergyEst");
+
+    //MMcEnergyEst &mcest = *((MMcEnergyEst*)gROOT->FindObject("MMcEnergyEst"));
+    gLog << "Parameters of energy estimator were read in" << endl;
+
+
+    gLog << "Read in Migration matrix" << endl;   
+
+    MHMcEnergyMigration mighiston("MHMcEnergyMigration");
+    mighiston.Read("MHMcEnergyMigration");
+    //MHMcEnergyMigration &mighiston = 
+    //      *((MHMcEnergyMigration*)gROOT->FindObject("MHMcEnergyMigration"));
+
+    gLog << "Migration matrix was read in" << endl;
+
+
+    TArrayD parA(mcest.GetNumCoeffA());
+    TArrayD parB(mcest.GetNumCoeffB());
+    for (Int_t i=0; i<parA.GetSize(); i++)
+      parA[i] = mcest.GetCoeff(i);
+    for (Int_t i=0; i<parB.GetSize(); i++)
+      parB[i] = mcest.GetCoeff( i+parA.GetSize() );
+
+    //*************************************************************************
+    //
+    // Analyse the data
+    //
+    gLog << "============================================================"
+         << endl;
+    gLog << "Analyse the data" << endl;
+
+    MTaskList tliston;
+    MParList pliston;
+
+    // geometry is needed in  MHHillas... classes 
+    MGeomCam *fGeom = 
+             (MGeomCam*)pliston->FindCreateObj("MGeomCamCT1", "MGeomCam");
+
+
+    //-------------------------------------------
+    // create the tasks which should be executed 
+    //
+
+    MReadMarsFile read("Events", filenameData);
+    read.DisableAutoScheme();
+
+    //.......................................................................
+
+      gLog << "CT1Analysis.C : write root file '" << filenameDataout 
+           << "'" << endl;
+   
+      //MWriteRootFile &write = *(new MWriteRootFile(filenameDataout));
+
+
+      MWriteRootFile write(filenameDataout, "RECREATE");
+
+      write.AddContainer("MRawRunHeader", "RunHeaders");
+      write.AddContainer("MTime",         "Events");
+      write.AddContainer("MMcEvt",        "Events");
+      write.AddContainer("ThetaOrig",     "Events");
+      write.AddContainer("MSrcPosCam",    "Events");
+      write.AddContainer("MSigmabar",     "Events");
+      write.AddContainer("MHillas",       "Events");
+      write.AddContainer("MHillasExt",    "Events");
+      write.AddContainer("MHillasSrc",    "Events");
+      write.AddContainer("MNewImagePar",  "Events");
+
+      //write.AddContainer("HadNN",         "Events");
+      write.AddContainer("HadSC",         "Events");
+      write.AddContainer("HadRF",         "Events");
+
+      write.AddContainer("MEnergyEst",    "Events");
+
+
+    //-----------------------------------------------------------------
+    // geometry is needed in  MHHillas... classes 
+    MGeomCam *fGeom = 
+             (MGeomCam*)pliston->FindCreateObj("MGeomCamCT1", "MGeomCam");
+
+    MFCT1SelFinal selfinalgh(fHilNameSrc);
+    selfinalgh.SetCuts(maxhadronness, 100.0, maxdist);
+    selfinalgh.SetHadronnessName(fhadronnessName);
+    selfinalgh.SetName("SelFinalgh");
+    MContinue contfinalgh(&selfinalgh);
+    contfinalgh.SetName("ContSelFinalgh");
+
+    //MFillH fillhadnn("hadNN[MHHadronness]", "HadNN");
+    //fillhadnn.SetName("HhadNN");
+    MFillH fillhadsc("hadSC[MHHadronness]", "HadSC");
+    fillhadsc.SetName("HhadSC");
+    MFillH fillhadrf("hadRF[MHHadronness]", "HadRF");
+    fillhadrf.SetName("HhadRF");
+
+    //---------------------------
+    // calculate estimated energy
+
+    MEnergyEstParam eeston(fHilName);
+    eeston.Add(fHilNameSrc);
+
+    eeston.SetCoeffA(parA);
+    eeston.SetCoeffB(parB);
+
+    //---------------------------
+    // calculate estimated energy using Daniel's parameters
+
+    //MEnergyEstParamDanielMkn421 eeston(fHilName);
+    //eeston.Add(fHilNameSrc);
+    //eeston.SetCoeffA(parA);
+    //eeston.SetCoeffB(parB);
+
+
+    //---------------------------
+
+
+    MFillH hfill1("MHHillas",    fHilName);
+    hfill1.SetName("HHillas");
+
+    MFillH hfill2("MHStarMap",   fHilName);
+    hfill2.SetName("HStarMap");
+
+    MFillH hfill3("MHHillasExt",   fHilNameSrc);
+    hfill3.SetName("HHillasExt");    
+
+    MFillH hfill4("MHHillasSrc",   fHilNameSrc);
+    hfill4.SetName("HHillasSrc");    
+
+    MFillH hfill5("MHNewImagePar", fImgParName);
+    hfill5.SetName("HNewImagePar");    
+
+    //---------------------------
+    // new from Robert
+
+    MFillH hfill6("MHTimeDiffTheta", "MMcEvt");
+    hfill6.SetName("HTimeDiffTheta");
+
+    MFillH hfill6a("MHTimeDiffTime", "MMcEvt");
+    hfill6a.SetName("HTimeDiffTime");
+
+    MFillH hfill7("MHAlphaEnergyTheta", fHilNameSrc);
+    hfill7.SetName("HAlphaEnergyTheta");
+
+    MFillH hfill7a("MHAlphaEnergyTime", fHilNameSrc);
+    hfill7a.SetName("HAlphaEnergyTime");
+
+    MFillH hfill7b("MHThetabarTime", fHilNameSrc);
+    hfill7b.SetName("HThetabarTime");
+
+    MFillH hfill7c("MHEnergyTime", "MMcEvt");
+    hfill7c.SetName("HEnergyTime");
+
+
+    //---------------------------
+
+    MFCT1SelFinal selfinal(fHilNameSrc);
+    selfinal.SetCuts(maxhadronness, maxalpha, maxdist);
+    selfinal.SetHadronnessName(fhadronnessName);
+    selfinal.SetName("SelFinal");
+    MContinue contfinal(&selfinal);
+    contfinal.SetName("ContSelFinal");
+
+
+    //*****************************
+    // entries in MParList
+
+    pliston.AddToList(&tliston);
+    InitBinnings(&pliston);
+
+
+    //*****************************
+    // entries in MTaskList
+    
+    tliston.AddToList(&read);
+
+    // robert      
+    tliston.AddToList(&hfill6);   //timediff
+    tliston.AddToList(&hfill6a);   //timediff
+
+    tliston.AddToList(&contfinalgh);
+    tliston.AddToList(&eeston);
+
+    tliston.AddToList(&write);
+
+    //tliston.AddToList(&fillhadnn);
+    tliston.AddToList(&fillhadsc);
+    tliston.AddToList(&fillhadrf);
+
+    tliston.AddToList(&hfill1);
+    tliston.AddToList(&hfill2);
+    tliston.AddToList(&hfill3);
+    tliston.AddToList(&hfill4);
+    tliston.AddToList(&hfill5);
+
+    //robert
+    tliston.AddToList(&hfill7);
+    tliston.AddToList(&hfill7a);
+    tliston.AddToList(&hfill7b);
+    tliston.AddToList(&hfill7c);
+
+    tliston.AddToList(&contfinal);
+
+    //*****************************
+
+    //-------------------------------------------
+    // Execute event loop
+    //
+    MProgressBar bar;
+    MEvtLoop evtloop;
+    evtloop.SetParList(&pliston);
+    evtloop.SetProgressBar(&bar);
+
+    Int_t maxevents = -1;
+    if ( !evtloop.Eventloop(maxevents) )
+        return;
+
+    tliston.PrintStatistics(0, kTRUE);
+
+
+    //-------------------------------------------
+    // Display the histograms
+    //
+
+    //pliston.FindObject("hadNN", "MHHadronness")->DrawClone();
+
+    gLog << "before hadRF" << endl;
+    pliston.FindObject("hadRF", "MHHadronness")->DrawClone();
+
+    gLog << "before hadSC" << endl;
+    pliston.FindObject("hadSC", "MHHadronness")->DrawClone();
+
+    gLog << "before MHHillas" << endl;
+    pliston.FindObject("MHHillas")->DrawClone();
+
+    gLog << "before MHHillasExt" << endl;
+    pliston.FindObject("MHHillasExt")->DrawClone();
+
+    gLog << "before MHHillasSrc" << endl;
+    pliston.FindObject("MHHillasSrc")->DrawClone();
+
+    gLog << "before MHNewImagePar" << endl;
+    pliston.FindObject("MHNewImagePar")->DrawClone();
+
+    gLog << "before MHStarMap" << endl;
+    pliston.FindObject("MHStarMap")->DrawClone();
+
+    gLog << "before DeleteBinnings" << endl;
+
+    DeleteBinnings(&pliston);
+
+    gLog << "before Robert's code" << endl;
+
+
+//rwagner write all relevant histograms onto a file
+
+  if (WRobert)
+  {
+    gLog << "=======================================================" << endl;
+    gLog << "Write results onto file '" << filenameResults << "'" << endl;
+
+    TFile outfile(filenameResults,"recreate");
+
+    MHHillasSrc* hillasSrc = 
+      (MHHillasSrc*)(pliston->FindObject("MHHillasSrc"));
+        TH1F* alphaHist = (TH1F*)(hillasSrc->GetHistAlpha());
+    alphaHist->Write();
+    gLog << "Alpha plot has been written out" << endl;    
+
+
+    MHAlphaEnergyTheta* aetH = 
+      (MHAlphaEnergyTheta*)(pliston->FindObject("MHAlphaEnergyTheta"));
+    TH3D* aetHist = (TH3D*)(aetH->GetHist());
+    aetHist->SetName("aetHist");
+    aetHist->Write();
+    gLog << "AlphaEnergyTheta plot has been written out" << endl;    
+
+    MHAlphaEnergyTime* aetH2 = 
+      (MHAlphaEnergyTime*)(pliston->FindObject("MHAlphaEnergyTime"));
+    TH3D* aetHist2 = (TH3D*)(aetH2->GetHist());
+    aetHist2->SetName("aetimeHist");
+//     aetHist2->DrawClone();
+    aetHist2->Write();
+    gLog << "AlphaEnergyTime plot has been written out" << endl;    
+
+    MHThetabarTime* tbt = 
+      (MHThetabarTime*)(pliston->FindObject("MHThetabarTime"));
+    TProfile* tbtHist = (TProfile*)(tbt->GetHist());
+    tbtHist->SetName("tbtHist");
+    tbtHist->Write();
+    gLog << "ThetabarTime plot has been written out" << endl;    
+
+    MHEnergyTime* ent = 
+      (MHEnergyTime*)(pliston->FindObject("MHEnergyTime"));
+    TH2D* entHist = (TH2D*)(ent->GetHist());
+    entHist->SetName("entHist");
+    entHist->Write();
+    gLog << "EnergyTime plot has been written out" << endl;    
+    
+    MHTimeDiffTheta *time = (MHTimeDiffTheta*)pliston.FindObject("MHTimeDiffTheta");
+    TH2D* timeHist = (TH2D*)(time->GetHist());
+    timeHist->SetName("MHTimeDiffTheta");
+    timeHist->SetTitle("Time diffs");
+    timeHist->Write();
+    gLog << "TimeDiffTheta plot has been written out" << endl;    
+
+
+    MHTimeDiffTime *time2 = (MHTimeDiffTime*)pliston.FindObject("MHTimeDiffTime");
+    TH2D* timeHist2 = (TH2D*)(time2->GetHist());
+    timeHist2->SetName("MHTimeDiffTime");
+    timeHist2->SetTitle("Time diffs");
+    timeHist2->Write();
+    gLog << "TimeDiffTime plot has been written out" << endl;    
+
+//rwagner write also collareas to same file
+    collarea->GetHist()->Write();
+    collarea->GetHAll()->Write();
+    collarea->GetHSel()->Write();
+    gLog << "Effective collection areas have been written out" << endl;        
+
+//rwagner todo: write alpha_cut, type of g/h sep (RF, SC, NN), type of data
+//rwagner (ON/OFF/MC), MJDmin, MJDmax to this file
+
+    gLog << "before closing outfile" << endl;
+
+    //outfile.Close();
+    gLog << "Results were written onto file '" << filenameResults 
+         << "'" << endl;
+    gLog << "=======================================================" << endl;
+  }
+
+  }
+
+    gLog << "Macro CT1Analysis : End of Job E_XX" << endl;
+    gLog << "=======================================================" << endl;
+ }
+  //---------------------------------------------------------------------
+
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/macros/PedCalcFromData.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/PedCalcFromData.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/PedCalcFromData.C	(revision 9661)
@@ -0,0 +1,200 @@
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// Description: Macro that uses MPedCalcFromData to evaluate Pedestals from//
+//              Data Runs.                                                 //
+// Author:      Josep Flix (jflix@ifae.es)                                 //
+// Date:        25/06/2004                                                 //
+//                                                                         // 
+/////////////////////////////////////////////////////////////////////////////
+
+void PedCalcFromData()
+{
+
+    gROOT->Reset();
+    gStyle->SetCanvasColor(0);
+    gStyle->SetCanvasBorderMode(0);
+    gStyle->SetPadBorderMode(0);
+    gStyle->SetFrameBorderMode(0);
+    gStyle->SetOptStat(0000000);
+    gStyle->SetPalette(1);
+
+    TString pedfile("20040422_23229_P_Mrk421_E.root");
+    TString datafile("20040422_23230_D_Mrk421_E.root");
+    
+    gStyle->SetOptFit(0);
+    gStyle->SetOptStat(0000);
+    
+    MParList       plist;
+    MTaskList      tlist;
+    
+    MPedestalCam   cam;  
+    plist.AddToList(&cam);
+    
+    plist.AddToList(&tlist);
+    
+    MReadMarsFile read("Events", "/home/pepe/DATA_REAL/Mkn421/"+pedfile);
+    read.DisableAutoScheme();    
+    MGeomApply      geomapl;
+    MExtractFixedWindow    extractor;   
+    extractor.SetRange(2,14,4,14);
+   
+    MPedCalcPedRun ped;
+    ped.SetWindowSize(12);
+    ped.SetRange(2,14);
+    
+    tlist.AddToList(&read);
+    tlist.AddToList(&geomapl);
+    tlist.AddToList(&ped); 
+    
+    MEvtLoop evtloop;
+    
+    if (!tlist.PreProcess(&plist))
+	return;
+    
+    while (tlist.Process())
+    {
+    }
+    tlist.PostProcess();     
+    
+    
+    // ---------------------------------------------------------------
+    // 2nd evt loop
+    // ---------------------------------------------------------------
+
+    c1 = new TCanvas("c1","c1",0,0,600,300);
+    c1->Divide(2,1);
+    c1->SetBorderMode(0);
+    
+    TH2D *plot1 = new TH2D("","",1,0.1,175000,1,8,15);
+    TH2D *plot2 = new TH2D("","",1,0.1,175000,1,1,40);
+    c1->cd(1);
+    plot1->Draw();
+    c1->cd(2);
+    plot2->Draw();
+
+    Int_t COUNT=0;
+    
+    for (int j = 0; j < 6 ; j++){
+
+	if (j == 1)
+	    TString datafile("20040422_23231_D_Mrk421_E.root");
+	if (j == 2)
+	    TString datafile("20040422_23233_D_Mrk421_E.root");
+	if (j == 3)
+	    TString datafile("20040422_23234_D_Mrk421_E.root");
+	if (j == 4)
+	    TString datafile("20040422_23236_D_Mrk421_E.root");
+	if (j == 5)
+	    TString datafile("20040422_23237_D_Mrk421_E.root");
+
+	MParList  plist2;
+	MTaskList tlist2;
+	plist2.AddToList(&tlist2);
+	plist2.AddToList(&cam);
+	
+	MGeomCam *geomcam = (MGeomCam*)plist->FindObject("MGeomCam");
+	
+	MReadMarsFile read2("Events");
+	read2.DisableAutoScheme();
+    
+	read2.AddFile("/home/pepe/DATA_REAL/Mkn421/"+datafile);
+	MGeomApply        apply2;
+	
+	MPedCalcFromData  ped2;
+	ped2.SetDumpEvents(500);
+	ped2.SetLoRange(2,14);
+	ped2.SetHighGainThreshold(50);
+	
+	tlist2.AddToList(&read2);
+	tlist2.AddToList(&apply2);
+	tlist2.AddToList(&ped2);
+	
+	MEvtLoop evtloop2;
+	evtloop2.SetParList(&plist2);
+	
+	if (!tlist2.PreProcess(&plist2))
+	    return;
+	
+	TArrayD PedMean[577];
+	TArrayD PedRms[577];
+	for (int i = 0; i < 577 ; i++){
+	    PedMean[i].Set(20001);
+	    PedRms[i].Set(20001);
+	};
+	Double_t x[20001];
+	Double_t y[20001];
+	Int_t Cont = 0;
+	Int_t HOT = 0;
+	
+	while (tlist2.Process())
+	{
+	    
+	    COUNT++;
+	    
+	    if (read2.GetNumExecutions()==1 || read2.GetNumExecutions()%500==0){
+		
+		x[Cont] = COUNT;
+		for (int i = 1; i < 577; i++){
+		    
+		    PedMean[i](Cont) = cam[i]->GetPedestal();
+		    PedRms[i](Cont) = cam[i]->GetPedestalRms();
+		    
+		};
+		Cont++;
+	    };
+//         if (read2.GetNumExecutions() == 5000) break;
+	}
+	
+	tlist2.PostProcess();
+	cout << "EXEC = " << read2.GetNumExecutions() << '\t' << HOT << endl;
+	
+	for (int i = 1; i < 577; i++){
+	    
+	    if ( i == 8 || i ==146 || i ==200 || i ==269 || i==279 || i==400 || i==26 || i==439 || i==490 || i==39){
+		
+		for (int k = 0 ; k < 20000; k++)
+		    y[k] = PedMean[i](k);
+		
+		c1->cd(1);
+		
+		TGraph *graph1 = new TGraph(Cont,x,y);
+		graph1->SetLineColor((int)i/3);
+		graph1->SetMarkerColor((int)i/3);
+		graph1->SetMarkerSize(.4);
+		graph1->SetMarkerStyle(20);
+		graph1->Draw("PL");
+		
+		c1->cd(2);
+		for (int k = 0 ; k < 20000; k++)
+		    y[k] = PedRms[i](k);
+		
+		TGraph *graph2 = new TGraph(Cont,x,y);
+		graph2->SetMarkerSize(.4);
+		graph2->SetLineColor((int)i/3);
+		graph2->SetMarkerStyle(20);
+		graph2->SetMarkerColor((int)i/3);
+		graph2->Draw("PL");
+		
+		Char_t tit[100];
+		sprintf(tit,"Pixel %i",i);
+		TLatex *pix = new TLatex(20000.,38.-1.*HOT,tit);
+		pix->SetTextColor((int)i/3);
+		pix->SetTextSize(.03);
+		pix->Draw("");
+		HOT++;
+	    };
+	    
+	};
+	
+	TLine *line2 = new TLine(x[Cont-1],1.,x[Cont-1],40.);
+	line2->SetLineStyle(2);
+	TLine *line1 = new TLine(x[Cont-1],8.,x[Cont-1],15.);
+	line1->SetLineStyle(2);
+	c1->cd(1);
+	line1->Draw("");
+	c1->cd(2);
+	line2->Draw("");
+	
+    };    
+}
Index: /tags/Mars_V0-8-5/Mars/macros/Pedestals_Stability.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/Pedestals_Stability.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/Pedestals_Stability.C	(revision 9661)
@@ -0,0 +1,147 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): ???
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+
+ void Pedestals_Stability()
+{
+    char *files[11] = {"ped_stab/stab1.root",
+                      "ped_stab/stab2.root",
+                      "ped_stab/stab3.root",
+                      "ped_stab/stab4.root",
+                      "ped_stab/stab5.root",
+                      "ped_stab/stab6.root",
+                      "ped_stab/stab7.root",
+                      "ped_stab/stab8.root",
+                      "ped_stab/stab9.root",
+                      "ped_stab/stab10.root",
+                      "ped_stab/stab11.root"};
+
+    for (Int_t stab_f=0; stab_f<11; stab_f++){
+
+      MParList plist;
+
+      MPedestalCam  pedest;
+      MTaskList     tlist;
+
+      plist->AddToList(&pedest);
+      plist->AddToList(&tlist);
+
+      MReadTree read("Events", files[stab_f] );
+      MPedCalcPedRun pedcalc;
+
+      tlist.AddToList(&read);
+      tlist.AddToList(&pedcalc);
+
+      MEvtLoop evtloop;
+      evtloop.SetParList(&plist);
+
+      if (!evtloop.PreProcess())
+        return;
+
+      const UInt_t NumEnt = read.GetEntries();
+
+      Float_t pedmeantohist[8][NumEnt];
+      Float_t pedMean[8][11];
+      Float_t pedRMS[8][11];
+
+      Int_t Ecount = 0;
+
+      while (read.Process())
+      {
+
+        pedcalc.Process();
+
+        for (Int_t i=0; i<8; i++){
+          pedmeantohist[i][Ecount] = pedest[i].GetMean();
+        }
+
+	Ecount++;
+
+      } 
+
+      evtloop.PostProcess();
+
+
+    // Create Histogram to get Mean & RMS per 100 pixel events
+ 
+      gROOT->Reset();
+
+      PixelHist = new TH1F("Pixel Hist","Pixel x - Ped hist",100,0,1000);
+
+      cout << files[stab_f] << endl;
+
+      for (Int_t pix=0; pix<8 ; pix++){
+         for (Int_t ev=0; ev<NumEnt; ev++){
+           PixelHist->Fill(pedmeantohist[pix][ev]);
+        }
+     
+	 pedMean[pix][stab_f] = PixelHist->GetMean();
+	 pedRMS[pix][stab_f] = PixelHist->GetRMS();
+
+	 //        cout << "Px" << pix << " - Ped = " 
+	 //	     << PixelHist->GetMean() << " +/- " << PixelHist->GetRMS() << endl;
+
+        PixelHist->Reset();     
+
+      }
+    }
+
+
+    // Plot the results
+
+    // Create the Canvas
+
+    c1 = new TCanvas("c1","Pedestals for all pixels",605,0,600,650);
+    c1->Divide(3,3);
+
+    for (Int_t pix=0; pix<8 ; pix++){
+
+      Float_t Time[11] = {0,51,117,170,229,341,409,475,533,585,643};
+      Float_t Err_Time[11];
+
+      Float_t PedestMeantoGraph[11];
+      Float_t PedestRMStoGraph[11];
+
+      char Title[40];
+
+       for (Int_t ev=0; ev<11; ev++){
+	 PedestMeantoGraph[ev] = pedMean[pix][ev];
+	 PedestRMStoGraph[ev] = pedRMS[pix][ev];
+       }
+       c1->cd(pix+1);
+       gr = new TGraphErrors(11,Time,PedestMeantoGraph,Err_Time,PedestRMStoGraph);
+
+       sprintf(Title,"Pedestal Stability - Pixel %d",pix+1);
+       gr->SetMarkerStyle(20);
+       gr->SetMarkerSize(0.7);
+       gr->SetTitle(Title);
+       gr->Draw("ALP");
+       gr->GetXaxis()->SetTitle("Time (min)");
+       gr->GetYaxis()->SetTitle("ADC Counts");
+       gr->Draw("ALP");
+    
+    }
+    c1->Update();
+
+}
Index: /tags/Mars_V0-8-5/Mars/macros/RanForest.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/RanForest.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/RanForest.C	(revision 9661)
@@ -0,0 +1,179 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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 Hengstebeck 3/2003 <mailto:hengsteb@alwa02.physik.uni-siegen.de>!
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+void RanForest()
+{
+    //
+    // 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);
+
+    MReadMarsFile  read("Events", "~/MagicData/data1/CT1Data/ONTrain/*.root");
+    read.DisableAutoScheme();
+    tlist.AddToList(&read);
+
+    MFParticleId fgamma("MMcEvt", '=', kGAMMA);
+    tlist.AddToList(&fgamma);
+
+    MFParticleId fhadrons("MMcEvt", '!', kGAMMA);
+    tlist.AddToList(&fhadrons);
+
+    MHMatrix matrixg("MatrixGammas");
+    matrixg.AddColumn("cos(MMcEvt.fTelescopeTheta)");
+    matrixg.AddColumn("MSigmabar.fSigmabar");
+    matrixg.AddColumn("log10(Hillas.fSize)");
+    matrixg.AddColumn("HillasSrc.fDist");
+    matrixg.AddColumn("Hillas.fWidth");
+    matrixg.AddColumn("Hillas.fLength");
+    matrixg.AddColumn("log10(Hillas.fSize)/Hillas.fWidth*Hillas.fLength");
+    matrixg.AddColumn("abs(Hillas.fM3Long)");
+    matrixg.AddColumn("Hillas.fConc");
+    matrixg.AddColumn("Hillas.fConc1");
+
+    //matrixg.AddColumn("abs(Hillas.fAsym)");
+    //matrixg.AddColumn("abs(Hillas.fM3Trans)");
+    //matrixg.AddColumn("abs(HillasSrc.fHeadTail)");
+    //matrixg.AddColumn("abs(HillasSrc.fAlpha)");
+
+    plist.AddToList(&read);
+
+    plist.AddToList(&matrixg);
+
+    MHMatrix matrixh("MatrixHadrons");
+    matrixh.AddColumns(matrixg.GetColumns());
+    plist.AddToList(&matrixh);
+
+    MFillH fillmatg("MatrixGammas");
+    fillmatg.SetFilter(&fgamma);
+    tlist.AddToList(&fillmatg);
+
+    MFillH fillmath("MatrixHadrons");
+    fillmath.SetFilter(&fhadrons);
+    tlist.AddToList(&fillmath);
+
+    //
+    // Create and setup the eventloop
+    //
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    //
+    // Execute your analysis
+    //
+    if (!evtloop.Eventloop())
+        return;
+
+    tlist.PrintStatistics();
+
+    // ---------------------------------------------------------------
+    // ---------------------------------------------------------------
+    // second event loop: the trees of the random forest are grown,
+    // the event loop is now actually a tree loop (loop of training
+    // process)
+    // ---------------------------------------------------------------
+    // ---------------------------------------------------------------
+
+    MTaskList tlist2;
+    plist.Replace(&tlist2);
+
+    MRanForestGrow rfgrow2;
+    rfgrow2.SetNumTrees(10);
+    rfgrow2.SetNumTry(3);
+    rfgrow2.SetNdSize(10);
+
+    MWriteRootFile rfwrite2("RF.root");
+    rfwrite2.AddContainer("MRanTree","Tree");       //save all trees
+    MFillH fillh2("MHRanForestGini");
+
+    tlist2.AddToList(&rfgrow2);
+    tlist2.AddToList(&rfwrite2);
+    tlist2.AddToList(&fillh2);
+
+    // gRandom is accessed from MRanForest (-> bootstrap aggregating)
+    // and MRanTree (-> random split selection) and should be initialized
+    // here if you want to set a certain random number generator
+    if(gRandom)
+        delete gRandom;
+    gRandom = new TRandom3(0);
+
+    //
+    // Execute tree growing (now the eventloop is actually a treeloop)
+    //
+    if (!evtloop.Eventloop())
+        return;
+
+    tlist2.PrintStatistics();
+
+    plist.FindObject("MHRanForestGini")->DrawClone();
+
+    // ---------------------------------------------------------------
+    // ---------------------------------------------------------------
+    // third event loop: the control sample (star2.root) is processed
+    // through the previously grown random forest,
+    //
+    // the histograms MHHadronness (quality of g/h-separation) and
+    // MHRanForest are created and displayed.
+    // MHRanForest shows the convergence of the classification error
+    // as function of the number of grown (and combined) trees
+    // and tells the user how many trees are actually needed in later
+    // classification tasks.
+    // ---------------------------------------------------------------
+    // ---------------------------------------------------------------
+
+    MTaskList tlist3;
+
+    plist.Replace(&tlist3);
+
+    MReadMarsFile  read3("Events", "~/MagicData/data1/CT1Data/ONTest/*.root");
+    read3.DisableAutoScheme();
+    tlist3.AddToList(&read3);
+
+    MRanForestCalc calc;
+    tlist3.AddToList(&calc);
+
+    MFillH fillh3a("MHHadronness");
+    MFillH fillh3b("MHRanForest");
+
+    tlist3.AddToList(&fillh3a);
+    tlist3.AddToList(&fillh3b);
+
+    MProgressBar bar;
+    evtloop.SetProgressBar(&bar);
+
+    //
+    // Execute your analysis
+    //
+    if (!evtloop.Eventloop())
+        return;
+
+    tlist3.PrintStatistics();
+
+    plist.FindObject("MHRanForest")->DrawClone();
+    plist.FindObject("MHHadronness")->DrawClone();
+    plist.FindObject("MHHadronness")->Print();//*/
+}
Index: /tags/Mars_V0-8-5/Mars/macros/RanForest2.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/RanForest2.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/RanForest2.C	(revision 9661)
@@ -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 Hengstebeck, 3/2003 <mailto:hengsteb@alwa02.physik.uni-siegen.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+void RanForest2()
+{
+    //
+    // 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);
+    //
+    // ---------------------------------------------------------------
+    // ---------------------------------------------------------------
+    // first event loop: the trees of the random forest are read in
+    // ---------------------------------------------------------------
+    // ---------------------------------------------------------------
+    //
+    MReadTree read("Tree","RF.root");
+    read.DisableAutoScheme();
+
+    MRanForestFill rffill;
+    rffill.SetNumTrees(100);
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&rffill);
+
+    //
+    // Create and setup the eventloop
+    //
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    //
+    // Execute tree reading (now the eventloop is actually a treeloop)
+    //
+    if (!evtloop.Eventloop())
+        return;
+
+    tlist.PrintStatistics();
+
+    // ---------------------------------------------------------------
+    // ---------------------------------------------------------------
+    // second event loop: the control sample is processed
+    // through the previously grown random forest,
+    //
+    // the histograms MHHadronness (quality of g/h-separation) and
+    // MHRanForest are created and displayed.
+    // MHRanForest shows the convergence of the classification error
+    // as function of the number of grown (and combined) trees
+    // and tells the user how many trees are actually needed in later
+    // classification tasks.
+    // ---------------------------------------------------------------
+    // ---------------------------------------------------------------
+
+    MTaskList tlist2;
+
+    plist.Replace(&tlist2);
+
+    MReadMarsFile  read2("Events", "~/MagicData/data1/CT1Data/ONTest/*.root");
+    read2.DisableAutoScheme();
+    tlist2.AddToList(&read2);
+
+    MRanForestCalc calc;
+    tlist2.AddToList(&calc);
+
+    MFillH fillh2a("MHHadronness");
+    MFillH fillh2b("MHRanForest");
+
+    tlist2.AddToList(&fillh2a);
+    tlist2.AddToList(&fillh2b);
+
+    //
+    // Execute your analysis
+    //
+    MProgressBar bar;
+    evtloop.SetProgressBar(&bar);
+
+    if (!evtloop.Eventloop())
+        return;
+
+    tlist2.PrintStatistics();
+
+    plist.FindObject("MHRanForest")->DrawClone();
+    plist.FindObject("MHHadronness")->DrawClone();
+    plist.FindObject("MHHadronness")->Print();
+}
Index: /tags/Mars_V0-8-5/Mars/macros/ScanExtractSignalABCorr.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/ScanExtractSignalABCorr.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/ScanExtractSignalABCorr.C	(revision 9661)
@@ -0,0 +1,193 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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>
+!              Florian Goebel 07/2004
+!
+!   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;
+}
+
+const TString defname = "/.magic/magicserv01/MAGIC/rootdata2/2004_04_22/20040422_23211_D_Mrk421_E.root";
+const TString defpedname = "/.magic/magicserv01/MAGIC/rootdata2/2004_04_22/20040422_23209_P_Mrk421_E.root";
+
+void ScanExtractSignalABCorr(const TString fname = defname,  const TString pedname = defpedname) {
+  
+  MParList plist_ped;
+  
+  MTaskList tlist_ped;
+  plist_ped.AddToList(&tlist_ped);
+  
+  MPedestalCam   pedcam;
+  plist_ped.AddToList(&pedcam);
+  
+  MReadMarsFile read("Events", pedname);
+  read.DisableAutoScheme();
+  
+  MGeomApply    geomapl_ped;
+  MGeomCamMagic geomcam_ped;
+
+  MPedCalcFromLoGain pedcalc_ped;
+  pedcalc_ped.SetPedestalUpdate(kFALSE);
+  
+  tlist_ped.AddToList(&read);
+  tlist_ped.AddToList(&geomapl_ped);
+  tlist_ped.AddToList(&pedcalc_ped);
+  
+  MEvtLoop evtloop_ped;
+  evtloop_ped.SetParList(&plist_ped);
+  
+  if (!evtloop_ped.Eventloop())
+    return;
+  
+  tlist_ped.PrintStatistics();
+  
+  
+  // now the event loop for the signal reconstruction with pedestals subtracted
+  
+  
+  MParList plist;
+  MTaskList     tlist;
+  //  MPedestalCam   pedcam;
+  plist.AddToList(&pedcam);
+  
+  MRawEvtData evtdata; 
+  plist.AddToList(&evtdata);
+  
+  MArrivalTimeCam timecam;
+  plist.AddToList(&timecam);
+  
+  MExtractedSignalCam sigcam;
+  plist.AddToList(&sigcam);
+  
+  
+  plist.AddToList(&tlist);
+  
+  MReadMarsFile read("Events", fname);
+  read.DisableAutoScheme();
+  
+  MGeomApply       geomapl;
+  MArrivalTimeCalc timetime;
+
+  MExtractSignalABcorr sigsig;
+  sigsig.SetRange(5,7,5,7);
+  
+  tlist.AddToList(&read);
+  tlist.AddToList(&geomapl);
+  tlist.AddToList(&sigsig);
+  tlist.AddToList(&timetime);
+  
+  
+  
+  MEvtLoop evtloop;
+  evtloop.SetParList(&plist);
+  
+  if (!evtloop.PreProcess())
+    return;
+  
+  
+  MGeomCam *geomcam = (MGeomCam*)plist->FindObject("MGeomCam");
+  
+  MHCamera display;
+  TCanvas c("Events", "Real Events", 600, 600);
+  c.SetBorderMode(0);
+  c.Divide(1,1);
+  
+  MHCamera display_time;
+  TCanvas c_time("Events_time", "Events Time", 600, 600);
+  c_time.SetBorderMode(0);
+  c_time.Divide(1,1);
+  
+  
+  display.SetGeometry(*geomcam);
+  display.SetPrettyPalette();
+  c.cd(1);
+  display.Draw();
+  gPad->cd(1);
+  
+  display_time.SetGeometry(*geomcam);
+  display_time.SetPrettyPalette();
+  c_time.cd(1);
+  display_time.Draw();
+  gPad->cd(1);
+  
+  
+  // Use this if you don't want the event to be autoscaled
+  //display.SetMinimum(0);
+  //display.SetMaximum(100);
+  
+
+  while (tlist.Process()) {
+    cout << "Event #" << read.GetNumEntry() ":" << endl;
+      
+      display.SetCamContent(sigcam,0);
+      display.SetCamError(sigcam,1);
+      
+      c.GetPad(1)->GetPad(1)->Modified(); //vielleicht fehler? 1->i ??
+      c.GetPad(1)->GetPad(1)->Update();
+      
+      
+      display_time.SetCamContent(timecam,0);
+      display_time.SetCamError(timecam,1);
+      c_time.GetPad(1)->GetPad(1)->Modified(); //vielleicht fehler? 1->i ??
+      c_time.GetPad(1)->GetPad(1)->Update();
+            
+      if (!HandleInput())
+      	break;
+  }
+  
+  evtloop.PostProcess();
+
+  TCanvas c("Events", "Real Events", 600, 600);
+  c.SetBorderMode(0);
+  c.Divide(1,1);
+  c.cd(1);
+
+  chargevpixel->Draw();
+
+}
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/macros/ScanPulseABPed.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/ScanPulseABPed.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/ScanPulseABPed.C	(revision 9661)
@@ -0,0 +1,189 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  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;
+}
+
+const TString defname = "/.magic/magicserv01/MAGIC/rootdata2/2004_04_22/20040422_23211_D_Mrk421_E.root";
+const TString defpedname = "/.magic/magicserv01/MAGIC/rootdata2/2004_04_22/20040422_23209_P_Mrk421_E.root";
+
+void ScanPulseABPed(Int_t ipix = 1, const TString fname = defname, const TString pedname = defpedname) {
+  
+  MParList plist_ped;
+  
+  MTaskList tlist_ped;
+  plist_ped.AddToList(&tlist_ped);
+  
+  MPedestalCam   pedcam;
+  plist_ped.AddToList(&pedcam);
+  
+  MReadMarsFile read("Events", pedname);
+  read.DisableAutoScheme();
+  tlist_ped.AddToList(&read);
+  
+  MGeomApply     geomapl_ped;
+  MGeomCamMagic  geomcam;
+  tlist_ped.AddToList(&geomapl_ped);
+
+  
+  MPedCalcFromLoGain pedcalc_ped;
+  pedcalc_ped.SetMaxHiGainVar(20);
+  pedcalc_ped.SetRange(0, 11, 1, 14);
+  pedcalc_ped.SetWindowSize(12,14);
+  pedcalc_ped.SetPedestalUpdate(kFALSE);
+  tlist_ped.AddToList(&pedcalc_ped);
+  
+  MEvtLoop evtloop_ped;
+  evtloop_ped.SetParList(&plist_ped);
+  
+  if (!evtloop_ped.Eventloop())
+    return;
+  
+  tlist_ped.PrintStatistics();
+  
+  
+  // now the event loop for the signal reconstruction with pedestals subtracted
+  
+  
+  MParList plist;
+  MTaskList     tlist;
+  // MPedestalCam   pedcam;
+  plist.AddToList(&pedcam);
+  
+  MRawRunHeader runheader;
+  plist.AddToList(&runheader);
+
+  MRawEvtData evtdata; 
+  plist.AddToList(&evtdata);
+  
+  plist.AddToList(&tlist);
+  
+  MReadMarsFile read("Events", fname);
+  read.DisableAutoScheme();
+  
+  MGeomApply geomapl;
+  
+  tlist.AddToList(&read);
+  tlist.AddToList(&geomapl);
+  
+  MEvtLoop evtloop;
+  evtloop.SetParList(&plist);
+  
+  if (!evtloop.PreProcess())
+    return;
+
+  TString title = "Pulse in pixel: ";
+  title += ipix;
+  TCanvas c("Events", title, 600, 600);
+  c.SetBorderMode(0);
+  c.Divide(1,1);
+  c.cd(1);
+  gPad->cd(1); 
+
+  Int_t First = 1;
+
+  while (tlist.Process()) {
+
+    if (First) {
+      First = 0;
+
+      const Int_t nh = runheader.GetNumSamplesHiGain();
+      const Int_t nl = runheader.GetNumSamplesLoGain();
+      const Int_t nt = nh+nl;
+      
+      TH1D *hpulse_corr = new TH1D("hpulse_corr", title, nt, -0.5, nt+0.5);
+      hpulse_corr->SetMaximum(255);
+      hpulse_corr->SetMinimum(-10);
+      hpulse_corr->SetLineColor(2);
+      //      hpulse_corr->SetLineWidth(3);
+      
+      hpulse_corr->Draw();
+
+      TH1D *hpulse = new TH1D("hpulse", title, nt, -0.5, nt+0.5);
+      hpulse->Draw("same");
+    }
+
+    MRawEvtPixelIter pixel(&evtdata);
+    pixel.Jump(ipix);
+
+    Bool_t ABFlag = pixel.HasABFlag();
+
+    cout << "Event: " << read.GetNumEntry() << " ABFlag: " << (Int_t)ABFlag << endl;
+      
+    const Byte_t *higains = pixel.GetHiGainSamples();
+    const Byte_t *logains = pixel.GetLoGainSamples();
+  
+    const Float_t ped_mean = pedcam[ipix].GetPedestal();
+    const Float_t ABoffs = pedcam[ipix].GetPedestalABoffset();
+
+    Float_t PedMean[2];
+    PedMean[0] = ped_mean + ABoffs;
+    PedMean[1] = ped_mean - ABoffs;
+
+    for (int slice=0; slice<nh; slice++) {
+      hpulse_corr->SetBinContent(slice+1, higains[slice]-PedMean[(slice+ABFlag)&0x1]);
+      hpulse->SetBinContent(slice+1, higains[slice]);
+    }
+    for (int slice=0; slice<nl; slice++) {
+      hpulse_corr->SetBinContent(slice+nh+1, logains[slice]-PedMean[(nh+slice+ABFlag)&0x1]);
+      hpulse->SetBinContent(slice+nh+1, logains[slice]);
+    }
+
+    c.GetPad(1)->Modified(); 
+    c.GetPad(1)->Update();
+
+    if (!HandleInput())
+      break;
+  }
+  
+  evtloop.PostProcess();
+
+}
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/macros/bootcampstandardanalysis.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/bootcampstandardanalysis.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/bootcampstandardanalysis.C	(revision 9661)
@@ -0,0 +1,322 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Javier López, 12/2003 <mailto:jlopez@ifae.es>
+!              Markus Gaug , 04/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+/////////////////////////////////////////////////////////////////////////////
+//
+//  bootcampstandardanalysis.C
+//
+//  Updated version of the macro designed at the Wuerzburg bootcamp and 
+//  compatible with the latest changes in Mars for general usage at the
+//  Udine bootcamp. 
+//
+//  Needs as arguments the run number of a pedestal file ("*_P_*.root"), 
+//  one of a calibration file ("*_C_*.root") and one of a data file 
+//  ("*_D_*.root"). Performs the pedestal calculation, the calibration 
+/// constants calculation and the calibration of the data. 
+//
+//  The TString inpath has to be set correctly.
+//
+//  The macro searches for the pulser colour which corresponds to the calibration
+//  run number. If the run number is smaller than 20000, pulser colour "CT1" 
+//  is assumed, otherwise, it searches for the strings "green", "blue", "uv" or 
+//  "ct1" in the filenames. If no colour or multiple colours are found, the 
+//  execution is aborted.  
+//
+//////////////////////////////////////////////////////////////////////////////////
+const TString inpath = "/mnt/Data/rootdata/CrabNebula/2004_02_10/";
+const TString outpath = "./";
+const Int_t dpedrun  = 14607;
+const Int_t dcalrun1 = 14608;
+const Int_t dcalrun2 = 0;
+const Int_t ddatrun1 = 14609;
+const Int_t ddatrun2 = 14614;
+const Bool_t usedisplay = kTRUE;
+//
+// A switch to use the Blind Pixel
+//
+const Bool_t blindpix = kTRUE;
+//
+// A switch to use the PIN Diode 
+//
+const Bool_t pindiode = kFALSE;
+//
+void bootcampstandardanalysis(const Int_t prun=dpedrun, // pedestal file
+                              const Int_t crun1=dcalrun1, const Int_t crun2=dcalrun2, // calibration file(s)
+                              const Int_t drun1=ddatrun1, const Int_t drun2=ddatrun2 // data files(s)
+                              )
+                              
+{
+
+  //
+  // Choose the signal Extractor:
+  //
+  MExtractSlidingWindow extractor;
+  //  MExtractFixedWindowPeakSearch extractor;
+  //  MExtractFixedWindow    extractor;   
+
+  //
+  // Set Ranges or Windows
+  //
+  extractor.SetRange(2,14,5,14);
+  //  extractor.SetWindows(8,8);
+
+  //
+  // Choose the arrival time Extractor:
+  //
+  MExtractTimeFastSpline       timeext;
+  //  MExtractTimeHighestIntegral timeext;
+  //  MExtractTimeSpline          timeext;
+  //
+  // Set Ranges or Windows
+  //
+  timeext.SetRange(3,12,6,14);
+
+
+  MRunIter pruns;
+  MRunIter cruns;
+  MRunIter druns;
+
+  pruns.AddRun(prun,inpath);
+
+  if (crun2==0)
+    cruns.AddRun(crun1,inpath);
+  else
+    cruns.AddRuns(crun1,crun2,inpath);
+
+  if (drun2==0)
+    druns.AddRun(drun1,inpath);
+  else
+    druns.AddRuns(drun1,drun2,inpath);
+  
+  //
+  // Now setup the tasks and tasklist for the pedestals:
+  // ---------------------------------------------------
+  //
+  MBadPixelsCam     badcam;
+  MGeomCamMagic     geomcam;
+  MGeomApply        geomapl;
+  //
+  // If you want to exclude pixels from the beginning, read 
+  // an ascii-file with the corr. pixel numbers (see MBadPixelsCam)
+  //
+  //  badcam.AsciiRead("badpixels.dat");
+  
+  /************************************/
+  /* FIRST LOOP: PEDESTAL COMPUTATION */
+  /************************************/
+
+  MJPedestal pedloop;
+  pedloop.SetInput(&pruns);
+  pedloop.SetOutputPath(outpath.Data());
+  if (usedisplay)
+    {
+      MStatusDisplay *display = new MStatusDisplay;
+      display->SetUpdateTime(3000);
+      display->Resize(850,700);
+      pedloop.SetDisplay(display);
+    }
+  pedloop.SetBadPixels(badcam);
+  pedloop.SetExtractor(&extractor);
+
+  if (!pedloop.Process())
+    return;
+
+  /****************************************/
+  /* SECOND LOOP: CALIBRATION COMPUTATION */
+  /****************************************/
+
+  //
+  // Now setup the new tasks for the calibration:
+  // ---------------------------------------------------
+  //
+  MCalibrationQECam qecam;
+  MJCalibration     calloop;
+  calloop.SetInput(&cruns);
+  calloop.SetOutputPath(outpath.Data());
+  calloop.SetExtractor(&extractor);
+  //
+  // Apply rel. time calibration:
+  //
+  calloop.SetRelTimeCalibration();
+  calloop.SetTimeExtractor(&timeext);
+  //
+  // Set the corr. cams:
+  //
+  calloop.SetQECam(qecam);
+  calloop.SetBadPixels(pedloop.GetBadPixels());
+  //
+  // Choose if you want to use the blind pixel and/or the pin diode
+  //
+  calloop.SetUseBlindPixel(blindpix);
+  calloop.SetUsePINDiode(pindiode);
+  //
+  // The next two commands are for the display:
+  //
+  if (usedisplay)
+      calloop.SetDisplay(display);
+  
+  //
+  // Do the event-loop:
+  //
+  if (!calloop.Process(pedloop.GetPedestalCam()))
+    return;
+  
+
+  /*************************************/
+  /* THIRD LOOP: PEDESTAL CALIBRATION  */
+  /*************************************/
+
+  MJExtractSignal pedphotloop;
+
+  pedphotloop.SetExtractor(&extractor);
+  pedphotloop.SetTimeExtractor(&timeext);
+  pedphotloop.SetInput(&pruns);
+  pedphotloop.SetOutputPath(outpath);
+  pedphotloop.SetDisplay(display);
+  pedphotloop.SetBadPixels(calloop.GetBadPixels());
+  
+  if (!pedphotloop.ProcessP(pedloop.GetPedestalCam(),calloop.GetCalibrationCam(),calloop.GetQECam()))
+    return;
+
+  /*************************************/
+  /* FOURTH LOOP: DATA CALIBRATION     */
+  /*************************************/
+
+  //
+  // Create a empty Parameter List and an empty Task List
+  //
+  MParList  plist4;
+  MTaskList tlist4;
+  plist4.AddToList(&tlist4);
+  
+  //
+  // Now setup the tasks and tasklist to analize the data
+  // -----------------------------------------------------
+  //
+  plist4.AddToList(&geomcam);
+  //
+  // Retrieve the cameras from the previous runs:
+  //
+  plist4.AddToList(&pedloop.GetPedestalCam());
+  plist4.AddToList(&calloop.GetCalibrationCam());
+  plist4.AddToList(&calloop.GetQECam());
+  plist4.AddToList(&calloop.GetRelTimeCam());
+  plist4.AddToList(&calloop.GetBadPixels());
+  plist4.AddToList(&pedphotloop.GetPedPhotCam());
+
+  MCerPhotEvt nphot;
+  plist4.AddToList(&nphot);
+
+  MArrivalTime times;
+  plist4.AddToList(&times);
+  
+  //tasks
+  MReadMarsFile read4("Events");
+  read4.DisableAutoScheme();
+  static_cast<MRead&>(read4).AddFiles(druns);  
+  
+  MCalibrate       photcalc;
+  photcalc.SetCalibrationMode(MCalibrate::kFfactor);
+  MCalibrateRelTimes  timecal;
+
+  tlist4.AddToList(&read4);
+  tlist4.AddToList(&geomapl);
+  tlist4.AddToList(&extractor);
+  tlist4.AddToList(&timeext);
+  tlist4.AddToList(&photcalc);
+  tlist4.AddToList(&timecal);
+  
+  //
+  // Create and setup the eventloop
+  //
+  MEvtLoop evtloop4;
+  evtloop4.SetParList(&plist4);
+
+  if (!evtloop4.PreProcess())
+    return;
+  
+  TCanvas *c1 = new TCanvas;
+  MHCamera disp1(geomcam);
+  disp1.SetPrettyPalette();
+  //disp1.SetInvDeepBlueSeaPalette()
+  disp1.Draw();
+  gPad->SetLogy();
+  gPad->cd(1);
+  
+  /*
+  TCanvas *c2 = new TCanvas;
+  MHCamera disp2(geomcam);
+  disp2.SetPrettyPalette();
+  //disp2.SetInvDeepBlueSeaPalette()
+  disp2.Draw();
+  gPad->SetLogy();
+  gPad->cd(1);
+  */
+  while (tlist4.Process())
+    {
+      disp1.SetCamContent(nphot);
+      
+      gPad->Modified();
+      gPad->Update();
+
+      /*    
+      disp2.SetCamContent(times);
+      
+      gPad->Modified();
+      gPad->Update();
+      */
+
+      // Remove the comments if you want to go through the file
+      // event-by-event:
+      if (!HandleInput())
+	break;
+    }
+
+  evtloop4.PostProcess();
+  
+}
+
+Bool_t HandleInput()
+{
+    TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
+
+    while (1)
+    {
+        //
+        // While reading the input process gui events asynchronously
+        //
+        timer.TurnOn();
+        TString input = Getline("Type 'q' to exit, <return> to go on: ");
+        timer.TurnOff();
+
+        if (input=="q\n")
+            return kFALSE;
+
+        if (input=="\n")
+            return kTRUE;
+    };
+
+    return kFALSE;
+}
+
Index: /tags/Mars_V0-8-5/Mars/macros/calibClasses.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/calibClasses.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/calibClasses.C	(revision 9661)
@@ -0,0 +1,729 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug  04/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  calibClasses
+//
+//  This macro draws the schemes found in htmldoc/images/CalibClasses.gif
+//  and htmldoc/images/RelTimeClasses.gif
+//
+/////////////////////////////////////////////////////////////////////////////
+
+void calibClasses()
+{
+
+  const Float_t ell1x1 = 0.3;
+  const Float_t ell2x1 = 0.575;
+  const Float_t ell3x1 = 0.85;
+  
+  const Float_t ellr1 = 0.12;
+  const Float_t ellr2 = 0.035;
+  
+  const Float_t tex1x1 = 0.19;
+  const Float_t tex2x1 = 0.465;
+  const Float_t tex3x1 = 0.74;
+
+
+  const Float_t texsize = 0.0257913;
+  const Float_t texsize2 = 0.015;
+
+  const Float_t arr1x1 = 0.3;
+  const Float_t arr2x1 = 0.575;
+  const Float_t arr3x1 = 0.85;
+
+  const Float_t arrsize = 0.02;
+  
+  const Float_t pt1x1 = 0.175;
+  const Float_t pt2x1 = 0.45;
+  const Float_t pt3x1 = 0.725;
+
+  const Float_t pt1x2 = 0.425;
+  const Float_t pt2x2 = 0.7;
+  const Float_t pt3x2 = 0.975;
+
+  Float_t arry1  = 0.;
+  Float_t arry2  = 0.;
+  Float_t elly1  = 0.;
+  Float_t pty1   = 0.;
+  Float_t pty2   = 0.;
+  Float_t texy1  = 0.;
+  Float_t linex1 = 0.;
+  Float_t linex2 = 0.;
+  Float_t liney1 = 0.l;
+
+  TCanvas *CalibClasses = new TCanvas("CalibClasses", "Calibration Classes",89,96,758,1051);
+  CalibClasses->Range(0,0,1,1);
+  CalibClasses->SetBorderSize(2);
+  CalibClasses->SetFrameFillColor(0);
+   
+// First line:
+   TPaveText *pt = new TPaveText(0.375,0.895,0.785,0.95,"br");
+   pt->SetFillColor(18);
+   TText *text = pt->AddText("MRawEvtData");
+   pt->Draw();
+      tex = new TLatex(0.55,0.955,"C");
+   tex->SetTextSize(0.05);
+   tex->SetLineWidth(2);
+   tex->Draw();
+      tex = new TLatex(0.12,0.955,"P");
+   tex->SetTextSize(0.05);
+   tex->SetLineWidth(2);
+   tex->Draw();
+   
+   pt = new TPaveText(0.015,0.875,0.25,0.95,"br");
+   pt->SetFillColor(18);
+   text = pt->AddText("MPedestalCam:");
+   text = pt->AddText("ped, RMS, #Deltaped, #DeltaRMS");
+   text->SetTextColor(kBlue);
+   pt->Draw();
+   
+
+// Second line:
+   elly1 = 0.805;
+
+   TEllipse *ellipse = new TEllipse(ell1x1,elly1,ellr1,ellr2,0,360,0);
+   ellipse->Draw();
+   
+   ellipse = new TEllipse(ell2x1,elly1,ellr1,ellr2,0,360,0);
+   ellipse->Draw();
+   
+   ellipse = new TEllipse(ell3x1,elly1,ellr1,ellr2,0,360,0);
+   ellipse->Draw();
+
+   texy1 = 0.805;
+
+      tex = new TLatex(tex1x1,texy1,"MExtractSignal:");
+   tex->SetTextSize(texsize);
+   tex->SetLineWidth(2);
+   tex->Draw();
+
+      tex = new TLatex(tex2x1,texy1,"MExtractBlindPixel:");
+   tex->SetTextSize(texsize);
+   tex->SetLineWidth(2);
+   tex->Draw();
+      tex = new TLatex(tex3x1,texy1,"MExtractPINDiode:");
+   tex->SetTextSize(texsize);
+   tex->SetLineWidth(2);
+   tex->Draw();
+
+   texy1 = 0.79;
+
+      tex = new TLatex(tex1x1+0.02,texy1,"sum FADC slices, error??");
+   tex->SetTextSize(texsize2);
+   tex->SetTextColor(kRed);
+   tex->SetLineWidth(1);
+   tex->Draw();
+
+      tex = new TLatex(tex2x1+0.02,texy1,"sum FADC slices");
+   tex->SetTextSize(texsize2);
+   tex->SetTextColor(kRed);
+   tex->SetLineWidth(1);
+   tex->Draw();
+      tex = new TLatex(tex3x1+0.02,texy1,"sum FADC slices");
+   tex->SetTextSize(texsize2);
+   tex->SetTextColor(kRed);
+   tex->SetLineWidth(1);
+   tex->Draw();
+
+
+   arry1 = 0.89;
+   arry2 = 0.84;
+
+   TArrow *arrow = new TArrow(0.45, arry1,arr1x1,arry2,arrsize,"|>");
+   arrow->SetFillColor(1);
+   arrow->SetFillStyle(1001);
+   arrow->Draw();
+
+   arrow         = new TArrow(arr2x1,arry1,arr2x1,arry2,arrsize,"|>");
+   arrow->SetFillColor(1);
+   arrow->SetFillStyle(1001);
+   arrow->Draw();
+
+   arrow         = new TArrow(0.715, arry1,arr3x1,arry2,arrsize,"|>");
+   arrow->SetFillColor(1);
+   arrow->SetFillStyle(1001);
+   arrow->Draw();
+   
+// Third line:
+   pty1 = 0.67;
+   pty2 = 0.73;
+   
+   pt = new TPaveText(pt1x1,pty1,pt1x2,pty2,"br");
+   pt->SetFillColor(18);
+   text = pt->AddText("MExtractedSignalCam");
+   pt->Draw();
+   
+   pt = new TPaveText(pt2x1,pty1,pt2x2,pty2,"br");
+   pt->SetFillColor(18);
+   text = pt->AddText("MExtractedSignalBlindPixel");
+   pt->Draw();
+   
+   pt = new TPaveText(pt3x1,pty1,pt3x2,pty2,"br");
+   pt->SetFillColor(18);
+   text = pt->AddText("MExtractedSignalPINDiode");
+   pt->Draw();
+
+   arry1 = 0.77;
+   arry2 = 0.73;
+
+   arrow = new TArrow(arr1x1,arry1,arr1x1,arry2,arrsize,"|>");
+   arrow->SetFillColor(1);
+   arrow->SetFillStyle(1001);
+   arrow->Draw();
+   arrow = new TArrow(arr2x1,arry1,arr2x1,arry2,arrsize,"|>");
+   arrow->SetFillColor(1);
+   arrow->SetFillStyle(1001);
+   arrow->Draw();
+   arrow = new TArrow(arr3x1,arry1,arr3x1,arry2,arrsize,"|>");
+   arrow->SetFillColor(1);
+   arrow->SetFillStyle(1001);
+   arrow->Draw();
+
+
+// Fourth line:
+   elly1 = 0.6;
+
+   TEllipse *ellipse = new TEllipse(ell1x1,elly1,ellr1,ellr2,0,360,0);
+   ellipse->Draw();
+   
+   ellipse = new TEllipse(ell2x1,elly1,ellr1,ellr2,0,360,0);
+   ellipse->Draw();
+   
+   ellipse = new TEllipse(ell3x1,elly1,ellr1,ellr2,0,360,0);
+   ellipse->Draw();
+
+
+
+   texy1 = 0.6;
+
+      tex = new TLatex(tex1x1,texy1,"MHCalibrationChargeCam:");
+   tex->SetTextSize(texsize2);
+   tex->SetLineWidth(2);
+   tex->Draw();
+      tex = new TLatex(tex2x1,texy1,"MHCalibrationChargeBlindPix:");
+   tex->SetTextSize(texsize2);
+   tex->SetLineWidth(2);
+   tex->Draw();
+      tex = new TLatex(tex3x1,texy1,"MHCalibrationChargePINDiode:");
+   tex->SetTextSize(texsize2);
+   tex->SetLineWidth(2);
+   tex->Draw();
+
+   linex1 = 0.18;
+   linex2 = 0.08;
+
+   TLine *line = new TLine(linex1,texy1,linex2,texy1);
+   line->Draw();
+
+   arrow = new TArrow(linex2,texy1,linex2,0.29,arrsize,"|>");
+   arrow->SetFillColor(1);
+   arrow->SetFillStyle(1001);
+   arrow->Draw();
+   
+   tex = new TLatex(linex2-0.01,0.35,"Pulse not in extraction window");
+   tex->SetTextSize(texsize2+0.008);
+   tex->SetTextAngle(90);
+   tex->SetTextColor(006);
+   tex->SetLineWidth(1);
+   tex->Draw();
+
+   texy1 = 0.59;
+
+   tex = new TLatex(tex1x1+0.01,texy1,"Fit High-, Low-Gain, each pixel");
+   tex->SetTextSize(texsize2);
+   tex->SetTextColor(kRed);
+   tex->SetLineWidth(1);
+   tex->Draw();
+      tex = new TLatex(tex1x1+0.01,texy1-0.01,"Fast Fourier Analysis");
+   tex->SetTextSize(texsize2);
+   tex->SetTextColor(kRed);
+   tex->SetLineWidth(1);
+   tex->Draw();
+
+
+
+      tex = new TLatex(tex2x1+0.01,texy1,"Fit Single-Phe spectrum");
+   tex->SetTextSize(texsize2);
+   tex->SetTextColor(kRed);
+   tex->SetLineWidth(1);
+   tex->Draw();
+      tex = new TLatex(tex3x1+0.01,texy1,"Fit Charge distribution");
+   tex->SetTextSize(texsize2);
+   tex->SetTextColor(kRed);
+   tex->SetLineWidth(1);
+   tex->Draw();
+      tex = new TLatex(tex3x1+0.01,texy1-0.01,"Fast Fourier Analysis");
+   tex->SetTextSize(texsize2);
+   tex->SetTextColor(kRed);
+   tex->SetLineWidth(1);
+   tex->Draw();
+
+
+   arry1 = 0.67;
+   arry2 = 0.63;
+
+   arrow = new TArrow(arr1x1,arry1,arr1x1,arry2,arrsize,"|>");
+   arrow->SetFillColor(1);
+   arrow->SetFillStyle(1001);
+   arrow->Draw();
+   arrow = new TArrow(arr2x1,arry1,arr2x1,arry2,arrsize,"|>");
+   arrow->SetFillColor(1);
+   arrow->SetFillStyle(1001);
+   arrow->Draw();
+   arrow = new TArrow(arr3x1,arry1,arr3x1,arry2,arrsize,"|>");
+   arrow->SetFillColor(1);
+   arrow->SetFillStyle(1001);
+   arrow->Draw();
+
+// Fifth line:
+   pty1 = 0.465;
+   pty2 = 0.525;
+
+   pt = new TPaveText(pt1x1,pty1-0.03,pt1x2,pty2,"br");
+   pt->SetFillColor(18);
+   text = pt->AddText("MCalibrationChargeCam:");
+   pt->Draw();
+   text = pt->AddText("Conv. FADC to Phe's, error");
+   text->SetTextColor(kBlue);
+   pt->Draw();
+   text = pt->AddText("Total F-Factor to Photons");
+   text->SetTextColor(kBlue);
+   pt->Draw();
+   
+   pt = new TPaveText(pt2x1,pty1,pt2x2,pty2,"br");
+   pt->SetFillColor(18);
+   text = pt->AddText("MCalibrationChargeBlindPix");
+   pt->Draw();
+   
+   pt = new TPaveText(pt3x1,pty1,pt3x2,pty2,"br");
+   pt->SetFillColor(18);
+   text = pt->AddText("MCalibrationChargePINDiode");
+   pt->Draw();
+   
+
+   arry1 = 0.565;
+   arry2 = 0.525;
+
+   arrow = new TArrow(arr1x1,arry1,arr1x1,arry2,arrsize,"|>");
+   arrow->SetFillColor(1);
+   arrow->SetFillStyle(1001);
+   arrow->Draw();
+   arrow = new TArrow(arr2x1,arry1,arr2x1,arry2,arrsize,"|>");
+   arrow->SetFillColor(1);
+   arrow->SetFillStyle(1001);
+   arrow->Draw();
+   arrow = new TArrow(arr3x1,arry1,arr3x1,arry2,arrsize,"|>");
+   arrow->SetFillColor(1);
+   arrow->SetFillStyle(1001);
+   arrow->Draw();
+
+
+// Sixth line:
+   Float_t nellx1 = 0.39;
+   elly1 = 0.38;
+
+   ellipse = new TEllipse(0.57,elly1,0.235,0.04,0,360,0);
+   ellipse->Draw();
+
+      tex = new TLatex(nellx1,0.38,"MCalibrationChargeCalc:");
+   tex->SetTextSize(0.0328253);
+   tex->SetLineWidth(2);
+   tex->Draw();
+
+   tex = new TLatex(nellx1+0.02,0.365,"Low Gain Ped., Red. #sigma's, Nr. Phe's, total F-Factor");
+   tex->SetTextSize(texsize2);
+   tex->SetTextColor(kRed);
+   tex->SetLineWidth(1);
+   tex->Draw();
+
+   tex = new TLatex(nellx1+0.02,0.355,"#gamma-fluxes: F-Factor, BlindPixel, PIN Diode Method");
+   tex->SetTextSize(texsize2);
+   tex->SetTextColor(kRed);
+   tex->SetLineWidth(1);
+   tex->Draw();
+
+
+   arry1 = 0.46;
+   arry2 = 0.42;
+
+   arrow = new TArrow(arr1x1,0.435,arr1x1+0.1,arry2-0.01,arrsize,"|>");
+   arrow->SetFillColor(1);
+   arrow->SetFillStyle(1001);
+   arrow->Draw();
+   arrow = new TArrow(arr2x1,arry1,arr2x1,arry2,arrsize,"|>");
+   arrow->SetFillColor(1);
+   arrow->SetFillStyle(1001);
+   arrow->Draw();
+   arrow = new TArrow(arr3x1,arry1,arr3x1-0.1,arry2-0.01,arrsize,"|>");
+   arrow->SetFillColor(1);
+   arrow->SetFillStyle(1001);
+   arrow->Draw();
+
+   linex1 = 0.135;
+   liney1 = 0.38;
+
+   TLine *line = new TLine(linex1,0.87,linex1,liney1);
+   line->Draw();
+
+   arrow = new TArrow(linex1,liney1,0.335544,liney1,arrsize,"|>");
+   arrow->SetFillColor(1);
+   arrow->SetFillStyle(1001);
+   arrow->Draw();
+
+   arrow = new TArrow(0.38,0.402,0.27,0.433,arrsize,"|>");
+   arrow->SetFillColor(1);
+   arrow->SetFillStyle(1001);
+   arrow->Draw();
+
+
+   arrow = new TArrow(0.35,0.365,0.15,0.29,arrsize,"|>");
+   arrow->SetFillColor(1);
+   arrow->SetFillStyle(1001);
+   arrow->Draw();
+
+   tex = new TLatex(0.2,0.29,"Deviating Nr. Phe's");
+   tex->SetTextSize(texsize2+0.006);
+   tex->SetTextAngle(27);
+   tex->SetTextColor(006);
+   tex->SetLineWidth(1);
+   tex->Draw();
+
+   tex = new TLatex(0.19,0.325,"Oscillations");
+   tex->SetTextSize(texsize2+0.006);
+   tex->SetTextAngle(27);
+   tex->SetTextColor(006);
+   tex->SetLineWidth(1);
+   tex->Draw();
+
+   tex = new TLatex(0.195,0.31,"Absurd fit results");
+   tex->SetTextSize(texsize2+0.006);
+   tex->SetTextAngle(27);
+   tex->SetTextColor(006);
+   tex->SetLineWidth(1);
+   tex->Draw();
+
+// seventh line
+   pty1 = 0.215;
+   pty2 = 0.29;
+
+   pt = new TPaveText(0.015,pty1,0.25,pty2,"br");
+   pt->SetFillColor(18);
+   text = pt->AddText("MBadPixelsCam:");
+   text = pt->AddText("kUnsuitableRun");
+   text->SetTextColor(kBlue);
+   text = pt->AddText("kUnreliableRun");
+   text->SetTextColor(kBlue);
+   pt->Draw();
+   
+
+   pt = new TPaveText(0.3,pty1,0.85,pty2,"br");
+   pt->SetFillColor(18);
+   text = pt->AddText("MCalibrationQECam:");
+   pt->Draw();
+   text = pt->AddText("QE: Green, Blue, UV, CT1, av. Cascades(cos#theta), error");
+   text->SetTextColor(kBlue);
+   pt->Draw();
+   text = pt->AddText("QE: F-Factor, Blind Pixel, PIN Diode, Combined Method");
+   text->SetTextColor(kBlue);
+   pt->Draw();
+   
+
+   arry1 = 0.34;
+   arry2 = 0.3;
+
+   arrow = new TArrow(arr1x1+0.1,arry1+0.01,arr1x1+0.1,arry2-0.01,arrsize,"|>");
+   arrow->SetFillColor(1);
+   arrow->SetFillStyle(1001);
+   arrow->Draw();
+   arrow = new TArrow(arr2x1,arry1,arr2x1,arry2-0.01,arrsize,"|>");
+   arrow->SetFillColor(1);
+   arrow->SetFillStyle(1001);
+   arrow->Draw();
+   arrow = new TArrow(arr3x1-0.1,arry1+0.01,arr3x1-0.1,arry2-0.01,arrsize,"|>");
+   arrow->SetFillColor(1);
+   arrow->SetFillStyle(1001);
+   arrow->Draw();
+
+// eightth line:
+
+   Float_t nellx1 = 0.39;
+   elly1 = 0.13;
+
+   ellipse = new TEllipse(0.57,elly1,0.235,0.04,0,360,0);
+   ellipse->Draw();
+
+      tex = new TLatex(nellx1,elly1,"MCalibrate:");
+   tex->SetTextSize(0.0328253);
+   tex->SetLineWidth(2);
+   tex->Draw();
+
+   tex = new TLatex(nellx1+0.02,elly1-0.01,"Sum FADC slices to Phe's");
+   tex->SetTextSize(texsize2);
+   tex->SetTextColor(kRed);
+   tex->SetLineWidth(1);
+   tex->Draw();
+
+   tex = new TLatex(nellx1+0.02,elly1-0.02,"Phe's to photons (cos#theta), #Delta(photons)");
+   tex->SetTextSize(texsize2);
+   tex->SetTextColor(kRed);
+   tex->SetLineWidth(1);
+   tex->Draw();
+
+   arry1 = 0.21;
+   arry2 = 0.17;
+
+   arrow = new TArrow(arr2x1,arry1,arr2x1,arry2,arrsize,"|>");
+   arrow->SetFillColor(1);
+   arrow->SetFillStyle(1001);
+   arrow->Draw();
+
+   Float_t linex1 = 0.27;
+   Float_t liney1 = 0.13;
+
+   TLine *line = new TLine(linex1,0.435,linex1,liney1);
+   line->Draw();
+
+   arrow = new TArrow(linex1,liney1,0.335544,liney1,arrsize,"|>");
+   arrow->SetFillColor(1);
+   arrow->SetFillStyle(1001);
+   arrow->Draw();
+
+   linex1 = 0.15;
+   liney1 = 0.05;
+
+   TLine *line = new TLine(linex1,0.215,linex1,liney1);
+   line->Draw();
+
+   TLine *line = new TLine(linex1,liney1,arr2x1,liney1);
+   line->Draw();
+
+   arrow = new TArrow(arr2x1,liney1,arr2x1,0.09,arrsize,"|>");
+   arrow->SetFillColor(1);
+   arrow->SetFillStyle(1001);
+   arrow->Draw();
+
+
+   CalibClasses->Modified();
+   CalibClasses->cd();
+
+   CalibClasses->SaveAs("htmldoc/images/CalibClasses.gif");
+
+   //
+   // Relative Time classes
+   //
+
+   TCanvas *RelTimeClasses = new TCanvas("RelTimeClasses", "Relative Time Calibration Classes",89,96,758,1051);
+   RelTimeClasses->Range(0,0,1,1);
+   RelTimeClasses->SetBorderSize(2);
+   RelTimeClasses->SetFrameFillColor(0);
+   
+// First line:
+   TPaveText *pt = new TPaveText(0.375,0.895,0.785,0.95,"br");
+   pt->SetFillColor(18);
+   TText *text = pt->AddText("MRawEvtData");
+   pt->Draw();
+      tex = new TLatex(0.55,0.955,"C");
+   tex->SetTextSize(0.05);
+   tex->SetLineWidth(2);
+   tex->Draw();
+   
+
+// Second line:
+   elly1 = 0.805;
+
+   ellipse = new TEllipse(ell2x1,elly1,ellr1,ellr2,0,360,0);
+   ellipse->Draw();
+   
+   texy1 = 0.805;
+
+      tex = new TLatex(tex2x1,texy1,"MArrivalTimeCalc:");
+   tex->SetTextSize(texsize);
+   tex->SetLineWidth(2);
+   tex->Draw();
+
+   texy1 = 0.79;
+
+   tex = new TLatex(tex2x1+0.02,texy1,"Abs. Arrival Time");
+   tex->SetTextSize(texsize2);
+   tex->SetTextColor(kRed);
+   tex->SetLineWidth(1);
+   tex->Draw();
+
+   arry1 = 0.89;
+   arry2 = 0.84;
+
+   arrow = new TArrow(arr2x1,arry1,arr2x1,arry2,arrsize,"|>");
+   arrow->SetFillColor(1);
+   arrow->SetFillStyle(1001);
+   arrow->Draw();
+
+   
+// Third line:
+   pty1 = 0.67;
+   pty2 = 0.73;
+   
+   pt = new TPaveText(pt2x1,pty1,pt2x2,pty2,"br");
+   pt->SetFillColor(18);
+   text = pt->AddText("MArrivalTimeCam");
+   pt->Draw();
+   
+   arry1 = 0.77;
+   arry2 = 0.73;
+
+   arrow = new TArrow(arr2x1,arry1,arr2x1,arry2,arrsize,"|>");
+   arrow->SetFillColor(1);
+   arrow->SetFillStyle(1001);
+   arrow->Draw();
+
+// Fourth line:
+   elly1 = 0.6;
+
+   TEllipse *ellipse = new TEllipse(ell2x1,elly1,0.235,0.04,0,360,0);
+   ellipse->Draw();
+   
+   texy1 = 0.6;
+
+   tex = new TLatex(tex2x1-0.05,texy1,"MHCalibrationRelTimeCam:");
+   tex->SetTextSize(texsize);
+   tex->SetLineWidth(2);
+   tex->Draw();
+
+
+   arrow = new TArrow(0.35,0.465,0.15,0.39,arrsize,"|>");
+   arrow->SetFillColor(1);
+   arrow->SetFillStyle(1001);
+   arrow->Draw();
+
+   tex = new TLatex(0.17,0.425,"Oscillations");
+   tex->SetTextSize(texsize2+0.006);
+   tex->SetTextAngle(27);
+   tex->SetTextColor(006);
+   tex->SetLineWidth(1);
+   tex->Draw();
+
+   tex = new TLatex(0.175,0.41,"Absurd results");
+   tex->SetTextSize(texsize2+0.006);
+   tex->SetTextAngle(27);
+   tex->SetTextColor(006);
+   tex->SetLineWidth(1);
+   tex->Draw();
+
+// seventh line
+   pty1 = 0.315;
+   pty2 = 0.39;
+
+   pt = new TPaveText(0.015,pty1,0.25,pty2,"br");
+   pt->SetFillColor(18);
+   text = pt->AddText("MBadPixelsCam:");
+   text = pt->AddText("kUnreliableRun");
+   text->SetTextColor(kBlue);
+   pt->Draw();
+   
+   texy1 = 0.59;
+
+   tex = new TLatex(tex2x1-0.04,texy1,"Calculate Rel. Arrival Times");
+   tex->SetTextSize(texsize2);
+   tex->SetTextColor(kRed);
+   tex->SetLineWidth(1);
+   tex->Draw();
+   tex = new TLatex(tex2x1-0.04,texy1-0.01," (w.r.t. pixel 1 software idx)");
+   tex->SetTextSize(texsize2);
+   tex->SetTextColor(kRed);
+   tex->SetLineWidth(1);
+   tex->Draw();
+
+   arry1 = 0.67;
+   arry2 = 0.63;
+
+   arrow = new TArrow(arr2x1,arry1,arr2x1,arry2,arrsize,"|>");
+   arrow->SetFillColor(1);
+   arrow->SetFillStyle(1001);
+   arrow->Draw();
+
+   arry1 = 0.56;
+   arry2 = 0.52;
+
+   arrow = new TArrow(arr2x1,arry1,arr2x1,arry2,arrsize,"|>");
+   arrow->SetFillColor(1);
+   arrow->SetFillStyle(1001);
+   arrow->Draw();
+
+// Fifth line:
+   pty1 = 0.44;
+   pty2 = 0.52;
+
+
+   pt = new TPaveText(0.3,pty1,0.85,pty2,"br");
+   pt->SetFillColor(18);
+   text = pt->AddText("MCalibrationRelTimeCam:");
+   pt->Draw();
+   text = pt->AddText("Offset, Resolution, errors");
+   text->SetTextColor(kBlue);
+   pt->Draw();
+
+
+
+// eightth line:
+
+   Float_t nellx1 = 0.39;
+   elly1 = 0.36;
+
+   ellipse = new TEllipse(0.57,elly1,0.235,0.04,0,360,0);
+   ellipse->Draw();
+
+   tex = new TLatex(nellx1,elly1,"MCalibrateTime:");
+   tex->SetTextSize(0.0328253);
+   tex->SetLineWidth(2);
+   tex->Draw();
+
+   tex = new TLatex(nellx1+0.02,elly1-0.02,"Offset correction");
+   tex->SetTextSize(texsize);
+   tex->SetTextColor(kRed);
+   tex->SetLineWidth(1);
+   tex->Draw();
+
+   arry1 = 0.44;
+   arry2 = 0.4;
+
+   arrow = new TArrow(arr2x1,arry1,arr2x1,arry2,arrsize,"|>");
+   arrow->SetFillColor(1);
+   arrow->SetFillStyle(1001);
+   arrow->Draw();
+
+   Float_t linex1 = 0.25;
+   Float_t liney1 = 0.36;
+
+   arrow = new TArrow(linex1,liney1,0.335,liney1,arrsize,"|>");
+   arrow->SetFillColor(1);
+   arrow->SetFillStyle(1001);
+   arrow->Draw();
+
+   RelTimeClasses->Modified();
+   RelTimeClasses->cd();
+
+   RelTimeClasses->SaveAs("htmldoc/images/RelTimeClasses.gif");
+
+
+}
Index: /tags/Mars_V0-8-5/Mars/macros/calibrate_data.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/calibrate_data.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/calibrate_data.C	(revision 9661)
@@ -0,0 +1,385 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Hendrik Bartko, 03/2004 <mailto:hbartko@mppmu.mpg.de>
+!              Markus Gaug,    03/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+const TString defpath = "./";
+const TString defrout = "output_test.root";
+
+const Int_t defpedr [] = {20122};
+const Int_t defcalr [] = {20125};
+const Int_t defdatar[] = {20122};
+
+void calibrate_data(const TString inpath=defpath, 
+                    const Int_t psize=1, const Int_t pedruns[]=defpedr, 
+                    const Int_t csize=1, const Int_t calruns[]=defcalr, 
+                    const Int_t dsize=1, const Int_t dataruns[]=defdatar, 
+                    const TString resname=defrout)
+
+{
+
+//  MExtractSlidingWindow extractor;
+
+  MExtractFixedWindowPeakSearch extractor;
+  MExtractTimeFastSpline timeext;
+
+  MRunIter pruns;
+  MRunIter cruns;
+  MRunIter druns;
+  
+  for (Int_t i=0;i<psize;i++) {
+    cout << "Adding pedestal run: " << pedruns[i] << endl;
+    pruns.AddRun(pedruns[i],inpath);
+  }
+  for (Int_t i=0;i<csize;i++) {
+    cout << "Adding calibration run: " << calruns[i] << endl;
+    cruns.AddRun(calruns[i],inpath);
+  }
+  for (Int_t i=0;i<dsize;i++) {
+    cout << "Adding data run: " << dataruns[i] << endl;
+    druns.AddRun(dataruns[i],inpath);
+  }
+
+
+  MStatusDisplay *display = new MStatusDisplay;
+  display->SetUpdateTime(3000);
+  display->Resize(850,700);
+
+  gStyle->SetOptStat(1111);
+  gStyle->SetOptFit();
+
+  /************************************/
+  /* FIRST LOOP: PEDESTAL COMPUTATION */
+  /************************************/
+  
+  MParList plist1;
+  MTaskList tlist1;
+  plist1.AddToList(&tlist1);
+  
+  // containers
+  MPedestalCam   pedcam;
+  MBadPixelsCam  badcam;
+  //
+  // for excluding pixels from the beginning:
+  //
+  // badcam.AsciiRead("badpixels.dat");
+
+
+  plist1.AddToList(&pedcam);
+  plist1.AddToList(&badcam);
+    
+  //tasks
+  MReadMarsFile  read("Events");
+  read.DisableAutoScheme();
+  static_cast<MRead&>(read).AddFiles(pruns);
+
+  MGeomApply     geomapl;
+  MPedCalcPedRun pedcalc;
+  MGeomCamMagic  geomcam;
+    
+  tlist1.AddToList(&read);
+  tlist1.AddToList(&geomapl);
+  tlist1.AddToList(&pedcalc);
+
+  // Create and execute the event looper
+  MEvtLoop pedloop;
+  pedloop.SetParList(&plist1);
+  pedloop.SetDisplay(display);
+
+  cout << "*************************" << endl;
+  cout << "** COMPUTING PEDESTALS **" << endl;
+  cout << "*************************" << endl;
+
+  if (!pedloop.Eventloop())
+    return;
+  
+  tlist1.PrintStatistics();
+
+  // 
+  // Now the short version: 
+  //
+  //
+  // Now setup the new tasks for the calibration:
+  // ---------------------------------------------------
+  //
+  MJCalibration     calloop;
+  calloop.SetInput(&cruns);
+  //  calloop.SetFullDisplay();
+  //
+  calloop.SetExtractor(&extractor);
+  //
+  // Set the corr. cams:
+  //
+  calloop.SetBadPixels(badcam);
+  //
+  // The next two commands are for the display:
+  //
+  calloop.SetDisplay(display);
+  
+  //
+  // Apply rel. time calibration:
+  //
+  calloop.SetRelTimeCalibration();
+  calloop.SetTimeExtractor(&timeext);
+  //
+  // Do the event-loop:
+  //
+  cout << "***************************" << endl;
+  cout << "** COMPUTING CALIBRATION **" << endl;
+  cout << "***************************" << endl;
+  
+  if (!calloop.Process(pedcam))
+    return;
+
+  badcam.Print();
+  
+  MBadPixelsCam          &badbad  = calloop.GetBadPixels();
+  MCalibrationChargeCam  &calcam  = calloop.GetCalibrationCam();
+  MCalibrationRelTimeCam &timecam = calloop.GetRelTimeCam();
+  MCalibrationQECam      &qecam   = calloop.GetQECam();
+
+  badbad.Print();
+
+  /************************************************************************/
+  /*                THIRD LOOP: DATA CALIBRATION INTO PHOTONS             */
+  /************************************************************************/
+
+  // Create an empty Parameter List and an empty Task List
+  MParList  plist3;  
+  MTaskList tlist3;
+  plist3.AddToList(&tlist3);
+ 
+  // containers
+  MCerPhotEvt         photevt;
+  MPedPhotCam         pedphotcam;
+  MSrcPosCam          srccam;
+  MRawRunHeader       runhead;
+  MExtractedSignalCam sigcam;
+
+  plist3.AddToList(&geomcam );
+  plist3.AddToList(&pedcam  );
+  plist3.AddToList(&calcam  );
+  plist3.AddToList(&qecam   );
+  plist3.AddToList(&badbad  );
+  plist3.AddToList(&timecam );
+  plist3.AddToList(&sigcam  );
+  plist3.AddToList(&photevt);
+  plist3.AddToList(&pedphotcam);
+  plist3.AddToList(&srccam);
+  plist3.AddToList(&runhead);
+
+  //tasks
+  MReadMarsFile read3("Events");
+  read3.DisableAutoScheme();
+  static_cast<MRead&>(read3).AddFiles(druns);
+
+  MArrivalTimeCalc2   timecalc;
+  MCalibrateData      photcalc;     
+  photcalc.SetCalibrationMode(MCalibrateData::kFfactor);  // !!! was only MCalibrate
+  // MPedPhotCalc     pedphotcalc;   // already done by MCalibrate Data
+  // MCerPhotCalc     cerphotcalc;  // already done by MCalibrate Data
+  
+  tlist3.AddToList(&read3);
+  tlist3.AddToList(&geomapl);
+  tlist3.AddToList(&extractor);
+  tlist3.AddToList(&timecalc);
+  //  tlist3.AddToList(&cerphotcalc); // already done by MCalibrate Data
+  tlist3.AddToList(&photcalc);
+  // tlist3.AddToList(&pedphotcalc);   // already done by MCalibrate Data
+
+  MWriteRootFile write(resname);
+  
+  write.AddContainer("MGeomCam"              , "RunHeaders");
+  write.AddContainer("MRawRunHeader"         , "RunHeaders");
+  write.AddContainer("MSrcPosCam"            , "RunHeaders");
+  write.AddContainer("MCalibrationChargeCam" , "RunHeaders");
+  write.AddContainer("MCalibrationQECam"     , "RunHeaders");
+  //  write.AddContainer("MPedPhotCam","RunHeaders"); // Attention, was in Events - Tree!!
+  write.AddContainer("MPedestalCam"          , "RunHeaders");
+  write.AddContainer("MCalibrationRelTimeCam", "RunHeaders");
+
+  write.AddContainer("MCerPhotEvt"   , "Events");
+  write.AddContainer("MRawEvtHeader" , "Events");
+  write.AddContainer("MBadPixelsCam" , "Events");
+  write.AddContainer("MPedPhotCam"   , "Events");
+
+  tlist3.AddToList(&write);
+  
+  // Create and execute eventloop
+  MEvtLoop evtloop3;
+  evtloop3.SetParList(&plist3);
+    
+  cout << "*************************************************************" << endl;
+  cout << "***   COMPUTING DATA USING EXTRACTED SIGNAL (IN PHOTONS)  ***" << endl;
+  cout << "*************************************************************" << endl;
+  
+  if (!evtloop3.Eventloop())  
+    return;  
+  tlist3.PrintStatistics();
+
+}
+
+void CamDraw(TCanvas &c, MHCamera &cam, MCamEvent &evt, Int_t i, Int_t j, Int_t fit)
+{
+
+  c.cd(i);
+  gPad->SetBorderMode(0);
+  MHCamera *obj1=(MHCamera*)cam.DrawCopy("hist");
+  //  obj1->AddNotify(evt);
+  
+  c.cd(i+j);
+  gPad->SetBorderMode(0);
+  obj1->Draw();
+  ((MHCamera*)obj1)->SetPrettyPalette();
+
+  if (fit != 0)
+    {
+      c.cd(i+2*j);
+      gPad->SetBorderMode(0);
+      TH1D *obj2 = (TH1D*)obj1->Projection(obj1.GetName());
+      
+//      obj2->Sumw2();
+      obj2->Draw();
+      obj2->SetBit(kCanDelete);
+
+      const Double_t min   = obj2->GetBinCenter(obj2->GetXaxis()->GetFirst());
+      const Double_t max   = obj2->GetBinCenter(obj2->GetXaxis()->GetLast());
+      const Double_t integ = obj2->Integral("width")/2.5066283;
+      const Double_t mean  = obj2->GetMean();
+      const Double_t rms   = obj2->GetRMS();
+      const Double_t width = max-min;
+
+      if (rms == 0. || width == 0. )
+        return;
+      
+      switch (fit)
+        {
+        case 1:
+          TF1 *sgaus = new TF1("sgaus","gaus(0)",min,max);
+          sgaus->SetBit(kCanDelete);
+          sgaus->SetParNames("Area","#mu","#sigma");
+          sgaus->SetParameters(integ/rms,mean,rms);
+          sgaus->SetParLimits(0,0.,integ);
+          sgaus->SetParLimits(1,min,max);
+          sgaus->SetParLimits(2,0,width/1.5);
+          obj2->Fit("sgaus","QLR");
+          obj2->GetFunction("sgaus")->SetLineColor(kYellow);
+          break;
+
+        case 2:
+          TString dgausform = "([0]-[3])/[2]*exp(-0.5*(x-[1])*(x-[1])/[2]/[2])";
+          dgausform += "+[3]/[5]*exp(-0.5*(x-[4])*(x-[4])/[5]/[5])";
+          TF1 *dgaus = new TF1("dgaus",dgausform.Data(),min,max);
+          dgaus->SetBit(kCanDelete);
+          dgaus->SetParNames("A_{tot}","#mu_{1}","#sigma_{1}","A_{2}","#mu_{2}","#sigma_{2}");
+          dgaus->SetParameters(integ,(min+mean)/2.,width/4.,
+                               integ/width/2.,(max+mean)/2.,width/4.);
+          // The left-sided Gauss 
+          dgaus->SetParLimits(0,integ-1.5,integ+1.5);
+          dgaus->SetParLimits(1,min+(width/10.),mean);
+          dgaus->SetParLimits(2,0,width/2.);
+          // The right-sided Gauss 
+          dgaus->SetParLimits(3,0,integ);
+          dgaus->SetParLimits(4,mean,max-(width/10.));
+          dgaus->SetParLimits(5,0,width/2.);
+          obj2->Fit("dgaus","QLRM");
+          obj2->GetFunction("dgaus")->SetLineColor(kYellow);
+          break;
+          
+        case 3:
+          TString tgausform = "([0]-[3]-[6])/[2]*exp(-0.5*(x-[1])*(x-[1])/[2]/[2])";
+          tgausform += "+[3]/[5]*exp(-0.5*(x-[4])*(x-[4])/[5]/[5])";
+          tgausform += "+[6]/[8]*exp(-0.5*(x-[7])*(x-[7])/[8]/[8])";
+          TF1 *tgaus = new TF1("tgaus",tgausform.Data(),min,max);
+          tgaus->SetBit(kCanDelete);
+          tgaus->SetParNames("A_{tot}","#mu_{1}","#sigma_{1}",
+                             "A_{2}","#mu_{2}","#sigma_{2}",
+                             "A_{3}","#mu_{3}","#sigma_{3}");
+          tgaus->SetParameters(integ,(min+mean)/2,width/4.,
+                               integ/width/3.,(max+mean)/2.,width/4.,
+                               integ/width/3.,mean,width/2.);
+          // The left-sided Gauss 
+          tgaus->SetParLimits(0,integ-1.5,integ+1.5);
+          tgaus->SetParLimits(1,min+(width/10.),mean);
+          tgaus->SetParLimits(2,width/15.,width/2.);
+          // The right-sided Gauss 
+          tgaus->SetParLimits(3,0.,integ);
+          tgaus->SetParLimits(4,mean,max-(width/10.));
+          tgaus->SetParLimits(5,width/15.,width/2.);
+          // The Gauss describing the outliers
+          tgaus->SetParLimits(6,0.,integ);
+          tgaus->SetParLimits(7,min,max);
+          tgaus->SetParLimits(8,width/4.,width/1.5);
+          obj2->Fit("tgaus","QLRM");
+          obj2->GetFunction("tgaus")->SetLineColor(kYellow);
+          break;
+        case 4:
+          obj2->Fit("pol0","Q");
+          obj2->GetFunction("pol0")->SetLineColor(kYellow);
+          break;
+        case 9:
+          break;
+        default:
+          obj2->Fit("gaus","Q");
+          obj2->GetFunction("gaus")->SetLineColor(kYellow);
+          break;
+        }
+      
+        TArrayI s0(3);
+        s0[0] = 6;
+        s0[1] = 1;
+        s0[2] = 2;
+
+        TArrayI s1(3);
+        s1[0] = 3;
+        s1[1] = 4;
+        s1[2] = 5;
+
+        TArrayI inner(1);
+        inner[0] = 0;
+
+        TArrayI outer(1);
+        outer[0] = 1;
+
+        // Just to get the right (maximum) binning
+        TH1D *half[4];
+        half[0] = obj1->ProjectionS(s0, inner, "Sector 6-1-2 Inner");
+        half[1] = obj1->ProjectionS(s1, inner, "Sector 3-4-5 Inner");
+        half[2] = obj1->ProjectionS(s0, outer, "Sector 6-1-2 Outer");
+        half[3] = obj1->ProjectionS(s1, outer, "Sector 3-4-5 Outer");
+
+        for (int i=0; i<4; i++)      
+        {
+            half[i]->SetLineColor(kRed+i);
+            half[i]->SetDirectory(0);
+            half[i]->SetBit(kCanDelete);
+            half[i]->Draw("same");
+        }
+
+      gPad->Modified();
+      gPad->Update();
+      
+    }
+}
+
+
Index: /tags/Mars_V0-8-5/Mars/macros/calibration.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/calibration.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/calibration.C	(revision 9661)
@@ -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): Markus Gaug, 11/2003 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+/////////////////////////////////////////////////////////////////////////////
+//
+//  calibration.C
+//
+//  Needs as arguments the run number of a calibration file ("*_C_*.root") and 
+//  the run number of the corresponding pedestal file ("*_P_*.root"). 
+//
+//  The TString inpath has to be set correctly.
+//
+//  The macro searches for the pulser colour which corresponds to the calibration
+//  run number. If the run number is smaller than 20000, pulser colour "CT1" 
+//  is assumed, otherwise, it searches for the strings "green", "blue", "uv" or 
+//  "ct1" in the filenames. If no colour or multiple colours are found, the 
+//  execution is aborted.  
+//
+//  The container MBadPixelsCam is created and followed during the execution of the 
+//  rest of the macro.
+// 
+//  A first loop over the pedestal file is performed using the class MJPedestal
+//
+//  The container MCalibrationQECam is created and followed during the execution of the 
+//  rest of the macro.
+//
+//  A loop over the calibration files is performed using the class MJCalibration. 
+//  The results are displayed using the MJCalibration::SetNormalDisplay() facility, 
+//  but other displays can easily be uncommented. 
+//  The call to MJCalibration skips the relative time calibration, which can be 
+//  uncommented as well. 
+// 
+//  Last, a third loop is performed over the calibration file again in order to 
+//  "calibrate" it and test the resulting outcome.
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MJPedestal.h"
+#include "MJCalibration.h"
+#include "MJExtractSignal.h"
+#include "MJExtractCalibTest.h"
+#include "MExtractFixedWindowPeakSearch.h"
+#include "MExtractSlidingWindow.h"
+#include "MExtractFixedWindow.h"
+#include "MExtractFixedWindowSpline.h"
+#include "MExtractAmplitudeSpline.h"
+#include "MExtractTimeHighestIntegral.h"
+#include "MExtractTimeFastSpline.h"
+#include "MRunIter.h"
+#include "MStatusDisplay.h"
+#include "MCalibrationQECam.h"
+#include "MHCalibrationTestCam.h"
+#include "MHCalibrationTestPix.h"
+#include "MBadPixelsCam.h"
+#include "MArgs.h"
+#include "MArray.h"
+#include "MLog.h"
+#include "MParContainer.h"
+
+#include "TStyle.h"
+#include "TObject.h"
+#include "TObjectTable.h"
+#include "TSystem.h"
+
+#include <fstream>
+
+using namespace std;
+
+static TString outpath = "./";
+static TString inpath  = "/home/rootdata/Calib/2004_05_24/";
+static TString badfile = "";
+//
+// the default pedestal run for the calibration
+//
+static const Int_t   pedrun  = 26569;
+//
+// the default start calibration run 
+//
+static const Int_t   calrun1 = 26568;
+//
+// the default last calibration run (if 0, only one run is taken, otherwise consecutive runs 
+// between calrun1 and calrun2)
+//
+static  const Int_t calrun2 = 0;
+//
+// A switch to output debugging information about Objects use
+//
+static Bool_t debug = kFALSE;
+//
+// A switch to use the Blind Pixel
+//
+static Bool_t blindpix = kTRUE;
+//
+// A switch to use the PIN Diode 
+//
+static Bool_t pindiode = kFALSE;
+//
+// Tell if you want to calibrate times:
+//
+static Bool_t useTimes = kTRUE;
+//
+// Tell if you want to use the display:
+//
+static Bool_t useDisplay = kTRUE;
+//
+// Tell if you want to test the result afterwards
+//
+static Bool_t useTest = kTRUE;
+//
+Int_t calibration(const Int_t prun=pedrun, 
+                  const Int_t crun1=calrun1, const Int_t crun2=calrun2)
+{
+
+  if (debug)
+    TObject::SetObjectStat(kTRUE);
+
+  //
+  // Choose the signal Extractor:
+  //
+  //  MExtractFixedWindowPeakSearch extractor;
+  //  MExtractSlidingWindow  extractor;   
+  MExtractFixedWindowSpline extractor;
+  //  MExtractAmplitudeSpline extractor;
+  //  MExtractTimeAndChargeSpline extractor;
+  //
+  // Set Ranges or Windows
+  //
+  extractor.SetRange(1,14,2,13);
+  //  extractor.SetWindows(8,8);
+
+  //
+  // Choose the arrival time Extractor:
+  //
+  //  MExtractTimeHighestIntegral timeext;
+  MExtractTimeFastSpline timeext;
+  //
+  // Set Ranges or Windows
+  //
+  timeext.SetRange(0,7,3,8);
+
+  MRunIter pruns;
+  MRunIter cruns;
+
+  pruns.AddRun(prun,inpath);
+
+  if (crun2==0)
+    cruns.AddRun(crun1,inpath);
+  else
+    cruns.AddRuns(crun1,crun2,inpath);
+
+  gStyle->SetOptStat(1111);
+  gStyle->SetOptFit();
+  gStyle->SetTitleSize(0.1,"u");
+  gStyle->SetLineWidth(1);
+
+  MStatusDisplay *display = NULL;
+
+  if (useDisplay)
+    {
+      display = new MStatusDisplay;
+      display->SetUpdateTime(3000);
+      display->Resize(850,700);
+    }
+  
+  /************************************/
+  /* FIRST LOOP: PEDESTAL COMPUTATION */
+  /************************************/
+
+  MCalibrationQECam qecam;
+  MBadPixelsCam     badcam;
+  //
+  // If you want to exclude pixels from the beginning, read 
+  // an ascii-file with the corr. pixel numbers (see MBadPixelsCam)
+  //
+  if (!badfile.IsNull())
+    {
+      ifstream f(badfile.Data());
+      badcam.AsciiRead(f);  
+      f.close();
+    }
+
+  MJPedestal pedloop;
+  pedloop.SetExtractor(&extractor);
+  pedloop.SetInput(&pruns);
+  pedloop.SetOutputPath(outpath.Data());
+  if (useDisplay)
+    pedloop.SetDisplay(display);
+  pedloop.SetBadPixels(badcam);
+
+  if (!pedloop.Process())
+    return 1;
+
+  /****************************************/
+  /* SECOND LOOP: CALIBRATION COMPUTATION */
+  /****************************************/
+
+  MJCalibration calloop;
+
+  if (debug)
+    calloop.SetDebug();
+  //
+  // If you want to run the data-check on RAW DATA!!!, choose:
+  //  calloop.SetDataCheck();
+  // 
+  // If you want to see the data-check plots only, choose:
+  calloop.SetDataCheckDisplay();
+  // 
+  // For everything, you have ever dreamed of, choose:
+  //  calloop.SetFullDisplay();
+
+  //
+  // If you want to calibrate the times as well, choose:
+  //
+  calloop.SetRelTimeCalibration(useTimes);
+  calloop.SetExtractor(&extractor);
+  calloop.SetTimeExtractor(&timeext);
+  calloop.SetInput(&cruns);
+  calloop.SetOutputPath(outpath.Data());
+  if (useDisplay)
+    calloop.SetDisplay(display);
+  calloop.SetUseBlindPixel(blindpix);
+  calloop.SetUsePINDiode(pindiode);
+  calloop.SetQECam(qecam);
+  calloop.SetBadPixels(pedloop.GetBadPixels());
+
+  if (!calloop.Process(pedloop.GetPedestalCam()))
+    return 2;
+
+  //
+  // The next lines are the use the Print() function and have 
+  // all the results as ascii-tables:
+  //
+  if (debug)
+    {
+      MCalibrationChargeCam &chargecam   = calloop.GetCalibrationCam();
+      MCalibrationQECam     &nqecam      = calloop.GetQECam();
+      MBadPixelsCam         &badbad      = calloop.GetBadPixels();
+      chargecam.Print();
+      nqecam.Print();
+      badbad.Print();
+    }
+
+  gLog << endl;
+  gLog << "Mean number of photons from pulser Inner pixels (F-Factor Method): " 
+       << calloop.GetCalibrationCam().GetNumPhotonsFFactorMethod() 
+       << " +- " << calloop.GetCalibrationCam().GetNumPhotonsFFactorMethodErr() << endl;
+  gLog << endl;
+
+  /********************************************************************/
+  /* THIRD LOOP: APPLY CALIBRATION TO THE CALIBRATION FILES FOR TESTS */
+  /********************************************************************/
+
+  if (useTest)
+    {
+      
+      MJExtractCalibTest testloop;
+      
+      testloop.SetExtractor(&extractor);
+      testloop.SetTimeExtractor(&timeext);
+      testloop.SetInput(&cruns);
+      testloop.SetOutputPath(outpath);
+      if (useDisplay)
+        testloop.SetDisplay(display);
+      testloop.SetBadPixels(calloop.GetBadPixels());
+      
+      if (!testloop.ProcessD(pedloop.GetPedestalCam(),calloop.GetCalibrationCam(),calloop.GetQECam()))
+        return 3;
+      
+      if (useTimes)
+        if (!testloop.ProcessT(pedloop.GetPedestalCam(),calloop.GetRelTimeCam()))
+      return 4;
+      
+      gLog << endl;
+      gLog << "Mean equiv. number of photons from cascades per mm^2 Inner pixels: " 
+       << testloop.GetTestCam().GetMeanMeanPhotPerArea(0) 
+           << " +- " << testloop.GetTestCam().GetRmsMeanPhotPerArea(0) << endl;
+      gLog << "Sigma equiv. number of photons from cascades per mm^2 Inner pixels: " 
+           << testloop.GetTestCam().GetMeanSigmaPhotPerArea(0) 
+           << " +- " << testloop.GetTestCam().GetRmsSigmaPhotPerArea(0) << endl;
+      
+      gLog << endl;
+      gLog << "Mean equiv. number of photons from cascades per mm^2 Outer pixels: " 
+           << testloop.GetTestCam().GetMeanMeanPhotPerArea(1) 
+           << " +- " << testloop.GetTestCam().GetRmsMeanPhotPerArea(1) << endl;
+      gLog << "Sigma equiv. number of photons from cascades per mm^2 Outer pixels: " 
+           << testloop.GetTestCam().GetMeanSigmaPhotPerArea(1) 
+           << " +- " << testloop.GetTestCam().GetRmsSigmaPhotPerArea(1) << endl;
+      gLog << endl;  
+      
+    }
+  
+  /********************************************************************/
+  /* FOURTH LOOP: APPLY CALIBRATION TO THE PEDESTAL FILES             */
+  /********************************************************************/
+
+  MJExtractSignal pedphotloop;
+
+  pedphotloop.SetExtractor(&extractor);
+  pedphotloop.SetTimeExtractor(&timeext);
+  pedphotloop.SetInput(&pruns);
+  pedphotloop.SetOutputPath(outpath);
+  if (useDisplay)
+    pedphotloop.SetDisplay(display);
+  pedphotloop.SetBadPixels(calloop.GetBadPixels());
+  
+  if (!pedphotloop.ProcessP(pedloop.GetPedestalCam(),calloop.GetCalibrationCam(),calloop.GetQECam()))
+    return 5;
+
+
+  if (debug)
+    TObject::SetObjectStat(kFALSE);
+
+  //
+  // Debugging at the end:
+  // 
+  if (debug)
+    gObjectTable->Print();
+
+  //
+  // List of useful containers:
+  // 
+/*
+  MPedestalCam          &pedcam      = pedloop.GetPedestalCam();
+  MCalibrationChargeCam &chargecam   = calloop.GetCalibrationCam();
+  MCalibrationQECam     &qecam       = calloop.GetCalibrationCam();
+  MBadPixelsCam         &badcam      = calloop.GetBadPixels();
+  MHCalibrationTestCam  &testcam     = testloop.GetTestCam();
+  MHCalibrationTestTimeCam &testtime = testloop.GetTestTimeCam();
+*/
+
+  //
+  // List of interesting plots:
+  // 
+/*
+  testcam[200].DrawClone("fourierevents");
+  testcam.GetAverageHiGainArea(0).DrawClone();
+  testcam.GetAverageLoGainArea(0).DrawClone();
+  testcam.GetAverageHiGainArea(1).DrawClone();
+  testcam.GetAverageLoGainArea(1).DrawClone();
+
+  testcam.GetAverageHiGainSector(1).DrawClone();
+  testcam.GetAverageLoGainSector(1).DrawClone();
+  testcam.GetAverageHiGainSector(2).DrawClone();
+  testcam.GetAverageLoGainSector(2).DrawClone();
+  testcam.GetAverageHiGainSector(3).DrawClone();
+  testcam.GetAverageLoGainSector(3).DrawClone();
+  testcam.GetAverageHiGainSector(4).DrawClone();
+  testcam.GetAverageLoGainSector(4).DrawClone();
+  testcam.GetAverageHiGainSector(5).DrawClone();
+  testcam.GetAverageLoGainSector(5).DrawClone();
+  testcam.GetAverageHiGainSector(6).DrawClone();
+  testcam.GetAverageLoGainSector(6).DrawClone();
+*/
+
+  return 0;
+
+}
+
+static void Usage()
+{
+    gLog << endl;
+    gLog << "Usage:" << endl;
+    gLog << endl;
+    gLog << "   calibration [ped.run nr.] [first cal.run nr.] [last cal.run nr.]" << endl ;
+    gLog << endl;
+    gLog << "   ped.run.nr:        Run number of the pedestal file." << endl;
+    gLog << "   first cal.run nr.: Run number of the first calibration file." << endl;
+    gLog << "   last  cal.run nr.: Run number of the last  calibration file." << endl;
+    gLog << endl;
+    gLog << "All calibration runs between (first cal.run nr.) and (last  cal.run nr.) will be used" << endl;
+    gLog << "If last.cal.run.nr is 0 (default), only one calibration run is taken"                  << endl;
+    gLog << endl;
+    gLog << "Additional Options: " << endl;
+    gLog << "     --inpath=#          Find the data in inpath"                      << endl;
+    gLog << "     --outpath=#         Write the output containers to outpath"       << endl;
+    gLog << "     --badfile=#         Use the file # to exclude pixels from the beginning" << endl;
+    gLog << "     --debug             Use the TObjectTable for debugging    "       << endl;
+    gLog << "                             and write out the pixels as ascii tables" << endl;
+    gLog << "     --useTimes          Calibrate the relative arrival times"         << endl;
+    gLog << "     --useTest           Use the class MJExtractCalibTest to test the calibration on itself" << endl;
+    gLog << "     --skipBlindPix      Skip the blind pixel calibration"             << endl;
+    gLog << "     --skipPINDiode      Skip the PIN Diode   calibration"             << endl;
+}
+
+
+int main(int argc, char **argv)
+{
+  //
+  // Evaluate arguments
+  //
+  MArgs arg(argc, argv);
+  
+  if (arg.HasOnly("-?") || arg.HasOnly("-h") || arg.HasOnly("--help"))
+    {
+      Usage();
+      return -1;
+    }
+  
+  debug    = arg.HasOnlyAndRemove("--debug")    || arg.HasOnlyAndRemove("-d");
+  useTimes = arg.HasOnlyAndRemove("--useTimes") || arg.HasOnlyAndRemove("-t");
+  useTest  = arg.HasOnlyAndRemove("--useTest")  || arg.HasOnlyAndRemove("-e");
+  blindpix = !(arg.HasOnlyAndRemove("--skipBlindPix"));
+  pindiode = !(arg.HasOnlyAndRemove("--skipPINDiode"));
+
+  if (arg.HasOption("--inpath="))
+    inpath = arg.GetStringAndRemove("--inpath=");
+
+  if (arg.HasOption("--outpath="))
+    outpath = arg.GetStringAndRemove("--outpath=");
+
+  if (arg.HasOption("--badfile="))
+    badfile = arg.GetStringAndRemove("--badfile=");
+
+  if (gSystem->AccessPathName(badfile,kFileExists))
+  {
+    gLog << "WARNING: the bad pixels file '" << badfile.Data() << "' doesn't exist." << endl;
+    badfile = "";
+  }
+
+  // check for the right usage of the program
+  //
+  if (arg.GetNumArguments()>4)
+    {
+      Usage();
+      return -1;
+    }
+
+  //
+  // Initialize Non-GUI (batch) mode
+  //
+  gROOT->SetBatch();
+  
+  //
+  // Switch off the display
+  //
+  useDisplay = kFALSE;
+
+
+  //
+  // check for the arguments
+  //
+  Int_t pedr  = 0;
+  Int_t calr1 = 0;
+  Int_t calr2 = 0;
+
+  const Int_t nargs = arg.GetNumArguments();
+
+  if (nargs>=3)
+    {
+      pedr = arg.GetArgumentInt(0);
+      calr1 = arg.GetArgumentInt(1);
+      calr2 = arg.GetArgumentInt(2);
+      return calibration(pedr,calr1,calr2);
+    }
+
+  if (nargs>=2)
+    {
+      pedr = arg.GetArgumentInt(0);
+      calr1 = arg.GetArgumentInt(1);
+      return calibration(pedr,calr1);
+    }
+
+  if (nargs>=1)
+    {
+      pedr = arg.GetArgumentInt(0);
+      gLog << "PEDR: " << pedr << endl;
+      return calibration(pedr);
+    }
+
+  return calibration();
+}
Index: /tags/Mars_V0-8-5/Mars/macros/collarea.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/collarea.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/collarea.C	(revision 9661)
@@ -0,0 +1,90 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+
+void collarea(TString filename="camera.root", TString outname="")
+{
+    MStatusDisplay *d = new MStatusDisplay;
+    // redirect logging output to GUI, kFALSE to disable stream to stdout
+    d->SetLogStream(&gLog, kTRUE);
+
+    //
+    // 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
+    //
+    magic.SetDisplay(d);
+    if (!magic.Eventloop())
+        return;
+
+    tasklist.PrintStatistics();
+
+    //
+    // Now the histogram we wanted to get out of the data is
+    // filled and can be displayed
+    //
+    if ((d = magic.GetDisplay()))
+        d->AddTab("Collection Area");
+    else
+        new TCanvas("CollArea", "Result of the collection area calculation");
+
+    parlist.FindObject("MHMcCollectionArea")->DrawClone("nonew");
+
+
+    //
+    // Write histogram to a file in case an output
+    // filename has been supplied
+    //
+    if (outname.IsNull())
+        return;
+
+    TFile f(outname, "recreate");
+    if (!f)
+        return;
+
+    parlist.FindObject("MHMcCollectionArea")->Write();
+}
Index: /tags/Mars_V0-8-5/Mars/macros/comprob.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/comprob.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/comprob.C	(revision 9661)
@@ -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.
+! *
+!
+!   macro comprob.C
+!
+!   Author(s): Abelardo Moralejo
+!   Author(s): Thomas Bretz, 2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////////
+//
+//  This macro demonstrates one way of gamma hadron separation using the
+//  composite probability method. To use it you need a star-file (which is
+//  a file ouput by the star.C macro containing image parameters)
+//
+///////////////////////////////////////////////////////////////////////////
+void comprob()
+{
+    //
+    // Create a empty Parameter List and an empty Task List
+    // The tasklist is identified in the eventloop by its name
+    //
+    MParList  plist;
+
+    // Create task list and add it to the parameter list:
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    // First task in list: read the star file (reference data)
+    MReadMarsFile read("Events", "star.root");
+    read.DisableAutoScheme();
+    tlist.AddToList(&read);
+
+    //
+    // Task to do the composite analysis of Hillas parameters:
+    // Add(rule, number of bins, lower limit, upper limit)
+    // For the meaning of the rule see MDataChain
+    //
+    MHCompProb compprob(500);
+    compprob.Add("MHillas.fWidth",              500,    0, 160);
+    compprob.Add("MHillas.fLength",             500,    0, 300);
+    compprob.Add("abs(MHillas.fAsym)",          500,    0, 400);
+    compprob.Add("MHillasSrc.fDist",            500,    0, 400);
+    compprob.Add("abs(MHillasSrc.fHeadTail)",   500,    0, 400);
+    compprob.Add("abs(MHillas.fM3Long)",        500,    0, 300);
+    compprob.Add("abs(MHillas.fM3Trans)",       500,    0, 150);
+    compprob.Add("MHillas.fConc1",              500,    0, 0.6);
+    compprob.Add("MHillas.fConc",               500,    0, 0.9);
+    compprob.Add("log10(MHillas.fSize)",        500,    0,   5);
+
+    plist.AddToList(&compprob);
+
+    MFillH fill(&compprob, "MMcEvt");
+
+    // Use this if you want to do it for a fixed energy range:
+    /*
+     MF filter("MMcEvt.fEnergy < 100");
+     fill->SetFilter(&filter);
+     tlist.AddToList(&filter);
+     */
+
+    tlist.AddToList(&fill);
+
+    //
+    // Create and setup the eventloop
+    //
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    // Loop over all data to fill the "normal" histograms:
+    if (!evtloop.Eventloop())
+        return;
+
+    tlist.PrintStatistics();
+
+    gLog.SetDebugLevel(2);
+
+    // Loop to fill the variable bin histograms:
+    read.SetEventNum(0);
+    if (!evtloop.Eventloop())
+        return;
+
+    // ------------------------------------------------------------------
+
+    // Create task list and replace the old task list with the new one
+    MTaskList tlist2;
+    plist.Replace(&tlist2);
+
+    // First task in list: read star file (test data)
+    MReadMarsFile read2("Events", "star2.root");
+    read2.DisableAutoScheme();
+    tlist2.AddToList(&read2);
+
+    // create task to calculate composite probabilities
+    MCompProbCalc calc;
+    tlist2.AddToList(&calc);
+
+    // fill probabilities (hadroness) into histogram
+    MFillH fill2("MHHadronness");
+    tlist2.AddToList(&fill2);
+
+    // Loop to fill the hadronness histograms:
+    if (!evtloop.Eventloop())
+        return;
+
+    //
+    // Display the hadroness histograms and print some informations on
+    // the console window
+    //
+    plist.FindObject("MHHadronness")->DrawClone();
+    plist.FindObject("MHHadronness")->Print();
+}
+
Index: /tags/Mars_V0-8-5/Mars/macros/datatrigcheck.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/datatrigcheck.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/datatrigcheck.C	(revision 9661)
@@ -0,0 +1,227 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Nicola Galante, 3/2004 <mailto:nicola.galante@pi.infn.it>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  datatrigcheck 
+//
+//  This macro is the standard trigger's parameters checking stuff
+//  
+//
+/////////////////////////////////////////////////////////////////////////////
+Double_t myPoisson(Double_t *x, Double_t *par)
+{
+  Double_t a=0.0, b=0.0, c=0.0;
+  Double_t fitval = 0.0;
+
+  Int_t floorX = (Int_t)TMath::Floor(x[0]);
+  a = TMath::Power(par[0],floorX);
+  b = TMath::Exp(-par[0]);
+  c = TMath::Factorial(floorX);
+ 
+  if (c!=0)
+    fitval = par[1]*a*b/c;
+
+  return fitval;
+}
+
+Double_t myExp(Double_t *x, Double_t *par)
+{
+  Double_t a=0.0;
+  Double_t fitval = 0.0;
+
+  a = TMath::Exp(-x[0]);
+  fitval = par[0]*a;
+
+  return fitval;
+}
+
+// The macro
+//  Input:
+//   1. The directory path starting from the Period (the complete path is
+//       written in the basedir variable)
+//   2. The data filename (without extension)
+//
+void datatrigcheck(TString dirin="Period014/rootdata/2004_02_17/", TString filein="20040117_03695_D_Crab-On_E")
+{
+ 
+  // Set file name and INPUT and OUTPUT directories
+  
+  TString basedir="/data1/earth/magic/data/";
+  
+  TString filenamein(filein);
+  TString dirnamein(dirin);
+  
+  dirnamein = basedir+dirnamein;
+  filenamein = dirnamein + filein + ".root";
+  
+  // Here the output plots are saved
+  TString webdatadir = basedir + "webdata/" + filein + "/";   
+  
+  //
+  // 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);
+  
+  MReadMarsFile read("Events");
+  read.DisableAutoScheme();
+  read.AddFile(filenamein);
+  
+  tlist.AddToList(&read);
+  
+  //
+  // Extract Number of events
+  //
+  const Int_t numEvt = read.GetEntries();
+
+  cout << "Opened file " << filenamein << " with "<< numEvt << " events." << endl;
+  // ==================
+  // Create histos
+  // FIXME: should be created using MH or similar?
+  
+  // HISTcom-hTrigPatternEvt
+  // The trigger pattern is shown as a decimal number
+  // The trigger pattern consists of 16 bits (8+8 bits) generated by the trigger system. 
+  // The first 8 bits correspond to the trigger configuration before the prescaling, 
+  // the others after prescaling.
+  //    Bit structure: 
+  //          not prscd | prscaled
+  //          xxxx xxxx xxxx xxxx    <-- pattern (x=0,1)
+  //    bit   7654 3210 7654 3210
+  //
+    TH1I *hTrigPatternEvt = new TH1I("hTrigPatternEvt","Trigger Pattern vs. Event Number",numEvt,0,(Axis_t)numEvt);
+
+    // HISTcom-hTimeEvt
+    // Absolute time vs event number 
+    // The Absolute time has been calculated using the MTime->GetTime() (millisec) and the MTime->GetMjd() (nanosec)
+    TH1D *hTimeEvt = new TH1D("hTimeEvt","DAQ Time vs. Event Number",numEvt,0,(Axis_t)numEvt);
+    
+    // HISTcom-hTimeDiffEvt
+    TH1D *hTimeDiffEvt = new TH1D("hTimeDiffEvt","Differences of time vs. Event Number",numEvt-1,0,(Axis_t)numEvt-1);
+ 
+    // HISTcom-hTimeDiff
+    TH1D *hTimeDiff = new TH1D("hTimeDiff","Distribution of differences of time (ns)",200,0,1000000);
+    
+
+    TF1 *func1 = new TF1("myPoisson",myPoisson,0,10,2);
+    TF1 *func2 = new TF1("myExp",myExp,0,10,1);
+
+    cout << "*func defined" << endl;
+    func1->SetParameters(1.0,1.0);
+    func2->SetParameter(0,400.0);
+    cout << "parameters setted" << endl;
+    func1->SetParNames("MU","CONST");
+    func2->SetParNames("A");
+
+    //
+    // Create and set up the eventloop
+    //
+    MProgressBar bar;
+
+    MEvtLoop evtloop;
+    evtloop.SetProgressBar(&bar);
+    evtloop.SetParList(&plist);
+
+    Double_t tOld;  // buffer variable
+    Double_t tMin = 1E+10;
+    Double_t tMax = -1E+10;
+    Double_t DAQNumMin = 1E+10;
+    //
+    // Execute your analysis
+    //
+    //if (!evtloop.Eventloop())
+    //    return;
+    if (!evtloop.PreProcess())
+    return;
+    
+    while (tlist.Process())
+      {
+	// Create the container MRawEvtHeader where time and trigger 
+	//  info are read and stored.
+	MRawEvtHeader *evtHeader = (MRawEvtHeader *)plist->FindObject("MRawEvtHeader");
+	MTime *evtTime = (MTime *)plist->FindObject("MTime");
+
+	Long_t ms = evtTime->GetTime();
+	Double_t ns = ((evtTime->GetMjd()-TMath::Floor(evtTime->GetMjd()))*(Double_t)evtTime->kDay-(Double_t)ms)*1E+6;
+	Double_t t = (Double_t)ms+ns/1.E+6;
+	if (t<tMin) tMin=t;
+
+	// Fill the histos
+	hTrigPatternEvt->Fill(evtHeader->GetDAQEvtNumber(),evtHeader->GetTriggerID());
+ 	hTimeEvt->Fill(evtHeader->GetDAQEvtNumber(),t);
+	if (evtHeader->GetDAQEvtNumber() != 0){
+	  hTimeDiffEvt->Fill(evtHeader->GetDAQEvtNumber(),t-tOld);
+	  hTimeDiff->Fill((t-tOld)*1E+6);
+	}
+	if (t-tOld > tMax) tMax = t-tOld;
+	tOld = t;
+      }
+
+    //TString command = "./macros/create_web_folder.sh " + webdatadir + filein ;
+
+    // Create new directory with the same name of the run.
+    // Delete old content.
+    //
+    TString command = "mkdir -p " + webdatadir ;
+    system ( command.Data() ) ;
+    command = "rm -f " + webdatadir + "*.gif" ;
+    system ( command.Data() ) ;
+    command = "rm -f " + webdatadir + "*.txt" ;
+    system ( command.Data() ) ;
+
+    tlist.PrintStatistics();
+
+    // Draw Plots and save them as gif images
+    //
+    c1 = new TCanvas( "c1" );
+    hTrigPatternEvt->SetXTitle("Event");
+    hTrigPatternEvt->SetYTitle("Trigger Pattern");
+    hTrigPatternEvt->Draw();
+    c1->Print(webdatadir+hTrigPatternEvt->GetName()+".gif");
+
+    c2 = new TCanvas( "c2" );
+    hTimeEvt->SetXTitle("Event");
+    hTimeEvt->SetYTitle("Abs. time (ms)");
+    hTimeEvt->SetMinimum(tMin);
+    hTimeEvt->Draw();
+    c2->Print(webdatadir+hTimeEvt->GetName()+".gif");
+
+    c3 = new TCanvas( "c3" );
+    hTimeDiffEvt->SetXTitle("Event");
+    hTimeDiffEvt->SetYTitle("Time diff (ms)");
+    hTimeDiffEvt->SetMaximum(tMax*1.1);
+    hTimeDiffEvt->Draw();
+    c3->Print(webdatadir+hTimeDiffEvt->GetName()+".gif");
+
+    c4 = new TCanvas( "c4" );
+    hTimeDiff->SetXTitle("Time diff. (ms)");
+    hTimeDiff->SetYTitle("Events");
+    hTimeDiff->Draw();
+    c4->Print(webdatadir+hTimeDiff->GetName()+".gif");
+
+}
Index: /tags/Mars_V0-8-5/Mars/macros/derotatedc.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/derotatedc.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/derotatedc.C	(revision 9661)
@@ -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, 4/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// derotatedc.C
+// ============
+//
+// Derotate a MCamEvent and fill a histogram with derotated data
+// (sky-plot).
+//
+// As an input you need a merpped root file conataining DC information
+// from a camera report file. To be able to derotate you also need
+// aproproitate time-stamps and the corresponding pointing information.
+//
+// All events are filled into a 2D histograms - derotated.
+//
+// The example shows the usage of MHCamEventRot. The output is the derotated
+// sky-plot.
+//
+/////////////////////////////////////////////////////////////////////////////
+
+void derotatedc()
+{
+    //
+    // 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);
+
+    // Define Observatory location (for derotation)
+    MObservatory obs;
+    plist.AddToList(&obs);
+
+    // Set the camera geometry (for histogram size)
+    MGeomCamMagic cam;
+    plist.AddToList(&cam);
+
+    // setup pointing position
+    MPointingPos ppos;
+    ppos.SetSkyPosition(MAstro::Hms2Hor(5, 34, 31.9), MAstro::Dms2Deg(22, 0, 52.0));
+    plist.AddToList(&ppos);
+
+    // Define which file to read
+    MReadTree read("Currents", "../dc.root");
+    read.DisableAutoScheme();
+
+    // Derotated histogram to fill
+    MHCamEventRot hist;
+
+    // Set name of time container corresponding to your data
+    hist.SetNameTime("MTimeCurrents");
+
+    // Setup fill task
+    MFillH fill(&hist, "MCameraDC");
+
+    // Set a draw option for your 2D histogram
+    //fill.SetDrawOption("colz");
+
+    // Setup tasklist
+    tlist.AddToList(&read);
+    tlist.AddToList(&fill);
+
+    //
+    // Create and setup the eventloop
+    //
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    MStatusDisplay *d = new MStatusDisplay;
+    evtloop.SetDisplay(d);
+
+    //
+    // Execute your analysis
+    //
+    if (!evtloop.Eventloop())
+        return;
+
+    tlist.PrintStatistics();
+}
Index: /tags/Mars_V0-8-5/Mars/macros/dohtml.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/dohtml.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/dohtml.C	(revision 9661)
@@ -0,0 +1,125 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////////
+//
+// dohtml.C
+// ========
+//
+// This is a service macro used to create the html-documentation from
+// source code (THtml)
+//
+// Add here all directories in which files are stored from which the
+// documentation should be created an add all macros which should be
+// converted to HTML.
+//
+///////////////////////////////////////////////////////////////////////////
+
+void dohtml()
+{
+    //
+    //  don't forget that the shared object must have been loaded
+    //
+
+    //
+    // Do not print 'Info' messages from the root system such like
+    // TCanvas::Print
+    //
+    gErrorIgnoreLevel=kWarning;
+
+    //
+    //   create the html document class
+    //
+    THtml html;
+
+    TString sourcedir;
+    sourcedir += "manalysis:";
+    sourcedir += "mastro:";
+    sourcedir += "mbadpixels:";
+    sourcedir += "mbase:";
+    sourcedir += "mcamera:";
+    sourcedir += "mcalib:";
+    sourcedir += "mdata:";
+    sourcedir += "mfbase:";
+    sourcedir += "mfileio:";
+    sourcedir += "mfilter:";
+    sourcedir += "mfit:";
+    sourcedir += "mgeom:";
+    sourcedir += "mgui:";
+    sourcedir += "mhbase:";
+    sourcedir += "mhist:";
+    sourcedir += "mhistmc:";
+    sourcedir += "mhvstime:";
+    sourcedir += "mimage:";
+    sourcedir += "mjobs:";
+    sourcedir += "mmain:";
+    sourcedir += "mmc:";
+    sourcedir += "mmontecarlo:";
+    sourcedir += "mpointing:";
+    sourcedir += "mpedestal:";
+    sourcedir += "mranforest:";
+    sourcedir += "mraw:";
+    sourcedir += "mreflector:";
+    sourcedir += "mreport:";
+    sourcedir += "msignal:";
+    sourcedir += "msql:";
+    sourcedir += "mtools:";
+    sourcedir += ".:";
+
+    html.SetSourceDir(sourcedir);
+    html.SetOutputDir("htmldoc");
+
+    html.MakeAll(kTRUE);
+
+    html.SetSourceDir("macros");
+    html.Convert("merpp.C",         "MARS - Merging and Preprocessing");
+    html.Convert("readraw.C",       "MARS - How To Read A Raw");
+    html.Convert("rootlogon.C",     "MARS - rootlogon.C");
+    html.Convert("readCT1.C",       "MARS - Read and display CT1 Events");
+    html.Convert("readMagic.C",     "MARS - Read and display Magic Events");
+    html.Convert("CT1Hillas.C",     "MARS - Calculate CT1 Hillas");
+    html.Convert("MagicHillas.C",   "MARS - Calculate Magic Hillas");
+    html.Convert("collarea.C",      "MARS - Calculate Collection Area from a MC root file");
+    html.Convert("threshold.C",     "MARS - Calculate Energy Threshold from a MC root file");
+    html.Convert("trigrate.C",      "MARS - Calculate Trigger Rate from a MC root file");
+    html.Convert("star.C",          "MARS - (St)andard (A)nalysis and (R)econstruction");
+    html.Convert("starplot.C",      "MARS - Plot parameters from file created with star.C");
+    html.Convert("comprob.C",       "MARS - Calculation of composite probabilities for G/H-Seperation");
+    html.Convert("multidimdist.C",  "MARS - Calculation of multidimensional distances for G/H-Seperation");
+    html.Convert("multidimdist2.C", "MARS - Calculation of multidimensional distances for G/H-Seperation");
+    html.Convert("estimate.C",      "MARS - Shows results from the energy estimation");
+    html.Convert("estfit.C",        "MARS - Fits the coefficients of the energy estimator MEnergyEstParam");
+    html.Convert("plot.C",          "MARS - Plots 1D mars histogram");
+    html.Convert("plot2.C",         "MARS - Plots a 2D mars histogram");
+    html.Convert("starplot.C",      "MARS - Plots data from a STAR-file into a mars histogram");
+    html.Convert("testenv.C",       "MARS - Example to use TEnv and Mars Eventloops");
+    html.Convert("triglvl2.C",      "MARS - Example to use MMcTriggerLvl2 class, using filters and creating histograms");
+    html.Convert("status.C",        "MARS - Example to use the online display");
+    html.Convert("calibration.C",   "MARS - Example to use the calibration");
+    html.Convert("pedvsevent.C",    "MARS - Example to use MPedCalcPedRun");
+    html.Convert("pedphotcalc.C",   "MARS - Example to use MPedPhotCalc");
+    html.Convert("sectorvstime.C",  "MARS - Example how to plot mean value of a camera sector versus time");
+    html.Convert("calibration.C",   "MARS - Example how to use the calibrationa camera ");
+    html.Convert("bootcampstandardanalysis.C",  "MARS - Example of the status of the standard analysis at the bootcamp");
+}
Index: /tags/Mars_V0-8-5/Mars/macros/estct1.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/estct1.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/estct1.C	(revision 9661)
@@ -0,0 +1,243 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz et al,  09/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+
+void estct1()
+{
+    //
+    // This is a demonstration program which calculates the Hillas
+    // parameter out of a Magic root file (raw data file).
+    //
+
+    //
+    // Create a empty Parameter List and an empty Task List
+    // The tasklist is identified in the eventloop by its name
+    //
+    MParList plist;
+
+
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    //
+    // Now setup the tasks and tasklist:
+    // ---------------------------------
+    //
+    MReadTree read("Events", "~/ct1/MC_ON2.root");
+
+    //MReadMarsFile read("Events");
+    read.DisableAutoScheme();
+    /*
+     read.AddFile("star.root");
+     read.AddFile("star2.root");
+     */
+    //read.AddFile("~/ct1/MC_ON2.root");
+
+    MEnergyEstParam eest("Hillas");
+    eest.Add("HillasSrc");
+
+    //
+    // Use this to change the binnign of the histograms to CT1-style
+    //
+    Bool_t usect1 = kTRUE;
+
+    //
+    // Here you set up the coefficients of the parametrization
+    // (MEnergyEstParam)
+    //
+    TArrayD fA(5);
+    fA[0] = -3907.74; //4916.4;     //-2414.75;
+    fA[1] = 1162.3; //149.549;    // 1134.28;
+    fA[2] = 199.351;//-558.209;   // 132.932;
+    fA[3] = 0.403192;//0.270725;   //0.292845;
+    fA[4] = 121.921;//107.001;    // 107.001;
+
+    TArrayD fB(7);
+    fB[0] =  677.821;//-8234.12;  //-4282.25;
+    fB[1] =  11.3302;//23.2153;   //  18.892;
+    fB[2] =  -0.0211177;//0.416372;  //0.193373;
+    fB[3] =  -23.0217;//332.42;    //203.803;
+    fB[4] =  -0.785242;//-0.701764; //-0.534876;
+    fB[5] = 5.6413e-5;//-0.0131774; //-0.00789539;
+    fB[6] =  -0.146595;//-0.162687; //  0.111913;
+
+    eest.SetCoeffA(fA);
+    eest.SetCoeffB(fB);
+
+    MH3 mh3e("MMcEvt.fEnergy",     "(MEnergyEst.fEnergy/MMcEvt.fEnergy-1)*(MEnergyEst.fEnergy/MMcEvt.fEnergy-1)");
+    MH3 mh3i("MMcEvt.fImpact/100", "(MEnergyEst.fImpact/MMcEvt.fImpact-1)*(MEnergyEst.fImpact/MMcEvt.fImpact-1)");
+    MH3 mh3eo("MMcEvt.fEnergy",     "MEnergyEst.fEnergy/MMcEvt.fEnergy-1");
+    MH3 mh3io("MMcEvt.fImpact/100", "MEnergyEst.fImpact/MMcEvt.fImpact-1");
+
+    MH3 mh3e2("MEnergyEst.fEnergy",     "(MEnergyEst.fEnergy/MMcEvt.fEnergy-1)*(MEnergyEst.fEnergy/MMcEvt.fEnergy-1)");
+    MH3 mh3i2("MEnergyEst.fImpact/100", "(MEnergyEst.fImpact/MMcEvt.fImpact-1)*(MEnergyEst.fImpact/MMcEvt.fImpact-1)");
+    MH3 mh3eo2("MEnergyEst.fEnergy",     "MEnergyEst.fEnergy/MMcEvt.fEnergy-1");
+    MH3 mh3io2("MEnergyEst.fImpact/100", "MEnergyEst.fImpact/MMcEvt.fImpact-1");
+
+    MH3 mhe("MMcEvt.fEnergy",     "MEnergyEst.fEnergy");
+    MH3 mhi("MMcEvt.fImpact/100", "MEnergyEst.fImpact/100");
+
+    mh3e.SetName("HistEnergy");
+    mh3i.SetName("HistImpact");
+    mh3eo.SetName("HistEnergyOffset");
+    mh3io.SetName("HistImpactOffset");
+
+    mh3e2.SetName("HistEnergy");
+    mh3i2.SetName("HistImpact");
+    mh3eo2.SetName("HistEnergyOffset");
+    mh3io2.SetName("HistImpactOffset");
+
+    mhe.SetName("HistEE");
+    mhi.SetName("HistII");
+
+    MFillH hfille(&mh3e);
+    MFillH hfilli(&mh3i);
+    MFillH hfilleo(&mh3eo);
+    MFillH hfillio(&mh3io);
+
+    MFillH hfille2(&mh3e2);
+    MFillH hfilli2(&mh3i2);
+    MFillH hfilleo2(&mh3eo2);
+    MFillH hfillio2(&mh3io2);
+
+    MFillH hfillee(&mhe);
+    MFillH hfillii(&mhi);
+
+    MBinning binsex("BinningHistEnergyX");
+    MBinning binsey("BinningHistEnergyY");
+    MBinning binsix("BinningHistImpactX");
+    MBinning binsiy("BinningHistImpactY");
+    MBinning binseox("BinningHistEnergyOffsetX");
+    MBinning binseoy("BinningHistEnergyOffsetY");
+    MBinning binsiox("BinningHistImpactOffsetX");
+    MBinning binsioy("BinningHistImpactOffsetY");
+    MBinning binseex("BinningHistEEX");
+    MBinning binsiix("BinningHistIIX");
+    MBinning binseey("BinningHistEEY");
+    MBinning binsiiy("BinningHistIIY");
+
+    binsex.SetEdgesLog(50, usect1 ? 300: 10, usect1 ? 50000 : 1e4);
+    binsey.SetEdges(50, 0, usect1 ? 0.8 : 1.75);
+    binseox.SetEdgesLog(50, usect1 ? 300 : 10, usect1 ? 50000 : 1e4);
+    binseoy.SetEdges(50, usect1 ? -0.75 : -1.75, usect1 ? 0.75 : 1.75);
+
+    binsix.SetEdges(50, 0, usect1 ? 275 : 300);
+    binsiy.SetEdges(50, 0, usect1 ? 0.2 : 1.75);
+    binsiox.SetEdges(50, 0, usect1 ? 275 : 300);
+    binsioy.SetEdges(50, usect1 ? -0.75 : -1.75, usect1 ? 0.75 : 1.75);
+
+    binseex.SetEdgesLog(50, usect1 ? 300 : 10, usect1 ? 50000 : 15e3);
+    binseey.SetEdgesLog(50, usect1 ? 300 : 1,  usect1 ? 50000 : 2e3);
+    binsiix.SetEdges(50, 0, usect1 ? 275 : 300);
+    binsiiy.SetEdges(50, 0, usect1 ? 275 : 150);
+
+    plist.AddToList(&binsex);
+    plist.AddToList(&binsey);
+    plist.AddToList(&binsix);
+    plist.AddToList(&binsiy);
+    plist.AddToList(&binseox);
+    plist.AddToList(&binseoy);
+    plist.AddToList(&binsiox);
+    plist.AddToList(&binsioy);
+    plist.AddToList(&binseex);
+    plist.AddToList(&binseey);
+    plist.AddToList(&binsiix);
+    plist.AddToList(&binsiiy);
+
+    //
+    //  Setup tasklists
+    //
+    tlist.AddToList(&read);
+
+    tlist.AddToList(&eest);
+    tlist.AddToList(&hfille);
+    tlist.AddToList(&hfilli);
+    tlist.AddToList(&hfilleo);
+    tlist.AddToList(&hfillio);
+
+    tlist.AddToList(&hfille2);
+    tlist.AddToList(&hfilli2);
+    tlist.AddToList(&hfilleo2);
+    tlist.AddToList(&hfillio2);
+
+    tlist.AddToList(&hfillee);
+    tlist.AddToList(&hfillii);
+
+    /*
+     MPrint p("MEnergyEst");
+     tlist2.AddToList(&p);
+     */
+
+    //
+    // Create and setup the eventloop
+    //
+    MProgressBar bar;
+
+    MEvtLoop evtloop;
+    evtloop.SetProgressBar(&bar);
+    evtloop.SetParList(&plist);
+
+    //
+    // Execute your analysis
+    //
+    if (!evtloop.Eventloop())
+        return;
+
+    tlist.PrintStatistics();
+
+    const TString text = "\\sqrt{<y>}=%.0f%%";
+
+    char txt[1000];
+
+    TCanvas *c=new TCanvas("Est1", "Estimates vs. E_{true}");
+    c->Divide(2,2);
+    c->cd(1);
+    mh3i.DrawClone("PROFXnonew");
+    sprintf(txt, text.Data(), sqrt(mh3i.GetHist().GetMean(2))*100);
+    TLatex *t = new TLatex(180, 0.15, txt);
+    t->Draw();
+    c->cd(2);
+    mh3e.DrawClone("PROFXnonew");
+    sprintf(txt, text.Data(), sqrt(mh3e.GetHist().GetMean(2))*100);
+    t = new TLatex(3.5, 0.6, txt);
+    t->Draw();
+    c->cd(3);
+    mh3io.DrawClone("PROFXnonew");
+    c->cd(4);
+    mh3eo.DrawClone("PROFXnonew");
+
+    c=new TCanvas("Est2", "Estimates vs. E_{est}");
+    c->Divide(2,2);
+    c->cd(1);
+    mh3i2.DrawClone("PROFXnonew");
+    c->cd(2);
+    mh3e2.DrawClone("PROFXnonew");
+    c->cd(3);
+    mh3io2.DrawClone("PROFXnonew");
+    c->cd(4);
+    mh3eo2.DrawClone("PROFXnonew");
+
+    mhe.DrawClone("PROFX");
+    mhi.DrawClone("PROFX");
+}
Index: /tags/Mars_V0-8-5/Mars/macros/estfit.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/estfit.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/estfit.C	(revision 9661)
@@ -0,0 +1,239 @@
+#include <TStopwatch.h>
+#include <TMinuit.h>
+
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MEvtLoop.h"
+
+#include "MReadTree.h"
+#include "MHMatrix.h"
+#include "MChisqEval.h"
+#include "MMatrixLoop.h"
+#include "MParameterD.h"
+#include "MDataMember.h"
+#include "MDataElement.h"
+#include "MEnergyEstParam.h"
+
+// --------------------------------------------------------------------------
+
+void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)
+{
+    MEvtLoop *evtloop = (MEvtLoop*)gMinuit->GetObjectFit();
+
+    MParList  *plist  = evtloop->GetParList();
+    MTaskList *tlist  = evtloop->GetTaskList();
+
+    MChisqEval      *eval = (MChisqEval*)     plist->FindObject("MFitResult", "MParameterD");
+    MEnergyEstParam *eest = (MEnergyEstParam*)tlist->FindObject("MEnergyEstParam");
+
+    eest->SetCoeff(TArrayD(eest->GetNumCoeff(), par));
+
+    evtloop->Eventloop();
+
+    f = eval->GetVal();
+}
+
+// --------------------------------------------------------------------------
+//
+//  0: fit impact parameter only
+//  1: fit energy only
+//  2: fit all parameters with respect to the energy resolution
+//
+void estfit(Int_t evalenergy=0)
+{
+    //
+    // Fill events into a MHMatrix
+    //
+    MParList parlist;
+    MHMatrix matrix;
+
+    Int_t col = matrix.AddColumn(evalenergy?"MMcEvt.fEnergy":"MMcEvt.fImpact");
+
+    MEnergyEstParam eest("Hillas");
+    eest.Add("HillasSrc");
+    eest.InitMapping(&matrix);
+
+    MReadTree read("Events", "MC_ON2_short.root");
+    read.DisableAutoScheme();
+
+    if (!matrix.Fill(&parlist, &read))
+        return;
+
+    //
+    // Setup the tasklist used to evaluate the needed chisq
+    //
+    MTaskList tasklist;
+    parlist.AddToList(&tasklist);
+
+    MMatrixLoop loop(&matrix);
+
+    MChisqEval eval;
+    eval.SetY1(new MDataElement(&matrix, col));
+    eval.SetY2(new MDataMember(evalenergy ? "MEnergyEst.fEnergy" : "MEnergyEst.fImpact"));
+    eval.SetOwner();
+
+    tasklist.AddToList(&loop);
+    tasklist.AddToList(&eest);
+    tasklist.AddToList(&eval);
+
+    MEvtLoop evtloop;
+    evtloop.SetParList(&parlist);
+
+    //
+    // Be carefull: This is not thread safe
+    //
+    TMinuit minuit(12);
+    minuit.SetPrintLevel(-1);
+    minuit.SetFCN(fcn);
+
+    // Ready for: minuit.mnexcm("SET ERR", arglist, 1, ierflg)
+    if (minuit.SetErrorDef(1))
+    {
+        cout << "SetErrorDef failed." << endl;
+        return;
+    }
+
+    //
+    // Set initial values
+    //
+    TArrayD fA(5);
+    TArrayD fB(7);
+    fA[0] =  392957;
+    fA[1] =  135;
+    fA[2] =  -37449;
+    fA[3] =  0.3464;
+    fA[4] =  1;
+    fB[0] =  1;
+    fB[1] =  1;
+    fB[2] =  1;
+    fB[3] =  1;
+    fB[4] =  1;
+    fB[5] =  1;
+    fB[6] =  1;
+     /*
+     fA[0] = 6122.97;
+     fA[1] = 144.889;
+     fA[2] = -601.256;
+     fA[3] = 0.00171985;
+     fA[4] = 116.451;
+     fB[0] =  -2368.21;
+     fB[1] =  1186.26;
+     fB[2] =  0.147235;
+     fB[3] =  144.49;
+     fB[4] =  42.7681;
+     fB[5] = -0.757817;
+     fB[6] =  0.182482;
+     */
+    /*
+     TArrayD fA(5);
+    fA[0] = 6122.97;
+    fA[1] = 144.889;
+    fA[2] = -601.256;
+    fA[3] = 0.00171985;
+    fA[4] = 116.451;
+
+    TArrayD fB(7);
+    fB[0] =  -10445.5;
+    fB[1] =  2172.05;
+    fB[2] =  0.69;
+    fB[3] =  491.2;
+    fB[4] =  4.71444;
+    fB[5] = -0.0331926;
+    fB[6] = -0.014833;
+    */
+    // Set starting values and step sizes for parameters
+    for (Int_t i=0; i<fA.GetSize(); i++)
+    {
+        TString name = "fA[";
+        name += i;
+        name += "]";
+        Double_t vinit = fA[i];
+        Double_t step  = fabs(fA[i]/3);
+
+        Double_t limlo = 0; // limlo=limup=0: no limits
+        Double_t limup = 0; 
+
+        Bool_t rc = minuit.DefineParameter(i, name, vinit, step, limlo, limup);
+        if (evalenergy==1)
+        {
+            minuit.FixParameter(i);
+            cout << "Fixed Parameter #" << i << endl;
+        }
+
+        if (!rc)
+            continue;
+
+        cout << "Error in defining parameter #" << i << endl;
+        return;
+    }
+
+    for (Int_t i=0; i<fB.GetSize(); i++)
+    {
+        TString name = "fB[";
+        name += i;
+        name += "]";
+        Double_t vinit = fB[i];
+        Double_t step  = fabs(fB[i]/3);
+
+        Double_t limlo = 0; // limlo=limup=0: no limits
+        Double_t limup = 0;
+
+        Bool_t rc = minuit.DefineParameter(i+fA.GetSize(), name, vinit, step, limlo, limup);
+        if (evalenergy==0)
+        {
+            minuit.FixParameter(i+fA.GetSize());
+            cout << "Fixed Parameter #" << i+fA.GetSize() << endl;
+        }
+
+        if (!rc)
+            continue;
+
+        cout << "Error in defining parameter #" << i+fA.GetSize() << endl;
+        return;
+    }
+
+    //
+    // Setup globals used in FCN
+    //
+    minuit.SetObjectFit(&evtloop);
+
+    cout << endl << "Fitting procedure running..." << endl;
+
+    TStopwatch clock;
+    clock.Start();
+
+    // Now ready for minimization step: minuit.mnexcm("MIGRAD", arglist, 1, ierflg)
+    gLog.SetNullOutput(kTRUE);
+    Bool_t rc = minuit.Migrad();
+    gLog.SetNullOutput(kFALSE);
+    if (rc)
+    {
+        cout << "Migrad failed." << endl;
+        return;
+    }
+
+    cout << endl;
+    clock.Stop();
+    clock.Print();
+    cout << endl;
+
+    for (Int_t i=(evalenergy==1?fA.GetSize():0); i<(evalenergy>0?fA.GetSize()+fB.GetSize():fA.GetSize()); i++)
+    //for (Int_t i=0; i<fA.GetSize()+fB.GetSize(); i++)
+    {
+        Double_t val;
+        Double_t er;
+
+        if (!minuit.GetParameter(i, val, er))
+            cout << "Error getting parameter #" << i << endl;
+
+        cout << i << ":  " << val << "  +-  " << er << endl;
+    }
+
+    /*
+     // Print results
+     Double_t amin, edm, errdef;
+     Int_t nvpar, nparx, icstat;
+     minuit.mnstat(amin, edm, errdef, nvpar, nparx, icstat);
+     minuit.mnprin(3, amin);
+     */
+}
Index: /tags/Mars_V0-8-5/Mars/macros/estimate.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/estimate.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/estimate.C	(revision 9661)
@@ -0,0 +1,245 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz et al,  09/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+
+void estimate()
+{
+    //
+    // This is a demonstration program which calculates the Hillas
+    // parameter out of a Magic root file (raw data file).
+    //
+
+    //
+    // Create a empty Parameter List and an empty Task List
+    // The tasklist is identified in the eventloop by its name
+    //
+    MParList plist;
+
+
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    //
+    // Now setup the tasks and tasklist:
+    // ---------------------------------
+    //
+    MReadMarsFile read("Events");
+    read.DisableAutoScheme();
+    /*
+     read.AddFile("star.root");
+     read.AddFile("star2.root");
+     */
+    read.AddFile("gammas.root");
+
+    // Create a filter for the gamma events
+    MFParticleId fgamma("MMcEvt", '=', kGAMMA);
+
+    MTaskList tlist2;
+    tlist2.SetFilter(&fgamma);
+
+    MEnergyEstParam eest;
+    eest.Add("MHillasSrc");
+
+    //
+    // Use this to change the binnign of the histograms to CT1-style
+    //
+    Bool_t usect1 = kTRUE;
+
+    //
+    // Here you set up the coefficients of the parametrization
+    // (MEnergyEstParam)
+    //
+    TArrayD fA(5);
+    fA[0] =  -2539; // [cm]
+    fA[1] =    900; // [cm]
+    fA[2] =   17.5; // [cm]
+    fA[3] =      4;
+    fA[4] =   58.3;
+
+    TArrayD fB(7);
+    fB[0] =    -8.64; // [GeV]
+    fB[1] =   -0.069; // [GeV]
+    fB[2] =  0.00066; // [GeV]
+    fB[3] =    0.033; // [GeV]
+    fB[4] = 0.000226; // [GeV]
+    fB[5] =  4.14e-8; // [GeV]
+    fB[6] =    -0.06;
+
+    eest.SetCoeffA(fA);
+    eest.SetCoeffB(fB);
+
+    MH3 mh3e("MMcEvt.fEnergy",     "(MEnergyEst.fEnergy/MMcEvt.fEnergy-1)*(MEnergyEst.fEnergy/MMcEvt.fEnergy-1)");
+    MH3 mh3i("MMcEvt.fImpact/100", "(MEnergyEst.fImpact/MMcEvt.fImpact-1)*(MEnergyEst.fImpact/MMcEvt.fImpact-1)");
+    MH3 mh3eo("MMcEvt.fEnergy",     "MEnergyEst.fEnergy/MMcEvt.fEnergy-1");
+    MH3 mh3io("MMcEvt.fImpact/100", "MEnergyEst.fImpact/MMcEvt.fImpact-1");
+
+    MH3 mh3e2("MEnergyEst.fEnergy",     "(MEnergyEst.fEnergy/MMcEvt.fEnergy-1)*(MEnergyEst.fEnergy/MMcEvt.fEnergy-1)");
+    MH3 mh3i2("MEnergyEst.fImpact/100", "(MEnergyEst.fImpact/MMcEvt.fImpact-1)*(MEnergyEst.fImpact/MMcEvt.fImpact-1)");
+    MH3 mh3eo2("MEnergyEst.fEnergy",     "MEnergyEst.fEnergy/MMcEvt.fEnergy-1");
+    MH3 mh3io2("MEnergyEst.fImpact/100", "MEnergyEst.fImpact/MMcEvt.fImpact-1");
+
+    MH3 mhe("MMcEvt.fEnergy",     "MEnergyEst.fEnergy");
+    MH3 mhi("MMcEvt.fImpact/100", "MEnergyEst.fImpact/100");
+
+    mh3e.SetName("HistEnergy");
+    mh3i.SetName("HistImpact");
+    mh3eo.SetName("HistEnergyOffset");
+    mh3io.SetName("HistImpactOffset");
+
+    mh3e2.SetName("HistEnergy");
+    mh3i2.SetName("HistImpact");
+    mh3eo2.SetName("HistEnergyOffset");
+    mh3io2.SetName("HistImpactOffset");
+
+    mhe.SetName("HistEE");
+    mhi.SetName("HistII");
+
+    MFillH hfille(&mh3e);
+    MFillH hfilli(&mh3i);
+    MFillH hfilleo(&mh3eo);
+    MFillH hfillio(&mh3io);
+
+    MFillH hfille2(&mh3e2);
+    MFillH hfilli2(&mh3i2);
+    MFillH hfilleo2(&mh3eo2);
+    MFillH hfillio2(&mh3io2);
+
+    MFillH hfillee(&mhe);
+    MFillH hfillii(&mhi);
+
+    MBinning binsex("BinningHistEnergyX");
+    MBinning binsey("BinningHistEnergyY");
+    MBinning binsix("BinningHistImpactX");
+    MBinning binsiy("BinningHistImpactY");
+    MBinning binseox("BinningHistEnergyOffsetX");
+    MBinning binseoy("BinningHistEnergyOffsetY");
+    MBinning binsiox("BinningHistImpactOffsetX");
+    MBinning binsioy("BinningHistImpactOffsetY");
+    MBinning binseex("BinningHistEEX");
+    MBinning binsiix("BinningHistIIX");
+    MBinning binseey("BinningHistEEY");
+    MBinning binsiiy("BinningHistIIY");
+
+    binsex.SetEdgesLog(50, usect1 ? 300: 10, usect1 ? 50000 : 1e4);
+    binsey.SetEdges(50, 0, 1.75);
+    binseox.SetEdgesLog(50, usect1 ? 300 : 10, usect1 ? 50000 : 1e4);
+    binseoy.SetEdges(50, -1.75, 1.75);
+
+    binsix.SetEdges(50, 0, usect1 ? 450 : 300);
+    binsiy.SetEdges(50, 0, 1.75);
+    binsiox.SetEdges(50, 0, usect1 ? 450 : 300);
+    binsioy.SetEdges(50, -1.75, 1.75);
+
+    binseex.SetEdgesLog(50, usect1 ? 300 : 10, usect1 ? 50000 : 15e3);
+    binseey.SetEdgesLog(50, usect1 ? 300 : 1,  usect1 ? 50000 : 2e3);
+    binsiix.SetEdges(50, 0, usect1 ? 450 : 300);
+    binsiiy.SetEdges(50, 0, usect1 ? 450 : 150);
+
+    plist.AddToList(&binsex);
+    plist.AddToList(&binsey);
+    plist.AddToList(&binsix);
+    plist.AddToList(&binsiy);
+    plist.AddToList(&binseox);
+    plist.AddToList(&binseoy);
+    plist.AddToList(&binsiox);
+    plist.AddToList(&binsioy);
+    plist.AddToList(&binseex);
+    plist.AddToList(&binseey);
+    plist.AddToList(&binsiix);
+    plist.AddToList(&binsiiy);
+
+    //
+    //  Setup tasklists
+    //
+    tlist.AddToList(&read);
+    tlist.AddToList(&fgamma);
+    tlist.AddToList(&tlist2);
+
+    tlist2.AddToList(&eest);
+    tlist2.AddToList(&hfille);
+    tlist2.AddToList(&hfilli);
+    tlist2.AddToList(&hfilleo);
+    tlist2.AddToList(&hfillio);
+
+    tlist2.AddToList(&hfille2);
+    tlist2.AddToList(&hfilli2);
+    tlist2.AddToList(&hfilleo2);
+    tlist2.AddToList(&hfillio2);
+
+    tlist2.AddToList(&hfillee);
+    tlist2.AddToList(&hfillii);
+
+    /*
+     MPrint p("MEnergyEst");
+     tlist2.AddToList(&p);
+     */
+
+    //
+    // Create and setup the eventloop
+    //
+    MProgressBar bar;
+
+    MEvtLoop evtloop;
+    evtloop.SetProgressBar(&bar);
+    evtloop.SetParList(&plist);
+
+    //
+    // Execute your analysis
+    //
+    if (!evtloop.Eventloop())
+        return;
+
+    tlist.PrintStatistics();
+
+    const TString text = "\\sqrt{<y>}=%.0f%%";
+
+    TCanvas *c=new TCanvas("Est1", "Estimates vs. E_{true}");
+    c->Divide(2,2);
+    c->cd(1);
+    mh3i.DrawClone("PROFXnonew");
+    TLatex *t = new TLatex(180, 1.6, Form(text, sqrt(mh3i.GetHist().GetMean(2))*100));
+    t->Draw();
+    c->cd(2);
+    mh3e.DrawClone("PROFXnonew");
+    t = new TLatex(2.7, 1.6, Form(text, sqrt(mh3e.GetHist().GetMean(2))*100));
+    t->Draw();
+    c->cd(3);
+    mh3io.DrawClone("PROFXnonew");
+    c->cd(4);
+    mh3eo.DrawClone("PROFXnonew");
+
+    c=new TCanvas("Est2", "Estimates vs. E_{est}");
+    c->Divide(2,2);
+    c->cd(1);
+    mh3i2.DrawClone("PROFXnonew");
+    c->cd(2);
+    mh3e2.DrawClone("PROFXnonew");
+    c->cd(3);
+    mh3io2.DrawClone("PROFXnonew");
+    c->cd(4);
+    mh3eo2.DrawClone("PROFXnonew");
+
+    mhe.DrawClone("PROFX");
+    mhi.DrawClone("PROFX");
+}
Index: /tags/Mars_V0-8-5/Mars/macros/evtrate.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/evtrate.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/evtrate.C	(revision 9661)
@@ -0,0 +1,78 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////////
+//
+// evtrate.C
+// =========
+//
+// Example macro how to calulate the eventrate (per event) and display
+// the result versus time.
+//
+// As an input you need a merpped raw-data file containing correct times.
+// The output is the plot: Eventrate vs. time.
+//
+///////////////////////////////////////////////////////////////////////////
+
+void evtrate()
+{
+    // Setup parameter- and tasklist
+    MParList plist;
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    // Setup reading task
+    MReadMarsFile read("Events");
+    read.DisableAutoScheme();
+    read.AddFile("test-time.root");
+
+    // Setup event rate calculator
+    MEventRateCalc calc;
+    // Setup number of events to be averaged
+    calc.SetNumEvents(200);
+
+    // Setup histogram to be filles with rate
+    MHVsTime rate("MEventRate.fRate");
+
+    // Setup task to fill the histogram
+    MFillH fill(&rate, "MTime");
+
+    // Setup tasklist
+    tlist.AddToList(&read);
+    tlist.AddToList(&calc);
+    tlist.AddToList(&fill);
+
+    // Execute your eventloop
+    MEvtLoop loop;
+    loop.SetParList(&plist);
+
+    if (!loop.Eventloop())
+        return;
+
+    // print some execution statistics
+    tlist.PrintStatistics();
+
+    // Draw result
+    rate.DrawClone();
+}
Index: /tags/Mars_V0-8-5/Mars/macros/flux.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/flux.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/flux.C	(revision 9661)
@@ -0,0 +1,625 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Wolfgang Wittek 4/2002 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+// This macro calculates photon fluxes as a function of                     //
+//    - energy and time                                                     //
+//    - energy and Theta                                                    //
+//                                                                          //
+// It is assumed that the data have been taken in the wobble mode.          //
+// This means that there is only one set of data, from which both           //
+// 'on' and 'off' data are constructed.                                     //
+//                                                                          //
+// Necessary input from MC :                                                //
+//    - migration matrix (E_est, E_true) as a functioin of Theta            //
+//    - effective collection areas as a function of energy and Theta        //
+//                                                                          //
+//                                                                          // 
+// The input from MC has to refer to the wobble mode too.                   // 
+//                                                                          //
+// The macro includes :                                                     // 
+//    - the calculation of Hillas parameters                                //
+//    - the calculation of the effective on time                            //
+//    - the unfolding of the distributions in the estimated energy E_est    //
+//                                                                          //
+// For testing purposes (as long as no real data, no energy estimator,      //
+// no migration matrices and no effective collection areas are available)   //
+//    - event times are generated (according to a Poissonian with dead time)//
+//    - a dummy energy estimator is provided                                //
+//    - migration matrices are generated                                    //
+//    - dummy effective collection areas are used                           //
+//                                                                          // 
+//////////////////////////////////////////////////////////////////////////////
+void flux()
+{ 
+    //--------------------------------------------------------------
+    // empty lists of parameter containers and tasks
+    //
+    MParList  parlist;
+    MTaskList tasklist;
+
+    //--------------------------------------------------------------
+    // Geometry information of the MAGIC camera
+    //
+    MGeomCamMagic geomcam;
+
+    //--------------------------------------------------------------
+    // Define the two source positions
+    //
+    MSrcPosCam source("Source");
+    MSrcPosCam antisrc("AntiSource");
+    source.SetXY(0, 0);
+    antisrc.SetXY(+240, 0);
+
+    //--------------------------------------------------------------
+    // Setup the binning for the histograms
+    //
+
+    //...............................................................
+    // These are NOT the binnings for the flux determination
+
+    MBinning binswidth("BinningWidth");
+    binswidth.SetEdges(100, 0, 0.5);   // 100 bins from 0 to 0.5 deg
+
+    MBinning binslength("BinningLength");
+    binslength.SetEdges(100, 0, 1);  // 100 bins from 0 to 1 deg
+
+    MBinning binscamera("BinningCamera");
+    binscamera.SetEdges(90, -2.25, 2.25);  // 90 bins from -2.25 to 2.25 deg
+
+    MBinning binsdist("BinningDist");
+    binsdist.SetEdges(90, 0, 2.25);    // 90 bins from 0 to 2.25 deg
+
+    MBinning binsalpha("BinningAlpha");
+    binsalpha.SetEdges(100, -100, 100);
+
+    MBinning binsasym("BinningAsym");
+    binsasym.SetEdges(100, -0.5, 0.5);   // 100 bins from -0.5 to 0.5 deg
+
+    MBinning binsasymn("BinningAsymn");
+    binsasymn.SetEdges(100, -0.005, 0.005);   // 100 bins from -0.005 to 0.005 deg
+
+    MBinning binsm3long("BinningM3Long");
+    binsm3long.SetEdges(100, -0.5, 0.5);   // 100 bins from -0.5 to 0.5 deg
+
+    MBinning binsm3trans("BinningM3Trans");
+    binsm3trans.SetEdges(100, -0.5, 0.5);   // 100 bins from -0.5 to 0.5 deg
+
+    //...............................................................
+    // These ARE the binnings for the flux determination
+
+    MBinning binsalphaflux("BinningAlphaFlux");
+    binsalphaflux.SetEdges(100, 0, 100);
+
+    MBinning binse("BinningE");
+    binse.SetEdgesLog(10, 10, 1e3);
+
+    MBinning binstheta("BinningTheta");
+    binstheta.SetEdges(7, -2.5, 32.5);
+
+    MBinning binstime("BinningTime");
+    binstime.SetEdges(5, 0, 100);
+
+    MBinning binsdifftime("BinningTimeDiff");
+    binsdifftime.SetEdges(50, 0, 0.1);
+
+
+    //--------------------------------------------------------------
+    // Fill list of parameter containers
+    //
+
+    parlist.AddToList(&tasklist);
+    parlist.AddToList(&geomcam);
+
+    parlist.AddToList(&source);
+    parlist.AddToList(&antisrc);
+
+    parlist.AddToList(&binswidth);
+    parlist.AddToList(&binslength);
+    parlist.AddToList(&binscamera);
+
+    parlist.AddToList(&binsdist);
+
+    parlist.AddToList(&binsalpha);
+
+    parlist.AddToList(&binsasym);
+    parlist.AddToList(&binsasymn);
+    parlist.AddToList(&binsm3long);
+    parlist.AddToList(&binsm3trans);
+
+    parlist.AddToList(&binsalphaflux);
+    parlist.AddToList(&binse);
+    parlist.AddToList(&binstheta);
+    parlist.AddToList(&binstime);
+    parlist.AddToList(&binsdifftime);
+
+    //--------------------------------------------------------------
+    // Setup the tasks
+    //
+
+    //.....................................
+    // input file
+    //
+    // next statement commented out
+    //    MReadMarsFile reader("Events", "~/data/Gamma*.root");
+
+    MReadMarsFile reader("Events");
+
+    //reader.AddFile("/hd31/rkb/Camera/mpi/Gamma*.root");
+    //reader.AddFile("/hd31/rkb/Camera/mpi/prot_N_*.root");
+    //reader.AddFile("/hd31/rkb/Camera/mpi/prot_NS_*.root");
+    //reader.AddFile("protondata/gamma_10_n*.root");
+    reader.AddFile("protondata/gamma_10_cn*.root");
+
+    reader.EnableBranch("MMcEvt.fTheta");
+
+    //.....................................
+    // filters
+    MFTriggerLvl1 lvl1;
+
+    //.....................................
+    // generation of event time
+    MMcTimeGenerate   rand;
+
+    //.....................................
+    MMcPedestalCopy   pcopy;
+    MMcPedestalNSBAdd pnsb;
+    MCerPhotCalc      ncalc;
+    MImgCleanStd      clean;
+    MBlindPixelCalc   blind;
+
+    //.....................................
+    // source independent image parameters
+    MHillasCalc       hcalc;
+    MHillasExt        hext;
+    parlist.AddToList(&hext);
+
+    //.....................................
+    // source dependent image parameters
+    MHillasSrcCalc    hsrc1("Source",     "HillasSrc");
+    MHillasSrcCalc    hsrc2("AntiSource", "HillasAntiSrc");
+
+    //.....................................
+    // energy estimation
+    MEnergyEstimate   estim;
+
+    //.....................................
+    // migration matrix (MC)
+    MFillH eestetrue("MHMcEnergyMigration",  "HillasSrc");
+    eestetrue.SetTitle("Task to determine the migration matrix for the energy");
+
+    //.....................................
+    // plots of source independent parameters (length, width, delta, size, center)
+    MFillH hfill1h("MHHillas",  "MHillas");
+    hfill1h.SetTitle("Task to plot the source independent image parameters");
+    hfill1h.SetFilter(&lvl1);
+
+    MFillH hfill1x("MHHillasExt", "MHillas");
+    hfill1x.SetTitle("Task to plot the extended image parameters");
+    hfill1x.SetFilter(&lvl1);
+
+    //.....................................
+    // plots of source dependent parameters (alpha, dist)
+    MFillH hfill2s("HSource     [MHHillasSrc]", "HillasSrc");
+    hfill2s.SetTitle("Task to plot the source dependent image parameters (Source)");
+    hfill2s.SetFilter(&lvl1);
+    MFillH hfill2a("HAntiSource [MHHillasSrc]", "HillasAntiSrc");
+    hfill2a.SetTitle("Task to plot the source dependent image parameters (AntiSource)");
+    hfill2a.SetFilter(&lvl1); 
+
+    //.....................................
+    // star map
+    MFillH hfill1m("MHStarMap", "MHillas");
+    hfill1m.SetTitle("Task to plot the Star map");
+
+    //.....................................
+    const Float_t alpha0 = 15; // [deg]
+    MFAlpha fsrc ("HillasSrc",     '>', alpha0);
+    fsrc.SetTitle("Task to check alphaSrc > alpha0");
+
+    MFAlpha fasrc("HillasAntiSrc", '>', alpha0);
+    fasrc.SetTitle("Task to check alphaAntiSrc > alpha0");
+
+    //.....................................
+    // 1-D profile plots     (<Theta>,  time)
+    //                       (<Theta>, Theta)
+    MFillH fillthetabartime ("ThetabarTime  [MHThetabarTime]",  "MMcEvt");
+    fillthetabartime.SetTitle("Task to plot <Theta> vs time");
+    // fillthetabartime.SetFilter(&lvl1);
+
+    MFillH fillthetabartheta("ThetabarTheta [MHThetabarTheta]", "MMcEvt");
+    fillthetabartheta.SetTitle("Task to plot <Theta> vs theta");
+    // fillthetabartheta.SetFilter(&lvl1);
+
+    //.....................................
+    // 2-D plots     (Delta(time),  time)
+    //               (Delta(time), Theta)
+    MFillH filldtimetime ("EffOnTime  [MHTimeDiffTime]",  "MMcEvt");
+    filldtimetime.SetTitle("Task to plot Delta(time) vs time");
+    // filldtime.SetFilter(&lvl1);
+
+    MFillH filldtimetheta("EffOnTheta [MHTimeDiffTheta]", "MMcEvt");
+    filldtimetheta.SetTitle("Task to plot Delta(time) vs theta");
+    // fillontheta.SetFilter(&lvl1);
+
+    //.....................................
+    // 3-D plots     (alpha, E_est, time) 
+    MFillH fillsptime  ("SrcTime   [MHAlphaEnergyTime]",  "HillasSrc");
+    fillsptime.SetTitle("Task for 3D plots (alpha, E_est, time) (Source)");
+    fillsptime.SetFilter(&fasrc);
+
+    MFillH fillasptime ("ASrcTime  [MHAlphaEnergyTime]",  "HillasAntiSrc");
+    fillasptime.SetTitle("Task for 3D plots (alpha, E_est, time) (AntiSource)");
+    fillasptime.SetFilter(&fsrc);
+
+    //.....................................
+    // 3-D plots     (alpha, E_est, Theta) 
+    MFillH fillsptheta ("SrcTheta  [MHAlphaEnergyTheta]", "HillasSrc");
+    fillsptheta.SetTitle("Task for 3D plots (alpha, E_est, Theta) (Source)");
+    fillsptheta.SetFilter(&fasrc);
+
+    MFillH fillasptheta("ASrcTheta [MHAlphaEnergyTheta]", "HillasAntiSrc");
+    fillasptheta.SetTitle("Task for 3D plots (alpha, E_est, Theta) (AntiSource)");
+    fillasptheta.SetFilter(&fsrc);
+
+    //.....................................
+    // MFillH fethetaall("AllTheta [MHEnergyTheta]", "MMcEvt");
+    // MFillH fethetasel("SelTheta [MHEnergyTheta]", "MMcEvt");
+    // fethetasel.SetFilter(&lvl1);
+
+    // MFillH fetimeall ("AllTime  [MHEnergyTime]",  "MMcEvt");
+    // MFillH fetimesel ("SelTime  [MHEnergyTime]",  "MMcEvt");
+    // fetimesel.SetFilter(&lvl1);
+
+
+    //---------------------------------------------------------------------
+    // Setup the task list
+    //
+    tasklist.AddToList(&reader);
+
+    tasklist.AddToList(&lvl1);
+    tasklist.AddToList(&rand);
+
+    tasklist.AddToList(&pcopy);
+    tasklist.AddToList(&pnsb);
+    tasklist.AddToList(&ncalc);
+    tasklist.AddToList(&clean);
+    tasklist.AddToList(&blind);
+
+    tasklist.AddToList(&hcalc);
+    
+    tasklist.AddToList(&hsrc1);
+    tasklist.AddToList(&hsrc2);
+    tasklist.AddToList(&estim);
+    tasklist.AddToList(&eestetrue);
+
+    tasklist.AddToList(&hfill1h);
+    tasklist.AddToList(&hfill1x);
+
+    tasklist.AddToList(&hfill1m);
+    tasklist.AddToList(&hfill2s);
+    tasklist.AddToList(&hfill2a);
+
+    tasklist.AddToList(&fillthetabartime);
+    tasklist.AddToList(&fillthetabartheta);
+
+    tasklist.AddToList(&filldtimetime);
+    tasklist.AddToList(&filldtimetheta);
+
+
+
+    // tasklist.AddToList(&fethetaall);
+    // tasklist.AddToList(&fethetasel);
+    // tasklist.AddToList(&fetimeall);
+    // tasklist.AddToList(&fetimesel);
+
+    tasklist.AddToList(&fsrc);
+    tasklist.AddToList(&fasrc);
+
+    tasklist.AddToList(&fillsptime);
+    tasklist.AddToList(&fillasptime);
+
+    tasklist.AddToList(&fillsptheta);
+    tasklist.AddToList(&fillasptheta);
+
+ 
+    //----------------------------------------------------------------------
+    // Event loop
+    //
+    MEvtLoop magic;
+    magic.SetParList(&parlist);
+
+    //
+    // loop over all events
+    //
+    if (!magic.Eventloop())
+        return;
+    //----------------------------------------------------------------------
+
+
+    tasklist.PrintStatistics(10);
+
+    
+    MHHillas *mhhillas = (MHHillas*)parlist.FindObject("MHHillas");
+    mhhillas->SetTitle("Source indep. image parameters");
+    mhhillas->DrawClone();
+    
+
+    
+    MHHillasExt *mhhillasext = (MHHillasExt*)parlist.FindObject("MHHillasExt");
+    mhhillasext->SetTitle("Extended image parameters");
+    mhhillasext->DrawClone();
+    
+    
+    MHHillasSrc *hsource = (MHHillasSrc*)parlist.FindObject("HSource");
+    hsource->SetTitle("Source dependent image parameters (Source)");
+    hsource->DrawClone();
+
+    MHHillasSrc *hantisource = (MHHillasSrc*)parlist.FindObject("HAntiSource");
+    hantisource->SetTitle("Source dependent image parameters (AntiSource)");
+    hantisource->DrawClone();
+    
+
+    /*    
+    parlist.FindObject("MHStarMap")->DrawClone();
+    */
+
+    //----------------------------------------------------------------------
+    // average Theta versus time
+    //           and versus Theta
+    // This is needed for selecting later the right collection area 
+    // (at the right Theta) for each bin in time or Theta
+    //
+    MHThetabarTime  *bartime  = (MHThetabarTime*)parlist.FindObject("ThetabarTime");
+    MHThetabarTheta *bartheta = (MHThetabarTheta*)parlist.FindObject("ThetabarTheta");
+    
+    /*    
+    bartime->DrawClone();
+    bartheta->DrawClone();
+    */
+
+     //----------------------------------------------------------------------
+     // Effective on time
+
+     //....................................
+     // get plots of time differences for different intervals in time
+     // and plots of time differences for different intervals in Theta 
+
+     MHTimeDiffTime  *dtimetime  = (MHTimeDiffTime*)parlist.FindObject("EffOnTime");
+     MHTimeDiffTheta *dtimetheta = (MHTimeDiffTheta*)parlist.FindObject("EffOnTheta");
+
+     /*
+     dtimetime->DrawClone();
+     dtimetheta->DrawClone();
+     */
+
+
+     //....................................
+     // calculate effective on time for different intervals in Time
+     //                         and for different intervals in Theta      
+
+     MHEffOnTime effontime ("Time",  "[s]");
+     MHEffOnTime effontheta("Theta", "[\\circ]");
+
+     effontime.SetupFill(&parlist);
+     effontheta.SetupFill(&parlist);
+
+
+     // Draw == 0  don't draw the individual distributions of time differences
+     //      != 0  draw them
+     Bool_t draw=kFALSE;
+     effontime.Calc (dtimetime->GetHist(), draw);
+     effontheta.Calc(dtimetheta->GetHist(),draw);
+
+
+     // plot effective on time versus Time
+     //                    and versus Theta
+     /*     
+     effontime.DrawClone();
+     effontheta.DrawClone();
+     */
+
+
+     //======================================================================
+     //
+     // A : fully differential plots (Alpha, E-est, Var)
+     //
+     //----------------------------------------------------------------------
+     // 3D-plots of alpha, E_est and time
+     //      and of alpha, E_est and Theta 
+     // with alpha calculated relative to the source position
+     //                   and relative to the anti-source position
+
+     MHAlphaEnergyTime  *evtsptime   = (MHAlphaEnergyTime*)parlist.FindObject("SrcTime");
+     MHAlphaEnergyTime  *evtasptime  = (MHAlphaEnergyTime*)parlist.FindObject("ASrcTime");
+     MHAlphaEnergyTheta *evtsptheta  = (MHAlphaEnergyTheta*)parlist.FindObject("SrcTheta");
+     MHAlphaEnergyTheta *evtasptheta = (MHAlphaEnergyTheta*)parlist.FindObject("ASrcTheta");
+
+
+     /*     
+      evtsptime->SetTitle("Source : 3D-plot Al-En-time, alpha\_{asp} .gt. alpha\_0");
+      evtsptime->DrawClone();
+      evtasptime->SetTitle("AntiSource : 3D-plot Al-En-time, alpha\_{sp} .gt. alpha\_0");
+      evtasptime->DrawClone();
+
+      evtsptheta->SetTitle("Source : 3D-plot Al-En-Theta, alpha\_{asp} .gt. alpha\_0");
+      evtsptheta->DrawClone();
+      evtasptheta->SetTitle("AntiSource : 3D-plot Al-En-Theta, alpha\_{sp} .gt. alpha\_0");
+      evtasptheta->DrawClone();
+     */
+                
+     //----------------------------------------------------------------------
+     // Difference between source and antisource (= 'gamma' sample) 
+     // for             3D-plots of alpha, E_est and time
+     //                      and of alpha, E_est and Theta 
+     // 3rd and 4th argument are name and title of the resulting histogram
+
+     MHGamma gamma;
+
+     TH3D *hsubtime  = gamma.Subtract( evtsptime->GetHist(), 
+                                       evtasptime->GetHist(),
+                        "Al-En-time", "3D-plot of Alpha,E-est,time", draw);
+
+     TH3D *hsubtheta = gamma.Subtract( evtsptheta->GetHist(), 
+                                       evtasptheta->GetHist(),
+                        "Al-En-time", "3D-plot of Alpha,E-est,Theta", draw);
+    
+
+     //----------------------------------------------------------------------
+     // get number of 'gammas' in the alpha range (lo, up) as a function of
+     //                 E_est and time
+     //        or       E_est and Theta 
+
+     Axis_t lo =   0;    // [deg]
+     Axis_t up =  10;    // [deg]
+     const TH2D &evttime  = *(gamma.GetAlphaProjection(hsubtime, 
+                              lo, up, draw));
+
+     const TH2D &evttheta = *(gamma.GetAlphaProjection(hsubtheta, 
+                              lo, up, draw));
+     
+
+     //----------------------------------------------------------------------
+     // plot migration matrix:  E-true E-est Theta
+
+
+     /*
+     MHMcEnergyMigration *migrationmatrix = 
+         (MHMcEnergyMigration*)parlist.FindObject("MHMcEnergyMigration");
+     migrationmatrix->SetTitle("Migration matrix");;
+     migrationmatrix->DrawClone();
+     */
+
+
+     //----------------------------------------------------------------------
+     // determine gamma flux from distributions of E-est :
+     //   -  do unfolding to get the distributions in E-unfold
+     //   -  divide by bin width in energy
+     //                effective ontime and
+     //                effective collection area
+     //      to get the absolute gamma flux
+    
+     //.............................................
+     // get flux spectrum for different bins in Time
+     //
+     // use dummy histogram *aeff which eventually will contain
+     //     the effective collection area as a function of Etrue and Theta
+     TH2D aeff;
+
+     // arguments of MHFlux constructor are :
+     //   - 2D histogram containing the no.of gammas as a function of
+     //     E-est and Var
+     //   - name  of variable Var ("Time" or "Theta")
+     //   - units of variable Var ( "[s]" or "[\\circ]")
+
+     // Draw == kTRUE  draw the no.of photons vs. E-est 
+     //                for the individual bins of the variable Var
+     draw=kTRUE;
+     MHFlux fluxtime(evttime, draw, "Time", "[s]");
+     fluxtime.Unfold(draw);
+     fluxtime.CalcFlux(effontime.GetHist(), bartime.GetHist(),
+                       &aeff, draw);
+     
+     fluxtime.DrawClone();
+     
+
+
+     //..............................................
+     // get flux spectrum for different bins in Theta
+     MHFlux fluxtheta(evttheta, draw, "Theta", "[\\circ]");
+     fluxtheta.Unfold(draw);
+     fluxtheta.CalcFlux(effontheta.GetHist(), bartheta.GetHist(),
+                       &aeff, draw);
+     
+     fluxtheta.DrawClone();
+     
+
+return;
+     //----------------------------------------------------------------------
+
+
+     //======================================================================
+     //
+     // B : plots integrated over E-est
+     //
+     //----------------------------------------------------------------------
+     // integrate 3D-plot of (alpha, E_est and Time) over E-est
+     //    to get 2D-plot of (alpha, Time) 
+                                   
+     Draw = kFALSE;                        
+     TH2D *evttimesp  = evtsptime.IntegrateEest ("AlphaSP vs. Time", Draw);
+     TH2D *evttimeasp = evtasptime.IntegrateEest("AlphaASP vs. Time",Draw);
+
+
+     //======================================================================
+     //
+     // C : plots integrated over Time
+     //
+     //----------------------------------------------------------------------
+     // integrate 3D-plot of (alpha, E_est and Time) over the Time
+     //    to get 2D-plot of (alpha, E_est) 
+                                   
+     Draw = kFALSE;                        
+     TH2D *evteestsp  = evtsptime.IntegrateTime ("AlphaSP vs. E-est", Draw);
+     TH2D *evteestasp = evtasptime.IntegrateTime("AlphaASP vs. E-est",Draw);
+
+
+
+     //======================================================================
+     //
+     // D : plots integrated over E-est and Time
+     //
+
+     //----------------------------------------------------------------------
+     // integrate 3D-plot of (alpha, E_est and Time) over E-est and Time
+     //    to get 1D-plot of (alpha) 
+                                   
+     Draw = kFALSE;                        
+     TH1D *evtalphasp  = evtsptime.IntegrateEestTime ("AlphaSP", Draw);
+     TH1D *evtalphaasp = evtasptime.IntegrateEestTime("AlphaASP",Draw);
+
+     //----------------------------------------------------------------------
+     // list of tasks for processing
+
+     cout << " " << endl;
+     cout << "List of tasks for processing :" << endl;
+     cout << "==============================" << endl;
+     cout << " " << endl;
+
+     // was folgt geht nicht :
+
+     // Error: Function Next() is not defined in current scope  FILE:macros/flux.C LINE:636
+
+     //while ( (task=(MTask*)Next()) )
+     //{
+     //  cout << tasklist.GetName() << " :   " << tasklist.GetTitle() << endl;
+     //}
+
+     return;
+
+     //======================================================================                
+}
+//===========================================================================
+
+
Index: /tags/Mars_V0-8-5/Mars/macros/fluxunfold.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/fluxunfold.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/fluxunfold.C	(revision 9661)
@@ -0,0 +1,3744 @@
+   
+////////////////////////////////////////////////////////////////////////////
+//                                                                        //
+// This program should be run under root :                                //
+//      root fluxunfold.C++                                               //
+//                                                                        //
+// Author(s) : T. Bretz  02/2002 <mailto:tbretz@astro.uni-wuerzburg.de>   //
+//             W. Wittek 09/2002 <mailto:wittek@mppmu.mpg.de>             //
+//                                                                        //
+// this macro is prepared to be used in the analysis :                    //
+//                                                                        //
+//      the unfolding should be called by                                 //
+//      doUnfolding(TH2D &tobeunfolded,      // (E-est, Theta)            //
+//                  TH3D &migrationmatrix,   // (E-est, E-true, Theta)    //
+//                  TH2D &unfolded)          // (E-true,Theta)            //
+//                                                                        //
+////////////////////////////////////////////////////////////////////////////
+
+#include <TMath.h>
+#include <TRandom3.h>
+#include <TVector.h>
+#include <TMatrixD.h>
+#include <TMatrix.h>
+#include <TH1.h>
+#include <TH2.h>
+#include <TH3.h>
+#include <TProfile.h>
+#include <TF1.h>
+#include <iostream.h>
+#include <TMinuit.h>
+#include <TCanvas.h>
+#include <TMarker.h>
+
+#include <fstream.h>
+#include <iomanip.h>
+
+TH1 *DrawMatrixClone(const TMatrixD &m, Option_t *opt="")
+{
+    const Int_t nrows = m.GetNrows();
+    const Int_t ncols = m.GetNcols();
+
+    TMatrix m2(nrows, ncols);
+    for (int i=0; i<nrows; i++)
+        for (int j=0; j<ncols; j++)
+            m2(i, j) = m(i, j);
+
+    TH2F *hist = new TH2F(m2);
+    hist->SetBit(kCanDelete);
+    hist->Draw(opt);
+    hist->SetDirectory(NULL);
+
+    return hist;
+
+}
+
+TH1 *DrawMatrixColClone(const TMatrixD &m, Option_t *opt="", Int_t col=0)
+{
+    const Int_t nrows = m.GetNrows();
+
+    TVector vec(nrows);
+    for (int i=0; i<nrows; i++)
+        vec(i) = m(i, col);
+
+    TH1F *hist = new TH1F("TVector","",nrows,0,nrows);
+    for (int i=0; i<nrows; i++)
+    {
+      hist->SetBinContent(i+1, vec(i));
+    }
+
+    hist->SetBit(kCanDelete);
+    hist->Draw(opt);
+    hist->SetDirectory(NULL);
+
+    return hist;
+}
+
+
+void PrintTH3Content(const TH3 &hist)
+{
+    cout << hist.GetName() << ": " << hist.GetTitle() << endl;
+    cout << "-----------------------------------------------------" << endl;
+    for (Int_t i=1; i<=hist.GetNbinsX(); i++)
+    {
+      for (Int_t j=1; j<=hist.GetNbinsY(); j++)
+        for (Int_t k=1; k<=hist.GetNbinsZ(); k++)
+            cout << hist.GetBinContent(i,j,k) << " \t";
+      cout << endl << endl;
+    }
+}
+
+void PrintTH3Error(const TH3 &hist)
+{
+    cout << hist.GetName() << ": " << hist.GetTitle() << " <error>" << endl;
+    cout << "-----------------------------------------------------" << endl;
+    for (Int_t i=1; i<=hist.GetNbinsX(); i++)
+    {
+      for (Int_t j=1; j<=hist.GetNbinsY(); j++)
+        for (Int_t k=1; k<=hist.GetNbinsZ(); k++)
+            cout << hist.GetBinError(i, j, k) << " \t";
+      cout << endl << endl;
+    }
+}
+
+void PrintTH2Content(const TH2 &hist)
+{
+    cout << hist.GetName() << ": " << hist.GetTitle() << endl;
+    cout << "-----------------------------------------------------" << endl;
+    for (Int_t i=1; i<=hist.GetNbinsX(); i++)
+        for (Int_t j=1; j<=hist.GetNbinsY(); j++)
+            cout << hist.GetBinContent(i,j) << " \t";
+        cout << endl << endl;
+}
+
+void PrintTH2Error(const TH2 &hist)
+{
+    cout << hist.GetName() << ": " << hist.GetTitle() << " <error>" << endl;
+    cout << "-----------------------------------------------------" << endl;
+    for (Int_t i=1; i<=hist.GetNbinsX(); i++)
+        for (Int_t j=1; j<=hist.GetNbinsY(); j++)
+            cout << hist.GetBinError(i, j) << " \t";
+        cout << endl << endl;
+}
+
+void PrintTH1Content(const TH1 &hist)
+{
+    cout << hist.GetName() << ": " << hist.GetTitle() << endl;
+    cout << "-----------------------------------------------------" << endl;
+    for (Int_t i=1; i<=hist.GetNbinsX(); i++)
+        cout << hist.GetBinContent(i) << " \t";
+    cout << endl << endl;
+}
+
+void PrintTH1Error(const TH1 &hist)
+{
+    cout << hist.GetName() << ": " << hist.GetTitle() << " <error>" << endl;
+    cout << "-----------------------------------------------------" << endl;
+    for (Int_t i=1; i<=hist.GetNbinsX(); i++)
+        cout << hist.GetBinError(i) << " \t";
+    cout << endl << endl;
+}
+
+void CopyCol(TMatrixD &m, const TH1 &h, Int_t col=0)
+{
+    const Int_t n = m.GetNrows();
+
+    for (Int_t i=0; i<n; i++)
+        m(i, col) = h.GetBinContent(i+1);
+}
+
+void CopyCol(TH1 &h, const TMatrixD &m, Int_t col=0)
+{
+    const Int_t n = m.GetNrows();
+
+    for (Int_t i=0; i<n; i++)
+        h.SetBinContent(i+1, m(i, col));
+}
+
+void CopyH2M(TMatrixD &m, const TH2 &h)
+{
+    const Int_t nx = m.GetNrows();
+    const Int_t ny = m.GetNcols();
+
+    for (Int_t i=0; i<nx; i++)
+        for (Int_t j=0; j<ny; j++)
+            m(i, j) = h.GetBinContent(i+1, j+1);
+}
+
+void CopySqr(TMatrixD &m, const TH1 &h)
+{
+    const Int_t nx = m.GetNrows();
+    const Int_t ny = m.GetNcols();
+
+    for (Int_t i=0; i<nx; i++)
+        for (Int_t j=0; j<ny; j++)
+        {
+            const Double_t bin =  h.GetBinContent(i+1, j+1);
+            m(i, j) = bin*bin;
+        }
+}
+
+Double_t GetMatrixSumRow(const TMatrixD &m, Int_t row)
+{
+    const Int_t n = m.GetNcols();
+
+    Double_t sum = 0;
+    for (Int_t i=0; i<n; i++)
+        sum += m(row, i);
+
+    return sum;
+}
+
+Double_t GetMatrixSumDiag(const TMatrixD &m)
+{
+    const Int_t n = m.GetNcols();
+
+    Double_t sum = 0;
+    for (Int_t i=0; i<n; i++)
+        sum += m(i, i);
+
+    return sum;
+}
+
+Double_t GetMatrixSumCol(const TMatrixD &m, Int_t col=0)
+{
+    const Int_t n = m.GetNrows();
+
+    Double_t sum = 0;
+    for (Int_t i=0; i<n; i++)
+        sum += m(i, col);
+
+    return sum;
+}
+Double_t GetMatrixSum(const TMatrixD &m)
+{
+    const Int_t n = m.GetNrows();
+
+    Double_t sum = 0;
+    for (Int_t i=0; i<n; i++)
+        sum += GetMatrixSumRow(m, i);
+
+    return sum;
+}
+
+////////////////////////////////////////////////////////////////////////////
+//                                                                        //
+// fcnSmooth   (used by SmoothMigrationMatrix)                                 //
+//                                                                        //
+// is called by MINUIT                                                    //
+// for given values of the parameters it calculates                       //
+//                     the function to be minimized                       //  
+//                                                                        //
+////////////////////////////////////////////////////////////////////////////
+void fcnSmooth(Int_t &npar, Double_t *gin, Double_t &f, 
+               Double_t *par, Int_t iflag);
+
+
+
+////////////////////////////////////////////////////////////////////////////
+//                                                                        //
+// fcnTikhonov2   (used by Tikhonov2)                                     //
+//                                                                        //
+// is called by MINUIT                                                    //
+// for given values of the parameters it calculates                       //
+//                     the function to be minimized                       //  
+//                                                                        //
+////////////////////////////////////////////////////////////////////////////
+void fcnTikhonov2(Int_t &npar, Double_t *gin, Double_t &f, 
+                              Double_t *par, Int_t iflag);
+
+////////////////////////////////////////////////////////////////////////////
+//                                                                        //
+// MUnfold                                                                //
+//                                                                        //
+// class for unfolding a 1-dimensional distribution                       //
+//                                                                        //
+// the methods used are described in :                                    //
+//                                                                        //
+//     V.B.Anykeyev et al., NIM A303 (1991) 350                           //
+//     M. Schmelling, Nucl. Instr. and Meth. A 340 (1994) 400             //
+//     M. Schmelling : "Numerische Methoden der Datenanalyse"             //
+//                    Heidelberg, Maerz 1998                              //
+//     M.Bertero, INFN/TC-88/2 (1988)                                     //
+//                                                                        //
+////////////////////////////////////////////////////////////////////////////
+class MUnfold : public TObject
+{
+public:
+    TString   bintitle;
+
+    UInt_t    fNa;        // Number of bins in the distribution to be unfolded
+    UInt_t    fNb;        // Number of bins in the unfolded distribution
+
+    TMatrixD  fMigrat;    // migration matrix                  (fNa, fNb)
+    TMatrixD  fMigraterr2;// error**2 of migration matrix      (fNa, fNb)
+
+    TMatrixD  fMigOrig;    // original migration matrix         (fNa, fNb)
+    TMatrixD  fMigOrigerr2;// error**2 oforiginal migr. matrix  (fNa, fNb)
+
+    TMatrixD  fMigSmoo;    // smoothed migration matrix M       (fNa, fNb)
+    TMatrixD  fMigSmooerr2;// error**2 of smoothed migr. matrix (fNa, fNb)
+    TMatrixD  fMigChi2;    // chi2 contributions for smoothing  (fNa, fNb)
+
+    TMatrixD  fVa;        // distribution to be unfolded       (fNa)
+    TMatrixD  fVacov;     // error matrix of fVa               (fNa, fNa)
+    TMatrixD  fVacovInv; // inverse of fVacov                 (fNa, fNa)
+    Double_t  fSpurVacov; // Spur of fVacov
+
+    //    UInt_t    fVaevents;  // total number of events
+    UInt_t    fVapoints;  // number of significant measurements
+
+    TMatrixD  fVb;        // unfolded distribution             (fNb)
+    TMatrixD  fVbcov;     // error matrix of fVb               (fNb, fNb)
+
+    TMatrixD  fVEps;      // prior distribution                (fNb)
+    TMatrixDColumn fVEps0;
+
+    Double_t  fW;         // weight
+    Double_t  fWbest;     // best weight
+    Int_t     ixbest;
+
+    TMatrixD  fResult;    // unfolded distribution and errors  (fNb, 5)
+    TMatrixD  fChi2;      // chisquared contribution           (fNa, 1)
+
+    Double_t  fChisq;     // total chisquared
+    Double_t  fNdf;       // number of degrees of freedom
+    Double_t  fProb;      // chisquared probability
+
+    TMatrixD  G;          // G = M * M(transposed)             (fNa, fNa)
+    TVectorD  EigenValue; // vector of eigenvalues lambda of G (fNa)
+    TMatrixD  Eigen;      // matrix of eigen vectors of G      (fNa, fNa)
+    Double_t  RankG;      // rank of G
+    Double_t  tau;        // 1 / lambda_max
+    Double_t  EpsLambda;
+
+    // quantities stored for each weight :
+    TVectorD SpSig;       // Spur of covariance matrix of fVbcov
+    TVectorD SpAR;        // effective rank of G^tilde
+    TVectorD chisq;       // chi squared (measures agreement between
+    // fVa and the folded fVb)
+    TVectorD SecDer;      // regularization term = sum of (2nd der.)**2
+    TVectorD ZerDer;      // regularization term = sum of (fVb)**2
+    TVectorD Entrop;      // regularization term = reduced cross-entropy
+    TVectorD DAR2;        //
+    TVectorD Dsqbar;      //
+
+    Double_t SpurAR;
+    Double_t SpurSigma;
+    Double_t SecDeriv;
+    Double_t ZerDeriv;
+    Double_t Entropy;
+    Double_t DiffAR2;
+    Double_t Chisq;
+    Double_t D2bar;
+
+    TMatrixD Chi2;
+
+    //
+
+    // plots versus weight
+    Int_t    Nix;
+    Double_t xmin;
+    Double_t xmax;
+    Double_t dlogx;
+
+    TH1D *hBchisq;
+    TH1D *hBSpAR;
+    TH1D *hBDSpAR;
+    TH1D *hBSpSig;
+    TH1D *hBDSpSig;
+    TH1D *hBSecDeriv;
+    TH1D *hBDSecDeriv;
+    TH1D *hBZerDeriv;
+    TH1D *hBDZerDeriv;
+    TH1D *hBEntropy;
+    TH1D *hBDEntropy;
+    TH1D *hBDAR2;
+    TH1D *hBD2bar;
+
+    //
+    TH1D *hEigen;
+
+    // plots for the best solution
+    TH2D *fhmig;
+    TH2D *shmig;
+    TH2D *shmigChi2;
+
+    TH1D *fhb0;
+
+    TH1D *fha;
+
+    TH1D *hprior;
+
+    TH1D *hb;
+
+    Double_t CalcSpurSigma(TMatrixD &T, Double_t norm=1)
+    {
+        Double_t spursigma = 0;
+
+        for (UInt_t a=0; a<fNb; a++)
+        {
+            for (UInt_t b=0; b<fNb; b++)
+            {
+                fVbcov(a,b) = 0;
+
+                for (UInt_t c=0; c<fNa; c++)
+                    for (UInt_t d=0; d<fNa; d++)
+                        fVbcov(a,b) += T(a,d)*fVacov(d,c)*T(b,c);
+
+                fVbcov(a,b) *= norm*norm;
+            }
+            spursigma += fVbcov(a,a);
+        }
+
+        return spursigma;
+    }
+
+public:
+    // -----------------------------------------------------------------------
+    //
+    // Constructor
+    //              copy histograms into matrices
+    //
+    MUnfold(TH1D &ha, TH2D &hacov, TH2D &hmig)
+        : fVEps(hmig.GetYaxis()->GetNbins(),1), fVEps0(fVEps, 0)
+    {
+        // ha      is the distribution to be unfolded
+        // hacov   is the covariance matrix of ha
+        // hmig    is the migration matrix;
+        //         this matrix will be used in the unfolding
+        //         unless SmoothMigrationMatrix(*hmigrat) is called;
+        //         in the latter case hmigrat is smoothed
+        //         and the smoothed matrix is used in the unfolding
+
+        // Eigen values of the matrix G, which are smaller than EpsLambda
+        // will be considered as being zero
+        EpsLambda = 1.e-10;
+        fW = 0.0;
+
+        fNa  = hmig.GetXaxis()->GetNbins();
+        const Double_t alow = hmig.GetXaxis()->GetXmin();
+        const Double_t aup  = hmig.GetXaxis()->GetXmax();
+
+        fNb  = hmig.GetYaxis()->GetNbins();
+        const Double_t blow = hmig.GetYaxis()->GetXmin();
+        const Double_t bup  = hmig.GetYaxis()->GetXmax();
+
+
+        UInt_t Na = ha.GetNbinsX();
+        if (fNa != Na)
+        {
+            cout << "MUnfold::MUnfold : dimensions do not match,  fNa = ";
+            cout << fNa << ",   Na = " << Na << endl;
+        }
+
+        cout << "MUnfold::MUnfold :" << endl;
+        cout << "==================" << endl;
+        cout << "   fNa = " << fNa << ",   fNb = " << fNb << endl;
+
+        // ------------------------
+
+        fVa.ResizeTo(fNa, 1);
+        CopyCol(fVa, ha, 0);
+
+        cout << "   fVa = ";
+
+        for (UInt_t i=0; i<fNa; i++)
+            cout << fVa(i,0) << " \t";
+        cout << endl;
+
+        Double_t vaevents = GetMatrixSumCol(fVa, 0);
+        cout << "   Total number of events in fVa = " << vaevents << endl;
+
+        // ------------------------
+
+        fChi2.ResizeTo(fNa,1);
+        Chi2.ResizeTo(fNa,1);
+
+        // ------------------------
+
+        fVacov.ResizeTo(fNa, fNa);
+        fSpurVacov = 0;
+
+        CopyH2M(fVacov, hacov);
+
+        fVapoints = 0;
+        for (UInt_t i=0; i<fNa; i++)
+            if (fVa(i,0)>0 && fVacov(i,i)<fVa(i,0)*fVa(i,0))
+                fVapoints++;
+
+        fSpurVacov = GetMatrixSumDiag(fVacov);
+
+        //cout << "MUnfold::MUnfold :   fVacov = " << endl;
+        //cout << "==============================" << endl;
+        //fVacov.Print();
+
+        cout << "   Number of significant points in fVa = ";
+        cout << fVapoints << endl;
+
+        cout << "   Spur of fVacov = ";
+        cout << fSpurVacov << endl;
+
+        // ------------------------
+
+        fVacovInv.ResizeTo(fNa, fNa);
+        fVacovInv = fVacov;
+        fVacovInv.InvertPosDef();
+
+        //cout << "MUnfold::MUnfold :   fVacovInv = " << endl;
+        //cout << "==================================" << endl;
+        //fVacovInv.Print();
+
+        // ------------------------
+        // fMigrat is the migration matrix to be used in the unfolding;
+        // fMigrat may be overwritten by SmoothMigrationMatrix
+
+        fMigrat.ResizeTo(fNa, fNb); // row, col
+
+        CopyH2M(fMigrat, hmig);
+
+
+        // ------------------------
+
+        fMigraterr2.ResizeTo(fNa, fNb); // row, col
+        CopySqr(fMigraterr2, hmig);
+
+        // normaxlize
+
+        for (UInt_t j=0; j<fNb; j++)
+        {
+            const Double_t sum = GetMatrixSumCol(fMigrat, j);
+
+            if (sum==0)
+                continue;
+
+            TMatrixDColumn col1(fMigrat, j);
+            col1 *= 1./sum;
+
+            TMatrixDColumn col2(fMigraterr2, j);
+            col2 *= 1./(sum*sum);
+        }
+
+        //cout << "MUnfold::MUnfold :   fMigrat = " << endl;
+        //cout << "===============================" << endl;
+        //fMigrat.Print();
+
+        //cout << "MUnfold::MUnfold :   fMigraterr2 = " << endl;
+        //cout << "===================================" << endl;
+        //fMigraterr2.Print();
+
+        // ------------------------
+        G.ResizeTo(fNa, fNa);
+        EigenValue.ResizeTo(fNa);
+        Eigen.ResizeTo(fNa, fNa);
+
+        fMigOrig.ResizeTo(fNa, fNb); 
+        fMigOrigerr2.ResizeTo(fNa, fNb); 
+
+        fMigSmoo.ResizeTo    (fNa, fNb); 
+        fMigSmooerr2.ResizeTo(fNa, fNb); 
+        fMigChi2.ResizeTo    (fNa, fNb); 
+
+        // ------------------------
+
+        fVEps0 = 1./fNb;
+
+        //cout << "MUnfold::MUnfold :   Default prior distribution fVEps = " << endl;
+        //cout << "========================================================" << endl;
+        //fVEps.Print();
+
+        // ------------------------
+
+        fVb.ResizeTo(fNb,1);
+        fVbcov.ResizeTo(fNb,fNb);
+
+        // ----------------------------------------------------
+        // number and range of weights to be scanned
+        Nix  = 30;
+        xmin = 1.e-5;
+        xmax = 1.e5;
+        dlogx = (log10(xmax)-log10(xmin)) / Nix;
+
+        SpSig.ResizeTo (Nix);
+        SpAR.ResizeTo  (Nix);
+        chisq.ResizeTo (Nix);
+        SecDer.ResizeTo(Nix);
+        ZerDer.ResizeTo(Nix);
+        Entrop.ResizeTo(Nix);
+        DAR2.ResizeTo  (Nix);
+        Dsqbar.ResizeTo(Nix);
+
+        //------------------------------------
+        // plots as a function of the iteration  number
+
+        hBchisq = new TH1D("Bchisq", "chisq",
+                           Nix, log10(xmin)-dlogx/2.0, log10(xmax)-dlogx/2.0 );
+
+        hBSpAR  = new TH1D("BSpAR", "SpurAR",
+                           Nix, log10(xmin)-dlogx/2.0, log10(xmax)-dlogx/2.0 );
+
+        hBDSpAR  = new TH1D("BDSpAR", "Delta(SpurAR)",
+                            Nix, log10(xmin)-dlogx/2.0, log10(xmax)-dlogx/2.0 );
+
+        hBSpSig = new TH1D("BSpSig", "SpurSigma/SpurC",
+                           Nix, log10(xmin)-dlogx/2.0, log10(xmax)-dlogx/2.0 );
+
+        hBDSpSig = new TH1D("BDSpSig", "Delta(SpurSigma/SpurC)",
+                            Nix, log10(xmin)-dlogx/2.0, log10(xmax)-dlogx/2.0 );
+
+        hBSecDeriv = new TH1D("BSecDeriv", "Second Derivative squared",
+                              Nix, log10(xmin)-dlogx/2.0, log10(xmax)-dlogx/2.0 );
+
+        hBDSecDeriv = new TH1D("BDSecDeriv", "Delta(Second Derivative squared)",
+                               Nix, log10(xmin)-dlogx/2.0, log10(xmax)-dlogx/2.0 );
+
+        hBZerDeriv = new TH1D("BZerDeriv", "Zero Derivative squared",
+                              Nix, log10(xmin)-dlogx/2.0, log10(xmax)-dlogx/2.0 );
+
+        hBDZerDeriv = new TH1D("BDZerDeriv", "Delta(Zero Derivative squared)",
+                               Nix, log10(xmin)-dlogx/2.0, log10(xmax)-dlogx/2.0 );
+
+        hBEntropy = new TH1D("BEntrop", "Entropy",
+                             Nix, log10(xmin)-dlogx/2.0, log10(xmax)-dlogx/2.0 );
+
+        hBDEntropy = new TH1D("BDEntrop", "Delta(Entropy)",
+                              Nix, log10(xmin)-dlogx/2.0, log10(xmax)-dlogx/2.0 );
+
+        hBDAR2 = new TH1D("BDAR2", "norm(AR-AR+)",
+                          Nix, log10(xmin)-dlogx/2.0, log10(xmax)-dlogx/2.0 );
+
+        hBD2bar = new TH1D("BD2bar", "(b_unfolded-b_ideal)**2",
+                           Nix, log10(xmin)-dlogx/2.0, log10(xmax)-dlogx/2.0 );
+
+        //-------------------------------------
+        // original migration matrix
+        fhmig = new TH2D("fMigrat", "Migration matrix",
+                         fNa, alow, aup, fNb, blow, bup);
+        fhmig->Sumw2();
+
+        //-------------------------------------
+        // smoothed migration matrix
+        shmig = new TH2D("sMigrat", "Smoothed migration matrix",
+                         fNa, alow, aup, fNb, blow, bup);
+        shmig->Sumw2();
+
+        //-------------------------------------
+        // chi2 contributions for smoothing of migration matrix
+        shmigChi2 = new TH2D("sMigratChi2", "Chi2 contr. for smoothing",
+                             fNa, alow, aup, fNb, blow, bup);
+
+        //-------------------------------------
+        // eigen values of matrix G = M * M(transposed)
+        hEigen = new TH1D("Eigen", "Eigen values of M*MT",
+                          fNa, 0.5, fNa+0.5);
+
+        //------------------------------------
+        // Ideal distribution
+        
+        fhb0 = new TH1D("fhb0", "Ideal distribution", fNb, blow, bup);
+        fhb0->Sumw2();
+        
+
+        //------------------------------------
+        // Distribution to be unfolded
+        fha = new TH1D("fha", "Distribution to be unfolded", fNa, alow, aup);
+        fha->Sumw2();
+
+        //------------------------------------
+        // Prior distribution
+        hprior = new TH1D("Prior", "Prior distribution", fNb, blow, bup);
+
+        //------------------------------------
+        // Unfolded distribution
+        hb = new TH1D("DataSp", "Unfolded distribution", fNb, blow, bup);
+        hb->Sumw2();
+
+    }
+
+    // -----------------------------------------------------------------------
+    //
+    // Define prior distribution to be a constant
+    //
+    void SetPriorConstant()
+    {
+        fVEps0 = 1./fNb;
+
+        CopyCol(*hprior, fVEps);
+
+        //cout << "SetPriorConstant : Prior distribution fVEps = " << endl;
+        //cout << "==============================================" << endl;
+        //fVEps.Print();
+    }
+
+    // -----------------------------------------------------------------------
+    //
+    // Take prior distribution from the histogram 'ha'
+    // which may have a different binning than 'hprior'
+    //
+    Bool_t SetPriorRebin(TH1D &ha)
+    {
+        // ------------------------------------------------------------------
+        //
+        // fill the contents of histogram 'ha' into the histogram 'hrior';
+        // the histograms need not have the same binning;
+        // if the binnings are different, the bin contents of histogram 'ha'
+        //    are distributed properly (linearly) over the bins of 'hprior'
+        //
+
+        const Int_t    na   = ha.GetNbinsX();
+        const Double_t alow = ha.GetBinLowEdge(1);
+        const Double_t aup  = ha.GetBinLowEdge(na+1);
+
+        const Int_t    nb   = hprior->GetNbinsX();
+        const Double_t blow = hprior->GetBinLowEdge(1);
+        const Double_t bup  = hprior->GetBinLowEdge(nb+1);
+
+        // check whether there is an overlap
+        //       between the x ranges of the 2 histograms
+        if (alow>bup || aup<blow)
+        {
+            cout << "Rebinning not possible because there is no overlap of the x ranges of the two histograms" << endl;
+            return kFALSE;
+        }
+
+        // there is an overlap
+        //********************
+        Double_t sum = 0;
+        for (Int_t j=1; j<=nb; j++)
+        {
+            const Double_t yl = hprior->GetBinLowEdge(j);
+            const Double_t yh = hprior->GetBinLowEdge(j+1);
+
+            // search bins of histogram ha which contribute
+            // to bin j of histogram hb
+            //----------------
+            Int_t il=0;
+            Int_t ih=0;
+            for (Int_t i=2; i<=na+1; i++)
+            {
+                const Double_t xl = ha.GetBinLowEdge(i);
+                if (xl>yl)
+                {
+                    il = i-1;
+
+                    //.................................
+                    ih = 0;
+                    for (Int_t k=(il+1); k<=(na+1); k++)
+                    {
+                        const Double_t xh = ha.GetBinLowEdge(k);
+                        if (xh >= yh)
+                        {
+                            ih = k-1;
+                            break;
+                        }
+                    }
+                    //.................................
+                    if (ih == 0)
+                        ih = na;
+                    break;
+                }
+            }
+            //----------------
+            if (il == 0)
+            {
+                cout << "Something is wrong " << endl;
+                cout << "          na, alow, aup = " << na << ",  " << alow
+                    << ",  " << aup << endl;
+                cout << "          nb, blow, bup = " << nb << ",  " << blow
+                    << ",  " << bup << endl;
+                return kFALSE;
+            }
+
+            Double_t content=0;
+            // sum up the contribution to bin j
+            for (Int_t i=il; i<=ih; i++)
+            {
+                const Double_t xl = ha.GetBinLowEdge(i);
+                const Double_t xh = ha.GetBinLowEdge(i+1);
+                const Double_t bina = xh-xl;
+
+                if (xl<yl  &&  xh<yh)
+                    content += ha.GetBinContent(i) * (xh-yl) / bina;
+                else
+                    if (xl<yl  &&  xh>=yh)
+                        content += ha.GetBinContent(i) * (yh-yl) / bina;
+                    else
+                        if (xl>=yl  &&  xh<yh)
+                            content += ha.GetBinContent(i);
+                        else if (xl>=yl  &&  xh>=yh)
+                            content += ha.GetBinContent(i) * (yh-xl) / bina;
+            }
+            hprior->SetBinContent(j, content);
+            sum += content;
+        }
+
+        // normalize histogram hb
+        if (sum==0)
+        {
+            cout << "histogram hb is empty; sum of weights in ha = ";
+            cout << ha.GetSumOfWeights() << endl;
+            return kFALSE;
+        }
+
+        for (Int_t j=1; j<=nb; j++)
+        {
+            const Double_t content = hprior->GetBinContent(j)/sum;
+            hprior->SetBinContent(j, content);
+            fVEps0(j-1) = content;
+        }
+
+        //cout << "SetPriorRebin : Prior distribution fVEps = " << endl;
+        //cout << "===========================================" << endl;
+        //fVEps.Print();
+
+        return kTRUE;
+    }
+
+
+    // -----------------------------------------------------------------------
+    //
+    // Set prior distribution to a given distribution 'hpr'
+    //
+    Bool_t SetPriorInput(TH1D &hpr)
+    {
+        CopyCol(fVEps, hpr);
+
+        const Double_t sum = GetMatrixSumCol(fVEps, 0);
+
+        if (sum<=0)
+        {
+            cout << "MUnfold::SetPriorInput: invalid prior distribution" << endl;
+            return kFALSE;
+        }
+
+        // normalize prior distribution
+        fVEps0 *= 1./sum;
+
+        CopyCol(*hprior, fVEps);
+
+        //cout << "SetPriorInput : Prior distribution fVEps = " << endl;
+        //cout << "===========================================" << endl;
+        //fVEps.Print();
+
+        return kTRUE;
+    }
+
+    // -----------------------------------------------------------------------
+    //
+    // Define prior distribution to be a power law
+    // use input distribution 'hprior' only
+    //           for defining the histogram parameters
+    //
+    Bool_t SetPriorPower(Double_t gamma)
+    {
+        // generate distribution according to a power law
+        //                        dN/dE = E^{-gamma}
+        //  or with y = lo10(E),  E = 10^y :
+        //                        dN/dy = ln10 * 10^{y*(1-gamma)}
+        TH1D hpower(*hprior);
+
+        const UInt_t   nbin = hprior->GetNbinsX();
+        const Double_t xmin = hprior->GetBinLowEdge(1);
+        const Double_t xmax = hprior->GetBinLowEdge(nbin+1);
+
+        cout << "nbin, xmin, xmax = " << nbin << ",  ";
+        cout << xmin << ",  " << xmax << endl;
+
+        TF1* fpow = new TF1("fpow", "pow(10.0, x*(1.0-[0]))", xmin,xmax);
+        fpow->SetParName  (0,"gamma");
+        fpow->SetParameter(0, gamma );
+
+        hpower.FillRandom("fpow", 100000);
+
+        // fill prior distribution
+        CopyCol(fVEps, hpower);
+
+        const Double_t sum = GetMatrixSumCol(fVEps, 0);
+        if (sum <= 0)
+        {
+            cout << "MUnfold::SetPriorPower : invalid prior distribution"  << endl;
+            return kFALSE;
+        }
+
+        // normalize prior distribution
+        fVEps0 *= 1./sum;
+        CopyCol(*hprior, fVEps);
+
+        //cout << "SetPriorPower : Prior distribution fVEps = " << endl;
+        //cout << "===========================================" << endl;
+        //fVEps.Print();
+
+        return kTRUE;
+    }
+
+
+    // -----------------------------------------------------------------------
+    //
+    // Set the initial weight
+    //
+    Bool_t SetInitialWeight(Double_t &weight)
+    {
+        if (weight == 0.0)
+        {
+            TMatrixD v1(fVa, TMatrixD::kTransposeMult, fVacovInv);
+            TMatrixD v2(v1, TMatrixD::kMult, fVa);
+            weight = 1./sqrt(v2(0,0));
+        }
+
+        cout << "MUnfold::SetInitialWeight : Initial Weight = "
+            << weight << endl;
+
+        return kTRUE;
+    }
+
+    // -----------------------------------------------------------------------
+    //
+    // Print the unfolded distribution
+    //
+    void PrintResults()
+    {
+        cout << bintitle << endl;
+        cout << "PrintResults : Unfolded distribution fResult " << endl;
+        cout << "=============================================" << endl;
+        //cout << "val, eparab, eplus, eminus, gcc = "  << endl;
+
+        for (UInt_t i=0; i<fNb; i++)
+        {
+	  //    cout << fResult(i, 0) << " \t";
+          //  cout << fResult(i, 1) << " \t";
+          //  cout << fResult(i, 2) << " \t";
+          //  cout << fResult(i, 3) << " \t";
+          //  cout << fResult(i, 4) <<  endl;
+        }
+        cout << "Chisquared, NDF, chi2 probability, ixbest = "
+            << fChisq << ",  "
+            << fNdf << ",  " << fProb << ",  " << ixbest << endl;
+
+    }
+
+
+    // -----------------------------------------------------------------------
+    //
+    // Schmelling  : unfolding by minimizing the function Z
+    //               by Gauss-Newton iteration
+    //
+    //               the weights are scanned between
+    //               1.e-5*fWinitial and 1.e5*fWinitial
+    //
+    Bool_t Schmelling(TH1D &hb0)
+    {
+    
+        //======================================================================
+        // copy ideal distribution
+        for (UInt_t i=1; i<=fNb; i++)
+        {
+            fhb0->SetBinContent(i, hb0.GetBinContent(i));
+            fhb0->SetBinError  (i, hb0.GetBinError(i));
+        }
+    
+        //-----------------------------------------------------------------------
+        // Initialization
+        // ==============
+
+        Int_t numGiteration;
+        Int_t MaxGiteration = 1000;
+
+        TMatrixD alpha;
+        alpha.ResizeTo(fNa, 1);
+
+
+        //-----------------------------------------------------------------------
+        // Newton iteration
+        // ================
+
+        Double_t dga2;
+        Double_t dga2old;
+        Double_t EpsG = 1.e-12;
+
+        TMatrixD wZdp_inv(fNa, fNa);
+        TMatrixD d(fNb, 1);
+        TMatrixD p(fNb, 1);
+
+        TMatrixD gamma (fNa, 1);
+        TMatrixD dgamma(fNa, 1);
+
+        Double_t fWinitial;
+        fWinitial = 0.0;
+        SetInitialWeight(fWinitial);
+        // for my example this fWinitial was not good; therefore :
+        fWinitial = 1.0;
+
+        Int_t ix;
+        Double_t xiter;
+
+        //--------   start  scanning weights   --------------------------
+        // if full == kFALSE   only quantities necessary for the Gauss-Newton
+        //                     iteration are calculated in SchmellCore
+        // if full == kTRUE    in addition the unfolded distribution,
+        //                     its covariance matrix and quantities like
+        //                     Chisq, SpurAR, etc. are computed in SchmellCore
+        //Bool_t full;
+        //full = kFALSE;
+        Int_t full;
+
+        cout << "Schmelling : start loop over weights" << endl;
+
+        dga2 = 1.e20;
+        for (ix=0; ix<Nix; ix++)
+        {
+            xiter = pow(10.0,log10(xmin)+ix*dlogx) * fWinitial;
+
+            //----------   start Gauss-Newton iteration   ----------------------
+            numGiteration = 0;
+
+            // if there was no convergence and the starting gamma was != 0
+            // redo unfolding for the same weight starting with gamma = 0
+            //
+            Int_t gamma0 = 0;
+            while (1)
+	    {
+              if (dga2 > EpsG)
+	      {
+                gamma0 = 1;
+                gamma.Zero();
+	      }
+
+              dga2 = 1.e20;
+
+              while (1)
+              {
+                dga2old = dga2;
+
+                full = 0;
+                SchmellCore(full, xiter, gamma, dgamma, dga2);
+
+                gamma += dgamma;
+
+                //cout << "Schmelling : ix, numGiteration, dga2, dga2old = "
+                //     << ix << ",  " << numGiteration << ",  "
+                //     << dga2 << ",  " << dga2old << endl;
+
+                numGiteration += 1;
+
+                // convergence
+                if (dga2 < EpsG)
+                    break;
+
+                // no convergence
+                if (numGiteration > MaxGiteration)
+                    break;
+
+                // gamma doesn't seem to change any more
+                if (fabs(dga2-dga2old) < EpsG/100.)
+                    break;
+              }
+              //----------   end Gauss-Newton iteration   ------------------------
+              if (dga2<EpsG || gamma0 != 0) break;
+	    }
+
+            // if Gauss-Newton iteration has not converged
+            // go to next weight
+            if (dga2 > EpsG)
+            {
+                cout << "Schmelling : Gauss-Newton iteration has not converged;"
+                    << "   numGiteration = " << numGiteration << endl;
+                cout << "             ix, dga2, dga2old = " << ix << ",  "
+                    << dga2 << ",  " << dga2old << endl;
+                continue;
+            }
+
+            //cout << "Schmelling : Gauss-Newton iteration has converged;" << endl;
+            //cout << "==================================================" << endl;
+            //cout << "             numGiteration = " << numGiteration << endl;
+            //cout << "             ix, dga2 = " << ix << ",  " << dga2 << endl;
+
+            // calculated quantities which will be useful for determining
+            // the best weight (Chisq, SpurAR, ...)
+            //full = kTRUE;
+            full = 1;
+            SchmellCore(full, xiter, gamma, dgamma, dga2);
+
+            // calculate difference between ideal and unfolded distribution
+            Double_t D2bar = 0.0;
+            for (UInt_t i = 0; i<fNb; i++)
+            {
+                Double_t temp = fVb(i,0)-hb0.GetBinContent(i+1,0);
+                D2bar += temp*temp;
+            }
+
+            SpAR(ix)  = SpurAR;
+            SpSig(ix) = SpurSigma;
+            chisq(ix) = Chisq;
+            SecDer(ix) = SecDeriv;
+            ZerDer(ix) = ZerDeriv;
+            Entrop(ix) = Entropy;
+            DAR2(ix)   = DiffAR2;
+            Dsqbar(ix) = D2bar;
+
+        }
+        //----------   end of scanning weights   -------------------------------
+        cout << "Schmelling : end of loop over weights" << endl;
+        // plots ------------------------------
+        for (ix=0; ix<Nix; ix++)
+        {
+            Double_t xbin = log10(xmin)+ix*dlogx;
+            xiter = pow(10.0,xbin) * fWinitial;
+
+            Int_t bin;
+            bin = hBchisq->FindBin( xbin );
+            hBchisq->SetBinContent(bin,chisq(ix));
+            hBSpAR->SetBinContent(bin,SpAR(ix));
+            hBSpSig->SetBinContent(bin,SpSig(ix)/fSpurVacov);
+            hBSecDeriv->SetBinContent(bin,SecDer(ix));
+            hBZerDeriv->SetBinContent(bin,ZerDer(ix));
+            hBEntropy->SetBinContent(bin,Entrop(ix));
+            hBDAR2->SetBinContent(bin,DAR2(ix));
+            hBD2bar->SetBinContent(bin,Dsqbar(ix));
+
+            if (ix > 0)
+            {
+                Double_t DSpAR = SpAR(ix) - SpAR(ix-1);
+                hBDSpAR->SetBinContent(bin,DSpAR);
+
+                Double_t diff = SpSig(ix) - SpSig(ix-1);
+                Double_t DSpSig = diff;
+                hBDSpSig->SetBinContent(bin, DSpSig/fSpurVacov);
+
+                Double_t DEntrop = Entrop(ix) - Entrop(ix-1);
+                hBDEntropy->SetBinContent(bin,DEntrop);
+
+                Double_t DSecDer = SecDer(ix) - SecDer(ix-1);
+                hBDSecDeriv->SetBinContent(bin,DSecDer);
+
+                Double_t DZerDer = ZerDer(ix) - ZerDer(ix-1);
+                hBDZerDeriv->SetBinContent(bin,DZerDer);
+            }
+        }
+
+        // Select best weight
+        SelectBestWeight();
+
+        if (ixbest < 0.0)
+        {
+            cout << "Schmelling : no solution found; " << endl;
+            return kFALSE;
+        }
+
+        // do the unfolding using the best weight
+        //full = kTRUE;
+
+
+        xiter = pow(10.0,log10(xmin)+ixbest*dlogx) * fWinitial;
+
+        //----------   start Gauss-Newton iteration   ----------------------
+        numGiteration = 0;
+        gamma.Zero();
+        dga2 = 1.e20;
+
+        while (1)
+        {
+            full = 1;
+            SchmellCore(full, xiter, gamma, dgamma, dga2);
+            gamma += dgamma;
+
+            //cout << "Schmelling : sum(dgamma^2) = " << dga2 << endl;
+
+            numGiteration += 1;
+
+            if (numGiteration > MaxGiteration)
+                break;
+
+            if (dga2 < EpsG)
+                break;
+        }
+        //----------   end Gauss-Newton iteration   ------------------------
+
+
+        //-----------------------------------------------------------------------
+        // termination stage
+        // =================
+
+        cout << "Schmelling : best solution found; " << endl;
+        cout << "==================================" << endl;
+        cout << "             xiter, ixbest, numGiteration, Chisq = "
+            << xiter << ",  " << ixbest << ",  "
+            << numGiteration << ",  " << Chisq << endl;
+
+        //------------------------------------
+        //..............................................
+        // put unfolded distribution into fResult
+        //     fResult(i,0)   value in bin i
+        //     fResult(i,1)   error of value in bin i
+
+        fNdf = SpurAR;
+        fChisq = Chisq;
+
+        for (UInt_t i=0; i<fNa; i++)
+	{
+          fChi2(i,0) = Chi2(i,0);
+	}
+
+        UInt_t iNdf   = (UInt_t) (fNdf+0.5);
+        fProb = iNdf>0 ? TMath::Prob(fChisq, iNdf) : 0;
+
+        fResult.ResizeTo(fNb, 5);
+        for (UInt_t i=0; i<fNb; i++)
+        {
+            fResult(i, 0) = fVb(i,0);
+            fResult(i, 1) = sqrt(fVbcov(i,i));
+            fResult(i, 2) = 0.0;
+            fResult(i, 3) = 0.0;
+            fResult(i, 4) = 1.0; 
+	}
+
+        //--------------------------------------------------------
+
+        cout << "Schmelling : gamma = " << endl;
+        for (UInt_t i=0; i<fNa; i++)
+            cout << gamma(i,0) << " \t";
+        cout << endl;
+
+        return kTRUE;
+    }
+
+
+
+
+    // -----------------------------------------------------------------------
+    //
+    // SchmellCore     main part of Schmellings calculations
+    //
+    void SchmellCore(Int_t full, Double_t &xiter, TMatrixD &gamma,
+                     TMatrixD &dgamma, Double_t &dga2)
+    {
+        Double_t norm;
+        TMatrixD wZdp_inv(fNa, fNa);
+        TMatrixD d(fNb, 1);
+        TMatrixD p(fNb, 1);
+
+        //--------------------------------------------------------
+        //--      determine the probability vector p
+
+
+        TMatrixD v3(gamma, TMatrixD::kTransposeMult, fMigrat);
+        TMatrixD v4(TMatrixD::kTransposed, v3);
+        d = v4;
+        Double_t dmax  = -1.e10;
+        for (UInt_t j=0; j<fNb; j++)
+            if (d(j,0)>dmax)
+                dmax = d(j,0);
+
+        Double_t psum = 0.0;
+        for (UInt_t j=0; j<fNb; j++)
+        {
+            d(j,0) -= dmax;
+            p(j,0)  = fVEps0(j)*exp(xiter*d(j,0));
+            psum += p(j,0);
+        }
+
+        p *= 1.0/psum;
+
+        //--      get the vector alpha
+
+        TMatrixD alpha(fMigrat, TMatrixD::kMult, p);
+
+        //--      determine the current normalization
+
+        TMatrixD v2   (alpha, TMatrixD::kTransposeMult, fVacovInv);
+        TMatrixD normb(v2,    TMatrixD::kMult, alpha);
+
+        TMatrixD normc(v2,    TMatrixD::kMult, fVa);
+
+        norm  = normc(0,0)/normb(0,0);
+
+        //--------------------------------------------------------
+        //--      determine the scaled slope vector s and Hessian H
+
+        TMatrixD Zp(fNa,1);
+        for (UInt_t i=0; i<fNa; i++)
+        {
+            Zp(i,0) = norm*alpha(i,0) - fVa(i,0);
+            for (UInt_t k=0; k<fNa; k++)
+                Zp(i,0) += gamma(k,0)*fVacov(k,i);
+        }
+
+
+        TMatrixD Q  (fNa, fNa);
+        TMatrixD wZdp(fNa, fNa);
+        for (UInt_t i=0; i<fNa; i++)
+        {
+            for (UInt_t j=0; j<fNa; j++)
+            {
+                Q(i,j) = - alpha(i,0)*alpha(j,0);
+                for (UInt_t k=0; k<fNb; k++)
+                    Q(i,j) += fMigrat(i,k)*fMigrat(j,k)*p(k,0);
+                wZdp(i,j) = xiter*norm*Q(i,j) + fVacov(i,j);
+            }
+        }
+
+        //--      invert H and calculate the next Newton step
+
+        Double_t determ = 1.0;
+        wZdp_inv = wZdp;
+        wZdp_inv.Invert(&determ);
+
+        if(determ == 0.0)
+        {
+            cout << "SchmellCore: matrix inversion for H failed" << endl;
+            return;
+        }
+
+
+        dga2 = 0.0;
+        for (UInt_t i=0; i<fNa; i++)
+        {
+            dgamma(i,0) = 0.0;
+            for (UInt_t j=0; j<fNa; j++)
+                dgamma(i,0) -= wZdp_inv(i,j)*Zp(j,0);
+            dga2 += dgamma(i,0)*dgamma(i,0);
+        }
+
+        if (full == 0)
+            return;
+
+        //--------------------------------------------------------
+        //--      determine chi2 and dNdf (#measurements ignored)
+        Double_t dNdf = 0;
+        for (UInt_t i=0; i<fNa; i++)
+        {
+            Chi2(i,0) = 0;
+            for (UInt_t j=0; j<fNa; j++)
+            {
+                Chi2(i,0) += fVacov(i,j) * gamma(i,0) * gamma(j,0);
+                dNdf       += fVacov(i,j) * wZdp_inv(j,i);
+            }
+        }
+        Chisq = GetMatrixSumCol(Chi2, 0);
+        SpurAR = fNa - dNdf;
+
+        //-----------------------------------------------------
+        // calculate the norm |AR - AR+|**2
+
+        TMatrixD AR(fNa, fNa);
+        DiffAR2 = 0.0;
+        for (UInt_t i=0; i<fNa; i++)
+        {
+            for (UInt_t j=0; j<fNa; j++)
+            {
+                AR(i,j) = 0.0;
+                for (UInt_t k=0; k<fNa; k++)
+                    AR(i,j) +=  fVacov(i,k) * wZdp_inv(k,j);
+                DiffAR2 += AR(i,j) * AR(i,j);
+            }
+        }
+
+        //--------------------------------------------------------
+        //--      fill distribution b(*)
+        fVb = p;
+        fVb *= norm;
+
+        //--      determine the covariance matrix of b (very expensive)
+
+        TMatrixD T(fNb,fNa);
+        for (UInt_t i=0; i<fNb; i++)
+        {
+            for (UInt_t j=0; j<fNa; j++)
+            {
+                T(i,j) = 0.0;
+                for (UInt_t k=0; k<fNa; k++)
+                    T(i,j) += xiter*wZdp_inv(k,j)*(fMigrat(k,i)-alpha(k,0))*p(i,0);
+            }
+        }
+
+        SpurSigma = CalcSpurSigma(T, norm);
+
+        //--------------------------------------------------------
+
+        //-----------------------------------------------------
+        // calculate the second derivative squared
+
+        SecDeriv = 0;
+        for (UInt_t j=1; j<(fNb-1); j++)
+        {
+            Double_t temp =
+                + 2.0*(fVb(j+1,0)-fVb(j,0)) / (fVb(j+1,0)+fVb(j,0))
+                - 2.0*(fVb(j,0)-fVb(j-1,0)) / (fVb(j,0)+fVb(j-1,0));
+            SecDeriv += temp*temp;
+        }
+
+        ZerDeriv = 0;
+        for (UInt_t j=0; j<fNb; j++)
+            ZerDeriv += fVb(j,0) * fVb(j,0);
+
+        //-----------------------------------------------------
+        // calculate the entropy
+        Entropy = 0;
+        for (UInt_t j=0; j<fNb; j++)
+            if (p(j,0) > 0.0)
+                Entropy += p(j,0) * log( p(j,0) );
+
+        //--------------------------------------------------------
+    }
+
+
+    // -----------------------------------------------------------------------
+    //
+    // Smooth migration matrix
+    //              by fitting a function to the migration matrix
+    //
+    Bool_t SmoothMigrationMatrix(TH2D &hmigorig)
+    {
+        // copy histograms into matrices; the matrices will be used in fcnSmooth
+        // ------------------------
+
+      
+      //cout << "MUnfold::SmoothMigrationMatrix : fNa, fNb = " << fNa << ",  " << fNb << endl;
+
+      //cout << "MUnfold::SmoothMigrationMatrix:   fMigOrig = "  << endl;
+      //cout << "========================================"  << endl;
+        for (UInt_t i=0; i<fNa; i++)
+        {
+            for (UInt_t j=0; j<fNb; j++)
+            {
+                fMigOrig(i, j)     = hmigorig.GetBinContent(i+1, j+1);
+	        //cout << fMigOrig(i, j) << " \t";
+            }
+            //cout << endl;
+        }
+      
+
+        // ------------------------
+
+      
+        //cout << "MUnfold::SmoothMigrationMatrix :   fMigOrigerr2 = " << endl;
+        //cout << "=============================================" << endl;
+        for (UInt_t i=0; i<fNa; i++)
+        {
+            for (UInt_t j=0; j<fNb; j++)
+            {
+                fMigOrigerr2(i, j) =   hmigorig.GetBinError(i+1, j+1)
+                    * hmigorig.GetBinError(i+1, j+1);
+
+                //cout << fMigOrigerr2(i, j) << " \t";
+            }
+            //cout << endl;
+        }
+      
+
+        // ------------------------
+        // the number of free parameters (npar) is equal to 6:
+        //     a0mean, a1mean, a2mean     
+        //     <log10(Eest)>    = a0 + a1*log10(Etrue) + a2*SQR(log10(Etrue))
+        //                                                     + log10(Etrue)  
+        //     b0RMS,  b1RMS, b2RMS      
+        //     RMS(log10(Eest)) = b0 + b1*log10(Etrue) + b2*SQR(log10(Etrue))
+        // 
+        UInt_t npar = 6;
+
+        if (npar > 20)
+        {
+            cout << "MUnfold::SmoothMigrationMatrix : too many parameters,  npar = "
+                << npar << endl;
+            return kFALSE;
+        }
+
+
+        //..............................................
+        // Find reasonable starting values for a0, a1 and b0, b1
+
+        Double_t xbar   = 0.0;
+        Double_t xxbar  = 0.0;
+
+        Double_t ybarm  = 0.0;
+        Double_t xybarm = 0.0;
+
+        Double_t ybarR  = 0.0;
+        Double_t xybarR = 0.0;
+
+        Double_t Sum = 0.0;
+        for (UInt_t j=0; j<fNb; j++)
+        {
+            Double_t x = (double)j + 0.5;
+
+            Double_t meany = 0.0;
+            Double_t RMSy  = 0.0;
+            Double_t sum   = 0.0;
+            for (UInt_t i=0; i<fNa; i++)
+            {
+                Double_t y = (double)i + 0.5;
+                meany +=   y * fMigOrig(i, j);
+                RMSy  += y*y * fMigOrig(i, j);
+                sum   +=       fMigOrig(i, j);
+            }
+            if (sum > 0.0)
+            {
+                meany  = meany / sum;
+                RMSy   =  RMSy / sum  - meany*meany;
+                RMSy = sqrt(RMSy);
+
+                Sum += sum;
+                xbar  +=   x * sum;
+                xxbar += x*x * sum;
+
+                ybarm  +=   meany * sum;
+                xybarm += x*meany * sum;
+
+                ybarR  +=   RMSy  * sum;
+                xybarR += x*RMSy  * sum;
+            }
+        }
+
+        if (Sum > 0.0)
+        {
+            xbar   /= Sum;
+            xxbar  /= Sum;
+
+            ybarm  /= Sum;
+            xybarm /= Sum;
+
+            ybarR  /= Sum;
+            xybarR /= Sum;
+        }
+
+        Double_t a1start = (xybarm - xbar*ybarm) / (xxbar - xbar*xbar);
+        Double_t a0start = ybarm - a1start*xbar;
+        a1start = a1start - 1.0;
+
+        Double_t b1start = (xybarR - xbar*ybarR) / (xxbar - xbar*xbar);
+        Double_t b0start = ybarR - b1start*xbar;
+
+        cout << "MUnfold::SmoothMigrationMatrix : " << endl;
+        cout << "============================" << endl;
+        cout << "a0start, a1start = " << a0start << ",  " << a1start << endl;
+        cout << "b0start, b1start = " << b0start << ",  " << b1start << endl;
+
+        //..............................................
+        // Set starting values and step sizes for parameters
+
+        char name[20][100];
+        Double_t vinit[20];
+        Double_t  step[20];
+        Double_t limlo[20];
+        Double_t limup[20];
+        Int_t    fix[20];
+
+        sprintf(&name[0][0], "a0mean");
+        vinit[0] = a0start;
+        //vinit[0] = 1.0;
+        step[0]  = 0.1;
+        limlo[0] = 0.0;
+        limup[0] = 0.0;
+        fix[0]   = 0;
+
+        sprintf(&name[1][0], "a1mean");
+        vinit[1] = a1start;
+        //vinit[1] = 0.0;
+        step[1]  = 0.1;
+        limlo[1] = 0.0;
+        limup[1] = 0.0;
+        fix[1]   = 0;
+
+        sprintf(&name[2][0], "a2mean");
+        vinit[2] = 0.0;
+        step[2]  = 0.1;
+        limlo[2] = 0.0;
+        limup[2] = 0.0;
+        fix[2]   = 0;
+
+        sprintf(&name[3][0], "b0RMS");
+        vinit[3] = b0start;
+          //vinit[3] = 0.8;
+        step[3]  = 0.1;
+        limlo[3] = 1.e-20;
+        limup[3] = 10.0;
+        fix[3]   = 0;
+
+        sprintf(&name[4][0], "b1RMS");
+        vinit[4] = b1start;
+        //vinit[4] = 0.0;
+        step[4]  = 0.1;
+        limlo[4] = 0.0;
+        limup[4] = 0.0;
+        fix[4]   = 0;
+
+        sprintf(&name[5][0], "b2RMS");
+        vinit[5] = 0.0;
+        step[5]  = 0.1;
+        limlo[5] = 0.0;
+        limup[5] = 0.0;
+        fix[5]   = 0;
+
+
+        if ( CallMinuit(fcnSmooth, npar, name, vinit,
+                        step, limlo, limup, fix) )
+        {
+
+            // ------------------------
+            // fMigrat is the migration matrix to be used in the unfolding;
+            // fMigrat, as set by the constructor, is overwritten
+            //          by the smoothed migration matrix
+
+            for (UInt_t i=0; i<fNa; i++)
+                for (UInt_t j=0; j<fNb; j++)
+                    fMigrat(i, j) = fMigSmoo(i, j);
+
+            // ------------------------
+
+            for (UInt_t i=0; i<fNa; i++)
+                for (UInt_t j=0; j<fNb; j++)
+                    fMigraterr2(i, j) = fMigSmooerr2(i, j);
+
+
+            // normalize
+            for (UInt_t j=0; j<fNb; j++)
+            {
+                Double_t sum = 0.0;
+                for (UInt_t i=0; i<fNa; i++)
+                    sum += fMigrat(i, j);
+
+                //cout << "SmoothMigrationMatrix : normalization fMigrat; j, sum + "
+                //     << j << ",  " << sum << endl;
+
+                if (sum == 0.0)
+                    continue;
+
+                for (UInt_t i=0; i<fNa; i++)
+                {
+                    fMigrat(i, j)     /= sum;
+                    fMigraterr2(i, j) /= (sum*sum);
+                }
+            }
+
+            cout << "MUnfold::SmoothMigrationMatrix :   fMigrat = "  << endl;
+            cout << "========================================"  << endl;
+            for (UInt_t i=0; i<fNa; i++)
+            {
+                for (UInt_t j=0; j<fNb; j++)
+                    cout << fMigrat(i, j) << " \t";
+                cout << endl;
+            }
+
+	    /*
+            cout << "MUnfold::SmoothMigrationMatrix :   fMigraterr2 = "  << endl;
+            cout << "============================================"  << endl;
+            for (UInt_t i=0; i<fNa; i++)
+            {
+                for (UInt_t j=0; j<fNb; j++)
+                    cout << fMigraterr2(i, j) << " \t";
+                cout << endl;
+            }
+	    */
+
+            // ------------------------
+
+            return kTRUE;
+        }
+
+        return kFALSE;
+    }
+
+    // -----------------------------------------------------------------------
+    //
+    // Prepare the call to MINUIT for the minimization of the function
+    //         f = chi2*w/2 + reg, where reg is the regularization term
+    //         reg is the sum the squared 2nd derivatives
+    //                        of the unfolded distribution
+    //
+    // the corresponding fcn routine is 'fcnTikhonov2'
+    //
+    Bool_t Tikhonov2(TH1D &hb0)
+    {
+        // the number of free parameters (npar) is equal to
+        // the number of bins (fNb) of the unfolded distribution minus 1,
+        // because of the constraint that the total number of events
+        // is fixed
+        UInt_t npar = fNb-1;
+
+        if (npar > 20)
+        {
+            cout << "MUnfold::Tikhonov2 : too many parameters,  npar = "
+                << npar << ",  fNb = " << fNb << endl;
+            return kFALSE;
+        }
+
+        // copy ideal distribution
+        
+        for (UInt_t i=1; i<=fNb; i++)
+        {
+            fhb0->SetBinContent(i, hb0.GetBinContent(i));
+            fhb0->SetBinError  (i, hb0.GetBinError(i));
+        }
+        
+
+        //---   start w loop -----------------------------------
+
+        cout << "Tikhonov2 : start loop over weights" << endl;
+
+        Int_t ix;
+        Double_t xiter;
+
+        for (ix=0; ix<Nix; ix++)
+        {
+            fW = pow(10.0,log10(xmin)+ix*dlogx);
+
+            //..............................................
+            // Set starting values and step sizes for parameters
+
+            char name[20][100];
+            Double_t vinit[20];
+            Double_t  step[20];
+            Double_t limlo[20];
+            Double_t limup[20];
+            Int_t    fix[20];
+
+            for (UInt_t i=0; i<npar; i++)
+            {
+                sprintf(&name[i][0], "p%d", i+1);
+                vinit[i] = fVEps0(i);
+                step[i]  = fVEps0(i)/10;
+
+                // lower and upper limits  (limlo=limup=0: no limits)
+                //limlo[i] = 1.e-20;
+                limlo[i] = -1.0;
+                limup[i] = 1.0;
+                fix[i]   = 0;
+            }
+
+            // calculate solution for the weight fW
+            // flag non-convergence by chisq(ix) = 0.0
+            chisq(ix) = 0.0;
+            if ( CallMinuit(fcnTikhonov2, npar, name, vinit,
+                            step, limlo, limup, fix) )
+            {
+                // calculate difference between ideal and unfolded distribution
+                Double_t D2bar = 0.0;
+                for (UInt_t i = 0; i<fNb; i++)
+                {
+                    Double_t temp = fVb(i,0)-hb0.GetBinContent(i+1,0);
+                    D2bar += temp*temp;
+                }
+
+                SpAR(ix)   = SpurAR;
+                SpSig(ix)  = SpurSigma;
+                chisq(ix)  = Chisq;
+                SecDer(ix) = SecDeriv;
+                ZerDer(ix) = ZerDeriv;
+                Entrop(ix) = Entropy;
+                DAR2(ix)   = DiffAR2;
+                Dsqbar(ix) = D2bar;
+            }
+        }
+        cout << "Tikhonov2 : end of loop over weights" << endl;
+
+        // plots ------------------------------
+        for (ix=0; ix<Nix; ix++)
+        {
+            // test whether minimization has converged
+            if (chisq(ix) != 0.0)
+            {
+                xiter = pow(10.0,log10(xmin)+ix*dlogx);
+
+                Int_t bin;
+                bin = hBchisq->FindBin( log10(xiter) );
+                hBchisq->SetBinContent(bin,chisq(ix));
+
+                //hBSpAR->SetBinContent(bin,SpAR(ix));
+                hBSpAR->SetBinContent(bin,0.0);
+
+                hBSpSig->SetBinContent(bin,SpSig(ix)/fSpurVacov);
+                hBSecDeriv->SetBinContent(bin,SecDer(ix));
+                hBZerDeriv->SetBinContent(bin,ZerDer(ix));
+                hBEntropy->SetBinContent(bin,Entrop(ix));
+
+                //hBDAR2->SetBinContent(bin,DAR2(ix));
+                hBDAR2->SetBinContent(bin,0.0);
+
+                hBD2bar->SetBinContent(bin,Dsqbar(ix));
+
+                if (ix > 0)
+                {
+                    //Double_t DSpAR = SpAR(ix) - SpAR(ix-1);
+                    //hBDSpAR->SetBinContent(bin,DSpAR);
+
+                    Double_t diff = SpSig(ix) - SpSig(ix-1);
+                    Double_t DSpSig = diff;
+                    hBDSpSig->SetBinContent(bin, DSpSig/fSpurVacov);
+
+                    Double_t DEntrop = Entrop(ix) - Entrop(ix-1);
+                    hBDEntropy->SetBinContent(bin,DEntrop);
+
+                    Double_t DSecDer = SecDer(ix) - SecDer(ix-1);
+                    hBDSecDeriv->SetBinContent(bin,DSecDer);
+
+                    Double_t DZerDer = ZerDer(ix) - ZerDer(ix-1);
+                    hBDZerDeriv->SetBinContent(bin,DZerDer);
+                }
+            }
+        }
+
+
+        //---   end w loop -----------------------------------
+
+        // Select best weight
+        SelectBestWeight();
+
+        cout << " Tikhonov2 : after SelectBestWeight" << endl;
+
+        if (ixbest < 0.0)
+        {
+            cout << "Tikhonov2 : no result found; " << endl;
+            return kFALSE;
+        }
+
+        cout << "Tikhonov2 : best result found; " << endl;
+        cout << "===============================" << endl;
+        cout << "           ixbest = " << ixbest << endl;
+
+
+        // do a final unfolding using the best weight
+
+        fW = pow(10.0,log10(xmin)+ixbest*dlogx);
+
+        //..............................................
+        // Set starting values and step sizes for parameters
+
+        char name[20][100];
+        Double_t vinit[20];
+        Double_t  step[20];
+        Double_t limlo[20];
+        Double_t limup[20];
+        Int_t    fix[20];
+
+        for (UInt_t i=0; i<npar; i++)
+        {
+            sprintf(&name[i][0], "p%d", i+1);
+            vinit[i] = fVEps0(i);
+            step[i]  = fVEps0(i)/10;
+
+            // lower and upper limits  (limlo=limup=0: no limits)
+            //limlo[i] = 1.e-20;
+            limlo[i] = -1.0;
+            limup[i] = 1.0;
+            fix[i]   = 0;
+        }
+
+        // calculate solution for the best weight
+        CallMinuit(fcnTikhonov2, npar, name, vinit,
+                   step, limlo, limup, fix);
+
+
+        cout << "Tikhonov : Values for best weight " << endl;
+        cout << "==================================" << endl;
+        cout << "fW, ixbest, Chisq, SpurAR, SpurSigma, SecDeriv, ZerDeriv, Entrop, DiffAR2, D2bar = " << endl;
+        cout << "      " << fW << ",  " << ixbest << ",  "
+            << Chisq << ",  " << SpurAR << ",  "
+            << SpurSigma << ",  " << SecDeriv << ",  " << ZerDeriv << ",  "
+            << Entropy << ",  " << DiffAR2 << ",  "
+            << Dsqbar(ixbest) << endl;
+
+        return kTRUE;
+
+    }
+
+
+    // -----------------------------------------------------------------------
+    //
+    // Bertero :
+    //
+    // the unfolded distribution is calculated iteratively;
+    // the number of iterations after which the iteration is stopped
+    //            corresponds to the 'weight' in other methods
+    // a small number of iterations corresponds to strong regularization
+    // a high number to no regularization
+    //
+    // see : M.Bertero, INFN/TC-88/2 (1988)
+    //       V.B.Anykeyev et al., NIM A303 (1991) 350
+    //
+    Bool_t Bertero(TH1D &hb0)
+    {
+        // copy ideal distribution
+        
+        for (UInt_t i=1; i<=fNb; i++)
+        {
+            fhb0->SetBinContent(i, hb0.GetBinContent(i));
+            fhb0->SetBinError  (i, hb0.GetBinError(i));
+        }
+        
+
+        TMatrixD bold(fNb, 1);
+        bold.Zero();
+
+        //----------------------------------------------------------
+
+        Double_t db2 = 1.e20;
+
+
+        TMatrixD aminusaest(fNa, 1);
+
+        //-------   scan number of iterations   -----------------
+
+        cout << "Bertero : start loop over number of iterations" << endl;
+
+        Int_t ix;
+
+        for (ix=0; ix<Nix; ix++)
+        {
+            Double_t xiter = pow(10.0,log10(xmin)+ix*dlogx);
+
+            // calculate solution for the iteration number xiter
+            BertCore(xiter);
+
+            // calculate difference between ideal and unfolded distribution
+            Double_t D2bar = 0.0;
+            for (UInt_t i = 0; i<fNb; i++)
+            {
+                Double_t temp = fVb(i,0)-hb0.GetBinContent(i+1,0);
+                D2bar += temp*temp;
+            }
+
+            SpAR(ix)   = SpurAR;
+            SpSig(ix)  = SpurSigma;
+            chisq(ix)  = Chisq;
+            SecDer(ix) = SecDeriv;
+            ZerDer(ix) = ZerDeriv;
+            Entrop(ix) = Entropy;
+            DAR2(ix)   = DiffAR2;
+            Dsqbar(ix) = D2bar;
+
+            db2 = 0.0;
+            for (UInt_t i = 0; i<fNb; i++)
+            {
+                Double_t temp = fVb(i,0)-bold(i,0);
+                db2 += temp*temp;
+            }
+            bold = fVb;
+
+            //if (db2 < Epsdb2) break;
+
+        }
+
+        cout << "Bertero : end of loop over number of iterations" << endl;
+
+        // plots ------------------------------
+        for (ix=0; ix<Nix; ix++)
+        {
+            Double_t xiter = pow(10.0,log10(xmin)+ix*dlogx);
+
+            Int_t bin;
+            bin = hBchisq->FindBin( log10(xiter) );
+            hBchisq->SetBinContent(bin,chisq(ix));
+            hBSpAR->SetBinContent(bin,SpAR(ix));
+            hBSpSig->SetBinContent(bin,SpSig(ix)/fSpurVacov);
+            hBSecDeriv->SetBinContent(bin,SecDer(ix));
+            hBZerDeriv->SetBinContent(bin,ZerDer(ix));
+            hBEntropy->SetBinContent(bin,Entrop(ix));
+            hBDAR2->SetBinContent(bin,DAR2(ix));
+            hBD2bar->SetBinContent(bin,Dsqbar(ix));
+
+            if (ix > 0)
+            {
+                Double_t DSpAR = SpAR(ix) - SpAR(ix-1);
+                hBDSpAR->SetBinContent(bin,DSpAR);
+
+                Double_t diff = SpSig(ix) - SpSig(ix-1);
+                Double_t DSpSig = diff;
+                hBDSpSig->SetBinContent(bin, DSpSig/fSpurVacov);
+
+                Double_t DEntrop = Entrop(ix) - Entrop(ix-1);
+                hBDEntropy->SetBinContent(bin,DEntrop);
+
+                Double_t DSecDer = SecDer(ix) - SecDer(ix-1);
+                hBDSecDeriv->SetBinContent(bin,DSecDer);
+
+                Double_t DZerDer = ZerDer(ix) - ZerDer(ix-1);
+                hBDZerDeriv->SetBinContent(bin,DZerDer);
+            }
+        }
+        //-------   end of scan of number of iterations   -----------------
+
+        // Select best weight
+        SelectBestWeight();
+
+
+        if (ixbest < 0.0)
+        {
+            cout << "Bertero : weight iteration has NOT converged; " << endl;
+            return kFALSE;
+        }
+
+        cout << "Bertero : weight iteration has converged; " << endl;
+        cout << "            ixbest = " << ixbest << endl;
+
+
+        // do a final unfolding using the best weight
+
+        // calculate solution for the iteration number xiter
+        Double_t xiter = pow(10.0,log10(xmin)+ixbest*dlogx);
+        BertCore(xiter);
+
+        cout << "Bertero : Values for best weight " << endl;
+        cout << "=================================" << endl;
+        cout << "fW, ixbest, Chisq, SpurAR, SpurSigma, SecDeriv, ZerDeriv, Entrop, DiffAR2, D2bar = " << endl;
+        cout << "      " << fW << ",  " << ixbest << ",  "
+            << Chisq << ",  " << SpurAR << ",  "
+            << SpurSigma << ",  " << SecDeriv << ",  " << ZerDeriv << ",  "
+            << Entropy << ",  " << DiffAR2 << ",  "
+            << Dsqbar(ixbest) << endl;
+
+        //----------------
+
+        fNdf   = SpurAR;
+        fChisq = Chisq;
+
+        for (UInt_t i=0; i<fNa; i++)
+	{
+          fChi2(i,0) = Chi2(i,0);
+	}
+
+        UInt_t iNdf   = (UInt_t) (fNdf+0.5);
+        fProb = iNdf>0 ? TMath::Prob(fChisq, iNdf) : 0;
+
+
+        fResult.ResizeTo(fNb, 5);
+        for (UInt_t i=0; i<fNb; i++)
+        {
+            fResult(i, 0) = fVb(i,0);
+            fResult(i, 1) = sqrt(fVbcov(i,i));
+            fResult(i, 2) = 0.0;
+            fResult(i, 3) = 0.0;
+            fResult(i, 4) = 1.0;
+        }
+
+        return kTRUE;
+    }
+
+    // -----------------------------------------------------------------------
+    //
+    // main part of Bertero's calculations
+    //
+    Bool_t BertCore(Double_t &xiter)
+    {
+        // ignore eigen values which are smaller than EpsLambda
+        TMatrixD G_inv(fNa, fNa);
+        TMatrixD Gtil_inv(fNa, fNa);
+        TMatrixD atil(fNb, fNa);
+        TMatrixD aminusaest(fNa, 1);
+
+        G_inv.Zero();
+        Gtil_inv.Zero();
+        SpurAR = 0.0;
+
+        // -----   loop over eigen values   ------------------
+        // calculate the approximate inverse of the matrix G
+        //cout << "flaml = " << endl;
+
+        UInt_t flagstart = 2;
+        Double_t flaml=0;
+
+        for (UInt_t l=0; l<fNa; l++)
+        {
+            if (EigenValue(l) < EpsLambda)
+                continue;
+
+            switch (flagstart)
+            {
+            case 1 :
+                // This is the expression for f(lambda) if the initial C^(0)
+                // is chosen to be zero
+                flaml = 1.0 - pow(1.0-tau*EigenValue(l),xiter);
+                break;
+
+            case 2 :
+                // This is the expression for f(lambda) if the initial C^(0)
+                // is chosen to be equal to the measured distribution
+                flaml =           1.0 - pow(1.0-tau*EigenValue(l),xiter)
+                    + EigenValue(l) * pow(1.0-tau*EigenValue(l),xiter);
+                break;
+            }
+
+            //  cout << flaml << ",  ";
+
+            for (UInt_t m=0; m<fNa; m++)
+            {
+                for (UInt_t n=0; n<fNa; n++)
+                {
+                    G_inv(m,n)    += 1.0  /EigenValue(l) * Eigen(m,l)*Eigen(n,l);
+                    Gtil_inv(m,n) += flaml/EigenValue(l) * Eigen(m,l)*Eigen(n,l);
+                }
+            }
+            SpurAR += flaml;
+        }
+        //cout << endl;
+
+
+        //cout << "Gtil_inv =" << endl;
+        //for (Int_t m=0; m<fNa; m++)
+        //{
+        //  for (Int_t n=0; n<fNa; n++)
+        //  {
+        //    cout << Gtil_inv(m,n) << ",  ";
+        //  }
+        //  cout << endl;
+        //}
+
+        //-----------------------------------------------------
+        // calculate the unfolded distribution b
+        TMatrixD v2(fMigrat, TMatrixD::kTransposeMult, Gtil_inv);
+        atil = v2;
+        TMatrixD v4(atil, TMatrixD::kMult, fVa);
+        fVb = v4;
+
+        //-----------------------------------------------------
+        // calculate AR and AR+
+        TMatrixD AR(v2, TMatrixD::kMult, fMigrat);
+
+        TMatrixD v3(fMigrat, TMatrixD::kTransposeMult, G_inv);
+        TMatrixD ARplus(v3, TMatrixD::kMult, fMigrat);
+
+
+        //-----------------------------------------------------
+        // calculate the norm |AR - AR+|**2
+
+        DiffAR2 = 0.0;
+        for (UInt_t j=0; j<fNb; j++)
+        {
+            for (UInt_t k=0; k<fNb; k++)
+            {
+                Double_t tempo = AR(j,k) - ARplus(j,k);
+                DiffAR2       += tempo*tempo;
+            }
+        }
+
+        //-----------------------------------------------------
+        // calculate the second derivative squared
+
+        SecDeriv = 0;
+        for (UInt_t j=1; j<(fNb-1); j++)
+        {
+            // temp = ( 2.0*fVb(j,0)-fVb(j-1,0)-fVb(j+1,0) ) / ( 2.0*fVb(j,0) );
+            Double_t temp =    2.0*(fVb(j+1,0)-fVb(j,0)) / (fVb(j+1,0)+fVb(j,0))
+                - 2.0*(fVb(j,0)-fVb(j-1,0)) / (fVb(j,0)+fVb(j-1,0));
+            SecDeriv += temp*temp;
+        }
+
+        ZerDeriv = 0;
+        for (UInt_t j=0; j<fNb; j++)
+            ZerDeriv += fVb(j,0) * fVb(j,0);
+
+        //-----------------------------------------------------
+        // calculate the entropy
+
+        Double_t sumb = 0.0;
+        for (UInt_t j=0; j<fNb; j++)
+            sumb += fVb(j,0);
+
+        TMatrixD p(fNb,1);
+        p = fVb;
+        if (sumb > 0.0)
+            p *= 1.0/sumb;
+
+        Entropy = 0;
+        for (UInt_t j=0; j<fNb; j++)
+            if (p(j,0) > 0.0)
+                Entropy += p(j,0) * log( p(j,0) );
+
+        //-----------------------------------------------------
+
+        TMatrixD Gb(fMigrat, TMatrixD::kMult, fVb);
+        aminusaest = fVa;
+        aminusaest -= Gb;
+    
+        TMatrixD v1(1,fNa);
+        for (UInt_t i=0; i<fNa; i++)
+        {
+            v1(0,i) = 0.0;
+            for (UInt_t j=0; j<fNa; j++)
+                v1(0,i) += aminusaest(j,0) * fVacovInv(j,i) ;
+        }
+
+        //-----------------------------------------------------
+        // calculate error matrix fVbcov of unfolded distribution
+        SpurSigma = CalcSpurSigma(atil);
+
+        //-----------------------------------------------------
+        // calculate the chi squared
+        for (UInt_t i = 0; i<fNa; i++)
+            Chi2(i,0) = v1(0,i) * aminusaest(i,0);
+
+        Chisq = GetMatrixSumCol(Chi2,0);
+        return kTRUE;
+    }
+
+
+    // -----------------------------------------------------------------------
+    //
+    // Calculate the matrix G = M * M(transposed)
+    //           and its eigen values and eigen vectors
+    //
+    Bool_t CalculateG()
+    {
+        // Calculate matrix G = M*M(transposed)     (M = migration matrix)
+        //           the matrix Eigen of the eigen vectors of G
+        //           the vector EigenValues of the eigen values of G
+        //           the parameter tau = 1/lambda_max
+        //
+        TMatrixD v5(TMatrixD::kTransposed, fMigrat);
+        //TMatrixD G(fMigrat, TMatrixD::kMult, v5);
+        G.Mult(fMigrat, v5);
+
+        Eigen = G.EigenVectors(EigenValue);
+
+        RankG = 0.0;
+        for (UInt_t l=0; l<fNa; l++)
+        {
+            if (EigenValue(l) < EpsLambda) continue;
+            RankG += 1.0;
+        }
+
+        tau = 1.0 / EigenValue(0);
+
+        //  cout << "eigen values : " << endl;
+        //  for (Int_t i=0; i<fNa; i++)
+        //  {
+        //    cout << EigenValue(i) << ",  ";
+        //  }
+        //  cout << endl;
+
+        //cout << "eigen vectors : " << endl;
+        //for (Int_t i=0; i<fNa; i++)
+        //{
+        //  cout << "               vector " << i << endl;
+        //  for (Int_t j=0; j<fNa; j++)
+        //  {
+        //    cout << Eigen(j,i) << ",  ";
+        //  }
+        //  cout << endl;
+        //}
+        //cout << endl;
+
+        //cout << "G =" << endl;
+        //for (Int_t m=0; m<fNa; m++)
+        //{
+        //  for (Int_t n=0; n<fNa; n++)
+        //  {
+        //    cout << G(m,n) << ",  ";
+        //  }
+        //  cout << endl;
+        //}
+
+        return kTRUE;
+    }
+
+    // -----------------------------------------------------------------------
+    //
+    // Select the best weight
+    //
+    Bool_t SelectBestWeight()
+    {
+        //-------------------------------
+        // select 'best' weight according to some criterion
+
+        Int_t ix;
+
+        Double_t DiffSpSigmax = -1.e10;
+        Int_t    ixDiffSpSigmax = -1;
+
+        Double_t DiffSigpointsmin = 1.e10;
+        Int_t    ixDiffSigpointsmin = -1;
+
+        Double_t DiffRankGmin = 1.e10;
+        Int_t    ixDiffRankGmin = -1;
+
+        Double_t D2barmin = 1.e10;
+        Int_t    ixD2barmin = -1;
+
+        Double_t DiffSpSig1min = 1.e10;
+        Int_t    ixDiffSpSig1min = -1;
+
+
+        Int_t ixmax = -1;
+
+        // first loop over all weights :
+        //       find smallest chi2
+        Double_t chisqmin = 1.e20;
+        for (ix=0; ix<Nix; ix++)
+        {
+            // consider only weights for which
+            //  - unfolding was successful
+            if (chisq(ix) != 0.0)
+            {
+                if (chisq(ix) < chisqmin)
+                    chisqmin = chisq(ix);
+            }
+        }
+        Double_t chisq0 = chisqmin > fVapoints ? chisqmin : fVapoints/2.0;
+
+        // second loop over all weights :
+        //        consider only weights for which chisq(ix) < chisq0
+        ixbest = -1;
+        for (ix=0; ix<Nix; ix++)
+        {
+            if (chisq(ix) != 0.0 && chisq(ix) < 2.0*chisq0)
+            {
+                // ixmax = highest weight with successful unfolding
+                //         (Least squares solution)
+                ixmax = ix;
+
+                SpurSigma = SpSig(ix);
+                SpurAR    = SpAR(ix);
+                Chisq    = chisq(ix);
+                D2bar     = Dsqbar(ix);
+
+                //----------------------------------
+                // search weight where SpurSigma changes most
+                //                               (as a function of the weight)
+                if (ix > 0  &&  chisq(ix-1) != 0.0)
+                {
+                    Double_t diff = SpSig(ix) - SpSig(ix-1);
+                    if (diff > DiffSpSigmax)
+                    {
+                        DiffSpSigmax   = diff;
+                        ixDiffSpSigmax = ix;
+                    }
+                }
+
+                //----------------------------------
+                // search weight where Chisq is close
+                //        to the number of significant measurements
+                Double_t DiffSigpoints = fabs(Chisq-fVapoints);
+
+                if (DiffSigpoints < DiffSigpointsmin)
+                {
+                    DiffSigpointsmin   = DiffSigpoints;
+                    ixDiffSigpointsmin = ix;
+                }
+
+                //----------------------------------
+                // search weight where Chisq is close
+                //        to the rank of matrix G
+                Double_t DiffRankG = fabs(Chisq-RankG);
+
+                if (DiffRankG < DiffRankGmin)
+                {
+                    DiffRankGmin   = DiffRankG;
+                    ixDiffRankGmin = ix;
+                }
+
+                //----------------------------------
+                // search weight where SpurSigma is close to 1.0
+                Double_t DiffSpSig1 = fabs(SpurSigma/fSpurVacov-1.0);
+
+                if (DiffSpSig1 < DiffSpSig1min)
+                {
+                    DiffSpSig1min   = DiffSpSig1;
+                    ixDiffSpSig1min = ix;
+                }
+
+                //----------------------------------
+                // search weight where D2bar is minimal
+
+                if (D2bar < D2barmin)
+                {
+                    D2barmin   = D2bar;
+                    ixD2barmin = ix;
+                }
+
+                //----------------------------------
+            }
+        }
+
+
+        // choose solution where increase of SpurSigma is biggest
+        //if ( DiffSpSigmax > 0.0)
+        //  ixbest = ixDiffSpSigmax;
+        //else
+        //  ixbest = ixDiffSigpointsmin;
+
+        // choose Least Squares Solution
+	//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
+        // ixbest = ixmax;
+	//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
+
+        // choose weight where chi2 is close to the number of significant
+        // measurements
+        // ixbest = ixDiffSigpointsmin;
+
+        // choose weight where chi2 is close to the rank of matrix G
+        // ixbest = ixDiffRankGmin;
+
+        // choose weight where chi2 is close to the rank of matrix G
+	//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
+           ixbest = ixDiffSpSig1min;
+	//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
+
+        cout << "SelectBestWeight : ixDiffSpSigmax, DiffSpSigmax = "
+            << ixDiffSpSigmax << ",  " << DiffSpSigmax << endl;
+        cout << "================== ixDiffSigpointsmin, DiffSigpointsmin = "
+            << ixDiffSigpointsmin << ",  " << DiffSigpointsmin << endl;
+
+        cout << "                   ixDiffRankGmin, DiffRankGmin = "
+            << ixDiffRankGmin << ",  " << DiffRankGmin << endl;
+
+        cout << "                   ixDiffSpSig1min, DiffSpSig1min = "
+            << ixDiffSpSig1min << ",  " << DiffSpSig1min << endl;
+
+        cout << "                   ixD2barmin, D2barmin = "
+            << ixD2barmin << ",  " << D2barmin << endl;
+        cout << "                   ixmax  = " << ixmax  << endl;
+        cout << "                   ixbest = " << ixbest << endl;
+
+
+        return kTRUE;
+    }
+
+    // -----------------------------------------------------------------------
+    //
+    // Draw the plots
+    //
+    Bool_t DrawPlots()
+    {
+
+        // in the plots, mark the weight which has been selected
+        Double_t xbin = log10(xmin)+ixbest*dlogx;
+
+        TMarker *m = new TMarker();
+        m->SetMarkerSize(1);
+        m->SetMarkerStyle(20);
+
+        //-------------------------------------
+        // draw the iteration plots
+        TString ctitle = bintitle;
+        ctitle += "Plots versus weight";
+        TCanvas *c = new TCanvas("iter", ctitle, 900, 600);
+        c->Divide(3,2);
+
+        c->cd(1);
+        hBchisq->Draw();
+        gPad->SetLogy();
+        hBchisq->SetXTitle("log10(iteration number)");
+        hBchisq->SetYTitle("chisq");
+        m->DrawMarker(xbin, log10(chisq(ixbest)));
+
+        c->cd(2);
+        hBD2bar->Draw();
+        gPad->SetLogy();
+        hBD2bar->SetXTitle("log10(iteration number)");
+        hBD2bar->SetYTitle("(b_unfolded-b_ideal)**2");
+        m->DrawMarker(xbin, log10(Dsqbar(ixbest)));
+
+        /*
+         c->cd(3);
+         hBDAR2->Draw();
+         gPad->SetLogy();
+         strgx = "log10(iteration number)";
+         strgy = "norm(AR-AR+)";
+         hBDAR2->SetXTitle(strgx);
+         hBDAR2->SetYTitle(strgy);
+         m->DrawMarker(xbin, log10(DAR2(ixbest)));
+         */
+
+        c->cd(3);
+        hBSecDeriv->Draw();
+        hBSecDeriv->SetXTitle("log10(iteration number)");
+        hBSecDeriv->SetYTitle("Second Derivative squared");
+        m->DrawMarker(xbin, SecDer(ixbest));
+
+        /*
+         c->cd(8);
+         hBDSecDeriv->Draw();
+         strgx = "log10(iteration number)";
+         strgy = "Delta(Second Derivative squared)";
+         hBDSecDeriv->SetXTitle(strgx);
+         hBDSecDeriv->SetYTitle(strgy);
+         */
+
+        /*
+         c->cd(4);
+         hBZerDeriv->Draw();
+         strgx = "log10(iteration number)";
+         strgy = "Zero Derivative squared";
+         hBZerDeriv->SetXTitle(strgx);
+         hBZerDeriv->SetYTitle(strgy);
+         m->DrawMarker(xbin, ZerDer(ixbest));
+         */
+
+        /*
+         c->cd(5);
+         hBDZerDeriv->Draw();
+         strgx = "log10(iteration number)";
+         strgy = "Delta(Zero Derivative squared)";
+         hBDZerDeriv->SetXTitle(strgx);
+         hBDZerDeriv->SetYTitle(strgy);
+         */
+
+        c->cd(4);
+        hBSpAR->Draw();
+        hBSpAR->SetXTitle("log10(iteration number)");
+        hBSpAR->SetYTitle("SpurAR");
+        m->DrawMarker(xbin, SpAR(ixbest));
+
+
+        /*
+         c->cd(11);
+         hBDSpAR->Draw();
+         strgx = "log10(iteration number)";
+         strgy = "Delta(SpurAR)";
+         hBDSpAR->SetXTitle(strgx);
+         hBDSpAR->SetYTitle(strgy);
+         */
+
+        c->cd(5);
+        hBSpSig->Draw();
+        hBSpSig->SetXTitle("log10(iteration number)");
+        hBSpSig->SetYTitle("SpurSig/SpurC");
+        m->DrawMarker(xbin, SpSig(ixbest)/fSpurVacov);
+
+        /*
+         c->cd(14);
+         hBDSpSig->Draw();
+         strgx = "log10(iteration number)";
+         strgy = "Delta(SpurSig/SpurC)";
+         hBDSpSig->SetXTitle(strgx);
+         hBDSpSig->SetYTitle(strgy);
+         */
+
+        c->cd(6);
+        hBEntropy->Draw();
+        hBEntropy->SetXTitle("log10(iteration number)");
+        hBEntropy->SetYTitle("Entropy");
+        m->DrawMarker(xbin, Entrop(ixbest));
+
+        /*
+         c->cd(17);
+         hBDEntropy->Draw();
+         strgx = "log10(iteration number)";
+         strgy = "Delta(Entropy)";
+         hBDEntropy->SetXTitle(strgx);
+         hBDEntropy->SetYTitle(strgy);
+         */
+
+        //-------------------------------------
+
+        for (UInt_t i=0; i<fNa; i++)
+        {
+            fha->SetBinContent(i+1, fVa(i, 0)         );
+            fha->SetBinError  (i+1, sqrt(fVacov(i, i)));
+
+            for (UInt_t j=0; j<fNb; j++)
+            {
+                fhmig->SetBinContent(i+1, j+1, fMigOrig(i, j)           );
+                fhmig->SetBinError  (i+1, j+1, sqrt(fMigOrigerr2(i, j)) );
+
+                shmig->SetBinContent(i+1, j+1, fMigrat(i, j)           );
+                shmig->SetBinError  (i+1, j+1, sqrt(fMigraterr2(i, j)) );
+                shmigChi2->SetBinContent(i+1, j+1, fMigChi2(i, j)   );
+            }
+        }
+
+        //PrintTH2Content(*shmig);
+        //PrintTH2Content(*shmigChi2);
+
+        //-------------------------------------
+        CopyCol(*hprior, fVEps);
+        CopyCol(*hb,     fVb);
+        for (UInt_t i=0; i<fNb; i++)
+            hb->SetBinError(i+1, sqrt(fVbcov(i, i)));
+
+        PrintTH1Content(*hb);
+        PrintTH1Error(*hb);
+
+        //..............................................
+        for (UInt_t i=0; i<fNa; i++)
+            hEigen->SetBinContent(i+1, EigenValue(i));
+
+        //..............................................
+        // draw the plots
+        TString cctitle = bintitle;
+        cctitle +=  "Unfolding input";
+        TCanvas *cc = new TCanvas("input", cctitle, 900, 600);
+        cc->Divide(3, 2);
+
+        // distribution to be unfolded
+        cc->cd(1);
+        fha->Draw();
+        gPad->SetLogy();
+        fha->SetXTitle("log10(E-est/GeV)");
+        fha->SetYTitle("Counts");
+
+        // superimpose unfolded distribution
+        // hb->Draw("*HSAME");
+
+        // prior distribution
+        cc->cd(2);
+        hprior->Draw();
+        gPad->SetLogy();
+        hprior->SetXTitle("log10(E-true/GeV)");
+        hprior->SetYTitle("Counts");
+
+        // migration matrix
+        cc->cd(3);
+        fhmig->Draw("box");
+        fhmig->SetXTitle("log10(E-est/GeV)");
+        fhmig->SetYTitle("log10(E-true/GeV)");
+
+        // smoothed migration matrix
+        cc->cd(4);
+        shmig->Draw("box");
+        shmig->SetXTitle("log10(E-est/GeV)");
+        shmig->SetYTitle("log10(E-true/GeV)");
+
+        // chi2 contributions for smoothing
+        cc->cd(5);
+        shmigChi2->Draw("box");
+        shmigChi2->SetXTitle("log10(E-est/GeV)");
+        shmigChi2->SetYTitle("log10(E-true/GeV)");
+
+        // Eigenvalues of matrix M*M(transposed)
+        cc->cd(6);
+        hEigen->Draw();
+        hEigen->SetXTitle("l");
+        hEigen->SetYTitle("Eigen values Lambda_l of M*M(transposed)");
+
+
+       //..............................................
+        // draw the results
+        TString crtitle = bintitle;
+        crtitle +=  "Unfolding results";
+        TCanvas *cr = new TCanvas("results", crtitle, 600, 600);
+        cr->Divide(2, 2);
+
+        // unfolded distribution
+        cr->cd(1);
+        hb->Draw();
+        gPad->SetLogy();
+        hb->SetXTitle("log10(E-true/GeV)");
+        hb->SetYTitle("Counts");
+
+	
+        // covariance matrix of unfolded distribution
+        cr->cd(2);
+        TH1 *hbcov=DrawMatrixClone(fVbcov, "lego");
+        hbcov->SetBins(fNb, hb->GetBinLowEdge(1), hb->GetBinLowEdge(fNb+1),
+                       fNb, hb->GetBinLowEdge(1), hb->GetBinLowEdge(fNb+1));
+
+        hbcov->SetName("hbcov");
+        hbcov->SetTitle("Error matrix of distribution hb");
+        hbcov->SetXTitle("log10(E-true/GeV)");
+        hbcov->SetYTitle("log10(E-true/GeV)");
+       
+	
+        // chi2 contributions
+        cr->cd(3);
+        TH1 *hchi2=DrawMatrixColClone(fChi2);
+        hchi2->SetBins(fNa, fha->GetBinLowEdge(1), fha->GetBinLowEdge(fNa+1));
+
+        hchi2->SetName("Chi2");
+        hchi2->SetTitle("chi2 contributions");
+        hchi2->SetXTitle("log10(E-est/GeV)");
+        hchi2->SetYTitle("Chisquared");
+	
+	
+        // ideal distribution
+        
+        cr->cd(4);
+        fhb0->Draw();
+        gPad->SetLogy();
+        fhb0->SetXTitle("log10(E-true/GeV)");
+        fhb0->SetYTitle("Counts");
+        
+
+        // superimpose unfolded distribution
+        hb->Draw("*Hsame");
+	
+
+        return kTRUE;
+    }
+
+
+    // -----------------------------------------------------------------------
+    //
+    // Interface to MINUIT
+    //
+    //
+    Bool_t CallMinuit(
+                      void (*fcnx)(Int_t &, Double_t *, Double_t &, Double_t *, Int_t),
+                      UInt_t npar, char name[20][100],
+                      Double_t vinit[20], Double_t step[20],
+                      Double_t limlo[20], Double_t limup[20], Int_t fix[20])
+    {
+        //
+        // Be carefull: This is not thread safe
+        //
+        UInt_t maxpar = 100;
+
+        if (npar > maxpar)
+        {
+            cout << "MUnfold::CallMinuit : too many parameters,  npar = " << fNb
+                << ",   maxpar = " << maxpar << endl;
+            return kFALSE;
+        }
+
+        //..............................................
+        // Set the maximum number of parameters
+        TMinuit minuit(maxpar);
+
+
+        //..............................................
+        // Set the print level
+        // -1   no output except SHOW comands
+        //  0   minimum output
+        //  1   normal output (default)
+        //  2   additional ouput giving intermediate results
+        //  3   maximum output, showing progress of minimizations
+        //
+        Int_t printLevel = -1;
+        minuit.SetPrintLevel(printLevel);
+
+        //..............................................       
+        // Printout for warnings
+        //    SET WAR      print warnings
+        //    SET NOW      suppress warnings
+        Int_t errWarn;
+        Double_t tmpwar = 0;
+        minuit.mnexcm("SET NOW", &tmpwar, 0, errWarn);
+
+        //..............................................
+        // Set the address of the minimization function
+        minuit.SetFCN(fcnx);
+
+        //..............................................
+        // Set starting values and step sizes for parameters
+        for (UInt_t i=0; i<npar; i++)
+        {
+            if (minuit.DefineParameter(i, &name[i][0], vinit[i], step[i],
+                                       limlo[i], limup[i]))
+            {
+                cout << "MUnfold::CallMinuit: Error in defining parameter "
+                    << name << endl;
+                return kFALSE;
+            }
+        }
+
+        //..............................................
+        //Int_t NumPars = minuit.GetNumPars();
+        //cout << "MUnfold::CallMinuit :  number of free parameters = "
+        //     << NumPars << endl;
+
+        //..............................................
+        // Minimization
+        minuit.SetObjectFit(this);
+
+        //..............................................
+        // Error definition :
+        //
+        //    for chisquare function :
+        //      up = 1.0   means calculate 1-standard deviation error
+        //         = 4.0   means calculate 2-standard deviation error
+        //
+        //    for log(likelihood) function :
+        //      up = 0.5   means calculate 1-standard deviation error
+        //         = 2.0   means calculate 2-standard deviation error
+        Double_t up = 1.0;
+        minuit.SetErrorDef(up);
+
+
+
+        // Int_t errMigrad;
+        // Double_t tmp = 0;
+        // minuit.mnexcm("MIGRAD", &tmp, 0, errMigrad);
+
+
+        //..............................................
+        // fix a parameter
+        for (UInt_t i=0; i<npar; i++)
+        {
+            if (fix[i] > 0)
+            {
+                Int_t parNo = i;
+                minuit.FixParameter(parNo);
+            }
+        }
+
+        //..............................................
+        // Set maximum number of iterations (default = 500)
+        Int_t maxiter = 100000;
+        minuit.SetMaxIterations(maxiter);
+
+        //..............................................
+        // minimization by the method of Migrad
+        // Int_t errMigrad;
+        // Double_t tmp = 0;
+        // minuit.mnexcm("MIGRAD", &tmp, 0, errMigrad);
+
+        //..............................................       
+        // same minimization as by Migrad
+        // but switches to the SIMPLEX method if MIGRAD fails to converge
+        Int_t errMinimize;
+        Double_t tmp = 0;
+        minuit.mnexcm("MINIMIZE", &tmp, 0, errMinimize);
+
+        //..............................................       
+        // check quality of minimization
+        // istat = 0   covariance matrix not calculated
+        //         1   diagonal approximation only (not accurate)
+        //         2   full matrix, but forced positive-definite
+        //         3   full accurate covariance matrix 
+        //             (indication of normal convergence)
+        Double_t fmin, fedm, errdef;
+        Int_t    npari, nparx, istat;
+        minuit.mnstat(fmin, fedm, errdef, npari, nparx, istat);
+
+        if (errMinimize || istat < 3)
+        {
+            cout << "MUnfold::CallMinuit : Minimization failed" << endl;
+            cout << "       fmin = " << fmin   << ",   fedm = "  << fedm
+                << ",   errdef = "  << errdef << ",   istat = " << istat
+                << endl;
+            return kFALSE;
+        }
+
+        //..............................................
+        // Minos error analysis
+        // minuit.mnmnos();
+
+        //..............................................       
+        // Print current status of minimization
+        // if nkode = 0    only function value
+        //            1    parameter values, errors, limits
+        //            2    values, errors, step sizes, internal values
+        //            3    values, errors, step sizes, 1st derivatives
+        //            4    values, paraboloc errors, MINOS errors
+  
+        //Int_t nkode = 4;
+        //minuit.mnprin(nkode, fmin);
+
+        //..............................................       
+        // call fcn with IFLAG = 3 (final calculation : calculate p(chi2))
+        // iflag = 1   initial calculations only
+        //         2   calculate 1st derivatives and function
+        //         3   calculate function only
+        //         4   calculate function + final calculations
+        const char *command = "CALL";
+        Double_t iflag = 3;
+        Int_t errfcn3;
+        minuit.mnexcm(command, &iflag, 1, errfcn3); 
+
+        return kTRUE;
+    }
+
+    // -----------------------------------------------------------------------
+    //
+    // Return the unfolded distribution
+    //
+    TMatrixD &GetVb() { return fVb; }
+
+    // -----------------------------------------------------------------------
+    //
+    // Return the covariance matrix of the unfolded distribution
+    //
+    TMatrixD &GetVbcov() { return fVbcov; }
+
+    // -----------------------------------------------------------------------
+    //
+    // Return the unfolded distribution + various errors
+    //
+    TMatrixD &GetResult() { return fResult; }
+
+    // -----------------------------------------------------------------------
+    //
+    // Return the chisquared contributions
+    //
+    TMatrixD &GetChi2() { return fChi2; }
+
+    // -----------------------------------------------------------------------
+    //
+    // Return the total chisquared
+    //
+    Double_t &GetChisq() { return fChisq; }
+
+    // -----------------------------------------------------------------------
+    //
+    // Return the number of degrees of freedom
+    //
+    Double_t &GetNdf() { return fNdf; }
+
+    // -----------------------------------------------------------------------
+    //
+    // Return the chisquared probability
+    //
+    Double_t &GetProb() { return fProb; }
+
+    // -----------------------------------------------------------------------
+    //
+    // Return the smoothed migration matrix
+    //
+    TMatrixD &GetMigSmoo() { return fMigSmoo; }
+
+    // -----------------------------------------------------------------------
+    //
+    // Return the error2 of the smoothed migration matrix
+    //
+    TMatrixD &GetMigSmooerr2() { return fMigSmooerr2; }
+
+    // -----------------------------------------------------------------------
+    //
+    // Return the chi2 contributions for the smoothing
+    //
+    TMatrixD &GetMigChi2() { return fMigChi2; }
+};
+// end of definition of class MUnfold
+///////////////////////////////////////////////////
+
+
+// -----------------------------------------------------------------------
+//
+// fcnSmooth     (used by SmoothMigrationMatrix)
+//
+// is called by MINUIT
+// for given values of the parameters it calculates the function 
+//                                               to be minimized
+//
+void fcnSmooth(Int_t &npar, Double_t *gin, Double_t &f, 
+               Double_t *par, Int_t iflag)
+{
+    MUnfold &gUnfold = *(MUnfold*)gMinuit->GetObjectFit();
+
+    Double_t a0 = par[0];
+    Double_t a1 = par[1];
+    Double_t a2 = par[2];
+
+    Double_t b0 = par[3];
+    Double_t b1 = par[4];
+    Double_t b2 = par[5];
+
+    // loop over bins of log10(E-true)
+    Double_t chi2 = 0.0;
+    Int_t npoints = 0;
+    Double_t func[20];
+
+    for (UInt_t j=0; j<gUnfold.fNb; j++)
+    {
+        Double_t yj   = ((double)j) + 0.5;
+        Double_t mean = a0 + a1*yj + a2*yj*yj + yj;
+        Double_t RMS  = b0 + b1*yj + b2*yj*yj;
+
+        if (RMS <= 0.0)
+        {
+            chi2 = 1.e20;
+            break;
+        }
+
+        // loop over bins of log10(E-est)
+
+        //.......................................
+        Double_t function;
+        Double_t sum=0.0;
+        for (UInt_t i=0; i<gUnfold.fNa; i++)
+        {
+            Double_t xlow = (double)i;
+            Double_t xup  = xlow + 1.0;
+            Double_t xl  = (xlow- mean) / RMS;
+            Double_t xu  = (xup - mean) / RMS;
+            function = (TMath::Freq(xu) - TMath::Freq(xl));
+
+            //cout << "i, xl, xu, function = " <<  i <<  ",  "  << xl << ",  "
+            //     << xu  << ",  " << function << endl;
+
+            if (function < 1.e-10)
+                function = 0.0;
+
+            func[i] = function;
+            sum += function;
+        }
+
+        //      cout << "mean, RMS = "  << mean << ",  " << RMS
+        //     << ",   j , sum of function = " << j << ",  " << sum << endl;
+
+        //.......................................
+
+        for (UInt_t i=0; i<gUnfold.fNa; i++)
+        {
+            if (sum != 0.0)
+                func[i] /= sum;
+
+            gUnfold.fMigSmoo(i,j) = func[i];
+            gUnfold.fMigChi2(i,j) = 0.0;
+
+            // if relative error is greater than 30 % ignore the point
+
+            if (gUnfold.fMigOrig(i,j)     != 0 &&
+                gUnfold.fMigOrigerr2(i,j) != 0 &&
+                func[i] != 0  )
+            {
+                if (gUnfold.fMigOrigerr2(i,j)/
+                    (gUnfold.fMigOrig(i,j)*gUnfold.fMigOrig(i,j)) <= 0.09)
+                {
+                    gUnfold.fMigChi2(i,j) =   ( gUnfold.fMigOrig(i,j) - func[i] )
+                        * ( gUnfold.fMigOrig(i,j) - func[i] )
+                        /   gUnfold.fMigOrigerr2(i,j);
+                    chi2 += gUnfold.fMigChi2(i,j);
+                    npoints += 1;
+                }
+            }
+        }
+        //.......................................
+
+    }
+    f = chi2;
+
+    //cout << "fcnSmooth : f = " << f << endl;
+
+    //--------------------------------------------------------------------
+    // final calculations
+    if (iflag == 3)
+    {
+        Int_t     NDF = npoints - npar;
+        Double_t prob = TMath::Prob(chi2, NDF);
+
+        cout << "fcnSmooth : npoints, chi2, NDF, prob = " << npoints << ",  ";
+        cout << chi2 << ",  " << NDF << ",  " << prob << endl;
+        cout << "=======================================" << endl;
+    }
+}
+
+// -----------------------------------------------------------------------
+//
+// fcnTikhonov2     (used by Tikhonov2)
+//
+// is called by MINUIT
+// for given values of the parameters it calculates the function F
+// the free parameters are the first (fNb-1) elements
+//                     of the normalized unfolded distribution
+//
+void fcnTikhonov2(Int_t &npar, Double_t *gin, Double_t &f,
+                  Double_t *par, Int_t iflag)
+{
+    MUnfold &gUnfold = *(MUnfold*)gMinuit->GetObjectFit();
+
+    // (npar+1) is the number of bins of the unfolded distribuition (fNb)
+    //  npar    is the number of free parameters                    (fNb-1)
+
+    UInt_t npar1 = npar + 1;
+
+    UInt_t fNa = gUnfold.fNa;
+    UInt_t fNb = gUnfold.fNb;
+    if (npar1 != fNb)
+    {
+        cout << "fcnTikhonov2 : inconsistency in number of parameters; npar, fNb = ";
+        cout << npar << ",  " << fNb << endl;
+        //return;
+    }
+    npar1 = fNb;
+
+    TMatrixD p(npar1, 1);
+    TMatrixD &fVb = gUnfold.fVb;
+
+    // p is the normalized unfolded distribution
+    // sum(p(i,0)) from i=0 to npar is equal to 1
+    Double_t sum = 0.0;
+    for (Int_t i=0; i<npar; i++)
+    {
+        p(i,0) = par[i];
+        sum += par[i];
+    }
+    p(npar,0) = 1.0 - sum;
+
+
+    // all p(i,0) have to be greater than zero
+    for (UInt_t i=0; i<npar1; i++)
+        if (p(i,0) <= 0.0)
+        {
+            f = 1.e20;
+            return;
+        }
+
+    //.......................
+    // take least squares result for the normaliztion
+    TMatrixD alpha(gUnfold.fMigrat, TMatrixD::kMult, p);
+
+    //TMatrixD v4   (gUnfold.fVa, TMatrixD::kTransposeMult,
+    //                                 gUnfold.fVacovInv);
+    //TMatrixD norma(v4,  TMatrixD::kMult, gUnfold.fVa);
+
+    TMatrixD v5   (alpha, TMatrixD::kTransposeMult, gUnfold.fVacovInv);
+    TMatrixD normb(v5,    TMatrixD::kMult, alpha);
+
+    TMatrixD normc(v5,    TMatrixD::kMult, gUnfold.fVa);
+
+    Double_t norm  = normc(0,0)/normb(0,0);
+
+    //.......................
+
+    // b is the unnormalized unfolded distribution
+    // sum(b(i,0)) from i=0 to npar is equal to norm
+    //                       (the total number of events)
+    for (UInt_t i=0; i<npar1; i++)
+        fVb(i,0) = p(i,0) * norm;
+
+    TMatrixD Gb(gUnfold.fMigrat, TMatrixD::kMult, fVb);
+    TMatrixD v3(fNa, 1);
+    v3 = gUnfold.fVa;
+    v3 -= Gb;
+
+    TMatrixD v1(1,fNa);
+    for (UInt_t i=0; i<fNa; i++)
+    {
+        v1(0,i) = 0;
+        for (UInt_t j=0; j<fNa; j++)
+            v1(0,i) += v3(j,0) * gUnfold.fVacovInv(j,i) ;
+    }
+
+    for (UInt_t i = 0; i<fNa; i++)
+        gUnfold.Chi2(i,0) = v1(0,i) * v3(i,0);
+
+    gUnfold.Chisq = GetMatrixSumCol(gUnfold.Chi2,0);
+
+    //-----------------------------------------------------
+    // calculate 2nd derivative squared
+    // regularization term (second derivative squared)
+    gUnfold.SecDeriv = 0;
+    for (UInt_t j=1; j<(fNb-1); j++)
+     {
+         const Double_t temp =
+             + 2.0*(fVb(j+1,0)-fVb(j,0)) / (fVb(j+1,0)+fVb(j,0))
+             - 2.0*(fVb(j,0)-fVb(j-1,0)) / (fVb(j,0)+fVb(j-1,0));
+
+         gUnfold.SecDeriv += temp*temp;
+     }
+
+    gUnfold.ZerDeriv = 0;
+    for (UInt_t j=0; j<fNb; j++)
+        gUnfold.ZerDeriv += fVb(j,0) * fVb(j,0);
+
+    f = gUnfold.Chisq/2 * gUnfold.fW + gUnfold.SecDeriv;
+
+    //cout << "F=" << f      << " \tSecDeriv=" << gUnfold.SecDeriv
+    //     << " \tchi2="
+    //	  << gUnfold.Chisq << " \tfW=" << gUnfold.fW << endl;
+
+    //--------------------------------------------------------------------
+    // final calculations
+    if (iflag == 3)
+    {
+        //..............................................
+        // calculate external error matrix of the fitted parameters 'val'
+        // extend it with the covariances for y=1-sum(val)
+        Double_t emat[20][20];
+        Int_t    ndim = 20;
+        gMinuit->mnemat(&emat[0][0], ndim);
+
+        Double_t covv = 0;
+        for (UInt_t i=0; i<(gUnfold.fNb-1); i++)
+        {
+            Double_t cov = 0;
+            for (UInt_t k=0; k<(gUnfold.fNb-1); k++)
+                cov += emat[i][k];
+
+            emat[i][gUnfold.fNb-1] = -cov;
+            emat[gUnfold.fNb-1][i] = -cov;
+
+            covv += cov;
+        }
+        emat[gUnfold.fNb-1][gUnfold.fNb-1] = covv;
+
+        for (UInt_t i=0; i<gUnfold.fNb; i++)
+            for (UInt_t k=0; k<gUnfold.fNb; k++)
+                gUnfold.fVbcov(i,k) = emat[i][k] *norm*norm;
+
+        //-----------------------------------------------------
+        //..............................................
+        // put unfolded distribution into fResult
+        //     fResult(i,0)   value in bin i
+        //     fResult(i,1)   error of value in bin i
+
+        gUnfold.fResult.ResizeTo(gUnfold.fNb, 5);
+
+        Double_t sum = 0;
+        for (UInt_t i=0; i<(gUnfold.fNb-1); i++)
+        {
+            Double_t val;
+            Double_t err;
+            if (!gMinuit->GetParameter(i, val, err))
+            {
+                cout << "Error getting parameter #" << i << endl;
+                return;
+            }
+
+            Double_t eplus;
+            Double_t eminus;
+            Double_t eparab;
+            Double_t gcc;
+            gMinuit->mnerrs(i, eplus, eminus, eparab, gcc);
+
+            gUnfold.fVb(i, 0)     = val    * norm;
+
+            gUnfold.fResult(i, 0) = val    * norm;
+            gUnfold.fResult(i, 1) = eparab * norm;
+            gUnfold.fResult(i, 2) = eplus  * norm;
+            gUnfold.fResult(i, 3) = eminus * norm;
+            gUnfold.fResult(i, 4) = gcc;
+            sum += val;
+        }
+        gUnfold.fVb(gUnfold.fNb-1, 0)     = (1.0-sum) * norm;
+
+        gUnfold.fResult(gUnfold.fNb-1, 0) = (1.0-sum) * norm;
+        gUnfold.fResult(gUnfold.fNb-1, 1) =
+            sqrt(gUnfold.fVbcov(gUnfold.fNb-1,gUnfold.fNb-1));
+        gUnfold.fResult(gUnfold.fNb-1, 2) = 0;
+        gUnfold.fResult(gUnfold.fNb-1, 3) = 0;
+        gUnfold.fResult(gUnfold.fNb-1, 4) = 1;
+        //..............................................
+
+        //-----------------------------------------------------
+        // calculate 0th derivative squared
+        gUnfold.ZerDeriv = 0;
+        for (UInt_t j=0; j<fNb; j++)
+            gUnfold.ZerDeriv += fVb(j,0) * fVb(j,0);
+
+        //-----------------------------------------------------
+        // calculate the entropy
+
+        gUnfold.Entropy = 0;
+        for (UInt_t j=0; j<gUnfold.fNb; j++)
+            if (p(j,0) > 0)
+                gUnfold.Entropy += p(j,0) * log( p(j,0) );
+
+
+        //-----------------------------------------------------
+        // calculate SpurSigma
+        gUnfold.SpurSigma = 0.0;
+        for (UInt_t m=0; m<fNb; m++)
+            gUnfold.SpurSigma += gUnfold.fVbcov(m,m);
+        // cout << "SpurSigma =" << SpurSigma << endl;
+
+        //-----------------------------------------------------
+        gUnfold.SpurAR  = 0;
+        gUnfold.DiffAR2 = 0;
+
+        //-----------------------------------------------------
+        gUnfold.fNdf   = gUnfold.fNa;
+        gUnfold.fChisq   = gUnfold.Chisq;
+
+        for (UInt_t i=0; i<fNa; i++)
+	{
+          gUnfold.fChi2(i,0) = gUnfold.Chi2(i,0);
+	}
+
+
+        UInt_t iNdf = (UInt_t) (gUnfold.fNdf+0.5);
+
+        //cout << "fcnTikhonov2 : fW, chisq (from fcnF) = "
+        //     << gUnfold.fW << ",  " << gUnfold.fChisq << endl;
+
+        gUnfold.fProb = iNdf>0 ? TMath::Prob(gUnfold.fChisq, iNdf) : 0;
+    }
+}
+
+
+// ======================================================
+//
+// SteerUnfold
+//
+void SteerUnfold(TString bintitle,
+                 TH1D &ha,     TH2D &hacov, TH2D &hmig,
+                 TH2D &hmigor, TH1D &hb0,   TH1D *hpr,
+                 TH1D &hb)
+{
+    // ha      is the distribution to be unfolded
+    // hacov   is the covariance matrix of the distribution ha
+    // hmig    is the migration matrix;
+    //         it is used in the unfolding unless it is overwritten
+    //         by SmoothMigrationMatrix by the smoothed migration matrix
+    // hmigor  is the migration matrix to be smoothed;
+    //         the smoothed migration matrix will be used in the unfolding
+    // hpr     the prior distribution
+    //         it is only used if SetPriorInput(*hpr) is called   
+    // hb      unfolded distribution
+
+    //..............................................       
+    // create an MUnfold object;
+    // fill histograms into vectors and matrices
+
+    MUnfold unfold(ha, hacov, hmig);
+    unfold.bintitle = bintitle;
+
+    //..............................................       
+    // smooth the migration matrix;
+    //        the smoothed migration matrix will be used in the unfolding
+    //        hmig is the original (unsmoothed) migration matrix
+
+    unfold.SmoothMigrationMatrix(hmigor);
+
+    //..............................................       
+    // define prior distribution (has always to be defined) 
+    // the alternatives are  :
+
+    // 1  SetPriorConstant() :   isotropic distribution
+    // 2  SetPriorPower(gamma) : dN/dE = E^{-gamma}
+    // 3  SetPriorInput(*hpr):   the distribution *hpr is used 
+    // 4  SetPriorRebin(*ha) :   use rebinned histogram ha 
+
+    UInt_t flagprior = 4;
+    cout << "SteerUnfold : flagprior = " << flagprior << endl;
+    cout << "==========================="<< endl;
+
+    Bool_t errorprior=kTRUE;
+    switch (flagprior)
+    {
+    case 1:
+        unfold.SetPriorConstant();
+        break;
+    case 2:
+        errorprior = unfold.SetPriorPower(1.5);
+        break;
+    case 3:
+        if (!hpr)
+        {
+            cout << "Error: No hpr!" << endl;
+            return;
+        }
+        errorprior = unfold.SetPriorInput(*hpr);
+        break;
+    case 4:
+        errorprior = unfold.SetPriorRebin(ha);
+        break;
+    }
+    if (!errorprior)
+    {
+        cout << "MUnfold::SetPrior... : failed.  flagprior = " ;
+        cout << flagprior << endl;
+        return;
+    }
+
+    //..............................................       
+    // calculate the matrix G = M * M(transposed)
+    //           M being the migration matrix
+
+    unfold.CalculateG();
+
+    //..............................................       
+    // call steering routine for the actual unfolding;
+    // the alternatives are :
+
+    // 1  Schmelling : minimize the function Z by Gauss-Newton iteration;
+    //                 the parameters to be fitted are gamma(i) = lambda(i)/w;
+
+    // 2  Tikhonov2 :  regularization term is sum of (2nd deriv.)**2 ;
+    //                 minimization by using MINUIT;
+    //                 the parameters to be fitted are
+    //                 the bin contents of the unfolded distribution
+
+    // 3  Bertero:     minimization by iteration
+    //                 
+
+    UInt_t flagunfold = 1;
+    cout << "SteerUnfold : flagunfold = "  << flagunfold << endl;
+    cout << "============================" << endl;
+
+
+
+    switch (flagunfold)
+    {
+    case 1: // Schmelling
+        cout << "" << endl;
+        cout << "Unfolding algorithm : Schmelling" << endl;
+        cout << "================================" << endl;
+        if (!unfold.Schmelling(hb0))
+            cout << "MUnfold::Schmelling : failed." << endl;
+        break;
+
+    case 2: // Tikhonov2
+        cout << "" << endl;
+        cout << "Unfolding algorithm :   Tikhonov" << endl;
+        cout << "================================" << endl;
+        if (!unfold.Tikhonov2(hb0))
+            cout << "MUnfold::Tikhonov2 : failed." << endl;
+        break;
+
+    case 3: // Bertero
+        cout << "" << endl;
+        cout << "Unfolding algorithm :    Bertero" << endl;
+        cout << "================================" << endl;
+        if (!unfold.Bertero(hb0))
+            cout << "MUnfold::Bertero : failed." << endl;
+        break;
+    }    
+
+
+    //..............................................       
+    // Print fResult
+    unfold.PrintResults();
+
+
+    //..............................................       
+    // Draw the plots
+    unfold.DrawPlots();
+
+    //..............................................       
+    // get unfolded distribution
+    TMatrixD &Vb    = unfold.GetVb();
+    TMatrixD &Vbcov = unfold.GetVbcov();
+
+    UInt_t fNb = unfold.fNb;
+
+    for (UInt_t a=0; a<fNb; a++)
+    {
+      hb.SetBinContent(a+1, Vb(a,0));
+      hb.SetBinError(a+1, sqrt(Vbcov(a, a)) );
+    }
+
+}
+
+//__________________________________________________________________________
+////////////////////////////////////////////////////////////////////////////
+//                                                                        //
+// doUnfolding    (to be called in the analysis)                          //
+//                                                                        //
+// arguments :                                                            //
+//                                                                        //
+//   INPUT                                                                //
+//      TH2D &tobeunfolded : no.of excess events and its error            //
+//                           vs. (E-est, Theta)                           //
+//      TH3D &migration    : migration matrix (E-est, E_true, Theta)      //
+//                                                                        //
+//   OUITPUT                                                              //
+//      TH2D &unfolded     : no.of excess events and its error            //
+//                           vs. (E-true, Theta)                          //
+//                                                                        //
+// calls SteerUnfold to do the unfolding                                  //
+//                                                                        //
+// The "Theta" axis is only used to loop over the bins of theta           //
+// and to do the unfolding for each bin of theta. Instead of theta        //
+// any other variable (or a dummy variable) may be used.                  //
+//                                                                        //
+//                                                                        //
+////////////////////////////////////////////////////////////////////////////
+
+void doUnfolding(TH2D &tobeunfolded, TH3D &migration, TH2D &unfolded)
+{
+  TAxis &taxis  = *tobeunfolded.GetYaxis();
+  Int_t numybins = taxis.GetNbins();
+
+  for (Int_t m=1; m<=numybins; m++)
+  {
+    TString bintitle = "Bin ";
+    bintitle += m;
+    bintitle += ": ";
+
+    // -----------------------------------------
+    // ha : distribution to be unfolded
+
+    TH1D &ha = *tobeunfolded.ProjectionX("", m, m, "e");
+    TString title = bintitle;
+    title += "E-est distr. to be unfolded";
+    ha.SetNameTitle("ha", title);
+    TAxis &aaxis = *ha.GetXaxis();
+    Int_t na = aaxis.GetNbins();
+    Double_t alow = aaxis.GetBinLowEdge(1);
+    Double_t aup  = aaxis.GetBinLowEdge(na+1);
+
+    PrintTH1Content(ha);
+    PrintTH1Error(ha);
+
+    // -----------------------------------------
+    // covariance matrix of the distribution ha
+
+    title = bintitle;
+    title +=  "Error matrix of distribution ha";
+    TH2D hacov("hacov", title, na, alow, aup, na, alow, aup);
+    //MH::SetBinning(&hacov, &aaxis, &aaxis); 
+
+    Double_t errmin = 3.0;
+    for (Int_t i=1; i<=na; i++)
+    {
+      for (Int_t j=1; j<=na; j++)
+      {
+        hacov.SetBinContent(i, j, 0.0);
+      }
+      const Double_t content = ha.GetBinContent(i);
+      const Double_t error2  = (ha.GetBinError(i))*(ha.GetBinError(i));
+      if (content <= errmin  &&  error2 < errmin) 
+        hacov.SetBinContent(i, i, errmin);
+      else
+        hacov.SetBinContent(i, i, error2);
+    }
+
+    //PrintTH2Content(hacov);
+    
+
+    // -----------------------------------------
+    // migration matrix :
+    //           x corresponds to measured quantity
+    //           y corresponds to true quantity
+    TH2D &hmig = *(TH2D*)migration.Project3D("yxe");
+    title = bintitle;
+    title += "Migration Matrix";
+    hmig.SetNameTitle("Migrat", title);
+
+    TAxis &aaxismig = *hmig.GetXaxis();
+    Int_t namig = aaxismig.GetNbins();
+
+    if (na != namig)
+    {
+      cout << "doUnfolding : binnings are incompatible; na, namig = "
+           << na << ",  " << namig << endl;
+      return;
+    }
+
+    TAxis &baxismig = *hmig.GetYaxis();
+    Int_t nbmig = baxismig.GetNbins();
+    Double_t blow = baxismig.GetBinLowEdge(1);
+    Double_t bup  = baxismig.GetBinLowEdge(nbmig+1);
+
+    PrintTH2Content(hmig);
+    //PrintTH2Error(hmig);
+
+
+    // -----------------------------------------
+    // dummy ideal distribution
+
+    Int_t nb = nbmig;
+
+    title = bintitle;
+    title += "Dummy Ideal distribution";
+    TH1D hb0("dummyhb0", title, nb, blow, bup);;
+    //MH::SetBinning(&hb0, &baxismig); 
+    hb0.Sumw2();
+
+    for (Int_t k=1; k<=nb; k++)
+    {
+        hb0.SetBinContent(k, 1.0/nb);
+        hb0.SetBinError  (k, 0.1/nb);
+    }
+
+    //PrintTH1Content(hb0);
+
+    // -----------------------------------------
+    // here the prior distribution can be defined for the call
+    // to SetPriorInput(*hpr)
+
+    title = bintitle;
+    title += "Dummy Prior distribution";
+    TH1D hpr("hpr", title, nb, blow, bup);
+    //MH::SetBinning(&hpr, &baxismig); 
+    
+    for (Int_t k=1; k<=nb; k++)
+        hpr.SetBinContent(k, 1.0/nb);
+
+    //PrintTH1Content(hpr);
+
+
+    // -----------------------------------------
+    // unfolded distribution
+
+
+    title = bintitle;
+    title += "Unfolded distribution";
+    TH1D hb("hb", title, nb, blow, bup);
+    //MH::SetBinning(&hb, &baxismig); 
+
+    // -----------------------------------------
+    SteerUnfold(bintitle, ha, hacov, hmig, hmig, hb0, &hpr, hb);
+
+    for (Int_t k=1; k<=nb; k++)
+    {
+      Double_t content = hb.GetBinContent(k);
+      Double_t error   = hb.GetBinError(k);
+
+      unfolded.SetBinContent(k, m, content);
+      unfolded.SetBinError(k, m, error);
+    }    
+
+    delete &ha;
+    delete &hmig;
+  }
+
+}
+//========================================================================//
+
+
+////////////////////////////////////////////////////////////////////////////
+//                                                                        //
+// Main program   (for testing purposes)                                  //
+//                                                                        //
+//                defines the ideal distribution          (hb0)           //
+//                defines the migration matrix            (hMigrat)       //
+//                defines the distribution to be unfolded (hVa)           //
+//                                                                        //
+//                calls doUnfolding                                       //
+//                      to do the unfolding                               //
+//                                                                        //
+////////////////////////////////////////////////////////////////////////////
+void fluxunfold()
+{
+  // -----------------------------------------
+  // migration matrix :
+  //           x corresponds to measured quantity
+  //           y corresponds to true quantity
+
+    const Int_t  na   =   13;
+    //const Int_t  na   =   18;
+    const Axis_t alow = 0.25;
+    const Axis_t aup  = 3.50;
+
+    const Int_t  nb   =   11;
+    //const Int_t  nb   =   22;
+    const Axis_t blow = 0.50;
+    const Axis_t bup  = 3.25;
+
+    const Int_t  nc   =     1;
+    const Axis_t clow =   0.0;
+    const Axis_t cup  =   1.0;
+
+    Int_t m = 1;
+
+    TH3D migration("migration", "Migration Matrix", 
+                   na, alow, aup, nb, blow, bup, nc, clow, cup);
+    migration.Sumw2();
+
+    // parametrize migration matrix as
+    //     <log10(Eest)>      = a0 + a1*log10(Etrue) + a2*log10(Etrue)**2 
+    //                             + log10(Etrue) 
+    //     RMS( log10(Eest) ) = b0 + b1*log10(Etrue) + b2*log10(Etrue)**2
+    Double_t a0 = 0.0;
+    Double_t a1 = 0.0;
+    Double_t a2 = 0.0;
+
+    Double_t b0 = 0.26;
+    Double_t b1 =-0.054;
+    Double_t b2 = 0.0;
+
+    TF1 f2("f2", "gaus(0)", alow, aup);
+    f2.SetParName(0, "ampl");
+    f2.SetParName(1, "mean");
+    f2.SetParName(2, "sigma");
+
+    // loop over log10(Etrue) bins
+    TAxis &yaxis = *migration.GetYaxis();
+    for (Int_t j=1; j<=nb; j++)
+    {
+        Double_t yvalue = yaxis.GetBinCenter(j);
+
+        const Double_t mean  = a0 + a1*yvalue + a2*yvalue*yvalue + yvalue;
+        const Double_t sigma = b0 + b1*yvalue + b2*yvalue*yvalue;
+        const Double_t ampl  = 1./ ( sigma*TMath::Sqrt(2.0*TMath::Pi()));
+
+        // gaus(0) is a substitute for [0]*exp( -0.5*( (x-[1])/[2] )**2 )
+        f2.SetParameter(0, ampl);
+        f2.SetParameter(1, mean);
+        f2.SetParameter(2, sigma);
+
+        // fill temporary 1-dim histogram with the function
+        // fill the histogram using
+        //    - either FillRandom
+        //    - or using Freq
+        TH1D htemp("temp", "temp", na, alow, aup);
+        htemp.Sumw2();
+
+        for (Int_t k=0; k<1000000; k++)
+            htemp.Fill(f2.GetRandom());
+
+        // copy it into the migration matrix
+        Double_t sum = 0;
+        for (Int_t i=1; i<=na; i++)
+        {
+            const Stat_t content = htemp.GetBinContent(i);
+            migration.SetBinContent(i, j, m, content);
+            sum += content;
+        }
+
+        // normalize migration matrix
+        if (sum==0)
+            continue;
+
+        for (Int_t i=1; i<=na; i++)
+        {
+            const Stat_t content = migration.GetBinContent(i,j,m);
+            migration.SetBinContent(i,j,m,       content/sum);
+            migration.SetBinError  (i,j,m, sqrt(content)/sum);
+        }
+    }
+
+    //PrintTH3Content(migration);
+    //PrintTH3Error(migration);
+
+    // -----------------------------------------
+    // ideal distribution
+
+    TH1D hb0("hb0", "Ideal distribution", nb, blow, bup);
+    hb0.Sumw2();
+
+    // fill histogram with random numbers according to 
+    // an exponential function dN/dE = E^{-gamma}
+    //    or with y = log10(E), E = 10^y :             
+    //                          dN/dy = ln10 * 10^{y*(1-gamma)}     
+    TF1 f1("f1", "pow(10.0, x*(1.0-[0]))", blow, bup);
+    f1.SetParName(0,"gamma");
+    f1.SetParameter(0, 2.7);
+
+    // ntimes is the number of entries
+    for (Int_t k=0; k<10000; k++)
+        hb0.Fill(f1.GetRandom());
+
+    // introduce energy threshold at 50 GeV
+
+    const Double_t  lgEth = 1.70;
+    const Double_t dlgEth = 0.09;
+
+    for (Int_t j=1; j<=nb; j++)
+    {
+        const Double_t lgE = hb0.GetBinCenter(j);
+        const Double_t c   = hb0.GetBinContent(j);
+        const Double_t dc  = hb0.GetBinError(j);
+        const Double_t f   = 1.0 / (1.0 + exp( -(lgE-lgEth)/dlgEth ));
+
+        hb0.SetBinContent(j, f* c);
+        hb0.SetBinError  (j, f*dc);
+    }
+
+    //PrintTH1Content(hb0);
+
+    // -----------------------------------------
+    // generate distribution to be unfolded (ha)
+    // by smearing the ideal distribution  (hb0)
+    //
+    TH2D tobeunfolded("tobeunfolded", "Distribution to be unfolded", 
+                      na, alow, aup, nc, clow, cup);
+    tobeunfolded.Sumw2();
+
+    for (Int_t i=1; i<=na; i++)
+    {
+        Double_t cont = 0;
+        for (Int_t j=1; j<=nb; j++)
+            cont += migration.GetBinContent(i, j, m) * hb0.GetBinContent(j);
+
+        tobeunfolded.SetBinContent(i, m, cont);
+        tobeunfolded.SetBinError(i, m, sqrt(cont));
+    }
+
+    //PrintTH2Content(tobeunfolded);
+    //PrintTH2Error(tobeunfolded);
+
+    // -----------------------------------------
+    // unfolded distribution
+
+    TH2D unfolded("unfolded", "Unfolded distribution", 
+                  nb, blow, bup, nc, clow, cup);
+    unfolded.Sumw2();
+
+    // -----------------------------------------
+    doUnfolding(tobeunfolded, migration, unfolded);
+
+}
+//========================================================================//
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/macros/mccalibrate.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/mccalibrate.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/mccalibrate.C	(revision 9661)
@@ -0,0 +1,209 @@
+/* ======================================================================== *\
+   !
+   ! *
+   ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+   ! * Software. It is distributed to you in the hope that it can be a useful
+   ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+   ! * It is distributed WITHOUT ANY WARRANTY.
+   ! *
+   ! * Permission to use, copy, modify and distribute this software and its
+   ! * documentation for any purpose is hereby granted without fee,
+   ! * provided that the above copyright notice appear in all copies and
+   ! * that both that copyright notice and this permission notice appear
+   ! * in supporting documentation. It is provided "as is" without express
+   ! * or implied warranty.
+   ! *
+   !
+   !
+   !   Author(s): Abelardo Moralejo 1/2004 <mailto:moralejo@pd.infn.it>
+   !              Thomas Bretz  5/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+   !
+   !   Copyright: MAGIC Software Development, 2000-2004
+   !
+   !
+   \* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MMCALIBRATE - Calibration of MC data
+//
+//  This macro converts raw MC data into calibrated data (photons per pixel) 
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MImgCleanStd.h"
+
+void mccalibrate()
+{
+  //
+  // This is a demonstration program which reads in MC camera files
+  // and produces and output with calibrated events (signal in photons
+  // for all pixels, in MCerPhotEvt containers).
+  //
+
+  // ------------- user change -----------------
+  TString* CalibrationFilename;
+  CalibrationFilename = new TString("../../gammas_nonoise/Gamma_zbin0_0*.root");  // File to be used for the calibration (must be a camera file without added noise)
+
+  Char_t* AnalysisFilename = "Proton_zbin0_0*.root";  // File to be analyzed
+
+  Char_t* OutFilename      = "calibrated_data.root";  // Output file name
+
+
+  MExtractSignal    sigextract;  
+  // (other extraction methods can be used)
+
+  sigextract.SetSaturationLimit(240);
+  // Defines when to switch to low gain
+
+  // Define FADC slices to be integrated in high and low gain:
+  sigextract.SetRange(5, 10, 5, 10);
+
+  // ---------------------------------------------------------------------
+  //
+  // Create a empty Parameter List and an empty Task List
+  // The tasklist is identified in the eventloop by its name
+  //
+  MParList  plist;
+
+  MTaskList tlist;
+
+  plist.AddToList(&tlist);
+
+  MSrcPosCam src;
+  src.SetReadyToSave();
+  plist.AddToList(&src);
+
+  MBadPixelsCam badpix;
+  plist.AddToList(&badpix);  // Not used for now.
+ 
+  //
+  // Now setup the tasks and tasklist:
+  // ---------------------------------
+  //
+  MReadMarsFile read("Events");
+
+  if (CalibrationFilename)
+    read.AddFile(CalibrationFilename->Data());
+
+  read.DisableAutoScheme();
+
+  MGeomApply geom; 
+  // Reads in geometry from MC file and sets the right sizes for
+  // several parameter containers.
+
+  MMcPedestalCopy   pcopy; 
+  // Copies pedestal data from the MC file run fadc header to the 
+  // MPedestalCam container.
+
+  MPointingPosCalc pointcalc;
+  // Creates MPointingPos object and fill it with the telescope orientation
+  // information taken from MMcEvt.
+
+  MMcCalibrationUpdate  mccalibupdate;
+
+  MCalibrate calib; 
+  // MCalibrate transforms signals from ADC counts into photons. In the first
+  // loop it applies a "dummy" calibration supplied by MMcCalibrationUpdate, just 
+  // to equalize inner and outer pixels. At the end of the first loop, in the
+  // PostProcess of MMcCalibrationCalc (see below) the true calibration constants
+  // are calculated.
+
+  calib.SetCalibrationMode(MCalibrate::kFfactor);
+
+  MImgCleanStd clean;
+  //
+  // Applies tail cuts to image. Since the calibration is performed on 
+  // noiseless camera files, the precise values of the cleaning levels 
+  // are unimportant (in any case, only pixels without any C-photon will
+  // be rejected).
+  //
+
+  MHillasCalc hcalc; // Calculates Hillas parameters not dependent on source position.
+
+  MMcCalibrationCalc mccalibcalc; 
+  // Calculates calibration constants to convert from ADC counts to photons.
+  
+
+  tlist.AddToList(&read);
+  tlist.AddToList(&geom);
+  tlist.AddToList(&pcopy);
+  tlist.AddToList(&pointcalc);
+  tlist.AddToList(&sigextract);
+  tlist.AddToList(&mccalibupdate);
+  tlist.AddToList(&calib);
+  tlist.AddToList(&clean);
+  tlist.AddToList(&hcalc);
+
+  tlist.AddToList(&mccalibcalc);
+
+  //
+  // Open output file:
+  //
+  MWriteRootFile write(OutFilename); // Writes output
+  write.AddContainer("MGeomCam",            "RunHeaders");
+  write.AddContainer("MMcConfigRunHeader",  "RunHeaders");
+  write.AddContainer("MMcCorsikaRunHeader", "RunHeaders");
+  write.AddContainer("MMcFadcHeader",       "RunHeaders");
+  write.AddContainer("MMcRunHeader",        "RunHeaders");
+  write.AddContainer("MMcTrigHeader",       "RunHeaders");
+  write.AddContainer("MRawRunHeader",       "RunHeaders");
+  write.AddContainer("MSrcPosCam",          "RunHeaders");
+
+
+  write.AddContainer("MMcEvt",        "Events");
+  write.AddContainer("MMcTrig",       "Events");
+  write.AddContainer("MPointingPos",  "Events");
+  write.AddContainer("MRawEvtHeader", "Events");
+  write.AddContainer("MCerPhotEvt",   "Events");
+  write.AddContainer("MPedPhotCam",   "Events");
+
+  //
+  // First loop: Calibration loop
+  //
+
+  MProgressBar bar;
+  bar.SetWindowName("Calibrating...");
+
+  MEvtLoop evtloop;
+  evtloop.SetProgressBar(&bar);
+  evtloop.SetParList(&plist);
+
+  if (CalibrationFilename)
+    {
+      if (!evtloop.Eventloop())
+	return;
+      mccalibcalc->GetHistADC2PhotEl()->Write();
+      mccalibcalc->GetHistPhot2PhotEl()->Write();
+      // Writes out the histograms used for calibration.
+    }
+
+  //
+  // Second loop: apply calibration factors to MC events in the 
+  // file to be anlyzed:
+  //
+
+  //
+  // Change the read task by another one which reads the file we want to analyze:
+  //
+
+  MReadMarsFile read2("Events");
+  read2.AddFile(AnalysisFilename);
+  read2.DisableAutoScheme();
+  tlist.AddToListBefore(&read2, &read, "All");
+  tlist.RemoveFromList(&read);
+
+  bar.SetWindowName("Writing...");
+
+  tlist.RemoveFromList(&clean);
+  tlist.RemoveFromList(&hcalc);
+  tlist.RemoveFromList(&mccalibcalc);
+
+  tlist.AddToList(&write);            // Add task to write output.
+
+  if (!evtloop.Eventloop())
+    return;
+
+
+  tlist.PrintStatistics();
+}
Index: /tags/Mars_V0-8-5/Mars/macros/mergecamera.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/mergecamera.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/mergecamera.C	(revision 9661)
@@ -0,0 +1,60 @@
+//
+// A. Moralejo, March 2003
+// This macro merges several MC camera files into one. The output files
+// are useful to run Mars over larger samples of triggered events than 
+// those contained in a single file.
+//
+
+void mergecamera(Char_t *in="Proton*root", Char_t *out="all.root")
+{
+  cout << endl
+       << "WARNING: this macro merges camera output files, but the" << endl
+       << "Run headers of the resulting file are those of the first" <<endl
+       << "merged file, and so do not represent the whole of the" << endl
+       << "merged events. Be careful not to mix files with different" << endl
+       << "parameters (primary, theta...)." << endl << endl;
+
+  //
+  // Open output file:
+  //
+  TFile* f = new TFile(out,"recreate");
+
+  //
+  // First the Events tree:
+  //
+  MMcEvt* mmcevt = new MMcEvt();;
+  MMcTrig* mmctrig = new MMcTrig();
+  MRawEvtHeader* mrawhead = new MRawEvtHeader();
+  MRawEvtData* mrawdata = new MRawEvtData();
+
+  TChain c("Events");
+  c.SetBranchAddress("MMcEvt",&mmcevt);
+  c.SetBranchAddress("MMcTrig",&mmctrig);
+  c.SetBranchAddress("MRawEvtHeader",&mrawhead);
+  c.SetBranchAddress("MRawEvtData",&mrawdata);
+  c.Add(in);
+  c.Merge(f,1000);
+
+  //
+  // Now the RunHeaders tree:
+  //
+  MMcConfigRunHeader* mcconfig = new MMcConfigRunHeader();
+  MMcCorsikaRunHeader* mccorsi = new MMcCorsikaRunHeader();
+  MMcFadcHeader* mcfadc = new MMcFadcHeader();
+  MMcRunHeader* mcrunhead = new MMcRunHeader();
+  MMcTrigHeader* mctrighead = new MMcTrigHeader();
+  MRawRunHeader* mrawrunhead = new MRawRunHeader();
+  TChain d("RunHeaders");
+  d.SetBranchAddress("MMcConfigRunHeader",&mcconfig);
+  d.SetBranchAddress("MMcCorsikaRunHeader",&mccorsi);
+  d.SetBranchAddress("MMcFadcHeader",&mcfadc);
+  d.SetBranchAddress("MMcRunHeader",&mcrunhead);
+  d.SetBranchAddress("MMcTrigHeader",&mctrighead);
+  d.SetBranchAddress("MRawRunHeader",&mrawrunhead);
+  d.Add(in);
+  d.Merge(f,1000);
+
+  f->Close();
+
+  return;
+}
Index: /tags/Mars_V0-8-5/Mars/macros/merpp.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/merpp.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/merpp.C	(revision 9661)
@@ -0,0 +1,103 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// merpp.C
+// =======
+//
+// This is an easy implementation of the Merging process (as root Macro)
+//
+// at the moment it reads a binary file ("rawtest.raw") 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")
+//
+// It also demonstrates how you can loop over files in a single or more
+// than one directory and process them. For details see MRunIter.
+//
+/////////////////////////////////////////////////////////////////////////////
+
+void ProcessFile(TString fname)
+{
+    //
+    // 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(fname);
+    MRawFileWrite writer(fname(0, fname.Last('.')+1) + "root", "RECREATE", fname, 1);
+    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();
+}
+
+void merpp(const char *dirname="/home/MAGIC/online_data/rawdata/")
+{
+    MDirIter Next;
+    Next.AddDirectory(dirname, "*.raw", -1);
+
+    while (1)
+    {
+        TString fname = Next();
+        if (fname.IsNull())
+            break;
+
+        ProcessFile(fname);
+    }
+}
+
Index: /tags/Mars_V0-8-5/Mars/macros/multidimdist.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/multidimdist.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/multidimdist.C	(revision 9661)
@@ -0,0 +1,176 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 5/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Rudy Bock, 5/2002 <mailto:rkb@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+void multidimdist()
+{
+    //
+    // This is a demonstration program which calculates the Hillas
+    // parameter out of a Magic root file.
+
+    //
+    // Create a empty Parameter List and an empty Task List
+    // The tasklist is identified in the eventloop by its name
+    //
+    MParList  plist;
+
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    //
+    // This is an example program which reads image parameters for gammas 
+    // and hadrons, builds a 'matrix' of look-alike events,
+    // and then finds quality numbers and acceptances for the same sample
+
+    // Create an empty Parameter List and an empty Task List
+    // The tasklist is identified in the eventloop by its name
+    //
+    MParList  plist;
+    MTaskList tlistg;
+    plist.AddToList(&tlistg);
+
+    //
+    // ------------- user attention -----------------
+    //
+
+    // cut used both for the matrices and the sample
+    // for more information see the documentation of MF and MDataChain
+    MF filterenergy("MMcEvt.fEnergy > 0");
+
+    // matrix limitation for look-alike events (approximate number)
+    MFEventSelector selector;
+    selector.SetNumSelectEvts(2000);
+
+    // setup an AND-Filterlist from the two filters to be used
+    // in the event selection for the filling of the matrices
+    MFilterList flist;
+    flist.AddToList(&filterenergy);
+    flist.AddToList(&selector);
+
+    //
+    // ---------------------------------------------------------------
+    //  Now set up the tasks and tasklist (first event loop, gammas)
+    // ---------------------------------------------------------------
+    //
+
+    // --------------- user change -----------------
+    //  Give the names of the star-files to be read
+    //   Here you give the trainings sample(s) for
+    //                 the hadrons
+    // ---------------------------------------------
+    MReadMarsFile read("Events");
+    read.AddFile("star_gammas.root");
+    read.AddFile("star_protons.root");
+    read.DisableAutoScheme();
+    tlistg.AddToList(&read);
+
+    MFParticleId fgamma("MMcEvt", '=', kGAMMA);
+    tlist.AddToList(&fgamma);
+
+    MFParticleId fhadrons("MMcEvt", '!', kGAMMA);
+    tlist.AddToList(&fhadrons);
+
+    MHMatrix matrix("MatrixGammas");
+    matrix.AddColumn("MHillas.fWidth");
+    matrix.AddColumn("MHillas.fLength");
+    matrix.AddColumn("MHillas.fWidth*MHillas.fLength/MHillas.fSize");
+    matrix.AddColumn("abs(MHillas.fAsym)");
+    matrix.AddColumn("abs(MHillas.fM3Long)");
+    matrix.AddColumn("abs(MHillas.fM3Trans)");
+    matrix.AddColumn("abs(MHillasSrc.fHeadTail)");
+    matrix.AddColumn("MHillas.fConc");
+    matrix.AddColumn("MHillas.fConc1");
+    matrix.AddColumn("MHillasSrc.fDist");
+    matrix.AddColumn("log10(MHillas.fSize)");
+    matrix.AddColumn("MHillasSrc.fAlpha");
+    matrix.AddColumn("MMcEvt.fTheta");
+    plist.AddToList(&matrix);
+
+    MHMatrix matrix2("MatrixHadrons");
+    matrix2.AddColumns(matrix.GetColumns());
+    plist.AddToList(&matrix2);
+
+    MFillH fillmat("MatrixGammas");
+    fillmat.SetFilter(&fgamma);
+    tlist.AddToList(&fillmat);
+
+    MFillH fillmat2("MatrixHadrons");
+    fillmat2.SetFilter(&fhadrons);
+    tlist.AddToList(&fillmat2);
+
+    //
+    // Create and setup the eventloop
+    //
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    //
+    // Execute your analysis
+    //
+    if (!evtloop.Eventloop())
+        return;
+
+    tlist.PrintStatistics();
+
+    matrix.Print("size");
+    matrix2.Print("size");
+
+    // ---------------------------------------------------------
+
+    MTaskList tlist2;
+
+    plist.Replace(&tlist2);
+
+    MReadMarsFile read2("Events");
+    read2.("gammas2.root");
+    read2.AddFile("hadrons2.root");
+    read2.DisableAutoScheme();
+    tlist2.AddToList(&read2);
+
+    MMultiDimDistCalc calc;
+    calc.SetUseNumRows(0);
+    calc.SetUseKernelMethod(kTRUE);
+    tlist2.AddToList(&calc);
+
+    MFillH fillh("MHHadronness");
+
+    /*
+     MF filter("MMcEvt.fEnergy < 100");
+     fillh.SetFilter(&filter);
+     tlist2.AddToList(&filter);
+     */
+
+    tlist2.AddToList(&fillh);
+
+    //
+    // Execute your analysis
+    //
+    if (!evtloop.Eventloop())
+        return;
+
+    tlist2.PrintStatistics();
+
+    plist.FindObject("MHHadronness")->DrawClone();
+    plist.FindObject("MHHadronness")->Print();
+}
Index: /tags/Mars_V0-8-5/Mars/macros/multidimdist2.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/multidimdist2.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/multidimdist2.C	(revision 9661)
@@ -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, 11/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Rudy Bock, 11/2002 <mailto:rkb@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+void multidimdist2()
+{
+    //
+    // This is an example program which reads image parameters for gammas 
+    // and hadrons, builds a 'matrix' of look-alike events,
+    // and then finds quality numbers and acceptances for the same sample
+
+    // Create an empty Parameter List and an empty Task List
+    // The tasklist is identified in the eventloop by its name
+    //
+    MParList  plist;
+    MTaskList tlistg;
+    plist.AddToList(&tlistg);
+
+    //
+    // ------------- user attention -----------------
+    //
+
+    // cut used both for the matrices and the sample
+    // for more information see the documentation of MF and MDataChain
+    MF filterenergy("MMcEvt.fEnergy > 0");
+
+    // matrix limitation for look-alike events (approximate number)
+    MFEventSelector selector;
+    selector.SetNumSelectEvts(2000);
+
+    // setup an AND-Filterlist from the two filters to be used
+    // in the event selection for the filling of the matrices
+    MFilterList flist;
+    flist.AddToList(&filterenergy);
+    flist.AddToList(&selector);
+
+    //
+    // ---------------------------------------------------------------
+    //  Now set up the tasks and tasklist (first event loop, gammas)
+    // ---------------------------------------------------------------
+    //
+
+    // --------------- user change -----------------
+    //  Give the names of the star-files to be read
+    //   Here you give the trainings sample(s) for
+    //                 the gammas
+    //      If you have only _one_ single Theta
+    //            remove MMcEvt.fTheta!
+    // ---------------------------------------------
+    MReadMarsFile readg("Events", "star_gammas0.root");
+    readg.DisableAutoScheme();
+    tlistg.AddToList(&readg);
+
+    MHMatrix matrix("MatrixGammas");
+    matrix.AddColumn("MHillas.fWidth");
+    matrix.AddColumn("MHillas.fLength");
+    matrix.AddColumn("MHillas.fWidth*MHillas.fLength/MHillas.fSize");
+    matrix.AddColumn("abs(MHillas.fAsym)");
+    matrix.AddColumn("abs(MHillas.fM3Long)");
+    matrix.AddColumn("abs(MHillas.fM3Trans)");
+    matrix.AddColumn("abs(MHillasSrc.fHeadTail)");
+    matrix.AddColumn("MHillas.fConc");
+    matrix.AddColumn("MHillas.fConc1");
+    matrix.AddColumn("MHillasSrc.fDist");
+    matrix.AddColumn("log10(MHillas.fSize)");
+    matrix.AddColumn("MHillasSrc.fAlpha");
+    matrix.AddColumn("MMcEvt.fTheta");
+    plist.AddToList(&matrix);
+
+    MFillH fillmatg("MatrixGammas");
+    fillmatg.SetFilter(&flist);
+    tlistg.AddToList(&flist);
+    tlistg.AddToList(&fillmatg);
+
+    //
+    // --- Create and set up the eventloop (gammas) ---
+    //
+    MEvtLoop evtloop1;
+    evtloop1.SetParList(&plist);
+
+    //
+    // --- Execute matrix buildup (gammas) ---
+    //
+    if (!evtloop1.Eventloop())
+        return;
+
+    tlistg.PrintStatistics();
+
+    //
+    // ------------------------------------------------------------------
+    //                prepare second event loop, hadrons
+    // ------------------------------------------------------------------
+    //
+    MTaskList tlisth;
+    plist.Replace(&tlisth);
+
+    // --------------- user change -----------------
+    //  Give the names of the star-files to be read
+    //   Here you give the trainings sample(s) for
+    //                 the hadrons
+    // ---------------------------------------------
+    MReadMarsFile  readh("Events", "star_protons0.root");
+    readh.DisableAutoScheme();
+    tlisth.AddToList(&readh);
+
+    MHMatrix matrixh("MatrixHadrons");
+    matrixh.AddColumns(matrix.GetColumns());
+    plist.AddToList(&matrixh); 
+
+    MFillH fillmath("MatrixHadrons");
+    fillmath.SetFilter(&flist);         // filter list
+    tlisth.AddToList(&flist);
+    tlisth.AddToList(&fillmath);
+
+    //
+    // Create and set up the eventloop (protons)
+    //
+    MEvtLoop evtloop2;
+    evtloop2.SetParList(&plist);
+
+    //
+    // Execute matrix buildup (hadrons)
+    //
+    if (!evtloop2.Eventloop())
+        return;
+
+    //  sum up in log
+    tlisth.PrintStatistics();
+
+    matrix.Print("size");
+    matrixh.Print("size");
+
+    //
+    // ----------------------------------------------------------
+    //  Go through full sample again, now for getting hadronness
+    //  (third event loop)
+    // ----------------------------------------------------------
+    //
+
+    MTaskList tlist2;
+    plist.Replace(&tlist2);
+
+    // ------------------- user change --------------------
+    //    Give the names of the star-files to be read as
+    //  test samples   you should at least have one hadron
+    //          and one gamma file available
+    // ----------------------------------------------------
+    MReadMarsFile read2("Events", "star_gammas0.root");
+    read2.AddFile("star_protons0.root");
+    read2.DisableAutoScheme();
+    tlist2.AddToList(&read2);
+
+    // ---------------- user attention -----------------
+    //      Here you may change the algorithm used
+    //    You can switch from Kernel to Next Neighbor
+    //  or change the number of used shortest distances
+    //  For kernel you should always set this to 0 (all)
+    // -------------------------------------------------
+    MMultiDimDistCalc calc;
+    calc.SetUseNumRows(25);
+    calc.SetUseKernelMethod(kFALSE);
+    tlist2.AddToList(&calc);
+
+    MFillH fillh("MHHadronness");
+    fillh.SetFilter(&filterenergy);
+    tlist2.AddToList(&filterenergy);
+    tlist2.AddToList(&fillh);
+
+    //
+    // Execute analysis of gammas and hadrons
+    //
+    MProgressBar bar;
+    MEvtLoop evtloop3;
+    evtloop3.SetProgressBar(&bar);
+    evtloop3.SetParList(&plist);
+
+    if (!evtloop3.Eventloop())
+        return;
+
+    tlist2.PrintStatistics();
+
+    plist.FindObject("MHHadronness")->DrawClone();
+    plist.FindObject("MHHadronness")->Print();
+}
Index: /tags/Mars_V0-8-5/Mars/macros/optPad.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/optPad.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/optPad.C	(revision 9661)
@@ -0,0 +1,268 @@
+#include <TH1.h>
+#include <TCanvas.h>
+#include <TVector.h>
+#include <TMatrix.h>
+#include <iomanip.h>
+
+void optPad()
+{
+  Int_t N = 10;
+  Double_t eps = 1.e-10;
+
+  TMatrix g(N, N);
+  g.Zero();
+
+  // hista is the normalized 1D histogram of sigmabar for ON data
+  // histb is the normalized 1D histogram of sigmabar for OFF data
+  // histc is the difference ON-OFF
+
+  TH1D *hista = new TH1D("ON",   "ON  data before padding", N, 0., 5.);
+  TH1D *histb = new TH1D("OFF",  "OFF data before padding", N, 0., 5.);
+  TH1D *histc = new TH1D("ON-OFF", "ON-OFF before padding", N, 0., 5.);
+  hista->SetMaximum( 5.0/(Double_t)N );
+  hista->SetMinimum(-1.0/(Double_t)N );
+  histb->SetMaximum( 5.0/(Double_t)N );
+  histb->SetMinimum(-1.0/(Double_t)N );
+  histc->SetMaximum( 5.0/(Double_t)N );
+  histc->SetMinimum(-1.0/(Double_t)N );
+ 
+  // at the beginning, histap is a copy of hista
+  // at the end, it will be the 1D histogram for ON data after padding
+
+  // at the beginning, histbp is a copy of histb
+  // at the end, it will be the 1D histogram for OFF data after padding
+
+  // at the beginning, histcp is a copy of histc
+  // at the end, it should be zero
+
+  TH1D *histap = new TH1D("ONp",   "ON  data after padding", N, 0., 5.);
+  TH1D *histbp = new TH1D("OFFp",  "OFF data after padding", N, 0., 5.);
+  TH1D *histcp = new TH1D("ON-OFFp", "ON-OFF after padding", N, 0., 5.);  
+  histap->SetMaximum( 5.0/(Double_t)N );
+  histap->SetMinimum(-1.0/(Double_t)N );
+  histbp->SetMaximum( 5.0/(Double_t)N );
+  histbp->SetMinimum(-1.0/(Double_t)N );
+  histcp->SetMaximum( 1.0/(Double_t)N);
+  histcp->SetMinimum(-1.0/(Double_t)N);
+
+  Double_t shoulda[] = {1.0, 2.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 2.0, 1.0};
+  Double_t shouldb[] = {0.0, 0.0, 1.0, 2.0, 3.0, 2.0, 1.0, 0.0, 1.0, 2.0};
+  for (Int_t i=1; i<=N; i++)
+  {
+    hista->SetBinContent(i, shoulda[i-1]);
+    histb->SetBinContent(i, shouldb[i-1]);
+  }
+
+  // normalize histograms
+  Double_t suma, sumb, conta, contb;
+  suma = 0.0;
+  sumb = 0.0;
+  for (Int_t i=1; i<=N; i++)
+  {
+    conta = hista->GetBinContent(i);
+    contb = histb->GetBinContent(i);
+    suma += conta;
+    sumb += contb;    
+  }
+
+  for (Int_t i=1; i<=N; i++)
+  {
+    conta = hista->GetBinContent(i);
+    contb = histb->GetBinContent(i);
+
+    hista->SetBinContent(i,conta/suma);
+    histb->SetBinContent(i,contb/sumb);
+    histc->SetBinContent(i, conta/suma - contb/sumb);
+
+    histap->SetBinContent(i,conta/suma);
+    histbp->SetBinContent(i,contb/sumb);
+    histcp->SetBinContent(i, conta/suma - contb/sumb);
+  }
+
+
+  // g[k-1][j-1] (if <0.0) tells how many ON events in bin k should be padded
+  //              from sigma_k to sigma_j
+
+  // g[k-1][j-1] (if >0.0) tells how many OFF events in bin k should be padded
+  //              from sigma_k to sigma_j
+
+
+  //--------   start j loop   ------------------------------------------------
+  // loop over bins in histc, starting from the end
+  Double_t v, s, w, t, x, u, a, b, arg;
+
+  for (Int_t j=N; j >= 1; j--)
+  {
+    v = histcp->GetBinContent(j);
+    if ( fabs(v) < eps ) continue;
+    if (v >= 0.0) 
+      s = 1.0;
+    else
+      s = -1.0;
+
+    //................   start k loop   ......................................
+    // look for a bin k which may compensate the content of bin j
+    for (Int_t k=j-1; k >= 1; k--)
+    {
+      w = histcp->GetBinContent(k);
+      if ( fabs(w) < eps ) continue;
+      if (w >= 0.0) 
+        t = 1.0;
+      else
+        t = -1.0;
+
+      if (s==t) continue;
+
+      x = v + w;
+      if (x >= 0.0) 
+        u = 1.0;
+      else
+        u = -1.0;
+
+      if (u == s)
+      {
+        arg = -w;
+        g(k-1, j-1)   = arg;
+        cout << "k-1, j-1, arg = " << k-1 << ",  " << j-1 << ",  " 
+             << arg << endl;
+
+
+        //......................................
+        // this is for checking the procedure
+        if (arg < 0.0)
+        {
+          a = histap->GetBinContent(k);
+          histap->SetBinContent(k, a+arg);
+          a = histap->GetBinContent(j);
+          histap->SetBinContent(j, a-arg);
+        }
+        else
+        {
+          b = histbp->GetBinContent(k);
+          histbp->SetBinContent(k, b-arg);
+          b = histbp->GetBinContent(j);
+          histbp->SetBinContent(j, b+arg);
+        }
+        //......................................
+
+        histcp->SetBinContent(k, 0.0);
+        histcp->SetBinContent(j,   x);
+
+        //......................................
+        // redefine v 
+        v = histcp->GetBinContent(j);
+        if ( fabs(v) < eps ) break;
+        if (v >= 0.0) 
+          s = 1.0;
+        else
+          s = -1.0;
+        //......................................
+       
+        continue;
+      }
+
+      arg = v;
+      g(k-1, j-1) = arg;
+      cout << "k-1, j-1, arg = " << k-1 << ",  " << j-1 << ",  " 
+           << arg << endl;
+
+      //......................................
+      // this is for checking the procedure
+      if (arg < 0.0)
+      {
+        a = histap->GetBinContent(k);
+        histap->SetBinContent(k, a+arg);
+        a = histap->GetBinContent(j);
+        histap->SetBinContent(j, a-arg);
+      }
+      else
+      {
+        b = histbp->GetBinContent(k);
+        histbp->SetBinContent(k, b-arg);
+        b = histbp->GetBinContent(j);
+        histbp->SetBinContent(j, b+arg);
+      }
+      //......................................
+
+      histcp->SetBinContent(k,   x);
+      histcp->SetBinContent(j, 0.0);
+
+      break;
+    }
+    //................   end k loop   ......................................
+
+
+}
+  //--------   end j loop   ------------------------------------------------
+  TVector index(N);
+  index.Zero();
+
+  TVector  map(N);
+  Int_t indexold = 0;
+
+  cout << "=========================================================" << endl;
+  for (Int_t k=0; k<N-1; k++)
+  {
+    index(k) = (Double_t)indexold;
+    Int_t add = 0;
+    for (Int_t j=k+1; j<N; j++)
+    { 
+      if (fabs(g(k,j)) > eps)
+      {
+          map(indexold) = g(k, j);
+
+          cout << "k, j, indexold, map = " << k << ",  " << j << ",  "
+             << indexold << ",  " << map(indexold) << endl;;
+
+          indexold += 1;
+          add += 1;
+      }
+    }
+    if (add == 0) index(k) = 0;
+    cout << endl;
+    cout << "index(k), add = " << index(k) << ",  " << add << endl;
+  }
+
+  cout << "=========================================================" << endl;
+  cout << " " << endl;
+
+  //------------------------------------------------------------------------
+
+
+  TCanvas *c1 = new TCanvas("c1","", 600, 900);
+  c1->Divide(2,3);
+
+  c1->cd(1);
+  hista->Draw();
+
+  c1->cd(2);
+  histap->Draw();
+
+  c1->cd(3);
+  histb->Draw();
+
+  c1->cd(4);
+  histbp->Draw();
+
+  c1->cd(5);
+  histc->Draw();
+
+  c1->cd(6);
+  histcp->Draw();
+
+}
+//=========================================================================
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/macros/pedestalstudies.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/pedestalstudies.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/pedestalstudies.C	(revision 9661)
@@ -0,0 +1,504 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug, 04/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+//////////////////////////////////////////////////////////////////////////////
+//
+// pedestalstudies.C
+//
+// macro to study the pedestal and pedestalRMS with the number of FADC 
+// slices summed up. 
+//
+/////////////////////////////////////////////////////////////////////////////////
+const TString pedfile = "./20040303_20123_P_NewCalBoxTestLidOpen_E.root";
+
+void pedestalstudies(const TString pedname=pedfile)
+{
+
+  Int_t loops = 13;
+  Int_t stepsize = 2;
+
+  gStyle->SetOptStat(1111);
+  gStyle->SetOptFit();
+  
+  TArrayF *hmeandiffinn = new TArrayF(loops);
+  TArrayF *hrmsdiffinn  = new TArrayF(loops);
+  TArrayF *hmeandiffout = new TArrayF(loops);
+  TArrayF *hrmsdiffout  = new TArrayF(loops);
+  TArrayF *hmeaninn  = new TArrayF(loops);
+  TArrayF *hmeanout  = new TArrayF(loops);
+  TArrayF *hrmsinn   = new TArrayF(loops);
+  TArrayF *hrmsout   = new TArrayF(loops);
+  TArrayF *hmuinn    = new TArrayF(loops);
+  TArrayF *hmuout    = new TArrayF(loops);
+  TArrayF *hsigmainn = new TArrayF(loops);
+  TArrayF *hsigmaout = new TArrayF(loops);
+
+  TArrayF *hmeandiffinnerr = new TArrayF(loops);
+  TArrayF *hrmsdiffinnerr  = new TArrayF(loops);
+  TArrayF *hmeandiffouterr = new TArrayF(loops);
+  TArrayF *hrmsdiffouterr  = new TArrayF(loops);
+  TArrayF *hmeaninnerr  = new TArrayF(loops);
+  TArrayF *hmeanouterr  = new TArrayF(loops);
+  TArrayF *hrmsinnerr   = new TArrayF(loops);
+  TArrayF *hrmsouterr   = new TArrayF(loops);
+  TArrayF *hmuinnerr    = new TArrayF(loops);
+  TArrayF *hmuouterr    = new TArrayF(loops);
+  TArrayF *hsigmainnerr = new TArrayF(loops);
+  TArrayF *hsigmaouterr = new TArrayF(loops);
+
+
+  MStatusDisplay *display = new MStatusDisplay;
+  display->SetUpdateTime(500);
+  display->Resize(850,700);
+      
+  //
+  // Create a empty Parameter List and an empty Task List
+  // The tasklist is identified in the eventloop by its name
+  //
+  MParList  plist;
+  MTaskList tlist;
+  plist.AddToList(&tlist);
+
+  for (Int_t samples=2;samples<stepsize*loops+1;samples=samples+stepsize)
+    {
+
+      plist.Reset();
+      tlist.Reset();
+      
+      //
+      // Now setup the tasks and tasklist for the pedestals:
+      // ---------------------------------------------------
+      //
+      
+      MReadMarsFile read("Events", pedname);
+      read.DisableAutoScheme();
+      
+      MGeomApply      geomapl;
+      //
+      // Set the extraction range higher:
+      //		
+      MExtractFixedWindow sigcalc;
+      sigcalc.SetRange(0,samples-1,0,1);
+  
+      MPedCalcPedRun pedcalc;
+      pedcalc.SetRange(0,samples-1,0,0);
+      pedcalc.SetWindowSize((Int_t)sigcalc.GetNumHiGainSamples());
+
+      //
+      // Additionally to calculating the pedestals, 
+      // you can fill histograms and look at them
+      //
+      MFillH fill("MHPedestalCam", "MExtractedSignalCam");
+      fill.SetNameTab(Form("%s%2d","PedCam",samples));
+
+      tlist.AddToList(&read);
+      tlist.AddToList(&geomapl);
+      tlist.AddToList(&sigcalc);
+      tlist.AddToList(&pedcalc);
+      tlist.AddToList(&fill);
+      
+      MGeomCamMagic      geomcam;
+      MPedestalCam       pedcam;
+      MBadPixelsCam      badcam;
+      badcam.AsciiRead("badpixels.dat");  
+      
+      MHPedestalCam      hpedcam;
+      MCalibrationPedCam cpedcam;
+      
+      plist.AddToList(&geomcam);
+      plist.AddToList(&pedcam);
+      plist.AddToList(&hpedcam);
+      plist.AddToList(&cpedcam);
+      plist.AddToList(&badcam);
+      
+      //
+      // Create and setup the eventloop
+      //
+      MEvtLoop evtloop;
+      
+      evtloop.SetParList(&plist);
+      evtloop.SetDisplay(display);
+
+      //
+      // Execute first analysis
+      //
+      if (!evtloop.Eventloop())
+        return;
+      
+      // 
+      // Look at one specific pixel, after all the histogram manipulations:
+      //
+      /*
+      MHGausEvents &hpix = hpedcam.GetAverageHiGainArea(0);
+      hpix.DrawClone("fourierevents");
+      
+      MHGausEvents &lpix = hpedcam.GetAverageHiGainArea(1);
+      lpix.DrawClone("fourierevents");
+
+      hpedcam[170].DrawClone("fourierevents");
+  
+      */
+
+      MHCamera dispped0  (geomcam, "Ped;Pedestal",       "Mean per Slice");
+      MHCamera dispped2  (geomcam, "Ped;PedestalRms",    "RMS per Slice");
+      MHCamera dispped4  (geomcam, "Ped;Mean",           "Fitted Mean per Slice");
+      MHCamera dispped6  (geomcam, "Ped;Sigma",          "Fitted Sigma per Slice");
+      MHCamera dispped9  (geomcam, "Ped;DeltaPedMean",   "Rel. Diff. Mean per Slice (Fit-Calc.)");
+      MHCamera dispped11 (geomcam, "Ped;DeltaRmsSigma",  "Rel. Diff. RMS per Slice (Fit-Calc.)");
+  
+      dispped0.SetCamContent(  pedcam, 0);
+      dispped0.SetCamError(    pedcam, 1);
+      dispped2.SetCamContent(  pedcam, 2);
+      dispped2.SetCamError(    pedcam, 3);
+      
+      dispped4.SetCamContent( hpedcam, 0);
+      dispped4.SetCamError(   hpedcam, 1);
+      dispped6.SetCamContent( hpedcam, 2);
+      dispped6.SetCamError(   hpedcam, 3);
+      dispped9.SetCamContent( hpedcam, 5);
+      dispped9.SetCamError(   hpedcam, 6);
+      dispped11.SetCamContent(hpedcam, 8);
+      dispped11.SetCamError(  hpedcam, 9);
+  
+      dispped0.SetYTitle("Calc. Pedestal per slice [FADC counts]");
+      dispped2.SetYTitle("Calc. Pedestal RMS per slice [FADC counts]");
+      dispped4.SetYTitle("Fitted Mean per slice [FADC counts]");
+      dispped6.SetYTitle("Fitted Sigma per slice [FADC counts]");
+      dispped9.SetYTitle("Rel. Diff. Pedestal per slice Fit-Calc [1]");
+      dispped11.SetYTitle("Rel. Diff. Pedestal RMS per slice Fit-Calc [1]");
+
+
+      // Histogram values
+      TCanvas &b1 = display->AddTab(Form("%s%d","MeanRMS",samples));
+      b1.Divide(4,3);
+
+      CamDraw(b1,dispped0,1,4,*hmeaninn,*hmeanout,*hmeaninnerr,*hmeanouterr,samples,stepsize);
+      CamDraw(b1,dispped2,2,4,*hrmsinn,*hrmsout,*hrmsinnerr,*hrmsouterr,samples,stepsize);  
+      CamDraw(b1,dispped4,3,4,*hmuinn,*hmuout,*hmuinnerr,*hmuouterr,samples,stepsize);
+      CamDraw(b1,dispped6,4,4,*hsigmainn,*hsigmaout,*hsigmainnerr,*hsigmaouterr,samples,stepsize); 
+      
+      display->SaveAsGIF(3*((samples-1)/stepsize)+2,Form("%s%d","MeanRmsSamples",samples));
+
+      // Differences
+      TCanvas &c4 = display->AddTab(Form("%s%d","RelDiff",samples));
+      c4.Divide(2,3);
+      
+      CamDraw(c4,dispped9,1,2,*hmeandiffinn,*hmeandiffout,*hmeandiffinnerr,*hmeandiffouterr,samples,stepsize);
+      CamDraw(c4,dispped11,2,2,*hrmsdiffinn,*hrmsdiffout,*hrmsdiffinnerr,*hrmsdiffouterr,samples,stepsize); 
+
+      display->SaveAsGIF(3*((samples-1)/stepsize)+3,Form("%s%d","RelDiffSamples",samples));
+
+    }
+
+  /*
+  TF1 *logg = new TF1("logg","[1]+TMath::Log(x-[0])",1.,30.,2);
+  logg->SetParameters(1.,3.5);
+  logg->SetParLimits(0,-1.,3.);
+  logg->SetParLimits(1,-1.,7.);
+  logg->SetLineColor(kRed);
+  */
+
+  TCanvas *canvas = new TCanvas("PedstudInner","Pedestal Studies Inner Pixels",600,900);
+  canvas->Divide(2,3);
+  canvas->cd(1);
+
+  TGraphErrors *gmeaninn = new TGraphErrors(hmeaninn->GetSize(),
+                                            CreateXaxis(hmeaninn->GetSize(),stepsize),hmeaninn->GetArray(),
+                                            CreateXaxisErr(hmeaninnerr->GetSize(),stepsize),hmeaninnerr->GetArray());
+  gmeaninn->Draw("A*");
+  gmeaninn->SetTitle("Calculated Mean per Slice Inner Pixels");
+  gmeaninn->GetXaxis()->SetTitle("Nr. added FADC slices");
+  gmeaninn->GetYaxis()->SetTitle("Calculated Mean per slice");
+  //  gmeaninn->Fit("pol0");
+  //  gmeaninn->GetFunction("pol0")->SetLineColor(kGreen);
+  //  //  gmeaninn->Fit(logg);
+
+  canvas->cd(2);
+
+  TGraphErrors *gmuinn = new TGraphErrors(hmuinn->GetSize(),
+                                          CreateXaxis(hmuinn->GetSize(),stepsize),hmuinn->GetArray(),
+                                          CreateXaxisErr(hmuinnerr->GetSize(),stepsize),hmuinnerr->GetArray());
+  gmuinn->Draw("A*");
+  gmuinn->SetTitle("Fitted Mean per Slice Inner Pixels");
+  gmuinn->GetXaxis()->SetTitle("Nr. added FADC slices");
+  gmuinn->GetYaxis()->SetTitle("Fitted Mean per Slice");
+  //  gmuinn->Fit("pol0");
+  //  gmuinn->GetFunction("pol0")->SetLineColor(kGreen);
+  //gmuinn->Fit(logg);
+
+
+  canvas->cd(3);
+
+  TGraphErrors *grmsinn = new TGraphErrors(hrmsinn->GetSize(),
+                                           CreateXaxis(hrmsinn->GetSize(),stepsize),hrmsinn->GetArray(),
+                                           CreateXaxisErr(hrmsinnerr->GetSize(),stepsize),hrmsinnerr->GetArray());
+  grmsinn->Draw("A*");
+  grmsinn->SetTitle("Calculated Rms per Slice Inner Pixels");
+  grmsinn->GetXaxis()->SetTitle("Nr. added FADC slices");
+  grmsinn->GetYaxis()->SetTitle("Calculated Rms per Slice");
+  //  //grmsinn->Fit("pol2");
+  //  //grmsinn->GetFunction("pol2")->SetLineColor(kRed);
+  //  grmsinn->Fit(logg);
+
+  canvas->cd(4);
+
+  TGraphErrors *gsigmainn = new TGraphErrors(hsigmainn->GetSize(),
+                                             CreateXaxis(hsigmainn->GetSize(),stepsize),hsigmainn->GetArray(),
+                                             CreateXaxisErr(hsigmainnerr->GetSize(),stepsize),hsigmainnerr->GetArray());
+  gsigmainn->Draw("A*");
+  gsigmainn->SetTitle("Fitted Sigma per Slice Inner Pixels");
+  gsigmainn->GetXaxis()->SetTitle("Nr. added FADC slices");
+  gsigmainn->GetYaxis()->SetTitle("Fitted Sigma per Slice");
+  //  //  gsigmainn->Fit("pol2");
+  //  //  gsigmainn->GetFunction("pol2")->SetLineColor(kRed);
+  //  gsigmainn->Fit(logg);
+
+  canvas->cd(5);
+
+  TGraphErrors *gmeandiffinn = new TGraphErrors(hmeandiffinn->GetSize(),
+                                                CreateXaxis(hmeandiffinn->GetSize(),stepsize),hmeandiffinn->GetArray(),
+                                                CreateXaxisErr(hmeandiffinnerr->GetSize(),stepsize),hmeandiffinnerr->GetArray());
+  gmeandiffinn->Draw("A*"); 
+  gmeandiffinn->SetTitle("Rel. Difference  Mean per Slice Inner Pixels");
+  gmeandiffinn->GetXaxis()->SetTitle("Nr. added FADC slices");
+  gmeandiffinn->GetYaxis()->SetTitle("Rel. Difference Mean per Slice");
+  //  //gmeandiffinn->Fit("pol2");
+  //  //gmeandiffinn->GetFunction("pol2")->SetLineColor(kBlue);
+  //  gmeandiffinn->Fit(logg);
+
+
+  canvas->cd(6);
+
+  TGraphErrors *grmsdiffinn = new TGraphErrors(hrmsdiffinn->GetSize(),
+                                               CreateXaxis(hrmsdiffinn->GetSize(),stepsize),hrmsdiffinn->GetArray(),
+                                               CreateXaxisErr(hrmsdiffinnerr->GetSize(),stepsize),hrmsdiffinnerr->GetArray());
+  grmsdiffinn->Draw("A*");
+  grmsdiffinn->SetTitle("Rel. Difference Sigma per Slice-RMS Inner Pixels");
+  grmsdiffinn->GetXaxis()->SetTitle("Nr. added FADC slices");
+  grmsdiffinn->GetYaxis()->SetTitle("Rel. Difference Sigma per Slice-RMS");
+  //  //grmsdiffinn->Fit("pol2");
+  //  //grmsdiffinn->GetFunction("pol2")->SetLineColor(kBlue);
+  //  grmsdiffinn->Fit(logg);
+
+  canvas->SaveAs("PedestalStudyInner.root");
+  canvas->SaveAs("PedestalStudyInner.ps");
+
+  TCanvas *canvas2 = new TCanvas("PedstudOut","Pedestal Studies Outer Pixels",600,900);
+  canvas2->Divide(2,3);
+  canvas2->cd(1);
+
+  TGraphErrors *gmeanout = new TGraphErrors(hmeanout->GetSize(),
+                                            CreateXaxis(hmeanout->GetSize(),stepsize),hmeanout->GetArray(),
+                                            CreateXaxisErr(hmeanouterr->GetSize(),stepsize),hmeanouterr->GetArray());
+  gmeanout->Draw("A*");
+  gmeanout->SetTitle("Calculated Mean per Slice Outer Pixels");
+  gmeanout->GetXaxis()->SetTitle("Nr. added FADC slices");
+  gmeanout->GetYaxis()->SetTitle("Calculated Mean per Slice");
+  //  gmeanout->Fit("pol0");
+  //  gmeanout->GetFunction("pol0")->SetLineColor(kGreen);
+  //gmeanout->Fit(logg);
+
+  canvas2->cd(2);
+
+  TGraphErrors *gmuout = new TGraphErrors(hmuout->GetSize(),
+                                          CreateXaxis(hmuout->GetSize(),stepsize),hmuout->GetArray(),
+                                          CreateXaxisErr(hmuouterr->GetSize(),stepsize),hmuouterr->GetArray());
+  gmuout->Draw("A*");
+  gmuout->SetTitle("Fitted Mean per Slice Outer Pixels");
+  gmuout->GetXaxis()->SetTitle("Nr. added FADC slices");
+  gmuout->GetYaxis()->SetTitle("Fitted Mean per Slice");
+  //  gmuout->Fit("pol0");
+  //  gmuout->GetFunction("pol0")->SetLineColor(kGreen);
+  //gmuout->Fit(logg);
+
+  canvas2->cd(3);
+
+  TGraphErrors *grmsout = new TGraphErrors(hrmsout->GetSize(),
+                                           CreateXaxis(hrmsout->GetSize(),stepsize),hrmsout->GetArray(),
+                                           CreateXaxisErr(hrmsouterr->GetSize(),stepsize),hrmsouterr->GetArray());
+  grmsout->Draw("A*");
+  grmsout->SetTitle("Calculated Rms per Slice Outer Pixels");
+  grmsout->GetXaxis()->SetTitle("Nr. added FADC slices");
+  grmsout->GetYaxis()->SetTitle("Calculated Rms per Slice");
+  //  //grmsout->Fit("pol2");
+  //  //grmsout->GetFunction("pol2")->SetLineColor(kRed);
+  //  grmsout->Fit(logg);
+
+  canvas2->cd(4);
+
+  TGraphErrors *gsigmaout = new TGraphErrors(hsigmaout->GetSize(),
+                                             CreateXaxis(hsigmaout->GetSize(),stepsize),hsigmaout->GetArray(),
+                                             CreateXaxisErr(hsigmaouterr->GetSize(),stepsize),hsigmaouterr->GetArray());
+  gsigmaout->Draw("A*");
+  gsigmaout->SetTitle("Fitted Sigma per Slice Outer Pixels");
+  gsigmaout->GetXaxis()->SetTitle("Nr. added FADC slices");
+  gsigmaout->GetYaxis()->SetTitle("Fitted Sigma per Slice");
+  //  //gsigmaout->Fit("pol2");
+  //  //gsigmaout->GetFunction("pol2")->SetLineColor(kRed);
+  //  gsigmaout->Fit(logg);
+
+
+  canvas2->cd(5);
+
+  TGraphErrors *gmeandiffout = new TGraphErrors(hmeandiffout->GetSize(),
+                                                CreateXaxis(hmeandiffout->GetSize(),stepsize),hmeandiffout->GetArray(),
+                                                CreateXaxisErr(hmeandiffouterr->GetSize(),stepsize),hmeandiffouterr->GetArray());
+  gmeandiffout->Draw("A*");
+  gmeandiffout->SetTitle("Rel. Difference  Mean per Slice Outer Pixels");
+  gmeandiffout->GetXaxis()->SetTitle("Nr. added FADC slices");
+  gmeandiffout->GetYaxis()->SetTitle("Rel. Difference Mean per Slice");
+  //  //gmeandiffout->Fit("pol2");
+  //w  //gmeandiffout->GetFunction("pol2")->SetLineColor(kBlue);
+  //  gmeandiffout->Fit(logg);
+
+  canvas2->cd(6);
+
+  TGraphErrors *grmsdiffout = new TGraphErrors(hrmsdiffout->GetSize(),
+                                               CreateXaxis(hrmsdiffout->GetSize(),stepsize),hrmsdiffout->GetArray(),
+                                               CreateXaxisErr(hrmsdiffouterr->GetSize(),stepsize),hrmsdiffouterr->GetArray());
+  grmsdiffout->Draw("A*");
+  grmsdiffout->SetTitle("Rel. Difference Sigma per Slice-RMS Outer Pixels");
+  grmsdiffout->GetXaxis()->SetTitle("Nr. added FADC slices");
+  grmsdiffout->GetYaxis()->SetTitle("Rel. Difference Sigma per Slice-RMS");
+  //  //grmsdiffout->Fit("pol2");
+  //  //grmsdiffout->GetFunction("pol2")->SetLineColor(kBlue);
+  //  grmsdiffout->Fit(logg);
+
+
+  canvas2->SaveAs("PedestalStudyOuter.root");
+  canvas2->SaveAs("PedestalStudyOuter.ps");
+
+
+}
+
+
+void CamDraw(TCanvas &c, MHCamera &cam, Int_t i, Int_t j, TArrayF &a1, TArrayF &a2, 
+             TArrayF &a1err, TArrayF &a2err, Int_t samp, Int_t stepsize)
+{
+
+  c.cd(i);
+  MHCamera *obj1=(MHCamera*)cam.DrawCopy("hist");
+  obj1->SetDirectory(NULL);
+  
+  c.cd(i+j);
+  obj1->Draw();
+  ((MHCamera*)obj1)->SetPrettyPalette();
+
+  c.cd(i+2*j);
+  TH1D *obj2 = (TH1D*)obj1->Projection();
+  obj2->SetDirectory(NULL);
+  
+  //      obj2->Sumw2();
+  obj2->Draw();
+  obj2->SetBit(kCanDelete);
+  
+  const Double_t min   = obj2->GetBinCenter(obj2->GetXaxis()->GetFirst());
+  const Double_t max   = obj2->GetBinCenter(obj2->GetXaxis()->GetLast());
+  const Double_t integ = obj2->Integral("width")/2.5066283;
+  const Double_t mean  = obj2->GetMean();
+  const Double_t rms   = obj2->GetRMS();
+  const Double_t width = max-min;
+  
+  if (rms == 0. || width == 0. )
+    return;
+  
+  TArrayI s0(6);
+  s0[0] = 6;
+  s0[1] = 1;
+  s0[2] = 2;
+  s0[3] = 3;
+  s0[4] = 4;
+  s0[5] = 5;
+  
+  TArrayI inner(1);
+  inner[0] = 0;
+  
+  TArrayI outer(1);
+  outer[0] = 1;
+      
+  // Just to get the right (maximum) binning
+  TH1D *half[2];
+  half[0] = obj1->ProjectionS(s0, inner, "Inner");
+  half[1] = obj1->ProjectionS(s0, outer, "Outer");
+
+  half[0]->SetDirectory(NULL);
+  half[1]->SetDirectory(NULL);
+  
+  for (int i=0; i<2; i++)
+    {
+      half[i]->SetLineColor(kRed+i);
+      half[i]->SetDirectory(0);
+      half[i]->SetBit(kCanDelete);
+      half[i]->Draw("same");
+      half[i]->Fit("gaus","Q+");
+
+      if (i==0)
+        {
+          a1[(samp-1)/stepsize] = half[i]->GetFunction("gaus")->GetParameter(1);
+          a1err[(samp-1)/stepsize] = half[i]->GetFunction("gaus")->GetParError(1);
+          if (a1err[(samp-1)/stepsize] > 3.)
+            a1err[(samp-1)/stepsize] = 1.;
+        }
+     if (i==1)
+       {
+         a2[(samp-1)/stepsize] = half[i]->GetFunction("gaus")->GetParameter(1);
+         a2err[(samp-1)/stepsize] = half[i]->GetFunction("gaus")->GetParError(1);
+          if (a2err[(samp-1)/stepsize] > 3.)
+            a2err[(samp-1)/stepsize] = 1.;
+       }
+    }
+  
+  
+}
+
+// -----------------------------------------------------------------------------
+// 
+// Create the x-axis for the event graph
+//
+Float_t *CreateXaxis(Int_t n, Int_t step)
+{
+
+  Float_t *xaxis = new Float_t[n];
+
+  for (Int_t i=0;i<n;i++)
+    xaxis[i] = 2. + step*i;
+
+  return xaxis;
+                 
+}
+
+// -----------------------------------------------------------------------------
+// 
+// Create the x-axis for the event graph
+//
+Float_t *CreateXaxisErr(Int_t n, Int_t step)
+{
+
+  Float_t *xaxis = new Float_t[n];
+
+  for (Int_t i=0;i<n;i++)
+    xaxis[i] = step/2.;
+
+  return xaxis;
+                 
+}
Index: /tags/Mars_V0-8-5/Mars/macros/pedestalvstime.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/pedestalvstime.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/pedestalvstime.C	(revision 9661)
@@ -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, 6/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+void ProcessFile(TString fname, Int_t idx)
+{
+    //
+    // Create a empty Parameter List and an empty Task List
+    // The tasklist is identified in the eventloop by its name
+    //
+    MParList  plist;
+
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    //
+    // Now setup the tasks and tasklist:
+    // ---------------------------------
+    //
+
+    // First Task: Read file with image parameters
+    // (created with the star.C macro)
+
+    MReadMarsFile read("Events", fname);
+    read.DisableAutoScheme();
+
+    MGeomApply geomapl;
+
+    MCerPhotAnal2 ncalc;
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&geomapl);
+    tlist.AddToList(&ncalc);
+
+    MHPixVsTime hist1(idx, "Pedestal");
+    MHPixVsTime hist2(idx, "PedestalRMS");
+    hist2.SetType(1);
+    plist.AddToList(&hist1);
+    plist.AddToList(&hist2);
+
+    MFillH fill1("Pedestal",    "MPedestalCam");
+    MFillH fill2("PedestalRMS", "MPedestalCam");
+    tlist.AddToList(&fill1);
+    tlist.AddToList(&fill2);
+
+    //
+    // Create and setup the eventloop
+    //
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    //
+    // Execute your analysis
+    //
+    if (!evtloop.Eventloop())
+        return;
+
+    tlist.PrintStatistics();
+
+    TCanvas *c = MH::MakeDefCanvas();
+    c->Divide(2,2);
+
+    c->cd(1);
+    TGraph &g1 = hist1.GetGraph();
+    TH1 *h1 = g1.GetHistogram();
+    h1->SetXTitle("Time [au]");
+    h1->SetYTitle("P [au]");
+    g1.DrawClone("A*");
+
+    c->cd(2);
+    TH1F h1f("Pedestal", "Pedestals", 21, 46, 56);
+    h1f.SetXTitle("P");
+    h1f.SetYTitle("Counts");
+    for (int i=0;i<g1.GetN(); i++)
+        h1f.Fill(g1.GetY()[i]);
+    ((TH1F*)h1f.DrawCopy())->Fit("gaus");
+
+    c->cd(3);
+    TGraph &g2 = hist2.GetGraph();
+    TH1 *h2 = g2.GetHistogram();
+    h2->SetXTitle("Time [au]");
+    h2->SetYTitle("P_{rms} [au]");
+    g2.DrawClone("A*");
+
+    c->cd(4);
+    TH1F h2f("PedestalRMS", "Pedestals RMS", 26, 0, 3.5);
+    h2f.SetXTitle("P_{rms}");
+    h2f.SetYTitle("Counts");
+    for (int i=0;i<g2.GetN(); i++)
+        h2f.Fill(g2.GetY()[i]);
+    ((TH1F*)h2f.DrawCopy())->Fit("gaus");
+
+    c->SaveAs(fname(0, fname.Last('.')+1) + "ps");
+    //c->SaveAs(fname(0, fname.Last('.')+1) + "root");
+}
+
+// -------------------------------------------------------------------------
+//
+//  plot.C
+//
+//  This macro shows how to fill and display a histogram using Mars
+//
+void pedestalvstime(Int_t idx=0, const char *dirname=".")
+{
+    MDirIter Next;
+    Next.AddDirectory(dirname, "raw*.root", -1);
+
+    TString fname;
+    while (1)
+    {
+        fname = Next();
+        if (fname.IsNull())
+            break;
+
+        ProcessFile(fname, idx);
+        return;
+    }
+}
Index: /tags/Mars_V0-8-5/Mars/macros/pedphotcalc.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/pedphotcalc.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/pedphotcalc.C	(revision 9661)
@@ -0,0 +1,541 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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,  01/2004 <mailto:jflix@ifae.es>
+!              Javier Rico,  01/2004 <mailto:jrico@ifae.es>
+!              Markus Gaug,  03/2004 <mailto:markus@ifae.es>
+!
+!   (based on bootcampstandardanalysis.C by Javier López)
+!
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+/////////////////////////////////////////////////////////////////////////////
+//
+//  pedphotcalc.C
+//
+//  This macro is an example of the use of MPedPhotCalc. It computes
+//  the pedestal mean and rms from pedestal files undergoing the
+//  signal extraction + calibration chain, in units of photons. It
+//  produces plots of the relevant computed quantities.
+//
+//  Needs as arguments the run number of a pedestal file ("*_P_*.root"), 
+//  one of a calibration file ("*_C_*.root").
+//  performs the pedestal calculation, the calibration 
+/// constants calculation and the calibration of the pedestals. 
+//
+//  The TString inpath has to be set correctly.
+//
+//  The macro searches for the pulser colour which corresponds to the calibration
+//  run number. If the run number is smaller than 20000, pulser colour "CT1" 
+//  is assumed, otherwise, it searches for the strings "green", "blue", "uv" or 
+//  "ct1" in the filenames. If no colour or multiple colours are found, the 
+//  execution is aborted.  
+//
+////////////////////////////////////////////////////////////////////////////////////
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MJPedestal.h"
+#include "MJCalibration.h"
+#include "MPedestalCam.h"
+#include "MPedestalPix.h"
+#include "MReadMarsFile.h"
+#include "MGeomApply.h"
+#include "MGeomCamMagic.h"
+#include "MEvtLoop.h"
+#include "MCalibrationCam.h"
+#include "MCalibrationChargeCam.h"
+#include "MCalibrationChargePix.h"
+#include "MCalibrationQECam.h"
+#include "MCalibrationQEPix.h"
+#include "MExtractedSignalCam.h"
+#include "MExtractSlidingWindow.h" 
+#include "MExtractFixedWindow.h" 
+#include "MCerPhotEvt.h"
+#include "MCalibrate.h"
+#include "MPedPhotCalc.h"
+#include "MPedPhotCam.h"
+#include "MPedPhotPix.h"
+#include "MHCamera.h"
+#include "MRunIter.h"
+#include "MDirIter.h"
+#include "MStatusDisplay.h"
+#include "MHCamera.h"
+
+#include "TTimer.h"
+#include "TString.h"
+#include "TCanvas.h"
+#include "TStyle.h"
+#include "TF1.h"
+#include "TLegend.h"
+
+#include <iostream.h>
+#include "Getline.h"
+
+const TString inpath = "/mnt/Data/rootdata/CrabNebula/2004_02_10/";
+const Int_t dpedrun  = 14607;
+const Int_t dcalrun1 = 14608;
+const Int_t dcalrun2 = 0;
+const Bool_t usedisplay = kTRUE;
+
+
+
+void DrawProjection(MHCamera *obj1, Int_t fit) 
+{
+    TH1D *obj2 = (TH1D*)obj1->Projection(obj1->GetName());
+    obj2->SetDirectory(0);
+    obj2->Draw();
+    obj2->SetBit(kCanDelete);
+    gPad->SetLogy();
+
+    if (obj1->GetGeomCam().InheritsFrom("MGeomCamMagic"))
+    {
+        TArrayI s0(3);
+        s0[0] = 6;
+        s0[1] = 1;
+        s0[2] = 2;
+
+        TArrayI s1(3);
+        s1[0] = 3;
+        s1[1] = 4;
+        s1[2] = 5;
+
+        TArrayI inner(1);
+        inner[0] = 0;
+
+        TArrayI outer(1);
+        outer[0] = 1;
+
+        // Just to get the right (maximum) binning
+        TH1D *half[4];
+        half[0] = obj1->ProjectionS(s0, inner, "Sector 6-1-2 Inner");
+        half[1] = obj1->ProjectionS(s1, inner, "Sector 3-4-5 Inner");
+        half[2] = obj1->ProjectionS(s0, outer, "Sector 6-1-2 Outer");
+        half[3] = obj1->ProjectionS(s1, outer, "Sector 3-4-5 Outer");
+
+        for (int i=0; i<4; i++)
+        {
+            half[i]->SetLineColor(kRed+i);
+            half[i]->SetDirectory(0);
+            half[i]->SetBit(kCanDelete);
+            half[i]->Draw("same");
+        }
+    }
+
+    const Double_t min   = obj2->GetBinCenter(obj2->GetXaxis()->GetFirst());
+    const Double_t max   = obj2->GetBinCenter(obj2->GetXaxis()->GetLast());
+    const Double_t integ = obj2->Integral("width")/2.5066283;
+    const Double_t mean  = obj2->GetMean();
+    const Double_t rms   = obj2->GetRMS();
+    const Double_t width = max-min;
+
+    if (rms==0 || width==0)
+        return;
+
+    const TString dgausformula("([0]-[3])/[2]*exp(-0.5*(x-[1])*(x-[1])/[2]/[2])"
+                               "+[3]/[5]*exp(-0.5*(x-[4])*(x-[4])/[5]/[5])");
+
+    TF1 *f=0;
+    switch (fit)
+    {
+        // FIXME: MAYBE add function to TH1?
+    case 0:
+        f = new TF1("sgaus", "gaus(0)", min, max);
+        f->SetLineColor(kYellow);
+        f->SetBit(kCanDelete);
+        f->SetParNames("Area", "#mu", "#sigma");
+        f->SetParameters(integ/rms, mean, rms);
+        f->SetParLimits(0, 0,   integ);
+        f->SetParLimits(1, min, max);
+        f->SetParLimits(2, 0,   width/1.5);
+        obj2->Fit(f, "QLRM");
+        break;
+
+    case 1:
+        f = new TF1("dgaus", dgausformula, min, max);
+        f->SetLineColor(kYellow);
+        f->SetBit(kCanDelete);
+        f->SetParNames("A_{tot}", "#mu_{1}", "#sigma_{1}", "A_{2}", "#mu_{2}", "#sigma_{2}");
+        f->SetParameters(integ,         (min+mean)/2, width/4,
+                         integ/width/2, (max+mean)/2, width/4);
+        // The left-sided Gauss
+        f->SetParLimits(0, integ-1.5,      integ+1.5);
+        f->SetParLimits(1, min+(width/10), mean);
+        f->SetParLimits(2, 0,              width/2);
+        // The right-sided Gauss
+        f->SetParLimits(3, 0,    integ);
+        f->SetParLimits(4, mean, max-(width/10));
+        f->SetParLimits(5, 0,    width/2);
+        obj2->Fit(f, "QLRM");
+        break;
+
+    default:
+        obj2->Fit("gaus", "Q");
+        obj2->GetFunction("gaus")->SetLineColor(kYellow);
+        break;
+    }
+}
+
+void CamDraw(TCanvas &c, Int_t x, Int_t y, MHCamera &cam1, Int_t fit)
+{
+    c.cd(x);
+    gPad->SetBorderMode(0);
+    MHCamera *obj1=(MHCamera*)cam1.DrawCopy("hist");
+
+    c.cd(x+y);
+    gPad->SetBorderMode(0);
+    obj1->Draw();
+
+    c.cd(x+2*y);
+    gPad->SetBorderMode(0);
+    DrawProjection(obj1, fit);
+}
+
+void pedphotcalc(const Int_t prun=dpedrun, // pedestal file
+                 const Int_t crun1=dcalrun1, const Int_t crun2=dcalrun2 // calibration file(s)
+                 )
+{
+
+  MExtractFixedWindow extractor;
+  
+  MRunIter pruns;
+  MRunIter cruns;
+
+  pruns.AddRun(prun,inpath);
+
+  if (crun2==0)
+    cruns.AddRun(crun1,inpath);
+  else
+    cruns.AddRuns(crun1,crun2,inpath);
+
+  //
+  // Now setup the tasks and tasklist for the pedestals:
+  // ---------------------------------------------------
+  //
+  MGeomCamMagic     geomcam;
+  MGeomApply        geomapl;
+  MStatusDisplay   *display = NULL;
+
+  /************************************/
+  /* FIRST LOOP: PEDESTAL COMPUTATION */
+  /************************************/
+  
+  MJPedestal pedloop;
+  pedloop.SetInput(&pruns);
+  if (usedisplay)
+    {
+      display = new MStatusDisplay;
+      display->SetUpdateTime(3000);
+      display->Resize(850,700);
+      display->SetBit(kCanDelete);
+      pedloop.SetDisplay(display);
+    }
+  
+  cout << "*************************" << endl;
+  cout << "** COMPUTING PEDESTALS **" << endl;
+  cout << "*************************" << endl;
+
+  if (!pedloop.Process())
+    return;
+
+  MPedestalCam pedcam = pedloop.GetPedestalCam();
+
+  /****************************/
+  /* SECOND LOOP: CALIBRATION */
+  /****************************/
+  
+  //
+  // Now setup the new tasks for the calibration:
+  // ---------------------------------------------------
+  //
+  MJCalibration     calloop;
+  calloop.SetInput(&cruns);
+  //
+  // Use as signal extractor MExtractSignal:
+  //
+  calloop.SetExtractor(&extractor);
+  //
+  // The next two commands are for the display:
+  //
+  if (usedisplay)
+    {
+      calloop.SetDisplay(display);
+      calloop.SetDataCheck();
+    }
+  
+  cout << "***********************************" << endl;
+  cout << "** COMPUTING CALIBRATION FACTORS **" << endl;
+  cout << "***********************************" << endl;
+
+  if (!calloop.Process(pedcam))
+    return;
+  
+  MCalibrationChargeCam &calcam = calloop.GetCalibrationCam();
+  MCalibrationQECam     &qecam  = calloop.GetQECam();
+
+  /************************************************************************/
+  /* THIRD LOOP: PEDESTAL COMPUTATION USING EXTRACTED SIGNAL (IN PHOTONS) */
+  /************************************************************************/
+  
+  // Create an empty Parameter List and an empty Task List
+  MParList  plist3;  
+  MTaskList tlist3;
+  plist3.AddToList(&tlist3);
+
+  // containers
+  MCerPhotEvt    photcam;
+  MPedPhotCam    pedphotcam;
+  MExtractedSignalCam extedsig;
+  
+  plist3.AddToList(&geomcam);
+  plist3.AddToList(&pedcam );
+  plist3.AddToList(&calcam );
+  plist3.AddToList(&qecam  );
+  plist3.AddToList(&photcam);
+  plist3.AddToList(&extedsig);
+  plist3.AddToList(&pedphotcam);
+  
+  //tasks
+  MReadMarsFile read3("Events");
+  read3.DisableAutoScheme();
+  static_cast<MRead&>(read3).AddFiles(pruns);  
+
+  MCalibrate      photcalc;
+  photcalc.SetCalibrationMode(MCalibrate::kFfactor);
+  MPedPhotCalc    pedphotcalc;  
+
+  tlist3.AddToList(&read3);
+  tlist3.AddToList(&geomapl);
+  tlist3.AddToList(&extractor);
+  tlist3.AddToList(&photcalc);
+  tlist3.AddToList(&pedphotcalc);
+  
+  // Create and execute eventloop
+  MEvtLoop evtloop3;
+  evtloop3.SetParList(&plist3);
+    
+  cout << "*************************************************************" << endl;
+  cout << "** COMPUTING PEDESTALS USING EXTRACTED SIGNAL (IN PHOTONS) **" << endl;
+  cout << "*************************************************************" << endl;
+  
+  if (!evtloop3.Eventloop())  
+    return;  
+  tlist3.PrintStatistics();
+
+  /**********************/
+  /* PRODUCE NICE PLOTS */
+  /**********************/
+
+  if (usedisplay)
+    {
+      
+      MHCamera disp0(geomcam, "MPedPhotCam;ped", "Pedestals");
+      MHCamera disp1(geomcam, "MPedPhotCam;rms", "Sigma Pedestal");
+      
+      disp0.SetCamContent(pedphotcam, 0);
+      disp0.SetCamError  (pedphotcam, 1);
+      
+      disp1.SetCamContent(pedphotcam, 1);
+      
+      disp0.SetYTitle("Pedestal signal [photons]");
+      disp1.SetYTitle("Pedestal signal RMS [photons]");
+      
+      //
+      // Display data
+      //
+      TCanvas &c1 = display->AddTab("PedPhotCam");
+      c1.Divide(2,3);
+      
+      CamDraw(c1, 1, 2, disp0, 0);
+      CamDraw(c1, 2, 2, disp1, 1);
+      
+    }
+  
+
+#if 0
+  const UShort_t npix = 577;
+
+  // declare histograms
+  // pedestals
+  TH1F* pedhist    = new TH1F("pedhist","Pedestal",npix,0,npix);
+  TH1F* pedrmshist = new TH1F("pedrmshist","Pedestal RMS",npix,0,npix);
+  TH1F* peddist    = new TH1F("peddist","Pedestal",100,0,20);
+  TH1F* pedrmsdist = new TH1F("pedrmsdist","Pedestal RMS",100,0,15);
+  
+  // calibration factors
+  TH1F* calhist    = new TH1F("calhist","Calibration factors",npix,0,npix);
+  TH1F* caldist    = new TH1F("caldist","Calibration factors",100,0,1);
+  TH1F* qehist     = new TH1F("qehist", "Quantrum efficiencies",npix,0,npix);
+  TH1F* qedist     = new TH1F("qedist", "Quantrum efficiencies",100,0,1);
+
+  // pedestal signals
+  TH1F* pedphothist    = new TH1F("pedphothist","Pedestal Signal",npix,0,npix);
+  TH1F* pedphotrmshist = new TH1F("pedphotrmshist","Pedestal Signal RMS",npix,0,npix);
+  TH1F* pedphotdist    = new TH1F("pedphotdist","Pedestal Signal",100,-0.4,0.4);
+  TH1F* pedphotrmsdist = new TH1F("pedphotrmsdist","Pedestal Signal RMS",100,0,25);
+
+  // fill histograms
+  for(int i=0;i<npix;i++)
+    {
+      MCalibrationChargePix &calpix = (MCalibrationChargePix&)calcam[i];
+      MCalibrationQEPix     &qepix  = (MCalibrationQEPix&)    qecam[i];
+
+      const Float_t ped        = pedcam[i].GetPedestal();
+      const Float_t pedrms     = pedcam[i].GetPedestalRms();
+      const Float_t cal        = calpix.GetMeanConvFADC2Phe();
+      const Float_t qe         = qepix .GetQECascadesFFactor();
+      const Float_t pedphot    = pedphotcam[i].GetMean();
+      const Float_t pedphotrms = pedphotcam[i].GetRms();
+
+      pedhist->Fill(i,ped);
+      peddist->Fill(ped);
+      pedrmshist->Fill(i,pedrms);
+      pedrmsdist->Fill(pedrms);
+
+      calhist->Fill(i,cal);
+      caldist->Fill(cal);
+      qehist->Fill(i,qe);
+      qedist->Fill(qe);
+
+      pedphothist->Fill(i,pedphot);
+      pedphotdist->Fill(pedphot);
+      pedphotrmshist->Fill(i,pedphotrms);
+      pedphotrmsdist->Fill(pedphotrms);
+    }
+
+  // Draw
+  gROOT->Reset();
+  gStyle->SetCanvasColor(0);
+  TCanvas* canvas = new TCanvas("canvas","pedphotcalc.C", 0, 100, 650, 800);
+  canvas->SetBorderMode(0);    // Delete the Canvas' border line     
+  canvas->cd();
+
+  canvas->Divide(2,5);
+
+  // draw pedestal histo
+  canvas->cd(1);
+  gPad->cd();
+  gPad->SetBorderMode(0);
+
+  pedhist->SetStats(kFALSE);
+  pedhist->GetXaxis()->SetTitle("Pixel SW Id");
+  pedhist->GetYaxis()->SetTitle("Pedestal (ADC counts)");
+  pedrmshist->SetStats(kFALSE);
+  pedrmshist->SetLineColor(2);
+  pedhist->Draw();
+  pedrmshist->Draw("same");
+
+  TLegend* leg1 = new TLegend(.14,.68,.39,.88);
+  leg1->SetHeader("");
+  leg1->AddEntry(pedhist,"Pedestal","L");
+  leg1->AddEntry(pedrmshist,"Pedestal RMS","L");
+  leg1->SetFillColor(0);
+  leg1->SetLineColor(0);
+  leg1->SetBorderSize(0);
+  leg1->Draw();
+     
+  // draw pedestal distribution
+  canvas->cd(2);
+  gPad->cd();
+  gPad->SetBorderMode(0);
+  peddist->GetXaxis()->SetTitle("Pedestal (ADC counts)");
+  pedrmsdist->SetLineColor(2);
+  peddist->Draw();
+  pedrmsdist->Draw("same");
+
+  TLegend* leg2 = new TLegend(.14,.68,.39,.88);
+  leg2->SetHeader("");
+  leg2->AddEntry(pedhist,"Pedestal","L");
+  leg2->AddEntry(pedrmshist,"Pedestal RMS","L");
+  leg2->SetFillColor(0);
+  leg2->SetLineColor(0);
+  leg2->SetBorderSize(0);
+  leg2->Draw();
+
+  // draw calibration histo
+  canvas->cd(3);
+  gPad->cd();
+  gPad->SetBorderMode(0);
+  calhist->GetXaxis()->SetTitle("Pixel SW Id");
+  calhist->SetMaximum(1);
+  calhist->SetMinimum(0);
+  calhist->GetYaxis()->SetTitle("Calibration factor (phe/ADC count)");
+  calhist->SetStats(kFALSE);
+  calhist->Draw();
+
+  // draw calibration distribution
+  canvas->cd(4);
+  gPad->cd();
+  gPad->SetBorderMode(0);
+  caldist->GetXaxis()->SetTitle("Calibration factor (phe/ADC count)");
+  caldist->Draw();
+
+  // draw qe histo
+  canvas->cd(5);
+  gPad->cd();
+  gPad->SetBorderMode(0);
+  qehist->GetXaxis()->SetTitle("Pixel SW Id");
+  qehist->SetMaximum(1);
+  qehist->SetMinimum(0);
+  qehist->GetYaxis()->SetTitle("Quantum efficiency for cascades");
+  qehist->SetStats(kFALSE);
+  qehist->Draw();
+
+  // draw qe distribution
+  canvas->cd(6);
+  gPad->cd();
+  gPad->SetBorderMode(0);
+  qedist->GetXaxis()->SetTitle("Quantum efficiency for cascades");
+  qedist->Draw();
+
+  // draw pedestal signal histo
+  canvas->cd(7);
+  gPad->cd();
+  gPad->SetBorderMode(0);
+  pedphothist->GetXaxis()->SetTitle("Pixel SW Id");
+  pedphothist->GetYaxis()->SetTitle("Pedestal signal (photons)");
+  pedphothist->SetStats(kFALSE);
+  pedphothist->Draw();
+
+  // draw pedestal signal distribution
+  canvas->cd(8);
+  gPad->cd();
+  gPad->SetBorderMode(0);
+  pedphotdist->GetXaxis()->SetTitle("Pedestal signal (photons)");
+  pedphotdist->Draw();
+
+  // draw pedestal signal rms histo
+  canvas->cd(9);
+  gPad->cd();
+  gPad->SetBorderMode(0);
+  pedphotrmshist->GetXaxis()->SetTitle("Pixel SW Id");
+  pedphotrmshist->GetYaxis()->SetTitle("Pedestal signal rms (photons)");
+  pedphotrmshist->SetStats(kFALSE);
+  pedphotrmshist->Draw();
+
+  // draw pedestal signal rms distribution
+  canvas->cd(10);
+  gPad->cd();
+  gPad->SetBorderMode(0);
+  pedphotrmsdist->GetXaxis()->SetTitle("Pedestal signal rms (photons)");
+  pedphotrmsdist->Draw();
+
+  canvas->SaveAs("pedphotcalc.root");
+
+#endif
+}
Index: /tags/Mars_V0-8-5/Mars/macros/pedvsevent.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/pedvsevent.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/pedvsevent.C	(revision 9661)
@@ -0,0 +1,214 @@
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// Author(s): S.C. Commichau,  Javier Rico, 12/2003                        //
+//                                                                         //
+// Macro to generate pedestal vs time (event) plot for a single pixel      //
+//                                                                         // 
+/////////////////////////////////////////////////////////////////////////////
+
+
+const Int_t default_pixel = 1 ;
+
+void pedvsevent(Int_t pixel = default_pixel, 
+		TString pname = "/disc02/Data/rootdata/Miscellaneous/2003_11_29/20031128_03118_P_Park-camera-closed_E.root")
+{
+
+    TH1F* Pedestal    = new TH1F("Pedestal","Pedestals",100,0,20);
+    TH1F* PedestalRMS = new TH1F("PedestalRMS","Pedestal RMS",100,0,10);
+  
+    //Create an empty parameter list and an empty task list
+    //the tasklist is identified in the eventloop by ist name
+    MParList       plist;
+    MTaskList      tlist;
+
+    //Creates a MPedestalPix object for each pixel, i.e. it is a
+    //storage container for all Pedestal information in the camera
+    MPedestalCam   cam;  
+  
+    plist.AddToList(&cam);
+
+    //MHCamEvent hist;
+    //hist.SetType(1);
+    //plist.AddToList(&hist);
+
+    plist.AddToList(&tlist);
+
+    //Setup task and tasklist for the pedestals
+    MReadMarsFile read("Events", pname);
+    read.DisableAutoScheme();
+
+    //Apply the geometry to geometry dependant containers.
+    //MGeomApply changes the size of the arrays in the containers to a size
+    //matching the number of pixels, eg: MPedestalCam, MBlindPixels
+    //Default geometry is MGeomCamMagic
+    MGeomApply      geomapl;
+   
+    //Task to calculate pedestals
+    MPedCalcPedRun  ped;
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&geomapl);
+    tlist.AddToList(&ped); 
+
+    //ped.SetPixel(pixel);
+    //ped.Draw();
+
+    //Create and setup the 1st Eventloop  
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    //Execute first analysis, pedestals...
+     if (!tlist.PreProcess(&plist))
+         return;
+
+     const Int_t nevents = read.GetEntries();
+
+     Float_t x[nevents], rms[nevents], mean[nevents];
+
+
+     Int_t i = 0;     
+     while (tlist.Process())
+     {
+	 mean[i] = cam[pixel].GetPedestal();
+         rms[i] = cam[pixel].GetPedestalRms();
+         x[i] = i;
+	 i++; 
+     }
+
+     TGraphErrors* pedgraph = new TGraphErrors(nevents,x,mean,NULL,NULL);
+     TGraphErrors* rmsgraph = new TGraphErrors(nevents,x,rms,NULL,NULL);
+
+	 //plist.FindObject("MPedestalCam")->Print();
+    
+     tlist.PostProcess(); 
+     //if (!evtloop.Eventloop())
+     // return;
+
+     Float_t finalmean = cam[pixel].GetPedestal();
+     Float_t finalrms = cam[pixel].GetPedestalRms();
+   
+     TLine* pedline = new TLine(0,finalmean,nevents,finalmean);
+     TLine* rmsline = new TLine(0,finalrms,nevents,finalrms);
+    
+     //The draw area
+     
+
+
+     gROOT->Reset();
+     gStyle->SetOptStat(0);
+     // Set statistics options, 1111111
+     //                         |||||||
+     //                         ||||||histogram name
+     //                         |||||number of entries
+     //                         ||||mean value
+     //                         |||RMS
+     //                         ||underflows
+     //                         |overflows
+     //                         sum of bins
+     
+     // Set gPad options
+     gStyle->SetFrameBorderMode(0);
+     gStyle->SetPalette(1);
+     // Delete Frames of subCanvas' does not work, hook it Mr. gPad!
+     gStyle->SetFrameBorderSize(0);
+     gStyle->SetCanvasColor(0);
+     gStyle->SetFrameFillColor(0);
+     gStyle->SetTitleFont(102);
+     gStyle->SetTitleFillColor(0);
+     gStyle->SetTitleBorderSize(0);
+     gStyle->SetStatColor(0);
+     gStyle->SetStatBorderSize(0);
+     
+     // Set Canvas options
+     TCanvas *MyC1 = new TCanvas("MyC","Pedestal vs Event", 0, 100, 900, 500);
+     MyC->SetBorderMode(0);    // Delete the Canvas' border line
+     
+     MyC->cd();
+     gPad->SetBorderMode(0);
+     
+     //  TLine* pedline = new TLine(0,finalmean,nevents,finalmean);
+     //TLine* rmsline = new TLine(0,finalrms,nevents,finalrms);
+     
+     tlist.PrintStatistics();
+     //plist.FindObject("MPedestalCam")->Print();
+     Size_t pos = pname.Last('/')+10;
+     TString iRun = TString(pname(pos,5));
+     
+     char str[64];
+     
+     sprintf(str,"Run %s Pixel %d",iRun.Data(),pixel);
+     
+     pedgraph->SetMaximum(30);
+     pedgraph->SetMinimum(0);
+     pedgraph->SetMarkerStyle(24);
+     pedgraph->SetMarkerSize(.5);
+     pedgraph->GetXaxis()->SetTitleFont(102);
+     pedgraph->GetYaxis()->SetTitleFont(102);
+     pedgraph->GetXaxis()->SetLabelFont(102);
+     pedgraph->GetYaxis()->SetLabelFont(102);
+     pedgraph->SetTitle(str); 
+//     pedgraph->SetTitleFont(102);
+     pedgraph->GetYaxis()->SetTitleFont(102);
+     pedgraph->GetXaxis()->SetTitle("Event");
+     pedgraph->GetYaxis()->SetTitle("[FADC Counts]");
+     pedgraph->GetXaxis()->SetLimits(0,nevents-1);
+     
+     rmsgraph->SetMarkerStyle(25);
+     rmsgraph->SetMarkerSize(.5);
+     rmsgraph->SetMarkerColor(8);
+
+     pedline->SetLineColor(2);
+     rmsline->SetLineColor(4);
+     pedline->SetLineWidth(2);
+     rmsline->SetLineWidth(2);
+
+     pedgraph->Draw("AP");
+     rmsgraph->Draw("P");
+     
+     pedline->Draw("same");
+     rmsline->Draw("same");
+     
+     TLegend* leg = new TLegend(.14,.68,.39,.88);
+     leg->SetHeader("");
+     leg->AddEntry(pedgraph,"Event based Pedestal","P");
+     leg->AddEntry(pedline,"Run based Pedestal","L");
+     leg->AddEntry(rmsgraph,"Event based RMS","P");
+     leg->AddEntry(rmsline,"Run based RMS","L");
+     leg->SetFillColor(0);
+     leg->SetLineColor(1);
+     leg->SetBorderSize(1);
+
+
+     leg->Draw("same");
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/macros/pixfirerate.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/pixfirerate.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/pixfirerate.C	(revision 9661)
@@ -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): Abelardo Moralejo <mailto:moralejo@pd.infn.it>
+!   Author(s): Thomas Bretz <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// pixfirerate.C
+// =============
+//
+// This macro can help to  find "hot" pixels firing too often
+// or pixels firing too rarely. It plots camera displays showing how many 
+// times the FADC integral of each pixel has been found to be above pedestal
+// by 10, 20, 50, 100 or 200 ADC counts. As "pedestal"  we now use simply 
+// the signal in the first ADC slice, which seemed reasonable from a first
+// look at the available test data.
+//
+/////////////////////////////////////////////////////////////////////////////
+
+void pixfirerate(TString filename="rawfile.root")
+{
+    //
+    // Update frequency by default = 1Hz
+    //
+    MStatusDisplay *d = new MStatusDisplay;
+
+    // Set update time to 5s
+    // d->SetUpdateTime(5000);
+
+    // Disable online update
+    // d->SetUpdateTime(-1);
+
+    d->SetLogStream(&gLog, kTRUE); // Disables output to stdout
+    gLog.SetOutputFile("status.log", kTRUE); // Enable output to file
+    //gLog.EnableOutputDevice(MLog::eStdout); // Enable output to stdout again
+
+    //
+    // Create a empty Parameter List and an empty Task List
+    // The tasklist is identified in the eventloop by its name
+    //
+    MTaskList tlist;
+    MParList  plist;
+    plist.AddToList(&tlist);
+
+    //
+    // Now setup the tasks and tasklist:
+    // ---------------------------------
+    //
+    MReadMarsFile read("Events");
+    read.DisableAutoScheme();
+    read.AddFile(filename);
+    tlist.AddToList(&read);
+
+    MGeomApply geomapl;
+    tlist.AddToList(&geomapl);
+
+    // A list of threshold which should be displayed. The last entry
+    // MUST be -1.
+    Double_t threshold[] = { 10, 20, 100, 200, -1 };
+
+    Int_t cnt = 0;
+    while (threshold[cnt]>0) cnt++;
+
+    // Create the corresponding fill tasks and containers
+    for (int i=0; i<cnt; i++)
+    {
+        TString name = "Above ";
+        TString num;
+        num += threshold[i];
+        name += num.Strip(TString::kBoth);
+        TString title = "Firerate [%] of pixels with signal > ";
+        title += num.Strip(TString::kBoth);
+
+        MHTriggerLvl0 *trigmap = new MHTriggerLvl0(threshold[i], name, title);
+        MFillH *fillh = new MFillH(trigmap, "MRawEvtData");
+        trigmap->SetBit(kCanDelete);
+        fillh->SetBit(kCanDelete);
+        plist.AddToList(trigmap);
+        tlist.AddToList(fillh);
+    }
+
+    // create the eventloop
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+    evtloop.SetDisplay(d);
+
+    //
+    // Execute your analysis
+    //
+    if (!evtloop.Eventloop())
+        return;
+
+    tlist.PrintStatistics();
+
+    //
+    // Make sure the display hasn't been deleted by the user while the
+    // eventloop was running.
+    //
+    if ((d = evtloop.GetDisplay()))
+    {
+        // Save data in a postscriptfile (status.ps)
+        d->SaveAsPS();
+        /*
+         * ----------- Write status to a root file ------------
+         *
+         TFile file("status.root", "RECREATE");
+         d->Write();
+         file.Close();
+         delete d;
+         */
+    }
+
+}
Index: /tags/Mars_V0-8-5/Mars/macros/pixsatrate.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/pixsatrate.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/pixsatrate.C	(revision 9661)
@@ -0,0 +1,120 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Abelardo Moralejo <mailto:moralejo@pd.infn.it>
+!   Author(s): Thomas Bretz <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// pixfirerate.C
+// =============
+//
+// This macro can help to  find "hot" pixels firing too often
+// or pixels firing too rarely. It plots camera displays showing how many 
+// times the FADC integral of each pixel has been found to be above pedestal
+// by 10, 20, 50, 100 or 200 ADC counts. As "pedestal"  we now use simply 
+// the signal in the first ADC slice, which seemed reasonable from a first
+// look at the available test data.
+//
+/////////////////////////////////////////////////////////////////////////////
+
+void pixsatrate(TString filename="rawfile.root")
+{
+    //
+    // Update frequency by default = 1Hz
+    //
+    MStatusDisplay *d = new MStatusDisplay;
+
+    // Set update time to 5s
+    // d->SetUpdateTime(5000);
+
+    // Disable online update
+    // d->SetUpdateTime(-1);
+
+    d->SetLogStream(&gLog, kTRUE); // Disables output to stdout
+    gLog.SetOutputFile("status.log", kTRUE); // Enable output to file
+    //gLog.EnableOutputDevice(MLog::eStdout); // Enable output to stdout again
+
+    //
+    // Create a empty Parameter List and an empty Task List
+    // The tasklist is identified in the eventloop by its name
+    //
+    MTaskList tlist;
+    MParList  plist;
+    plist.AddToList(&tlist);
+
+    //
+    // Now setup the tasks and tasklist:
+    // ---------------------------------
+    //
+    MReadMarsFile read("Events");
+    read.DisableAutoScheme();
+    read.AddFile(filename);
+    tlist.AddToList(&read);
+
+    MGeomApply geomapl;
+    tlist.AddToList(&geomapl);
+
+    // Create histograms with saturation limits at 254
+    MHTriggerLvl0 trighi(254, "SaturationHi", "Saturation Rate of Hi Gains");
+    MHTriggerLvl0 triglo(254, "SaturationLo", "Saturation Rate of Lo Gains");
+    trighi.SetType(1);
+    triglo.SetType(2);
+
+    // craete fill tasks to fill the histogarms
+    MFillH fillhi(&trighi, "MRawEvtData");
+    MFillH filllo(&triglo, "MRawEvtData");
+    tlist.AddToList(&fillhi);
+    tlist.AddToList(&filllo);
+
+    // create eventloop
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+    evtloop.SetDisplay(d);
+
+    //
+    // Execute your analysis
+    //
+    if (!evtloop.Eventloop())
+        return;
+
+    tlist.PrintStatistics();
+
+    //
+    // Make sure the display hasn't been deleted by the user while the
+    // eventloop was running.
+    //
+    if ((d = evtloop.GetDisplay()))
+    {
+        // Save data in a postscriptfile (status.ps)
+        d->SaveAsPS();
+        /*
+         * ----------- Write status to a root file ------------
+         *
+         TFile file("status.root", "RECREATE");
+         d->Write();
+         file.Close();
+         delete d;
+         */
+    }
+
+}
Index: /tags/Mars_V0-8-5/Mars/macros/plot.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/plot.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/plot.C	(revision 9661)
@@ -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, 5/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Rudy Bock, 5/2002 <mailto:rkb@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////////
+//
+//  plot.C
+//  ======
+//
+//  This macro shows how to fill and display a histogram using Mars
+//
+//  The advantage of using Mars histograms instead of root-trees is that
+//  you can fill values in your histogram which is calculated in the
+//  eventloop.
+//
+//  In this particular sample we fill a histogram with the size parameter
+//  of gammas and one with hadron's size. At the end we display both in a
+//  single plot.
+//
+//  The input is a star-macro already conatining image parameters.
+//
+///////////////////////////////////////////////////////////////////////////
+
+void plot()
+{
+    // Create a status display for graphical output
+    MStatusDisplay *d = new MStatusDisplay;
+    d->SetLogStream(&gLog);
+
+    //
+    // Create a empty Parameter List and an empty Task List
+    // The tasklist is identified in the eventloop by its name
+    //
+    MParList  plist;
+
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    //
+    // Now setup the tasks and tasklist:
+    // ---------------------------------
+    //
+
+    // First Task: Read file with image parameters
+    // (created with the star.C macro)
+    MReadMarsFile  read("Events", "MC_OFF1.root");
+    read.AddFile("MC_ON1.root");
+    read.DisableAutoScheme();
+    tlist.AddToList(&read);
+
+    // Create a filter for Gammas
+    MFParticleId fgamma("MMcEvt", '=', MMcEvt::kGAMMA);
+    tlist.AddToList(&fgamma);
+
+    // Create a filter for Non-Gammas
+    MFParticleId fhadrons("MMcEvt", '!', MMcEvt::kGAMMA);
+    tlist.AddToList(&fhadrons);
+
+    // -------------------------------------------------------
+    //
+    // set the name of the variable to plot and the binning
+    //
+    TString var("Hillas.fSize");
+
+    MBinning bins("BinningMH3X");
+    bins.SetEdgesLog(50, 100, 20000);
+    plist.AddToList(&bins);
+    //
+    // -------------------------------------------------------
+
+    // Create a histogram for the data from gammas and from non-gammas
+    MH3 h3g(var);
+    MH3 h3h(var);
+
+    // Add the histograms to the parameter container list
+    plist.AddToList(&h3g);
+    plist.AddToList(&h3h);
+
+    // Create a task which fills one histogram with the gamma-data
+    MFillH fillg(&h3g);
+    fillg.SetFilter(&fgamma);
+    tlist.AddToList(&fillg);
+
+    // Create a task which fills the other histogram with the non-gamma-data
+    MFillH fillh(&h3h);
+    fillh.SetFilter(&fhadrons);
+    tlist.AddToList(&fillh);
+
+    //
+    // Create and setup the eventloop
+    //
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    //
+    // Execute your analysis
+    //
+    evtloop.SetDisplay(d);
+    if (!evtloop.Eventloop())
+        return;
+
+    tlist.PrintStatistics();
+
+    // Create a pad, check if MStatusDisplay was not closed meanwhile
+    if (evtloop.GetDisplay())
+        d->AddTab("Size");
+    else
+        MH::MakeDefCanvas("Plot");
+
+    // x-axis to logarithmic scale
+    gPad->SetLogx();
+
+    // Setup some style options of the two histograms
+    // and draw a copy of both
+    h3h.GetHist().SetLineColor(kRed);
+    MH::DrawCopy(h3h.GetHist(), h3g.GetHist(), "Size");
+
+    // Now create a new histogram, fill it with the division of the
+    // two histograms and draw also a copy of it
+    TH1D h;
+    MH::SetBinning(&h, &bins);
+    h.Divide(&h3g.GetHist(), &h3h.GetHist());
+    h.SetLineColor(kGreen);
+    h.DrawCopy("same");
+}
Index: /tags/Mars_V0-8-5/Mars/macros/plot2.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/plot2.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/plot2.C	(revision 9661)
@@ -0,0 +1,154 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 5/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Rudy Bock, 5/2002 <mailto:rkb@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////////
+//
+//  plot2.C
+//  =======
+//
+//  This macro shows how to fill and display a histogram using Mars
+//
+//  The advantage of using Mars histograms instead of root-trees is that
+//  you can fill values in your histogram which is calculated in the
+//  eventloop.
+//
+//  In this particular sample we fill a histogram with width vs length
+//  of gammas and hadrons. At the end we display both in a single plot.
+//
+//  The input is a star-macro already conatining image parameters.
+//
+///////////////////////////////////////////////////////////////////////////
+
+void plot2()
+{
+    //
+    // Create a empty Parameter List and an empty Task List
+    // The tasklist is identified in the eventloop by its name
+    //
+    MParList  plist;
+
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    //
+    // Now setup the tasks and tasklist:
+    // ---------------------------------
+    //
+
+    // First Task: read in a file created with star.C
+    MReadMarsFile  read("Events", "star.root");
+    read.DisableAutoScheme();
+    tlist.AddToList(&read);
+
+    // Create a filter for the gamma events
+    MFParticleId fgamma("MMcEvt", '=', MMcEvt::kGAMMA);
+    tlist.AddToList(&fgamma);
+
+    // Create a filter for the non-gamma events
+    MFParticleId fhadrons("MMcEvt", '!', MMcEvt::kGAMMA);
+    tlist.AddToList(&fhadrons);
+
+    // -------------------------------------------------------
+    //
+    // set the name of the variable to plot and the binning
+    //
+    MGeomCamMagic cam;
+    plist.AddToList(&cam);
+
+    // Set the variables (converted to deg)
+    TString vary("MHillas.fWidth*MGeomCam.fConvMm2Deg");
+    TString varx("MHillas.fLength*MGeomCam.fConvMm2Deg");
+
+    // Set the binning
+    MBinning binsy("BinningMH3Y");
+    MBinning binsx("BinningMH3X");
+    binsy.SetEdges(11, 0, 0.3);
+    binsx.SetEdges(11, 0, 0.6);
+    plist.AddToList(&binsx);
+    plist.AddToList(&binsy);
+    //
+    // -------------------------------------------------
+
+    // Create two 2D histograms and add them to the list
+    MH3 h3g(varx, vary);
+    MH3 h3h(varx, vary);
+
+    plist.AddToList(&h3g);
+    plist.AddToList(&h3h);
+
+    // Create a task to fill one histogram with the gamma data
+    MFillH fillg(&h3g);
+    fillg.SetFilter(&fgamma);
+    tlist.AddToList(&fillg);
+
+    // Create a task to fill the other one with the non gamma data
+    MFillH fillh(&h3h);
+    fillh.SetFilter(&fhadrons);
+    tlist.AddToList(&fillh);
+
+    //
+    // Create and setup the eventloop
+    //
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    //
+    // Execute your analysis
+    //
+    MProgressBar bar;
+    evtloop.SetProgressBar(&bar);
+    if (!evtloop.Eventloop())
+        return;
+
+    tlist.PrintStatistics();
+
+    // Create a default canvas
+    MH::MakeDefCanvas("Plot");
+
+    // setup some style options
+    h3h.GetHist().SetMarkerColor(kRed);
+    h3h.GetHist().SetLineColor(kRed);
+    h3h.GetHist().SetFillStyle(4000);
+
+    // show a contour plot of both histograms
+    h3h.GetHist().DrawCopy("cont3");
+    h3g.GetHist().DrawCopy("cont3same");
+
+    return;
+
+    //
+    // Use this (or something similar) if you want to plot the profile
+    // histograms
+    //
+    TProfile *p = ((TH2&)h3g.GetHist()).ProfileX();
+    p->Draw("same");
+    p->SetBit(kCanDelete);
+
+    TProfile *p = ((TH2&)h3h.GetHist()).ProfileX();
+    p->SetLineColor(kRed);
+    p->SetFillStyle(4000);
+    p->Draw("same");
+    p->SetBit(kCanDelete);
+}
Index: /tags/Mars_V0-8-5/Mars/macros/pointing.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/pointing.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/pointing.C	(revision 9661)
@@ -0,0 +1,462 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 5/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// pointing.C
+// ==========
+//
+// This macro is a demonstartion how check plots for a subsystem
+// (here the drive) can be made using Mars.
+//
+// In this case a merpped (root-) cc-report file is read in. The data
+// of the Drive branch is extracted using MReadReports and the
+// Stream-Id feature of MTaskList (second argument in AddToList).
+//
+// The output are plots showing (hopefully) the peformance of the system.
+//
+/////////////////////////////////////////////////////////////////////////////
+
+/*
+ class MGraph : public TGraph
+{
+public:
+    MGraph() : TGraph() {}
+    MGraph(Int_t n) : TGraph(n) {}
+    MGraph(Int_t n, const Int_t *x, const Int_t *y) : TGraph(n, x, y) {}
+    MGraph(Int_t n, const Float_t *x, const Float_t *y) : TGraph(n, x, y) {}
+    MGraph(Int_t n, const Double_t *x, const Double_t *y) : TGraph(n, x, y) {}
+    MGraph(const TVector  &vx, const TVector  &vy) : TGraph(vx, vy) {}
+    MGraph(const TVectorD &vx, const TVectorD &vy) : TGraph(vx, vy) {}
+    MGraph(const TH1 *h) : TGraph(h) {}
+    MGraph(const TF1 *f, Option_t *option="") : TGraph(f, option) {}
+    MGraph(const char *filename, const char *format="%lg %lg", Option_t *option="") : TGraph(filename, format, option) {}
+
+    void Paint(Option_t *o="")
+    {
+        if (!strstr(option,"POL") && !strstr(option,"pol"))
+        {
+            TGraph::Paint(o);
+            return;
+        }
+
+        //gPad->Range(-1.15, -1, 1.15, 1);
+
+        //gPad->Modified();
+        //gPad->Update();
+
+        TView *view = gPad->GetView();
+        if (!view)
+        {
+            cout << "No View!" << endl;
+            return;
+        }
+
+        TGraph gr;
+
+        Double_t *zd=g1->GetY();
+        Double_t *az=g2->GetY();
+
+        TMarker m;
+        m.SetMarkerStyle(kFullDotMedium);
+        m.SetMarkerColor(kRed);
+
+        for (int i=0; i<fN; i++)
+        {
+            const Double_t x = fX[i]/90;
+            const Double_t y = (fY[i]/180+1)*TMath::Pi();
+
+            Double_t r0[3] = { y*cos(x), y*sin(x), 0};
+            Double_t r1[3];
+
+            //gr.SetPoint(gr.GetN(), r0[0], r0[1]);
+
+            view->WCtoNDC(x, y);
+
+            m->PaintMarker(r1[0], r1[1]);
+        }
+    }
+};*/
+
+void pointing()
+{
+    MStatusDisplay *d = new MStatusDisplay;
+    d->SetLogStream(&gLog, kTRUE);
+
+    //
+    // Create a empty Parameter List and an empty Task List
+    // The tasklist is identified in the eventloop by its name
+    //
+    MParList  plist;
+
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    //
+    // Now setup the tasks and tasklist:
+    // ---------------------------------
+    //
+
+    // First Task: Read file with image parameters
+    // (created with the star.C macro)
+    MReadReports read;
+    read.AddTree("Drive");
+    read.AddFile("data/2004_01_26_report.root");
+    read.AddToBranchList("MReportDrive.*");
+
+    MContinue tracking("MReportDrive.fState<3.5");
+
+    // Create a task which fills one histogram with the data
+    //MHVsTime h0("MReportDrive.fMjd");
+    MHVsTime h1("MReportDrive.fNominalZd");
+    MHVsTime h2("MReportDrive.fNominalAz");
+    MHVsTime h3("MReportDrive.fState");
+    MHVsTime h7("MReportDrive.GetAbsError*60");
+    //h0.SetName("Mjd");
+    h1.SetName("Zd");
+    h2.SetName("Az");
+    h3.SetName("State");
+    h7.SetName("ControlDeviation");
+
+    MH3 h4("MReportDrive.GetAbsError*60");
+    h4.SetName("DeltaH");
+
+    MH3 h5("MReportDrive.fNominalZd","MReportDrive.GetAbsError*60");
+    h5.SetName("DeltaHvsZd");
+
+    MBinning bins("BinningDeltaH");
+    bins.SetEdges(18, 0, 3.6);
+
+    MBinning bins2("BinningDeltaHvsZdX");
+    MBinning bins3("BinningDeltaHvsZdY");
+    bins2.SetEdges(90, 0, 90);
+    bins3.SetEdges(18, 0, 3.6);
+
+    plist.AddToList(&bins);
+    plist.AddToList(&bins2);
+    plist.AddToList(&bins3);
+
+    //MFillH fill0(&h0, "MTimeDrive");
+    MFillH fill1(&h1, "MTimeDrive");
+    MFillH fill2(&h2, "MTimeDrive");
+    MFillH fill3(&h3, "MTimeDrive");
+    MFillH fill7(&h7, "MTimeDrive");
+    MFillH fill4(&h4);
+    MFillH fill5(&h5);
+
+    //fill0.SetBit(MFillH::kDoNotDisplay);
+    fill1.SetBit(MFillH::kDoNotDisplay);
+    fill2.SetBit(MFillH::kDoNotDisplay);
+    fill3.SetBit(MFillH::kDoNotDisplay);
+    fill4.SetBit(MFillH::kDoNotDisplay);
+    fill5.SetBit(MFillH::kDoNotDisplay);
+    fill7.SetBit(MFillH::kDoNotDisplay);
+
+    // -----------------------------------------------
+
+    //
+    // Setup Task list
+    //
+    tlist.AddToList(&read);
+    tlist.AddToList(&fill3);
+    tlist.AddToList(&tracking);
+    //tlist.AddToList(&fill0);
+    tlist.AddToList(&fill1);
+    tlist.AddToList(&fill2);
+    tlist.AddToList(&fill4);
+    tlist.AddToList(&fill5);
+    tlist.AddToList(&fill7);
+
+    gStyle->SetOptStat(0);
+
+    //
+    // Create and setup the eventloop
+    //
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    //
+    // Execute your analysis
+    //
+    evtloop.SetDisplay(d);
+    if (!evtloop.Eventloop())
+        return;
+
+    tlist.PrintStatistics();
+
+
+    TGraph *g1 = h1.GetGraph();
+    TGraph *g2 = h2.GetGraph();
+
+    TCanvas &c = d->AddTab("Sky");
+    c.cd();
+
+    //Skyplot
+    TPad *p = new TPad("", "",0,0.32,0.5,1);
+    p->Draw();
+    p->cd();
+
+    gPad->SetTheta(-90);
+    gPad->SetPhi(90);
+    gPad->SetBorderMode(0);
+    gStyle->SetOptStat(0);
+
+    TH2F h("pol", "Telescope Tracking Positions on the Sky", 16, 0, 1, 9, 0, 1);
+    h.DrawClone("surf1pol");
+
+    gPad->Modified();
+    gPad->Update();
+
+    TView *view = gPad->GetView();
+    if (!view)
+    {
+        cout << "No View!" << endl;
+        return;
+    }
+
+    Double_t *zd=g1->GetY();
+    Double_t *az=g2->GetY();
+
+    Double_t old[2] = {0,0};
+
+    for (int i=0; i<g1->GetN(); i++)
+    {
+        az[i] += 180;
+        az[i] *= TMath::Pi()/180;
+
+        Double_t x[3] = { zd[i]*cos(az[i])/90, zd[i]*sin(az[i])/90, 0};
+        Double_t y[3];
+
+        view->WCtoNDC(x, y);
+
+        if (old[0]!=0 && old[1]!=1)
+        {
+            TLine *l = new TLine(y[0], y[1], old[0], old[1]);
+            l->SetLineColor(kBlue);
+            l->Draw();
+        }
+
+        TMarker *m = new TMarker(y[0], y[1], kFullDotMedium);
+        m->SetMarkerColor(i==g1->GetN()-1 ? kGreen : kRed);
+        m->Draw();
+
+        old[0] = y[0];
+        old[1] = y[1];
+    }
+
+    c.cd();
+
+
+/*
+    //MJD
+    p = new TPad("", "", 0.6, 0.66, 1, 1);
+    p->Draw();
+    p->cd();
+
+    MHVsTime *hvt=h0.DrawClone("nonew");
+    hvt->GetGraph()->SetMarkerStyle(kFullDotSmall);
+    hvt->GetGraph()->GetHistogram()->SetXTitle("Time");
+    hvt->GetGraph()->GetHistogram()->SetYTitle("");
+    hvt->GetGraph()->GetHistogram()->SetTitle("MJD vs. Time");
+    hvt->GetGraph()->GetHistogram()->SetStats(0);
+
+    c.cd();
+*/
+
+
+    //Histogram of Control Deviation
+    p = new TPad("", "", 0, 0, 0.5, 0.32);
+    p->Draw();
+    p->cd();
+
+    gPad->SetBorderMode(0);
+    //number of entries, mean, rms and number of overflows in the statusbox
+    gStyle->SetOptStat("emro"); 
+    //gStyle->SetStatFormat(".2g");
+
+    MH3 *mh3 = (MH3*)h4.DrawClone("nonew");
+
+    TAxis *axey = mh3->GetHist()->GetYaxis();
+    TAxis *axex = mh3->GetHist()->GetXaxis();
+    axey->SetLabelSize(0.05);
+    axex->SetLabelSize(0.05);
+    axex->SetTitleSize(0.05);
+    axex->SetTitleOffset(0.85);
+
+    mh3->GetHist()->SetXTitle("\\Delta [arcmin]");
+    mh3->GetHist()->SetYTitle("");
+    mh3->GetHist()->SetTitle("Control deviation of the motors");
+    mh3->GetHist()->SetStats(1);
+
+    //insert lines for 0.5, 1 and 2 SE
+    TLine ln;
+    ln.SetLineColor(kGreen);
+    ln.DrawLine(0.5*360*60/16384., 0, 0.5*360*60/16384., h4.GetHist()->GetMaximum());
+    ln.SetLineColor(kYellow);
+    ln.DrawLine(1.0*360*60/16384., 0, 1.0*360*60/16384., h4.GetHist()->GetMaximum());
+    ln.SetLineColor(kRed);
+    ln.DrawLine(2.0*360*60/16384., 0, 2.0*360*60/16384., h4.GetHist()->GetMaximum());
+
+    c.cd();
+
+
+    //Status of the Drive System vs Time
+    p = new TPad("", "", 0.5, 0.86, 1, 1);
+    p->Draw();
+    p->cd();
+    gPad->SetBorderMode(0);
+    p->SetGridx();
+
+    hvt = (MHVsTime*)h3.DrawClone("nonew");
+    hvt->GetGraph()->SetMarkerStyle(kFullDotSmall);
+
+    TH1 *hist = hvt->GetGraph()->GetHistogram();
+    TAxis *axey = hist->GetYaxis();
+    TAxis *axex = hist->GetXaxis();
+
+    hist->SetXTitle("Time");
+    hist->SetYTitle("");
+    hist->SetTitle("");//Drive Status vs. Time");
+    hist->SetStats(0);
+    hist->SetMinimum(-0.5);
+    hist->SetMaximum(4.5);
+    axey->Set(5, -0.5, 4.5);
+    axey->SetBinLabel(axey->FindFixBin(0), "Error");
+    axey->SetBinLabel(axey->FindFixBin(1), "Stopped");
+    axey->SetBinLabel(axey->FindFixBin(3), "Moving");
+    axey->SetBinLabel(axey->FindFixBin(4), "Tracking");
+    axey->SetLabelSize(0.15);
+    axex->SetLabelSize(0.08);
+    axex->SetTitleSize(0.09);
+    axex->SetTitleOffset(0.45);
+
+    c.cd();
+
+
+    //Zd vs Time
+    p = new TPad("", "", 0.5, 0.59, 1, 0.86);
+    p->Draw();
+    p->cd();
+    gPad->SetBorderMode(0);
+    p->SetGridx();
+
+    hvt = (MHVsTime*)h1.DrawClone("nonew");
+    hvt->GetGraph()->SetMarkerStyle(kFullDotSmall);
+
+    TH1 *hist = hvt->GetGraph()->GetHistogram();
+    if (hvt->GetGraph()->GetN())
+    {
+        hist->SetXTitle("Time");
+        hist->SetYTitle("Zd [\\circ]");
+        hist->SetTitle("Zd vs. Time");
+        hist->SetStats(0);
+    }
+
+    TAxis *axey = hist->GetYaxis();
+    TAxis *axex = hist->GetXaxis();
+    axey->SetLabelSize(0.05);
+    axey->SetTitleSize(0.06);
+    axey->SetTitleOffset(0.6);
+    axex->SetLabelSize(0.05);
+    axex->SetTitleSize(0.06);
+    axex->SetTitleOffset(0.85);
+
+    c.cd();
+
+
+    //Controll Deviation vs Time
+    p = new TPad("", "", 0.5, 0.32, 1, 0.59);
+    p->Draw();
+    p->cd();
+    gPad->SetBorderMode(0);
+    p->SetGridx();
+
+    hvt = (MHVsTime*)h7.DrawClone("nonew L");
+    TH1 *hist = hvt->GetGraph()->GetHistogram();
+    hist->SetAxisRange(-0.5, 10.5, "Y");
+    hist->SetXTitle("Time");
+    hist->SetYTitle("\\Delta [arcmin]");
+    hist->SetTitle("Control Deviation vs. Time");
+
+    TAxis *axey = hist->GetYaxis();
+    TAxis *axex = hist->GetXaxis();
+    axey->SetLabelSize(0.05);
+    axey->SetTitleSize(0.06);
+    axey->SetTitleOffset(0.5);
+    axex->SetLabelSize(0.05);
+    axex->SetTitleSize(0.06);
+    axex->SetTitleOffset(0.8);
+
+    //insert lines for 0.5, 1 and 2 SE
+    TLine ln;
+    ln.SetLineColor(kGreen);
+    ln.DrawLine(hist->GetXaxis()->GetXmin(), 0.5*360*60/16384., hist->GetXaxis()->GetXmax(), 0.5*360*60/16384.);
+    ln.SetLineColor(kYellow);
+    ln.DrawLine(hist->GetXaxis()->GetXmin(), 1.0*360*60/16384., hist->GetXaxis()->GetXmax(), 1.0*360*60/16384.);
+    ln.SetLineColor(kRed);
+    ln.DrawLine(hist->GetXaxis()->GetXmin(), 2.0*360*60/16384., hist->GetXaxis()->GetXmax(), 2.0*360*60/16384.);
+
+    c.cd();
+
+
+    //Controll Deviation vs Zd
+    p = new TPad("", "", 0.5, 0, 1, 0.32);
+    p->Draw();
+    p->cd();
+
+    gPad->SetBorderMode(0);
+    gStyle->SetOptStat(1110);
+    gStyle->SetStatFormat(".2g");
+
+    mh3 = (MH3*)h5.DrawClone("nonew");
+
+    TAxis *axey = mh3->GetHist()->GetYaxis();
+    TAxis *axex = mh3->GetHist()->GetXaxis();
+    axey->SetLabelSize(0.05);
+    axey->SetTitleSize(0.05);
+    axey->SetTitleOffset(0.7);
+    axex->SetLabelSize(0.05);
+    axex->SetTitleSize(0.05);
+    axex->SetTitleOffset(0.85);
+
+    mh3->GetHist()->SetYTitle("Zd [\\circ]");
+    mh3->GetHist()->SetXTitle("\\Delta [arcmin]");
+    mh3->GetHist()->SetTitle("Control deviation of the motors");
+    mh3->GetHist()->SetStats(1);
+    mh3->GetHist()->Draw("box");
+
+    //insert lines for 0.5, 1 and 2 SE
+    TLine ln;
+    ln.SetLineColor(kGreen);
+    ln.DrawLine(0, 0.5*360*60/16384., 90, 0.5*360*60/16384.);
+    ln.SetLineColor(kYellow);
+    ln.DrawLine(0, 1.0*360*60/16384., 90, 1.0*360*60/16384.);
+    ln.SetLineColor(kRed);
+    ln.DrawLine(0, 2.0*360*60/16384., 90, 2.0*360*60/16384.);
+
+
+    //d.SaveAsPS(2, "rep_files/CC_2003_11_27_22_31_59-new.ps");
+    //d.SaveAsRoot(2, "~/dev/Mars/rep_files/CC_2003_11_27_22_31_59-new.root");
+
+}
Index: /tags/Mars_V0-8-5/Mars/macros/pointspreadfunction.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/pointspreadfunction.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/pointspreadfunction.C	(revision 9661)
@@ -0,0 +1,853 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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, 12/2003 <mailto:jlopez@ifae.es>
+!   Author(s): Alex Armada,   1/2004 <mailto:armada@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+
+//------------------------------------------------------------------------- //
+//                                                                          //
+//  This macro fits the dc signal of a star using a two dimension gaussian  //
+//  for each dc measurement. Then the values of parameters of the fit are   //
+//  stored in histograms and shown at the end of the macro.                 //
+//                                                                          //
+//  USAGE:                                                                  //
+//  It has two arguments,                                                   //
+//  1- The first one is the dc file with the tracked star                   //
+//  2- The second one is a continuos light file used to intercalibrate      //
+//     the gain of the photomultipliers.                                    //
+//     (It's possible not to use the calibration file and then the gain     //
+//      of the pmts are supouse to be the same for all of them.             //
+//  3- The third argument is just the number of dc measurements you want    //
+//     analize. If you put 0 it just stops after each fit and show you      //
+//     results.                                                             //
+//                                                                          //
+//--------------------------------------------------------------------------// 
+
+const Int_t numPixels = 577;
+Int_t nPixelsFitted; 
+Bool_t isPixelsFitted[numPixels];
+Float_t z[numPixels],x[numPixels],y[numPixels],errorz[numPixels];
+Float_t chisquare;
+
+//______________________________________________________________________________
+//
+// Function used by Minuit to do the fit
+//
+void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)
+{
+    Int_t i;
+
+//calculate chisquare
+    Double_t chisq = 0;
+    Double_t delta;
+    nPixelsFitted=0;
+    for (i=1;i<numPixels; i++) {
+	if (isPixelsFitted[i])
+	{
+	    if (errorz[i] != 0.0)
+	    {
+		delta  = (z[i]-func(x[i],y[i],par))/errorz[i];
+		chisq += delta*delta;
+		nPixelsFitted++;
+	    }
+	    else
+		cout << "This should never happen errorz[" << i << "] " << errorz[i] << endl;
+	}
+    }
+    f = chisq;
+    chisquare = chisq;
+}
+
+//______________________________________________________________________________
+//
+// The 2D gaussian fucntion used to fit the spot of the star
+//
+Double_t func(float x,float y,Double_t *par)
+{
+    Double_t value=par[0]*TMath::exp(-(x-par[1])*(x-par[1])/(2*par[2]*par[2]))*TMath::exp(-(y-par[3])*(y-par[3])/(2*par[4]*par[4]));
+    return value;
+}
+
+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 pointspreadfunction(TString fname, TString clname = "NULL", Int_t userNumLines = 1000)
+{
+
+
+    Float_t currmean[numPixels];
+    Float_t currsquaremean[numPixels];
+    Float_t currrms[numPixels];
+    Float_t meanofcurrmean = 0;
+
+    for (Int_t swpix=0; swpix<numPixels; swpix++)
+    {
+ 	currmean[swpix] = 0.;
+ 	currsquaremean[swpix] = 0.;
+  	currrms[swpix] = 0.;
+    }
+    
+    Int_t numLines=0;
+
+    //containers
+    MGeomCamMagic geomcam;
+    MCameraDC     curr;
+    MCameraDC     currbis;
+    
+    const Float_t conv4mm2deg = geomcam.GetConvMm2Deg();
+
+	 
+    if (clname != "NULL")
+    {
+
+	//
+	// First run over continuos light files to have a DC calibration
+	//
+
+	MParList plist0;
+	
+	MTaskList     tlist0;
+	plist0.AddToList(&tlist0);
+	
+	plist0.AddToList(&geomcam);
+	plist0.AddToList(&curr);
+	
+	MReportFileRead read0(clname);
+	read0.SetHasNoHeader();
+	read0.AddToList("MReportCurrents");
+	
+	tlist0.AddToList(&read0);
+	
+	MEvtLoop evtloop0;
+	evtloop0.SetParList(&plist0);
+	
+	
+	if (!evtloop0.PreProcess())
+	    return;
+	
+	while (tlist0.Process())
+	{
+	    for (Int_t swpix=0; swpix<numPixels; swpix++)
+	    {
+		meanofcurrmean += curr[swpix];
+		currmean[swpix] += curr[swpix];
+		currsquaremean[swpix] += curr[swpix]*curr[swpix];
+	    }
+	    numLines++;
+	}
+	
+	evtloop0.PostProcess();
+	
+	meanofcurrmean /= (numLines*numPixels);
+	for (Int_t swpix=0; swpix<numPixels; swpix++)
+	{
+	    
+	    currmean[swpix] /= numLines;
+	    currsquaremean[swpix] /= numLines;
+	    currrms[swpix] = sqrt(fabs(currsquaremean[swpix] - currmean[swpix]*currmean[swpix]));
+	    
+	    curr[swpix] = currmean[swpix];
+	    currbis[swpix] = currrms[swpix];
+	    
+	    currmean[swpix] /= meanofcurrmean;	
+	    currrms[swpix] /= meanofcurrmean;	
+	    
+	}
+	
+	
+/*     MHCamera display0(geomcam);
+       display0.SetPrettyPalette();
+       display0.Draw();
+       
+	//    curr.Print();
+       display0.SetCamContent(currbis);
+       cout << "PSF>> DC mean values drawn" << endl;
+       // Remove the comments if you want to go through the file
+       // event-by-event:
+       if (!HandleInput())
+       break;
+*/
+    }
+    else
+    {
+	// If you don't use the continuous light this is the currrms[] array 
+	// is the error associated to the currents TMinuit will use.
+	for (Int_t swpix=0; swpix<numPixels; swpix++)
+	{
+	    currmean[swpix] = 1.;
+	    currrms[swpix] = 0.2; 
+	}
+	
+    }
+
+//
+// Now we can run over the dc data to extract the psf. 
+//	
+    const Int_t maxNumLines = 10000;
+	
+    Double_t ux[maxNumLines];
+    Double_t uy[maxNumLines];
+    Double_t sx[maxNumLines];
+    Double_t sy[maxNumLines];
+    Double_t chisqu[maxNumLines];
+    Double_t time[maxNumLines];
+
+    MParList plist;
+
+    MGeomCamMagic geomcam;
+    MCameraDC     curr;
+    MTaskList     tlist;
+
+    plist.AddToList(&geomcam);
+    plist.AddToList(&curr);
+    plist.AddToList(&tlist);
+
+    MReportFileRead read(fname);
+    read.SetHasNoHeader();
+    read.AddToList("MReportCurrents");
+
+    tlist.AddToList(&read);
+    
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+    
+    if (!evtloop.PreProcess())
+        return;
+    
+    MHCamera display(geomcam);
+    display.SetPrettyPalette();
+    display.Draw();
+    gPad->SetLogy();
+    gPad->cd(1);
+
+    Double_t amin,edm,errdef;
+    Int_t nvpar,nparx,icstat;
+
+    Double_t max,maxerror;
+    Double_t xmean,xsigma,ymean,ysigma;
+    Double_t xmeanerror,xsigmaerror,ymeanerror,ysigmaerror;
+
+    TEllipse ellipse;
+    ellipse.SetFillStyle(4000);
+    ellipse.SetLineWidth(2);
+    ellipse.SetLineColor(2);
+
+    ellipse.Draw();
+
+    Int_t nbinsxy = 80;
+    Float_t minxy = -600*conv4mm2deg;
+    Float_t maxxy = 600*conv4mm2deg;
+    Float_t fromdegtobin = (maxxy-minxy)/nbinsxy;
+
+    TH2D psfhist("psfhist","",nbinsxy,minxy,maxxy,nbinsxy,minxy,maxxy);
+    psfhist->GetXaxis()->SetTitle("[deg]");
+    psfhist->GetYaxis()->SetTitle("[deg]");
+    psfhist->GetZaxis()->SetTitle("DC [uA]");
+
+    TCanvas *psfcanvas = new TCanvas("psfcanvas","Point Spread Funtion 2D",200,20,900,700);
+
+
+    //
+    // Using the first dc measurement we search the pixels which contains the star and define
+    // an area to be fitted by Minuit which is 3 rings of neightbords around the peak of the star.
+    // 
+
+    tlist.Process();
+
+    Int_t numLines=0;
+    Float_t minDCStar = 6.0;
+
+    Int_t numPixelsInStar = 0;
+    Float_t maxDC = 0;
+    Int_t swpixelmaxDC;
+    
+    Bool_t isPixelsFittedTmp[numPixels];
+    
+    for(Int_t swpixel=1; swpixel<numPixels; swpixel++)
+	isPixelsFittedTmp[swpixel] = kFALSE;
+    
+    for(Int_t swpixel=1; swpixel<numPixels; swpixel++)
+    {
+	if(curr[swpixel] > maxDC)
+	{
+	    swpixelmaxDC = swpixel;
+	    maxDC = curr[swpixelmaxDC];
+	}
+	
+	if(curr[swpixel]>minDCStar)
+	{
+	    numPixelsInStar++;
+	    isPixelsFitted[swpixel] = kTRUE;
+	}
+	else
+	    isPixelsFitted[swpixel] = kFALSE;
+    }
+    
+    if (numPixelsInStar == 0)
+    {
+	cout << "PSF>> Warning: none pixel over minDCStar(" << minDCStar  << ')' << endl; 
+	return;
+    }
+    
+//1st neighboor ring
+    for(Int_t swpixel=1; swpixel<numPixels; swpixel++)
+	if (isPixelsFitted[swpixel])
+	    for(Int_t next=0; next<geomcam[swpixel].GetNumNeighbors(); next++)
+		isPixelsFittedTmp[geomcam[swpixel].GetNeighbor(next)] = kTRUE;
+    
+    for(Int_t swpixel=1; swpixel<numPixels; swpixel++)
+	if (isPixelsFittedTmp[swpixel])
+	    isPixelsFitted[swpixel] = kTRUE;
+    
+//2on neighboor ring
+    for(Int_t swpixel=1; swpixel<numPixels; swpixel++)
+	if (isPixelsFitted[swpixel])
+	    for(Int_t next=0; next<geomcam[swpixel].GetNumNeighbors(); next++)
+		isPixelsFittedTmp[geomcam[swpixel].GetNeighbor(next)] = kTRUE;
+    
+    for(Int_t swpixel=1; swpixel<numPixels; swpixel++)
+	if (isPixelsFittedTmp[swpixel])
+	    isPixelsFitted[swpixel] = kTRUE;
+    
+
+//3rt neighboor ring
+    for(Int_t swpixel=1; swpixel<numPixels; swpixel++)
+	if (isPixelsFitted[swpixel])
+	    for(Int_t next=0; next<geomcam[swpixel].GetNumNeighbors(); next++)
+		isPixelsFittedTmp[geomcam[swpixel].GetNeighbor(next)] = kTRUE;
+    
+    for(Int_t swpixel=1; swpixel<numPixels; swpixel++)
+	if (isPixelsFittedTmp[swpixel])
+	    isPixelsFitted[swpixel] = kTRUE;
+	      
+   
+    for(Int_t swpixel=1; swpixel<numPixels; swpixel++)
+	curr[swpixel] = (Float_t)isPixelsFitted[swpixel]; 
+    
+/*    MHCamera display0(geomcam);
+    display0.SetPrettyPalette();
+    display0.Draw();
+    
+    display0.SetCamContent(curr);
+    cout << "PSF>> Fitted pixels drawn" << endl;
+    // Remove the comments if you want to go through the file
+    // event-by-event:
+    if (!HandleInput())
+	break;
+*/
+
+    // Minuit initialization
+
+    TMinuit *gMinuit = new TMinuit(7);  //initialize TMinuit with a maximum of 5 params
+    gMinuit->SetFCN(fcn);
+
+    Double_t arglist[10];
+    Int_t ierflg = 0;
+
+    arglist[0] = 1;
+    gMinuit->mnexcm("SET ERR", arglist ,1,ierflg);
+//    arglist[0] = -1;
+    arglist[0] = 0;
+    gMinuit->mnexcm("SET PRI", arglist ,1,ierflg);
+
+// Set starting values and step sizes for parameters
+    Double_t vstart[5];
+    Double_t step[5];
+    Double_t lowlimit[5] = {minDCStar, -2., 0.05, -2, 0.05};
+    Double_t uplimit[5] = {30., 2., 1., 2., 1.};
+
+    vstart[0] = maxDC;
+    vstart[1] = geomcam[swpixelmaxDC].GetX()*conv4mm2deg;
+    vstart[2] = 30*TMath::Sqrt(numPixelsInStar/2)*conv4mm2deg;
+    vstart[3] = geomcam[swpixelmaxDC].GetY()*conv4mm2deg;
+    vstart[4] = 30*TMath::Sqrt(numPixelsInStar/2)*conv4mm2deg;
+    
+    for(Int_t i=0; i<5; i++)
+    {
+	if (vstart[i] != 0)
+	    step[i] = TMath::Abs(vstart[i]/sqrt(2));
+	else
+	    step[i] = uplimit[i]/2;
+    }
+  
+    gMinuit->mnparm(0, "max", vstart[0], step[0], lowlimit[0], uplimit[0],ierflg);
+    gMinuit->mnparm(1, "xmean", vstart[1], step[1], lowlimit[1], uplimit[1],ierflg);
+    gMinuit->mnparm(2, "xsigma", vstart[2], step[2], lowlimit[2], uplimit[2],ierflg);
+    gMinuit->mnparm(3, "ymean", vstart[3], step[3], lowlimit[3], uplimit[3],ierflg);
+    gMinuit->mnparm(4, "ysigma", vstart[4], step[4], lowlimit[4], uplimit[4],ierflg);
+
+    while (tlist.Process() && numLines < maxNumLines)
+    {
+
+	for (Int_t swpixel=1; swpixel<577; swpixel++)
+	{
+	    
+	    x[swpixel] = geomcam[swpixel].GetX()*conv4mm2deg;
+	    y[swpixel] = geomcam[swpixel].GetY()*conv4mm2deg;
+	    z[swpixel] = curr[swpixel]/currmean[swpixel];
+	    errorz[swpixel] = TMath::Sqrt((curr[swpixel]*currrms[swpixel]/(currmean[swpixel]*currmean[swpixel]))*(curr[swpixel]*currrms[swpixel]/(currmean[swpixel]*currmean[swpixel]))+(0.1)/currmean[swpixel]*(0.1)/currmean[swpixel]);
+
+
+	    psfhist->SetBinContent((Int_t)((x[swpixel]+600*conv4mm2deg)/fromdegtobin),(Int_t)((y[swpixel]+600*conv4mm2deg)/fromdegtobin),z[swpixel]);
+	}
+	
+	psfcanvas->cd(1);
+	psfhist->Draw("lego2");
+	
+// Now ready for minimization step
+	arglist[0] = 500;
+	arglist[1] = 1.;
+	gMinuit->mnexcm("MIGRAD", arglist ,2,ierflg);
+
+// Print results
+/*	gMinuit->mnstat(amin,edm,errdef,nvpar,nparx,icstat);
+	gMinuit->mnprin(3,amin);
+*/
+	gMinuit->GetParameter(0,max,maxerror);
+	gMinuit->GetParameter(1,xmean,xmeanerror);
+	gMinuit->GetParameter(2,xsigma,xsigmaerror);
+	gMinuit->GetParameter(3,ymean,ymeanerror);
+	gMinuit->GetParameter(4,ysigma,ysigmaerror);
+
+/*	cout << endl;
+	cout << "numLine " << numLines << endl; 
+	cout << "max \t" << max <<  " +- " << maxerror << endl;
+	cout << "xmean \t" << xmean << " +- " << xmeanerror << endl;
+	cout << "xsigma \t" << TMath::Abs(xsigma) << " +- " << xsigmaerror << endl;
+	cout << "ymean \t" << ymean << " +- " << ymeanerror << endl;
+	cout << "ysigma \t" << TMath::Abs(ysigma) << " +- " << ysigmaerror << endl;
+	cout << "chisquare/ndof \t" << chisquare/(nPixelsFitted-5) << endl;
+*/
+	
+	chisqu[numLines]=chisquare/(nPixelsFitted-5);
+
+        if(chisqu[numLines]<100.)
+	{
+	    ux[numLines]=xmean;
+	    uy[numLines]=ymean;
+	    sx[numLines]=TMath::Abs(xsigma);
+	    sy[numLines]=TMath::Abs(ysigma);
+	    time[numLines]=numLines;
+
+	    display.SetCamContent(curr);
+	    gPad->cd(1);
+	    ellipse.SetX1(xmean/conv4mm2deg);
+	    ellipse.SetY1(ymean/conv4mm2deg);
+	    ellipse.SetR1(TMath::Abs(xsigma)/conv4mm2deg);
+	    ellipse.SetR2(TMath::Abs(ysigma)/conv4mm2deg);
+
+	    gPad->Modified();
+	    gPad->Update();
+
+	    // Remove the comments if you want to go through the file
+	    //event-by-event:
+	    if (userNumLines>0)
+	    {
+		if (numLines>userNumLines)
+		    break;
+	    }
+	    else
+	    {
+		if (!HandleInput())
+		    break;
+	    }
+	    numLines++;
+	}
+    }
+
+    
+    evtloop.PostProcess();
+
+    //
+    // Draw the ditributions of the sigmas the point spread function
+    //
+
+    cout<<"PSF>> Number of lines "<<numLines<<endl;
+
+    gROOT->Reset();
+    gStyle->SetCanvasColor(0);
+    gStyle->SetCanvasBorderMode(0);
+    gStyle->SetPadBorderMode(0);
+    gStyle->SetFrameBorderMode(0);
+    gStyle->SetOptStat(00000000);
+
+//
+// Find in the file name the date, run and project name to put it in the title
+//
+
+    Size_t pos = fname.Last('/');
+    TString iRun = TString(fname(pos+24,5));
+    TString iYear = TString(fname(pos+4,4));
+    TString iMonth = TString(fname(pos+9,2));
+    TString iDay = TString(fname(pos+12,2));
+
+    TString iHour = TString(fname(pos+15,2));
+    TString iMin = TString(fname(pos+18,2));
+    TString iSec = TString(fname(pos+21,2));
+
+    Size_t poslast = fname.Last('.');
+    Size_t posfirst = poslast-1;
+    while (fname[posfirst] != '_')
+	posfirst--;
+
+    TString iSource = TString(fname(posfirst+1,poslast-posfirst-1));
+
+    
+    char str[100];
+    
+//    sprintf(str,"Date %s/%s/%s Run %s Source %s",iYear.Data(),iMonth.Data(),iDay.Data(),iRun.Data(),iSource.Data());
+    sprintf(str,"Date %s/%s/%s   StartTime %s:%s:%s   Run %s   Source %s",iYear.Data(),iMonth.Data(),iDay.Data(),iHour.Data(),iMin.Data(),iSec.Data(),iRun.Data(),iSource.Data());
+
+    c1 = new TCanvas("c1",str,0,0,1200,850);
+//    c1 = new TCanvas("c1","Time evolution & distributions",0,0,1200,850);
+    c1->Divide(3,2);
+
+    c1->cd(1);
+
+    TMath math;
+   
+    Double_t minmeanx, maxmeanx;
+    minmeanx = ux[math.LocMin(numLines,ux)];
+    maxmeanx = ux[math.LocMax(numLines,ux)];
+
+    Double_t minmeany, maxmeany;
+    minmeany = uy[math.LocMin(numLines,uy)];
+    maxmeany = uy[math.LocMax(numLines,uy)];
+
+    Double_t minmean, maxmean;
+    minmean = math.Min(minmeanx,minmeany);
+    maxmean = math.Max(maxmeanx,maxmeany);
+
+    Double_t diff;
+    diff = maxmean - minmean;
+    diff = 0.1*diff;
+    minmean = minmean - diff;
+    maxmean = maxmean + diff;
+
+    Double_t mintime, maxtime;
+    mintime = time[math.LocMin(numLines,time)];
+    maxtime = time[math.LocMax(numLines,time)];
+
+    TH2D *h1 = new TH2D("h1","",1,mintime-1,maxtime+1,1,minmean,maxmean);
+    h1->GetXaxis()->SetTitle("Event number");
+    h1->GetYaxis()->SetTitle("mean position (deg)");
+    h1->Draw();
+
+    TGraph *grtimeevolmeanx = new TGraph(numLines,time,ux);
+    grtimeevolmeanx->SetMarkerColor(3);
+    grtimeevolmeanx->SetMarkerStyle(20);
+    grtimeevolmeanx->SetMarkerSize (0.4);
+    grtimeevolmeanx->Draw("P");
+
+    TGraph *grtimeevolmeany = new TGraph(numLines,time,uy);
+    grtimeevolmeany->SetMarkerColor(6);
+    grtimeevolmeany->SetMarkerStyle(24);
+    grtimeevolmeany->SetMarkerSize (0.4);
+    grtimeevolmeany->Draw("P");
+
+    legmeanxy = new TLegend(0.8,0.85,0.95,0.95);
+    legmeanxy.SetTextSize(0.03);
+    legmeanxy.AddEntry(grtimeevolmeanx,"mean x","P");
+    legmeanxy.AddEntry(grtimeevolmeany,"mean y","P");
+    legmeanxy.Draw();
+
+    c1->cd(2);
+
+    TMath math;
+   
+    Double_t minsigmax, maxsigmax;
+    minsigmax = sx[math.LocMin(numLines,sx)];
+    maxsigmax = sx[math.LocMax(numLines,sx)];
+
+    Double_t minsigmay, maxsigmay;
+    minsigmay = sy[math.LocMin(numLines,sy)];
+    maxsigmay = sy[math.LocMax(numLines,sy)];
+
+    Double_t minsigma, maxsigma;
+    minsigma = math.Min(minsigmax,minsigmay);
+    maxsigma = math.Max(maxsigmax,maxsigmay);
+
+    diff = maxsigma - minsigma;
+    diff = 0.1*diff;
+    minsigma = minsigma - diff;
+    maxsigma = maxsigma + diff;
+
+    TH2D *h2 = new TH2D("h2","",1,mintime-1,maxtime+1,1,minsigma,maxsigma);
+    h2->GetXaxis()->SetTitle("Event number");
+    h2->GetYaxis()->SetTitle("PSF Rms (deg)");
+    h2->Draw();
+
+    TGraph* grtimeevolsigmax= new TGraph(numLines,time,sx);
+    grtimeevolsigmax->SetMarkerColor(3);
+    grtimeevolsigmax->SetMarkerStyle(20);
+    grtimeevolsigmax->SetMarkerSize (0.4);
+    grtimeevolsigmax->Draw("P");
+
+    TGraph* grtimeevolsigmay= new TGraph(numLines,time,sy);
+    grtimeevolsigmay->SetMarkerColor(6);
+    grtimeevolsigmay->SetMarkerStyle(24);
+    grtimeevolsigmay->SetMarkerSize (0.4);
+    grtimeevolsigmay->Draw("P");
+
+    legsigmaxy = new TLegend(0.8,0.85,0.95,0.95);
+    legsigmaxy.SetTextSize(0.03);
+    legsigmaxy.AddEntry(grtimeevolsigmax,"sigma x","P");
+    legsigmaxy.AddEntry(grtimeevolsigmay,"sigma y","P");
+    legsigmaxy.Draw();
+   
+    c1->cd(3);
+
+    Double_t minchisqu, maxchisqu;
+
+    minchisqu = chisqu[math.LocMin(numLines,chisqu)];
+    maxchisqu = chisqu[math.LocMax(numLines,chisqu)];
+
+    diff = maxchisqu - minchisqu;
+    diff = 0.1*diff;
+    minchisqu = minchisqu - diff;
+    maxchisqu = maxchisqu + diff;
+
+    TH2D *h3 = new TH2D("h3","",1,mintime-1,maxtime+1,1,minchisqu,maxchisqu);
+    h3->GetXaxis()->SetTitle("Event number");
+    h3->Draw();
+
+    TGraph * grtimeevolchisqu = new TGraph(numLines,time,chisqu);
+    grtimeevolchisqu->SetMarkerColor(215);
+    grtimeevolchisqu->SetMarkerStyle(20);
+    grtimeevolchisqu->SetMarkerSize(0.4);
+    grtimeevolchisqu->Draw("P");
+
+    legchisqu = new TLegend(0.55,0.90,0.95,0.95);
+    legchisqu.SetTextSize(0.03);
+    legchisqu.AddEntry(grtimeevolchisqu,"chi square / ndof","P");
+    legchisqu.Draw();
+
+//***************************************
+
+    const Int_t nbins = 100; 
+  
+    TH1D *xsigmahist = new TH1D("xsigmahist","",nbins,minsigma,maxsigma);
+    TH1D *ysigmahist = new TH1D("ysigmahist","",nbins,minsigma,maxsigma);
+    TH1D *xmeanhist = new TH1D("xmeanhist","",nbins,minmean,maxmean);
+    TH1D *ymeanhist = new TH1D("ymeanhist","",nbins,minmean,maxmean);
+    TH1D *chisquhist = new TH1D("chisquhist","",nbins,minchisqu,maxchisqu);
+
+    for (Int_t i=0; i<numLines; i++)
+    {
+	xsigmahist->Fill(TMath::Abs(sx[i]));
+	ysigmahist->Fill(TMath::Abs(sy[i]));
+	xmeanhist->Fill(ux[i]);
+	ymeanhist->Fill(uy[i]);
+	chisquhist->Fill(chisqu[i]);
+	
+    }
+
+    c1->cd(5);
+
+    TMath math;
+    Double_t maxsigma;
+    Int_t binmaxx, binmaxy;
+    xsigmahist->SetLineColor(3);
+    xsigmahist->SetLineWidth(2);
+    xsigmahist->SetXTitle("RMS [deg]");
+    binmaxx = xsigmahist->GetMaximumBin();
+    binmaxx = xsigmahist->GetBinContent(binmaxx);
+       
+    ysigmahist->SetLineColor(6);
+    ysigmahist->SetLineWidth(2);
+    binmaxy = ysigmahist->GetMaximumBin();
+    binmaxy = ysigmahist->GetBinContent(binmaxy);
+   
+    maxsigma = math.Max(binmaxx,binmaxy);
+    maxsigma += 1;
+
+    xsigmahist->SetMaximum(maxsigma);
+    ysigmahist->SetMaximum(maxsigma);
+    xsigmahist->DrawCopy();
+    ysigmahist->DrawCopy("Same");
+
+    TLegend *legendsigma = new TLegend(.3,.8,.95,.95);
+    legendsigma->SetTextSize(0.03);
+    char xsigmatitle[100];
+    char ysigmatitle[100];
+    sprintf(xsigmatitle,"PSF Rms on X axis -- %5.2f +/- %5.2f deg",xsigmahist->GetMean(),xsigmahist->GetRMS());
+    sprintf(ysigmatitle,"PSF Rms on Y axis -- %5.2f +/- %5.2f deg",ysigmahist->GetMean(),ysigmahist->GetRMS());
+    legendsigma->AddEntry(xsigmahist,xsigmatitle,"F");
+    legendsigma->AddEntry(ysigmahist,ysigmatitle,"F");
+    legendsigma->Draw();
+
+    c1->cd(4);
+   
+    Double_t maxmean;
+
+    xmeanhist->SetLineColor(3);
+    xmeanhist->SetLineWidth(2);
+    xmeanhist->SetXTitle("mean [deg]");
+    binmaxx = xmeanhist->GetMaximumBin();
+    binmaxx = xmeanhist->GetBinContent(binmaxx);
+
+    ymeanhist->SetLineColor(6);
+    ymeanhist->SetLineWidth(2);
+    binmaxy = ymeanhist->GetMaximumBin();
+    binmaxy = ymeanhist->GetBinContent(binmaxy);
+
+    maxmean = math.Max(binmaxx,binmaxy);
+    maxmean += 1;
+
+    xmeanhist->SetMaximum(maxmean);
+    ymeanhist->SetMaximum(maxmean);
+    xmeanhist->DrawCopy();
+    ymeanhist->DrawCopy("Same");
+
+    TLegend *legendmean = new TLegend(.35,.8,.95,.95);
+    legendmean->SetTextSize(0.03);
+    char xmeantitle[100];
+    char ymeantitle[100];
+    sprintf(xmeantitle,"mean on X axis -- %5.2f +/- %5.2f deg",xmeanhist->GetMean(),xmeanhist->GetRMS());
+    sprintf(ymeantitle,"mean on Y axis -- %5.2f +/- %5.2f deg",ymeanhist->GetMean(),ymeanhist->GetRMS());
+    legendmean->AddEntry(xmeanhist,xmeantitle,"F");
+    legendmean->AddEntry(ymeanhist,ymeantitle,"F");
+    legendmean->Draw();
+
+    //meancanvas->Modified();
+    //meancanvas->Update();
+
+    c1->cd(6);
+
+    chisquhist->SetLineColor(215);
+    chisquhist->SetLineWidth(2);
+    chisquhist->SetXTitle("chi square / ndof");
+    TAxis * axis = chisquhist->GetXaxis();
+    axis->SetLabelSize(0.025);
+    chisquhist->DrawCopy();
+    
+    TLegend *legendchisqu = new TLegend(.4,.85,.95,.95);
+    legendchisqu->SetTextSize(0.03);
+    char chisqutitle[100];
+    sprintf(chisqutitle,"chi square / ndof -- %5.2f +/- %5.2f ",chisquhist->GetMean(),chisquhist->GetRMS());
+    legendchisqu->AddEntry(chisquhist,chisqutitle,"F");
+    legendchisqu->Draw();
+    
+    
+    return;
+      
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/macros/readCT1.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/readCT1.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/readCT1.C	(revision 9661)
@@ -0,0 +1,134 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  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;
+
+    MHillas      hillas;
+    MHillasExt   hillasext;
+    MNewImagePar newimgpar;
+    MTaskList    tlist;
+
+    plist.AddToList(&hillas);
+    plist.AddToList(&hillasext);
+    plist.AddToList(&newimgpar);
+    plist.AddToList(&tlist);
+
+    MCT1ReadAscii read(fname);
+    MGeomApply    geomapl;
+    MClone        clone("MCerPhotEvt");
+    MImgCleanStd  clean;
+    MHillasCalc   hcalc;
+
+    geomapl.SetGeometry("MGeomCamCT1");
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&geomapl);
+    tlist.AddToList(&clone);
+    tlist.AddToList(&clean);
+    tlist.AddToList(&hcalc);
+
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    if (!evtloop.PreProcess())
+        return;
+
+    MGeomCam *geomcam = (MGeomCam*)plist->FindObject("MGeomCam");
+
+    Int_t icount = 0;
+
+    MHCamera display[4];
+    TCanvas c("Events", "Real Events", 600, 600);
+    c.SetBorderMode(0);
+    c.Divide(2,2);
+    for (int i=0; i<4; i++)
+    {
+        display[i].SetGeometry(*geomcam);
+        c.cd(i+1);
+        display[i].Draw();
+        gPad->cd(1);
+        hillas.Draw();
+    }
+
+    // Use this if you don't want the event to be autoscaled
+    //display.SetMinimum(0);
+    //display.SetMaximum(100);
+
+    while ((rc=tlist.Process()))
+    {
+        cout << "Event #" << icount++ << endl;
+
+        MCerPhotEvt *evt = (MCerPhotEvt*)clone.GetClone();
+        if (!evt)      // If skipped due to MInputStreamId
+            continue;
+
+        display[0].SetCamContent(*(MCerPhotEvt*)clone.GetClone());
+        display[1].SetCamContent(*(MCerPhotEvt*)plist.FindObject("MCerPhotEvt"));
+        display[2].SetCamContent(*(MCamEvent*)plist.FindObject("MCameraData"));
+        display[3].SetCamContent(*(MCamEvent*)plist.FindObject("MCameraData"));
+        TArrayF lvl(2);
+        lvl[0] = clean.GetCleanLvl2();
+        lvl[1] = clean.GetCleanLvl1();
+        display[3].SetLevels(lvl);
+
+        for (int i=1; i<=4; i++)
+        {
+            c.GetPad(i)->GetPad(1)->Modified();
+            c.GetPad(i)->GetPad(1)->Update();
+        }
+
+        hillas.Print(*geomcam);
+        hillasext.Print(*geomcam);
+        newimgpar.Print(*geomcam);
+
+        if (!HandleInput())
+            break;
+    } 
+
+    evtloop.PostProcess();
+}
Index: /tags/Mars_V0-8-5/Mars/macros/readCalibration.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/readCalibration.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/readCalibration.C	(revision 9661)
@@ -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): Markus Gaug, 05/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+/////////////////////////////////////////////////////////////////////////////
+//
+//  readCalibration.C
+//
+//  Needs as arguments the run number of a calibration file ("*_C_*.root") and 
+//  the run number of the corresponding pedestal file ("*_P_*.root"). 
+//
+//  The TString inpath has to be set correctly.
+//
+//
+/////////////////////////////////////////////////////////////////////////////
+static const TString inpath = ".";
+//
+// Tell if you want to calibrate times:
+//
+static const  Bool_t useTimes = kTRUE;
+//
+// the default pedestal run for the calibration
+//
+static const Int_t   pedrun = 26210;
+//
+// the default start calibration run 
+//
+static const Int_t   calrun = 26209;
+//
+// A switch to output debugging information about Objects use
+//
+static const Bool_t debug = kFALSE;
+//
+// Tell if you want to use the display:
+//
+static Bool_t useDisplay = kTRUE;
+//
+void readCalibration(const Int_t prun=pedrun, const Int_t crun=calrun)
+{
+
+  const TString pedname  = Form("%s/%i-F0.root", (const char*)inpath,prun);
+  const TString calname  = Form("%s/%i-F1.root", (const char*)inpath,crun);
+  const TString testname = Form("%s/%i-Test.root", (const char*)inpath,crun);
+
+  if (gSystem->AccessPathName(pedname, kFileExists))
+    {
+      cout << "Input file " << pedname << " doesn't exist." << endl;
+      return;
+    }
+
+  if (gSystem->AccessPathName(calname, kFileExists))
+    {
+      cout << "Input file " << calname << " doesn't exist." << endl;
+      return;
+    }
+
+  if (gSystem->AccessPathName(testname, kFileExists))
+    {
+      cout << "Input file " << testname << " doesn't exist." << endl;
+      return;
+    }
+
+  MStatusDisplay = NULL;
+  
+  if (useDisplay)
+    display = new MStatusDisplay;
+
+
+  MPedestalCam             pedcam;
+  MCalibrationChargeCam    chargecam;  
+  MCalibrationQECam        qecam;
+  MCalibrationRelTimeCam   reltimecam;
+  MBadPixelsCam            badcam;
+  MHCalibrationTestCam     testcam;
+  MHCalibrationTestTimeCam testtime;
+
+  cout << "Reading from file: " << pedname << endl;
+
+  TFile pedfile(pedname, "READ");
+  if (pedcam.Read()<=0)
+    {
+      cout << "Unable to read MPedestalCam from " << pedname << endl;
+      return;
+    }
+  
+  if (useDisplay)
+    {
+      if (display->GetCanvas("Pedestals"))
+        display->Read();
+    }
+  
+  cout << "Reading from file: " << calname << endl;
+
+  TFile calfile(calname, "READ");
+  if (chargecam.Read()<=0)
+    {
+      cout << "Unable to read MCalibrationChargeCam from " << calname << endl;
+      return;
+    }
+
+  if (qecam.Read()<=0)
+    {
+      cout << "Unable to read MCalibrationQECam from " << calname << endl;
+      return;
+    }
+
+    if (reltimecam.Read()<=0)
+    {
+      cout << "Unable to read MCalibrationRelTimeCam from " << calname << endl;
+      return;
+    }
+    
+    if (calfile.FindKey("MBadPixelsCam"))
+      {
+        MBadPixelsCam bad;
+        if (bad.Read()<=0)
+          {
+            cout << "Unable to read MBadPixelsCam from " << calname << endl;
+            return;
+          }
+        badcam.Merge(bad);
+      }
+
+  if (useDisplay)
+    display->Read();
+    
+  cout << "Reading from file: " << testname << endl;
+
+  TFile testfile(testname, "READ");
+  if (testcam.Read()<=0)
+    {
+      cout << "Unable to read MHCalibrationTestCam from " << testname << endl;
+      return;
+    }
+  if (testtime.Read()<=0)
+    {
+      cout << "Unable to read MHCalibrationTestTimeCam from " << testname << endl;
+      return;
+    }
+  
+  if (useDisplay)
+    display->Read();
+
+  //
+  // List of interesting plots:
+  // 
+/*
+  testcam.GetAverageHiGainArea(0).DrawClone();
+  testcam.GetAverageLoGainArea(0).DrawClone();
+  testcam.GetAverageHiGainArea(1).DrawClone();
+  testcam.GetAverageLoGainArea(1).DrawClone();
+
+  testcam.GetAverageHiGainSector(1).DrawClone();
+  testcam.GetAverageLoGainSector(1).DrawClone();
+  testcam.GetAverageHiGainSector(2).DrawClone();
+  testcam.GetAverageLoGainSector(2).DrawClone();
+  testcam.GetAverageHiGainSector(3).DrawClone();
+  testcam.GetAverageLoGainSector(3).DrawClone();
+  testcam.GetAverageHiGainSector(4).DrawClone();
+  testcam.GetAverageLoGainSector(4).DrawClone();
+  testcam.GetAverageHiGainSector(5).DrawClone();
+  testcam.GetAverageLoGainSector(5).DrawClone();
+  testcam.GetAverageHiGainSector(6).DrawClone();
+  testcam.GetAverageLoGainSector(6).DrawClone();
+*/
+
+
+
+
+}
+
Index: /tags/Mars_V0-8-5/Mars/macros/readMagic.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/readMagic.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/readMagic.C	(revision 9661)
@@ -0,0 +1,229 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////////
+//
+// readMagic.C
+// ===========
+//
+// This is a demonstration program showing how to do particular processing
+// on a single event basis. Here we simply display uncleand und cleand
+// images.
+// Therefor MInteractiveTask is used, which gives you the possibility
+// to develop new tasks without the need of compilation.
+// The input is a merpp raw-data file.
+//
+///////////////////////////////////////////////////////////////////////////
+
+Bool_t HandleInput()
+{
+    // This must be there to get accesss to the GUI while the macro
+    // is still running!
+
+    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;
+}
+
+//
+// Setup the data-members of your 'virtual' class
+//
+MHCamera display[4];
+
+TCanvas   *c;
+MParList  *fParList;
+MTaskList *fTaskList;
+
+//
+// Called like all PreProcess functions of tasks. Get the access to
+// the containers necessary for you.
+//
+Int_t PreProcess(MParList *plist)
+{
+    // Get parameter and tasklist, see Process
+    fParList = plist;
+    fTaskList = (MTaskList*)plist->FindObject("MTaskList");
+
+    // Get camera geoemtry
+    MGeomCam *geomcam = (MGeomCam*)plist->FindObject("MGeomCam");
+
+    // setup canvas and camera-histograms
+    c = new TCanvas("Events", "Real Events", 600, 600);
+    c->SetBorderMode(0);
+    c->Divide(2,2);
+    for (int i=0; i<4; i++)
+    {
+        display[i].SetGeometry(*geomcam);
+        c->cd(i+1);
+        display[i].Draw();
+        gPad->cd(1);
+        plist->FindObject("MHillas")->Draw();
+    }
+    return kTRUE;
+}
+
+//
+// Called like all Process functions of tasks. Process a single
+// event - here display it.
+//
+Int_t Process()
+{
+    // For simplicity we search in the Process function for the
+    // objects. This is deprectaed! Store the pointers to the objects
+    // as data member and get the pointers in PreProcess.
+    MReadMarsFile *read = (MReadMarsFile*)fTaskList->FindObject("MRead");
+    MClone *clone = (MClone*)fTaskList->FindObject("MClone");
+    MImgCleanStd *clean = (MImgCleanStd*)fTaskList->FindObject("MImgCleanStd");
+    MGeomCam *geom = (MGeomCam*)fParList->FindObject("MGeomCam");
+
+    // Ouput event number
+    cout << "Event #" << read->GetNumEntry() << ":" << endl;
+
+    // Fill the data into your camera-histograms
+    display[0].SetCamContent(*(MCerPhotEvt*)clone->GetClone());
+    display[1].SetCamContent(*(MCerPhotEvt*)fParList->FindObject("MCerPhotEvt"));
+    display[2].SetCamContent(*(MCameraData*)fParList->FindObject("MCameraData"));
+    display[3].SetCamContent(*(MCameraData*)fParList->FindObject("MCameraData"));
+
+    // Setup the cleaning level histogram
+    TArrayF lvl(2);
+    lvl[0] = clean->GetCleanLvl2();
+    lvl[1] = clean->GetCleanLvl1();
+    display[3].SetLevels(lvl);
+
+    // Update the display
+    for (int i=1; i<=4; i++)
+    {
+        c->GetPad(i)->GetPad(1)->Modified();
+        c->GetPad(i)->GetPad(1)->Update();
+    }
+
+    // print the data on the console
+    ((MHillas*)fParList->FindObject("MHillas"))->Print(*geom);
+    ((MHillasExt*)fParList->FindObject("MHillasExt"))->Print(*geom);
+    ((MNewImagePar*)fParList->FindObject("MNewImagePar"))->Print(*geom);
+
+    // wait for 'return'
+    return HandleInput();
+}
+
+//
+// Called like all PostProcess functions of tasks. Delete
+// instanciated objects.
+//
+Int_t PostProcess()
+{
+    delete c;
+}
+
+void readMagic(const char *fname="../Proton*.root")
+{
+    // Setup parameter- and tasklist
+    MParList  plist;
+    MTaskList tlist;
+
+    plist.AddToList(&tlist);
+
+    // setup reading task
+    MReadMarsFile read("Events", fname);
+    read.DisableAutoScheme();
+
+    // setup a task making sure that all arrays are resized correctly
+    MGeomApply geomapl;
+
+    // Setup a print task calling TObject::Print
+    MPrint print1("MMcEvt");
+    MPrint print2("MRawEvtHeader");
+    // Skip them if conatainers are not found
+    print1.EnableSkip();
+    print2.EnableSkip();
+
+    // Copy MC pedestals to apropriate conatiners (if MC file)
+    MMcPedestalCopy   pcopy;
+    MMcPedestalNSBAdd pnsb;
+
+    // Calculate signal and pedestal from data (use MCerPhotCalc
+    // in case of MC files)
+    MCerPhotAnal2     ncalc;
+
+    // Blind Pixel Treatment (deprecated, will be replaced by
+    // MBadPixel*)
+    MBlindPixelCalc   blind;
+    blind.SetUseInterpolation();
+
+    // Clone MCerPhotEvt befor eimage cleaning
+    MClone            clone("MCerPhotEvt");
+
+    // Setup image cleaning
+    MImgCleanStd      clean;
+
+    // Setup calculation of Image parameters
+    MHillasCalc       hcalc;
+
+    // Setup intercative task calling the functions defined above
+    MTaskInteractive  mytask;
+
+    mytask.SetPreProcess(PreProcess);
+    mytask.SetProcess(Process);
+
+    // Setup your tasklist
+    tlist.AddToList(&read);
+    tlist.AddToList(&geomapl);
+    tlist.AddToList(&print1);
+    tlist.AddToList(&print2);
+    tlist.AddToList(&pcopy);
+    tlist.AddToList(&pnsb);
+    tlist.AddToList(&ncalc);
+    tlist.AddToList(&blind);
+    tlist.AddToList(&clone);
+    tlist.AddToList(&clean);
+    tlist.AddToList(&hcalc);
+    tlist.AddToList(&mytask);
+
+    // Run your analysis
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    if (!evtloop.Eventloop())
+        return;
+
+    // Print statistics information about your loop
+    tlist.PrintStatistics();
+}
+
Index: /tags/Mars_V0-8-5/Mars/macros/readcurrents.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/readcurrents.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/readcurrents.C	(revision 9661)
@@ -0,0 +1,90 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 5/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+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 readcurrents(const char *fname="../currents/dcs_arcturus.dat")
+{
+    MParList plist;
+
+    MGeomCamMagic geomcam;
+    MCameraDC     cur;
+    MTaskList     tlist;
+
+    plist.AddToList(&geomcam);
+    plist.AddToList(&cur);
+    plist.AddToList(&tlist);
+
+    MReportFileRead read(fname);
+    read.SetHasNoHeader();
+    read.AddToList("MReportCurrents");
+
+    tlist.AddToList(&read);
+
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    if (!evtloop.PreProcess())
+        return;
+
+    MHCamera display(geomcam);
+    display.Draw();
+    gPad->SetLogy();
+
+    int gifcnt = 0;
+
+    while (tlist.Process())
+    {
+        // cur.Print();
+        display.SetCamContent(cur);
+        gPad->GetPad(1)->Modified();
+        gPad->GetPad(1)->Update();
+        // Remove the comments if you want to go through the file
+        // event-by-event:
+        if (!HandleInput())
+            break;
+    } 
+
+    evtloop.PostProcess();
+}
Index: /tags/Mars_V0-8-5/Mars/macros/readin.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/readin.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/readin.C	(revision 9661)
@@ -0,0 +1,91 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 (tbretz@uni-sw.gwdg.de)
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+
+void readin()
+{
+    //
+    // open the file
+    //
+    TFile input("test.root", "READ");
+
+    //
+    // open the Run Header tree
+    //
+    TTree *runtree = (TTree*) input.Get("RunHeaders") ;
+
+    if (!runtree)
+        return;
+
+    cout << " Entries in Tree RunHeaders: " << runtree->GetEntries() << endl ;
+
+    //
+    // create an instance of MRawRunHeader, enable the branch and
+    // read the header, print it
+    //
+    MRawRunHeader *runheader = new MRawRunHeader();
+    runtree->GetBranch("MRawRunHeader")->SetAddress(&runheader);
+    runtree->GetEvent(0);
+    runheader->Print();
+
+    //
+    // open the Data Tree
+    //
+    TTree *evttree = (TTree*) input.Get("Data") ;
+
+    //
+    // create the instances of the data to read in
+    //
+    MRawEvtHeader  *evtheader = new MRawEvtHeader();
+    MTime          *evttime   = new MTime();
+    MRawEvtData    *evtdata   = new MRawEvtData();
+    MRawCrateArray *evtcrate  = new MRawCrateArray();
+
+    //
+    // enable the corresponding branches
+    //
+    evttree->GetBranch("MRawEvtHeader")->SetAddress(&evtheader);
+    evttree->GetBranch("MTime")->SetAddress(&evttime);
+    evttree->GetBranch("MRawEvtData")->SetAddress(&evtdata);
+    evttree->GetBranch("MRawCrateArray")->SetAddress(&evtcrate);
+
+    //
+    // loop over all events and print the information
+    //
+    Int_t iEnt = evttree->GetEntries();
+    cout << " Entries in Tree Data: " << iEnt << endl;
+
+    for (Int_t i = 0; i<iEnt; i++)
+    {
+      // readin event with the selected branches
+      evttree->GetEvent(i);
+
+      evtheader->Print();
+      evttime->Print();
+      evtcrate->Print();
+      evtdata->Print();
+    } 
+}
+
+
Index: /tags/Mars_V0-8-5/Mars/macros/readpix.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/readpix.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/readpix.C	(revision 9661)
@@ -0,0 +1,97 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 (tbretz@uni-sw.gwdg.de)
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+
+#include <iomanip>
+
+void readpix()
+{
+    //
+    // open the file
+    //
+    TFile input("delme.root", "READ");
+
+    //
+    // open the Run Header tree
+    //
+    TTree *runtree = (TTree*) input.Get("RunHeaders") ;
+
+    if (!runtree)
+        return;
+
+    cout << " Entries in Tree RunHeaders: " << runtree->GetEntries() << endl ;
+
+    //
+    // create an instance of MRawRunHeader, enable the branch and
+    // read the header, print it
+    //
+    MRawRunHeader *runheader = new MRawRunHeader();
+    runtree->GetBranch("MRawRunHeader")->SetAddress(&runheader);
+    runtree->GetEvent(0);
+    runheader->Print();
+
+    //
+    // open the Data Tree
+    //
+    TTree *evttree = (TTree*) input.Get("Data") ;
+
+    //
+    // create the instances of the data to read in
+    //
+    MRawEvtData *evtdata = new MRawEvtData();
+
+    //
+    // enable the corresponding branches
+    //
+    evttree->GetBranch("MRawEvtData")->SetAddress(&evtdata);
+
+    evttree->GetEvent(0);
+
+    MRawEvtPixelIter pixel(evtdata);
+
+    while (pixel.Next())
+    {
+       
+       cout << "Pixel Nr: " << dec << pixel.GetPixelId() << " ";
+       cout << setfill('0') << endl;
+      
+       cout << "Hi Gains: ";
+       for (int i=0; i<evtdata->GetNumHiGainSamples(); i++)
+	  cout << setw(3) << (UInt_t)pixel.GetHiGainFadcSamples()[i];
+       cout << endl;
+      
+       cout << "Lo Gains: ";
+       if (pixel.IsLoGain())
+	  for (int i=0; i<evtdata->GetNumLoGainSamples(); i++)
+	     cout << setw(3) << (UInt_t)pixel.GetLoGainFadcSamples()[i];
+       cout << endl << endl;
+
+       if (pixel.GetPixelId() == 11)
+	 pixel.Draw();
+    };
+}
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/macros/readraw.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/readraw.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/readraw.C	(revision 9661)
@@ -0,0 +1,91 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 (tbretz@uni-sw.gwdg.de)
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+
+void readraw()
+{
+    //
+    // open the file
+    //
+    TFile input("test.root", "READ");
+
+    //
+    // open the Run Header tree
+    //
+    TTree *runtree = (TTree*) input.Get("RunHeaders") ;
+
+    if (!runtree)
+        return;
+
+    cout << " Entries in Tree RunHeaders: " << runtree->GetEntries() << endl ;
+
+    //
+    // create an instance of MRawRunHeader, enable the branch and
+    // read the header, print it
+    //
+    MRawRunHeader *runheader = new MRawRunHeader();
+    runtree->GetBranch("MRawRunHeader")->SetAddress(&runheader);
+    runtree->GetEvent(0);
+    runheader->Print();
+
+    //
+    // open the Data Tree
+    //
+    TTree *evttree = (TTree*) input.Get("Data") ;
+
+    //
+    // create the instances of the data to read in
+    //
+    MRawEvtHeader  *evtheader = new MRawEvtHeader();
+    MTime          *evttime   = new MTime();
+    MRawEvtData    *evtdata   = new MRawEvtData();
+    MRawCrateArray *evtcrate  = new MRawCrateArray();
+
+    //
+    // enable the corresponding branches
+    //
+    evttree->GetBranch("MRawEvtHeader")->SetAddress(&evtheader);
+    evttree->GetBranch("MTime")->SetAddress(&evttime);
+    evttree->GetBranch("MRawEvtData")->SetAddress(&evtdata);
+    evttree->GetBranch("MRawCrateArray")->SetAddress(&evtcrate);
+
+    //
+    // loop over all events and print the information
+    //
+    Int_t iEnt = evttree->GetEntries();
+    cout << " Entries in Tree Data: " << iEnt << endl;
+
+    for (Int_t i = 0; i<iEnt; i++)
+    {
+      // readin event with the selected branches
+      evttree->GetEvent(i);
+
+      evtheader->Print();
+      evttime->Print();
+      evtcrate->Print();
+      evtdata->Print();
+    } 
+}
+
+
Index: /tags/Mars_V0-8-5/Mars/macros/readrep.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/readrep.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/readrep.C	(revision 9661)
@@ -0,0 +1,125 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// This macro demonstrates how to read a central control report file.
+// (rootification, see merpp, too)
+//
+// In a second eventloop it gives an example on how to read such a root file.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+void readrep(const char *fname="CC_2003_11_04_23_53_18.rep")
+{
+    //
+    // Read a report file and write containers into a root file
+    //
+    MParList  plist;
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    MReportFileRead read(fname);
+    tlist.AddToList(&read);
+
+    read.AddToList("DAQ");
+    read.AddToList("Drive");
+    read.AddToList("Camera");
+    read.AddToList("Trigger");
+
+    MWriteRootFile write("test.root");
+    write.AddContainer("MReportCamera",      "Camera");
+    write.AddContainer("MTimeCamera",        "Camera");
+    write.AddContainer("MCameraAUX",         "Camera");
+    write.AddContainer("MCameraCalibration", "Camera");
+    write.AddContainer("MCameraCooling",     "Camera");
+    write.AddContainer("MCameraHV",          "Camera");
+    write.AddContainer("MCameraLV",          "Camera");
+    write.AddContainer("MCameraLids",        "Camera");
+    write.AddContainer("MReportTrigger",     "Trigger");
+    write.AddContainer("MTimeTrigger",       "Trigger");
+    write.AddContainer("MReportDrive",       "Drive");
+    write.AddContainer("MTimeDrive",         "Drive");
+    tlist.AddToList(&write);
+
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    if (!evtloop.Eventloop())
+        return;
+
+    tlist.PrintStatistics();
+
+    // ----------------------------------------------------------------
+    //
+    // Read a report file and write containers into a root file
+    //
+    MTaskList tlist2;
+    plist.Replace(&tlist2);
+
+    // Create a tasklist to process the read events from the Camera tree
+    MTaskList list1("ProcessCamera");
+    MPrint print1("MTimeCamera");
+    list1.AddToList(&print1);
+
+    // Create a tasklist to process the read events from the Drive tree
+    MTaskList list2("ProcessDrive");
+    MPrint print2("MTimeDrive");
+    list2.AddToList(&print2);
+
+    // Tell the reader to read the trees Drive, Trigger and Camera
+    MReadReports read;
+    read.AddTree("Drive");
+    read.AddTree("Trigger");
+    read.AddTree("Camera");
+    //read.AddTree("Events", "MTime"); // for later use!
+
+    // Now (not earlier!) set the file to read!
+    read.AddFile("test.root");
+
+    // First read the events
+    tlist.AddToList(&read);
+    // Process the events from the Camera tree with the task list list1
+    tlist.AddToList(&list1, "Camera");
+    // Process the events from the Camera tree with the task list list2
+    tlist.AddToList(&list2, "Drive");
+
+    // The task lists list1 and list2 are only executed (according to
+    // their stream id - the second argument of AddToList) if a
+    // corresponding event was read and MReadReports has set the stream
+    // id accoringly. MReadReports always sets the stream id to the name
+    // of the tree from which the event was read
+
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    //
+    // Execute the eventloop which should print the time-stamps of the subsystem
+    // events from Drive and Camera in the correct order...
+    //
+    if (!evtloop.Eventloop())
+        return;
+
+    tlist.PrintStatistics();
+}
Index: /tags/Mars_V0-8-5/Mars/macros/readrfl.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/readrfl.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/readrfl.C	(revision 9661)
@@ -0,0 +1,106 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 5/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+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;
+}
+
+Bool_t JumpTo(MTaskList &tlist, MReadRflFile &read, int runno, int evtno)
+{
+    if (runno<0 || evtno<0)
+        return tlist.Process();
+
+    return read.SearchFor(runno, evtno);
+}
+
+void readrfl(int runno=-1, int evtno=-1, const char *fname="Gamma_zbin0_90_7_50700to50704_w0.rfl")
+{
+    MParList plist;
+
+    MGeomCamMagic geomcam;
+    MRflEvtData   event;
+    MRflEvtHeader evthead;
+    MRflRunHeader runhead;
+    MTaskList     tlist;
+
+    plist.AddToList(&geomcam);
+    plist.AddToList(&event);
+    plist.AddToList(&evthead);
+    plist.AddToList(&runhead);
+    plist.AddToList(&tlist);
+
+    MReadRflFile read(fname);
+    tlist.AddToList(&read);
+
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    if (!evtloop.PreProcess())
+        return;
+
+    MHCamera display(geomcam);
+    display.Draw();
+    gPad->cd(1);
+    event.Draw();
+
+
+
+    cout << "Runno: " << runno << "  Eventno: " << evtno << endl;
+
+    while (JumpTo(tlist, read, runno, evtno))
+    {
+        runno = -1;
+
+        cout << "Run #" << runhead.GetRunNumber() << "   ";
+        cout << "Event #" << evthead.GetEvtNumber() << endl;
+
+	display.SetCamContent(event);
+
+	gPad->Modified();
+	gPad->Update();
+	
+        if (!HandleInput())
+            break;
+    } 
+
+    evtloop.PostProcess();
+}
Index: /tags/Mars_V0-8-5/Mars/macros/rootlogon.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/rootlogon.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/rootlogon.C	(revision 9661)
@@ -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): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////////
+//
+// rootlogon.C
+// ===========
+//
+// This file is the startup script ("autoexec.bat") executed when root is
+// started. The definition which file to start is done in ".rootrc".
+// There are three files which are automatically processed by root at
+// startup: A systemwide .rootrc, one in your home directory and one
+// in the current directory.
+// So rootlogon.C is correctly executed if your start root from your
+// Mars directory.
+//
+// The script setupts some small environmental things and makes
+// sure that the Mars shared object (libmars.so) is loaded. This shared
+// object gives you access to all Mars features from within the root
+// interpreter.
+//
+// If libmars.so is not found in the current directory we search in the
+// directory given in "MARSSYS" environment variable.
+//
+///////////////////////////////////////////////////////////////////////////
+
+Bool_t isloaded()
+{
+    TString str = gSystem->GetLibraries("libmars.so");
+
+    return !str.IsNull();
+}
+
+void unload()
+{
+    if (!isloaded())
+        return;
+
+    cout << "Unloading 'libmars.so'... " << flush;
+    if (gSystem->Unload("libmars.so"))
+        cout << "error." << endl;
+    else
+        cout << "done." << endl << endl;
+}
+
+bool load(TString &dir)
+{
+    if (isloaded())
+        return;
+
+    cout << "\033[33m\033[1m" << "Loading '" << dir << "libmars.so'... " << "\033[0m" << flush;
+
+    if (dir.IsNull())
+        dir = "./";
+
+    if (gSystem->Load(dir+"libmars.so")!=0)
+    {
+        cout << "\033[33m\033[1m" << "error." << endl;
+        cout << "\033[0m" << endl;
+        return false;
+    }
+    else
+    {
+        MParContainer::Class()->IgnoreTObjectStreamer();
+        MArray::Class()->IgnoreTObjectStreamer();
+        cout << "\033[33m\033[1m" << "done." << endl;
+        cout << "\033[0m" << endl;
+        return true;
+    }
+}
+/*
+void make()
+{
+    unload();
+
+    if (gSystem->Exec("make"))
+    {
+        cout << "Error calling make..." << endl;
+        return;
+    }
+
+    load();
+}
+*/
+void rootlogon()
+{
+    cout << endl;
+
+    const Bool_t fileexist = !gSystem->AccessPathName("libmars.so", kFileExists);
+
+    TString dir = fileexist ? "" : gSystem->Getenv("MARSSYS");
+    if (!dir.IsNull())
+    {
+        cout << "\033[34m\033[1m" << "Searching Mars in " << dir << " (MARSSYS)" << "\033[0m" << endl << endl;
+
+        if (!dir.EndsWith("/"))
+            dir += "/";
+    }
+
+    if (!load(dir))
+        return;
+
+    gInterpreter->AddIncludePath(dir+"macros");
+    gInterpreter->AddIncludePath(dir+"manalysis");
+    gInterpreter->AddIncludePath(dir+"mastro");
+    gInterpreter->AddIncludePath(dir+"mbase");
+    gInterpreter->AddIncludePath(dir+"mbadpixels");
+    gInterpreter->AddIncludePath(dir+"mcamera");
+    gInterpreter->AddIncludePath(dir+"mcalib");
+    gInterpreter->AddIncludePath(dir+"mdata");
+    gInterpreter->AddIncludePath(dir+"mfbase");
+    gInterpreter->AddIncludePath(dir+"mfileio");
+    gInterpreter->AddIncludePath(dir+"mfilter");
+    gInterpreter->AddIncludePath(dir+"mgeom");
+    gInterpreter->AddIncludePath(dir+"mgui");
+    gInterpreter->AddIncludePath(dir+"mhbase");
+    gInterpreter->AddIncludePath(dir+"mhist");
+    gInterpreter->AddIncludePath(dir+"mhistmc");
+    gInterpreter->AddIncludePath(dir+"mhvstime");
+    gInterpreter->AddIncludePath(dir+"mimage");
+    gInterpreter->AddIncludePath(dir+"mjobs");
+    gInterpreter->AddIncludePath(dir+"mmain");
+    gInterpreter->AddIncludePath(dir+"mmc");
+    gInterpreter->AddIncludePath(dir+"mmontecarlo");
+    gInterpreter->AddIncludePath(dir+"mpedestal");
+    gInterpreter->AddIncludePath(dir+"mpointing");
+    gInterpreter->AddIncludePath(dir+"mranforest");
+    gInterpreter->AddIncludePath(dir+"mraw");
+    gInterpreter->AddIncludePath(dir+"mreflector");
+    gInterpreter->AddIncludePath(dir+"mreport");
+    gInterpreter->AddIncludePath(dir+"msignal");
+    gInterpreter->AddIncludePath(dir+"msql");
+    gInterpreter->AddIncludePath(dir+"mtools");
+
+    if (TString("linux")==gSystem->GetBuildArch())
+    {
+        TString options = " -O -pipe -Wall -Woverloaded-virtual -fno-exceptions -fPIC ";
+
+        TString s = "cd $BuildDir ; ";
+        s += "g++ -c" + options + "-Iinclude -D_REENTRANT $IncludePath $SourceFiles ; ";
+        s += "g++ $ObjectFiles -shared -Wl,-soname,$LibName.so -O -o $SharedLib";
+        gSystem->SetMakeSharedLib(s);
+    }
+
+    cout << "\033[32m" << "Welcome to the Mars Root environment." << "\033[0m" << endl;
+    cout << endl;
+}
Index: /tags/Mars_V0-8-5/Mars/macros/runbook.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/runbook.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/runbook.C	(revision 9661)
@@ -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): Thomas Bretz  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////////
+//
+// runbook.C
+// =========
+//
+// This is an example macro how to extract the runbook information of
+// a given date from the runbook files.
+//
+// The argument is a date in regexp format, eg.
+//   .x runbook.C("2004-05-1[0-9]")
+//
+// With an MDirIter you can tell the macro which directories and files
+// should be searched.
+//
+// The output are the runbook entries matching your query.
+//
+///////////////////////////////////////////////////////////////////////////
+
+void Wrap(TString &str)
+{
+    // Wrap lines to 80 chars
+    while (str.Length()>80)
+    {
+        TString ss = str(0, 80);
+        Int_t l = ss.Last(' ');
+        if (l<0)
+            break;
+        cout << str(0, l) << endl;
+        str.Remove(0, l);
+    }
+    cout << str << endl;
+}
+
+void ProcessFile(TString fname, TString date)
+{
+    // File processed
+    cout << fname << endl;
+
+    // Open file
+    ifstream fin(fname);
+
+    TString line;
+
+    int i=81;
+
+    TRegexp r0("20[0-2][0-9]-[0-1][0-9]-[0-3][0-9] [0-2][0-9]:[0-5][0-9]:[0-5][0-9]");
+    TRegexp r1(date+" [0-2][0-9]:[0-5][0-9]:[0-5][0-9]");
+
+    int lcnt=0;
+
+    int print = 0;
+
+    while (!fin.eof())
+    {
+        // Read file line by line
+        char *txt=new char[i];
+        fin.getline(txt, i-1);
+
+        if (lcnt++<4)
+            continue;
+
+        if (!fin)
+            txt[i-1]=0;
+
+        line += txt;
+        delete txt;
+
+        if (line.Length()==0)
+        {
+            if (print)
+                cout << endl;
+            continue;
+        }
+
+        if (!fin)
+        {
+            i *= 2;
+            fin.clear();
+            continue;
+        }
+
+        // Check whether line matches regexp
+        if (!line(r0).IsNull())
+            print = !line(r1).IsNull();
+
+        // Wrap lines to 80 chars
+        if (print)
+            Wrap(line);
+        line = "";
+        i=81;
+    }
+    cout << "DONE." << endl;
+}
+
+void runbook(const char *d="20[0-2][0-9]-[0-1][0-9]-[0-3][0-9]")
+{
+    // Regexp to check for valid date
+    TString regexp = "20[0-2][0-9]-[0-1][0-9]-[0-3][0-9]";
+
+    if (regexp!=d)
+    {
+        TRegexp r(regexp);
+
+        TString date=d;
+        if (date(r).IsNull())
+        {
+            cout << "ERROR - Date has wrong format (2003-05-06)" << endl;
+            return;
+        }
+    }
+
+    // Tell which dierctories and files to search
+    MDirIter Next;
+    Next.AddDirectory("/home/MAGIC/online_data/runbook", "CC_*.rbk");
+
+    // Loop over files
+    TString name;
+    while (1)
+    {
+        name=Next();
+        if (name.IsNull())
+            break;
+
+        ProcessFile(name, d);
+    }
+}
Index: /tags/Mars_V0-8-5/Mars/macros/sectorvstime.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/sectorvstime.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/sectorvstime.C	(revision 9661)
@@ -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@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// sectorvstime.C
+// ==============
+//
+// In this example we plot the mean content of the right and left half of
+// camera. As an input we use a class derived from MCamEvent. Here this
+// are dc currents read directly from a camera control report file.
+//
+// The output are two histograms one for each half.
+//
+/////////////////////////////////////////////////////////////////////////////
+
+void sectorvstime()
+{
+    // Initialize Mars environment
+    MParList  plist;
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    // Create Magic camera geometry
+    MGeomCamMagic cam;
+    plist.AddToList(&cam);
+
+    // Which DC file to read?
+    MReportFileRead read("/data/MAGIC/Period013/cacodata/2004_01_26/dc_2004_01_26_05_35_10_12117_OffMrk421-1.txt");
+    read.SetHasNoHeader();
+    read.AddToList("MReportCurrents");
+
+    // Initialize histogram
+    MHSectorVsTime hist1;
+    hist1.SetNameTime("MTimeCurrents");
+
+    // Define sectors you want to display the mean from
+    TArrayI s0(3);
+    s0[0] = 6;
+    s0[1] = 1;
+    s0[2] = 2;
+
+    // Define area index [0=inner, 1=outer]
+    TArrayI inner(1);
+    inner[0] = 0;
+
+    // Don't call this if you want to have all sectors
+    hist1.SetSectors(s0);
+
+    // Don't call this if you want to have all area indices
+    hist1.SetAreaIndex(inner);
+
+    // Task to fill the histogram
+    MFillH fill1(&hist1, "MCameraDC");
+
+    // Also fill a histogram with the mean of all pixels
+    MHCamEvent hist2;
+    MFillH fill2(&hist2, "MCameraDC");
+
+    // Setup Tasklist
+    tlist.AddToList(&read);
+    tlist.AddToList(&fill1);
+    tlist.AddToList(&fill2);
+
+    // Setup Eventloop
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    // Run Eventloop
+    if (!evtloop.Eventloop())
+        return;
+
+    // Print some statistics
+    tlist.PrintStatistics();
+
+    // Draw clones of the histograms
+    hist1.DrawClone();
+    hist2.DrawClone();
+}
Index: /tags/Mars_V0-8-5/Mars/macros/spline.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/spline.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/spline.C	(revision 9661)
@@ -0,0 +1,109 @@
+/* This macro is defined as a class for debugging (with CInt) reasons
+
+To use it at the root prompt type:
+
+root [0] .L spline.C
+root [1] TestSpline::sp()
+*/
+/* Example of a spline. You can use it as Test. If you think there are some
+   bugs in the MCubicSpline class please mail to: raducci@fisica.uniud.it */
+
+class TestSpline
+{
+public:
+    void sp();
+};
+
+void TestSpline::sp()
+{
+gROOT -> Reset();
+
+//Here are defined the points. X goes from 0 to 14 (as the fadc slices...)
+//Y are arbitrary values
+
+/* User Change */
+const Byte_t y[]={0x0F,0x10,0x2F,0x7F,0xAA,0x6C,0x14,0x13,0x15,0x18,0x21,0x12,0x11,0x14,0x13};
+/* End user Change */
+const Byte_t x[]={0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E};
+
+/*This cast is needed only to show graphically the output. Don' t needed if you
+  use the spline to calc the arrival times       */
+
+Int_t *newX = new Int_t[15];
+Int_t *newY = new Int_t[15];
+
+for (Int_t i = 0; i < 15; i++)
+{
+    newX[i] = (Int_t) x[i];
+    newY[i] = (Int_t) y[i];
+}
+
+//Canvas to display output
+TCanvas *c = new TCanvas ("c1","c1",800,600);
+
+//Graph containting only the points (displayed as stars)
+TGraph *g1 = new TGraph(15,newX,newY);
+
+g1 -> Draw("A*");
+
+//Spline constructor(specialized for 15 slices using Bytes as values. There exist another constructor.
+MCubicSpline *s = new MCubicSpline(y);
+
+//*spline and *ab are two arrays containing some values evaluated from the spline
+Double_t *spline = new Double_t[139];
+Double_t *ab     = new Double_t[139];
+Double_t step = 0.0;
+
+for (Int_t i = 0; i < 139; i++)
+{
+    spline[i] = s->Eval(step);
+    ab[i] = step;
+    step += 0.1;
+}
+
+//Graph of the sline. The points calculated are joined with a red line. If the stars lie
+//on the red line, then the Spline class is working properly
+TGraph *g2 = new TGraph(139,ab,spline);
+
+g2 -> SetLineColor(2);
+g2 -> Draw("C");
+
+//Maximum and minimum evaluation
+Double_t *mm   = new Double_t[2];
+Double_t *abmm = new Double_t[2];
+
+mm[0] = s->EvalMin();
+mm[1] = s->EvalMax();
+abmm[0] = s->EvalAbMin();
+abmm[1] = s->EvalAbMax();
+
+//Display the max and the min using two black squares. If they lie on the max and min
+//of the red line, then the Spline class is working properly
+
+TGraph *g3 = new TGraph(2,abmm,mm);
+
+g3 -> SetMarkerStyle(21);
+g3 -> Draw("P");
+
+//Test of the Cardan formula. Find the point(abval) where the Spline value is val
+Double_t val = 82.5;
+Double_t abval = s->FindVal(val, abmm[1], 'l');
+
+//Display this point. Again, if it lies on the red line, then we are right.
+//It's a black triangle
+
+TGraph *g4 = new TGraph(1,&abval,&val);
+
+g4 -> SetMarkerStyle(22);
+g4 -> Draw("P");
+
+//Free memory
+s->~MCubicSpline();
+delete [] newX;
+delete [] newY;
+delete [] spline;
+delete [] ab;
+delete [] mm;
+delete [] abmm;
+
+} 
Index: /tags/Mars_V0-8-5/Mars/macros/sql/filldotrun.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/sql/filldotrun.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/sql/filldotrun.C	(revision 9661)
@@ -0,0 +1,428 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Daniela Dorner, 08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
+!   Author(s): Thomas Bretz, 08/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// filldotrun.C
+// ============
+//
+// This macro is used in the datacenter to automatically fill the run-database
+// with the information stored in the .run-files written by the central
+// control.
+//
+// To following Arehucas versions are Currently supported:
+//   040505-0
+//   040514-0
+//   040518-0
+//
+// Usage:
+//    root -q -l -b filldotrun.C+("/data/MAGIC/Period019/ccdata", kTRUE) 2>&1 | tee filldotrun.log
+//
+// While the first argument is the directory in which all subdirectories where
+// searches for CC_*.run files. All these files were analysed and the run
+// info will be put into the DB, eg:
+//   "/data/MAGIC"                              would do it for all data
+//   "/data/MAGIC/Period019"                    would do it for one Period
+//   "/data/MAGIC/Period019/ccdata/2004_05_17"  would do it for a single day
+//
+// The second argument is the 'dummy-mode'. If it is kTRUE dummy-mode is
+// switched on and nothing will be written into the database. Instead
+// informations about the subtables are displayed. This is usefull for tests
+// when adding a new arehucas version support. If it is kFALSE the information
+// are written into the subtables and the runs info is written into the
+// rundatabase.
+//
+// In the automatic case it makes sense to check the logfiles to make sure
+// that everything is fine...
+//
+// The macro can also be run without ACLiC but this is a lot slower...
+//
+// Remark: Running it from the commandline looks like this:
+//   root -q -l -b filldotrun.C+\(\"path\"\,kFALSE\) 2>&1 | tee filldotrun.log
+//
+/////////////////////////////////////////////////////////////////////////////
+#include <iostream>
+#include <iomanip>
+#include <fstream>
+
+#include <MSQLServer.h>
+#include <TSQLRow.h>
+#include <TSQLResult.h>
+
+#include <TMath.h>
+#include <TRegexp.h>
+
+#include <MTime.h>
+#include <MDirIter.h>
+
+using namespace std;
+
+Bool_t ExistStr(MSQLServer &serv, const char *column, const char *table, const char *test)
+{
+    TString query(Form("SELECT %s FROM %s WHERE %s='%s'", column, table, column, test));
+    TSQLResult *res = serv.Query(query);
+    if (!res)
+        return kFALSE;
+
+    Bool_t rc = kFALSE;
+
+    TSQLRow *row=res->Next();
+    if (row && (*row)[0])
+        rc=kTRUE;
+
+    delete res;
+    return rc;
+}
+
+Int_t QueryNameKEY(MSQLServer &serv, Bool_t dummy, const char *col, const char *name, Bool_t insert=kTRUE)
+{
+    TString query;
+
+    query = Form("SELECT f%sKEY FROM MyMagic.%s WHERE f%sName='%s'", col, col, col, name);
+    TSQLResult *res = serv.Query(query);
+    if (!res)
+    {
+        cout << "ERROR - Query: " << query << endl;
+        return -1;
+    }
+
+    TSQLRow *row=res->Next();
+
+    Int_t rc = row && (*row)[0] ? atoi((*row)[0]) : -1;
+
+    delete res;
+
+    if (rc>=0)
+        return rc;
+
+    if (!insert)
+        return -1;
+
+    query = Form("INSERT MyMagic.%s (f%sName) VALUES (\"%s\");", col, col, name);
+
+    if (dummy)
+    {
+        cout << query << endl;
+        return 0;
+    }
+
+    res=serv.Query(query);
+    if (!res)
+    {
+        cout << "ERROR - Query: " << query << endl;
+        return -1;
+    }
+    delete res;
+
+    Int_t key = QueryNameKEY(serv, dummy, col, name, kFALSE);
+    if (key>0)
+    {
+        cout << "New " << col << ": " << name << endl;
+        return key;
+    }
+
+    cout << "ERROR: " << query << endl;
+    return kFALSE;
+}
+
+
+Int_t insert(MSQLServer &serv, Bool_t dummy, TString filename)
+{
+    ifstream fin(filename);
+
+    TString strng;
+    strng.ReadLine(fin);
+    if (strng!=TString("[CC Plain Run Summary File]"))
+    {
+        cout << filename << ": No Plain Run Summary File" << endl;
+        cout << "First Line: " << strng << endl;
+        cout << endl;
+        return 0;
+    }
+
+    strng.ReadLine(fin);
+    TRegexp reg("[0-9][0-9][0-9][0-9][0-9][0-9]-[0-9]");
+    TString arehucas = strng(reg);
+    arehucas.Prepend("20");
+    arehucas.ReplaceAll("-", "");
+
+    Int_t version = atoi(arehucas.Data());
+    if (version!=200405050 && version!=200405140 && version!=200405180)
+    {
+        cout << filename << ": File Version unknown - please update the macro!" << endl;
+        cout << "Second Line: " << strng << endl;
+        cout << endl;
+        return 0;
+    }
+
+    cout << "  V" << version << " " << flush;
+
+    Int_t cnt=0;
+    while (1)
+    {
+        // ========== Col 1: Run Number =========
+        //Reading the line
+        //and converting some strings to ints/floats
+        strng.ReadToDelim(fin, ' ');
+        if (!fin)
+            break;
+
+        Int_t runnumber = atoi(strng.Data());
+
+        //runnumber=0 means no valid dataset
+        //-> continue
+        if (runnumber == 0)
+        {
+            strng.ReadLine(fin);
+            cout << "Runnumber == 0" << endl;
+            continue;
+        }
+
+        //cout << "RunNo: " << runnumber << " ";
+
+        if (ExistStr(serv, "fRunNumber", "MyMagic.RunData", strng.Data()))
+        {
+            // FIXME: Maybe we can implement an switch to update mode?
+            cout << "Run #" << runnumber << " already existing... skipped." << endl;
+            strng.ReadLine(fin);
+            continue;
+        }
+
+        // ========== Col 1: Run Type =========
+        strng.ReadToDelim(fin, ' ');
+        if (strng.Contains("???"))
+            strng="n/a";
+
+        Int_t runtype = QueryNameKEY(serv, dummy, "RunType", strng.Data(), kFALSE);
+        if (runtype<0)
+        {
+            cout << "ERROR - RunType " << strng << " not available." << endl;
+            strng.ReadLine(fin);
+            continue;
+        }
+
+        //cout << runtype << " ";
+
+        // ========== Col 2,3: Start Time =========
+        TString startdate, starttime;
+        startdate.ReadToDelim(fin, ' ');
+        starttime.ReadToDelim(fin, ' ');
+        //cout << startdate << " " << starttime << " ";
+
+        // ========== Col 4,5: Stop Time =========
+        TString stopdate, stoptime;
+        stopdate.ReadToDelim(fin, ' ');
+        stoptime.ReadToDelim(fin, ' ');
+        //cout << stopdate << " " << stoptime << " ";
+
+        if (startdate.Contains("???"))
+            startdate="0000-00-00";
+        if (starttime.Contains("???"))
+            starttime="00:00:00";
+        if (stopdate.Contains("???"))
+            stopdate="0000-00-00";
+        if (stoptime.Contains("???"))
+            stoptime="00:00:00";
+
+        // ========== Col 6: Source Name =========
+        strng.ReadToDelim(fin, ' ');
+        if (strng.Contains("???"))
+            strng="Unavailable";
+
+        Int_t sourcekey = QueryNameKEY(serv, dummy, "Source", strng.Data());
+        if (sourcekey<0)
+        {
+            strng.ReadLine(fin);
+            continue;
+        }
+        //cout << sourcekey << " ";
+
+        // ========== Col 7, 8: Local source position =========
+        strng.ReadToDelim(fin, ' ');
+        Float_t zd = atof(strng.Data());
+
+        strng.ReadToDelim(fin, ' ');
+        Float_t az = atof(strng.Data());
+
+        //cout << zd << " " << az << " ";
+
+        // ========== Col 9: Number of Events =========
+        strng.ReadToDelim(fin, ' ');
+        Int_t evtno = atoi(strng.Data());
+
+        //cout << evtno << " ";
+
+        // ========== Col 10: Project Name =========
+        strng.ReadToDelim(fin, ' ');
+        if (strng.Contains("???"))
+            strng="Unavailable";
+
+        Int_t projkey = QueryNameKEY(serv, dummy, "Project", strng.Data());
+        if (projkey<0)
+        {
+            strng.ReadLine(fin);
+            continue;
+        }
+        //cout << projkey << " ";
+
+        // ========== Col 10: Trigger Table Name =========
+        strng.ReadToDelim(fin, ' ');
+        if (strng.Contains("???"))
+            strng="n/a";
+
+        Int_t triggerkey = QueryNameKEY(serv, dummy, "TriggerTable", strng.Data());
+        if (triggerkey<0)
+        {
+            strng.ReadLine(fin);
+            continue;
+        }
+        //cout << triggerkey << " ";
+
+        // ========== Col 11-13: TrigRate, L2 UnPresc Rate, L2 Presc Rate ==========
+        strng.ReadToDelim(fin, ' ');
+        Float_t trigrate = atof(strng.Data());
+
+        strng.ReadToDelim(fin, ' ');
+        Float_t l2uprate = atof(strng.Data());
+
+        strng.ReadToDelim(fin, ' ');
+        Float_t l2prrate = atof(strng.Data());
+
+        // ========== Col 14,15: DaqRate, Storage Rate ==========
+        strng.ReadToDelim(fin, ' ');
+        Float_t daqrate = atof(strng.Data());
+
+        strng.ReadToDelim(fin, ' ');
+        Float_t storerate = atof(strng.Data());
+
+        // ========== Col 16: HV table =========
+        if (version==200405050 || version==200405140)
+            strng.ReadToDelim(fin, '\n');
+        else
+            strng.ReadToDelim(fin, ' ');
+        if (strng.Contains("???"))
+            strng="n/a";
+
+        Int_t hvkey = QueryNameKEY(serv, dummy, "HvSettings", strng.Data());
+        if (hvkey<0)
+        {
+            //strng.ReadLine(fin);
+            continue;
+        }
+
+        if (version==200405180)
+            strng.ReadLine(fin);
+
+        //continue;
+
+        //cout << endl;
+
+        // ================================================================
+        // ========== Data read from file now access the database =========
+        // ================================================================
+
+        //assemlbe the query that is needed to insert the values of this run
+        TString query;
+        query += "INSERT MyMagic.RunData SET ";
+
+        query += Form("fRunNumber=%d, ",  runnumber);
+        query += Form("fRunTypeKEY=%d, ", runtype);
+        query += Form("fProjectKEY=%d, ", projkey);
+        query += Form("fSourceKEY=%d, ",  sourcekey);
+        query += Form("fNumEvents=%d, ",  evtno);
+        query += Form("fRunStart=\"%s %s\", ", startdate.Data(), starttime.Data());
+        query += Form("fRunStop=\"%s %s\", ", stopdate.Data(), stoptime.Data());
+        query += Form("fTriggerTableKEY=%d, ", triggerkey);
+        query += Form("fHvSettingsKEY=%d, ", hvkey);
+        if (!TMath::IsNaN(zd) && TMath::Finite(zd))
+            query += Form("fZenithDistance=%d, ", TMath::Nint(zd));
+        if (!TMath::IsNaN(az) && TMath::Finite(az))
+            query += Form("fAzimuth=%d, ", TMath::Nint(az));
+        if (!TMath::IsNaN(storerate) && TMath::Finite(storerate))
+            query += Form("fDaqStoreRate=%d, ", TMath::Nint(storerate));
+        if (!TMath::IsNaN(daqrate) && TMath::Finite(daqrate))
+            query += Form("fDaqTriggerRate=%d, ", TMath::Nint(daqrate));
+        if (!TMath::IsNaN(trigrate) && TMath::Finite(trigrate))
+            query += Form("fMeanTriggerRate=%d, ", TMath::Nint(trigrate));
+        if (!TMath::IsNaN(l2prrate) && TMath::Finite(l2prrate))
+            query += Form("fL2RatePresc=%d, ", TMath::Nint(l2prrate));
+        if (!TMath::IsNaN(l2uprate) && TMath::Finite(l2uprate))
+            query += Form("fL2RateUnpresc=%d, ", TMath::Nint(l2uprate));
+        query += "fMagicNumberKEY=1";
+
+        //cout << query << endl;
+        cnt++;
+
+        //cout << query << endl;
+        //continue;
+
+        if (dummy)
+            continue;
+
+        //send query, add dataset to DB
+        TSQLResult *res = serv.Query(query);
+        if (!res)
+        {
+            cout << query << " - FAILED!" << endl;
+            continue;
+        }
+
+        delete res;
+    }
+
+    return cnt;
+
+}
+
+// This tool will work from Period017 (2004_05_17) on...
+void filldotrun(const char *path="/data/MAGIC/Period018/ccdata", Bool_t dummy=kTRUE)
+{
+    MSQLServer serv("mysql://hercules:d99swMT!@localhost");
+    if (!serv.IsConnected())
+    {
+        cout << "ERROR - Connection to database failed." << endl;
+        return;
+    }
+    cout << "filldotrun" << endl;
+    cout << "----------" << endl;
+    cout << endl;
+    cout << "Connected to " << serv.GetName() << endl;
+    cout << "Search Path: " << path << endl;
+    cout << endl;
+
+    MDirIter Next(path, "CC_*.run", -1);
+    while (1)
+    {
+        TString name = Next();
+        if (name.IsNull())
+            break;
+
+        cout << name(TRegexp("CC_.*.run", kFALSE)) << flush;
+
+        Int_t n = insert(serv, dummy, name);
+
+        cout << " <" << n << "> " << (dummy?"DUMMY":"") << endl;
+    }
+}
Index: /tags/Mars_V0-8-5/Mars/macros/sql/readrbk.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/sql/readrbk.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/sql/readrbk.C	(revision 9661)
@@ -0,0 +1,186 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 08/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// This macro is used to read the central control runbook files from
+// the data center and store their contents in the runbook-database.
+//
+// Usage: root readrbk.C("/data/MAGIC/Period014")
+//
+// This command will loop over all subdirectories, read all *.rbk files and
+// store its contents in the database (if an entry with the same date is
+// already existing it is ignored).
+//
+// Make sure, that database and password are corretly set in the macro.
+//
+///////////////////////////////////////////////////////////////////////////
+
+// --------------------------------------------------------------------------
+//
+// Checks whether an entry for this date is already existing
+//
+Bool_t ExistStr(TSQLServer *serv, const char *column, const char *table, const char *test)
+{
+    TString query(Form("SELECT %s FROM %s WHERE %s='%s'", column, table, column, test));
+    TSQLResult *res = serv->Query(query);
+    if (!res)
+        return kFALSE;
+
+    TSQLRow *row;
+
+    Bool_t rc = kFALSE;
+    while (row=res->Next())
+    {
+        if ((*row)[0])
+        {
+            rc = kTRUE;
+            break;
+        }
+    }
+
+    delete res;
+
+    return rc;
+}
+
+// --------------------------------------------------------------------------
+//
+// insert the entries from this runbook file into the database
+//
+void insert(TString fname)
+{
+    //cout << endl;
+    //cout << "FILE: " << fname << endl;
+
+    ifstream fin(fname);
+    if (!fin)
+    {
+        cout << "Could not open file " << fname << endl;
+        return;
+    }
+
+    TSQLServer *serv = TSQLServer::Connect("mysql://localhost:3306", "hercules", "d99swMT!");
+    if (!serv)
+    {
+        cout << "Could not connect so mysqld..." << endl;
+        return;
+    }
+
+    TRegexp regexp("^.20[0-9][0-9]-[0-1][0-9]-[0-3][0-9] [0-2][0-9]:[0-5][0-9]:[0-5][0-9].$", kFALSE);
+
+    Int_t num=0;
+
+    Bool_t valid = kFALSE;
+    TString entry;
+    while (1)
+    {
+        TString line;
+        line.ReadLine(fin);
+        if (!fin)
+            break;
+
+        TString l0 = line(regexp);
+
+        if (l0.IsNull())
+        {
+            entry += line;
+            entry += "\n";
+            continue;
+        }
+        if (!valid)
+        {
+            valid = kTRUE;
+            entry = "";
+            //cout << "First entry skipped..." << endl;
+            continue;
+        }
+
+        if (entry.Contains("Operator names: "))
+        {
+            //cout << "OPERATORS: " << entry << flush;
+            entry="";
+            continue;
+        }
+
+        if (entry.Contains("CALIBRATION RUN STATISTICS") ||
+            entry.Contains("DATA RUN STATISTICS")        ||
+            entry.Contains("PEDESTAL RUN STATISTICS"))
+        {
+            //cout << "Run entry skipped..." << endl;
+            entry ="";
+            continue;
+        }
+
+        TString date(l0(1, l0.Length()-2));
+
+        if (ExistStr(serv, "fRunBookDate", "MyMagic.RunBook", date))
+        {
+            entry ="";
+            continue;
+        }
+
+        entry.ReplaceAll("'", "\\'");
+        entry.ReplaceAll("\"", "\\\"");
+
+        TString query("INSERT MyMagic.RunBook (fRunBookDate, fRunBookText) VALUES (\"");
+        query += date;
+        query += "\", \"";
+        query += entry;
+        query += "\");";
+
+        TSQLResult *res = serv->Query(query);
+        if (!res)
+            cout << "ERROR: " << query << endl << endl;
+        else
+        {
+            delete res;
+            num++;
+        }
+
+        entry = "";
+    }
+
+    serv->Close();
+    delete serv;
+
+    cout << fname << " <" << num << ">" << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// loop over all files in this path
+//
+void readrbk(TString path="/data/MAGIC/Period014")
+{
+    MDirIter Next(path, "*.rbk", -1);
+
+    while (1)
+    {
+        TString name = Next();
+        if (name.IsNull())
+            break;
+        insert(name);
+    }
+}
Index: /tags/Mars_V0-8-5/Mars/macros/star.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/star.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/star.C	(revision 9661)
@@ -0,0 +1,131 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 5/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  STAR - STandard Analysis and Reconstruction
+//
+// This macro is the standard converter to convert raw data into image
+// parameters. It is a demonstration how the star-executable implementation
+// looks like.
+//
+// As an input you need a Merpp output file (raw data).
+// All parameters are written to an output file called starfile.root.
+// For the calculation an arbitrary signal extractor (MCerPhotAnal2/Calc)
+// is used.
+//
+/////////////////////////////////////////////////////////////////////////////
+
+void star()
+{
+    //
+    // Create a empty Parameter List and an empty Task List
+    // The tasklist is identified in the eventloop by its name
+    //
+    MParList  plist;
+
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    //
+    // Now setup the tasks and tasklist:
+    // ---------------------------------
+    //
+    MReadMarsFile read("Events");
+    read.DisableAutoScheme();
+
+    // ------------- user change -----------------
+    read.AddFile("~/MC/test_sample/Gamma_zbin0_0_*.root");
+
+    MGeomApply        apply;
+    MMcPedestalCopy   pcopy;
+    MMcPedestalNSBAdd pnsb;
+
+    MCerPhotCalc      ncalc;
+    MCerPhotAnal2     nanal;
+
+    MFDataMember f1("MRawRunHeader.fRunType", '>', 255.5);
+    MFDataMember f2("MRawRunHeader.fRunType", '<', 255.5);
+
+    ncalc.SetFilter(&f1);
+    nanal.SetFilter(&f2);
+
+    MBlindPixelCalc   blind;
+    blind.SetUseInterpolation();
+
+    MSigmabarCalc     sgcal;
+    MImgCleanStd      clean;
+    MHillasCalc       hcalc;
+    MHillasSrcCalc    scalc; // !!Preliminary!! Will be removed later!
+
+    // ------------- user change -----------------
+    MWriteRootFile write("starfile.root");
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&f1);
+    tlist.AddToList(&f2);
+    tlist.AddToList(&apply);
+    tlist.AddToList(&pcopy);
+    tlist.AddToList(&pnsb);
+    tlist.AddToList(&ncalc);
+    tlist.AddToList(&nanal);
+    tlist.AddToList(&blind);
+    tlist.AddToList(&sgcal);
+    tlist.AddToList(&clean);
+    tlist.AddToList(&hcalc);
+    tlist.AddToList(&scalc);
+    tlist.AddToList(&write);
+
+    // ------------- user change -----------------
+    // You may use the "UPDATE" option in the constructor
+    // of MWriteRootFile to update an existing file.
+    //
+    // tlist.SetSerialNumber(1); // Serial number of telescope
+    write.AddContainer(write.AddSerialNumber("MMcEvt"),       "Events", kFALSE);
+    write.AddContainer(write.AddSerialNumber("MSigmabar"),    "Events");
+    write.AddContainer(write.AddSerialNumber("MHillas"),      "Events");
+    write.AddContainer(write.AddSerialNumber("MHillasExt"),   "Events");
+    write.AddContainer(write.AddSerialNumber("MHillasSrc"),   "Events");
+    write.AddContainer(write.AddSerialNumber("MNewImagePar"), "Events");
+    write.AddContainer(write.AddSerialNumber("MSrcPosCam"),   "RunHeaders");
+    write.AddContainer("MRawRunHeader", "RunHeaders");
+    write.AddContainer("MMcRunHeader",  "RunHeaders", kFALSE);
+
+    //
+    // Create and set up the eventloop
+    //
+    MProgressBar bar;
+
+    MEvtLoop evtloop;
+    evtloop.SetProgressBar(&bar);
+    evtloop.SetParList(&plist);
+
+    //
+    // Execute your analysis
+    //
+    if (!evtloop.Eventloop())
+        return;
+
+    tlist.PrintStatistics();
+}
Index: /tags/Mars_V0-8-5/Mars/macros/starfield.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/starfield.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/starfield.C	(revision 9661)
@@ -0,0 +1,107 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz 5/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////////
+//
+// starfield.C
+// ===========
+//
+// This is a macro demonstrating how to use Mars to display a starfield.
+// It also is a tutorial for MAstroCatalog and MAstroCamera.
+//
+// For more details on this classes see the class-reference.
+//
+// If you want to display stars in a camera you need the camera geometry
+// and the mirror definition. You can get this either from a Monte Carlo
+// file containing both or create your MGeomCam object manually and
+// read a magic.def file which you will find in the camera simulation
+// program.
+//
+///////////////////////////////////////////////////////////////////////////
+
+void ReadSetup(TString fname, MAstroCamera &cam)
+{
+    MMcConfigRunHeader *config=0;
+    MGeomCam           *geom=0;
+
+    TFile file(fname);
+    TTree *tree = (TTree*)file.Get("RunHeaders");
+    tree->SetBranchAddress("MMcConfigRunHeader", &config);
+    if (tree->GetBranch("MGeomCam"))
+        tree->SetBranchAddress("MGeomCam", &geom);
+    tree->GetEntry(0);
+
+    cam.SetMirrors(*config->GetMirrors());
+    cam.SetGeom(*geom);
+
+    /* Alternative:
+
+     MGeomCamMagic geom;
+     cam.SetGeom(geom);
+     cam.SetMirrors("magic.def");
+     */
+}
+
+void starfield()
+{
+    // Name of a MC file having MGeomCam and MMcConfigRunHeader
+    TString fname = "../Mars/Gamma_zbin7_90_7_53395to53399_w0.root";
+
+    // Time for which to get the picture
+    MTime time;
+    time.Set(2004, 2, 28, 01, 32, 15);
+
+    // Current observatory
+    MObservatory magic1;
+
+    // Right Ascension [h] and declination [deg] of source
+    // Currently 'perfect' pointing is assumed
+    const Double_t ra  = MAstro::Hms2Rad(5, 34, 31.9);
+    const Double_t dec = MAstro::Dms2Rad(22, 0, 52.0);
+
+    new TCanvas;
+
+    // --------------------------------------------------------------------------
+    // Create camera display from geometry
+    //MAstroCatalog stars;     // Use this top display a catalog
+    MAstroCamera stars;        // Use this top display a catalog on top of a camera
+    ReadSetup(fname, stars);   // Use this top display a catalog on top of a camera
+    stars.SetLimMag(6);
+    stars.SetRadiusFOV(3);
+    stars.SetRaDec(ra, dec);
+
+    // Read the stars from a star catalog. The catalogs can be downloaded
+    // from the Mars web page. For more information see class reference.
+    stars.ReadBSC("bsc5.dat");
+
+    stars.SetObservatory(magic1);
+    stars.SetTime(time);
+    stars.SetGuiActive();
+
+    // See the cooresponding Draw-function for more options
+    TObject *o = stars.Clone();
+    o->SetBit(kCanDelete);
+    o->Draw();
+
+}
Index: /tags/Mars_V0-8-5/Mars/macros/starmc.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/starmc.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/starmc.C	(revision 9661)
@@ -0,0 +1,252 @@
+/* ======================================================================== *\
+   !
+   ! *
+   ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+   ! * Software. It is distributed to you in the hope that it can be a useful
+   ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+   ! * It is distributed WITHOUT ANY WARRANTY.
+   ! *
+   ! * Permission to use, copy, modify and distribute this software and its
+   ! * documentation for any purpose is hereby granted without fee,
+   ! * provided that the above copyright notice appear in all copies and
+   ! * that both that copyright notice and this permission notice appear
+   ! * in supporting documentation. It is provided "as is" without express
+   ! * or implied warranty.
+   ! *
+   !
+   !
+   !   Author(s): Abelardo Moralejo 1/2004 <mailto:moralejo@pd.infn.it>
+   !              Thomas Bretz  5/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+   !
+   !   Copyright: MAGIC Software Development, 2000-2004
+   !
+   !
+   \* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  STARMC - STandard Analysis and Reconstruction (MC example)
+//
+//  This macro is a version of the standard converter to convert raw data 
+//  into image  parameters, made to show how to run analysis on MC files. 
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MImgCleanStd.h"
+
+void starmc()
+{
+  //
+  // This is a demonstration program which calculates the image 
+  // parameters from Magic Monte Carlo files (output of camera).
+
+  TString* CalibrationFilename;
+  TString* OutFilename1;
+  TString* OutFilename2;
+
+  // ------------- user change -----------------
+  //
+  // Comment line starting "CalibrationFileName" to disable calibration. In that 
+  // case the units of the MHillas.fSize parameter will be ADC counts (rather, 
+  // equivalent ADC counts in inner pixels, since we correct for the possible 
+  // differences in gain of outer pixels)
+  //
+  CalibrationFilename = new TString("../../gammas_nonoise/Gamma_zbin0_90_*.root");
+  // File to be used in the calibration (must be a camera file without added noise)
+
+  Char_t* AnalysisFilename = "Gamma_zbin*.root";  // File to be analyzed
+
+
+  // ------------- user change -----------------
+  //
+  // Change output file names as desired. If you want only one output, comment
+  // the initialization of OutFilename2.
+
+  OutFilename1 = new TString("star_train.root");   // Output file name 1 (test)
+  OutFilename2 = new TString("star_test.root");    // Output file name 2 (train)
+  //
+  // Fraction of events (taken at random) which one wants to process from the 
+  // file to be analyzed (useful to make smaller files if starting sample is
+  // too large).
+  //
+  Float_t accepted_fraction = 1.;
+
+  Float_t CleanLev[2] = {4., 3.}; // Tail cuts for image analysis
+
+  Int_t BinsHigh[2] = {5, 10}; // First and last FADC bin of the range to be integrated,
+  Int_t BinsLow[2]  = {5, 10}; // for high and low gain respectively.
+
+  // -------------------------------------------
+
+  //
+  // Create a empty Parameter List and an empty Task List
+  // The tasklist is identified in the eventloop by its name
+  //
+  MParList  plist;
+
+  MTaskList tlist;
+
+  plist.AddToList(&tlist);
+
+  MSrcPosCam src;
+  src.SetReadyToSave();
+  plist.AddToList(&src);
+
+  MBadPixelsCam badpix;
+  plist.AddToList(&badpix);
+
+
+  //
+  // Now setup the tasks and tasklist:
+  // ---------------------------------
+  //
+  MReadMarsFile read("Events");
+
+  if (CalibrationFilename)
+    read.AddFile(CalibrationFilename->Data());
+
+  read.DisableAutoScheme();
+
+  MGeomApply geom; // Reads in geometry from MC file and sets the right sizes for
+  // several parameter containers.
+
+  MMcPedestalCopy   pcopy; 
+  // Copies pedestal data from the MC file run fadc header to the MPedestalCam container.
+
+  MExtractSignal    sigextract;
+  sigextract.SetSaturationLimit(240);
+  // Define ADC slices to be integrated in high and low gain:
+  sigextract.SetRange(BinsHigh[0], BinsHigh[1], BinsLow[0], BinsLow[1]);
+
+  MMcCalibrationUpdate  mccalibupdate;
+
+  MCalibrate calib; // Transforms signals from ADC counts into photons.
+  calib.SetCalibrationMode(MCalibrate::kFfactor);
+
+  //    MBlindPixelCalc   blind;
+  //    blind.SetUseInterpolation();
+
+  MImgCleanStd      clean(CleanLev[0], CleanLev[1]); // Applies tail cuts to image.
+
+  MHillasCalc       hcalc; // Calculates Hillas parameters not dependent on source position.
+  MHillasSrcCalc    scalc; // Calculates source-dependent Hillas parameters 
+
+  MMcCalibrationCalc mccalibcalc;
+
+  tlist.AddToList(&read);
+  tlist.AddToList(&geom);
+  tlist.AddToList(&pcopy);
+
+  tlist.AddToList(&sigextract);
+  tlist.AddToList(&mccalibupdate);
+  tlist.AddToList(&calib);
+  tlist.AddToList(&clean);
+  //    tlist.AddToList(&blind);
+  tlist.AddToList(&hcalc);
+
+  tlist.AddToList(&mccalibcalc);
+
+  //
+  // Open output files:
+  //
+
+  MWriteRootFile write1(OutFilename1.Data()); // Writes output1
+  write1.AddContainer("MRawRunHeader", "RunHeaders");
+  write1.AddContainer("MMcRunHeader",  "RunHeaders");
+  write1.AddContainer("MSrcPosCam",    "RunHeaders");
+  write1.AddContainer("MMcEvt",        "Events");
+  write1.AddContainer("MHillas",       "Events");
+  write1.AddContainer("MHillasExt",    "Events");
+  write1.AddContainer("MHillasSrc",    "Events");
+  write1.AddContainer("MNewImagePar",  "Events");
+
+  if (OutFilename2)
+    {
+      MWriteRootFile write2(OutFilename2.Data()); // Writes output2
+      write2.AddContainer("MRawRunHeader", "RunHeaders");
+      write2.AddContainer("MMcRunHeader",  "RunHeaders");
+      write2.AddContainer("MSrcPosCam",    "RunHeaders");
+      write2.AddContainer("MMcEvt",        "Events");
+      write2.AddContainer("MHillas",       "Events");
+      write2.AddContainer("MHillasExt",    "Events");
+      write2.AddContainer("MHillasSrc",    "Events");
+      write2.AddContainer("MNewImagePar",  "Events");
+
+      //
+      // Divide output in train and test samples, using the event number
+      // (odd/even) to achieve otherwise unbiased event samples:
+      //
+      
+      MF filter1("{MMcEvt.fEvtNumber%2}>0.5");
+      MF filter2("{MMcEvt.fEvtNumber%2}<0.5");
+
+      write1.SetFilter(&filter1);
+      write2.SetFilter(&filter2);
+    }
+
+  //
+  // First loop: Calibration loop
+  //
+
+  MProgressBar bar;
+  bar.SetWindowName("Calibrating...");
+
+  MEvtLoop evtloop;
+  evtloop.SetProgressBar(&bar);
+  evtloop.SetParList(&plist);
+
+  if (CalibrationFilename)
+    {
+      if (!evtloop.Eventloop())
+	return;
+      mccalibcalc->GetHistADC2PhotEl()->Write();
+      mccalibcalc->GetHistPhot2PhotEl()->Write();
+    }
+
+  //
+  // Second loop: analysis loop
+  //
+
+  //
+  // Change the read task by another one which reads the file we want to analyze:
+  //
+
+  MReadMarsFile read2("Events");
+  read2.AddFile(AnalysisFilename);
+  read2.DisableAutoScheme();
+  tlist.AddToListBefore(&read2, &read);
+  tlist.RemoveFromList(&read);
+
+  //
+  // Analyzed only the desired fraction of events, skip the rest:
+  //
+  MFEventSelector eventselector;
+  Float_t rejected_fraction = 1. - accepted_fraction; 
+  eventselector.SetSelectionRatio(rejected_fraction);
+  MContinue skip(&eventselector);
+  tlist.AddToListBefore(&skip, &sigextract);
+
+  bar.SetWindowName("Analyzing...");
+
+  tlist.RemoveFromList(&mccalibcalc); // Removes calibration task from list.
+
+  tlist.AddToList(&scalc);            // Calculates Source-dependent Hillas parameters
+
+
+  // Add tasks to write output:
+
+  if (OutFilename2)
+    {
+      tlist.AddToList(&filter1);
+      tlist.AddToList(&filter2);
+      tlist.AddToList(&write2); 
+    }
+
+  tlist.AddToList(&write1); 
+
+  if (!evtloop.Eventloop())
+    return;
+
+
+  tlist.PrintStatistics();
+}
Index: /tags/Mars_V0-8-5/Mars/macros/starmc2.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/starmc2.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/starmc2.C	(revision 9661)
@@ -0,0 +1,114 @@
+/* ======================================================================== *\
+   !
+   ! *
+   ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+   ! * Software. It is distributed to you in the hope that it can be a useful
+   ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+   ! * It is distributed WITHOUT ANY WARRANTY.
+   ! *
+   ! * Permission to use, copy, modify and distribute this software and its
+   ! * documentation for any purpose is hereby granted without fee,
+   ! * provided that the above copyright notice appear in all copies and
+   ! * that both that copyright notice and this permission notice appear
+   ! * in supporting documentation. It is provided "as is" without express
+   ! * or implied warranty.
+   ! *
+   !
+   !
+   !   Author(s): Abelardo Moralejo 1/2004 <mailto:moralejo@pd.infn.it>
+   !              Thomas Bretz  5/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+   !
+   !   Copyright: MAGIC Software Development, 2000-2004
+   !
+   !
+   \* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  STARMC2 - STandard Analysis and Reconstruction (MC example)
+//
+//  This macro converts into image  parameters an input file of MC data 
+//  previously calibrated (see mccalibrate.C).
+//  
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MImgCleanStd.h"
+
+void starmc2()
+{
+  Char_t* AnalysisFilename = "calibrated_data.root"; // File to be analyzed
+  Char_t* OutFilename      = "star.root";        // Output file name
+
+  Float_t CleanLev[2] = {4., 3.}; // Tail cuts for image analysis
+
+  // ------------------------------------------------------------------
+
+  //
+  // Create a empty Parameter List and an empty Task List
+  // The tasklist is identified in the eventloop by its name
+  //
+  MParList  plist;
+
+  MTaskList tlist;
+
+  plist.AddToList(&tlist);
+
+  MSrcPosCam src;
+  src.SetReadyToSave();
+
+  plist.AddToList(&src);
+
+  //
+  // Now setup the tasks and tasklist:
+  // ---------------------------------
+  //
+  MReadMarsFile read("Events");
+
+  read.AddFile(AnalysisFilename);
+
+  read.DisableAutoScheme();
+
+  MImgCleanStd      clean(CleanLev[0], CleanLev[1]); // Applies tail cuts to image.
+
+  MHillasCalc       hcalc; // Calculates Hillas parameters not dependent on source position.
+  MHillasSrcCalc    scalc; // Calculates source-dependent Hillas parameters 
+
+  tlist.AddToList(&read);
+  tlist.AddToList(&clean);
+  tlist.AddToList(&hcalc);
+  tlist.AddToList(&scalc); // Calculates Source-dependent Hillas parameters
+
+  //
+  // Open output file:
+  //
+  MWriteRootFile write(OutFilename); // Writes output
+  write.AddContainer("MRawRunHeader", "RunHeaders");
+  write.AddContainer("MMcRunHeader",  "RunHeaders", kFALSE);
+  write.AddContainer("MSrcPosCam",    "RunHeaders");
+  write.AddContainer("MMcEvt",        "Events", kFALSE);
+  write.AddContainer("MPointingPos",  "Events", kFALSE);
+  write.AddContainer("MHillas",       "Events");
+  write.AddContainer("MHillasExt",    "Events");
+  write.AddContainer("MHillasSrc",    "Events");
+  write.AddContainer("MNewImagePar",  "Events");
+
+  tlist.AddToList(&write);            // Add task to write output.
+
+  //
+  // analysis loop
+  //
+
+  MEvtLoop evtloop;
+  MProgressBar bar;
+  bar.SetWindowName("Analyzing...");
+  evtloop.SetProgressBar(&bar);
+  evtloop.SetParList(&plist);
+
+  if (!evtloop.Eventloop())
+    return;
+
+  tlist.PrintStatistics();
+
+  return;
+}
Index: /tags/Mars_V0-8-5/Mars/macros/starmcstereo.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/starmcstereo.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/starmcstereo.C	(revision 9661)
@@ -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):  Abelardo Moralejo 1/2004 <mailto:moralejo@pd.infn.it>
+!               Thomas Bretz, 5/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  STARMCSTEREO - STandard Analysis and Reconstruction (for MC stereo files)
+//
+//  This macro is the standard converter to convert raw data from stereo 
+//  camera simulation into image parameters
+//
+/////////////////////////////////////////////////////////////////////////////
+
+//
+// User change. 
+//
+
+Float_t ctx[7] = {0., 0., 0., 0., 0., 0., 0.}; 
+Float_t cty[7] = {-70., -40., -30., 30., 50., 60., 70.}; // in meters
+//
+// FIXME: unfortunately present version of reflector was not prepared for
+// stereo configurations and keeps no track of CT position. So the positions
+// must be set above by the user, making sure that they correspond to the
+// files one is analysing.
+//
+
+void starmcstereo(Int_t ct1 = 2, Int_t ct2 = 5)
+{
+  if (ct1 > sizeof(ctx)/sizeof(ctx[0]) || 
+      ct2 > sizeof(ctx)/sizeof(ctx[0]) )
+    {
+      cout << endl << "Wrong CT id number!" << endl;
+      return;
+    }
+
+  Int_t CT[2] = {ct1, ct2};  // Only 2-telescope analysis for the moment
+  Int_t NCTs = sizeof(CT)/sizeof(CT[0]);
+
+
+  // ------------- user change -----------------
+
+  Char_t* AnalysisFilename = "gam-yXX-00001.root";  // File to be analyzed
+  Char_t* OutFileTag      = "gammas";           // Output file tag
+
+  Float_t CleanLev[2] = {4., 3.}; // Tail cuts for image analysis
+
+  Int_t BinsHigh[2] = {5, 9}; // First and last FADC bin of the range to be integrated,
+  Int_t BinsLow[2]  = {5, 9}; // for high and low gain respectively.
+
+  // -------------------------------------------
+
+  //
+  // This is a demonstration program which calculates the image 
+  // parameters from a Magic Monte Carlo root file. Units of Size are
+  // for the moment, FADC counts.
+  //
+  //
+  // Create a empty Parameter List and an empty Task List
+  // The tasklist is identified in the eventloop by its name
+  //
+  MParList  plist;
+
+  MTaskList tlist;
+
+  plist.AddToList(&tlist);
+
+  MSrcPosCam src[NCTs];
+  MBadPixelsCam badpix[NCTs];
+
+  for (Int_t ict = 0; ict < NCTs; ict++)
+    {
+      TString s = "MSrcPosCam;";
+      s += CT[ict];
+      src[ict].SetName(s);
+      src[ict].SetReadyToSave();
+      plist.AddToList(&(src[ict]));
+
+      TString b = "MBadPixelsCam;";
+      b += CT[ict];
+      badpix[ict].SetName(b);
+      badpix[ict].SetReadyToSave();
+      plist.AddToList(&(badpix[ict]));
+    }
+  //
+  // Now setup the tasks and tasklist:
+  // ---------------------------------
+  //
+  MReadMarsFile read("Events");
+  read.DisableAutoScheme();
+
+  read.AddFile(AnalysisFilename);
+
+  MGeomApply*        apply = new MGeomApply[NCTs];
+
+  MMcPedestalCopy*   pcopy = new MMcPedestalCopy[NCTs];
+
+  MExtractSignal*      sigextract = new MExtractSignal[NCTs];
+
+  MMcCalibrationUpdate*  mccalibupdate = new MMcCalibrationUpdate[NCTs];
+  MCalibrate* calib = new MCalibrate[NCTs];
+
+  MImgCleanStd**     clean = new MImgCleanStd*[NCTs];
+
+  MHillasCalc*       hcalc = new MHillasCalc[NCTs];
+  MHillasSrcCalc*    scalc = new MHillasSrcCalc[NCTs];
+
+  TString outfile = "star_";
+  outfile += CT[0];
+  if (NCTs==2)
+    {
+      outfile += "_";
+      outfile += CT[1];
+    }
+
+  //
+  // We have two output files (will be later train and test sampls for random forest)
+  //
+  outfile += "_";
+  outfile += OutFileTag;
+  outfile += "_train.root";
+  MWriteRootFile    write1(outfile);
+
+  outfile = "star_";
+  outfile += CT[0];
+  if (NCTs==2)
+    {
+      outfile += "_";
+      outfile += CT[1];
+    }
+
+  outfile += "_";
+  outfile += OutFileTag; 
+  outfile += "_test.root";
+
+  MWriteRootFile write2(outfile);
+
+  for (Int_t i = 0; i < NCTs; i++)
+    {
+      apply[i]->SetSerialNumber(CT[i]);
+
+      pcopy[i]->SetSerialNumber(CT[i]);
+
+      sigextract[i]->SetSerialNumber(CT[i]);
+      sigextract[i].SetRange(BinsHigh[0], BinsHigh[1], BinsLow[0], BinsLow[1]);
+
+      mccalibupdate[i]->SetSerialNumber(CT[i]);
+      calib[i]->SetSerialNumber(CT[i]);
+
+      clean[i] = new MImgCleanStd(CleanLev[0], CleanLev[1]);
+      clean[i]->SetSerialNumber(CT[i]);
+
+      hcalc[i]->SetSerialNumber(CT[i]);
+      scalc[i]->SetSerialNumber(CT[i]);
+
+      write1.SetSerialNumber(CT[i]);
+      write2.SetSerialNumber(CT[i]);
+
+      write1.AddContainer(write1.AddSerialNumber("MMcEvt"),       "Events");
+      write1.AddContainer(write1.AddSerialNumber("MHillas"),      "Events");
+      write1.AddContainer(write1.AddSerialNumber("MHillasExt"),   "Events");
+      write1.AddContainer(write1.AddSerialNumber("MHillasSrc"),   "Events");
+      write1.AddContainer(write1.AddSerialNumber("MNewImagePar"), "Events");
+      write1.AddContainer(write1.AddSerialNumber("MSrcPosCam"),   "RunHeaders");
+      write2.AddContainer(write2.AddSerialNumber("MMcEvt"),       "Events");
+      write2.AddContainer(write2.AddSerialNumber("MHillas"),      "Events");
+      write2.AddContainer(write2.AddSerialNumber("MHillasExt"),   "Events");
+      write2.AddContainer(write2.AddSerialNumber("MHillasSrc"),   "Events");
+      write2.AddContainer(write2.AddSerialNumber("MNewImagePar"), "Events");
+      write2.AddContainer(write2.AddSerialNumber("MSrcPosCam"),   "RunHeaders");
+    }
+
+  if (NCTs==2)
+    {
+      write1.AddContainer("MStereoPar", "Events");
+      write2.AddContainer("MStereoPar", "Events");
+    }
+
+  write1.AddContainer("MRawRunHeader", "RunHeaders");
+  write1.AddContainer("MMcRunHeader",  "RunHeaders");
+
+  write2.AddContainer("MRawRunHeader", "RunHeaders");
+  write2.AddContainer("MMcRunHeader",  "RunHeaders");
+
+  tlist.AddToList(&read);
+
+  for (i = 0; i < NCTs; i++)
+    {
+      tlist.AddToList(&(apply[i]));
+      tlist.AddToList(&(pcopy[i]));
+      tlist.AddToList(&(sigextract[i]));
+      tlist.AddToList(&(mccalibupdate[i]));
+      tlist.AddToList(&(calib[i]));
+      tlist.AddToList(clean[i]);
+      tlist.AddToList(&(hcalc[i]));
+      tlist.AddToList(&(scalc[i]));
+    }
+
+  MStereoCalc stereocalc;
+  stereocalc.SetCTids(CT[0],CT[1]);
+
+  //
+  // FIXME: telescope coordinates must be introduced by the user, since
+  // they are not available nor in the camera file, neither in the reflector 
+  // output.
+  //
+
+  stereocalc.SetCT1coor(ctx[CT[0]-1],cty[CT[0]-1]);
+  stereocalc.SetCT2coor(ctx[CT[1]-1],cty[CT[1]-1]);
+
+  tlist.AddToList(&stereocalc);
+
+
+  MF filter1("{MMcEvt;1.fEvtNumber%2}<0.5");
+  MF filter2("{MMcEvt;1.fEvtNumber%2}>0.5");
+  //
+  // ^^^^ Filters to divide output in two: test and train samples.
+  //
+
+  write1.SetFilter (&filter1);
+  write2.SetFilter (&filter2);
+
+  tlist.AddToList(&filter1);
+  tlist.AddToList(&write1);
+  tlist.AddToList(&filter2);
+  tlist.AddToList(&write2);
+
+  //
+  // Create and set up the eventloop
+  //
+  MProgressBar bar;
+
+  MEvtLoop evtloop;
+  evtloop.SetProgressBar(&bar);
+  evtloop.SetParList(&plist);
+
+  //
+  // Execute your analysis
+  //
+  if (!evtloop.Eventloop())
+    return;
+
+  for (Int_t i= 0; i < NCTs; i++ )
+    delete clean[i];
+
+  tlist.PrintStatistics();
+}
Index: /tags/Mars_V0-8-5/Mars/macros/starplot.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/starplot.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/starplot.C	(revision 9661)
@@ -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 et al, 08/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+
+void starplot(const char *filename="Gamma_*.root")
+{
+    //
+    // This is a demonstration program which plots the Hillas
+    // parameter from a file created with star.C
+    //
+
+    //
+    // Create a empty Parameter List and an empty Task List
+    // The tasklist is identified in the eventloop by its name
+    //
+    MParList plist;
+
+
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    //
+    // Use this if you want to change the binning of one of
+    // the histograms. You can use:
+    // BinningConc, BinningConc1, BinningAsym, BinningM3Long,
+    // BinningM3Trans, BinningWidth, BinningLength, BinningDist,
+    // BinningHeadTail, BinningAlpha, BinningSize, BinningDelta,
+    // BinningPixels and BinningCamera
+    //
+    // For more information see MBinning and the corresponding
+    // histograms
+    //
+    // MBinning binsalpha("BinningAlpha");
+    // binsalpha.SetEdges(90, 0, 90);       // 90 bins from 0 to 90 deg
+    // plist.AddToList(&binsalpha);
+
+    // MBinning binssize("BinningSize");
+    // binssize.SetEdgesLog(50, 1, 1e7);
+    // plist.AddToList(&binssize);
+
+    //
+    // Now setup the tasks and tasklist:
+    // ---------------------------------
+    //
+    // The first argument is the tree you want to read.
+    //   Events:     Cosmic ray events
+    //   PedEvents:  Pedestal Events
+    //   CalEvents:  Calibration Events
+    //
+    MReadMarsFile read("Events", filename);
+    read.DisableAutoScheme();
+
+    MGeomApply geomapl;
+
+    MFillH hfill1("MHHillas", "MHillas");
+    MFillH hfill2("MHHillasExt");
+    MFillH hfill3("MHStarMap", "MHillas");
+    MFillH hfill4("HistExtSource [MHHillasExt]", "MHillasSrc");
+    MFillH hfill5("HistSource [MHHillasSrc]", "MHillasSrc");
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&geomapl);
+    tlist.AddToList(&hfill1);
+    tlist.AddToList(&hfill2);
+    tlist.AddToList(&hfill3);
+    tlist.AddToList(&hfill4);
+    tlist.AddToList(&hfill5);
+
+    //
+    // Create and setup the eventloop
+    //
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    //
+    // Execute your analysis
+    //
+    MProgressBar bar;
+    evtloop.SetProgressBar(&bar);
+    if (!evtloop.Eventloop())
+        return;
+
+    tlist.PrintStatistics();
+
+    //
+    // After the analysis is finished we can display the histograms
+    //
+    plist.FindObject("MHHillas")->DrawClone();
+    plist.FindObject("MHHillasExt")->DrawClone();
+    plist.FindObject("MHStarMap")->DrawClone();
+    plist.FindObject("HistSource")->DrawClone();
+    plist.FindObject("HistExtSource")->DrawClone();
+}
+
Index: /tags/Mars_V0-8-5/Mars/macros/status.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/status.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/status.C	(revision 9661)
@@ -0,0 +1,189 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 4/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  Status - Example how to use the MStatusDisplay
+//
+//  Use a camera file as input
+//
+/////////////////////////////////////////////////////////////////////////////
+
+void status()
+{
+    //
+    // Update frequency by default = 1Hz
+    //
+    MStatusDisplay *d = new MStatusDisplay;
+
+    // Set update time to 5s
+    // d->SetUpdateTime(5000);
+
+    // Disable online update
+    // d->SetUpdateTime(-1);
+
+    d->SetLogStream(&gLog, kTRUE);            // Disables output to stdout
+    gLog.SetOutputFile("status.log", kTRUE);  // Enable output to file
+    //gLog.EnableOutputDevice(MLog::eStdout); // Enable output to stdout again
+
+    //
+    // 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);
+
+    // ------------- user change -----------------
+    MDirIter files(".", "G*.root", -1);
+    //files.Print("all");
+
+    //
+    // Now setup the tasks and tasklist:
+    // ---------------------------------
+    //
+    MReadMarsFile read("Events");
+    read.DisableAutoScheme();
+    read.AddFiles(files);
+
+    MGeomApply        geomapl;
+
+    MMcPedestalCopy   pcopy;
+    MMcPedestalNSBAdd pnsb;
+    MCerPhotCalc      ncalc;
+
+    TArrayS blinds(0);
+
+    MBlindPixelCalc blind;
+    blind.SetPixelIndices(blinds);
+    blind.SetUseInterpolation();
+
+    MSigmabarCalc     sgcal;
+    MImgCleanStd      clean;
+    MHillasCalc       hcalc;
+    MHillasSrcCalc    scalc; // !!Preliminary!! Will be removed later!
+
+    MHCamEvent hist("PedestalRms");
+    hist.SetType(1);
+    plist.AddToList(&hist);
+
+    // -------------------------------------------
+    MHTriggerLvl0 trighi(254, "SaturationHi", "Saturation Rate of Hi Gains");
+    trighi.SetType(1);
+
+    MHCamEvent maxhi("MaxIdxHi", "Index of maximum hi-gain slice");
+    MHCamEvent maxlo("MaxIdxLo", "Index of maximum lo-gain slice");
+    maxhi.SetType(3);
+    maxlo.SetType(4);
+    plist.AddToList(&maxhi);
+    plist.AddToList(&maxlo);
+
+
+    MFillH fillhi(&trighi, "MRawEvtData");
+    MFillH hfilhi("MaxIdxHi", "MRawEvtData");
+    MFillH hfillo("MaxIdxLo", "MRawEvtData");
+    MFillH hfill0("Uncleaned [MHCamEvent]", "MCerPhotEvt");
+    MFillH hfill1("Pedestals [MHCamEvent]", "MPedestalCam");
+    MFillH hfill2("PedestalRms", "MPedestalCam");
+    MFillH hfill3("MHHillas", "MHillas");
+    MFillH hfill4("MHHillasExt");
+    MFillH hfill5("MHHillasExtSrc [MHHillasExt]", "MHillasSrc");
+    MFillH hfill6("MHHillasSrc","MHillasSrc");
+    MFillH hfill7("MHNewImagePar","MNewImagePar");
+    MFillH hfill8("MHStarMap", "MHillas");
+    MFillH hfill9("Cleaned [MHCamEvent]", "MCerPhotEvt");
+
+    MContinue cont1("MNewImagePar.fNumCorePixels<0");
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&geomapl);
+    tlist.AddToList(&hfilhi);
+    tlist.AddToList(&hfillo);
+    tlist.AddToList(&fillhi);
+    tlist.AddToList(&pcopy);
+    tlist.AddToList(&pnsb);
+    tlist.AddToList(&ncalc);
+    tlist.AddToList(&blind);
+    tlist.AddToList(&hfill0);
+    //tlist.AddToList(&sgcal);
+    tlist.AddToList(&clean);
+    tlist.AddToList(&hcalc);
+    tlist.AddToList(&cont1);
+    tlist.AddToList(&scalc);
+    tlist.AddToList(&hfill1);
+    tlist.AddToList(&hfill2);
+    tlist.AddToList(&hfill3);
+    tlist.AddToList(&hfill4);
+    tlist.AddToList(&hfill5);
+    tlist.AddToList(&hfill6);
+    tlist.AddToList(&hfill7);
+    tlist.AddToList(&hfill8);
+    tlist.AddToList(&hfill9);
+
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+    evtloop.SetDisplay(d);
+
+    //
+    // Execute your analysis
+    //
+    if (!evtloop.Eventloop())
+        return;
+
+    tlist.PrintStatistics();
+
+    MHCamEvent *uncl = (MHCamEvent*)plist.FindObject("Uncleaned");
+    MHCamEvent *hped = (MHCamEvent*)plist.FindObject("Pedestals");
+    MHCamEvent *hrms = (MHCamEvent*)plist.FindObject("PedestalRms");
+    uncl->PrintOutliers(3);
+    hped->PrintOutliers(1.5);
+    hrms->PrintOutliers(4);
+    trighi.PrintOutliers(2.5);
+
+    //
+    // Make sure the display hasn't been deleted by the user while the
+    // eventloop was running.
+    //
+    if ((d = evtloop.GetDisplay()))
+    {
+        // Save data in a postscriptfile (status.ps)
+        //d->SaveAsPS();
+        /*
+         * ----------- Write status to a root file ------------
+         *
+         TFile file("status.root", "RECREATE");
+         d->Write();
+         file.Close();
+         delete d;
+         */
+    }
+    /*
+     * ----------- Read status from a root file ------------
+     *
+     TFile file2("status.root", "READ");
+     MStatusDisplay *d2 = new MStatusDisplay;
+     d2->Read();
+     */
+}
Index: /tags/Mars_V0-8-5/Mars/macros/sumcurrents.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/sumcurrents.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/sumcurrents.C	(revision 9661)
@@ -0,0 +1,162 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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, 6/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////////
+//
+// sumcurrents.C
+// =============
+//
+// This is a demonstration macro to display mean DC currents for all pixels.
+// The input is cc report file. The output are histograms and plots.
+// Using the MDirIter functionality you can process more than one file
+// in one or more directories. For more information see MDirIter.
+//
+///////////////////////////////////////////////////////////////////////////
+
+void ProcessFile(TString fname)
+{
+    //
+    // Create a empty Parameter List and an empty Task List
+    // The tasklist is identified in the eventloop by its name
+    //
+    MParList  plist;
+
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    //
+    // Now setup the tasks and tasklist:
+    // ---------------------------------
+    //
+
+    // Create the magic geometry
+    MGeomCamMagic geom;
+    plist.AddToList(&geom);
+
+    // First Task: Read file with image parameters
+    // (created with the star.C macro)
+    MReportFileRead read(fname);
+    read.SetHasNoHeader();
+    read.AddToList("MReportCurrents");
+    tlist.AddToList(&read);
+
+    // create a task to fill a histogram
+    MFillH fill("MHCamEvent", "MCameraDC");
+    tlist.AddToList(&fill);
+
+    //
+    // Create and setup the eventloop
+    //
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    //
+    // Execute your analysis
+    //
+    if (!evtloop.Eventloop())
+        return;
+
+    tlist.PrintStatistics();
+
+    //
+    // Now display the result of the loop
+    //
+    MHCamEvent &h2 = *(MHCamEvent*)plist->FindObject("MHCamEvent");
+    MHCamera &h = *(MHCamera*)h2.GetHistByName("sum");
+;
+
+    TCanvas *c = MH::MakeDefCanvas();
+    c->Divide(3, 2);
+
+    MHCamera *disp1=h.Clone();
+    MHCamera *disp2=h.Clone();
+    MHCamera *disp3=h.Clone();
+    disp2->SetCamContent(h, 1);
+    disp3->SetCamContent(h, 2);
+
+    disp1->SetYTitle("I [nA]");
+    disp2->SetYTitle("\\sigma_{I} [\\mu A]");
+    disp3->SetYTitle("\\sigma_{I} [%]");
+    disp1->SetName("Currents;avg");
+    disp2->SetName("Currents;err");
+    disp3->SetName("Currents;rel");
+    disp1->SetTitle("Currents Average");
+    disp2->SetTitle("Currents error");
+    disp3->SetTitle("Currents relative error");
+
+    c->cd(1);
+    TText text(0.1, 0.95, &fname[fname.Last('/')+1]);
+    text.SetTextSize(0.03);
+    text.DrawClone();
+    gPad->SetBorderMode(0);
+    gPad->Divide(1,1);
+    gPad->cd(1);
+    gPad->SetLogy();
+    disp1->Draw();
+    disp1->SetBit(kCanDelete);
+    c->cd(2);
+    gPad->SetBorderMode(0);
+    gPad->Divide(1,1);
+    gPad->cd(1);
+    gPad->SetLogy();
+    disp2->Draw();
+    disp2->SetBit(kCanDelete);
+    c->cd(3);
+    gPad->SetBorderMode(0);
+    gPad->Divide(1,1);
+    gPad->cd(1);
+    gPad->SetLogy();
+    disp3->Draw();
+    disp3->SetBit(kCanDelete);
+    c->cd(4);
+    gPad->SetBorderMode(0);
+    disp1->Draw("EPhist");
+    c->cd(5);
+    gPad->SetBorderMode(0);
+    gPad->SetLogy();
+    disp2->Draw("Phist");
+    c->cd(6);
+    gPad->SetBorderMode(0);
+    gPad->SetLogy();
+    disp3->Draw("Phist");
+
+    c->SaveAs(fname(0, fname.Last('.')+1) + "ps");
+    c->SaveAs(fname(0, fname.Last('.')+1) + "root");
+}
+
+void sumcurrents(const char *dirname=".")
+{
+    MDirIter Next;
+    Next.AddDirectory(dirname, "dc_*.txt", -1);
+
+    TString fname;
+    while (1)
+    {
+        fname = Next();
+        if (fname.IsNull())
+            break;
+
+        ProcessFile(fname);
+    }
+}
Index: /tags/Mars_V0-8-5/Mars/macros/sumevents.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/sumevents.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/sumevents.C	(revision 9661)
@@ -0,0 +1,155 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 6/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+void ProcessFile(TString fname)
+{
+    //
+    // Create a empty Parameter List and an empty Task List
+    // The tasklist is identified in the eventloop by its name
+    //
+    MParList  plist;
+
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    //
+    // Now setup the tasks and tasklist:
+    // ---------------------------------
+    //
+
+    // First Task: Read file with image parameters
+    // (created with the star.C macro)
+
+    MReadMarsFile read("Events", fname);
+    read.DisableAutoScheme();
+
+    MGeomApply geomapl;
+    MCerPhotAnal2 ncalc;
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&geomapl);
+    tlist.AddToList(&ncalc);
+
+    MFillH fill("MHCamEvent", "MCerPhotEvt");
+    tlist.AddToList(&fill);
+
+    //
+    // Create and setup the eventloop
+    //
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    //
+    // Execute your analysis
+    //
+    if (!evtloop.Eventloop())
+        return;
+
+    tlist.PrintStatistics();
+
+    TCanvas *c = MH::MakeDefCanvas();
+    c->Divide(3, 2);
+
+    MHCamEvent &h = *(MHCamEvent*)plist->FindObject("MHCamEvent");
+    MHCamera *disp0 = h.GetHistByName();
+    MHCamera *disp1 = new MHCamera(geom, "MCerPhotEvt;avg", "Cerenkov Photons Avarage");
+    MHCamera *disp2 = new MHCamera(geom, "MCerPhotEvt;err", "Cerenkov Photons Error");
+    MHCamera *disp3 = new MHCamera(geom, "MCerPhotEvt;rel", "Cerenkov Photons ERR/VAL");
+    disp1->SetBit(kCanDelete);
+    disp2->SetBit(kCanDelete);
+    disp3->SetBit(kCanDelete);
+
+    disp1->SetCamContent(*disp0, 0);
+    disp2->SetCamContent(*disp0, 1);
+    disp3->SetCamContent(*disp0, 2);
+
+    disp1->SetYTitle("S [au]");
+    disp2->SetYTitle("\\sigma_{S} [au]");
+    disp3->SetYTitle("\\sigma_{S} [%]");
+
+    TText text(0.1, 0.5, &fname[fname.Last('/')+1]);
+    text.SetTextSize(0.015);
+    text.DrawClone();
+
+    c->cd(1);
+    gStyle->SetOptStat(1111);
+    disp1->Draw("hist");
+    gPad->Update();
+
+    c->cd(2);
+    gPad->SetLogy();
+    gStyle->SetOptStat(1101);
+    disp2->Draw("hist");
+    gPad->Update();
+
+    c->cd(3);
+    gPad->SetLogy();
+    gStyle->SetOptStat(1101);
+    disp3->Draw("hist");
+    gPad->Update();
+
+    c->cd(4);
+    gPad->SetBorderMode(0);
+    gPad->Divide(1,1);
+    gPad->cd(1);
+    disp1->Draw();
+
+    c->cd(5);
+    gPad->SetBorderMode(0);
+    gPad->Divide(1,1);
+    gPad->cd(1);
+    disp2->Draw();
+
+    c->cd(6);
+    gPad->SetBorderMode(0);
+    gPad->Divide(1,1);
+    gPad->cd(1);
+    disp3->Draw();
+
+    c->SaveAs(fname(0, fname.Last('.')+1) + "ps");
+    //c->SaveAs(fname(0, fname.Last('.')+1) + "root");
+}
+
+// -------------------------------------------------------------------------
+//
+//  plot.C
+//
+//  This macro shows how to fill and display a histogram using Mars
+//
+void sumevents(const char *dirname=".")
+{
+    MDirIter Next;
+    Next.AddDirectory(dirname, "*1947*.root", -1);
+
+    TString fname;
+    while (1)
+    {
+        fname = Next();
+        if (fname.IsNull())
+            break;
+
+        ProcessFile(fname);
+        return;
+    }
+}
Index: /tags/Mars_V0-8-5/Mars/macros/sumeventserr.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/sumeventserr.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/sumeventserr.C	(revision 9661)
@@ -0,0 +1,158 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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, 6/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+void ProcessFile(TString fname)
+{
+    //
+    // Create a empty Parameter List and an empty Task List
+    // The tasklist is identified in the eventloop by its name
+    //
+    MParList  plist;
+
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    //
+    // Now setup the tasks and tasklist:
+    // ---------------------------------
+    //
+
+    // First Task: Read file with image parameters
+    // (created with the star.C macro)
+
+    MReadMarsFile read("Events", fname);
+    read.DisableAutoScheme();
+
+    //MPedestalSum  ncalc;
+    //MCerPhotCalc  ncalc;
+    //MCerPhotAnal  ncalc;
+    MGeomApply geomapl;
+    MCerPhotAnal2 ncalc;
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&geomapl);
+    tlist.AddToList(&ncalc);
+
+    MFillH fill("MHCamEvent", "MCerPhotEvt");
+    tlist.AddToList(&fill);
+
+    //
+    // Create and setup the eventloop
+    //
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    //
+    // Execute your analysis
+    //
+    if (!evtloop.Eventloop())
+        return;
+
+    tlist.PrintStatistics();
+
+    TCanvas *c = MH::MakeDefCanvas();
+    c->Divide(3, 2);
+
+    MHCamEvent &h = *(MHCamEvent*)plist->FindObject("MHCamEvent");
+    MHCamera *disp0 = h.GetHistByName();
+    MHCamera *disp1 = new MHCamera(geom, "MCerPhotEvt;avg", "Cerenkov Photons Avarage");
+    MHCamera *disp2 = new MHCamera(geom, "MCerPhotEvt;err", "Cerenkov Photons Error");
+    MHCamera *disp3 = new MHCamera(geom, "MCerPhotEvt;rel", "Cerenkov Photons ERR/VAL");
+    disp1->SetBit(kCanDelete);
+    disp2->SetBit(kCanDelete);
+    disp3->SetBit(kCanDelete);
+
+    disp1->SetCamContent(*disp0, 0);
+    disp2->SetCamContent(*disp0, 1);
+    disp3->SetCamContent(*disp0, 2);
+
+    disp1->SetYTitle("S_{err} [au]");
+    disp2->SetYTitle("\\sigma_{S_{err}} [au]");
+    disp3->SetYTitle("\\sigma_{S_{err}} [%]");
+
+    TText text(0.1, 0.5, &fname[fname.Last('/')+1]);
+    text.SetTextSize(0.015);
+    text.DrawClone();
+
+    c->cd(1);
+    gStyle->SetOptStat(1111);
+    disp1->Draw("hist");
+    gPad->Update();
+
+    c->cd(2);
+    gPad->SetLogy();
+    gStyle->SetOptStat(1101);
+    disp2->Draw("hist");
+    gPad->Update();
+
+    c->cd(3);
+    gPad->SetLogy();
+    gStyle->SetOptStat(1101);
+    disp3->Draw("hist");
+    gPad->Update();
+
+    c->cd(4);
+    gPad->SetBorderMode(0);
+    gPad->Divide(1,1);
+    gPad->cd(1);
+    disp1->Draw();
+
+    c->cd(5);
+    gPad->SetBorderMode(0);
+    gPad->Divide(1,1);
+    gPad->cd(1);
+    disp2->Draw();
+
+    c->cd(6);
+    gPad->SetBorderMode(0);
+    gPad->Divide(1,1);
+    gPad->cd(1);
+    disp3->Draw();
+
+    c->SaveAs(fname(0, fname.Last('.')+1) + "ps");
+    //c->SaveAs(fname(0, fname.Last('.')+1) + "root");
+}
+
+// -------------------------------------------------------------------------
+//
+//  plot.C
+//
+//  This macro shows how to fill and display a histogram using Mars
+//
+void sumeventserr(const char *dirname=".")
+{
+    MDirIter Next;
+    Next.AddDirectory(dirname, "*1947*.root", -1);
+
+    TString fname;
+    while (1)
+    {
+        fname = Next();
+        if (fname.IsNull())
+            break;
+
+        ProcessFile(fname);
+        return;
+    }
+}
Index: /tags/Mars_V0-8-5/Mars/macros/sumeventsrms.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/sumeventsrms.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/sumeventsrms.C	(revision 9661)
@@ -0,0 +1,159 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 6/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+void ProcessFile(TString fname)
+{
+    //
+    // Create a empty Parameter List and an empty Task List
+    // The tasklist is identified in the eventloop by its name
+    //
+    MParList  plist;
+
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    //
+    // Now setup the tasks and tasklist:
+    // ---------------------------------
+    //
+
+    // First Task: Read file with image parameters
+    // (created with the star.C macro)
+
+    MReadMarsFile read("Events", fname);
+    read.DisableAutoScheme();
+
+    MGeomApply geomapl;
+    MPedestalSum  ncalc;
+    //MCerPhotCalc  ncalc;
+    //MCerPhotAnal  ncalc;
+    //MCerPhotAnal2 ncalc;
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&geomapl);
+    tlist.AddToList(&ncalc);
+
+    MHCamEvent hist;
+    hist.SetType(3);
+    plist.AddToList(&hist);
+
+    MFillH fill("MHCamEvent", "MCerPhotEvt");
+    tlist.AddToList(&fill);
+
+    //
+    // Create and setup the eventloop
+    //
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    //
+    // Execute your analysis
+    //
+    if (!evtloop.Eventloop())
+        return;
+
+    tlist.PrintStatistics();
+
+    TCanvas *c = MH::MakeDefCanvas();
+    c->Divide(3, 2);
+
+    MHCamEvent &h = *(MHCamEvent*)plist->FindObject("MHCamEvent");
+    MHCamera *disp0 = h.GetHistByName();
+    MHCamera *disp1 = new MHCamera(geom, "MCerPhotEvt;avg", "Cerenkov Photons RMS Avarage");
+    MHCamera *disp2 = new MHCamera(geom, "MCerPhotEvt;err", "Cerenkov Photons RMS Error");
+    MHCamera *disp3 = new MHCamera(geom, "MCerPhotEvt;rel", "Cerenkov Photons RMS ERR/VAL");
+    disp1->SetBit(kCanDelete);
+    disp2->SetBit(kCanDelete);
+    disp3->SetBit(kCanDelete);
+
+    disp1->SetCamContent(*disp0, 0);
+    disp2->SetCamContent(*disp0, 1);
+    disp3->SetCamContent(*disp0, 2);
+
+    disp2->SetStats(kFALSE);
+    disp3->SetStats(kFALSE);
+
+    disp1->SetYTitle("a.u.");
+    disp2->SetYTitle("err");
+    disp3->SetYTitle("rel.err [%]");
+
+    TText text(0.1, 0.5, &fname[fname.Last('/')+1]);
+    text.SetTextSize(0.015);
+    text.DrawClone();
+
+    c->cd(1);
+    disp1->Draw("hist");
+
+    c->cd(2);
+    gPad->SetLogy();
+    disp2->Draw("hist");
+
+    c->cd(3);
+    gPad->SetLogy();
+    disp3->Draw("hist");
+
+    c->cd(4);
+    gPad->SetBorderMode(0);
+    gPad->Divide(1,1);
+    gPad->cd(1);
+    disp1->Draw();
+
+    c->cd(5);
+    gPad->SetBorderMode(0);
+    gPad->Divide(1,1);
+    gPad->cd(1);
+    disp2->Draw();
+
+    c->cd(6);
+    gPad->SetBorderMode(0);
+    gPad->Divide(1,1);
+    gPad->cd(1);
+    disp3->Draw();
+
+    c->SaveAs(fname(0, fname.Last('.')+1) + "ps");
+    //c->SaveAs(fname(0, fname.Last('.')+1) + "root");
+}
+
+// -------------------------------------------------------------------------
+//
+//  plot.C
+//
+//  This macro shows how to fill and display a histogram using Mars
+//
+void sumeventsrms(const char *dirname=".")
+{
+    MDirIter Next;
+    Next.AddDirectory(dirname, "*ped*.root", -1);
+
+    TString fname;
+    while (1)
+    {
+        fname = Next();
+        if (fname.IsNull())
+            break;
+
+        ProcessFile(fname);
+        return;
+    }
+}
Index: /tags/Mars_V0-8-5/Mars/macros/sumpedestalrms.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/sumpedestalrms.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/sumpedestalrms.C	(revision 9661)
@@ -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, 6/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+void ProcessFile(TString fname)
+{
+    //
+    // Create a empty Parameter List and an empty Task List
+    // The tasklist is identified in the eventloop by its name
+    //
+    MParList  plist;
+
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    //
+    // Now setup the tasks and tasklist:
+    // ---------------------------------
+    //
+
+    // First Task: Read file with image parameters
+    // (created with the star.C macro)
+
+    MReadMarsFile read("Events", fname);
+    read.DisableAutoScheme();
+
+    MGeomApply geomapl;
+    MCerPhotAnal2 ncalc;
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&geomapl);
+    tlist.AddToList(&ncalc);
+
+    MHCamEvent hist;
+    hist.SetType(1);
+    plist.AddToList(&hist);
+
+    MFillH fill("MHCamEvent", "MPedestalCam");
+    tlist.AddToList(&fill);
+
+    //
+    // Create and setup the eventloop
+    //
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    //
+    // Execute your analysis
+    //
+    if (!evtloop.Eventloop())
+        return;
+
+    tlist.PrintStatistics();
+
+    TCanvas *c = MH::MakeDefCanvas();
+    c->Divide(3, 2);
+
+    MHCamEvent &h = *(MHCamEvent*)plist->FindObject("MHCamEvent");
+    MHCamera *disp0 = h.GetHistByName();
+    MHCamera *disp1 = new MHCamera(geom, "MPedestalCam;avg", "Pedestal-RMS Avarage");
+    MHCamera *disp2 = new MHCamera(geom, "MPedestalCam;err", "Pedestal-RMS Avarage Error");
+    MHCamera *disp3 = new MHCamera(geom, "MPedestalCam;rel", "Pedestal-RMS Avarage ERR/VAL");
+    disp1->SetBit(kCanDelete);
+    disp2->SetBit(kCanDelete);
+    disp3->SetBit(kCanDelete);
+
+    disp1->SetCamContent(*disp0, 0);
+    disp2->SetCamContent(*disp0, 1);
+    disp3->SetCamContent(*disp0, 2);
+
+    disp1->SetYTitle("P_{rms} [au]");
+    disp2->SetYTitle("\\sigma_{P_{rms}} [au]");
+    disp3->SetYTitle("\\sigma_{P_{rms}} [%]");
+
+    TText text(0.1, 0.5, &fname[fname.Last('/')+1]);
+    text.SetTextSize(0.015);
+    text.DrawClone();
+
+    c->cd(1);
+    gStyle->SetOptStat(1111);
+    disp1->Draw("hist");
+    gPad->Update();
+
+    c->cd(2);
+    gStyle->SetOptStat(1101);
+    disp2->Draw("hist");
+    gPad->Update();
+
+    c->cd(3);
+    gStyle->SetOptStat(1101);
+    disp3->Draw("hist");
+    gPad->Update();
+ 
+    c->cd(4);
+    gPad->SetBorderMode(0);
+    gPad->Divide(1,1);
+    gPad->cd(1);
+    disp1->Draw();
+
+    c->cd(5);
+    gPad->SetBorderMode(0);
+    gPad->Divide(1,1);
+    gPad->cd(1);
+    disp2->Draw();
+
+    c->cd(6);
+    gPad->SetBorderMode(0);
+    gPad->Divide(1,1);
+    gPad->cd(1);
+    disp3->Draw();
+
+    c->SaveAs(fname(0, fname.Last('.')+1) + "ps");
+    //c->SaveAs(fname(0, fname.Last('.')+1) + "root");
+}
+
+// -------------------------------------------------------------------------
+//
+//  plot.C
+//
+//  This macro shows how to fill and display a histogram using Mars
+//
+void sumpedestalrms(const char *dirname=".")
+{
+    MDirIter Next;
+    Next.AddDirectory(dirname, "*1947*.root", -1);
+
+    TString fname;
+    while (1)
+    {
+        fname = Next();
+        if (fname.IsNull())
+            break;
+
+        ProcessFile(fname);
+        return;
+    }
+}
Index: /tags/Mars_V0-8-5/Mars/macros/sumpedestals.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/sumpedestals.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/sumpedestals.C	(revision 9661)
@@ -0,0 +1,153 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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, 6/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+void ProcessFile(TString fname)
+{
+    //
+    // Create a empty Parameter List and an empty Task List
+    // The tasklist is identified in the eventloop by its name
+    //
+    MParList  plist;
+
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    //
+    // Now setup the tasks and tasklist:
+    // ---------------------------------
+    //
+
+    // First Task: Read file with image parameters
+    // (created with the star.C macro)
+
+    MReadMarsFile read("Events", fname);
+    read.DisableAutoScheme();
+
+    MGeomApply geomapl;
+    MCerPhotAnal2 ncalc;
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&geomapl);
+    tlist.AddToList(&ncalc);
+
+    MFillH fill("MHCamEvent", "MPedestalCam");
+    tlist.AddToList(&fill);
+
+    //
+    // Create and setup the eventloop
+    //
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    //
+    // Execute your analysis
+    //
+    if (!evtloop.Eventloop())
+        return;
+
+    tlist.PrintStatistics();
+
+    TCanvas *c = MH::MakeDefCanvas();
+    c->Divide(3, 2);
+
+    MHCamEvent &h = *(MHCamEvent*)plist->FindObject("MHCamEvent");
+    MHCamera *disp0 = h.GetHistByName();
+    MHCamera *disp1 = new MHCamera(geom, "MPedestalCam;avg", "Pedestals Avarage");
+    MHCamera *disp2 = new MHCamera(geom, "MPedestalCam;rms", "Pedestals Avarage Error");
+    MHCamera *disp3 = new MHCamera(geom, "MPedestalCam;rel", "Pedestals Avarage ERR/VAL");
+    disp1->SetBit(kCanDelete);
+    disp2->SetBit(kCanDelete);
+    disp3->SetBit(kCanDelete);
+
+    disp1->SetCamContent(*disp0, 0);
+    disp2->SetCamContent(*disp0, 1);
+    disp3->SetCamContent(*disp0, 2);
+
+    disp1->SetYTitle("P [au]");
+    disp2->SetYTitle("\\sigma_{P} [au]");
+    disp3->SetYTitle("\\sigma_{P} [%]");
+
+    TText text(0.1, 0.5, &fname[fname.Last('/')+1]);
+    text.SetTextSize(0.015);
+    text.DrawClone();
+
+    c->cd(1);
+    gStyle->SetOptStat(1111);
+    disp1->Draw("hist");
+    gPad->Update();
+
+    c->cd(2);
+    gStyle->SetOptStat(1101);
+    disp2->Draw("hist");
+    gPad->Update();
+
+    c->cd(3);
+    gStyle->SetOptStat(1101);
+    disp3->Draw("hist");
+    gPad->Update();
+
+    c->cd(4);
+    gPad->SetBorderMode(0);
+    gPad->Divide(1,1);
+    gPad->cd(1);
+    disp1->Draw();
+
+    c->cd(5);
+    gPad->SetBorderMode(0);
+    gPad->Divide(1,1);
+    gPad->cd(1);
+    disp2->Draw();
+
+    c->cd(6);
+    gPad->SetBorderMode(0);
+    gPad->Divide(1,1);
+    gPad->cd(1);
+    disp3->Draw();
+
+    c->SaveAs(fname(0, fname.Last('.')+1) + "ps");
+    //c->SaveAs(fname(0, fname.Last('.')+1) + "root");
+}
+
+// -------------------------------------------------------------------------
+//
+//  plot.C
+//
+//  This macro shows how to fill and display a histogram using Mars
+//
+void sumpedestals(const char *dirname=".")
+{
+    MDirIter Next;
+    Next.AddDirectory(dirname, "*1947*.root", -1);
+
+    TString fname;
+    while (1)
+    {
+        fname = Next();
+        if (fname.IsNull())
+            break;
+
+        ProcessFile(fname);
+        return;
+    }
+}
Index: /tags/Mars_V0-8-5/Mars/macros/tar.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/tar.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/tar.C	(revision 9661)
@@ -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 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////////
+//
+// tar.C
+// =====
+//
+// Service script. used to create the tar archive for an release. It makes
+// sure that the correct files are included and the name of the archive is
+// the name of the current directory (+.tar.gz)
+//
+///////////////////////////////////////////////////////////////////////////
+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=Makefile.depend --exclude=Root --exclude=Tag "+name+"/.rootrc "+name+"/*";
+
+    cout << "Executing: " << cmd << endl;
+
+    gSystem->Exec(cmd);
+    gSystem->Exec("gzip -9 "+name+".tar");
+
+    gSystem->cd(name);
+}
Index: /tags/Mars_V0-8-5/Mars/macros/testenv.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/testenv.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/testenv.C	(revision 9661)
@@ -0,0 +1,120 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////////
+//
+// testenv.C
+// =========
+//
+// This example reads an config-file (steering card, input card, ...)
+// The contents of the file a forwarded to the apropriate eventloop
+// setup in your file.
+//
+// All tasks and containers in an eventloop should implement the
+// ReadEnv/WriteEnv function (for an example see the tasks used below).
+//
+// The functions gets the corresponding setup data from the file as an
+// argument and can change their behaviour and setup on this information.
+//
+///////////////////////////////////////////////////////////////////////////
+
+void testenv()
+{
+    // Setup for all MHMatrix objects is done by:
+    // MHMatrix.Column0: ...
+    //
+    // This can be overwritten for a MHMatrix called MatrixGammas by:
+    // MatrixGammas.Column0;
+    //
+    // This can be overwritten for all MHMatrix in one Job by:
+    // Job1.MHMatrix.Column0;
+    //
+    // This can be overwritten for a MHMatrix called MatrixGammas in one Job by:
+    // Job1.MatrixGammas.Column0;
+    //
+    TEnv env(".marsrc");
+
+    //
+    // For developers: Set this to kTRUE to see how the TEnv file
+    // entries are checked.
+    //
+    Bool_t print = kFALSE;
+
+    // ------------ Job 1 -------------------
+    if (env.GetValue("Job1", kFALSE))
+    {
+        cout << "++++++++++++++++++ Job 1 +++++++++++++++++++" << endl;
+        MParList plist1;
+        MTaskList tlist1;
+
+        plist1.AddToList(&tlist1);
+
+        MReadMarsFile read1("Events");
+
+        MHMatrix matrix1("MatrixGammas");
+
+        MFillH fillm1(&matrix1);
+        plist1.AddToList(&matrix1);
+
+        tlist1.AddToList(&read1);
+        tlist1.AddToList(&fillm1);
+
+        MEvtLoop evtloop1("Job1");
+        evtloop1.SetParList(&plist1);
+        cout << "--------------------------------------------" << endl;
+        evtloop1.ReadEnv(env, "", print);
+        cout << "--------------------------------------------" << endl;
+        evtloop1.Eventloop();
+        cout << endl;
+    }
+
+    // ------------ Job 2 -------------------
+
+    if (env.GetValue("Job2", kTRUE))
+    {
+        cout << "++++++++++++++++++ Job 2 +++++++++++++++++++" << endl;
+        MParList plist2;
+        MTaskList tlist2;
+
+        plist2.AddToList(&tlist2);
+
+        MReadMarsFile read2("Events");
+
+        MHMatrix matrix2("MatrixGammas");
+
+        MFillH fillm2(&matrix2);
+        plist2.AddToList(&matrix2);
+
+        tlist2.AddToList(&read2);
+        tlist2.AddToList(&fillm2);
+
+        MEvtLoop evtloop2("Job2");
+        evtloop2.SetParList(&plist2);
+        cout << "--------------------------------------------" << endl;
+        evtloop2.ReadEnv(env, "", print);
+        cout << "--------------------------------------------" << endl;
+        evtloop2.Eventloop();
+        cout << endl;
+    }
+}
Index: /tags/Mars_V0-8-5/Mars/macros/threshold.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/threshold.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/threshold.C	(revision 9661)
@@ -0,0 +1,116 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+
+void threshold(TString filename="data/camera.root", TString outname="")
+{
+    //
+    // This macro fill the container MHMcEnergies using the task
+    // MMcThresholdCalc and shows the results.
+    //
+    MParList parlist;
+
+    MTaskList tasklist;
+    parlist.AddToList(&tasklist);
+
+    //
+    // Setup the parameter list
+    // - You need create the container MHMcEnergies.
+    //    + You need to put the number of trigger conditions when
+    //      you declarete the MHMcEnergies
+    //    + If you don't put any dimension to MHMcEnergies it works
+    //      taking only the trigger information from MMcTrig
+    //
+    const UInt_t numtrigcond = 0;
+
+    UInt_t from = numtrigcond>0 ?           1 : -numtrigcond;
+    UInt_t to   = numtrigcond>0 ? numtrigcond : -numtrigcond;
+
+    Int_t dim = to-from+1;
+
+    //
+    // Create numtriggerconditions histograms of type MHMcEnergy
+    // and store the histograms in an TObjArray
+    //
+    TObjArray hists(MParList::CreateObjList("MHMcEnergy", from, to));
+    hists.SetOwner();
+
+    //
+    // Check if the list really contains the right number of histograms
+    //
+    if (hists.GetEntriesFast() != dim)
+        return;
+
+    //
+    // Add the histograms to the paramater list.
+    //
+    parlist.AddToList(&hists);
+
+    //
+    // Setup the task list
+    // - You need the read and the MMcThresholdCalc tasks
+    // - You have to fill the histograms for the Energy threshold
+    //    + You need to put the number of trigger conditions when
+    //      you declarete the MMcThresholdCalc
+    //    + If you don't put any dimension to MMcThresholdCalc it works
+    //      like one dimension MMcThresholdCalc
+    //
+    MReadTree read("Events", filename);
+    MMcThresholdCalc calc(numtrigcond);
+
+    tasklist.AddToList(&read);
+    tasklist.AddToList(&calc);
+
+    MEvtLoop evtloop;
+    evtloop.SetParList(&parlist);
+
+    //
+    // Begin the loop (if the loop wasn't succesfull
+    // don't try to draw the results
+    //
+    MProgressBar bar;
+    evtloop.SetProgressBar(&bar);
+    if (!evtloop.Eventloop())
+        return;
+
+    //
+    // Now you can display the results
+    //
+    hists.Print();
+
+    TIter Next(&hists);
+    TObject *obj;
+    while ((obj=Next()))
+        obj->DrawClone();
+
+    // Write histogram to a file in case an output filename has been supplied:
+    if (outname.IsNull())
+        return;
+
+    TFile f(outname, "recreate");
+    if (!f)
+        return;
+
+    parlist.FindObject("MHMcEnergy")->Write();
+}
Index: /tags/Mars_V0-8-5/Mars/macros/triglvl2.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/triglvl2.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/triglvl2.C	(revision 9661)
@@ -0,0 +1,228 @@
+//   triglvl2.C
+//  Macro to use the class MMcTriggerLvl2, which calculates the 
+//   2nd level trigger (L2T) selection parameters.
+//  Filters to select events using these parameter and 
+//  histograms with selection variables distributions are also created.
+//
+//   Inputs:
+//      - filename      name of data file
+//      - CompactNN     number of NN to define a compact pixel
+//      - fValue        comparision value for the filter
+//
+//  23/04/2003 Added example of MFEnergySlope filter
+//
+//  
+void triglvl2(char *filename = "Gamma.root")
+  //    USER:   Data File Name    ---^
+{ 
+    //
+    // first we have to create our empty lists
+    //
+    MParList  parlist;
+    MTaskList tasklist;
+
+    parlist.AddToList(&tasklist);
+
+    // 
+    // Setup our tasks:
+    //  - First we have to read the events
+    //  - Then we can fill the efficiency histograms
+    //
+    
+
+    MReadMarsFile reader("Events", filename);
+    reader.DisableAutoScheme();
+     //  reader.EnableBranch("fEnergy");
+     //  reader.EnableBranch("fImpact"); reader.EnableBranch("fTimeFirst[4]");
+     //  reader.EnableBranch("fPixelsFirst[73][4]");
+   
+    tasklist.AddToList(&reader);
+    MGeomCamMagic geocam;
+    parlist.AddToList(&geocam);
+
+    //    MHillas hillas;
+    // parlist.AddToList(&hillas);
+
+    // An instance of the class MMcTriggerLvl2 is created and added to the 
+    //  parameter list
+    MMcTriggerLvl2 cell;     
+    parlist.AddToList(&cell);
+
+    MMcEvt mevt;
+    parlist.AddToList(&mevt);
+
+    // Set the number of Next Neighbourhoods that define a compact pixel
+    //
+    cell.SetCompactNN(3);
+    //  USER:       --^
+
+    //
+    //  A filter to select events using the L2T parameters is created
+    //
+    // MF lvl2filter("MMcTriggerLvl2.fPseudoSize > 25 && MMcTriggerLvl2.fPseudoSize < 31");
+    //    MF lvl2filter("MMcTriggerLvl2.fSizeBiggerCell > 34");
+    MF lvl2filter("MMcTriggerLvl2.fSizeBiggerCell > 18");
+ 
+    //
+    // A second filter is created using the class MFTriggerLvl2
+    //
+    MFTriggerLvl2 fTrig("MMcTriggerLvl2", '>', 8);
+    //      USER:       fValue to be compared --^
+
+    //
+    // A selection on the number and energy of the events 
+    //
+    MF energyfilter("MMcEvt.fEnergy > 100");
+    MFEventSelector selector;
+    //selector.SetNumSelectEvts(4000);
+
+
+    // Filter to select events according to a give slope
+    MFEnergySlope eslope;
+
+    eslope.SetMcMinEnergy(50.);
+    eslope.SetMcMaxEnergy(400.);
+    eslope.SetNewSlope(-.5);
+
+    // A filter list is created; the filters created can be added to the list
+    //
+    MFilterList flist;
+    //flist.AddToList(&energyfilter);
+    flist.AddToList(&lvl2filter);
+    //   flist.AddToList(&selector);
+    //   flist.AddToList(&eslope);
+    //   flist.AddToList(&fTrig);
+
+    //
+    // The task to calculate the L2T parameter is added to the task list
+    //
+    MMcTriggerLvl2Calc calcps("MMcTriggerLvl2","MMcTriggerLvl2");  
+    tasklist.AddToList(&calcps);
+
+    //
+    // The filter list is added to the task list
+    //
+    tasklist.AddToList(&flist);
+
+
+    MContinue L1offline ("MMcTriggerLvl2.fLutPseudoSize < 6");
+    //    tasklist.AddToList(&L1offline);
+
+    //
+    //  Task to calculate and plot the effective area
+    //
+    MMcCollectionAreaCalc effi;
+    tasklist.AddToList(&effi);    
+    //
+    // The filter list selects events for the effective area calculation
+    //
+    effi.SetFilter(&flist);
+ 
+
+    //
+    // Filling of histos for MHMcTriggerLvl2
+    //
+    MFillH hfill1("MHMcTriggerLvl2","MMcTriggerLvl2");
+    tasklist.AddToList(&hfill1);
+    //hfill1.SetFilter(&flist);
+    //MFillH hfill2("MHMcTriggerLvl2", &mevt, &cell);
+    //tasklist.AddToList(&hfill2);
+    //hfill2.SetFilter(&flist);
+
+    
+    
+    //
+    // set up the loop for the processing
+    //
+    MEvtLoop magic;
+    magic.SetParList(&parlist);
+
+    
+    //
+    // Start to loop over all events
+    //
+    MProgressBar bar;
+    magic.SetProgressBar(&bar);
+
+
+    if (!magic.Eventloop())
+      return;
+    /*
+    if (!magic.PreProcess())
+    return;
+    
+    while (tasklist.Process())
+      {
+	cout<< mevt.GetEnergy()<<endl;
+	
+	cell.Print();
+      }
+    */
+    //fMcEvt = (MMcEvt*)parlist->FindObject("MMcEvt");
+    //if (!fMcEvt)
+    //{
+    //cout << "MMcEvt not found... exit." << endl;
+    //*fLog << err << dbginf << "MMcEvt not found... exit." << endl;
+    //  return kFALSE;
+    //}
+    //   cout << "fMcEvt = " << fMcEvt << endl;
+
+    //parlist.FindObject("MHMcTriggerLvl2")->Fill((Double_t) fMcEvt->GetEnergy(), cell);
+
+
+    tasklist.PrintStatistics();
+ 
+    //
+    // Now the histogram we wanted to get out of the data is
+    // filled and can be displayd
+    //
+    
+
+    //parlist.FindObject("MHMcTriggerLvl2")->DrawClone("sbc");
+    //parlist.FindObject("MHMcTriggerLvl2")->DrawClone("lps");
+    //parlist.FindObject("MHMcTriggerLvl2")->DrawClone();
+    //parlist.FindObject("MHMcTriggerLvl2")->DrawClone("energy");
+    //parlist.FindObject("MHMcTriggerLvl2")->DrawClone("lut-energy");
+    //parlist.FindObject("MHMcCollectionArea")->DrawClone();
+    // Returns histogram of the class MHMcTriggerLvl2  
+    
+    MHMcTriggerLvl2 *htrig = (MHMcTriggerLvl2 *)parlist.FindObject("MHMcTriggerLvl2");
+    MHMcCollectionArea *collarea = (MHMcCollectionArea *)parlist.FindObject("MHMcCollectionArea");
+    TH1F *hps = (TH1F *)htrig->GetHistByName("fHistPseudoSize");
+    TH1F *hlps = (TH1F *)htrig->GetHistByName("fHistLutPseudoSize");
+    TH1F *hsbc = (TH1F *)htrig->GetHistSizeBiggerCell();
+    TH1F *hpsn = (TH1F *)htrig->GetHistByName("fHistPseudoSizeNorm");
+    TH1F *hlpsn = (TH1F *)htrig->GetHistByName("fHistLutPseudoSizeNorm");
+    TH1F *hsbcn = (TH1F *)htrig->GetHistSizeBiggerCellNorm();
+    TH2D *hlpse = (TH2D *)htrig->GetHistByName("fHistLutPseudoSizeEnergy");
+    TH2D *hpse = (TH2D *)htrig->GetHistByName("fHistPseudoSizeEnergy");
+    TH2D *hsbce = (TH2D *)htrig->GetHistSizeBiggerCellEnergy();
+    TH1D *hcollarea = collarea->GetHist();
+
+    // Please set rootfile as the directory where you want to store
+    // your file.root containing histograms
+    rootfile = new TString(filename);
+    if (rootfile->Index("/*.root",1)>=0){
+      rootfile->Resize(rootfile->Index("/*.root",1));
+      rootfile[0]+="_sbcmag18_CNN3.root";
+    }
+      
+    hfile = new TFile((char *)rootfile[0], "RECREATE");
+    hlps->Write();
+    hps->Write();
+    hsbc->Write();
+    hlpsn->Write();
+    hpsn->Write();
+    hsbcn->Write();
+    hlpse->Write();
+    hpse->Write();
+    hsbce->Write();
+    hcollarea->Write();
+    hfile->Close();
+    cout << "Histograms stored into " << rootfile[0] << endl;
+    
+
+}
+
+
+
Index: /tags/Mars_V0-8-5/Mars/macros/trigrate.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/trigrate.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/trigrate.C	(revision 9661)
@@ -0,0 +1,209 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+\* ======================================================================== */
+
+/*
+ !   Modified 4/7/2002, Abelardo Moralejo:
+ !   Added one optional input parameter: a camera .root file containing
+ !   pure NSB events. One such file is generated running the camera over an
+ !   "empty" reflector file, with the NSB option on, and asking the camera
+ !   program (see camera program manual) to do the simulation even if no
+ !   photoelectron from the shower arrives at the camera. One also needs to
+ !   write to the output file all the events, both triggered and untriggered
+ !   (see again camera manual). These nsb camera files must contain the same
+ !   trigger conditions as the proton file.
+ !
+ !   If no nsb file is supplied, the macro will assume no triggers from
+ !   pure NSB fluctuations.
+ */
+
+Float_t GetNSBEvents(TString name, Float_t *BgR, int dim)
+{
+    Int_t numnsbevents;
+
+    TFile bgfile(name);
+    TTree *events = (TTree*) bgfile.Get("Events");
+
+    TH1F h("h","",5,.5,5.5);
+
+    UInt_t from = dim>0 ?   1 : -dim;
+    UInt_t to   = dim>0 ? dim : -dim;
+
+    cout << endl << "Calculating NSB triggers from file " << name << "..." << endl << endl;
+
+    for (UInt_t i = from; i <= to; i++)
+    {
+      TString cond("MMcTrig;");
+      cond += i;
+      cond += ".";
+      TBranch *b = events->GetBranch(cond);
+      MMcTrig *mctrig;
+      b->SetAddress(&mctrig);
+
+      Int_t tottrig = 0.;
+      
+      UInt_t imax = b->GetEntries();
+
+      for (UInt_t iev = 0; iev < imax; iev++)
+	{	
+	  b->GetEvent(iev);
+	  tottrig += mctrig->GetFirstLevel();
+	}
+      // Set total number of L1 triggers:
+      BgR[dim>0? i-1: 0] = (Float_t) tottrig;
+
+      numnsbevents = (Float_t) imax;
+    }
+
+    return numnsbevents;
+}
+
+
+void trigrate(int dim=0, char *filename = "data/camera.root", 
+	      char *nsbfile = NULL)
+{
+    // The dim parameter has three possible values:
+    // dim : = 0 -> root file with 1 trigger condition.
+    //       > 0 -> number of trigger condition to be analised 
+    //              in multi conditon file.
+    //       < 0 -> selects the -dim trigger condition.
+    //
+    // first we have to create our empty lists
+    //
+    MParList  parlist;
+    MTaskList tasklist;
+
+    //
+    // Setup the parameter list.
+    //  - we do not need to create any other container. All of them
+    //    are created automatically without loss - we don't have to
+    //    access them-
+    //
+    //  - we need to create MHMcRate only. The other containers
+    //    are created automatically without loss - we don't have to
+    //    access them-
+    //  - MHMcRate must be created by us because we need the pointer
+    //    to it and if it would get created automatically it would also be
+    //    deleted automatically
+    //  - Actually, depending on using a single trigger option MonteCarlo
+    //    file or a multyple trigger option, a MHMcRate or an array of 
+    //    MHMcRate are needed.
+    //
+    parlist.AddToList(&tasklist);
+
+    //
+    // You don't have to add the MHMcRate container here by hand.
+    // But if you want to print or display these containers later on
+    // it is necessary (Rem: No printing or displaying is done in this
+    // macro yet)
+    //
+    UInt_t from = dim>0 ?   1 : -dim;
+    UInt_t to   = dim>0 ? dim : -dim;
+
+    Int_t num = to-from+1;
+
+    TObjArray hists(MParList::CreateObjList("MHMcRate", from, to));
+    hists.SetOwner();
+
+    //
+    // Check if the list really contains the right number of histograms
+    //
+    if (hists.GetEntriesFast() != num)
+        return;
+
+    // Set for each MHMcRate object the trigger condition number in the 
+    // camera file (for the case of camera files with several conditions,
+    // produced with the trigger_loop option.
+    //
+
+    if (dim < 0)
+      ((MHMcRate*)(hists[0]))->SetTriggerCondNum((Short_t)(-dim));
+    if (dim > 0)
+      for (Short_t i = from ; i <= to; i++)
+	((MHMcRate*)(hists[i-1]))->SetTriggerCondNum(i);
+
+    //
+    // 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[])
+    //
+
+    MReadMarsFile reader("Events", filename);
+    tasklist.AddToList(&reader);
+
+    // Now we have to build the BgR array, containing the number 
+    // of triggers (may be more than 1 trigger/event!) from the
+    // numnsbevents simulated in the nsbfile (3rd input parameter).
+    // If no nsbfile is supplied, we assume no triggers from NSB
+
+    Float_t* BgR = new Float_t[num];
+    memset(BgR, 0, num*sizeof(Float_t));
+
+    Float_t numnsbevents = 5.e4; // some default value.
+    if (nsbfile)
+      numnsbevents = GetNSBEvents(nsbfile, BgR, dim);
+
+    cout << "Number of Trigger conditions: " << num << endl;
+
+    MMcTriggerRateCalc rate(dim, BgR, numnsbevents);
+
+    tasklist.AddToList(&rate);
+
+    //
+    // set up the loop for the processing
+    //
+    MEvtLoop magic;
+    magic.SetParList(&parlist);
+
+    //
+    // Start to loop over all events
+    //
+    MProgressBar bar;
+    magic.SetProgressBar(&bar);
+    if (!magic.Eventloop())
+        return;
+
+    delete BgR;
+
+    hists.Print();
+
+    if (num > 1)
+      {
+	gStyle->SetOptStat(0);
+	rate->Draw();
+
+	TFile f("ratehists.root", "recreate");
+	
+	rate->GetHist(2)->Write();
+	rate->GetHist(3)->Write();
+	rate->GetHist(4)->Write();
+      }
+
+
+}
Index: /tags/Mars_V0-8-5/Mars/macros/unfold.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/unfold.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/unfold.C	(revision 9661)
@@ -0,0 +1,3505 @@
+   
+////////////////////////////////////////////////////////////////////////////
+//                                                                        //
+// This program should be run under root :                                //
+//      root unfold.C++                                                   //
+//                                                                        //
+// Author(s) : T. Bretz  02/2002 <mailto:tbretz@astro.uni-wuerzburg.de>   //
+// Author(s) : W. Wittek 09/2002 <mailto:wittek@mppmu.mpg.de>             //
+//                                                                        //
+////////////////////////////////////////////////////////////////////////////
+
+#include <TMath.h>
+#include <TRandom3.h>
+#include <TVector.h>
+#include <TMatrixD.h>
+#include <TMatrix.h>
+#include <TH1.h>
+#include <TH2.h>
+#include <TProfile.h>
+#include <TF1.h>
+#include <iostream.h>
+#include <TMinuit.h>
+#include <TCanvas.h>
+#include <TMarker.h>
+
+#include <fstream.h>
+#include <iomanip.h>
+
+TH1 *DrawMatrixClone(const TMatrixD &m, Option_t *opt="")
+{
+    const Int_t nrows = m.GetNrows();
+    const Int_t ncols = m.GetNcols();
+
+    TMatrix m2(nrows, ncols);
+    for (int i=0; i<nrows; i++)
+        for (int j=0; j<ncols; j++)
+            m2(i, j) = m(i, j);
+
+    TH2F *hist = new TH2F(m2);
+    hist->SetBit(kCanDelete);
+    hist->Draw(opt);
+    hist->SetDirectory(NULL);
+
+    return hist;
+
+}
+
+TH1 *DrawMatrixColClone(const TMatrixD &m, Option_t *opt="", Int_t col=0)
+{
+    const Int_t nrows = m.GetNrows();
+
+    TVector vec(nrows);
+    for (int i=0; i<nrows; i++)
+        vec(i) = m(i, col);
+
+    TH1F *hist = new TH1F("TVector","",nrows,0,nrows);
+    for (int i=0; i<nrows; i++)
+    {
+      hist->SetBinContent(i+1, vec(i));
+    }
+
+    hist->SetBit(kCanDelete);
+    hist->Draw(opt);
+    hist->SetDirectory(NULL);
+
+    return hist;
+}
+
+
+void PrintTH2Content(const TH2 &hist)
+{
+    cout << hist.GetName() << ": " << hist.GetTitle() << endl;
+    cout << "-----------------------------------------------------" << endl;
+    for (Int_t i=1; i<=hist.GetNbinsX(); i++)
+        for (Int_t j=1; j<=hist.GetNbinsY(); j++)
+            cout << hist.GetBinContent(i,j) << " \t";
+        cout << endl << endl;
+}
+
+void PrintTH2Error(const TH2 &hist)
+{
+    cout << hist.GetName() << ": " << hist.GetTitle() << " <error>" << endl;
+    cout << "-----------------------------------------------------" << endl;
+    for (Int_t i=1; i<=hist.GetNbinsX(); i++)
+    {
+        for (Int_t j=1; j<=hist.GetNbinsY(); j++)
+            cout << hist.GetBinError(i, j) << " \t";
+        cout << endl << endl;
+    }
+}
+
+void PrintTH1Content(const TH1 &hist)
+{
+    cout << hist.GetName() << ": " << hist.GetTitle() << endl;
+    cout << "-----------------------------------------------------" << endl;
+    for (Int_t i=1; i<=hist.GetNbinsX(); i++)
+        cout << hist.GetBinContent(i) << " \t";
+    cout << endl << endl;
+}
+
+void PrintTH1Error(const TH1 &hist)
+{
+    cout << hist.GetName() << ": " << hist.GetTitle() << " <error>" << endl;
+    cout << "-----------------------------------------------------" << endl;
+    for (Int_t i=1; i<=hist.GetNbinsX(); i++)
+        cout << hist.GetBinError(i) << " \t";
+    cout << endl << endl;
+}
+
+void CopyCol(TMatrixD &m, const TH1 &h, Int_t col=0)
+{
+    const Int_t n = m.GetNrows();
+
+    for (Int_t i=0; i<n; i++)
+        m(i, col) = h.GetBinContent(i+1);
+}
+
+void CopyCol(TH1 &h, const TMatrixD &m, Int_t col=0)
+{
+    const Int_t n = m.GetNrows();
+
+    for (Int_t i=0; i<n; i++)
+        h.SetBinContent(i+1, m(i, col));
+}
+
+void CopyH2M(TMatrixD &m, const TH2 &h)
+{
+    const Int_t nx = m.GetNrows();
+    const Int_t ny = m.GetNcols();
+
+    for (Int_t i=0; i<nx; i++)
+        for (Int_t j=0; j<ny; j++)
+            m(i, j) = h.GetBinContent(i+1, j+1);
+}
+
+void CopySqr(TMatrixD &m, const TH1 &h)
+{
+    const Int_t nx = m.GetNrows();
+    const Int_t ny = m.GetNcols();
+
+    for (Int_t i=0; i<nx; i++)
+        for (Int_t j=0; j<ny; j++)
+        {
+            const Double_t bin =  h.GetBinContent(i+1, j+1);
+            m(i, j) = bin*bin;
+        }
+}
+
+Double_t GetMatrixSumRow(const TMatrixD &m, Int_t row)
+{
+    const Int_t n = m.GetNcols();
+
+    Double_t sum = 0;
+    for (Int_t i=0; i<n; i++)
+        sum += m(row, i);
+
+    return sum;
+}
+
+Double_t GetMatrixSumDiag(const TMatrixD &m)
+{
+    const Int_t n = m.GetNcols();
+
+    Double_t sum = 0;
+    for (Int_t i=0; i<n; i++)
+        sum += m(i, i);
+
+    return sum;
+}
+
+Double_t GetMatrixSumCol(const TMatrixD &m, Int_t col=0)
+{
+    const Int_t n = m.GetNrows();
+
+    Double_t sum = 0;
+    for (Int_t i=0; i<n; i++)
+        sum += m(i, col);
+
+    return sum;
+}
+Double_t GetMatrixSum(const TMatrixD &m)
+{
+    const Int_t n = m.GetNrows();
+
+    Double_t sum = 0;
+    for (Int_t i=0; i<n; i++)
+        sum += GetMatrixSumRow(m, i);
+
+    return sum;
+}
+
+////////////////////////////////////////////////////////////////////////////
+//                                                                        //
+// fcnSmooth   (used by SmoothMigrationMatrix)                                 //
+//                                                                        //
+// is called by MINUIT                                                    //
+// for given values of the parameters it calculates                       //
+//                     the function to be minimized                       //  
+//                                                                        //
+////////////////////////////////////////////////////////////////////////////
+void fcnSmooth(Int_t &npar, Double_t *gin, Double_t &f, 
+               Double_t *par, Int_t iflag);
+
+
+
+////////////////////////////////////////////////////////////////////////////
+//                                                                        //
+// fcnTikhonov2   (used by Tikhonov2)                                     //
+//                                                                        //
+// is called by MINUIT                                                    //
+// for given values of the parameters it calculates                       //
+//                     the function to be minimized                       //  
+//                                                                        //
+////////////////////////////////////////////////////////////////////////////
+void fcnTikhonov2(Int_t &npar, Double_t *gin, Double_t &f, 
+                              Double_t *par, Int_t iflag);
+
+////////////////////////////////////////////////////////////////////////////
+//                                                                        //
+// MUnfold                                                                //
+//                                                                        //
+// class for unfolding a 1-dimensional distribution                       //
+//                                                                        //
+// the methods used are described in :                                    //
+//                                                                        //
+//     V.B.Anykeyev et al., NIM A303 (1991) 350                           //
+//     M. Schmelling, Nucl. Instr. and Meth. A 340 (1994) 400             //
+//     M. Schmelling : "Numerische Methoden der Datenanalyse"             //
+//                    Heidelberg, Maerz 1998                              //
+//     M.Bertero, INFN/TC-88/2 (1988)                                     //
+//                                                                        //
+////////////////////////////////////////////////////////////////////////////
+class MUnfold : public TObject
+{
+public:
+
+    UInt_t    fNa;        // Number of bins in the distribution to be unfolded
+    UInt_t    fNb;        // Number of bins in the unfolded distribution
+
+    TMatrixD  fMigrat;    // migration matrix                  (fNa, fNb)
+    TMatrixD  fMigraterr2;// error**2 of migration matrix      (fNa, fNb)
+
+    TMatrixD  fMigOrig;    // original migration matrix         (fNa, fNb)
+    TMatrixD  fMigOrigerr2;// error**2 oforiginal migr. matrix  (fNa, fNb)
+
+    TMatrixD  fMigSmoo;    // smoothed migration matrix M       (fNa, fNb)
+    TMatrixD  fMigSmooerr2;// error**2 of smoothed migr. matrix (fNa, fNb)
+    TMatrixD  fMigChi2;    // chi2 contributions for smoothing  (fNa, fNb)
+
+    TMatrixD  fVa;        // distribution to be unfolded       (fNa)
+    TMatrixD  fVacov;     // error matrix of fVa               (fNa, fNa)
+    TMatrixD  fVacovInv; // inverse of fVacov                 (fNa, fNa)
+    Double_t  fSpurVacov; // Spur of fVacov
+
+    //    UInt_t    fVaevents;  // total number of events
+    UInt_t    fVapoints;  // number of significant measurements
+
+    TMatrixD  fVb;        // unfolded distribution             (fNb)
+    TMatrixD  fVbcov;     // error matrix of fVb               (fNb, fNb)
+
+    TMatrixD  fVEps;      // prior distribution                (fNb)
+    TMatrixDColumn fVEps0;
+
+    Double_t  fW;         // weight
+    Double_t  fWbest;     // best weight
+    Int_t     ixbest;
+
+    TMatrixD  fResult;    // unfolded distribution and errors  (fNb, 5)
+    TMatrixD  fChi2;      // chisquared contribution           (fNa, 1)
+
+    Double_t  fChisq;     // total chisquared
+    Double_t  fNdf;       // number of degrees of freedom
+    Double_t  fProb;      // chisquared probability
+
+    TMatrixD  G;          // G = M * M(transposed)             (fNa, fNa)
+    TVectorD  EigenValue; // vector of eigenvalues lambda of G (fNa)
+    TMatrixD  Eigen;      // matrix of eigen vectors of G      (fNa, fNa)
+    Double_t  RankG;      // rank of G
+    Double_t  tau;        // 1 / lambda_max
+    Double_t  EpsLambda;
+
+    // quantities stored for each weight :
+    TVectorD SpSig;       // Spur of covariance matrix of fVbcov
+    TVectorD SpAR;        // effective rank of G^tilde
+    TVectorD chisq;       // chi squared (measures agreement between
+    // fVa and the folded fVb)
+    TVectorD SecDer;      // regularization term = sum of (2nd der.)**2
+    TVectorD ZerDer;      // regularization term = sum of (fVb)**2
+    TVectorD Entrop;      // regularization term = reduced cross-entropy
+    TVectorD DAR2;        //
+    TVectorD Dsqbar;      //
+
+    Double_t SpurAR;
+    Double_t SpurSigma;
+    Double_t SecDeriv;
+    Double_t ZerDeriv;
+    Double_t Entropy;
+    Double_t DiffAR2;
+    Double_t Chisq;
+    Double_t D2bar;
+
+    TMatrixD Chi2;
+
+    //
+
+    // plots versus weight
+    Int_t    Nix;
+    Double_t xmin;
+    Double_t xmax;
+    Double_t dlogx;
+
+    TH1D *hBchisq;
+    TH1D *hBSpAR;
+    TH1D *hBDSpAR;
+    TH1D *hBSpSig;
+    TH1D *hBDSpSig;
+    TH1D *hBSecDeriv;
+    TH1D *hBDSecDeriv;
+    TH1D *hBZerDeriv;
+    TH1D *hBDZerDeriv;
+    TH1D *hBEntropy;
+    TH1D *hBDEntropy;
+    TH1D *hBDAR2;
+    TH1D *hBD2bar;
+
+    //
+    TH1D *hEigen;
+
+    // plots for the best solution
+    TH2D *fhmig;
+    TH2D *shmig;
+    TH2D *shmigChi2;
+
+    TH1D *fhb0;
+
+    TH1D *fha;
+
+    TH1D *hprior;
+
+    TH1D *hb;
+
+    Double_t CalcSpurSigma(TMatrixD &T, Double_t norm=1)
+    {
+        Double_t spursigma = 0;
+
+        for (UInt_t a=0; a<fNb; a++)
+        {
+            for (UInt_t b=0; b<fNb; b++)
+            {
+                fVbcov(a,b) = 0;
+
+                for (UInt_t c=0; c<fNa; c++)
+                    for (UInt_t d=0; d<fNa; d++)
+                        fVbcov(a,b) += T(a,d)*fVacov(d,c)*T(b,c);
+
+                fVbcov(a,b) *= norm*norm;
+            }
+            spursigma += fVbcov(a,a);
+        }
+
+        return spursigma;
+    }
+
+public:
+    // -----------------------------------------------------------------------
+    //
+    // Constructor
+    //              copy histograms into matrices
+    //
+    MUnfold(TH1D &ha, TH2D &hacov, TH2D &hmig)
+        : fVEps(hmig.GetYaxis()->GetNbins(),1), fVEps0(fVEps, 0)
+    {
+        // ha      is the distribution to be unfolded
+        // hacov   is the covariance matrix of ha
+        // hmig    is the migration matrix;
+        //         this matrix will be used in the unfolding
+        //         unless SmoothMigrationMatrix(*hmigrat) is called;
+        //         in the latter case hmigrat is smoothed
+        //         and the smoothed matrix is used in the unfolding
+
+        // Eigen values of the matrix G, which are smaller than EpsLambda
+        // will be considered as being zero
+        EpsLambda = 1.e-10;
+        fW = 0.0;
+
+        fNa  = hmig.GetXaxis()->GetNbins();
+        const Double_t alow = hmig.GetXaxis()->GetXmin();
+        const Double_t aup  = hmig.GetXaxis()->GetXmax();
+
+        fNb  = hmig.GetYaxis()->GetNbins();
+        const Double_t blow = hmig.GetYaxis()->GetXmin();
+        const Double_t bup  = hmig.GetYaxis()->GetXmax();
+
+
+        UInt_t Na = ha.GetNbinsX();
+        if (fNa != Na)
+        {
+            cout << "MUnfold::MUnfold : dimensions do not match,  fNa = ";
+            cout << fNa << ",   Na = " << Na << endl;
+        }
+
+        cout << "MUnfold::MUnfold :" << endl;
+        cout << "==================" << endl;
+        cout << "   fNa = " << fNa << ",   fNb = " << fNb << endl;
+
+        // ------------------------
+
+        fVa.ResizeTo(fNa, 1);
+        CopyCol(fVa, ha, 0);
+
+        cout << "   fVa = ";
+
+        for (UInt_t i=0; i<fNa; i++)
+            cout << fVa(i,0) << " \t";
+        cout << endl;
+
+        Double_t vaevents = GetMatrixSumCol(fVa, 0);
+        cout << "   Total number of events in fVa = " << vaevents << endl;
+
+        // ------------------------
+
+        fChi2.ResizeTo(fNa,1);
+        Chi2.ResizeTo(fNa,1);
+
+        // ------------------------
+
+        fVacov.ResizeTo(fNa, fNa);
+        fSpurVacov = 0;
+
+        CopyH2M(fVacov, hacov);
+
+        fVapoints = 0;
+        for (UInt_t i=0; i<fNa; i++)
+            if (fVa(i,0)>0 && fVacov(i,i)<fVa(i,0)*fVa(i,0))
+                fVapoints++;
+
+        fSpurVacov = GetMatrixSumDiag(fVacov);
+
+        cout << "MUnfold::MUnfold :   fVacov = " << endl;
+        cout << "==============================" << endl;
+        fVacov.Print();
+
+        cout << "   Number of significant points in fVa = ";
+        cout << fVapoints << endl;
+
+        cout << "   Spur of fVacov = ";
+        cout << fSpurVacov << endl;
+
+        // ------------------------
+
+        fVacovInv.ResizeTo(fNa, fNa);
+        fVacovInv = fVacov;
+        fVacovInv.InvertPosDef();
+
+        cout << "MUnfold::MUnfold :   fVacovInv = " << endl;
+        cout << "==================================" << endl;
+        fVacovInv.Print();
+
+        // ------------------------
+        // fMigrat is the migration matrix to be used in the unfolding;
+        // fMigrat may be overwritten by SmoothMigrationMatrix
+
+        fMigrat.ResizeTo(fNa, fNb); // row, col
+
+        CopyH2M(fMigrat, hmig);
+
+
+        // ------------------------
+
+        fMigraterr2.ResizeTo(fNa, fNb); // row, col
+        CopySqr(fMigraterr2, hmig);
+
+        // normaxlize
+
+        for (UInt_t j=0; j<fNb; j++)
+        {
+            const Double_t sum = GetMatrixSumCol(fMigrat, j);
+
+            if (sum==0)
+                continue;
+
+            TMatrixDColumn col1(fMigrat, j);
+            col1 *= 1./sum;
+
+            TMatrixDColumn col2(fMigraterr2, j);
+            col2 *= 1./(sum*sum);
+        }
+
+        cout << "MUnfold::MUnfold :   fMigrat = " << endl;
+        cout << "===============================" << endl;
+        fMigrat.Print();
+
+        cout << "MUnfold::MUnfold :   fMigraterr2 = " << endl;
+        cout << "===================================" << endl;
+        fMigraterr2.Print();
+
+        // ------------------------
+        G.ResizeTo(fNa, fNa);
+        EigenValue.ResizeTo(fNa);
+        Eigen.ResizeTo(fNa, fNa);
+
+        fMigOrig.ResizeTo(fNa, fNb); 
+        fMigOrigerr2.ResizeTo(fNa, fNb); 
+
+        fMigSmoo.ResizeTo    (fNa, fNb); 
+        fMigSmooerr2.ResizeTo(fNa, fNb); 
+        fMigChi2.ResizeTo    (fNa, fNb); 
+
+        // ------------------------
+
+        fVEps0 = 1./fNb;
+
+        cout << "MUnfold::MUnfold :   Default prior distribution fVEps = " << endl;
+        cout << "========================================================" << endl;
+        fVEps.Print();
+
+        // ------------------------
+
+        fVb.ResizeTo(fNb,1);
+        fVbcov.ResizeTo(fNb,fNb);
+
+        // ----------------------------------------------------
+        // number and range of weights to be scanned
+        Nix  = 30;
+        xmin = 1.e-5;
+        xmax = 1.e5;
+        dlogx = (log10(xmax)-log10(xmin)) / Nix;
+
+        SpSig.ResizeTo (Nix);
+        SpAR.ResizeTo  (Nix);
+        chisq.ResizeTo (Nix);
+        SecDer.ResizeTo(Nix);
+        ZerDer.ResizeTo(Nix);
+        Entrop.ResizeTo(Nix);
+        DAR2.ResizeTo  (Nix);
+        Dsqbar.ResizeTo(Nix);
+
+        //------------------------------------
+        // plots as a function of the iteration  number
+
+        hBchisq = new TH1D("Bchisq", "chisq",
+                           Nix, log10(xmin)-dlogx/2.0, log10(xmax)-dlogx/2.0 );
+
+        hBSpAR  = new TH1D("BSpAR", "SpurAR",
+                           Nix, log10(xmin)-dlogx/2.0, log10(xmax)-dlogx/2.0 );
+
+        hBDSpAR  = new TH1D("BDSpAR", "Delta(SpurAR)",
+                            Nix, log10(xmin)-dlogx/2.0, log10(xmax)-dlogx/2.0 );
+
+        hBSpSig = new TH1D("BSpSig", "SpurSigma/SpurC",
+                           Nix, log10(xmin)-dlogx/2.0, log10(xmax)-dlogx/2.0 );
+
+        hBDSpSig = new TH1D("BDSpSig", "Delta(SpurSigma/SpurC)",
+                            Nix, log10(xmin)-dlogx/2.0, log10(xmax)-dlogx/2.0 );
+
+        hBSecDeriv = new TH1D("BSecDeriv", "Second Derivative squared",
+                              Nix, log10(xmin)-dlogx/2.0, log10(xmax)-dlogx/2.0 );
+
+        hBDSecDeriv = new TH1D("BDSecDeriv", "Delta(Second Derivative squared)",
+                               Nix, log10(xmin)-dlogx/2.0, log10(xmax)-dlogx/2.0 );
+
+        hBZerDeriv = new TH1D("BZerDeriv", "Zero Derivative squared",
+                              Nix, log10(xmin)-dlogx/2.0, log10(xmax)-dlogx/2.0 );
+
+        hBDZerDeriv = new TH1D("BDZerDeriv", "Delta(Zero Derivative squared)",
+                               Nix, log10(xmin)-dlogx/2.0, log10(xmax)-dlogx/2.0 );
+
+        hBEntropy = new TH1D("BEntrop", "Entropy",
+                             Nix, log10(xmin)-dlogx/2.0, log10(xmax)-dlogx/2.0 );
+
+        hBDEntropy = new TH1D("BDEntrop", "Delta(Entropy)",
+                              Nix, log10(xmin)-dlogx/2.0, log10(xmax)-dlogx/2.0 );
+
+        hBDAR2 = new TH1D("BDAR2", "norm(AR-AR+)",
+                          Nix, log10(xmin)-dlogx/2.0, log10(xmax)-dlogx/2.0 );
+
+        hBD2bar = new TH1D("BD2bar", "(b_unfolded-b_ideal)**2",
+                           Nix, log10(xmin)-dlogx/2.0, log10(xmax)-dlogx/2.0 );
+
+        //-------------------------------------
+        // original migration matrix
+        fhmig = new TH2D("fMigrat", "Migration matrix",
+                         fNa, alow, aup, fNb, blow, bup);
+        fhmig->Sumw2();
+
+        //-------------------------------------
+        // smoothed migration matrix
+        shmig = new TH2D("sMigrat", "Smoothed migration matrix",
+                         fNa, alow, aup, fNb, blow, bup);
+        shmig->Sumw2();
+
+        //-------------------------------------
+        // chi2 contributions for smoothing of migration matrix
+        shmigChi2 = new TH2D("sMigratChi2", "Chi2 contr. for smoothing",
+                             fNa, alow, aup, fNb, blow, bup);
+
+        //-------------------------------------
+        // eigen values of matrix G = M * M(transposed)
+        hEigen = new TH1D("Eigen", "Eigen values of M*MT",
+                          fNa, 0.5, fNa+0.5);
+
+        //------------------------------------
+        // Ideal distribution
+        
+        fhb0 = new TH1D("fhb0", "Ideal distribution", fNb, blow, bup);
+        fhb0->Sumw2();
+        
+
+        //------------------------------------
+        // Distribution to be unfolded
+        fha = new TH1D("fha", "Distribution to be unfolded", fNa, alow, aup);
+        fha->Sumw2();
+
+        //------------------------------------
+        // Prior distribution
+        hprior = new TH1D("Prior", "Prior distribution", fNb, blow, bup);
+
+        //------------------------------------
+        // Unfolded distribution
+        hb = new TH1D("DataSp", "Unfolded distribution", fNb, blow, bup);
+        hb->Sumw2();
+
+    }
+
+    // -----------------------------------------------------------------------
+    //
+    // Define prior distribution to be a constant
+    //
+    void SetPriorConstant()
+    {
+        fVEps0 = 1./fNb;
+
+        CopyCol(*hprior, fVEps);
+
+        cout << "SetPriorConstant : Prior distribution fVEps = " << endl;
+        cout << "==============================================" << endl;
+        fVEps.Print();
+    }
+
+    // -----------------------------------------------------------------------
+    //
+    // Take prior distribution from the histogram 'ha'
+    // which may have a different binning than 'hprior'
+    //
+    Bool_t SetPriorRebin(TH1D &ha)
+    {
+        // ------------------------------------------------------------------
+        //
+        // fill the contents of histogram 'ha' into the histogram 'hrior';
+        // the histograms need not have the same binning;
+        // if the binnings are different, the bin contents of histogram 'ha'
+        //    are distributed properly (linearly) over the bins of 'hprior'
+        //
+
+        const Int_t    na   = ha.GetNbinsX();
+        const Double_t alow = ha.GetBinLowEdge(1);
+        const Double_t aup  = ha.GetBinLowEdge(na+1);
+
+        const Int_t    nb   = hprior->GetNbinsX();
+        const Double_t blow = hprior->GetBinLowEdge(1);
+        const Double_t bup  = hprior->GetBinLowEdge(nb+1);
+
+        // check whether there is an overlap
+        //       between the x ranges of the 2 histograms
+        if (alow>bup || aup<blow)
+        {
+            cout << "Rebinning not possible because there is no overlap of the x ranges of the two histograms" << endl;
+            return kFALSE;
+        }
+
+        // there is an overlap
+        //********************
+        Double_t sum = 0;
+        for (Int_t j=1; j<=nb; j++)
+        {
+            const Double_t yl = hprior->GetBinLowEdge(j);
+            const Double_t yh = hprior->GetBinLowEdge(j+1);
+
+            // search bins of histogram ha which contribute
+            // to bin j of histogram hb
+            //----------------
+            Int_t il=0;
+            Int_t ih=0;
+            for (Int_t i=2; i<=na+1; i++)
+            {
+                const Double_t xl = ha.GetBinLowEdge(i);
+                if (xl>yl)
+                {
+                    il = i-1;
+
+                    //.................................
+                    ih = 0;
+                    for (Int_t k=(il+1); k<=(na+1); k++)
+                    {
+                        const Double_t xh = ha.GetBinLowEdge(k);
+                        if (xh >= yh)
+                        {
+                            ih = k-1;
+                            break;
+                        }
+                    }
+                    //.................................
+                    if (ih == 0)
+                        ih = na;
+                    break;
+                }
+            }
+            //----------------
+            if (il == 0)
+            {
+                cout << "Something is wrong " << endl;
+                cout << "          na, alow, aup = " << na << ",  " << alow
+                    << ",  " << aup << endl;
+                cout << "          nb, blow, bup = " << nb << ",  " << blow
+                    << ",  " << bup << endl;
+                return kFALSE;
+            }
+
+            Double_t content=0;
+            // sum up the contribution to bin j
+            for (Int_t i=il; i<=ih; i++)
+            {
+                const Double_t xl = ha.GetBinLowEdge(i);
+                const Double_t xh = ha.GetBinLowEdge(i+1);
+                const Double_t bina = xh-xl;
+
+                if (xl<yl  &&  xh<yh)
+                    content += ha.GetBinContent(i) * (xh-yl) / bina;
+                else
+                    if (xl<yl  &&  xh>=yh)
+                        content += ha.GetBinContent(i) * (yh-yl) / bina;
+                    else
+                        if (xl>=yl  &&  xh<yh)
+                            content += ha.GetBinContent(i);
+                        else if (xl>=yl  &&  xh>=yh)
+                            content += ha.GetBinContent(i) * (yh-xl) / bina;
+            }
+            hprior->SetBinContent(j, content);
+            sum += content;
+        }
+
+        // normalize histogram hb
+        if (sum==0)
+        {
+            cout << "histogram hb is empty; sum of weights in ha = ";
+            cout << ha.GetSumOfWeights() << endl;
+            return kFALSE;
+        }
+
+        for (Int_t j=1; j<=nb; j++)
+        {
+            const Double_t content = hprior->GetBinContent(j)/sum;
+            hprior->SetBinContent(j, content);
+            fVEps0(j-1) = content;
+        }
+
+        cout << "SetPriorRebin : Prior distribution fVEps = " << endl;
+        cout << "===========================================" << endl;
+        fVEps.Print();
+
+        return kTRUE;
+    }
+
+
+    // -----------------------------------------------------------------------
+    //
+    // Set prior distribution to a given distribution 'hpr'
+    //
+    Bool_t SetPriorInput(TH1D &hpr)
+    {
+        CopyCol(fVEps, hpr);
+
+        const Double_t sum = GetMatrixSumCol(fVEps, 0);
+
+        if (sum<=0)
+        {
+            cout << "MUnfold::SetPriorInput: invalid prior distribution" << endl;
+            return kFALSE;
+        }
+
+        // normalize prior distribution
+        fVEps0 *= 1./sum;
+
+        CopyCol(*hprior, fVEps);
+
+        cout << "SetPriorInput : Prior distribution fVEps = " << endl;
+        cout << "===========================================" << endl;
+        fVEps.Print();
+
+        return kTRUE;
+    }
+
+    // -----------------------------------------------------------------------
+    //
+    // Define prior distribution to be a power law
+    // use input distribution 'hprior' only
+    //           for defining the histogram parameters
+    //
+    Bool_t SetPriorPower(Double_t gamma)
+    {
+        // generate distribution according to a power law
+        //                        dN/dE = E^{-gamma}
+        //  or with y = lo10(E),  E = 10^y :
+        //                        dN/dy = ln10 * 10^{y*(1-gamma)}
+        TH1D hpower(*hprior);
+
+        const UInt_t   nbin = hprior->GetNbinsX();
+        const Double_t xmin = hprior->GetBinLowEdge(1);
+        const Double_t xmax = hprior->GetBinLowEdge(nbin+1);
+
+        cout << "nbin, xmin, xmax = " << nbin << ",  ";
+        cout << xmin << ",  " << xmax << endl;
+
+        TF1* fpow = new TF1("fpow", "pow(10.0, x*(1.0-[0]))", xmin,xmax);
+        fpow->SetParName  (0,"gamma");
+        fpow->SetParameter(0, gamma );
+
+        hpower.FillRandom("fpow", 100000);
+
+        // fill prior distribution
+        CopyCol(fVEps, hpower);
+
+        const Double_t sum = GetMatrixSumCol(fVEps, 0);
+        if (sum <= 0)
+        {
+            cout << "MUnfold::SetPriorPower : invalid prior distribution"  << endl;
+            return kFALSE;
+        }
+
+        // normalize prior distribution
+        fVEps0 *= 1./sum;
+        CopyCol(*hprior, fVEps);
+
+        cout << "SetPriorPower : Prior distribution fVEps = " << endl;
+        cout << "===========================================" << endl;
+        fVEps.Print();
+
+        return kTRUE;
+    }
+
+
+    // -----------------------------------------------------------------------
+    //
+    // Set the initial weight
+    //
+    Bool_t SetInitialWeight(Double_t &weight)
+    {
+        if (weight == 0.0)
+        {
+            TMatrixD v1(fVa, TMatrixD::kTransposeMult, fVacovInv);
+            TMatrixD v2(v1, TMatrixD::kMult, fVa);
+            weight = 1./sqrt(v2(0,0));
+        }
+
+        cout << "MUnfold::SetInitialWeight : Initial Weight = "
+            << weight << endl;
+
+        return kTRUE;
+    }
+
+    // -----------------------------------------------------------------------
+    //
+    // Print the unfolded distribution
+    //
+    void PrintResults()
+    {
+        cout << "PrintResults : Unfolded distribution fResult " << endl;
+        cout << "=============================================" << endl;
+        cout << "val, eparab, eplus, eminus, gcc = "  << endl;
+
+        for (UInt_t i=0; i<fNb; i++)
+        {
+            cout << fResult(i, 0) << " \t";
+            cout << fResult(i, 1) << " \t";
+            cout << fResult(i, 2) << " \t";
+            cout << fResult(i, 3) << " \t";
+            cout << fResult(i, 4) <<  endl;
+        }
+        cout << "Chisquared, NDF, chi2 probability, ixbest = "
+            << fChisq << ",  "
+            << fNdf << ",  " << fProb << ",  " << ixbest << endl;
+
+    }
+
+
+    // -----------------------------------------------------------------------
+    //
+    // Schmelling  : unfolding by minimizing the function Z
+    //               by Gauss-Newton iteration
+    //
+    //               the weights are scanned between
+    //               1.e-5*fWinitial and 1.e5*fWinitial
+    //
+    Bool_t Schmelling(TH1D &hb0)
+    {
+    
+        //======================================================================
+        // copy ideal distribution
+        for (UInt_t i=1; i<=fNb; i++)
+        {
+            fhb0->SetBinContent(i, hb0.GetBinContent(i));
+            fhb0->SetBinError  (i, hb0.GetBinError(i));
+        }
+    
+        //-----------------------------------------------------------------------
+        // Initialization
+        // ==============
+
+        Int_t numGiteration;
+        Int_t MaxGiteration = 1000;
+
+        TMatrixD alpha;
+        alpha.ResizeTo(fNa, 1);
+
+
+        //-----------------------------------------------------------------------
+        // Newton iteration
+        // ================
+
+        Double_t dga2;
+        Double_t dga2old;
+        Double_t EpsG = 1.e-12;
+
+        TMatrixD wZdp_inv(fNa, fNa);
+        TMatrixD d(fNb, 1);
+        TMatrixD p(fNb, 1);
+
+        TMatrixD gamma (fNa, 1);
+        TMatrixD dgamma(fNa, 1);
+
+        Double_t fWinitial;
+        fWinitial = 0.0;
+        SetInitialWeight(fWinitial);
+        // for my example this fWinitial was not good; therefore :
+        fWinitial = 1.0;
+
+        Int_t ix;
+        Double_t xiter;
+
+        //--------   start  scanning weights   --------------------------
+        // if full == kFALSE   only quantities necessary for the Gauss-Newton
+        //                     iteration are calculated in SchmellCore
+        // if full == kTRUE    in addition the unfolded distribution,
+        //                     its covariance matrix and quantities like
+        //                     Chisq, SpurAR, etc. are computed in SchmellCore
+        //Bool_t full;
+        //full = kFALSE;
+        Int_t full;
+
+        dga2 = 1.e20;
+        for (ix=0; ix<Nix; ix++)
+        {
+            xiter = pow(10.0,log10(xmin)+ix*dlogx) * fWinitial;
+
+            //----------   start Gauss-Newton iteration   ----------------------
+            numGiteration = 0;
+
+            // if there was no convergence and the starting gamma was != 0
+            // redo unfolding for the same weight starting with gamma = 0
+            //
+            Int_t gamma0 = 0;
+            while (1)
+	    {
+              if (dga2 > EpsG)
+	      {
+                gamma0 = 1;
+                gamma.Zero();
+	      }
+
+              dga2 = 1.e20;
+
+              while (1)
+              {
+                dga2old = dga2;
+
+                full = 0;
+                SchmellCore(full, xiter, gamma, dgamma, dga2);
+
+                gamma += dgamma;
+
+                //cout << "Schmelling : ix, numGiteration, dga2, dga2old = "
+                //     << ix << ",  " << numGiteration << ",  "
+                //     << dga2 << ",  " << dga2old << endl;
+
+                numGiteration += 1;
+
+                // convergence
+                if (dga2 < EpsG)
+                    break;
+
+                // no convergence
+                if (numGiteration > MaxGiteration)
+                    break;
+
+                // gamma doesn't seem to change any more
+                if (fabs(dga2-dga2old) < EpsG/100.)
+                    break;
+              }
+              //----------   end Gauss-Newton iteration   ------------------------
+              if (dga2<EpsG || gamma0 != 0) break;
+	    }
+
+            // if Gauss-Newton iteration has not converged
+            // go to next weight
+            if (dga2 > EpsG)
+            {
+                cout << "Schmelling : Gauss-Newton iteration has not converged;"
+                    << "   numGiteration = " << numGiteration << endl;
+                cout << "             ix, dga2, dga2old = " << ix << ",  "
+                    << dga2 << ",  " << dga2old << endl;
+                continue;
+            }
+
+            //cout << "Schmelling : Gauss-Newton iteration has converged;" << endl;
+            //cout << "==================================================" << endl;
+            //cout << "             numGiteration = " << numGiteration << endl;
+            //cout << "             ix, dga2 = " << ix << ",  " << dga2 << endl;
+
+            // calculated quantities which will be useful for determining
+            // the best weight (Chisq, SpurAR, ...)
+            //full = kTRUE;
+            full = 1;
+            SchmellCore(full, xiter, gamma, dgamma, dga2);
+
+            // calculate difference between ideal and unfolded distribution
+            Double_t D2bar = 0.0;
+            for (UInt_t i = 0; i<fNb; i++)
+            {
+                Double_t temp = fVb(i,0)-hb0.GetBinContent(i+1,0);
+                D2bar += temp*temp;
+            }
+
+            SpAR(ix)  = SpurAR;
+            SpSig(ix) = SpurSigma;
+            chisq(ix) = Chisq;
+            SecDer(ix) = SecDeriv;
+            ZerDer(ix) = ZerDeriv;
+            Entrop(ix) = Entropy;
+            DAR2(ix)   = DiffAR2;
+            Dsqbar(ix) = D2bar;
+
+        }
+        //----------   end of scanning weights   -------------------------------
+
+        // plots ------------------------------
+        for (ix=0; ix<Nix; ix++)
+        {
+            Double_t xbin = log10(xmin)+ix*dlogx;
+            xiter = pow(10.0,xbin) * fWinitial;
+
+            Int_t bin;
+            bin = hBchisq->FindBin( xbin );
+            hBchisq->SetBinContent(bin,chisq(ix));
+            hBSpAR->SetBinContent(bin,SpAR(ix));
+            hBSpSig->SetBinContent(bin,SpSig(ix)/fSpurVacov);
+            hBSecDeriv->SetBinContent(bin,SecDer(ix));
+            hBZerDeriv->SetBinContent(bin,ZerDer(ix));
+            hBEntropy->SetBinContent(bin,Entrop(ix));
+            hBDAR2->SetBinContent(bin,DAR2(ix));
+            hBD2bar->SetBinContent(bin,Dsqbar(ix));
+
+            if (ix > 0)
+            {
+                Double_t DSpAR = SpAR(ix) - SpAR(ix-1);
+                hBDSpAR->SetBinContent(bin,DSpAR);
+
+                Double_t diff = SpSig(ix) - SpSig(ix-1);
+                Double_t DSpSig = diff;
+                hBDSpSig->SetBinContent(bin, DSpSig/fSpurVacov);
+
+                Double_t DEntrop = Entrop(ix) - Entrop(ix-1);
+                hBDEntropy->SetBinContent(bin,DEntrop);
+
+                Double_t DSecDer = SecDer(ix) - SecDer(ix-1);
+                hBDSecDeriv->SetBinContent(bin,DSecDer);
+
+                Double_t DZerDer = ZerDer(ix) - ZerDer(ix-1);
+                hBDZerDeriv->SetBinContent(bin,DZerDer);
+            }
+        }
+
+        // Select best weight
+        SelectBestWeight();
+
+        if (ixbest < 0.0)
+        {
+            cout << "Schmelling : no solution found; " << endl;
+            return kFALSE;
+        }
+
+        // do the unfolding using the best weight
+        //full = kTRUE;
+
+
+        xiter = pow(10.0,log10(xmin)+ixbest*dlogx) * fWinitial;
+
+        //----------   start Gauss-Newton iteration   ----------------------
+        numGiteration = 0;
+        gamma.Zero();
+        dga2 = 1.e20;
+
+        while (1)
+        {
+            full = 1;
+            SchmellCore(full, xiter, gamma, dgamma, dga2);
+            gamma += dgamma;
+
+            //cout << "Schmelling : sum(dgamma^2) = " << dga2 << endl;
+
+            numGiteration += 1;
+
+            if (numGiteration > MaxGiteration)
+                break;
+
+            if (dga2 < EpsG)
+                break;
+        }
+        //----------   end Gauss-Newton iteration   ------------------------
+
+
+        //-----------------------------------------------------------------------
+        // termination stage
+        // =================
+
+        cout << "Schmelling : best solution found; " << endl;
+        cout << "==================================" << endl;
+        cout << "             xiter, ixbest, numGiteration, Chisq = "
+            << xiter << ",  " << ixbest << ",  "
+            << numGiteration << ",  " << Chisq << endl;
+
+        //------------------------------------
+        //..............................................
+        // put unfolded distribution into fResult
+        //     fResult(i,0)   value in bin i
+        //     fResult(i,1)   error of value in bin i
+
+        fNdf = SpurAR;
+        fChisq = Chisq;
+
+        for (UInt_t i=0; i<fNa; i++)
+	{
+          fChi2(i,0) = Chi2(i,0);
+	}
+
+        UInt_t iNdf   = (UInt_t) (fNdf+0.5);
+        fProb = iNdf>0 ? TMath::Prob(fChisq, iNdf) : 0;
+
+        fResult.ResizeTo(fNb, 5);
+        for (UInt_t i=0; i<fNb; i++)
+        {
+            fResult(i, 0) = fVb(i,0);
+            fResult(i, 1) = sqrt(fVbcov(i,i));
+            fResult(i, 2) = 0.0;
+            fResult(i, 3) = 0.0;
+            fResult(i, 4) = 1.0; 
+	}
+
+        //--------------------------------------------------------
+
+        cout << "Schmelling : gamma = " << endl;
+        for (UInt_t i=0; i<fNa; i++)
+            cout << gamma(i,0) << " \t";
+        cout << endl;
+
+        return kTRUE;
+    }
+
+
+
+
+    // -----------------------------------------------------------------------
+    //
+    // SchmellCore     main part of Schmellings calculations
+    //
+    void SchmellCore(Int_t full, Double_t &xiter, TMatrixD &gamma,
+                     TMatrixD &dgamma, Double_t &dga2)
+    {
+        Double_t norm;
+        TMatrixD wZdp_inv(fNa, fNa);
+        TMatrixD d(fNb, 1);
+        TMatrixD p(fNb, 1);
+
+        //--------------------------------------------------------
+        //--      determine the probability vector p
+
+
+        TMatrixD v3(gamma, TMatrixD::kTransposeMult, fMigrat);
+        TMatrixD v4(TMatrixD::kTransposed, v3);
+        d = v4;
+        Double_t dmax  = -1.e10;
+        for (UInt_t j=0; j<fNb; j++)
+            if (d(j,0)>dmax)
+                dmax = d(j,0);
+
+        Double_t psum = 0.0;
+        for (UInt_t j=0; j<fNb; j++)
+        {
+            d(j,0) -= dmax;
+            p(j,0)  = fVEps0(j)*exp(xiter*d(j,0));
+            psum += p(j,0);
+        }
+
+        p *= 1.0/psum;
+
+        //--      get the vector alpha
+
+        TMatrixD alpha(fMigrat, TMatrixD::kMult, p);
+
+        //--      determine the current normalization
+
+        TMatrixD v2   (alpha, TMatrixD::kTransposeMult, fVacovInv);
+        TMatrixD normb(v2,    TMatrixD::kMult, alpha);
+
+        TMatrixD normc(v2,    TMatrixD::kMult, fVa);
+
+        norm  = normc(0,0)/normb(0,0);
+
+        //--------------------------------------------------------
+        //--      determine the scaled slope vector s and Hessian H
+
+        TMatrixD Zp(fNa,1);
+        for (UInt_t i=0; i<fNa; i++)
+        {
+            Zp(i,0) = norm*alpha(i,0) - fVa(i,0);
+            for (UInt_t k=0; k<fNa; k++)
+                Zp(i,0) += gamma(k,0)*fVacov(k,i);
+        }
+
+
+        TMatrixD Q  (fNa, fNa);
+        TMatrixD wZdp(fNa, fNa);
+        for (UInt_t i=0; i<fNa; i++)
+        {
+            for (UInt_t j=0; j<fNa; j++)
+            {
+                Q(i,j) = - alpha(i,0)*alpha(j,0);
+                for (UInt_t k=0; k<fNb; k++)
+                    Q(i,j) += fMigrat(i,k)*fMigrat(j,k)*p(k,0);
+                wZdp(i,j) = xiter*norm*Q(i,j) + fVacov(i,j);
+            }
+        }
+
+        //--      invert H and calculate the next Newton step
+
+        Double_t determ = 1.0;
+        wZdp_inv = wZdp;
+        wZdp_inv.Invert(&determ);
+
+        if(determ == 0.0)
+        {
+            cout << "SchmellCore: matrix inversion for H failed" << endl;
+            return;
+        }
+
+
+        dga2 = 0.0;
+        for (UInt_t i=0; i<fNa; i++)
+        {
+            dgamma(i,0) = 0.0;
+            for (UInt_t j=0; j<fNa; j++)
+                dgamma(i,0) -= wZdp_inv(i,j)*Zp(j,0);
+            dga2 += dgamma(i,0)*dgamma(i,0);
+        }
+
+        if (full == 0)
+            return;
+
+        //--------------------------------------------------------
+        //--      determine chi2 and dNdf (#measurements ignored)
+        Double_t dNdf = 0;
+        for (UInt_t i=0; i<fNa; i++)
+        {
+            Chi2(i,0) = 0;
+            for (UInt_t j=0; j<fNa; j++)
+            {
+                Chi2(i,0) += fVacov(i,j) * gamma(i,0) * gamma(j,0);
+                dNdf       += fVacov(i,j) * wZdp_inv(j,i);
+            }
+        }
+        Chisq = GetMatrixSumCol(Chi2, 0);
+        SpurAR = fNa - dNdf;
+
+        //-----------------------------------------------------
+        // calculate the norm |AR - AR+|**2
+
+        TMatrixD AR(fNa, fNa);
+        DiffAR2 = 0.0;
+        for (UInt_t i=0; i<fNa; i++)
+        {
+            for (UInt_t j=0; j<fNa; j++)
+            {
+                AR(i,j) = 0.0;
+                for (UInt_t k=0; k<fNa; k++)
+                    AR(i,j) +=  fVacov(i,k) * wZdp_inv(k,j);
+                DiffAR2 += AR(i,j) * AR(i,j);
+            }
+        }
+
+        //--------------------------------------------------------
+        //--      fill distribution b(*)
+        fVb = p;
+        fVb *= norm;
+
+        //--      determine the covariance matrix of b (very expensive)
+
+        TMatrixD T(fNb,fNa);
+        for (UInt_t i=0; i<fNb; i++)
+        {
+            for (UInt_t j=0; j<fNa; j++)
+            {
+                T(i,j) = 0.0;
+                for (UInt_t k=0; k<fNa; k++)
+                    T(i,j) += xiter*wZdp_inv(k,j)*(fMigrat(k,i)-alpha(k,0))*p(i,0);
+            }
+        }
+
+        SpurSigma = CalcSpurSigma(T, norm);
+
+        //--------------------------------------------------------
+
+        //-----------------------------------------------------
+        // calculate the second derivative squared
+
+        SecDeriv = 0;
+        for (UInt_t j=1; j<(fNb-1); j++)
+        {
+            Double_t temp =
+                + 2.0*(fVb(j+1,0)-fVb(j,0)) / (fVb(j+1,0)+fVb(j,0))
+                - 2.0*(fVb(j,0)-fVb(j-1,0)) / (fVb(j,0)+fVb(j-1,0));
+            SecDeriv += temp*temp;
+        }
+
+        ZerDeriv = 0;
+        for (UInt_t j=0; j<fNb; j++)
+            ZerDeriv += fVb(j,0) * fVb(j,0);
+
+        //-----------------------------------------------------
+        // calculate the entropy
+        Entropy = 0;
+        for (UInt_t j=0; j<fNb; j++)
+            if (p(j,0) > 0.0)
+                Entropy += p(j,0) * log( p(j,0) );
+
+        //--------------------------------------------------------
+    }
+
+
+    // -----------------------------------------------------------------------
+    //
+    // Smooth migration matrix
+    //              by fitting a function to the migration matrix
+    //
+    Bool_t SmoothMigrationMatrix(TH2D &hmigorig)
+    {
+        // copy histograms into matrices; the matrices will be used in fcnSmooth
+        // ------------------------
+
+        cout << "MUnfold::SmoothMigrationMatrix : fNa, fNb = " << fNa << ",  " << fNb << endl;
+
+        cout << "MUnfold::SmoothMigrationMatrix:   fMigOrig = "  << endl;
+        cout << "========================================"  << endl;
+        for (UInt_t i=0; i<fNa; i++)
+        {
+            for (UInt_t j=0; j<fNb; j++)
+            {
+                fMigOrig(i, j)     = hmigorig.GetBinContent(i+1, j+1);
+                cout << fMigOrig(i, j) << " \t";
+            }
+            cout << endl;
+        }
+
+        // ------------------------
+
+        cout << "MUnfold::SmoothMigrationMatrix :   fMigOrigerr2 = " << endl;
+        cout << "=============================================" << endl;
+        for (UInt_t i=0; i<fNa; i++)
+        {
+            for (UInt_t j=0; j<fNb; j++)
+            {
+                fMigOrigerr2(i, j) =   hmigorig.GetBinError(i+1, j+1)
+                    * hmigorig.GetBinError(i+1, j+1);
+
+                cout << fMigOrigerr2(i, j) << " \t";
+            }
+            cout << endl;
+        }
+
+        // ------------------------
+        // the number of free parameters (npar) is equal to 6:
+        //     a0mean, a1mean, a2mean     
+        //     <log10(Eest)>    = a0 + a1*log10(Etrue) + a2*SQR(log10(Etrue))
+        //                                                     + log10(Etrue)  
+        //     b0RMS,  b1RMS, b2RMS      
+        //     RMS(log10(Eest)) = b0 + b1*log10(Etrue) + b2*SQR(log10(Etrue))
+        // 
+        UInt_t npar = 6;
+
+        if (npar > 20)
+        {
+            cout << "MUnfold::SmoothMigrationMatrix : too many parameters,  npar = "
+                << npar << endl;
+            return kFALSE;
+        }
+
+
+        //..............................................
+        // Find reasonable starting values for a0, a1 and b0, b1
+
+        Double_t xbar   = 0.0;
+        Double_t xxbar  = 0.0;
+
+        Double_t ybarm  = 0.0;
+        Double_t xybarm = 0.0;
+
+        Double_t ybarR  = 0.0;
+        Double_t xybarR = 0.0;
+
+        Double_t Sum = 0.0;
+        for (UInt_t j=0; j<fNb; j++)
+        {
+            Double_t x = (double)j + 0.5;
+
+            Double_t meany = 0.0;
+            Double_t RMSy  = 0.0;
+            Double_t sum   = 0.0;
+            for (UInt_t i=0; i<fNa; i++)
+            {
+                Double_t y = (double)i + 0.5;
+                meany +=   y * fMigOrig(i, j);
+                RMSy  += y*y * fMigOrig(i, j);
+                sum   +=       fMigOrig(i, j);
+            }
+            if (sum > 0.0)
+            {
+                meany  = meany / sum;
+                RMSy   =  RMSy / sum  - meany*meany;
+                RMSy = sqrt(RMSy);
+
+                Sum += sum;
+                xbar  +=   x * sum;
+                xxbar += x*x * sum;
+
+                ybarm  +=   meany * sum;
+                xybarm += x*meany * sum;
+
+                ybarR  +=   RMSy  * sum;
+                xybarR += x*RMSy  * sum;
+            }
+        }
+
+        if (Sum > 0.0)
+        {
+            xbar   /= Sum;
+            xxbar  /= Sum;
+
+            ybarm  /= Sum;
+            xybarm /= Sum;
+
+            ybarR  /= Sum;
+            xybarR /= Sum;
+        }
+
+        Double_t a1start = (xybarm - xbar*ybarm) / (xxbar - xbar*xbar);
+        Double_t a0start = ybarm - a1start*xbar;
+        a1start = a1start - 1.0;
+
+        Double_t b1start = (xybarR - xbar*ybarR) / (xxbar - xbar*xbar);
+        Double_t b0start = ybarR - b1start*xbar;
+
+        cout << "MUnfold::SmoothMigrationMatrix : " << endl;
+        cout << "============================" << endl;
+        cout << "a0start, a1start = " << a0start << ",  " << a1start << endl;
+        cout << "b0start, b1start = " << b0start << ",  " << b1start << endl;
+
+        //..............................................
+        // Set starting values and step sizes for parameters
+
+        char name[20][100];
+        Double_t vinit[20];
+        Double_t  step[20];
+        Double_t limlo[20];
+        Double_t limup[20];
+        Int_t    fix[20];
+
+        sprintf(&name[0][0], "a0mean");
+        vinit[0] = a0start;
+        //vinit[0] = 1.0;
+        step[0]  = 0.1;
+        limlo[0] = 0.0;
+        limup[0] = 0.0;
+        fix[0]   = 0;
+
+        sprintf(&name[1][0], "a1mean");
+        vinit[1] = a1start;
+        //vinit[1] = 0.0;
+        step[1]  = 0.1;
+        limlo[1] = 0.0;
+        limup[1] = 0.0;
+        fix[1]   = 0;
+
+        sprintf(&name[2][0], "a2mean");
+        vinit[2] = 0.0;
+        step[2]  = 0.1;
+        limlo[2] = 0.0;
+        limup[2] = 0.0;
+        fix[2]   = 0;
+
+        sprintf(&name[3][0], "b0RMS");
+        vinit[3] = b0start;
+          //vinit[3] = 0.8;
+        step[3]  = 0.1;
+        limlo[3] = 1.e-20;
+        limup[3] = 10.0;
+        fix[3]   = 0;
+
+        sprintf(&name[4][0], "b1RMS");
+        vinit[4] = b1start;
+        //vinit[4] = 0.0;
+        step[4]  = 0.1;
+        limlo[4] = 0.0;
+        limup[4] = 0.0;
+        fix[4]   = 0;
+
+        sprintf(&name[5][0], "b2RMS");
+        vinit[5] = 0.0;
+        step[5]  = 0.1;
+        limlo[5] = 0.0;
+        limup[5] = 0.0;
+        fix[5]   = 0;
+
+
+        if ( CallMinuit(fcnSmooth, npar, name, vinit,
+                        step, limlo, limup, fix) )
+        {
+
+            // ------------------------
+            // fMigrat is the migration matrix to be used in the unfolding;
+            // fMigrat, as set by the constructor, is overwritten
+            //          by the smoothed migration matrix
+
+            for (UInt_t i=0; i<fNa; i++)
+                for (UInt_t j=0; j<fNb; j++)
+                    fMigrat(i, j) = fMigSmoo(i, j);
+
+            // ------------------------
+
+            for (UInt_t i=0; i<fNa; i++)
+                for (UInt_t j=0; j<fNb; j++)
+                    fMigraterr2(i, j) = fMigSmooerr2(i, j);
+
+
+            // normalize
+            for (UInt_t j=0; j<fNb; j++)
+            {
+                Double_t sum = 0.0;
+                for (UInt_t i=0; i<fNa; i++)
+                    sum += fMigrat(i, j);
+
+                //cout << "SmoothMigrationMatrix : normalization fMigrat; j, sum + "
+                //     << j << ",  " << sum << endl;
+
+                if (sum == 0.0)
+                    continue;
+
+                for (UInt_t i=0; i<fNa; i++)
+                {
+                    fMigrat(i, j)     /= sum;
+                    fMigraterr2(i, j) /= (sum*sum);
+                }
+            }
+
+            cout << "MUnfold::SmoothMigrationMatrix :   fMigrat = "  << endl;
+            cout << "========================================"  << endl;
+            for (UInt_t i=0; i<fNa; i++)
+            {
+                for (UInt_t j=0; j<fNb; j++)
+                    cout << fMigrat(i, j) << " \t";
+                cout << endl;
+            }
+
+            cout << "MUnfold::SmoothMigrationMatrix :   fMigraterr2 = "  << endl;
+            cout << "============================================"  << endl;
+            for (UInt_t i=0; i<fNa; i++)
+            {
+                for (UInt_t j=0; j<fNb; j++)
+                    cout << fMigraterr2(i, j) << " \t";
+                cout << endl;
+            }
+
+            // ------------------------
+
+            return kTRUE;
+        }
+
+        return kFALSE;
+    }
+
+    // -----------------------------------------------------------------------
+    //
+    // Prepare the call to MINUIT for the minimization of the function
+    //         f = chi2*w/2 + reg, where reg is the regularization term
+    //         reg is the sum the squared 2nd derivatives
+    //                        of the unfolded distribution
+    //
+    // the corresponding fcn routine is 'fcnTikhonov2'
+    //
+    Bool_t Tikhonov2(TH1D &hb0)
+    {
+        // the number of free parameters (npar) is equal to
+        // the number of bins (fNb) of the unfolded distribution minus 1,
+        // because of the constraint that the total number of events
+        // is fixed
+        UInt_t npar = fNb-1;
+
+        if (npar > 20)
+        {
+            cout << "MUnfold::Tikhonov2 : too many parameters,  npar = "
+                << npar << ",  fNb = " << fNb << endl;
+            return kFALSE;
+        }
+
+        // copy ideal distribution
+        
+        for (UInt_t i=1; i<=fNb; i++)
+        {
+            fhb0->SetBinContent(i, hb0.GetBinContent(i));
+            fhb0->SetBinError  (i, hb0.GetBinError(i));
+        }
+        
+
+        //---   start w loop -----------------------------------
+        Int_t ix;
+        Double_t xiter;
+
+        for (ix=0; ix<Nix; ix++)
+        {
+            fW = pow(10.0,log10(xmin)+ix*dlogx);
+
+            //..............................................
+            // Set starting values and step sizes for parameters
+
+            char name[20][100];
+            Double_t vinit[20];
+            Double_t  step[20];
+            Double_t limlo[20];
+            Double_t limup[20];
+            Int_t    fix[20];
+
+            for (UInt_t i=0; i<npar; i++)
+            {
+                sprintf(&name[i][0], "p%d", i+1);
+                vinit[i] = fVEps0(i);
+                step[i]  = fVEps0(i)/10;
+
+                // lower and upper limits  (limlo=limup=0: no limits)
+                //limlo[i] = 1.e-20;
+                limlo[i] = -1.0;
+                limup[i] = 1.0;
+                fix[i]   = 0;
+            }
+
+            // calculate solution for the weight fW
+            // flag non-convergence by chisq(ix) = 0.0
+            chisq(ix) = 0.0;
+            if ( CallMinuit(fcnTikhonov2, npar, name, vinit,
+                            step, limlo, limup, fix) )
+            {
+                // calculate difference between ideal and unfolded distribution
+                Double_t D2bar = 0.0;
+                for (UInt_t i = 0; i<fNb; i++)
+                {
+                    Double_t temp = fVb(i,0)-hb0.GetBinContent(i+1,0);
+                    D2bar += temp*temp;
+                }
+
+                SpAR(ix)   = SpurAR;
+                SpSig(ix)  = SpurSigma;
+                chisq(ix)  = Chisq;
+                SecDer(ix) = SecDeriv;
+                ZerDer(ix) = ZerDeriv;
+                Entrop(ix) = Entropy;
+                DAR2(ix)   = DiffAR2;
+                Dsqbar(ix) = D2bar;
+            }
+        }
+
+
+        // plots ------------------------------
+        for (ix=0; ix<Nix; ix++)
+        {
+            // test whether minimization has converged
+            if (chisq(ix) != 0.0)
+            {
+                xiter = pow(10.0,log10(xmin)+ix*dlogx);
+
+                Int_t bin;
+                bin = hBchisq->FindBin( log10(xiter) );
+                hBchisq->SetBinContent(bin,chisq(ix));
+
+                //hBSpAR->SetBinContent(bin,SpAR(ix));
+                hBSpAR->SetBinContent(bin,0.0);
+
+                hBSpSig->SetBinContent(bin,SpSig(ix)/fSpurVacov);
+                hBSecDeriv->SetBinContent(bin,SecDer(ix));
+                hBZerDeriv->SetBinContent(bin,ZerDer(ix));
+                hBEntropy->SetBinContent(bin,Entrop(ix));
+
+                //hBDAR2->SetBinContent(bin,DAR2(ix));
+                hBDAR2->SetBinContent(bin,0.0);
+
+                hBD2bar->SetBinContent(bin,Dsqbar(ix));
+
+                if (ix > 0)
+                {
+                    //Double_t DSpAR = SpAR(ix) - SpAR(ix-1);
+                    //hBDSpAR->SetBinContent(bin,DSpAR);
+
+                    Double_t diff = SpSig(ix) - SpSig(ix-1);
+                    Double_t DSpSig = diff;
+                    hBDSpSig->SetBinContent(bin, DSpSig/fSpurVacov);
+
+                    Double_t DEntrop = Entrop(ix) - Entrop(ix-1);
+                    hBDEntropy->SetBinContent(bin,DEntrop);
+
+                    Double_t DSecDer = SecDer(ix) - SecDer(ix-1);
+                    hBDSecDeriv->SetBinContent(bin,DSecDer);
+
+                    Double_t DZerDer = ZerDer(ix) - ZerDer(ix-1);
+                    hBDZerDeriv->SetBinContent(bin,DZerDer);
+                }
+            }
+        }
+
+
+        //---   end w loop -----------------------------------
+
+        // Select best weight
+        SelectBestWeight();
+
+        cout << " Tikhonov2 : after SelectBestWeight" << endl;
+
+        if (ixbest < 0.0)
+        {
+            cout << "Tikhonov2 : no result found; " << endl;
+            return kFALSE;
+        }
+
+        cout << "Tikhonov2 : best result found; " << endl;
+        cout << "===============================" << endl;
+        cout << "           ixbest = " << ixbest << endl;
+
+
+        // do a final unfolding using the best weight
+
+        fW = pow(10.0,log10(xmin)+ixbest*dlogx);
+
+        //..............................................
+        // Set starting values and step sizes for parameters
+
+        char name[20][100];
+        Double_t vinit[20];
+        Double_t  step[20];
+        Double_t limlo[20];
+        Double_t limup[20];
+        Int_t    fix[20];
+
+        for (UInt_t i=0; i<npar; i++)
+        {
+            sprintf(&name[i][0], "p%d", i+1);
+            vinit[i] = fVEps0(i);
+            step[i]  = fVEps0(i)/10;
+
+            // lower and upper limits  (limlo=limup=0: no limits)
+            //limlo[i] = 1.e-20;
+            limlo[i] = -1.0;
+            limup[i] = 1.0;
+            fix[i]   = 0;
+        }
+
+        // calculate solution for the best weight
+        CallMinuit(fcnTikhonov2, npar, name, vinit,
+                   step, limlo, limup, fix);
+
+
+        cout << "Tikhonov : Values for best weight " << endl;
+        cout << "==================================" << endl;
+        cout << "fW, ixbest, Chisq, SpurAR, SpurSigma, SecDeriv, ZerDeriv, Entrop, DiffAR2, D2bar = " << endl;
+        cout << "      " << fW << ",  " << ixbest << ",  "
+            << Chisq << ",  " << SpurAR << ",  "
+            << SpurSigma << ",  " << SecDeriv << ",  " << ZerDeriv << ",  "
+            << Entropy << ",  " << DiffAR2 << ",  "
+            << Dsqbar(ixbest) << endl;
+
+        return kTRUE;
+
+    }
+
+
+    // -----------------------------------------------------------------------
+    //
+    // Bertero :
+    //
+    // the unfolded distribution is calculated iteratively;
+    // the number of iterations after which the iteration is stopped
+    //            corresponds to the 'weight' in other methods
+    // a small number of iterations corresponds to strong regularization
+    // a high number to no regularization
+    //
+    // see : M.Bertero, INFN/TC-88/2 (1988)
+    //       V.B.Anykeyev et al., NIM A303 (1991) 350
+    //
+    Bool_t Bertero(TH1D &hb0)
+    {
+        // copy ideal distribution
+        
+        for (UInt_t i=1; i<=fNb; i++)
+        {
+            fhb0->SetBinContent(i, hb0.GetBinContent(i));
+            fhb0->SetBinError  (i, hb0.GetBinError(i));
+        }
+        
+
+        TMatrixD bold(fNb, 1);
+        bold.Zero();
+
+        //----------------------------------------------------------
+
+        Double_t db2 = 1.e20;
+
+
+        TMatrixD aminusaest(fNa, 1);
+
+        //-------   scan number of iterations   -----------------
+
+        Int_t ix;
+
+        for (ix=0; ix<Nix; ix++)
+        {
+            Double_t xiter = pow(10.0,log10(xmin)+ix*dlogx);
+
+            // calculate solution for the iteration number xiter
+            BertCore(xiter);
+
+            // calculate difference between ideal and unfolded distribution
+            Double_t D2bar = 0.0;
+            for (UInt_t i = 0; i<fNb; i++)
+            {
+                Double_t temp = fVb(i,0)-hb0.GetBinContent(i+1,0);
+                D2bar += temp*temp;
+            }
+
+            SpAR(ix)   = SpurAR;
+            SpSig(ix)  = SpurSigma;
+            chisq(ix)  = Chisq;
+            SecDer(ix) = SecDeriv;
+            ZerDer(ix) = ZerDeriv;
+            Entrop(ix) = Entropy;
+            DAR2(ix)   = DiffAR2;
+            Dsqbar(ix) = D2bar;
+
+            db2 = 0.0;
+            for (UInt_t i = 0; i<fNb; i++)
+            {
+                Double_t temp = fVb(i,0)-bold(i,0);
+                db2 += temp*temp;
+            }
+            bold = fVb;
+
+            //if (db2 < Epsdb2) break;
+
+        }
+
+        // plots ------------------------------
+        for (ix=0; ix<Nix; ix++)
+        {
+            Double_t xiter = pow(10.0,log10(xmin)+ix*dlogx);
+
+            Int_t bin;
+            bin = hBchisq->FindBin( log10(xiter) );
+            hBchisq->SetBinContent(bin,chisq(ix));
+            hBSpAR->SetBinContent(bin,SpAR(ix));
+            hBSpSig->SetBinContent(bin,SpSig(ix)/fSpurVacov);
+            hBSecDeriv->SetBinContent(bin,SecDer(ix));
+            hBZerDeriv->SetBinContent(bin,ZerDer(ix));
+            hBEntropy->SetBinContent(bin,Entrop(ix));
+            hBDAR2->SetBinContent(bin,DAR2(ix));
+            hBD2bar->SetBinContent(bin,Dsqbar(ix));
+
+            if (ix > 0)
+            {
+                Double_t DSpAR = SpAR(ix) - SpAR(ix-1);
+                hBDSpAR->SetBinContent(bin,DSpAR);
+
+                Double_t diff = SpSig(ix) - SpSig(ix-1);
+                Double_t DSpSig = diff;
+                hBDSpSig->SetBinContent(bin, DSpSig/fSpurVacov);
+
+                Double_t DEntrop = Entrop(ix) - Entrop(ix-1);
+                hBDEntropy->SetBinContent(bin,DEntrop);
+
+                Double_t DSecDer = SecDer(ix) - SecDer(ix-1);
+                hBDSecDeriv->SetBinContent(bin,DSecDer);
+
+                Double_t DZerDer = ZerDer(ix) - ZerDer(ix-1);
+                hBDZerDeriv->SetBinContent(bin,DZerDer);
+            }
+        }
+        //-------   end of scan of number of iterations   -----------------
+
+        // Select best weight
+        SelectBestWeight();
+
+
+        if (ixbest < 0.0)
+        {
+            cout << "Bertero : weight iteration has NOT converged; " << endl;
+            return kFALSE;
+        }
+
+        cout << "Bertero : weight iteration has converged; " << endl;
+        cout << "            ixbest = " << ixbest << endl;
+
+
+        // do a final unfolding using the best weight
+
+        // calculate solution for the iteration number xiter
+        Double_t xiter = pow(10.0,log10(xmin)+ixbest*dlogx);
+        BertCore(xiter);
+
+        cout << "Bertero : Values for best weight " << endl;
+        cout << "=================================" << endl;
+        cout << "fW, ixbest, Chisq, SpurAR, SpurSigma, SecDeriv, ZerDeriv, Entrop, DiffAR2, D2bar = " << endl;
+        cout << "      " << fW << ",  " << ixbest << ",  "
+            << Chisq << ",  " << SpurAR << ",  "
+            << SpurSigma << ",  " << SecDeriv << ",  " << ZerDeriv << ",  "
+            << Entropy << ",  " << DiffAR2 << ",  "
+            << Dsqbar(ixbest) << endl;
+
+        //----------------
+
+        fNdf   = SpurAR;
+        fChisq = Chisq;
+
+        for (UInt_t i=0; i<fNa; i++)
+	{
+          fChi2(i,0) = Chi2(i,0);
+	}
+
+        UInt_t iNdf   = (UInt_t) (fNdf+0.5);
+        fProb = iNdf>0 ? TMath::Prob(fChisq, iNdf) : 0;
+
+
+        fResult.ResizeTo(fNb, 5);
+        for (UInt_t i=0; i<fNb; i++)
+        {
+            fResult(i, 0) = fVb(i,0);
+            fResult(i, 1) = sqrt(fVbcov(i,i));
+            fResult(i, 2) = 0.0;
+            fResult(i, 3) = 0.0;
+            fResult(i, 4) = 1.0;
+        }
+
+        return kTRUE;
+    }
+
+    // -----------------------------------------------------------------------
+    //
+    // main part of Bertero's calculations
+    //
+    Bool_t BertCore(Double_t &xiter)
+    {
+        // ignore eigen values which are smaller than EpsLambda
+        TMatrixD G_inv(fNa, fNa);
+        TMatrixD Gtil_inv(fNa, fNa);
+        TMatrixD atil(fNb, fNa);
+        TMatrixD aminusaest(fNa, 1);
+
+        G_inv.Zero();
+        Gtil_inv.Zero();
+        SpurAR = 0.0;
+
+        // -----   loop over eigen values   ------------------
+        // calculate the approximate inverse of the matrix G
+        //cout << "flaml = " << endl;
+
+        UInt_t flagstart = 2;
+        Double_t flaml=0;
+
+        for (UInt_t l=0; l<fNa; l++)
+        {
+            if (EigenValue(l) < EpsLambda)
+                continue;
+
+            switch (flagstart)
+            {
+            case 1 :
+                // This is the expression for f(lambda) if the initial C^(0)
+                // is chosen to be zero
+                flaml = 1.0 - pow(1.0-tau*EigenValue(l),xiter);
+                break;
+
+            case 2 :
+                // This is the expression for f(lambda) if the initial C^(0)
+                // is chosen to be equal to the measured distribution
+                flaml =           1.0 - pow(1.0-tau*EigenValue(l),xiter)
+                    + EigenValue(l) * pow(1.0-tau*EigenValue(l),xiter);
+                break;
+            }
+
+            //  cout << flaml << ",  ";
+
+            for (UInt_t m=0; m<fNa; m++)
+            {
+                for (UInt_t n=0; n<fNa; n++)
+                {
+                    G_inv(m,n)    += 1.0  /EigenValue(l) * Eigen(m,l)*Eigen(n,l);
+                    Gtil_inv(m,n) += flaml/EigenValue(l) * Eigen(m,l)*Eigen(n,l);
+                }
+            }
+            SpurAR += flaml;
+        }
+        //cout << endl;
+
+
+        //cout << "Gtil_inv =" << endl;
+        //for (Int_t m=0; m<fNa; m++)
+        //{
+        //  for (Int_t n=0; n<fNa; n++)
+        //  {
+        //    cout << Gtil_inv(m,n) << ",  ";
+        //  }
+        //  cout << endl;
+        //}
+
+        //-----------------------------------------------------
+        // calculate the unfolded distribution b
+        TMatrixD v2(fMigrat, TMatrixD::kTransposeMult, Gtil_inv);
+        atil = v2;
+        TMatrixD v4(atil, TMatrixD::kMult, fVa);
+        fVb = v4;
+
+        //-----------------------------------------------------
+        // calculate AR and AR+
+        TMatrixD AR(v2, TMatrixD::kMult, fMigrat);
+
+        TMatrixD v3(fMigrat, TMatrixD::kTransposeMult, G_inv);
+        TMatrixD ARplus(v3, TMatrixD::kMult, fMigrat);
+
+
+        //-----------------------------------------------------
+        // calculate the norm |AR - AR+|**2
+
+        DiffAR2 = 0.0;
+        for (UInt_t j=0; j<fNb; j++)
+        {
+            for (UInt_t k=0; k<fNb; k++)
+            {
+                Double_t tempo = AR(j,k) - ARplus(j,k);
+                DiffAR2       += tempo*tempo;
+            }
+        }
+
+        //-----------------------------------------------------
+        // calculate the second derivative squared
+
+        SecDeriv = 0;
+        for (UInt_t j=1; j<(fNb-1); j++)
+        {
+            // temp = ( 2.0*fVb(j,0)-fVb(j-1,0)-fVb(j+1,0) ) / ( 2.0*fVb(j,0) );
+            Double_t temp =    2.0*(fVb(j+1,0)-fVb(j,0)) / (fVb(j+1,0)+fVb(j,0))
+                - 2.0*(fVb(j,0)-fVb(j-1,0)) / (fVb(j,0)+fVb(j-1,0));
+            SecDeriv += temp*temp;
+        }
+
+        ZerDeriv = 0;
+        for (UInt_t j=0; j<fNb; j++)
+            ZerDeriv += fVb(j,0) * fVb(j,0);
+
+        //-----------------------------------------------------
+        // calculate the entropy
+
+        Double_t sumb = 0.0;
+        for (UInt_t j=0; j<fNb; j++)
+            sumb += fVb(j,0);
+
+        TMatrixD p(fNb,1);
+        p = fVb;
+        if (sumb > 0.0)
+            p *= 1.0/sumb;
+
+        Entropy = 0;
+        for (UInt_t j=0; j<fNb; j++)
+            if (p(j,0) > 0.0)
+                Entropy += p(j,0) * log( p(j,0) );
+
+        //-----------------------------------------------------
+
+        TMatrixD Gb(fMigrat, TMatrixD::kMult, fVb);
+        aminusaest = fVa;
+        aminusaest -= Gb;
+    
+        TMatrixD v1(1,fNa);
+        for (UInt_t i=0; i<fNa; i++)
+        {
+            v1(0,i) = 0.0;
+            for (UInt_t j=0; j<fNa; j++)
+                v1(0,i) += aminusaest(j,0) * fVacovInv(j,i) ;
+        }
+
+        //-----------------------------------------------------
+        // calculate error matrix fVbcov of unfolded distribution
+        SpurSigma = CalcSpurSigma(atil);
+
+        //-----------------------------------------------------
+        // calculate the chi squared
+        for (UInt_t i = 0; i<fNa; i++)
+            Chi2(i,0) = v1(0,i) * aminusaest(i,0);
+
+        Chisq = GetMatrixSumCol(Chi2,0);
+        return kTRUE;
+    }
+
+
+    // -----------------------------------------------------------------------
+    //
+    // Calculate the matrix G = M * M(transposed)
+    //           and its eigen values and eigen vectors
+    //
+    Bool_t CalculateG()
+    {
+        // Calculate matrix G = M*M(transposed)     (M = migration matrix)
+        //           the matrix Eigen of the eigen vectors of G
+        //           the vector EigenValues of the eigen values of G
+        //           the parameter tau = 1/lambda_max
+        //
+        TMatrixD v5(TMatrixD::kTransposed, fMigrat);
+        //TMatrixD G(fMigrat, TMatrixD::kMult, v5);
+        G.Mult(fMigrat, v5);
+
+        Eigen = G.EigenVectors(EigenValue);
+
+        RankG = 0.0;
+        for (UInt_t l=0; l<fNa; l++)
+        {
+            if (EigenValue(l) < EpsLambda) continue;
+            RankG += 1.0;
+        }
+
+        tau = 1.0 / EigenValue(0);
+
+        //  cout << "eigen values : " << endl;
+        //  for (Int_t i=0; i<fNa; i++)
+        //  {
+        //    cout << EigenValue(i) << ",  ";
+        //  }
+        //  cout << endl;
+
+        //cout << "eigen vectors : " << endl;
+        //for (Int_t i=0; i<fNa; i++)
+        //{
+        //  cout << "               vector " << i << endl;
+        //  for (Int_t j=0; j<fNa; j++)
+        //  {
+        //    cout << Eigen(j,i) << ",  ";
+        //  }
+        //  cout << endl;
+        //}
+        //cout << endl;
+
+        //cout << "G =" << endl;
+        //for (Int_t m=0; m<fNa; m++)
+        //{
+        //  for (Int_t n=0; n<fNa; n++)
+        //  {
+        //    cout << G(m,n) << ",  ";
+        //  }
+        //  cout << endl;
+        //}
+
+        return kTRUE;
+    }
+
+    // -----------------------------------------------------------------------
+    //
+    // Select the best weight
+    //
+    Bool_t SelectBestWeight()
+    {
+        //-------------------------------
+        // select 'best' weight according to some criterion
+
+        Int_t ix;
+
+        Double_t DiffSpSigmax = -1.e10;
+        Int_t    ixDiffSpSigmax = -1;
+
+        Double_t DiffSigpointsmin = 1.e10;
+        Int_t    ixDiffSigpointsmin = -1;
+
+        Double_t DiffRankGmin = 1.e10;
+        Int_t    ixDiffRankGmin = -1;
+
+        Double_t D2barmin = 1.e10;
+        Int_t    ixD2barmin = -1;
+
+        Double_t DiffSpSig1min = 1.e10;
+        Int_t    ixDiffSpSig1min = -1;
+
+
+        Int_t ixmax = -1;
+
+        // first loop over all weights :
+        //       find smallest chi2
+        Double_t chisqmin = 1.e20;
+        for (ix=0; ix<Nix; ix++)
+        {
+            // consider only weights for which
+            //  - unfolding was successful
+            if (chisq(ix) != 0.0)
+            {
+                if (chisq(ix) < chisqmin)
+                    chisqmin = chisq(ix);
+            }
+        }
+        Double_t chisq0 = chisqmin > fVapoints ? chisqmin : fVapoints/2.0;
+
+        // second loop over all weights :
+        //        consider only weights for which chisq(ix) < chisq0
+        ixbest = -1;
+        for (ix=0; ix<Nix; ix++)
+        {
+            if (chisq(ix) != 0.0 && chisq(ix) < 2.0*chisq0)
+            {
+                // ixmax = highest weight with successful unfolding
+                //         (Least squares solution)
+                ixmax = ix;
+
+                SpurSigma = SpSig(ix);
+                SpurAR    = SpAR(ix);
+                Chisq    = chisq(ix);
+                D2bar     = Dsqbar(ix);
+
+                //----------------------------------
+                // search weight where SpurSigma changes most
+                //                               (as a function of the weight)
+                if (ix > 0  &&  chisq(ix-1) != 0.0)
+                {
+                    Double_t diff = SpSig(ix) - SpSig(ix-1);
+                    if (diff > DiffSpSigmax)
+                    {
+                        DiffSpSigmax   = diff;
+                        ixDiffSpSigmax = ix;
+                    }
+                }
+
+                //----------------------------------
+                // search weight where Chisq is close
+                //        to the number of significant measurements
+                Double_t DiffSigpoints = fabs(Chisq-fVapoints);
+
+                if (DiffSigpoints < DiffSigpointsmin)
+                {
+                    DiffSigpointsmin   = DiffSigpoints;
+                    ixDiffSigpointsmin = ix;
+                }
+
+                //----------------------------------
+                // search weight where Chisq is close
+                //        to the rank of matrix G
+                Double_t DiffRankG = fabs(Chisq-RankG);
+
+                if (DiffRankG < DiffRankGmin)
+                {
+                    DiffRankGmin   = DiffRankG;
+                    ixDiffRankGmin = ix;
+                }
+
+                //----------------------------------
+                // search weight where SpurSigma is close to 1.0
+                Double_t DiffSpSig1 = fabs(SpurSigma/fSpurVacov-1.0);
+
+                if (DiffSpSig1 < DiffSpSig1min)
+                {
+                    DiffSpSig1min   = DiffSpSig1;
+                    ixDiffSpSig1min = ix;
+                }
+
+                //----------------------------------
+                // search weight where D2bar is minimal
+
+                if (D2bar < D2barmin)
+                {
+                    D2barmin   = D2bar;
+                    ixD2barmin = ix;
+                }
+
+                //----------------------------------
+            }
+        }
+
+
+        // choose solution where increase of SpurSigma is biggest
+        //if ( DiffSpSigmax > 0.0)
+        //  ixbest = ixDiffSpSigmax;
+        //else
+        //  ixbest = ixDiffSigpointsmin;
+
+        // choose Least Squares Solution
+	//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
+        // ixbest = ixmax;
+	//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
+
+        // choose weight where chi2 is close to the number of significant
+        // measurements
+        // ixbest = ixDiffSigpointsmin;
+
+        // choose weight where chi2 is close to the rank of matrix G
+        // ixbest = ixDiffRankGmin;
+
+        // choose weight where chi2 is close to the rank of matrix G
+	//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
+           ixbest = ixDiffSpSig1min;
+	//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
+
+        cout << "SelectBestWeight : ixDiffSpSigmax, DiffSpSigmax = "
+            << ixDiffSpSigmax << ",  " << DiffSpSigmax << endl;
+        cout << "================== ixDiffSigpointsmin, DiffSigpointsmin = "
+            << ixDiffSigpointsmin << ",  " << DiffSigpointsmin << endl;
+
+        cout << "                   ixDiffRankGmin, DiffRankGmin = "
+            << ixDiffRankGmin << ",  " << DiffRankGmin << endl;
+
+        cout << "                   ixDiffSpSig1min, DiffSpSig1min = "
+            << ixDiffSpSig1min << ",  " << DiffSpSig1min << endl;
+
+        cout << "                   ixD2barmin, D2barmin = "
+            << ixD2barmin << ",  " << D2barmin << endl;
+        cout << "                   ixmax  = " << ixmax  << endl;
+        cout << "                   ixbest = " << ixbest << endl;
+
+
+        return kTRUE;
+    }
+
+    // -----------------------------------------------------------------------
+    //
+    // Draw the plots
+    //
+    Bool_t DrawPlots()
+    {
+
+        // in the plots, mark the weight which has been selected
+        Double_t xbin = log10(xmin)+ixbest*dlogx;
+
+        TMarker *m = new TMarker();
+        m->SetMarkerSize(1);
+        m->SetMarkerStyle(20);
+
+        //-------------------------------------
+        // draw the iteration plots
+        TCanvas *c = new TCanvas("iter", "Plots versus weight", 900, 600);
+        c->Divide(3,2);
+
+        c->cd(1);
+        hBchisq->Draw();
+        gPad->SetLogy();
+        hBchisq->SetXTitle("log10(iteration number)");
+        hBchisq->SetYTitle("chisq");
+        m->DrawMarker(xbin, log10(chisq(ixbest)));
+
+        c->cd(2);
+        hBD2bar->Draw();
+        gPad->SetLogy();
+        hBD2bar->SetXTitle("log10(iteration number)");
+        hBD2bar->SetYTitle("(b_unfolded-b_ideal)**2");
+        m->DrawMarker(xbin, log10(Dsqbar(ixbest)));
+
+        /*
+         c->cd(3);
+         hBDAR2->Draw();
+         gPad->SetLogy();
+         strgx = "log10(iteration number)";
+         strgy = "norm(AR-AR+)";
+         hBDAR2->SetXTitle(strgx);
+         hBDAR2->SetYTitle(strgy);
+         m->DrawMarker(xbin, log10(DAR2(ixbest)));
+         */
+
+        c->cd(3);
+        hBSecDeriv->Draw();
+        hBSecDeriv->SetXTitle("log10(iteration number)");
+        hBSecDeriv->SetYTitle("Second Derivative squared");
+        m->DrawMarker(xbin, SecDer(ixbest));
+
+        /*
+         c->cd(8);
+         hBDSecDeriv->Draw();
+         strgx = "log10(iteration number)";
+         strgy = "Delta(Second Derivative squared)";
+         hBDSecDeriv->SetXTitle(strgx);
+         hBDSecDeriv->SetYTitle(strgy);
+         */
+
+        /*
+         c->cd(4);
+         hBZerDeriv->Draw();
+         strgx = "log10(iteration number)";
+         strgy = "Zero Derivative squared";
+         hBZerDeriv->SetXTitle(strgx);
+         hBZerDeriv->SetYTitle(strgy);
+         m->DrawMarker(xbin, ZerDer(ixbest));
+         */
+
+        /*
+         c->cd(5);
+         hBDZerDeriv->Draw();
+         strgx = "log10(iteration number)";
+         strgy = "Delta(Zero Derivative squared)";
+         hBDZerDeriv->SetXTitle(strgx);
+         hBDZerDeriv->SetYTitle(strgy);
+         */
+
+        c->cd(4);
+        hBSpAR->Draw();
+        hBSpAR->SetXTitle("log10(iteration number)");
+        hBSpAR->SetYTitle("SpurAR");
+        m->DrawMarker(xbin, SpAR(ixbest));
+
+
+        /*
+         c->cd(11);
+         hBDSpAR->Draw();
+         strgx = "log10(iteration number)";
+         strgy = "Delta(SpurAR)";
+         hBDSpAR->SetXTitle(strgx);
+         hBDSpAR->SetYTitle(strgy);
+         */
+
+        c->cd(5);
+        hBSpSig->Draw();
+        hBSpSig->SetXTitle("log10(iteration number)");
+        hBSpSig->SetYTitle("SpurSig/SpurC");
+        m->DrawMarker(xbin, SpSig(ixbest)/fSpurVacov);
+
+        /*
+         c->cd(14);
+         hBDSpSig->Draw();
+         strgx = "log10(iteration number)";
+         strgy = "Delta(SpurSig/SpurC)";
+         hBDSpSig->SetXTitle(strgx);
+         hBDSpSig->SetYTitle(strgy);
+         */
+
+        c->cd(6);
+        hBEntropy->Draw();
+        hBEntropy->SetXTitle("log10(iteration number)");
+        hBEntropy->SetYTitle("Entropy");
+        m->DrawMarker(xbin, Entrop(ixbest));
+
+        /*
+         c->cd(17);
+         hBDEntropy->Draw();
+         strgx = "log10(iteration number)";
+         strgy = "Delta(Entropy)";
+         hBDEntropy->SetXTitle(strgx);
+         hBDEntropy->SetYTitle(strgy);
+         */
+
+        //-------------------------------------
+
+        for (UInt_t i=0; i<fNa; i++)
+        {
+            fha->SetBinContent(i+1, fVa(i, 0)         );
+            fha->SetBinError  (i+1, sqrt(fVacov(i, i)));
+
+            for (UInt_t j=0; j<fNb; j++)
+            {
+                fhmig->SetBinContent(i+1, j+1, fMigOrig(i, j)           );
+                fhmig->SetBinError  (i+1, j+1, sqrt(fMigOrigerr2(i, j)) );
+
+                shmig->SetBinContent(i+1, j+1, fMigrat(i, j)           );
+                shmig->SetBinError  (i+1, j+1, sqrt(fMigraterr2(i, j)) );
+                shmigChi2->SetBinContent(i+1, j+1, fMigChi2(i, j)   );
+            }
+        }
+
+        PrintTH2Content(*shmig);
+        PrintTH2Content(*shmigChi2);
+
+        //-------------------------------------
+        CopyCol(*hprior, fVEps);
+        CopyCol(*hb,     fVb);
+        for (UInt_t i=0; i<fNb; i++)
+            hb->SetBinError(i+1, sqrt(fVbcov(i, i)));
+
+        PrintTH1Content(*hb);
+        PrintTH1Error(*hb);
+
+        //..............................................
+        for (UInt_t i=0; i<fNa; i++)
+            hEigen->SetBinContent(i+1, EigenValue(i));
+
+        //..............................................
+        // draw the plots
+        TCanvas *cc = new TCanvas("input", "Unfolding input", 900, 600);
+        cc->Divide(3, 2);
+
+        // distribution to be unfolded
+        cc->cd(1);
+        fha->Draw();
+        gPad->SetLogy();
+        fha->SetXTitle("log10(E-est/GeV)");
+        fha->SetYTitle("Counts");
+
+        // superimpose unfolded distribution
+        // hb->Draw("*HSAME");
+
+        // prior distribution
+        cc->cd(2);
+        hprior->Draw();
+        gPad->SetLogy();
+        hprior->SetXTitle("log10(E-true/GeV)");
+        hprior->SetYTitle("Counts");
+
+        // migration matrix
+        cc->cd(3);
+        fhmig->Draw("box");
+        fhmig->SetXTitle("log10(E-est/GeV)");
+        fhmig->SetYTitle("log10(E-true/GeV)");
+
+        // smoothed migration matrix
+        cc->cd(4);
+        shmig->Draw("box");
+        shmig->SetXTitle("log10(E-est/GeV)");
+        shmig->SetYTitle("log10(E-true/GeV)");
+
+        // chi2 contributions for smoothing
+        cc->cd(5);
+        shmigChi2->Draw("box");
+        shmigChi2->SetXTitle("log10(E-est/GeV)");
+        shmigChi2->SetYTitle("log10(E-true/GeV)");
+
+        // Eigenvalues of matrix M*M(transposed)
+        cc->cd(6);
+        hEigen->Draw();
+        hEigen->SetXTitle("l");
+        hEigen->SetYTitle("Eigen values Lambda_l of M*M(transposed)");
+
+
+       //..............................................
+        // draw the results
+        TCanvas *cr = new TCanvas("results", "Unfolding results", 600, 600);
+        cr->Divide(2, 2);
+
+        // unfolded distribution
+        cr->cd(1);
+        hb->Draw();
+        gPad->SetLogy();
+        hb->SetXTitle("log10(E-true/GeV)");
+        hb->SetYTitle("Counts");
+
+	
+        // covariance matrix of unfolded distribution
+        cr->cd(2);
+        TH1 *hbcov=DrawMatrixClone(fVbcov, "lego");
+        hbcov->SetBins(fNb, hb->GetBinLowEdge(1), hb->GetBinLowEdge(fNb+1),
+                       fNb, hb->GetBinLowEdge(1), hb->GetBinLowEdge(fNb+1));
+
+        hbcov->SetName("hbcov");
+        hbcov->SetTitle("Error matrix of distribution hb");
+        hbcov->SetXTitle("log10(E-true/GeV)");
+        hbcov->SetYTitle("log10(E-true/GeV)");
+       
+	
+        // chi2 contributions
+        cr->cd(3);
+        TH1 *hchi2=DrawMatrixColClone(fChi2);
+        hchi2->SetBins(fNa, fha->GetBinLowEdge(1), fha->GetBinLowEdge(fNa+1));
+
+        hchi2->SetName("Chi2");
+        hchi2->SetTitle("chi2 contributions");
+        hchi2->SetXTitle("log10(E-est/GeV)");
+        hchi2->SetYTitle("Chisquared");
+	
+	
+        // ideal distribution
+        
+        cr->cd(4);
+        fhb0->Draw();
+        gPad->SetLogy();
+        fhb0->SetXTitle("log10(E-true/GeV)");
+        fhb0->SetYTitle("Counts");
+        
+
+        // superimpose unfolded distribution
+        hb->Draw("*Hsame");
+	
+
+        return kTRUE;
+    }
+
+
+    // -----------------------------------------------------------------------
+    //
+    // Interface to MINUIT
+    //
+    //
+    Bool_t CallMinuit(
+                      void (*fcnx)(Int_t &, Double_t *, Double_t &, Double_t *, Int_t),
+                      UInt_t npar, char name[20][100],
+                      Double_t vinit[20], Double_t step[20],
+                      Double_t limlo[20], Double_t limup[20], Int_t fix[20])
+    {
+        //
+        // Be carefull: This is not thread safe
+        //
+        UInt_t maxpar = 100;
+
+        if (npar > maxpar)
+        {
+            cout << "MUnfold::CallMinuit : too many parameters,  npar = " << fNb
+                << ",   maxpar = " << maxpar << endl;
+            return kFALSE;
+        }
+
+        //..............................................
+        // Set the maximum number of parameters
+        TMinuit minuit(maxpar);
+
+
+        //..............................................
+        // Set the print level
+        // -1   no output except SHOW comands
+        //  0   minimum output
+        //  1   normal output (default)
+        //  2   additional ouput giving intermediate results
+        //  3   maximum output, showing progress of minimizations
+        //
+        Int_t printLevel = -1;
+        minuit.SetPrintLevel(printLevel);
+
+        //..............................................       
+        // Printout for warnings
+        //    SET WAR      print warnings
+        //    SET NOW      suppress warnings
+        Int_t errWarn;
+        Double_t tmpwar = 0;
+        minuit.mnexcm("SET NOW", &tmpwar, 0, errWarn);
+
+        //..............................................
+        // Set the address of the minimization function
+        minuit.SetFCN(fcnx);
+
+        //..............................................
+        // Set starting values and step sizes for parameters
+        for (UInt_t i=0; i<npar; i++)
+        {
+            if (minuit.DefineParameter(i, &name[i][0], vinit[i], step[i],
+                                       limlo[i], limup[i]))
+            {
+                cout << "MUnfold::CallMinuit: Error in defining parameter "
+                    << name << endl;
+                return kFALSE;
+            }
+        }
+
+        //..............................................
+        //Int_t NumPars = minuit.GetNumPars();
+        //cout << "MUnfold::CallMinuit :  number of free parameters = "
+        //     << NumPars << endl;
+
+        //..............................................
+        // Minimization
+        minuit.SetObjectFit(this);
+
+        //..............................................
+        // Error definition :
+        //
+        //    for chisquare function :
+        //      up = 1.0   means calculate 1-standard deviation error
+        //         = 4.0   means calculate 2-standard deviation error
+        //
+        //    for log(likelihood) function :
+        //      up = 0.5   means calculate 1-standard deviation error
+        //         = 2.0   means calculate 2-standard deviation error
+        Double_t up = 1.0;
+        minuit.SetErrorDef(up);
+
+
+
+        // Int_t errMigrad;
+        // Double_t tmp = 0;
+        // minuit.mnexcm("MIGRAD", &tmp, 0, errMigrad);
+
+
+        //..............................................
+        // fix a parameter
+        for (UInt_t i=0; i<npar; i++)
+        {
+            if (fix[i] > 0)
+            {
+                Int_t parNo = i;
+                minuit.FixParameter(parNo);
+            }
+        }
+
+        //..............................................
+        // Set maximum number of iterations (default = 500)
+        Int_t maxiter = 100000;
+        minuit.SetMaxIterations(maxiter);
+
+        //..............................................
+        // minimization by the method of Migrad
+        // Int_t errMigrad;
+        // Double_t tmp = 0;
+        // minuit.mnexcm("MIGRAD", &tmp, 0, errMigrad);
+
+        //..............................................       
+        // same minimization as by Migrad
+        // but switches to the SIMPLEX method if MIGRAD fails to converge
+        Int_t errMinimize;
+        Double_t tmp = 0;
+        minuit.mnexcm("MINIMIZE", &tmp, 0, errMinimize);
+
+        //..............................................       
+        // check quality of minimization
+        // istat = 0   covariance matrix not calculated
+        //         1   diagonal approximation only (not accurate)
+        //         2   full matrix, but forced positive-definite
+        //         3   full accurate covariance matrix 
+        //             (indication of normal convergence)
+        Double_t fmin, fedm, errdef;
+        Int_t    npari, nparx, istat;
+        minuit.mnstat(fmin, fedm, errdef, npari, nparx, istat);
+
+        if (errMinimize || istat < 3)
+        {
+            cout << "MUnfold::CallMinuit : Minimization failed" << endl;
+            cout << "       fmin = " << fmin   << ",   fedm = "  << fedm
+                << ",   errdef = "  << errdef << ",   istat = " << istat
+                << endl;
+            return kFALSE;
+        }
+
+        //..............................................
+        // Minos error analysis
+        // minuit.mnmnos();
+
+        //..............................................       
+        // Print current status of minimization
+        // if nkode = 0    only function value
+        //            1    parameter values, errors, limits
+        //            2    values, errors, step sizes, internal values
+        //            3    values, errors, step sizes, 1st derivatives
+        //            4    values, paraboloc errors, MINOS errors
+  
+        //Int_t nkode = 4;
+        //minuit.mnprin(nkode, fmin);
+
+        //..............................................       
+        // call fcn with IFLAG = 3 (final calculation : calculate p(chi2))
+        // iflag = 1   initial calculations only
+        //         2   calculate 1st derivatives and function
+        //         3   calculate function only
+        //         4   calculate function + final calculations
+        const char *command = "CALL";
+        Double_t iflag = 3;
+        Int_t errfcn3;
+        minuit.mnexcm(command, &iflag, 1, errfcn3); 
+
+        return kTRUE;
+    }
+
+    // -----------------------------------------------------------------------
+    //
+    // Return the unfolded distribution
+    //
+    TMatrixD &GetVb() { return fVb; }
+
+    // -----------------------------------------------------------------------
+    //
+    // Return the covariance matrix of the unfolded distribution
+    //
+    TMatrixD &GetVbcov() { return fVbcov; }
+
+    // -----------------------------------------------------------------------
+    //
+    // Return the unfolded distribution + various errors
+    //
+    TMatrixD &GetResult() { return fResult; }
+
+    // -----------------------------------------------------------------------
+    //
+    // Return the chisquared contributions
+    //
+    TMatrixD &GetChi2() { return fChi2; }
+
+    // -----------------------------------------------------------------------
+    //
+    // Return the total chisquared
+    //
+    Double_t &GetChisq() { return fChisq; }
+
+    // -----------------------------------------------------------------------
+    //
+    // Return the number of degrees of freedom
+    //
+    Double_t &GetNdf() { return fNdf; }
+
+    // -----------------------------------------------------------------------
+    //
+    // Return the chisquared probability
+    //
+    Double_t &GetProb() { return fProb; }
+
+    // -----------------------------------------------------------------------
+    //
+    // Return the smoothed migration matrix
+    //
+    TMatrixD &GetMigSmoo() { return fMigSmoo; }
+
+    // -----------------------------------------------------------------------
+    //
+    // Return the error2 of the smoothed migration matrix
+    //
+    TMatrixD &GetMigSmooerr2() { return fMigSmooerr2; }
+
+    // -----------------------------------------------------------------------
+    //
+    // Return the chi2 contributions for the smoothing
+    //
+    TMatrixD &GetMigChi2() { return fMigChi2; }
+};
+// end of definition of class MUnfold
+///////////////////////////////////////////////////
+
+
+// -----------------------------------------------------------------------
+//
+// fcnSmooth     (used by SmoothMigrationMatrix)
+//
+// is called by MINUIT
+// for given values of the parameters it calculates the function 
+//                                               to be minimized
+//
+void fcnSmooth(Int_t &npar, Double_t *gin, Double_t &f, 
+               Double_t *par, Int_t iflag)
+{
+    MUnfold &gUnfold = *(MUnfold*)gMinuit->GetObjectFit();
+
+    Double_t a0 = par[0];
+    Double_t a1 = par[1];
+    Double_t a2 = par[2];
+
+    Double_t b0 = par[3];
+    Double_t b1 = par[4];
+    Double_t b2 = par[5];
+
+    // loop over bins of log10(E-true)
+    Double_t chi2 = 0.0;
+    Int_t npoints = 0;
+    Double_t func[20];
+
+    for (UInt_t j=0; j<gUnfold.fNb; j++)
+    {
+        Double_t yj   = ((double)j) + 0.5;
+        Double_t mean = a0 + a1*yj + a2*yj*yj + yj;
+        Double_t RMS  = b0 + b1*yj + b2*yj*yj;
+
+        if (RMS <= 0.0)
+        {
+            chi2 = 1.e20;
+            break;
+        }
+
+        // loop over bins of log10(E-est)
+
+        //.......................................
+        Double_t function;
+        Double_t sum=0.0;
+        for (UInt_t i=0; i<gUnfold.fNa; i++)
+        {
+            Double_t xlow = (double)i;
+            Double_t xup  = xlow + 1.0;
+            Double_t xl  = (xlow- mean) / RMS;
+            Double_t xu  = (xup - mean) / RMS;
+            function = (TMath::Freq(xu) - TMath::Freq(xl));
+
+            //cout << "i, xl, xu, function = " <<  i <<  ",  "  << xl << ",  "
+            //     << xu  << ",  " << function << endl;
+
+            if (function < 1.e-10)
+                function = 0.0;
+
+            func[i] = function;
+            sum += function;
+        }
+
+        //      cout << "mean, RMS = "  << mean << ",  " << RMS
+        //     << ",   j , sum of function = " << j << ",  " << sum << endl;
+
+        //.......................................
+
+        for (UInt_t i=0; i<gUnfold.fNa; i++)
+        {
+            if (sum != 0.0)
+                func[i] /= sum;
+
+            gUnfold.fMigSmoo(i,j) = func[i];
+            gUnfold.fMigChi2(i,j) = 0.0;
+
+            // if relative error is greater than 30 % ignore the point
+
+            if (gUnfold.fMigOrig(i,j)     != 0 &&
+                gUnfold.fMigOrigerr2(i,j) != 0 &&
+                func[i] != 0  )
+            {
+                if (gUnfold.fMigOrigerr2(i,j)/
+                    (gUnfold.fMigOrig(i,j)*gUnfold.fMigOrig(i,j)) <= 0.09)
+                {
+                    gUnfold.fMigChi2(i,j) =   ( gUnfold.fMigOrig(i,j) - func[i] )
+                        * ( gUnfold.fMigOrig(i,j) - func[i] )
+                        /   gUnfold.fMigOrigerr2(i,j);
+                    chi2 += gUnfold.fMigChi2(i,j);
+                    npoints += 1;
+                }
+            }
+        }
+        //.......................................
+
+    }
+    f = chi2;
+
+    //cout << "fcnSmooth : f = " << f << endl;
+
+    //--------------------------------------------------------------------
+    // final calculations
+    if (iflag == 3)
+    {
+        Int_t     NDF = npoints - npar;
+        Double_t prob = TMath::Prob(chi2, NDF);
+
+        cout << "fcnSmooth : npoints, chi2, NDF, prob = " << npoints << ",  ";
+        cout << chi2 << ",  " << NDF << ",  " << prob << endl;
+        cout << "=======================================" << endl;
+    }
+}
+
+// -----------------------------------------------------------------------
+//
+// fcnTikhonov2     (used by Tikhonov2)
+//
+// is called by MINUIT
+// for given values of the parameters it calculates the function F
+// the free parameters are the first (fNb-1) elements
+//                     of the normalized unfolded distribution
+//
+void fcnTikhonov2(Int_t &npar, Double_t *gin, Double_t &f,
+                  Double_t *par, Int_t iflag)
+{
+    MUnfold &gUnfold = *(MUnfold*)gMinuit->GetObjectFit();
+
+    // (npar+1) is the number of bins of the unfolded distribuition (fNb)
+    //  npar    is the number of free parameters                    (fNb-1)
+
+    UInt_t npar1 = npar + 1;
+
+    UInt_t fNa = gUnfold.fNa;
+    UInt_t fNb = gUnfold.fNb;
+    if (npar1 != fNb)
+    {
+        cout << "fcnTikhonov2 : inconsistency in number of parameters; npar, fNb = ";
+        cout << npar << ",  " << fNb << endl;
+        //return;
+    }
+    npar1 = fNb;
+
+    TMatrixD p(npar1, 1);
+    TMatrixD &fVb = gUnfold.fVb;
+
+    // p is the normalized unfolded distribution
+    // sum(p(i,0)) from i=0 to npar is equal to 1
+    Double_t sum = 0.0;
+    for (Int_t i=0; i<npar; i++)
+    {
+        p(i,0) = par[i];
+        sum += par[i];
+    }
+    p(npar,0) = 1.0 - sum;
+
+
+    // all p(i,0) have to be greater than zero
+    for (UInt_t i=0; i<npar1; i++)
+        if (p(i,0) <= 0.0)
+        {
+            f = 1.e20;
+            return;
+        }
+
+    //.......................
+    // take least squares result for the normaliztion
+    TMatrixD alpha(gUnfold.fMigrat, TMatrixD::kMult, p);
+
+    //TMatrixD v4   (gUnfold.fVa, TMatrixD::kTransposeMult,
+    //                                 gUnfold.fVacovInv);
+    //TMatrixD norma(v4,  TMatrixD::kMult, gUnfold.fVa);
+
+    TMatrixD v5   (alpha, TMatrixD::kTransposeMult, gUnfold.fVacovInv);
+    TMatrixD normb(v5,    TMatrixD::kMult, alpha);
+
+    TMatrixD normc(v5,    TMatrixD::kMult, gUnfold.fVa);
+
+    Double_t norm  = normc(0,0)/normb(0,0);
+
+    //.......................
+
+    // b is the unnormalized unfolded distribution
+    // sum(b(i,0)) from i=0 to npar is equal to norm
+    //                       (the total number of events)
+    for (UInt_t i=0; i<npar1; i++)
+        fVb(i,0) = p(i,0) * norm;
+
+    TMatrixD Gb(gUnfold.fMigrat, TMatrixD::kMult, fVb);
+    TMatrixD v3(fNa, 1);
+    v3 = gUnfold.fVa;
+    v3 -= Gb;
+
+    TMatrixD v1(1,fNa);
+    for (UInt_t i=0; i<fNa; i++)
+    {
+        v1(0,i) = 0;
+        for (UInt_t j=0; j<fNa; j++)
+            v1(0,i) += v3(j,0) * gUnfold.fVacovInv(j,i) ;
+    }
+
+    for (UInt_t i = 0; i<fNa; i++)
+        gUnfold.Chi2(i,0) = v1(0,i) * v3(i,0);
+
+    gUnfold.Chisq = GetMatrixSumCol(gUnfold.Chi2,0);
+
+    //-----------------------------------------------------
+    // calculate 2nd derivative squared
+    // regularization term (second derivative squared)
+    gUnfold.SecDeriv = 0;
+    for (UInt_t j=1; j<(fNb-1); j++)
+     {
+         const Double_t temp =
+             + 2.0*(fVb(j+1,0)-fVb(j,0)) / (fVb(j+1,0)+fVb(j,0))
+             - 2.0*(fVb(j,0)-fVb(j-1,0)) / (fVb(j,0)+fVb(j-1,0));
+
+         gUnfold.SecDeriv += temp*temp;
+     }
+
+    gUnfold.ZerDeriv = 0;
+    for (UInt_t j=0; j<fNb; j++)
+        gUnfold.ZerDeriv += fVb(j,0) * fVb(j,0);
+
+    f = gUnfold.Chisq/2 * gUnfold.fW + gUnfold.SecDeriv;
+
+    //cout << "F=" << f      << " \tSecDeriv=" << gUnfold.SecDeriv
+    //     << " \tchi2="
+    //	  << gUnfold.Chisq << " \tfW=" << gUnfold.fW << endl;
+
+    //--------------------------------------------------------------------
+    // final calculations
+    if (iflag == 3)
+    {
+        //..............................................
+        // calculate external error matrix of the fitted parameters 'val'
+        // extend it with the covariances for y=1-sum(val)
+        Double_t emat[20][20];
+        Int_t    ndim = 20;
+        gMinuit->mnemat(&emat[0][0], ndim);
+
+        Double_t covv = 0;
+        for (UInt_t i=0; i<(gUnfold.fNb-1); i++)
+        {
+            Double_t cov = 0;
+            for (UInt_t k=0; k<(gUnfold.fNb-1); k++)
+                cov += emat[i][k];
+
+            emat[i][gUnfold.fNb-1] = -cov;
+            emat[gUnfold.fNb-1][i] = -cov;
+
+            covv += cov;
+        }
+        emat[gUnfold.fNb-1][gUnfold.fNb-1] = covv;
+
+        for (UInt_t i=0; i<gUnfold.fNb; i++)
+            for (UInt_t k=0; k<gUnfold.fNb; k++)
+                gUnfold.fVbcov(i,k) = emat[i][k] *norm*norm;
+
+        //-----------------------------------------------------
+        //..............................................
+        // put unfolded distribution into fResult
+        //     fResult(i,0)   value in bin i
+        //     fResult(i,1)   error of value in bin i
+
+        gUnfold.fResult.ResizeTo(gUnfold.fNb, 5);
+
+        Double_t sum = 0;
+        for (UInt_t i=0; i<(gUnfold.fNb-1); i++)
+        {
+            Double_t val;
+            Double_t err;
+            if (!gMinuit->GetParameter(i, val, err))
+            {
+                cout << "Error getting parameter #" << i << endl;
+                return;
+            }
+
+            Double_t eplus;
+            Double_t eminus;
+            Double_t eparab;
+            Double_t gcc;
+            gMinuit->mnerrs(i, eplus, eminus, eparab, gcc);
+
+            gUnfold.fVb(i, 0)     = val    * norm;
+
+            gUnfold.fResult(i, 0) = val    * norm;
+            gUnfold.fResult(i, 1) = eparab * norm;
+            gUnfold.fResult(i, 2) = eplus  * norm;
+            gUnfold.fResult(i, 3) = eminus * norm;
+            gUnfold.fResult(i, 4) = gcc;
+            sum += val;
+        }
+        gUnfold.fVb(gUnfold.fNb-1, 0)     = (1.0-sum) * norm;
+
+        gUnfold.fResult(gUnfold.fNb-1, 0) = (1.0-sum) * norm;
+        gUnfold.fResult(gUnfold.fNb-1, 1) =
+            sqrt(gUnfold.fVbcov(gUnfold.fNb-1,gUnfold.fNb-1));
+        gUnfold.fResult(gUnfold.fNb-1, 2) = 0;
+        gUnfold.fResult(gUnfold.fNb-1, 3) = 0;
+        gUnfold.fResult(gUnfold.fNb-1, 4) = 1;
+        //..............................................
+
+        //-----------------------------------------------------
+        // calculate 0th derivative squared
+        gUnfold.ZerDeriv = 0;
+        for (UInt_t j=0; j<fNb; j++)
+            gUnfold.ZerDeriv += fVb(j,0) * fVb(j,0);
+
+        //-----------------------------------------------------
+        // calculate the entropy
+
+        gUnfold.Entropy = 0;
+        for (UInt_t j=0; j<gUnfold.fNb; j++)
+            if (p(j,0) > 0)
+                gUnfold.Entropy += p(j,0) * log( p(j,0) );
+
+
+        //-----------------------------------------------------
+        // calculate SpurSigma
+        gUnfold.SpurSigma = 0.0;
+        for (UInt_t m=0; m<fNb; m++)
+            gUnfold.SpurSigma += gUnfold.fVbcov(m,m);
+        // cout << "SpurSigma =" << SpurSigma << endl;
+
+        //-----------------------------------------------------
+        gUnfold.SpurAR  = 0;
+        gUnfold.DiffAR2 = 0;
+
+        //-----------------------------------------------------
+        gUnfold.fNdf   = gUnfold.fNa;
+        gUnfold.fChisq   = gUnfold.Chisq;
+
+        for (UInt_t i=0; i<fNa; i++)
+	{
+          gUnfold.fChi2(i,0) = gUnfold.Chi2(i,0);
+	}
+
+
+        UInt_t iNdf = (UInt_t) (gUnfold.fNdf+0.5);
+
+        //cout << "fcnTikhonov2 : fW, chisq (from fcnF) = "
+        //     << gUnfold.fW << ",  " << gUnfold.fChisq << endl;
+
+        gUnfold.fProb = iNdf>0 ? TMath::Prob(gUnfold.fChisq, iNdf) : 0;
+    }
+}
+
+
+// ======================================================
+//
+// SteerUnfold
+//
+void SteerUnfold(TH1D &ha,     TH2D &hacov, TH2D &hmig,
+                 TH2D &hmigor, TH1D &hb0,   TH1D *hpr=NULL)
+{
+    // ha      is the distribution to be unfolded
+    // hacov   is the covariance matrix of the distribution ha
+    // hmig    is the migration matrix;
+    //         it is used in the unfolding unless it is overwritten
+    //         by SmoothMigrationMatrix by the smoothed migration matrix
+    // hmigor  is the migration matrix to be smoothed;
+    //         the smoothed migration matrix will be used in the unfolding
+    // hpr     the prior distribution
+    //         it is only used if SetPriorInput(*hpr) is called   
+
+    //..............................................       
+    // create an MUnfold object;
+    // fill histograms into vectors and matrices
+
+    MUnfold unfold(ha, hacov, hmig);
+
+    //..............................................       
+    // smooth the migration matrix;
+    //        the smoothed migration matrix will be used in the unfolding
+    //        hmig is the original (unsmoothed) migration matrix
+
+    unfold.SmoothMigrationMatrix(hmigor);
+
+    //..............................................       
+    // define prior distribution (has always to be defined) 
+    // the alternatives are  :
+
+    // 1  SetPriorConstant() :   isotropic distribution
+    // 2  SetPriorPower(gamma) : dN/dE = E^{-gamma}
+    // 3  SetPriorInput(*hpr):   the distribution *hpr is used 
+    // 4  SetPriorRebin(*ha) :   use rebinned histogram ha 
+
+    UInt_t flagprior = 4;
+    cout << "SteerUnfold : flagprior = " << flagprior << endl;
+    cout << "=========================="<< endl;
+
+    Bool_t errorprior=kTRUE;
+    switch (flagprior)
+    {
+    case 1:
+        unfold.SetPriorConstant();
+        break;
+    case 2:
+        errorprior = unfold.SetPriorPower(1.5);
+        break;
+    case 3:
+        if (!hpr)
+        {
+            cout << "Error: No hpr!" << endl;
+            return;
+        }
+        errorprior = unfold.SetPriorInput(*hpr);
+        break;
+    case 4:
+        errorprior = unfold.SetPriorRebin(ha);
+        break;
+    }
+    if (!errorprior)
+    {
+        cout << "MUnfold::SetPrior... : failed.  flagprior = " ;
+        cout << flagprior << endl;
+        return;
+    }
+
+    //..............................................       
+    // calculate the matrix G = M * M(transposed)
+    //           M being the migration matrix
+
+    unfold.CalculateG();
+
+    //..............................................       
+    // call steering routine for the actual unfolding;
+    // the alternatives are :
+
+    // 1  Schmelling : minimize the function Z by Gauss-Newton iteration;
+    //                 the parameters to be fitted are gamma(i) = lambda(i)/w;
+
+    // 2  Tikhonov2 :  regularization term is sum of (2nd deriv.)**2 ;
+    //                 minimization by using MINUIT;
+    //                 the parameters to be fitted are
+    //                 the bin contents of the unfolded distribution
+
+    // 3  Bertero:     minimization by iteration
+    //                 
+
+    UInt_t flagunfold = 1;
+    cout << "SteerUnfold : flagunfold = " << flagunfold << endl;
+    cout << "===========================" << endl;
+
+
+
+    switch (flagunfold)
+    {
+    case 1: // Schmelling
+        cout << "" << endl;
+        cout << "Unfolding algorithm : Schmelling" << endl;
+        cout << "================================" << endl;
+        if (!unfold.Schmelling(hb0))
+            cout << "MUnfold::Schmelling : failed." << endl;
+        break;
+
+    case 2: // Tikhonov2
+        cout << "" << endl;
+        cout << "Unfolding algorithm :   Tikhonov" << endl;
+        cout << "================================" << endl;
+        if (!unfold.Tikhonov2(hb0))
+            cout << "MUnfold::Tikhonov2 : failed." << endl;
+        break;
+
+    case 3: // Bertero
+        cout << "" << endl;
+        cout << "Unfolding algorithm :    Bertero" << endl;
+        cout << "================================" << endl;
+        if (!unfold.Bertero(hb0))
+            cout << "MUnfold::Bertero : failed." << endl;
+        break;
+    }    
+
+
+    //..............................................       
+    // Print fResult
+    unfold.PrintResults();
+
+
+    //..............................................       
+    // Draw the plots
+    unfold.DrawPlots();
+
+    //..............................................       
+    // get unfolded distribution
+    //TMatrixD &Vb    = unfold.GetVb();
+    //TMatrixD &Vbcov = unfold.GetVbcov();
+
+}
+
+//__________________________________________________________________________
+
+
+////////////////////////////////////////////////////////////////////////////
+//                                                                        //
+// Main program                                                           //
+//                defines the ideal distribution          (hb0)           //
+//                defines the migration matrix            (hMigrat)       //
+//                defines the distribution to be unfolded (hVa)           //
+//                                                                        //
+//                calls member functions of the class MUnfold             //
+//                      to do the unfolding                               //
+//                                                                        //
+////////////////////////////////////////////////////////////////////////////
+void unfold()
+{
+  // -----------------------------------------
+  // migration matrix :
+  //           x corresponds to measured quantity
+  //           y corresponds to true quantity
+
+    //const Int_t  na   =   13;
+    const Int_t  na   =   18;
+    const Axis_t alow = 0.25;
+    const Axis_t aup  = 3.50;
+
+    //const Int_t  nb   =   11;
+    const Int_t  nb   =   22;
+    const Axis_t blow = 0.50;
+    const Axis_t bup  = 3.25;
+
+    TH2D hmig("Migrat", "Migration Matrix", na, alow, aup, nb, blow, bup);
+    hmig.Sumw2();
+
+    // parametrize migration matrix as
+    //     <log10(Eest)>      = a0 + a1*log10(Etrue) + a2*log10(Etrue)**2 
+    //                             + log10(Etrue) 
+    //     RMS( log10(Eest) ) = b0 + b1*log10(Etrue) + b2*log10(Etrue)**2
+    Double_t a0 = 0.0;
+    Double_t a1 = 0.0;
+    Double_t a2 = 0.0;
+
+    Double_t b0 = 0.26;
+    Double_t b1 =-0.054;
+    Double_t b2 = 0.0;
+
+    TF1 f2("f2", "gaus(0)", alow, aup);
+    f2.SetParName(0, "ampl");
+    f2.SetParName(1, "mean");
+    f2.SetParName(2, "sigma");
+
+    // loop over log10(Etrue) bins
+    TAxis &yaxis = *hmig.GetYaxis();
+    for (Int_t j=1; j<=nb; j++)
+    {
+        Double_t yvalue = yaxis.GetBinCenter(j);
+
+        const Double_t mean  = a0 + a1*yvalue + a2*yvalue*yvalue + yvalue;
+        const Double_t sigma = b0 + b1*yvalue + b2*yvalue*yvalue;
+        const Double_t ampl  = 1./ ( sigma*TMath::Sqrt(2.0*TMath::Pi()));
+
+        // gaus(0) is a substitute for [0]*exp( -0.5*( (x-[1])/[2] )**2 )
+        f2.SetParameter(0, ampl);
+        f2.SetParameter(1, mean);
+        f2.SetParameter(2, sigma);
+
+        // fill temporary 1-dim histogram with the function
+        // fill the histogram using
+        //    - either FillRandom
+        //    - or using Freq
+        TH1D htemp("temp", "temp", na, alow, aup);
+        htemp.Sumw2();
+
+        for (Int_t k=0; k<1000000; k++)
+            htemp.Fill(f2.GetRandom());
+
+        // copy it into the migration matrix
+        Double_t sum = 0;
+        for (Int_t i=1; i<=na; i++)
+        {
+            const Stat_t content = htemp.GetBinContent(i);
+            hmig.SetBinContent(i, j, content);
+            sum += content;
+        }
+
+        // normalize migration matrix
+        if (sum==0)
+            continue;
+
+        for (Int_t i=1; i<=na; i++)
+        {
+            const Stat_t content = hmig.GetBinContent(i,j);
+            hmig.SetBinContent(i,j,      content/sum);
+            hmig.SetBinError  (i,j,sqrt(content)/sum);
+        }
+    }
+
+    PrintTH2Content(hmig);
+    PrintTH2Error(hmig);
+
+    // -----------------------------------------
+    // ideal distribution
+
+    TH1D hb0("hb0", "Ideal distribution", nb, blow, bup);
+    hb0.Sumw2();
+
+    // fill histogram with random numbers according to 
+    // an exponential function dN/dE = E^{-gamma}
+    //    or with y = log10(E), E = 10^y :             
+    //                          dN/dy = ln10 * 10^{y*(1-gamma)}     
+    TF1 f1("f1", "pow(10.0, x*(1.0-[0]))", blow, bup);
+    f1.SetParName(0,"gamma");
+    f1.SetParameter(0, 2.7);
+
+    // ntimes is the number of entries
+    for (Int_t k=0; k<10000; k++)
+        hb0.Fill(f1.GetRandom());
+
+    // introduce energy threshold at 50 GeV
+
+    const Double_t  lgEth = 1.70;
+    const Double_t dlgEth = 0.09;
+
+    for (Int_t j=1; j<=nb; j++)
+    {
+        const Double_t lgE = hb0.GetBinCenter(j);
+        const Double_t c   = hb0.GetBinContent(j);
+        const Double_t dc  = hb0.GetBinError(j);
+        const Double_t f   = 1.0 / (1.0 + exp( -(lgE-lgEth)/dlgEth ));
+
+        hb0.SetBinContent(j, f* c);
+        hb0.SetBinError  (j, f*dc);
+    }
+
+    PrintTH1Content(hb0);
+
+    // -----------------------------------------
+    // here the prior distribution can be defined for the call
+    // to SetPriorInput(*hpr)
+    TH1D hpr("hpr", "Prior distribution" , nb, blow, bup);
+    for (Int_t j=1; j<=nb; j++)
+        hpr.SetBinContent(j, 1.0/nb);
+
+    PrintTH1Content(hpr);
+
+    // -----------------------------------------
+    // generate distribution to be unfolded (ha)
+    // by smearing the ideal distribution  (hb0)
+    //
+    TH1D ha("ha", "Distribution to be unfolded", na, alow, aup);
+    ha.Sumw2();
+
+    for (Int_t i=1; i<=na; i++)
+    {
+        Double_t cont = 0;
+        for (Int_t j=1; j<=nb; j++)
+            cont += hmig.GetBinContent(i, j) * hb0.GetBinContent(j);
+
+        ha.SetBinContent(i, cont);
+        ha.SetBinError(i, sqrt(cont));
+    }
+
+    PrintTH1Content(ha);
+    PrintTH1Error(ha);
+
+    // -----------------------------------------
+    // covariance matrix of the distribution ha
+    TH2D hacov("hacov", "Error matrix of distribution ha",
+               na, alow, aup, na, alow, aup);
+
+    for (Int_t i=1; i<=na; i++)
+    {
+        const Double_t content = ha.GetBinContent(i);
+        hacov.SetBinContent(i, i, content<3 ? 3.0 : content);
+    }
+
+    PrintTH2Content(hacov);
+
+    SteerUnfold(ha, hacov, hmig, hmig, hb0, &hpr);
+}
+//========================================================================//
Index: /tags/Mars_V0-8-5/Mars/macros/weights.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/macros/weights.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/macros/weights.C	(revision 9661)
@@ -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): Marcos Lopez, 10/2003 <mailto:marcos@gae.ucm.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// weights.C
+// =========
+//
+// This macro shows how to use the class MMcWeightEnergySpecCalc
+// to convert the energy spectrum of the MC showers generated with Corsika,
+// to a different one.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+Double_t myfunction(Double_t *x, Double_t *par)
+{
+  Double_t xx = x[0];
+
+  return pow(xx,-2)*exp(-xx/20);  
+}
+
+void weights(TString filename="/up1/data/Magic-MC/CameraAll/Gammas/zbin0/Gamma_zbin0_0_7_1000to1009_w0-4:4:2.root")
+{
+
+    //
+    // PartList
+    //
+    MParList  parlist;
+    MTaskList tasklist;
+    
+    MHMcEnergyImpact h1("h1");
+    MHMcEnergyImpact h2("h2");
+    parlist.AddToList(&h1);
+    parlist.AddToList(&h2);
+
+    MBinning binsenergy("BinningEnergy");
+    binsenergy.SetEdgesLog(100, 1, 1e5);
+    parlist.AddToList(&binsenergy);
+
+    MBinning binsimpact("BinningImpact");
+    binsimpact.SetEdges(100, 0, 450);
+    parlist.AddToList(&binsimpact);
+
+    parlist.AddToList(&tasklist);
+
+
+    //
+    // TaskList
+    //
+    MReadMarsFile reader("Events", filename);
+    reader.EnableBranch("fEnergy");
+    reader.EnableBranch("fImpact");
+
+
+    // -------------------------------------------------------------
+    //
+    // Option 1. Just change the slope of the MC power law spectrum
+    //
+    //MMcWeightEnergySpecCalc wcalc(-2.0);                //<-- Uncomment me
+
+    //
+    // Option 2. A completely differente specturm pass as a TF1 function
+    //           e.g. spectrum with exponential cutoff
+    //
+    //TF1 spec("spectrum","pow(x,[0])*exp(-x/[1])");      //<-- Uncomment me
+    //spec->SetParameter(0,-2.0);                         //<-- Uncomment me
+    //spec->SetParameter(1,50);                           //<-- Uncomment me
+    //MMcWeightEnergySpecCalc wcalc(spec);                //<-- Uncomment me
+ 
+    //
+    // Option 3. A completely differente specturm pass as a cahr*
+    //           
+    //char* func = "pow(x,-2)";                           //<-- Uncomment me
+    //MMcWeightEnergySpecCalc wcalc(func);                //<-- Uncomment me
+
+    //
+    // Option 4. A completely differente specturm pass as a c++ function
+    //     
+    MMcWeightEnergySpecCalc wcalc((void*)myfunction);   //<-- Uncomment me
+    //
+    //-------------------------------------------------------------
+
+    MFillH hfill(&h1,"MMcEvt");
+    MFillH hfill2(&h2,"MMcEvt");
+    hfill2.SetWeight("MWeight");
+
+    tasklist.AddToList(&reader);
+    tasklist.AddToList(&wcalc);
+    tasklist.AddToList(&hfill);
+    tasklist.AddToList(&hfill2);
+
+    //
+    // EventLoop
+    //
+    MEvtLoop magic;
+    magic.SetParList(&parlist);
+
+    if (!magic.Eventloop())
+        return;
+
+    tasklist.PrintStatistics();
+    parlist.Print();
+
+    //
+    // Draw the Results
+    //
+    TCanvas *c = new TCanvas();
+    c->SetLogy();
+    c->SetLogx();
+
+    TH1D* hist1 = (h1->GetHist())->ProjectionX();
+    TH1D* hist2 = (h2->GetHist())->ProjectionX();
+    hist2->SetLineColor(2);
+
+    hist1->DrawClone();
+    hist2->DrawClone("same");    
+}
Index: /tags/Mars_V0-8-5/Mars/magic_t.xpm
===================================================================
--- /tags/Mars_V0-8-5/Mars/magic_t.xpm	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/magic_t.xpm	(revision 9661)
@@ -0,0 +1,95 @@
+/* XPM */
+static char * magic_t_xpm[] = {
+"14 14 78 1",
+" 	c None",
+".	c #545792",
+"+	c #434988",
+"@	c #434888",
+"#	c #3E4284",
+"$	c #2B3279",
+"%	c #2B3179",
+"&	c #2C3279",
+"*	c #484C8B",
+"=	c #5D6198",
+"-	c #5B5E96",
+";	c #393E81",
+">	c #9193B8",
+",	c #E2E1EA",
+"'	c #FDFDFC",
+")	c #FEFEFC",
+"!	c #F7F6F7",
+"~	c #8E8FB5",
+"{	c #6C6EA0",
+"]	c #ECECF1",
+"^	c #F5DE8A",
+"/	c #F5E192",
+"(	c #FCF7E5",
+"_	c #565A93",
+":	c #65679C",
+"<	c #C8C8DA",
+"[	c #E7E7EE",
+"}	c #F9F9F9",
+"|	c #FEFEFA",
+"1	c #FDFAF0",
+"2	c #F5DF8F",
+"3	c #9395B9",
+"4	c #4D508D",
+"5	c #474B8A",
+"6	c #2C327A",
+"7	c #383E81",
+"8	c #8385B0",
+"9	c #F5EAC1",
+"0	c #F4DF8F",
+"a	c #F8EBB8",
+"b	c #A4A4C3",
+"c	c #ADADC9",
+"d	c #3C4183",
+"e	c #524E63",
+"f	c #A09275",
+"g	c #F6E5A3",
+"h	c #9193B7",
+"i	c #DCDCE8",
+"j	c #7376A5",
+"k	c #524D66",
+"l	c #383A75",
+"m	c #52558E",
+"n	c #EEEDF2",
+"o	c #5F6299",
+"p	c #DDDDE8",
+"q	c #B1B1CB",
+"r	c #ABABC8",
+"s	c #E5E4EC",
+"t	c #2F357B",
+"u	c #AFB0CB",
+"v	c #FCFCFB",
+"w	c #8D8FB5",
+"x	c #6A6DA0",
+"y	c #7779A8",
+"z	c #4F538F",
+"A	c #FAFAFA",
+"B	c #ABACC8",
+"C	c #34397E",
+"D	c #B2B2CC",
+"E	c #2C337A",
+"F	c #8384AF",
+"G	c #7779A7",
+"H	c #BEBDD4",
+"I	c #CDCDDE",
+"J	c #8F91B7",
+"K	c #787AA8",
+"L	c #9F9FC0",
+"M	c #7D7FAB",
+".++++++++++++@",
+"#$$$$$$$$$$$$%",
+"#$$$$$$$$$$$$%",
+"#$$$$$&*=-;$$%",
+"#$$$;>,'))!~$%",
+"#$${]))))^/(_%",
+"#$:<[})|12))3%",
+"#45$67890a))b%",
+"#cd$$$efg)))h%",
+"#ij$$$klmn))o%",
+"#pq$$$$$$r)st%",
+"#uvw&$$$$x)y$%",
+"#zA)Bt$$$CDE$%",
+"FGH))IJKGLMGGG"};
Index: /tags/Mars_V0-8-5/Mars/magiclogo.xpm
===================================================================
--- /tags/Mars_V0-8-5/Mars/magiclogo.xpm	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/magiclogo.xpm	(revision 9661)
@@ -0,0 +1,342 @@
+/* XPM */
+static char *mag1[] = {
+/* width height ncolors chars_per_pixel */
+"176 87 248 2",
+/* colors */
+"   c #F2D25C",
+" . c #FEFAEC",
+" X c #FEF6EC",
+" o c #A69EC4",
+" O c #F2F6F4",
+" + c #524E8C",
+" @ c #F2F2F4",
+" # c #F2EEF4",
+" $ c #9E92BC",
+" % c #EECA44",
+" & c #EEC644",
+" * c #4E4674",
+" = c #968AB4",
+" - c #363E84",
+" ; c #FEEAC4",
+" : c #363A84",
+" > c #E2DAE4",
+" , c #EAC22C",
+" < c #2E367C",
+" 1 c #827EB4",
+" 2 c #2E327C",
+" 3 c #FAEAAC",
+" 4 c #FAE6AC",
+" 5 c #EAC604",
+" 6 c #7A76AC",
+" 7 c #EAC204",
+" 8 c #7A72AC",
+" 9 c #CAA234",
+" 0 c #C6C2DC",
+" q c #C6BEDC",
+" w c #F6DE94",
+" e c #726EA4",
+" r c #CEA224",
+" t c #726AA4",
+" y c #BEBAD4",
+" u c #BEB6D4",
+" i c #6A669C",
+" p c #6A629C",
+" a c #EABE07",
+" s c #B6B2CC",
+" d c #B6AECC",
+" f c #625A94",
+" g c #F6D26C",
+" h c #826A64",
+" j c #76626C",
+" k c #4E5294",
+" l c #4E4E94",
+" z c #FEFAE4",
+" x c #FEF6E4",
+" c c #F2CA54",
+" v c #9A96C4",
+" b c #464A8C",
+" n c #62526C",
+" m c #46468C",
+" M c #564E74",
+" N c #E6E6F4",
+" B c #3E4684",
+" V c #EEC63C",
+" C c #928EBC",
+" Z c #3E4284",
+" A c #FAEECC",
+" S c #3E3E84",
+" D c #FAE2A1",
+" F c #DEDAEC",
+" G c #FEEABC",
+" H c #8A86B4",
+" J c #363A7C",
+" K c #8A82B4",
+" L c #36367C",
+" P c #EAC224",
+" I c #8A7EB4",
+" U c #EABE24",
+" Y c #D6D2E4",
+" T c #D6CEE4",
+" R c #827EAC",
+" E c #2E3274",
+" W c #827AAC",
+" Q c #2E2E74",
+" ! c #FAE6A4",
+" ~ c #2E2A74",
+" ^ c #F2CE5A",
+" / c #CECADC",
+" ( c #CEC6DC",
+" ) c #7A76A4",
+" _ c #7A72A4",
+" ` c #7A6EA4",
+" ' c #DEB604",
+" ] c #C6BED4",
+" [ c #F6DE8C",
+" { c #F6DA8C",
+" } c #5E5E9C",
+" | c #F2D674",
+".  c #5E5A9C",
+".. c #7E6A6C",
+".X c #7E666C",
+".o c #AAA6CC",
+".O c #AAA2CC",
+".+ c #565694",
+".@ c #F6FAFC",
+".# c #565294",
+".$ c #F6F6FC",
+".% c #F6F2FC",
+".& c #A29EC4",
+".* c #A29AC4",
+".= c #4E4E8C",
+".- c #4E4A8C",
+".; c #EEEEF4",
+".: c #FEF6DC",
+".> c #F2CA4C",
+"., c #EEEAF4",
+".< c #FEF2DC",
+".1 c #EAE6F0",
+".2 c #9A92BC",
+".3 c #464684",
+".4 c #9A8EBC",
+".5 c #464284",
+".6 c #E6E2EC",
+".7 c #E6DEEC",
+".8 c #FEEEC8",
+".9 c #EEC634",
+".0 c #EEC234",
+".q c #FAEAC4",
+".w c #323A84",
+".e c #DEDAE4",
+".r c #DED6E4",
+".t c #2A367C",
+".y c #EAC21C",
+".u c #2A327C",
+".i c #EABE1C",
+".p c #F6E6AC",
+".a c #2E266C",
+".s c #7672AC",
+".d c #E6BE04",
+".f c #E6BA04",
+".g c #D6AE1C",
+".h c #E6B604",
+".j c #C2BEDC",
+".k c #6E6AA4",
+".l c #6E66A4",
+".z c #F6DA84",
+".x c #BAB6D4",
+".c c #F6D684",
+".v c #BAB2D4",
+".b c #66629C",
+".n c #665E9C",
+".m c #866E6C",
+".M c #B2AECC",
+".N c #B2AACC",
+".B c #5E5A94",
+".V c #FEFEFC",
+".C c #F2D26C",
+".Z c #AAA2C4",
+".A c #725E6C",
+".S c #F6F2F4",
+".D c #EECE54",
+".F c #EECA54",
+".G c #FEF2D4",
+".H c #FEEED4",
+".J c #3A4284",
+".K c #3A3E84",
+".L c #3A3A84",
+".P c #EEC62C",
+".I c #FAEEBC",
+".U c #EEC22C",
+".Y c #3E3E74",
+".T c #FAEABC",
+".R c #3E3A74",
+".E c #323A7C",
+".W c #8682B4",
+".Q c #32367C",
+".! c #867EB4",
+".~ c #32327C",
+".^ c #D2CEE4",
+"./ c #2A3274",
+".( c #EABE14",
+".) c #7E7AAC",
+"._ c #2A2E74",
+".` c #7E76AC",
+".' c #2A2A74",
+".] c #F6E2A4",
+".[ c #F6D679",
+".{ c #CAC6DC",
+".} c #CAC2DC",
+".| c #7672A4",
+"X  c #766EA4",
+"X. c #C2BED4",
+"XX c #C2BAD4",
+"Xo c #6E669C",
+"XO c #F6DA7C",
+"X+ c #BAB2CC",
+"X@ c #BAAECC",
+"X# c #92765C",
+"X$ c #9E96C1",
+"X% c #5A5A9C",
+"X& c #4A4689",
+"X* c #5A569C",
+"X= c #FEFEF4",
+"X- c #F2D264",
+"X; c #FEFAF4",
+"X: c #A6A2CC",
+"X> c #F2CE64",
+"X, c #525294",
+"X< c #9E9AC4",
+"X1 c #4A4E8C",
+"X2 c #4A4A8C",
+"X3 c #EECA4C",
+"X4 c #EAEAF4",
+"X5 c #5A4E74",
+"X6 c #9692BC",
+"X7 c #968EBC",
+"X8 c #424284",
+"X9 c #E2E2EC",
+"X0 c #E2DEEC",
+"Xq c #928AB8",
+"Xw c #464274",
+"Xe c #E2DAEC",
+"Xr c #EAC234",
+"Xt c #8E8AB4",
+"Xy c #8E86B4",
+"Xu c #3A3A7C",
+"Xi c #8E82B4",
+"Xp c #EEC224",
+"Xa c #DAD6E4",
+"Xs c #FAEAB4",
+"Xd c #EEBE24",
+"Xf c #DAD2E4",
+"Xg c #FAE6B4",
+"Xh c #323674",
+"Xj c #424687",
+"Xk c #867EAC",
+"Xl c #EABA0C",
+"Xz c #F6E29C",
+"Xx c #2A266C",
+"Xc c #F6DE9C",
+"Xv c #DEB214",
+"Xb c #FADA8C",
+"Xn c #6A66A4",
+"Xm c #D2CADF",
+"XM c #B6B2D4",
+"XN c #9A7A5C",
+"XB c #B6AED4",
+"XV c #625E9C",
+"XC c #AEAACC",
+"XZ c #AEA6CC",
+"XA c #5A5A94",
+"XS c #5A5694",
+"XD c #FAFAFC",
+"XF c #FAF6FC",
+/* pixels */
+".1XX ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ] ]XX.^.V.V.V.V.V.V.V.V.V.<.G.G x.V.V.V.V.V.V.V.<.G.G.<.V.V.V.V.V.V.V.V.V.V.V.V X.G.G.<X=.V.V.V.V.V.V.V.V.V.V.V.V.V.V X ;.p DXs AX;.V.V.V.V.V.V.V.V.G.G.<.V.V.V.V.V.V.V.V.V.V.V . A ;.8.<X=.V",
+"X<./.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.u.=XD.V.V.V.V.V.V.V.<.(.d.d V.V.V.V.V.V.V.8 a.d.d P ..V.V.V.V.V.V.V.V.V.V.V ^.f.d.f D.V.V.V.V.V.V.V.V.V.V.V.V.G g a.dXl.f.f a.y g.V.V.V.V.V.V.8 a.dXpX;.V.V.V.V.V.V.V.V GX-.i a.d.f.dXd.8",
+"X$._././.u././.u././.u././.u././.u././.u././.u././.u././.u././.u././.u././.u././.u././.u././.u././.u././.u././.u././.u././.u././.u././.u././.u././.u././.u././.u././._ QX1XD.V.V.V.V.V.V.V.T.f.fXlXl.I.V.V.V.V.V.z.f.fXl a.G.V.V.V.V.V.V.V.V.V.V x.iXl.d.fX>.V.V.V.V.V.V.V.V.V.V.V |.d.f.f.d.f.f.f.f.f c.V.V.V.V.V.V.q.f.f.yX=.V.V.V.V.V.V.V |.f.f.f.f.f.f.f a.8",
+".*.'._.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u 2._ +.@.V.V.V.V.V.V.V D.f a.d.f.c.V.V.V.V.V.0.f.d.d.f.8.V.V.V.V.V.V.V.V.V.V 4.f.d.d.d.y x.V.V.V.V.V.V.V.V.V g.f.f.d.f.U.D ^X3.y.f |.V.V.V.V.V.V A.d.f.iX;.V.V.V.V.V.VX-.f a.d.f , V.U a.( .",
+".*._.u.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u.u.u.u._ lXD.V.V.V.V.V.V.VXO.f.f.dXl.9.V.V.V.V.8 a.f.f.d.f 4.V.V.V.V.V.V.V.V.V.VX-.f.f.f.f.f D.V.V.V.V.V.V.V.V.z.f.d.f.P.TX;.V.V.V X D.8.V.V.V.V.V.V.8.d.f.iX=.V.V.V.V.VXc.f.f.fXd !X;.VX= z.q.V",
+"X<._._.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u./ 2 Q +.@.V.V.V.V.V.V.V ^.f.d.f.d.d ;.V.V.V.z.f a.d a.fXc.V.V.V.V.V.V.V.V.V.<.(.fXp V.d.fX3.V.V.V.V.V.V.V.G.(.f.f.0.H.V.V.V.V.V.V.V.V.V.V.V.V.V.V.q a.d.yX;.V.V.V.VX=.9Xl.d.( A.V.V.V.V.V.V.V",
+".*._./ 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E.u.u.u._ lXD.V.V.V.V.V.VX; ,Xl a U.f.f.[.V.V.VX3.f aXr.fXl.[.V.V.V.V.V.V.V.V.V w.f.f.[Xc.f.f a.G.V.V.V.V.V.V.[.f.d.d.T.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.qXlXl.(X=.V.V.V.V ;.d.f.f [.V.V.V.V.V.V.V.V",
+"X$._._./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u E.u.u Q +.@.V.V.V.V.V.V x a.d.y.[Xl.f ,X=.V x.(.f &.[.f.f.D.V.V.V.V.V.V.V.V.V &.f.f.T x a.d.f D.V.V.V.V.V.VX3.fXl.UX;.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V A.d.f.yX;.V.V.V.V.p.f.d.f ;.V.V.V.V.V.V.V.V",
+".* Q.u.u.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u.u.u./.u.u._ lXD.V.V.V.V.V.V.8.f.f P.I a.d.f G.V.].f.f | !.fXl.PX=.V.V.V.V.V.V.V A.d.f PX;.V.F.f.fX-.V.V.V.V.VX;Xd.d.f ^.V.V.V.V.V.VX;.T.T.8.V.V.V.V.V.V A.dXl.(X=.V.V.V.V w.f.d.d x.V.V.V.V.V.V.V.V",
+"X$._._./.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u./ 2 2.u Q +.@.V.V.V.V.V.V.].fXl & ..9.f.f |.VX-.f.fXs A.d.f a x.V.V.V.V.V.V.VXO.f.f g.V.V.].f.d.i x.V.V.V.V ..y.f.fX-.V.V.V.V.V.V A.d.f.iX=.V.V.V.V.V A.d.f.yX;.V.V.V.V {.f.f.(X;.V.V.V.V.V.V.V.V",
+"X<._.u 2 2 E E 2 2 E 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E E 2 E.u./.u E.u._ lXD.V.V.V.V.V.V.z.f.f ^.VX>.f a &.< P.f.i x.<.d.fXl.8.V.V.V.V.V.VX; V.f.dXs.V.V x U.f.f D.V.V.V.VX;.y.d.f ^.V.V.V.V.V.V A a.f.iX=.V.V.V.V.V.8.dXl.(X=.V.V.V.V w.f.d a.G.V.V.V.V.V.V.V.V",
+"X$._._.u./.u.u.u./.u./.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u.u.u.u 2.u./.u.u Q +.@.V.V.V.V.V.VX-.f.f.[.VXz.f.f.y.[ a.fX>.VX=.P.f.f D.V.V.V.V.V.V GXl.d.f.[ D w w.9.d.f.F.V.V.V.V.VXr.f.f.i x.V.V.V.V.V ;.f.f.iX;.V.V.V.V.V.q.d.f.yX;.V.V.V.V D.f.f.f 4.V.V.V.V.V.V.V.V",
+".* Q./.u.u././.u.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u././.u./.u.u 2.u._ lXD.V.V.V.V.VX; V.f.f w.V.:.d.f.dXl.d.fXg.V.V ^.f.f.[.V.V.V.V.V.V.C.f.d.f.fXl.f.h.f a.f.d.8.V.V.V.V.[.f.d.f.[.V.V.V.V.V A.dXl.(X=.V.V.V.V.V.8.dXl.(X=.V.V.V.V.I.d.d.fX3.V.V.V.V.V.V.V.V",
+"X$._._.u./.u.u.u././.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u./.u.u./ 2 2./.u.u Q +.@.V.V.V.V.V ..(Xl.f.p.V.V ^.f.d.d.f.y x.V.V |.f.fX>.V.V.V.V.V xXd.f a a.d.( a.y a.d a.f.c.V.V.V.V A.d.d.d.d D.V.V.V.V AXl.d.yX;.V.V.V.V.V.q.d.f.yX;.V.V.V.V XXp.f.f.f.[.V.V.V.V.V.V.V",
+"X<._.u 2 E 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E.u./.u 2./ E.u._ lXD.V.V.V.V.V A.d.f a.8.V.V.].f.d.d.fX>.V.V.V w.f.d V.V.V.V.V.V.].f.f a.8X; . X .X; |.f.d.9X=.V.V.V.V.[.fXl.d a ^ DXs 4 |.fXl.(X=.V.V.V.V.V.8.dXl.(X=.V.V.V.V.VXb.f a.d.f %Xc 4 D.[ V.<",
+"X$._._./.u./.u.u./.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u.u./.u 2.u././.u.u.u Q +.@.V.V.V.V.V 4.f.d.d.<.V.V x a.f a.f D.V.V.V 4.f.f.( x.V.V.V.V ^.f.f c.V.V.V.V.V.VXsXl.f.f.T.V.V.V.V . ^.f.f.f.f.f.d.f.f.d.f.(X;.V.V.V.V.V.q.d.f.yX;.V.V.V.V.VX= ^.f.f aXlXl.f.f.f.f G",
+".* Q.u.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u././.u./.u./.u.u 2.u 2.u._ lXD.V.V.V.V.V [.h.fXpX=.V.V.V ^.f.f.f.8.V.V.V.8Xl.fXl.8.V.V.V.< a.f.f D.V.V.V.V.V.VX=Xp.f.h.C.V.V.V.V.VX=.z.y.d.f.f.f.h.f.d a &X=.V.V.V.V.V ;.d.f.(X=.V.V.V.V.V.V ..[ a.d.f.h.h.f.f.d 4",
+"X$._._.u./.u././.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u.u.u./ 2 2./././.u.u Q +.@.V.V.V.V.V.8 D.p.p.V.V.V.V.G D.p 3X;.V.V.VX= 3 !.p x.V.V.V x.p.p.p ..V.V.V.V.V.V.V.T !.p.T.V.V.V.V.V.V.V x G w.z.z [ w.p.GX=.V.V.V.V.V.V . 4 !Xg.V.V.V.V.V.V.V.V.V.:Xg w.z [ w !.qX;",
+"X<._./ 2 2 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 E 2.u.u./ 2.u 2./ 2.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$._._././.u./.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u./.u.u E./.u./.u./.u.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+".* Q.u.u./.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u./.u.u.u.u.u E.u E.u E.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$._._.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u.u.u././.u.u./.u././.u.u./.u.u./.u.u./.u.u./.u./.u.u./ E 2./.u.u.u./.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X<._./ 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2.u Q Q Q ~.'._._._.u.u 2._._ Q.'.' Q Q 2 E 2 E 2 2 2 2 E 2.u.u./ 2./ 2./ 2.u 2.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$._._./.u.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./._.'._.E b.b RX7.OXZ.v u.{ yXBXZ.& = _ l <._._._.u././.u./.u./ 2./.u.u.u./.u.u./.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+".* Q.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u._._.'.uX1.!XBX0XD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.rX$.b <.'._.u.u./.u./.u./.u E.u E.u 2./ E.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$._._./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u._._ <XS.2XfXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.VXa R :._./.u.u.u 2 2./.u./.u.u./.u.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X<._.u E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2.u Q Q S H.r.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V TX, Q./././.u 2.u 2./ 2.u E.u 2.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$._._.u././.u.u./.u././.u.u./.u././.u.u./.u././.u.u./.u./.u._.' Q l.& @.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.$ W Q 2.u./.u././.u.u./.u./.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+".* Q.u.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u./._ JXn.xX;.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.VX< 2.u./ 2.u E.u 2./ 2./ 2.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$._._.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u._._.l F.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V d E.u.u./.u.u./.u.u.u.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X<._./ 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 E 2 2 Q ~X,X..V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V X X.V.V.V.VXi._ 2./ E.u E.u E./ 2.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$._._./.u././.u.u./.u././.u.u./.u././.u.u./.u./.' - v.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V xXp V.V.V.V.V @.=._.u.u.u.u./.u.u.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+".* Q.u.u.u.u./.u.u./.u.u./.u.u./.u.u./.u.u./.u._XS.e.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V xXsXs.I.8.8.G xX=Xg.fXl.:.V.V.V.V.& Q./ E.u 2./ 2./ E.u._ lXD.V.V.V.V.V.V @.^X4.V.V F.r.V.V.V.V.V.V.VX$.M.V.V.V.V.V.V.V.V.V.V.V.V.V.VX0 Y.V.V.V.,.1.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V u.b.7.V.V.V.V.V.V.V.V.V.V.V.V.*.{.V.V.V.V.V",
+"X$._._./.u./.u.u./.u.u./.u.u./.u.u.u.u./.u Q._ 6XF.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.GXd.f.fXl.f.f.f a a aXl a x.V.V.V.V.6 J.u.u.u./.u./.u.u.u Q +.@.V.V.V.V.V.V.* ~ _.VXD m -.%.V.V.V.V.VXF.K.n.V.V.V.V.V.V.V.V.V.V.V.V.V.@ b./ q.V.VX1Xy.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V v.'.^.V.V.V.V.V.V.V.V.V.V.V.@.K K.V.V.V.V.V",
+"X<._.u 2 2 E E 2 2 E 2 E 2 2 E E E E 2./._.5XZ.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V [.f a.i a 7 a.d.f.f.d.d g.V.V.V.V.V.V _._ E.u 2.u 2.u 2.u._ lXD.V.V.V.V.V.V.)Xx Z #.^ E.uXe.V o.!X$X4.V K.O.VXaX7X7 /.V T.NX$Xe.V.V.V.x._._.`.VX@.Q. .} NXC.vXq /.MXy.{.V.$.ZXyXCXF.V y WXM.V.MXB.2.M.VX<./.2Xq /.V.%.O.! u.V.^XCX$ /X$XX.VXa.2Xq.6",
+"X$._._.u./.u.u.u./.u./.u.u./.u.u.u.u._ ~ t @.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V {.h V .X; X.G.8.8.I.T.G.V.V.V.V.V.V.V (.t.u.u././././.u.u Q +.@.V.V.V.V.V.V } 2._.M.W < < s.VXn R JX .V Z e.$.5 b m 2XaXqXx b Y.V.V.V tX2Xo.QX4 v.tXj o.v Q ZX2 2.- S.K.V I <X* Q.!XX 2.s.M.@.L < k Q.MXZ.'X8 mX&.V e J e JX0Xy.a Z.xX%XqX0.QX8XV.^",
+".* Q./.u.u././.u.u.u./.u.u./.u./.u.u.uXy.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V 4.f a.G.V.V.V.V.V.V.V.V.V.V.V.V.V.V.VXFX1 Q.u 2.u 2./ 2.u._ lXD.V.V.V.V.VXF.J t Z fX2X  <Xq.V YX7.KX*.@ S.s d.QX4X0._.2X7 :.;.V.V.V.$ m.W.x.' o.V.5Xy.VXB._.NXC.u.6Xq 2X0 Z v.V.B mX:.' W.,.$ <Xo @.u WX:._XXXZ - > : Z i._.OXq._Xa.VX1X7X7._Xe.V.V",
+"X$._._.u./.u.u.u././.u.u./.u./.u._._.2.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.G.d.f {.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V 6._.u./.u./.u.u.u Q +.@.V.V.V.V.V.6.uX6.` QXh.x <.` Y.KXn SXAXF Z.|.& -XFX0 Q.2Xt k.V.V.V.V Y.u L -._.b.VXj K.VXM._ /XC.E.V =.t.e L o.V.b ZXDX:.~X&X4 <Xy.V._ K.Z.uXeXZ.KX0 2XS.O o., K 2.%.V +.2 =._X4.V.V",
+"X<._.u 2 E 2 E 2 2 E 2 2 2 2 2 2 QXy.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.VX;Xr.f ^.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.O E.u E.u E.u E.u._ lXD.V.V.V.V.VXX.'X+.xXx S.;X2.B =.' K L.+.$ SX Xf E i.#.Q.7 W +.V.V.V.VXkX8 d u.n Q T.- m d.v.'.}XZ L.VXy Q @ f Z.|._ K.6X6.3.Y.1 :.+ e 2 /.*._Xa.O L.;X, SX$Xt.;.! E.%.VX2Xq.M ~X*.`.^",
+"X$._._./.u./.u.u./.u.u./././._._X7.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V |.f.( x.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V Y.u./.u.u.u./.u.u Q +.@.V.V.V.V.V 0.n Y.%Xn =.VXi 8 F i.+ tXy.@ ZXn.VX7 bXSXM.V.Z.!.V.V.V.V.!X<.V.V 0X%.jX$ bXy /.bX0 0 e.V d.bXD TX*X2 K.V (.=. .{.@ -.L.+XZ.V u.n.,.} tXDXa pX2XS.1XZ i.@.V WXZ.V K.= k.^",
+".* Q.u.u.u./.u.u./.u.u.u.u./ 2X6.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.VXs.f.f D.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.$.K./ E.u 2.u 2.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V #.v 2X .V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V @.u.!.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$._._././.u.u./.u././.u._._.&.V.O.`.* yX0.$.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V ..P.fX>.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.B._.u.u././.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.{ -X2 T.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.S BXq.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X<._.u 2 E 2 2 E 2 2 E.u Q.!.VXX <.'._ 2 < Z.+ tXqXC.{.,.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V |.fXpX=.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V p._ E.u 2./ 2.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.$.;.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.S.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$._._./.u.u./.u.u.u.u Q.+.V.6X8.'.u._./ Q Q Q._.' Q.u.E mXV.) v.x Y @.V.V.V.V.V.V.V.V.V.V.VX= w ^ ^ ^X-X-.[.[ [X3.f.( X.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V W.'.u.u./.u.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+".* Q.u./.u.u./././.u.u.u q.V. ._.u 2.u.u.u.u 2.u.u.u.u Q._._.'.'.u 2 :X,Xn.{.V.V.V.V.V.V.V.V.[.f.f.f.h.h.f.f.h.h.f.h.>.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V H.' E.u E.u E.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$._._.u.u./.u.u.u./.'Xo.V.).'.u././.u.u.u.u.u./.u./ 2.u.u 2./.u._.u._._ ~ :.x.V.V.V.V.V.VX;.0.f P ^.D VXr ,Xp.y P  .G.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.VXi.'.u.u.u./.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X<._./ 2 2 E 2 E 2._ ZX4.2._._ 2.u./.u./././ 2./ 2././.u./ 2./.u E.u.u./ E._ 2 RXD.V.V.V.V.VX3.f ^.V.V.VX;X; . .X;.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.VXy.' E.u 2.u 2.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$._._.u./.u./.u.u._.*.r L._ 2./.u 2 E 2 2.u.u 2.u.u.u E.u.u.u./.u 2 E.u.u.u./.'.b @.V.V.V.V {.h UX=.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.VXy.'.u.u././.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+".* Q.u.u.u.u./.u Q.3.V.4 ~.u.u E.u.u./.u E././.u./ 2.u./.u.u 2./.u.u.u./.u 2.u.u.'.+X4.V.V.V.8.dXl.I.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.W.' E.u 2./ 2.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$._._./././.u.u._Xq.V q.u././.u.u./.u./.u.u.u./ 2.u./ 2./ E./.u.u./ E.u E.u E.u.u.'XV @.V.VX=.0.h.c.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V t._.u.u./.u.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X<._.u 2 2 E.u._ LX0.V @.K Q.u./.u.u.u.u E.u 2./.u.u./ 2.u.u E.u.u.u 2.u./.u./ 2.u./.'X,.6.V.V.[Xl %.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.VXV._ E.u E.u E.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$._._./.u.u 2 Q.k.V.V.V.+._./ 2 E 2 E./.u E./.u.u E.u.u.u./.u 2 E./.u./.u.u.u./.u.u.u._ m.^.V 4.f a.<.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V l._.u.u.u./.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+".* Q.u././.u.u._XB.V.V.V 8._.u.u./.u 2.u.u.u./ 2.u./././ 2./.u.u.u./.u E.u E.u E._ Q Q.u ~.E vX;.U.f w.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V @Xu./ E.u 2.u 2.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$._._.u.u./._.J #.V.V.V.* Q._./.u./.u./.u./ 2.u./ 2.u 2.u.u./.u E.u E.u 2._.u.RX5 M *Xu J././XyX-.hX-.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V (.t.u.u.u././.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X<._.u E.u.u ~ i.V.V.V.V Y <.u.u.u./ 2./ 2./.u.u./ 2././ 2.u./.u 2.u./.u.u Q...h a.d.fXvXvXv.g rXl.f g.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V o._./ 2.u 2./ E.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$._._.u 2.u.'Xq.V.V.V.V.$ b Q 2 E.u.u 2./.u.u E.u./.u.u.u E 2.u././.u.u./.Y ' 7.f a a.d 7 7 7 5 7.g.p.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.!.'.u./.u./.u.u.u Q +.@.V.V.V.V.V.V.V T.!XnX  /.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.VXDXy u.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V F.KX$.V.V.V.V.V.V.V.V.V.V.V.V.V",
+".* Q./.u E.u.u.x.V.V.V.V.V 8.'.u E./.u.u./ 2.u.u.u./ 2./.u./.u.u.u E.u.u._Xw.f 7.X *X5X5 n.A.X.m jXu.kXF.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.VXA._.u E.u 2.u 2.u._ lXD.V.V.V.V.V.V.O./.QX, S.&.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V @ Q W.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V >.+XC.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$._._./.u./ < F.V.V.V.V.V.Z./._.u.u.u./ 2././ 2./ 2./.u./.u E.u E.u E.u.u.u 9 5X#._ Q._./._._._._._.'.+Xa.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.6.L Q.u.u./././.u.u Q +.@.V.V.V.V.V.6 J.=X4.V.V.V.VXMX%. .kX0.V oXn eX*X7Xn.+.v.V YXn.s.+ K.!X,X$.VXDX X%. .M.V.V.V.V.V.V.V #.t.!.V.M.l.kX*X7X .+XX.V FXn. .b T.V @ K. . .  /.VXV.N.V.W eXn.+XC.V.; W.  f.+.o",
+"X<._._.u.u._.K.S.V.V.V.V.V.6 :._ E.u 2./.u.u./ 2.u.u 2.u./.u E.u./.u E.u./._ h 5XN./././././././ 2.u.u._ :XB.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.O././.u 2.u 2./ 2.u._ lXD.V.V.V.V.VXB QXZ.V.V o q.V (.N o./ o.V I.aXy.n._ $X8XS.VXX.'X .|Xx.k 6 S O.@XZX. f.#.V.V.V.V.V.V.V @.t.!.VX7XxXt. .' HXAX*.V.6.o yX8X .VXq._Xa W L.6 @._Xy.V.# Q $ m.#.V 1 2X0.`.a /",
+"X$._.u.u./._X,.V.V.V.V.V.V.VXA._.u 2./.u.u E.u.u././.u E 2.u.u.u.u.u.u E.u./ E MXh./.u.u 2.u.u.u.u.u 2 2 Q E.O.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.VX .' 2././.u./.u.u.u Q +.@.V.V.V.V.V s.' v.V.VX& W.VXaXn b._ o.V R <.VXk.#.V.+.+.VX. <.6 o E T u - #.VX$X, :.+.V.V.V.V.V.V.V # 2 R.V =.K.V K <.VXk k.VXF KX2.t.k.VX7._.*.nX*.V.,._Xq.V.+X,.V.  +.VXy <X: f.K.%",
+".*._./ 2 2 Q. .V.V.V.V.V.V.VXy.'./.u.u E.u./.u.u 2./.u./.u././ E.u./.u.u.u./._ Q._.u./.u./ 2 E./ E./.u.u.u._ S.%.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V @X8._ 2.u E.u E.u E.u._ lXD.V.V.V.V.V N LX8 /.%X2 K.VXSX&.x <X:.V W.K.V R.+.VX,X,.VXX JXDX<./ F.v -XD.j._X$ eX,.V.V.V.V.V.V.V @ <.!.VXq Z.VXk.K.V W k.VXq._XBX2Xn.V.{.uXj iXa.V.,._Xq.VX,. .V. X,.V.x._ b.b.}.V",
+"X$ Q.u./.u._XV.V.V.V.V.V.V.V.x./.u.u E.u.u 2./ 2./.u.u.u E.u 2.u E.u.u 2./.u.u.u.u E 2./ 2./.u.u.u.u./.u./._.uXX.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.{.u.u.u.u.u.u.u./.u.u Q +.@.V.V.V.V.V.V.Z < 2.t.' C.V.b < b.uX$.V 1 -.V WXS.V.+.+.V.j LXD.*._.e.vXu.@.{.uXj.LX1XD.V.V.V.V.V.V #.u W.VXq S.V 1.K.V.!.=.V v Q k./ t.V.v./ SX, K.V.;.uXq.VX,XA.VX% +.V o._X8X, ).,",
+"X$ ~._.u./._.b.V.V.V.V.V.V.V.;.K E.u./.u./ 2./.u E.u./.u 2./.u.u E.u./ 2 2.u.u./.u.u.u.u.u.u E.u./.u E 2.u./._ K.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.VX$._./ E./ 2./ 2.u 2.u._ lXD.V.V.V.V.V.V.VX0 o v d @.V.7X$ u.} F.VXf y.VXa.{.V 0.{.V.;.xX;X0.v.$X4 uX;.V uX< / 0.V.V.V.V.V.V.V.V.x.r.V FXX.V Y y.VXf.}.V.@XZ.O ( /.VX$.w.2 8 QXX.V.v F.V.} /.V /.}.VXy :.2 W.' $",
+".*._.u./.u._XV.V.V.V.V.V.V.V.V.b.'./.u E.u.u.u.u.u E 2.u./.u.u./.u E.u././.u./.u.u./ E.u././.u./ 2 2.u./ 2 2.'X,.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.B._.u.u.u./.u.u./.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V 8./X$.| Z F.V.V.V.V.V.V.V.V.V.VXo.Q.*.).QXX",
+"X<._.u 2.u.'. .V.V.V.V.V.V.V.VX$.'./.u./.u./ E.u.u./.u.u./ E.u.u.u./.u.u E 2 2./.u.u./ 2 2.u 2./.u.u.u./.u.u./.u T.V.V.V.V.V.V.V.V.V.V.V.V.V.VXX._.u./ 2.u E.u 2./ E.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.,Xq p 1X9.V.V.V.V.V.V.V.V.V.V.V.1 H.b.`.^.V",
+".*._._.u E./ bXF.V.V.V.V.V.V.VXm <.u.u 2./ 2.u././.u 2./ 2.u E.u./ 2.u.u.u.u./ 2 2./ 2.u./.u./.u./.u./.u.u./.u QX6.V.V.V.V.V.V.V.V.V.V.V.V.V.V.k Q./.u././.u.u./.u.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$ Q./.u.u._ J @.V.V.V.V.V.V.V.$.3 Q.u 2./.u 2.u./.u 2./.u.u E.u./ 2 E././.u./.u.u./.u.u E.u./.u E 2./.u 2./.u ~ p.V.V.V.V.V.V.V.V.V.V.V.V.VXf.Q Q 2.u 2./ 2.u E.u 2.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+".*._._././.u.t (.V.V.V.V.V.V.V.VXk.'._./.u./.u E 2.u./.u.u./.u 2.u./.u.u.u.u.u./ E.u.u./.u.u 2 2.u./ 2 2./ 2./.u.K.,.V.V.V.V.V.V.V.V.V.V.V.V.)._.u.u.u./.u.u./.u./.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+".*._._ 2.u.u.u.O.V.V.V.V.V.V.V.V.V.!._._ 2./.u./.u.u./ E.u./.u./.u./ 2 E E.u.u.u./ 2 2./ E./.u./.u./.u.u.u.u./.u.uXB.V.V.V.V.V.V.V.V.V.V.VXe :./.u E.u E.u 2./ 2./ 2.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$._.u.u././.'.`.V.V.V.V.V.V.V.V.V.V I.u./.u./.u 2./ 2.u 2.u./ 2.u.u./.u.u E 2./ 2.u./.u.u.u./.u.u.u././.u E.u./.'.`.V.V.V.V.V.V.V.V.V.V.V.|.'.u./.u./.u.u./.u.u.u.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+".*._._ 2 2 2 QX2XD.V.V.V.V.V.V.V.V.V.V.N L._.u./ 2.u././ 2.u./ 2 E.u.u./.u./.u./.u.u E.u./.u E 2./.u 2./.u E.u./._ mXF.V.V.V.V.V.V.V.V.V.x.u./ 2.u 2./ 2.u E./ 2./ E.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$ Q.u.u./.u./.t /.V.V.V.V.V.V.V.V.V.V.V 0 S ~.u././.u.u.u E.u./.u.u./.u.u.u E.u.u./.u./ 2 2.u./ 2 2./ 2.u.u 2.u.u.u 0.V.V.V.V.V.V.V.VXD + Q 2.u././.u.u./.u.u./.u.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$._./.u./.u.u.'Xy.V.V.V.V.V.V.V.V.V.V.V.V YX2.'.u E.u./.u.u.u./ 2 2 E.u./.u./ 2 2.u 2./.u./.u.u./.u./.u././ 2././.'Xq.V.V.V.V.V.V.V.VX$.'._.u 2.u E.u 2./ 2.u 2.u 2.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+".*._._.u.u.u 2 QX2.@.V.V.V.V.V.V.V.V.V.V.V.V.6.+ ~.u E.u./ E./.u.u./.u E 2.u 2././.u./.u./.u.u./.u.u.u E.u.u./.u 2 QX*.V.V.V.V.V.V.V.6.L.u.u./.u./.u.u./.u././././.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$._._ E.u./.u.u QXB.V.V.V.V.V.V.V.V.V.V.V.V.V.;.#.'._.u.u 2 E.u.u./.u./.u./.u.u E.u.u.u E 2.u./ 2./.u E.u.u 2./.u./.EX0.V.V.V.V.V.V H.'./ 2./ 2./ 2.u 2.u 2.u 2./ 2.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+".* Q.u.u E.u./.u._X,XD.V.V.V.V.V.V.V.V.V.V.V.V.V.; 8 Q E.u./.u.u./.u.u.u E.u.u./.u.u E E.u.u E 2./ 2.u.u E././.u.u._ ~.*.V.V.V.V.V.M 2 E.u.u.u.u.u./././.u./.u./.u.u.u Q +.@.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X< Q./.u.u.u./.u./._X:.V.V.V.V.V.V.V.V.V.V.V.V.V.V.VXq./._.u E 2 E.u./.u.u E 2./ 2.u.u./.u.u./.u./.u./.u 2.u./.u.u.u.' i.V.V.V.V F.K.' E.u E./ 2.u 2.u E.u E.u E.u E.u._ lXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$._.u./ 2 E.u.u.u Q.3 #.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V o < Q.u./.u E 2.u E.u./.u.u././.u.u./.u.u.u E.u.u./.u 2 E./.u./.K #.V.VXDXS Q.u.u./.u.u./.u./.u.u.u.u.u.u./.u.u Q +.@.V.V.V.V.V.V.V.V.^XX.6.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V @Xn u.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V Y.^ Y.^ Y.V.V.V.V.@.l.O.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+"X$.'.u./.u E 2 E.u 2._ K.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.x J._.u.u./.u.u.u.u E.u.u.u E 2.u./ E.u.u 2./.u E.u.u 2./ 2.u.u d.V.V.`.'.u./ 2./ 2.u E.u E./ 2./ E.u 2.u 2.u._ lXD.V.V.V.V.V.V.^.=.u._.b.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.1._.2.V.V.V.V.V.V.V.V.V.V.V.V.V.V.,.K.u 2.u -.;.V.V.V @ Q.!.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V",
+".*._./.u.u.u./.u.u.u._ < T.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V /.K._./.u E.u././.u.u E E.u.u E 2.u 2././ 2.u.u././.u 2.u._.' o.VX$./.u E.u.u.u.u./.u.u.u.u./.u.u.u././.u.u Q +.@.V.V.V.V.V.V.- 2 o y q.V.{ K.v.V.;XXXB q.VXZXyXe.V (.{XC.2 # # <.*.;.N.,.$ oXqXa @.v.,.V.}.}.V.V.{Xq./XqXmX0X7.*.%.%.t R.V TXy.oXD.V.j K.v.VXFXZ.2.,.V.MXy /.VXa y uXqXa.V @.& = F.V",
+".*.'./.u./.u./.u.u.u.u._.l.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.VXX.L.'.u./ 2 2./ 2.u.u./.u.u./.u./.u.u./ 2./.u.u././.u.u.'.s.V.M 2./.u E.u E./ 2./ 2./ 2.u E.u E.u 2./ 2.u._ lXD.V.V.V.V.V (._ K.V.V.VXZ <X1.tX$ /.t._X7 R : b.=.%. ._ -._X7XD.tX7.+X8 FX% 2.t :.v.K.2.$ <.|.V.V.V.v._.x.V.+.3 J i.S <Xy T :X2.t KXX.uX2X7.V i._.K.{ `.u < :X0Xq.' -.uX,XDXV -Xj ZX9",
+"X< Q._ E.u.u.u E.u E E.u._.`.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V F.B.'.u.u./.u.u././.u.u./.u./.u E.u.u./.u E 2.u.u._._ R.V y 2._.u.u.u./.u.u.u.u./.u.u./.u./.u././.u.u.u Q +.@.V.V.V.V.V.N ~X$.V.V.V f < p.~XS.j.u.M Y 2XjXV._ yXV S.1XV.k.@ : <.LX9X$ Q /.6 2 _.lX2 C._ (.V.V.VX+.u qXX._.b.3.~X0.Q K.|./ p S.5X$ QX X0 0.'X<.V y._.&XD.3Xq.2._Xm.N.KXZ Q.=XS ~.*",
+"X<._.u 2 E E.u E.u.u./ 2.u Q K.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.@X ._.'._._._._.u./.u.u 2.u.u E.u.u 2.u./ 2./.u.'X .V (.K Q 2././ 2./ 2./ E.u E.u 2./ 2.u 2.u E.u E.u._ lXD.V.V.V.V.V (._.k.V.V.V.+Xj o.o 0XX :.$.{ Q i.o.ZX9.+.+.V p p.S J J.Q.rXy._.6.@ < WXZ._ <X%.V.V.V.V.v./ q.N.uX7.oXC.,.E.!.b -X<.o.M #X$ J.-XZ._XB.VXB Q.v.VX2XyX7.u.V.N S o.u 8.o.ZXa",
+"X$ ~._._._._._._._._.'._._.'.'.!.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.VXD.vXq tX* Z <./ Q._ Q._ Q._._ ~._._._._._ Q.'Xn.VXX.QXx._.' Q._._._._._._._._._._._._._._._._._._._.'.-.@.V.V.V.V.V.V f.aX,XV 1.`._ H I.v ] L.,XD Z.5X7.W.S.# +.V.b p.$.~XyX&X2.o QXS.n._ y.$.K.a.*.V.V.V.VX+.' y.6 L t =.2X4._XyX$.' WXy.* TX6 m S / 2.3.`XZ.Q b t <XaXq._ RXjX, F JX,.2 W.7",
+"XM.#XSX*X*XSX*XSX*. XAXSX%XS.+.+ u.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.VXFX0 y.*.)XVXSXSX*XAXSXSXSX*XAX%.+Xo @.,Xn.+X*XAX%. X%. XA. X%.BX%.BXA. X%.BXA.BX%.BX%. . .+ 8.V.V.V.V.V.V.VX4.W.#.= =.;.`X1.=XCXa.k @.V /.b m.lXFXi K.VX7X7.$ i 0XXXS.{ o kX,XZ.V.VXq.b.,.V.V.V.VXmXVXm.VXC kX1Xk.@.l.O.V K lX2X$XXX2XV q.VXCX,.+Xa.vX*X2X<.V H.'.-.l T.V.xXAX1XV.7",
+".V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.$.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.VXDXD.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V I.u.;.V.V.V.V.V.V.V.V",
+".V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.V.VXi < @.V.V.V.V.V.V.V.V"
+};
Index: /tags/Mars_V0-8-5/Mars/manalysis/AnalysisIncl.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/AnalysisIncl.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/AnalysisIncl.h	(revision 9661)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-8-5/Mars/manalysis/AnalysisLinkDef.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/AnalysisLinkDef.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/AnalysisLinkDef.h	(revision 9661)
@@ -0,0 +1,58 @@
+#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 MCerPhotEvtIter+;
+#pragma link C++ class MCerPhotAnal+;
+#pragma link C++ class MCerPhotAnal2+;
+#pragma link C++ class MCerPhotCalc+;
+
+#pragma link C++ class MCameraData+;
+
+#pragma link C++ class MHPedestalPix+;
+#pragma link C++ class MHPedestalCam+;
+
+#pragma link C++ class MGeomApply+;
+
+#pragma link C++ class MHadronness+;
+
+#pragma link C++ class MCompProbCalc+;
+#pragma link C++ class MMultiDimDistCalc+;
+
+#pragma link C++ class MEnergyEst+;
+#pragma link C++ class MEnergyEstimate+;
+#pragma link C++ class MEnergyEstParam+;
+#pragma link C++ class MEnergyEstParamDanielMkn421+;
+
+#pragma link C++ class MMatrixLoop+;
+
+#pragma link C++ class MSigmabar+;
+#pragma link C++ class MSigmabarCalc+;
+#pragma link C++ class MSigmabarParam+;
+
+#pragma link C++ class MEventRate+;
+#pragma link C++ class MEventRateCalc+;
+
+#pragma link C++ class MParameterI+;
+#pragma link C++ class MParameterD+;
+//#pragma link C++ class MParameters+;
+
+#pragma link C++ class MMcTriggerLvl2+;
+#pragma link C++ class MMcTriggerLvl2Calc+;
+
+#pragma link C++ class MSupercuts+;
+#pragma link C++ class MSupercutsCalc+;
+#pragma link C++ class MFindSupercuts+;
+#pragma link C++ class MMinuitInterface+;
+#pragma link C++ class MFiltercutsCalc+;
+
+#pragma link C++ class MPedestalWorkaround+;
+
+#pragma link C++ class MSourcePosfromStarPos+;
+#pragma link C++ class MMcCalibrationUpdate+;
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/manalysis/MCameraData.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MCameraData.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MCameraData.cc	(revision 9661)
@@ -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, 10/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Hendrik Bartko, 08/2004 <mailto:hbartko@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MCameraData
+//
+// This is a generalized class storing camera data. For example the cleaning
+// level for the image cleaning is one possibility.
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCameraData.h"
+
+#include "MCerPhotEvt.h"
+#include "MCerPhotPix.h"
+
+#include "MGeomCam.h"
+#include "MGeomPix.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MPedPhotCam.h"
+#include "MPedPhotPix.h"
+
+#include "MSigmabar.h"
+
+ClassImp(MCameraData);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Creates a MCerPhotPix object for each pixel in the event
+//
+MCameraData::MCameraData(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MCameraData";
+    fTitle = title ? title : "Generalized storage container for camera contents";
+}
+
+/*
+// --------------------------------------------------------------------------
+//
+// This is not yet implemented like it should.
+//
+
+void MCameraData::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);
+}
+*/
+
+
+// --------------------------------------------------------------------------
+//
+// Function to calculate the cleaning level for all pixels in a given event
+// as the ratio between the measured photons and the pedestal rms.
+// In order to do the image cleaning on average in the same photon flux
+// (reconstructed photons per pixel area) for the inner and outer pixels,
+// a correction factor is applied to the outer pixels (see TDAS 02-14).
+// The correction factor assumes the ideal case that the pedestal rms 
+// scales with the inverse square root of the pixel area.
+//
+// FIXME: Should the check noise<=0 be replaced by MBadPixels?
+//
+void MCameraData::CalcCleaningLevel(const MCerPhotEvt &evt, const MPedPhotCam &cam,
+                                    const MGeomCam &geom)
+{
+    const Int_t n = geom.GetNumPixels();
+
+    fData.Set(n);
+    fData.Reset();
+
+    fValidity.Set(n);
+    fValidity.Reset();
+
+    const Int_t entries = evt.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++)
+    {
+        const MCerPhotPix &pix = evt[i];
+
+        const Int_t idx = pix.GetPixId();
+        const Float_t noise = cam[idx].GetRms();
+
+        if (noise<=0) // fData[idx]=0, fValidity[idx]=0
+            continue;
+
+        //
+	// We calculate a correction factor which accounts for the 
+	// fact that pixels have different size (see TDAS 02-14).
+	//
+        fData[idx] = pix.GetNumPhotons() * geom.GetPixRatioSqrt(idx) / noise;
+        fValidity[idx] = 1;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Function to calculate the cleaning level for all pixels in a given event
+// as the ratio between the measured photons and the pedestal rms.
+// In order to do the image cleaning on average in the same photon flux
+// (reconstructed photons per pixel area) for the inner and outer pixels,
+// a correction factor is applied to the outer pixels (see TDAS 02-14).
+// The correction factor takes the actual average pedestal RMS of the
+// inner and outer pixels into account.
+//
+// FIXME: Should the check noise<=0 be replaced by MBadPixels?
+//
+void MCameraData::CalcCleaningLevel2(const MCerPhotEvt &evt, const MPedPhotCam &cam,
+                                     const MGeomCam &geom)
+{
+    const Int_t n = geom.GetNumPixels();
+
+    fData.Set(n);
+    fData.Reset();
+
+    fValidity.Set(n);
+    fValidity.Reset();
+
+    const Int_t entries   = evt.GetNumPixels();
+    const Float_t anoise0 = cam.GetArea(0).GetRms();
+    if (anoise0<=0)
+        return;
+
+    //
+    // 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++)
+    {
+        const MCerPhotPix &pix = evt[i];
+
+        const Int_t   idx   = pix.GetPixId();
+        const Float_t noise = cam[idx].GetRms();
+
+        if (noise<=0) // fData[idx]=0, fValidity[idx]=0
+            continue;
+
+        //
+	// We calculate a correction factor which accounts for the 
+	// fact that pixels have different size (see TDAS 02-14).
+	// We also take into account that the RMS does not scale 
+	// with the square root of the pixel area.
+	// 
+        const UInt_t  aidx  = geom[idx].GetAidx();
+        const Float_t ratio = cam.GetArea(aidx).GetRms()/anoise0;
+
+        fData[idx] = pix.GetNumPhotons() * geom.GetPixRatio(idx) * ratio / noise;
+        fValidity[idx] = 1;
+    }
+}
+
+
+void MCameraData::CalcCleaningLevel(const MCerPhotEvt &evt, const MSigmabar &sgb,
+                                    const MGeomCam &geom)
+{
+    CalcCleaningLevel(evt, sgb.GetSigmabarInner(), geom);
+}
+
+void MCameraData::CalcCleaningLevel(const MCerPhotEvt &evt, Double_t noise,
+                                    const MGeomCam &geom)
+{
+    const Int_t n = geom.GetNumPixels();
+
+    fData.Set(n);
+    fData.Reset();
+
+    fValidity.Set(n);
+    fValidity.Reset();
+
+    if (noise<=0)
+        return;
+
+    const Int_t entries = evt.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++)
+    {
+        const MCerPhotPix &pix = evt[i];
+
+        const Int_t idx = pix.GetPixId();
+
+        //
+	// We calculate a correction factor which accounts for the 
+	// fact that pixels have different size (see TDAS 02-14).
+	//
+        fData[idx] = pix.GetNumPhotons() * geom.GetPixRatio(idx) / noise;
+        fValidity[idx] = 1;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Function to calculate the cleaning level for all pixels in a given event
+// as the ratio between the reconstructed number of photons per area of an
+// inner pixel and the average pedestal RMS of the inner pixels (democratic
+// image cleaning, see TDAS 02-14).
+//
+// FIXME: Should the check noise<=0 be replaced by MBadPixels?
+//
+void MCameraData::CalcCleaningLevelDemocratic(const MCerPhotEvt &evt, const MPedPhotCam &cam,
+                                              const MGeomCam &geom)
+{
+    const Int_t n = geom.GetNumPixels();
+
+    fData.Set(n);
+    fData.Reset();
+
+    fValidity.Set(n);
+    fValidity.Reset();
+
+    const Int_t   entries = evt.GetNumPixels();
+    const Float_t noise0  = cam.GetArea(0).GetRms();
+    if (noise0<=0)
+        return;
+
+    //
+    // 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++)
+    {
+        const MCerPhotPix &pix = evt[i];
+
+        const Int_t idx     = pix.GetPixId();
+        const Float_t noise = cam[idx].GetRms();
+
+        if (noise<=0)
+            continue;
+
+        //
+        // We calculate a correction factor which accounts for the
+        // fact that pixels have different size (see TDAS 02-14).
+        //
+        fData[idx] = pix.GetNumPhotons() * geom.GetPixRatio(idx) / noise0;
+        fValidity[idx] = 1;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the contents of the pixel.
+//
+Bool_t MCameraData::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
+{
+    if (idx<0 || idx>=fData.GetSize())
+        return kFALSE;
+
+    val = fData[idx];
+    return fValidity[idx];
+}
+
+void MCameraData::DrawPixelContent(Int_t num) const
+{
+    *fLog << warn << "MCameraData::DrawPixelContent - not available." << endl;
+}
Index: /tags/Mars_V0-8-5/Mars/manalysis/MCameraData.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MCameraData.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MCameraData.h	(revision 9661)
@@ -0,0 +1,58 @@
+#ifndef MARS_MCameraData
+#define MARS_MCameraData
+
+#ifndef ROOT_TArrayD
+#include <TArrayD.h>
+#endif
+#ifndef ROOT_TArrayC
+#include <TArrayC.h>
+#endif
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+#ifndef MARS_MCamEvent
+#include "MCamEvent.h"
+#endif
+
+class MGeomCam;
+class MSigmabar;
+class MCerPhotEvt;
+class MPedPhotCam;
+
+class MCameraData : public MParContainer, public MCamEvent
+{
+private:
+    TArrayD fData;  //
+    TArrayC fValidity;
+
+public:
+    MCameraData(const char *name=NULL, const char *title=NULL);
+    ~MCameraData() { }
+
+    UInt_t GetNumPixels() const { return fData.GetSize(); }
+
+    void CalcCleaningLevel(const MCerPhotEvt &evt, const MPedPhotCam &fCam,
+                           const MGeomCam &geom);
+    void CalcCleaningLevel(const MCerPhotEvt &evt, const MSigmabar &sgb,
+                           const MGeomCam &geom);
+    void CalcCleaningLevel(const MCerPhotEvt &evt, Double_t noise,
+                           const MGeomCam &geom);
+
+    void CalcCleaningLevel2(const MCerPhotEvt &evt, const MPedPhotCam &fCam,
+                           const MGeomCam &geom);
+
+    void CalcCleaningLevelDemocratic(const MCerPhotEvt &evt, const MPedPhotCam &cam,
+                                     const MGeomCam &geom);
+
+    const TArrayD &GetData() const { return fData; }
+    const TArrayC &GetValidity() const  { return fValidity; }
+
+    Double_t operator[](int i) { return fData[i]; }
+
+    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
+    void DrawPixelContent(Int_t num) const;
+
+    ClassDef(MCameraData, 1) // Generalized storage class for camera data
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/manalysis/MCerPhotAnal.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MCerPhotAnal.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MCerPhotAnal.cc	(revision 9661)
@@ -0,0 +1,219 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//   MCerPhotAnal                                                           //
+//                                                                          //
+//   This is a task which calculates the number of photons from the FADC    //
+//   time slices. At the moment it integrates simply the FADC values.       //
+//                                                                          //
+//  Input Containers:                                                       //
+//   MRawEvtData, MPedesdtalCam                                             //
+//                                                                          //
+//  Output Containers:                                                      //
+//   MCerPhotEvt                                                            //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MCerPhotAnal.h"
+
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MRawRunHeader.h"
+#include "MRawEvtData.h"       // MRawEvtData::GetNumPixels
+#include "MCerPhotEvt.h"
+#include "MPedestalPix.h"
+#include "MPedestalCam.h"
+#include "MRawEvtPixelIter.h"
+
+ClassImp(MCerPhotAnal);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MCerPhotAnal::MCerPhotAnal(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MCerPhotAnal";
+    fTitle = title ? title : "Task to calculate Cerenkov photons from raw data";
+
+    AddToBranchList("MRawEvtData.fHiGainPixId");
+    AddToBranchList("MRawEvtData.fLoGainPixId");
+    AddToBranchList("MRawEvtData.fHiGainFadcSamples");
+    AddToBranchList("MRawEvtData.fLoGainFadcSamples");
+
+}
+
+// --------------------------------------------------------------------------
+//
+// The PreProcess searches for the following input containers:
+//  - MRawRunHeader
+//  - MRawEvtData
+//  - MPedestalCam
+//
+// The following output containers are also searched and created if
+// they were not found:
+//  - MCerPhotEvt
+//
+Int_t MCerPhotAnal::PreProcess(MParList *pList)
+{
+    fRunHeader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
+    if (!fRunHeader)
+    {
+        *fLog << dbginf << "MRawRunHeader not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
+    if (!fRawEvt)
+    {
+        *fLog << dbginf << "MRawEvtData not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fCerPhotEvt = (MCerPhotEvt*)pList->FindCreateObj("MCerPhotEvt");
+    if (!fCerPhotEvt)
+        return kFALSE;
+
+    return kTRUE;
+}
+
+Bool_t MCerPhotAnal::ReInit(MParList *pList)
+{
+    fPedestals = NULL;
+
+    // This must be done in ReInit because in PreProcess the
+    // headers are not available
+    const MRawRunHeader *runheader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
+    if (!runheader)
+        *fLog << warn << dbginf << "Warning - cannot check file type, MRawRunHeader not found." << endl;
+    else
+        if (runheader->IsMonteCarloRun())
+            return kTRUE;
+
+    fPedestals = (MPedestalCam*)pList->FindCreateObj("MPedestalCam");
+    if (runheader && !fPedestals)
+        return kFALSE;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculate the integral of the FADC time slices and store them as a new
+// pixel in the MCerPhotEvt container.
+//
+Int_t MCerPhotAnal::Process()
+{
+    //fCerPhotEvt->InitSize(fRawEvt->GetNumPixels());
+
+    MRawEvtPixelIter pixel(fRawEvt);
+
+    while (pixel.Next())
+    {
+	Byte_t *ptr = pixel.GetHiGainSamples();
+	const Byte_t *end = ptr + fRawEvt->GetNumHiGainSamples();
+	const Byte_t *limit = end - 5;
+	
+	Int_t sum=0;
+	Int_t sumpeak=0;
+	Int_t sumlocal =0;
+	Int_t slice=0;
+	Int_t slicelocal=0;
+
+	do
+        {
+            sumlocal = 0;
+            for (Int_t i = 0; i<5;i++)
+                sumlocal += *(ptr+i);
+
+            if (sumpeak < sumlocal)
+            {
+                slice=slicelocal;
+                sumpeak = sumlocal;
+            }
+
+            slicelocal++;
+	    sum += *ptr;
+        } while (++ptr != limit);
+
+        do sum += *ptr;
+        while (++ptr != end);
+
+        Float_t pedes = (Float_t)(sum-sumpeak)/(fRawEvt->GetNumHiGainSamples()-5);
+        Float_t nphot = (Float_t)sumpeak - 5.0*pedes;
+
+        Float_t sigmaped=0;
+
+        slicelocal=0;
+        sumlocal = 0;
+
+	ptr = pixel.GetHiGainSamples();
+        do
+        {
+            if (slicelocal==slice)
+                ptr += 4;
+            else
+            {
+                sumlocal = *ptr;
+
+                const Float_t d = (Float_t)sumlocal-pedes;
+                sigmaped += d*d;
+            }
+            slicelocal++;
+	}
+        while (++ptr != end);
+
+	sigmaped /= (fRawEvt->GetNumHiGainSamples()-5);
+	sigmaped = sqrt((float)sumlocal);
+
+	const UInt_t pixid = pixel.GetPixelId();
+
+        fCerPhotEvt->AddPixel(pixid, nphot, sigmaped/2.236);
+
+        if (fPedestals)
+            (*fPedestals)[pixid].Set(pedes, sigmaped);
+
+        /*
+         ped.SetPedestalRms(sigmaped/sqrt(fRawEvt->GetNumHiGainSamples()-5.),
+                            sigmaped/sqrt(2.*(fRawEvt->GetNumHiGainSamples()-5)));
+                            */
+        // FIXME! Handling of Lo Gains is missing!
+    }
+
+    fCerPhotEvt->FixSize();
+    fCerPhotEvt->SetReadyToSave();
+
+    if (fPedestals)
+        fPedestals->SetReadyToSave();
+
+    return kTRUE;
+}
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MCerPhotAnal.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MCerPhotAnal.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MCerPhotAnal.h	(revision 9661)
@@ -0,0 +1,39 @@
+#ifndef MARS_MCerPhotAnal
+#define MARS_MCerPhotAnal
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MCerPhotAnal                                                            //
+//                                                                         //
+// Integrates the time slices of one pixel and substracts the pedestal     //
+// (offset) value                                                          //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MRawEvtData;
+class MPedestalCam;
+class MCerPhotEvt;
+class MRawRunHeader;
+
+class MCerPhotAnal : public MTask
+{
+    MPedestalCam  *fPedestals;  // Pedestals of all pixels in the camera
+    MRawEvtData   *fRawEvt;     // raw event data (time slices)
+    MCerPhotEvt   *fCerPhotEvt; // Cerenkov Photon Event used for calculation
+    MRawRunHeader *fRunHeader;  // RunHeader information
+
+    Int_t  PreProcess(MParList *pList);
+    Bool_t ReInit(MParList *pList);
+    Int_t  Process();
+ 
+public:
+    MCerPhotAnal(const char *name=NULL, const char *title=NULL);
+
+    ClassDef(MCerPhotAnal, 0)   // Task to calculate cerenkov photons from raw data
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/manalysis/MCerPhotAnal2.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MCerPhotAnal2.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MCerPhotAnal2.cc	(revision 9661)
@@ -0,0 +1,293 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//   MCerPhotAnal2
+//
+//   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, MPedPhotCam
+//
+//  Output Containers:
+//   MCerPhotEvt
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MCerPhotAnal2.h"
+
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MRawRunHeader.h"
+#include "MRawEvtData.h"       // MRawEvtData::GetNumPixels
+#include "MCerPhotEvt.h"
+#include "MPedPhotPix.h"
+#include "MPedPhotCam.h"
+#include "MRawEvtPixelIter.h"
+
+ClassImp(MCerPhotAnal2);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. b is the number of slices before the maximum slice,
+// a the number of slices behind the maximum slice which is taken as signal.
+//
+MCerPhotAnal2::MCerPhotAnal2(Byte_t b, Byte_t a, const char *name, const char *title)
+    : fBefore(b), fAfter(a)
+{
+    fName  = name  ? name  : "MCerPhotAnal2";
+    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
+//  - MPedPhotCam
+//
+// The following output containers are also searched and created if
+// they were not found:
+//  - MCerPhotEvt
+//
+Int_t MCerPhotAnal2::PreProcess(MParList *pList)
+{
+    fSkip = 0;
+
+    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;
+    }
+
+    fCerPhotEvt = (MCerPhotEvt*)pList->FindCreateObj("MCerPhotEvt");
+    if (!fCerPhotEvt)
+        return kFALSE;
+
+    return kTRUE;
+}
+
+Bool_t MCerPhotAnal2::ReInit(MParList *pList)
+{
+    fPedestals=NULL;
+
+    // This must be done in ReInit because in PreProcess the
+    // headers are not available
+    const MRawRunHeader *runheader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
+    if (!runheader)
+        *fLog << warn << dbginf << "Warning - cannot check file type, MRawRunHeader not found." << endl;
+    else
+    {
+        if (runheader->IsMonteCarloRun())
+            return kTRUE;
+    }
+
+    fPedestals = (MPedPhotCam*)pList->FindCreateObj("MPedPhotCam");
+    if (runheader && !fPedestals)
+        return kFALSE;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculate the integral of the FADC time slices and store them as a new
+// pixel in the MCerPhotEvt container.
+//
+Int_t MCerPhotAnal2::Process()
+{
+    MRawEvtPixelIter pixel(fRawEvt);
+
+    while (pixel.Next())
+    {
+        Byte_t *ptr   = pixel.GetHiGainSamples();
+        Byte_t *max   = ptr+pixel.GetIdxMaxHiGainSample();
+	Byte_t *end   = ptr+fRawEvt->GetNumHiGainSamples();
+        Byte_t *first = max-fBefore;
+        Byte_t *last  = max+fAfter;
+
+        ULong_t sumb  = 0;   // sum background
+        ULong_t sqb   = 0;   // sum sqares background
+        ULong_t sumsb = 0;   // sum signal+background
+        ULong_t sqsb  = 0;   // sum sqares signal+background
+
+        Int_t sat  = 0; // saturates?
+        Int_t ishi = 0; // has a high content?
+        Int_t nb   = 0;
+        Int_t nsb  = 0;
+
+        if (*max==255)
+            sat++;
+
+        if (*max>80)
+            ishi++;
+
+        while (ptr<end)
+        {
+            if (ptr<first || ptr>last)
+            {
+                sumb += *ptr;
+                sqb  += *ptr* *ptr;
+                nb++;
+            }
+            else
+            {
+                sumsb += *ptr;
+                sqsb  += *ptr* *ptr;
+                nsb++;
+            }
+            ptr++;
+        }
+
+        if (sat==0 && ishi)
+        {
+            // Area: x9
+            ptr = pixel.GetLoGainSamples();
+            end = ptr+fRawEvt->GetNumLoGainSamples();
+
+            sumb = 0;   // sum background
+            sqb  = 0;   // sum sqares background
+            nb   = 0;
+
+            while (ptr<end)
+            {
+                // Background already calced from hi-gains!
+                sumb += *ptr;
+                sqb  += *ptr* *ptr;
+                nb++;
+                ptr++;
+            }
+        }
+
+        if (sat>1 && !ishi)
+        {
+            // Area: x9
+            ptr = pixel.GetLoGainSamples();
+            max = ptr+pixel.GetIdxMaxLoGainSample();
+
+            if (*max>250)
+            {
+                fSkip++;
+                return kCONTINUE;
+            }
+
+            end   = ptr+fRawEvt->GetNumLoGainSamples();
+            first = max-fBefore;
+            last  = max+fAfter;
+
+            sumsb = 0;   // sum signal+background
+            sqsb  = 0;   // sum sqares signal+background
+            //sumb  = 0;   // sum background
+            //sqb   = 0;   // sum sqares background
+
+            //nb = 0;
+            nsb = 0;
+            while (ptr<end)
+            {
+                if (ptr<first || ptr>last)
+                {
+                    /*
+                     // Background already calced from hi-gains!
+                    sumb += ptr[i];
+                    sqb  += ptr[i]*ptr[i];
+                    nb++;*/
+                }
+                else
+                {
+                    sumsb += *ptr;
+                    sqsb  += *ptr* *ptr;
+                    nsb++;
+                }
+                ptr++;
+            }
+        }
+
+        Float_t b  = (float)sumb/nb;       // background
+        Float_t sb = (float)sumsb/nsb;     // signal+background
+
+        Float_t msb  = (float)sqb/nb;      // mean square background
+        //Float_t mssb = (float)sqsb/nsb;    // mean square signal+background
+
+        Float_t sigb  = sqrt(msb-b*b);     // sigma background
+        //Float_t sigsb = sqrt(mssb-sb*sb);  // sigma signal+background
+
+        Float_t s   = sb-b;                // signal
+        Float_t sqs = sqsb-nsb*b;          // sum sqaures signal
+
+        Float_t mss  = (float)sqs/nsb;     // mean quare signal
+        Float_t sigs = sqrt(mss-s*s);      // sigma signal
+
+        if (sat>1)
+            s*=10; // tgb has measured 9, but Florian said it's 10.
+
+        Int_t idx = pixel.GetPixelId();
+        fCerPhotEvt->AddPixel(idx, s, sigs);
+
+        // Preliminary: Do not overwrite pedestals calculated by
+        // MMcPedestalCopy and MMcPedestalNSBAdd
+        if (fPedestals)
+            (*fPedestals)[idx].Set(b, sigb);
+    }
+
+    fCerPhotEvt->FixSize();
+    fCerPhotEvt->SetReadyToSave();
+
+    if (fPedestals)
+        fPedestals->SetReadyToSave();
+
+    return kTRUE;
+}
+
+Int_t MCerPhotAnal2::PostProcess()
+{
+    if (GetNumExecutions()==0 || fSkip==0)
+        return kTRUE;
+
+    *fLog << inf << endl;
+    *fLog << GetDescriptor() << " execution statistics:" << endl;
+    *fLog << dec << setfill(' ');
+    *fLog << " " << setw(7) << fSkip << " (" << setw(3) << (int)(fSkip*100/GetNumExecutions()) << "%) Evts skipped due to: lo gain saturated." << endl;
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/manalysis/MCerPhotAnal2.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MCerPhotAnal2.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MCerPhotAnal2.h	(revision 9661)
@@ -0,0 +1,46 @@
+#ifndef MARS_MCerPhotAnal2
+#define MARS_MCerPhotAnal2
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MCerPhotAnal2                                                            //
+//                                                                         //
+// Integrates the time slices of one pixel and substracts the pedestal     //
+// (offset) value                                                          //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MRawEvtData;
+class MPedPhotCam;
+class MCerPhotEvt;
+class MRawRunHeader;
+
+class MCerPhotAnal2 : public MTask
+{
+private:
+    MPedPhotCam   *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
+
+    Byte_t fBefore;
+    Byte_t fAfter;
+
+    Int_t fSkip;                //!
+
+    Int_t  PreProcess(MParList *pList);
+    Bool_t ReInit(MParList *pList);
+    Int_t  Process();
+    Int_t  PostProcess();
+
+public:
+    MCerPhotAnal2(Byte_t b=2, Byte_t a=5, const char *name=NULL, const char *title=NULL);
+
+    ClassDef(MCerPhotAnal2, 0)   // Task to calculate cerenkov photons from raw data
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/manalysis/MCerPhotCalc.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MCerPhotCalc.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MCerPhotCalc.cc	(revision 9661)
@@ -0,0 +1,284 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Abelardo Moralejo 7/2002  <mailto:moralejo@pd.infn.it>
+!   Author(s): Thomas Bretz 2002  <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2002-2003
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//   MCerPhotCalc
+//
+//   This is a task which calculates the number of photons from the FADC
+//   time slices. It weights the each slice according to the numbers in
+//   the array fWeight (default: all slices added up with weight 1).
+//
+//   The weights are rescaled, such that sum(weigths)=num slices
+//
+//  Input Containers:
+//   MRawEvtData
+//   MPedestalCam
+//   [MRawRunHeader]
+//
+//  Output Containers:
+//   MCerPhotEvt
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MCerPhotCalc.h"
+
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MGeomCam.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);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MCerPhotCalc::MCerPhotCalc(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MCerPhotCalc";
+    fTitle = title ? title : "Calculate pixel signal from FADC data";
+
+    AddToBranchList("MRawEvtData.fHiGainPixId");
+    AddToBranchList("MRawEvtData.fLoGainPixId");
+    AddToBranchList("MRawEvtData.fHiGainFadcSamples");
+    AddToBranchList("MRawEvtData.fLoGainFadcSamples");
+
+    SetDefaultWeights();
+}
+
+// --------------------------------------------------------------------------
+//
+// The PreProcess searches for the following input containers:
+//  - MRawRunHeader
+//  - MRawEvtData
+//  - MPedestalCam
+//
+// The following output containers are also searched and created if
+// they were not found:
+//  - MCerPhotEvt
+//
+Int_t MCerPhotCalc::PreProcess(MParList *pList)
+{
+    fRunHeader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
+    if (!fRunHeader)
+    {
+        *fLog << err << "MRawRunHeader not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData"));
+    if (!fRawEvt)
+    {
+        *fLog << err << "MRawEvtData not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fPedestals = (MPedestalCam*)pList->FindCreateObj(AddSerialNumber("MPedestalCam"));
+    if (!fPedestals)
+    {
+        *fLog << err << "MPedestalCam not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fCerPhotEvt = (MCerPhotEvt*)pList->FindCreateObj(AddSerialNumber("MCerPhotEvt"));
+    if (!fCerPhotEvt)
+        return kFALSE;
+
+    // Calculate sum and quadratic sum of weights:
+    fSumWeights = 0;
+    fSumQuadWeights = 0;
+    for (Int_t i=0; i<fWeight.GetSize(); i++)
+      {
+	fSumWeights += fWeight[i];
+	fSumQuadWeights += fWeight[i]*fWeight[i];
+      }
+
+    fSumQuadWeights = sqrt(fSumQuadWeights);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Check for the run type and camera version.
+// If the file is a MC file and the used camera version is <= 40
+// we enable a fix for truncated pedestal means in this version.
+//
+Bool_t MCerPhotCalc::ReInit(MParList *pList)
+{
+    const MRawRunHeader *runheader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
+    if (!runheader)
+    {
+        *fLog << warn << dbginf << "Warning - cannot check file type, MRawRunHeader not found." << endl;
+        return kTRUE;
+    }
+
+    if (fRunHeader->GetNumSamplesHiGain() != fWeight.GetSize())
+    {
+        *fLog << dbginf << "Number of FADC slices (" << fRunHeader->GetNumSamplesHiGain() <<") is different from assumed one (" << fWeight.GetSize() << ")... aborting." << endl;
+        return kFALSE;
+    }
+
+    if (!runheader->IsMonteCarloRun())
+        return kTRUE;
+
+    MMcRunHeader *mcrunheader = (MMcRunHeader*)pList->FindObject("MMcRunHeader");
+    if (!mcrunheader)
+    {
+        *fLog << warn << dbginf << "Warning - cannot check for camera version, MC run header not found." << endl;
+        return kTRUE;
+    }
+
+    fEnableFix = kFALSE;
+
+    if (mcrunheader->GetCamVersion() <= 40)
+        fEnableFix = kTRUE;
+
+    ScalePedestals();
+
+    return kTRUE;
+}
+
+void MCerPhotCalc::ScalePedestals()
+{
+    const Int_t n = fPedestals->GetSize();
+
+    for (int idx=0; idx<n; idx++)
+    {
+        MPedestalPix &ped = (*fPedestals)[idx];
+
+	// This converts the pedestal info contained in ped  from the pedestal 
+	// of each FADC slice to the pedesal of the pixel signal (depends on
+	// how many FADC slices are added up).
+
+        const Double_t offset = fEnableFix ? ped.GetPedestal()-0.5 : ped.GetPedestal();
+
+        ped.Set(offset*fSumWeights, ped.GetPedestalRms()*fSumQuadWeights);
+    }
+
+    fPedestals->SetReadyToSave();
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculate the integral of the FADC time slices and store them as a new
+// pixel in the MCerPhotEvt container.
+//
+Int_t MCerPhotCalc::Process()
+{
+    //fCerPhotEvt->InitSize(fRawEvt->GetNumPixels());
+
+//    if (fIsMcFile)
+//        ScalePedestals();
+
+    const Int_t n = fWeight.GetSize();
+
+    MRawEvtPixelIter pixel(fRawEvt);
+
+    Int_t saturatedpixels = 0;
+
+    while (pixel.Next())
+    {
+        const UInt_t idx = pixel.GetPixelId();
+
+        MPedestalPix &ped = (*fPedestals)[idx];
+
+        //
+        // Calculate pixel signal unless it has all FADC slices empty:
+        //
+        Byte_t *ptr = pixel.GetHiGainSamples();
+
+        Int_t i;
+        Double_t nphot = 0;
+        for (i=0; i<n; i++)
+        {
+            if (ptr[i]==0xff)
+                break;
+            nphot += ptr[i]*fWeight[i];
+        }
+
+	Bool_t saturatedlg = kFALSE;
+
+        if (i<n)
+        {
+	    nphot = 0;
+
+            ptr = pixel.GetLoGainSamples();
+            if (ptr==NULL)
+            {
+                *fLog << warn << "WARNING - Pixel #" << idx << " saturated but has no lo gains... skipping!" << endl;
+                return kCONTINUE;
+            }
+
+            for (i=0; i<n; i++)
+            {
+                if (ptr[i]==0xff)
+                    saturatedlg = kTRUE;
+
+                nphot += ptr[i]*fWeight[i];
+            }
+
+            nphot -= ped.GetPedestal();
+            nphot *= 10;
+        }
+        else
+            nphot -= ped.GetPedestal();
+
+        fCerPhotEvt->AddPixel(idx, nphot, 0);
+
+	if (saturatedlg)
+	  saturatedpixels++;
+    }
+
+    if (saturatedpixels>0)
+        *fLog << warn << "WARNING: " << saturatedpixels << " pixel(s) had saturating low gains..." << endl;
+
+    fCerPhotEvt->FixSize();
+    fCerPhotEvt->SetReadyToSave();
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Set default values for the number of slices and weights:
+//
+void MCerPhotCalc::SetDefaultWeights()
+{
+    const Float_t dummy[15] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
+    fWeight.Set(15, dummy);
+}
Index: /tags/Mars_V0-8-5/Mars/manalysis/MCerPhotCalc.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MCerPhotCalc.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MCerPhotCalc.h	(revision 9661)
@@ -0,0 +1,57 @@
+#ifndef MARS_MCerPhotCalc
+#define MARS_MCerPhotCalc
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MCerPhotCalc                                                            //
+//                                                                         //
+// Integrates the desired ADC time slices of one pixel and substracts the  //
+// pedestal (offset) value                                                 //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#ifndef ROOT_TArrayF
+#include <TArrayF.h>
+#endif
+
+#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)
+    Bool_t          fIsMcFile;
+
+    TArrayF         fWeight;  // Weights for adding up the ADC slices
+    Float_t         fSumQuadWeights;
+    Float_t         fSumWeights;
+
+    void SetDefaultWeights();
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
+    Bool_t ReInit(MParList *pList);
+    void ScalePedestals();
+
+public:
+    MCerPhotCalc(const char *name=NULL, const char *title=NULL);
+
+    // FIXME: The array size should be checked!
+    void   SetWeights(const TArrayF &w) { fWeight = w; }
+
+    ClassDef(MCerPhotCalc, 0)   // Task to calculate cerenkov photons from raw data
+};
+ 
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/manalysis/MCerPhotEvt.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MCerPhotEvt.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MCerPhotEvt.cc	(revision 9661)
@@ -0,0 +1,466 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Harald Kornmayer, 1/2001
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//            
+// MCerPhotEvt
+//
+// NOTE: This container is NOT ment for I/O. Write it to a file on your own
+//       risk!
+//
+// Class Version 2:
+// ----------------
+//  - added fLut to accelerate GetPixById a lot
+//            
+// Class Version 1:
+// ----------------
+//  - first version
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCerPhotEvt.h"
+
+#include <math.h>
+#include <limits.h>
+#include <fstream>
+
+#include <TCanvas.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MGeomCam.h"
+
+ClassImp(MCerPhotEvt);
+ClassImp(MCerPhotEvtIter);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// 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;
+    fMaxIndex  = -1;
+    fLut.Set(0);
+    // fPixels->Delete();
+}
+
+void MCerPhotEvt::FixSize()
+{
+    fLut.Set(fMaxIndex+1);
+
+    if (fPixels->GetEntriesFast() == (Int_t)fNumPixels)
+        return;
+
+    fPixels->ExpandCreateFast(fNumPixels);
+}
+
+// --------------------------------------------------------------------------
+//
+//  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
+{
+    return GetPixById(id) ? kTRUE : kFALSE;
+} 
+
+// --------------------------------------------------------------------------
+//
+//   Checks if in the pixel list is an entry with pixel id
+//
+Bool_t MCerPhotEvt::IsPixelUsed(Int_t id) const
+{
+    const MCerPhotPix *pix = GetPixById(id);
+    return pix ? pix->IsPixelUsed() : kFALSE;
+} 
+
+// --------------------------------------------------------------------------
+//
+//   Checks if in the pixel list is an entry with pixel id
+//
+Bool_t MCerPhotEvt::IsPixelCore(Int_t id) const
+{
+    const MCerPhotPix *pix = GetPixById(id);
+    return pix ? pix->IsPixelCore() : 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 UInt_t n = geom->GetNumPixels();
+
+    Float_t minval = FLT_MAX;
+
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        const MCerPhotPix &pix = (*this)[i];
+        if (!pix.IsPixelUsed())
+            continue;
+
+        const UInt_t id = pix.GetPixId();
+        if (id<0 || id>=n)
+            continue;
+
+        Float_t testval = pix.GetNumPhotons();
+
+        if (geom)
+            testval *= geom->GetPixRatio(id);
+
+        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 UInt_t n = geom->GetNumPixels();
+
+    Float_t maxval = -FLT_MAX;
+
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        const MCerPhotPix &pix = (*this)[i];
+        if (!pix.IsPixelUsed())
+            continue;
+
+        const UInt_t id = pix.GetPixId();
+        if (id<0 || id>=n)
+            continue;
+
+        Float_t testval = pix.GetNumPhotons();
+        if (geom)
+            testval *= geom->GetPixRatio(id);
+
+        if (testval > maxval)
+            maxval = testval;
+    }
+    return maxval;
+}
+
+// --------------------------------------------------------------------------
+//
+// get the minimum ratio of photons/error
+//
+Float_t MCerPhotEvt::GetRatioMin(const MGeomCam *geom) const
+{
+    if (fNumPixels <= 0)
+        return -5.;
+
+    Float_t minval = FLT_MAX;
+
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        const MCerPhotPix &pix = (*this)[i];
+        if (!pix.IsPixelUsed())
+            continue;
+
+        Float_t testval = pix.GetNumPhotons()/pix.GetErrorPhot();
+        if (geom)
+            testval *= TMath::Sqrt(geom->GetPixRatio(pix.GetPixId()));
+
+        if (testval < minval)
+            minval = testval;
+    }
+
+    return minval;
+}
+
+// --------------------------------------------------------------------------
+//
+// get the maximum ratio of photons/error
+//
+Float_t MCerPhotEvt::GetRatioMax(const MGeomCam *geom) const
+{
+    if (fNumPixels <= 0)
+        return -5.;
+
+    Float_t maxval = -FLT_MAX;
+
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        const MCerPhotPix &pix = (*this)[i];
+        if (!pix.IsPixelUsed())
+            continue;
+
+        Float_t testval = pix.GetNumPhotons()/pix.GetErrorPhot();
+        if (geom)
+            testval *= TMath::Sqrt(geom->GetPixRatio(pix.GetPixId()));
+
+        if (testval > maxval)
+            maxval = testval;
+    }
+
+    return maxval;
+}
+
+// --------------------------------------------------------------------------
+//
+// get the minimum of error
+// If you specify a geometry the number of photons is weighted with the
+// area of the pixel
+//
+Float_t MCerPhotEvt::GetErrorPhotMin(const MGeomCam *geom) const
+{
+    if (fNumPixels <= 0)
+        return 50.;
+
+    Float_t minval = FLT_MAX;
+
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        const MCerPhotPix &pix = (*this)[i];
+        if (!pix.IsPixelUsed())
+            continue;
+
+        Float_t testval = pix.GetErrorPhot();
+
+        if (geom)
+            testval *= geom->GetPixRatio(pix.GetPixId());
+
+        if (testval < minval)
+            minval = testval;
+    }
+    return minval;
+}
+
+// --------------------------------------------------------------------------
+//
+// get the maximum ratio of photons/error
+// If you specify a geometry the number of photons is weighted with the
+// area of the pixel
+//
+Float_t MCerPhotEvt::GetErrorPhotMax(const MGeomCam *geom) const
+{
+    if (fNumPixels <= 0)
+        return 50.;
+
+    Float_t maxval = -FLT_MAX;
+
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        const MCerPhotPix &pix = (*this)[i];
+        if (!pix.IsPixelUsed())
+            continue;
+
+        Float_t testval = pix.GetErrorPhot();
+
+        if (geom)
+            testval *= geom->GetPixRatio(pix.GetPixId());
+
+        if (testval > maxval)
+            maxval = testval;
+    }
+    return maxval;
+}
+
+void MCerPhotEvt::RemoveUnusedPixels()
+{
+    TIter Next(fPixels);
+    MCerPhotPix *pix = NULL;
+
+    while ((pix=(MCerPhotPix*)Next()))
+        if (!pix->IsPixelUsed())
+            fPixels->Remove(pix);
+
+    fPixels->Compress();
+    fNumPixels=fPixels->GetEntriesFast();
+}
+
+// --------------------------------------------------------------------------
+//
+// Return a pointer to the pixel with the requested idx. NULL if it doesn't
+// exist. The Look-up-table fLut is used. If its size is zero (according
+// to Rene this will happen if an old class object is loaded) we still
+// try to search in the array.
+//
+MCerPhotPix *MCerPhotEvt::GetPixById(Int_t idx) const
+{
+    if (idx<0)
+        return 0;
+
+    if (fLut.GetSize()>0)
+    {
+        if (idx>=fLut.GetSize())
+            return 0;
+        return fLut[idx]<0 ? 0 : (MCerPhotPix*)(fPixels->UncheckedAt(fLut[idx]));
+    }
+
+    TIter Next(fPixels);
+    MCerPhotPix *pix = NULL;
+
+    while ((pix=(MCerPhotPix*)Next()))
+        if (pix->GetPixId()==idx)
+            return pix;
+
+    return NULL;
+}
+
+MCerPhotPix *MCerPhotEvt::AddPixel(Int_t idx, Float_t nph, Float_t er)
+    {
+        //
+        // If this is too slow or takes to much space we might use
+        // MGeomApply and an InitSize member function instead.
+        //
+        if (idx>=fLut.GetSize())
+        {
+            const Int_t n = fLut.GetSize();
+            fLut.Set(idx*2+1); //idx+1 is slower than idx*2+1
+            for (int i=n; i<idx*2+1; i++)
+                fLut[i] = -1;
+        }
+
+        fLut[idx] = fNumPixels;
+        if (idx>fMaxIndex)
+            fMaxIndex=idx;
+
+        return new ((*fPixels)[fNumPixels++]) MCerPhotPix(idx, nph, er);
+    }
+
+// --------------------------------------------------------------------------
+//
+// Returns, depending on the type flag:
+//
+//  0: Number of Photons*PixRatio
+//  1: Error*sqrt(PixRatio)
+//  2: Cleaning level = Num Photons*sqrt(PixRatio)/Error
+//  3: Number of Photons
+//  4: Error
+//
+Bool_t MCerPhotEvt::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
+{
+    MCerPhotPix *pix = GetPixById(idx);
+
+    if (!pix || !pix->IsPixelUsed())
+        return kFALSE;
+
+    const Double_t ratio = cam.GetPixRatio(idx);
+
+    switch (type)
+    {
+    case 1:
+        val = pix->GetErrorPhot()*TMath::Sqrt(ratio);
+        return kTRUE;
+    case 2:
+        if (pix->GetErrorPhot()<=0)
+            return kFALSE;
+        val = pix->GetNumPhotons()*TMath::Sqrt(ratio)/pix->GetErrorPhot();
+        return kTRUE;
+    case 3:
+        val = pix->GetNumPhotons();
+        break;
+    case 4:
+        val = pix->GetErrorPhot();
+        break;
+    default:
+        val = pix->GetNumPhotons()*ratio;
+        return kTRUE;
+    }
+    return kTRUE;
+}
+
+void MCerPhotEvt::DrawPixelContent(Int_t num) const
+{
+    *fLog << warn << "MCerPhotEvt::DrawPixelContent - not available." << endl;
+}
+
+TObject *MCerPhotEvtIter::Next()
+{
+    if (!fUsedOnly)
+        return TObjArrayIter::Next();
+
+    MCerPhotPix *pix;
+    while ((pix = (MCerPhotPix*)TObjArrayIter::Next()))
+        if (pix->IsPixelUsed())
+            return pix;
+    return pix;
+}
Index: /tags/Mars_V0-8-5/Mars/manalysis/MCerPhotEvt.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MCerPhotEvt.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MCerPhotEvt.h	(revision 9661)
@@ -0,0 +1,89 @@
+#ifndef MARS_MCerPhotEvt
+#define MARS_MCerPhotEvt
+
+#ifndef ROOT_TClonesArray
+#include <TClonesArray.h>
+#endif
+#ifndef ROOT_TArrayI
+#include <TArrayI.h>
+#endif
+#ifndef MARS_MCamEvent
+#include "MCamEvent.h"
+#endif
+#ifndef MARS_MCerPhotPix
+#include "MCerPhotPix.h"
+#endif
+
+class MGeomCam;
+class MCerPhotPix;
+class MCerPhotEvtIter;
+
+class MCerPhotEvt : public MParContainer, public MCamEvent
+{
+    friend class MCerPhotEvtIter;
+private:
+    UInt_t        fNumPixels;
+     Int_t        fMaxIndex;
+    TArrayI       fLut;        // Lookup tabel to lookup pixel by index
+    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); }
+
+    MCerPhotPix *AddPixel(Int_t idx, Float_t nph=0, Float_t er=0);
+
+    void FixSize();
+
+    Bool_t  IsPixelExisting(Int_t id) const;
+    Bool_t  IsPixelUsed    (Int_t id) const;
+    Bool_t  IsPixelCore    (Int_t id) const;
+
+    Float_t GetNumPhotonsMin(const MGeomCam *geom=NULL) const;
+    Float_t GetNumPhotonsMax(const MGeomCam *geom=NULL) const;
+
+    Float_t GetRatioMin(const MGeomCam *geom=NULL) const;
+    Float_t GetRatioMax(const MGeomCam *geom=NULL) const;
+
+    Float_t GetErrorPhotMin(const MGeomCam *geom=NULL) const;
+    Float_t GetErrorPhotMax(const MGeomCam *geom=NULL) const;
+
+    MCerPhotPix &operator[](int i)       { return *(MCerPhotPix*)(fPixels->UncheckedAt(i)); }
+    MCerPhotPix &operator[](int i) const { return *(MCerPhotPix*)(fPixels->UncheckedAt(i)); }
+
+    void Scale(Double_t f) { fPixels->ForEach(MCerPhotPix, Scale)(f); }
+    void RemoveUnusedPixels();
+
+    MCerPhotPix *GetPixById(Int_t idx) const;
+
+    void Reset();
+
+    void Print(Option_t *opt=NULL) const;
+    void Clear(Option_t *opt=NULL) { Reset(); }
+
+    // class MCamEvent
+    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
+    void DrawPixelContent(Int_t num) const;
+
+    operator TIterator*() const;
+
+    ClassDef(MCerPhotEvt, 2)    // class for an event containing cerenkov photons
+};
+
+class MCerPhotEvtIter : public TObjArrayIter
+{
+private:
+    Bool_t fUsedOnly;
+public:
+    MCerPhotEvtIter(const MCerPhotEvt *evt, Bool_t usedonly=kTRUE, Bool_t dir=kIterForward) : TObjArrayIter(evt->fPixels, dir), fUsedOnly(usedonly) { }
+    TObject *Next();
+    TIterator &operator=(const TIterator &) { return *this; }
+    ClassDef(MCerPhotEvtIter, 0)
+};
+
+inline MCerPhotEvt::operator TIterator*() const { return new MCerPhotEvtIter(this); }
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/manalysis/MCerPhotPix.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MCerPhotPix.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MCerPhotPix.cc	(revision 9661)
@@ -0,0 +1,79 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Harald Kornmayer 1/2001
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MCerPhotPix
+//
+// Storage container for the signal in a pixel in number of photons.
+//
+// NOTE: This container is NOT ment for I/O. Write it to a file on your
+//       own risk!
+//
+// fIsSaturated: boolean variable set to kTRUE whenever one or more of
+//               the low gain FADC slices of the pixel is in saturation.
+//
+// Version 2:
+// ----------
+//  - added fIsSaturated
+//
+// Version 4:
+// ----------
+//  - added fIsHGSaturated
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MCerPhotPix.h"
+
+#include "MLog.h"
+
+ClassImp(MCerPhotPix);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. The pixel is assumed as used and not a core pixel.
+// NT 29/04/2003: A pixel is considered used when fRing > 0.
+//
+MCerPhotPix::MCerPhotPix(Int_t pix, Float_t phot, Float_t errphot) :
+    fPixId(pix), fRing(1), fIsCore(kFALSE), fPhot(phot), fErrPhot(errphot), 
+    fIsSaturated(kFALSE), fIsHGSaturated(kFALSE)
+{
+} 
+
+// --------------------------------------------------------------------------
+//
+//  Print information to gLog.
+//
+void MCerPhotPix::Print(Option_t *) const
+{ 
+    gLog << GetDescriptor() <<" Pixel: "<< fPixId;
+    gLog << (fRing>0?"   Used ":" Unused ");
+    gLog << (fIsCore?" Core ":"      ");
+    gLog << (fIsSaturated?"   ":"not") << " saturated ";
+    gLog << "High gain " << (fIsHGSaturated?"   ":"not") << " saturated ";
+    gLog << "Nphot= " << fPhot << " Error(Nphot)=" << fErrPhot << endl;
+}
Index: /tags/Mars_V0-8-5/Mars/manalysis/MCerPhotPix.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MCerPhotPix.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MCerPhotPix.h	(revision 9661)
@@ -0,0 +1,66 @@
+#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
+
+   Short_t fRing;      // NT: number of analyzed rings around the core pixels, fRing>0 means: used, fRing= 0 means: unused, fRing= -1 means: unmapped (no possible to use in the calculation of the image parameters)
+    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
+
+    Bool_t   fIsSaturated;   // the pixel's low gain is saturated
+    Bool_t   fIsHGSaturated; // the pixel's high gain is saturated
+
+    // 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; }
+    
+    Bool_t   IsPixelUsed() const         { return fRing>0; }
+    Bool_t   IsPixelUnmapped() const     { return fRing==-1; }
+    void     SetPixelUnused()            { fRing=0; }
+    void     SetPixelUsed()              { fRing=1; }
+    void     SetPixelUnmapped()          { fRing=-1;}
+
+    void     SetRing(UShort_t r)         { fRing = r;   }
+    Short_t  GetRing() const             { return fRing;}
+
+    void     SetPixelCore()              { fIsCore = kTRUE; }
+    Bool_t   IsPixelCore() const         { return fIsCore;  }
+
+    void     SetNumPhotons(Float_t f)    { fPhot    = f; }
+    void     SetErrorPhot(Float_t f)     { fErrPhot = f; }
+    void     Set(Float_t np, Float_t ep) { fPhot = np; fErrPhot = ep; }
+
+    void     SetPixelSaturated()         { fIsSaturated = kTRUE; }
+    Bool_t   IsPixelSaturated() const    { return fIsSaturated; }
+
+    void     SetPixelHGSaturated()         { fIsHGSaturated = kTRUE; }
+    Bool_t   IsPixelHGSaturated() const    { return fIsHGSaturated; }
+
+    void     AddNumPhotons(Float_t f)    { fPhot += f; }
+
+    void     Scale(Float_t f)            { fPhot/=f; }
+
+    void     Print(Option_t *opt = NULL) const;
+
+    ClassDef(MCerPhotPix, 4)  // class containing information about the Cerenkov Photons in a pixel
+};
+
+#endif
+
+
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MCompProbCalc.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MCompProbCalc.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MCompProbCalc.cc	(revision 9661)
@@ -0,0 +1,166 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Abelardo Moralejo <mailto:moralejo@pd.infn.it>
+!   Author(s): Thomas Bretz, 5/2002 <mailto:moralejo@pd.infn.it>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MCompProbCalc
+//
+// FIXME: Use A huge matrix to evaluate variable bins instead of a
+// histogram
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MCompProbCalc.h"
+
+#include <TH1.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MDataChain.h"
+
+#include "MHCompProb.h"
+#include "MHadronness.h"
+
+ClassImp(MCompProbCalc);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor
+//
+MCompProbCalc::MCompProbCalc(const char *name, const char *title)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MCompProbCalc";
+    fTitle = title ? title : "Composite Probabilities Loop 1/2";
+
+    fData = new TList;
+    fData->SetOwner();
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor
+//
+MCompProbCalc::~MCompProbCalc()
+{
+    delete fData;
+}
+
+// --------------------------------------------------------------------------
+//
+// Needs:
+//  - MHCompProb
+//  - all data values which were used to build the MHCompProb
+//  - MHadronness
+//
+Int_t MCompProbCalc::PreProcess(MParList *plist)
+{
+    MHCompProb *p = (MHCompProb*)plist->FindObject("MHCompProb");
+    if (!p)
+    {
+        *fLog << err << dbginf << "MHCompProb not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fHistVar = p->GetHistVar();
+    if (fHistVar->GetSize()==0)
+    {
+        *fLog << err << dbginf << "No Entries in MHCompProb::fHistVar... aborting." << endl;
+        return kFALSE;
+    }
+
+    const TList *rules = p->GetRules();
+    if (rules->GetSize()==0)
+    {
+        *fLog << err << dbginf << "No Entries in MHCompProb::fRules... aborting." << endl;
+        return kFALSE;
+    }
+
+    if (fHistVar->GetSize() != rules->GetSize())
+    {
+        *fLog << err << dbginf << "Number of rules doesn't match number of var.bin histograms.. aborting." << endl;
+        return kFALSE;
+    }
+
+    TIter Next(rules);
+    TObject *data=NULL;
+    while ((data=Next()))
+    {
+        MDataChain *chain = new MDataChain(data->GetName());
+        if (!chain->PreProcess(plist))
+        {
+            delete chain;
+            return kFALSE;
+        }
+        fData->Add(chain);
+    }
+
+    fHadronness = (MHadronness*)plist->FindCreateObj("MHadronness");
+    if (!fHadronness)
+        return kFALSE;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculate the hadroness (composite propability)
+//  - For each data member search the bin corresponding to the data value.
+//  - The value describes with which probability this value corresponds to
+//    a hadron
+//  - For all data members multiply the probabilities.
+//  - For normalization take the n-th root of the result.
+//  - This is the hadroness stored in the MHadronness container
+//
+Int_t MCompProbCalc::Process()
+{
+    Double_t p = 1;
+
+    TIter NextH(fHistVar);
+    TIter NextD(fData);
+
+    TH1D *hist=NULL;
+
+    Int_t n = 0;
+
+    while ((hist=(TH1D*)NextH()))
+    {
+        MData *data = (MData*)NextD();
+
+        Int_t ibin = hist->FindBin(data->GetValue());
+
+        p *= hist->GetBinContent(ibin) / hist->GetEntries();
+        n++;
+    }
+
+    fHadronness->SetHadronness(pow(p, 1./n));
+    return kTRUE;
+}
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MCompProbCalc.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MCompProbCalc.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MCompProbCalc.h	(revision 9661)
@@ -0,0 +1,33 @@
+#ifndef MARS_MCompProbCalc
+#define MARS_MCompProbCalc
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MMcEvt;
+class MParList;
+class MHadronness;
+
+class MCompProbCalc : public MTask
+{
+private:
+    MHadronness *fHadronness; //! Output container (Hadronness)
+
+    TList *fData;           //! List of MDataChains to be used
+    TList *fHistVar;        //! List of variable bin size histograms
+
+    void Fill(TList &list);
+    void SetBinningHistVar();
+
+public:
+    MCompProbCalc(const char *name=NULL, const char *title=NULL);
+    ~MCompProbCalc();
+
+    Int_t PreProcess(MParList *plist);
+    Int_t Process();
+
+    ClassDef(MCompProbCalc, 1) // Task to calculate composite probabilities
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/manalysis/MEnergyEst.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MEnergyEst.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MEnergyEst.cc	(revision 9661)
@@ -0,0 +1,57 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  1/2002 <mailto:tbretz@uni-sw.gwdg.de>
+!   Author(s): Wolfgang Wittek 1/2002 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MEnergyEst                                                              //
+//                                                                         //
+// Storage Container for the estimated energy                              //
+//                                                                         //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MEnergyEst.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MEnergyEst);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MEnergyEst::MEnergyEst(const char *name, const char *title) : fEnergy(0)
+{
+    fName  = name  ? name  : "MEnergyEst";
+    fTitle = title ? title : "Storage container for the estimated energy [GeV]";
+}
+
+void MEnergyEst::Print(Option_t *o) const
+{
+    *fLog << all << GetDescriptor() << ": Eest = " << (int)fEnergy << "GeV \t Ir = " << (int)(fImpact/100) << "m" << endl;
+}
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MEnergyEst.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MEnergyEst.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MEnergyEst.h	(revision 9661)
@@ -0,0 +1,28 @@
+#ifndef MARS_MEnergyEst
+#define MARS_MEnergyEst
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MEnergyEst : public MParContainer
+{
+private:
+    Double_t fEnergy; // [GeV] Estimated Energy
+    Double_t fImpact; // [cm]  Estimated Impact
+
+public:
+    MEnergyEst(const char *name=NULL, const char *title=NULL);
+
+    void SetEnergy(Double_t e) { fEnergy = e; }
+    void SetImpact(Double_t i) { fImpact = i; }
+    Double_t GetEnergy() const { return fEnergy; }
+    Double_t GetImpact() const { return fImpact; }
+
+    void Print(Option_t *o="") const;
+
+    ClassDef(MEnergyEst, 1) // Storage Container for the estimated Energy
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MEnergyEstParam.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MEnergyEstParam.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MEnergyEstParam.cc	(revision 9661)
@@ -0,0 +1,376 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  9/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MEnergyEstParam                                                         //
+//                                                                         //
+// Task to estimate the energy using a parametrization.                    //
+// Make sure, that all source dependant containers are based on the same   //
+// set of basic hillas parameters                                          //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MEnergyEstParam.h"
+
+#include "MParList.h"
+
+#include "MMcEvt.hxx"
+#include "MHMatrix.h"
+#include "MHillasSrc.h"
+#include "MEnergyEst.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MEnergyEstParam);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Initialize the coefficients with (nonsense) values
+//
+void MEnergyEstParam::InitCoefficients()
+{
+    fA.Set(5);
+    fA[0] =  -2539; // [cm]
+    fA[1] =    900; // [cm]
+    fA[2] =   17.5; // [cm]
+    fA[3] =  0.006;
+    fA[4] =   58.3;
+
+    /*
+      fA[0] =   39.667402; // [cm]
+      fA[1] =  143.081912; // [cm]
+      fA[2] = -395.501677; // [cm]
+      fA[3] =    0.006193;
+      fA[4] =    0;
+    */
+
+    fB.Set(7);
+    fB[0] =   -8.69;    // [GeV]
+    fB[1] =  -0.069;    // [GeV]
+    fB[2] =   0.000655; // [GeV]
+    fB[3] =   0.0326;   // [GeV]
+    fB[4] = 0.000225;   // [GeV]
+    fB[5] =  4.13e-8;   // [GeV]
+    fB[6] =     0.05;
+
+    /*
+      fB[0] =   45.037867; // [GeV]
+      fB[1] =    0.087222; // [GeV]
+      fB[2] =   -0.208065; // [GeV/cm]
+      fB[3] =   78.164942; // [GeV]
+      fB[4] = -159.361283; // [GeV]
+      fB[5] =   -0.130455; // [GeV/cm]
+      fB[6] =    0.051139;
+    */
+}
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. Give the name of the parameter container (MHillas)
+// storing width, length and size (Default="MHillas").
+// For the Zenith Angle MMcEvt.fTheta is used.
+//
+MEnergyEstParam::MEnergyEstParam(const char *hillas, const char *name, const char *title)
+   : fMatrix(NULL)
+{
+    fName  = name  ? name  : "MEnergyEstParam";
+    fTitle = title ? title : "Task to estimate the energy";
+
+    fHillasName = hillas;
+
+    fPairs     = new TList;
+    fEnergy    = new TList;
+    fHillasSrc = new TList;
+
+    fPairs->SetOwner();
+
+    InitCoefficients();
+
+    AddToBranchList("MMcEvt.fTelescopeTheta");
+    AddToBranchList(fHillasName+".fSize");
+    AddToBranchList(fHillasName+".fWidth");
+    AddToBranchList(fHillasName+".fLength");
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Destructor.
+//
+MEnergyEstParam::~MEnergyEstParam()
+{
+    delete fPairs;
+    delete fEnergy;
+    delete fHillasSrc;
+}
+
+// --------------------------------------------------------------------------
+//
+// Check for all necessary parameter containers.
+//
+Int_t MEnergyEstParam::PreProcess(MParList *plist)
+{
+    if (!fMatrix)
+    {
+        fHillas = (MHillas*)plist->FindObject(fHillasName, "MHillas");
+        if (!fHillas)
+        {
+            *fLog << err << dbginf << fHillasName << " [MHillas] not found... aborting." << endl;
+            return kFALSE;
+        }
+
+        fMc = (MMcEvt*)plist->FindObject("MMcEvt");
+        if (!fMc)
+        {
+            *fLog << err << dbginf << "MMcEvt not found... aborting." << endl;
+            return kFALSE;
+        }
+    }
+
+    TObject *obj = NULL;
+    TIter Next(fPairs);
+
+    while ((obj=Next()))
+    {
+        TObject *o = plist->FindCreateObj(obj->GetTitle(), "MEnergyEst");
+        if (!o)
+            return kFALSE;
+
+        if (!fEnergy->FindObject(obj->GetTitle()))
+            fEnergy->Add(o);
+
+        if (fMatrix)
+            continue;
+
+        o = plist->FindObject(obj->GetName(), "MHillasSrc");
+        if (!o)
+        {
+            *fLog << err << dbginf << obj->GetName() << " not found... aborting." << endl;
+            return kFALSE;
+        }
+        fHillasSrc->Add(o);
+    }
+
+   return kTRUE;    
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the five coefficients for the estimation of the impact parameter.
+// Argument must ba a TArrayD of size 5.
+//
+void MEnergyEstParam::SetCoeffA(const TArrayD &arr)
+{
+    if (arr.GetSize() != fA.GetSize())
+    {
+        *fLog << err << dbginf << "Error - Wrong number of coefficients!" << endl;
+        return;
+    }
+
+    fA = arr;
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the seven coefficients for the estimation of the energy.
+// Argument must ba a TArrayD of size 7.
+//
+void MEnergyEstParam::SetCoeffB(const TArrayD &arr)
+{
+    if (arr.GetSize() != fB.GetSize())
+    {
+        *fLog << err << dbginf << "Error - Wrong number of coefficients!" << endl;
+        return;
+    }
+
+    fB = arr;
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the twelve coefficients for the estimation of impact and energy.
+// Argument must ba a TArrayD of size 12.
+//
+void MEnergyEstParam::SetCoeff(const TArrayD &arr)
+{
+    if (arr.GetSize() != fA.GetSize()+fB.GetSize())
+    {
+        *fLog << err << dbginf << "Error - Wrong number of coefficients!" << endl;
+        return;
+    }
+
+    fA = TArrayD(fA.GetSize(), arr.GetArray());
+    fB = TArrayD(fB.GetSize(), arr.GetArray() + fA.GetSize());
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the mapped value from the Matrix
+//
+Double_t MEnergyEstParam::GetVal(Int_t i) const
+{
+    return (*fMatrix)[fMap[i]];
+}
+
+// --------------------------------------------------------------------------
+//
+// You can use this function if you want to use a MHMatrix instead of the
+// given containers. This function adds all necessary columns to the
+// given matrix. Afterward you should fill the matrix with the corresponding
+// data (eg from a file by using MHMatrix::Fill). If you now loop
+// through the matrix (eg using MMatrixLoop) MEnergyEstParam::Process
+// will take the values from the matrix instead of the containers.
+//
+void MEnergyEstParam::InitMapping(MHMatrix *mat)
+{
+    if (fMatrix)
+        return;
+
+    fMatrix = mat;
+
+    fMap[0] = fMatrix->AddColumn("MMcEvt.fTelescopeTheta");
+    fMap[1] = fMatrix->AddColumn(fHillasName+".fWidth");
+    fMap[2] = fMatrix->AddColumn(fHillasName+".fLength");
+    fMap[3] = fMatrix->AddColumn(fHillasName+".fSize");
+
+    Int_t col = 4;
+    TIter Next(fPairs);
+    TObject *o = NULL;
+    while ((o=Next()))
+        fMap[col++] = fMatrix->AddColumn(TString(o->GetName())+".fDist");
+}
+
+void MEnergyEstParam::StopMapping()
+{
+    fMatrix = NULL; 
+    fPairs->Clear();
+    fHillasSrc->Clear();
+    fEnergy->Clear();
+}
+
+// --------------------------------------------------------------------------
+//
+// Add a pair of input/output containers.
+//   eg. Add("MHillasSrc", "MEnergyEst");
+// Useful if you want to estimate the stuff for the source and antisource
+//
+void MEnergyEstParam::Add(const TString hillas, const TString energy)
+{
+    fPairs->Add(new TNamed(hillas, energy));
+
+    AddToBranchList(hillas+".fDist");
+}
+
+void MEnergyEstParam::Print(Option_t *opt) const
+{
+    for (int i=0; i<fA.GetSize(); i++)
+        *fLog << all << "fA[" << i << "]=" << const_cast<TArrayD&>(fA)[i] << endl;
+    for (int i=0; i<fB.GetSize(); i++)
+        *fLog << all << "fB[" << i << "]=" << const_cast<TArrayD&>(fB)[i] << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Estimates the impact parameter and energy using a parameterization
+//  (see code)
+//
+Int_t MEnergyEstParam::Process()
+{
+    const Double_t theta  = fMatrix ? GetVal(0) : fMc->GetTelescopeTheta();
+    const Double_t width  = fMatrix ? GetVal(1) : fHillas->GetWidth();
+    const Double_t length = fMatrix ? GetVal(2) : fHillas->GetLength();
+    const Double_t size   = fMatrix ? GetVal(3) : fHillas->GetSize();
+
+    const Double_t k   = 1./cos(theta);
+    const Double_t k2  = k*k;
+
+    const Double_t i0 = k * (fA[3]*k+1)/(fA[3]+1);
+    const Double_t i1 = fA[0] + fA[2]*width;
+
+
+    const Double_t e0 = k2 * (fB[6]*k2+1)/(fB[6]+1);
+
+    /* MY PARAM */
+    //const Double_t e1 = fB[0] + fB[1]*size + fB[3]*length + fB[4]*size*width;
+    //const Double_t e2 = fB[2] + fB[5]*size*width;
+
+    /* MARCOS */
+    /*
+    const Double_t e1 = fB[0] + fB[1]*size + fB[3]*length + fB[4]*size*length;
+    const Double_t e2 = fB[2] + fB[5]*length;
+    */
+
+    /* DANIEL */
+    const Double_t e1 = fB[0] + fB[1]*size/(length*width) + 
+      fB[3]*length + fB[4]*size/width;
+
+    const Double_t e2 = fB[2] + fB[5]*length;
+
+    TIter NextH(fHillasSrc);
+    TIter NextE(fEnergy);
+
+    Int_t col = 4;
+
+    while (1)
+    {
+        MEnergyEst *est = (MEnergyEst*)NextE();
+        if (!est)
+            break;
+
+        const Double_t dist = fMatrix ? GetVal(col++) : ((MHillasSrc*)NextH())->GetDist();
+
+        /* DANIEL - MARCOS */
+        const Double_t ir = i0 * (i1 + fA[1]*dist); // [cm]
+        Double_t er = e0 * (e1 + e2*ir);       // [GeV]
+
+        /* THOMAS BRETZ */
+        // if (width==0) return kCONTINUE;
+        // const Double_t ir = i0 * (i1 + dist*(fA[1]/width + fA[4]/log10(size))); // [cm]
+        //Double_t er = e0 * (e1 + e2*ir);      // [GeV]
+
+        /* MKA */
+        //Double_t er = e0 * (fB[0] + fB[1]*size/width + fB[2]*ir /*+ d*leakage*/);
+
+        if (width==0)
+            return kCONTINUE;
+
+        if (TMath::IsNaN(ir))
+            *fLog << all << theta << " " << width << " " << length << " " << size << " " << dist << endl;
+        if (TMath::IsNaN(er))
+        {
+            *fLog << all << theta << " " << width << " " << length << " " << size << " " << dist << endl;
+            er = 0;
+        }
+
+	est->SetEnergy(er);
+        est->SetImpact(ir);
+        est->SetReadyToSave();
+    }
+
+    return kTRUE;
+}
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MEnergyEstParam.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MEnergyEstParam.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MEnergyEstParam.h	(revision 9661)
@@ -0,0 +1,67 @@
+#ifndef MARS_MEnergyEstParam
+#define MARS_MEnergyEstParam
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+#ifndef ROOT_TArrayD
+#include <TArrayD.h>
+#endif
+
+class MHillasSrc;
+class MEnergyEst;
+class MHillas;
+class MMcEvt;
+class MHMatrix;
+
+class MEnergyEstParam : public MTask
+{
+private:
+    Int_t     fMap[100]; // FIXME!
+
+    MHMatrix *fMatrix;
+
+    TList    *fPairs;
+
+    TList    *fHillasSrc;
+    TList    *fEnergy;
+
+    MHillas  *fHillas;
+    TString   fHillasName;
+
+    TArrayD   fA;
+    TArrayD   fB;
+
+    MMcEvt   *fMc;
+
+    void InitCoefficients();
+
+    Double_t GetVal(Int_t i) const;
+
+    Int_t PreProcess(MParList *plist);
+    Int_t Process();
+
+public:
+    MEnergyEstParam(const char *hil="MHillas", const char *name=NULL, const char *title=NULL);
+    ~MEnergyEstParam();
+
+    void Add(const TString hillas, const TString energy="MEnergyEst");
+
+    void InitMapping(MHMatrix *mat);
+    void StopMapping();
+
+    Int_t GetNumCoeff() const { return fA.GetSize()+fB.GetSize(); }
+
+    void SetCoeff(const TArrayD &arr);
+    void SetCoeffA(const TArrayD &arr);
+    void SetCoeffB(const TArrayD &arr);
+
+    Double_t GetCoeff(Int_t i) { return i<fA.GetSize()? fA[i] : fB[i-fA.GetSize()]; }
+
+    void Print(Option_t *o=NULL) const;
+
+    ClassDef(MEnergyEstParam, 0) // Task to estimate the energy
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/manalysis/MEnergyEstParamDanielMkn421.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MEnergyEstParamDanielMkn421.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MEnergyEstParamDanielMkn421.cc	(revision 9661)
@@ -0,0 +1,401 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  9/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!              Wolfgang Wittek  7/2003 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MEnergyEstParamDanielMkn421                                             //
+//                                                                         //
+// Task to estimate the energy using a parametrization.                    //
+// Make sure, that all source dependant containers are based on the same   //
+// set of basic hillas parameters                                          //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MEnergyEstParamDanielMkn421.h"
+
+#include "MParList.h"
+
+#include "MGeomCam.h"
+#include "MMcEvt.hxx"
+#include "MHMatrix.h"
+#include "MHillasSrc.h"
+#include "MNewImagePar.h"
+#include "MEnergyEst.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MEnergyEstParamDanielMkn421);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Initialize the coefficients with Daniel's values
+// for Mkn421
+//
+//
+void MEnergyEstParamDanielMkn421::InitCoefficients()
+{
+    // parameters for the impact parameter
+    fA.Set(4);
+    fA[0] = 12.0322;  // 
+    fA[1] =  8.29911; // 
+    fA[2] = 73.0699;  // 
+    fA[3] =  0.311375;
+
+
+    // parameters for the energy
+    fB.Set(6);
+    fB[0] =  1.23138;    // 
+    fB[1] =  0.00276497; // 
+    fB[2] = -0.0110667;  // 
+    fB[3] =  7.47538;    // 
+    fB[4] = -1.25619;    // 
+    fB[5] =  0.627699;   // 
+}
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. Give the name of the parameter container (MHillas)
+// storing width, length and size (Default="MHillas").
+// For the Zenith Angle MMcEvt.fTheta is used.
+//
+MEnergyEstParamDanielMkn421::MEnergyEstParamDanielMkn421(const char *hillas, const char *name, const char *title)
+   : fMatrix(NULL)
+{
+    fName  = name  ? name  : "MEnergyEstParamDanielMkn421";
+    fTitle = title ? title : "Task to estimate the energy (Daniel Mkn421)";
+
+    fHillasName = hillas;
+
+    fPairs     = new TList;
+    fEnergy    = new TList;
+    fHillasSrc = new TList;
+
+    fPairs->SetOwner();
+
+    InitCoefficients();
+
+    AddToBranchList("MMcEvt.fTelescopeTheta");
+    AddToBranchList(fHillasName+".fSize");
+    AddToBranchList(fHillasName+".fWidth");
+    AddToBranchList(fHillasName+".fLength");
+    AddToBranchList("MNewImagePar.fLeakage1");
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Destructor.
+//
+MEnergyEstParamDanielMkn421::~MEnergyEstParamDanielMkn421()
+{
+    delete fPairs;
+    delete fEnergy;
+    delete fHillasSrc;
+}
+
+// --------------------------------------------------------------------------
+//
+// Check for all necessary parameter containers.
+//
+Int_t MEnergyEstParamDanielMkn421::PreProcess(MParList *plist)
+{
+    const MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam");
+    if (!geom)
+    {
+        *fLog << warn << dbginf << "No Camera Geometry available" << endl;
+        return kFALSE;
+    }
+    else
+    {
+        fMm2Deg = geom->GetConvMm2Deg();
+    }
+
+
+    if (!fMatrix)
+    {
+        fHillas = (MHillas*)plist->FindObject(fHillasName, "MHillas");
+        if (!fHillas)
+        {
+            *fLog << err << dbginf << fHillasName << " [MHillas] not found... aborting." << endl;
+            return kFALSE;
+        }
+
+        fMc = (MMcEvt*)plist->FindObject("MMcEvt");
+        if (!fMc)
+        {
+            *fLog << err << dbginf << "MMcEvt not found... aborting." << endl;
+            return kFALSE;
+        }
+
+        fNewImagePar = (MNewImagePar*)plist->FindObject("MNewImagePar");
+        if (!fNewImagePar)
+        {
+            *fLog << err << dbginf << " object 'MNewImagePar' not found... aborting." << endl;
+            return kFALSE;
+        }
+
+    }
+
+
+    TObject *obj = NULL;
+    TIter Next(fPairs);
+
+    while ((obj=Next()))
+    {
+        TObject *o = plist->FindCreateObj(obj->GetTitle(), "MEnergyEst");
+        if (!o)
+            return kFALSE;
+
+        if (!fEnergy->FindObject(obj->GetTitle()))
+            fEnergy->Add(o);
+
+        if (fMatrix)
+            continue;
+
+        o = plist->FindObject(obj->GetName(), "MHillasSrc");
+        if (!o)
+        {
+            *fLog << err << dbginf << obj->GetName() << " not found... aborting." << endl;
+            return kFALSE;
+        }
+        fHillasSrc->Add(o);
+    }
+
+   return kTRUE;    
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the five coefficients for the estimation of the impact parameter.
+// Argument must ba a TArrayD of size 5.
+//
+void MEnergyEstParamDanielMkn421::SetCoeffA(const TArrayD &arr)
+{
+    if (arr.GetSize() != fA.GetSize())
+    {
+        *fLog << err << dbginf << "Error - Wrong number of coefficients!" << endl;
+        return;
+    }
+
+    fA = arr;
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the seven coefficients for the estimation of the energy.
+// Argument must ba a TArrayD of size 7.
+//
+void MEnergyEstParamDanielMkn421::SetCoeffB(const TArrayD &arr)
+{
+    if (arr.GetSize() != fB.GetSize())
+    {
+        *fLog << err << dbginf << "Error - Wrong number of coefficients!" << endl;
+        return;
+    }
+
+    fB = arr;
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the twelve coefficients for the estimation of impact and energy.
+// Argument must ba a TArrayD of size 12.
+//
+void MEnergyEstParamDanielMkn421::SetCoeff(const TArrayD &arr)
+{
+    if (arr.GetSize() != fA.GetSize()+fB.GetSize())
+    {
+        *fLog << err << dbginf << "Error - Wrong number of coefficients!" << endl;
+        return;
+    }
+
+    fA = TArrayD(fA.GetSize(), arr.GetArray());
+    fB = TArrayD(fB.GetSize(), arr.GetArray() + fA.GetSize());
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the mapped value from the Matrix
+//
+Double_t MEnergyEstParamDanielMkn421::GetVal(Int_t i) const
+{
+    return (*fMatrix)[fMap[i]];
+}
+
+// --------------------------------------------------------------------------
+//
+// You can use this function if you want to use a MHMatrix instead of the
+// given containers. This function adds all necessary columns to the
+// given matrix. Afterward you should fill the matrix with the corresponding
+// data (eg from a file by using MHMatrix::Fill). If you now loop
+// through the matrix (eg using MMatrixLoop) MEnergyEstParamDanielMkn421::Process
+// will take the values from the matrix instead of the containers.
+//
+void MEnergyEstParamDanielMkn421::InitMapping(MHMatrix *mat)
+{
+    if (fMatrix)
+        return;
+
+    fMatrix = mat;
+
+    fMap[0] = fMatrix->AddColumn("MMcEvt.fTelescopeTheta");
+    fMap[1] = fMatrix->AddColumn(fHillasName+".fWidth");
+    fMap[2] = fMatrix->AddColumn(fHillasName+".fLength");
+    fMap[3] = fMatrix->AddColumn(fHillasName+".fSize");
+    fMap[4] = fMatrix->AddColumn("MNewImagePar.fLeakage1");
+
+    Int_t col = 5;
+    TIter Next(fPairs);
+    TObject *o = NULL;
+    while ((o=Next()))
+        fMap[col++] = fMatrix->AddColumn(TString(o->GetName())+".fDist");
+}
+
+void MEnergyEstParamDanielMkn421::StopMapping()
+{
+    fMatrix = NULL; 
+    fPairs->Clear();
+    fHillasSrc->Clear();
+    fEnergy->Clear();
+}
+
+// --------------------------------------------------------------------------
+//
+// Add a pair of input/output containers.
+//   eg. Add("MHillasSrc", "MEnergyEst");
+// Useful if you want to estimate the stuff for the source and antisource
+//
+void MEnergyEstParamDanielMkn421::Add(const TString hillas, const TString energy)
+{
+    fPairs->Add(new TNamed(hillas, energy));
+
+    AddToBranchList(hillas+".fDist");
+}
+
+void MEnergyEstParamDanielMkn421::Print(Option_t *opt) const
+{
+    for (int i=0; i<fA.GetSize(); i++)
+        *fLog << all << "fA[" << i << "]=" << const_cast<TArrayD&>(fA)[i] << endl;
+    for (int i=0; i<fB.GetSize(); i++)
+        *fLog << all << "fB[" << i << "]=" << const_cast<TArrayD&>(fB)[i] << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Estimates the impact parameter and energy using a parameterization
+//  (see code)
+//
+Int_t MEnergyEstParamDanielMkn421::Process()
+{
+
+    const Double_t theta  = fMatrix ? GetVal(0) : fMc->GetTelescopeTheta();
+
+    Double_t width  = fMatrix ? GetVal(1) : fHillas->GetWidth();
+    width *= fMm2Deg;
+
+    Double_t length = fMatrix ? GetVal(2) : fHillas->GetLength();
+    length *= fMm2Deg;
+
+    const Double_t size   = fMatrix ? GetVal(3) : fHillas->GetSize();
+    Double_t leakage= fMatrix ? GetVal(4) : fNewImagePar->GetLeakage1();
+    leakage = (leakage-0.1)<0. ? 0. : leakage-0.1;
+
+    const Double_t k   = 1./cos(theta);
+    const Double_t k2  = k*k;
+
+    const Double_t i0 = k  * (fA[3]*k + 1);
+    const Double_t e0 = k2 * (fB[4]*k + fB[5]*k2+1);
+
+    TIter NextH(fHillasSrc);
+    TIter NextE(fEnergy);
+
+    Int_t col = 5;
+
+    while (1)
+    {
+        MEnergyEst *est = (MEnergyEst*)NextE();
+        if (!est)
+            break;
+
+        Double_t dist = fMatrix ? GetVal(col++) : ((MHillasSrc*)NextH())->GetDist();
+        dist *= fMm2Deg;
+
+        Double_t ir = i0 * (fA[0] + fA[1]*dist/width + fA[2]*leakage); 
+        Double_t er = e0 * (fB[0] + fB[1]*size/width + fB[2]*ir + fB[3]*leakage);
+        er *= 1000.0;  // conversion to GeV
+
+        if (ir<0.  || er<0.)
+	{
+          ir = 0.;
+          er = 0.;
+	}
+
+        if (width==0)
+            return kCONTINUE;
+
+        if (TMath::IsNaN(ir))
+            *fLog << all << theta << " " << width << " " << length << " " << size << " " << dist << endl;
+        if (TMath::IsNaN(er))
+        {
+            *fLog << all << theta << " " << width << " " << length << " " << size << " " << dist << endl;
+            er = 0;
+        }
+
+	est->SetEnergy(er);
+        est->SetImpact(ir);
+        est->SetReadyToSave();
+
+    }
+
+
+    return kTRUE;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MEnergyEstParamDanielMkn421.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MEnergyEstParamDanielMkn421.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MEnergyEstParamDanielMkn421.h	(revision 9661)
@@ -0,0 +1,79 @@
+#ifndef MARS_MEnergyEstParamDanielMkn421
+#define MARS_MEnergyEstParamDanielMkn421
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+#ifndef ROOT_TArrayD
+#include <TArrayD.h>
+#endif
+
+class MHillasSrc;
+class MEnergyEst;
+class MHillas;
+class MNewImagePar;
+class MMcEvt;
+class MHMatrix;
+
+class MEnergyEstParamDanielMkn421 : public MTask
+{
+private:
+    Int_t     fMap[100]; // FIXME!
+
+    MHMatrix *fMatrix;
+
+    TList    *fPairs;
+
+    TList    *fHillasSrc;
+    TList    *fEnergy;
+
+    MHillas       *fHillas;
+    MNewImagePar  *fNewImagePar;
+
+    TString   fHillasName;
+
+    TArrayD   fA;
+    TArrayD   fB;
+
+    MMcEvt   *fMc;
+
+    void InitCoefficients();
+
+    Double_t GetVal(Int_t i) const;
+    Double_t fMm2Deg;
+
+    Int_t PreProcess(MParList *plist);
+    Int_t Process();
+
+public:
+    MEnergyEstParamDanielMkn421(const char *hil="MHillas", const char *name=NULL, const char *title=NULL);
+    ~MEnergyEstParamDanielMkn421();
+
+    void Add(const TString hillas, const TString energy="MEnergyEst");
+
+    void InitMapping(MHMatrix *mat);
+    void StopMapping();
+
+    Int_t GetNumCoeff() const { return fA.GetSize()+fB.GetSize(); }
+
+    void SetCoeff(const TArrayD &arr);
+    void SetCoeffA(const TArrayD &arr);
+    void SetCoeffB(const TArrayD &arr);
+
+    Double_t GetCoeff(Int_t i) { return i<fA.GetSize()? fA[i] : fB[i-fA.GetSize()]; }
+
+    void Print(Option_t *o=NULL) const;
+
+    ClassDef(MEnergyEstParamDanielMkn421, 0) // Task to estimate the energy
+};
+
+#endif
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MEnergyEstimate.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MEnergyEstimate.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MEnergyEstimate.cc	(revision 9661)
@@ -0,0 +1,90 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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);
+
+using namespace std;
+
+
+// --------------------------------------------------------------------------
+//
+// 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");
+}
+
+Int_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;    
+}
+
+Int_t MEnergyEstimate::Process()
+{
+  //fEnergy->SetEnergy(fHillas->GetSize());
+  fEnergy->SetEnergy(fMcEvt->GetEnergy());
+  return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/manalysis/MEnergyEstimate.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MEnergyEstimate.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MEnergyEstimate.h	(revision 9661)
@@ -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);
+
+    Int_t PreProcess(MParList *plist);
+    Int_t Process();
+
+    ClassDef(MEnergyEstimate, 0) // Task to copy the MC energy (preliminary)
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MEventRate.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MEventRate.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MEventRate.cc	(revision 9661)
@@ -0,0 +1,63 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MEventRate
+//
+// Storage Container for the event rate.
+//
+//    rate = Number of events / time in which the events were recorded
+//       r = N / t
+//       s = t / N  = 1 / r    mean time interval between consecutive events
+//
+//    for an exponential distribution of the time differences d between
+//    consecutive events:
+//
+//       s = <d>
+//       sigma(d)     = <d> = s
+//       delta(s)     = sigma(d) /sqrt(N) = s / sqrt(N)
+//       delta(s) / s = 1 / sqrt(N)
+//
+//       delta(r) / r = delta(s) / s = 1 / sqrt(N)
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MEventRate.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MEventRate);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MEventRate::MEventRate(const char *name, const char *title) : fRate(-1)
+{
+    fName  = name  ? name  : "MEventRate";
+    fTitle = title ? title : "Storage container for the event rate [Hz]";
+}
Index: /tags/Mars_V0-8-5/Mars/manalysis/MEventRate.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MEventRate.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MEventRate.h	(revision 9661)
@@ -0,0 +1,26 @@
+#ifndef MARS_MEventRate
+#define MARS_MEventRate
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MEventRate : public MParContainer
+{
+private:
+    Double_t fRate;      // [Hz] Event rate
+    UInt_t   fNumEvents; // Number of events correspoding to this rate
+
+public:
+    MEventRate(const char *name=NULL, const char *title=NULL);
+
+    void SetRate(Double_t r, UInt_t n) { fRate = r; fNumEvents = n; }
+    Double_t GetRate() const { return fRate; }
+    Double_t GetError() const { return TMath::Sqrt(1./fNumEvents); }
+    UInt_t GetNumEvents() const { return fNumEvents; }
+
+    ClassDef(MEventRate, 1) // Storage Container for the event rate
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MEventRateCalc.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MEventRateCalc.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MEventRateCalc.cc	(revision 9661)
@@ -0,0 +1,140 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 11/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2002-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MEventRateCalc
+//
+//  This task calculates the event rates from the event times and numbers.
+//
+//  The algorithm is explained in Process()
+//
+//
+//    rate = Number of events / time in which the events were recorded
+//       r = N / t
+//       s = t / N  = 1 / r    mean time interval between consecutive events
+//
+//    for an exponential distribution of the time differences d between
+//    consecutive events:
+//
+//       s = <d>
+//       sigma(d)     = <d> = s
+//       delta(s)     = sigma(d) /sqrt(N) = s / sqrt(N)
+//       delta(s) / s = 1 / sqrt(N)
+//
+//       delta(r) / r = delta(s) / s = 1 / sqrt(N)
+//
+//
+//  Input Containers:
+//    MTime
+//
+//  Output Containers:
+//    MEventRate
+//    MTimeRate [MTime] (missing)
+//
+//  FIXME: For convinience we could implement a mode which always takes
+//         n events to calculate the event rate and sets the corresponding
+//         time. This mode could be used to UPADTE files with the event
+//         rate.
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MEventRateCalc.h"
+
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MTime.h"
+#include "MEventRate.h"
+
+ClassImp(MEventRateCalc);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MEventRateCalc::MEventRateCalc(const char *name, const char *title)
+    : fTimes(1000)
+{
+    fName  = name  ? name  : "MEventRateCalc";
+    fTitle = title ? title : "Calculate trigger rate";
+}
+
+// --------------------------------------------------------------------------
+//
+// The PreProcess searches for the following input containers:
+//   MTime
+//
+// The PreProcess searches for the following input containers:
+//   MEventRate
+//
+// Reset all times in the buffer
+//
+Int_t MEventRateCalc::PreProcess(MParList *pList)
+{
+    fTime = (MTime*)pList->FindObject("MTime");
+    if (!fTime)
+    {
+        *fLog << err << "MTime not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fRate = (MEventRate*)pList->FindCreateObj("MEventRate");
+    if (!fRate)
+        return kFALSE;
+
+    fTimes.Reset();
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculate the events rate as (t1-t0)/n while t1 is the n-th event after
+// t0. If there are not yet enough events in the buffer n is the number
+// of available events. Otherwise the number setup in SetNumEvents.
+//
+Int_t MEventRateCalc::Process()
+{
+    const ULong_t exec = GetNumExecutions()-1;
+
+    const UInt_t n = fTimes.GetSize();
+
+    const UInt_t n1 = exec;
+    const UInt_t n2 = exec>=n ? exec+1 : 0;
+
+    fTimes[n1%n] = *fTime;
+
+    const UInt_t cnt = n1<n2 ? n : n1-n2;
+
+    const Double_t rate = (Double_t)cnt/(fTimes[n1%n]-fTimes[n2%n]);
+
+    fRate->SetRate(exec>1?rate:0, cnt);
+    fRate->SetReadyToSave();
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/manalysis/MEventRateCalc.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MEventRateCalc.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MEventRateCalc.h	(revision 9661)
@@ -0,0 +1,42 @@
+#ifndef MARS_MEventRateCalc
+#define MARS_MEventRateCalc
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+#ifndef MARS_MTime
+#include "MTime.h"
+#endif
+#ifndef ROOT_TArrayD
+#include <TArrayD.h>
+#endif
+
+class MEventRate;
+
+class MEventRateCalc : public MTask
+{
+    MTime      *fTime;  //!
+    MEventRate *fRate;  //!
+
+    //ULong_t fEvtNumber; //!
+    //MTime   fEvtTime;   //!
+
+    //UInt_t  fNumEvents;
+
+    TArrayD fTimes;     //!
+
+
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
+public:
+    MEventRateCalc(const char *name=NULL, const char *title=NULL);
+
+    void SetNumEvents(ULong_t num) { /*fNumEvents = num;*/ fTimes.Set(num); }
+
+    ClassDef(MEventRateCalc, 0)// Task to calculate event rates
+};
+ 
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/manalysis/MFiltercutsCalc.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MFiltercutsCalc.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MFiltercutsCalc.cc	(revision 9661)
@@ -0,0 +1,179 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 05/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//   MFiltercutsCalc
+//
+// This class sets the hadronness to 0.25 if the evaluttion of the cuts
+// is true, otherwise 0.75.
+//
+// The cuts can be set by AddCut (see there for mor information)
+//
+// All single cuts are linked with a logical and ('&&')
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MFiltercutsCalc.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MF.h"
+#include "MFDataChain.h"
+#include "MParList.h"
+#include "MFilterList.h"
+#include "MHadronness.h"
+
+ClassImp(MFiltercutsCalc);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. Creates the filter list.
+//
+MFiltercutsCalc::MFiltercutsCalc(const char *name, const char *title)
+    : fHadronnessName("MHadronness")
+{
+    fName  = name  ? name  : "MFiltercutsCalc";
+    fTitle = title ? title : "Class to evaluate the Supercuts";
+
+    fList = new MFilterList;
+    fList->SetOwner();
+    fList->SetBit(kMustCleanup);
+
+    gROOT->GetListOfCleanups()->Add(fList);
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the filter list.
+//
+MFiltercutsCalc::~MFiltercutsCalc()
+{
+    delete fList;
+}
+
+// --------------------------------------------------------------------------
+//
+// Add the filter to the list. Set the rule as its name.
+//
+void MFiltercutsCalc::AddToList(MFilter *f)
+{
+    f->SetName(f->GetRule());
+    f->SetBit(kMustCleanup);
+    fList->AddToList(f);
+}
+
+// --------------------------------------------------------------------------
+//
+// Print the rule of the list.
+//
+void MFiltercutsCalc::Print(Option_t *opt) const
+{
+    *fLog << all << underline << GetDescriptor() << ":" << endl;
+    fList->Print();
+    *fLog << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// There is MUCH space for speed improvement!
+// Add MF(lo<name && name<up) to the filter list (&&),
+// for more details see MF::MF(), too.
+//
+void MFiltercutsCalc::AddCut(const char *name, Double_t lo, Double_t up)
+{
+    AddToList(new MFDataChain(name, '>', lo));
+    AddToList(new MFDataChain(name, '<', up));
+}
+
+// --------------------------------------------------------------------------
+//
+// There is MUCH space for speed improvement!
+// Add MF(fabs(name)<val) to the filter list (&&),
+// for more details see MF::MF(), too.
+//
+void MFiltercutsCalc::AddCut(const char *name, Double_t val)
+{
+    AddToList(new MFDataChain(Form("fabs(%s)", name), '<', val));
+}
+
+// --------------------------------------------------------------------------
+//
+// There is MUCH space for speed improvement!
+// Add 'cut' as MF(cut) to the filter list (&&),
+// for more details see MF::MF(), too.
+//
+void MFiltercutsCalc::AddCut(const char *cut)
+{
+    AddToList(new MF(cut));
+}
+
+// --------------------------------------------------------------------------
+//
+// There is MUCH space for speed improvement!
+// Add cut to filter list (&&), for more details see MF::MF(), too.
+//
+void MFiltercutsCalc::AddCut(MFilter *f)
+{
+    AddToList(f);
+}
+
+// --------------------------------------------------------------------------
+//
+// Search for fHadronnessName [MHadronness] to store the hadronness in
+// there. PreProcess the filter list.
+//
+Int_t MFiltercutsCalc::PreProcess(MParList *pList)
+{
+    if (!fList->PreProcess(pList))
+        return kFALSE;
+
+    fHadronness = (MHadronness*)pList->FindCreateObj("MHadronness", fHadronnessName);
+    if (!fHadronness)
+        return kFALSE;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Evaluate the filter list. if the Expression is true set hadronness to
+// 0.25, otherwise to 0.75.
+//
+Int_t MFiltercutsCalc::Process()
+{
+    if (!fList->Process())
+        return kFALSE;
+
+    if (fList->IsExpressionTrue())
+        fHadronness->SetHadronness(0.25);
+    else
+        fHadronness->SetHadronness(0.75);
+
+    fHadronness->SetReadyToSave();
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/manalysis/MFiltercutsCalc.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MFiltercutsCalc.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MFiltercutsCalc.h	(revision 9661)
@@ -0,0 +1,48 @@
+#ifndef MARS_MFiltercutsCalc
+#define MARS_MFiltercutsCalc
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MFiltercutsCalc                                                         //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MFilter
+#include "MFilter.h"
+#endif
+
+class MParList;
+class MFilterList;
+class MHadronness;
+
+
+class MFiltercutsCalc : public MTask
+{
+private:
+    MFilterList *fList;       //->
+    MHadronness *fHadronness; //!
+    TString     fHadronnessName;  // name of container to store hadronness
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
+    void AddToList(MFilter *f);
+
+public:
+    MFiltercutsCalc(const char *name=NULL, const char *title=NULL);
+    ~MFiltercutsCalc();
+
+    void SetHadronnessName(const TString name) { fHadronnessName = name; }
+    TString GetHadronnessName() const { return fHadronnessName; }
+
+    void AddCut(const char *name, Double_t lo, Double_t up);
+    void AddCut(const char *name, Double_t val);
+    void AddCut(const char *cut);
+    void AddCut(MFilter *f);
+
+    void Print(Option_t *opt=NULL) const;
+
+    ClassDef(MFiltercutsCalc, 0) // A class to evaluate Filtercuts
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/manalysis/MFindSupercuts.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MFindSupercuts.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MFindSupercuts.cc	(revision 9661)
@@ -0,0 +1,1153 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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, 6/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Wolfgang Wittek, 7/2003 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MFindSupercuts                                                       //
+//                                                                         //
+// Class for otimizing the parameters of the supercuts                     //
+//                                                                         //
+//                                                                         //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MFindSupercuts.h"
+
+#include <math.h>            // fabs 
+
+#include <TFile.h>
+#include <TArrayD.h>
+#include <TMinuit.h>
+#include <TCanvas.h>
+#include <TStopwatch.h>
+#include <TVirtualFitter.h>
+
+#include "MBinning.h"
+#include "MContinue.h"
+#include "MSupercuts.h"
+#include "MSupercutsCalc.h"
+#include "MDataElement.h"
+#include "MDataMember.h"
+
+#include "MEvtLoop.h"
+#include "MFSelFinal.h"
+#include "MF.h"
+#include "MFEventSelector.h"
+#include "MFEventSelector2.h"
+#include "MFillH.h"
+//#include "MGeomCamCT1Daniel.h"
+#include "MFEventSelector.h"
+#include "MGeomCamMagic.h"
+#include "MH3.h"
+#include "MHSupercuts.h"
+#include "MHFindSignificance.h"
+#include "MHMatrix.h"
+#include "MHOnSubtraction.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+#include "MMatrixLoop.h"
+#include "MMinuitInterface.h"
+#include "MParList.h"
+#include "MProgressBar.h"
+#include "MReadMarsFile.h"
+#include "MReadTree.h"
+#include "MTaskList.h"
+
+
+ClassImp(MFindSupercuts);
+
+using namespace std;
+
+
+//------------------------------------------------------------------------
+//
+// fcnSupercuts 
+//
+// - calculates the quantity to be minimized (using TMinuit)
+//
+// - the quantity to be minimized is (-1)*significance of the gamma signal
+//   in the alpha distribution (after cuts)
+//
+// - the parameters to be varied in the minimization are the cut parameters
+//   (par)
+//
+static void fcnSupercuts(Int_t &npar, Double_t *gin, Double_t &f, 
+                         Double_t *par, Int_t iflag)
+{
+    //cout <<  "entry fcnSupercuts" << endl;
+
+    //-------------------------------------------------------------
+    // save pointer to the MINUIT object for optimizing the supercuts
+    // because it will be overwritten 
+    // when fitting the alpha distribution in MHFindSignificance
+    TMinuit *savePointer = gMinuit;
+    //-------------------------------------------------------------
+
+
+    MEvtLoop *evtloopfcn = (MEvtLoop*)gMinuit->GetObjectFit();
+
+    MParList *plistfcn   = (MParList*)evtloopfcn->GetParList();
+    //MTaskList *tasklistfcn   = (MTaskList*)plistfcn->FindObject("MTaskList");
+
+    MSupercuts *super = (MSupercuts*)plistfcn->FindObject("MSupercuts");
+    if (!super)
+    {
+        gLog << "fcnSupercuts : MSupercuts object '" << "MSupercuts"
+            << "' not found... aborting" << endl;
+        return;
+    }
+
+    //
+    // transfer current parameter values to MSupercuts
+    //
+    // Attention : npar is the number of variable parameters
+    //                  not the total number of parameters
+    //
+    Double_t fMin, fEdm, fErrdef;
+    Int_t     fNpari, fNparx, fIstat;
+    gMinuit->mnstat(fMin, fEdm, fErrdef, fNpari, fNparx, fIstat);
+
+    super->SetParameters(TArrayD(fNparx, par));
+
+    //$$$$$$$$$$$$$$$$$$$$$
+    // for testing
+    //TArrayD checkparameters = super->GetParameters();
+    //gLog << "fcnsupercuts : fNpari, fNparx =" << fNpari << ",  " 
+    //     << fNparx  << endl;
+    //gLog << "fcnsupercuts : i, par, checkparameters =" << endl;
+    //for (Int_t i=0; i<fNparx; i++)
+    //{
+    //  gLog << i << ",  " << par[i] << ",  " << checkparameters[i] << endl;
+    //}
+    //$$$$$$$$$$$$$$$$$$$$$
+
+    //
+    // plot alpha with the current cuts
+    //
+    evtloopfcn->Eventloop();
+
+    //tasklistfcn->PrintStatistics(0, kTRUE);
+
+    MH3* alpha = (MH3*)plistfcn->FindObject("AlphaFcn", "MH3");
+    if (!alpha)
+        return;
+
+    TH1 &alphaHist = alpha->GetHist();
+    alphaHist.SetName("alpha-fcnSupercuts");
+
+    //-------------------------------------------
+    // set Minuit pointer to zero in order not to destroy the TMinuit
+    // object for optimizing the supercuts
+    gMinuit = NULL;
+
+    //=================================================================
+    // fit alpha distribution to get the number of excess events and
+    // calculate significance of gamma signal in the alpha plot
+  
+    const Double_t alphasig = 20.0;
+    const Double_t alphamin = 30.0;
+    const Double_t alphamax = 90.0;
+    const Int_t    degree   =    2;
+
+    Bool_t drawpoly;
+    Bool_t fitgauss;
+    if (iflag == 3)
+    {
+        drawpoly  = kTRUE;
+        fitgauss  = kTRUE;
+    }
+    else
+    {
+        drawpoly  = kFALSE;
+        fitgauss  = kFALSE;
+    }
+    //drawpoly  = kFALSE;
+    //fitgauss  = kFALSE;
+
+    const Bool_t print = kTRUE;
+
+    MHFindSignificance findsig;
+    findsig.SetRebin(kTRUE);
+    findsig.SetReduceDegree(kFALSE);
+    
+    const Bool_t rc = findsig.FindSigma(&alphaHist, alphamin, alphamax, degree,
+                                        alphasig, drawpoly, fitgauss, print);
+
+    //=================================================================
+
+    // reset gMinuit to the MINUIT object for optimizing the supercuts 
+    gMinuit = savePointer;
+    //-------------------------------------------
+
+    if (!rc)
+    {
+        gLog << "fcnSupercuts : FindSigma() failed" << endl;
+        f = 1.e10;
+        return;
+    }
+
+    // plot some quantities during the optimization
+    MHSupercuts *plotsuper = (MHSupercuts*)plistfcn->FindObject("MHSupercuts");
+    if (plotsuper)
+        plotsuper->Fill(&findsig);
+
+    //------------------------
+    // get significance
+    const Double_t significance = findsig.GetSignificance();
+    f = significance>0 ? -significance : 0;
+
+
+    //------------------------
+    // optimize signal/background ratio
+    //Double_t ratio = findsig.GetNbg()>0.0 ? 
+    //                 findsig.GetNex()/findsig.GetNbg() : 0.0; 
+    //f = -ratio;
+
+    //-------------------------------------------
+    // final calculations
+    //if (iflag == 3)
+    //{
+    //
+    //}    
+
+    //-------------------------------------------------------------
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MFindSupercuts::MFindSupercuts(const char *name, const char *title)
+: fHowManyTrain(10000), fHowManyTest(10000), fMatrixFilter(NULL)
+{
+    fName  = name  ? name  : "MFindSupercuts";
+    fTitle = title ? title : "Optimizer of the supercuts";
+
+    //---------------------------
+    // camera geometry is needed for conversion mm ==> degree
+    //fCam = new MGeomCamCT1Daniel; 
+    fCam = new MGeomCamMagic; 
+
+    // matrices to contain the training/test samples
+    fMatrixTrain = new MHMatrix("MatrixTrain");
+    fMatrixTest  = new MHMatrix("MatrixTest");
+
+    // objects of MSupercutsCalc to which these matrices are attached
+    fCalcHadTrain = new MSupercutsCalc("SupercutsCalcTrain");
+    fCalcHadTest  = new MSupercutsCalc("SupercutsCalcTest");
+
+    // Define columns of matrices
+    fCalcHadTrain->InitMapping(fMatrixTrain);
+    fCalcHadTest->InitMapping(fMatrixTest);
+}
+
+// --------------------------------------------------------------------------
+//
+// Default destructor.
+//
+MFindSupercuts::~MFindSupercuts()
+{
+    delete fCam;
+    delete fMatrixTrain;
+    delete fMatrixTest;
+    delete fCalcHadTrain;
+    delete fCalcHadTest;
+}
+
+// --------------------------------------------------------------------------
+//
+// Define the matrix 'fMatrixTrain' for the training sample
+//
+// alltogether 'howmanytrain' events are read from file 'nametrain';
+// the events are selected according to a target distribution 'hreftrain'
+//
+//
+Bool_t MFindSupercuts::DefineTrainMatrix(
+			  const TString &nametrain, MH3 &hreftrain,
+	                  const Int_t howmanytrain, const TString &filetrain)
+{
+    if (nametrain.IsNull() || howmanytrain <= 0)
+        return kFALSE;
+
+    *fLog << "=============================================" << endl;
+    *fLog << "fill training matrix from file '" << nametrain 
+          << "',   select " << howmanytrain 
+        << " events " << endl;
+    if (!hreftrain.GetHist().GetEntries()==0)
+    {
+      *fLog << "     according to a distribution given by the MH3 object '"
+            << hreftrain.GetName() << "'" << endl;
+    }
+    else
+    {
+      *fLog << "     randomly" << endl;
+    }
+
+
+    MParList  plist;
+    MTaskList tlist;
+
+    MReadMarsFile read("Events", nametrain);
+    read.DisableAutoScheme();
+
+    MFEventSelector2 seltrain(hreftrain);
+    seltrain.SetNumMax(howmanytrain);
+    seltrain.SetName("selectTrain");
+
+    MFillH filltrain(fMatrixTrain);
+    filltrain.SetFilter(&seltrain);
+    filltrain.SetName("fillMatrixTrain");
+
+    //******************************
+    // entries in MParList 
+    
+    plist.AddToList(&tlist);
+    plist.AddToList(fCam);
+    plist.AddToList(fMatrixTrain);
+
+    //******************************
+    // entries in MTaskList 
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&seltrain);
+    tlist.AddToList(&filltrain);
+
+    //******************************
+
+    MProgressBar bar;
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+    evtloop.SetName("EvtLoopMatrixTrain");
+    evtloop.SetProgressBar(&bar);
+
+    if (!evtloop.Eventloop())
+      return kFALSE;
+
+    tlist.PrintStatistics(0, kTRUE);
+
+    fMatrixTrain->Print("SizeCols");
+    Int_t howmanygenerated = fMatrixTrain->GetM().GetNrows();
+    if (TMath::Abs(howmanygenerated-howmanytrain) > TMath::Sqrt(9.*howmanytrain))
+    {
+      *fLog << "MFindSupercuts::DefineTrainMatrix; no.of generated events ("
+	    << howmanygenerated 
+            << ") is incompatible with the no.of requested events ("
+            << howmanytrain << ")" << endl;
+    }
+
+    *fLog << "training matrix was filled" << endl;
+    *fLog << "=============================================" << endl;
+
+    //--------------------------
+    // write out training matrix
+
+    if (filetrain != "")
+    {
+      TFile filetr(filetrain, "RECREATE");
+      fMatrixTrain->Write();
+      filetr.Close();
+
+      *fLog << "MFindSupercuts::DefineTrainMatrix; Training matrix was written onto file '"
+            << filetrain << "'" << endl;
+    }
+
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Define the matrix for the test sample
+//
+// alltogether 'howmanytest' events are read from file 'nametest'
+//
+// the events are selected according to a target distribution 'hreftest'
+//
+//
+Bool_t MFindSupercuts::DefineTestMatrix(
+			  const TString &nametest, MH3 &hreftest,
+	                  const Int_t howmanytest, const TString &filetest)
+{
+    if (nametest.IsNull() || howmanytest<=0)
+        return kFALSE;
+
+    *fLog << "=============================================" << endl;
+    *fLog << "fill test matrix from file '" << nametest 
+          << "',   select " << howmanytest 
+          << " events " << endl;
+    if (!hreftest.GetHist().GetEntries()==0)
+    {
+      *fLog << "     according to a distribution given by the MH3 object '"
+            << hreftest.GetName() << "'" << endl;
+    }
+    else
+    {
+      *fLog << "     randomly" << endl;
+    }
+
+
+    MParList  plist;
+    MTaskList tlist;
+
+    MReadMarsFile read("Events", nametest);
+    read.DisableAutoScheme();
+
+    MFEventSelector2 seltest(hreftest);
+    seltest.SetNumMax(howmanytest);
+    seltest.SetName("selectTest");
+ 
+    MFillH filltest(fMatrixTest);
+    filltest.SetFilter(&seltest);
+
+    //******************************
+    // entries in MParList 
+    
+    plist.AddToList(&tlist);
+    plist.AddToList(fCam);
+    plist.AddToList(fMatrixTest);
+
+    //******************************
+    // entries in MTaskList 
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&seltest);
+    tlist.AddToList(&filltest);
+
+    //******************************
+
+    MProgressBar bar;
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+    evtloop.SetName("EvtLoopMatrixTest");
+    evtloop.SetProgressBar(&bar);
+
+    if (!evtloop.Eventloop())
+      return kFALSE;
+
+    tlist.PrintStatistics(0, kTRUE);
+
+    fMatrixTest->Print("SizeCols");
+    const Int_t howmanygenerated = fMatrixTest->GetM().GetNrows();
+    if (TMath::Abs(howmanygenerated-howmanytest) > TMath::Sqrt(9.*howmanytest))
+    {
+      *fLog << "MFindSupercuts::DefineTestMatrix; no.of generated events ("
+	    << howmanygenerated 
+            << ") is incompatible with the no.of requested events ("
+            << howmanytest << ")" << endl;
+    }
+
+    *fLog << "test matrix was filled" << endl;
+    *fLog << "=============================================" << endl;
+
+    //--------------------------
+    // write out test matrix
+
+    if (filetest != "")
+    {
+      TFile filete(filetest, "RECREATE", "");
+      fMatrixTest->Write();
+      filete.Close();
+
+      *fLog << "MFindSupercuts::DefineTestMatrix; Test matrix was written onto file '"
+            << filetest << "'" << endl;
+    }
+
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Define the matrices for the training and test sample respectively
+//
+//
+//
+Bool_t MFindSupercuts::DefineTrainTestMatrix(
+			  const TString &name, MH3 &href,
+	                  const Int_t howmanytrain, const Int_t howmanytest,
+                          const TString &filetrain, const TString &filetest)
+{
+    *fLog << "=============================================" << endl;
+    *fLog << "fill training and test matrix from file '" << name 
+          << "',   select "   << howmanytrain 
+          << " training and " << howmanytest << " test events " << endl;
+    if (!href.GetHist().GetEntries()==0)
+    {
+      *fLog << "     according to a distribution given by the MH3 object '"
+            << href.GetName() << "'" << endl;
+    }
+    else
+    {
+      *fLog << "     randomly" << endl;
+    }
+
+
+    MParList  plist;
+    MTaskList tlist;
+
+    MReadMarsFile read("Events", name);
+    read.DisableAutoScheme();
+
+    MFEventSelector2 selector(href);
+    selector.SetNumMax(howmanytrain+howmanytest);
+    selector.SetName("selectTrainTest");
+    selector.SetInverted();
+
+    MContinue cont(&selector);
+    cont.SetName("ContTrainTest");
+
+    Double_t prob =  ( (Double_t) howmanytrain )
+                   / ( (Double_t)(howmanytrain+howmanytest) );
+    MFEventSelector split;
+    split.SetSelectionRatio(prob);
+
+    MFillH filltrain(fMatrixTrain);
+    filltrain.SetFilter(&split);
+    filltrain.SetName("fillMatrixTrain");
+
+
+    // consider this event as candidate for a test event 
+    // only if event was not accepted as a training event
+
+    MContinue conttrain(&split);
+    conttrain.SetName("ContTrain");
+
+    MFillH filltest(fMatrixTest);
+    filltest.SetName("fillMatrixTest");
+
+
+    //******************************
+    // entries in MParList 
+    
+    plist.AddToList(&tlist);
+    plist.AddToList(fCam);
+    plist.AddToList(fMatrixTrain);
+    plist.AddToList(fMatrixTest);
+
+    //******************************
+    // entries in MTaskList 
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&cont);
+
+    tlist.AddToList(&split);
+    tlist.AddToList(&filltrain);
+    tlist.AddToList(&conttrain);
+
+    tlist.AddToList(&filltest);
+
+    //******************************
+
+    MProgressBar bar;
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+    evtloop.SetName("EvtLoopMatrixTrainTest");
+    evtloop.SetProgressBar(&bar);
+
+    Int_t maxev = -1;
+    if (!evtloop.Eventloop(maxev))
+      return kFALSE;
+
+    tlist.PrintStatistics(0, kTRUE);
+
+    fMatrixTrain->Print("SizeCols");
+    const Int_t generatedtrain = fMatrixTrain->GetM().GetNrows();
+    if (TMath::Abs(generatedtrain-howmanytrain) > TMath::Sqrt(9.*howmanytrain))
+    {
+      *fLog << "MFindSupercuts::DefineTrainTestMatrix; no.of generated events ("
+	    << generatedtrain 
+            << ") is incompatible with the no.of requested events ("
+            << howmanytrain << ")" << endl;
+    }
+
+    fMatrixTest->Print("SizeCols");
+    const Int_t generatedtest = fMatrixTest->GetM().GetNrows();
+    if (TMath::Abs(generatedtest-howmanytest) > TMath::Sqrt(9.*howmanytest))
+    {
+      *fLog << "MFindSupercuts::DefineTrainTestMatrix; no.of generated events ("
+	    << generatedtest 
+            << ") is incompatible with the no.of requested events ("
+            << howmanytest << ")" << endl;
+    }
+
+
+    *fLog << "training and test matrix were filled" << endl;
+    *fLog << "=============================================" << endl;
+
+
+    //--------------------------
+    // write out training matrix
+
+    if (filetrain != "")
+    {
+      TFile filetr(filetrain, "RECREATE");
+      fMatrixTrain->Write();
+      filetr.Close();
+
+      *fLog << "MFindSupercuts::DefineTrainTestMatrix; Training matrix was written onto file '"
+            << filetrain << "'" << endl;
+    }
+
+    //--------------------------
+    // write out test matrix
+
+    if (filetest != "")
+    {
+      TFile filete(filetest, "RECREATE", "");
+      fMatrixTest->Write();
+      filete.Close();
+
+      *fLog << "MFindSupercuts::DefineTrainTestMatrix; Test matrix was written onto file '"
+            << filetest << "'" << endl;
+    }
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Read training and test matrices from files
+//
+//
+
+Bool_t MFindSupercuts::ReadMatrix(const TString &filetrain, const TString &filetest)
+{
+  //--------------------------
+  // read in training matrix
+
+  TFile filetr(filetrain);
+  fMatrixTrain->Read("MatrixTrain");
+  fMatrixTrain->Print("SizeCols");
+
+  *fLog << "MFindSupercuts::ReadMatrix; Training matrix was read in from file '"
+        << filetrain << "'" << endl;
+  filetr.Close();
+
+
+  //--------------------------
+  // read in test matrix
+
+  TFile filete(filetest);
+  fMatrixTest->Read("MatrixTest");
+  fMatrixTest->Print("SizeCols");
+
+  *fLog << "MFindSupercuts::ReadMatrix; Test matrix was read in from file '"
+        << filetest << "'" << endl;
+  filete.Close();
+
+  return kTRUE;  
+}
+
+
+//------------------------------------------------------------------------
+//
+// Steering program for optimizing the supercuts
+// ---------------------------------------------
+//
+//      the criterion for the 'optimum' is 
+//
+//          - a maximum significance of the gamma signal in the alpha plot, 
+//            in which the supercuts have been applied
+//
+// The various steps are :
+//
+// - setup the event loop to be executed for each call to fcnSupercuts 
+// - call TMinuit to do the minimization of (-significance) :
+//        the fcnSupercuts function calculates the significance 
+//                                             for the current cut values
+//        for this - the alpha plot is produced in the event loop, 
+//                   in which the cuts have been applied
+//                 - the significance of the gamma signal in the alpha plot 
+//                   is calculated
+//
+// Needed as input : (to be set by the Set functions)
+//
+// - fFilenameParam      name of file to which optimum values of the 
+//                       parameters are written
+//
+// - fHadronnessName     name of container where MSupercutsCalc will
+//                       put the supercuts hadronness
+//
+// - for the minimization, the starting values of the parameters are taken  
+//     - from file parSCinit (if it is != "")
+//     - or from the arrays params and/or steps 
+//
+//----------------------------------------------------------------------
+Bool_t MFindSupercuts::FindParams(TString parSCinit,
+                                     TArrayD &params, TArrayD &steps)
+{
+    // Setup the event loop which will be executed in the 
+    //                 fcnSupercuts function  of MINUIT
+    //
+    // parSCinit is the name of the file containing the initial values 
+    // of the parameters; 
+    // if parSCinit = ""   'params' and 'steps' are taken as initial values
+
+    *fLog << "=============================================" << endl;
+    *fLog << "Setup event loop for fcnSupercuts" << endl;
+
+    if (fHadronnessName.IsNull())
+    {
+      *fLog << "MFindSupercuts::FindParams; hadronness name is not defined... aborting"
+            << endl;
+      return kFALSE;
+    }
+
+    if (fMatrixTrain == NULL)
+    {
+      *fLog << "MFindSupercuts::FindParams; training matrix is not defined... aborting"
+            << endl;
+      return kFALSE;
+    }
+
+    if (fMatrixTrain->GetM().GetNrows() <= 0)
+    {
+      *fLog << "MFindSupercuts::FindParams; training matrix has no entries"
+            << endl;
+      return kFALSE;
+    }
+
+    MParList  parlistfcn;
+    MTaskList tasklistfcn;
+
+    // loop over rows of matrix
+    MMatrixLoop loop(fMatrixTrain);
+
+    //--------------------------------
+    // create container for the supercut parameters
+    // and set them to their initial values
+    MSupercuts super;
+
+    // take initial values from file parSCinit
+    if (parSCinit != "")
+    {
+      TFile inparam(parSCinit);
+      super.Read("MSupercuts");
+      inparam.Close();
+      *fLog << "MFindSupercuts::FindParams; initial values of parameters are taken from file "
+            << parSCinit << endl;
+    }
+
+    // take initial values from 'params' and/or 'steps'
+    else if (params.GetSize() != 0  || steps.GetSize()  != 0 )
+    {
+      if (params.GetSize()  != 0)
+      {
+        *fLog << "MFindSupercuts::FindParams; initial values of parameters are taken from 'params'"
+              << endl;
+        super.SetParameters(params);
+      }
+      if (steps.GetSize()  != 0)
+      {
+        *fLog << "MFindSupercuts::FindParams; initial step sizes are taken from 'steps'"
+              << endl;
+        super.SetStepsizes(steps);
+      }
+    }
+    else
+    {
+        *fLog << "MFindSupercuts::FindParams; initial values and step sizes are taken from the MSupercuts constructor"
+              << endl;
+    }
+
+
+    //--------------------------------
+    // calculate supercuts hadronness
+    fCalcHadTrain->SetHadronnessName(fHadronnessName);
+
+    // apply the supercuts
+    MF scfilter(fHadronnessName+".fHadronness>0.5");
+    MContinue supercuts(&scfilter);
+
+    // plot |alpha|
+    const TString  mh3Name = "AlphaFcn";
+    MBinning binsalpha("Binning"+mh3Name);
+    binsalpha.SetEdges(54, -12.0, 96.0);
+
+    *fLog << warn << "WARNING------------>ALPHA IS ASSUMED TO BE IN COLUMN 7!!!!!!!!" << endl;
+
+    // |alpha| is assumed to be in column 7 of the matrix
+    MH3 alpha("MatrixTrain[7]");
+    alpha.SetName(mh3Name);
+
+    MFillH fillalpha(&alpha);
+
+    // book histograms to be filled during the optimization
+    //                              ! not in the event loop !
+    MHSupercuts plotsuper;
+    plotsuper.SetupFill(&parlistfcn);
+
+    //******************************
+    // entries in MParList (extension of old MParList)
+    
+    parlistfcn.AddToList(&tasklistfcn);
+    parlistfcn.AddToList(&super);
+    parlistfcn.AddToList(fCam);
+    parlistfcn.AddToList(fMatrixTrain);
+
+    parlistfcn.AddToList(&binsalpha);
+    parlistfcn.AddToList(&alpha);
+
+    parlistfcn.AddToList(&plotsuper);
+
+    //******************************
+    // entries in MTaskList
+
+    tasklistfcn.AddToList(&loop);
+    tasklistfcn.AddToList(fCalcHadTrain);
+    tasklistfcn.AddToList(&supercuts);
+    tasklistfcn.AddToList(&fillalpha);
+
+
+    //******************************
+
+    MEvtLoop evtloopfcn("EvtLoopFCN");
+    evtloopfcn.SetParList(&parlistfcn);
+    *fLog << "Event loop for fcnSupercuts has been setup" << endl;
+
+    // address of evtloopfcn is used in CallMinuit()
+
+
+    //-----------------------------------------------------------------------
+    //
+    //----------   Start of minimization part   --------------------
+    //
+    // Do the minimization with MINUIT
+    //
+    // Be careful: This is not thread safe
+    //
+    *fLog << "========================================================" << endl;
+    *fLog << "Start minimization for supercuts" << endl;
+
+
+    // -------------------------------------------
+    // prepare call to MINUIT
+    //
+
+    // get initial values of parameters 
+    fVinit = super.GetParameters();
+    fStep  = super.GetStepsizes();
+
+    TString name[fVinit.GetSize()];
+    fStep.Set(fVinit.GetSize());
+    fLimlo.Set(fVinit.GetSize());
+    fLimup.Set(fVinit.GetSize());
+    fFix.Set(fVinit.GetSize());
+
+    fNpar = fVinit.GetSize();
+
+    for (UInt_t i=0; i<fNpar; i++)
+    {
+        name[i]   = "p";
+        name[i]  += i+1;
+        //fStep[i]  = TMath::Abs(fVinit[i]/10.0);
+        fLimlo[i] = -100.0;
+        fLimup[i] =  100.0;
+        fFix[i]   =     0;
+    }
+
+    // these parameters make no sense, fix them at 0.0
+    fVinit[33] = 0.0;
+    fStep[33]  = 0.0;
+    fFix[33]   = 1;
+
+    fVinit[36] = 0.0;
+    fStep[36]  = 0.0;
+    fFix[36]   = 1;
+
+    fVinit[39] = 0.0;
+    fStep[39]  = 0.0;
+    fFix[39]   = 1;
+
+    fVinit[41] = 0.0;
+    fStep[41]  = 0.0;
+    fFix[41]   = 1;
+
+    fVinit[44] = 0.0;
+    fStep[44]  = 0.0;
+    fFix[44]   = 1;
+
+    fVinit[47] = 0.0;
+    fStep[47]  = 0.0;
+    fFix[47]   = 1;
+
+    // vary only first 48 parameters
+    //for (UInt_t i=0; i<fNpar; i++)
+    //{
+    //    if (i >= 48)
+    //	{
+    //      fStep[i] = 0.0;
+    //      fFix[i]  =   1;
+    //	}
+    //}
+ 
+
+    // -------------------------------------------
+    // call MINUIT
+
+    TStopwatch clock;
+    clock.Start();
+
+    *fLog << "before calling CallMinuit" << endl;
+
+    MMinuitInterface inter;               
+    Bool_t rc = inter.CallMinuit(fcnSupercuts, name,
+                                 fVinit, fStep, fLimlo, fLimup, fFix,
+                                 &evtloopfcn, "SIMPLEX", kFALSE);
+ 
+    *fLog << "after calling CallMinuit" << endl;
+
+    *fLog << "Time spent for the minimization in MINUIT :   " << endl;;
+    clock.Stop();
+    clock.Print();
+
+    plotsuper.DrawClone();
+
+    if (!rc)
+        return kFALSE;
+
+    *fLog << "Minimization for supercuts finished" << endl;
+    *fLog << "========================================================" << endl;
+
+
+    // -----------------------------------------------------------------
+    // in 'fcnSupercuts' (IFLAG=3) the optimum parameter values were put 
+    //                    into MSupercuts
+
+    // write optimum parameter values onto file filenameParam
+    
+    TFile outparam(fFilenameParam, "RECREATE"); 
+    super.Write();
+    outparam.Close();
+
+    *fLog << "Optimum parameter values for supercuts were written onto file '"
+              << fFilenameParam << "' :" << endl;
+
+    const TArrayD &check = super.GetParameters();
+    for (Int_t i=0; i<check.GetSize(); i++)
+        *fLog << check[i] << ",  ";
+    *fLog << endl;
+
+
+
+    *fLog << "End of  supercuts optimization part" << endl;
+    *fLog << "======================================================" << endl;
+
+    return kTRUE;
+}
+
+
+// -----------------------------------------------------------------------
+//
+// Test the supercuts on the test sample
+//
+
+Bool_t MFindSupercuts::TestParams()
+{
+    if (fMatrixTest->GetM().GetNrows() <= 0)
+    {
+        *fLog << "MFindSupercuts::TestParams; test matrix has no entries" 
+              << endl;
+        return kFALSE;
+    }
+
+    // -------------   TEST the supercuts    ------------------------------
+    //
+    *fLog << "Test the supercuts on the test sample" << endl;
+
+    // -----------------------------------------------------------------
+    // read optimum parameter values from file filenameParam
+    // into array 'supercutsPar'
+
+    TFile inparam(fFilenameParam);
+    MSupercuts scin; 
+    scin.Read("MSupercuts");
+    inparam.Close();
+
+    *fLog << "Optimum parameter values for supercuts were read from file '";
+    *fLog << fFilenameParam << "' :" << endl;
+
+    const TArrayD &supercutsPar = scin.GetParameters();
+    for (Int_t i=0; i<supercutsPar.GetSize(); i++)
+        *fLog << supercutsPar[i] << ",  ";
+    *fLog << endl;
+    //---------------------------
+
+
+    // -----------------------------------------------------------------
+    if (fHadronnessName.IsNull())
+    {
+        *fLog << "MFindSupercuts::TestParams; hadronness name is not defined... aborting";
+        *fLog << endl;
+        return kFALSE;
+    }
+
+    MParList  parlist2;
+    MTaskList tasklist2;
+
+    MSupercuts supercuts;
+    supercuts.SetParameters(supercutsPar);
+
+    fCalcHadTest->SetHadronnessName(fHadronnessName);
+
+
+    //-------------------------------------------
+
+    MMatrixLoop loop(fMatrixTest);
+
+    // plot alpha before applying the supercuts
+    const TString  mh3NameB = "AlphaBefore";
+    MBinning binsalphabef("Binning"+mh3NameB);
+    binsalphabef.SetEdges(54, -12.0, 96.0);
+
+    // |alpha| is assumed to be in column 7 of the matrix
+    MH3 alphabefore("MatrixTest[7]");
+    alphabefore.SetName(mh3NameB);
+
+    TH1 &alphahistb = alphabefore.GetHist();
+    alphahistb.SetName("alphaBefore-TestParams");
+
+    MFillH fillalphabefore(&alphabefore);
+    fillalphabefore.SetName("FillAlphaBefore");
+
+    // apply the supercuts
+    MF scfilter(fHadronnessName+".fHadronness>0.5");
+    MContinue applysupercuts(&scfilter);
+
+    // plot alpha after applying the supercuts
+    const TString  mh3NameA = "AlphaAfter";
+    MBinning binsalphaaft("Binning"+mh3NameA);
+    binsalphaaft.SetEdges(54, -12.0, 96.0);
+
+    MH3 alphaafter("MatrixTest[7]");
+    alphaafter.SetName(mh3NameA);
+
+    TH1 &alphahista = alphaafter.GetHist();
+    alphahista.SetName("alphaAfter-TestParams");
+
+    MFillH fillalphaafter(&alphaafter);
+    fillalphaafter.SetName("FillAlphaAfter");
+
+    //******************************
+    // entries in MParList
+
+    parlist2.AddToList(&tasklist2);
+
+    parlist2.AddToList(&supercuts);
+
+    parlist2.AddToList(fCam);
+    parlist2.AddToList(fMatrixTest);
+
+    parlist2.AddToList(&binsalphabef);
+    parlist2.AddToList(&alphabefore);
+
+    parlist2.AddToList(&binsalphaaft);
+    parlist2.AddToList(&alphaafter);
+
+    //******************************
+    // entries in MTaskList
+
+    tasklist2.AddToList(&loop);
+    tasklist2.AddToList(&fillalphabefore);
+
+    tasklist2.AddToList(fCalcHadTest);
+    tasklist2.AddToList(&applysupercuts);
+
+    tasklist2.AddToList(&fillalphaafter);
+
+    //******************************
+
+    MProgressBar bar2;
+    MEvtLoop evtloop2;
+    evtloop2.SetParList(&parlist2);
+    evtloop2.SetName("EvtLoopTestParams");
+    evtloop2.SetProgressBar(&bar2);
+    Int_t maxevents2 = -1;
+    if (!evtloop2.Eventloop(maxevents2))
+        return kFALSE;
+
+    tasklist2.PrintStatistics(0, kTRUE);
+
+
+    //-------------------------------------------
+    // draw the alpha plots
+
+    MH3* alphaBefore = (MH3*)parlist2.FindObject(mh3NameB, "MH3");
+    TH1  &alphaHist1 = alphaBefore->GetHist();
+    alphaHist1.SetXTitle("|\\alpha|  [\\circ]");
+
+    MH3* alphaAfter = (MH3*)parlist2.FindObject(mh3NameA, "MH3");
+    TH1  &alphaHist2 = alphaAfter->GetHist();
+    alphaHist2.SetXTitle("|\\alpha|  [\\circ]");
+    alphaHist2.SetName("alpha-TestParams");
+
+    TCanvas *c = new TCanvas("AlphaAfterSC", "AlphaTest", 600, 300);
+    c->Divide(2,1);
+
+    gROOT->SetSelectedPad(NULL);
+
+    c->cd(1);
+    alphaHist1.DrawCopy();
+
+    c->cd(2);
+    alphaHist2.DrawCopy();
+
+
+
+    //-------------------------------------------
+    // fit alpha distribution to get the number of excess events and
+    // calculate significance of gamma signal in the alpha plot
+  
+    const Double_t alphasig = 20.0;
+    const Double_t alphamin = 30.0;
+    const Double_t alphamax = 90.0;
+    const Int_t    degree   =    2;
+    const Bool_t   drawpoly  = kTRUE;
+    const Bool_t   fitgauss  = kTRUE;
+    const Bool_t   print     = kTRUE;
+
+    MHFindSignificance findsig;
+    findsig.SetRebin(kTRUE);
+    findsig.SetReduceDegree(kFALSE);
+
+    findsig.FindSigma(&alphaHist2, alphamin, alphamax, degree, 
+                      alphasig, drawpoly, fitgauss, print);
+
+    const Double_t significance = findsig.GetSignificance();
+    const Double_t alphasi = findsig.GetAlphasi();
+
+    *fLog << "Significance of gamma signal after supercuts in test sample : "
+         << significance << " (for |alpha| < " << alphasi << " degrees)" 
+         << endl;
+    //-------------------------------------------
+
+
+    *fLog << "Test of supercuts part finished" << endl;
+    *fLog << "======================================================" << endl;
+
+    return kTRUE;
+}
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MFindSupercuts.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MFindSupercuts.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MFindSupercuts.h	(revision 9661)
@@ -0,0 +1,132 @@
+#ifndef MARS_MFindSupercuts
+#define MARS_MFindSupercuts
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#ifndef ROOT_TArrayD
+#include <TArrayD.h>
+#endif
+#ifndef ROOT_TArrayI
+#include <TArrayI.h>
+#endif
+
+class MFilter;
+class MEvtLoop;
+class MH3;
+class MSupercutsCalc;
+class MGeomCam;
+class MHMatrix;
+/*
+#include "MFilter.h"
+#include "MEvtLoop.h"
+#include "MH3.h"
+#include "MSupercutsCalc.h"
+#include "MGeomCam.h"
+#include "MHMatrix.h"
+*/
+
+class MFindSupercuts : public MParContainer
+{
+private:
+
+  TString fFilenameTrain;
+  TString fFilenameTest;
+
+  Int_t   fHowManyTrain;
+  Int_t   fHowManyTest;
+
+  Bool_t  fUseOrigDistribution;
+
+  TString  fFilenameParam;
+
+  TString  fHadronnessName;
+
+  MSupercutsCalc *fCalcHadTrain;
+  MSupercutsCalc *fCalcHadTest;
+
+  MHMatrix          *fMatrixTrain;
+  MHMatrix          *fMatrixTest;
+  MGeomCam          *fCam;
+
+  MEvtLoop *fObjectFit;
+
+  MFilter  *fMatrixFilter; 
+
+  // to comunicate with MINUIT -----------------
+  // attention : dimensions must agree with those in 
+  //             MMinuitInterface::CallMinuit()
+  //char    fParName [80][100];
+  TArrayD fVinit;
+  TArrayD fStep;
+  TArrayD fLimlo;
+  TArrayD fLimup;
+  TArrayI fFix;
+
+  UInt_t     fNpar;
+
+  TString    fMethod;
+
+  Double_t fMin,   fEdm,   fErrdef;
+  Int_t    fNpari, fNparx, fIstat;
+  Int_t    fErrMinimize;
+  //--------------------------------------------
+
+
+public:
+  MFindSupercuts(const char *name=NULL, const char *title=NULL);
+  ~MFindSupercuts();
+
+  void SetFilenameTraining(const TString &name, const Int_t howmany) 
+      {fFilenameTrain = name;  fHowManyTrain = howmany; }
+
+  void SetFilenameTest(const TString &name, const Int_t howmany)     
+      {fFilenameTest     = name;  fHowManyTest  = howmany; }
+
+  void SetFilenameParam(const TString &name)    {fFilenameParam  = name;}
+  void SetHadronnessName(const TString &name)   {fHadronnessName = name;}
+
+  void SetMatrixFilter(MFilter *filter)          {fMatrixFilter = filter;}
+
+  Bool_t DefineTrainMatrix(const TString &name, MH3 &href,
+                           const Int_t howmany, const TString &filetrain); 
+
+  Bool_t DefineTestMatrix(const TString &name, MH3 &href,
+                          const Int_t howmany, const TString &filetest);
+
+  Bool_t DefineTrainTestMatrix(const TString &name, MH3 &href,
+			 const Int_t howmanytrain, const Int_t howmanytest, 
+                         const TString &filetrain, const TString &filetest);
+
+  MHMatrix *GetMatrixTrain() { return fMatrixTrain; }
+  MHMatrix *GetMatrixTest()  { return fMatrixTest;  }
+
+  Bool_t ReadMatrix( const TString &filetrain, const TString &filetest);
+
+  Bool_t FindParams(TString parSCinit, TArrayD &params, TArrayD &steps);
+  Bool_t TestParams();
+
+  ClassDef(MFindSupercuts, 1) // Class for optimization of the Supercuts
+};
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MGeomApply.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MGeomApply.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MGeomApply.cc	(revision 9661)
@@ -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, 09/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!              Markus Gaug,  03/2004 <mailto:markus@ifae.es>
+!              Hendrik Bartko, 07/2003 <mailto:hbartko@mppmu.mpg.de>
+!         
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MGeomApply
+//
+//  Applies the geometry to geometry dependant containers.
+//
+//  It changes the size of the arrays in the containers to a size
+//  matching the number of pixels, eg:
+//
+//   MPedestalCam
+//   MCalibrationChargeCam
+//   MCalibrationRelTimeCam
+//   MCalibrationQECam
+//   MCalibrationPedCam
+//   MPedPhotCam
+//   MExtractedSignalCam
+//   MArrivalTimeCam
+//   MArrivalTime
+//
+//  It uses the geometry (MGeomCam) found in the parameter list.
+//  If it is not found the task tries to create the geometry
+//  specified in the constructor. The default geometry is
+//  MGeomCamMagic.
+// 
+//  Input Containers:
+//   [MGeomCam]
+//
+//  Output Containers:
+//   [MPedestalCam]
+//   [MCalibrationChargeCam]
+//   [MCalibrationRelTimeCam]
+//   [MCalibrationQECam]
+//   [MCalibrationPedCam]
+//   [MPedPhotCam]
+//   [MExtractedSignalCam]
+//   [MArrivalTime]
+//   [MArrivalTimeCam]
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MGeomApply.h"
+
+#include <fstream>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MGeomCam.h"
+#include "MPedestalCam.h"
+#include "MCalibrationCam.h"
+#include "MPedPhotCam.h"
+#include "MExtractedSignalCam.h"
+#include "MArrivalTimeCam.h"
+#include "MArrivalTime.h"
+#include "MBadPixelsCam.h"
+
+ClassImp(MGeomApply);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+//  Default constructor. MGeomCamMagic is the default geometry.
+//
+MGeomApply::MGeomApply(const char *name, const char *title) : fGeomName("MGeomCamMagic")
+{
+    fName  = name  ? name  : "MGeomApply";
+    fTitle = title ? title : "Task to apply geometry settings";
+}
+
+// --------------------------------------------------------------------------
+//
+//  Try to find 'MGeomCam' in the Parameter List. If it is not found,
+//  try to create a fGeomName object.
+//
+Int_t MGeomApply::PreProcess(MParList *pList)
+{
+    MGeomCam *cam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
+    if (cam)
+        return kTRUE;
+
+    cam = (MGeomCam*)pList->FindCreateObj(AddSerialNumber(fGeomName), "MGeomCam");
+
+    return cam ? kTRUE : kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Try to find 'MGeomCam' in the Parameter List. If it is not found,
+//  processing is stopped.
+//
+Bool_t MGeomApply::ReInit(MParList *pList)
+{
+    MGeomCam *cam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
+    if (!cam)
+    {
+       *fLog << err << GetDescriptor() << ": No MGeomCam found... aborting." << endl;
+        return kFALSE;
+    }
+
+    // FIXME, workaround: this call to CalcPixRatio is here just to allow
+    // the use of some camera files from the 0.7 beta version in which the 
+    // array containing pixel ratios is not initialized.
+    cam->CalcPixRatio();
+
+    MPedestalCam *ped = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
+    if (ped)
+        ped->Init(*cam);
+
+    MCalibrationCam *cal = (MCalibrationCam*)pList->FindObject(AddSerialNumber("MCalibrationChargeCam"));
+    if (cal)
+        cal->Init(*cam);
+
+    MCalibrationCam *cat = (MCalibrationCam*)pList->FindObject(AddSerialNumber("MCalibrationRelTimeCam"));
+    if (cat)
+        cat->Init(*cam);
+
+    MCalibrationCam *qe = (MCalibrationCam*)pList->FindObject(AddSerialNumber("MCalibrationQECam"));
+    if (qe)
+        qe->Init(*cam);
+
+    MCalibrationCam *pcam = (MCalibrationCam*)pList->FindObject(AddSerialNumber("MCalibrationPedCam"));
+    if (pcam)
+        pcam->Init(*cam);
+
+    MPedPhotCam *pedphot = (MPedPhotCam*)pList->FindObject(AddSerialNumber("MPedPhotCam"));
+    if (pedphot)
+        pedphot->Init(*cam);
+
+    MExtractedSignalCam *ext = (MExtractedSignalCam*)pList->FindObject(AddSerialNumber("MExtractedSignalCam"));
+    if (ext)
+        ext->InitSize(cam->GetNumPixels());
+
+    MArrivalTimeCam *tme = (MArrivalTimeCam*)pList->FindObject(AddSerialNumber("MArrivalTimeCam"));
+    if (tme)
+      tme->InitSize(cam->GetNumPixels());
+
+    MArrivalTime    *atm = (MArrivalTime*)pList->FindObject(AddSerialNumber("MArrivalTime"));
+    if (atm)
+      atm->InitSize(cam->GetNumPixels());
+
+    MBadPixelsCam *bad = (MBadPixelsCam*)pList->FindObject(AddSerialNumber("MBadPixelsCam"));
+    if (bad)
+      bad->InitSize(cam->GetNumPixels());
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
+void MGeomApply::StreamPrimitive(ofstream &out) const
+{
+    out << "   " << ClassName() << " " << GetUniqueName() << "(\"";
+    out << "\"" << fName << "\", \"" << fTitle << "\");" << endl;
+
+    if (fGeomName.IsNull())
+        return;
+
+    out << "   " << GetUniqueName() << ".SetGeometry(\"";
+    out << fGeomName << "\");" << endl;
+}
Index: /tags/Mars_V0-8-5/Mars/manalysis/MGeomApply.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MGeomApply.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MGeomApply.h	(revision 9661)
@@ -0,0 +1,28 @@
+#ifndef MARS_MGeomApply
+#define MARS_MGeomApply
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MParList;
+
+class MGeomApply : public MTask
+{
+private:
+    TString fGeomName; // Name of geometry class
+
+    Int_t  PreProcess(MParList *plist);
+    Bool_t ReInit(MParList *pList);
+    void   StreamPrimitive(ofstream &out) const;
+
+public:
+    MGeomApply(const char *name=NULL, const char *title=NULL);
+
+    void SetGeometry(TString geom) { fGeomName = geom; }
+
+    ClassDef(MGeomApply, 0) // Task to apply geometry settings
+};
+    
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MHPedestalCam.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MHPedestalCam.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MHPedestalCam.cc	(revision 9661)
@@ -0,0 +1,584 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@atsro.uni-wuerzburh.de>
+!   Author(s): Markus Gaug   02/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHPedestalCam
+//
+// Fills the extracted pedestals of MExtractedSignalCam into
+// the MHGausEvents-classes MHPedestalPix for every:
+//
+// - Pixel, stored in the TObjArray's MHCalibrationCam::fHiGainArray
+//   or MHCalibrationCam::fHiGainArray, respectively, depending if
+//   MArrivalTimePix::IsLoGainUsed() is set.
+//
+// - Average pixel per AREA index (e.g. inner and outer for the MAGIC camera),
+//   stored in the TObjArray's MHCalibrationCam::fAverageHiGainAreas and
+//   MHCalibrationCam::fAverageHiGainAreas
+//
+// - Average pixel per camera SECTOR (e.g. sectors 1-6 for the MAGIC camera),
+//   stored in the TObjArray's MHCalibrationCam::fAverageHiGainSectors
+//   and MHCalibrationCam::fAverageHiGainSectors
+//
+// Every pedestal is directly taken from MExtractedSignalCam, filled by the
+// appropriate extractor.
+//
+// The pedestals are filled into a histogram and an array, in order to perform
+// a Fourier analysis (see MHGausEvents). The signals are moreover averaged on an
+// event-by-event basis and written into the corresponding average pixels.
+//
+// The histograms are fitted to a Gaussian, mean and sigma with its errors
+// and the fit probability are extracted. If none of these values are NaN's and
+// if the probability is bigger than MHGausEvents::fProbLimit (default: 0.5%),
+// the fit is declared valid.
+// Otherwise, the fit is repeated within ranges of the previous mean
+// +- MHGausEvents::fPickupLimit (default: 5) sigma (see MHGausEvents::RepeatFit())
+// In case this does not make the fit valid, the histogram means and RMS's are
+// taken directly (see MHGausEvents::BypassFit()).
+//
+// Outliers of more than MHGausEvents::fPickupLimit (default: 5) sigmas
+// from the mean are counted as Pickup events (stored in MHGausEvents::fPickup)
+//
+// The number of summed FADC slices is taken to re-normalize
+// the result to a pedestal per pixel with the formulas (see MHPedestalPix::Renorm()):
+// - Mean Pedestal        / slice = Mean Pedestal        / Number slices
+// - Mean Pedestal Error  / slice = Mean Pedestal Error  / Number slices
+// - Sigma Pedestal       / slice = Sigma Pedestal       / Sqrt (Number slices)
+// - Sigma Pedestal Error / slice = Sigma Pedestal Error / Sqrt (Number slices)
+//
+// The class also fills arrays with the signal vs. event number, creates a fourier
+// spectrum (see MHGausEvents::CreateFourierSpectrum()) and investigates if the
+// projected fourier components follow an exponential distribution.
+//
+// This same procedure is performed for the average pixels.
+//
+// The following results are written into MPedestalCam:
+//
+// - MCalibrationPix::SetMean()
+// - MCalibrationPix::SetMeanErr()
+// - MCalibrationPix::SetSigma()
+// - MCalibrationPix::SetSigmaErr()
+// - MCalibrationPix::SetProb()
+// - MCalibrationPix::SetNumPickup()
+//
+// For all averaged areas, the fitted sigma is multiplied with the square root of
+// the number involved pixels in order to be able to compare it to the average of
+// sigmas in the camera.
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MHPedestalCam.h"
+#include "MHPedestalPix.h"
+
+#include "MBadPixelsCam.h"
+#include "MBadPixelsPix.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MExtractedSignalCam.h"
+#include "MExtractedSignalPix.h"
+
+#include "MPedestalCam.h"
+#include "MPedestalPix.h"
+
+#include "MGeomCam.h"
+#include "MGeomPix.h"
+
+#include "MCalibrationPedCam.h"
+
+#include "TH1.h"
+
+ClassImp(MHPedestalCam);
+
+using namespace std;
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+// Initializes:
+// - fExtractHiGainSlices to 0.
+// - fExtractLoGainSlices to 0.
+// - the event frequency to 1200 Hz.
+// - the fRenorm flag to kTRUE
+//
+MHPedestalCam::MHPedestalCam(const char *name, const char *title) 
+    : fExtractHiGainSlices(0.), fExtractLoGainSlices(0.)
+{
+    fName  = name  ? name  : "MHPedestalCam";
+    fTitle = title ? title : "";
+
+    SetPulserFrequency(1200);
+    SetRenorm();
+}
+
+
+
+// --------------------------------------------------------------------------
+//
+// Searches pointer to:
+// - MPedestalCam
+// - MExtractedSignalCam
+//
+// Searches or creates:
+// - MCalibrationPedCam
+//
+// Retrieves from MExtractedSignalCam:
+// - number of used High Gain FADC slices (MExtractedSignalCam::GetNumUsedHiGainFADCSlices())
+// - number of used Low  Gain FADC slices (MExtractedSignalCam::GetNumUsedLoGainFADCSlices())
+//
+// Initializes, if empty to MGeomCam::GetNumPixels():
+// - MHCalibrationCam::fHiGainArray, MHCalibrationCam::fLoGainArray
+//
+// Initializes, if empty to MGeomCam::GetNumAreas() for:
+// - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
+//
+// Initializes, if empty to MGeomCam::GetNumSectors() for:
+// - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
+// 
+// Calls MHCalibrationCam::InitPedHists() for every entry in:
+// - MHCalibrationCam::fHiGainArray, MHCalibrationCam::fLoGainArray
+// - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
+// - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
+//
+// Sets Titles and Names for the Histograms 
+// - MHCalibrationCam::fAverageHiGainAreas
+// - MHCalibrationCam::fAverageHiGainSectors
+// 
+// Sets number of bins to MHCalibrationCam::fAverageNbins for:
+// - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
+// - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
+//
+Bool_t MHPedestalCam::ReInitHists(MParList *pList)
+{
+
+  MExtractedSignalCam *signal = (MExtractedSignalCam*)pList->FindObject("MExtractedSignalCam");
+  if (!signal)
+    {
+      gLog << err << "Cannot find MExtractedSignalCam... abort." << endl;
+      return kFALSE;
+    }
+  
+
+  fPedestals = (MPedestalCam*)pList->FindObject("MPedestalCam");
+
+  if (!fPedestals)
+    {
+      gLog << err << "Cannot find MPedestalCam ... abort." << endl;
+      return kFALSE;
+    }
+
+  const Int_t npixels  = fGeom->GetNumPixels();
+  const Int_t nsectors = fGeom->GetNumSectors();
+  const Int_t nareas   = fGeom->GetNumAreas();
+
+  fCam = (MCalibrationCam*)pList->FindObject("MCalibrationPedCam");
+  if (!fCam)
+  {
+      fCam = (MCalibrationCam*)pList->FindCreateObj(AddSerialNumber("MCalibrationPedCam"));
+      if (!fCam)
+          return kFALSE;
+
+      fCam->Init(*fGeom);
+  }
+  
+  Float_t sliceshi = signal->GetNumUsedHiGainFADCSlices();
+  Float_t sliceslo = signal->GetNumUsedLoGainFADCSlices();
+
+  if (sliceshi == 0.)
+    {
+      gLog << err << "Number of used signal slices in MExtractedSignalCam is zero  ... abort." 
+           << endl;
+      return kFALSE;
+    }
+
+  if (fExtractHiGainSlices != 0. && sliceshi != fExtractHiGainSlices )
+    {
+      gLog << err << "Number of used High Gain signal slices changed in MExtractedSignalCam  ... abort." 
+           << endl;
+      return kFALSE;
+    }
+
+  if (fExtractLoGainSlices != 0. && sliceslo != fExtractLoGainSlices )
+    {
+      gLog << err << "Number of used Low Gain signal slices changed in MExtractedSignalCam  ... abort." 
+           << endl;
+      return kFALSE;
+    }
+
+  fExtractHiGainSlices = sliceshi;
+  fExtractLoGainSlices = sliceslo;
+
+  if (fHiGainArray->GetEntries()==0)
+  {
+      fHiGainArray->Expand(npixels);
+      for (Int_t i=0; i<npixels; i++)
+      {
+	  (*fHiGainArray)[i] = new MHPedestalPix;
+          InitPedHists((MHPedestalPix&)(*this)[i],i,fExtractHiGainSlices);
+          
+          if ((*fBadPixels)[i].IsBad())
+            (*this)[i].SetExcluded();
+
+          (*fPedestals)[i].InitUseHists();
+      }
+
+  }
+
+  if (fLoGainArray->GetEntries()==0)
+  {
+      fLoGainArray->Expand(npixels);
+      for (Int_t i=0; i<npixels; i++)
+      {
+	  (*fLoGainArray)[i] = new MHPedestalPix;
+          InitPedHists((MHPedestalPix&)(*this)(i),i,fExtractLoGainSlices);
+
+          if ((*fBadPixels)[i].IsBad())
+            (*this)(i).SetExcluded();
+      }
+  }
+
+  if (fAverageHiGainAreas->GetEntries()==0)
+  {
+    fAverageHiGainAreas->Expand(nareas);
+    
+    for (Int_t j=0; j<nareas; j++)
+      {
+        (*fAverageHiGainAreas)[j] = 
+          new MHPedestalPix("AverageHiGainArea",
+                                      "Average Pedestals area idx ");
+
+        GetAverageHiGainArea(j).GetHGausHist()->SetTitle("Pedestals average Area Idx ");
+        GetAverageHiGainArea(j).SetNbins(fAverageNbins);
+
+        InitPedHists((MHPedestalPix&)GetAverageHiGainArea(j),j,fExtractHiGainSlices);
+
+      }
+  }
+
+  if (fAverageLoGainAreas->GetEntries()==0)
+  {
+    fAverageLoGainAreas->Expand(nareas);
+    
+    for (Int_t j=0; j<nareas; j++)
+      {
+        (*fAverageLoGainAreas)[j] = 
+          new MHPedestalPix("AverageLoGainArea",
+                                      "Pedestals average Area idx ");
+
+        GetAverageLoGainArea(j).GetHGausHist()->SetTitle("Pedestals average Area Idx ");
+        GetAverageLoGainArea(j).SetNbins(fAverageNbins);
+
+        InitPedHists((MHPedestalPix&)GetAverageLoGainArea(j),j,fExtractLoGainSlices);
+
+      }
+  }
+
+  if (fAverageHiGainSectors->GetEntries()==0)
+  {
+      fAverageHiGainSectors->Expand(nsectors);
+
+      for (Int_t j=0; j<nsectors; j++)
+      {
+	  (*fAverageHiGainSectors)[j] = 
+            new MHPedestalPix("AverageHiGainSector",
+                                        "Pedestals average sector ");
+
+          GetAverageHiGainSector(j).GetHGausHist()->SetTitle("Pedestals average Sector ");
+          GetAverageHiGainSector(j).SetNbins(fAverageNbins);
+
+          InitPedHists((MHPedestalPix&)GetAverageHiGainSector(j),j,fExtractHiGainSlices);
+
+      }
+  }
+
+  if (fAverageLoGainSectors->GetEntries()==0)
+  {
+      fAverageLoGainSectors->Expand(nsectors);
+
+      for (Int_t j=0; j<nsectors; j++)
+      {
+	  (*fAverageLoGainSectors)[j] = 
+            new MHPedestalPix("AverageLoGainSector",
+                                        "Pedestals average sector ");
+
+          GetAverageLoGainSector(j).GetHGausHist()->SetTitle("Pedestals average Sector ");
+          GetAverageLoGainSector(j).SetNbins(fAverageNbins);
+
+          InitPedHists((MHPedestalPix&)GetAverageLoGainSector(j),j,fExtractLoGainSlices);
+          
+      }
+  }
+
+  return kTRUE;
+}
+
+
+// -------------------------------------------------------------
+//
+// If MBadPixelsPix::IsBad():
+// - calls MHGausEvents::SetExcluded()
+//
+// Calls:
+// - MHGausEvents::InitBins()
+// - MHGausEvents::ChangeHistId(i)
+// - MHGausEvents::SetEventFrequency(fPulserFrequency)
+// - MHPedestalPix::SetNSlices(nslices)
+//
+void MHPedestalCam::InitPedHists(MHPedestalPix &hist, const Int_t i, const Float_t nslices)
+{
+  hist.InitBins();
+  hist.ChangeHistId(i);
+  hist.SetEventFrequency(fPulserFrequency);
+
+  if (fRenorm)
+    hist.SetNSlices(nslices);
+
+  hist.SetProbLimit(0.);
+
+  TH1F *h = hist.GetHGausHist();
+  h->SetTitle( Form("%s%s", h->GetTitle()," Runs: "));
+}
+// -------------------------------------------------------------------------------
+//
+// Retrieves pointer to MExtractedSignalCam:
+//
+// Retrieves from MGeomCam:
+// - number of pixels
+// - number of pixel areas
+// - number of sectors
+//
+// Fills HiGain or LoGain histograms (MHGausEvents::FillHistAndArray()), respectively
+// with the signals MExtractedSignalCam::GetExtractedSignalHiGain() and 
+// MExtractedSignalCam::GetExtractedSignalLoGain(), respectively.
+//
+Bool_t MHPedestalCam::FillHists(const MParContainer *par, const Stat_t w)
+{
+
+  MExtractedSignalCam *signal = (MExtractedSignalCam*)par;
+  if (!signal)
+    {
+      gLog << err << "No argument in MExtractedSignalCam::Fill... abort." << endl;
+      return kFALSE;
+    }
+  
+  const UInt_t npixels  = fGeom->GetNumPixels();
+  const UInt_t nareas   = fGeom->GetNumAreas();
+  const UInt_t nsectors = fGeom->GetNumSectors();
+
+  TArrayF sumareahi(nareas);
+  TArrayF sumarealo(nareas);
+  TArrayF sumsectorhi(nsectors);
+  TArrayD sumsectorlo(nsectors);
+  TArrayI numareahi(nareas);
+  TArrayI numarealo(nareas);
+  TArrayI numsectorhi(nsectors);
+  TArrayI numsectorlo(nsectors);
+
+  for (UInt_t i=0; i<npixels; i++)
+  {
+      MHGausEvents &histhi = (*this)[i];
+      MHGausEvents &histlo = (*this)(i);
+
+      if (histhi.IsExcluded())
+          continue;
+
+      const MExtractedSignalPix &pix = (*signal)[i];
+
+      const Float_t pedhi = pix.GetExtractedSignalHiGain();
+      const Float_t pedlo = pix.GetExtractedSignalLoGain();
+
+      const Int_t aidx   = (*fGeom)[i].GetAidx();
+      const Int_t sector = (*fGeom)[i].GetSector();
+
+      histhi.FillHistAndArray(pedhi) ;
+      sumareahi  [aidx]   += pedhi;
+      numareahi  [aidx]   ++;
+      sumsectorhi[sector] += pedhi;
+      numsectorhi[sector] ++;
+
+      histlo.FillHistAndArray(pedlo);
+      sumarealo  [aidx]   += pedlo;
+      numarealo  [aidx]   ++;
+      sumsectorlo[sector] += pedlo;
+      numsectorlo[sector] ++;
+
+    }
+  
+  for (UInt_t j=0; j<nareas; j++)
+    {
+      MHGausEvents &histhi = GetAverageHiGainArea(j);
+      histhi.FillHistAndArray(numareahi[j] == 0 ? 0. : sumareahi[j]/numareahi[j]);
+
+      MHGausEvents &histlo = GetAverageLoGainArea(j);
+      histlo.FillHistAndArray(numarealo[j] == 0 ? 0. : sumarealo[j]/numarealo[j]);
+    }
+  
+  for (UInt_t j=0; j<nsectors; j++)
+    {
+      MHGausEvents &histhi = GetAverageHiGainSector(j);
+      histhi.FillHistAndArray(numsectorhi[j] == 0 ? 0. : sumsectorhi[j]/numsectorhi[j]);
+
+      MHGausEvents &histlo = GetAverageLoGainSector(j);
+      histlo.FillHistAndArray(numsectorlo[j] == 0 ? 0. : sumsectorlo[j]/numsectorlo[j]);
+    }
+  
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calls:
+// - MHCalibrationCam::FitHiGainArrays() with Bad Pixels flags 0
+// - MHCalibrationCam::FitLoGainArrays() with Bad Pixels flags 0
+// 
+Bool_t MHPedestalCam::FinalizeHists()
+{
+
+  FitHiGainArrays((*fCam),*fBadPixels, 
+                  MBadPixelsPix::kHiGainNotFitted,
+                  MBadPixelsPix::kHiGainOscillating);
+  FitLoGainArrays((*fCam),*fBadPixels,
+                  MBadPixelsPix::kLoGainNotFitted,
+                  MBadPixelsPix::kLoGainOscillating);
+
+
+  return kTRUE;
+  
+
+}
+
+// ------------------------------------------------------------------
+//
+// The types are as follows:
+// 
+// Fitted values:
+// ============== 
+//
+// 0: Fitted Charge
+// 1: Error of fitted Charge
+// 2: Sigma of fitted Charge
+// 3: Error of Sigma of fitted Charge
+//
+//
+// Useful variables derived from the fit results:
+// =============================================
+//
+// 4: Returned probability of Gauss fit to Charge distribution
+// 5: Relative differenc of calculated pedestal (per slice) and fitted (per slice)
+// 6: Error of the Relative differenc of calculated pedestal (per slice) and fitted (per slice)
+// 7: Relative difference of the error of the mean pedestal (per slice) - calculated and fitted
+// 8: Relative differenc of calculated pedestal RMS (per slice) and fitted sigma (per slice)
+// 9: Error of Relative differenc of calculated pedestal RMS (per slice) and fitted sigma (per slice)
+// 10: Relative difference of the error of the pedestal RMS (per slice) - calculated and fitted
+//
+// Localized defects:
+// ==================
+//
+// 11: Gaus fit not OK
+// 12: Fourier spectrum not OK
+//
+Bool_t MHPedestalCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
+{
+
+  if (fHiGainArray->GetSize() <= idx)
+    return kFALSE;
+
+  if ((*this)[idx].IsExcluded())
+    return kFALSE;
+
+  const Float_t ped      = (*fPedestals)[idx].GetPedestal();
+  const Float_t rms      = (*fPedestals)[idx].GetPedestalRms();
+
+  const Float_t entsqr    =  TMath::Sqrt((Float_t)fPedestals->GetTotalEntries());
+
+  const Float_t pederr   = rms/entsqr;
+  const Float_t rmserr   = rms/entsqr/2.;
+
+  const Float_t mean     = (*this)[idx].GetMean();
+  const Float_t meanerr  = (*this)[idx].GetMeanErr();
+  const Float_t sigma    = (*this)[idx].GetSigma() ;
+  const Float_t sigmaerr = (*this)[idx].GetSigmaErr();
+
+  switch (type)
+    {
+    case 0:
+      val = mean;
+      break;
+    case 1:
+      val = meanerr;
+      break;
+    case 2:
+      val = sigma;
+      break;
+    case 3:
+      val = sigmaerr;
+      break;
+    case 4:
+      val = (*this)[idx].GetProb();
+      break;
+    case 5:
+      val = 2.*(mean-ped)/(ped+mean);
+      break;
+    case 6:
+      val = TMath::Sqrt((pederr*pederr + meanerr*meanerr) * (ped*ped + mean*mean))
+            *2./(ped+mean)/(ped+mean);
+      break;
+    case 7:
+      val = 2.*(meanerr-pederr)/(pederr + meanerr);
+      break;
+    case 8:
+      val = 2.*(sigma-rms)/(sigma+rms);
+      break;
+    case 9:
+      val = TMath::Sqrt((rmserr*rmserr + sigmaerr*sigmaerr) * (rms*rms + sigma*sigma))
+            *2./(rms+sigma)/(rms+sigma);
+      break;
+    case 10:
+      val = 2.*(sigmaerr - rmserr)/(sigmaerr + rmserr);
+      break;
+    case 11:
+      if (!(*this)[idx].IsGausFitOK())
+        val = 1.;
+      break;
+    case 12:
+      if (!(*this)[idx].IsFourierSpectrumOK())
+        val = 1.;
+      break;
+    default:
+      return kFALSE;
+    }
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calls MHGausEvents::DrawClone() for pixel idx
+//
+void MHPedestalCam::DrawPixelContent(Int_t idx) const
+{
+  (*this)[idx].DrawClone();
+}
Index: /tags/Mars_V0-8-5/Mars/manalysis/MHPedestalCam.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MHPedestalCam.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MHPedestalCam.h	(revision 9661)
@@ -0,0 +1,42 @@
+#ifndef MARS_MHPedestalCam
+#define MARS_MHPedestalCam
+
+#ifndef MARS_MHCalibrationCam
+#include "MHCalibrationCam.h"
+#endif
+
+class MGeomCam;
+class MPedestalCam;
+class MHPedestalPix;
+class MHPedestalCam : public MHCalibrationCam
+{
+
+private:
+
+  void   InitPedHists(MHPedestalPix &hist, const Int_t i, const Float_t nslices);
+  
+  Bool_t ReInitHists(MParList *pList);
+  Bool_t FillHists(const MParContainer *par, const Stat_t w=1);
+  Bool_t FinalizeHists();
+  
+  Float_t fExtractHiGainSlices;           // Number of FADC slices used for high gain signal extraction
+  Float_t fExtractLoGainSlices;           // Number of FADC slices used for low  gain signal extraction
+
+  Bool_t  fRenorm;
+
+  MPedestalCam *fPedestals;               //! Pedestal Cam filled by MPedCalcPedRun
+  
+public:
+  MHPedestalCam(const char *name=NULL, const char *title=NULL);
+  ~MHPedestalCam() {}
+  
+  Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
+  void DrawPixelContent(Int_t idx) const;
+  
+  void SetRenorm( const Bool_t b=kTRUE )  {  fRenorm = b; }
+
+  ClassDef(MHPedestalCam, 1)	// Histogram class for Charge Camera Pedestals 
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MHPedestalPix.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MHPedestalPix.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MHPedestalPix.cc	(revision 9661)
@@ -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): Markus Gaug 02/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MHPedestalPix
+//
+//  Histogram class for pedestal analysis. 
+//  Stores and fits the pedestals taken from MPedestalPix on an event-by-event
+//  basis. The results are re-normalized to a value per slice with the formulae:
+//
+// - Mean Pedestal        / slice = Mean Pedestal        / Number slices
+// - Mean Pedestal Error  / slice = Mean Pedestal Error  / Number slices
+// - Sigma Pedestal       / slice = Sigma Pedestal       / Sqrt (Number slices)
+// - Sigma Pedestal Error / slice = Sigma Pedestal Error / Sqrt (Number slices)
+// 
+//  Derives from MHGausEvents, fits the pedestals to a Gaussian and performs
+//  a Fourier analysis.
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MHPedestalPix.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include <TH1.h>
+
+ClassImp(MHPedestalPix);
+
+using namespace std;
+//
+const Int_t   MHPedestalPix::fgChargeNbins    = 500;
+const Axis_t  MHPedestalPix::fgChargeFirst    = -49.5;
+const Axis_t  MHPedestalPix::fgChargeLast     = 449.5;
+// --------------------------------------------------------------------------
+//
+// Default Constructor. 
+//
+// Sets: 
+// - the default number for fNbins        (fgChargeNbins)
+// - the default number for fFirst        (fgChargeFirst)
+// - the default number for fLast         (fgChargeLast)
+//
+// - the default name of the  fHGausHist ("HPedestalCharge")
+// - the default title of the fHGausHist ("Distribution of Summed FADC Pedestal slices Pixel ")
+// - the default x-axis title for fHGausHist ("Sum FADC Slices")
+// - the default y-axis title for fHGausHist ("Nr. of events")
+// - TH1::Sumw2() for fHGausHist
+//
+// Initializes:
+// - fNSlices to 1
+// - fProbLimit to 0.01
+//
+MHPedestalPix::MHPedestalPix(const char *name, const char *title) 
+    : fNSlices(1.)
+{ 
+
+  fName  = name  ? name  : "MHPedestalPix";
+  fTitle = title ? title : "Histogrammed Pedestal events";
+
+  SetNbins( fgChargeNbins );
+  SetFirst( fgChargeFirst );
+  SetLast(  fgChargeLast  );
+
+  SetProbLimit(0.01);
+
+  // Create a large number of bins, later we will rebin
+  fHGausHist.SetName("HPedestalCharge");
+  fHGausHist.SetTitle("Distribution of Summed FADC Pedestal Slices Pixel ");
+  fHGausHist.SetXTitle("Sum FADC Slices");
+  fHGausHist.SetYTitle("Nr. of events");
+  fHGausHist.Sumw2();
+
+}
+
+// --------------------------------------------------------------------------
+// 
+// If mean and sigma have not yet been set, returns.
+//
+// Renormalizes the pedestal fit results by the following formulae:
+//
+// - Mean Pedestal        / slice = Mean Pedestal        / Number slices
+// - Mean Pedestal Error  / slice = Mean Pedestal Error  / Number slices
+// - Sigma Pedestal       / slice = Sigma Pedestal       / Sqrt (Number slices)
+// - Sigma Pedestal Error / slice = Sigma Pedestal Error / Sqrt (Number slices)
+// 
+void MHPedestalPix::Renorm()
+{
+
+  //
+  // One never knows...
+  //
+  if (fNSlices <= 0)
+    return;
+
+  const Float_t sqslices = TMath::Sqrt(fNSlices);
+
+  SetMean     ( GetMean()    / fNSlices  );
+  //
+  // Mean error goes with PedestalRMS/Sqrt(entries) -> scale with slices
+  // 
+  SetMeanErr  ( GetMeanErr() / fNSlices  );
+  //
+  // Sigma goes like PedestalRMS -> scale with sqrt(slices)    
+  //
+  SetSigma    ( GetSigma()   / sqslices  );
+  //
+  // Sigma error goes like PedestalRMS/2.(entries) -> scale with sqrt(slices)
+  //
+  SetSigmaErr ( GetSigmaErr() / sqslices );
+  
+}
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MHPedestalPix.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MHPedestalPix.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MHPedestalPix.h	(revision 9661)
@@ -0,0 +1,36 @@
+#ifndef MARS_MHPedestalPix
+#define MARS_MHPedestalPix
+
+#ifndef MARS_MHGausEvents
+#include "MHGausEvents.h"
+#endif
+
+class MHPedestalPix : public MHGausEvents
+{
+
+private:
+
+  static const Int_t   fgChargeNbins;        // Default for fNbins   (now set to: 450  )
+  static const Axis_t  fgChargeFirst;        // Default for fFirst   (now set to: -0.5 )
+  static const Axis_t  fgChargeLast;         // Default for fLast    (now set to: 449.5)
+
+  Float_t fNSlices;                         // Number of FADC slices summed in extraction
+  
+public:
+
+  MHPedestalPix(const char *name=NULL, const char *title=NULL);
+  ~MHPedestalPix() {}
+
+  // Setters
+  void SetNSlices( const Float_t n)    { fNSlices = n ; }
+  
+  // Getters
+  Float_t GetNSlices() const       { return fNSlices; }
+  
+  // Others
+  void Renorm();  
+
+  ClassDef(MHPedestalPix, 1)     // Histogram class for Charge Pedestal Pixel
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/manalysis/MHadronness.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MHadronness.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MHadronness.cc	(revision 9661)
@@ -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 5/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHadronness
+//
+// The Value must be in the range [0,1]
+// It should be the value used for gamma/hadron seperation.
+// For quality histograms look at MHHadronness
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MHadronness.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHadronness);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MHadronness::MHadronness(const char *name, const char *title)
+    : fHadronness(-1)
+{
+    fName  = name  ? name  : "MHadronness";
+    fTitle = title ? title : "Storage container for hadroness value";
+}
+
+// --------------------------------------------------------------------------
+//
+// Reset hadroness, -1 indicates: invalid value
+//
+void MHadronness::Reset()
+{
+    fHadronness = -1;
+}
+
+// --------------------------------------------------------------------------
+//
+// Print the hillas Parameters to *fLog
+//
+void MHadronness::Print(Option_t *) const
+{
+    *fLog << all << GetDescriptor() << ": Hadronness = " << fHadronness << endl;
+}
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MHadronness.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MHadronness.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MHadronness.h	(revision 9661)
@@ -0,0 +1,26 @@
+#ifndef MARS_MHadronness
+#define MARS_MHadronness
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MHadronness : public MParContainer
+{
+private:
+    Double_t fHadronness; // [0,1] Hadronness
+
+public:
+    MHadronness(const char *name=NULL, const char *title=NULL);
+
+    void Reset();
+
+    virtual void Print(Option_t *opt=NULL) const;
+
+    Double_t GetHadronness() const { return fHadronness; }
+    void     SetHadronness(Double_t h) { fHadronness = h; }
+
+    ClassDef(MHadronness, 1) // Storage Container for the hadroness
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/manalysis/MMarquardt.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MMarquardt.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MMarquardt.cc	(revision 9661)
@@ -0,0 +1,414 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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 10/2003 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MMarquardt                                                              //
+//                                                                         //
+// Marquardt method of solving nonlinear least-squares problems            //
+//                                                                         //
+// (see Numerical recipes (2nd ed.), W.H.Press et al., p.688 ff)           //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MMarquardt.h"
+
+#include <math.h>            // fabs 
+
+#include <TVectorD.h>
+#include <TMatrixD.h>
+
+#include <TStopwatch.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+#include "MParContainer.h"
+
+ClassImp(MMarquardt);
+
+using namespace std;
+
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MMarquardt::MMarquardt(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MMarquardt";
+    fTitle = title ? title : "Marquardt minimization";
+}
+
+// -----------------------------------------------------------------------
+//
+// Set - the number of parameters
+//     - the maximum number of steps allowed in the minimization and
+//     - the change in chi2 signaling convergence
+
+void MMarquardt::SetNpar(Int_t numpar, Int_t numstepmax, Double_t loopchi2)
+{
+  fNpar       = numpar;
+  fNumStepMax = numstepmax;
+  fLoopChi2   = loopchi2;
+
+  fdParam.ResizeTo(fNpar);
+
+  fParam.ResizeTo(fNpar);
+  fGrad.ResizeTo(fNpar);
+  fCovar.ResizeTo(fNpar, fNpar);  
+
+  fmyParam.ResizeTo(fNpar);
+  fmyGrad.ResizeTo(fNpar);
+  fmyCovar.ResizeTo(fNpar, fNpar);  
+
+  fIxc.ResizeTo(fNpar);
+  fIxr.ResizeTo(fNpar);
+  fIp.ResizeTo(fNpar);
+}
+
+
+// -----------------------------------------------------------------------
+//
+// do the minimization
+//
+// fcn    is the function which calculates for a given set of parameters
+//        - the function L to be minimized
+//        - beta_k  = -1/2 * dL/da_k          (a kind of gradient of L)
+//        - alfa_kl =  1/2 * dL/(da_k da_l)   (a kind of 2nd derivative of L)
+//                              
+// Vinit  contains the starting values of the parameters
+//
+
+Int_t MMarquardt::Loop( 
+          Bool_t (*fcn)(TVectorD &, TMatrixD &, TVectorD &, Double_t &),
+          TVectorD &Vinit)
+{
+  fFunc = fcn; 
+
+  // set the initial parameter values
+  for (Int_t i=0; i<fNpar; i++)
+    fParam(i) = Vinit(i);
+
+  //-------------------------------------------
+  // first call of the function func
+  Bool_t rcfirst = FirstCall();
+  if (!rcfirst)
+  {
+    *fLog << "MMarquardt::Loop; first call of function failed " << endl;
+    return -1;
+  }
+
+  Double_t oldChi2  = fChi2;
+  Double_t fdChi2   = 1.e10;
+  Int_t    fNumStep = 0;
+
+  //-------------------------------------------
+  // do the next step in the minimization
+  Bool_t rcnext;
+  do
+  {
+    fNumStep++;
+
+    rcnext = NextStep();
+    if (!rcnext) break;
+
+    fdChi2 = fabs(oldChi2-fChi2);
+    oldChi2 = fChi2;
+  } while (fdChi2 > fLoopChi2  &&  fNumStep < fNumStepMax);
+
+  //-------------------------------------------
+  // do the final calculations
+  if (!rcnext)
+  {
+    *fLog << "MMarquardt::Loop; function call failed in step " << fNumStep
+          << endl;
+    return -2;
+  }
+
+  if (fdChi2 > fLoopChi2)
+  {
+    *fLog << "MMarquardt::Loop; minimization has not converged, fChi2, fdChi2 = "
+          << fChi2 << ",  " << fdChi2 << endl;
+    return -3;
+  }
+
+  *fLog << "MMarquardt::Loop; minimization has converged, fChi2, fdChi2, fNumStep = "
+        << fChi2 << ",  " << fdChi2 << ",  " << fNumStep << endl;
+
+
+  Bool_t rccov = CovMatrix();
+  if (!rccov)
+  {
+    *fLog << "MMarquardt::Loop; calculation of covariance matrix failed " 
+          << endl;
+    return 1;
+  }
+
+  //-------------------------------------------
+  // results
+
+  *fLog << "MMarquardt::Loop; Results of fit : fChi2, fNumStep, fdChi2 =" 
+        << fChi2 << ",  " << fNumStep << ",  " << fdChi2 << endl;
+
+  for (Int_t i=0; i<fNpar; i++)
+    fdParam(i) = sqrt(fCovar(i,i));
+
+  *fLog << "MMarquardt::Loop;   i, Param(i), dParam(i)" << endl;
+  for (Int_t i=0; i<fNpar; i++)
+  {
+    *fLog << i << "   " << fParam(i) << "   " << fdParam(i) << endl;
+  }
+
+  *fLog << "MMarquardt::Loop; Covariance matrix" << endl;
+  for (Int_t i=0; i<fNpar; i++)
+  {
+    *fLog << i;
+    for (Int_t j=0; j<fNpar; j++)
+    {
+      *fLog << fCovar(i,j) << "   ";
+    }
+    *fLog << endl;
+  }
+
+  return 0;
+}
+
+
+// -----------------------------------------------------------------------
+//
+// do 1st step of the minimization
+//
+
+Bool_t MMarquardt::FirstCall()
+{
+  fLambda = 0.001;
+  Bool_t rc = (*fFunc)(fParam, fCovar, fGrad, fChi2);
+  if (!rc) return kFALSE;
+
+  fCHIq = fChi2;
+  for (Int_t j=0; j<fNpar; j++)
+    fmyParam(j) = fParam(j);    
+
+  return kTRUE;
+}
+
+
+// -----------------------------------------------------------------------
+//
+// do one step of the minimization
+//
+
+Bool_t MMarquardt::NextStep()
+{
+  for (Int_t j=0; j<fNpar; j++)
+  {
+    for (Int_t k=0; k<fNpar; k++)
+      fmyCovar(j,k) = fCovar(j,k);
+
+    fmyCovar(j,j) *= (1.0 + fLambda);
+    fmyGrad(j) = fGrad(j);
+  }
+
+  Bool_t rgj = GaussJordan(fNpar, fmyCovar, fmyGrad);
+  if(!rgj) return kFALSE;
+
+  for (Int_t j=0; j<fNpar; j++)
+    fmyParam(j) = fParam(j) + fmyGrad(j);
+
+  Bool_t rc = (*fFunc)(fmyParam, fmyCovar, fmyGrad, fChi2);
+  if(!rc) return kFALSE;
+
+  if (fChi2 < fCHIq)
+  {
+    fLambda *= 0.1;
+    fCHIq = fChi2;
+
+    for (Int_t j=0; j<fNpar; j++)
+    {
+      for (Int_t k=0; k<fNpar; k++)
+        fCovar(j,k) = fmyCovar(j,k);
+
+      fGrad(j)  = fmyGrad(j);
+      fParam(j) = fmyParam(j);
+    }
+  }
+    else
+      fLambda *= 10.0;
+
+
+  return kTRUE;
+}
+
+// -----------------------------------------------------------------------
+//
+// calculate error matrix of fitted parameters
+//
+
+Bool_t MMarquardt::CovMatrix()
+{
+  Bool_t rc = (*fFunc)(fParam, fCovar, fGrad, fChi2);
+  if(!rc) return kFALSE;
+
+  for (Int_t j=0; j<fNpar; j++)
+  {
+    for (Int_t k=0; k<fNpar; k++)
+      fmyCovar(j,k) = fCovar(j,k);
+
+    fmyCovar(j,j) *= (1.0 + fLambda);
+    fmyGrad(j) = fGrad(j);
+  }
+
+  Bool_t rgj = GaussJordan(fNpar, fmyCovar, fmyGrad);
+  if(!rgj) return kFALSE;
+
+  for (Int_t j=0; j<fNpar; j++)
+  {
+    for (Int_t k=0; k<fNpar; k++)
+      fCovar(j,k) = fmyCovar(j,k);
+  }
+
+  return kTRUE;
+}
+
+// -----------------------------------------------------------------------
+//
+// solve normal equations 
+//
+//       sum(covar_kl * x_l) = beta_k        (k=0,... (n-1)) 
+//
+// by the Gauss-Jordan method
+// (see Numerical recipes (2nd ed.), W.H.Press et al., p.39) 
+//
+// on return :  covar contains the inverse of the input matrix covar
+//              beta  contains the result for x
+//
+// return value =  kTRUE   means OK
+//                 kFALSE  means singular matrix
+//
+                 
+Bool_t MMarquardt::GaussJordan(Int_t &n, TMatrixD &covar, TVectorD &beta)
+{
+  Int_t      i, j, k, l, ll;
+  Int_t      ic = 0;
+  Int_t      ir = 0;
+  Double_t   h, d, p;
+
+  for (j=0; j<n; j++)
+    fIp(j) = 0;
+
+  for (i=0; i<n; i++)
+  {
+    h = 0.0;
+    for (j=0; j<n; j++)
+    {
+      if (fIp(j) != 1)
+      {
+        for (k=0; k<n; k++)
+	{
+          if (fIp(k) == 0)
+	  {
+            if (fabs(covar(j,k)) >= h)
+	    {
+              h = fabs(covar(j,k));
+              ir = j;
+              ic = k;
+	    }
+	  }
+          else
+	  {
+            if (fIp(k) > 1) return kFALSE; 
+	  }
+	}
+      }
+    }
+
+    fIp(ic)++;
+    if (ir != ic)
+    {
+      for (l=0; l<n; l++)
+      {
+        d = covar(ir,l);
+        covar(ir,l) = covar(ic,l);
+        covar(ic,l) = d;
+      }
+      d = beta(ir);
+      beta(ir) = beta(ic);
+      beta(ic) = d;
+    }
+
+    fIxr(i) = ir;
+    fIxc(i) = ic;
+    if (covar(ic,ic) == 0.0) return kFALSE;
+    p = 1.0 / covar(ic,ic);
+    covar(ic,ic) = 1.0;
+
+    for (l=0; l<n; l++)
+      covar(ic,l) *= p;
+
+    beta(ic) *= p;
+
+    for (ll=0; ll<n; ll++)
+    {
+      if (ll!= ic)
+      {
+        d = covar(ll,ic);
+        covar(ll,ic) = 0.0;
+
+        for (l=0; l<n; l++)
+          covar(ll,l) -= covar(ic,l) * d;
+
+        beta(ll) -= beta(ic) * d;
+      }
+    }
+  }
+
+  for (l=n-1; l>=0; l--)
+  {
+    if (fIxr(l) != fIxc(l))
+    {
+      for (k=0; k<n; k++)
+      {
+        d = covar(k,fIxr(l));
+        covar(k,fIxr(l)) = covar(k,fIxc(l));
+        covar(k,fIxc(l)) = d;
+      }
+    }
+  }
+
+  return kTRUE;
+}
+//=========================================================================
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MMarquardt.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MMarquardt.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MMarquardt.h	(revision 9661)
@@ -0,0 +1,96 @@
+#ifndef MARS_MMarquardt
+#define MARS_MMarquardt
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#ifndef ROOT_TVectorD
+#include "TVectorD.h"
+#endif
+
+#ifndef ROOT_TMatrixD
+#include "TMatrixD.h"
+#endif
+
+
+class MMarquardt : public MParContainer
+{
+private:
+
+  Int_t fNumStepMax;  // maximum number of steps allowed in the minimization
+  Double_t fLoopChi2; // minimization will stop when the change in chi2 
+                      // is less than fLoopChi2
+
+  Int_t    fNpar;          // number of parameters
+  Int_t    fNumStep;       // number of steps made
+  Double_t fChi2;          // final chi2
+  Double_t fdChi2;         // change of chi2 in last step
+
+  // working space for Marquardt
+  TVectorD fdParam;
+
+  TVectorD fParam;
+  TMatrixD fCovar;
+  TVectorD fGrad;
+
+  TVectorD fmyParam;
+  TMatrixD fmyCovar;
+  TVectorD fmyGrad;
+
+  Double_t fCHIq;
+  Double_t fLambda;
+  Bool_t   (*fFunc)(TVectorD &, TMatrixD &, TVectorD &, Double_t &);
+
+  //working space for GaussJordan
+  TVectorD fIxc, fIxr, fIp;
+
+  Bool_t FirstCall();
+  Bool_t NextStep();
+  Bool_t CovMatrix();
+  Bool_t GaussJordan(Int_t &n, TMatrixD &covar, TVectorD &beta);
+
+
+public:
+    MMarquardt(const char *name=NULL, const char *title=NULL);
+    ~MMarquardt();
+
+    void SetNpar(Int_t npar, Int_t numstepmax, Double_t loopchi2);
+
+    Int_t Loop(Bool_t (*fcn)(TVectorD &, TMatrixD &, TVectorD &, Double_t &),
+               TVectorD &);
+
+    ClassDef(MMarquardt, 0) // Class for Marquardt minimization
+};
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MMatrixLoop.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MMatrixLoop.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MMatrixLoop.cc	(revision 9661)
@@ -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  9/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MMatrixLoop
+//
+// Use this task instead of reading from a file. It loops through the rows
+// of a given MHMatrix. PreProcessing the task again starts from scratch.
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MMatrixLoop.h"
+
+#include "MHMatrix.h"
+#include "MLog.h"
+
+ClassImp(MMatrixLoop);
+
+const TString MMatrixLoop::gsDefName  = "MMatrixLoop";
+const TString MMatrixLoop::gsDefTitle = "Loop through a MHMatrix (instead of reading from a file)";
+
+// --------------------------------------------------------------------------
+//
+//  Default Constructor. Specify the MHMatrix object you want to loop
+//  through.
+//
+MMatrixLoop::MMatrixLoop(MHMatrix *mat, const char *name, const char *title) : fMatrix(mat)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+}
+
+// --------------------------------------------------------------------------
+//
+Int_t MMatrixLoop::PreProcess(MParList *plist)
+{
+    fNumRow = 0;
+
+    return fMatrix ? kTRUE : kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the present row of the Matrix, stops the loop when all rows have
+// been accessed.
+//
+Int_t MMatrixLoop::Process()
+{
+    return fMatrix->SetNumRow(fNumRow++);
+}
Index: /tags/Mars_V0-8-5/Mars/manalysis/MMatrixLoop.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MMatrixLoop.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MMatrixLoop.h	(revision 9661)
@@ -0,0 +1,30 @@
+#ifndef MARS_MMatrixLoop
+#define MARS_MMatrixLoop
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+
+class MHMatrix;
+
+class MMatrixLoop : public MTask
+{
+private:
+    static const TString gsDefName;
+    static const TString gsDefTitle;
+
+protected:
+    MHMatrix *fMatrix;
+    Int_t     fNumRow;    //! Number of dimensions of histogram
+
+public:
+    MMatrixLoop(MHMatrix *mat, const char *name=NULL, const char *title=NULL);
+
+    Int_t PreProcess(MParList *plist);
+    Int_t Process();
+
+    ClassDef(MMatrixLoop, 0) // Task 'reading' events from a MHMatrix
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/manalysis/MMcCalibrationUpdate.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MMcCalibrationUpdate.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MMcCalibrationUpdate.cc	(revision 9661)
@@ -0,0 +1,405 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Abelardo Moralejo, 12/2003 <mailto:moralejo@pd.infn.it>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MMcCalibrationUpdate
+//
+//  This task looks for the ìnformation about FADC pedestals in
+//  MMcFadcHeader and translates it to the pedestal mean and rms (in adc counts).
+//  If not already existing in the parameter list, an MCalibrationCam object
+//  is created, with the conversion factor between photons and ADC counts is 
+//  set to 1 to allow the analysis to proceed.
+//
+//  Then it creates and fills also the MPedPhotCam object containing the pedestal
+//  mean and rms in units of photons.
+//
+//  Input Containers:
+//   MMcFadcHeader
+//   MRawRunHeader
+//  [MCalibrationChargeCam] (if it existed previously)
+//  [MCalibrationQECam] (if it existed previously)
+//
+//  Output Containers:
+//   MPedPhotCam
+//  [MCalibrationChargeCam] (if it did not exist previously)
+//  [MCalibrationQECam] (if it did not exist previously)
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MMcCalibrationUpdate.h"
+
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MCalibrationChargePix.h"
+#include "MCalibrationChargeCam.h"
+
+#include "MCalibrationQEPix.h"
+#include "MCalibrationQECam.h"
+
+#include "MExtractedSignalCam.h"
+#include "MExtractedSignalPix.h"
+#include "MGeomCam.h"
+#include "MPedPhotCam.h"
+#include "MPedPhotPix.h"
+
+#include "MRawRunHeader.h"
+#include "MMcRunHeader.hxx"
+#include "MMcFadcHeader.hxx"
+#include "MMcConfigRunHeader.h"
+
+ClassImp(MMcCalibrationUpdate);
+
+using namespace std;
+
+MMcCalibrationUpdate::MMcCalibrationUpdate(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MMcCalibrationUpdate";
+    fTitle = title ? title : "Write MC pedestals and conversion factors into MCalibration Container";
+
+
+    fAmplitude = -1.;
+    fAmplitudeOuter = -1.;
+    fConversionHiLo = -1.;
+
+    fFillCalibrationCam = kTRUE;
+    fOuterPixelsGainScaling = kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// 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 MMcCalibrationUpdate::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->IsMonteCarloRun();
+}
+
+// --------------------------------------------------------------------------
+//
+// Make sure, that there is an MCalibrationCam Object in the Parameter List.
+//
+Int_t MMcCalibrationUpdate::PreProcess(MParList *pList)
+{
+    fCalCam = (MCalibrationChargeCam*) pList->FindObject(AddSerialNumber("MCalibrationChargeCam"));
+    fQECam = (MCalibrationQECam*) pList->FindObject(AddSerialNumber("MCalibrationQECam"));
+
+    if (!fCalCam || !fQECam)
+    {
+        fCalCam = (MCalibrationChargeCam*) pList->FindCreateObj(AddSerialNumber("MCalibrationChargeCam"));
+        fQECam = (MCalibrationQECam*) pList->FindCreateObj(AddSerialNumber("MCalibrationQECam"));
+        if (!fCalCam || !fQECam)
+            return kFALSE;
+    }
+    else
+    {
+        fFillCalibrationCam = kFALSE;
+        *fLog << inf << AddSerialNumber("MCalibrationChargeCam") << " and " <<
+	  AddSerialNumber("MCalibrationQECam") << " already exist... " << endl;
+    }
+
+    fPedPhotCam = (MPedPhotCam*) pList->FindCreateObj(AddSerialNumber("MPedPhotCam"));
+    if (!fPedPhotCam)
+        return kFALSE;
+
+    fSignalCam = (MExtractedSignalCam*) pList->FindObject(AddSerialNumber("MExtractedSignalCam"));
+    if (!fSignalCam)
+    {
+        *fLog << err << AddSerialNumber("MExtractedSignalCam") << " not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Check for the runtype.
+// Search for MGeomCam and MMcFadcHeader.
+// Fill the MCalibrationCam object.
+//
+Bool_t MMcCalibrationUpdate::ReInit(MParList *pList)
+{
+    //
+    // If it is no MC file skip this function...
+    //
+    if (!CheckRunType(pList))
+    {
+        *fLog << inf << "This is no MC file... skipping." << endl;
+        return kTRUE;
+    }
+	
+    //
+    // Now check the existence of all necessary containers.
+    //
+    fGeom = (MGeomCam*) pList->FindObject(AddSerialNumber("MGeomCam"));
+    if (!fGeom)
+    {
+        *fLog << err << AddSerialNumber("MGeomCam") << " not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fHeaderFadc = (MMcFadcHeader*)pList->FindObject(AddSerialNumber("MMcFadcHeader"));
+    if (!fHeaderFadc)
+    {
+        *fLog << err << AddSerialNumber("MMcFadcHeader") << " not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    MMcRunHeader* mcrunh = (MMcRunHeader*) pList->FindObject("MMcRunHeader");
+
+    //
+    // Initialize Fadc simulation parameters:
+    //
+    if (fAmplitude < 0)
+    {
+	fAmplitude = fHeaderFadc->GetAmplitud();
+	if (mcrunh->GetCamVersion() > 60)
+	  {
+	    fAmplitudeOuter = fHeaderFadc->GetAmplitudOuter();
+	    fConversionHiLo = fHeaderFadc->GetLow2HighGain();
+	  }
+	else // old MC files, camera  < v0.7
+	  {
+	    fAmplitudeOuter = fAmplitude;
+	    fConversionHiLo = 10;  // dummy value
+	  }
+
+    }
+    else   // Check that following files have all the same FADC parameters
+    {
+      if ( fabs(fHeaderFadc->GetAmplitud()-fAmplitude) > 1.e-6 )
+	{
+	  *fLog << err << "Parameters of MMcFadcHeader are not the same for all files... aborting." << endl;
+	  return kFALSE;
+	}
+
+      if (mcrunh->GetCamVersion() > 60) // old MC files, camera < v0.7
+	{
+	  if( fabs(fHeaderFadc->GetAmplitudOuter()-fAmplitudeOuter) > 1.e-6  ||
+	      fabs(fConversionHiLo-fHeaderFadc->GetLow2HighGain())  > 1.e-6 )
+	    {
+	      *fLog << err << "Parameters of MMcFadcHeader are not the same for all files... aborting." << endl;
+	      return kFALSE;
+	    }
+	}
+    }
+
+    //
+    // If MCalibrationChargeCam and MCalibrationQECam already existed 
+    // in the parameter list before MMcCalibrationUpdate::PreProcess was 
+    // executed (from a previous calibration loop) we must not fill it, 
+    // hence nothing else has to be done in ReInit:
+    //
+    if (!fFillCalibrationCam)
+        return kTRUE;
+
+    // Now check the light collection for inner and outer pixels to
+    // calculate the ratio between the two. FIXME! Light collection
+    // depends on the incidence angle of the light w.r.t. the camera
+    // plane. For the moment we take the ratio for light impinging
+    // perpendicular to the camera plane.
+    //
+    // FIXME! We should look for AddSerialNumber("MMcConfigRunHeader") but
+    // for the moment the stereo version of camera does not write one such
+    // header per telescope (it should!)
+    //
+    MMcConfigRunHeader* mcconfig = (MMcConfigRunHeader*) pList->FindObject("MMcConfigRunHeader");
+    if (!mcconfig)
+    {
+        *fLog << err << "MMcConfigRunHeader" << " not found... aborting." << endl;
+        return kFALSE;
+    }
+    TArrayF innerlightcoll = mcconfig->GetLightCollectionFactor();
+    TArrayF outerlightcoll = mcconfig->GetLightCollectionFactorOuter();
+
+    // In principle outer pixels seem to have a different average light 
+    // collection efficiency than outer ones. We set here the factor between
+    // the two.
+
+    fOuterPixelsLightCollection = outerlightcoll[90] / innerlightcoll[90]; 
+    // (at angle = 90 deg)
+
+    // Set now the default conversion from ADC counts to "photoelectrons" 
+    // (in case no previous calibration existed in the parameter list).
+    // As default we want 1 photon = 1 inner pixel ADC count
+    // (this will make Size to be in ADC counts, which is what we want for
+    // the MC calibration loop). To achieve this we set the ADC to 
+    // photoelectron conversion equal to the QE, which will later make the 
+    // ADC to photon conversion factor (= ADC2PhotEl/QE) to be = 1.
+    //
+    fADC2PhElInner = MCalibrationQEPix::gkDefaultAverageQE;
+
+    //
+    // Set the default ADC to "photoelectrons" conversion factor for outer 
+    // pixels. One can choose not to apply the known (in MC) gain factor 
+    // between inner and outer pixels, (in case fOuterPixelsGainScaling = kFALSE),
+    // which may be useful for display purposes.
+    // If on the contrary we apply the factor, we must take into account the 
+    // different gains photoelectrons->ADC counts, given in MC by fAmplitude
+    // and fAmplitudeOuter. This "default" calibration is such that a shower
+    // completely contained in the inner part would have Size in ADC counts, 
+    // whereas one partially in the outer part would have Size in "equivalent 
+    // inner ADC counts" : the "same" shower (light density distribution) would
+    // have the same Size no matter where in the camera it lies. For this we have 
+    // also to set later (see below) the right QE for outer pixels, which may 
+    // be different from that of inner pixels.
+    //
+
+    if (fOuterPixelsGainScaling)
+      fADC2PhElOuter =  MCalibrationQEPix::gkDefaultAverageQE 
+	* (fAmplitude / fAmplitudeOuter);
+    else
+      fADC2PhElOuter = fADC2PhElInner;
+
+
+    Int_t num = fCalCam->GetSize();
+
+    fCalCam->SetFFactorMethodValid   ( kTRUE );
+    fQECam->SetFFactorMethodValid    ( kTRUE );
+    fQECam->SetBlindPixelMethodValid ( kTRUE );
+    fQECam->SetCombinedMethodValid   ( kTRUE );
+    fQECam->SetPINDiodeMethodValid   ( kTRUE );  
+    
+    for (Int_t i=0; i<num; i++)
+    {
+        MCalibrationChargePix &calpix = (MCalibrationChargePix&)(*fCalCam)[i];
+
+	calpix.SetFFactorMethodValid();
+
+	calpix.SetConversionHiLo(fConversionHiLo);
+	calpix.SetConversionHiLoErr(0.);         // FIXME ?
+
+	//
+	// Write conversion factor ADC to photo-electrons (different for inner
+	// and outer pixels).
+	//
+	Float_t adc2photel = (fGeom->GetPixRatio(i) < fGeom->GetPixRatio(0))?
+	  fADC2PhElOuter : fADC2PhElInner;
+
+
+	calpix.SetMeanConvFADC2Phe(adc2photel);
+        calpix.SetMeanConvFADC2PheVar(0.);
+        calpix.SetMeanFFactorFADC2Phot(0.); // Not used for now.
+
+    }
+
+    //
+    // Now set the average QE for each type of pixels. Correct outer pixels
+    // for different light collection efficiency.
+    //
+    num = fQECam->GetSize();
+    for (Int_t i=0; i<num; i++)
+    {
+        MCalibrationQEPix &qepix = (MCalibrationQEPix&)(*fQECam)[i];
+
+	Float_t avqe = MCalibrationQEPix::gkDefaultAverageQE;
+
+	if (fOuterPixelsGainScaling)
+	  if (fGeom->GetPixRatio(i) < fGeom->GetPixRatio(0))
+	    avqe = MCalibrationQEPix::gkDefaultAverageQE*fOuterPixelsLightCollection;
+
+	qepix.SetAverageQE(avqe);
+    }
+
+    return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Fill the MCerPhotPed object
+//
+Int_t MMcCalibrationUpdate::Process()
+{
+    const Int_t num = fCalCam->GetSize();
+
+    for (Int_t i=0; i<num; i++)
+    {
+	MExtractedSignalPix &sigpix = (*fSignalCam)[i];
+
+	//
+	// ped mean and rms per pixel, in ADC counts, according to signal 
+	// calculation (hi or low gain and number of integrated slices):
+	//
+        const Float_t pedestmean = sigpix.IsLoGainUsed()? 
+	  fSignalCam->GetNumUsedLoGainFADCSlices()*fHeaderFadc->GetPedestal(i) : 
+	  fSignalCam->GetNumUsedHiGainFADCSlices()*fHeaderFadc->GetPedestal(i);
+
+	//
+	// In some cases, depending on the camera simulation parameters, one can
+	// have very little or no noise in the FADC. In the case the rms of  
+	// pedestal is zero, the pixel will be cleaned out later in the image
+	// cleaning. To avoid this problem,we set a default value of 0.01 ADC
+	// counts for the RMS per slice:
+	//
+        const Double_t used = (Double_t)(sigpix.IsLoGainUsed() ?
+                                         fSignalCam->GetNumUsedLoGainFADCSlices() :
+                                         fSignalCam->GetNumUsedHiGainFADCSlices());
+
+        const Float_t rms0 = sigpix.IsLoGainUsed() ?
+            fHeaderFadc->GetPedestalRmsLow(i) :
+            fHeaderFadc->GetPedestalRmsHigh(i);
+
+        const Float_t pedestrms = TMath::Sqrt(used) * (rms0>0 ? rms0 : 0.01);
+
+	//
+	// Write mean pedestal and pedestal rms per pixel
+	// in number of photons:
+	//
+	MPedPhotPix &pedpix = (*fPedPhotCam)[i];
+
+        MCalibrationChargePix &calpix = (MCalibrationChargePix&)(*fCalCam)[i];
+        MCalibrationQEPix &qepix = (MCalibrationQEPix&)(*fQECam)[i];
+
+	qepix.SetAvNormFFactor(1.);
+	// This factor should convert the default average QE to average QE 
+	// for a spectrum like that of Cherenkov light. See the documentation 
+	// of MCalibrationQEPix. Here it is 1 because we calibrate using 
+	// Cherenkov light.
+
+        Float_t qe       = qepix.GetAverageQE();
+	Float_t adc2phot = calpix.GetMeanConvFADC2Phe() / qe;
+	Float_t hi2lo    = calpix.GetConversionHiLo();
+
+	if (sigpix.IsLoGainUsed())
+            pedpix.Set(adc2phot*hi2lo*pedestmean, adc2phot*hi2lo*pedestrms);
+	else
+            pedpix.Set(adc2phot*pedestmean, adc2phot*pedestrms);
+
+    }
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/manalysis/MMcCalibrationUpdate.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MMcCalibrationUpdate.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MMcCalibrationUpdate.h	(revision 9661)
@@ -0,0 +1,58 @@
+#ifndef MARS_MMcCalibrationUpdate
+#define MARS_MMcCalibrationUpdate
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MCalibrationChargeCam;
+class MCalibrationQECam;
+class MPedPhotCam;
+class MGeomCam;
+class MMcFadcHeader;
+class MExtractedSignalCam;
+
+class MMcCalibrationUpdate : public MTask
+{
+private:
+    Bool_t CheckRunType(MParList *pList) const;
+    Int_t  PreProcess(MParList *pList);
+    Int_t  Process();
+    Bool_t ReInit(MParList *pList);
+
+    MCalibrationChargeCam *fCalCam;
+    MCalibrationQECam     *fQECam;    
+    MPedPhotCam           *fPedPhotCam;
+    MGeomCam              *fGeom;
+    MMcFadcHeader         *fHeaderFadc;
+    MExtractedSignalCam   *fSignalCam;
+
+    Float_t fADC2PhElInner; // Conversion factor from ADC counts to photo-electrons
+    Float_t fADC2PhElOuter; // for inner and outer pixels.
+
+    Bool_t  fFillCalibrationCam;
+    Bool_t  fOuterPixelsGainScaling;
+
+    Float_t fAmplitude;      // FADC parameters from camera simulation (see camera manual)
+    Float_t fAmplitudeOuter; // to be read from the MMcFadcHeader.
+    Float_t fConversionHiLo; // Ratio of high to low gain.
+
+    Float_t fOuterPixelsLightCollection; 
+    // Photon collection efficiency of outer pixels w.r.t. inner ones.
+
+public:
+    MMcCalibrationUpdate(const char *name=NULL, const char *title=NULL);
+
+    void SetOuterPixelsGainScaling(Bool_t tf) 
+      { fOuterPixelsGainScaling = tf; }
+
+    ClassDef(MMcCalibrationUpdate, 0)   // Task which obtains, for MC files, the pedestal mean and rms, and the calibration factor from ADC counts to photons. 
+};
+
+#endif
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MMcTriggerLvl2.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MMcTriggerLvl2.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MMcTriggerLvl2.cc	(revision 9661)
@@ -0,0 +1,1040 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Antonio Stamerra  1/2003 <mailto:antono.stamerra@pi.infn.it>
+!   Author(s): Marcos Lopez 1/2003 <mailto:marcos@gae.ucm.es>
+!   Author(s): Nicola Galante 7/2003 <mailto:nicola.galante@pi.infn.it>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MMcTriggerLvl2                                                          //
+//   Storage container for the 2nd level trigger selection parameters      //
+//    as part of the 2nd level trigger simulation                          //
+//                                                                         //
+// input parameter:                                                        //
+//    fCompactNN number of next neighboors that define a compact pixel     //
+//                                                                         //
+//                                                                         //
+// Basic L2T Selection Parameters:                                         //
+//                                                                         //
+//    fLutPseudoSize number of compact pixels in one LUT                   //
+//    fPseudoSize Multiplicity of the bigger cluster                       //
+//    fSizeBiggerCell higher number of fired pixel in cell                 //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MMcTriggerLvl2.h"
+
+#include "MGeomCam.h"
+#include "MGeomPix.h"
+#include "MGeomCamMagic.h"
+
+#include "MMcTrig.hxx"
+
+#include "MMcEvt.hxx"
+
+#include "MLog.h"
+
+#include <TCanvas.h>
+
+ClassImp(MMcTriggerLvl2);
+
+using namespace std;
+
+// ---------------------------
+// Initialization of static const data members pixel_in_cell and pixel_in_lut
+
+//
+// Correspondence TABLE between pixel numbering in the trigger cells and
+// the standard spiral counting 
+// (*Note*: Pixels start to count ** from 1 ** instead of 0)
+//
+// This correspondence is valid only for MAGIC-like geometries!
+//
+//  FIXME!  These definitions should be included in a GeomTrig class
+//
+const  Int_t  MMcTriggerLvl2::gsPixelsInCell[gsNPixInCell][gsNCells] = {
+    {26,  91,  66,  71,  76,  81,  86,  269,  224,  233,  242,  251,  260,  391,  336,  347,  358,	369,  380},
+    {25,  61,  41,  45,  49,  53,  57,  215,  175,  183,  191,  199,  207,  325,  275,  285,  295,  305,  315},
+    {24,  37,  22,  25,  28,  31,  34,  167,  132,  139,  146,  153,  160,  265,  220,  229,  238,  247,  256},
+    {23,  19,   9,  11,  13,  15,  17,  125,   95,  101,  107,  113,  119,  211,  171,  179,  187,  195,  203},
+    {27,  62,  67,  72,  77,  82,  87,  270,  225,  234,  243,  252,  261,  392,  337,  348,  359,  370,  381},
+    {12,  38,  42,  46,  50,  54,  58,  216,  176,  184,  192,  200,  208,  326,  276,  286,  296,  306,  316},
+    {11,  20,  23,  26,  29,  32,  35,  168,  133,  140,  147,  154,  161,  266,  221,  230,  239,  248,  257},
+    {10,   8,  10,  12,  14,  16,  18,  126,   96,  102,  108,  114,  120,  212,  172,  180,  188,  196,  204},
+    {22,   2,   3,   4,   5,   6,   7,   90,   65,   70,   75,   80,   85,  164,  129,  136,  143,  150,  157},
+    {28,  93,  99, 105, 111, 117, 123,  271,  226,  235,  244,  253,  262,  393,  338,  349,  360,  371,  382},
+    {13,  63,  68,  73,  78,  83,  88,  217,  177,  185,  193,  201,  209,  327,  277,  287,  297,  307,  317},
+    { 4,  39,  43,  47,  51,  55,  59,  169,  134,  141,  148,  155,  162,  267,  222,  231,  240,  249,  258},
+    { 3,  21,  24,  27,  30,  33,  36,  127,   97,  103,  109,  115,  121,  213,  173,  181,  189,  197,  205},
+    { 9,   9,  11,  13,  15,  17,  19,   91,   66,   71,   76,   81,   86,  165,  130,  137,  144,  151,  158},
+    {21,   3,   4,   5,   6,   7,   2,   61,   41,   45,   49,   53,   57,  123,   93,   99,  105,  111,  117},
+    {29, 130, 137, 144, 151, 158, 165,  218,  227,  236,  245,  254,  263,  394,  339,  350,  361,  372,  383},
+    {14,  94, 100, 106, 112, 118, 124,  170,  178,  186,  194,  202,  210,  328,  278,  288,  298,  308,  318},
+    { 5,  64,  69,  74,  79,  84,  89,  128,  135,  142,  149,  156,  163,  268,  223,  232,  241,  250,  259},
+    { 1,  40,  44,  48,  52,  56,  60,   92,   98,  104,  110,  116,  122,  214,  174,  182,  190,  198,  206},
+    { 2,  22,  25,  28,  31,  34,  37,   62,   67,   72,   77,   82,   87,  166,  131,  138,  145,  152,  159},
+    { 8,  10,  12,  14,  16,  18,   8,   38,   42,   46,   50,   54,   58,  124,   94,  100,  106,  112,  118},
+    {20,  11,  13,  15,  17,  19,   9,   20,   23,   26,   29,   32,   35,   88,   63,   68,   73,   78,   83},
+    {30, 131, 138, 145, 152, 159, 166,  219,  228,  237,  246,  255,  264,  329,  279,  289,  299,  309,  319},
+    {15,  95, 101, 107, 113, 119, 125,  171,  179,  187,  195,  203,  211,  269,  224,  233,  242,  251,  260},
+    { 6,  65,  70,  75,  80,  85,  90,  129,  136,  143,  150,  157,  164,  215,  175,  183,  191,  199,  207},
+    { 7,  41,  45,  49,  53,  57,  61,   93,   99,  105,  111,  117,  123,  167,  132,  139,  146,  153,  160},
+    {19,  23,  26,  29,  32,  35,  20,   63,   68,   73,   78,   83,   88,  125,   95,  101,  107,  113,  119},
+    {37,  24,  27,  30,  33,  36,  21,   39,   43,   47,   51,   55,   59,   89,   64,   69,   74,   79,   84},
+    {31, 132, 139, 146, 153, 160, 167,  220,  229,  238,  247,  256,  265,  270,  225,  234,  243,  252,  261},
+    {16,  96, 102, 108, 114, 120, 126,  172,  180,  188,  196,  204,  212,  216,  176,  184,  192,  200,  208},
+    {17,  66,  71,  76,  81,  86,  91,  130,  137,  144,  151,  158,  165,  168,  133,  140,  147,  154,  161},
+    {18,  42,  46,  50,  54,  58,  38,   94,  100,  106,  112,  118,  124,  126,   96,  102,  108,  114,  120},
+    {36,  43,  47,  51,  55,  59,  39,   64,   69,   74,   79,   84,   89,   90,   65,   70,   75,   80,   85},
+    {32, 133, 140, 147, 154, 161, 168,  221,  230,  239,  248,  257,  266,  217,  177,  185,  193,  201,  209},
+    {33,  97, 103, 109, 115, 121, 127,  173,  181,  189,  197,  205,  213,  169,  134,  141,  148,  155,  162},
+    {35,  68,  73,  78,  83,  88,  63,   95,  101,  107,  113,  119,  125,   91,   66,   71,   76,   81,   86}
+  };
+
+//
+// corrispondence between pixels in cell and lut (pix numbering starts from 1)
+//
+const Int_t MMcTriggerLvl2::gsPixelsInLut[gsNLutInCell][gsNPixInLut] = {
+    { 1,  2,  3,  4,  6,  7,  8,  9, 12, 13, 14, 15},
+    {34, 29, 23, 16, 30, 24, 17, 10, 25, 18, 11,  5},
+    {35, 31, 26, 20, 19, 32, 27, 21, 36, 33, 28, 22},
+  };
+
+
+// --------------------------------------------------------------------------
+//
+//  Default constructor
+//
+MMcTriggerLvl2::MMcTriggerLvl2(const char *name, const char *title):fCompactNN(2),fTriggerPattern(0)
+{
+  fName = name ? name : ClassName();
+  fTitle = title;
+
+  *fLog << "created MMcTriggerLvl2" << endl;
+
+  //
+  // Initialization of the fPixels array to zero
+  //
+  memset (fPixels,0,gsNPixInCell*gsNCells*sizeof(Int_t));
+  memset (fFiredPixel,0,gsNTrigPixels*sizeof(Int_t));
+
+  // create a new camera
+  SetNewCamera(new MGeomCamMagic);
+
+}
+
+// --------------------------------------------------------------------------
+//
+//  Destructor
+//
+MMcTriggerLvl2::~MMcTriggerLvl2()
+{
+  delete fGeomCam;
+}
+
+// --------------------------------------------------------------------------
+//  
+//  Print functions for debugging and testing
+//
+//  Options available:
+//
+// "cell":
+//     Print out the pixel number of a given trigger cell
+//
+// "status":
+//     Print a table with the status (pixel is fired or not after Lvl1) for 
+//     all the pixels in all the trigger cells
+//
+// "check"
+//     Print a warning message when no starting pixel is found in the 
+//     CalcPseudoSize method.
+//
+//  no option:
+//     Print the value of the selection parameters
+//
+//
+void MMcTriggerLvl2::Print(Option_t *opt) const
+{
+  TString str(opt);
+
+  if (str.Contains("status", TString::kIgnoreCase)) 
+    {
+      *fLog << "    Status of cells 1-9" <<endl;
+      for(int i=0; i<gsNPixInCell; i++)
+	{
+	  for(int j=0; j<9; j++)
+	    {
+	      //      *fLog.width(3);
+	      *fLog <<gsPixelsInCell[i][j]-1 << ":" << fPixels[i][j]  << "\t ";
+	    } 
+	  *fLog << endl;
+	}      
+    }
+  else if (str.Contains("cell", TString::kIgnoreCase)) 
+    {
+      *fLog << "   Pixel numbering in cells 1-9" <<endl;
+      for (int i=0;i<gsNPixInCell;i++)
+	{
+	  for(int j=0; j<9; j++)
+	    {
+	      *fLog << gsPixelsInCell[i][j]-1 << "\t";
+	    }
+	  *fLog << endl;
+	}
+    }
+  else if (str.Contains("check", TString::kIgnoreCase)) 
+    {
+      // check when no starting pixels was found (<<--to be fixed)
+      if (fPseudoSize < 0)
+	*fLog << "  Warning: starting pixel not found. Pseudosize set to -1." << endl;
+    }
+  else 
+    {
+      *fLog << "  L2T selection parameters: " << endl;
+      *fLog << "   - LutPseudoSize  = " << fLutPseudoSize <<  endl;
+      *fLog << "   - CellPseudoSize  = " << fCellPseudoSize <<  endl;
+      *fLog << "   - PseudoSize  = " << fPseudoSize <<  endl;
+      *fLog << "   - BiggerCellSize = " << fSizeBiggerCell << endl;
+      *fLog << "   - TriggerPattern = " << fTriggerPattern << endl;
+    }
+  
+}
+
+// --------------------------------------------------------------------------
+//
+// Take the information supplied by the Lvl1 (it reads from the object MMcTrig
+// the status of all pixels after Lvl1) and pass it to the Lvl2 (fill the 
+// array fPixels)
+//
+//
+void MMcTriggerLvl2::SetLv1(MMcTrig *trig)
+{
+  if (!trig)
+    return;
+
+  fMcTrig = trig;
+
+  for(int i=0; i<gsNPixInCell; i++)
+    {
+      for(int j=0; j<gsNCells; j++)
+	{
+	  int pixel = gsPixelsInCell[i][j]-1;
+	  fPixels[i][j] = (fMcTrig->IsPixelFired(pixel,0)) ? 1 : 0;
+	  fFiredPixel[pixel]=(fMcTrig->IsPixelFired(pixel,0)) ? 1 : 0;
+	  //if (fFiredPixel[pixel]==1)
+	  //*fLog << pixel<<",";
+	}
+    }
+  //*fLog<<endl<<"Fine evento"<<endl;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Set the trigger status ( pixel fired(=1) or not(=0) ) manually for a given
+// pixel of a given cell
+//
+//
+void MMcTriggerLvl2::SetPixelFired(Int_t pixel, Int_t fired)
+{
+  for(int i=0; i<gsNPixInCell; i++)
+    {
+      for(int j=0; j<gsNCells; j++)
+	{
+	  if(gsPixelsInCell[i][j]-1==pixel) fPixels[i][j]=fired;
+	}
+    }
+
+}
+
+// --------------------------------------------------------------------------
+//
+//  Calculate the Level 2 Trigger (L2T) parameters. They can be used 
+//  to select the events that have passed the L2T selection rule.
+//
+//
+void MMcTriggerLvl2::Calc()
+{
+
+  // Find the Lut and cell with the higher LutPseudoSize. 
+  int lutcell = CalcBiggerLutPseudoSize(); 
+  fMaxCell = lutcell/10;
+  int maxlut = lutcell-fMaxCell*10;
+  fLutPseudoSize = GetLutCompactPixel(fMaxCell,maxlut);
+
+  fMaxCell = CalcBiggerCellPseudoSize();  // fCellPseudoSize
+  // fMaxCell is used by the PseudoSize to find the starting pixel
+  CalcPseudoSize();
+
+  fSizeBiggerCell = GetCellNumberFired(CalcBiggerFiredCell());
+
+  //*fLog << "fLPS="<<fLutPseudoSize<<endl;
+}
+
+
+
+// --------------------------------------------------------------------------
+//  
+// For a given cell, just count how many pixels have been fired after Lvl1
+//
+Int_t MMcTriggerLvl2::GetCellNumberFired(int cell)
+{
+  int size=0;
+ 
+  for(int i=0; i<gsNPixInCell; i++)
+    {
+      size += fPixels[i][cell];
+    }
+
+  return size;
+  
+}
+
+
+// --------------------------------------------------------------------------
+//  
+//  Find the cell which the bigger number of fired pixels
+// 
+//
+Int_t MMcTriggerLvl2::CalcBiggerFiredCell()
+{
+  int size=-1;
+  int cell=-1;
+
+  for(int j=0; j<gsNCells; j++)
+    {
+      if (GetCellNumberFired(j) > size) 
+	{
+	  size = GetCellNumberFired(j);
+	  cell = j;
+	}
+    }
+  
+  //  *fLog << "size " <<size <<" in cell " << cell << endl;
+
+  return cell;
+  
+}
+
+// --------------------------------------------------------------------------
+//  
+// Calculate the higher LutPseudoSize of one event defined as the higher number
+//   of compact pixel in the LUTs of the trigger cells.
+//  neighpix is the number of Next-Neighbors which defines the compact pixel
+//    topology (it can be 2-NN or 3-NN)
+//
+//   It returns the cell and the LUT with the bigger LutPseudoSize, coded
+//      accordingly to:   cell*10 + LUT 
+//
+Int_t MMcTriggerLvl2::CalcBiggerLutPseudoSize()
+{
+  int size=0;
+  int cell=-1;
+  int lut=-1;
+ 
+  for(int j=0; j<gsNCells; j++)
+    {
+      for(int i=0; i<gsNLutInCell; i++)
+	{
+	  if (GetLutCompactPixel(j,i) >= size) 
+	    {
+	      size = GetLutCompactPixel(j,i);
+	      cell = j;
+	      lut = i;
+	    }      
+	}
+    }
+  
+  //*fLog <<"Max cell: " << cell+1 << "  Max Lut: " << lut+1 << "  PseudoSize: " << size <<endl;
+    
+  return cell*10+lut;
+}
+
+
+// --------------------------------------------------------------------------
+//  
+// Identify compact pixels in one LUT and calculate the LutPseudoSize 
+//   (=number of compact pixels in one LUT)
+//  neighpix is the number of Next-Neighbors which defines the compact pixel
+//    topology.  
+//   Up to now only  2NN or 3NN are considered 
+//    <!if changed: change check made by Preprocess in MMcTriggerLvl2Calc>    
+//
+//   Returns: 
+//     -1    wrong neighpix
+//     -2    wrong cell (<1 or >19)
+//     -3    wrong lut  (<1 or >3)
+//    else:
+//      the number of compact pixels in one LUT.
+//     
+Int_t MMcTriggerLvl2::GetLutCompactPixel(int cell, int lut)
+{
+  int size=0;
+  int lutpix, a[gsNPixInLut]; 
+  int neighpix= (*this).fCompactNN;
+
+  // check on input variables
+
+  if (neighpix >3 || neighpix < 2) 
+    return(-1);
+
+  if (cell<0 || cell> gsNCells-1)
+    return(-2);
+
+  if (lut<0 || lut> gsNLutInCell-1)
+    return(-3);
+
+
+  //
+  // Warning!!! Following configurations are valid only for the standard MAGIC 
+  // trigger geometry; FIXME! these should be coded somewhere else....
+  //
+
+  // LUT 1 and 2 are similar; LUT 3 differs
+  
+  for(int j=0; j< gsNPixInLut; j++)
+    {
+      lutpix = gsPixelsInLut[lut][j]-1;
+      //    *fLog << "j=" <<j<<"  lutpix="<<lutpix<<"  Cell="<<cell<<endl;
+      a[j] = fPixels[lutpix][cell]; 
+    }
+  
+  //
+  // Look for compact pixels 2NN
+  //
+  if (neighpix==2)
+    {    
+      //  case Lut 1 and 2
+      if (lut == 0 || lut == 1)
+	{
+	  if (a[0] && a[1] && a[4])
+	    size ++;
+	  if (a[1] && ((a[0] && a[4]) || 
+		       (a[4] && a[5]) || 
+		       (a[5] && a[2]) )) 
+	    size ++;
+	  if (a[2] && ((a[1] && a[5]) || 
+		       (a[5] && a[6]) || 
+		       (a[6] && a[3]) )) 
+	    size ++;
+	  if (a[3] && ((a[2] && a[6]) || 
+		       (a[6] && a[7]) )) 
+	    size ++;
+	  if (a[4] && ((a[0] && a[1]) || 
+		       (a[1] && a[5]) || 
+		       (a[5] && a[8]) )) 
+	    size ++;
+	  if (a[5] && ((a[1] && a[2]) || 
+		       (a[2] && a[6]) || 
+		       (a[6] && a[9]) || 
+		       (a[9] && a[8]) || 
+		       (a[8] && a[4]) || 
+		       (a[4] && a[1]) )) 
+	    size ++;
+	  if (a[6] && ((a[2] && a[3]) || 
+		       (a[3] && a[7]) || 
+		       (a[7] && a[10]) || 
+		       (a[10] && a[9]) || 
+		       (a[9] && a[5]) || 
+		       (a[5] && a[2]) )) 
+	    size ++;
+	  if (a[7] && ((a[3] && a[6]) || 
+		       (a[6] && a[10]) || 
+		       (a[10] && a[11]) )) 
+	    size ++;
+	  if (a[8] && ((a[4] && a[5]) || 
+		       (a[5] && a[9]) )) 
+	    size ++;
+	  if (a[9] && ((a[8] && a[5]) || 
+		       (a[5] && a[6]) || 
+		       (a[6] && a[10]) )) 
+	    size ++;
+	  if (a[10] && ((a[9] && a[6]) || 
+			(a[6] && a[7]) || 
+			(a[7] && a[11]) )) 
+	    size ++;
+	  if (a[11] && a[7] && a[10]) 
+	    size ++;
+	}
+      
+      //  case Lut 3
+      if (lut==2) 
+	{
+	  if (a[0] && a[1] && a[5])
+	    size ++;
+	  if (a[1] && ((a[0] && a[5]) || 
+		       (a[5] && a[2]) )) 
+	    size ++;
+	  if (a[2] && ((a[1] && a[5]) || 
+		       (a[5] && a[6]) || 
+		       (a[3] && a[4]) || 
+		       (a[6] && a[3]) )) 
+	    size ++;
+	  if (a[3] && ((a[2] && a[6]) || 
+		       (a[6] && a[7]) || 
+		       (a[2] && a[4]) )) 
+	    size ++;
+	  if (a[4] && ((a[2] && a[3]) )) 
+	    size ++;
+	  if (a[5] && ((a[1] && a[2]) || 
+		       (a[2] && a[6]) || 
+		       (a[6] && a[9]) || 
+		       (a[9] && a[8]) )) 
+	    size ++;
+	  if (a[6] && ((a[2] && a[3]) || 
+		       (a[3] && a[7]) || 
+		       (a[7] && a[10]) || 
+		       (a[10] && a[9]) || 
+		       (a[9] && a[5]) || 
+		       (a[5] && a[2]) )) 
+	    size ++;
+	  if (a[7] && ((a[3] && a[6]) || 
+		       (a[6] && a[10]) || 
+		       (a[10] && a[11]) )) 
+	    size ++;
+	  if (a[8] && a[5] && a[9]) 
+	    size ++;
+	  if (a[9] && ((a[8] && a[5]) || 
+		       (a[5] && a[6]) || 
+		       (a[6] && a[10]) )) 
+	    size ++;
+	  if (a[10] && ((a[9] && a[6]) || 
+			(a[6] && a[7]) || 
+			(a[7] && a[11]) )) 
+	    size ++;
+	  if (a[11] && a[7] && a[10]) 
+	    size ++;    
+	}
+    }
+  
+  //
+  // Look for compact pixels 3NN 
+  //
+  if (neighpix==3)
+    {
+      //  case Lut 1 and 2
+      if (lut == 0 || lut == 1)
+	{
+	  if (a[0] && a[1] && a[4] && a[5]) // pix 0 is compact if there is a 4NN
+	    size ++;
+	  if (a[1] && ((a[0] && a[4] && a[5]) || 
+		       (a[2] && a[4] && a[5]) )) 
+	    size ++;
+	  if (a[2] && ((a[1] && a[5] && a[6]) || 
+		       (a[5] && a[6] && a[3]) )) 
+	    size ++;
+	  if (a[3] && (a[2] && a[6] && a[7] ))  
+	    size ++;
+	  if (a[4] && ((a[0] && a[1] && a[5]) || 
+		       (a[1] && a[5] && a[8]) )) 
+	    size ++;
+	  if (a[5] && ((a[1] && a[2] && a[6]) || 
+		       (a[2] && a[6] && a[9]) || 
+		       (a[6] && a[9] && a[8]) || 
+		       (a[9] && a[8] && a[4]) || 
+		       (a[8] && a[4] && a[1]) || 
+		       (a[4] && a[1] && a[2]) )) 
+	    size ++;
+	  if (a[6] && ((a[2] && a[3] && a[7]) || 
+		       (a[3] && a[7] && a[10]) || 
+		       (a[7] && a[10] && a[9]) || 
+		       (a[10] && a[9] && a[5]) || 
+		       (a[9] && a[5] && a[2]) || 
+		       (a[5] && a[2] && a[3]) )) 
+	    size ++;
+	  if (a[7] && ((a[3] && a[6] && a[10]) || 
+		       (a[6] && a[10] && a[11]) )) 
+	    size ++;
+	  if (a[8] && (a[4] && a[5] && a[9] )) 
+	    size ++;
+	  if (a[9] && ((a[8] && a[5] && a[6]) || 
+		       (a[5] && a[6] && a[10]) )) 
+	    size ++;
+	  if (a[10] && ((a[9] && a[6] && a[7]) || 
+			(a[6] && a[7] && a[11]) )) 
+	    size ++;
+	  if (a[11] && a[7] && a[10] && a[6]) //pix 0 is compact if there is a 4NN
+	    size ++;
+	}
+      
+      //  case Lut 3
+      if (lut==2) 
+	{
+	  if (a[0] && a[1] && a[5] && a[8]) // pix 0 is compact if there is a 4NN
+	    size ++;
+	  if (a[1] && (a[0] && a[5] && a[2])) //pix 0 is compact if there is a 4NN 
+	    size ++;
+	  if (a[2] && ((a[1] && a[5] && a[6]) || 
+		       (a[3] && a[5] && a[6]) || 
+		       (a[6] && a[3] && a[4]) )) 
+	    size ++;
+	  if (a[3] && ((a[2] && a[4] && a[6]) || 
+		       (a[2] && a[6] && a[7]) )) 
+	    size ++;
+	  if (a[4] && (a[2] && a[3] && a[6] )) 
+	    size ++;
+	  if (a[5] && ((a[1] && a[2] && a[6]) || 
+		       (a[2] && a[6] && a[9]) || 
+		       (a[6] && a[9] && a[8]) )) 
+	    size ++;
+	  if (a[6] && ((a[2] && a[3] && a[7]) || 
+		       (a[3] && a[7] && a[10]) || 
+		       (a[7] && a[10] && a[9]) || 
+		       (a[10] && a[9] && a[5]) || 
+		       (a[9] && a[5] && a[2]) || 
+		       (a[5] && a[2] && a[3]) )) 
+	    size ++;
+	  if (a[7] && ((a[3] && a[6] && a[10]) || 
+		       (a[6] && a[10] && a[11]) )) 
+	    size ++;
+	  if (a[8] && a[5] && a[9] && a[6])  //pix 0 is compact if there is a 4NN
+	    size ++;
+	  if (a[9] && ((a[8] && a[5] && a[6]) || 
+		       (a[5] && a[6] && a[10]) )) 
+	    size ++;
+	  if (a[10] && ((a[9] && a[6] && a[7]) || 
+			(a[6] && a[7] && a[11]) )) 
+	    size ++;
+	  if (a[11] && a[7] && a[10] && a[6]) //pix 0 is compact if there is a 4NN
+	    size ++;
+	}
+    }
+  
+
+  if(size<0 ||size>gsNPixInLut)
+    *fLog << "*" << size <<"-";
+  
+  return size;
+}
+
+
+// --------------------------------------------------------------------------
+//  
+// Look for clusters and calculate the PseudoSize of one event, 
+//   defined as the multiplicity of the bigger cluster. 
+//
+//
+//
+void MMcTriggerLvl2::CalcPseudoSize()
+{
+  // Fill the fCompactPixel array with the compact pixels
+  CalcCompactPixels(fGeomCam);
+
+  // seek the LUT with higher number of compact pixels
+  //
+  //int fMaxCell = CalcBiggerCellPseudoSize();
+  int sizetemp=0;
+  int maxlut=0;
+
+  for (int i=0;i<gsNLutInCell;i++)
+    if (GetLutCompactPixel(fMaxCell,i) > sizetemp)
+      {
+        maxlut=i;
+        sizetemp = GetLutCompactPixel(fMaxCell,i);
+      }
+
+  int startpix;
+  // 
+  // seek a starting pixel for the iteration inside the lut
+  //
+  int check=1;
+  for (int pixlut=0;pixlut<gsNPixInLut;pixlut++)
+    {
+      int pixcell =gsPixelsInLut[maxlut][pixlut]-1;
+      startpix = gsPixelsInCell[pixcell][fMaxCell]-1;
+      //*fLog << "pix, compact:" << startpix << "@"<<fCompactPixel[startpix];
+      if (fCompactPixel[startpix]) // a starting pixel was found
+		break;
+      check++;
+    }
+
+  //*fLog << "check = " << check << endl;
+  // A LUT contains 12 pixels
+  if (check > gsNPixInLut)
+	  {   
+		   *fLog <<"Warning: a starting pixel was not found! - PseudoSize = "<< fPseudoSize << endl;
+	    fPseudoSize=-1;
+	    return;
+	  }
+
+  //
+  // Bulding cluster
+  //
+  Int_t cluster[gsNTrigPixels];
+  int pnt=0;
+  int pnt2=0; //pointer in the array fCluster_pix, needed for filling
+
+  memset (cluster,0,gsNTrigPixels*sizeof(Int_t));
+  memset (fCluster_pix,-1,gsNTrigPixels*sizeof(Int_t));
+
+  cluster[startpix]=1;  
+  fCluster_pix[0]=startpix; //the starting pix is the first in cluster
+  
+  // Look at neighbour pixs if they are compact (iterative search)
+  //  until the array (fCluster_pix) has no more compact pixels.
+  // pnt points to the pixel in the array fCluster_pix whose neighbors are
+  // under study; pnt2 points to the last element of this array.
+  //
+  while (fCluster_pix[pnt] != -1)
+    { 
+      const MGeomPix &pix=(*fGeomCam)[fCluster_pix[pnt]];
+
+      for (int i=0;i<pix.GetNumNeighbors();i++)
+	    {
+	       int pix_neigh = pix.GetNeighbor(i);
+	       // check if pixel is fired and doesn't belong to cluster
+	       if (fCompactPixel[pix_neigh] && !cluster[pix_neigh])
+	         {
+	            cluster[pix_neigh] = 1;
+	            fCluster_pix[++pnt2] = pix_neigh;
+	         }
+	    }
+      pnt++;
+    }
+
+  fPseudoSize = pnt;
+
+  //if (fPseudoSize < 4)
+    //    *fLog << "fPseudoSize = " << fPseudoSize << endl;
+
+  //  *fLog << "ClusterID:" <<(*clust).GetClusterId() << " Mult:" << (*clust).GetMultiplicity()<<endl;  
+  /*
+  *fLog <<"PSize: "<< fPseudoSize << " in cell:" << fMaxCell << " lut:" <<maxlut << endl << "   Pixels: ";
+  for (int i =0;i<fPseudoSize; i++)
+    *fLog << fCluster_pix[i]+1 <<"; ";
+  *fLog << endl;
+  */
+  return;
+}
+
+// --------------------------------------------------------------------------
+//  
+//  Fill the fCompactPixels array with the pixels which are compact
+//
+//  neighpix is the number of Next-Neighbors which defines the compact pixel
+//    topology (it can be 2-NN or 3-NN)
+//
+//   Note: it is a *global* method; it looks in the all camera as a whole
+//         
+//
+void MMcTriggerLvl2::CalcCompactPixels(MGeomCam *geom)
+{
+  memset (fCompactPixel,0,gsNTrigPixels*sizeof(Int_t));
+  //  *fLog << endl << "NEW Event!";
+  for(Int_t pixid=0; pixid<gsNTrigPixels; pixid++)
+    {
+      // Look if the pixel is fired, otherwise continue
+      if (!fFiredPixel[pixid])
+	     continue;
+      
+      const MGeomPix &pix=(*geom)[pixid];
+      
+      // Reshuffle pixneighbour order, to arrange them (anti)clockwise
+      //   around the current pixel (Bubble sorting)
+      // The NeighPixOrdered array has a doubledd size so that
+      // the content in the first index is repeated in the last one
+      // to have a closed loop
+
+      Int_t NeighPixOrdered[2*pix.GetNumNeighbors()];
+
+      for (Int_t j=0; j<pix.GetNumNeighbors(); j++)
+        NeighPixOrdered[j] = pix.GetNeighbor(j);
+      
+      for (Int_t j=0; j<pix.GetNumNeighbors()-1; j++)
+        {
+          for (Int_t jk=pix.GetNumNeighbors()-1;jk>j;--jk)
+            {
+               UInt_t tmp = NeighPixOrdered[j+1];
+               const MGeomPix &pixneigh = (*geom)[NeighPixOrdered[j]];
+               for (int k=0; k<pix.GetNumNeighbors(); k++)
+                 if (NeighPixOrdered[jk] == pixneigh.GetNeighbor(k))
+     		       {
+                      NeighPixOrdered[j+1] = NeighPixOrdered[jk];
+                      NeighPixOrdered[jk] = tmp;
+              	   }
+	        }
+        }
+      
+      // Duplicate second half to take into account configurations
+ 	  //  containing tha last and first pixel
+      for (Int_t j=pix.GetNumNeighbors(); j<2*pix.GetNumNeighbors(); j++)
+        NeighPixOrdered[j] = NeighPixOrdered[j-pix.GetNumNeighbors()];
+
+      // Look for compact pixels. 
+      // A compact pixel must have at least fCompactNN adjacent fired neighbors
+      // It checks the 6 different configurations of neighbors pixels; if
+	  // one has fCompacNN adjacent fired pixels than the pixel pixid is
+	  // promoted to compact pixel and saved into the fCompactPixel array.
+	  //
+      for (int i=0;i<pix.GetNumNeighbors();i++)
+	    { 
+	      int j=0; // j counts the adjacent fired pixels
+	      //*fLog << pixid <<"->"<< pix.GetNeighbor(i+j) << endl;
+	      while ((i+j < 2*pix.GetNumNeighbors()) && (fFiredPixel[NeighPixOrdered[i+j]]==1) && (j < fCompactNN))
+	        j++;  
+	      if (j>=fCompactNN)	 // configuration satisfies the compact condition  
+		{
+	      	  fCompactPixel[pixid]=1; // pixel is compact
+	      	  //	  *fLog << ","<<pixid;
+		  break;
+		}
+	    }      
+    }
+
+}
+
+// --------------------------------------------------------------------------
+//  
+//  The Energy has to be given by this class to the Energy-PSSize correlation 
+//   histogram (MHMcTriggerLvl2)  
+//
+void MMcTriggerLvl2::GetEnergy(MMcEvt *fMcEvt)
+{
+   const MMcEvt &h = *(MMcEvt *)fMcEvt; 
+   fEnergy = h.GetEnergy();
+   return;
+}
+
+
+// --------------------------------------------------------------------------
+//  
+//   Looks for a x-NN compact pattern in the whole camera
+//   We have x-NN compact pattern when a triggered pix has
+//   x-1 triggered neighbor pixels.  
+//   The variable fTriggerPattern = x is computed
+//   (x= 2,3,4,5,6,7)  
+//
+//   x=2   * *
+//
+//   x=3   * *
+//          *        *
+//            x=4   * *
+//                   *       
+//                       * *
+//                 x=5  * * *
+//          * 
+//   x=6   * * *
+//          * *
+//               * *
+//          x=7 * * *
+//               * *
+//
+void MMcTriggerLvl2::CalcTriggerPattern(MGeomCam *geom)
+{
+  fTriggerPattern=0; //initialize
+
+  for(Int_t pixid=0;pixid<gsNTrigPixels;pixid++)
+    {
+      // Look if the pixel is fired, otherwise continue
+      if (!fFiredPixel[pixid])
+		continue;
+      
+      const MGeomPix &pix=(*geom)[pixid];
+      
+      // Look for x-NN compact pattern
+      // If a x-NN pattern exists then a pixel must have 
+      // at least x-1 adjacent neighbors (look at patterns)
+      // For each triggered pixel the number of adjacent triggered pixels 
+      // is counted.
+      //
+      int j=1;
+      for (int i=0;i<pix.GetNumNeighbors();i++)
+		if (fFiredPixel[pix.GetNeighbor(i)]==1) j++;
+	     
+      if (j > fTriggerPattern) 
+		fTriggerPattern=j;	 
+
+      if (fTriggerPattern==7) 
+	  	break;	 // the 7-NN (max) pattern was found: exit  
+
+    } // next pixel
+}
+
+
+// --------------------------------------------------------------------------
+//  Look for the cell with higher number of Compact pixels
+//  Return the cell number (starting from 0)
+//
+Int_t MMcTriggerLvl2::CalcBiggerCellPseudoSize()
+{
+  Int_t fMaxCell=-1;
+
+  fCellPseudoSize=0;
+
+  for (Int_t i=0;i<gsNCells;i++)
+    {
+      int size = GetCellCompactPixel(i,fGeomCam);
+      if (size > fCellPseudoSize)
+        {
+          fCellPseudoSize = size;
+          fMaxCell = i;
+        }
+    }
+  
+  //*fLog << "fCellPseudoSize = " << fCellPseudoSize << " in cell N. " << fMaxCell+1 << endl;
+
+  return fMaxCell;
+}
+
+// --------------------------------------------------------------------------
+//  Compute the number of compact pixels in one cell
+//
+Int_t MMcTriggerLvl2::GetCellCompactPixel(int cell, MGeomCam *geom)
+{
+  int size=0;
+
+  // check on input variables
+
+  if (cell<0 || cell>gsNCells-1)
+    return(-2);
+
+  //*fLog << " CNN:" << fCompactNN;
+  //*fLog << "Cell: " << cell+1 << " Compat Pixels:"; 
+
+  for(Int_t id=0; id<gsNPixInCell; id++)
+    {
+      UInt_t pixid = gsPixelsInCell[id][cell]-1;
+ 
+      // Look if the pixel is fired, otherwise continue
+      if (!fFiredPixel[pixid])
+        continue;
+
+      //*fLog << "Fired pix:"<<pixid+1 << " ";
+
+      const MGeomPix &pix=(*geom)[pixid];
+      
+      // Reshuffle pixneighbour order, to arrange them (anti)clockwise 
+      //   around the current pixel (Bubble sorting)
+      // The NeighPixOrdered has one index more so that 
+      // the content in the first index is repeated in the last one
+      // to have a closed loop
+      Int_t NeighPixOrdered[2*pix.GetNumNeighbors()];
+      for (Int_t j=0; j<pix.GetNumNeighbors(); j++)
+        NeighPixOrdered[j] = pix.GetNeighbor(j);
+      
+      for (Int_t j=0; j<pix.GetNumNeighbors()-1; j++)
+        {
+          for (Int_t jk=pix.GetNumNeighbors()-1;jk>j;--jk)
+            {
+              UInt_t tmp = NeighPixOrdered[j+1];                  
+              const MGeomPix &pixneigh = (*geom)[NeighPixOrdered[j]];
+              for (int k=0; k<pix.GetNumNeighbors(); k++)
+                if (NeighPixOrdered[jk] == pixneigh.GetNeighbor(k))
+                  {
+                    NeighPixOrdered[j+1] = NeighPixOrdered[jk];
+                    NeighPixOrdered[jk] = tmp;
+                  }
+            }
+        }
+
+      // Duplicate second half of the array to take into account configurations
+      // containing tha last and first pixel
+      for (Int_t j=pix.GetNumNeighbors(); j<2*pix.GetNumNeighbors(); j++)
+        NeighPixOrdered[j] = NeighPixOrdered[j-pix.GetNumNeighbors()];
+
+      // Look for compact pixels. 
+
+      // A compact pixel must have at least fCompactNN adjacent neighbors
+      // It checks the 6 different configurations of neighbors pixels.
+      // The neighbour pixels must belong to the cell
+
+      //      *fLog << "cell:"<< cell << "   ordered pixels:";
+      /*
+      for (int i=0;i<2*pix.GetNumNeighbors();i++)
+	{
+	  if (fFiredPixel[NeighPixOrdered[i]])
+	    *fLog << NeighPixOrdered[i]+1 << "*;";
+	  else
+	    *fLog << NeighPixOrdered[i]+1 << ";";
+	}
+      */
+      //*fLog <<endl;
+      //*fLog << pixid <<"->"<< pix.GetNumNeighbors() << " CNN="<< fCompactNN <<endl;
+
+
+      for (int i=0;i<pix.GetNumNeighbors();i++)
+        { 
+          int j=0;
+          while ((i+j < 2*pix.GetNumNeighbors()) && (fFiredPixel[NeighPixOrdered[i+j]]==1) && (j < fCompactNN) && IsPixelInCell(NeighPixOrdered[i+j],cell) )
+            j++;  
+
+          if (j>=fCompactNN) //configuration satisfies the compact condition  
+	    {          
+	      size++; // pixel is compact
+	      //*fLog << "->" << pixid+1;
+	      break; // (new pixel)
+	    }
+	}
+    }
+  
+  //*fLog <<" - size:" << size << endl<<endl;
+  
+  return size;
+  
+}
+
+//---------------------------------------------------------------------
+//  Check if a given pixel belongs to a given cell
+//
+Bool_t MMcTriggerLvl2::IsPixelInCell(Int_t pixel, Int_t cell)
+{
+  for (int i=0; i<gsNPixInCell; i++)
+    if ((gsPixelsInCell[i][cell]-1) == pixel)
+      return kTRUE;
+  
+  return kFALSE;
+}
+
+//---------------------------------------------------------------------
+//  Check if a given pixel is in the trigger region
+//
+Bool_t MMcTriggerLvl2::IsPixelInTrigger(Int_t pixel) const
+{
+  for (int cell=0; cell<gsNCells; cell++)
+    for (int i=0; i<gsNPixInCell; i++)
+      if ((gsPixelsInCell[i][cell]-1) == pixel)
+	return kTRUE;
+  
+  return kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns, depending on the type flag:
+//
+//  0: 1,0 if the pixel is triggered (1) or not (0)
+// 
+//
+Bool_t MMcTriggerLvl2::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
+{
+  // Pixel in no-trigger region are set to 0
+  val = this->IsPixelInTrigger(idx) ?  fFiredPixel[idx]+fCompactPixel[idx] : 0;
+
+  return kTRUE;
+}
+
+void MMcTriggerLvl2::DrawPixelContent(Int_t num) const
+{
+    *fLog << "MMcTriggerLvl2::DrawPixelContent - not available." << endl;
+}
Index: /tags/Mars_V0-8-5/Mars/manalysis/MMcTriggerLvl2.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MMcTriggerLvl2.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MMcTriggerLvl2.h	(revision 9661)
@@ -0,0 +1,106 @@
+#ifndef MARS_MMcTriggerLvl2
+#define MARS_MMcTriggerLvl2
+
+#ifndef MARS_MCamEvent
+#include "MCamEvent.h"
+#endif
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MMcTrig;
+class MMcEvt;
+class MGeomCamMagic;
+class MGeomCam;
+class MGeomPix;
+
+class MMcTriggerLvl2 : public MParContainer, public MCamEvent
+{
+ private:
+  
+  // Global trigger variables related to the geometry and trigger structures are here defined.  
+  // FIXME!  this is a temporary solution: these variables should be defined in a GeomTrg class    
+
+  static const Int_t fNumPixCell = 36; // Number of pixels in one cell
+
+  static const Int_t gsNCells = 19;   
+  static const Int_t gsNTrigPixels = 397;   
+  static const Int_t gsNPixInCell = 36;  
+  static const Int_t gsNLutInCell = 3;  
+  static const Int_t gsNPixInLut = 12; 
+  Int_t fPixels[gsNPixInCell][gsNCells];  
+  
+  // Array with flag for triggered pixels. 1st idx:pixels in trigger cell; 2nd idx:trigger cell number      
+
+  Int_t fFiredPixel[gsNTrigPixels]; // Array with flag for triggered pixel. idx: pixel id    
+  static const Int_t gsPixelsInCell[gsNPixInCell][gsNCells];   
+  static const Int_t gsPixelsInLut[gsNLutInCell][gsNPixInLut];     
+
+  Int_t fMaxCell;  // Cell with maximum number of fired pixels
+
+  Int_t fLutPseudoSize;   // number of compact pixels in one lut   
+  Int_t fPseudoSize;   // Multiplicity of the cluster identified by the L2T    
+  Int_t fSizeBiggerCell; // Number of fired pixel in bigger cell    
+  Int_t fCompactNN;    //Number of NN pixels that define a compact pixel    
+  Int_t fCompactPixel[gsNTrigPixels]; //Array with flag for compact pixels    
+  Int_t fCluster_pix[gsNTrigPixels]; //Array with pixel in cluster   
+  Double_t fEnergy;  // Energy of the shower    
+  Int_t fTriggerPattern; // x-NN compact trigger pattern;    
+  Int_t fCellPseudoSize; // number of compact pixels in one cell    
+  //  Int_t fCellCompactPixels[fNumPixCell]; // Array with compact pixels in cell
+
+  MMcTrig *fMcTrig;   
+  MGeomCam *fGeomCam;      
+
+     
+  Int_t CalcBiggerFiredCell();   
+  Int_t CalcBiggerLutPseudoSize();   
+  void CalcPseudoSize();   
+  Int_t CalcCellPseudoSize();   
+  Int_t CalcBiggerCellPseudoSize();    
+  Int_t GetCellCompactPixel(int cell, MGeomCam *fCam);
+
+  void SetNewCamera(MGeomCam *geom) {fGeomCam = geom;}   
+
+ public:     
+
+  MMcTriggerLvl2(const char* name = NULL, const char* title = NULL);   
+  ~MMcTriggerLvl2();      
+
+  virtual void Calc();    
+  virtual void Print(Option_t *opt="") const;    
+
+  void SetLv1(MMcTrig *trig = NULL);    
+  void SetPixelFired(Int_t pixel, Int_t fired=1);     
+  void SetCompactNN(Int_t neighpix)     {fCompactNN=neighpix;}    
+
+  Int_t GetPseudoSize() const     {return fPseudoSize;}   
+  Int_t GetLutPseudoSize() const  {return fLutPseudoSize;}   
+  Int_t GetSizeBiggerCell() const {return fSizeBiggerCell;}   
+  Int_t GetCompactNN() const      {return fCompactNN;}   
+  Int_t GetCellPseudoSize() const {return fCellPseudoSize;}
+  Int_t GetMaxCell() const        {return (fMaxCell+1);} // Returns
+                     // cell with maximum number of compact pixels
+  Int_t GetCellNumberFired(int cell);   
+  Int_t GetLutCompactPixel(int cell, int lut); 
+  void CalcCompactPixels(MGeomCam *fCam);
+  void CalcTriggerPattern(MGeomCam *fCam);
+    
+  Int_t GetTriggerPattern() const {return fTriggerPattern;}    
+
+  void GetEnergy(MMcEvt *fMcEvt = NULL);     
+  Double_t GetEnergy() const    {return fEnergy;}      
+
+  Bool_t IsPixelInCell(Int_t pixel, Int_t cell);    
+  Bool_t IsPixelInTrigger(Int_t pixel) const;    
+
+  Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
+  void DrawPixelContent(Int_t num) const;
+
+
+  ClassDef(MMcTriggerLvl2,0) // Container for 2nd Level Trigger selection parameters 
+    };  
+    
+#endif      
+    
Index: /tags/Mars_V0-8-5/Mars/manalysis/MMcTriggerLvl2Calc.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MMcTriggerLvl2Calc.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MMcTriggerLvl2Calc.cc	(revision 9661)
@@ -0,0 +1,209 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Antonio Stamerra  1/2003 <mailto:antono.stamerra@pi.infn.it>
+!   Author(s): Marcos Lopez 1/2003 <mailto:marcos@gae.ucm.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MTriggerLvl2Calc                                                        //
+//   This is a task to calculate the 2nd level trigger selection           //
+//   parameters                                                            //
+//                                                                         //
+//  Input containers:                                                      //
+//    MMcTriggerLvl2                                                            //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MMcTriggerLvl2Calc.h"
+#include "MMcTriggerLvl2.h"
+#include "MHMcTriggerLvl2.h"
+
+#include "MParList.h"
+#include "MLog.h"
+#include "MLogManip.h"
+
+//#include "MMcEvt.hxx"
+#include "MMcTrig.hxx"
+#include "MRawRunHeader.h"
+#include "MMcRunHeader.hxx"
+
+#include "MGeomCam.h"
+
+ClassImp(MMcTriggerLvl2Calc);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//                                                                         
+//  Default constructor
+// 
+//
+MMcTriggerLvl2Calc::MMcTriggerLvl2Calc(const char *name, const char *title)
+{
+  fName  = name  ? name  : "MMcTriggerLvl2Calc";
+  fTitle = title ? title : "Task to Fill the MMcTriggerLvl2 object";  
+} 
+
+ // --------------------------------------------------------------------------
+//
+// 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 MMcTriggerLvl2Calc::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->IsMonteCarloRun();
+}
+
+// --------------------------------------------------------------------------
+//
+// Check for the runtype.
+// Search for .
+//
+Bool_t MMcTriggerLvl2Calc::ReInit(MParList *pList)
+{
+    //
+    // If it is no MC file skip this function...
+    //
+    if (!CheckRunType(pList))
+    {
+        *fLog << inf << "This is no MC file... skipping." << endl;
+        return kTRUE;
+    }
+        
+    //
+    // Check all necessary containers
+    //
+    fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
+     if (!fMcEvt)
+     {
+         *fLog << err << dbginf << "MMcEvt not found... exit." << endl;
+         return kFALSE;
+     }
+
+    fMcTrig = (MMcTrig*)pList->FindObject("MMcTrig");
+    if (!fMcTrig)
+    {
+        *fLog << err << dbginf << "MMcTrig not found... exit." << endl;
+        return kFALSE;
+    }
+
+    fCam = (MGeomCam*)pList->FindObject("MGeomCam");
+    if (!fCam)
+    {
+        *fLog << dbginf << "MGeomCam not found (no geometry information available)... aborting." << endl;
+        return kFALSE;
+    }
+    // Check if fCam is a Magic geometry: only MGeomCamMagic geometry and 
+    // geometries with 577 pixels are now accepted by MMcTriggerLvl2
+    if (fCam->GetNumPixels()!= 577)
+      {
+        *fLog << dbginf << "MGeomCam has a wrong geometry; only MAGIC geometry (577 pixels) is accepted by now... aborting" <<endl;
+	return kFALSE;
+      }
+
+    return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//                                                                         
+//  PreProcess
+//  Check the exxistence of the MMcTriggerLvl2 containers and the correct 
+//    setting of the fCompactNN that defines a compact pixel
+//
+Int_t MMcTriggerLvl2Calc::PreProcess (MParList *pList)
+{
+
+    //    fMMcTriggerLvl2 = (MMcTriggerLvl2*)pList->FindObject("MMcTriggerLvl2");
+    fMMcTriggerLvl2 = (MMcTriggerLvl2*)pList->FindCreateObj("MMcTriggerLvl2");
+    if (!fMMcTriggerLvl2)
+    {
+        *fLog << err << dbginf << "MMcTriggerLvl2 not found... exit." << endl;
+        return kFALSE;
+    }
+
+    fMHMcTriggerLvl2 = (MHMcTriggerLvl2*)pList->FindCreateObj("MHMcTriggerLvl2");
+    if (!fMHMcTriggerLvl2)
+    {
+        *fLog << err << dbginf << "MHMcTriggerLvl2 not found... exit." << endl;
+        return kFALSE;
+    }
+
+    // Check if the variable fCompactNN has been correctly set;
+    //  accepted values for fCompactNN are (up to now) 2 and 3.
+    if (fMMcTriggerLvl2->GetCompactNN()<2 || fMMcTriggerLvl2->GetCompactNN()>3)
+      {
+	*fLog << err << dbginf << "fCompactNN is not correctly set ("<<fMMcTriggerLvl2->GetCompactNN() <<") ... exit" <<endl;
+        return kFALSE;	
+      }
+    else
+      *fLog << "Compact pixel is set with at least "<<fMMcTriggerLvl2->GetCompactNN() << " NN" <<endl;
+
+
+    return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//                                                                         
+//  Process 
+// 
+//
+Int_t MMcTriggerLvl2Calc::Process()
+{
+  //  fMMcTriggerLvl2->GetEnergy(fMcEvt);
+
+  fMMcTriggerLvl2->SetLv1(fMcTrig);
+
+  fMMcTriggerLvl2->CalcCompactPixels(fCam);
+
+  fMMcTriggerLvl2->Calc();
+
+  fMMcTriggerLvl2->CalcTriggerPattern(fCam);
+
+  return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//                                                                         
+//  PostProcess : Display the histogram 
+//           !to be fixed: create an histogram class!
+//
+Int_t MMcTriggerLvl2Calc::PostProcess()
+{ 
+  
+    return kTRUE;
+}
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MMcTriggerLvl2Calc.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MMcTriggerLvl2Calc.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MMcTriggerLvl2Calc.h	(revision 9661)
@@ -0,0 +1,48 @@
+#ifndef MARS_MMcTriggerLvl2Calc
+#define MARS_MMcTriggerLvl2Calc
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MParList;
+
+class MMcEvt;
+class MMcTrig;
+
+class MMcTriggerLvl2;
+class MHMcTriggerLvl2;
+
+class MGeomCam;
+
+class MMcTriggerLvl2Calc : public MTask
+{
+ private:
+
+  MMcEvt  *fMcEvt;
+  MMcTrig *fMcTrig;
+
+  MGeomCam *fCam;
+
+  MMcTriggerLvl2 *fMMcTriggerLvl2;
+  MHMcTriggerLvl2 *fMHMcTriggerLvl2;
+
+  Int_t PreProcess(MParList *pList);
+  Int_t Process();
+  Int_t PostProcess();
+
+  Bool_t ReInit(MParList *pList);
+  Bool_t CheckRunType(MParList *pList) const;
+
+ public:
+    MMcTriggerLvl2Calc(const char *name=NULL, const char *title=NULL);   
+
+    ClassDef(MMcTriggerLvl2Calc, 0) // Task to calculate the MMcTriggerLvl2 Parameters
+};
+
+#endif 
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MMinuitInterface.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MMinuitInterface.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MMinuitInterface.cc	(revision 9661)
@@ -0,0 +1,307 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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 7/2003 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MMinuitInterface                                                        //
+//                                                                         //
+// Class for interfacing with Minuit                                       //
+//                                                                         //
+//                                                                         //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MMinuitInterface.h"
+
+#include <math.h>            // fabs 
+
+#include <TArrayD.h>
+#include <TArrayI.h>
+#include <TMinuit.h>
+#include <TStopwatch.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+#include "MParContainer.h"
+
+ClassImp(MMinuitInterface);
+
+using namespace std;
+
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MMinuitInterface::MMinuitInterface(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MMinuitInterface";
+    fTitle = title ? title : "Interface for Minuit";
+}
+
+// -----------------------------------------------------------------------
+//
+// Interface to MINUIT
+//
+//
+Bool_t MMinuitInterface::CallMinuit( 
+             void (*fcn)(Int_t &, Double_t *, Double_t &, Double_t *, Int_t),
+             const TString* name, const TArrayD &vinit, const TArrayD &step2,
+             const TArrayD &limlo, const TArrayD &limup, const TArrayI &fix,
+             TObject *objectfit , const TString &method, Bool_t nulloutput)
+{
+    TArrayD step(step2);
+
+    //
+    // Be carefull: This is not thread safe
+    //
+    if (vinit.GetSize() != step.GetSize()  ||
+        vinit.GetSize() != limlo.GetSize() ||
+        vinit.GetSize() != limup.GetSize() ||
+        vinit.GetSize() != fix.GetSize())
+    {
+        *fLog << "CallMinuit: Parameter Size Mismatch" << endl;
+        return kFALSE;
+    }
+
+
+
+    //..............................................
+    // Set the maximum number of parameters
+    //TMinuit *const save = gMinuit;
+
+    TMinuit &minuit = *new TMinuit(vinit.GetSize());
+    minuit.SetName("MinuitSupercuts");
+
+
+    //..............................................
+    // Set the print level
+    // -1   no output except SHOW comands
+    //  0   minimum output
+    //  1   normal output (default)
+    //  2   additional ouput giving intermediate results
+    //  3   maximum output, showing progress of minimizations
+    //
+    minuit.SetPrintLevel(-1);
+
+    //..............................................
+    // Printout for warnings
+    //    SET WAR      print warnings
+    //    SET NOW      suppress warnings
+    Int_t errWarn;
+    Double_t tmpwar = 0;
+    minuit.mnexcm("SET NOW", &tmpwar, 0, errWarn);
+    //minuit.mnexcm("SET WAR", &tmpwar, 0, errWarn);
+
+    //..............................................
+    // Set the address of the minimization function
+    minuit.SetFCN(fcn);
+
+    //..............................................
+    // Store address of object to be used in fcn
+    minuit.SetObjectFit(objectfit );
+
+    //..............................................
+    // Set starting values and step sizes for parameters
+    for (Int_t i=0; i<vinit.GetSize(); i++)
+    {
+        if (minuit.DefineParameter(i, name[i], vinit[i], step[i],
+                                   limlo[i], limup[i]))
+        {
+            *fLog << "CallMinuit: Error in defining parameter "
+                << name[i][0] << endl;
+            return kFALSE;
+        }
+    }
+
+    //..............................................
+    //Int_t NumPars;
+    //NumPars = minuit.GetNumPars();
+    //*fLog << "CallMinuit :  number of free parameters = "
+    //     << NumPars << endl;
+
+
+    //..............................................
+        // Error definition :
+    //
+    //    for chisquare function :
+    //      up = 1.0   means calculate 1-standard deviation error
+    //         = 4.0   means calculate 2-standard deviation error
+    //
+    //    for log(likelihood) function :
+    //      up = 0.5   means calculate 1-standard deviation error
+    //         = 2.0   means calculate 2-standard deviation error
+    minuit.SetErrorDef(1.0);
+
+    // Int_t errMigrad;
+    // Double_t tmp = 0;
+    // minuit.mnexcm("MIGRAD", &tmp, 0, errMigrad);
+
+    //..............................................
+    // fix a parameter
+    for (Int_t i=0; i<vinit.GetSize(); i++)
+    {
+        if (fix[i] > 0)
+        {
+            minuit.FixParameter(i);
+            step[i] = 0.0;
+        }
+    }
+
+    //..............................................
+    //NumPars = minuit.GetNumPars();
+    //*fLog << "CallMinuit :  number of free parameters = "
+    //     << NumPars << endl;
+
+    //..............................................
+    // This doesn't seem to have any effect
+    // Set maximum number of iterations (default = 500)
+    //Int_t maxiter = 100000;
+    //minuit.SetMaxIterations(maxiter);
+
+    //..............................................
+    // minimization by the method of Migrad
+    if (method.Contains("Migrad", TString::kIgnoreCase))
+    {
+        //*fLog << "call MIGRAD" << endl;
+        if (nulloutput)
+            fLog->SetNullOutput(kTRUE);
+        Double_t tmp = 0;
+        minuit.mnexcm("MIGRAD", &tmp, 0, fErrMinimize);
+        if (nulloutput)
+            fLog->SetNullOutput(kFALSE);
+        //*fLog << "return from MIGRAD" << endl;
+    }
+
+    //..............................................
+    // same minimization as by Migrad
+    // but switches to the SIMPLEX method if MIGRAD fails to converge
+    if (method.Contains("Minimize", TString::kIgnoreCase))
+    {
+        *fLog << "call MINIMIZE" << endl;
+        Double_t tmp = 0;
+        minuit.mnexcm("MINIMIZE", &tmp, 0, fErrMinimize);
+        *fLog << "return from MINIMIZE" << endl;
+    }
+
+    //..............................................
+    // minimization by the SIMPLEX method
+    if (method.Contains("Simplex", TString::kIgnoreCase))
+    {
+        *fLog << "call SIMPLEX" << endl;
+        if (nulloutput)
+            fLog->SetNullOutput(kTRUE);
+        Int_t    maxcalls  = 3000;
+        Double_t tolerance = 0.1;
+        Double_t tmp[2];
+        tmp[0] = maxcalls;
+        tmp[1] = tolerance;
+        minuit.mnexcm("SIMPLEX", &tmp[0], 2, fErrMinimize);
+        if (nulloutput)
+            fLog->SetNullOutput(kFALSE);
+        *fLog << "return from SIMPLEX" << endl;
+    }
+
+    //..............................................
+    // check quality of minimization
+    // istat = 0   covariance matrix not calculated
+    //         1   diagonal approximation only (not accurate)
+    //         2   full matrix, but forced positive-definite
+    //         3   full accurate covariance matrix
+    //             (indication of normal convergence)
+    minuit.mnstat(fMin, fEdm, fErrdef, fNpari, fNparx, fIstat);
+
+    //if (fErrMinimize != 0  ||  fIstat < 3)
+    if (fErrMinimize != 0)
+    {
+        *fLog << "CallMinuit : Minimization failed" << endl;
+        *fLog << "       fMin = " << fMin   << ",   fEdm = "  << fEdm
+            << ",   fErrdef = "  << fErrdef << ",   fIstat = " << fIstat
+            << ",   fErrMinimize = " << fErrMinimize << endl;
+        return kFALSE;
+    }
+
+    //*fLog << "CallMinuit : Minimization was successful" << endl;
+    //*fLog << "       fMin = " << fMin   << ",   fEdm = "  << fEdm
+    //     << ",   fErrdef = "  << fErrdef << ",   fIstat = " << fIstat
+    //     << ",   fErrMinimize = " << fErrMinimize << endl;
+
+
+    //..............................................
+    // minimization by the method of Migrad
+    if (method.Contains("Hesse", TString::kIgnoreCase))
+    {
+        //*fLog << "call HESSE" << endl;
+        Double_t tmp = 0;
+        minuit.mnexcm("HESSE", &tmp, 0, fErrMinimize);
+        //*fLog << "return from HESSE" << endl;
+    }
+
+    //..............................................
+    // Minos error analysis
+    if (method.Contains("Minos", TString::kIgnoreCase))
+    {
+        //*fLog << "call MINOS" << endl;
+        Double_t tmp = 0;
+        minuit.mnexcm("MINOS", &tmp, 0, fErrMinimize);
+        //*fLog << "return from MINOS" << endl;
+    }
+
+    //..............................................
+    // Print current status of minimization
+    // if nkode = 0    only function value
+    //            1    parameter values, errors, limits
+    //            2    values, errors, step sizes, internal values
+    //            3    values, errors, step sizes, 1st derivatives
+    //            4    values, parabolic errors, MINOS errors
+
+    //Int_t nkode = 4;
+    //minuit.mnprin(nkode, fmin);
+
+    //..............................................
+    // call fcn with IFLAG = 3 (final calculation : calculate p(chi2))
+    // iflag = 1   initial calculations only
+    //         2   calculate 1st derivatives and function
+    //         3   calculate function only
+    //         4   calculate function + final calculations
+    Double_t iflag = 3;
+    Int_t errfcn3;
+    minuit.mnexcm("CALL", &iflag, 1, errfcn3);
+
+    // WW : the following statements were commented out because the
+    // Minuit object will still be used;
+    // this may be changed in the future 
+    //delete &minuit;
+    //gMinuit = save;
+
+    return kTRUE;
+}
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MMinuitInterface.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MMinuitInterface.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MMinuitInterface.h	(revision 9661)
@@ -0,0 +1,61 @@
+#ifndef MARS_MMinuitInterface
+#define MARS_MMinuitInterface
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class TArrayD;
+class TArrayI;
+
+class MMinuitInterface : public MParContainer
+{
+private:
+    UInt_t   fNpar;
+    Double_t fMin,   fEdm,   fErrdef;
+    Int_t    fNpari, fNparx, fIstat;
+    Int_t    fErrMinimize;
+
+public:
+    MMinuitInterface(const char *name=NULL, const char *title=NULL);
+
+    Bool_t CallMinuit(
+                      void (*fcn)(Int_t &, Double_t *, Double_t &, Double_t *, Int_t),
+                      const TString *name, const TArrayD &vinit, const TArrayD &step,
+                      const TArrayD &limlo, const TArrayD &limup, const TArrayI &fix,
+                      TObject *fObjectFit, const TString &method, Bool_t nulloutput);
+
+    ClassDef(MMinuitInterface, 0) // Class for interfacing with Minuit
+};
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MMultiDimDistCalc.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MMultiDimDistCalc.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MMultiDimDistCalc.cc	(revision 9661)
@@ -0,0 +1,226 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 5/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Rudy Bock, 5/2002 <mailto:rkb@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MMultiDimDistCalc
+//
+//  Calculated a multidimensional distance. It calculates the distance to
+//  all vectors in a given matrix describing Gammas and another one
+//  describing Hadrons (non gammas). The shortest distances are avaraged.
+//  How many distances are used for avaraging can be specified in the
+//  constructor.
+//
+//  * If you want to use the nearest neighbor function for calculation use:
+//      MMultiDimDistCalc::SetUseKernelMethod(kFALSE);
+//  * If you want to use the kernel function for calculation use:
+//      MMultiDimDistCalc::SetUseKernelMethod(kTRUE); <default>
+//  * To use only the n next neighbors for your calculation use:
+//      MMultiDimDistCalc::SetUseNumRows(n);
+//  * To use all reference events set the number to 0 <default>
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MMultiDimDistCalc.h"
+
+#include <fstream>
+
+#include "MHMatrix.h" // must be before MLogManip.h
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MDataChain.h"
+#include "MDataArray.h"
+
+#include "MHadronness.h"
+
+ClassImp(MMultiDimDistCalc);
+
+using namespace std;
+
+static const TString gsDefName  = "MMultiDimDistCalc";
+static const TString gsDefTitle = "Calculate Hadronness with Nearest Neighbor/Kernel Method";
+
+// --------------------------------------------------------------------------
+//
+// Setup histograms and the number of distances which are used for
+// avaraging in CalcDist
+//
+MMultiDimDistCalc::MMultiDimDistCalc(const char *name, const char *title)
+    : fNum(0), fUseKernel(kTRUE), fHadronnessName("MHadronness"), fData(NULL)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+
+    /*
+     fData = new TList;
+     fData->SetOwner();
+     */
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the data chains
+//
+MMultiDimDistCalc::~MMultiDimDistCalc()
+{
+    //    delete fData;
+}
+
+// --------------------------------------------------------------------------
+//
+// Needs:
+//  - MatrixGammas  [MHMatrix]
+//  - MatrixHadrons {MHMatrix]
+//  - MHadroness
+//  - all data containers used to build the matrixes
+//
+// The matrix object can be filles using MFillH. And must be of the same
+// number of columns (with the same meaning).
+//
+Int_t MMultiDimDistCalc::PreProcess(MParList *plist)
+{
+    fMGammas = (MHMatrix*)plist->FindObject("MatrixGammas", "MHMatrix");
+    if (!fMGammas)
+    {
+        *fLog << err << dbginf << "MatrixGammas [MHMatrix] not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fMHadrons = (MHMatrix*)plist->FindObject("MatrixHadrons", "MHMatrix");
+    if (!fMHadrons)
+    {
+        *fLog << err << dbginf << "MatrixHadrons [MHMatrix] not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    if (fMGammas->GetM().GetNcols() != fMHadrons->GetM().GetNcols())
+    {
+        *fLog << err << dbginf << "Error matrices have different numbers of columns... aborting." << endl;
+        return kFALSE;
+    }
+
+    /*
+    TIter Next(fMGammas->GetRules());
+    TObject *data=NULL;
+    while ((data=Next()))
+    {
+        MDataChain *chain = new MDataChain(data->GetName());
+        if (!chain->PreProcess(plist))
+        {
+            delete chain;
+            return kFALSE;
+        }
+        fData->Add(chain);
+    }
+    */
+    fData = fMGammas->GetColumns();
+    if (!fData)
+    {
+        *fLog << err << dbginf << "Error matrix doesn't contain columns... aborting." << endl;
+        return kFALSE;
+    }
+
+    if (!fData->PreProcess(plist))
+    {
+        *fLog << err << dbginf << "PreProcessing of the MDataArray failed for the columns failed... aborting." << endl;
+        return kFALSE;
+    }
+
+    fHadronness = (MHadronness*)plist->FindCreateObj("MHadronness", fHadronnessName);
+    if (!fHadronness)
+        return kFALSE;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Evaluates the avarage over the fNum shortest distances in a
+// multidimensional space to a matrix (set of vectors) describing
+// gammas and hadrons.
+// The hadroness of the event is defines as the avarage distance to the
+// set of gammas (dg) divided by the avarage distance to the set of
+// hadrons (dh). Because this value is in teh range [0, inf] it is
+// transformed into [0,1] by:
+//  H = exp(-dh/dg);
+//
+Int_t MMultiDimDistCalc::Process()
+{
+    // first copy the data from the data array to a vector event
+    TVector event;
+    *fData >> event;
+
+    Int_t numg = fNum;
+    Int_t numh = fNum;
+    if (fNum==0)
+    {
+        numg = fMGammas->GetM().GetNrows();
+        numh = fMHadrons->GetM().GetNrows();
+    }
+    if (fUseKernel)
+    {
+        numg = -numg;
+        numh = -numh;
+    }
+
+    const Double_t dg = fMGammas->CalcDist(event, numg);
+    const Double_t dh = fMHadrons->CalcDist(event, numh);
+
+    if (dg<0 || dh<0)
+    {
+        *fLog << err << "MHMatrix::CalcDist failed (dg=" << dg << ", dh=" << dh << ")... aborting" << endl;
+        return kERROR;
+    }
+
+    fHadronness->SetHadronness(dg==0 ? 0 : exp(-dh/dg));
+    fHadronness->SetReadyToSave();
+
+    return kTRUE;
+}
+
+void MMultiDimDistCalc::StreamPrimitive(ofstream &out) const
+{
+    out << "   MMultiDimDist " << GetUniqueName();
+
+    if (fName!=gsDefName || fTitle!=gsDefTitle)
+    {
+        out << "(\"" << fName << "\"";
+        if (fTitle!=gsDefTitle)
+            out << ", \"" << fTitle << "\")";
+    }
+    out << ";" << endl;
+
+    if (fHadronnessName!="MHadronness")
+        out << "   " << GetUniqueName() << ".SetHadronnessName(\"" << fHadronnessName << "\");" << endl;
+    if (fNum!=0)
+        out << "   " << GetUniqueName() << ".SetUseNumRows(" << fNum << ");" << endl;
+    if (fUseKernel)
+        out << "   " << GetUniqueName() << ".SetUseKernelMethod();" << endl;
+}
Index: /tags/Mars_V0-8-5/Mars/manalysis/MMultiDimDistCalc.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MMultiDimDistCalc.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MMultiDimDistCalc.h	(revision 9661)
@@ -0,0 +1,48 @@
+#ifndef MARS_MMultiDimDistCalc
+#define MARS_MMultiDimDistCalc
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MHMatrix;
+class MParList;
+class MDataArray;
+class MHadronness;
+
+class MMultiDimDistCalc : public MTask
+{
+private:
+    Int_t  fNum;              // number of distances used for an avarage
+    Bool_t fUseKernel;        // Flag whether kernel method should be used
+
+    TString fHadronnessName;  // Name of container storing hadronness
+
+    MHMatrix   *fMGammas;     //! Gammas describing matrix
+    MHMatrix   *fMHadrons;    //! Hadrons (non gammas) describing matrix
+
+    MHadronness *fHadronness; //! Output container for calculated hadroness
+
+    MDataArray *fData;        //! Used to store the MDataChains to get the event values
+
+    void StreamPrimitive(ofstream &out) const;
+    Int_t PreProcess(MParList *plist);
+    Int_t Process();
+
+public:
+    MMultiDimDistCalc(const char *name=NULL, const char *title=NULL);
+    ~MMultiDimDistCalc();
+
+    void SetHadronnessName(const TString name) { fHadronnessName = name; }
+    TString GetHadronnessName() const { return fHadronnessName; }
+
+    void SetUseNumRows(UShort_t n=0) { fNum = n; }
+    void SetUseKernelMethod(Bool_t k=kTRUE) { fUseKernel = k; }
+
+    ClassDef(MMultiDimDistCalc, 1) // Task to calculate nearest neighbor-/kernel-hadronness
+};
+
+#endif
+
+
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MPad.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MPad.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MPad.cc	(revision 9661)
@@ -0,0 +1,2370 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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, 06/2003 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MPad
+//
+//  The aim of the padding is to make the noise level (NSB + electronic noise)
+//  equal for the MC, ON and OFF data samples
+//  
+//  The target noise level is determined by 'merging' the (sigmabar vs. Theta)
+//  distributions of MC, ON and OFF data.
+//
+//  The prescription on which fraction of events has to padded from
+//  bin k of sigmabar to bin j is stored in the matrices 
+//  fHgMC, fHgON and fHgOFF.
+//
+//  By the padding the number of photons, its error and the pedestal sigmas 
+//  are altered. On average, the number of photons added is zero.
+//
+//  The formulas used can be found in Thomas Schweizer's Thesis,
+//                                    Section 2.2.1
+//
+//  The padding is done as follows :
+//
+//     Increase the sigmabar according to the matrices fHg.... Then generate 
+//     a pedestal sigma for each pixel using the 3D-histogram Theta, pixel no.,
+//     Sigma^2-Sigmabar^2 (fHDiffPixTheta).
+//
+//  The padding has to be done before the image cleaning because the
+//  image cleaning depends on the pedestal sigmas.
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MPad.h"
+
+#include <math.h>
+#include <stdio.h>
+
+#include <TH1.h>
+#include <TH2.h>
+#include <TH3.h>
+#include <TRandom.h>
+#include <TCanvas.h>
+#include <TFile.h>
+
+#include "MBinning.h"
+#include "MSigmabar.h"
+#include "MMcEvt.hxx"
+#include "MLog.h"
+#include "MLogManip.h"
+#include "MParList.h"
+#include "MGeomCam.h"
+
+#include "MCerPhotPix.h"
+#include "MCerPhotEvt.h"
+
+#include "MPedPhotCam.h"
+#include "MPedPhotPix.h"
+
+#include "MBlindPixels.h"
+
+#include "MRead.h"
+#include "MFilterList.h"
+#include "MTaskList.h"
+#include "MBlindPixelCalc.h"
+#include "MHBlindPixels.h"
+#include "MFillH.h"
+#include "MHSigmaTheta.h"
+#include "MEvtLoop.h"
+
+ClassImp(MPad);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+MPad::MPad(const char *name, const char *title) 
+{
+  fName  = name  ? name  : "MPad";
+  fTitle = title ? title : "Task for the padding";
+
+  fType = "";
+
+  fHSigmaThetaMC     = NULL;
+  fHSigmaThetaON     = NULL;
+  fHSigmaThetaOFF    = NULL;
+
+  fHDiffPixThetaMC   = NULL;
+  fHDiffPixThetaON   = NULL;
+  fHDiffPixThetaOFF  = NULL;
+
+  fHSigmaPixThetaMC   = NULL;
+  fHSigmaPixThetaON   = NULL;
+  fHSigmaPixThetaOFF  = NULL;
+
+  fHgMC  = NULL;
+  fHgON  = NULL;
+  fHgOFF = NULL;
+
+  fHBlindPixIdThetaMC  = NULL;
+  fHBlindPixIdThetaON  = NULL;
+  fHBlindPixIdThetaOFF = NULL;
+
+  fHBlindPixNThetaMC   = NULL;
+  fHBlindPixNThetaON   = NULL;
+  fHBlindPixNThetaOFF  = NULL;
+
+  fHSigmaPedestal = NULL;
+  fHPhotons       = NULL;
+  fHNSB           = NULL;
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor. 
+//
+MPad::~MPad()
+{
+  delete fHgMC;
+  delete fHgON;
+  delete fHgOFF;
+
+  delete fHSigmaTheta;
+  delete fHSigmaPixTheta;
+  delete fHDiffPixTheta;
+  delete fHBlindPixNTheta;
+  delete fHBlindPixIdTheta;
+
+  delete fHSigmaPedestal;
+  delete fHPhotons;
+  delete fHNSB;
+
+  delete fInfile;
+}
+// --------------------------------------------------------------------------
+//
+// Merge the sigmabar distributions of 2 samples (samples A and B)
+//
+// input : the original distributions for samples A and B (hista, histb)
+//
+// output : the prescription which fraction of events should be padded
+//          from the sigmabar bin k to bin j (fHgMC, fHgON, fHgOFF)
+//
+
+Bool_t MPad::Merge2Distributions(TH1D *hista, TH1D *histb, TH1D *histap,
+                                      TH2D *fHga,  TH2D *fHgb, Int_t nbinssig )
+{
+  // hista is the normalized 1D histogram of sigmabar for sample A
+  // histb is the normalized 1D histogram of sigmabar for sample B
+  // histc is the difference A-B
+
+  // at the beginning, histap is a copy of hista
+  // at the end, it will be the 1D histogram for sample A after padding
+
+  // at the beginning, histbp is a copy of histb
+  // at the end, it will be the 1D histogram for sample B after padding
+
+  // at the beginning, histcp is a copy of histc
+  // at the end, it should be the difference histap-histbp,
+  //             which should be zero
+
+  // fHga[k][j]  tells which fraction of events from sample A should be padded
+  //             from sigma_k to sigma_j
+
+
+  // fHgb[k][j]  tells which fraction of events from sample B should be padded
+  //             from sigma_k to sigma_j
+
+  Double_t eps = 1.e-10;
+
+    TH1D *histbp  = new TH1D( (const TH1D&)*histb );
+
+    TH1D *histc   = new TH1D( (const TH1D&)*hista );
+    histc->Add(histb, -1.0);
+
+    TH1D *histcp  = new TH1D( (const TH1D&)*histc );    
+
+
+  //--------   start j loop   ------------------------------------------------
+  // loop over bins in histc, 
+  // starting from the end (i.e. at the largest sigmabar)
+  Double_t v, s, w, t, x, u, a, b, arg;
+
+  for (Int_t j=nbinssig; j >= 1; j--)
+  {
+    v = histcp->GetBinContent(j);
+    if ( fabs(v) < eps ) continue;
+    if (v >= 0.0) 
+      s = 1.0;
+    else
+      s = -1.0;
+
+    //................   start k loop   ......................................
+    // look for a bin k which may compensate the content of bin j
+    for (Int_t k=j-1; k >= 1; k--)
+    {
+      w = histcp->GetBinContent(k);
+      if ( fabs(w) < eps ) continue;
+      if (w >= 0.0) 
+        t = 1.0;
+      else
+        t = -1.0;
+
+      // if s==t bin k cannot compensate, go to next k bin
+      if (s == t) continue;
+
+      x = v + w;
+      if (x >= 0.0) 
+        u = 1.0;
+      else
+        u = -1.0;
+
+      // if u==s bin k will partly compensate : pad the whole fraction
+      // w from bin k to bin j
+      if (u == s)
+        arg = -w;
+
+      // if u!=s bin k would overcompensate : pad only the fraction
+      // v from bin k to bin j
+      else
+        arg = v;
+
+      if (arg <=0.0)
+      {
+        fHga->SetBinContent(k, j, -arg);
+        fHgb->SetBinContent(k, j,  0.0);
+      }
+      else
+      {
+        fHga->SetBinContent(k, j,  0.0);
+        fHgb->SetBinContent(k, j,  arg);
+      }
+
+      *fLog << all << "k, j, arg = " << k << ",  " << j 
+            << ",  " << arg << endl;
+
+      //......................................
+      // this is for checking the procedure
+      if (arg < 0.0)
+      {
+        a = histap->GetBinContent(k);
+        histap->SetBinContent(k, a+arg);
+        a = histap->GetBinContent(j);
+        histap->SetBinContent(j, a-arg);
+      }
+      else
+      {
+        b = histbp->GetBinContent(k);
+        histbp->SetBinContent(k, b-arg);
+        b = histbp->GetBinContent(j);
+        histbp->SetBinContent(j, b+arg);
+      }
+      //......................................
+
+      if (u == s)
+      {
+        histcp->SetBinContent(k, 0.0);
+        histcp->SetBinContent(j,   x);
+
+        v = histcp->GetBinContent(j);
+        if ( fabs(v) < eps ) break;
+
+        // bin j was only partly compensated : go to next k bin
+        continue;
+      }
+      else
+      {
+        histcp->SetBinContent(k,   x);
+        histcp->SetBinContent(j, 0.0);
+
+        // bin j was completely compensated : go to next j bin
+        break;
+      }
+
+    }
+    //................   end k loop   ......................................
+  } 
+  //--------   end j loop   ------------------------------------------------
+
+  // check results 
+  for (Int_t j=1; j<=nbinssig; j++)
+  {
+    Double_t a = histap->GetBinContent(j);
+    Double_t b = histbp->GetBinContent(j);
+    Double_t c = histcp->GetBinContent(j);
+
+    if( fabs(a-b)>3.0*eps  ||  fabs(c)>3.0*eps )
+      *fLog << err << "MPad::Merge2Distributions(); inconsistency in results; j, a, b, c = "
+            << j << ",  " << a << ",  " << b << ",  " << c << endl;
+  }
+
+  //---------------------------------------------------------------
+  TCanvas &c = *(MH::MakeDefCanvas("Merging", "", 600, 600)); 
+  c.Divide(2, 2);
+  gROOT->SetSelectedPad(NULL);
+
+  c.cd(1);
+  hista->SetDirectory(NULL);
+  hista->DrawCopy();
+  hista->SetBit(kCanDelete);    
+
+  c.cd(2);
+  histb->SetDirectory(NULL);
+  histb->DrawCopy();
+  histb->SetBit(kCanDelete);    
+
+  c.cd(3);
+  histap->SetDirectory(NULL);
+  histap->DrawCopy();
+  histap->SetBit(kCanDelete);    
+
+  //--------------------------------------------------------------------
+
+  delete histc;
+  delete histbp;
+  delete histcp;
+
+  return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Merge the distributions 
+//   fHSigmaTheta      2D-histogram  (Theta, sigmabar)
+//
+// ===>   of ON, OFF and MC data   <==============
+//
+// and define the matrices fHgMC, fHgON and fHgOFF 
+//
+// These matrices tell which fraction of events should be padded 
+// from bin k of sigmabar to bin j
+//
+
+Bool_t MPad::MergeONOFFMC(
+   TH2D *sigthmc,  TH3D *diffpixthmc,  TH3D *sigmapixthmc,
+   TH2D *blindidthmc,  TH2D *blindnthmc,
+   TH2D *sigthon,  TH3D *diffpixthon,  TH3D *sigmapixthon,
+   TH2D *blindidthon,  TH2D *blindnthon,
+   TH2D *sigthoff, TH3D *diffpixthoff, TH3D *sigmapixthoff,
+   TH2D *blindidthoff, TH2D *blindnthoff)
+{
+  *fLog << all << "----------------------------------------------------------------------------------" << endl;
+  *fLog << all << "MPad::MergeONOFFMC(); Merge the ON, OFF and MC histograms to obtain the target distributions for the padding"
+        << endl;
+
+  fHSigmaTheta = new TH2D( (TH2D&)*sigthon );
+  fHSigmaTheta->SetNameTitle("2D-ThetaSigmabar", "2D-ThetaSigmabar (target)");
+
+  fHDiffPixTheta = new TH3D( (TH3D&)*diffpixthon );
+  fHDiffPixTheta->SetNameTitle("3D-ThetaPixDiff", "3D-ThetaPixDiff (target)");
+
+  fHSigmaPixTheta = new TH3D( (TH3D&)*sigmapixthon );
+  fHSigmaPixTheta->SetNameTitle("3D-ThetaPixSigma", "3D-ThetaPixSigma (target)");
+
+  fHBlindPixNTheta = new TH2D( (TH2D&)*blindnthon );
+  fHBlindPixNTheta->SetNameTitle("2D-ThetaBlindN", "2D-ThetaBlindN (target)");
+
+  fHBlindPixIdTheta = new TH2D( (TH2D&)*blindidthon );
+  fHBlindPixIdTheta->SetNameTitle("2D-ThetaBlindId", "2D-ThetaBlindId (target)");
+
+  //--------------------------
+  fHSigmaThetaMC = sigthmc;
+  fHSigmaThetaMC->SetNameTitle("2D-ThetaSigmabarMC", "2D-ThetaSigmabarMC (orig.)");
+  fHSigmaThetaON = sigthon;
+  fHSigmaThetaON->SetNameTitle("2D-ThetaSigmabarON", "2D-ThetaSigmabarON (orig.)");
+  fHSigmaThetaOFF = sigthoff;
+  fHSigmaThetaOFF->SetNameTitle("2D-ThetaSigmabarOFF", "2D-ThetaSigmabarOFF (orig.)");
+
+  //--------------------------
+  fHBlindPixNThetaMC = blindnthmc;
+  fHBlindPixNThetaMC->SetNameTitle("2D-ThetaBlindNMC", "2D-ThetaBlindNMC (orig.)");
+  fHBlindPixNThetaON = blindnthon;
+  fHBlindPixNThetaON->SetNameTitle("2D-ThetaBlindNON", "2D-ThetaBlindNON (orig.)");
+  fHBlindPixNThetaOFF = blindnthoff;
+  fHBlindPixNThetaOFF->SetNameTitle("2D-ThetaBlindNOFF", "2D-ThetaBlindNOFF (orig.)");
+
+  //--------------------------
+  fHBlindPixIdThetaMC = blindidthmc;
+  fHBlindPixIdThetaMC->SetNameTitle("2D-ThetaBlindIdMC", "2D-ThetaBlindIdMC (orig.)");
+  fHBlindPixIdThetaON = blindidthon;
+  fHBlindPixIdThetaON->SetNameTitle("2D-ThetaBlindIdON", "2D-ThetaBlindIdON (orig.)");
+  fHBlindPixIdThetaOFF = blindidthoff;
+  fHBlindPixIdThetaOFF->SetNameTitle("2D-ThetaBlindIdOFF", "2D-ThetaBlindIdOFF (orig.)");
+
+  //--------------------------
+  fHDiffPixThetaMC = diffpixthmc;
+  fHDiffPixThetaMC->SetNameTitle("3D-ThetaPixDiffMC", "3D-ThetaPixDiffMC (orig.)");
+  fHDiffPixThetaON = diffpixthon;
+  fHDiffPixThetaON->SetNameTitle("3D-ThetaPixDiffON", "3D-ThetaPixDiffON (orig.)");
+  fHDiffPixThetaOFF = diffpixthoff;
+  fHDiffPixThetaOFF->SetNameTitle("3D-ThetaPixDiffOFF", "3D-ThetaPixDiffOFF (orig.)");
+
+  //--------------------------
+  fHSigmaPixThetaMC = sigmapixthmc;
+  fHSigmaPixThetaMC->SetNameTitle("3D-ThetaPixSigmaMC", "3D-ThetaPixSigmaMC (orig.)");
+  fHSigmaPixThetaON = sigmapixthon;
+  fHSigmaPixThetaON->SetNameTitle("3D-ThetaPixSigmaON", "3D-ThetaPixSigmaON (orig.)");
+  fHSigmaPixThetaOFF = sigmapixthoff;
+  fHSigmaPixThetaOFF->SetNameTitle("3D-ThetaPixSigmaOFF", "3D-ThetaPixSigmaOFF (orig.)");
+  //--------------------------
+
+
+  // get binning for fHgON, fHgOFF and fHgMC  from sigthon
+  // binning in Theta
+  TAxis *ax = sigthon->GetXaxis();
+  Int_t nbinstheta = ax->GetNbins();
+  TArrayD edgesx;
+  edgesx.Set(nbinstheta+1);
+  for (Int_t i=0; i<=nbinstheta; i++)
+  {
+    edgesx[i] = ax->GetBinLowEdge(i+1);
+    *fLog << all << "i, theta low edge = " << i << ",  " << edgesx[i] 
+          << endl; 
+  }
+  MBinning binth;
+  binth.SetEdges(edgesx);
+
+  // binning in sigmabar
+  TAxis *ay = sigthon->GetYaxis();
+  Int_t nbinssig = ay->GetNbins();
+  TArrayD edgesy;
+  edgesy.Set(nbinssig+1);
+  for (Int_t i=0; i<=nbinssig; i++)
+  {
+    edgesy[i] = ay->GetBinLowEdge(i+1); 
+    *fLog << all << "i, sigmabar low edge = " << i << ",  " << edgesy[i] 
+          << endl; 
+  }
+  MBinning binsg;
+  binsg.SetEdges(edgesy);
+
+
+  fHgMC = new TH3D;
+  MH::SetBinning(fHgMC, &binth, &binsg, &binsg);
+  fHgMC->SetNameTitle("3D-PaddingMatrixMC", "3D-PadMatrixThetaMC");
+
+  fHgON = new TH3D;
+  MH::SetBinning(fHgON, &binth, &binsg, &binsg);
+  fHgON->SetNameTitle("3D-PaddingMatrixON", "3D-PadMatrixThetaON");
+
+  fHgOFF = new TH3D;
+  MH::SetBinning(fHgOFF, &binth, &binsg, &binsg);
+  fHgOFF->SetNameTitle("3D-PaddingMatrixOFF", "3D-PadMatrixThetaOFF");
+
+  //............   loop over Theta bins   ...........................
+
+
+
+  *fLog << all << "MPad::MergeONOFFMC(); bins of Theta, Sigmabarold, Sigmabarnew, fraction of events to be padded" << endl;
+  for (Int_t l=1; l<=nbinstheta; l++)
+  {
+    TH2D * fHga = new TH2D;
+    MH::SetBinning(fHga, &binsg, &binsg);
+    TH2D * fHgb = new TH2D;
+    MH::SetBinning(fHgb, &binsg, &binsg);
+
+    //-------------------------------------------
+    // merge ON and OFF distributions
+    // input : hista is the normalized 1D distr. of sigmabar for ON  data
+    //         histb is the normalized 1D distr. of sigmabar for OFF data
+    // output : histap    will be the merged distribution (ON-OFF)
+    //          fHga(k,j) will tell which fraction of ON events should be 
+    //                    padded from bin k to bin j
+    //          fHgb(k,j) will tell which fraction of OFF events should be 
+    //                    padded from bin k to bin j
+
+    TH1D *hista  = sigthon->ProjectionY("sigon_y", l, l, "");
+    Stat_t suma = hista->Integral();
+    hista->Scale(1./suma);
+
+    TH1D *histap  = new TH1D( (const TH1D&)*hista );
+
+    TH1D *histb  = sigthoff->ProjectionY("sigoff_y", l, l, "");
+    Stat_t sumb = histb->Integral();
+    histb->Scale(1./sumb);
+
+    Merge2Distributions(hista, histb, histap, fHga, fHgb, nbinssig);
+    delete hista;
+    delete histb;
+
+    // fill fHgON and fHgOFF
+    for (Int_t k=1; k<=nbinssig; k++)
+      for (Int_t j=1; j<=nbinssig; j++)
+      {
+        Double_t a = fHga->GetBinContent(k,j);
+        fHga->SetBinContent (k, j, 0.0);
+        fHgON->SetBinContent(l, k, j, a);
+
+        Double_t b = fHgb->GetBinContent(k,j);
+        fHgb->SetBinContent (k, j, 0.0);
+        fHgOFF->SetBinContent(l, k, j, b);
+      }
+
+    //-------------------------------------------
+    // now merge ON-OFF and MC distributions
+    // input : hista is the result of the merging of ON and OFF distributions  
+    //         histb is the normalized 1D distr. of sigmabar for MC data
+    // output : histap    will be the merged distribution (target distribution)
+    //          fHga(k,j) will tell which fraction of ON, OFF events should be 
+    //                    padded from bin k to bin j
+    //          fHgb(k,j) will tell which fraction of MC events should be 
+    //                    padded from bin k to bin j
+
+    hista  = new TH1D( (const TH1D&)*histap);
+
+    histb  = sigthmc->ProjectionY("sigmc_y", l, l, "");
+    sumb = histb->Integral();
+    histb->Scale(1./sumb);
+
+    Merge2Distributions(hista, histb, histap, fHga, fHgb, nbinssig);
+    delete hista;
+    delete histb;
+
+    // update fHgON and fHgOFF and fill fHgMC
+    for (Int_t k=1; k<=nbinssig; k++)
+      for (Int_t j=1; j<=nbinssig; j++)
+      {
+        Double_t a   =  fHga->GetBinContent  (k,j);
+
+        Double_t aON = fHgON->GetBinContent(l,k,j);
+        fHgON->SetBinContent(l, k, j, aON+a);
+
+        Double_t aOFF = fHgOFF->GetBinContent(l,k,j);
+        fHgOFF->SetBinContent(l, k, j, aOFF+a);
+
+        Double_t b = fHgb->GetBinContent(k,j);
+        fHgMC->SetBinContent(l, k, j, b);
+      }
+
+    // fill target distribution fHSigmaTheta 
+    // (only for plotting, it will not  be used in the padding)
+    for (Int_t j=1; j<=nbinssig; j++)
+    {
+      Double_t a = histap->GetBinContent(j);
+      fHSigmaTheta->SetBinContent(l, j, a);
+    }
+
+    delete fHga;
+    delete fHgb;
+
+    delete histap;
+  }
+  //............   end of loop over Theta bins   ....................
+
+  
+  // Define the target distributions 
+  //        fHDiffPixTheta, fHSigmaPixTheta
+  //               (they are calculated as 
+  //               averages of the ON and OFF distributions)
+  //        fHBlindPixNTheta, fHBlindPixIdTheta
+  //               (they are calculated as 
+  //               the sum of the ON and OFF distributions)
+  // (fHDiffPixTheta will be used in the padding of MC events)
+
+  //............   start of new loop over Theta bins   ....................
+  for (Int_t j=1; j<=nbinstheta; j++)
+  {
+    // fraction of ON/OFF/MC events to be padded : fracON, fracOFF, fracMC
+
+    Double_t fracON  = fHgON->Integral (j, j, 1, nbinssig, 1, nbinssig, "");
+    Double_t fracOFF = fHgOFF->Integral(j, j, 1, nbinssig, 1, nbinssig, "");
+    Double_t fracMC  = fHgMC->Integral(j, j, 1, nbinssig, 1, nbinssig, "");
+
+    Double_t normON;
+    Double_t normOFF;
+
+    // set ranges for 2D-projections of 3D-histograms
+    TAxis *ax = diffpixthon->GetXaxis();
+    ax->SetRange(j, j);
+    ax = diffpixthoff->GetXaxis();
+    ax->SetRange(j, j);
+
+    TH2D *hist;
+    TH2D *histOFF;
+
+    TH1D *hist1;
+    TH1D *hist1OFF;
+
+    // weights for ON and OFF distrubtions when
+    // calculating the weighted average
+    Double_t facON  = 0.5 * (1. - fracON + fracOFF);
+    Double_t facOFF = 0.5 * (1. + fracON - fracOFF);
+  
+    *fLog << all << "Theta bin j : fracON, fracOFF, facON, facOFF = " 
+          << j << ",  " << fracON << ",  " << fracOFF << ",  "
+          << fracMC << ",  " << facON << ",  " << facOFF << endl; 
+
+    //------------------------------------------------------------------
+    // define target distribution  'sigma^2-sigmavar^2 vs. pixel number'
+    ay = diffpixthon->GetYaxis();
+    Int_t nbinspixel = ay->GetNbins();
+
+    TAxis *az = diffpixthon->GetZaxis();
+    Int_t nbinsdiff = az->GetNbins();
+
+    hist    = (TH2D*)diffpixthon->Project3D("zy");
+    hist->SetName("dummy");
+    histOFF = (TH2D*)diffpixthoff->Project3D("zy");
+
+    normON  = hist->Integral();
+    normOFF = histOFF->Integral();
+    if (normON  != 0.0) hist->Scale(1.0/normON);
+    if (normOFF != 0.0) histOFF->Scale(1.0/normOFF);
+
+    // weighted average of ON and OFF distributions
+    hist->Scale(facON);
+    hist->Add(histOFF, facOFF); 
+
+    for (Int_t k=1; k<=nbinspixel; k++)
+      for (Int_t l=1; l<=nbinsdiff; l++)
+      {
+        Double_t cont = hist->GetBinContent(k,l);
+        fHDiffPixTheta->SetBinContent(j, k, l, cont);  
+      }
+
+    delete hist;
+    delete histOFF;
+
+    //------------------------------------------------------------------
+    // define target distribution  'sigma vs. pixel number'
+    ay = sigmapixthon->GetYaxis();
+    nbinspixel = ay->GetNbins();
+
+    az = sigmapixthon->GetZaxis();
+    Int_t nbinssigma = az->GetNbins();
+
+    hist    = (TH2D*)sigmapixthon->Project3D("zy");
+    hist->SetName("dummy");
+    histOFF = (TH2D*)sigmapixthoff->Project3D("zy");
+
+    normON  = hist->Integral();
+    normOFF = histOFF->Integral();
+    if (normON  != 0.0) hist->Scale(1.0/normON);
+    if (normOFF != 0.0) histOFF->Scale(1.0/normOFF);
+
+    // weighted average of ON and OFF distributions
+    hist->Scale(facON);
+    hist->Add(histOFF, facOFF); 
+
+    for (Int_t k=1; k<=nbinspixel; k++)
+      for (Int_t l=1; l<=nbinssigma; l++)
+      {
+        Double_t cont = hist->GetBinContent(k,l);
+        fHSigmaPixTheta->SetBinContent(j, k, l, cont);  
+      }
+
+    delete hist;
+    delete histOFF;
+
+
+    //------------------------------------------------------------------
+    // define target distribution  'number of blind pixels per event'
+    ay = blindnthon->GetYaxis();
+    Int_t nbinsn = ay->GetNbins();
+
+    hist1    = fHBlindPixNThetaON->ProjectionY("", j, j, "");
+    hist1->SetName("dummy");
+    hist1OFF = fHBlindPixNThetaOFF->ProjectionY("", j, j, "");
+
+    normON  = hist1->Integral();
+    normOFF = hist1OFF->Integral();
+    if (normON  != 0.0) hist1->Scale(1.0/normON);
+    if (normOFF != 0.0) hist1OFF->Scale(1.0/normOFF);
+
+    // sum of ON and OFF distributions
+    hist1->Add(hist1OFF, 1.0); 
+    hist1->Scale( 1.0/hist1->Integral() );
+
+    for (Int_t k=1; k<=nbinsn; k++)
+      {
+        Double_t cont = hist1->GetBinContent(k);
+        fHBlindPixNTheta->SetBinContent(j, k, cont);  
+      }
+
+    delete hist1;
+    delete hist1OFF;
+
+    //------------------------------------------------------------------
+    // define target distribution  'id of blind pixel'
+    ay = blindidthon->GetYaxis();
+    Int_t nbinsid = ay->GetNbins();
+
+    hist1    = fHBlindPixIdThetaON->ProjectionY("", j, j, "");
+    hist1->SetName("dummy");
+    hist1OFF = fHBlindPixIdThetaOFF->ProjectionY("", j, j, "");
+
+    // divide by the number of events (from fHBlindPixNTheta)
+    if (normON  != 0.0) hist1->Scale(1.0/normON);
+    if (normOFF != 0.0) hist1OFF->Scale(1.0/normOFF);
+
+    // sum of ON and OFF distributions
+    hist1->Add(hist1OFF, 1.0); 
+
+    for (Int_t k=1; k<=nbinsid; k++)
+      {
+        Double_t cont = hist1->GetBinContent(k);
+        fHBlindPixIdTheta->SetBinContent(j, k, cont);  
+      }
+
+    delete hist1;
+    delete hist1OFF;
+  }
+  //............   end of new loop over Theta bins   ....................
+
+  *fLog << all 
+        << "MPad::MergeONOFFMC(); The target distributions for the padding have been created" 
+        << endl;
+  *fLog << all << "----------------------------------------------------------" 
+        << endl;
+  //--------------------------------------------
+
+  fHSigmaThetaMC->SetDirectory(NULL);
+  fHSigmaThetaON->SetDirectory(NULL);
+  fHSigmaThetaOFF->SetDirectory(NULL);
+
+  fHDiffPixThetaMC->SetDirectory(NULL);
+  fHDiffPixThetaON->SetDirectory(NULL);
+  fHDiffPixThetaOFF->SetDirectory(NULL);
+
+  fHSigmaPixThetaMC->SetDirectory(NULL);
+  fHSigmaPixThetaON->SetDirectory(NULL);
+  fHSigmaPixThetaOFF->SetDirectory(NULL);
+
+  fHBlindPixIdThetaMC->SetDirectory(NULL);
+  fHBlindPixIdThetaON->SetDirectory(NULL);
+  fHBlindPixIdThetaOFF->SetDirectory(NULL);
+
+  fHBlindPixNThetaMC->SetDirectory(NULL);
+  fHBlindPixNThetaON->SetDirectory(NULL);
+  fHBlindPixNThetaOFF->SetDirectory(NULL);
+
+  fHgMC->SetDirectory(NULL);
+  fHgON->SetDirectory(NULL);
+  fHgOFF->SetDirectory(NULL);
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Merge the distributions 
+//   fHSigmaTheta      2D-histogram  (Theta, sigmabar)
+//
+// ===>   of ON and MC data   <==============
+//
+// and define the matrices fHgMC and fHgON  
+//
+// These matrices tell which fraction of events should be padded 
+// from bin k of sigmabar to bin j
+//
+
+Bool_t MPad::MergeONMC(
+   TH2D *sigthmc,  TH3D *diffpixthmc,  TH3D *sigmapixthmc,
+   TH2D *blindidthmc,  TH2D *blindnthmc,
+   TH2D *sigthon,  TH3D *diffpixthon,  TH3D *sigmapixthon,
+   TH2D *blindidthon,  TH2D *blindnthon)
+{
+  *fLog << all << "----------------------------------------------------------------------------------" << endl;
+  *fLog << all << "MPad::MergeONMC(); Merge the ON  and MC histograms to obtain the target distributions for the padding"
+        << endl;
+
+  fHSigmaTheta = new TH2D( (TH2D&)*sigthon );
+  fHSigmaTheta->SetNameTitle("2D-ThetaSigmabar", "2D-ThetaSigmabar (target)");
+
+  fHDiffPixTheta = new TH3D( (TH3D&)*diffpixthon );
+  fHDiffPixTheta->SetNameTitle("3D-ThetaPixDiff", "3D-ThetaPixDiff (target)");
+
+  fHSigmaPixTheta = new TH3D( (TH3D&)*sigmapixthon );
+  fHSigmaPixTheta->SetNameTitle("3D-ThetaPixSigma", "3D-ThetaPixSigma (target)");
+
+  fHBlindPixNTheta = new TH2D( (TH2D&)*blindnthon );
+  fHBlindPixNTheta->SetNameTitle("2D-ThetaBlindN", "2D-ThetaBlindN (target)");
+
+  fHBlindPixIdTheta = new TH2D( (TH2D&)*blindidthon );
+  fHBlindPixIdTheta->SetNameTitle("2D-ThetaBlindId", "2D-ThetaBlindId (target)");
+
+  //--------------------------
+  fHSigmaThetaMC = sigthmc;
+  fHSigmaThetaMC->SetNameTitle("2D-ThetaSigmabarMC", "2D-ThetaSigmabarMC (orig.)");
+  fHSigmaThetaON = sigthon;
+  fHSigmaThetaON->SetNameTitle("2D-ThetaSigmabarON", "2D-ThetaSigmabarON (orig.)");
+
+  //--------------------------
+  fHBlindPixNThetaMC = blindnthmc;
+  fHBlindPixNThetaMC->SetNameTitle("2D-ThetaBlindNMC", "2D-ThetaBlindNMC (orig.)");
+  fHBlindPixNThetaON = blindnthon;
+  fHBlindPixNThetaON->SetNameTitle("2D-ThetaBlindNON", "2D-ThetaBlindNON (orig.)");
+
+  //--------------------------
+  fHBlindPixIdThetaMC = blindidthmc;
+  fHBlindPixIdThetaMC->SetNameTitle("2D-ThetaBlindIdMC", "2D-ThetaBlindIdMC (orig.)");
+  fHBlindPixIdThetaON = blindidthon;
+  fHBlindPixIdThetaON->SetNameTitle("2D-ThetaBlindIdON", "2D-ThetaBlindIdON (orig.)");
+
+  //--------------------------
+  fHDiffPixThetaMC = diffpixthmc;
+  fHDiffPixThetaMC->SetNameTitle("3D-ThetaPixDiffMC", "3D-ThetaPixDiffMC (orig.)");
+  fHDiffPixThetaON = diffpixthon;
+  fHDiffPixThetaON->SetNameTitle("3D-ThetaPixDiffON", "3D-ThetaPixDiffON (orig.)");
+
+  //--------------------------
+  fHSigmaPixThetaMC = sigmapixthmc;
+  fHSigmaPixThetaMC->SetNameTitle("3D-ThetaPixSigmaMC", "3D-ThetaPixSigmaMC (orig.)");
+  fHSigmaPixThetaON = sigmapixthon;
+  fHSigmaPixThetaON->SetNameTitle("3D-ThetaPixSigmaON", "3D-ThetaPixSigmaON (orig.)");
+
+  //--------------------------
+
+
+  // get binning for fHgON and fHgMC  from sigthon
+  // binning in Theta
+  TAxis *ax = sigthon->GetXaxis();
+  Int_t nbinstheta = ax->GetNbins();
+  TArrayD edgesx;
+  edgesx.Set(nbinstheta+1);
+  for (Int_t i=0; i<=nbinstheta; i++)
+  {
+    edgesx[i] = ax->GetBinLowEdge(i+1);
+    *fLog << all << "i, theta low edge = " << i << ",  " << edgesx[i] 
+          << endl; 
+  }
+  MBinning binth;
+  binth.SetEdges(edgesx);
+
+  // binning in sigmabar
+  TAxis *ay = sigthon->GetYaxis();
+  Int_t nbinssig = ay->GetNbins();
+  TArrayD edgesy;
+  edgesy.Set(nbinssig+1);
+  for (Int_t i=0; i<=nbinssig; i++)
+  {
+    edgesy[i] = ay->GetBinLowEdge(i+1); 
+    *fLog << all << "i, sigmabar low edge = " << i << ",  " << edgesy[i] 
+          << endl; 
+  }
+  MBinning binsg;
+  binsg.SetEdges(edgesy);
+
+
+  fHgMC = new TH3D;
+  MH::SetBinning(fHgMC, &binth, &binsg, &binsg);
+  fHgMC->SetNameTitle("3D-PaddingMatrixMC", "3D-PadMatrixThetaMC");
+
+  fHgON = new TH3D;
+  MH::SetBinning(fHgON, &binth, &binsg, &binsg);
+  fHgON->SetNameTitle("3D-PaddingMatrixON", "3D-PadMatrixThetaON");
+
+
+  //............   loop over Theta bins   ...........................
+
+
+
+  *fLog << all << "MPad::MergeONMC(); bins of Theta, Sigmabarold, Sigmabarnew, fraction of events to be padded" << endl;
+  for (Int_t l=1; l<=nbinstheta; l++)
+  {
+    TH2D * fHga = new TH2D;
+    MH::SetBinning(fHga, &binsg, &binsg);
+    TH2D * fHgb = new TH2D;
+    MH::SetBinning(fHgb, &binsg, &binsg);
+
+    //-------------------------------------------
+    // merge ON and MC distributions
+    // input : hista is the normalized 1D distr. of sigmabar for ON data
+    //         histb is the normalized 1D distr. of sigmabar for MC data
+    // output : histap    will be the merged distribution (ON-MC)
+    //          fHga(k,j) will tell which fraction of ON events should be 
+    //                    padded from bin k to bin j
+    //          fHgb(k,j) will tell which fraction of MC events should be 
+    //                    padded from bin k to bin j
+
+    TH1D *hista  = sigthon->ProjectionY("sigon_y", l, l, "");
+    Stat_t suma = hista->Integral();
+    hista->Scale(1./suma);
+
+    TH1D *histap  = new TH1D( (const TH1D&)*hista );
+
+    TH1D *histb  = sigthmc->ProjectionY("sigmc_y", l, l, "");
+    Stat_t sumb = histb->Integral();
+    histb->Scale(1./sumb);
+
+    Merge2Distributions(hista, histb, histap, fHga, fHgb, nbinssig);
+    delete hista;
+    delete histb;
+
+    // fill fHgON and fHgMC
+    for (Int_t k=1; k<=nbinssig; k++)
+      for (Int_t j=1; j<=nbinssig; j++)
+      {
+        Double_t a = fHga->GetBinContent(k,j);
+        fHga->SetBinContent (k, j, 0.0);
+        fHgON->SetBinContent(l, k, j, a);
+
+        Double_t b = fHgb->GetBinContent(k,j);
+        fHgb->SetBinContent (k, j, 0.0);
+        fHgMC->SetBinContent(l, k, j, b);
+      }
+
+
+    // fill target distribution fHSigmaTheta 
+    // (only for plotting, it will not  be used in the padding)
+    for (Int_t j=1; j<=nbinssig; j++)
+    {
+      Double_t a = histap->GetBinContent(j);
+      fHSigmaTheta->SetBinContent(l, j, a);
+    }
+
+    delete fHga;
+    delete fHgb;
+
+    delete histap;
+  }
+  //............   end of loop over Theta bins   ....................
+
+  
+  // Define the target distributions 
+  //        fHDiffPixTheta, fHSigmaPixTheta
+  //               (they are calculated as 
+  //               averages of the ON and MCdistributions)
+  //        fHBlindPixNTheta, fHBlindPixIdTheta
+  //               (they are calculated as 
+  //               the sum of the ON and MC distributions)
+  // (fHDiffPixTheta will be used in the padding of MC events)
+
+  //............   start of new loop over Theta bins   ....................
+  for (Int_t j=1; j<=nbinstheta; j++)
+  {
+    // fraction of ON/MC events to be padded : fracON, fracMC
+
+    Double_t fracON  = fHgON->Integral (j, j, 1, nbinssig, 1, nbinssig, "");
+    Double_t fracMC  = fHgMC->Integral(j, j, 1, nbinssig, 1, nbinssig, "");
+
+    Double_t normON;
+    Double_t normMC;
+
+    // set ranges for 2D-projections of 3D-histograms
+    TAxis *ax = diffpixthon->GetXaxis();
+    ax->SetRange(j, j);
+    ax = diffpixthmc->GetXaxis();
+    ax->SetRange(j, j);
+
+    TH2D *hist;
+    TH2D *histMC;
+
+    TH1D *hist1;
+    TH1D *hist1MC;
+
+    // weights for ON and MC distrubtions when
+    // calculating the weighted average
+    Double_t facON = 0.5 * (1. - fracON + fracMC);
+    Double_t facMC = 0.5 * (1. + fracON - fracMC);
+  
+    *fLog << all << "Theta bin j : fracON, fracMC, facON, facMC = " 
+          << j << ",  " << fracON << ",  " << fracMC << ",  "
+          << facON << ",  " << facMC << endl; 
+
+    //------------------------------------------------------------------
+    // define target distribution  'sigma^2-sigmavar^2 vs. pixel number'
+    ay = diffpixthon->GetYaxis();
+    Int_t nbinspixel = ay->GetNbins();
+
+    TAxis *az = diffpixthon->GetZaxis();
+    Int_t nbinsdiff = az->GetNbins();
+
+    hist    = (TH2D*)diffpixthon->Project3D("zy");
+    hist->SetName("dummy");
+    histMC = (TH2D*)diffpixthmc->Project3D("zy");
+
+    normON  = hist->Integral();
+    normMC = histMC->Integral();
+    if (normON  != 0.0) hist->Scale(1.0/normON);
+    if (normMC != 0.0)  histMC->Scale(1.0/normMC);
+
+    // weighted average of ON and MC distributions
+    hist->Scale(facON);
+    hist->Add(histMC, facMC); 
+
+    for (Int_t k=1; k<=nbinspixel; k++)
+      for (Int_t l=1; l<=nbinsdiff; l++)
+      {
+        Double_t cont = hist->GetBinContent(k,l);
+        fHDiffPixTheta->SetBinContent(j, k, l, cont);  
+      }
+
+    delete hist;
+    delete histMC;
+
+    //------------------------------------------------------------------
+    // define target distribution  'sigma vs. pixel number'
+    ay = sigmapixthon->GetYaxis();
+    nbinspixel = ay->GetNbins();
+
+    az = sigmapixthon->GetZaxis();
+    Int_t nbinssigma = az->GetNbins();
+
+    hist    = (TH2D*)sigmapixthon->Project3D("zy");
+    hist->SetName("dummy");
+    histMC = (TH2D*)sigmapixthmc->Project3D("zy");
+
+    normON  = hist->Integral();
+    normMC = histMC->Integral();
+    if (normON  != 0.0) hist->Scale(1.0/normON);
+    if (normMC != 0.0) histMC->Scale(1.0/normMC);
+
+    // weighted average of ON and MC distributions
+    hist->Scale(facON);
+    hist->Add(histMC, facMC); 
+
+    for (Int_t k=1; k<=nbinspixel; k++)
+      for (Int_t l=1; l<=nbinssigma; l++)
+      {
+        Double_t cont = hist->GetBinContent(k,l);
+        fHSigmaPixTheta->SetBinContent(j, k, l, cont);  
+      }
+
+    delete hist;
+    delete histMC;
+
+
+    //------------------------------------------------------------------
+    // define target distribution  'number of blind pixels per event'
+    ay = blindnthon->GetYaxis();
+    Int_t nbinsn = ay->GetNbins();
+
+    hist1    = fHBlindPixNThetaON->ProjectionY("", j, j, "");
+    hist1->SetName("dummy");
+    hist1MC  = fHBlindPixNThetaMC->ProjectionY("", j, j, "");
+
+    normON  = hist1->Integral();
+    normMC  = hist1MC->Integral();
+    if (normON  != 0.0) hist1->Scale(1.0/normON);
+    if (normMC != 0.0)  hist1MC->Scale(1.0/normMC);
+
+    // sum of ON and MC distributions
+    hist1->Add(hist1MC, 1.0); 
+    hist1->Scale( 1.0/hist1->Integral() );
+
+    for (Int_t k=1; k<=nbinsn; k++)
+      {
+        Double_t cont = hist1->GetBinContent(k);
+        fHBlindPixNTheta->SetBinContent(j, k, cont);  
+      }
+
+    delete hist1;
+    delete hist1MC;
+
+    //------------------------------------------------------------------
+    // define target distribution  'id of blind pixel'
+    ay = blindidthon->GetYaxis();
+    Int_t nbinsid = ay->GetNbins();
+
+    hist1    = fHBlindPixIdThetaON->ProjectionY("", j, j, "");
+    hist1->SetName("dummy");
+    hist1MC = fHBlindPixIdThetaMC->ProjectionY("", j, j, "");
+
+    // divide by the number of events (from fHBlindPixNTheta)
+    if (normON  != 0.0) hist1->Scale(1.0/normON);
+    if (normMC != 0.0)  hist1MC->Scale(1.0/normMC);
+
+    // sum of ON and MC distributions
+    hist1->Add(hist1MC, 1.0); 
+
+    for (Int_t k=1; k<=nbinsid; k++)
+      {
+        Double_t cont = hist1->GetBinContent(k);
+        fHBlindPixIdTheta->SetBinContent(j, k, cont);  
+      }
+
+    delete hist1;
+    delete hist1MC;
+  }
+  //............   end of new loop over Theta bins   ....................
+
+  *fLog << all 
+        << "MPad::MergeONMC(); The target distributions for the padding have been created" 
+        << endl;
+  *fLog << all << "----------------------------------------------------------" 
+        << endl;
+  //--------------------------------------------
+
+  fHSigmaThetaMC->SetDirectory(NULL);
+  fHSigmaThetaON->SetDirectory(NULL);
+
+  fHDiffPixThetaMC->SetDirectory(NULL);
+  fHDiffPixThetaON->SetDirectory(NULL);
+
+  fHSigmaPixThetaMC->SetDirectory(NULL);
+  fHSigmaPixThetaON->SetDirectory(NULL);
+
+  fHBlindPixIdThetaMC->SetDirectory(NULL);
+  fHBlindPixIdThetaON->SetDirectory(NULL);
+
+  fHBlindPixNThetaMC->SetDirectory(NULL);
+  fHBlindPixNThetaON->SetDirectory(NULL);
+
+  fHgMC->SetDirectory(NULL);
+  fHgON->SetDirectory(NULL);
+
+  return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Read padding distributions from a file
+//
+//
+Bool_t MPad::ReadPaddingDist(const char* namefilein)
+{
+  *fLog << all << "MPad : Read padding histograms from file " 
+        << namefilein << endl;
+
+  fInfile = new TFile(namefilein);
+  fInfile->ls();
+
+    //------------------------------------
+      fHSigmaThetaMC = 
+      (TH2D*) gROOT->FindObject("2D-ThetaSigmabarMC");
+      if (!fHSigmaThetaMC)
+	{
+          *fLog << all 
+                << "MPad : Object '2D-ThetaSigmabarMC' not found on root file" 
+                << endl;
+          return kFALSE;
+	}
+      *fLog << all 
+            << "MPad : Object '2D-ThetaSigmabarMC' was read in" << endl;
+
+      fHSigmaThetaON = 
+      (TH2D*) gROOT->FindObject("2D-ThetaSigmabarON");
+      if (!fHSigmaThetaON)
+	{
+          *fLog << all 
+                << "MPad : Object '2D-ThetaSigmabarON' not found on root file" 
+                << endl;
+          return kFALSE;
+	}
+      *fLog << all 
+            << "MPad : Object '2D-ThetaSigmabarON' was read in" << endl;
+
+      fHSigmaThetaOFF = 
+      (TH2D*) gROOT->FindObject("2D-ThetaSigmabarOFF");
+      if (!fHSigmaThetaOFF)
+	{
+          *fLog << all 
+                << "MPad : Object '2D-ThetaSigmabarOFF' not found on root file" 
+                << endl;
+          return kFALSE;
+	}
+      *fLog << all 
+            << "MPad:Object '2D-ThetaSigmabarOFF' was read in" << endl;
+
+    //------------------------------------
+      fHDiffPixTheta = 
+      (TH3D*) gROOT->FindObject("3D-ThetaPixDiff");
+      if (!fHDiffPixTheta)
+	{
+          *fLog << all 
+                << "MPad : Object '3D-ThetaPixDiff' not found on root file" 
+                << endl;
+          return kFALSE;
+	}
+      *fLog << all 
+            << "MPad : Object '3D-ThetaPixDiff' was read in" << endl;
+
+      fHDiffPixThetaMC = 
+      (TH3D*) gROOT->FindObject("3D-ThetaPixDiffMC");
+      if (!fHDiffPixThetaMC)
+	{
+          *fLog << all 
+                << "MPad : Object '3D-ThetaPixDiffMC' not found on root file" 
+                << endl;
+          return kFALSE;
+	}
+      *fLog << all 
+            << "MPad : Object '3D-ThetaPixDiffMC' was read in" << endl;
+
+      fHDiffPixThetaON = 
+      (TH3D*) gROOT->FindObject("3D-ThetaPixDiffON");
+      if (!fHDiffPixThetaON)
+	{
+          *fLog << all 
+                << "MPad : Object '3D-ThetaPixDiffON' not found on root file" 
+                << endl;
+          return kFALSE;
+	}
+      *fLog << all 
+            << "MPad : Object '3D-ThetaPixDiffON' was read in" << endl;
+
+      fHDiffPixThetaOFF = 
+      (TH3D*) gROOT->FindObject("3D-ThetaPixDiffOFF");
+      if (!fHDiffPixThetaOFF)
+	{
+          *fLog << all 
+                << "MPad : Object '3D-ThetaPixDiffOFF' not found on root file" 
+                << endl;
+          return kFALSE;
+	}
+      *fLog << all 
+            << "MPad : Object '3D-ThetaPixDiffOFF' was read in" << endl;
+
+
+    //------------------------------------
+       fHSigmaPixTheta = 
+      (TH3D*) gROOT->FindObject("3D-ThetaPixSigma");
+      if (!fHSigmaPixTheta)
+	{
+          *fLog << all 
+                << "MPad : Object '3D-ThetaPixSigma' not found on root file" 
+                << endl;
+          return kFALSE;
+	}
+      *fLog << all 
+            << "MPad : Object '3D-ThetaPixSigma' was read in" << endl;
+
+       fHSigmaPixThetaMC = 
+      (TH3D*) gROOT->FindObject("3D-ThetaPixSigmaMC");
+      if (!fHSigmaPixThetaMC)
+	{
+          *fLog << all 
+                << "MPad : Object '3D-ThetaPixSigmaMC' not found on root file" 
+                << endl;
+          return kFALSE;
+	}
+      *fLog << all 
+            << "MPad : Object '3D-ThetaPixSigmaMC' was read in" << endl;
+
+      fHSigmaPixThetaON = 
+      (TH3D*) gROOT->FindObject("3D-ThetaPixSigmaON");
+      if (!fHSigmaPixThetaON)
+	{
+          *fLog << all 
+                << "MPad : Object '3D-ThetaPixSigmaON' not found on root file" 
+                << endl;
+          return kFALSE;
+	}
+      *fLog << all 
+            << "MPad : Object '3D-ThetaPixSigmaON' was read in" << endl;
+
+      fHSigmaPixThetaOFF = 
+      (TH3D*) gROOT->FindObject("3D-ThetaPixSigmaOFF");
+      if (!fHSigmaPixThetaOFF)
+	{
+          *fLog << all 
+                << "MPad : Object '3D-ThetaPixSigmaOFF' not found on root file" 
+                << endl;
+          return kFALSE;
+	}
+      *fLog << all 
+            << "MPad : Object '3D-ThetaPixSigmaOFF' was read in" << endl;
+
+    //------------------------------------
+      fHgMC = 
+      (TH3D*) gROOT->FindObject("3D-PaddingMatrixMC");
+      if (!fHgMC)
+	{
+          *fLog << all 
+                << "MPad : Object '3D-PaddingMatrixMC' not found on root file" 
+                << endl;
+          return kFALSE;
+	}
+      *fLog << all 
+            << "MPad : Object '3D-PaddingMatrixMC' was read in" << endl;
+
+      fHgON = 
+      (TH3D*) gROOT->FindObject("3D-PaddingMatrixON");
+      if (!fHgON)
+	{
+          *fLog << all 
+                << "MPad : Object '3D-PaddingMatrixON' not found on root file" 
+                << endl;
+          return kFALSE;
+	}
+      *fLog << all 
+            << "MPad : Object '3D-PaddingMatrixON' was read in" << endl;
+
+      fHgOFF = 
+      (TH3D*) gROOT->FindObject("3D-PaddingMatrixOFF");
+      if (!fHgOFF)
+	{
+          *fLog << all 
+                << "MPad : Object '3D-PaddingMatrixOFF' not found on root file"
+                << endl;
+          return kFALSE;
+	}
+      *fLog << all 
+            << "MPad : Object '3D-PaddingMatrixOFF' was read in" << endl;
+
+    //------------------------------------
+      fHBlindPixIdThetaMC = 
+      (TH2D*) gROOT->FindObject("2D-ThetaBlindIdMC");
+      if (!fHBlindPixIdThetaMC)
+	{
+          *fLog << all 
+                << "MPad : Object '2D-ThetaBlindIdMC' not found on root file" 
+                << endl;
+          return kFALSE;
+	}
+      *fLog << all 
+            << "MPad : Object '2D-ThetaBlindIdMC' was read in" << endl;
+
+      fHBlindPixIdThetaON = 
+      (TH2D*) gROOT->FindObject("2D-ThetaBlindIdON");
+      if (!fHBlindPixIdThetaON)
+	{
+          *fLog << all 
+                << "MPad : Object '2D-ThetaBlindIdON' not found on root file" 
+                << endl;
+          return kFALSE;
+	}
+      *fLog << all 
+            << "MPad : Object '2D-ThetaBlindIdON' was read in" << endl;
+
+      fHBlindPixIdThetaOFF = 
+      (TH2D*) gROOT->FindObject("2D-ThetaBlindIdOFF");
+      if (!fHBlindPixIdThetaOFF)
+	{
+          *fLog << all 
+                << "MPad : Object '2D-ThetaBlindIdOFF' not found on root file" 
+                << endl;
+          return kFALSE;
+	}
+      *fLog << all 
+            << "MPad : Object '2D-ThetaBlindIdMC' was read in" << endl;
+
+    //------------------------------------
+      fHBlindPixNThetaMC = 
+      (TH2D*) gROOT->FindObject("2D-ThetaBlindNMC");
+      if (!fHBlindPixNThetaMC)
+	{
+          *fLog << all 
+                << "MPad : Object '2D-ThetaBlindNMC' not found on root file" 
+                << endl;
+          return kFALSE;
+	}
+      *fLog << all 
+            << "MPad : Object '2D-ThetaBlindNMC' was read in" << endl;
+
+      fHBlindPixNThetaON = 
+      (TH2D*) gROOT->FindObject("2D-ThetaBlindNON");
+      if (!fHBlindPixNThetaON)
+	{
+          *fLog << all 
+                << "MPad : Object '2D-ThetaBlindNON' not found on root file" 
+                << endl;
+          return kFALSE;
+	}
+      *fLog << all 
+            << "MPad : Object '2D-ThetaBlindNON' was read in" << endl;
+
+      fHBlindPixNThetaOFF = 
+      (TH2D*) gROOT->FindObject("2D-ThetaBlindNOFF");
+      if (!fHBlindPixNThetaOFF)
+	{
+          *fLog << all 
+                << "MPad : Object '2D-ThetaBlindNOFF' not found on root file" 
+                << endl;
+          return kFALSE;
+	}
+      *fLog << all 
+            << "MPad : Object '2D-ThetaBlindNOFF' was read in" << endl;
+
+    //------------------------------------
+
+  return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Write padding distributions onto a file
+//
+//
+Bool_t MPad::WritePaddingDist(const char* namefileout)
+{
+  *fLog << all << "MPad : Write padding histograms onto file " 
+        << namefileout << endl;
+
+  TFile outfile(namefileout, "RECREATE");
+
+  fHBlindPixNThetaMC->Write();
+  fHBlindPixNThetaON->Write();
+  fHBlindPixNThetaOFF->Write();
+
+  fHBlindPixIdThetaMC->Write();
+  fHBlindPixIdThetaON->Write();
+  fHBlindPixIdThetaOFF->Write();
+
+  fHSigmaThetaMC->Write();
+  fHSigmaThetaON->Write();
+  fHSigmaThetaOFF->Write();
+
+  fHDiffPixTheta->Write();
+  fHDiffPixThetaMC->Write();
+  fHDiffPixThetaON->Write();
+  fHDiffPixThetaOFF->Write();
+
+  fHSigmaPixTheta->Write();
+  fHSigmaPixThetaMC->Write();
+  fHSigmaPixThetaON->Write();
+  fHSigmaPixThetaOFF->Write();
+
+  fHgMC->Write();
+  fHgON->Write();
+  fHgOFF->Write();
+
+  *fLog << all 
+        << "MPad::WriteTargetDist(); padding histograms written onto file "
+        << namefileout << endl;
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Set type of data to be padded
+//
+//     this is not necessary if the type of the data can be recognized
+//     directly from the input
+//
+//
+void MPad::SetDataType(const char* type)
+{
+  fType = type;
+  *fLog << all << "MPad::SetDataType(); type of data to be padded : " 
+        << fType << endl; 
+
+  return;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Set the pointers and prepare the histograms
+//
+Int_t MPad::PreProcess(MParList *pList)
+{
+  if ( !fHSigmaThetaMC     || !fHSigmaThetaON     || !fHSigmaThetaOFF      ||  
+       !fHDiffPixThetaMC   || !fHDiffPixThetaON   || !fHDiffPixThetaOFF    ||
+       !fHBlindPixIdThetaMC|| !fHBlindPixIdThetaON|| !fHBlindPixIdThetaOFF ||
+       !fHBlindPixNThetaMC || !fHBlindPixNThetaON || !fHBlindPixNThetaOFF  ||
+       !fHgMC              || !fHgON              || !fHgOFF                 )
+  { 
+       *fLog << err 
+             << "MPad : At least one of the histograms needed for the padding is not defined ... aborting." 
+             << endl;
+       return kFALSE;
+  }
+
+  fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
+  if (!fMcEvt)
+    {
+       *fLog << err << dbginf << "MPad : MMcEvt not found... aborting." 
+             << endl;
+       return kFALSE;
+     }
+  
+   fPed = (MPedPhotCam*)pList->FindObject("MPedPhotCam");
+   if (!fPed)
+     {
+       *fLog << err << "MPad : MPedPhotCam not found... aborting." 
+             << endl;
+       return kFALSE;
+     }
+
+   fCam = (MGeomCam*)pList->FindObject("MGeomCam");
+   if (!fCam)
+     {
+       *fLog << err 
+             << "MPad : MGeomCam not found (no geometry information available)... aborting." 
+             << endl;
+       return kFALSE;
+     }
+  
+   fEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
+   if (!fEvt)
+     {
+       *fLog << err << "MPad : MCerPhotEvt not found... aborting." 
+             << endl;
+       return kFALSE;
+     }
+
+   fSigmabar = (MSigmabar*)pList->FindCreateObj("MSigmabar");
+   if (!fSigmabar)
+     {
+       *fLog << err << "MPad : MSigmabar not found... aborting." << endl;
+       return kFALSE;
+     }
+
+   fBlinds = (MBlindPixels*)pList->FindCreateObj("MBlindPixels");
+   if (!fBlinds)
+     {
+       *fLog << err << "MPad : MBlindPixels not found... aborting." 
+             << endl;
+       return kFALSE;
+     }
+   
+   if (fType !="ON"  &&  fType !="OFF"  &&  fType !="MC")
+     {
+       *fLog << err 
+             << "MPad : Type of data to be padded not defined... aborting." 
+             << endl;
+       return kFALSE;
+     }
+
+
+   //--------------------------------------------------------------------
+   // histograms for checking the padding
+   //
+   // plot pedestal sigmas
+   fHSigmaPedestal = new TH2D("SigPed","Sigma: after vs. before padding", 
+                     100, 0.0, 5.0, 100, 0.0, 5.0);
+   fHSigmaPedestal->SetXTitle("Pedestal sigma before padding");
+   fHSigmaPedestal->SetYTitle("Pedestal sigma after padding");
+
+   // plot no.of photons (before vs. after padding) 
+   fHPhotons = new TH2D("Photons","Photons: after vs.before padding", 
+                        100, -10.0, 90.0, 100, -10, 90);
+   fHPhotons->SetXTitle("no.of photons before padding");
+   fHPhotons->SetYTitle("no.of photons after padding");
+
+   // plot of added NSB
+   fHNSB = new TH1D("NSB","Distribution of added NSB", 100, -10.0, 10.0);
+   fHNSB->SetXTitle("no.of added NSB photons");
+   fHNSB->SetYTitle("no.of pixels");
+
+
+   //--------------------------------------------------------------------
+
+   fIter = 20;
+
+   memset(fErrors,   0, sizeof(fErrors));
+   memset(fWarnings, 0, sizeof(fWarnings));
+
+   return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Do the Padding (noise adjustment)
+//
+// input for the padding : 
+//  - the matrices fHgON, fHgOFF, fHgMC
+//  - the original distributions fHBlindPixNTheta, fHBlindPixIdTheta
+//                               fHSigmaTheta, fHDiffPixTheta
+//
+
+Int_t MPad::Process()
+{
+  *fLog << all << "Entry MPad::Process();" << endl;
+
+  // this is the conversion factor from the number of photons
+  //                                 to the number of photo electrons
+  // later to be taken from MCalibration
+  // fPEperPhoton = PW * LG * QE * 1D
+  Double_t fPEperPhoton = 0.95 * 0.90 * 0.13 * 0.9;
+
+  //------------------------------------------------
+  // add pixels to MCerPhotEvt which are not yet in;
+  // set their number of photons equal to zero
+
+  UInt_t imaxnumpix = fCam->GetNumPixels();
+
+  for (UInt_t i=0; i<imaxnumpix; i++)
+  {
+    Bool_t alreadythere = kFALSE;
+    UInt_t npix = fEvt->GetNumPixels();
+    for (UInt_t j=0; j<npix; j++)
+    {
+      MCerPhotPix &pix = (*fEvt)[j];
+      UInt_t id = pix.GetPixId();
+      if (i==id)
+      {
+        alreadythere = kTRUE;
+        break;
+      }
+    }
+    if (alreadythere)
+      continue;
+
+    fEvt->AddPixel(i, 0.0, (*fPed)[i].GetRms());
+  }
+
+
+
+  //-----------------------------------------
+  Int_t rc=0;
+  Int_t rw=0;
+
+  const UInt_t npix = fEvt->GetNumPixels();
+
+  //-------------------------------------------
+  // Calculate average sigma of the event
+  //
+  Double_t sigbarold_phot = fSigmabar->Calc(*fCam, *fPed, *fEvt);
+  *fLog << all << "MPad::Process(); before padding : " << endl;
+  fSigmabar->Print("");
+  Double_t sigbarold  = sigbarold_phot * fPEperPhoton;
+  Double_t sigbarold2 = sigbarold*sigbarold;
+
+  const Double_t theta = kRad2Deg*fMcEvt->GetTelescopeTheta();
+  *fLog << all << "theta = " << theta << endl;
+
+  Int_t binTheta = fHBlindPixNTheta->GetXaxis()->FindBin(theta);
+  if ( binTheta < 1  ||  binTheta > fHBlindPixNTheta->GetNbinsX() )
+  {
+    *fLog << warn 
+          << "MPad::Process(); binNumber out of range : theta, binTheta = "
+          << theta << ",  " << binTheta << ";  Skip event " << endl;
+    // event cannot be padded; skip event
+
+    rc = 2;
+    fErrors[rc]++;
+    return kCONTINUE;
+  }
+
+  //-------------------------------------------
+  // get number of events in this theta bin
+  // and number of events in this sigbarold_phot bin
+
+  Double_t nTheta;
+  Double_t nSigma;
+
+  TH2D *st = NULL;
+  if      (fType == "MC")  st = fHSigmaThetaMC;
+  else if (fType == "ON")  st = fHSigmaThetaON;
+  else if (fType == "OFF") st = fHSigmaThetaOFF;
+  else
+  {
+    *fLog << err << "MPad : illegal data type '" << fType 
+          <<  "'" << endl;
+    return kERROR;  
+  }
+
+  TH1D *hn;
+  hn = st->ProjectionY("", binTheta, binTheta, "");
+  nTheta = hn->Integral();
+  Int_t binSigma = hn->FindBin(sigbarold_phot);
+  nSigma = hn->GetBinContent(binSigma);
+
+   *fLog << all           
+         << "Theta, sigbarold_phot, binTheta, binSigma, nTheta, nSigma = "
+         << theta << ",  " << sigbarold_phot << ",  " << binTheta << ",  "
+         << binSigma << ",  " << nTheta << ",  " << nSigma   << endl;      
+
+  delete hn;
+  
+
+  //-------------------------------------------
+  // for the current theta :
+  //     generate blind pixels according to the histograms 
+  //     fHBlindPixNTheta and fHBlindPixIDTheta
+  //
+  // ON  : add the blind pixels from the OFF data
+  // OFF : add the blind pixels from the ON data
+  // MC  : add the blind pixels from the ON and OFF data
+
+  //-----------------------------------
+  if (fType == "ON"  ||  fType == "MC")
+  {
+    // numBlind is the number of blind pixels in an event
+    TH1D *nblind;
+    UInt_t numBlind;
+
+    nblind = fHBlindPixNThetaOFF->ProjectionY("", binTheta, binTheta, "");
+    if ( nblind->Integral() == 0.0 )
+    {
+      *fLog << warn << "MPad::Process(); projection for Theta bin " 
+            << binTheta << " has no entries; Skip event " << endl;
+      // event cannot be padded; skip event
+      delete nblind;
+
+      rc = 7;
+      fErrors[rc]++;
+      return kCONTINUE;
+    }
+    else
+    {
+      numBlind = (Int_t) (nblind->GetRandom()+0.5);
+    }
+    delete nblind;
+
+
+    // throw the Id of numBlind different pixels in this event
+    if ( numBlind > 0)
+    {
+      TH1D *hblind;
+      UInt_t idBlind;
+      UInt_t listId[npix];
+      UInt_t nlist = 0;
+      Bool_t equal;
+
+      hblind = fHBlindPixIdThetaOFF->ProjectionY("", binTheta, binTheta, "");
+      if ( hblind->Integral() > 0.0 )
+        for (UInt_t i=0; i<numBlind; i++)
+        {
+          while(1)
+          {
+            idBlind = (Int_t) (hblind->GetRandom()+0.5);
+            equal = kFALSE;
+            for (UInt_t j=0; j<nlist; j++)
+              if (idBlind == listId[j])
+  	      { 
+                equal = kTRUE;
+                break;
+	      }
+            if (!equal) break;
+          }
+          listId[nlist] = idBlind;
+          nlist++;
+
+          fBlinds->SetPixelBlind(idBlind);
+          *fLog << all << "idBlind = " << idBlind << endl;
+        }
+      fBlinds->SetReadyToSave();
+
+      delete hblind;
+    }
+  }
+
+  //------------------------------------
+  if (fType == "OFF"  ||  fType == "MC")
+  {
+    // throw numBlind;
+    // numBlind is the number of blind pixels in an event
+    TH1D *nblind;
+    UInt_t numBlind;
+
+    nblind = fHBlindPixNThetaON->ProjectionY("", binTheta, binTheta, "");
+    if ( nblind->Integral() == 0.0 )
+    {
+      *fLog << warn << "MPad::Process(); projection for Theta bin " 
+            << binTheta << " has no entries; Skip event " << endl;
+      // event cannot be padded; skip event
+      delete nblind;
+
+      rc = 7;
+      fErrors[rc]++;
+      return kCONTINUE;
+    }
+    else
+    {
+      numBlind = (Int_t) (nblind->GetRandom()+0.5);
+    }
+    delete nblind;
+
+
+    // throw the Id of numBlind different pixels in this event
+    if ( numBlind > 0)
+    {
+      TH1D *hblind;
+      UInt_t idBlind;
+      UInt_t listId[npix];
+      UInt_t nlist = 0;
+      Bool_t equal;
+
+      hblind = fHBlindPixIdThetaON->ProjectionY("", binTheta, binTheta, "");
+      if ( hblind->Integral() > 0.0 )
+        for (UInt_t i=0; i<numBlind; i++)
+        {
+          while(1)
+          {
+            idBlind = (Int_t) (hblind->GetRandom()+0.5);
+            equal = kFALSE;
+            for (UInt_t j=0; j<nlist; j++)
+              if (idBlind == listId[j])
+  	      { 
+                equal = kTRUE;
+                break;
+	      }
+            if (!equal) break;
+          }
+          listId[nlist] = idBlind;
+          nlist++;
+
+          fBlinds->SetPixelBlind(idBlind);
+          *fLog << all << "idBlind = " << idBlind << endl;
+        }
+      fBlinds->SetReadyToSave();
+
+      delete hblind;
+    }
+  }
+
+  //******************************************************************
+  // has the event to be padded ?
+  // if yes : to which sigmabar should it be padded ?
+  //
+
+  Int_t binSig = fHgON->GetYaxis()->FindBin(sigbarold_phot);
+  *fLog << all << "binSig, sigbarold_phot = " << binSig << ",  " 
+          << sigbarold_phot << endl;
+
+  Double_t prob;
+  TH1D *hpad = NULL;
+
+  TH3D *Hg = NULL;
+  if      (fType == "MC")  Hg = fHgMC;
+  else if (fType == "ON")  Hg = fHgON;
+  else if (fType == "OFF") Hg = fHgOFF;
+  else
+  {
+    *fLog << err << "MPad : illegal type of data '" << fType << "'"
+          << endl;
+    return kERROR;
+  }
+
+  hpad = Hg->ProjectionZ("zON", binTheta, binTheta, binSig, binSig, "");
+
+  //Int_t nb = hpad->GetNbinsX();
+  //for (Int_t i=1; i<=nb; i++)
+  //{
+  //  if (hpad->GetBinContent(i) != 0.0)
+  //    *fLog << all << "i, fHgON = " << i << ",  " 
+  //          << hpad->GetBinContent(i) << endl;
+  //}
+
+  if (nSigma != 0.0)
+    prob = hpad->Integral() * nTheta/nSigma;
+  else
+    prob = 0.0;
+
+   *fLog << all << "nTheta, nSigma, prob = " << nTheta << ",  " << nSigma 
+         << ",  " << prob << endl;
+
+  if ( prob <= 0.0  ||  gRandom->Uniform() > prob )
+  {
+    delete hpad;
+    // event should not be padded
+    *fLog << all << "event is not padded" << endl;
+
+    rc = 8;
+    fErrors[rc]++;
+    return kTRUE;
+  }
+  // event should be padded
+  *fLog << all << "event will be padded" << endl;  
+
+
+  //-------------------------------------------
+  // for the current theta, generate a sigmabar :
+  //     for MC/ON/OFF data according to the matrix fHgMC/ON/OFF
+  //
+  Double_t sigmabar_phot = 0;
+  Double_t sigmabar      = 0;
+
+  
+  //Int_t nbinsx = hpad->GetNbinsX();
+  //for (Int_t i=1; i<=nbinsx; i++)
+  //{
+  //  if (hpad->GetBinContent(i) != 0.0)
+  //    *fLog << all << "i, fHg = " << i << ",  " << hpad->GetBinContent(i) 
+  //          << endl;
+  //}
+
+  sigmabar_phot = hpad->GetRandom();
+  sigmabar = sigmabar_phot * fPEperPhoton;
+
+  *fLog << all << "sigmabar_phot = " << sigmabar_phot << endl;
+
+  delete hpad;
+  
+  const Double_t sigmabar2 = sigmabar*sigmabar;
+
+  //-------------------------------------------
+
+  *fLog << all << "MPad::Process(); sigbarold, sigmabar = " 
+        << sigbarold << ",  "<< sigmabar << endl;
+
+  // Skip event if target sigmabar is <= sigbarold
+  if (sigmabar <= sigbarold)
+  {
+    *fLog << all << "MPad::Process(); target sigmabar is less than sigbarold : "
+          << sigmabar << ",  " << sigbarold << ",   Skip event" << endl;
+
+    rc = 4;
+    fErrors[rc]++;
+    return kCONTINUE;     
+  }
+
+
+  //-------------------------------------------
+  //
+  // Calculate average number of NSB photo electrons to be added (lambdabar)
+  // from the value of sigmabar, 
+  //  - making assumptions about the average electronic noise (elNoise2) and
+  //  - using a fixed value (F2excess)  for the excess noise factor
+  
+  Double_t elNoise2;         // [photo electrons]  
+  Double_t F2excess  = 1.3;
+  Double_t lambdabar;        // [photo electrons]
+
+
+  Int_t bincheck = fHDiffPixTheta->GetXaxis()->FindBin(theta);
+  if (binTheta != bincheck)
+  {
+    *fLog << err 
+          << "MPad::Process(); The binnings of the 2 histograms are not identical; aborting"
+          << endl;
+    return kERROR;
+  }
+
+  // Get RMS of (Sigma^2-sigmabar^2) in this Theta bin.
+  // The average electronic noise (to be added) has to be well above this RMS,
+  // otherwise the electronic noise of an individual pixel (elNoise2Pix)
+  // may become negative
+
+  TH1D *hnoise;
+  if (fType == "MC")
+    hnoise = fHDiffPixTheta->ProjectionZ("", binTheta, binTheta, 0, 9999, "");
+  else if (fType == "ON")
+    hnoise = fHDiffPixThetaOFF->ProjectionZ("", binTheta, binTheta, 0, 9999, "");
+  else if (fType == "OFF")
+    hnoise = fHDiffPixThetaON->ProjectionZ("", binTheta, binTheta, 0, 9999, "");
+  else
+  {
+    *fLog << err << "MPad::Process(); illegal data type... aborting" 
+          << endl;
+    return kERROR;
+  }
+
+  Double_t RMS_phot = hnoise->GetRMS(1);  
+  Double_t RMS = RMS_phot * fPEperPhoton * fPEperPhoton;
+  delete hnoise;
+
+  elNoise2 = TMath::Min(RMS,  sigmabar2 - sigbarold2);
+  *fLog << all << "elNoise2 = " << elNoise2 << endl; 
+
+  lambdabar = (sigmabar2 - sigbarold2 - elNoise2) / F2excess;  
+
+  // This value of lambdabar is the same for all pixels;
+  // note that lambdabar is normalized to the area of pixel 0
+
+  //----------   start loop over pixels   ---------------------------------
+  // do the padding for each pixel
+  //
+  // pad only pixels   - which are used (before image cleaning)
+  //
+
+  Double_t sigma2      = 0;
+
+  Double_t diff_phot   = 0;
+  Double_t diff        = 0;
+
+  Double_t addSig2_phot= 0;
+  Double_t addSig2     = 0;
+
+  Double_t elNoise2Pix = 0;
+
+
+  for (UInt_t i=0; i<npix; i++) 
+  {   
+    MCerPhotPix &pix = (*fEvt)[i];
+    if ( !pix.IsPixelUsed() )
+      continue;
+
+    //if ( pix.GetNumPhotons() == 0.0)
+    //{
+    //  *fLog << warn 
+    //        << "MPad::Process(); no.of photons is 0 for used pixel" 
+    //        << endl;
+    //  continue;
+    //}
+
+    Int_t j = pix.GetPixId();
+
+    // GetPixRatio returns (area of pixel 0 / area of current pixel)
+    Double_t ratioArea = 1.0 / fCam->GetPixRatio(j);
+
+    MPedPhotPix &ppix = (*fPed)[j];
+    Double_t oldsigma_phot = ppix.GetRms();
+    Double_t oldsigma = oldsigma_phot * fPEperPhoton;
+    Double_t oldsigma2 = oldsigma*oldsigma;
+
+    //---------------------------------
+    // throw the Sigma for this pixel 
+    //
+    Int_t binPixel = fHDiffPixTheta->GetYaxis()->FindBin( (Double_t)j );
+
+    Int_t count;
+    Bool_t ok;
+
+    TH1D *hdiff;
+
+    // throw the Sigma for this pixel from the distribution fHDiffPixTheta
+    // MC  : from fHDiffPixTheta
+    // ON  : from fHDiffPixThetaOFF
+    // OFF : from fHDiffPixThetaON
+
+    TH3D *sp = NULL;
+
+    if      (fType == "MC")  sp = fHDiffPixTheta;
+    else if (fType == "ON")  sp = fHDiffPixThetaOFF;
+    else if (fType == "OFF") sp = fHDiffPixThetaON;
+    else
+    {
+      *fLog << err << "MPad::Process(); illegal data type... aborting" 
+            << endl;
+      return kERROR;
+    }
+
+    hdiff = sp->ProjectionZ("", binTheta, binTheta,
+                                binPixel, binPixel, "");
+
+    if ( hdiff->GetEntries() == 0 )
+    {
+      *fLog << warn << "MPad::Process(); projection for Theta bin " 
+            << binTheta << "  and pixel bin " << binPixel  
+            << " has no entries;  aborting " << endl;
+      delete hdiff;
+
+      rc = 5;
+      fErrors[rc]++;
+      return kCONTINUE;     
+    }
+
+    count = 0;
+    ok = kFALSE;
+    for (Int_t m=0; m<fIter; m++)
+    {
+      count += 1;
+      diff_phot = hdiff->GetRandom();
+      diff = diff_phot * fPEperPhoton * fPEperPhoton;
+ 
+     // the following condition ensures that elNoise2Pix > 0.0 
+      if ( (diff + sigmabar2 - oldsigma2/ratioArea
+                               - lambdabar*F2excess) > 0.0 )
+      {
+        ok = kTRUE;
+        break;
+      }
+    }
+
+    if (!ok)
+    {
+      *fLog << all << "theta, j, count, sigmabar, diff = " << theta 
+            << ",  " 
+            << j << ",  " << count << ",  " << sigmabar << ",  " 
+            << diff << endl;
+      diff = lambdabar*F2excess + oldsigma2/ratioArea - sigmabar2;
+
+      rw = 1;
+      fWarnings[rw]++;
+    }
+    else
+    {
+      rw = 0;
+      fWarnings[rw]++;
+    }
+
+    delete hdiff;
+    sigma2 = diff + sigmabar2;
+
+
+    //---------------------------------
+    // get the additional sigma^2 for this pixel (due to the padding)
+
+    addSig2 = sigma2*ratioArea - oldsigma2;
+    addSig2_phot = addSig2 / (fPEperPhoton * fPEperPhoton);
+
+    //---------------------------------
+    // get the additional electronic noise for this pixel
+
+    elNoise2Pix = addSig2 - lambdabar*F2excess*ratioArea;
+
+
+    //---------------------------------
+    // throw actual number of additional NSB photo electrons (NSB)
+    //       and its RMS (sigmaNSB) 
+
+    Double_t NSB0 = gRandom->Poisson(lambdabar*ratioArea);
+    Double_t arg  = NSB0*(F2excess-1.0) + elNoise2Pix;
+    Double_t sigmaNSB0;
+
+    if (arg >= 0.0)
+    {
+      sigmaNSB0 = sqrt( arg );
+    }
+    else
+    {
+      sigmaNSB0 = 0.0000001;      
+      if (arg < -1.e-10)
+      {
+        *fLog << warn << "MPad::Process(); argument of sqrt < 0 : "
+              << arg << endl;
+      }
+    }
+
+
+    //---------------------------------
+    // smear NSB0 according to sigmaNSB0
+    // and subtract lambdabar because of AC coupling
+
+    Double_t NSB = gRandom->Gaus(NSB0, sigmaNSB0) - lambdabar*ratioArea;
+    Double_t NSB_phot = NSB / fPEperPhoton;
+
+    //---------------------------------
+ 
+    // add additional NSB to the number of photons
+    Double_t oldphotons_phot = pix.GetNumPhotons();
+    Double_t oldphotons = oldphotons_phot * fPEperPhoton;
+    Double_t newphotons = oldphotons + NSB;
+    Double_t newphotons_phot = newphotons / fPEperPhoton;    
+    pix.SetNumPhotons(	newphotons_phot );
+
+
+    fHNSB->Fill( NSB_phot/ratioArea );
+    fHPhotons->Fill( oldphotons_phot/ratioArea, 
+                     newphotons_phot/ratioArea );
+
+
+    // error: add sigma of padded noise quadratically
+    Double_t olderror_phot = pix.GetErrorPhot();
+    Double_t newerror_phot = 
+                           sqrt( olderror_phot*olderror_phot + addSig2_phot );
+    pix.SetErrorPhot( newerror_phot );
+
+
+    Double_t newsigma = sqrt( oldsigma2 + addSig2 ); 
+    Double_t newsigma_phot = newsigma / fPEperPhoton; 
+    ppix.SetRms( newsigma_phot );
+
+    fHSigmaPedestal->Fill( oldsigma_phot, newsigma_phot );
+  } 
+  //----------   end of loop over pixels   ---------------------------------
+
+  // Calculate sigmabar again and crosscheck
+
+  fSigmabar->Calc(*fCam, *fPed, *fEvt);
+  *fLog << all << "MPad::Process(); after padding : " << endl;
+  fSigmabar->Print("");
+
+  *fLog << all << "Exit MPad::Process();" << endl;
+
+  rc = 0;
+  fErrors[rc]++;
+  return kTRUE;
+  //******************************************************************
+}
+
+// --------------------------------------------------------------------------
+//
+//
+Int_t MPad::PostProcess()
+{
+    if (GetNumExecutions() != 0)
+    {
+
+    *fLog << inf << endl;
+    *fLog << GetDescriptor() << " execution statistics:" << endl;
+    *fLog << dec << setfill(' ');
+
+    int temp;
+    if (fWarnings[0] != 0.0)    
+      temp = (int)(fWarnings[1]*100/fWarnings[0]);
+    else
+      temp = 100;
+
+    *fLog << " " << setw(7) << fWarnings[1] << " (" << setw(3) 
+          << temp 
+          << "%) Warning : iteration to find acceptable sigma failed" 
+          << ", fIter = " << fIter << endl;
+
+    *fLog << " " << setw(7) << fErrors[1] << " (" << setw(3) 
+          << (int)(fErrors[1]*100/GetNumExecutions()) 
+          << "%) Evts skipped due to: Sigmabar_old > 0" << endl;
+
+    *fLog << " " << setw(7) << fErrors[2] << " (" << setw(3) 
+          << (int)(fErrors[2]*100/GetNumExecutions()) 
+          << "%) Evts skipped due to: Zenith angle out of range" << endl;
+
+    *fLog << " " << setw(7) << fErrors[3] << " (" << setw(3) 
+          << (int)(fErrors[3]*100/GetNumExecutions()) 
+          << "%) Evts skipped due to: No data for generating Sigmabar" << endl;
+
+    *fLog << " " << setw(7) << fErrors[4] << " (" << setw(3) 
+          << (int)(fErrors[4]*100/GetNumExecutions()) 
+          << "%) Evts skipped due to: Target sigma <= Sigmabar_old" << endl;
+
+    *fLog << " " << setw(7) << fErrors[5] << " (" << setw(3) 
+          << (int)(fErrors[5]*100/GetNumExecutions()) 
+          << "%) Evts skipped due to: No data for generating Sigma^2-Sigmabar^2" << endl;
+
+    *fLog << " " << setw(7) << fErrors[6] << " (" << setw(3) 
+          << (int)(fErrors[6]*100/GetNumExecutions()) 
+          << "%) Evts skipped due to: No data for generating Sigma" << endl;
+
+    *fLog << " " << setw(7) << fErrors[7] << " (" << setw(3) 
+          << (int)(fErrors[7]*100/GetNumExecutions()) 
+          << "%) Evts skipped due to: No data for generating Blind pixels" << endl;
+
+    *fLog << " " << setw(7) << fErrors[8] << " (" << setw(3) 
+          << (int)(fErrors[8]*100/GetNumExecutions()) 
+          << "%) Evts didn't have to be padded" << endl;
+
+    *fLog << " " << fErrors[0] << " (" 
+          << (int)(fErrors[0]*100/GetNumExecutions()) 
+          << "%) Evts were successfully padded!" << endl;
+    *fLog << endl;
+
+    }
+
+    //---------------------------------------------------------------
+    TCanvas &c = *(MH::MakeDefCanvas("Pad", "", 900, 1500)); 
+    c.Divide(3, 5);
+    gROOT->SetSelectedPad(NULL);
+
+    c.cd(1);
+    fHNSB->SetDirectory(NULL);
+    fHNSB->DrawCopy();
+    fHNSB->SetBit(kCanDelete);    
+
+    c.cd(2);
+    fHSigmaPedestal->SetDirectory(NULL);
+    fHSigmaPedestal->DrawCopy();
+    fHSigmaPedestal->SetBit(kCanDelete);    
+
+    c.cd(3);
+    fHPhotons->SetDirectory(NULL);
+    fHPhotons->DrawCopy();
+    fHPhotons->SetBit(kCanDelete);    
+
+    //--------------------------------------------------------------------
+
+
+    c.cd(4);
+    fHSigmaTheta->SetDirectory(NULL);
+    fHSigmaTheta->SetTitle("(Target) 2D : Sigmabar, \\Theta");
+    fHSigmaTheta->DrawCopy();     
+    fHSigmaTheta->SetBit(kCanDelete);     
+
+
+    //--------------------------------------------------------------------
+
+
+    c.cd(7);
+    fHBlindPixNTheta->SetDirectory(NULL);
+    fHBlindPixNTheta->SetTitle("(Target) 2D : no.of blind pixels, \\Theta");
+    fHBlindPixNTheta->DrawCopy();     
+    fHBlindPixNTheta->SetBit(kCanDelete);     
+
+    //--------------------------------------------------------------------
+
+
+    c.cd(10);
+    fHBlindPixIdTheta->SetDirectory(NULL);
+    fHBlindPixIdTheta->SetTitle("(Target) 2D : blind pixel Id, \\Theta");
+    fHBlindPixIdTheta->DrawCopy();     
+    fHBlindPixIdTheta->SetBit(kCanDelete);     
+
+
+    //--------------------------------------------------------------------
+    // draw the 3D histogram (target): Theta, pixel, Sigma^2-Sigmabar^2
+
+    c.cd(5);
+    TH2D *l1 = NULL;
+    l1 = (TH2D*) ((TH3*)fHDiffPixTheta)->Project3D("zx");
+    l1->SetDirectory(NULL);
+    l1->SetTitle("(Target) Sigma^2-Sigmabar^2 vs. \\Theta (all pixels)");
+    l1->SetXTitle("\\Theta [\\circ]");
+    l1->SetYTitle("Sigma^2-Sigmabar^2");
+
+    l1->DrawCopy("box");
+    l1->SetBit(kCanDelete);;
+
+    c.cd(8);
+    TH2D *l2 = NULL;
+    l2 = (TH2D*) ((TH3*)fHDiffPixTheta)->Project3D("zy");
+    l2->SetDirectory(NULL);
+    l2->SetTitle("(Target) Sigma^2-Sigmabar^2 vs. pixel number (all \\Theta)");
+    l2->SetXTitle("pixel");
+    l2->SetYTitle("Sigma^2-Sigmabar^2");
+
+    l2->DrawCopy("box");
+    l2->SetBit(kCanDelete);;
+
+    //--------------------------------------------------------------------
+    // draw the 3D histogram (target): Theta, pixel, Sigma
+
+    c.cd(6);
+    TH2D *k1 = NULL;
+    k1 = (TH2D*) ((TH3*)fHSigmaPixTheta)->Project3D("zx");
+    k1->SetDirectory(NULL);
+    k1->SetTitle("(Target) Sigma vs. \\Theta (all pixels)");
+    k1->SetXTitle("\\Theta [\\circ]");
+    k1->SetYTitle("Sigma");
+
+    k1->DrawCopy("box");
+    k1->SetBit(kCanDelete);
+
+    c.cd(9);
+    TH2D *k2 = NULL;
+    k2 = (TH2D*) ((TH3*)fHSigmaPixTheta)->Project3D("zy");
+    k2->SetDirectory(NULL);
+    k2->SetTitle("(Target) Sigma vs. pixel number (all \\Theta)");
+    k2->SetXTitle("pixel");
+    k2->SetYTitle("Sigma");
+
+    k2->DrawCopy("box");
+    k2->SetBit(kCanDelete);;
+
+
+    //--------------------------------------------------------------------
+
+    c.cd(13);
+    TH2D *m1;
+    m1 = (TH2D*) ((TH3*)fHgON)->Project3D("zy");
+    m1->SetDirectory(NULL);
+    m1->SetTitle("(Target) Sigmabar-new vs. Sigmabar-old (ON, all  \\Theta)");
+    m1->SetXTitle("Sigmabar-old");
+    m1->SetYTitle("Sigmabar-new");
+
+    m1->DrawCopy("box");
+    m1->SetBit(kCanDelete);;
+
+    c.cd(14);
+    TH2D *m2;
+    m2 = (TH2D*) ((TH3*)fHgOFF)->Project3D("zy");
+    m2->SetDirectory(NULL);
+    m2->SetTitle("(Target) Sigmabar-new vs. Sigmabar-old (OFF, all  \\Theta)");
+    m2->SetXTitle("Sigmabar-old");
+    m2->SetYTitle("Sigmabar-new");
+
+    m2->DrawCopy("box");
+    m2->SetBit(kCanDelete);;
+
+    c.cd(15);
+    TH2D *m3;
+    m3 = (TH2D*) ((TH3*)fHgMC)->Project3D("zy");
+    m3->SetDirectory(NULL);
+    m3->SetTitle("(Target) Sigmabar-new vs. Sigmabar-old (MC, all  \\Theta)");
+    m3->SetXTitle("Sigmabar-old");
+    m3->SetYTitle("Sigmabar-new");
+
+    m3->DrawCopy("box");
+    m3->SetBit(kCanDelete);;
+
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MPad.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MPad.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MPad.h	(revision 9661)
@@ -0,0 +1,131 @@
+#ifndef MARS_MPad
+#define MARS_MPad
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+class TH1D;
+class TH2D;
+class TH3D;
+
+class MGeomCam;
+class MCerPhotEvt;
+class MPedPhotCam;
+class MMcEvt;
+class MSigmabar;
+class MParList;
+class MBlindPixels;
+class MRead;
+class MFilterList;
+
+
+class MPad : public MTask
+{
+private:
+    MGeomCam       *fCam;
+    MCerPhotEvt    *fEvt; 
+    MSigmabar      *fSigmabar;
+    MMcEvt         *fMcEvt;
+    MPedPhotCam    *fPed;
+    MBlindPixels   *fBlinds;
+
+    TString        fType;           // type of data to be padded
+    TFile          *fInfile;        // input file containing padding histograms
+
+    Int_t          fIter;
+
+    Int_t          fErrors[9];
+    Int_t          fWarnings[2];
+
+    //----------------------------------
+    // plots used for the padding
+    // for all plots it is assumed that the pedestal RMS is given in units of "number of photons"
+    TH2D  *fHBlindPixIdTheta;    // 2D-histogram (blind pixel Id vs. Theta)
+    TH2D  *fHBlindPixIdThetaMC;  // 2D-histogram (blind pixel Id vs. Theta)
+    TH2D  *fHBlindPixIdThetaON;  // 2D-histogram (blind pixel Id vs. Theta)
+    TH2D  *fHBlindPixIdThetaOFF; // 2D-histogram (blind pixel Id vs. Theta)
+
+    //---------------------
+    TH2D  *fHBlindPixNTheta;    // 2D-histogram (no.of blind pixels vs. Theta)
+    TH2D  *fHBlindPixNThetaMC;  // 2D-histogram (no.of blind pixels vs. Theta)
+    TH2D  *fHBlindPixNThetaON;  // 2D-histogram (no.of blind pixels vs. Theta)
+    TH2D  *fHBlindPixNThetaOFF; // 2D-histogram (no.of blind pixels vs. Theta)
+
+    //---------------------
+    TH2D  *fHSigmaTheta;       // 2D-histogram (sigmabar vs. Theta)
+    TH2D  *fHSigmaThetaMC;     // 2D-histogram (sigmabar vs. Theta)
+    TH2D  *fHSigmaThetaON;     // 2D-histogram (sigmabar vs. Theta)
+    TH2D  *fHSigmaThetaOFF;    // 2D-histogram (sigmabar vs. Theta)
+
+    //---------------------
+    TH3D  *fHDiffPixTheta;     // 3D-histogram (Theta, pixel, sigma^2-sigmabar^2)
+    TH3D  *fHDiffPixThetaMC;   // 3D-histogram (Theta, pixel, sigma^2-sigmabar^2)
+    TH3D  *fHDiffPixThetaON;   // 3D-histogram (Theta, pixel, sigma^2-sigmabar^2)
+    TH3D  *fHDiffPixThetaOFF;  // 3D-histogram (Theta, pixel, sigma^2-sigmabar^2)
+
+    //---------------------
+    TH3D  *fHSigmaPixTheta;     // 3D-histogram (Theta, pixel, sigma)
+    TH3D  *fHSigmaPixThetaMC;   // 3D-histogram (Theta, pixel, sigma)
+    TH3D  *fHSigmaPixThetaON;   // 3D-histogram (Theta, pixel, sigma)
+    TH3D  *fHSigmaPixThetaOFF;  // 3D-histogram (Theta, pixel, sigma)
+
+    //---------------------
+    TH3D  *fHgMC;           // matrix (Theta, sigbarold, sigbarnew) for MC data
+    TH3D  *fHgON;           // matrix (Theta, sigbarold, sigbarnew) for ON data
+    TH3D  *fHgOFF;          // matrix (Theta, sigbarold, sigbarnew) for OFF data
+
+    //-------------------------------
+    // plots for checking the padding
+    TH2D  *fHSigmaPedestal; // 2D-histogram : pedestal sigma after
+                                     //                versus before padding
+    TH2D  *fHPhotons;       // 2D-histogram : no.of photons after
+                                     //                versus before padding
+    TH1D  *fHNSB;           // 1D-histogram : additional NSB
+
+
+    Bool_t Merge2Distributions(TH1D *hista, TH1D * histb, TH1D * histap,
+                               TH2D *fHga,  TH2D * fHgb, Int_t nbinssig);
+
+
+public:
+    MPad(const char *name=NULL, const char *title=NULL);
+    ~MPad();
+
+    Bool_t MergeONOFFMC(
+      TH2D *sigthmc,  TH3D *diffpixthmc, TH3D *sigmapixthmc,
+      TH2D *blindidthmc,  TH2D *blindnthmc,
+      TH2D *sigthon,  TH3D *diffpixthon, TH3D *sigmapixthon,
+      TH2D *blindidthon,  TH2D *blindnthon,
+      TH2D *sigthoff=NULL, TH3D *diffpixthoff=NULL,TH3D *sigmapixthoff=NULL,
+      TH2D *blindidthoff=NULL, TH2D *blindnthoff=NULL);
+
+    Bool_t MergeONMC(
+      TH2D *sigthmc,  TH3D *diffpixthmc, TH3D *sigmapixthmc,
+      TH2D *blindidthmc,  TH2D *blindnthmc,
+      TH2D *sigthon,  TH3D *diffpixthon, TH3D *sigmapixthon,
+      TH2D *blindidthon,  TH2D *blindnthon);
+
+    Bool_t ReadPaddingDist(const char *filein);
+    Bool_t WritePaddingDist(const char *fileout);
+
+    void SetDataType(const char *type);   // type of data to be padded
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
+    ClassDef(MPad, 0)    // task for the padding 
+}; 
+
+#endif
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MPadding.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MPadding.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MPadding.cc	(revision 9661)
@@ -0,0 +1,554 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Robert Wagner, 10/2002   <mailto:magicsoft@rwagner.de>
+!   Author(s): Wolfgang Wittek, 01/2003 <mailto:wittek@mppmu.mpg.de>
+!   Author(s): Thomas Bretz, 04/2003    <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//  MPadding                                                               //
+//  (developped from MApplyPadding)                                        //
+//                                                                         //
+//  This task applies padding to a given Sigmabar target value.            //
+//  The task checks whether the data stream it is applied to has to be     //
+//  padded or not and if so, Gaussian noise with the difference in Sigma   //
+//  is produced and added to the particular event. The number of photons,  // 
+//  its error and the pedestal sigmas are altered.                         //
+//                                                                         //
+//  The padding has to be done before the image cleaning because the       //
+//  image cleaning depends on the pedestal sigmas.                         //
+//                                                                         //
+//  There are several ways of defining the sigmabar value to which the     // 
+//  events are padded:                                                     //
+//                                                                         //
+//  1) Set a fixed level (fFixedSigmabar) by calling 'SetTargetLevel'.     //
+//                                                                         //
+//  2) By calling 'SetDefiningHistogram', give a TH1D histogram            //
+//     (fHSigmabarMax) which defines the Sigmabar as a function of Theta.  //
+//                                                                         //
+//  3) By calling 'SetSigmaThetaHist', give a TH2D histogram               //
+//     (fHSigmaTheta) which contains the Sigmabar distribution for the     //
+//     different bins in Theta. For a given event, the sigmabar value to   //
+//     be used for the padding is thrown from this distribution.           //
+//                                                                         //
+//  Workaround :                                                           //  
+//  If none of these options is specified then PreProcess will try to read // 
+//  in a propriety format ASCII database for the CT1 test. The name of     // 
+//  this file is set by 'SetDatabaseFile'. From the data in this file a    //
+//  TH1D histogram (fHSigmabarMax) is generated.                           //
+//                                                                         //
+//  This implementation is still PRELIMINARY and requires some workarounds //
+//  put in SPECIFICALLY FOR THE CT1 TESTS, since a database to access is   //
+//  missing. It is not the FINAL MAGIC VERSION.                            //
+//                                                                         //
+//  For random numbers gRandom is used.                                    //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MPadding.h"
+
+#include <stdio.h>
+
+#include <TH1.h>
+#include <TH2.h>
+#include <TH3.h>
+#include <TRandom.h>
+#include <TCanvas.h>
+#include <TProfile.h>
+
+#include "MH.h"
+#include "MBinning.h"
+
+#include "MSigmabar.h"
+
+#include "MMcEvt.hxx"
+
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MGeomCam.h"
+
+#include "MCerPhotEvt.h"
+#include "MCerPhotPix.h"
+
+#include "MPedPhotCam.h"
+#include "MPedPhotPix.h"
+
+ClassImp(MPadding);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+MPadding::MPadding(const char *name, const char *title)
+    : fRunType(0), fGroup(0), fFixedSigmabar(0), fHSigMaxAllocated(kFALSE), fHSigmabarMax(NULL), fHSigmaTheta(NULL)
+{
+    fName  = name  ? name  : "MPadding";
+    fTitle = title ? title : "Task for the padding";
+
+    //--------------------------------------------------------------------
+    // plot pedestal sigmas for testing purposes
+    fHSigmaPedestal = new TH2D("SigPed", "Padded vs orig. sigma",
+                               100, 0.0, 5.0, 100, 0.0, 5.0);
+   fHSigmaPedestal->SetXTitle("Orig. Pedestal sigma");
+   fHSigmaPedestal->SetYTitle("Padded Pedestal sigma");
+
+   // plot no.of photons (before vs. after padding) for testing purposes
+   fHPhotons = new TH2D("Photons", "Photons after vs.before padding",
+                        100, -10.0, 90.0, 100, -10, 90);
+   fHPhotons->SetXTitle("No.of photons before padding");
+   fHPhotons->SetYTitle("No.of photons after padding");
+
+   // plot of added NSB
+   fHNSB = new TH1D("NSB", "Distribution of added NSB", 100, -10.0, 10.0);
+   fHNSB->SetXTitle("No.of added NSB photons");
+   fHNSB->SetYTitle("No.of pixels");
+
+   fHSigmaOld = new TH2D;
+   fHSigmaOld->SetNameTitle("fHSigmaOld", "Sigma before padding");
+   fHSigmaOld->SetXTitle("Theta");
+   fHSigmaOld->SetYTitle("Sigma");
+
+   fHSigmaNew = new TH2D;
+   fHSigmaNew->SetNameTitle("fHSigmaNew", "Sigma after padding");
+   fHSigmaNew->SetXTitle("Theta");
+   fHSigmaNew->SetYTitle("Sigma");
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor. 
+//
+MPadding::~MPadding()
+{
+   delete fHSigmaPedestal;
+   delete fHPhotons;
+   delete fHNSB;
+   delete fHSigmaOld;
+   delete fHSigmaNew;
+   if (fHSigMaxAllocated && fHSigmabarMax)
+       delete fHSigmabarMax;
+}
+
+// --------------------------------------------------------------------------
+//
+// You can provide a TH1D* histogram containing 
+//     - the target Sigmabar in bins of theta. 
+// Be sure to use the same binning as for the analysis
+//
+Bool_t MPadding::SetDefiningHistogram(TH1D *histo)
+{
+    if (fHSigmabarMax)
+    {
+        *fLog << warn << "MPadding - SigmabarMax already set.";
+        return kFALSE;
+    }
+
+    fHSigmabarMax  = histo;
+
+    fFixedSigmabar = 0;
+    fHSigmaTheta   = NULL;
+
+    *fLog << inf << "MPadding - Use Defining Histogram.";
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// You can provide a TH2D* histogram containing 
+//     - the Sigmabar distribution in bins of theta. 
+//
+Bool_t MPadding::SetSigmaThetaHist(TH2D *histo)
+{
+    if (fHSigmaTheta)
+    {
+        *fLog << warn << "MPadding - SigmaTheta already set.";
+        return kFALSE;
+    }
+
+    fHSigmaTheta   = histo;
+
+    fFixedSigmabar = 0;
+    if (fHSigMaxAllocated)
+    {
+        fHSigMaxAllocated = kFALSE;
+        delete fHSigmabarMax;
+    }
+    fHSigmabarMax  = NULL;
+
+    *fLog << inf << "MPadding - Use Sigma Theta Histogram.";
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//
+void MPadding::SetTargetLevel(Double_t sigmabar)
+{
+    fFixedSigmabar = sigmabar;
+
+    fHSigmaTheta   = NULL;
+    if (fHSigMaxAllocated)
+    {
+        fHSigMaxAllocated = kFALSE;
+        delete fHSigmabarMax;
+    }
+    fHSigmabarMax = NULL;
+
+    *fLog << inf << "MPadding - Use fixed sigmabar: fFixedSigmabar = ";
+    *fLog << fFixedSigmabar << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+//  check if MEvtHeader exists in the Parameter list already.
+//  if not create one and add them to the list
+//
+Int_t MPadding::PreProcess(MParList *pList)
+{
+  fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
+  if (!fMcEvt)
+    {
+       *fLog << err << dbginf << "MMcEvt not found... aborting." << endl;
+       return kFALSE;
+     }
+  
+   fPed = (MPedPhotCam*)pList->FindObject("MPedPhotCam");
+   if (!fPed)
+     {
+       *fLog << err << dbginf << "MPedPhotCam not found... aborting." << endl;
+       return kFALSE;
+     }
+  
+   fCam = (MGeomCam*)pList->FindObject("MGeomCam");
+   if (!fCam)
+     {
+       *fLog << err << dbginf << "MGeomCam not found (no geometry information available)... aborting." << endl;
+       return kFALSE;
+     }
+  
+   fEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
+   if (!fEvt)
+     {
+       *fLog << err << dbginf << "MCerPhotEvt not found... aborting." << endl;
+       return kFALSE;
+     }
+
+   fSigmabar = (MSigmabar*)pList->FindCreateObj("MSigmabar");
+   if (!fSigmabar)
+     {
+       *fLog << err << dbginf << "MSigmabar not found... aborting." << endl;
+       return kFALSE;
+     }
+   
+   // Get Theta Binning  
+   MBinning* binstheta  = (MBinning*)pList->FindObject("BinningTheta");
+   if (!binstheta)
+     {
+       *fLog << err << dbginf << "BinningTheta not found... aborting." << endl;
+       return kFALSE;      
+     }
+
+   // Get Sigma Binning  
+   MBinning* binssigma  = (MBinning*)pList->FindObject("BinningSigmabar");
+   if (!binssigma)
+     {
+       *fLog << err << dbginf << "BinningSigmabar not found... aborting." << endl;
+       return kFALSE;      
+     }
+
+   MH::SetBinning(fHSigmaOld, binstheta, binssigma);
+   MH::SetBinning(fHSigmaNew, binstheta, binssigma);
+
+   //************************************************************************
+   // Create fSigmabarMax histogram
+   // (only if no fixed Sigmabar target value and no histogram have been 
+   // provided)
+   //
+   if (fFixedSigmabar==0 && !fHSigmabarMax && !fHSigmaTheta)
+   {
+       *fLog << inf << "MPadding - Creating fSigmabarMax histogram: ";
+       *fLog << "fFixedSigmabar=" << fFixedSigmabar << ", ";
+       *fLog << "fHSigmabarMax = " << fHSigmabarMax << endl;
+
+       // FIXME: Not deleted
+     fHSigmabarMax = new TH1D;
+     fHSigmabarMax->SetNameTitle("fHSigmabarMax", "Sigmabarmax for this analysis");
+
+     fHSigMaxAllocated = kTRUE;
+
+     MH::SetBinning(fHSigmabarMax, binstheta);
+
+     // -------------------------------------------------
+     // read in SigmabarParams
+     // workaround--proprietary file format--CT1test only BEGIN
+     // -------------------------------------------------
+     
+     FILE *f=fopen(fDatabaseFilename, "r");
+     if(!f) {
+         *fLog << err << dbginf << "Database file '" << fDatabaseFilename;
+         *fLog << "' was not found (specified by MPadding::SetDatabaseFile) ...aborting." << endl;
+         return kFALSE;
+     }
+
+     TAxis &axe = *fHSigmabarMax->GetXaxis();
+
+     char line[80];
+     while ( fgets(line, sizeof(line), f) != NULL) {
+         if (line[0]=='#')
+             continue;
+
+         Float_t sigmabarMin, sigmabarMax, thetaMin, thetaMax, ra, dec2;
+         Int_t type, group, mjd, nr;
+
+         sscanf(line,"%d %d %f %f %d %d %f %f %f %f",
+                &type, &group, &ra, &dec2, &mjd, &nr,
+                &sigmabarMin, &sigmabarMax, &thetaMin, &thetaMax);
+
+         if (group!=fGroup && type!=1) //selected ON group or OFF
+             continue;
+
+         const Int_t from = axe.FindFixBin(thetaMin);
+         const Int_t to   = axe.FindFixBin(thetaMax);
+
+         // find out which bin(s) we have to look at
+         for (Int_t i=from; i<to+1; i++)
+             if (sigmabarMax > fHSigmabarMax->GetBinContent(i))
+                 fHSigmabarMax->SetBinContent(i, sigmabarMax);
+     }//while
+  
+   } //fFixedSigmabar
+   //************************************************************************
+
+   if (!fHSigmabarMax && !fHSigmaTheta && fFixedSigmabar==0)
+   {
+       *fLog << err << "ERROR: Sigmabar for padding not defined... aborting." << endl;
+       return kFALSE;
+   }
+
+   return kTRUE;
+}
+
+Double_t MPadding::CalcOtherSig(const Double_t mySig, const Double_t theta) const
+{
+  //
+  // Get sigmabar which we have to pad to
+  //
+  const TAxis   &axe     = *fHSigmabarMax->GetXaxis();
+  const Int_t    binnum  =  axe.FindFixBin(theta);
+  const Bool_t   inrange =  theta>=axe.GetXmin() && theta<=axe.GetXmax();
+
+  if ((fHSigmabarMax || fHSigmaTheta) && !inrange)
+  {
+      *fLog << err << dbginf;
+      *fLog << "Theta of current event is beyond the limits, Theta = ";
+      *fLog << theta << " ...skipping." <<endl;
+      return -1;
+  }
+
+
+  //
+  // get target sigma for the current Theta from the histogram fHSigmabarMax
+  //
+  if (fHSigmabarMax != NULL) 
+      return fHSigmabarMax->GetBinContent(binnum);
+
+  //
+  // for the current Theta, 
+  // generate a sigma according to the histogram fHSigmaTheta
+  //
+  if (fHSigmaTheta != NULL)
+  {
+      Double_t otherSig = -1;
+
+      TH1D* fHSigma = fHSigmaTheta->ProjectionY("", binnum, binnum, "");
+
+      if (fHSigma->GetEntries()>0)
+          otherSig = fHSigma->GetRandom();
+
+      delete fHSigma;
+
+      return otherSig;
+  }
+
+  //
+  // use a fixed target sigma
+  //
+  return fFixedSigmabar;
+}
+
+// --------------------------------------------------------------------------
+//
+// Do the padding  (mySig ==> otherSig)
+// 
+Int_t MPadding::Padding(const Double_t quadraticDiff, const Double_t theta)
+{
+   const UInt_t npix = fEvt->GetNumPixels();
+
+   // pad only pixels   - which are used (before image cleaning)
+   //                   - and for which the no.of photons is != 0.0
+   //
+   for (UInt_t i=0; i<npix; i++) 
+   {   
+     MCerPhotPix &pix = (*fEvt)[i];
+     if ( !pix.IsPixelUsed() )
+       continue;
+/*
+     if ( pix.GetNumPhotons() == 0)
+     {
+       *fLog << "MPadding::Process(); no.of photons is 0 for used pixel" 
+             << endl;
+       continue;
+     }
+*/
+     const Double_t area = fCam->GetPixRatio(pix.GetPixId());
+
+     // add additional NSB to the number of photons
+     const Double_t NSB = sqrt(quadraticDiff*area) * gRandom->Gaus(0, 1);
+     const Double_t oldphotons = pix.GetNumPhotons();
+     const Double_t newphotons = oldphotons + NSB;
+     pix.SetNumPhotons(	newphotons );
+
+     fHNSB->Fill( NSB/sqrt(area) );
+     fHPhotons->Fill( newphotons/sqrt(area), oldphotons/sqrt(area) );
+
+     // error: add sigma of padded noise quadratically
+     const Double_t olderror = pix.GetErrorPhot();
+     const Double_t newerror = sqrt( olderror*olderror + quadraticDiff*area );
+     pix.SetErrorPhot( newerror );
+
+     MPedPhotPix &ppix = (*fPed)[i];
+
+     ppix.SetRms(0);
+
+     const Double_t oldsigma = ppix.GetRms();
+     const Double_t newsigma = sqrt( oldsigma*oldsigma + quadraticDiff*area );
+     ppix.SetRms( newsigma );
+
+     fHSigmaPedestal->Fill( oldsigma, newsigma );
+     fHSigmaOld->Fill( theta, oldsigma );
+     fHSigmaNew->Fill( theta, newsigma );
+   } //for
+
+   return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Calculate Sigmabar for current event
+// Then apply padding
+// 
+// 1) have current event
+// 2) get sigmabar(theta)
+// 3) pad event
+//
+Int_t MPadding::Process()
+{
+    const Double_t theta = kRad2Deg*fMcEvt->GetTelescopeTheta();
+
+    //
+    // Calculate sigmabar of event
+    //
+    Double_t mySig = fSigmabar->Calc(*fCam, *fPed, *fEvt);
+
+    //$$$$$$$$$$$$$$$$$$$$$$$$$$
+    mySig = 0.0;  // FIXME?
+    //$$$$$$$$$$$$$$$$$$$$$$$$$$
+
+    const Double_t otherSig = CalcOtherSig(mySig, theta);
+
+    // Skip event if target sigma is zero
+    if (otherSig<=0)
+        return kCONTINUE;
+
+    // Determine quadratic difference other-mine
+    const Double_t quadraticDiff = otherSig*otherSig - mySig*mySig;
+
+    if (quadraticDiff < 0) {
+        *fLog << err << "ERROR - MPadding: Event has higher Sigmabar=" << mySig;
+        *fLog << " than Sigmabarmax=" << otherSig << " @ Theta =" << theta;
+        *fLog << " ...skipping." << endl;
+        return kCONTINUE; //skip
+    }
+
+    if (quadraticDiff == 0)
+        return kTRUE; //no padding necessary.
+
+    //
+    // quadratic difference is > 0, do the padding;
+    //
+    Padding(quadraticDiff, theta);
+
+    // Calculate Sigmabar again and crosscheck
+    //mySig = fSigmabar->Calc(*fCam, *fPed, *fEvt);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draws some histograms if IsGraphicalOutputEnabled
+//
+Bool_t MPadding::PostProcess()
+{
+    if (!IsGraphicalOutputEnabled())
+        return kTRUE;
+
+    TCanvas &c = *MH::MakeDefCanvas("Padding", "", 600, 900);
+    c.Divide(2,3);
+    gROOT->SetSelectedPad(NULL);
+
+    if (fHSigmabarMax != NULL)
+    {
+        c.cd(1);
+        fHSigmabarMax->DrawClone();
+    }
+    else if (fHSigmaTheta != NULL)
+    {
+        c.cd(1);
+        fHSigmaTheta->DrawClone();
+    }
+
+    c.cd(3);
+    fHSigmaPedestal->DrawClone();
+
+    c.cd(5);
+    fHPhotons->DrawClone();
+
+    c.cd(2);
+    fHNSB->DrawClone();
+
+    c.cd(4);
+    fHSigmaOld->DrawClone();     
+
+    c.cd(6);
+    fHSigmaNew->DrawClone();     
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/manalysis/MPadding.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MPadding.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MPadding.h	(revision 9661)
@@ -0,0 +1,68 @@
+#ifndef MARS_MPadding
+#define MARS_MPadding
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class TH1D;
+class TH2D;
+class MGeomCam;
+class MCerPhotEvt;
+class MPedPhotCam;
+class MMcEvt;
+class MSigmabar;
+class MParList;
+
+class MPadding : public MTask
+{
+private:
+    MGeomCam     *fCam;
+    MCerPhotEvt  *fEvt;
+    MSigmabar    *fSigmabar;
+    MMcEvt       *fMcEvt;
+    MPedPhotCam  *fPed;
+
+    Int_t     fRunType;
+    Int_t     fGroup;
+
+    TString   fDatabaseFilename; // data file used for generating fHSigmabarMax histogram
+    Double_t  fFixedSigmabar;    // fixed sigmabar value
+
+    Bool_t    fHSigMaxAllocated; // flag whether MPadding allocated it
+    TH1D     *fHSigmabarMax;     // histogram (sigmabarmax vs. Theta)
+    TH2D     *fHSigmaTheta;      // 2D-histogram (sigmabar vs. Theta)
+    TH2D     *fHSigmaPedestal;   //-> for testing: plot of padded vs orig. pedestal sigmas
+    TH2D     *fHPhotons;         //-> for testing: no.of photons after versus before padding
+    TH2D     *fHSigmaOld;        //-> histogram (sigma vs. Theta) before padding
+    TH2D     *fHSigmaNew;        //-> histogram (sigma vs. Theta) after padding
+    TH1D     *fHNSB;             //-> histogram of added NSB
+
+    Double_t CalcOtherSig(const Double_t mySig, const Double_t theta) const;
+    Bool_t   Padding(const Double_t quadDiff, const Double_t theta);
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
+public:
+    MPadding(const char *name=NULL, const char *title=NULL);
+    ~MPadding();
+
+    void SetRunType(Int_t runtype) { fRunType =  runtype; }
+    void SetGroup(Int_t group)     { fGroup   =  group; }
+
+    Bool_t SetDefiningHistogram(TH1D *hist);
+    void SetDatabaseFile(char *filename) { fDatabaseFilename = filename; }
+
+    Bool_t SetSigmaThetaHist(TH2D *histo);
+
+    void SetTargetLevel(Double_t sigmabar);
+
+    ClassDef(MPadding, 0)   // task for the padding
+}; 
+
+#endif
+
+
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MParameters.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MParameters.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MParameters.cc	(revision 9661)
@@ -0,0 +1,67 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz 03/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MParameterD, MParameterI
+//
+// Storage Container for doubles and ints
+//
+// This classes can be used for intermidiate variables which we don't want
+// to have in a special container.
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MParameters.h"
+
+#include <fstream>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MParameterD);
+ClassImp(MParameterI);
+//ClassImp(MParameter);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MParameterD::MParameterD(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MParameterD";
+    fTitle = title ? title : "Storgare container for general parameters (double)";
+}
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MParameterI::MParameterI(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MParameterI";
+    fTitle = title ? title : "Storgare container for general parameters (integer)";
+}
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MParameters.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MParameters.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MParameters.h	(revision 9661)
@@ -0,0 +1,98 @@
+#ifndef MARS_MParameters
+#define MARS_MParameters
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MParameterD : public MParContainer
+{
+private:
+    Double_t fVal;
+
+public:
+    MParameterD(const char *name=NULL, const char *title=NULL);
+
+    void SetVal(Double_t v) { fVal = v; }
+    Double_t GetVal() const { return fVal; }
+
+    ClassDef(MParameterD, 1) // Container to hold a generalized parameters (double)
+};
+
+class MParameterI : public MParContainer
+{
+private:
+    Int_t fVal;
+
+public:
+    MParameterI(const char *name=NULL, const char *title=NULL);
+
+    void SetVal(Int_t v) { fVal = v; }
+    Int_t GetVal() const { return fVal; }
+
+    ClassDef(MParameterI, 1) // Container to hold a generalized parameters (integer)
+};
+/*
+class MParameters : public MParContainer
+{
+private:
+    TObjArray fList;
+    TObjArray fNames;
+
+public:
+    MParameters(const char *name=NULL, const char *title=NULL)
+    {
+        fName  = name  ? name  : "MParameters";
+        fTitle = title ? title : "Additional temporary parameters";
+
+        SetReadyToSave();
+    }
+
+    MParamaterI &AddInteger(const TString name, const TString title, Int_t val=0)
+    {
+        MParameterI &p = *new MParameterI(name, title);
+        p.SetValue(val);
+
+        fList.Add(&p);
+
+        TNamed &n = *new TNamed(name, title);
+        fNames.Add(&n);
+
+        return p;
+    }
+
+    MParameterD &AddDouble(const TString name, const TString title, Double_t val=0)
+    {
+        MParameterD &p = *new MParameterD(name, title);
+        p.SetValue(val);
+
+        fList.Add(&p);
+
+        TNamed &n = *new TNamed(name, title);
+        fNames.Add(&n);
+
+        return p;
+    }
+
+    const TObjArray &GetList()
+    {
+        fList.SetNames(&fNames);
+        return fList;
+    }
+
+    MParameterD *GetParameterD(const TString &name)
+    {
+        fList.SetNames(&fNames);
+        return (MParamaterD*)fList.FindObject(name);
+    }
+
+    MParameterI *GetParameterI(const TString &name)
+    {
+        fList.SetNames(&fNames);
+        return (MParameterI*)fList.FindObject(name);
+    }
+
+    ClassDef(MParameters, 1) // List to hold generalized parameters (MParameterD/I)
+    }
+    */
+#endif
Index: /tags/Mars_V0-8-5/Mars/manalysis/MPedCalUpdate.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MPedCalUpdate.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MPedCalUpdate.cc	(revision 9661)
@@ -0,0 +1,236 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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 03/2004 <mailto:tbretz@astro.uni.wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MPedCalUpdate
+//
+//  This task reads files stored by MJ* storing pedestals (F2) and
+//  calibration constants (F1) while an eventloop is running.
+//
+//  The update is done according to the run-number. The information
+//  which ped/cal files corresponds to which run-number is stored in
+//  an ascii file. In a next step this ascii file can be created
+//  automatically (hopefully from the Database)
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MPedCalUpdate.h"
+
+#include <fstream>
+#include <TFile.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MRawRunHeader.h"
+#include "MPedPhotCam.h"
+#include "MCalibrationChargeCam.h"
+#include "MBadPixelsCam.h"
+
+ClassImp(MPedCalUpdate);
+
+using namespace std;
+
+static const TString gsDefName  = "MPedCalUpdate";
+static const TString gsDefTitle = "";
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MPedCalUpdate::MPedCalUpdate(const char *fname, const char *name, const char *title)
+    : fPedPhot(0), fCalCam(0), fFileName(fname)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+
+    fLast=0;
+}
+
+Bool_t MPedCalUpdate::ReadPed(const char *fname)
+{
+    TFile file(fname, "READ");
+    if (fPedPhot->Read()<=0)
+    {
+        *fLog << err << "Unable to read MPedPhotCam from " << fname << endl;
+        return kFALSE;
+    }
+
+    if (file.FindKey("MBadPixelsCam"))
+    {
+        MBadPixelsCam bad;
+        if (bad.Read()<=0)
+        {
+            *fLog << err << "Unable to read MBadPixelsCam from " << fname << endl;
+            return kFALSE;
+        }
+        fBadPix->Merge(bad);
+    }
+    return kTRUE;
+}
+
+Bool_t MPedCalUpdate::ReadCal(const char *fname)
+{
+    TFile file(fname, "READ");
+    if (fCalCam->Read()<=0)
+    {
+        *fLog << err << "Unable to read MCalibrationChargeCam from " << fname << endl;
+        return kFALSE;
+    }
+
+    if (file.FindKey("MBadPixelsCam"))
+    {
+        MBadPixelsCam bad;
+        if (bad.Read()<=0)
+        {
+            *fLog << "Unable to read MBadPixelsCam from " << fname << endl;
+            return kFALSE;
+        }
+        fBadPix->Merge(bad);
+    }
+    return kTRUE;
+}
+
+Bool_t MPedCalUpdate::ReadPC(TString &line)
+{
+    const Int_t f = line.First(' ');
+    if (f<0)
+    {
+        *fLog << err << "Entry for pedestal file not found!" << endl;
+        return kFALSE;
+    }
+
+    const Int_t l = line.Last(' ')+1;
+    if (l<0)
+    {
+        *fLog << err << "Entry for calibration file not found!" << endl;
+        return kFALSE;
+    }
+
+    const TString fname1 = line(0, f);
+    const TString fname2 = line(l, line.Length());
+
+    TString mid(line(f, l-f));
+    mid=mid.Strip(TString::kBoth);
+    if (!mid.IsNull())
+    {
+        *fLog << err << "Found three filenames '" << fname1 << "' '" << mid << "' '" << fname2 << "'" << endl;
+        return kFALSE;
+    }
+
+    if (!ReadPed(fname1))
+        return kFALSE;
+
+    if (!ReadCal(fname2))
+        return kFALSE;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//
+Bool_t MPedCalUpdate::ReInit(MParList *pList)
+{
+    MRawRunHeader *header = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
+    if (!header)
+    {
+        *fLog << err << "MRawRunHeader not found... aborting." << endl;
+        return kFALSE;
+    }
+    fPedPhot = (MPedPhotCam*)pList->FindCreateObj("MPedPhotCam");
+    if (!fPedPhot)
+        return kFALSE;
+    fBadPix = (MBadPixelsCam*)pList->FindCreateObj("MBadPixelsCam");
+    if (!fBadPix)
+        return kFALSE;
+    fCalCam = (MCalibrationChargeCam*)pList->FindCreateObj("MCalibrationChargeCam");
+    if (!fCalCam)
+        return kFALSE;
+
+    const Int_t run = header->GetRunNumber();
+
+    ifstream fin(fFileName);
+    if (!fin)
+    {
+        *fLog << err << "Cannot open file: " << fFileName << endl;
+        return kFALSE;
+    }
+
+    Int_t last = 0;
+
+    TString readline;
+
+    while (1)
+    {
+        // Read line from file
+        TString line;
+        line.ReadLine(fin);
+        if (!fin && !readline.IsNull() && fLast!=last)
+        {
+            *fLog << dbg << "Reading line " << readline << endl;
+            fLast = last;
+            return ReadPC(readline);
+        }
+
+        if (!fin)
+            break;
+
+        line = line.Strip(TString::kBoth);
+
+        // Interprete line
+        Int_t len, num;
+        if (sscanf(line.Data(), "%d %n", &num, &len)!=1)
+            continue;
+
+        // Check whether entries are in increasing order
+        if (num<=last)
+        {
+            *fLog << err << "Runs must be in increasing order..." << endl;
+            return kFALSE;
+        }
+        last = num;
+
+        // Check if a new set of files must be read
+        if (num<=run)
+        {
+            readline=line;
+            readline.Remove(0, len);
+            continue;
+        }
+
+        // This is the case if the correct files were already read
+        if (fLast==num)
+            return kTRUE;
+
+        // Read files given in new line
+        *fLog << dbg << "Reading line " << readline << endl;
+        fLast = num;
+        return ReadPC(readline);
+    }
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/manalysis/MPedCalUpdate.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MPedCalUpdate.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MPedCalUpdate.h	(revision 9661)
@@ -0,0 +1,35 @@
+#ifndef MARS_MPedCalUpdate
+#define MARS_MPedCalUpdate
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MPedPhotCam;
+class MCalibrationChargeCam;
+class MBadPixelsCam;
+
+class MPedCalUpdate : public MTask
+{
+private:
+    MPedPhotCam           *fPedPhot;
+    MCalibrationChargeCam *fCalCam;
+    MBadPixelsCam         *fBadPix;
+
+    TString fFileName;
+
+    Int_t fLast;
+
+    Bool_t ReadCal(const char *name);
+    Bool_t ReadPed(const char *name);
+    Bool_t ReadPC(TString &line);
+    Bool_t ReInit(MParList *pList);
+
+public:
+    MPedCalUpdate(const char *filename, const char *name=NULL, const char *title=NULL);
+
+    ClassDef(MPedCalUpdate, 1) // Task to update Pedestals and Cal-Constants while an eventloop is running
+}; 
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MPedestalCalc.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MPedestalCalc.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MPedestalCalc.cc	(revision 9661)
@@ -0,0 +1,229 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Josep Flix 11/2002 <mailto:jflix@ifae.es>
+!   Author(s): Thomas Bretz 11/2002 <mailto:tbretz@astro.uni-wuerburg.de>
+!
+!   Copyright: MAGIC Software Development, 2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MPedestalCalc
+//
+//  Task to calculate the pedestals from the event stream.
+//
+//  From the events two streams of pedestals are created like in the
+//  following table
+//  MRawEvtData:    1   2   3   4   5   6   7   8   9  10  11  12
+//  MPedestalCam;1: ------1------   ------2------   ------3------...
+//  MPedestalCam;2:         ------1------   ------2------  ------...
+//
+//  Input Containers:
+//   MRawEvtData
+//
+//  Output Containers:
+//   MPedestalCam;1
+//   MPedestalCam;2
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MPedestalCalc.h"
+
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MTime.h"
+#include "MHFadcCam.h"
+#include "MRawEvtPixelIter.h"
+
+#include "MPedestalCam.h"
+#include "MPedestalPix.h"
+
+ClassImp(MPedestalCalc);
+
+MPedestalCalc::MPedestalCalc(const char *name, const char *title)
+    : fNumBranches(2), fTimeSlot(6), fHists(NULL)
+{
+    fName  = name  ? name  : "MPedestalCalc";
+    fTitle = title ? title : "Task to calculate pedestals from pedestal runs raw data";
+
+    AddToBranchList("fHiGainPixId");
+    AddToBranchList("fLoGainPixId");
+    AddToBranchList("fHiGainFadcSamples");
+    AddToBranchList("fLoGainFadcSamples");
+}
+
+Int_t MPedestalCalc::PreProcess(MParList *pList)
+{
+    if (fHists)
+    {
+        *fLog << err << "ERROR - Previous PostProcess not called." << endl;
+        return kFALSE;
+    }
+
+    fHists = new MHFadcCam[fNumBranches];
+    fStart = new MTime    [fNumBranches];
+
+    fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
+    if (!fRawEvt)
+    {
+        *fLog << dbginf << "MRawEvtData not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fPedestals = (MPedestalCam*)pList->FindCreateObj("MPedestalCam");
+    if (!fPedestals)
+        return kFALSE;
+
+    fPedTime = (MTime*)pList->FindCreateObj("MTime", "MPedestalTime");
+    if (!fPedTime)
+        return kFALSE;
+
+    //
+    // Fixme: FindCreateObj --> FindObject
+    //
+    fEvtTime = (MTime*)pList->FindCreateObj("MTime", "MRawEvtTime");
+    if (!fEvtTime)
+        return kFALSE;
+
+    for (int i=0; i<fNumBranches; i++)
+        fStart[i].SetTime(fTimeSlot*10/fNumBranches*i, 0);
+
+    fPedTime->SetDuration(fTimeSlot);
+    fEvtTime->SetTime(0, 0);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Checks whether the current event exceed the validity range of a pedestal
+//  in one of the streams. If this is the case the data from the histogram
+//  is dumped as pedestals into the corresponding containers and the
+//  histograms are reset.
+//
+//  Then the current event is filled into the histograms.
+//
+Int_t MPedestalCalc::Process()
+{
+    //
+    // Time when filling of stream a/b must be restarted
+    //
+    for (int i=0; i<fNumBranches; i++)
+    {
+        Check(i);
+        Fill(i);
+    }
+
+    fEvtTime->SetTime(fEvtTime->GetTimeLo()+10, 0);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Fill the event in the histogram if the current time of the
+//  event is _after_ the start time for filling
+//
+void MPedestalCalc::Fill(Int_t i)
+{
+    if (*fEvtTime < fStart[i])
+        return;
+
+    fHists[i].Fill(fRawEvt);
+}
+
+// --------------------------------------------------------------------------
+//
+//  If the current time of the event is equal or after the time
+//  which is given by the start time plus the validity range
+//  calculate the corresponding set of pedestals and reset the
+//  histograms
+//
+void MPedestalCalc::Check(Int_t i)
+{
+    if (*fEvtTime-fStart[i] < fTimeSlot*10)
+        return;
+
+    Calc(i);
+
+    fStart[i] = *fEvtTime;
+    fHists[i].ResetHistograms();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Deletes all dynamicly allocated arrays
+//
+Bool_t MPedestalCalc::PostProcess()
+{
+    delete fHists;
+    delete fStart;
+
+    fHists=NULL;
+
+    return kTRUE;
+}
+
+/*
+ #include "MRawEvtData.h"
+ */
+// --------------------------------------------------------------------------
+//
+//  Dumps the mean, rms and their errors from the filled histograms into
+//  the Pedestal container. Sets the ReadyToSaveFlag of the MPedestalCam
+//  container.
+//
+void MPedestalCalc::Calc(Int_t i) const
+{
+    // FIXME! Fit +- 3 sigma to avoid outliers...
+
+    MRawEvtPixelIter pixel(fRawEvt);
+    while (pixel.Next())
+    {
+        const UInt_t pixid = pixel.GetPixelId();
+
+        const TH1 &h = *fHists[i].GetHistHi(pixid);
+
+        const Int_t   entries = (Int_t)h.GetEntries();
+        const Float_t meanhi  = h.GetMean();
+        const Float_t rmshi   = h.GetRMS();
+
+        const Float_t meanhierr = rmshi/sqrt(entries);
+        const Float_t rmshierr  = rmshi/sqrt(entries*2);
+
+        MPedestalPix &pix = (*fPedestals)[pixid];
+        pix.SetPedestal(meanhi, rmshi);
+        pix.SetPedestalRms(meanhierr, rmshierr);
+    }
+
+    *fPedTime = fStart[i];
+
+    fPedTime->SetReadyToSave();
+    fPedestals->SetReadyToSave();
+
+    /*
+     *fLog << i << "[" << fHists[i].GetHistHi(0)->GetEntries()/fRawEvt->GetNumHiGainSamples() << "]:  ";
+     *fLog << fEvtTime->GetTimeLo() << ": Calc [";
+     *fLog << fStart[i].GetTimeLo() << " < ";
+     *fLog << fStart[i].GetTimeLo()+fTimeSlot*10 << "]" << endl;
+     */
+}
Index: /tags/Mars_V0-8-5/Mars/manalysis/MPedestalCalc.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MPedestalCalc.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MPedestalCalc.h	(revision 9661)
@@ -0,0 +1,59 @@
+#ifndef MARS_MPedestalCalc
+#define MARS_MPedestalCalc
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MPedestalCalc                                                           //
+//                                                                         //
+// Implementation of ped. Eval. defined in Jan 02                          //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+#ifndef MARS_MHFadCam
+#include "MHFadcCam.h"
+#endif
+
+class MTime;
+class MRawEvtData;
+class MPedestalCam;
+
+class MPedestalCalc : public MTask 
+{
+private:
+    Int_t   fNumBranches;
+    Float_t fTimeSlot;
+
+    MRawEvtData  *fRawEvt;
+    MPedestalCam *fPedestals;  //
+
+    MHFadcCam *fHists;         //[fNumBranches]
+
+    MTime     *fPedTime; // time of the pedestal event
+    MTime     *fEvtTime; // time of the current event
+    MTime     *fStart;   //[fNumBranches] starting time of the current pedestal
+
+
+    void Calc(Int_t i) const;
+    void Fill(Int_t i);
+    void Check(Int_t i);
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
+public:
+    MPedestalCalc(const char *name=NULL, const char *title=NULL);
+
+    void SetTimeSlot(Float_t newslot) { fTimeSlot = newslot; }
+    void SetNumBranches(Int_t num) { fNumBranches = num; }
+
+    ClassDef(MPedestalCalc, 0) // Task to calculate the pestels from pedestal events
+};
+
+#endif
+
+
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MPedestalSum.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MPedestalSum.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MPedestalSum.cc	(revision 9661)
@@ -0,0 +1,227 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Abelardo Moralejo 7/2002  <mailto:moralejo@pd.infn.it>
+!   Author(s): Thomas Bretz 2002  <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2002-2003
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//   MPedestalSum
+//
+//   This is a task which calculates the number of photons from the FADC
+//   time slices. It weights the each slice according to the numbers in
+//   the array fWeight (default: all slices added up with weight 1).
+//
+//   The weights are rescaled, such that sum(weigths)=num slices
+//
+//  Input Containers:
+//   MRawRunHeader, MRawEvtData, MPedestalCam
+//
+//  Output Containers:
+//   MCerPhotEvt
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MPedestalSum.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(MPedestalSum);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MPedestalSum::MPedestalSum(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MPedestalSum";
+    fTitle = title ? title : "Calculate pixel signal from FADC data";
+
+    AddToBranchList("MRawEvtData.fHiGainPixId");
+    AddToBranchList("MRawEvtData.fLoGainPixId");
+    AddToBranchList("MRawEvtData.fHiGainFadcSamples");
+    AddToBranchList("MRawEvtData.fLoGainFadcSamples");
+
+    SetDefaultWeights();
+}
+
+// --------------------------------------------------------------------------
+//
+// The PreProcess searches for the following input containers:
+//  - MRawRunHeader
+//  - MRawEvtData
+//  - MPedestalCam
+//
+// The following output containers are also searched and created if
+// they were not found:
+//  - MCerPhotEvt
+//
+Int_t MPedestalSum::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;
+    }
+
+    fCerPhotEvt = (MCerPhotEvt*)pList->FindCreateObj("MCerPhotEvt");
+    if (!fCerPhotEvt)
+    {
+        *fLog << dbginf << "MCerPhotEvt not found... aborting." << endl;
+        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 MPedestalSum::ReInit(MParList *pList)
+{
+    /*
+    const MRawRunHeader *runheader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
+    if (!runheader)
+    {
+        *fLog << warn << dbginf << "Warning - cannot check file type, MRawRunHeader not found." << endl;
+        return kTRUE;
+    }
+
+    if (fRunHeader->GetNumSamplesHiGain() != fWeight.GetSize())
+    {
+        *fLog << dbginf << "Number of FADC slices (" << fRunHeader->GetNumSamplesHiGain() <<") is different from assumed one (" << fWeight.GetSize() << ")... aborting." << endl;
+        return kFALSE;
+    }
+
+    Bool_t fIsMcFile = runheader->GetRunType() == kRTMonteCarlo;
+    if (!fIsMcFile)
+        return kTRUE;
+
+    ScalePedestals();
+
+    MMcRunHeader *mcrunheader = (MMcRunHeader*)pList->FindObject("MMcRunHeader");
+    if (!mcrunheader)
+    {
+        *fLog << warn << dbginf << "Warning - cannot check for camera version, MC run header not found." << endl;
+        return kTRUE;
+    }
+
+    fEnableFix = kFALSE;
+    if (mcrunheader->GetCamVersion() <= 40)
+        fEnableFix = kTRUE;
+     */
+    return kTRUE;
+}
+
+void MPedestalSum::ScalePedestals()
+{
+    Int_t n = 577; //FIXME: fPedestals->GetNumPixel();
+
+    for (int idx=0; idx<n; idx++)
+    {
+        MPedestalPix &ped = (*fPedestals)[idx];
+
+        const Double_t offset = fEnableFix ? ped.GetPedestal()-0.5 : ped.GetPedestal();
+        ped.Set(offset*fSumWeights, ped.GetPedestalRms()*sqrt(fSumQuadWeights));
+    }
+
+    fPedestals->SetReadyToSave();
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculate the integral of the FADC time slices and store them as a new
+// pixel in the MCerPhotEvt container.
+//
+Int_t MPedestalSum::Process()
+{
+    //fCerPhotEvt->InitSize(fRawEvt->GetNumPixels());
+
+//    if (fIsMcFile)
+//        ScalePedestals();
+
+    MRawEvtPixelIter pixel(fRawEvt);
+
+    while (pixel.Next())
+    {
+        const UInt_t idx = pixel.GetPixelId();
+
+        const int n = fRunHeader->GetNumSamplesHiGain();
+
+        //
+        // Calculate pixel signal unless it has all FADC slices empty:
+        //
+        Byte_t *ptr = pixel.GetHiGainSamples();
+
+        Float_t nphot = 0;
+        Float_t nerr  = 0;
+        for(Int_t i=0; i<n; i++)
+        {
+            nphot += ptr[i];
+            nerr  += ptr[i]*ptr[i];
+        }
+
+        nphot /= n;
+
+        fCerPhotEvt->AddPixel(idx, nphot, sqrt(nerr/n-nphot*nphot));
+
+        // FIXME! Handling of Lo Gains is missing!
+    }
+
+    fCerPhotEvt->FixSize();
+    fCerPhotEvt->SetReadyToSave();
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Set default values for the number of slices and weights:
+//
+void MPedestalSum::SetDefaultWeights()
+{
+    const Float_t dummy[15] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
+    fWeight.Set(15, dummy);
+}
Index: /tags/Mars_V0-8-5/Mars/manalysis/MPedestalSum.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MPedestalSum.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MPedestalSum.h	(revision 9661)
@@ -0,0 +1,57 @@
+#ifndef MARS_MPedestalSum
+#define MARS_MPedestalSum
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MPedestalSum                                                            //
+//                                                                         //
+// Integrates the desired ADC time slices of one pixel and substracts the  //
+// pedestal (offset) value                                                 //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#ifndef ROOT_TArrayF
+#include <TArrayF.h>
+#endif
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MRawEvtData;
+class MPedestalCam;
+class MCerPhotEvt;
+class MRawRunHeader;
+
+class MPedestalSum : 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)
+    Bool_t          fIsMcFile;
+
+    TArrayF         fWeight;  // Weights for adding up the ADC slices
+    Float_t         fSumWeights;
+    Float_t         fSumQuadWeights;
+
+    void SetDefaultWeights();
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
+    Bool_t ReInit(MParList *pList);
+    void ScalePedestals();
+
+public:
+    MPedestalSum(const char *name=NULL, const char *title=NULL);
+
+    // FIXME: The array size should be checked!
+    void   SetWeights(const TArrayF &w) { fWeight = w; }
+
+    ClassDef(MPedestalSum, 0)   // Task to calculate cerenkov photons from raw data
+};
+ 
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/manalysis/MPedestalWorkaround.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MPedestalWorkaround.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MPedestalWorkaround.cc	(revision 9661)
@@ -0,0 +1,552 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Sabrina Stark   12/2003 <mailto:lstark@particle.phys.ethz.ch>
+!              Wolfgang Wittek 12/2003 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MPedestalWorkaround                                                     //
+//                                                                         //
+// copies the pedestal value and the pedestal RMS                          //
+//        from the container MPedPhotCam                                   //
+//        into the contaier  MPedestalCam                                  //
+//                                                                         //
+// put the zenith angle into MMcEvt;                                       //
+//     the zenith angle is taken from the runbooks                         //
+//     (1 fixed zenith angle for a given run)                              //
+//                                                                         //
+// this workaround is necessary                                            //
+// - as long as the analysis classes                                       //
+//   take the pedestals from MPedestalCam; in the long run they have to    //
+//   be taken from MPedPhotCam                                             //
+// - and as long as the container for the zenith angle is not defined      //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MPedestalWorkaround.h"
+
+#include <stdio.h>
+#include "MLog.h"
+#include "MLogManip.h"
+#include "MParList.h"
+#include "MGeomCam.h"
+
+#include "MPedPhotCam.h"
+#include "MPedPhotPix.h"
+#include "MMcEvt.hxx"
+#include "MRawRunHeader.h"
+
+using namespace std;
+
+ClassImp(MPedestalWorkaround);
+
+MPedestalWorkaround::MPedestalWorkaround(const char *name, const char *title)
+{
+    fName = name ? name : "MPedestalWorkaround";
+    fTitle = title ? title : "Storage of pedestal values and RMS in units of photons";
+   
+}
+
+// ------------------------------------------------------------------------
+//
+
+Int_t MPedestalWorkaround::PreProcess(MParList *pList)
+{
+  /*
+   fPed = (MPedestalCam*)pList->FindObject("MPedestalCam");
+   if (!fPed)
+     {
+       *fLog << err << "MPedestalCam not found... aborting." << endl;
+       return kFALSE;
+     }
+  */
+
+   fPedPhot = (MPedPhotCam*)pList->FindObject("MPedPhotCam");
+   if (!fPedPhot)
+     {
+       *fLog << err << "MPedPhotCam not found... aborting." << endl;
+       return kFALSE;
+     }
+
+   fCam = (MGeomCam*)pList->FindObject("MGeomCam");
+   if (!fCam)
+     {
+       *fLog << err << "MGeomCam not found (no geometry information available)... aborting." << endl;
+       return kFALSE;
+     }
+
+   fRun = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
+   if (!fRun)
+   {
+       *fLog << err << "MRawRunHeader not found... aborting." << endl;
+       return kFALSE;
+   }
+
+   fMcEvt = (MMcEvt*)pList->FindCreateObj("MMcEvt");
+   if (!fMcEvt)
+   {
+       *fLog << err << "MMcEvt not found... aborting." << endl;
+       return kFALSE;
+   }
+
+   return kTRUE;
+}
+
+// ------------------------------------------------------------------------
+//
+Int_t MPedestalWorkaround::Process()
+{
+  //-------------------------------------------------------------------
+  // copy the pedestal and the pedestal RMS 
+  // from MPedPhotCam into MPedestalCam   
+
+  // set pedestalRMS = 0 if it is too high
+  UInt_t imaxnumpix = fCam->GetNumPixels();
+  for (UInt_t i=0; i<imaxnumpix; i++)
+  {
+    Double_t val = (*fPedPhot)[i].GetRms();
+    if (val < 0.0 || val > 10.0)
+      (*fPedPhot)[i].SetRms(0.0);
+  }
+
+
+  //-------------------------------------------------------------------
+  // put the zenith angle into MMcEvt
+
+  Double_t thetadeg;
+  Double_t thetarad;
+
+
+  /*
+  Int_t run = fRun->GetRunNumber();
+
+  if      (run == 3127)  thetadeg = 27.2;  // Crab
+  else if (run == 3128)  thetadeg = 25.6;
+  else if (run == 3129)  thetadeg = 24.3;
+  else if (run == 3130)  thetadeg = 23.9;
+
+
+  else if (run == 3132)  thetadeg = 22.9;
+  else if (run == 3133)  thetadeg = 22.8;
+  else if (run == 3134)  thetadeg = 22.3;
+  else if (run == 3135)  thetadeg = 21.9;
+  else if (run == 3136)  thetadeg = 21.5;
+  else if (run == 3137)  thetadeg = 21.1;
+  else if (run == 3138)  thetadeg = 20.8;
+  else if (run == 3139)  thetadeg = 20.4;
+
+  else if (run == 3140)  thetadeg = 19.5;
+  else if (run == 3141)  thetadeg = 19.4;
+  else if (run == 3142)  thetadeg = 19.0;
+  else if (run == 3143)  thetadeg = 18.6;
+  else if (run == 3144)  thetadeg = 13.0;
+  else if (run == 3145)  thetadeg = 12.4;
+  else if (run == 3146)  thetadeg = 12.1;
+  else if (run == 3147)  thetadeg = 11.7;
+  else if (run == 3148)  thetadeg = 11.3;
+  else if (run == 3149)  thetadeg = 11.9;
+
+  else if (run == 3150)  thetadeg = 10.6;
+  else if (run == 3151)  thetadeg = 10.3;
+  else if (run == 3152)  thetadeg = 10.0;
+  else if (run == 3153)  thetadeg =  9.6;
+  else if (run == 3154)  thetadeg =  9.3;
+  else if (run == 3155)  thetadeg =  9.0;
+  else if (run == 3156)  thetadeg =  8.7;
+  else if (run == 3157)  thetadeg =  8.4;
+  else if (run == 3158)  thetadeg =  8.1;
+  else if (run == 3159)  thetadeg =  7.9;
+
+  else if (run == 3160)  thetadeg =  7.7;
+  else if (run == 3161)  thetadeg =  7.3;
+  else if (run == 3162)  thetadeg =  7.2;
+  else if (run == 3163)  thetadeg =  7.0;
+  else if (run == 3164)  thetadeg =  6.8;
+  else if (run == 3165)  thetadeg =  6.7;
+  else if (run == 3166)  thetadeg =  6.6;
+  else if (run == 3167)  thetadeg =  6.5;
+  else if (run == 3168)  thetadeg =  6.4;
+  else if (run == 3169)  thetadeg =  6.4;
+
+  else if (run == 3170)  thetadeg =  6.4;
+  else if (run == 3171)  thetadeg =  6.4;
+  else if (run == 3172)  thetadeg =  6.5;
+  else if (run == 3173)  thetadeg =  6.6;
+  else if (run == 3174)  thetadeg =  6.7;
+
+  else if (run == 3176)  thetadeg =  7.1;
+  else if (run == 3177)  thetadeg =  7.4;
+  else if (run == 3178)  thetadeg =  7.6;
+  else if (run == 3179)  thetadeg =  7.9;
+
+
+  else if (run == 3182)  thetadeg =  8.4;
+  else if (run == 3183)  thetadeg =  8.9;
+  else if (run == 3184)  thetadeg =  9.2;
+  else if (run == 3185)  thetadeg =  9.5;
+  else if (run == 3186)  thetadeg =  9.8;
+  else if (run == 3187)  thetadeg = 10.5;
+  else if (run == 3188)  thetadeg = 10.9;
+  else if (run == 3189)  thetadeg = 11.2;
+
+  else if (run == 3190)  thetadeg = 11.6;
+  else if (run == 3191)  thetadeg = 11.6;
+  else if (run == 3192)  thetadeg = 12.4;
+  else if (run == 3193)  thetadeg = 12.7;
+  else if (run == 3194)  thetadeg = 13.1;
+  else if (run == 3195)  thetadeg = 13.5;
+  else if (run == 3196)  thetadeg = 13.9;
+  else if (run == 3197)  thetadeg = 14.3;
+  else if (run == 3198)  thetadeg = 14.7;
+  else if (run == 3199)  thetadeg = 15.1;
+
+  else if (run == 3200)  thetadeg = 15.6;
+  else if (run == 3201)  thetadeg = 16.0;
+  else if (run == 3202)  thetadeg = 16.5;
+  else if (run == 3203)  thetadeg = 16.9;
+  else if (run == 3204)  thetadeg = 17.3;
+  else if (run == 3205)  thetadeg = 17.7;
+  else if (run == 3206)  thetadeg = 18.2;
+  else if (run == 3207)  thetadeg = 18.6;
+  else if (run == 3208)  thetadeg = 19.0;
+  else if (run == 3209)  thetadeg = 19.4;
+
+  else if (run == 3210)  thetadeg = 19.9;
+  else if (run == 3211)  thetadeg = 20.4;
+  else if (run == 3212)  thetadeg = 20.8;
+  else if (run == 3213)  thetadeg = 21.2;
+  else if (run == 3214)  thetadeg = 21.7;
+  else if (run == 3215)  thetadeg = 22.2;
+  else if (run == 3216)  thetadeg = 25.6;  // Off Crab1
+  else if (run == 3217)  thetadeg = 25.0;
+  else if (run == 3218)  thetadeg = 24.5;
+  else if (run == 3219)  thetadeg = 24.0;
+
+  else if (run == 3220)  thetadeg = 23.5;
+  else if (run == 3221)  thetadeg = 22.5;
+  else if (run == 3222)  thetadeg = 22.1;
+
+  else if (run == 3225)  thetadeg = 15.1;
+  else if (run == 3226)  thetadeg = 15.0;
+  else if (run == 3227)  thetadeg = 14.5;
+  else if (run == 3228)  thetadeg = 14.1;
+  else if (run == 3229)  thetadeg = 13.8;
+
+  else if (run == 3230)  thetadeg = 13.3;
+  else if (run == 3231)  thetadeg = 13.0;
+  else if (run == 3232)  thetadeg = 12.6;
+  else if (run == 3233)  thetadeg = 12.3;
+  else if (run == 3234)  thetadeg = 12.0;
+  else if (run == 3235)  thetadeg = 11.6;
+  else if (run == 3236)  thetadeg = 11.3;
+  else if (run == 3237)  thetadeg = 11.0;
+  else if (run == 3238)  thetadeg = 10.8;
+  else if (run == 3239)  thetadeg = 10.4;
+
+  else if (run == 3240)  thetadeg = 10.1;
+  else if (run == 3241)  thetadeg =  9.9;
+  else if (run == 3242)  thetadeg =  9.6;
+  else if (run == 3243)  thetadeg =  9.4;
+  else if (run == 3244)  thetadeg =  9.2;
+  else if (run == 3245)  thetadeg =  9.0;
+  else if (run == 3246)  thetadeg =  8.9;
+  else if (run == 3247)  thetadeg =  8.8;
+  else if (run == 3248)  thetadeg =  8.7;
+  else if (run == 3249)  thetadeg =  8.6;
+
+  else if (run == 3250)  thetadeg =  8.6;
+  else if (run == 3251)  thetadeg =  8.6;
+  else if (run == 3252)  thetadeg =  8.6;
+  else if (run == 3253)  thetadeg =  8.7;
+  else if (run == 3254)  thetadeg =  8.8;
+  else if (run == 3255)  thetadeg =  8.9;
+  else if (run == 3256)  thetadeg =  9.1;
+  else if (run == 3257)  thetadeg =  9.3;
+  else if (run == 3258)  thetadeg =  9.5;
+  else if (run == 3259)  thetadeg =  9.7;
+  else if (run == 3260)  thetadeg =  9.9;
+
+  else if (run == 3261)  thetadeg = 10.2;
+  else if (run == 3262)  thetadeg = 10.5;
+  else if (run == 3263)  thetadeg = 10.8;
+  else if (run == 3264)  thetadeg = 11.1;
+  else if (run == 3265)  thetadeg = 11.4;
+  else if (run == 3266)  thetadeg = 11.8;
+  else if (run == 3267)  thetadeg = 12.1;
+  else if (run == 3268)  thetadeg = 12.5;
+  else if (run == 3269)  thetadeg = 12.8;
+
+  else if (run == 3270)  thetadeg = 13.2;
+  else if (run == 3271)  thetadeg = 13.5;
+  else if (run == 3272)  thetadeg = 13.9;
+  else if (run == 3273)  thetadeg = 14.0;
+  else if (run == 3274)  thetadeg = 14.4;
+
+  else if (run == 3284)  thetadeg =  7.0;  // Crab
+  else if (run == 3285)  thetadeg =  7.2;
+  else if (run == 3286)  thetadeg =  7.4;
+  else if (run == 3287)  thetadeg =  7.5;
+  else if (run == 3288)  thetadeg =  8.4;
+  else if (run == 3289)  thetadeg =  9.0;
+
+  else if (run == 3290)  thetadeg =  9.4;
+  else if (run == 3291)  thetadeg =  9.8;
+  else if (run == 3292)  thetadeg = 10.2;
+  else if (run == 3293)  thetadeg = 10.5;
+  else if (run == 3294)  thetadeg = 10.9;
+  else if (run == 3295)  thetadeg = 11.3;
+  else if (run == 3296)  thetadeg = 11.8;
+  else if (run == 3297)  thetadeg = 12.2;
+  else if (run == 3298)  thetadeg = 12.6;
+  else if (run == 3299)  thetadeg = 13.0;
+
+  else if (run == 3300)  thetadeg = 13.5;
+  else if (run == 3301)  thetadeg = 13.9;
+  else if (run == 3302)  thetadeg = 14.3;
+  else if (run == 3303)  thetadeg = 14.8;
+  else if (run == 3304)  thetadeg = 15.2;
+  else if (run == 3305)  thetadeg = 15.7;
+  else if (run == 3306)  thetadeg = 16.2;
+  else if (run == 3307)  thetadeg = 16.6;
+  else if (run == 3308)  thetadeg = 17.1;
+  else if (run == 3309)  thetadeg = 17.6;
+
+  else if (run == 3310)  thetadeg = 17.9;
+  else if (run == 3311)  thetadeg = 18.4;
+  else if (run == 3312)  thetadeg = 18.9;
+  else if (run == 3313)  thetadeg = 19.3;
+  else if (run == 3314)  thetadeg = 19.8;
+  else if (run == 3315)  thetadeg = 20.1;
+  else if (run == 3316)  thetadeg = 20.7;
+  else if (run == 3317)  thetadeg = 21.2;
+  else if (run == 3318)  thetadeg = 21.7;
+  else if (run == 3319)  thetadeg = 22.1;
+
+  else if (run == 3320)  thetadeg = 22.5;
+  else if (run == 3321)  thetadeg = 23.1;
+  else if (run == 3322)  thetadeg = 23.6;
+  else if (run == 3323)  thetadeg = 24.1;
+  else if (run == 3324)  thetadeg = 24.6;
+  else if (run == 3325)  thetadeg = 24.9;
+  else if (run == 3326)  thetadeg = 25.5;
+  else if (run == 3327)  thetadeg = 26.0;
+  else if (run == 3328)  thetadeg = 26.0;
+  else if (run == 3329)  thetadeg = 26.6;
+
+  else if (run == 3330)  thetadeg = 26.6;
+  else if (run == 3331)  thetadeg = 27.1;
+  else if (run == 3332)  thetadeg = 27.7;
+  else if (run == 3333)  thetadeg = 28.2;
+  else if (run == 3334)  thetadeg = 28.5;
+
+  else if (run == 3340)  thetadeg = 10.5;
+  else if (run == 3341)  thetadeg = 10.3;
+  else if (run == 3342)  thetadeg =  9.6;
+  else if (run == 3343)  thetadeg =  9.2;
+  else if (run == 3344)  thetadeg =  8.9;
+  else if (run == 3345)  thetadeg =  8.6;
+  else if (run == 3346)  thetadeg =  8.3;
+  else if (run == 3347)  thetadeg =  8.0;
+  else if (run == 3348)  thetadeg =  7.7;
+  else if (run == 3349)  thetadeg =  7.5;
+
+  else if (run == 3350)  thetadeg =  7.2;
+  else if (run == 3351)  thetadeg =  7.0;
+  else if (run == 3352)  thetadeg =  6.8;
+  else if (run == 3353)  thetadeg =  6.7;
+  else if (run == 3354)  thetadeg =  6.6;
+  else if (run == 3355)  thetadeg =  6.5;
+  else if (run == 3356)  thetadeg =  6.4;
+  else if (run == 3357)  thetadeg =  6.4;
+  else if (run == 3358)  thetadeg =  6.4;
+  else if (run == 3359)  thetadeg =  6.5;
+
+  else if (run == 3360)  thetadeg =  6.6;
+
+  else if (run == 3362)  thetadeg =  6.7;
+  else if (run == 3363)  thetadeg =  6.8;
+  else if (run == 3364)  thetadeg =  7.0;
+  else if (run == 3365)  thetadeg =  7.2;
+  else if (run == 3366)  thetadeg =  7.5;
+  else if (run == 3367)  thetadeg =  7.7;
+  else if (run == 3368)  thetadeg =  8.0;
+  else if (run == 3369)  thetadeg =  8.3;
+
+  else if (run == 3370)  thetadeg =  8.6;
+  else if (run == 3371)  thetadeg =  9.0;
+  else if (run == 3372)  thetadeg =  9.3;
+  else if (run == 3373)  thetadeg =  9.6;
+  else if (run == 3374)  thetadeg = 10.0;
+  else if (run == 3375)  thetadeg = 10.4;
+  else if (run == 3376)  thetadeg = 10.7;
+  else if (run == 3377)  thetadeg = 11.1;
+  else if (run == 3378)  thetadeg = 11.5;
+  else if (run == 3379)  thetadeg = 11.9;
+
+  else if (run == 3380)  thetadeg = 12.3;
+  else if (run == 3381)  thetadeg = 12.7;
+  else if (run == 3382)  thetadeg = 13.1;
+  else if (run == 3383)  thetadeg = 13.5;
+  else if (run == 3384)  thetadeg = 13.9;
+  else if (run == 3385)  thetadeg = 14.3;
+  else if (run == 3386)  thetadeg = 14.7;
+  else if (run == 3387)  thetadeg = 15.2;
+  else if (run == 3388)  thetadeg = 15.6;
+  else if (run == 3389)  thetadeg = 16.0;
+
+  else if (run == 3390)  thetadeg = 16.4;
+  else if (run == 3391)  thetadeg = 16.7;
+  else if (run == 3392)  thetadeg = 17.9;
+  else if (run == 3393)  thetadeg = 18.3;
+  else if (run == 3394)  thetadeg = 18.7;
+  else if (run == 3395)  thetadeg = 19.2;
+  else if (run == 3396)  thetadeg = 19.6;
+  else if (run == 3397)  thetadeg = 20.0;
+  else if (run == 3398)  thetadeg = 20.5;
+  else if (run == 3399)  thetadeg = 20.9;
+
+  else if (run == 3400)  thetadeg = 21.4;
+  else if (run == 3401)  thetadeg = 21.8;
+  else if (run == 3402)  thetadeg = 22.1;
+  else if (run == 3403)  thetadeg = 22.6;
+  else if (run == 3404)  thetadeg = 23.1;
+  else if (run == 3405)  thetadeg = 23.4;
+  else if (run == 3406)  thetadeg = 23.9;
+  else if (run == 3407)  thetadeg = 24.3;
+  else if (run == 3408)  thetadeg = 24.7;
+  else if (run == 3409)  thetadeg = 26.9;
+
+  else if (run == 3410)  thetadeg = 27.3;
+  else if (run == 3411)  thetadeg = 27.7;
+  else if (run == 3412)  thetadeg = 28.2;
+  else if (run == 3413)  thetadeg = 28.7;
+  else if (run == 3414)  thetadeg = 29.1;
+  else if (run == 3415)  thetadeg = 29.2;
+  else if (run == 3416)  thetadeg = 30.0;
+  else if (run == 3417)  thetadeg = 18.5;  // Off Crab1
+  else if (run == 3418)  thetadeg = 18.4;
+  else if (run == 3419)  thetadeg = 17.5;
+
+  else if (run == 3420)  thetadeg = 17.2;
+  else if (run == 3421)  thetadeg = 16.8;
+  else if (run == 3422)  thetadeg = 16.4;
+  else if (run == 3423)  thetadeg = 16.0;
+  else if (run == 3424)  thetadeg = 15.6;
+  else if (run == 3425)  thetadeg = 15.3;
+  else if (run == 3426)  thetadeg = 14.9;
+  else if (run == 3427)  thetadeg = 14.5;
+  else if (run == 3428)  thetadeg = 14.1;
+  else if (run == 3429)  thetadeg = 13.7;
+
+  else if (run == 3430)  thetadeg = 13.4;
+  else if (run == 3431)  thetadeg = 13.0;
+  else if (run == 3432)  thetadeg = 12.7;
+  else if (run == 3433)  thetadeg = 12.3;
+  else if (run == 3434)  thetadeg = 12.0;
+  else if (run == 3435)  thetadeg = 12.0;
+  else if (run == 3436)  thetadeg = 11.6;
+  else if (run == 3437)  thetadeg = 11.3;
+  else if (run == 3438)  thetadeg = 11.0;
+  else if (run == 3439)  thetadeg = 10.7;
+
+  else if (run == 3440)  thetadeg = 10.4;
+  else if (run == 3441)  thetadeg = 10.1;
+  else if (run == 3442)  thetadeg =  9.9;
+  else if (run == 3443)  thetadeg =  9.8;
+  else if (run == 3444)  thetadeg = 30.8;  // Mkn 421
+  else if (run == 3445)  thetadeg = 30.6;
+  else if (run == 3446)  thetadeg = 29.7;
+  else if (run == 3447)  thetadeg = 29.3;
+  else if (run == 3448)  thetadeg = 28.9;
+  else if (run == 3449)  thetadeg = 28.5;
+
+  else if (run == 3450)  thetadeg = 28.1;
+  else if (run == 3451)  thetadeg = 27.7;
+  else if (run == 3452)  thetadeg = 27.3;
+  else if (run == 3453)  thetadeg = 26.9;
+  else if (run == 3454)  thetadeg = 26.5;
+  else if (run == 3455)  thetadeg = 26.1;
+  else if (run == 3456)  thetadeg = 25.7;
+  else if (run == 3457)  thetadeg = 25.3;
+  else if (run == 3458)  thetadeg = 24.9;
+  else if (run == 3459)  thetadeg = 24.5;
+
+  else if (run == 3460)  thetadeg = 24.1;
+
+  else if (run == 3463)  thetadeg = 23.2;
+  else if (run == 3464)  thetadeg = 22.8;
+  else if (run == 3465)  thetadeg = 22.4;
+  else if (run == 3466)  thetadeg = 22.0;
+  else if (run == 3467)  thetadeg = 21.6;
+  else if (run == 3468)  thetadeg = 21.2;
+  else if (run == 3469)  thetadeg = 20.8;
+
+  else if (run == 3470)  thetadeg = 20.4;
+  else if (run == 3471)  thetadeg = 20.1;
+  else if (run == 3472)  thetadeg = 19.7;
+  else if (run == 3473)  thetadeg = 19.3;
+  else if (run == 3474)  thetadeg = 18.9;
+  else if (run == 3475)  thetadeg = 18.5;
+  else if (run == 3476)  thetadeg = 18.2;
+  else if (run == 3477)  thetadeg = 18.1;
+  else if (run == 3478)  thetadeg = 17.7;
+
+
+  else if (run == 3480)  thetadeg = 17.5;
+  else if (run == 3481)  thetadeg = 17.1;
+  else if (run == 3482)  thetadeg = 16.7;
+  else if (run == 3483)  thetadeg = 16.3;
+  else if (run == 3484)  thetadeg = 16.0;
+  else if (run == 3485)  thetadeg = 15.6;
+  else if (run == 3486)  thetadeg = 15.3;
+  else if (run == 3487)  thetadeg = 15.0;
+  else if (run == 3488)  thetadeg = 14.8;
+  else if (run == 3489)  thetadeg = 14.8;
+  
+  else
+  {
+    *fLog << warn << "MPedestalWorkaround : no zenith angle for run number = "
+          << run << endl;
+    thetadeg = 90.0;
+  }
+
+  thetarad = thetadeg / kRad2Deg;
+  */
+
+  thetadeg = 10.0;
+  thetarad = thetadeg / kRad2Deg;
+  fMcEvt->SetTelescopeTheta(thetarad);
+  
+  return kTRUE;
+}
+
+Int_t MPedestalWorkaround::PostProcess()
+{
+    return kTRUE;
+}
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MPedestalWorkaround.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MPedestalWorkaround.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MPedestalWorkaround.h	(revision 9661)
@@ -0,0 +1,47 @@
+#ifndef MARS_MPedestalWorkaround
+#define MARS_MPedestalWorkaround
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MPedestalWorkaround                                                     //
+//                                                                         //
+// Temporary copy of pedestal values and RMS into MPedestalCam from        //
+// MPedPhotCam in order to have the pedestal RMS in units of number of     // 
+// photons                                                                  //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MPedestalCam;
+class MPedPhotCam;
+class MGeomCam;
+class MParList;
+class MMcEvt;
+class MRawRunHeader;
+
+class MPedestalWorkaround : public MTask 
+{
+private:
+
+    MPedestalCam  *fPed;  
+    MPedPhotCam   *fPedPhot; 
+    MGeomCam      *fCam;  
+    MMcEvt        *fMcEvt;
+    MRawRunHeader *fRun;  
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
+public:
+    MPedestalWorkaround(const char *name=NULL, const char *title=NULL);
+
+    ClassDef(MPedestalWorkaround, 0) // Task to copy pedestal RMS
+};
+
+#endif
+
+
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MPointingCorr.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MPointingCorr.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MPointingCorr.cc	(revision 9661)
@@ -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  03/2003 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//  MPointingCorr                                                          //
+//                                                                         //
+//  This is a task to do the pointing correction                           //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MPointingCorr.h"
+
+#include "MParList.h"
+
+#include "MMcEvt.hxx"
+#include "MSrcPosCam.h"
+#include "MGeomCam.h"
+#include "MParameters.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MPointingCorr);
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MPointingCorr::MPointingCorr(const char *name, const char *title,
+                             const char *srcname)
+{
+    fName  = name  ? name  : "MPointingCorr";
+    fTitle = title ? title : "Task to do the pointing correction";
+
+    fSrcName = srcname;
+}
+
+// --------------------------------------------------------------------------
+//
+// 
+// 
+// 
+//
+Int_t MPointingCorr::PreProcess(MParList *pList)
+{
+    MGeomCam *geom = (MGeomCam*)pList->FindObject("MGeomCam");
+    if (!geom)
+        *fLog << warn << GetDescriptor() << ": No Camera Geometry available. Using mm-scale for histograms." << endl;
+    else
+    {
+        fMm2Deg = geom->GetConvMm2Deg();
+    }
+
+
+    fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
+    if (!fMcEvt)
+    {
+        *fLog << dbginf << "MMcEvt not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fHourAngle = (MParameterD*)pList->FindObject("HourAngle", "MParameterD");
+    if (!fHourAngle)
+    {
+        *fLog << dbginf << "HourAngle 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;
+    }
+
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Do the pointing correction
+//
+// the parametrization is for Mkn421 2001 data (Daniel Kranich)
+// 
+Int_t MPointingCorr::Process()
+{
+   // fhourangle is the hour angle [degrees]
+   // (cx, cy) is the source position in the camera [mm]
+   //
+   Float_t fhourangle = fHourAngle->GetVal();
+
+   //*fLog << "MPointingCorr::Process; fhourangle = " 
+   //      << fhourangle << endl;
+
+   Float_t cx = -0.05132 - 0.001064 * fhourangle 
+                         - 3.530e-6 * fhourangle * fhourangle;
+   cx /= fMm2Deg;
+
+   Float_t cy = -0.04883 - 0.0003175* fhourangle
+                         - 2.165e-5 * fhourangle * fhourangle;
+   cy /= fMm2Deg;
+
+   fSrcPos->SetXY(cx, cy);
+
+   //*fLog << "MPointingCorr::Process; fhourangle, cx, cy, fMm2Deg = "
+   //      << fhourangle << ",  " << cx << ",  " << cy << ",  " 
+   //      << fMm2Deg << endl;
+
+   return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/manalysis/MPointingCorr.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MPointingCorr.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MPointingCorr.h	(revision 9661)
@@ -0,0 +1,40 @@
+#ifndef MARS_MPointingCorr
+#define MARS_MPointingCorr
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MPointingCorr                                                           //
+//                                                                         //
+// Task to do the pointing correction                                      //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MMcEvt;
+class MSrcPosCam;
+class MParameterD;
+
+class MPointingCorr : public MTask
+{
+private:
+    MMcEvt       *fMcEvt;       
+    MSrcPosCam   *fSrcPos;
+    TString       fSrcName;
+    MParameterD  *fHourAngle;
+
+    Float_t       fMm2Deg;
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
+public:
+    MPointingCorr(const char *name=NULL, const char *title=NULL,
+                  const char *srcname="MSrcPosCam");
+
+    ClassDef(MPointingCorr, 0)   // Task to do the pointing correction
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/manalysis/MSigmabar.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MSigmabar.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MSigmabar.cc	(revision 9661)
@@ -0,0 +1,260 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Robert Wagner,   10/2002 <mailto:magicsoft@rwagner.de>
+!   Author(s): Wolfgang Wittek, 01/2003 <mailto:wittek@mppmu.mpg.de>
+!   Author(s): Thomas Bretz,    04/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MSigmabar                                                               //
+//                                                                         //
+// This is the storage container to hold information about                 //
+// "average" pedestal sigmas                                               //
+//                                                                         //
+// In calculating averages all sigmas are normalized to the area of pixel 0//
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MSigmabar.h"
+
+#include <TMath.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MGeomCam.h"
+#include "MGeomPix.h"
+
+#include "MCerPhotEvt.h"
+#include "MCerPhotPix.h"
+
+#include "MPedPhotCam.h"
+#include "MPedPhotPix.h"
+
+ClassImp(MSigmabar);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+MSigmabar::MSigmabar(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MSigmabar";
+    fTitle = title ? title : "Storage container for Sigmabar";
+}
+
+// --------------------------------------------------------------------------
+//
+MSigmabar::~MSigmabar()
+{
+  // do nothing special.
+}
+
+void MSigmabar::Reset()
+{
+    fSigmabar      = -1;
+    fInnerPixels   = -1;
+    fOuterPixels   = -1;
+    fSigmabarInner = -1;
+    fSigmabarOuter = -1;
+
+    memset(fSigmabarSector, 0, sizeof(fSigmabarSector));
+    memset(fSigmabarInnerSector, 0, sizeof(fSigmabarInnerSector));
+    memset(fSigmabarOuterSector, 0, sizeof(fSigmabarOuterSector));
+}
+
+// --------------------------------------------------------------------------
+//
+// Actual calculation of sigmabar. This is done for each of the six sectors
+// separately due to their possibly different HV behavior. Also inner and
+// outer pixels are treated separately.
+//
+// Preliminary! Works for CT1 test, for real MAGIC crosschecks still have
+// to be done. Also implementation details will be updated, like 
+// determination of sector to which a respective pixel belongs
+//
+Float_t MSigmabar::Calc(const MGeomCam &geom, const MPedPhotCam &ped, 
+                        const MCerPhotEvt &evt)
+{
+    Int_t innerPixels[6];
+    Int_t outerPixels[6];
+    Float_t innerSum[6];
+    Float_t outerSum[6];
+
+    memset(innerPixels, 0, sizeof(innerPixels));
+    memset(outerPixels, 0, sizeof(outerPixels));
+    memset(innerSum, 0, sizeof(innerSum));
+    memset(outerSum, 0, sizeof(outerSum));
+
+    //
+    // sum up sigma/sqrt(area) for each sector, 
+    // separately for inner and outer region;
+    //
+    // consider all pixels with Cherenkov photon information
+    // and require "Used"
+    //
+
+    const UInt_t npix = evt.GetNumPixels();
+
+    //*fLog << "MSigmabar : npix = " << npix << endl;
+
+    for (UInt_t i=0; i<npix; i++)
+    {
+        MCerPhotPix &cerpix = evt.operator[](i);
+        if (!cerpix.IsPixelUsed())
+            continue;
+
+	/*
+         if ( cerpix.GetNumPhotons() == 0 )
+         {
+         *fLog << "MSigmabar::Calc(); no.of photons is 0 for used pixel"
+         << endl;
+         continue;
+         }
+	*/
+
+        const Int_t idx = cerpix.GetPixId();
+        if (idx == 0)
+	{
+          //*fLog << "MSigmabar : id = 0;  pixel '0' is used, ignore it" 
+	  //      << endl;
+          continue;
+        }
+
+        // ratio is the area of pixel 0
+        //          divided by the area of the current pixel
+        const Double_t ratio = geom.GetPixRatio(idx);
+
+        const MGeomPix &gpix = geom[idx];
+
+        // This is wrong : rounding has to be done on positive values
+        //Int_t sector = (Int_t)(atan2(gpix.GetY(),gpix.GetX())*6 
+        //               / (TMath::Pi()*2));
+        //if (sector<0)
+        //    sector+=6;
+
+        Float_t sectorf = atan2(gpix.GetY(),gpix.GetX()) * 6.0 
+                          / (TMath::Pi()*2);
+        if (sectorf < 0.0)
+          sectorf += 6.0;
+        Int_t sector = (Int_t)sectorf;
+
+        // count only those pixels which have a sigma != 0.0
+        const Float_t sigma = ped[idx].GetRms();
+
+        if ( sigma <= 0 )
+            continue;
+
+        //if (area < 1.5)
+        if (ratio > 0.5)
+        {
+            innerPixels[sector]++;
+            innerSum[sector]+= sigma * sqrt(ratio);
+        }
+        else
+        {
+            outerPixels[sector]++;
+            outerSum[sector]+= sigma * sqrt(ratio);
+        }
+    }
+
+    fInnerPixels   = 0;
+    fOuterPixels   = 0;
+    Double_t fSumInner = 0;
+    Double_t fSumOuter = 0;
+    for (UInt_t i=0; i<6; i++)
+    {
+        fSumInner      += innerSum[i];
+        fInnerPixels   += innerPixels[i];
+        fSumOuter      += outerSum[i];
+        fOuterPixels   += outerPixels[i];
+    }
+
+    if (fInnerPixels > 0) fSigmabarInner = fSumInner / fInnerPixels;
+    if (fOuterPixels > 0) fSigmabarOuter = fSumOuter / fOuterPixels;
+
+    //
+    // this is the average sigma/sqrt(area) (over all pixels)
+    //
+    fSigmabar = (fInnerPixels+fOuterPixels)<=0 ? 0:
+                (fSumInner+fSumOuter)/(fInnerPixels+fOuterPixels);
+
+    for (UInt_t i=0; i<6; i++)
+    {
+        const Double_t ip  = innerPixels[i];
+        const Double_t op  = outerPixels[i];
+        const Double_t iss = innerSum[i];
+        const Double_t oss = outerSum[i];
+
+        const Double_t sum = ip + op;
+        fSigmabarInnerSector[i] = ip <=0 ? 0 :       iss/ip;
+        fSigmabarOuterSector[i] = op <=0 ? 0 :       oss/op;
+        fSigmabarSector[i]      = sum<=0 ? 0 : (iss+oss)/sum;
+    }
+
+    //TString opt = "";
+    //Print(opt);
+
+  return fSigmabar;
+}
+
+// --------------------------------------------------------------------------
+//
+void MSigmabar::Print(Option_t *) const
+{
+  *fLog << all << endl;
+  *fLog << "Total number of inner pixels is " << fInnerPixels << endl;
+  *fLog << "Total number of outer pixels is " << fOuterPixels << endl;
+  *fLog << endl;
+
+  *fLog << "Sigmabar     Overall : " << fSigmabar << "   ";
+  *fLog << " Sectors: ";
+  for (Int_t i=0;i<6;i++)
+      *fLog << fSigmabarSector[i] << ", ";
+  *fLog << endl;
+
+
+  *fLog << "Sigmabar     Inner   : " << fSigmabarInner << "   ";
+  *fLog << " Sectors: ";
+  for (Int_t i=0;i<6;i++)
+      *fLog << fSigmabarInnerSector[i] << ", ";
+  *fLog << endl;
+
+
+  *fLog << "Sigmabar     Outer   : " << fSigmabarOuter << "   ";
+  *fLog << " Sectors: ";
+  for (Int_t i=0;i<6;i++)
+      *fLog << fSigmabarOuterSector[i] << ", ";
+  *fLog << endl;
+
+}
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MSigmabar.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MSigmabar.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MSigmabar.h	(revision 9661)
@@ -0,0 +1,56 @@
+#ifndef MARS_MSigmabar
+#define MARS_MSigmabar
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MGeomCam;
+class MParList;
+class MCerPhotEvt;
+class MPedPhotCam;
+
+class MSigmabar : public MParContainer
+{
+private:
+    Float_t fSigmabar;          // Sigmabar ("average" RMS) of pedestal
+    Float_t fSigmabarInner;     // --only for inner pixels
+    Float_t fSigmabarOuter;     // --only for outer pixels  
+
+    Float_t fSigmabarSector[6]; // --for the 6 sectors of the camera
+    Float_t fSigmabarInnerSector[6];
+    Float_t fSigmabarOuterSector[6];
+
+    Int_t  fInnerPixels;       // Overall number of inner pixels
+    Int_t  fOuterPixels;       // Overall number of outer pixels
+
+public:
+    MSigmabar(const char *name=NULL, const char *title=NULL);
+    ~MSigmabar();
+    
+    void Reset();
+
+    void Print(Option_t *) const;
+ 
+    Float_t GetSigmabar() const       { return fSigmabar;       }
+    Float_t GetSigmabarInner() const  { return fSigmabarInner;  }
+    Float_t GetSigmabarOuter() const  { return fSigmabarOuter;  }
+    Float_t GetSigmabarSector(const Int_t sector) const 
+                              { return fSigmabarSector[sector]; } 
+  
+    //   void SetSigmabar(Float_t f, Float_t i, Float_t o) 
+    //      { fSigmabar = f; fSigmabarInner = i; fSigmabarOuter = o; }
+    //    void SetSigmabarInner(Float_t f) { fSigmabarInner = f; }
+    //    void SetSigmabarOuter(Float_t f) { fSigmabarOuter = f; }   
+
+    Float_t Calc(const MGeomCam &geom, const MPedPhotCam &ped, const MCerPhotEvt &evt);
+      
+    ClassDef(MSigmabar, 1)  // Storage Container for Sigmabar
+};
+
+#endif
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MSigmabarCalc.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MSigmabarCalc.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MSigmabarCalc.cc	(revision 9661)
@@ -0,0 +1,186 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Robert Wagner, 10/2002 <rwagner@mppmu.mpg.de>
+!   Author(s): Thomas Bretz, 4/2003 <tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MSigmabarCalc
+//
+//  This task calculates Sigmabar using the MSigmabar container and stores
+//  its extremal values together with the corresponding Theta values       
+//  in MSigmabarParam. For the time being, Theta is taken from a Monte
+//  Carlo container. This is preliminary and to be changed ASAP.
+//
+//  Input Containers:
+//   MGeomCam
+//   MPedPhotCam
+//   MRawRunHeader
+//   MMcEvt  (FIXME: Must be replaced by a 'real-data' container)
+//   MCerPhotEvt
+//
+//  Output Containers:
+//   MSigmabar
+//   MSigmabarParam
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MSigmabarCalc.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MGeomCam.h"
+#include "MPedPhotCam.h"
+
+#include "MSigmabar.h"
+#include "MSigmabarParam.h"
+
+#include "MMcEvt.hxx"
+
+ClassImp(MSigmabarCalc);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+MSigmabarCalc::MSigmabarCalc(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MSigmabarCalc";
+    fTitle = title ? title : "Task to calculate Sigmabar";
+
+    Reset();
+}
+
+// --------------------------------------------------------------------------
+//
+//  check if necessary containers exists in the Parameter list already.
+//  if not create one and add them to the list
+//
+Int_t MSigmabarCalc::PreProcess(MParList *pList)
+{
+    fCam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
+    if (!fCam)
+    {
+        *fLog << err << "MGeomCam not found (no geometry information available)... aborting." << endl;
+        return kFALSE;
+    }
+
+    fPed = (MPedPhotCam*)pList->FindObject(AddSerialNumber("MPedPhotCam"));
+    if (!fPed)
+    {
+        *fLog << err << "MPedPhotCam not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fRun = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
+    if (!fRun)
+    {
+        *fLog << err << "MRawRunHeader not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    // This is needed for determining min/max Theta
+    fMcEvt = (MMcEvt*)pList->FindObject(AddSerialNumber("MMcEvt"));
+    if (!fMcEvt)
+    {
+        *fLog << warn << "MMcEvt not found... aborting." << endl;
+        fThetaMin =  0;
+        fThetaMax = 90;
+    }
+
+    fEvt = (MCerPhotEvt*)pList->FindObject(AddSerialNumber("MCerPhotEvt"));
+    if (!fEvt)
+      {
+	*fLog << err << "MCerPhotEvt not found... aborting." << endl;
+	return kFALSE;
+      }
+
+    fSig = (MSigmabar*)pList->FindCreateObj(AddSerialNumber("MSigmabar"));
+    if (!fSig)
+        return kFALSE;
+
+    // FIXME: This might have to change in a
+    //        'more-than-one-telescope-environment'
+    fSigParam = (MSigmabarParam*)pList->FindCreateObj(AddSerialNumber("MSigmabarParam"));
+    if (!fSigParam)
+        return kFALSE;
+
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculating a new Sigmabar is not necessary on event basis as long as
+// we deal with CT1 data. Therefore, the real calculation is done in
+// the ReInit function. Process just takes care for finding the extremal
+// values. Preliminary.
+//
+Int_t MSigmabarCalc::Process()
+{
+    const Double_t rc = fSig->Calc(*fCam, *fPed, *fEvt);
+
+    if (rc>fSigmabarMax) fSigmabarMax=rc;
+    if (rc<fSigmabarMin) fSigmabarMin=rc;
+
+    if (!fMcEvt)
+        return kTRUE;
+
+    const Double_t theta = fMcEvt->GetTelescopeTheta()*kRad2Deg;
+
+    if (theta>fSigmabarMax) fSigmabarMax=theta;
+    if (theta<fSigmabarMax) fSigmabarMin=theta;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculates Sigmabar (for CT1 only needed at Reinit, i.e. when reading
+// a new file)
+//
+Bool_t MSigmabarCalc::ReInit(MParList *pList)
+{
+    fSigParam->SetParams(1, fSigmabarMin, fSigmabarMax, fThetaMin, fThetaMax);
+    fSigParam->SetRunNumber(fRun->GetRunNumber());
+
+    Reset();
+
+    return kTRUE;
+}
+
+void MSigmabarCalc::Reset()
+{
+    if (!fMcEvt)
+        return;
+
+    fThetaMin    = FLT_MAX;
+    fThetaMax    = 0;
+    fSigmabarMin = FLT_MAX;
+    fSigmabarMax = 0;
+}
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MSigmabarCalc.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MSigmabarCalc.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MSigmabarCalc.h	(revision 9661)
@@ -0,0 +1,64 @@
+#ifndef MARS_MSigmabarCalc
+#define MARS_MSigmabarCalc
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+#ifndef MARS_MGeomCam
+#include "MGeomCam.h"
+#endif
+
+#ifndef MARS_MMcEvt
+#include "MMcEvt.hxx"
+#endif
+
+#ifndef MARS_MPedPhotCam
+#include "MPedPhotCam.h"
+#endif
+
+#ifndef MARS_MSigmabar
+#include "MSigmabar.h"
+#endif
+
+#ifndef MARS_MSigmabarParam
+#include "MSigmabarParam.h"
+#endif
+
+#ifndef MARS_MRawRunHeader
+#include "MRawRunHeader.h"
+#endif
+
+class MSigmabarCalc : public MTask
+{
+private:
+    MMcEvt         *fMcEvt;
+    MCerPhotEvt    *fEvt;
+    MGeomCam       *fCam;
+    MPedPhotCam   *fPed;
+    MRawRunHeader  *fRun;
+    MSigmabar      *fSig;
+    MSigmabarParam *fSigParam;
+
+    Double_t fSigmabarMin; // Parametrization
+    Double_t fSigmabarMax;
+    Double_t fThetaMin;
+    Double_t fThetaMax;
+
+    void Reset();
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
+    Bool_t ReInit(MParList *pList);
+
+public:
+    MSigmabarCalc(const char *name=NULL, const char *title=NULL);
+
+    ClassDef(MSigmabarCalc, 0) // task for calculating sigmabar
+}; 
+
+#endif
+
+
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MSigmabarParam.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MSigmabarParam.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MSigmabarParam.cc	(revision 9661)
@@ -0,0 +1,82 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Robert Wagner  10/2002 <mailto:magicsoft@rwagner.de>
+!
+!   Copyright: MAGIC Software Development, 2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MSigmabarParam                                                          //
+//                                                                         //
+// Storage Container for parameters characterizing a distribution of       //
+// events in the Sigmabar-Theta plane                                      //
+//                                                                         //
+// For CT1 tests, we just store Sigmabar_max, Sigmabar_min, Theta_max,     //
+// Theta_min. Later MJD and perhaps more than two points on the            //
+// distribution might follow.                                              //
+//                                                                         //
+//  This implementation is still PRELIMINARY and requires some workarounds //
+//  put in SPECIFICALLY FOR THE CT1 TESTS, since a database to access is   //
+//  missing. It is not the FINAL MAGIC VERSION.                            //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MSigmabarParam.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MSigmabarParam);
+
+using namespace std;
+
+MSigmabarParam::MSigmabarParam(const char *name, const char *title) : fSigmabarMin(0), fSigmabarMax(0), fMjdMin(0), fMjdMax(0), fThetaMin(0), fThetaMax(0), fRunNumber(0)
+{
+    fName  = name  ? name  : "MSigmabarParam";
+    fTitle = title ? title : "Storage container for characterizing a distribution of events in the Sigmabar-Theta plane";      
+}
+
+MSigmabarParam::~MSigmabarParam()
+{
+  // nothing special yet
+}
+
+void MSigmabarParam::SetRunNumber(Int_t r)
+{
+  fRunNumber = r;
+}
+
+void MSigmabarParam::SetParams(Int_t r, Double_t si, Double_t sx, Double_t ti, Double_t tx, Double_t mi, Double_t mx)
+{
+  fSigmabarMin = si;
+  fSigmabarMax = sx;
+  fThetaMin = ti;
+  fThetaMax = tx;
+  fMjdMin = mi;
+  fMjdMax = mx;
+  //fRunNumber = r;
+}
+
+void MSigmabarParam::Print(Option_t *) const
+{
+  *fLog << endl << "Run " << fRunNumber << " | " 
+       << "Sigmabar Min, Max: " << fSigmabarMin << " " << fSigmabarMax 
+       << "| Theta Min, Max: " << fThetaMin << " " << fThetaMax << endl;
+}
Index: /tags/Mars_V0-8-5/Mars/manalysis/MSigmabarParam.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MSigmabarParam.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MSigmabarParam.h	(revision 9661)
@@ -0,0 +1,42 @@
+#ifndef MARS_MSigmabarParam
+#define MARS_MSigmabarParam
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MSigmabarParam : public MParContainer
+{
+private:
+  Double_t fSigmabarMin;
+  Double_t fSigmabarMax;
+  Double_t fMjdMin;
+  Double_t fMjdMax;
+  Double_t fThetaMin;
+  Double_t fThetaMax;
+  Int_t    fRunNumber;
+
+public:
+  
+  MSigmabarParam(const char *name=NULL, const char *title=NULL);
+  ~MSigmabarParam();
+  
+  //  void Print(Option_t *) const;
+
+  void SetRunNumber(Int_t r);
+  
+  void SetParams(Int_t r, Double_t si, Double_t sx, Double_t ti, Double_t tx, Double_t mi=0, Double_t mx=0);
+
+  Double_t GetSigmabarMin() const { return fSigmabarMin; }
+  Double_t GetSigmabarMax() const { return fSigmabarMax; }
+  Double_t GetThetaMin() const { return fThetaMin; }
+  Double_t GetThetaMax() const { return fThetaMax; }
+
+  void Print(Option_t *o="") const;
+      
+  ClassDef(MSigmabarParam, 1)  // Storage container for characterizing a distribution of events in the Sigmabar-Theta plane
+
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MSourcePosfromStarPos.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MSourcePosfromStarPos.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MSourcePosfromStarPos.cc	(revision 9661)
@@ -0,0 +1,865 @@
+
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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 02/2004 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MSourcePosfromStarPos
+//
+//  This is a task which
+//  - calculates the position of the source in the camera
+//    from the position of a known star in the camera
+//  - and puts the source position into the container MSrcPosCam
+//
+//  Input :
+//   ASCII file containing for each run 
+//   - the run number
+//   - the direction (theta, phi) the telescope is pointing to in [deg]
+//   - the position  (xStar, yStar)   of a known star in the camera in [mm]
+//   - the error     (dxStar, dyStar) of this position in [mm]
+//
+//  Output Containers :
+//   MSrcPosCam
+//
+/////////////////////////////////////////////////////////////////////////////
+#include <TList.h>
+#include <TSystem.h>
+#include <TMatrixD.h>
+
+#include <fstream>
+
+#include "MSourcePosfromStarPos.h"
+
+#include "MParList.h"
+#include "MRawRunHeader.h"
+#include "MGeomCam.h"
+#include "MSrcPosCam.h"
+#include "MPointingPos.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+#include "MObservatory.h"
+
+ClassImp(MSourcePosfromStarPos);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MSourcePosfromStarPos::MSourcePosfromStarPos(
+                                         const char *name, const char *title)
+  : fIn(NULL)
+{
+    fName  = name  ? name  : "MSourcePosfromStarPos";
+    fTitle = title ? title : "Calculate source position from star position";
+
+    fFileNames = new TList;
+    fFileNames->SetOwner();
+
+    fRuns  = 0;
+    fSize  = 100;
+
+    fRunNr.Set(fSize);
+
+    fThetaTel.Set(fSize);
+    fPhiTel.Set(fSize);
+    fdThetaTel.Set(fSize);
+    fdPhiTel.Set(fSize);
+
+    Int_t fRows = 1;
+    fDecStar.Set(fRows);
+    fRaStar.Set(fRows);
+    fxStar.ResizeTo(fRows,fSize);
+    fyStar.ResizeTo(fRows,fSize);
+    fdxStar.ResizeTo(fRows,fSize);
+    fdyStar.ResizeTo(fRows,fSize);
+
+    fStars = 0;
+    fDecSource = 0.0;
+    fRaSource  = 0.0;
+
+    // these are the default values when starting the excution;
+    // later these locations contain the values of the last event
+    fxSourceold  =  25.0;
+    fySourceold  = -40.0;
+    fThetaradold =  25.0/kRad2Deg;
+    fPhiradold   = 180.0/kRad2Deg;
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the filename list and the input stream if one exists.
+//
+MSourcePosfromStarPos::~MSourcePosfromStarPos()
+{
+    delete fFileNames;
+    if (fIn)
+        delete fIn;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Set the sky coordinates of the source and of the star
+//
+// Input :
+// declination in units of     (Deg,  Min, Sec)
+// right ascension in units of (Hour, Min, Sec)
+//
+
+void MSourcePosfromStarPos::SetSourceAndStarPosition(
+	 TString  nameSource,
+	 Double_t decSourceDeg, Double_t decSourceMin, Double_t decSourceSec, 
+         Double_t raSourceHour, Double_t raSourceMin,  Double_t raSourceSec,
+	 TString nameStar,
+	 Double_t decStarDeg,   Double_t decStarMin,   Double_t decStarSec, 
+         Double_t raStarHour,   Double_t raStarMin,    Double_t raStarSec  )
+{
+  *fLog << "MSourcePosfromStarPos::SetSourceAndStarPosition :" << endl;
+  *fLog << "       Source (dec) : "  << nameSource << "   " << decSourceDeg << ":" 
+        << decSourceMin << ":" << decSourceSec << endl;
+  *fLog << "       Source (ra)  : "  << nameSource  << "   " << raSourceHour << ":" 
+        << raSourceMin  << ":" << raSourceSec << endl;
+
+  *fLog << "       Star  (dec) : "  << nameStar   << "   " << decStarDeg << ":" 
+        << decStarMin << ":"   << decStarSec << endl;
+  *fLog << "       Star  (ra)  : "  << nameStar   << "   " << raStarHour << ":" 
+        << raStarMin << ":"    << raStarSec  << endl;
+
+  // convert into radians
+  fDecSource = (decSourceDeg + decSourceMin/60.0 + decSourceSec/3600.0)
+               / kRad2Deg;
+  fRaSource  = (raSourceHour + raSourceMin/60.0  + raSourceSec/3600.0)
+               * 360.0 / (24.0 * kRad2Deg);
+
+  fStars += 1;
+  fDecStar.Set(fStars);
+  fRaStar.Set(fStars);
+  fxStar.ResizeTo(fStars,fSize);
+  fyStar.ResizeTo(fStars,fSize);
+  fdxStar.ResizeTo(fStars,fSize);
+  fdyStar.ResizeTo(fStars,fSize);
+
+  fDecStar[fStars-1] = (decStarDeg + decStarMin/60.0 + decStarSec/3600.0)
+                       / kRad2Deg;
+  fRaStar[fStars-1]  = (raStarHour + raStarMin/60.0  + raStarSec/3600.0)
+                       * 360.0 / (24.0 * kRad2Deg);
+
+  *fLog << all << "MSourcePosfromStarPos::SetSourceAndStarPosition; fStars = "
+        << fStars << endl;
+  *fLog << all << "       fDecSource, fRaSource, fDecStar, fRaStar were set to : [radians]  "
+        << fDecSource << ",  " << fRaSource << ",  "
+        << fDecStar[fStars-1] << ",  " << fRaStar[fStars-1] << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the sky coordinates of another star
+//
+// Input :
+// declination in units of     (Deg,  Min, Sec)
+// right ascension in units of (Hour, Min, Sec)
+//
+
+void MSourcePosfromStarPos::AddStar(
+	 TString nameStar,
+	 Double_t decStarDeg,   Double_t decStarMin,   Double_t decStarSec, 
+         Double_t raStarHour,   Double_t raStarMin,    Double_t raStarSec  )
+{
+  *fLog << "MSourcePosfromStarPos::AddStar :" << endl;
+  *fLog << "       Star (dec)  : "  << nameStar   << "   " << decStarDeg << ":" 
+        << decStarMin << ":"   << decStarSec << endl;
+  *fLog << "       Star (ra)   : "  << nameStar   << "   " << raStarHour << ":" 
+        << raStarMin << ":"    << raStarSec  << endl;
+
+  // convert into radians
+  fStars += 1;
+  fDecStar.Set(fStars);
+  fRaStar.Set(fStars);
+  fxStar.ResizeTo(fStars,fSize);
+  fyStar.ResizeTo(fStars,fSize);
+  fdxStar.ResizeTo(fStars,fSize);
+  fdyStar.ResizeTo(fStars,fSize);
+
+  fDecStar[fStars-1] = (decStarDeg + decStarMin/60.0 + decStarSec/3600.0)
+                       / kRad2Deg;
+  fRaStar[fStars-1]  = (raStarHour + raStarMin/60.0  + raStarSec/3600.0)
+                       * 360.0 / (24.0 * kRad2Deg);
+
+  *fLog << all << "MSourcePosfromStarPos::AddStar; fStars = " << fStars 
+        << endl;
+  *fLog << all << "       fDecStar, fRaStar were set to : [radians]  "
+        << fDecStar[fStars-1] << ",  " << fRaStar[fStars-1] << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+//
+Int_t MSourcePosfromStarPos::PreProcess(MParList *pList)
+{
+    MGeomCam *geom = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
+    if (!geom)
+    {
+        *fLog << err << "MSourcePosfromStarPos : MGeomCam (Camera Geometry) missing in Parameter List... aborting." << endl;
+        return kFALSE;
+    }
+    fMm2Deg = geom->GetConvMm2Deg();
+    // fDistCameraReflector is the distance of the camera from the reflector center in [mm]
+    fDistCameraReflector = kRad2Deg / fMm2Deg;   
+        *fLog << all << "MSourcePosfromStarPos::PreProcess; fMm2Deg, fDistCameraReflector = " 
+              << fMm2Deg << ",  " << fDistCameraReflector << endl;
+
+    fObservatory = (MObservatory*)pList->FindObject(AddSerialNumber("MObservatory"));
+    if (!fObservatory)
+    {
+        *fLog << err << "MObservatory not found...  aborting" << endl;
+        return kFALSE;
+    }
+
+    fRun = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
+    if (!fRun)
+    {
+        *fLog << err << "MSourcePosfromStarPos::PreProcess; MRawRunHeader not found... aborting." << endl;
+        return kFALSE;
+    }
+
+
+
+   fPointPos = (MPointingPos*)pList->FindCreateObj("MPointingPos");
+   if (!fPointPos)
+   {
+       *fLog << err << "MSourcePosfromStarPos::PreProcess; MPointingPos not found... aborting." << endl;
+       return kFALSE;
+   }
+
+
+    fSrcPos = (MSrcPosCam*)pList->FindObject(AddSerialNumber("MSrcPosCam"));
+    if (!fSrcPos)
+    {
+        *fLog << err << "MSourcePosfromStarPos::PreProcess; MSrcPosCam not found...  aborting" << endl;
+        return kFALSE;
+    }
+
+    //---------------------------------------------------------------------
+    // read all files and call ReadData() to read and store the information
+    //
+
+    *fLog << all << "---------------------------------" << endl;
+    while(1)
+    {
+      if (!OpenNextFile()) 
+      {
+        *fLog << "there is no more file to open" << endl;
+        break;
+      }
+
+      *fLog << "read data" << endl;
+
+      // read "fStarsRead" = no.of (x,y) pairs to be read
+      *fIn >> fStarsRead;
+
+      while (1)
+      {
+        if (fIn->eof())
+        {
+          *fLog << "eof encountered; open next file" << endl;
+
+          if (!OpenNextFile()) break;
+        }
+
+        // FIXME! Set InputStreamID
+      
+        ReadData();
+      }
+    }
+
+    *fLog << "all data were read" << endl;
+    FixSize();
+
+    if (fDecSource == 0.0  ||  fRaSource == 0.0  ||  fStars == 0) 
+    {
+      *fLog << warn << "MSourcePosfromStarPos::PreProcess; there are no sky coordinates defined for the source or from stars; fStars, fStarsRead = " 
+            << fStars << ",  " << fStarsRead 
+            << endl;
+    }
+    *fLog << all << "---------------------------------" << endl;
+
+    //-------------------------------------------------------------
+
+    return kTRUE;
+}
+
+//=========================================================================
+//
+// SourcefromStar
+//
+// this routine calculates the position of a source (for example Crab) in the camera
+// from the position of a star (for example ZetaTauri) in the camera. The latter 
+// position may have been determined by analysing the DC currents in the different
+// pixels.
+//
+// Input  : thetaTel, phiTel          the direction the telescope is pointing to,
+//                                    in local coordinates
+//          f                         the distance between camera and reflector
+//          decStar, raStar           the position of the star in sky coordinates
+//          decSource, raSource       the position of the source in sky coordinates
+//          xStar, yStar              the position of the star in the camera
+//          dxStar, dyStar            error of the position of the star in the camera
+//
+// Output : xSource, ySource       the calculated position of the source in the camera
+//          dxSource, dySource     error of the calculated position of the source in 
+//                                 the camera
+//
+// Useful formulas can be found in TDAS 00-11 and TDAS 01-05
+//
+
+void MSourcePosfromStarPos::SourcefromStar(Double_t &f,
+		    TArrayD  &decStar,     TArrayD  &raStar,
+		    Double_t &decSource,   Double_t &raSource,
+                    Double_t &thetaTel,    Double_t &phiTel,    
+		    TArrayD  &xStar,       TArrayD  &yStar,
+		    TArrayD  &dxStar,      TArrayD  &dyStar,
+		    Double_t &xSource,     Double_t &ySource,
+		    Double_t &dxSource,    Double_t &dySource)
+{
+  /*
+  *fLog << "MSourcePosfromStarPos::SourcefromStar :  printout in degrees" << endl;
+  *fLog << "       decStar, raStar = " << decStar[0]*kRad2Deg << ",  " 
+        << raStar[0]*kRad2Deg << endl;
+  *fLog << "       decSource, raSource = " << decSource*kRad2Deg << ",  " 
+        << raSource*kRad2Deg << endl;
+  *fLog << "       thetaTel, phiTel = " << thetaTel*kRad2Deg << ",  " 
+        << phiTel*kRad2Deg << endl;
+  *fLog << "       xStar, yStar = " << xStar[0]*fMm2Deg << ",  " 
+        << yStar[0]*fMm2Deg << endl;
+
+  *fLog << "MSourcePosfromStarPos::SourcefromStar :  printout in radians and mm" << endl;
+  *fLog << "       decStar, raStar = " << decStar[0] << ",  " 
+        << raStar[0] << endl;
+  *fLog << "       decSource, raSource = " << decSource << ",  " 
+        << raSource << endl;
+  *fLog << "       thetaTel, phiTel = " << thetaTel << ",  " 
+        << phiTel << endl;
+  *fLog << "       xStar, yStar = " << xStar[0] << ",  " 
+        << yStar[0] << endl;
+  */
+
+  // the units are assumed to be radians for theta, phi, dec and ra
+  //            and                   mm for f, x and y
+
+
+  // calculate rotation angle alpha of sky image in camera 
+  // (see TDAS 00-11, eqs. (18) and (20))
+  // a1 = cos(Lat), a3 = -sin(Lat), where Lat is the geographical latitude of La Palma
+  Double_t a1 =  0.876627;
+  Double_t a3 = -0.481171;
+
+  Double_t denom =  1./ sqrt( sin(thetaTel)*sin(phiTel) * sin(thetaTel)*sin(phiTel) +
+			      ( a1*cos(thetaTel)+a3*sin(thetaTel)*cos(phiTel) ) * 
+                              ( a1*cos(thetaTel)+a3*sin(thetaTel)*cos(phiTel) )   );
+  Double_t cosal = - (a3 * sin(thetaTel) + a1 * cos(thetaTel) * cos(phiTel)) * denom;
+  Double_t sinal =    a1 * sin(phiTel) * denom;
+
+  *fLog << "old thetaTel, phiTel, cosal, sinal = " << thetaTel << ",  "
+        << phiTel << ",  " << cosal << ",  " << sinal << endl;
+
+
+  fObservatory->RotationAngle(thetaTel, phiTel, sinal, cosal);
+
+  *fLog << "new thetaTel, phiTel, cosal, sinal = " << thetaTel << ",  "
+        << phiTel << ",  " << cosal << ",  " << sinal << endl;
+
+
+  // calculate coordinates of source in system B (see TDAS 00-11, eqs. (2))
+  // note that right ascension and hour angle go into opposite directions
+  Double_t xB0 =  cos(decSource) * cos(-raSource);
+  Double_t yB0 =  cos(decSource) * sin(-raSource);
+  Double_t zB0 = -sin(decSource);
+
+  //*fLog << "xB0, yB0, zB0 = " << xB0 << ",  " << yB0 << ",  "
+  //      << zB0 << endl;
+
+  //-----------------------------------------------------
+  // loop over stars
+  Double_t sumx  = 0.0;
+  Double_t sumy  = 0.0;
+  Double_t sumwx = 0.0;
+  Double_t sumwy = 0.0;
+
+  for (Int_t i=0; i<decStar.GetSize(); i++)
+  {
+    // calculate weights
+    Double_t weightx = 1.0 / (dxStar[i]*dxStar[i]);
+    Double_t weighty = 1.0 / (dyStar[i]*dyStar[i]);
+    sumwx += weightx;
+    sumwy += weighty;
+
+    //*fLog << "weightx, weighty = " << weightx << ",  " << weighty << endl;
+
+    // calculate coordinates of star in system B (see TDAS 00-11, eqs. (2))
+    // note that right ascension and hour angle go into opposite directions
+    Double_t xB  =  cos(decStar[i]) * cos(-raStar[i]);
+    Double_t yB  =  cos(decStar[i]) * sin(-raStar[i]);
+    Double_t zB  = -sin(decStar[i]);
+
+
+    //*fLog << "xB, yB, zB = " << xB << ",  " << yB << ",  "
+    //    << zB << endl;
+
+ 
+    // calculate coordinates of star in a system with the basis vectors e1, e2, e3
+    // where  e1 is in the direction (r0 x a)
+    //        e2 is in the direction (e1 x r0)
+    //   and  e3 is in the direction -r0;
+    // r0 is the direction to the source
+    // and a is the earth rotation axis (pointing to the celestial north pole)
+    // 
+    Double_t x = (-xB*yB0 + xB0*yB) / sqrt( xB0*xB0 + yB0*yB0 );
+    Double_t y = ( xB*xB0*zB0 + yB*yB0*zB0 - zB*(xB0*xB0 + yB0*yB0) ) 
+                                    / sqrt( xB0*xB0 + yB0*yB0 );
+    Double_t z = -(xB*xB0 + yB*yB0 + zB*zB0);
+
+    //*fLog << "x, y, z = " << x << ",  " << y << ",  "
+    //    << z << endl;
+
+
+    // calculate coordinates of star in camera
+    Double_t xtilde = -f/z * (cosal*x - sinal*y);
+    Double_t ytilde = -f/z * (sinal*x + cosal*y);
+
+    //*fLog << "i, xtilde, ytile = " << i << " : " << xtilde << ",  " 
+    //      << ytilde << endl;
+
+
+    // calculate coordinates of source in camera
+    // note : in real camera signs are inverted (therefore s = -1.0)
+    Double_t s = -1.0;
+
+    Double_t xs = xStar[i] - s * xtilde;
+    Double_t ys = yStar[i] - s * ytilde;
+
+    *fLog << "i, xs, ys = " << i << " : " << xs << ",  " 
+          << ys << endl;
+
+    sumx += xs * weightx;
+    sumy += ys * weighty;
+  }
+  //-----------------------------------------------------
+
+  xSource  = sumx / sumwx;
+  ySource  = sumy / sumwy;
+  dxSource = 1.0 / sqrt(sumwx);
+  dySource = 1.0 / sqrt(sumwy);
+    
+  /*
+  Int_t run = fRun->GetRunNumber();
+  *fLog << all << "MSourcePosfromStarPos::SourcefromStar; run, xSource, ySource = "
+        << run << " : "
+        << xSource << " +- " << dxSource << ",   " 
+        << ySource << " +- " << dySource << endl; 
+   */
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the source position and put it into MSrcPosCam
+//
+//
+Bool_t MSourcePosfromStarPos::ReInit(MParList *pList)
+{
+  //if (1 == 1) return kTRUE;
+
+
+  Int_t run = fRun->GetRunNumber();
+  *fLog << all << "MSourcePosfromStarPos::ReInit; run = " << run << endl;
+
+
+  //-------------------------------------------------------------------
+  // search this run in the list 
+  for (Int_t i=0; i<fSize; i++)
+  {
+    if (run == fRunNr[i])
+    {
+      //-----------------------------------------
+      // put the zenith angle into MPointingPos
+
+      Double_t thetarad = fThetaTel[i];
+      Double_t phirad   = fPhiTel[i];
+
+      if (fabs(thetarad*kRad2Deg+1.0) < 0.001)
+        thetarad = fThetaradold;
+      else
+        fThetaradold = thetarad;
+      if (fabs(phirad*kRad2Deg+1.0) < 0.001)
+        phirad = fPhiradold;
+      else
+        fPhiradold = phirad;
+
+      fPointPos->SetLocalPosition(thetarad*kRad2Deg, phirad*kRad2Deg);
+      fPointPos->SetReadyToSave();
+
+      *fLog << all << "theta, phi = " << thetarad*kRad2Deg << ",  "
+            << phirad*kRad2Deg << " deg" << endl;
+       
+      //-----------------------------------------
+      // Get source position and put it into MSrcPosCam
+
+      
+      if (fStars > 0  && fStars == fStarsRead)
+      {
+        TArrayD xStar(fxStar.GetNrows());
+        TArrayD dxStar(fdxStar.GetNrows());
+        TArrayD yStar(fyStar.GetNrows());
+        TArrayD dyStar(fdyStar.GetNrows());
+        for (Int_t j=0; j<fxStar.GetNrows(); j++)
+        {
+          xStar[j]  = fxStar(j, i);
+          dxStar[j] = fdxStar(j, i);
+          yStar[j]  = fyStar(j, i);
+          dyStar[j] = fdyStar(j, i);
+        }
+
+        SourcefromStar( fDistCameraReflector,
+                        fDecStar, fRaStar, fDecSource, fRaSource,
+                        thetarad, phirad,   
+         	        xStar,          yStar,
+		        dxStar,         dyStar,
+		        fxSource,       fySource,
+		        fdxSource,      fdySource);
+      
+        fSrcPos->SetXY(fxSource, fySource);
+
+        fxSourceold = fxSource;
+        fySourceold = fySource;
+
+        *fLog << all << "MSourcePosfromStarPos::ReInit; fRunNr, fxSource, fySource = "
+              << fRunNr[i] << ",  " << fxSource << " +- " << fdxSource 
+              << ",  " << fySource  << " +- "  << fdySource << endl;
+       
+        fSrcPos->SetReadyToSave();       
+      }
+      else
+      {
+        // set default values
+        fxSource = fxSourceold;
+        fySource = fySourceold;
+        fSrcPos->SetXY(fxSource, fySource);
+        fSrcPos->SetReadyToSave();       
+
+
+        *fLog << warn << "MSourcePosfromStarPos::ReInit;  no information on source position for run number = "
+              << run << endl;
+        *fLog << warn << "       set xSource, ySource = " << fxSource << ",  "
+              << fySource << " mm" << endl;
+      }
+      
+
+      return kTRUE;
+    }
+  }
+  //-------------------------------------------------------------------  
+
+    // set default values
+    fxSource = fxSourceold;
+    fySource = fySourceold;
+    fSrcPos->SetXY(fxSource, fySource);
+    fSrcPos->SetReadyToSave();       
+
+    Double_t thetarad = fThetaradold;
+    Double_t phirad = fPhiradold;
+    fPointPos->SetLocalPosition(thetarad*kRad2Deg, phirad*kRad2Deg);
+    fPointPos->SetReadyToSave();
+
+
+    *fLog << warn << "MSourcePosfromStarPos::ReInit;  no information on theta, phi and source position for run number = "
+          << run << endl;
+    *fLog << warn << "       set xSource, ySource = " << fxSource << ",  "
+          << fySource << " mm" << endl;
+    *fLog << warn << "       set theta, phi = " << thetarad*kRad2Deg << ",  "
+          << phirad*kRad2Deg << " deg" << endl;
+
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//
+Int_t MSourcePosfromStarPos::Process()
+{
+  //Int_t run = fRun->GetRunNumber();
+  //*fLog << "MSourcePosfromStarPos::Process; run = " << run << endl;
+    
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//
+Int_t MSourcePosfromStarPos::PostProcess()
+{
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// read the data from the ASCII file and store them
+//
+void MSourcePosfromStarPos::FixSize()
+{
+    fSize = fRuns;
+    if (fRuns <= 0)
+      fSize = 1;
+
+    fRunNr.Set(fSize);
+
+    fThetaTel.Set(fSize);
+    fPhiTel.Set(fSize);
+    fdThetaTel.Set(fSize);
+    fdPhiTel.Set(fSize);
+
+    Int_t fRows = fxStar.GetNrows();
+    fxStar.ResizeTo(fRows, fSize);
+    fyStar.ResizeTo(fRows, fSize);
+    fdxStar.ResizeTo(fRows, fSize);
+    fdyStar.ResizeTo(fRows, fSize);
+
+  *fLog << "MSourcePosfromStarPos::FixSize; fix size of arrays : fStars = "
+        << fStars << ",  fRuns = " << fRuns << ",  fRows = " << fRows
+        << ",  fSize = " << fSize << endl;
+  *fLog << "       first run : " << fRunNr[0] << ",  last run : "
+        << fRunNr[fRuns-1] << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// read the data from the ASCII file and store them
+//
+void MSourcePosfromStarPos::ReadData()
+{
+  Float_t val;
+  Int_t   ival;
+
+  // extend size of arrays if necessary
+  if ( fRuns >= fSize )
+  {
+    fSize += 100;
+
+    fRunNr.Set(fSize);
+
+    fThetaTel.Set(fSize);
+    fPhiTel.Set(fSize);
+    fdThetaTel.Set(fSize);
+    fdPhiTel.Set(fSize);
+    
+    Int_t fRows = fxStar.GetNrows();
+    fxStar.ResizeTo(fRows, fSize);
+    fyStar.ResizeTo(fRows, fSize);
+    fdxStar.ResizeTo(fRows, fSize);
+    fdyStar.ResizeTo(fRows, fSize);
+
+    *fLog << "MSourcePosfromStarPos::ReadData(); size of arrays has been increased to (fRows, fSize) = ("
+          << fRows << ",  " << fSize << ")" << endl;
+  }
+
+  //-------------------
+  // read header line
+  //*fIn >> val;
+
+  //*fLog << "val =" << val << endl;
+
+  //*fIn >> val;
+  //*fIn >> val;
+  //*fIn >> val;
+  //*fIn >> val;
+  //*fIn >> val;
+  //*fIn >> val;
+  //*fIn >> val;
+  //*fIn >> val;
+  //*fIn >> val;
+  //*fIn >> val;
+  //-------------------
+
+
+
+  while(1)
+  {
+    *fIn >> ival;
+
+    if (fIn->eof())
+      return;
+
+    // run number must be greater than 10000
+    if (TMath::Abs(ival) < 10000)
+    {
+      *fLog << err << "===========> Error when reading file with theta and phi <========="
+	    << "             ival = " << ival << endl;
+    }          
+    else
+      break;
+  }  
+
+  fRuns += 1;
+  *fLog << fRuns <<"th run : " << ival << endl;  
+
+  fRunNr.AddAt(ival, fRuns-1);
+
+  //*fLog << "check : fRuns, fRunNr[fRuns-1], fRunNr[fRuns] = " << fRuns << ",  "
+  //      << fRunNr[fRuns-1] << ",  " << fRunNr[fRuns] << endl;
+
+ 
+  // read mjdS, hmsS, mjdE, hmsE
+  // these data are present only for ON data (fStars > 0)
+  /*
+  if (fStars > 0)
+  {
+    *fIn >> val; 
+    *fIn >> val; 
+    *fIn >> val; 
+    *fIn >> val; 
+
+    *fIn >> val; 
+    *fIn >> val; 
+    *fIn >> val; 
+    *fIn >> val; 
+  }
+  */
+
+  *fIn >> val;
+  fThetaTel.AddAt(val/kRad2Deg, fRuns-1);
+  //*fLog << "val, fThetaTel[fRuns-1] = " << val << ",  "
+  //      << fThetaTel[fRuns-1] << endl;
+
+
+  *fIn >> val;
+  fPhiTel.AddAt(val/kRad2Deg, fRuns-1);
+  //*fLog << "val, fPhiTel[fRuns-1] = " << val << ",  "
+  //      << fPhiTel[fRuns-1] << endl;
+
+
+  //*fIn >> val;
+  //fdThetaTel.AddAt(val/kRad2Deg, fRuns-1);
+  //*fIn >> val;
+  //fdPhiTel.AddAt(val/kRad2Deg, fRuns-1);
+
+  // input is in [deg], convert to [mm]
+
+  //*fLog << "ReadData : fStarsRead = " << fStarsRead << endl;
+
+    for (Int_t i=0; i<fStarsRead; i++)
+    {
+      *fIn >> val;
+      if (i<fStars) fxStar(i, fRuns-1) = val;
+
+      *fIn >> val;
+      if (i<fStars) fyStar(i, fRuns-1) = val;
+
+      //*fIn >> val;
+      // if (i < fStars) fdxStar(i, fRuns-1) = val;
+      if (i < fStars) fdxStar(i, fRuns-1) = 1.0;
+
+      //*fIn >> val;
+      // if (i < fStars) fdyStar(i, fRuns-1) = val;
+      if (i < fStars) fdyStar(i, fRuns-1) = 1.0;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Add this file as the last entry in the chain
+//
+Int_t MSourcePosfromStarPos::AddFile(const char *txt, Int_t)
+{
+    TNamed *name = new TNamed(txt, "");
+    fFileNames->AddLast(name);
+
+    *fLog << "MSourcePosfromStarPos::AddFile; add file '" << txt << "'"
+          << endl;
+
+    return 1;
+}
+
+// --------------------------------------------------------------------------
+//
+// This opens the next file in the list and deletes its name from the list.
+//
+Bool_t MSourcePosfromStarPos::OpenNextFile()
+{
+    //
+    // open the input stream and check if it is really open (file exists?)
+    //
+    if (fIn)
+        delete fIn;
+    fIn = NULL;
+
+    //
+    // Check for the existence 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();
+
+    const char *expname = gSystem->ExpandPathName(name);
+    fIn = new ifstream(expname);
+    delete [] expname;
+
+    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;
+}
+
+// --------------------------------------------------------------------------
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MSourcePosfromStarPos.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MSourcePosfromStarPos.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MSourcePosfromStarPos.h	(revision 9661)
@@ -0,0 +1,127 @@
+#ifndef MARS_MSourcePosfromStarPos
+#define MARS_MSourcePosfromStarPos
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MSourcePosfromStarPos                                                   //
+//                                                                         //
+// Task to calculate the position of the source in the camera from
+//      the position of a known star in the camera
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+#ifndef ROOT_TArrayI
+#include <TArrayI.h>
+#endif
+
+#ifndef ROOT_TArrayD
+#include <TArrayD.h>
+#endif
+
+#ifndef ROOT_TMatrixD
+#include <TMatrixD.h>
+#endif
+
+class TList;
+class MRawRunHeader;
+class MPointingPos;
+class MGeomCam;
+class MSrcPosCam;
+class MObservatory;
+
+
+class MSourcePosfromStarPos : public MTask
+{
+ private:
+    const MRawRunHeader *fRun;      //!
+    const MGeomCam      *fGeomCam;  //! Camera Geometry used to calculate Hillas
+    MPointingPos        *fPointPos;       //!
+    MSrcPosCam          *fSrcPos;         //!
+    MObservatory        *fObservatory;    //!
+
+    ifstream    *fIn;             // input file
+    TList       *fFileNames;      // array which contains the \0-terminated file names
+
+    Double_t fMm2Deg;
+    Double_t fDistCameraReflector;
+
+    Int_t   fRuns;                // current number of runs
+    Int_t   fSize;                // final   number of runs
+    Int_t   fStars;               // number of stars
+    Int_t   fStarsRead;           // number of (x,y) pairs to be read
+
+
+    Double_t fDecSource;  // sky coordinates of source
+    Double_t fRaSource;
+    Double_t fxSource;    // estimated position of source in camera
+    Double_t fySource;
+    Double_t fdxSource;
+    Double_t fdySource;
+
+    TArrayI fRunNr;       // list of run numbers
+    TArrayD fThetaTel;    // for each run : theta, phi, ...
+    TArrayD fPhiTel;
+    TArrayD fdThetaTel;
+    TArrayD fdPhiTel;
+
+    TArrayD  fDecStar;   // sky coordinates of stars
+    TArrayD  fRaStar;
+    TMatrixD fxStar;     // for each run : positions of stars in camera (from DC currents)
+    TMatrixD fyStar;
+    TMatrixD fdxStar;
+    TMatrixD fdyStar;
+
+    Double_t fxSourceold;  
+    Double_t fySourceold;
+    Double_t fThetaradold;
+    Double_t fPhiradold;
+
+    Bool_t OpenNextFile();
+    void   ReadData();
+    void   FixSize();
+
+    Int_t  PreProcess(MParList *pList);
+    Bool_t ReInit(MParList *pList);
+    Int_t  Process();
+    Int_t  PostProcess();
+
+public:
+    MSourcePosfromStarPos(const char *name=NULL, const char *title=NULL);
+    ~MSourcePosfromStarPos();
+
+    void SetSourceAndStarPosition(
+	 TString  nameSource,
+	 Double_t decSourceDeg, Double_t decSourceMin, Double_t decSourceSec, 
+         Double_t raSourceHour, Double_t raSourceMin,  Double_t raSourceSec,
+	 TString  nameStar,
+	 Double_t decStarDeg,   Double_t decStarMin,   Double_t decStarSec, 
+         Double_t raStarHour,   Double_t raStarMin,    Double_t raStarSec  );
+
+    Int_t  AddFile(const char *fname, Int_t dummy=-1);
+
+    void AddStar(
+	 TString  nameStar,
+	 Double_t decStarDeg,   Double_t decStarMin,   Double_t decStarSec, 
+         Double_t raStarHour,   Double_t raStarMin,    Double_t raStarSec  );
+
+    void SourcefromStar(Double_t &, 
+      TArrayD  &, TArrayD  &, Double_t &, Double_t &, Double_t &, Double_t &, 
+      TArrayD  &, TArrayD  &, TArrayD  &, TArrayD  &, Double_t &, Double_t &, 
+      Double_t &, Double_t & );
+
+    ClassDef(MSourcePosfromStarPos, 0) // Task to calculate the source position from a star position
+};
+
+#endif
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MSupercuts.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MSupercuts.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MSupercuts.cc	(revision 9661)
@@ -0,0 +1,388 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Wolfgang Wittek, 08/2003 <mailto:wittek@mppmu.mpg.de>
+!   Author(s): Thomas Bretz, 08/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//   MSupercuts                                                         //
+//                                                                         //
+//   this is the container for the parameters of the supercuts             //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MSupercuts.h"
+
+#include <math.h>
+#include <fstream>
+
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MSupercuts);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// constructor
+//
+MSupercuts::MSupercuts(const char *name, const char *title)
+  : fParameters(104), fStepsizes(104),
+    fLengthUp(fParameters.GetArray()),   fLengthLo(fParameters.GetArray()+8),
+    fWidthUp(fParameters.GetArray()+16), fWidthLo(fParameters.GetArray()+24),
+    fDistUp(fParameters.GetArray()+32),  fDistLo(fParameters.GetArray()+40),
+    fAsymUp(fParameters.GetArray()+48),  fAsymLo(fParameters.GetArray()+56),
+    fConcUp(fParameters.GetArray()+64),  fConcLo(fParameters.GetArray()+72),
+    fLeakage1Up(fParameters.GetArray()+80), fLeakage1Lo(fParameters.GetArray()+88),
+    fAlphaUp(fParameters.GetArray()+96)
+{
+    fName  = name  ? name  : "MSupercuts";
+    fTitle = title ? title : "Container for the supercut parameters";
+
+    // set supercut parameters to their default values
+    InitParameters();
+}
+
+
+// --------------------------------------------------------------------------
+//
+// set default values for the supercut parameters
+//
+void MSupercuts::InitParameters()
+{
+    //---------------------------------------------------
+    //  these are the default values
+
+    fLengthUp[0] =  0.2;
+    fLengthUp[1] =  0.0;
+    fLengthUp[2] =  0.0;
+    fLengthUp[3] =  0.0;
+    fLengthUp[4] =  0.0;
+    fLengthUp[5] =  0.0;
+    fLengthUp[6] =  0.0;
+    fLengthUp[7] =  0.0;
+
+    fLengthLo[0] =  0.;
+    fLengthLo[1] =  0.;
+    fLengthLo[2] =  0.;
+    fLengthLo[3] =  0.;
+    fLengthLo[4] =  0.;
+    fLengthLo[5] =  0.;
+    fLengthLo[6] =  0.;
+    fLengthLo[7] =  0.;
+
+    fWidthUp[0] =  0.1;
+    fWidthUp[1] =  0.0;
+    fWidthUp[2] =  0.0;
+    fWidthUp[3] =  0.0;
+    fWidthUp[4] =  0.0;
+    fWidthUp[5] =  0.0;
+    fWidthUp[6] =  0.0;
+    fWidthUp[7] =  0.0;
+
+    fWidthLo[0] =  0.;
+    fWidthLo[1] =  0.;
+    fWidthLo[2] =  0.;
+    fWidthLo[3] =  0.;
+    fWidthLo[4] =  0.;
+    fWidthLo[5] =  0.;
+    fWidthLo[6] =  0.;
+    fWidthLo[7] =  0.;
+
+    fDistUp[0] =  1.e10;
+    fDistUp[1] =  0.0;
+    fDistUp[2] =  0.0;
+    fDistUp[3] =  0.0;
+    fDistUp[4] =  0.0;
+    fDistUp[5] =  0.0;
+    fDistUp[6] =  0.0;
+    fDistUp[7] =  0.0;
+
+    fDistLo[0] =  0.0;
+    fDistLo[1] =  0.0;
+    fDistLo[2] =  0.0;
+    fDistLo[3] =  0.0;
+    fDistLo[4] =  0.0;
+    fDistLo[5] =  0.0;
+    fDistLo[6] =  0.0;
+    fDistLo[7] =  0.0;
+    
+
+    // dummy values
+
+    fAsymUp[0] =  1.e10;
+    fAsymUp[1] =  0.0;
+    fAsymUp[2] =  0.0;
+    fAsymUp[3] =  0.0;
+    fAsymUp[4] =  0.0;
+    fAsymUp[5] =  0.0;
+    fAsymUp[6] =  0.0;
+    fAsymUp[7] =  0.0;
+
+    fAsymLo[0] = -1.e10;
+    fAsymLo[1] =  0.0;
+    fAsymLo[2] =  0.0;
+    fAsymLo[3] =  0.0;
+    fAsymLo[4] =  0.0;
+    fAsymLo[5] =  0.0;
+    fAsymLo[6] =  0.0;
+    fAsymLo[7] =  0.0;
+
+    fConcUp[0] =  1.e10;
+    fConcUp[1] =  0.0;
+    fConcUp[2] =  0.0;
+    fConcUp[3] =  0.0;
+    fConcUp[4] =  0.0;
+    fConcUp[5] =  0.0;
+    fConcUp[6] =  0.0;
+    fConcUp[7] =  0.0;
+
+    fConcLo[0] = -1.e10;
+    fConcLo[1] =  0.0;
+    fConcLo[2] =  0.0;
+    fConcLo[3] =  0.0;
+    fConcLo[4] =  0.0;
+    fConcLo[5] =  0.0;
+    fConcLo[6] =  0.0;
+    fConcLo[7] =  0.0;
+
+    fLeakage1Up[0] =  1.e10;
+    fLeakage1Up[1] =  0.0;
+    fLeakage1Up[2] =  0.0;
+    fLeakage1Up[3] =  0.0;
+    fLeakage1Up[4] =  0.0;
+    fLeakage1Up[5] =  0.0;
+    fLeakage1Up[6] =  0.0;
+    fLeakage1Up[7] =  0.0;
+
+    fLeakage1Lo[0] = -1.e10;
+    fLeakage1Lo[1] =  0.0;
+    fLeakage1Lo[2] =  0.0;
+    fLeakage1Lo[3] =  0.0;
+    fLeakage1Lo[4] =  0.0;
+    fLeakage1Lo[5] =  0.0;
+    fLeakage1Lo[6] =  0.0;
+    fLeakage1Lo[7] =  0.0;
+
+    fAlphaUp[0] = 13.123440; 
+    fAlphaUp[1] = 0;
+    fAlphaUp[2] = 0;
+    fAlphaUp[3] = 0;
+    fAlphaUp[4] = 0;
+    fAlphaUp[5] = 0;
+    fAlphaUp[6] = 0;
+    fAlphaUp[7] = 0;
+
+    //---------------------------------------------------
+    // fStepsizes 
+    // if == 0.0    the parameter will be fixed in the minimization
+    //    != 0.0    initial step sizes for the parameters
+
+    // LengthUp
+    fStepsizes[0] = 0.02;
+    fStepsizes[1] = 0.0;
+    fStepsizes[2] = 0.0;
+    fStepsizes[3] = 0.0;
+    fStepsizes[4] = 0.0;
+    fStepsizes[5] = 0.0;
+    fStepsizes[6] = 0.0;
+    fStepsizes[7] = 0.0;
+
+    // LengthLo
+    fStepsizes[8]  = 0.0;
+    fStepsizes[9]  = 0.0;
+    fStepsizes[10] = 0.0;
+    fStepsizes[11] = 0.0;
+    fStepsizes[12] = 0.0;
+    fStepsizes[13] = 0.0;
+    fStepsizes[14] = 0.0;
+    fStepsizes[15] = 0.0;
+
+    // WidthUp
+    fStepsizes[16] = 0.01;
+    fStepsizes[17] = 0.0;
+    fStepsizes[18] = 0.0;
+    fStepsizes[19] = 0.0;
+    fStepsizes[20] = 0.0;
+    fStepsizes[21] = 0.0;
+    fStepsizes[22] = 0.0;
+    fStepsizes[23] = 0.0;
+
+    // WidthLo
+    fStepsizes[24] = 0.0;
+    fStepsizes[25] = 0.0;
+    fStepsizes[26] = 0.0;
+    fStepsizes[27] = 0.0;
+    fStepsizes[28] = 0.0;
+    fStepsizes[29] = 0.0;
+    fStepsizes[30] = 0.0;
+    fStepsizes[31] = 0.0;
+
+    // DistUp
+    fStepsizes[32] = 0.0;
+    fStepsizes[33] = 0.0;
+    fStepsizes[34] = 0.0;
+    fStepsizes[35] = 0.0;
+    fStepsizes[36] = 0.0;
+    fStepsizes[37] = 0.0;
+    fStepsizes[38] = 0.0;
+    fStepsizes[39] = 0.0;
+
+    // DistLo
+    fStepsizes[40] = 0.0;
+    fStepsizes[41] = 0.0;
+    fStepsizes[42] = 0.0;
+    fStepsizes[43] = 0.0;
+    fStepsizes[44] = 0.0;
+    fStepsizes[45] = 0.0;
+    fStepsizes[46] = 0.0;
+    fStepsizes[47] = 0.0;
+
+    // AsymUp
+    fStepsizes[48] = 0.0;
+    fStepsizes[49] = 0.0;
+    fStepsizes[50] = 0.0;
+    fStepsizes[51] = 0.0;
+    fStepsizes[52] = 0.0;
+    fStepsizes[53] = 0.0;
+    fStepsizes[54] = 0.0;
+    fStepsizes[55] = 0.0;
+
+    // AsymLo
+    fStepsizes[56] = 0.0;
+    fStepsizes[57] = 0.0;
+    fStepsizes[58] = 0.0;
+    fStepsizes[59] = 0.0;
+    fStepsizes[60] = 0.0;
+    fStepsizes[61] = 0.0;
+    fStepsizes[62] = 0.0;
+    fStepsizes[63] = 0.0;
+
+    // ConcUp
+    fStepsizes[64] = 0.0;
+    fStepsizes[65] = 0.0;
+    fStepsizes[66] = 0.0;
+    fStepsizes[67] = 0.0;
+    fStepsizes[68] = 0.0;
+    fStepsizes[69] = 0.0;
+    fStepsizes[70] = 0.0;
+    fStepsizes[71] = 0.0;
+
+    // ConcLo
+    fStepsizes[72] = 0.0;
+    fStepsizes[73] = 0.0;
+    fStepsizes[74] = 0.0;
+    fStepsizes[75] = 0.0;
+    fStepsizes[76] = 0.0;
+    fStepsizes[77] = 0.0;
+    fStepsizes[78] = 0.0;
+    fStepsizes[79] = 0.0;
+
+    // Leakage1Up
+    fStepsizes[80] = 0.0;
+    fStepsizes[81] = 0.0;
+    fStepsizes[82] = 0.0;
+    fStepsizes[83] = 0.0;
+    fStepsizes[84] = 0.0;
+    fStepsizes[85] = 0.0;
+    fStepsizes[86] = 0.0;
+    fStepsizes[87] = 0.0;
+
+    // Leakage1Lo
+    fStepsizes[88] = 0.0;
+    fStepsizes[89] = 0.0;
+    fStepsizes[90] = 0.0;
+    fStepsizes[91] = 0.0;
+    fStepsizes[92] = 0.0;
+    fStepsizes[93] = 0.0;
+    fStepsizes[94] = 0.0;
+    fStepsizes[95] = 0.0;
+
+    // AlphaUp
+    fStepsizes[96]  = 0.0;
+    fStepsizes[97]  = 0.0;
+    fStepsizes[98]  = 0.0;
+    fStepsizes[99]  = 0.0;
+    fStepsizes[100] = 0.0;
+    fStepsizes[101] = 0.0;
+    fStepsizes[102] = 0.0;
+    fStepsizes[103] = 0.0;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Set the parameter values from the array 'd'
+//
+//
+Bool_t MSupercuts::SetParameters(const TArrayD &d)
+{
+    if (d.GetSize() != fParameters.GetSize())
+    {
+        *fLog << err << "Sizes of d and of fParameters are different : "
+              << d.GetSize() << ",  " << fParameters.GetSize() << endl;
+        return kFALSE;
+    }
+
+    fParameters = d;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the step sizes from the array 'd'
+//
+//
+Bool_t MSupercuts::SetStepsizes(const TArrayD &d)
+{
+    if (d.GetSize() != fStepsizes.GetSize())
+    {
+        *fLog << err << "Sizes of d and of fStepsizes are different : "
+              << d.GetSize() << ",  " << fStepsizes.GetSize() << endl;
+        return kFALSE;
+    }
+
+    fStepsizes = d;
+
+    return kTRUE;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MSupercuts.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MSupercuts.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MSupercuts.h	(revision 9661)
@@ -0,0 +1,69 @@
+#ifndef MARS_MSupercuts
+#define MARS_MSupercuts
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#ifndef ROOT_TArrayD
+#include <TArrayD.h>
+#endif
+
+class MSupercuts : public MParContainer
+{
+private:
+    TArrayD fParameters; // supercut parameters
+    TArrayD fStepsizes;  // step sizes of supercut parameters
+
+    Double_t *fLengthUp; //!
+    Double_t *fLengthLo; //!
+    Double_t *fWidthUp;  //!
+    Double_t *fWidthLo;  //!
+    Double_t *fDistUp;   //!
+    Double_t *fDistLo;   //!
+    Double_t *fAsymUp;   //!
+    Double_t *fAsymLo;   //!
+
+    Double_t *fConcUp;   //!
+    Double_t *fConcLo;   //!
+    Double_t *fLeakage1Up;   //!
+    Double_t *fLeakage1Lo;   //!
+
+    Double_t *fAlphaUp;  //!
+
+
+public:
+    MSupercuts(const char *name=NULL, const char *title=NULL);
+
+    void InitParameters();
+
+    Bool_t SetParameters(const TArrayD &d);
+    Bool_t SetStepsizes(const TArrayD &d);
+
+    const TArrayD &GetParameters() const { return fParameters; }
+    const TArrayD &GetStepsizes()  const { return fStepsizes;  }
+
+    const Double_t *GetLengthUp() const { return fLengthUp; }
+    const Double_t *GetLengthLo() const { return fLengthLo; }
+    const Double_t *GetWidthUp() const  { return fWidthUp; }
+    const Double_t *GetWidthLo() const  { return fWidthLo; }
+    const Double_t *GetDistUp() const   { return fDistUp; }
+    const Double_t *GetDistLo() const   { return fDistLo; }
+    const Double_t *GetAsymUp() const   { return fAsymUp; }
+    const Double_t *GetAsymLo() const   { return fAsymLo; }
+
+    const Double_t *GetConcUp() const   { return fConcUp; }
+    const Double_t *GetConcLo() const   { return fConcLo; }
+
+    const Double_t *GetLeakage1Up() const   { return fLeakage1Up; }
+    const Double_t *GetLeakage1Lo() const   { return fLeakage1Lo; }
+
+    const Double_t *GetAlphaUp() const  { return fAlphaUp; }
+
+    ClassDef(MSupercuts, 1) // A container for the Supercut parameters
+};
+
+#endif
+
+
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MSupercutsCalc.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MSupercutsCalc.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MSupercutsCalc.cc	(revision 9661)
@@ -0,0 +1,348 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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, 04/2003 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//   MSupercutsCalc                                                     //
+//                                                                         //
+//   this class calculates the hadronness for the supercuts                //
+//   the parameters of the supercuts are taken                             //
+//                  from the container MSupercuts                       //
+//                                                                         //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MSupercutsCalc.h"
+
+#include <math.h>
+#include <fstream>
+
+#include "TFile.h"
+#include "TArrayD.h"
+
+#include "MParList.h"
+#include "MHillasExt.h"
+#include "MHillasSrc.h"
+#include "MNewImagePar.h"
+#include "MMcEvt.hxx"
+#include "MCerPhotEvt.h"
+#include "MGeomCam.h"
+#include "MHadronness.h"
+#include "MHMatrix.h"
+#include "MSupercuts.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MSupercutsCalc);
+
+using namespace std;
+
+
+// --------------------------------------------------------------------------
+//
+// constructor
+//
+
+MSupercutsCalc::MSupercutsCalc(const char *hilname, 
+                                     const char *hilsrcname, 
+                                     const char *name, const char *title)
+  : fHadronnessName("MHadronness"), fHilName(hilname), fHilSrcName(hilsrcname),
+    fHilExtName("MHillasExt"), fNewParName("MNewImagePar"), 
+    fSuperName("MSupercuts") 
+{
+    fName  = name  ? name  : "MSupercutsCalc";
+    fTitle = title ? title : "Class to evaluate the Supercuts";
+
+    fMatrix = NULL;
+}
+
+// --------------------------------------------------------------------------
+//
+Int_t MSupercutsCalc::PreProcess(MParList *pList)
+{
+    MGeomCam *cam = (MGeomCam*)pList->FindObject("MGeomCam");
+    if (!cam)
+    {
+        *fLog << err << "MGeomCam (Camera Geometry) not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fMm2Deg = cam->GetConvMm2Deg();
+
+    fHadronness = (MHadronness*)pList->FindCreateObj("MHadronness", fHadronnessName);
+    if (!fHadronness)
+    {
+        *fLog << err << fHadronnessName << " [MHadronness] not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fSuper = (MSupercuts*)pList->FindObject(fSuperName, "MSupercuts");
+    if (!fSuper)
+    {
+        *fLog << err << fSuperName << " [MSupercuts] not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    if (fMatrix)
+        return kTRUE;
+
+    //-----------------------------------------------------------
+    fHil = (MHillas*)pList->FindObject(fHilName, "MHillas");
+    if (!fHil)
+    {
+        *fLog << err << fHilName << " [MHillas] not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fHilExt = (MHillasExt*)pList->FindObject(fHilExtName, "MHillasExt");
+    if (!fHilExt)
+    {
+        *fLog << err << fHilExtName << " [MHillasExt] not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fHilSrc = (MHillasSrc*)pList->FindObject(fHilSrcName, "MHillasSrc");
+    if (!fHilSrc)
+    {
+        *fLog << err << fHilSrcName << " [MHillasSrc] not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fNewPar = (MNewImagePar*)pList->FindObject(fNewParName, "MNewImagePar");
+    if (!fNewPar)
+    {
+        *fLog << err << fNewParName << " [MNewImagePar] not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
+    if (!fMcEvt)
+    {
+        *fLog << err << "MMcEvt not found... aborting." << endl;
+        return kFALSE;
+    }
+
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculation of upper and lower limits
+//
+Double_t MSupercutsCalc::CtsMCut(const Double_t* a,  Double_t ls, Double_t ct,
+                                    Double_t ls2, Double_t dd2) const
+{
+    // define cut-function
+    //
+    //    dNOMLOGSIZE = 5.0 (=log(150.0)
+    //    dNOMCOSZA   = 1.0
+    //
+    //      a: array of cut parameters
+    //     ls: log(SIZE) - dNOMLOGSIZE
+    //    ls2: ls^2
+    //     ct: Cos(ZA.) - dNOMCOSZA
+    //    dd2: DIST^2
+    const Double_t limit =
+        a[0] + a[1] * dd2 + a[2] * ct  +
+        ls  * (a[3] + a[4] * dd2 + a[5] * ct) +
+        ls2 * (a[6] + a[7] * dd2);
+
+    //*fLog << "MSupercutsCalc::CtsMCut; *a = "
+    //      << *a     << ",  " << *(a+1) << ",  " << *(a+2) << ",  "
+    //      << *(a+3) << ",  " << *(a+4) << ",  " << *(a+5) << ",  "
+    //      << *(a+6) << ",  " << *(a+7) << endl;
+
+    //*fLog << "MSupercutsCalc::CtsMCut; ls, ls2, ct, dd2, limit = " << ls
+    //      << ",  " << ls2 << ",  " << ct << ",  " << dd2 << ",  "
+    //      << limit << endl;
+
+    return limit;
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the mapped value from the Matrix
+//
+Double_t MSupercutsCalc::GetVal(Int_t i) const
+{
+
+    Double_t val = (*fMatrix)[fMap[i]];
+
+
+    //*fLog << "MSupercutsCalc::GetVal; i, fMatrix, fMap, val = "
+    //    << i << ",  " << fMatrix << ",  " << fMap[i] << ",  " << val << endl;
+
+
+    return val;
+}
+
+// --------------------------------------------------------------------------
+//
+// You can use this function if you want to use a MHMatrix instead of the
+// given containers. This function adds all necessary columns to the
+// given matrix. Afterward you should fill the matrix with the corresponding
+// data (eg from a file by using MHMatrix::Fill). If you now loop
+// through the matrix (eg using MMatrixLoop) MEnergyEstParam::Process
+// will take the values from the matrix instead of the containers.
+//
+void MSupercutsCalc::InitMapping(MHMatrix *mat)
+{
+    if (fMatrix)
+      return;
+
+    fMatrix = mat;
+
+    fMap[0] = fMatrix->AddColumn("MMcEvt.fTelescopeTheta");
+    fMap[1] = fMatrix->AddColumn("MHillas.fWidth");
+    fMap[2] = fMatrix->AddColumn("MHillas.fLength");
+    fMap[3] = fMatrix->AddColumn("MHillas.fSize");
+    fMap[4] = fMatrix->AddColumn("MHillas.fMeanX");
+    fMap[5] = fMatrix->AddColumn("MHillas.fMeanY");
+    fMap[6] = fMatrix->AddColumn("MHillasSrc.fDist");
+    fMap[7] = fMatrix->AddColumn("fabs(MHillasSrc.fAlpha)");
+    fMap[8] = fMatrix->AddColumn("sgn(MHillasSrc.fCosDeltaAlpha)*(MHillasExt.fM3Long)");
+    fMap[9] = fMatrix->AddColumn("MNewImagePar.fConc");
+    fMap[10]= fMatrix->AddColumn("MNewImagePar.fLeakage1");
+}
+
+// ---------------------------------------------------------------------------
+//
+// Evaluate dynamical supercuts 
+// 
+//          set hadronness to 0.25 if cuts are fullfilled
+//                            0.75 otherwise
+//
+Int_t MSupercutsCalc::Process()
+{
+    const Double_t kNomLogSize = 4.1;
+    const Double_t kNomCosZA   = 1.0;
+
+    const Double_t theta   = fMatrix ? GetVal(0) : fMcEvt->GetTelescopeTheta();
+    const Double_t width0  = fMatrix ? GetVal(1) : fHil->GetWidth();
+    const Double_t length0 = fMatrix ? GetVal(2) : fHil->GetLength();
+    const Double_t size    = fMatrix ? GetVal(3) : fHil->GetSize();
+    const Double_t meanx   = fMatrix ? GetVal(4) : fHil->GetMeanX();
+    const Double_t meany   = fMatrix ? GetVal(5) : fHil->GetMeanY();
+    const Double_t dist0   = fMatrix ? GetVal(6) : fHilSrc->GetDist();
+
+    Double_t help;
+    if (!fMatrix)
+      help = TMath::Sign(fHilExt->GetM3Long(), 
+	      		 fHilSrc->GetCosDeltaAlpha());
+    const Double_t asym0   = fMatrix ? GetVal(8) : help;
+    const Double_t conc    = fMatrix ? GetVal(9) : fNewPar->GetConc();
+    const Double_t leakage = fMatrix ? GetVal(10): fNewPar->GetLeakage1();
+
+    const Double_t newdist = dist0 * fMm2Deg;
+
+    const Double_t dist2   = meanx*meanx + meany*meany;
+    const Double_t dist    = sqrt(dist2) * fMm2Deg;
+    const Double_t dd2     = dist*dist;
+
+
+    const Double_t dmls    = log(size) - kNomLogSize;
+    const Double_t dmls2   = dmls * dmls;
+
+    const Double_t dmcza   = cos(theta) - kNomCosZA;
+
+    const Double_t length  = length0 * fMm2Deg;
+    const Double_t width   = width0  * fMm2Deg;
+    const Double_t asym    = asym0   * fMm2Deg;
+
+    /*
+    *fLog << "newdist, length, width, asym, dist, conc, leakage = " 
+          << newdist << ",  " << length << ",  " << width << ",  "
+          << asym    << ",  " << dist   << ",  " << conc  << ",  " << leakage
+          << endl;
+  
+    *fLog << "upper cuts in newdist, length, width, asym, dist, conc, leakage = " 
+          << CtsMCut (fSuper->GetDistUp(),   dmls, dmcza, dmls2, dd2) << ",  "
+          << CtsMCut (fSuper->GetDistLo(),   dmls, dmcza, dmls2, dd2) << ",  "
+
+          << CtsMCut (fSuper->GetLengthUp(),   dmls, dmcza, dmls2, dd2) << ",  "
+          << CtsMCut (fSuper->GetLengthLo(),   dmls, dmcza, dmls2, dd2) << ",  "
+
+          << CtsMCut (fSuper->GetWidthUp(),   dmls, dmcza, dmls2, dd2) << ",  "
+          << CtsMCut (fSuper->GetWidthLo(),   dmls, dmcza, dmls2, dd2) << ",  "
+
+          << CtsMCut (fSuper->GetAsymUp(),   dmls, dmcza, dmls2, dd2) << ",  "
+          << CtsMCut (fSuper->GetAsymLo(),   dmls, dmcza, dmls2, dd2) << ",  "
+
+          << CtsMCut (fSuper->GetDistUp(),   dmls, dmcza, dmls2, dd2) << ",  "
+          << CtsMCut (fSuper->GetDistLo(),   dmls, dmcza, dmls2, dd2) << ",  "
+
+          << CtsMCut (fSuper->GetConcUp(),   dmls, dmcza, dmls2, dd2) << ",  "
+          << CtsMCut (fSuper->GetConcLo(),   dmls, dmcza, dmls2, dd2) << ",  "
+
+          << CtsMCut (fSuper->GetLeakage1Up(),   dmls, dmcza, dmls2, dd2) << ",  "
+          << CtsMCut (fSuper->GetLeakage1Lo(),   dmls, dmcza, dmls2, dd2) << ",  "
+          << endl;
+    */
+
+
+    if (
+        //dist    < 1.05                                                     &&
+        //newdist < 1.05                                                     &&
+
+        newdist < CtsMCut (fSuper->GetDistUp(),   dmls, dmcza, dmls2, dd2) &&
+        newdist > CtsMCut (fSuper->GetDistLo(),   dmls, dmcza, dmls2, dd2) &&
+
+        length  < CtsMCut (fSuper->GetLengthUp(), dmls, dmcza, dmls2, dd2) &&
+        length  > CtsMCut (fSuper->GetLengthLo(), dmls, dmcza, dmls2, dd2) &&
+
+        width   < CtsMCut (fSuper->GetWidthUp(),  dmls, dmcza, dmls2, dd2) &&
+        width   > CtsMCut (fSuper->GetWidthLo(),  dmls, dmcza, dmls2, dd2) &&
+
+        asym    < CtsMCut (fSuper->GetAsymUp(),   dmls, dmcza, dmls2, dd2) &&
+        asym    > CtsMCut (fSuper->GetAsymLo(),   dmls, dmcza, dmls2, dd2) &&
+
+        dist    < CtsMCut (fSuper->GetDistUp(),   dmls, dmcza, dmls2, dd2) &&
+        dist    > CtsMCut (fSuper->GetDistLo(),   dmls, dmcza, dmls2, dd2) &&
+
+        conc    < CtsMCut (fSuper->GetConcUp(),   dmls, dmcza, dmls2, dd2) &&
+        conc    > CtsMCut (fSuper->GetConcLo(),   dmls, dmcza, dmls2, dd2) &&
+
+        leakage < CtsMCut (fSuper->GetLeakage1Up(),dmls, dmcza, dmls2, dd2) &&
+        leakage > CtsMCut (fSuper->GetLeakage1Lo(),dmls, dmcza, dmls2, dd2)  ) 
+
+      fHadronness->SetHadronness(0.25);
+    else
+      fHadronness->SetHadronness(0.75);
+
+    //*fLog << "SChadroness = " << fHadronness->GetHadronness() << endl;
+
+    fHadronness->SetReadyToSave();
+
+    return kTRUE;
+}
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/MSupercutsCalc.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/MSupercutsCalc.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/MSupercutsCalc.h	(revision 9661)
@@ -0,0 +1,82 @@
+#ifndef MARS_MSupercutsCalc
+#define MARS_MSupercutsCalc
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+#ifndef ROOT_TArrayD
+#include <TArrayD.h>
+#endif
+
+class MParList;
+class MHillas;
+class MHillasSrc;
+class MHillasExt;
+class MNewImagePar;
+class MMcEvt;
+class MCerPhotEvt;
+class MGeomCam;
+class MHadronness;
+class MHMatrix;
+class MSupercuts;
+
+class MSupercutsCalc : public MTask
+{
+private:
+    MHillas       *fHil;
+    MHillasSrc    *fHilSrc;
+    MHillasExt    *fHilExt;
+    MNewImagePar  *fNewPar;
+    MMcEvt        *fMcEvt;
+    MHadronness   *fHadronness; //! output container for hadronness
+    MSupercuts *fSuper;      // container for supercut parameters
+
+    TString  fHadronnessName;   // name of container to store hadronness
+    TString  fHilName;
+    TString  fHilSrcName;
+    TString  fHilExtName;
+    TString  fNewParName;
+    TString  fSuperName;        // name of container for supercut parameters
+
+    Double_t fMm2Deg;           //!
+
+    Int_t     fMap[11];         //!
+    MHMatrix *fMatrix;          //!
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
+    Double_t GetVal(Int_t i) const;
+
+    Double_t CtsMCut(const Double_t* a, Double_t ls, Double_t ct,
+                     Double_t ls2, Double_t dd2) const;
+
+public:
+    MSupercutsCalc(const char *hilname="MHillas",
+                      const char *hilsrcname="MHillasSrc",
+                      const char *name=NULL, const char *title=NULL);
+
+    void SetHadronnessName(const TString name) { fHadronnessName = name; }
+    TString GetHadronnessName() const { return fHadronnessName; }
+
+    void InitMapping(MHMatrix *mat);
+    void StopMapping() { InitMapping(NULL); }
+
+
+    ClassDef(MSupercutsCalc, 0) // A class to evaluate the Supercuts
+};
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/manalysis/Makefile
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysis/Makefile	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysis/Makefile	(revision 9661)
@@ -0,0 +1,70 @@
+##################################################################
+#
+#   subdirectory makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#------------------------------------------------------------------------------
+
+#
+# Handling name of the Root Dictionary Files
+#
+CINT  = Analysis
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES = -I. -I../mbase -I../mmc -I../mraw -I../mgeom -I../mfilter \
+	   -I../mdata -I../mhbase -I../mhist -I../mgui -I../mimage   \
+           -I../mhistmc -I../mfileio -I../mmain -I../mcalib          \
+           -I../msignal -I../mpointing -I../mtools -I../mfbase       \
+           -I../mbadpixels -I../mastro -I../mpedestal
+# mcalib: MGeomApply (MCalibrationCam)
+
+SRCFILES = MHPedestalPix.cc \
+           MHPedestalCam.cc \
+           MGeomApply.cc \
+           MCameraData.cc \
+           MEnergyEst.cc \
+           MEnergyEstimate.cc \
+           MEnergyEstParam.cc \
+           MEnergyEstParamDanielMkn421.cc \
+           MHadronness.cc \
+           MMatrixLoop.cc \
+           MCompProbCalc.cc \
+           MMultiDimDistCalc.cc \
+	   MCerPhotPix.cc \
+	   MCerPhotEvt.cc \
+           MCerPhotAnal.cc \
+           MCerPhotAnal2.cc \
+	   MCerPhotCalc.cc \
+           MEventRate.cc \
+           MEventRateCalc.cc \
+	   MSigmabar.cc \
+	   MSigmabarParam.cc \
+	   MSigmabarCalc.cc \
+           MParameters.cc \
+	   MMcTriggerLvl2.cc \
+	   MMcTriggerLvl2Calc.cc \
+           MSupercuts.cc \
+           MSupercutsCalc.cc \
+           MFindSupercuts.cc \
+           MMinuitInterface.cc \
+           MFiltercutsCalc.cc \
+           MPedestalWorkaround.cc \
+           MSourcePosfromStarPos.cc \
+           MMcCalibrationUpdate.cc
+
+############################################################
+
+all:  $(OBJS)
+
+include ../Makefile.rules
+
+clean:	rmcint rmobjs rmcore rmlib
+
+mrproper:	clean rmbak
Index: /tags/Mars_V0-8-5/Mars/manalysisct1/AnalysisCT1Incl.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysisct1/AnalysisCT1Incl.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysisct1/AnalysisCT1Incl.h	(revision 9661)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-8-5/Mars/manalysisct1/AnalysisCT1LinkDef.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysisct1/AnalysisCT1LinkDef.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysisct1/AnalysisCT1LinkDef.h	(revision 9661)
@@ -0,0 +1,18 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+// Doesn't compile: Please replace MBlindPixels by MBadPixel*
+//#pragma link C++ class MCT1PadSchweizer+;
+//#pragma link C++ class MCT1PadONOFF+;
+
+#pragma link C++ class MCT1PointingCorrCalc+;
+#pragma link C++ class MCT1Supercuts+;
+#pragma link C++ class MCT1SupercutsCalc+;
+#pragma link C++ class MCT1FindSupercuts+;
+#pragma link C++ class MCT1ReadPreProc+;
+#pragma link C++ class MCT1ReadAscii+;
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1FindSupercuts.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1FindSupercuts.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1FindSupercuts.cc	(revision 9661)
@@ -0,0 +1,1153 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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, 6/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Wolfgang Wittek, 7/2003 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MCT1FindSupercuts                                                       //
+//                                                                         //
+// Class for otimizing the parameters of the supercuts                     //
+//                                                                         //
+//                                                                         //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MCT1FindSupercuts.h"
+
+#include <math.h>            // fabs 
+
+#include <TFile.h>
+#include <TArrayD.h>
+#include <TMinuit.h>
+#include <TCanvas.h>
+#include <TStopwatch.h>
+#include <TVirtualFitter.h>
+
+#include "MBinning.h"
+#include "MContinue.h"
+#include "MCT1Supercuts.h"
+#include "MCT1SupercutsCalc.h"
+#include "MDataElement.h"
+#include "MDataMember.h"
+
+#include "MEvtLoop.h"
+#include "MFCT1SelFinal.h"
+#include "MF.h"
+#include "MFEventSelector.h"
+#include "MFEventSelector2.h"
+#include "MFillH.h"
+//#include "MGeomCamCT1Daniel.h"
+#include "MFEventSelector.h"
+#include "MGeomCamCT1.h"
+#include "MH3.h"
+#include "MHCT1Supercuts.h"
+#include "MHFindSignificance.h"
+#include "MHMatrix.h"
+#include "MHOnSubtraction.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+#include "MMatrixLoop.h"
+#include "MMinuitInterface.h"
+#include "MParList.h"
+#include "MProgressBar.h"
+#include "MReadMarsFile.h"
+#include "MReadTree.h"
+#include "MTaskList.h"
+
+
+ClassImp(MCT1FindSupercuts);
+
+using namespace std;
+
+
+//------------------------------------------------------------------------
+//
+// fcnSupercuts 
+//
+// - calculates the quantity to be minimized (using TMinuit)
+//
+// - the quantity to be minimized is (-1)*significance of the gamma signal
+//   in the alpha distribution (after cuts)
+//
+// - the parameters to be varied in the minimization are the cut parameters
+//   (par)
+//
+static void fcnSupercuts(Int_t &npar, Double_t *gin, Double_t &f, 
+                         Double_t *par, Int_t iflag)
+{
+    //cout <<  "entry fcnSupercuts" << endl;
+
+    //-------------------------------------------------------------
+    // save pointer to the MINUIT object for optimizing the supercuts
+    // because it will be overwritten 
+    // when fitting the alpha distribution in MHFindSignificance
+    TMinuit *savePointer = gMinuit;
+    //-------------------------------------------------------------
+
+
+    MEvtLoop *evtloopfcn = (MEvtLoop*)gMinuit->GetObjectFit();
+
+    MParList *plistfcn   = (MParList*)evtloopfcn->GetParList();
+    //MTaskList *tasklistfcn   = (MTaskList*)plistfcn->FindObject("MTaskList");
+
+    MCT1Supercuts *super = (MCT1Supercuts*)plistfcn->FindObject("MCT1Supercuts");
+    if (!super)
+    {
+        gLog << "fcnSupercuts : MCT1Supercuts object '" << "MCT1Supercuts"
+            << "' not found... aborting" << endl;
+        return;
+    }
+
+    //
+    // transfer current parameter values to MCT1Supercuts
+    //
+    // Attention : npar is the number of variable parameters
+    //                  not the total number of parameters
+    //
+    Double_t fMin, fEdm, fErrdef;
+    Int_t     fNpari, fNparx, fIstat;
+    gMinuit->mnstat(fMin, fEdm, fErrdef, fNpari, fNparx, fIstat);
+
+    super->SetParameters(TArrayD(fNparx, par));
+
+    //$$$$$$$$$$$$$$$$$$$$$
+    // for testing
+    //TArrayD checkparameters = super->GetParameters();
+    //gLog << "fcnsupercuts : fNpari, fNparx =" << fNpari << ",  " 
+    //     << fNparx  << endl;
+    //gLog << "fcnsupercuts : i, par, checkparameters =" << endl;
+    //for (Int_t i=0; i<fNparx; i++)
+    //{
+    //  gLog << i << ",  " << par[i] << ",  " << checkparameters[i] << endl;
+    //}
+    //$$$$$$$$$$$$$$$$$$$$$
+
+    //
+    // plot alpha with the current cuts
+    //
+    evtloopfcn->Eventloop();
+
+    //tasklistfcn->PrintStatistics(0, kTRUE);
+
+    MH3* alpha = (MH3*)plistfcn->FindObject("AlphaFcn", "MH3");
+    if (!alpha)
+        return;
+
+    TH1 &alphaHist = alpha->GetHist();
+    alphaHist.SetName("alpha-fcnSupercuts");
+
+    //-------------------------------------------
+    // set Minuit pointer to zero in order not to destroy the TMinuit
+    // object for optimizing the supercuts
+    gMinuit = NULL;
+
+    //=================================================================
+    // fit alpha distribution to get the number of excess events and
+    // calculate significance of gamma signal in the alpha plot
+  
+    const Double_t alphasig = 20.0;
+    const Double_t alphamin = 30.0;
+    const Double_t alphamax = 90.0;
+    const Int_t    degree   =    2;
+
+    Bool_t drawpoly;
+    Bool_t fitgauss;
+    if (iflag == 3)
+    {
+        drawpoly  = kTRUE;
+        fitgauss  = kTRUE;
+    }
+    else
+    {
+        drawpoly  = kFALSE;
+        fitgauss  = kFALSE;
+    }
+    //drawpoly  = kFALSE;
+    //fitgauss  = kFALSE;
+
+    const Bool_t print = kTRUE;
+
+    MHFindSignificance findsig;
+    findsig.SetRebin(kTRUE);
+    findsig.SetReduceDegree(kFALSE);
+    
+    const Bool_t rc = findsig.FindSigma(&alphaHist, alphamin, alphamax, degree,
+                                        alphasig, drawpoly, fitgauss, print);
+
+    //=================================================================
+
+    // reset gMinuit to the MINUIT object for optimizing the supercuts 
+    gMinuit = savePointer;
+    //-------------------------------------------
+
+    if (!rc)
+    {
+        gLog << "fcnSupercuts : FindSigma() failed" << endl;
+        f = 1.e10;
+        return;
+    }
+
+    // plot some quantities during the optimization
+    MHCT1Supercuts *plotsuper = (MHCT1Supercuts*)plistfcn->FindObject("MHCT1Supercuts");
+    if (plotsuper)
+        plotsuper->Fill(&findsig);
+
+    //------------------------
+    // get significance
+    const Double_t significance = findsig.GetSignificance();
+    f = significance>0 ? -significance : 0;
+
+
+    //------------------------
+    // optimize signal/background ratio
+    //Double_t ratio = findsig.GetNbg()>0.0 ? 
+    //                 findsig.GetNex()/findsig.GetNbg() : 0.0; 
+    //f = -ratio;
+
+    //-------------------------------------------
+    // final calculations
+    //if (iflag == 3)
+    //{
+    //
+    //}    
+
+    //-------------------------------------------------------------
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MCT1FindSupercuts::MCT1FindSupercuts(const char *name, const char *title)
+: fHowManyTrain(10000), fHowManyTest(10000), fMatrixFilter(NULL)
+{
+    fName  = name  ? name  : "MCT1FindSupercuts";
+    fTitle = title ? title : "Optimizer of the supercuts";
+
+    //---------------------------
+    // camera geometry is needed for conversion mm ==> degree
+    //fCam = new MGeomCamCT1Daniel; 
+    fCam = new MGeomCamCT1; 
+
+    // matrices to contain the training/test samples
+    fMatrixTrain = new MHMatrix("MatrixTrain");
+    fMatrixTest  = new MHMatrix("MatrixTest");
+
+    // objects of MCT1SupercutsCalc to which these matrices are attached
+    fCalcHadTrain = new MCT1SupercutsCalc("SupercutsCalcTrain");
+    fCalcHadTest  = new MCT1SupercutsCalc("SupercutsCalcTest");
+
+    // Define columns of matrices
+    fCalcHadTrain->InitMapping(fMatrixTrain);
+    fCalcHadTest->InitMapping(fMatrixTest);
+}
+
+// --------------------------------------------------------------------------
+//
+// Default destructor.
+//
+MCT1FindSupercuts::~MCT1FindSupercuts()
+{
+    delete fCam;
+    delete fMatrixTrain;
+    delete fMatrixTest;
+    delete fCalcHadTrain;
+    delete fCalcHadTest;
+}
+
+// --------------------------------------------------------------------------
+//
+// Define the matrix 'fMatrixTrain' for the training sample
+//
+// alltogether 'howmanytrain' events are read from file 'nametrain';
+// the events are selected according to a target distribution 'hreftrain'
+//
+//
+Bool_t MCT1FindSupercuts::DefineTrainMatrix(
+			  const TString &nametrain, MH3 &hreftrain,
+	                  const Int_t howmanytrain, const TString &filetrain)
+{
+    if (nametrain.IsNull() || howmanytrain <= 0)
+        return kFALSE;
+
+    *fLog << "=============================================" << endl;
+    *fLog << "fill training matrix from file '" << nametrain 
+          << "',   select " << howmanytrain 
+          << " events " << endl;
+    if (!hreftrain.GetHist().GetEntries()==0)
+    {
+      *fLog << "     according to a distribution given by the MH3 object '"
+            << hreftrain.GetName() << "'" << endl;
+    }
+    else
+    {
+      *fLog << "     randomly" << endl;
+    }
+
+
+    MParList  plist;
+    MTaskList tlist;
+
+    MReadMarsFile read("Events", nametrain);
+    read.DisableAutoScheme();
+
+    MFEventSelector2 seltrain(hreftrain);
+    seltrain.SetNumMax(howmanytrain);
+    seltrain.SetName("selectTrain");
+
+    MFillH filltrain(fMatrixTrain);
+    filltrain.SetFilter(&seltrain);
+    filltrain.SetName("fillMatrixTrain");
+
+    //******************************
+    // entries in MParList 
+    
+    plist.AddToList(&tlist);
+    plist.AddToList(fCam);
+    plist.AddToList(fMatrixTrain);
+
+    //******************************
+    // entries in MTaskList 
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&seltrain);
+    tlist.AddToList(&filltrain);
+
+    //******************************
+
+    MProgressBar bar;
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+    evtloop.SetName("EvtLoopMatrixTrain");
+    evtloop.SetProgressBar(&bar);
+
+    if (!evtloop.Eventloop())
+      return kFALSE;
+
+    tlist.PrintStatistics(0, kTRUE);
+
+    fMatrixTrain->Print("SizeCols");
+    Int_t howmanygenerated = fMatrixTrain->GetM().GetNrows();
+    if (TMath::Abs(howmanygenerated-howmanytrain) > TMath::Sqrt(9.*howmanytrain))
+    {
+      *fLog << "MCT1FindSupercuts::DefineTrainMatrix; no.of generated events ("
+	    << howmanygenerated 
+            << ") is incompatible with the no.of requested events ("
+            << howmanytrain << ")" << endl;
+    }
+
+    *fLog << "training matrix was filled" << endl;
+    *fLog << "=============================================" << endl;
+
+    //--------------------------
+    // write out training matrix
+
+    if (filetrain != "")
+    {
+      TFile filetr(filetrain, "RECREATE");
+      fMatrixTrain->Write();
+      filetr.Close();
+
+      *fLog << "MCT1FindSupercuts::DefineTrainMatrix; Training matrix was written onto file '"
+            << filetrain << "'" << endl;
+    }
+
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Define the matrix for the test sample
+//
+// alltogether 'howmanytest' events are read from file 'nametest'
+//
+// the events are selected according to a target distribution 'hreftest'
+//
+//
+Bool_t MCT1FindSupercuts::DefineTestMatrix(
+			  const TString &nametest, MH3 &hreftest,
+	                  const Int_t howmanytest, const TString &filetest)
+{
+    if (nametest.IsNull() || howmanytest<=0)
+        return kFALSE;
+
+    *fLog << "=============================================" << endl;
+    *fLog << "fill test matrix from file '" << nametest 
+          << "',   select " << howmanytest 
+          << " events " << endl;
+    if (!hreftest.GetHist().GetEntries()==0)
+    {
+      *fLog << "     according to a distribution given by the MH3 object '"
+            << hreftest.GetName() << "'" << endl;
+    }
+    else
+    {
+      *fLog << "     randomly" << endl;
+    }
+
+
+    MParList  plist;
+    MTaskList tlist;
+
+    MReadMarsFile read("Events", nametest);
+    read.DisableAutoScheme();
+
+    MFEventSelector2 seltest(hreftest);
+    seltest.SetNumMax(howmanytest);
+    seltest.SetName("selectTest");
+ 
+    MFillH filltest(fMatrixTest);
+    filltest.SetFilter(&seltest);
+
+    //******************************
+    // entries in MParList 
+    
+    plist.AddToList(&tlist);
+    plist.AddToList(fCam);
+    plist.AddToList(fMatrixTest);
+
+    //******************************
+    // entries in MTaskList 
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&seltest);
+    tlist.AddToList(&filltest);
+
+    //******************************
+
+    MProgressBar bar;
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+    evtloop.SetName("EvtLoopMatrixTest");
+    evtloop.SetProgressBar(&bar);
+
+    if (!evtloop.Eventloop())
+      return kFALSE;
+
+    tlist.PrintStatistics(0, kTRUE);
+
+    fMatrixTest->Print("SizeCols");
+    const Int_t howmanygenerated = fMatrixTest->GetM().GetNrows();
+    if (TMath::Abs(howmanygenerated-howmanytest) > TMath::Sqrt(9.*howmanytest))
+    {
+      *fLog << "MCT1FindSupercuts::DefineTestMatrix; no.of generated events ("
+	    << howmanygenerated 
+            << ") is incompatible with the no.of requested events ("
+            << howmanytest << ")" << endl;
+    }
+
+    *fLog << "test matrix was filled" << endl;
+    *fLog << "=============================================" << endl;
+
+    //--------------------------
+    // write out test matrix
+
+    if (filetest != "")
+    {
+      TFile filete(filetest, "RECREATE", "");
+      fMatrixTest->Write();
+      filete.Close();
+
+      *fLog << "MCT1FindSupercuts::DefineTestMatrix; Test matrix was written onto file '"
+            << filetest << "'" << endl;
+    }
+
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Define the matrices for the training and test sample respectively
+//
+//
+//
+Bool_t MCT1FindSupercuts::DefineTrainTestMatrix(
+			  const TString &name, MH3 &href,
+	                  const Int_t howmanytrain, const Int_t howmanytest,
+                          const TString &filetrain, const TString &filetest)
+{
+    *fLog << "=============================================" << endl;
+    *fLog << "fill training and test matrix from file '" << name 
+          << "',   select "   << howmanytrain 
+          << " training and " << howmanytest << " test events " << endl;
+    if (!href.GetHist().GetEntries()==0)
+    {
+      *fLog << "     according to a distribution given by the MH3 object '"
+            << href.GetName() << "'" << endl;
+    }
+    else
+    {
+      *fLog << "     randomly" << endl;
+    }
+
+
+    MParList  plist;
+    MTaskList tlist;
+
+    MReadMarsFile read("Events", name);
+    read.DisableAutoScheme();
+
+    MFEventSelector2 selector(href);
+    selector.SetNumMax(howmanytrain+howmanytest);
+    selector.SetName("selectTrainTest");
+    selector.SetInverted();
+
+    MContinue cont(&selector);
+    cont.SetName("ContTrainTest");
+
+    Double_t prob =  ( (Double_t) howmanytrain )
+                   / ( (Double_t)(howmanytrain+howmanytest) );
+    MFEventSelector split;
+    split.SetSelectionRatio(prob);
+
+    MFillH filltrain(fMatrixTrain);
+    filltrain.SetFilter(&split);
+    filltrain.SetName("fillMatrixTrain");
+
+
+    // consider this event as candidate for a test event 
+    // only if event was not accepted as a training event
+
+    MContinue conttrain(&split);
+    conttrain.SetName("ContTrain");
+
+    MFillH filltest(fMatrixTest);
+    filltest.SetName("fillMatrixTest");
+
+
+    //******************************
+    // entries in MParList 
+    
+    plist.AddToList(&tlist);
+    plist.AddToList(fCam);
+    plist.AddToList(fMatrixTrain);
+    plist.AddToList(fMatrixTest);
+
+    //******************************
+    // entries in MTaskList 
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&cont);
+
+    tlist.AddToList(&split);
+    tlist.AddToList(&filltrain);
+    tlist.AddToList(&conttrain);
+
+    tlist.AddToList(&filltest);
+
+    //******************************
+
+    MProgressBar bar;
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+    evtloop.SetName("EvtLoopMatrixTrainTest");
+    evtloop.SetProgressBar(&bar);
+
+    Int_t maxev = -1;
+    if (!evtloop.Eventloop(maxev))
+      return kFALSE;
+
+    tlist.PrintStatistics(0, kTRUE);
+
+    fMatrixTrain->Print("SizeCols");
+    const Int_t generatedtrain = fMatrixTrain->GetM().GetNrows();
+    if (TMath::Abs(generatedtrain-howmanytrain) > TMath::Sqrt(9.*howmanytrain))
+    {
+      *fLog << "MCT1FindSupercuts::DefineTrainTestMatrix; no.of generated events ("
+	    << generatedtrain 
+            << ") is incompatible with the no.of requested events ("
+            << howmanytrain << ")" << endl;
+    }
+
+    fMatrixTest->Print("SizeCols");
+    const Int_t generatedtest = fMatrixTest->GetM().GetNrows();
+    if (TMath::Abs(generatedtest-howmanytest) > TMath::Sqrt(9.*howmanytest))
+    {
+      *fLog << "MCT1FindSupercuts::DefineTrainTestMatrix; no.of generated events ("
+	    << generatedtest 
+            << ") is incompatible with the no.of requested events ("
+            << howmanytest << ")" << endl;
+    }
+
+
+    *fLog << "training and test matrix were filled" << endl;
+    *fLog << "=============================================" << endl;
+
+
+    //--------------------------
+    // write out training matrix
+
+    if (filetrain != "")
+    {
+      TFile filetr(filetrain, "RECREATE");
+      fMatrixTrain->Write();
+      filetr.Close();
+
+      *fLog << "MCT1FindSupercuts::DefineTrainTestMatrix; Training matrix was written onto file '"
+            << filetrain << "'" << endl;
+    }
+
+    //--------------------------
+    // write out test matrix
+
+    if (filetest != "")
+    {
+      TFile filete(filetest, "RECREATE", "");
+      fMatrixTest->Write();
+      filete.Close();
+
+      *fLog << "MCT1FindSupercuts::DefineTrainTestMatrix; Test matrix was written onto file '"
+            << filetest << "'" << endl;
+    }
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Read training and test matrices from files
+//
+//
+
+Bool_t MCT1FindSupercuts::ReadMatrix(const TString &filetrain, const TString &filetest)
+{
+  //--------------------------
+  // read in training matrix
+
+  TFile filetr(filetrain);
+  fMatrixTrain->Read("MatrixTrain");
+  fMatrixTrain->Print("SizeCols");
+
+  *fLog << "MCT1FindSupercuts::ReadMatrix; Training matrix was read in from file '"
+        << filetrain << "'" << endl;
+  filetr.Close();
+
+
+  //--------------------------
+  // read in test matrix
+
+  TFile filete(filetest);
+  fMatrixTest->Read("MatrixTest");
+  fMatrixTest->Print("SizeCols");
+
+  *fLog << "MCT1FindSupercuts::ReadMatrix; Test matrix was read in from file '"
+        << filetest << "'" << endl;
+  filete.Close();
+
+  return kTRUE;  
+}
+
+
+//------------------------------------------------------------------------
+//
+// Steering program for optimizing the supercuts
+// ---------------------------------------------
+//
+//      the criterion for the 'optimum' is 
+//
+//          - a maximum significance of the gamma signal in the alpha plot, 
+//            in which the supercuts have been applied
+//
+// The various steps are :
+//
+// - setup the event loop to be executed for each call to fcnSupercuts 
+// - call TMinuit to do the minimization of (-significance) :
+//        the fcnSupercuts function calculates the significance 
+//                                             for the current cut values
+//        for this - the alpha plot is produced in the event loop, 
+//                   in which the cuts have been applied
+//                 - the significance of the gamma signal in the alpha plot 
+//                   is calculated
+//
+// Needed as input : (to be set by the Set functions)
+//
+// - fFilenameParam      name of file to which optimum values of the 
+//                       parameters are written
+//
+// - fHadronnessName     name of container where MCT1SupercutsCalc will
+//                       put the supercuts hadronness
+//
+// - for the minimization, the starting values of the parameters are taken  
+//     - from file parSCinit (if it is != "")
+//     - or from the arrays params and/or steps 
+//
+//----------------------------------------------------------------------
+Bool_t MCT1FindSupercuts::FindParams(TString parSCinit,
+                                     TArrayD &params, TArrayD &steps)
+{
+    // Setup the event loop which will be executed in the 
+    //                 fcnSupercuts function  of MINUIT
+    //
+    // parSCinit is the name of the file containing the initial values 
+    // of the parameters; 
+    // if parSCinit = ""   'params' and 'steps' are taken as initial values
+
+    *fLog << "=============================================" << endl;
+    *fLog << "Setup event loop for fcnSupercuts" << endl;
+
+    if (fHadronnessName.IsNull())
+    {
+      *fLog << "MCT1FindSupercuts::FindParams; hadronness name is not defined... aborting"
+            << endl;
+      return kFALSE;
+    }
+
+    if (fMatrixTrain == NULL)
+    {
+      *fLog << "MCT1FindSupercuts::FindParams; training matrix is not defined... aborting"
+            << endl;
+      return kFALSE;
+    }
+
+    if (fMatrixTrain->GetM().GetNrows() <= 0)
+    {
+      *fLog << "MCT1FindSupercuts::FindParams; training matrix has no entries"
+            << endl;
+      return kFALSE;
+    }
+
+    MParList  parlistfcn;
+    MTaskList tasklistfcn;
+
+    // loop over rows of matrix
+    MMatrixLoop loop(fMatrixTrain);
+
+    //--------------------------------
+    // create container for the supercut parameters
+    // and set them to their initial values
+    MCT1Supercuts super;
+
+    // take initial values from file parSCinit
+    if (parSCinit != "")
+    {
+      TFile inparam(parSCinit);
+      super.Read("MCT1Supercuts");
+      inparam.Close();
+      *fLog << "MCT1FindSupercuts::FindParams; initial values of parameters are taken from file "
+            << parSCinit << endl;
+    }
+
+    // take initial values from 'params' and/or 'steps'
+    else if (params.GetSize() != 0  || steps.GetSize()  != 0 )
+    {
+      if (params.GetSize()  != 0)
+      {
+        *fLog << "MCT1FindSupercuts::FindParams; initial values of parameters are taken from 'params'"
+              << endl;
+        super.SetParameters(params);
+      }
+      if (steps.GetSize()  != 0)
+      {
+        *fLog << "MCT1FindSupercuts::FindParams; initial step sizes are taken from 'steps'"
+              << endl;
+        super.SetStepsizes(steps);
+      }
+    }
+    else
+    {
+        *fLog << "MCT1FindSupercuts::FindParams; initial values and step sizes are taken from the MCT1Supercits constructor"
+              << endl;
+    }
+
+
+    //--------------------------------
+    // calculate supercuts hadronness
+    fCalcHadTrain->SetHadronnessName(fHadronnessName);
+
+    // apply the supercuts
+    MF scfilter(fHadronnessName+".fHadronness>0.5");
+    MContinue supercuts(&scfilter);
+
+    // plot |alpha|
+    const TString  mh3Name = "AlphaFcn";
+    MBinning binsalpha("Binning"+mh3Name);
+    binsalpha.SetEdges(54, -12.0, 96.0);
+
+    *fLog << warn << "WARNING------------>ALPHA IS ASSUMED TO BE IN COLUMN 7!!!!!!!!" << endl;
+
+    // |alpha| is assumed to be in column 7 of the matrix
+    MH3 alpha("MatrixTrain[7]");
+    alpha.SetName(mh3Name);
+
+    MFillH fillalpha(&alpha);
+
+    // book histograms to be filled during the optimization
+    //                              ! not in the event loop !
+    MHCT1Supercuts plotsuper;
+    plotsuper.SetupFill(&parlistfcn);
+
+    //******************************
+    // entries in MParList (extension of old MParList)
+    
+    parlistfcn.AddToList(&tasklistfcn);
+    parlistfcn.AddToList(&super);
+    parlistfcn.AddToList(fCam);
+    parlistfcn.AddToList(fMatrixTrain);
+
+    parlistfcn.AddToList(&binsalpha);
+    parlistfcn.AddToList(&alpha);
+
+    parlistfcn.AddToList(&plotsuper);
+
+    //******************************
+    // entries in MTaskList
+
+    tasklistfcn.AddToList(&loop);
+    tasklistfcn.AddToList(fCalcHadTrain);
+    tasklistfcn.AddToList(&supercuts);
+    tasklistfcn.AddToList(&fillalpha);
+
+
+    //******************************
+
+    MEvtLoop evtloopfcn("EvtLoopFCN");
+    evtloopfcn.SetParList(&parlistfcn);
+    *fLog << "Event loop for fcnSupercuts has been setup" << endl;
+
+    // address of evtloopfcn is used in CallMinuit()
+
+
+    //-----------------------------------------------------------------------
+    //
+    //----------   Start of minimization part   --------------------
+    //
+    // Do the minimization with MINUIT
+    //
+    // Be careful: This is not thread safe
+    //
+    *fLog << "========================================================" << endl;
+    *fLog << "Start minimization for supercuts" << endl;
+
+
+    // -------------------------------------------
+    // prepare call to MINUIT
+    //
+
+    // get initial values of parameters 
+    fVinit = super.GetParameters();
+    fStep  = super.GetStepsizes();
+
+    TString name[fVinit.GetSize()];
+    fStep.Set(fVinit.GetSize());
+    fLimlo.Set(fVinit.GetSize());
+    fLimup.Set(fVinit.GetSize());
+    fFix.Set(fVinit.GetSize());
+
+    fNpar = fVinit.GetSize();
+
+    for (UInt_t i=0; i<fNpar; i++)
+    {
+        name[i]   = "p";
+        name[i]  += i+1;
+        //fStep[i]  = TMath::Abs(fVinit[i]/10.0);
+        fLimlo[i] = -100.0;
+        fLimup[i] =  100.0;
+        fFix[i]   =     0;
+    }
+
+    // these parameters make no sense, fix them at 0.0
+    fVinit[33] = 0.0;
+    fStep[33]  = 0.0;
+    fFix[33]   = 1;
+
+    fVinit[36] = 0.0;
+    fStep[36]  = 0.0;
+    fFix[36]   = 1;
+
+    fVinit[39] = 0.0;
+    fStep[39]  = 0.0;
+    fFix[39]   = 1;
+
+    fVinit[41] = 0.0;
+    fStep[41]  = 0.0;
+    fFix[41]   = 1;
+
+    fVinit[44] = 0.0;
+    fStep[44]  = 0.0;
+    fFix[44]   = 1;
+
+    fVinit[47] = 0.0;
+    fStep[47]  = 0.0;
+    fFix[47]   = 1;
+
+    // vary only first 48 parameters
+    //for (UInt_t i=0; i<fNpar; i++)
+    //{
+    //    if (i >= 48)
+    //	{
+    //      fStep[i] = 0.0;
+    //      fFix[i]  =   1;
+    //	}
+    //}
+ 
+
+    // -------------------------------------------
+    // call MINUIT
+
+    TStopwatch clock;
+    clock.Start();
+
+    *fLog << "before calling CallMinuit" << endl;
+
+    MMinuitInterface inter;               
+    Bool_t rc = inter.CallMinuit(fcnSupercuts, name,
+                                 fVinit, fStep, fLimlo, fLimup, fFix,
+                                 &evtloopfcn, "SIMPLEX", kFALSE);
+ 
+    *fLog << "after calling CallMinuit" << endl;
+
+    *fLog << "Time spent for the minimization in MINUIT :   " << endl;;
+    clock.Stop();
+    clock.Print();
+
+    plotsuper.DrawClone();
+
+    if (!rc)
+        return kFALSE;
+
+    *fLog << "Minimization for supercuts finished" << endl;
+    *fLog << "========================================================" << endl;
+
+
+    // -----------------------------------------------------------------
+    // in 'fcnSupercuts' (IFLAG=3) the optimum parameter values were put 
+    //                    into MCT1Supercuts
+
+    // write optimum parameter values onto file filenameParam
+    
+    TFile outparam(fFilenameParam, "RECREATE"); 
+    super.Write();
+    outparam.Close();
+
+    *fLog << "Optimum parameter values for supercuts were written onto file '"
+              << fFilenameParam << "' :" << endl;
+
+    const TArrayD &check = super.GetParameters();
+    for (Int_t i=0; i<check.GetSize(); i++)
+        *fLog << check[i] << ",  ";
+    *fLog << endl;
+
+
+
+    *fLog << "End of  supercuts optimization part" << endl;
+    *fLog << "======================================================" << endl;
+
+    return kTRUE;
+}
+
+
+// -----------------------------------------------------------------------
+//
+// Test the supercuts on the test sample
+//
+
+Bool_t MCT1FindSupercuts::TestParams()
+{
+    if (fMatrixTest->GetM().GetNrows() <= 0)
+    {
+        *fLog << "MCT1FindSupercuts::TestParams; test matrix has no entries" 
+              << endl;
+        return kFALSE;
+    }
+
+    // -------------   TEST the supercuts    ------------------------------
+    //
+    *fLog << "Test the supercuts on the test sample" << endl;
+
+    // -----------------------------------------------------------------
+    // read optimum parameter values from file filenameParam
+    // into array 'supercutsPar'
+
+    TFile inparam(fFilenameParam);
+    MCT1Supercuts scin; 
+    scin.Read("MCT1Supercuts");
+    inparam.Close();
+
+    *fLog << "Optimum parameter values for supercuts were read from file '";
+    *fLog << fFilenameParam << "' :" << endl;
+
+    const TArrayD &supercutsPar = scin.GetParameters();
+    for (Int_t i=0; i<supercutsPar.GetSize(); i++)
+        *fLog << supercutsPar[i] << ",  ";
+    *fLog << endl;
+    //---------------------------
+
+
+    // -----------------------------------------------------------------
+    if (fHadronnessName.IsNull())
+    {
+        *fLog << "MCT1FindSupercuts::TestParams; hadronness name is not defined... aborting";
+        *fLog << endl;
+        return kFALSE;
+    }
+
+    MParList  parlist2;
+    MTaskList tasklist2;
+
+    MCT1Supercuts supercuts;
+    supercuts.SetParameters(supercutsPar);
+
+    fCalcHadTest->SetHadronnessName(fHadronnessName);
+
+
+    //-------------------------------------------
+
+    MMatrixLoop loop(fMatrixTest);
+
+    // plot alpha before applying the supercuts
+    const TString  mh3NameB = "AlphaBefore";
+    MBinning binsalphabef("Binning"+mh3NameB);
+    binsalphabef.SetEdges(54, -12.0, 96.0);
+
+    // |alpha| is assumed to be in column 7 of the matrix
+    MH3 alphabefore("MatrixTest[7]");
+    alphabefore.SetName(mh3NameB);
+
+    TH1 &alphahistb = alphabefore.GetHist();
+    alphahistb.SetName("alphaBefore-TestParams");
+
+    MFillH fillalphabefore(&alphabefore);
+    fillalphabefore.SetName("FillAlphaBefore");
+
+    // apply the supercuts
+    MF scfilter(fHadronnessName+".fHadronness>0.5");
+    MContinue applysupercuts(&scfilter);
+
+    // plot alpha after applying the supercuts
+    const TString  mh3NameA = "AlphaAfter";
+    MBinning binsalphaaft("Binning"+mh3NameA);
+    binsalphaaft.SetEdges(54, -12.0, 96.0);
+
+    MH3 alphaafter("MatrixTest[7]");
+    alphaafter.SetName(mh3NameA);
+
+    TH1 &alphahista = alphaafter.GetHist();
+    alphahista.SetName("alphaAfter-TestParams");
+
+    MFillH fillalphaafter(&alphaafter);
+    fillalphaafter.SetName("FillAlphaAfter");
+
+    //******************************
+    // entries in MParList
+
+    parlist2.AddToList(&tasklist2);
+
+    parlist2.AddToList(&supercuts);
+
+    parlist2.AddToList(fCam);
+    parlist2.AddToList(fMatrixTest);
+
+    parlist2.AddToList(&binsalphabef);
+    parlist2.AddToList(&alphabefore);
+
+    parlist2.AddToList(&binsalphaaft);
+    parlist2.AddToList(&alphaafter);
+
+    //******************************
+    // entries in MTaskList
+
+    tasklist2.AddToList(&loop);
+    tasklist2.AddToList(&fillalphabefore);
+
+    tasklist2.AddToList(fCalcHadTest);
+    tasklist2.AddToList(&applysupercuts);
+
+    tasklist2.AddToList(&fillalphaafter);
+
+    //******************************
+
+    MProgressBar bar2;
+    MEvtLoop evtloop2;
+    evtloop2.SetParList(&parlist2);
+    evtloop2.SetName("EvtLoopTestParams");
+    evtloop2.SetProgressBar(&bar2);
+    Int_t maxevents2 = -1;
+    if (!evtloop2.Eventloop(maxevents2))
+        return kFALSE;
+
+    tasklist2.PrintStatistics(0, kTRUE);
+
+
+    //-------------------------------------------
+    // draw the alpha plots
+
+    MH3* alphaBefore = (MH3*)parlist2.FindObject(mh3NameB, "MH3");
+    TH1  &alphaHist1 = alphaBefore->GetHist();
+    alphaHist1.SetXTitle("|\\alpha|  [\\circ]");
+
+    MH3* alphaAfter = (MH3*)parlist2.FindObject(mh3NameA, "MH3");
+    TH1  &alphaHist2 = alphaAfter->GetHist();
+    alphaHist2.SetXTitle("|\\alpha|  [\\circ]");
+    alphaHist2.SetName("alpha-TestParams");
+
+    TCanvas *c = new TCanvas("AlphaAfterSC", "AlphaTest", 600, 300);
+    c->Divide(2,1);
+
+    gROOT->SetSelectedPad(NULL);
+
+    c->cd(1);
+    alphaHist1.DrawCopy();
+
+    c->cd(2);
+    alphaHist2.DrawCopy();
+
+
+
+    //-------------------------------------------
+    // fit alpha distribution to get the number of excess events and
+    // calculate significance of gamma signal in the alpha plot
+  
+    const Double_t alphasig = 20.0;
+    const Double_t alphamin = 30.0;
+    const Double_t alphamax = 90.0;
+    const Int_t    degree   =    2;
+    const Bool_t   drawpoly  = kTRUE;
+    const Bool_t   fitgauss  = kTRUE;
+    const Bool_t   print     = kTRUE;
+
+    MHFindSignificance findsig;
+    findsig.SetRebin(kTRUE);
+    findsig.SetReduceDegree(kFALSE);
+
+    findsig.FindSigma(&alphaHist2, alphamin, alphamax, degree, 
+                      alphasig, drawpoly, fitgauss, print);
+
+    const Double_t significance = findsig.GetSignificance();
+    const Double_t alphasi = findsig.GetAlphasi();
+
+    *fLog << "Significance of gamma signal after supercuts in test sample : "
+         << significance << " (for |alpha| < " << alphasi << " degrees)" 
+         << endl;
+    //-------------------------------------------
+
+
+    *fLog << "Test of supercuts part finished" << endl;
+    *fLog << "======================================================" << endl;
+
+    return kTRUE;
+}
+
Index: /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1FindSupercuts.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1FindSupercuts.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1FindSupercuts.h	(revision 9661)
@@ -0,0 +1,130 @@
+#ifndef MARS_MCT1FindSupercuts
+#define MARS_MCT1FindSupercuts
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#ifndef ROOT_TArrayD
+#include <TArrayD.h>
+#endif
+#ifndef ROOT_TArrayI
+#include <TArrayI.h>
+#endif
+
+class MFilter;
+class MEvtLoop;
+class MH3;
+class MCT1SupercutsCalc;
+class MGeomCam;
+class MHMatrix;
+/*
+#include "MFilter.h"
+#include "MEvtLoop.h"
+#include "MH3.h"
+#include "MCT1SupercutsCalc.h"
+#include "MGeomCam.h"
+#include "MHMatrix.h"
+*/
+
+class MCT1FindSupercuts : public MParContainer
+{
+private:
+
+  TString fFilenameTrain;
+  TString fFilenameTest;
+
+  Int_t   fHowManyTrain;
+  Int_t   fHowManyTest;
+
+  TString  fFilenameParam;
+
+  TString  fHadronnessName;
+
+  MCT1SupercutsCalc *fCalcHadTrain;
+  MCT1SupercutsCalc *fCalcHadTest;
+
+  MHMatrix          *fMatrixTrain;
+  MHMatrix          *fMatrixTest;
+  MGeomCam          *fCam;
+
+  MEvtLoop *fObjectFit;
+
+  MFilter  *fMatrixFilter; 
+
+  // to comunicate with MINUIT -----------------
+  // attention : dimensions must agree with those in 
+  //             MMinuitInterface::CallMinuit()
+  //char    fParName [80][100];
+  TArrayD fVinit;
+  TArrayD fStep;
+  TArrayD fLimlo;
+  TArrayD fLimup;
+  TArrayI fFix;
+
+  UInt_t     fNpar;
+
+  TString    fMethod;
+
+  Double_t fMin,   fEdm,   fErrdef;
+  Int_t    fNpari, fNparx, fIstat;
+  Int_t    fErrMinimize;
+  //--------------------------------------------
+
+
+public:
+  MCT1FindSupercuts(const char *name=NULL, const char *title=NULL);
+  ~MCT1FindSupercuts();
+
+  void SetFilenameTraining(const TString &name, const Int_t howmany) 
+      {fFilenameTrain = name;  fHowManyTrain = howmany; }
+
+  void SetFilenameTest(const TString &name, const Int_t howmany)     
+      {fFilenameTest     = name;  fHowManyTest  = howmany; }
+
+  void SetFilenameParam(const TString &name)    {fFilenameParam  = name;}
+  void SetHadronnessName(const TString &name)   {fHadronnessName = name;}
+
+  void SetMatrixFilter(MFilter *filter)          {fMatrixFilter = filter;}
+
+  Bool_t DefineTrainMatrix(const TString &name, MH3 &href,
+                           const Int_t howmany, const TString &filetrain); 
+
+  Bool_t DefineTestMatrix(const TString &name, MH3 &href,
+                          const Int_t howmany, const TString &filetest);
+
+  Bool_t DefineTrainTestMatrix(const TString &name, MH3 &href,
+			 const Int_t howmanytrain, const Int_t howmanytest, 
+                         const TString &filetrain, const TString &filetest);
+
+  MHMatrix *GetMatrixTrain() { return fMatrixTrain; }
+  MHMatrix *GetMatrixTest()  { return fMatrixTest;  }
+
+  Bool_t ReadMatrix( const TString &filetrain, const TString &filetest);
+
+  Bool_t FindParams(TString parSCinit, TArrayD &params, TArrayD &steps);
+  Bool_t TestParams();
+
+  ClassDef(MCT1FindSupercuts, 1) // Class for optimization of the Supercuts
+};
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1PadONOFF.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1PadONOFF.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1PadONOFF.cc	(revision 9661)
@@ -0,0 +1,1819 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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, 06/2003 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MCT1PadONOFF
+//
+//  This task applies padding such that for a given pixel and for a given
+//  Theta bin the resulting distribution of the pedestal sigma is identical
+//  to the distributions given by fHSigmaPixTheta and fHDiffPixTheta.
+//
+//  The number of photons, its error and the pedestal sigmas are altered.
+//  On average, the number of photons added is zero.
+//
+//  The formulas used can be found in Thomas Schweizer's Thesis,
+//                                    Section 2.2.1
+//
+//  There are 2 options for the padding :
+//
+//  1) fPadFlag = 1 :
+//     Generate first a Sigmabar using the 2D-histogram Sigmabar vs. Theta
+//     (fHSigmaTheta). Then generate a pedestal sigma for each pixel using
+//     the 3D-histogram Theta, pixel no., Sigma^2-Sigmabar^2
+//     (fHDiffPixTheta).
+//
+//     This is the preferred option as it takes into account the
+//     correlations between the Sigma of a pixel and Sigmabar.
+//
+//  2) fPadFlag = 2 :
+//     Generate a pedestal sigma for each pixel using the 3D-histogram
+//     Theta, pixel no., Sigma (fHSigmaPixTheta).
+//
+//
+//  The padding has to be done before the image cleaning because the
+//  image cleaning depends on the pedestal sigmas.
+//
+//  For random numbers gRandom is used.
+//
+//  This implementation has been tested for CT1 data. For MAGIC some
+//  modifications are necessary.
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCT1PadONOFF.h"
+
+#include <math.h>
+#include <stdio.h>
+
+#include <TH1.h>
+#include <TH2.h>
+#include <TH3.h>
+#include <TRandom.h>
+#include <TCanvas.h>
+#include <TFile.h>
+
+#include "MBinning.h"
+#include "MSigmabar.h"
+#include "MMcEvt.hxx"
+#include "MLog.h"
+#include "MLogManip.h"
+#include "MParList.h"
+#include "MGeomCam.h"
+
+#include "MCerPhotPix.h"
+#include "MCerPhotEvt.h"
+
+#include "MPedPhotCam.h"
+#include "MPedPhotPix.h"
+
+#include "MBlindPixels.h"
+
+#include "MRead.h"
+#include "MFilterList.h"
+#include "MTaskList.h"
+#include "MBlindPixelCalc.h"
+#include "MHBlindPixels.h"
+#include "MFillH.h"
+#include "MHSigmaTheta.h"
+#include "MEvtLoop.h"
+
+ClassImp(MCT1PadONOFF);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+MCT1PadONOFF::MCT1PadONOFF(const char *name, const char *title) 
+{
+  fName  = name  ? name  : "MCT1PadONOFF";
+  fTitle = title ? title : "Task for the ON-OFF padding";
+
+  fPadFlag = 1;
+  *fLog << "MCT1PadONOFF: fPadFlag = " << fPadFlag << endl;
+
+  fType = "";
+
+  fHSigmaTheta       = NULL;
+  fHSigmaThetaON     = NULL;
+  fHSigmaThetaOFF    = NULL;
+
+  fHSigmaPixTheta    = NULL;
+  fHSigmaPixThetaON  = NULL;
+  fHSigmaPixThetaOFF = NULL;
+
+  fHDiffPixTheta     = NULL;
+  fHDiffPixThetaON   = NULL;
+  fHDiffPixThetaOFF  = NULL;
+
+  fHgON  = NULL;
+  fHgOFF = NULL;
+
+  fHBlindPixIdTheta = NULL;
+  fHBlindPixNTheta  = NULL;
+
+  fHSigmaPedestal = NULL;
+  fHPhotons       = NULL;
+  fHNSB           = NULL;
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor. 
+//
+MCT1PadONOFF::~MCT1PadONOFF()
+{
+  if (fHBlindPixIdTheta   != NULL) delete fHBlindPixIdTheta;
+  if (fHBlindPixNTheta    != NULL) delete fHBlindPixNTheta;
+
+  if (fHSigmaTheta    != NULL) delete fHSigmaTheta;
+  if (fHSigmaPixTheta != NULL) delete fHSigmaPixTheta;
+  if (fHDiffPixTheta  != NULL) delete fHDiffPixTheta;
+
+  if (fHSigmaPedestal != NULL) delete fHSigmaPedestal;
+  if (fHPhotons       != NULL) delete fHPhotons;
+  if (fHNSB           != NULL) delete fHNSB;
+
+  if (fInfile         != NULL) delete fInfile;
+}
+
+// --------------------------------------------------------------------------
+//
+// Merge the distributions of ON and OFF data
+//
+//   fHSigmaTheta    2D-histogram  (Theta, sigmabar)
+//   fHSigmaPixTheta 3D-hiostogram (Theta, pixel, sigma)
+//   fHDiffPixTheta  3D-histogram  (Theta, pixel, sigma^2-sigmabar^2)
+//   fHBlindPixIdTheta 2D-histogram  (Theta, blind pixel Id)
+//   fHBlindPixNTheta  2D-histogram  (Theta, no.of blind pixels )
+//
+// and define the target distributions for the padding
+//
+Bool_t MCT1PadONOFF::MergeHistograms(TH2D *sigthon,     TH2D *sigthoff,
+                                  TH3D *sigpixthon,  TH3D *sigpixthoff,
+                                  TH3D *diffpixthon, TH3D *diffpixthoff,
+                                  TH2D *blindidthon, TH2D *blindidthoff,
+                                  TH2D *blindnthon,  TH2D *blindnthoff)
+{
+  *fLog << "----------------------------------------------------------------------------------" << endl;
+  *fLog << "Merge the ON and OFF histograms to obtain the target distributions for the padding"
+        << endl;
+
+  //-------------------------------------------------------------
+  // merge the distributions of ON and OFF events
+  // to obtain the target distribution fHSigmaTheta
+  //
+
+  Double_t eps = 1.e-10;
+
+  fHSigmaTheta = new TH2D( (TH2D&)*sigthon );
+  fHSigmaTheta->SetNameTitle("2D-ThetaSigmabar", "2D-ThetaSigmabar (target)");
+
+  // get binning for fHgON and fHgOFF from sigthon
+  // binning in Theta
+  TAxis *ax = sigthon->GetXaxis();
+  Int_t nbinstheta = ax->GetNbins();
+  TArrayD edgesx;
+  edgesx.Set(nbinstheta+1);
+  for (Int_t i=0; i<=nbinstheta; i++)
+  {
+    edgesx[i] = ax->GetBinLowEdge(i+1);
+    // *fLog << "i, theta low edge = " << i << ",  " << edgesx[i] << endl; 
+  }
+  MBinning binth;
+  binth.SetEdges(edgesx);
+
+  // binning in sigmabar
+  TAxis *ay = sigthon->GetYaxis();
+  Int_t nbinssig = ay->GetNbins();
+  TArrayD edgesy;
+  edgesy.Set(nbinssig+1);
+  for (Int_t i=0; i<=nbinssig; i++)
+  {
+    edgesy[i] = ay->GetBinLowEdge(i+1); 
+    // *fLog << "i, sigmabar low edge = " << i << ",  " << edgesy[i] << endl; 
+  }
+  MBinning binsg;
+  binsg.SetEdges(edgesy);
+
+
+  fHgON = new TH3D;
+  MH::SetBinning(fHgON, &binth, &binsg, &binsg);
+  fHgON->SetNameTitle("3D-PaddingMatrixON", "3D-PadMatrixThetaON");
+
+  fHgOFF = new TH3D;
+  MH::SetBinning(fHgOFF, &binth, &binsg, &binsg);
+  fHgOFF->SetNameTitle("3D-PaddingMatrixOFF", "3D-PadMatrixThetaOFF");
+
+  //............   loop over Theta bins   ...........................
+
+  // hista is the normalized 1D histogram of sigmabar for ON data
+  // histb is the normalized 1D histogram of sigmabar for OFF data
+  // histc is the difference ON-OFF
+
+  // at the beginning, histap is a copy of hista
+  // at the end, it will be the 1D histogram for ON data after padding
+
+  // at the beginning, histbp is a copy of histb
+  // at the end, it will be the 1D histogram for OFF data after padding
+
+  // at the beginning, histcp is a copy of histc
+  // at the end, it should be zero
+
+  *fLog << "MCT1PadONOFF::MergeHistograms; bins of Theta, Sigmabarold, Sigmabarnew, fraction of events to be padded" << endl;
+  for (Int_t l=1; l<=nbinstheta; l++)
+  {
+    TH1D *hista  = sigthon->ProjectionY("sigon_y", l, l, "");
+    Stat_t suma = hista->Integral();
+    hista->Scale(1./suma);
+
+    TH1D *histap  = new TH1D( (const TH1D&)*hista );
+
+    TH1D *histb  = sigthoff->ProjectionY("sigoff_y", l, l, "");
+    Stat_t sumb = histb->Integral();
+    histb->Scale(1./sumb);
+
+    TH1D *histbp  = new TH1D( (const TH1D&)*histb );
+
+    TH1D *histc   = new TH1D( (const TH1D&)*hista );
+    histc->Add(histb, -1.0);
+
+    TH1D *histcp  = new TH1D( (const TH1D&)*histc );    
+
+
+  // calculate matrix g
+
+  // fHg[k][j] (if <0.0) tells how many ON events in bin k should be padded
+  //              from sigma_k to sigma_j
+
+
+  // fHg[k][j] (if >0.0) tells how many OFF events in bin k should be padded
+  //              from sigma_k to sigma_j
+
+  //--------   start j loop   ------------------------------------------------
+  // loop over bins in histc, starting from the end
+  Double_t v, s, w, t, x, u, a, b, c, arg;
+
+  for (Int_t j=nbinssig; j >= 1; j--)
+  {
+    v = histcp->GetBinContent(j);
+    if ( fabs(v) < eps ) continue;
+    if (v >= 0.0) 
+      s = 1.0;
+    else
+      s = -1.0;
+
+    //................   start k loop   ......................................
+    // look for a bin k which may compensate the content of bin j
+    for (Int_t k=j-1; k >= 1; k--)
+    {
+      w = histcp->GetBinContent(k);
+      if ( fabs(w) < eps ) continue;
+      if (w >= 0.0) 
+        t = 1.0;
+      else
+        t = -1.0;
+
+      if (s==t) continue;
+
+      x = v + w;
+      if (x >= 0.0) 
+        u = 1.0;
+      else
+        u = -1.0;
+
+      if (u == s)
+      {
+        arg = -w;
+
+        if (arg <=0.0)
+	{
+          fHgON->SetBinContent (l, k, j, -arg);
+          fHgOFF->SetBinContent(l, k, j,  0.0);
+	}
+        else
+	{
+          fHgON->SetBinContent (l, k, j,  0.0);
+          fHgOFF->SetBinContent(l, k, j,  arg);
+	}
+
+
+        *fLog << "l, k, j, arg = " << l << ",  " << k << ",  " << j 
+              << ",  " << arg << endl;
+
+	//        g(k-1, j-1)   = arg;
+        //cout << "k-1, j-1, arg = " << k-1 << ",  " << j-1 << ",  " 
+        //     << arg << endl;
+
+        //......................................
+        // this is for checking the procedure
+        if (arg < 0.0)
+        {
+          a = histap->GetBinContent(k);
+          histap->SetBinContent(k, a+arg);
+          a = histap->GetBinContent(j);
+          histap->SetBinContent(j, a-arg);
+        }
+        else
+        {
+          b = histbp->GetBinContent(k);
+          histbp->SetBinContent(k, b-arg);
+          b = histbp->GetBinContent(j);
+          histbp->SetBinContent(j, b+arg);
+        }
+        //......................................
+
+        histcp->SetBinContent(k, 0.0);
+        histcp->SetBinContent(j,   x);
+
+        //......................................
+        // redefine v 
+        v = histcp->GetBinContent(j);
+        if ( fabs(v) < eps ) break;
+        if (v >= 0.0) 
+          s = 1.0;
+        else
+          s = -1.0;
+        //......................................
+       
+        continue;
+      }
+
+      arg = v;
+
+      if (arg <=0.0)
+      {
+        fHgON->SetBinContent (l, k, j, -arg);
+        fHgOFF->SetBinContent(l, k, j,  0.0);
+      }
+      else
+      {
+        fHgON->SetBinContent (l, k, j,  0.0);
+        fHgOFF->SetBinContent(l, k, j,  arg);
+      }
+
+      *fLog << "l, k, j, arg = " << l << ",  " << k << ",  " << j 
+            << ",  " << arg << endl;
+
+      //g(k-1, j-1) = arg;
+      //cout << "k-1, j-1, arg = " << k-1 << ",  " << j-1 << ",  " 
+      //     << arg << endl;
+
+      //......................................
+      // this is for checking the procedure
+      if (arg < 0.0)
+      {
+        a = histap->GetBinContent(k);
+        histap->SetBinContent(k, a+arg);
+        a = histap->GetBinContent(j);
+        histap->SetBinContent(j, a-arg);
+      }
+      else
+      {
+        b = histbp->GetBinContent(k);
+
+        histbp->SetBinContent(k, b-arg);
+        b = histbp->GetBinContent(j);
+        histbp->SetBinContent(j, b+arg);
+      }
+      //......................................
+
+      histcp->SetBinContent(k,   x);
+      histcp->SetBinContent(j, 0.0);
+
+      break;
+    }
+    //................   end k loop   ......................................
+  } 
+  //--------   end j loop   ------------------------------------------------
+
+  // check results for this Theta bin
+  for (Int_t j=1; j<=nbinssig; j++)
+  {
+    a = histap->GetBinContent(j);
+    b = histbp->GetBinContent(j);
+    c = histcp->GetBinContent(j);
+
+    if( fabs(a-b)>3.0*eps  ||  fabs(c)>3.0*eps )
+      *fLog << "MCT1PadONOFF::Read; inconsistency in results; a, b, c = "
+            << a << ",  " << b << ",  " << c << endl;
+  }
+    
+
+  // fill target distribution SigmaTheta
+  // for this Theta bin
+  //
+  for (Int_t j=1; j<=nbinssig; j++)
+  {
+    a = histap->GetBinContent(j);
+    fHSigmaTheta->SetBinContent(l, j, a);
+  }
+
+  delete hista;
+  delete histb;
+  delete histc;
+
+  delete histap;
+  delete histbp;
+  delete histcp;
+  }
+  //............   end of loop over Theta bins   ....................
+
+  
+  // target distributions for MC
+  //        SigmaPixTheta and DiffPixTheta
+  //        BlindPixIdTheta and BlindPixNTheta     
+  // are calculated as averages of the ON and OFF distributions
+
+  fHSigmaThetaON = sigthon;
+  fHSigmaThetaON->SetNameTitle("2D-ThetaSigmabarON", "2D-ThetaSigmabarON (target)");
+
+  fHSigmaThetaOFF = sigthoff;
+  fHSigmaThetaOFF->SetNameTitle("2D-ThetaSigmabarOFF", "2D-ThetaSigmabarOFF (target)");
+
+
+  fHBlindPixNTheta = new TH2D( (TH2D&)*blindnthon );
+  fHBlindPixNTheta->SetNameTitle("2D-ThetaBlindN", "2D-ThetaBlindN (target)");
+
+  fHBlindPixIdTheta = new TH2D( (TH2D&)*blindidthon );
+  fHBlindPixIdTheta->SetNameTitle("2D-ThetaBlindId", "2D-ThetaBlindId (target)");
+
+  fHSigmaPixTheta = new TH3D( (TH3D&)*sigpixthon );
+  fHSigmaPixTheta->SetNameTitle("3D-ThetaPixSigma", "3D-ThetaPixSigma (target)");
+
+  fHSigmaPixThetaON = sigpixthon;
+  fHSigmaPixThetaON->SetNameTitle("3D-ThetaPixSigmaON", "3D-ThetaPixSigmaON (target)");
+
+  fHSigmaPixThetaOFF = sigpixthoff;
+  fHSigmaPixThetaOFF->SetNameTitle("3D-ThetaPixSigmaOFF", "3D-ThetaPixSigmaOFF (target)");
+
+  fHDiffPixTheta = new TH3D( (TH3D&)*diffpixthon );
+  fHDiffPixTheta->SetNameTitle("3D-ThetaPixDiff", "3D-ThetaPixDiff (target)");
+
+  fHDiffPixThetaON = diffpixthon;
+  fHDiffPixThetaON->SetNameTitle("3D-ThetaPixDiffON", "3D-ThetaPixDiffON (target)");
+
+  fHDiffPixThetaOFF = diffpixthoff;
+  fHDiffPixThetaOFF->SetNameTitle("3D-ThetaPixDiffOFF", "3D-ThetaPixDiffOFF (target)");
+
+
+  for (Int_t j=1; j<=nbinstheta; j++)
+  {
+    // fraction of ON/OFF events to be padded to a sigmabar 
+    // of the OFF/ON events : fracON, fracOFF
+
+    Double_t fracON  = fHgON->Integral (j, j, 1, nbinssig, 1, nbinssig, "");
+    Double_t fracOFF = fHgOFF->Integral(j, j, 1, nbinssig, 1, nbinssig, "");
+
+    TAxis *ax;
+    TAxis *ay;
+    TAxis *az;
+
+    Double_t entON;
+    Double_t entOFF;
+
+    Double_t normON;
+    Double_t normOFF;
+
+    // set ranges for 2D-projections of 3D-histograms
+    ax = sigpixthon->GetXaxis();
+    ax->SetRange(j, j);
+    ax = sigpixthoff->GetXaxis();
+    ax->SetRange(j, j);
+
+    ax = diffpixthon->GetXaxis();
+    ax->SetRange(j, j);
+    ax = diffpixthoff->GetXaxis();
+    ax->SetRange(j, j);
+
+    TH2D *hist;
+    TH2D *histOFF;
+
+    TH1D *hist1;
+    TH1D *hist1OFF;
+
+    // weights for ON and OFF distrubtions when
+    // calculating the weighted average
+    Double_t facON  = 0.5 * (1. - fracON + fracOFF);
+    Double_t facOFF = 0.5 * (1. + fracON - fracOFF);
+  
+    *fLog << fracON << ",  " << fracOFF << ",  "
+          << facON  << ",  " << facOFF  << endl; 
+    //-------------------------------------------
+    ay = blindnthon->GetYaxis();
+    Int_t nbinsn = ay->GetNbins();
+
+    hist1    = (TH1D*)blindnthon->ProjectionY ("", j, j, "");
+    hist1->SetName("dummy");
+    hist1OFF = (TH1D*)blindnthoff->ProjectionY("", j, j, "");
+
+    // number of events in this theta bin
+    entON  = hist1->Integral();
+    entOFF = hist1OFF->Integral();
+
+    *fLog << "BlindPixNTheta : j, entON, entOFF = " << j << ",  " 
+          << entON  << ",  " << entOFF  << endl;
+
+    normON  = entON<=0.0  ? 0.0 : 1.0/entON;
+    normOFF = entOFF<=0.0 ? 0.0 : 1.0/entOFF;
+
+    hist1->Scale(normON);
+    hist1OFF->Scale(normOFF);
+
+    // weighted average of ON and OFF distributions
+    hist1->Scale(facON);
+    hist1->Add(hist1OFF, facOFF); 
+
+    for (Int_t k=1; k<=nbinsn; k++)
+      {
+        Double_t cont = hist1->GetBinContent(k);
+        fHBlindPixNTheta->SetBinContent(j, k, cont);  
+      }
+
+    delete hist1;
+    delete hist1OFF;
+
+    //-------------------------------------------
+    ay = blindidthon->GetYaxis();
+    Int_t nbinsid = ay->GetNbins();
+
+    hist1    = (TH1D*)blindidthon->ProjectionY ("", j, j, "");
+    hist1->SetName("dummy");
+    hist1OFF = (TH1D*)blindidthoff->ProjectionY("", j, j, "");
+
+    hist1->Scale(normON);
+    hist1OFF->Scale(normOFF);
+
+    // weighted average of ON and OFF distributions
+    hist1->Scale(facON);
+    hist1->Add(hist1OFF, facOFF); 
+
+    for (Int_t k=1; k<=nbinsid; k++)
+      {
+        Double_t cont = hist1->GetBinContent(k);
+        fHBlindPixIdTheta->SetBinContent(j, k, cont);  
+      }
+
+    delete hist1;
+    delete hist1OFF;
+
+    //-------------------------------------------
+    ay = sigpixthon->GetYaxis();
+    Int_t nbinspix = ay->GetNbins();
+
+    az = sigpixthon->GetZaxis();
+    Int_t nbinssigma = az->GetNbins();
+
+    hist    = (TH2D*)sigpixthon->Project3D("zy");
+    hist->SetName("dummy");
+    histOFF = (TH2D*)sigpixthoff->Project3D("zy");
+
+    hist->Scale(normON);
+    histOFF->Scale(normOFF);
+
+    // weighted average of ON and OFF distributions
+
+    hist->Scale(facON);
+    hist->Add(histOFF, facOFF); 
+
+    for (Int_t k=1; k<=nbinspix; k++)
+      for (Int_t l=1; l<=nbinssigma; l++)
+      {
+        Double_t cont = hist->GetBinContent(k,l);
+        fHSigmaPixTheta->SetBinContent(j, k, l, cont);  
+      }
+
+    delete hist;
+    delete histOFF;
+
+    //-------------------------------------------
+    ay = diffpixthon->GetYaxis();
+    Int_t nbinspixel = ay->GetNbins();
+
+    az = diffpixthon->GetZaxis();
+    Int_t nbinsdiff = az->GetNbins();
+
+    hist    = (TH2D*)diffpixthon->Project3D("zy");
+    hist->SetName("dummy");
+    histOFF = (TH2D*)diffpixthoff->Project3D("zy");
+
+    hist->Scale(normON);
+    histOFF->Scale(normOFF);
+
+    // weighted average of ON and OFF distributions
+    hist->Scale(facON);
+    hist->Add(histOFF, facOFF); 
+
+    for (Int_t k=1; k<=nbinspixel; k++)
+      for (Int_t l=1; l<=nbinsdiff; l++)
+      {
+        Double_t cont = hist->GetBinContent(k,l);
+        fHDiffPixTheta->SetBinContent(j, k, l, cont);  
+      }
+
+    delete hist;
+    delete histOFF;
+
+    //-------------------------------------------
+  }
+
+
+  *fLog << "The target distributions for the padding have been created" 
+        << endl;
+  *fLog << "----------------------------------------------------------" 
+        << endl;
+  //--------------------------------------------
+
+  fHSigmaTheta->SetDirectory(NULL);
+  fHSigmaThetaON->SetDirectory(NULL);
+  fHSigmaThetaOFF->SetDirectory(NULL);
+
+  fHSigmaPixTheta->SetDirectory(NULL);
+  fHSigmaPixThetaON->SetDirectory(NULL);
+  fHSigmaPixThetaOFF->SetDirectory(NULL);
+
+  fHDiffPixTheta->SetDirectory(NULL);
+  fHDiffPixThetaON->SetDirectory(NULL);
+  fHDiffPixThetaOFF->SetDirectory(NULL);
+
+  fHBlindPixIdTheta->SetDirectory(NULL);
+  fHBlindPixNTheta->SetDirectory(NULL);
+
+
+  fHgON->SetDirectory(NULL);
+  fHgOFF->SetDirectory(NULL);
+
+
+  return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Read target distributions from a file
+//
+//
+Bool_t MCT1PadONOFF::ReadTargetDist(const char* namefilein)
+{
+  *fLog << "Read padding histograms from file " << namefilein << endl;
+
+  fInfile = new TFile(namefilein);
+  fInfile->ls();
+
+    //------------------------------------
+
+      fHSigmaTheta = 
+      (TH2D*) gROOT->FindObject("2D-ThetaSigmabar");
+      if (!fHSigmaTheta)
+	{
+          *fLog << "Object '2D-ThetaSigmabar' not found on root file" << endl;
+          return kFALSE;
+	}
+      *fLog << "Object '2D-ThetaSigmabar' was read in" << endl;
+
+      fHSigmaThetaON = 
+      (TH2D*) gROOT->FindObject("2D-ThetaSigmabarON");
+      if (!fHSigmaThetaON)
+	{
+          *fLog << "Object '2D-ThetaSigmabarON' not found on root file" << endl;
+          return kFALSE;
+	}
+      *fLog << "Object '2D-ThetaSigmabarON' was read in" << endl;
+
+      fHSigmaThetaOFF = 
+      (TH2D*) gROOT->FindObject("2D-ThetaSigmabarOFF");
+      if (!fHSigmaThetaOFF)
+	{
+          *fLog << "Object '2D-ThetaSigmabarOFF' not found on root file" << endl;
+          return kFALSE;
+	}
+      *fLog << "Object '2D-ThetaSigmabarOFF' was read in" << endl;
+
+      fHSigmaPixTheta = 
+      (TH3D*) gROOT->FindObject("3D-ThetaPixSigma");
+      if (!fHSigmaPixTheta)
+	{
+          *fLog << "Object '3D-ThetaPixSigma' not found on root file" << endl;
+          return kFALSE;
+	}
+      *fLog << "Object '3D-ThetaPixSigma' was read in" << endl;
+
+      fHSigmaPixThetaON = 
+      (TH3D*) gROOT->FindObject("3D-ThetaPixSigmaON");
+      if (!fHSigmaPixThetaON)
+	{
+          *fLog << "Object '3D-ThetaPixSigmaON' not found on root file" << endl;
+          return kFALSE;
+	}
+      *fLog << "Object '3D-ThetaPixSigmaON' was read in" << endl;
+
+      fHSigmaPixThetaOFF = 
+      (TH3D*) gROOT->FindObject("3D-ThetaPixSigmaOFF");
+      if (!fHSigmaPixThetaOFF)
+	{
+          *fLog << "Object '3D-ThetaPixSigmaOFF' not found on root file" << endl;
+          return kFALSE;
+	}
+      *fLog << "Object '3D-ThetaPixSigmaOFF' was read in" << endl;
+
+      fHDiffPixTheta = 
+      (TH3D*) gROOT->FindObject("3D-ThetaPixDiff");
+      if (!fHDiffPixTheta)
+	{
+          *fLog << "Object '3D-ThetaPixDiff' not found on root file" << endl;
+          return kFALSE;
+	}
+      *fLog << "Object '3D-ThetaPixDiff' was read in" << endl;
+
+      fHDiffPixThetaON = 
+      (TH3D*) gROOT->FindObject("3D-ThetaPixDiffON");
+      if (!fHDiffPixThetaON)
+	{
+          *fLog << "Object '3D-ThetaPixDiffON' not found on root file" << endl;
+          return kFALSE;
+	}
+      *fLog << "Object '3D-ThetaPixDiffON' was read in" << endl;
+
+      fHDiffPixThetaOFF = 
+      (TH3D*) gROOT->FindObject("3D-ThetaPixDiffOFF");
+      if (!fHDiffPixThetaOFF)
+	{
+          *fLog << "Object '3D-ThetaPixDiffOFF' not found on root file" << endl;
+          return kFALSE;
+	}
+      *fLog << "Object '3D-ThetaPixDiffOFF' was read in" << endl;
+
+      fHgON = 
+      (TH3D*) gROOT->FindObject("3D-PaddingMatrixON");
+      if (!fHgON)
+	{
+          *fLog << "Object '3D-PaddingMatrixON' not found on root file" << endl;
+          return kFALSE;
+	}
+      *fLog << "Object '3D-PaddingMatrixON' was read in" << endl;
+
+      fHgOFF = 
+      (TH3D*) gROOT->FindObject("3D-PaddingMatrixOFF");
+      if (!fHgOFF)
+	{
+          *fLog << "Object '3D-PaddingMatrixOFF' not found on root file" << endl;
+          return kFALSE;
+	}
+      *fLog << "Object '3D-PaddingMatrixOFF' was read in" << endl;
+
+
+      fHBlindPixIdTheta = 
+      (TH2D*) gROOT->FindObject("2D-ThetaBlindId");
+      if (!fHBlindPixIdTheta)
+	{
+          *fLog << "Object '2D-ThetaBlindId' not found on root file" << endl;
+          return kFALSE;
+	}
+      *fLog << "Object '2D-ThetaBlindId' was read in" << endl;
+
+      fHBlindPixNTheta = 
+      (TH2D*) gROOT->FindObject("2D-ThetaBlindN");
+      if (!fHBlindPixNTheta)
+	{
+          *fLog << "Object '2D-ThetaBlindN' not found on root file" << endl;
+          return kFALSE;
+	}
+      *fLog << "Object '2D-ThetaBlindN' was read in" << endl;
+
+
+    //------------------------------------
+
+  return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Write target distributions onto a file
+//
+//
+Bool_t MCT1PadONOFF::WriteTargetDist(const char* namefileout)
+{
+  *fLog << "Write padding histograms onto file " << namefileout << endl;
+
+  TFile outfile(namefileout, "RECREATE");
+
+  fHBlindPixNTheta->Write();
+  fHBlindPixIdTheta->Write();
+
+  fHSigmaTheta->Write();
+  fHSigmaThetaON->Write();
+  fHSigmaThetaOFF->Write();
+
+  fHSigmaPixTheta->Write();
+  fHSigmaPixThetaON->Write();
+  fHSigmaPixThetaOFF->Write();
+
+  fHDiffPixTheta->Write();
+  fHDiffPixThetaON->Write();
+  fHDiffPixThetaOFF->Write();
+
+  fHgON->Write();
+  fHgOFF->Write();
+
+  *fLog << "MCT1PadONOFF::WriteTargetDist; target histograms written onto file "
+        << namefileout << endl;
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Set type of data to be padded
+//
+//     this is not necessary if the type of the data can be recognized
+//     directly from the input
+//
+//
+void MCT1PadONOFF::SetDataType(const char* type)
+{
+  fType = type;
+  *fLog << "MCT1PadONOFF::SetDataType(); type of data to be padded : " 
+        << fType << endl; 
+
+  return;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Set the option for the padding
+//
+//  There are 2 options for the padding :
+//
+//  1) fPadFlag = 1 :
+//     Generate first a Sigmabar using the 2D-histogram Sigmabar vs. Theta
+//     (fHSigmaTheta). Then generate a pedestal sigma for each pixel using
+//     the 3D-histogram Theta, pixel no., Sigma^2-Sigmabar^2
+//     (fHDiffPixTheta).
+//
+//     This is the preferred option as it takes into account the
+//     correlations between the Sigma of a pixel and Sigmabar.
+//
+//  2) fPadFlag = 2 :
+//     Generate a pedestal sigma for each pixel using the 3D-histogram
+//     Theta, pixel no., Sigma (fHSigmaPixTheta).
+//
+void MCT1PadONOFF::SetPadFlag(Int_t padflag)
+{
+  fPadFlag = padflag;
+  *fLog << "MCT1PadONOFF::SetPadFlag(); choose option " << fPadFlag << endl; 
+}
+
+// --------------------------------------------------------------------------
+//
+//  Set the pointers and prepare the histograms
+//
+Int_t MCT1PadONOFF::PreProcess(MParList *pList)
+{
+  if ( !fHSigmaTheta       ||  !fHSigmaThetaON    ||  !fHSigmaThetaOFF    ||  
+       !fHSigmaPixTheta    ||  !fHSigmaPixThetaON ||  !fHSigmaPixThetaOFF ||
+       !fHDiffPixTheta     ||  !fHDiffPixThetaON  ||  !fHDiffPixThetaOFF  ||
+       !fHBlindPixIdTheta  ||  !fHBlindPixNTheta  ||
+       !fHgON              ||  !fHgOFF)
+  { 
+       *fLog << err << "At least one of the histograms needed for the padding is not defined ... aborting." << endl;
+       return kFALSE;
+  }
+
+  fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
+  if (!fMcEvt)
+    {
+       *fLog << err << dbginf << "MMcEvt not found... aborting." << endl;
+       return kFALSE;
+     }
+  
+   fPed = (MPedPhotCam*)pList->FindObject("MPedPhotCam");
+   if (!fPed)
+     {
+       *fLog << err << "MPedPhotCam not found... aborting." << endl;
+       return kFALSE;
+     }
+
+   fCam = (MGeomCam*)pList->FindObject("MGeomCam");
+   if (!fCam)
+     {
+       *fLog << err << "MGeomCam not found (no geometry information available)... aborting." << endl;
+       return kFALSE;
+     }
+  
+   fEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
+   if (!fEvt)
+     {
+       *fLog << err << "MCerPhotEvt not found... aborting." << endl;
+       return kFALSE;
+     }
+
+   fSigmabar = (MSigmabar*)pList->FindCreateObj("MSigmabar");
+   if (!fSigmabar)
+     {
+       *fLog << err << "MSigmabar not found... aborting." << endl;
+       return kFALSE;
+     }
+
+   fBlinds = (MBlindPixels*)pList->FindCreateObj("MBlindPixels");
+   if (!fBlinds)
+     {
+       *fLog << err << "MBlindPixels not found... aborting." << endl;
+       return kFALSE;
+     }
+   
+   if (fType !="ON"  &&  fType !="OFF"  &&  fType !="MC")
+     {
+       *fLog << err << "Type of data to be padded not defined... aborting." << endl;
+       return kFALSE;
+     }
+
+
+   //--------------------------------------------------------------------
+   // histograms for checking the padding
+   //
+   // plot pedestal sigmas
+   fHSigmaPedestal = new TH2D("SigPed","Sigma: after vs. before padding", 
+                     100, 0.0, 5.0, 100, 0.0, 5.0);
+   fHSigmaPedestal->SetXTitle("Pedestal sigma before padding");
+   fHSigmaPedestal->SetYTitle("Pedestal sigma after padding");
+
+   // plot no.of photons (before vs. after padding) 
+   fHPhotons = new TH2D("Photons","Photons: after vs.before padding", 
+                        100, -10.0, 90.0, 100, -10, 90);
+   fHPhotons->SetXTitle("no.of photons before padding");
+   fHPhotons->SetYTitle("no.of photons after padding");
+
+   // plot of added NSB
+   fHNSB = new TH1D("NSB","Distribution of added NSB", 100, -10.0, 10.0);
+   fHNSB->SetXTitle("no.of added NSB photons");
+   fHNSB->SetYTitle("no.of pixels");
+
+
+   //--------------------------------------------------------------------
+
+   fIter = 20;
+
+   memset(fErrors, 0, sizeof(fErrors));
+
+   return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Do the Padding
+// idealy the events to be padded should have been generated without NSB
+// 
+Int_t MCT1PadONOFF::Process()
+{
+  // *fLog << "Entry MCT1PadONOFF::Process();" << endl;
+
+  //------------------------------------------------
+  // add pixels to MCerPhotEvt which are not yet in;
+  // set their number of photons equal to zero
+
+  UInt_t imaxnumpix = fCam->GetNumPixels();
+
+  for (UInt_t i=0; i<imaxnumpix; i++)
+  {
+    Bool_t alreadythere = kFALSE;
+    UInt_t npix = fEvt->GetNumPixels();
+    for (UInt_t j=0; j<npix; j++)
+    {
+      MCerPhotPix &pix = (*fEvt)[j];
+      UInt_t id = pix.GetPixId();
+      if (i==id)
+      {
+        alreadythere = kTRUE;
+        break;
+      }
+    }
+    if (alreadythere)
+      continue;
+
+    fEvt->AddPixel(i, 0.0, (*fPed)[i].GetRms());
+  }
+
+
+
+  //-----------------------------------------
+  Int_t rc=0;
+  Int_t rw=0;
+
+  const UInt_t npix = fEvt->GetNumPixels();
+
+  //fSigmabar->Calc(*fCam, *fPed, *fEvt);
+  // *fLog << "before padding : " << endl;
+  //fSigmabar->Print("");
+
+
+  //$$$$$$$$$$$$$$$$$$$$$$$$$$
+  // to simulate the situation that before the padding the NSB and 
+  // electronic noise are zero : set Sigma = 0 for all pixels
+  //for (UInt_t i=0; i<npix; i++) 
+  //{   
+  //  MCerPhotPix &pix = fEvt->operator[](i);      
+  //  Int_t j = pix.GetPixId();
+
+  //  MPedPhotPix &ppix = fPed->operator[](j);
+  //  ppix.SetRms(0.0);
+  //}
+  //$$$$$$$$$$$$$$$$$$$$$$$$$$
+
+  //-------------------------------------------
+  // Calculate average sigma of the event
+  //
+  Double_t sigbarold = fSigmabar->Calc(*fCam, *fPed, *fEvt);
+  Double_t sigbarold2 = sigbarold*sigbarold;
+  //fSigmabar->Print("");
+
+  // for MC data : expect sigmabar to be zero before the padding
+  if (fType == "MC")
+  {
+    if (sigbarold > 0)
+    {
+      // *fLog << "MCT1PadONOFF::Process(); sigmabar of event to be padded is > 0 : "
+      //      << sigbarold << ". Stop event loop " << endl;
+      // input data should have sigmabar = 0; stop event loop
+  
+      rc = 1;
+      fErrors[rc]++;
+      return kCONTINUE; 
+    }
+  }
+
+  const Double_t theta = kRad2Deg*fMcEvt->GetTelescopeTheta();
+  // *fLog << "theta = " << theta << endl;
+
+  Int_t binTheta = fHBlindPixNTheta->GetXaxis()->FindBin(theta);
+  if ( binTheta < 1  ||  binTheta > fHBlindPixNTheta->GetNbinsX() )
+  {
+    // *fLog << "MCT1PadONOFF::Process(); binNumber out of range : theta, binTheta = "
+    //      << theta << ",  " << binTheta << ";  Skip event " << endl;
+    // event cannot be padded; skip event
+
+    rc = 2;
+    fErrors[rc]++;
+    return kCONTINUE;
+  }
+
+  //-------------------------------------------
+  // get number of events in this theta bin
+  // and number of events in this sigbarold bin
+
+  Double_t nTheta;
+  Double_t nSigma;
+  if (fType == "ON")
+  {
+    TH1D *hn;
+
+    hn = fHSigmaThetaON->ProjectionY("", binTheta, binTheta, "");
+    nTheta = hn->Integral();
+    Int_t binSigma = hn->FindBin(sigbarold);
+    nSigma = hn->GetBinContent(binSigma);
+
+    // *fLog << "Theta, sigbarold, binTheta, binSigma, nTheta, nSigma = "
+    //      << theta << ",  " << sigbarold << ",  " << binTheta << ",  "
+    //      << binSigma << ",  " << nTheta << ",  " << nSigma   << endl;      
+
+    delete hn;
+  }
+
+  else if (fType == "OFF")
+  {
+    TH1D *hn;
+
+    hn = fHSigmaThetaOFF->ProjectionY("", binTheta, binTheta, "");
+    nTheta = hn->Integral();
+    Int_t binSigma = hn->FindBin(sigbarold);
+    nSigma = hn->GetBinContent(binSigma);
+
+    // *fLog << "Theta, sigbarold, binTheta, binSigma, nTheta, nSigma = "
+    //      << theta << ",  " << sigbarold << ",  " << binTheta << ",  "
+    //      << binSigma << ",  " << nTheta << ",  " << nSigma   << endl;      
+
+    delete hn;
+  }
+
+  else
+  {
+    nTheta = 0.0;
+    nSigma = 0.0;
+  }
+
+  //-------------------------------------------
+  // for the current theta, 
+  // generate blind pixels according to the histograms 
+  //          fHBlindPixNTheta and fHBlindPixIDTheta
+  // do this only for MC data
+
+
+  if (fType == "MC")
+  {
+
+  // numBlind is the number of blind pixels in this event
+  TH1D *nblind;
+  UInt_t numBlind;
+
+  nblind = fHBlindPixNTheta->ProjectionY("", binTheta, binTheta, "");
+  if ( nblind->Integral() == 0.0 )
+  {
+    // *fLog << "MCT1PadONOFF::Process(); projection for Theta bin " 
+    //      << binTheta << " has no entries; Skip event " << endl;
+    // event cannot be padded; skip event
+    delete nblind;
+
+    rc = 7;
+    fErrors[rc]++;
+    return kCONTINUE;
+  }
+  else
+  {
+    numBlind = (Int_t) (nblind->GetRandom()+0.5);
+  }
+  delete nblind;
+
+  //warn Code commented out due no compilation errors on Alpha OSF (tgb)
+
+  // throw the Id of numBlind different pixels in this event
+  TH1D *hblind;
+  UInt_t idBlind;
+  UInt_t listId[npix];
+  UInt_t nlist = 0;
+  Bool_t equal;
+
+  hblind = fHBlindPixIdTheta->ProjectionY("", binTheta, binTheta, "");
+  if ( hblind->Integral() > 0.0 )
+    for (UInt_t i=0; i<numBlind; i++)
+    {
+      while(1)
+      {
+        idBlind = (Int_t) (hblind->GetRandom()+0.5);
+        equal = kFALSE;
+        for (UInt_t j=0; j<nlist; j++)
+          if (idBlind == listId[j])
+	  { 
+            equal = kTRUE;
+            break;
+	  }
+        if (!equal) break;
+      }
+      listId[nlist] = idBlind;
+      nlist++;
+
+      fBlinds->SetPixelBlind(idBlind);
+      // *fLog << "idBlind = " << idBlind << endl;
+    }
+  fBlinds->SetReadyToSave();
+
+  delete hblind;
+
+  }
+
+  //******************************************************************
+  // has the event to be padded ?
+  // if yes : to which sigmabar should it be padded ?
+  //
+
+  Int_t binSig = fHgON->GetYaxis()->FindBin(sigbarold);
+  // *fLog << "binSig, sigbarold = " << binSig << ",  " << sigbarold << endl;
+
+  Double_t prob;
+  TH1D *hpad = NULL;
+  if (fType == "ON")
+  {
+    hpad = fHgON->ProjectionZ("zON", binTheta, binTheta, binSig, binSig, "");
+
+    //Int_t nb = hpad->GetNbinsX();
+    //for (Int_t i=1; i<=nb; i++)
+    //{
+    //  if (hpad->GetBinContent(i) != 0.0)
+    //    *fLog << "i, fHgON = " << i << ",  " << hpad->GetBinContent(i) << endl;
+    //}
+
+    if (nSigma != 0.0)
+      prob = hpad->Integral() * nTheta/nSigma;
+    else
+      prob = 0.0;
+
+    // *fLog << "nTheta, nSigma, prob = " << nTheta << ",  " << nSigma 
+    //      << ",  " << prob << endl;
+  }
+  else if (fType == "OFF")
+  {
+    hpad = fHgOFF->ProjectionZ("zOFF", binTheta, binTheta, binSig, binSig, "");
+    if (nSigma != 0.0)
+      prob = hpad->Integral() * nTheta/nSigma;
+    else
+      prob = 0.0;
+  }
+  else
+    prob = 1.0;
+
+  if ( fType != "MC"  &&
+       (prob <= 0.0  ||  gRandom->Uniform() > prob) )
+  {
+    delete hpad;
+    // event should not be padded
+    // *fLog << "event is not padded" << endl;
+
+    rc = 8;
+    fErrors[rc]++;
+    return kTRUE;
+  }
+  // event should be padded
+  // *fLog << "event is padded" << endl;  
+
+
+  //-------------------------------------------
+  // for the current theta, generate a sigmabar 
+  //
+  // for ON/OFF data according to the matrix fHgON/OFF
+  // for MC data     according to the histogram fHSigmaTheta
+  //
+  Double_t sigmabar=0;
+  if (fType == "ON"  ||  fType == "OFF")
+  {
+    //Int_t nbinsx = hpad->GetNbinsX();
+    //for (Int_t i=1; i<=nbinsx; i++)
+    //{
+    //  if (hpad->GetBinContent(i) != 0.0)
+    //    *fLog << "i, fHg = " << i << ",  " << hpad->GetBinContent(i) << endl;
+    //}
+
+    sigmabar = hpad->GetRandom();
+
+    // *fLog << "sigmabar = " << sigmabar << endl;
+
+    delete hpad;
+  }
+
+  else if (fType == "MC")
+  {
+    Int_t bincheck = fHSigmaTheta->GetXaxis()->FindBin(theta);
+
+    if (binTheta != bincheck)
+    {
+      cout << "The binnings of the 2 histograms are not identical; aborting"
+           << endl;
+      return kERROR;
+    }
+
+    TH1D *hsigma;
+
+    hsigma = fHSigmaTheta->ProjectionY("", binTheta, binTheta, "");
+    if ( hsigma->Integral() == 0.0 )
+    {
+      *fLog << "MCT1PadONOFF::Process(); projection for Theta bin " 
+            << binTheta << " has no entries; Skip event " << endl;
+      // event cannot be padded; skip event
+      delete hsigma;
+
+      rc = 3;
+      fErrors[rc]++;
+      return kCONTINUE;
+    }
+    else
+    {
+      sigmabar = hsigma->GetRandom();
+       // *fLog << "Theta, bin number = " << theta << ",  " << binTheta  
+       //      << ",  sigmabar = " << sigmabar << endl
+    }
+    delete hsigma;
+  }
+
+  const Double_t sigmabar2 = sigmabar*sigmabar;
+
+  //-------------------------------------------
+
+  // *fLog << "MCT1PadONOFF::Process(); sigbarold, sigmabar = " 
+  //      << sigbarold << ",  "<< sigmabar << endl;
+
+  // Skip event if target sigmabar is <= sigbarold
+  if (sigmabar <= sigbarold)
+  {
+    *fLog << "MCT1PadONOFF::Process(); target sigmabar is less than sigbarold : "
+          << sigmabar << ",  " << sigbarold << ",   Skip event" << endl;
+
+    rc = 4;
+    fErrors[rc]++;
+    return kCONTINUE;     
+  }
+
+
+  //-------------------------------------------
+  //
+  // Calculate average number of NSB photons to be added (lambdabar)
+  // from the value of sigmabar, 
+  //  - making assumptions about the average electronic noise (elNoise2) and
+  //  - using a fixed value (F2excess)  for the excess noise factor
+  
+  Double_t elNoise2;         // [photons]  
+  Double_t F2excess  = 1.3;
+  Double_t lambdabar;        // [photons]
+
+
+
+  Int_t bincheck = fHDiffPixTheta->GetXaxis()->FindBin(theta);
+  if (binTheta != bincheck)
+  {
+    cout << "The binnings of the 2 histograms are not identical; aborting"
+         << endl;
+    return kERROR;
+  }
+
+  // Get RMS of (Sigma^2-sigmabar^2) in this Theta bin.
+  // The average electronic noise (to be added) has to be well above this RMS,
+  // otherwise the electronic noise of an individual pixel (elNoise2Pix)
+  // may become negative
+
+  TH1D *hnoise;
+  if (fType == "MC")
+    hnoise = fHDiffPixTheta->ProjectionZ("", binTheta, binTheta, 0, 9999, "");
+  else if (fType == "ON")
+    hnoise = fHDiffPixThetaOFF->ProjectionZ("", binTheta, binTheta, 0, 9999, "");
+  else if (fType == "OFF")
+    hnoise = fHDiffPixThetaON->ProjectionZ("", binTheta, binTheta, 0, 9999, "");
+  else
+  {
+    *fLog << "MCT1PadONOFF::Process; illegal data type... aborting" << endl;
+    return kERROR;
+  }
+
+  Double_t RMS = hnoise->GetRMS(1);  
+  delete hnoise;
+
+  elNoise2 = TMath::Min(RMS,  sigmabar2 - sigbarold2);
+  // *fLog << "elNoise2 = " << elNoise2 << endl; 
+
+  lambdabar = (sigmabar2 - sigbarold2 - elNoise2) / F2excess;     // [photons]
+
+  // This value of lambdabar is the same for all pixels;
+  // note that lambdabar is normalized to the area of pixel 0
+
+  //----------   start loop over pixels   ---------------------------------
+  // do the padding for each pixel
+  //
+  // pad only pixels   - which are used (before image cleaning)
+  //
+  Double_t sig         = 0;
+  Double_t sigma2      = 0;
+  Double_t diff        = 0;
+  Double_t addSig2     = 0;
+  Double_t elNoise2Pix = 0;
+
+
+  for (UInt_t i=0; i<npix; i++) 
+  {   
+    MCerPhotPix &pix = (*fEvt)[i];
+    if ( !pix.IsPixelUsed() )
+      continue;
+
+    //if ( pix.GetNumPhotons() == 0.0)
+    //{
+    //  *fLog << "MCT1PadONOFF::Process(); no.of photons is 0 for used pixel" 
+    //        << endl;
+    //  continue;
+    //}
+
+    Int_t j = pix.GetPixId();
+
+    // GetPixRatio returns (area of pixel 0 / area of current pixel)
+    Double_t ratioArea = 1.0 / fCam->GetPixRatio(j);
+
+    MPedPhotPix &ppix = (*fPed)[j];
+    Double_t oldsigma = ppix.GetRms();
+    Double_t oldsigma2 = oldsigma*oldsigma;
+
+    //---------------------------------
+    // throw the Sigma for this pixel 
+    //
+    Int_t binPixel = fHDiffPixTheta->GetYaxis()->FindBin( (Double_t)j );
+
+    Int_t count;
+    Bool_t ok;
+
+    TH1D *hdiff;
+    TH1D *hsig;
+
+    switch (fPadFlag)
+    {
+    case 1 :
+      // throw the Sigma for this pixel from the distribution fHDiffPixTheta
+
+      if (fType == "MC")
+        hdiff = fHDiffPixTheta->ProjectionZ("", binTheta, binTheta,
+                                                binPixel, binPixel, "");
+      else if (fType == "ON") 
+        hdiff = fHDiffPixThetaOFF->ProjectionZ("", binTheta, binTheta,
+                                                   binPixel, binPixel, "");
+      else 
+        hdiff = fHDiffPixThetaON->ProjectionZ("", binTheta, binTheta,
+                                                  binPixel, binPixel, "");
+
+     if ( hdiff->Integral() == 0 )
+      {
+        *fLog << "MCT1PadONOFF::Process(); projection for Theta bin " 
+              << binTheta << "  and pixel bin " << binPixel  
+              << " has no entries;  aborting " << endl;
+        delete hdiff;
+
+        rc = 5;
+        fErrors[rc]++;
+        return kCONTINUE;     
+      }
+
+      count = 0;
+      ok = kFALSE;
+      for (Int_t m=0; m<fIter; m++)
+      {
+        count += 1;
+        diff = hdiff->GetRandom();
+        // the following condition ensures that elNoise2Pix > 0.0 
+
+        if ( (diff + sigmabar2 - oldsigma2/ratioArea
+                               - lambdabar*F2excess) > 0.0 )
+	{
+          ok = kTRUE;
+          break;
+	}
+      }
+      if (!ok)
+      {
+        // *fLog << "theta, j, count, sigmabar, diff = " << theta << ",  " 
+        //      << j << ",  " << count << ",  " << sigmabar << ",  " 
+        //      << diff << endl;
+        diff = lambdabar*F2excess + oldsigma2/ratioArea - sigmabar2;
+
+        rw = 1;
+        fWarnings[rw]++;
+      }
+      else
+      {
+        rw = 0;
+        fWarnings[rw]++;
+      }
+
+      delete hdiff;
+      sigma2 = diff + sigmabar2;
+      break;
+
+    case 2 :
+      // throw the Sigma for this pixel from the distribution fHSigmaPixTheta
+
+      if (fType == "MC")
+        hsig = fHSigmaPixTheta->ProjectionZ("", binTheta, binTheta,
+                                                binPixel, binPixel, "");
+      else if (fType == "ON")
+        hsig = fHSigmaPixThetaOFF->ProjectionZ("", binTheta, binTheta,
+                                                   binPixel, binPixel, "");
+      else 
+        hsig = fHSigmaPixThetaON->ProjectionZ("", binTheta, binTheta,
+                                                  binPixel, binPixel, "");
+
+      if ( hsig->Integral() == 0 )
+      {
+        *fLog << "MCT1PadONOFF::Process(); projection for Theta bin " 
+              << binTheta << "  and pixel bin " << binPixel  
+              << " has no entries;  aborting " << endl;
+        delete hsig;
+
+        rc = 6;
+        fErrors[rc]++;
+        return kCONTINUE;     
+      }
+
+      count = 0;
+      ok = kFALSE;
+      for (Int_t m=0; m<fIter; m++)
+      {
+        count += 1;
+
+        sig = hsig->GetRandom();
+        sigma2 = sig*sig/ratioArea;
+        // the following condition ensures that elNoise2Pix > 0.0 
+
+        if ( (sigma2-oldsigma2/ratioArea-lambdabar*F2excess) > 0.0 )
+	{
+          ok = kTRUE;
+          break;
+	}
+      }
+      if (!ok)
+      {
+        // *fLog << "theta, j, count, sigmabar, sig = " << theta << ",  " 
+        //      << j << ",  " << count << ",  " << sigmabar << ",  " 
+        //      << sig << endl;
+        sigma2 = lambdabar*F2excess + oldsigma2/ratioArea; 
+
+        rw = 1;
+        fWarnings[rw]++;
+      }
+      else
+      {
+        rw = 0;
+        fWarnings[rw]++;
+      }
+
+      delete hsig;
+      break;
+    }
+
+    //---------------------------------
+    // get the additional sigma^2 for this pixel (due to the padding)
+
+    addSig2 = sigma2*ratioArea - oldsigma2;
+
+
+    //---------------------------------
+    // get the additional electronic noise for this pixel
+
+    elNoise2Pix = addSig2 - lambdabar*F2excess*ratioArea;
+
+
+    //---------------------------------
+    // throw actual number of additional NSB photons (NSB)
+    //       and its RMS (sigmaNSB) 
+
+    Double_t NSB0 = gRandom->Poisson(lambdabar*ratioArea);
+    Double_t arg  = NSB0*(F2excess-1.0) + elNoise2Pix;
+    Double_t sigmaNSB0;
+
+    if (arg >= 0.0)
+    {
+      sigmaNSB0 = sqrt( arg );
+    }
+    else
+    {
+      sigmaNSB0 = 0.0000001;      
+      if (arg < -1.e-10)
+      {
+        *fLog << "MCT1PadONOFF::Process(); argument of sqrt < 0 : "
+              << arg << endl;
+      }
+    }
+
+
+    //---------------------------------
+    // smear NSB0 according to sigmaNSB0
+    // and subtract lambdabar because of AC coupling
+
+    Double_t NSB = gRandom->Gaus(NSB0, sigmaNSB0) - lambdabar*ratioArea;
+
+    //---------------------------------
+ 
+    // add additional NSB to the number of photons
+    Double_t oldphotons = pix.GetNumPhotons();
+    Double_t newphotons = oldphotons + NSB;
+    pix.SetNumPhotons(	newphotons );
+
+
+    fHNSB->Fill( NSB/sqrt(ratioArea) );
+    fHPhotons->Fill( oldphotons/sqrt(ratioArea), newphotons/sqrt(ratioArea) );
+
+
+    // error: add sigma of padded noise quadratically
+    Double_t olderror = pix.GetErrorPhot();
+    Double_t newerror = sqrt( olderror*olderror + addSig2 );
+    pix.SetErrorPhot( newerror );
+
+
+    Double_t newsigma = sqrt( oldsigma2 + addSig2 ); 
+    ppix.SetRms( newsigma );
+
+    fHSigmaPedestal->Fill( oldsigma, newsigma );
+  } 
+  //----------   end of loop over pixels   ---------------------------------
+
+  // Calculate sigmabar again and crosscheck
+
+  //fSigmabar->Calc(*fCam, *fPed, *fEvt);
+  // *fLog << "after padding : " << endl;
+  //fSigmabar->Print("");
+
+  rc = 0;
+  fErrors[rc]++;
+  return kTRUE;
+  //******************************************************************
+}
+
+// --------------------------------------------------------------------------
+//
+//
+Int_t MCT1PadONOFF::PostProcess()
+{
+    if (GetNumExecutions() != 0)
+    {
+
+    *fLog << inf << endl;
+    *fLog << GetDescriptor() << " execution statistics:" << endl;
+    *fLog << dec << setfill(' ');
+
+    int temp;
+    if (fWarnings[0] != 0.0)    
+      temp = (int)(fWarnings[1]*100/fWarnings[0]);
+    else
+      temp = 100;
+
+    *fLog << " " << setw(7) << fWarnings[1] << " (" << setw(3) 
+          << temp 
+          << "%) Warning : iteration to find acceptable sigma failed" 
+          << ", fIter = " << fIter << endl;
+
+    *fLog << " " << setw(7) << fErrors[1] << " (" << setw(3) 
+          << (int)(fErrors[1]*100/GetNumExecutions()) 
+          << "%) Evts skipped due to: Sigmabar_old > 0" << endl;
+
+    *fLog << " " << setw(7) << fErrors[2] << " (" << setw(3) 
+          << (int)(fErrors[2]*100/GetNumExecutions()) 
+          << "%) Evts skipped due to: Zenith angle out of range" << endl;
+
+    *fLog << " " << setw(7) << fErrors[3] << " (" << setw(3) 
+          << (int)(fErrors[3]*100/GetNumExecutions()) 
+          << "%) Evts skipped due to: No data for generating Sigmabar" << endl;
+
+    *fLog << " " << setw(7) << fErrors[4] << " (" << setw(3) 
+          << (int)(fErrors[4]*100/GetNumExecutions()) 
+          << "%) Evts skipped due to: Target sigma <= Sigmabar_old" << endl;
+
+    *fLog << " " << setw(7) << fErrors[5] << " (" << setw(3) 
+          << (int)(fErrors[5]*100/GetNumExecutions()) 
+          << "%) Evts skipped due to: No data for generating Sigma^2-Sigmabar^2" << endl;
+
+    *fLog << " " << setw(7) << fErrors[6] << " (" << setw(3) 
+          << (int)(fErrors[6]*100/GetNumExecutions()) 
+          << "%) Evts skipped due to: No data for generating Sigma" << endl;
+
+    *fLog << " " << setw(7) << fErrors[7] << " (" << setw(3) 
+          << (int)(fErrors[7]*100/GetNumExecutions()) 
+          << "%) Evts skipped due to: No data for generating Blind pixels" << endl;
+
+    *fLog << " " << setw(7) << fErrors[8] << " (" << setw(3) 
+          << (int)(fErrors[8]*100/GetNumExecutions()) 
+          << "%) Evts didn't have to be padded" << endl;
+
+    *fLog << " " << fErrors[0] << " (" 
+          << (int)(fErrors[0]*100/GetNumExecutions()) 
+          << "%) Evts were successfully padded!" << endl;
+    *fLog << endl;
+
+    }
+
+    //---------------------------------------------------------------
+    TCanvas &c = *(MH::MakeDefCanvas("PadONOFF", "", 900, 1200)); 
+    c.Divide(3, 4);
+    gROOT->SetSelectedPad(NULL);
+
+    c.cd(1);
+    fHNSB->SetDirectory(NULL);
+    fHNSB->DrawCopy();
+    fHNSB->SetBit(kCanDelete);    
+
+    c.cd(2);
+    fHSigmaPedestal->SetDirectory(NULL);
+    fHSigmaPedestal->DrawCopy();
+    fHSigmaPedestal->SetBit(kCanDelete);    
+
+    c.cd(3);
+    fHPhotons->SetDirectory(NULL);
+    fHPhotons->DrawCopy();
+    fHPhotons->SetBit(kCanDelete);    
+
+    //--------------------------------------------------------------------
+
+
+    c.cd(4);
+    fHSigmaTheta->SetDirectory(NULL);
+    fHSigmaTheta->SetTitle("(Target) 2D : Sigmabar, \\Theta");
+    fHSigmaTheta->DrawCopy();     
+    fHSigmaTheta->SetBit(kCanDelete);     
+
+
+    //--------------------------------------------------------------------
+
+
+    c.cd(7);
+    fHBlindPixNTheta->SetDirectory(NULL);
+    fHBlindPixNTheta->SetTitle("(Target) 2D : no.of blind pixels, \\Theta");
+    fHBlindPixNTheta->DrawCopy();     
+    fHBlindPixNTheta->SetBit(kCanDelete);     
+
+    //--------------------------------------------------------------------
+
+
+    c.cd(10);
+    fHBlindPixIdTheta->SetDirectory(NULL);
+    fHBlindPixIdTheta->SetTitle("(Target) 2D : blind pixel Id, \\Theta");
+    fHBlindPixIdTheta->DrawCopy();     
+    fHBlindPixIdTheta->SetBit(kCanDelete);     
+
+
+    //--------------------------------------------------------------------
+    // draw the 3D histogram (target): Theta, pixel, Sigma^2-Sigmabar^2
+
+    c.cd(5);
+    TH2D *l1;
+    l1 = (TH2D*) ((TH3*)fHDiffPixTheta)->Project3D("zx");
+    l1->SetDirectory(NULL);
+    l1->SetTitle("(Target) Sigma^2-Sigmabar^2 vs. \\Theta (all pixels)");
+    l1->SetXTitle("\\Theta [\\circ]");
+    l1->SetYTitle("Sigma^2-Sigmabar^2");
+
+    l1->DrawCopy("box");
+    l1->SetBit(kCanDelete);;
+
+    c.cd(8);
+    TH2D *l2;
+    l2 = (TH2D*) ((TH3*)fHDiffPixTheta)->Project3D("zy");
+    l2->SetDirectory(NULL);
+    l2->SetTitle("(Target) Sigma^2-Sigmabar^2 vs. pixel number (all \\Theta)");
+    l2->SetXTitle("pixel");
+    l2->SetYTitle("Sigma^2-Sigmabar^2");
+
+    l2->DrawCopy("box");
+    l2->SetBit(kCanDelete);;
+
+    //--------------------------------------------------------------------
+    // draw the 3D histogram (target): Theta, pixel, Sigma
+
+    c.cd(6);
+    TH2D *k1;
+    k1 = (TH2D*) ((TH3*)fHSigmaPixTheta)->Project3D("zx");
+    k1->SetDirectory(NULL);
+    k1->SetTitle("(Target) Sigma vs. \\Theta (all pixels)");
+    k1->SetXTitle("\\Theta [\\circ]");
+    k1->SetYTitle("Sigma");
+
+    k1->DrawCopy("box");
+    k1->SetBit(kCanDelete);
+
+    c.cd(9);
+    TH2D *k2;
+    k2 = (TH2D*) ((TH3*)fHSigmaPixTheta)->Project3D("zy");
+    k2->SetDirectory(NULL);
+    k2->SetTitle("(Target) Sigma vs. pixel number (all \\Theta)");
+    k2->SetXTitle("pixel");
+    k2->SetYTitle("Sigma");
+
+    k2->DrawCopy("box");
+    k2->SetBit(kCanDelete);;
+
+
+    //--------------------------------------------------------------------
+
+    c.cd(11);
+    TH2D *m1;
+    m1 = (TH2D*) ((TH3*)fHgON)->Project3D("zy");
+    m1->SetDirectory(NULL);
+    m1->SetTitle("(Target) Sigmabar-new vs. Sigmabar-old (ON, all  \\Theta)");
+    m1->SetXTitle("Sigmabar-old");
+    m1->SetYTitle("Sigmabar-new");
+
+    m1->DrawCopy("box");
+    m1->SetBit(kCanDelete);;
+
+    c.cd(12);
+    TH2D *m2;
+    m2 = (TH2D*) ((TH3*)fHgOFF)->Project3D("zy");
+    m2->SetDirectory(NULL);
+    m2->SetTitle("(Target) Sigmabar-new vs. Sigmabar-old (OFF, all  \\Theta)");
+    m2->SetXTitle("Sigmabar-old");
+    m2->SetYTitle("Sigmabar-new");
+
+    m2->DrawCopy("box");
+    m2->SetBit(kCanDelete);;
+
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1PadONOFF.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1PadONOFF.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1PadONOFF.h	(revision 9661)
@@ -0,0 +1,104 @@
+#ifndef MARS_MCT1PadONOFF
+#define MARS_MCT1PadONOFF
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+class TH1D;
+class TH2D;
+class TH3D;
+
+class MGeomCam;
+class MCerPhotEvt;
+class MPedPhotCam;
+class MMcEvt;
+class MSigmabar;
+class MParList;
+class MBlindPixels;
+class MRead;
+class MFilterList;
+
+
+class MCT1PadONOFF : public MTask
+{
+private:
+    MGeomCam       *fCam;
+    MCerPhotEvt    *fEvt; 
+    MSigmabar      *fSigmabar;
+    MMcEvt         *fMcEvt;
+    MPedPhotCam   *fPed;
+    MBlindPixels   *fBlinds;
+
+    TString        fType;           // type of data to be padded
+    TFile          *fInfile;        // input file containing padding histograms
+
+    Int_t          fPadFlag;
+    Int_t          fIter;
+
+    Int_t          fErrors[9];
+    Int_t          fWarnings[2];
+
+
+    // plots used for the padding
+    TH2D           *fHBlindPixIdTheta; // 2D-histogram (blind pixel Id vs. Theta)
+    TH2D           *fHBlindPixNTheta; // 2D-histogram (no.of blind pixels vs. Theta)
+
+    TH2D           *fHSigmaTheta;       // 2D-histogram (sigmabar vs. Theta)
+    TH2D           *fHSigmaThetaON;     // 2D-histogram (sigmabar vs. Theta)
+    TH2D           *fHSigmaThetaOFF;    // 2D-histogram (sigmabar vs. Theta)
+
+    TH3D           *fHSigmaPixTheta;    // 3D-histogram (Theta, pixel, sigma)
+    TH3D           *fHSigmaPixThetaON;  // 3D-histogram (Theta, pixel, sigma)
+    TH3D           *fHSigmaPixThetaOFF; // 3D-histogram (Theta, pixel, sigma)
+
+    TH3D           *fHDiffPixTheta;     // 3D-histogram (Theta, pixel, sigma^2-sigmabar^2)
+    TH3D           *fHDiffPixThetaON;   // 3D-histogram (Theta, pixel, sigma^2-sigmabar^2)
+    TH3D           *fHDiffPixThetaOFF;  // 3D-histogram (Theta, pixel, sigma^2-sigmabar^2)
+
+    TH3D           *fHgON;           // matrix (Theta, sigbarold, sigbarnew) for ON data
+    TH3D           *fHgOFF;          // matrix (Theta, sigbarold, sigbarnew) for OFF data
+
+    // plots for checking the padding
+    TH2D           *fHSigmaPedestal; // 2D-histogram : pedestal sigma after
+                                     //                versus before padding
+    TH2D           *fHPhotons;       // 2D-histogram : no.of photons after
+                                     //                versus before padding
+    TH1D           *fHNSB;           // 1D-histogram : additional NSB
+
+
+public:
+    MCT1PadONOFF(const char *name=NULL, const char *title=NULL);
+    ~MCT1PadONOFF();
+
+    Bool_t MergeHistograms(TH2D *sigthon,     TH2D *sigthoff,
+                           TH3D *sigpixthon,  TH3D *sigpixthoff,
+                           TH3D *diffpixthon, TH3D *diffpixthoff,
+                           TH2D *blindidthon, TH2D *blindidthoff,
+                           TH2D *blindnthon,  TH2D *blindnthoff);
+
+    Bool_t ReadTargetDist(const char *filein);
+    Bool_t WriteTargetDist(const char *fileout);
+
+    void SetDataType(const char *type);   // type of data to be padded
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+    
+    void SetPadFlag(Int_t padflag);
+
+    ClassDef(MCT1PadONOFF, 0)    // task for the ON-OFF padding 
+}; 
+
+#endif
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1PadSchweizer.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1PadSchweizer.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1PadSchweizer.cc	(revision 9661)
@@ -0,0 +1,897 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Robert Wagner, 10/2002 <mailto:magicsoft@rwagner.de>
+!   Author(s): Wolfgang Wittek, 02/2003 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MCT1PadSchweizer
+//
+//  This task applies padding such that for a given pixel and for a given
+//  Theta bin the resulting distribution of the pedestal sigma is identical
+//  to the distributions given by fHSigmaPixTheta and fHDiffPixTheta.
+//
+//  The number of photons, its error and the pedestal sigmas are altered.
+//  On average, the number of photons added is zero.
+//
+//  The formulas used can be found in Thomas Schweizer's Thesis,
+//                                    Section 2.2.1
+//
+//  There are 2 options for the padding :
+//
+//  1) fPadFlag = 1 :
+//     Generate first a Sigmabar using the 2D-histogram Sigmabar vs. Theta
+//     (fHSigmaTheta). Then generate a pedestal sigma for each pixel using
+//     the 3D-histogram Theta, pixel no., Sigma^2-Sigmabar^2
+//     (fHDiffPixTheta).
+//
+//     This is the preferred option as it takes into account the
+//     correlations between the Sigma of a pixel and Sigmabar.
+//
+//  2) fPadFlag = 2 :
+//     Generate a pedestal sigma for each pixel using the 3D-histogram
+//     Theta, pixel no., Sigma (fHSigmaPixTheta).
+//
+//
+//  The padding has to be done before the image cleaning because the
+//  image cleaning depends on the pedestal sigmas.
+//
+//  For random numbers gRandom is used.
+//
+//  This implementation has been tested for CT1 data. For MAGIC some
+//  modifications are necessary.
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCT1PadSchweizer.h"
+
+#include <stdio.h>
+
+#include <TH1.h>
+#include <TH2.h>
+#include <TH3.h>
+#include <TRandom.h>
+#include <TCanvas.h>
+
+#include "MBinning.h"
+#include "MSigmabar.h"
+#include "MMcEvt.hxx"
+#include "MLog.h"
+#include "MLogManip.h"
+#include "MParList.h"
+#include "MGeomCam.h"
+
+#include "MCerPhotPix.h"
+#include "MCerPhotEvt.h"
+
+#include "MPedPhotCam.h"
+#include "MPedPhotPix.h"
+
+#include "MBlindPixels.h"
+
+ClassImp(MCT1PadSchweizer);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+MCT1PadSchweizer::MCT1PadSchweizer(const char *name, const char *title) 
+{
+  fName  = name  ? name  : "MCT1PadSchweizer";
+  fTitle = title ? title : "Task for the padding (Schweizer)";
+
+  fHSigmaTheta    = NULL;
+  fHSigmaPixTheta = NULL;
+  fHDiffPixTheta  = NULL;
+  fHBlindPixIdTheta = NULL;
+  fHBlindPixNTheta  = NULL;
+
+  fHSigmaPedestal = NULL;
+  fHPhotons       = NULL;
+  fHNSB           = NULL;
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor. 
+//
+MCT1PadSchweizer::~MCT1PadSchweizer()
+{
+  if (fHSigmaPedestal != NULL) delete fHSigmaPedestal;
+  if (fHPhotons != NULL)       delete fHPhotons;
+  if (fHNSB != NULL)           delete fHNSB;
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the references to the histograms to be used in the padding
+// 
+// fHSigmaTheta    2D-histogram  (Theta, sigmabar)
+// fHSigmaPixTheta 3D-hiostogram (Theta, pixel, sigma)
+// fHDiffPixTheta  3D-histogram  (Theta, pixel, sigma^2-sigmabar^2)
+// fHBlindPixIdTheta 2D-histogram  (Theta, blind pixel Id)
+// fHBlindPixNTheta  2D-histogram  (Theta, no.of blind pixels )
+//
+//
+void MCT1PadSchweizer::SetHistograms(TH2D *hist2, TH3D *hist3, TH3D *hist3Diff,
+                                  TH2D *hist2Pix, TH2D *hist2PixN)
+{
+    fHSigmaTheta    = hist2;
+    fHSigmaPixTheta = hist3;
+    fHDiffPixTheta  = hist3Diff;
+    fHBlindPixIdTheta = hist2Pix;
+    fHBlindPixNTheta  = hist2PixN;
+
+    fHSigmaTheta->SetDirectory(NULL);
+    fHSigmaPixTheta->SetDirectory(NULL);
+    fHDiffPixTheta->SetDirectory(NULL);
+    fHBlindPixIdTheta->SetDirectory(NULL);
+    fHBlindPixNTheta->SetDirectory(NULL);
+
+    Print();
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the option for the padding
+//
+//  There are 2 options for the padding :
+//
+//  1) fPadFlag = 1 :
+//     Generate first a Sigmabar using the 2D-histogram Sigmabar vs. Theta
+//     (fHSigmaTheta). Then generate a pedestal sigma for each pixel using
+//     the 3D-histogram Theta, pixel no., Sigma^2-Sigmabar^2
+//     (fHDiffPixTheta).
+//
+//     This is the preferred option as it takes into account the
+//     correlations between the Sigma of a pixel and Sigmabar.
+//
+//  2) fPadFlag = 2 :
+//     Generate a pedestal sigma for each pixel using the 3D-histogram
+//     Theta, pixel no., Sigma (fHSigmaPixTheta).
+//
+void MCT1PadSchweizer::SetPadFlag(Int_t padflag)
+{
+  fPadFlag = padflag;
+  *fLog << "MCT1PadSchweizer::SetPadFlag(); choose option " << fPadFlag << endl; 
+}
+
+// --------------------------------------------------------------------------
+//
+//  Set the pointers and prepare the histograms
+//
+Int_t MCT1PadSchweizer::PreProcess(MParList *pList)
+{
+  if ( !fHSigmaTheta  || !fHSigmaPixTheta  || !fHDiffPixTheta  ||
+       !fHBlindPixIdTheta  ||  !fHBlindPixNTheta)
+  { 
+       *fLog << err << "At least one of the histograms needed for the padding is not defined ... aborting." << endl;
+       return kFALSE;
+  }
+
+  fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
+  if (!fMcEvt)
+    {
+       *fLog << err << dbginf << "MMcEvt not found... aborting." << endl;
+       return kFALSE;
+     }
+  
+   fPed = (MPedPhotCam*)pList->FindObject("MPedPhotCam");
+   if (!fPed)
+     {
+       *fLog << err << "MPedPhotCam not found... aborting." << endl;
+       return kFALSE;
+     }
+
+   fCam = (MGeomCam*)pList->FindObject("MGeomCam");
+   if (!fCam)
+     {
+       *fLog << err << "MGeomCam not found (no geometry information available)... aborting." << endl;
+       return kFALSE;
+     }
+  
+   fEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
+   if (!fEvt)
+     {
+       *fLog << err << "MCerPhotEvt not found... aborting." << endl;
+       return kFALSE;
+     }
+
+   fSigmabar = (MSigmabar*)pList->FindCreateObj("MSigmabar");
+   if (!fSigmabar)
+     {
+       *fLog << err << "MSigmabar not found... aborting." << endl;
+       return kFALSE;
+     }
+
+   fBlinds = (MBlindPixels*)pList->FindCreateObj("MBlindPixels");
+   if (!fBlinds)
+     {
+       *fLog << err << "MBlindPixels not found... aborting." << endl;
+       return kFALSE;
+     }
+   
+
+   //--------------------------------------------------------------------
+   // histograms for checking the padding
+   //
+   // plot pedestal sigmas
+   fHSigmaPedestal = new TH2D("SigPed","Sigma: after vs. before padding", 
+                     100, 0.0, 5.0, 100, 0.0, 5.0);
+   fHSigmaPedestal->SetXTitle("Pedestal sigma before padding");
+   fHSigmaPedestal->SetYTitle("Pedestal sigma after padding");
+
+   // plot no.of photons (before vs. after padding) 
+   fHPhotons = new TH2D("Photons","Photons: after vs.before padding", 
+                        100, -10.0, 90.0, 100, -10, 90);
+   fHPhotons->SetXTitle("no.of photons before padding");
+   fHPhotons->SetYTitle("no.of photons after padding");
+
+   // plot of added NSB
+   fHNSB = new TH1D("NSB","Distribution of added NSB", 100, -10.0, 10.0);
+   fHNSB->SetXTitle("no.of added NSB photons");
+   fHNSB->SetYTitle("no.of pixels");
+
+
+   //--------------------------------------------------------------------
+
+   memset(fErrors, 0, sizeof(fErrors));
+
+   return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Do the Padding
+// idealy the events to be padded should have been generated without NSB
+// 
+Int_t MCT1PadSchweizer::Process()
+{
+  //*fLog << "Entry MCT1PadSchweizer::Process();" << endl;
+
+  //------------------------------------------------
+  // add pixels to MCerPhotEvt which are not yet in;
+  // set their numnber of photons equal to zero
+
+  UInt_t imaxnumpix = fCam->GetNumPixels();
+
+  for (UInt_t i=0; i<imaxnumpix; i++)
+  {
+    Bool_t alreadythere = kFALSE;
+    UInt_t npix = fEvt->GetNumPixels();
+    for (UInt_t j=0; j<npix; j++)
+    {
+      MCerPhotPix &pix = (*fEvt)[j];
+      UInt_t id = pix.GetPixId();
+      if (i==id)
+      {
+        alreadythere = kTRUE;
+        break;
+      }
+    }
+    if (alreadythere)
+      continue;
+
+    fEvt->AddPixel(i, 0.0, (*fPed)[i].GetRms());
+  }
+
+
+
+  //-----------------------------------------
+  Int_t rc=0;
+
+  const UInt_t npix = fEvt->GetNumPixels();
+
+  //fSigmabar->Calc(*fCam, *fPed, *fEvt);
+  //*fLog << "before padding : " << endl;
+  //fSigmabar->Print("");
+
+
+  //$$$$$$$$$$$$$$$$$$$$$$$$$$
+  // to simulate the situation that before the padding the NSB and 
+  // electronic noise are zero : set Sigma = 0 for all pixels
+  //for (UInt_t i=0; i<npix; i++) 
+  //{   
+  //  MCerPhotPix &pix = fEvt->operator[](i);      
+  //  Int_t j = pix.GetPixId();
+
+  //  MPedPhotPix &ppix = fPed->operator[](j);
+  //  ppix.SetRms(0.0);
+  //}
+  //$$$$$$$$$$$$$$$$$$$$$$$$$$
+
+  //-------------------------------------------
+  // Calculate average sigma of the event
+  //
+  Double_t sigbarold = fSigmabar->Calc(*fCam, *fPed, *fEvt);
+  Double_t sigbarold2 = sigbarold*sigbarold;
+  //fSigmabar->Print("");
+
+  if (sigbarold > 0)
+  {
+    //*fLog << "MCT1PadSchweizer::Process(); sigmabar of event to be padded is > 0 : "
+    //      << sigbarold << ". Stop event loop " << endl;
+    // input data should have sigmabar = 0; stop event loop
+  
+    rc = 1;
+    fErrors[rc]++;
+    return kCONTINUE; 
+  }
+
+  const Double_t theta = kRad2Deg*fMcEvt->GetTelescopeTheta();
+  // *fLog << "theta = " << theta << endl;
+
+
+  //-------------------------------------------
+  // for the current theta, 
+  // generate blind pixels according to the histograms 
+  //          fHBlindPixNTheta and fHBlindPixIDTheta
+  //
+
+
+  Int_t binPix = fHBlindPixNTheta->GetXaxis()->FindBin(theta);
+
+  if ( binPix < 1  ||  binPix > fHBlindPixNTheta->GetNbinsX() )
+  {
+    //*fLog << "MCT1PadSchweizer::Process(); binNumber out of range : theta, binPix = "
+    //      << theta << ",  " << binPix << ";  Skip event " << endl;
+    // event cannot be padded; skip event
+
+    rc = 2;
+    fErrors[rc]++;
+    return kCONTINUE;
+  }
+
+  // numBlind is the number of blind pixels in this event
+  TH1D *nblind;
+  UInt_t numBlind;
+
+  nblind = fHBlindPixNTheta->ProjectionY("", binPix, binPix, "");
+  if ( nblind->GetEntries() == 0.0 )
+  {
+    *fLog << "MCT1PadSchweizer::Process(); projection for Theta bin " 
+          << binPix << " has no entries; Skip event " << endl;
+    // event cannot be padded; skip event
+    delete nblind;
+
+    rc = 7;
+    fErrors[rc]++;
+    return kCONTINUE;
+  }
+  else
+  {
+    numBlind = (Int_t) (nblind->GetRandom()+0.5);
+  }
+  delete nblind;
+
+
+  // throw the Id of numBlind different pixels in this event
+  TH1D *hblind;
+  UInt_t idBlind;
+  UInt_t listId[npix];
+  UInt_t nlist = 0;
+  Bool_t equal;
+
+  hblind = fHBlindPixIdTheta->ProjectionY("", binPix, binPix, "");
+  if ( hblind->GetEntries() > 0.0 )
+    for (UInt_t i=0; i<numBlind; i++)
+    {
+      while(1)
+      {
+        idBlind = (Int_t) (hblind->GetRandom()+0.5);
+        equal = kFALSE;
+        for (UInt_t j=0; j<nlist; j++)
+          if (idBlind == listId[j])
+	  { 
+            equal = kTRUE;
+            break;
+	  }
+        if (!equal) break;
+      }
+      listId[nlist] = idBlind;
+      nlist++;
+
+      fBlinds->SetPixelBlind(idBlind);
+      //*fLog << "idBlind = " << idBlind << endl;
+    }
+  fBlinds->SetReadyToSave();
+
+  delete hblind;
+
+
+  //-------------------------------------------
+  // for the current theta, 
+  // generate a sigmabar according to the histogram fHSigmaTheta
+  //
+  Double_t sigmabar=0;
+  Int_t binNumber = fHSigmaTheta->GetXaxis()->FindBin(theta);
+
+  if (binPix != binNumber)
+  {
+    cout << "The binnings of the 2 histograms are not identical; aborting"
+         << endl;
+    return kERROR;
+  }
+
+  TH1D *hsigma;
+
+  hsigma = fHSigmaTheta->ProjectionY("", binNumber, binNumber, "");
+  if ( hsigma->GetEntries() == 0.0 )
+  {
+    *fLog << "MCT1PadSchweizer::Process(); projection for Theta bin " 
+          << binNumber << " has no entries; Skip event " << endl;
+    // event cannot be padded; skip event
+    delete hsigma;
+
+    rc = 3;
+    fErrors[rc]++;
+    return kCONTINUE;
+  }
+  else
+  {
+    sigmabar = hsigma->GetRandom();
+     //*fLog << "Theta, bin number = " << theta << ",  " << binNumber      //      << ",  sigmabar = " << sigmabar << endl
+  }
+  delete hsigma;
+
+  const Double_t sigmabar2 = sigmabar*sigmabar;
+
+  //-------------------------------------------
+
+  //*fLog << "MCT1PadSchweizer::Process(); sigbarold, sigmabar = " 
+  //      << sigbarold << ",  "<< sigmabar << endl;
+
+  // Skip event if target sigmabar is <= sigbarold
+  if (sigmabar <= sigbarold)
+  {
+    *fLog << "MCT1PadSchweizer::Process(); target sigmabar is less than sigbarold : "
+          << sigmabar << ",  " << sigbarold << ",   Skip event" << endl;
+
+    rc = 4;
+    fErrors[rc]++;
+    return kCONTINUE;     
+  }
+
+
+  //-------------------------------------------
+  //
+  // Calculate average number of NSB photons to be added (lambdabar)
+  // from the value of sigmabar, 
+  //  - making assumptions about the average electronic noise (elNoise2) and
+  //  - using a fixed value (F2excess)  for the excess noise factor
+  
+  Double_t elNoise2;         // [photons]  
+  Double_t F2excess  = 1.3;
+  Double_t lambdabar;        // [photons]
+
+
+
+  Int_t binTheta = fHDiffPixTheta->GetXaxis()->FindBin(theta);
+  if (binTheta != binNumber)
+  {
+    cout << "The binnings of the 2 histograms are not identical; aborting"
+         << endl;
+    return kERROR;
+  }
+
+  // Get RMS of (Sigma^2-sigmabar^2) in this Theta bin.
+  // The average electronic noise (to be added) has to be well above this RMS,
+  // otherwise the electronic noise of an individual pixel (elNoise2Pix)
+  // may become negative
+
+  TH1D *hnoise = fHDiffPixTheta->ProjectionZ("", binTheta, binTheta,
+                                                          0, 9999, "");
+  Double_t RMS = hnoise->GetRMS(1);  
+  delete hnoise;
+
+  elNoise2 = TMath::Min(RMS,  sigmabar2 - sigbarold2);
+  //*fLog << "elNoise2 = " << elNoise2 << endl; 
+
+  lambdabar = (sigmabar2 - sigbarold2 - elNoise2) / F2excess;     // [photons]
+
+  // This value of lambdabar is the same for all pixels;
+  // note that lambdabar is normalized to the area of pixel 0
+
+  //----------   start loop over pixels   ---------------------------------
+  // do the padding for each pixel
+  //
+  // pad only pixels   - which are used (before image cleaning)
+  //
+  Double_t sig         = 0;
+  Double_t sigma2      = 0;
+  Double_t diff        = 0;
+  Double_t addSig2     = 0;
+  Double_t elNoise2Pix = 0;
+
+
+  for (UInt_t i=0; i<npix; i++) 
+  {   
+    MCerPhotPix &pix = (*fEvt)[i];
+    if ( !pix.IsPixelUsed() )
+      continue;
+
+    //if ( pix.GetNumPhotons() == 0.0)
+    //{
+    //  *fLog << "MCT1PadSchweizer::Process(); no.of photons is 0 for used pixel" 
+    //        << endl;
+    //  continue;
+    //}
+
+    Int_t j = pix.GetPixId();
+
+    // GetPixRatio returns (area of pixel 0 / area of current pixel)
+    Double_t ratioArea = 1.0 / fCam->GetPixRatio(j);
+
+    MPedPhotPix &ppix = (*fPed)[j];
+    Double_t oldsigma = ppix.GetRms();
+    Double_t oldsigma2 = oldsigma*oldsigma;
+
+    //---------------------------------
+    // throw the Sigma for this pixel 
+    //
+    Int_t binPixel = fHDiffPixTheta->GetYaxis()->FindBin( (Double_t)j );
+
+    Int_t count;
+    Bool_t ok;
+
+    TH1D *hdiff;
+    TH1D *hsig;
+
+    switch (fPadFlag)
+    {
+    case 1 :
+      // throw the Sigma for this pixel from the distribution fHDiffPixTheta
+
+      hdiff = fHDiffPixTheta->ProjectionZ("", binTheta, binTheta,
+                                              binPixel, binPixel, "");
+      if ( hdiff->GetEntries() == 0 )
+      {
+        *fLog << "MCT1PadSchweizer::Process(); projection for Theta bin " 
+              << binTheta << "  and pixel bin " << binPixel  
+              << " has no entries;  aborting " << endl;
+        delete hdiff;
+
+        rc = 5;
+        fErrors[rc]++;
+        return kCONTINUE;     
+      }
+
+      count = 0;
+      ok = kFALSE;
+      for (Int_t m=0; m<20; m++)
+      {
+        count += 1;
+        diff = hdiff->GetRandom();
+        // the following condition ensures that elNoise2Pix > 0.0 
+
+        if ( (diff + sigmabar2 - oldsigma2/ratioArea
+                               - lambdabar*F2excess) > 0.0 )
+	{
+          ok = kTRUE;
+          break;
+	}
+      }
+      if (!ok)
+      {
+
+        *fLog << "theta, j, count, sigmabar, diff = " << theta << ",  " 
+              << j << ",  " << count << ",  " << sigmabar << ",  " 
+              << diff << endl;
+        diff = lambdabar*F2excess + oldsigma2/ratioArea - sigmabar2;
+      }
+      delete hdiff;
+      sigma2 = diff + sigmabar2;
+      break;
+
+    case 2 :
+      // throw the Sigma for this pixel from the distribution fHSigmaPixTheta
+
+      hsig = fHSigmaPixTheta->ProjectionZ("", binTheta, binTheta,
+                                              binPixel, binPixel, "");
+      if ( hsig->GetEntries() == 0 )
+      {
+        *fLog << "MCT1PadSchweizer::Process(); projection for Theta bin " 
+              << binTheta << "  and pixel bin " << binPixel  
+              << " has no entries;  aborting " << endl;
+        delete hsig;
+
+        rc = 6;
+        fErrors[rc]++;
+        return kCONTINUE;     
+      }
+
+      count = 0;
+      ok = kFALSE;
+      for (Int_t m=0; m<20; m++)
+      {
+        count += 1;
+
+        sig = hsig->GetRandom();
+        sigma2 = sig*sig/ratioArea;
+        // the following condition ensures that elNoise2Pix > 0.0 
+
+        if ( (sigma2-oldsigma2/ratioArea-lambdabar*F2excess) > 0.0 )
+	{
+          ok = kTRUE;
+          break;
+	}
+      }
+      if (!ok)
+      {
+
+        *fLog << "theta, j, count, sigmabar, sig = " << theta << ",  " 
+              << j << ",  " << count << ",  " << sigmabar << ",  " 
+              << sig << endl;
+        sigma2 = lambdabar*F2excess + oldsigma2/ratioArea; 
+      }
+      delete hsig;
+      break;
+    }
+
+    //---------------------------------
+    // get the additional sigma^2 for this pixel (due to the padding)
+
+    addSig2 = sigma2*ratioArea - oldsigma2;
+
+
+    //---------------------------------
+    // get the additional electronic noise for this pixel
+
+    elNoise2Pix = addSig2 - lambdabar*F2excess*ratioArea;
+
+
+    //---------------------------------
+    // throw actual number of additional NSB photons (NSB)
+    //       and its RMS (sigmaNSB) 
+
+    Double_t NSB0 = gRandom->Poisson(lambdabar*ratioArea);
+    Double_t arg  = NSB0*(F2excess-1.0) + elNoise2Pix;
+    Double_t sigmaNSB0;
+
+    if (arg >= 0)
+    {
+      sigmaNSB0 = sqrt( arg );
+    }
+    else
+    {
+      *fLog << "MCT1PadSchweizer::Process(); argument of sqrt < 0 : "
+            << arg << endl;
+      sigmaNSB0 = 0.0000001;      
+    }
+
+
+    //---------------------------------
+    // smear NSB0 according to sigmaNSB0
+    // and subtract lambdabar because of AC coupling
+
+    Double_t NSB = gRandom->Gaus(NSB0, sigmaNSB0) - lambdabar*ratioArea;
+
+    //---------------------------------
+ 
+    // add additional NSB to the number of photons
+    Double_t oldphotons = pix.GetNumPhotons();
+    Double_t newphotons = oldphotons + NSB;
+    pix.SetNumPhotons(newphotons);
+
+
+    fHNSB->Fill( NSB/sqrt(ratioArea) );
+    fHPhotons->Fill( oldphotons/sqrt(ratioArea), newphotons/sqrt(ratioArea) );
+
+
+    // error: add sigma of padded noise quadratically
+    Double_t olderror = pix.GetErrorPhot();
+    Double_t newerror = sqrt(olderror*olderror + addSig2);
+    pix.SetErrorPhot(newerror);
+
+
+    Double_t newsigma = sqrt(oldsigma2 + addSig2);
+    ppix.SetRms(newsigma);
+
+    fHSigmaPedestal->Fill(oldsigma, newsigma);
+  } 
+  //----------   end of loop over pixels   ---------------------------------
+
+  // Calculate sigmabar again and crosscheck
+
+
+  //fSigmabar->Calc(*fCam, *fPed, *fEvt);
+  //*fLog << "after padding : " << endl;
+  //fSigmabar->Print("");
+
+
+  //*fLog << "Exit MCT1PadSchweizer::Process();" << endl;
+
+  rc = 0;
+  fErrors[rc]++;
+
+  return kTRUE;
+
+}
+
+// --------------------------------------------------------------------------
+//
+//
+Int_t MCT1PadSchweizer::PostProcess()
+{
+    if (GetNumExecutions() != 0)
+    {
+
+    *fLog << inf << endl;
+    *fLog << GetDescriptor() << " execution statistics:" << endl;
+    *fLog << dec << setfill(' ');
+    *fLog << " " << setw(7) << fErrors[1] << " (" << setw(3) 
+          << (int)(fErrors[1]*100/GetNumExecutions()) 
+          << "%) Evts skipped due to: Sigmabar_old > 0" << endl;
+
+    *fLog << " " << setw(7) << fErrors[2] << " (" << setw(3) 
+          << (int)(fErrors[2]*100/GetNumExecutions()) 
+          << "%) Evts skipped due to: Zenith angle out of range" << endl;
+
+    *fLog << " " << setw(7) << fErrors[3] << " (" << setw(3) 
+          << (int)(fErrors[3]*100/GetNumExecutions()) 
+          << "%) Evts skipped due to: No data for generating Sigmabar" << endl;
+
+    *fLog << " " << setw(7) << fErrors[4] << " (" << setw(3) 
+          << (int)(fErrors[4]*100/GetNumExecutions()) 
+          << "%) Evts skipped due to: Target sigma <= Sigmabar_old" << endl;
+
+    *fLog << " " << setw(7) << fErrors[5] << " (" << setw(3) 
+          << (int)(fErrors[5]*100/GetNumExecutions()) 
+          << "%) Evts skipped due to: No data for generating Sigma^2-Sigmabar^2" << endl;
+
+    *fLog << " " << setw(7) << fErrors[6] << " (" << setw(3) 
+          << (int)(fErrors[6]*100/GetNumExecutions()) 
+          << "%) Evts skipped due to: No data for generating Sigma" << endl;
+
+    *fLog << " " << setw(7) << fErrors[7] << " (" << setw(3) 
+          << (int)(fErrors[7]*100/GetNumExecutions()) 
+          << "%) Evts skipped due to: No data for generating Blind pixels" << endl;
+
+    *fLog << " " << fErrors[0] << " (" 
+          << (int)(fErrors[0]*100/GetNumExecutions()) 
+          << "%) Evts survived the padding!" << endl;
+    *fLog << endl;
+
+    }
+
+    //---------------------------------------------------------------
+    TCanvas &c = *(MH::MakeDefCanvas("PadSchweizer", "", 900, 1200)); 
+    c.Divide(3, 4);
+    gROOT->SetSelectedPad(NULL);
+
+    c.cd(1);
+    fHNSB->SetDirectory(NULL);
+    fHNSB->DrawCopy();
+    fHNSB->SetBit(kCanDelete);    
+
+    c.cd(2);
+    fHSigmaPedestal->SetDirectory(NULL);
+    fHSigmaPedestal->DrawCopy();
+    fHSigmaPedestal->SetBit(kCanDelete);    
+
+    c.cd(3);
+    fHPhotons->SetDirectory(NULL);
+    fHPhotons->DrawCopy();
+    fHPhotons->SetBit(kCanDelete);    
+
+    //--------------------------------------------------------------------
+
+
+    c.cd(4);
+    fHSigmaTheta->SetDirectory(NULL);
+    fHSigmaTheta->SetTitle("(Input) 2D : Sigmabar, \\Theta");
+    fHSigmaTheta->DrawCopy();     
+    fHSigmaTheta->SetBit(kCanDelete);     
+
+    //--------------------------------------------------------------------
+
+
+    c.cd(7);
+    fHBlindPixNTheta->SetDirectory(NULL);
+    fHBlindPixNTheta->SetTitle("(Input) 2D : no.of blind pixels, \\Theta");
+    fHBlindPixNTheta->DrawCopy();     
+    fHBlindPixNTheta->SetBit(kCanDelete);     
+
+    //--------------------------------------------------------------------
+
+
+    c.cd(10);
+    fHBlindPixIdTheta->SetDirectory(NULL);
+    fHBlindPixIdTheta->SetTitle("(Input) 2D : blind pixel Id, \\Theta");
+    fHBlindPixIdTheta->DrawCopy();     
+    fHBlindPixIdTheta->SetBit(kCanDelete);     
+
+
+    //--------------------------------------------------------------------
+    // draw the 3D histogram (input): Theta, pixel, Sigma^2-Sigmabar^2
+
+    c.cd(5);
+    TH2D *l1;
+    l1 = (TH2D*) ((TH3*)fHDiffPixTheta)->Project3D("zx");
+    l1->SetDirectory(NULL);
+    l1->SetTitle("(Input) Sigma^2-Sigmabar^2 vs. \\Theta (all pixels)");
+    l1->SetXTitle("\\Theta [\\circ]");
+    l1->SetYTitle("Sigma^2-Sigmabar^2");
+
+    l1->DrawCopy("box");
+    l1->SetBit(kCanDelete);;
+
+    c.cd(8);
+    TH2D *l2;
+    l2 = (TH2D*) ((TH3*)fHDiffPixTheta)->Project3D("zy");
+    l2->SetDirectory(NULL);
+    l2->SetTitle("(Input) Sigma^2-Sigmabar^2 vs. pixel number (all \\Theta)");
+    l2->SetXTitle("pixel");
+    l2->SetYTitle("Sigma^2-Sigmabar^2");
+
+    l2->DrawCopy("box");
+    l2->SetBit(kCanDelete);;
+
+    //--------------------------------------------------------------------
+    // draw the 3D histogram (input): Theta, pixel, Sigma
+
+    c.cd(6);
+    TH2D *k1;
+    k1 = (TH2D*) ((TH3*)fHSigmaPixTheta)->Project3D("zx");
+    k1->SetDirectory(NULL);
+    k1->SetTitle("(Input) Sigma vs. \\Theta (all pixels)");
+    k1->SetXTitle("\\Theta [\\circ]");
+    k1->SetYTitle("Sigma");
+
+    k1->DrawCopy("box");
+    k1->SetBit(kCanDelete);
+
+    c.cd(9);
+    TH2D *k2;
+    k2 = (TH2D*) ((TH3*)fHSigmaPixTheta)->Project3D("zy");
+    k2->SetDirectory(NULL);
+    k2->SetTitle("(Input) Sigma vs. pixel number (all \\Theta)");
+    k2->SetXTitle("pixel");
+    k2->SetYTitle("Sigma");
+
+    k2->DrawCopy("box");
+    k2->SetBit(kCanDelete);;
+
+
+    //--------------------------------------------------------------------
+
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1PadSchweizer.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1PadSchweizer.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1PadSchweizer.h	(revision 9661)
@@ -0,0 +1,80 @@
+#ifndef MARS_MCT1PadSchweizer
+#define MARS_MCT1PadSchweizer
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+class TH1D;
+class TH2D;
+class TH3D;
+
+class MGeomCam;
+class MCerPhotEvt;
+class MPedPhotCam;
+class MMcEvt;
+class MSigmabar;
+class MParList;
+class MBlindPixels;
+
+class MCT1PadSchweizer : public MTask
+{
+private:
+    MGeomCam       *fCam;
+    MCerPhotEvt    *fEvt; 
+    MSigmabar      *fSigmabar;
+    MMcEvt         *fMcEvt;
+    MPedPhotCam   *fPed;
+    MBlindPixels   *fBlinds;
+
+    Int_t          fPadFlag;
+    Int_t          fRunType;
+    Int_t          fGroup;
+
+    Int_t          fErrors[8];
+
+    // plots used for the padding
+    TH2D           *fHBlindPixIdTheta; // 2D-histogram (blind pixel Id vs. Theta)
+    TH2D           *fHBlindPixNTheta; // 2D-histogram (no.of blind pixels vs. Theta)
+    TH2D           *fHSigmaTheta;    // 2D-histogram (sigmabar vs. Theta)
+    TH3D           *fHSigmaPixTheta; // 3D-histogram (Theta, pixel, sigma)
+    TH3D           *fHDiffPixTheta;  // 3D-histogram (Theta, pixel, sigma^2-sigmabar^2)
+
+    // plots for checking the padding
+    TH2D           *fHSigmaPedestal; // 2D-histogram : pedestal sigma after
+                                     //                versus before padding
+    TH2D           *fHPhotons;       // 2D-histogram : no.of photons after
+                                     //                versus before padding
+    TH1D           *fHNSB;           // 1D-histogram : additional NSB
+
+
+public:
+    MCT1PadSchweizer(const char *name=NULL, const char *title=NULL);
+    ~MCT1PadSchweizer();
+
+    void SetHistograms(TH2D *hist2, TH3D *hist3, TH3D *hist3Diff,
+                       TH2D *hist2Pix, TH2D *hist2PixN);
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+    
+    void SetPadFlag(Int_t padflag);
+
+    ClassDef(MCT1PadSchweizer, 0)    // task for the padding (Schweizer)
+}; 
+
+#endif
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1PointingCorrCalc.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1PointingCorrCalc.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1PointingCorrCalc.cc	(revision 9661)
@@ -0,0 +1,218 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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  03/2003 <mailto:wittek@mppmu.mpg.de>
+!              Nadia Tonello    05/2003 <mailto:tonello@mppmu.mpg.de>
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//  MCT1PointingCorrCalc                                                   //
+//                                                                         //
+//  This is a task to do the CT1 pointing correction.                      // 
+//                                                                         //
+//  NT: You can correct the Mkn421 data (default setting), or the 1ES1959  //
+//      data.                                                              // 
+//      To change to the correction needed for 1ES1959,  you have to call  //
+//      the member funcion: SetPointedSource                               //
+//                                                                         //
+//  Example:                                                               //
+//      MCT1PointingCorrCalc correct;                                      //
+//      correct.SetPointedSource(MCT1PointingCorrectionCalc::K1959)        //
+//                                                                         // 
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MCT1PointingCorrCalc.h"
+
+#include "MParList.h"
+
+#include "MSrcPosCam.h"
+#include "MGeomCam.h"
+#include "MParameters.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MCT1PointingCorrCalc);
+
+using namespace std;
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MCT1PointingCorrCalc::MCT1PointingCorrCalc(const char *srcname,
+                                           const char *name, const char *title)
+  : fSrcName(srcname), fPoiSource(k421)
+{
+    fName  = name  ? name  : "MCT1PointingCorrCalc";
+    fTitle = title ? title : "Task to do the CT1 pointing correction";
+}
+
+// --------------------------------------------------------------------------
+//
+Int_t MCT1PointingCorrCalc::PreProcess(MParList *pList)
+{
+    MGeomCam *geom = (MGeomCam*)pList->FindObject("MGeomCam");
+    if (!geom)
+        *fLog << warn << GetDescriptor() << ": No Camera Geometry available. Using mm-scale for histograms." << endl;
+    else
+    {
+        fMm2Deg = geom->GetConvMm2Deg();
+    }
+
+   fHourAngle = (MParameterD*)pList->FindObject("HourAngle", "MParameterD");
+    if (!fHourAngle)
+    {
+        *fLog << err << "HourAngle [MParameterD] not found... aborting." << endl;
+        return kFALSE;
+    }
+
+
+    fSrcPos = (MSrcPosCam*)pList->FindObject(fSrcName, "MSrcPosCam");
+    if (!fSrcPos)
+    {
+        *fLog << err << fSrcName << " [MSrcPosCam] not found... aborting." << endl;
+        return kFALSE;
+    }
+
+
+    return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
+//Implemented Daniel Kranich's pointing correction for Mkn421 (2001 data)
+//
+
+void MCT1PointingCorrCalc::PointCorr421()
+{
+   //*fLog << "MCT1PointingCorrCalc::Process; fhourangle = " 
+   //      << fhourangle << endl;
+
+   Float_t fhourangle = fHourAngle->GetVal();
+
+   Float_t cx = -0.05132 - 0.001064 * fhourangle 
+                         - 3.530e-6 * fhourangle * fhourangle;
+   cx /= fMm2Deg;
+
+   Float_t cy = -0.04883 - 0.0003175* fhourangle
+                         - 2.165e-5 * fhourangle * fhourangle;
+   cy /= fMm2Deg;
+
+   fSrcPos->SetXY(cx, cy);
+
+   //*fLog << "MCT1PointingCorrCal::Process; fhourangle, cx, cy, fMm2Deg = "
+   //      << fhourangle << ",  " << cx << ",  " << cy << ",  " 
+   //      << fMm2Deg << endl;
+
+   fSrcPos->SetReadyToSave();
+   return;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// NT :Implemente Daniel Kranich's pointing correction for 1ES1959 (2002 data)
+
+void MCT1PointingCorrCalc::PointCorr1959()
+{
+   //*fLog << "MCT1PointingCorrCalc::Process; fhourangle = " 
+   //      << fhourangle << endl;
+
+   Float_t fhourangle = fHourAngle->GetVal();
+
+   Float_t cx = -0.086 - 0.00091 * fhourangle ;
+   cx /= fMm2Deg;
+
+   Float_t cy = -0.083 - 0.001 * fhourangle ;
+   cy /= fMm2Deg;
+
+   fSrcPos->SetXY(cx, cy);
+
+   //*fLog << "MCT1PointingCorrCal::Process; fhourangle, cx, cy, fMm2Deg = "
+   //      << fhourangle << ",  " << cx << ",  " << cy << ",  " 
+   //      << fMm2Deg << endl;
+
+   fSrcPos->SetReadyToSave();
+   return;
+
+}
+// --------------------------------------------------------------------------
+//
+// Do the pointing correction
+//
+Int_t MCT1PointingCorrCalc::Process()
+{
+   // fhourangle is the hour angle [degrees]
+   // (cx, cy) is the source position in the camera [mm]
+   //
+   switch (fPoiSource)
+    {
+    case k421:
+        PointCorr421();
+    case k1959:
+        PointCorr1959();
+    }  
+   return kTRUE;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1PointingCorrCalc.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1PointingCorrCalc.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1PointingCorrCalc.h	(revision 9661)
@@ -0,0 +1,64 @@
+#ifndef MARS_MCT1PointingCorrCalc
+#define MARS_MCT1PointingCorrCalc
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MCT1PointingCorrCalc                                                    //
+//                                                                         //
+// Task to do the pointing correction                                      //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MSrcPosCam;
+class MParameterD;
+
+
+class MCT1PointingCorrCalc : public MTask
+{
+public:
+    typedef enum {
+        k421,
+        k1959
+    } PointedSource_t;
+
+private:
+
+    MSrcPosCam   *fSrcPos;
+    TString       fSrcName;
+    MParameterD  *fHourAngle;
+
+    PointedSource_t fPoiSource;
+    Float_t       fMm2Deg;
+
+    void PointCorr421();
+    void PointCorr1959();
+
+public:
+
+    MCT1PointingCorrCalc(const char *srcname="MSrcPosCam",
+                         const char *name=NULL, const char *title=NULL);
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
+    void SetPointedSource(PointedSource_t s) { fPoiSource = s; }
+ 
+    ClassDef(MCT1PointingCorrCalc, 0)   // Task to do the CT1 pointing correction for Mkn421 2001 data or 1ES1959 2002 data
+};
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1ReadAscii.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1ReadAscii.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1ReadAscii.cc	(revision 9661)
@@ -0,0 +1,304 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Harald Kornmayer, 1/2001
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// 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 <errno.h>
+#include <fstream>
+
+#include <TList.h>
+#include <TSystem.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MCerPhotEvt.h"
+
+#include "MPedPhotPix.h"
+#include "MPedPhotCam.h"
+
+ClassImp(MCT1ReadAscii);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// 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
+//
+Int_t MCT1ReadAscii::AddFile(const char *txt, Int_t)
+{
+    TNamed *name = new TNamed(txt, "");
+    fFileNames->AddLast(name);
+    return 1;
+}
+
+// --------------------------------------------------------------------------
+//
+// 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();
+
+    const char *expname = gSystem->ExpandPathName(name);
+    fIn = new ifstream(expname);
+
+    const Bool_t noexist = !(*fIn);
+    if (noexist)
+    {
+        *fLog << err << "Cannot open file " << expname << ": ";
+        *fLog << strerror(errno) << endl;
+    }
+    else
+        *fLog << inf << "Open file: '" << name << "'" << endl;
+
+    delete [] expname;
+
+    //
+    // 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 MPedPhotCam container to 127 pixels (CT1 camera)
+//
+Int_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 = (MPedPhotCam*)pList->FindCreateObj("MPedPhotCam");
+    if (!fPedest)
+        return kFALSE;
+
+    MGeomCam *geom = (MGeomCam*)pList->FindObject("MGeomCam");
+    if (!geom)
+    {
+        *fLog << err << "MGeomCam not found... abort." << endl;
+        return kFALSE;
+    }
+
+    fPedest->Init(*geom);
+
+    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)
+            (*fPedest)[i].Set(0, val);
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Read a data entry (line) from the file
+//
+void MCT1ReadAscii::ReadData()
+{
+    //
+    // 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
+    //
+    for (Int_t i = 0; i<127; i++ )
+    {
+        Float_t nphot;
+
+        *fIn >> nphot;
+
+        if (nphot > 0.0)
+            fNphot->AddPixel(i, nphot, (*fPedest)[i].GetRms());
+    }
+    fNphot->FixSize();
+}
+
+// --------------------------------------------------------------------------
+//
+// 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.
+//
+Int_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 MPedPhotCam )
+    //
+ 
+    //
+    // read in the event nr
+    //
+    Int_t evtnr;
+    *fIn >> evtnr;
+
+    //
+    // check if we are done. Try to open the next file in chain.
+    // If it was possible start reading. If not break the event loop
+    //
+    if (fIn->eof())
+        return OpenNextFile() ? kCONTINUE : kFALSE;
+
+    //
+    // if the first number is negativ this is a pedestal line:
+    // read in pedestals
+    //
+    // FIXME! Set InputStreamID
+
+    if (evtnr < 0)
+    {
+        ReadPedestals();
+        return kCONTINUE;
+    }
+
+    ReadData();
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1ReadAscii.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1ReadAscii.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1ReadAscii.h	(revision 9661)
@@ -0,0 +1,41 @@
+#ifndef MARS_MCT1ReadAscii
+#define MARS_MCT1ReadAscii
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class TList;
+class MCerPhotEvt;
+class MPedPhotCam;
+
+class MCT1ReadAscii : public MTask
+{
+private:
+    ifstream    *fIn;        // the inputfile
+    MCerPhotEvt *fNphot;     // the data container for all data.
+    MPedPhotCam *fPedest;    // CT1 pedestals
+    TList       *fFileNames; // Array which stores the \0-terminated filenames
+
+    Bool_t OpenNextFile();
+
+    void ReadPedestals();
+    void ReadData();
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
+public:
+    MCT1ReadAscii(const char *filename=NULL,
+                  const char *name=NULL,
+                  const char *title=NULL);
+
+    ~MCT1ReadAscii();
+
+    Int_t AddFile(const char *fname, Int_t dummy=-1);
+
+    ClassDef(MCT1ReadAscii, 0)	// Reads the CT1 data file
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1ReadPreProc.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1ReadPreProc.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1ReadPreProc.cc	(revision 9661)
@@ -0,0 +1,1171 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 11/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MCT1ReadPreProc
+//
+// Reads a output file of the CT1 preproc.
+//
+// Implements usage of a selector (see MRead) Use such a filter to skip
+// events before reading! But never use a filter which needs read data
+// as input...
+//
+//  Input Containers:
+//   -/-
+//
+//  Output Containers:
+//    MCerPhotEvt     the data container for all data.
+//    MPedPhotCam     CT1 pedestals
+//    MMcEvt          monte carlo data container for MC files
+//    MMcTrig         mc data container for trigger information
+//    MSrcPosCam      source position in the camera
+//    MBadPixelsCam   Array holding blind pixels
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCT1ReadPreProc.h"
+
+#include <errno.h>
+#include <fstream>
+
+#include <TList.h>
+#include <TSystem.h>
+#include <TRandom3.h>
+
+#define LINUX
+#define HISTO void
+#define HBOOK_FILE int
+#include "defines.h"
+#include "structures.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MTime.h"
+#include "MFilter.h"
+
+#include "MParList.h"
+#include "MCerPhotEvt.h"
+
+#include "MPedPhotPix.h"
+#include "MPedPhotCam.h"
+
+#include "MGeomCam.h"
+#include "MSrcPosCam.h"
+#include "MBadPixelsCam.h"
+#include "MBadPixelsPix.h"
+
+#include "MRawRunHeader.h"
+#include "MTaskList.h"
+
+#include "MMcEvt.hxx"
+#include "MMcTrig.hxx"
+#include "MBinning.h"
+
+#include "MParameters.h"
+
+ClassImp(MCT1ReadPreProc);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. Creates an array which stores the file names of
+// the files which should be read. If a filename is given it is added
+// to the list.
+//
+MCT1ReadPreProc::MCT1ReadPreProc(const char *fname, const char *name,
+                                 const char *title) : fIn(NULL), fEntries(0)
+{
+    fName  = name  ? name  : "MRead";
+    fTitle = title ? title : "Reads a CT1 preproc data file";
+
+    //
+    // remember file name for opening the file in the preprocessor
+    //
+    fFileNames = new TList;
+    fFileNames->SetOwner();
+
+    if (fname)
+        AddFile(fname);
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the filename list and the input stream if one exists.
+//
+MCT1ReadPreProc::~MCT1ReadPreProc()
+{
+    delete fFileNames;
+    if (fIn)
+        delete fIn;
+}
+
+// --------------------------------------------------------------------------
+//
+// Add this file as the last entry in the chain
+//
+Int_t MCT1ReadPreProc::AddFile(const char *txt, int)
+{
+    const char *name = gSystem->ExpandPathName(txt);
+
+    TString fname(name);
+    delete [] name;
+
+    if (!CheckHeader(fname))
+    {
+        *fLog << warn << "WARNING - Problem reading header... ignored." << endl;
+        return 0;
+    }
+
+    const Int_t n = GetNumEvents(fname);
+    if (n==0)
+    {
+        *fLog << warn << "WARNING - File contains no data... ignored." << endl;
+        return 0;
+    }
+
+    fEntries += n;
+
+    *fLog << inf << "File " << txt << " contains " << n << " events (Total=" << fEntries << ")" << endl;
+
+    fFileNames->AddLast(new TNamed(txt, ""));
+    return 1;
+}
+
+// --------------------------------------------------------------------------
+//
+// Print data from the header to the screen and analyse the header data,
+// means store and copy the needed data into Mars structures and
+// data members
+//
+void MCT1ReadPreProc::ProcessRunHeader(const struct outputpars &outpars)
+{
+    if (outpars.inumpixels != iMAXNUMPIX)
+        *fLog << warn << "WARNING! File doesn't contain " << iMAXNUMPIX << " Pixels... maybe corrupt." << endl;
+
+    fNumEventsInRun = 0;
+
+    //
+    // ------------------- Output some stuff -----------------------
+    //
+
+    // int     itelescope;       // number of the CT which took the data
+    *fLog << inf << "Telescope: CT" << outpars.itelescope;
+
+    // float   flongitude_deg;   // longitude (counted positive towards West) of CT position */
+    // float   flatitude_deg;    // latitude (counted positive towards North) of CT position */
+    *fLog << " located @ Longitude=" << outpars.flongitude_deg;
+    *fLog << "deg  Latitude=" << outpars.flatitude_deg << "deg" << endl;
+
+    // int     irunnum;          // run number (from parameters file)
+    fRawRunHeader->SetRunNumber(outpars.irunnum);
+    fRawRunHeader->SetReadyToSave();
+
+    // enum    onoroff {NEITHER_ON_NOR_OFF, OFF_SOURCE, ON_SOURCE} eruntype; // runtype
+    *fLog << "Run:       #" << outpars.irunnum << "  (";
+    switch (outpars.eruntype)
+    {
+    case NEITHER_ON_NOR_OFF: *fLog << "unknown";    break;
+    case OFF_SOURCE:         *fLog << "off-source"; break;
+    case ON_SOURCE:          *fLog << "on-source";  break;
+    default:                 *fLog << (int)outpars.eruntype; break;
+    }
+    *fLog << ", ";
+    switch (outpars.etrackmode)
+    {
+    case NORMAL:  *fLog << "normal tracking";  break;
+    case REVERSE: *fLog << "reverse tracking"; break;
+    case DUNNO:   *fLog << "unknown tracking"; break;
+    default:      *fLog << (int)outpars.etrackmode; break;
+    }
+    *fLog << ")" << endl;
+
+    //double  dsourcera_hours;  // right ascension of observed source in hours
+    //double  dsourcedec_deg;   // declination of observed source in degrees
+    *fLog << "Source:    RA=" << outpars.dsourcera_hours << "h  DEC=";
+    *fLog << outpars.dsourcedec_deg << "deg" << endl;
+
+    //int     inummuonpixels;   // number of pixels in the muon shield
+    //int     inumcointdcs;     // number of coincidence tdcs recorded in the runfile
+    //float   fpixdiameter_deg; // smallest pixel diameter (degrees) (from parameters file) */
+
+    // enum    axes {RA, DEC, ALT, AZ} ese1_is; // name of the axis to which shaft encoder 1 is attached (implies the type of mount)
+    *fLog << "Shaftencoder 1 @ ";
+    switch (outpars.ese1_is)
+    {
+    case RA:  *fLog << "RA";  break;
+    case DEC: *fLog << "DEC"; break;
+    case ALT: *fLog << "ALT"; break;
+    case AZ:  *fLog << "AZ";  break;
+    default:  *fLog << (int)outpars.ese1_is; break;
+    }
+    *fLog << endl;
+
+    // int     isezeropos[2];       // zero position of shaftencoders 1 and 2 (from parameters file)
+    *fLog << "SE Zero:   SE(1)=" << outpars.isezeropos[0] << "  ";
+    *fLog << "SE(2)=" << outpars.isezeropos[1] << endl;
+
+    // int     iaz_rev_track_corr;  // correction for the azimuth shaft encoder (ALT/AZ mount only) in reverse tracking mode
+    // int     ialt_rev_track_corr; // correction for the altitude shaft encoder (ALT/AZ mount only) in reverse tracking mode
+    *fLog << "Reverse tracking corrections: SE(az)=" << outpars.iaz_rev_track_corr;
+    *fLog << "  SE(alt)=" << outpars.ialt_rev_track_corr << endl;
+
+    // float   fbendingcorr;        // bending correction factor (ALT/AZ mount only)
+    // float   fextinction;         // atmospheric extinction (typically taken from the Carlsberg Meridian Circle data)
+    *fLog << "Bending: Correction factor=" << outpars.fbendingcorr << "  ";
+    *fLog << "Extinction=" << outpars.fextinction << endl;
+
+    // Boolean bdontusepix[iMAXNUMPIX]; // bdontusepix is set true if the pixel should not be used in image analysis, otherwise it is true;
+
+    fBlinds->Clear();
+    *fLog << "Don't use pixels: ";
+    for (int i=0; i<iMAXNUMPIX; i++)
+        if (outpars.bdontusepix[i])
+        {
+            *fLog << i << " ";
+            (*fBlinds)[i].SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
+        }
+    *fLog << endl;
+
+    *fLog << "Exclude pixels: ";
+    // Boolean bexcludepix[iMAXNUMPIX];
+    for (int i=0; i<iMAXNUMPIX; i++)
+        if (outpars.bexcludepix[i])
+        {
+            *fLog << i << " ";
+            (*fBlinds)[i].SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
+        }
+    *fLog << endl;
+
+    // save blind pixels for all events of this run
+    fBlnd.Set(iMAXNUMPIX);
+    for (int i=0; i<iMAXNUMPIX; i++)
+        fBlnd[i] = (*fBlinds)[i].IsBad() ? 1 : 0;
+
+    fBlinds->SetReadyToSave();
+
+    /* bexcludepix[] is set TRUE (== exclude from pedestal, Laser
+     * calibration and the further analysis) when the Mean value
+     * of a pixel inside a pedestal Run is larger than 50 or ( || )
+     * if the pedestal RMS value of this pixel is larger than 5.0
+     * This is reflected in the (new for versions >= 0.4)
+     * variable "pixonoff" in the ntuple written by preproc:
+     * preproc.nt.hbook
+     *
+     * When the pixel is excluded by the user it will get a -2 otherwise
+     * pixonoff = 0.
+     * Additive to this a -1 is added when preproc excludes the pixel
+     * for a given Run. So the actual value tells you whether you caught
+     * it already by hand or not.
+     *
+     * A plot of pixonoff may also be handy to tell you the status of your
+     * ADC equipment. */
+
+    // float   fphotoel_per_adccnt[iMAXNUMPIX]; // conversion factors for the pixel signals */
+    /*
+    float padc = outpars.fphotoel_per_adccnt[0];
+    *fLog << "Phe/ADC (pixel 0): " << padc << endl;
+    for (int i=0; i<iMAXNUMPIX; i++)
+        *fLog << outpars.fphotoel_per_adccnt[i] << " ";
+    *fLog << endl;
+    */
+    /*
+     --- USEFULL? NEEDED? ---
+     int     irubminusutc_usecs;              // difference between rubidium clock and UTC in microseconds
+     int     isum_thresh_phot;                // threshold for the total sum of photoelectrons filter
+     int     i2out_thresh_phot;               // threshold for the two-pixels-out-of-all software
+     int     imuoncut_thresh_adccnt[iMAXNUMMUONPIX]; // thresholds for the muon cut
+     Boolean bmuon_suppression;               // "Dolby" noise reduction flag
+     float   ftolerated_pointerror_deg;       // maximum tolerated pointing error in the position
+     */
+
+    // float fxpointcorr_deg; // pointing correction (to be added along the camera x axis) e.g. from point run */
+    // float fypointcorr_deg; // pointing correction (to be added along the camera y axis) e.g. from point run */
+    *fLog << "Pointing correction: dx=" << outpars.fxpointcorr_deg << "deg  ";
+    *fLog << "dy=" << outpars.fypointcorr_deg << "deg" << endl;
+
+    // FIXME? Is x-y echanged between Mars CT1 geometry and CT1 definition?
+    fSrcPos->SetXY(-outpars.fypointcorr_deg/fGeom->GetConvMm2Deg(),
+                   -outpars.fxpointcorr_deg/fGeom->GetConvMm2Deg());
+    fSrcPos->SetReadyToSave();
+
+    /*
+     --- USEFULL? NEEDED? ---
+     float   fcamera_align_angle_deg;         // the angle between the camera y-axis and the meridian when a culminating object is observed (defined counter-clockwise looking at the sky)
+     int     iratecalc_numevents_odd;         // number of events used in the rate calculation (must be odd)
+     int     inumpedfile;                     // number of the pedestal file used
+     int     inumpedrun;                      // number of the pedestal run used in the file (starting at 0)
+     int     inumcalfile;                     // number of the calibration file used
+     int     inumlaserrun;                    // number of the laserrun used in the file (starting at 0)
+     int     inumtellogfile;                  // number of the TelLog file to be used
+     int     inumtellogrun;                   // number of the tellog entry (Runnumber) used from the log file
+     int     imcparticle;                     // CORSIKA-coded Monte Carlo particle type.
+    */
+
+    // ----- preprocessing results -----
+
+    // int     istart_mjdate_day;                 // MJD of run start (first event) */
+    // int     iend_mjdate_day;                   // MJD of run end (last event) */
+    // int     irunduration_secs;                 // difference between start and end time (secs) */
+    *fLog << "Run Time: From " << outpars.istart_mjdate_day << " to ";
+    *fLog << outpars.iend_mjdate_day << " (MJD),  Duration=";
+    *fLog << outpars.irunduration_secs/3600 << "h";
+    *fLog << (outpars.irunduration_secs/60)%60 << "m";
+    *fLog << outpars.irunduration_secs%60 << "s" << endl;
+    fRawRunHeader->SetRunTime(outpars.istart_mjdate_day, outpars.iend_mjdate_day);
+    fRawRunHeader->SetReadyToSave();
+
+    /*
+     --- USEFULL? NEEDED? ---
+     int     iproc_mjdate;                      // MJD of data processing (i.e. creation of this file)
+     */
+
+    // int     iproc_evts;                        // number of events processed */
+    *fLog << "Number of processed events: " << outpars.iproc_evts << endl;
+
+    // --- USEFULL? NEEDED? ---
+    // double  dactual_sourcera_hours;            // for off runs: the false source (that should have been) observed */
+
+    // float   frms_pedsig_phot[iMAXNUMPIX];      // standard deviation of the calibrated signals from the pedestal run */
+    fPedest->Init(*fGeom);
+
+    fPedRMS.Set(iMAXNUMPIX);
+
+    *fLog << "PedestalRMS : ";
+    for (Int_t i=0; i<iMAXNUMPIX; i++)
+    {
+        (*fPedest)[i].Set(0, outpars.frms_pedsig_phot[i]);
+        *fLog << outpars.frms_pedsig_phot[i] << " "; 
+        fPedRMS[i] = outpars.frms_pedsig_phot[i];
+    }
+    *fLog << endl;
+
+    fPedest->SetReadyToSave();
+
+    // Used to communicate the mean over all pixels
+    // pedestal RMS into the Runs NTuple, as it might
+    // be used for e.g. quality cuts.
+    // float   fpedrms_mean;
+    *fLog << "Pedestal RMS: " << outpars.fpedrms_mean << endl;
+
+    // The average current over the active pixels
+    // for this run. This is done separately for
+    // ON and OF runs.
+    //float   fcurrent_mean;
+
+    // enum eERRORTOLERANCE {CAUTIOUS=0, GOODPHYSICS, TANK} eerrortolerance;
+    /* 0 == "cautious", exits on any reason (but tells in
+     * the .err file,
+     * 1 == "goodphysics", exits when physics could be affected
+     * by the error,
+     * 2 == "tank", never exits except on coredumps and when
+     * all files have been processed. Do not use such files for
+     * physics analysis!
+     *
+     * NOTE: the capital letter words are the enums, the small letter
+     * words must be used inside the parameter file. */
+
+    // enum eMCTRIGGERFLAG {ALL=0, FLAG, NOFLAG} emctriggerflag;
+    /* all: all events which survive the filter are written to the
+     *      events NTuple.
+     * flag: When Dorota's triggerflag is set to 1 for a particular
+     *       event, it shall be written to the output. All others shall
+     *       just be disregarded. (Default)
+     * noflag: Opposite of 'flag': only events with triggerflag = 0 shall
+     *         be treated further. */
+
+    *fLog << "Particle Id #" << outpars.imcparticle << endl;
+    *fLog << "Right Ascension: " << outpars.dsourcera_hours << "h" << endl;
+    *fLog << "Declination: " << outpars.dsourcedec_deg << "deg" << endl;
+
+    // Next statement commented out because bmontecarlo was set wrongly
+    //fIsMcFile = outpars.bmontecarlo==TRUE;
+    fIsMcFile = (outpars.dsourcera_hours==0 && outpars.dsourcedec_deg==0 &&
+                 outpars.imcparticle != 0);
+
+    if (fIsMcFile != (outpars.bmontecarlo==TRUE))
+    {
+        *fLog << "File tells you that it is a ";
+        *fLog << (outpars.bmontecarlo ? "Monte Carlo" : "Real Data");
+        *fLog << " file." << endl;
+    }
+
+    *fLog << "File detected as a ";
+    *fLog << (fIsMcFile ? "Monte Carlo" : "Real Data");
+    *fLog << " file." << endl;
+    *fLog << " " << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Read CT1 PreProc File Header:
+//
+Int_t MCT1ReadPreProc::ReadRunHeader()
+{
+    char cheadertitle[iHEADERTITLELENGTH];
+    fIn->read(cheadertitle, iHEADERTITLELENGTH);
+
+    TString s = cheadertitle;
+    TString m = cTITLE_TEMPLATE;
+
+    if (!s.BeginsWith(m(0, m.First('%'))))
+        return kFALSE;
+
+    *fLog << cheadertitle << flush;
+
+    // cTITLE_TEMPLATE "PREPROC V%f/S%f CT %d RUN %d %d PROCMJD %d\n"
+    struct outputpars outpars;
+
+    int dummy;
+
+    Float_t fpreprocversion, structversion;
+    sscanf(cheadertitle, cTITLE_TEMPLATE,
+           &fpreprocversion,    &structversion,
+           &outpars.itelescope, &outpars.irunnum,
+           &dummy/*&outpars.eruntype*/, &outpars.iproc_mjdate);
+
+    if (fpreprocversion<0.6)
+    {
+        *fLog << err << "Sorry, only files from PreProc V0.6 and newer are supported." << endl;
+        return kFALSE;
+    }
+
+    //
+    // This is a stupid way of getting rid of numerical uncertanties when
+    // comparing floating point numbers (Argh...)
+    //
+    TString s1 = Form("%.2f", structversion);
+    TString s2 = Form("%.2f", STRUCT_VERSION);
+
+    if (s1 != s2)
+    {
+        *fLog << warn << "WARNING: Version of C-structures of file (V";
+        *fLog << s1 << ") not identical with current structures (V";
+        *fLog << s2 << ")" << endl;
+    }
+
+    fIn->read((char*)&outpars, sizeof(struct outputpars));
+
+    ProcessRunHeader(outpars);
+
+    //rwagner: ReInit whenever new run commences
+    // rc==-1 means: ReInit didn't work out
+
+    MTaskList *tlist = (MTaskList*)fParList->FindCreateObj("MTaskList");
+    if (!tlist)
+        return -1;
+
+    if (!tlist->ReInit(fParList))
+        return -1;
+
+    return kTRUE;
+}
+
+Int_t MCT1ReadPreProc::ReadRunFooter()
+{
+    char cheadertitle[iHEADERTITLELENGTH];
+    fIn->read(cheadertitle, iHEADERTITLELENGTH);
+    /*
+     sscanf(cheadertitle, cEND_EVENTS_TEMPLATE,
+     &filterres.ifilter_passed_evts);
+     */
+
+    TString s = cheadertitle;
+    TString m = cEND_EVENTS_TEMPLATE;
+    Int_t p = m.First('%');
+
+
+    if (!s.BeginsWith(m(0,p)))
+    {
+        fIn->seekg(-iHEADERTITLELENGTH, ios::cur);
+        return 0;
+    }
+
+    *fLog << inf << cheadertitle << flush;
+
+    struct filterresults filterres;
+    fIn->read((char*)&filterres, sizeof(struct filterresults));
+    /*
+     int   imax_alt_arcs;            // maximum altitude reached during the run
+     int   iaz_at_max_alt_arcs;      // azimuth at the time the max. alt. was reached
+     int   itimeaverage_alt_arcs;    // altitude averaged over the runtime
+     int   icoord_inconsist_evts;    // number of events with time-coordinate inconsistency in this run
+     int   ifilter_passed_evts;      // number of events which passed the filter
+     int   imuon_fail_evts;          // number of events rejected as muons (other filters passed)
+     int   i2out_fail_evts;          // number of events which failed in the two out of all pixels software trigger
+     int   imuon_and_2out_fail_evts; // number of events failing in both muon and 2out filter
+     int   isum_fail_evts;           // number of events which failed the sum-of-all-calibrated ADC counts filter
+     int   isum_and_muon_fail_evts;  // number of events which failed in both the sum and the muon filter
+     int   isum_and_2out_fail_evts;  // number of events which failed in both the sum and the 2out filter
+     int   iall_filters_fail_evts;   // number of events which failed in all filters
+     float favg_event_rate_hz;       // average rate before filtering
+     float fstddev_event_rate_hz;    // standard deviation of the rate before filtering
+     */
+
+    if (fNumEventsInRun!=(UInt_t)filterres.ifilter_passed_evts)
+    {
+        *fLog << err << "ERROR! Number of events in run (" << (UInt_t)filterres.ifilter_passed_evts;
+        *fLog << ") doesn't match number of read events (";
+        *fLog << fNumEventsInRun << ")" << endl;
+        *fLog << "       File corrupted." << endl;
+        return -1;
+    }
+
+    fNumFilterEvts += fNumEventsInRun;
+    fNumRuns++;
+
+    *fLog << inf << "Read " << fNumEventsInRun << " events from run (Total=";
+    *fLog << fNumFilterEvts << "/" << fEntries << " [";
+    *fLog << 100*fNumFilterEvts/fEntries << "%], Runs=" << fNumRuns << ")";
+    *fLog << endl;
+
+    return 1;
+}
+
+// --------------------------------------------------------------------------
+//
+// This opens the next file in the list and deletes its name from the list.
+//
+Bool_t MCT1ReadPreProc::OpenNextFile()
+{
+    //
+    // open the input stream and check if it is really open (file exists?)
+    //
+    if (fIn)
+        delete fIn;
+    fIn = NULL;
+
+    //
+    // Check for the existence of a next file to read
+    //
+    if (fNumFile >= (UInt_t)fFileNames->GetSize())
+        return kFALSE;
+
+    TNamed *file = (TNamed*)fFileNames->At(fNumFile);
+
+    //TNamed *file = (TNamed*)fFileNames->GetFirst();
+    //if (!file)
+    //    return kFALSE;
+
+    //
+    // open the file which is the first one in the chain
+    //
+    const TString name = file->GetName();
+
+    const char *expname = gSystem->ExpandPathName(name);
+    const TString fname(expname);
+    delete [] expname;
+
+    //
+    // Remove this file from the list of pending files
+    //
+    //fFileNames->Remove(file);
+
+    *fLog << inf << "Open file: '" << name << "'" << endl;
+
+    if (!CheckHeader(fname))
+        return kFALSE;
+
+    fNumFile++;
+
+    fIn = new ifstream(fname);
+    if (!*fIn)
+    {
+        *fLog << err << "Cannot open file " << fname << ": ";
+        *fLog << strerror(errno) << endl;
+        return kFALSE;
+    }
+
+    *fLog << inf << "-----------------------------------------------------------------------" << endl;
+
+    switch (ReadRunHeader())
+    {
+    case kFALSE:
+        *fLog << warn << "Unable to read first run header... skipping file." << endl;
+        return kFALSE;
+    case -1:
+        *fLog << warn << "ReInit of Tasklist didn't succeed." << endl;
+        return kFALSE;
+    default:
+        *fLog << "After opening next file: Number of Events #" << fNumEventsInRun << endl;
+        return kTRUE;
+    }
+}
+
+Bool_t MCT1ReadPreProc::CheckHeader(const TString fname) const
+{
+    ifstream fin(fname);
+    if (!fin)
+    {
+        *fLog << dbginf << err << "ERROR - Cannot open file '" << fname << "'" << endl;
+        return kFALSE;
+    }
+
+    char cheadertitle[iHEADERTITLELENGTH];
+    fin.read(cheadertitle, iHEADERTITLELENGTH);
+
+    Float_t fpreprocversion, structversion;
+    Int_t dummyi;
+
+    sscanf(cheadertitle, cTITLE_TEMPLATE,
+           &fpreprocversion, &structversion,
+           &dummyi, &dummyi, &dummyi, &dummyi);
+
+    if (fpreprocversion < 0.6)
+    {
+        *fLog << dbginf << err << "ERROR - You must use PreProc V0.6 or higher." << endl;
+        return kFALSE;
+    }
+
+    if (STRUCT_VERSION > structversion)
+    {
+        *fLog << warn << "WARNING: Version of C-structures of file (V";
+        *fLog << structversion << ") newer than current structures (V";
+        *fLog << STRUCT_VERSION << ")" << endl;
+    }
+
+    *fLog << "Current structures: " << STRUCT_VERSION << "  ";
+    *fLog << "Structures in file: " << structversion << "  ";
+    *fLog << "Used preproc version: " << fpreprocversion << endl;
+
+    return kTRUE;
+}
+
+
+Int_t MCT1ReadPreProc::GetNumEvents(const TString fname) const
+{
+    *fLog << inf << "Scanning file " << fname << " for size" << flush;
+
+    ifstream fin(fname);
+    if (!fin)
+    {
+        *fLog << dbginf << err << "ERROR - Opening file." << endl;
+        return 0;
+    }
+
+    const TString m(cEND_EVENTS_TEMPLATE);
+    const Int_t p = m.First('%');
+    const TString test = m(0, p);
+
+    Int_t nevts = 0;
+    Int_t nruns = 0;
+
+    while (!fin.eof() && fin.peek()!=EOF)
+    {
+        fin.seekg(iHEADERTITLELENGTH, ios::cur);
+        fin.seekg(sizeof(struct outputpars), ios::cur);
+
+        while (1)
+        {
+            if (fin.peek()==cEND_EVENTS_TEMPLATE[0])
+            {
+                char cheadertitle[iHEADERTITLELENGTH];
+                fin.read(cheadertitle, iHEADERTITLELENGTH);
+
+                const TString s = cheadertitle;
+                if (s.BeginsWith(test))
+                {
+                    fin.seekg(sizeof(struct filterresults), ios::cur);
+                    nruns++;
+                    break;
+                }
+
+                fin.seekg(-iHEADERTITLELENGTH, ios::cur);
+            }
+
+            fin.seekg(sizeof(struct eventrecord), ios::cur);
+            if (fin.eof())
+                break;
+
+            nevts++;
+        }
+        *fLog << "." << flush;
+    }
+
+    *fLog << "done." << endl;
+    *fLog << "Found " << nevts << " events in " << nruns << " runs." << endl;
+
+    return nevts;
+}
+
+Bool_t MCT1ReadPreProc::Rewind()
+{
+    fNumFilterEvts = 0;
+    fNumEvents     = 0;
+    fNumRuns       = 0;
+    fNumFile       = 0;
+    if (fIn)
+        delete fIn;
+
+    fIn=NULL;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// 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 MPedPhotCam container to 127 pixels (CT1 camera)
+//
+Int_t MCT1ReadPreProc::PreProcess(MParList *pList)
+{
+    fParList = pList;
+
+    //
+    //  look for the HourAngle container in the plist
+    //
+    fHourAngle = (MParameterD*)pList->FindCreateObj("MParameterD", "HourAngle");
+    if (!fHourAngle)
+        return kFALSE;
+    fHourAngle->SetTitle("Store the CT1 hour angle [deg]");
+
+    //
+    //  look for the ThetaOrig container in the plist
+    //
+    fThetaOrig = (MParameterD*)pList->FindCreateObj("MParameterD", "ThetaOrig");
+    if (!fThetaOrig)
+        return kFALSE;
+    fThetaOrig->SetTitle("Store the original CT1 zenith angle [rad]");
+
+    //
+    //  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 = (MPedPhotCam*)pList->FindCreateObj("MPedPhotCam");
+    if (!fPedest)
+        return kFALSE;
+
+    //
+    //  look for the time class in the plist
+    //
+    fTime = (MTime*)pList->FindCreateObj("MTime");
+    if (!fTime)
+        return kFALSE;
+
+    //
+    //  look for the pedestal class in the plist
+    //
+    fBlinds = (MBadPixelsCam*)pList->FindCreateObj("MBadPixelsCam");
+    if (!fBlinds)
+        return kFALSE;
+
+    //
+    //  look for the source position in the camera
+    //
+    fSrcPos = (MSrcPosCam*)pList->FindCreateObj("MSrcPosCam");
+    if (!fSrcPos)
+        return kFALSE;
+
+    //
+    //  look for the camera geometry
+    //
+    fGeom = (MGeomCam*)pList->FindCreateObj("MGeomCamCT1", "MGeomCam");
+    if (!fGeom)
+        return kFALSE;
+
+    //
+    //  look for the mc event class
+    //
+    fMcEvt = (MMcEvt*)pList->FindCreateObj("MMcEvt");
+    if (!fMcEvt)
+        return kFALSE;
+
+    //
+    //  look for the mc trigger class
+    //
+    fMcTrig = (MMcTrig*)pList->FindCreateObj("MMcTrig");
+    if (!fMcTrig)
+        return kFALSE;
+
+    //
+    //  look for the raw run header class
+    //
+    fRawRunHeader = (MRawRunHeader*)pList->FindCreateObj("MRawRunHeader");
+    if (!fRawRunHeader)
+        return kFALSE;
+
+    fBinningT = (MBinning*)pList->FindObject("BinningTheta");
+
+    Rewind();
+
+    fPedest->Init(*fGeom);
+
+    return GetSelector() ? GetSelector()->CallPreProcess(pList) : kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Smear Theta uniformly in a bin of Theta
+//   theta [rad]
+//   SmearTheta [rad]
+//
+Double_t MCT1ReadPreProc::SmearTheta(Double_t theta)
+{
+    if (!fBinningT)
+        return theta;
+
+    const Int_t bin = fBinningT->FindLoEdge(theta * 180/TMath::Pi());
+    if (bin<0)
+        return theta;
+
+    // smear Theta within the Theta bin
+    const Double_t low = fBinningT->GetEdges()[bin];
+    const Double_t up  = fBinningT->GetEdges()[bin+1];
+
+    // "up-": Do not allow the upper edge
+    return (up - gRandom->Uniform() * (up-low)) * TMath::Pi()/180;
+}
+
+// --------------------------------------------------------------------------
+//
+// Discretize Theta according to the binning in Theta
+//   theta [rad]
+//   DiscreteTheta [rad]  (= bin center)
+//
+Double_t MCT1ReadPreProc::DiscreteTheta(Double_t theta)
+{
+    if (!fBinningT)
+        return theta;
+
+    const Int_t bin = fBinningT->FindLoEdge(theta * 180/TMath::Pi());
+    if (bin<0)
+        return theta;
+
+    const Double_t low = fBinningT->GetEdges()[bin];
+    const Double_t up  = fBinningT->GetEdges()[bin+1];
+
+    return 0.5*(up+low) * TMath::Pi()/180;
+}
+
+// --------------------------------------------------------------------------
+//
+// Analyse the event data, means store and copy the needed data into
+// Mars structures and data members
+//
+Bool_t MCT1ReadPreProc::ProcessEvent(const struct eventrecord &event)
+{
+    /*
+    if (fRawRunHeader->GetRunNumber() == 1)
+    {
+        *fLog << "eventrecord" << endl;
+        *fLog << "isecs_since_midday = " << event.isecs_since_midday << endl;
+        *fLog << "isecfrac_200ns     = " << event.isecfrac_200ns << endl;
+        *fLog << "snot_ok_flags      = " << event.snot_ok_flags << endl;
+        *fLog << "ialt_arcs          = " << event.ialt_arcs << endl;
+        *fLog << "iaz_arcs           = " << event.iaz_arcs << endl;
+        *fLog << "ipreproc_alt_arcs  = " << event.ipreproc_alt_arcs << endl;
+        *fLog << "ipreproc_az_arcs   = " << event.ipreproc_az_arcs << endl;
+        *fLog << "ifieldrot_arcs     = " << event.ifieldrot_arcs << endl;
+
+        *fLog << "srate_millihz      = " << event.srate_millihz << endl;
+        *fLog << "fhourangle         = " << event.fhourangle << endl;
+        *fLog << "fmcenergy_tev      = " << event.fmcenergy_tev << endl;
+        *fLog << "fmcsize_phel       = " << event.fmcsize_phel << endl;
+        *fLog << "imcimpact_m        = " << event.imcimpact_m << endl;
+        *fLog << "imcparticle        = " << event.imcparticle << endl;
+        *fLog << "imctriggerflag     = " << event.imctriggerflag << endl;
+    }
+    */
+
+    // reset blind pixels for this event
+    fBlinds->Clear();
+    for (int i=0; i<iMAXNUMPIX; i++)
+        if (fBlnd[i]==1)
+            (*fBlinds)[i].SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
+
+    // reset pedestal RMS for this event
+    for (Int_t i=0; i<iMAXNUMPIX; i++)
+        (*fPedest)[i].Set(0, fPedRMS[i]);
+
+    //  int   isecs_since_midday; // seconds passed since midday before sunset (JD of run start)
+    //  int   isecfrac_200ns;     // fractional part of isecs_since_midday
+    fTime->SetCT1Time((UInt_t)fRawRunHeader->GetRunStart().GetMjd(), event.isecfrac_200ns, event.isecs_since_midday);
+    fTime->SetReadyToSave();
+
+    /*
+     --- USEFULL? NEEDED? ---
+     short snot_ok_flags;      // the bits in these two bytes are flags for additional information on the event: Everything OK =: all Bits = 0
+
+     // for ALT-AZ mount telescopes: rotation angle of the field of
+     // view; this angle is defined mathematically positive looking
+     // towards the sky as the angle between the hour circle through
+     // the object being tracked and the line through pixel 1 and 2
+     int   ifieldrot_arcs;
+
+     // event rate in milli Hertz before filtering calculated by
+     // iratecalc_numevents_odd/(time[i+iratecalc_numevents_odd/2] -
+     // time[i-iratecalc_numevents_odd/2])
+     // For the first and the last iratecalc_numevents_odd/2
+     // events the rate is assumed to be constant
+     unsigned short srate_millihz;
+
+     // This is the angle between the observation of this event and the
+     // culmination point. It is going to be written into the events NTuple.
+     float fhourangle;
+     */
+
+    //
+    // read in the number of cerenkov photons and add the 'new' pixel
+    // too the list with it's id, number of photons and error
+    // number of photoelectrons measured in each pixel only the
+    // actual number of pixels (outputpars.inumpixels) is written out
+    // short spixsig_10thphot[iMAXNUMPIX];
+    //
+    for (Int_t i=0; i<iMAXNUMPIX; i++)
+    {
+      //*fLog << event.spixsig_10thphot[i] << " ";
+
+      if (event.spixsig_10thphot[i]==0)
+            continue;
+
+        fNphot->AddPixel(i, 0.1*event.spixsig_10thphot[i], (*fPedest)[i].GetRms());
+    }
+    fNphot->FixSize();
+    fNphot->SetReadyToSave();
+
+    // int ipreproc_alt_arcs; // "should be" alt according to preproc (arcseconds)
+    // int ipreproc_az_arcs;  // "should be" az according to preproc (arcseconds)
+
+    // smear Theta in its Theta bin
+    const Double_t theta = TMath::Pi()*(0.5-1./180*event.ialt_arcs/3600);
+    fThetaOrig->SetVal(theta);
+
+    // store hour angle
+    fHourAngle->SetVal(event.fhourangle);
+
+    fMcEvt->Fill(event.isecs_since_midday,     //0, /*fEvtNum*/
+                 fIsMcFile ? event.imcparticle : 0, /*corsika particle type*/
+                 fIsMcFile ? event.fmcenergy_tev*1000 : 0,
+		 0, /* fThi0 */
+		 0, /* fFirTar */
+                 0, /* fzFirInt */
+		 // 0, /* fThet*/
+		 // rwagner: The following should be theta, right? Check with
+		 // altitude fill some lines down...
+		 0, // altitude (arcseconds)
+                 0, /* fPhii */
+                 0, /* fCorD */
+                 0, /* fCorX */
+                 0, /* fCorY */
+                 fIsMcFile ? event.imcimpact_m*100 : 0,
+                 TMath::Pi()/180*event.iaz_arcs/3600, // azimuth (arcseconds)
+		 // fIsMcFile ? SmearTheta(theta) : theta,
+                 DiscreteTheta(theta),
+                 0, /* fTFirst */
+		 0, /* fTLast */
+		 0, /* fL_Nmax */
+		 0, /* fL_t0 */
+		 0, /* fL_tmax */
+		 0, /* fL_a */
+		 0, /* fL_b */
+		 0, /* fL_c */
+		 0, /* fL_chi2 */
+		 0, /* uiPin */
+		 0, /* uiPat */
+		 0, /* uiPre */
+		 0, /* uiPco */
+		 0, /* uiPelS */
+                 (int)(fIsMcFile ? event.fmcsize_phel : 0), /* uiPelC, Simulated SIZE */
+		 0, /* elec */
+		 0, /* muon */
+		 0  /* other */
+                 );
+
+    fMcTrig->SetFirstLevel(event.imctriggerflag);    // MC data from Dorota get a triggerflag: 1 means triggered, 0 not. */
+
+    fMcTrig->SetReadyToSave();
+    fMcEvt->SetReadyToSave();
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Because of the file format of the preproc output we have to check at any
+// event where in the file stream we are...
+//
+Bool_t MCT1ReadPreProc::CheckFilePosition()
+{
+    //
+    // Means: If no file is open (first call) try to open the first file
+    //
+    if (!fIn)
+        return kFALSE;
+
+    //
+    // Because we can have 0-event runs in the file we loop as often
+    // as we don't find a new footer-header combination.
+    //
+    while (1)
+    {
+        //
+        // If the first character isn't the first of the footer it must be
+        // an event
+        //
+        if (fIn->peek()!=cEND_EVENTS_TEMPLATE[0])
+            return kTRUE;
+
+        //
+        // Try reading the footer. If this isn't successful...
+        // must be an event
+        //
+        switch (ReadRunFooter())
+        {
+        case -1:
+            return kFALSE;
+        case 0:
+            return kTRUE;
+        }
+
+        *fLog << inf << "Footer found." << endl;
+
+        const char c = fIn->peek();
+
+        //
+        // No after reading the footer check if we reached the end of the file
+        //
+        if (fIn->eof() || c==EOF)
+        {
+            *fLog << "End of file." << endl;
+            return kFALSE;
+        }
+
+        //
+        // If the eof isn't reached a new header must follow. Check for it.
+        //
+        if (c!=cTITLE_TEMPLATE[0])
+        {
+            *fLog << inf << "Error finding new run header in file (possible EOF)... skipping rest of file." << endl;
+            return kFALSE;
+        }
+
+        *fLog << "-----------------------------------------------------------------------" << endl;
+
+
+        if (ReadRunHeader() < 0)
+        {
+            *fLog << warn << "ReInit of Tasklist didn't succeed." << endl;
+            return kFALSE;
+        }
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// 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.
+//
+Int_t MCT1ReadPreProc::Process()
+{
+    //
+    // Check where in the file we are. If neither a new event, nor a
+    // footer/header combination is detected go to the next file.
+    //
+    if (!CheckFilePosition())
+        if (!OpenNextFile())
+            return kFALSE;
+
+    //
+    // Check for a selector. If one is given and returns kFALSE
+    // skip this event.
+    //
+    if (GetSelector())
+    {
+        //
+        // Make sure selector is processed
+        //
+        if (!GetSelector()->CallProcess())
+        {
+            *fLog << err << dbginf << "Processing Selector failed." << endl;
+            return kFALSE;
+        }
+
+        //
+        // Skip Event
+        //
+        if (!GetSelector()->IsConditionTrue())
+        {
+            fIn->seekg(sizeof(struct eventrecord), ios::cur);
+
+            fNumEvents++;
+            fNumEventsInRun++;
+
+            return kCONTINUE;
+        }
+    }
+
+    // event data to be read from the file
+    struct eventrecord event;
+
+
+
+    // read the eventrecord from the file
+    fIn->read((char*)&event, sizeof(struct eventrecord));
+
+    switch (ProcessEvent(event))
+    {
+    case kFALSE:
+        return kFALSE;
+    case kCONTINUE:
+        return kCONTINUE;
+    }
+
+    fNumEvents++;
+    fNumEventsInRun++;
+
+    return kTRUE;
+}
+
+Int_t MCT1ReadPreProc::PostProcess()
+{
+    *fLog << all;
+    *fLog << "Number events passed the filter: " << fNumFilterEvts << endl;
+    *fLog << "Number of Events read from file: " << fNumEvents << endl;
+    *fLog << "Number of Runs read from file:   " << fNumRuns << endl;
+    *fLog << "Number of events detected first: " << fEntries << endl;
+
+    if (fNumEvents!=fNumFilterEvts)
+    {
+        *fLog << warn << "WARNING! Number of events in file doesn't match number of read events..." << endl;
+        *fLog << "         File might be corrupt." << endl;
+    }
+
+    delete fIn;
+    fIn = NULL;
+
+    return GetSelector() ? GetSelector()->CallPostProcess() : kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1ReadPreProc.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1ReadPreProc.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1ReadPreProc.h	(revision 9661)
@@ -0,0 +1,104 @@
+#ifndef MARS_MCT1ReadPreProc
+#define MARS_MCT1ReadPreProc
+
+#ifndef ROOT_TArrayF
+#include <TArrayF.h>
+#endif
+
+#ifndef ROOT_TArrayI
+#include <TArrayI.h>
+#endif
+
+#ifndef MARS_MRead
+#include "MRead.h"
+#endif
+
+class TList;
+class MTime;
+class MMcEvt;
+class MMcTrig;
+class MGeomCam;
+class MSrcPosCam;
+class MCerPhotEvt;
+class MPedPhotCam;
+class MBadPixelsCam;
+class MRawRunHeader;
+class MTaskList;
+class MParList;
+class MParameterD;
+class MBinning;
+
+struct outputpars;
+struct eventrecord;
+
+class MCT1ReadPreProc : public MRead
+{
+private:
+    ifstream *fIn;          // the inputfile
+    TList    *fFileNames;   // Array which stores the \0-terminated filenames
+
+    MGeomCam      *fGeom;    // camera geometry
+    MCerPhotEvt   *fNphot;   // the data container for all data.
+    MPedPhotCam   *fPedest;  // ct1 pedestals
+    MTime         *fTime;    // event time
+    MMcEvt        *fMcEvt;   // monte carlo data container for MC files
+    MMcTrig       *fMcTrig;  // mc data container for trigger information
+    MSrcPosCam    *fSrcPos;  // source position in the camera
+    MBadPixelsCam *fBlinds;  // Array holding blind pixels
+    MRawRunHeader *fRawRunHeader; // raw run header
+    MParList      *fParList;      // parameter list
+    MParameterD   *fHourAngle;    // hour angle [deg]
+    MParameterD   *fThetaOrig;    // original zenith angle [rad]
+    MBinning      *fBinningT;     // Theta binning for the smearing
+
+    Bool_t fIsMcFile;       // Flag whether current run is a MC run
+
+    UInt_t fNumFile;
+    UInt_t fNumEvents;      // number of events counted in all runs in all files
+    UInt_t fNumEventsInRun; // number of events in the counted in th ecurrent run
+    UInt_t fNumRuns;        // number of processed runs of all files
+    UInt_t fEntries;        // entries of all files succesfully added
+    UInt_t fNumFilterEvts;  // number of events mentioned in the runs footers
+
+    TArrayF fPedRMS;
+    TArrayI fBlnd;
+
+    Bool_t OpenNextFile();
+
+    Int_t  GetNumEvents(const TString name) const;
+    Bool_t CheckHeader(const TString fname) const;
+
+    void   ReadPedestals();
+    Int_t  ReadRunHeader();
+    Int_t  ReadRunFooter();
+    Bool_t CheckFilePosition();
+    void   ProcessRunHeader(const struct outputpars &outpars);
+    Bool_t ProcessEvent(const struct eventrecord &event);
+
+    Double_t SmearTheta(Double_t theta);
+    Double_t DiscreteTheta(Double_t theta);
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
+    Bool_t Rewind();
+
+public:
+    MCT1ReadPreProc(const char *filename=NULL,
+                    const char *name=NULL,
+                    const char *title=NULL);
+
+    ~MCT1ReadPreProc();
+
+    Int_t AddFile(const char *fname, int i=0);
+
+    UInt_t GetEntries() { return fEntries; }
+
+    ClassDef(MCT1ReadPreProc, 0) // Reads the CT1 preproc data file
+};
+
+#endif
+
+
+
Index: /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1Supercuts.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1Supercuts.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1Supercuts.cc	(revision 9661)
@@ -0,0 +1,388 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Wolfgang Wittek, 08/2003 <mailto:wittek@mppmu.mpg.de>
+!   Author(s): Thomas Bretz, 08/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//   MCT1Supercuts                                                         //
+//                                                                         //
+//   this is the container for the parameters of the supercuts             //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MCT1Supercuts.h"
+
+#include <math.h>
+#include <fstream>
+
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MCT1Supercuts);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// constructor
+//
+MCT1Supercuts::MCT1Supercuts(const char *name, const char *title)
+  : fParameters(104), fStepsizes(104),
+    fLengthUp(fParameters.GetArray()),   fLengthLo(fParameters.GetArray()+8),
+    fWidthUp(fParameters.GetArray()+16), fWidthLo(fParameters.GetArray()+24),
+    fDistUp(fParameters.GetArray()+32),  fDistLo(fParameters.GetArray()+40),
+    fAsymUp(fParameters.GetArray()+48),  fAsymLo(fParameters.GetArray()+56),
+    fConcUp(fParameters.GetArray()+64),  fConcLo(fParameters.GetArray()+72),
+    fLeakage1Up(fParameters.GetArray()+80), fLeakage1Lo(fParameters.GetArray()+88),
+    fAlphaUp(fParameters.GetArray()+96)
+{
+    fName  = name  ? name  : "MCT1Supercuts";
+    fTitle = title ? title : "Container for the supercut parameters";
+
+    // set supercut parameters to their default values
+    InitParameters();
+}
+
+
+// --------------------------------------------------------------------------
+//
+// set default values for the supercut parameters
+//
+void MCT1Supercuts::InitParameters()
+{
+    //---------------------------------------------------
+    //  these are Daniel's original values for Mkn 421
+
+    fLengthUp[0] =  0.315585;
+    fLengthUp[1] =  0.001455;
+    fLengthUp[2] =  0.203198;
+    fLengthUp[3] =  0.005532;
+    fLengthUp[4] = -0.001670;
+    fLengthUp[5] = -0.020362;
+    fLengthUp[6] =  0.007388;
+    fLengthUp[7] = -0.013463;
+
+    fLengthLo[0] =  0.151530;
+    fLengthLo[1] =  0.028323;
+    fLengthLo[2] =  0.510707;
+    fLengthLo[3] =  0.053089;
+    fLengthLo[4] =  0.013708;
+    fLengthLo[5] =  2.357993;
+    fLengthLo[6] =  0.000080;
+    fLengthLo[7] = -0.007157;
+
+    fWidthUp[0] =  0.145412;
+    fWidthUp[1] = -0.001771;
+    fWidthUp[2] =  0.054462;
+    fWidthUp[3] =  0.022280;
+    fWidthUp[4] = -0.009893;
+    fWidthUp[5] =  0.056353;
+    fWidthUp[6] =  0.020711;
+    fWidthUp[7] = -0.016703;
+
+    fWidthLo[0] =  0.089187;
+    fWidthLo[1] = -0.006430;
+    fWidthLo[2] =  0.074442;
+    fWidthLo[3] =  0.003738;
+    fWidthLo[4] = -0.004256;
+    fWidthLo[5] = -0.014101;
+    fWidthLo[6] =  0.006126;
+    fWidthLo[7] = -0.002849;
+
+    fDistUp[0] =  1.787943;
+    fDistUp[1] =  0;
+    fDistUp[2] =  2.942310;
+    fDistUp[3] =  0.199815;
+    fDistUp[4] =  0;
+    fDistUp[5] =  0.249909;
+    fDistUp[6] =  0.189697;
+    fDistUp[7] =  0;
+
+    fDistLo[0] =  0.589406;
+    fDistLo[1] =  0;
+    fDistLo[2] = -0.083964;
+    fDistLo[3] = -0.007975;
+    fDistLo[4] =  0;
+    fDistLo[5] =  0.045374;
+    fDistLo[6] = -0.001750;
+    fDistLo[7] =  0;
+    
+
+    // dummy values
+
+    fAsymUp[0] =  1.e10;
+    fAsymUp[1] =  0.0;
+    fAsymUp[2] =  0.0;
+    fAsymUp[3] =  0.0;
+    fAsymUp[4] =  0.0;
+    fAsymUp[5] =  0.0;
+    fAsymUp[6] =  0.0;
+    fAsymUp[7] =  0.0;
+
+    fAsymLo[0] = -1.e10;
+    fAsymLo[1] =  0.0;
+    fAsymLo[2] =  0.0;
+    fAsymLo[3] =  0.0;
+    fAsymLo[4] =  0.0;
+    fAsymLo[5] =  0.0;
+    fAsymLo[6] =  0.0;
+    fAsymLo[7] =  0.0;
+
+    fConcUp[0] =  1.e10;
+    fConcUp[1] =  0.0;
+    fConcUp[2] =  0.0;
+    fConcUp[3] =  0.0;
+    fConcUp[4] =  0.0;
+    fConcUp[5] =  0.0;
+    fConcUp[6] =  0.0;
+    fConcUp[7] =  0.0;
+
+    fConcLo[0] = -1.e10;
+    fConcLo[1] =  0.0;
+    fConcLo[2] =  0.0;
+    fConcLo[3] =  0.0;
+    fConcLo[4] =  0.0;
+    fConcLo[5] =  0.0;
+    fConcLo[6] =  0.0;
+    fConcLo[7] =  0.0;
+
+    fLeakage1Up[0] =  1.e10;
+    fLeakage1Up[1] =  0.0;
+    fLeakage1Up[2] =  0.0;
+    fLeakage1Up[3] =  0.0;
+    fLeakage1Up[4] =  0.0;
+    fLeakage1Up[5] =  0.0;
+    fLeakage1Up[6] =  0.0;
+    fLeakage1Up[7] =  0.0;
+
+    fLeakage1Lo[0] = -1.e10;
+    fLeakage1Lo[1] =  0.0;
+    fLeakage1Lo[2] =  0.0;
+    fLeakage1Lo[3] =  0.0;
+    fLeakage1Lo[4] =  0.0;
+    fLeakage1Lo[5] =  0.0;
+    fLeakage1Lo[6] =  0.0;
+    fLeakage1Lo[7] =  0.0;
+
+    fAlphaUp[0] = 13.123440; 
+    fAlphaUp[1] = 0;
+    fAlphaUp[2] = 0;
+    fAlphaUp[3] = 0;
+    fAlphaUp[4] = 0;
+    fAlphaUp[5] = 0;
+    fAlphaUp[6] = 0;
+    fAlphaUp[7] = 0;
+
+    //---------------------------------------------------
+    // fStepsizes 
+    // if == 0.0    the parameter will be fixed in the minimization
+    //    != 0.0    initial step sizes for the parameters
+
+    // LengthUp
+    fStepsizes[0] = 0.03;
+    fStepsizes[1] = 0.0002;
+    fStepsizes[2] = 0.02;
+    fStepsizes[3] = 0.0006;
+    fStepsizes[4] = 0.0002;
+    fStepsizes[5] = 0.002;
+    fStepsizes[6] = 0.0008;
+    fStepsizes[7] = 0.002;
+
+    // LengthLo
+    fStepsizes[8]  = 0.02;
+    fStepsizes[9]  = 0.003;
+    fStepsizes[10] = 0.05;
+    fStepsizes[11] = 0.006;
+    fStepsizes[12] = 0.002;
+    fStepsizes[13] = 0.3;
+    fStepsizes[14] = 0.0001;
+    fStepsizes[15] = 0.0008;
+
+    // WidthUp
+    fStepsizes[16] = 0.02;
+    fStepsizes[17] = 0.0002;
+    fStepsizes[18] = 0.006;
+    fStepsizes[19] = 0.003;
+    fStepsizes[20] = 0.002;
+    fStepsizes[21] = 0.006;
+    fStepsizes[22] = 0.002;
+    fStepsizes[23] = 0.002;
+
+    // WidthLo
+    fStepsizes[24] = 0.009;
+    fStepsizes[25] = 0.0007;
+    fStepsizes[26] = 0.008;
+    fStepsizes[27] = 0.0004;
+    fStepsizes[28] = 0.0005;
+    fStepsizes[29] = 0.002;
+    fStepsizes[30] = 0.0007;
+    fStepsizes[31] = 0.003;
+
+    // DistUp
+    fStepsizes[32] = 0.2;
+    fStepsizes[33] = 0.0;
+    fStepsizes[34] = 0.3;
+    fStepsizes[35] = 0.02;
+    fStepsizes[36] = 0.0;
+    fStepsizes[37] = 0.03;
+    fStepsizes[38] = 0.02;
+    fStepsizes[39] = 0.0;
+
+    // DistLo
+    fStepsizes[40] = 0.06;
+    fStepsizes[41] = 0.0;
+    fStepsizes[42] = 0.009;
+    fStepsizes[43] = 0.0008;
+    fStepsizes[44] = 0.0;
+    fStepsizes[45] = 0.005;
+    fStepsizes[46] = 0.0002;
+    fStepsizes[47] = 0.0;
+
+    // AsymUp
+    fStepsizes[48] = 0.0;
+    fStepsizes[49] = 0.0;
+    fStepsizes[50] = 0.0;
+    fStepsizes[51] = 0.0;
+    fStepsizes[52] = 0.0;
+    fStepsizes[53] = 0.0;
+    fStepsizes[54] = 0.0;
+    fStepsizes[55] = 0.0;
+
+    // AsymLo
+    fStepsizes[56] = 0.0;
+    fStepsizes[57] = 0.0;
+    fStepsizes[58] = 0.0;
+    fStepsizes[59] = 0.0;
+    fStepsizes[60] = 0.0;
+    fStepsizes[61] = 0.0;
+    fStepsizes[62] = 0.0;
+    fStepsizes[63] = 0.0;
+
+    // ConcUp
+    fStepsizes[64] = 0.0;
+    fStepsizes[65] = 0.0;
+    fStepsizes[66] = 0.0;
+    fStepsizes[67] = 0.0;
+    fStepsizes[68] = 0.0;
+    fStepsizes[69] = 0.0;
+    fStepsizes[70] = 0.0;
+    fStepsizes[71] = 0.0;
+
+    // ConcLo
+    fStepsizes[72] = 0.0;
+    fStepsizes[73] = 0.0;
+    fStepsizes[74] = 0.0;
+    fStepsizes[75] = 0.0;
+    fStepsizes[76] = 0.0;
+    fStepsizes[77] = 0.0;
+    fStepsizes[78] = 0.0;
+    fStepsizes[79] = 0.0;
+
+    // Leakage1Up
+    fStepsizes[80] = 0.0;
+    fStepsizes[81] = 0.0;
+    fStepsizes[82] = 0.0;
+    fStepsizes[83] = 0.0;
+    fStepsizes[84] = 0.0;
+    fStepsizes[85] = 0.0;
+    fStepsizes[86] = 0.0;
+    fStepsizes[87] = 0.0;
+
+    // Leakage1Lo
+    fStepsizes[88] = 0.0;
+    fStepsizes[89] = 0.0;
+    fStepsizes[90] = 0.0;
+    fStepsizes[91] = 0.0;
+    fStepsizes[92] = 0.0;
+    fStepsizes[93] = 0.0;
+    fStepsizes[94] = 0.0;
+    fStepsizes[95] = 0.0;
+
+    // AlphaUp
+    fStepsizes[96]  = 0.0;
+    fStepsizes[97]  = 0.0;
+    fStepsizes[98]  = 0.0;
+    fStepsizes[99]  = 0.0;
+    fStepsizes[100] = 0.0;
+    fStepsizes[101] = 0.0;
+    fStepsizes[102] = 0.0;
+    fStepsizes[103] = 0.0;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Set the parameter values from the array 'd'
+//
+//
+Bool_t MCT1Supercuts::SetParameters(const TArrayD &d)
+{
+    if (d.GetSize() != fParameters.GetSize())
+    {
+        *fLog << err << "Sizes of d and of fParameters are different : "
+              << d.GetSize() << ",  " << fParameters.GetSize() << endl;
+        return kFALSE;
+    }
+
+    fParameters = d;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the step sizes from the array 'd'
+//
+//
+Bool_t MCT1Supercuts::SetStepsizes(const TArrayD &d)
+{
+    if (d.GetSize() != fStepsizes.GetSize())
+    {
+        *fLog << err << "Sizes of d and of fStepsizes are different : "
+              << d.GetSize() << ",  " << fStepsizes.GetSize() << endl;
+        return kFALSE;
+    }
+
+    fStepsizes = d;
+
+    return kTRUE;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1Supercuts.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1Supercuts.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1Supercuts.h	(revision 9661)
@@ -0,0 +1,69 @@
+#ifndef MARS_MCT1Supercuts
+#define MARS_MCT1Supercuts
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#ifndef ROOT_TArrayD
+#include <TArrayD.h>
+#endif
+
+class MCT1Supercuts : public MParContainer
+{
+private:
+    TArrayD fParameters; // supercut parameters
+    TArrayD fStepsizes;  // step sizes of supercut parameters
+
+    Double_t *fLengthUp; //!
+    Double_t *fLengthLo; //!
+    Double_t *fWidthUp;  //!
+    Double_t *fWidthLo;  //!
+    Double_t *fDistUp;   //!
+    Double_t *fDistLo;   //!
+    Double_t *fAsymUp;   //!
+    Double_t *fAsymLo;   //!
+
+    Double_t *fConcUp;   //!
+    Double_t *fConcLo;   //!
+    Double_t *fLeakage1Up;   //!
+    Double_t *fLeakage1Lo;   //!
+
+    Double_t *fAlphaUp;  //!
+
+
+public:
+    MCT1Supercuts(const char *name=NULL, const char *title=NULL);
+
+    void InitParameters();
+
+    Bool_t SetParameters(const TArrayD &d);
+    Bool_t SetStepsizes(const TArrayD &d);
+
+    const TArrayD &GetParameters() const { return fParameters; }
+    const TArrayD &GetStepsizes()  const { return fStepsizes;  }
+
+    const Double_t *GetLengthUp() const { return fLengthUp; }
+    const Double_t *GetLengthLo() const { return fLengthLo; }
+    const Double_t *GetWidthUp() const  { return fWidthUp; }
+    const Double_t *GetWidthLo() const  { return fWidthLo; }
+    const Double_t *GetDistUp() const   { return fDistUp; }
+    const Double_t *GetDistLo() const   { return fDistLo; }
+    const Double_t *GetAsymUp() const   { return fAsymUp; }
+    const Double_t *GetAsymLo() const   { return fAsymLo; }
+
+    const Double_t *GetConcUp() const   { return fConcUp; }
+    const Double_t *GetConcLo() const   { return fConcLo; }
+
+    const Double_t *GetLeakage1Up() const   { return fLeakage1Up; }
+    const Double_t *GetLeakage1Lo() const   { return fLeakage1Lo; }
+
+    const Double_t *GetAlphaUp() const  { return fAlphaUp; }
+
+    ClassDef(MCT1Supercuts, 1) // A container for the Supercut parameters
+};
+
+#endif
+
+
+
Index: /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1SupercutsCalc.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1SupercutsCalc.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1SupercutsCalc.cc	(revision 9661)
@@ -0,0 +1,348 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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, 04/2003 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//   MCT1SupercutsCalc                                                     //
+//                                                                         //
+//   this class calculates the hadronness for the supercuts                //
+//   the parameters of the supercuts are taken                             //
+//                  from the container MCT1Supercuts                       //
+//                                                                         //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MCT1SupercutsCalc.h"
+
+#include <math.h>
+#include <fstream>
+
+#include "TFile.h"
+#include "TArrayD.h"
+
+#include "MParList.h"
+#include "MHillasExt.h"
+#include "MHillasSrc.h"
+#include "MNewImagePar.h"
+#include "MMcEvt.hxx"
+#include "MCerPhotEvt.h"
+#include "MGeomCam.h"
+#include "MHadronness.h"
+#include "MHMatrix.h"
+#include "MCT1Supercuts.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MCT1SupercutsCalc);
+
+using namespace std;
+
+
+// --------------------------------------------------------------------------
+//
+// constructor
+//
+
+MCT1SupercutsCalc::MCT1SupercutsCalc(const char *hilname, 
+                                     const char *hilsrcname, 
+                                     const char *name, const char *title)
+  : fHadronnessName("MHadronness"), fHilName(hilname), fHilSrcName(hilsrcname),
+    fHilExtName("MHillasExt"), fNewParName("MNewImagePar"), 
+    fSuperName("MCT1Supercuts") 
+{
+    fName  = name  ? name  : "MCT1SupercutsCalc";
+    fTitle = title ? title : "Class to evaluate the Supercuts";
+
+    fMatrix = NULL;
+}
+
+// --------------------------------------------------------------------------
+//
+Int_t MCT1SupercutsCalc::PreProcess(MParList *pList)
+{
+    MGeomCam *cam = (MGeomCam*)pList->FindObject("MGeomCam");
+    if (!cam)
+    {
+        *fLog << err << "MGeomCam (Camera Geometry) not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fMm2Deg = cam->GetConvMm2Deg();
+
+    fHadronness = (MHadronness*)pList->FindCreateObj("MHadronness", fHadronnessName);
+    if (!fHadronness)
+    {
+        *fLog << err << fHadronnessName << " [MHadronness] not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fSuper = (MCT1Supercuts*)pList->FindObject(fSuperName, "MCT1Supercuts");
+    if (!fSuper)
+    {
+        *fLog << err << fSuperName << " [MCT1Supercuts] not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    if (fMatrix)
+        return kTRUE;
+
+    //-----------------------------------------------------------
+    fHil = (MHillas*)pList->FindObject(fHilName, "MHillas");
+    if (!fHil)
+    {
+        *fLog << err << fHilName << " [MHillas] not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fHilExt = (MHillasExt*)pList->FindObject(fHilExtName, "MHillasExt");
+    if (!fHilExt)
+    {
+        *fLog << err << fHilExtName << " [MHillasExt] not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fHilSrc = (MHillasSrc*)pList->FindObject(fHilSrcName, "MHillasSrc");
+    if (!fHilSrc)
+    {
+        *fLog << err << fHilSrcName << " [MHillasSrc] not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fNewPar = (MNewImagePar*)pList->FindObject(fNewParName, "MNewImagePar");
+    if (!fNewPar)
+    {
+        *fLog << err << fNewParName << " [MNewImagePar] not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
+    if (!fMcEvt)
+    {
+        *fLog << err << "MMcEvt not found... aborting." << endl;
+        return kFALSE;
+    }
+
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculation of upper and lower limits
+//
+Double_t MCT1SupercutsCalc::CtsMCut(const Double_t* a,  Double_t ls, Double_t ct,
+                                    Double_t ls2, Double_t dd2) const
+{
+    // define cut-function
+    //
+    //    dNOMLOGSIZE = 4.1 (=log(60.0)
+    //    dNOMCOSZA   = 1.0
+    //
+    //      a: array of cut parameters
+    //     ls: log(SIZE) - dNOMLOGSIZE
+    //    ls2: ls^2
+    //     ct: Cos(ZA.) - dNOMCOSZA
+    //    dd2: DIST^2
+    const Double_t limit =
+        a[0] + a[1] * dd2 + a[2] * ct  +
+        ls  * (a[3] + a[4] * dd2 + a[5] * ct) +
+        ls2 * (a[6] + a[7] * dd2);
+
+    //*fLog << "MCT1SupercutsCalc::CtsMCut; *a = "
+    //      << *a     << ",  " << *(a+1) << ",  " << *(a+2) << ",  "
+    //      << *(a+3) << ",  " << *(a+4) << ",  " << *(a+5) << ",  "
+    //      << *(a+6) << ",  " << *(a+7) << endl;
+
+    //*fLog << "MCT1SupercutsCalc::CtsMCut; ls, ls2, ct, dd2, limit = " << ls
+    //      << ",  " << ls2 << ",  " << ct << ",  " << dd2 << ",  "
+    //      << limit << endl;
+
+    return limit;
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the mapped value from the Matrix
+//
+Double_t MCT1SupercutsCalc::GetVal(Int_t i) const
+{
+
+    Double_t val = (*fMatrix)[fMap[i]];
+
+
+    //*fLog << "MCT1SupercutsCalc::GetVal; i, fMatrix, fMap, val = "
+    //    << i << ",  " << fMatrix << ",  " << fMap[i] << ",  " << val << endl;
+
+
+    return val;
+}
+
+// --------------------------------------------------------------------------
+//
+// You can use this function if you want to use a MHMatrix instead of the
+// given containers. This function adds all necessary columns to the
+// given matrix. Afterward you should fill the matrix with the corresponding
+// data (eg from a file by using MHMatrix::Fill). If you now loop
+// through the matrix (eg using MMatrixLoop) MEnergyEstParam::Process
+// will take the values from the matrix instead of the containers.
+//
+void MCT1SupercutsCalc::InitMapping(MHMatrix *mat)
+{
+    if (fMatrix)
+      return;
+
+    fMatrix = mat;
+
+    fMap[0] = fMatrix->AddColumn("MMcEvt.fTelescopeTheta");
+    fMap[1] = fMatrix->AddColumn("MHillas.fWidth");
+    fMap[2] = fMatrix->AddColumn("MHillas.fLength");
+    fMap[3] = fMatrix->AddColumn("MHillas.fSize");
+    fMap[4] = fMatrix->AddColumn("MHillas.fMeanX");
+    fMap[5] = fMatrix->AddColumn("MHillas.fMeanY");
+    fMap[6] = fMatrix->AddColumn("MHillasSrc.fDist");
+    fMap[7] = fMatrix->AddColumn("fabs(MHillasSrc.fAlpha)");
+    fMap[8] = fMatrix->AddColumn("sgn(MHillasSrc.fCosDeltaAlpha)*(MHillasExt.fM3Long)");
+    fMap[9] = fMatrix->AddColumn("MNewImagePar.fConc");
+    fMap[10]= fMatrix->AddColumn("MNewImagePar.fLeakage1");
+}
+
+// ---------------------------------------------------------------------------
+//
+// Evaluate dynamical supercuts 
+// 
+//          set hadronness to 0.25 if cuts are fullfilled
+//                            0.75 otherwise
+//
+Int_t MCT1SupercutsCalc::Process()
+{
+    const Double_t kNomLogSize = 4.1;
+    const Double_t kNomCosZA   = 1.0;
+
+    const Double_t theta   = fMatrix ? GetVal(0) : fMcEvt->GetTelescopeTheta();
+    const Double_t width0  = fMatrix ? GetVal(1) : fHil->GetWidth();
+    const Double_t length0 = fMatrix ? GetVal(2) : fHil->GetLength();
+    const Double_t size    = fMatrix ? GetVal(3) : fHil->GetSize();
+    const Double_t meanx   = fMatrix ? GetVal(4) : fHil->GetMeanX();
+    const Double_t meany   = fMatrix ? GetVal(5) : fHil->GetMeanY();
+    const Double_t dist0   = fMatrix ? GetVal(6) : fHilSrc->GetDist();
+
+    Double_t help;
+    if (!fMatrix)
+      help = TMath::Sign(fHilExt->GetM3Long(), 
+	      		 fHilSrc->GetCosDeltaAlpha());
+    const Double_t asym0   = fMatrix ? GetVal(8) : help;
+    const Double_t conc    = fMatrix ? GetVal(9) : fNewPar->GetConc();
+    const Double_t leakage = fMatrix ? GetVal(10): fNewPar->GetLeakage1();
+
+    const Double_t newdist = dist0 * fMm2Deg;
+
+    const Double_t dist2   = meanx*meanx + meany*meany;
+    const Double_t dist    = sqrt(dist2) * fMm2Deg;
+    const Double_t dd2     = dist*dist;
+
+
+    const Double_t dmls    = log(size) - kNomLogSize;
+    const Double_t dmls2   = dmls * dmls;
+
+    const Double_t dmcza   = cos(theta) - kNomCosZA;
+
+    const Double_t length  = length0 * fMm2Deg;
+    const Double_t width   = width0  * fMm2Deg;
+    const Double_t asym    = asym0   * fMm2Deg;
+
+    /*
+    *fLog << "newdist, length, width, asym, dist, conc, leakage = " 
+          << newdist << ",  " << length << ",  " << width << ",  "
+          << asym    << ",  " << dist   << ",  " << conc  << ",  " << leakage
+          << endl;
+  
+    *fLog << "upper cuts in newdist, length, width, asym, dist, conc, leakage = " 
+          << CtsMCut (fSuper->GetDistUp(),   dmls, dmcza, dmls2, dd2) << ",  "
+          << CtsMCut (fSuper->GetDistLo(),   dmls, dmcza, dmls2, dd2) << ",  "
+
+          << CtsMCut (fSuper->GetLengthUp(),   dmls, dmcza, dmls2, dd2) << ",  "
+          << CtsMCut (fSuper->GetLengthLo(),   dmls, dmcza, dmls2, dd2) << ",  "
+
+          << CtsMCut (fSuper->GetWidthUp(),   dmls, dmcza, dmls2, dd2) << ",  "
+          << CtsMCut (fSuper->GetWidthLo(),   dmls, dmcza, dmls2, dd2) << ",  "
+
+          << CtsMCut (fSuper->GetAsymUp(),   dmls, dmcza, dmls2, dd2) << ",  "
+          << CtsMCut (fSuper->GetAsymLo(),   dmls, dmcza, dmls2, dd2) << ",  "
+
+          << CtsMCut (fSuper->GetDistUp(),   dmls, dmcza, dmls2, dd2) << ",  "
+          << CtsMCut (fSuper->GetDistLo(),   dmls, dmcza, dmls2, dd2) << ",  "
+
+          << CtsMCut (fSuper->GetConcUp(),   dmls, dmcza, dmls2, dd2) << ",  "
+          << CtsMCut (fSuper->GetConcLo(),   dmls, dmcza, dmls2, dd2) << ",  "
+
+          << CtsMCut (fSuper->GetLeakage1Up(),   dmls, dmcza, dmls2, dd2) << ",  "
+          << CtsMCut (fSuper->GetLeakage1Lo(),   dmls, dmcza, dmls2, dd2) << ",  "
+          << endl;
+    */
+
+
+    if (
+        //dist    < 1.05                                                     &&
+        //newdist < 1.05                                                     &&
+
+        newdist < CtsMCut (fSuper->GetDistUp(),   dmls, dmcza, dmls2, dd2) &&
+        newdist > CtsMCut (fSuper->GetDistLo(),   dmls, dmcza, dmls2, dd2) &&
+
+        length  < CtsMCut (fSuper->GetLengthUp(), dmls, dmcza, dmls2, dd2) &&
+        length  > CtsMCut (fSuper->GetLengthLo(), dmls, dmcza, dmls2, dd2) &&
+
+        width   < CtsMCut (fSuper->GetWidthUp(),  dmls, dmcza, dmls2, dd2) &&
+        width   > CtsMCut (fSuper->GetWidthLo(),  dmls, dmcza, dmls2, dd2) &&
+
+        asym    < CtsMCut (fSuper->GetAsymUp(),   dmls, dmcza, dmls2, dd2) &&
+        asym    > CtsMCut (fSuper->GetAsymLo(),   dmls, dmcza, dmls2, dd2) &&
+
+        dist    < CtsMCut (fSuper->GetDistUp(),   dmls, dmcza, dmls2, dd2) &&
+        dist    > CtsMCut (fSuper->GetDistLo(),   dmls, dmcza, dmls2, dd2) &&
+
+        conc    < CtsMCut (fSuper->GetConcUp(),   dmls, dmcza, dmls2, dd2) &&
+        conc    > CtsMCut (fSuper->GetConcLo(),   dmls, dmcza, dmls2, dd2) &&
+
+        leakage < CtsMCut (fSuper->GetLeakage1Up(),dmls, dmcza, dmls2, dd2) &&
+        leakage > CtsMCut (fSuper->GetLeakage1Lo(),dmls, dmcza, dmls2, dd2)  ) 
+
+      fHadronness->SetHadronness(0.25);
+    else
+      fHadronness->SetHadronness(0.75);
+
+    //*fLog << "SChadroness = " << fHadronness->GetHadronness() << endl;
+
+    fHadronness->SetReadyToSave();
+
+    return kTRUE;
+}
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1SupercutsCalc.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1SupercutsCalc.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysisct1/MCT1SupercutsCalc.h	(revision 9661)
@@ -0,0 +1,82 @@
+#ifndef MARS_MCT1SupercutsCalc
+#define MARS_MCT1SupercutsCalc
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+#ifndef ROOT_TArrayD
+#include <TArrayD.h>
+#endif
+
+class MParList;
+class MHillas;
+class MHillasSrc;
+class MHillasExt;
+class MNewImagePar;
+class MMcEvt;
+class MCerPhotEvt;
+class MGeomCam;
+class MHadronness;
+class MHMatrix;
+class MCT1Supercuts;
+
+class MCT1SupercutsCalc : public MTask
+{
+private:
+    MHillas       *fHil;
+    MHillasSrc    *fHilSrc;
+    MHillasExt    *fHilExt;
+    MNewImagePar  *fNewPar;
+    MMcEvt        *fMcEvt;
+    MHadronness   *fHadronness; //! output container for hadronness
+    MCT1Supercuts *fSuper;      // container for supercut parameters
+
+    TString  fHadronnessName;   // name of container to store hadronness
+    TString  fHilName;
+    TString  fHilSrcName;
+    TString  fHilExtName;
+    TString  fNewParName;
+    TString  fSuperName;        // name of container for supercut parameters
+
+    Double_t fMm2Deg;           //!
+
+    Int_t     fMap[11];         //!
+    MHMatrix *fMatrix;          //!
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
+    Double_t GetVal(Int_t i) const;
+
+    Double_t CtsMCut(const Double_t* a, Double_t ls, Double_t ct,
+                     Double_t ls2, Double_t dd2) const;
+
+public:
+    MCT1SupercutsCalc(const char *hilname="MHillas",
+                      const char *hilsrcname="MHillasSrc",
+                      const char *name=NULL, const char *title=NULL);
+
+    void SetHadronnessName(const TString name) { fHadronnessName = name; }
+    TString GetHadronnessName() const { return fHadronnessName; }
+
+    void InitMapping(MHMatrix *mat);
+    void StopMapping() { InitMapping(NULL); }
+
+
+    ClassDef(MCT1SupercutsCalc, 0) // A class to evaluate the Supercuts
+};
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/manalysisct1/Makefile
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysisct1/Makefile	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysisct1/Makefile	(revision 9661)
@@ -0,0 +1,45 @@
+##################################################################
+#
+#   subdirectory makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#------------------------------------------------------------------------------
+
+#
+# Handling name of the Root Dictionary Files
+#
+CINT  = AnalysisCT1
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES = -I. -I../mbase -I../mhbase -I../mdata -I../mfbase -I../mgeom     \
+           -I../mfileio -I../mfilter -I../manalysis -I../mpedestal -I../mmc \
+           -I../mhist -I../mpointing -I../mimage -I../mgui -I../mbadpixels  \
+           -I../mraw
+
+SRCFILES = MCT1FindSupercuts.cc \
+           MCT1PointingCorrCalc.cc \
+           MCT1Supercuts.cc \
+           MCT1SupercutsCalc.cc \
+           MCT1ReadPreProc.cc \
+           MCT1ReadAscii.cc
+
+# Doesn't compile: Please replace MBlindPixels by MBadPixel*
+#           MCT1PadONOFF.cc \
+#           MCT1PadSchweizer.cc \
+
+############################################################
+
+all:  $(OBJS)
+
+include ../Makefile.rules
+
+clean:	rmcint rmobjs rmcore rmlib
+
+mrproper:	clean rmbak
Index: /tags/Mars_V0-8-5/Mars/manalysisct1/structures.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/manalysisct1/structures.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/manalysisct1/structures.h	(revision 9661)
@@ -0,0 +1,882 @@
+/******************************************************************/
+/*              GGG   AAA   M   M M   M  AAA   SSS                */
+/*             G   G A   A  MM MM MM MM A   A S   S               */
+/*             G     A   A  M M M M M M A   A  SS                 */
+/*             G  GG AAAAA  M   M M   M AAAAA   SS                */
+/*             G   G A   A  M   M M   M A   A S   S               */
+/*              GGG  A   A  M   M M   M A   A  SSS                */
+/*       Gamma Astronomer's Munich Madrid Analysis Suite          */
+/*   An Atmospheric Cherenkov Telescope Data Analysis Software    */
+/*  MPI f"ur Physik, M"unchen & Universidad Complutense, Madrid   */
+/******************************************************************/
+
+/******************************************************************/
+/* This File belongs to the programs                              */
+/*                                                                */
+/*  P R E P R O C E S S O R   and   I M A G E R                   */
+/*                                                                */
+/* Purpose: provide the structure definitions common to both      */
+/*          programs, especially the output structures of the     */
+/*          preprocessor                                          */ 
+/*                                                                */
+/******************************************************************/
+
+/******************************************************************/
+/* @(#) File name structures.h
+   @(#) latest SID 0.5  
+   @(#) Date of latest delta 26/6/00  
+   Author: D. Petry 
+   changed by M. Kestel */
+/******************************************************************/
+
+#ifndef _structures_h_
+#define _structures_h_ "__structures_h__"
+
+#define STRUCT_VERSION 0.6
+
+#define iHEADERTITLELENGTH 60
+/* length of the string written at the beginning of the */
+/* output for each runfile */
+#define cTITLE_TEMPLATE "PREPROC V%f/S%f CT %d RUN %d %d PROCMJD %d\n"
+
+#define cEND_EVENTS_TEMPLATE "EVENTS AFTER FILTER = %d\n"
+
+#define iMAXNUMPIX 127
+/* maximum value for the number of camera pixels (excl. muon shield) */
+#define iMAXNUMMUONPIX 5 
+/* maximum value for the number of pixels in the muon shield */
+#define iMAXNUMCOINTDCS 5
+/* maximum value for the number of coincidence tdcs */
+
+
+#define iBADMACTIME_BIT 1
+/* snot_ok_flags is ORed with this number to set the bit which 
+ * indicates that the mactime measurement didn't work */
+#define iBADRUBTIME_BIT 2 
+/* snot_ok_flags is ORed with this number to set the bit which 
+ * indicates that the Rubidium time measurement didn't work */
+#define iBADPOINTING_BIT 4 
+/* snot_ok_flags is ORed with this number to set the bit which 
+ * indicates that the shaft encoder values were inconsistent with 
+ * time OR source coordinates */
+#define iMUON_BIT 8
+ /* snot_ok_flags is ORed with this number to set the bit which 
+  * indicates that the event didn't pass the muon filter 
+  * (for test puposes) */
+
+#define i2OUTFAIL_BIT 16 
+/* snot_ok_flags is ORed with this number to set the bit which 
+ * indicates that the event didn't pass the "two out of all" 
+ * software trigger */
+#define iSUMFAIL_BIT 32 
+/* snot_ok_flags is ORed with this number to set the bit which
+ * indicates that the event didn't pass the "sum of all
+ * photoelectrons" filter */
+
+#define iPARTICLETYPE_FACTOR 1024 
+/* for MC data: the particle type multiplied with this number 
+ * is ORed with snot_ok_flags */
+
+enum onoroff {NEITHER_ON_NOR_OFF, OFF_SOURCE, ON_SOURCE};
+enum trackmodes {NORMAL, REVERSE, DUNNO};
+enum axes {RA, DEC, ALT, AZ};
+enum eERRORTOLERANCE {CAUTIOUS=0, GOODPHYSICS, TANK};
+enum eMCTRIGGERFLAG {ALL=0, FLAG, NOFLAG};
+ 
+struct outputpars {
+  /* preprocessing parameters that are passed to imager.
+   * Note: Not all parameters from the parameter file are passed to
+   * imager, only those that are repeated in this struct outputpars 
+   * here !! That's why these two structs must be the same for both
+   * preproc and imager. */
+
+  int     itelescope;
+  /* number of the CT which took the data (from parameters file */
+  /* crosschecked with run file name) */
+  float   flongitude_deg;
+  /* longitude (counted positive towards West) of CT position */
+  float   flatitude_deg;
+  /* latitude (counted positive towards North) of CT position */
+  int     irunnum;
+  /* run number (from parameters file cross checked with run */
+  /* file name) */
+  enum onoroff eruntype;
+#ifdef LINUX
+  int dummy;
+#endif
+  /* indicates if the */
+  /* run is on- or off source (from runfile cross checked with */
+  /* file name) */
+  double  dsourcera_hours;
+  /* right ascension of observed source in hours */
+  double  dsourcedec_deg; 
+  /* declination of observed source in degrees */
+  int     inumpixels; 
+  /* number of pixels in the camera (from parameters file cross */
+  /* checked with run file, calibration file and pedestal file) */
+  int     inummuonpixels;
+  /* number of pixels in the muon shield (from parameters file */
+  /* cross checked with run file, calibration file and pedestal */
+  /* file) */
+  int     inumcointdcs;
+  /* number of coincidence tdcs recorded in the runfile (from */
+  /* parameters file cross checked */
+  /* with run file) */
+  float   fpixdiameter_deg;
+  /* smallest pixel diameter (degrees) (from parameters file) */ 
+  enum axes ese1_is;
+  /* name of the axis to which shaft encoder 1 is attached */
+  /* (implies the type of mount) */
+  int     isezeropos[2];
+  /* zero position of shaftencoders 1 and 2 (from parameters file) */
+  int     iaz_rev_track_corr;
+  /* correction for the azimuth shaft encoder (ALT/AZ mount */
+  /* only) in reverse tracking mode */
+  int     ialt_rev_track_corr;
+  /* correction for the altitude shaft encoder (ALT/AZ mount */
+  /* only) in reverse tracking mode */
+  float   fbendingcorr;
+  /* bending correction factor (ALT/AZ mount only) */
+  float   fextinction;
+  /* atmospheric extinction (typically taken from the Carlsberg */
+  /* Meridian Circle data) */
+  Boolean bdontusepix[iMAXNUMPIX];
+  /* bdontusepix is set true if the pixel should due to whatever
+   * reason not be used in image analysis, otherwise it is true; 
+   * 
+   * bdontusepix is set by the user inside preproc.par and is 
+   * untouched by preproc (version >= 0.4). */
+  Boolean bexcludepix[iMAXNUMPIX];
+  /* bexcludepix[] is set TRUE (== exclude from pedestal, Laser 
+   * calibration and the further analysis) when the Mean value
+   * of a pixel inside a pedestal Run is larger than 50 or ( || )
+   * if the pedestal RMS value of this pixel is larger than 5.0
+   * This is reflected in the (new for versions >= 0.4) 
+   * variable "pixonoff" in the ntuple written by preproc:
+   * preproc.nt.hbook
+   *
+   * When the pixel is excluded by the user it will get a -2 otherwise 
+   * pixonoff = 0.
+   * Additive to this a -1 is added when preproc excludes the pixel
+   * for a given Run. So the actual value tells you whether you caught 
+   * it already by hand or not.
+   *
+   * A plot of pixonoff may also be handy to tell you the status of your
+   * ADC equipment. */
+  float   fphotoel_per_adccnt[iMAXNUMPIX];
+  /* conversion factors for the pixel signals */
+  int     irubminusutc_usecs;
+  /* difference between rubidium clock and UTC in microseconds */
+  int     isum_thresh_phot;
+  /* threshold for the total sum of photoelectrons filter */
+  /* from the parameters file */
+  int     i2out_thresh_phot;
+  /* threshold for the two-pixels-out-of-all software */
+  /* trigger from parameters file */
+  int     imuoncut_thresh_adccnt[iMAXNUMMUONPIX]; 
+  /* thresholds for the muon cut */
+  Boolean bmuon_suppression;
+  /* "Dolby" noise reduction flag */
+  float   ftolerated_pointerror_deg;
+  /* maximum tolerated pointing error in the position 
+   * check in iprocessdata */
+  float   fxpointcorr_deg;
+  /* pointing correction (to be added along the camera
+   * x axis) e.g. from point run */ 
+  float   fypointcorr_deg;  
+  /* pointing correction (to be added along the camera 
+   * y axis) e.g. from point run */ 
+  float   fcamera_align_angle_deg;
+  /* the angle between the camera y-axis and the meridian 
+   * when a culminating object is observed (defined 
+   * counter-clockwise looking at the sky) */ 
+  int     iratecalc_numevents_odd;
+  /* number of events used in the rate calculation (must be odd) */
+  int     inumpedfile;
+  /* number of the pedestal file used */
+  int     inumpedrun;
+  /* number of the pedestal run used in the file (starting at 0) */
+  int     inumcalfile;
+  /* number of the calibration file used */
+  int     inumlaserrun;
+  /* number of the laserrun used in the file (starting at 0) */ 
+  int     inumtellogfile;
+  /* number of the TelLog file to be used */
+  int     inumtellogrun;
+  /* number of the tellog entry (Runnumber) used from the log file */
+  int imcparticle; /* CORSIKA-coded Monte Carlo particle type.
+		    * This is given once per run. */
+
+  /* preprocessing results: */
+
+  int     istart_mjdate_day;
+  /* MJD of run start (first event) */
+  int     iend_mjdate_day;
+  /* MJD of run end (last event) */
+  int     irunduration_secs;
+  /* difference between start and end time (secs) */
+  int     iproc_mjdate; 
+  /* MJD of data processing (i.e. creation of this file) */ 
+  enum trackmodes etrackmode;
+  /* tracking mode (for ALT/AZ CTs) */
+  int     iproc_evts;
+#ifdef LINUX
+  int dummy2;
+#endif
+  /* number of events processed */
+  double  dactual_sourcera_hours;
+  /* for off runs: the false source (that should have been) observed */
+  float   frms_pedsig_phot[iMAXNUMPIX];
+  /* standard deviation of the calibrated signals from the pedestal run */ 
+  float   fpedrms_mean; /* Used to communicate the mean over all pixels 
+			 * pedestal RMS into the Runs NTuple, as it might 
+			 * be used for e.g. quality cuts. */
+  float   fcurrent_mean; /* The average current over the active pixels
+			  * for this run. This is done separately for
+			  * ON and OF runs. */
+
+  enum eERRORTOLERANCE eerrortolerance;
+  /* 0 == "cautious", exits on any reason (but tells in 
+   * the .err file,
+   * 1 == "goodphysics", exits when physics could be affected
+   * by the error,
+   * 2 == "tank", never exits except on coredumps and when
+   * all files have been processed. Do not use such files for
+   * physics analysis! 
+   *
+   * NOTE: the capital letter words are the enums, the small letter
+   * words must be used inside the parameter file. */
+  enum eMCTRIGGERFLAG emctriggerflag;
+  /* all: all events which survive the filter are written to the 
+   *      events NTuple. 
+   * flag: When Dorota's triggerflag is set to 1 for a particular
+   *       event, it shall be written to the output. All others shall
+   *       just be disregarded. (Default)
+   * noflag: Opposite of 'flag': only events with triggerflag = 0 shall
+   *         be treated further. */
+  Boolean bmontecarlo;
+  /* if TRUE we have a monte carlo dataset before us, if FALSE 
+   * (default value) it is just normal data. */
+};
+
+struct filterresults {
+  int     imax_alt_arcs;
+  /* maximum altitude reached during the run */
+  int     iaz_at_max_alt_arcs;
+  /* azimuth at the time the max. alt. was reached */
+  int     itimeaverage_alt_arcs;
+  /* altitude averaged over the runtime */
+  int     icoord_inconsist_evts;
+  /* number of events with time-coordinate */
+  /* inconsistency in this run */
+  int     ifilter_passed_evts;
+  /* number of events which passed the filter */
+  int     imuon_fail_evts;
+  /* number of events rejected as muons (other filters passed) */
+  int     i2out_fail_evts;
+  /* number of events which failed in the two out of all */
+  /* pixels software trigger */
+  int     imuon_and_2out_fail_evts;
+  /* number of events failing in both muon and */
+  /* 2out filter */  
+  int     isum_fail_evts;
+  /* number of events which failed the sum-of-all-calibrated */
+  /* ADC counts filter */
+  int     isum_and_muon_fail_evts;
+  /* number of events which failed in both the sum and */
+  /* the muon filter */
+  int     isum_and_2out_fail_evts;
+  /* number of events which failed in both the sum and */
+  /* the 2out filter */
+  int     iall_filters_fail_evts;
+  /* number of events which failed in all filters */ 
+  float   favg_event_rate_hz;
+  /* average rate before filtering */
+  float   fstddev_event_rate_hz;
+  /* standard deviation of the rate before filtering */
+
+};
+
+struct eventrecord {
+  int   isecs_since_midday;
+  /* seconds passed since midday before sunset (JD of run start) */
+  int   isecfrac_200ns;
+  /* fractional part of isecs_since_midday */
+  short snot_ok_flags;
+  /* the bits in these two bytes are flags for additional */
+  /* information on the event: Everything OK =: all Bits = 0 */
+  int   ialt_arcs;
+  /* altitude (arcseconds) */
+  int   iaz_arcs;
+  /* azimuth (arcseconds) */
+  int   ipreproc_alt_arcs;
+  /* "should be" alt according to preproc (arcseconds) */
+  int   ipreproc_az_arcs;
+  /* "should be" az according to preproc (arcseconds) */
+  int   ifieldrot_arcs;
+  /* for ALT-AZ mount telescopes: rotation angle of the field of 
+   * view; this angle is defined mathematically positive looking 
+   * towards the sky as the angle between the hour circle through 
+   * the object being tracked and the line through pixel 1 and 2 */
+  unsigned short srate_millihz;
+  /* event rate in milli Hertz before filtering calculated by 
+   * iratecalc_numevents_odd/(time[i+iratecalc_numevents_odd/2] - 
+   * time[i-iratecalc_numevents_odd/2]) 
+   * For the first and the last iratecalc_numevents_odd/2 
+   * events the rate is assumed to be constant */
+  float fhourangle; /* This is the angle between the observation of this
+		     * event and the culmination point. It is going to 
+		     * be written into the events NTuple. */
+  float fmcenergy_tev; /* Simulated Energy.... dropping through to
+			* the Events NTuple. */
+  float fmcsize_phel; /* Simulated SIZE.... dropping through to
+			* the Events NTuple. */
+  int imcimpact_m;
+  /* MC data contain the impact parameter, which is given here in 
+   * meters. */
+  int imcparticle;
+  /* MC data know which particle they are.... all in CORSIKA standard. */
+  int imctriggerflag;
+  /* MC data from Dorota get a triggerflag: 1 means triggered, 0 not. */
+  short spixsig_10thphot[iMAXNUMPIX];
+  /* number of photoelectrons measured in each pixel only the 
+   * actual number of pixels (outputpars.inumpixels) is written out */
+};
+
+struct camera { /* camera parameters for imaging */
+  int inumpixels;
+  int inumrings;
+  double dpixdiameter_deg;
+  double dxc[iMAXNUMPIX]; 
+/* Pixel coordinates in camera coordinate system (x points from
+ * pixel 1 to 2). */
+  double dyc[iMAXNUMPIX];
+  /* The numbering of the pixels in these arrays starts at 0! */
+  double dxpointcorr_deg; 
+  /* correction of the pixel coordinates; to be added to dxc[] 
+   * to get correct value */
+  double dypointcorr_deg; 
+  /* correction of the pixel coordinates; to be added to dxc[] 
+   * to get correct value */
+};
+
+
+/* two structures for better file handling */
+struct inputfile {
+  char cname[iMAXFILENAMELENGTH];
+  /* filename (including path) */
+  FILE *pointer;
+  /* filepointer */
+  char ccannotopentext[161];
+  /* Error text printed when file cannot be opened */
+  int  icannotopencode; 
+  /* Error code for the exit statement when file could not be opened */
+  int  iearlyeofcode;
+  /* Error code for the exit statement for unexpected EOF */
+  int  ierroratclosecode;
+  /* Error code for the exit statement for error while trying to close */
+};
+
+struct outputfile {
+  char cname[iMAXFILENAMELENGTH]; /* filename (including path) */
+  FILE *pointer;  /* filepointer */
+  char ccannotopentext[161]; 
+  /* Error text printed when file cannot be opened */
+  int  icannotopencode; 
+  /* Error code for the exit statement when file could not be opened */
+  int  icannotwritecode; 
+  /* Error code for the exit statement for failed fprintf */
+  int  ierroratclosecode; 
+  /* Error code for the exit statement for error while trying to close */
+};
+
+struct P2ALLHISTOS {
+
+  HISTO *p2adchist;
+  HISTO *p2pedonhist;
+  HISTO *p2pedofhist;
+  HISTO *p2pedonmeanhist;
+  HISTO *p2pedofmeanhist;
+  HISTO *p2pedonjitthist;
+  HISTO *p2pedofjitthist;
+  HISTO *p2calonhist;
+  HISTO *p2calofhist;
+  HISTO *p2calonmeanhist;
+  HISTO *p2calofmeanhist;
+  HISTO *p2calonjitthist;
+  HISTO *p2calofjitthist;
+  HISTO *p2phehist;
+  HISTO *p2zenonhist;
+  HISTO *p2zenofhist;
+  HISTO *p2corrpedhist;
+  HISTO *p2pedfwhmhist;
+};
+
+struct CALNT_DAT { 
+  /* the structure for an entry in the calibration ntuple */
+  float CTrunnum;
+  float runtype;
+  float ALT_deg; /* the ALT taken from the first event of the run */
+  float extinct; /* extinction */
+  float RtiSecBF; /* runtime in seconds before filter */
+  float pixnum;  /* number of the pixel for which the following 
+		  * data is given */
+  float pixonoff; /* Quantity telling whether this pixel was switched
+		   * off by the user (-= 2.) or by preproc (-= 1.).
+		   * If ON, its value = 0. */
+  float ped_adcc; /* the standard deviation of the pedestal as 
+		   * calculated by TIJARAFE */
+  float pedrmsac; /* the standard deviation of the pedestal in
+		   * ADC counts as calculated by TIJARAFE */
+  float pedrmsPE; /* the calibrated ped RMS in photoelectrons 
+		   * which is also given to the imager */
+  float las_adcc; /* the mean signal for this pixel from the 
+		   * laser run */
+  float lasrmsac; /* RMS of the laser events after cleaning from cosmics */
+  float conv_fac; /* conversion factor = <Q>/Var(Q) * F^2 */
+  float F;        /* The F from the line before */
+  float rel_gain; /* the relative gain of the pixel */
+  float numtrig;  /* number of events in which the pixel was 
+		   * above trigger threshold */
+  float num3sig;  /* number of events in which the pixel was 
+		   * 3 sigma above its pedestal */ 
+  float HV1;      /* Adjustment of HV1 for this run, if available. */
+  float HV2;      /* Adjustment of HV2 for this run, if available. */
+  float ThrCurr;
+  float AvgCurr;  /* the sum of all currents during this run (with the
+		   * particular runtype in question) from the TelLog 
+		   * file. The currents are averaged over the 2-minute
+		   * intervals but summed over all pixels with currents
+		   * higher than the threshold current value. This sum
+		   * is then stored in the runs ntuple. 
+		   * Same for the scaler values --> */
+  float AvgScal;
+};
+
+struct inputpars {
+  Boolean bkeywordgiven[iNUMKEYWORDS+1]; /* if a valid keyword 
+					  * is given in the 
+					  * parameters file 
+					  * the corresponding
+					  * element in this 
+					  * array is set to true */ 
+  int     itelescope;       /* number of the CT which took the data */
+  float   flongitude_deg;   /* longitude (counted positive 
+			     * towards West) of CT position */
+  float   flatitude_deg;    /* latitude (counted positive 
+			     * towards North) of CT position */
+  int     ifirstrunnum;     /* first run number to which these 
+			     * parameters apply*/
+  int     ilastrunnum;      /* last run number to which these 
+			     * parameters apply, */
+                            /* i.e. this run will be processed 
+			     * with these parameters */
+  int     inumpixels;       /* number of pixels in the camera */
+  int     inummuonpixels;   /* number of pixels in the muon shield */
+  int     inumcointdcs;     /* number of coincidence tdcs recorded 
+			     * in the runfile */
+  float   fpixdiameter_deg; /* smallest pixel diameter (degrees) */
+  enum axes ese1_is;        /* name of the axis to which shaft
+			     * encoder 1 is attached
+			     * (implies the type of mount) (the 
+			     * type axes is declared in structures.h) */
+  float   fdegrees_per_step[2]; /* angular resolution of shaft 
+				 * encoders 1 and 2 */
+  int     isezeropos[2];    /* zero position of shaftencoders 1 and 
+			     * 2 from parameters file */
+  int     iaz_rev_track_corr; /* correction for the azimuth shaft 
+			       * encoder (ALT/AZ mount only) in 
+			       * reverse tracking mode */
+  int     ialt_rev_track_corr; /* correction for the altitude 
+				* shaft encoder (ALT/AZ mount only) 
+				* in reverse tracking mode */
+  float   fbendingcorr;     /* bending correction factor 
+			     * (ALT/AZ mount only) */
+  Boolean bdontusepix[iMAXNUMPIX]; /* bdontusepix is set true 
+				    * if the pixel should due 
+				    * to whatever reason not be 
+				    * used in image analysis, 
+				    * otherwise it is false;
+				    * this is a copy of the 
+				    * input from the parameters file */
+  Boolean bdontusepix_in_trig[iMAXNUMPIX]; /* is set true if the 
+					    * pixel should due 
+					    * to whatever reason not 
+					    * be used in the two out 
+					    * of all trigger, otherwise 
+					    * it is false; this is a 
+					    * copy of the input from 
+					    * the parameters file */
+  float   fphotoel_per_adccnt[iMAXNUMPIX]; /* conversion factors for 
+					    * the pixel signals */
+  float   fextinction;      /* atmospheric extinction (typically 
+			     * taken from the Carlsberg Meridian
+			     * Circle data) */
+  int     irubminusutc_usecs; /* difference between rubidium clock 
+			       * and UTC in microseconds */
+  int     isum_thresh_phot; /* threshold for the total sum of 
+			     * photoelectrons filter from the 
+			     * parameters file */
+  int     i2out_thresh_phot; /* threshold for the 
+			      * two-pixels-out-of-all software 
+			      * trigger from parameters file */
+  int     imuoncut_thresh_adccnt[iMAXNUMMUONPIX]; /* thresholds for 
+						   * the muon cut */
+  Boolean bmuon_suppression;       /* if true, the events which do 
+				    * not pass the muon cut are not 
+				    * written to the output */
+  float   ftolerated_pointerror_deg; /* maximum tolerated pointing 
+				      * error in the position check 
+				      * in iprocessdata */
+  float   fxpointcorr_deg;  /* pointing correction (to be added 
+			     * along the camera x axis) e.g. 
+			     * from point run */ 
+  float   fypointcorr_deg;  /* pointing correction (to be added 
+			     * along the camera y axis) e.g. 
+			     * from point run */ 
+  float   fcamera_align_angle_deg; /* the angle between the camera 
+				    * y-axis and the meridian when 
+				    * a culminating object is 
+				    * observed (defined 
+				    * counter-clockwise looking at 
+				    * the sky) */ 
+  int     iratecalc_numevents_odd; /* number of events used in the 
+				    * rate calculation (must be odd) */
+  enum pedsearchdirs {MATCH=0, BEFORE, AFTER, PINGPONG, 
+		      PEAKFWHM, NONE} epedsearchdir ; 
+  /* MATCH = only same number as run file (if ipedendofsearch is 0) or 
+     exactly ipedendofsearch;
+     BEFORE = search backwards until pedendofsearch; 
+     AFTER = search forward until pedendofsearch, 
+     PINGPONG = Try to fibnd the matching partner, try run#-1, run#+1,
+     run#-2, run#+2 etc. up to the third argument, the partnerfindrange 
+     NONE = use none of both. This is only useful for Monte Carlo
+     Analysis, for everything else it is highly unrecommended.*/
+  int     ipedendofsearch;  /* pedestal file number until which to 
+			     * search (see epedsearchdir) */
+  int     ipedsearchdepth;  /* depth, until which preproc should
+			     * try to find TelPed* partnerfiles */
+  enum    pedsearchdirs ecalsearchdir; 
+  /* MATCH = only same number as run file (if ipedendofsearch is 0) or 
+     exactly ipedendofsearch;
+     BEFORE = search backwards until pedendofsearch; 
+     AFTER = search forward until pedendofsearch, 
+     PINGPONG = Try to fibnd the matching partner, try run#-1, run#+1,
+     run#-2, run#+2 etc. up to the third argument, the partnerfindrange 
+     NONE = use none of both. This is only useful for Monte Carlo
+     Analysis, for everything else it is highly unrecommended.*/
+  int     icalendofsearch;  /* calibration file number until which 
+			     * to search (see ecalsearchdir)*/
+  int     icalsearchdepth;  /* depth, until which preproc should
+			     * try to find TelCal* partnerfiles */
+  double  dsourcera_hours;  /* right ascension of observed source 
+			     * in hours */
+  double  dsourcedec_deg;   /* declination of observed source in 
+			     * degrees */
+  float   fpadlevel_phot_pix[iMAXNUMPIX];   /* if > 0., software 
+					     * padding to this 
+					     * level is applied 
+					     * for the given pixel */
+  float   fseed1; /* seed for random generators */
+  float   fseed2;
+
+  int iswap_partner_of_pix[iMAXNUMPIX]; /* if >= 0, pixel i is 
+					 * swapped with 
+					 * iswap_partner_of_pix[i] 
+					 * in ireadrunfile, -pedfile, 
+					 * -calfile (internal 
+					 * numbering starting at 0)*/
+
+  Boolean bnewhistograms; /* set to true if new histograms shall be booked */
+  Boolean bhisto_on; /* set to true if histogramming is on */
+
+  enum eERRORTOLERANCE eerrortolerance; 
+  /* 0 == "cautious", exits on any reason (but tells in 
+   * the .err file,
+   * 1 == "normal", exits when physics could be affected
+   * by the error,
+   * 2 == "tank", never exits except on coredumps and when
+   * all files have been processed. Do not use such files for
+   * physics analysis! 
+   *
+   * NOTE: the capital letter words are the enums, the small letter
+   * words are to be used inside the parameter file. */
+  Boolean bmontecarlo;
+  /* if TRUE we have a monte carlo dataset before us, if FALSE 
+   * (default value) it is just normal data. */
+  enum eMCTRIGGERFLAG emctriggerflag;
+  /* all: all events which survive the filter are written to the 
+   *      events NTuple. 
+   * flag: When Dorota's triggerflag is set to 1 for a particular
+   *       event, it shall be written to the output. All others shall
+   *       just be disregarded. (Default)
+   * noflag: Opposite of 'flag': only events with triggerflag = 0 shall
+   *         be treated further. */
+  char mcfile[FILENAME_MAX];
+  float fmean_nsb_pe_pix[iMAXNUMPIX];
+  Boolean bfitmypedrms;
+  /* If TRUE, the pedestal MEAN and SIGMA=sqrt(MEAN) is fitted
+   * from pickup corrected pedestal data and not calculated from 
+   * the pickup corrected ADC values, as it was done up to 
+   * ~November 2000. */
+};
+
+struct calibrationdata { /* Calibration (Laser Run) Data to be read 
+			  * from the Te?Cal files */
+  int iid; /* no useful information, is long in the Macintosh format */
+  int itelescope; /* number of the CT which took the data */
+  int irunnum; /* run number from the file name */
+  enum onoroff eruntype; /* indicates if the run is on- or off 
+			  * (taken from filename) */
+  int inumruns; /* number of laser runs recorded in this file, is 
+		 * long in the Macintosh format */
+  char cname[iMAXFILENAMELENGTH]; /* copy of the filename used when 
+				   * the data was read */
+  double dmean_adc[iMAXNUMLASERRUNS][iMAXNUMPIX]; 
+  /* means of pixel signals over all shots calculated by TIJARAFE /
+   * Roberto: in processdata.c this number is recalculated. */
+  double dmean_lasoutput[iMAXNUMLASERRUNS][iMAXNUMLASEREVENTS]; 
+  /* This new (April 26 2000) quantity monitors the laser mean
+   * output recorded in events, which are not considered cosmics. */
+  double dmean_alladc[iMAXNUMPIX]; 
+  /* means of pixel signals over all triggers calculated by 
+   * preproc. */
+  double dmean_laserjitter[iMAXNUMPIX]; 
+  /* Here we calc. the deviation from the actual lasergain in a 
+   * single laser shot to the laser mean as averaged over the camera */
+  double drms_adc[iMAXNUMPEDRUNS][iMAXNUMPIX];
+  /* the standard deviations of the pixel signals */
+  int inumpixels; /* number of pixels in the camera, short in 
+		   * Macintosh format */
+  int inumevents[iMAXNUMLASERRUNS]; /* number laser shots, 
+				     * short in Macintosh format */
+  int ipixsig_adc[iMAXNUMLASERRUNS][iMAXNUMLASEREVENTS][iMAXNUMPIX]; 
+  /* the signals obtained from each pixel for each laser shot and 
+   * each laser run, unsigned short in the Macintosh format */
+};
+
+struct pedestaldata { /* Pedestal Run Data to be read from the 
+		       * Te?Ped files */
+  int iid; /* no useful information, is long in the Macintosh 
+	    * format */
+  int itelescope; /* number of the CT which took the data */
+  int irunnum; /* run number from the file name */
+  enum onoroff eruntype; /* indicates if the run is on- or of 
+			  * (taken from filename) */
+  int inumruns; /* number of pedestal events recorded in this file, 
+		 * is long in the Macintosh format */
+  char cname[iMAXFILENAMELENGTH]; /* copy of the filename used 
+				   * when the data was read */
+  double dmean_adc[iMAXNUMPEDRUNS][iMAXNUMPIX]; 
+  /* means of pixel signals over all triggers calculated by 
+   * TIJARAFE using a sigma cut of 2 */
+  double dmean_alladc[iMAXNUMPIX]; 
+  /* means of pixel signals over all triggers calculated by 
+   * preproc. */
+  double dmean_allPE[iMAXNUMPIX]; 
+  /* means of pixel signals over all triggers calculated by 
+   * preproc. */
+  double dmean_pedlevel[iMAXNUMPEDRUNS][iMAXNUMPEDEVENTS]; 
+  /* This new (preproc_0.4) quantity monitors the pedestal mean
+   * output recorded in events, which are not considered cosmics. 
+   * The calc.ing is done inside processdata.c */
+  double dmean_pedlevelPE[iMAXNUMPEDRUNS][iMAXNUMPEDEVENTS]; 
+  /* This new (preproc_0.4) quantity monitors the pedestal mean
+   * output recorded in events, which are not considered cosmics. 
+   * The calc.ing is done inside processdata.c */
+  double dmean_pedoffset[iMAXNUMPIX]; 
+  /* Mean Offset from the ADC spectrum of a pixel to the mean of the
+   * pedestal events. */
+  double dmean_pedoffsetPE[iMAXNUMPIX]; 
+  /* Mean Offset from the ADC spectrum of a pixel to the mean of the
+   * pedestal events. */
+  double drms_adc[iMAXNUMPEDRUNS][iMAXNUMPIX];
+  /* the standard deviations of the pixel signals used in the 
+   * sigma cut mentioned above */
+  double drms_alladc[iMAXNUMPIX];
+  /* The RMS value of the as-is ADC spectrum for all events inside a 
+   * Pedestal file. */
+  double drms_allPE[iMAXNUMPIX];
+  /* The RMS value of the as-is ADC spectrum for all events inside a 
+   * Pedestal file. */
+  double drms_nopickup[iMAXNUMPIX];
+  /* the standard deviations of the pixel signals' deviation from
+   * the events' mean (in ADC counts, of course...)  ---
+   * This is the same as the RMS of the pickup corrected pedestals! */
+  double drms_nopickupPE[iMAXNUMPIX];
+  /* the standard deviations of the pixel signals' deviation from
+   * the events' mean (in ADC counts, of course...)  ---
+   * This is the same as the RMS of the pickup corrected pedestals! */
+  int inumpixels; /* number of pixels in the camera, short in 
+		   * Macintosh format */
+  int inumevents[iMAXNUMPEDRUNS]; /* number of random triggers, 
+				   * short in Macintosh format */
+  int ipixsig_adc[iMAXNUMPEDRUNS][iMAXNUMPEDEVENTS][iMAXNUMPIX]; 
+  /* the signals obtained from each pixel for each random trigger 
+   * and each pedestal event, short in the Macintosh format */
+}; 
+
+struct runfiledata { /* Data read from Te?Run files */
+  int iformatid; /* Format ID of the data, long in Macintosh format */
+  int iversid;   /* Version ID of the data, long in Macintosh format */
+  int irevid;    /* Revision ID..., long in Macintosh format */
+  int itelescope; /* number of the CT which took the data */
+  int irunnum; /* run number from the file name */
+  int irunnumx; /* number read from the file, long in Macintosh format */
+  int inumevents; /* number of events recorded in this run, long in 
+		   * Macintosh format */
+  char cname[iMAXFILENAMELENGTH]; /* copy of the filename used when 
+				   * the data was read */
+  int ieventheaderlength; /* number of bytes in the event header,
+			   * long in Macintosh format */
+  int ieventheaderoffset; /* unknown meaning, long in Macintosh 
+			   * format */
+  int isignalslength; /* number of bytes used by the pixel signals, 
+		       * long in Macintosh format */
+  int isignalsoffset; /* unknown meaning, long in Macintosh format */
+  int itdccountslength; /* number of bytes used by the TDC signals, 
+			 * long in Macintosh format */
+  int itdccountsoffset; /* unknown meaning, long in Macintosh format */
+  int iobservtime_mins; /* (planned) observational time (minutes), 
+			 * short in Macintosh format */
+  enum onoroff eruntype; /* indicates if the run is on- or off-source; 
+			  * in the Macintosh format, this is a short
+			  * where 1 means off and 2 means on */
+  int ileapsecs; /* Leap seconds, introduced into UTC in order to 
+		  * keep track of some very small differences 
+		  * accumulated through the years. */
+  int ihv1;
+  int ihv2; /* these two numbers represent the HV adjustment made
+	     * by the shiftpersonnel. The last three items are 
+	     * only read for Roberto files, but not for Tijarafe 
+	     * files, as e.g. the HVs are not written out correctly. */
+  char cdummy[40]; /* unknown meaning */
+  int imactime_secs[iMAXNUMRUNEVENTS]; 
+  /* Macintosh time (time_t mydatum) in seconds since 1970, this is 
+   * put together from two Macintosh shorts and converted to the time 
+   * format required by SYSTEM */
+  unsigned int uigpstime_secs[iMAXNUMRUNEVENTS]; 
+  /* GPS time (time_t mydatum) in seconds since 1970, this is 
+   * put together from two Macintosh shorts and converted to the time 
+   * format required by SYSTEM 
+   * This time is new from Roberto and is coming from the PC-GPS card.
+   * There is another flag available in the runheader, which gives an
+   * overall flag for the run, whether or not the GPS time had been
+   * working. It is, however, not a good idea to use this flag, as 
+   * the workability of this card can also be dedued from the GPS time
+   * itself. This allows to check for failures on a event-by-event 
+   * basis, which seems more reasonable than using the global flag. */
+  unsigned int uigpstime_usecs[iMAXNUMRUNEVENTS]; 
+  /* GPS microseconds -- available from the card, that's why it is 
+   * put to the data, here it is.
+   * This is put together from two Macintosh shorts and converted
+   * to the time format required by SYSTEM */
+  unsigned int uirubsecs_secs[iMAXNUMRUNEVENTS]; 
+  /* the seconds of the Rubidium clock time this is put together 
+   * from two Macintosh shorts and converted to the time format 
+   * required by SYSTEM */
+  unsigned int uirubsecfrac_200ns[iMAXNUMRUNEVENTS]; 
+  /* the fractional part of the Rubidium clock time second, this is 
+   * put together from two Macintosh shorts, unit is 200 ns */
+  int isepos[2][iMAXNUMRUNEVENTS]; 
+  /* positions of shaft encoders 1 and 2, short in Macintosh format */
+  float fhourangle; /* This is the angle between the observation of this
+		     * event and the culmination point. It is going to 
+		     * be written into the events NTuple. */
+  int ieventnumber[iMAXNUMRUNEVENTS]; 
+/* number of the event, short in Macintosh format */
+  int inumpixels; /* number of pixels in the camera, short in 
+		   * Macintosh format */
+  int inummuonpixels; /* number of pixels in  the muon shield; 
+		       * the sum of inumpixels and inummuonpixels is 
+		       * part of the event record but should be the 
+		       * same for all events, so it is not put into 
+		       * an array */
+  int inumcointdcs; /* number of coincidence TDCs for which counts 
+		     * were recorded, short in Macintosh format
+                     * this value is part of the event record but 
+		     * should be the same for all events, so it is 
+		     * not put into an array */
+  int ipixsig_adc[iMAXNUMRUNEVENTS][iMAXNUMPIX]; 
+  /* signals from the camera photo multipliers (ADC counts) */
+  int imuonpixsig_adc[iMAXNUMRUNEVENTS][iMAXNUMMUONPIX]; 
+  /* signals from the muon shield photo multipliers (ADC counts) */
+  int itdcsig_cnts[iMAXNUMRUNEVENTS][iMAXNUMCOINTDCS]; 
+  /* counts from the coincidence TDCs if itdccountslength > 0 */
+};
+
+struct TELLOGDATA {
+  int irunnum; /* The runnumber which we are interested in. 
+		* Only data for this runnumber are written into 
+		* this structure and then copied to the calnt NTuple.
+		* 
+		* This runnumber is generally the closest match 
+		* inside the TelLog file. */
+  float pixel_timeaveraged_current[127];
+  float pixel_timeaveraged_scaler[127];
+};
+
+/************************************************
+ * structures in output file                    *
+ * (Konopelko files format)                     *
+ * (from structures.h file 4.4)                 *
+ ************************************************/
+struct mcbankheader { /* Once in every file */
+  int iparticle_type;  
+  /* Primary particle type: 0 = gamma; +-1= e+-; 
+   * +-2 = mu+-; +-3 = p+-, n; +-4 = pi+- */
+  int inum_cts;
+  /* Number of simulated telescopes */
+  int inum_nfl_shifts; 
+  /* Number of NFL shifts for hadrons (per event) */
+  int itrigger_thresh_phot; 
+  /* Only images with two pixels above this threshold are 
+   * in the MC data file */
+  int imin_signal;
+  /* "Tail cut" = smallest signal saved */
+  int inum_sim_showers; 
+  /* Total number of showers simulated for this file */
+  float fatmothick_gcm2; 
+  /* Atmosphere above the telescope [g/cm2] */
+  float fcos_zenangle;
+  /* Cosine of the zenith angle */
+  float fnfl_shift_radius_deg; 
+  /* Maximum angular radius within which a shifted 
+   * hadron shower is sampled [degrees] */
+  float fenergybin_bound_tev[iNUMENERGYBINS+1]; 
+  /* Boundaries for the 14 energy bins [TeV] 
+   * (newline after the first 8 numbers) */
+  float fzenithanglebin_bound[iNUMZENANGLEBINS+1]; 
+  /* Boundaries for the 11 zenith angle bins [degrees] */
+  int inum_show_in_bin[iNUMENERGYBINS]; 
+  /* Number of simulated (or saved) showers 
+   * per energy bin (newline after the first 8 numbers) */
+  float fmaxdist_impact_m[iNUMIMPACTBINS]; 
+  /* Maximum distance of the impact point to the 
+   * central telescope [m] for each energy bin 
+   * (newline after the first 8 numbers) */
+  int inumpixels_for_ct[iMAXNUMCTS]; 
+  /* Number of pixels in the camera of each simulated CT */
+  float fpixwidth_deg_ct[iMAXNUMCTS]; 
+  /* Pixel width [degrees] for each CT */
+  float fmirrsize_m2_ct[iMAXNUMCTS];  
+  /* Mirror area [m^2] for each CT  */
+  float fmean_nsb_phot_ct[iMAXNUMCTS]; 
+  /* Mean signal caused by the NSB in each pixel for each CT 
+   * [photoelectrons]. This is the simulation of the NSB, 
+   * not the electronic noise */
+  float fphes_per_photon_ct[iMAXNUMCTS]; 
+  /* Conversion factor photoelectron per photon */
+  float frelative_x_ct[iMAXNUMCTS]; 
+  /* x position relative to the central CT for each CT */
+  float frelative_y_ct[iMAXNUMCTS]; 
+  /* y position relative to the central CT for each CT */
+}; 
+#endif
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mars.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mars.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mars.cc	(revision 9661)
@@ -0,0 +1,147 @@
+#include <TApplication.h>
+
+#include "MAGIC.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MMars.h"
+#include "MArgs.h"
+#include "MArray.h"
+#include "MParContainer.h"
+
+#ifdef HAVE_XPM
+#include "MLogo.h"
+#endif
+
+using namespace std;
+/*
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,10,02)
+#include <TRootGuiFactory.h>
+#include <TPluginManager.h>
+void InitGuiFactory()
+{
+    if (gROOT->IsBatch())
+        gROOT->SetBatch(kFALSE);
+
+    //
+    // Must be loaded by hand, because it is not loaded by TGApplication.
+    // We could also use TApplication instead, but TApplication doesn't
+    // deal with the DISPLAY variable in a convient way.
+    //
+    TPluginHandler *h;
+    if ((h = gROOT->GetPluginManager()->FindHandler("TGuiFactory", "root")))
+    {
+        if (h->LoadPlugin() == -1)
+            return;
+        gGuiFactory = (TGuiFactory*)h->ExecPlugin(0);
+    }
+}
+#endif
+*/
+
+// **********************************************************************
+//
+//    MARS main program  
+//
+//    The only job of the main program is the initialisation of ROOT and 
+//    the start of the guiinterface for the mars program
+//
+//    started by  h. kornmayer      january, 3rd  2001 
+static void StartUpMessage()
+{
+    gLog << all << endl;
+
+    //                1         2         3         4         5
+    //       12345678901234567890123456789012345678901234567890
+    gLog << "==================================================" << endl;
+    gLog << "                    MARS V" << MARSVER              << endl;
+    gLog << "    Magic Analysis and Reconstruction Software"     << endl;
+    gLog << "            Compiled on <" << __DATE__ << ">"       << endl;
+    gLog << "               Using ROOT v" << ROOTVER             << endl;
+    gLog << "==================================================" << endl;
+    gLog << endl;
+}
+
+static void Usage()
+{
+    gLog << all << endl;
+    gLog << "Sorry the usage is:" << endl;
+    gLog << "   mars [-h] [-?] [-a0] [-vn]" << endl << endl;
+    gLog << "     -a0: Do not use Ansii codes." << endl;
+    gLog << "     -vn: Verbosity level n [default=2]" << endl;
+    gLog << "     -?/-h: This help" << endl << endl;
+}
+
+int main(int argc, char **argv)
+{
+    StartUpMessage();
+
+    //
+    // Evaluate arguments
+    //
+    MArgs arg(argc, argv);
+
+    if (arg.HasOption("-?") || arg.HasOption("-h"))
+    {
+        Usage();
+        return -1;
+    }
+
+    //
+    // Set verbosity to highest level.
+    //
+    gLog.SetDebugLevel(arg.HasOption("-v") ? arg.GetIntAndRemove("-v") : 2);
+
+    if (arg.HasOption("-a") && arg.GetIntAndRemove("-a")==0)
+        gLog.SetNoColors();
+
+#ifdef HAVE_XPM
+    MLogo logo;
+    logo.Popup();
+#endif
+
+    //
+    // initialise ROOT
+    //
+    TApplication app("Mars", &argc, argv);
+    if (gROOT->IsBatch() || !gClient)
+    {
+        gLog << "Bombing... maybe your DISPLAY variable is not set correctly!" << endl;
+        return 1;
+    }
+
+    //
+    // Swtich of TObjectStreamer in our base classes derived from TObject
+    //
+    MArray::Class()->IgnoreTObjectStreamer();
+    MParContainer::Class()->IgnoreTObjectStreamer();
+
+    /*
+    TGApplication app("Mars", &argc, argv);
+
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,10,02)
+    InitGuiFactory();
+#endif
+    */
+
+#ifdef HAVE_XPM
+    logo.Popdown();
+#endif
+
+    //
+    // start the main window
+    //
+    new MMars;
+
+    //
+    // run the application
+    //
+    app.Run();
+
+    gLog << all << endl;
+
+    return 0;
+}
+ 
+
Index: /tags/Mars_V0-8-5/Mars/marslogo.xpm
===================================================================
--- /tags/Mars_V0-8-5/Mars/marslogo.xpm	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/marslogo.xpm	(revision 9661)
@@ -0,0 +1,363 @@
+/* XPM */
+static char *marslogo[] = {
+/* width height ncolors chars_per_pixel */
+"100 100 256 2",
+/* colors */
+"   c #E99C39",
+" . c #71705B",
+" X c #113A42",
+" o c #DBAF21",
+" O c #9A8A76",
+" + c #928282",
+" @ c #7B815E",
+" # c #AD6A4A",
+" $ c #172834",
+" % c #6C7F8E",
+" & c #444B49",
+" * c #1C3B46",
+" = c #785944",
+" - c #28485F",
+" ; c #EA8651",
+" : c #C8714A",
+" > c #8A7145",
+" , c #515759",
+" < c #9E6145",
+" 1 c #061837",
+" 2 c #4F5157",
+" 3 c #636464",
+" 4 c #485750",
+" 5 c #9E962A",
+" 6 c #2C2A24",
+" 7 c #3D464F",
+" 8 c #B17854",
+" 9 c #DBC313",
+" 0 c #647789",
+" q c #867A3A",
+" w c #A7705E",
+" e c #9F7656",
+" r c #D2BE14",
+" t c #82604A",
+" y c #3E4D5D",
+" u c #544C16",
+" i c #A7AB99",
+" p c #C58443",
+" a c #C9B40B",
+" s c #88803F",
+" d c #263542",
+" f c #5C6877",
+" g c #8A7A02",
+" h c #9C7160",
+" j c #9D9C2F",
+" k c #6E6622",
+" l c #5C6463",
+" z c #999F8B",
+" x c #152A3B",
+" c c #A0937E",
+" v c #E9C313",
+" b c #E9B81D",
+" n c #B4833F",
+" m c #90624A",
+" M c #02051B",
+" N c #655244",
+" B c #D1B819",
+" V c #AD7642",
+" C c #AA6853",
+" Z c #2A2A2B",
+" A c #646550",
+" S c #988602",
+" D c #3C4B4D",
+" F c #64693C",
+" G c #5A5850",
+" H c #263F5F",
+" J c #B4A11A",
+" K c #AB8339",
+" L c #3B3C42",
+" P c #D2814F",
+" I c #5A5146",
+" U c #3F5D7E",
+" Y c #2A4A70",
+" T c #273D4C",
+" R c #BABAAE",
+" E c #C88C3B",
+" W c #64716A",
+" Q c #635C1D",
+" ! c #3A3202",
+" ~ c #E8A92C",
+" ^ c #7C783C",
+" / c #746952",
+" ( c #8F5D45",
+" ) c #51524A",
+" _ c #C89D34",
+" ` c #C3AE25",
+" ' c #BAA830",
+" ] c #D17951",
+" [ c #020203",
+" { c #BC8B3C",
+" } c #D46A4A",
+" | c #B0A026",
+".  c #113643",
+".. c #32618B",
+".X c #141525",
+".o c #16253E",
+".O c #776705",
+".+ c #050C20",
+".@ c #92674E",
+".# c #3F4345",
+".$ c #6A5E02",
+".% c #8B7B5E",
+".& c #797174",
+".* c #A96E4A",
+".= c #8E8643",
+".- c #9E826A",
+".; c #CA9232",
+".: c #71696C",
+".> c #255B81",
+"., c #08131C",
+".< c #827716",
+".1 c #B3A81B",
+".2 c #BE704E",
+".3 c #E87A53",
+".4 c #9C8B0B",
+".5 c #DC7951",
+".6 c #D1943C",
+".7 c #18191B",
+".8 c #9A863E",
+".9 c #9C8040",
+".0 c #C5A926",
+".q c #8F6A5B",
+".w c #C87751",
+".e c #9E961A",
+".r c #06203E",
+".t c #DECA10",
+".y c #485A61",
+".u c #EA8C44",
+".i c #B69A8B",
+".p c #DD8155",
+".a c #7E6E4A",
+".s c #334249",
+".d c #DB9A35",
+".f c #9E7D4F",
+".g c #0D3D69",
+".h c #DBAA21",
+".j c #5A5941",
+".k c #785F4E",
+".l c #967947",
+".z c #1A4A6F",
+".x c #D2714A",
+".c c #EBA234",
+".v c #B1933D",
+".b c #323234",
+".n c #826851",
+".m c #293335",
+".M c #165282",
+".N c #4D6376",
+".B c #687876",
+".V c #716054",
+".C c #6A7039",
+".Z c #364E52",
+".A c #83695F",
+".S c #34567B",
+".D c #0A2834",
+".F c #31484D",
+".G c #1D3C61",
+".H c #406380",
+".J c #4E5C70",
+".K c #69651A",
+".L c #B49A3C",
+".P c #171A30",
+".I c #151403",
+".U c #0B0C0D",
+".Y c #C26A4A",
+".T c #3F5261",
+".R c #314B71",
+".E c #B8694A",
+".W c #AB9B15",
+".Q c #324B5E",
+".! c #AB6447",
+".~ c #7E6E56",
+".^ c #757782",
+"./ c #B38A3E",
+".( c #DCBA1A",
+".) c #A89C89",
+"._ c #DD9339",
+".` c #484003",
+".' c #E4764A",
+".] c #425253",
+".[ c #5B6351",
+".{ c #666973",
+".} c #403C26",
+".| c #827E74",
+"X  c #E9943E",
+"X. c #AA8B42",
+"XX c #072130",
+"Xo c #596070",
+"XO c #654D47",
+"X+ c #607184",
+"X@ c #877065",
+"X# c #323C43",
+"X$ c #594A45",
+"X% c #675E56",
+"X& c #273D42",
+"X* c #92928A",
+"X= c #E9BE19",
+"X- c #4E4544",
+"X; c #32425A",
+"X: c #67574C",
+"X> c #E28A4E",
+"X, c #35536A",
+"X< c #CE8A4E",
+"X1 c #728692",
+"X2 c #071A29",
+"X3 c #DB8B3D",
+"X4 c #8C801A",
+"X5 c #061428",
+"X6 c #BD9F33",
+"X7 c #4D4B46",
+"X8 c #C1A123",
+"X9 c #E7AF24",
+"X0 c #968A52",
+"Xq c #715145",
+"Xw c #C2AE06",
+"Xe c #8C9048",
+"Xr c #51574D",
+"Xt c #D29D37",
+"Xy c #2E2E2E",
+"Xu c #9F8B3D",
+"Xi c #C5B420",
+"Xp c #D1A922",
+"Xa c #D5A126",
+"Xs c #8F7155",
+"Xd c #EED506",
+"Xf c #815944",
+"Xg c #AEA831",
+"Xh c #415872",
+"Xj c #BD9536",
+"Xk c #928305",
+"Xl c #242424",
+"Xz c #705947",
+"Xx c #595E4E",
+"Xc c #788A8A",
+"Xv c #DB8343",
+"Xb c #D38D3B",
+"Xn c #919132",
+"Xm c #6A763A",
+"XM c #A17142",
+"XN c #5A5B5C",
+"XB c #E9CA0E",
+"XV c #C07750",
+"XC c #EA7F55",
+"XZ c #365C6A",
+"XA c #AA9605",
+"XS c #685742",
+"XD c #1D1E20",
+"XF c #1A313E",
+"XG c #B56E4F",
+"XH c #D3B220",
+"XJ c #907066",
+"XK c #0B3143",
+"XL c #272202",
+"XP c #082940",
+"XI c #193554",
+"XU c #9E684C",
+/* pixels */
+"XlXlXlXy Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z ZXy",
+"XlXlXlXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXlXDXy",
+"Xy.bXl.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U Z",
+".b.bXD [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+"XyXyXD [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+"XyXy.7 [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ M.U.U.+.,.,XXX2X5.,.+.+.U.+ [ M [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+"XyXy.7 [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ M.,.,XXXXXF $ xXF. XFXF.FX&.FX& * xXF.D x.D.DX2X2., M [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+"XyXyXD [.U [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [.U.+XX.D X X.FX&X&.F.F.s.F.].].].].FX& * * * X. . .DXX.,.+ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [.U [ [ [ [ [ [ [ [ [ [Xl",
+"XyXy.7 [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [.+.UXX.D $X&X&X& *.F.F.Z 4.]Xr.[.B %.B.B.[ D D.s.sX&.FX& *XF.D.DX2X5.+.U [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+" Z 6XD [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [.U.U.,XXXF dX&X&X&X&X&.mX#.Z 4 W ..C.B @X* z z z.| F.[Xr & & 4.] 4 DX&X&. . .D.DX5.U M [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+" Z ZXD [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [.+.D xX&.F.s.F.sX&X# dXF.m.b A.| i z zX*.).).).) c @ / /.V.jXx.jXx.[Xr & &.F.sX& *XKXXXX.+ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+" Z 6XD [.U [ [ [ [ [ [ [ [.U [ [ [ [ [ [ [ [ [ [ [ [ [ [.,XI *.s D.#.s.s.sX#.m.m.m.b.: + R i i.).).) c O O.% / / /XxXx G.[ A.j & & &.ZX&X& XXP.DX5 M [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [.U [Xl",
+"XyXy.7 [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [.,.,.DX& 7.s.#.s.#.s.#.s.b.b.b.b.b.kX@.i.i.i.-.- h m m.n t N.j I I.[.[X% / A I I & & D D.s X. XKXXX5 [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+" Z 6XD [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [.+ $X&X&X#.FX- & &X7 &X7X7X7XO IX$X-X-X7 IXzXz N NXS N.V.VXz.j.j I.j.jX: AXzXSXS N.j I uX7 &.#X#.m * XXPX2 1.+ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+"Xy.bXD [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [.,.D.FX#X#X#.# &X7Xr I NXOXq =Xf ( ( = =XOXOX$X$X$X$X$ I NXS N NXzXzXzXS.~.n.kXzXz NXO N I I ) &.b.bX&X& XXKXKXX.+ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+"Xy 6XD [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [.U.+XP d.Z.mX#X#.#X7X7.jXS =XfXfXf ( < ( (XfXf =XqXqXqXq NXqXf = = =.k = t =.n.aXf = =XSXq N N I I &.}X#.FX& *XKXKXPX5 M [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+" Z ZXD [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [.U x. .F.Q.sX#X#X# & I I = = ( < < < < < < < <.! < < < ( < ( < ( ( m m ( ( ( t t = = = =XzXz NXq N NX7 &.F &.s.s X X XXKX2X5.+ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+"XyXyXD [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ M x.FX;.s.s.#.#.#.#X7XO NXfXf ( ( < < < < < <.! <.! < ( < < < < ( ( ( ( ( ( ( t t.nXf = = =XzXq NXS N I & & & & &X&X#X& XXKXPXXX5 [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+" Z 6.7 [ [ [ [ [ [ [ [ [ [ [ [ [ [ [., -.s.s.s.s 7 & &X7 IXOXq t ( < < < < < < <XUXM.! <.! < < <XM < < <XU ( (XfXfXf t t = = =Xz =XSXqXzXS IX-X7X7 & &X#X#X#X& X XXK.r [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+" 6XyXD [ [ [ [ [ [ [ [ [ [ [ [ [ [ xXF.Z.Z D.F D &X7 &X$ N =Xf ( ( < < m <XU < <.!.! <.! < < <.* < < < < < <Xf ( (Xf (Xf = =XzXzXSXSXSXS N IX7 &X7X7.#.s.s.F.s * X.DXP.+ M [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+" Z ZXD [ [ [ [ [ [ [ [ [ [ [ [.+X2.F.Z.T.] 2 4.] )X7 IXS = m m < < ( ( ( ( m < < < < m < ( ( ( ( ( (Xf tXfXfXfXfXfXf = =XzXzXO NXS N N N I IX7 ) &X7 &.#.}.s.#.s.s.m. .D.r.+ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+"XyXy.7 [ [ [ [ [ [ [ [ [ [ [.UXF T 7.Q.] 2 2 , ) ).j IXS ( <.! < <XfXf =XqXf ( ( ( ( tXfXfXqXqXzXqXqXSXSXSXq N NXq NXS NXO.jX$X$ I I N I I I )X7X7X7X7 & & & & & &.#X&. XKX2.+ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+"Xy.bXD [ [ [ [ [ [ [ [ [ [ [.,X&.F.# 7 4 , 2 2 , ) I I = <.! <.! <Xf =XqXqXf ( ( ( ( t t =XqXOXqXO N I I IXO I I N I N IX$ IX7X7X$ I N I I.jX7X$X7X7X- & & & &X7 &.FX# X. .DX5 [ [ [ [ [ [ [ [ [ [ [ [Xl",
+" Z 6XD [ [ [ [ [ [ [ [ [ [X5 x.s.s & & 2 4 ,XN G GXOXO = <.!.!.!.!Xf = = tXf ( (XfXf.n tXf =Xz =XqXS N N N N N.j I IX$X7X7X7.#X7X7X7 I I ).j ) )X7X7 & & & &X-X7 u &X-X#X&XK.rX5 [ [ [ [ [ [ [ [ [ [ [Xl",
+".b.b.7 [ [ [ [ [ [ [ [ [ M -.Z D 7X- 2 4 G G G G IXO NXq <.!.E #.! ( ( ( ( = < < ( ( t t =Xz =XzXzXS = = =Xf I I I IX7X7X-.s.} & & & & ) ) I I IX7X7X7 & &X7X7 I IX7X7.F.s * XXP M [ [ [ [ [ [ [ [ [ [Xl",
+" Z 6XD [ [ [ [ [ [ [ [ [ d.Z.Z &.#.#.# ) IX7X7 IX$ N NXz.!.!.E.!.!.!.! < < < < < < < < (XzXzXSXzXS NXzXz =XS I N I IX7X7.#.sX#.s.# & &X7X7 IX7X7X7 )X7.j ) )X$ I I I IX7 &X# TXPX5.+ [ [ [ [ [ [ [ [ [Xl",
+" Z ZXD [ [ [ [ [ [ [ [ M T.Z.].# &X-X-X7 IX7X$ IX$ N N = <.E.E.!.!.!.E < < <XU < <XU < <Xf =.kXSXS IXzXSXSXO N I I IX7 & &.#X#.#.#X7X7 &X7 )X7X$X7 )X7XrXrX7 I.j N N IX7 &.s T.  1X5 [ [ [ [ [ [ [ [ [Xl",
+"Xy 6XD [ [ [ [ [ [ [.+ $.F.] & & &X-X7X-X$ I I IXqXqXfXf.!.E.E.E.Y.E.E.E.!.! # # #.E.! #XU < ( mXfXSXSXzXS I N I IX7 &X7 &.# D D & &X7X7X7X7X7 )X7X7X7X$ I IXSXSXSXS NX7 ) &.Z.GXP.r.+ [ [ [ [ [ [ [ [Xl",
+" Z Z.7 [ [ [ [ [ [ [XX -.]X7X7X- &X-X-X$XO N N N = (Xf <.!.!.Y.Y.E.E.E.E.E.!.E.E.E.Y.E.2.2.E.Y #.!.@ m mXfXzXzXz I IX- &X7 & & & & &X7 ) ) &X7 &X7X7 ) N IXq =XzXzX:XS I I 4 D -XKXP.+ [ [ [ [ [ [ [ [Xl",
+" Z 6XD [ [ [ [ [ [ [XFX,.]X7 &X7X-X$X$ I I IXOXOXf ( ( <.!.E.E.E.Y.E.E.E #.!XG.!.Y.2.2 :.Y.Y.2.2.EXUXUXU < t ( t =XS I I IX7 &X7 &X7X7 &X7X7X7X7X7 & IXSXzXz = =XzXzXz I I.].T T.gXKX2.+ [ [ [ [ [ [ [Xl",
+"XyXy.7 [ [ [ [ [ [.+X;.y.]Xr )X7 I = =XqXz NXfXf ( ( < < #.E.E.2.2 :.w :.E.*.E.E : : : : : : :XV : :.E.EXGXG # # # # m (.kXS.jX7X7X7X7 D & )X7X7X7.jXz t t.nXf = =XzXz N G ).Z T H.zXP 1 [ [ [ [ [ [ [Xl",
+" ZXyXD [ [ [ [ [.P x.y 4X7 ) I = t m.@ m < (XU <XU #.! #.E.2.E.2XG : : :.x.x : : : :.x :.xXV.E.2.2XGXU < #.! ( (XU # #.E.!XU <XzXSX7 ) &X7X7 IXSXqXf m m m m t t t =XzXz N ) & -.Q Y.M.g M M [ [ [ [ [Xl",
+".bXyXD [ [ [ [ [ * T.y.y ) ).j t mXUXUXU C.! # # #.EXG.E.2.Y.E.Y.!.E.2 :.x p.x.x.x.x.x ].xXG.EXG.2 #.@ <XU <XqXf mXU.EXG.Y.Y #.n = ) )X7X7X7XSX: (Xf ( m.@ ( ( t t = =X:X% 2.].FX,XZ.M.MX5.+ [ [ [ [ [Xl",
+"Xy 6XD [ [ [ [ [X;.Q.y ) )X: =XUXU C #XU.E.EXGXG.EXG.2.2.2.2.2.! <.!.!XG :.Y.Y.2.x ].x.x.x.Y.2.2 : : < m <XfXz = <XUXUXUXG.E.* t = IX$X7X$ I t t < ( < m m ( ( t t.k =XzXz ) 4.FX,.S...>.rX5 [ [ [ [ [Xl",
+" ZXy.7 [ [ [ [.,Xh.J.] &X: m.q.*.*.!.! C.EXG.2.2.2.2.Y.2 :.2.E <.@ ( < #.EXG #.E :.x :.w.x.x.x.x.x :.@ < m =Xq = <XUXU.!.*.*.!.@ tX$X7 I I = <XU < <.@ mXU m ( ( t t = =Xz GXN.ZX,.S.....gXK [ [ [ [ [Xl",
+" Z 6XD [ [ [.IX& l fXxXx.nXUXUXU C.!.!.* #.2XVXV.2.2 :XV.2 : V.!.!.! # :.x.2.2 : ].x.wXV.xXv ]Xv ]XG.!XU.@ m tXf t < # # # #XGXU mXSXS.a t.@XM.*XUXMXM < m.@ ( t m t =.k =X: G 2.T.N.N.H.>.z.7.U.I.U [Xl",
+" Z Z.7 [ [.`Xk.eXgXg |XgX8 VXU.*XU.!.E.E #.EXVXa.h o.h.h.h.hXa < #.EXG :.x : :XV.x.x.;.h oX9.hX9 o.2XM.*XU.@.n t = ( # # # VXpX8.0 J J.0XwXpXpXpXpXpXpXj.@ < ( m t.n = = =X% GXr.yXnXgXg j jXkXkXk.OXL 6",
+"XyXyXD [ [.$XBXBXdXBXdXdXd nXU.!.!.!.!.!.E.E p 9XdXBXdXdXBXd.( #.2 : :.x.x.5.x.'.x.'.dXdXdXdXdXdXBXb m < <.E.E.E < m m m <.9XBXdXBXdXBXdXBXdXBXdXBXdXB 9XH./ m ( ( m t.V.kX:X% |.1.tXdXdXdXdXBXdXB 9XA.<",
+" ZXy.7 [.`XAXdXdXdXdXdXdXd {.!.!.!.!.E.E.Y.Y.hXBXdXdXdXdXdXBX= :.x.x.x.x.'.'.'.'.'.u bXdXdXdXdXdXd.hXM mXU.2 : : :XG.E # VX8XBXdXdXdXdXdXdXdXdXdXdXdXdXdXB oXM m (.q.AXf.A /.9.t.tXdXdXdXdXdXdXdXdXd.t.W",
+"XyXyXD [ gXBXdXdXdXdXdXdXd.0 V.E.E.E.E.Y } }XBXdXdXdXdXdXd v.d ].'.x.5.3.'.'.'.'XC ~XBXdXBXdXdXdXdXB K ( ( #.x.x.x : } } EX=XdXdXdXdXdXdXdXdXdXdXdXdXdXdXdXB K m m m (.A.k.9 BXdXdXdXdXdXdXdXdXdXdXd 9.<",
+"XyXy.7 [.4XdXdXdXdXdXdXdXd v n #.EXGXG.2.x._XdXdXdXdXdXdXd b.'.'.5.'.'.3XC.3.'.'.uX=XdXdXdXdXdXdXdXd n < (XG.x.x.x :.x :Xb vXdXdXdXdXB.hX9.h o bXdXdXdXdXdXd K m m m.A.k.9XiXdXdXdXdXd `Xg | j S.4XdXw u",
+" ZXy.7 [ SXdXdXdXdXdXdXdXdXB pXGXV.2.2.x ]XdXdXdXdXdXdXdXdX9.'.'.'.3.3.3.3XC.3.3X9XdXdXdXdXdXdXdXdXdXb.Y.2.2 }.x.Y :.x.YX3XBXdXdXdXd b.E #.E.E.;XdXdXdXdXdXd KXU m.A (.A BXdXdXdXdXB r W.S.>.g.U [ J S.}",
+"XyXy.7 [.4XdXdXdXdXdXdXdXdXB p.2XV.2XV ]X3XdXdXdXdXdXdXdXd b.'.'.'.3.3XC.3.3.3.u bXdXdXdXBXdXdXdXdXd._.'.x :.x : : : : }XbXBXdXdXdXd o.Y.2.E.!.;XdXdXdXdXdXd {.@.q.@ m.l.(XdXdXdXd 9Xe.N.N.H.g.+ [XLXL 6",
+" Z 6XD.IXAXdXdXdXdXdXdXdXdXB pXV.2XV.2 P bXdXdXdXdXdXdXdXd b.3.3.3.3.3.3.3.3.3X XBXdXdXBXBXdXdXdXdXdXa.x.x : : :.x : : :.d vXdXdXdXB.h.2.EXG.! pXdXdXdXdXdXd nXs.@.q.qX6XBXdXBXdXd.t @.N.N U.z.+.U [ [Xl",
+"XyXy.7 u 9XdXdXdXdXdXdXdXdXBX<XGXV.2.wX3 vXdXdXdXBXdXdXdXd b.3.'.3.3XC.3XC.3.3  XdXdXB ~ bXdXdXBXdXdX=X3.x ] : ].x.x.w pX9XdXdXdXd o p.2.2.E #.;XdXdXdXdXdXd nXU h.qX@.0XdXdXdXdXd 9 @.N.N.H.z., M [ [Xl",
+" Z 6XD.OXBXdXBXdXa.(XdXdXdXB pXV.2XV P ~XBXdXdXdXdXdXdXd v.u.3.'.3.3.3XCXC.3X X=XdXdXd.c.cXdXdXdXdXdXdX3 ].w P ].x ] ]XbX=XdXdXdXd.h.2.E.2.2.EXbXdXdXdXdXd o e hXU.q.q.0XdXdXdXdXdXd a W.N.H.zX5.+ [ [Xl",
+"XyXy.7.OXdXdXdXdX. BXBXdXdXBX<.2XV P.hXBXdXdXBXdXdXdXBXd bXC.3.3.3.3XCXCXC.u vXdXdXd b.'.u vXdXdXdXdXdX3 ] ] ].wXV : ] P vXdXdXdXd.hXV.2.2XG.;X=XdXdXdXBX9 V w.q.q.q h.fX=XdXdXdXBXdXdXi f.N.z.r.+ [ [Xl",
+".b.bXD.OXdXdXdXBX.XHXdXdXdXB EXVXV.pX=XdXdXdX9 vXdXdXdXdX=.3XC.3.3XC.3.3XC  XdXdXdXB ~.'.'X=XdXdXdXdXd._.x ].w.w.2.x.w PX=XdXdXdXd o pXVXV E.(XdXdXdXdXdX6 C w hXJ h.q.qXiXBXdXdXdXdXdXd jXeXZ.r.+ [ [Xl",
+".b.bXD.OXdXdXd.1.% BXdXdXdXB o pXVX9XBXdXdXBX  vXdXdXdXd bXC.3.3XCXCXCXC.u bXdXdXd b.u.3.' vXdXdXdXdXdX3.5.x.wXV.w.w.2 pX=XdXdXdXdX= oXpXp oXdXdXdXBXd b n w h h h hXJXJX..(XdXdXdXdXdXd.t 9XnXFX5 [ [Xl",
+"Xy.b.`.4XBXdXd s.AXHXdXdXdXdXBX<.wXdXdXdXd b.u vXdXdXdXdX=XC.3.3.3XCXCXC  XdXdXdXd.c.3.3XCX=XdXdXdXdXB.cXv ].x.x.2 #.! E vXdXdXdXdXdXBXdXdXdXdXdXd v o.;XU C w h h hXJX@XJ.v vXdXdXdXdXdXdXd r.KX5 [ [Xl",
+" Z Z.<XBXdXdXd s.AXHXdXdXdXd v.6X<XdXdXB vXC   vXdXdXdXB b ;XC ;.3XC.3XC.cXdXdXdXBX XC.3.3 vXdXdXdXdXdXB.6.2.2 w.@ t.qXBXdXdXdXdXdXdXdXdXdXdXdXdXBXt 8 w w w h h hXJXJXJ.qXJ 'XBXdXdXdXdXdXdXd.tX& [ [Xl",
+" Z Z.<XdXdXdXd.=X@XHXdXdXdXdXB.6 bXdXdXBX>XCXBXdXdXdXd b.uXC ;XC.3.3.3  XBXdXdXd.cXC.3.3.3 ~XBXdXdXdXdXB.dXG w w t =.nXdXdXdXdXdXdXdXdXdXdXdXdXd b 8 wXU w w w hXJXJXJXJXJ.AXJ ` vXdXdXBXdXdXdXd a !.UXl",
+"XyXyX4XdXdXdXd.=.qXHXdXdXdXd vXtXBXdXB bX>.pXdXdXdXdXd bXC.3XC.3.3.3XC ~XdXdXdXd.cX .uX .u  X=XdXdXdXdXB._ w t.kXzXz.VXdXdXdXdXBXB.( 9XdXdXdXdXd b 8 w w w w w h h hXJXJXJXJ.A.| '.(XBXdXdXdXdXdXBXAXLXl",
+".bXyX4XdXdXdXdX0.q.(XdXdXdXdXdX=XdXdXB.c.p.pXdXdXdXdXd bXC.3.3.3.3.3.u vXdXdXdXdXBX= vX= v bXBXdXdXdXdXB.6 CX%X:XqXq.kXdXdXdXdXd r.9Xu bXBXdXdXdXBXj w w C w h h h.- hXJXJX@.A.&.%X0 `XBXdXdXdXdXdXwXLXl",
+".b.}.4XdXBXdXB s.A.0XBXdXdXdXdXdXdXdX=._ ].pXdXdXdXdXd bXCXC.3.3XC.3.uXdXdXdXdXdXdXdXdXdXdXdXdXdXdXdXdXB.d hXzX:X: G.VXdXdXdXdXdXH.a.a EXdXdXdXdXdXt h w C h h h h hXJXJXJX@X@.&.:.& . 9XdXdXdXdXdXwXLXl",
+" Z.KXHXdXdXd ` /.A.8.(XdXBXdXdXdXdXBXtX<.5.5XdXdXdXdXd b ;.3.3.3XC.u bXdXdXdXdXdXdXdXdXdXdXdXdXdXdXdXdXdXH hX:Xq 2X: |XBXdXdXdXd B.a.V 8XdXdXdXdXd _ w C w w w.- h hXJXJXJX@X@.&.:.:Xo 9XdXdXBXdXdXwXLXl",
+"XyX4XdXdXdXd jXN /X@.0XdXdXdXdXdXdXBX<.w ] ~XdXdXdXd vX XCXC.3.3.3X XdXdXdXdXdXdXdXdXdXdXdXdXdXdXdXdXdXdX= >X:XN 2 AXBXdXdXdXd v qX%X%XsXdXdXdXdXdX=./ wXU h h h h h hXJXJX@X@.&.:.:Xo 9XdXdXdXdXdXwXLXl",
+"XyX4XdXdXdXd 5XN.V /XpXdXdXdXdXdXd.6XV.w ]XdXdXdXdXdX=.3.3.3.3XCX  bXdXdXdX=    X       .cX X X9XdXBXdXd.t.@XN 2 2.CXBXdXdXdXd 9 IXr GXsX8XdXdXdXdXd _ w C C h h h h h.qXJ.A.A.A.:.: l.(XdXdXdXdXdXwXLXl",
+".bX4XdXdXdXd 5 2Xz.k.0XdXdXdXdXdXB.2.2.w ]XdXdXdXdXd b.p.p.3.3.3.cXdXdXdX=.cXCXCXCXCXCXCXC.3XC.cXdXdXdXdX= >X: I y AXBXdXdXdXd 9 2 ) ).k.9XdXdXdXBXd o n w h h h h.v.L eXJXJ.A.&.: /.=.tXdXdXdXdXB.$.U 6",
+".bX4XdXdXdXBXn 2.V.k _XdXdXdXdXB.(XGXGXV ]XdXdXdXdXdX=.5.5.5.p ; ~XdXdXdX9XC.3XCXCXCXCXC.3.3.3 ~XdXdXdXd 9.lXN I y.CXBXdXdXdXd 9.T & & G.lXBXdXdXdXdXBXpXU.@ h h e.0XBX6X.X.X..8.=XuXiXBXdXdXdXB 9.I [Xl",
+".}.WXdXdXd a.C &X:Xz |XdXdXdXB.( nXGXG.w.xXdXBXdXdXd b.p ].5.p.cXBXdXd v  XC.3XCXCXC.3.3.3.3XC ~XdXdXdXdXBXj G GX7 sXBXdXdXdXd 9.] y &.].C BXdXdXdXdXdXH hXU h.q e.(XdXB.( 9.( 9 9 9XBXdXdXd vXA S [ [Xl",
+" QXBXdXdXdXk * DX:X%.WXBXBXB 9 nXU.EXG.w.5XdXdXdXdXd b ] ].pX>XBXdXdXdX9.pXC.3.3.3.3XC.3.3.3XC ~XdXdXdXdXdXBX%XrXxXiXdXdXdXdXd r.] y & 7X7 K vXdXdXdXd o hXUXJ.q.LXdXdXdXdXdXdXdXdXdXdXdXdXBXwXL.U [ [Xl",
+" kXdXdXdXd.< $.s I IX7 4 GXqXqX:Xq C C.w vXdXdXdXdXd ] ] ].xX3XdXdXdXd ~.3.3.5.3XCXC.3.3.3.p.p.cXBXdXdXdXdXdX: I IXwXdXdXdXdXd , 2 , 2 2.T.=XBXdXdXdXdXB _ hXU.q.LXdXdXdXdXdXdXdXdXdXd v 9.1.m [ [ [ [Xl",
+" Q B a a a.$.+XF ) ) &.sX- )X7X-.#Xf (X<.( vX= vX= v ] ] ] ]X= v v v bXC.3.p.3.3XC.3XC.3XC.3.3XvX9 vX=X=X=.( G I.j.1 B B B B B.T ,XN A GX%.8.( 9.(X= v 9Xj.q.q.q.vX= 9.( 9 r.( B r B r F.FX&., [ [ [ [Xl",
+".} Q Q.`.`XL M $X-X7 7X# LX7 &.#.#XO (.2X<.6._.d.6._ P ] ] ]._X3X X ._.5.5.5.5.p.p.p.p.p.5.5.5.pX<.6 p { K.9 IX7 & F F.K.C.C.CXr ,X%X%.V.kXs.8.8 KX../X..f.q.q.q.lXu.8.8X0 q q ^XmXm.C -XKXK.+ [ [ [ [Xl",
+"Xy 6XD.U [ [ [.P & & 7X#.#X-.#.# LXOXfXG.2XV.w ]XV P.w P.5 ] ].5 ].5.3.p.3.p.5.5.5.p.p.p.5.p ] ] ].2.*.!.@ =X-X- 7.sX# T.s D D & 2 2X:.A.nXs.n.n.n.qXUXs.q.q.A.n.A.A.A.V.VXN , D.F.F * XXK.r.+ [ [ [ [Xl",
+"XyXyXD [ [ [ [.,.# 7X7 &.#.#.#.#.#X: = CXGXGXG.2.2 ].w.w.w :.x.x ].5 ].5 ].5.5.5.5.5.5.5 ] ] ].wXV w.@.@ tX:X- 7 7X# d T TX;.F.# 7 ,XN.n.A.@.n mX@.q.q.q.A.n.kX%X%X%X%X%X% , 4.Q TXIXK.r.r 1 [ [ [ [ [Xl",
+" 6 6XD [ [ [ [ [XFX#X7 &.#.#.#.# LXOXO t C C CXU C.w.wXVXVXV.2 ] ] P ].x ].x :.w ].x.5.5 ].w.wXV C.A t.kXq GX- & 7X; T H d T T 7 D GX%.k t t /.A.n.q.A.V /.VXN , , y ,X%XN ,.].Q *.GXP 1 1.+ [ [ [ [ [Xl",
+".b.bXD [ [ [ [ [ $XFX$X7.#.#X-.#.#X-X$XqXU.* m ( <XV.2XV.w.2XV ].w ].w P ] ]XV.2 P.w.x ] ]XV.2.2 w.kXz.VXOX$ 2X- 7.s.Q.F T d H 7 yXN G.A.V.V.V.V.AX@.kXNXNXNX% 2.T.T 2XNXN 2 &.Z * *.r 1 M M [ [ [ [ [Xl",
+" 6 6XD [ [ [ [ [X5XD.#X$X-X-X-.# LX-X-X$XqXqXf =XfXU.q C.2XGXGXVXV.w P.w ]XVXV.2.w ] ] ].2XV.2XGXUXqX:XqX:X-X-X- 7.s 7 7X;X;X; D y 2X:X:XqX:X:X:X%X%X% G 2 I 2 y y.F y GXN 2 D TXI. .r 1.+ M [ [ [ [ [Xl",
+"XyXy.7 [ [ [ [ [ M.,X# &X7 IX7X7X-X-X-X-X7X7X$X$XO N NXq m C.E.2.2 ].w.w.w.2.2 :.2XV.2.2.2.2.2 C mX$XOXOXOX-.# LX;.#X7 &X# 7 7 7 7X-X$X$ 2X-X- 7 2 2 2 & & y &.F.F.s.F ) ) D.s TXKXK 1.+ M [ [ [ [ [ [Xl",
+" Z 6XD [ [ [ [ [ [ [XlX#X$ I N I IX$X$X$X$X$ IX$X7X7X7X-XO ( mXU C.E.2.2.2.2.E.E.Y.2.Y.Y.EXGXGXU mXqX$XOX$X$X- 7 L 7 7X- &X# 7 7.# 7X-X-.#X; 7 7 7 7 7 7 7 7.s TX;X#.s & & T T. XP.r M M [ [ [ [ [ [ [Xl",
+" Z Z.7 [ [ [ [ [ [ [.PX&X- N N N NXOXOX$X$X$XO IX-X-X7X-X-XzXq ( m.!.! :.2.Y.E.E.E.E.YXGXG C C.q mXqXOXOXOX$ 2X- 7 7 7 7X- L.s 7 L 7 &X- LX; L 7 T.s L.s.sX# TX# d TX;.# 7 T d. .r 1 M M [ [ [ [.U [ [Xl",
+"XyXyXD [ [ [ [ [ [ [., $.}X$ IXSXzXq N N NXOXOXqX$X-X-X-X7X-X-XOXO ( ( #.EXG.E.E.EXG.E.Y # <XU t = IXOX$X$X$X-X7X- &X- 7 L L.s L.# 7 L L L.s 7.sX#X; dX# d d T d T dX#X#X# dXFXP 1X5 M [ [ [ [ [ [ [ [Xl",
+" Z 6.7 [.U [ [ [ [ [ [.+ dX$X$XS = =Xf = = =XzXz NXO N NX$X-X-X-X$X$XOXqXq <.Y.EXG.EXG # C m tXqXOX-X-X-X$X$X$X$X7X- 7 L L LX;X#X# L.#X#X#X#X;X#X& d d d d d d d * TXI dXF. XK 1X5 M [ [ [ [ [ [ [ [ [Xl",
+"XyXyXD [ [ [ [ [ [ [ [ [.X.# &XOXOXz =Xf t t t t =XzXzXqXOXOXOXOX$XOX$XOX$ (XG # # # # C m.@ t ( tXqX$X$X$X-X7X-.# L.#.#.# LX#X#X# L LX; L LX#X# d.b d d d d xXFXF xXK. . XP 1 1 M M [ [ [ [ [ [ [ [ [Xl",
+"XyXyXD [ [ [ [ [ [ [ [ [.U.b.#XOXOXSXz =.n t t t = = =XzXq N N NXO N IX$X$XfXUXU # #.* # m m m.n tXq I IX7X$X7 &.# L.#.# L L LX#X# L L L 7.sX#X#X# dXF.o.o d.oXF x x. XKXKXP 1 1 M [ [ [ [ [ [ [ [ [ [Xl",
+"XyXy.7 [ [ [ [ [ [ [ [ [ [XDXlX7X$ IXSXzXf t =XfXf t t = = = =XzXq N N NXOXz =Xf m mXUXU.@ m mXf =X$.# &X-X7 &X-.# LX-.#.#X#X# L.# 7 LX#X# LX#X# d.b dXF xXF x x x.D.D.DXP 1X5 M [ [ [ [ [ [ [ [ [ [ [Xl",
+"Xy.bXD [ [ [ [ [ [ [ [ [ [ M.7 LX7 N IXOXz =Xf t.n = = = = = = = =XzXzXz NX%X:X:XqXf t m m m tXqXOX-.s.#.#X7X7X7 & &X-X7.# L L 7.# 7.#X#X#.#X#.# d d d. . .  x xXPXK xXP.DX5 M M [ [ [ [ [.U [ [ [ [ [Xl",
+"XyXy.7 [ [ [ [ [ [ [ [ [ [ [.+.}.#X$ IXO = = = =Xf = = = =Xf = = =XzXzXqX:XqX: NXz =.k t t t tXzXOX-.#.#X7X7X7X7X7X7 &.#.#X#.#.s.#.#X#X#X#.# L L d d d. XFXF x x.DXKXPXX.r.+ M [ [ [ [ [ [ [ [ [ [ [ [Xl",
+"Xy ZXD [ [ [ [ [ [ [ [ [ [ [ [XDXyX- & IXSXS NXz =XzXzXz = =XzXqXqXSXq NX: N N I NX: N NXz =Xz N I IX$ I I I I I IX7X-.#X-.#.#.#.#.s L.#.s.#X# LX& d d Z x $ xXPXP.DXXX5X5 M [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+" Z 6XD [ [ [ [ [ [ [ [ [ [ [ [ [.U Z.bX7 IX7XO NXSXzXSXSXzXSXSXO NXqX: N N I N N N I N I N NXS I N I NXO N I IX7.jX7X7X7X7X7 & &X7.#.#.#.s.#X#X#X& d d x x x xXX.DXX 1 M M [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+" Z Z.7 [ [ [ [ [ [ [ [ [ [ [ [ [ [.X ZX7X-X$ I I N NXqXSXzXq N N NX:Xz N N I N N I I N I I N N I N I N N N IX7X$ )X7X7X7X7X7X7X7X-.#X-.s.#.sX#.bX&.b d x $ $ xXXXXXXX5 M [ [ [ [ [ [ [.U [ [ [ [ [ [ [Xl",
+"XyXyXD [ [ [ [ [ [ [ [ [ [ [ [ [ [.U.X.} &X- IX7 I N I IXS I N I IXS N I N IXO I IX7 I I I I I I I I.j I I I IX7 IX7X7 )X7X7X7X7X7 &.#.#.#.#.sX#X& d d $ x x.DXXXXX5.+ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+" ZXy.7 [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [.7.bX#X-X- &X7X7 ) I I I I I I I I I IX7X7X-X-X- &X7 IX7 I.j I I ) I ) I I I I ) I ) & &X7X7 & &X-.#.#.s.sX& d *.o x.o.oX5.+.+ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+"XyXyXD [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [.7.7.#.#.# & &X7 2 ) I G ) ) ) )X7X7X7X7X-.# &X-X7X$ I I I.j GXrXr G G G ) 2 ) 2.] y y D D D D &.#.#.F.F d d x x x $X5 M M [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+".bXyXD [ [ [ [ [ [ [ [ [ [ [ [ [.U [ [ [.+.X.}.#.# & yX7 2 ) ) G G ) ).]X7X7X7X7.#.#X7X7X7 I I I I G G G G GXN , 2 2 2 2 2.T y y 7 y.Q & 7.s.F.F T d x.o $XX.X [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+" 6 6XD [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [.X L.#X- &X7 2 2 2 2 2 )XrX7X7X7X7Xr.j NXO IXOXOXNXN lXoXo 3 f.NXoXo.J.JXhXhXh.RX, y.Q yX;X;X; d dXIXF.D 1 1X5 M [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+"Xy Z.7 [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [.U Z.m.m LX7X7 2 2XNXN lXN 2 ,XNXNX%X%X:X% 3 lX+X+X+.^.^.B.^.{.{.{ f fXo.N.JXh.SXhX,X, - - H.GXIXP.r 1 M M [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+" Z 6XD [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ M M.X d.#.#X-X-XNXNXN lXNXNX% 3 3 3 3.{ 0 0 % %Xc.^.^.^.&.:.&.{.{.{.{ f f.JX,Xh.R.R.R.R HXK x 1X5 M [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+" Z ZXD [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [.+XD L.b LX- 2 2 )XN 2 2.JX%.{XNXoX+ 0 %X1X1Xc.^.^.&.&.:.{.{.{ 3 3Xo.NXhXhXZ.S.S.R Y.G.r.r 1.+ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+"XyXyXD [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ M.+.P.o Z.b L L.#X- 7 7 2 2 y.TX+ % % %X1.^.&.&.& 3Xo 3XoXo.J.J.N U U.H...S.S.G.G.r.+ M M [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+"Xy ZXD [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ M M.X 1.P.o.b dX#X#X; y 2Xh f f 0X+ f fX+ f.NXhXhXh.T.SXh.S.S.S Y YXI.o 1X5 M [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+".b.bXD [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [.U [ [ [ [ [ [ M M.X 1.o.b d dX; 7 7 2XNXoXo f U.H.H.N U.R.R.R.R.R.R.S Y YXI.oX5 M M [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [.U [ [ [ [ [ [Xl",
+" Z 6.7 [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ M.+.+.P 1.P.o d d LX;X; 7 y.R.R.R.RX; H HXI.GXIXIXI.o.rX5.+ M M [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+"XyXyXD [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ M M M M.+.+.+.X.P.P.P.P.P.P 1.P 1 1 1 1.+.+ M M M M [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+" Z Z.7 [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ M M [ M M M M M M M M M [ M [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+" Z 6.7 [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [ [Xl",
+"XyXyXl.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U.U [Xl",
+" Z ZXy.b.bXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXy.bXy.bXy.bXy.bXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXyXy.b L"
+};
Index: /tags/Mars_V0-8-5/Mars/mastro/AstroIncl.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mastro/AstroIncl.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mastro/AstroIncl.h	(revision 9661)
@@ -0,0 +1,7 @@
+#ifndef __CINT__
+
+#include <TArrayC.h>
+#include "MArrayB.h"
+#include "MArrayS.h"
+
+#endif // __CINT__
Index: /tags/Mars_V0-8-5/Mars/mastro/AstroLinkDef.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mastro/AstroLinkDef.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mastro/AstroLinkDef.h	(revision 9661)
@@ -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 MVector3+;
+
+#pragma link C++ class MAstro+;
+#pragma link C++ class MAstroSky2Local+;
+#pragma link C++ class MAstroCatalog+;
+#pragma link C++ class MAstroCamera+;
+
+#pragma link C++ class MObservatory+;
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mastro/MAstro.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mastro/MAstro.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mastro/MAstro.cc	(revision 9661)
@@ -0,0 +1,406 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MAstro
+// ------
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MAstro.h"
+
+#include <iostream>
+
+#include <TVector3.h> // TVector3
+
+#include "MTime.h"    // MTime::GetGmst
+
+using namespace std;
+
+ClassImp(MAstro);
+
+Double_t MAstro::Trunc(Double_t val)
+{
+    // dint(A) - truncate to nearest whole number towards zero (double)
+    return val<0 ? TMath::Ceil(val) : TMath::Floor(val);
+}
+
+Double_t MAstro::Round(Double_t val)
+{
+    // dnint(A) - round to nearest whole number (double)
+    return val<0 ? TMath::Ceil(val-0.5) : TMath::Floor(val+0.5);
+}
+
+Double_t MAstro::Hms2Sec(Int_t deg, UInt_t min, Double_t sec, Char_t sgn)
+{
+    const Double_t rc = TMath::Sign((60.0 * (60.0 * (Double_t)TMath::Abs(deg) + (Double_t)min) + sec), (Double_t)deg);
+    return sgn=='-' ? -rc : rc;
+}
+
+Double_t MAstro::Dms2Rad(Int_t deg, UInt_t min, Double_t sec, Char_t sgn)
+{
+    // pi/(180*3600):  arcseconds to radians
+    //#define DAS2R 4.8481368110953599358991410235794797595635330237270e-6
+    return Hms2Sec(deg, min, sec, sgn)*TMath::Pi()/(180*3600)/**DAS2R*/;
+}
+
+Double_t MAstro::Hms2Rad(Int_t hor, UInt_t min, Double_t sec, Char_t sgn)
+{
+    // pi/(12*3600):  seconds of time to radians
+//#define DS2R 7.2722052166430399038487115353692196393452995355905e-5
+    return Hms2Sec(hor, min, sec, sgn)*TMath::Pi()/(12*3600)/**DS2R*/;
+}
+
+Double_t MAstro::Dms2Deg(Int_t deg, UInt_t min, Double_t sec, Char_t sgn)
+{
+    return Hms2Sec(deg, min, sec, sgn)/3600.;
+}
+
+Double_t MAstro::Hms2Deg(Int_t hor, UInt_t min, Double_t sec, Char_t sgn)
+{
+    return Hms2Sec(hor, min, sec, sgn)/240.;
+}
+
+Double_t MAstro::Dms2Hor(Int_t deg, UInt_t min, Double_t sec, Char_t sgn)
+{
+    return Hms2Sec(deg, min, sec, sgn)/54000.;
+}
+
+Double_t MAstro::Hms2Hor(Int_t hor, UInt_t min, Double_t sec, Char_t sgn)
+{
+    return Hms2Sec(hor, min, sec, sgn)/3600.;
+}
+
+void MAstro::Day2Hms(Double_t day, Char_t &sgn, UShort_t &hor, UShort_t &min, UShort_t &sec)
+{
+    /* Handle sign */
+    sgn = day<0?'-':'+';
+
+    /* Round interval and express in smallest units required */
+    Double_t a = Round(86400. * TMath::Abs(day)); // Days to seconds
+
+    /* Separate into fields */
+    const Double_t ah = Trunc(a/3600.);
+    a -= ah * 3600.;
+    const Double_t am = Trunc(a/60.);
+    a -= am * 60.;
+    const Double_t as = Trunc(a);
+
+    /* Return results */
+    hor = (UShort_t)ah;
+    min = (UShort_t)am;
+    sec = (UShort_t)as;
+}
+
+void MAstro::Rad2Hms(Double_t rad, Char_t &sgn, UShort_t &deg, UShort_t &min, UShort_t &sec)
+{
+    Day2Hms(rad/(TMath::Pi()*2), sgn, deg, min, sec);
+}
+
+void MAstro::Rad2Dms(Double_t rad, Char_t &sgn, UShort_t &deg, UShort_t &min, UShort_t &sec)
+{
+    Rad2Hms(rad*15, sgn, deg, min, sec);
+}
+
+void MAstro::Deg2Dms(Double_t d, Char_t &sgn, UShort_t &deg, UShort_t &min, UShort_t &sec)
+{
+    Day2Hms(d/24, sgn, deg, min, sec);
+}
+
+void MAstro::Deg2Hms(Double_t d, Char_t &sgn, UShort_t &deg, UShort_t &min, UShort_t &sec)
+{
+    Rad2Hms(d/360, sgn, deg, min, sec);
+}
+
+void MAstro::Hor2Dms(Double_t h, Char_t &sgn, UShort_t &deg, UShort_t &min, UShort_t &sec)
+{
+    Day2Hms(h*15/24, sgn, deg, min, sec);
+}
+
+void MAstro::Hor2Hms(Double_t h, Char_t &sgn, UShort_t &deg, UShort_t &min, UShort_t &sec)
+{
+    Day2Hms(h/24, sgn, deg, min, sec);
+}
+
+void MAstro::Day2Hm(Double_t day, Char_t &sgn, UShort_t &hor, Double_t &min)
+{
+    /* Handle sign */
+    sgn = day<0?'-':'+';
+
+    /* Round interval and express in smallest units required */
+    Double_t a = Round(86400. * TMath::Abs(day)); // Days to seconds
+
+    /* Separate into fields */
+    const Double_t ah = Trunc(a/3600.);
+    a -= ah * 3600.;
+
+    /* Return results */
+    hor = (UShort_t)ah;
+    min = a/60.;
+}
+
+void MAstro::Rad2Hm(Double_t rad, Char_t &sgn, UShort_t &deg, Double_t &min)
+{
+    Day2Hm(rad/(TMath::Pi()*2), sgn, deg, min);
+}
+
+void MAstro::Rad2Dm(Double_t rad, Char_t &sgn, UShort_t &deg, Double_t &min)
+{
+    Rad2Hm(rad*15, sgn, deg, min);
+}
+
+void MAstro::Deg2Dm(Double_t d, Char_t &sgn, UShort_t &deg, Double_t &min)
+{
+    Day2Hm(d/24, sgn, deg, min);
+}
+
+void MAstro::Deg2Hm(Double_t d, Char_t &sgn, UShort_t &deg, Double_t &min)
+{
+    Rad2Hm(d/360, sgn, deg, min);
+}
+
+void MAstro::Hor2Dm(Double_t h, Char_t &sgn, UShort_t &deg, Double_t &min)
+{
+    Day2Hm(h*15/24, sgn, deg, min);
+}
+
+void MAstro::Hor2Hm(Double_t h, Char_t &sgn, UShort_t &deg, Double_t &min)
+{
+    Day2Hm(h/24, sgn, deg, min);
+}
+
+// --------------------------------------------------------------------------
+//
+// Interpretes a string ' - 12 30 00.0' or '+ 12 30 00.0'
+// as floating point value -12.5 or 12.5. If interpretation is
+// successfull kTRUE is returned, otherwise kFALSE. ret is not
+// touched if interpretation was not successfull. The successfull
+// interpreted part is removed from the TString.
+//
+Bool_t MAstro::String2Angle(TString &str, Double_t &ret)
+{
+    Char_t  sgn;
+    Int_t   d, len;
+    UInt_t  m;
+    Float_t s;
+
+    // Skip whitespaces before %c and after %f
+    int n=sscanf(str.Data(), " %c %d %d %f %n", &sgn, &d, &m, &s, &len);
+
+    if (n!=4 || (sgn!='+' && sgn!='-'))
+        return kFALSE;
+
+    str.Remove(0, len);
+
+    ret = Dms2Deg(d, m, s, sgn);
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Interpretes a string '-12:30:00.0', '12:30:00.0' or '+12:30:00.0'
+// as floating point value -12.5, 12.5 or 12.5. If interpretation is
+// successfull kTRUE is returned, otherwise kFALSE. ret is not
+// touched if interpretation was not successfull.
+//
+Bool_t MAstro::Coordinate2Angle(const TString &str, Double_t &ret)
+{
+    Char_t  sgn = str[0]=='-' ? '-' : '+';
+    Int_t   d;
+    UInt_t  m;
+    Float_t s;
+
+    const int n=sscanf(str[0]=='+'||str[0]=='-' ? str.Data()+1 : str.Data(), "%d:%d:%f", &d, &m, &s);
+
+    if (n!=3)
+        return kFALSE;
+
+    ret = Dms2Deg(d, m, s, sgn);
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Return year y, month m and day d corresponding to Mjd.
+//
+void MAstro::Mjd2Ymd(UInt_t mjd, UShort_t &y, Byte_t &m, Byte_t &d)
+{
+    // Express day in Gregorian calendar
+    const ULong_t jd   = mjd + 2400001;
+    const ULong_t n4   = 4*(jd+((6*((4*jd-17918)/146097))/4+1)/2-37);
+    const ULong_t nd10 = 10*(((n4-237)%1461)/4)+5;
+
+    y = n4/1461L-4712;
+    m = ((nd10/306+2)%12)+1;
+    d = (nd10%306)/10+1;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Return Mjd corresponding to year y, month m and day d.
+//
+Int_t MAstro::Ymd2Mjd(UShort_t y, Byte_t m, Byte_t d)
+{
+    // Month lengths in days
+    static int months[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
+
+    // Validate month
+    if (m<1 || m>12)
+        return -1;
+
+    // Allow for leap year
+    months[1] = (y%4==0 && (y%100!=0 || y%400==0)) ? 29 : 28;
+
+    // Validate day
+    if (d<1 || d>months[m-1])
+        return -1;
+
+    // Precalculate some values
+    const Byte_t  lm = 12-m;
+    const ULong_t lm10 = 4712 + y - lm/10;
+
+    // Perform the conversion
+    return 1461L*lm10/4 + (306*((m+9)%12)+5)/10 - (3*((lm10+188)/100))/4 + d - 2399904;
+}
+
+// --------------------------------------------------------------------------
+//
+//  theta0, phi0    [rad]: polar angle/zenith distance, azimuth of 1st object
+//  theta1, phi1    [rad]: polar angle/zenith distance, azimuth of 2nd object
+//  AngularDistance [rad]: Angular distance between two objects
+//
+Double_t MAstro::AngularDistance(Double_t theta0, Double_t phi0, Double_t theta1, Double_t phi1)
+{
+    TVector3 v0(1);
+    v0.Rotate(phi0, theta0);
+
+    TVector3 v1(1);
+    v1.Rotate(phi1, theta1);
+
+    return v0.Angle(v1);
+}
+
+// --------------------------------------------------------------------------
+//
+// Calls MTime::GetGmst() Better use MTime::GetGmst() directly
+//
+Double_t MAstro::UT2GMST(Double_t ut1)
+{
+    return MTime(ut1).GetGmst();
+}
+
+// --------------------------------------------------------------------------
+//
+// RotationAngle 
+// 
+// calculates the angle for the rotation of the sky coordinate system
+// with respect to the local coordinate system. This is identical
+// to the rotation angle of the sky image in the camera.
+//
+//  sinl  [rad]: sine of observers latitude
+//  cosl  [rad]: cosine of observers latitude
+//  theta [rad]: polar angle/zenith distance
+//  phi   [rad]: rotation angle/azimuth
+//
+// Return sin/cos component of angle
+//
+// The convention is such, that the rotation angle is -pi/pi if
+// right ascension and local rotation angle are counted in the
+// same direction, 0 if counted in the opposite direction.
+//
+// (In other words: The rotation angle is 0 when the source culminates)
+//
+// Using vectors it can be done like:
+//    TVector3 v, p;
+//    v.SetMagThetaPhi(1, theta, phi);
+//    p.SetMagThetaPhi(1, TMath::Pi()/2-latitude, 0);
+//    v = v.Cross(l)); 
+//    v.RotateZ(-phi);
+//    v.Rotate(-theta)
+//    rho = TMath::ATan2(v(2), v(1));
+//
+// For more information see TDAS 00-11, eqs. (18) and (20)
+//
+void MAstro::RotationAngle(Double_t sinl, Double_t cosl, Double_t theta, Double_t phi, Double_t &sin, Double_t &cos)
+{
+    const Double_t sint = TMath::Sin(theta);
+    const Double_t cost = TMath::Cos(theta);
+
+    const Double_t snlt = sinl*sint;
+    const Double_t cslt = cosl*cost;
+
+    const Double_t sinp = TMath::Sin(phi);
+    const Double_t cosp = TMath::Cos(phi);
+
+    const Double_t v1 = sint*sinp;
+    const Double_t v2 = cslt - snlt*cosp;
+
+    const Double_t denom = TMath::Sqrt(v1*v1 + v2*v2);
+
+    sin =   cosl*sinp      / denom; // y-component
+    cos = (snlt-cslt*cosp) / denom; // x-component
+}
+
+// --------------------------------------------------------------------------
+//
+// RotationAngle 
+// 
+// calculates the angle for the rotation of the sky coordinate system
+// with respect to the local coordinate system. This is identical
+// to the rotation angle of the sky image in the camera.
+//
+//  sinl  [rad]: sine of observers latitude
+//  cosl  [rad]: cosine of observers latitude
+//  theta [rad]: polar angle/zenith distance
+//  phi   [rad]: rotation angle/azimuth
+//
+// Return angle [rad] in the range -pi, pi
+//
+// The convention is such, that the rotation angle is -pi/pi if
+// right ascension and local rotation angle are counted in the
+// same direction, 0 if counted in the opposite direction.
+//
+// (In other words: The rotation angle is 0 when the source culminates)
+//
+// Using vectors it can be done like:
+//    TVector3 v, p;
+//    v.SetMagThetaPhi(1, theta, phi);
+//    p.SetMagThetaPhi(1, TMath::Pi()/2-latitude, 0);
+//    v = v.Cross(l)); 
+//    v.RotateZ(-phi);
+//    v.Rotate(-theta)
+//    rho = TMath::ATan2(v(2), v(1));
+//
+// For more information see TDAS 00-11, eqs. (18) and (20)
+//
+Double_t MAstro::RotationAngle(Double_t sinl, Double_t cosl, Double_t theta, Double_t phi)
+{
+    const Double_t snlt = sinl*TMath::Sin(theta);
+    const Double_t cslt = cosl*TMath::Cos(theta);
+
+    const Double_t sinp = TMath::Sin(phi);
+    const Double_t cosp = TMath::Cos(phi);
+
+    return TMath::ATan2(cosl*sinp, snlt-cslt*cosp);
+}
Index: /tags/Mars_V0-8-5/Mars/mastro/MAstro.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mastro/MAstro.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mastro/MAstro.h	(revision 9661)
@@ -0,0 +1,59 @@
+#ifndef MARS_MAstro
+#define MARS_MAstro
+
+#ifndef ROOT_TROOT
+#include <TROOT.h>
+#endif
+
+class MAstro
+{
+private:
+    static Double_t Round(Double_t val);
+    static Double_t Trunc(Double_t val);
+
+public:
+    // Angle/Time conversion functions
+    static Double_t Hms2Sec(Int_t deg, UInt_t min, Double_t sec, char sgn='+');
+    static Double_t Dms2Rad(Int_t deg, UInt_t min, Double_t sec, Char_t sgn='+');
+    static Double_t Hms2Rad(Int_t hor, UInt_t min, Double_t sec, Char_t sgn='+');
+    static Double_t Dms2Deg(Int_t deg, UInt_t min, Double_t sec, Char_t sgn='+');
+    static Double_t Hms2Deg(Int_t hor, UInt_t min, Double_t sec, Char_t sgn='+');
+    static Double_t Dms2Hor(Int_t deg, UInt_t min, Double_t sec, Char_t sgn='+');
+    static Double_t Hms2Hor(Int_t hor, UInt_t min, Double_t sec, Char_t sgn='+');
+
+    static void Day2Hms(Double_t rad, Char_t &sgn, UShort_t &deg, UShort_t &min, UShort_t &sec);
+    static void Rad2Dms(Double_t rad, Char_t &sgn, UShort_t &deg, UShort_t &min, UShort_t &sec);
+    static void Rad2Hms(Double_t rad, Char_t &sgn, UShort_t &deg, UShort_t &min, UShort_t &sec);
+    static void Deg2Dms(Double_t rad, Char_t &sgn, UShort_t &deg, UShort_t &min, UShort_t &sec);
+    static void Deg2Hms(Double_t rad, Char_t &sgn, UShort_t &deg, UShort_t &min, UShort_t &sec);
+    static void Hor2Dms(Double_t rad, Char_t &sgn, UShort_t &deg, UShort_t &min, UShort_t &sec);
+    static void Hor2Hms(Double_t rad, Char_t &sgn, UShort_t &deg, UShort_t &min, UShort_t &sec);
+
+    static void Day2Hm(Double_t rad, Char_t &sgn, UShort_t &deg, Double_t &min);
+    static void Rad2Dm(Double_t rad, Char_t &sgn, UShort_t &deg, Double_t &min);
+    static void Rad2Hm(Double_t rad, Char_t &sgn, UShort_t &deg, Double_t &min);
+    static void Deg2Dm(Double_t rad, Char_t &sgn, UShort_t &deg, Double_t &min);
+    static void Deg2Hm(Double_t rad, Char_t &sgn, UShort_t &deg, Double_t &min);
+    static void Hor2Dm(Double_t rad, Char_t &sgn, UShort_t &deg, Double_t &min);
+    static void Hor2Hm(Double_t rad, Char_t &sgn, UShort_t &deg, Double_t &min);
+
+    // Angle treatment functions
+    static Bool_t String2Angle(TString &str, Double_t &ret);
+    static Bool_t Coordinate2Angle(const TString &str, Double_t &ret);
+
+    static Double_t AngularDistance(Double_t theta0, Double_t phi0, Double_t theta1, Double_t phi1);
+
+    // Time treatment functions
+    static void  Mjd2Ymd(UInt_t mjd, UShort_t &y, Byte_t &m, Byte_t &d);
+    static Int_t Ymd2Mjd(UShort_t y, Byte_t m, Byte_t d);
+
+    static Double_t UT2GMST(Double_t ut1);
+
+    // Rotation angle between local and sky coordinate system
+    static void     RotationAngle(Double_t sinl, Double_t cosl, Double_t theta, Double_t phi, Double_t &sin, Double_t &cos);
+    static Double_t RotationAngle(Double_t sinl, Double_t cosl, Double_t theta, Double_t phi);
+
+    ClassDef(MAstro, 0)
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mastro/MAstroCamera.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mastro/MAstroCamera.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mastro/MAstroCamera.cc	(revision 9661)
@@ -0,0 +1,565 @@
+/*====================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without expressed
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 3/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MAstroCamera
+// ============
+//
+// A tools displaying stars from a catalog in the camera display.
+// PRELIMINARY!!
+//
+//
+// Usage:
+// ------
+// For a usage example see macros/starfield.C
+//
+// To be able to reflect the star-light you need the geometry of the
+// mirror and the distance of the plain screen.
+//
+// You can get the mirror geometry from a MC file and the distance of
+// the screen from MGeomCam.
+//
+//
+// Algorithm:
+// ----------
+// The calculation of the position of the reflection in the camera is
+// done by:
+//   - Rotation of the star-field such that the camera is looking into
+//     the pointing direction
+//   - Calculation of the reflected star-light vector by calling
+//     MGeomMirror::GetReflection (which returns the point at which
+//     the vector hits the camera plain)
+//   - Depending on the draw-option you get each reflected point, the
+//     reflection on a virtual ideal mirror or the reflection on each
+//     individual mirror
+//
+//
+// GUI:
+// ----
+//  * You can use the the cursor keys to change the pointing position
+//    and plus/minus to change the time by a quarter of an hour.
+//
+// ToDo:
+// -----
+//  * possibility to overwrite distance from mirror to screen
+//  * read the mirror geometry directly from the MC input file
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MAstroCamera.h"
+
+#include <errno.h>        // strerror
+#include <fstream>        // ifstream
+
+#include <KeySymbols.h>   // kKey_*
+
+#include <TH2.h>          // TH2D
+#include <TMarker.h>      // TMarker
+#include <TVirtualPad.h>  // gPad
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MGeomCam.h"
+#include "MGeomMirror.h"
+
+#include "MTime.h"
+#include "MAstroSky2Local.h"
+#include "MObservatory.h"
+
+#include "../mhist/MHCamera.h" // FIXME: This dependancy is very bad!
+                      // HOW TO GET RID OF IT? Move MHCamera to mgeom?
+
+// FIXME: remove comments as soon as MStarLocalPos official part of MARS
+//#include "MStarLocalPos.h"
+// FIXME: remove comments as soon as MStarLocalPos official part of MARS
+
+ClassImp(MAstroCamera);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Create a virtual MGeomMirror which is in the center of the coordinate
+// system and has a normal vector in z-direction.
+//
+MAstroCamera::MAstroCamera() : fGeom(0), fMirrors(0)
+{
+    fMirror0 = new MGeomMirror;
+    fMirror0->SetMirrorContent(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete fGeom, fMirrors and the virtual 0-Mirror fMirror0
+//
+MAstroCamera::~MAstroCamera()
+{
+    if (fGeom)
+        delete fGeom;
+    if (fMirrors)
+        delete fMirrors;
+
+    delete fMirror0;
+
+}
+
+// --------------------------------------------------------------------------
+//
+// Set a list of mirrors. The Mirrors must be of type MGeomMirror and
+// stored in a TClonesArray
+//
+void MAstroCamera::SetMirrors(TClonesArray &arr)
+{
+    if (arr.GetClass()!=MGeomMirror::Class())
+    {
+      cout << "ERROR - TClonesArray doesn't contain objects of type MGeomMirror... ignored." << endl;
+      return;
+    }
+
+    const Int_t n = arr.GetSize();
+
+    if (!fMirrors)
+        fMirrors = new TClonesArray(MGeomMirror::Class(), n);
+
+    fMirrors->ExpandCreate(n);
+
+    for (int i=0; i<n; i++)
+        memcpy((*fMirrors)[i], arr[i], sizeof(MGeomMirror));
+
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Read the mirror geometry from a MC .def file. The following
+// structure is expected:
+//
+// #*  TYPE=1  (MAGIC)
+// #*      i  f   sx   sy   x   y   z   thetan  phin 
+// #* 
+// #*       i : number of the mirror
+// #*       f : focal distance of that mirror
+// #*      sx : curvilinear coordinate of mirror's center in X[cm]
+// #*      sy : curvilinear coordinate of mirror's center in X[cm]
+// #*       x : x coordinate of the center of the mirror [cm]
+// #*       y : y coordinate of the center of the mirror [cm]
+// #*       z : z coordinate of the center of the mirror [cm]
+// #*  thetan : polar theta angle of the direction where the mirror points to
+// #*    phin : polar phi angle of the direction where the mirror points to
+// #*      xn : xn coordinate of the normal vector in the center (normalized)
+// #*      yn : yn coordinate of the normal vector in the center (normalized)
+// #*      zn : zn coordinate of the normal vector in the center (normalized)
+// #
+// define_mirrors
+//   1 1700.9200   25.0002   75.0061   25.0000   75.0000    0.9207 0.02328894 1.24904577 -0.00736394 -0.02209183 0.99972882
+//   2 ...
+//
+void MAstroCamera::SetMirrors(const char *fname)
+{
+    ifstream fin(fname);
+    if (!fin)
+    {
+        gLog << err << "Cannot open file " << fname << ": ";
+        gLog << strerror(errno) << endl;
+        return;
+    }
+
+    TString line;
+    while (1)
+    {
+        line.ReadLine(fin);
+        if (!fin)
+            return;
+
+        line = line.Strip(TString::kBoth);
+
+        if (line.BeginsWith("n_mirrors"))
+        {
+            Int_t n;
+            sscanf(line.Data(), "%*s %d", &n);
+
+            if (!fMirrors)
+                fMirrors = new TClonesArray(MGeomMirror::Class(), n);
+
+            fMirrors->ExpandCreate(n);
+            continue;
+        }
+
+
+        Int_t id;
+        Float_t f, sx, sy, x, y, z, thetan, phin, xn, yn, zn;
+
+        const Int_t n = sscanf(line.Data(), "%d %f %f %f %f %f %f %f %f %f %f %f",
+                               &id, &f, &sx, &sy, &x, &y, &z, &thetan,
+                               &phin, &xn, &yn, &zn);
+        if (n!=12)
+            continue;
+
+        new ((*fMirrors)[id-1]) MGeomMirror;
+        ((MGeomMirror*)(*fMirrors)[id-1])->SetMirrorContent(id, f, sx, sy, x, y, z, thetan, phin, xn, yn, zn);
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the camera geometry. The MGeomCam object is cloned.
+//
+void MAstroCamera::SetGeom(const MGeomCam &cam)
+{
+    if (fGeom)
+        delete fGeom;
+
+    fGeom = (MGeomCam*)cam.Clone();
+}
+
+// --------------------------------------------------------------------------
+//
+// Convert To Pad coordinates (see MAstroCatalog)
+//
+Int_t MAstroCamera::ConvertToPad(const TVector3 &w, TVector2 &v) const
+{
+    /*
+     --- Use this to plot the 'mean grid' instead of the grid of a
+         theoretical central mirror ---
+
+        TVector3 spot;
+        const Int_t num = fConfig->GetNumMirror();
+        for (int i=0; i<num; i++)
+        spot += fConfig->GetMirror(i).GetReflection(w, fGeom->GetCameraDist())*1000;
+        spot *= 1./num;
+        */
+
+    const TVector3 spot = fMirror0->GetReflection(w, fGeom->GetCameraDist())*1000;
+    v.Set(spot(0), spot(1));
+
+    const Float_t max = fGeom->GetMaxRadius()*0.70;
+    return v.X()>-max && v.Y()>-max && v.X()<max && v.Y()<max;
+}
+
+// --------------------------------------------------------------------------
+//
+// Find an object with a given name in the list of primitives of this pad.
+//
+TObject *FindObjectInPad(const char *name, TVirtualPad *pad)
+{
+    if (!pad)
+        pad = gPad;
+
+    if (!pad)
+        return NULL;
+
+    TObject *o;
+
+    TIter Next(pad->GetListOfPrimitives());
+    while ((o=Next()))
+    {
+        if (o->InheritsFrom(gROOT->GetClass(name)))
+            return o;
+
+        if (o->InheritsFrom("TPad"))
+            if ((o = FindObjectInPad(name, (TVirtualPad*)o)))
+                return o;
+    }
+    return NULL;
+}
+
+// --------------------------------------------------------------------------
+//
+// Options:
+//
+//  '*' Draw the mean of the reflections on all mirrors
+//  '.' Draw a dot for the reflection on each individual mirror
+//  'h' To create a TH2D of the star-light which is displayed
+//  'c' Use the underlaying MHCamera as histogram
+//  '0' Draw the reflection on a virtual perfect mirror
+//  '=' Draw '0' or '*' propotional to the star magnitude
+//
+// If the Pad contains an object MHCamera of type MHCamera it is used.
+// Otherwise a new object is created.
+//
+void MAstroCamera::AddPrimitives(TString o)
+{
+    if (!fTime || !fObservatory || !fMirrors)
+    {
+      cout << "Missing data..." << endl;
+        return;
+    }
+
+    if (o.IsNull())
+        o = "*.";
+
+    const Bool_t hasnull = o.Contains("0", TString::kIgnoreCase);
+    const Bool_t hashist = o.Contains("h", TString::kIgnoreCase);
+    const Bool_t hasmean = o.Contains("*", TString::kIgnoreCase);
+    const Bool_t hasdot  = o.Contains(".", TString::kIgnoreCase);
+    const Bool_t usecam  = o.Contains("c", TString::kIgnoreCase);
+    const Bool_t resize  = o.Contains("=", TString::kIgnoreCase);
+
+    // Get camera
+    MHCamera *camera=(MHCamera*)FindObjectInPad("MHCamera", gPad);
+    if (camera)
+    {
+        if (!camera->GetGeometry() || camera->GetGeometry()->IsA()!=fGeom->IsA())
+            camera->SetGeometry(*fGeom);
+    }
+    else
+    {
+        camera = new MHCamera(*fGeom);
+        camera->SetName("MHCamera");
+        camera->SetStats(0);
+        camera->SetInvDeepBlueSeaPalette();
+        camera->SetBit(kCanDelete);
+        camera->Draw();
+    }
+
+    camera->SetTitle(GetPadTitle());
+
+    gPad->cd(1);
+
+    if (!usecam)
+    {
+        if (camera->GetEntries()==0)
+            camera->SetBit(MHCamera::kNoLegend);
+    }
+    else
+    {
+        camera->Reset();
+        camera->SetYTitle("arb.cur");
+    }
+
+    TH2 *h=0;
+    if (hashist)
+    {
+        TH2F hist("","", 90, -650, 650, 90, -650, 650);
+        hist.SetMinimum(0);
+        h = (TH2*)hist.DrawCopy("samecont1");
+    }
+
+    const TRotation rot(GetGrid(kTRUE));
+
+    MVector3 *radec;
+    TIter Next(&fList);
+
+    while ((radec=(MVector3*)Next()))
+    {
+        const Double_t mag = radec->Magnitude();
+        if (mag>GetLimMag())
+            continue;
+
+        TVector3 star(*radec);
+
+        // Rotate Star into telescope system
+        star *= rot;
+
+        TVector3 mean;
+
+        Int_t num = 0;
+
+        MGeomMirror *mirror = 0;
+        TIter NextM(fMirrors);
+        while ((mirror=(MGeomMirror*)NextM()))
+        {
+            const TVector3 spot = mirror->GetReflection(star, fGeom->GetCameraDist())*1000;
+
+            // calculate mean of all 'stars' hitting the camera plane
+            // by taking the sum of the intersection points between
+            // the light vector and the camera plane
+            mean += spot;
+
+            if (hasdot)
+            {
+                TMarker *m=new TMarker(spot(0), spot(1), 1);
+                m->SetMarkerColor(kMagenta);
+                m->SetMarkerStyle(kDot);
+                fMapG.Add(m);
+            }
+            if (h)
+                h->Fill(spot(0), spot(1), pow(10, -mag/2.5));
+
+            if (usecam)
+                camera->Fill(spot(0), spot(1), pow(10, -mag/2.5));
+
+            num++;
+        }
+
+        // transform meters into millimeters (camera display works with mm)
+        mean *= 1./num;
+        DrawStar(mean(0), mean(1), *radec, hasmean?kBlack:-1, Form("x=%.1fmm y=%.1fmm", mean(0), mean(1)), resize);
+        if (hasnull)
+        {
+            TVector3 star(*radec);
+            star *= rot;
+            const TVector3 spot = fMirror0->GetReflection(star, fGeom->GetCameraDist())*1000;
+            DrawStar(spot(0), spot(1), *radec, hasmean?kBlack:-1, Form("x=%.1fmm y=%.1fmm", mean(0), mean(1)), resize);
+            // This can be used to get the abberation...
+            //cout << TMath::Hypot(spot(0), spot(1)) << " " << TMath::Hypot(mean(0)-spot(0), mean(1)-spot(1)) << endl;
+        }
+    }
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Fills a TList with all stars found under current presets
+// (Coordinates, Time, FOV). The list is emptied before the filling is done.
+// Currently, the mean spot when averaging over all mirrors is used.
+//
+void MAstroCamera::FillStarList(TList* list)
+{
+    if (!fTime || !fObservatory || !fMirrors) {
+      cout << "Missing data..." << endl;
+      return;
+    }
+
+    if (!list) {
+      cout << "Missing storage list for stars found..." << endl;
+      return;
+    }
+
+    list->Delete(); // dump old list... (otherwise the same stars would pile up)
+   
+    const TRotation rot(GetGrid(kTRUE));
+    MVector3 *radec;
+    TIter Next(&fList);
+
+    while ((radec=(MVector3*)Next())) {
+      const Double_t mag = radec->Magnitude();
+      if (mag>GetLimMag())
+	continue;
+      TVector3 star(*radec);
+      // Rotate Star into telescope system
+      star *= rot;
+      TVector3 mean;
+      Int_t num = 0;
+      MGeomMirror *mirror = 0;
+      TIter NextM(fMirrors);
+      while ((mirror=(MGeomMirror*)NextM())) {
+	const TVector3 spot = mirror->GetReflection(star, fGeom->GetCameraDist())*1000;
+	mean += spot;
+	num++;
+      }
+      mean *= 1./num;
+// FIXME: remove comments as soon as MStarLocalPos official part of MARS
+//      MStarLocalPos *starpos = new MStarLocalPos;
+//      starpos->SetExpValues(mag,mean(0),mean(1));
+      
+//      TString name = radec->GetName();
+//      if (name.Length()==0) {
+//	starpos->SetName("unknown"); 
+//      } else {
+//	starpos->SetName(radec->GetName());
+//      }	 
+//      list->Add(starpos);   
+// FIXME: remove comments as soon as MStarLocalPos official part of MARS
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// Uses fRaDec as a reference point.
+//
+// Return dZd and dAz corresponding to the distance from x,y to fRaDec
+//
+// Before calling this function you should correct for abberation. In
+// case of MAGIC you can do this by:
+//    x /= 1.0713;
+//    y /= 1.0713;
+//
+// x [mm]: x coordinate in the camera plane (assuming a perfect mirror)
+// y [mm]: y coordinate in the camera plane (assuming a perfect mirror)
+//
+// We assume (0, 0) to be the center of the FOV
+//
+// dzd [deg]: Delta Zd
+// daz [deg]: Delta Az
+//
+void MAstroCamera::GetDiffZdAz(Double_t x, Double_t y, Double_t &dzd, Double_t &daz)
+{
+    // Reflect the corrected pixel on a perfect mirror
+    TVector3 v(x, y, fGeom->GetCameraDist()*1000);
+    TVector3 spot = fMirror0->GetReflection(v);
+    
+    // Derotate into the local coordinate system
+    const MAstroSky2Local rot(*fTime, *fObservatory);
+    const TRotation align(AlignCoordinates(rot*fRaDec).Inverse());
+    spot *= align;
+
+    cout << "Zd="<<spot.Theta()*TMath::RadToDeg() << " ";
+    cout << "Az="<<spot.Phi()  *TMath::RadToDeg()+360 << endl;
+
+    // Derotatet the center of the camera
+    TVector3 c(0, 0, 1);
+    c *= align;
+
+    dzd = (spot.Theta()-c.Theta())*TMath::RadToDeg();
+    daz = (spot.Phi()  -c.Phi())  *TMath::RadToDeg();
+
+    if (daz> 180) daz -= 360;
+    if (daz<-180) daz += 360;
+}
+
+// ------------------------------------------------------------------------
+//
+// Execute a gui event on the camera
+//
+void MAstroCamera::ExecuteEvent(Int_t event, Int_t mp1, Int_t mp2)
+{
+    // if (mp1>0 && mp2>0)
+    // {
+    //     // Calculate World coordinates from pixel
+    //     Double_t x = gPad->AbsPixeltoX(mp1);
+    //     Double_t y = gPad->AbsPixeltoY(mp2);
+    //
+    //     // Correct for abberation
+    //     x /= 1.0713;
+    //     y /= 1.0713;
+    //
+    //     Double_t dzd, daz;
+    //     GetDiffZdAz(x, y, dzd, daz);
+    //
+    //     cout << "dZd="<< dzd << " " << "dAz="<< daz << endl;
+    // }
+    //
+    // For MAGIC the distance of the mean of the light distribution
+    // to the Mirror0 reflection of the star (Abberation) can be
+    // expressed as:  dr = 0.0713*r = r/14.03
+    //                   +-0.0002
+
+    if (event==kKeyPress && fTime)
+        switch (mp2)
+        {
+        case kKey_Plus:
+            fTime->SetMjd(fTime->GetMjd()+0.25/24);
+            Update(kTRUE);
+            return;
+
+        case kKey_Minus:
+            fTime->SetMjd(fTime->GetMjd()-0.25/24);
+            Update(kTRUE);
+            return;
+        }
+
+    MAstroCatalog::ExecuteEvent(event, mp1, mp2);
+}
Index: /tags/Mars_V0-8-5/Mars/mastro/MAstroCamera.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mastro/MAstroCamera.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mastro/MAstroCamera.h	(revision 9661)
@@ -0,0 +1,44 @@
+#ifndef MARS_MAstroCamera
+#define MARS_MAstroCamera
+
+#ifndef MARS_MAstroCatalog
+#include "MAstroCatalog.h"
+#endif
+
+class TClonesArray;
+class TList;
+
+class MTime;
+class MGeomCam;
+class MGeomMirror;
+class MObservatory;
+
+class MAstroCamera : public MAstroCatalog
+{
+private:
+    MGeomCam     *fGeom;
+    TClonesArray *fMirrors;
+
+    MGeomMirror  *fMirror0;     //!
+
+    Int_t  ConvertToPad(const TVector3 &w, TVector2 &v) const;
+    void   AddPrimitives(TString o);
+    void   SetRangePad(Option_t *o) { }
+    void   ExecuteEvent(Int_t event, Int_t mp1, Int_t mp2);
+
+public:
+    MAstroCamera();
+    ~MAstroCamera();
+
+    void SetMirrors(TClonesArray &arr);
+    void SetMirrors(const char *fname);
+    void SetGeom(const MGeomCam &cam);
+
+    void FillStarList(TList *list);
+
+    void GetDiffZdAz(Double_t x, Double_t y, Double_t &dzd, Double_t &daz);
+
+    ClassDef(MAstroCamera, 1) // Display class to display stars on the camera
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mastro/MAstroCatalog.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mastro/MAstroCatalog.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mastro/MAstroCatalog.cc	(revision 9661)
@@ -0,0 +1,1423 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without expressed
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 03/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Robert Wagner, 08/2004 <mailto:rwagner@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2002-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MAstroCatalog
+//  =============
+//
+//  THIS IMPLEMENTATION IS PRELIMINARY AND WILL BE MERGED WITH
+//  SOME PARTS OF THE DRIVE SOFTWARE SOON!
+//
+//
+//  Catalogs:
+//  ---------
+//
+//  To be able to use this class you need a catalog file suppored by
+//  MAstroCatalog.
+//  Catalog files can be found at
+//  http://magic.astro.uni-wuerzburg.de/mars/catalogs.html
+//  You must copy the file into the directory from which you start your macro
+//  or give an abolute path loading the catalog.
+//
+//
+//  Usage:
+//  ------
+//
+//  To display a starfield you must have a supported catalog, then do:
+//
+//    MTime time;
+//    // Time for which to get the picture
+//    time.Set(2004, 2, 28, 20, 14, 7);
+//    // Current observatory
+//    MObservatory magic1;
+//    // Right Ascension [h] and declination [deg] of source
+//    // Currently 'perfect' pointing is assumed
+//    const Double_t ra  = MAstro::Hms2Rad(5, 34, 31.9);
+//    const Double_t dec = MAstro::Dms2Rad(22, 0, 52.0);
+//    MAstroCatalog stars;
+//    // Magnitude up to which the stars are loaded from the catalog
+//    stars.SetLimMag(6);
+//    // Radius of FOV around the source position to load the stars
+//    stars.SetRadiusFOV(3);
+//    // Source position
+//    stars.SetRaDec(ra, dec);
+//    // Catalog to load (here: Bright Star Catalog V5)
+//    stars.ReadBSC("bsc5.dat");
+//    // Obersavatory and time to also get local coordinate information
+//    stars.SetObservatory(magic1);
+//    stars.SetTime(time);
+//    // Enable interactive GUI
+//    stars.SetGuiActive();
+//    //Clone the catalog due to the validity range of the instance
+//    TObject *o = stars.Clone();
+//    o->SetBit(kCanDelete);
+//    o->Draw();
+//
+//  If no time and/or Obervatory location is given no local coordinate
+//  information is displayed.
+//
+//
+//  Coordinate Transformation:
+//  -------------------------
+//  The conversion from sky coordinates to local coordinates is done using
+//  MAstroSky2Local which does a simple rotation of the coordinate system.
+//  This is inaccurate in the order of 30arcsec due to ignorance of all
+//  astrometrical corrections (nutation, precission, abberation, ...)
+//
+//
+//  GUI:
+//  ----
+//    * If the gui is interactive you can use the cursor keys to change
+//      the position you are looking at and with plus/minus you
+//      can (un)zoom the FOV (Field Of View)
+//    * The displayed values mean the following:
+//        + alpha: Right Ascension
+//        + delta: Declination
+//        + theta: zenith distance / zenith angle
+//        + phi:   azimuth angle
+//        + rho:   angle of rotation sky-coordinate system vs local-
+//                 coordinate system
+//        + time of display
+//    * Move the mouse on top of the grid points or the stars to get
+//      more setailed information.
+//    * Enable the event-info in a canvas to see the current
+//      ObjectInfo=tooltip-text
+//    * call SetNoToolTips to supress the tooltips
+//    * the blue lines are the local coordinat system
+//    * the red lines are sky coordinate system
+//
+//
+//  ToDo:
+//  -----
+//   - replace MVetcor3 by a more convinient class. Maybe use TExMap, too.
+//   - change tooltips to multi-line tools tips as soon as root
+//     supports them
+//   - a derived class is missing which supports all astrometrical
+//     correction (base on slalib and useable in Cosy)
+//   - Implement a general loader for heasarc catlogs, see
+//     http://heasarc.gsfc.nasa.gov/W3Browse/star-catalog/
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MAstroCatalog.h"
+
+#include <errno.h>      // strerror
+#include <fstream>      // ifstream
+#include <stdlib.h>     // ati, atof
+#include <limits.h>     // INT_MAX (Suse 7.3/gcc 2.95)
+
+#include <KeySymbols.h> // kKey_*
+
+#include <TLine.h>      // TLine
+#include <TMarker.h>    // TMarker
+#include <TCanvas.h>    // TCanvas
+#include <TArrayI.h>    // TArrayI
+#include <TGToolTip.h>  // TGToolTip
+#include <TPaveText.h>  // TPaveText
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MTime.h"
+#include "MString.h"
+#include "MAstro.h"
+#include "MAstroSky2Local.h"
+#include "MObservatory.h"
+
+#undef DEBUG
+//#define DEBUG
+
+#ifdef DEBUG
+#include <TStopwatch.h>
+#endif
+
+ClassImp(MVector3);
+ClassImp(MAstroCatalog);
+
+using namespace std;
+
+void MVector3::WriteBinary(ostream &out) const
+{
+    const Double_t t = Theta();
+    const Double_t p = Phi();
+    const Float_t  m = Mag();
+    out.write((char*)&t, 8);
+    out.write((char*)&p, 8);
+    out.write((char*)&m, 4);
+    out << fName << endl;
+}
+
+void MVector3::ReadBinary(istream &in)
+{
+    Double_t t, p;
+    Float_t  m;
+
+    in.read((char*)&t, 8);
+    in.read((char*)&p, 8);
+    in.read((char*)&m, 4);
+    fName.ReadLine(in);
+
+    SetMagThetaPhi(m, t, p);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Default Constructor. Set Default values:
+//   fLimMag    = 99
+//   fRadiusFOV = 90
+//
+MAstroCatalog::MAstroCatalog() : fLimMag(99), fRadiusFOV(90), fToolTip(0), fObservatory(0), fTime(0)
+{
+    fList.SetOwner();
+    fMapG.SetOwner();
+    fToolTip = gROOT->IsBatch() || !gClient ? 0 : new TGToolTip(0, "", 0);
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor. Delete fTime, fObservatory. Disconnect signal. delete tooltip.
+// Delete Map with gui primitives
+//
+MAstroCatalog::~MAstroCatalog()
+{
+    // First disconnect the EventInfo...
+    // FIXME: There must be an easier way!
+    TIter Next(gROOT->GetListOfCanvases());
+    TCanvas *c;
+    while ((c=(TCanvas*)Next()))
+        c->Disconnect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)", this,
+                      "EventInfo(Int_t,Int_t,Int_t,TObject*)");
+
+    // Now delete the data members
+    if (fTime)
+        delete fTime;
+    if (fObservatory)
+        delete fObservatory;
+
+    if (fToolTip)
+    {
+        fToolTip->Hide();
+        delete fToolTip;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Snippet to for reading catalog files.
+//
+TString MAstroCatalog::FindToken(TString &line, Char_t tok)
+{
+    Ssiz_t token = line.First(tok);
+    if (token<0)
+    {
+        const TString copy(line);
+        line = "";
+        return copy;
+    }
+
+    const TString res = line(0, token);
+    line.Remove(0, token+1);
+    return res;
+}
+
+// --------------------------------------------------------------------------
+//
+// return int correspoding to TSubString
+//
+Int_t MAstroCatalog::atoi(const TSubString &sub)
+{
+    return atoi(TString(sub));
+}
+
+// --------------------------------------------------------------------------
+//
+// return float correspoding to TSubString
+//
+Float_t MAstroCatalog::atof(const TSubString &sub)
+{
+    return atof(TString(sub));
+}
+
+// --------------------------------------------------------------------------
+//
+// return int correspoding to TString
+//
+Int_t MAstroCatalog::atoi(const TString &s)
+{
+    return std::atoi(s);
+}
+
+// --------------------------------------------------------------------------
+//
+// return float correspoding to TString
+//
+Float_t MAstroCatalog::atof(const TString &s)
+{
+    return std::atof(s);
+}
+
+// --------------------------------------------------------------------------
+//
+// Read from a xephem catalog, set bit kHasChahanged.
+// Already read data is not deleted. To delete the stored data call
+// Delete().
+//
+Int_t MAstroCatalog::ReadXephem(TString catalog)
+{
+    gLog << inf << "Reading Xephem catalog: " << catalog << endl;
+
+    ifstream fin(catalog);
+    if (!fin)
+    {
+        gLog << err << "Cannot open catalog file " << catalog << ": ";
+        gLog << strerror(errno) << endl;
+        return 0;
+    }
+
+    Int_t add =0;
+    Int_t cnt =0;
+    Int_t line=0;
+
+    Double_t maxmag=0;
+
+    while (1)
+    {
+        TString row;
+        row.ReadLine(fin);
+        if (!fin)
+            break;
+
+        line++;
+
+        if (row[0]=='#')
+            continue;
+
+        TString line(row);
+
+        TString name  = FindToken(line);
+        TString dummy = FindToken(line);
+        TString r     = FindToken(line);
+        TString d     = FindToken(line);
+        TString m     = FindToken(line);
+        TString epoch = FindToken(line);
+
+        if (name.IsNull() || r.IsNull() || d.IsNull() || m.IsNull() || epoch.IsNull())
+        {
+            gLog << warn << "Invalid Entry Line #" << line << ": " << row << endl;
+            continue;
+        }
+
+        cnt++;
+
+        const Double_t mag = atof(m);
+
+        maxmag = TMath::Max(maxmag, mag);
+
+        if (mag>fLimMag)
+            continue;
+
+        if (epoch!="2000")
+        {
+            gLog << warn << "Epoch != 2000... skipped." << endl;
+            continue;
+        }
+
+        Double_t ra0, dec0;
+        MAstro::Coordinate2Angle(r, ra0);
+        MAstro::Coordinate2Angle(d, dec0);
+
+        ra0  *= TMath::Pi()/12;
+        dec0 *= TMath::Pi()/180;
+
+        if (AddObject(ra0, dec0, mag, name))
+            add++;
+    }
+    gLog << inf << "Read " << add << " out of " << cnt << " (Total max mag=" << maxmag << ")" << endl;
+
+    return add;
+}
+
+// --------------------------------------------------------------------------
+//
+// Read from a NGC2000 catalog. set bit kHasChanged
+// Already read data is not deleted. To delete the stored data call
+// Delete().
+//
+Int_t MAstroCatalog::ReadNGC2000(TString catalog)
+{
+    gLog << inf << "Reading NGC2000 catalog: " << catalog << endl;
+
+    ifstream fin(catalog);
+    if (!fin)
+    {
+        gLog << err << "Cannot open catalog file " << catalog << ": ";
+        gLog << strerror(errno) << endl;
+        return 0;
+    }
+
+    Int_t add=0;
+    Int_t cnt=0;
+    Int_t n  =0;
+
+    Double_t maxmag=0;
+
+    while (1)
+    {
+        TString row;
+        row.ReadLine(fin);
+        if (!fin)
+            break;
+
+        cnt++;
+
+        const Int_t   rah  = atoi(row(13, 2));
+        const Float_t ram  = atof(row(16, 4));
+        const Char_t  decs = row(22);
+        const Int_t   decd = atoi(row(23, 2));
+        const Int_t   decm = atoi(row(26, 2));
+        const TString m    = row(43, 4);
+
+        if (m.Strip().IsNull())
+            continue;
+
+        n++;
+
+        const Double_t mag = atof(m);
+
+        maxmag = TMath::Max(maxmag, mag);
+
+        if (mag>fLimMag)
+            continue;
+
+        const Double_t ra  = MAstro::Hms2Rad(rah,  (int)ram, fmod(ram, 1)*60);
+        const Double_t dec = MAstro::Dms2Rad(decd, decm, 0, decs);
+
+        if (AddObject(ra, dec, mag, row(0,8)))
+            add++;
+    }
+
+    gLog << inf << "Read " << add << " out of " << n << " (Total max mag=" << maxmag << ")" << endl;
+
+    return add;
+}
+
+// --------------------------------------------------------------------------
+//
+// Read from a Bright Star Catalog catalog. set bit kHasChanged
+// Already read data is not deleted. To delete the stored data call
+// Delete().
+//
+Int_t MAstroCatalog::ReadBSC(TString catalog)
+{
+    gLog << inf << "Reading Bright Star Catalog (BSC5) catalog: " << catalog << endl;
+
+    ifstream fin(catalog);
+    if (!fin)
+    {
+        gLog << err << "Cannot open catalog file " << catalog << ": ";
+        gLog << strerror(errno) << endl;
+        return 0;
+    }
+
+    Int_t add=0;
+    Int_t cnt=0;
+    Int_t n  =0;
+
+    Double_t maxmag=0;
+
+    while (1)
+    {
+        TString row;
+        row.ReadLine(fin);
+        if (!fin)
+            break;
+
+        cnt++;
+
+        const Int_t   rah    = atoi(row(75, 2));
+        const Int_t   ram    = atoi(row(77, 2));
+        const Float_t ras    = atof(row(79, 4));
+        const Char_t  decsgn = row(83);
+        const Int_t   decd   = atoi(row(84, 2));
+        const Int_t   decm   = atoi(row(86, 2));
+        const Int_t   decs   = atoi(row(88, 2));
+        const TString m      = row(102, 5);
+
+        if (m.Strip().IsNull())
+            continue;
+
+        n++;
+
+        const Double_t mag = atof(m.Data());
+
+        maxmag = TMath::Max(maxmag, mag);
+
+        if (mag>fLimMag)
+            continue;
+
+        const Double_t ra  = MAstro::Hms2Rad(rah, ram, ras);
+        const Double_t dec = MAstro::Dms2Rad(decd, decm, decs, decsgn);
+
+        if (AddObject(ra, dec, mag, row(4,9)))
+            add++;
+    }
+
+    gLog << inf << "Read " << add << " out of " << n << " (Total max mag=" << maxmag << ")" << endl;
+
+    return add;
+}
+
+// --------------------------------------------------------------------------
+//
+// Read from a ascii heasarc ppm catalog. set bit kHasChanged
+// Already read data is not deleted. To delete the stored data call
+// Delete().
+// If the second argument is given all survived stars are written
+// to a file outname. This files will contain an apropriate compressed
+// file format. You can read such files again using ReadCompressed.
+//
+// FIXME: A General loader for heasarc catlogs is missing, see
+//        http://heasarc.gsfc.nasa.gov/W3Browse/star-catalog/
+//
+Int_t MAstroCatalog::ReadHeasarcPPM(TString catalog, TString outname)
+{
+    gLog << inf << "Reading Heasarc PPM catalog: " << catalog << endl;
+
+    ifstream fin(catalog);
+    if (!fin)
+    {
+        gLog << err << "Cannot open catalog file " << catalog << ": ";
+        gLog << strerror(errno) << endl;
+        return 0;
+    }
+
+    ofstream *fout = outname.IsNull() ? 0 : new ofstream(outname);
+    if (fout && !*fout)
+    {
+        gLog << warn << "Cannot open output file " << outname << ": ";
+        gLog << strerror(errno) << endl;
+        delete fout;
+        fout = 0;
+    }
+
+    Int_t add=0;
+    Int_t cnt=0;
+    Int_t n  =0;
+
+    Double_t maxmag=0;
+
+    while (1)
+    {
+        TString row;
+        row.ReadLine(fin);
+        if (!fin)
+            break;
+
+        cnt++;
+
+        if (!row.BeginsWith("PPM "))
+            continue;
+
+        const TString name = row(0, row.First('|'));
+        row = row(row.First('|')+1, row.Length());
+        row = row(row.First('|')+1, row.Length());
+
+        const TString vmag = row(0, row.First('|'));
+
+        n++;
+        const Double_t mag = atof(vmag.Data());
+        maxmag = TMath::Max(maxmag, mag);
+        if (mag>fLimMag)
+            continue;
+
+        row = row(row.First('|')+1, row.Length());
+        row = row(row.First('|')+1, row.Length());
+
+        row = row(row.First('|')+1, row.Length());
+        row = row(row.First('|')+1, row.Length());
+
+        row = row(row.First('|')+1, row.Length());
+        row = row(row.First('|')+1, row.Length());
+
+        const TString ra = row(0, row.First('|'));
+        row = row(row.First('|')+1, row.Length());
+        const TString de = row(0, row.First('|'));
+        row = row(row.First('|')+1, row.Length());
+
+        Char_t sgn;
+        Int_t d, m;
+        Float_t s;
+        if (sscanf(ra.Data(), "%d %d %f", &d, &m, &s)!=3)
+        {
+            // gLog << "Error loading entry in line " << i << endl;
+            continue;
+        }
+        const Double_t ra0 = MAstro::Hms2Rad(d, m, s);
+
+        if (sscanf(de.Data(), "%c%d %d %f", &sgn, &d, &m, &s)!=4)
+        {
+            // gLog << "Error loading entry in line " << i << endl;
+            continue;
+        }
+        const Double_t de0 = MAstro::Dms2Rad(d, m, s, sgn);
+
+        if (!AddObject(ra0, de0, mag, name))
+            continue;
+
+        add++;
+
+        if (fout)
+            ((MVector3*)fList.Last())->WriteBinary(*fout);
+    }
+
+    gLog << inf << "Read " << add << " out of " << n << " (Total max mag=" << maxmag << ")" << endl;
+
+    return add;
+}
+
+// --------------------------------------------------------------------------
+//
+// Read from a MAstroCatalog compressed catalog. set bit kHasChanged
+// Already read data is not deleted. To delete the stored data call
+// Delete().
+//
+Int_t MAstroCatalog::ReadCompressed(TString catalog)
+{
+    SetBit(kHasChanged);
+
+    gLog << inf << "Reading MAstroCatalog compressed catalog: " << catalog << endl;
+
+    ifstream fin(catalog);
+    if (!fin)
+    {
+        gLog << err << "Cannot open catalog file " << catalog << ": ";
+        gLog << strerror(errno) << endl;
+        return 0;
+    }
+
+    Int_t add=0;
+    Int_t cnt=0;
+    Int_t n  =0;
+
+    Double_t maxmag=0;
+
+    MVector3 entry;
+
+    while (1)
+    {
+        cnt++;
+
+        entry.ReadBinary(fin);
+        if (!fin)
+            break;
+
+        n++;
+
+        const Double_t mag = entry.Magnitude();
+        maxmag = TMath::Max(maxmag, mag);
+        if (mag>fLimMag)
+            continue;
+
+        if (entry.Angle(fRaDec)*TMath::RadToDeg()>fRadiusFOV)
+            continue;
+
+        fList.Add(entry.Clone());
+        add++;
+    }
+
+    gLog << inf << "Read " << add << " out of " << n << " (Total max mag=" << maxmag << ")" << endl;
+
+    return add;
+}
+
+// --------------------------------------------------------------------------
+//
+// Add an object to the star catalog manually. Return true if the object
+// was added and false otherwise (criteria is the FOV)
+//
+Bool_t MAstroCatalog::AddObject(Float_t ra, Float_t dec, Float_t mag, TString name)
+{
+    MVector3 *star = new MVector3;
+    star->SetRaDec(ra, dec, mag);
+    star->SetName(name);
+
+    if (star->Angle(fRaDec)*TMath::RadToDeg()>fRadiusFOV)
+    {
+        delete star;
+        return 0;
+    }
+
+    SetBit(kHasChanged);
+    fList.AddLast(star);
+    return 1;
+}
+
+// --------------------------------------------------------------------------
+//
+// Set Range of pad. If something has changed create and draw new primitives.
+// Paint all gui primitives.
+//
+void MAstroCatalog::Paint(Option_t *o)
+{
+    SetRangePad(o);
+
+    if (TestBit(kHasChanged))
+        DrawPrimitives(o);
+
+    fMapG.Paint();
+}
+
+// --------------------------------------------------------------------------
+//
+// Set Range of pad if pad available. If something has changed create
+// and draw new primitives. Paint all gui primitives to the Drawable with
+// Id id. This can be used to be able to
+//
+/*
+void MAstroCatalog::PaintImg(Int_t id, Option_t *o)
+{
+    if (gPad)
+        SetRangePad(o);
+
+    if (TestBit(kHasChanged))
+    {
+        if (id>0)
+            gPad=0;
+        DrawPrimitives(o);
+    }
+
+    fMapG.Paint(id, fRadiusFOV);
+}
+*/
+
+// --------------------------------------------------------------------------
+//
+// Set Range of pad. If something has changed create and draw new primitives.
+// Paint all gui primitives.
+//
+// Because in some kind of multi-threaded environments gPad doesn't stay
+// the same in a single thread (because it might be changed in the same
+// thread inside a gui updating timer for example) we have to secure the
+// usage of gPad with a bit. This is also not multi-thread safe against
+// calling this function, but the function should work well in multi-
+// threaded environments. Never call this function from different threads
+// simultaneously.
+//
+void MAstroCatalog::PaintImg(unsigned char *buf, int w, int h, Option_t *o)
+{
+    if (!o)
+        o = "local mirrorx yellow * =";
+
+    if (TestBit(kHasChanged))
+    {
+        SetBit(kDrawingImage);
+        DrawPrimitives(o);
+        ResetBit(kDrawingImage);
+    }
+
+    fMapG.Paint(buf, w, h, fRadiusFOV);
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw a black marker at the position of the star. Create a corresponding
+// tooltip with the coordinates.
+// x, y: Pad Coordinates to draw star
+// v: Sky position (Ra/Dec) of the star
+// col: Color of marker (<0 mean transparent)
+// txt: additional tooltip text
+// resize: means resize the marker according to the magnitude
+//
+void MAstroCatalog::DrawStar(Double_t x, Double_t y, const TVector3 &v, Int_t col, const char *txt, Bool_t resize)
+{
+    const Double_t ra  = v.Phi()*TMath::RadToDeg()/15;
+    const Double_t dec = (TMath::Pi()/2-v.Theta())*TMath::RadToDeg();
+
+    const Double_t mag = -2.5*log10(v.Mag());
+
+    MString str;
+    str.Print("%s:  Ra=%.2fh  Dec=%.1fd  Mag=%.1f", v.GetName(), ra, dec, mag);
+    if (txt)
+    {
+        str += "  (";
+        str += txt;
+        str += ")";
+    }
+
+    // draw star on the camera display
+    TMarker *tip=new TMarker(x, y, col<0 ? kDot : kFullDotMedium);;
+    tip->SetMarkerColor(col);
+    fMapG.Add(tip, new TString(str));
+
+    if (!resize)
+        return;
+
+    tip->SetMarkerSize((10 - (mag>1 ? mag : 1))/15);
+    tip->SetMarkerStyle(kCircle);
+}
+
+// --------------------------------------------------------------------------
+//
+// Set pad as modified.
+//
+void MAstroCatalog::Update(Bool_t upd)
+{
+    SetBit(kHasChanged);
+    if (gPad && TestBit(kMustCleanup))
+    {
+        gPad->Modified();
+        if (upd)
+            gPad->Update();
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the observation time. Necessary to use local coordinate
+// system. The MTime object is cloned.
+//
+void MAstroCatalog::SetTime(const MTime &time)
+{
+    if (fTime)
+        delete fTime;
+    fTime=(MTime*)time.Clone();
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the observatory location. Necessary to use local coordinate
+// system. The MObservatory object is cloned.
+//
+void MAstroCatalog::SetObservatory(const MObservatory &obs)
+{
+    if (fObservatory)
+        delete fObservatory;
+    fObservatory=new MObservatory;
+    obs.Copy(*fObservatory);
+}
+
+// --------------------------------------------------------------------------
+//
+// Convert the vector to pad coordinates. After conversion
+// the x- coordinate of the vector must be the x coordinate
+// of the pad - the same for y. If the coordinate is inside
+// the current draw area return kTRUE, otherwise kFALSE.
+// If it is an invalid coordinate return kERROR
+//
+Int_t MAstroCatalog::ConvertToPad(const TVector3 &w0, TVector2 &v) const
+{
+    TVector3 w(w0);
+
+    // Stretch such, that the Z-component is alwas the same. Now
+    // X and Y contains the intersection point between the star-light
+    // and the plain of a virtual plain screen (ccd...)
+    if (TestBit(kPlainScreen))
+        w *= 1./w(2);
+
+    w *= TMath::RadToDeg(); // FIXME: *conversion factor?
+    v.Set(TestBit(kMirrorX) ? -w(0) : w(0),
+          TestBit(kMirrorY) ? -w(1) : w(1));
+
+    if (w(2)<0)
+        return kERROR;
+
+    if (TestBit(kDrawingImage) || !gPad)
+        return v.Mod2()<fRadiusFOV*fRadiusFOV;
+
+    return v.X()>gPad->GetX1() && v.Y()>gPad->GetY1() &&
+           v.X()<gPad->GetX2() && v.Y()<gPad->GetY2();
+}
+
+// --------------------------------------------------------------------------
+//
+// Convert theta/phi coordinates of v by TRotation into new coordinate
+// system and convert the coordinated to pad by ConvertToPad.
+// The result is retunred in v.
+//
+Int_t MAstroCatalog::Convert(const TRotation &rot, TVector2 &v) const
+{
+    MVector3 w;
+    w.SetMagThetaPhi(1, v.Y(), v.X());
+    w *= rot;
+
+    return ConvertToPad(w, v);
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw a line from v to v+(dx,dy) using Convert/ConvertToPad to get the
+// corresponding pad coordinates.
+//
+Bool_t MAstroCatalog::DrawLine(const TVector2 &v, Int_t dx, Int_t dy, const TRotation &rot, Int_t type)
+{
+    const TVector2 add(dx*TMath::DegToRad(), dy*TMath::DegToRad());
+
+    // Define all lines in the same direction
+    const TVector2 va(dy==1?v:v+add);
+    const TVector2 vb(dy==1?v+add:v);
+
+    TVector2 v0(va);
+    TVector2 v1(vb);
+
+    const Int_t rc0 = Convert(rot, v0);
+    const Int_t rc1 = Convert(rot, v1);
+
+    // Both are kFALSE or both are kERROR
+    if ((rc0|rc1)==kFALSE || (rc0&rc1)==kERROR)
+        return kFALSE;
+
+    TLine *line = new TLine(v0.X(), v0.Y(), v1.X(), v1.Y());
+    line->SetLineStyle(kDashDotted); //kDashed, kDotted, kDashDotted
+    line->SetLineColor(kWhite+type*2);
+    fMapG.Add(line);
+
+    if (dx!=0)
+        return kTRUE;
+
+    const TVector2 deg = va*TMath::RadToDeg();
+
+    MString txt;
+    if (type==1)
+        txt.Print("Ra=%.2fh  Dec=%.1fd", fmod(deg.X()/15+48, 24),  fmod(90-deg.Y()+270,180)-90);
+    else
+        txt.Print("Zd=%.1fd  Az=%.1fd",  fmod(deg.Y()+270,180)-90, fmod(deg.X()+720, 360));
+
+    TMarker *tip=new TMarker(v0.X(), v0.Y(), kDot);
+    tip->SetMarkerColor(kWhite+type*2);
+    fMapG.Add(tip, new TString(txt));
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Use "local" draw option to align the display to the local
+// coordinate system instead of the sky coordinate system.
+// dx, dy are arrays storing recuresively all touched points
+// stepx, stepy are the step-size of the current grid.
+//
+void MAstroCatalog::Draw(const TVector2 &v0, const TRotation &rot, TArrayI &dx, TArrayI &dy, Int_t stepx, Int_t stepy, Int_t type)
+{
+    // Calculate the end point
+    const TVector2 v1 = v0 + TVector2(dx[0]*TMath::DegToRad(), dy[0]*TMath::DegToRad());
+
+    // Check whether the point has already been touched.
+    Int_t idx[] = {1, 1, 1, 1};
+
+    Int_t dirs[4][2] = { {0, stepy}, {stepx, 0}, {0, -stepy}, {-stepx, 0} };
+
+    // Check for ambiguities.
+    for (int i=0; i<dx.GetSize(); i++)
+    {
+        for (int j=0; j<4; j++)
+        {
+            const Bool_t rcx0 = (dx[i]+720)%360==(dx[0]+dirs[j][0]+720)%360;
+            const Bool_t rcy0 = (dy[i]+360)%180==(dy[0]+dirs[j][1]+360)%180;
+            if (rcx0&&rcy0)
+                idx[j] = 0;
+        }
+    }
+
+    // Enhance size of array by 1, copy current
+    // position as last entry
+    dx.Set(dx.GetSize()+1);
+    dy.Set(dy.GetSize()+1);
+
+    dx[dx.GetSize()-1] = dx[0];
+    dy[dy.GetSize()-1] = dy[0];
+
+    // Store current positon
+    const Int_t d[2] = { dx[0], dy[0] };
+
+    for (int i=0; i<4; i++)
+        if (idx[i])
+        {
+            // Calculate new position
+            dx[0] = d[0]+dirs[i][0];
+            dy[0] = d[1]+dirs[i][1];
+
+            // Draw corresponding line and iterate through grid
+            if (DrawLine(v1, dirs[i][0], dirs[i][1], rot, type))
+                Draw(v0, rot, dx, dy, stepx, stepy, type);
+
+            dx[0]=d[0];
+            dy[0]=d[1];
+        }
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw a grid recursively around the point v0 (either Ra/Dec or Zd/Az)
+// The points in the grid are converted by a TRotation and CovertToPad
+// to pad coordinates. The type arguemnts is neccessary to create the
+// correct tooltip (Ra/Dec, Zd/Az) at the grid-points.
+// From the pointing position the step-size of teh gris is caluclated.
+//
+void MAstroCatalog::DrawGrid(const TVector3 &v0, const TRotation &rot, Int_t type)
+{
+    TArrayI dx(1);
+    TArrayI dy(1);
+
+    // align to 1deg boundary
+    TVector2 v(v0.Phi()*TMath::RadToDeg(), v0.Theta()*TMath::RadToDeg());
+    v.Set((Float_t)TMath::Nint(v.X()), (Float_t)TMath::Nint(v.Y()));
+
+    // calculate stepsizes based on visible FOV
+    Int_t stepx = 1;
+
+    if (v.Y()<fRadiusFOV || v.Y()>180-fRadiusFOV)
+        stepx=36;
+    else
+    {
+        // This is a rough estimate how many degrees are visible
+        const Float_t m = log(fRadiusFOV/180.)/log(90./(fRadiusFOV+1)+1);
+        const Float_t t = log(180.)-m*log(fRadiusFOV);
+        const Float_t f = m*log(90-fabs(90-v.Y()))+t;
+        const Int_t nx = (Int_t)(exp(f)+0.5);
+        stepx = nx<4 ? 1 : nx/4;
+        if (stepx>36)
+            stepx=36;
+    }
+
+    const Int_t ny = (Int_t)(fRadiusFOV+1);
+    Int_t stepy = ny<4 ? 1 : ny/4;
+
+    // align stepsizes to be devisor or 180 and 90
+    while (180%stepx)
+        stepx++;
+    while (90%stepy)
+        stepy++;
+
+    // align to step-size boundary (search for the nearest one)
+    Int_t dv = 1;
+    while ((int)(v.X())%stepx)
+    {
+        v.Set(v.X()+dv, v.Y());
+        dv = -TMath::Sign(TMath::Abs(dv)+1, dv);
+    }
+
+    dv = 1;
+    while ((int)(v.Y())%stepy)
+    {
+        v.Set(v.X(), v.Y()+dv);
+        dv = -TMath::Sign(TMath::Abs(dv)+1, dv);
+    }
+
+    // draw...
+    v *= TMath::DegToRad();
+
+    Draw(v, rot, dx, dy, stepx, stepy, type);
+}
+
+// --------------------------------------------------------------------------
+//
+// Get a rotation matrix which aligns the pointing position
+// to the center of the x,y plain
+//
+TRotation MAstroCatalog::AlignCoordinates(const TVector3 &v) const
+{
+    TRotation trans;
+    trans.RotateZ(-v.Phi());
+    trans.RotateY(-v.Theta());
+    trans.RotateZ(-TMath::Pi()/2);
+    return trans;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the rotation matrix which converts either sky or
+// local coordinates to coordinates which pole is the current
+// pointing direction.
+//
+TRotation MAstroCatalog::GetGrid(Bool_t local)
+{
+    const Bool_t enable = fTime && fObservatory;
+
+    // If sky coordinate view is requested get rotation matrix and
+    // draw corresponding sky-grid and if possible local grid
+    if (!local)
+    {
+        const TRotation trans(AlignCoordinates(fRaDec));
+
+        DrawGrid(fRaDec, trans, 1);
+
+        if (enable)
+        {
+            const MAstroSky2Local rot(*fTime, *fObservatory);
+            DrawGrid(rot*fRaDec, trans*rot.Inverse(), 2);
+        }
+
+        // Return the correct rotation matrix
+        return trans;
+    }
+
+    // If local coordinate view is requested get rotation matrix and
+    // draw corresponding sky-grid and if possible local grid
+    if (local && enable)
+    {
+        const MAstroSky2Local rot(*fTime, *fObservatory);
+
+        const TRotation trans(AlignCoordinates(rot*fRaDec));
+
+        DrawGrid(fRaDec,     trans*rot, 1);
+        DrawGrid(rot*fRaDec, trans,     2);
+
+        // Return the correct rotation matrix
+        return trans*rot;
+    }
+
+    return TRotation();
+}
+
+// --------------------------------------------------------------------------
+//
+// Create the title for the pad.
+//
+TString MAstroCatalog::GetPadTitle() const
+{
+    const Double_t ra  = fRaDec.Phi()*TMath::RadToDeg();
+    const Double_t dec = (TMath::Pi()/2-fRaDec.Theta())*TMath::RadToDeg();
+
+    TString txt;
+    txt += Form("\\alpha=%.2fh ",      fmod(ra/15+48, 24));
+    txt += Form("\\delta=%.1f\\circ ", fmod(dec+270,180)-90);
+    txt += Form("/ FOV=%.1f\\circ",    fRadiusFOV);
+
+    if (!fTime || !fObservatory)
+        return txt;
+
+    const MAstroSky2Local rot(*fTime, *fObservatory);
+    const TVector3 loc = rot*fRaDec;
+
+    const Double_t rho = rot.RotationAngle(fRaDec.Phi(), TMath::Pi()/2-fRaDec.Theta());
+
+    const Double_t zd = TMath::RadToDeg()*loc.Theta();
+    const Double_t az = TMath::RadToDeg()*loc.Phi();
+
+    txt.Prepend("#splitline{");
+    txt += Form("  \\theta=%.1f\\circ ", fmod(zd+270,180)-90);
+    txt += Form("\\phi=%.1f\\circ ",     fmod(az+720, 360));
+    txt += Form(" / \\rho=%.1f\\circ",   rho*TMath::RadToDeg());
+    txt += "}{<";
+    txt += fTime->GetSqlDateTime();
+    txt += ">}";
+    return txt;
+}
+
+// --------------------------------------------------------------------------
+//
+// To overlay the catalog make sure, that in any case you are using
+// the 'same' option.
+//
+// If you want to overlay this on top of any picture which is created
+// by derotation of the camera plain you have to use the 'mirror' option
+// the compensate the mirroring of the image in the camera plain.
+//
+// If you have already compensated this by x=-x and y=-y when creating
+// the histogram you can simply overlay the catalog.
+//
+// To overlay the catalog on a 2D histogram the histogram must have
+// units of degrees (which are plain, like you directly convert the
+// camera units by multiplication to degrees)
+//
+// To be 100% exact you must use the option 'plain' which assumes a plain
+// screen. This is not necessary for the MAGIC-camera because the
+// difference between both is less than 1e-3.
+//
+// You should always be aware of the fact, that the shown stars and the
+// displayed grid is the ideal case, like a reflection on a virtual
+// perfectly aligned central mirror. In reality the star-positions are
+// smeared to the edge of the camera the more the distance to the center
+// is, such that the center of gravity of the light distribution might
+// be more far away from the center than the display shows.
+//
+// If you want the stars to be displayed as circles with a size
+// showing their magnitude use "*" as an option.
+//
+// Use 'white'  to display white instead of black stars
+// Use 'yellow' to display white instead of black stars
+//
+//
+void MAstroCatalog::AddPrimitives(TString o)
+{
+    const Bool_t same   = o.Contains("same",    TString::kIgnoreCase);
+    const Bool_t local  = o.Contains("local",   TString::kIgnoreCase);
+    const Bool_t mirx   = o.Contains("mirrorx", TString::kIgnoreCase);
+    const Bool_t miry   = o.Contains("mirrory", TString::kIgnoreCase);
+    const Bool_t mirror = o.Contains("mirror",  TString::kIgnoreCase) && !mirx && !miry;
+    const Bool_t size   = o.Contains("*",       TString::kIgnoreCase);
+    const Bool_t white  = o.Contains("white",   TString::kIgnoreCase);
+    const Bool_t yellow = o.Contains("yellow",  TString::kIgnoreCase) && !white;
+
+    // X is vice versa, because ra is defined anti-clockwise
+    mirx || mirror ? ResetBit(kMirrorX) : SetBit(kMirrorX);
+    miry || mirror ? SetBit(kMirrorY) : ResetBit(kMirrorY);
+
+    const TRotation rot(GetGrid(local));
+
+    TIter Next(&fList);
+    MVector3 *v=0;
+    while ((v=(MVector3*)Next()))
+    {
+        if (v->Magnitude()>fLimMag)
+            continue;
+
+        TVector2 s(v->Phi(), v->Theta());
+        if (Convert(rot, s)==kTRUE)
+            DrawStar(s.X(), s.Y(), *v, yellow?kYellow:(white?kWhite:kBlack), 0, size);
+    }
+
+    if (!same && !TestBit(kDrawingImage) && gPad)
+    {
+        TPaveText *pv = new TPaveText(0.01, 0.90, 0.63, 0.99, "brNDC");
+        pv->AddText(GetPadTitle());
+        fMapG.Add(pv);
+    }
+
+    TMarker *mk=new TMarker(0, 0, kMultiply);
+    mk->SetMarkerColor(white||yellow?kWhite:kBlack);
+    mk->SetMarkerSize(1.5);
+    fMapG.Add(mk);
+}
+
+// --------------------------------------------------------------------------
+//
+// Do nothing if 'same' option given.
+// Otherwise set pad-range such that x- and y- coordinates have the same
+// step-size
+//
+void MAstroCatalog::SetRangePad(Option_t *o)
+{
+    if (TString(o).Contains("same", TString::kIgnoreCase))
+        return;
+
+    const Double_t edge = fRadiusFOV/TMath::Sqrt(2.);
+    //gPad->Range(-edge, -edge, edge, edge);
+
+    const Float_t w = gPad->GetWw();
+    const Float_t h = gPad->GetWh();
+
+    if (w<h)
+        gPad->Range(-edge, -edge*h/w, edge, edge*h/w);
+    else
+        gPad->Range(-edge*w/h, -edge, edge*w/h, edge);
+}
+
+// --------------------------------------------------------------------------
+//
+// First delete all gui elements.
+// Set the correct range of the pad.
+// Create all gui primitives
+// If "this" is not in the current pad add it to the current pad.
+// Reset vit kHasChanged
+//
+void MAstroCatalog::DrawPrimitives(Option_t *o)
+{
+    fMapG.Delete();
+
+    if (!TestBit(kDrawingImage) && gPad)
+        SetRangePad(o);
+
+#ifdef DEBUG
+    TStopwatch clk;
+    clk.Start();
+#endif
+    AddPrimitives(o);
+#ifdef DEBUG
+    clk.Stop();
+    clk.Print();
+#endif
+
+    // Append to a possible second pad
+    if (!TestBit(kDrawingImage) && gPad && !gPad->GetListOfPrimitives()->FindObject(this))
+        AppendPad(o);
+
+    ResetBit(kHasChanged);
+}
+
+// --------------------------------------------------------------------------
+//
+// Append "this" to current pad
+// set bit kHasChanged to recreate all gui elements
+// Connect signal
+//
+void MAstroCatalog::Draw(Option_t *o)
+{
+    // Append to first pad
+    AppendPad(o);
+
+    // If contents have not previously changed make sure that
+    // all primitives are recreated.
+    SetBit(kHasChanged);
+
+    // Connect all TCanvas::ProcessedEvent to this->EventInfo
+    // This means, that after TCanvas has processed an event
+    // EventInfo of this class is called, see TCanvas::HandleInput
+    gPad->GetCanvas()->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)",
+                               "MAstroCatalog", this,
+                               "EventInfo(Int_t,Int_t,Int_t,TObject*)");
+}
+
+// --------------------------------------------------------------------------
+//
+// This function was connected to all created canvases. It is used
+// to redirect GetObjectInfo into our own status bar.
+//
+// The 'connection' is done in Draw. It seems that 'connected'
+// functions must be public.
+//
+void MAstroCatalog::EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected)
+{
+    TCanvas *c = (TCanvas*)gTQSender;
+
+    gPad = c ? c->GetSelectedPad() : NULL;
+    if (!gPad)
+        return;
+
+
+    // Try to find a corresponding object with kCannotPick set and
+    // an available TString (for a tool tip)
+    TString str;
+    if (!selected || selected==this)
+        selected =  fMapG.PickObject(px, py, str);
+
+    if (!selected)
+        return;
+
+    // Handle some gui events
+    switch (event)
+    {
+    case kMouseMotion:
+        if (fToolTip && !fToolTip->IsMapped() && !str.IsNull())
+            ShowToolTip(px, py, str);
+        break;
+
+    case kMouseLeave:
+        if (fToolTip && fToolTip->IsMapped())
+            fToolTip->Hide();
+        break;
+
+    case kKeyPress:
+        ExecuteEvent(kKeyPress, px, py);
+        break;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Handle keyboard events.
+//
+void MAstroCatalog::ExecuteEventKbd(Int_t keycode, Int_t keysym)
+{
+    Double_t dra =0;
+    Double_t ddec=0;
+
+    switch (keysym)
+    {
+    case kKey_Left:
+        dra = -TMath::DegToRad();
+        break;
+    case kKey_Right:
+        dra = +TMath::DegToRad();
+        break;
+    case kKey_Up:
+        ddec = +TMath::DegToRad();
+        break;
+    case kKey_Down:
+        ddec = -TMath::DegToRad();
+        break;
+    case kKey_Plus:
+        SetRadiusFOV(fRadiusFOV+1);
+        break;
+    case kKey_Minus:
+        SetRadiusFOV(fRadiusFOV-1);
+        break;
+
+    default:
+        return;
+    }
+
+    const Double_t r = fRaDec.Phi();
+    const Double_t d = TMath::Pi()/2-fRaDec.Theta();
+
+    SetRaDec(r+dra, d+ddec);
+
+    gPad->Update();
+}
+
+// ------------------------------------------------------------------------
+//
+// Execute a gui event on the camera
+//
+void MAstroCatalog::ExecuteEvent(Int_t event, Int_t mp1, Int_t mp2)
+{
+    if (!TestBit(kGuiActive))
+        return;
+
+    if (event==kKeyPress)
+        ExecuteEventKbd(mp1, mp2);
+}
+
+// --------------------------------------------------------------------------
+//
+// Displays a tooltip
+//
+void MAstroCatalog::ShowToolTip(Int_t px, Int_t py, const char *txt)
+{
+    if (TestBit(kNoToolTips))
+        return;
+
+    Int_t x=0;
+    Int_t y=0;
+
+    const Window_t id1 = gVirtualX->GetWindowID(gPad->GetCanvasID());
+    const Window_t id2 = fToolTip->GetParent()->GetId();
+
+    Window_t id3;
+    gVirtualX->TranslateCoordinates(id1, id2, px, py, x, y, id3);
+
+    // Show tool tip
+    fToolTip->SetText(txt);
+    fToolTip->Show(x+4, y+4);
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculate distance to primitive by checking all gui elements
+//
+Int_t MAstroCatalog::DistancetoPrimitive(Int_t px, Int_t py)
+{
+    return fMapG.DistancetoPrimitive(px, py);
+}
+
+// ------------------------------------------------------------------------
+//
+// Returns string containing info about the object at position (px,py).
+// Returned string will be re-used (lock in MT environment).
+//
+char *MAstroCatalog::GetObjectInfo(Int_t px, Int_t py) const
+{
+    return fMapG.GetObjectInfo(px, py);
+}
Index: /tags/Mars_V0-8-5/Mars/mastro/MAstroCatalog.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mastro/MAstroCatalog.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mastro/MAstroCatalog.h	(revision 9661)
@@ -0,0 +1,197 @@
+#ifndef MARS_MAstroCatalog
+#define MARS_MAstroCatalog
+
+#ifndef ROOT_TVector3
+#include <TVector3.h>
+#endif
+#ifndef ROOT_TList
+#include <TList.h>
+#endif
+#ifndef MARS_MGMap
+#include <MGMap.h>
+#endif
+
+class MTime;
+class MObservatory;
+class TArrayI;
+class TGToolTip;
+
+class MVector3 : public TVector3
+{
+private:
+    enum VectorType_t
+    {
+        kIsInvalid,
+        kIsRaDec,
+        kIsZdAz,
+        kIsAltAz,
+        kIsArbitrary
+    };
+
+    VectorType_t fType;
+
+    TString fName;
+
+public:
+    MVector3() { fType=kIsInvalid; }
+    MVector3(const TVector3 &v3) : TVector3(v3) { fType=kIsArbitrary; }
+    Double_t Magnitude() const { return -2.5*TMath::Log10(Mag()); }
+
+    void SetRaDec(Double_t ra, Double_t dec, Double_t mag)
+    {
+        fType = kIsRaDec;
+        SetMagThetaPhi(pow(10, -mag/2.5), TMath::Pi()/2-dec, ra);
+    }
+    void SetName(const TString &str) { fName = str.Strip(TString::kBoth); }
+    void SetZdAz(Double_t zd, Double_t az, Double_t mag)
+    {
+        fType = kIsZdAz;
+        SetMagThetaPhi(pow(10, -mag/2.5), zd, az);
+    }
+    void SetAltAz(Double_t alt, Double_t az, Double_t mag)
+    {
+        fType = kIsAltAz;
+        SetMagThetaPhi(pow(10, -mag/2.5), TMath::Pi()/2-alt, az);
+    }
+
+    const char *GetName() const { return fName; }
+
+    void WriteBinary(ostream &out) const;
+    void ReadBinary(istream &in);
+
+    ClassDef(MVector3, 1) // A specialized TVector3 storing a star-name
+};
+
+class MAstroCatalog : public TObject
+{
+private:
+    Double_t   fLimMag;    // [1]   Limiting Magnitude
+    Double_t   fRadiusFOV; // [deg] Radius of Field of View
+
+    TGToolTip *fToolTip;   //! The tooltip currently displayed
+
+    void ShowToolTip(Int_t px, Int_t py, const char *txt);
+
+    TString FindToken(TString &line, Char_t tok=',');
+
+    Int_t   atoi(const TSubString &sub);
+    Float_t atof(const TSubString &sub);
+    Int_t   atoi(const TString &s);
+    Float_t atof(const TString &s);
+
+//#if ROOT_VERSION_CODE < ROOT_VERSION(4,00,03)
+    Bool_t fPlainScreen;  //! Just a dummy!!!! ([Set,Is]Freezed)
+    Bool_t fNoToolTips;   //! Just a dummy!!!! ([Set,Is]Freezed)
+//#endif
+
+    virtual Int_t ConvertToPad(const TVector3 &w, TVector2 &v) const;
+    virtual void  AddPrimitives(TString o);
+    virtual void  SetRangePad(Option_t *o);
+
+    Int_t  Convert(const TRotation &rot, TVector2 &v) const;
+    void   Draw(const TVector2 &v0, const TRotation &rot, TArrayI &dx, TArrayI &dy, Int_t stepx, Int_t stepy, Int_t type);
+    void   DrawPrimitives(Option_t *o);
+    Bool_t DrawLine(const TVector2 &v0, Int_t dx, Int_t dy, const TRotation &rot, Int_t type);
+    void   DrawGrid(const TVector3 &v0, const TRotation &rot, Int_t type);
+    void   Paint(Option_t *o="");
+    Int_t  DistancetoPrimitive(Int_t px, Int_t py);
+
+protected:
+    enum {
+        kHasChanged   = BIT(15), // Display has changed
+        kGuiActive    = BIT(16), // GUI is interactive
+        kPlainScreen  = BIT(17), // View is a plain screen view
+        kMirrorX      = BIT(18), // Mirror display in X
+        kMirrorY      = BIT(19), // Mirror display in Y
+        kNoToolTips   = BIT(20), // suppress tooltips
+        kDrawingImage = BIT(21)  // just drawing into a bitmap
+    };
+
+    MGMap    fMapG;              //! A map with all gui primitives and tooltips
+
+    TList    fList;              // List of stars loaded
+    MVector3 fRaDec;             // pointing position
+
+    MObservatory *fObservatory;  // Possible obervatory location
+    MTime        *fTime;         // Possible observation time
+
+    TRotation AlignCoordinates(const TVector3 &v) const;
+    virtual TString GetPadTitle() const;
+    TRotation GetGrid(Bool_t local);
+    void      DrawStar(Double_t x, Double_t y, const TVector3 &v, Int_t col, const char *txt=0, Bool_t resize=kFALSE);
+    void      Update(Bool_t upd=kFALSE);
+
+    void      ExecuteEventKbd(Int_t keycode, Int_t keysym);
+    void      ExecuteEvent(Int_t event, Int_t mp1, Int_t mp2);
+    char     *GetObjectInfo(Int_t px, Int_t py) const;
+
+public:
+    MAstroCatalog();
+    ~MAstroCatalog();
+
+    void SetTime(const MTime &time);
+    void SetObservatory(const MObservatory &obs);
+    void SetLimMag(Double_t mag) { fLimMag=mag; Update(); } // *MENU* *ARGS={mag=>fLimMag}
+    void SetRadiusFOV(Double_t deg)
+    {
+        //const Double_t max = TestBit(kPlainScreen) ? 90 : 55;
+        const Double_t max = TestBit(kPlainScreen) ? 180 : 90;
+        if (deg>max)
+            deg=max;
+        if (deg<1)
+            deg=1;
+
+        fRadiusFOV=deg;
+
+        Update();
+    } // *MENU* *ARGS={deg=>fRadiusFOV}
+    void SetRadiusFOV(Double_t pixsize, Double_t w, Double_t h)
+    {
+        // pixsize [arcsec/pixel]
+        // w       [pixel]
+        // h       [pixel]
+        const Double_t scale = TMath::Hypot(w, h)/2;
+        SetRadiusFOV(scale*pixsize/3600);
+    } // Set Radius of FOV using the pixsize [arcsec/pix], width and height [pixel] of image
+
+    void SetRaDec(Double_t ra, Double_t dec) { fRaDec.SetRaDec(ra, dec, 1); Update(); }
+    void SetRaDec(const TVector3 &v)         { fRaDec=v; Update(); }
+    void SetGuiActive(Bool_t b=kTRUE)        { b ? SetBit(kGuiActive) : ResetBit(kGuiActive); }
+
+    void   SetPlainScreen(Bool_t b=kTRUE)    { b ? SetBit(kPlainScreen) : ResetBit(kPlainScreen); Update(); } // *TOGGLE* *GETTER=IsPlainScreen
+    Bool_t IsPlainScreen() const             { return TestBit(kPlainScreen); }
+
+    void   SetNoToolTips(Bool_t b=kTRUE)     { b ? SetBit(kNoToolTips) : ResetBit(kNoToolTips); } // *TOGGLE* *GETTER=HasNoToolTips
+    Bool_t HasNoToolTips() const             { return TestBit(kNoToolTips); }
+
+    Double_t GetLimMag() const { return fLimMag; } // Get Limiting Magnitude
+    Double_t GetRadiusFOV() const { return fRadiusFOV; } // Get maximum radius of Field Of View
+
+    void Delete(Option_t *o="") { fList.Delete(); fMapG.Delete(); } // Delete list of stars
+
+    Int_t ReadXephem(TString catalog = "/usr/X11R6/lib/xephem/catalogs/YBS.edb");
+    Int_t ReadNGC2000(TString catalog = "ngc2000.dat");
+    Int_t ReadBSC(TString catalog = "bsc5.dat");
+    Int_t ReadHeasarcPPM(TString catalog = "heasarc_ppm.tdat", TString fout="");
+    Int_t ReadCompressed(TString catalog);
+    Bool_t AddObject(Float_t ra, Float_t dec, Float_t mag, TString name="");
+
+    void Print(Option_t *o="") const { fList.Print(); } // Print all stars
+
+    TList *GetList() { return &fList; } // Return list of stars
+
+    //void PaintImg(Int_t id=0, Option_t *o="");
+    void PaintImg(unsigned char *buf, int w=768, int h=576, Option_t *o=0);
+    void Draw(Option_t *o="");
+    void SetDrawOption(Option_t *option="")
+    {
+        TObject::SetDrawOption(option);
+        Update(kTRUE);
+    } //*MENU*
+
+    virtual void EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected=0);
+
+    ClassDef(MAstroCatalog, 1) // Display class for star catalogs
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mastro/MAstroSky2Local.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mastro/MAstroSky2Local.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mastro/MAstroSky2Local.cc	(revision 9661)
@@ -0,0 +1,140 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 11/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MAstroSky2Local
+// ---------------
+//
+// Rotation Matrix to convert sky coordinates to ideal local coordinates
+// for example:
+//
+//   const Double_t ra  = MAstro::Hms2Rad(5, 34, 31.9);
+//   const Double_t dec = MAstro::Dms2Rad(22, 0, 52.0);
+//
+//   MTime time;
+//   time.Set(2004, 1, 26, 00, 20, 00);
+//
+//   MObservatory obs(MObservatory::kMagic1);
+//
+//   TVector3 v;
+//   v.SetMagThetaPhi(1, TMath::Pi()/2-dec, ra);
+//
+//   v *= MAstroSky2Local(time, obs);
+//
+//   Double_t azimuth   = v.Phi();
+//   Double_t zdistance = v.Theta();
+//
+// To get the inverse matrix for an inverse transformation you can use:
+//
+//   MAstroSky2Local::Invert()
+//
+// or simply do:
+//
+//   v *= MAstroSky2Local(time, obs).Inverse();
+//
+// Reminder: This tranformation only does a simple coordinate
+//           transformation. It completely ignores all other atrometric
+//           effects, like nutation, abberation, precission, ...
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MAstroSky2Local.h"
+
+#include "MAstro.h"
+#include "MTime.h"
+#include "MObservatory.h"
+
+using namespace std;
+
+ClassImp(MAstroSky2Local);
+
+// --------------------------------------------------------------------------
+//
+// Initialize the rotation matrix R as:
+//
+//   R = A*B*C*D
+//
+// with
+//
+//       |1  0  0|
+//   A = |0 -1  0|    (Change counting direction of rotation angle)
+//       |0  0  1|
+//
+//   B = RotZ(r1)     (Change rotation angle such, that phi=0 is identical
+//                     for both coordinate systems)
+//
+//   C = RotY(r2)     (Make zenith and sky pole the same point)
+//
+//   D = RotZ(180deg) (Align rottaion angle to N=0, E=90)
+//
+// with
+//
+//   r1 = gmst + longitude   with   gmst fraction of day, see MTime::GetGmst
+//                                  logitude of observers location
+//
+//   r2 = latitude-90deg     with   latitude of observers location
+//
+void MAstroSky2Local::Init(Double_t gmst, const MObservatory &obs)
+{
+    RotateZ(gmst + obs.GetElong());
+    RotateY(obs.GetPhi()-TMath::Pi()/2);
+    RotateZ(TMath::Pi());
+}
+
+// --------------------------------------------------------------------------
+//
+// Initialize MAstroSky2Local for a given time an a defined observatory
+// For more information see class description
+// For more information about gmst see MTime::GetGmst()
+//
+MAstroSky2Local::MAstroSky2Local(Double_t gmst, const MObservatory &obs) : TRotation(1, 0, 0, 0, -1, 0, 0, 0, 1)
+{
+    Init(gmst, obs);
+}
+
+// --------------------------------------------------------------------------
+//
+// Initialize MAstroSky2Local for a given time an a defined observatory
+// For more information see class description
+//
+MAstroSky2Local::MAstroSky2Local(const MTime &t, const MObservatory &obs) : TRotation(1, 0, 0, 0, -1, 0, 0, 0, 1)
+{
+    Init(t.GetGmst(), obs);
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the corresponding rotation angle of the sky coordinate system
+// seen with an Alt/Az telescope.
+//
+// For more information see MAstro::RotationAngle
+//
+Double_t MAstroSky2Local::RotationAngle(Double_t ra, Double_t dec) const
+{
+    TVector3 v;
+    v.SetMagThetaPhi(1, TMath::Pi()/2-dec, ra);
+    v *= *this;
+
+    return MAstro::RotationAngle(ZZ(), XZ(), v.Theta(), v.Phi());
+}
Index: /tags/Mars_V0-8-5/Mars/mastro/MAstroSky2Local.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mastro/MAstroSky2Local.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mastro/MAstroSky2Local.h	(revision 9661)
@@ -0,0 +1,25 @@
+#ifndef MARS_MAstroSky2Local
+#define MARS_MAstroSky2Local
+
+#ifndef ROOT_TRotation
+#include <TRotation.h>
+#endif
+
+class MTime;
+class MObservatory;
+
+class MAstroSky2Local : public TRotation
+{
+private:
+    void Init(Double_t gmst, const MObservatory &obs);
+
+public:
+    MAstroSky2Local(Double_t gmst,  const MObservatory &obs);
+    MAstroSky2Local(const MTime &t, const MObservatory &obs);
+
+    Double_t RotationAngle(Double_t ra, Double_t dec) const;
+
+    ClassDef(MAstroSky2Local, 1) // Rotation Matrix to convert sky coordinates to ideal local coordinates
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mastro/MObservatory.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mastro/MObservatory.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mastro/MObservatory.cc	(revision 9661)
@@ -0,0 +1,131 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Robert Wagner  10/2002 <mailto:magicsoft@rwagner.de>
+!   Author(s): Thomas Bretz   2/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2002-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MObservatory
+//
+// BE EXTREMLY CARFEFULL CHANGING THIS CLASS! THE TRACKING SYSTEM IS BASED
+// ON IT!
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MObservatory.h"
+
+#include <TVector3.h>
+
+#include "MTime.h"
+#include "MAstro.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MObservatory);
+
+using namespace std;
+
+void MObservatory::Init(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MObservatory";
+    fTitle = title ? title : "Storage container for coordinates of an observatory";   
+}
+
+MObservatory::MObservatory(const char *name, const char *title)
+{
+    Init(name, title);
+
+    SetLocation(kMagic1);
+}
+
+MObservatory::MObservatory(LocationName_t key, const char *name, const char *title)
+{
+    Init(name, title);
+
+    SetLocation(key);
+}
+
+// --------------------------------------------------------------------------
+//
+// BE EXTREMLY CARFEFULL CHANGING THIS CLASS! THE TRACKING SYSTEM IS BASED
+// ON IT!
+//
+void MObservatory::SetLocation(LocationName_t name)
+{
+    switch (name)
+    {
+        // BE EXTREMLY CARFEFULL CHANGING THIS CLASS!
+        // THE TRACKING SYSTEM IS BASED ON IT!
+    case kMagic1:
+        // Values taken from the GPS Receiver (avg 24h)
+        // on 29/04/2004 at 17h30 in the counting house
+        fLatitude  = MAstro::Dms2Rad(28, 45, 42.462, '+');
+        fLongitude = MAstro::Dms2Rad(17, 53, 26.525, '-');
+        fHeight    = 2199.4; // m
+        fObservatoryName = "Observatorio del Roque de los Muchachos (Magic1)";
+        break;
+
+    case kWuerzburgCity:
+        fLatitude  = MAstro::Dms2Rad(51, 38, 48.0);
+        fLongitude = MAstro::Dms2Rad( 9, 56, 36.0);
+        fHeight    = 300;
+        fObservatoryName = "Wuerzburg City";
+        break;
+    }
+
+    fSinLatitude = TMath::Sin(fLatitude);
+    fCosLatitude = TMath::Cos(fLatitude);
+}
+
+void MObservatory::Print(Option_t *) const
+{
+    *fLog << all;
+    *fLog << underline << fObservatoryName << ":" << endl;
+    *fLog << "Latitude:  " << TMath::Abs(fLatitude*kRad2Deg)  << " deg " << (fLatitude  > 0 ? "W" : "E") << endl;
+    *fLog << "Longitude: " << TMath::Abs(fLongitude*kRad2Deg) << " deg " << (fLongitude < 0 ? "N" : "S") << endl;
+    *fLog << "Height:    " << fHeight << "m" << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the corresponding rotation angle of the sky coordinate system
+// seen with an Alt/Az telescope.
+//
+// For more information see MAstro::RotationAngle
+//
+void MObservatory::RotationAngle(Double_t theta, Double_t phi, Double_t &sin, Double_t &cos) const
+{
+    MAstro::RotationAngle(fSinLatitude, fCosLatitude, theta, phi, sin, cos);
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the corresponding rotation angle of the sky coordinate system
+// seen with an Alt/Az telescope.
+//
+// For more information see MAstro::RotationAngle
+//
+Double_t MObservatory::RotationAngle(Double_t theta, Double_t phi) const
+{
+    return MAstro::RotationAngle(fSinLatitude, fCosLatitude, theta, phi);
+}
Index: /tags/Mars_V0-8-5/Mars/mastro/MObservatory.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mastro/MObservatory.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mastro/MObservatory.h	(revision 9661)
@@ -0,0 +1,77 @@
+#ifndef MARS_MObservatory
+#define MARS_MObservatory
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MTime;
+
+class MObservatory : public MParContainer
+{
+public:
+    enum LocationName_t
+    {
+        kMagic1,
+        kWuerzburgCity
+    };
+
+private:
+    LocationName_t fObservatoryKey;  //!
+
+    TString  fObservatoryName;       //! Name of the observatory
+
+    Double_t fLongitude;             //! [rad] Longitude of observatory (+ east)
+    Double_t fLatitude;              //! [rad] Latitude of observatory (+ north)
+
+    Double_t fSinLatitude;           //! Sin component for faster access
+    Double_t fCosLatitude;           //! Cos component for faster access
+
+    Double_t fHeight;                //! [m] height of observatory
+
+    void Init(const char *name, const char *title);
+
+public:
+    MObservatory(const char *name=NULL, const char *title=NULL);
+    MObservatory(LocationName_t key, const char *name=NULL, const char *title=NULL);
+
+    void Copy(TObject &obj) const
+    {
+        MObservatory &obs = (MObservatory&)obj;
+        obs.fObservatoryName = fObservatoryName;
+        obs.fLongitude = fLongitude;
+        obs.fLatitude = fLatitude;
+        obs.fSinLatitude = fSinLatitude;
+        obs.fCosLatitude = fCosLatitude;
+        obs.fHeight = fHeight;
+    }
+
+    void SetLocation(LocationName_t name);
+
+    void Print(Option_t *o=0) const;
+
+    const TString &GetObservatoryName() const { return fObservatoryName; }
+
+    Double_t GetLatitudeDeg() const     { return fLatitude*kRad2Deg; }  //[deg]
+    Double_t GetLongitudeDeg() const    { return fLongitude*kRad2Deg; } //[deg]
+
+    Double_t GetLatitudeRad() const     { return fLatitude; }           //[rad]
+    Double_t GetLongitudeRad() const    { return fLongitude; }          //[rad]
+
+    Double_t GetPhi() const             { return fLatitude; }           //[rad]
+    Double_t GetElong() const           { return fLongitude; }          //[rad]
+
+    Double_t GetSinPhi() const          { return fSinLatitude; }
+    Double_t GetCosPhi() const          { return fCosLatitude; }
+
+    Double_t GetHeight() const          { return fHeight; }
+
+    void RotationAngle(Double_t theta, Double_t phi, Double_t &sin, Double_t &cos) const;
+    Double_t RotationAngle(Double_t theta, Double_t phi) const;
+
+    LocationName_t GetObservatoryKey() const { return fObservatoryKey; }
+
+    ClassDef(MObservatory, 0) // class storing observatory locations
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mastro/Makefile
===================================================================
--- /tags/Mars_V0-8-5/Mars/mastro/Makefile	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mastro/Makefile	(revision 9661)
@@ -0,0 +1,36 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#------------------------------------------------------------------------------
+
+#
+# Handling name of the Root Dictionary Files
+#
+CINT  = Astro
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES =  -I. -I../mbase -I../mgeom -I../mtemp
+# mgeom (MAstroCamera): MGeomCam, MGeomMirror
+
+SRCFILES = MAstro.cc \
+	   MAstroSky2Local.cc \
+	   MAstroCatalog.cc \
+           MAstroCamera.cc \
+           MObservatory.cc
+
+############################################################
+
+all: $(OBJS)
+
+include ../Makefile.rules
+
+mrproper:	clean rmbak
Index: /tags/Mars_V0-8-5/Mars/mbadpixels/BadPixelsIncl.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbadpixels/BadPixelsIncl.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbadpixels/BadPixelsIncl.h	(revision 9661)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-8-5/Mars/mbadpixels/BadPixelsLinkDef.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbadpixels/BadPixelsLinkDef.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbadpixels/BadPixelsLinkDef.h	(revision 9661)
@@ -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 MBadPixelsPix+;
+#pragma link C++ class MBadPixelsCam+;
+
+#pragma link C++ class MBadPixelsCalc+;
+#pragma link C++ class MBadPixelsTreat+;
+#pragma link C++ class MBadPixelsMerge+;
+
+#pragma link C++ class MMcBadPixelsSet+;
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mbadpixels/MBadPixelsCalc.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbadpixels/MBadPixelsCalc.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbadpixels/MBadPixelsCalc.cc	(revision 9661)
@@ -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, 02/2004 <mailto:tbretz@astro.uni.wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MBadPixelsCalc
+//
+//
+// The job of the task is to determin bad pixels event-wise. This must be
+// redone for each event. This particular task is for what is explained
+// below.
+// New algorithms may enter new tasks.
+//
+//
+// Check the pedestal RMS of every pixel with respect to the mean
+// pedestal RMS of the camera (Sigmabar).
+//
+// The pixels can be set as blind if the pedestalRMS is too big or 0.
+//
+// If you don't want to use this option set the PedestalLevel<=0;
+//
+//     MBadPixelsCalc calc;
+//     calc.SetPedestalLevel(-1);
+//
+//
+//  Input Containers:
+//   [MPedPhotCam]
+//   [MGeomCam]
+//   [MSigmabar]
+//
+//  Output Containers:
+//   MBadPixels
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MBadPixelsCalc.h"
+
+#include <TArrayD.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MGeomCam.h"
+#include "MGeomPix.h"
+
+#include "MSigmabar.h"
+
+#include "MPedPhotCam.h"
+#include "MPedPhotPix.h"
+
+#include "MBadPixelsCam.h"
+#include "MBadPixelsPix.h"
+
+ClassImp(MBadPixelsCalc);
+
+using namespace std;
+
+static const TString gsDefName  = "MBadPixelsCalc";
+static const TString gsDefTitle = "Find hot spots (star, broken pixels, etc)";
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MBadPixelsCalc::MBadPixelsCalc(const char *name, const char *title)
+    : fPedestalLevel(3)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+}
+
+// --------------------------------------------------------------------------
+//
+//
+Int_t MBadPixelsCalc::PreProcess (MParList *pList)
+{
+    fBadPixels = (MBadPixelsCam*)pList->FindCreateObj(AddSerialNumber("MBadPixelsCam"));
+    if (!fBadPixels)
+        return kFALSE;
+
+    if (fPedestalLevel>0)
+    {
+        fPedPhotCam = (MPedPhotCam*)pList->FindObject(AddSerialNumber("MPedPhotCam"));
+        if (!fPedPhotCam)
+        {
+            *fLog << err << "MPedPhotCam not found... aborting." << endl;
+            return kFALSE;
+        }
+
+        fGeomCam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
+        if (!fGeomCam)
+        {
+            *fLog << err << "MGeomCam not found... aborting." << endl;
+            return kFALSE;
+        }
+
+        fSigmabar = (MSigmabar*)pList->FindObject(AddSerialNumber("MSigmabar"));
+        if (!fSigmabar)
+        {
+            *fLog << err << "MSigmabar not found... aborting." << endl;
+            return kFALSE;
+        }
+    }
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Check the pedestal RMS of every pixel with respect to the mean pedestal RMS 
+// of the camera (Sigmabar).
+//
+// The pixels can be set as blind if the pedestalRMS is too big or 0.
+//
+// If you don't want to use this option set the PedestalLevel<=0;
+//
+//     MBadPixelsCalc calc;
+//     calc.SetPedestalLevel(-1);
+//
+void MBadPixelsCalc::CheckPedestalRMS() const
+{
+    const Int_t entries = fPedPhotCam->GetSize();
+
+    const Float_t meanPedRMS = fSigmabar->GetSigmabar();
+
+    for (Int_t i=0; i<entries; i++)
+    {
+        //
+        // get pixel as entry from list
+        //
+        const Double_t nratio    = fGeomCam->GetPixRatio(i);
+        const Double_t pixPedRms = (*fPedPhotCam)[i].GetRms();
+
+        if (pixPedRms*nratio > fPedestalLevel * meanPedRMS || pixPedRms == 0)
+            (*fBadPixels)[i].SetUnsuitable(MBadPixelsPix::kUnsuitableEvt);
+    }
+}
+
+// --------------------------------------------------------------------------
+// Check the pedestal Rms of the pixels: compute with 2 iterations the mean 
+// for inner and outer pixels. Set as blind the pixels with too small or 
+// too high pedestal Rms with respect to the mean.
+// 
+Bool_t MBadPixelsCalc::CheckPedestalRms() const
+{
+    const Int_t entries = fPedPhotCam->GetSize();
+
+    const Int_t na = fGeomCam->GetNumAreas();
+
+    TArrayD meanrms(na);
+    TArrayI npix(na);
+
+    for (Int_t i=0; i<entries; i++)
+    {
+        const Double_t rms = (*fPedPhotCam)[i].GetRms();
+
+        if (rms<=0 || rms>=200*fGeomCam->GetPixRatioSqrt(i))
+            continue;
+
+        const Byte_t aidx = (*fGeomCam)[i].GetAidx();
+
+        meanrms[aidx] += rms;
+        npix[aidx]++;
+    }
+
+    //if no pixel has a minimum signal, return
+    for (int i=0; i<na; i++)
+    {
+        if (npix[i]==0 || meanrms[i]==0)
+        {
+            //fErrors[1]++;          //no valid Pedestals Rms
+            return kFALSE;
+        }
+
+        meanrms[i] /= npix[i];
+        npix[i]=0;
+    }
+
+    TArrayD meanrms2(na);
+    for (Int_t i=0; i<entries; i++)
+    {
+        const Double_t rms = (*fPedPhotCam)[i].GetRms();
+        const Byte_t  aidx = (*fGeomCam)[i].GetAidx();
+
+        //Calculate the corrected means:
+
+        if (rms<=0.5*meanrms[aidx] || rms>=1.5*meanrms[aidx])
+            continue;
+
+        meanrms2[aidx] += rms;
+        npix[aidx]++;
+    }
+
+    //if no pixel has a minimum signal, return
+    for (int i=0; i<na; i++)
+    {
+        if (npix[i]==0 || meanrms2[i]==0)
+        {
+            //fErrors[1]++;          //no valid Pedestals Rms
+            return kFALSE;
+        }
+
+        meanrms2[i] /= npix[i];
+    }
+
+    Int_t bads = 0;
+
+    //Blind the Bad Pixels
+    for (Int_t i=0; i<entries; i++)
+    {
+        const Double_t rms = (*fPedPhotCam)[i].GetRms();
+        const Byte_t  aidx = (*fGeomCam)[i].GetAidx();
+
+        if (rms>meanrms2[aidx]/3 && rms<=meanrms2[aidx]*3)
+            continue;
+
+        (*fBadPixels)[i].SetUnsuitable(MBadPixelsPix::kUnsuitableEvt);
+        bads++;
+    }
+
+    // Check if the number of pixels to blind is > 60% of total number of pixels
+    //
+    if (bads>0.6*entries)
+    {
+        //fErrors[2]++;
+        return kFALSE;
+    }
+
+    return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
+//
+Int_t MBadPixelsCalc::Process()
+{
+    if (fPedestalLevel>0)
+        CheckPedestalRms();
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mbadpixels/MBadPixelsCalc.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbadpixels/MBadPixelsCalc.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbadpixels/MBadPixelsCalc.h	(revision 9661)
@@ -0,0 +1,42 @@
+#ifndef MARS_MBadPixelsCalc
+#define MARS_MBadPixelsCalc
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MBadPixelsCam;
+class MSigmabar;
+class MGeomCam;
+class MPedPhotCam;
+
+class MBadPixelsCalc : public MTask
+{
+private:
+    MGeomCam      *fGeomCam;    //! Input container storing the pixel sizes
+    MSigmabar     *fSigmabar;   //! Input container storing mean pedestal rms of the camera
+    MPedPhotCam   *fPedPhotCam; //! Input container storing the pedestal and pedestal rms of all pixels
+
+    MBadPixelsCam *fBadPixels;  //! Output container holding the bad pixels
+
+    Float_t fPedestalLevel;
+
+    void CheckPedestalRMS() const;
+    Bool_t CheckPedestalRms() const;
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
+public:
+    MBadPixelsCalc(const char *name=NULL, const char *title=NULL);
+
+    void SetPedestalLevel(Float_t f) { fPedestalLevel=f; }
+
+    ClassDef(MBadPixelsCalc, 1) // Task to find bad pixels (star, broken pixels, etc)
+}; 
+
+#endif
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mbadpixels/MBadPixelsCam.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbadpixels/MBadPixelsCam.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbadpixels/MBadPixelsCam.cc	(revision 9661)
@@ -0,0 +1,597 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!              Markus Gaug  3/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MBadPixelsCam                                                                                                                              //
+//
+// Storage container to store bad pixel of the camera...
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MBadPixelsCam.h"
+
+#include <fstream>
+
+#include <TClonesArray.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MBadPixelsPix.h"
+
+ClassImp(MBadPixelsCam);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MBadPixelsCam::MBadPixelsCam(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MBadPixelsCam";
+    fTitle = title ? title : "Storage container to store bad pixel information";
+
+    fArray = new TClonesArray("MBadPixelsPix", 1);
+}
+
+MBadPixelsCam::MBadPixelsCam(const MBadPixelsCam &cam)
+{
+    fName  = "MBadPixelsCam";
+    fTitle = "Storage container to store bad pixel information";
+
+    fArray = new TClonesArray("MBadPixelsPix", 1);
+    cam.Copy(*this);
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the array conatining the bad pixel information
+//
+MBadPixelsCam::~MBadPixelsCam()
+{
+    delete fArray;
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the size of the camera
+//
+void MBadPixelsCam::InitSize(const UInt_t i)
+{
+    fArray->ExpandCreate(i);
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the size of the MBadPixelsCam
+//
+Int_t MBadPixelsCam::GetSize() const
+{
+    return fArray->GetEntriesFast();
+}
+
+// --------------------------------------------------------------------------
+//
+// Copy 'constructor'
+//
+void MBadPixelsCam::Copy(TObject &object) const
+{
+    MBadPixelsCam &cam = (MBadPixelsCam&)object;
+
+    const Int_t n = GetSize();
+
+    if (n==0)
+        return;
+
+    cam.InitSize(n);
+    for (int i=0; i<n; i++)
+        (*this)[i].Copy(cam[i]);
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th pixel (pixel number)
+//
+MBadPixelsPix &MBadPixelsCam::operator[](Int_t i)
+{
+    return *static_cast<MBadPixelsPix*>(fArray->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th pixel (pixel number)
+//
+const MBadPixelsPix &MBadPixelsCam::operator[](Int_t i) const
+{
+    return *static_cast<MBadPixelsPix*>(fArray->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Merge two MBadPixelsCam together, see also MBadPixelsPix::Merge
+//
+void MBadPixelsCam::Merge(const MBadPixelsCam &cam)
+{
+    const Int_t n = cam.GetSize();
+    if (n==0)
+    {
+        *fLog << warn << "MBadPixelsCam::Merge: Container empty." << endl;
+        return;
+    }
+
+    if (GetSize()==0)
+        InitSize(n);
+
+    if (n!=GetSize())
+    {
+        *fLog << warn << "MBadPixelsCam::Merge: Size mismatch... ignored." << endl;
+        return;
+    }
+
+    for (int i=0; i<n; i++)
+        (*this)[i].Merge(cam[i]);
+}
+
+// --------------------------------------------------------------------------
+//
+// Clear the contents of all bad pixels (set=0 means Ok)
+//
+void MBadPixelsCam::Clear(Option_t *o)
+{
+    fArray->ForEach(TObject, Clear)();
+}
+
+// --------------------------------------------------------------------------
+//
+// Print the contents of all bad pixels
+//
+void MBadPixelsCam::Print(Option_t *o) const
+{
+  *fLog << all << GetDescriptor() << ":" << endl;
+  
+  *fLog << "Pixels without problems:" << endl;
+  *fLog << endl;
+    
+  Int_t count = 0;
+  
+  for (Int_t i=0; i<GetSize(); i++)
+    {
+      if (!(*this)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
+        {
+          *fLog << i << " ";
+          count ++;
+        }
+      
+      if (count == 0)
+        continue;
+      
+      if (!(count % 25))
+        *fLog << endl;
+    }
+  *fLog << endl;
+  *fLog << count << " normal pixels :-))" << endl;
+  *fLog << endl;
+  count = 0;
+  
+  
+  *fLog << "Pixels unsuited for the whole run:" << endl;
+  *fLog << endl;
+  
+  for (Int_t i=0; i<GetSize(); i++)
+    {
+      if ((*this)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
+        {
+          *fLog << i << " ";
+          count ++;
+        }
+      
+      if (count == 0)
+        continue;
+      
+      if (!(count % 25))
+        *fLog << endl;
+    }
+  *fLog << endl;
+  *fLog << count << " unsuited pixels :-(" << endl;
+  *fLog << endl;
+  
+  count = 0;
+  
+  *fLog << all << "Pixels unreliable for the whole run:" << endl;
+  *fLog << all << endl;
+  
+  for (Int_t i=0; i<GetSize(); i++)
+    {
+      if ((*this)[i].IsUnsuitable(MBadPixelsPix::kUnreliableRun))
+        {
+          *fLog << i << " ";
+          count ++;
+        }
+      
+      if (count == 0)
+        continue;
+      
+      if (!(count % 25))
+        *fLog << endl;
+    }
+  
+  *fLog << endl;
+  *fLog << count << " unreliable pixels :-(" << endl;
+  *fLog << endl;
+
+  count = 0;
+  
+  *fLog << all << "Charge is Pedestal:" << endl;
+  *fLog << all << endl;
+  
+  for (Int_t i=0; i<GetSize(); i++)
+    {
+      if ((*this)[i].IsUncalibrated(MBadPixelsPix::kChargeIsPedestal))
+        {
+          *fLog << i << " ";
+          count ++;
+        }
+      
+      if (count == 0)
+        continue;
+      
+      if (!(count % 25))
+        *fLog << endl;
+    }
+  
+  *fLog << endl;
+  *fLog << count << " ChargeIsPedestal :-(" << endl;
+  *fLog << endl;
+
+  count = 0;
+  
+  *fLog << all << "Charge Sigma not valid:" << endl;
+  *fLog << all << endl;
+  
+  for (Int_t i=0; i<GetSize(); i++)
+    {
+      if ((*this)[i].IsUncalibrated(MBadPixelsPix::kChargeSigmaNotValid))
+        {
+          *fLog << i << " ";
+          count ++;
+        }
+      
+      if (count == 0)
+        continue;
+      
+      if (!(count % 25))
+        *fLog << endl;
+    }
+  
+  *fLog << endl;
+  *fLog << count << " ChargeSigmaNotValid :-(" << endl;
+  *fLog << endl;
+
+  count = 0;
+  
+  *fLog << all << "Rel. Error Charge not valid:" << endl;
+  *fLog << all << endl;
+  
+  for (Int_t i=0; i<GetSize(); i++)
+    {
+      if ((*this)[i].IsUncalibrated(MBadPixelsPix::kChargeRelErrNotValid))
+        {
+          *fLog << i << " ";
+          count ++;
+        }
+      
+      if (count == 0)
+        continue;
+      
+      if (!(count % 25))
+        *fLog << endl;
+    }
+  
+  *fLog << endl;
+  *fLog << count << " ChargeRelErrNotValid :-(" << endl;
+  *fLog << endl;
+
+
+  count = 0;
+  
+  *fLog << all << " Deviating number photo-electrons:" << endl;
+  *fLog << all << endl;
+  
+  for (Int_t i=0; i<GetSize(); i++)
+    {
+      if ((*this)[i].IsUncalibrated(MBadPixelsPix::kDeviatingNumPhes))
+        {
+          *fLog << i << " ";
+          count ++;
+        }
+      
+      if (count == 0)
+        continue;
+      
+      if (!(count % 25))
+        *fLog << endl;
+    }
+  
+  *fLog << endl;
+  *fLog << count << " DeviatingNumPhes :-(" << endl;
+  *fLog << endl;
+
+  count = 0;
+  
+  *fLog << all << " Deviating F-Factor:" << endl;
+  *fLog << all << endl;
+  
+  for (Int_t i=0; i<GetSize(); i++)
+    {
+      if ((*this)[i].IsUncalibrated(MBadPixelsPix::kDeviatingFFactor))
+        {
+          *fLog << i << " ";
+          count ++;
+        }
+      
+      if (count == 0)
+        continue;
+      
+      if (!(count % 25))
+        *fLog << endl;
+    }
+  
+  *fLog << endl;
+  *fLog << count << " DeviatingFFactor :-(" << endl;
+  *fLog << endl;
+
+}
+
+// --------------------------------------------------------------------------
+//
+// Read from an ascii file of the format:
+//    pixel1 pixel2 pixel3 pixel4
+// while pixel1,2,3,4 are the pixel indices used in the software.
+//
+// To read the pixels corresponding to a given run you can give run!=0
+// and a file of the format:
+//   1234: 17 193 292
+//   1235: 17 193 292 293
+//
+void MBadPixelsCam::AsciiRead(ifstream &fin, UInt_t run=0)
+{
+    Int_t len;
+    TString str;
+
+    while (1)
+    {
+        str.ReadLine(fin);
+        if (!fin)
+            return;
+
+        Int_t r;
+
+        const Int_t n = sscanf(str.Data(), " %d : %n", &r, &len);
+        if (n!=1)
+            return;
+
+        if (run==0 || run && (UInt_t)r==run)
+            break;
+    }
+
+    str.Remove(0, len);
+
+    while (1)
+    {
+        Int_t idx;
+        const Int_t n = sscanf(str.Data(), " %d %n", &idx, &len);
+
+        if (n!=1)
+            break;
+
+        str.Remove(0, len);
+
+        if (idx>=GetSize())
+            InitSize(idx+1);
+
+        (*this)[idx].SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Write the information into an ascii file. If a run-number is given the
+// run-number will lead the line.
+//
+Bool_t MBadPixelsCam::AsciiWrite(ostream &fout, UInt_t run=0) const
+{
+    if (run)
+        fout << run << ":";
+
+    for (int i=0; i<GetSize(); i++)
+        if ((*this)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
+            fout << " " << i;
+
+    if (run && GetSize())
+        fout << endl;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// The types are the following:
+// 0: MBadPixelsPix::GetInfo()[0]
+// 1: MBadPixelsPix::IsUnsuitable(MBadPixelsPix::kUnsuitableRun)
+// 2: MBadPixelsPix::IsUnsuitable(MBadPixelsPix::kUnsuitableEvt)
+// 3: MBadPixelsPix::IsUnsuitable(MBadPixelsPix::kUnreliableRun)
+// 4: MBadPixelsPix::IsHiGainBad()
+// 5: MBadPixelsPix::IsLoGainBad()
+// 8: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kHiGainNotFitted)
+// 9: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kLoGainNotFitted)
+// 10: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kHiGainOscillating)
+// 11: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kLoGainOscillating)
+// 12: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kLoGainSaturation )
+// 13: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kChargeIsPedestal )
+// 14: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kChargeErrNotValid)
+// 15: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kChargeRelErrNotValid)
+// 16: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kChargeSigmaNotValid )
+// 17: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kMeanTimeInFirstBin  )
+// 18: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kMeanTimeInLast2Bins )
+// 19: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kDeviatingNumPhes    )
+// 20: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kRelTimeNotFitted )
+// 21: MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kRelTimeOscillating  )
+//
+Bool_t MBadPixelsCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
+{
+
+  if (idx >= GetSize())
+    return kFALSE;
+
+  switch (type)
+    {
+    case 0:
+      return (*this)[idx].GetInfo()[0];
+    case 1:
+      if  ((*this)[idx].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
+        val = 1;
+      else
+        return kFALSE;
+      break;
+    case 2:
+      if  ((*this)[idx].IsUnsuitable(MBadPixelsPix::kUnsuitableEvt))
+        val = 1;
+      else
+        return kFALSE;
+      break;
+    case 3:
+      if  ((*this)[idx].IsUnsuitable(MBadPixelsPix::kUnreliableRun))
+        val = 1;
+      else
+        return kFALSE;
+      break;
+    case 4:
+      if  ((*this)[idx].IsHiGainBad())
+        val = 1;
+      else
+        return kFALSE;
+      break;
+    case 5:
+      if  ((*this)[idx].IsLoGainBad())
+        val = 1;
+      else
+        return kFALSE;
+      break;
+    case 8:
+      if  ((*this)[idx].IsUncalibrated(MBadPixelsPix::kHiGainNotFitted))
+        val = 1;
+      else
+        return kFALSE;
+      break;
+    case 9:
+      if  ((*this)[idx].IsUncalibrated(MBadPixelsPix::kLoGainNotFitted))
+        val = 1;
+      else
+        return kFALSE;
+      break;
+    case 10:
+      if  ((*this)[idx].IsUncalibrated(MBadPixelsPix::kHiGainOscillating))
+        val = 1;
+      else
+        return kFALSE;
+      break;
+    case 11:
+      if ((*this)[idx].IsUncalibrated(MBadPixelsPix::kLoGainOscillating))
+        val = 1;
+      else
+        return kFALSE;
+      break;
+    case 12:
+      if  ((*this)[idx].IsUncalibrated(MBadPixelsPix::kLoGainSaturation ))
+        val = 1;
+      else
+        return kFALSE;
+      break;
+    case 13:
+      if  ((*this)[idx].IsUncalibrated(MBadPixelsPix::kChargeIsPedestal ))
+        val = 1;
+      else
+        return kFALSE;
+      break;
+    case 14:
+      if  ((*this)[idx].IsUncalibrated(MBadPixelsPix::kChargeErrNotValid))
+        val = 1;
+      else
+        return kFALSE;
+      break;
+    case 15:
+      if  ((*this)[idx].IsUncalibrated(MBadPixelsPix::kChargeRelErrNotValid))
+        val = 1;
+      else
+        return kFALSE;
+      break;
+    case 16:
+      if  ((*this)[idx].IsUncalibrated(MBadPixelsPix::kChargeSigmaNotValid ))
+        val = 1;
+      else
+        return kFALSE;
+      break;
+    case 17:
+      if  ((*this)[idx].IsUncalibrated(MBadPixelsPix::kMeanTimeInFirstBin  ))
+        val = 1;
+      else
+        return kFALSE;
+      break;
+    case 18:
+      if  ((*this)[idx].IsUncalibrated(MBadPixelsPix::kMeanTimeInLast2Bins ))
+        val = 1;
+      else
+        return kFALSE;
+      break;
+    case 19:
+      if  ((*this)[idx].IsUncalibrated(MBadPixelsPix::kDeviatingNumPhes ))
+        val = 1;
+      else
+        return kFALSE;
+      break;
+    case 20:
+      if  ((*this)[idx].IsUncalibrated(MBadPixelsPix::kRelTimeNotFitted ))
+        val = 1;
+      else
+        return kFALSE;
+      break;
+    case 21:
+      if  ((*this)[idx].IsUncalibrated(MBadPixelsPix::kRelTimeOscillating))
+        val = 1;
+      else
+        return kFALSE;
+      break;
+    default:
+      return kFALSE;
+    }
+  
+  return kTRUE;
+}
+
+void MBadPixelsCam::DrawPixelContent(Int_t num) const
+{
+    *fLog << warn << "MBadPixelsCam::DrawPixelContent - not available." << endl;
+}
Index: /tags/Mars_V0-8-5/Mars/mbadpixels/MBadPixelsCam.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbadpixels/MBadPixelsCam.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbadpixels/MBadPixelsCam.h	(revision 9661)
@@ -0,0 +1,48 @@
+#ifndef MARS_MBadPixelsCam
+#define MARS_MBadPixelsCam
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+#ifndef MARS_MCamEvent
+#include "MCamEvent.h"
+#endif
+
+class TClonesArray;
+class MBadPixelsPix;
+
+class MBadPixelsCam : public MParContainer, public MCamEvent
+{
+private:
+    TClonesArray *fArray; //-> 
+
+public:
+    MBadPixelsCam(const char *name=NULL, const char *title=NULL);
+    MBadPixelsCam(const MBadPixelsCam &cam);
+    ~MBadPixelsCam();
+
+    void Clear(Option_t *o="");
+    void Print(Option_t *o="") const;
+    void Copy(TObject &object) const;
+
+    void InitSize(const UInt_t i);
+    Int_t GetSize() const;
+
+    MBadPixelsPix &operator[](Int_t i);
+    const MBadPixelsPix &operator[](Int_t i) const;
+
+    void Merge(const MBadPixelsCam &cam);
+
+    void   AsciiRead(ifstream &fin, UInt_t run);
+    void   AsciiRead(ifstream &fin) { AsciiRead(fin, 0); }
+    Bool_t AsciiWrite(ostream &out, UInt_t run) const;
+    Bool_t AsciiWrite(ostream &out) const { return AsciiWrite(out, 0); }
+
+    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
+    void DrawPixelContent(Int_t num) const;
+
+    ClassDef(MBadPixelsCam, 1)	//Storage container to store bad pixel of the camera...
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mbadpixels/MBadPixelsMerge.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbadpixels/MBadPixelsMerge.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbadpixels/MBadPixelsMerge.cc	(revision 9661)
@@ -0,0 +1,125 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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 02/2004 <mailto:tbretz@astro.uni.wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MBadPixelsMerge
+//  ===============
+//
+//  Merges in ReInit two bad pixel containers together:
+//   1) The contents of the container given in the constructor is in ReInit
+//      merged into MBadPixelsCam from the parameter list (aka run-headers)
+//   2) MBadPixelsCam from the parameter list (aka run-headers) is merged
+//      into the container given in the constructor. While the contents
+//      to which 1) refers are still untouched.
+//
+//
+// An explanation taken from Mantis:
+// --------------------------------
+// In my eyes everything works a supposed to do. We have different sources
+// for bad-pixels, eg from Pedestal calculation, from the calibration
+// constant calculation, manual setting and so on. If processing data we
+// have to take care of all this different sources. Therefor we have to
+// store the bad pixels from this sources (eg. from calibration). In
+// addition MBadPixelsCam is read from the file containing the data (once
+// per file). Now always after a new (data-)file has been opened the bad
+// pixels from (for example) the calibration file have to be merged into
+// the container loaded from the (data-)file which is stored in the
+// parameter list. Copying the pointer would totally overwrite the pixels
+// loaded (automatically by MReadMarsFile) from the data-file. All this is
+// done using a copy of the original MBadPixelsCam (fSource). In addition
+// fDest is initialized to the pointer given as argument to the
+// constructor. To keep track of all bad pixels the instance this pointer
+// is pointing to is used to collect all bad pixels used so far.
+//
+//
+// ToDo:
+//   - Take a setup file (ReadEnv-implementation) as input
+//
+//
+//  Input Containers:
+//   MBadPixelsCam
+//
+//  Output Containers:
+//   MBadPixelsCam
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MBadPixelsMerge.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MBadPixelsCam.h"
+
+ClassImp(MBadPixelsMerge);
+
+using namespace std;
+
+const TString MBadPixelsMerge::fgDefName  = "MBadPixelsMerge";
+const TString MBadPixelsMerge::fgDefTitle = "Merge extra- and intra-loop pixels";
+
+// --------------------------------------------------------------------------
+//
+// Constructor. A copy of the given MBadPixelsCam is created. This copy
+// is - in ReInit - merged into the MBadPixelsCam which is found in the
+// parameter list. In addition the pointer is stored and all MBadPixelsCam
+// which are processed in ReInit are merged into this container.
+//
+MBadPixelsMerge::MBadPixelsMerge(MBadPixelsCam *bad, const char *name, const char *title)
+    : fDest(bad)
+{
+    fName  = name  ? name  : fgDefName.Data();
+    fTitle = title ? title : fgDefTitle.Data();
+
+    fSource = new MBadPixelsCam(*bad);
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the copy of the primer MBadPixelsCam
+//
+MBadPixelsMerge::~MBadPixelsMerge()
+{
+    delete fSource;
+}
+
+// --------------------------------------------------------------------------
+//
+// 1) Get MBadPixelCam from the parameter list, if it doesn't yet exist,
+//    it will be created.
+// 2) Merge MBasPixelsCam into the primer container given in the constructor
+// 3) Merge the primer container given in the constructor into MBadPixelsCam
+//
+Bool_t MBadPixelsMerge::ReInit(MParList *pList)
+{
+    MBadPixelsCam *cam = (MBadPixelsCam*)pList->FindCreateObj("MBadPixelsCam");
+    if (!cam)
+        return kFALSE;
+
+    fDest->Merge(*cam);
+    cam->Merge(*fSource);
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mbadpixels/MBadPixelsMerge.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbadpixels/MBadPixelsMerge.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbadpixels/MBadPixelsMerge.h	(revision 9661)
@@ -0,0 +1,29 @@
+#ifndef MARS_MBadPixelsMerge
+#define MARS_MBadPixelsMerge
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MBadPixelsCam;
+
+class MBadPixelsMerge : public MTask
+{
+private:
+    static const TString fgDefName;  //!
+    static const TString fgDefTitle; //!
+
+    MBadPixelsCam *fDest;            //!
+    MBadPixelsCam *fSource;          //->
+
+    Bool_t ReInit(MParList *pList);
+
+public:
+    MBadPixelsMerge(MBadPixelsCam *bad, const char *name=NULL, const char *title=NULL);
+    ~MBadPixelsMerge();
+
+    ClassDef(MBadPixelsMerge, 0) //Merge extra- and intra-loop pixels
+}; 
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mbadpixels/MBadPixelsPix.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbadpixels/MBadPixelsPix.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbadpixels/MBadPixelsPix.cc	(revision 9661)
@@ -0,0 +1,182 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!              Markus Gaug,  3/2004 <mailto:markus@ifae.es>
+! 
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+/////////////////////////////////////////////////////////////////////////////
+//
+// MBadPixelsPix
+//
+// The bits of an integer array fInfo are used to declare and inform about 
+// possible defects in a pixel. Default and absence of defects create an array
+// of zeros. 
+//
+// The first index (fInfo[0]) holds general information which is coded as follows:
+// * BIT(1): Unsuitable Run: The pixel is not suited for analysis for the entire run
+// * BIT(2): Unsuitable Evt: The pixel is not suited for analysis for the current event
+// * BIT(3): Unreliable Run: The pixel can in principle be used for analysis, although 
+//                           previous analysis steps have yielded certain inconsistencies
+//
+// These bits can be called with the enum MBadPixelsPix::UnsuitableTupe_t in combination 
+// with the function IsUnsuitable(MBadPixelsPix::UnsuitableTupe_t), e.g. 
+// MBadPixelsPix::IsUnsuitalbe(MBadPixelsPix::kUnsuitableRun) asks if the first bit is set. 
+//
+// The second index (fInfo[1]) hold information acquired during the calibration. The bits 
+// are coded in the following form:
+//
+// * Set bits leading to an unreliable flag:
+// 
+// BIT(1 ): kHiGainNotFitted     :  Any High Gain signal is calibrated without a Gauss Fit to the signal distribution
+// BIT(2 ): kLoGainNotFitted     :  Any Low  Gain signal is calibrated without a Gauss Fit to the signal distribution
+// BIT(3 ): kRelTimeNotFitted    :  Any High Gain signal's arrival times are calibrated without a Gauss Fit
+// BIT(4 ): kHiGainOscillating   :  The High Gain signals fourier transform showed abnormal behavior  
+// BIT(5 ): kLoGainOscillating   :  The Low  Gain signals fourier transform showed abnormal behavior  
+// BIT(6 ): kRelTimeOscillating  :  The High Gain arrival times fourier transform showed abnormal behavior  
+// BIT(7 ): kLoGainSaturation    :  The Low  Gain signals were saturated during calibration
+//
+// * Set bits leading to an unsuitable flag:
+//
+// BIT(8 ): kChargeIsPedestal    :  The calibration signal contained only pedestals - presumably dead pixel
+// BIT(9 ): kChargeErrNotValid   :  The absolute error of the derived charge has given non-sense - presumably pedestal
+// BIT(10): kChargeRelErrNotValid:  The relative error of the derived charge was too large or too small
+// BIT(11): kChargeSigmaNotValid :  The sigma of the pedestal distribution smaller than the pedestal RMS - presumably a pixel with a star in its FOV only during the pedestal taking 
+// BIT(12): kMeanTimeInFirstBin  :  The signal has its mean maximum in the first used FADC slice - signal extractor bad
+// BIT(13): kMeanTimeInLast2Bins :  The signal has its mean maximum in the last two used FADC slice - signal extractor bad
+// BIT(14): kDeviatingNumPhes    :  The calculated number of photo-electrons deviates too much from the mean - inconsistency
+// BIT(15): kDeviatingFFactor    :  The calculated overall F-Factor deviates too much from the mean - inconsistency
+//
+// * Set bits leading to not useable low-gain signal:
+//
+// BIT(16): kConversionHiLoNotValid: The calibrated Conversion between Hi-Gain and Low Gain gives absurd results
+//
+// These bits can be called with the enum MBadPixelsPix::UncalibratedType_t in combination 
+// with the function IsUncalibrated(MBadPixelsPix::UncalibratedTupe_t), e.g. 
+// MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kHiGainNotCalibrated) asks if the Hi Gain signal
+// could be calibrated.
+//
+// The third index (fInfo[2]) holds information about possible hardware mulfunctionning. The bits 
+// are coded in the following form:
+// BIT(1 ): kHVNotNominal :  The HV deviates more than 3% from the nominal value.
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MBadPixelsPix.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MBadPixelsPix);
+
+using namespace std;
+
+const Int_t MBadPixelsPix::fgRunMask =
+    MBadPixelsPix::kUnsuitableRun |
+    MBadPixelsPix::kUnreliableRun;
+
+// ------------------------------------------------------------------------
+//
+// Initialize Pixel to be Ok.
+//
+MBadPixelsPix::MBadPixelsPix(const char* name, const char* title)
+{
+    fName  = name  ? name  : "MBadPixelsPix";
+    fTitle = title ? title : "Container storing bad pixel information for a single pixel";
+
+    fInfo.Set(3);
+
+}
+
+// ------------------------------------------------------------------------
+//
+// Invalidate all bits which are not run-wise. This will be called for
+// all entries in the parameter list, just before each time the task-list
+// is executed.
+//
+void MBadPixelsPix::Reset()
+{
+    fInfo[0] &= fgRunMask;
+}
+
+// ------------------------------------------------------------------------
+//
+// Invalidate values (set=0 which mean Pixel OK)
+//
+void MBadPixelsPix::Clear(Option_t *o)
+{
+    fInfo.Reset(0);
+}
+
+// ------------------------------------------------------------------------
+//
+// Merge (bitwise or) the information in pix into this pixel.
+//
+void MBadPixelsPix::Merge(const MBadPixelsPix &pix)
+{
+  const Int_t n = pix.fInfo.GetSize();
+  if (n>fInfo.GetSize())
+    fInfo.Set(n);
+  
+  for (int i=0; i<n; i++)
+    fInfo[i] |= pix.fInfo[i];
+}
+
+
+/****************************************************************************
+           This is a collection of possible defects for later use
+ ****************************************************************************/
+
+/*
+ 1  PMT defective.
+ 2  Preamplifier defective.
+ 3  Optical link defective.
+ 4  HV cannot be set.
+ 7  HV unstable.
+ 5  HV readout defective.
+ 8  DC unstable.
+ 6  DC readout defective.
+ 9  Discriminator threshold cannot be set.
+ 10  Trigger delay cannot be set.
+ 11  Discriminator gives no output.
+ <-? 12  Pixel out of L1T.
+ 13  FADC defective.
+ 14  FADC board digital information defective.
+ */
+
+/*
+ 1  Pixel shows no signal
+ */
+
+/*
+
+Hardware defects which cannot be detected automatically by software. This might be stored at least in the data-base. I think we should wait until we implement these things...
+Preamplifier defective.
+Optical link defective.
+HV cannot be set.
+HV readout defective.
+DC readout defective.
+Discriminator threshold cannot be set.
+Trigger delay cannot be set.
+Discriminator gives no output.
+FADC defective.
+FADC board digital information defective.
+Pixel out of L1T. (this is an important information, but not necessarily a defect, is it?)
+
+*/
Index: /tags/Mars_V0-8-5/Mars/mbadpixels/MBadPixelsPix.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbadpixels/MBadPixelsPix.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbadpixels/MBadPixelsPix.h	(revision 9661)
@@ -0,0 +1,96 @@
+#ifndef MARS_MBadPixelsPix
+#define MARS_MBadPixelsPix
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#ifndef ROOT_TArrayI
+#include <TArrayI.h>
+#endif
+
+class MBadPixelsPix : public MParContainer
+{
+private:
+    TArrayI fInfo;
+
+public:
+    MBadPixelsPix(const char* name=NULL, const char* title=NULL);
+
+    enum UnsuitableType_t {
+        kUnsuitableRun = BIT(1),
+        kUnsuitableEvt = BIT(2),
+        kUnsuitable    = kUnsuitableRun|kUnsuitableEvt,
+        kUnreliableRun = BIT(3),
+        kUnreliableEvt = BIT(4),
+        kUnreliable    = kUnreliableRun|kUnreliableEvt
+    };
+
+    static const Int_t fgRunMask; // All types which are not event wise determined
+
+    // All types are initialized to normal behaviour
+    enum UncalibratedType_t {
+      kHiGainNotFitted          = BIT(1),
+      kLoGainNotFitted          = BIT(2), 
+      kRelTimeNotFitted         = BIT(3),
+      kHiGainOscillating        = BIT(4),
+      kLoGainOscillating        = BIT(5),
+      kRelTimeOscillating       = BIT(6),
+      kLoGainSaturation         = BIT(7),
+      kChargeIsPedestal         = BIT(8),
+      kChargeErrNotValid        = BIT(9),
+      kChargeRelErrNotValid     = BIT(10),
+      kChargeSigmaNotValid      = BIT(11),
+      kMeanTimeInFirstBin       = BIT(12),
+      kMeanTimeInLast2Bins      = BIT(13), 
+      kDeviatingNumPhes         = BIT(14),
+      kDeviatingFFactor         = BIT(15),
+      kDeviatingTimeResolution  = BIT(16),
+      kConversionHiLoNotValid   = BIT(17)
+    };
+    
+    // This is just a start..
+    enum HardwareType_t {
+      kHVNotNominal             = BIT(1)
+    };
+    
+      
+    void Reset();
+    void Clear(Option_t *o="");
+    void Copy(TObject &object) const
+    {
+        static_cast<MBadPixelsPix&>(object).fInfo = fInfo;
+    }
+
+    // Setter
+    void SetUnsuitable  (UnsuitableType_t   typ) { fInfo[0] |= typ; }
+    void SetUncalibrated(UncalibratedType_t typ) { fInfo[1] |= typ; }
+    void SetHardware    (HardwareType_t     typ) { fInfo[2] |= typ; }
+
+    // Getter
+    Bool_t IsUnsuitable  (UnsuitableType_t   typ) const { return fInfo[0]&typ; }
+    Bool_t IsUncalibrated(UncalibratedType_t typ) const { return fInfo[1]&typ; }
+    Bool_t IsHardwareBad (HardwareType_t     typ) const { return fInfo[2]&typ; }
+
+    Bool_t IsUnsuitable() const { return fInfo[0]&kUnsuitable; }
+    Bool_t IsUnreliable() const { return fInfo[0]&kUnreliable; }
+
+    Bool_t IsOK()  const { return fInfo[0]==0; }
+    Bool_t IsBad() const { return fInfo[0]!=0; }
+
+    Bool_t IsLoGainBad() const { return IsUnsuitable  (kUnsuitableRun      )
+				     || IsUncalibrated(kLoGainSaturation   ) 
+				     || IsUncalibrated(kConversionHiLoNotValid) 
+				     || IsUncalibrated(kLoGainOscillating  ) ; }
+    Bool_t IsHiGainBad() const { return IsUnsuitable  (kUnsuitableRun      )
+  				     || IsUncalibrated(kHiGainOscillating  ) ; }
+
+    void Merge(const MBadPixelsPix &pix);
+
+    const TArrayI &GetInfo() const { return fInfo; }
+
+    ClassDef(MBadPixelsPix, 1)	// Storage Container for bad pixel information of a single pixel
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mbadpixels/MBadPixelsTreat.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbadpixels/MBadPixelsTreat.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbadpixels/MBadPixelsTreat.cc	(revision 9661)
@@ -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): Oscar Blanch 12/2001 <mailto:blanch@ifae.es>
+!   Author(s): Thomas Bretz 08/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MBadPixelsTreat
+//
+//  You can use MBadPixelsTreat::SetUseInterpolation to replaced the
+//  bad pixels by the average of its neighbors instead of unmapping
+//  them. If you want to include the central pixel use
+//  MBadPixelsTreat::SetUseCentralPixel. The bad pixels are taken from
+//  an existing MBadPixelsCam.
+//
+//  It check if there are enough neighbors to calculate the mean
+//  If not, unmap the pixel. The minimum number of good neighbors
+//  should be set using SetNumMinNeighbors
+//
+//  If you don't want to interpolate unreliable pixels but only unsuitable
+//  (broken) pixels use SetSloppyTreatment().
+//
+//
+//  Input Containers:
+//   MCerPhotEvt
+//   MPedPhotCam
+//   MBadPixelsCam
+//   [MGeomCam]
+//
+//  Output Containers:
+//   MCerPhotEvt
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MBadPixelsTreat.h"
+
+#include <fstream>
+
+#include <TArrayD.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MGeomPix.h"
+#include "MGeomCam.h"
+
+#include "MCerPhotPix.h"
+#include "MCerPhotEvt.h"
+
+#include "MPedPhotPix.h"
+#include "MPedPhotCam.h"
+
+#include "MBadPixelsPix.h"
+#include "MBadPixelsCam.h"
+
+ClassImp(MBadPixelsTreat);
+
+using namespace std;
+
+static const TString gsDefName  = "MBadPixelsTreat";
+static const TString gsDefTitle = "Task to treat bad pixels (interpolation, unmapping)";
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MBadPixelsTreat::MBadPixelsTreat(const char *name, const char *title)
+    : fFlags(0), fNumMinNeighbors(3)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the status of a pixel. If kSloppyTreatment is set a pixel must
+// be unsuitable to be treated. If not it is enough if it is unreliable
+// (IsBad() checks for any flag)
+//
+Bool_t MBadPixelsTreat::IsPixelBad(Int_t idx) const
+{
+    return TESTBIT(fFlags, kSloppyTreatment) ? (*fBadPixels)[idx].IsUnsuitable() : (*fBadPixels)[idx].IsBad();
+}
+
+// --------------------------------------------------------------------------
+//
+//  - 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.
+//
+Int_t MBadPixelsTreat::PreProcess (MParList *pList)
+{
+    fBadPixels = (MBadPixelsCam*)pList->FindObject(AddSerialNumber("MBadPixelsCam"));
+    if (!fBadPixels)
+    {
+        *fLog << err << "MBadPixelsCam not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fPedPhot = (MPedPhotCam*)pList->FindObject(AddSerialNumber("MPedPhotCam"));
+    if (!fPedPhot)
+    {
+        *fLog << err << "MPedPhotCam not found... aborting." << endl;
+        return kFALSE;
+    }
+    
+    fEvt = (MCerPhotEvt*)pList->FindObject(AddSerialNumber("MCerPhotEvt"));
+    if (!fEvt)
+    {
+        *fLog << err << "MCerPhotEvt not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fGeomCam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
+    if (!fGeomCam && TESTBIT(fFlags, kUseInterpolation))
+    {
+        *fLog << err << "MGeomCam not found... can't use interpolation." << endl;
+        return kFALSE;
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Replaces each pixel (signal, signal error, pedestal, pedestal rms)
+//  by the average of its surrounding pixels.
+//  If TESTBIT(fFlags, kUseCentralPixel) is set the central pixel is also
+//  included.
+//
+void MBadPixelsTreat::InterpolateSignal() const
+{
+    const UShort_t entries = fGeomCam->GetNumPixels();
+
+    //
+    // Create arrays (FIXME: Check if its possible to create it only once)
+    //
+    TArrayD nphot(entries);
+    TArrayD perr(entries);
+ 
+    //
+    // Loop over all pixels
+    //
+    for (UShort_t i=0; i<entries; i++)
+    {
+        MCerPhotPix *pix = fEvt->GetPixById(i);
+
+        //
+        // Check whether pixel with idx i is blind
+        //
+        if (pix && !IsPixelBad(i))
+            continue;
+
+        //
+        // Get a pointer to this pixel. If it is not yet existing
+        // create a new entry for this pixel in MCerPhotEvt
+        //
+        if (!pix)
+        {
+            pix = fEvt->AddPixel(i, 0, 0);
+            (*fBadPixels)[i].SetUnsuitable(MBadPixelsPix::kUnsuitableEvt);
+        }
+
+        //
+        // Get the corresponding geometry and pedestal
+        //
+        const MGeomPix &gpix = (*fGeomCam)[i];
+
+        // Do Not-Use-Central-Pixel
+        const Bool_t nucp = !TESTBIT(fFlags, kUseCentralPixel);
+
+        Int_t num = nucp ? 0 : 1;
+
+        nphot[i]  = nucp ? 0 : pix->GetNumPhotons();
+        perr[i]   = nucp ? 0 : Pow2(pix->GetErrorPhot());
+
+        //
+	// The values are rescaled to the small pixels area for the right comparison
+        //
+        const Double_t ratio = fGeomCam->GetPixRatio(i);
+
+        nphot[i] *= ratio;
+        perr[i]  *= ratio;
+
+        //
+        // Loop over all its neighbors
+        //
+        const Int_t n = gpix.GetNumNeighbors();
+        for (int j=0; j<n; j++)
+        {
+            const UShort_t nidx = gpix.GetNeighbor(j);
+
+            //
+            // Do not use blind neighbors
+            //
+            if (IsPixelBad(nidx))
+                continue;
+
+            //
+            // Check whether the neighbor has a signal stored
+            //
+            const MCerPhotPix *evtpix = fEvt->GetPixById(nidx);
+            if (!evtpix)
+                continue;
+
+            //
+            // Get the geometry for the neighbor
+            //
+            const Double_t nratio = fGeomCam->GetPixRatio(nidx);
+
+            //
+	    //The error is calculated as the quadratic sum of the errors
+	    //
+            nphot[i] += nratio*evtpix->GetNumPhotons();
+            perr[i]  += nratio* Pow2(evtpix->GetErrorPhot());
+
+            num++;
+        }
+
+	// Check if there are enough neighbors to calculate the mean
+        // If not, unmap the pixel. The maximum number of blind neighbors
+        // should be 2
+        if (num<fNumMinNeighbors)
+        {
+            pix->SetPixelUnmapped();
+            continue;
+        }
+
+        //
+        // Now the mean is calculated and the values rescaled back
+        // to the pixel area
+        //
+	nphot[i] /= (num*ratio);
+        perr[i]   = TMath::Sqrt(perr[i]/(num*ratio));
+ 
+        pix->Set(nphot[i], perr[i]);
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+void MBadPixelsTreat::InterpolatePedestals() const
+{
+    const Int_t entries = fPedPhot->GetSize();
+
+    // Create arrays (FIXME: Check if its possible to create it only once)
+    TArrayD ped(entries);
+    TArrayD rms(entries);
+
+    //
+    // Loop over all pixels
+    //
+    for (UShort_t i=0; i<entries; i++)
+    {
+        //
+        // Check whether pixel with idx i is blind
+        //
+        if (!IsPixelBad(i))
+            continue;
+
+        //
+        // Get the corresponding geometry and pedestal
+        //
+        const MGeomPix    &gpix = (*fGeomCam)[i];
+        const MPedPhotPix &ppix = (*fPedPhot)[i];
+
+        // Do Not-Use-Central-Pixel
+        const Bool_t nucp = !TESTBIT(fFlags, kUseCentralPixel);
+
+        Int_t num = nucp ? 0 : 1;
+
+        ped[i] = nucp ? 0 : ppix.GetMean();
+        rms[i] = nucp ? 0 : Pow2(ppix.GetRms());
+
+        //
+        // The values are rescaled to the small pixels area for the right comparison
+        //
+        const Double_t ratio = fGeomCam->GetPixRatio(i);
+
+        ped[i] *= ratio;
+        rms[i] *= ratio;
+
+        //
+        // Loop over all its neighbors
+        //
+        const Int_t n = gpix.GetNumNeighbors();
+        for (int j=0; j<n; j++)
+        {
+            const UShort_t nidx = gpix.GetNeighbor(j);
+
+            //
+            // Do not use blind neighbors
+            //
+            if (IsPixelBad(nidx))
+                continue;
+
+            //
+            // Get the geometry for the neighbor
+            //
+            const Double_t    nratio = fGeomCam->GetPixRatio(nidx);
+            const MPedPhotPix &nppix = (*fPedPhot)[nidx];
+
+            //
+            //The error is calculated as the quadratic sum of the errors
+            //
+            ped[i] += nratio*nppix.GetMean();
+            rms[i] += nratio*Pow2(nppix.GetRms());
+
+            num++;
+        }
+
+        // Check if there are enough neighbors to calculate the mean
+        // If not, unmap the pixel. The minimum number of good neighbors
+        // should be fNumMinNeighbors
+        if (num < fNumMinNeighbors)
+        {
+            MCerPhotPix *pix =fEvt->GetPixById(i);
+            if (!pix)
+                pix = fEvt->AddPixel(i, 0, 0);
+            pix->SetPixelUnmapped();
+            continue;
+        }
+
+        //
+        // Now the mean is calculated and the values rescaled back
+        // to the pixel area
+        //
+        ped[i] /=  (num*ratio);
+        rms[i]  = TMath::Sqrt(rms[i]/(num*ratio));
+
+        (*fPedPhot)[i].Set(ped[i], rms[i]);
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+//  Replaces each pixel (signal, signal error, pedestal, pedestal rms)
+//  by the average of its surrounding pixels.
+//  If TESTBIT(fFlags, kUseCentralPixel) is set the central pixel is also
+//  included.
+//
+//  NT: Informations about the interpolated pedestals are added. 
+//      When the option Interpolated is called, the blind pixel with the new
+//      values of signal and fluttuation is included in the calculation of
+//      the Image Parameters.
+//
+/*
+void MBadPixelsTreat::Interpolate() const
+{
+    const UShort_t entries = fGeomCam->GetNumPixels();
+
+    //
+    // Create arrays
+    //
+    TArrayD nphot(entries);
+    TArrayD perr(entries);
+    TArrayD ped(entries);
+    TArrayD pedrms(entries);
+ 
+    //
+    // Loop over all pixels
+    //
+    for (UShort_t i=0; i<entries; i++)
+    {
+        MCerPhotPix *pix = fEvt->GetPixById(i);
+
+        //
+        // Check whether pixel with idx i is blind
+        //
+        if (pix && (*fBadPixels)[i].IsOK())
+            continue;
+
+        //
+        // Get a pointer to this pixel. If it is not yet existing
+        // create a new entry for this pixel in MCerPhotEvt
+        //
+        if (!pix)
+        {
+            pix = fEvt->AddPixel(i, 0, 0);
+            (*fBadPixels)[i].SetUnsuitable(MBadPixelsPix::kUnsuitableEvt);
+        }
+
+        //
+        // Get the corresponding geometry and pedestal
+        //
+        const MGeomPix &gpix    = (*fGeomCam)[i];
+        const MPedPhotPix &ppix = (*fPedPhot)[i];
+
+        // Do Not-Use-Central-Pixel
+        const Bool_t nucp = !TESTBIT(fFlags, kUseCentralPixel);
+
+        Int_t num = nucp ? 0 : 1;
+
+        nphot[i]  = nucp ? 0 : pix->GetNumPhotons();
+        ped[i]    = nucp ? 0 : ppix.GetMean();
+        perr[i]   = nucp ? 0 : Pow2(pix->GetErrorPhot());
+        pedrms[i] = nucp ? 0 : Pow2(ppix.GetRms());
+
+        //
+	// The values are rescaled to the small pixels area for the right comparison
+        //
+        const Double_t ratio = fGeomCam->GetPixRatio(i);
+
+        if (nucp)
+        {
+            nphot[i]  *= ratio;
+            perr[i]   *= ratio;
+            ped[i]    *= ratio;
+            pedrms[i] *= ratio;
+        }
+
+        //
+        // Loop over all its neighbors
+        //
+        const Int_t n = gpix.GetNumNeighbors();
+        for (int j=0; j<n; j++)
+        {
+            const UShort_t nidx = gpix.GetNeighbor(j);
+
+            //
+            // Do not use blind neighbors
+            //
+            if ((*fBadPixels)[nidx].IsBad())
+                continue;
+
+            //
+            // Check whether the neighbor has a signal stored
+            //
+            const MCerPhotPix *evtpix = fEvt->GetPixById(nidx);
+            if (!evtpix)
+                continue;
+
+            //
+            // Get the geometry for the neighbor
+            //
+            const Double_t nratio = fGeomCam->GetPixRatio(nidx);
+            MPedPhotPix &nppix    = (*fPedPhot)[nidx];
+
+            //
+	    // The error is calculated as the quadratic sum of the errors
+	    //
+            nphot[i]  += nratio*evtpix->GetNumPhotons();
+            ped[i]    += nratio*nppix.GetMean();
+            perr[i]   += nratio*Pow2(evtpix->GetErrorPhot());
+	    pedrms[i] += nratio*Pow2(nppix.GetRms());
+
+            num++;
+        }
+
+        if (num<fNumMinNeighbors)
+        {
+            pix->SetPixelUnmapped();
+            nphot[i]  = 0;
+            ped[i]    = 0;
+            perr[i]   = 0;
+            pedrms[i] = 0;
+            continue;
+        }
+
+        //
+	// Now the mean is calculated and the values rescaled back to the pixel area
+        //
+	nphot[i] /= num*ratio;
+        ped[i]   /= num*ratio;
+        perr[i]   = TMath::Sqrt(perr[i]/(num*ratio));
+        pedrms[i] = TMath::Sqrt(pedrms[i]/(num*ratio));
+
+    }
+
+    //
+    // Now the new pixel values are calculated and can be replaced in
+    // the corresponding containers
+    //
+    for (UShort_t i=0; i<entries; i++)
+    {
+        //
+        // Do not use blind neighbors
+        //
+        if ((*fBadPixels)[i].IsOK())
+            continue;
+
+        //
+        // It must exist, we have created it in the loop before.
+        //
+        fEvt->GetPixById(i)->Set(nphot[i], perr[i]);
+        (*fPedPhot)[i].Set(ped[i], pedrms[i]);
+    }
+}
+*/
+
+// --------------------------------------------------------------------------
+//
+//  Removes all blind pixels from the analysis by setting their state
+//  to unused.
+//
+void MBadPixelsTreat::Unmap() const
+{
+    const UShort_t entries = fEvt->GetNumPixels();
+
+    //
+    // remove the pixels in fPixelsIdx 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 (IsPixelBad(pix.GetPixId()))
+            pix.SetPixelUnmapped();
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Interpolate Pedestals if kProcessRMS not set
+//
+Bool_t MBadPixelsTreat::ReInit(MParList *pList)
+{
+    if (!TESTBIT(fFlags, kProcessRMS))
+        InterpolatePedestals();
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Treat the blind pixels
+//
+Int_t MBadPixelsTreat::Process()
+{
+    if (TESTBIT(fFlags, kUseInterpolation) && fGeomCam)
+    {
+        InterpolateSignal();
+        if (TESTBIT(fFlags, kProcessRMS))
+            InterpolatePedestals();
+    }
+    else
+        Unmap();
+
+    return kTRUE;
+}
+
+void MBadPixelsTreat::StreamPrimitive(ofstream &out) const
+{
+    out << "   MBadPixelsTreat " << GetUniqueName();
+    if (fName!=gsDefName || fTitle!=gsDefTitle)
+    {
+        out << "(\"" << fName << "\"";
+        if (fTitle!=gsDefTitle)
+            out << ", \"" << fTitle << "\"";
+        out <<")";
+    }
+    out << ";" << endl;
+
+    if (TESTBIT(fFlags, kUseInterpolation))
+        out << "   " << GetUniqueName() << ".SetUseInterpolation();" << endl;
+    if (TESTBIT(fFlags, kUseCentralPixel))
+        out << "   " << GetUniqueName() << ".SetUseCentralPixel();" << endl;
+}
Index: /tags/Mars_V0-8-5/Mars/mbadpixels/MBadPixelsTreat.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbadpixels/MBadPixelsTreat.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbadpixels/MBadPixelsTreat.h	(revision 9661)
@@ -0,0 +1,72 @@
+#ifndef MARS_MBadPixelsTreat
+#define MARS_MBadPixelsTreat
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MGeomCam;
+class MCerPhotEvt;
+class MPedPhotCam;
+class MBadPixelsCam;
+
+class MBadPixelsTreat : public MTask
+{
+private:
+    MGeomCam      *fGeomCam;   //!
+    MPedPhotCam   *fPedPhot;   //!
+    MCerPhotEvt   *fEvt;       //!
+    MBadPixelsCam *fBadPixels; //!
+
+    Byte_t fFlags;       // flag for the method which is used
+    Byte_t fNumMinNeighbors;
+
+    enum
+    {
+        kUseInterpolation = 1,
+        kUseCentralPixel  = 2,
+        kProcessRMS       = 3,
+        kSloppyTreatment  = 4
+    };
+
+    static Double_t Pow2(Double_t x) { return x*x; }
+
+    void InterpolateSignal() const;
+    void InterpolatePedestals() const;
+
+    void   Unmap() const;
+    void   StreamPrimitive(ofstream &out) const;
+
+    Bool_t ReInit(MParList *pList);
+    Int_t  PreProcess(MParList *pList);
+    Int_t  Process();
+
+    Bool_t IsPixelBad(Int_t idx) const;
+
+public:
+    MBadPixelsTreat(const char *name=NULL, const char *title=NULL);
+
+    void SetUseInterpolation(Bool_t b=kTRUE)
+    {
+        b ? SETBIT(fFlags, kUseInterpolation) : CLRBIT(fFlags, kUseInterpolation);
+    }
+    void SetUseCentralPixel(Bool_t b=kTRUE)
+    {
+        b ? SETBIT(fFlags, kUseCentralPixel) : CLRBIT(fFlags, kUseCentralPixel);
+    }
+    void SetProcessRMS(Bool_t b=kTRUE)
+    {
+        b ? SETBIT(fFlags, kProcessRMS) : CLRBIT(fFlags, kProcessRMS);
+    }
+    void SetSloppyTreatment(Bool_t b=kTRUE)
+    {
+        b ? SETBIT(fFlags, kSloppyTreatment) : CLRBIT(fFlags, kSloppyTreatment);
+    }
+    void SetNumMinNeighbors(Byte_t num) { fNumMinNeighbors=num; }
+
+
+    ClassDef(MBadPixelsTreat, 1) // Task to treat bad pixels (interpolation, unmapping)
+}; 
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mbadpixels/MMcBadPixelsSet.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbadpixels/MMcBadPixelsSet.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbadpixels/MMcBadPixelsSet.cc	(revision 9661)
@@ -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): Oscar Blanch    12/2001 <mailto:blanch@ifae.es>
+!   Author(s): Thomas Bretz    08/2002 <mailto:tbretz@astro.uni.wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MMcBadPixelsSet
+//
+//  This task tries to identify the starfield from the
+//  MMcRunHeader container and tries to identifies it. If it is known
+//  (eg. Crab) the fixed build in pixel numbers are used as blind
+//  pixels.
+//
+//  Implemented star fields (for the MAGIC camera only):
+//   - Crab: 400, 401, 402, 437, 438, 439
+//
+//  Input Containers:
+//   -/-
+//
+//  Output Containers:
+//   MBadPixels
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MMcBadPixelsSet.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MGeomCam.h"
+#include "MMcRunHeader.hxx"
+
+#include "MBadPixelsCam.h"
+#include "MBadPixelsPix.h"
+
+ClassImp(MMcBadPixelsSet);
+
+using namespace std;
+
+static const TString gsDefName  = "MMcBadPixelsSet";
+static const TString gsDefTitle = "Set predefined star fields";
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MMcBadPixelsSet::MMcBadPixelsSet(const char *name, const char *title)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+}
+
+// --------------------------------------------------------------------------
+//
+Int_t MMcBadPixelsSet::PreProcess (MParList *pList)
+{
+    fBadPixels = (MBadPixelsCam*)pList->FindCreateObj(AddSerialNumber("MBadPixelsCam"));
+    if (!fBadPixels)
+        return kFALSE;
+
+    fGeomCam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
+    if (!fGeomCam)
+    {
+        *fLog << err << dbginf << "MGeomCam not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  - 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 MMcBadPixelsSet::ReInit(MParList *pList)
+{
+    if (!fGeomCam->InheritsFrom("MGeomCamMagic"))
+    {
+        *fLog << warn << "MMcBadPixelsSet::ReInit: Warning - Starfield only implemented for Magic standard Camera... no action." << endl;
+        return kTRUE;
+    }
+
+    //
+    // Set as blind some particular pixels because of a particular
+    // Star Field of View.
+    //
+    MMcRunHeader *mcrun = (MMcRunHeader*)pList->FindObject("MMcRunHeader");
+    if (!mcrun)
+    {
+        *fLog << warn << "MMcBadPixelsSet::ReInit: Warning - No run header available... no action." << endl;
+        return kTRUE;
+    }
+
+    Int_t rah, ram, ras;
+    Int_t ded, dem, des;
+    mcrun->GetStarFieldRa(&rah, &ram, &ras);
+    mcrun->GetStarFieldDec(&ded, &dem, &des);
+
+    if (rah!=5 || ram!=34 || ras!=32 || ded!=22 || dem!=0 || des!=55)
+    {
+        *fLog << warn << "Warning - Starfield unknown..." << endl;
+        return kTRUE;
+    }
+
+    //
+    // Case for Crab Nebula FOV
+    //
+    (*fBadPixels)[400].SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
+    (*fBadPixels)[401].SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
+    (*fBadPixels)[402].SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
+    (*fBadPixels)[437].SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
+    (*fBadPixels)[438].SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
+    (*fBadPixels)[439].SetUnsuitable(MBadPixelsPix::kUnsuitableRun);
+
+    *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-8-5/Mars/mbadpixels/MMcBadPixelsSet.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbadpixels/MMcBadPixelsSet.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbadpixels/MMcBadPixelsSet.h	(revision 9661)
@@ -0,0 +1,30 @@
+#ifndef MARS_MMcBadPixelsSet
+#define MARS_MMcBadPixelsSet
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MGeomCam;
+class MBadPixelsCam;
+
+class MMcBadPixelsSet : public MTask
+{
+private:
+    MBadPixelsCam *fBadPixels;  //!
+    MGeomCam      *fGeomCam;    //!
+
+    Int_t  PreProcess(MParList *pList);
+    Bool_t ReInit(MParList *pList);
+
+public:
+    MMcBadPixelsSet(const char *name=NULL, const char *title=NULL);
+
+    ClassDef(MMcBadPixelsSet, 1) // Task to deal with known MC star-fields
+}; 
+
+#endif
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mbadpixels/Makefile
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbadpixels/Makefile	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbadpixels/Makefile	(revision 9661)
@@ -0,0 +1,46 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#------------------------------------------------------------------------------
+
+#
+# Handling name of the Root Dictionary Files
+#
+CINT  = BadPixels
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES = -I. -I../mbase -I../manalysis -I../mgeom -I../mgui \
+           -I../mmc -I../mpedestal
+# MBadPixelsCalc  (manalysis): MPedPhotCam, MSigmabar
+# MBadPixelsCalc  (mgeom):     MGeomCam
+# MBadPixelsCam   (mgui):      MCamEvent
+# MMcBadPixelsSet (mmc):       MMcRunHeader
+# MBadPixelsTreat (mpedestal): MPedPhot*
+
+.SUFFIXES: .c .cc .cxx .h .hxx .o 
+
+SRCFILES = MBadPixelsPix.cc \
+           MBadPixelsCam.cc \
+           MBadPixelsMerge.cc \
+           MBadPixelsCalc.cc \
+           MBadPixelsTreat.cc \
+           MMcBadPixelsSet.cc
+
+############################################################
+
+all: $(OBJS)
+
+include ../Makefile.rules
+
+clean:	rmcint rmobjs rmcore rmlib
+
+mrproper:	clean rmbak
Index: /tags/Mars_V0-8-5/Mars/mbase/BaseIncl.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/BaseIncl.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/BaseIncl.h	(revision 9661)
@@ -0,0 +1,12 @@
+#ifndef __CINT__
+
+/*
+#include <fstream.h>
+
+#include <TFile.h>
+#include <TTree.h>
+
+#include <TGListBox.h>
+*/
+
+#endif // __CINT__
Index: /tags/Mars_V0-8-5/Mars/mbase/BaseLinkDef.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/BaseLinkDef.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/BaseLinkDef.h	(revision 9661)
@@ -0,0 +1,73 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+// Global constants
+#pragma link C++ global kCONTINUE;
+#pragma link C++ global kRad2Deg;
+
+// Logging
+#pragma link C++ global gLog;
+
+#pragma link C++ class MLog+;
+#pragma link C++ class MLogPlugin+;
+#pragma link C++ class MLogHtml+;
+
+// Basic Network Tools
+#pragma link C++ class MReadSocket+;
+
+// Basic Tools
+#pragma link C++ class MMath+;
+#pragma link C++ class MString+;
+#pragma link C++ class MIter+;
+#pragma link C++ class MDirIter+;
+#pragma link C++ class MRunIter+;
+
+// Mars core
+#pragma link C++ class MInputStreamID+;
+
+#pragma link C++ class MParContainer+;
+#pragma link C++ class MParList+;
+
+#pragma link C++ class MTask+;
+#pragma link C++ class MTaskInteractive+;
+#pragma link C++ class MTaskList+;
+
+#pragma link C++ class MFilter+;
+
+#pragma link C++ class MEvtLoop+;
+
+// Mars core (GUI part)
+#pragma link C++ class MStatusArray+;
+#pragma link C++ class MStatusDisplay+;
+#pragma link C++ class MProgressBar+;
+#pragma link C++ class MSearch+;
+
+#pragma link C++ class MGTask+;
+#pragma link C++ class MGList+;
+#pragma link C++ class MGMap+;
+#pragma link C++ class MGGroupFrame+;
+
+// Root enhancements
+//#pragma link C++ class MGraph+;
+
+// Basic containers
+#pragma link C++ class MArray;
+#pragma link C++ class MArrayB;
+#pragma link C++ class MArrayS;
+
+#pragma link C++ class MTime+;
+#pragma link C++ function operator<<(ostream&, const MTime&);
+#pragma link C++ function operator>>(istream&, MTime&);
+
+#pragma link C++ class MArgs+;
+#pragma link C++ class MArgsEntry+;
+
+// Tool tasks
+#pragma link C++ class MClone+;
+#pragma link C++ class MPrint+;
+#pragma link C++ class MContinue+;
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mbase/MAGIC.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MAGIC.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MAGIC.h	(revision 9661)
@@ -0,0 +1,32 @@
+#ifndef MARS_MAGIC
+#define MARS_MAGIC
+///////////////////////////////////////////////////////////////////////////////
+//
+//     Magic.h
+//
+//     defines MAGIC base informations
+//
+///////////////////////////////////////////////////////////////////////////////
+#ifndef ROOT_TROOT
+#include <TROOT.h>
+#endif
+
+//
+// Check here if Mars can be compiled with the present root version
+//
+#ifndef __CINT__
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,05,06)
+#error Your root version is too old to compile Mars, use root>=3.05/06
+#endif
+#endif
+
+//
+// Values for the eventloop control
+//
+const Int_t kCONTINUE = 2;
+const Int_t kSKIP     = 2;
+const Int_t kERROR    = 3;
+
+const Double_t kRad2Deg = 180.0/3.1415926535897932384626433832795028841971693993751;
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mbase/MArgs.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MArgs.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MArgs.cc	(revision 9661)
@@ -0,0 +1,387 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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, 7/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2003-2004
+!
+!
+\* ======================================================================== */
+
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// MArgs
+//
+// This is a helper class for executables to parse command line arguments
+//
+// Arguments beginning with a trailing '-' are called 'options'.
+// Arguments without a trailing '-' are considered 'arguments'
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MArgs.h"
+
+#include <stdlib.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MArgsEntry);
+ClassImp(MArgs);
+
+using namespace std;
+
+void MArgsEntry::Print(const Option_t *o) const
+{
+    gLog << all << *this << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Initializes:
+//  fName: The name of the executable
+//  fArgv: A TList containing all other command line arguments
+//
+MArgs::MArgs(int argc, char **argv) : fArgc(argc)
+{
+    // FIXME: argv has no const-qualifier to be idetical with
+    //        TApplication.
+    fName = argv[0];
+
+    fArgv = new TList;
+    fArgv->SetOwner();
+
+    for (int i=1; i<argc; i++)
+    {
+        MArgsEntry &o = *new MArgsEntry(argv[i]);
+        dynamic_cast<TString&>(o) = o.Strip(TString::kBoth);
+        fArgv->Add(&o);
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Deletes fArgv.
+//
+MArgs::~MArgs()
+{
+    delete fArgv;
+}
+
+// --------------------------------------------------------------------------
+//
+// Print everything parsed.
+// Using 'options' as option only 'options' are printed.
+// Using 'arguments' as option only 'arguments' are printed.
+//
+void MArgs::Print(const Option_t *o) const
+{
+    gLog << all << underline << fName << ":" << endl;
+
+    const TString str(o);
+
+    if (!str.CompareTo("options", TString::kIgnoreCase))
+    {
+        TIter Next(fArgv);
+        TString *s = NULL;
+        while ((s=dynamic_cast<TString*>(Next())))
+            if (s->BeginsWith("-"))
+                gLog << *s << endl;
+        return;
+    }
+
+    if (!str.CompareTo("arguments", TString::kIgnoreCase))
+    {
+        TIter Next(fArgv);
+        TString *s = NULL;
+        while ((s=dynamic_cast<TString*>(Next())))
+            if (!s->BeginsWith("-"))
+                gLog << *s << endl;
+        return;
+    }
+
+    fArgv->Print();
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the Integer corresponding to the command line argument 'name'
+//  eg. executable -argument 5
+//      GetInt("argument") will return 5
+//
+Int_t MArgs::GetInt(const TString name) const
+{
+    return atoi(GetString(name));
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the floating point value corresponding to the command line argument
+// 'name'
+//  eg. executable -argument 5.7
+//      GetFloat("argument") will return 5.7
+//
+Double_t MArgs::GetFloat(const TString name) const
+{
+    return atof(GetString(name));
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the TString corresponding to the command line argument 'name'
+//  eg. executable -argument=last
+//      GetString("-argument=") will return "last"
+//
+TString MArgs::GetString(const TString name) const
+{
+    TIter Next(fArgv);
+    TString *s = NULL;
+    while ((s=dynamic_cast<TString*>(Next())))
+        if (s->BeginsWith(name))
+            return s->Data()+s->Index(name)+name.Length();
+    return 0;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the Integer corresponding to the command line argument 'name'
+//  eg. executable -argument5
+//      GetIntAndRemove("-argument") will return 5
+// and removes the argument from the internal list.
+//
+Int_t MArgs::GetIntAndRemove(const TString name)
+{
+    return atoi(GetStringAndRemove(name));
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the floating point value corresponding to the command line argument
+// 'name'
+//  eg. executable -argument5.7
+//      GetFloatAndRemove("-argument") will return 5.7
+// and removes the argument from the internal list.
+//
+Double_t MArgs::GetFloatAndRemove(const TString name)
+{
+    return atof(GetStringAndRemove(name));
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the TString corresponding to the command line argument 'name'
+//  eg. executable -argument=last
+//      GetStringAndRemove("-argument=") will return "last"
+// and removes the argument from the internal list.
+//
+TString MArgs::GetStringAndRemove(const TString n)
+{
+    const TString name = n.Strip(TString::kBoth);
+
+    TIter Next(fArgv);
+    TString *s = NULL;
+    while ((s=dynamic_cast<TString*>(Next())))
+        if (s->BeginsWith(name))
+        {
+            TString str = s->Data()+s->Index(name)+name.Length();
+            delete fArgv->Remove(dynamic_cast<TObject*>(s));
+            return str;
+        }
+    return 0;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the Integer corresponding to the i-th argument. This is ment
+// for enumerations like
+//  executable 1 7 2
+//  GetArgumentInt(1) will return 7
+//
+Int_t MArgs::GetArgumentInt(Int_t i) const
+{
+    return atoi(GetArgumentStr(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the floating point value corresponding to the i-th argument.
+// This is ment for enumerations like
+//  executable 1.7 7.5 2.3
+//  GetArgumentFloat(1) will return 7.5
+//
+Float_t MArgs::GetArgumentFloat(Int_t i) const
+{
+    return atof(GetArgumentStr(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the TString corresponding to the i-th argument.
+// This is ment for enumerations like
+//  executable file1 file2 file3
+//  GetArgumentStr(1) will return "file2"
+// Only arguments without a trailing '-' are considered
+//
+TString MArgs::GetArgumentStr(Int_t i) const
+{
+    Int_t num = 0;
+
+    TIter Next(fArgv);
+    TString *s = NULL;
+    while ((s=dynamic_cast<TString*>(Next())))
+    {
+        if (s->BeginsWith("-"))
+            continue;
+
+        if (i==num++)
+            return *s;
+    }
+
+    return "";
+}
+
+// --------------------------------------------------------------------------
+//
+// return the number of arguments without a trainling '-'
+//
+Int_t MArgs::GetNumArguments() const
+{
+    Int_t num = 0;
+
+    TIter Next(fArgv);
+    TString *s = NULL;
+    while ((s=dynamic_cast<TString*>(Next())))
+        if (!s->BeginsWith("-"))
+            num++;
+
+    return num;
+}
+
+// --------------------------------------------------------------------------
+//
+// return the number of arguments with a trainling '-'
+//
+Int_t MArgs::GetNumOptions() const
+{
+    Int_t num = 0;
+
+    TIter Next(fArgv);
+    TString *s = NULL;
+    while ((s=dynamic_cast<TString*>(Next())))
+        if (s->BeginsWith("-"))
+            num++;
+
+    return num;
+}
+
+// --------------------------------------------------------------------------
+//
+// return the total number of entries
+//
+Int_t MArgs::GetNumEntries() const
+{
+    return fArgv->GetSize();
+}
+
+// --------------------------------------------------------------------------
+//
+// Checks whether an argument beginning with 'n' is existing, eg:
+//  executable -value5
+//  executable -value
+//  HasOption("-value") will return true in both cases
+//
+Bool_t MArgs::Has(const TString n) const
+{
+    const TString name = n.Strip(TString::kBoth);
+
+    TIter Next(fArgv);
+    TString *s = NULL;
+    while ((s=dynamic_cast<TString*>(Next())))
+        if (s->BeginsWith(name))
+            return kTRUE;
+    return kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Checks whether an argument beginning with 'n' is existing, eg:
+//  executable -value5
+//   HasOption("-value") will return false
+//  executable -value
+//   HasOption("-value") will return true
+//
+Bool_t MArgs::HasOnly(const TString n) const
+{
+    const TString name = n.Strip(TString::kBoth);
+
+    TIter Next(fArgv);
+    TString *s = NULL;
+    while ((s=dynamic_cast<TString*>(Next())))
+        if (*s==name)
+            return kTRUE;
+    return kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Checks whether an argument beginning with 'n' is exists and a
+// corresponding option is available, eg.
+//  executable -value5
+//  HasOption("-value") will return true
+// but:
+//  executable -value
+//  HasOption("-value") will return false
+//
+Bool_t MArgs::HasOption(const TString n) const
+{
+    const TString name = n.Strip(TString::kBoth);
+
+    TIter Next(fArgv);
+    TString *s = NULL;
+    while ((s=dynamic_cast<TString*>(Next())))
+        if (s->BeginsWith(name) && s->Length()>name.Length())
+            return kTRUE;
+    return kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Checks whether an argument beginning with 'n' is exists and a
+// corresponding option is available, eg.
+//  executable -value5
+//  HasOption("-value") will return false
+// but:
+//  executable -value
+//  HasOption("-value") will return true
+//
+// The argument is removed from the internal list.
+//
+Bool_t MArgs::HasOnlyAndRemove(const TString n)
+{
+    const TString name = n.Strip(TString::kBoth);
+
+    TIter Next(fArgv);
+    TString *s = NULL;
+    while ((s=dynamic_cast<TString*>(Next())))
+        if (*s==name)
+        {
+            delete fArgv->Remove(dynamic_cast<TObject*>(s));
+            return kTRUE;
+        }
+
+    return kFALSE;
+}
Index: /tags/Mars_V0-8-5/Mars/mbase/MArgs.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MArgs.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MArgs.h	(revision 9661)
@@ -0,0 +1,60 @@
+#ifndef MARS_MArgs
+#define MARS_MArgs
+
+#ifndef ROOT_TNamed
+#include <TNamed.h>
+#endif
+
+#ifndef ROOT_TList
+#include <TList.h>
+#endif
+
+class MArgsEntry : public TString, public TObject
+{
+public:
+    MArgsEntry(const char *c) : TString(c), TObject() {}
+
+    void Print(const Option_t *o) const;
+
+    ClassDef(MArgsEntry, 0)
+};
+
+class MArgs : public TNamed
+{
+private:
+    Int_t  fArgc;
+    TList *fArgv; //->
+
+public:
+    MArgs(int argc, char **argv);
+    ~MArgs();
+
+    void Print(const Option_t *o="") const;
+
+    // FIXME: Add max, min option
+    // FIXME: Add default option
+
+    Int_t    GetInt(const TString name) const;
+    Double_t GetFloat(const TString name) const;
+    TString  GetString(const TString name) const;
+
+    Int_t    GetIntAndRemove(const TString name);
+    Double_t GetFloatAndRemove(const TString name);
+    TString  GetStringAndRemove(const TString name);
+
+    Bool_t   Has(const TString name) const;
+    Bool_t   HasOnly(const TString name) const;
+    Bool_t   HasOption(const TString name) const;
+    Bool_t   HasOnlyAndRemove(const TString name);
+
+    TString  GetArgumentStr(Int_t i) const;
+    Int_t    GetArgumentInt(Int_t i) const;
+    Float_t  GetArgumentFloat(Int_t i) const;
+    Int_t    GetNumArguments() const;
+    Int_t    GetNumOptions() const;
+    Int_t    GetNumEntries() const;
+
+    ClassDef(MArgs, 0)  //Class to parse command line arguments
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mbase/MArray.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MArray.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MArray.cc	(revision 9661)
@@ -0,0 +1,75 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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"
+
+#include <TArrayF.h>
+#include <TArrayD.h>
+
+ClassImp(MArray);
+
+// --------------------------------------------------------------------------
+//
+//  Cuts the last entries of an array containing only zeros.
+//
+void MArray::StripZeros(TArrayD &arr)
+{
+    const Int_t n = arr.GetSize();
+
+    for (Int_t i=n-1; i>=0; i--)
+        if (arr[i] != 0)
+        {
+            arr.Set(i+1);
+            break;
+        }
+}
+
+// --------------------------------------------------------------------------
+//
+//  Cuts the last entries of an array containing only zeros.
+//
+void MArray::StripZeros(TArrayF &arr)
+{
+    const Int_t n = arr.GetSize();
+
+    for (Int_t i=n-1; i>=0; i--)
+        if (arr[i] != 0)
+        {
+            arr.Set(i+1);
+            break;
+        }
+}
Index: /tags/Mars_V0-8-5/Mars/mbase/MArray.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MArray.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MArray.h	(revision 9661)
@@ -0,0 +1,40 @@
+#ifndef MARS_MArray
+#define MARS_MArray
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MArray                                                                  //
+//                                                                         //
+// Abstract array base class for TObject derived Arrays                    //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MAGIC
+#include "MAGIC.h"
+#endif
+
+class TArrayF;
+class TArrayD;
+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;
+
+   static void  StripZeros(TArrayF &arr);
+   static void  StripZeros(TArrayD &arr);        
+   
+   ClassDef(MArray, 1)  //Abstract array base class for TObject derived Arrays
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mbase/MArrayB.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MArrayB.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MArrayB.cc	(revision 9661)
@@ -0,0 +1,36 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!   Author(s): Thomas Bretz  12/2000 (tbretz@uni-sw.gwdg.de)
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+\* ======================================================================== */
+
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+// MArrayB                                                                  //
+//                                                                          //
+// Array of Byte_t. It is almost the same than TArrayC, but it containes    //
+// Byte_t instead of Char_t and it can be stored with splitlevel=1 to a     //
+// a root-file because of it's derivement from MArray (TObject)             //                                                                       //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+#include "MArrayB.h"
+
+ClassImp(MArrayB);
+
Index: /tags/Mars_V0-8-5/Mars/mbase/MArrayB.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MArrayB.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MArrayB.h	(revision 9661)
@@ -0,0 +1,174 @@
+#ifndef MARS_MArrayB
+#define MARS_MArrayB
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MArrayB                                                                 //
+//                                                                         //
+// Array of Byte_t                                                         //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MArray
+#include "MArray.h"
+#endif
+
+#include <string.h>
+
+class MArrayB : public MArray
+{
+private:
+    Byte_t *fArray; //[fN] Array of fN chars
+
+public:
+
+    MArrayB()
+    {
+        fN     = 0;
+        fArray = NULL;
+    }
+
+    MArrayB(UInt_t n)
+    {
+        fN     = 0;
+        fArray = NULL;
+
+        Set(n);
+    }
+
+    MArrayB(UInt_t n, Byte_t *array)
+    {
+        // Create TArrayC object and initialize it with values of array.
+        fN     = 0;
+        fArray = NULL;
+
+        Set(n, array);
+    }
+
+    MArrayB(const MArrayB &array)
+    {
+        // Copy constructor.
+        fArray = NULL;
+        Set(array.fN, array.fArray);
+    }
+
+    UInt_t GetSize() const
+    {
+        return fN;
+    }
+
+    MArrayB &operator=(const MArrayB &rhs)
+    {
+        // TArrayC assignment operator.
+        if (this != &rhs)
+            Set(rhs.fN, rhs.fArray);
+        return *this;
+    }
+
+    virtual ~MArrayB()
+    {
+        // Delete TArrayC object.
+        delete [] fArray;
+        fArray = NULL;
+    }
+
+    void Adopt(UInt_t n, Byte_t *array)
+    {
+        // Adopt array arr into TArrayC, i.e. don't copy arr but use it directly
+        // in TArrayC. User may not delete arr, TArrayC dtor will do it.
+        if (fArray)
+            delete [] fArray;
+
+        fN     = n;
+        fArray = array;
+    }
+
+    void AddAt(Byte_t c, UInt_t i)
+    {
+        // Add char c at position i. Check for out of bounds.
+        fArray[i] = c;
+    }
+
+    void AddAt(Byte_t *array, UInt_t i, UInt_t n)
+    {
+        // Add char c at position i. Check for out of bounds.
+        memcpy(fArray+i, array, n*sizeof(Byte_t));
+    }
+
+    Byte_t     At(UInt_t i)
+    {
+        return fArray[i];
+    }
+
+    Byte_t    *GetArray() const
+    {
+        return fArray;
+    }
+
+    void Reset()
+    {
+        memset(fArray, 0, fN*sizeof(Byte_t));
+    }
+
+    void Set(UInt_t n)
+    {
+        // Set size of this array to n chars.
+        // A new array is created, the old contents copied to the new array,
+        // then the old array is deleted.
+
+        if (n==fN)
+            return;
+
+        Byte_t *temp = fArray;
+        if (n == 0)
+            fArray = 0;
+        else
+        {
+            fArray = new Byte_t[n];
+            if (n < fN)
+                memcpy(fArray,temp, n*sizeof(Byte_t));
+            else
+            {
+                memcpy(fArray,temp,fN*sizeof(Byte_t));
+                memset(&fArray[fN],0,(n-fN)*sizeof(Byte_t));
+            }
+        }
+
+        if (fN)
+            delete [] temp;
+
+        fN = n;
+    }
+
+    void Set(UInt_t n, Byte_t *array)
+    {
+        // Set size of this array to n chars and set the contents.
+        if (!array)
+            return;
+
+        if (fArray && fN != n)
+        {
+            delete [] fArray;
+            fArray = 0;
+        }
+
+        fN = n;
+
+        if (fN == 0)
+            return;
+
+        if (!fArray)
+            fArray = new Byte_t[fN];
+
+        memcpy(fArray,array, n*sizeof(Byte_t));
+    }
+
+    Byte_t &operator[](UInt_t i)
+    {
+        return fArray[i];
+    }
+
+    ClassDef(MArrayB, 1)  //Array of Byte_t
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mbase/MArrayS.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MArrayS.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MArrayS.cc	(revision 9661)
@@ -0,0 +1,38 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+// MArrayS                                                                  //
+//                                                                          //
+// Array of UShort_t. It is almost the same than TArrayS, but it containes  //
+// UShort_t instead of Short_t and it can be stored with splitlevel=1 to a  //
+// a root-file because of it's derivement from MArray (TObject)             //                                                                       //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+#include "MArrayS.h"
+
+ClassImp(MArrayS);
+
Index: /tags/Mars_V0-8-5/Mars/mbase/MArrayS.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MArrayS.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MArrayS.h	(revision 9661)
@@ -0,0 +1,165 @@
+#ifndef MARS_MArrayS
+#define MARS_MArrayS
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MArrayS                                                                 //
+//                                                                         //
+// Array of UShort_t                                                       //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MArray
+#include "MArray.h"
+#endif
+
+#include <string.h>
+
+class MArrayS : public MArray
+{
+private:
+    UShort_t *fArray; //[fN] Array of fN chars
+
+public:
+
+    MArrayS()
+    {
+        fN     = 0;
+        fArray = NULL;
+    }
+
+    MArrayS(UInt_t n)
+    {
+        fN     = 0;
+        fArray = NULL;
+        Set(n);
+    }
+
+    MArrayS(UInt_t n, UShort_t *array)
+    {
+        // Create TArrayC object and initialize it with values of array.
+        fN     = 0;
+        fArray = NULL;
+        Set(n, array);
+    }
+
+    MArrayS(const MArrayS &array)
+    {
+        // Copy constructor.
+        fArray = NULL;
+        Set(array.fN, array.fArray);
+    }
+
+    UInt_t GetSize() const
+    {
+        return fN;
+    }
+
+    MArrayS &operator=(const MArrayS &rhs)
+    {
+        // TArrayC assignment operator.
+        if (this != &rhs)
+            Set(rhs.fN, rhs.fArray);
+        return *this;
+    }
+
+    virtual ~MArrayS()
+    {
+        // Delete TArrayC object.
+        delete [] fArray;
+        fArray = NULL;
+    }
+
+    void Adopt(UInt_t n, UShort_t *array)
+    {
+        // Adopt array arr into TArrayC, i.e. don't copy arr but use it directly
+        // in TArrayC. User may not delete arr, TArrayC dtor will do it.
+        if (fArray)
+            delete [] fArray;
+
+        fN     = n;
+        fArray = array;
+    }
+
+    void AddAt(UShort_t c, UInt_t i)
+    {
+        // Add char c at position i. Check for out of bounds.
+        fArray[i] = c;
+    }
+
+    UShort_t     At(UInt_t i)
+    {
+        return fArray[i];
+    }
+
+    UShort_t    *GetArray() const
+    {
+        return fArray;
+    }
+
+    void Reset()
+    {
+        memset(fArray, 0, fN*sizeof(UShort_t));
+    }
+
+    void Set(UInt_t n)
+    {
+        // Set size of this array to n chars.
+        // A new array is created, the old contents copied to the new array,
+        // then the old array is deleted.
+
+        if (n==fN)
+            return;
+
+        UShort_t *temp = fArray;
+        if (n == 0)
+            fArray = NULL;
+        else
+        {
+            fArray = new UShort_t[n];
+            if (n < fN)
+                memcpy(fArray, temp, n*sizeof(UShort_t));
+            else
+            {
+                memcpy(fArray, temp, fN*sizeof(UShort_t));
+                memset(&fArray[fN], 0, (n-fN)*sizeof(UShort_t));
+            }
+        }
+
+        if (fN)
+            delete [] temp;
+
+        fN = n;
+    }
+
+    void Set(UInt_t n, UShort_t *array)
+    {
+        // Set size of this array to n chars and set the contents.
+        if (!array)
+            return;
+
+        if (fArray && fN != n)
+        {
+            delete [] fArray;
+            fArray = 0;
+        }
+        fN = n;
+
+        if (fN == 0)
+            return;
+
+        if (!fArray)
+            fArray = new UShort_t[fN];
+
+        memcpy(fArray, array, n*sizeof(UShort_t));
+    }
+
+    UShort_t &operator[](UInt_t i)
+    {
+        return fArray[i];
+    }
+
+    ClassDef(MArrayS, 1)  //Array of UShort_t
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mbase/MClone.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MClone.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MClone.cc	(revision 9661)
@@ -0,0 +1,174 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// 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.
+//
+Int_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.
+//
+Int_t MClone::Process()
+{
+    //
+    // Delete an existing clone
+    //
+    Clear();
+
+    //
+    // Clone the given parameter container
+    //
+    fClone = fObject->Clone();
+
+    return kTRUE;
+} 
+
Index: /tags/Mars_V0-8-5/Mars/mbase/MClone.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MClone.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MClone.h	(revision 9661)
@@ -0,0 +1,41 @@
+#ifndef MARS_MClone
+#define MARS_MClone
+
+#ifndef MARS_MAGIC
+#include "MAGIC.h"
+#endif
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MParList;
+
+class MClone : public MTask
+{
+private:
+    const TObject *fObject; // pointer to container which has to be cloned
+    TString fObjName;       // given name to search for in the parameterlist
+
+    TObject* fClone;        // pointer to the cloned object. deletion is handled by MClone
+
+    void Init(const char *name, const char *title);
+
+public:
+    MClone(const char *obj,    const char *name=NULL, const char *title=NULL);
+    MClone(const TObject *obj, const char *name=NULL, const char *title=NULL);
+    ~MClone();
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
+    TObject *GetClone() const  { return fClone; }
+    const TObject *GetObject() const { return fObject; }
+
+    void Clear(Option_t *opt=NULL);
+
+    ClassDef(MClone, 0) // Task to clone (duplicate) an object in memory
+};
+    
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mbase/MContinue.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MContinue.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MContinue.cc	(revision 9661)
@@ -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 10/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MContinue
+//
+// Does nothing than return kCONTINUE in the Process-function
+// (use with filters). For more details see the description of the
+// constructors.
+//
+// To invert the meaning of the contained filter call SetInverted()
+//
+//  Input Containers:
+//   -/-
+//
+//  Output Containers:
+//   -/-
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MContinue.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MF.h"
+#include "MParList.h"
+#include "MTaskList.h"
+
+ClassImp(MContinue);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Use this constructor if a rule (see MF for more details) shell be used.
+// MContinue will create a MF object and use it as a filter for the
+// instance. The MF-Task is added to the tasklist in front of the MContinue
+// instance and also automatically deleted, eg.
+//   MContinue cont("MHillas.fSize<20");
+//   tasklist.AddToList(&cont);
+// would skip all events which fullfill "MHillas.fSize<20" from this point
+// in the tasklist.
+// It is not necessary to put the filter in the tasklist. The PreProcess
+// will search for the filter and if it isn't found in the tasklist it
+// is added to the tasklist in front of MContinue.
+//
+MContinue::MContinue(const TString rule, const char *name, const char *title)
+{
+    fName  = name  ? name  : "MContinue";
+    fTitle = title ? title : "Task returning kCONTINUE";
+
+    if (rule.IsNull())
+        return;
+
+    SetBit(kIsOwner);
+
+    MTask::SetFilter(new MF(rule, TString("MF(")+fName+")"));
+}
+
+// --------------------------------------------------------------------------
+//
+// Use this if you have a filter. Would be the same as if you would call:
+//   MContinue cont;
+//   cont.SetFilter(f);
+// It is not necessary to put the filter in the tasklist. The PreProcess
+// will search for the filter and if it isn't found in the tasklist it
+// is added to the tasklist in front of MContinue.
+//
+MContinue::MContinue(MFilter *f, const char *name, const char *title)
+{
+    fName  = name  ? name  : "MContinue";
+    fTitle = title ? title : "Task returning kCONTINUE";
+
+    SetFilter(f);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Delete the filter if it was created automatically
+//
+MContinue::~MContinue()
+{
+    if (TestBit(kIsOwner))
+        delete GetFilter();
+}
+
+// --------------------------------------------------------------------------
+//
+//  PreProcess tries to find the tasklist MTaskList, adds the filter
+//  before this instance to the tasklist and preprocesses the filter.
+//
+Int_t MContinue::PreProcess(MParList *list)
+{
+    if (!GetFilter())
+    {
+        *fLog << err << dbginf << "Unknown fatal Error! (fFilter=NULL?!?)" << endl;
+        return kFALSE;
+    }
+
+    fTaskList = (MTaskList*)list->FindObject("MTaskList");
+    if (!fTaskList)
+    {
+        *fLog << err << dbginf << "ERROR - Tasklist 'MTaskList' not found... abort." << endl;
+        return kFALSE;
+    }
+
+    if (fTaskList->FindObject(GetFilter()))
+    {
+        *fLog << inf << dbginf << "The filter is already in the tasklist..." << endl;
+        return kTRUE;
+    }
+
+    if (!fTaskList->AddToListBefore(GetFilter(), this))
+    {
+        *fLog << err << dbginf << "ERROR - Adding filter before MContinue... abort." << endl;
+        return kFALSE;
+    }
+
+    GetFilter()->SetDisplay(fDisplay);
+    GetFilter()->SetLogStream(fLog);
+
+    SetBit(kFilterIsPrivate);
+
+    return GetFilter()->CallPreProcess(list);
+}
+
+void MContinue::SetDisplay(MStatusDisplay *d)
+{
+    if (GetFilter())
+        GetFilter()->SetDisplay(d);
+
+    MTask::SetDisplay(d);
+}
+
+void MContinue::SetLogStream(MLog *lg)
+{
+    if (GetFilter())
+        GetFilter()->SetLogStream(lg);
+
+    MTask::SetLogStream(lg);
+}
+
+// --------------------------------------------------------------------------
+//
+// If the filter was added to the tasklist automatically it is removed
+// from the tasklist.
+//
+Int_t MContinue::PostProcess()
+{
+    if (!TestBit(kFilterIsPrivate))
+        return kTRUE;
+
+    if (fTaskList->RemoveFromList(GetFilter()))
+        return kTRUE;
+
+    *fLog << err << "ERROR: MContinue::PostProcess - Cannot remove Filter from tasklist" << endl;
+
+    return kFALSE;
+}
+
+void MContinue::SetInverted(Bool_t i)
+{
+    GetFilter()->SetInverted(i);
+}
+
+Bool_t MContinue::IsInverted() const
+{
+    return GetFilter()->IsInverted();
+}
Index: /tags/Mars_V0-8-5/Mars/mbase/MContinue.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MContinue.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MContinue.h	(revision 9661)
@@ -0,0 +1,47 @@
+#ifndef MARS_MContinue
+#define MARS_MContinue
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MContinue                                                               //
+//                                                                         //
+// Does nothing than return kCONTINUE in the Process-fucntion              //
+// (use with filters)                                                      //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MLog;
+class MFilter;
+class MTaskList;
+class MStatusDisplay;
+
+class MContinue : public MTask
+{
+private:
+    MTaskList *fTaskList;  //! pointer to the present tasklist
+
+    Int_t PreProcess(MParList *list);
+    Int_t Process() { return kCONTINUE; }
+    Int_t PostProcess();
+
+    enum { kIsOwner = BIT(14), kFilterIsPrivate = BIT(15) };
+
+public:
+    MContinue(const TString rule="", const char *name=NULL, const char *title=NULL);
+    MContinue(MFilter *f, const char *name=NULL, const char *title=NULL);
+    ~MContinue();
+
+    void SetInverted(Bool_t i=kTRUE);
+    Bool_t IsInverted() const;
+
+    void SetDisplay(MStatusDisplay *d);
+    void SetLogStream(MLog *lg);
+
+    ClassDef(MContinue, 1) //Task returning kCONTINUE
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mbase/MDirIter.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MDirIter.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MDirIter.cc	(revision 9661)
@@ -0,0 +1,339 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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, 6/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MDirIter
+//
+// Iterator for files in several directories (with filters)
+//
+// Use this class if you want to get all filenames in a directory
+// one-by-one.
+//
+// You can specify more than one directory (also recursivly) and you
+// can use filters (eg. *.root)
+//
+// Here is an example which will print all *.root files in the current
+// directory and all its subdirectories and all Gamma*.root files in
+// the directory ../data.
+//
+// ------------------------------------------------------------------------
+//
+//  // Instatiate the iterator
+//  MDirIter Next();
+//
+//  // Add the current directory (for *.root files) and recursive
+//  // directories with the same filter
+//  Next.AddDirectory(".", "*.root", kTRUE);
+//  // Add the directory ../data, too (filter only Gamma*.root files)
+//  Next.AddDirectory("../data", "Gamma*.root");
+//
+//  TString name;
+//  while (!(name=Next()).IsNull())
+//     cout << name << endl;
+//
+// ------------------------------------------------------------------------
+//
+// WARNING: If you specify relative directories (like in the example) the
+//          result may depend on the current working directory! Better use
+//          absolute paths.
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MDirIter.h"
+
+#include <iostream>
+
+#include <TNamed.h>
+#include <TRegexp.h>
+#include <TSystem.h>
+
+ClassImp(MDirIter);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+//  Add a directory, eg dir="../data"
+//  Using a filter (wildcards) will only return files matching this filter.
+//  recursive is the number of recursive directories (use 0 for none and -1
+//  for all)
+//  Returns the number of directories added.
+//  If a directory is added using a filter and the directory is already
+//  existing without a filter the filter is replaced.
+//  If any directory to be added is already existing with a different
+//  filter a new entry is created, eg:
+//   already existing:  ../data <*.root>
+//   new entry:         ../data <G*>
+//  The filters are or'ed.
+//
+Int_t MDirIter::AddDirectory(const char *d, const char *filter, Int_t recursive)
+{
+    TString dir = d;
+
+    // Sanity check
+    if (dir.IsNull())
+        return 0;
+
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,05,05)
+    if (dir[dir.Length()-1]!='/')
+        dir += '/';
+#else
+    if (!dir.EndsWith("/"))
+        dir += '/';
+#endif
+    gSystem->ExpandPathName(dir);
+
+    // Try to find dir in the list of existing dirs
+    TObject *o = fList.FindObject(dir);
+    if (o)
+    {
+        const TString t(o->GetTitle());
+
+        // Check whether the existing dir has an associated filter
+        if (t.IsNull())
+        {
+            // Replace old filter by new one
+            ((TNamed*)o)->SetTitle(filter);
+            return 0;
+        }
+
+        // If the filters are the same no action is taken
+        if (t==filter)
+            return 0;
+    }
+
+    fList.Add(new TNamed((const char*)dir, filter ? filter : ""));
+
+    // No recuresive directories, return
+    if (recursive==0)
+        return 1;
+
+    Int_t rc = 1;
+
+    // Create an iterator to iterate over all entries in the directory
+    MDirIter Next(dir);
+
+    TString c;
+    while (!(c=Next(kTRUE)).IsNull())
+    {
+        // Do not process . and .. entries
+        if (c.EndsWith("/.") || c.EndsWith("/.."))
+            continue;
+
+        // If entry is a directory add it with a lowere recursivity
+        if (IsDir(c)==0)
+            rc += AddDirectory(c, filter, recursive-1);
+    }
+    return rc;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Return the pointer to the current directory. If the pointer is NULL
+//  a new directory is opened. If no new directory can be opened NULL is
+//  returned.
+//
+void *MDirIter::Open()
+{
+    // Check whether a directory is already open
+    if (fDirPtr)
+        return fDirPtr;
+
+    // Get Next entry of list
+    fCurrentPath=fNext();
+
+    // Open directory if new entry was found
+    return fCurrentPath ? gSystem->OpenDirectory(fCurrentPath->GetName()) : NULL;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Close directory is opened. Set fDirPtr=NULL
+//
+void MDirIter::Close()
+{
+    if (fDirPtr)
+        gSystem->FreeDirectory(fDirPtr);
+    fDirPtr = NULL;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Returns the concatenation of 'dir' and 'name'
+//
+TString MDirIter::ConcatFileName(const char *dir, const char *name) const
+{
+    return TString(dir)+name;
+}
+
+// --------------------------------------------------------------------------
+//
+// Check whether the given name n matches the filter f.
+// Filters are of the form TRegexp(f, kTRUE)
+//
+Bool_t MDirIter::MatchFilter(const TString &n, const TString &f) const
+{
+    // As the filter string may contain a + character, we have to replace
+    // this filter by a new filter contaning a \+ at all locations where a +
+    // was in the original filter.
+    TString nf(f);
+    nf.ReplaceAll("+","\\+");
+
+    return f.IsNull() || !n(TRegexp(nf, kTRUE)).IsNull();
+}
+
+// --------------------------------------------------------------------------
+//
+// Check whether fqp is a directory.
+// Returns -1 if fqp couldn't be accesed, 0 if it is a directory,
+// 1 otherwise
+//
+Int_t MDirIter::IsDir(const char *fqp) const
+{
+    Long_t t[4];
+    if (gSystem->GetPathInfo(fqp, t, t+1, t+2, t+3))
+        return -1;
+
+    if (t[2]==3)
+        return 0;
+
+    return 1;
+}
+
+// --------------------------------------------------------------------------
+//
+// Check whether the current entry in the directory n is valid or not.
+// Entries must:
+//  - not be . or ..
+//  - match the associated filter
+//  - match the global filter
+//  - not be a directory
+//  - have read permission
+//
+Bool_t MDirIter::Check(const TString n) const
+{
+    // Check . and ..
+    if (n=="." || n=="..")
+        return kFALSE;
+
+    // Check associated filter
+    if (!MatchFilter(n, fCurrentPath->GetTitle()))
+        return kFALSE;
+
+    // Check global filter
+    if (!MatchFilter(n, fFilter))
+         return kFALSE;
+
+    // Check for file or directory
+    const TString fqp = ConcatFileName(fCurrentPath->GetName(), n);
+    if (IsDir(fqp)<=0)
+        return kFALSE;
+
+    // Check for rread perissions
+    return !gSystem->AccessPathName(fqp, kReadPermission);
+
+}
+
+// --------------------------------------------------------------------------
+//
+// Reset the iteration and strat from scratch. To do this correctly we have
+// to reset the list of directories to iterate _and_ to close the current
+// directory. When you call Next() the next time the first directory will
+// be reopened again and you'll get the first entry.
+//
+// Do not try to only close the current directory or to reset the directory
+// list only. This might not give the expected result!
+//
+void  MDirIter::Reset()
+{
+    Close();
+    fNext.Reset();
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the Next file in the directory which is valid (see Check())
+// nocheck==1 returns the next entry unchecked
+//
+TString MDirIter::Next(Bool_t nocheck)
+{
+    fDirPtr = Open();
+    if (!fDirPtr)
+        return "";
+
+    // Get next entry in dir, if existing check validity
+    const char *n = gSystem->GetDirEntry(fDirPtr);
+    if (n)
+        return nocheck || Check(n) ? ConcatFileName(fCurrentPath->GetName(), n) : Next();
+
+    // Otherwise close directory and try to get next entry
+    Close();
+    return Next();
+}
+
+// --------------------------------------------------------------------------
+//
+// Print a single entry in the list
+//
+void MDirIter::PrintEntry(const TObject &o) const
+{
+    TString p = o.GetName();
+    TString f = o.GetTitle();
+    cout << p;
+    if (!f.IsNull())
+        cout << " <" << f << ">";
+    cout << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Print all scheduled directories. If "all" is specified also all
+// matching entries are printed.
+//
+void MDirIter::Print(const Option_t *o) const
+{
+    TString s(o);
+    if (!s.Contains("all", TString::kIgnoreCase))
+    {
+        TIter Next(&fList);
+        TObject *o=NULL;
+        while ((o=Next()))
+            PrintEntry(*o);
+        return;
+    }
+
+    MDirIter Next(*this);
+    TString name;
+    TString d;
+    while (!(name=Next()).IsNull())
+    {
+        const TString p = Next.fCurrentPath->GetName();
+        if (p!=d)
+        {
+            d=p;
+            PrintEntry(*Next.fCurrentPath);
+        }
+        cout << " " << name << endl;
+    }
+}
Index: /tags/Mars_V0-8-5/Mars/mbase/MDirIter.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MDirIter.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MDirIter.h	(revision 9661)
@@ -0,0 +1,70 @@
+#ifndef MARS_MDirIter
+#define MARS_MDirIter
+
+#ifndef ROOT_TObjArray
+#include <TObjArray.h>
+#endif
+
+class MDirIter : public TObject
+{
+private:
+    TObjArray fList;
+    TString   fFilter;
+
+    TIter     fNext;        //!
+    void     *fDirPtr;      //!
+    TObject  *fCurrentPath; //!
+
+    void   *Open();
+    void    Close();
+    Bool_t  Check(const TString n) const;
+    Int_t   IsDir(const char *dir) const;
+    Bool_t  MatchFilter(const TString &name, const TString &filter) const;
+    TString ConcatFileName(const char *dir, const char *name) const;
+    void    PrintEntry(const TObject &o) const;
+
+public:
+    MDirIter() : fNext(&fList), fDirPtr(NULL)
+    {
+        fList.SetOwner();
+    }
+    MDirIter(const MDirIter &dir) : fNext(&fList), fDirPtr(NULL)
+    {
+        fList.SetOwner();
+
+        TObject *o=NULL;
+        TIter Next(&dir.fList);
+        while ((o=Next()))
+            AddDirectory(o->GetName(), o->GetTitle());
+    }
+    MDirIter(const char *dir, const char *filter="", Int_t rec=0) : fNext(&fList), fDirPtr(NULL)
+    {
+        fList.SetOwner();
+        AddDirectory(dir, filter, rec);
+    }
+    ~MDirIter()
+    {
+        Close();
+    }
+
+    Int_t AddDirectory(const char *dir, const char *filter="", Int_t recursive=0);
+    void  Reset();
+
+    TString Next(Bool_t nocheck=kFALSE);
+    TString operator()(Bool_t nocheck=kFALSE) { return Next(nocheck); }
+
+    void SetFilter(const char *f="") { fFilter = f; }
+    UInt_t GetNumEntries() const
+    {
+        UInt_t n = 0;
+        MDirIter Next(*this);
+        while (!Next().IsNull()) n++;
+        return n;
+    }
+
+    void Print(const Option_t *o="") const;
+
+    ClassDef(MDirIter, 1) // Iterator for files in several directories (with filters)
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mbase/MEvtLoop.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MEvtLoop.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MEvtLoop.cc	(revision 9661)
@@ -0,0 +1,1032 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// 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 function of the tasks are
+// executed as long as one function returns kSTOP. Only the tasks which
+// are 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.
+//
+// If you want to display the progress in a gui you can use SetProgressBar
+// and a TGProgressBar or a MProgressBar. If you set a MStatusDisplay
+// using SetDisplay, the Progress bar from this display is used.
+//
+// You can create a macro from a completely setup eventloop by:
+//   evtloop.MakeMacro("mymacro.C");
+//
+// You will always need to check the macro, it will not run, but it
+// should have al important information.
+//
+//
+// You can also write all this information to a root file:
+//   TFile file("myfile.root");
+//   evtloop.Write("MyEvtloopKey");
+//
+// You can afterwards read the information from an open file by:
+//   evtloop.Read("MyEvtloopKey");
+//
+// To lookup the information write it to a file using MakeMacro
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MEvtLoop.h"
+
+#include <time.h>           // time_t
+#include <fstream>          // ofstream, SavePrimitive
+
+#include <TEnv.h>           // TEnv
+#include <TRint.h>          // gApplication, TRint::Class()
+#include <TTime.h>          // TTime
+#include <TFile.h>          // gFile
+#include <TThread.h>        // TThread::Self()
+#include <TDatime.h>        // TDatime
+#include <TSystem.h>        // gSystem
+#include <TStopwatch.h>
+#include <TGProgressBar.h>  
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MTaskList.h"
+#ifdef __MARS__
+#include "MRead.h"           // for setting progress bar
+#include "MProgressBar.h"    // MProgressBar::GetBar
+#include "MStatusDisplay.h"  // MStatusDisplay::GetBar
+#endif
+
+ClassImp(MEvtLoop);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// default constructor
+//
+MEvtLoop::MEvtLoop(const char *name) : fParList(NULL), fProgress(NULL)
+{
+    fName = name;
+
+    gROOT->GetListOfCleanups()->Add(this); // To remove fDisplay
+    SetBit(kMustCleanup);
+
+    *fLog << inf << underline << "Instantiated MEvtLoop (" << name << "), using ROOT v" << ROOTVER << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// destructor
+//
+MEvtLoop::~MEvtLoop()
+{
+    if (TestBit(kIsOwner) && fParList)
+        delete fParList;
+}
+
+void MEvtLoop::SetParList(MParList *p)
+{
+    if (!p)
+        return;
+
+    p->SetBit(kMustCleanup);
+    fParList = p;
+}
+
+// --------------------------------------------------------------------------
+//
+// If the evntloop knows its tasklist search for the task there,
+// otherwise return NULL.
+//
+MTask *MEvtLoop::FindTask(const char *name) const
+{
+    return fTaskList ? fTaskList->FindTask(name) : NULL;
+}
+
+// --------------------------------------------------------------------------
+//
+// If the evntloop knows its tasklist search for the task there,
+// otherwise return NULL.
+//
+MTask *MEvtLoop::FindTask(const MTask *obj) const
+{
+    return fTaskList ? fTaskList->FindTask(obj) : NULL;
+}
+
+// --------------------------------------------------------------------------
+//
+//  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);
+}
+
+void MEvtLoop::SetProgressBar(TGProgressBar *bar)
+{
+    fProgress = bar;
+    if (fProgress)
+        fProgress->SetBit(kMustCleanup);
+}
+
+#ifdef __MARS__
+// --------------------------------------------------------------------------
+//
+//  Specify an existing MProgressBar object. It will display the progress
+//  graphically. This will make thing about 1-2% slower.
+//
+void MEvtLoop::SetProgressBar(MProgressBar *bar)
+{
+    SetProgressBar(bar->GetBar());
+}
+#endif
+
+void MEvtLoop::SetDisplay(MStatusDisplay *d)
+{
+    MParContainer::SetDisplay(d);
+    if (!d)
+        fProgress=NULL;
+    else
+    {
+        d->SetBit(kMustCleanup);
+
+        // Get pointer to update Progress bar
+        fProgress = fDisplay->GetBar();
+    }
+
+    if (fParList)
+        fParList->SetDisplay(d);
+}
+
+// --------------------------------------------------------------------------
+//
+// 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)
+{
+    fTaskList = NULL;
+
+    //
+    // 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);
+
+#ifdef __MARS__
+    //
+    // Check whether display is still existing
+    //
+    if (fDisplay)
+    {
+        // Lock display to prevent user from deleting it
+        fDisplay->Lock();
+        // Don't display context menus
+        fDisplay->SetNoContextMenu();
+        // Set window and icon name
+        fDisplay->SetWindowName(TString("Status Display: ")+fName);
+        fDisplay->SetIconName(fName);
+        // Start automatic update
+        fDisplay->StartUpdate();
+        // Cascade display through childs
+        fParList->SetDisplay(fDisplay);
+    }
+#endif
+
+    //
+    //  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;
+}
+
+Bool_t MEvtLoop::ProcessGuiEvents(Int_t num)
+{
+    if (gROOT->IsBatch())
+        return kTRUE;
+
+    //
+    // Check status of display
+    //
+    Bool_t rc = kTRUE;
+
+    if (fDisplay)
+        switch (fDisplay->CheckStatus())
+        {
+        case MStatusDisplay::kLoopNone:
+            break;
+        case MStatusDisplay::kLoopStop:
+            rc = kFALSE;
+            fDisplay->ClearStatus();
+            break;
+        //
+        // If the display is not on the heap (means: not created
+        // with the new operator) the object is deleted somewhere
+        // else in the code. It is the responsibility of the
+        // application which instantiated the object to make
+        // sure that the correct action is taken. This can be
+        // done by calling MStatusDisplay::CheckStatus()
+        //
+        // Because we are synchronous we can safely delete it here!
+        //
+        // Close means: Close the display but leave analysis running
+        // Exit means: Close the display and stop analysis
+        //
+        case MStatusDisplay::kFileClose:
+        case MStatusDisplay::kFileExit:
+            rc = fDisplay->CheckStatus() == MStatusDisplay::kFileClose;
+
+            if (fDisplay->IsOnHeap())
+                delete fDisplay;
+
+            //
+            // This makes the display really disappear physically on
+            // the screen in case of MStatusDisplay::kFileClose
+            //
+            gSystem->ProcessEvents();
+
+            return rc;
+        default:
+            *fLog << warn << "MEvtloop: fDisplay->CheckStatus() has returned unknown status #" << fDisplay->CheckStatus() << "... cleared." << endl;
+            fDisplay->ClearStatus();
+            break;
+        }
+
+    //
+    // Check System time (don't loose too much time by updating the GUI)
+    //
+
+    // FIXME: Not thread safe (if you have more than one eventloop running)
+    static Int_t start = num;
+    static TTime t1 = gSystem->Now();
+    static TTime t2 = t1;
+
+    //
+    // No update < 20ms
+    //
+    const TTime t0 = gSystem->Now();
+    if (t0-t1 < (TTime)20)
+        return rc;
+    t1 = t0;
+
+    //
+    // Update current speed each 1.5 second
+    //
+    if (fDisplay && t0-t2>(TTime)1500)
+    {
+        const Float_t speed = 1000.*(num-start)/(long int)(t0-t2);
+        TString txt = "Processing...";
+        if (speed>0)
+        {
+            txt += " (";
+            txt += (Int_t)speed;
+            txt += "Evts/s";
+            if (fNumEvents>0)
+            {
+                txt += ", est: ";
+                txt += (int)((fNumEvents-num)/speed/60)+1;
+                txt += "min";
+            }
+            //txt += (int)fmod(entries/(1000.*(num-start)/(long int)(t0-t2)), 60);
+            //txt += "s";
+            txt += ")";
+        }
+        fDisplay->SetStatusLine1(txt);
+        start = num;
+        t2 = t0;
+    }
+
+    //
+    // Set new progress bar position
+    //
+    if (fProgress && fNumEvents>0)
+        fProgress->SetPosition((Double_t)num/fNumEvents);
+
+    // FIXME: This is a workaround, because TApplication::Run is not
+    //        thread safe against ProcessEvents. We assume, that if
+    //        we are not in the Main-Thread ProcessEvents() is
+    //        called by the TApplication Event Loop...
+    if (!TThread::Self()/*gApplication->InheritsFrom(TRint::Class())*/)
+    {
+        //
+        // Handle GUI events (display changes)
+        //
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,02,06)
+        gSystem->ProcessEvents();
+#else
+        if (fDisplay)
+            gSystem->ProcessEvents();
+        else
+            if (fProgress)
+                gClient->ProcessEventsFor(fProgress);
+#endif
+    }
+
+    return rc;
+}
+
+// --------------------------------------------------------------------------
+//
+// The processing part of the eventloop. Be careful, this is
+// for developers or use in special jobs only!
+//
+Int_t MEvtLoop::Process(UInt_t maxcnt)
+{
+    if (!fTaskList)
+        return kFALSE;
+
+    //
+    //   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;
+
+    UInt_t entries = kMaxUInt;
+    fNumEvents = 0;
+
+    if (fProgress && !gROOT->IsBatch())
+    {
+        fProgress->Reset();
+        fProgress->SetRange(0, 1);
+
+#ifdef __MARS__
+        MRead *read = (MRead*)fTaskList->FindObject("MRead");
+        if (read && read->GetEntries()>0)
+            entries = read->GetEntries();
+#endif
+
+        if (maxcnt>0)
+            fNumEvents = TMath::Min(maxcnt, entries);
+        else
+            if (entries!=kMaxUInt)
+                fNumEvents = entries;
+    }
+
+    if (fDisplay)
+    {
+        fDisplay->SetStatusLine1("Processing...");
+        fDisplay->SetStatusLine2("");
+    }
+
+    //
+    // 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
+    //
+    UInt_t numcnts = 0;
+    UInt_t dummy   = maxcnt;
+
+    Int_t rc = kTRUE;
+    if (maxcnt==0)
+        // process first and increment if sucessfull
+        while ((rc=fTaskList->Process())==kTRUE)
+        {
+            numcnts++;
+            if (!ProcessGuiEvents(++dummy))
+                break;
+        }
+    else
+        // check for number and break if unsuccessfull
+        while (dummy-- && (rc=fTaskList->Process())==kTRUE)
+        {
+            numcnts++;
+            if (!ProcessGuiEvents(maxcnt - dummy))
+                break;
+        }
+
+    //
+    // stop stop-watch, print results
+    //
+    clock.Stop();
+
+    if (fProgress && !gROOT->IsBatch())
+    {
+        //fProgress->SetPosition(maxcnt>0 ? TMath::Min(maxcnt, entries) : entries);
+        fProgress->SetPosition(1);
+
+        // FIXME: This is a workaround, because TApplication::Run is not
+        //        thread safe against ProcessEvents. We assume, that if
+        //        we are not in the Main-Thread ProcessEvents() is
+        //        called by the TApplication Event Loop...
+        if (!TThread::Self()/*gApplication->InheritsFrom(TRint::Class())*/)
+        {
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,02,06)
+            gSystem->ProcessEvents();
+#else
+            gClient->ProcessEventsFor(fDisplay ? fDisplay->GetBar() : fProgress);
+#endif
+        }
+    }
+
+    *fLog << all << "Ready!" << endl << endl;
+
+    *fLog << dec << endl << "CPU  - Time: ";
+    *fLog << clock.CpuTime() << "s" << " for " << numcnts << " Events";
+    if (numcnts>0)
+        *fLog << " --> " << numcnts/clock.CpuTime() << " Events/s";
+    *fLog << endl << "Real - Time: ";
+    *fLog << clock.RealTime() << "s" << " for " << numcnts << " Events";
+    if (numcnts>0)
+        *fLog << " --> " << numcnts/clock.RealTime() << " Events/s";
+
+    *fLog << endl << endl;
+
+    return rc!=kERROR;
+}
+
+// --------------------------------------------------------------------------
+//
+//  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 ? fTaskList->PostProcess() : kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// See class description above. Returns kTRUE if PreProcessing,
+// Processing and PostProcessing was successfull, otherwise kFALSE.
+// maxcnt==0 means: all events
+// tlist is the name of the task-list to be used. Be carefull, this
+// feature is not finally implemented - it will only work if no
+// task will access the tasklist.
+//
+Bool_t MEvtLoop::Eventloop(UInt_t maxcnt, const char *tlist)
+{
+    TDatime d;
+    *fLog << inf << underline << "Eventloop: " << fName << " started at " << d.AsString() << endl;
+
+    Bool_t rc = PreProcess(tlist);
+
+    //
+    // If all Tasks were PreProcesses successfully start Processing.
+    //
+    if (rc)
+        rc = Process(maxcnt);
+
+    //
+    // Now postprocess all tasks. Only successfully preprocessed tasks
+    // are postprocessed. If the Postprocessing of one task fails
+    // return an error.
+    //
+    if (!PostProcess())
+    {
+        *fLog << err << "Error detected while PostProcessing." << endl;
+        rc = kFALSE;
+    }
+
+    if (!fDisplay)
+        return rc;
+
+    // Set status lines
+    fDisplay->SetStatusLine1(fName);
+    fDisplay->SetStatusLine2(rc ? "Done." : "Error!");
+    // Stop automatic update
+    fDisplay->StopUpdate();
+    // Reallow context menus
+    fDisplay->SetNoContextMenu(kFALSE);
+    // Reallow user to exit window by File menu
+    fDisplay->UnLock();
+
+    //
+    // If postprocessing of all preprocessed tasks was sucefully return rc.
+    // This gives an error in case the preprocessing has failed already.
+    // Otherwise the eventloop is considered: successfully.
+    //
+    return rc;
+}
+
+// --------------------------------------------------------------------------
+//
+//  After you setup (or read) an Evtloop you can use MakeMacro() to write
+//  the eventloop setup as a macro. The default name is "evtloop.C". The
+//  default extension is .C If the extension is not given, .C is added.
+//  If the last character in the argument is a '+' the file is not closed.
+//  This is usefull if you have an eventloop which runs three times and
+//  you want to write one macro. If the first character is a '+' no
+//  opening is written, eg:
+//
+//     MEvtLoop evtloop;
+//     // some setup
+//     evtloop.MakeMacro("mymacro+");
+//     // replace the tasklist the first time
+//     evtloop.MakeMacro("+mymacro+");
+//     // replace the tasklist the second time
+//     evtloop.MakeMacro("+mymacro");
+//
+void MEvtLoop::MakeMacro(const char *filename)
+{
+    TString name(filename);
+
+    name = name.Strip(TString::kBoth);
+
+    Bool_t open  = kTRUE;
+    Bool_t close = kTRUE;
+    if (name[0]=='+')
+    {
+        open = kFALSE;
+        name.Remove(0, 1);
+        name = name.Strip(TString::kBoth);
+    }
+
+    if (name[name.Length()-1]=='+')
+    {
+        close = kFALSE;
+        name.Remove(name.Length()-1, 1);
+        name = name.Strip(TString::kBoth);
+    }
+
+    if (!name.EndsWith(".C"))
+        name += ".C";
+
+    ofstream fout;
+
+    if (!open)
+    {
+        fout.open(name, ios::app);
+        fout << endl;
+        fout << "   // ----------------------------------------------------------------------" << endl;
+        fout << endl;
+    }
+    else
+    {
+        fout.open(name);
+
+        time_t t = time(NULL);
+        fout <<
+            "/* ======================================================================== *\\" << endl <<
+            "!" << endl <<
+            "! *" << endl <<
+            "! * This file is part of MARS, the MAGIC Analysis and Reconstruction" << endl <<
+            "! * Software. It is distributed to you in the hope that it can be a useful" << endl <<
+            "! * and timesaving tool in analysing Data of imaging Cerenkov telescopes." << endl <<
+            "! * It is distributed WITHOUT ANY WARRANTY." << endl <<
+            "! *" << endl <<
+            "! * Permission to use, copy, modify and distribute this software and its" << endl <<
+            "! * documentation for any purpose is hereby granted without fee," << endl <<
+            "! * provided that the above copyright notice appear in all copies and" << endl <<
+            "! * that both that copyright notice and this permission notice appear" << endl <<
+            "! * in supporting documentation. It is provided \"as is\" without express" << endl <<
+            "! * or implied warranty." << endl <<
+            "! *" << endl <<
+            "!" << endl <<
+            "!" << endl <<
+            "!   Author(s): Thomas Bretz et al. <mailto:tbretz@astro.uni-wuerzburg.de>" << endl <<
+            "!" << endl <<
+            "!   Copyright: MAGIC Software Development, 2000-2002" << endl <<
+            "!" << endl <<
+            "!" << endl <<
+            "\\* ======================================================================== */" << endl << endl <<
+            "// ------------------------------------------------------------------------" << endl <<
+            "//" << endl <<
+            "//     This macro was automatically created on" << endl<<
+            "//             " << ctime(&t) <<
+            "//        with the MEvtLoop::MakeMacro tool." << endl <<
+            "//" << endl <<
+            "// ------------------------------------------------------------------------" << endl << endl <<
+            "void " << name(0, name.Length()-2) << "()" << endl <<
+            "{" << endl;
+    }
+
+    SavePrimitive(fout, (TString)"" + (open?"open":"") + (close?"close":""));
+
+    if (!close)
+        return;
+
+    fout << "}" << endl;
+
+    *fLog << inf << "Macro '" << name << "' written." << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
+void MEvtLoop::StreamPrimitive(ofstream &out) const
+{
+    out << "   MEvtLoop " << GetUniqueName();
+    if (fName!="Evtloop")
+        out << "(\"" << fName << "\")";
+    out << ";" << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+//
+void MEvtLoop::SavePrimitive(ofstream &out, Option_t *opt)
+{
+    TString options = opt;
+    options.ToLower();
+
+    if (HasDuplicateNames("MEvtLoop::SavePrimitive"))
+    {
+        out << "   // !" << endl;
+        out << "   // ! WARNING - Your eventloop (MParList, MTaskList, ...) contains more than" << endl;
+        out << "   // ! one object (MParContainer, MTask, ...) with the same name. The created macro" << endl;
+        out << "   // ! may need manual intervention before it can be used." << endl;
+        out << "   // !" << endl;
+        out << endl;
+    }
+
+    if (!options.Contains("open"))
+    {
+        if (gListOfPrimitives)
+        {
+            *fLog << err << "MEvtLoop::SavePrimitive - Error: old file not closed." << endl;
+            gListOfPrimitives->ForEach(TObject, ResetBit)(BIT(15));
+            delete gListOfPrimitives;
+        }
+        gListOfPrimitives = new TList;
+    }
+
+    if (fParList)
+        fParList->SavePrimitive(out);
+
+    MParContainer::SavePrimitive(out);
+
+    if (fParList)
+        out << "   " << GetUniqueName() << ".SetParList(&" << fParList->GetUniqueName() << ");" << endl;
+    else
+        out << "   // fParList empty..." << endl;
+    out << "   if (!" << GetUniqueName() << ".Eventloop())" << endl;
+    out << "      return;" << endl;
+
+    if (!options.Contains("close"))
+        return;
+
+    gListOfPrimitives->ForEach(TObject, ResetBit)(BIT(15));
+    delete gListOfPrimitives;
+    gListOfPrimitives = 0;
+}
+
+// --------------------------------------------------------------------------
+//
+// Get a list of all conmtainer names which are somehow part of the
+// eventloop. Chack for duplicate members and print a warning if
+// duplicates are found. Return kTRUE if duplicates are found, otherwise
+// kFALSE;
+//
+Bool_t MEvtLoop::HasDuplicateNames(TObjArray &arr, const TString txt) const
+{
+    arr.Sort();
+
+    TIter Next(&arr);
+    TObject *obj;
+    TString name;
+    Bool_t found = kFALSE;
+    while ((obj=Next()))
+    {
+        if (name==obj->GetName())
+        {
+            if (!found)
+            {
+                *fLog << warn << endl;
+                *fLog << " ! WARNING (" << txt << ")" << endl;
+                *fLog << " ! Your eventloop (MParList, MTaskList, ...) contains more than" << endl;
+                *fLog << " ! one object (MParContainer, MTask, ...) with the same name." << endl;
+                *fLog << " ! Creating a macro from it using MEvtLoop::MakeMacro may create" << endl;
+                *fLog << " ! a macro which needs manual intervention before it can be used." << endl;
+                found = kTRUE;
+            }
+            *fLog << " ! Please rename: " << obj->GetName() << endl;
+        }
+        name = obj->GetName();
+    }
+
+    return found;
+}
+
+// --------------------------------------------------------------------------
+//
+// Get a list of all conmtainer names which are somehow part of the
+// eventloop. Chack for duplicate members and print a warning if
+// duplicates are found. Return kTRUE if duplicates are found, otherwise
+// kFALSE;
+//
+Bool_t MEvtLoop::HasDuplicateNames(const TString txt) const
+{
+    if (!fParList)
+        return kFALSE;
+
+    TObjArray list;
+    list.SetOwner();
+
+    fParList->GetNames(list);
+
+    return HasDuplicateNames(list, txt);
+}
+
+// --------------------------------------------------------------------------
+//
+// Reads a saved eventloop from a file. The default name is "Evtloop".
+// Therefor an open file must exist (See TFile for more information)
+//
+//  eg:
+//        TFile file("myfile.root", "READ");
+//        MEvtLoop evtloop;
+//        evtloop.Read();
+//        evtloop.MakeMacro("mymacro");
+//
+Int_t MEvtLoop::Read(const char *name)
+{
+    if (!gFile)
+    {
+        *fLog << err << "MEvtloop::Read: No file found. Please create a TFile first." << endl;
+        return 0;
+    }
+
+    if (!gFile->IsOpen())
+    {
+        *fLog << err << "MEvtloop::Read: File not open. Please open the TFile first." << endl;
+        return 0;
+    }
+
+    Int_t n = 0;
+    TObjArray list;
+
+    n += TObject::Read(name);
+
+    if (n==0)
+    {
+        *fLog << err << "MEvtloop::Read: No objects read." << endl;
+        return 0;
+    }
+
+    n += list.Read((TString)name+"_names");
+
+    fParList->SetNames(list);
+
+    HasDuplicateNames(list, "MEvtLoop::Read");
+
+    *fLog << inf << "Eventloop '" << name << "' read from file." << endl;
+
+    return n;
+}
+
+// --------------------------------------------------------------------------
+//
+// If available print the contents of the parameter list.
+//
+void MEvtLoop::Print(Option_t *opt) const
+{
+    if (fParList)
+        fParList->Print();
+    else
+        *fLog << all << "MEvtloop: No Parameter List available." << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Writes a eventloop to a file. The default name is "Evtloop".
+// Therefor an open file must exist (See TFile for more information)
+//
+//  eg:
+//        TFile file("myfile.root", "RECREATE");
+//        MEvtLoop evtloop;
+//        evtloop.Write();
+//        file.Close();
+//
+Int_t MEvtLoop::Write(const char *name, Int_t option, Int_t bufsize)
+{
+    if (!gFile)
+    {
+        *fLog << err << "MEvtloop::Write: No file found. Please create a TFile first." << endl;
+        return 0;
+    }
+
+    if (!gFile->IsOpen())
+    {
+        *fLog << err << "MEvtloop::Write: File not open. Please open the TFile first." << endl;
+        return 0;
+    }
+
+    if (!gFile->IsWritable())
+    {
+        *fLog << err << "MEvtloop::Write: File not writable." << endl;
+        return 0;
+    }
+
+    Int_t n = 0;
+
+    TObjArray list;
+    list.SetOwner();
+
+    fParList->GetNames(list);
+
+    n += TObject::Write(name, option, bufsize);
+
+    if (n==0)
+    {
+        *fLog << err << "MEvtloop::Read: No objects written." << endl;
+        return 0;
+    }
+
+    n += list.Write((TString)name+"_names", kSingleKey);
+
+    HasDuplicateNames(list, "MEvtLoop::Write");
+
+    *fLog << inf << "Eventloop written to file as " << name << "." << endl;
+
+    return n;
+}
+
+// --------------------------------------------------------------------------
+//
+// Read the contents/setup of a parameter container/task from a TEnv
+// instance (steering card/setup file).
+// The key to search for in the file should be of the syntax:
+//    prefix.vname
+// While vname is a name which is specific for a single setup date
+// (variable) of this container and prefix is something like:
+//    evtloopname.name
+// While name is the name of the containers/tasks in the parlist/tasklist
+//
+// eg.  Job4.MImgCleanStd.CleaningLevel1:  3.0
+//      Job4.MImgCleanStd.CleaningLevel2:  2.5
+//
+// If this cannot be found the next step is to search for
+//      MImgCleanStd.CleaningLevel1:  3.0
+// And if this doesn't exist, too, we should search for:
+//      CleaningLevel1:  3.0
+//
+// Warning: The programmer is responsible for the names to be unique in
+//          all Mars classes.
+//
+Bool_t MEvtLoop::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
+{
+    if (!prefix.IsNull())
+        *fLog << warn << "WARNING - Second argument in MEvtLoop::ReadEnv has no meaning... ignored." << endl;
+
+    prefix = fName;
+    prefix += ".";
+
+    *fLog << inf << "Reading resources for " << prefix /*TEnv::fRcName << " from " << env.GetRcName()*/ << endl;
+
+    if (fParList->ReadEnv(env, prefix, print)==kERROR)
+    {
+        *fLog << err << "ERROR - Reading Environment file." << endl;
+        return kFALSE;
+    }
+
+    fLog->ReadEnv(env, prefix, print);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calls 'ReadEnv' with a TEnv initialized with the given file name.
+// If 'config=0' kTRUE is returned.
+//
+Bool_t MEvtLoop::ReadEnv(const char *config)
+{
+    return config ? ReadEnv(TEnv(config)) : kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Write the contents/setup of a parameter container/task to a TEnv
+// instance (steering card/setup file).
+// The key to search for in the file should be of the syntax:
+//    prefix.vname
+// While vname is a name which is specific for a single setup date
+// (variable) of this container and prefix is something like:
+//    evtloopname.name
+// While name is the name of the containers/tasks in the parlist/tasklist
+//
+// eg.  Job4.MImgCleanStd.CleaningLevel1:  3.0
+//      Job4.MImgCleanStd.CleaningLevel2:  2.5
+//
+// If this cannot be found the next step is to search for
+//      MImgCleanStd.CleaningLevel1:  3.0
+// And if this doesn't exist, too, we should search for:
+//      CleaningLevel1:  3.0
+//
+// Warning: The programmer is responsible for the names to be unique in
+//          all Mars classes.
+//
+Bool_t MEvtLoop::WriteEnv(TEnv &env, TString prefix, Bool_t print) const
+{
+    if (!prefix.IsNull())
+        *fLog << warn << "WARNING - Second argument in MEvtLoop::WriteEnv has no meaning... ignored." << endl;
+
+    prefix = fName;
+    prefix += ".";
+
+    *fLog << inf << "Writing resources: " << prefix /*TEnv::fRcName << " to " << env.GetRcName()*/ << endl;
+
+    if (fParList->WriteEnv(env, prefix, print)!=kTRUE)
+    {
+        *fLog << err << "ERROR - Writing Environment file." << endl;
+        return kFALSE;
+    }
+
+    fLog->WriteEnv(env, prefix, print);
+
+    return kTRUE;
+}
+
+void MEvtLoop::RecursiveRemove(TObject *obj)
+{
+    if (obj==fParList)
+    {
+        fParList=NULL;
+        fTaskList=NULL;
+    }
+
+    if (obj==fProgress)
+        fProgress = NULL;
+
+    if (obj==fDisplay)
+        SetDisplay(NULL);
+
+    if (obj==fLog)
+    {
+        if (fParList)
+            fParList->SetLogStream(NULL);
+        SetLogStream(NULL);
+    }
+}
Index: /tags/Mars_V0-8-5/Mars/mbase/MEvtLoop.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MEvtLoop.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MEvtLoop.h	(revision 9661)
@@ -0,0 +1,89 @@
+#ifndef MARS_MEvtLoop
+#define MARS_MEvtLoop
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MEvtLoop                                                                //
+//                                                                         //
+// Class to execute the tasks in a tasklist                                //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MTask;
+class MParList;
+class MTaskList;
+class TGProgressBar;
+#ifdef __MARS__
+class MProgressBar;
+#endif
+
+class MEvtLoop : public MParContainer
+{
+private:
+    MParList  *fParList;
+    MTaskList *fTaskList;      //!
+
+    TGProgressBar *fProgress;  //!
+
+    ULong_t fNumEvents;        //!
+
+    enum { kIsOwner = BIT(14) };
+
+    Bool_t HasDuplicateNames(const TString txt) const;
+    Bool_t HasDuplicateNames(TObjArray &arr, const TString txt) const;
+
+    void StreamPrimitive(ofstream &out) const;
+
+    Bool_t ProcessGuiEvents(Int_t num);
+
+public:
+    MEvtLoop(const char *name="Evtloop");
+    virtual ~MEvtLoop();
+
+    void       SetParList(MParList *p);
+    MParList  *GetParList() const  { return fParList; }
+    MTaskList *GetTaskList() const { return fTaskList; }
+
+    MTask *FindTask(const char *name) const;
+    MTask *FindTask(const MTask *obj) const;
+
+    MStatusDisplay *GetDisplay() { return fDisplay; }
+    void SetDisplay(MStatusDisplay *d);
+
+    void SetOwner(Bool_t enable=kTRUE);
+
+    void SetProgressBar(TGProgressBar *bar);
+#ifdef __MARS__
+    void SetProgressBar(MProgressBar *bar);
+#endif
+
+    Bool_t PreProcess(const char *tlist="MTaskList");
+    Int_t  Process(UInt_t maxcnt);
+    Bool_t PostProcess() const;
+
+    Bool_t Eventloop(UInt_t maxcnt=0, const char *tlist="MTaskList");
+
+    void MakeMacro(const char *filename="evtloop.C");
+
+    void SavePrimitive(ofstream &out, Option_t *o="");
+
+    Int_t Read(const char *name="Evtloop");
+    Int_t Write(const char *name="Evtloop", Int_t option=0, Int_t bufsize=0);
+
+    void Print(Option_t *opt="") const;
+
+    Bool_t ReadEnv(const TEnv &env, TString prefix="", Bool_t print=kFALSE);
+    Bool_t WriteEnv(TEnv &env, TString prefix="", Bool_t print=kFALSE) const;
+
+    Bool_t ReadEnv(const char *config);
+
+    void RecursiveRemove(TObject *obj);
+
+    ClassDef(MEvtLoop, 1) // Class to execute the tasks in a tasklist
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mbase/MFilter.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MFilter.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MFilter.cc	(revision 9661)
@@ -0,0 +1,86 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 07/2001 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//   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 invert the meaning of a filter (logical NOT '!') by calling   //
+//   SetInverted().                                                        //
+//                                                                         //
+//   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) : fInverted(kFALSE)
+{
+    fName  = name  ? name  : "MFilter";
+    fTitle = title ? title : "Base Class for a filter";
+}
+
+TString MFilter::GetRule() const
+{
+    return "<GetRule n/a for " + fName + ">";
+}
Index: /tags/Mars_V0-8-5/Mars/mbase/MFilter.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MFilter.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MFilter.h	(revision 9661)
@@ -0,0 +1,30 @@
+#ifndef MARS_MFilter
+#define MARS_MFilter
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MParList;
+
+class MFilter : public MTask
+{
+private:
+    Bool_t fInverted;
+
+    virtual Bool_t IsExpressionTrue() const = 0;
+
+public:
+    MFilter(const char *name=NULL, const char *title=NULL);
+
+    virtual TString GetRule() const;
+
+    Bool_t IsConditionTrue() const { return fInverted ? !IsExpressionTrue() : IsExpressionTrue(); }
+
+    void SetInverted(Bool_t i=kTRUE) { fInverted=i; }
+    Bool_t IsInverted() const  { return fInverted; }
+
+    ClassDef(MFilter, 1)		// Abstract base class for the filters
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mbase/MGGroupFrame.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MGGroupFrame.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MGGroupFrame.cc	(revision 9661)
@@ -0,0 +1,139 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  11/2001 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MGGroupFrame                                                            //
+//                                                                         //
+// This is a group frame derived from TGGroupFrame with some               //
+// enhancements:                                                           //
+//  - It holds a list which deletes all it's members in ~MGGroupFrame      //
+//    (use AddToList to add an object.                                     //
+//  - You can access the members of the list by their widget id (if they   //
+//    have one)                                                            //
+//  - All messages from associated GUI elemets are redirectd to a given    //
+//    task.                                                                //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MGGroupFrame.h"
+
+#include "MGList.h"
+#include "MGTask.h"
+
+ClassImp(MGGroupFrame);
+
+// --------------------------------------------------------------------------
+//
+//  For a detailed description check TGGroupFrame::TGGroupFrame.
+//  All messages from associated GUI elements are redirected to the given
+//  task.
+//  Creates a MGList object to store Widgets. Use AddToList to Add
+//  objects.
+//
+MGGroupFrame::MGGroupFrame(MGTask *task,
+                           const TGWindow *p, TGString *title,
+                           UInt_t options, GContext_t norm,
+                           FontStruct_t font, ULong_t back)
+    : TGGroupFrame(p, title, options, norm, font, back), TGWidget(-1)
+{
+    fWidgetFlags = 0;
+    fMsgWindow   = p;
+    fTask        = task;
+
+    fList = new MGList;
+}
+
+// --------------------------------------------------------------------------
+//
+//  For a detailed description check TGGroupFrame::TGGroupFrame.
+//  All messages from associated GUI elements are redirected to the given
+//  task.
+//  Creates a MGList object to store Widgets. Use AddToList to Add
+//  objects.
+//
+MGGroupFrame::MGGroupFrame(MGTask *task,
+                           const TGWindow *p, const char *title,
+                           UInt_t options, GContext_t norm,
+                           FontStruct_t font, ULong_t back)
+: TGGroupFrame(p, title, options, norm, font, back), TGWidget(-1)
+{
+    fWidgetFlags = 0;
+    fMsgWindow   = p;
+    fTask        = task;
+
+    fList = new MGList;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Deleted the MGList object and all its members.
+//
+MGGroupFrame::~MGGroupFrame()
+{
+    fList->SetOwner();
+    delete fList;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Add an object to the MGList. All the objects in MGList are deleted
+//  in the destructor MGGroupFrame automatically.
+//  You can add all object which have to exist until the Group Frame is
+//  destroyed (eg. TGLayoutElements)
+//  If an object is also derived from TGWidget you can get a pointer
+//  to it by its widget Id (use FindWidget)
+//
+void MGGroupFrame::AddToList(TObject *obj)
+{
+    fList->Add(obj);
+}
+
+// --------------------------------------------------------------------------
+//
+//  To get an object which has a widget id (is derived from TGWidget) by
+//  its widget id use FindWidget with the widget id of the object you
+//  are searching for. If no object with this widget id exists NULL
+//  is returned. See also MGList::FindWidget(Int_t)
+//
+TObject *MGGroupFrame::FindWidget(Int_t id) const
+{
+    return fList->FindWidget(id);
+}
+
+// --------------------------------------------------------------------------
+//
+//  If you associate an object with this MGGroupFrame object, like in the
+//  following example:
+//
+//   MGGroupFrame *f = new MGGroupFrame(...);
+//   TGTextEntry *entry = new TGTextEntry(...);
+//   entry->Associate(f);
+//
+//  All messages send to the group frame by the GUI elent are redirected
+//  to the task corresponing to the MGGroupFrame.
+//
+Bool_t MGGroupFrame::ProcessMessage(Long_t msg, Long_t param1, Long_t param2)
+{
+    return fTask->ProcessMessage(GET_MSG(msg), GET_SUBMSG(msg), param1, param2);
+}
Index: /tags/Mars_V0-8-5/Mars/mbase/MGGroupFrame.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MGGroupFrame.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MGGroupFrame.h	(revision 9661)
@@ -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) // An interface to widgets in a group frame (makes live easier)
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mbase/MGList.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MGList.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MGList.cc	(revision 9661)
@@ -0,0 +1,270 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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>
+
+#include <TClass.h>
+#include <TGClient.h>
+#include <TGWidget.h>
+#include <TGPicture.h>
+
+ClassImp(MGList);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+//  Before destroying the list with all its contents free all TGPicture
+//  objects in the list.
+//
+MGList::~MGList()
+{
+    TObject *obj;
+    TIter Next(this);
+    while ((obj=Next()))
+    {
+        if (!obj->InheritsFrom(TGPicture::Class()))
+            continue;
+
+        //
+        // Remove the object first. Otherwise we would remove
+        // a non existing object...
+        //
+        Remove(obj);
+        gClient->FreePicture((TGPicture*)obj);
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+//  Does a dynamic cast from a TObject to a TGWidget. This is necesary
+//  if a class derived from TObject inherits also from TGWidget and
+//  you have only a pointer to the TObject available.
+//
+TGWidget *MGList::GetWidget(TObject *obj) const
+{
+    //
+    // - IsA gives a pointer to the parent class entry in the dictionary
+    // - DynamicCast tries to cast obj of class type obj->IsA to one
+    //   of its base classes TGWidget
+    // - This method is ment for dynamic casts (multi inheritance)
+    //
+    //  If this functions makes trouble check for the correct inheritance
+    //  first via obj->InheritsFrom(TGWidget::Class())
+    //
+    //  The root implementation is used, because for space reasons
+    //  the C++ dynamic_cast<TGWidget*> is turned off by the option
+    //  -fno-rtti, which could be used in 'plain' C++
+    //
+
+    //
+    // FIXME: This should not be necessary but it is, why??
+    //
+    // TRY: TGPicture *pic = gClient->GetPicture("pic");
+    //      cout << pic->IsA()->DynamicCast(TGWidget::Class(), pic) << endl;
+    //
+    //      Is this another bug in root?
+    //
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,02,07)
+    if (!obj->InheritsFrom(TGWidget::Class()))
+        return NULL;
+#endif
+
+    return (TGWidget*)obj->IsA()->DynamicCast(TGWidget::Class(), obj);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Returns kTRUE if the object is derived from TGWidget and a widget
+//  with the TGWidget id of this object is already in the list.
+//  If the object is not derived from TGWidget or no TGWidget object
+//  with the same widget id is existing in the list kFALSE is returned.
+//  If the TGWidget has an object id < 0 kFALSE is always retuned.
+//
+Bool_t MGList::IsExisting(TObject *obj) const
+{
+    const TGWidget *wid = GetWidget(obj);
+
+    //
+    // check whether it is a TGWidget
+    //
+    if (!wid)
+        return kFALSE;
+
+    const Int_t id = wid->WidgetId();
+
+    //
+    // check whether is has a valid id
+    // (not id=-1, which is the standard id)
+    //
+    if (id < 0)
+        return kFALSE;
+
+    //
+    // check whether Widget id is already existing in the list
+    //
+    return FindWidget(id) ? kTRUE : kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  If the given object obj is derived from TGWidget and a TGWidget with
+//  the same widget id is already existing in the list the object is
+//  ignored, otherwise it is added to the list via TList::Add(TObject *)
+//
+void MGList::Add(TObject *obj)
+{
+    if (IsExisting(obj))
+    {
+        // FIXME: Replace by gLog
+        const Int_t id = GetWidget(obj)->WidgetId();
+        cout << "Widget with id #" << id << " (";
+        cout << FindWidget(id)->ClassName() << ") already in list... ";
+        cout << obj->GetName() << " ignored." << endl;
+        return;
+    }
+
+    TList::Add(obj);
+}
+
+// --------------------------------------------------------------------------
+//
+//  If the given object obj is derived from TGWidget and a TGWidget with
+//  the same widget id is already existing in the list the object is
+//  ignored, otherwise it is added to the list via
+//  TList::Add(TObject *, Option_t *)
+//
+void MGList::Add(TObject *obj, Option_t *opt)
+{
+    if (IsExisting(obj))
+    {
+        Int_t id = GetWidget(obj)->WidgetId();
+        cout << "Widget with id #" << id << " (";
+        cout << FindWidget(id)->ClassName() << ") already in list... ";
+        cout << obj->GetName() << " ignored." << endl;
+        return;
+    }
+
+    TList::Add(obj, opt);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Adds the picture physically to the list. The list takes care of that
+//   - The picture is freed as often as it was retrieved from gClient
+//
+void MGList::AddPicture(const TGPicture *pic, const char *name)
+{
+    //
+    // Check whether the picture exists
+    //
+    if (!pic)
+    {
+        cout << "Warning: Requested picture '" << name << "' not found... ignored." << endl;
+        cout << "    Please copy " << name << " to $HOME or $HOME/icons or add" << endl;
+        cout << "      Unix.*.Gui.IconPath: ~/Path/To/The/Picture" << endl;
+        cout << "    to [$HOME/].rootrc."  << endl;
+        return;
+    }
+
+    //
+    // Add the picture to the list
+    //
+    TList::Add(const_cast<TGPicture*>(pic));
+}
+
+// --------------------------------------------------------------------------
+//
+//  This gets a picture from the picture pool of the TGClient-object.
+//  The pictures are freed automatically in the dstructor of the list.
+//  The picture counts itself how often it got used, so that only
+//  the first call to GetPicture will craete it and the last call to
+//  FreePicture will destroy it. If you access the picture only via
+//  MGList::GetPicture you don't have to care about.
+//
+//  Don't try to call FreePicture by yourself for a picture gotten by
+//  GetPicture. This is independant of the kIsOwner bit.
+//
+const TGPicture *MGList::GetPicture(const char *name)
+{
+    const TGPicture *pic = gClient->GetPicture(name);
+    AddPicture(pic, name);
+    return pic;
+}
+
+// --------------------------------------------------------------------------
+//
+//  This gets a picture from the picture pool of the TGClient-object.
+//  The pictures are freed automatically in the dstructor of the list.
+//  The picture counts itself how often it got used, so that only
+//  the first call to GetPicture will craete it and the last call to
+//  FreePicture will destroy it. If you access the picture only via
+//  MGList::GetPicture you don't have to care about.
+//
+//  Don't try to call FreePicture by yourself for a picture gotten by
+//  GetPicture. This is independant of the kIsOwner bit.
+//
+const TGPicture *MGList::GetPicture(const char *name, Int_t width, Int_t height)
+{
+    const TGPicture *pic = gClient->GetPicture(name, width, height);
+    AddPicture(pic, name);
+    return pic;
+}
+// --------------------------------------------------------------------------
+//
+//  Search the list for a object derived from TGidget which has the given
+//  widget id. Returns a pointer to this object otherwise NULL.
+//  For IDs < 0 the function returns always NULL.
+//
+TObject *MGList::FindWidget(Int_t id) const
+{
+    if (id<0)
+        return NULL;
+
+    TObject *obj;
+    TIter Next(this);
+    while ((obj=Next()))
+    {
+        const TGWidget *wid = GetWidget(obj);
+
+        if (!wid)
+            continue;
+
+        if (id == wid->WidgetId())
+            return obj;
+    }
+    return NULL;
+}
Index: /tags/Mars_V0-8-5/Mars/mbase/MGList.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MGList.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MGList.h	(revision 9661)
@@ -0,0 +1,34 @@
+#ifndef MARS_MGList
+#define MARS_MGList
+
+#ifndef ROOT_TList
+#include <TList.h>
+#endif
+
+class TGWidget;
+class TGPicture;
+
+class MGList : public TList
+{
+private:
+    TGWidget *GetWidget(TObject *obj) const;
+    Bool_t    IsExisting(TObject *obj) const;
+
+    void      AddPicture(const TGPicture *pic, const char *name);
+
+public:
+    MGList() : TList() {}
+    virtual ~MGList();
+
+    void Add(TObject *obj);
+    void Add(TObject *obj, Option_t *opt);
+
+    const TGPicture *GetPicture(const char *name);
+    const TGPicture *GetPicture(const char *name, Int_t width, Int_t height);
+
+    TObject *FindWidget(Int_t id) const;
+
+    ClassDef(MGList, 0)
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mbase/MGMap.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MGMap.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MGMap.cc	(revision 9661)
@@ -0,0 +1,587 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 05/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2002-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MGMap
+//  =====
+//
+// This Map of TObjects connects TObjects with a TString. It can be used
+// to create maps which displays tooltips it the mouse is above the objects.
+//
+// It is also a tool to convert TObjects which are drawn into
+// a bitmap or to draw them into a TGFrame. Because in both cases the
+// support for drawing such object must be programmed explicitly only
+// simple objects (TLine, TMarker, etc) are supported.
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MGMap.h"
+
+#include <limits.h>  // INT_MAX
+
+#include <TPad.h>    // gPad, TPad::GetMaxDistance()
+
+#include <TLine.h>
+#include <TMarker.h>
+
+#include <TGToolTip.h>
+
+ClassImp(MGMap);
+
+using namespace std;
+
+//
+// THIS IS A WORKAROUND TO GET A MORE DIRECT ACCESS TO TGX11
+//
+/*
+#include <TGX11.h>
+class MGX11 : public TGX11
+{
+public:
+    ULong_t GetGc(Int_t which) const
+    {
+        return (ULong_t)*TGX11::GetGC(which);
+    }
+    void DrawLine(Drawable_t id, TObject *o, Int_t dx, Int_t dy, Float_t r)
+    {
+        TLine *l = dynamic_cast<TLine*>(o);
+        if (!l)
+            return;
+
+        SetLineColor(l->GetLineColor());
+        SetLineWidth(l->GetLineWidth());
+        SetLineStyle(l->GetLineStyle());
+
+        if (l->GetLineColor()==kRed)
+            SetLineColor(50);
+        if (l->GetLineColor()==kBlue)
+            SetLineColor(9);
+
+        gVirtualX->DrawLine(id, GetGc(0),
+                            dx+(l->GetX1()/r), dy-(l->GetY1()/r),
+                            dx+(l->GetX2()/r), dy-(l->GetY2()/r));
+    }
+    void DrawMarker(Drawable_t id, TObject *o, Int_t dx, Int_t dy, Float_t r)
+    {
+        TMarker *m = dynamic_cast<TMarker*>(o);
+        if (!m)
+            return;
+
+        SetLineColor(m->GetMarkerColor());
+        SetLineStyle(kSolid);
+        SetLineWidth(1);
+
+        const Double_t x = dx+(m->GetX()/r);
+        const Double_t y = dy-(m->GetY()/r);
+        const Int_t l = (Int_t)(m->GetMarkerSize()*5)+1;
+
+        switch (m->GetMarkerStyle())
+        {
+        case kPlus:
+            gVirtualX->DrawLine(id, GetGc(0), x-l, y, x+l, y);
+            gVirtualX->DrawLine(id, GetGc(0), x, y-l, x, y+l);
+            break;
+        case kCircle:
+            for (int i=0; i<8; i++)
+                gVirtualX->DrawLine(id, GetGc(0),
+                                    x+l*cos(i*TMath::TwoPi()/8),
+                                    y+l*sin(i*TMath::TwoPi()/8),
+                                    x+l*cos(((i+1)%8)*TMath::TwoPi()/8),
+                                    y+l*sin(((i+1)%8)*TMath::TwoPi()/8));
+            break;
+        case kCross:
+            gVirtualX->DrawLine(id, GetGc(0), x-l, y-l, x+l, y+l);
+            gVirtualX->DrawLine(id, GetGc(0), x-l, y+l, x+l, y-l);
+            break;
+        }
+    }
+};
+*/
+// --------------------------------------------------------------------------
+//
+// Constructor. For more details see TExMap
+//
+MGMap::MGMap(Int_t mapSize) : TExMap(mapSize)//, fToolTip(0)
+{
+//    fToolTip = new TGToolTip(0, "", 0);
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor. Deletes all objects of the map if kIsOwner is set via
+// SetOwner.
+//
+MGMap::~MGMap()
+{
+//    fToolTip->Hide();
+//    delete fToolTip;
+
+    if (TestBit(kIsOwner))
+        Delete();
+}
+
+// --------------------------------------------------------------------------
+//
+// Add an TObject to be drawn and if necessary a corresponding TString
+// to the Map. You must take care of deleting both objects if SetOwner()
+// was not called. Otherwise MGMap takes the ownership of the objects.
+//
+void MGMap::Add(TObject *k, TString *v)
+{
+    TExMap::Add((ULong_t)GetSize(), (Long_t)k, (Long_t)v);
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete all objects stored in the TExMap
+//
+void MGMap::Delete(Option_t *opt)
+{
+    Long_t key, val;
+    TExMapIter map(this);
+    while (map.Next(key, val))
+    {
+        delete (TObject*)(key);
+        if (!val)
+            continue;
+
+        delete (TString*)(val);
+        /*
+         Long_t key2, val2;
+         TExMapIter map2(&fMapG);
+         while (map2.Next(key2, val2))
+         if (val==val2)
+         {
+         delete (TObject*)key;
+         fMapG.Remove(key);
+         }
+         */
+    }
+    TExMap::Delete();
+}
+
+// --------------------------------------------------------------------------
+//
+// Paint all TObjects (which are supported) to a drawable with Id id.
+// Scale is the distance of the center of your drawable to one edge in
+// user coordinates.
+//
+// FIXME: Currently the width and height is hardcoded to 768x576 -
+//        find a way to get it from the drawable.
+//
+/*
+void MGMap::Paint(Drawable_t id, Float_t scale)
+{
+    if (id==0 && gPad)
+        id = gVirtualX->GetWindowID(gPad->GetPixmapID());
+
+    const Int_t w = 768;
+    const Int_t h = 576;
+
+    scale /= TMath::Hypot((float)w, (float)h)/2;
+
+    Long_t key, val;
+    TExMapIter map(this);
+    while (map.Next(key, val))
+    {
+        TObject *o = (TObject*)key;
+        ((MGX11*)gVirtualX)->DrawLine(id,   o, w/2, h/2, scale);
+        ((MGX11*)gVirtualX)->DrawMarker(id, o, w/2, h/2, scale);
+    }
+}
+*/
+
+// --------------------------------------------------------------------------
+//
+// Convert root colors to arbitrary bitmap coordinates
+//
+UChar_t MGMap::Color(int col)
+{
+    switch (col)
+    {
+    case kBlack:  return 0;
+    case kWhite:  return 0xff;
+    case kYellow: return 0x0f;
+    case kRed:    return 2;
+    case kGreen:  return 2<<2;
+    case kBlue:   return 2<<4;
+    default:
+        return 0;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw a line into the buffer (size w*h) from (x1, y1) to (x2, y2) with
+// the color col and the line style style (default: solid)
+//
+void MGMap::DrawLine(UChar_t *buf, int w, int h, Float_t x1, Float_t y1, Float_t x2, Float_t y2, UChar_t col, Int_t style)
+{
+    const Int_t    step = style==kSolid?1:3;
+    const Double_t len  = TMath::Hypot(x2-x1, y2-y1);
+    const Double_t dx   = (x2-x1)/len*step;
+    const Double_t dy   = (y2-y1)/len*step;
+
+    Double_t x = x1;
+    Double_t y = y1;
+
+    for (int i=0; i<len; i+=step)
+    {
+        x+= dx;
+        y+= dy;
+
+        const Int_t iy = TMath::Nint(y);
+        if (iy<0 || iy>=h)
+            continue;
+
+        const Int_t ix = TMath::Nint(x);
+        if (ix<0 || ix>=w)
+            continue;
+
+        buf[ix+iy*w] = col;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw a box into the buffer (size w*h) from (x1, y1) to (x2, y2) with
+// the color col and the line style style (default: solid)
+//
+void MGMap::DrawBox(UChar_t *buf, int w, int h, Float_t x1, Float_t y1, Float_t x2, Float_t y2, UChar_t col, Int_t style)
+{
+    DrawLine(buf, w, h, x1, y1, x2, y1, col, style);
+    DrawLine(buf, w, h, x1, y2, x2, y1, col, style);
+    DrawLine(buf, w, h, x1, y1, x1, y2, col, style);
+    DrawLine(buf, w, h, x2, y1, x2, y2, col, style);
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw a circle into the buffer (size w*h) around (x, y) with radius r and
+// the color col.
+//
+void MGMap::DrawCircle(UChar_t *buf, int w, int h, Float_t x, Float_t y, Float_t r, UChar_t col)
+{
+    const Int_t n = TMath::Nint(sqrt(2.)*r*TMath::Pi()/2);
+    for (int i=0; i<n-1; i++)
+    {
+        const Double_t angle = TMath::TwoPi()*i/n;
+
+        const Double_t dx = r*cos(angle);
+        const Double_t dy = r*sin(angle);
+
+        const Int_t x1 = TMath::Nint(x+dx);
+        const Int_t x2 = TMath::Nint(x-dx);
+
+        const Int_t y1 = TMath::Nint(y+dy);
+        if (y1>=0 && y1<h)
+        {
+            if (x1>=0 && x1<w)
+                buf[x1+y1*w] = col;
+
+            if (x2>=0 && x2<w)
+                buf[x2+y1*w] = col;
+        }
+
+        const Int_t y2 = TMath::Nint(y-dy);
+        if (y2>=0 && y2<h)
+        {
+            if (x1>=0 && x1<w)
+                buf[x1+y2*w] = col;
+
+            if (x2>=0 && x2<w)
+                buf[x2+y2*w] = col;
+        }
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw a dot into the buffer (size w*h) at (x, y) with color col.
+//
+void MGMap::DrawDot(UChar_t *buf, int w, int h, Float_t cx, Float_t cy, UChar_t col)
+{
+    const Int_t x1 = TMath::Nint(cx);
+    const Int_t y1 = TMath::Nint(cy);
+
+    if (x1>=0 && y1>=0 && x1<w && y1<h)
+        buf[x1+y1*w] = col;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw a line into the buffer. The TObject must be a TLine.
+// Currently only solid and non sloid line are supported.
+//
+void MGMap::DrawLine(TObject *o, UChar_t *buf, int w, int h, Double_t scale)
+{
+    TLine *l = dynamic_cast<TLine*>(o);
+    if (!l)
+        return;
+
+    const Double_t x1 = 0.5*w-(l->GetX1()/scale);
+    const Double_t x2 = 0.5*w-(l->GetX2()/scale);
+    const Double_t y1 = 0.5*h-(l->GetY1()/scale);
+    const Double_t y2 = 0.5*h-(l->GetY2()/scale);
+
+    const Int_t col = Color(l->GetLineColor());
+    DrawLine(buf, w, h, x1, y1, x2, y2, col, l->GetLineStyle());
+}
+
+void MGMap::DrawMultiply(UChar_t *buf, int w, int h, Float_t cx, Float_t cy, Float_t size, UChar_t col)
+{
+    DrawLine(buf, w, h, cx-size, cy-size, cx+size, cy+size, col);
+    DrawLine(buf, w, h, cx+size, cy-size, cx-size, cy+size, col);
+}
+
+void MGMap::DrawCross(UChar_t *buf, int w, int h, Float_t cx, Float_t cy, Float_t size, UChar_t col)
+{
+    DrawLine(buf, w, h, cx-size, cy, cx+size, cy, col);
+    DrawLine(buf, w, h, cx, cy-size, cx, cy+size, col);
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw marker into the buffer. The TObject must be a TMarker.
+// Currently kCircle, kMultiply and KDot are supported.
+//
+void MGMap::DrawMarker(TObject *o, UChar_t *buf, int w, int h, Double_t scale)
+{
+    TMarker *m = dynamic_cast<TMarker*>(o);
+    if (!m)
+        return;
+
+    Double_t x = 0.5*w-(m->GetX()/scale);
+    Double_t y = 0.5*h-(m->GetY()/scale);
+
+    Int_t col = Color(m->GetMarkerColor());
+
+    switch (m->GetMarkerStyle())
+    {
+    case kCircle:
+        DrawCircle(buf, w, h, x, y, m->GetMarkerSize()*2+1, col);
+        break;
+    case kDot:
+        DrawDot(buf, w, h, x, y, col);
+        break;
+    case kMultiply:
+        DrawMultiply(buf, w, h, x, y, m->GetMarkerSize()*2+1, col);
+        break;
+    case kCross:
+        DrawCross(buf, w, h, x, y, m->GetMarkerSize()*2+1, col);
+        break;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Paint all elements to the pad by calling their Paint() function
+//
+void MGMap::Paint(Option_t *o)
+{
+    Long_t key, val;
+    TExMapIter map(this);
+    while (map.Next(key, val))
+        ((TObject*)key)->Paint();
+}
+
+// --------------------------------------------------------------------------
+//
+// Paint all objects into a buffer of w*h UChar_ts. The scale
+// gives you the conversio factor to convert pad coordinates into
+// buffer pixels - it is the distance from the center of the buffer
+// to one of its edges.
+//
+void MGMap::Paint(UChar_t *buf, int w, int h, Float_t scale)
+{
+    scale /= TMath::Hypot((float)w, (float)h)/2;
+
+    Long_t key, val;
+    TExMapIter map(this);
+    while (map.Next(key, val))
+    {
+        TObject *o = (TObject*)key;
+        DrawLine(o, buf, w, h, scale);
+        DrawMarker(o, buf, w, h, scale);
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Search for an object at px, py. Return the pointer to it
+// if found. Set str accordingly if a corresponding TString is found.
+//
+TObject *MGMap::PickObject(Int_t px, Int_t py, TString &str) const
+{
+    Long_t key, val;
+    TExMapIter map(this);
+    while (map.Next(key, val))
+    {
+        if (!val)
+            continue;
+
+        TObject *o=(TObject*)key;
+        if (o->DistancetoPrimitive(px, py)>TPad::GetMaxPickDistance())
+            continue;
+
+        str = *(TString*)val;
+        return o;
+    }
+    return NULL;
+}
+
+// ------------------------------------------------------------------------
+//
+// Returns string containing info about the object at position (px,py).
+// Returned string will be re-used (lock in MT environment).
+// The text will be truncated to 128 charcters
+//
+char *MGMap::GetObjectInfo(Int_t px, Int_t py) const
+{
+    TString str;
+    PickObject(px, py, str);
+
+    static char txt[129];
+    txt[128]=0;
+
+    return strncpy(txt, str.Data(), 128);
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculate distance to primitive by checking all gui elements
+//
+Int_t MGMap::DistancetoPrimitive(Int_t px, Int_t py)
+{
+    Int_t min = INT_MAX;
+
+    Long_t key, val;
+    TExMapIter map(this);
+    while (map.Next(key, val))
+    {
+        TObject *o=(TObject*)key;
+
+        const Int_t d = o->DistancetoPrimitive(px, py);
+
+        if (d<TPad::GetMaxPickDistance())
+            return 0;
+
+        if (d<min)
+            min=d;
+    }
+
+    return min;
+}
+
+// --------------------------------------------------------------------------
+//
+// Displays a tooltip
+//
+/*
+void MGMap::ShowToolTip(Int_t px, Int_t py, const char *txt)
+{
+    if (TestBit(kNoToolTips))
+        return;
+
+    Int_t x=0;
+    Int_t y=0;
+
+    const Window_t id1 = gVirtualX->GetWindowID(gPad->GetCanvasID());
+    const Window_t id2 = fToolTip->GetParent()->GetId();
+
+    Window_t id3;
+    gVirtualX->TranslateCoordinates(id1, id2, px, py, x, y, id3);
+
+    // Show tool tip
+    fToolTip->SetText(txt);
+    fToolTip->Show(x+4, y+4);
+}
+*/
+
+// --------------------------------------------------------------------------
+//
+// This function was connected to all created canvases. It is used
+// to redirect GetObjectInfo into our own status bar.
+//
+// The 'connection' is done in Draw. It seems that 'connected'
+// functions must be public.
+//
+/*
+void MGMap::EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected)
+{
+    TVirtualPad *c = (TVirtualPad*)gTQSender; // gTQSender==TCanvas
+
+    gPad = c ? c->GetSelectedPad() : NULL;
+    if (!gPad)
+        return;
+
+    // Try to find a corresponding object with kCannotPick set and
+    // an available TString (for a tool tip)
+    TString str;
+    if (!selected || selected==this)
+        selected =  PickObject(px, py, str);
+
+    if (!selected)
+        return;
+
+    // Handle some gui events
+    switch (event)
+    {
+    case kMouseMotion:
+        if (!fToolTip->IsMapped() && !str.IsNull())
+            ShowToolTip(px, py, str);
+        break;
+
+    case kMouseLeave:
+        if (fToolTip->IsMapped())
+            fToolTip->Hide();
+        break;
+
+    default:
+        ExecuteEvent(event, px, py);
+        break;
+    }
+}
+*/
+
+/*
+void MAstroCatalog::RecursiveRemove(TObject *obj)
+{
+    ULong_t hash;
+    Long_t key, val;
+
+    TExMapIter map(&fMapG);
+    while (map.Next(hash, key, val))
+    {
+        if (key != (Long_t)obj)
+            continue;
+
+        fMapG.Remove(hash, key);
+        delete (TObject*)(key);
+        if (val)
+            delete (TString*)(val);
+        break;
+    }
+}
+*/
Index: /tags/Mars_V0-8-5/Mars/mbase/MGMap.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MGMap.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MGMap.h	(revision 9661)
@@ -0,0 +1,60 @@
+#ifndef MARS_MGMap
+#define MARS_MGMap
+
+#ifndef ROOT_GuiTypes
+#include <GuiTypes.h> // Drawable_t
+#endif
+#ifndef ROOT_TExMap
+#include <TExMap.h>
+#endif
+
+class TString;
+class TGToolTip;
+
+class MGMap : public TExMap
+{
+private:
+    //    TGToolTip *fToolTip;   //! The tooltip currently displayed
+
+    enum {
+        kIsOwner    = BIT(14),
+        // kNoToolTips = BIT(15), // suppress tooltips
+    };
+
+    //    void ShowToolTip(Int_t px, Int_t py, const char *txt);
+
+public:
+    MGMap(Int_t mapSize = 100);
+    ~MGMap();
+
+    void     SetOwner(Bool_t o=kTRUE) { o ? SetBit(kIsOwner) : ResetBit(kIsOwner); }
+    void     Add(TObject *k, TString *v=0);
+    void     Delete(Option_t *opt = "");
+
+    //    void   SetNoToolTips(Bool_t b=kTRUE) { b ? SetBit(kNoToolTips) : ResetBit(kNoToolTips); } // *TOGGLE* *GETTER=HasNoToolTips
+    //    Bool_t HasNoToolTips() const         { return TestBit(kNoToolTips); }
+
+    void     Paint(Option_t *o="");
+    void     Paint(UChar_t *buf, int w, int h, Float_t scale);
+    //void     Paint(Drawable_t id, Float_t scale);
+
+    void     DrawLine(TObject *o, UChar_t *buf, int w, int h, Double_t scale);
+    void     DrawMarker(TObject *o, UChar_t *buf, int w, int h, Double_t scale);
+
+    //void     EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected);
+    TObject *PickObject(Int_t px, Int_t py, TString &str) const;
+    char    *GetObjectInfo(Int_t px, Int_t py) const;
+    Int_t    DistancetoPrimitive(Int_t px, Int_t py);
+
+    static UChar_t Color(int col);
+    static void    DrawCircle(UChar_t *buf, int w, int h, Float_t x, Float_t y, Float_t r, UChar_t col);
+    static void    DrawLine(UChar_t *buf, int w, int h, Float_t x1, Float_t y1, Float_t x2, Float_t y2, UChar_t col, Int_t style=1);
+    static void    DrawBox(UChar_t *buf, int w, int h, Float_t x1, Float_t y1, Float_t x2, Float_t y2, UChar_t col, Int_t style=1);
+    static void    DrawDot(UChar_t *buf, int w, int h, Float_t cx, Float_t cy, UChar_t col);
+    static void    DrawMultiply(UChar_t *buf, int w, int h, Float_t cx, Float_t cy, Float_t size, UChar_t col);
+    static void    DrawCross(UChar_t *buf, int w, int h, Float_t cx, Float_t cy, Float_t size, UChar_t col);
+
+    ClassDef(MGMap, 1) // Special TExMap supporting enhanced drawing and bitmap drawing
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mbase/MGMenu.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MGMenu.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MGMenu.cc	(revision 9661)
@@ -0,0 +1,226 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 4/2003 <mailto:tbretz@astro-uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MGMenu, MGPopupMenu
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MGMenu.h"
+
+
+MGMenuEntry::MGMenuEntry(TGMenuEntry *ent)
+{
+    memcpy(this, ent, sizeof(*ent));
+}
+
+// -------------------------------------------------------------
+//
+// Return the keycode corresponding to the hot string of
+// a TGmenuEntry
+//
+UInt_t MGPopupMenu::GetKeyCode(TGMenuEntry *el)
+{
+    TGHotString *str = MGMenuEntry(el).GetLabel();
+    return gVirtualX->KeysymToKeycode(str->GetHotChar());
+}
+
+// -------------------------------------------------------------
+//
+// Bind all hot keys used in this popup menu subsequentlt
+// to the TGMainFrame and send a HandleKey message to the
+// TGWindow
+//
+void MGPopupMenu::BindKeys(const TGWindow *w, TGMainFrame *frame)
+{
+    TIter Next(fEntryList);
+    TGMenuEntry *el;
+
+    //
+    // Loop Through all entries
+    //
+    while ((el=(TGMenuEntry*)Next()))
+    {
+        switch (el->GetType())
+        {
+            //
+            // For seperators and labels nothing to do
+            //
+        case kMenuSeparator:
+        case kMenuLabel:
+            continue;
+
+            //
+            // For an entry and a popup menu bind the hot key
+            // In case of a popup menu call BindKeys subsequently
+            //
+        case kMenuEntry:
+        case kMenuPopup:
+            frame->BindKey(w, GetKeyCode(el), kKeyMod1Mask);
+            if (el->GetType()==kMenuPopup)
+                MGMenuEntry(el).GetPopup()->BindKeys(w, frame);
+            continue;
+        }
+    }
+}
+
+/*
+ kMenuActiveMask  = BIT(0),
+ kMenuEnableMask  = BIT(1),
+ kMenuDefaultMask = BIT(2),
+ kMenuCheckedMask = BIT(3),
+ kMenuRadioMask   = BIT(4),
+ kMenuHideMask    = BIT(5)
+ */
+
+// -------------------------------------------------------------
+//
+//  Handle a keyboard event. Return kFALSE in case of a
+//  successfully send message, which means: close all open
+//  popups.
+//
+Bool_t MGPopupMenu::HandleKey(Event_t *evt)
+{
+    //
+    // Loop through all entries in this popup menu. If the entry is
+    // an open popup menu send the key event to the open popup.
+    //
+    TIter Next(fEntryList);
+    TGMenuEntry *el;
+    while ((el=(TGMenuEntry*)Next()))
+    {
+        if (el->GetType()==kMenuPopup && el->GetStatus()&kMenuActiveMask)
+            return MGMenuEntry(el).GetPopup()->HandleKey(evt);
+    }
+
+    Next.Reset();
+
+    //
+    // If no open popup is found search the pressed key in this
+    // popup menu.
+    //
+    while ((el=(TGMenuEntry*)Next()))
+    {
+        switch (el->GetType())
+        {
+            //
+            // Do nothing
+            //
+        case kMenuSeparator:
+        case kMenuLabel:
+            continue;
+
+            //
+            // If the keycode corresponds to the hot key
+            // of this entry and the entry is enabled activate the entry
+            // and send the corresponding message/
+            //
+        case kMenuEntry:
+            if (GetKeyCode(el)==evt->fCode && el->GetStatus()&kMenuEnableMask)
+            {
+                Activate(el);
+                SendMessage(fMsgWindow, MK_MSG(kC_COMMAND, kCM_MENU),
+                            el->GetEntryId(), (Long_t)MGMenuEntry(el).GetUserData());
+                return kFALSE;
+            }
+            continue;
+
+            //
+            // If the keycode corresponds to the hot key
+            // of this popup menu activate the popup menu.
+            //
+        case kMenuPopup:
+            if (GetKeyCode(el)!=evt->fCode)
+                continue;
+
+            Activate(el);
+            HandleTimer(NULL);
+            return kTRUE;
+        }
+    }
+    return kTRUE;
+}
+
+// -------------------------------------------------------------
+//
+// Bind the keys of all popups subsequently to the given main
+// frame. The menu bar hot keys are already bound by TGMenuBar.
+// Bind the Escape key to close the popups, too.
+//
+void MGMenuBar::BindKeys(TGMainFrame *frame)
+{
+    TGFrameElement *el=NULL;
+    TIter Next(fList);
+    while ((el = (TGFrameElement *)Next()))
+        ((MGPopupMenu*)((TGMenuTitle *) el->fFrame)->GetMenu())->BindKeys(this, frame);
+
+    frame->BindKey(this, 9/*ESC*/, 0);
+}
+
+// -------------------------------------------------------------
+//
+// Handle the keyboard event send to this menu bar.
+//
+Bool_t MGMenuBar::HandleKey(Event_t *event)
+{
+    //
+    // If this isn't a pressed key do nothing
+    //
+    if (event->fType != kGKeyPress)
+        return kTRUE;
+
+    //
+    // Check whether one popup is alreadu open
+    //
+    TGFrameElement *el=NULL;
+    TIter Next(fList);
+    while ((el = (TGFrameElement *)Next()))
+    {
+        if (!((TGMenuTitle*)el->fFrame)->GetState())
+            continue;
+
+        TGMenuTitle &f = *(TGMenuTitle*)el->fFrame;
+
+        //
+        // If a open popup is found redirect the key event to this
+        // popup menu
+        //
+        Bool_t rc = ((MGPopupMenu*)f.GetMenu())->HandleKey(event);
+
+        //
+        // If a message could be successfully send or the escape key
+        // was pressed close the popup.
+        //
+        if (rc && event->fCode!=9/*ESC*/)
+            return kTRUE;
+
+        f.SetState(kFALSE);
+        gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);  // ungrab pointer
+        gVirtualX->SetKeyAutoRepeat(kTRUE); // set in TGMainFrame::HandleKey
+        fCurrent = 0;
+        return kTRUE;
+    }
+
+    return TGMenuBar::HandleKey(event);
+}
Index: /tags/Mars_V0-8-5/Mars/mbase/MGMenu.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MGMenu.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MGMenu.h	(revision 9661)
@@ -0,0 +1,53 @@
+#ifndef MARS_MGMenu
+#define MARS_MGMenu
+
+#ifndef ROOT_TGMenu
+#include <TGMenu.h>
+#endif
+
+class MGPopupMenu;
+
+class MGMenuEntry : public TGMenuEntry
+{
+    /*
+     Workaround for the protected data mambers of TGMenuEntry
+     */
+public:
+    MGMenuEntry(TGMenuEntry *ent);
+    ~MGMenuEntry()
+    {
+        fLabel=0;
+    }
+
+    MGPopupMenu *GetPopup() { return (MGPopupMenu*)fPopup; }
+    TGHotString *GetLabel() { return fLabel; }
+    void *GetUserData()     { return fUserData; }
+};
+
+class MGPopupMenu : public TGPopupMenu
+{
+public:
+    MGPopupMenu(const TGWindow* p = 0, UInt_t w = 10, UInt_t h = 10, UInt_t options = 0) :
+        TGPopupMenu(p, w, h, options)
+    {
+    }
+
+    UInt_t GetKeyCode(TGMenuEntry *el);
+
+    void BindKeys(const TGWindow *w, TGMainFrame *frame);
+
+    Bool_t HandleKey(Event_t *evt);
+};
+
+class MGMenuBar : public TGMenuBar
+{
+public:
+    MGMenuBar(const TGWindow* p, UInt_t w, UInt_t h, UInt_t options = kHorizontalFrame|kRaisedFrame) :
+        TGMenuBar(p, w, h, options) {}
+
+    void BindKeys(TGMainFrame *frame);
+
+    Bool_t HandleKey(Event_t *event);
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mbase/MGTask.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MGTask.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MGTask.cc	(revision 9661)
@@ -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): 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);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+//  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
+//
+Int_t MGTask::CallPreProcess(MParList *plist)
+{
+    HideGui();
+
+    return MTask::CallPreProcess(plist);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Shows the graphical interface if existing and calls
+//  MTask::CallPostProcess
+//
+Int_t MGTask::CallPostProcess()
+{
+    ShowGui();
+
+    return MTask::CallPostProcess();
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the Widget from the MGGroupFrame (GUI) with the Id id.
+//
+TObject *MGTask::FindWidget(Int_t id) const
+{
+    return fFrame->FindWidget(id);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Process a message. Redirect gui events (eg by calling
+//  TGButton->Associate()) to the MGGroupFrame when Creating the GUI in
+//  CreateGuiElements. And process the messages in the overwritten
+//  ProcessMessage function.
+//
+Bool_t MGTask::ProcessMessage(Int_t msg, Int_t submsg, Long_t param1, Long_t param2)
+{
+    fLog->setf(ios::showbase);
+    *fLog << all << "Task " << GetDescriptor() << " received gui msg " << hex;
+    *fLog << msg << " " << submsg << " " << param1 << " " << param2 << endl;
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Show the gui (and its gui elements) of the task if existing.
+//
+void MGTask::ShowGui()
+{
+    if (fFrame)
+        fFrame->MapWindow();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Hide the gui (and its gui elements) of the task if existing.
+//
+void MGTask::HideGui()
+{
+    if (fFrame)
+        fFrame->UnmapWindow();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Check whether a gui for this task was already created.
+//  If not create a MGGroupFrame to group the gui elements and add it
+//  to the given frame with the given layout hints.
+//  Now call the overwritten function CreateGuiElements to fill the group
+//  frame.
+//
+void MGTask::CreateGui(TGCompositeFrame *f, TGLayoutHints *layout)
+{
+    //
+    // Check whether frame already exists
+    //
+    if (fFrame)
+    {
+        *fLog << warn << GetDescriptor() << " Gui already created... skipped." << endl;
+        return;
+    }
+
+    //
+    // Check whether a gui is implemented for this class
+    //  - IsA gives a pointer to the dictionary entry of the mostly
+    //    inherited class of this Task
+    //  - GetMethodAllAny checks for the existance of CreateGuiElements
+    //    in the class and all its base classes
+    //  - now get the dictionary entry of the corresponding class
+    //    (in which the mathos was found)
+    //  - if method isn't overwritten the result is the dictionary
+    //    entry for MGTask.
+    //
+    TMethod *method = IsA()->GetMethodAllAny("CreateGuiElements");
+    if (method->GetClass() == MGTask::Class())
+    {
+        *fLog << warn << "Sorry, " << GetDescriptor();
+        *fLog << " doesn't override CreateGuiElements." << endl;
+        return;
+    }
+
+    //
+    //  create group frame
+    //
+    fFrame = new MGGroupFrame(this, f, ClassName());
+    f->AddFrame(fFrame, layout);
+
+    //
+    // add gui elements
+    //
+    CreateGuiElements(fFrame);
+}
Index: /tags/Mars_V0-8-5/Mars/mbase/MGTask.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MGTask.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MGTask.h	(revision 9661)
@@ -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();
+
+    Int_t CallPreProcess(MParList *plist);
+    Int_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 having a gui
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mbase/MInputStreamID.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MInputStreamID.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MInputStreamID.cc	(revision 9661)
@@ -0,0 +1,51 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+// MInpuStreamID                                                            //
+//                                                                          //
+// This is a ID which is assigned to tasks and to a task list.              //
+// It depends on this ID whether a task is executed by the                  //
+// MTaskList::Process member funtion or not.                                //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MInputStreamID.h"
+
+ClassImp(MInputStreamID);
+
+// --------------------------------------------------------------------------
+//
+// (default) constructor
+//
+MInputStreamID::MInputStreamID(const char *name, const char *title)
+{
+    fName = name ? name : ClassName();
+    fTitle = title;
+
+    fStreamId = "All";
+}
+
Index: /tags/Mars_V0-8-5/Mars/mbase/MInputStreamID.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MInputStreamID.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MInputStreamID.h	(revision 9661)
@@ -0,0 +1,44 @@
+#ifndef MARS_MInputStreamID
+#define MARS_MInputStreamID
+
+///////////////////////////////////////////////////////////////////////
+//                                                                   //
+// MInpuStreamID                                                     //
+//                                                                   //
+// Assigns an ID to tasks or a task list                             //
+//                                                                   //
+///////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+// -----------------------------------------------------------------------
+
+class MInputStreamID : public MParContainer
+{
+private:
+    TString fStreamId;	//! which type of task should be processed?
+
+public:
+    MInputStreamID(const char *name=NULL, const char *title=NULL);
+
+    const TString &GetStreamId() const { return fStreamId; }
+    void SetStreamId(const char *t)    { fStreamId = t; }
+
+    Bool_t operator==(MInputStreamID &id) const
+    {
+        return fStreamId == id.fStreamId;
+    }
+
+    Bool_t operator!=(MInputStreamID &id) const
+    {
+        return fStreamId != id.fStreamId;
+    }
+
+    ClassDef(MInputStreamID, 0)	//Assigns an Id to tasks or a task list
+};
+
+// ---------------------------------------------------------------------
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mbase/MIter.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MIter.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MIter.cc	(revision 9661)
@@ -0,0 +1,65 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  08/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+// MIter                                                                    //
+//                                                                          //
+// This is the original MIter, but returns a MParContainer instead of a     //
+// TObject.                                                                 //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+#include "MIter.h"
+
+ClassImp(MIter);
+
+//______________________________________________________________________________
+MIter::MIter(const MIter &iter)
+{
+   // Copy a MIter. This involves allocating a new MIterator of the right
+   // sub class and assigning it with the original.
+
+   if (iter.fIterator) {
+      fIterator = iter.GetCollection()->MakeIterator();
+      fIterator->operator=(*iter.fIterator);
+   } else
+      fIterator = 0;
+}
+
+//______________________________________________________________________________
+MIter &MIter::operator=(const MIter &rhs)
+{
+   // Assigning an MIter to another. This involves allocatiing a new MIterator
+   // of the right sub class and assigning it with the original.
+
+   if (this != &rhs) {
+      if (rhs.fIterator) {
+         delete fIterator;
+         fIterator = rhs.GetCollection()->MakeIterator();
+         fIterator->operator=(*rhs.fIterator);
+      }
+   }
+   return *this;
+}
Index: /tags/Mars_V0-8-5/Mars/mbase/MIter.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MIter.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MIter.h	(revision 9661)
@@ -0,0 +1,43 @@
+#ifndef MARS_MIter
+#define MARS_MIter
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MIter                                                                   //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#ifndef MARS_MAGIC
+#include "MAGIC.h"
+#endif
+
+#ifndef ROOT_TIterator
+#include <TIterator.h>
+#endif
+
+class MParContainer;
+
+class MIter
+{
+private:
+   TIterator *fIterator;         //collection iterator
+
+protected:
+   MIter() : fIterator(0) { }
+
+public:
+   MIter(const TCollection *col, Bool_t dir = kIterForward)
+        : fIterator(col ? col->MakeIterator(dir) : 0) { }
+   MIter(TIterator *it) : fIterator(it) { }
+   MIter(const MIter &iter);
+   MIter &operator=(const MIter &rhs);
+   virtual            ~MIter() { SafeDelete(fIterator) }
+   MParContainer     *operator()() { return (MParContainer*)(fIterator ? fIterator->Next() : 0); }
+   MParContainer     *Next() { return (MParContainer*)(fIterator ? fIterator->Next() : 0); }
+   const TCollection *GetCollection() const { return fIterator ? fIterator->GetCollection() : 0; }
+   Option_t          *GetOption() const { return fIterator ? fIterator->GetOption() : ""; }
+   void               Reset() { if (fIterator) fIterator->Reset(); }
+
+   ClassDef(MIter,0)  //Iterator wrapper
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mbase/MLog.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MLog.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MLog.cc	(revision 9661)
@@ -0,0 +1,642 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// 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..
+//
+// The MLog stream has the advantage, that it can be used like the common
+// C++ streams (for example cout). It can redirect the stream to different
+// outputs (console, file, GUI) if necessary at the same time.
+//
+// It supports different debug levels. The debug level of the current
+// stream contents is set by SetDebugLevel, the output level of the
+// current stream can be set by SetOutputLevel.
+//
+// The header file MLogManip.h contains so called manipulators (like flush
+// or setw from iomanip.h) which can manipulate these levels from within
+// stream, for example:
+//    gLog << debug(3) << "Hallo World " << endl;
+// sets the debug level of the following stream to 3
+//
+// edev(), ddev() can be used to enable/disable an output device from
+// within the stream. The enumerations are defined in MLog::_flags
+//
+// Commonly used abbreviations are also defined:
+//    dbginf  Prints source file name and line number. Used for output
+//            which people may like to look up in the code
+//    all     Is streamed to the output in any case. Used for outputs
+//            which are requested by the user (eg TObject::Print)
+//    err     Should be used for fatal errors which stops the current
+//            processing, eg:
+//              gLog << err << "ERROR: TObject::Copy - Stopped" << endl;
+//    warn    Warning means an error occured, but it is not clear whether
+//            this results further procesing or not.
+//    inf     Informs the user about what's going on. Mostly usefull for
+//            debugging, but in general not necessary at all.
+//    dbg     Use this for your private purpose to mark something as debug
+//            output. This is _not_ ment to be persistent!
+//
+// If your console is capable of ANSI colors the stream is displayed
+// in several colors:
+//    all:    default
+//    err:    red
+//    warn:   yellow/brown
+//    inf:    green
+//    dbg:    blue (and all other levels)
+//
+// If you have a dark background on your console you might want to set
+// an environment variable, eg:
+//    export MARSDEFINES=-DHAVE_DARKBACKGROUND
+// and recompile MLog.
+//
+// If your console can display it also 'underline' can be used. This
+// underlines a text till the next 'endl', eg:
+//    gLog << underline << "This is important!" << endl;
+//
+// To switch off ANSI support call: SetNoColors()
+//
+// gLog is a global stream defined like cout or cerr
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MLog.h"
+
+#include <stdlib.h>     // mkstemp
+
+#include <fstream>
+#include <iomanip>
+
+#include <TROOT.h>      // gROOT->GetListOfCleanups()
+
+#ifdef _REENTRANT
+#include <TMutex.h>
+#endif
+#include <TGTextView.h>
+
+#include "MLogPlugin.h"
+#include "MParContainer.h"
+#include "MArgs.h"
+
+ClassImp(MLog);
+
+using namespace std;
+
+// root 3.02:
+// check for TObjectWarning, TObject::Info, gErrorIgnoreLevel
+
+const char MLog::kESC = '\033'; // (char)27
+const char *const MLog::kEsc       = "\033[";
+const char *const MLog::kReset     = "\033[0m";
+const char *const MLog::kRed       = "\033[31m";
+const char *const MLog::kGreen     = "\033[32m";
+#ifdef HAVE_DARKBACKGROUND
+const char *const MLog::kYellow    = "\033[33m\033[1m";
+#else
+const char *const MLog::kYellow    = "\033[33m";
+#endif
+const char *const MLog::kBlue      = "\033[34m";
+const char *const MLog::kUnderline = "\033[4m";;
+const char *const MLog::kBlink     = "\033[5m";;
+const char *const MLog::kBright    = "\033[1m";;
+const char *const MLog::kDark      = "\033[2m";;
+
+//
+// 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()
+{
+
+    //
+    // Creat drawing semaphore
+    //
+#ifdef _REENTRANT
+    fMuxGui    = new TMutex;
+    fMuxStream = new TMutex;
+#endif
+
+    fPlugins = new TList;
+    gROOT->GetListOfCleanups()->Add(fPlugins);
+    fPlugins->SetBit(kMustCleanup);
+
+    setp(&fBuffer, &fBuffer+1);
+    *this << '\0';
+}
+
+// --------------------------------------------------------------------------
+//
+// default constructor which initializes the streamer and sets the device
+// which is used for the output (i)
+//
+MLog::MLog(int i) : ostream(this), fPPtr(fBase), fEPtr(fBase+bsz), fOutputLevel(0), fDebugLevel((unsigned)-1), fDevice(i), fIsNull(kFALSE), fOut(NULL), fOutAllocated(kFALSE), fGui(NULL), fNumLines(0)
+{
+    Init();
+}
+
+// --------------------------------------------------------------------------
+//
+// default constructor which initializes the streamer and sets the given
+// ofstream as the default output device
+//
+MLog::MLog(ofstream &out) : ostream(this), fPPtr(fBase), fEPtr(fBase+bsz), fOutputLevel(0), fDebugLevel((unsigned)-1), fDevice(eFile), fIsNull(kFALSE), fOut(&out), fOutAllocated(kFALSE), fGui(NULL), fNumLines(0)
+{
+    Init();
+}
+
+// --------------------------------------------------------------------------
+//
+// default constructor which initializes the streamer and sets the given
+// TGTextView as the default output device
+//
+MLog::MLog(TGTextView &out) : ostream(this), fPPtr(fBase), fEPtr(fBase+bsz), fOutputLevel(0), fDebugLevel((unsigned)-1), fDevice(eGui), fOut(NULL), fOutAllocated(kFALSE), fGui(&out), fNumLines(0)
+{
+    Init();
+}
+
+// --------------------------------------------------------------------------
+//
+// default constructor which initializes the streamer and opens a file with
+// the given name. Dependend on the flag the file is set as output device
+// or not.
+//
+MLog::MLog(const char *fname, int flag) : ostream(this), fPPtr(fBase), fEPtr(fBase+bsz), fOutputLevel(0), fDebugLevel((unsigned)-1), fDevice(eFile), fIsNull(kFALSE), fGui(NULL), fNumLines(0)
+{
+    Init();
+
+    AllocateFile(fname);
+    CheckFlag(eFile, flag);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Destructor, destroying the gui mutex.
+//
+MLog::~MLog()
+{
+    DeallocateFile();
+
+    delete fPlugins;
+#ifdef _REENTRANT
+    delete fMuxStream;
+    delete fMuxGui;
+#endif
+}
+
+// --------------------------------------------------------------------------
+//
+// copyt constructor
+//
+/*
+MLog::MLog(MLog const& log)
+{
+//    fOutputLevel = log.fOutputLevel;
+//    fDebugLevel  = log.fDebugLevel;
+//    fDevice      = log.fDevice;
+}
+*/
+
+void MLog::Underline()
+{
+    SetBit(kIsUnderlined);
+
+    fPlugins->ForEach(MLogPlugin, Underline)();
+
+    if (TestBit(eNoColors))
+        return;
+
+    if (fDevice&eStdout)
+        cout << kUnderline;
+
+    if (fDevice&eStderr)
+        cerr << kUnderline;
+}
+
+void MLog::Output(ostream &out, int len)
+{
+    if (!TestBit(eNoColors))
+        switch (fOutputLevel)
+        {
+            // do not output reset. Otherwise we reset underline in 0-mode
+            // case 1: out << MLog::kReset; break; // all
+        case 0:  break; // all = background color
+        case 1:  out << MLog::kRed;     break;  // err
+        case 2:  out << MLog::kYellow;  break;  // warn
+        case 3:  out << MLog::kGreen;   break;  // inf
+        default: out << MLog::kBlue;    break;  // all others (dbg)
+        }
+
+    if (len>0)
+    {
+        // Check for EOL
+        const Int_t endline = fBase[len-1]=='\n' ? 1 : 0;
+        // output text to screen (without trailing '\n')
+        out << TString(fBase, len-endline);
+        // reset colors if working with colors
+        if (!TestBit(eNoColors))
+            out << kReset;
+        // output EOL of check found EOL
+        if (endline)
+        {
+            out << '\n';
+            // Check whether text was underlined
+            if (TestBit(kIsUnderlined) && TestBit(eNoColors))
+            {
+                out << setw(len-1) << setfill('-') << "" << "\n";
+                ResetBit(kIsUnderlined);
+            }
+        }
+    }
+    out.flush();
+}
+
+void MLog::AddGuiLine(const TString &line)
+{
+    // add a new TString* to the array of gui lines
+    TString **newstr = new TString*[fNumLines+1];
+    memcpy(newstr, fGuiLines, fNumLines*sizeof(TString*));
+    if (fNumLines>0)
+        delete fGuiLines;
+    fGuiLines = newstr;
+
+    // add Gui line as last line of array
+    fGuiLines[fNumLines++] = new TString(line);
+}
+
+// --------------------------------------------------------------------------
+//
+// This is the function which writes the stream physically to a device.
+// If you want to add a new device this must be done here.
+//
+void MLog::WriteBuffer()
+{
+    //
+    // restart writing to the buffer at its first char
+    //
+    const int len = fPPtr - fBase;
+
+    fPPtr = fBase;
+
+    if (fIsNull)
+        return;
+
+    if (fDevice&eStdout)
+        Output(cout, len);
+
+    if (fDevice&eStderr)
+        Output(cerr, len);
+
+    if (fDevice&eFile && fOut)
+        fOut->write(fBase, len);
+
+    fPlugins->ForEach(MLogPlugin, SetColor)(fOutputLevel);
+    fPlugins->ForEach(MLogPlugin, WriteBuffer)(fBase, len);
+
+    if (fDevice&eGui && fGui)
+    {
+        // check whether the current text was flushed or endl'ed
+        const Int_t endline = fBase[len-1]=='\n' ? 1 : 0;
+
+        // for the gui remove trailing characters ('\n' or '\0')
+        fBase[len-endline]='\0';
+
+        // add new text to line storage
+        fGuiLine += fBase;
+
+        if (endline)
+        {
+            AddGuiLine(fGuiLine);
+            fGuiLine = "";
+
+            // Check whether text should be underlined
+            if (endline && TestBit(kIsUnderlined))
+            {
+                AddGuiLine("");
+                fGuiLines[fNumLines-1]->Append('-', fGuiLines[fNumLines-2]->Length());
+                ResetBit(kIsUnderlined);
+            }
+        }
+    }
+}
+
+void MLog::UpdateGui()
+{
+    if (fNumLines==0)
+        return;
+
+    // lock mutex
+    if (!LockUpdate("UpdateGui"))
+    {
+        Warning("UpdateGui", "Execution skipped");
+        return;
+    }
+
+    TGText &txt=*fGui->GetText();
+
+    // copy lines to TGListBox
+    for (int i=0; i<fNumLines; i++)
+    {
+        // Replace all tabs by 7 white spaces
+        fGuiLines[i]->ReplaceAll("\t", "       ");
+        txt.InsText(TGLongPosition(0, txt.RowCount()), *fGuiLines[i]);
+        delete fGuiLines[i];
+    }
+    delete fGuiLines;
+
+    fNumLines=0;
+
+    // cut text box top 1000 lines
+    //    while (txt.RowCount()>1000)
+    //        txt.DelLine(1);
+
+    // show last entry
+    fGui->Layout();
+    fGui->SetVsbPosition(txt.RowCount()-1);
+
+    // tell a main loop, that list box contents have changed
+    fGui->SetBit(kHasChanged);
+
+    // release mutex
+    UnLockUpdate("UpdateGui");
+}
+
+bool MLog::LockUpdate(const char *msg)
+{
+#ifdef _REENTRANT
+    if (fMuxGui->Lock()==13)
+    {
+        Info("LockUpdate", "%s - mutex is already locked by this thread\n", msg);
+        return false;
+    }
+    return true;
+#endif
+}
+
+bool MLog::UnLockUpdate(const char *msg)
+{
+#ifdef _REENTRANT
+    if (fMuxGui->UnLock()==13)
+    {
+        Info("UnLockUpdate", "%s - tried to unlock mutex locked by other thread\n", msg);
+        return false;
+    }
+    return true;
+#endif
+}
+
+bool MLog::Lock(const char *msg)
+{
+#ifdef _REENTRANT
+    if (fMuxStream->Lock()==13)
+    {
+        Error("Lock", "%s - mutex is already locked by this thread\n", msg);
+        return false;
+    }
+//    while (fMuxStream->Lock()==13)
+//        usleep(1);
+//    {
+//        Error("Lock", "%s - mutex is already locked by this thread\n", msg);
+//        return false;
+//    }
+    return true;
+#endif
+}
+
+bool MLog::UnLock(const char *msg)
+{
+#ifdef _REENTRANT
+    if (fMuxStream->UnLock()==13)
+    {
+        Error("UnLock", "%s - tried to unlock mutex locked by other thread\n", msg);
+        return false;
+    }
+    return true;
+#endif
+}
+
+// --------------------------------------------------------------------------
+//
+// This is called to flush the buffer of the streaming devices
+//
+int MLog::sync()
+{
+    if (!LockUpdate("sync"))
+        usleep(1);
+    WriteBuffer();
+    UnLockUpdate("sync");
+
+    if (fDevice&eStdout)
+    {
+        if (!TestBit(eNoColors))
+            cout << kReset;
+        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)
+    {
+        if (!LockUpdate("overflow"))
+            usleep(1);
+
+        *fPPtr++ = (char)i;
+
+        if (fPPtr == fEPtr)
+            WriteBuffer();
+
+        UnLockUpdate("overflow");
+    }
+
+    return 0;
+}
+
+// --------------------------------------------------------------------------
+//
+// Setup MLog and global debug output from command line arguments.
+//
+//    gLog << "     -v#                              Verbosity level # [default=2]" << endl;
+//    gLog << "     -a, --no-colors                  Do not use Ansii color codes" << endl;
+//    gLog << "     --debug[=n]                      Enable root debugging (Default: gDebug=1)" << endl;
+//
+void MLog::Setup(MArgs &arg)
+{
+    if (arg.HasOnlyAndRemove("--no-colors") || arg.HasOnlyAndRemove("-a"))
+        SetNoColors();
+
+    SetDebugLevel(arg.HasOption("-v") ? arg.GetIntAndRemove("-v") : 2);
+
+    gDebug = arg.HasOption("--debug=") ? arg.GetIntAndRemove("--debug=") : 0;
+    if (gDebug==0 && arg.HasOnlyAndRemove("--debug"))
+        gDebug=1;
+}
+
+// --------------------------------------------------------------------------
+//
+// Read the setup from a TEnv:
+//   MLog.VerbosityLevel: 0, 1, 2, 3, 4
+//   MLog.DebugLevel: 0, 1, 2, 3, 4
+//   MLog.NoColors
+//
+// Depending on your setup it might be correct to use something like:
+//   Job1.MLog.VerbosityLevel: 1
+//   Job1.DebugLevel: 2
+//   Job1.MLog.NoColors
+//
+void MLog::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
+{
+    if (!prefix.IsNull())
+        prefix += ".";
+    prefix += "MLog";
+
+    MParContainer mlog("MLog");
+
+    if (mlog.IsEnvDefined(env, prefix, "VerbosityLevel", print))
+        SetDebugLevel(mlog.GetEnvValue(env, prefix, "VerbosityLevel", 2));
+
+    if (mlog.IsEnvDefined(env, prefix, "DebugLevel", print))
+        gDebug = mlog.GetEnvValue(env, prefix, "DebugLevel", 0);
+
+    if (mlog.IsEnvDefined(env, prefix, "NoColors", print))
+        if (mlog.GetEnvValue(env, prefix, "NoColors", 1)>0)
+            SetNoColors();
+}
+
+// --------------------------------------------------------------------------
+//
+// Read the setup from a TEnv:
+//   MLog.VerbosityLevel: 0, 1, 2, 3, 4
+//   MLog.DebugLevel: 0, 1, 2, 3, 4
+//   MLog.NoColors
+//
+// Depending on your setup it might be correct to use something like:
+//   Job1.MLog.VerbosityLevel: 1
+//   Job1.DebugLevel: 2
+//   Job1.MLog.NoColors
+//
+void MLog::WriteEnv(TEnv &env, TString prefix, Bool_t print) const
+{
+    if (!prefix.IsNull())
+        prefix += ".";
+    prefix += "MLog";
+
+    cout << "MLog::WriteEnv: not yet implemented!" << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Create a new instance of an file output stream
+// an set the corresponding flag
+//
+void MLog::AllocateFile(const char *fname)
+{
+    // gcc 3.2:
+    char *txt = (char*)"logXXXXXX";
+    fOut = fname ? new ofstream(fname) : new ofstream(/*mkstemp(*/txt/*)*/);
+    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);
+}
+
+// --------------------------------------------------------------------------
+//
+// Add a plugin to which the output should be redirected, eg. MLogHtml
+// The user has to take care of its deletion. If the plugin is deleted
+// (and the kMustCleanup bit was not reset accidentaly) the plugin
+// is automatically removed from the list of active plugins.
+//
+void MLog::AddPlugin(MLogPlugin *plug)
+{
+    fPlugins->Add(plug);
+    plug->SetBit(kMustCleanup);
+}
Index: /tags/Mars_V0-8-5/Mars/mbase/MLog.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MLog.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MLog.h	(revision 9661)
@@ -0,0 +1,221 @@
+#ifndef MARS_MLog
+#define MARS_MLog
+
+#ifndef ROOT_TObject
+#include <TObject.h>
+#endif
+#ifndef ROOT_TString
+#include <TString.h>
+#endif
+
+#include <iostream>  // base classes for MLog
+
+#define bsz    160 // two standard lines
+
+class MArgs;
+
+class TEnv;
+class TMutex;
+class TGTextView;
+
+class MLogPlugin;
+
+class MLog : public std::streambuf, public std::ostream, public TObject
+{
+public:
+    typedef enum _flags {
+        eStdout   = 0x001,
+        eStderr   = 0x002,
+        eFile     = 0x004,
+        eGui      = 0x008,
+        eNoColors = 0x400  //BIT(15)
+    } Flags_t;
+
+    enum ELogBits {
+        kHasChanged = BIT(14)  // if gui has changed
+    };
+
+private:
+    enum {
+        kIsUnderlined = BIT(15)
+    };
+    static const char kESC;
+    static const char *const kEsc;
+    static const char *const kReset;
+    static const char *const kRed;
+    static const char *const kGreen;
+    static const char *const kYellow;
+    static const char *const kBlue;
+    static const char *const kUnderline;
+    static const char *const kBlink;
+    static const char *const kBright;
+    static const char *const kDark;
+
+    char        fBuffer;      //!
+    char        fBase[bsz+1]; //! Buffer to store the data in
+    char       *fPPtr;        //! Pointer to present position in buffer
+    const char *fEPtr;        //! Pointer to end of buffer
+
+    UInt_t fOutputLevel;      //! Present output level of the stream
+    UInt_t fDebugLevel;       //! Present global debug level
+    UInt_t fDevice;           //! Flag to indicate the present streams
+
+    Bool_t fIsNull;           //! Switch output completely off
+
+    ofstream   *fOut;          //! possible file output stream
+    Bool_t      fOutAllocated; //! flag if fout is created by MLogging
+    TGTextView *fGui;          //! Text View output
+
+    Bool_t     fIsDirectGui;  //! Pipe text directly to the GUI (for single threaded environments)
+    TString  **fGuiLines;     //! Lines to pipe to gui
+    Int_t      fNumLines;     //!
+    TString    fGuiLine;      //!
+
+#ifdef _REENTRANT
+    TMutex *fMuxGui;          //! Mutex locking access of TGListBox
+    TMutex *fMuxStream;       //! Mutex locking access to streaming
+#endif
+
+    TList *fPlugins;
+
+    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);
+    void Output(ostream &out, int len);
+    void AddGuiLine(const TString& line);
+
+public:
+    MLog(int i=eStdout);
+    MLog(ofstream &out);
+    MLog(TGTextView &out);
+    MLog(const char *fname, int flag=-1);
+
+    MLog(MLog const& log) : ostream((std::streambuf*)&log)
+    {
+        fOutputLevel = log.fOutputLevel;
+        fDebugLevel  = log.fDebugLevel;
+        fDevice      = log.fDevice;
+    }
+    ~MLog();
+
+    bool LockUpdate(const char *msg);
+    bool UnLockUpdate(const char *msg);
+
+    bool Lock(const char *msg="");
+    bool UnLock(const char *msg="");
+
+    void EnableDirectGui()  { fIsDirectGui = kTRUE; }
+    void DisableDirectGui() { fIsDirectGui = kFALSE; }
+    void UpdateGui();
+
+    void Underline();
+
+    void SetDebugLevel(int i)           { fDebugLevel  =  i;  }
+    int  GetDebugLevel() const          { return fDebugLevel; }
+    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=(TGTextView *out)     { SetOutputGui(out);  }
+
+    Bool_t IsOutputDeviceEnabled(int i) const { return fDevice & i; }
+
+    void SetOutputGui(TGTextView *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;
+    }
+
+    // FIXME: Switch off colors when on....
+    void SetNullOutput(Bool_t n=kTRUE) { fIsNull = n; }
+
+    void SetNoColors(Bool_t flag=kTRUE) { flag ? SetBit(eNoColors) : ResetBit(eNoColors); }
+
+    void Setup(MArgs &arg);
+
+    void ReadEnv(const TEnv &env, TString prefix="", Bool_t print=kFALSE);
+    void WriteEnv(TEnv &env, TString prefix="", Bool_t print=kFALSE) const;
+
+    void Separator(TString str="", int outlvl=0)
+    {
+        if (!str.IsNull())
+        {
+            const Int_t l = (78-str.Length())/2-3;
+            str.Prepend("={ ");
+            str.Prepend('-', l);
+            str.Append(" }=");
+            str.Append('-', l);
+        }
+        if (str.Length()<78)
+            str.Append('-', 78-str.Length());
+
+        const int save = fOutputLevel;
+        SetOutputLevel(outlvl);
+        (*this) << str << std::endl;
+        fOutputLevel = save;
+    }
+
+    void AddPlugin(MLogPlugin *plug);
+
+    ClassDef(MLog, 0) // This is what we call 'The logging system'
+};
+
+//
+// This is the definition of a global output stream, which by
+// default pipes all output to the stdout
+//
+R__EXTERN MLog gLog;
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mbase/MLogHtml.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MLogHtml.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MLogHtml.cc	(revision 9661)
@@ -0,0 +1,124 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 1/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// MLogHtml
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MLogHtml.h"
+
+#include <fstream>  // ofstream
+#include <iostream> // cout
+
+#include "MTime.h"
+
+ClassImp(MLogHtml);
+
+using namespace std;
+
+MLogHtml::MLogHtml(const char *name) : fUnderline(0), fColor(-1)
+{
+    fOut = new ofstream(name);
+    if (!*fOut)
+    {
+        delete fOut;
+        fOut = NULL;
+        return;
+    }
+
+    MTime time;
+    time.Now();
+
+    *fOut << "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">" << endl;
+    *fOut << endl;
+    *fOut << "<html>" << endl;
+    *fOut << "<head>" << endl;
+    *fOut << "    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">" << endl;
+    *fOut << "    <meta name=\"Author\" content=\"Mars-MLogHtml" << MARSVER << "\">" << endl;
+    *fOut << "    <title>MARS - Logging, created " << time << "</title>" << endl;
+    *fOut << "</head>" << endl;
+    *fOut << endl;
+    *fOut << "<pre>" << endl;
+    //*fOut << "<body background=\"background.gif" text="#000000" bgcolor="#000099" link="#1122FF" vlink="#8888FF" alink="#FF0000">
+}
+
+MLogHtml::~MLogHtml()
+{
+    if (!fOut)
+        return;
+
+    *fOut << "</font>" << endl;
+    *fOut << "</pre>" << endl;
+    *fOut << endl;
+    *fOut << "</html>" << endl;
+
+    delete fOut;
+}
+
+void MLogHtml::Underline()
+{
+    *fOut << "<u>";
+    fUnderline = kTRUE;
+}
+
+void MLogHtml::SetColor(Int_t col)
+{
+    if (!fOut)
+        return;
+
+    if (fColor>0 && fColor!=col)
+        *fOut << "</font>";
+
+    if (fColor==col)
+        return;
+
+    switch (col)
+    {
+    case 0:  break;
+    case 1:  *fOut << "<font color=#aa0000>"; break;  // err
+    case 2:  *fOut << "<font color=#00aaaa>"; break;  // warn
+    case 3:  *fOut << "<font color=#00aa00>"; break;  // inf
+    default: *fOut << "<font color=#0000aa>"; break;  // all others (dbg)
+    }
+
+    fColor=col;
+}
+
+void MLogHtml::WriteBuffer(const char *str, int len)
+{
+    if (!fOut)
+    {
+        cout.write(str, len);
+        return;
+    }
+
+    fOut->write(str, len);
+    if (fUnderline)
+    {
+        *fOut << "</u>";
+        fUnderline = kFALSE;
+    }
+}
Index: /tags/Mars_V0-8-5/Mars/mbase/MLogHtml.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MLogHtml.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MLogHtml.h	(revision 9661)
@@ -0,0 +1,33 @@
+#ifndef MARS_MLogHtml
+#define MARS_MLogHtml
+
+#ifndef MARS_MLogPlugin
+#include "MLogPlugin.h"
+#endif
+
+class MLogHtml : public MLogPlugin
+{
+private:
+    ofstream *fOut;
+
+    Bool_t fUnderline;
+    Int_t  fColor;
+
+    enum { kFontOpen=BIT(15) };
+
+public:
+    MLogHtml(const char *name);
+    MLogHtml() : fOut(0)
+    {
+    }
+
+    ~MLogHtml();
+
+    void Underline();
+    void SetColor(int col);
+    void WriteBuffer(const char *str, int len);
+
+    ClassDef(MLogHtml, 0) // Logger Plugin for HTML
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mbase/MLogManip.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MLogManip.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MLogManip.cc	(revision 9661)
@@ -0,0 +1,126 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@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();
+    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;
+}
+
+ostream& underline(ostream& lout)
+{
+    //
+    // 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->Underline();
+    return lout;
+}
+*/
Index: /tags/Mars_V0-8-5/Mars/mbase/MLogManip.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MLogManip.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MLogManip.h	(revision 9661)
@@ -0,0 +1,92 @@
+#ifndef MARS_MLogManip
+#define MARS_MLogManip
+
+#include <iomanip>
+
+#include "MLog.h"
+
+// --------------------- simple manipulators -----------------------
+
+enum MLogManip {
+    underline
+};
+
+inline std::ostream &operator<<(std::ostream &lout, MLogManip u)
+{
+    MLog *log=dynamic_cast<MLog*>(lout.rdbuf());
+    if (log)
+        log->Underline();
+    return lout;
+}
+
+
+// ----------------------------- debug -----------------------------
+
+struct _Debug { int level; };
+
+const _Debug all  = { 0 }; // use this for output in any case
+const _Debug err  = { 1 }; // use this for fatal errors (red)
+const _Debug warn = { 2 }; // use this for wrnings (yellow)
+const _Debug inf  = { 3 }; // use this for informations (green)
+const _Debug dbg  = { 4 }; // use this for debug messages (blue)
+
+inline _Debug debug(int level)
+{
+    _Debug d;
+    d.level = level;
+    return d;
+}
+
+inline std::ostream &operator<<(std::ostream &lout, _Debug d)
+{
+    MLog *log=dynamic_cast<MLog*>(lout.rdbuf());
+    if (log)
+        log->SetOutputLevel(d.level);
+    return lout;
+}
+
+// ------------------------------- edev ----------------------------
+
+struct _EnableDev { MLog::_flags dev; };
+
+inline _EnableDev edev(MLog::_flags i)
+{
+    _EnableDev e;
+    e.dev = i;
+    return e;
+}
+
+inline std::ostream &operator<<(std::ostream &lout, _EnableDev e)
+{
+    MLog *log=dynamic_cast<MLog*>(lout.rdbuf());
+    if (log)
+        log->EnableOutputDevice(e.dev);
+    return lout;
+}
+
+// ------------------------------- sdev ----------------------------
+
+struct _DisableDev { MLog::_flags dev; };
+
+inline _DisableDev ddev(MLog::_flags i)
+{
+    _DisableDev d;
+    d.dev = i;
+    return d;
+}
+
+inline std::ostream &operator<<(std::ostream &lout, _DisableDev d)
+{
+    MLog *log=dynamic_cast<MLog*>(lout.rdbuf());
+    if (log)
+        log->EnableOutputDevice(d.dev);
+    return lout;
+}
+
+// ------------------------------ Macros ---------------------------
+
+#ifndef __CINT__
+#define dbginf __FILE__ << " l." << dec << __LINE__ << ": "
+#endif
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mbase/MLogPlugin.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MLogPlugin.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MLogPlugin.cc	(revision 9661)
@@ -0,0 +1,35 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 1/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// MLogPlugin
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MLogPlugin.h"
+
+ClassImp(MLogPlugin);
+
+using namespace std;
Index: /tags/Mars_V0-8-5/Mars/mbase/MLogPlugin.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MLogPlugin.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MLogPlugin.h	(revision 9661)
@@ -0,0 +1,18 @@
+#ifndef MARS_MLogPlugin
+#define MARS_MLogPlugin
+
+#ifndef ROOT_TObject
+#include <TObject.h>
+#endif
+
+class MLogPlugin : public TObject
+{
+public:
+    virtual void SetColor(int col) { }
+    virtual void Underline() { }
+    virtual void WriteBuffer(const char *str, int len) = 0;
+
+    ClassDef(MLogPlugin, 0) // Base for a logger plugin
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mbase/MLogo.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MLogo.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MLogo.cc	(revision 9661)
@@ -0,0 +1,209 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  05/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+// MLogo                                                                    //
+//                                                                          //
+// X based logo displayer. Displays a given logo after a call to Popup()    //
+// until Popdown() or the destructor is called, but for a minimum of a      //
+// given number of milliseconds.                                            //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+#ifdef HAVE_XPM
+#include "MLogo.h"
+
+#include <unistd.h>    // usleep
+#include <iostream.h>  // cout
+#include <sys/time.h>  // gettimeofday
+
+#ifndef XpmSuccess
+#define XpmSuccess       0
+#endif
+#ifndef XpmColorError
+#define XpmColorError    1
+#endif
+
+MLogo::MLogo(int millisec)
+   : fDisplay(0), fLogoWindow(0), fLogoPixmap(0), fMilliSec(millisec)
+{
+    // millisec: time of minimum stayup
+}
+
+void MLogo::Wait() const
+{
+    struct timeval tv;
+
+    gettimeofday(&tv, 0);
+
+    tv.tv_sec  -= fPopupTime.tv_sec;
+    tv.tv_usec -= fPopupTime.tv_usec;
+
+    while (tv.tv_usec < 0)
+    {
+        tv.tv_usec += 1000000;
+        tv.tv_sec--;
+    }
+
+    while (tv.tv_sec > 0)
+        tv.tv_usec += 1000000;
+
+    long sleep = fMilliSec*1000-tv.tv_usec;
+
+    if (sleep <= 0)
+        return;
+
+    usleep(sleep);
+}
+
+Pixmap MLogo::GetLogo() const
+{
+#ifdef XpmVersion
+    int depth = PlanesOfScreen(XDefaultScreenOfDisplay(fDisplay));
+
+    if (depth <= 1)
+        return 0;
+
+    XWindowAttributes win_attr;
+    XGetWindowAttributes(fDisplay, fLogoWindow, &win_attr);
+
+    XpmAttributes attr;
+    attr.valuemask = XpmVisual | XpmColormap | XpmDepth;
+    attr.visual    = win_attr.visual;
+    attr.colormap  = win_attr.colormap;
+    attr.depth     = win_attr.depth;
+
+#ifdef XpmColorKey              // Not available in XPM 3.2 and earlier
+
+    switch (depth)
+    {
+    case 0:
+        attr.valuemask &= ~XpmColorKey;
+        break;
+    case 1:
+        attr.color_key = XPM_MONO;
+        break;
+    case 2:
+        attr.color_key = XPM_GRAY;
+        break;
+    case 3:
+    case 4:
+        attr.color_key = XPM_GRAY4;
+        break;
+    default:
+        attr.color_key = XPM_COLOR;
+    }
+#endif // defined(XpmColorKey)
+
+
+    Pixmap logo;
+#ifdef USE_MAGICLOGO
+#include "../magiclogo.xpm"
+    int ret = XpmCreatePixmapFromData(fDisplay, fLogoWindow,
+                                      mag1, &logo, 0, &attr);
+#else
+#include "../marslogo.xpm"
+    int ret = XpmCreatePixmapFromData(fDisplay, fLogoWindow,
+                                      marslogo, &logo, 0, &attr);
+#endif
+    XpmFreeAttributes(&attr);
+
+    if (ret == XpmSuccess || ret == XpmColorError)
+        return logo;
+
+    if (logo)
+        XFreePixmap(fDisplay, logo);
+#endif
+    return 0;
+}
+
+void MLogo::Popup()
+{
+#ifdef XpmVersion
+    if (fLogoWindow || fLogoPixmap || fDisplay)
+#endif
+        return;
+
+    fDisplay = XOpenDisplay("");
+    if (!fDisplay)
+        return;
+
+    int screen = DefaultScreen(fDisplay);
+
+    fLogoWindow = XCreateSimpleWindow(fDisplay, DefaultRootWindow(fDisplay),
+                                      -100, -100, 50, 50, 0,
+                                      BlackPixel(fDisplay, screen),
+                                      WhitePixel(fDisplay, screen));
+    fLogoPixmap = GetLogo();
+
+    Window root;
+    int x, y;
+    unsigned int w, h, bw, depth;
+    XGetGeometry(fDisplay, fLogoPixmap,
+                 &root, &x, &y, &w, &h, &bw, &depth);
+
+    Screen *xscreen = XDefaultScreenOfDisplay(fDisplay);
+    x = (WidthOfScreen(xscreen) - w) / 2;
+    y = (HeightOfScreen(xscreen) - h) / 2;
+
+    XMoveResizeWindow(fDisplay, fLogoWindow, x, y, w, h);
+    XSync(fDisplay, False);   // make sure move & resize is done before mapping
+
+    unsigned long valmask  = CWBackPixmap | CWOverrideRedirect;
+
+    XSetWindowAttributes xswa;
+    xswa.background_pixmap = fLogoPixmap;
+    xswa.override_redirect = True;
+    XChangeWindowAttributes(fDisplay, fLogoWindow, valmask, &xswa);
+
+    XMapRaised(fDisplay, fLogoWindow);
+    XSync(fDisplay, False);
+
+    gettimeofday(&fPopupTime, 0);
+}
+
+void MLogo::Popdown()
+{
+    if (fLogoWindow && fLogoPixmap && fDisplay)
+        Wait();
+
+    if (fLogoWindow)
+    {
+        XUnmapWindow(fDisplay, fLogoWindow);
+        XDestroyWindow(fDisplay, fLogoWindow);
+        fLogoWindow = 0;
+    }
+    if (fLogoPixmap)
+    {
+        XFreePixmap(fDisplay, fLogoPixmap);
+        fLogoPixmap = 0;
+    }
+    if (fDisplay)
+    {
+        XSync(fDisplay, False);
+        XCloseDisplay(fDisplay);
+        fDisplay = 0;
+    }
+}
+#endif
Index: /tags/Mars_V0-8-5/Mars/mbase/MLogo.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MLogo.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MLogo.h	(revision 9661)
@@ -0,0 +1,37 @@
+#ifndef MARS_MLogo
+#define MARS_MLogo
+
+#ifdef HAVE_XPM
+
+#ifndef __CINT__
+
+#include <X11/Xlib.h>
+
+#include "Xpm.h"
+
+class MLogo
+{
+    Display *fDisplay;         // display handle
+    Window   fLogoWindow;      // window handle
+    Pixmap   fLogoPixmap;      // pixmap handle
+    long     fMilliSec;        // stayup time
+
+    struct timeval fPopupTime; // time of popup
+
+    void   Wait() const;
+    Pixmap GetLogo() const;
+
+public:
+    MLogo(int millisec=777);
+    ~MLogo()
+    {
+        Popdown();
+    }
+
+    void Popup();
+    void Popdown();
+};
+
+#endif // __CINT__
+#endif // HAVE_XPM
+#endif // MARS_MLogo
Index: /tags/Mars_V0-8-5/Mars/mbase/MMath.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MMath.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MMath.cc	(revision 9661)
@@ -0,0 +1,107 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  3/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MMath
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MMath.h"
+
+ClassImp(MMath);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Calculate Significance as
+// significance = (s-b)/sqrt(s+k*k*b) mit k=s/b
+//
+// s: total number of events in signal region
+// b: number of background events in signal region
+// 
+Double_t MMath::Significance(Double_t s, Double_t b)
+{
+    const Double_t k = b==0 ? 0 : s/b;
+    const Double_t f = s+k*k*b;
+
+    return f==0 ? 0 : (s-b)/TMath::Sqrt(f);
+}
+
+// --------------------------------------------------------------------------
+//
+// Symmetrized significance - this is somehow analog to
+// SignificanceLiMaSigned
+//
+// Returns Significance(s,b) if s>b otherwise -Significance(b, s);
+// 
+Double_t MMath::SignificanceSym(Double_t s, Double_t b)
+{
+    return s>b ? Significance(s, b) : -Significance(b, s);
+}
+
+// --------------------------------------------------------------------------
+//
+//  calculates the significance according to Li & Ma
+//  ApJ 272 (1983) 317, Formula 17
+//
+//  s                    // s: number of on events
+//  b                    // b: number of off events
+//  alpha = t_on/t_off;  // t: observation time
+//
+//  The significance has the same (positive!) value for s>b and b>s.
+//
+//  Returns -1 if sum<0 or alpha<0 or the argument of sqrt<0
+//  Returns  0 if s+b==0
+//
+Double_t MMath::SignificanceLiMa(Double_t s, Double_t b, Double_t alpha)
+{
+    const Double_t sum = s+b;
+
+    if (sum==0)
+        return 0;
+
+    if (sum<0 || alpha<=0)
+        return -1;
+
+    const Double_t l = s*TMath::Log(s/sum*(alpha+1)/alpha);
+    const Double_t m = b*TMath::Log(b/sum*(alpha+1)      );
+
+    return l+m<0 ? -1 : TMath::Sqrt((l+m)*2);
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculates MMath::SignificanceLiMa(s, b, alpha). Returns 0 if the
+// calculation has failed. Otherwise the Li/Ma significance which was
+// calculated. If s<b a negative value is returned.
+//
+Double_t MMath::SignificanceLiMaSigned(Double_t s, Double_t b, Double_t alpha)
+{
+    const Double_t sig = SignificanceLiMa(s, b, alpha);
+    if (sig<=0)
+        return 0;
+
+    return TMath::Sign(sig, s-b);
+}
Index: /tags/Mars_V0-8-5/Mars/mbase/MMath.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MMath.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MMath.h	(revision 9661)
@@ -0,0 +1,19 @@
+#ifndef MARS_MMath
+#define MARS_MMath
+
+#ifndef ROOT_TMath
+#include <TMath.h>
+#endif
+
+class MMath : public TMath
+{
+public:
+    static Double_t Significance(Double_t s, Double_t b);
+    static Double_t SignificanceSym(Double_t s, Double_t b);
+    static Double_t SignificanceLiMa(Double_t s, Double_t b, Double_t alpha=1);
+    static Double_t SignificanceLiMaSigned(Double_t s, Double_t b, Double_t alpha=1);
+
+    ClassDef(MMath, 0)
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mbase/MParContainer.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MParContainer.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MParContainer.cc	(revision 9661)
@@ -0,0 +1,665 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// 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 ("//!")
+//
+// MParContainer has several enhancements compared to TNamed:
+//  - GetDescriptor():        returns name and class type
+//  - GetUniqueName():        returns a unique name (used in StreamPrimitive)
+//  - SetLogStream(MLog *lg): Set a logging stream to which loggingis stored
+//  - Reset():                Reset content of class in an eventloop
+//  - IsReadyToSave():        The contents are ready to be saved to a file
+//  - IsSavedAsPrimitive():   A unique name for this instance is already
+//                            existing
+//  - SetVariables():         Can be overloaded if the containers stores
+//                            coefficients (to be used in fits)
+//  - SetDisplay():           Set a display for redirecting graphical output
+//  - GetNames():             Get Name/Title from instance and store it in
+//                            a TObjArray (used to store the names of the
+//                            conteiners in a file
+//  - SetNames():             vice versa
+//  - ReadEnv(), WriteEnv():  Function which is used for automatical setup
+//    IsEnvDefined()          from a TEnv file
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MParContainer.h"
+
+#include <ctype.h>        // isdigit
+#include <fstream>        // ofstream, AsciiWrite
+
+#include <TEnv.h>         // Env::Lookup
+#include <TClass.h>       // IsA
+#include <TObjArray.h>    // TObjArray
+#include <TBaseClass.h>   // GetClassPointer
+#include <TMethodCall.h>  // TMethodCall, AsciiWrite
+#include <TDataMember.h>  // TDataMember, AsciiWrite
+#include <TVirtualPad.h>  // gPad
+
+#include "MString.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+TList *gListOfPrimitives; // forard declaration in MParContainer.h
+
+#undef DEBUG
+//#define DEBUG
+
+ClassImp(MParContainer);
+
+using namespace std;
+
+MParContainer::MParContainer(const char *name, const char *title) :
+    fName(name), fTitle(title), fLog(&gLog), fDisplay(NULL), fReadyToSave(kFALSE)
+{
+}
+
+MParContainer::MParContainer(const TString &name, const TString &title) :
+    fName(name), fTitle(title), fLog(&gLog), fDisplay(NULL), fReadyToSave(kFALSE)
+{
+}
+
+// --------------------------------------------------------------------------
+//
+//  MParContainer copy ctor
+//
+MParContainer::MParContainer(const MParContainer &named)
+{
+    fName  = named.fName;
+    fTitle = named.fTitle;
+
+    fLog = named.fLog;
+
+    fReadyToSave = named.fReadyToSave;
+
+    fDisplay = named.fDisplay;
+}
+
+MParContainer::~MParContainer()
+{
+#ifdef DEBUG
+    *fLog << all << "Deleting " << GetDescriptor() << endl;
+#endif
+}
+
+// --------------------------------------------------------------------------
+//
+//  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)
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,04,01)
+const
+#endif
+{
+    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);
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the name of the object. If the name of the object is not the
+// class name it returns the object name and in []-brackets the class name.
+//
+const char *MParContainer::GetDescriptor() const
+{
+    //
+    // Because it returns a (const char*) we cannot return a casted
+    // local TString. The pointer would - immediatly after return -
+    // point to a random memory segment, because the TString has gone.
+    //
+    MString desc;
+    desc.Print("%s [%s]", fName.Data(), ClassName());
+    return fName==ClassName() ? ClassName() : desc.Data();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Return a unique name for this container. It is created from
+//  the container name and the unique Id. (This is mostly used
+//  in the StreamPrimitive member functions)
+//
+const TString MParContainer::GetUniqueName() const
+{
+    TString ret = ToLower(fName);
+
+    if (isdigit(ret[ret.Length()-1]))
+        ret+="_";
+
+    ret+=GetUniqueID();
+
+    return ret;
+}
+
+// --------------------------------------------------------------------------
+//
+//  List MParContainer name and title.
+//
+void MParContainer::ls(Option_t *) const
+{
+    TROOT::IndentLevel();
+    *fLog << all << GetDescriptor() << " " << GetTitle() << ": kCanDelete=";
+    *fLog << Int_t(TestBit(kCanDelete)) << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Print MParContainer name and title.
+//
+void MParContainer::Print(Option_t *) const
+{
+    *fLog << all << GetDescriptor() << " " << GetTitle() << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Change (i.e. set) the name of the MParContainer.
+//  WARNING !!
+//  If the object is a member of a THashTable, THashList container
+//  The HashTable must be Rehashed after SetName
+//  For example the list of objects in the current directory is a THashList
+//
+void MParContainer::SetName(const char *name)
+{
+    fName = name;
+    ResetBit(kIsSavedAsPrimitive);
+    if (gPad && TestBit(kMustCleanup)) gPad->Modified();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Change (i.e. set) all the MParContainer parameters (name and title).
+//  See also WARNING in SetName
+//
+void MParContainer::SetObject(const char *name, const char *title)
+{
+    fName  = name;
+    fTitle = title;
+    ResetBit(kIsSavedAsPrimitive);
+    if (gPad && TestBit(kMustCleanup)) gPad->Modified();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Change (i.e. set) the title of the MParContainer.
+//
+void MParContainer::SetTitle(const char *title)
+{
+    fTitle = title;
+    ResetBit(kIsSavedAsPrimitive);
+    if (gPad && TestBit(kMustCleanup)) gPad->Modified();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Return size of the MParContainer part of the TObject.
+//
+Int_t MParContainer::Sizeof() const
+{
+    Int_t nbytes = fName.Sizeof() + fTitle.Sizeof();
+    return nbytes;
+}
+
+// --------------------------------------------------------------------------
+//
+//  If you want to use Ascii-Input/-Output (eg. MWriteAsciiFile) of a
+//  container, overload this function.
+//
+void MParContainer::AsciiRead(ifstream &fin)
+{
+    *fLog << warn << "To use the the ascii input of " << GetName();
+    *fLog << " you have to overload " << ClassName() << "::AsciiRead." << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Write out a data member given as a TDataMember object to an output stream.
+//
+Bool_t MParContainer::WriteDataMember(ostream &out, const TDataMember *member, Double_t scale) const
+{
+    if (!member)
+        return kFALSE;
+
+    if (!member->IsPersistent() || member->Property()&kIsStatic)
+        return kFALSE;
+
+    /*const*/ TMethodCall *call = ((TDataMember*)member)->GetterMethod(); //FIXME: Root
+    if (!call)
+    {
+        *fLog << warn << "Sorry, no getter method found for " << member->GetName() << endl;
+        return kFALSE;
+    }
+
+    // For debugging: out << member->GetName() << ":";
+
+    switch (call->ReturnType())
+    {
+    case TMethodCall::kLong:
+        Long_t l;
+        call->Execute((void*)this, l); // FIXME: const, root
+        out << l << " ";
+        return kTRUE;
+
+    case TMethodCall::kDouble:
+        Double_t d;
+        call->Execute((void*)this, d); // FIXME: const, root
+        out << (scale*d) << " ";
+        return kTRUE;
+
+    default:
+    //case TMethodCall::kString:
+    //case TMethodCall::kOther:
+        /* someone may want to enhance this? */
+        return kFALSE;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+//  Write out a data member given by name to an output stream.
+//
+Bool_t MParContainer::WriteDataMember(ostream &out, const char *member, Double_t scale) const
+{
+    /*const*/ TClass *cls = IsA()->GetBaseDataMember(member);
+    if (!cls)
+        return kFALSE;
+
+    return WriteDataMember(out, cls->GetDataMember(member), scale);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Write out a data member from a given TList of TDataMembers.
+//  returns kTRUE when at least one member was successfully written
+//
+Bool_t MParContainer::WriteDataMember(ostream &out, const TList *list) const
+{
+    Bool_t rc = kFALSE;
+
+    TDataMember *data = NULL;
+
+    TIter Next(list);
+    while ((data=(TDataMember*)Next()))
+        rc |= WriteDataMember(out, data);
+
+    return rc;
+}
+
+// --------------------------------------------------------------------------
+//
+//  If you want to use Ascii-Input/-Output (eg. MWriteAsciiFile) of a
+//  container, you may overload this function. If you don't overload it
+//  the data member of a class are written to the file in the order of
+//  appearance in the class header (be more specfic: root dictionary)
+//  Only data members which are of integer (Bool_t, Int_t, ...) or
+//  floating point (Float_t, Double_t, ...) type are written.
+//  returns kTRUE when at least one member was successfully written
+//
+Bool_t MParContainer::AsciiWrite(ostream &out) const
+{
+    // *fLog << warn << "To use the the ascii output of " << GetName();
+    // *fLog << " you have to overload " << ClassName() << "::AsciiWrite." << endl;
+
+    Bool_t rc = WriteDataMember(out, IsA()->GetListOfDataMembers());
+
+    TIter NextBaseClass(IsA()->GetListOfBases());
+    TBaseClass *base;
+    while ((base = (TBaseClass*) NextBaseClass()))
+    {
+        /*const*/ TClass *cls = base->GetClassPointer();
+
+        if (!cls)
+            continue;
+
+        if (cls->GetClassVersion())
+            rc |= WriteDataMember(out, cls->GetListOfDataMembers());
+    }
+
+    return rc;
+}
+
+TMethodCall *MParContainer::GetterMethod(const char *name) const
+{
+    const TString n(name);
+    const Int_t pos1 = n.First('.');
+
+    const TString part1 = pos1<0 ? n : n(0, pos1);
+    const TString part2 = pos1<0 ? TString("") : n(pos1+1, n.Length());
+
+    TClass *cls = IsA()->GetBaseDataMember(part1);
+    if (cls)
+    {
+        TDataMember *member = cls->GetDataMember(part1);
+        if (!member)
+        {
+            *fLog << err << "Datamember '" << part1 << "' not in " << GetDescriptor() << endl;
+            return NULL;
+        }
+
+        // This handles returning references of contained objects, eg
+        // class X { TObject fO; TObject &GetO() { return fO; } };
+        if (!member->IsBasic() && !part2.IsNull())
+        {
+            cls = gROOT->GetClass(member->GetTypeName());
+            if (!cls)
+            {
+                *fLog << err << "Datamember " << part1 << " [";
+                *fLog << member->GetTypeName() << "] not in dictionary." << endl;
+                return NULL;
+            }
+            if (!cls->InheritsFrom(MParContainer::Class()))
+            {
+                *fLog << err << "Datamember " << part1 << " [";
+                *fLog << member->GetTypeName() << "] does not inherit from ";
+                *fLog << "MParContainer." << endl;
+                return NULL;
+            }
+
+            const MParContainer *sub = (MParContainer*)((ULong_t)this+member->GetOffset());
+            return sub->GetterMethod(part2);
+        }
+
+        if (member->IsaPointer())
+        {
+            *fLog << warn << "Data-member " << part1 << " is a pointer..." << endl;
+            *fLog << dbginf << "Not yet implemented!" << endl;
+            //TClass *test = gROOT->GetClass(member->GetTypeName());
+            return 0;
+        }
+
+        TMethodCall *call = member->GetterMethod();
+        if (call)
+            return call;
+    }
+
+    *fLog << warn << "No standard access for '" << part1 << "' in ";
+    *fLog << GetDescriptor() << " or one of its base classes." << endl;
+
+    TMethodCall *call = NULL;
+
+    *fLog << warn << "Trying to find MethodCall '" << ClassName();
+    *fLog << "::Get" << part1 << "' instead <LEAKS MEMORY>" << endl;
+    call = new TMethodCall(IsA(), (TString)"Get"+part1, "");
+    if (call->GetMethod())
+        return call;
+
+    delete call;
+
+    *fLog << warn << "Trying to find MethodCall '" << ClassName();
+    *fLog << "::" << part1 << "' instead <LEAKS MEMORY>" << endl;
+    call = new TMethodCall(IsA(), part1, "");
+    if (call->GetMethod())
+        return call;
+
+    delete call;
+
+    *fLog << err << "Sorry, no getter method found for " << part1 << endl;
+    return NULL;
+}
+
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
+void MParContainer::SavePrimitive(ofstream &out, Option_t *o)
+{
+    static UInt_t uid = 0;
+
+    if (IsSavedAsPrimitive())
+        return;
+
+    SetUniqueID(uid++);
+    SetBit(kIsSavedAsPrimitive);
+
+    if (gListOfPrimitives && !gListOfPrimitives->FindObject(this))
+        gListOfPrimitives->Add(this);
+
+    StreamPrimitive(out);
+}
+
+// --------------------------------------------------------------------------
+//
+// Creates the string written by SavePrimitive and returns it.
+//
+void MParContainer::StreamPrimitive(ofstream &out) const
+{
+    out << "   // Using MParContainer::StreamPrimitive" << endl;
+    out << "   " << ClassName() << " " << GetUniqueName() << "(\"";
+    out << fName << "\", \"" << fTitle << "\");" << endl;
+}
+
+void MParContainer::GetNames(TObjArray &arr) const
+{
+    arr.AddLast(new TNamed(fName, fTitle));
+}
+
+void MParContainer::SetNames(TObjArray &arr)
+{
+    TNamed *name = (TNamed*)arr.First();
+
+    fName  = name->GetName();
+    fTitle = name->GetTitle();
+
+    delete arr.Remove(name);
+    arr.Compress();
+}
+
+// --------------------------------------------------------------------------
+//
+// Creates a new instance of this class. The idea is to create a clone of
+// this class in its initial state.
+//
+MParContainer *MParContainer::New() const
+{
+    return (MParContainer*)IsA()->New();
+}
+
+// --------------------------------------------------------------------------
+//
+// Read the contents/setup of a parameter container/task from a TEnv
+// instance (steering card/setup file).
+// The key to search for in the file should be of the syntax:
+//    prefix.vname
+// While vname is a name which is specific for a single setup date
+// (variable) of this container and prefix is something like:
+//    evtloopname.name
+// While name is the name of the containers/tasks in the parlist/tasklist
+//
+// eg.  Job4.MImgCleanStd.CleaningLevel1:  3.0
+//      Job4.MImgCleanStd.CleaningLevel2:  2.5
+//
+// If this cannot be found the next step is to search for
+//      MImgCleanStd.CleaningLevel1:  3.0
+// And if this doesn't exist, too, we should search for:
+//      CleaningLevel1:  3.0
+//
+// Warning: The programmer is responsible for the names to be unique in
+//          all Mars classes.
+//
+Bool_t MParContainer::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
+{
+    if (!IsEnvDefined(env, prefix, "", print))
+        return kFALSE;
+
+    *fLog << warn << "WARNING - Resource " << prefix+fName << " found, but no " << ClassName() << "::ReadEnv." << endl;
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Write the contents/setup of a parameter container/task to a TEnv
+// instance (steering card/setup file).
+// The key to search for in the file should be of the syntax:
+//    prefix.vname
+// While vname is a name which is specific for a single setup date
+// (variable) of this container and prefix is something like:
+//    evtloopname.name
+// While name is the name of the containers/tasks in the parlist/tasklist
+//
+// eg.  Job4.MImgCleanStd.CleaningLevel1:  3.0
+//      Job4.MImgCleanStd.CleaningLevel2:  2.5
+//
+// If this cannot be found the next step is to search for
+//      MImgCleanStd.CleaningLevel1:  3.0
+// And if this doesn't exist, too, we should search for:
+//      CleaningLevel1:  3.0
+//
+// Warning: The programmer is responsible for the names to be unique in
+//          all Mars classes.
+//
+Bool_t MParContainer::WriteEnv(TEnv &env, TString prefix, Bool_t print) const
+{
+    if (!IsEnvDefined(env, prefix, "", print))
+        return kFALSE;
+
+    *fLog << warn << "WARNING - Resource " << prefix+fName << " found, but " << ClassName() << "::WriteEnv not overloaded." << endl;
+    return kTRUE;
+}
+
+Bool_t MParContainer::IsEnvDefined(const TEnv &env, TString prefix, TString postfix, Bool_t print) const
+{
+    if (!postfix.IsNull())
+        postfix.Insert(0, ".");
+
+    return IsEnvDefined(env, prefix+postfix, print);
+}
+
+Bool_t MParContainer::IsEnvDefined(const TEnv &env, TString name, Bool_t print) const
+{
+    if (print)
+        *fLog << all << GetDescriptor() << " - " << name << "... " << flush;
+
+    if (!((TEnv&)env).Defined(name))
+    {
+        if (print)
+            *fLog << "not found." << endl;
+        return kFALSE;
+    }
+
+    if (print)
+        *fLog << "found." << endl;
+
+    return kTRUE;
+}
+
+Int_t MParContainer::GetEnvValue(const TEnv &env, TString prefix, TString postfix, Int_t dflt) const
+{
+    return GetEnvValue(env, prefix+"."+postfix, dflt);
+}
+
+Double_t MParContainer::GetEnvValue(const TEnv &env, TString prefix, TString postfix, Double_t dflt) const
+{
+    return GetEnvValue(env, prefix+"."+postfix, dflt);
+}
+
+const char *MParContainer::GetEnvValue(const TEnv &env, TString prefix, TString postfix, const char *dflt) const
+{
+    return GetEnvValue(env, prefix+"."+postfix, dflt);
+}
+
+Int_t MParContainer::GetEnvValue(const TEnv &env, TString prefix, Int_t dflt) const
+{
+    return ((TEnv&)env).GetValue(prefix, dflt);
+}
+
+Double_t MParContainer::GetEnvValue(const TEnv &env, TString prefix, Double_t dflt) const
+{
+    return ((TEnv&)env).GetValue(prefix, dflt);
+}
+
+const char *MParContainer::GetEnvValue(const TEnv &env, TString prefix, const char *dflt) const
+{
+    return ((TEnv&)env).GetValue(prefix, dflt);
+}
Index: /tags/Mars_V0-8-5/Mars/mbase/MParContainer.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MParContainer.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MParContainer.h	(revision 9661)
@@ -0,0 +1,176 @@
+#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
+
+// gcc 3.2
+#include <iosfwd>
+//class ofstream;
+//class ifstream;
+
+class TEnv;
+class TArrayD;
+class TDataMember;
+class TMethodCall;
+
+class MLog;
+class MStatusDisplay;
+
+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
+
+    // This data member was added later, because for calculating the
+    // Checksum root (3.02/07) ignores ClassDef=0 all data members
+    // which are not persistent (//!) are used. To make the two
+    // class versions CheckSum-compatible (only getting rid of a
+    // warning) this member is persistent.
+    MStatusDisplay *fDisplay; //!
+
+private:
+    enum {
+        kIsSavedAsPrimitive = BIT(15)
+    };
+
+    Bool_t  fReadyToSave; // should be set to true if the contents of the container is changed somehow
+
+    // FIXME: Change to ostream!
+    virtual void StreamPrimitive(ofstream &out) const;
+
+public:
+    enum {
+        kEnableGraphicalOutput = BIT(16)
+    };
+
+    MParContainer(const char *name="", const char *title="");
+    MParContainer(const TString &name, const TString &title);
+    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)
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,04,01)
+const
+#endif
+        ;
+    virtual void        FillBuffer(char *&buffer);
+
+    virtual const char   *GetDescriptor() const;
+    virtual const TString GetUniqueName() const;
+    virtual const char   *GetName() const       { return fName.Data(); }
+    virtual const char   *GetTitle() const      { return fTitle.Data(); }
+    virtual ULong_t       Hash() const          { return fName.Hash(); }
+    virtual Bool_t        IsSortable() const    { return kTRUE; }
+
+    virtual void   SetName(const char *name); // *MENU*
+    virtual void   SetObject(const char *name, const char *title);
+    virtual void   SetTitle(const char *title=""); // *MENU*
+    virtual void   ls(Option_t *option="") const;
+    virtual void   Print(Option_t *option="") const;
+    virtual Int_t  Sizeof() const;
+    virtual void   SavePrimitive(ofstream &out, Option_t *o="");
+
+    virtual MParContainer *New() const;
+    virtual void   SetLogStream(MLog *lg) { fLog = lg; }
+    virtual void   Reset() { }
+    virtual Bool_t IsReadyToSave() const             { return fReadyToSave; }
+    virtual void   SetReadyToSave(Bool_t flag=kTRUE) { fReadyToSave=flag; }
+    virtual Bool_t IsSavedAsPrimitive() const        { return TestBit(kIsSavedAsPrimitive); }
+    virtual void   EnableGraphicalOutput(Bool_t flag=kTRUE) { flag ? SetBit(kEnableGraphicalOutput) : ResetBit(kEnableGraphicalOutput);}
+    virtual Bool_t IsGraphicalOutputEnabled() const  { return TestBit(kEnableGraphicalOutput); }
+    virtual void   SetVariables(const TArrayD &)     { AbstractMethod("SetVariables(const TArrayD&)"); }
+
+    virtual void SetDisplay(MStatusDisplay *d) { fDisplay = d; }
+
+    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;
+
+    Int_t Read(const char *name=NULL) { return TObject::Read(name?name:(const char*)fName); }
+
+    virtual void GetNames(TObjArray &arr) const;
+    virtual void SetNames(TObjArray &arr);
+
+    virtual Bool_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
+    virtual Bool_t WriteEnv(TEnv &env, TString prefix, Bool_t print=kFALSE) const;
+
+    Bool_t ReadEnv(const TEnv &env, Bool_t print=kFALSE) { return ReadEnv(env, "", print); }
+    Bool_t WriteEnv(TEnv &env, Bool_t print=kFALSE) const { return WriteEnv(env, "", print); }
+
+    Bool_t IsEnvDefined(const TEnv &env, TString prefix, TString postfix, Bool_t print) const;
+    Bool_t IsEnvDefined(const TEnv &env, TString name, Bool_t print) const;
+
+    Int_t       GetEnvValue(const TEnv &env, TString prefix, TString postfix, Int_t dflt) const;
+    Double_t    GetEnvValue(const TEnv &env, TString prefix, TString postfix, Double_t dflt) const;
+    const char *GetEnvValue(const TEnv &env, TString prefix, TString postfix, const char *dflt) const;
+
+    Int_t       GetEnvValue(const TEnv &env, TString prefix, Int_t dflt) const;
+    Double_t    GetEnvValue(const TEnv &env, TString prefix, Double_t dflt) const;
+    const char *GetEnvValue(const TEnv &env, TString prefix, const char *dflt) const;
+
+    ClassDef(MParContainer, 0)  //The basis for all parameter containers
+};
+
+//!
+//! Maybe we can add a static parameter list to MEvtLoop
+//! Also we can derive MEvtLoop from MTaskList to have a static tasklist, too
+//!
+
+// FIXME: Move as (persistent) static data member to MParContainer
+R__EXTERN TList *gListOfPrimitives; // instantiation in MEvtLoop
+
+/*
+class MParContainer : public TNamed
+{
+protected:
+    MLog    *fLog;         //! The general log facility for this object, initialized with the global object
+
+private:
+    Bool_t   fReadyToSave; //! should be set to true if the contents of the container is changed somehow
+
+public:
+    MParContainer(const char *name="", const char *title="") : TNamed(name, title), fLog(&gLog), fReadyToSave(kFALSE) { }
+    MParContainer(const TString &name, const TString &title) : TNamed(name, title), fLog(&gLog), fReadyToSave(kFALSE) { }
+
+    void SetLogStream(MLog *lg)                      { fLog = lg; }
+
+    virtual void   Reset()                           {  }
+
+    virtual Bool_t IsReadyToSave()                   { return fReadyToSave; }
+    virtual void   SetReadyToSave(Bool_t flag=kTRUE) { fReadyToSave=flag; }
+
+    virtual void AsciiRead(ifstream &fin);
+    virtual void AsciiWrite(ofstream &fout) const;
+
+    ClassDef(MParContainer, 0)  //The basis for all parameter containers
+};
+*/
+#endif
+
+
Index: /tags/Mars_V0-8-5/Mars/mbase/MParList.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MParList.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MParList.cc	(revision 9661)
@@ -0,0 +1,937 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MParList                                                                //
+//                                                                         //
+// This class contains a list of different parameter containers.           //
+//                                                                         //
+// A parameter container is an object which is derived from                //
+// MParContainer.                                                          //
+//                                                                         //
+// Normally a parameter container is used for data exchange between two    //
+// tasks at runtime.                                                       //
+//                                                                         //
+// You can add every parameter container (Named object) to the             //
+// instance and access it from somewhere else via its Name.                //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MParList.h"
+
+#include <fstream>     // ofstream, SavePrimitive
+
+#include <TNamed.h>
+#include <TClass.h>
+#include <TOrdCollection.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MIter.h"
+
+ClassImp(MParList);
+
+using namespace std;
+
+static const TString gsDefName  = "MParList";
+static const TString gsDefTitle = "A list of Parameter Containers";
+
+// --------------------------------------------------------------------------
+//
+//  default constructor
+//  creates an empty list
+//
+MParList::MParList(const char *name, const char *title)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+
+    //
+    // This sets a flag that the list is the owner, which means
+    // that the destructor of the list deletes all it's objects
+    //
+    fContainer  = new TOrdCollection;
+    fAutodelete = new TOrdCollection;
+
+    gROOT->GetListOfCleanups()->Add(fContainer);
+    gROOT->GetListOfCleanups()->Add(fAutodelete);
+    fContainer->SetBit(kMustCleanup);
+    fAutodelete->SetBit(kMustCleanup);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Copy constructor. It copies all entries of the parameter list, but it
+//  takes care of, that the automatically created entries are only deleted
+//  once. (doesn't copy the list which holds the automatically created
+//  entries)
+//
+MParList::MParList(MParList &ts)
+{
+    fContainer->AddAll(ts.fContainer);
+}
+
+// --------------------------------------------------------------------------
+//
+//  If the 'IsOwner' bit is set (via SetOwner()) all containers are deleted
+//  by the destructor
+//
+MParList::~MParList()
+{
+    //
+    // Case:
+    //  1) MParList is owner of the containers:
+    //     All container are stored in fContainer, and become deleted by
+    //     'delete fContainer'. Some of these containers, which were
+    //     created automatically are stored in fAutodelete, too. To prevent
+    //     double deletion this containers are not deleted by the destructor
+    //     of fAutodelete.
+    //  2) MParList is not owner of the containers:
+    //     The containers which were Added by AddToList are not touched.
+    //     Only the containers which were created automatically are also
+    //     automatically deleted.
+    //
+    IsOwner() ? fContainer->SetOwner() : fAutodelete->SetOwner();
+
+    TIter Next(fContainer);
+    TObject *o;
+    while ((o=Next()))
+        if (o->TestBit(kCanDelete))
+            delete fContainer->Remove(o);
+
+    // FIXME? If fContainer is owner do we have to remove the object
+    //   from fAutodelete due to the acces when checking for a
+    //   garbage collection?
+
+    delete fContainer;
+    delete fAutodelete;
+}
+
+// --------------------------------------------------------------------------
+//
+//  If the 'IsOwner' bit is set (via SetOwner()) all containers are deleted
+//  by the destructor
+//
+void MParList::SetOwner(Bool_t enable)
+{
+    enable ? SetBit(kIsOwner) : ResetBit(kIsOwner);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Set the logging streamer of the parameter list and all contained
+//  parameter containers
+//
+void MParList::SetLogStream(MLog *log)
+{
+    fContainer->ForEach(MParContainer, SetLogStream)(log);
+    MParContainer::SetLogStream(log);
+}
+
+void MParList::SetDisplay(MStatusDisplay *d)
+{
+    fContainer->ForEach(MParContainer, SetDisplay)(d);
+    MParContainer::SetDisplay(d);
+}
+
+// --------------------------------------------------------------------------
+//
+//  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;
+
+    cont->SetBit(kMustCleanup);
+    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;
+
+    MIter Next(list);
+
+    MParContainer *cont = NULL;
+    while ((cont=Next()))
+    {
+        cont->SetBit(kMustCleanup);
+        AddToList(cont);
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+//  Find an object with the same name in the list and replace it with
+//  the new one. If the kIsOwner flag is set and the object was not
+//  created automatically, the object is deleted.
+//
+Bool_t MParList::Replace(MParContainer *cont)
+{
+    //
+    //  check if the object (you want to add) exists
+    //
+    if (!cont)
+        return kFALSE;
+
+    TObject *obj = FindObject(cont->GetName());
+    if (!obj)
+    {
+        *fLog << warn << "No object with the same name '";
+        *fLog << cont->GetName() << "' in list... adding." << endl;
+        return AddToList(cont);
+    }
+
+    fContainer->Remove(obj);
+
+    if (IsOwner() && !fAutodelete->FindObject(obj))
+        delete obj;
+
+    *fLog << inf << "MParContainer '" << cont->GetName() << "' found and replaced..." << endl;
+
+    return AddToList(cont);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Find an object with the same name in the list and remove it.
+//  If the kIsOwner flag is set and the object was not created
+//  automatically, the object is deleted.
+//
+void MParList::Remove(MParContainer *cont)
+{
+    //
+    //  check if the object (you want to add) exists
+    //
+    if (!cont)
+        return;
+
+    TObject *obj = fContainer->Remove(cont);
+    if (!obj)
+    {
+        *fLog << warn << "Object not found in list..." << endl;
+        return;
+    }
+
+    *fLog << inf << "MParContainer '" << cont->GetName() << "' removed..." << endl;
+
+    if (IsOwner() && !fAutodelete->FindObject(obj))
+        delete obj;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Find an object in the list.
+//  'name' is the name of the object you are searching for.
+//
+TObject *MParList::FindObject(const char *name) const
+{
+    return fContainer->FindObject(name);
+}
+
+// --------------------------------------------------------------------------
+//
+//  check if the object is in the list or not
+//
+TObject *MParList::FindObject(const TObject *obj) const
+{
+    return fContainer->FindObject(obj);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Find an object in the list and check for the correct inheritance.
+//  'name' is the name of the object you are searching for.
+//
+// In words: Find object name and check whether it inherits from classname
+//
+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.")
+//
+// In words: Create object of type classname and set its name to objname.
+//           If an object with objname already exists return it.
+//
+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);
+    Int_t rc = 0;
+    if (!cls)
+        rc =1;
+    else
+    {
+        if (!cls->Property())
+            rc = 5;
+        if (!cls->Size())
+            rc = 4;
+        if (!cls->IsLoaded())
+            rc = 3;
+        if (!cls->HasDefaultConstructor())
+            rc = 2;
+    }
+
+    if (rc)
+    {
+        *fLog << err << dbginf << "Cannot create new instance of class '" << cname << "': ";
+        switch (rc)
+        {
+        case 1:
+            *fLog << "gROOT->GetClass() returned NULL." << endl;
+            return NULL;
+        case 2:
+            *fLog << "no default constructor." << endl;
+            return NULL;
+        case 3:
+            *fLog << "not loaded." << endl;
+            return NULL;
+        case 4:
+            *fLog << "zero size." << endl;
+            return NULL;
+        case 5:
+            *fLog << "no property." << endl;
+            return NULL;
+        }
+    }
+
+    //
+    // create the parameter container of the the given class type
+    //
+    pcont = (MParContainer*)cls->New();
+    if (!pcont)
+    {
+        *fLog << " - Class has no default constructor." << endl;
+        *fLog << " - An abstract member functions of a base class is not overwritten." << 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 << underline << GetDescriptor() << ":" << endl;
+
+    MParContainer *obj = NULL;
+    MIter Next(fContainer);
+    while ((obj=Next()))
+    {
+        *fLog << " " << obj->GetDescriptor();
+        if (fAutodelete->FindObject(obj))
+            *fLog << " <autodel>";
+        *fLog << endl;
+    }
+    *fLog << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+//   Sets the flags off all containers in the list (and the list
+//   itself) to unchanged
+//
+void MParList::SetReadyToSave(Bool_t flag)
+{
+    fContainer->ForEach(MParContainer, SetReadyToSave)(flag);
+    MParContainer::SetReadyToSave(flag);
+}
+
+// --------------------------------------------------------------------------
+//
+//   Reset all containers in the list
+//
+void MParList::Reset()
+{
+    fContainer->ForEach(MParContainer, Reset)();
+}
+
+// --------------------------------------------------------------------------
+//
+//  This finds numbered objects. The objects are returned in a copy of a
+//  TObjArray.
+//
+//  If from only is given (or to=0) object are assumed numbered
+//  from 1 to from.
+//
+TObjArray MParList::FindObjectList(const char *name, UInt_t first, const UInt_t last) const
+{
+    TObjArray list;
+
+    if (first>0 && last<first)
+    {
+        *fLog << err << dbginf << "Cannot create entries backwards (last<first)...skipped." << endl;
+        return list;
+    }
+
+    const UInt_t len = strlen(name);
+
+    char *auxname = new char[len+7];
+    strcpy(auxname, name);
+
+    if (first==0 && last!=0)
+        first = 1;
+
+    //
+    // If only 'from' is specified the number of entries are ment
+    //
+    for (UInt_t i=first; i<=last; i++)
+    {
+        if (first!=0 || last!=0)
+            sprintf(auxname+len, ";%d", i);
+
+        TObject *obj = FindObject(auxname);
+        if (!obj)
+            continue;
+
+        list.AddLast(obj);
+    }
+    delete auxname;
+
+    return list;
+}
+
+// --------------------------------------------------------------------------
+//
+//  This finds numbered objects. The objects are returned in a copy of a
+//  TObjArray. If one of the objects doesn't exist it is created from the
+//  meaning of cname and oname (s. FindCreateObj)
+//
+//  If from only is given (or to=0) object are assumed numbered
+//  from 1 to from.
+//
+TObjArray MParList::FindCreateObjList(const char *cname, UInt_t first, const UInt_t last, const char *oname)
+{
+    TObjArray list;
+
+    if (first>0 && last<first)
+    {
+        *fLog << err << dbginf << "Cannot create entries backwards (last<first)...skipped." << endl;
+        return list;
+    }
+
+    const UInt_t len = strlen(cname);
+
+    char *auxname = new char[len+7];
+    strcpy(auxname, cname);
+
+    //
+    // If only 'from' is specified the number of entries are ment
+    //
+    if (first==0 && last!=0)
+        first = 1;
+
+    for (UInt_t i=first; i<=last; i++)
+    {
+        if (first!=0 || last!=0)
+            sprintf(auxname+len, ";%d", i);
+
+        TObject *obj = FindCreateObj(auxname, oname);
+        if (!obj)
+            break;
+
+        list.AddLast(obj);
+    }
+    delete auxname;
+
+    return list;
+}
+
+// --------------------------------------------------------------------------
+//
+//  This finds numbered objects. The objects are returned in a copy of a
+//  TObjArray. If one of the objects doesn't exist it is created from the
+//  meaning of cname and oname (s. FindCreateObj)
+//
+//  If from only is given (or to=0) object are assumed numbered
+//  from 1 to from.
+//
+//  Remark: Because it is static the object are only created and not added to
+//  the parameter list. You must also take care of deleting these objects!
+//  This function is mainly made for use in root macros. Don't use it in
+//  compiled programs if you are not 100% sure what you are doing.
+//
+TObjArray MParList::CreateObjList(const char *cname, UInt_t first, const UInt_t last, const char *oname)
+{
+    TObjArray list;
+
+    if (first>0 && last<first)
+    {
+        gLog << err << dbginf << "Cannot create entries backwards (last<first)...skipped." << endl;
+        return list;
+    }
+
+    //
+    // try to get class from root environment
+    //
+    TClass *cls = gROOT->GetClass(cname);
+    if (!cls)
+    {
+        //
+        // if class is not existing in the root environment
+        //
+        gLog << dbginf << "Class '" << cname << "' not existing in dictionary." << endl;
+        return list;
+    }
+
+    const UInt_t len = strlen(cname);
+
+    char *auxname = new char[len+7];
+    strcpy(auxname, cname);
+
+    //
+    // If only 'from' is specified the number of entries are ment
+    //
+    if (first==0 && last!=0)
+        first = 1;
+
+    for (UInt_t i=first; i<=last; i++)
+    {
+        if (first!=0 || last!=0)
+            sprintf(auxname+len, ";%d", i);
+
+        //
+        // create the parameter container of the the given class type
+        //
+        MParContainer *pcont = (MParContainer*)cls->New();
+        if (!pcont)
+        {
+            gLog << err << dbginf << "Cannot create new instance of class '" << cname << "' (Maybe no def. constructor)" << endl;
+            return list;
+        }
+
+        //
+        // Set the name of the container
+        //
+        pcont->SetName(auxname);
+
+        //
+        // Add new object to the return list
+        //
+        list.AddLast(pcont);
+    }
+    delete auxname;
+
+    return list;
+}
+
+void MParList::SavePrimitive(ofstream &out, Option_t *o)
+{
+    Bool_t saved = IsSavedAsPrimitive();
+
+    MParContainer::SavePrimitive(out);
+
+    MIter Next(fContainer);
+
+    MParContainer *cont = NULL;
+    while ((cont=Next()))
+    {
+        //
+        // Because it was automatically created don't store its primitive
+        // I guess it will be automatically created again
+        //
+        if (fAutodelete->FindObject(cont) || cont->IsSavedAsPrimitive())
+            continue;
+
+        cont->SavePrimitive(out, "");
+
+        out << "   " << GetUniqueName() << ".";
+        out << (cont->InheritsFrom("MTaskList") && saved ? "Replace" : "AddToList");
+        out << "(&" << cont->GetUniqueName() << ");" << endl << endl;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
+void MParList::StreamPrimitive(ofstream &out) const
+{
+    out << "   MParList " << GetUniqueName();
+    if (fName!=gsDefName || fTitle!=gsDefTitle)
+    {
+        out << "(\"" << fName << "\"";
+        if (fTitle!=gsDefTitle)
+            out << ", \"" << fTitle << "\"";
+        out <<")";
+    }
+    out << ";" << endl << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Adds one TNamed object per object in the list. The TNamed object must
+// be deleted by the user.
+//
+void MParList::GetNames(TObjArray &arr) const
+{
+    MParContainer::GetNames(arr);
+    fContainer->ForEach(MParContainer, GetNames)(arr);
+}
+
+// --------------------------------------------------------------------------
+//
+// Sets name and title of each object in the list from the objects in
+// the array.
+//
+void MParList::SetNames(TObjArray &arr)
+{
+    MParContainer::SetNames(arr);
+    fContainer->ForEach(MParContainer, SetNames)(arr);
+}
+
+// --------------------------------------------------------------------------
+//
+// Read the contents/setup of a parameter container/task from a TEnv
+// instance (steering card/setup file).
+// The key to search for in the file should be of the syntax:
+//    prefix.vname
+// While vname is a name which is specific for a single setup date
+// (variable) of this container and prefix is something like:
+//    evtloopname.name
+// While name is the name of the containers/tasks in the parlist/tasklist
+//
+// eg.  Job4.MImgCleanStd.CleaningLevel1:  3.0
+//      Job4.MImgCleanStd.CleaningLevel2:  2.5
+//
+// If this cannot be found the next step is to search for
+//      MImgCleanStd.CleaningLevel1:  3.0
+// And if this doesn't exist, too, we search for:
+//      CleaningLevel1:  3.0
+//
+// Warning: The programmer is responsible for the names to be unique in
+//          all Mars classes.
+//
+Bool_t MParList::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
+{
+    if (print)
+        *fLog << all << "MParList::ReadEnv: " << prefix << " (" << (int)print << ")" << endl;
+
+    MParContainer *cont = NULL;
+
+    MIter Next(fContainer);
+    while ((cont=Next()))
+    {
+        if (cont->InheritsFrom("MTaskList"))
+        {
+            if (cont->ReadEnv(env, prefix, print)==kERROR)
+                return kERROR;
+            continue;
+        }
+
+        // Check For: Job4.ContainerName.Varname
+        if (print)
+            *fLog << all << "Testing: " << prefix+cont->GetName() << endl;
+        Bool_t rc = cont->ReadEnv(env, prefix+cont->GetName(), print);
+        if (rc==kERROR)
+            return kERROR;
+        if (rc==kTRUE)
+            continue;
+
+        // Check For: Job4.MClassName.Varname
+        if (print)
+            *fLog << all << "Testing: " << prefix+cont->ClassName() << endl;
+        rc = cont->ReadEnv(env, prefix+cont->ClassName(), print);
+        if (rc==kERROR)
+            return kERROR;
+        if (rc==kTRUE)
+            continue;
+
+        // Check For: ContainerName.Varname
+        if (print)
+            *fLog << all << "Testing: " << cont->GetName() << endl;
+        rc = cont->ReadEnv(env, cont->GetName(), print);
+        if (rc==kERROR)
+            return kERROR;
+        if (rc==kTRUE)
+            continue;
+
+        // Check For: MClassName.Varname
+        if (print)
+            *fLog << all << "Testing: " << cont->ClassName() << endl;
+        rc = cont->ReadEnv(env, cont->ClassName(), print);
+        if (rc==kERROR)
+            return kERROR;
+        if (rc==kTRUE)
+            continue;
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Write the contents/setup of a parameter container/task to a TEnv
+// instance (steering card/setup file).
+// The key to search for in the file should be of the syntax:
+//    prefix.vname
+// While vname is a name which is specific for a single setup date
+// (variable) of this container and prefix is something like:
+//    evtloopname.name
+// While name is the name of the containers/tasks in the parlist/tasklist
+//
+// eg.  Job4.MImgCleanStd.CleaningLevel1:  3.0
+//      Job4.MImgCleanStd.CleaningLevel2:  2.5
+//
+// If this cannot be found the next step is to search for
+//      MImgCleanStd.CleaningLevel1:  3.0
+// And if this doesn't exist, too, we search for:
+//      CleaningLevel1:  3.0
+//
+// Warning: The programmer is responsible for the names to be unique in
+//          all Mars classes.
+//
+Bool_t MParList::WriteEnv(TEnv &env, TString prefix, Bool_t print) const
+{
+    MParContainer *cont = NULL;
+
+    MIter Next(fContainer);
+    while ((cont=Next()))
+        if (!cont->WriteEnv(env, prefix, print))
+            return kFALSE;
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mbase/MParList.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MParList.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MParList.h	(revision 9661)
@@ -0,0 +1,99 @@
+#ifndef MARS_MParList
+#define MARS_MParList
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MParList                                                                //
+//                                                                         //
+// List of parameter containers (MParContainer)                            //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef ROOT_TObjArray
+#include <TObjArray.h>
+#endif
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class TClass;
+class TOrdCollection;
+
+class MLog;
+
+class MParList : public MParContainer
+{
+private:
+    TOrdCollection *fContainer;	 // Collection of Parameter and Data Containers
+    TOrdCollection *fAutodelete; //! All what this list contains is deleted in the destructor
+
+    static TString GetClassName(const char *classname);
+    static TString GetObjectName(const char *classname, const char *objname);
+
+    enum { kIsOwner = BIT(14) };
+
+    void StreamPrimitive(ofstream &out) const;
+
+public:
+    enum { kDoNotReset = BIT(17), kIsProcessing = BIT(18) };
+
+    MParList(const char *name=NULL, const char *title=NULL);
+    MParList(MParList &ts);
+
+    virtual ~MParList();
+
+    Bool_t AddToList(MParContainer *obj, MParContainer *where = NULL);
+    void   AddToList(TObjArray *list);
+
+    Bool_t Replace(MParContainer *obj);
+    void   Remove(MParContainer *obj);
+
+    void SetLogStream(MLog *log);
+    void SetDisplay(MStatusDisplay *d);
+
+    TObject *FindObject(const char *name) const;
+    TObject *FindObject(const TObject *obj) const;
+
+    TObject *FindObject(const char *name, const char *classname) const;
+    TObject *FindObject(const TObject *obj, const char *classname) const;
+
+    MParContainer *FindCreateObj(const char *classname, const char *objname=NULL);
+
+    TObjArray FindObjectList(const char *name, UInt_t first, const UInt_t last) const;
+    TObjArray FindObjectList(const char *name, const UInt_t num) const
+    {
+        return FindObjectList(name, 0, num);
+    }
+
+    TObjArray FindCreateObjList(const char *cname, UInt_t first, const UInt_t last, const char *oname=NULL);
+    TObjArray FindCreateObjList(const char *cname, const UInt_t num, const char *oname=NULL)
+    {
+        return FindCreateObjList(cname, 0, num, oname);
+    }
+
+    static TObjArray CreateObjList(const char *cname, UInt_t first, const UInt_t last, const char *oname=NULL);
+    static TObjArray CreateObjList(const char *cname, const UInt_t num, const char *oname=NULL)
+    {
+        return CreateObjList(cname, 0, num, oname);
+    }
+
+    void Reset();
+    void SetReadyToSave(Bool_t flag=kTRUE);
+
+    void SetOwner(Bool_t enable=kTRUE);
+    Bool_t IsOwner() const { return TestBit(kIsOwner); }
+
+    void Print(Option_t *t = NULL) const;
+
+    void GetNames(TObjArray &arr) const;
+    void SetNames(TObjArray &arr);
+
+    void SavePrimitive(ofstream &out, Option_t *o="");
+
+    Bool_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
+    Bool_t WriteEnv(TEnv &env, TString prefix, Bool_t print=kFALSE) const;
+
+    ClassDef(MParList, 1) // list of parameter containers (MParContainer)
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mbase/MPrint.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MPrint.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MPrint.cc	(revision 9661)
@@ -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  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);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// 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;
+}
+
+MPrint::MPrint()
+{
+    Init(0, 0);
+    SetBit(kSeperator);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Constructor. Remembers the name to search for in the parameter list
+//  of the object to be printed. The object must be derived from TObject and
+//  TObject::Print(Option_t *) const
+//  must be overloaded. You can also set an option string to use
+//  when calling TObject::Print
+//  If you want that the MPrint instance is removed from the tasklist
+//  if the container to be printed is not found in the PreProcess, call:
+//     MPrint::EnableSkip();
+//
+MPrint::MPrint(const char *obj, const char *option,
+               const char *name, const char *title)
+{
+    Init(name, title);
+    SetOption(option);
+
+    fObjName = obj;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Constructor. Remember the pointer of the object which has to be
+//  printed. The object must be derived from TObject and
+//  TObject::Print(Option_t *) const
+//  must be overloaded. You can also set an option string to use
+//  when calling TObject::Print
+//  if the container to be printed is not found in the PreProcess, call:
+//     MPrint::EnableSkip();
+//
+MPrint::MPrint(const TObject *obj, const char *option,
+               const char* name, const char *title)
+{
+    Init(name, title);
+    SetOption(option);
+
+    fObject  = obj;
+    fObjName = obj->GetName();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Checks the parameter list for the existance of the parameter container. If
+//  the name of it was given in the constructor.
+//
+Int_t MPrint::PreProcess(MParList *pList)
+{
+    //
+    // The pointer is already given by the user.
+    //
+    if (fObject || TestBit(kSeperator))
+        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
+    //
+    if (TestBit(kSkip))
+    {
+        *fLog << warn << fObjName << " not found... removing task from list." << endl;
+        return kSKIP;
+    }
+    else
+    {
+        *fLog << err << fObjName << " not found... aborting." << endl;
+        return kFALSE;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+//  Calls overloaded TObject::Print
+//
+Int_t MPrint::Process()
+{
+    if (TestBit(kSeperator))
+        gLog << endl << setfill('-') << setw(72) << "-" << endl << endl;
+    else
+        fObject->Print(fOption);
+    return kTRUE;
+} 
+
Index: /tags/Mars_V0-8-5/Mars/mbase/MPrint.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MPrint.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MPrint.h	(revision 9661)
@@ -0,0 +1,36 @@
+#ifndef MARS_MPrint
+#define MARS_MPrint
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MParList;
+
+class MPrint : public MTask
+{
+private:
+    const TObject *fObject;  // pointer to container which has to be printed
+    TString fObjName;        // given name to search for in the parameterlist
+    TString fOption;         // Print option
+
+    enum { kSkip = BIT(14), kSeperator = BIT(15) };
+
+    void Init(const char *name, const char *title);
+
+public:
+    MPrint();
+    MPrint(const char *obj,    const char *option="", const char *name=NULL, const char *title=NULL);
+    MPrint(const TObject *obj, const char *option="", const char *name=NULL, const char *title=NULL);
+
+    void SetOption(Option_t *option) { fOption = option; }
+    void EnableSkip(Bool_t skip=kTRUE) { skip ? SetBit(kSkip) : ResetBit(kSkip); }
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
+    ClassDef(MPrint, 0) // Task to call Print() function
+};
+    
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mbase/MProgressBar.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MProgressBar.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MProgressBar.cc	(revision 9661)
@@ -0,0 +1,90 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 9/2002 <mailto:tbretz@astro-uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MProgressBar
+//
+// Simple window with progress bar. Can be used in an eventloop.
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MProgressBar.h"
+
+#include <TSystem.h>        // gSystem
+#include <TGProgressBar.h>  // TGHProgressBar
+
+#include "MGList.h"
+
+ClassImp(MProgressBar);
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. Opens a window with a progress bar. Get a pointer
+// to the bar by calling GetBar. This pointer can be used for the
+// eventloop.
+//
+// Be carefull: killing or closing the window while the progress meter
+//   is still in use may cause segmentation faults. Please kill the window
+//   always by deleting the corresponding object.
+//
+MProgressBar::MProgressBar() : TGTransientFrame(gClient->GetRoot(), gClient->GetRoot(), 1, 1)
+{
+    fList = new MGList;
+    fList->SetOwner();
+
+    //SetMWMHints(0, 0, 0);
+
+    SetWMSizeHints(150, 15, 640, 480, 10, 10); // set the smallest and biggest size of the Main frame
+    Move(rand()%100+50, rand()%100+50);
+    Resize(150, 30);
+
+    TGLayoutHints *laybar=new TGLayoutHints(kLHintsExpandX|kLHintsExpandY, 2,2,2,2);
+    fList->Add(laybar);
+
+    fBar=new TGHProgressBar(this);
+    fBar->ShowPosition();
+    AddFrame(fBar, laybar);
+    fList->Add(fBar);
+
+    Layout();
+
+    MapSubwindows();
+
+    SetWindowName("Progress");
+    SetIconName("Progress");
+
+    MapWindow();
+}
+
+// --------------------------------------------------------------------------
+//
+// Destruct the window with all its tiles. Also the Progress Bar object
+// is deleted.
+//
+MProgressBar::~MProgressBar()
+{
+    delete fList;
+} 
+
Index: /tags/Mars_V0-8-5/Mars/mbase/MProgressBar.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MProgressBar.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MProgressBar.h	(revision 9661)
@@ -0,0 +1,33 @@
+#ifndef MARS_MProgressBar
+#define MARS_MProgressBar
+
+#ifndef MARS_MAGIC
+#include "MAGIC.h"
+#endif
+
+#ifndef ROOT_TGFrame
+#include <TGFrame.h>
+#endif
+
+class MGList;
+class TGProgressBar;
+class TGHProgressBar;
+
+class MProgressBar : public TGTransientFrame
+{
+private:
+    MGList         *fList;
+    TGHProgressBar *fBar;
+
+public:
+     MProgressBar();
+     virtual ~MProgressBar();
+
+     TGProgressBar *GetBar() const { return (TGProgressBar*)fBar; }
+
+     ClassDef(MProgressBar, 0)   // A simple progress bar window for the Eventloop
+};
+
+#endif
+
+
Index: /tags/Mars_V0-8-5/Mars/mbase/MReadSocket.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MReadSocket.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MReadSocket.cc	(revision 9661)
@@ -0,0 +1,314 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni.wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// MReadSocket
+//
+// This class acts like a standard C++ istream, but read from a socket
+// (ifstream works similar)
+//
+// ios::io_state:
+// --------------
+// eof()  or ios::eofbit:  Connection closed or not established
+// fail() or ios::failbit: Error trying to establish connection or
+//                         waiting for data in underflow() timed out
+// good() tells you that everything is ok and we can read from the stream
+//
+// Example:
+// --------
+//
+//    Double_t d;
+//
+//    MReadSocket sin(1024); // open port 1024
+//
+//    sin >> d;
+//    sin.read((char*)&d, sizeof(Double_t));
+//
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MReadSocket.h"
+
+#include <unistd.h>          // usleep
+
+#include <TMath.h>           // TMath::Min
+#include <TTime.h>           // TTime
+#include <TDatime.h>         // TDatime
+#include <TSystem.h>         // gSystem
+#include <TSocket.h>         // TSocket
+#include <TServerSocket.h>   // TServerSocket
+
+ClassImp(MReadSocket);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// You can use the constructor in two ways:
+//
+//    MReadSocket read(7000);
+// This opens the socket and blocks until the connection has been
+// established.
+//
+//    MReadSocket read;
+// Returns immidiatly. The connection will be opend by calling
+//    read.Open(7000);
+//
+MReadSocket::MReadSocket(int port, int mtu) : istream(this), fMtu(mtu), fTimeout(2500), fServSock(NULL), fRxSocket(NULL)
+{
+    fBuffer = new char[mtu];
+
+    setg(fBuffer, fBuffer, fBuffer+1);
+
+    clear(ios::eofbit);
+
+    if (port>0)
+        Open(port);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Destructor. Close an possible open connection and delete the fBuffer
+//
+MReadSocket::~MReadSocket()
+{
+    Close();
+    delete fBuffer;
+}
+
+void MReadSocket::OpenServerSocket(int port)
+{
+    if (fServSock)
+        return;
+
+    cout << "Starting server socket on port #" << port << "..." << endl;
+
+    while (!fServSock)
+    {
+        fServSock=new TServerSocket(port, kTRUE);
+        if (fServSock->IsValid())
+            continue;
+
+        cout << "ServerSocket not valid: ";
+        switch (fServSock->GetErrorCode())
+        {
+        case  0: cout << "No error." << endl; break;
+        case -1: cout << "low level socket() call failed." << endl; break;
+        case -2: cout << "low level bind() call failed." << endl; break;
+        case -3: cout << "low level listen() call failed." << endl; break;
+        default: cout << "Unknown." << endl; break;
+        }
+
+        Close();
+        clear(ios::failbit);
+        return;
+    }
+
+    fServSock->SetOption(kNoBlock, 1);
+}
+
+void MReadSocket::OpenConnection(Bool_t block)
+{
+    do
+    {
+        const TTime timeout = gSystem->Now() + TTime(5000);
+
+        TDatime now;
+        cout << now.AsString() << ": Waiting for connection..." << endl;
+
+        //
+        // fRxSocket<0  means: No connection,non-blocking mode
+        // fRxSocket==0 means: Error
+        // This is only done until timeout is reached
+        //
+        while (fRxSocket==0 && gSystem->Now()<timeout)
+        {
+            fRxSocket = fServSock->Accept();
+            if (fRxSocket==0)
+            {
+                cout << "MReadSocket::OpenConnection: ERROR - TServerSock::Accept()" << endl;
+                setstate(ios::failbit);
+                return;
+            }
+            if ((Long_t)fRxSocket<0)
+                fRxSocket=NULL;
+
+            usleep(10);
+        }
+
+        //
+        // No connection has been established. Restart waiting for
+        // connection except we are in non-blocking mode.
+        //
+        if (fRxSocket==0)
+            continue;
+
+        //
+        // Check if the established connection is valid
+        //
+        if (fRxSocket->IsValid())
+        {
+            cout << "Connection established..." << endl;
+            fRxSocket->SetOption(kNoBlock, 1);
+            clear();
+            return;
+        }
+
+        cout << "TSocket: Connection not valid..." << endl;
+        delete fRxSocket;
+        fRxSocket=NULL;
+        setstate(ios::failbit);
+        return;
+
+    } while (block);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Open the connectionj on port port. Wait until the connection has
+//  been established. If an error occures and the connection cannot
+//  be established return kFALSE. To check whether an error occured
+//  use operator!() or operator void*() or fail()
+//
+Bool_t MReadSocket::Open(int port, Bool_t block)
+{
+    //
+    // If no port is given use the port given in the constructor
+    //
+    if (port<=0)
+        port = fPort;
+
+    //
+    // Remember port for later uses
+    //
+    if (fPort<=0)
+        fPort = port;
+
+    //
+    // Check whether a connection has already been established
+    //
+    if (fServSock)
+    {
+        //
+        // Check whether the connection has the right port
+        //
+        if (fServSock->GetLocalPort()!=port)
+            Close();
+    }
+
+    //
+    // Check whether port is valid
+    //
+    if (port<=0)
+    {
+        cout << "Invalid port #" << port << "!" << endl;
+        clear(ios::failbit);
+        return kFALSE;
+    }
+
+    //
+    // Start server socket...
+    //
+    OpenServerSocket(port);
+    if (!fServSock)
+        return kFALSE;
+
+    OpenConnection(block);
+    if (!fRxSocket)
+        return kFALSE;
+
+    underflow();
+    return kTRUE;
+}
+
+void MReadSocket::Close()
+{
+    if (fRxSocket)
+    {
+        delete fRxSocket;
+        fRxSocket=NULL;
+    }
+    if (fServSock)
+    {
+        const Int_t port = fServSock->GetLocalPort();
+
+        delete fServSock;
+        fServSock=NULL;
+
+        cout << "Connection on Port #" << port << " closed." << endl;
+    }
+
+    clear(ios::eofbit);
+}
+
+// --------------------------------------------------------------------------
+//
+// This is called to flush the buffer of the streaming devices
+//
+int MReadSocket::sync()
+{
+    cout << "sync" << endl;
+    return 0;
+}
+
+int MReadSocket::underflow()
+{
+    // FIXME:     vvvvv is this correct?
+    if (fail() || eof())
+    {
+        setg(fBuffer, fBuffer, fBuffer+fMtu);
+        return 0;
+    }
+
+    //
+    // This simple trick should do its job, because the
+    // TCP/IP stream is buffered already
+    //
+    const TTime timeout = fTimeout+gSystem->Now();
+
+    Int_t len=-1;
+    while (len<0 && gSystem->Now()<timeout)
+    {
+        Int_t l;
+        fRxSocket->GetOption(kBytesToRead, l);
+        if (l==0)
+        {
+            gSystem->Sleep(1);
+            continue;
+        }
+        len = fRxSocket->RecvRaw(fBuffer, TMath::Min(fMtu, l));
+    }
+
+    if (len<0)
+    {
+        cout << "MReadSocket: TSocket::RecvRaw - Connection timed out." << endl;
+        setstate(ios::failbit);
+        memset(fBuffer, 0, fMtu);
+        len = fMtu;
+    }
+
+    setg(fBuffer, fBuffer, fBuffer+len);
+    return 0;
+}
Index: /tags/Mars_V0-8-5/Mars/mbase/MReadSocket.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MReadSocket.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MReadSocket.h	(revision 9661)
@@ -0,0 +1,49 @@
+#ifndef MARS_MReadSocket
+#define MARS_MReadSocket
+
+#ifndef ROOT_TROOT
+#include <TROOT.h>
+#endif
+#ifndef ROOT_TTime
+#include <TTime.h>
+#endif
+
+#include <iostream>  // base classes for MReadSocket
+
+class TSocket;
+class TServerSocket;
+
+class MReadSocket : public std::streambuf, public std::istream
+{
+private:
+    char *fBuffer; //!
+
+    int   fPort;
+    int   fMtu;
+    TTime fTimeout;
+
+    TServerSocket  *fServSock;
+    TSocket        *fRxSocket;
+
+    void OpenServerSocket(int port);
+    void OpenConnection(Bool_t block);
+
+    int underflow();
+    int sync();
+
+public:
+    MReadSocket(int port=-1, int mtu=1500);
+    MReadSocket(MReadSocket const& log) : istream((std::streambuf*)&log)
+    {
+    }
+    ~MReadSocket();
+
+    Bool_t Open(int port=-1, Bool_t block=kFALSE);
+    void   Close();
+
+    void SetTimeout(UInt_t millisec) { fTimeout = millisec; }
+
+    ClassDef(MReadSocket, 0) // This is what we call 'The logging system'
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mbase/MRunIter.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MRunIter.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MRunIter.cc	(revision 9661)
@@ -0,0 +1,129 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 1/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Javier Rico,  4/2004 <mailto:jrico@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MRunIter
+//
+//  Use this to iterate over run-files giving only the run-number.
+//
+//  You need the specify the run-file root-directory (eg /data/MAGIC).
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MRunIter.h"
+
+#include <TSystem.h>
+#include <iostream>
+
+ClassImp(MRunIter);
+
+using namespace std;
+
+Int_t MRunIter::AddRun(UInt_t run, const char *path)
+{
+    TString p(path);
+
+    if (p.IsNull())
+        p = fPath;
+
+    if (p.IsNull())
+        p = ".";
+
+    MDirIter Next(p, Form("*_%05d_*_%s", run,fIsRawFile?"*.raw":"*.root"), -1);
+
+    const TString name(Next());
+    if (name.IsNull())
+        return 0;
+
+    AddRunNumber(run);
+
+    return AddDirectory(gSystem->DirName(name), gSystem->BaseName(name), -1);
+}
+
+// --------------------------------------------------------------------------
+//
+// Add runs specified in a character chain with the format:
+// run1,run2-run3,run4-run5,...
+// e.g  if runrange="100,105-107,110-112,115" 
+// runs 100,105,106,107,110,111,112 and 115 are included in the iterator list
+//
+Int_t MRunIter::AddRuns(const char* runrange, const char* path)
+{ 
+    const TString chcopy(runrange);
+  
+    Ssiz_t last=0;
+    Int_t  lowrun=-1;
+    UInt_t totdir=0;
+  
+    // loop over the elements of the character chain 
+    for (Int_t i=0;i<chcopy.Length();i++)
+    {
+        // look for a digit, a '-' or a ',' 
+        const char c=chcopy[i];
+        if (! ((c>='0' && c<='9') || c=='-' || c==','))
+            return totdir;
+        
+        // if '-' is found, save the previous number as initial run
+        if (c=='-' && lowrun<0 && i>last)
+        {
+            const TSubString chrun = chcopy(last,i-last);
+            lowrun=atoi(chrun.Data());	  	  
+            last=i+1;
+            continue;
+        }
+        // if ',' or the end of the string are found, save the previous run or run range
+        if (c==',' && i>last)
+        {
+            const TSubString chrun = chcopy(last,i-last);
+            const Int_t up=atoi(chrun.Data());
+            if(lowrun>=0 && lowrun<=up)
+                totdir+=AddRuns(lowrun,up,path);
+            else if(lowrun<0)
+                totdir+=AddRun(up,path);
+            
+            lowrun=-1;
+            last=i+1;
+            continue;
+        }
+  
+        // if find two continous separators exit
+        if ((c=='-' && i==last) || (c==',' && i==last))
+            return totdir;
+    }
+  
+    // save last run range
+    const TSubString chrun = chcopy(last,chcopy.Length()-last);
+    const Int_t upprun=atoi(chrun.Data());
+    if(lowrun>=0 && lowrun<=upprun)
+    {
+        totdir+=AddRuns(lowrun,upprun,path);
+        return totdir;
+    }
+  
+    if(lowrun<0)
+        totdir+=AddRun(upprun,path);
+  
+    return totdir;
+}
Index: /tags/Mars_V0-8-5/Mars/mbase/MRunIter.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MRunIter.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MRunIter.h	(revision 9661)
@@ -0,0 +1,87 @@
+#ifndef MARS_MRunIter
+#define MARS_MRunIter
+
+#ifndef MARS_MDirIter
+#include "MDirIter.h"
+#endif
+
+#ifndef ROOT_TArrayI
+#include <TArrayI.h>
+#endif
+
+class MRunIter : public MDirIter
+{
+private:
+    TString fPath;
+    TArrayI fRuns;
+
+    Bool_t fIsRawFile;
+
+    void AddRunNumber(UInt_t run)
+    {
+        fRuns.Set(fRuns.GetSize()+1);
+        fRuns[fRuns.GetSize()-1] = run;
+
+        Sort();
+
+    }
+
+    void Sort()
+    {
+        const int n = GetNumRuns();
+
+        TArrayI idx(n);
+        TMath::Sort(n, fRuns.GetArray(), idx.GetArray(), kFALSE);
+
+        for (int i=0; i<n; i++)
+            idx[i] = fRuns[idx[i]];
+
+        fRuns = idx;
+    }
+
+public:
+    MRunIter(const char *path=0) : fPath(path), fIsRawFile(0) { }
+
+    void SetRawFile(Bool_t filetype) { fIsRawFile = filetype; }
+
+    Int_t AddRun(UInt_t run, const char *path=0);
+    Int_t AddRuns(const char* runrange, const char *path=0);
+    Int_t AddRuns(UInt_t from, UInt_t to, const char *path=0)
+    {
+        Int_t n = 0;
+
+        for (UInt_t i=from; i<=to; i++)
+            AddRun(i, path);
+
+        return n;
+    }
+
+    UInt_t GetNumRuns() const { return fRuns.GetSize(); }
+    const TArrayI &GetRuns() const { return fRuns; }
+
+    TString GetRunsAsString() const {
+        TString txt;
+        for (int i=0; i<fRuns.GetSize(); i++)
+        {
+            txt += "#";
+            txt += fRuns[i];
+            if (i!=fRuns.GetSize()-1)
+                txt += " ";
+        }
+        return txt;
+    }
+    TString GetRunsAsFileName() const {
+        TString txt;
+        for (int i=0; i<fRuns.GetSize(); i++)
+        {
+            txt += fRuns[i];
+            if (i!=fRuns.GetSize()-1)
+                txt += "_";
+        }
+        return txt;
+    }
+
+    ClassDef(MRunIter, 1) // Iterator for runs
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mbase/MSearch.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MSearch.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MSearch.cc	(revision 9661)
@@ -0,0 +1,210 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 9/2002 <mailto:tbretz@astro-uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MSearch
+//
+// Simple search dialog (usefull for TGTextViews)
+//
+// Sends: kC_USER, KS_START, mp1, txt
+//
+//   with mp1: bit0 on=case sensitive
+//             bit1 on=backward
+//        mp2: char* pointing to the text to search for
+//
+// WARNING: Do not store mp2, immeditaly copy the text to a local
+//          location!
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MSearch.h"
+
+#include <TSystem.h>      // gSystem
+#include <TGLabel.h>      // TGLabel
+#include <TGButton.h>     // TGButton
+#include <TGTextEntry.h>  // TGTextEntry
+
+#include "MGList.h"
+
+ClassImp(MSearch);
+
+enum
+{
+    kSearchText, kCase, kDirection, kSearch, kCancel
+};
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. w is the window which will receive the message.
+// Id is currently useless.
+//
+MSearch::MSearch(const TGWindow *w, Int_t id) : TGTransientFrame(gClient->GetRoot(), gClient->GetRoot(), 1, 1), TGWidget(id)
+{
+    Associate(w);
+
+    fList = new MGList;
+    fList->SetOwner();
+
+    // set the smallest and biggest size of the Main frame
+    SetWMSizeHints(320, 110, 250, 50, 0, 0);
+    Move(rand()%100+50, rand()%100+50);
+
+    // -------------------------------------------------------------
+
+    TGLayoutHints *lay4=new TGLayoutHints(kLHintsNormal|kLHintsExpandX);
+    TGLayoutHints *lay0=new TGLayoutHints(kLHintsNormal|kLHintsExpandX, 4, 8, 4);
+    TGLayoutHints *lay1=new TGLayoutHints(kLHintsNormal,  6, 4, 8);
+    TGLayoutHints *lay2=new TGLayoutHints(kLHintsNormal, 69, 4, 4, 4);
+    TGLayoutHints *lay3=new TGLayoutHints(kLHintsNormal, 69, 4, 4, 4);
+    TGLayoutHints *lay5=new TGLayoutHints(kLHintsNormal,  5, 5, 5);
+    TGLayoutHints *lay7=new TGLayoutHints(kLHintsCenterX);
+
+    // -------------------------------------------------------------
+    //  Create Widgets
+    // -------------------------------------------------------------
+
+    TGHorizontalFrame  *f = new TGHorizontalFrame(this, 1, 1);
+    TGLabel        *label = new TGLabel(this, "Find Text:");
+    TGTextEntry    *entry = new TGTextEntry(f, "", kSearchText);
+    TGCheckButton   *box1 = new TGCheckButton(this, "Match upper/lower case", kCase);
+    TGCheckButton   *box2 = new TGCheckButton(this, "Search backward", kDirection);
+    TGHorizontalFrame *f2 = new TGHorizontalFrame(this, 1, 1);
+    TGHorizontalFrame *f3 = new TGHorizontalFrame(f2, 1, 1);
+    TGTextButton    *txt1 = new TGTextButton(f3, "Search", kSearch);
+    TGTextButton    *txt2 = new TGTextButton(f3, "Cancel", kCancel);
+
+    txt1->Associate(this);
+    txt2->Associate(this);
+
+    // -------------------------------------------------------------
+    //  Layout the widgets in the frame
+    // -------------------------------------------------------------
+
+    AddFrame(f, lay4);
+    f->AddFrame(label, lay1);
+    f->AddFrame(entry, lay0);
+    AddFrame(box1, lay2);
+    AddFrame(box2, lay3);
+    AddFrame(f2, lay4);
+    f2->AddFrame(f3, lay7);
+    f3->AddFrame(txt1, lay5);
+    f3->AddFrame(txt2, lay5);
+
+    // -------------------------------------------------------------
+
+    entry->Associate(this);
+    txt1->Associate(this);
+    txt1->Associate(this);
+
+    // -------------------------------------------------------------
+
+    fList->Add(lay0);
+    fList->Add(lay1);
+    fList->Add(lay2);
+    fList->Add(lay3);
+    fList->Add(lay4);
+    fList->Add(lay5);
+    fList->Add(lay7);
+    fList->Add(f);
+    fList->Add(f2);
+    fList->Add(f3);
+    fList->Add(label);
+    fList->Add(entry);
+    fList->Add(box1);
+    fList->Add(box2);
+    fList->Add(txt1);
+    fList->Add(txt2);
+
+    // -------------------------------------------------------------
+
+    Layout();
+
+    MapSubwindows();
+
+    SetWindowName("Search in Text");
+    SetIconName("Search");
+
+    MapWindow();
+}
+
+// --------------------------------------------------------------------------
+//
+// Destruct the window with all its tiles and widgets.
+//
+MSearch::~MSearch()
+{
+    delete fList;
+}
+
+// --------------------------------------------------------------------------
+//
+// Send the search message to the associated TGWindow.
+// See class description.
+//
+Bool_t MSearch::SendSearch()
+{
+    if (!fMsgWindow)
+        return kTRUE;
+
+    const TGCheckButton &b1 = *(TGCheckButton*)fList->FindWidget(kCase);
+    const TGCheckButton &b2 = *(TGCheckButton*)fList->FindWidget(kDirection);
+    const TGTextEntry   &e  = *(TGTextEntry*)  fList->FindWidget(kSearchText);
+
+    const Long_t msg = MK_MSG(kC_USER, (EWidgetMessageTypes)kS_START);
+    const Long_t mp1 = (b1.GetState()<<1) | b2.GetState();
+    const Long_t mp2 = (Long_t)e.GetText();
+
+    SendMessage(fMsgWindow, msg, mp1, mp2);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Process messages from the widgets.
+//
+Bool_t MSearch::ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2)
+{
+    // Can be found in WidgetMessageTypes.h
+    switch (GET_MSG(msg))
+    {
+    case kC_COMMAND:
+        switch (GET_SUBMSG(msg))
+        {
+        case kCM_BUTTON:
+            switch (mp1)
+            {
+            case kSearch:
+                return SendSearch();
+            case kCancel:
+                delete this;
+                return kTRUE;
+            }
+            return kTRUE;
+
+        }
+        return kTRUE;
+    }
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mbase/MSearch.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MSearch.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MSearch.h	(revision 9661)
@@ -0,0 +1,41 @@
+#ifndef MARS_MSearch
+#define MARS_MSearch
+
+#ifndef MARS_MAGIC
+#include "MAGIC.h"
+#endif
+
+#ifndef ROOT_TGFrame
+#include <TGFrame.h>
+#endif
+
+#ifndef ROOT_TGWidget
+#include <TGWidget.h>
+#endif
+
+enum EMarsWidgetMessageTypes {
+    kS_START = 1
+};
+
+class MGList;
+
+class MSearch : public TGTransientFrame, public TGWidget
+{
+private:
+    MGList *fList;
+
+    Bool_t SendSearch();
+    void CloseWindow() { delete this; }
+
+public:
+    MSearch(const TGWindow *w, Int_t id=-1);
+    virtual ~MSearch();
+
+    Bool_t ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2);
+
+    ClassDef(MSearch, 0)   // A simple progress bar window for the Eventloop
+};
+
+#endif
+
+
Index: /tags/Mars_V0-8-5/Mars/mbase/MStatusArray.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MStatusArray.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MStatusArray.cc	(revision 9661)
@@ -0,0 +1,57 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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 03/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MStatusArray
+//
+//  Helper class for MStatusDisplay
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MStatusArray.h"
+
+#include "MStatusDisplay.h"
+
+ClassImp(MStatusArray);
+
+using namespace std;
+
+TObject *MStatusArray::DisplayIn(Option_t *o) const
+{
+    MStatusDisplay *d = 0;
+    if (TString(o).IsNull())
+        d = new MStatusDisplay;
+
+    if (!d)
+        d = (MStatusDisplay*)gROOT->GetListOfSpecials()->FindObject(o);
+
+    if (!d)
+        return 0;
+
+    if (d->Display(*this))
+        return d;
+
+    delete d;
+    return 0;
+}
Index: /tags/Mars_V0-8-5/Mars/mbase/MStatusArray.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MStatusArray.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MStatusArray.h	(revision 9661)
@@ -0,0 +1,17 @@
+#ifndef MARS_MStatusArray
+#define MARS_MStatusArray
+
+#ifndef ROOT_TObjArray
+#include <TObjArray.h>
+#endif
+
+class MStatusArray : public TObjArray
+{
+public:
+    TObject *DisplayIn(Option_t *o=0) const;         // *MENU*
+    TObject *Display() const { return DisplayIn(); } // *MENU*
+
+    ClassDef(MStatusArray, 0) // Helper class for status display
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mbase/MStatusDisplay.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MStatusDisplay.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MStatusDisplay.cc	(revision 9661)
@@ -0,0 +1,2427 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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, 4/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2003-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MStatusDisplay
+//
+// This status display can be used (and is used) to display results in
+// a tabbed window. The window can be written to and read from a root file
+// (see Read and Write) or printed as a postscript file (see SaveAsPS).
+//
+// To write gif files of C-Macros use SaveAsGif() or SaveAsC().
+// Direct printing to the default printer (via lpr) can be done by
+// PrintToLpr().
+//
+// It has also to half status lines which can be used to display the status
+// or something going on. Together with the status lines it has a progress
+// bar which can display the progress of a job or loop.
+// Access the progress bar by GetProgressBar()
+//
+// To add a new tab and get a pointer to the newly created TCanvas
+// use AddTab.
+//
+// If you have a MStatusDisplay and you are not sure whether it was
+// destroyed by the user meanwhile use:
+//   gROOT->GetListOfSpecials()->FindObject(pointer);
+// Each MStatusDisplay is added to list list by its constructor and
+// removed from the list by the destructor.
+//
+// You can redirect an output to a MLog-logstream by calling SetLogStream().
+// To disable redirction call SetLogStream(NULL)
+//
+// Because updates to the tabs are only done/displayed if a tab is active
+// using the gui doesn't make things slower (<1%) if the first (legend
+// tab) is displayed. This gives you the possibility to look into
+// the current progress of a loop without loosing more time than the
+// single update of the tab.
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MStatusDisplay.h"
+
+#include <fstream>                // fstream
+
+#include <TLine.h>                // TLine
+#include <TText.h>                // TText
+#include <TFile.h>                // gFile
+#include <TFrame.h>               // TFrame
+#include <TStyle.h>               // gStyle
+#include <TCanvas.h>              // TCanvas
+#include <TSystem.h>              // gSystem
+#include <TDatime.h>              // TDatime
+#include <TRandom.h>              // TRandom
+#include <TThread.h>              // TThread::Self()
+#include <TBrowser.h>             // TBrowser
+#include <TObjArray.h>            // TObjArray
+#include <TPostScript.h>          // TPostScript
+#include <TMethodCall.h>          // TMethodCall
+
+//#include <TRint.h>                // gApplication, TRint::Class()
+#include <TInterpreter.h>         // gInterpreter
+
+#include <TGTab.h>                // TGTab
+#include <TGLabel.h>              // TGLabel
+#include <TG3DLine.h>             // TGHorizontal3DLine
+#include <TGButton.h>             // TGPictureButton
+#include <TGTextView.h>           // TGTextView
+#include <TGComboBox.h>           // TGComboBox
+#include <TGStatusBar.h>          // TGStatusBar
+#include <TGFileDialog.h>         // TGFileDialog
+#include <TGProgressBar.h>        // TGHProgressBar
+#include <TRootEmbeddedCanvas.h>  // TRootEmbeddedCanvas
+
+#include "MLog.h"                 // MLog
+#include "MLogManip.h"            // inf, warn, err
+
+#include "MGList.h"               // MGList
+#include "MGMenu.h"               // MGMenu, TGMenu
+#include "MSearch.h"              // MSearch
+#include "MParContainer.h"        // MParContainer::GetDescriptor
+#include "MStatusArray.h"         // MStatusArray
+
+#undef DEBUG
+//#define DEBUG
+
+ClassImp(MStatusDisplay);
+
+using namespace std;
+
+// ------------ Workaround for a non working TGTextView::Search -------------
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,02,05)
+class MGTextView : public TGTextView
+{
+public:
+    MGTextView(const TGWindow *parent, UInt_t w, UInt_t h, Int_t id = -1,
+               UInt_t sboptions = 0, ULong_t back = GetWhitePixel()) :
+    TGTextView(parent, w, h, id, sboptions, back) {}
+    MGTextView(const TGWindow *parent, UInt_t w, UInt_t h, TGText *text,
+               Int_t id = -1, UInt_t sboptions = 0, ULong_t back = GetWhitePixel()) :
+    TGTextView(parent, w, h, text, id, sboptions, back) {}
+    MGTextView(const TGWindow *parent, UInt_t w, UInt_t h, const char *string,
+               Int_t id = -1, UInt_t sboptions = 0, ULong_t back = GetWhitePixel()) :
+    TGTextView(parent, w, h, string, id, sboptions, back) {}
+
+    void Mark(Long_t xPos, Long_t yPos) { TGTextView::Mark(xPos, yPos); }
+    void UnMark()                       { TGTextView::UnMark(); }
+
+    Bool_t Search(const char *string, Bool_t direction, Bool_t caseSensitive)
+    {
+        // Taken from TGTextView::Search and modified.
+
+        TGLongPosition pos, pos2;
+        pos2.fX = pos2.fY = 0;
+        if (fIsMarked) {
+            if (!direction)
+            {
+                pos2.fX = fMarkedStart.fX;
+                pos2.fY = fMarkedStart.fY;
+            }
+            else
+            {
+                pos2.fX = fMarkedEnd.fX + 1;
+                pos2.fY = fMarkedEnd.fY;
+            }
+        }
+        if (!fText->Search(&pos, pos2, string, direction, caseSensitive))
+            return kFALSE;
+        UnMark();
+        fIsMarked = kTRUE;
+        fMarkedStart.fY = fMarkedEnd.fY = pos.fY;
+        fMarkedStart.fX = pos.fX;
+        fMarkedEnd.fX = fMarkedStart.fX + strlen(string);
+        pos.fY = ToObjYCoord(fVisible.fY);
+        if ((fMarkedStart.fY < pos.fY) ||
+            (ToScrYCoord(fMarkedStart.fY) >= (Int_t)fCanvas->GetHeight()))
+            pos.fY = fMarkedStart.fY;
+        pos.fX = ToObjXCoord(fVisible.fX, pos.fY);
+        if ((fMarkedStart.fX < pos.fX) ||
+            (ToScrXCoord(fMarkedStart.fX, pos.fY) >= (Int_t)fCanvas->GetWidth()))
+            pos.fX = fMarkedStart.fX;
+
+        SetVsbPosition((ToScrYCoord(pos.fY) + fVisible.fY)/fScrollVal.fY);
+        SetHsbPosition((ToScrXCoord(pos.fX, pos.fY) + fVisible.fX)/fScrollVal.fX);
+        DrawRegion(0, (Int_t)ToScrYCoord(fMarkedStart.fY), fCanvas->GetWidth(),
+                   UInt_t(ToScrYCoord(fMarkedEnd.fY+1) - ToScrYCoord(fMarkedEnd.fY)));
+
+        return kTRUE;
+    }
+};
+#else
+#define MGTextView TGTextView
+#endif
+
+// --------------------------------------------------------------------------
+
+// --------------------------------------------------------------------------
+//
+// Add menu bar to the GUI
+//
+void MStatusDisplay::AddMenuBar()
+{
+    //
+    // File Menu
+    //
+    MGPopupMenu *filemenu = new MGPopupMenu(gClient->GetRoot());
+    // filemenu->AddEntry("Save &As...", kFileSaveAs);
+    filemenu->AddEntry("New Can&vas",   kFileCanvas);
+    filemenu->AddEntry("New &Browser",  kFileBrowser);
+    filemenu->AddSeparator();
+    filemenu->AddEntry("Save As status.&ps",   kFileSaveAsPS);
+    filemenu->AddEntry("Save As status.&gif",  kFileSaveAsGIF);
+    filemenu->AddEntry("Save As status.&C",    kFileSaveAsC);
+    filemenu->AddEntry("Save As status.&root", kFileSaveAsRoot);
+    filemenu->AddSeparator();
+    filemenu->AddEntry("&Open...",             kFileOpen);
+    filemenu->AddEntry("Save &As...",          kFileSaveAs);
+    filemenu->AddSeparator();
+    filemenu->AddEntry("Re&set",               kFileReset);
+    filemenu->AddSeparator();
+    filemenu->AddEntry("Print with &lpr",      kFilePrint);
+    //filemenu->AddEntry("Set printer &name",    kFilePrinterName);
+    filemenu->AddSeparator();
+    filemenu->AddEntry("C&lose", kFileClose);
+    filemenu->AddEntry("E&xit", kFileExit);
+    filemenu->Associate(this);
+
+    //
+    // Tab Menu
+    //
+    MGPopupMenu *tabmenu = new MGPopupMenu(gClient->GetRoot());
+    tabmenu->AddEntry("Next [&+]",           kTabNext);
+    tabmenu->AddEntry("Previous [&-]",       kTabPrevious);
+    tabmenu->AddSeparator();
+    tabmenu->AddEntry("Save As tab-i.&ps",   kTabSaveAsPS);
+    tabmenu->AddEntry("Save As tab-i.&gif",  kTabSaveAsGIF);
+    tabmenu->AddEntry("Save As tab-i.&C",    kTabSaveAsC);
+    tabmenu->AddEntry("Save As tab-i.&root", kTabSaveAsRoot);
+    tabmenu->AddSeparator();
+    tabmenu->AddEntry("Save &As...",         kTabSaveAs);
+    tabmenu->AddSeparator();
+    tabmenu->AddEntry("Re&move",             kTabRemove);
+    tabmenu->AddSeparator();
+    tabmenu->AddEntry("Print with &lpr",     kTabPrint);
+    tabmenu->Associate(this);
+
+    //
+    // Loop Menu
+    //
+    MGPopupMenu *loopmenu = new MGPopupMenu(gClient->GetRoot());
+    loopmenu->AddEntry("&Stop", kLoopStop);
+    loopmenu->Associate(this);
+
+    //
+    // Loop Menu
+    //
+    MGPopupMenu *sizemenu = new MGPopupMenu(gClient->GetRoot());
+    sizemenu->AddEntry("Fit to 640x&480",   kSize640);
+    sizemenu->AddEntry("Fit to 800x&600",   kSize800);
+    sizemenu->AddEntry("Fit to 960x7&20",   kSize960);
+    sizemenu->AddEntry("Fit to 1024x&768",  kSize1024);
+    sizemenu->AddEntry("Fit to 1280x&1024", kSize1280);
+    sizemenu->Associate(this);
+
+    //
+    // Log Menu
+    //
+    MGPopupMenu *logmenu = new MGPopupMenu(gClient->GetRoot());
+    logmenu->AddEntry("&Copy Selected", kLogCopy);
+    logmenu->AddEntry("Cl&ear all",     kLogClear);
+    logmenu->AddSeparator();
+    logmenu->AddEntry("Select &All",    kLogSelect);
+    logmenu->AddSeparator();
+    logmenu->AddEntry("&Find...",       kLogFind);
+    logmenu->AddSeparator();
+    logmenu->AddEntry("&Save",          kLogSave);
+    logmenu->AddEntry("Save &append",   kLogAppend);
+    logmenu->Associate(this);
+
+    //
+    // Menu Bar
+    //
+    TGLayoutHints *layitem = new TGLayoutHints(kLHintsNormal, 0, 4, 0, 0);
+    fList->Add(layitem);
+
+    MGMenuBar *menubar = new MGMenuBar(this, 1, 1, kHorizontalFrame);
+    menubar->AddPopup("&File", filemenu, layitem);
+    menubar->AddPopup("Lo&g",  logmenu,  layitem);
+    menubar->AddPopup("&Size", sizemenu, layitem);
+    menubar->AddPopup("&Tab",  tabmenu,  layitem);
+    menubar->AddPopup("&Loop", loopmenu, layitem);
+    menubar->BindKeys(this);
+    AddFrame(menubar);
+
+    //
+    // Line below menu bar
+    //
+    TGLayoutHints *laylinesep  = new TGLayoutHints(kLHintsTop|kLHintsExpandX);
+    fList->Add(laylinesep);
+
+    TGHorizontal3DLine *linesep = new TGHorizontal3DLine(this);
+    AddFrame(linesep, laylinesep);
+
+    //
+    // Add everything to autodel list
+    //
+    fList->Add(filemenu);
+    fList->Add(loopmenu);
+    fList->Add(sizemenu);
+    fList->Add(menubar);
+    fList->Add(tabmenu);
+    fList->Add(logmenu);
+    fList->Add(linesep);
+}
+
+// --------------------------------------------------------------------------
+//
+// Adds an empty TGCompositeFrame which might be filled by the user
+//
+void MStatusDisplay::AddUserFrame()
+{
+    TGLayoutHints *lay=new TGLayoutHints(kLHintsExpandX);
+    fList->Add(lay);
+
+    fUserFrame = new TGCompositeFrame(this, 1, 1);
+    AddFrame(fUserFrame, lay);
+    fList->Add(fUserFrame);
+}
+
+char *rot128(char *c)
+{
+    char *rc=c;
+    while (*c) *c++ += 128;
+    return rc;
+}
+
+// --------------------------------------------------------------------------
+//
+// Add the title tab
+//
+void MStatusDisplay::AddMarsTab()
+{
+    // Create Tab1
+    TGCompositeFrame *f = fTab->AddTab("-=MARS=-");
+
+    // Add list of tabs
+
+    TGComboBox *filter = new TGComboBox(f, kTabs);
+    fList->Add(filter);
+    filter->Associate(this);
+    filter->AddEntry("-=MARS=-", 0);
+    filter->Select(0);
+
+    TGLayoutHints *lay3 = new TGLayoutHints(kLHintsCenterX|kLHintsTop, 10, 10, 10, 5);
+    fList->Add(lay3);
+    f->AddFrame(filter, lay3);
+
+    // Add MARS version
+    TGLabel *l = new TGLabel(f, Form("Official Release: V%s", MARSVER));
+    fList->Add(l);
+
+    filter->SetWidth(l->GetWidth());
+    filter->SetHeight(4*l->GetHeight()/3);
+
+    TGLayoutHints *layb = new TGLayoutHints(kLHintsCenterX|kLHintsTop, 10, 10, 5, 5);
+    fList->Add(layb);
+    f->AddFrame(l, layb);
+
+    // Add root version
+    l = new TGLabel(f, Form("Using ROOT v%s", ROOTVER));
+    fList->Add(l);
+
+    TGLayoutHints *lay = new TGLayoutHints(kLHintsCenterX|kLHintsTop);
+    fList->Add(lay);
+    f->AddFrame(l, lay);
+
+    // Add Mars logo picture
+    const TGPicture *pic2 = fList->GetPicture("marslogo.xpm");
+    if (pic2)
+    {
+        TGPictureButton *mars  = new TGPictureButton(f, pic2, kPicMars);
+        fList->Add(mars);
+        mars->Associate(this);
+
+        TGLayoutHints *lay2 = new TGLayoutHints(kLHintsCenterX|kLHintsCenterY, 10, 10, 5, 5);
+        fList->Add(lay2);
+        f->AddFrame(mars, lay2);
+    }
+
+    // Add date and time
+    TDatime d;
+    l = new TGLabel(f, d.AsString());
+    fList->Add(l);
+    f->AddFrame(l, lay);
+
+    // Add copyright notice
+    l = new TGLabel(f, "(c) MAGIC Software Development, 2000-2004");
+    fList->Add(l);
+    f->AddFrame(l, layb);
+
+    TGLayoutHints *layc = new TGLayoutHints(kLHintsCenterX|kLHintsTop, 10, 10, 0, 5);
+    fList->Add(layc);
+
+    char *txt = "<< Thomas Bretz >>";
+    l = new TGLabel(f, txt);
+    fList->Add(l);
+    f->AddFrame(l, layc);
+}
+
+// --------------------------------------------------------------------------
+//
+// Adds the logbook tab to the GUI if it was not added previously.
+//
+// The logbook is updated four times a second only if the tab is visible.
+//
+// You can redirect an output to a MLog-logstream by calling SetLogStream().
+// To disable redirction call SetLogStream(NULL)
+//
+// if enable==kFALSE the stdout is disabled/enabled. Otherwise stdout
+// is ignored.
+//
+void MStatusDisplay::SetLogStream(MLog *log, Bool_t enable)
+{
+    if (gROOT->IsBatch())
+        return;
+
+    if (log && fLogBox==NULL)
+    {
+        fLogIdx = fTab->GetNumberOfTabs();
+
+        // Create Tab1
+        TGCompositeFrame *f = AddRawTab("-Logbook-");//fTab->AddTab("-Logbook-");
+
+        // Create Text View
+        fLogBox = new MGTextView(f, 1, 1); // , -1, 0, TGFrame::GetDefaultFrameBackground());
+        if (fFont)
+            fLogBox->SetFont(fFont);
+        //fLogBox->Associate(this);
+
+        // Add List box to the tab
+        TGLayoutHints *lay = new TGLayoutHints(kLHintsNormal|kLHintsExpandX|kLHintsExpandY,2,2,2,2);
+        f->AddFrame(fLogBox, lay);
+
+        // layout and map tab
+        Layout();
+        MapSubwindows();
+
+        // make it visible
+        // FIXME: This is a workaround, because TApplication::Run is not
+        //        thread safe against ProcessEvents. We assume, that if
+        //        we are not in the Main-Thread ProcessEvents() is
+        //        called by the TApplication Event Loop...
+        if (!TThread::Self()/*gApplication->InheritsFrom(TRint::Class())*/)
+            gClient->ProcessEventsFor(fTab);
+    }
+
+    if (log)
+    {
+        fLog = log;
+
+        log->SetOutputGui(fLogBox, kTRUE);
+        log->EnableOutputDevice(MLog::eGui);
+        if (!enable)
+            log->DisableOutputDevice(MLog::eStdout);
+
+        fLogTimer.Start();
+    }
+    else
+    {
+        fLogTimer.Stop();
+
+        fLog->DisableOutputDevice(MLog::eGui);
+        fLog->SetOutputGui(NULL);
+        if (!enable)
+            fLog->EnableOutputDevice(MLog::eStdout);
+
+        fLog = &gLog;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Add the Tabs and the predifined Tabs to the GUI
+//
+void MStatusDisplay::AddTabs()
+{
+    fTab = new TGTab(this, 300, 300);
+
+    AddMarsTab();
+
+    // Add fTab to Frame
+    TGLayoutHints *laytabs = new TGLayoutHints(kLHintsNormal|kLHintsExpandX|kLHintsExpandY, 5, 5, 5);
+    AddFrame(fTab, laytabs);
+
+    fList->Add(fTab);
+    fList->Add(laytabs);
+}
+
+// --------------------------------------------------------------------------
+//
+// Add the progress bar to the GUI. The Progress Bar range is set to
+// (0,1) as default.
+//
+void MStatusDisplay::AddProgressBar()
+{
+    TGLayoutHints *laybar=new TGLayoutHints(kLHintsExpandX, 5, 5, 5, 5);
+    fList->Add(laybar);
+
+    fBar=new TGHProgressBar(this);
+    fBar->SetRange(0, 1);
+    fBar->ShowPosition();
+    AddFrame(fBar, laybar);
+    fList->Add(fBar);
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the progress bar position between 0 and 1. The Progress bar range
+// is assumed to be (0,1)
+//
+void MStatusDisplay::SetProgressBarPosition(Float_t p)
+{
+    fBar->SetPosition(p);
+}
+
+// --------------------------------------------------------------------------
+//
+// Adds the status bar to the GUI
+//
+void MStatusDisplay::AddStatusBar()
+{
+    fStatusBar = new TGStatusBar(this, 1, 1);
+
+    //
+    // Divide it like the 'Golden Cut' (goldener Schnitt)
+    //
+    //     1-a     a
+    // 1: ------|----
+    //
+    // a/(1-a) = (1-a)/1
+    // a^2+a-1 = 0
+    //       a = (-1+-sqrt(1+4))/2 = sqrt(5)/2-1/2 = 0.618
+    //
+    Int_t p[2] = {38, 62};
+
+    fStatusBar->SetParts(p, 2);
+
+    TGLayoutHints *layb = new TGLayoutHints(kLHintsNormal|kLHintsExpandX, 5, 4, 0, 3);
+    AddFrame(fStatusBar, layb);
+
+    fList->Add(fStatusBar);
+    fList->Add(layb);
+}
+
+// --------------------------------------------------------------------------
+//
+// Change the text in the status line 1
+//
+void MStatusDisplay::SetStatusLine1(const char *txt)
+{
+    if (gROOT->IsBatch())
+        return;
+    fStatusBar->SetText(txt, 0);
+
+    // FIXME: This is a workaround, because TApplication::Run is not
+    //        thread safe against ProcessEvents. We assume, that if
+    //        we are not in the Main-Thread ProcessEvents() is
+    //        called by the TApplication Event Loop...
+    if (!TThread::Self()/*gApplication->InheritsFrom(TRint::Class())*/)
+        gClient->ProcessEventsFor(fStatusBar);
+}
+
+// --------------------------------------------------------------------------
+//
+// Change the text in the status line 2
+//
+void MStatusDisplay::SetStatusLine2(const char *txt)
+{
+    if (gROOT->IsBatch())
+        return;
+
+    fStatusBar->SetText(txt, 1);
+
+    // FIXME: This is a workaround, because TApplication::Run is not
+    //        thread safe against ProcessEvents. We assume, that if
+    //        we are not in the Main-Thread ProcessEvents() is
+    //        called by the TApplication Event Loop...
+    if (!TThread::Self()/*gApplication->InheritsFrom(TRint::Class())*/)
+        gClient->ProcessEventsFor(fStatusBar);
+}
+
+// --------------------------------------------------------------------------
+//
+// Display information about the name of a container
+//
+void MStatusDisplay::SetStatusLine2(const MParContainer &cont)
+{
+    SetStatusLine2(Form("%s: %s", cont.GetDescriptor(), cont.GetTitle()));
+}
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. Opens a window with a progress bar. Get a pointer
+// to the bar by calling GetBar. This pointer can be used for the
+// eventloop.
+//
+// Be carefull: killing or closing the window while the progress meter
+//   is still in use may cause segmentation faults. Please kill the window
+//   always by deleting the corresponding object.
+//
+// Update time default: 10s
+//
+MStatusDisplay::MStatusDisplay(Long_t t)
+: TGMainFrame(NULL, 1, 1), fName("MStatusDisplay"), fLog(&gLog), fTab(NULL), fTimer(this, t, kTRUE), fStatus(kLoopNone), fLogIdx(-1), fLogTimer(this, 250, kTRUE), fLogBox(NULL), fIsLocked(0)
+{
+    // p==NULL means: Take gClient->GetRoot() if not in batch mode
+    // see TGWindow::TGWindow()
+
+    //
+    // This is a possibility for the user to check whether this
+    // object has already been deleted. It will be removed
+    // from the list in the destructor.
+    //
+    gROOT->GetListOfSpecials()->Add(this);
+
+    fFont = gVirtualX->LoadQueryFont("7x13bold");
+    fMutex = new TMutex;
+
+    //
+    // In case we are in batch mode use a list of canvases
+    // instead of the Root Embedded Canvases in the TGTab
+    //
+    fBatch = new TList;
+    fBatch->SetOwner();
+
+    //
+    // Create a list handling GUI widgets
+    //
+    fList = new MGList;
+    fList->SetOwner();
+
+    //
+    // Create the layout hint for the root embedded canavses
+    //
+    fLayCanvas = new TGLayoutHints(kLHintsExpandX|kLHintsExpandY);
+    fList->Add(fLayCanvas);
+
+    //
+    // Add Widgets (from top to bottom)
+    //
+    if (gClient) // BATCH MODE
+    {
+        AddMenuBar();
+        AddUserFrame();
+        AddTabs();
+        AddProgressBar();
+        AddStatusBar();
+    }
+
+    //
+    // set the smallest and biggest size of the Main frame
+    // and move it to its appearance position
+    SetWMSizeHints(570, 480, 1280, 980, 1, 1);
+    MoveResize(rand()%100+570, rand()%100+480, 570, 480);
+
+    //
+    // Now do an automatic layout of the widgets and display the window
+    //
+    Layout();
+    MapSubwindows();
+
+    SetWindowName("Status Display");
+    SetIconName("Status Display");
+
+    MapWindow();
+
+    // FIXME: This is a workaround, because TApplication::Run is not
+    //        thread safe against ProcessEvents. We assume, that if
+    //        we are not in the Main-Thread ProcessEvents() is
+    //        called by the TApplication Event Loop...
+    if (!TThread::Self()/*gApplication->InheritsFrom(TRint::Class())*/)
+        gSystem->ProcessEvents();
+}
+
+// --------------------------------------------------------------------------
+//
+// Destruct the window with all its tiles. Also the Progress Bar object
+// is deleted.
+//
+MStatusDisplay::~MStatusDisplay()
+{
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,10,01)
+    fTab = NULL; // See HandleEvent
+#endif
+
+    //
+    // Delete object from global object table so it cannot
+    // be deleted by chance a second time
+    //
+    gInterpreter->DeleteGlobal(this);
+
+    //
+    // This is a possibility for the user to check whether this
+    // object has already been deleted. It has been added
+    // to the list in the constructor.
+    //
+    gROOT->GetListOfSpecials()->Remove(this);
+
+    SetLogStream(NULL);
+
+    //
+    // Delete the list of objects corresponding to this object
+    //
+    delete fList;
+
+    //
+    // Delete the list list of canvases used in batch mode
+    // instead of the Root Embedded Canvases in the TGTab
+    //
+    delete fBatch;
+
+    //
+    // Delete the font used for the logging window
+    //
+    if (fFont)
+        gVirtualX->DeleteFont(fFont);
+
+    //
+    // Delete mutex
+    //
+    delete fMutex;
+}
+
+// --------------------------------------------------------------------------
+//
+// Takes a TGCompositeFrame as argument. Searches for the first
+// TRootEmbeddedCanvas which is contained by it and returns a pointer
+// to the corresponding TCanvas. If it isn't found NULL is returned.
+//
+TRootEmbeddedCanvas *MStatusDisplay::GetEmbeddedCanvas(TGCompositeFrame *cf) const
+{
+    TIter Next(cf->GetList());
+
+    TGFrameElement *f;
+    while ((f=(TGFrameElement*)Next()))
+        if (f->fFrame->InheritsFrom(TRootEmbeddedCanvas::Class()))
+            return (TRootEmbeddedCanvas*)f->fFrame;
+
+    return NULL;
+}
+
+// --------------------------------------------------------------------------
+//
+// Takes a TGCompositeFrame as argument. Searches for the first
+// TRootEmbeddedCanvas which is contained by it and returns a pointer
+// to the corresponding TCanvas. If it isn't found NULL is returned.
+//
+TCanvas *MStatusDisplay::GetCanvas(TGCompositeFrame *cf) const
+{
+    TRootEmbeddedCanvas *ec = GetEmbeddedCanvas(cf);
+    return ec ? ec->GetCanvas() : NULL;
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns GetCanvas of the i-th Tab.
+//
+TCanvas *MStatusDisplay::GetCanvas(int i) const
+{
+    if (gROOT->IsBatch())
+        return (TCanvas*)fBatch->At(i-1);
+
+    if (i<0 || i>=fTab->GetNumberOfTabs())
+    {
+        *fLog << warn << "MStatusDisplay::GetCanvas: Out of range." << endl;
+        return NULL;
+    }
+
+    return GetCanvas(fTab->GetTabContainer(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Searches for a TRootEmbeddedCanvas in the TGCompositeFramme of the
+// Tab with the name 'name'. Returns the corresponding TCanvas or
+// NULL if something isn't found.
+//
+TCanvas *MStatusDisplay::GetCanvas(const TString &name) const
+{
+    TGFrameElement *f;
+    TIter Next(fTab->GetList());
+    while ((f=(TGFrameElement*)Next()))
+    {
+        TObject *frame = f->fFrame;
+        if (!frame->InheritsFrom(TGTabElement::Class()))
+            continue;
+
+        TGTabElement *tab = (TGTabElement*)frame;
+        if (tab->GetString()==name)
+            break;
+    }
+
+    // Search for the next TGCompositeFrame in the list
+    while ((f=(TGFrameElement*)Next()))
+    {
+        TObject *frame = f->fFrame;
+        if (frame->InheritsFrom(TGCompositeFrame::Class()))
+            return GetCanvas((TGCompositeFrame*)frame);
+    }
+
+    return NULL;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calls TCanvas::cd(), for the canvas returned by GetCanvas.
+//
+Bool_t MStatusDisplay::CdCanvas(const TString &name)
+{
+    TCanvas *c = GetCanvas(name);
+    if (!c)
+        return kFALSE;
+
+    c->cd();
+    return kTRUE;
+}
+
+TGCompositeFrame *MStatusDisplay::AddRawTab(const char *name)
+{
+    // Add new tab
+    TGCompositeFrame *f = fTab->AddTab(name);
+
+    TGComboBox *box = (TGComboBox*)fList->FindWidget(kTabs);
+    box->AddEntry(name, box->GetListBox()->GetNumberOfEntries());
+
+    // layout and map new tab
+    Layout();
+    MapSubwindows();
+    Layout();
+
+    // display new tab in the main frame
+    // FIXME: This is a workaround, because TApplication::Run is not
+    //        thread safe against ProcessEvents. We assume, that if
+    //        we are not in the Main-Thread ProcessEvents() is
+    //        called by the TApplication Event Loop...
+    if (!TThread::Self()/*gApplication->InheritsFrom(TRint::Class())*/)
+        gClient->ProcessEventsFor(fTab);
+
+    *fLog << inf << "Adding Raw Tab '" << name << "' (" << f->GetWidth() << "x";
+    *fLog << f->GetHeight() << ")" << endl;
+
+    // return pointer to new canvas
+    return f;
+}
+
+// --------------------------------------------------------------------------
+//
+// This function was connected to all created canvases. It is used
+// to redirect GetObjectInfo into our own status bar.
+//
+// The 'connection' is done in AddTab
+//
+void MStatusDisplay::EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected)
+{
+    //  Writes the event status in the status bar parts
+    if (!selected)
+        return;
+
+    TCanvas *c = (TCanvas*)gTQSender;
+
+    TVirtualPad* save=gPad;
+
+    gPad = c ? c->GetSelectedPad() : NULL;
+
+    if (gPad)
+        SetStatusLine2(selected->GetObjectInfo(px,py));
+
+    gPad=save;
+}
+
+// --------------------------------------------------------------------------
+//
+// Adds a new tab with the name 'name'. Adds a TRootEmbeddedCanvas to the
+// tab and returns a reference to the corresponding TCanvas.
+//
+TCanvas &MStatusDisplay::AddTab(const char *name)
+{
+    if (gROOT->IsBatch())
+    {
+        TCanvas *c = new TCanvas(name, name);
+        fBatch->Add(c);
+        return *c;
+    }
+
+    // Add new tab
+    TGCompositeFrame *f = fTab->AddTab(name);
+
+    // create root embedded canvas and add it to the tab
+    TRootEmbeddedCanvas *ec = new TRootEmbeddedCanvas(name, f, f->GetWidth(), f->GetHeight(), 0);
+    f->AddFrame(ec, fLayCanvas);
+    fList->Add(ec);
+
+    // set background and border mode of the canvas
+    TCanvas &c = *ec->GetCanvas();
+
+    c.SetFillColor(16/*165*//*17*//*203*/);
+    c.SetBorderMode(0);
+
+    // If kNoContextMenu set set kNoContextMenu of the canvas
+    if (TestBit(kNoContextMenu))
+        c.SetBit(kNoContextMenu);
+
+    // Connect all TCanvas::ProcessedEvent to this->EventInfo
+    // This means, that after TCanvas has processed an event
+    // EventInfo of this class is called, see TCanvas::HandleInput
+    c.Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)",
+              "MStatusDisplay", this, "EventInfo(Int_t,Int_t,Int_t,TObject*)");
+
+    TGComboBox *box = (TGComboBox*)fList->FindWidget(kTabs);
+    box->AddEntry(name, box->GetListBox()->GetNumberOfEntries());
+
+    // layout and map new tab
+    Layout();          // seems to layout the TGCompositeFrame
+    MapSubwindows();   // maps the TGCompositeFrame
+    Layout();          // layout the embedded canvas in the frame
+
+    // display new tab in the main frame
+    // FIXME: This is a workaround, because TApplication::Run is not
+    //        thread safe against ProcessEvents. We assume, that if
+    //        we are not in the Main-Thread ProcessEvents() is
+    //        called by the TApplication Event Loop...
+    if (!TThread::Self()/*gApplication->InheritsFrom(TRint::Class())*/)
+        gClient->ProcessEventsFor(fTab);
+
+    *fLog << inf << "Adding Tab '" << name << "' (" << f->GetWidth() << "x";
+    *fLog << f->GetHeight() << ", TCanvas=" << &c << ")" << endl;
+
+    // return pointer to new canvas
+    return c;
+}
+
+// --------------------------------------------------------------------------
+//
+// Update a canvas in a tab, takes the corresponding TGCompositeFrame
+// as an argument. This is necessary, because not all functions
+// changing the contents of a canvas or pad can call SetModified()
+// for the corresponding tab. If this is not called correctly the
+// tab won't be updated calling TCanvas::Update(). So we simply
+// redraw it by our own (instead we could recursively call
+// TPad::Modified() for everything contained by the TCanvas and
+// call TCanvas::Update() afterwards)
+//
+void MStatusDisplay::UpdateTab(TGCompositeFrame *f)
+{
+    if (!f)
+        return;
+
+    TCanvas *c=GetCanvas(f);
+    if (!c)
+        return;
+
+    //
+    // If we are in a multithreaded environment (gThreadXAR) we
+    // have to make sure, that thus function is called from
+    // the main thread.
+    //
+    if (gThreadXAR)
+    {
+        // Tell the X-Requester how to call this method
+        TString str = Form("%d", (ULong_t)f);
+
+        TMethodCall call(IsA(), "UpdateTab", "NULL");
+        void *arr[4] = { NULL, &call, this, (void*)(const char*)str };
+
+        // If this is not the main thread return
+        if (((*gThreadXAR)("METH", 4, arr, NULL)))
+            return;
+    }
+
+    //
+    // Secure calls to update the tabs against itself, at least
+    // c->Paint() or c->Flush() may crash X (bad drawable).
+    // This makes sure, that a X call is not interuppted by
+    // another X-call which was started from an gui interrrupt
+    // in the same thread
+    //
+    if (fMutex->TryLock())
+        return;
+
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,10,02)
+    TPad *padsav = (TPad*)gPad;
+    if (!gPad)
+        c->cd();
+#endif
+
+    if (!c->IsBatch())
+        c->FeedbackMode(kFALSE);  // Goto double buffer mode
+
+    //
+    // Doing this ourself gives us the possibility to repaint
+    // the canvas in any case (Paint() instead of PaintModified())
+    //
+    c->Paint();                   // Repaint all pads
+    c->Flush();                   // Copy all pad pixmaps to the screen
+
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,10,02)
+    if (padsav)
+        padsav->cd();
+    else
+        gPad=NULL;
+#endif
+
+    //c->SetCursor(kCross);
+
+    // Old version
+    //c->Modified();
+    //c->Update();
+    //c->Paint();
+
+    fMutex->UnLock();
+}
+
+// --------------------------------------------------------------------------
+//
+// Saves the given canvas (pad) or all pads (num<0) as a temporary
+// postscript file and prints it using 'lpr'. If a printer name is set
+// via SetPrinter 'lpr -Pname' is used.
+//
+Int_t MStatusDisplay::PrintToLpr(Int_t num)
+{
+    TString name = "mars";
+
+    for (int i=0; i<6; i++)
+        name += (char)(gRandom->Uniform(25)+65);
+
+    name += ".ps";
+
+    const Int_t pages = SaveAsPS(num, name);
+
+    SetStatusLine1("Printing...");
+    SetStatusLine2("");
+
+    if (!pages)
+    {
+        *fLog << warn << "MStatusDisplay::PrintToLpr: Sorry, couldn't save file as temporary postscript!" << endl;
+        SetStatusLine2("Failed!");
+        return 0;
+    }
+
+    TString cmd="lpr ";
+    if (!fPrinter.IsNull())
+    {
+        cmd += "-P";
+        cmd += fPrinter;
+        cmd += " ";
+    }
+    cmd += name;
+
+    gSystem->Exec(cmd);
+    gSystem->Unlink(name);
+
+    SetStatusLine2(Form("Done (%dpage(s))", pages));
+
+    return pages;
+}
+
+// --------------------------------------------------------------------------
+//
+// Remove tab no i if this tab contains a TRootEmbeddedCanvas
+//
+void MStatusDisplay::RemoveTab(int i)
+{
+    TGCompositeFrame *f = fTab->GetTabContainer(i);
+    if (!f)
+        return;
+
+    TRootEmbeddedCanvas *ec = GetEmbeddedCanvas(f);
+    if (!ec)
+        return;
+
+    TCanvas *c = ec->GetCanvas();
+    if (!c)
+        return;
+
+    const TString name(c->GetName());
+
+    f->RemoveFrame(ec);
+    delete fList->Remove(ec);
+
+    fTab->RemoveTab(i);
+    fTab->SetTab(0);
+
+    TGComboBox *box = (TGComboBox*)fList->FindWidget(kTabs);
+    box->RemoveEntry(i);
+    for (int j=i; j<box->GetListBox()->GetNumberOfEntries(); j++)
+    {
+        TGTextLBEntry *entry = (TGTextLBEntry *)box->GetListBox()->Select(j+1, kFALSE);
+        box->AddEntry(entry->GetText()->GetString(), j);
+        box->RemoveEntry(j+1);
+    }
+    box->GetListBox()->Select(0);
+
+    // Looks strange...
+    // const Int_t n = fTab->GetNumberOfTabs();
+    // fTab->SetTab(i<=n-1 ? i : i-1);
+
+    // layout and map new tab
+    Layout();          // seems to layout the TGCompositeFrame
+    MapSubwindows();   // maps the TGCompositeFrame
+    Layout();          // layout the embedded canvas in the frame
+
+    // display new tab in the main frame
+    // FIXME: This is a workaround, because TApplication::Run is not
+    //        thread safe against ProcessEvents. We assume, that if
+    //        we are not in the Main-Thread ProcessEvents() is
+    //        called by the TApplication Event Loop...
+    if (!TThread::Self()/*gApplication->InheritsFrom(TRint::Class())*/)
+        gClient->ProcessEventsFor(fTab);
+
+    *fLog << inf << "Removed Tab #" << i << " '" << name << "'" << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Use this to check whether the MStatusDisplay still contains the
+// TCanvas c. It could be removed meanwhile by menu usage.
+//
+Bool_t MStatusDisplay::HasCanvas(const TCanvas *c) const
+{
+    if (!c)
+        return kFALSE;
+
+    if (gROOT->IsBatch())
+        return (Bool_t)fBatch->FindObject(c);
+
+    for (int i=1; i<fTab->GetNumberOfTabs(); i++)
+        if (c==GetCanvas(i))
+            return kTRUE;
+    return kFALSE;
+}
+
+/*
+    if (...)
+       fMenu->AddPopup("&CaOs", fCaOs, NULL);
+    else
+       fMenu->RemovePopup("CaOs");
+    fMenu->Resize(fMenu->GetDefaultSize());
+    MapSubwindows();
+    MapWindow();
+ */
+
+void MStatusDisplay::Reset()
+{
+    for (int i=fTab->GetNumberOfTabs()-1; i>0; i--)
+        RemoveTab(i);
+}
+
+// --------------------------------------------------------------------------
+//
+// Process the kC_COMMAND, kCM_MENU  messages
+//
+Bool_t MStatusDisplay::ProcessMessageCommandMenu(Long_t id)
+{
+    switch (id)
+    {
+    case kLoopStop:
+    case kFileClose:
+    case kFileExit:
+        if (id==kFileExit || id==kFileClose)
+            CloseWindow();
+        fStatus = (Status_t)id;
+        return kTRUE;
+
+    case kFileCanvas:
+        new TCanvas;
+        return kTRUE;
+
+    case kFileBrowser:
+        new TBrowser;
+        return kTRUE;
+
+    case kFileReset:
+        Reset();
+        return kTRUE;
+
+    case kFileOpen:
+        Open();
+        return kTRUE;
+
+    case kFileSaveAs:
+        SaveAs();
+        return kTRUE;
+
+    case kFileSaveAsPS:
+        SaveAsPS();
+        return kTRUE;
+
+    case kFileSaveAsGIF:
+        SaveAsGIF();
+        return kTRUE;
+
+    case kFileSaveAsC:
+        SaveAsC();
+        return kTRUE;
+
+    case kFileSaveAsRoot:
+        SaveAsRoot();
+        return kTRUE;
+
+    case kFilePrint:
+        PrintToLpr();
+        return kTRUE;
+
+    case kTabSaveAs:
+        SaveAs(fTab->GetCurrent());
+        return kTRUE;
+
+    case kTabSaveAsPS:
+        SaveAsPS(fTab->GetCurrent());
+        return kTRUE;
+
+    case kTabSaveAsGIF:
+        SaveAsGIF(fTab->GetCurrent());
+        return kTRUE;
+
+    case kTabSaveAsC:
+        SaveAsC(fTab->GetCurrent());
+        return kTRUE;
+
+    case kTabSaveAsRoot:
+        SaveAsRoot(fTab->GetCurrent());
+        return kTRUE;
+
+    case kTabPrint:
+        PrintToLpr(fTab->GetCurrent());
+        return kTRUE;
+
+    case kTabNext:
+        fTab->SetTab(fTab->GetCurrent()+1);
+        return kTRUE;
+
+    case kTabPrevious:
+        fTab->SetTab(fTab->GetCurrent()-1);
+        return kTRUE;
+
+    case kTabRemove:
+        RemoveTab(fTab->GetCurrent());
+        return kTRUE;
+
+    case kSize640:
+        Resize(570, 480);
+        return kTRUE;
+    case kSize800:
+        Resize(740, 600);
+        return kTRUE;
+    case kSize960:
+        Resize(880, 700);
+        return kTRUE;
+    case kSize1024:
+        Resize(980, 768);
+        return kTRUE;
+    case kSize1280:
+        Resize(1280, 980);
+        return kTRUE;
+
+    case kLogClear:
+        fLogBox->Clear();
+        return kTRUE;
+    case kLogCopy:
+        fLogBox->Copy();
+        return kTRUE;
+    case kLogSelect:
+        fLogBox->SelectAll();
+        return kTRUE;
+    case kLogFind:
+        new MSearch(this);
+        return kTRUE;
+    case kLogSave:
+        SetStatusLine1("Saving log...");
+        SetStatusLine2("");
+        *fLog << inf << "Saving log... " << flush;
+        if (fLogBox->GetText()->Save("statusdisplay.log"))
+        {
+            *fLog << "done." << endl;
+            SetStatusLine2("done.");
+        }
+        else
+        {
+            *fLog << "failed!" << endl;
+            SetStatusLine2("Failed!");
+        }
+        return kTRUE;
+
+    case kLogAppend:
+        SetStatusLine1("Appending logg...");
+        SetStatusLine2("");
+        *fLog << inf << "Appending log... " << flush;
+        if (fLogBox->GetText()->Append("statusdisplay.log"))
+        {
+            *fLog << "done." << endl;
+            SetStatusLine2("done.");
+        }
+        else
+        {
+            *fLog << "failed!" << endl;
+            SetStatusLine2("Failed!");
+        }
+        return kTRUE;
+#ifdef DEBUG
+    default:
+        cout << "Command-Menu #" << id << endl;
+#endif
+    }
+    return kTRUE;
+
+}
+
+// --------------------------------------------------------------------------
+//
+// Process the kC_COMMAND messages
+//
+Bool_t MStatusDisplay::ProcessMessageCommand(Long_t submsg, Long_t mp1, Long_t mp2)
+{
+    switch (submsg)
+    {
+    case kCM_MENU: // 1
+        return ProcessMessageCommandMenu(mp1); // mp2=userdata
+    case kCM_TAB:  // 8
+        /*
+         for (int i=0; i<fTab->GetNumberOfTabs(); i++)
+         fTab->GetTabContainer(i)->UnmapWindow();
+         */
+        UpdateTab(fTab->GetTabContainer(mp1));
+        //fTab->GetTabContainer(mp1)->MapWindow();
+
+        /*
+        if (mp1>0)
+            fMenu->AddPopup("&CaOs", fCaOs, NULL);
+        else
+            fMenu->RemovePopup("CaOs");
+        fMenu->Resize(fMenu->GetDefaultSize());
+        MapSubwindows();
+        MapWindow();
+        */
+        return kTRUE;
+    case kCM_COMBOBOX: // 7
+        if (mp1==kTabs)
+            fTab->SetTab(mp2);
+        return kTRUE;
+#ifdef DEBUG
+    case kCM_MENUSELECT: // 2
+        cout << "Command-Menuselect #" << mp1 << " (UserData=" << (void*)mp2 << ")" << endl;
+        return kTRUE;
+
+    case kCM_BUTTON: // 3
+        cout << "Command-Button." << endl;
+        return kTRUE;
+
+    case kCM_CHECKBUTTON: // 4
+        cout << "Command-CheckButton." << endl;
+        return kTRUE;
+
+    case kCM_RADIOBUTTON: // 5
+        cout << "Command-RadioButton." << endl;
+        return kTRUE;
+
+    case kCM_LISTBOX: // 6
+        cout << "Command-Listbox #" << mp1 << " (LineId #" << mp2 << ")" << endl;
+        return kTRUE;
+    default:
+        cout << "Command: " << "Submsg:" << submsg << " Mp1=" << mp1 << " Mp2=" << mp2 << endl;
+#endif
+    }
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Process the kC_TEXTVIEW messages
+//
+Bool_t MStatusDisplay::ProcessMessageTextview(Long_t submsg, Long_t mp1, Long_t mp2)
+{
+    // kC_TEXTVIEW, kTXT_ISMARKED, widget id, [true|false]                  //
+    // kC_TEXTVIEW, kTXT_DATACHANGE, widget id, 0                           //
+    // kC_TEXTVIEW, kTXT_CLICK2, widget id, position (y << 16) | x)         //
+    // kC_TEXTVIEW, kTXT_CLICK3, widget id, position (y << 16) | x)         //
+    // kC_TEXTVIEW, kTXT_F3, widget id, true                                //
+    // kC_TEXTVIEW, kTXT_OPEN, widget id, 0                                 //
+    // kC_TEXTVIEW, kTXT_CLOSE, widget id, 0                                //
+    // kC_TEXTVIEW, kTXT_SAVE, widget id, 0                                 //
+#ifdef DEBUG
+    switch (submsg)
+    {
+    case kTXT_ISMARKED:
+        cout << "Textview-IsMarked #" << mp1 << " " << (mp2?"yes":"no") << endl;
+        return kTRUE;
+
+    case kTXT_DATACHANGE:
+        cout << "Textview-DataChange #" << mp1 << endl;
+        return kTRUE;
+
+    case kTXT_CLICK2:
+        cout << "Textview-Click2 #" << mp1 << " x=" << (mp2&0xffff) << " y= " << (mp2>>16) << endl;
+        return kTRUE;
+
+    case kTXT_CLICK3:
+        cout << "Textview-Click3 #" << mp1 << " x=" << (mp2&0xffff) << " y= " << (mp2>>16) << endl;
+        return kTRUE;
+
+    case kTXT_F3:
+        cout << "Textview-F3 #" << mp1 << endl;
+        return kTRUE;
+
+    case kTXT_OPEN:
+        cout << "Textview-Open #" << mp1 << endl;
+        return kTRUE;
+
+    case kTXT_CLOSE:
+        cout << "Textview-Close #" << mp1 << endl;
+        return kTRUE;
+
+    case kTXT_SAVE:
+        cout << "Textview-Save #" << mp1 << endl;
+        return kTRUE;
+
+    default:
+        cout << "Textview: " << "Submsg:" << submsg << " Mp1=" << mp1 << " Mp2=" << mp2 << endl;
+    }
+#endif
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Process the kC_USER messages
+//
+Bool_t MStatusDisplay::ProcessMessageUser(Long_t submsg, Long_t mp1, Long_t mp2)
+{
+    // kS_START, case sensitive | backward<<1, char *txt
+    switch (submsg)
+    {
+    case kS_START:
+        fLogBox->Search((char*)mp2, !(mp1&2>>1), mp1&1);
+        return kTRUE;
+#ifdef DEBUG
+    default:
+        cout << "User: " << "Submsg:" << submsg << " Mp1=" << mp1 << " Mp2=" << mp2 << endl;
+#endif
+    }
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Process the messages from the GUI
+//
+Bool_t MStatusDisplay::ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2)
+{
+    // Can be found in WidgetMessageTypes.h
+#ifdef DEBUG
+    cout << "Msg: " << GET_MSG(msg) << " Submsg:" << GET_SUBMSG(msg);
+    cout << " Mp1=" << mp1 << " Mp2=" << mp2 << endl;
+#endif
+    switch (GET_MSG(msg))
+    {
+    case kC_COMMAND:  // 1
+        return ProcessMessageCommand(GET_SUBMSG(msg), mp1, mp2);
+
+    case kC_TEXTVIEW: // 9
+        return ProcessMessageTextview(GET_SUBMSG(msg), mp1, mp2);
+
+    case kC_USER:     // 1001
+        return ProcessMessageUser(GET_SUBMSG(msg), mp1, mp2);
+    }
+#ifdef DEBUG
+    cout << "Msg: " << GET_MSG(msg) << " Submsg:" << GET_SUBMSG(msg);
+    cout << " Mp1=" << mp1 << " Mp2=" << mp2 << endl;
+#endif
+    return kTRUE;
+}
+
+void MStatusDisplay::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.
+
+    // CloseWindow must be overwritten because otherwise CloseWindow
+    // and the destructor are calling DestroyWindow which seems to be
+    // in conflict with the TRootEmbeddedCanvas.
+
+    // FIXME: Make sure that the Status Display is deleted from every
+    //        where (eg Eventloop) first!
+
+    //gLog << dbg << fName << " is on heap: " << (int)IsOnHeap() << endl;
+
+    if (TestBit(kExitLoopOnExit) || TestBit(kExitLoopOnClose))
+    {
+        gLog << dbg << "CloseWindow() calling ExitLoop." << endl;
+        gSystem->ExitLoop();
+    }
+
+    if (fIsLocked<=0 && IsOnHeap())
+    {
+        //gLog << dbg << "delete " << fName << ";" << endl;
+        delete this;
+    }
+    fStatus = kFileExit;
+    //gLog << dbg << fName << ".fStatus=kFileExit;" << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calls SetBit(kNoContextMenu) for all TCanvas objects found in the
+// Tabs.
+//
+void MStatusDisplay::SetNoContextMenu(Bool_t flag)
+{
+    if (fIsLocked>1 || gROOT->IsBatch())
+        return;
+
+    flag ? SetBit(kNoContextMenu) : ResetBit(kNoContextMenu);
+
+    for (int i=1; i<fTab->GetNumberOfTabs(); i++)
+    {
+        TCanvas *c = GetCanvas(i);
+        if (c)
+            flag ? c->SetBit(kNoContextMenu) : c->ResetBit(kNoContextMenu);
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Updates the canvas (if existing) in the currenly displayed Tab.
+// The update intervall is controlled by StartUpdate and StopUpdate
+//
+Bool_t MStatusDisplay::HandleTimer(TTimer *timer)
+{
+    if (gROOT->IsBatch())
+        return kTRUE;
+
+    const Int_t c = fTab->GetCurrent();
+
+    // Skip Legend Tab
+    if (c==0)
+        return kTRUE;
+
+    // Update a canvas tab (if visible)
+    if (timer==&fTimer && c!=fLogIdx)
+    {
+        UpdateTab(fTab->GetCurrentContainer());
+        return kTRUE;
+    }
+
+    // update the logbook tab (if visible)
+    if (timer==&fLogTimer && c==fLogIdx)
+    {
+        fLog->UpdateGui();
+
+        /*
+        if (!fLogBox->TestBit(kHasChanged))
+            return kTRUE;
+
+            fLogBox->ResetBit(kHasChanged);
+            */
+        return kTRUE;
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draws a clone of a canvas into a new canvas. Taken from TCanvas.
+//
+void MStatusDisplay::DrawClonePad(TCanvas &newc, const TCanvas &oldc) const
+{
+    //copy pad attributes
+    newc.Range(oldc.GetX1(),oldc.GetY1(),oldc.GetX2(),oldc.GetY2());
+    newc.SetTickx(oldc.GetTickx());
+    newc.SetTicky(oldc.GetTicky());
+    newc.SetGridx(oldc.GetGridx());
+    newc.SetGridy(oldc.GetGridy());
+    newc.SetLogx(oldc.GetLogx());
+    newc.SetLogy(oldc.GetLogy());
+    newc.SetLogz(oldc.GetLogz());
+    newc.SetBorderSize(oldc.GetBorderSize());
+    newc.SetBorderMode(oldc.GetBorderMode());
+    ((TAttLine&)oldc).Copy((TAttLine&)newc);
+    ((TAttFill&)oldc).Copy((TAttFill&)newc);
+    ((TAttPad&)oldc).Copy((TAttPad&)newc);
+
+    //copy primitives
+    TObject *obj;
+    TIter next(oldc.GetListOfPrimitives());
+    while ((obj=next())) {
+        gROOT->SetSelectedPad(&newc);
+        newc.GetListOfPrimitives()->Add(obj->Clone(),obj->GetDrawOption());
+    }
+    newc.Modified();
+    newc.Update();
+}
+
+Bool_t MStatusDisplay::Display(const TObjArray &list)
+{
+    TIter Next(&list);
+
+    TObject *o=Next();
+    if (!o)
+    {
+        *fLog << err << "MStatusDisplay::Display: No entry in TObjArray." << endl;
+        return kFALSE;
+    }
+
+    fTitle = o->GetTitle();
+
+    TCanvas *c;
+    while ((c=(TCanvas*)Next()))
+        if (!GetCanvas(c->GetName()))
+            DrawClonePad(AddTab(c->GetName()), *c);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Reads the contents of a saved MStatusDisplay from a file.
+//
+Int_t MStatusDisplay::Read(const char *name)
+{
+    if (!gFile)
+    {
+        *fLog << warn << "MStatusDisplay::Read: No file found. Please create a TFile first." << endl;
+        return 0;
+    }
+
+    if (!gFile->IsOpen())
+    {
+        *fLog << warn << "MStatusDisplay::Read: File not open. Please open the TFile first." << endl;
+        return 0;
+    }
+
+    MStatusArray list;
+
+    const Int_t n = list.Read(name);
+    if (n==0)
+    {
+        *fLog << warn << "MStatusDisplay::Read: No objects read." << endl;
+        return 0;
+    }
+
+    if (!Display(list))
+    {
+        *fLog << err << "MStatusDisplay::Display: No entry in " << name << "." << endl;
+        return 0;
+    }
+
+    *fLog << inf << "MStatusDisplay: Key " << name << " with " << n << " keys read from file." << endl;
+
+    return n;
+}
+
+// --------------------------------------------------------------------------
+//
+// Writes the contents of a MStatusDisplay to a file.
+//
+Int_t MStatusDisplay::Write(Int_t num, const char *name, Int_t option, Int_t bufsize)
+{
+    if (!gFile)
+    {
+        *fLog << warn << "MStatusDisplay::Write: No file found. Please create a TFile first." << endl;
+        return 0;
+    }
+
+    if (!gFile->IsOpen())
+    {
+        *fLog << warn << "MStatusDisplay::Write: File not open. Please open the TFile first." << endl;
+        return 0;
+    }
+
+    if (!gFile->IsWritable())
+    {
+        *fLog << warn << "MStatusDisplay::Write: File not writable." << endl;
+        return 0;
+    }
+
+    if (num==0)
+    {
+        *fLog << warn << "MStatusDisplay::Write: Tab doesn't contain an embedded Canvas... skipped." << endl;
+        return 0;
+    }
+
+    if (!gROOT->IsBatch() && num>=fTab->GetNumberOfTabs())
+    {
+        *fLog << warn << "MStatusDisplay::Write: Tab doesn't exist... skipped." << endl;
+        return 0;
+    }
+    if (gROOT->IsBatch() && num>fBatch->GetSize())
+    {
+        *fLog << warn << "MStatusDisplay::Write: Tab doesn't exist... skipped." << endl;
+        return 0;
+    }
+
+    MStatusArray list;
+
+    TNamed named;
+    named.SetTitle(fTitle);
+    list.Add(&named);
+
+    const Int_t max  = gROOT->IsBatch() ? fBatch->GetSize()+1 : fTab->GetNumberOfTabs();
+    const Int_t from = num<0 ?   1 : num;
+    const Int_t to   = num<0 ? max : num+1;
+
+    TCanvas *c;
+    for (int i=from; i<to; i++)
+        if ((c = GetCanvas(i)))
+            list.Add(c);
+
+    const Int_t n = list.Write(name, kSingleKey);
+
+    *fLog << inf << "MStatusDisplay: " << n << " keys written to file as key " << name << "." << endl;
+
+    return n;
+}
+
+// --------------------------------------------------------------------------
+//
+// Use this to start the synchronous (GUI eventloop driven) tab update.
+// Can also be used to change the update intervall. If millisec<0
+// the intervall given in SetUpdateTime is used. If the intervall in
+// SetUpdateTime is <0 nothing is done. (Call SetUpdateTime(-1) to
+// disable the automatic update in a MEventloop.
+//
+void MStatusDisplay::StartUpdate(Int_t millisec)
+{
+    if (fIsLocked>1)
+        return;
+
+    if (fTimer.GetTime()<TTime(0))
+        return;
+    fTimer.Start(millisec);
+}
+
+// --------------------------------------------------------------------------
+//
+// Stops the automatic GUI update
+//
+void MStatusDisplay::StopUpdate()
+{
+    if (fIsLocked>1)
+        return;
+
+    fTimer.Stop();
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the update interval for the GUI update, see StartUpdate.
+//
+void MStatusDisplay::SetUpdateTime(Long_t t)
+{
+    fTimer.SetTime(t);
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the background color in a canvas
+//
+void MStatusDisplay::CanvasSetFillColor(TPad &p, Int_t col) const
+{
+    TObject *obj;
+
+    // See also TPad::UseCurrentStyle
+    TIter Next(p.GetListOfPrimitives());
+    while ((obj=Next()))
+    {
+        if (obj->InheritsFrom(TPad::Class()))
+            CanvasSetFillColor(*(TPad*)obj, col);
+        if (obj->InheritsFrom(TFrame::Class()))
+            ((TFrame*)obj)->SetFillColor(col);
+    }
+
+    p.SetFillColor(col);
+}
+
+void MStatusDisplay::AddExtension(TString &name, const TString &ext, Int_t num) const
+{
+    if (name.IsNull())
+    {
+        name = "status";
+        if (num>0)
+        {
+            name += "-";
+            name += num;
+        }
+    }
+
+    if (name.EndsWith("."+ext))
+        return;
+
+    name += ".";
+    name += ext;
+}
+
+Bool_t MStatusDisplay::CheckTabForCanvas(int num) const
+{
+    if (gROOT->IsBatch())
+        return num>0 && num<=fBatch->GetSize() || num<0;
+
+    if (num>=fTab->GetNumberOfTabs())
+    {
+        *fLog << warn << "Tab #" << num << " doesn't exist..." << endl;
+        return kFALSE;
+    }
+    if (num==0)
+    {
+        *fLog << warn << "Tab #" << num << " doesn't contain an embedded canvas..." << endl;
+        return kFALSE;
+    }
+    if (fTab->GetNumberOfTabs()<2 || !gPad)
+    {
+        *fLog << warn << "Sorry, you must have at least one existing canvas (gPad!=NULL)" << endl;
+        return kFALSE;
+    }
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Insert the following two lines into the postscript header:
+//
+//   %%DocumentPaperSizes: a4
+//   %%Orientation: Landscape
+//
+void MStatusDisplay::UpdatePSHeader(const TString &name) const
+{
+    const TString newstr("%%DocumentPaperSizes: a4\n%%Orientation: Landscape\n");
+
+    ifstream fin(name);
+    ofstream fout(name+".$$$");
+
+    char c;
+
+    TString str;
+    fin >> str >> c;                // Read "%!PS-Adobe-2.0\n"
+    fout << str << endl << newstr;
+
+    // Doing it in blocks seems not to gain much for small (MB) files
+    while (fin)
+    {
+        fin.read(&c, 1);
+        fout.write(&c, 1);
+    }
+
+    gSystem->Unlink(name);
+    gSystem->Rename(name+".$$$", name);
+/*
+    //
+    // Old style algorithm. Shifts blocks inside a single file --- SLOW!
+    //
+    const Int_t l = newstr.Length();
+
+    Long_t t[4]; // { id, size, flags, modtime }
+    gSystem->GetPathInfo(name, t, t+1, t+2, t+3);
+
+    char *c[2] = { new char[l], new char[l] };
+
+    fstream f(name, ios::in|ios::out);
+
+    TString str;
+    f >> str >> c[0][0];     // Read "%!PS-Adobe-2.0\n" (Mini Header)
+    f.read(c[0], l);
+    f.seekp(-l, ios::cur);
+    f.write(newstr, l);
+
+    int i=0;
+    while (1)
+    {
+        f.read(c[(i+1)%2], l);
+        f.seekp(-l, ios::cur);
+
+        if (f)
+        {
+            f.write(c[i%2],l);
+            i++;
+            i%=2;
+            continue;
+        }
+
+        const Int_t ssz   = str.Length()+1;        // Length of Mini-Header
+        const Int_t block = t[1]-ssz;              // Length of block to be shifted
+        const Int_t size  = block%l;               // Reminder
+        const Int_t pos   = (block/l)*l + ssz + 1; // Position to start writing
+
+        f.clear();
+        f.seekp(pos);
+        f.write(c[i%2], l);
+        f.write(c[(i+1)%2], size);
+        break;
+    }
+
+    delete c[1];
+    delete c[0];
+*/
+}
+
+// --------------------------------------------------------------------------
+//
+// In case of num<0 all tabs are written into the PS file. If num>0
+// the canvas in the corresponding tab is written to the file.
+// Name is the name of the file (with or without extension).
+//
+// Returns the number of pages written.
+//
+// To write all tabs you can also use SaveAsPS(name)
+//
+// If the third argument is given a bottom line is drawn with the text
+// under it. If no argument is given a bottom line is drawn if
+// fTitle (SetTitle) is not empty.
+//
+Int_t MStatusDisplay::SaveAsPS(Int_t num, TString name, const TString addon)
+{
+    SetStatusLine1("Writing Postscript file...");
+    SetStatusLine2("");
+
+    if (!CheckTabForCanvas(num))
+    {
+        SetStatusLine2("Failed!");
+        return 0;
+    }
+
+    AddExtension(name, "ps", num);
+
+    if (num<0)
+        *fLog << inf << "Open ps-File: " << name << endl;
+
+    TPad       *padsav = (TPad*)gPad;
+    TVirtualPS *psave  = gVirtualPS;
+
+    TDatime d;
+
+    TPostScript ps(name, 112);
+    ps.SetBit(TPad::kPrintingPS);
+    ps.PrintFast(13, "/nan {1} def ");
+
+    gVirtualPS = &ps;
+
+    //
+    // Create a list to delete the canvas clones
+    //
+    TList l;
+    l.SetOwner();
+
+    //
+    // Create some GUI elements for a page legend
+    //
+    TLine line;
+
+    int page = 1;
+
+    //
+    // Maintain tab numbers
+    //
+    const Int_t max  = gROOT->IsBatch() ? fBatch->GetSize()+1 : fTab->GetNumberOfTabs();
+    const Int_t from = num<0 ?   1 : num;
+    const Int_t to   = num<0 ? max : num+1;
+
+    for (int i=from; i<to; i++)
+    {
+        TCanvas *c;
+        if (!(c = GetCanvas(i)))
+        {
+            if (num<0)
+                *fLog << inf << " - ";
+            *fLog << "Tab #" << i << " doesn't contain an embedded Canvas... skipped." << endl;
+            continue;
+        }
+
+        SetStatusLine2(Form("Tab #%d", i));
+
+        //
+        // Init page and page size, make sure, that the canvas in the file
+        // has the same Aspect Ratio than on the screen.
+        //
+        ps.NewPage();
+
+        //
+        // 28 is used here to scale the canvas into a height of 28,
+        // such that the page title can be set above the canvas...
+        //
+        Float_t psw = 28.0; // A4 - width (29.7)
+        Float_t psh = 21.0; // A4 - height (21.0)
+
+        const Float_t cw = c->GetWw();
+        const Float_t ch = c->GetWh();
+
+        if (psw/psh>cw/ch)
+            psw = cw/ch*psh;
+        else
+            psh = ch/cw*psw;
+
+        ps.Range(psw, psh); // A4
+
+        //
+        // Clone canvas and change background color and schedule for
+        // deletion
+        //
+        TCanvas *n = (TCanvas*)c->Clone();
+        CanvasSetFillColor(*n, kWhite);
+        l.Add(n);
+
+        //
+        // Paint canvas into root file
+        //
+        if (num<0)
+            *fLog << inf << " - ";
+        *fLog << inf << "Writing Tab #" << i << ": " << c->GetName() << " (" << c << ") ";
+        if (num>0)
+            *fLog << "to " << name;
+        *fLog << "... " << flush;
+
+        n->SetBatch(kTRUE);
+        n->Paint();
+
+        //
+        // Use the canvas as coordinate system for the overlaying text
+        //
+        gPad = n;
+        //n->cd();
+
+        //
+        // Print overlaying text (NDC = %)
+        //
+        ps.SetTextColor(kBlack);
+        ps.SetTextSize(0.015);
+        ps.SetTextFont(22);
+        ps.SetTextAlign(11); // left top
+        ps.TextNDC(0, 1.015, TString("  ")+n->GetName());
+        ps.SetTextAlign(21); // cent top
+        ps.TextNDC(0.5, 1.015, TString("MARS - Magic Analysis and Reconstruction Software - ")+d.AsString());
+        ps.SetTextAlign(31); // right top
+        ps.TextNDC(1, 1.015, Form("Page No.%i (%i)  ", page++, i));
+        line.PaintLineNDC(0, 1.01, 1, 1.01);
+
+        TString txt(addon.IsNull() ? fTitle : addon);
+        if (!txt.IsNull())
+        {
+            line.PaintLineNDC(0, -0.00, 1, -0.00);
+            ps.SetTextAlign(11); // left top
+            ps.TextNDC(0, -0.005, txt);
+            ps.SetTextAlign(31); // right top
+            ps.TextNDC(1, -0.005, "(c) 2000-2004, Thomas Bretz");
+        }
+
+        //
+        // Finish drawing page
+        //
+        n->SetBatch(kFALSE);
+        *fLog << "done." << endl;
+    }
+
+    gPad = NULL; // Important!
+    l.Delete();
+
+    ps.Close();
+
+    SetStatusLine2("Updating header of PS file...");
+
+    if (num<0)
+        *fLog << " - Updating header of PS file... " << flush;
+    UpdatePSHeader(name);
+    if (num<0)
+        *fLog << inf << "done." << endl;
+
+    gVirtualPS = psave;
+    if (padsav)
+        padsav->cd();
+
+    if (num<0)
+        *fLog << inf << "done." << endl;
+
+    SetStatusLine2(Form("Done (%dpages)", page-1));
+
+    return page-1;
+}
+
+Bool_t MStatusDisplay::SaveAsGIF(Int_t num, TString name)
+{
+    if (gROOT->IsBatch())
+    {
+        *fLog << warn << "Sorry, writing gif-files is not available in batch mode." << endl;
+        return 0;
+    }
+    SetStatusLine1("Writing GIF file...");
+    SetStatusLine2("");
+
+    if (!CheckTabForCanvas(num))
+    {
+        SetStatusLine2("Failed!");
+        return 0;
+    }
+
+    AddExtension(name, "gif", num);
+
+    if (num<0)
+        *fLog << inf << "Writing gif-Files..." << endl;
+
+    TPad *padsav = (TPad*)gPad;
+
+    int page = 1;
+
+    //
+    // Maintain tab numbers
+    //
+    const Int_t from = num<0 ? 1 : num;
+    const Int_t to   = num<0 ? fTab->GetNumberOfTabs() : num+1;
+
+    for (int i=from; i<to; i++)
+    {
+        TCanvas *c;
+        if (!(c = GetCanvas(i)))
+        {
+            if (num<0)
+                *fLog << inf << " - ";
+            *fLog << "Tab #" << i << " doesn't contain an embedded Canvas... skipped." << endl;
+            continue;
+        }
+
+        SetStatusLine2(Form("Tab #%d", i));
+
+        //
+        // Clone canvas and change background color and schedule for
+        // deletion
+        //
+        //TCanvas *n = (TCanvas*)c->Clone();
+        //CanvasSetFillColor(*n, kWhite);
+
+        //
+        // Paint canvas into root file
+        //
+        TString writename = name;
+        if (num<0)
+        {
+            TString numname = "-";
+            numname += i;
+            writename.Insert(name.Last('.'), numname);
+        }
+        if (num<0)
+            *fLog << inf << " - ";
+        *fLog << inf << "Writing Tab #" << i << " to " << writename << ": " << c->GetName() << " (" << c << ") ";
+        if (num>0)
+            *fLog << "to " << name;
+        *fLog << "..." << flush;
+
+        c->Draw();
+        c->SaveAs(writename);
+        /*
+         n->Draw();
+         n->SaveAs(writename);
+         delete n;
+         */
+
+        if (num<0)
+            *fLog << "done." << endl;
+    }
+
+    padsav->cd();
+
+    *fLog << inf << "done." << endl;
+
+    SetStatusLine2("Done.");
+
+    return page-1;
+}
+
+Bool_t MStatusDisplay::SaveAsC(Int_t num, TString name)
+{
+    SetStatusLine1("Writing C++ file...");
+    SetStatusLine2("");
+
+    if (!CheckTabForCanvas(num))
+    {
+        SetStatusLine2("Failed!");
+        return 0;
+    }
+
+    AddExtension(name, "C", num);
+
+    if (num<0)
+        *fLog << inf << "Writing C-Files..." << endl;
+
+    TPad *padsav = (TPad*)gPad;
+
+    int page = 1;
+
+    //
+    // Maintain tab numbers
+    //
+    const Int_t from = num<0 ? 1 : num;
+    const Int_t to   = num<0 ? fTab->GetNumberOfTabs() : num+1;
+
+    for (int i=from; i<to; i++)
+    {
+        TCanvas *c;
+        if (!(c = GetCanvas(i)))
+        {
+            if (num<0)
+                *fLog << inf << " - ";
+            *fLog << "Tab #" << i << " doesn't contain an embedded Canvas... skipped." << endl;
+            continue;
+        }
+
+        SetStatusLine2(Form("Tab #%d", i));
+
+        //
+        // Clone canvas and change background color and schedule for
+        // deletion
+        //
+        TCanvas *n = (TCanvas*)c->Clone();
+        CanvasSetFillColor(*n, kWhite);
+
+        //
+        // Paint canvas into root file
+        //
+        TString writename = name;
+        if (num<0)
+        {
+            TString numname = "-";
+            numname += i;
+            writename.Insert(name.Last('.'), numname);
+        }
+        if (num<0)
+            *fLog << inf << " - ";
+        *fLog << inf << "Writing Tab #" << i << " to " << writename << ": " << c->GetName() << " (" << n << ") ";
+        if (num>0)
+            *fLog << "to " << name;
+        *fLog << "..." << flush;
+
+        n->SaveSource(writename, "");
+        delete n;
+
+        if (num<0)
+            *fLog << "done." << endl;
+    }
+
+    padsav->cd();
+
+    *fLog << inf << "done." << endl;
+
+    SetStatusLine2("Done.");
+
+    return page-1;
+}
+
+// --------------------------------------------------------------------------
+//
+// In case of num<0 all tabs are written into the PS file. If num>0
+// the canvas in the corresponding tab is written to the file.
+// Name is the name of the file (with or without extension).
+//
+// Returns the number of keys written.
+//
+// To write all tabs you can also use SaveAsPS(name)
+//
+Int_t MStatusDisplay::SaveAsRoot(Int_t num, TString name)
+{
+    SetStatusLine1("Writing root file...");
+    SetStatusLine2("");
+
+    if (!CheckTabForCanvas(num))
+    {
+        SetStatusLine2("Failed!");
+        return 0;
+    }
+
+    AddExtension(name, "root", num);
+
+    TFile *fsave = gFile;
+    TFile file(name, "RECREATE", "MARS - Status Window Contents", 9);
+    const Int_t keys = Write(num);
+    gFile = fsave;
+
+    SetStatusLine2("Done.");
+
+    return keys;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Opens a save as dialog
+//
+Int_t MStatusDisplay::SaveAs(Int_t num)
+{
+    static const char *gSaveAsTypes[] =
+    {
+        "PostScript",   "*.ps",
+        "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 0;
+
+    dir = fi.fIniDir;
+
+    const TString name(fi.fFilename);
+
+    if (name.EndsWith(".root")) return SaveAsRoot(num, name);
+    if (name.EndsWith(".ps"))   return SaveAsPS(num, name);
+    if (name.EndsWith(".gif"))  return SaveAsGIF(num, name);
+    if (name.EndsWith(".C"))    return SaveAsC(num, name);
+
+    Warning("MStatusDisplay::SaveAs", "Unknown Extension: %s", fi.fFilename);
+    return 0;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Open contents of a MStatusDisplay with key name from file fname.
+//
+Int_t MStatusDisplay::Open(TString fname, const char *name)
+{
+    TFile file(fname, "READ");
+    if (file.IsZombie())
+    {
+        gLog << warn << "WARNING - Cannot open file " << fname << endl;
+        return 0;
+    }
+
+    return Read(name);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Opens an open dialog
+//
+Int_t MStatusDisplay::Open()
+{
+    static const char *gOpenTypes[] =
+    {
+        "ROOT files", "*.root",
+        "All files",  "*",
+        NULL,           NULL
+    };
+
+    static TString dir(".");
+
+    TGFileInfo fi; // fFileName and fIniDir deleted in ~TGFileInfo
+
+    fi.fFileTypes = (const char**)gOpenTypes;
+    fi.fIniDir    = StrDup(dir);
+
+    new TGFileDialog(fClient->GetRoot(), this, kFDSave, &fi);
+
+    if (!fi.fFilename)
+        return 0;
+
+    dir = fi.fIniDir;
+
+    return Open(fi.fFilename);
+}
+
+Bool_t MStatusDisplay::HandleConfigureNotify(Event_t *evt)
+{
+    //
+    // The initialization of the GUI is not yet enough finished...
+    //
+    if (!fTab)
+        return kTRUE;
+
+    UInt_t w = evt->fWidth;
+    UInt_t h = evt->fHeight;
+
+    /*
+     cout << "Old: " << GetWidth() << " " << GetHeight() << " " << GetBorderWidth() << endl;
+     cout << "New: " << w << " " << h << " ";
+     cout << "New: " << GetDefaultWidth() << " " << GetDefaultHeight() << " " << endl;
+     */
+
+    Bool_t wchanged = w!=GetWidth();
+    Bool_t hchanged = h!=GetHeight();
+
+    if (!wchanged && !hchanged)
+    {
+        Layout();
+        // FIXME: Make sure that this doesn't result in endless loops.
+        return kTRUE;
+    }
+
+
+    if (GetWidth()==1 && GetHeight()==1)
+        return kTRUE;
+
+    // calculate the constant part of the window
+    const UInt_t cw = GetWidth() -fTab->GetWidth();
+    const UInt_t ch = GetHeight()-fTab->GetHeight();
+
+    // calculate new size of frame (canvas @ 1:sqrt(2))
+    if (hchanged)
+        w = (UInt_t)((h-ch)*sqrt(2.)+.5)+cw;
+    else
+        h = (UInt_t)((w-cw)/sqrt(2.)+.5)+ch;
+
+    // resize frame
+    Resize(w, h);
+
+    return kTRUE;
+}
+
+Bool_t MStatusDisplay::HandleEvent(Event_t *event)
+{
+    Bool_t rc = TGMainFrame::HandleEvent(event);
+
+    //
+    // This fixes a bug in older root versions which makes
+    // TCanvas crash if gPad==NULL. So we make sure, that
+    // gPad!=NULL -- be carfull, this may have other side
+    // effects.
+    //
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,10,01)
+    if (!gPad && fTab)
+        for (int i=0; i<fTab->GetNumberOfTabs(); i++)
+        {
+            TCanvas *c = GetCanvas(i);
+            if (c)
+            {
+                c->cd();
+                gLog << dbg << "MStatusDisplay::HandleEvent - Workaround: gPad=" << gPad << "." << endl;
+                break;
+            }
+        }
+#endif
+
+    return rc;
+}
Index: /tags/Mars_V0-8-5/Mars/mbase/MStatusDisplay.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MStatusDisplay.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MStatusDisplay.h	(revision 9661)
@@ -0,0 +1,205 @@
+#ifndef MARS_MStatusDisplay
+#define MARS_MStatusDisplay
+
+#ifndef MARS_MAGIC
+#include "MAGIC.h"
+#endif
+
+#ifndef ROOT_TGFrame
+#include <TGFrame.h>
+#endif
+
+#ifndef ROOT_TTimer
+#include <TTimer.h>
+#endif
+
+class MLog;
+class MGList;
+class MParContainer;
+
+class TPad;
+class TTimer;
+class TMutex;
+class TCanvas;
+
+class TGTab;
+class TGTextView;
+class TGStatusBar;
+class TGProgressBar;
+class TGHProgressBar;
+class TGCompositeFrame;
+class TRootEmbeddedCanvas;
+
+class MStatusDisplay : public TGMainFrame
+{
+    friend class MStatusArray;
+public:
+    typedef enum {
+        // kFile
+        kFileBrowser, kFileCanvas, kFileOpen, kFileSave, kFileSaveAs, kFileSaveAsPS,
+        kFileSaveAsRoot, kFileSaveAsGIF, kFileSaveAsC, kFilePrint,
+        kFilePrinterName, kFileClose, kFileExit, kFileReset,
+        // kLoop
+        kLoopNone, kLoopStop,
+        // kTab
+        kTabSave, kTabSaveAs, kTabSaveAsPS, kTabSaveAsRoot, kTabSaveAsGIF,
+        kTabSaveAsC, kTabPrint, kTabNext, kTabPrevious, kTabRemove,
+        // kSize
+        kSize640, kSize800, kSize960, kSize1024, kSize1280,
+        // kLog
+        kLogCopy, kLogClear, kLogSelect, kLogFind, kLogSave, kLogAppend,
+        // kPic
+        kPicMagic, kPicMars,
+        // kGui
+        kSearch, kTabs
+    } Status_t;
+
+    enum
+    {
+        // TGMainFrame::kDontCallClose = BIT(14)
+        kExitLoopOnExit  = BIT(15),
+        kExitLoopOnClose = BIT(16)
+     };
+
+protected:
+    TString fName;  // status display identifier (name) (gROOT->FindObject())
+    TString fTitle; // status display title
+
+    MLog             *fLog;
+    MGList           *fList;
+    TGCompositeFrame *fUserFrame;
+
+    Bool_t ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2);
+
+private:
+    TGHProgressBar   *fBar;
+    TGTab            *fTab;
+    TGLayoutHints    *fLayCanvas;
+
+    TTimer  fTimer;
+    TMutex *fMutex;
+
+    TGStatusBar *fStatusBar;
+
+    Status_t fStatus;
+
+    TString fPrinter;
+
+    Int_t fLogIdx;
+    TTimer fLogTimer;
+    TGTextView *fLogBox;
+
+    FontStruct_t fFont;
+
+    UInt_t fIsLocked;
+
+    TList *fBatch;          //!
+
+    void AddMenuBar();
+    void AddUserFrame();
+    void AddTabs();
+    void AddProgressBar();
+    void AddStatusBar();
+    void AddMarsTab();
+    void AddLogTab();
+
+    TCanvas *GetCanvas(TGCompositeFrame *f) const;
+
+    Bool_t ProcessMessageCommandMenu(Long_t mp1);
+    Bool_t ProcessMessageCommand(Long_t submsg, Long_t mp1, Long_t mp2);
+    Bool_t ProcessMessageTextview(Long_t submsg, Long_t mp1, Long_t mp2);
+    Bool_t ProcessMessageUser(Long_t submsg, Long_t mp1, Long_t mp2);
+    void   CloseWindow();
+    Bool_t HandleConfigureNotify(Event_t *);
+    Bool_t HandleEvent(Event_t *event);
+
+    Bool_t HandleTimer(TTimer *timer=NULL);
+    void UpdateTab(TGCompositeFrame *f);
+
+    void DrawClonePad(TCanvas &newc, const TCanvas &oldc) const;
+    void CanvasSetFillColor(TPad &c, Int_t col) const;
+    Bool_t Display(const TObjArray &list);
+
+    void AddExtension(TString &name, const TString &ext, Int_t num) const;
+
+    void UpdatePSHeader(const TString &name) const;
+
+    void RemoveTab(int i);
+
+    TRootEmbeddedCanvas *GetEmbeddedCanvas(TGCompositeFrame *cf) const;
+
+public:
+     MStatusDisplay(Long_t t=1000);
+     virtual ~MStatusDisplay();
+
+     void SetLogStream(MLog *log, Bool_t enable=kFALSE);
+
+     void StartUpdate(Int_t millisec=-1);
+     void StopUpdate();
+     void SetUpdateTime(Long_t t);
+
+     void SetProgressBarPosition(Float_t p);
+     TGProgressBar *GetBar() const { return (TGProgressBar*)fBar; }
+
+     void SetStatusLine1(const char *txt);
+     void SetStatusLine2(const char *txt);
+     void SetStatusLine2(const MParContainer &cont);
+
+     void SetPrinter(const TString &lpr) { fPrinter = lpr; }
+
+     virtual void SetName(const char *name) { fName = name; }
+     virtual void SetTitle(const char *title="") { fTitle = title; }
+     virtual const char *GetName() const { return fName.Data(); }
+     virtual const char *GetTitle() const { return fTitle.Data(); }
+
+     TCanvas &AddTab(const char *name);
+     TGCompositeFrame *AddRawTab(const char *name);
+
+     Bool_t   HasCanvas(const TCanvas *c) const;
+     TCanvas *GetCanvas(int i) const;
+     TCanvas *GetCanvas(const TString &name) const;
+
+     Int_t Read(const char *name="MStatusDisplay");
+     Int_t Write(const char *name="MStatusDisplay", Int_t option=0, Int_t bufsize=0)
+     {
+         return Write(-1, name, option, bufsize);
+     }
+     Int_t Write(Int_t num, const char *name="MStatusDisplay", Int_t option=0, Int_t bufsize=0);
+
+     Bool_t CdCanvas(const TString &name);
+     void   Update() { HandleTimer(&fTimer); HandleTimer(&fLogTimer); }
+
+     void SetNoContextMenu(Bool_t flag=kTRUE);
+
+     Int_t  SaveAsPS(TString name="", const TString addon="") { return SaveAsPS(-1, name, addon); }
+     Bool_t SaveAsGIF(TString name="") { return SaveAsGIF(-1, name); }
+     Bool_t SaveAsC(TString name="") { return SaveAsC(-1, name); }
+     Int_t  SaveAsRoot(TString name="") { return SaveAsRoot(-1, name); }
+     Int_t  PrintToLpr() { return PrintToLpr(-1); }
+
+     Int_t  SaveAsPS(Int_t num, TString name="", const TString addon="");
+     Bool_t SaveAsGIF(Int_t num, TString name="");
+     Bool_t SaveAsC(Int_t num, TString name="");
+     Int_t  SaveAsRoot(Int_t num, TString name="");
+     Int_t  PrintToLpr(Int_t num);
+
+     Int_t  SaveAs(Int_t num=-1);
+     Int_t  Open(TString fname, const char *name="MStatusDisplay");
+     Int_t  Open();
+
+     Status_t CheckStatus() const { return fStatus; }
+     void ClearStatus() { fStatus = kLoopNone; }
+
+     void Lock() { fIsLocked++; }
+     void UnLock() { if (fIsLocked>0) fIsLocked--; }
+
+     void Reset();
+
+     Bool_t CheckTabForCanvas(int num) const;
+
+     void EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected);
+
+     ClassDef(MStatusDisplay, 0)   // Window for a status display
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mbase/MString.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MString.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MString.cc	(revision 9661)
@@ -0,0 +1,88 @@
+/*====================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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, 3/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MString
+// =======
+//
+// If you are using root Form() command you must be aware of the fact that
+// it uses a global buffer. This buffer is recreated depending on the
+// length which is necessary to form the string. This recreation is not
+// thread safe and it might result in crashes if used in multi-threaded
+// environments.
+//
+// To get around this problem MString implements a Print() member function
+// which form a string like Form does. This formation is done in a
+// internal buffer. Because this buffer must be recreated and
+// deleted each time Print() is called this might be slower than Form().
+// The advantage is, that the buffer is not global and a call to Print()
+// from different threads is safe. However accessing the same
+// M/TString-object must still be locked with a mutex.
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MString.h"
+
+ClassImp(MString);
+
+// --------------------------------------------------------------------------
+//
+// Thread safe replacement for Form, use it like:
+//
+//  MString string;
+//  string.Print("MyString has %d bytes", 128);
+//
+// As a special feature the function returns the reference to the MString
+// so that you can directly work with it, eg.
+//
+//  string.Print("  MyString has %d bytes  ", 128).Strip(TString::kBoth);
+//
+MString &MString::Print(const char *fmt, ...)
+{
+    va_list ap;
+    va_start(ap, fmt);
+
+    Int_t n=256;
+
+    char *ret=0;
+
+    while (1)
+    {
+        ret = new char[n+1];
+        Int_t sz = vsnprintf(ret, n, fmt, ap);
+        if (sz<=n)
+            break;
+
+        n *= 2;
+        delete [] ret;
+    };
+
+    va_end(ap);
+
+    *static_cast<TString*>(this) = ret;
+
+    delete [] ret;
+
+    return *this;
+}
Index: /tags/Mars_V0-8-5/Mars/mbase/MString.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MString.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MString.h	(revision 9661)
@@ -0,0 +1,19 @@
+#ifndef MARS_MString
+#define MARS_MString
+
+#ifndef ROOT_TString
+#include <TString.h>
+#endif
+
+#include <stdio.h>
+#include <stdarg.h>
+
+class MString : public TString
+{
+public:
+    MString &Print(const char *fmt, ...);
+
+    ClassDef(MString, 1) // Tool to make Form() thread safe against other TStrings
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mbase/MTask.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MTask.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MTask.cc	(revision 9661)
@@ -0,0 +1,484 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//   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. If you want
+//                     to stop the eventloop and wants the eventloop to
+//                     return the status 'failed' return kERROR.
+//
+//   - ReInit()        The idea is, that
+//                       a) we have one file per run
+//                       b) each file contains so called run-headers which
+//                          stores information 'per run', eg MRawRunHeader
+//                          or the bad pixels
+//                       c) this information must be evaluated somehow each
+//                          time a new file is opened.
+//
+//                     If you use MReadMarsFile or MCT1ReadPreProc it is
+//                     called each time a new file has been opened and the
+//                     new run headers have been read before the first
+//                     event of these file is preprocessed.
+//
+//   - PostProcess():  executed after the eventloop. Here you can close
+//                     output files, start display of the run parameter,
+//                     etc. PostProcess is only executed in case of
+//                     PreProcess was successfull (returned kTRUE)
+//
+//
+//  Remark: Using a MTask in your tasklist doesn't make much sense,
+//          because it is doing nothing. However it is a nice tool
+//          to count something (exspecially if used together with a
+//          filter)
+//
+//
+//  Version 1:
+//  ----------
+//   - first version
+//
+//  Version 2:
+//  ----------
+//   - added fSerialNumber
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MTask.h"
+
+#include <fstream>
+
+#include <TBaseClass.h> // OverwritesProcess
+#include <TStopwatch.h> // TStopwatch
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MFilter.h"
+#include "MStatusDisplay.h"
+
+ClassImp(MTask);
+
+using namespace std;
+
+MTask::MTask(const char *name, const char *title)
+    : fFilter(NULL), fSerialNumber(0), fIsPreprocessed(kFALSE),
+    fStopwatch(0)
+{
+    fName  = name  ? name  : "MTask";
+    fTitle = title ? title : "Base class for all tasks (dummy task).";
+
+    fListOfBranches = new TList;
+    fListOfBranches->SetOwner();
+
+    fStopwatch = new TStopwatch;
+}
+
+MTask::~MTask()
+{
+    delete fStopwatch;
+    delete fListOfBranches;
+}
+
+// --------------------------------------------------------------------------
+//
+// This adds a branch to the list for the auto enabeling schmeme.
+// This makes it possible for MReadTree to decide which branches
+// are really needed for the eventloop. Only the necessary branches
+// are read from disk which speeds up the calculation enormously.
+//
+// You can use TRegExp expressions like "*.fEnergy", but the
+// recommended method is to call this function for exactly all
+// branches you want to have, eg:
+//  AddToBranchList("MMcTrig.fNumFirstLevel");
+//  AddToBranchList("MMcTrig;1.fNumFirstLevel");
+//  AddToBranchList("MMcTrig;2.fNumFirstLevel");
+//
+// We agreed on the convetion, that all branches are stored with
+// a trailing dot '.' so that always the Master Branch name
+// (eg. MMcTrig) is part of the branch name.
+//
+// Remark: The common place to call AddToBranchList is the
+//         constructor of the derived classes (tasks)
+//
+void MTask::AddToBranchList(const char *b)
+{
+    if (fListOfBranches->FindObject(b))
+        return;
+
+    fListOfBranches->Add(new TNamed(b, ""));
+}
+
+// --------------------------------------------------------------------------
+//
+// Using this overloaded member function you may cascade several branches
+// in acomma seperated list, eg: "MMcEvt.fTheta,MMcEvt.fEnergy"
+//
+// For moredetailed information see AddToBranchList(const char *b);
+//
+void MTask::AddToBranchList(const TString &str)
+{
+    TString s = str;
+
+    while (!s.IsNull())
+    {
+        Int_t fst = s.First(',');
+
+        if (fst<0)
+            fst = s.Length();
+
+        AddToBranchList((const char*)TString(s(0, fst)));
+
+        s.Remove(0, fst+1);
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Copy constructor.
+//
+MTask::MTask(MTask &t)
+{
+    fFilter = t.fFilter;
+    fListOfBranches->AddAll(t.fListOfBranches);
+}
+
+// --------------------------------------------------------------------------
+//
+// Mapper function for PreProcess.
+// Sets the preprocessed flag dependend on the return value of PreProcess.
+// Resets number of executions and cpu consumtion timer.
+//
+Int_t MTask::CallPreProcess(MParList *plist)
+{
+    fStopwatch->Reset();
+
+    *fLog << all << fName << "... " << flush;
+    if (fDisplay)
+        fDisplay->SetStatusLine2(*this);
+
+    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.
+// Count cpu consumtion time.
+//
+Int_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->IsConditionTrue() : kTRUE;
+
+    if (!exec)
+        return kTRUE;
+
+    fStopwatch->Start(kFALSE);
+    const Int_t rc = Process();
+    fStopwatch->Stop();
+
+    return rc;
+}
+
+// --------------------------------------------------------------------------
+//
+// Mapper function for PreProcess.
+// Calls Postprocess dependent on the state of the preprocessed flag,
+// resets this flag.
+//
+Int_t MTask::CallPostProcess()
+{
+    if (!fIsPreprocessed)
+        return kTRUE;
+
+    fIsPreprocessed = kFALSE;
+
+    *fLog << all << fName << "... " << flush;
+    if (fDisplay)
+        fDisplay->SetStatusLine2(*this);
+
+    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
+//
+Int_t MTask::PreProcess(MParList *pList)
+{
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// This is processed for every event in the eventloop
+//
+// the virtual implementation returns kTRUE
+//
+Int_t MTask::Process()
+{
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// This is processed after the eventloop starts
+//
+// the virtual implementation returns kTRUE
+//
+Int_t MTask::PostProcess()
+{
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the name of the object. If the name of the object is not the
+// class name it returns the object name and in []-brackets the class name.
+// If a serial number is set (!=0) the serial number is added to the
+// name (eg. ;1)
+//
+const char *MTask::GetDescriptor() const
+{
+    //
+    // Because it returns a (const char*) we cannot return a casted
+    // local TString. The pointer would - immediatly after return -
+    // point to a random memory segment, because the TString has gone.
+    //
+    if (fName==ClassName())
+        return fSerialNumber==0 ? ClassName() : Form("%s;%d", ClassName(), fSerialNumber);
+
+    return fSerialNumber>0 ?
+        Form("%s;%d [%s]", fName.Data(), fSerialNumber, ClassName()) :
+        Form("%s [%s]", fName.Data(), ClassName());
+}
+
+// --------------------------------------------------------------------------
+//
+//  Return the total number of calls to Process(). If Process() was not
+//  called due to a set filter this is not counted.
+//
+UInt_t MTask::GetNumExecutions() const
+{
+    return (UInt_t)fStopwatch->Counter()-1;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Return total CPU execution time in seconds of calls to Process().
+//  If Process() was not called due to a set filter this is not counted.
+//
+Double_t MTask::GetCpuTime() const
+{
+    return fStopwatch->CpuTime();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Return total real execution time in seconds of calls to Process().
+//  If Process() was not called due to a set filter this is not counted.
+//
+Double_t MTask::GetRealTime() const
+{
+    return fStopwatch->RealTime();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Prints the relative time spent in Process() (relative means relative to
+//  its parent Tasklist) and the number of times Process() was executed.
+//  Don't wonder if the sum of the tasks in a tasklist is not 100%,
+//  because only the call to Process() of the task is measured. The
+//  time of the support structure is ignored. The faster your analysis is
+//  the more time is 'wasted' in the support structure.
+//  Only the CPU time is displayed. This means that exspecially task
+//  which have a huge part of file i/o will be underestimated in their
+//  relative wasted time.
+//  For convinience the lvl argument results in a number of spaces at the
+//  beginning of the line. So that the structur of a tasklist can be
+//  identified. If a Tasklist or task has filter applied the name of the
+//  filter is printer in <>-brackets behind the number of executions.
+//  Use MTaskList::PrintStatistics without an argument.
+//  For tasks which don't overwrite Process() no action is perfomed.
+//
+void MTask::PrintStatistics(const Int_t lvl, Bool_t title, Double_t time) const
+{
+    if (!OverwritesProcess() && IsA()!=MTask::Class())
+        return;
+
+    *fLog << all << setfill(' ') << setw(lvl) << " ";
+
+    if (GetCpuTime()>0 && time>0 && GetCpuTime()>=0.001*time)
+        *fLog << Form("%5.1f", GetCpuTime()/time*100) << "% ";
+    else
+        *fLog << "       ";
+    *fLog << GetDescriptor() << "\t";
+    *fLog << dec << GetNumExecutions();
+    if (fFilter)
+        *fLog << " <" << fFilter->GetName() << ">";
+    if (title)
+        *fLog << "\t" << fTitle;
+    *fLog << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// First call MParContainer::SavePrimitive which should stream the primitive
+// to the output stream. Then, if a filter is set, stream first the filter
+// and afterwards set the filter for this task.
+//
+void MTask::SavePrimitive(ofstream &out, Option_t *o)
+{
+    MParContainer::SavePrimitive(out);
+    if (!fFilter)
+        return;
+
+    /*
+     If we don't stream filter which are not in the task list itself
+     (which means: already streamed) we may be able to use
+     SavePrimitive as some kind of validity check for the macros
+
+     fFilter->SavePrimitive(out);
+     */
+    out << "   " << GetUniqueName() << ".SetFilter(&" << fFilter->GetUniqueName() <<");" << endl;
+    if (fSerialNumber>0)
+        out << "   " << GetUniqueName() << ".SetSerialNumber(" << fSerialNumber <<");" << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Check whether the class given in the argument overwrites MTask::Process.
+// This function calls itself recursively. If you want to call it,
+// leave out the argument.
+//
+Bool_t MTask::OverwritesProcess(TClass *cls) const
+{
+    if (!cls)
+        cls = IsA();
+
+    //
+    // Check whether we reached the base class MTask
+    //
+    if (cls==MTask::Class())
+        return kFALSE;
+
+    //
+    // Check whether the class cls overwrites Process
+    //
+    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 (OverwritesProcess(base->GetClassPointer()))
+            return kTRUE;
+    }
+
+    return kFALSE;
+}
+
+void MTask::SetDisplay(MStatusDisplay *d)
+{
+    if (fFilter)
+        fFilter->SetDisplay(d);
+    MParContainer::SetDisplay(d);
+}
Index: /tags/Mars_V0-8-5/Mars/mbase/MTask.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MTask.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MTask.h	(revision 9661)
@@ -0,0 +1,110 @@
+#ifndef MARS_MTask
+#define MARS_MTask
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MTask                                                                   //
+//                                                                         //
+// Abstract base class for a task                                          //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MInputStreamID
+#include "MInputStreamID.h"
+#endif
+
+class TList;
+class TStopwatch;
+
+class MFilter;
+class MParList;
+
+class MTask : public MInputStreamID
+{
+private:
+    TList *fListOfBranches; //! List of Branch names for auto enabeling scheme
+
+    MFilter *fFilter;       // Filter for conditional task execution
+    Byte_t   fSerialNumber; // Serial number having more than one detector of the same type
+
+    Bool_t fIsPreprocessed; //! Indicates the success of the PreProcessing (set by MTaskList)
+
+    TStopwatch *fStopwatch; //! Count the execution time and number of executions
+
+    virtual Int_t PreProcess(MParList *pList);
+    virtual Int_t Process();
+    virtual Int_t PostProcess();
+
+protected:
+    void AddToBranchList(const char *b);
+    void AddToBranchList(const TString &str);
+    void AddToBranchList(const char *master, const char *sub, const UInt_t first, const UInt_t last)
+    {
+        if (first==0 && last==0)
+        {
+            AddToBranchList(sub);
+            return;
+        }
+
+        for (unsigned int i=first; i<last+1; i++)
+            AddToBranchList(Form("%s;%d.%s", master, i, sub));
+    }
+    void AddToBranchList(TString &master, TString &sub, const UInt_t first, const UInt_t last)
+    {
+        AddToBranchList((const char*)master, (const char*)sub, first, last);
+    }
+    void AddToBranchList(const char *master, const char *sub, const UInt_t num)
+    {
+        AddToBranchList(master, sub, 0, num);
+    }
+    void AddToBranchList(TString &master, TString &sub, const UInt_t num)
+    {
+        AddToBranchList(master, sub, 0, num);
+    }
+
+public:
+    MTask(const char *name=NULL, const char *title=NULL);
+    MTask(MTask &t);
+    virtual ~MTask();
+
+    const TList *GetListOfBranches() const { return fListOfBranches; }
+    Bool_t OverwritesProcess(TClass *cls=NULL) const;
+
+    // Filter functions
+    virtual void SetFilter(MFilter *filter) { fFilter=filter; }
+    const MFilter *GetFilter() const        { return fFilter; }
+    MFilter *GetFilter()                    { return fFilter; } // for MContinue only
+
+    // Display functions
+    void SetDisplay(MStatusDisplay *d);
+
+    // Function for parallel executions
+    static TString AddSerialNumber(const char *str, UInt_t num) { TString s(str); if (num==0) return s; s += ";"; s += num; return s; }
+    static TString AddSerialNumber(const TString &str, UInt_t num) { return AddSerialNumber((const char*)str, num); }
+    TString AddSerialNumber(const char *str) const { return AddSerialNumber(str, fSerialNumber); }
+    TString AddSerialNumber(const TString &str) const { return AddSerialNumber(str, fSerialNumber); }
+
+    virtual void SetSerialNumber(Byte_t num) { fSerialNumber = num;  }
+    Byte_t GetSerialNumber() const           { return fSerialNumber; }
+
+    const char *GetDescriptor() const;
+
+    // Task execution statistics
+    UInt_t   GetNumExecutions() const;
+    Double_t GetCpuTime() const;
+    Double_t GetRealTime() const;
+    virtual void PrintStatistics(const Int_t lvl=0, Bool_t title=kFALSE, Double_t time=0) const;
+
+    // Task overwrite functions
+    virtual Bool_t ReInit(MParList *pList);
+
+    virtual Int_t CallPreProcess(MParList *plist);
+    virtual Int_t CallProcess();
+    virtual Int_t CallPostProcess();
+
+    void SavePrimitive(ofstream &out, Option_t *o="");
+
+    ClassDef(MTask, 2) //Abstract base class for a task
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mbase/MTaskInteractive.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MTaskInteractive.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MTaskInteractive.cc	(revision 9661)
@@ -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, 6/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MTaskInteractive
+//
+// If you want to create a new task inside a macro you will have to compile
+// your macro using macro.C++, because the root interpreter cannot use
+// uncompiled classes. To workaround this problem you can write simple
+// funcions (which can be handled by CINT) and use MTaskInteractive.
+//
+// This is a simple way to develop new code in a macro without need
+// to compile it.
+//
+// Example:
+//    Int_t Process()
+//    {
+//       gLog << "Processing..." << endl;
+//       return kTRUE;
+//    }
+//
+//    void main()
+//    {
+//       MTaskInteractive task;
+//       task.SetProcess(Process);
+//       MTaskList list;
+//       list.AddToList(&task);
+//    }
+//
+//
+//  Input Containers:
+//   -/-
+//
+//  Output Containers:
+//   -/-
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MTaskInteractive.h"
+
+#include <Api.h>
+#include <TMethodCall.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MTaskInteractive);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor. Takes name and title of the interactive task
+//
+MTaskInteractive::MTaskInteractive(const char *name, const char *title) :
+    fPreProcess(NULL), fProcess(NULL), fPostProcess(NULL)
+{
+    fName  = name  ? name  : "MTaskInteractive";
+    fTitle = title ? title : "Interactive task";
+
+    fCall[0] = 0;
+    fCall[1] = 0;
+    fCall[2] = 0;
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor. Free all resources.
+//
+MTaskInteractive::~MTaskInteractive()
+{
+    Free(0);
+    Free(1);
+    Free(2);
+}
+
+// --------------------------------------------------------------------------
+//
+// Calls the function and returns its return value.
+// Called by PreProcess, Process, PostProcess and ReInit.
+//
+inline Int_t MTaskInteractive::Return(Int_t no, void *params)
+{
+    // Static function called when SetFCN is called in interactive mode
+    if (!fCall[no])
+    {
+        gLog << err << dbginf << "Return(" << no << ") - TMethodCall not set." << endl;
+        return kFALSE;
+    }
+
+    Long_t result;
+    fCall[no]->SetParamPtrs(params);
+    fCall[no]->Execute(result);
+
+    return result;
+}
+
+// --------------------------------------------------------------------------
+//
+// Generalized function to set the functions of your interactive task.
+// Called by SetPreProcess, SetProcess, SetPostProcess and SetReInit
+//
+Bool_t MTaskInteractive::Set(void *fcn, Int_t no, const char *params)
+{
+    // this function is called by CINT instead of the function above
+    if (!fcn)
+        return kFALSE;
+
+    char *funcname = G__p2f2funcname(fcn);
+    if (!funcname)
+        return kFALSE;
+
+    Free(no);
+
+    fCall[no] = new TMethodCall;
+    fCall[no]->InitWithPrototype(funcname, params);
+
+    gLog << inf << GetDescriptor() << ": Using " << funcname << " as ";
+    switch (no)
+    {
+    case 0:
+        gLog << "Pre";
+        break;
+    case 2:
+        gLog << "Post";
+        break;
+
+    }
+    gLog << "Process-function." << endl;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//
+//
+void MTaskInteractive::Free(Int_t no)
+{
+    if (!fCall[no])
+        return;
+    delete fCall[no];
+    fCall[no] = 0;
+}
Index: /tags/Mars_V0-8-5/Mars/mbase/MTaskInteractive.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MTaskInteractive.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MTaskInteractive.h	(revision 9661)
@@ -0,0 +1,45 @@
+#ifndef MARS_MTaskInteractive
+#define MARS_MTaskInteractive
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MFilter;
+class MTaskList;
+
+class MTaskInteractive : public MTask
+{
+private:
+    TMethodCall *fCall[3];
+
+    Int_t (*fPreProcess)(MParList *list);
+    Int_t (*fProcess)();
+    Int_t (*fPostProcess)();
+
+    Int_t PreProcess(MParList *list) { if (fCall[0]) return Return(0, &list); return fPreProcess  ? (*fPreProcess)(list) : kTRUE; }
+    Int_t Process()                  { if (fCall[1]) return Return(1);        return fProcess     ? (*fProcess)()        : kTRUE; }
+    Int_t PostProcess()              { if (fCall[2]) return Return(2);        return fPostProcess ? (*fPostProcess)()    : kTRUE; }
+
+    Int_t Return(Int_t no, void *param=NULL);
+    Bool_t Set(void *fcn, Int_t no, const char *params);
+    void   Free(Int_t no);
+
+public:
+    MTaskInteractive(const char *name=NULL, const char *title=NULL);
+    ~MTaskInteractive();
+
+    // This is to be used in compiled code
+    void SetPreProcess(Int_t (*func)(MParList *list)) { fPreProcess = func;  Free(0); }
+    void SetProcess(Int_t (*func)())                  { fProcess = func;     Free(1);  }
+    void SetPostProcess(Int_t (*func)())              { fPostProcess = func; Free(2);  }
+
+    // This is for usage in CINT
+    void SetPreProcess(void *fcn)  { Set(fcn, 0, "MParList*"); fPreProcess =0; }
+    void SetProcess(void *fcn)     { Set(fcn, 1, "");          fProcess    =0; }
+    void SetPostProcess(void *fcn) { Set(fcn, 2, "");          fPostProcess=0; }
+
+    ClassDef(MTaskInteractive, 0) // Interactive task
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mbase/MTaskList.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MTaskList.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MTaskList.cc	(revision 9661)
@@ -0,0 +1,844 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// 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.
+//
+// Remark: The Process function is only executed if the class of your task
+//         overloads Process() or if the task itself is a MTask. This
+//         means if you have a task without Process() (only PreProcess
+//         and PostProcess no time is lost during execution)
+//
+// Warning:
+//  Be carefull if you are writing your tasklist
+//  (eg. MWriteRootFile("file.root", "MTaskList")) to a file. You may
+//  not be able to initialize a new working tasklist from a file if
+//   a) Two Paramerer containers with the same names are existing in the
+//      MParList.
+//   b) You used a container somewhere which is not part of MParList.
+//      (eg. You specified a pointer to a MH container in MFillH which is
+//      not added to the parameter list.
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MTaskList.h"
+
+#include <fstream>           // ofstream, SavePrimitive
+
+#include <TSystem.h>         // gSystem
+#include <TOrdCollection.h>  // TOrdCollection
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MIter.h"
+#include "MFilter.h"
+#include "MParList.h"
+#include "MInputStreamID.h"
+
+#include "MStatusDisplay.h"
+
+ClassImp(MTaskList);
+
+using namespace std;
+
+const TString MTaskList::gsDefName  = "MTaskList";
+const TString MTaskList::gsDefTitle = "A list for tasks to be executed";
+
+// --------------------------------------------------------------------------
+//
+// the name for the task list must be the same for all task lists
+// because the task list (at the moment) is identified by exactly
+// this name in the parameter list (by MEvtLoop::SetParList)
+//
+MTaskList::MTaskList(const char *name, const char *title)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+
+    fTasks = new TList;
+
+    gROOT->GetListOfCleanups()->Add(fTasks);
+    gROOT->GetListOfCleanups()->Add(&fTasksProcess);
+    fTasks->SetBit(kMustCleanup);
+    fTasksProcess.SetBit(kMustCleanup);
+}
+
+// --------------------------------------------------------------------------
+//
+//   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);
+    MTask::SetLogStream(log);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Set the display for the all tasks in the list and the tasklist itself.
+//
+void MTaskList::SetDisplay(MStatusDisplay *d)
+{
+    fTasks->ForEach(MTask, SetDisplay)(d);
+    MTask::SetDisplay(d);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Set the serial number for the all tasks in the list and the tasklist
+//  itself.
+//
+void MTaskList::SetSerialNumber(Byte_t num)
+{
+    fTasks->ForEach(MTask, SetSerialNumber)(num);
+    MTask::SetSerialNumber(num);
+}
+
+Bool_t MTaskList::CheckAddToList(MTask *task, const char *type, const MTask *where) const
+{
+    //
+    // Sanity check
+    //
+    if (!task)
+    {
+        *fLog << err << "ERROR - task argument=NULL." << endl;
+        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)
+        return kTRUE;
+
+    if (fTasks->FindObject(where))
+        return kTRUE;
+
+    *fLog << err << dbginf << "Error: Cannot find task after which the new task should be scheduled!" << endl;
+    return kFALSE;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// schedule task for execution, before 'where'.
+// 'type' is the event type which should be processed
+//
+Bool_t MTaskList::AddToListBefore(MTask *task, const MTask *where, const char *type)
+{
+    // FIXME: We agreed to put the task into list in an ordered way.
+    if (!CheckAddToList(task, type, where))
+        return kFALSE;
+
+    *fLog << inf << "Adding " << task->GetName() << " to " << GetName() << " for " << type << "... " << flush;
+    task->SetStreamId(type);
+    task->SetBit(kMustCleanup);
+    fTasks->AddBefore((TObject*)where, task);
+    *fLog << "Done." << endl;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// schedule task for execution, after 'where'.
+// 'type' is the event type which should be processed
+//
+Bool_t MTaskList::AddToListAfter(MTask *task, const MTask *where, const char *type)
+{
+    // FIXME: We agreed to put the task into list in an ordered way.
+
+    if (!CheckAddToList(task, type, where))
+        return kFALSE;
+
+    *fLog << inf << "Adding " << task->GetName() << " to " << GetName() << " for " << type << "... " << flush;
+    task->SetStreamId(type);
+    task->SetBit(kMustCleanup);
+    fTasks->AddAfter((TObject*)where, task);
+    *fLog << "Done." << endl;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// schedule task for execution, 'type' is the event type which should
+// be processed
+//
+Bool_t MTaskList::AddToList(MTask *task, const char *type)
+{
+    // FIXME: We agreed to put the task into list in an ordered way.
+
+    if (!CheckAddToList(task, type))
+        return kFALSE;
+
+    *fLog << inf << "Adding " << task->GetName() << " to " << GetName() << " for " << type << "... " << flush;
+    task->SetStreamId(type);
+    task->SetBit(kMustCleanup);
+    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);
+}
+
+// --------------------------------------------------------------------------
+//
+//  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;
+}
+
+// --------------------------------------------------------------------------
+//
+//  do pre processing (before eventloop) of all tasks in the task-list
+//  Only if a task overwrites the Process function the 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.
+//
+Int_t MTaskList::PreProcess(MParList *pList)
+{
+    *fLog << all << "Preprocessing... " << flush;
+    if (fDisplay)
+    {
+        // Set status lines
+        fDisplay->SetStatusLine1("PreProcessing...");
+        fDisplay->SetStatusLine2("");
+    }
+
+    fParList = pList;
+
+    //
+    // Make sure, that the ReadyToSave flag is not reset from a tasklist
+    // running as a task in another tasklist.
+    //
+    const Bool_t noreset = fParList->TestBit(MParList::kDoNotReset);
+    if (!noreset)
+        fParList->SetBit(MParList::kDoNotReset);
+
+    //
+    //  create the Iterator over the tasklist
+    //
+    TIter Next(fTasks);
+
+    MTask *task=NULL;
+
+    //
+    // loop over all tasks for preproccesing
+    //
+    while ((task=(MTask*)Next()))
+    {
+        //
+        // PreProcess the task and check for it's return value.
+        //
+        switch (task->CallPreProcess(fParList))
+        {
+        case kFALSE:
+            return kFALSE;
+
+        case kTRUE:
+            // Handle GUI events (display changes, mouse clicks)
+            if (fDisplay)
+                gSystem->ProcessEvents();
+            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;
+
+    //
+    // Reset the ReadyToSave flag.
+    //
+    if (!noreset)
+    {
+        fParList->SetReadyToSave(kFALSE);
+        fParList->ResetBit(MParList::kDoNotReset);
+    }
+
+    //
+    // loop over all tasks to fill fTasksProcess
+    //
+    Next.Reset();
+    fTasksProcess.Clear();
+    while ((task=(MTask*)Next()))
+        if (task->IsA()==MTask::Class() || task->OverwritesProcess())
+            fTasksProcess.Add(task);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  do reinit of all tasks in the task-list
+//
+Bool_t MTaskList::ReInit(MParList *pList)
+{ 
+    *fLog << all << "Reinit... " << flush;
+
+    if (!pList)
+        pList = fParList;
+
+    //
+    // Make sure, that the ReadyToSave flag is not reset from a tasklist
+    // running as a task in another tasklist.
+    //
+    const Bool_t noreset = pList->TestBit(MParList::kDoNotReset);
+    if (!noreset)
+        pList->SetBit(MParList::kDoNotReset);
+
+    //
+    //  create the Iterator over the tasklist
+    //
+    TIter Next(fTasks);
+
+    MTask *task=NULL;
+
+    //
+    // loop over all tasks for reinitialization
+    //
+    while ((task=(MTask*)Next()))
+    {
+        *fLog << all << task->GetName() << "... " << flush;
+
+        if (!task->ReInit(pList/*?pList:fParList*/))
+        {
+            *fLog << err << "ERROR - ReInit of Task '" << task->GetDescriptor() << "' failed." << endl;
+            return kFALSE;
+        }
+    }
+
+    *fLog << all << endl;
+
+    //
+    // Reset the ReadyToSave flag.
+    //
+    if (!noreset)
+    {
+        pList->SetReadyToSave(kFALSE);
+        pList->ResetBit(MParList::kDoNotReset);
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// do the event execution of all tasks in the task-list
+//
+Int_t MTaskList::Process()
+{
+    //
+    // Check whether there is something which can be processed, otherwise
+    // stop the eventloop.
+    //
+    if (fTasksProcess.GetSize()==0)
+    {
+        *fLog << warn << "Warning: No entries in " << GetDescriptor() << " for Processing." << endl;
+        return kFALSE;
+    }
+
+    //
+    // Reset the ReadyToSave flag.
+    // Reset all containers.
+    //
+    // Make sure, that the parameter list is not reset from a tasklist
+    // running as a task in another tasklist.
+    //
+    const Bool_t noreset = fParList->TestBit(MParList::kIsProcessing);
+    if (!noreset)
+    {
+        fParList->SetBit(MParList::kIsProcessing);
+        fParList->Reset();
+    }
+
+    //
+    //  create the Iterator for the TaskList
+    //
+    TIter Next(&fTasksProcess);
+    MTask *task=NULL;
+
+    //
+    // loop over all tasks for processing
+    //
+    Bool_t rc = kTRUE;
+    while ( (task=(MTask*)Next()) )
+    {
+        //
+        // if the task has the wrong stream id skip it.
+        //
+        if (GetStreamId() != task->GetStreamId() &&
+            task->GetStreamId() !=  "All")
+            continue;
+
+        //
+        // if it has the right stream id execute the CallProcess() function
+        // and check what the result of it is.
+        // The CallProcess() function increases the execution counter and
+        // calls the Process() function dependent on the existance and
+        // return value of a filter.
+        //
+        switch (task->CallProcess())
+        {
+        case kTRUE:
+            //
+            // everything was OK: go on with the next task
+            //
+            continue;
+
+        case kFALSE:
+            //
+            // an error occured: stop eventloop
+            //
+            rc = kFALSE;
+            *fLog << inf << task->GetDescriptor() << " has stopped execution of " << GetDescriptor() << "." << endl;
+            break;
+
+        case kERROR:
+            //
+            // an error occured: stop eventloop and return: failed
+            //
+            *fLog << err << dbginf << "Fatal error occured... stopped." << endl;
+            rc = kERROR;
+            break;
+
+        case kCONTINUE:
+            //
+            // something occured: skip the rest of the tasks for this event
+            //
+            rc = kTRUE;
+            break;
+
+        default:
+            *fLog << warn << dbginf << "Unknown return value from MTask::Process()... ignored." << endl;
+            continue;
+        }
+        break;
+    }
+
+    if (!noreset)
+    {
+        fParList->SetReadyToSave(kFALSE);
+        fParList->ResetBit(MParList::kIsProcessing);
+    }
+
+    return rc;
+}
+
+// --------------------------------------------------------------------------
+//
+//  do post processing (before eventloop) of all tasks in the task-list
+//  only tasks which have successfully been preprocessed are postprocessed.
+//
+Int_t MTaskList::PostProcess()
+{
+    *fLog << all << "Postprocessing... " << flush;
+    if (fDisplay)
+    {
+        // Set status lines
+        fDisplay->SetStatusLine1("PostProcessing...");
+        fDisplay->SetStatusLine2("");
+    }
+
+    //
+    // Make sure, that the ReadyToSave flag is not reset from a tasklist
+    // running as a task in another tasklist.
+    //
+    const Bool_t noreset = fParList->TestBit(MParList::kDoNotReset);
+    if (!noreset)
+    {
+        fParList->SetBit(MParList::kDoNotReset);
+        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;
+
+        // Handle GUI events (display changes, mouse clicks)
+        if (fDisplay)
+            gSystem->ProcessEvents();
+    }
+
+    *fLog << all << endl;
+
+    //
+    // Reset the ReadyToSave flag.
+    //
+    if (!noreset)
+    {
+        fParList->SetReadyToSave(kFALSE);
+        fParList->ResetBit(MParList::kDoNotReset);
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Prints the number of times all the tasks in the list has been.
+//  For convinience the lvl argument results in a number of spaces at the
+//  beginning of the line. So that the structur of a tasklist can be
+//  identified. If a Tasklist or task has filter applied the name of the
+//  filter is printer in <>-brackets behind the number of executions.
+//  Use MTaskList::PrintStatistics without an argument.
+//
+void MTaskList::PrintStatistics(const Int_t lvl, Bool_t title, Double_t time) const
+{
+    if (lvl==0)
+    {
+        *fLog << all << underline << "Process execution Statistics:" << endl;
+        *fLog << GetDescriptor();
+        if (GetFilter())
+            *fLog << " <" << GetFilter()->GetName() << ">";
+        if (title)
+            *fLog << "\t" << fTitle;
+        if (time>=0)
+            *fLog << Form(" %5.1f", GetCpuTime()/time*100) << "%";
+        else
+            *fLog << " 100.0%";
+        *fLog << endl;
+    }
+    else
+        MTask::PrintStatistics(lvl, title, time);
+
+    //
+    //  create the Iterator for the TaskList
+    //
+    fTasks->ForEach(MTask, PrintStatistics)(lvl+1, title, GetCpuTime());
+
+    if (lvl==0)
+        *fLog << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Call 'Print()' of all tasks
+//
+void MTaskList::Print(Option_t *t) const
+{
+    *fLog << all << underline << GetDescriptor() << ":" << endl;
+
+    fTasks->Print();
+
+    *fLog << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
+void MTaskList::StreamPrimitive(ofstream &out) const
+{
+    out << "   MTaskList " << GetUniqueName();
+    if (fName!=gsDefName || fTitle!=gsDefTitle)
+    {
+        out << "(\"" << fName << "\"";
+        if (fTitle!=gsDefTitle)
+            out << ", \"" << fTitle << "\"";
+        out <<")";
+    }
+    out << ";" << endl << endl;
+
+    MIter Next(fTasks);
+
+    MParContainer *cont = NULL;
+    while ((cont=Next()))
+    {
+        cont->SavePrimitive(out, "");
+        out << "   " << GetUniqueName() << ".AddToList(&";
+        out << cont->GetUniqueName() << ");" << endl << endl;
+    }
+}
+
+void MTaskList::GetNames(TObjArray &arr) const
+{
+    MParContainer::GetNames(arr);
+    fTasks->ForEach(MParContainer, GetNames)(arr);
+}
+
+void MTaskList::SetNames(TObjArray &arr)
+{
+    MParContainer::SetNames(arr);
+    fTasks->ForEach(MParContainer, SetNames)(arr);
+}
+
+// --------------------------------------------------------------------------
+//
+// Read the contents/setup of a parameter container/task from a TEnv
+// instance (steering card/setup file).
+// The key to search for in the file should be of the syntax:
+//    prefix.vname
+// While vname is a name which is specific for a single setup date
+// (variable) of this container and prefix is something like:
+//    evtloopname.name
+// While name is the name of the containers/tasks in the parlist/tasklist
+//
+// eg.  Job4.MImgCleanStd.CleaningLevel1:  3.0
+//      Job4.MImgCleanStd.CleaningLevel2:  2.5
+//
+// If this cannot be found the next step is to search for
+//      MImgCleanStd.CleaningLevel1:  3.0
+// And if this doesn't exist, too, we should search for:
+//      CleaningLevel1:  3.0
+//
+// Warning: The programmer is responsible for the names to be unique in
+//          all Mars classes.
+//
+Bool_t MTaskList::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
+{
+    if (print)
+        *fLog << all << "MTaskList::ReadEnv: " << prefix << " (" << (int)print << ")" << endl;
+
+    MParContainer *cont = NULL;
+
+    MIter Next(fTasks);
+    while ((cont=Next()))
+    {
+        if (cont->InheritsFrom("MTaskList"))
+        {
+            if (cont->ReadEnv(env, prefix, print)==kERROR)
+                return kERROR;
+            continue;
+        }
+
+        // Check For: Job4.ContainerName.Varname
+        if (print)
+            *fLog << all << "Testing: " << prefix+cont->GetName() << endl;
+        Bool_t rc = cont->ReadEnv(env, prefix+cont->GetName(), print);
+        if (rc==kERROR)
+            return kERROR;
+        if (rc==kTRUE)
+            continue;
+
+        // Check For: Job4.MClassName.Varname
+        if (print)
+            *fLog << all << "Testing: " << prefix+cont->ClassName() << endl;
+        rc = cont->ReadEnv(env, prefix+cont->ClassName(), print);
+        if (rc==kERROR)
+            return kERROR;
+        if (rc==kTRUE)
+            continue;
+
+        // Check For: ContainerName.Varname
+        if (print)
+            *fLog << all << "Testing: " << cont->GetName() << endl;
+        rc = cont->ReadEnv(env, cont->GetName(), print);
+        if (rc==kERROR)
+            return kERROR;
+        if (rc==kTRUE)
+            continue;
+
+        // Check For: MClassName.Varname
+        if (print)
+            *fLog << all << "Testing: " << cont->ClassName() << endl;
+        rc = cont->ReadEnv(env, cont->ClassName(), print);
+        if (rc==kERROR)
+            return kERROR;
+        if (rc==kTRUE)
+            continue;
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Write the contents/setup of a parameter container/task to a TEnv
+// instance (steering card/setup file).
+// The key to search for in the file should be of the syntax:
+//    prefix.vname
+// While vname is a name which is specific for a single setup date
+// (variable) of this container and prefix is something like:
+//    evtloopname.name
+// While name is the name of the containers/tasks in the parlist/tasklist
+//
+// eg.  Job4.MImgCleanStd.CleaningLevel1:  3.0
+//      Job4.MImgCleanStd.CleaningLevel2:  2.5
+//
+// If this cannot be found the next step is to search for
+//      MImgCleanStd.CleaningLevel1:  3.0
+// And if this doesn't exist, too, we should search for:
+//      CleaningLevel1:  3.0
+//
+// Warning: The programmer is responsible for the names to be unique in
+//          all Mars classes.
+//
+Bool_t MTaskList::WriteEnv(TEnv &env, TString prefix, Bool_t print) const
+{
+    MParContainer *cont = NULL;
+
+    MIter Next(fTasks);
+    while ((cont=Next()))
+        if (!cont->WriteEnv(env, prefix, print))
+            return kFALSE;
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Removes a task from the tasklist. Returns kFALSE if the object was not
+// found in the list.
+//
+Bool_t MTaskList::RemoveFromList(MTask *task)
+{
+    TObject *obj = fTasks->Remove(task);
+
+    //
+    // If the task was found in the list try to remove it from the second
+    // list, too.
+    //
+    if (obj)
+        fTasksProcess.Remove(task);
+
+    return obj ? kTRUE : kFALSE;
+
+}
Index: /tags/Mars_V0-8-5/Mars/mbase/MTaskList.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MTaskList.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MTaskList.h	(revision 9661)
@@ -0,0 +1,86 @@
+#ifndef MARS_MTaskList
+#define MARS_MTaskList
+
+///////////////////////////////////////////////////////////////////////
+//                                                                   //
+// MTaskList                                                         //
+//                                                                   //
+// Collection of tasks to be processed in the eventloop              //
+//                                                                   //
+///////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MLog;
+class MParList;
+class MInputStreamID;
+
+class MTaskList : public MTask
+{
+private:
+    static const TString gsDefName;  // default name
+    static const TString gsDefTitle; // default title
+
+    TList    *fTasks;        // Container for the ordered list of different tasks
+    TList     fTasksProcess; //! Task which overload the Process function
+    MParList *fParList;      //! The parameter list given in PreProcess
+
+    enum { kIsOwner = BIT(14) };
+
+    void   Remove(MTask *task);
+    void   StreamPrimitive(ofstream &out) const;
+    Bool_t CheckAddToList(MTask *task, const char *tType, const MTask *where=NULL) const;
+
+public:
+    MTaskList(const char *name=NULL, const char *title=NULL);
+    MTaskList(MTaskList &ts);
+
+    ~MTaskList();
+
+    void SetLogStream(MLog *log);
+    void SetDisplay(MStatusDisplay *d);
+
+    Bool_t AddToListBefore(MTask *task, const MTask *where, const char *tType="All");
+    Bool_t AddToListAfter(MTask *task, const MTask *where, const char *tType="All");
+    Bool_t AddToList(MTask *task, const char *tType="All");
+
+    void SetSerialNumber(Byte_t num);
+
+    Bool_t RemoveFromList(MTask *task);
+
+    TObject *FindObject(const char *name) const;
+    TObject *FindObject(const TObject *obj) const;
+
+    MTask *FindTask(const char *name) const
+    {
+        return (MTask*)FindObject(name);
+    }
+    MTask *FindTask(const MTask *obj) const
+    {
+        return (MTask*)FindObject(obj);
+    }
+
+    Bool_t ReInit(MParList *pList=NULL);
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
+    void Print(Option_t *opt = "") const;
+    void PrintStatistics(const Int_t lvl=0, Bool_t title=kFALSE, Double_t time=-1) const;
+    void SetOwner(Bool_t enable=kTRUE);
+
+    const TList *GetList() const { return fTasks; }
+
+    void GetNames(TObjArray &arr) const;
+    void SetNames(TObjArray &arr);
+
+    Bool_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
+    Bool_t WriteEnv(TEnv &env, TString prefix, Bool_t print=kFALSE) const;
+
+    ClassDef(MTaskList, 1) //collection of tasks to be performed in the eventloop
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mbase/MTime.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MTime.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MTime.cc	(revision 9661)
@@ -0,0 +1,531 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MTime
+//
+// A generalized MARS time stamp.
+//
+//
+// We do not use floating point values here, because of several reasons:
+//  - having the times stored in integers only is more accurate and
+//    more reliable in comparison conditions
+//  - storing only integers gives similar bit-pattern for similar times
+//    which makes compression (eg gzip algorithm in TFile) more
+//    successfull
+//
+// Note, that there are many conversion function converting the day time
+// into a readable string. Also a direct interface to SQL time strings
+// is available.
+//
+// If you are using MTime containers as axis lables in root histograms
+// use GetAxisTime(). Make sure that you use the correct TimeFormat
+// on your TAxis (see GetAxisTime())
+//
+//
+// WARNING: Be carefull changing this class. It is also used in the
+//          MAGIC drive software cosy as VERY IMPORTANT stuff!
+//
+// Remarke: If you encounter strange behaviour, check the casting.
+//          Note, that on Linux machines ULong_t and UInt_t is the same.
+//
+//
+// Version 1:
+// ----------
+//  - first version
+//
+// Version 2:
+// ----------
+//  - removed fTimeStamp[2]
+//
+// Version 3:
+// ----------
+//  - removed fDurtaion - we may put it back when it is needed
+//  - complete rewrite of the data members (old ones completely replaced)
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MTime.h"
+
+#include <iomanip>
+
+#include <time.h>     // struct tm
+#include <sys/time.h> // struct timeval
+
+#include <TTime.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MAstro.h"
+
+ClassImp(MTime);
+
+using namespace std;
+
+const UInt_t MTime::kHour = 3600000;         // [ms] one hour
+const UInt_t MTime::kDay  = MTime::kHour*24; // [ms] one day
+
+// --------------------------------------------------------------------------
+//
+// Constructor. Calls SetMjd(d) for d>0 in all other cases the time
+// is set to the current UTC time.
+//
+MTime::MTime(Double_t d)
+{
+    Init(0, 0);
+    if (d<=0)
+        Now();
+    else
+        SetMjd(d);
+}
+
+// --------------------------------------------------------------------------
+//
+// Return date as year(y), month(m), day(d)
+//
+void MTime::GetDate(UShort_t &y, Byte_t &m, Byte_t &d) const
+{
+    MAstro::Mjd2Ymd((Long_t)fTime<0?fMjd-1:fMjd, y, m, d);
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the time in the range [0h, 24h) = [0h0m0.000s - 23h59m59.999s]
+//
+void MTime::GetTime(Byte_t &h, Byte_t &m, Byte_t &s, UShort_t &ms) const
+{
+    Long_t tm = GetTime24();
+    ms  = tm%1000;            // [ms]
+    tm /= 1000;               // [s]
+    s   = tm%60;              // [s]
+    tm /= 60;                 // [m]
+    m   = tm%60;              // [m]
+    tm /= 60;                 // [h]
+    h   = tm;                 // [h]
+}
+
+// --------------------------------------------------------------------------
+//
+//  Return time as MJD (=JD-24000000.5)
+//
+Double_t MTime::GetMjd() const
+{
+    return fMjd+(Double_t)(fNanoSec/1e6+(Long_t)fTime)/kDay;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return a time which is expressed in milliseconds since 01/01/1995 0:00h
+// This is compatible with root's definition used in gSystem->Now()
+// and TTime.
+// Note, gSystem->Now() returns local time, such that it may differ
+// from GetRootTime() (if you previously called MTime::Now())
+//
+TTime MTime::GetRootTime() const
+{
+    return (ULong_t)((GetMjd()-49718)*kDay);
+}
+
+// --------------------------------------------------------------------------
+//
+// Return a time which is expressed in seconds since 01/01/1995 0:00h
+// This is compatible with root's definition used in TAxis.
+// Note, a TAxis always displayes (automatically) given times in
+// local time (while here we return UTC) such, that you may encounter
+// strange offsets. You can get rid of this by calling:
+//    TAxis::SetTimeFormat("[your-format] %F1995-01-01 00:00:00");
+//
+// Be carefull: It seems that root takes sommer and winter time into account!
+//              In some circumstances you may need
+//    TAxis::SetTimeFormat("[your-format] %F1995-01-00 23:00:00");
+//
+Double_t MTime::GetAxisTime() const
+{
+    return (GetMjd()-49718)*kDay/1000;
+}
+
+// --------------------------------------------------------------------------
+//
+// Set a time expressed in MJD, Time of Day (eg. 23:12.779h expressed
+// in milliseconds) and a nanosecond part.
+//
+Bool_t MTime::SetMjd(UInt_t mjd, ULong_t ms, UInt_t ns)
+{
+    // [d]  mjd  (eg. 52320)
+    // [ms] time (eg. 17h expressed in ms)
+    // [ns] time (ns part of time)
+
+    if (ms>kDay-1 || ns>999999)
+        return kFALSE;
+
+    const Bool_t am = ms<kHour*13; // day of sunrise?
+
+    fMjd     = am ? mjd : mjd + 1;
+    fTime    = (Long_t)(am ? ms  : ms-kDay);
+    fNanoSec = ns;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Set MTime to given MJD (eg. 52080.0915449892)
+//
+void MTime::SetMjd(Double_t m)
+{
+    const UInt_t   mjd  = (UInt_t)TMath::Floor(m);
+    const Double_t frac = fmod(m, 1)*kDay; // [ms] Fraction of day
+    const UInt_t   ns   = (UInt_t)fmod(frac*1e6, 1000000);
+
+    SetMjd(mjd, (ULong_t)TMath::Floor(frac), ns);
+}
+
+// --------------------------------------------------------------------------
+//
+// Set MTime to given time and date
+//
+Bool_t MTime::Set(UShort_t y, Byte_t m, Byte_t d, Byte_t h, Byte_t min, Byte_t s, UShort_t ms, UInt_t ns)
+{
+    if (h>23 || min>59 || s>59 || ms>999 || ns>999999)
+        return kFALSE;
+
+    const Int_t mjd = MAstro::Ymd2Mjd(y, m, d);
+    if (mjd<0)
+        return kFALSE;
+
+    const ULong_t tm = ((((h*60+min)*60)+s)*1000)+ms;
+
+    return SetMjd(mjd, tm, ns);
+}
+
+// --------------------------------------------------------------------------
+//
+// Set MTime to time expressed in a 'struct timeval'
+//
+void MTime::Set(const struct timeval &tv)
+{
+    const UInt_t mjd = 1000*tv.tv_sec/kDay + 40587;
+    const Long_t tm  = tv.tv_sec%(24*3600)*1000 + tv.tv_usec/1000;
+    const UInt_t ms  = tv.tv_usec%1000;
+
+    SetMjd(mjd, tm, ms*1000);
+}
+
+// --------------------------------------------------------------------------
+//
+// Return contents as a TString of the form:
+//   "dd.mm.yyyy hh:mm:ss.fff"
+//
+Bool_t MTime::SetString(const char *str)
+{
+    if (!str)
+        return kFALSE;
+
+    UInt_t y, mon, d, h, m, s, ms;
+    const Int_t n = sscanf(str, "%02u.%02u.%04u %02u:%02u:%02u.%03u",
+                           &d, &mon, &y, &h, &m, &s, &ms);
+
+    return n==7 ? Set(y, mon, d, h, m, s, ms) : kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return contents as a TString of the form:
+//   "yyyy-mm-dd hh:mm:ss"
+//
+Bool_t MTime::SetSqlDateTime(const char *str)
+{
+    if (!str)
+        return kFALSE;
+
+    UInt_t y, mon, d, h, m, s;
+    const Int_t n = sscanf(str, "%04u-%02u-%02u %02u:%02u:%02u",
+                           &y, &mon, &d, &h, &m, &s);
+
+    return n==6 ? Set(y, mon, d, h, m, s) : kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return contents as a TString of the form:
+//   "yyyymmddhhmmss"
+//
+Bool_t MTime::SetSqlTimeStamp(const char *str)
+{
+    if (!str)
+        return kFALSE;
+
+    UInt_t y, mon, d, h, m, s;
+    const Int_t n = sscanf(str, "%04u%02u%02u%02u%02u%02u",
+                           &y, &mon, &d, &h, &m, &s);
+
+    return n==6 ? Set(y, mon, d, h, m, s) : kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Set MTime to time expressed as in CT1 PreProc files
+//
+void MTime::SetCT1Time(UInt_t mjd, UInt_t t1, UInt_t t0)
+{
+    // int   isecs_since_midday; // seconds passed since midday before sunset (JD of run start)
+    // int   isecfrac_200ns;     // fractional part of isecs_since_midday
+    // fTime->SetTime(isecfrac_200ns, isecs_since_midday);
+    fNanoSec         = (200*t1)%1000000;
+    const ULong_t ms = (200*t1)/1000000 + t0+12*kHour;
+
+    fTime = (Long_t)(ms<13*kHour ? ms : ms-kDay);
+
+    fMjd = mjd+1;
+}
+
+// --------------------------------------------------------------------------
+//
+// Update the magic time. Make sure, that the MJD is set correctly.
+// It must be the MJD of the corresponding night. You can set it
+// by Set(2003, 12, 24);
+//
+// It is highly important, that the time correspoding to the night is
+// between 13:00:00.0 (day of dawning) and 12:59:59.999 (day of sunrise)
+//
+Bool_t MTime::UpdMagicTime(Byte_t h, Byte_t m, Byte_t s, UInt_t ns)
+{
+    if (h>23 || m>59 || s>59 || ns>999999999)
+         return kFALSE;
+
+    const ULong_t tm = ((((h*60+m)*60)+s)*1000)+ns/1000000;
+
+    fTime = (Long_t)(tm<kHour*13 ? tm  : tm-kDay); // day of sunrise?
+    fNanoSec = ns%1000000;
+
+    return kTRUE;
+
+}
+
+// --------------------------------------------------------------------------
+//
+//  Conversion from Universal Time to Greenwich mean sidereal time,
+//  with rounding errors minimized.
+//
+//  The result is the Greenwich Mean Sidereal Time (radians)
+//
+//  There is no restriction on how the UT is apportioned between the
+//  date and ut1 arguments.  Either of the two arguments could, for
+//  example, be zero and the entire date+time supplied in the other.
+//  However, the routine is designed to deliver maximum accuracy when
+//  the date argument is a whole number and the ut argument lies in
+//  the range 0 to 1, or vice versa.
+//
+//  The algorithm is based on the IAU 1982 expression (see page S15 of
+//  the 1984 Astronomical Almanac).  This is always described as giving
+//  the GMST at 0 hours UT1.  In fact, it gives the difference between
+//  the GMST and the UT, the steady 4-minutes-per-day drawing-ahead of
+//  ST with respect to UT.  When whole days are ignored, the expression
+//  happens to equal the GMST at 0 hours UT1 each day.
+//
+//  In this routine, the entire UT1 (the sum of the two arguments date
+//  and ut) is used directly as the argument for the standard formula.
+//  The UT1 is then added, but omitting whole days to conserve accuracy.
+//
+//  The extra numerical precision delivered by the present routine is
+//  unlikely to be important in an absolute sense, but may be useful
+//  when critically comparing algorithms and in applications where two
+//  sidereal times close together are differenced.
+//
+Double_t MTime::GetGmst() const
+{
+    const Double_t ut = (Double_t)(fNanoSec/1e6+(Long_t)fTime)/kDay;
+
+    // Julian centuries since J2000.
+    const Double_t t = (ut -(51544.5-fMjd)) / 36525.0;
+
+    // GMST at this UT1
+    const Double_t r1 = 24110.54841+(8640184.812866+(0.093104-6.2e-6*t)*t)*t;
+    const Double_t r2 = 86400.0*ut;
+
+    const Double_t sum = (r1+r2)/(24*3600);
+
+    return fmod(sum, 1)*TMath::TwoPi();//+TMath::TwoPi();
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the time to the current system time. The timezone is ignored.
+// If everything is set correctly you'll get UTC.
+//
+void MTime::Now()
+{
+#ifdef __LINUX__
+    struct timeval tv;
+    if (gettimeofday(&tv, NULL)<0)
+        Clear();
+    else
+        Set(tv);
+#else
+    Clear();
+#endif
+}
+
+// --------------------------------------------------------------------------
+//
+// Return contents as a TString of the form:
+//   "dd.mm.yyyy hh:mm:ss.fff"
+//
+TString MTime::GetString() const
+{
+    UShort_t y, ms;
+    Byte_t mon, d, h, m, s;
+
+    GetDate(y, mon, d);
+    GetTime(h, m, s, ms);
+
+    return TString(Form("%02d.%02d.%04d %02d:%02d:%02d.%03d", d, mon, y, h, m, s, ms));
+}
+
+// --------------------------------------------------------------------------
+//
+// Return contents as a string format'd with strftime:
+// Here is a short summary of the most important formats. For more
+// information see the man page (or any other description) of
+// strftime...
+//
+//  %a  The abbreviated weekday name according to the current locale.
+//  %A  The full weekday name according to the current locale.
+//  %b  The abbreviated month name according to the current locale.
+//  %B  The full month name according to the current locale.
+//  %c  The preferred date and time representation for the current locale.
+//  %d  The day of the month as a decimal number (range  01 to 31).
+//  %e  Like %d, the day of the month as a decimal number,
+//      but a leading zero is replaced by a space.
+//  %H  The hour as a decimal number using a 24-hour clock (range 00 to 23)
+//  %k  The hour (24-hour clock) as a decimal number (range 0 to 23);
+//      single digits are preceded by a blank.
+//  %m  The month as a decimal number (range 01 to 12).
+//  %M  The minute as a decimal number (range 00 to 59).
+//  %R  The time in 24-hour notation (%H:%M).  For a
+//      version including the seconds, see %T below.
+//  %S  The second as a decimal number (range 00 to 61).
+//  %T  The time in 24-hour notation (%H:%M:%S).
+//  %x  The preferred date representation for the current
+//      locale without the time.
+//  %X  The preferred time representation for the current
+//      locale without the date.
+//  %y  The year as a decimal number without a century (range 00 to 99).
+//  %Y  The year as a decimal number including the century.
+//  %+  The date and time in date(1) format.
+//
+// The default is: Tuesday 16.February 2004 12:17:22
+//
+// The maximum size of the return string is 128 (incl. NULL)
+//
+TString MTime::GetStringFmt(const char *fmt) const
+{
+    if (!fmt)
+        fmt = "%A %e.%B %Y %H:%M:%S";
+
+    UShort_t y, ms;
+    Byte_t mon, d, h, m, s;
+
+    GetDate(y, mon, d);
+    GetTime(h, m, s, ms);
+
+    struct tm time;
+    time.tm_sec   = s;
+    time.tm_min   = m;
+    time.tm_hour  = h;
+    time.tm_mday  = d;
+    time.tm_mon   = mon-1;
+    time.tm_year  = y-1900;
+    time.tm_isdst = 0;
+
+    // recalculate tm_yday and tm_wday
+    mktime(&time);
+
+    char ret[128];
+    return TString(strftime(ret, 127, fmt, &time) ? ret : "");
+}
+
+// --------------------------------------------------------------------------
+//
+// Return contents as a TString of the form:
+//   "yyyy-mm-dd hh:mm:ss"
+//
+TString MTime::GetSqlDateTime() const
+{
+    return GetStringFmt("%Y-%m-%d %H:%M:%S");
+}
+
+// --------------------------------------------------------------------------
+//
+// Return contents as a TString of the form:
+//   "yyyymmddhhmmss"
+//
+TString MTime::GetSqlTimeStamp() const
+{
+    return GetStringFmt("%Y%m%d%H%M%S");
+}
+
+// --------------------------------------------------------------------------
+//
+// Return contents as a TString of the form:
+//   "yyyymmdd_hhmmss"
+//
+TString MTime::GetFileName() const
+{
+    return GetStringFmt("%Y%m%d_%H%M%S");
+}
+
+// --------------------------------------------------------------------------
+//
+// Print MTime as string
+//
+void MTime::Print(Option_t *) const
+{
+    UShort_t yea, ms;
+    Byte_t mon, day, h, m, s;
+
+    GetDate(yea, mon, day);
+    GetTime(h, m, s, ms);
+
+    *fLog << all << GetDescriptor() << ": ";
+    *fLog << GetString() << Form(" (+%dns)", fNanoSec) << endl;
+} 
+
+istream &MTime::ReadBinary(istream &fin)
+{
+    UShort_t y;
+    Byte_t mon, d, h, m, s;
+
+    fin.read((char*)&y,   2);
+    fin.read((char*)&mon, 1);
+    fin.read((char*)&d,   1);
+    fin.read((char*)&h,   1);
+    fin.read((char*)&m,   1);
+    fin.read((char*)&s,   1); // Total=7
+
+    Set(y, mon, d, h, m, s, 0);
+
+    return fin;
+}
Index: /tags/Mars_V0-8-5/Mars/mbase/MTime.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/MTime.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/MTime.h	(revision 9661)
@@ -0,0 +1,186 @@
+#ifndef MARS_MTime
+#define MARS_MTime
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MTime                                                                   //
+//                                                                         //
+// A generalized MARS time stamp                                           //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#ifndef _CPP_IOSFWD
+#include <iosfwd>
+#endif
+
+#ifndef ROOT_TTime
+#include <TTime.h>
+#endif
+
+struct timeval;
+
+class MTime : public MParContainer
+{
+public:
+    static const UInt_t kHour; // [ms] one hour
+    static const UInt_t kDay;  // [ms] one day
+
+private:
+    UInt_t fMjd;     // [d]  Day in the century        (Day of sun rise)
+    TTime  fTime;    // [ms] Time of Day               (-11h<=x<13h)
+    UInt_t fNanoSec; // [ns] NanoSec part of TimeOfDay (<1000000)
+
+    ULong_t GetTime24() const
+    {
+        return (Long_t)fTime<0 ? (Long_t)fTime+kDay : (ULong_t)fTime;
+    }
+    void Init(const char *name, const char *title)
+    {
+        fName  = name  ? name  : "MTime";
+        fTitle = title ? title : "Generalized time stamp";
+    }
+
+public:
+    MTime(const char *name=NULL, const char *title=NULL)
+    {
+        Init(name, title);
+        Clear();
+    }
+    MTime(const struct timeval &tm)
+    {
+        Init(NULL, NULL);
+        Set(tm);
+    }
+    MTime(Double_t mjd);
+    MTime(const MTime& t) : fMjd(t.fMjd), fTime(t.fTime), fNanoSec(t.fNanoSec)
+    {
+        Init(NULL, NULL);
+    }
+
+    void operator=(const MTime &t)
+    {
+        fMjd     = t.fMjd;
+        fTime    = t.fTime;
+        fNanoSec = t.fNanoSec;
+    }
+
+    void Clear(const Option_t *o="") { fMjd=0; fTime=0; fNanoSec=0; }
+
+    void Print(Option_t *t=NULL) const;
+
+    void Now();
+
+    Bool_t   Set(UShort_t y, Byte_t m, Byte_t d, Byte_t h=13, Byte_t min=0, Byte_t s=0, UShort_t ms=0, UInt_t ns=0);
+    void     Set(const struct timeval &tv);
+    Bool_t   SetString(const char *str);
+    Bool_t   SetSqlDateTime(const char *str);
+    Bool_t   SetSqlTimeStamp(const char *str);
+    void     SetCT1Time(UInt_t mjd, UInt_t t1, UInt_t t0);
+    Bool_t   UpdMagicTime(Byte_t h, Byte_t m, Byte_t s, UInt_t ns);
+    Bool_t   SetMjd(UInt_t mjd, ULong_t ms, UInt_t ns=0);
+    void     SetMjd(Double_t m);
+    Double_t GetMjd() const;
+    Double_t GetGmst() const;
+    TString  GetString() const;
+    TString  GetStringFmt(const char *fmt=0) const;
+    TString  GetSqlDateTime() const;
+    TString  GetSqlTimeStamp() const;
+    TString  GetFileName() const;
+    void     GetDate(UShort_t &y, Byte_t &m, Byte_t &d) const;
+    TTime    GetRootTime() const;
+    Double_t GetAxisTime() const;
+    Long_t   GetTime() const { return (Long_t)fTime; } // [ms] Time of Day returned in the range [-11h, 13h)
+    void     GetTime(Byte_t &h, Byte_t &m, Byte_t &s, UShort_t &ms) const;
+    void     GetTime(Byte_t &h, Byte_t &m, Byte_t &s) const
+    {
+        UShort_t ms;
+        GetTime(h, m, s, ms);
+    }
+
+    UInt_t Year() const  { UShort_t y; Byte_t m, d; GetDate(y,m,d); return y; }
+    UInt_t Month() const { UShort_t y; Byte_t m, d; GetDate(y,m,d); return m; }
+    UInt_t Day() const   { UShort_t y; Byte_t m, d; GetDate(y,m,d); return d; }
+    UInt_t Hour() const  { Byte_t h, m, s; GetTime(h,m,s); return h; }
+    UInt_t Min() const   { Byte_t h, m, s; GetTime(h,m,s); return m; }
+    UInt_t Sec() const   { Byte_t h, m, s; GetTime(h,m,s); return s; }
+
+    istream &ReadBinary(istream &fin);
+
+    operator double() const   //[s]
+    {
+        return ((Double_t)fMjd*kDay+(Long_t)fTime+fNanoSec/1e6)/1000;
+    }
+    double operator()() const //[s]
+    {
+        return operator double();
+    }
+
+    bool operator<(const MTime &t) const
+    {
+        if (fMjd<t.fMjd)
+            return true;
+        if (fMjd==t.fMjd && fTime<t.fTime)
+            return true;
+        if (fMjd==t.fMjd && fTime==t.fTime && fNanoSec<t.fNanoSec)
+            return true;
+        return false;
+    }
+    bool operator>(const MTime &t) const
+    {
+        if (fMjd>t.fMjd)
+            return true;
+        if (fMjd==t.fMjd && fTime>t.fTime)
+            return true;
+        if (fMjd==t.fMjd && fTime==t.fTime && fNanoSec>t.fNanoSec)
+            return true;
+        return false;
+    }
+
+    bool operator<=(const MTime &t) const
+    {
+        return !operator>(t);
+    }
+
+    bool operator>=(const MTime &t) const
+    {
+        return !operator<(t);
+    }
+
+    bool operator==(const MTime &t) const
+    {
+        return fNanoSec==t.fNanoSec && fTime==t.fTime && fMjd==t.fMjd;
+    }
+
+    bool operator!=(const MTime &t) const
+    {
+        return fNanoSec!=t.fNanoSec || fTime!=t.fTime || fMjd!=t.fMjd;
+    }
+
+    bool operator!() const
+    {
+        return fNanoSec==0 && (ULong_t)fTime==0 && fMjd==0;
+    }
+
+    ClassDef(MTime, 3)	//A generalized MARS time stamp
+};
+
+inline ostream &operator<<(ostream &out, const MTime &t)
+{
+    out << t.GetString();
+    return out;
+}
+
+inline istream &operator>>(istream &in, MTime &t)
+{
+    TString date, time;
+    date.ReadToDelim(in, ' ');
+    time.ReadToDelim(in, ' ');
+    t.SetString(Form("%s %s", date.Data(), time.Data()));
+    return in;
+}
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mbase/Makefile
===================================================================
--- /tags/Mars_V0-8-5/Mars/mbase/Makefile	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mbase/Makefile	(revision 9661)
@@ -0,0 +1,63 @@
+##################################################################
+#
+#   subdirectory makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#------------------------------------------------------------------------------
+
+INCLUDES = -I. -I../mfileio -I../mfbase -I../mastro
+# mfileio:  MRead  (MEvtLoop)
+# mfbase:   MF     (MContinue)
+# mastro:   MAstro (MTime)
+
+CINT = Base
+
+SRCFILES = MLogo.cc \
+           MArgs.cc \
+           MString.cc \
+           MMath.cc \
+	   MLog.cc \
+           MLogManip.cc \
+           MLogPlugin.cc \
+           MLogHtml.cc \
+           MParContainer.cc \
+	   MParList.cc \
+	   MInputStreamID.cc \
+           MTask.cc \
+           MTaskInteractive.cc \
+	   MTaskList.cc \
+           MFilter.cc \
+           MEvtLoop.cc \
+           MProgressBar.cc \
+           MSearch.cc \
+           MGMenu.cc \
+           MGMap.cc \
+           MIter.cc \
+           MDirIter.cc \
+           MRunIter.cc \
+           MReadSocket.cc \
+           MGGroupFrame.cc \
+           MGList.cc \
+           MGTask.cc \
+           MStatusArray.cc \
+           MStatusDisplay.cc \
+	   MArray.cc \
+	   MArrayB.cc \
+	   MArrayS.cc \
+           MTime.cc \
+           MClone.cc \
+           MContinue.cc \
+           MPrint.cc
+
+############################################################
+
+all: $(OBJS)
+
+include ../Makefile.rules
+
+mrproper:	clean rmbak
Index: /tags/Mars_V0-8-5/Mars/mcalib/CalibIncl.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/CalibIncl.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/CalibIncl.h	(revision 9661)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-8-5/Mars/mcalib/CalibLinkDef.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/CalibLinkDef.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/CalibLinkDef.h	(revision 9661)
@@ -0,0 +1,45 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class MCalibrate+;
+#pragma link C++ class MCalibrateData+;
+#pragma link C++ class MCalibrateRelTimes+;
+
+#pragma link C++ class MCalibrationCam+;
+#pragma link C++ class MCalibrationPix+;
+#pragma link C++ class MCalibrationRelTimeCalc+;
+#pragma link C++ class MCalibrationRelTimeCam+;
+#pragma link C++ class MCalibrationRelTimePix+;
+#pragma link C++ class MCalibrationPedCam+;
+#pragma link C++ class MCalibrationQECam+;
+#pragma link C++ class MCalibrationQEPix+;
+#pragma link C++ class MCalibrationChargeCalc+;
+#pragma link C++ class MCalibrationChargeCam+;
+#pragma link C++ class MCalibrationChargePix+;
+#pragma link C++ class MCalibrationChargeBlindCam+;
+#pragma link C++ class MCalibrationChargeBlindPix+;
+#pragma link C++ class MCalibrationChargePINDiode+;
+
+#pragma link C++ class MHCalibrationCam+;
+#pragma link C++ class MHCalibrationChargeCam+;
+#pragma link C++ class MHCalibrationChargePix+;
+#pragma link C++ class MHCalibrationChargeHiGainPix+;
+#pragma link C++ class MHCalibrationChargeLoGainPix+;
+#pragma link C++ class MHCalibrationChargeBlindCam+;
+#pragma link C++ class MHCalibrationChargeBlindPix+;
+#pragma link C++ class MHCalibrationChargePINDiode+;
+#pragma link C++ class MHCalibrationRelTimePix+;
+#pragma link C++ class MHCalibrationRelTimeCam+;
+#pragma link C++ class MHCalibrationTestCam+;
+#pragma link C++ class MHCalibrationTestPix+;
+#pragma link C++ class MHCalibrationTestTimeCam+;
+#pragma link C++ class MHCalibrationTestTimePix+;
+
+#pragma link C++ class MMcCalibrationCalc++;
+
+#pragma link C++ class MHGausEvents++;
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mcalib/MCalibrate.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MCalibrate.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MCalibrate.cc	(revision 9661)
@@ -0,0 +1,430 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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 12/2003 <mailto:jlopez@ifae.es>
+!   Author(s): Javier Rico  01/2004 <mailto:jrico@ifae.es>
+!   Author(s): Markus Gaug  04/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//   MCalibrate
+//
+//   This task takes the integrated charge from MExtractedSignal and apply
+//   the calibration constants from MCalibraitionCam to convert the summed FADC 
+//   slices to photons. The number of photons obtained is stored in MCerPhotEvt. 
+//
+//   Selection of different calibration methods is possible through the 
+//   SetCalibrationMode member function
+//
+//   The calibration modes which exclude non-valid pixels are the following: 
+//
+//   kFfactor:    calibrates using the F-Factor method
+//   kBlindpixel: calibrates using the BlindPixel method 
+//   kBlindpixel: calibrates using the BlindPixel method 
+//   kFlatCharge: perform a charge flat-flatfielding. Outer pixels are area-corrected.
+//   kDummy:      calibrates with fixed conversion factors of 1 and errors of 0.
+//
+//   The calibration modes which include all pixels regardless of their validity is:
+//
+//   kNone:       calibrates with fixed conversion factors of 1 and errors of 0.
+//
+//   Use the kDummy and kNone methods ONLY FOR DEBUGGING!   
+//
+//   Input Containers:
+//    MExtractedSingal
+//    MCalibrationChargeCam
+//
+//   Output Containers:
+//    MCerPhotEvt
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MCalibrate.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MH.h"
+
+#include "MGeomCam.h"
+
+#include "MCalibrationChargeCam.h"
+#include "MCalibrationChargePix.h"
+
+#include "MCalibrationQECam.h"
+#include "MCalibrationQEPix.h"
+
+#include "MExtractedSignalCam.h"
+#include "MExtractedSignalPix.h"
+
+#include "MBadPixelsCam.h"
+#include "MBadPixelsPix.h"
+
+#include "MCerPhotEvt.h"
+
+ClassImp(MCalibrate);
+
+using namespace std;
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+MCalibrate::MCalibrate(CalibrationMode_t calmode,const char *name, const char *title) 
+    : fGeomCam(NULL), fCalibrations(NULL), fQEs(NULL), fBadPixels(NULL), fSignals(NULL), 
+      fCerPhotEvt(NULL), fCalibrationMode(calmode)
+{
+    fName  = name  ? name  : "MCalibrate";
+    fTitle = title ? title : "Task to calculate the number of photons in one event";
+}
+
+// --------------------------------------------------------------------------
+//
+// The PreProcess searches for the following input containers:
+//  - MGeomCam
+//  - MCalibrationChargeCam
+//  - MExtractedSignalCam
+//  - MBadPixelsCam
+//
+// The following output containers are also searched and created if
+// they were not found:
+//
+//  - MCerPhotEvt
+//
+Int_t MCalibrate::PreProcess(MParList *pList)
+{
+
+    fSignals = (MExtractedSignalCam*)pList->FindObject(AddSerialNumber("MExtractedSignalCam"));
+
+    if (!fSignals)
+    {
+      *fLog << err << AddSerialNumber("MExtractedSignalCam") << " not found ... aborting" << endl;
+        return kFALSE;
+    }
+
+    fBadPixels = (MBadPixelsCam*)pList->FindObject(AddSerialNumber("MBadPixelsCam"));
+    if (!fBadPixels)
+      *fLog << warn << AddSerialNumber("MBadPixelsCam") << " not found ... no action" << endl;
+    
+    if(fCalibrationMode>kNone)
+      {
+
+	fCalibrations = (MCalibrationChargeCam*)pList->FindObject(AddSerialNumber("MCalibrationChargeCam"));
+	if (!fCalibrations)
+	  {
+	    *fLog << err << AddSerialNumber("MCalibrationChargeCam") << " not found ... aborting." << endl;
+	    return kFALSE;
+	  }
+
+	if (fCalibrationMode>kFlatCharge)
+	{
+	    fQEs = (MCalibrationQECam*)pList->FindObject(AddSerialNumber("MCalibrationQECam"));
+	    if (!fQEs)
+	    {
+		*fLog << err << AddSerialNumber("MCalibrationQECam") << " not found ... aborting." << endl;
+		return kFALSE;
+	    }
+        }
+      }
+
+    fCerPhotEvt = (MCerPhotEvt*)pList->FindCreateObj(AddSerialNumber("MCerPhotEvt"));
+    if (!fCerPhotEvt)
+        return kFALSE;
+
+    fGeomCam = (MGeomCam*)pList->FindCreateObj(AddSerialNumber("MGeomCam"));
+    if (!fGeomCam)
+      return kFALSE;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Check for validity of the selected calibration method, switch to a 
+// different one in case of need
+//
+Bool_t MCalibrate::ReInit(MParList *pList)
+{
+
+  if(fCalibrationMode == kBlindPixel && !fQEs->IsBlindPixelMethodValid())
+    {
+      *fLog << warn << GetDescriptor() 
+            << "Warning: Blind pixel calibration method not valid, switching to F-factor method" << endl;
+      fCalibrationMode = kFfactor;
+    }
+  
+  if(fCalibrationMode == kPinDiode && !fQEs->IsPINDiodeMethodValid())
+    { 
+      *fLog << warn << GetDescriptor() 
+            << "Warning: PIN diode calibration method not valid, switching to F-factor method" << endl;
+      fCalibrationMode = kFfactor;
+    }
+
+  if(fCalibrationMode == kCombined && !fQEs->IsCombinedMethodValid())
+    { 
+      *fLog << warn << GetDescriptor() 
+            << "Warning: Combined calibration method not valid, switching to F-factor method" << endl;
+      fCalibrationMode = kFfactor;
+    }
+
+
+  if (fCalibrationMode == kFlatCharge)
+  {
+      fGeomCam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
+      if (!fGeomCam)
+      {
+	  *fLog << err << AddSerialNumber("MGeomCam") << " not found ... aborting." << endl;
+	  return kFALSE;
+      }
+  }
+
+
+  switch(fCalibrationMode)
+    {
+    case kBlindPixel:
+      break;
+    case kFfactor:
+      break;
+    case kPinDiode:
+      *fLog << err << GetDescriptor() 
+                    << ": PIN Diode Calibration mode not yet available " << endl;
+      return kFALSE;
+      break;
+    case kCombined:
+      *fLog << err << GetDescriptor() 
+                    << ": Combined Calibration mode not yet available " << endl;
+      return kFALSE;
+      break;
+	case kFlatCharge:
+      *fLog << warn << GetDescriptor() 
+                    << ": WARNING: Flat-fielding charges - only for Keiichi!!" << endl;
+      break;
+    case kDummy:
+      *fLog << warn << GetDescriptor() 
+                    << ": WARNING: Dummy calibration, no calibration applied!!" << endl;
+      break;
+    case kNone:
+      *fLog << warn << GetDescriptor() 
+                    << ": WARNING: No calibration applied!!" << endl;
+      break;
+    default:
+      *fLog << warn << GetDescriptor() 
+            << ": WARNING: Calibration mode value ("
+            <<fCalibrationMode<<") not known" << endl;
+      return kFALSE;
+    }
+  
+  return kTRUE;
+}
+// --------------------------------------------------------------------------
+//
+// Apply the calibration factors to the extracted signal according to the 
+// selected calibration method
+//
+Int_t MCalibrate::Process()
+{
+
+  //
+  // For the moment, we use only a dummy zenith for the calibration:
+  //
+  const Float_t zenith = 0;
+
+  /*
+    if (fCalibrations->GetNumPixels() != (UInt_t)fSignals->GetSize())
+    {
+        // FIXME: MExtractedSignal must be of variable size -
+        //        like MCerPhotEvt - because we must be able
+        //        to reduce size by zero supression
+        //        For the moment this check could be done in ReInit...
+        *fLog << err << "MExtractedSignal and MCalibrationCam have different sizes... abort." << endl;
+        return kFALSE;
+    }
+  */
+
+  UInt_t npix = fSignals->GetSize();
+
+  Float_t hiloconv      = 0.;
+  Float_t hiloconverr   = 0.;
+  Float_t calibConv     = 0.;
+  Float_t calibConvVar  = 0.;
+  Float_t calibFFactor  = 0.;
+  Float_t calibQE       = 1.;
+  Float_t calibQEVar    = 0.;
+  Float_t avMean        = 1.;
+  Float_t avMeanRelVar  = 0.;
+  
+
+  if (fCalibrationMode == kFlatCharge)
+  {
+      MCalibrationChargePix &avpix = (MCalibrationChargePix&)fCalibrations->GetAverageArea(0);
+      avMean       =  avpix.GetMean();
+      avMeanRelVar =  avpix.GetMeanRelVar();
+  }
+  
+  
+  for (UInt_t pixidx=0; pixidx<npix; pixidx++)
+    {
+
+      if(fCalibrationMode!=kNone)
+	{
+	  
+	  MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCalibrations)[pixidx];
+
+	  hiloconv   = pix.GetConversionHiLo   ();
+	  hiloconverr= pix.GetConversionHiLoErr();
+	  
+          if (fBadPixels)
+            {
+              MBadPixelsPix         &bad = (*fBadPixels)[pixidx];
+              if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
+                continue;
+            }
+            
+          calibConv      = pix.GetMeanConvFADC2Phe();
+          calibConvVar   = pix.GetMeanConvFADC2PheVar();
+          calibFFactor   = pix.GetMeanFFactorFADC2Phot();
+
+   	  if (fCalibrationMode== kFlatCharge)
+	  {
+	      calibConv        = avMean / pix.GetMean() / fGeomCam->GetPixRatio(pixidx) ;
+	      calibConvVar     = (avMeanRelVar + pix.GetMeanRelVar()) * calibConv * calibConv;
+	      calibFFactor     = pix.GetRSigmaPerCharge();
+	  }
+	  else
+	  {
+
+	      MCalibrationQEPix &qe  = (MCalibrationQEPix&) (*fQEs)[pixidx];
+
+	      switch(fCalibrationMode)
+	      {
+		  case kBlindPixel:
+		      if (qe.IsBlindPixelMethodValid())
+		      {
+			  calibQE      = qe.GetQECascadesBlindPixel   ( zenith );
+			  calibQEVar   = qe.GetQECascadesBlindPixelVar( zenith );
+		      }
+		      else
+			  continue;
+		      break;
+		  case kPinDiode:
+		      if (qe.IsPINDiodeMethodValid())
+		      {
+			  calibQE      = qe.GetQECascadesPINDiode   ( zenith );
+			  calibQEVar   = qe.GetQECascadesPINDiodeVar( zenith );
+		      }
+		      else
+			  continue;
+		      break;
+		  case kFfactor:
+		      if (pix.IsFFactorMethodValid())
+                        {
+                          calibQE      = qe.GetQECascadesFFactor   ( zenith );
+			  calibQEVar   = qe.GetQECascadesFFactorVar( zenith );
+                        }
+		      else
+			  continue;
+		      break;
+		  case kCombined:
+		      if (qe.IsCombinedMethodValid())
+		      {
+			  calibQE      = qe.GetQECascadesCombined   ( zenith );
+			  calibQEVar   = qe.GetQECascadesCombinedVar( zenith );
+		      }
+		      else
+			  continue;
+		      break;
+		  case kDummy:
+		      hiloconv     = 1.;
+		      hiloconverr  = 0.;
+		      calibQE      = 1.;
+		      calibQEVar   = 0.;
+		      break;
+		      
+	      } /* switch calibration mode */
+	  } /* else fCalibrationMode == kFlatCharge */
+	} /* if(fCalibrationMode!=kNone) */
+      else
+      {
+	  hiloconv       = 1.;
+	  hiloconverr    = 0.;
+	  calibConv      = 1./fGeomCam->GetPixRatio(pixidx);
+	  calibConvVar   = 0.;
+	  calibFFactor   = 0.;
+	  calibQE        = 1.;
+	  calibQEVar     = 0.;
+      }      
+
+      MExtractedSignalPix &sig =  (*fSignals)[pixidx];
+      
+      Float_t signal;
+      Float_t signalErr = 0.;
+      Float_t nphot,nphotErr;
+            
+      if (sig.IsLoGainUsed())
+        {
+          signal    = sig.GetExtractedSignalLoGain()*hiloconv;
+          signalErr = signal*hiloconverr;
+        }
+      else
+        {
+	  if (sig.GetExtractedSignalHiGain() > 9999.)
+	    {
+	      signal    = 0.;
+	      signalErr = 0.;
+	    }
+	  else
+	    signal = sig.GetExtractedSignalHiGain();
+        }
+      
+      nphot    = signal*calibConv/calibQE;
+      nphotErr = calibFFactor*TMath::Sqrt(TMath::Abs(nphot));
+
+      if (fCalibrationMode == kFlatCharge)
+	  nphotErr = calibFFactor * signal;
+
+
+      //
+      // The following part is the outcommented first version of the error calculation
+      // Contact Markus Gaug for questions (or wait for the next documentation update...)
+      //
+      /*
+        nphotErr = signal    > 0 ? signalErr*signalErr / (signal * signal)  : 0.
+                 + calibConv > 0 ? calibConvVar  / (calibConv * calibConv ) : 0.
+                 + calibQE   > 0 ? calibQEVar    / (calibQE   * calibQE   ) : 0.;
+        nphotErr  = TMath::Sqrt(nphotErr) * nphot;
+      */
+
+      MCerPhotPix *cpix = fCerPhotEvt->AddPixel(pixidx, nphot, nphotErr);
+
+      if (sig.GetNumLoGainSaturated() > 0)
+	cpix->SetPixelSaturated();
+
+      if (sig.GetNumHiGainSaturated() > 0)
+	cpix->SetPixelHGSaturated();
+
+
+    } /* for (UInt_t pixidx=0; pixidx<npix; pixidx++) */
+  
+  fCerPhotEvt->FixSize();
+  fCerPhotEvt->SetReadyToSave();
+  
+  return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mcalib/MCalibrate.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MCalibrate.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MCalibrate.h	(revision 9661)
@@ -0,0 +1,54 @@
+#ifndef MARS_MCalibrate
+#define MARS_MCalibrate
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MCalibrate                                                              //
+//                                                                         //
+// Integrates the desired ADC time slices of one pixel and apply           //
+// calibration constants                                                   //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MGeomCam;
+class MBadPixelsCam;
+class MCalibrationChargeCam;
+class MCalibrationQECam;
+class MExtractedSignalCam;
+class MCerPhotEvt;
+
+class MCalibrate : public MTask
+{
+private:
+    MGeomCam              *fGeomCam;      // Camera geometry container
+    MCalibrationChargeCam *fCalibrations; // Calibration constants
+    MCalibrationQECam     *fQEs;          // Quantum efficiencies
+    MBadPixelsCam         *fBadPixels;    // Bad Pixels information
+    MExtractedSignalCam   *fSignals;      // Integrated charge in FADCs counts
+    MCerPhotEvt           *fCerPhotEvt;   // Cerenkov Photon Event used for calculation
+
+    Float_t fConversionHiLo;
+    UShort_t fCalibrationMode;
+    
+    Int_t PreProcess(MParList *pList);
+    Bool_t ReInit(MParList *pList);
+    Int_t Process();
+
+public:
+
+    enum CalibrationMode_t{kNone=0,kFlatCharge=1,kBlindPixel,kFfactor,kPinDiode,kCombined, kDummy};
+    static const CalibrationMode_t kDefault = kFfactor;
+
+    MCalibrate(CalibrationMode_t calmode = kDefault,const char *name=NULL, const char *title=NULL);
+
+    void SetConversionHiLo(Float_t conv) { fConversionHiLo = conv; };
+    void SetCalibrationMode(CalibrationMode_t calmode=kDefault){ fCalibrationMode=calmode;};
+    
+    ClassDef(MCalibrate, 0)   // Task to calculate cerenkov photons using calibration constants
+};
+ 
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mcalib/MCalibrateData.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MCalibrateData.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MCalibrateData.cc	(revision 9661)
@@ -0,0 +1,379 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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    12/2003 <mailto:jlopez@ifae.es>
+!   Author(s): Javier Rico     01/2004 <mailto:jrico@ifae.es>
+!   Author(s): Wolfgang Wittek 02/2004 <mailto:wittek@mppmu.mpg.de>
+!   Author(s): Markus Gaug     04/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//   MCalibrateData
+//
+//   This task takes the integrated charge from MExtractedSignal and apply
+//   the calibration constants from MCalibraitionCam to the charge. Then
+//   stores number of photons obtained in MCerPhotEvt. Selection of different
+//   calibration methods is allowed through SetCalibrationMode member function
+//
+//   in ReInit the MPedPhotCam container is filled using the information from
+//   MPedestalCam, MExtractedSignalCam and MCalibrationCam
+//
+//   Input Containers:
+//    MPedestalCam
+//    MExtractedSingalCam
+//    MCalibrationChargeCam
+//    MCalibrationQECam
+//
+//   Output Containers:
+//    MPedPhotCam
+//    MCerPhotEvt
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MCalibrateData.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MH.h"
+
+#include "MGeomCam.h"
+
+#include "MPedestalCam.h"
+#include "MPedestalPix.h"
+
+#include "MCalibrationChargeCam.h"
+#include "MCalibrationChargePix.h"
+
+#include "MCalibrationQECam.h"
+#include "MCalibrationQEPix.h"
+
+#include "MExtractedSignalCam.h"
+#include "MExtractedSignalPix.h"
+
+#include "MPedPhotCam.h"
+#include "MPedPhotPix.h"
+
+#include "MBadPixelsCam.h"
+#include "MBadPixelsPix.h"
+
+#include "MCerPhotEvt.h"
+
+ClassImp(MCalibrateData);
+
+using namespace std;
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+MCalibrateData::MCalibrateData(CalibrationMode_t calmode,const char *name, const char *title) 
+    : fCam(NULL), fPedestal(NULL), fBadPixels(NULL), fCalibrations(NULL), fSignals(NULL), 
+      fPedPhot(NULL), fCerPhotEvt(NULL), fCalibrationMode(calmode)
+{
+    fName  = name  ? name  : "MCalibrateData";
+    fTitle = title ? title : "Task to calculate the number of photons in one event";
+}
+
+// --------------------------------------------------------------------------
+//
+// The PreProcess searches for the following input containers:
+//  - MGeomCam
+//  - MPedestalCam
+//  - MCalibrationChargeCam
+//  - MCalibrationQECam
+//  - MExtractedSignalCam
+//
+// The following output containers are also searched and created if
+// they were not found:
+//
+//  - MPedPhotCam
+//  - MCerPhotEvt
+//
+Int_t MCalibrateData::PreProcess(MParList *pList)
+{
+    fPedestal = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
+    if (!fPedestal)
+    {
+      *fLog << err << AddSerialNumber("MPedestalCam") << " not found ... aborting" << endl;
+        return kFALSE;
+    }
+
+
+    fSignals = (MExtractedSignalCam*)pList->FindObject(AddSerialNumber("MExtractedSignalCam"));
+    if (!fSignals)
+    {
+      *fLog << err << AddSerialNumber("MExtractedSignalCam") << " not found ... aborting" << endl;
+        return kFALSE;
+    }
+
+    fBadPixels = (MBadPixelsCam*)pList->FindObject(AddSerialNumber("MBadPixelsCam"));
+
+    if (!fBadPixels)
+    {
+      *fLog << err << AddSerialNumber("MBadPixelsCam") << " not found ... aborting" << endl;
+        return kFALSE;
+    }
+
+    if (fCalibrationMode>kNone)
+    {
+        fCalibrations = (MCalibrationChargeCam*)pList->FindObject(AddSerialNumber("MCalibrationChargeCam"));
+        if (!fCalibrations)
+        {
+            *fLog << err << AddSerialNumber("MCalibrationChargeCam") << " not found ... aborting." << endl;
+            return kFALSE;
+        }
+        fQEs = (MCalibrationQECam*)pList->FindObject(AddSerialNumber("MCalibrationQECam"));
+        if (!fQEs)
+        {
+            *fLog << err << AddSerialNumber("MCalibrationQECam") << " not found ... aborting." << endl;
+            return kFALSE;
+        }
+    }
+
+    fPedPhot = (MPedPhotCam*)pList->FindCreateObj(AddSerialNumber("MPedPhotCam"));
+    if (!fPedPhot)
+        return kFALSE;
+
+    fCerPhotEvt = (MCerPhotEvt*)pList->FindCreateObj(AddSerialNumber("MCerPhotEvt"));
+    if (!fCerPhotEvt)
+        return kFALSE;
+    
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Check for validity of the selected calibration method, switch to a 
+// different one in case of need
+//
+// fill the MPedPhotCam container using the information from MPedestalCam,
+// MExtractedSignalCam and MCalibrationCam
+//
+//
+Bool_t MCalibrateData::ReInit(MParList *pList)
+{
+
+  if(fCalibrationMode == kBlindPixel && !fQEs->IsBlindPixelMethodValid())
+    {
+      *fLog << warn << GetDescriptor() << "Warning: Blind pixel calibration method not valid, switching to F-factor method" << endl;
+      fCalibrationMode = kFfactor;
+    }
+
+  if(fCalibrationMode == kPinDiode && !fQEs->IsPINDiodeMethodValid())
+    { 
+      *fLog << warn << GetDescriptor() << "Warning: PIN diode calibration method not valid, switching to F-factor method" << endl;
+      fCalibrationMode = kFfactor;
+    }
+
+  //---------------------------------------------
+  // fill MPedPhot container using the informations from
+  // MPedestalCam, MExtractedSignalCam and MCalibrationCam
+
+  fNumUsedHiGainFADCSlices = fSignals->GetNumUsedHiGainFADCSlices();
+
+  // is pixid equal to pixidx ?
+  if (    (Int_t)(fPedestal->GetSize()) != fSignals->GetSize())
+  {
+    *fLog << err << "MCalibrateData::ReInit(); sizes of MPedestalCam and MCalibrationCam are different" 
+          << endl;
+  } 
+
+  *fLog << all << "MCalibrateData::ReInit(); fill MPedPhotCam container"
+        << endl;
+  *fLog << all << "     fNumUsedHiGainADCSlices = " 
+        <<  fNumUsedHiGainFADCSlices << endl;
+  *fLog << all << "     pixid, calibrationConversionFactor, ped, pedRMS, pedphot, pedphotRMS :"
+        << endl;
+  for (Int_t pixid=0; pixid<fPedestal->GetSize(); pixid++)
+  {
+    const MPedestalPix    &ped = (*fPedestal)[pixid];
+
+    // pedestals/(used FADC slices)   in [ADC] counts
+    Float_t pedes  = ped.GetPedestal()    * fNumUsedHiGainFADCSlices;
+    Float_t pedrms = ped.GetPedestalRms() * sqrt(fNumUsedHiGainFADCSlices);
+
+    //----------------------------------
+    // get phe/ADC conversion factor
+
+    Float_t hiloconv;
+    Float_t hiloconverr;
+    Float_t calibConv;
+    Float_t calibFFactor;
+
+    if ( !GetConversionFactor(pixid, hiloconv, hiloconverr,
+			      calibConv, calibFFactor ))
+      continue;
+
+    //---------------------------------- 
+
+    // pedestals/(used FADC slices)   in [number of photons] 
+    Float_t pedphot    = pedes  * calibConv;
+    Float_t pedphotrms = pedrms * calibConv;
+
+    (*fPedPhot)[pixid].Set(pedphot, pedphotrms);
+
+    *fLog << all << pixid << ",  " << calibConv << ",  "
+          << ped.GetPedestal() << ",  " << ped.GetPedestalRms() << ",  " 
+          << pedphot << ",  " << pedphotrms << endl;
+  }
+
+  //---------------------------------------------
+
+  fPedPhot->SetReadyToSave();
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Get conversion factor and its error from MCalibrationCam
+// 
+//
+Bool_t MCalibrateData::GetConversionFactor(UInt_t pixidx,
+ Float_t &hiloconv, Float_t &hiloconverr,
+ Float_t &calibConv, Float_t &calibFFactor)
+{
+
+  //
+  // For the moment, we use only a dummy zenith for the calibration:
+  //
+  const Float_t zenith = -1.;
+
+  hiloconv     = 1.;
+  hiloconverr  = 0.;
+  calibConv    = 1.;
+  calibFFactor = 0.;
+
+  if(fCalibrationMode!=kNone)
+  {
+    MCalibrationChargePix &pix   = (MCalibrationChargePix&)(*fCalibrations)[pixidx];       
+    MCalibrationQEPix     &qepix = (MCalibrationQEPix&)    (*fQEs)         [pixidx];       
+    MBadPixelsPix         &bad   = (*fBadPixels)[pixidx];
+    
+    if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
+      return kFALSE;
+    
+    hiloconv   = pix.GetConversionHiLo();
+    hiloconverr= pix.GetConversionHiLoErr();
+
+    const Float_t pheConv = pix.GetMeanConvFADC2Phe();
+    calibFFactor          = pix.GetMeanFFactorFADC2Phot();
+    Float_t calibQE       = 1.;
+    
+    switch(fCalibrationMode)
+    {
+      case kBlindPixel:
+        calibQE      = qepix.GetQECascadesBlindPixel   ( zenith );
+        //        calibQEVar   = qepix.GetQECascadesBlindPixelVar( zenith );
+      break;
+      case kFfactor:
+        calibQE      = qepix.GetQECascadesFFactor   ( zenith );
+        //        calibQEVar   = qepix.GetQECascadesFFactorVar( zenith );
+      break;
+      default:
+      *fLog << warn << "MCalibrateData::GetConversionFactor; Warning: Calibration mode value ("<<fCalibrationMode<<") not known" << endl;
+	      break;
+    }
+    calibConv = pheConv / calibQE;
+
+  }
+
+  return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Apply the calibration factors to the extracted signal according to the 
+// selected calibration method
+//
+Int_t MCalibrateData::Process()
+{
+  /*
+    if (fCalibrations->GetNumPixels() != (UInt_t)fSignals->GetSize())
+    {
+        // FIXME: MExtractedSignal must be of variable size -
+        //        like MCerPhotEvt - because we must be able
+        //        to reduce size by zero supression
+        //        For the moment this check could be done in ReInit...
+        *fLog << err << "MExtractedSignal and MCalibrationCam have different sizes... abort." << endl;
+        return kFALSE;
+    }
+  */
+
+  UInt_t npix = fSignals->GetSize();
+
+  Float_t hiloconv;
+  Float_t hiloconverr;
+  Float_t calibrationConversionFactor;
+  Float_t calibrationConversionFactorErr;
+  
+  for (UInt_t pixidx=0; pixidx<npix; pixidx++)
+    {
+      if ( !GetConversionFactor(pixidx, hiloconv, hiloconverr,
+	    calibrationConversionFactor, calibrationConversionFactorErr) )
+        continue;
+      
+      MExtractedSignalPix &sig =  (*fSignals)[pixidx];
+      
+      Float_t signal;
+      Float_t signalErr = 0.;
+      Float_t nphot,nphotErr;
+            
+      if (sig.IsLoGainUsed())
+        {
+          signal    = sig.GetExtractedSignalLoGain()*hiloconv;
+          signalErr = signal*hiloconverr;
+        }
+      else
+        {
+	  if (sig.GetExtractedSignalHiGain() > 9999.)
+	    {
+	      signal = 0.;
+	      signalErr = 0.;
+	    }
+	  else
+	    signal = sig.GetExtractedSignalHiGain();
+        }
+      
+      nphot    = signal*calibrationConversionFactor;
+      nphotErr = signal*calibrationConversionFactorErr
+	*signal*calibrationConversionFactorErr
+	+signalErr*calibrationConversionFactor
+	*signalErr*calibrationConversionFactor;
+      
+      nphotErr  = TMath::Sqrt(nphotErr);
+      
+      MCerPhotPix *cpix = fCerPhotEvt->AddPixel(pixidx, nphot, nphotErr);
+
+      if (sig.GetNumHiGainSaturated() > 0)
+	cpix->SetPixelHGSaturated();
+
+      if (sig.GetNumLoGainSaturated() > 0)
+	cpix->SetPixelSaturated();
+    }
+  
+  fCerPhotEvt->FixSize();
+  fCerPhotEvt->SetReadyToSave();
+  
+  return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mcalib/MCalibrateData.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MCalibrateData.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MCalibrateData.h	(revision 9661)
@@ -0,0 +1,83 @@
+#ifndef MARS_MCalibrateData
+#define MARS_MCalibrateData
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MCalibrateData
+//                                                                         //
+// Integrates the desired ADC time slices of one pixel and apply           //
+// calibration constants                                                   //
+//                                                                         //
+// Differences between MCalibrateData and MCalibrate :
+// in MCalibrateData
+// - in ReInit the MPedPhot container is filled using
+//      - the pedstals/slice from MPedestalCam
+//      - the number of used FADC slices from MExtractedSignalCam   
+//      - the photon/ADC conversion factor from MCalibrationCam
+//                                                                         //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MGeomCam;
+class MBadPixelsCam;
+class MPedestalCam;
+class MCalibrationChargeCam;
+class MCalibrationQECam;
+class MExtractedSignalCam;
+
+class MPedPhotCam;
+class MCerPhotEvt;
+
+class MCalibrateData : public MTask
+{
+private:
+    MGeomCam              *fCam;
+    MPedestalCam          *fPedestal;     // Pedestals/slice [ADC counts]
+    MBadPixelsCam         *fBadPixels;    // Bad Pixels information
+    MCalibrationChargeCam *fCalibrations; // Calibration constants
+    MCalibrationQECam     *fQEs;          // Quantum efficiencies
+    MExtractedSignalCam   *fSignals;      // Integrated charge in FADCs counts
+
+    MPedPhotCam           *fPedPhot;      // Pedestals/(used slices) [photons]
+    MCerPhotEvt           *fCerPhotEvt;   // Cerenkov Photon Event used for calculation
+
+    Float_t fNumUsedHiGainFADCSlices;
+    Float_t fNumUsedLoGainFADCSlices;
+
+    Float_t  fConversionHiLo;
+    UShort_t fCalibrationMode;
+
+    Bool_t GetConversionFactor(UInt_t, 
+                               Float_t &, Float_t &, Float_t &, Float_t &);    
+
+    Int_t  PreProcess(MParList *pList);
+    Bool_t ReInit(MParList *pList);
+    Int_t  Process();
+
+public:
+
+    enum CalibrationMode_t{kNone=0,kBlindPixel,kFfactor,kPinDiode,kCombined};
+    static const CalibrationMode_t kDefault = kBlindPixel;
+
+    MCalibrateData(CalibrationMode_t calmode = kDefault,const char *name=NULL, const char *title=NULL);
+
+    void SetConversionHiLo(Float_t conv) { fConversionHiLo = conv; };
+    void SetCalibrationMode(CalibrationMode_t calmode=kDefault){ fCalibrationMode=calmode;};
+    
+    ClassDef(MCalibrateData, 0)   // Task to calculate cerenkov photons using calibration constants
+};
+ 
+
+#endif
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mcalib/MCalibrateRelTimes.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MCalibrateRelTimes.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MCalibrateRelTimes.cc	(revision 9661)
@@ -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): Markus Gaug  04/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//   MCalibrateRelTimes
+//
+//   This task takes the extracted arrival times from MArrivalTimeCam for each  
+//   pixel and applies the offset calibrated in MCalibrationRelTimeCam 
+//   The calibrated arrival time and its error gets stored in MCerPhotEvt. 
+//
+//   Input Containers:
+//    MArrivalTimeCam 
+//    MCalibrationRelTimeCam
+//
+//   Output Containers:
+//    MArrivalTime
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MCalibrateRelTimes.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MH.h"
+
+#include "MGeomCam.h"
+
+#include "MCalibrationRelTimeCam.h"
+#include "MCalibrationRelTimePix.h"
+
+#include "MArrivalTimeCam.h"
+#include "MArrivalTimePix.h"
+
+#include "MBadPixelsCam.h"
+#include "MBadPixelsPix.h"
+
+#include "MArrivalTime.h"
+
+ClassImp(MCalibrateRelTimes);
+
+using namespace std;
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+MCalibrateRelTimes::MCalibrateRelTimes(const char *name, const char *title) 
+    : fGeomCam(NULL), fCalibrations(NULL), fBadPixels(NULL), fSignals(NULL), 
+      fArrivalTime(NULL)
+{
+    fName  = name  ? name  : "MCalibrateRelTimes";
+    fTitle = title ? title : "Task to calculate the calibrated arrival times of photons in one event";
+}
+
+// --------------------------------------------------------------------------
+//
+// The PreProcess searches for the following input containers:
+//  - MGeomCam
+//  - MCalibrationRelTimesCam
+//  - MArrivalTimeCam
+//  - MBadPixelsCam
+//
+// The following output containers are also searched and created if
+// they were not found:
+//
+//  - MArrivalTime
+//
+Int_t MCalibrateRelTimes::PreProcess(MParList *pList)
+{
+
+    fSignals = (MArrivalTimeCam*)pList->FindObject(AddSerialNumber("MArrivalTimeCam"));
+
+    if (!fSignals)
+    {
+      *fLog << err << AddSerialNumber("MArrivalTimeCam") << " not found ... aborting" << endl;
+        return kFALSE;
+    }
+
+    fBadPixels = (MBadPixelsCam*)pList->FindObject(AddSerialNumber("MBadPixelsCam"));
+    if (!fBadPixels)
+      *fLog << warn << AddSerialNumber("MBadPixelsCam") << " not found ... no action" << endl;
+    
+
+    fCalibrations = (MCalibrationRelTimeCam*)pList->FindObject(AddSerialNumber("MCalibrationRelTimeCam"));
+    if (!fCalibrations)
+      {
+        *fLog << err << AddSerialNumber("MCalibrationRelTimeCam") << " not found ... aborting." << endl;
+        return kFALSE;
+      }
+
+
+    fArrivalTime = (MArrivalTime*)pList->FindCreateObj(AddSerialNumber("MArrivalTime"));
+    if (!fArrivalTime)
+      {
+        *fLog << err << AddSerialNumber("MArrivalTime") << ": Cannot create ... aborting." << endl;
+        return kFALSE;
+      }
+    
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Check for validity of the selected calibration method, switch to a 
+// different one in case of need
+//
+Bool_t MCalibrateRelTimes::ReInit(MParList *pList)
+{
+  return kTRUE;
+}
+// --------------------------------------------------------------------------
+//
+// Apply the calibration factors to the extracted signal according to the 
+// selected calibration method
+//
+Int_t MCalibrateRelTimes::Process()
+{
+
+  /*
+    if (fCalibrations->GetNumPixels() != (UInt_t)fSignals->GetSize())
+    {
+        // FIXME: MArrivalTime must be of variable size -
+        //        like MCerPhotEvt - because we must be able
+        //        to reduce size by zero supression
+        //        For the moment this check could be done in ReInit...
+        *fLog << err << "MArrivalTime and MCalibrationCam have different sizes... abort." << endl;
+        return kFALSE;
+    }
+  */
+
+  UInt_t npix = fSignals->GetSize();
+
+  Float_t offset    = 0.;
+  Float_t precision = 0.;
+  
+  for (UInt_t pixidx=0; pixidx<npix; pixidx++)
+    {
+
+      MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*fCalibrations)[pixidx];
+      
+      if (fBadPixels)
+        {
+          MBadPixelsPix          &bad = (*fBadPixels)[pixidx];
+          if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
+            continue;
+        }
+      
+      offset     = pix.GetTimeOffset();
+      precision  = pix.GetTimePrecision();
+      
+      MArrivalTimePix &sig =  (*fSignals)[pixidx];
+      
+      Float_t signal;
+      Float_t sigerr;
+            
+      if (sig.IsLoGainUsed())
+        {
+          signal = sig.GetArrivalTimeLoGain();
+          sigerr = sig.GetArrivalTimeLoGainError();
+        }
+      else
+        {
+          signal = sig.GetArrivalTimeHiGain();
+          sigerr = sig.GetArrivalTimeHiGainError();
+        }
+      
+      const Float_t time = signal - offset;
+      Float_t err        = sigerr*sigerr + precision*precision;
+      if (err > 0)
+        err = TMath::Sqrt(err);
+
+      fArrivalTime->SetTime(pixidx,time);
+      fArrivalTime->SetTimeErr(pixidx,err);
+
+    } /* for (UInt_t pixidx=0; pixidx<npix; pixidx++) */
+  
+  fArrivalTime->SetReadyToSave();
+  
+  return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mcalib/MCalibrateRelTimes.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MCalibrateRelTimes.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MCalibrateRelTimes.h	(revision 9661)
@@ -0,0 +1,42 @@
+#ifndef MARS_MCalibrateRelTimes
+#define MARS_MCalibrateRelTimes
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MCalibrateRelTimes                                                      //
+//                                                                         //
+// Calculates the relative arrival time and applies the offset,            //
+// stored in MCalibrationRelTimePix                                        //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MGeomCam;
+class MBadPixelsCam;
+class MCalibrationRelTimeCam;
+class MArrivalTimeCam;
+class MArrivalTime;
+class MCalibrateRelTimes : public MTask
+{
+private:
+    MGeomCam               *fGeomCam;      // Camera geometry container
+    MCalibrationRelTimeCam *fCalibrations; // Calibration rel. time constants
+    MBadPixelsCam          *fBadPixels;    // Bad Pixels information
+    MArrivalTimeCam        *fSignals;      // Extracted Arrival Time
+    MArrivalTime           *fArrivalTime;  // Calibrated arrival times
+
+    Int_t PreProcess(MParList *pList);
+    Bool_t ReInit(MParList *pList);
+    Int_t Process();
+
+public:
+
+    MCalibrateRelTimes(const char *name=NULL, const char *title=NULL);
+
+    ClassDef(MCalibrateRelTimes, 0)   // Task to calculate calibrated relative arrival times
+};
+ 
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationCam.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationCam.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationCam.cc	(revision 9661)
@@ -0,0 +1,501 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug   11/2003 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                               
+// MCalibrationCam                                               
+//                                                               
+// Base class for Camera Calibration results. 
+//
+// Contains TClonesArrays for the following objects:
+// - fPixels:         Array of classes derived from MCalibrationPix, one entry 
+//                    per pixel. Has to be created
+// - fAverageAreas:   Array of classes derived from MCalibrationPix, one entry
+//                    per pixel AREA. Has to be created
+// - fAverageSectors: Array of classes derived from MCalibrationPix, one entry
+//                    per camera SECTOR. Has to be created
+//
+// - fAverageBadAreas: Array of classes derived from MBadPixelsPix, one entry
+//                     per pixel AREA. Is created automatically. 
+// - fAverageBadSectors: Array of classes derived from MBadPixelsPix, one entry
+//                    per camera SECTOR. Is created automatically.
+//
+// All TClonesArrays have to enlarged by the corresponding calls to (e.g. in MGeomApply): 
+// - InitSize()
+// - InitAverageAreas()
+// - InitAverageSectors() 
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCalibrationCam.h"
+
+#include <TClonesArray.h>
+
+#include "MGeomCam.h"
+#include "MGeomPix.h"
+
+#include "MBadPixelsCam.h"
+#include "MBadPixelsPix.h"
+
+#include "MCalibrationPix.h"
+
+ClassImp(MCalibrationCam);
+
+using namespace std;
+
+const Int_t MCalibrationCam::gkNumPulserColors = 4;
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+// Set the following pointer to NULL:
+// - fPixels
+// - fAverageAreas
+// - fAverageSectors
+//
+// Initializes:
+// - fPulserColor to kNONE 
+// - fNumHiGainFADCSlices to 0.
+// - fNumLoGainFADCSlices to 0.
+//
+// Creates a TClonesArray of MBadPixelsPix containers for the TClonesArray's: 
+// - fAverageBadAreas
+// - fAverageBadSectors
+// all initialized to 1 entry
+//
+// Later, a call to InitAverageAreas() and InitAverageSectors() (or Init()) 
+// has to be performed in order to get the dimension correctly.
+//
+MCalibrationCam::MCalibrationCam(const char *name, const char *title)
+    : fPulserColor(kNONE), 
+      fPixels(NULL), fAverageAreas(NULL), fAverageSectors(NULL)
+{
+
+  fAverageBadAreas    = new TClonesArray("MBadPixelsPix",1);
+  fAverageBadSectors  = new TClonesArray("MBadPixelsPix",1);
+
+  fNumHiGainFADCSlices.Set(1);
+  fNumLoGainFADCSlices.Set(1);
+}
+
+// --------------------------------------------------------------------------
+//
+// Deletes the following TClonesArray's of MCalibrationPix containers (if exist):
+// - fPixels
+// - fAverageAreas
+// - fAverageSectors
+//  
+// Deletes the following TClonesArray's of MBadPixelsPix containers (if exist):
+// - fAverageBadAreas
+// - fAverageBadSectors
+//
+MCalibrationCam::~MCalibrationCam()
+{
+
+  //
+  // delete fPixels should delete all Objects stored inside
+  // 
+  if (fPixels)
+    delete fPixels;
+
+  if (fAverageAreas)
+    delete fAverageAreas;
+
+  if (fAverageSectors)
+    delete fAverageSectors;
+
+  delete fAverageBadAreas;
+  delete fAverageBadSectors;
+  
+}
+
+// --------------------------------------
+//
+// Calls the ForEach macro for the TClonesArray fPixels with the argument Clear()
+// 
+// Loops over the fAverageAreas, calling the function Clear() for 
+// every entry in:
+// - fAverageAreas
+// - fAverageBadAreas
+// 
+// Loops over the fAverageSectors, calling the function Clear() for 
+// every entry in:
+// - fAverageSectors
+// - fAverageBadSectors
+// 
+void MCalibrationCam::Clear(Option_t *o)
+{
+
+  fPixels->ForEach(TObject, Clear)();
+
+  //
+  // another ForEach does not compile, thus have to do the loop ourselves:
+  //
+  for (Int_t i=0;i<GetAverageAreas();i++)
+    {
+      fAverageAreas[i].Clear();
+      fAverageBadAreas[i].Clear();
+    }
+
+  //
+  // another ForEach does not compile, thus have to do the loop ourselves:
+  //
+  for (Int_t i=0;i<GetAverageSectors();i++)
+    {
+      fAverageSectors[i].Clear();
+      fAverageBadSectors[i].Clear();
+    }
+  
+  return;
+}
+
+void MCalibrationCam::Copy(TObject& object) const
+{
+  
+  MCalibrationCam &calib = (MCalibrationCam&)object;
+  
+  MParContainer::Copy(calib);
+  
+  calib.fPulserColor          = fPulserColor;
+  
+  const Int_t n3 = GetSize();
+  if (n3 != 0)
+    {
+      calib.InitSize(n3);
+      for (int i=0; i<n3; i++)
+        (*this)[i].Copy(calib[i]);
+    }
+  
+  const Int_t n4 = GetAverageAreas();
+  if (n4 != 0)
+    {
+      calib.InitAverageAreas(n4);
+      for (int i=0; i<n4; i++)
+        {
+          GetAverageArea   (i).Copy(calib.GetAverageArea(i));
+          GetAverageBadArea(i).Copy(calib.GetAverageBadArea(i));
+          calib.fNumUnsuitable      [i] = fNumUnsuitable[i];
+          calib.fNumUnreliable      [i] = fNumUnreliable[i];
+          calib.fNumHiGainFADCSlices[i] = fNumHiGainFADCSlices[i];
+          calib.fNumLoGainFADCSlices[i] = fNumLoGainFADCSlices[i];
+        }
+    }
+  
+  const Int_t n5 = GetAverageSectors();
+  if (n5 != 0)
+    {
+      calib.InitAverageSectors(n5);
+      for (int i=0; i<n5; i++)
+        {
+          GetAverageSector   (i).Copy(calib.GetAverageSector(i));
+          GetAverageBadSector(i).Copy(calib.GetAverageBadSector(i));
+        }
+    }
+}
+
+// -------------------------------------------------------------------
+//
+// Calls TClonesArray::ExpandCreate() for fPixels
+//
+void MCalibrationCam::InitSize(const UInt_t i)
+{
+  fPixels->ExpandCreate(i);
+}
+
+// -------------------------------------------------------------------
+//
+// Calls TClonesArray::ExpandCreate() for:
+// - fAverageAreas
+// - fAverageBadAreas
+//
+void MCalibrationCam::InitAverageAreas(const UInt_t i)
+{
+  fAverageAreas->ExpandCreate(i);
+  fAverageBadAreas->ExpandCreate(i);
+
+  for (UInt_t j=0; j<i; j++)
+    GetAverageArea(j).SetPixId(j);
+  
+  fNumUnsuitable.Set(i);
+  fNumUnreliable.Set(i);
+  fNumHiGainFADCSlices.Set(i);
+  fNumLoGainFADCSlices.Set(i);
+}
+
+// -------------------------------------------------------------------
+//
+// Calls TClonesArray::ExpandCreate() for:
+// - fAverageSectors
+// - fAverageBadSectors
+//
+void MCalibrationCam::InitAverageSectors(const UInt_t i)
+{
+  fAverageSectors->ExpandCreate(i);
+  fAverageBadSectors->ExpandCreate(i);
+
+  for (UInt_t j=0; j<i; j++)
+    GetAverageSector(j).SetPixId(j);
+
+}
+
+// -------------------------------------------------------------------
+//
+// Calls:
+// - InitSize()
+// - InitAverageAreas()
+// - InitAverageSectors()
+//
+void MCalibrationCam::Init(const MGeomCam &geom)
+{
+  InitSize          (geom.GetNumPixels() );
+  InitAverageAreas  (geom.GetNumAreas()  );
+  InitAverageSectors(geom.GetNumSectors());
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the number of un-suitable pixels per area index and -1 if 
+// the area index exceeds the initialized array.
+//
+const Int_t MCalibrationCam::GetNumUnsuitable( Int_t aidx ) const
+{
+  if (aidx < 0)
+    return -1;
+
+  return aidx > fNumUnsuitable.GetSize() ? -1 : fNumUnsuitable[aidx]; 
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the number of un-reliable pixels per area index and -1 if 
+// the area index exceeds the initialized array.
+//
+const Int_t MCalibrationCam::GetNumUnreliable( Int_t aidx ) const
+{
+  if (aidx < 0)
+    return -1;
+
+  return aidx > fNumUnreliable.GetSize() ? -1 : fNumUnreliable[aidx]; 
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the mean number of High-Gain FADC slices per area index and -1 if 
+// the area index exceeds the initialized array.
+//
+const Float_t MCalibrationCam::GetNumHiGainFADCSlices( Int_t aidx ) const
+{
+  if (aidx < 0)
+    return -1;
+
+  return aidx > fNumHiGainFADCSlices.GetSize() ? -1 : fNumHiGainFADCSlices[aidx]; 
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the mean number of Low-Gain FADC slices per area index and -1 if 
+// the area index exceeds the initialized array.
+//
+const Float_t MCalibrationCam::GetNumLoGainFADCSlices( Int_t aidx ) const
+{
+  if (aidx < 0)
+    return -1;
+
+  return aidx > fNumLoGainFADCSlices.GetSize() ? -1 : fNumLoGainFADCSlices[aidx]; 
+}
+
+
+
+// --------------------------------------------------------------------------
+//
+// Returns the current size of the TClonesArray fAverageAreas
+// independently if the MCalibrationPix is filled with values or not.
+//
+const Int_t MCalibrationCam::GetAverageAreas() const
+{
+  return fAverageAreas->GetEntriesFast();
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the current size of the TClonesArray fAverageSectors
+// independently if the MCalibrationPix is filled with values or not.
+//
+const Int_t MCalibrationCam::GetAverageSectors() const
+{
+  return fAverageSectors->GetEntriesFast();
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Get i-th pixel (pixel number)
+//
+MCalibrationPix &MCalibrationCam::operator[](UInt_t i)
+{
+  return *static_cast<MCalibrationPix*>(fPixels->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th pixel (pixel number)
+//
+const MCalibrationPix &MCalibrationCam::operator[](UInt_t i) const
+{
+  return *static_cast<MCalibrationPix*>(fPixels->UncheckedAt(i));
+}
+
+// Returns the current size of the TClonesArray fPixels 
+// independently if the MCalibrationPix is filled with values or not.
+const Int_t MCalibrationCam::GetSize() const
+{
+  return fPixels->GetEntriesFast();
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th average pixel (area number)
+//
+MCalibrationPix &MCalibrationCam::GetAverageArea(UInt_t i)
+{
+  return *static_cast<MCalibrationPix*>(fAverageAreas->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th average pixel (area number)
+//
+const MCalibrationPix &MCalibrationCam::GetAverageArea(UInt_t i) const 
+{
+  return *static_cast<MCalibrationPix*>(fAverageAreas->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th average pixel (sector number)
+//
+MCalibrationPix &MCalibrationCam::GetAverageSector(UInt_t i)
+{
+  return *static_cast<MCalibrationPix*>(fAverageSectors->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th average pixel (sector number)
+//
+const MCalibrationPix &MCalibrationCam::GetAverageSector(UInt_t i) const 
+{
+  return *static_cast<MCalibrationPix*>(fAverageSectors->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th average pixel (area number)
+//
+MBadPixelsPix &MCalibrationCam::GetAverageBadArea(UInt_t i)
+{
+  return *static_cast<MBadPixelsPix*>(fAverageBadAreas->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th average pixel (area number)
+//
+const MBadPixelsPix &MCalibrationCam::GetAverageBadArea(UInt_t i) const 
+{
+  return *static_cast<MBadPixelsPix*>(fAverageBadAreas->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th average pixel (sector number)
+//
+MBadPixelsPix &MCalibrationCam::GetAverageBadSector(UInt_t i)
+{
+  return *static_cast<MBadPixelsPix*>(fAverageBadSectors->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th average pixel (sector number)
+//
+const MBadPixelsPix &MCalibrationCam::GetAverageBadSector(UInt_t i) const 
+{
+  return *static_cast<MBadPixelsPix*>(fAverageBadSectors->UncheckedAt(i));
+}
+
+
+
+// --------------------------------------------------------------------------
+//
+// Dummy needed for compilation with MCamEvent
+//
+Bool_t MCalibrationCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
+{
+  return kTRUE;
+}
+
+
+
+// --------------------------------------------------------------------------
+//
+// Calls MCalibrationPix::DrawClone()
+//
+void MCalibrationCam::DrawPixelContent(Int_t idx) const
+{
+  (*this)[idx].DrawClone();
+}
+
+void MCalibrationCam::SetNumHiGainFADCSlices( const Float_t i, const Int_t aidx)
+{
+  if (aidx < 0)
+    return;
+
+  if (aidx < fNumHiGainFADCSlices.GetSize())
+    fNumHiGainFADCSlices[aidx] = i;  
+}
+
+void MCalibrationCam::SetNumLoGainFADCSlices( const Float_t i, const Int_t aidx)
+{
+  if (aidx < 0)
+    return;
+  if (aidx < fNumLoGainFADCSlices.GetSize())
+    fNumLoGainFADCSlices[aidx] = i; 
+}
+
+void MCalibrationCam::SetNumUnsuitable( const UInt_t i, const Int_t aidx)
+{
+  if (aidx < 0)
+    return;
+
+  if (aidx < fNumUnsuitable.GetSize())
+    fNumUnsuitable[aidx] = i;  
+}
+
+void MCalibrationCam::SetNumUnreliable( const UInt_t i, const Int_t aidx)
+{
+  if (aidx < 0)
+    return;
+  if (aidx < fNumUnreliable.GetSize())
+    fNumUnreliable[aidx] = i; 
+}
Index: /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationCam.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationCam.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationCam.h	(revision 9661)
@@ -0,0 +1,95 @@
+#ifndef MARS_MCalibrationCam
+#define MARS_MCalibrationCam
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+#ifndef MARS_MCamEvent
+#include "MCamEvent.h"
+#endif
+#ifndef ROOT_TArrayI
+#include "TArrayI.h"
+#endif
+#ifndef ROOT_TArrayF
+#include "TArrayF.h"
+#endif
+
+class TClonesArray;
+
+class MCalibrationPix;
+class MBadPixelsPix;
+class MBadPixelsCam;
+class MGeomCam;
+class MCalibrationCam : public MParContainer, public MCamEvent
+{
+public:
+
+  enum PulserColor_t { kCT1=0, kGREEN=1, kBLUE=2, kUV=3, kNONE=4 }; // Possible Pulser colours
+  static const Int_t gkNumPulserColors;                     // Number of Pulser colours (now set to: 4)
+  
+protected:
+
+  TArrayI fNumUnsuitable;            // Number uncalibrated Pixels per area index 
+  TArrayI fNumUnreliable;            // Number unreliable   Pixels per area index 
+
+  TArrayF fNumHiGainFADCSlices;      // Number High-Gain FADC slices used by extractor      
+  TArrayF fNumLoGainFADCSlices;      // Number Low -Gain FADC slices used by extractor
+  
+  PulserColor_t fPulserColor;        // Colour of the pulsed LEDs
+
+  TClonesArray *fPixels;             //-> Array of MCalibrationPix, one per pixel
+  TClonesArray *fAverageAreas;       //-> Array of MCalibrationPix, one per pixel area
+  TClonesArray *fAverageSectors;     //-> Array of MCalibrationPix, one per camera sector
+  TClonesArray *fAverageBadAreas;    //-> Array of MBadPixelsPix,   one per pixel area
+  TClonesArray *fAverageBadSectors;  //-> Array of MBadPixelsPix,   one per camera sector
+  
+public:
+
+  MCalibrationCam(const char *name=NULL, const char *title=NULL);
+  virtual ~MCalibrationCam();
+  
+  virtual void Clear           ( Option_t *o="");
+  virtual void DrawPixelContent( Int_t num) const;    
+  virtual void Copy(TObject& object) const;
+  
+  // Getters
+  const Int_t            GetAverageAreas        ()             const;
+        MCalibrationPix &GetAverageArea         ( UInt_t i );
+  const MCalibrationPix &GetAverageArea         ( UInt_t i )   const;
+        MBadPixelsPix   &GetAverageBadArea      ( UInt_t i );
+  const MBadPixelsPix   &GetAverageBadArea      ( UInt_t i )   const;
+        MBadPixelsPix   &GetAverageBadSector    ( UInt_t i );
+  const MBadPixelsPix   &GetAverageBadSector    ( UInt_t i )   const;
+        MCalibrationPix &GetAverageSector       ( UInt_t i );
+  const Int_t            GetAverageSectors      ()             const;  
+  const MCalibrationPix &GetAverageSector       ( UInt_t i   ) const;
+  const Float_t          GetNumHiGainFADCSlices ( Int_t aidx=0 ) const;
+  const Float_t          GetNumLoGainFADCSlices ( Int_t aidx=0 ) const;
+  const Int_t            GetNumUnsuitable       ( Int_t aidx ) const;
+  const Int_t            GetNumUnreliable       ( Int_t aidx ) const;
+
+  virtual Bool_t         GetPixelContent     ( Double_t &val, Int_t idx, 
+                                               const MGeomCam &cam, Int_t type=0) const;
+  const PulserColor_t    GetPulserColor()                 const { return fPulserColor;         }
+  const Int_t            GetSize()                        const;
+
+        MCalibrationPix &operator[]          ( UInt_t i );
+  const MCalibrationPix &operator[]          ( UInt_t i ) const;
+
+  // Inits
+  virtual void  Init           ( const MGeomCam &geom         );
+  void  InitSize               ( const UInt_t i               );
+  void  InitAverageAreas       ( const UInt_t i               );
+  void  InitAverageSectors     ( const UInt_t i               );
+
+  // Setters
+  void  SetNumHiGainFADCSlices ( const Float_t f, const Int_t aidx=0 );
+  void  SetNumLoGainFADCSlices ( const Float_t f, const Int_t aidx=0 );
+  void  SetNumUnsuitable       ( const UInt_t i,  const Int_t aidx );  
+  void  SetNumUnreliable       ( const UInt_t i,  const Int_t aidx ); 
+  void  SetPulserColor         ( const PulserColor_t col=kCT1 )  { fPulserColor = col; }
+  
+  ClassDef(MCalibrationCam, 3)	// Base class Container for Calibration Results Camera
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationChargeBlindCam.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationChargeBlindCam.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationChargeBlindCam.cc	(revision 9661)
@@ -0,0 +1,239 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug   07/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                               
+// MCalibrationChargeBlindCam                                               
+//                                                               
+// Base class for Blind Pixels Calibration results. 
+//
+// Contains TClonesArrays for the following objects:
+// - fBlindPixels:    Array of classes derived from MCalibrationChargeBlindPix, one entry 
+//                    per blind pixel. 
+//
+// All TClonesArrays have to enlarged by the corresponding calls to (e.g. in MGeomApply): 
+// - InitSize()
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCalibrationChargeBlindCam.h"
+#include "MCalibrationChargeBlindPix.h"
+
+#include "MCalibrationCam.h"
+#include "MCalibrationPix.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include <TClonesArray.h>
+
+ClassImp(MCalibrationChargeBlindCam);
+
+using namespace std;
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+// Set the following pointer to NULL:
+// - fBlindPixels
+//
+// Initializes:
+// - fPulserColor to kNONE 
+//
+// Creates a TClonesArray of MCalibrationChargeBlindPix containers for the TClonesArray's: 
+// - fBlindPixels
+// all initialized to 1 entry
+//
+// Later, a call to InitSize() 
+// has to be performed in order to get the dimension correctly.
+//
+MCalibrationChargeBlindCam::MCalibrationChargeBlindCam(const char *name, const char *title)
+    : fPulserColor(MCalibrationCam::kNONE), 
+      fBlindPixels(NULL), 
+      fValid(kFALSE)
+{
+  fName  = name  ? name  : "MCalibrationChargeBlindCam";
+  fTitle = title ? title : "Container for the Calibration Information of the blind pixels in the camera";
+
+  fBlindPixels = new TClonesArray("MCalibrationChargeBlindPix",1);
+}
+
+// --------------------------------------------------------------------------
+//
+// Deletes the following TClonesArray's of MCalibrationPix containers (if exist):
+// - fBlindPixels
+//
+MCalibrationChargeBlindCam::~MCalibrationChargeBlindCam()
+{
+
+  //
+  // delete fBlindPixels should delete all Objects stored inside
+  // 
+  delete fBlindPixels;
+
+}
+
+// --------------------------------------
+//
+// Calls the ForEach macro for the TClonesArray fBlindPixels with the argument Clear()
+// 
+void MCalibrationChargeBlindCam::Clear(Option_t *o)
+{
+
+  fBlindPixels->ForEach(TObject, Clear)();
+
+  return;
+}
+
+// -----------------------------------------------------
+//
+// own copy function to do the initialization correctly
+//
+void MCalibrationChargeBlindCam::Copy(TObject& object) const
+{
+  
+  MCalibrationChargeBlindCam &calib = (MCalibrationChargeBlindCam&)object;
+  
+  MParContainer::Copy(calib);
+  
+  calib.fPulserColor          = fPulserColor;
+  
+  const Int_t n3 = GetSize();
+  if (n3 != 0)
+    {
+      calib.InitSize(n3);
+      for (int i=0; i<n3; i++)
+        (*this)[i].Copy(calib[i]);
+    }
+  
+}
+
+// -------------------------------------------------------------------
+//
+// Calls TClonesArray::ExpandCreate() for fBlindPixels
+//
+void MCalibrationChargeBlindCam::InitSize(const UInt_t i)
+{
+  fBlindPixels->ExpandCreate(i);
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Get i-th blind pixel (pixel number)
+//
+MCalibrationChargeBlindPix &MCalibrationChargeBlindCam::operator[](UInt_t i)
+{
+  return *static_cast<MCalibrationChargeBlindPix*>(fBlindPixels->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th pixel (pixel number)
+//
+const MCalibrationChargeBlindPix &MCalibrationChargeBlindCam::operator[](UInt_t i) const
+{
+  return *static_cast<MCalibrationChargeBlindPix*>(fBlindPixels->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the current size of the TClonesArray fBlindPixels 
+// independently if the MCalibrationChargeBlindPix is filled with values or not.
+//
+const Int_t MCalibrationChargeBlindCam::GetSize() const
+{
+  return fBlindPixels->GetEntriesFast();
+}
+
+// --------------------------------------------------------------------------
+//
+// Print first the results of the pixels 
+// and then the ones which are not FitValid
+//
+void MCalibrationChargeBlindCam::Print(Option_t *o) const
+{
+
+  *fLog << all << GetDescriptor() << ":" << endl;
+  int id = 0;
+  
+  *fLog << all << "Calibrated Blind pixels:" << endl;
+  *fLog << all << endl;
+
+  TIter Next(fBlindPixels);
+  MCalibrationChargeBlindPix *pix;
+  while ((pix=(MCalibrationChargeBlindPix*)Next()))
+    {
+      
+      if (pix->IsSinglePheFitOK()) 
+	{                            
+
+          *fLog << all 
+                << Form("%s%3i","BlindPixel: ",pix->GetPixId())
+                << Form("%s%4.2f%s%4.2f","  Lambda: ",pix->GetLambda(),"+-",pix->GetLambdaErr())
+		<< Form("%s%4.2f%s%4.2f","  Mu0: ",pix->GetMu0(),"+-",pix->GetMu0Err())
+		<< Form("%s%4.2f%s%4.2f","  Mu1: ",pix->GetMu1(),"+-",pix->GetMu1Err()) 
+		<< Form("%s%4.2f%s%4.2f","  Sigma0: ",pix->GetSigma0(),"+-",pix->GetSigma0Err())
+		<< Form("%s%4.2f%s%4.2f","  Sigma1: ",pix->GetSigma1(),"+-",pix->GetSigma1Err())
+		<< endl;
+	  *fLog << all
+                << " Pedestal Fit OK? :" << pix->IsPedestalFitOK() 
+		<< Form("%s%4.2f%s%4.2f","  Lambda (Check): " ,pix->GetLambdaCheck(),"+-",pix->GetLambdaCheckErr()) << endl;
+	  *fLog << all
+                << " Flux available? :" << pix->IsFluxInsidePlexiglassAvailable() 
+		<< Form("%s%4.2f%s%4.2f","  Flux: " ,pix->GetFluxInsidePlexiglass(),"+-",pix->GetFluxInsidePlexiglassErr())
+		<< endl;
+          id++;
+	}
+    }
+  *fLog << all << id << " blind pixels OK" << endl;
+  id = 0;
+  
+  TIter Next2(fBlindPixels);
+  while ((pix=(MCalibrationChargeBlindPix*)Next2()))
+    {
+      
+      if (!pix->IsSinglePheFitOK()) 
+	{                            
+
+          *fLog << all 
+                << Form("%s%3i","BlindPixel: ",pix->GetPixId())
+                << Form("%s%4.2f%s%4.2f","  Lambda: ",pix->GetLambda(),"+-",pix->GetLambdaErr())
+		<< Form("%s%4.2f%s%4.2f","  Mu0: ",pix->GetMu0(),"+-",pix->GetMu0Err())
+		<< Form("%s%4.2f%s%4.2f","  Mu1: ",pix->GetMu1(),"+-",pix->GetMu1Err()) 
+		<< Form("%s%4.2f%s%4.2f","  Sigma0: ",pix->GetSigma0(),"+-",pix->GetSigma0Err())
+		<< Form("%s%4.2f%s%4.2f","  Sigma1: ",pix->GetSigma1(),"+-",pix->GetSigma1Err())
+		<< endl;
+	  *fLog << all
+                << " Pedestal Fit OK? :" << pix->IsPedestalFitOK() 
+		<< Form("%s%4.2f%s%4.2f","  Lambda (Check): " ,pix->GetLambdaCheck(),"+-",pix->GetLambdaCheckErr()) << endl;
+	  *fLog << all
+                << " Flux available? :" << pix->IsFluxInsidePlexiglassAvailable() 
+		<< Form("%s%4.2f%s%4.2f","  Flux: " ,pix->GetFluxInsidePlexiglass(),"+-",pix->GetFluxInsidePlexiglassErr())
+		<< endl;
+          id++;
+	}
+    }
+  *fLog << all << id << " blind pixels NOT OK" << endl;
+  
+}
Index: /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationChargeBlindCam.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationChargeBlindCam.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationChargeBlindCam.h	(revision 9661)
@@ -0,0 +1,49 @@
+#ifndef MARS_MCalibrationChargeBlindCam
+#define MARS_MCalibrationChargeBlindCam
+
+#ifndef MARS_MCalibrationCam
+#include "MCalibrationCam.h"
+#endif
+
+class MCalibrationChargeBlindPix;
+class TClonesArray;
+class MCalibrationChargeBlindCam : public MParContainer
+{
+private:
+
+  MCalibrationCam::PulserColor_t fPulserColor;  // Colour of the pulsed LEDs
+
+  TClonesArray *fBlindPixels;                   //-> Array of MCalibrationChargeBlindPix
+
+  Bool_t fValid;
+
+public:
+  MCalibrationChargeBlindCam(const char *name=NULL, const char *title=NULL);
+  ~MCalibrationChargeBlindCam();
+  
+  void   Clear ( Option_t *o="" );
+  void   Copy ( TObject& obj ) const;
+
+  // Getters
+  const Int_t                          GetSize()        const;
+  const MCalibrationCam::PulserColor_t GetColor() const { return fPulserColor; }
+
+        MCalibrationChargeBlindPix &operator[] ( UInt_t i );
+  const MCalibrationChargeBlindPix &operator[] ( UInt_t i ) const;
+
+  Bool_t IsValid() const { return fValid; }
+
+  // Setters
+  void  SetColor ( const MCalibrationCam::PulserColor_t col )  { fPulserColor = col; }
+  void  SetValid () { fValid = kTRUE; }
+
+  // Inits
+  void  InitSize( const UInt_t i);
+  
+  // Prints
+  void   Print(Option_t *o="") const;
+
+  ClassDef(MCalibrationChargeBlindCam, 1) // Container Blind Pixel Calibration Results Camera
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationChargeBlindPix.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationChargeBlindPix.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationChargeBlindPix.cc	(revision 9661)
@@ -0,0 +1,643 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug   02/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                               
+// MCalibrationChargeBlindPix    
+//
+// Storage container of the fit results of the Blind Pixel signal 
+// (from MHCalibrationChargeBlindPix). 
+//
+// The Flux is calculated in photons per mm^2 in the camera plane. 
+//
+// Currently, the following numbers are implemented:
+// - gkBlindPixelArea: 100 mm^2
+// - Average QE of Blind Pixel: 
+//    gkBlindPixelQEGreen: 0.154
+//    gkBlindPixelQEBlue : 0.226
+//    gkBlindPixelQEUV   : 0.247
+//    gkBlindPixelQECT1  : 0.247
+// - Average QE Error of Blind Pixel: 
+//    gkBlindPixelQEGreenErr: 0.015;
+//    gkBlindPixelQEBlueErr : 0.02;
+//    gkBlindPixelQEUVErr   : 0.02;
+//    gkBlindPixelQECT1Err  : 0.02;
+// - Attenuation factor Blind Pixel:
+//    gkBlindPixelAttGreen :  1.97;
+//    gkBlindPixelAttBlue  :  1.96;
+//    gkBlindPixelAttUV    :  1.95;
+//    gkBlindPixelAttCT1   :  1.95;
+//
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCalibrationChargeBlindPix.h"
+#include "MCalibrationCam.h"
+
+#include <TH1.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MCalibrationChargeBlindPix);
+
+using namespace std;
+const Float_t MCalibrationChargeBlindPix::gkBlindPixelArea       = 100;
+const Float_t MCalibrationChargeBlindPix::gkBlindPixelAttGreen   = 1.97;
+const Float_t MCalibrationChargeBlindPix::gkBlindPixelAttBlue    = 1.96;
+const Float_t MCalibrationChargeBlindPix::gkBlindPixelAttUV      = 1.95;
+const Float_t MCalibrationChargeBlindPix::gkBlindPixelAttCT1     = 1.95;
+const Float_t MCalibrationChargeBlindPix::gkBlindPixelQEUnCoatedGreen    = 0.154;
+const Float_t MCalibrationChargeBlindPix::gkBlindPixelQEUnCoatedBlue     = 0.226;
+const Float_t MCalibrationChargeBlindPix::gkBlindPixelQEUnCoatedUV       = 0.247;
+const Float_t MCalibrationChargeBlindPix::gkBlindPixelQEUnCoatedCT1      = 0.247;
+const Float_t MCalibrationChargeBlindPix::gkBlindPixelQEUnCoatedGreenErr = 0.005;
+const Float_t MCalibrationChargeBlindPix::gkBlindPixelQEUnCoatedBlueErr  = 0.007;
+const Float_t MCalibrationChargeBlindPix::gkBlindPixelQEUnCoatedUVErr    = 0.01;
+const Float_t MCalibrationChargeBlindPix::gkBlindPixelQEUnCoatedCT1Err   = 0.01;
+const Float_t MCalibrationChargeBlindPix::gkBlindPixelQECoatedGreen      = 0.192;
+const Float_t MCalibrationChargeBlindPix::gkBlindPixelQECoatedBlue       = 0.27;
+const Float_t MCalibrationChargeBlindPix::gkBlindPixelQECoatedUV         = 0.285;
+const Float_t MCalibrationChargeBlindPix::gkBlindPixelQECoatedCT1        = 0.285;
+const Float_t MCalibrationChargeBlindPix::gkBlindPixelQECoatedGreenErr   = 0.007;
+const Float_t MCalibrationChargeBlindPix::gkBlindPixelQECoatedBlueErr    = 0.01;
+const Float_t MCalibrationChargeBlindPix::gkBlindPixelQECoatedUVErr      = 0.012;
+const Float_t MCalibrationChargeBlindPix::gkBlindPixelQECoatedCT1Err     = 0.012;
+const Float_t MCalibrationChargeBlindPix::gkBlindPixelCollectionEff      = 0.95; 
+const Float_t MCalibrationChargeBlindPix::gkBlindPixelCollectionEffErr   = 0.02; 
+// --------------------------------------------------------------------------
+//
+// Default Constructor. 
+//
+// Calls:
+// - Clear()
+// - SetCoated()
+//
+MCalibrationChargeBlindPix::MCalibrationChargeBlindPix(const char *name, const char *title)
+{
+
+  fName  = name  ? name  : "MCalibrationChargeBlindPix";
+  fTitle = title ? title : "Container of the fit results of the blind pixel";
+
+  SetCoated();
+  Clear();
+}
+
+
+// ------------------------------------------------------------------------
+//
+// Sets:
+// - all flags to kFALSE
+// - all variables to -1.
+// - the fColor to MCalibrationCam::kNONE
+//
+// Calls: 
+// - MCalibrationChargePix::Clear()
+//
+void MCalibrationChargeBlindPix::Clear(Option_t *o)
+{
+
+  fFluxInsidePlexiglass    = -1.;
+  fFluxInsidePlexiglassVar = -1.;
+  fLambda                  = -1.;
+  fLambdaCheck             = -1.;
+  fLambdaVar               = -1.;
+  fMu0                     = -1.;
+  fMu0Err                  = -1.;
+  fMu1                     = -1.;
+  fMu1Err                  = -1.;
+  fSigma0                  = -1.;
+  fSigma0Err               = -1.;
+  fSigma1                  = -1.;
+  fSigma1Err               = -1.;
+
+  SetOscillating                   ( kFALSE );
+  SetExcluded                      ( kFALSE );
+  SetChargeFitValid                ( kFALSE );
+  SetPedestalFitOK                 ( kFALSE );
+  SetSinglePheFitOK                ( kFALSE );
+  SetFluxInsidePlexiglassAvailable ( kFALSE );
+  
+  SetColor(MCalibrationCam::kNONE);
+
+  MCalibrationChargePix::Clear();
+}
+
+void  MCalibrationChargeBlindPix::SetFluxInsidePlexiglassAvailable( const Bool_t b)
+{
+    b ? SETBIT(fFlags,kFluxInsidePlexiglassAvailable) : CLRBIT(fFlags,kFluxInsidePlexiglassAvailable);
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the Coated Bit from outside 
+//
+void  MCalibrationChargeBlindPix::SetCoated( const Bool_t b)
+{
+    b ? SETBIT(fFlags,kCoated) : CLRBIT(fFlags,kCoated);
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the Oscillating Bit from outside 
+//
+void  MCalibrationChargeBlindPix::SetOscillating( const Bool_t b)
+{
+    b ? SETBIT(fFlags,kOscillating) : CLRBIT(fFlags,kOscillating);
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the ChargeFitValid Bit from outside 
+//
+void  MCalibrationChargeBlindPix::SetChargeFitValid( const Bool_t b)
+{
+    b ? SETBIT(fFlags,kChargeFitValid) : CLRBIT(fFlags,kChargeFitValid);
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the PedestalFitValid Bit from outside 
+//
+void  MCalibrationChargeBlindPix::SetPedestalFitOK( const Bool_t b)
+{
+    b ? SETBIT(fFlags,kPedestalFitOK) : CLRBIT(fFlags,kPedestalFitOK);
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the SinglePheFitValid Bit from outside 
+//
+void  MCalibrationChargeBlindPix::SetSinglePheFitOK( const Bool_t b)
+{
+    b ? SETBIT(fFlags,kSinglePheFitOK) : CLRBIT(fFlags,kSinglePheFitOK);
+}
+
+// --------------------------------------------------------------------------
+//
+// Return -1 if fFluxInsidePlexiglassVar is smaller than 0.
+// Return square root of fFluxInsidePlexiglassVar
+// 
+Float_t MCalibrationChargeBlindPix::GetFluxInsidePlexiglassErr() const
+{
+  if (fFluxInsidePlexiglassVar < 0.)
+    return -1.;
+  
+  return TMath::Sqrt(fFluxInsidePlexiglassVar);
+}
+
+// --------------------------------------------------------------------------
+//
+// Return -1 if fFluxInsidePlexiglassVar is smaller than 0.
+// Return -1 if fFluxInsidePlexiglass    is 0.
+// Return fFluxInsidePlexiglassVar / fFluxInsidePlexiglass^2
+// 
+Float_t MCalibrationChargeBlindPix::GetFluxInsidePlexiglassRelVar() const
+{
+  if (fFluxInsidePlexiglassVar < 0.)
+    return -1.;
+
+  if (fFluxInsidePlexiglass == 0.)
+    return -1.;
+  
+  return fFluxInsidePlexiglassVar / (fFluxInsidePlexiglass * fFluxInsidePlexiglass) ;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return -1 if fLambdaVar is smaller than 0.
+// Return square root of fLambdaVar
+// 
+Float_t MCalibrationChargeBlindPix::GetLambdaErr() const
+{
+  if (fLambdaVar < 0.)
+    return -1.;
+  
+  return TMath::Sqrt(fLambdaVar);
+}
+
+// --------------------------------------------------------------------------
+//
+// Return -1 if fLambdaVar is smaller than 0.
+// Return -1 if fLambda    is 0.
+// Return fLambdaVar / (fLambda * fLambda )
+// 
+Float_t MCalibrationChargeBlindPix::GetLambdaRelVar() const
+{
+  if (fLambdaVar < 0.)
+    return -1.;
+  
+  if (fLambda  == 0.)
+    return -1.;
+  
+  return fLambdaVar / fLambda / fLambda ;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return -1 if gkBlindPixelQEGreenErr is smaller than 0.
+// Return -1 if gkBlindPixelQEGreen    is 0.
+// Return gkBlindPixelQEGreenErr^2 / (gkBlindPixelQEGreen^2 )
+// 
+const Float_t MCalibrationChargeBlindPix::GetBlindPixelQEGreen() const
+{
+
+  if (IsCoated())
+    {
+      if (gkBlindPixelQECoatedGreen < 0.)
+        return -1.;
+      
+      return gkBlindPixelQECoatedGreen;
+    }
+  else
+    {
+      if (gkBlindPixelQEUnCoatedGreen < 0.)
+        return -1.;
+      
+      return gkBlindPixelQEUnCoatedGreen;
+    }
+  
+}
+
+// --------------------------------------------------------------------------
+//
+// Return -1 if gkBlindPixelQEBlueErr is smaller than 0.
+// Return -1 if gkBlindPixelQEBlue    is 0.
+// Return gkBlindPixelQEBlueErr^2 / gkBlindPixelQEBlue^2
+// 
+const Float_t MCalibrationChargeBlindPix::GetBlindPixelQEBlue() const
+{
+  if (IsCoated())
+    {
+      if (gkBlindPixelQECoatedBlue < 0.)
+        return -1.;
+      
+      return gkBlindPixelQECoatedBlue;
+    }
+  else
+    {
+      if (gkBlindPixelQEUnCoatedBlue < 0.)
+        return -1.;
+      
+      return gkBlindPixelQEUnCoatedBlue;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Return -1 if gkBlindPixelQEUVErr is smaller than 0.
+// Return -1 if gkBlindPixelQEUV    is 0.
+// Return gkBlindPixelQEUVErr ^2 / gkBlindPixelQEUV^2 
+// 
+const Float_t MCalibrationChargeBlindPix::GetBlindPixelQEUV() const
+{
+
+  if (IsCoated())
+    {
+      if (gkBlindPixelQECoatedUV < 0.)
+        return -1.;
+      
+      return gkBlindPixelQECoatedUV;
+    }
+  else
+    {
+      if (gkBlindPixelQEUnCoatedUV < 0.)
+        return -1.;
+      
+      
+      return gkBlindPixelQEUnCoatedUV;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Return -1 if gkBlindPixelQECT1Err is smaller than 0.
+// Return -1 if gkBlindPixelQECT1    is 0.
+// Return gkBlindPixelQECT1Err ^2 / gkBlindPixelQECT1^2
+// 
+const Float_t MCalibrationChargeBlindPix::GetBlindPixelQECT1() const
+{
+
+  if (IsCoated())
+    {
+      if (gkBlindPixelQECoatedCT1 < 0.)
+        return -1.;
+      
+      return gkBlindPixelQECoatedCT1;
+    }
+  else
+    {
+      if (gkBlindPixelQEUnCoatedCT1 < 0.)
+        return -1.;
+      
+      return gkBlindPixelQEUnCoatedCT1;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Return -1 if gkBlindPixelQEGreenErr is smaller than 0.
+// Return -1 if gkBlindPixelQEGreen    is 0.
+// Return gkBlindPixelQEGreenErr^2 / (gkBlindPixelQEGreen^2 )
+// 
+const Float_t MCalibrationChargeBlindPix::GetBlindPixelQEGreenRelVar() const
+{
+
+  if (IsCoated())
+    {
+      if (gkBlindPixelQECoatedGreenErr < 0.)
+        return -1.;
+      
+      if (gkBlindPixelQECoatedGreen  == 0.)
+        return -1.;
+      
+      return gkBlindPixelQECoatedGreenErr * gkBlindPixelQECoatedGreenErr 
+         / gkBlindPixelQECoatedGreen / gkBlindPixelQECoatedGreen ;
+    }
+  else
+    {
+      if (gkBlindPixelQEUnCoatedGreenErr < 0.)
+        return -1.;
+      
+      if (gkBlindPixelQEUnCoatedGreen  == 0.)
+        return -1.;
+      
+      return gkBlindPixelQEUnCoatedGreenErr * gkBlindPixelQEUnCoatedGreenErr 
+         / gkBlindPixelQEUnCoatedGreen / gkBlindPixelQEUnCoatedGreen ;
+    }
+  
+}
+
+// --------------------------------------------------------------------------
+//
+// Return -1 if gkBlindPixelQEBlueErr is smaller than 0.
+// Return -1 if gkBlindPixelQEBlue    is 0.
+// Return gkBlindPixelQEBlueErr^2 / gkBlindPixelQEBlue^2
+// 
+const Float_t MCalibrationChargeBlindPix::GetBlindPixelQEBlueRelVar() const
+{
+  if (IsCoated())
+    {
+      if (gkBlindPixelQECoatedBlueErr < 0.)
+        return -1.;
+      
+      if (gkBlindPixelQECoatedBlue  == 0.)
+        return -1.;
+      
+      return gkBlindPixelQECoatedBlueErr * gkBlindPixelQECoatedBlueErr 
+         / gkBlindPixelQECoatedBlue / gkBlindPixelQECoatedBlue ;
+    }
+  else
+    {
+      if (gkBlindPixelQEUnCoatedBlueErr < 0.)
+        return -1.;
+      
+      if (gkBlindPixelQEUnCoatedBlue  == 0.)
+        return -1.;
+      
+      return gkBlindPixelQEUnCoatedBlueErr * gkBlindPixelQEUnCoatedBlueErr 
+         / gkBlindPixelQEUnCoatedBlue / gkBlindPixelQEUnCoatedBlue ;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Return -1 if gkBlindPixelQEUVErr is smaller than 0.
+// Return -1 if gkBlindPixelQEUV    is 0.
+// Return gkBlindPixelQEUVErr ^2 / gkBlindPixelQEUV^2 
+// 
+const Float_t MCalibrationChargeBlindPix::GetBlindPixelQEUVRelVar() const
+{
+
+  if (IsCoated())
+    {
+      if (gkBlindPixelQECoatedUVErr < 0.)
+        return -1.;
+      
+      if (gkBlindPixelQECoatedUV  == 0.)
+        return -1.;
+      
+      return gkBlindPixelQECoatedUVErr * gkBlindPixelQECoatedUVErr 
+         / gkBlindPixelQECoatedUV / gkBlindPixelQECoatedUV ;
+    }
+  else
+    {
+      if (gkBlindPixelQEUnCoatedUVErr < 0.)
+        return -1.;
+      
+      if (gkBlindPixelQEUnCoatedUV  == 0.)
+        return -1.;
+      
+      return gkBlindPixelQEUnCoatedUVErr * gkBlindPixelQEUnCoatedUVErr 
+         / gkBlindPixelQEUnCoatedUV / gkBlindPixelQEUnCoatedUV ;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Return -1 if gkBlindPixelQECT1Err is smaller than 0.
+// Return -1 if gkBlindPixelQECT1    is 0.
+// Return gkBlindPixelQECT1Err ^2 / gkBlindPixelQECT1^2
+// 
+const Float_t MCalibrationChargeBlindPix::GetBlindPixelQECT1RelVar() const
+{
+
+  if (IsCoated())
+    {
+      if (gkBlindPixelQECoatedCT1Err < 0.)
+        return -1.;
+      
+      if (gkBlindPixelQECoatedCT1  == 0.)
+        return -1.;
+      
+      return gkBlindPixelQECoatedCT1Err * gkBlindPixelQECoatedCT1Err 
+         / gkBlindPixelQECoatedCT1 / gkBlindPixelQECoatedCT1 ;
+    }
+  else
+    {
+      if (gkBlindPixelQEUnCoatedCT1Err < 0.)
+        return -1.;
+      
+      if (gkBlindPixelQEUnCoatedCT1  == 0.)
+        return -1.;
+      
+      return gkBlindPixelQEUnCoatedCT1Err * gkBlindPixelQEUnCoatedCT1Err 
+         / gkBlindPixelQEUnCoatedCT1 / gkBlindPixelQEUnCoatedCT1 ;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Return gkBlindPixelCollectionEffErr^2 / (gkBlindPixelCollectionEff^2 )
+// 
+const Float_t MCalibrationChargeBlindPix::GetBlindPixelCollectionEffRelVar() const
+{
+
+  return gkBlindPixelCollectionEffErr * gkBlindPixelCollectionEffErr 
+    / gkBlindPixelCollectionEff / gkBlindPixelCollectionEff ;
+}
+
+// --------------------------------------------------------------------------
+//
+// Test bit kChargeFitValid
+//
+Bool_t MCalibrationChargeBlindPix::IsChargeFitValid()  const 
+{
+    return TESTBIT(fFlags,kChargeFitValid);
+}
+
+// --------------------------------------------------------------------------
+//
+// Test bit kCoated
+//
+Bool_t MCalibrationChargeBlindPix::IsCoated()  const 
+{
+    return TESTBIT(fFlags,kCoated);
+}
+
+// --------------------------------------------------------------------------
+//
+// Test bit kOscillating
+//
+Bool_t MCalibrationChargeBlindPix::IsOscillating()  const 
+{
+    return TESTBIT(fFlags,kOscillating);
+}
+
+// --------------------------------------------------------------------------
+//
+// Test bit kPedestalFitValid
+//
+Bool_t MCalibrationChargeBlindPix::IsPedestalFitOK()  const 
+{
+    return TESTBIT(fFlags,kPedestalFitOK);
+}
+
+// --------------------------------------------------------------------------
+//
+// Test bit kSinglePheFitValid
+//
+Bool_t MCalibrationChargeBlindPix::IsSinglePheFitOK()  const 
+{
+    return TESTBIT(fFlags,kSinglePheFitOK);
+}
+
+// --------------------------------------------------------------------------
+//
+// Test bit kFluxInsidePlexiglassAvailable
+//
+Bool_t  MCalibrationChargeBlindPix::IsFluxInsidePlexiglassAvailable()   const
+{
+  return TESTBIT(fFlags,kFluxInsidePlexiglassAvailable);
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Return kFALSE if IsChargeFitValid() is kFALSE
+//
+// Calculate fFluxInsidePlexiglass with the formula:
+// - fFluxInsidePlexiglass    = fLambda 
+//                            / GetBlindPixelCollectionEff()
+//                            / GetBlindPixelQE() 
+//                            * 10**gkBlindPixelAtt[color] 
+//                            / gkBlindPixelArea 
+// - fFluxInsidePlexiglassVar = sqrt( fLambdaVar / ( fLambda * fLambda ) 
+//                             + GetBlindPixelQERelVar() 
+//                             + GetBlindPixelCollectionEffRelVar()
+//                               ) * fFluxInsidePlexiglass * * fFluxInsidePlexiglass
+//
+// If the fFluxInsidePlexiglass is smaller than 0., return kFALSE
+// If the Variance is smaller than 0., return kFALSE
+//
+// SetFluxInsidePlexiglassAvailable() and return kTRUE
+//
+Bool_t MCalibrationChargeBlindPix::CalcFluxInsidePlexiglass()
+{
+
+  if (IsChargeFitValid())
+    return kFALSE;
+  
+
+  //
+  // Start calculation of number of photons 
+  // The blind pixel has exactly 100 mm^2 area (with negligible error), 
+  //
+  switch (fColor)
+    {
+    case MCalibrationCam::kGREEN:
+      fFluxInsidePlexiglass    = fLambda / GetBlindPixelQEGreen() * TMath::Power(10,gkBlindPixelAttGreen);   
+      // attenuation has negligible error
+      fFluxInsidePlexiglassVar = GetLambdaRelVar() + GetBlindPixelQEGreenRelVar();
+      break;
+    case MCalibrationCam::kBLUE:
+      fFluxInsidePlexiglass    = fLambda / GetBlindPixelQEBlue() * TMath::Power(10,gkBlindPixelAttBlue);   
+      // attenuation has negligible error
+      fFluxInsidePlexiglassVar = GetLambdaRelVar() + GetBlindPixelQEBlueRelVar();
+      break;
+    case MCalibrationCam::kUV:
+      fFluxInsidePlexiglass    = fLambda / GetBlindPixelQEUV() * TMath::Power(10,gkBlindPixelAttUV);   
+      // attenuation has negligible error
+      fFluxInsidePlexiglassVar = GetLambdaRelVar() + GetBlindPixelQEUVRelVar();
+      break;
+    case MCalibrationCam::kCT1:
+    default:
+      fFluxInsidePlexiglass    = fLambda / GetBlindPixelQECT1() * TMath::Power(10,gkBlindPixelAttCT1);   
+      // attenuation has negligible error
+      fFluxInsidePlexiglassVar = GetLambdaRelVar() + GetBlindPixelQECT1RelVar();
+      break;
+    }
+
+  fFluxInsidePlexiglass    /= gkBlindPixelArea;
+  fFluxInsidePlexiglass    /= gkBlindPixelCollectionEff;
+  //
+  // Finish calculation of errors -> convert from relative variance to absolute variance
+  //
+  fFluxInsidePlexiglassVar += GetBlindPixelCollectionEffRelVar();
+  fFluxInsidePlexiglassVar *= fFluxInsidePlexiglass * fFluxInsidePlexiglass;
+
+  if (fFluxInsidePlexiglass < 0.)
+      return kFALSE;
+
+  if (fFluxInsidePlexiglassVar < 0.)
+      return kFALSE;
+
+  SetFluxInsidePlexiglassAvailable(kTRUE);  
+
+  *fLog << inf << endl;
+  *fLog << inf << GetDescriptor() 
+        << ": Photon flux [ph/mm^2] inside Plexiglass: " 
+        << Form("%5.3f%s%5.3f",fFluxInsidePlexiglass," +- ",GetFluxInsidePlexiglassErr()) << endl;
+
+  return kTRUE;
+}
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationChargeBlindPix.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationChargeBlindPix.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationChargeBlindPix.h	(revision 9661)
@@ -0,0 +1,134 @@
+#ifndef MARS_MCalibrationChargeBlindPix
+#define MARS_MCalibrationChargeBlindPix
+
+#ifndef MARS_MCalibrationChargeCam
+#include "MCalibrationChargeCam.h"
+#endif
+
+#ifndef MARS_MCalibrationChargePix
+#include "MCalibrationChargePix.h"
+#endif
+
+class MCalibrationChargeBlindPix : public MCalibrationChargePix
+{
+private:
+
+  static const Float_t gkBlindPixelArea;               //! The Blind Pixel area in mm^2
+  static const Float_t gkBlindPixelAttGreen;           //! Attenuation Filter at 520 nm 
+  static const Float_t gkBlindPixelAttBlue ;           //! Attenuation Filter at 460 nm 
+  static const Float_t gkBlindPixelAttUV   ;           //! Attenuation Filter at 370 nm 
+  static const Float_t gkBlindPixelAttCT1  ;           //! Attenuation Filter at 370 nm
+  static const Float_t gkBlindPixelQEUnCoatedGreen;    //! Quantum Efficiency at 520 nm
+  static const Float_t gkBlindPixelQEUnCoatedBlue ;    //! Quantum Efficiency at 460 nm
+  static const Float_t gkBlindPixelQEUnCoatedUV   ;    //! Quantum Efficiency at 370 nm
+  static const Float_t gkBlindPixelQEUnCoatedCT1  ;    //! Quantum Efficiency at 370 nm
+  static const Float_t gkBlindPixelQEUnCoatedGreenErr; //! Uncertainty QEUnCoated at 520 nm 
+  static const Float_t gkBlindPixelQEUnCoatedBlueErr ; //! Uncertainty QEUnCoated at 460 nm 
+  static const Float_t gkBlindPixelQEUnCoatedUVErr   ; //! Uncertainty QEUnCoated at 370 nm 
+  static const Float_t gkBlindPixelQEUnCoatedCT1Err  ; //! Uncertainty QEUnCoated at 370 nmu
+  static const Float_t gkBlindPixelQECoatedGreen;      //! Quantum Efficiency at 520 nm
+  static const Float_t gkBlindPixelQECoatedBlue ;      //! Quantum Efficiency at 460 nm
+  static const Float_t gkBlindPixelQECoatedUV   ;      //! Quantum Efficiency at 370 nm
+  static const Float_t gkBlindPixelQECoatedCT1  ;      //! Quantum Efficiency at 370 nm
+  static const Float_t gkBlindPixelQECoatedGreenErr;   //! Uncertainty QECoated at 520 nm 
+  static const Float_t gkBlindPixelQECoatedBlueErr ;   //! Uncertainty QECoated at 460 nm 
+  static const Float_t gkBlindPixelQECoatedUVErr   ;   //! Uncertainty QECoated at 370 nm 
+  static const Float_t gkBlindPixelQECoatedCT1Err  ;   //! Uncertainty QECoated at 370 nmu
+  static const Float_t gkBlindPixelCollectionEff;      //! Collection Efficiency
+  static const Float_t gkBlindPixelCollectionEffErr;   //! Uncertainty Collection Efficiency
+
+  Float_t fLambda;                  // Mean Poisson fit
+  Float_t fLambdaCheck;             // Mean Pedestal Check (Gauss) fit
+  Float_t fLambdaCheckErr;          // Error mean pedestal Check fit
+  Float_t fLambdaVar;               // Variance lambda Poisson fit
+  Float_t fFluxInsidePlexiglass;    // Number photons in INNER PIXEL inside the plexiglass
+  Float_t fFluxInsidePlexiglassVar; // Variance number of photons in INNER PIXEL 
+  Float_t fMu0;                     // Position pedestal peak
+  Float_t fMu0Err;                  // Error pos. pedestal-peak
+  Float_t fMu1;                     // Position first photo-electron peak
+  Float_t fMu1Err;                  // Error pos. first photo-electon peak
+  Float_t fSigma0;                  // Width pedestal peak
+  Float_t fSigma0Err;               // Error width pedestal peak
+  Float_t fSigma1;                  // Width first photo-electron peak  
+  Float_t fSigma1Err;               // Error width first photo-electron peak  
+
+  enum { kOscillating, kPedestalFitOK, kSinglePheFitOK, kChargeFitValid, 
+         kFluxInsidePlexiglassAvailable, kCoated };
+
+  MCalibrationCam::PulserColor_t fColor;
+
+  const Float_t GetBlindPixelQEGreen() const; 
+  const Float_t GetBlindPixelQEBlue () const; 
+  const Float_t GetBlindPixelQEUV   () const; 
+  const Float_t GetBlindPixelQECT1  () const; 
+
+  const Float_t GetBlindPixelQEGreenRelVar     () const; 
+  const Float_t GetBlindPixelQEBlueRelVar      () const; 
+  const Float_t GetBlindPixelQEUVRelVar        () const; 
+  const Float_t GetBlindPixelQECT1RelVar       () const;
+  const Float_t GetBlindPixelCollectionEffRelVar  () const;   
+
+ public:
+
+  MCalibrationChargeBlindPix(const char *name=NULL, const char *title=NULL);
+  ~MCalibrationChargeBlindPix() {}
+  
+  Bool_t CalcFluxInsidePlexiglass();
+  void   Clear(Option_t *o="");
+  
+  // Getters
+  MCalibrationCam::PulserColor_t GetColor () const { return fColor;                }
+  Float_t GetLambda                       () const { return fLambda;               }
+  Float_t GetLambdaErr                    () const;
+  Float_t GetLambdaRelVar                 () const;  
+  Float_t GetLambdaCheck                  () const { return fLambdaCheck;          }
+  Float_t GetLambdaCheckErr               () const { return fLambdaCheckErr;       }
+  Float_t GetFluxInsidePlexiglass         () const { return fFluxInsidePlexiglass; }
+  Float_t GetFluxInsidePlexiglassErr      () const;
+  Float_t GetFluxInsidePlexiglassRelVar   () const;  
+  Float_t GetMu0                          () const { return fMu0;                  }
+  Float_t GetMu0Err                       () const { return fMu0Err;               }
+  Float_t GetMu1                          () const { return fMu1;                  }
+  Float_t GetMu1Err                       () const { return fMu1Err;               }
+  Float_t GetSigma0                       () const { return fSigma0;               }
+  Float_t GetSigma0Err                    () const { return fSigma0Err;            } 
+  Float_t GetSigma1                       () const { return fSigma1;               }
+  Float_t GetSigma1Err                    () const { return fSigma1Err;            }
+
+  Bool_t  IsCoated                        () const;  
+  Bool_t  IsOscillating                   () const;
+  Bool_t  IsChargeFitValid                () const;
+  Bool_t  IsPedestalFitOK                 () const;
+  Bool_t  IsSinglePheFitOK                () const;
+  Bool_t  IsFluxInsidePlexiglassAvailable () const;
+  
+  // Setters
+  void SetColor          ( const MCalibrationCam::PulserColor_t color ) { fColor      = color; }
+  void SetLambda         ( const Float_t f )                            { fLambda         = f; }
+  void SetLambdaVar      ( const Float_t f )                            { fLambdaVar      = f; }
+  void SetLambdaCheck    ( const Float_t f )                            { fLambdaCheck    = f; }
+  void SetLambdaCheckErr ( const Float_t f )                            { fLambdaCheckErr = f; }
+  void SetMu0            ( const Float_t f )                            { fMu0            = f; }
+  void SetMu0Err         ( const Float_t f )                            { fMu0Err         = f; }
+  void SetMu1            ( const Float_t f )                            { fMu1            = f; }
+  void SetMu1Err         ( const Float_t f )                            { fMu1Err         = f; }
+  void SetSigma0         ( const Float_t f )                            { fSigma0         = f; }
+  void SetSigma0Err      ( const Float_t f )                            { fSigma0Err      = f; }
+  void SetSigma1         ( const Float_t f )                            { fSigma1         = f; }
+  void SetSigma1Err      ( const Float_t f )                            { fSigma1Err      = f; }
+
+  void SetCoated         ( const Bool_t  b=kTRUE );  
+  void SetOscillating    ( const Bool_t  b=kTRUE );
+  void SetChargeFitValid ( const Bool_t  b=kTRUE );
+  void SetPedestalFitOK  ( const Bool_t  b=kTRUE );
+  void SetSinglePheFitOK ( const Bool_t  b=kTRUE );
+  void SetFluxInsidePlexiglassAvailable( const Bool_t b=kTRUE);
+
+  ClassDef(MCalibrationChargeBlindPix, 2)	// Container Charge Calibration Results Blind Pixel
+};
+
+#endif
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationChargeCalc.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationChargeCalc.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationChargeCalc.cc	(revision 9661)
@@ -0,0 +1,1810 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug  02/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//   MCalibrationChargeCalc
+//
+//   Task to calculate the calibration conversion factors and quantum efficiencies 
+//   from the fit results to the summed FADC slice distributions delivered by 
+//   MCalibrationChargeCam, MCalibrationChargePix, MCalibrationChargeBlindPix and 
+//   MCalibrationChargePINDiode, calculated and filled by MHCalibrationChargeCam, 
+//   MHCalibrationChargePix, MHCalibrationChargeBlindPix and MHCalibrationChargePINDiode.
+//
+//   PreProcess(): Initialize pointers to MCalibrationChargeCam, MCalibrationChargeBlindPix
+//                 MCalibrationChargePINDiode and  MCalibrationQECam
+//
+//                 Initialize pulser light wavelength
+//               
+//   ReInit():     MCalibrationCam::InitSize(NumPixels) is called from MGeomApply (which allocates
+//                 memory in a TClonesArray of type MCalibrationChargePix)
+//                 Initializes pointer to MBadPixelsCam
+//
+//   Process():    Nothing to be done, histograms getting filled by MHCalibrationChargeCam
+//
+//   PostProcess(): - FinalizePedestals()
+//                  - FinalizeCharges()
+//                  - FinalizeFFactorMethod()
+//                  - FinalizeBadPixels()
+//                  - FinalizeBlindPixel()
+//                  - FinalizePINDiode()
+//                  - FinalizeFFactorQECam()
+//                  - FinalizeBlindPixelQECam()
+//                  - FinalizePINDiodeQECam()
+//
+//  Input Containers:
+//   MCalibrationChargeCam
+//   MCalibrationChargeBlindPix
+//   MCalibrationChargePINDiode
+//   MCalibrationQECam
+//   MPedestalCam
+//   MBadPixelsCam
+//   MGeomCam
+//   MTime
+//
+//  Output Containers:
+//   MCalibrationChargeCam
+//   MCalibrationChargeBlindPix
+//   MCalibrationChargePINDiode
+//   MCalibrationQECam
+//   MBadPixelsCam
+//
+//
+//  Preliminary description of the calibration in photons (email from 12/02/04)
+//
+//  Why calibrating in photons:
+//  ===========================
+//  
+//  At the Barcelona meeting in 2002, we decided to calibrate the camera in
+//  photons. This for the following reasons:
+//  
+//  * The physical quantity arriving at the camera are photons. This is
+//    the direct physical information from the air shower. The photons
+//    have a flux and a spectrum.
+//  
+//  * The photon fluxes depend mostly on the shower energy (with
+//    corrections deriving from the observation conditions), while the photon
+//    spectra depend mostly on the observation conditions: zenith angle,
+//    quality of the air, also the impact parameter of the shower.
+//  
+//  * The photomultiplier, in turn, has different response properties
+//    (quantum efficiencies) for photons of different colour. (Moreover,
+//    different pixels have slightly different quantum efficiencies).
+//    The resulting number of photo-electrons is then amplified (linearly)
+//    with respect to the photo-electron flux.
+//  
+//  * In the ideal case, one would like to disentagle the effects
+//    of the observation conditions from the primary particle energy (which
+//    one likes to measure). To do so, one needs:
+//  
+//    1) A reliable calibration relating the FADC counts to the photo-electron
+//       flux -> This is accomplished with the F-Factor method.
+//  
+//    2) A reliable calibration of the wavelength-dependent quantum efficiency
+//       -> This is accomplished with the combination of the three methods,
+//          together with QE-measurements performed by David in order to do
+//          the interpolation.
+//  
+//    3) A reliable calibration of the observation conditions. This means:
+//       - Tracing the atmospheric conditions   -> LIDAR
+//       - Tracing the observation zenith angle -> Drive System
+//
+//    4) Some knowlegde about the impact parameter:
+//       - This is the only part which cannot be accomplished well with a
+//         single telescope. We would thus need to convolute the spectrum
+//         over the distribution of impact parameters.
+//  
+//  
+//  How an ideal calibration would look like:
+//  =========================================
+//  
+//  We know from the combined PIN-Diode and Blind-Pixel Method the response of
+//  each pixel to well-measured light fluxes in three representative
+//  wavelengths (green, blue, UV). We also know the response to these light
+//  fluxes in photo-electrons. Thus, we can derive:
+//  
+//  - conversion factors to photo-electrons
+//  - conversion factors to photons in three wavelengths.
+//  
+//  Together with David's measurements and some MC-simulation, we should be
+//  able to derive tables for typical Cherenkov-photon spectra - convoluted
+//  with the impact parameters and depending on the athmospheric conditions
+//  and the zenith angle (the "outer parameters").
+//  
+//  From these tables we can create "calibration tables" containing some
+//  effective quantum efficiency depending on these outer parameters and which
+//  are different for each pixel.
+//  
+//  In an ideal MCalibrate, one would thus have to convert first the FADC
+//  slices to Photo-electrons and then, depending on the outer parameters,
+//  look up the effective quantum efficiency and get the mean number of
+//  photons which is then used for the further analysis.
+//  
+//  How the (first) MAGIC calibration should look like:
+//  ===================================================
+//  
+//  For the moment, we have only one reliable calibration method, although
+//  with very large systematic errors. This is the F-Factor method. Knowing
+//  that the light is uniform over the whole camera (which I would not at all
+//  guarantee in the case of the CT1 pulser), one could in principle already
+//  perform a relative calibration of the quantum efficiencies in the UV.
+//  However, the spread in QE at UV is about 10-15% (according to the plot
+//  that Abelardo sent around last time. The spread in photo-electrons is 15%
+//  for the inner pixels, but much larger (40%) for the outer ones.
+//  
+//  I'm not sure if we can already say that we have measured the relative
+//  difference in quantum efficiency for the inner pixels and produce a first
+//  QE-table for each pixel. To so, I would rather check in other wavelengths
+//  (which we can do in about one-two weeks when the optical transmission of
+//  the calibration trigger is installed).
+//  
+//  Thus, for the moment being, I would join Thomas proposal to calibrate in
+//  photo-electrons and apply one stupid average quantum efficiency for all
+//  pixels. This keeping in mind that we will have much preciser information
+//  in about one to two weeks.
+//  
+//  
+//  What MCalibrate should calculate and what should be stored:
+//  ===========================================================
+//  
+//  It is clear that in the end, MCerPhotEvt will store photons.
+//  MCalibrationCam stores the conversionfactors to photo-electrons and also
+//  some tables of how to apply the conversion to photons, given the outer
+//  parameters. This is not yet implemented and not even discussed.
+//  
+//  To start, I would suggest that we define the "average quantum efficiency"
+//  (maybe something like 25+-3%) and apply them equally to all
+//  photo-electrons. Later, this average factor can be easily replaced by a
+//  pixel-dependent factor and later by a (pixel-dependent) table.
+//  
+//  
+//  
+//////////////////////////////////////////////////////////////////////////////
+#include "MCalibrationChargeCalc.h"
+
+#include <TSystem.h>
+#include <TH1.h>
+#include <TF1.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MRawRunHeader.h"
+#include "MRawEvtPixelIter.h"
+
+#include "MGeomCam.h"
+#include "MGeomPix.h"
+#include "MHCamera.h"
+
+#include "MPedestalCam.h"
+#include "MPedestalPix.h"
+
+#include "MCalibrationChargeCam.h"
+#include "MCalibrationChargePix.h"
+#include "MCalibrationChargePINDiode.h"
+#include "MCalibrationChargeBlindPix.h"
+#include "MCalibrationChargeBlindCam.h"
+
+#include "MExtractedSignalCam.h"
+#include "MExtractedSignalPix.h"
+#include "MExtractedSignalBlindPixel.h"
+#include "MExtractedSignalPINDiode.h"
+
+#include "MBadPixelsCam.h"
+#include "MBadPixelsPix.h"
+
+#include "MCalibrationQECam.h"
+#include "MCalibrationQEPix.h"
+
+#include "MCalibrationCam.h"
+
+ClassImp(MCalibrationChargeCalc);
+
+using namespace std;
+
+const Float_t MCalibrationChargeCalc::fgChargeLimit            = 2.5;
+const Float_t MCalibrationChargeCalc::fgChargeErrLimit         = 0.;
+const Float_t MCalibrationChargeCalc::fgChargeRelErrLimit      = 1.;
+const Float_t MCalibrationChargeCalc::fgLambdaErrLimit         = 0.2;
+const Float_t MCalibrationChargeCalc::fgLambdaCheckLimit       = 0.5;
+const Float_t MCalibrationChargeCalc::fgPheErrLimit            = 3.5;
+const Float_t MCalibrationChargeCalc::fgFFactorErrLimit        = 4.5;
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+// Sets the pointer to fQECam and fGeom to NULL
+// 
+// Calls AddToBranchList for: 
+// - MRawEvtData.fHiGainPixId   
+// - MRawEvtData.fLoGainPixId   
+// - MRawEvtData.fHiGainFadcSamples
+// - MRawEvtData.fLoGainFadcSamples
+//
+// Initializes:
+// - fChargeLimit       to fgChargeLimit 
+// - fChargeErrLimit    to fgChargeErrLimit   
+// - fChargeRelErrLimit to fgChargeRelErrLimit
+// - fFFactorErrLimit   to fgFFactorErrLimit
+// - fLambdaCheckLimit  to fgLambdaCheckLimit 
+// - fLambdaErrLimit    to fgLambdaErrLimit 
+// - fPheErrLimit       to fgPheErrLimit  
+// - fPulserColor       to MCalibrationCam::kCT1
+// - fOutputPath        to "."
+// - fOutputFile        to "ChargeCalibStat.txt"
+// - flag debug         to kFALSE
+//
+// Calls:
+// - Clear()
+//
+MCalibrationChargeCalc::MCalibrationChargeCalc(const char *name, const char *title)
+    : fQECam(NULL), fGeom(NULL)
+{
+        
+  fName  = name  ? name  : "MCalibrationChargeCalc";
+  fTitle = title ? title : "Task to calculate the calibration constants and MCalibrationCam ";
+  
+  AddToBranchList("MRawEvtData.fHiGainPixId");
+  AddToBranchList("MRawEvtData.fLoGainPixId");
+  AddToBranchList("MRawEvtData.fHiGainFadcSamples");
+  AddToBranchList("MRawEvtData.fLoGainFadcSamples");
+  
+  SetChargeLimit       ();
+  SetChargeErrLimit    ();  
+  SetChargeRelErrLimit ();
+  SetFFactorErrLimit   ();
+  SetLambdaCheckLimit  ();
+  SetLambdaErrLimit    ();
+  SetPheErrLimit       ();
+  SetOutputPath        ();
+  SetOutputFile        ();
+  SetDebug       ( kFALSE );
+
+  Clear();
+  
+}
+
+// --------------------------------------------------------------------------
+//
+// Sets:
+// - all variables to 0., 
+// - all flags to kFALSE
+// - all pointers to NULL
+// - the pulser colour to kNONE
+// - fBlindPixelFlags to 0
+// - fPINDiodeFlags   to 0
+//
+void MCalibrationChargeCalc::Clear(const Option_t *o)
+{
+  
+    fNumHiGainSamples          = 0.;
+    fNumLoGainSamples          = 0.;
+    fSqrtHiGainSamples         = 0.;
+    fSqrtLoGainSamples         = 0.;
+    fNumInnerFFactorMethodUsed = 0;
+
+    fBadPixels  = NULL;
+    fCam        = NULL;
+    fBlindPixel = NULL;
+    fBlindCam   = NULL;
+    fPINDiode   = NULL;
+    fPedestals  = NULL;
+
+    SetPulserColor ( MCalibrationCam::kNONE );
+    
+    fBlindPixelFlags.Set(0);
+    fPINDiodeFlags  .Set(0);
+    fResultFlags    .Set(0);
+}
+
+
+// -----------------------------------------------------------------------------------
+//
+// The following container are searched for and execution aborted if not in MParList:
+//  - MPedestalCam
+//
+// The following containers are searched and created if they were not found:
+//
+//  - MCalibrationQECam
+//  - MBadPixelsCam
+//
+Int_t MCalibrationChargeCalc::PreProcess(MParList *pList)
+{
+  
+  // 
+  // Containers that have to be there.
+  //
+  fPedestals = (MPedestalCam*)pList->FindObject("MPedestalCam");
+  if (!fPedestals)
+    {
+      *fLog << err << "MPedestalCam not found... aborting" << endl;
+      return kFALSE;
+    }
+  
+  // 
+  // Containers that are created in case that they are not there.
+  //
+  fQECam = (MCalibrationQECam*)pList->FindCreateObj("MCalibrationQECam");
+  if (!fQECam)
+    {
+      *fLog << err << "Cannot find nor create MCalibrationQECam... aborting" << endl;
+      return kFALSE;
+    }
+
+  fBadPixels = (MBadPixelsCam*)pList->FindCreateObj("MBadPixelsCam");
+  if (!fBadPixels)
+    {
+      *fLog << err << "Could not find or create MBadPixelsCam ... aborting." << endl;
+      return kFALSE;
+    }
+
+  
+  //
+  // Check the pulser colour --> FIXME: this solution is only valid until the arrival of the DM's
+  //
+  if (fPulserColor == MCalibrationCam::kNONE)
+    {
+      *fLog << endl;
+      *fLog << err << GetDescriptor()
+            << ": No Pulser colour has been chosen. Since the installation of the IFAE pulser box,"
+            << " you HAVE to provide the LEDs colour, otherwise there is no calibration. " << endl;
+      *fLog << "See e.g. the macro calibration.C " << endl;
+      return kFALSE;
+    }
+  
+  return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Search for the following input containers and abort if not existing:
+//  - MGeomCam
+//  - MCalibrationChargeCam
+// 
+// Search for the following input containers and give a warning if not existing:
+//  - MCalibrationChargeBlindPix
+//  - MCalibrationChargePINDiode
+//
+// It retrieves the following variables from MCalibrationChargeCam:
+//
+//  - fNumHiGainSamples 
+//  - fNumLoGainSamples 
+//
+// It defines the PixId of every pixel in:
+//
+// - MCalibrationChargeCam 
+// - MCalibrationQECam
+//
+// It sets all pixels in excluded which have the flag fBadBixelsPix::IsBad() set in:
+// 
+// - MCalibrationChargePix
+// - MCalibrationQEPix
+//
+// Sets the pulser colour and tests if it has not changed w.r.t. fPulserColor in:
+//
+// - MCalibrationChargeCam
+// - MCalibrationChargeBlindPix (if existing)
+// - MCalibrationChargePINDiode (if existing)
+//
+Bool_t MCalibrationChargeCalc::ReInit(MParList *pList )
+{
+
+  fGeom = (MGeomCam*)pList->FindObject("MGeomCam");
+  if (!fGeom)
+    {
+      *fLog << err << "No MGeomCam found... aborting." << endl;
+      return kFALSE;
+    }
+  
+  fCam = (MCalibrationChargeCam*)pList->FindObject("MCalibrationChargeCam");
+  if (!fCam)
+    {
+      *fLog << err << "Cannot find MCalibrationChargeCam... aborting" << endl;
+      *fLog << err << "Maybe you forget to call an MFillH for the MHCalibrationChargeCam before..." << endl;
+      return kFALSE;
+    }
+
+  // 
+  // Optional Containers 
+  //
+  fBlindPixel = (MCalibrationChargeBlindPix*)pList->FindObject("MCalibrationChargeBlindPix");
+  if (!fBlindPixel)
+    {
+      fBlindCam = (MCalibrationChargeBlindCam*)pList->FindObject("MCalibrationChargeBlindCam");
+      if (!fBlindCam)
+	{
+      *fLog << endl;
+      *fLog << warn << GetDescriptor() 
+            << ": MCalibrationChargeBlindPix nor MCalibrationChargeBlindCam "
+	    << " found... no Blind Pixel method! " << endl;
+	}
+    }
+  
+  fPINDiode = (MCalibrationChargePINDiode*)pList->FindObject("MCalibrationChargePINDiode");
+  if (!fPINDiode)
+    {
+      *fLog << endl;
+      *fLog << warn << GetDescriptor() 
+            << ": MCalibrationChargePINDiode not found... no PIN Diode method! " << endl;
+    }
+  
+
+  //
+  // Initialize the pulser colours
+  //
+  if (fCam->GetPulserColor() == MCalibrationCam::kNONE)
+    {
+      fCam->SetPulserColor( fPulserColor );
+      
+      if (fBlindPixel)
+        fBlindPixel->SetColor( fPulserColor );
+      
+      if (fBlindCam)
+        fBlindCam->SetColor( fPulserColor );
+      
+      if (fPINDiode)
+        fPINDiode->SetColor( fPulserColor );
+    }
+
+  if (fPulserColor != fCam->GetPulserColor())
+    {
+      *fLog << err << GetDescriptor() 
+            << ": Pulser colour has changed w.r.t. last file in MCalibrationChargeCam" << endl;
+      *fLog << err << "This feature is not yet implemented, sorry ... aborting " << endl;
+      return kFALSE;
+    }
+
+  if (fBlindPixel)
+    if (fPulserColor != fBlindPixel->GetColor())
+      {
+        *fLog << err << GetDescriptor() 
+              << ": Pulser colour has changed w.r.t. last file in MCalibrationChargeBlindPix." << endl;
+        *fLog << err << "This feature is not yet implemented, sorry ... aborting " << endl;
+        return kFALSE;
+      }
+
+  if (fBlindCam)
+    if (fPulserColor != fBlindCam->GetColor())
+      {
+        *fLog << err << GetDescriptor() 
+              << ": Pulser colour has changed w.r.t. last file in MCalibrationChargeBlindCam." << endl;
+        *fLog << err << "This feature is not yet implemented, sorry ... aborting " << endl;
+        return kFALSE;
+      }
+  
+  if (fPINDiode)
+    if (fPulserColor != fPINDiode->GetColor())
+      {
+        *fLog << err << GetDescriptor() 
+              << ": Pulser colour has changed w.r.t. last file in MCalibrationChargePINDiode." << endl;
+        *fLog << err << "This feature is not yet implemented, sorry ... aborting " << endl;
+        return kFALSE;
+      }
+  
+
+  fNumHiGainSamples  =  fCam->GetNumHiGainFADCSlices();
+  fNumLoGainSamples  =  fCam->GetNumLoGainFADCSlices();
+
+  fSqrtHiGainSamples =  TMath::Sqrt(fNumHiGainSamples);
+  fSqrtLoGainSamples =  TMath::Sqrt(fNumLoGainSamples);
+  
+  UInt_t npixels     = fGeom->GetNumPixels();
+  
+  for (UInt_t i=0; i<npixels; i++)
+    {
+      
+      MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)  [i];
+      MCalibrationQEPix     &pqe = (MCalibrationQEPix&)    (*fQECam)[i];
+      MBadPixelsPix         &bad = (*fBadPixels)[i];
+      
+      pix.SetPixId(i);
+      pqe.SetPixId(i);
+      
+      if (bad.IsBad())
+        {
+          pix.SetExcluded();
+          pqe.SetExcluded();
+          continue;
+        }
+      
+      if (IsDebug())
+        pix.SetDebug();
+    }
+
+  return kTRUE;
+}
+
+// ----------------------------------------------------------------------------------
+//  
+// Nothing to be done in Process, but have a look at MHCalibrationChargeCam, instead
+// 
+Int_t MCalibrationChargeCalc::Process()
+{
+  return kTRUE;
+}
+
+// -----------------------------------------------------------------------
+//
+// Return if number of executions is null.
+//
+// First loop over pixels, average areas and sectors, call: 
+//  - FinalizePedestals() 
+//  - FinalizeCharges()
+// for every entry. Count number of valid pixels in loop and return kFALSE
+// if there are none (the "Michele check").
+//
+// Call FinalizeBadPixels()
+//
+// Call FinalizeFFactorMethod() (second and third loop over pixels and areas)
+//
+// Call FinalizeBlindPixel() 
+// Call FinalizePINDiode()
+//
+// Call  FinalizeFFactorQECam() (fourth loop over pixels and areas)
+// Call  FinalizeBlindPixelQECam() (fifth loop over pixels and areas)
+// Call  FinalizePINDiodeQECam() (sixth loop over pixels and areas)
+//
+// Call  FinalizeUnsuitablePixels()
+//  
+// Call MParContainer::SetReadyToSave() for fCam, fQECam, fBadPixels and 
+//                                          fBlindPixel and fPINDiode if they exist
+//
+// Print out some statistics
+//
+Int_t MCalibrationChargeCalc::PostProcess()
+{
+
+  if (GetNumExecutions()==0)
+    return kFALSE;
+
+  if (fPINDiode)
+    if (!fPINDiode->IsValid())
+      {
+        *fLog << warn << GetDescriptor() 
+              << ": MCalibrationChargePINDiode is declared not valid... no PIN Diode method! " << endl;
+        fPINDiode = NULL;
+      }
+
+  if (fBlindPixel)
+    if (!fBlindPixel->IsValid())
+      {
+        *fLog << warn << GetDescriptor() 
+              << ": MCalibrationChargeBlindPix is declared not valid... no Blind Pixel method! " << endl;
+        fBlindPixel = NULL;
+      }
+
+  if (fBlindCam)
+    if (!fBlindCam->IsValid())
+      {
+        *fLog << warn << GetDescriptor() 
+              << ": MCalibrationChargeBlindCam is declared not valid... no Blind Pixel method! " << endl;
+        fBlindCam = NULL;
+      }
+  
+  //
+  // First loop over pixels, call FinalizePedestals and FinalizeCharges
+  //
+  Int_t   nvalid      = 0;
+
+  for (Int_t pixid=0; pixid<fPedestals->GetSize(); pixid++)
+    {
+
+      MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[pixid];
+      //
+      // Check if the pixel has been excluded from the fits
+      //
+      if (pix.IsExcluded())
+        continue;
+
+      MPedestalPix  &ped = (*fPedestals)[pixid];
+      MBadPixelsPix &bad = (*fBadPixels)[pixid];
+      const Int_t aidx    = (*fGeom)[pixid].GetAidx();
+
+      FinalizePedestals(ped,pix,aidx);
+
+      if (FinalizeCharges(pix,bad))
+        nvalid++;
+    }
+  
+  //
+  // The Michele check ...
+  //
+  if (nvalid == 0)
+  {
+      *fLog << err << GetDescriptor() << ": All pixels have non-valid calibration. " 
+	    << "Did you forget to fill the histograms "
+            << "(filling MHCalibrationChargeCam from MExtractedSignalCam using MFillH) ? " << endl;
+      *fLog << err << GetDescriptor() << ": Or, maybe, you have used a pedestal run " 
+            << "instead of a calibration run " << endl;
+      return kFALSE;
+  }
+
+  for (UInt_t aidx=0; aidx<fGeom->GetNumAreas(); aidx++)
+    {
+
+      const MPedestalPix     &ped = fPedestals->GetAverageArea(aidx);
+      MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageArea(aidx);
+
+      FinalizePedestals(ped,pix,aidx);
+      FinalizeCharges(pix, fCam->GetAverageBadArea(aidx));
+    }
+  
+  for (UInt_t sector=0; sector<fGeom->GetNumSectors(); sector++)
+    {
+
+      const MPedestalPix     &ped = fPedestals->GetAverageSector(sector);
+
+      MCalibrationChargePix &pix = (MCalibrationChargePix&)fCam->GetAverageSector(sector);
+      FinalizePedestals(ped,pix, 0);
+      FinalizeCharges(pix, fCam->GetAverageBadSector(sector));
+    }
+  
+  //
+  // Finalize Bad Pixels
+  // 
+  FinalizeBadPixels();
+
+  // 
+  // Finalize F-Factor method
+  //
+  if (!FinalizeFFactorMethod())
+    {
+      *fLog << warn << "Could not calculate the photons flux from the F-Factor method " << endl;
+      fCam->SetFFactorMethodValid(kFALSE); 
+      return kFALSE;
+    }
+  else
+    fCam->SetFFactorMethodValid(kTRUE);
+  
+  // 
+  // Finalize Blind Pixel
+  //
+  if (FinalizeBlindPixel())
+    fQECam->SetBlindPixelMethodValid(kTRUE);
+  else
+    fQECam->SetBlindPixelMethodValid(kFALSE); 
+
+  // 
+  // Finalize PIN Diode
+  //
+  if (FinalizePINDiode())
+    fQECam->SetPINDiodeMethodValid(kTRUE);
+  else
+    fQECam->SetPINDiodeMethodValid(kFALSE); 
+
+  //
+  // Finalize QE Cam
+  //
+  FinalizeFFactorQECam();
+  FinalizeBlindPixelQECam();
+  FinalizePINDiodeQECam();
+
+  //
+  // Re-direct the output to an ascii-file from now on:
+  //
+  MLog asciilog;
+  asciilog.SetOutputFile(GetOutputFile(),kTRUE);
+  SetLogStream(&asciilog);
+  //
+  // Finalize calibration statistics
+  //
+  FinalizeUnsuitablePixels();
+
+  fCam      ->SetReadyToSave();
+  fQECam    ->SetReadyToSave();
+  fBadPixels->SetReadyToSave();
+
+  if (fBlindPixel)
+    fBlindPixel->SetReadyToSave();
+  if (fBlindCam)
+    fBlindCam->SetReadyToSave();
+  if (fPINDiode)
+    fPINDiode->SetReadyToSave();
+  
+  *fLog << inf << endl;
+  *fLog << GetDescriptor() << ": Fatal errors statistics:" << endl;  
+
+  PrintUncalibrated(MBadPixelsPix::kChargeIsPedestal,    
+                    Form("%s%2.1f%s","Signal less than ",fChargeLimit," Pedestal RMS:                "));
+  PrintUncalibrated(MBadPixelsPix::kChargeRelErrNotValid,
+                    Form("%s%2.1f%s","Signal Error bigger than ",fChargeRelErrLimit," times Mean Signal:   "));
+  PrintUncalibrated(MBadPixelsPix::kChargeSigmaNotValid, 
+                    "Signal Sigma smaller than Pedestal RMS:           ");
+  PrintUncalibrated(MBadPixelsPix::kLoGainSaturation,    
+                    "Pixels with Low Gain Saturation:                  ");
+  PrintUncalibrated(MBadPixelsPix::kMeanTimeInFirstBin, 
+                    Form("%s%2.1f%s","Mean Abs. Arr. Time in First ",1.," Bin(s):          "));
+  PrintUncalibrated(MBadPixelsPix::kMeanTimeInLast2Bins, 
+                    Form("%s%2.1f%s","Mean Abs. Arr. Time in Last ",2.," Bin(s):           "));
+  PrintUncalibrated(MBadPixelsPix::kDeviatingNumPhes,    
+                    "Pixels with deviating number of phes:             ");
+  PrintUncalibrated(MBadPixelsPix::kDeviatingFFactor,    
+                    "Pixels with deviating F-Factor:                   ");
+
+  *fLog << inf << endl;
+  *fLog << GetDescriptor() << ": Unreliable errors statistics:" << endl;  
+
+  PrintUncalibrated(MBadPixelsPix::kHiGainOscillating,   
+                    "Pixels with changing Hi Gain signal over time:    ");
+  PrintUncalibrated(MBadPixelsPix::kLoGainOscillating,   
+                    "Pixels with changing Lo Gain signal over time:    ");
+  PrintUncalibrated(MBadPixelsPix::kHiGainNotFitted,     
+                    "Pixels with unsuccesful Gauss fit to the Hi Gain: ");
+  PrintUncalibrated(MBadPixelsPix::kLoGainNotFitted,     
+                    "Pixels with unsuccesful Gauss fit to the Lo Gain: ");
+
+  SetLogStream(&gLog);
+
+  return kTRUE;
+}
+
+// ----------------------------------------------------------------------------------
+//  
+// Retrieves pedestal and pedestal RMS from MPedestalPix 
+// Retrieves total entries from MPedestalCam
+// Sets pedestal*fNumHiGainSamples and pedestal*fNumLoGainSamples in MCalibrationChargePix
+// Sets pedRMS *fSqrtHiGainSamples and pedRMS *fSqrtLoGainSamples in MCalibrationChargePix
+//
+// If the flag MCalibrationPix::IsHiGainSaturation() is set, call also: 
+// - MCalibrationChargePix::CalcLoGainPedestal()
+//
+void MCalibrationChargeCalc::FinalizePedestals(const MPedestalPix &ped, MCalibrationChargePix &cal, const Int_t aidx)
+{
+  
+  //
+  // get the pedestals
+  //
+  const Float_t pedes  = ped.GetPedestal();
+  const Float_t prms   = ped.GetPedestalRms();
+  const Float_t num    = TMath::Sqrt((Float_t)fPedestals->GetTotalEntries());
+
+
+  //
+  // set them in the calibration camera
+  //
+  if (cal.IsHiGainSaturation())
+    {
+      cal.SetPedestal(pedes* fNumLoGainSamples,
+                      prms * fSqrtLoGainSamples,
+                      prms * fNumLoGainSamples / num);
+      cal.CalcLoGainPedestal((Float_t)fNumLoGainSamples, aidx);
+    }
+  else
+    {
+      cal.SetPedestal(pedes* fNumHiGainSamples,
+                      prms * fSqrtHiGainSamples,
+                      prms * fNumHiGainSamples / num);
+    }
+  
+}
+
+// ----------------------------------------------------------------------------------------------------
+//
+// Check fit results validity. Bad Pixels flags are set if:
+//
+// 1) Pixel has a mean smaller than fChargeLimit*PedRMS    ( Flag: MBadPixelsPix::kChargeIsPedestal)
+// 2) Pixel has a mean error smaller than fChargeErrLimit  ( Flag: MBadPixelsPix::kChargeErrNotValid)
+// 3) Pixel has mean smaller than fChargeRelVarLimit times its mean error 
+//                                                         ( Flag: MBadPixelsPix::kChargeRelErrNotValid)
+// 4) Pixel has a sigma bigger than its Pedestal RMS       ( Flag: MBadPixelsPix::kChargeSigmaNotValid )
+// 
+// Further returns if flags: MBadPixelsPix::kUnsuitableRun is set
+// 
+// Calls MCalibrationChargePix::CalcReducedSigma() and sets flag:  MBadPixelsPix::kChargeIsPedestal 
+//       if not succesful.
+// 
+// Calls MCalibrationChargePix::CalcFFactorMethod() and sets flag: MBadPixelsPix::kDeviatingNumPhes) 
+//       if not succesful.
+//
+Bool_t MCalibrationChargeCalc::FinalizeCharges(MCalibrationChargePix &cal, MBadPixelsPix &bad)
+{
+
+  if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
+    return kFALSE;
+
+  if (cal.GetMean() < fChargeLimit*cal.GetPedRms())
+    {
+      *fLog << warn << GetDescriptor() << ": Fitted Charge: " << cal.GetMean() << " is smaller than "
+            << fChargeLimit << " Pedestal RMS: " <<  cal.GetPedRms() << " in Pixel  " << cal.GetPixId() << endl;
+      bad.SetUncalibrated( MBadPixelsPix::kChargeIsPedestal);
+    }
+  
+   if (cal.GetMean() < fChargeRelErrLimit*cal.GetMeanErr()) 
+    {
+      *fLog << warn << GetDescriptor() << ": Fitted Charge: " << cal.GetMean() << " is smaller than "
+            << fChargeRelErrLimit << "* its error: " << cal.GetMeanErr()
+            << " in Pixel  " << cal.GetPixId() << endl;
+      bad.SetUncalibrated( MBadPixelsPix::kChargeRelErrNotValid );
+    }
+
+  if (cal.GetSigma() < cal.GetPedRms())
+    {
+      *fLog << warn << GetDescriptor() << ": Sigma of Fitted Charge: " << cal.GetSigma()
+	    << " smaller than Pedestal RMS: " << cal.GetPedRms() << " in Pixel  " << cal.GetPixId() << endl;
+      bad.SetUncalibrated( MBadPixelsPix::kChargeSigmaNotValid );
+    }
+
+  if (!cal.CalcReducedSigma())
+    {
+      *fLog << warn << GetDescriptor() 
+            << ": Could not calculate reduced sigmas of pixel: " << cal.GetPixId() << endl;
+      bad.SetUncalibrated(MBadPixelsPix::kChargeIsPedestal);
+      return kFALSE;
+    }
+
+  if (!cal.CalcFFactorMethod())
+    {
+      *fLog << warn << GetDescriptor() 
+            << ": Could not calculate F-Factor of pixel: " << cal.GetPixId() << endl;
+      bad.SetUncalibrated(MBadPixelsPix::kDeviatingNumPhes);
+      return kFALSE;
+    }
+
+  return kTRUE;
+}
+
+
+
+// -----------------------------------------------------------------------------------
+//
+// Sets pixel to MBadPixelsPix::kUnsuitableRun, if one of the following flags is set:
+// - MBadPixelsPix::kChargeIsPedestal
+// - MBadPixelsPix::kChargeRelErrNotValid 
+// - MBadPixelsPix::kChargeSigmaNotValid 
+// - MBadPixelsPix::kMeanTimeInFirstBin 
+// - MBadPixelsPix::kMeanTimeInLast2Bins 
+// - MBadPixelsPix::kDeviatingNumPhes
+//
+// - Call MCalibrationPix::SetExcluded() for the bad pixels
+//
+void MCalibrationChargeCalc::FinalizeBadPixels()
+{
+  
+  for (Int_t i=0; i<fBadPixels->GetSize(); i++)
+    {
+      
+      MBadPixelsPix    &bad    = (*fBadPixels)[i];
+      MCalibrationPix  &pix    = (*fCam)[i];
+
+      if (bad.IsUncalibrated( MBadPixelsPix::kChargeIsPedestal))
+        bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun   );
+ 
+      if (bad.IsUncalibrated( MBadPixelsPix::kChargeErrNotValid ))
+        bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun    );
+
+      if (bad.IsUncalibrated( MBadPixelsPix::kChargeRelErrNotValid ))
+        bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun    );
+ 
+      if (bad.IsUncalibrated( MBadPixelsPix::kChargeSigmaNotValid ))
+        bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun    );
+
+      if (bad.IsUncalibrated( MBadPixelsPix::kMeanTimeInFirstBin ))
+        bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun    );
+
+      if (bad.IsUncalibrated( MBadPixelsPix::kMeanTimeInLast2Bins ))
+        bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun    );
+
+      if (bad.IsUncalibrated( MBadPixelsPix::kDeviatingNumPhes ))
+        bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun    );
+
+      if (bad.IsUnsuitable(   MBadPixelsPix::kUnsuitableRun    ))
+        pix.SetExcluded();
+
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+//
+// First loop: Calculate a mean and mean RMS of photo-electrons per area index 
+//             Include only pixels which are not MBadPixelsPix::kUnsuitableRun or 
+//             MBadPixelsPix::kUnreliableRun (see FinalizeBadPixels()) and set 
+//             MCalibrationChargePix::SetFFactorMethodValid(kFALSE) in that case.
+//              
+// Second loop: Get weighted mean number of photo-electrons and its RMS including 
+//              only pixels with flag MCalibrationChargePix::IsFFactorMethodValid() 
+//              and further exclude those deviating by more than fPheErrLimit mean 
+//              sigmas from the mean (obtained in first loop). Set 
+//              MBadPixelsPix::kDeviatingNumPhes if excluded.
+// 
+//              Set weighted mean and variance of photo-electrons per area index in: 
+//              average area pixels of MCalibrationChargeCam (obtained from: 
+//              MCalibrationChargeCam::GetAverageArea() )
+// 
+//              Set weighted mean  and variance of photo-electrons per sector in:
+//              average sector pixels of MCalibrationChargeCam (obtained from: 
+//              MCalibrationChargeCam::GetAverageSector() )
+// 
+Bool_t MCalibrationChargeCalc::FinalizeFFactorMethod()
+{
+
+  const UInt_t npixels  = fGeom->GetNumPixels();
+  const UInt_t nareas   = fGeom->GetNumAreas();
+  const UInt_t nsectors = fGeom->GetNumSectors();
+
+  Float_t lowlim      [nareas];
+  Float_t upplim      [nareas];
+  Float_t areavars    [nareas];
+  Float_t areaweights [nareas], sectorweights [nsectors];
+  Float_t areaphes    [nareas], sectorphes    [nsectors];
+  Int_t   numareavalid[nareas], numsectorvalid[nsectors];
+
+  memset(lowlim        ,0, nareas   * sizeof(Float_t));
+  memset(upplim        ,0, nareas   * sizeof(Float_t));
+  memset(areaphes      ,0, nareas   * sizeof(Float_t));
+  memset(areavars      ,0, nareas   * sizeof(Float_t));
+  memset(areaweights   ,0, nareas   * sizeof(Float_t));
+  memset(numareavalid  ,0, nareas   * sizeof(Int_t  ));
+  memset(sectorweights ,0, nsectors * sizeof(Float_t));
+  memset(sectorphes    ,0, nsectors * sizeof(Float_t));
+  memset(numsectorvalid,0, nsectors * sizeof(Int_t  ));
+  
+  //
+  // First loop: Get mean number of photo-electrons and the RMS
+  //             The loop is only to recognize later pixels with very deviating numbers
+  //
+  MHCamera camphes(*fGeom,"Camphes","Phes in Camera");
+
+  for (UInt_t i=0; i<npixels; i++)
+    {
+      
+      MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)  [i];
+      MBadPixelsPix         &bad = (*fBadPixels)[i];
+      
+      if (!pix.IsFFactorMethodValid())
+        continue;
+
+      if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
+        {
+          pix.SetFFactorMethodValid(kFALSE);
+          continue;
+        }
+
+      // if (bad.IsUnsuitable(MBadPixelsPix::kUnreliableRun))
+      //        continue;
+      
+      const Float_t nphe  = pix.GetPheFFactorMethod();
+      const Int_t   aidx  = (*fGeom)[i].GetAidx();
+
+      camphes.Fill(i,nphe);
+      camphes.SetUsed(i);
+
+      areaphes    [aidx] += nphe;
+      areavars    [aidx] += nphe*nphe;
+      numareavalid[aidx] ++;
+    } 
+
+  for (UInt_t i=0; i<nareas; i++)
+    {
+      if (numareavalid[i] == 0)
+        {
+          *fLog << warn << GetDescriptor() << ": No pixels with valid number of photo-electrons found "
+                << "in area index: " << i << endl;
+          continue;
+        }
+
+      areavars[i] = (areavars[i] - areaphes[i]*areaphes[i]/numareavalid[i]) / (numareavalid[i]-1.);
+      areaphes[i] = areaphes[i] / numareavalid[i];
+
+      if (areavars[i] < 0.)
+        {
+          *fLog << warn << GetDescriptor() << ": No pixels with valid variance of photo-electrons found "
+                << "in area index: " << i << endl;
+          continue;
+        }
+      
+      lowlim  [i] = areaphes[i] - fPheErrLimit*TMath::Sqrt(areavars[i]);
+      upplim  [i] = areaphes[i] + fPheErrLimit*TMath::Sqrt(areavars[i]);
+
+      TArrayI area(1);
+      area[0] = i;
+
+      TH1D *hist = camphes.ProjectionS(TArrayI(),area,"_py",100);
+      hist->Fit("gaus","Q");
+      const Float_t mean  = hist->GetFunction("gaus")->GetParameter(1);
+      const Float_t sigma = hist->GetFunction("gaus")->GetParameter(2);
+      const Int_t   ndf   = hist->GetFunction("gaus")->GetNDF();
+
+      if (ndf < 2)
+        {
+          *fLog << warn << GetDescriptor() << ": Cannot use a Gauss fit to the number of photo-electrons " 
+                << "in the camera with area index: " << i << endl;
+          *fLog << warn << GetDescriptor() << ": Number of dof.: " << ndf << " is smaller than 2 " << endl;
+          *fLog << warn << GetDescriptor() << ": Will use the simple mean and rms " << endl;
+          delete hist;
+          continue;
+        }
+      
+      const Double_t prob = hist->GetFunction("gaus")->GetProb();
+
+      if (prob < 0.001)
+        {
+          *fLog << warn << GetDescriptor() << ": Cannot use a Gauss fit to the number of photo-electrons " 
+                << "in the camera with area index: " << i << endl;
+          *fLog << warn << GetDescriptor() << ": Fit probability " << prob 
+                << " is smaller than 0.001 " << endl;
+          *fLog << warn << GetDescriptor() << ": Will use the simple mean and rms " << endl;
+          delete hist;
+          continue;
+        }
+      
+      *fLog << inf << endl;
+      *fLog << inf << GetDescriptor() << ": Mean Number of photo-electrons " 
+            << "in the camera with area index: " << i << ": " 
+            << Form("%4.2f%s%4.2f",mean,"+-",sigma) << endl;
+      *fLog << inf << endl;
+
+      lowlim  [i] = mean  - fPheErrLimit*sigma;
+      upplim  [i] = mean  + fPheErrLimit*sigma;
+
+      delete hist;
+    }
+
+  memset(numareavalid,0,nareas*sizeof(Int_t));
+  memset(areaphes    ,0,nareas*sizeof(Int_t));
+  memset(areavars    ,0,nareas*sizeof(Int_t));
+
+  //
+  // Second loop: Get mean number of photo-electrons and its RMS excluding 
+  //              pixels deviating by more than fPheErrLimit sigma. 
+  //              Set the conversion factor FADC counts to photo-electrons
+  // 
+  for (UInt_t i=0; i<npixels; i++)
+    {
+      
+      MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
+
+      if (!pix.IsFFactorMethodValid())
+        continue;
+
+      const Float_t nvar  = pix.GetPheFFactorMethodVar();
+
+      if (nvar <= 0.)
+        {
+          pix.SetFFactorMethodValid(kFALSE);
+          continue;
+        }
+      
+      MBadPixelsPix         &bad = (*fBadPixels)[i];
+
+      const Int_t   aidx   = (*fGeom)[i].GetAidx();
+      const Int_t   sector = (*fGeom)[i].GetSector();
+      const Float_t nphe   = pix.GetPheFFactorMethod();
+
+      if ( nphe < lowlim[aidx] || nphe > upplim[aidx] )
+        {
+          *fLog << warn << GetDescriptor() << ": Deviating number of photo-electrons: " 
+                << Form("%4.2f",nphe) << " out of accepted limits: [" 
+                << Form("%4.2f%s%4.2f",lowlim[aidx],",",upplim[aidx]) << "] in pixel " << i << endl;
+          bad.SetUncalibrated( MBadPixelsPix::kDeviatingNumPhes );
+          bad.SetUnsuitable  ( MBadPixelsPix::kUnsuitableRun    );
+          pix.SetFFactorMethodValid(kFALSE);
+          continue;
+        }
+      
+      //      const Float_t weight = 1./nvar;
+      //      areaweights   [aidx]   += weight;
+      //      areaphes      [aidx]   += weight*nphe;
+      areaweights   [aidx]   += nphe*nphe;
+      areaphes      [aidx]   += nphe;
+      numareavalid  [aidx]   ++;
+
+      if (aidx == 0)
+        fNumInnerFFactorMethodUsed++;
+      //       sectorweights [sector] += weight;
+      //      sectorphes    [sector] += weight*nphe;
+      sectorweights [sector] += nphe*nphe;
+      sectorphes    [sector] += nphe;
+      numsectorvalid[sector] ++;
+    } 
+
+  for (UInt_t aidx=0; aidx<nareas; aidx++)
+    {
+
+      MCalibrationChargePix &apix = (MCalibrationChargePix&)fCam->GetAverageArea(aidx);
+
+      areaweights[aidx] -=  areaphes[aidx]*areaphes[aidx]/numareavalid[aidx];
+      areaphes[aidx]    /=  numareavalid[aidx];
+      areaweights[aidx] /=  numareavalid[aidx]-1.;
+      
+      if (areaweights[aidx] <= 0. || areaphes[aidx] <= 0.)
+        {
+          *fLog << warn << " Mean number of phe's from area index " << aidx << " cannot be calculated: "
+                << " Mean number of phes: "  << areaphes[aidx] 
+                << " Variance: " << areaweights[aidx]    << endl;
+          apix.SetFFactorMethodValid(kFALSE);
+          continue;
+        }
+      
+      *fLog << inf << "Replacing number photo-electrons of average area idx " << aidx << ": " 
+            << Form("%5.3f%s%5.3f",apix.GetPheFFactorMethod()," +- ",apix.GetPheFFactorMethodErr()) << endl;
+      *fLog << inf << "  by average number of photo-electrons from area idx " << aidx <<  ": " 
+            << Form("%5.3f%s%5.3f",areaphes[aidx]," +- ",TMath::Sqrt(areaweights[aidx])) << endl;
+                    
+      //      apix.SetPheFFactorMethod   ( areaphes[aidx]/ areaweights[aidx] );
+      //      apix.SetPheFFactorMethodVar(    1.         / areaweights[aidx] );      
+      apix.SetPheFFactorMethod   ( areaphes[aidx] );
+      apix.SetPheFFactorMethodVar( areaweights[aidx] / numareavalid[aidx] );      
+      apix.SetFFactorMethodValid ( kTRUE );
+
+    }
+
+  for (UInt_t sector=0; sector<nsectors; sector++)
+    {
+
+      sectorweights[sector] -=  sectorphes[sector]*sectorphes[sector]/numsectorvalid[sector];
+      sectorphes[sector]    /=  numsectorvalid[sector];
+      sectorweights[sector] /=  numsectorvalid[sector]-1.;
+
+      MCalibrationChargePix &spix = (MCalibrationChargePix&)fCam->GetAverageSector(sector);
+
+      if (sectorweights[sector] <= 0. || sectorphes[sector] <= 0.)
+        {
+          *fLog << warn << " Mean number of phe's from sector " << sector << " cannot be calculated: "
+                << " Mean number of phes: "  << sectorphes[sector] 
+                << " Variance: "             << sectorweights[sector]    << endl;
+          spix.SetFFactorMethodValid(kFALSE);
+          continue;
+        }
+
+      *fLog << inf << "Replacing number photo-electrons of average sector " << sector << ": " 
+            << Form("%5.3f%s%5.3f",spix.GetPheFFactorMethod()," +- ",spix.GetPheFFactorMethodErr()) << endl;
+      *fLog << inf << "   by average number photo-electrons from sector " << sector <<  ": " 
+            << Form("%5.3f%s%5.3f",sectorphes[sector]," +- ",TMath::Sqrt(sectorweights[sector])) << endl;
+
+      //      spix.SetPheFFactorMethod   ( sectorphes[sector]/ sectorweights[sector] );
+      //      spix.SetPheFFactorMethodVar(    1.        / sectorweights[sector] );      
+      spix.SetPheFFactorMethod   ( sectorphes[sector] );
+      spix.SetPheFFactorMethodVar( sectorweights[sector] / numsectorvalid[sector]);      
+      spix.SetFFactorMethodValid ( kTRUE );
+
+    }
+
+  return kTRUE;
+}
+
+
+// ------------------------------------------------------------------------
+//
+// Returns kFALSE if pointer to MCalibrationChargeBlindPix is NULL
+//
+// The check returns kFALSE if:
+//
+// 1) fLambda and fLambdaCheck are separated relatively to each other by more than fLambdaCheckLimit
+// 2) BlindPixel has an fLambdaErr greater than fLambdaErrLimit
+// 
+// Calls:
+// - MCalibrationChargeBlindPix::CalcFluxInsidePlexiglass()
+//
+Bool_t MCalibrationChargeCalc::FinalizeBlindPixel()
+{
+
+  if (!fBlindPixel)
+    return kFALSE;  
+
+  const Float_t lambda      = fBlindPixel->GetLambda();
+  const Float_t lambdaerr   = fBlindPixel->GetLambdaErr();
+  const Float_t lambdacheck = fBlindPixel->GetLambdaCheck();
+
+  if (2.*(lambdacheck-lambda)/(lambdacheck+lambda) > fLambdaCheckLimit)
+    {
+      *fLog << warn << GetDescriptor() 
+            << Form("%s%4.2f%s%4.2f%s%4.2f%s",": Lambda: ",lambda," and Lambda-Check: ",
+                    lambdacheck," differ by more than ",fLambdaCheckLimit," in the Blind Pixel ")
+            << endl;
+      return kFALSE;
+    }
+  
+  if (lambdaerr > fLambdaErrLimit) 
+    {
+      *fLog << warn << GetDescriptor() 
+            << Form("%s%4.2f%s%4.2f%s",": Error of Fitted Lambda: ",lambdaerr," is greater than ",
+                    fLambdaErrLimit," in Blind Pixel ") << endl;
+      return kFALSE;
+    }
+      
+  if (!fBlindPixel->CalcFluxInsidePlexiglass())
+    {
+      *fLog << warn << "Could not calculate the flux of photons from the Blind Pixel, "
+            << "will skip Blind Pixel Calibration " << endl;
+      return kFALSE;
+    }
+  
+  return kTRUE;
+}
+
+// ------------------------------------------------------------------------
+//
+// Returns kFALSE if pointer to MCalibrationChargePINDiode is NULL
+//
+// The check returns kFALSE if:
+//
+// 1) PINDiode has a fitted charge smaller than fChargeLimit*PedRMS
+// 2) PINDiode has a fit error smaller than fChargeErrLimit
+// 3) PINDiode has a fitted charge smaller its fChargeRelErrLimit times its charge error
+// 4) PINDiode has a charge sigma smaller than its Pedestal RMS
+// 
+// Calls:
+// - MCalibrationChargePINDiode::CalcFluxOutsidePlexiglass()
+//
+Bool_t MCalibrationChargeCalc::FinalizePINDiode()
+{
+
+  if (!fPINDiode)
+    return kFALSE;  
+
+  if (fPINDiode->GetMean() < fChargeLimit*fPINDiode->GetPedRms())
+    {
+      *fLog << warn << GetDescriptor() << ": Fitted Charge is smaller than "
+            << fChargeLimit << " Pedestal RMS in PINDiode " << endl;
+      return kFALSE;
+    }
+  
+  if (fPINDiode->GetMeanErr() < fChargeErrLimit) 
+    {
+      *fLog << warn << GetDescriptor() << ": Error of Fitted Charge is smaller than "
+            << fChargeErrLimit << " in PINDiode " << endl;
+      return kFALSE;
+    }
+      
+  if (fPINDiode->GetMean() < fChargeRelErrLimit*fPINDiode->GetMeanErr()) 
+    {
+      *fLog << warn << GetDescriptor() << ": Fitted Charge is smaller than "
+            << fChargeRelErrLimit << "* its error in PINDiode " << endl;
+      return kFALSE;
+    }
+      
+  if (fPINDiode->GetSigma() < fPINDiode->GetPedRms())
+    {
+      *fLog << warn << GetDescriptor() 
+            << ": Sigma of Fitted Charge smaller than Pedestal RMS in PINDiode " << endl;
+      return kFALSE;
+    }
+
+
+  if (!fPINDiode->CalcFluxOutsidePlexiglass())
+    {
+      *fLog << warn << "Could not calculate the flux of photons from the PIN Diode, "
+            << "will skip PIN Diode Calibration " << endl;
+      return kFALSE;
+    }
+  
+  return kTRUE;
+}
+
+// ------------------------------------------------------------------------
+//
+// Calculate the average number of photons outside the plexiglass with the 
+// formula: 
+// 
+// av.Num.photons(area index) = av.Num.Phes(area index) 
+//                            / MCalibrationQEPix::GetDefaultQE(fPulserColor) 
+//                            / MCalibrationQEPix::GetPMTCollectionEff()
+//                            / MCalibrationQEPix::GetLightGuidesEff(fPulserColor)
+//                            / MCalibrationQECam::GetPlexiglassQE()
+//
+// Calculate the variance on the average number of photons assuming that the error on the 
+// Quantum efficiency is reduced by the number of used inner pixels, but the rest of the 
+// values keeps it ordinary error since it is systematic.
+//
+// Loop over pixels: 
+//
+// - Continue, if not MCalibrationChargePix::IsFFactorMethodValid() and set:
+//                    MCalibrationQEPix::SetFFactorMethodValid(kFALSE,fPulserColor)
+//
+// - Call MCalibrationChargePix::CalcMeanFFactor(av.Num.photons) and set: 
+//        MCalibrationQEPix::SetFFactorMethodValid(kFALSE,fPulserColor) if not succesful
+//
+// - Calculate the quantum efficiency with the formula:
+// 
+//   QE = ( Num.Phes / av.Num.photons ) * MGeomCam::GetPixRatio()
+//
+// - Set QE in MCalibrationQEPix::SetQEFFactor ( QE, fPulserColor );
+//
+// - Set Variance of QE in  MCalibrationQEPix::SetQEFFactorVar ( Variance, fPulserColor );
+// - Set bit MCalibrationQEPix::SetFFactorMethodValid(kTRUE,fPulserColor) 
+//
+// - Call MCalibrationQEPix::UpdateFFactorMethod()
+//
+void MCalibrationChargeCalc::FinalizeFFactorQECam()
+{
+
+  if (fNumInnerFFactorMethodUsed < 2)
+    {
+      *fLog << warn << GetDescriptor() 
+            << ": Could not calculate F-Factor Method: Less than 2 inner pixels valid! " << endl;
+      return;
+    }
+  
+  MCalibrationChargePix &avpix = (MCalibrationChargePix&)fCam->GetAverageArea(0);
+  MCalibrationQEPix     &qepix = (MCalibrationQEPix&)  fQECam->GetAverageArea(0);  
+
+  const Float_t avphotons   = avpix.GetPheFFactorMethod()       
+                           / qepix.GetDefaultQE(fPulserColor) 
+                           / qepix.GetPMTCollectionEff()
+                           / qepix.GetLightGuidesEff(fPulserColor)
+                           / fQECam->GetPlexiglassQE();
+
+  const Float_t avphotrelvar = avpix.GetPheFFactorMethodRelVar() 
+                            + qepix.GetDefaultQERelVar(fPulserColor) / fNumInnerFFactorMethodUsed
+                            + qepix.GetPMTCollectionEffRelVar()
+                            + qepix.GetLightGuidesEffRelVar(fPulserColor)
+                            + fQECam->GetPlexiglassQERelVar();
+
+  const UInt_t nareas   = fGeom->GetNumAreas();
+
+  //
+  // Set the results in the MCalibrationChargeCam
+  //
+  fCam->SetNumPhotonsFFactorMethod   (avphotons);
+  if (avphotrelvar > 0.)
+    fCam->SetNumPhotonsFFactorMethodErr(TMath::Sqrt( avphotrelvar * avphotons * avphotons));  
+
+  Float_t lowlim           [nareas];
+  Float_t upplim           [nareas];
+  Float_t avffactorphotons [nareas];
+  Float_t avffactorphotvar [nareas];
+  Int_t   numffactor       [nareas];
+
+  memset(lowlim          ,0, nareas   * sizeof(Float_t));
+  memset(upplim          ,0, nareas   * sizeof(Float_t));
+  memset(avffactorphotons,0, nareas   * sizeof(Float_t));
+  memset(avffactorphotvar,0, nareas   * sizeof(Float_t));
+  memset(numffactor      ,0, nareas   * sizeof(Int_t));
+
+  const UInt_t npixels  = fGeom->GetNumPixels();
+
+  MHCamera camffactor(*fGeom,"Camffactor","F-Factor in Camera");
+
+  for (UInt_t i=0; i<npixels; i++)
+    {
+      
+      MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
+      MCalibrationQEPix   &qepix = (MCalibrationQEPix&)  (*fQECam)[i];
+      MBadPixelsPix         &bad =                   (*fBadPixels)[i];
+
+      if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
+        continue;
+
+      const Float_t photons = avphotons / fGeom->GetPixRatio(i);
+      const Float_t qe      = pix.GetPheFFactorMethod() / photons ;
+
+      if (!pix.CalcMeanFFactor( photons , avphotrelvar ))
+        {
+          (*fBadPixels)[i].SetUncalibrated( MBadPixelsPix::kDeviatingNumPhes );
+          continue;
+        }
+
+      const Float_t qerelvar = avphotrelvar +  pix.GetPheFFactorMethodRelVar();
+
+      qepix.SetQEFFactor    ( qe            , fPulserColor );
+      qepix.SetQEFFactorVar ( qerelvar*qe*qe, fPulserColor );      
+      qepix.SetFFactorMethodValid(  kTRUE   , fPulserColor );
+
+      if (!qepix.UpdateFFactorMethod())
+        *fLog << warn << GetDescriptor() 
+              << ": Cannot update Quantum efficiencies with the F-Factor Method" << endl;
+
+      const Int_t aidx = (*fGeom)[i].GetAidx();
+      const Float_t ffactor = pix.GetMeanFFactorFADC2Phot();
+
+      camffactor.Fill(i,ffactor);
+      camffactor.SetUsed(i);
+
+      avffactorphotons[aidx] += ffactor;
+      avffactorphotvar[aidx] += ffactor*ffactor;
+      numffactor[aidx]++;
+    }
+
+  for (UInt_t i=0; i<nareas; i++)
+    {
+
+      if (numffactor[i] == 0)
+        {
+          *fLog << warn << GetDescriptor() << ": No pixels with valid total F-Factor found "
+                << "in area index: " << i << endl;
+          continue;
+        }
+
+      avffactorphotvar[i] = (avffactorphotvar[i] - avffactorphotons[i]*avffactorphotons[i]/numffactor[i]) / (numffactor[i]-1.);
+      avffactorphotons[i] = avffactorphotons[i] / numffactor[i];
+
+      if (avffactorphotvar[i] < 0.)
+        {
+          *fLog << warn << GetDescriptor() << ": No pixels with valid variance of total F-Factor found "
+                << "in area index: " << i << endl;
+          continue;
+        }
+
+      lowlim  [i] = 1.1;   // Lowest known F-Factor of a PMT
+      upplim  [i] = avffactorphotons[i] + fFFactorErrLimit*TMath::Sqrt(avffactorphotvar[i]);
+
+      TArrayI area(1);
+      area[0] = i;
+
+      TH1D *hist = camffactor.ProjectionS(TArrayI(),area,"_py",100);
+      hist->Fit("gaus","Q");
+      const Float_t mean  = hist->GetFunction("gaus")->GetParameter(1);
+      const Float_t sigma = hist->GetFunction("gaus")->GetParameter(2);
+      const Int_t   ndf   = hist->GetFunction("gaus")->GetNDF();
+
+      if (ndf < 2)
+        {
+          *fLog << warn << GetDescriptor() << ": Cannot use a Gauss fit to the F-Factor " 
+                << "in the camera with area index: " << i << endl;
+          *fLog << warn << GetDescriptor() << ": Number of dof.: " << ndf << " is smaller than 2 " << endl;
+          *fLog << warn << GetDescriptor() << ": Will use the simple mean and rms " << endl;
+          delete hist;
+          continue;
+        }
+      
+      const Double_t prob = hist->GetFunction("gaus")->GetProb();
+
+      if (prob < 0.001)
+        {
+          *fLog << warn << GetDescriptor() << ": Cannot use a Gauss fit to the F-Factor " 
+                << "in the camera with area index: " << i << endl;
+          *fLog << warn << GetDescriptor() << ": Fit probability " << prob 
+                << " is smaller than 0.001 " << endl;
+          *fLog << warn << GetDescriptor() << ": Will use the simple mean and rms " << endl;
+          delete hist;
+          continue;
+        }
+
+      *fLog << inf << endl;
+      *fLog << inf << GetDescriptor() << ": Mean F-Factor " 
+            << "in the camera with area index: " << i << ": " 
+            << Form("%4.2f%s%4.2f",mean,"+-",sigma) << endl;
+      *fLog << inf << endl;
+
+      lowlim  [i] = mean  - fFFactorErrLimit*sigma;
+      upplim  [i] = mean  + fFFactorErrLimit*sigma;
+
+      delete hist;
+    }
+  
+  for (UInt_t i=0; i<npixels; i++)
+    {
+      
+      MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
+      MBadPixelsPix         &bad =                   (*fBadPixels)[i];
+
+      if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
+        continue;
+      
+      const Float_t ffactor = pix.GetMeanFFactorFADC2Phot();
+      const Int_t   aidx   = (*fGeom)[i].GetAidx();
+
+      if ( ffactor < lowlim[aidx] || ffactor > upplim[aidx] )
+        {
+          *fLog << warn << GetDescriptor() << ": Deviating F-Factor: " 
+                << Form("%4.2f",ffactor) << " out of accepted limits: [" 
+                << Form("%4.2f%s%4.2f",lowlim[aidx],",",upplim[aidx]) << "] in pixel " << i << endl;
+          bad.SetUncalibrated( MBadPixelsPix::kDeviatingFFactor );
+          bad.SetUnsuitable  ( MBadPixelsPix::kUnsuitableRun    );
+        }
+    }
+
+  for (UInt_t i=0; i<npixels; i++)
+    {
+      
+      MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
+      MCalibrationQEPix   &qepix = (MCalibrationQEPix&)  (*fQECam)[i];
+      MBadPixelsPix         &bad =                   (*fBadPixels)[i];
+      
+      if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
+        {
+          qepix.SetFFactorMethodValid(kFALSE,fPulserColor);
+          pix.SetFFactorMethodValid(kFALSE);
+          pix.SetExcluded();
+          continue;
+        }
+    }
+}
+
+
+// ------------------------------------------------------------------------
+//
+// Loop over pixels: 
+//
+// - Continue, if not MCalibrationChargeBlindPix::IsFluxInsidePlexiglassAvailable() and set:
+//                    MCalibrationQEPix::SetBlindPixelMethodValid(kFALSE,fPulserColor)
+//
+// - Calculate the quantum efficiency with the formula:
+// 
+//   QE =  Num.Phes / MCalibrationChargeBlindPix::GetFluxInsidePlexiglass() 
+//        / MGeomPix::GetA() * MCalibrationQECam::GetPlexiglassQE()
+//
+// - Set QE in MCalibrationQEPix::SetQEBlindPixel ( QE, fPulserColor );
+// - Set Variance of QE in  MCalibrationQEPix::SetQEBlindPixelVar ( Variance, fPulserColor );
+// - Set bit MCalibrationQEPix::SetBlindPixelMethodValid(kTRUE,fPulserColor) 
+//
+// - Call MCalibrationQEPix::UpdateBlindPixelMethod()
+//
+void MCalibrationChargeCalc::FinalizeBlindPixelQECam()
+{
+
+  const UInt_t npixels  = fGeom->GetNumPixels();
+
+  //
+  // Set the results in the MCalibrationChargeCam
+  //
+  if (fBlindPixel)
+    {
+      if (fBlindPixel->IsFluxInsidePlexiglassAvailable())
+        {
+
+          const Float_t photons = fBlindPixel->GetFluxInsidePlexiglass() * (*fGeom)[0].GetA()
+                               / fQECam->GetPlexiglassQE();
+          fCam->SetNumPhotonsBlindPixelMethod(photons);
+
+          const Float_t photrelvar = fBlindPixel->GetFluxInsidePlexiglassRelVar() 
+                                   + fQECam->GetPlexiglassQERelVar();
+          if (photrelvar > 0.)
+            fCam->SetNumPhotonsBlindPixelMethodErr(TMath::Sqrt( photrelvar * photons * photons));  
+        }
+    }
+  //
+  //  With the knowledge of the overall photon flux, calculate the 
+  //  quantum efficiencies after the Blind Pixel and PIN Diode method
+  //
+  for (UInt_t i=0; i<npixels; i++)
+    {
+      
+      MCalibrationQEPix   &qepix = (MCalibrationQEPix&)  (*fQECam)[i];
+
+      if (!fBlindPixel)
+        {
+          qepix.SetBlindPixelMethodValid(kFALSE, fPulserColor);
+          continue;
+        }
+
+      if (!fBlindPixel->IsFluxInsidePlexiglassAvailable())
+        {
+          qepix.SetBlindPixelMethodValid(kFALSE, fPulserColor);
+          continue;
+        }
+      
+      MBadPixelsPix &bad = (*fBadPixels)[i];
+      if (bad.IsUnsuitable (MBadPixelsPix::kUnsuitableRun))
+        {
+          qepix.SetBlindPixelMethodValid(kFALSE, fPulserColor);
+          continue;
+        }
+      
+      MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
+      MGeomPix              &geo =                        (*fGeom)[i];
+      
+      const Float_t qe        = pix.GetPheFFactorMethod() 
+                             / fBlindPixel->GetFluxInsidePlexiglass() 
+                             / geo.GetA() 
+                             * fQECam->GetPlexiglassQE();
+
+      const Float_t qerelvar = fBlindPixel->GetFluxInsidePlexiglassRelVar() 
+                               + fQECam->GetPlexiglassQERelVar()
+                               + pix.GetPheFFactorMethodRelVar();
+
+      qepix.SetQEBlindPixel    ( qe            , fPulserColor );
+      qepix.SetQEBlindPixelVar ( qerelvar*qe*qe, fPulserColor );      
+      qepix.SetBlindPixelMethodValid(  kTRUE   , fPulserColor );
+
+      if (!qepix.UpdateBlindPixelMethod())
+        *fLog << warn << GetDescriptor() 
+              << ": Cannot update Quantum efficiencies with the Blind Pixel Method" << endl;
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// Loop over pixels: 
+//
+// - Continue, if not MCalibrationChargePINDiode::IsFluxOutsidePlexiglassAvailable() and set:
+//                    MCalibrationQEPix::SetPINDiodeMethodValid(kFALSE,fPulserColor)
+//
+// - Calculate the quantum efficiency with the formula:
+// 
+//   QE =  Num.Phes / MCalibrationChargePINDiode::GetFluxOutsidePlexiglass() / MGeomPix::GetA()
+//
+// - Set QE in MCalibrationQEPix::SetQEPINDiode ( QE, fPulserColor );
+// - Set Variance of QE in  MCalibrationQEPix::SetQEPINDiodeVar ( Variance, fPulserColor );
+// - Set bit MCalibrationQEPix::SetPINDiodeMethodValid(kTRUE,fPulserColor) 
+//
+// - Call MCalibrationQEPix::UpdatePINDiodeMethod()
+//
+void MCalibrationChargeCalc::FinalizePINDiodeQECam()
+{
+  
+  const UInt_t npixels  = fGeom->GetNumPixels();
+
+  //
+  //  With the knowledge of the overall photon flux, calculate the 
+  //  quantum efficiencies after the PIN Diode method
+  //
+  for (UInt_t i=0; i<npixels; i++)
+    {
+      
+      MCalibrationQEPix   &qepix = (MCalibrationQEPix&)  (*fQECam)[i];
+
+      if (!fPINDiode)
+        {
+          qepix.SetPINDiodeMethodValid(kFALSE, fPulserColor);
+          continue;
+        }
+      
+      if (!fPINDiode->IsFluxOutsidePlexiglassAvailable())
+        {
+          qepix.SetPINDiodeMethodValid(kFALSE, fPulserColor);
+          continue;
+        }
+
+      MBadPixelsPix &bad  =  (*fBadPixels)[i];
+
+      if (!bad.IsUnsuitable (MBadPixelsPix::kUnsuitableRun))
+        {
+          qepix.SetPINDiodeMethodValid(kFALSE, fPulserColor);
+          continue;
+        }
+      
+      MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
+      MGeomPix              &geo =                        (*fGeom)[i];
+      
+      const Float_t qe       =  pix.GetPheFFactorMethod() 
+                               / fPINDiode->GetFluxOutsidePlexiglass() 
+                               / geo.GetA();
+
+      const Float_t qerelvar = fPINDiode->GetFluxOutsidePlexiglassRelVar() + pix.GetPheFFactorMethodRelVar();
+
+      qepix.SetQEPINDiode    ( qe            , fPulserColor );
+      qepix.SetQEPINDiodeVar ( qerelvar*qe*qe, fPulserColor );      
+      qepix.SetPINDiodeMethodValid(  kTRUE   , fPulserColor );
+
+      if (!qepix.UpdatePINDiodeMethod())
+        *fLog << warn << GetDescriptor() 
+              << ": Cannot update Quantum efficiencies with the PIN Diode Method" << endl;
+    }
+}
+
+// -----------------------------------------------------------------------------------------------
+//
+// - Print out statistics about BadPixels of type UnsuitableType_t 
+// - store numbers of bad pixels of each type in fCam
+//
+void MCalibrationChargeCalc::FinalizeUnsuitablePixels()
+{
+  
+  *fLog << inf << endl;
+  *fLog << GetDescriptor() << ": Charge Calibration status:" << endl;
+  *fLog << dec << setfill(' ');
+
+  const Int_t nareas = fGeom->GetNumAreas();
+
+  Int_t counts[nareas];
+  memset(counts,0,nareas*sizeof(Int_t));
+
+  for (Int_t i=0; i<fBadPixels->GetSize(); i++)
+    {
+      MBadPixelsPix &bad = (*fBadPixels)[i];
+      if (!bad.IsBad())
+        {
+          const Int_t aidx = (*fGeom)[i].GetAidx();
+          counts[aidx]++;
+        }
+    }
+
+  if (fGeom->InheritsFrom("MGeomCamMagic"))
+    *fLog << " " << setw(7) << "Successfully calibrated Pixels: " 
+          << Form("%s%3i%s%3i","Inner: ",counts[0]," Outer: ",counts[1]) << endl;
+  
+  memset(counts,0,nareas*sizeof(Int_t));
+
+  for (Int_t i=0; i<fBadPixels->GetSize(); i++)
+    {
+      MBadPixelsPix &bad = (*fBadPixels)[i];
+      if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
+        {
+          const Int_t aidx = (*fGeom)[i].GetAidx();
+          counts[aidx]++;
+        }
+    }
+
+  for (Int_t aidx=0; aidx<nareas; aidx++)
+    fCam->SetNumUnsuitable(counts[aidx], aidx);
+
+  if (fGeom->InheritsFrom("MGeomCamMagic"))
+    *fLog << " " << setw(7) << "Uncalibrated Pixels:            " 
+          << Form("%s%3i%s%3i","Inner: ",counts[0]," Outer: ",counts[1]) << endl;
+
+  memset(counts,0,nareas*sizeof(Int_t));
+
+  for (Int_t i=0; i<fBadPixels->GetSize(); i++)
+    {
+      MBadPixelsPix &bad = (*fBadPixels)[i];
+      if (bad.IsUnsuitable(MBadPixelsPix::kUnreliableRun))
+        {
+          const Int_t aidx = (*fGeom)[i].GetAidx();
+          counts[aidx]++;
+        }
+    }
+
+  for (Int_t aidx=0; aidx<nareas; aidx++)
+    fCam->SetNumUnreliable(counts[aidx], aidx);
+
+  *fLog << " " << setw(7) << "Unreliable Pixels:              "
+        << Form("%s%3i%s%3i","Inner: ",counts[0]," Outer: ",counts[1]) << endl;
+
+}
+
+// -----------------------------------------------------------------------------------------------
+//
+// Print out statistics about BadPixels of type UncalibratedType_t 
+// 
+void MCalibrationChargeCalc::PrintUncalibrated(MBadPixelsPix::UncalibratedType_t typ, const char *text) const 
+{
+  
+  UInt_t countinner = 0;
+  UInt_t countouter = 0;
+
+  for (Int_t i=0; i<fBadPixels->GetSize(); i++)
+    {
+      MBadPixelsPix &bad = (*fBadPixels)[i];
+      if (bad.IsUncalibrated(typ))
+        {
+          if (fGeom->GetPixRatio(i) == 1.)
+            countinner++;
+          else
+            countouter++;
+        }
+    }
+
+  *fLog << " " << setw(7) << text  
+        << Form("%s%3i%s%3i","Inner: ",countinner," Outer: ",countouter) << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the path for output file
+// 
+void MCalibrationChargeCalc::SetOutputPath(TString path)
+{
+  fOutputPath = path;
+  if (fOutputPath.EndsWith("/"))
+    fOutputPath = fOutputPath(0, fOutputPath.Length()-1);
+}
+
+void MCalibrationChargeCalc::SetOutputFile(TString file)
+{ 
+  fOutputFile        = file; 
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the output file
+// 
+const char* MCalibrationChargeCalc::GetOutputFile()
+{
+  return Form("%s/%s", (const char*)fOutputPath, (const char*)fOutputFile);
+}
Index: /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationChargeCalc.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationChargeCalc.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationChargeCalc.h	(revision 9661)
@@ -0,0 +1,150 @@
+#ifndef MARS_MCalibrationChargeCalc
+#define MARS_MCalibrationChargeCalc
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MCalibrationChargeCalc                                                   //
+//                                                                         //
+// Integrates the time slices of the all pixels of a calibration event     //
+// and substract the pedestal value                                        //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+#ifndef MARS_MBadPixelsPix
+#include "MBadPixelsPix.h"
+#endif
+
+#ifndef MARS_MCalibrationCam
+#include "MCalibrationCam.h"
+#endif
+
+#ifndef ROOT_TArrayC
+#include "TArrayC.h"
+#endif
+
+class MRawEvtData;
+class MRawRunHeader;
+class MPedestalCam;
+class MPedestalPix;
+class MCalibrationChargePINDiode;
+class MCalibrationChargeBlindCam;
+class MCalibrationChargeBlindPix;
+class MCalibrationChargePix;
+class MCalibrationChargeCam;
+class MCalibrationQECam;
+class MGeomCam;
+class MExtractedSignalCam;
+class MExtractedSignalBlindPixel;
+class MExtractedSignalPINDiode;
+class MBadPixelsCam;
+class MBadPixelsPix;
+class MTime;
+class MCalibrationChargeCalc : public MTask
+{
+private:
+
+  static const Float_t fgChargeLimit;          //! Default for fChargeLimit            (now set to: 2.5)
+  static const Float_t fgChargeErrLimit;       //! Default for fChargeErrLimit         (now set to: 0.)
+  static const Float_t fgChargeRelErrLimit;    //! Default for fChargeRelErrLimit      (now set to: 1.)
+  static const Float_t fgLambdaCheckLimit;     //! Default for fLambdaCheckLimit       (now set to: 0.2)
+  static const Float_t fgLambdaErrLimit;       //! Default for fLabmdaErrLimit         (now set to: 0.5)
+  static const Float_t fgPheErrLimit;          //! Default for fPheErrLimit            (now set to: 4.)
+  static const Float_t fgFFactorErrLimit;      //! Default for fFFactorErrLimit        (now set to: 4.)
+ 
+  // Variables
+  Float_t fChargeLimit;                        // Limit acceptance mean charge  (in units of PedRMS)
+  Float_t fChargeErrLimit;                     // Limit acceptance charge error (in abs. numbers)
+  Float_t fChargeRelErrLimit;                  // Limit acceptance rel. error mean (in abs. numbers)
+  Float_t fLambdaCheckLimit;                   // Limit rel. diff. lambda and lambdacheck in Blind Pixel
+  Float_t fLambdaErrLimit;                     // Limit acceptance lambda error in Blind Pixel
+  Float_t fNumHiGainSamples;                   // Number High-Gain FADC slices used by extractor
+  Float_t fNumLoGainSamples;                   // Number Low -Gain FADC slices used by extractor
+  Float_t fPheErrLimit;                        // Limit acceptance nr. phe's w.r.t. area idx mean (in sigmas)
+  Float_t fFFactorErrLimit;                    // Limit acceptance F-Factor w.r.t. area idx mean 
+  Float_t fSqrtHiGainSamples;                  // Square root nr. High-Gain FADC slices used by extractor
+  Float_t fSqrtLoGainSamples;                  // Square root nr. Low -Gain FADC slices used by extractor 
+  MCalibrationCam::PulserColor_t fPulserColor; // Calibration LEDs colour 
+  Int_t   fNumInnerFFactorMethodUsed;          // Number of inner pixels used for F-Factor Method calibration
+
+  Byte_t  fFlags;                              // Bit-field for the general flags
+  TArrayC fResultFlags;                        // Bit-fields for the fitting results   (one field per area index)
+  TArrayC fBlindPixelFlags;                    // Bit-fields for the blind pixel flags (one field per blind pixel)
+  TArrayC fPINDiodeFlags;                      // Bit-fields for the PIN Diode flags   (one field per PIN Diode  )
+  
+  TString fOutputPath;                         // Path to the output file
+  TString fOutputFile;                         // Name of the output file  
+  
+  // Pointers
+  MBadPixelsCam              *fBadPixels;      //  Bad Pixels 
+  MCalibrationChargeCam      *fCam;            //  Calibrated Charges of all pixels 
+  MCalibrationChargeBlindPix *fBlindPixel;     //  Calibrated Charges of the Blind Pixel 
+  MCalibrationChargeBlindCam *fBlindCam;       //  Calibrated Charges of the Blind Pixels
+  MCalibrationChargePINDiode *fPINDiode;       //  Calibrated Charges of the PIN Diode
+  MCalibrationQECam          *fQECam;          //  Calibrated Quantum Efficiencies of all pixels 
+  MGeomCam                   *fGeom;           //! Camera geometry
+  MPedestalCam               *fPedestals;      //! Pedestals all pixels (calculated previously from ped.file)
+
+  // enums
+  enum  { kDebug, kPheFitOK, kFFactorFitOK, kBlindPixelFitOK, kBlindPixelPedFitOK, kPINDiodeFitOK };
+
+  // functions
+  const char* GetOutputFile();
+  void   FinalizePedestals       ( const MPedestalPix    &ped, MCalibrationChargePix &cal, const Int_t aidx );
+  Bool_t FinalizeCharges         ( MCalibrationChargePix &cal, MBadPixelsPix &bad                           );
+  Bool_t FinalizePINDiode        ();
+  Bool_t FinalizeBlindPixel      ();
+  Bool_t FinalizeFFactorMethod   ();
+  void   FinalizeBadPixels       ();
+  void   FinalizeFFactorQECam    ();  
+  void   FinalizeBlindPixelQECam ();
+  void   FinalizePINDiodeQECam   ();
+  void   FinalizeUnsuitablePixels();
+
+  void   PrintUncalibrated( MBadPixelsPix::UncalibratedType_t typ, const char *text) const;
+
+  void   SetPheFitOK          ( const Int_t aidx, const Bool_t b=kTRUE ) { b ? SETBIT(fResultFlags[aidx], kPheFitOK) 
+							                     : CLRBIT(fResultFlags[aidx], kPheFitOK);      }
+  void   SetFFactorFitOK      ( const Int_t aidx, const Bool_t b=kTRUE ) { b ? SETBIT(fResultFlags[aidx], kFFactorFitOK) 
+							                     : CLRBIT(fResultFlags[aidx], kFFactorFitOK);  }
+  void   SetBlindPixelFitOK   ( const Int_t  idx, const Bool_t b=kTRUE ) { b ? SETBIT(fBlindPixelFlags[idx], kBlindPixelFitOK) 
+							                     : CLRBIT(fBlindPixelFlags[idx], kBlindPixelFitOK); }
+  void   SetBlindPixelPedFitOK( const Int_t  idx, const Bool_t b=kTRUE ) { b ? SETBIT(fBlindPixelFlags[idx], kBlindPixelPedFitOK) 
+								             : CLRBIT(fBlindPixelFlags[idx], kBlindPixelPedFitOK); }
+  void   SetPINDiodeFitOK     ( const Int_t  idx, const Bool_t b=kTRUE ) { b ? SETBIT(fPINDiodeFlags[idx], kPINDiodeFitOK) 
+							                     : CLRBIT(fPINDiodeFlags[idx], kPINDiodeFitOK); }
+
+  Int_t  PreProcess (MParList *pList);
+  Bool_t ReInit     (MParList *pList); 
+  Int_t  Process    ();
+  Int_t  PostProcess();
+
+public:
+
+  MCalibrationChargeCalc(const char *name=NULL, const char *title=NULL);
+
+  void Clear(const Option_t *o="");
+
+  Bool_t IsDebug() const   {  return TESTBIT(fFlags,kDebug); }
+  
+  void SetChargeLimit       ( const Float_t f=fgChargeLimit            ) { fChargeLimit       = f;     }
+  void SetChargeErrLimit    ( const Float_t f=fgChargeErrLimit         ) { fChargeErrLimit    = f;     }
+  void SetChargeRelErrLimit ( const Float_t f=fgChargeRelErrLimit      ) { fChargeRelErrLimit = f;     }
+  void SetDebug             ( const Bool_t  b=kTRUE                    ) { b ? SETBIT(fFlags, kDebug) 
+									     : CLRBIT(fFlags, kDebug); }
+  void SetFFactorErrLimit   ( const Float_t f=fgFFactorErrLimit        ) { fFFactorErrLimit   = f;     }
+  void SetLambdaErrLimit    ( const Float_t f=fgLambdaErrLimit         ) { fLambdaErrLimit    = f;     }
+  void SetLambdaCheckLimit  ( const Float_t f=fgLambdaCheckLimit       ) { fLambdaCheckLimit  = f;     }
+  void SetOutputPath        ( TString path="."                   );
+  void SetOutputFile        ( TString file="ChargeCalibStat.txt" );
+  void SetPheErrLimit       ( const Float_t f=fgPheErrLimit            ) { fPheErrLimit       = f;     }  
+  void SetPulserColor       ( const MCalibrationCam::PulserColor_t col ) { fPulserColor       = col;   }
+
+
+  ClassDef(MCalibrationChargeCalc, 1)   // Task calculating Calibration Containers and Quantum Efficiencies
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationChargeCam.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationChargeCam.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationChargeCam.cc	(revision 9661)
@@ -0,0 +1,573 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug   11/2003 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+/////////////////////////////////////////////////////////////////////////////
+//                                                               
+// MCalibrationChargeCam                                               
+//                                                               
+// Storage container for charge calibration results from the signal distribution 
+// fits (see MHCalibrationChargeCam and MHCalibrationChargePix), the calculation 
+// of reduced sigmas and number of photo-electrons (this class) and conversion 
+// factors sum FADC slices to photo-electrons (see MCalibrationChargeCalc)
+//
+// Individual pixels have to be cast when retrieved e.g.:
+// MCalibrationChargePix &avpix = (MCalibrationChargePix&)(*fChargeCam)[i]
+// 
+// Averaged values over one whole area index (e.g. inner or outer pixels for 
+// the MAGIC camera), can be retrieved via: 
+// MCalibrationChargePix &avpix = (MCalibrationChargePix&)fChargeCam->GetAverageArea(i)
+//
+// Averaged values over one whole camera sector can be retrieved via: 
+// MCalibrationChargePix &avpix = (MCalibrationChargePix&)fChargeCam->GetAverageSector(i)
+//
+// Note the averageing has been done on an event-by-event basis. Resulting 
+// Sigma's of the Gauss fit have been multiplied with the square root of the number 
+// of involved pixels in order to make a direct comparison possible with the mean of 
+// sigmas. 
+//
+// Final numbers of uncalibrated or unreliable pixels can be retrieved via the commands:
+// GetNumUncalibrated(aidx) and GetNumUnreliable(aidx) where aidx is the area index (0 for 
+// inner and 1 for outer pixels in the MAGIC camera).
+//
+// The following "calibration" constants are used for the calibration of each pixel 
+// (see MCalibrate):
+//
+// - MCalibrationQEPix::GetMeanConvFADC2Phe(): The mean conversion factor from the 
+//   summed FADC slices to the number of photo-electrons (in first order independent 
+//   on colour and intensity)
+// - MCalibrationQEPix::GetMeanFFactorFADC2Phot(): The mean F-Factor of the total  
+//   readout chain dividing the signal to noise of the incoming number of photons 
+//   (= sqrt(number photons)) by the signal to noise of the outgoing summed FADC slices 
+//   signal (= MCalibrationPix::GetMean() / MCalibrationChargePix::GetRSigma() )
+//
+// The following calibration constants can be retrieved directly from this class:
+//
+// - GetConversionFactorFFactor    ( Int_t idx, Float_t &mean, Float_t &err, Float_t &sigma );
+//
+// where: 
+// - idx is the pixel software ID
+// - "mean" is the mean conversion constant, to be multiplied with the retrieved signal 
+//   in order to get a calibrated number of PHOTONS. 
+// - "err" is the pure statistical uncertainty about the MEAN
+// - "sigma", if mulitplied with the square root of signal, gives the approximate sigma of the 
+//   retrieved mean number of incident Cherenkov photons.
+//
+// Note, Conversion is ALWAYS (included the F-Factor method!) from summed FADC slices to PHOTONS.
+//
+// See also: MCalibrationChargePix, MCalibrationChargeCalc, MCalibrationQECam
+//           MHCalibrationChargePix, MHCalibrationChargeCam              
+//           MCalibrationChargeBlindPix, MCalibrationChargePINDiode
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCalibrationChargeCam.h"
+#include "MCalibrationCam.h"
+
+#include <TClonesArray.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MGeomCam.h"
+#include "MGeomPix.h"
+
+#include "MBadPixelsCam.h"
+#include "MBadPixelsPix.h"
+
+#include "MCalibrationChargePix.h"
+#include "MCalibrationChargeBlindPix.h"
+#include "MCalibrationChargePINDiode.h"
+
+ClassImp(MCalibrationChargeCam);
+
+using namespace std;
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+// Sets all pointers to 0
+// 
+// Creates a TClonesArray of MCalibrationChargePix containers, initialized to 1 entry, destinated 
+// to hold one container per pixel. Later, a call to MCalibrationChargeCam::InitSize() 
+// has to be performed (in MGeomApply). 
+//
+// Creates a TClonesArray of MCalibrationChargePix containers, initialized to 1 entry, destinated 
+// to hold one container per pixel AREA. Later, a call to MCalibrationChargeCam::InitAreas() 
+// has to be performed (in MGeomApply). 
+//
+// Creates a TClonesArray of MCalibrationChargePix containers, initialized to 1 entry, destinated
+// to hold one container per camera SECTOR. Later, a call to MCalibrationChargeCam::InitSectors() 
+// has to be performed (in MGeomApply). 
+//
+// Calls:
+// - Clear()
+//
+MCalibrationChargeCam::MCalibrationChargeCam(const char *name, const char *title)
+{
+  fName  = name  ? name  : "MCalibrationChargeCam";
+  fTitle = title ? title : "Storage container for the Calibration Information in the camera";
+  
+  fPixels           = new TClonesArray("MCalibrationChargePix",1);
+  fAverageAreas     = new TClonesArray("MCalibrationChargePix",1);
+  fAverageSectors   = new TClonesArray("MCalibrationChargePix",1);
+  
+  Clear();
+}
+
+
+// --------------------------------------
+//
+// Sets all variable to 0.
+// Sets all flags to kFALSE
+// Calls MCalibrationCam::Clear()
+//
+void MCalibrationChargeCam::Clear(Option_t *o)
+{
+
+  SetFFactorMethodValid    ( kFALSE );
+
+  fNumPhotonsBlindPixelMethod    = 0.; 
+  fNumPhotonsFFactorMethod       = 0.; 
+  fNumPhotonsPINDiodeMethod      = 0.; 
+  fNumPhotonsBlindPixelMethodErr = 0.; 
+  fNumPhotonsFFactorMethodErr    = 0.;  
+  fNumPhotonsPINDiodeMethodErr   = 0.;  
+
+  MCalibrationCam::Clear();
+
+  return;
+}
+
+// -------------------------------------------------------------------
+//
+// Calls:
+// - MCalibrationCam::Init()
+//
+void MCalibrationChargeCam::Init(const MGeomCam &geom)
+{
+  MCalibrationCam::Init(geom);
+}
+
+// -----------------------------------------------
+//
+// Sets the kFFactorMethodValid bit from outside
+//
+void MCalibrationChargeCam::SetFFactorMethodValid(const Bool_t b)
+{
+    b ? SETBIT(fFlags, kFFactorMethodValid) : CLRBIT(fFlags, kFFactorMethodValid); 
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Test bit kFFactorMethodValid
+//
+Bool_t  MCalibrationChargeCam::IsFFactorMethodValid()   const
+{
+  return TESTBIT(fFlags,kFFactorMethodValid);
+}
+
+// --------------------------------------------------------------------------
+//
+// Print first the well fitted pixels 
+// and then the ones which are not FitValid
+//
+void MCalibrationChargeCam::Print(Option_t *o) const
+{
+
+  *fLog << all << GetDescriptor() << ":" << endl;
+  int id = 0;
+  
+  *fLog << all << "Calibrated pixels:" << endl;
+  *fLog << all << endl;
+
+  TIter Next(fPixels);
+  MCalibrationChargePix *pix;
+  while ((pix=(MCalibrationChargePix*)Next()))
+    {
+      
+      if (!pix->IsExcluded()) 
+	{                            
+
+          *fLog << all 
+                << Form("%s%3i","Pixel: ",pix->GetPixId())
+                << Form("%s%4.2f%s%4.2f","  Ped.Rms: ",pix->GetPedRms(),"+-",pix->GetPedRmsErr())
+		<< Form("%s%4.2f%s%4.2f","  Charge: " ,pix->GetConvertedMean(),"+-",pix->GetConvertedSigma())
+		<< Form("%s%4.2f%s%4.2f","  Red.Sigma: ",pix->GetConvertedRSigma(),"+-",pix->GetConvertedRSigmaErr())
+		<< Form("%s%4.2f%s%4.2f","  Num.Phes: ",pix->GetPheFFactorMethod(),"+-",pix->GetPheFFactorMethodErr()) 
+		<< Form("%s%4.2f%s%4.2f","  Conv.FADC2Phe: ",pix->GetMeanConvFADC2Phe(),"+-",pix->GetMeanConvFADC2PheErr())
+                << " Saturated? :" << pix->IsHiGainSaturation() 
+		<< endl;
+          id++;
+	}
+    }
+  
+  *fLog << all << id << " pixels" << endl;
+  id = 0;
+  
+   
+  *fLog << all << endl;
+  *fLog << all << "Excluded pixels:" << endl;
+  *fLog << all << endl;
+  
+  id = 0;
+
+  TIter Next4(fPixels);
+  while ((pix=(MCalibrationChargePix*)Next4()))
+  {
+      if (pix->IsExcluded())
+      {
+        *fLog << all << pix->GetPixId() << " ";
+        id++;
+
+        if (!(id % 25))
+          *fLog << endl;
+      }
+  }
+  
+  *fLog << endl;
+  *fLog << all << id << " Excluded pixels " << endl;
+  *fLog << endl;
+
+  *fLog << all << endl;
+  *fLog << all << "Averaged Areas:" << endl;
+  *fLog << all << endl;
+
+  TIter Next5(fAverageAreas);
+  while ((pix=(MCalibrationChargePix*)Next5()))
+  {
+    *fLog << all << Form("%s%3i","Area Idx: ",pix->GetPixId())
+          << "   Ped.  Rms: "            << pix->GetPedRms()        << " +- " << pix->GetPedRmsErr() 
+          << "   Mean signal: "          << pix->GetMean()    << " +- " << pix->GetMeanErr() 
+          << "   Sigma signal: "         << pix->GetSigma()    << " +- "<< pix->GetSigmaErr() 
+          << "   Reduced Sigma: "        << pix->GetRSigma() 
+          << "   Nr Phe's: "             << pix->GetPheFFactorMethod() 
+          << endl;
+  }
+
+  *fLog << all << endl;
+  *fLog << all << "Averaged Sectors:" << endl;
+  *fLog << all << endl;
+
+  TIter Next6(fAverageSectors);
+  while ((pix=(MCalibrationChargePix*)Next6()))
+  {
+    *fLog << all << Form("%s%3i","Sector: ",pix->GetPixId())
+          << "   Ped.  Rms: "            << pix->GetPedRms()        << " +- " << pix->GetPedRmsErr() 
+          << "   Mean signal: "          << pix->GetMean()    << " +- " << pix->GetMeanErr() 
+          << "   Sigma signal: "         << pix->GetSigma()    << " +- "<< pix->GetSigmaErr() 
+          << "   Reduced Sigma: "        << pix->GetRSigma() 
+          << "   Nr Phe's: "             << pix->GetPheFFactorMethod() 
+          << endl;
+  }
+  *fLog << all << endl;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// The types are as follows:
+// 
+// Fitted values:
+// ============== 
+//
+// 0: Fitted Charge                              (see MCalibrationPix::GetMean())
+// 1: Error of fitted Charge                     (see MCalibrationPix::GetMeanErr())
+// 2: Sigma of fitted Charge                     (see MCalibrationPix::GetSigma())
+// 3: Error of Sigma of fitted Charge            (see MCalibrationPix::GetSigmaErr())
+//
+// Useful variables derived from the fit results:
+// =============================================
+//
+// 4: Probability Gauss fit Charge distribution  (see MCalibrationPix::GetProb())
+// 5: Reduced Sigma of fitted Charge             (see MCalibrationChargePix::GetRSigma())
+// 6: Error Reduced Sigma of fitted Charge       (see MCalibrationChargePix::GetRSigmaErr())
+// 7: Reduced Sigma per Charge                   (see MCalibrationChargePix::GetRSigmaPerCharge())
+// 8: Error of Reduced Sigma per Charge          (see MCalibrationChargePix::GetRSigmaPerChargeErr())
+//
+// Results of the F-Factor calibration Method:
+// ===========================================
+//
+//  9: Nr. Photo-electrons from F-Factor Method  (see MCalibrationChargePix::GetPheFFactorMethod())
+// 10: Error Nr. Photo-el. from F-Factor Method  (see MCalibrationChargePix::GetPheFFactorMethodErr())
+// 11: Conversion factor   from F-Factor Method  (see MCalibrationChargePix::GetMeanConvFADC2Phe()
+// 12: Error conv. factor  from F-Factor Method  (see MCalibrationChargePix::GetMeanConvFADC2PheErr()
+// 13: Overall F-Factor    from F-Factor Method  (see MCalibrationChargePix::GetMeanFFactorFADC2Phot()
+// 14: Error F-Factor      from F-Factor Method  (see MCalibrationChargePix::GetMeanFFactorFADC2PhotErr()
+// 15: Pixels valid calibration F-Factor-Method  (see MCalibrationChargePix::IsFFactorMethodValid())           
+//
+// Results of the Low-Gain vs. High-Gain Conversion:
+// =================================================
+//
+// 16: Mean Signal Hi-Gain / Mean Signal Lo-Gain (see MCalibrationPix::GetHiLoMeansDivided())
+// 17: Error Signal High-Gain / Signal Low Gain  (see MCalibrationPix::GetHiLoMeansDividedErr())
+// 18: Sigma High-Gain / Sigma Low Gain          (see MCalibrationPix::GetHiLoSigmasDivided())
+// 19: Error Sigma High-Gain / Sigma Low Gain    (see MCalibrationPix::GetHiLoSigmasDividedErr())
+//                                                
+// Localized defects:                             
+// ==================
+//
+// 20: Excluded Pixels
+// 21: Number of pickup   events in the Hi Gain  (see MCalibrationPix::GetHiGainNumPickup())
+// 22: Number of pickup   events in the Lo Gain  (see MCalibrationPix::GetLoGainNumPickup())
+// 23: Number of blackout events in the Hi Gain  (see MCalibrationPix::GetHiGainNumBlackout())
+// 24: Number of blackout events in the Lo Gain  (see MCalibrationPix::GetLoGainNumBlackout())
+//
+// Other classifications of pixels:
+// ================================
+//
+// 25: Pixels with saturated High-Gain           (see MCalibrationPix::IsHiGainSaturation())
+//
+// Calculated absolute arrival times (very low precision!):
+// ========================================================
+//
+// 26: Absolute Arrival time of the signal       (see MCalibrationChargePix::GetAbsTimeMean())
+// 27: RMS Ab.  Arrival time of the signal       (see MCalibrationChargePix::GetAbsTimeRms())
+//
+// Used Pedestals:
+// ===============
+//
+// 28: Pedestal for entire signal extr. range    (see MCalibrationChargePix::Ped())
+// 29: Error Pedestal entire signal extr. range  (see MCalibrationChargePix::PedErr())
+// 30: Ped. RMS entire signal extraction range   (see MCalibrationChargePix::PedRms())
+// 31: Error Ped. RMS entire signal extr. range  (see MCalibrationChargePix::PedRmsErr())
+//
+Bool_t MCalibrationChargeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
+{
+
+  if (idx > GetSize())
+    return kFALSE;
+
+  Float_t area = cam[idx].GetA();
+
+ if (area == 0)
+    return kFALSE;
+
+ MCalibrationChargePix &pix = (MCalibrationChargePix&)(*this)[idx];
+
+  switch (type)
+    {
+    case 0:
+      if (pix.IsExcluded())
+        return kFALSE;
+      val = pix.GetMean();
+      break;
+    case 1:
+      if (pix.IsExcluded())
+        return kFALSE;
+      val = pix.GetMeanErr();
+      break;
+    case 2:
+      if (pix.IsExcluded())
+        return kFALSE;
+      val = pix.GetSigma();
+      break;
+    case 3:
+      if (pix.IsExcluded())
+        return kFALSE;
+      val = pix.GetSigmaErr();
+      break;
+    case 4:
+      if (pix.IsExcluded())
+        return kFALSE;
+      val = pix.GetProb();
+      break;
+    case 5:
+      if (pix.IsExcluded())
+        return kFALSE;
+      if (pix.GetRSigma() == -1.)
+	  return kFALSE;
+      val = pix.GetRSigma();
+      break;
+    case 6:
+      if (pix.IsExcluded())
+        return kFALSE;    
+      if (pix.GetRSigma() == -1.)
+	  return kFALSE;
+      val = pix.GetRSigmaErr();
+      break;
+    case 7:
+      if (pix.IsExcluded())
+        return kFALSE;
+      val = pix.GetRSigmaPerCharge();
+      break;
+    case 8:
+      if (pix.IsExcluded())
+        return kFALSE;
+      val =  pix.GetRSigmaPerChargeErr();
+      break;
+    case 9:
+      if (pix.IsExcluded() || !pix.IsFFactorMethodValid())
+        return kFALSE;
+      val = pix.GetPheFFactorMethod();
+      break;
+    case 10:
+      if (pix.IsExcluded() || !pix.IsFFactorMethodValid())
+        return kFALSE;
+      val = pix.GetPheFFactorMethodErr();
+      break;
+    case 11:
+      if (pix.IsExcluded() || !pix.IsFFactorMethodValid())
+        return kFALSE;
+      val = pix.GetMeanConvFADC2Phe();
+      break;
+    case 12:
+      if (pix.IsExcluded() || !pix.IsFFactorMethodValid())
+        return kFALSE;
+      val = pix.GetMeanConvFADC2PheErr();
+      break;
+    case 13:
+      if (pix.IsExcluded() || !pix.IsFFactorMethodValid())
+        return kFALSE;
+      val = pix.GetMeanFFactorFADC2Phot();
+      break;
+    case 14:
+      if (pix.IsExcluded() || !pix.IsFFactorMethodValid())
+        return kFALSE;
+      val = pix.GetMeanFFactorFADC2PhotErr();
+      break;
+    case 15:
+      if (pix.IsExcluded())
+        return kFALSE;
+      if (pix.IsFFactorMethodValid())
+        val = 1;
+      else
+        return kFALSE;
+      break;
+    case 16:
+      if (pix.IsExcluded())
+        return kFALSE;
+      val = pix.GetHiLoMeansDivided();
+      break;
+    case 17:
+      if (pix.IsExcluded())
+        return kFALSE;
+      val = pix.GetHiLoMeansDividedErr();
+      break;
+    case 18:
+      if (pix.IsExcluded())
+        return kFALSE;
+      val = pix.GetHiLoSigmasDivided();
+      break;
+    case 19:
+      if (pix.IsExcluded())
+        return kFALSE;
+      val = pix.GetHiLoSigmasDividedErr();
+      break;
+    case 20:
+      if (pix.IsExcluded())
+        val = 1.;
+      else
+        return kFALSE;
+      break;
+    case 21:
+      if (pix.IsExcluded())
+        return kFALSE;
+      val = pix.GetHiGainNumPickup();
+      break;
+    case 22:
+      if (pix.IsExcluded())
+        return kFALSE;
+      val = pix.GetLoGainNumPickup();
+      break;
+    case 23:
+      if (pix.IsExcluded())
+        return kFALSE;
+      val = pix.GetHiGainNumBlackout();
+      break;
+    case 24:
+      if (pix.IsExcluded())
+        return kFALSE;
+      val = pix.GetLoGainNumBlackout();
+      break;
+    case 25:
+      if (pix.IsExcluded())
+        return kFALSE;
+      val = pix.IsHiGainSaturation();
+      break;
+    case 26:
+      if (pix.IsExcluded())
+        return kFALSE;
+      val = pix.GetAbsTimeMean();
+      break;
+    case 27:
+      if (pix.IsExcluded())
+        return kFALSE;
+      val = pix.GetAbsTimeRms();
+      break;
+    case 28:
+      if (pix.IsExcluded())
+        return kFALSE;
+      val = pix.GetPed();
+      break;
+    case 29:
+      if (pix.IsExcluded())
+        return kFALSE;
+      val = pix.GetPedErr();
+      break;
+    case 30:
+      if (pix.IsExcluded())
+        return kFALSE;
+      val = pix.GetPedRms();
+      break;
+    case 31:
+      if (pix.IsExcluded())
+        return kFALSE;
+      val = pix.GetPedErr()/2.;
+      break;
+    default:
+      return kFALSE;
+    }
+
+  return val!=-1.;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calls MCalibrationChargePix::DrawClone()
+//
+void MCalibrationChargeCam::DrawPixelContent(Int_t idx) const
+{
+  MCalibrationChargePix &pix = (MCalibrationChargePix&)(*this)[idx];
+  pix.DrawClone();
+}
+
+
+
+Bool_t MCalibrationChargeCam::GetConversionFactorFFactor(Int_t ipx, Float_t &mean, Float_t &err, Float_t &ffactor)
+{
+
+  MCalibrationChargePix &pix = (MCalibrationChargePix&)(*this)[ipx];
+
+  Float_t conv = pix.GetMeanConvFADC2Phe();
+
+  if (conv < 0.)
+    return kFALSE;
+
+  mean    = conv;
+  err     = pix.GetMeanConvFADC2PheErr();
+  ffactor = pix.GetMeanFFactorFADC2Phot();
+
+  return kTRUE;
+}
+
+
Index: /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationChargeCam.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationChargeCam.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationChargeCam.h	(revision 9661)
@@ -0,0 +1,66 @@
+#ifndef MARS_MCalibrationChargeCam
+#define MARS_MCalibrationChargeCam
+
+#ifndef MARS_MCalibrationCam
+#include "MCalibrationCam.h"
+#endif
+
+#ifndef ROOT_TArrayI
+#include "TArrayI.h"
+#endif
+
+class MCalibrationChargeCam : public MCalibrationCam
+{
+private:
+  
+  Byte_t  fFlags;                         // Bit-field to hold the flags
+
+  Float_t fNumPhotonsBlindPixelMethod;    // Average nr. photons from Blind Pixel Method (Inner Pixel)
+  Float_t fNumPhotonsFFactorMethod;       // Average nr. photons from F-Factor Method (Inner Pixel)
+  Float_t fNumPhotonsPINDiodeMethod;      // Average nr. photons from PIN Diode Method (Inner Pixel)
+  Float_t fNumPhotonsBlindPixelMethodErr; // Error av. nr. photons from Blind Pixel Method
+  Float_t fNumPhotonsFFactorMethodErr;    // Error av. nr. photons from F-Factor Method
+  Float_t fNumPhotonsPINDiodeMethodErr;   // Error av. nr. photons from PIN Diode Method
+  
+  enum  { kFFactorMethodValid };
+
+public:
+
+  MCalibrationChargeCam(const char *name=NULL, const char *title=NULL);
+  
+  void   Clear ( Option_t *o="" );
+  
+  // Draws
+  void   DrawPixelContent(Int_t num)   const;    
+
+  // Getters
+  Bool_t  GetConversionFactorFFactor( Int_t ipx, Float_t &mean, Float_t &err, Float_t &ffactor );
+  Bool_t  GetPixelContent           ( Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
+
+  Float_t GetNumPhotonsBlindPixelMethod   () const { return fNumPhotonsBlindPixelMethod;    }
+  Float_t GetNumPhotonsFFactorMethod      () const { return fNumPhotonsFFactorMethod;       }     
+  Float_t GetNumPhotonsPINDiodeMethod     () const { return fNumPhotonsPINDiodeMethod;      }    
+  Float_t GetNumPhotonsBlindPixelMethodErr() const { return fNumPhotonsBlindPixelMethodErr; }
+  Float_t GetNumPhotonsFFactorMethodErr   () const { return fNumPhotonsFFactorMethodErr;    }     
+  Float_t GetNumPhotonsPINDiodeMethodErr  () const { return fNumPhotonsPINDiodeMethodErr;   }    
+  Bool_t  IsFFactorMethodValid            () const;
+
+  // Inits
+  void  Init                   ( const MGeomCam &geom         );
+  
+  // Prints
+  void   Print(Option_t *o="")         const;
+
+  // Setters   
+  void  SetFFactorMethodValid ( const Bool_t b=kTRUE );
+  void  SetNumPhotonsBlindPixelMethod ( const Float_t f )     { fNumPhotonsBlindPixelMethod    = f; } 
+  void  SetNumPhotonsFFactorMethod   ( const Float_t f )     { fNumPhotonsFFactorMethod       = f; }      
+  void  SetNumPhotonsPINDiodeMethod  ( const Float_t f )     { fNumPhotonsPINDiodeMethod      = f; }   
+  void  SetNumPhotonsBlindPixelMethodErr ( const Float_t f )  { fNumPhotonsBlindPixelMethodErr = f; } 
+  void  SetNumPhotonsFFactorMethodErr   ( const Float_t f )  { fNumPhotonsFFactorMethodErr    = f; }      
+  void  SetNumPhotonsPINDiodeMethodErr  ( const Float_t f )  { fNumPhotonsPINDiodeMethodErr   = f; }   
+  
+  ClassDef(MCalibrationChargeCam, 4) // Container Charge Calibration Results Camera
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationChargePINDiode.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationChargePINDiode.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationChargePINDiode.cc	(revision 9661)
@@ -0,0 +1,434 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug   02/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                     
+// MCalibrationChargePINDiode       
+//                                  
+// Storage container of the fit results of the PIN Diode signal 
+// (from MHCalibrationChargePINDiode). The PIN Diode is not yet working, so 
+// is the documentation for the moment.
+//
+// The Flux is calculated in photons per mm^2 in the camera plane. 
+//
+// Currently, the following numbers are implemented:
+//
+// Area of PIN Diode   Ap: 100.000 +- 10 mm^2 
+//
+// Ratio of areas: 
+//
+// Distance of PIN Diode to pulser D1:   1.5  +- 0.3 m
+// Distance of Inner Pixel to pulser D2: 18.0 +- 0.5 m
+//
+//                          D1*D1
+// gkSolidAngleRatio   =   -------- = 0.00007
+//                         Ap*D2*D2
+//
+// gkSolidAngleRatioErr = 0.00002
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCalibrationChargePINDiode.h"
+#include "MCalibrationChargePix.h"
+
+#include "MCalibrationCam.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MCalibrationChargePINDiode);
+
+using namespace std;
+
+const Float_t MCalibrationChargePINDiode::fgChargeToPhotons    = -1.; 
+const Float_t MCalibrationChargePINDiode::fgChargeToPhotonsErr = -1.; 
+const Float_t MCalibrationChargePINDiode::gkSolidAngleRatio      = 0.00007;
+const Float_t MCalibrationChargePINDiode::gkSolidAngleRatioErr   = 0.00002;
+const Float_t MCalibrationChargePINDiode::gkPINDiodeQEGreen    = -1.0;
+const Float_t MCalibrationChargePINDiode::gkPINDiodeQEBlue     = -1.0;
+const Float_t MCalibrationChargePINDiode::gkPINDiodeQEUV       = -1.0;
+const Float_t MCalibrationChargePINDiode::gkPINDiodeQECT1      = -1.0;
+const Float_t MCalibrationChargePINDiode::gkPINDiodeQEGreenErr = -1.0;
+const Float_t MCalibrationChargePINDiode::gkPINDiodeQEBlueErr  = -1.0;
+const Float_t MCalibrationChargePINDiode::gkPINDiodeQEUVErr    = -1.0;
+const Float_t MCalibrationChargePINDiode::gkPINDiodeQECT1Err   = -1.0;
+// --------------------------------------------------------------------------
+//
+// Default Constructor. 
+//
+// Sets:
+// - fCalibFlags to 0
+// - fChargeToPhotons to fgChargeToPhotons
+// - fChargeToPhotonsVar to fgChargeToPhotonsErr*fgChargeToPhotonsErr
+// 
+// Calls:
+// - Clear()
+//
+MCalibrationChargePINDiode::MCalibrationChargePINDiode(const char *name, const char *title)
+    : fCalibFlags(0)
+{
+
+  fName  = name  ? name  : "MCalibrationChargePINDiode";
+  fTitle = title ? title : "Container of the fit results of MHCalibrationChargePINDiode";
+
+  SetChargeToPhotons();
+  SetChargeToPhotonsErr();
+
+  Clear();
+
+}
+
+// ------------------------------------------------------------------------
+//
+// Sets:
+// - all flags to kFALSE
+// - all variables to -1.
+//
+// Calls: 
+// - MCalibrationPix::Clear()
+//
+void MCalibrationChargePINDiode::Clear(Option_t *o)
+{
+
+  SetOscillating        ( kFALSE );
+  SetChargeFitValid     ( kFALSE );
+  SetTimeFitValid       ( kFALSE );
+  SetColor              ( MCalibrationCam::kNONE);
+    
+  fAbsTimeMean              =  -1.;
+  fAbsTimeRms               =  -1.;
+  fFluxOutsidePlexiglass    =  -1.;  
+  fFluxOutsidePlexiglassVar =  -1.;
+  fNumPhotons               =  -1.;
+  fNumPhotonsVar            =  -1.;
+  fPed                      =  -1.;
+  fPedRms                   =  -1.;
+  fRmsChargeMean            =  -1.;
+  fRmsChargeMeanErr         =  -1.;
+  fRmsChargeSigma           =  -1.;  
+  fRmsChargeSigmaErr        =  -1.;
+
+  MCalibrationPix::Clear();
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Set the pedestals from outside
+//
+void MCalibrationChargePINDiode::SetPedestal(Float_t ped, Float_t pedrms)
+{
+
+  fPed    = ped;    
+  fPedRms = pedrms;
+  
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the Oscillating Bit from outside 
+//
+void  MCalibrationChargePINDiode::SetOscillating( const Bool_t b)
+{
+    b ? SETBIT(fCalibFlags,kOscillating) : CLRBIT(fCalibFlags,kOscillating);
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Set the ChargeFitValid Bit from outside 
+//
+void MCalibrationChargePINDiode::SetChargeFitValid(Bool_t b )    
+{ 
+  b ?  SETBIT(fCalibFlags, kChargeFitValid) : CLRBIT(fCalibFlags, kChargeFitValid); 
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the TimeFitValid Bit from outside 
+//
+void MCalibrationChargePINDiode::SetTimeFitValid(Bool_t b )    
+{ 
+  b ?  SETBIT(fCalibFlags, kTimeFitValid) : CLRBIT(fCalibFlags, kTimeFitValid); 
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the FluxOutsidePlexiglassAvailable Bit from outside 
+//
+void MCalibrationChargePINDiode::SetFluxOutsidePlexiglassAvailable (const Bool_t b)
+{
+  b ?  SETBIT(fCalibFlags, kFluxOutsidePlexiglassAvailable) 
+    : CLRBIT(fCalibFlags, kFluxOutsidePlexiglassAvailable); 
+}
+
+// --------------------------------------------------------------------------
+//
+// Return -1 if fFluxOutsidePlexiglassVar is smaller than 0.
+// Return square root of fFluxOutsidePlexiglassVar
+// 
+Float_t MCalibrationChargePINDiode::GetFluxOutsidePlexiglassErr() const
+{
+  if (fFluxOutsidePlexiglassVar < 0.)
+    return -1.;
+  
+  return TMath::Sqrt(fFluxOutsidePlexiglassVar);
+}
+
+// --------------------------------------------------------------------------
+//
+// Return -1 if fFluxOutsidePlexiglassVar is smaller than 0.
+// Return -1 if fFluxOutsidePlexiglass is 0.
+// Return  fFluxOutsidePlexiglassVar / fFluxOutsidePlexiglass^2
+// 
+Float_t MCalibrationChargePINDiode::GetFluxOutsidePlexiglassRelVar() const
+{
+  if (fFluxOutsidePlexiglassVar < 0.)
+    return -1.;
+  
+  if (fFluxOutsidePlexiglass == 0.)
+    return -1.;
+  
+  return fFluxOutsidePlexiglassVar / (fFluxOutsidePlexiglass * fFluxOutsidePlexiglass );
+}
+
+// --------------------------------------------------------------------------
+//
+// Return -1 if fNumPhotonsVar is smaller than 0.
+// Return square root of fNumPhotonsVar
+// 
+Float_t MCalibrationChargePINDiode::GetNumPhotonsErr() const
+{
+  if (fNumPhotonsVar < 0.)
+    return -1.;
+  
+  return TMath::Sqrt(fNumPhotonsVar);
+}
+
+// --------------------------------------------------------------------------
+//
+// Return -1 if fNumPhotonsVar is smaller than 0.
+// Return -1 if fNumPhotons    is 0.
+// Return fNumPhotonsVar / (fNumPhotons^2 )
+// 
+Float_t MCalibrationChargePINDiode::GetNumPhotonsRelVar() const
+{
+  if (fNumPhotonsVar < 0.)
+    return -1.;
+  
+  if (fNumPhotons  == 0.)
+    return -1.;
+  
+  return  fNumPhotonsVar / fNumPhotons / fNumPhotons ;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Return -1 if gkPINDiodeQEGreenErr is smaller than 0.
+// Return -1 if gkPINDiodeQEGreen    is 0.
+// Return gkPINDiodeQEGreenErr^2 / (gkPINDiodeQEGreen^2 )
+// 
+const Float_t MCalibrationChargePINDiode::GetPINDiodeQEGreenRelVar() const
+{
+  if (gkPINDiodeQEGreenErr < 0.)
+    return -1.;
+  
+  if (gkPINDiodeQEGreen  == 0.)
+    return -1.;
+  
+  return gkPINDiodeQEGreenErr * gkPINDiodeQEGreenErr / gkPINDiodeQEGreen / gkPINDiodeQEGreen ;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return -1 if gkPINDiodeQEBlueErr is smaller than 0.
+// Return -1 if gkPINDiodeQEBlue    is 0.
+// Return gkPINDiodeQEBlueErr^2 / gkPINDiodeQEBlue^2
+// 
+const Float_t MCalibrationChargePINDiode::GetPINDiodeQEBlueRelVar() const
+{
+  if (gkPINDiodeQEBlueErr < 0.)
+    return -1.;
+  
+  if (gkPINDiodeQEBlue  == 0.)
+    return -1.;
+  
+  return gkPINDiodeQEBlueErr * gkPINDiodeQEBlueErr / gkPINDiodeQEBlue / gkPINDiodeQEBlue ;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return -1 if gkPINDiodeQEUVErr is smaller than 0.
+// Return -1 if gkPINDiodeQEUV    is 0.
+// Return gkPINDiodeQEUVErr ^2 / gkPINDiodeQEUV^2 
+// 
+const Float_t MCalibrationChargePINDiode::GetPINDiodeQEUVRelVar() const
+{
+  if (gkPINDiodeQEUVErr < 0.)
+    return -1.;
+  
+  if (gkPINDiodeQEUV  == 0.)
+    return -1.;
+  
+  return gkPINDiodeQEUVErr * gkPINDiodeQEUVErr / gkPINDiodeQEUV / gkPINDiodeQEUV ;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return -1 if gkPINDiodeQECT1Err is smaller than 0.
+// Return -1 if gkPINDiodeQECT1    is 0.
+// Return gkPINDiodeQECT1Err ^2 / gkPINDiodeQECT1^2
+// 
+const Float_t MCalibrationChargePINDiode::GetPINDiodeQECT1RelVar() const
+{
+  if (gkPINDiodeQECT1Err < 0.)
+    return -1.;
+  
+  if (gkPINDiodeQECT1  == 0.)
+    return -1.;
+  
+  return gkPINDiodeQECT1Err * gkPINDiodeQECT1Err / gkPINDiodeQECT1 / gkPINDiodeQECT1 ;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return -1 if gkSolidAngleRatioErr is smaller than 0.
+// Return -1 if gkSolidAngleRatio    is 0.
+// Return gkSolidAngleRatioErr ^2 / gkSolidAngleRatio^2
+// 
+const Float_t MCalibrationChargePINDiode::GetSolidAngleRatioRelVar() const
+{
+  if (gkSolidAngleRatioErr < 0.)
+    return -1.;
+  
+  if (gkSolidAngleRatio  == 0.)
+    return -1.;
+  
+  return gkSolidAngleRatioErr * gkSolidAngleRatioErr / gkSolidAngleRatio / gkSolidAngleRatio ;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Test bit kChargeFitValid
+//
+Bool_t MCalibrationChargePINDiode::IsChargeFitValid() const 
+{
+  return TESTBIT(fCalibFlags, kChargeFitValid);  
+}
+
+// --------------------------------------------------------------------------
+//
+// Test bit kFluxOutsidePlexiglassAvailable
+//
+Bool_t  MCalibrationChargePINDiode::IsFluxOutsidePlexiglassAvailable()   const
+{
+  return TESTBIT(fFlags,kFluxOutsidePlexiglassAvailable);
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Test bit kTimeFitValid
+//
+Bool_t MCalibrationChargePINDiode::IsTimeFitValid()   const 
+{
+  return TESTBIT(fCalibFlags, kTimeFitValid);  
+}
+
+// --------------------------------------------------------------------------
+//
+// Test bit kOscillating
+//
+Bool_t MCalibrationChargePINDiode::IsOscillating()   const 
+{
+  return TESTBIT(fCalibFlags, kOscillating);  
+}
+
+// --------------------------------------------------------------------------
+//
+// Return kFALSE if IsChargeFitValid() is kFALSE
+//
+// Calculate fFluxOutsidePlexiglass with the formula:
+// - fFluxOutsidePlexiglass    = fNumPhotons*gkSolidAngleRatio / gkPINDiodeQE (of the corr. colour) 
+// - fFluxOutsidePlexiglassVar = sqrt( fNumPhotonsVar / ( fNumPhotons * fNumPhotons ) 
+//                             + ( gkSolidAngleRatioErr * gkSolidAngleRatioErr / gkSolidAngleRatio / gkSolidAngleRatio )
+//                             + ( gkPINDiodeQEErr * gkPINDiodeQEErr / gkPINDiodeQE / gkPINDiodeQE )
+//                               ) * fFluxOutsidePlexiglass * * fFluxOutsidePlexiglass
+//
+// If the fFluxOutsidePlexiglass is smaller than 0., return kFALSE
+// If the Variance is smaller than 0., return kFALSE
+//
+// SetFluxOutsidePlexiglassAvailable() and return kTRUE
+//
+Bool_t MCalibrationChargePINDiode::CalcFluxOutsidePlexiglass()
+{
+
+  if (IsChargeFitValid())
+    return kFALSE;
+  
+  //
+  // Start calculation of number of photons per mm^2 on an inner pixel:
+  // Correct for the distance between camera and PIN Diode and for different areas.
+  //
+  switch (fColor)
+    {
+    case MCalibrationCam::kGREEN:
+      fFluxOutsidePlexiglass    = fNumPhotons           * gkSolidAngleRatio           * gkPINDiodeQEGreen;
+      fFluxOutsidePlexiglassVar = GetNumPhotonsRelVar() + GetSolidAngleRatioRelVar()  + GetPINDiodeQEGreenRelVar();
+      break;
+    case MCalibrationCam::kBLUE:
+      fFluxOutsidePlexiglass    = fNumPhotons           * gkSolidAngleRatio           * gkPINDiodeQEBlue;
+      fFluxOutsidePlexiglassVar = GetNumPhotonsRelVar() + GetSolidAngleRatioRelVar()  + GetPINDiodeQEBlueRelVar();
+      break; 
+    case MCalibrationCam::kUV:
+      fFluxOutsidePlexiglass    = fNumPhotons           * gkSolidAngleRatio          * gkPINDiodeQEUV;
+      fFluxOutsidePlexiglassVar = GetNumPhotonsRelVar() + GetSolidAngleRatioRelVar() + GetPINDiodeQEUVRelVar();
+      break;
+    case MCalibrationCam::kCT1:
+    default:
+      fFluxOutsidePlexiglass    = fNumPhotons           * gkSolidAngleRatio          * gkPINDiodeQECT1;
+      fFluxOutsidePlexiglassVar = GetNumPhotonsRelVar() + GetSolidAngleRatioRelVar() + GetPINDiodeQECT1RelVar();
+      break;
+    }
+
+  //
+  // Finish calculation of errors -> convert from relative variance to absolute variance
+  //
+  fFluxOutsidePlexiglassVar *= fFluxOutsidePlexiglass * fFluxOutsidePlexiglass;
+
+  if (fFluxOutsidePlexiglass < 0.)
+      return kFALSE;
+
+  if (fFluxOutsidePlexiglassVar < 0.)
+      return kFALSE;
+
+  SetFluxOutsidePlexiglassAvailable();  
+
+  *fLog << inf << endl;
+  *fLog << inf << " Mean Photon flux [ph/mm^2] outside Plexiglass: " 
+        << Form("%5.3f%s%5.3f",fFluxOutsidePlexiglass," +- ",GetFluxOutsidePlexiglassErr()) << endl;
+
+  return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationChargePINDiode.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationChargePINDiode.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationChargePINDiode.h	(revision 9661)
@@ -0,0 +1,113 @@
+#ifndef MARS_MCalibrationChargePINDiode
+#define MARS_MCalibrationChargePINDiode
+
+#ifndef MARS_MCalibrationCam
+#include "MCalibrationCam.h"
+#endif
+
+#ifndef MARS_MCalibrationPix
+#include "MCalibrationPix.h"
+#endif
+
+class MCalibrationChargePINDiode : public MCalibrationPix
+{
+private:
+
+  static const Float_t fgChargeToPhotons;     //! Default for fChargeToPhotons
+  static const Float_t fgChargeToPhotonsErr;  //! Default for fChargeToPhotonsVar
+  static const Float_t gkPINDiodeQEGreen;     //! Quantum Efficiency at 520 nm
+  static const Float_t gkPINDiodeQEBlue;      //! Quantum Efficiency at 460 nm
+  static const Float_t gkPINDiodeQEUV;        //! Quantum Efficiency at 370 nm
+  static const Float_t gkPINDiodeQECT1;       //! Quantum Efficiency at 370 nm
+  static const Float_t gkPINDiodeQEGreenErr;  //! Uncertainty QE at 520 nm
+  static const Float_t gkPINDiodeQEBlueErr;   //! Uncertainty QE at 460 nm
+  static const Float_t gkPINDiodeQEUVErr;     //! Uncertainty QE at 370 nm
+  static const Float_t gkPINDiodeQECT1Err;    //! Uncertainty QE at 370 nmu
+  static const Float_t gkSolidAngleRatio;     //! Solid angles ratio PIN Diode - inner pixel
+  static const Float_t gkSolidAngleRatioErr;  //! Error solid angle ratio PIN Diode - inn. pix.
+
+  Float_t fAbsTimeMean;               // Mean Absolute Arrival Time
+  Float_t fAbsTimeRms;                // RMS Mean Absolute Arrival Time
+  Byte_t  fCalibFlags;                // Bit-field for the class-own bits
+  Float_t fChargeLimit;               // Limit (in units of PedRMS) for acceptance fitted mean charge
+  Float_t fChargeErrLimit;            // Limit (in units of PedRMS) for acceptance fitted charge sigma
+  Float_t fChargeRelErrLimit;         // Limit (in units of Error of fitted charge) for acceptance fitted mean  
+  Float_t fChargeToPhotons;           // Mean conv. PIN Diode charge to number of incident photons
+  Float_t fChargeToPhotonsVar;        // Variance of mean conv. PIN Diode charge to nr. incident photons
+  Float_t fNumPhotons;                // Number photons incidident on PIN Diode
+  Float_t fNumPhotonsVar;             // Variance nr. photons incid. on PIN Diode
+  Float_t fFluxOutsidePlexiglass;     // Mean number photons in INNER PIXEL outside plexiglass
+  Float_t fFluxOutsidePlexiglassVar;  // Error on nr. photons in INNER PIXEL outside plexiglass
+  Float_t fPed;                       // Mean pedestal (from MPedestalPix)
+  Float_t fPedRms;                    // Pedestal  RMS (from MPedestalPix)
+  Float_t fRmsChargeMean;             // Mean of RMS of summed FADC slices distribution 
+  Float_t fRmsChargeMeanErr;          // Error on Mean RMS summed FADC slices distribution 
+  Float_t fRmsChargeSigma;            // Sigma of RMS of summed FADC slices distribution    
+  Float_t fRmsChargeSigmaErr;         // Error on Sigma RMS summed FADC slices distribution 
+  MCalibrationCam::PulserColor_t fColor; // Colour of the pulsed LEDs
+
+  enum  { kOscillating,
+          kChargeFitValid, kTimeFitValid, 
+	  kFluxOutsidePlexiglassAvailable  }; // Possible bits to be set
+
+  const Float_t GetPINDiodeQEGreenRelVar() const; 
+  const Float_t GetPINDiodeQEBlueRelVar () const; 
+  const Float_t GetPINDiodeQEUVRelVar   () const; 
+  const Float_t GetPINDiodeQECT1RelVar  () const;
+  const Float_t GetSolidAngleRatioRelVar() const; 
+
+ public:
+
+  MCalibrationChargePINDiode(const char *name=NULL, const char *title=NULL);
+  ~MCalibrationChargePINDiode() {}
+  
+  void   Clear(Option_t *o="");
+  Bool_t CalcFluxOutsidePlexiglass();
+
+  // Getters
+  Float_t GetAbsTimeMean                  () const { return fAbsTimeMean;           }
+  Float_t GetAbsTimeRms                   () const { return fAbsTimeRms;            }
+  MCalibrationCam::PulserColor_t GetColor () const { return fColor;                 }
+  Float_t GetFluxOutsidePlexiglass        () const { return fFluxOutsidePlexiglass; }
+  Float_t GetFluxOutsidePlexiglassErr     () const;
+  Float_t GetFluxOutsidePlexiglassRelVar  () const;  
+  Float_t GetNumPhotons                   () const { return fNumPhotons;            } 
+  Float_t GetNumPhotonsErr                () const;
+  Float_t GetNumPhotonsRelVar             () const;
+  Float_t GetPed                          () const { return fPed;                   }
+  Float_t GetPedRms                       () const { return fPedRms;                }
+
+  Bool_t  IsChargeFitValid                () const;
+  Bool_t  IsTimeFitValid                  () const;
+  Bool_t  IsOscillating                   () const;
+  Bool_t  IsFluxOutsidePlexiglassAvailable() const;
+  
+  // Setters
+  void SetAbsTimeMean        ( const Float_t f      )                 { fAbsTimeMean        = f;   }
+  void SetAbsTimeRms         ( const Float_t f      )                 { fAbsTimeRms         = f;   }
+  void SetChargeToPhotons    ( const Float_t f=fgChargeToPhotons    ) { fChargeToPhotons    = f;   }  
+  void SetChargeToPhotonsErr ( const Float_t f=fgChargeToPhotonsErr ) { fChargeToPhotonsVar = f*f; }  
+  void SetColor              ( const MCalibrationCam::PulserColor_t color) { fColor = color;   }
+  void SetPedestal           (       Float_t ped, Float_t pedrms    );
+  void SetRmsChargeMean      ( const Float_t f      )                 { fRmsChargeMean      = f;   }
+  void SetRmsChargeMeanErr   ( const Float_t f      )                 { fRmsChargeMeanErr   = f;   }
+  void SetRmsChargeSigma     ( const Float_t f      )                 { fRmsChargeSigma     = f;   }
+  void SetRmsChargeSigmaErr  ( const Float_t f      )                 { fRmsChargeSigmaErr  = f;   }
+  void SetOscillating        ( const Bool_t b=kTRUE );
+  void SetChargeFitValid     ( const Bool_t b=kTRUE );
+  void SetTimeFitValid       ( const Bool_t b=kTRUE );
+  void SetFluxOutsidePlexiglassAvailable ( const Bool_t b = kTRUE );
+
+  ClassDef(MCalibrationChargePINDiode, 1)	// Container Charge Calibration Results PIN Diode
+};
+
+#endif   /* MARS_MCalibrationChargePINDiode */
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationChargePix.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationChargePix.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationChargePix.cc	(revision 9661)
@@ -0,0 +1,1050 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug   02/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+\* ======================================================================== */
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         
+// MCalibrationChargePix                                                   
+//                                                                         
+// Storage container of the calibrated Charge of one pixel.
+//                                                                         
+// The following values are initialized to meaningful values:
+//
+// - The Electronic Rms to 1.5 per FADC slice
+// - The uncertainty about the Electronic RMS to 0.3 per slice
+// - The F-Factor is assumed to have been measured in Munich to 1.13 - 1.17.
+//   with the Munich definition of the F-Factor, thus:
+//   F = Sigma(Out)/Mean(Out) * Mean(In)/Sigma(In)
+//   Mean F-Factor (gkFFactor)     = 1.15
+//   Error F-Factor (gkFFactorErr) = 0.02
+//
+// The following variables are calculated inside this class:
+// -  fLoGainPedRmsSquare and fLoGainPedRmsSquareVar (see CalcLoGainPedestal())
+// -  fRSigmaSquare and fRSigmaSquareVar             (see CalcReducedSigma()  )
+// -  fPheFFactorMethod and fPheFFactorMethodVar     (see CalcFFactorMethod() )
+//
+// The following variables are set by MHCalibrationChargeCam:
+// -  fAbsTimeMean and fAbsTimeRms
+// -  all variables in MCalibrationPix
+//
+// The following variables are set by MCalibrationChargeCalc:
+// - fPed, fPedVar and fPedRms                         
+// - fMeanConvFADC2Phe
+// - fConvFADC2PheVar 
+// - fSigmaConvFADC2Phe
+// - fTotalFFactorFFactorMethod 
+// - fTotalFFactorFFactorMethodVar 
+//
+// The following variables are not yet implemented:
+// - fConversionHiLo and fConversionHiLoVar (now set fixed to 10. +- 2.5)
+//
+//  Error of all variables are calculated by error-propagation. Note that internally, 
+//  all error variables contain Variances in order to save the CPU-intensive square rooting 
+// 
+//  Low-Gain variables are stored internally unconverted, i.e. directly from the summed 
+//  FADC slices extraction results, but can be retrieved converted to High-Gain amplifications 
+//  by calls to: GetConvertedMean() or GetConvertedSigma()
+// 
+// See also: MCalibrationChargeCam, MCalibrationChargeCalc,
+//           MHCalibrationChargeCam, MHCalibrationChargePix
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCalibrationChargePix.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MBadPixelsPix.h"
+
+ClassImp(MCalibrationChargePix);
+
+using namespace std;
+
+const Float_t MCalibrationChargePix::gkElectronicPedRmsInner    = 1.5;
+const Float_t MCalibrationChargePix::gkElectronicPedRmsOuter    = 1.8;
+const Float_t MCalibrationChargePix::gkElectronicPedRmsErr      = 0.35;
+const Float_t MCalibrationChargePix::gkFFactor                  = 1.15;
+const Float_t MCalibrationChargePix::gkFFactorErr               = 0.02;
+
+const Float_t MCalibrationChargePix::fgConversionHiLo           = 10.;
+const Float_t MCalibrationChargePix::fgConversionHiLoErr        = 2.5;
+const Float_t MCalibrationChargePix::fgPheFFactorMethodLimit    = 1.;
+const Float_t MCalibrationChargePix::fgConvFFactorRelErrLimit   = 0.75;
+// --------------------------------------------------------------------------
+//
+// Default Constructor: 
+//
+// Sets:
+// - fCalibFlags to 0
+// - fConversionHiLo to fgConversionHiLo
+// - fConversionHiLoVar to square of fgConversionHiLoErr
+// - fConvFFactorelErrLimit to fgConvFFactorRelErrLimit*fgConvFFactorelErrLimit
+// - fPheFFactorLimit to fgPheFFactorLimit
+// 
+// Calls:
+// - Clear()
+//
+MCalibrationChargePix::MCalibrationChargePix(const char *name, const char *title)
+    : fCalibFlags(0)
+{
+
+  fName  = name  ? name  : "MCalibrationChargePix";
+  fTitle = title ? title : "Container of the fit results of MHCalibrationChargePixs ";
+
+  //
+  // At the moment, we don't have a database, yet, 
+  // so we get it from the configuration file
+  //
+  SetConversionHiLo();
+  SetConversionHiLoErr();
+
+  SetPheFFactorMethodLimit();
+  SetConvFFactorRelErrLimit();
+  
+  Clear();
+}
+
+// ------------------------------------------------------------------------
+//
+// Sets:
+// - all flags to kFALSE
+// - all variables to -1.
+//
+// Calls: 
+// - MCalibrationPix::Clear()
+//
+void MCalibrationChargePix::Clear(Option_t *o)
+{
+
+  SetFFactorMethodValid     ( kFALSE );
+
+  fRSigmaSquare                     =  -1.;
+  fRSigmaSquareVar                  =  -1.;
+  
+  fPed                              =  -1.;
+  fPedRms                           =  -1.;
+  fPedVar                           =  -1.;
+
+  fLoGainPedRmsSquare               =  -1.;
+  fLoGainPedRmsSquareVar            =  -1.;
+
+  fAbsTimeMean                      =  -1.;
+  fAbsTimeRms                       =  -1.;
+
+  fPheFFactorMethod                 =  -1.;
+  fPheFFactorMethodVar              =  -1.;
+
+  fMeanConvFADC2Phe                 =  -1.;
+  fMeanConvFADC2PheVar              =  -1.;
+  fMeanFFactorFADC2Phot             =  -1.;
+  fMeanFFactorFADC2PhotVar          =  -1.;  
+
+  MCalibrationPix::Clear();
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Set F-Factor Method Validity Bit from outside 
+//
+void MCalibrationChargePix::SetFFactorMethodValid(const Bool_t b )
+{ 
+  b ?  SETBIT(fCalibFlags, kFFactorMethodValid) : CLRBIT(fCalibFlags, kFFactorMethodValid); 
+}    
+
+// --------------------------------------------------------------------------
+//
+// Set pedestals from outside (done by MCalibrationChargeCalc)
+//
+void MCalibrationChargePix::SetPedestal(const Float_t ped, const Float_t pedrms, const Float_t pederr)
+{
+
+  fPed       = ped;    
+  fPedRms    = pedrms;
+  fPedVar    = pederr*pederr;
+}
+
+// --------------------------------------------------------------------------
+//
+// Set pedestals from outside (done by MCalibrationChargeCalc)
+//
+void MCalibrationChargePix::SetPed(const Float_t ped, const Float_t pederr)
+{
+
+  fPed       = ped;    
+  fPedVar    = pederr*pederr;
+}
+
+// --------------------------------------------------------------------------
+//
+// Set pedestals RMS from outside (done by MHCalibrationChargeCam)
+//
+void MCalibrationChargePix::SetPedRMS( const Float_t pedrms, const Float_t pedrmserr)
+{
+  
+  fPedRms    = pedrms;
+  fPedRmsVar = pedrmserr*pedrmserr;
+  
+}
+
+
+// -------------------------------------------------------------------------------
+//
+// Get the conversion Error Hi-Gain to Low-Gain:
+// - If fConversionHiLoVar is smaller than 0 (i.e. has not yet been set), return -1.
+//  
+Float_t MCalibrationChargePix::GetConversionHiLoErr()  const
+{
+  if (fConversionHiLoVar < 0.)
+    return -1.;
+
+  return TMath::Sqrt(fConversionHiLoVar);
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the relative variance of the conversion factor between higain and logain:
+// - If fConversionHiLo    is 0,              return -1.
+// - If fConversionHiLoVar is smaller than 0, return -1.
+// - Else returns: fConversionHiLoVar / fConversionHiLo^2
+//
+const Float_t MCalibrationChargePix::GetConversionHiLoRelVar() const 
+{
+
+  if (fConversionHiLoVar < 0.)
+    return -1.;
+
+  if (fConversionHiLo == 0.)
+    return -1.;
+
+  return fConversionHiLoVar / (fConversionHiLo * fConversionHiLo);
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the relative variance of the electronics pedestal RMS
+// - If aidx is 0, return rel. variance of gkElectronicPedRmsInner
+// - If aidx is 1, return rel. variance of gkElectronicPedRmsOuter
+//
+const Float_t MCalibrationChargePix::GetElectronicPedRmsRelVar(const Int_t aidx) const 
+{
+
+  if (aidx == 0)
+    return gkElectronicPedRmsErr * gkElectronicPedRmsErr / gkElectronicPedRmsInner / gkElectronicPedRmsInner;
+
+  if (aidx == 1)
+    return gkElectronicPedRmsErr * gkElectronicPedRmsErr / gkElectronicPedRmsOuter / gkElectronicPedRmsOuter;
+
+  return -1.;
+}
+ 
+
+// --------------------------------------------------------------------------
+//
+// Get the relative variance of the conversion factor between higain and logain:
+// - If gkFFactor    is 0,              return -1.
+// - If gkFFactorErr is smaller than 0, return -1.
+// - Else returns: gkFFactorErr^2 / gkFFactor*^2
+//
+const Float_t MCalibrationChargePix::GetFFactorRelVar() const 
+{
+
+  if (gkFFactorErr < 0.)
+    return -1.;
+
+  if (gkFFactor == 0.)
+    return -1.;
+
+  return gkFFactorErr * gkFFactorErr / (gkFFactor * gkFFactor);
+}
+ 
+
+// --------------------------------------------------------------------------
+//
+// Get the pedestals RMS: 
+// - Test bit kHiGainSaturation: 
+//   If yes, return square root of fLoGainPedRmsSquare (if greater than 0, otherwise -1.), 
+//   If no,  return fPedRms
+//
+Float_t  MCalibrationChargePix::GetPedRms()  const
+{
+
+  if (IsHiGainSaturation())
+    if (fLoGainPedRmsSquare < 0.)
+      return -1.;
+    else
+      return TMath::Sqrt(fLoGainPedRmsSquare);
+  
+  return fPedRms;
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the Error of the pedestals RMS: 
+// - Test bit kHiGainSaturation: 
+//   If yes, return square root of (0.25*fLoGainPedRmsSquareVar/ fLoGainPedRmsSquare) (if greater than 0, otherwise -1.)
+//   If no , return square root of (fPedVar) (if greater than 0, otherwise -1.), divided by 2. 
+//
+Float_t  MCalibrationChargePix::GetPedRmsErr()  const
+{
+  if (IsHiGainSaturation())
+    if (fLoGainPedRmsSquareVar < 0.)
+      return -1.;
+    else
+      return TMath::Sqrt(0.25*fLoGainPedRmsSquareVar/fLoGainPedRmsSquare);
+  else
+    if (fPedVar < 0.)
+      return -1.;
+    else
+      return TMath::Sqrt(fPedVar)/2.;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Get the Low Gain Mean Charge converted to High Gain amplification: 
+// Returns fLoGainMean multiplied with fConversionHiLo if IsHiGainSaturation(), 
+//         else return fHiGainMean
+//
+Float_t MCalibrationChargePix::GetConvertedMean()  const 
+{
+
+  if (IsHiGainSaturation())
+    return fLoGainMean * fConversionHiLo;
+
+  return fHiGainMean;
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the Error of the converted Low Gain Mean: 
+//
+// Returns -1 if the variable fLoGainMean or fLoGainMeanVar are smaller than 0.
+//
+// Returns the square root of the quadratic sum of the relative variances of 
+// the fLoGainMean and fConversionHiLo, mulitplied with GetConvertedMean()
+// in case of HiGain Saturation, 
+// else return GetMeanErr()
+//
+Float_t MCalibrationChargePix::GetConvertedMeanErr()  const
+{
+
+  if (IsHiGainSaturation())
+    {
+      const Float_t logainrelvar = GetLoGainMeanRelVar();
+      
+      if (logainrelvar < 0.)
+        return -1.;
+
+      return TMath::Sqrt(logainrelvar + GetConversionHiLoRelVar()) * GetConvertedMean();
+    }
+  else
+    return GetMeanErr();
+
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the Low Gain Sigma converted to High Gain amplification: 
+// Returns fLoGainSigma multiplied with fConversionHiLo if IsHiGainSaturation()
+// else return fHiGainSigma
+//
+Float_t MCalibrationChargePix::GetConvertedSigma()  const 
+{
+  
+  if (IsHiGainSaturation())
+    return fLoGainSigma * fConversionHiLo;
+  else
+    return fHiGainSigma;
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the Error of the converted Sigma: 
+//
+// Returns -1 if the variable fLoGainSigma or fLoGainSigmaVar are smaller than 0.
+//
+// if IsHiGainSaturatio()
+// returns the square root of the quadratic sum of the relative variances of 
+// the fLoGainSigma and fConversionHiLo, mulitplied with GetConvertedSigma()
+// else returns GetSigmaErr()
+//
+Float_t MCalibrationChargePix::GetConvertedSigmaErr()  const
+{
+
+  if (IsHiGainSaturation())
+    {
+      if (fLoGainSigmaVar < 0.)
+        return -1.;
+      
+      if (fLoGainSigma < 0.)
+        return -1.;
+      
+      const Float_t sigmaRelVar =  fLoGainSigmaVar
+                                /( fLoGainSigma * fLoGainSigma );
+
+      return TMath::Sqrt(sigmaRelVar+GetConversionHiLoRelVar()) * GetConvertedSigma();
+    }
+  else
+    return GetSigmaErr();
+
+
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the converted reduced Sigma: 
+// - If fRSigmaSquare is smaller than 0 (i.e. has not yet been set), return -1.
+// - Test bit kHiGainSaturation: 
+//   If yes, return square root of fRSigmaSquare, multiplied with fConversionHiLo, 
+//   If no , return square root of fRSigmaSquare
+//
+Float_t MCalibrationChargePix::GetConvertedRSigma()  const
+{
+  if (fRSigmaSquare < 0)
+    return -1;
+
+  const Float_t rsigma = TMath::Sqrt(fRSigmaSquare);
+  
+  return IsHiGainSaturation() ? rsigma*fConversionHiLo : rsigma ;
+} 
+
+// --------------------------------------------------------------------------
+//
+// Get the error of the converted reduced Sigma: 
+// - If fRSigmaSquareVar is smaller than 0 (i.e. has not yet been set), return -1.
+// - Calculate the absolute variance of the reduced sigma with the formula:
+//   reduced sigma variance = 0.25 * fRSigmaSquareVar / fRSigmaSquare
+// - Test bit kHiGainSaturation: 
+//   If yes, returns the square root of the quadratic sum of the relative variances of the 
+//           reduced sigma and fConversionHiLo, mulitplied with GetRSigma()
+//   Else returns the square root of rel. (0.25*fRSigmaSquareVar / fRSigmaSquare)
+//
+Float_t MCalibrationChargePix::GetConvertedRSigmaErr()  const
+{
+
+  if (fRSigmaSquareVar < 0)
+    return -1;
+
+  //
+  // SigmaSquareVar = 4. * Sigma * Sigma * Var(sigma)
+  // ==> Var(sigma) = 0.25 * SigmaSquareVar / (Sigma * Sigma)
+  //
+  const Float_t rsigmaVar = 0.25 * fRSigmaSquareVar / fRSigmaSquare;
+
+  if (IsHiGainSaturation())
+    return TMath::Sqrt(rsigmaVar/fRSigmaSquare + GetConversionHiLoRelVar()) * GetRSigma();
+  else
+    return TMath::Sqrt(rsigmaVar);
+
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the reduced Sigma: 
+// - If fRSigmaSquare is smaller than 0 (i.e. has not yet been set), return -1.
+// - Test bit kHiGainSaturation: 
+//   If yes, return square root of fRSigmaSquare, multiplied with fConversionHiLo, 
+//   If no , return square root of fRSigmaSquare
+//
+Float_t MCalibrationChargePix::GetRSigma()  const
+{
+  if (fRSigmaSquare < 0)
+    return -1;
+
+  return TMath::Sqrt(fRSigmaSquare);
+  
+} 
+
+// --------------------------------------------------------------------------
+//
+// Get the error of the reduced Sigma: 
+// - If fRSigmaSquareVar is smaller than 0 (i.e. has not yet been set), return -1.
+// - Calculate the absolute variance of the reduced sigma with the formula:
+//   reduced sigma variance = 0.25 * fRSigmaSquareVar / fRSigmaSquare
+// - Test bit kHiGainSaturation: 
+//   If yes, returns the square root of the quadratic sum of the relative variances of the 
+//           reduced sigma and fConversionHiLo, mulitplied with GetRSigma()
+//   Else returns the square root of rel. (0.25*fRSigmaSquareVar / fRSigmaSquare)
+//
+Float_t MCalibrationChargePix::GetRSigmaErr()  const
+{
+
+  if (fRSigmaSquareVar < 0)
+    return -1;
+
+  //
+  // SigmaSquareVar = 4. * Sigma * Sigma * Var(sigma)
+  // ==> Var(sigma) = 0.25 * SigmaSquareVar / (Sigma * Sigma)
+  //
+  return TMath::Sqrt(0.25 * fRSigmaSquareVar / fRSigmaSquare);
+
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the reduced Sigma per Charge: 
+// - If GetRSigma() is smaller or equal 0. (i.e. has not yet been set), return -1.
+// - If GetMean() is 0. or -1. (i.e. has not yet been set), return -1.
+// - Return GetRSigma() / GetMean() 
+//
+Float_t MCalibrationChargePix::GetRSigmaPerCharge()  const 
+{
+  
+  const Float_t rsigma = GetRSigma();
+
+  if (rsigma <= 0)
+    return -1.;
+  
+
+  const Float_t mean   = GetMean();
+  
+  if (mean == 0. || mean == -1.)
+    return -1.;
+  
+  return rsigma / mean;
+} 
+
+
+// --------------------------------------------------------------------------
+//
+// Get the error of the reduced Sigma per Charge: 
+// - If GetRSigmaRelVar() is smaller or equal 0. (i.e. has not yet been set), return -1.
+// - If GetMeanRelVar() is smaller or equal 0. (i.e. has not yet been set), return -1.
+// - Return the propagated error of GetRSigmaPerCharge() 
+//
+Float_t MCalibrationChargePix::GetRSigmaPerChargeErr()  const 
+{
+  
+  const Float_t rsigmarelvar  = GetRSigmaRelVar();
+
+  if (rsigmarelvar <= 0)
+    return -1.;
+  
+
+  const Float_t meanrelvar   = GetMeanRelVar();
+  
+  if (meanrelvar <= 0.)
+    return -1.;
+  
+  return TMath::Sqrt(rsigmarelvar + meanrelvar) * GetRSigmaPerCharge();
+} 
+
+// --------------------------------------------------------------------------
+//
+// Get the reduced Sigma Square: 
+// - If fRSigmaSquare is smaller than 0 (i.e. has not yet been set), return -1.
+// - Test bit kHiGainSaturation: 
+//   If yes, return fRSigmaSquare, multiplied with fConversionHiLo^2, 
+//   If no , return fRSigmaSquare
+//
+Float_t MCalibrationChargePix::GetConvertedRSigmaSquare()  const
+{
+  if (fRSigmaSquare < 0)
+    return -1;
+
+  return IsHiGainSaturation() ? fRSigmaSquare*fConversionHiLo*fConversionHiLo : fRSigmaSquare ;
+} 
+
+// --------------------------------------------------------------------------
+//
+// Get the relative variance of the reduced Sigma: 
+// - If fRSigmaSquareVar is smaller than 0 (i.e. has not yet been set), return -1.
+// - Calculate the relative variance of the reduced sigma squares with the formula:
+//   reduced sigma rel. variance = 0.25 * fRSigmaSquareVar / fRSigmaSquare / fRSigmaSquare
+// - Test bit kHiGainSaturation: 
+//   If yes, returns the sum of the relative variances of the reduced sigma and fConversionHiLo
+//   Else returns the relative variance of the reduced sigma
+//
+Float_t MCalibrationChargePix::GetRSigmaRelVar()  const
+{
+
+  if (fRSigmaSquareVar < 0)
+    return -1;
+
+  //
+  // SigmaSquareVar = 4. * Sigma * Sigma * Var(sigma)
+  // ==> Var(sigma) = 0.25 * SigmaSquareVar / (Sigma * Sigma)
+  //
+  return 0.25 * fRSigmaSquareVar / ( fRSigmaSquare * fRSigmaSquare );
+
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the error on the number of photo-electrons (F-Factor Method):
+// - If fPheFFactorMethodVar is smaller than 0 (i.e. has not yet been set), return -1.
+// - Else returns the square root of fPheFFactorMethodVar
+//
+Float_t MCalibrationChargePix::GetPheFFactorMethodErr()  const
+{
+  if (fPheFFactorMethodVar < 0.)
+    return -1.;
+  return TMath::Sqrt(fPheFFactorMethodVar);
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the error on the mean total F-Factor of the signal readout (F-Factor Method):
+// - If fMeanFFactorFADC2PhotVar is smaller than 0 (i.e. has not yet been set), return -1.
+// - Else returns the square root of fMeanFFactorFADC2PhotVar
+//
+Float_t MCalibrationChargePix::GetMeanFFactorFADC2PhotErr()  const
+{
+  if (fMeanFFactorFADC2PhotVar < 0.)
+    return -1.;
+  return TMath::Sqrt(fMeanFFactorFADC2PhotVar);
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the relative variance on the number of photo-electrons (F-Factor Method):
+// - If fPheFFactorMethodVar is smaller than 0 (i.e. has not yet been set), return -1.
+// - If fPheFFactorMethod    is 0, return -1.
+// - Else returns fPheFFactorMethodVar / fPheFFactorMethod^2
+//
+Float_t MCalibrationChargePix::GetPheFFactorMethodRelVar()  const
+{
+  if (fPheFFactorMethodVar < 0.)
+    return -1.;
+  if (fPheFFactorMethod  == 0.)
+    return -1.;
+
+  return fPheFFactorMethodVar / (fPheFFactorMethod * fPheFFactorMethod);
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Get the error on the mean conversion factor (FFactor  Method):
+// - If fMeanConvFADC2PheVar is smaller than 0 (i.e. has not yet been set), return -1.
+// - Else returns the square root of fMeanConvFADC2PheVar
+//
+Float_t MCalibrationChargePix::GetMeanConvFADC2PheErr()  const
+{
+  if (fMeanConvFADC2PheVar < 0.)
+    return -1.;
+  return TMath::Sqrt(fMeanConvFADC2PheVar);
+}
+
+// --------------------------------------------------------------------------
+//
+// Test bit kFFactorMethodValid
+//
+Bool_t MCalibrationChargePix::IsFFactorMethodValid()   const
+{ 
+  return TESTBIT(fCalibFlags, kFFactorMethodValid);     
+}
+
+
+// ----------------------------------------------------------------------------
+// 
+// - If fSigma  is smaller than 0 (i.e. has not yet been set), return kFALSE
+// - If fPedRms is smaller than 0 (i.e. has not yet been set), return kFALSE
+//
+// Calculate the reduced sigma of the low-Gain FADC slices:
+// - Test bit IsHiGainSaturation() for the Sigma: 
+//   If yes, take fLoGainSigma and fLoGainSigmaVar 
+//   If no , take fHiGainSigma and fHiGainSigmaVar 
+//
+// - Test bit IsHiGainSaturation() for the pedRMS: 
+//   If yes, take fLoGainPedRmsSquare and fLoGainPedRmsSquareVar
+//   If no , take fPedRms and fPedVar
+//
+// - Calculate the reduced sigma with the formula:
+//   fRSigmaSquare = Sigma*Sigma - pedRMS*pedRMS
+// 
+// - If fRSigmaSquare is smaller than 0, give a warning and return kFALSE
+//
+// - Calculate the variance of the reduced sigma with the formula:
+//   fRSigmaSquareVar = 4.* (sigmaVar*Sigma*Sigma + pedRmsVar*pedRMS*pedRMS)
+//
+// A back-transformation to the corr. amplification factor of the High-Gain is done 
+// in GetRSigma() and GetRSigmaErr()
+//
+Bool_t MCalibrationChargePix::CalcReducedSigma()
+{
+
+  if (GetSigma() < 0.)
+    return kFALSE;
+  
+  if (GetPedRms() < 0.)
+    return kFALSE;
+
+  const Float_t sigma           = IsHiGainSaturation() ? fLoGainSigma           : fHiGainSigma   ;
+  const Float_t sigmavar        = IsHiGainSaturation() ? fLoGainSigmaVar        : fHiGainSigmaVar;
+  const Float_t pedRmsSquare    = IsHiGainSaturation() ? fLoGainPedRmsSquare    : fPedRms*fPedRms;
+  const Float_t pedRmsSquareVar = IsHiGainSaturation() ? fLoGainPedRmsSquareVar : 0.25*fPedVar*pedRmsSquare;
+
+  if (IsDebug())
+    {
+      *fLog << dbginf << "ID: " << GetPixId() 
+            << " HiGainSaturation: " << IsHiGainSaturation() 
+            << " Sigma: " << sigma 
+            << " Var.Sigma: " << sigmavar
+            << " PedRmsSquare: " << pedRmsSquare
+            << " pedRmsSquareVar: " << pedRmsSquareVar
+            << endl;
+    }
+  
+  const Float_t sigmaSquare    =      sigma     * sigma;
+  const Float_t sigmaSquareVar = 4. * sigmavar  * sigmaSquare;
+
+  //
+  // Calculate the reduced sigmas
+  //
+  fRSigmaSquare = sigmaSquare - pedRmsSquare;
+
+  if (IsDebug())
+    {
+      *fLog << dbginf << "ID: " << GetPixId() 
+            << " Red.Sigma Square: " << fRSigmaSquare
+            << endl;
+    }
+  
+  if (fRSigmaSquare <= 0.)
+    {
+      *fLog << warn 
+            << "WARNING: Cannot calculate the reduced sigma: smaller than 0 in pixel " 
+            << fPixId << endl;
+      return kFALSE;
+    }
+
+  
+  fRSigmaSquareVar = 4. * (sigmaSquareVar + pedRmsSquareVar);
+
+  if (IsDebug())
+    {
+      *fLog << dbginf << "ID: " << GetPixId() 
+            << " Var.Red.Sigma Square: " << fRSigmaSquareVar
+            << endl;
+    }
+
+  return kTRUE;
+}
+
+// ------------------------------------------------------------------
+//
+// If fRSigmaSquare is smaller than 0 (i.e. has not yet been set),
+// set kFFactorMethodValid to kFALSE and return kFALSE
+//
+// Calculate the number of photo-electrons with the F-Factor method:
+// - Test bit IsHiGainSaturation() for the Mean Sum of FADC slices: 
+//   If yes, take fLoGainMean and fLoGainMeanVar 
+//   If no , take fHiGainMean and fHiGainMeanVar 
+//
+// - Test bit IsHiGainSaturation() for the pedRMS: 
+//   If yes, take fLoGainPedRmsSquare and fLoGainPedRmsSquareVar
+//   If no , take fPedRms and fPedVar
+//
+// - Calculate the number of photo-electrons with the formula:
+//   fPheFFactorMethod   = gkFFactor*gkFFactor * Mean * Mean  / fRSigmaSquare
+//
+// - Calculate the Variance on the photo-electrons with the formula:
+//   fPheFFactorMethodVar =  (  4. * gkFFactorErr * gkFFactorErr / ( gkFFactor * gkFFactor ) 
+//                            + 4. * Mean Var.   / ( Mean * Mean )
+//                            + fRSigmaSquareVar / fRSigmaSquare
+//                            ) * fPheFFactorMethod * fPheFFactorMethod
+//
+// - If fPheFFactorMethod is less than fPheFFactorMethodLimit, 
+//   set kFFactorMethodValid to kFALSE and return kFALSE
+//   else: Set kFFactorMethodValid to kTRUE and return kTRUE
+//
+Bool_t MCalibrationChargePix::CalcFFactorMethod()
+{
+
+
+  if (fRSigmaSquare < 0.)
+    return kFALSE;
+  
+  //
+  // Square all variables in order to avoid applications of square root
+  //
+  const Float_t meanSquare          =     GetMean()    * GetMean();
+  const Float_t meanSquareRelVar    = 4.* GetMeanRelVar();
+
+  const Float_t ffactorsquare       =     gkFFactor    * gkFFactor;
+  const Float_t ffactorsquareRelVar = 4.* GetFFactorRelVar();
+
+  const Float_t rsigmaSquareRelVar  =     fRSigmaSquareVar / fRSigmaSquare / fRSigmaSquare;
+  //
+  // Calculate the number of phe's from the F-Factor method
+  // (independent on Hi Gain or Lo Gain)
+  //
+  fPheFFactorMethod = ffactorsquare * meanSquare / fRSigmaSquare;
+
+  if (IsDebug())
+    {
+      *fLog << dbginf << "ID: " << GetPixId() 
+            << " F-Factor Square: " << ffactorsquare
+            << " Mean Square: " << meanSquare
+            << " Red.Sigma Square: " << fRSigmaSquare
+            << " Photo-electrons: " << fPheFFactorMethod
+            << endl;
+    }
+
+  if (fPheFFactorMethod < fPheFFactorMethodLimit)
+    return kFALSE;
+  
+  //
+  // Calculate the Error of Nphe
+  //
+  const Float_t pheRelVar = ffactorsquareRelVar + meanSquareRelVar + rsigmaSquareRelVar;
+  fPheFFactorMethodVar =  pheRelVar * fPheFFactorMethod * fPheFFactorMethod;
+
+  if (IsDebug())
+    {
+      *fLog << dbginf << "ID: " << GetPixId() 
+            << " Rel.Var.F-Factor Square: " << ffactorsquareRelVar
+            << " Rel.Var. Mean Square: " << meanSquareRelVar
+            << " Rel.Var. Red.Sigma Square: " << rsigmaSquareRelVar
+            << " Rel.Var. Photo-electrons: " << pheRelVar
+            << endl;
+    }
+
+  if (fPheFFactorMethodVar < 0. )
+    return kFALSE;
+  
+  const Float_t convmean = GetConvertedMean();
+  
+
+  if (convmean > 0.)
+    fMeanConvFADC2Phe    =  fPheFFactorMethod / GetConvertedMean();
+  else
+    fMeanConvFADC2Phe    =  -1.;
+
+  if (IsDebug())
+    {
+      *fLog << dbginf << "ID: " << GetPixId() 
+            << " Converted Mean: " << convmean 
+            << " Conversion FADC2Phe: " << fMeanConvFADC2Phe
+            << endl;
+    }
+
+  if (fMeanConvFADC2Phe < 0. )
+    return kFALSE;
+  
+  //
+  // In the calculation of the number of phe's one mean square has already been used. 
+  // Now, we divide by another mean, so one mean calcels out, we cannot directly propagate
+  // the errors, but have to take account of this cancellation:
+  // 
+  const Float_t convrelvar = ffactorsquareRelVar + GetMeanRelVar() + rsigmaSquareRelVar;
+  const Float_t limit      = IsHiGainSaturation() ? fConvFFactorRelVarLimit * 4. : fConvFFactorRelVarLimit;
+
+  if (IsDebug())
+    {
+      *fLog << dbginf << "ID: " << GetPixId() 
+            << " Rel.Var.Red.Sigma: " << rsigmaSquareRelVar
+            << " Rel.Var.Mean: " << GetMeanRelVar()
+            << " Rel.Var.F-Factor: " << ffactorsquareRelVar
+            << " Rel.Var.Conversion FADC2Phe: " << convrelvar
+            << endl;
+    }
+
+  if (convrelvar > limit || convrelvar < 0.)
+    {
+      *fLog << warn << GetDescriptor() << ": Conversion F-Factor Method Rel. Variance: " 
+            << convrelvar << " above limits of: [0," << Form("%3.2f",limit)
+            << "] in pixel: " << fPixId << endl;
+      return kFALSE;
+    }
+  
+  fMeanConvFADC2PheVar =  convrelvar * fMeanConvFADC2Phe * fMeanConvFADC2Phe;
+  
+  SetFFactorMethodValid(kTRUE);
+  return kTRUE;
+}
+
+// ----------------------------------------------------------------------------------
+//
+// If photflux is smaller or equal 0, return kFALSE
+//
+// Calculate the total F-Factor with the formula:
+//   fMeanFFactorFADC2Phot = Sqrt ( fRSigmaSquare ) / GetMean()  * sqrt(nphotons)
+//
+// Calculate the error of the total F-Factor
+//
+Bool_t MCalibrationChargePix::CalcMeanFFactor( const Float_t nphotons, const Float_t nphotonsrelvar )
+{
+
+
+  if (IsDebug())
+    {
+      *fLog << dbginf << "ID: " << GetPixId() 
+            << " Number photons: " << nphotons
+            << " Rel.Var.Number photons: " << nphotonsrelvar
+            << " Red.Sigma Square: " << fRSigmaSquare
+            << " Mean: " << GetMean()
+            << endl;
+    }
+
+
+  if (nphotons <= 0.)
+    {
+      *fLog << warn << GetDescriptor() << ": Assumed photon flux is smaller or equal 0." << endl;
+      return kFALSE;
+    }
+
+  if (nphotonsrelvar < 0.)
+    {
+      *fLog << warn << GetDescriptor() << ": Assumed photon flux variance is smaller than 0." << endl;
+      return kFALSE;
+    }
+
+  fMeanFFactorFADC2Phot =  TMath::Sqrt(fRSigmaSquare * nphotons) / GetMean() ;
+  
+  if (IsDebug())
+    {
+      *fLog << dbginf << "ID: " << GetPixId() 
+            << " F-Factor FADC2Phot: " << fMeanFFactorFADC2Phot
+            << endl;
+    }
+
+  if (fMeanFFactorFADC2Phot < 0.)
+    {
+      *fLog << warn << GetDescriptor() << ": F-Factor photons to FADC counts smaller than 0." << endl;
+      return kFALSE;
+    }
+  
+  const Float_t ffactorrelvar = 0.25 * fRSigmaSquareVar / ( fRSigmaSquare * fRSigmaSquare) 
+                              + GetMeanRelVar() 
+                              + 0.25 * nphotonsrelvar;
+  
+  fMeanFFactorFADC2PhotVar    = ffactorrelvar * fMeanFFactorFADC2Phot * fMeanFFactorFADC2Phot;
+
+  if (IsDebug())
+    {
+      *fLog << dbginf << "ID: " << GetPixId() 
+            << " Rel.Var.Red.Sigma: " << 0.25 * fRSigmaSquareVar / ( fRSigmaSquare * fRSigmaSquare) 
+            << " Rel.Var.Mean: " << GetMeanRelVar()
+            << " Rel.Var.photons: " << 0.25 * nphotonsrelvar
+            << " Rel.Var.F-Factor FADC2Phot: " << ffactorrelvar
+            << endl;
+    }
+
+  return kTRUE;
+}
+
+
+// ----------------------------------------------------------------------------
+// 
+// - If fPed    is smaller than 0 (i.e. has not yet been set), return.
+// - If fPedVar is smaller than 0 (i.e. has not yet been set), return.
+//
+// Calculate the electronic pedestal RMS with the formula:
+//  - elec. pedestal = gkElectronicPedRms * sqrt(logainsamples)
+// 
+// Calculate the night sky background ped. RMS contribution ("NSB") in the high-gain 
+// from the high gain Pedestal RMS with the formula:
+// - HiGain NSB square      = fPedRms * fPedRms - elec.ped.* elec.ped.
+// - Var(HiGain NSB square) = fPedVar * fPedRms * fPedRms + 4.*elecPedRmsVar * elec.ped.* elec.ped.
+//
+// If HiGain NSB square is smaller than 0., set it to zero. (but not the error!)
+//
+// Convert the NSB ped. RMS contribution to the low-gain with the formula:
+// - LoGain NSB square      = - HiGain NSB square / (fConversionHiLo*fConversionHiLo)
+// - Var(LoGain NSB square) = ( Var(HiGain NSB square) / (HiGain NSB square * HiGain NSB square)
+//                              + GetConversionHiLoRelVar()   
+//                            ) * LoGain NSB square * LoGain NSB square
+//
+// - Low Gain Ped RMS Square       = LoGain NSB square      + elec.ped. square
+//   Var (Low Gain Ped RMS Square) = Var(LoGain NSB square) + Var(elec.ped. square)
+//
+void MCalibrationChargePix::CalcLoGainPedestal(Float_t logainsamples, const Int_t aidx)
+{
+
+  if (fPedRms < 0.)
+    return;
+
+  if (fPedVar < 0.)
+    return;
+
+  const Float_t elecPedRms     = (aidx == 0 ? gkElectronicPedRmsInner : gkElectronicPedRmsOuter ) 
+                               * TMath::Sqrt(logainsamples) / fConversionHiLo;
+  const Float_t elecPedRmsVar  = ( GetElectronicPedRmsRelVar(aidx) + GetConversionHiLoRelVar() )
+                               * elecPedRms * elecPedRms;
+  
+  Float_t pedRmsSquare      = fPedRms * fPedRms;
+  Float_t pedRmsSquareVar   = fPedVar * pedRmsSquare; // fPedRmsErr = fPedErr/2.
+  
+  //
+  // We do not know the Lo Gain Pedestal RMS, so we have to retrieve it 
+  // from the HI GAIN (all calculation per slice up to now):  
+  //
+  // We extract the pure NSB contribution:
+  //
+  const Float_t elecRmsSquare    =    elecPedRms    * elecPedRms;
+  const Float_t elecRmsSquareVar = 4.*elecPedRmsVar * elecRmsSquare;
+  
+  if (IsDebug())
+    {
+      *fLog << dbginf << "ID: " << GetPixId() 
+            << " Ped.Rms Square:  " << pedRmsSquare 
+            << " Elec.Rms Square: " << elecRmsSquare 
+            << " Ped.Rms.Square Var.: " << pedRmsSquareVar 
+            << " Elec.Rms Square Var.: " << elecRmsSquareVar 
+            << endl;
+    }
+  
+
+  Float_t higainNsbSquare        =  pedRmsSquare    - elecRmsSquare;
+  Float_t higainNsbSquareRelVar  = (pedRmsSquareVar + elecRmsSquareVar);
+
+
+  if (higainNsbSquare < 0.001)
+    higainNsbSquare = 0.;
+  else
+    higainNsbSquareRelVar  /= (higainNsbSquare * higainNsbSquare) ;
+  
+  if (IsDebug())
+    {
+      *fLog << dbginf << "ID: " << GetPixId() 
+            << " HiGain NSB Square:  " << higainNsbSquare
+            << " Rel.Var.HiGain NSB Square:  " << higainNsbSquareRelVar
+            << endl;
+    }
+  
+  //
+  // Now, we divide the NSB by the conversion factor and 
+  // add it quadratically to the electronic noise
+  //
+  const Float_t conversionSquare        =     fConversionHiLo    * fConversionHiLo;
+  const Float_t conversionSquareRelVar  = 4.* GetConversionHiLoRelVar();
+
+  const Float_t logainNsbSquare         =   higainNsbSquare       / conversionSquare;
+  const Float_t logainNsbSquareVar      = ( higainNsbSquareRelVar + conversionSquareRelVar )
+                                	  * logainNsbSquare * logainNsbSquare;
+    
+  fLoGainPedRmsSquare    = logainNsbSquare    + elecRmsSquare;
+  fLoGainPedRmsSquareVar = logainNsbSquareVar + elecRmsSquareVar;
+
+  if (IsDebug())
+    {
+      *fLog << dbginf << "ID: " << GetPixId() 
+            << " LoGain Ped Rms Square:  " << fLoGainPedRmsSquare
+            << " Var.Ped Rms Square:  " << fLoGainPedRmsSquareVar
+            << endl;
+    }
+  
+  
+}
+ 
Index: /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationChargePix.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationChargePix.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationChargePix.h	(revision 9661)
@@ -0,0 +1,119 @@
+#ifndef MARS_MCalibrationChargePix
+#define MARS_MCalibrationChargePix
+
+#ifndef MARS_MCalibrationPix
+#include "MCalibrationPix.h"
+#endif
+
+class MCalibrationChargePix : public MCalibrationPix
+{
+private:
+
+  static const Float_t gkElectronicPedRmsInner;  //! Electronic component of ped. RMS (now set to: 1.5)
+  static const Float_t gkElectronicPedRmsOuter;  //! Electronic component of ped. RMS (now set to: 1.8)
+  static const Float_t gkElectronicPedRmsErr;    //! Error Electr. component ped. RMS (now set to: 0.35)
+  static const Float_t gkFFactor;                //! Laboratory F-factor PMTs         (now set to: 1.15)
+  static const Float_t gkFFactorErr;             //! Laboratory F-factor Error PMTs   (now set to: 0.02)
+
+  static const Float_t fgConversionHiLo;         //! Default fConversionHiLo          (now set to: 10.)
+  static const Float_t fgConversionHiLoErr;      //! Default fConversionHiLoVar       (now set to: 2.5)
+  static const Float_t fgPheFFactorMethodLimit;  //! Default fPheFFactorMethodLimit   (now set to: 5.)
+  static const Float_t fgConvFFactorRelErrLimit; //! Default fConvFFactorRelErrLimit  (now set to: 0.35)  
+  
+  Float_t fAbsTimeMean;                     // Mean Absolute Arrival Time
+  Float_t fAbsTimeRms;                      // RMS Mean Absolute Arrival Time
+  Byte_t  fCalibFlags;                      // Bit-field for the class-own bits
+  Float_t fConversionHiLo;                  // Conversion factor betw. Hi Gain and Lo Gain  
+  Float_t fConversionHiLoVar;               // Variance Conversion factor betw. Hi and Lo Gain
+  Float_t fConvFFactorRelVarLimit;          // Limit for acceptance rel. variance Conversion FADC2Phe
+  Float_t fLoGainPedRmsSquare;              // Pedestal RMS square of Low Gain
+  Float_t fLoGainPedRmsSquareVar;           // Pedestal RMS square Variance of Low Gain
+  Float_t fMeanConvFADC2Phe;                // Conversion factor (F-factor method)
+  Float_t fMeanConvFADC2PheVar;             // Variance conversion factor (F-factor method)
+  Float_t fMeanFFactorFADC2Phot;            // Total mean F-Factor to photons (F-factor method)
+  Float_t fMeanFFactorFADC2PhotVar;         // Variance mean F-Factor photons (F-factor method)  
+  Float_t fPed;                             // Pedestal (from MPedestalPix) times number FADC slices
+  Float_t fPedVar;                          // Variance of pedestal 
+  Float_t fPedRms;                          // Pedestal RMS (from MPedestalPix) times sqrt nr. FADC slices
+  Float_t fPedRmsVar;                       // Pedestal RMS (from MPedestalPix) times sqrt nr. FADC slices
+  Float_t fPheFFactorMethod;                // Number Phe's calculated (F-factor method)
+  Float_t fPheFFactorMethodVar;             // Variance number of Phe's (F-factor method)
+  Float_t fPheFFactorMethodLimit;           // Min. number Photo-electrons for pix to be accepted.
+  Float_t fRSigmaSquare;                    // Square of Reduced sigma
+  Float_t fRSigmaSquareVar;                 // Variance Reduced sigma
+  
+  enum  { kFFactorMethodValid   };          // Possible bits to be set
+
+  const Float_t GetElectronicPedRmsRelVar(const Int_t aidx) const;
+  const Float_t GetConversionHiLoRelVar()  const;
+  const Float_t GetFFactorRelVar()     const;
+  
+public:
+
+  MCalibrationChargePix(const char *name=NULL, const char *title=NULL);
+  ~MCalibrationChargePix() {}
+  
+  void Clear(Option_t *o="");
+
+  // Setter
+  void SetAbsTimeMean ( const Float_t f ) { fAbsTimeMean = f; }
+  void SetAbsTimeRms  ( const Float_t f ) { fAbsTimeRms  = f; }
+  void SetConversionHiLo    ( const Float_t c=fgConversionHiLo    )        { fConversionHiLo    = c;       }
+  void SetConversionHiLoErr ( const Float_t e=fgConversionHiLoErr )        { fConversionHiLoVar = e*e;     }
+  void SetConvFFactorRelErrLimit   ( const Float_t f=fgConvFFactorRelErrLimit) { fConvFFactorRelVarLimit = f*f;}
+  void SetFFactorMethodValid   ( const Bool_t b = kTRUE );
+  void SetMeanConvFADC2Phe      ( const Float_t f)                          { fMeanConvFADC2Phe       = f; }
+  void SetMeanConvFADC2PheVar   ( const Float_t f)                          { fMeanConvFADC2PheVar    = f; }
+  void SetMeanFFactorFADC2Phot  ( const Float_t f)                          { fMeanFFactorFADC2Phot   = f; }
+  void SetPedestal              ( const Float_t ped, const Float_t pedrms, const Float_t pederr);
+  void SetPed                   ( const Float_t ped, const Float_t pederr);  
+  void SetPedRMS              ( const Float_t pedrms, const Float_t pedrmserr);  
+  void SetPheFFactorMethod      ( const Float_t f)                          { fPheFFactorMethod       = f; }
+  void SetPheFFactorMethodVar   ( const Float_t f)                          { fPheFFactorMethodVar    = f; }  
+  void SetPheFFactorMethodLimit ( const Float_t f=fgPheFFactorMethodLimit ) { fPheFFactorMethodLimit  = f; }
+  
+  // Getters
+  Float_t GetAbsTimeMean             () const { return fAbsTimeMean;             }
+  Float_t GetAbsTimeRms              () const { return fAbsTimeRms;              }
+  Float_t GetConversionHiLo          () const { return fConversionHiLo;          }
+  Float_t GetConversionHiLoErr       () const;
+  Float_t GetConvertedMean           () const;
+  Float_t GetConvertedMeanErr        () const;
+  Float_t GetConvertedSigma          () const;
+  Float_t GetConvertedSigmaErr       () const;
+  Float_t GetConvertedRSigma         () const;
+  Float_t GetConvertedRSigmaErr      () const;
+  Float_t GetConvertedRSigmaSquare   () const;  
+  Float_t GetMeanConvFADC2Phe        () const { return fMeanConvFADC2Phe;        } 
+  Float_t GetMeanConvFADC2PheErr     () const;
+  Float_t GetMeanConvFADC2PheVar     () const { return fMeanConvFADC2PheVar;     }
+  Float_t GetMeanFFactorFADC2Phot    () const { return fMeanFFactorFADC2Phot;    }
+  Float_t GetMeanFFactorFADC2PhotErr () const;
+  Float_t GetMeanFFactorFADC2PhotVar () const { return fMeanFFactorFADC2PhotVar; }    
+  Float_t GetPed                     () const { return fPed;                     }
+  Float_t GetPedErr                  () const { return TMath::Sqrt(fPedVar);     }
+  Float_t GetPedRms                  () const;
+  Float_t GetPedRmsErr               () const;
+  Float_t GetPheFFactorMethod        () const { return fPheFFactorMethod;        }    
+  Float_t GetPheFFactorMethodErr     () const;
+  Float_t GetPheFFactorMethodVar     () const { return fPheFFactorMethodVar;     }
+  Float_t GetPheFFactorMethodRelVar  () const;
+  Float_t GetRSigma                  () const;
+  Float_t GetRSigmaErr               () const;
+  Float_t GetRSigmaRelVar            () const;
+  Float_t GetRSigmaPerCharge         () const;
+  Float_t GetRSigmaPerChargeErr      () const;
+
+  Bool_t IsFFactorMethodValid        () const;
+
+  // Calculations
+  void   CalcLoGainPedestal       ( const Float_t logainsamples, const Int_t aidx );
+  Bool_t CalcReducedSigma  (  );
+  Bool_t CalcFFactorMethod ();
+  Bool_t CalcMeanFFactor   ( const Float_t nphotons, const Float_t nphotonsrelvar );
+  
+  ClassDef(MCalibrationChargePix, 2)	// Container Charge Calibration Results Pixel
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationPedCam.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationPedCam.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationPedCam.cc	(revision 9661)
@@ -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): Markus Gaug   11/2003 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                               
+// MCalibrationPedCam                                               
+//                                                               
+// Hold the pedestal Calibration results obtained from MHPedestalCam of the camera:
+//                                                               
+// The calculated values (types of GetPixelContent) are:
+// 
+// Fitted values:
+// ============== 
+//
+// 0: Fitted Pedestal
+// 1: Error of fitted Pedestal
+// 2: Sigma of fitted Pedestal
+// 3: Error of Sigma of fitted Pedestal
+//
+// Useful variables derived from the fit results:
+// =============================================
+//
+// 4: Returned probability of Gauss fit to Pedestal distribution
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCalibrationPedCam.h"
+#include "MCalibrationCam.h"
+
+#include <TClonesArray.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MGeomCam.h"
+#include "MGeomPix.h"
+
+#include "MCalibrationPix.h"
+
+ClassImp(MCalibrationPedCam);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+// Creates a TClonesArray of MCalibrationPix containers, initialized to 1 entry, destinated 
+// to hold one container per pixel. Later, a call to MCalibrationRelTimeCam::InitSize() 
+// has to be performed (in MGeomApply). 
+//
+// Creates a TClonesArray of MCalibrationPix containers, initialized to 1 entry, destinated 
+// to hold one container per pixel AREA. Later, a call to MCalibrationRelTimeCam::InitAreas() 
+// has to be performed (in MGeomApply). 
+//
+// Creates a TClonesArray of MCalibrationPix containers, initialized to 1 entry, destinated
+// to hold one container per camera SECTOR. Later, a call to MCalibrationRelTimeCam::InitSectors() 
+// has to be performed (in MGeomApply). 
+//
+MCalibrationPedCam::MCalibrationPedCam(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MCalibrationPedCam";
+    fTitle = title ? title : "Storage container for the Pedestal Calibration Results in the camera";
+
+    fPixels           = new TClonesArray("MCalibrationPix",1);
+    fAverageAreas     = new TClonesArray("MCalibrationPix",1);
+    fAverageSectors   = new TClonesArray("MCalibrationPix",1);
+
+}
+
+// --------------------------------------------------------------------------
+//
+// The calculated values (types of GetPixelContent) are:
+// 
+// Fitted values:
+// ============== 
+//
+// 0: Fitted Pedestal
+// 1: Error of fitted Pedestal
+// 2: Sigma of fitted Pedestal
+// 3: Error of Sigma of fitted Pedestal
+//
+// Useful variables derived from the fit results:
+// =============================================
+//
+// 4: Returned probability of Gauss fit to Pedestal distribution
+//
+Bool_t MCalibrationPedCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
+{
+
+  if (idx > GetSize())
+    return kFALSE;
+
+  Float_t area = cam[idx].GetA();
+
+ if (area == 0)
+    return kFALSE;
+
+ if ((*this)[idx].IsExcluded())
+   return kFALSE;
+
+  switch (type)
+    {
+    case 0:
+      val = (*this)[idx].GetMean();
+      break;
+    case 1:
+      val = (*this)[idx].GetMeanErr();
+      break;
+    case 2:
+      val = (*this)[idx].GetSigma();
+      break;
+    case 3:
+      val = (*this)[idx].GetSigmaErr();
+      break;
+    case 4:
+      val = (*this)[idx].GetProb();
+      break;
+    default:
+      return kFALSE;
+    }
+
+  return val!=-1.;
+  
+}
Index: /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationPedCam.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationPedCam.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationPedCam.h	(revision 9661)
@@ -0,0 +1,23 @@
+#ifndef MARS_MCalibrationPedCam
+#define MARS_MCalibrationPedCam
+
+#ifndef MARS_MCalibrationCam
+#include "MCalibrationCam.h"
+#endif
+
+class MCalibrationPedCam : public MCalibrationCam
+{
+private:
+  
+  
+public:
+
+  MCalibrationPedCam(const char *name=NULL, const char *title=NULL);
+  ~MCalibrationPedCam() {}
+
+  Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
+  
+  ClassDef(MCalibrationPedCam, 1)	// Container Pedestal Calibration Results Camera
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationPix.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationPix.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationPix.cc	(revision 9661)
@@ -0,0 +1,412 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug   02/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+\* ======================================================================== */
+/////////////////////////////////////////////////////////////////////////////
+//                                                     
+// MCalibrationPix                                     
+//                                                     
+// Base Storage container for a calibration pixel. Holds mean and sigmas,  
+// their errors, the fit probability and the number of pickup events for 
+// the high-gain and the low-gain derived values.    
+//                                                                         
+// Errors are stored internally as variances, but are returned and filled 
+// as square root of the variances. 
+//
+// Calls to GetMean(), GetMeanErr(), GetSigma(), GetSigmaErr(), GetProb() or 
+// GetNumPickup() and GetNumBlackout() test first the bit kHiGainSaturation 
+// before returning the high-gain or low-gain value, analogue for the 
+// corr. Setters.
+//
+// The three flags: kValid, kExcluded and kHiGainSaturation may be set.
+// The colors: kGREEN, kBLUE, kUV and kCT1 may be set. 
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCalibrationPix.h"
+
+ClassImp(MCalibrationPix);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor: 
+//
+// Sets:
+// - fPixId to -1
+// - fFlags to 0
+//
+// Calls:
+// - Clear()
+//
+MCalibrationPix::MCalibrationPix(const char *name, const char *title)
+    : fPixId(-1),
+      fFlags(0)
+{
+
+  fName  = name  ? name  : "MCalibrationPix";
+  fTitle = title ? title : "Container of the fit results of MHCalibrationPixs ";
+
+  Clear();
+
+}
+
+// ------------------------------------------------------------------------
+//
+// Sets:
+// - all variables to -1
+// - all flags to kFALSE
+//
+void MCalibrationPix::Clear(Option_t *o)
+{
+
+  fHiGainNumBlackout   =  -1 ;
+  fHiGainNumPickup     =  -1 ;
+  fHiGainMean          =  -1.;
+  fHiGainMeanVar       =  -1.;
+  fHiGainProb          =  -1.;
+  fHiGainSigma         =  -1.;
+  fHiGainSigmaVar      =  -1.;
+
+  fLoGainNumBlackout   =  -1 ;
+  fLoGainNumPickup     =  -1 ;
+  fLoGainMean          =  -1.;
+  fLoGainMeanVar       =  -1.;
+  fLoGainProb          =  -1.;
+  fLoGainSigma         =  -1.;
+  fLoGainSigmaVar      =  -1.;
+
+  SetHiGainSaturation  ( kFALSE );
+  SetExcluded          ( kFALSE );
+  SetValid             ( kFALSE );
+  SetDebug             ( kFALSE );
+
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the Hi Gain Saturation Bit from outside
+//
+void MCalibrationPix::SetHiGainSaturation(Bool_t b)
+{
+    b ?  SETBIT(fFlags, kHiGainSaturation) : CLRBIT(fFlags, kHiGainSaturation); 
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the Valid Bit from outside 
+//
+void MCalibrationPix::SetDebug(Bool_t b )
+{ 
+    b ?  SETBIT(fFlags, kDebug) : CLRBIT(fFlags, kDebug); 
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the Excluded Bit from outside 
+//
+void MCalibrationPix::SetExcluded(Bool_t b )
+{ 
+    b ?  SETBIT(fFlags, kExcluded) : CLRBIT(fFlags, kExcluded); 
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the Valid Bit from outside 
+//
+void MCalibrationPix::SetValid(Bool_t b )
+{ 
+    b ?  SETBIT(fFlags, kValid) : CLRBIT(fFlags, kValid); 
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Return -1, if IsHiGainSaturation()
+// Return -1, if the LoGain Mean is smaller than 0.5
+// Return -1, if the HiGain Mean is -1.         (has not yet been set) 
+// Return fHiGainMean / fLoGainMean
+//
+Float_t MCalibrationPix::GetHiLoMeansDivided() const
+{
+  
+  if (IsHiGainSaturation())
+    return -1.;
+
+  if (fLoGainMean <= 0.5)
+    return -1.;
+
+  if (fHiGainMean == -1.)
+    return -1.;
+  
+  return fHiGainMean / fLoGainMean;
+  
+}
+
+// ----------------------------------------------------------------------------------
+//
+// Return -1, if IsHiGainSaturation()
+// Return -1, if the LoGain Mean or its variance is smaller than 0.5 (has not yet been set)
+// Return -1, if the HiGain Mean or its variance is -1.         (has not yet been set) 
+// Return propagated error of GetHiLoMeansDivided()
+//
+Float_t MCalibrationPix::GetHiLoMeansDividedErr() const
+{
+  
+  if (IsHiGainSaturation())
+    return -1.;
+
+  if (fLoGainMean <= 0.5)
+    return -1.;
+
+  if (fHiGainMean == -1.)
+    return -1.;
+  
+  if (fLoGainMeanVar <= 0.)
+    return -1.;
+
+  if (fHiGainMeanVar <= 0.)
+    return -1.;
+  
+  const Float_t lomeansquare = fLoGainMean * fLoGainMean;
+  const Float_t deltaHi = fHiGainMeanVar / lomeansquare;
+  const Float_t deltaLo = fLoGainMeanVar / (lomeansquare * lomeansquare) * fHiGainMean * fHiGainMean;
+
+  return TMath::Sqrt(deltaHi + deltaLo);
+  
+}
+
+// --------------------------------------------------------------------------
+//
+// Return -1, if IsHiGainSaturation()
+// Return -1, if the LoGain Sigma is smaller than 0.01 
+// Return -1, if the HiGain Sigma is -1.         (has not yet been set) 
+// Return fHiGainSigma / fLoGainSigma
+//
+Float_t MCalibrationPix::GetHiLoSigmasDivided() const
+{
+  
+  if (IsHiGainSaturation())
+    return -1.;
+
+  if (fLoGainSigma <= 0.01)
+    return -1.;
+
+  if (fHiGainSigma == -1.)
+    return -1.;
+  
+  return fHiGainSigma / fLoGainSigma;
+  
+}
+
+// ----------------------------------------------------------------------------------
+//
+// Return -1, if IsHiGainSaturation()
+// Return -1, if the LoGain Sigma variance is smaller than 0.
+// Return -1, if the LoGain Sigma is smaller than 0.01
+// Return -1, if the HiGain Sigma or its variance is -1.         (has not yet been set) 
+// Return propagated error of GetHiLoSigmasDivided()
+//
+Float_t MCalibrationPix::GetHiLoSigmasDividedErr() const
+{
+  
+  if (IsHiGainSaturation())
+    return -1.;
+
+  if (fLoGainSigma <= 0.01) 
+    return -1.;
+
+  if (fHiGainSigma == -1.)
+    return -1.;
+  
+  if (fLoGainSigmaVar <= 0.)
+    return -1.;
+
+  if (fHiGainSigmaVar <= 0.)
+    return -1.;
+  
+  const Float_t losigmasquare = fLoGainSigma * fLoGainSigma;
+  const Float_t deltaHi = fHiGainSigmaVar / losigmasquare;
+  const Float_t deltaLo = fLoGainSigmaVar / (losigmasquare * losigmasquare) * fHiGainSigma * fHiGainSigma;
+
+  return TMath::Sqrt(deltaHi + deltaLo);
+  
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Get the Relative Variance of either High Gain or Low Gain Mean 
+// depending on IsHighGainSaturation()
+//
+// If variance is smaller than 0. return -1.
+//
+Float_t MCalibrationPix::GetMeanRelVar()  const
+{
+
+  if (IsHiGainSaturation())
+    if (fLoGainMeanVar < 0. || fLoGainMean < 0.)
+      return -1.;
+    else
+      return fLoGainMeanVar / (fLoGainMean * fLoGainMean);
+  else
+    if (fHiGainMeanVar < 0. || fHiGainMean < 0.)
+      return -1.;
+    else
+      return fHiGainMeanVar / (fHiGainMean * fHiGainMean);
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the Square of either High Gain or Low Gain Mean 
+// depending on IsHighGainSaturation()
+//
+Float_t MCalibrationPix::GetMeanSquare()  const
+{
+
+  if (IsHiGainSaturation())
+    return fLoGainMean == -1. ? -1. : fLoGainMean * fLoGainMean;
+  else
+    return fHiGainMean == -1. ? -1. : fHiGainMean * fHiGainMean;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Get the Relative Variance of either High Gain or Low Gain Sigma 
+// depending on IsHighGainSaturation()
+//
+// If variance is smaller than 0. return -1.
+//
+Float_t MCalibrationPix::GetSigmaRelVar()  const
+{
+
+  if (IsHiGainSaturation())
+    if (fLoGainSigmaVar < 0.)
+      return -1.;
+    else
+      return fLoGainSigmaVar / (fLoGainSigma * fLoGainSigma);
+  else
+    if (fHiGainSigmaVar < 0.)
+      return -1.;
+    else
+      return fHiGainSigmaVar / (fHiGainSigma * fHiGainSigma);
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the High Gain Mean Error: Takes square root of fHiGainMeanVar
+//
+Float_t MCalibrationPix::GetHiGainMeanErr()  const
+{
+  if (fLoGainMeanVar < 0.)
+    return -1.;
+
+  return TMath::Sqrt(fLoGainMeanVar);
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Get the High Gain Sigma Error: Takes square root of fHiGainSigmaVar
+//
+Float_t MCalibrationPix::GetHiGainSigmaErr()  const
+{
+  if (fHiGainSigmaVar < 0.)
+    return -1.;
+
+  return TMath::Sqrt(fHiGainSigmaVar);
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the Low Gain Mean Error: Takes square root of fLoGainMeanVar
+//
+Float_t MCalibrationPix::GetLoGainMeanErr()  const
+{
+  if (fLoGainMeanVar < 0.)
+    return -1.;
+
+  return TMath::Sqrt(fLoGainMeanVar);
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the Low Gain Mean Rel Variance
+//
+Float_t MCalibrationPix::GetLoGainMeanRelVar()  const
+{
+  if (fLoGainMeanVar < 0.)
+    return -1.;
+  if (fLoGainMean   == 0.)
+    return -1.;
+
+  return fLoGainMeanVar / ( fLoGainMean * fLoGainMean);
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the Low Gain Sigma Error: Takes square root of fHiGainSigmaVar
+//
+Float_t MCalibrationPix::GetLoGainSigmaErr()  const
+{
+  if (fLoGainSigmaVar < 0.)
+    return -1.;
+
+  return TMath::Sqrt(fLoGainSigmaVar);
+}
+
+// --------------------------------------------------------------------------
+//
+// Test bit kHiGainSaturation
+//
+Bool_t MCalibrationPix::IsHiGainSaturation()    const
+{ 
+  return TESTBIT(fFlags,kHiGainSaturation);  
+}
+
+// --------------------------------------------------------------------------
+//
+// Test bit kDebug
+//
+Bool_t MCalibrationPix::IsDebug()     const
+{ 
+   return TESTBIT(fFlags,kDebug);  
+}
+
+// --------------------------------------------------------------------------
+//
+// Test bit kExcluded
+//
+Bool_t MCalibrationPix::IsExcluded()     const
+{ 
+   return TESTBIT(fFlags,kExcluded);  
+}
+
+// --------------------------------------------------------------------------
+//
+// Test bit kValid
+//
+Bool_t MCalibrationPix::IsValid()     const
+{ 
+   return TESTBIT(fFlags,kValid);  
+}
+
Index: /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationPix.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationPix.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationPix.h	(revision 9661)
@@ -0,0 +1,111 @@
+#ifndef MARS_MCalibrationPix
+#define MARS_MCalibrationPix
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MCalibrationPix : public MParContainer
+{
+protected:
+
+  Int_t   fPixId;             // Software PixId (needed to get Id in calls to Next())
+  UInt_t  fFlags;             // Flag for the set bits
+  Float_t fHiGainMean;        // Mean from fit to high gain values
+  Float_t fHiGainMeanVar;     // Error of mean from fit to high gain values
+  Float_t fHiGainNumBlackout; // Number blackout events in high-gain
+  Float_t fHiGainNumPickup;   // Number pickup events in high-gain
+  Float_t fHiGainSigma;       // Sigma from fit to high gain values
+  Float_t fHiGainSigmaVar;    // Error of sigma from fit to high gain values
+  Float_t fHiGainProb;        // Probability of fit to high gain values
+  Float_t fLoGainMean;        // Mean from fit to high gain values
+  Float_t fLoGainMeanVar;     // Error of mean from fit to low gain values
+  Float_t fLoGainNumBlackout; // Number blackout events in low-gain
+  Float_t fLoGainNumPickup;   // Number pickup events in low-gain
+  Float_t fLoGainSigma;       // Sigma of from fit to low gain values
+  Float_t fLoGainSigmaVar;    // Error of sigma from fit to low gain values
+  Float_t fLoGainProb;        // Probability of fit to low gain values
+
+  enum { kHiGainSaturation, kExcluded, kValid, kDebug };   // Possible bits to be sets
+
+public:
+
+  MCalibrationPix(const char *name=NULL, const char *title=NULL);
+  ~MCalibrationPix() {}
+  
+  virtual void Clear(Option_t *o="");
+
+  // Setter
+  void SetPixId( const Int_t i )   { fPixId = i; }
+
+  void SetHiGainMean        ( const Float_t f ) { fHiGainMean        = f; }
+  void SetHiGainMeanVar     ( const Float_t f ) { fHiGainMeanVar     = f; }
+  void SetHiGainNumBlackout ( const Float_t f ) { fHiGainNumBlackout = f; }
+  void SetHiGainNumPickup   ( const Float_t f ) { fHiGainNumPickup   = f; }
+  void SetHiGainProb        ( const Float_t f ) { fHiGainProb        = f; }
+  void SetHiGainSigma       ( const Float_t f ) { fHiGainSigma       = f; }
+  void SetHiGainSigmaVar    ( const Float_t f ) { fHiGainSigmaVar    = f; }
+  void SetLoGainMean        ( const Float_t f ) { fLoGainMean        = f; }
+  void SetLoGainMeanVar     ( const Float_t f ) { fLoGainMeanVar     = f; }
+  void SetLoGainNumBlackout ( const Float_t f ) { fLoGainNumBlackout = f; }  
+  void SetLoGainNumPickup   ( const Float_t f ) { fLoGainNumPickup   = f; }
+  void SetLoGainProb        ( const Float_t f ) { fLoGainProb        = f; }
+  void SetLoGainSigma       ( const Float_t f ) { fLoGainSigma       = f; }
+  void SetLoGainSigmaVar    ( const Float_t f ) { fLoGainSigmaVar    = f; }
+  void SetMean       ( const Float_t f ) { IsHiGainSaturation() ? fLoGainMean        = f : fHiGainMean        = f      ; }
+  void SetMeanVar    ( const Float_t f ) { IsHiGainSaturation() ? fLoGainMeanVar     = f : fHiGainMeanVar     = f  ;  }
+  void SetNumBlackout( const Float_t f ) { IsHiGainSaturation() ? fLoGainNumBlackout = f : fHiGainNumBlackout = f ; }  
+  void SetNumPickup  ( const Float_t f ) { IsHiGainSaturation() ? fLoGainNumPickup   = f : fHiGainNumPickup   = f ; }
+  void SetProb       ( const Float_t f ) { IsHiGainSaturation() ? fLoGainProb        = f : fHiGainProb        = f      ; }
+  void SetSigma      ( const Float_t f ) { IsHiGainSaturation() ? fLoGainSigma       = f : fHiGainSigma       = f     ; }
+  void SetSigmaVar   ( const Float_t f ) { IsHiGainSaturation() ? fLoGainSigmaVar    = f : fHiGainSigmaVar    = f  ; }
+
+  void SetDebug           ( const Bool_t  b = kTRUE );  
+  void SetExcluded        ( const Bool_t  b = kTRUE );
+  void SetHiGainSaturation( const Bool_t  b = kTRUE );
+  void SetValid           ( const Bool_t  b = kTRUE );
+  
+  // Getters
+  Float_t GetHiGainMean       () const { return fHiGainMean   ;     }
+  Float_t GetHiGainMeanErr    () const;
+  Float_t GetHiGainProb       () const { return fHiGainProb   ;     }
+  Float_t GetHiGainSigma      () const { return fHiGainSigma  ;     }
+  Float_t GetHiGainSigmaErr   () const;
+  Float_t GetHiGainNumPickup  () const { return fHiGainNumPickup;   }
+  Float_t GetHiGainNumBlackout() const { return fHiGainNumBlackout; }  
+  Float_t GetHiLoMeansDivided         () const;
+  Float_t GetHiLoMeansDividedErr      () const;
+  Float_t GetHiLoSigmasDivided        () const;
+  Float_t GetHiLoSigmasDividedErr     () const;
+
+  virtual Float_t GetLoGainMean       () const { return fLoGainMean;        }
+  virtual Float_t GetLoGainMeanErr    () const;
+  virtual Float_t GetLoGainMeanRelVar () const;  
+  virtual Float_t GetLoGainProb       () const { return fLoGainProb;        }
+  virtual Float_t GetLoGainSigma      () const { return fLoGainSigma;       }
+  virtual Float_t GetLoGainSigmaErr   () const;
+  virtual Float_t GetLoGainNumPickup  () const { return fLoGainNumPickup;   }
+  virtual Float_t GetLoGainNumBlackout() const { return fLoGainNumBlackout; }  
+
+  Float_t GetMean       () const { return IsHiGainSaturation() ? GetLoGainMean()        : GetHiGainMean()     ;   }
+  Float_t GetMeanErr    () const { return IsHiGainSaturation() ? GetLoGainMeanErr()     : GetHiGainMeanErr()  ;   }
+  Float_t GetMeanRelVar () const;
+  Float_t GetMeanSquare () const;  
+  Float_t GetProb       () const { return IsHiGainSaturation() ? GetLoGainProb()        : GetHiGainProb()     ;   }
+  Float_t GetSigma      () const { return IsHiGainSaturation() ? GetLoGainSigma()       : GetHiGainSigma()    ;   }
+  Float_t GetSigmaErr   () const { return IsHiGainSaturation() ? GetLoGainSigmaErr()    : GetHiGainSigmaErr() ;   }
+  Float_t GetSigmaRelVar() const;
+  Float_t GetNumPickup  () const { return IsHiGainSaturation() ? GetLoGainNumPickup()   : GetHiGainNumPickup();   }
+  Float_t GetNumBlackout() const { return IsHiGainSaturation() ? GetLoGainNumBlackout() : GetHiGainNumBlackout(); }
+  Int_t   GetPixId      () const { return fPixId ;  }
+  
+  Bool_t  IsHiGainSaturation() const;
+  Bool_t  IsDebug   ()         const;
+  Bool_t  IsExcluded()         const;
+  Bool_t  IsValid   ()         const;
+
+  ClassDef(MCalibrationPix, 1)	// Base Container for Calibration Results Pixel
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationQECam.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationQECam.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationQECam.cc	(revision 9661)
@@ -0,0 +1,772 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+
+! *
+!
+!
+!   Author(s): Markus Gaug   02/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                               
+// MCalibrationQECam                                               
+//                                                               
+// Storage container for the calibrated Quantum Efficiency of the whole camera.
+//
+// For a complete description of the quantum efficiency calibration process, 
+// see MCalibrationQEPix.
+//
+// Individual pixels have to be cast when retrieved e.g.:
+// MCalibrationQEPix &avpix = (MCalibrationQEPix&)(*fQECam)[i]
+// 
+// Averaged values over one whole area index (e.g. inner or outer pixels for 
+// the MAGIC camera), can be retrieved via: 
+// MCalibrationQEPix &avpix = (MCalibrationQEPix&)fQECam->GetAverageArea(i)
+//
+// Averaged values over one whole camera sector can be retrieved via: 
+// MCalibrationQEPix &avpix = (MCalibrationQEPix&)fQECam->GetAverageSector(i)
+//
+// The following "calibration" constants are used for the calibration of each pixel:
+//
+// - MCalibrationQEPix::GetQECascadesBlindPixel(): The mean quantum efficiency folded 
+//   into a cascades spectrum obtained with the Blind Pixel Method. 
+// - MCalibrationQEPix::GetQECascadesFFactor(): The mean quantum efficiency folded 
+//   into a cascades spectrum obtained with the F-Factor Method
+// - MCalibrationQEPix::GetQECascadesPINDiode(): The mean quantum efficiency folded 
+//   into a cascades spectrum obtained with the PIN Diode Method
+// - MCalibrationQEPix::GetQECascadesCombined(): The mean quantum efficiency folded 
+//   into a cascades spectrum obtained with the combination of the three methods
+//
+// The following "calibration" constants have been measured to obtain the above values:
+//
+// - MCalibrationQEPix::GetQEBlindPixel( MCalibrationCam::PulserColor_t color ): 
+//   The mean quantum efficiency obtained with the calibration pulser color 
+//   (e.g. kGREEN, kBLUE, kUV, kCT1) after the Blind Pixel Method
+// - MCalibrationQEPix::GetQEFFactor( MCalibrationCam::PulserColor_t color ): 
+//   The mean quantum efficiency obtained with the calibration pulser color
+//   (e.g. kGREEN, kBLUE, kUV, kCT1) after the F-Factor Method
+// - MCalibrationQEPix::GetQEPINDiode( MCalibrationCam::PulserColor_t color ): 
+//   The mean quantum efficiency obtained with the calibration pulser color 
+//   (e.g. kGREEN, kBLUE, kUV, kCT1) after the PIN Diode Method
+// - MCalibrationQEPix::GetQECombined( MCalibrationCam::PulserColor_t color ): 
+//   The mean quantum efficiency obtained with the calibration pulser color 
+//   (e.g. kGREEN, kBLUE, kUV, kCT1) after the combination of the three methods
+//
+// See also: MCalibrationQEPix, MCalibrationChargeCam, MCalibrationChargeCalc
+//           MCalibrationChargeBlindPix, MCalibrationChargePINDiode, MCalibrationChargePix
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCalibrationQECam.h"
+#include "MCalibrationCam.h"
+
+#include <TClonesArray.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MCalibrationQEPix.h"
+
+ClassImp(MCalibrationQECam);
+
+using namespace std;
+
+const Float_t MCalibrationQECam::gkPlexiglassQE         = 0.96;
+const Float_t MCalibrationQECam::gkPlexiglassQEErr      = 0.01;
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+// Creates a TClonesArray of MCalibrationQEPix containers, initialized to 1 entry, destinated 
+// to hold one container per pixel. Later, a call to MCalibrationQECam::InitSize() 
+// has to be performed (in MGeomApply). 
+//
+// Creates a TClonesArray of MCalibrationQEPix containers, initialized to 1 entry, destinated 
+// to hold one container per pixel AREA. Later, a call to MCalibrationQECam::InitAreas() 
+// has to be performed (in MGeomApply). 
+//
+// Creates a TClonesArray of MCalibrationQEPix containers, initialized to 1 entry, destinated
+// to hold one container per camera SECTOR. Later, a call to MCalibrationQECam::InitSectors() 
+// has to be performed (in MGeomApply). 
+//
+MCalibrationQECam::MCalibrationQECam(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MCalibrationQECam";
+    fTitle = title ? title : "Storage container for the calibrated Quantrum Efficiency of the camera";
+
+    fPixels           = new TClonesArray("MCalibrationQEPix",1);
+    fAverageAreas     = new TClonesArray("MCalibrationQEPix",1);
+    fAverageSectors   = new TClonesArray("MCalibrationQEPix",1);
+
+    fFlags.Set(MCalibrationCam::gkNumPulserColors);
+
+    Clear();
+}
+
+// ------------------------------------------------------------------------
+//
+// Sets all bits to kFALSE
+// 
+// Calls:
+// - MCalibrationCam::Clear()
+//
+void MCalibrationQECam::Clear(Option_t *o)
+{
+
+  SetBlindPixelMethodValid ( kFALSE, MCalibrationCam::kGREEN);
+  SetFFactorMethodValid    ( kFALSE, MCalibrationCam::kGREEN);
+  SetCombinedMethodValid   ( kFALSE, MCalibrationCam::kGREEN);
+  SetPINDiodeMethodValid   ( kFALSE, MCalibrationCam::kGREEN);
+  SetBlindPixelMethodValid ( kFALSE, MCalibrationCam::kBLUE);
+  SetFFactorMethodValid    ( kFALSE, MCalibrationCam::kBLUE);
+  SetCombinedMethodValid   ( kFALSE, MCalibrationCam::kBLUE);
+  SetPINDiodeMethodValid   ( kFALSE, MCalibrationCam::kBLUE);
+  SetBlindPixelMethodValid ( kFALSE, MCalibrationCam::kUV);
+  SetFFactorMethodValid    ( kFALSE, MCalibrationCam::kUV);
+  SetCombinedMethodValid   ( kFALSE, MCalibrationCam::kUV);
+  SetPINDiodeMethodValid   ( kFALSE, MCalibrationCam::kUV);
+  SetBlindPixelMethodValid ( kFALSE, MCalibrationCam::kCT1);
+  SetFFactorMethodValid    ( kFALSE, MCalibrationCam::kCT1);
+  SetCombinedMethodValid   ( kFALSE, MCalibrationCam::kCT1);
+  SetPINDiodeMethodValid   ( kFALSE, MCalibrationCam::kCT1);
+
+  MCalibrationCam::Clear();
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Not yet implemented
+//
+void MCalibrationQECam::DrawPixelContent(Int_t idx) const
+{
+  return;
+}
+
+// --------------------------------------------------------------------
+//
+// Types used by MCalibrate and MCalibrateData: 
+// ============================================
+//
+// 0: Mean Quantum Efficiency for cascades, obtained with the F-Factor method
+// 1: Error of the Mean QE for cascades, obtained with the F-Factor method
+// 2: Mean Quantum Efficiency for cascades, obtained with the Blind Pixel method
+// 3: Error of the Mean QE for cascades, obtained with the Blind Pixel method
+// 4: Mean Quantum Efficiency for cascades, obtained with the PIN Diode method
+// 5: Error of the Mean QE for cascades, obtained with the PIN Diode method
+// 6: Mean Quantum Efficiency for cascades, obtained with combination of the 3 methods
+// 7: Error of the Mean QE for cascades, obtained with combination of the 3 methods
+// 8: Availabiliy of Quantum Efficiency for cascades, F-Factor method
+// 9: Availabiliy of Quantum Efficiency for cascades, F-Factor method
+// 10: Availabiliy of Quantum Efficiency for cascades, F-Factor method
+// 11: Availabiliy of Quantum Efficiency for cascades, F-Factor method
+//
+// Types filled by MCalibrationChargeCalc in combination of MCalibrationChargePix:
+// ===============================================================================
+//
+// 12: Mean Quantum Efficiency obtained with F-Factor Method ( color: kCT1)
+// 13: Error of the Mean QE obtained with F-Factor Method ( color: kCT1)
+// 14: Mean Quantum Efficiency obtained with F-Factor Method ( color: kGREEN)
+// 15: Error of the Mean QE obtained with F-Factor Method ( color: kGREEN)
+// 16: Mean Quantum Efficiency obtained with F-Factor Method ( color: kBLUE)
+// 17: Error of the Mean QE obtained with F-Factor Method ( color: kBLUE)
+// 18: Mean Quantum Efficiency obtained with F-Factor Method ( color: kUV)
+// 19: Error of the Mean QE obtained with F-Factor Method ( color: kUV)
+//
+// Types filled by MCalibrationChargeCalc in combination of MCalibrationChargeBlindPix:
+// ====================================================================================
+//
+// 20: Mean Quantum Efficiency obtained with Blind Pixel Method ( color: kCT1)
+// 21: Error of the Mean QE obtained with Blind Pixel Method ( color: kCT1)
+// 22: Mean Quantum Efficiency obtained with Blind Pixel Method ( color: kGREEN)
+// 23: Error of the Mean QE obtained with Blind Pixel Method ( color: kGREEN)
+// 24: Mean Quantum Efficiency obtained with Blind Pixel Method ( color: kBLUE)
+// 25: Error of the Mean QE obtained with Blind Pixel Method ( color: kBLUE)
+// 26: Mean Quantum Efficiency obtained with Blind Pixel Method ( color: kUV)
+// 27: Error of the Mean QE obtained with Blind Pixel Method ( color: kUV)
+//
+// Types filled by MCalibrationChargeCalc in combination of MCalibrationChargePINDiode:
+// ====================================================================================
+//
+// 28: Mean Quantum Efficiency obtained with PIN Diode Method ( color: kCT1)
+// 29: Error of the Mean QE obtained with PIN Diode Method ( color: kCT1)
+// 30: Mean Quantum Efficiency obtained with PIN Diode Method ( color: kGREEN)
+// 31: Error of the Mean QE obtained with PIN Diode Method ( color: kGREEN)
+// 32: Mean Quantum Efficiency obtained with PIN Diode Method ( color: kBLUE)
+// 33: Error of the Mean QE obtained with PIN Diode Method ( color: kBLUE)
+// 34: Mean Quantum Efficiency obtained with PIN Diode Method ( color: kUV)
+// 35: Error of the Mean QE obtained with PIN Diode Method ( color: kUV)
+//
+// Types filled by MCalibrationChargeCalc in combination of MCalibrationQEPix:
+// ===========================================================================
+//
+// 36: Mean Quantum Efficiency obtained with combination of 3 methods ( color: kCT1)
+// 37: Error of the Mean QE obtained with combination of 3 methods ( color: kCT1)
+// 38: Mean Quantum Efficiency obtained with combination of 3 methods ( color: kGREEN)
+// 39: Error of the Mean QE obtained with combination of 3 methods ( color: kGREEN)
+// 40: Mean Quantum Efficiency obtained with combination of 3 methods ( color: kBLUE)
+// 41: Error of the Mean QE obtained with combination of 3 methods ( color: kBLUE)
+// 42: Mean Quantum Efficiency obtained with combination of 3 methods ( color: kUV)
+// 43: Error of the Mean QE obtained with combination of 3 methods ( color: kUV)
+//
+Bool_t MCalibrationQECam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
+{
+
+  if (idx > GetSize())
+    return kFALSE;
+
+  MCalibrationQEPix &pix = (MCalibrationQEPix&)(*this)[idx];
+
+  if (pix.IsExcluded())
+    return kFALSE;
+
+  switch (type)
+    {
+    case 0:
+      if (!pix.IsAverageQEFFactorAvailable())
+        return kFALSE;
+      val = pix.GetQECascadesFFactor();
+      break;
+    case 1:
+      if (!pix.IsAverageQEFFactorAvailable())
+        return kFALSE;
+      val = pix.GetQECascadesFFactorErr();
+      break;
+    case 2:
+      if (!pix.IsAverageQEBlindPixelAvailable())
+        return kFALSE;
+      val = pix.GetQECascadesBlindPixel();
+      break;
+    case 3:
+      if (!pix.IsAverageQEBlindPixelAvailable())
+        return kFALSE;
+      val = pix.GetQECascadesBlindPixelErr();
+      break;
+    case 4:
+      if (!pix.IsAverageQEPINDiodeAvailable())
+        return kFALSE;
+      val = pix.GetQECascadesPINDiode();
+      break;
+    case 5:
+      if (!pix.IsAverageQEPINDiodeAvailable())
+        return kFALSE;
+      val = pix.GetQECascadesPINDiodeErr();
+      break;
+    case 6:
+      if (!pix.IsAverageQECombinedAvailable())
+        return kFALSE;
+      val = pix.GetQECascadesCombined();
+      break;
+    case 7:
+      if (!pix.IsAverageQECombinedAvailable())
+        return kFALSE;
+      val = pix.GetQECascadesCombinedErr();
+      break;
+    case 8:
+      if (pix.IsAverageQEFFactorAvailable())
+        val = 1;
+      else
+        return kFALSE;
+      break;
+    case 9:
+      if (pix.IsAverageQEBlindPixelAvailable())
+        val = 1;
+      else
+        return kFALSE;
+      break;
+    case 10:
+      if (pix.IsAverageQEPINDiodeAvailable())
+        val = 1;
+      else
+        return kFALSE;
+      break;
+    case 11:
+      if (pix.IsAverageQECombinedAvailable())
+        val = 1;
+      else
+        return kFALSE;
+      break;
+    case 12:
+      val = pix.GetQEFFactor(kCT1);
+      break;
+    case 13:
+      val = pix.GetQEFFactorErr(kCT1);
+      break;
+    case 14:
+      val = pix.GetQEFFactor(kGREEN);
+      break;
+    case 15:
+      val = pix.GetQEFFactorErr(kGREEN);
+      break;
+    case 16:
+      val = pix.GetQEFFactor(kBLUE);
+      break;
+    case 17:
+      val = pix.GetQEFFactorErr(kBLUE);
+      break;
+    case 18:
+      val = pix.GetQEFFactor(kUV);
+      break;
+    case 19:
+      val = pix.GetQEFFactorErr(kUV);
+      break;
+    case 20:
+      val = pix.GetQEBlindPixel(kCT1);
+      break;
+    case 21:
+      val = pix.GetQEBlindPixelErr(kCT1);
+      break;
+    case 22:
+      val = pix.GetQEBlindPixel(kGREEN);
+      break;
+    case 23:
+      val = pix.GetQEBlindPixelErr(kGREEN);
+      break;
+    case 24:
+      val = pix.GetQEBlindPixel(kBLUE);
+      break;
+    case 25:
+      val = pix.GetQEBlindPixelErr(kBLUE);
+      break;
+    case 26:
+      val = pix.GetQEBlindPixel(kUV);
+      break;
+    case 27:
+      val = pix.GetQEBlindPixelErr(kUV);
+      break;
+    case 28:
+      val = pix.GetQEPINDiode(kCT1);
+      break;
+    case 29:
+      val = pix.GetQEPINDiodeErr(kCT1);
+      break;
+    case 30:
+      val = pix.GetQEPINDiode(kGREEN);
+      break;
+    case 31:
+      val = pix.GetQEPINDiodeErr(kGREEN);
+      break;
+    case 32:
+      val = pix.GetQEPINDiode(kBLUE);
+      break;
+    case 33:
+      val = pix.GetQEPINDiodeErr(kBLUE);
+      break;
+    case 34:
+      val = pix.GetQEPINDiode(kUV);
+      break;
+    case 35:
+      val = pix.GetQEPINDiodeErr(kUV);
+      break;
+    case 36:
+      val = pix.GetQECombined(kCT1);
+      break;
+    case 37:
+      val = pix.GetQECombinedErr(kCT1);
+      break;
+    case 38:
+      val = pix.GetQECombined(kGREEN);
+      break;
+    case 39:
+      val = pix.GetQECombinedErr(kGREEN);
+      break;
+    case 40:
+      val = pix.GetQECombined(kBLUE);
+      break;
+    case 41:
+      val = pix.GetQECombinedErr(kBLUE);
+      break;
+    case 42:
+      val = pix.GetQECombined(kUV);
+      break;
+    case 43:
+      val = pix.GetQECombinedErr(kUV);
+      break;
+    default:
+      return kFALSE;
+    }
+  return val!=-1.;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return -1 if gkPlexiglassQEErr is smaller than 0.
+// Return -1 if gkPlexiglassQE    is 0.
+// Return gkPlexiglassQEErr^2 / gkPlexiglassQE^2
+// 
+Float_t MCalibrationQECam::GetPlexiglassQERelVar() const
+{
+  if (gkPlexiglassQEErr < 0.)
+    return -1.;
+  
+  if (gkPlexiglassQE  == 0.)
+    return -1.;
+  
+  return gkPlexiglassQEErr * gkPlexiglassQEErr / gkPlexiglassQE / gkPlexiglassQE ;
+}
+
+
+// --------------------------------------------------------------------------------
+//
+// Returns kTRUE if ANY of the four colours have the bit kBlindPixelMethodValid set,
+// otherwise kFALSE
+// 
+Bool_t MCalibrationQECam::IsBlindPixelMethodValid () const  
+{
+  if (IsBlindPixelMethodValid (MCalibrationCam::kGREEN))
+    return kTRUE;
+  if (IsBlindPixelMethodValid (MCalibrationCam::kBLUE ))
+    return kTRUE;
+  if (IsBlindPixelMethodValid (MCalibrationCam::kUV   ))
+    return kTRUE;
+  if (IsBlindPixelMethodValid (MCalibrationCam::kCT1  ))
+    return kTRUE;
+
+  return kFALSE;
+}
+
+// --------------------------------------------------------------------------------
+//
+// Returns kTRUE if ANY of the four colours have the bit kCombinedMethodValid set,
+// otherwise kFALSE
+// 
+Bool_t MCalibrationQECam::IsCombinedMethodValid () const
+{
+  if (IsCombinedMethodValid (MCalibrationCam::kGREEN))
+    return kTRUE;
+  if (IsCombinedMethodValid (MCalibrationCam::kBLUE ))
+    return kTRUE;
+  if (IsCombinedMethodValid (MCalibrationCam::kUV   ))
+    return kTRUE;
+  if (IsCombinedMethodValid (MCalibrationCam::kCT1  ))
+    return kTRUE;
+
+  return kFALSE;
+}
+
+// --------------------------------------------------------------------------------
+//
+// Returns kTRUE if ANY of the four colours have the bit kFFactorMethodValid set,
+// otherwise kFALSE
+// 
+Bool_t MCalibrationQECam::IsFFactorMethodValid () const
+{
+  if (IsFFactorMethodValid (MCalibrationCam::kGREEN))
+    return kTRUE;
+  if (IsFFactorMethodValid (MCalibrationCam::kBLUE ))
+    return kTRUE;
+  if (IsFFactorMethodValid (MCalibrationCam::kUV   ))
+    return kTRUE;
+  if (IsFFactorMethodValid (MCalibrationCam::kCT1  ))
+    return kTRUE;
+
+  return kFALSE;
+}
+
+
+// --------------------------------------------------------------------------------
+//
+// Returns kTRUE if ANY of the four colours have the bit kPINDiodeMethodValid set,
+// otherwise kFALSE
+// 
+Bool_t MCalibrationQECam::IsPINDiodeMethodValid () const
+{
+  if (IsPINDiodeMethodValid (MCalibrationCam::kGREEN))
+    return kTRUE;
+  if (IsPINDiodeMethodValid (MCalibrationCam::kBLUE ))
+    return kTRUE;
+  if (IsPINDiodeMethodValid (MCalibrationCam::kUV   ))
+    return kTRUE;
+  if (IsPINDiodeMethodValid (MCalibrationCam::kCT1  ))
+    return kTRUE;
+
+  return kFALSE;
+}
+
+// --------------------------------------------------------------------------------
+//
+// Returns kTRUE if ANY of the bit kBlindPixelMethodValid is set for colour "col"
+// otherwise kFALSE
+// 
+Bool_t MCalibrationQECam::IsBlindPixelMethodValid (MCalibrationCam::PulserColor_t col)  const
+{
+  return TESTBIT(fFlags[ MCalibrationCam::kGREEN ],kBlindPixelMethodValid);
+}
+
+// --------------------------------------------------------------------------------
+//
+// Returns kTRUE if ANY of the bit kCombinedMethodValid is set for colour "col"
+// otherwise kFALSE
+// 
+Bool_t MCalibrationQECam::IsCombinedMethodValid (MCalibrationCam::PulserColor_t col)  const
+{
+  return TESTBIT(fFlags[ MCalibrationCam::kGREEN ],kCombinedMethodValid);
+}
+
+// --------------------------------------------------------------------------------
+//
+// Returns kTRUE if ANY of the bit kFFactorMethodValid is set for colour "col"
+// otherwise kFALSE
+// 
+Bool_t MCalibrationQECam::IsFFactorMethodValid (MCalibrationCam::PulserColor_t col)  const
+{
+  return TESTBIT(fFlags[ MCalibrationCam::kGREEN ],kFFactorMethodValid);
+}
+
+// --------------------------------------------------------------------------------
+//
+// Returns kTRUE if ANY of the bit kPINDiodeMethodValid is set for colour "col"
+// otherwise kFALSE
+// 
+Bool_t MCalibrationQECam::IsPINDiodeMethodValid (MCalibrationCam::PulserColor_t col)  const
+{
+  return TESTBIT(fFlags[ MCalibrationCam::kGREEN ],kPINDiodeMethodValid);
+}
+
+// --------------------------------------------------------------------------
+//
+// Print the 
+// - MCalibrationQEPix::GetQECascadesFFactor() 
+// - MCalibrationQEPix::GetQECascadesBlindPixel() 
+// - MCalibrationQEPix::GetQECascadesPINDiode() 
+// - MCalibrationQEPix::GetQECascadesCombined()
+// for all pixels 
+//
+void MCalibrationQECam::Print(Option_t *o) const
+{
+
+  *fLog << all << GetDescriptor() << ":" << endl;
+  int id = 0;
+  
+  *fLog << all << endl;
+  *fLog << all << "Quantum Efficiencies averaged over cascades spectra, measured with F-Factor method:" << endl;
+  *fLog << all << endl;
+
+  TIter Next(fPixels);
+  MCalibrationQEPix *pix;
+  while ((pix=(MCalibrationQEPix*)Next()))
+    {
+      
+      if (!pix->IsExcluded() && pix->IsAverageQEFFactorAvailable()) 
+	{
+          *fLog << all 
+                << Form("%s%4i%s%4.2f%s%4.2f","Pix  ",pix->GetPixId(),
+                        ":  QE: ",pix->GetQECascadesFFactor()," +- ",pix->GetQECascadesFFactorErr())
+		<< endl;
+          id++;
+	}
+    }
+  
+  *fLog << all << id << " succesful pixels :-))" << endl;
+  id = 0;
+  
+  *fLog << all << endl;
+  *fLog << all << "Quantum Efficiencies averaged over cascades spectra, " 
+        << "measured with Blind Pixel method:" << endl;
+  *fLog << all << endl;
+  
+  TIter Next2(fPixels);
+    while ((pix=(MCalibrationQEPix*)Next2()))
+      {
+        
+      if (!pix->IsExcluded() && pix->IsAverageQEBlindPixelAvailable()) 
+	{
+          *fLog << all 
+                << Form("%s%4i%s%4.2f%s%4.2f","Pix  ",pix->GetPixId(),
+                        ":  QE: ",pix->GetQECascadesBlindPixel()," +- ",pix->GetQECascadesBlindPixelErr())
+		<< endl;
+          id++;
+	}
+      }
+
+  *fLog << all << id << " succesful pixels :-))" << endl;
+  id = 0;
+  
+  *fLog << all << endl;
+  *fLog << all << "Quantum Efficiencies averaged over cascades spectra, " 
+        << "measured with PIN Diode method:" << endl;
+  *fLog << all << endl;
+  
+  TIter Next3(fPixels);
+    while ((pix=(MCalibrationQEPix*)Next3()))
+      {
+        
+      if (!pix->IsExcluded() && pix->IsAverageQEPINDiodeAvailable()) 
+	{
+          *fLog << all 
+                << Form("%s%4i%s%4.2f%s%4.2f","Pix  ",pix->GetPixId(),
+                        ":  QE: ",pix->GetQECascadesPINDiode()," +- ",pix->GetQECascadesPINDiodeErr())
+		<< endl;
+          id++;
+	}
+      }
+
+  *fLog << all << id << " succesful pixels :-))" << endl;
+  id = 0;
+
+    
+  *fLog << all << endl;
+  *fLog << all << "Quantum Efficiencies averaged over cascades spectra, " 
+        << "measured with combination of the 3 methods:" << endl;
+  *fLog << all << endl;
+  
+  TIter Next4(fPixels);
+    while ((pix=(MCalibrationQEPix*)Next4()))
+      {
+        
+      if (!pix->IsExcluded() && pix->IsAverageQECombinedAvailable()) 
+	{
+          *fLog << all 
+                << Form("%s%4i%s%4.2f%s%4.2f","Pix  ",pix->GetPixId(),
+                        ":  QE: ",pix->GetQECascadesCombined()," +- ",pix->GetQECascadesCombinedErr())
+		<< endl;
+          id++;
+	}
+      }
+
+  *fLog << all << id << " succesful pixels :-))" << endl;
+  id = 0;
+
+  *fLog << all << endl;
+  *fLog << all << "Excluded pixels:" << endl;
+  *fLog << all << endl;
+  
+  TIter Next5(fPixels);
+  while ((pix=(MCalibrationQEPix*)Next5()))
+  {
+      if (pix->IsExcluded())
+      {
+	  *fLog << all << pix->GetPixId() << endl;
+	  id++;
+      }
+  }
+  *fLog << all << id << " Excluded pixels " << endl;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Sets the validity flag (according to b) for the Blind Pixel Method, 
+// for all colours (kGREEN, kBLUE, kUV, kCT1)
+// 
+void MCalibrationQECam::SetBlindPixelMethodValid ( const Bool_t b ) 
+{
+  SetBlindPixelMethodValid ( b, MCalibrationCam::kGREEN);
+  SetBlindPixelMethodValid ( b, MCalibrationCam::kBLUE );
+  SetBlindPixelMethodValid ( b, MCalibrationCam::kUV   );
+  SetBlindPixelMethodValid ( b, MCalibrationCam::kCT1  );
+}
+
+// ----------------------------------------------------------------------------
+//
+// Sets the validity flag (according to b) for the combination of the 3 methods
+// for all colours (kGREEN, kBLUE, kUV, kCT1)
+// 
+void MCalibrationQECam::SetCombinedMethodValid ( const Bool_t b ) 
+{
+  SetCombinedMethodValid ( b, MCalibrationCam::kGREEN);
+  SetCombinedMethodValid ( b, MCalibrationCam::kBLUE );
+  SetCombinedMethodValid ( b, MCalibrationCam::kUV   );
+  SetCombinedMethodValid ( b, MCalibrationCam::kCT1  );
+}
+
+// --------------------------------------------------------------------------
+//
+// Sets the validity flag (according to b) for the F-Factor Method
+// for all colours (kGREEN, kBLUE, kUV, kCT1)
+// 
+void MCalibrationQECam::SetFFactorMethodValid ( const Bool_t b ) 
+{
+  SetFFactorMethodValid ( b, MCalibrationCam::kGREEN);
+  SetFFactorMethodValid ( b, MCalibrationCam::kBLUE );
+  SetFFactorMethodValid ( b, MCalibrationCam::kUV   );
+  SetFFactorMethodValid ( b, MCalibrationCam::kCT1  );
+}
+
+// --------------------------------------------------------------------------
+//
+// Sets the validity flag (according to b) for the PIN Diode Method, 
+// for all colours (kGREEN, kBLUE, kUV, kCT1)
+// 
+void MCalibrationQECam::SetPINDiodeMethodValid ( const Bool_t b ) 
+{
+  SetPINDiodeMethodValid ( b, MCalibrationCam::kGREEN);
+  SetPINDiodeMethodValid ( b, MCalibrationCam::kBLUE );
+  SetPINDiodeMethodValid ( b, MCalibrationCam::kUV   );
+  SetPINDiodeMethodValid ( b, MCalibrationCam::kCT1  );
+}
+
+// --------------------------------------------------------------------------
+//
+// Sets the validity flag (according to b) for the Blind Pixel Method, 
+// for colour "col"
+// 
+void MCalibrationQECam::SetBlindPixelMethodValid ( const Bool_t b,  MCalibrationCam::PulserColor_t col ) 
+{
+  if (b) 
+    SETBIT(fFlags[ MCalibrationCam::kGREEN ],kBlindPixelMethodValid);
+  else
+    CLRBIT(fFlags[ MCalibrationCam::kGREEN ],kBlindPixelMethodValid);    
+}
+
+// --------------------------------------------------------------------------
+//
+// Sets the validity flag (according to b) for the combination of 3 methods
+// for colour "col"
+// 
+void MCalibrationQECam::SetCombinedMethodValid ( const Bool_t b,  MCalibrationCam::PulserColor_t col ) 
+{
+  if (b) 
+    SETBIT(fFlags[ MCalibrationCam::kGREEN ],kCombinedMethodValid);
+  else
+    CLRBIT(fFlags[ MCalibrationCam::kGREEN ],kCombinedMethodValid);    
+}
+
+// --------------------------------------------------------------------------
+//
+// Sets the validity flag (according to b) for the F-Factor Method, 
+// for colour "col"
+// 
+void MCalibrationQECam::SetFFactorMethodValid ( const Bool_t b,  MCalibrationCam::PulserColor_t col ) 
+{
+  if (b) 
+    SETBIT(fFlags[ MCalibrationCam::kGREEN ],kFFactorMethodValid);
+  else
+    CLRBIT(fFlags[ MCalibrationCam::kGREEN ],kFFactorMethodValid);    
+}
+
+// --------------------------------------------------------------------------
+//
+// Sets the validity flag (according to b) for the PIN Diode Method, 
+// for colour "col"
+// 
+void MCalibrationQECam::SetPINDiodeMethodValid ( const Bool_t b,  MCalibrationCam::PulserColor_t col ) 
+{
+  if (b) 
+    SETBIT(fFlags[ MCalibrationCam::kGREEN ],kPINDiodeMethodValid);
+  else
+    CLRBIT(fFlags[ MCalibrationCam::kGREEN ],kPINDiodeMethodValid);    
+}
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationQECam.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationQECam.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationQECam.h	(revision 9661)
@@ -0,0 +1,69 @@
+#ifndef MARS_MCalibrationQECam
+#define MARS_MCalibrationQECam
+
+#ifndef MARS_MCalibrationCam
+#include "MCalibrationCam.h"
+#endif
+
+#ifndef ROOT_TArrayC
+#include "TArrayC.h"
+#endif
+
+class MCalibrationQECam : public MCalibrationCam
+{
+private:
+
+  static const Float_t gkPlexiglassQE   ;  //! Quantum Efficiency Plexiglass (now set to: 0.96)
+  static const Float_t gkPlexiglassQEErr;  //! Uncertainty QE Plexiglass     (now set to: 0.01)
+
+  TArrayC fFlags;
+
+  enum { kBlindPixelMethodValid, kFFactorMethodValid,
+         kPINDiodeMethodValid, kCombinedMethodValid };
+
+public:
+
+  MCalibrationQECam(const char *name=NULL, const char *title=NULL);
+  ~MCalibrationQECam() {}
+
+  void    Clear( Option_t *o="");
+  
+  // Others
+  void    DrawPixelContent( Int_t num ) const;    
+  Bool_t  GetPixelContent ( Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0 ) const;
+
+  Float_t GetPlexiglassQE          () const { return gkPlexiglassQE; }
+  Float_t GetPlexiglassQERelVar    () const; 
+
+  Bool_t  IsBlindPixelMethodValid  () const;
+  Bool_t  IsFFactorMethodValid     () const;  
+  Bool_t  IsCombinedMethodValid    () const;  
+  Bool_t  IsPINDiodeMethodValid    () const;  
+          
+  Bool_t  IsBlindPixelMethodValid  ( MCalibrationCam::PulserColor_t col ) const;
+  Bool_t  IsFFactorMethodValid     ( MCalibrationCam::PulserColor_t col ) const;  
+  Bool_t  IsCombinedMethodValid    ( MCalibrationCam::PulserColor_t col ) const;  
+  Bool_t  IsPINDiodeMethodValid    ( MCalibrationCam::PulserColor_t col ) const;  
+
+  // Prints
+  void    Print(Option_t *o="")       const;
+  
+  // Setters (without color only for MC!)
+  void    SetBlindPixelMethodValid ( const Bool_t  b=kTRUE );
+  void    SetBlindPixelMethodValid ( const Bool_t  b, MCalibrationCam::PulserColor_t col);
+  void    SetCombinedMethodValid   ( const Bool_t  b=kTRUE );
+  void    SetCombinedMethodValid   ( const Bool_t  b, MCalibrationCam::PulserColor_t col);
+  void    SetFFactorMethodValid    ( const Bool_t  b=kTRUE );  
+  void    SetFFactorMethodValid    ( const Bool_t  b, MCalibrationCam::PulserColor_t col);  
+  void    SetPINDiodeMethodValid   ( const Bool_t  b=kTRUE );  
+  void    SetPINDiodeMethodValid   ( const Bool_t  b, MCalibrationCam::PulserColor_t col);  
+
+  ClassDef(MCalibrationQECam, 1) // Container Quantum Efficieny Calibration Results Camera
+};
+
+#endif
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationQEPix.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationQEPix.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationQEPix.cc	(revision 9661)
@@ -0,0 +1,1357 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug   02/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                      
+// MCalibrationQEPix                                                    
+//                                                                      
+// Storage container of the calibrated Quantrum Efficiency of one pixel. 
+// This container (like MCalibrationQECam) is designed to persist during 
+// several eventloops over different calibration files, especially those 
+// with different colour LEDs. This class contains all measured Quantum 
+// Efficiencies with the calibration system for each individual pixel.
+// 
+// At the moment, this calibration works in the following steps:
+//
+// 1)  MHCalibrationChargeCam extracts mean and sigma (and its errors) of 
+//     the summed FADC slices distribution and stores them in MCalibrationCam 
+//     
+// 2)  MHCalibrationChargeBlindPix extracts the mean of a Poisson fit to the 
+//     single photo-electron spectrum and stores it in MCalibrationChargeBlindPix
+//     
+// 3)  MHCalibrationChargePINDiode extracts the mean of a charge distribution 
+//     of the signals collected by the PIN Diode and stores it in 
+//     MCalibrationChargePINDiode
+//     
+// 4)  MCalibrationChargeCalc calculates for every pixel the number of 
+//     photo-electrons with the F-Factor method and stores them in MCalibrationChargePix
+//
+// 5)  MCalibrationChargeCalc calculates the (weighted) average number of photo-
+//     electrons from the pixels with the area index 0 (Inner pixels for the MAGIC 
+//     camera) and divides this number by gkDefaultQEGreen, gkDefaultQEBlue, 
+//     gkDefaultQEUV or gkDefaultQECT1, depending on the used pulser LED colour, 
+//     and further by MCalibrationQECam::gkPlexiglassQE. The obtained number is then 
+//     divided further by MGeomCam::GetPixRatio(pixel idx) (1. for inner pixels) and 
+//     gives the NUMBER OF PHOTONS incident on every pixel light guide OUTSIDE THE PLEXIGLASS 
+//     of the camera, obtained with the F-Factor method. (In the case of the MAGIC camera, 
+//     this number is thus BY CONSTRUCTION four times bigger for the outer pixels than for 
+//     the inner ones.)
+//
+// 6)  MCalibrationChargeCalc calculates the mean photon flux per mm^2 in the camera 
+//     from the MCalibrationChargeBlindPix and multiplies it with the light guides area 
+//     of each pixel (MGeomPix::GetA()) and divides it by the quantum efficiency of the 
+//     plexi-glass (MCalibrationQECam::gkPlexiglassQE). The obtained number gives the 
+//     NUMBER OF PHOTONS incident on every pixel light guide OUTSIDE THE PLEXIGLASS of the camera, 
+//     obtained with the Blind Pixel method. 
+//
+// 7)  MCalibrationChargeCalc calculates the mean photon flux per mm^2 in the camera 
+//     from the MCalibrationChargePINDiode and multiplies it with the light guides area 
+//     of each pixel (MGeomPix::GetA()).  The obtained number gives the NUMBER OF PHOTONS 
+//     incident on every pixels light guid OUTSIDE THE PLEXIGLASS of the camera, 
+//     obtained with the PIN Diode method. 
+//
+// 8)  Each of the three photons numbers is divided by the mean sum of FADC counts 
+//     and defined as MEASURED QUANTUM EFFICIENCY AT A GIVEN COLOUR. They are stored 
+//     in the variables SetQEBlindPixel(qe, color), SetQEFFactor(qe,color) and 
+//     SetQEPINDiode(qe,color) 
+//
+// 9)  Errors are propagated and corresponding variances get stored in 
+//     SetQEBlindPixelVar(var,color), SetQEFFactorVar(var,color) and 
+//     SetQEPINDiodeVar(var,color).
+//
+// 10) After every eventloop, MCalibrationChargeCalc calls the functions UpdateBlindPixelMethod(),
+//     UpdateFFactorMethod() and UpdatePINDiodeMethod() which calculate the ratio 
+//     measured QE / gkDefaultQEGreen (or gkDefaultQEBlue or gkDefaultQEUV or gkDefaultQECT1) 
+//     and calculates an weighted average of these quantum-efficiency normalizations obtained
+//     by one of the three methods.
+//
+// 11) A call to GetQECascadesBlindPixel(zenith), GetQECascadesFFactor(zenith) or 
+//     GetQECascadesPINDiode(zenith) returns then the normalization multiplied with an average QE 
+//     folded into a cascades spectrum. This number should be dependent on zenith angle, but 
+//     this feature is not yet implemented, instead a fixed number gkDefaultAverageQE is used. 
+// 
+// The number gkDefaultAverageQE = 0.18 +- 0.02 can be obtained in the following way: 
+//
+// * Transmission probability Plexiglass: 0.96
+//
+// * Averaged QE coated PMTs: zenith     value
+//                              0.       0.237
+//                             20.       0.237
+//                             40.       0.236
+//                             60.       0.234
+// (from D.Paneque et al., NIM A 504, 2003, 109-115, see following figure with the 
+//  photon spectra at 2200 m altitude:)
+//
+//Begin_Html
+/*
+<img src="images/Photon_spectrum.png">
+*/
+//End_Html
+// 
+// * PMT photoelectron collection efficiency: 0.9
+// (from D.Paneque, email 14.2.2004)
+//
+// * Light guides efficiency: 0.94
+// (from D.Paneque, email 14.2.2004)
+// 
+// "Concerning the light guides effiency estimation... Daniel Ferenc 
+//  is preparing some work (simulations) to estimate it. Yet so far, he has 
+//  been busy with other stuff, and this work is still Unfinished.
+//
+//  The estimation I did comes from:
+//  1) Reflectivity of light guide walls is 85 % (aluminum)
+//  2) At ZERO degree light incidence, 37% of the light hits such walls 
+//    (0.15X37%= 5.6% of light lost)
+//  3) When increasing the light incidence angle, more and more light hits 
+//     the walls.
+//
+//  However, the loses due to larger amount of photons hitting the walls is more 
+//  or less counteracted by the fact that more and more photon trajectories cross 
+//  the PMT photocathode twice, increasing the effective sensitivity of the PMT.
+//
+//Begin_Html
+/*
+<img src="images/Normalized_Cherenkov_phe_spectrums_20deg_60deg_coatedPMT.png">
+*/
+//End_Html
+//
+// The plot shows the normalized spectrum of photo-electrons preceding from 
+// a typical spectrum of Cherenkov photons produced by an atmospheric shower. The 
+// green line is for observation zenith angles of 20 deg. and the red line for 
+// 60 deg. The overall effective QE drops from about 20.8 to about 19.8. 
+//
+// Jurgen Gebauer did some quick measurements about this issue. I attach a 
+// plot. You can see that the angular dependence is (more or less) in agreement with a 
+// CosTheta function (below 20-25 degrees), which is the variation of the entrance 
+// window cross section. So, in first approximation, no losses when increasing light 
+// incidence angle; and therefore, the factor 0.94.
+//
+//Begin_Html
+/*
+<img src="images/JuergensMeasurementWithCosThetaCurve.png">
+*/
+//End_Html
+//
+// The Quantum efficiencies for individual colours have been taken from: 
+// D. Paneque et al., A Method to enhance the sensitivity of photomultipliers 
+//                    of air Cherenkov Telescopes, NIM A 504, 2003, 109-115
+// (see following figure)
+//
+//Begin_Html
+/*
+<img src="images/QE_Paneque.png">
+*/
+//End_Html
+//
+// The Transmission of the Plexiglass window has been provided by Eckart and is 
+// displayed in the next plot. The above red curve has to be taken since it corresponds
+// to the glass type set on the camera.
+//
+//Begin_Html
+/*
+<img src="images/Transmission_Plexiglass.jpg">
+*/
+//End_Html
+//
+// See also: MJCalibration, MCalibrationChargeCalc, 
+//           MCalibrationChargeCam, MCalibrationChargePix, 
+//           MHCalibrationChargeCam, MHCalibrationChargePix,
+//           MHCalibrationChargePINDiode, MHCalibrationChargeBlindPix
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCalibrationQEPix.h"
+#include "MCalibrationCam.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "TArrayF.h"
+#include "TArrayC.h"
+
+ClassImp(MCalibrationQEPix);
+
+using namespace std;
+
+const Float_t MCalibrationQEPix::gkDefaultQEGreen      = 0.192;
+const Float_t MCalibrationQEPix::gkDefaultQEBlue       = 0.27;
+const Float_t MCalibrationQEPix::gkDefaultQEUV         = 0.285;
+const Float_t MCalibrationQEPix::gkDefaultQECT1        = 0.285;
+const Float_t MCalibrationQEPix::gkDefaultQEGreenErr   = 0.007;
+const Float_t MCalibrationQEPix::gkDefaultQEBlueErr    = 0.01 ;
+const Float_t MCalibrationQEPix::gkDefaultQEUVErr      = 0.012;
+const Float_t MCalibrationQEPix::gkDefaultQECT1Err     = 0.012;
+const Float_t MCalibrationQEPix::gkDefaultAverageQE    = 0.18 ;     
+const Float_t MCalibrationQEPix::gkDefaultAverageQEErr = 0.02 ;  
+const Float_t MCalibrationQEPix::gkPMTCollectionEff    = 0.90 ;
+const Float_t MCalibrationQEPix::gkPMTCollectionEffErr = 0.01 ;
+const Float_t MCalibrationQEPix::gkLightGuidesEffGreen    = 0.94 ;
+const Float_t MCalibrationQEPix::gkLightGuidesEffGreenErr = 0.03 ;
+const Float_t MCalibrationQEPix::gkLightGuidesEffBlue     = 0.94 ;
+const Float_t MCalibrationQEPix::gkLightGuidesEffBlueErr  = 0.03 ;
+const Float_t MCalibrationQEPix::gkLightGuidesEffUV       = 0.94 ;
+const Float_t MCalibrationQEPix::gkLightGuidesEffUVErr    = 0.03 ;
+const Float_t MCalibrationQEPix::gkLightGuidesEffCT1      = 0.94 ;
+const Float_t MCalibrationQEPix::gkLightGuidesEffCT1Err   = 0.03 ;
+// --------------------------------------------------------------------------
+//
+// Default Constructor: 
+//
+// Initializes all TArrays to MCalibrationCam::gkNumPulserColors
+//
+// Calls:
+// - Clear()
+//
+MCalibrationQEPix::MCalibrationQEPix(const char *name, const char *title)
+    :  fAverageQE       ( gkDefaultAverageQE )
+{
+
+  fName  = name  ? name  : "MCalibrationQEPix";
+  fTitle = title ? title : "Container of the calibrated quantum efficiency ";
+
+  fQEBlindPixel    .Set( MCalibrationCam::gkNumPulserColors ); 
+  fQEBlindPixelVar .Set( MCalibrationCam::gkNumPulserColors );
+  fQECombined      .Set( MCalibrationCam::gkNumPulserColors );    
+  fQECombinedVar   .Set( MCalibrationCam::gkNumPulserColors ); 
+  fQEFFactor       .Set( MCalibrationCam::gkNumPulserColors );     
+  fQEFFactorVar    .Set( MCalibrationCam::gkNumPulserColors );  
+  fQEPINDiode      .Set( MCalibrationCam::gkNumPulserColors );    
+  fQEPINDiodeVar   .Set( MCalibrationCam::gkNumPulserColors );
+  fValidFlags      .Set( MCalibrationCam::gkNumPulserColors );
+
+  Clear();
+
+}
+
+// ----------------------------------------------------------------------------------------------
+// 
+// Search all available QE's of a certain colour after the blind pixel method, 
+// compare them to the default QE of that colour and 
+// add up a weighted average (wav) and a sum of weights (sumw)
+//
+// FIXME: This has to be replaced by a decent fit the QE-spectrum!
+//
+void MCalibrationQEPix::AddAverageBlindPixelQEs(const MCalibrationCam::PulserColor_t col, Float_t &wav, Float_t &sumw )
+{
+
+  if (IsBlindPixelMethodValid (col))
+  {
+    const Float_t newavqe    =   GetQEBlindPixel      (col) / GetDefaultQE      (col) 
+                               / GetLightGuidesEff    (col) / GetPMTCollectionEff(); 
+    const Float_t newavqevar = ( GetQEBlindPixelRelVar(col) + GetDefaultQERelVar(col) 
+                               + GetLightGuidesEffRelVar(col) + GetPMTCollectionEffRelVar()  ) 
+                               * newavqe * newavqe;
+    const Float_t weight     = 1./newavqevar;
+
+    wav  += newavqe * weight;
+    sumw += weight;
+  }
+}
+
+// ----------------------------------------------------------------------------------------------
+// 
+// Search all available QE's of a certain colour after the combination of the three methods
+// compare them to the default QE of that colour and 
+// add up a weighted average (wav) and a sum of weights (sumw)
+//
+// FIXME: This has to be replaced by a decent fit the QE-spectrum!
+//
+void MCalibrationQEPix::AddAverageCombinedQEs(const MCalibrationCam::PulserColor_t col, Float_t &wav, Float_t &sumw )
+{
+
+  if (IsCombinedMethodValid (col))
+  {
+    const Float_t newavqe    =   GetQECombined(col)       / GetDefaultQE (col) 
+                               / GetLightGuidesEff    (col) / GetPMTCollectionEff(); 
+    const Float_t newavqevar = ( GetQECombinedRelVar(col) + GetDefaultQERelVar(col) 
+                               + GetLightGuidesEffRelVar(col) + GetPMTCollectionEffRelVar()  ) 
+                               * newavqe * newavqe;
+    const Float_t weight     = 1./newavqevar;
+    wav  += newavqe * weight;
+    sumw += weight;
+
+  }
+}
+
+// ----------------------------------------------------------------------------------------------
+// 
+// Search all available QE's of a certain colour after the F-Factor method, 
+// compare them to the default QE of that colour and 
+// add up a weighted average (wav) and a sum of weights (sumw)
+//
+// FIXME: This has to be replaced by a decent fit the QE-spectrum!
+//
+void MCalibrationQEPix::AddAverageFFactorQEs(const MCalibrationCam::PulserColor_t col, Float_t &wav, Float_t &sumw )
+{
+
+  if (IsFFactorMethodValid (col))
+  {
+    const Float_t newavqe    =   GetQEFFactor(col)       / GetDefaultQE (col) 
+                               / GetLightGuidesEff    (col) / GetPMTCollectionEff(); 
+    const Float_t newavqevar = ( GetQEFFactorRelVar(col) + GetDefaultQERelVar(col) 
+                               + GetLightGuidesEffRelVar(col) + GetPMTCollectionEffRelVar()  ) 
+                               * newavqe * newavqe;
+    const Float_t weight     = 1./newavqevar;
+
+    wav  += newavqe *weight;
+    sumw += weight;
+
+  }
+
+
+}
+
+// ----------------------------------------------------------------------------------------------
+// 
+// Search all available QE's of a certain colour after the PIN Diode method, 
+// compare them to the default QE of that colour and 
+// add up a weighted average (wav) and a sum of weights (sumw)
+//
+// FIXME: This has to be replaced by a decent fit the QE-spectrum!
+//
+void MCalibrationQEPix::AddAveragePINDiodeQEs(const MCalibrationCam::PulserColor_t col, Float_t &wav, Float_t &sumw )
+{
+
+  if (IsPINDiodeMethodValid (col))
+  {
+    const Float_t newavqe    =   GetQEPINDiode(col)       / GetDefaultQE (col) 
+                               / GetLightGuidesEff    (col) / GetPMTCollectionEff(); 
+    const Float_t newavqevar = ( GetQEPINDiodeRelVar(col) + GetDefaultQERelVar(col) 
+                               + GetLightGuidesEffRelVar(col) + GetPMTCollectionEffRelVar()  ) 
+                               * newavqe * newavqe;
+    const Float_t weight     = 1./newavqevar;
+    wav  += newavqe *weight;
+    sumw += weight;
+  }
+}
+
+
+
+// ------------------------------------------------------------------------
+//
+// Sets all quantum efficiencies to the gkDefaultQE*
+// Sets all Variances to the square root of gkDefaultQE*Err
+// Sets all flags to kFALSE
+// Sets all fAvNorm-Variables to 1.;
+// Sets all fAvNorm-Variances to 0.;
+// 
+// Calls:
+// - MCalibrationPix::Clear()
+//
+void MCalibrationQEPix::Clear(Option_t *o)
+{
+
+  SetAverageQEBlindPixelAvailable ( kFALSE );
+  SetAverageQEFFactorAvailable    ( kFALSE );
+  SetAverageQECombinedAvailable   ( kFALSE );
+  SetAverageQEPINDiodeAvailable   ( kFALSE );
+
+  fQEBlindPixel    [ MCalibrationCam::kGREEN ] = gkDefaultQEGreen;  
+  fQEBlindPixelVar [ MCalibrationCam::kGREEN ] = gkDefaultQEGreenErr*gkDefaultQEGreenErr;
+  fQEFFactor       [ MCalibrationCam::kGREEN ] = gkDefaultQEGreen;     
+  fQEFFactorVar    [ MCalibrationCam::kGREEN ] = gkDefaultQEGreenErr*gkDefaultQEGreenErr;
+  fQECombined      [ MCalibrationCam::kGREEN ] = gkDefaultQEGreen;    
+  fQECombinedVar   [ MCalibrationCam::kGREEN ] = gkDefaultQEGreenErr*gkDefaultQEGreenErr; 
+  fQEPINDiode      [ MCalibrationCam::kGREEN ] = gkDefaultQEGreen;    
+  fQEPINDiodeVar   [ MCalibrationCam::kGREEN ] = gkDefaultQEGreenErr*gkDefaultQEGreenErr; 
+
+  SetBlindPixelMethodValid ( kFALSE, MCalibrationCam::kGREEN);
+  SetFFactorMethodValid    ( kFALSE, MCalibrationCam::kGREEN);
+  SetCombinedMethodValid   ( kFALSE, MCalibrationCam::kGREEN);
+  SetPINDiodeMethodValid   ( kFALSE, MCalibrationCam::kGREEN);
+
+  fQEBlindPixel    [ MCalibrationCam::kBLUE ] = gkDefaultQEBlue;  
+  fQEBlindPixelVar [ MCalibrationCam::kBLUE ] = gkDefaultQEBlueErr*gkDefaultQEBlueErr;
+  fQEFFactor       [ MCalibrationCam::kBLUE ] = gkDefaultQEBlue;     
+  fQEFFactorVar    [ MCalibrationCam::kBLUE ] = gkDefaultQEBlueErr*gkDefaultQEBlueErr;
+  fQECombined      [ MCalibrationCam::kBLUE ] = gkDefaultQEBlue;    
+  fQECombinedVar   [ MCalibrationCam::kBLUE ] = gkDefaultQEBlueErr*gkDefaultQEBlueErr; 
+  fQEPINDiode      [ MCalibrationCam::kBLUE ] = gkDefaultQEBlue;    
+  fQEPINDiodeVar   [ MCalibrationCam::kBLUE ] = gkDefaultQEBlueErr*gkDefaultQEBlueErr; 
+
+  SetBlindPixelMethodValid ( kFALSE, MCalibrationCam::kBLUE);
+  SetFFactorMethodValid    ( kFALSE, MCalibrationCam::kBLUE);
+  SetCombinedMethodValid   ( kFALSE, MCalibrationCam::kBLUE);
+  SetPINDiodeMethodValid   ( kFALSE, MCalibrationCam::kBLUE);
+
+  fQEBlindPixel    [ MCalibrationCam::kUV ] = gkDefaultQEUV;  
+  fQEBlindPixelVar [ MCalibrationCam::kUV ] = gkDefaultQEUVErr*gkDefaultQEUVErr;
+  fQEFFactor       [ MCalibrationCam::kUV ] = gkDefaultQEUV;     
+  fQEFFactorVar    [ MCalibrationCam::kUV ] = gkDefaultQEUVErr*gkDefaultQEUVErr;
+  fQECombined      [ MCalibrationCam::kUV ] = gkDefaultQEUV;    
+  fQECombinedVar   [ MCalibrationCam::kUV ] = gkDefaultQEUVErr*gkDefaultQEUVErr; 
+  fQEPINDiode      [ MCalibrationCam::kUV ] = gkDefaultQEUV;    
+  fQEPINDiodeVar   [ MCalibrationCam::kUV ] = gkDefaultQEUVErr*gkDefaultQEUVErr; 
+
+  SetBlindPixelMethodValid ( kFALSE, MCalibrationCam::kUV);
+  SetFFactorMethodValid    ( kFALSE, MCalibrationCam::kUV);
+  SetCombinedMethodValid   ( kFALSE, MCalibrationCam::kUV);
+  SetPINDiodeMethodValid   ( kFALSE, MCalibrationCam::kUV);
+
+  fQEBlindPixel    [ MCalibrationCam::kCT1 ] = gkDefaultQECT1;  
+  fQEBlindPixelVar [ MCalibrationCam::kCT1 ] = gkDefaultQECT1Err*gkDefaultQECT1Err;
+  fQEFFactor       [ MCalibrationCam::kCT1 ] = gkDefaultQECT1;     
+  fQEFFactorVar    [ MCalibrationCam::kCT1 ] = gkDefaultQECT1Err*gkDefaultQECT1Err;
+  fQECombined      [ MCalibrationCam::kCT1 ] = gkDefaultQECT1;    
+  fQECombinedVar   [ MCalibrationCam::kCT1 ] = gkDefaultQECT1Err*gkDefaultQECT1Err; 
+  fQEPINDiode      [ MCalibrationCam::kCT1 ] = gkDefaultQECT1;    
+  fQEPINDiodeVar   [ MCalibrationCam::kCT1 ] = gkDefaultQECT1Err*gkDefaultQECT1Err; 
+
+  SetBlindPixelMethodValid ( kFALSE, MCalibrationCam::kCT1);
+  SetFFactorMethodValid    ( kFALSE, MCalibrationCam::kCT1);
+  SetCombinedMethodValid   ( kFALSE, MCalibrationCam::kCT1);
+  SetPINDiodeMethodValid   ( kFALSE, MCalibrationCam::kCT1);
+
+  fAvNormBlindPixel     = 1.;     
+  fAvNormBlindPixelVar  = 0.;  
+  fAvNormCombined       = 1.;       
+  fAvNormCombinedVar    = 0.;    
+  fAvNormFFactor        = 1.;        
+  fAvNormFFactorVar     = 0.;     
+  fAvNormPINDiode       = 1.;       
+  fAvNormPINDiodeVar    = 0.;    
+
+  MCalibrationPix::Clear();
+}
+
+
+// -----------------------------------------------------------------
+//
+// Return the average Default QE (depending on zenith angle)
+// FIXME: The zenith angle dependency is not yet implemented
+//
+const Float_t MCalibrationQEPix::GetAverageQE( const Float_t zenith ) const 
+{
+  //  return gkDefaultAverageQE ;
+  return fAverageQE; 
+}
+
+// -----------------------------------------------------------------
+//
+// Return the relative variance of the average Default QE (depending on zenith angle)
+// FIXME: The zenith angle dependency is not yet implemented
+//
+const Float_t MCalibrationQEPix::GetAverageQERelVar( const Float_t zenith ) const 
+{
+  return gkDefaultAverageQEErr * gkDefaultAverageQEErr / (gkDefaultAverageQE * gkDefaultAverageQE ); 
+}
+
+// -----------------------------------------------------------------
+//
+// Return the relative variance of the average normalization (Blind Pixel Method)
+// FIXME: The zenith angle dependency is not yet implemented
+//
+const Float_t MCalibrationQEPix::GetAvNormBlindPixelRelVar( ) const 
+{
+  return fAvNormBlindPixelVar / (fAvNormBlindPixel * fAvNormBlindPixel ); 
+}
+
+// -----------------------------------------------------------------
+//
+// Return the relative variance of the average normalization (Combined Method)
+// FIXME: The zenith angle dependency is not yet implemented
+//
+const Float_t MCalibrationQEPix::GetAvNormCombinedRelVar( ) const 
+{
+  return fAvNormCombinedVar / (fAvNormCombined * fAvNormCombined ); 
+}
+
+// -----------------------------------------------------------------
+//
+// Return the relative variance of the average normalization (F-Factor Method)
+//
+const Float_t MCalibrationQEPix::GetAvNormFFactorRelVar( ) const 
+{
+  return fAvNormFFactorVar / (fAvNormFFactor * fAvNormFFactor ); 
+}
+
+// -----------------------------------------------------------------
+//
+// Return the relative variance of the average normalization (PIN Diode Method)
+// FIXME: The zenith angle dependency is not yet implemented
+//
+const Float_t MCalibrationQEPix::GetAvNormPINDiodeRelVar( ) const 
+{
+  return fAvNormPINDiodeVar / (fAvNormPINDiode * fAvNormPINDiode ); 
+}
+
+// ------------------------------------------------------------------------------
+//
+// Get the default Quantum efficiency for pulser colour "col"
+//
+Float_t MCalibrationQEPix::GetDefaultQE( const MCalibrationCam::PulserColor_t col )  const
+{
+  switch (col)
+    {
+    case MCalibrationCam::kGREEN:
+      return gkDefaultQEGreen;
+      break;
+    case MCalibrationCam::kBLUE:
+      return gkDefaultQEBlue;
+      break;
+    case MCalibrationCam::kUV:
+      return gkDefaultQEUV;
+      break;
+    case MCalibrationCam::kCT1:
+      return gkDefaultQECT1;
+      break;
+    default:
+      return gkDefaultQECT1;
+      break;
+    }
+  return -1.;
+}
+
+// ------------------------------------------------------------------------------
+//
+// Get the relative variance of the default Quantum efficiency for pulser colour "col"
+//
+Float_t MCalibrationQEPix::GetDefaultQERelVar( const MCalibrationCam::PulserColor_t col )  const
+{
+
+  switch (col)
+    {
+    case MCalibrationCam::kGREEN:
+      return gkDefaultQEGreenErr * gkDefaultQEGreenErr / (gkDefaultQEGreen * gkDefaultQEGreen );
+      break;
+    case MCalibrationCam::kBLUE:
+      return gkDefaultQEBlueErr  * gkDefaultQEBlueErr  / (gkDefaultQEBlue  * gkDefaultQEBlue  );
+      break;
+    case MCalibrationCam::kUV:
+      return gkDefaultQEUVErr    * gkDefaultQEUVErr    / (gkDefaultQEUV    * gkDefaultQEUV    );
+      break;
+    case MCalibrationCam::kCT1:
+      return gkDefaultQECT1Err   * gkDefaultQECT1Err   / (gkDefaultQECT1   * gkDefaultQECT1   );
+      break;
+    default: 
+      return gkDefaultQECT1Err   * gkDefaultQECT1Err   / (gkDefaultQECT1   * gkDefaultQECT1   );
+      break;
+    }
+  return -1.;
+}
+
+// ------------------------------------------------------------------------------
+//
+// Get the light guides efficiency depending on the pulser colour "col"
+// FIXME: Lacking detailed measurement, these number are not yet available 
+//        for the individual colours and therefore, only one same number is 
+//        returned, namely gkLightGuidesEff
+//
+Float_t MCalibrationQEPix::GetLightGuidesEff( const MCalibrationCam::PulserColor_t col )  const
+{
+  switch (col)
+    {
+    case MCalibrationCam::kGREEN:
+      return gkLightGuidesEffGreen;
+      break;
+    case MCalibrationCam::kBLUE:
+      return gkLightGuidesEffBlue;
+      break;
+    case MCalibrationCam::kUV:
+      return gkLightGuidesEffUV;
+      break;
+    case MCalibrationCam::kCT1:
+      return gkLightGuidesEffCT1;
+      break;
+    default:
+      return gkLightGuidesEffCT1;
+      break;
+    }
+  return -1.;
+}
+
+// ------------------------------------------------------------------------------
+//
+// Get the relative variance of the light guides efficiency depending on the 
+// pulser colour "col"
+// FIXME: Lacking detailed measurement, these number are not yet available 
+//        for the individual colours and therefore, only one same number is 
+//        returned, namely gkLightGuidesEffErr^2 / gkLightGuidesEff^2
+//
+Float_t MCalibrationQEPix::GetLightGuidesEffRelVar( const MCalibrationCam::PulserColor_t col )  const
+{
+
+  switch (col)
+    {
+    case MCalibrationCam::kGREEN:
+      return gkLightGuidesEffGreenErr * gkLightGuidesEffGreenErr / gkLightGuidesEffGreen / gkLightGuidesEffGreen;
+      break;
+    case MCalibrationCam::kBLUE:
+      return gkLightGuidesEffBlueErr  * gkLightGuidesEffBlueErr / gkLightGuidesEffBlue / gkLightGuidesEffBlue;
+      break;
+    case MCalibrationCam::kUV:
+      return gkLightGuidesEffUVErr  * gkLightGuidesEffUVErr / gkLightGuidesEffUV / gkLightGuidesEffUV;
+      break;
+    case MCalibrationCam::kCT1:
+      return gkLightGuidesEffCT1Err * gkLightGuidesEffCT1Err / gkLightGuidesEffCT1 / gkLightGuidesEffCT1;
+      break;
+    default: 
+      return gkLightGuidesEffCT1Err * gkLightGuidesEffCT1Err / gkLightGuidesEffCT1 / gkLightGuidesEffCT1;
+      break;
+    }
+  return -1.;
+}
+
+// ------------------------------------------------------------------------------
+//
+// Get the light guides efficiency for Cherenkov spectra, 
+// depending on the zenith angle of the telescope
+// FIXME: Lacking detailed measurement, these number are not yet available 
+//        for the individual colours and therefore, only one same number is 
+//        returned, namely gkLightGuidesEffBlue
+//
+Float_t MCalibrationQEPix::GetLightGuidesEff( const Float_t zenith )  const
+{
+  return gkLightGuidesEffBlue;
+}
+
+
+// ------------------------------------------------------------------------------
+//
+// Get the relative variance of the light guides efficiency for Cherenkov spectra 
+// depending on the zenith angle of the telescope 
+// FIXME: Lacking detailed measurement, these number are not yet available 
+//        for the individual colours and therefore, only one same number is 
+//        returned, namely gkLightGuidesEffBlueErr^2 / gkLightGuidesBlueEff^2
+//
+Float_t MCalibrationQEPix::GetLightGuidesEffRelVar( const Float_t zenith )  const
+{
+  return gkLightGuidesEffBlueErr  * gkLightGuidesEffBlueErr / gkLightGuidesEffBlue / gkLightGuidesEffBlue;
+}
+
+
+
+// ------------------------------------------------------------------------------
+//
+// Get the calculated Quantum efficiency with the blind pixel method, 
+// obtained with pulser colour "col"
+//
+Float_t MCalibrationQEPix::GetQEBlindPixel( const MCalibrationCam::PulserColor_t col )  const
+{
+  return fQEBlindPixel[col];
+}
+
+// ------------------------------------------------------------------------------
+//
+// Get the error on the calculated Quantum efficiency with the blind pixel method, 
+// obtained with pulser colour "col"
+// Tests for variances smaller than 0. (e.g. if it has not yet been set) 
+// and returns -1. in that case
+//
+Float_t MCalibrationQEPix::GetQEBlindPixelErr( const MCalibrationCam::PulserColor_t col )  const
+{
+
+  if (fQEBlindPixelVar[col] < 0.)
+    return -1.;
+
+  return TMath::Sqrt(fQEBlindPixelVar[col]);
+
+}
+
+// ------------------------------------------------------------------------------
+//
+// Get the relative variance of the calculated Quantum efficiency with the blind pixel method, 
+// obtained with pulser colour "col"
+// Tests for variances smaller than 0. (e.g. if it has not yet been set) 
+// and returns -1. in that case
+// Tests for quantum efficiency equal to  0. and returns -1. in that case
+//
+Float_t MCalibrationQEPix::GetQEBlindPixelRelVar( const MCalibrationCam::PulserColor_t col )  const
+{
+
+  if (fQEBlindPixelVar[col] < 0.)
+    return -1.;
+  if (fQEBlindPixel[col] < 0.)
+      return -1.;
+  return fQEBlindPixelVar[col] / ( fQEBlindPixel[col] * fQEBlindPixel[col] );
+
+}
+
+// ------------------------------------------------------------------------------
+//
+// Get the calculated Quantum efficiency with the combination of the three methods
+// obtained with pulser colour "col"
+//
+Float_t MCalibrationQEPix::GetQECombined( const MCalibrationCam::PulserColor_t col )  const
+{
+  return fQECombined[col];
+}
+
+
+// ------------------------------------------------------------------------------
+//
+// Get the error on the calculated Quantum efficiency with the combination of the three methods
+// obtained with pulser colour "col"
+// Tests for variances smaller than 0. (e.g. if it has not yet been set) 
+// and returns -1. in that case
+//
+Float_t MCalibrationQEPix::GetQECombinedErr( const MCalibrationCam::PulserColor_t col )  const
+{
+
+  if (fQECombinedVar[col] < 0.)
+    return -1.;
+
+  return TMath::Sqrt(fQECombinedVar[col]);
+
+}
+
+
+// ----------------------------------------------------------------------------------------
+//
+// Get the relative variance of the calculated Quantum efficiency with the combination of 
+// the three methods, 
+// obtained with pulser colour "col"
+// Tests for variances smaller than 0. (e.g. if it has not yet been set) 
+// and returns -1. in that case
+// Tests for quantum efficiency equal to  0. and returns -1. in that case
+//
+Float_t MCalibrationQEPix::GetQECombinedRelVar( const MCalibrationCam::PulserColor_t col )  const
+{
+
+  if (fQECombinedVar[col] < 0.)
+    return -1.;
+  if (fQECombined[col] < 0.)
+      return -1.;
+  return fQECombinedVar[col] / ( fQECombined[col] * fQECombined[col] );
+
+}
+
+// ------------------------------------------------------------------------------
+//
+// Get the calculated Quantum efficiency with the F-Factor method
+// obtained with pulser colour "col"
+//
+Float_t MCalibrationQEPix::GetQEFFactor( const MCalibrationCam::PulserColor_t col )  const
+{
+  return fQEFFactor[col];
+}
+
+
+// ------------------------------------------------------------------------------
+//
+// Get the error on the calculated Quantum efficiency with the F-Factor method, 
+// obtained with pulser colour "col"
+// Tests for variances smaller than 0. (e.g. if it has not yet been set) 
+// and returns -1. in that case
+//
+Float_t MCalibrationQEPix::GetQEFFactorErr( const MCalibrationCam::PulserColor_t col )  const
+{
+
+  if (fQEFFactorVar[col] < 0.)
+    return -1.;
+
+  return TMath::Sqrt(fQEFFactorVar[col]);
+
+}
+
+
+// ----------------------------------------------------------------------------------------
+//
+// Get the relative variance of the calculated Quantum efficiency with the F-Factor method, 
+// obtained with pulser colour "col"
+// Tests for variances smaller than 0. (e.g. if it has not yet been set) 
+// and returns -1. in that case
+// Tests for quantum efficiency equal to  0. and returns -1. in that case
+//
+Float_t MCalibrationQEPix::GetQEFFactorRelVar( const MCalibrationCam::PulserColor_t col )  const
+{
+
+  if (fQEFFactorVar[col] < 0.)
+    return -1.;
+  if (fQEFFactor[col] < 0.)
+      return -1.;
+  return fQEFFactorVar[col] / ( fQEFFactor[col] * fQEFFactor[col] );
+
+}
+
+// ------------------------------------------------------------------------------
+//
+// Get the calculated Quantum efficiency with the PIN-Diode method
+// obtained with pulser colour "col"
+//
+Float_t MCalibrationQEPix::GetQEPINDiode( const MCalibrationCam::PulserColor_t col )  const
+{
+  return fQEPINDiode[col];
+}
+
+
+// ------------------------------------------------------------------------------
+//
+// Get the error on the calculated Quantum efficiency with the PIN Diode method, 
+// obtained with pulser colour "col"
+// Tests for variances smaller than 0. (e.g. if it has not yet been set) 
+// and returns -1. in that case
+//
+Float_t MCalibrationQEPix::GetQEPINDiodeErr( const MCalibrationCam::PulserColor_t col )  const
+{
+
+  if (fQEPINDiodeVar[col] < 0.)
+    return -1.;
+
+  return TMath::Sqrt(fQEPINDiodeVar[col]);
+
+}
+
+// ----------------------------------------------------------------------------------------
+//
+// Get the relative variance of the calculated Quantum efficiency with the PIN Diode method, 
+// obtained with pulser colour "col"
+// Tests for variances smaller than 0. (e.g. if it has not yet been set) 
+// and returns -1. in that case
+// Tests for quantum efficiency equal to  0. and returns -1. in that case
+//
+Float_t MCalibrationQEPix::GetQEPINDiodeRelVar( const MCalibrationCam::PulserColor_t col )  const
+{
+
+  if (fQEPINDiodeVar[col] < 0.)
+    return -1.;
+  if (fQEPINDiode[col] < 0.)
+      return -1.;
+  return fQEPINDiodeVar[col] / ( fQEPINDiode[col] * fQEPINDiode[col] );
+
+}
+
+// ------------------------------------------------------------------------------
+//
+// Get the averaged Quantum efficiency folded over the cascade spectrum, obtained 
+// with the blind pixel method and averaged over the results from the different colours.
+//
+Float_t MCalibrationQEPix::GetQECascadesBlindPixel( const Float_t zenith  )  const
+{
+  return fAvNormBlindPixel * GetAverageQE ( zenith );
+}
+
+// ------------------------------------------------------------------------------
+//
+// Get the variance of the averaged Quantum efficiency folded over the cascade spectrum, 
+// obtained with the blind pixel method and averaged over the results from the 
+// different colours.
+//
+Float_t MCalibrationQEPix::GetQECascadesBlindPixelVar( const Float_t zenith  )  const
+{
+  return ( GetAvNormBlindPixelRelVar()  + GetAverageQERelVar(zenith)) 
+    * GetQECascadesBlindPixel(zenith) * GetQECascadesBlindPixel(zenith);
+}
+
+// ------------------------------------------------------------------------------
+//
+// Get the error on the averaged Quantum efficiency folded over the cascade spectrum, 
+// obtained with the blind pixel method and averaged over the results from the 
+// different colours.
+//
+Float_t MCalibrationQEPix::GetQECascadesBlindPixelErr( const Float_t zenith  )  const
+{
+  const Float_t var = GetQECascadesBlindPixelVar(zenith);
+  
+  if (var < 0.)
+    return -1.;
+
+  return TMath::Sqrt(var);
+}
+
+// ------------------------------------------------------------------------------
+//
+// Get the averaged Quantum efficiency folded over the cascade spectrum, obtained 
+// with the combination of the three methods and averaged over the results 
+// from the different colours.
+//
+Float_t MCalibrationQEPix::GetQECascadesCombined( const Float_t zenith  )  const
+{
+  return fAvNormCombined * GetAverageQE ( zenith );
+}
+
+// ------------------------------------------------------------------------------
+//
+// Get the error on the averaged Quantum efficiency folded over the cascade spectrum, 
+// obtained with the combined method and averaged over the results from the 
+// different colours.
+//
+Float_t MCalibrationQEPix::GetQECascadesCombinedErr( const Float_t zenith  )  const
+{
+  const Float_t var = GetQECascadesCombinedVar(zenith);
+  
+  if (var < 0.)
+    return -1.;
+
+  return TMath::Sqrt(var);
+}
+
+// ------------------------------------------------------------------------------
+//
+// Get the variance of the averaged Quantum efficiency folded over the cascade spectrum, 
+// obtained with the combination of the three methods and averaged over the results from the 
+// different colours.
+//
+Float_t MCalibrationQEPix::GetQECascadesCombinedVar( const Float_t zenith  )  const
+{
+  return ( GetAvNormCombinedRelVar()  + GetAverageQERelVar(zenith)) 
+    * GetQECascadesCombined(zenith) * GetQECascadesCombined(zenith);
+}
+
+// ------------------------------------------------------------------------------
+//
+// Get the averaged Quantum efficiency folded over the cascade spectrum, obtained 
+// with the F-Factor method and averaged over the results from the different colours.
+//
+Float_t MCalibrationQEPix::GetQECascadesFFactor( const Float_t zenith  )  const
+{
+  return fAvNormFFactor * GetAverageQE ( zenith );
+}
+
+// ------------------------------------------------------------------------------
+//
+// Get the error on the averaged Quantum efficiency folded over the cascade spectrum, 
+// obtained with the F-Factor method and averaged over the results from the 
+// different colours.
+//
+Float_t MCalibrationQEPix::GetQECascadesFFactorErr( const Float_t zenith  )  const
+{
+  const Float_t var = GetQECascadesFFactorVar(zenith);
+  
+  if (var < 0.)
+    return -1.;
+
+  return TMath::Sqrt(var);
+}
+
+// ------------------------------------------------------------------------------
+//
+// Get the variance of the averaged Quantum efficiency folded over the cascade spectrum, 
+// obtained with the F-Factor method and averaged over the results from the 
+// different colours.
+//
+Float_t MCalibrationQEPix::GetQECascadesFFactorVar( const Float_t zenith  )  const
+{
+  return ( GetAvNormFFactorRelVar()  + GetAverageQERelVar(zenith)) 
+    * GetQECascadesFFactor(zenith) * GetQECascadesFFactor(zenith);
+}
+
+// ------------------------------------------------------------------------------
+//
+// Get the averaged Quantum efficiency folded over the cascade spectrum, obtained 
+// with the PIN Diode method and averaged over the results from the different colours.
+//
+Float_t MCalibrationQEPix::GetQECascadesPINDiode( const Float_t zenith  )  const
+{
+  return fAvNormPINDiode * GetAverageQE ( zenith );
+}
+
+// ------------------------------------------------------------------------------
+//
+// Get the error on the averaged Quantum efficiency folded over the cascade spectrum, 
+// obtained with the PIN Diode method and averaged over the results from the 
+// different colours.
+//
+Float_t MCalibrationQEPix::GetQECascadesPINDiodeErr( const Float_t zenith  )  const
+{
+  const Float_t var = GetQECascadesPINDiodeVar(zenith);
+  
+  if (var < 0.)
+    return -1.;
+
+  return TMath::Sqrt(var);
+}
+
+// ------------------------------------------------------------------------------
+//
+// Get the variance of the averaged Quantum efficiency folded over the cascade spectrum, 
+// obtained with the PIN Diode method and averaged over the results from the 
+// different colours.
+//
+Float_t MCalibrationQEPix::GetQECascadesPINDiodeVar( const Float_t zenith  )  const
+{
+  return ( GetAvNormPINDiodeRelVar()  + GetAverageQERelVar(zenith)) 
+    * GetQECascadesPINDiode(zenith) * GetQECascadesPINDiode(zenith);
+}
+
+// -----------------------------------------------------------------
+//
+// Return the overall collection efficiency of the PMT
+//
+Float_t MCalibrationQEPix::GetPMTCollectionEff() const 
+{
+  return gkPMTCollectionEff; 
+}
+
+// -----------------------------------------------------------------
+//
+// Return the relative variance of the collection efficiency of the PMT
+//
+Float_t MCalibrationQEPix::GetPMTCollectionEffRelVar() const 
+{
+  return gkPMTCollectionEffErr * gkPMTCollectionEffErr / gkPMTCollectionEff / gkPMTCollectionEff; 
+}
+
+// ------------------------------------------------------------------------------
+//
+// Test if the average QE can be obtained from the blind pixel method
+//
+Bool_t MCalibrationQEPix::IsAverageQEBlindPixelAvailable() const
+{
+  return TESTBIT(fAvailableFlags,kAverageQEBlindPixelAvailable);
+}
+
+// ------------------------------------------------------------------------------
+//
+// Test if the average QE can be obtained from the combination of the three methods
+//
+Bool_t MCalibrationQEPix::IsAverageQECombinedAvailable() const
+{
+  return TESTBIT(fAvailableFlags,kAverageQECombinedAvailable);
+}
+
+// ------------------------------------------------------------------------------
+//
+// Test if the average QE can be obtained from the F-Factor method
+//
+Bool_t MCalibrationQEPix::IsAverageQEFFactorAvailable() const
+{
+  return TESTBIT(fAvailableFlags,kAverageQEFFactorAvailable);
+}
+
+// ------------------------------------------------------------------------------
+//
+// Test if the average QE can be obtained from the PIN Diode method
+//
+Bool_t MCalibrationQEPix::IsAverageQEPINDiodeAvailable() const
+{
+  return TESTBIT(fAvailableFlags,kAverageQEPINDiodeAvailable);
+}
+
+// ------------------------------------------------------------------------------
+//
+// Test if any of the three colours has already been calibrated with the blind pixel method
+//
+Bool_t MCalibrationQEPix::IsBlindPixelMethodValid () const
+{
+
+  if (IsBlindPixelMethodValid (MCalibrationCam::kGREEN))
+    return kTRUE;
+  if (IsBlindPixelMethodValid (MCalibrationCam::kBLUE ))
+    return kTRUE;
+  if (IsBlindPixelMethodValid (MCalibrationCam::kUV   ))
+    return kTRUE;
+  if (IsBlindPixelMethodValid (MCalibrationCam::kCT1  ))
+    return kTRUE;
+
+  return kFALSE;
+}
+
+// ------------------------------------------------------------------------------
+//
+// Test if any of the three colours has already been calibrated with the combination 
+// of the three methods
+//
+Bool_t MCalibrationQEPix::IsCombinedMethodValid () const
+{
+  if (IsCombinedMethodValid (MCalibrationCam::kGREEN))
+    return kTRUE;
+  if (IsCombinedMethodValid (MCalibrationCam::kBLUE ))
+    return kTRUE;
+  if (IsCombinedMethodValid (MCalibrationCam::kUV   ))
+    return kTRUE;
+  if (IsCombinedMethodValid (MCalibrationCam::kCT1  ))
+    return kTRUE;
+
+  return kFALSE;
+}
+
+// ------------------------------------------------------------------------------
+//
+// Test if any of the three colours has already been calibrated with the F-Factor method
+//
+Bool_t MCalibrationQEPix::IsFFactorMethodValid () const
+{
+  if (IsFFactorMethodValid (MCalibrationCam::kGREEN))
+    return kTRUE;
+  if (IsFFactorMethodValid (MCalibrationCam::kBLUE ))
+    return kTRUE;
+  if (IsFFactorMethodValid (MCalibrationCam::kUV   ))
+    return kTRUE;
+  if (IsFFactorMethodValid (MCalibrationCam::kCT1  ))
+    return kTRUE;
+
+  return kFALSE;
+}
+
+
+// ------------------------------------------------------------------------------
+//
+// Test if any of the three colours has already been calibrated with the PIN Diode method
+//
+Bool_t MCalibrationQEPix::IsPINDiodeMethodValid () const
+{
+  if (IsPINDiodeMethodValid (MCalibrationCam::kGREEN))
+    return kTRUE;
+  if (IsPINDiodeMethodValid (MCalibrationCam::kBLUE ))
+    return kTRUE;
+  if (IsPINDiodeMethodValid (MCalibrationCam::kUV   ))
+    return kTRUE;
+  if (IsPINDiodeMethodValid (MCalibrationCam::kCT1  ))
+    return kTRUE;
+
+  return kFALSE;
+}
+
+// ------------------------------------------------------------------------------
+//
+// Test if the colour "col" has already been calibrated with the Blind Pixel method
+//
+Bool_t MCalibrationQEPix::IsBlindPixelMethodValid (MCalibrationCam::PulserColor_t col)  const
+{
+  return TESTBIT(fValidFlags[ col ],kBlindPixelMethodValid);
+}
+
+// ------------------------------------------------------------------------------
+//
+// Test if the colour "col" has already been calibrated with the combination of 
+// the three methods
+//
+Bool_t MCalibrationQEPix::IsCombinedMethodValid (MCalibrationCam::PulserColor_t col)  const
+{
+  return TESTBIT(fValidFlags[ col ],kCombinedMethodValid);
+}
+
+// ------------------------------------------------------------------------------
+//
+// Test if the colour "col" has already been calibrated with the F-Factor method
+//
+Bool_t MCalibrationQEPix::IsFFactorMethodValid (MCalibrationCam::PulserColor_t col)  const
+{
+  return TESTBIT(fValidFlags[ col ],kFFactorMethodValid);
+}
+
+// ------------------------------------------------------------------------------
+//
+// Test if the colour "col" has already been calibrated with the PIN Diode method
+//
+Bool_t MCalibrationQEPix::IsPINDiodeMethodValid (MCalibrationCam::PulserColor_t col)  const
+{
+  return TESTBIT(fValidFlags[ col ],kPINDiodeMethodValid);
+}
+
+// ------------------------------------------------------------------------------
+//
+// Set the bit Average QE Blind Pixel method available from outside (only for MC!)
+//
+void MCalibrationQEPix::SetAverageQEBlindPixelAvailable ( Bool_t b ) 
+{
+  if (b) 
+    SETBIT(fAvailableFlags,kAverageQEBlindPixelAvailable);
+  else
+    CLRBIT(fAvailableFlags,kAverageQEBlindPixelAvailable);    
+}
+
+// ------------------------------------------------------------------------------
+//
+// Set the bit Average QE combination of three methods available from outside (only for MC!)
+//
+void MCalibrationQEPix::SetAverageQECombinedAvailable ( Bool_t b ) 
+{
+  if (b) 
+    SETBIT(fAvailableFlags,kAverageQECombinedAvailable);
+  else
+    CLRBIT(fAvailableFlags,kAverageQECombinedAvailable);    
+}
+
+// ------------------------------------------------------------------------------
+//
+// Set the bit Average QE F-Factor method available from outside (only for MC!)
+//
+void MCalibrationQEPix::SetAverageQEFFactorAvailable ( Bool_t b ) 
+{
+  if (b) 
+    SETBIT(fAvailableFlags,kAverageQEFFactorAvailable);
+  else
+    CLRBIT(fAvailableFlags,kAverageQEFFactorAvailable);    
+}
+
+// ------------------------------------------------------------------------------
+//
+// Set the bit Average QE PIN Diode method available from outside (only for MC!)
+//
+void MCalibrationQEPix::SetAverageQEPINDiodeAvailable ( Bool_t b ) 
+{
+  if (b) 
+    SETBIT(fAvailableFlags,kAverageQEPINDiodeAvailable);
+  else
+    CLRBIT(fAvailableFlags,kAverageQEPINDiodeAvailable);    
+}
+
+// ------------------------------------------------------------------------------
+//
+// Set the bit QE Blind Pixel method available from colour "col"
+//
+void MCalibrationQEPix::SetBlindPixelMethodValid ( Bool_t b,  MCalibrationCam::PulserColor_t col ) 
+{
+  if (b) 
+    SETBIT(fValidFlags[ col ],kBlindPixelMethodValid);
+  else
+    CLRBIT(fValidFlags[ col ],kBlindPixelMethodValid);    
+}
+
+// ------------------------------------------------------------------------------
+//
+// Set the bit QE Combination of three methods available from colour "col"
+//
+void MCalibrationQEPix::SetCombinedMethodValid ( Bool_t b,  MCalibrationCam::PulserColor_t col ) 
+{
+  if (b) 
+    SETBIT(fValidFlags[ col ],kCombinedMethodValid);
+  else
+    CLRBIT(fValidFlags[ col ],kCombinedMethodValid);    
+}
+
+// ------------------------------------------------------------------------------
+//
+// Set the bit QE F-Factor method available from colour "col"
+//
+void MCalibrationQEPix::SetFFactorMethodValid ( Bool_t b,  MCalibrationCam::PulserColor_t col ) 
+{
+  if (b) 
+    SETBIT(fValidFlags[ col ],kFFactorMethodValid);
+  else
+    CLRBIT(fValidFlags[ col ],kFFactorMethodValid);    
+}
+
+// ------------------------------------------------------------------------------
+//
+// Set the bit QE PIN Diode method available from colour "col"
+//
+void MCalibrationQEPix::SetPINDiodeMethodValid ( Bool_t b,  MCalibrationCam::PulserColor_t col ) 
+{
+  if (b) 
+    SETBIT(fValidFlags[ col ],kPINDiodeMethodValid);
+  else
+    CLRBIT(fValidFlags[ col ],kPINDiodeMethodValid);    
+}
+
+// ------------------------------------------------------------------------------
+//
+// Update the Blind Pixel Method: Calculate new average QE's
+//
+Bool_t  MCalibrationQEPix::UpdateBlindPixelMethod()
+{
+
+  Float_t weightedav = 0.;
+  Float_t sumweights = 0.;
+
+  AddAverageBlindPixelQEs(MCalibrationCam::kGREEN, weightedav, sumweights);
+  AddAverageBlindPixelQEs(MCalibrationCam::kBLUE , weightedav, sumweights);
+  AddAverageBlindPixelQEs(MCalibrationCam::kUV   , weightedav, sumweights);
+  AddAverageBlindPixelQEs(MCalibrationCam::kCT1  , weightedav, sumweights);
+
+  if (weightedav == 0. || sumweights == 0.)
+    return kFALSE;
+
+  fAvNormBlindPixel     = weightedav / sumweights;
+  fAvNormBlindPixelVar  = 1./ sumweights ;
+
+  SetAverageQEBlindPixelAvailable();
+
+  return kTRUE;
+}
+
+// ------------------------------------------------------------------------------
+//
+// Update the Combination of the three Methods: Calculate new average QE's
+//
+Bool_t  MCalibrationQEPix::UpdateCombinedMethod()
+{
+  
+  Float_t weightedav = 0.;
+  Float_t sumweights = 0.;
+
+  AddAverageCombinedQEs(MCalibrationCam::kGREEN, weightedav, sumweights);
+  AddAverageCombinedQEs(MCalibrationCam::kBLUE , weightedav, sumweights);
+  AddAverageCombinedQEs(MCalibrationCam::kUV   , weightedav, sumweights);
+  AddAverageCombinedQEs(MCalibrationCam::kCT1  , weightedav, sumweights);
+
+  if (weightedav == 0. || sumweights == 0.)
+    return kFALSE;
+
+  fAvNormCombined     = weightedav / sumweights;
+  fAvNormCombinedVar  = 1./ sumweights ;
+
+  SetAverageQECombinedAvailable();
+
+  return kTRUE;
+  
+}
+
+// ------------------------------------------------------------------------------
+//
+// Update the F-Factor Method: Calculate new average QE's
+//
+Bool_t  MCalibrationQEPix::UpdateFFactorMethod()
+{
+
+  Float_t weightedav = 0.;
+  Float_t sumweights = 0.;
+
+  AddAverageFFactorQEs(MCalibrationCam::kGREEN, weightedav, sumweights);
+  AddAverageFFactorQEs(MCalibrationCam::kBLUE , weightedav, sumweights);
+  AddAverageFFactorQEs(MCalibrationCam::kUV   , weightedav, sumweights);
+  AddAverageFFactorQEs(MCalibrationCam::kCT1  , weightedav, sumweights);
+ 
+  if (weightedav == 0. || sumweights == 0.)
+    return kFALSE;
+
+  fAvNormFFactor     = weightedav / sumweights;
+  fAvNormFFactorVar  = 1./ sumweights ;
+  
+  SetAverageQEFFactorAvailable();
+
+  return kTRUE;
+  
+  
+}
+
+// ------------------------------------------------------------------------------
+//
+// Update the PIN Diode Method: Calculate new average QE's
+//
+Bool_t  MCalibrationQEPix::UpdatePINDiodeMethod()
+{
+  
+  Float_t weightedav = 0.;
+  Float_t sumweights = 0.;
+
+  AddAveragePINDiodeQEs(MCalibrationCam::kGREEN, weightedav, sumweights);
+  AddAveragePINDiodeQEs(MCalibrationCam::kBLUE , weightedav, sumweights);
+  AddAveragePINDiodeQEs(MCalibrationCam::kUV   , weightedav, sumweights);
+  AddAveragePINDiodeQEs(MCalibrationCam::kCT1  , weightedav, sumweights);
+
+  if (weightedav == 0. || sumweights == 0.)
+    return kFALSE;
+
+  fAvNormPINDiode     = weightedav / sumweights;
+  fAvNormPINDiodeVar  = 1./ sumweights ;
+
+  SetAverageQEPINDiodeAvailable();
+
+  return kTRUE;
+
+  
+}
+
Index: /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationQEPix.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationQEPix.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationQEPix.h	(revision 9661)
@@ -0,0 +1,178 @@
+#ifndef MARS_MCalibrationQEPix
+#define MARS_MCalibrationQEPix
+
+#ifndef MARS_MCalibrationPix
+#include "MCalibrationPix.h"
+#endif
+
+#ifndef ROOT_TArrayF
+#include "TArrayF.h"
+#endif
+
+#ifndef ROOT_TArrayC
+#include "TArrayC.h"
+#endif
+
+#ifndef MARS_MCalibrationCam
+#include "MCalibrationCam.h"
+#endif
+
+class MCalibrationQEPix : public MCalibrationPix
+{
+private:
+
+  static const Float_t gkDefaultQEGreen;      //! Default QE at 520 nm (now set to: 0.192)
+  static const Float_t gkDefaultQEBlue;       //! Default QE at 460 nm (now set to: 0.27 )
+  static const Float_t gkDefaultQEUV;         //! Default QE at 370 nm (now set to: 0.285)
+  static const Float_t gkDefaultQECT1;        //! Default QE at 370 nm (now set to: 0.285)
+  static const Float_t gkDefaultQEGreenErr;   //! Uncertainty Def. QE  at 520 nm (now set to: 0.05)
+  static const Float_t gkDefaultQEBlueErr;    //! Uncertainty Def. QE  at 460 nm (now set to: 0.07)
+  static const Float_t gkDefaultQEUVErr;      //! Uncertainty Def. QE  at 370 nm (now set to: 0.07)
+  static const Float_t gkDefaultQECT1Err;     //! Uncertainty Def. QE  at 370 nm (now set to: 0.07)
+  static const Float_t gkLightGuidesEffGreen;    //! Default Light guides efficiency at 520 nm
+  static const Float_t gkLightGuidesEffGreenErr; //! Uncertainty Def. Light guides efficiency at 520 nm
+  static const Float_t gkLightGuidesEffBlue;     //! Default Light guides efficiency at 460 nm
+  static const Float_t gkLightGuidesEffBlueErr;  //! Uncertainty Def. Light guides efficiency at 460 nm
+  static const Float_t gkLightGuidesEffUV;       //! Default Light guides efficiency at 370 nm
+  static const Float_t gkLightGuidesEffUVErr;    //! Uncertainty Def. Light guides efficiency at 370 nm
+  static const Float_t gkLightGuidesEffCT1;      //! Default Light guides efficiency at 370 nm
+  static const Float_t gkLightGuidesEffCT1Err;   //! Uncertainty Def. Light guides efficiency at 370 nm
+  static const Float_t gkPMTCollectionEff;    //! Default Collection efficiency of the PMTs
+  static const Float_t gkPMTCollectionEffErr; //! Uncertainty Def. Collection efficiency of the PMTs (0.01)
+  
+  TArrayF fQEBlindPixel;                     // Calibrated QEs    (Blind Pixel Method)
+  TArrayF fQEBlindPixelVar;                  // Variance cal. QEs (Blind Pixel Method)
+  TArrayF fQECombined;                       // Calibrated QEs    (Combined Method)
+  TArrayF fQECombinedVar;                    // Variance cal. QEs (Combined Method)
+  TArrayF fQEFFactor;                        // Calibrated QEs    (F-Factor Method)
+  TArrayF fQEFFactorVar;                     // Variance cal. QEs (F-Factor Method)
+  TArrayF fQEPINDiode;                       // Calibrated QEs    (PIN Diode Method)
+  TArrayF fQEPINDiodeVar;                    // Variance cal. QEs (PIN Diode Method)
+                                             
+  Float_t fAvNormBlindPixel;                 // Normalization w.r.t. default QE (Blind Pixel Method)
+  Float_t fAvNormBlindPixelVar;              // Variance norm. w.r.t. def. QE (Blind Pixel Method)
+  Float_t fAvNormCombined;                   // Normalization w.r.t. default QE (Combined Method)
+  Float_t fAvNormCombinedVar;                // Variance norm. w.r.t. def. QE (Combined Method)
+  Float_t fAvNormFFactor;                    // Normalization w.r.t. default QE (F-Factor Method)
+  Float_t fAvNormFFactorVar;                 // Variance norm. w.r.t. def. QE (F-Factor Method)
+  Float_t fAvNormPINDiode;                   // Normalization w.r.t. default QE (PIN Diode Method)
+  Float_t fAvNormPINDiodeVar;                // Variance norm. w.r.t. def. QE (PIN Diode Method)
+  Float_t fAverageQE;                        // Average QE for Cascade spectrum (default 0.18)
+
+  TArrayC fValidFlags;                       // Bit-field for valid flags, one array entry for each color
+  Byte_t  fAvailableFlags;                   // Bit-field for available flags
+  
+  enum { kBlindPixelMethodValid, kFFactorMethodValid, 
+	 kPINDiodeMethodValid, kCombinedMethodValid,
+         kAverageQEBlindPixelAvailable, kAverageQEFFactorAvailable,
+         kAverageQEPINDiodeAvailable, kAverageQECombinedAvailable  };
+
+  void  AddAverageBlindPixelQEs( const MCalibrationCam::PulserColor_t col, Float_t &wav, Float_t &sumw );
+  void  AddAverageCombinedQEs  ( const MCalibrationCam::PulserColor_t col, Float_t &wav, Float_t &sumw );
+  void  AddAverageFFactorQEs  ( const MCalibrationCam::PulserColor_t col, Float_t &wav, Float_t &sumw );
+  void  AddAveragePINDiodeQEs  ( const MCalibrationCam::PulserColor_t col, Float_t &wav, Float_t &sumw );
+
+  const Float_t GetAvNormBlindPixelRelVar()  const;
+  const Float_t GetAvNormCombinedRelVar()  const;
+  const Float_t GetAvNormFFactorRelVar()  const;
+  const Float_t GetAvNormPINDiodeRelVar()  const;  
+
+public:
+
+  static const Float_t gkDefaultAverageQE;    //! Default QE folded into Cascade spectrum (now set to: 0.18)
+  static const Float_t gkDefaultAverageQEErr; //! Uncertainty Def. QE Cascade spectrum    (now set to: 0.02)
+
+  MCalibrationQEPix(const char *name=NULL, const char *title=NULL);
+  ~MCalibrationQEPix() {}
+  
+  void    Clear(Option_t *o="");
+  
+  // Getters
+
+  const Float_t GetAverageQE     ( const Float_t zenith=0. ) const;  
+  const Float_t GetAverageQERelVar( const Float_t zenith=0. ) const;
+  
+  Float_t GetDefaultQE                   ( const MCalibrationCam::PulserColor_t col ) const;
+  Float_t GetDefaultQERelVar             ( const MCalibrationCam::PulserColor_t col ) const;  
+  Float_t GetLightGuidesEff              ( const MCalibrationCam::PulserColor_t col ) const;
+  Float_t GetLightGuidesEffRelVar        ( const MCalibrationCam::PulserColor_t col ) const;
+  Float_t GetLightGuidesEff              ( const Float_t zenith=0.)                   const;
+  Float_t GetLightGuidesEffRelVar        ( const Float_t zenith=0.)                   const;
+  Float_t GetQEBlindPixel                ( const MCalibrationCam::PulserColor_t col ) const;  
+  Float_t GetQEBlindPixelErr             ( const MCalibrationCam::PulserColor_t col ) const;
+  Float_t GetQEBlindPixelRelVar          ( const MCalibrationCam::PulserColor_t col ) const;  
+  Float_t GetQECascadesBlindPixel        ( const Float_t zenith=0.)                   const;
+  Float_t GetQECascadesBlindPixelErr     ( const Float_t zenith=0.)                   const;
+  Float_t GetQECascadesBlindPixelVar     ( const Float_t zenith=0.)                   const;
+  Float_t GetQECascadesCombined          ( const Float_t zenith=0.)                   const;  
+  Float_t GetQECascadesCombinedErr       ( const Float_t zenith=0.)                   const;
+  Float_t GetQECascadesCombinedVar       ( const Float_t zenith=0.)                   const;    
+  Float_t GetQECascadesFFactor           ( const Float_t zenith=0.)                   const;  
+  Float_t GetQECascadesFFactorErr        ( const Float_t zenith=0 )                   const;
+  Float_t GetQECascadesFFactorVar        ( const Float_t zenith=0 )                   const;    
+  Float_t GetQECascadesPINDiode          ( const Float_t zenith=0.)                   const;
+  Float_t GetQECascadesPINDiodeErr       ( const Float_t zenith=0.)                   const;
+  Float_t GetQECascadesPINDiodeVar       ( const Float_t zenith=0.)                   const;  
+  Float_t GetQECombined                  ( const MCalibrationCam::PulserColor_t col ) const;        
+  Float_t GetQECombinedErr               ( const MCalibrationCam::PulserColor_t col ) const;
+  Float_t GetQECombinedRelVar            ( const MCalibrationCam::PulserColor_t col ) const;  
+  Float_t GetQEFFactor                   ( const MCalibrationCam::PulserColor_t col ) const;  
+  Float_t GetQEFFactorErr                ( const MCalibrationCam::PulserColor_t col ) const;
+  Float_t GetQEFFactorRelVar             ( const MCalibrationCam::PulserColor_t col ) const;  
+  Float_t GetQEPINDiode                  ( const MCalibrationCam::PulserColor_t col ) const;        
+  Float_t GetQEPINDiodeErr               ( const MCalibrationCam::PulserColor_t col ) const;
+  Float_t GetQEPINDiodeRelVar            ( const MCalibrationCam::PulserColor_t col ) const;  
+  Float_t GetPMTCollectionEff()                                                       const;
+  Float_t GetPMTCollectionEffRelVar()                                                 const;
+
+  Bool_t  IsAverageQEBlindPixelAvailable ()                                           const;
+  Bool_t  IsAverageQECombinedAvailable   ()                                           const;  
+  Bool_t  IsAverageQEFFactorAvailable    ()                                           const;  
+  Bool_t  IsAverageQEPINDiodeAvailable   ()                                           const;  
+  Bool_t  IsBlindPixelMethodValid        ()                                           const;
+  Bool_t  IsBlindPixelMethodValid        ( const MCalibrationCam::PulserColor_t col ) const;
+  Bool_t  IsCombinedMethodValid          ()                                           const;  
+  Bool_t  IsCombinedMethodValid          ( const MCalibrationCam::PulserColor_t col ) const;  
+  Bool_t  IsFFactorMethodValid           ()                                           const;  
+  Bool_t  IsFFactorMethodValid           ( const MCalibrationCam::PulserColor_t col ) const;  
+  Bool_t  IsPINDiodeMethodValid          ()                                           const;  
+  Bool_t  IsPINDiodeMethodValid          ( const MCalibrationCam::PulserColor_t col ) const;  
+
+  // Setters 
+  void SetAverageQE            ( const Float_t f )  { fAverageQE            = f; }
+  void SetAvNormBlindPixel     ( const Float_t f )  { fAvNormBlindPixel     = f; }      
+  void SetAvNormBlindPixelVar  ( const Float_t f )  { fAvNormBlindPixelVar  = f; }   
+  void SetAvNormCombined       ( const Float_t f )  { fAvNormCombined       = f; }        
+  void SetAvNormCombinedVar    ( const Float_t f )  { fAvNormCombinedVar    = f; }     
+  void SetAvNormFFactor        ( const Float_t f )  { fAvNormFFactor        = f; }         
+  void SetAvNormFFactorVar     ( const Float_t f )  { fAvNormFFactorVar     = f; }      
+  void SetAvNormPINDiode       ( const Float_t f )  { fAvNormPINDiode       = f; }        
+  void SetAvNormPINDiodeVar    ( const Float_t f )  { fAvNormPINDiodeVar    = f; }     
+  void SetAverageQEBlindPixelAvailable   ( const Bool_t b=kTRUE );
+  void SetAverageQECombinedAvailable     ( const Bool_t b=kTRUE );
+  void SetAverageQEFFactorAvailable      ( const Bool_t b=kTRUE );
+  void SetAverageQEPINDiodeAvailable     ( const Bool_t b=kTRUE );
+  void SetBlindPixelMethodValid          ( const Bool_t b, const MCalibrationCam::PulserColor_t col);
+  void SetCombinedMethodValid            ( const Bool_t b, const MCalibrationCam::PulserColor_t col);
+  void SetFFactorMethodValid             ( const Bool_t b, const MCalibrationCam::PulserColor_t col);  
+  void SetPINDiodeMethodValid            ( const Bool_t b, const MCalibrationCam::PulserColor_t col);  
+  void SetQEBlindPixel    ( Float_t f, MCalibrationCam::PulserColor_t col) { fQEBlindPixel   [col] = f; }
+  void SetQEBlindPixelVar ( Float_t f, MCalibrationCam::PulserColor_t col) { fQEBlindPixelVar[col] = f; }
+  void SetQECombined      ( Float_t f, MCalibrationCam::PulserColor_t col) { fQECombined     [col] = f; }
+  void SetQECombinedVar   ( Float_t f, MCalibrationCam::PulserColor_t col) { fQECombinedVar  [col] = f; }
+  void SetQEFFactor       ( Float_t f, MCalibrationCam::PulserColor_t col) { fQEFFactor      [col] = f; }
+  void SetQEFFactorVar    ( Float_t f, MCalibrationCam::PulserColor_t col) { fQEFFactorVar   [col] = f; }
+  void SetQEPINDiode      ( Float_t f, MCalibrationCam::PulserColor_t col) { fQEPINDiode     [col] = f; }
+  void SetQEPINDiodeVar   ( Float_t f, MCalibrationCam::PulserColor_t col) { fQEPINDiodeVar  [col] = f; }
+
+  // Updates
+  Bool_t  UpdateBlindPixelMethod();
+  Bool_t  UpdateCombinedMethod  ();
+  Bool_t  UpdateFFactorMethod   ();
+  Bool_t  UpdatePINDiodeMethod  ();
+
+  ClassDef(MCalibrationQEPix, 3)     // Container Quantum Efficieny Calibration Results Pixel
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationRelTimeCalc.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationRelTimeCalc.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationRelTimeCalc.cc	(revision 9661)
@@ -0,0 +1,525 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug  04/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//   MCalibrationRelTimeCalc
+//
+//   Task to finalize the relative time calibration obtained 
+//   from the fit results to the summed FADC slice distributions delivered by 
+//   MCalibrationRelTimeCam, calculated and filled by MHCalibrationRelTimeCam, 
+//
+//   PreProcess(): Initialize pointers to MCalibrationRelTimeCam, 
+//               
+//   ReInit():     Initializes pointer to MBadPixelsCam
+//
+//   Process():    Nothing to be done, histograms getting filled by MHCalibrationChargeCam
+//
+//   PostProcess(): - FinalizeRelTimes()
+//                  - FinalizeBadPixels()
+//
+//  Input Containers:
+//   MCalibrationRelTimeCam
+//   MBadPixelsCam
+//   MGeomCam
+//
+//  Output Containers:
+//   MCalibrationRelTimeCam
+//   MBadPixelsCam
+//
+//  
+//////////////////////////////////////////////////////////////////////////////
+#include "MCalibrationRelTimeCalc.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MGeomCam.h"
+#include "MGeomPix.h"
+
+#include "MCalibrationRelTimeCam.h"
+#include "MCalibrationRelTimePix.h"
+
+#include "MBadPixelsCam.h"
+#include "MBadPixelsPix.h"
+
+
+ClassImp(MCalibrationRelTimeCalc);
+
+using namespace std;
+
+const Float_t MCalibrationRelTimeCalc::fgRelTimeResolutionLimit = 0.75;
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+// Sets all pointers to NULL
+// 
+// Initializes:
+// - fRelTimeResolutionLimit to fgRelTimeResolutionimit
+// - fOutputPath        to "."
+// - fOutputFile        to "TimeCalibStat.txt"
+//
+// Calls:
+// - Clear()
+//
+MCalibrationRelTimeCalc::MCalibrationRelTimeCalc(const char *name, const char *title)
+    : fBadPixels(NULL), fCam(NULL), fGeom(NULL)
+{
+        
+  fName  = name  ? name  : "MCalibrationRelTimeCalc";
+  fTitle = title ? title : "Task to finalize the relative time calibration";
+  
+  SetRelTimeResolutionLimit();
+  SetOutputPath();
+  SetOutputFile();
+ 
+  Clear();
+  
+}
+
+// --------------------------------------------------------------------------
+//
+// Sets:
+// - all flags to kFALSE
+//
+void MCalibrationRelTimeCalc::Clear(const Option_t *o)
+{
+    SkipHiLoGainCalibration( kFALSE );    
+}
+
+
+// -----------------------------------------------------------------------------------
+//
+// The following containers are searched and created if they were not found:
+//
+//  - MBadPixelsCam
+//
+Int_t MCalibrationRelTimeCalc::PreProcess(MParList *pList)
+{
+  
+
+  fBadPixels = (MBadPixelsCam*)pList->FindCreateObj("MBadPixelsCam");
+  if (!fBadPixels)
+    {
+      *fLog << err << "Could not find or create MBadPixelsCam ... aborting." << endl;
+      return kFALSE;
+    }
+
+  
+  
+  return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Search for the following input containers and abort if not existing:
+//  - MGeomCam
+//  - MCalibrationRelTimeCam
+// 
+// It defines the PixId of every pixel in:
+//
+// - MCalibrationRelTimeCam 
+//
+// It sets all pixels in excluded which have the flag fBadBixelsPix::IsBad() set in:
+// 
+// - MCalibrationRelTimePix
+//
+Bool_t MCalibrationRelTimeCalc::ReInit(MParList *pList )
+{
+
+  fGeom = (MGeomCam*)pList->FindObject("MGeomCam");
+  if (!fGeom)
+    {
+      *fLog << err << "No MGeomCam found... aborting." << endl;
+      return kFALSE;
+    }
+  
+  fCam = (MCalibrationRelTimeCam*)pList->FindObject("MCalibrationRelTimeCam");
+  if (!fCam)
+    {
+      *fLog << err << "Cannot find MCalibrationRelTimeCam... aborting" << endl;
+      *fLog << err << "Maybe you forget to call an MFillH for the MHCalibrationRelTimeCam before..." << endl;
+      return kFALSE;
+    }
+
+  
+  UInt_t npixels     = fGeom->GetNumPixels();
+  
+  for (UInt_t i=0; i<npixels; i++)
+    {
+      
+      MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*fCam)  [i];
+      MBadPixelsPix         &bad = (*fBadPixels)[i];
+      
+      pix.SetPixId(i);
+      
+      if (bad.IsBad())
+        {
+          pix.SetExcluded();
+          continue;
+        }
+      
+    }
+
+  return kTRUE;
+}
+
+// ----------------------------------------------------------------------------------
+//  
+// Nothing to be done in Process, but have a look at MHCalibrationRelTimeCam, instead
+// 
+Int_t MCalibrationRelTimeCalc::Process()
+{
+  return kTRUE;
+}
+
+// -----------------------------------------------------------------------
+//
+// Return if number of executions is null.
+//
+// First loop over pixels, average areas and sectors, call: 
+//  - FinalizeRelTimes()
+// for every entry. Count number of valid pixels in loop and return kFALSE
+// if there are none (the "Michele check").
+//
+// Call FinalizeBadPixels()
+//
+// Call MParContainer::SetReadyToSave() for fCam
+//
+// Print out some statistics
+//
+Int_t MCalibrationRelTimeCalc::PostProcess()
+{
+
+  if (GetNumExecutions()==0)
+    return kFALSE;
+
+  //
+  // First loop over pixels, call FinalizePedestals and FinalizeRelTimes
+  //
+  FinalizeRelTimes();
+
+  //
+  // Finalize Bad Pixels
+  // 
+  FinalizeBadPixels();
+
+  //
+  // Re-direct the output to an ascii-file from now on:
+  //
+  MLog asciilog;
+  asciilog.SetOutputFile(GetOutputFile(),kTRUE);
+  SetLogStream(&asciilog);
+  //
+  // Finalize calibration statistics
+  //
+  FinalizeUnsuitablePixels();
+
+  fCam      ->SetReadyToSave();
+  fBadPixels->SetReadyToSave();
+
+  *fLog << inf << endl;
+  *fLog << GetDescriptor() << ": Errors statistics:" << endl;  
+
+  PrintUncalibrated(MBadPixelsPix::kDeviatingTimeResolution,    
+                    Form("%s%2.1f%s","Time resolution less than ",fRelTimeResolutionLimit," FADC slices from Mean:   "));
+  PrintUncalibrated(MBadPixelsPix::kRelTimeOscillating,   
+                    "Pixels with changing Rel. Times   over time:      ");
+  PrintUncalibrated(MBadPixelsPix::kRelTimeNotFitted,     
+                    "Pixels with unsuccesful Gauss fit to the times:   ");
+
+  SetLogStream(&gLog);
+
+  return kTRUE;
+}
+
+
+// ----------------------------------------------------------------------------------------------------
+//
+//
+// First loop: Calculate a mean and mean RMS of time resolution per area index 
+//             Include only pixels which are not MBadPixelsPix::kUnsuitableRun or 
+//             MBadPixelsPix::kUnreliableRun (see FinalizeBadPixels())
+//              
+// Second loop: Exclude those deviating by more than fRelTimeResolutionLimit FADC slices
+//              from the mean (obtained in first loop). Set 
+//              MBadPixelsPix::kDeviatingTimeResolution if excluded.
+// 
+void MCalibrationRelTimeCalc::FinalizeRelTimes()
+{
+
+  const UInt_t npixels  = fGeom->GetNumPixels();
+  const UInt_t nareas   = fGeom->GetNumAreas();
+
+  Float_t lowlim       [nareas];
+  Float_t upplim       [nareas];
+  Float_t areasum      [nareas];
+  //  Float_t areasum2     [nareas];
+  Int_t   numareavalid [nareas];
+  Int_t   useunreliable[nareas];
+
+  memset(lowlim        ,0, nareas   * sizeof(Float_t));
+  memset(upplim        ,0, nareas   * sizeof(Float_t));
+  memset(areasum       ,0, nareas   * sizeof(Float_t));
+  //  memset(areasum2      ,0, nareas   * sizeof(Float_t));
+  memset(numareavalid  ,0, nareas   * sizeof(Int_t  ));
+  memset(useunreliable ,0, nareas   * sizeof(Int_t  ));
+
+  //
+  // Apero loop: Count number of unreliable pixels:
+  //     
+  for (UInt_t i=0; i<npixels; i++)
+    {
+      MBadPixelsPix &bad = (*fBadPixels)[i];      
+      const Int_t  aidx  = (*fGeom)[i].GetAidx();
+
+      if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
+        continue;
+
+      if (bad.IsUnsuitable(MBadPixelsPix::kUnreliableRun))
+        continue;
+
+      numareavalid[aidx] ++;
+    }
+  
+  for (UInt_t aidx=0; aidx<nareas; aidx++)
+    if (numareavalid[aidx] < 100)
+      useunreliable[aidx] = 1;
+
+  memset(numareavalid  ,0, nareas   * sizeof(Int_t  ));
+  //
+  // First loop: Get mean time resolution the RMS
+  //             The loop is only to recognize later pixels with very deviating numbers
+  //
+  for (UInt_t i=0; i<npixels; i++)
+    {
+      
+      MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*fCam)[i];
+      MBadPixelsPix          &bad = (*fBadPixels)[i];
+      
+      if (pix.IsExcluded())
+        continue;
+
+      if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
+        continue;
+
+      const Int_t   aidx  = (*fGeom)[i].GetAidx();
+
+      if (!useunreliable[aidx])
+        if (bad.IsUnsuitable(MBadPixelsPix::kUnreliableRun))
+          continue;
+
+      const Float_t res   = pix.GetTimePrecision();
+
+      areasum     [aidx] += res;
+      //      areasum2    [aidx] += res*res;
+      numareavalid[aidx] ++;
+    }
+
+
+  for (UInt_t aidx=0; aidx<nareas; aidx++)
+    {
+      if (numareavalid[aidx] < 20)
+        {
+          *fLog << warn << GetDescriptor() << ": Less than 20 pixels with valid time resolution found "
+                << "in area index: " << aidx << endl;
+          continue;
+        }
+ 
+      // Calculate the rms out of sum2:
+      /*
+      areasum2[aidx]  = (areasum2[aidx] - areasum[aidx]*areasum[aidx]/numareavalid[aidx]);
+      areasum2[aidx] /= (numareavalid[aidx]-1.);
+      */
+      areasum [aidx] /= numareavalid[aidx];
+      lowlim  [aidx]  = 0.;
+      upplim  [aidx]  = areasum [aidx] + fRelTimeResolutionLimit;
+      
+    }
+  *fLog << endl;  
+
+
+  for (UInt_t i=0; i<npixels; i++)
+    {
+      
+      MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*fCam)[i];
+      MBadPixelsPix          &bad = (*fBadPixels)[i];
+      
+      if (pix.IsExcluded())
+        continue;
+      
+      if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
+        continue;
+      
+      const Float_t res  = pix.GetTimePrecision();
+      const Int_t   aidx   = (*fGeom)[i].GetAidx();
+      
+      if ( res < lowlim[aidx] || res > upplim[aidx] )
+        {
+          *fLog << warn << GetDescriptor() << ": Deviating time resolution: " 
+            << Form("%4.2f",res) << " out of accepted limits: [" 
+                << Form("%4.2f%s%4.2f",lowlim[aidx],",",upplim[aidx]) << "] in pixel " << i << endl;
+          bad.SetUncalibrated( MBadPixelsPix::kDeviatingTimeResolution);
+          pix.SetExcluded();
+        }
+    }
+}
+
+
+// -----------------------------------------------------------------------------------
+//
+// Sets pixel to MBadPixelsPix::kUnsuitableRun, if one of the following flags is set:
+// - MBadPixelsPix::kRelTimeIsPedestal
+// - MBadPixelsPix::kRelTimeErrNotValid 
+// - MBadPixelsPix::kRelTimeRelErrNotValid 
+//
+// - Call MCalibrationPix::SetExcluded() for the bad pixels
+//
+void MCalibrationRelTimeCalc::FinalizeBadPixels()
+{
+  
+  for (Int_t i=0; i<fBadPixels->GetSize(); i++)
+    {
+      
+      MBadPixelsPix    &bad    = (*fBadPixels)[i];
+      MCalibrationPix  &pix    = (*fCam)[i];
+
+      if (bad.IsUncalibrated( MBadPixelsPix::kDeviatingTimeResolution))
+        bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun   );
+ 
+      if (bad.IsUncalibrated( MBadPixelsPix::kRelTimeNotFitted))
+        bad.SetUnsuitable(   MBadPixelsPix::kUnreliableRun   );
+ 
+      if (bad.IsUncalibrated( MBadPixelsPix::kRelTimeOscillating))
+        bad.SetUnsuitable(   MBadPixelsPix::kUnreliableRun   );
+ 
+      if (bad.IsUnsuitable(   MBadPixelsPix::kUnsuitableRun    ))
+        pix.SetExcluded();
+
+    }
+}
+
+
+// -----------------------------------------------------------------------------------------------
+//
+// - Print out statistics about BadPixels of type UnsuitableType_t 
+// - store numbers of bad pixels of each type in fCam
+//
+void MCalibrationRelTimeCalc::FinalizeUnsuitablePixels()
+{
+  
+  *fLog << inf << endl;
+  *fLog << GetDescriptor() << ": Rel. Times Calibration status:" << endl;
+  *fLog << dec << setfill(' ');
+
+  const Int_t nareas = fGeom->GetNumAreas();
+
+  Int_t counts[nareas];
+  memset(counts,0,nareas*sizeof(Int_t));
+
+  for (Int_t i=0; i<fBadPixels->GetSize(); i++)
+    {
+      MBadPixelsPix &bad = (*fBadPixels)[i];
+      if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
+        {
+          const Int_t aidx = (*fGeom)[i].GetAidx();
+          counts[aidx]++;
+        }
+    }
+
+  for (Int_t aidx=0; aidx<nareas; aidx++)
+    fCam->SetNumUnsuitable(counts[aidx], aidx);
+
+  if (fGeom->InheritsFrom("MGeomCamMagic"))
+    *fLog << " " << setw(7) << "Uncalibrated Pixels:            " 
+          << Form("%s%3i%s%3i","Inner: ",counts[0]," Outer: ",counts[1]) << endl;
+
+  memset(counts,0,nareas*sizeof(Int_t));
+
+  for (Int_t i=0; i<fBadPixels->GetSize(); i++)
+    {
+      MBadPixelsPix &bad = (*fBadPixels)[i];
+      if (bad.IsUnsuitable(MBadPixelsPix::kUnreliableRun))
+        {
+          const Int_t aidx = (*fGeom)[i].GetAidx();
+          counts[aidx]++;
+        }
+    }
+
+  for (Int_t aidx=0; aidx<nareas; aidx++)
+    fCam->SetNumUnreliable(counts[aidx], aidx);
+
+  *fLog << " " << setw(7) << "Unreliable Pixels:              "
+        << Form("%s%3i%s%3i","Inner: ",counts[0]," Outer: ",counts[1]) << endl;
+
+}
+
+// -----------------------------------------------------------------------------------------------
+//
+// Print out statistics about BadPixels of type UncalibratedType_t 
+// 
+void MCalibrationRelTimeCalc::PrintUncalibrated(MBadPixelsPix::UncalibratedType_t typ, const char *text) const 
+{
+  
+  UInt_t countinner = 0;
+  UInt_t countouter = 0;
+  for (Int_t i=0; i<fBadPixels->GetSize(); i++)
+    {
+      MBadPixelsPix &bad = (*fBadPixels)[i];
+      if (bad.IsUncalibrated(typ))
+        {
+          if (fGeom->GetPixRatio(i) == 1.)
+            countinner++;
+          else
+            countouter++;
+        }
+    }
+
+  *fLog << " " << setw(7) << text  
+        << Form("%s%3i%s%3i","Inner: ",countinner," Outer: ",countouter) << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the path for output file
+// 
+void MCalibrationRelTimeCalc::SetOutputPath(TString path)
+{
+  fOutputPath = path;
+  if (fOutputPath.EndsWith("/"))
+    fOutputPath = fOutputPath(0, fOutputPath.Length()-1);
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the output file
+// 
+const char* MCalibrationRelTimeCalc::GetOutputFile()
+{
+  return Form("%s/%s", (const char*)fOutputPath, (const char*)fOutputFile);
+}
Index: /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationRelTimeCalc.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationRelTimeCalc.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationRelTimeCalc.h	(revision 9661)
@@ -0,0 +1,81 @@
+#ifndef MARS_MCalibrationRelTimeCalc
+#define MARS_MCalibrationRelTimeCalc
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MCalibrationRelTimeCalc                                                   //
+//                                                                         //
+// Integrates the time slices of the all pixels of a calibration event     //
+// and substract the pedestal value                                        //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+#ifndef MARS_MBadPixelsPix
+#include "MBadPixelsPix.h"
+#endif
+
+#ifndef MARS_MCalibrationRelTimeCam
+#include "MCalibrationRelTimeCam.h"
+#endif
+
+class MCalibrationRelTimePix;
+class MCalibrationRelTimeCam;
+class MGeomCam;
+class MBadPixelsCam;
+class MBadPixelsPix;
+class MCalibrationRelTimeCalc : public MTask
+{
+private:
+
+  static const Float_t fgRelTimeResolutionLimit; //! Default for fRelTimeResolutionLimit (now set to: 0.75)
+ 
+  // Variables
+  Float_t fRelTimeResolutionLimit;              // Limit acceptance rel. time resolution (in FADC slices)
+  Byte_t  fFlags;                               // Bit-field for the flags
+  
+  TString fOutputPath;                          // Path to the output file
+  TString fOutputFile;                          // Name of the output file  
+  
+  // Pointers
+  MBadPixelsCam              *fBadPixels;      //  Bad Pixels 
+  MCalibrationRelTimeCam     *fCam;            //  Calibrated RelTimes of all pixels 
+  MGeomCam                   *fGeom;           //! Camera geometry
+
+  // enums
+  enum  { kHiLoGainCalibration };
+
+  // functions
+  const char* GetOutputFile();
+  void   FinalizeAverageResolution();
+  void   FinalizeRelTimes     ();
+  void   FinalizeBadPixels      ();
+  void   FinalizeUnsuitablePixels();
+
+  void   PrintUncalibrated( MBadPixelsPix::UncalibratedType_t typ, const char *text) const;
+
+  Int_t  PreProcess (MParList *pList);
+  Bool_t ReInit     (MParList *pList); 
+  Int_t  Process    ();
+  Int_t  PostProcess();
+
+public:
+
+  MCalibrationRelTimeCalc(const char *name=NULL, const char *title=NULL);
+
+  void Clear(const Option_t *o="");
+  
+  void SetOutputPath        ( TString path="."                   );
+  void SetOutputFile        ( TString file="TimeCalibStat.txt"   ) { fOutputFile        = file; }
+  void SetRelTimeResolutionLimit ( const Float_t f=fgRelTimeResolutionLimit    ) { fRelTimeResolutionLimit = f;   }
+
+  void SkipHiLoGainCalibration ( const Bool_t b=kTRUE )
+      { b ? CLRBIT(fFlags, kHiLoGainCalibration) : SETBIT(fFlags, kHiLoGainCalibration); }
+
+  ClassDef(MCalibrationRelTimeCalc, 1)   // Task finalizing the relative time Calibration 
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationRelTimeCam.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationRelTimeCam.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationRelTimeCam.cc	(revision 9661)
@@ -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): Markus Gaug   11/2003 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                               
+// MCalibrationRelTimeCam                                               
+//                                                               
+// Storage container for relative arrival time calibration results         
+// of the whole camera.
+//
+// Individual pixels have to be cast when retrieved e.g.:
+// MCalibrationRelTimePix &avpix = (MCalibrationRelTimePix&)(*fRelCam)[i]
+// 
+// The following "calibration" constants can be retrieved from each pixel:
+// - GetTimeOffset(): The mean offset in relative times, 
+//   has to be added to any calculated relative time in the camera. 
+// - GetTimePrecision(): The Gauss sigma of histogrammed relative arrival 
+//   times for the calibration run. Gives an estimate about the timing 
+//   resolution.
+//
+// ALL RELATIVE TIMES HAVE TO BE CALCULATED W.R.T. PIXEL IDX 1 
+// (HARDWARE NUMBER: 2) !!
+//
+// Averaged values over one whole area index (e.g. inner or outer pixels for 
+// the MAGIC camera), can be retrieved via: 
+// MCalibrationRelTimePix &avpix = (MCalibrationRelTimePix&)fRelCam->GetAverageArea(i)
+//
+// Averaged values over one whole camera sector can be retrieved via: 
+// MCalibrationRelTimePix &avpix = (MCalibrationRelTimePix&)fRelCam->GetAverageSector(i)
+//
+// Note the averageing has been done on an event-by-event basis. Resulting 
+// Sigma's of the Gauss fit have been multiplied with the square root of the number 
+// of involved pixels in order to make a direct comparison possible with the mean of 
+// sigmas. 
+//
+// See also: MHCalibrationRelTimePix, MHCalibrationRelTimeCam              
+//                                                                         
+// The calculated values (types of GetPixelContent) are:
+// 
+// Fitted values:
+// ============== 
+//
+// 0: Mean Time Offset
+// 1: Error of Mean Time Offset
+// 2: Sigma of Time Offset == Time Resolution 
+// 3: Error of Sigma of Time Offset
+//
+// Useful variables derived from the fit results:
+// =============================================
+//
+// 4: Returned probability of Gauss fit to Rel. Arrival Time distribution
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCalibrationRelTimeCam.h"
+#include "MCalibrationCam.h"
+
+#include <TClonesArray.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MGeomCam.h"
+#include "MGeomPix.h"
+
+#include "MCalibrationRelTimePix.h"
+
+ClassImp(MCalibrationRelTimeCam);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+// Creates a TClonesArray of MCalibrationRelTimePix containers, initialized to 1 entry, destinated 
+// to hold one container per pixel. Later, a call to MCalibrationRelTimeCam::InitSize() 
+// has to be performed (in MGeomApply). 
+//
+// Creates a TClonesArray of MCalibrationRelTimePix containers, initialized to 1 entry, destinated 
+// to hold one container per pixel AREA. Later, a call to MCalibrationRelTimeCam::InitAreas() 
+// has to be performed (in MGeomApply). 
+//
+// Creates a TClonesArray of MCalibrationRelTimePix containers, initialized to 1 entry, destinated
+// to hold one container per camera SECTOR. Later, a call to MCalibrationRelTimeCam::InitSectors() 
+// has to be performed (in MGeomApply). 
+//
+MCalibrationRelTimeCam::MCalibrationRelTimeCam(const char *name, const char *title)
+{
+
+  fName  = name  ? name  : "MCalibrationRelTimeCam";
+  fTitle = title ? title : "Container for Relative Time Calibration Information";
+  
+  fPixels           = new TClonesArray("MCalibrationRelTimePix",1);
+  fAverageAreas     = new TClonesArray("MCalibrationRelTimePix",1);
+  fAverageSectors   = new TClonesArray("MCalibrationRelTimePix",1);
+  
+}
+
+// --------------------------------------------------------------------------
+//
+// Print first the well fitted pixels 
+// and then the ones which are not Valid
+//
+void MCalibrationRelTimeCam::Print(Option_t *o) const
+{
+
+  *fLog << all << GetDescriptor() << ":" << endl;
+  int id = 0;
+  
+  *fLog << all << "Calibrated pixels:" << endl;
+  *fLog << all << endl;
+
+  TIter Next(fPixels);
+  MCalibrationRelTimePix *pix;
+  while ((pix=(MCalibrationRelTimePix*)Next()))
+    {
+      
+      if (!pix->IsExcluded()) 
+	{                            
+
+          *fLog << all 
+                << Form("%s%4i%s%4.2f%s%4.2f%s%4.2f%s%4.2f","Pix  ",pix->GetPixId(),
+                        ":            Offset: ",pix->GetTimeOffset()," +- ",pix->GetTimeOffsetErr(),
+                        "   Precision: ",pix->GetTimePrecision()," +- ",pix->GetTimePrecisionErr())
+		<< endl;
+          id++;
+	}
+    }
+  
+  *fLog << all << id << " pixels" << endl;
+  id = 0;
+  
+   
+  *fLog << all << endl;
+  *fLog << all << "Excluded pixels:" << endl;
+  *fLog << all << endl;
+  
+  id = 0;
+
+  TIter Next4(fPixels);
+  while ((pix=(MCalibrationRelTimePix*)Next4()))
+  {
+      if (pix->IsExcluded())
+      {
+	  *fLog << all << pix->GetPixId() << endl;
+	  id++;
+      }
+  }
+  *fLog << all << id << " Excluded pixels " << endl;
+  *fLog << endl;
+
+  TIter Next5(fAverageAreas);
+  while ((pix=(MCalibrationRelTimePix*)Next5()))
+  {
+    *fLog << all 
+          << Form("%s%4i%s%4.2f%s%4.2f%s%4.2f%s%4.2f","Average Area   ",pix->GetPixId(),
+                  ":  Offset: ",pix->GetTimeOffset()," +- ",pix->GetTimeOffsetErr(),
+                  "   Precision: ",pix->GetTimePrecision()," +- ",pix->GetTimePrecisionErr())
+          << endl;
+  }
+
+  TIter Next6(fAverageSectors);
+  while ((pix=(MCalibrationRelTimePix*)Next5()))
+  {
+    *fLog << all 
+          << Form("%s%4i%s%4.2f%s%4.2f%s%4.2f%s%4.2f","Average Sector ",pix->GetPixId(),
+                  ":  Offset: ",pix->GetTimeOffset()," +- ",pix->GetTimeOffsetErr(),
+                  "   Precision: ",pix->GetTimePrecision()," +- ",pix->GetTimePrecisionErr())
+          << endl;
+  }
+}
+
+
+// --------------------------------------------------------------------------
+//
+// The types are as follows:
+// 
+// Fitted values:
+// ============== 
+//
+// 0: Fitted RelTime
+// 1: Error of fitted RelTime
+// 2: Sigma of fitted RelTime
+// 3: Error of Sigma of fitted RelTime
+//
+// Useful variables derived from the fit results:
+// =============================================
+//
+// 4: Returned probability of Gauss fit to RelTime distribution
+//
+Bool_t MCalibrationRelTimeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
+{
+
+  if (idx > GetSize())
+    return kFALSE;
+
+  Float_t area = cam[idx].GetA();
+
+ if (area == 0)
+    return kFALSE;
+
+ MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*this)[idx];
+
+  switch (type)
+    {
+    case 0:
+      if (pix.IsExcluded())
+        return kFALSE;
+      val = pix.GetMean();
+      break;
+    case 1:
+      if (pix.IsExcluded())
+        return kFALSE;
+      val = pix.GetMeanErr();
+      break;
+    case 2:
+      if (pix.IsExcluded())
+        return kFALSE;
+      val = pix.GetSigma();
+      break;
+    case 3:
+      if (pix.IsExcluded())
+        return kFALSE;
+      val = pix.GetSigmaErr();
+      break;
+    case 4:
+      if (pix.IsExcluded())
+        return kFALSE;
+      val = pix.GetProb();
+      break;
+    default:
+      return kFALSE;
+    }
+
+  return val!=-1.;
+
+}
+
+// --------------------------------------------------------------------------
+//
+// Calls MCalibrationPix::DrawClone()
+//
+void MCalibrationRelTimeCam::DrawPixelContent(Int_t idx) const
+{
+  (*this)[idx].DrawClone();
+}
+
Index: /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationRelTimeCam.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationRelTimeCam.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationRelTimeCam.h	(revision 9661)
@@ -0,0 +1,29 @@
+#ifndef MARS_MCalibrationRelTimeCam
+#define MARS_MCalibrationRelTimeCam
+
+#ifndef MARS_MCalibrationCam
+#include "MCalibrationCam.h"
+#endif
+
+#ifndef ROOT_TArrayI
+#include "TArrayI.h"
+#endif
+
+
+class MCalibrationRelTimeCam : public MCalibrationCam
+{
+public:
+
+  MCalibrationRelTimeCam(const char *name=NULL, const char *title=NULL);
+
+  // Prints
+  void Print(Option_t *o="") const;
+  
+  // Others
+  Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
+  void DrawPixelContent(Int_t num) const;    
+
+  ClassDef(MCalibrationRelTimeCam, 1)	// Container Rel. Arrival Time Calibration Results Camera
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationRelTimePix.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationRelTimePix.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationRelTimePix.cc	(revision 9661)
@@ -0,0 +1,58 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug   02/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+\* ======================================================================== */
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MCalibrationRelTimePix                                                  //
+//                                                                         //
+// Storage container for relative arrival time calibration results         // 
+// of one Pixel (PMT).                                                     //
+// The following "calibration" constants can be retrieved:                 //
+// - GetTimeOffset(): The mean offset in relative times, 
+//   has to be added to any calculated relative time in the camera. 
+// - GetTimePrecision(): The Gauss sigma of histogrammed relative arrival 
+//   times for the calibration run. Gives an estimate about the timing 
+//   resolution.
+//
+// ALL RELATIVE TIMES HAVE TO BE CALCULATED W.R.T. PIXEL IDX 1 
+// (HARDWARE NUMBER: 2) !!
+//
+// See also: MHCalibrationRelTimePix, MHCalibrationRelTimeCam              //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MCalibrationRelTimePix.h"
+
+ClassImp(MCalibrationRelTimePix);
+
+using namespace std;
+// --------------------------------------------------------------------------
+//
+// Default Constructor
+//
+MCalibrationRelTimePix::MCalibrationRelTimePix(const char *name, const char *title)
+{
+
+  fName  = name  ? name  : "MCalibrationRelTimePix";
+  fTitle = title ? title : "Results of MHCalibrationRelTimePix ";
+
+}
+
Index: /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationRelTimePix.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationRelTimePix.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MCalibrationRelTimePix.h	(revision 9661)
@@ -0,0 +1,26 @@
+#ifndef MARS_MCalibrationRelTimePix
+#define MARS_MCalibrationRelTimePix
+
+#ifndef MARS_MCalibrationPix
+#include "MCalibrationPix.h"
+#endif
+
+class MCalibrationRelTimePix : public MCalibrationPix
+{
+private:
+
+public:
+
+  MCalibrationRelTimePix(const char *name=NULL, const char *title=NULL);
+  ~MCalibrationRelTimePix() {}
+  
+  Float_t GetTimeOffset()       const { return GetMean();        }
+  Float_t GetTimeOffsetErr()    const { return GetMeanErr();     }
+  Float_t GetTimePrecision()    const { return GetSigma();       }
+  Float_t GetTimePrecisionErr() const { return GetSigmaErr();    }
+
+  ClassDef(MCalibrationRelTimePix, 1)	// Container Rel. Arrival Time Calibration Results Pixel
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationCam.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationCam.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationCam.cc	(revision 9661)
@@ -0,0 +1,1024 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug   02/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+/////////////////////////////////////////////////////////////////////////////
+//                                                               
+// MHCalibrationCam                                               
+//
+// Base class for camera calibration classes. Incorporates the TObjArray's:
+// - fHiGainArray (for calibrated High Gains per pixel)
+// - fLoGainArray (for calibrated Low Gains per pixel) 
+// - fAverageHiGainAreas (for averaged High Gains events per camera area index)
+// - fAverageLoGainAreas (for averaged High Gains events per camera area index)
+// - fAverageHiGainSectors (for averaged High Gains events per camera sector )
+// - fAverageLoGainSectors (for averaged High Gains events per camera sector )
+// These TObjArray's are called by their default constructors, thus no objects 
+// are created, until the derived class does so. 
+//
+// The corresponding operators: [],() and the operators GetAverageHiGainArea(), 
+// GetAverageLoGainArea(), GetAverageHiGainSector() and GetAverageLoGainSector() 
+// have to be cast to the corresponding class. It is assumed that all classes 
+// dealing with calibration pixels derive from MHGausEvents.
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MHCalibrationCam.h"
+
+#include <TVirtualPad.h>
+#include <TCanvas.h>
+#include <TPad.h>
+#include <TText.h>
+#include <TPaveText.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MCalibrationPix.h"
+#include "MCalibrationCam.h"
+
+#include "MHGausEvents.h"
+
+#include "MBadPixelsPix.h"
+#include "MBadPixelsCam.h"
+
+#include "MGeomCam.h"
+#include "MGeomPix.h"
+
+#include "MParList.h"
+
+#include "MRawRunHeader.h"
+
+ClassImp(MHCalibrationCam);
+
+using namespace std;
+
+const Int_t   MHCalibrationCam::fgAverageNbins    = 2000;
+const Int_t   MHCalibrationCam::fgPulserFrequency = 500;
+// --------------------------------------------------------------------------
+//
+// Default Constructor. 
+//
+// Sets:
+// - all pointers to NULL
+//
+// Initializes and sets owner of:
+// - fHiGainArray, fLoGainArray
+// - fAverageHiGainAreas, fAverageLoGainAreas
+// - fAverageHiGainSectors, fAverageLoGainSectors
+//
+// Initializes:
+// - fPulserFrequency to fgPulserFrequency
+//
+MHCalibrationCam::MHCalibrationCam(const char *name, const char *title)
+    :  fBadPixels(NULL), fCam(NULL), fGeom(NULL), fRunHeader(NULL), fDebug(kFALSE)
+{
+
+    fHiGainArray = new TObjArray;
+    fHiGainArray->SetOwner();
+    
+    fLoGainArray = new TObjArray;
+    fLoGainArray->SetOwner();
+
+    fAverageHiGainAreas = new TObjArray;
+    fAverageHiGainAreas->SetOwner();
+
+    fAverageLoGainAreas = new TObjArray;
+    fAverageLoGainAreas->SetOwner();
+
+    fAverageHiGainSectors = new TObjArray;
+    fAverageHiGainSectors->SetOwner();
+
+    fAverageLoGainSectors = new TObjArray;
+    fAverageLoGainSectors->SetOwner();
+
+    SetAverageNbins();
+    SetPulserFrequency();
+
+    fHiGainOverFlow = 0;
+    fLoGainOverFlow = 0;
+}
+
+// --------------------------------------------------------------------------
+//
+// Deletes the TClonesArray of:
+// - fHiGainArray, fLoGainArray
+// - fAverageHiGainAreas, fAverageLoGainAreas
+// - fAverageHiGainSectors, fAverageLoGainSectors
+//
+MHCalibrationCam::~MHCalibrationCam()
+{
+
+  delete fHiGainArray;
+  delete fLoGainArray;
+
+  delete fAverageHiGainAreas;
+  delete fAverageLoGainAreas;
+
+  delete fAverageHiGainSectors;
+  delete fAverageLoGainSectors;
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th High Gain pixel (pixel number)
+//
+MHGausEvents &MHCalibrationCam::operator[](UInt_t i)
+{
+  return *static_cast<MHGausEvents*>(fHiGainArray->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th High Gain pixel (pixel number)
+//
+const MHGausEvents &MHCalibrationCam::operator[](UInt_t i) const
+{
+  return *static_cast<MHGausEvents*>(fHiGainArray->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th Low Gain pixel (pixel number)
+//
+MHGausEvents  &MHCalibrationCam::operator()(UInt_t i)
+{
+  return *static_cast<MHGausEvents*>(fLoGainArray->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th Low Gain pixel (pixel number)
+//
+const MHGausEvents  &MHCalibrationCam::operator()(UInt_t i) const
+{
+  return *static_cast<MHGausEvents*>(fLoGainArray->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the current size of the TObjArray fAverageHiGainAreas
+// independently if the MHGausEvents is filled with values or not.
+//
+const Int_t MHCalibrationCam::GetAverageAreas() const
+{
+  return fAverageHiGainAreas->GetEntries();
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th High Gain pixel Area (area number)
+//
+MHGausEvents  &MHCalibrationCam::GetAverageHiGainArea(UInt_t i)
+{
+  return *static_cast<MHGausEvents*>(fAverageHiGainAreas->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th High Gain pixel Area (area number)
+//
+const MHGausEvents  &MHCalibrationCam::GetAverageHiGainArea(UInt_t i) const
+{
+  return *static_cast<MHGausEvents *>(fAverageHiGainAreas->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th Low Gain pixel Area (area number)
+//
+MHGausEvents  &MHCalibrationCam::GetAverageLoGainArea(UInt_t i)
+{
+  return *static_cast<MHGausEvents*>(fAverageLoGainAreas->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th Low Gain pixel Area (area number)
+//
+const MHGausEvents  &MHCalibrationCam::GetAverageLoGainArea(UInt_t i) const
+{
+  return *static_cast<MHGausEvents*>(fAverageLoGainAreas->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the current size of the TObjArray fAverageHiGainSectors
+// independently if the MHGausEvents is filled with values or not.
+//
+const Int_t MHCalibrationCam::GetAverageSectors() const
+{
+  return fAverageHiGainSectors->GetEntries();
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th High Gain Sector (sector number)
+//
+MHGausEvents  &MHCalibrationCam::GetAverageHiGainSector(UInt_t i)
+{
+  return *static_cast<MHGausEvents*>(fAverageHiGainSectors->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th High Gain Sector (sector number)
+//
+const MHGausEvents  &MHCalibrationCam::GetAverageHiGainSector(UInt_t i) const
+{
+  return *static_cast<MHGausEvents*>(fAverageHiGainSectors->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th Low Gain Sector (sector number)
+//
+MHGausEvents  &MHCalibrationCam::GetAverageLoGainSector(UInt_t i)
+{
+  return *static_cast<MHGausEvents*>(fAverageLoGainSectors->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th Low Gain Sector (sector number)
+//
+const MHGausEvents  &MHCalibrationCam::GetAverageLoGainSector(UInt_t i) const
+{
+  return *static_cast<MHGausEvents*>(fAverageLoGainSectors->UncheckedAt(i));
+}
+
+
+const TArrayI &MHCalibrationCam::GetRunNumbers() const 
+{
+  return fRunNumbers;
+}
+
+// --------------------------------------------------------------------------
+//
+// Our own clone function is necessary since root 3.01/06 or Mars 0.4
+// I don't know the reason. 
+//
+// Creates new MHCalibrationCam
+// Deletes the TObjArray's and Clones them individually
+// Copies the TArray's
+// Copies the fPulserFrequency
+//
+TObject *MHCalibrationCam::Clone(const char *) const
+{
+
+  //  const Int_t nhi   = fHiGainArray->GetEntries();
+  //  const Int_t nlo   = fLoGainArray->GetEntries();
+  const Int_t navhi = fAverageHiGainAreas->GetEntries();
+  const Int_t navlo = fAverageLoGainAreas->GetEntries();
+  const Int_t nsehi = fAverageHiGainSectors->GetEntries();
+  const Int_t nselo = fAverageLoGainSectors->GetEntries();
+  
+  //
+  // FIXME, this might be done faster and more elegant, by direct copy.
+  //
+  MHCalibrationCam *cam = new MHCalibrationCam();
+
+  //  cam->fHiGainArray->Expand(nhi);
+  //  cam->fLoGainArray->Expand(nlo);
+  cam->fAverageHiGainAreas->Expand(navhi);
+  cam->fAverageLoGainAreas->Expand(navlo);
+  cam->fAverageHiGainSectors->Expand(nsehi);
+  cam->fAverageLoGainSectors->Expand(nselo);
+
+  /*
+  for (int i=0; i<nhi; i++)
+    {
+      delete (*cam->fHiGainArray)[i];
+      (*cam->fHiGainArray)[i] = (*fHiGainArray)[i]->Clone();
+    }
+  for (int i=0; i<nlo; i++)
+    {
+      delete (*cam->fLoGainArray)[i];
+      (*cam->fLoGainArray)[i] = (*fLoGainArray)[i]->Clone();
+    }
+  */
+  
+  for (int i=0; i<navhi; i++)
+    {
+      //      delete (*cam->fAverageHiGainAreas)[i];
+      (*cam->fAverageHiGainAreas)[i] = (*fAverageHiGainAreas)[i]->Clone();
+    }
+  for (int i=0; i<navlo; i++)
+    {
+      //      delete (*cam->fAverageLoGainAreas)[i];
+      (*cam->fAverageLoGainAreas)[i] = (*fAverageLoGainAreas)[i]->Clone();
+    }
+  for (int i=0; i<nsehi; i++)
+    {
+      //      delete (*cam->fAverageHiGainSectors)[i];
+      (*cam->fAverageHiGainSectors)[i] = (*fAverageHiGainSectors)[i]->Clone();
+    }
+  for (int i=0; i<nselo; i++)
+    {
+      //      delete (*cam->fAverageLoGainSectors)[i];
+      (*cam->fAverageLoGainSectors)[i] = (*fAverageLoGainSectors)[i]->Clone();
+    }
+
+  cam->fAverageAreaNum         = fAverageAreaNum;
+  cam->fAverageAreaSat         = fAverageAreaSat;
+  cam->fAverageAreaSigma       = fAverageAreaSigma;      
+  cam->fAverageAreaSigmaVar    = fAverageAreaSigmaVar;   
+  cam->fAverageAreaRelSigma    = fAverageAreaRelSigma;
+  cam->fAverageAreaRelSigmaVar = fAverageAreaRelSigmaVar;   
+  cam->fAverageSectorNum       = fAverageSectorNum;      
+  cam->fRunNumbers             = fRunNumbers;
+
+  cam->fPulserFrequency        = fPulserFrequency;
+  cam->fAverageNbins           = fAverageNbins;
+
+  return cam;
+}
+
+// --------------------------------------------------------------------------
+//
+// Gets the pointers to:
+// - MGeomCam
+//
+// Calls SetupHists(const MParList *pList)
+//
+// Calls Delete-Function of:
+// - MHCalibrationCam::fHiGainArray, MHCalibrationCam::fLoGainArray
+// - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
+// - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
+//
+Bool_t MHCalibrationCam::SetupFill(const MParList *pList)
+{
+  
+  fGeom = (MGeomCam*)pList->FindObject("MGeomCam");
+  if (!fGeom)
+  {
+      *fLog << err << GetDescriptor() 
+            << ": MGeomCam not found... aborting." << endl;
+      return kFALSE;
+  }
+
+  fRunHeader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
+  if (!fRunHeader)
+  {
+    *fLog << warn << GetDescriptor() 
+          << ": MRawRunHeader not found... will not store run numbers." << endl;
+  }
+
+  fHiGainArray->Delete();
+  fLoGainArray->Delete();
+
+  fAverageHiGainAreas->Delete();
+  fAverageLoGainAreas->Delete();
+
+  fAverageHiGainSectors->Delete();
+  fAverageLoGainSectors->Delete();
+
+  return SetupHists(pList);
+}
+
+
+Bool_t MHCalibrationCam::SetupHists(const MParList *pList)
+{
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Gets or creates the pointers to:
+// - MBadPixelsCam
+//
+// Searches pointer to:
+// - MArrivalTimeCam
+//
+// Initializes, if empty to MArrivalTimeCam::GetSize() for:
+// - MHCalibrationCam::fHiGainArray, MHCalibrationCam::fLoGainArray
+//
+// Initializes, if empty to MGeomCam::GetNumAreas() for:
+// - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
+//
+// Initializes, if empty to MGeomCam::GetNumSectors() for:
+// - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
+// 
+// Initializes TArray's to MGeomCam::GetNumAreas and MGeomCam::GetNumSectors, respectively
+// Fills with number of valid pixels (if !MBadPixelsPix::IsBad()):
+// - MHCalibrationCam::fAverageAreaNum[area index]
+// - MHCalibrationCam::fAverageSectorNum[area index]
+//
+// Calls InitializeHists() for every entry in:
+// - MHCalibrationCam::fHiGainArray
+// - MHCalibrationCam::fAverageHiGainAreas
+// - MHCalibrationCam::fAverageHiGainSectors
+//
+// Sets Titles and Names for the Histograms 
+// - MHCalibrationCam::fAverageHiGainAreas
+// - MHCalibrationCam::fAverageHiGainSectors
+// 
+// Retrieves the run numbers from MRawRunHeader and stores them in fRunNumbers
+//
+Bool_t MHCalibrationCam::ReInit(MParList *pList)
+{
+
+  const Int_t npixels  = fGeom->GetNumPixels();
+  const Int_t nsectors = fGeom->GetNumSectors();
+  const Int_t nareas   = fGeom->GetNumAreas();
+
+  fBadPixels = (MBadPixelsCam*)pList->FindObject("MBadPixelsCam");
+  if (!fBadPixels)
+    {
+
+      fBadPixels = (MBadPixelsCam*)pList->FindCreateObj(AddSerialNumber("MBadPixelsCam"));
+      if (!fBadPixels)
+        {
+          gLog << err << "Cannot find nor create MBadPixelsCam ... abort." << endl;
+          return kFALSE;
+        }
+      else 
+        fBadPixels->InitSize(npixels);
+    }
+
+  //
+  // The function TArrayF::Set() already sets all entries to 0.
+  //
+  fAverageAreaNum.        Set(nareas);
+  fAverageAreaSat.        Set(nareas);           
+  fAverageAreaSigma.      Set(nareas);      
+  fAverageAreaSigmaVar.   Set(nareas);   
+  fAverageAreaRelSigma.   Set(nareas);   
+  fAverageAreaRelSigmaVar.Set(nareas);
+  fAverageSectorNum.      Set(nsectors);
+  fRunNumbers.            Set(fRunNumbers.GetSize()+1);
+
+  for (Int_t aidx=0; aidx<nareas; aidx++)
+      fAverageAreaNum[aidx] = 0;
+
+  for (Int_t sector=0; sector<nsectors; sector++)
+      fAverageSectorNum[sector] = 0;
+
+  for (Int_t i=0; i<npixels; i++)
+    {
+
+      if ((*fBadPixels)[i].IsBad())
+        continue;
+
+      fAverageAreaNum  [(*fGeom)[i].GetAidx()  ]++;
+      fAverageSectorNum[(*fGeom)[i].GetSector()]++;
+    }
+
+  if (fRunHeader)
+    fRunNumbers[fRunNumbers.GetSize()-1] = fRunHeader->GetRunNumber();
+
+  if (!ReInitHists(pList))
+    return kFALSE;
+
+  if (!fRunHeader)
+    return kTRUE;
+  
+  for (Int_t i=0; i<fHiGainArray->GetEntries(); i++)
+    {
+      TH1F *h = (*this)[i].GetHGausHist();
+      h->SetTitle( Form("%s%i%s", h->GetTitle(),fRunNumbers[fRunNumbers.GetSize()-1]," "));
+    }
+
+  for (Int_t i=0; i<fLoGainArray->GetEntries(); i++)
+    {
+      TH1F *h = (*this)(i).GetHGausHist();
+      h->SetTitle( Form("%s%i%s", h->GetTitle(),fRunNumbers[fRunNumbers.GetSize()-1]," "));
+    }
+  
+  for (Int_t j=0; j<nareas; j++)
+    {
+      TH1F *h = GetAverageHiGainArea(j).GetHGausHist();
+      h->SetTitle( Form("%s%i%s", h->GetTitle(),fRunNumbers[fRunNumbers.GetSize()-1]," "));
+    }
+  
+  for (Int_t j=0; j<nareas; j++)
+    {
+      TH1F *h = GetAverageLoGainArea(j).GetHGausHist();
+      h->SetTitle( Form("%s%i%s", h->GetTitle(),fRunNumbers[fRunNumbers.GetSize()-1]," "));
+    }
+  
+  for (Int_t j=0; j<nsectors; j++)
+    {
+      TH1F *h = GetAverageHiGainSector(j).GetHGausHist();
+      h->SetTitle( Form("%s%i%s", h->GetTitle(),fRunNumbers[fRunNumbers.GetSize()-1]," "));
+    }
+  
+  for (Int_t j=0; j<nsectors; j++)
+    {
+      TH1F *h = GetAverageLoGainSector(j).GetHGausHist();
+      h->SetTitle( Form("%s%i%s", h->GetTitle(),fRunNumbers[fRunNumbers.GetSize()-1]," "));
+    }
+
+  return kTRUE;
+}
+
+
+
+Bool_t MHCalibrationCam::ReInitHists(MParList *pList)
+{
+  return kTRUE;
+}
+
+
+
+//--------------------------------------------------------------------------------
+//
+// Retrieves from MGeomCam:
+// - number of pixels
+// - number of pixel areas
+// - number of sectors
+//
+// For all TObjArray's (including the averaged ones), the following steps are performed: 
+//
+// 1) Test size and return kFALSE if not matching
+// 2) 
+//
+Bool_t MHCalibrationCam::Fill(const MParContainer *par, const Stat_t w)
+{
+
+  const Int_t npixels  = fGeom->GetNumPixels();
+  const Int_t nareas   = fGeom->GetNumAreas();
+  const Int_t nsectors = fGeom->GetNumSectors();
+  
+  if (fHiGainArray->GetEntries() != npixels)
+    {
+      gLog << err << "ERROR - Size mismatch... abort." << endl;
+      return kFALSE;
+    }
+  
+  if (fLoGainArray->GetEntries() != npixels)
+    {
+      gLog << err << "ERROR - Size mismatch... abort." << endl;
+      return kFALSE;
+    }
+  
+  if (fAverageHiGainAreas->GetEntries() != nareas)
+    {
+      *fLog << err << "ERROR - Size mismatch in number of areas ... abort." << endl;
+      return kFALSE;
+    }
+
+  if (fAverageLoGainAreas->GetEntries() != nareas)
+    {
+      *fLog << err << "ERROR - Size mismatch in number of areas ... abort." << endl;
+      return kFALSE;
+    }
+
+  if (fAverageHiGainSectors->GetEntries() != nsectors)
+    {
+      *fLog << err << "ERROR - Size mismatch in number of sectors ... abort." << endl;
+      return kFALSE;
+    }
+
+  if (fAverageLoGainSectors->GetEntries() != nsectors)
+    {
+      *fLog << err << "ERROR - Size mismatch in number of sectors ... abort." << endl;
+      return kFALSE;
+    }
+
+  return FillHists(par, w);
+}
+
+Bool_t MHCalibrationCam::FillHists(const MParContainer *par, const Stat_t w)
+{
+  *fLog << warn << GetDescriptor() << "FillHists not overloaded! Can't be used!" << endl;
+  return kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+// 1) FinalizeHists()
+// 2) FinalizeBadPixels()
+// 3) CalcAverageSigma()
+//
+Bool_t MHCalibrationCam::Finalize()
+{
+  if (!FinalizeHists())
+    return kFALSE;
+
+  FinalizeBadPixels();
+  CalcAverageSigma();
+
+  return kTRUE;
+}
+
+Bool_t MHCalibrationCam::FinalizeHists()
+{
+  return kTRUE;
+}
+
+void MHCalibrationCam::FinalizeBadPixels()
+{
+}
+
+
+// -------------------------------------------------------------
+//
+// If MBadPixelsPix::IsBad():
+// - calls MHGausEvents::SetExcluded()
+//
+// Calls:
+// - MHGausEvents::InitBins()
+// - MHGausEvents::ChangeHistId(i)
+// - MHGausEvents::SetEventFrequency(fPulserFrequency)
+// 
+void MHCalibrationCam::InitHists(MHGausEvents &hist, MBadPixelsPix &bad, const Int_t i)
+{
+
+  if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
+    hist.SetExcluded();
+  
+  hist.InitBins();
+  hist.ChangeHistId(i);
+  hist.SetEventFrequency(fPulserFrequency);
+
+  TH1F *h = hist.GetHGausHist();
+  h->SetTitle( Form("%s%s", h->GetTitle()," Runs: "));
+}
+
+void MHCalibrationCam::FitHiGainArrays(MCalibrationCam &calcam, MBadPixelsCam &badcam,
+                                       MBadPixelsPix::UncalibratedType_t fittyp, 
+                                       MBadPixelsPix::UncalibratedType_t osctyp)
+{
+  
+  for (Int_t i=0; i<fHiGainArray->GetSize(); i++)
+    {
+      
+      MHGausEvents &hist = (*this)[i];
+      
+      if (hist.IsExcluded())
+        continue;
+      
+      MCalibrationPix &pix    = calcam[i];
+      MBadPixelsPix   &bad    = badcam[i];
+      
+      FitHiGainHists(hist,pix,bad,fittyp,osctyp);
+      
+    }
+
+  for (Int_t j=0; j<fAverageHiGainAreas->GetSize(); j++)
+    {
+      
+      MHGausEvents     &hist = GetAverageHiGainArea(j);      
+      MCalibrationPix  &pix  = calcam.GetAverageArea(j);
+      MBadPixelsPix    &bad  = calcam.GetAverageBadArea(j);        
+      
+      FitHiGainHists(hist,pix,bad,fittyp,osctyp);
+  }
+  
+
+  for (Int_t j=0; j<fAverageHiGainSectors->GetSize(); j++)
+    {
+      
+      MHGausEvents     &hist = GetAverageHiGainSector(j);      
+      MCalibrationPix  &pix  = calcam.GetAverageSector(j);
+      MBadPixelsPix    &bad  = calcam.GetAverageBadSector(j);        
+      
+      FitHiGainHists(hist,pix,bad,fittyp,osctyp);
+    }
+
+}
+
+void MHCalibrationCam::FitLoGainArrays(MCalibrationCam &calcam, MBadPixelsCam &badcam,
+                                            MBadPixelsPix::UncalibratedType_t fittyp, 
+                                            MBadPixelsPix::UncalibratedType_t osctyp)
+{
+  
+  for (Int_t i=0; i<fLoGainArray->GetSize(); i++)
+    {
+      
+      MHGausEvents &hist = (*this)(i);
+      
+      if (hist.IsExcluded())
+        continue;
+      
+      MCalibrationPix &pix    = calcam[i];
+      MBadPixelsPix   &bad    = badcam[i];
+      
+      FitLoGainHists(hist,pix,bad,fittyp,osctyp);
+      
+    }
+
+  for (Int_t j=0; j<fAverageLoGainAreas->GetSize(); j++)
+    {
+      
+      MHGausEvents     &hist = GetAverageLoGainArea(j);      
+      MCalibrationPix  &pix  = calcam.GetAverageArea(j);
+      MBadPixelsPix    &bad  = calcam.GetAverageBadArea(j);        
+      
+      FitLoGainHists(hist,pix,bad,fittyp,osctyp);
+  }
+  
+
+  for (Int_t j=0; j<fAverageLoGainSectors->GetSize(); j++)
+    {
+      
+      MHGausEvents     &hist = GetAverageLoGainSector(j);      
+      MCalibrationPix  &pix  = calcam.GetAverageSector(j);
+      MBadPixelsPix    &bad  = calcam.GetAverageBadSector(j);        
+      
+      FitLoGainHists(hist,pix,bad,fittyp,osctyp);
+    }
+}
+
+//------------------------------------------------------------
+//
+// For all averaged areas, the fitted sigma is multiplied with the square root of 
+// the number involved pixels
+//
+void MHCalibrationCam::CalcAverageSigma()
+{
+  
+  for (UInt_t j=0; j<fGeom->GetNumAreas(); j++)
+    {
+  
+      MCalibrationPix &pix    = fCam->GetAverageArea(j);
+
+      const Float_t numsqr    = TMath::Sqrt((Float_t)fAverageAreaNum[j]);
+      fAverageAreaSigma[j]    = pix.GetSigma    () * numsqr;
+      fAverageAreaSigmaVar[j] = pix.GetSigmaErr () * pix.GetSigmaErr() * numsqr;
+
+      pix.SetSigma   (fAverageAreaSigma[j]);
+      pix.SetSigmaVar(fAverageAreaSigmaVar[j]);
+
+      fAverageAreaRelSigma   [j]  = fAverageAreaSigma[j]    / pix.GetMean();
+      fAverageAreaRelSigmaVar[j]  = fAverageAreaSigmaVar[j] / (fAverageAreaSigma[j]*fAverageAreaSigma[j]);
+      fAverageAreaRelSigmaVar[j] += pix.GetMeanRelVar();
+      fAverageAreaRelSigmaVar[j] *= fAverageAreaRelSigma[j];
+    }
+}
+
+// ---------------------------------------------------------------------------
+//
+// Returns if the histogram is empty and sets the following flag:
+// - MBadPixelsPix::SetUnsuitable(MBadPixelsPix::kUnsuitableRun)
+//
+// Fits the histograms with a Gaussian, in case of failure 
+// calls MHGausEvents::RepeatFit(), in case of repeated failure 
+// calls MHGausEvents::BypassFit() and sets the following flags:
+// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::UncalibratedType_t fittyp )
+// - MBadPixelsPix::SetUnsuitable(   MBadPixelsPix::kUnreliableRun   )
+// 
+// Creates the fourier spectrum and tests MHGausEvents::IsFourierSpectrumOK(). 
+// In case no, sets the following flags:
+// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::UncalibratedType_t osctyp )
+// - MBadPixelsPix::SetUnsuitable(   MBadPixelsPix::kUnreliableRun     )
+//
+// Retrieves the results and store them in MCalibrationPix
+//
+void MHCalibrationCam::FitHiGainHists(MHGausEvents &hist, 
+                                      MCalibrationPix &pix, 
+                                      MBadPixelsPix &bad, 
+                                      MBadPixelsPix::UncalibratedType_t fittyp,
+                                      MBadPixelsPix::UncalibratedType_t osctyp)
+{
+
+
+  if (hist.IsEmpty())
+    return;
+
+  //
+  // 2) Fit the Hi Gain histograms with a Gaussian
+  //
+  if (!hist.FitGaus())
+    //
+    // 3) In case of failure set the bit Fitted to false and take histogram means and RMS
+    //
+    if (!hist.RepeatFit())
+      {
+        hist.BypassFit();
+        bad.SetUncalibrated( fittyp );
+      }
+  
+  hist.Renorm();
+  //
+  // 4) Check for oscillations
+  // 
+  hist.CreateFourierSpectrum();
+  
+
+  if (!hist.IsFourierSpectrumOK())
+    bad.SetUncalibrated( osctyp );
+  
+  //
+  // 5) Retrieve the results and store them in this class
+  //
+  pix.SetHiGainMean       ( hist.GetMean()      );
+  pix.SetHiGainMeanVar    ( hist.GetMeanErr() * hist.GetMeanErr()   );
+  pix.SetHiGainSigma      ( hist.GetSigma()     );
+  pix.SetHiGainSigmaVar   ( hist.GetSigmaErr()* hist.GetSigmaErr()  );
+  pix.SetHiGainProb       ( hist.GetProb()      );
+  pix.SetHiGainNumBlackout( hist.GetBlackout()  );
+  pix.SetHiGainNumPickup  ( hist.GetPickup()    );
+  
+  if (IsDebug())
+    {
+      *fLog << dbginf << GetDescriptor() << ": ID " << hist.GetPixId() 
+            << " HiGainSaturation: " << pix.IsHiGainSaturation() 
+            << " HiGainMean: " << hist.GetMean()
+            << " HiGainMeanErr: " << hist.GetMeanErr()
+            << " HiGainMeanSigma: " << hist.GetSigma()
+            << " HiGainMeanSigmaErr: " << hist.GetSigmaErr()
+            << " HiGainMeanProb: " << hist.GetProb()
+            << " HiGainNumBlackout: " << hist.GetBlackout()
+            << " HiGainNumPickup  : " << hist.GetPickup  ()
+            << endl;
+    }
+
+}
+
+
+// ---------------------------------------------------------------------------
+//
+// Returns if the histogram is empty and sets the following flag:
+// - MBadPixelsPix::SetUnsuitable(MBadPixelsPix::kUnsuitableRun)
+//
+// Fits the histograms with a Gaussian, in case of failure 
+// calls MHGausEvents::RepeatFit(), in case of repeated failure 
+// calls MHGausEvents::BypassFit() and sets the following flags:
+// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::UncalibratedType_t fittyp )
+// - MBadPixelsPix::SetUnsuitable(   MBadPixelsPix::kUnreliableRun   )
+// 
+// Creates the fourier spectrum and tests MHGausEvents::IsFourierSpectrumOK(). 
+// In case no, sets the following flags:
+// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::UncalibratedType_t osctyp )
+// - MBadPixelsPix::SetUnsuitable(   MBadPixelsPix::kUnreliableRun     )
+//
+// Retrieves the results and store them in MCalibrationPix
+//
+void MHCalibrationCam::FitLoGainHists(MHGausEvents &hist, 
+                                      MCalibrationPix &pix, 
+                                      MBadPixelsPix &bad, 
+                                      MBadPixelsPix::UncalibratedType_t fittyp,
+                                      MBadPixelsPix::UncalibratedType_t osctyp)
+{
+
+  if (hist.IsEmpty())
+      return;
+  
+
+  //
+  // 2) Fit the Hi Gain histograms with a Gaussian
+  //
+  if (!hist.FitGaus())
+    //
+    // 3) In case of failure set the bit Fitted to false and take histogram means and RMS
+    //
+    if (!hist.RepeatFit())
+      {
+        hist.BypassFit();
+        bad.SetUncalibrated( fittyp );
+      }
+  
+  //
+  // 4) Check for oscillations
+  // 
+  hist.CreateFourierSpectrum();
+  
+  if (!hist.IsFourierSpectrumOK())
+    bad.SetUncalibrated( osctyp );
+  
+  //
+  // 5) Retrieve the results and store them in this class
+  //
+  pix.SetLoGainMean       ( hist.GetMean()      );
+  pix.SetLoGainMeanVar    ( hist.GetMeanErr()  * hist.GetMeanErr()   );
+  pix.SetLoGainSigma      ( hist.GetSigma()     );
+  pix.SetLoGainSigmaVar   ( hist.GetSigmaErr() * hist.GetSigmaErr()  );
+  pix.SetLoGainProb       ( hist.GetProb()      );
+  pix.SetLoGainNumBlackout( hist.GetBlackout()  );
+  pix.SetLoGainNumPickup  ( hist.GetPickup()    );
+  
+  if (IsDebug())
+    {
+      *fLog << dbginf << GetDescriptor() << "ID: " << hist.GetPixId() 
+            << " HiGainSaturation: " << pix.IsHiGainSaturation() 
+            << " LoGainMean: " << hist.GetMean()
+            << " LoGainMeanErr: " << hist.GetMeanErr()
+            << " LoGainMeanSigma: " << hist.GetSigma()
+            << " LoGainMeanSigmaErr: " << hist.GetSigmaErr()
+            << " LoGainMeanProb: " << hist.GetProb()
+            << " LoGainNumBlackout: " << hist.GetBlackout()
+            << " LoGainNumPickup  : " << hist.GetPickup  ()
+            << endl;
+    }
+
+}
+
+
+
+// --------------------------------------------------------------------------
+//
+// Dummy, needed by MCamEvent
+//
+Bool_t MHCalibrationCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
+{
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// What MHCamera needs in order to draw an individual pixel in the camera
+//
+void MHCalibrationCam::DrawPixelContent(Int_t idx) const
+{
+}
+
+// -----------------------------------------------------------------------------
+// 
+// Default draw:
+//
+// Displays the averaged areas, both High Gain and Low Gain 
+//
+// Calls the Draw of the fAverageHiGainAreas and fAverageLoGainAreas objects with options
+//
+void MHCalibrationCam::Draw(const Option_t *opt)
+{
+
+  const Int_t nareas = fAverageHiGainAreas->GetEntries();
+  if (nareas == 0)
+    return;
+
+  TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);  
+  pad->SetBorderMode(0);
+
+  pad->Divide(2,nareas);
+
+  for (Int_t i=0; i<nareas;i++) 
+    {
+
+      pad->cd(2*(i+1)-1);
+      GetAverageHiGainArea(i).Draw(opt);
+
+      if (!fAverageAreaSat[i])
+        DrawAverageSigma(fAverageAreaSat[i], i,
+                         fAverageAreaSigma[i],    fAverageAreaSigmaVar[i],
+                         fAverageAreaRelSigma[i], fAverageAreaRelSigmaVar[i]);
+
+      pad->cd(2*(i+1));
+      GetAverageLoGainArea(i).Draw(opt);
+      
+      if (fAverageAreaSat[i])
+        DrawAverageSigma(fAverageAreaSat[i], i,
+                         fAverageAreaSigma[i], fAverageAreaSigmaVar[i],
+                         fAverageAreaRelSigma[i], fAverageAreaRelSigmaVar[i]);
+    }
+
+}
+
+// -----------------------------------------------------------------------------
+// 
+// Default draw:
+//
+// Displays a TPaveText with the re-normalized sigmas of the average area
+//
+void MHCalibrationCam::DrawAverageSigma(Bool_t sat, Bool_t inner,
+                                              Float_t sigma, Float_t sigmavar,
+                                              Float_t relsigma, Float_t relsigmavar) const 
+{
+  
+  if (sigma != 0 && sigmavar >= 0 && relsigmavar >= 0.)
+    {
+      
+      TPad *newpad = new TPad("newpad","transparent",0,0,1,1);
+      newpad->SetFillStyle(4000);
+      newpad->Draw();
+      newpad->cd();
+      
+      TPaveText *text = new TPaveText(sat? 0.1 : 0.35,0.7,sat ? 0.4 : 0.7,1.0);
+      text->SetTextSize(0.07);
+      const TString line1 = Form("%s%s%s",inner ? "Outer" : "Inner",
+                                 " Pixels ", sat ? "Low Gain" : "High Gain");
+      TText *txt1 = text->AddText(line1.Data());
+      const TString line2 = Form("#sigma per pix: %2.2f #pm %2.2f",sigma,TMath::Sqrt(sigmavar));
+      TText *txt2 = text->AddText(line2.Data());
+      const TString line3 = Form("Rel. #sigma per pix: %2.2f #pm %2.2f",relsigma,TMath::Sqrt(relsigmavar));
+      TText *txt3 = text->AddText(line3.Data());
+      text->Draw("");
+      
+      text->SetBit(kCanDelete);
+      txt1->SetBit(kCanDelete);
+      txt2->SetBit(kCanDelete);
+      txt3->SetBit(kCanDelete);
+      newpad->SetBit(kCanDelete);
+    }
+}
+
Index: /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationCam.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationCam.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationCam.h	(revision 9661)
@@ -0,0 +1,170 @@
+#ifndef MARS_MHCalibrationCam
+#define MARS_MHCalibrationCam
+
+#ifndef ROOT_TObjArray
+#include <TObjArray.h>
+#endif
+
+#ifndef ROOT_TArrayI
+#include <TArrayI.h>
+#endif
+
+#ifndef ROOT_TArrayF
+#include <TArrayF.h>
+#endif
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+#ifndef MARS_MCamEvent
+#include "MCamEvent.h"
+#endif
+
+#ifndef MARS_MBadPixelsPix
+#include "MBadPixelsPix.h"
+#endif
+
+class TText;
+class TArrayI;
+class TArrayF;
+class MHGausEvents;
+class MGeomCam;
+class MRawRunHeader;
+class MCalibrationCam;
+class MCalibrationPix;
+class MBadPixelsCam;
+class MBadPixelsPix;
+class MHCalibrationCam : public MH, public MCamEvent
+{
+  
+private:
+
+  static const Int_t fgAverageNbins;     //! The default for fAverageNbins    (now set to: 2000)
+  static const Int_t fgPulserFrequency;  //! The default for fPulserFrequency (now set to: 500)
+
+protected:
+
+  Float_t fNumHiGainSaturationLimit;    // Rel. amount sat. higain FADC slices until pixel is called saturated
+  Float_t fNumLoGainSaturationLimit;    // Rel. amount sat. logain FADC slices until pixel is called saturated
+
+  TArrayI    fAverageAreaNum;           // Number of pixels in average pixels per area
+  TArrayF    fAverageAreaRelSigma;      // Re-normalized relative sigmas in average pixels per area
+  TArrayF    fAverageAreaRelSigmaVar;   // Variance Re-normalized relative sigmas in average pixels per area
+  TArrayI    fAverageAreaSat;           // Number of saturated slices in average pixels per area
+  TArrayF    fAverageAreaSigma;         // Re-normalized sigmas in average pixels per area
+  TArrayF    fAverageAreaSigmaVar;      // Variance Re-normalized sigmas in average pixels per area
+  Int_t      fAverageNbins;             // Number of bins for the average histograms
+  TObjArray *fAverageHiGainAreas;       //-> Array of calibration pixels, one per pixel area
+  TObjArray *fAverageHiGainSectors;     //-> Array of calibration pixels, one per camera sector
+  TObjArray *fAverageLoGainAreas;       //-> Array of calibration pixels, one per pixel area
+  TObjArray *fAverageLoGainSectors;     //-> Array of calibration pixels, one per camera sector
+  TArrayI    fAverageSectorNum;         // Number of pixels in average pixels per sector 
+  TArrayI    fRunNumbers;               // Numbers of runs used
+  UInt_t     fHiGainOverFlow;           // Number of times overflow occurred in whole run
+  UInt_t     fLoGainOverFlow;           // Number of times overflow occurred in whole run
+  
+  MBadPixelsCam    *fBadPixels;         //!  Bad Pixels storage container
+  MCalibrationCam  *fCam;               //!  Calibration Cam with the results
+  MGeomCam         *fGeom;              //!  Camera geometry
+  MRawRunHeader    *fRunHeader;         //!  Run Header
+  
+  TObjArray *fHiGainArray;              //-> Array of calibration pixels, one per pixel
+  TObjArray *fLoGainArray;              //-> Array of calibration pixels, one per pixel
+
+  Int_t      fPulserFrequency;          // Light pulser frequency
+  Bool_t     fDebug;                     
+  
+  virtual Bool_t SetupHists(const MParList *pList);
+  virtual Bool_t ReInitHists(MParList *pList);  
+  virtual Bool_t FillHists(const MParContainer *par, const Stat_t w=1);
+  virtual Bool_t FinalizeHists();
+  virtual void   FinalizeBadPixels();
+  
+  virtual void CalcAverageSigma();
+  
+  void DrawAverageSigma(Bool_t sat, Bool_t inner,
+                        Float_t sigma, Float_t sigmaerr,
+                        Float_t relsigma, Float_t relsigmaerr) const; 
+  
+  void FitHiGainArrays(MCalibrationCam &calcam, MBadPixelsCam &badcam,
+                       MBadPixelsPix::UncalibratedType_t fittyp,
+                       MBadPixelsPix::UncalibratedType_t osctyp);
+  
+  void FitHiGainHists(MHGausEvents &hist, 
+                      MCalibrationPix &pix, 
+                      MBadPixelsPix &bad, 
+                      MBadPixelsPix::UncalibratedType_t fittyp,
+                      MBadPixelsPix::UncalibratedType_t osctyp);
+  
+  void FitLoGainArrays(MCalibrationCam &calcam, MBadPixelsCam &badcam,
+                       MBadPixelsPix::UncalibratedType_t fittyp,
+                       MBadPixelsPix::UncalibratedType_t osctyp);
+  
+  void FitLoGainHists(MHGausEvents &hist, 
+                      MCalibrationPix &pix, 
+                      MBadPixelsPix &bad, 
+                      MBadPixelsPix::UncalibratedType_t fittyp,
+                      MBadPixelsPix::UncalibratedType_t osctyp);
+
+  void InitHists(MHGausEvents &hist, MBadPixelsPix &bad, const Int_t i);
+
+public:
+
+  MHCalibrationCam(const char *name=NULL, const char *title=NULL);
+  virtual ~MHCalibrationCam();
+
+  virtual Bool_t SetupFill(const MParList *pList);
+  virtual Bool_t ReInit   (      MParList *pList);
+  virtual Bool_t Fill     (const MParContainer *par, const Stat_t w=1);
+  virtual Bool_t Finalize ( );
+
+  // Clone
+  virtual TObject *Clone(const char *) const;
+
+  // Draw
+  virtual void   Draw(const Option_t *opt);
+
+  virtual Bool_t GetPixelContent ( Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
+  virtual void   DrawPixelContent( Int_t num )  const;    
+
+  const Int_t          GetAverageAreas       ()          const;	 
+        MHGausEvents  &GetAverageHiGainArea  (UInt_t i);
+  const MHGausEvents  &GetAverageHiGainArea  (UInt_t i)  const;
+        MHGausEvents  &GetAverageLoGainArea  (UInt_t i);
+  const MHGausEvents  &GetAverageLoGainArea  (UInt_t i)  const;
+        MHGausEvents  &GetAverageHiGainSector(UInt_t i);
+  const MHGausEvents  &GetAverageHiGainSector(UInt_t i)  const;
+        MHGausEvents  &GetAverageLoGainSector(UInt_t i);
+  const MHGausEvents  &GetAverageLoGainSector(UInt_t i)  const;
+  const Int_t          GetAverageSectors     ()          const;
+  const Float_t        GetNumHiGainSaturationLimit()     const  { return fNumHiGainSaturationLimit; }
+  const Float_t        GetNumLoGainSaturationLimit()     const  { return fNumLoGainSaturationLimit; }
+  const TArrayI       &GetRunNumbers         ()          const;
+  const Int_t          GetSize               ()          const  { return fHiGainArray->GetSize();   }
+
+  const Bool_t         IsDebug                ()          const  { return fDebug; }
+  
+        MHGausEvents  &operator[]            (UInt_t i);
+  const MHGausEvents  &operator[]            (UInt_t i)  const;
+        MHGausEvents  &operator()            (UInt_t i);
+  const MHGausEvents  &operator()            (UInt_t i)  const;
+ 
+  void SetDebug                (const Bool_t b=kTRUE) { fDebug           = b; }
+  void SetAverageNbins        ( const Int_t bins=fgAverageNbins ) { fAverageNbins = bins; }
+  void SetNumLoGainSaturationLimit( const Float_t lim) { fNumLoGainSaturationLimit = lim; }
+  void SetNumHiGainSaturationLimit( const Float_t lim) { fNumHiGainSaturationLimit = lim; }
+  void SetPulserFrequency      ( const Int_t f=fgPulserFrequency)  { fPulserFrequency = f; }
+  
+  ClassDef(MHCalibrationCam, 1)	// Base Histogram class for Calibration Camera
+};
+
+#endif
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargeBlindCam.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargeBlindCam.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargeBlindCam.cc	(revision 9661)
@@ -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): Markus Gaug   02/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+/////////////////////////////////////////////////////////////////////////////
+//                                                               
+// MHCalibrationChargeBlindCam                                               
+//
+// Histogram class for blind pixels in the camera. Incorporates the TObjArray's:
+// - fBlindPixelsArray (for calibrated High Gains per pixel)
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MHCalibrationChargeBlindCam.h"
+#include "MHCalibrationChargeBlindPix.h"
+
+#include <TVirtualPad.h>
+#include <TCanvas.h>
+#include <TPad.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MCalibrationChargeBlindPix.h"
+#include "MCalibrationChargeBlindCam.h"
+
+#include "MExtractedSignalBlindPixel.h"
+
+#include "MParList.h"
+
+#include "MRawRunHeader.h"
+
+ClassImp(MHCalibrationChargeBlindCam);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor. 
+//
+// Sets:
+// - all pointers to NULL
+//
+// Initializes and sets owner of:
+// - fBlindPixelsArray
+//
+MHCalibrationChargeBlindCam::MHCalibrationChargeBlindCam(const char *name, const char *title)
+    :  fCam(NULL), fRunHeader(NULL)
+{
+
+  fBlindPixelsArray = new TObjArray;
+  fBlindPixelsArray->SetOwner();
+}
+
+// --------------------------------------------------------------------------
+//
+// Deletes the TClonesArray of:
+// - fBlindPixelsArray
+//
+MHCalibrationChargeBlindCam::~MHCalibrationChargeBlindCam()
+{
+  delete fBlindPixelsArray;
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th High Gain pixel (pixel number)
+//
+MHCalibrationChargeBlindPix &MHCalibrationChargeBlindCam::operator[](UInt_t i)
+{
+  return *static_cast<MHCalibrationChargeBlindPix*>(fBlindPixelsArray->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th High Gain pixel (pixel number)
+//
+const MHCalibrationChargeBlindPix &MHCalibrationChargeBlindCam::operator[](UInt_t i) const
+{
+  return *static_cast<MHCalibrationChargeBlindPix*>(fBlindPixelsArray->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Our own clone function is necessary since root 3.01/06 or Mars 0.4
+// I don't know the reason. 
+//
+// Creates new MHCalibrationChargeBlindCam
+// Deletes the TObjArray's and Clones them individually
+//
+TObject *MHCalibrationChargeBlindCam::Clone(const char *) const
+{
+
+  const Int_t nhi   = fBlindPixelsArray->GetEntries();
+  
+  //
+  // FIXME, this might be done faster and more elegant, by direct copy.
+  //
+  MHCalibrationChargeBlindCam *cam = new MHCalibrationChargeBlindCam();
+
+  cam->fBlindPixelsArray->Expand(nhi);
+
+  for (int i=0; i<nhi; i++)
+    (*cam->fBlindPixelsArray)[i] = (*fBlindPixelsArray)[i]->Clone();
+
+  return cam;
+}
+
+// --------------------------------------------------------------------------
+//
+// Gets the pointers to:
+// - MRunHeader
+// - MExtractedSignalBlindPix
+//
+// Calls Delete-Function of:
+// - MHCalibrationChargeBlindCam::fBlindPixelsArray
+//
+Bool_t MHCalibrationChargeBlindCam::SetupFill(const MParList *pList)
+{
+  
+  fRunHeader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
+  if (!fRunHeader)
+  {
+    *fLog << warn << GetDescriptor() 
+          << ": MRawRunHeader not found... will not store run numbers." << endl;
+    return kFALSE;
+  }
+
+  fSignal  = (MExtractedSignalBlindPixel*)pList->FindObject("MExtractedSignalBlindPixel");
+  if (!fSignal)
+    {
+      *fLog << err << "MExtractedSignalBlindPixel not found... aborting " << endl;
+      return kFALSE;
+    }
+
+  fBlindPixelsArray->Delete();
+
+  return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Initializes, if empty to MExtractedSignalCam::GetSize() for:
+// - MHCalibrationChargeBlindCam::fBlindPixelsArray
+//
+// Calls InitializeHists() for every entry in:
+// - MHCalibrationChargeBlindCam::fBlindPixelsArray
+//
+// Retrieves the run numbers from MRawRunHeader and stores them in fRunNumbers
+//
+Bool_t MHCalibrationChargeBlindCam::ReInit(MParList *pList)
+{
+
+  const Int_t nblindpixels  = fSignal->GetNumBlindPixels();
+
+  Int_t runnr = 0;
+
+  if (fRunHeader)
+    runnr = fRunHeader->GetRunNumber();
+
+  fCam = (MCalibrationChargeBlindCam*)pList->FindCreateObj("MCalibrationChargeBlindCam");
+  if (!fCam)
+    {
+	*fLog << err << "Cannot find nor create MCalibrationChargeBlindCam ... abort." << endl;
+	return kFALSE;
+    }
+
+  fCam->InitSize(nblindpixels);
+
+  const Int_t samples = fSignal->GetNumFADCSamples();
+  const Int_t integ   = fSignal->IsExtractionType( MExtractBlindPixel::kIntegral );
+
+  if (fBlindPixelsArray->GetEntries()==0)
+  {
+
+      fBlindPixelsArray->Expand(nblindpixels);
+
+      for (Int_t i=0; i<nblindpixels; i++)
+	{
+	  (*fBlindPixelsArray)[i] = new MHCalibrationChargeBlindPix;
+	  (*this)[i].ChangeHistId(i);
+	  if (integ)
+	    {
+	      (*this)[i].SetLast( samples * integ * 
+				  ((*this)[i].GetLast()+0.5) - 0.5 );
+	      (*this)[i].SetSinglePheCut( samples * integ *
+					  (*this)[i].GetSinglePheCut() );
+	    }
+	  (*this)[i].InitBins();
+	  TH1F *h = (*this)[i].GetHGausHist();
+	  h->SetTitle( Form("%s%s", h->GetTitle()," Runs: "));
+	  (*this)[i].SetupFill(pList);
+	  (*this)[i].SetCalibrationChargeBlindPix(&(*fCam)[i]);
+      }
+  }
+
+  for (Int_t i=0; i<nblindpixels; i++)
+    {
+      TH1F *h = (*this)[i].GetHGausHist();
+      h->SetTitle( Form("%s%i%s", h->GetTitle(),runnr," "));
+    }
+
+  return kTRUE;
+}
+
+
+//--------------------------------------------------------------------------------
+//
+// Retrieves from MExtractedSignalBlindPixel:
+// - number of blind pixels
+//
+// For all TObjArray's, the following steps are performed: 
+//
+// 1) Test size and return kFALSE if not matching
+// 2) 
+//
+Bool_t MHCalibrationChargeBlindCam::Fill(const MParContainer *par, const Stat_t w)
+{
+
+  const Int_t nblindpixels  = fSignal->GetNumBlindPixels();
+  
+  if (GetSize() != nblindpixels)
+    {
+      gLog << err << "ERROR - Size mismatch... abort." << endl;
+      return kFALSE;
+    }
+  
+  for (Int_t i=0; i<nblindpixels; i++)
+    (*this)[i].Fill(par,w);
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calls the Finalize() function of the blind pixels
+//
+Bool_t MHCalibrationChargeBlindCam::Finalize()
+{
+
+  for (Int_t i=0; i<GetSize(); i++)
+    if (!(*this)[i].Finalize())
+      return kFALSE;
+
+  return kTRUE;
+}
+
+
+
+// -----------------------------------------------------------------------------
+// 
+// Default draw:
+//
+// Displays the averaged areas, both High Gain and Low Gain 
+//
+// Calls the Draw of the fAverageHiGainAreas and fAverageLoGainAreas objects with options
+//
+void MHCalibrationChargeBlindCam::Draw(const Option_t *opt)
+{
+
+  const Int_t size = fBlindPixelsArray->GetEntries();
+  if (size == 0)
+    return;
+  
+  TString option(opt);
+  option.ToLower();
+
+  TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);  
+  pad->SetBorderMode(0);
+  pad->Divide(size/2+1,size/2+1);
+
+  for (Int_t i=0; i<size;i++) 
+    {
+      pad->cd(i+1);
+      (*this)[i].Draw(option);
+    }
+}
Index: /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargeBlindCam.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargeBlindCam.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargeBlindCam.h	(revision 9661)
@@ -0,0 +1,66 @@
+#ifndef MARS_MHCalibrationChargeBlindCam
+#define MARS_MHCalibrationChargeBlindCam
+
+#ifndef ROOT_TObjArray
+#include <TObjArray.h>
+#endif
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+#ifndef MARS_MCamEvent
+#include "MCamEvent.h"
+#endif
+
+#ifndef MARS_MBadPixelsPix
+#include "MBadPixelsPix.h"
+#endif
+
+class MExtractedSignalBlindPixel;
+class MCalibrationChargeBlindCam;
+class MRawRunHeader;
+class MHCalibrationChargeBlindPix;
+class MHCalibrationChargeBlindCam : public MH
+{
+private:
+
+  MExtractedSignalBlindPixel *fSignal;     //!  Extracted Signal class
+  MCalibrationChargeBlindCam *fCam;        //!  Calibration Cam with the results
+  MRawRunHeader              *fRunHeader;  //!  Run Header
+  
+  TObjArray *fBlindPixelsArray;          //-> Array of calibration pixels, one per pixel
+
+public:
+
+  MHCalibrationChargeBlindCam(const char *name=NULL, const char *title=NULL);
+  ~MHCalibrationChargeBlindCam();
+
+  Bool_t SetupFill( const MParList *pList);
+  Bool_t ReInit   (       MParList *pList);
+  Bool_t Fill     ( const MParContainer *par, const Stat_t w=1);
+  Bool_t Finalize ( );
+
+  // Clone
+  TObject *Clone(const char *) const;
+  
+  // Draw
+  void   Draw(const Option_t *opt);
+  
+  const Int_t    GetSize       ()    const  { return fBlindPixelsArray->GetSize(); }
+  
+      MHCalibrationChargeBlindPix  &operator[]            (UInt_t i);
+  const MHCalibrationChargeBlindPix  &operator[]            (UInt_t i)  const;
+  
+  ClassDef(MHCalibrationChargeBlindCam, 0)	// Histogram class for Blind Pixel Calibration
+};
+
+#endif
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargeBlindPix.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargeBlindPix.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargeBlindPix.cc	(revision 9661)
@@ -0,0 +1,1139 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug 02/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MHCalibrationChargeBlindPix
+//
+//  Histogram class for the charge calibration of the Blind Pixel.
+//  Stores and fits the charges and stores the averaged assumed pedestal and 
+//  single-phe FADC slice entries. Charges are taken from MExtractedSignalBlindPix.
+//  Performs the Single Photo-electron fit to extract the Poisson mean and its errors.
+//
+//  Different fits can be chosen with the function ChangeFitFunc().
+//
+//  The fit result is accepted under the condition that:
+//  1) the Probability is greater than fProbLimit (default 0.001 == 99.7%)
+//  2) at least fNumSinglePheLimit events are found in the single Photo-electron peak
+//
+//  The single FADC slice entries are averaged and stored in fASinglePheFADCSlices, if 
+//  their sum exceeds fSinglePheCut, otherwise in fAPedestalFADCSlices.
+//
+//  Used numbers are the following:
+//
+//  Electronic conversion factor:
+//   Assume, we have N_e electrons at the anode, 
+//   thus a charge of N_e*e (e = electron charge) Coulomb.
+//
+//   This charge is AC coupled and runs into a R_pre = 50 Ohm resistency. 
+//   The corresponding current is amplified by a gain factor G_pre = 400 
+//   (the precision of this value still has to be checked !!!) and again AC coupled to 
+//   the output. 
+//   The corresponding signal goes through the whole transmission and 
+//   amplification chain and is digitized in the FADCs. 
+//   The conversion Signal Area to FADC counts (Conv_trans) has been measured 
+//   by David and Oscar to be approx. 3.9 pVs^-1
+//
+//   Thus: Conversion FADC counts to Number of Electrons at Anode: 
+//         FADC counts = (1/Conv_tran) * G_pre * R_pre *  e * N_e = 8 * 10^-4 N_e. 
+//
+//   Also: FADC counts = 8*10^-4 * GAIN * N_phe
+//
+//   In the blind pixel, there is an additional pre-amplifier with an amplification of 
+//   about 10. Therefore, we have for the blind pixel:
+//
+//
+//   FADC counts (Blind Pixel) = 8*10^-3 * GAIN * N_phe
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MHCalibrationChargeBlindPix.h"
+#include "MExtractBlindPixel.h"
+
+#include <TStyle.h>
+#include <TCanvas.h>
+#include <TPaveText.h>
+
+#include <TVector.h>
+#include <TF1.h>
+#include <TH1.h>
+#include <TRandom.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MRawEvtData.h"
+#include "MRawEvtPixelIter.h"
+
+#include "MExtractedSignalBlindPixel.h"
+#include "MCalibrationChargeBlindPix.h"
+
+ClassImp(MHCalibrationChargeBlindPix);
+
+using namespace std;
+
+const Double_t MHCalibrationChargeBlindPix::gkElectronicAmp      = 0.008;
+const Double_t MHCalibrationChargeBlindPix::gkElectronicAmpErr   = 0.002;
+const Float_t  MHCalibrationChargeBlindPix::gkSignalInitializer  = -9999.;
+
+const Int_t    MHCalibrationChargeBlindPix::fgChargeNbins        = 512;
+const Axis_t   MHCalibrationChargeBlindPix::fgChargeFirst        = -0.5;
+const Axis_t   MHCalibrationChargeBlindPix::fgChargeLast         = 255.5;
+const Float_t  MHCalibrationChargeBlindPix::fgSinglePheCut       =  30.;
+const Float_t  MHCalibrationChargeBlindPix::fgNumSinglePheLimit  =  50.;
+// --------------------------------------------------------------------------
+//
+// Default Constructor. 
+//
+// Sets: 
+// - the default number for fNbins        (fgChargeNbins)
+// - the default number for fFirst        (fgChargeFirst)
+// - the default number for fLast         (fgChargeLast)
+// - the default number for fSinglePheCut (fgSingePheCut)
+// - the default number for fNumSinglePheLimit (fgNumSinglePheLimit)
+// - the default number of bins after stripping (30)
+//
+// - the default name of the  fHGausHist ("HCalibrationChargeBlindPix")
+// - the default title of the fHGausHist ("Distribution of Summed FADC slices Blind Pixel ")
+// - the default x-axis title for fHGausHist ("Sum FADC Slices")
+// - the default y-axis title for fHGausHist ("Nr. of events")
+//
+// Initializes:
+// - all pointers to NULL
+// - fASinglePheFADCSlices(0);
+// - fAPedestalFADCSlices(0);
+// - fPixId to 0
+//
+// Calls:
+// - Clear()
+//
+MHCalibrationChargeBlindPix::MHCalibrationChargeBlindPix(const char *name, const char *title)
+    :  fBlindPix(NULL), fSignal(NULL), fRawEvt(NULL), 
+       fSinglePheFit(NULL), 
+       fFitLegend(NULL),
+       fHSinglePheFADCSlices(NULL), fHPedestalFADCSlices(NULL)
+{
+
+    fName  = name  ? name  : "MHCalibrationChargeBlindPix";
+    fTitle = title ? title : "Statistics of the FADC sums of Blind Pixel calibration events";
+
+    SetNbins( fgChargeNbins );
+    SetFirst( fgChargeFirst );
+    SetLast ( fgChargeLast  );
+    
+    fASinglePheFADCSlices.ResizeTo(1);
+    fAPedestalFADCSlices.ResizeTo(1);
+
+    SetSinglePheCut();
+    SetNumSinglePheLimit();
+    SetProbLimit(0.001);
+    SetBinsAfterStripping(64);
+
+    fHGausHist.SetName("HCalibrationChargeBlindPix");
+    fHGausHist.SetTitle("Distribution of Summed FADC slices Blind Pixel");  
+    fHGausHist.SetXTitle("Sum FADC Slices");
+    fHGausHist.SetYTitle("Nr. of events");
+
+    fPixId     = 0;
+
+    Clear();
+}
+
+// --------------------------------------------------------------------------
+//
+// Default Destructor. 
+//
+// Deletes (if Pointer is not NULL):
+// 
+// - fSinglePheFit
+// - fFitLegend 
+// - fHSinglePheFADCSlices
+// - fHPedestalFADCSlices    
+// 
+MHCalibrationChargeBlindPix::~MHCalibrationChargeBlindPix()
+{
+
+  if (fSinglePheFit)
+    delete fSinglePheFit;
+
+  if (fFitLegend)
+    delete fFitLegend;
+
+  if (fHSinglePheFADCSlices)
+    delete fHSinglePheFADCSlices;
+
+  if (fHPedestalFADCSlices)
+    delete fHPedestalFADCSlices;
+
+}
+
+// --------------------------------------------------------------------------
+//
+// Sets:
+// - all variables to 0., except the fit result variables to gkSignalInitializer
+// - all flags to kFALSE
+// - all pointers to NULL
+// - the default fit function (kEPoisson5)
+//
+// Deletes: 
+// - all pointers unequal NULL
+//
+// Calls:
+// - MHCalibrationChargePix::Clear()
+//
+void MHCalibrationChargeBlindPix::Clear(Option_t *o)
+{
+
+  fLambda    = gkSignalInitializer;
+  fMu0       = gkSignalInitializer;
+  fMu1       = gkSignalInitializer;
+  fSigma0    = gkSignalInitializer;
+  fSigma1    = gkSignalInitializer;
+  fLambdaErr = gkSignalInitializer;
+  fMu0Err    = gkSignalInitializer;
+  fMu1Err    = gkSignalInitializer;
+  fSigma0Err = gkSignalInitializer;
+  fSigma1Err = gkSignalInitializer;
+
+  fLambdaCheck    = gkSignalInitializer;
+  fLambdaCheckErr = gkSignalInitializer;
+  
+  //  fFitFunc = kEMichele;
+  fFitFunc = kEPoisson4;
+
+  fNumSinglePhes    = 0;
+  fNumPedestals     = 0;
+
+  fChisquare        = 0.;
+  fNDF              = 0 ;
+  fProb             = 0.;
+
+  SetSinglePheFitOK ( kFALSE );
+  SetPedestalFitOK  ( kFALSE );
+
+  if (fFitLegend)
+  {
+    delete fFitLegend;
+    fFitLegend = NULL;
+  }
+
+  if (fSinglePheFit)
+  {
+    delete fSinglePheFit;
+    fSinglePheFit = NULL;
+  }
+
+  if (fHSinglePheFADCSlices)
+  {
+    delete fHSinglePheFADCSlices;
+    fHSinglePheFADCSlices = NULL;
+  }
+
+  if (fHPedestalFADCSlices)
+  {
+    delete fHPedestalFADCSlices;
+    fHPedestalFADCSlices = NULL;
+  }
+
+
+  MHGausEvents::Clear();
+  return;
+}
+
+// --------------------------------------------------------------------------
+//
+// Empty function to overload MHGausEvents::Reset()
+//
+void MHCalibrationChargeBlindPix::Reset()
+{
+}
+
+/*
+// --------------------------------------------------------------------------
+//
+// Our own clone function is necessary since root 3.01/06 or Mars 0.4
+// I don't know the reason. 
+//
+// Creates new MHCalibrationCam
+//
+TObject *MHCalibrationChargeBlindPix::Clone(const char *) const
+{
+
+    MHCalibrationChargeBlindPix *pix = new MHCalibrationChargeBlindPix();
+    this->Copy(*pix);
+
+    this->fHGausHist.Copy(pix->fHGausHist);
+    this->fSinglePheFit->Copy(*(pix->fSinglePheFit));
+    this->fHSinglePheFADCSlices->Copy(*(pix->fHSinglePheFADCSlices));
+    this->fHPedestalFADCSlices->Copy(*(pix->fHPedestalFADCSlices));
+    
+
+    return pix;
+}
+*/
+
+// --------------------------------------------------------------------------
+//
+// Set bit kSinglePheFitOK from outside
+//
+void MHCalibrationChargeBlindPix::SetSinglePheFitOK (const Bool_t b ) 
+{
+    b ? SETBIT(fFlags,kSinglePheFitOK) : CLRBIT(fFlags,kSinglePheFitOK);
+}
+
+// --------------------------------------------------------------------------
+//
+// Set bit kPedestalFitOK from outside
+//
+void MHCalibrationChargeBlindPix::SetPedestalFitOK(const Bool_t b)
+{
+    b ? SETBIT(fFlags,kPedestalFitOK) : CLRBIT(fFlags,kPedestalFitOK);
+}
+
+// --------------------------------------------------------------------------
+//
+// Ask for status of bit kSinglePheFitOK 
+//
+const Bool_t  MHCalibrationChargeBlindPix::IsSinglePheFitOK()     const 
+{
+    return TESTBIT(fFlags,kSinglePheFitOK);
+}
+
+// --------------------------------------------------------------------------
+//
+// Ask for status of bit kPedestalFitOK 
+//
+const Bool_t  MHCalibrationChargeBlindPix::IsPedestalFitOK()  const
+{
+    return TESTBIT(fFlags,kPedestalFitOK);
+}
+  
+// --------------------------------------------------------------------------
+//
+// Gets the pointers to:
+// - MRawEvtData
+// - MExtractedSignalBlindPixel
+// 
+Bool_t MHCalibrationChargeBlindPix::SetupFill(const MParList *pList) 
+{
+
+  fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
+  if (!fRawEvt)
+    {
+      *fLog << err << "MRawEvtData not found... aborting." << endl;
+      return kFALSE;
+    }
+  
+  fSignal  = (MExtractedSignalBlindPixel*)pList->FindObject("MExtractedSignalBlindPixel");
+  if (!fSignal)
+    {
+      *fLog << err << "MExtractedSignalBlindPixel not found... aborting " << endl;
+      return kFALSE;
+    }
+  
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Gets or creates the pointers to:
+// - MCalibrationChargeBlindPix
+//
+// Calls:
+// - MHGausHist::InitBins()
+//
+Bool_t MHCalibrationChargeBlindPix::ReInit(MParList *pList)
+{
+
+  fBlindPix = (MCalibrationChargeBlindPix*)pList->FindCreateObj("MCalibrationChargeBlindPix");
+  if (!fBlindPix)
+      return kFALSE;
+
+  const Int_t samples = fSignal->GetNumFADCSamples();
+  const Int_t integ   = fSignal->IsExtractionType( MExtractBlindPixel::kIntegral );
+
+  //
+  // Modify the histogram size in case, integrals have been used
+  //
+  if ( fLast < samples*integ*fgChargeLast )
+    {
+      SetLast        ( samples * (fgChargeLast+0.5) - 0.5 );
+      SetSinglePheCut( samples * fgSinglePheCut );
+    }
+
+  MHGausEvents::InitBins();
+  
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Retrieves from MExtractedSignalBlindPixel:
+// - number of FADC samples
+// - extracted signal 
+// - blind Pixel ID
+//
+// Resizes (if necessary):
+// - fASinglePheFADCSlices to sum of HiGain and LoGain samples
+// - fAPedestalFADCSlices to sum of HiGain and LoGain samples
+//
+// Fills the following histograms:
+// - MHGausEvents::FillHistAndArray(signal)
+//
+// Creates MRawEvtPixelIter, jumps to blind pixel ID, 
+// fills the vectors fASinglePheFADCSlices and fAPedestalFADCSlices 
+// with the full FADC slices, depending on the size of the signal w.r.t. fSinglePheCut
+//
+Bool_t MHCalibrationChargeBlindPix::Fill(const MParContainer *par, const Stat_t w)
+{
+
+  const Int_t samples = (Int_t)fRawEvt->GetNumHiGainSamples()
+                      +(Int_t)fRawEvt->GetNumLoGainSamples();
+
+  if (!fASinglePheFADCSlices.IsValid())
+    {
+      fASinglePheFADCSlices.ResizeTo(samples);
+      fAPedestalFADCSlices.ResizeTo(samples);
+    }
+
+  if (fASinglePheFADCSlices.GetNrows() != samples)
+    {
+      fASinglePheFADCSlices.ResizeTo(samples);
+      fAPedestalFADCSlices.ResizeTo(samples);
+    }
+
+  Float_t slices = (Float_t)fSignal->GetNumFADCSamples();
+  
+  if (slices == 0.)
+    {
+      *fLog << err 
+	    << "Number of used signal slices in MExtractedSignalBlindPix "
+	    << "is zero  ... abort." 
+            << endl;
+      return kFALSE;
+    }
+  
+  //
+  // Signal extraction and histogram filling
+  //
+  const Float_t signal = fSignal->GetExtractedSignal(fPixId);
+
+  if (signal > -0.5)
+    FillHist(signal);
+  else
+    return kTRUE;
+
+  //
+  // In order to study the single-phe posistion, we extract the slices
+  //
+  const Int_t blindpixIdx = fSignal->GetBlindPixelIdx(fPixId);
+
+  MRawEvtPixelIter pixel(fRawEvt);
+  pixel.Jump(blindpixIdx);
+
+  if (signal > fSinglePheCut)
+      FillSinglePheFADCSlices(pixel);
+  else
+      FillPedestalFADCSlices(pixel);
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns kFALSE, if empty
+//
+// - Creates the fourier spectrum and sets bit MHGausEvents::IsFourierSpectrumOK()
+// - Retrieves the pedestals from MExtractedSignalBlindPixel
+// - Normalizes fASinglePheFADCSlices and fAPedestalFADCSlices
+// - Executes FitPedestal()
+// - Executes FitSinglePhe()
+// - Retrieves fit results and stores them in MCalibrationChargeBlindPix
+// 
+Bool_t MHCalibrationChargeBlindPix::Finalize() 
+{
+  
+  if (IsEmpty())
+  {
+    *fLog << err << GetDescriptor() << " ID: " << fPixId 
+	  << " My histogram has not been filled !! " << endl;
+      return kFALSE;
+  }
+
+  fBlindPix->SetValid(kTRUE);
+
+  fMeanPedestal     = fSignal->GetPed();
+  fMeanPedestalErr  = fSignal->GetPedErr();
+  fSigmaPedestal    = fSignal->GetPedRms();
+  fSigmaPedestalErr = fSignal->GetPedRmsErr();
+
+  if (fNumSinglePhes > 1)
+      for (Int_t i=0;i<fASinglePheFADCSlices.GetNrows();i++)
+	  fASinglePheFADCSlices[i] = fASinglePheFADCSlices[i]/fNumSinglePhes;
+  if (fNumPedestals > 1)
+      for (Int_t i=0;i<fAPedestalFADCSlices.GetNrows();i++)
+	  fAPedestalFADCSlices[i]  = fAPedestalFADCSlices[i]/fNumPedestals;
+
+  FitPedestal();
+
+  if (FitSinglePhe())
+    fBlindPix->SetSinglePheFitOK();
+  else
+    fBlindPix->SetValid(IsPedestalFitOK());
+
+  fBlindPix->SetLambda      (    fLambdaCheck          );
+  fBlindPix->SetLambdaVar   (    fLambdaCheckErr*fLambdaCheckErr );
+  fBlindPix->SetMu0         (    fMu0                  );
+  fBlindPix->SetMu0Err      (    fMu0Err               );
+  fBlindPix->SetMu1         (    fMu1                  );
+  fBlindPix->SetMu1Err      (    fMu1Err               );
+  fBlindPix->SetSigma0      (    fSigma0               );
+  fBlindPix->SetSigma0Err   (    fSigma0Err            );
+  fBlindPix->SetSigma1      (    fSigma1               );
+  fBlindPix->SetSigma1Err   (    fSigma1Err            );
+  fBlindPix->SetProb        (    fProb                 );
+
+  fBlindPix->SetLambdaCheck    ( fLambda               );
+  fBlindPix->SetLambdaCheckErr ( fLambdaErr            );
+
+  return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Checks again for the size and fills fASinglePheFADCSlices with the FADC slice entries
+// 
+void MHCalibrationChargeBlindPix::FillSinglePheFADCSlices(const MRawEvtPixelIter &iter)
+{
+
+  const Int_t n = iter.GetNumHiGainSamples() + iter.GetNumLoGainSamples();
+
+  if (fASinglePheFADCSlices.GetNrows() < n)
+      fASinglePheFADCSlices.ResizeTo(n);
+  
+  Int_t i=0;
+  
+  Byte_t *start = iter.GetHiGainSamples();
+  Byte_t *end   = start + iter.GetNumHiGainSamples();
+
+  for (Byte_t *ptr = start; ptr < end; ptr++, i++)
+      fASinglePheFADCSlices(i) = fASinglePheFADCSlices(i) + (Float_t)*ptr;
+
+  start = iter.GetLoGainSamples();
+  end   = start + iter.GetNumLoGainSamples();
+
+  for (Byte_t *ptr = start; ptr < end; ptr++, i++)
+      fASinglePheFADCSlices(i) = fASinglePheFADCSlices(i) + (Float_t)*ptr;
+
+  fNumSinglePhes++;
+}
+
+// --------------------------------------------------------------------------
+//
+// Checks again for the size and fills fAPedestalFADCSlices with the FADC slice entries
+// 
+void MHCalibrationChargeBlindPix::FillPedestalFADCSlices(const MRawEvtPixelIter &iter)
+{
+
+  const Int_t n = iter.GetNumHiGainSamples() + iter.GetNumLoGainSamples();
+
+  if (fAPedestalFADCSlices.GetNrows() < n)
+      fAPedestalFADCSlices.ResizeTo(n);
+
+  Int_t i = 0;
+  Byte_t *start = iter.GetHiGainSamples();
+  Byte_t *end   = start + iter.GetNumHiGainSamples();
+
+  for (Byte_t *ptr = start; ptr < end; ptr++, i++)
+      fAPedestalFADCSlices(i) = fAPedestalFADCSlices(i)+ (Float_t)*ptr;
+
+  start = iter.GetLoGainSamples();
+  end   = start + iter.GetNumLoGainSamples();
+
+  for (Byte_t *ptr = start; ptr < end; ptr++, i++)
+      fAPedestalFADCSlices(i) = fAPedestalFADCSlices(i)+ (Float_t)*ptr;
+
+  fNumPedestals++;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Task to simulate single phe spectrum with the given parameters
+// 
+Bool_t MHCalibrationChargeBlindPix::SimulateSinglePhe(Double_t lambda, Double_t mu0, Double_t mu1, Double_t sigma0, Double_t sigma1) 
+{
+
+  gRandom->SetSeed();
+
+  if (fHGausHist.GetIntegral() != 0)
+    {
+      *fLog << err << "Histogram " << fHGausHist.GetTitle() << " is already filled. " << endl;
+      *fLog << err << "Create new class MHCalibrationBlindPixel for simulation! " << endl;
+      return kFALSE;
+    }
+
+  if (!InitFit())
+    return kFALSE;
+
+  for (Int_t i=0;i<10000; i++) 
+    fHGausHist.Fill(fSinglePheFit->GetRandom());
+  
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// - Get the ranges from the stripped histogram
+// - choose reasonable start values for the fit
+// - initialize the fit function depending on fFitFunc
+// - initialize parameter names and limits depending on fFitFunc
+//
+Bool_t MHCalibrationChargeBlindPix::InitFit()
+{
+  
+  //
+  // Get the fitting ranges
+  //
+  Axis_t rmin = fHGausHist.GetBinCenter(fHGausHist.GetXaxis()->GetFirst());
+  Axis_t rmax = fHGausHist.GetBinCenter(fHGausHist.GetXaxis()->GetLast()); 
+
+  if (rmin < 0.)
+      rmin = 0.;
+
+  //
+  // First guesses for the fit (should be as close to reality as possible, 
+  // otherwise the fit goes gaga because of high number of dimensions ...
+  //
+  const Stat_t   entries      = fHGausHist.Integral("width");
+  const Double_t lambda_guess = 0.05;
+  const Double_t maximum_bin  = fHGausHist.GetBinCenter(fHGausHist.GetMaximumBin());
+  const Double_t norm         = entries/TMath::Sqrt(TMath::TwoPi());
+
+  //
+  // Initialize the fit function
+  //
+  switch (fFitFunc)
+    {
+    case kEPoisson4:
+      fSinglePheFit = new TF1("SinglePheFit",&fPoissonKto4,rmin,rmax,6);
+      break;
+    case kEPoisson5:
+      fSinglePheFit = new TF1("SinglePheFit",&fPoissonKto5,rmin,rmax,6);
+      break;
+    case kEPoisson6:
+      fSinglePheFit = new TF1("SinglePheFit",&fPoissonKto6,rmin,rmax,6);
+      break;
+    case kEPolya:
+      fSinglePheFit = new TF1("SinglePheFit",&fPolya,rmin,rmax,8);
+      break;
+    case kEMichele:
+      fSinglePheFit = new TF1("SinglePheFit",&fFitFuncMichele,rmin,rmax,10);
+      break;
+    default:
+      *fLog << warn << "WARNING: Could not find Fit Function for Blind Pixel " << endl;
+      return kFALSE;
+      break;
+    }
+
+  if (!fSinglePheFit) 
+  {
+      *fLog << warn << dbginf << "WARNING: Could not create fit function for Single Phe fit" << endl;
+      return kFALSE;
+  }
+  
+  const Double_t mu_0_guess = maximum_bin;
+  const Double_t si_0_guess = 40.;
+  const Double_t mu_1_guess = mu_0_guess + 4000.;
+  const Double_t si_1_guess = si_0_guess + si_0_guess;
+  // Michele
+  const Double_t lambda_1cat_guess = 0.05;
+  const Double_t lambda_1dyn_guess = lambda_1cat_guess/10.;
+  const Double_t mu_1cat_guess = 1000.;
+  const Double_t mu_1dyn_guess = 2500.;
+  const Double_t si_1cat_guess = si_0_guess+ 500.;
+  const Double_t si_1dyn_guess = si_0_guess+ 1000.;
+  const Double_t offset_guess  = 0.5;
+  // Polya
+  const Double_t excessPoisson_guess = 0.5;
+  const Double_t delta1_guess     = 8.;
+  const Double_t delta2_guess     = 5.;
+  const Double_t electronicAmp_guess  = gkElectronicAmp;
+  const Double_t electronicAmp_limit  = gkElectronicAmpErr;
+
+  //
+  // Initialize boundaries and start parameters
+  //
+  switch (fFitFunc)
+    {
+      
+    case kEPoisson4:
+	fSinglePheFit->SetParNames(  "#lambda",   "#mu_{0}",    "#mu_{1}", "#sigma_{0}",  "#sigma_{1}","Area");
+        //        fSinglePheFit->SetParameters(lambda_guess,fMeanPedestal,mu_1_guess,fSigmaPedestal,si_1_guess,norm);
+        fSinglePheFit->SetParameters(0.05,10.,75.,20.,70.,norm);
+
+	fSinglePheFit->SetParLimits(0,0.,0.5);
+        //        fSinglePheFit->SetParLimits(1,
+        //                                    fMeanPedestal-5.*fMeanPedestalErr,
+        //                                    fMeanPedestal+5.*fMeanPedestalErr);
+        fSinglePheFit->SetParLimits(1,0.,30.);
+        //	fSinglePheFit->SetParLimits(2,rmin,rmax);
+	fSinglePheFit->SetParLimits(2,50.,150.);
+        //        fSinglePheFit->SetParLimits(3,
+        //                                    fSigmaPedestal-5.*fSigmaPedestalErr,
+        //                                    fSigmaPedestal+5.*fSigmaPedestalErr);
+        fSinglePheFit->SetParLimits(3,0.,50.);
+        //	fSinglePheFit->SetParLimits(4,0.,(rmax-rmin));
+	fSinglePheFit->SetParLimits(4,0.,100.);
+	fSinglePheFit->SetParLimits(5,norm-(0.5*norm),norm+(0.5*norm));
+	break;
+    case kEPoisson5:
+    case kEPoisson6:
+      fSinglePheFit->SetParameters(lambda_guess,mu_0_guess,mu_1_guess,si_0_guess,si_1_guess,norm);
+      fSinglePheFit->SetParNames("#lambda","#mu_{0}","#mu_{1}","#sigma_{0}","#sigma_{1}","Area");
+      fSinglePheFit->SetParLimits(0,0.,1.);
+      fSinglePheFit->SetParLimits(1,rmin,(rmax-rmin)/1.5);
+      fSinglePheFit->SetParLimits(2,(rmax-rmin)/2.,(rmax-0.05*(rmax-rmin)));
+      fSinglePheFit->SetParLimits(3,1.0,(rmax-rmin)/2.0);
+      fSinglePheFit->SetParLimits(4,1.0,(rmax-rmin)/2.5);
+      fSinglePheFit->SetParLimits(5,norm-0.1,norm+0.1);
+      break;
+
+    case kEPolya:
+        fSinglePheFit->SetParameters(lambda_guess, excessPoisson_guess,
+                                     delta1_guess,delta2_guess,
+                                     electronicAmp_guess,
+                                     fSigmaPedestal,
+                                     norm, 
+                                     fMeanPedestal);
+      fSinglePheFit->SetParNames("#lambda","b_{tot}",
+                                 "#delta_{1}","#delta_{2}",
+                                 "amp_{e}","#sigma_{0}",
+                                 "Area", "#mu_{0}");
+      fSinglePheFit->SetParLimits(0,0.,1.);
+      fSinglePheFit->SetParLimits(1,0.,1.); 
+      fSinglePheFit->SetParLimits(2,6.,12.);    
+      fSinglePheFit->SetParLimits(3,3.,8.);    
+      fSinglePheFit->SetParLimits(4,electronicAmp_guess-electronicAmp_limit,
+                                    electronicAmp_guess+electronicAmp_limit);    
+      fSinglePheFit->SetParLimits(5,
+                                    fSigmaPedestal-3.*fSigmaPedestalErr,
+                                    fSigmaPedestal+3.*fSigmaPedestalErr);
+      fSinglePheFit->SetParLimits(6,norm-0.1,norm+0.1);
+      fSinglePheFit->SetParLimits(7,
+                                    fMeanPedestal-3.*fMeanPedestalErr,
+                                    fMeanPedestal+3.*fMeanPedestalErr);
+      break;
+    case kEMichele:
+      fSinglePheFit->SetParameters(lambda_1cat_guess, lambda_1dyn_guess, 
+                                   20., mu_1cat_guess,mu_1dyn_guess,
+                                   si_0_guess, si_1cat_guess,si_1dyn_guess,
+                                   norm, offset_guess);
+      fSinglePheFit->SetParNames("#lambda_{cat}","#lambda_{dyn}",
+                                 "#mu_{0}","#mu_{1cat}","#mu_{1dyn}",
+                                 "#sigma_{0}","#sigma_{1cat}","#sigma_{1dyn}",
+                                 "Area","offset");
+      fSinglePheFit->SetParLimits(0,0.,0.5);
+      fSinglePheFit->SetParLimits(1,0.,0.05); 
+      fSinglePheFit->SetParLimits(2,0.,fSinglePheCut);    
+      fSinglePheFit->SetParLimits(3,1500.,5500.);    
+      fSinglePheFit->SetParLimits(4,fSinglePheCut,1500.);    
+      fSinglePheFit->SetParLimits(5,0.1,fSinglePheCut/1.25);    
+      fSinglePheFit->SetParLimits(6,fSinglePheCut/1.25,1000.);    
+      fSinglePheFit->SetParLimits(7,1000.,1500.);    
+      fSinglePheFit->SetParLimits(8,norm/1.1,norm*1.1);
+      fSinglePheFit->SetParLimits(9,0.,1.);
+      break;
+
+    default:
+      *fLog << warn << "WARNING: Could not find Fit Function for Blind Pixel " << endl;
+      return kFALSE;
+      break;
+    }
+
+  fSinglePheFit->SetRange(rmin,rmax);
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// - Retrieve the parameters depending on fFitFunc
+// - Retrieve probability, Chisquare and NDF
+//
+void MHCalibrationChargeBlindPix::ExitFit()
+{
+  
+
+  //
+  // Finalize
+  //
+  switch (fFitFunc)
+    {
+      
+    case kEPoisson4:
+    case kEPoisson5:
+    case kEPoisson6:
+    case kEPoisson7:
+      fLambda = fSinglePheFit->GetParameter(0);
+      fMu0    = fSinglePheFit->GetParameter(1);
+      fMu1    = fSinglePheFit->GetParameter(2);
+      fSigma0 = fSinglePheFit->GetParameter(3);
+      fSigma1 = fSinglePheFit->GetParameter(4);
+      
+      fLambdaErr = fSinglePheFit->GetParError(0);
+      fMu0Err    = fSinglePheFit->GetParError(1);
+      fMu1Err    = fSinglePheFit->GetParError(2);
+      fSigma0Err = fSinglePheFit->GetParError(3);
+      fSigma1Err = fSinglePheFit->GetParError(4);
+      break;
+    case kEPolya:
+      fLambda =  fSinglePheFit->GetParameter(0);
+      fMu0    =  fSinglePheFit->GetParameter(7);
+      fMu1    = 0.;
+      fSigma0 =  fSinglePheFit->GetParameter(5);
+      fSigma1 = 0.;
+
+      fLambdaErr = fSinglePheFit->GetParError(0);
+      fMu0Err    = fSinglePheFit->GetParError(7);
+      fMu1Err    = 0.;
+      fSigma0Err = fSinglePheFit->GetParError(5);
+      fSigma1Err = 0.;
+    case kEMichele:
+      fLambda =  fSinglePheFit->GetParameter(0);
+      fMu0    =  fSinglePheFit->GetParameter(2);
+      fMu1    =  fSinglePheFit->GetParameter(3);
+      fSigma0 =  fSinglePheFit->GetParameter(5);
+      fSigma1 =  fSinglePheFit->GetParameter(6);
+
+      fLambdaErr = fSinglePheFit->GetParError(0);
+      fMu0Err    = fSinglePheFit->GetParError(2);
+      fMu1Err    = fSinglePheFit->GetParError(3);
+      fSigma0Err = fSinglePheFit->GetParError(5);
+      fSigma1Err = fSinglePheFit->GetParError(6);
+      break;
+    default:
+      break;
+    }
+
+  fProb      = fSinglePheFit->GetProb();
+  fChisquare = fSinglePheFit->GetChisquare();
+  fNDF       = fSinglePheFit->GetNDF();
+
+  *fLog << all << "Results of the Blind Pixel Fit: "              << endl;
+  *fLog << all << "Chisquare:   " << fChisquare                   << endl;
+  *fLog << all << "DoF:         " << fNDF                         << endl;
+  *fLog << all << "Probability: " << fProb                        << endl;
+
+}
+
+// --------------------------------------------------------------------------
+//
+// - Executes InitFit()
+// - Fits the fHGausHist with fSinglePheFit
+// - Executes ExitFit()
+//
+// The fit result is accepted under condition:
+// 1) The results are not nan's
+// 2) The NDF is not smaller than fNDFLimit (5)
+// 3) The Probability is greater than fProbLimit (default 0.001 == 99.9%)
+// 4) at least fNumSinglePheLimit events are in the single Photo-electron peak
+//
+Bool_t MHCalibrationChargeBlindPix::FitSinglePhe(Option_t *opt) 
+{
+
+  if (!InitFit())
+      return kFALSE;
+
+  fHGausHist.Fit(fSinglePheFit,opt);
+
+  ExitFit();
+
+  //
+  // The fit result is accepted under condition:
+  // 1) The results are not nan's
+  // 2) The NDF is not smaller than fNDFLimit (5)
+  // 3) The Probability is greater than fProbLimit (default 0.001 == 99.9%)
+  // 4) at least fNumSinglePheLimit events are in the single Photo-electron peak
+  //
+  if (   TMath::IsNaN(fLambda) 
+      || TMath::IsNaN(fLambdaErr)
+      || TMath::IsNaN(fProb)    
+      || TMath::IsNaN(fMu0)
+      || TMath::IsNaN(fMu0Err) 
+      || TMath::IsNaN(fMu1)
+      || TMath::IsNaN(fMu1Err) 
+      || TMath::IsNaN(fSigma0)
+      || TMath::IsNaN(fSigma0Err) 
+      || TMath::IsNaN(fSigma1)
+      || TMath::IsNaN(fSigma1Err) 
+      || fNDF  < fNDFLimit
+      || fProb < fProbLimit )
+    return kFALSE;
+
+  const Stat_t   entries      = fHGausHist.Integral("width");
+  const Float_t  numSinglePhe = TMath::Exp(-1.0*fLambda)*fLambda*entries;
+  
+  if (numSinglePhe < fNumSinglePheLimit) 
+    {
+      *fLog << warn << "WARNING - Statistics is too low: Only " << numSinglePhe
+            << " in the Single Photo-Electron peak " << endl;
+      return kFALSE;
+    } 
+  else
+    *fLog << all << numSinglePhe << " in Single Photo-Electron peak " << endl;
+  
+  SetSinglePheFitOK();
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// - Retrieves limits for the fit
+// - Fits the fHGausHist with Gauss 
+// - Retrieves the results to fLambdaCheck and fLambdaCheckErr
+// - Sets a flag IsPedestalFitOK()
+//
+void MHCalibrationChargeBlindPix::FitPedestal  (Option_t *opt)
+{
+
+  // Perform the cross-check fitting only the pedestal:
+  const Axis_t rmin    = 0.;
+  //  const Axis_t rmax    = fHGausHist.GetBinCenter(fHGausHist.GetMaximumBin());
+  const Axis_t rmax = fSinglePheCut;
+
+  FitGaus(opt, rmin, rmax);
+
+  const Stat_t   entries = fHGausHist.Integral("width");
+  const Double_t pedarea = fFGausFit->Integral(0.,fSinglePheCut);
+
+  fLambdaCheck     = TMath::Log(entries/pedarea);
+  // estimate the error by the error of the obtained area from the Gauss-function:
+  fLambdaCheckErr  = fFGausFit->GetParError(0)/fFGausFit->GetParameter(0);
+  
+  SetPedestalFitOK(IsGausFitOK());
+  return;
+}
+
+ 
+// -------------------------------------------------------------------------
+//
+// Draw a legend with the fit results
+//
+void MHCalibrationChargeBlindPix::DrawLegend()
+{
+
+  if (!fFitLegend)
+  {
+      fFitLegend = new TPaveText(0.05,0.05,0.95,0.95);
+      fFitLegend->SetLabel(Form("%s%s", "Results of the single PhE Fit (",
+				(fFitFunc ==  kEPoisson4) ? "Poisson(k=4))" : 
+				(fFitFunc ==  kEPoisson5) ? "Poisson(k=5))" : 
+				(fFitFunc ==  kEPoisson6) ? "Poisson(k=6))" :
+				(fFitFunc ==  kEPolya   ) ? "Polya(k=4))"   : 
+				(fFitFunc ==  kEMichele ) ?  "Michele)"     : " none )" ));
+      fFitLegend->SetTextSize(0.05);
+  }
+  else
+      fFitLegend->Clear();
+
+  const TString line1 = 
+      Form("Mean: #lambda = %2.2f #pm %2.2f",fLambda,fLambdaErr);
+  TText *t1 = fFitLegend->AddText(line1.Data());
+  t1->SetBit(kCanDelete);
+      
+  const TString line6 =
+      Form("Mean #lambda (check) = %2.2f #pm %2.2f",fLambdaCheck,fLambdaCheckErr);
+  TText *t2 = fFitLegend->AddText(line6.Data());
+  t2->SetBit(kCanDelete);
+  
+  const TString line2 = 
+      Form("Pedestal: #mu_{0} = %2.2f #pm %2.2f",fMu0,fMu0Err);
+  TText *t3 = fFitLegend->AddText(line2.Data());
+  t3->SetBit(kCanDelete);
+  
+  const TString line3 =
+      Form("Width Pedestal: #sigma_{0} = %2.2f #pm %2.2f",fSigma0,fSigma0Err);
+  TText *t4 = fFitLegend->AddText(line3.Data());
+  t4->SetBit(kCanDelete);
+  
+  const TString line4 =
+      Form("1^{st} Phe-peak: #mu_{1} = %2.2f #pm %2.2f",fMu1,fMu1Err);
+  TText *t5 = fFitLegend->AddText(line4.Data());
+  t5->SetBit(kCanDelete);
+  
+  const TString line5 =
+      Form("Width 1^{st} Phe-peak: #sigma_{1} = %2.2f #pm %2.2f",fSigma1,fSigma1Err);
+  TText *t6 = fFitLegend->AddText(line5.Data());
+  t6->SetBit(kCanDelete);
+  
+  const TString line7 =
+      Form("#chi^{2} / N_{dof}: %4.2f / %3i",fChisquare,fNDF);
+  TText *t7 = fFitLegend->AddText(line7.Data());
+  t7->SetBit(kCanDelete);
+  
+  const TString line8 =
+      Form("Probability: %4.2f ",fProb);
+  TText *t8 = fFitLegend->AddText(line8.Data());
+  t8->SetBit(kCanDelete);
+  
+  if (IsSinglePheFitOK())
+  {
+      TText *t = fFitLegend->AddText(0.,0.,"Result of the Fit: OK");
+      t->SetBit(kCanDelete);
+  }
+  else
+  {
+      TText *t = fFitLegend->AddText("Result of the Fit: NOT OK");
+      t->SetBit(kCanDelete);
+  }
+
+  fFitLegend->SetFillColor(IsSinglePheFitOK() ? 80 : 2);
+  fFitLegend->Draw();
+  
+  return;
+}
+
+
+// -------------------------------------------------------------------------
+//
+// Draw the histogram
+//
+// The following options can be chosen:
+//
+// "": displays the fHGausHist, the fits, the legend and fASinglePheFADCSlices and fAPedestalFADCSlices
+// "all": executes additionally MHGausEvents::Draw(), with option "fourierevents"
+// "datacheck" display the fHGausHist, the fits and the legend
+//
+void MHCalibrationChargeBlindPix::Draw(Option_t *opt) 
+{
+
+  TString option(opt);
+  option.ToLower();
+  
+  Int_t win = 1;
+
+  TVirtualPad *oldpad = gPad ? gPad : MH::MakeDefCanvas(this,900, 600);
+  TVirtualPad *pad    = NULL;
+
+  if (option.Contains("all"))
+  {
+      option.ReplaceAll("all","");
+      oldpad->Divide(2,1);
+      win = 2;
+      oldpad->cd(1);
+      TVirtualPad *newpad = gPad;
+      pad = newpad;
+      pad->Divide(2,2);
+      pad->cd(1);
+  }
+  else if (option.Contains("datacheck"))
+    {
+      pad = oldpad;
+      pad->Divide(2,1);
+      pad->cd(1);
+    }
+  else
+  {
+      pad = oldpad;
+      pad->Divide(2,2);
+      pad->cd(1);
+  }
+
+  if (!IsEmpty())
+    gPad->SetLogy();
+
+  gPad->SetTicks();
+
+  fHGausHist.Draw(); 
+  if (fFGausFit)
+  {
+      fFGausFit->SetLineColor(kBlue);
+      fFGausFit->Draw("same");
+      TLine *line = new TLine(fSinglePheCut, 0., fSinglePheCut, 10.);
+      line->SetBit(kCanDelete);
+      line->SetLineColor(kBlue);
+      line->SetLineWidth(3);
+      line->DrawLine(fSinglePheCut, 0., fSinglePheCut, 2.);
+  }
+  if (fSinglePheFit)
+  {    
+      fSinglePheFit->SetLineColor(IsSinglePheFitOK() ? kGreen : kRed);          
+      fSinglePheFit->Draw("same");
+  }
+
+  pad->cd(2);
+  DrawLegend();
+
+  if (option.Contains("datacheck"))
+    return;
+
+  pad->cd(3);
+
+  if (fASinglePheFADCSlices.GetNrows()!=1)
+    {
+      if (fHSinglePheFADCSlices)
+        delete fHSinglePheFADCSlices;
+      fHSinglePheFADCSlices = new TH1F(fASinglePheFADCSlices);
+      fHSinglePheFADCSlices->SetName("SinglePheFADCSlices");
+      fHSinglePheFADCSlices->SetTitle(Form("%s%f","Assumed Single Phe FADC Slices, Sum > ",fSinglePheCut));
+      fHSinglePheFADCSlices->SetXTitle("FADC slice number");
+      fHSinglePheFADCSlices->SetYTitle("FADC counts");
+      fHSinglePheFADCSlices->Draw();
+    }
+  
+  pad->cd(4);
+  if (fAPedestalFADCSlices.GetNrows()!=1)
+    {
+
+      if (fHPedestalFADCSlices)
+        delete fHPedestalFADCSlices;
+      
+      fHPedestalFADCSlices = new TH1F(fAPedestalFADCSlices);
+      fHPedestalFADCSlices->SetName("PedestalFADCSlices");
+      fHPedestalFADCSlices->SetTitle(Form("%s%f","Pedestal FADC Slices, Sum < ",fSinglePheCut));
+      fHPedestalFADCSlices->SetXTitle("FADC slice number");
+      fHPedestalFADCSlices->SetYTitle("FADC counts");
+      fHPedestalFADCSlices->Draw();
+    }
+  
+  if (win < 2)
+  return;
+
+  oldpad->cd(2);
+  MHGausEvents::Draw("fourierevents");
+}
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargeBlindPix.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargeBlindPix.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargeBlindPix.h	(revision 9661)
@@ -0,0 +1,525 @@
+#ifndef MARS_MHCalibrationChargeBlindPix
+#define MARS_MHCalibrationChargeBlindPix
+
+
+#ifndef MARS_MHCalibrationChargePix
+#include "MHCalibrationChargePix.h"
+#endif
+
+#ifndef ROOT_TMatrix
+#include <TMatrix.h>
+#endif
+
+#ifndef ROOT_TF1
+#include <TF1.h>
+#endif
+
+class TH1F;
+class TF1;
+class TPaveText;
+class TText;
+class MRawEvtData;
+class MRawEvtPixelIter;
+class MCalibrationChargeBlindPix;
+class MExtractBlindPixel;
+class MExtractedSignalBlindPixel;
+class MHCalibrationChargeBlindPix : public MHGausEvents
+{
+private:
+
+  static const Int_t    fgChargeNbins;       //! Default for fNBins        (now set to: 5300   )
+  static const Axis_t   fgChargeFirst;       //! Default for fFirst        (now set to: -100.5 )
+  static const Axis_t   fgChargeLast;        //! Default for fLast         (now set to: 5199.5 )
+  static const Float_t  fgSinglePheCut;      //! Default for fSinglePheCut (now set to: 200    )
+  static const Float_t  fgNumSinglePheLimit; //! Default for fNumSinglePheLimit (now set to: 50)
+  static const Float_t  gkSignalInitializer; //! Signal initializer (-9999.)
+  
+  static const Double_t gkElectronicAmp;     // Electronic Amplification after the PMT (in FADC counts/N_e)
+  static const Double_t gkElectronicAmpErr;  // Error of the electronic amplification
+
+  Float_t fSinglePheCut;                     // Value of summed FADC slices upon which event considered as single-phe
+  Float_t fNumSinglePheLimit;                // Minimum number of single-phe events 
+
+  MCalibrationChargeBlindPix *fBlindPix;     //! Storage container results  
+  MExtractedSignalBlindPixel *fSignal;       //! Storage container extracted signal
+  MRawEvtData                *fRawEvt;       //! Storage container raw data
+ 
+  TVector fASinglePheFADCSlices;             // Averaged FADC slice entries supposed single-phe events
+  TVector fAPedestalFADCSlices;              // Averaged FADC slice entries supposed pedestal   events
+ 
+  TF1 *fSinglePheFit;                        // Single Phe Fit (Gaussians convoluted with Poisson) 
+
+  UInt_t  fNumSinglePhes;                    // Number of entries in fASinglePheFADCSlices 
+  UInt_t  fNumPedestals;                     // Number of entries in fAPedestalFADCSlices  
+
+  Double_t  fLambda;                         // Poisson mean from Single-phe fit 
+  Double_t  fLambdaCheck;                    // Poisson mean from Pedestal fit alone
+  Double_t  fMu0;                            // Mean of the pedestal
+  Double_t  fMu1;                            // Mean of single-phe peak
+  Double_t  fSigma0;                         // Sigma of the pedestal
+  Double_t  fSigma1;                         // Sigma of single-phe peak
+  Double_t  fLambdaErr;                      // Error of Poisson mean from Single-phe fit 
+  Double_t  fLambdaCheckErr;                 // Error of Poisson mean from Pedestal fit alone 
+  Double_t  fMu0Err;                         // Error of  Mean of the pedestal    
+  Double_t  fMu1Err;                         // Error of  Mean of single-phe peak 
+  Double_t  fSigma0Err;                      // Error of  Sigma of the pedestal   
+  Double_t  fSigma1Err;                      // Error of  Sigma of single-phe peak
+  Double_t  fChisquare;                      // Chisquare of single-phe fit 
+  Int_t     fNDF;                            // Ndof of single-phe fit 
+  Double_t  fProb;                           // Probability of singleo-phe fit
+  Double_t  fMeanPedestal;                   // Mean pedestal from pedestal run
+  Double_t  fSigmaPedestal;                  // Sigma pedestal from pedestal run
+  Double_t  fMeanPedestalErr;                // Error of Mean pedestal from pedestal run 
+  Double_t  fSigmaPedestalErr;               // Error of Sigma pedestal from pedestal run
+				     
+  Byte_t    fFlags;                          // Bit-field for the flags
+  enum { kSinglePheFitOK, kPedestalFitOK };  // Possible bits to be set
+
+  TPaveText *fFitLegend;                     //! Some legend to display the fit results
+  TH1F      *fHSinglePheFADCSlices;          //! A histogram created and deleted only in Draw()
+  TH1F      *fHPedestalFADCSlices;           //! A histogram created and deleted only in Draw()
+
+  // Fill histos
+  void  FillSinglePheFADCSlices(const MRawEvtPixelIter &iter);
+  void  FillPedestalFADCSlices( const MRawEvtPixelIter &iter);
+
+  // Fit
+  Bool_t InitFit();
+  void   ExitFit();  
+  
+public:
+
+  MHCalibrationChargeBlindPix(const char *name=NULL, const char *title=NULL);
+  ~MHCalibrationChargeBlindPix();
+
+  void Clear(Option_t *o="");  
+  void Reset();
+  
+//  TObject *Clone(const char *) const;
+
+  Bool_t SetupFill(const MParList *pList);
+  Bool_t ReInit   (      MParList *pList);
+  Bool_t Fill     (const MParContainer *par, const Stat_t w=1);
+  Bool_t Finalize();
+  
+  // Getters
+  const Double_t GetLambda        ()  const { return fLambda;         }
+  const Double_t GetLambdaCheck   ()  const { return fLambdaCheck;    }
+  const Double_t GetMu0           ()  const { return fMu0;            }
+  const Double_t GetMu1           ()  const { return fMu1;            }
+  const Double_t GetSigma0        ()  const { return fSigma0;         }
+  const Double_t GetSigma1        ()  const { return fSigma1;         }
+  const Double_t GetLambdaErr     ()  const { return fLambdaErr;      }
+  const Double_t GetLambdaCheckErr()  const { return fLambdaCheckErr; }
+  const Double_t GetMu0Err        ()  const { return fMu0Err;         }
+  const Double_t GetMu1Err        ()  const { return fMu1Err;         }
+  const Double_t GetSigma0Err     ()  const { return fSigma0Err;      }
+  const Double_t GetSigma1Err     ()  const { return fSigma1Err;      }
+  const Float_t  GetSinglePheCut  ()  const { return fSinglePheCut;   }
+ 
+  TVector &GetASinglePheFADCSlices()             { return fASinglePheFADCSlices;  }
+  const TVector &GetASinglePheFADCSlices() const { return fASinglePheFADCSlices;  }
+
+  TVector &GetAPedestalFADCSlices()              { return fAPedestalFADCSlices;  }  
+  const TVector &GetAPedestalFADCSlices()  const { return fAPedestalFADCSlices;  }  
+
+  const Bool_t  IsSinglePheFitOK()         const;
+  const Bool_t  IsPedestalFitOK()          const;
+  
+  // Setters
+  void SetCalibrationChargeBlindPix ( MCalibrationChargeBlindPix *pix)    { fBlindPix          = pix;  }
+  void SetSinglePheCut      ( const Float_t cut =fgSinglePheCut      )    { fSinglePheCut      = cut;  }
+  void SetNumSinglePheLimit ( const Float_t lim =fgNumSinglePheLimit )    { fNumSinglePheLimit = lim;  }
+
+  void SetMeanPedestal      ( const Float_t f )   { fMeanPedestal     = f;  }
+  void SetMeanPedestalErr   ( const Float_t f )   { fMeanPedestalErr  = f;  }
+  void SetSigmaPedestal     ( const Float_t f )   { fSigmaPedestal    = f;  }
+  void SetSigmaPedestalErr  ( const Float_t f )   { fSigmaPedestalErr = f;  }
+
+  void SetSinglePheFitOK    ( const Bool_t b=kTRUE);
+  void SetPedestalFitOK     ( const Bool_t b=kTRUE);
+  
+  // Draws
+  void Draw(Option_t *opt="");
+
+private:
+  void DrawLegend();
+  
+  // Fits
+public:
+  enum FitFunc_t { kEPoisson4, kEPoisson5, kEPoisson6, kEPoisson7, kEPolya, kEMichele }; // The possible fit functions
+
+private:
+  FitFunc_t fFitFunc;
+
+public:
+  Bool_t FitSinglePhe (Option_t *opt="RL0+Q");
+  void   FitPedestal  (Option_t *opt="RL0+Q");
+
+  void   ChangeFitFunc(const FitFunc_t func)  { fFitFunc = func;  }
+  
+  // Simulation
+  Bool_t SimulateSinglePhe(const Double_t lambda,
+                           const Double_t mu0,    const Double_t mu1,
+                           const Double_t sigma0, const Double_t sigma1);
+  
+private:
+
+  inline static Double_t fFitFuncMichele(Double_t *x, Double_t *par)
+    {
+      
+      Double_t lambda1cat = par[0];  
+      Double_t lambda1dyn = par[1];
+      Double_t mu0        = par[2];
+      Double_t mu1cat     = par[3];
+      Double_t mu1dyn     = par[4];
+      Double_t sigma0     = par[5];
+      Double_t sigma1cat  = par[6];
+      Double_t sigma1dyn  = par[7];
+      Double_t offset     = par[9];
+      
+      Double_t sumcat = 0.;
+      Double_t sumdyn = 0.;
+      Double_t arg    = 0.;
+      
+      if (lambda1cat < lambda1dyn)
+        return FLT_MAX;
+
+      if (mu1cat    < mu0)
+        return FLT_MAX;
+
+      if (mu1dyn    < mu0)
+        return FLT_MAX;
+
+      if (mu1cat < mu1dyn)
+        return FLT_MAX;
+
+      if (sigma0 < 0.0001)
+        return FLT_MAX;
+      
+      if (sigma1cat < sigma0)
+        return FLT_MAX;
+
+      if (sigma1dyn < sigma0)
+        return FLT_MAX;
+
+      Double_t mu2cat = (2.*mu1cat)-mu0;  
+      Double_t mu2dyn = (2.*mu1dyn)-mu0;  
+      Double_t mu3cat = (3.*mu1cat)-(2.*mu0);
+      Double_t mu3dyn = (3.*mu1dyn)-(2.*mu0);
+      
+      Double_t sigma2cat = TMath::Sqrt((2.*sigma1cat*sigma1cat) - (sigma0*sigma0));  
+      Double_t sigma2dyn = TMath::Sqrt((2.*sigma1dyn*sigma1dyn) - (sigma0*sigma0));  
+      Double_t sigma3cat = TMath::Sqrt((3.*sigma1cat*sigma1cat) - (2.*sigma0*sigma0));
+      Double_t sigma3dyn = TMath::Sqrt((3.*sigma1dyn*sigma1dyn) - (2.*sigma0*sigma0));
+      
+      Double_t lambda2cat = lambda1cat*lambda1cat;
+      Double_t lambda2dyn = lambda1dyn*lambda1dyn;
+      Double_t lambda3cat = lambda2cat*lambda1cat;
+      Double_t lambda3dyn = lambda2dyn*lambda1dyn;
+
+     // k=0:
+      arg = (x[0] - mu0)/sigma0;
+      sumcat = TMath::Exp(-0.5*arg*arg)/sigma0;
+      sumdyn =sumcat;
+
+      // k=1cat:
+      arg = (x[0] - mu1cat)/sigma1cat;
+      sumcat += lambda1cat*TMath::Exp(-0.5*arg*arg)/sigma1cat;
+      // k=1dyn:
+      arg = (x[0] - mu1dyn)/sigma1dyn;
+      sumdyn += lambda1dyn*TMath::Exp(-0.5*arg*arg)/sigma1dyn;
+      
+      // k=2cat:
+      arg = (x[0] - mu2cat)/sigma2cat;
+      sumcat += 0.5*lambda2cat*TMath::Exp(-0.5*arg*arg)/sigma2cat;
+      // k=2dyn:
+      arg = (x[0] - mu2dyn)/sigma2dyn;
+      sumdyn += 0.5*lambda2dyn*TMath::Exp(-0.5*arg*arg)/sigma2dyn;
+  
+     
+      // k=3cat:
+      arg = (x[0] - mu3cat)/sigma3cat;
+      sumcat += 0.1666666667*lambda3cat*TMath::Exp(-0.5*arg*arg)/sigma3cat;
+      // k=3dyn:
+      arg = (x[0] - mu3dyn)/sigma3dyn;
+      sumdyn += 0.1666666667*lambda3dyn*TMath::Exp(-0.5*arg*arg)/sigma3dyn;  
+    
+      sumcat = TMath::Exp(-1.*lambda1cat)*sumcat;
+      sumdyn = TMath::Exp(-1.*lambda1dyn)*sumdyn;
+      
+      return par[8]*(sumcat+sumdyn)/2. + offset;
+
+    }
+    
+  inline static Double_t fPoissonKto4(Double_t *x, Double_t *par)
+    {
+
+      Double_t lambda = par[0];  
+      
+      Double_t sum = 0.;
+      Double_t arg = 0.;
+      
+      Double_t mu0 = par[1];
+      Double_t mu1 = par[2];
+      
+      if (mu1 < mu0)
+        return FLT_MAX;
+
+      Double_t sigma0 = par[3];
+      Double_t sigma1 = par[4];
+
+      if (sigma0 < 0.0001)
+        return FLT_MAX;
+      
+      if (sigma1 < sigma0)
+        return FLT_MAX;
+      
+      Double_t mu2 = (2.*mu1)-mu0;  
+      Double_t mu3 = (3.*mu1)-(2.*mu0);
+      Double_t mu4 = (4.*mu1)-(3.*mu0);
+      
+      Double_t sigma2 = TMath::Sqrt((2.*sigma1*sigma1) - (sigma0*sigma0));  
+      Double_t sigma3 = TMath::Sqrt((3.*sigma1*sigma1) - (2.*sigma0*sigma0));
+      Double_t sigma4 = TMath::Sqrt((4.*sigma1*sigma1) - (3.*sigma0*sigma0));
+      
+      Double_t lambda2 = lambda*lambda;
+      Double_t lambda3 = lambda2*lambda;
+      Double_t lambda4 = lambda3*lambda;
+      
+      // k=0:
+      arg = (x[0] - mu0)/sigma0;
+      sum = TMath::Exp(-0.5*arg*arg)/sigma0;
+      
+      // k=1:
+      arg = (x[0] - mu1)/sigma1;
+      sum += lambda*TMath::Exp(-0.5*arg*arg)/sigma1;
+      
+      // k=2:
+      arg = (x[0] - mu2)/sigma2;
+      sum += 0.5*lambda2*TMath::Exp(-0.5*arg*arg)/sigma2;
+      
+      // k=3:
+      arg = (x[0] - mu3)/sigma3;
+      sum += 0.1666666667*lambda3*TMath::Exp(-0.5*arg*arg)/sigma3;
+      
+      // k=4:
+      arg = (x[0] - mu4)/sigma4;
+      sum += 0.041666666666667*lambda4*TMath::Exp(-0.5*arg*arg)/sigma4;
+      
+      return TMath::Exp(-1.*lambda)*par[5]*sum;
+      
+    } 
+
+  
+  inline static Double_t fPoissonKto5(Double_t *x, Double_t *par)
+    {
+      
+      Double_t lambda = par[0];  
+      
+      Double_t sum = 0.;
+      Double_t arg = 0.;
+      
+      Double_t mu0 = par[1];
+      Double_t mu1 = par[2];
+      
+      if (mu1 < mu0)
+        return FLT_MAX;
+      
+      Double_t sigma0 = par[3];
+      Double_t sigma1 = par[4];
+      
+      if (sigma0 < 0.0001)
+        return FLT_MAX;
+      
+      if (sigma1 < sigma0)
+        return FLT_MAX;
+      
+      
+      Double_t mu2 = (2.*mu1)-mu0;  
+      Double_t mu3 = (3.*mu1)-(2.*mu0);
+      Double_t mu4 = (4.*mu1)-(3.*mu0);
+      Double_t mu5 = (5.*mu1)-(4.*mu0);
+      
+      Double_t sigma2 = TMath::Sqrt((2.*sigma1*sigma1) - (sigma0*sigma0));  
+      Double_t sigma3 = TMath::Sqrt((3.*sigma1*sigma1) - (2.*sigma0*sigma0));
+      Double_t sigma4 = TMath::Sqrt((4.*sigma1*sigma1) - (3.*sigma0*sigma0));
+      Double_t sigma5 = TMath::Sqrt((5.*sigma1*sigma1) - (4.*sigma0*sigma0));
+      
+      Double_t lambda2 = lambda*lambda;
+      Double_t lambda3 = lambda2*lambda;
+      Double_t lambda4 = lambda3*lambda;
+      Double_t lambda5 = lambda4*lambda;
+      
+      // k=0:
+      arg = (x[0] - mu0)/sigma0;
+      sum = TMath::Exp(-0.5*arg*arg)/sigma0;
+      
+      // k=1:
+      arg = (x[0] - mu1)/sigma1;
+      sum += lambda*TMath::Exp(-0.5*arg*arg)/sigma1;
+      
+      // k=2:
+      arg = (x[0] - mu2)/sigma2;
+      sum += 0.5*lambda2*TMath::Exp(-0.5*arg*arg)/sigma2;
+      
+      // k=3:
+      arg = (x[0] - mu3)/sigma3;
+      sum += 0.1666666667*lambda3*TMath::Exp(-0.5*arg*arg)/sigma3;
+      
+      // k=4:
+      arg = (x[0] - mu4)/sigma4;
+      sum += 0.041666666666667*lambda4*TMath::Exp(-0.5*arg*arg)/sigma4;
+      
+      // k=5:
+      arg = (x[0] - mu5)/sigma5;
+      sum += 0.008333333333333*lambda5*TMath::Exp(-0.5*arg*arg)/sigma5;
+      
+      return TMath::Exp(-1.*lambda)*par[5]*sum;
+      
+    }
+  
+  
+  inline static Double_t fPoissonKto6(Double_t *x, Double_t *par)
+    {
+      
+      Double_t lambda = par[0];  
+      
+      Double_t sum = 0.;
+      Double_t arg = 0.;
+      
+      Double_t mu0 = par[1];
+      Double_t mu1 = par[2];
+      
+      if (mu1 < mu0)
+        return FLT_MAX;
+      
+      Double_t sigma0 = par[3];
+      Double_t sigma1 = par[4];
+      
+      if (sigma0 < 0.0001)
+        return FLT_MAX;
+      
+      if (sigma1 < sigma0)
+        return FLT_MAX;
+      
+      
+      Double_t mu2 = (2.*mu1)-mu0;  
+      Double_t mu3 = (3.*mu1)-(2.*mu0);
+      Double_t mu4 = (4.*mu1)-(3.*mu0);
+      Double_t mu5 = (5.*mu1)-(4.*mu0);
+      Double_t mu6 = (6.*mu1)-(5.*mu0);
+      
+      Double_t sigma2 = TMath::Sqrt((2.*sigma1*sigma1) - (sigma0*sigma0));  
+      Double_t sigma3 = TMath::Sqrt((3.*sigma1*sigma1) - (2.*sigma0*sigma0));
+      Double_t sigma4 = TMath::Sqrt((4.*sigma1*sigma1) - (3.*sigma0*sigma0));
+      Double_t sigma5 = TMath::Sqrt((5.*sigma1*sigma1) - (4.*sigma0*sigma0));
+      Double_t sigma6 = TMath::Sqrt((6.*sigma1*sigma1) - (5.*sigma0*sigma0));
+      
+      Double_t lambda2 = lambda*lambda;
+      Double_t lambda3 = lambda2*lambda;
+      Double_t lambda4 = lambda3*lambda;
+      Double_t lambda5 = lambda4*lambda;
+      Double_t lambda6 = lambda5*lambda;
+      
+      // k=0:
+      arg = (x[0] - mu0)/sigma0;
+      sum = TMath::Exp(-0.5*arg*arg)/sigma0;
+      
+      // k=1:
+      arg = (x[0] - mu1)/sigma1;
+      sum += lambda*TMath::Exp(-0.5*arg*arg)/sigma1;
+      
+      // k=2:
+      arg = (x[0] - mu2)/sigma2;
+      sum += 0.5*lambda2*TMath::Exp(-0.5*arg*arg)/sigma2;
+      
+      // k=3:
+      arg = (x[0] - mu3)/sigma3;
+      sum += 0.1666666667*lambda3*TMath::Exp(-0.5*arg*arg)/sigma3;
+      
+      // k=4:
+      arg = (x[0] - mu4)/sigma4;
+      sum += 0.041666666666667*lambda4*TMath::Exp(-0.5*arg*arg)/sigma4;
+      
+      // k=5:
+      arg = (x[0] - mu5)/sigma5;
+      sum += 0.008333333333333*lambda5*TMath::Exp(-0.5*arg*arg)/sigma5;
+      
+      // k=6:
+      arg = (x[0] - mu6)/sigma6;
+      sum += 0.001388888888889*lambda6*TMath::Exp(-0.5*arg*arg)/sigma6;
+      
+      return TMath::Exp(-1.*lambda)*par[5]*sum;
+      
+    }
+
+  inline static Double_t fPolya(Double_t *x, Double_t *par)
+    {
+
+      const Double_t QEcat = 0.247;            // mean quantum efficiency
+      const Double_t sqrt2 = 1.4142135623731;
+      const Double_t sqrt3 = 1.7320508075689;
+      const Double_t sqrt4 = 2.;
+      
+      const Double_t lambda = par[0];           // mean number of photons
+      
+      const Double_t excessPoisson = par[1];    // non-Poissonic noise contribution
+      const Double_t delta1 = par[2];           // amplification first dynode
+      const Double_t delta2 = par[3];           // amplification subsequent dynodes
+      
+      const Double_t electronicAmpl = par[4];   // electronic amplification and conversion to FADC charges
+
+      const Double_t pmtAmpl = delta1*delta2*delta2*delta2*delta2*delta2;  // total PMT gain
+      const Double_t A = 1. + excessPoisson - QEcat                        
+        + 1./delta1 
+                + 1./delta1/delta2
+        + 1./delta1/delta2/delta2;                                  // variance contributions from PMT and QE
+      
+      const Double_t totAmpl = QEcat*pmtAmpl*electronicAmpl;        // Total gain and conversion
+      
+      const Double_t mu0 = par[7];                                      // pedestal
+      const Double_t mu1 = totAmpl;                                 // single phe position
+      const Double_t mu2 = 2*totAmpl;                               // double phe position
+      const Double_t mu3 = 3*totAmpl;                               // triple phe position
+      const Double_t mu4 = 4*totAmpl;                               // quadruple phe position
+      
+      const Double_t sigma0 = par[5];
+      const Double_t sigma1 = electronicAmpl*pmtAmpl*TMath::Sqrt(QEcat*A);
+      const Double_t sigma2 = sqrt2*sigma1;
+      const Double_t sigma3 = sqrt3*sigma1;
+      const Double_t sigma4 = sqrt4*sigma1;
+      
+      const Double_t lambda2 = lambda*lambda;
+      const Double_t lambda3 = lambda2*lambda;
+      const Double_t lambda4 = lambda3*lambda;
+      
+      //-- calculate the area----
+      Double_t arg = (x[0] - mu0)/sigma0;
+      Double_t sum = TMath::Exp(-0.5*arg*arg)/sigma0;
+      
+     // k=1:
+      arg = (x[0] - mu1)/sigma1;
+      sum += lambda*TMath::Exp(-0.5*arg*arg)/sigma1;
+      
+      // k=2:
+      arg = (x[0] - mu2)/sigma2;
+      sum += 0.5*lambda2*TMath::Exp(-0.5*arg*arg)/sigma2;
+      
+      // k=3:
+      arg = (x[0] - mu3)/sigma3;
+      sum += 0.1666666667*lambda3*TMath::Exp(-0.5*arg*arg)/sigma3;
+      
+      // k=4:
+      arg = (x[0] - mu4)/sigma4;
+      sum += 0.041666666666667*lambda4*TMath::Exp(-0.5*arg*arg)/sigma4;      
+      
+      return TMath::Exp(-1.*lambda)*par[6]*sum;
+    }
+  
+
+  
+  ClassDef(MHCalibrationChargeBlindPix, 1)  // Histogram class for Charge Blind Pixel Calibration
+};
+
+#endif  /* MARS_MHCalibrationChargeBlindPix */
Index: /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargeCam.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargeCam.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargeCam.cc	(revision 9661)
@@ -0,0 +1,1064 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug   02/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+/////////////////////////////////////////////////////////////////////////////
+//                                                               
+// MHCalibrationChargeCam                                               
+//
+// Fills the extracted signals of MExtractedSignalCam into the MHGausEvents-classes 
+// MHCalibrationChargeHiGainPix and MHCalibrationChargeLoGainPix for every:
+//
+// - Pixel, stored in the TObjArray's MHCalibrationCam::fHiGainArray and 
+//   MHCalibrationCam::fLoGainArray
+//
+// - Average pixel per AREA index (e.g. inner and outer for the MAGIC camera), 
+//   stored in the TObjArray's MHCalibrationCam::fAverageHiGainAreas and 
+//   MHCalibrationCam::fAverageLoGainAreas
+//
+// - Average pixel per camera SECTOR (e.g. sectors 1-6 for the MAGIC camera), 
+//   stored in the TObjArray's MHCalibrationCam::fAverageHiGainSectors and 
+//   MHCalibrationCam::fAverageLoGainSectors
+// 
+// Every signal is taken from MExtractedSignalCam and filled into a histogram and 
+// an array, in order to perform a Fourier analysis (see MHGausEvents). 
+// The signals are moreover averaged on an event-by-event basis and written into 
+// the corresponding average pixels.
+//
+// Additionally, the (FADC slice) position of the maximum is stored in an Absolute 
+// Arrival Time histogram. This histogram serves for a rough cross-check if the 
+// signal does not lie at or outside the edges of the extraction window. 
+//
+// The Charge histograms are fitted to a Gaussian, mean and sigma with its errors 
+// and the fit probability are extracted. If none of these values are NaN's and 
+// if the probability is bigger than MHGausEvents::fProbLimit (default: 0.5%), 
+// the fit is declared valid.
+// Otherwise, the fit is repeated within ranges of the previous mean 
+// +- MHGausEvents::fPickupLimit (default: 5) sigma (see MHGausEvents::RepeatFit())
+// In case this does not make the fit valid, the histogram means and RMS's are 
+// taken directly (see MHGausEvents::BypassFit()) and the following flags are set:
+// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainNotFitted ) or  
+// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainNotFitted ) and 
+// - MBadPixelsPix::SetUnsuitable(   MBadPixelsPix::kUnreliableRun   ) 
+// 
+// Outliers of more than MHGausEvents::fPickupLimit (default: 5) sigmas 
+// from the mean are counted as Pickup events (stored in MHGausEvents::fPickup) 
+//
+// Unless more than fNumHiGainSaturationLimit (default: 1%) of the overall FADC 
+// slices show saturation, the following flag is set:
+// - MCalibrationChargePix::SetHiGainSaturation();
+// In that case, the calibration constants are derived from the low-gain results.
+//
+// If more than fNumLoGainSaturationLimit (default: 1%) of the overall 
+// low-gain FADC slices saturate, the following flags are set:
+// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainSaturation ) and
+// - MBadPixelsPix::SetUnsuitable(   MBadPixelsPix::kUnsuitableRun    )
+// 
+// The class also fills arrays with the signal vs. event number, creates a fourier 
+// spectrum and investigates if the projected fourier components follow an exponential 
+// distribution. In case that the probability of the exponential fit is less than 
+// MHGausEvents::fProbLimit (default: 0.5%), the following flags are set:
+// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainOscillating ) or
+// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainOscillating ) and
+// - MBadPixelsPix::SetUnsuitable(   MBadPixelsPix::kUnreliableRun     )
+// 
+// This same procedure is performed for the average pixels.
+//
+// The following results are written into MCalibrationChargeCam:
+//
+// - MCalibrationPix::SetHiGainSaturation() 
+// - MCalibrationPix::SetHiGainMean()
+// - MCalibrationPix::SetHiGainMeanErr()
+// - MCalibrationPix::SetHiGainSigma()
+// - MCalibrationPix::SetHiGainSigmaErr()
+// - MCalibrationPix::SetHiGainProb()
+// - MCalibrationPix::SetHiGainNumPickup()
+//
+// - MCalibrationPix::SetLoGainMean()
+// - MCalibrationPix::SetLoGainMeanErr()
+// - MCalibrationPix::SetLoGainSigma()
+// - MCalibrationPix::SetLoGainSigmaErr()
+// - MCalibrationPix::SetLoGainProb()
+// - MCalibrationPix::SetLoGainNumPickup()
+//
+// - MCalibrationChargePix::SetAbsTimeMean()
+// - MCalibrationChargePix::SetAbsTimeRms()
+//
+// For all averaged areas, the fitted sigma is multiplied with the square root of 
+// the number involved pixels in order to be able to compare it to the average of 
+// sigmas in the camera.
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MHCalibrationChargeCam.h"
+#include "MHCalibrationCam.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MHCalibrationChargeHiGainPix.h"
+#include "MHCalibrationChargeLoGainPix.h"
+#include "MHCalibrationChargePix.h"
+
+#include "MCalibrationChargeCam.h"
+#include "MCalibrationChargePix.h"
+
+#include "MGeomCam.h"
+#include "MGeomPix.h"
+
+#include "MHGausEvents.h"
+
+#include "MBadPixelsCam.h"
+#include "MBadPixelsPix.h"
+
+#include "MRawEvtData.h"
+#include "MRawEvtPixelIter.h"
+
+#include "MExtractedSignalCam.h"
+#include "MExtractedSignalPix.h"
+
+#include <TPad.h>
+#include <TVirtualPad.h>
+#include <TCanvas.h>
+#include <TStyle.h>
+#include <TF1.h>
+#include <TH2D.h>
+#include <TLine.h>
+#include <TLatex.h>
+#include <TLegend.h>
+
+ClassImp(MHCalibrationChargeCam);
+
+using namespace std;
+
+const Float_t MHCalibrationChargeCam::fgNumHiGainSaturationLimit = 0.01;
+const Float_t MHCalibrationChargeCam::fgNumLoGainSaturationLimit = 0.005;
+const Float_t MHCalibrationChargeCam::fgTimeLowerLimit           = 1.;
+const Float_t MHCalibrationChargeCam::fgTimeUpperLimit           = 2.;
+// 1Led Green, 1 LED blue, 5 LEDs blue, 10 LEDs blue, 10 LEDs UV, CT1, 5Leds Green
+const Float_t MHCalibrationChargeCam::gkHiGainInnerRefLines[7]   = { 245., 323. , 1065., 1467., 180., 211. , 533.5};   
+const Float_t MHCalibrationChargeCam::gkHiGainOuterRefLines[7]   = { 217., 307.5, 932. , 1405., 167., 183.5, 405.5};
+const Float_t MHCalibrationChargeCam::gkLoGainInnerRefLines[7]   = { 20.8, 28.0 , 121. , 200.2, 16.5, 13.5 , 41.7 };
+const Float_t MHCalibrationChargeCam::gkLoGainOuterRefLines[7]   = { 18.9, 26.0 , 108.3, 198. , 14.0, 11.  , 42.  };
+// --------------------------------------------------------------------------
+//
+// Default Constructor. 
+//
+// Sets:
+// - all pointers to NULL
+//
+// Initializes:
+// - fNumHiGainSaturationLimit to fgNumHiGainSaturationLimit
+// - fNumLoGainSaturationLimit to fgNumLoGainSaturationLimit
+// - fTimeLowerLimit           to fgTimeLowerLimit 
+// - fTimeUpperLimit           to fgTimeUpperLimit 
+//
+MHCalibrationChargeCam::MHCalibrationChargeCam(const char *name, const char *title)
+    : fRawEvt(NULL)
+{
+  fName  = name  ? name  : "MHCalibrationChargeCam";
+  fTitle = title ? title : "Class to fill the calibration histograms ";
+  
+  SetNumHiGainSaturationLimit(fgNumHiGainSaturationLimit);
+  SetNumLoGainSaturationLimit(fgNumLoGainSaturationLimit);
+  SetTimeLowerLimit();
+  SetTimeUpperLimit();
+
+
+}
+
+// --------------------------------------------------------------------------
+//
+// Gets the pointers to:
+// - MRawEvtData
+//
+Bool_t MHCalibrationChargeCam::SetupHists(const MParList *pList)
+{
+
+  fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
+  if (!fRawEvt)
+  {
+      *fLog << err << dbginf << "MRawEvtData not found... aborting." << endl;
+      return kFALSE;
+  }
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Gets or creates the pointers to:
+// - MExtractedSignalCam
+// - MCalibrationChargeCam
+// - MBadPixelsCam
+//
+// Initializes the number of used FADC slices from MExtractedSignalCam 
+// into MCalibrationChargeCam and test for changes in that variable
+//
+// Initializes, if empty to MGeomCam::GetNumPixels():
+// - MHCalibrationCam::fHiGainArray, MHCalibrationCam::fLoGainArray
+//
+// Initializes, if empty to MGeomCam::GetNumAreas() for:
+// - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
+//
+// Initializes, if empty to MGeomCam::GetNumSectors() for:
+// - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
+//
+// Calls MHCalibrationCam::InitHists() for every entry in:
+// - MHCalibrationCam::fHiGainArray, MHCalibrationCam::fLoGainArray
+// - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
+// - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
+//
+// Sets Titles and Names for the Charge Histograms:
+// - MHCalibrationCam::fAverageHiGainAreas
+// - MHCalibrationCam::fAverageHiGainSectors
+// 
+// Sets number of bins to MHCalibrationCam::fAverageNbins for:
+// - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
+// - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
+// 
+Bool_t MHCalibrationChargeCam::ReInitHists(MParList *pList)
+{
+
+  MExtractedSignalCam *signal = (MExtractedSignalCam*)pList->FindObject("MExtractedSignalCam");
+  if (!signal)
+  {
+      *fLog << err << "MExtractedSignalCam not found... abort." << endl;
+      return kFALSE;
+  }
+
+  fCam = (MCalibrationCam*)pList->FindObject("MCalibrationChargeCam");
+  if (!fCam)
+    {
+      fCam = (MCalibrationCam*)pList->FindCreateObj(AddSerialNumber("MCalibrationChargeCam"));
+      if (!fCam)
+        {
+          gLog << err << "Cannot find nor create MCalibrationChargeCam ... abort." << endl;
+          return kFALSE;
+        }
+      else 
+        fCam->Init(*fGeom);
+    }
+
+  fFirstHiGain = signal->GetFirstUsedSliceHiGain();
+  fLastHiGain  = signal->GetLastUsedSliceHiGain();
+  fFirstLoGain = signal->GetFirstUsedSliceLoGain();
+  fLastLoGain  = signal->GetLastUsedSliceLoGain();
+
+  const Float_t numhigain = signal->GetNumUsedHiGainFADCSlices();
+  const Float_t numlogain = signal->GetNumUsedLoGainFADCSlices();  
+
+  if (fCam->GetNumHiGainFADCSlices() == 0.)
+    fCam->SetNumHiGainFADCSlices ( numhigain );
+  else if (fCam->GetNumHiGainFADCSlices() != numhigain)
+    {
+      *fLog << err << GetDescriptor() 
+            << ": Number of High Gain FADC extraction slices has changed, abort..." << endl;
+      return kFALSE;
+    }
+
+  if (fCam->GetNumLoGainFADCSlices() == 0.)
+    fCam->SetNumLoGainFADCSlices ( numlogain );
+  else if (fCam->GetNumLoGainFADCSlices() != numlogain)
+    {
+      *fLog << err << GetDescriptor() 
+            << ": Number of Low Gain FADC extraction slices has changes, abort..." << endl;
+      return kFALSE;
+    }
+
+  const Int_t npixels  = fGeom->GetNumPixels();
+  const Int_t nsectors = fGeom->GetNumSectors();
+  const Int_t nareas   = fGeom->GetNumAreas();
+
+  if (fHiGainArray->GetEntries()==0)
+  {
+      fHiGainArray->Expand(npixels);
+      for (Int_t i=0; i<npixels; i++)
+      {
+	  (*fHiGainArray)[i] = new MHCalibrationChargeHiGainPix;
+          InitHists((*this)[i],(*fBadPixels)[i],i);
+      }
+  }
+
+  if (fLoGainArray->GetEntries()==0)
+  {
+      fLoGainArray->Expand(npixels);
+      
+      for (Int_t i=0; i<npixels; i++)
+      {
+	  (*fLoGainArray)[i] = new MHCalibrationChargeLoGainPix;
+          InitHists((*this)(i),(*fBadPixels)[i],i);
+      }
+      
+  }
+
+  if (fAverageHiGainAreas->GetEntries()==0)
+  {
+    fAverageHiGainAreas->Expand(nareas);
+    
+    for (Int_t j=0; j<nareas; j++)
+      {
+        (*fAverageHiGainAreas)[j] = 
+          new MHCalibrationChargeHiGainPix("AverageHiGainArea",
+                                           "Average HiGain FADC sums area idx ");
+
+        MHCalibrationChargePix &hist = (MHCalibrationChargePix&)GetAverageHiGainArea(j);
+
+        hist.SetNbins(fAverageNbins);
+        hist.SetLast(2.*hist.GetLast());
+        hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average HiGain Area Idx ");
+
+        if (fGeom->InheritsFrom("MGeomCamMagic"))
+          {
+            hist.GetHGausHist()->SetTitle(Form("%s%s%s","Signal averaged on event-by-event basis ",
+                                               j==0 ? "Inner Pixels " : "Outer Pixels ","High Gain Runs: "));
+            hist.InitBins();
+            hist.SetEventFrequency(fPulserFrequency);
+          }
+        else
+          {
+            hist.GetHGausHist()->SetTitle("Signal averaged on event-by-event basis High Gain Area Idx ");
+            InitHists(hist,fCam->GetAverageBadArea(j),j);
+          }
+      }
+  }
+
+
+  if (fAverageLoGainAreas->GetEntries()==0)
+    {
+      fAverageLoGainAreas->Expand(nareas);
+      
+      for (Int_t j=0; j<nareas; j++)
+        {
+	  (*fAverageLoGainAreas)[j] = 
+            new MHCalibrationChargeLoGainPix("AverageLoGainArea",
+                                             "Average LoGain FADC sums of pixel area idx ");
+
+        MHCalibrationChargePix &hist = (MHCalibrationChargePix&)GetAverageLoGainArea(j);
+
+        hist.SetNbins(fAverageNbins);
+        hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average LoGain Area Idx ");
+
+        if (fGeom->InheritsFrom("MGeomCamMagic"))
+          {
+            hist.GetHGausHist()->SetTitle(Form("%s%s%s","Signal averaged on event-by-event basis ",
+                                               j==0 ? "Inner Pixels " : "Outer Pixels ","High Gain Runs: "));
+            hist.InitBins();
+            hist.SetEventFrequency(fPulserFrequency);
+          }
+        else
+          {
+            hist.GetHGausHist()->SetTitle("Signal averaged on event-by-event basis High Gain Area Idx ");
+            InitHists(hist,fCam->GetAverageBadArea(j),j);
+          }
+        }
+    }
+  
+  if (fAverageHiGainSectors->GetEntries()==0)
+  {
+      fAverageHiGainSectors->Expand(nsectors);
+
+      for (Int_t j=0; j<nsectors; j++)
+      {
+	  (*fAverageHiGainSectors)[j] = 
+            new MHCalibrationChargeHiGainPix("AverageHiGainSector",
+                                             "Average HiGain FADC sums of pixel sector ");
+
+          MHCalibrationChargePix &hist = (MHCalibrationChargePix&)GetAverageHiGainSector(j);
+
+          hist.GetHGausHist()->SetTitle("Summed FADC slices average HiGain Sector ");
+          hist.SetNbins(fAverageNbins);
+          hist.SetLast (2.*hist.GetLast());
+          hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average HiGain Sector ");
+
+          InitHists(hist,fCam->GetAverageBadSector(j),j);
+
+      }
+  }
+
+  if (fAverageLoGainSectors->GetEntries()==0)
+  {
+      fAverageLoGainSectors->Expand(nsectors);
+  
+      for (Int_t j=0; j<nsectors; j++)
+      {
+	  (*fAverageLoGainSectors)[j] = 
+            new MHCalibrationChargeLoGainPix("AverageLoGainSector",
+                                             "Average LoGain FADC sums of pixel sector ");
+
+          MHCalibrationChargePix &hist = (MHCalibrationChargePix&)GetAverageLoGainSector(j);
+
+          hist.GetHGausHist()->SetTitle("Summed FADC slices average LoGain Sector ");
+          hist.SetNbins(fAverageNbins);
+          hist.GetHAbsTime()->SetTitle("Absolute Arrival Time average LoGain Sector ");
+
+          InitHists(hist,fCam->GetAverageBadSector(j),j);
+          
+      }
+  }
+
+  return kTRUE;
+}
+
+  
+// --------------------------------------------------------------------------
+//
+// Retrieves from MExtractedSignalCam:
+// - first used LoGain FADC slice
+//
+// Retrieves from MGeomCam:
+// - number of pixels
+// - number of pixel areas
+// - number of sectors
+//
+// For all TObjArray's (including the averaged ones), the following steps are performed: 
+//
+// 1) Fill Charges histograms (MHGausEvents::FillHistAndArray()) with:
+// - MExtractedSignalPix::GetExtractedSignalHiGain();
+// - MExtractedSignalPix::GetExtractedSignalLoGain();
+//
+// 2) Set number of saturated slices (MHCalibrationChargePix::SetSaturated()) with:
+// - MExtractedSignalPix::GetNumHiGainSaturated();
+// - MExtractedSignalPix::GetNumLoGainSaturated();
+//
+// 3) Fill AbsTime histograms (MHCalibrationChargePix::FillAbsTime()) with:
+// - MRawEvtPixelIter::GetIdxMaxHiGainSample();       
+// - MRawEvtPixelIter::GetIdxMaxLoGainSample(first slice);
+//
+Bool_t MHCalibrationChargeCam::FillHists(const MParContainer *par, const Stat_t w)
+{
+
+  MExtractedSignalCam *signal = (MExtractedSignalCam*)par;
+  if (!signal)
+    {
+      *fLog << err << "No argument in MExtractedSignalCam::Fill... abort." << endl;
+      return kFALSE;
+    }
+  
+  const UInt_t npixels  = fGeom->GetNumPixels();
+  const UInt_t nareas   = fGeom->GetNumAreas();
+  const UInt_t nsectors = fGeom->GetNumSectors();
+  const UInt_t lofirst  = signal->GetFirstUsedSliceLoGain();
+
+  Float_t sumhiarea  [nareas],   sumloarea  [nareas],   timehiarea  [nareas],   timeloarea  [nareas];
+  Float_t sumhisector[nsectors], sumlosector[nsectors], timehisector[nsectors], timelosector[nsectors];
+  Int_t   sathiarea  [nareas],   satloarea  [nareas];
+  Int_t   sathisector[nsectors], satlosector[nsectors];
+
+  memset(sumhiarea,   0, nareas * sizeof(Float_t));
+  memset(sumloarea,   0, nareas * sizeof(Float_t));
+  memset(timehiarea,  0, nareas * sizeof(Float_t));
+  memset(timeloarea,  0, nareas * sizeof(Float_t));
+  memset(sathiarea,   0, nareas * sizeof(Int_t  ));
+  memset(satloarea,   0, nareas * sizeof(Int_t  ));
+  memset(sumhisector, 0, nsectors*sizeof(Float_t));
+  memset(sumlosector, 0, nsectors*sizeof(Float_t));
+  memset(timehisector,0, nsectors*sizeof(Float_t));
+  memset(timelosector,0, nsectors*sizeof(Float_t));
+  memset(sathisector, 0, nsectors*sizeof(Int_t  ));
+  memset(satlosector, 0, nsectors*sizeof(Int_t  ));
+
+  for (UInt_t i=0; i<npixels; i++)
+    {
+
+      MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)(*this)[i];
+      MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)(*this)(i);
+
+      if (histhi.IsExcluded())
+	continue;
+
+      const MExtractedSignalPix &pix = (*signal)[i];
+      
+      const Float_t sumhi  = pix.GetExtractedSignalHiGain();
+      const Float_t sumlo  = pix.GetExtractedSignalLoGain();
+      
+      if (!histhi.FillHistAndArray(sumhi))
+        fHiGainOverFlow++;
+      if (!histlo.FillHistAndArray(sumlo))
+        fLoGainOverFlow++;
+
+      const Int_t sathi = (Int_t)pix.GetNumHiGainSaturated();
+      const Int_t satlo = (Int_t)pix.GetNumLoGainSaturated();
+
+      histhi.SetSaturated(sathi); 
+      histlo.SetSaturated(satlo); 
+
+      const Int_t aidx   = (*fGeom)[i].GetAidx();
+      const Int_t sector = (*fGeom)[i].GetSector();
+
+      sumhiarea[aidx]  += sumhi;
+      sumloarea[aidx]  += sumlo;
+      sathiarea[aidx]  += sathi;
+      satloarea[aidx]  += satlo;
+
+      sumhisector[sector]  += sumhi;
+      sumlosector[sector]  += sumlo;
+      sathisector[sector]  += sathi;
+      satlosector[sector]  += satlo;
+    }
+
+  MRawEvtPixelIter pixel(fRawEvt);
+  while (pixel.Next())
+    {
+      
+      const UInt_t pixid = pixel.GetPixelId();
+
+      MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)(*this)[pixid];
+      MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)(*this)(pixid);
+
+      if (histhi.IsExcluded())
+         continue;
+      
+      const Float_t timehi = (Float_t)pixel.GetIdxMaxHiGainSample();
+      const Float_t timelo = (Float_t)pixel.GetIdxMaxLoGainSample(lofirst);
+
+      histhi.FillAbsTime(timehi);
+      histlo.FillAbsTime(timelo);
+
+      const Int_t aidx   = (*fGeom)[pixid].GetAidx();
+      const Int_t sector = (*fGeom)[pixid].GetSector();
+
+      timehiarea[aidx] += timehi;
+      timeloarea[aidx] += timelo;
+
+      timehisector[sector] += timehi;
+      timelosector[sector] += timelo;
+    }
+  
+  for (UInt_t j=0; j<nareas; j++)
+    {
+
+      const Int_t npix = fAverageAreaNum[j];
+
+      MHCalibrationChargePix &hipix = (MHCalibrationChargePix&)GetAverageHiGainArea(j);
+      MHCalibrationChargePix &lopix = (MHCalibrationChargePix&)GetAverageLoGainArea(j);
+
+      hipix.FillHistAndArray(sumhiarea[j]/npix);
+      lopix.FillHistAndArray(sumloarea[j]/npix);
+
+      hipix.SetSaturated((Float_t)sathiarea[j]/npix); 
+      lopix.SetSaturated((Float_t)satloarea[j]/npix); 
+
+      hipix.FillAbsTime(timehiarea[j]/npix);
+      lopix.FillAbsTime(timeloarea[j]/npix);
+
+    }
+
+  for (UInt_t j=0; j<nsectors; j++)
+    {
+
+      const Int_t npix = fAverageSectorNum[j];
+
+      MHCalibrationChargePix &hipix = (MHCalibrationChargePix&)GetAverageHiGainSector(j);
+      MHCalibrationChargePix &lopix = (MHCalibrationChargePix&)GetAverageLoGainSector(j);
+
+      hipix.FillHistAndArray(sumhisector[j]/npix);
+      lopix.FillHistAndArray(sumlosector[j]/npix);
+
+      hipix.SetSaturated((Float_t)sathisector[j]/npix); 
+      lopix.SetSaturated((Float_t)satlosector[j]/npix); 
+
+      hipix.FillAbsTime(timehisector[j]/npix);
+      lopix.FillAbsTime(timelosector[j]/npix);
+
+    }
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// For all TObjArray's (including the averaged ones), the following steps are performed: 
+//
+// 1) Returns if the pixel is excluded.
+// 2) Tests saturation. In case yes, set the flag: MCalibrationPix::SetHiGainSaturation()
+//    or the flag: MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainSaturated )
+// 3) Store the absolute arrival times in the MCalibrationChargePix's. If flag 
+//    MCalibrationPix::IsHiGainSaturation() is set, the Low-Gain arrival times are stored, 
+//    otherwise the Hi-Gain ones.
+// 4) Calls to MHCalibrationCam::FitHiGainArrays() and MCalibrationCam::FitLoGainArrays() 
+//    with the flags:
+//    - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainNotFitted )
+//    - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainNotFitted )
+//    - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainOscillating )
+//    - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kLoGainOscillating )
+//
+Bool_t MHCalibrationChargeCam::FinalizeHists()
+{
+
+  if (fHiGainOverFlow)
+    *fLog << warn << GetDescriptor()
+          << ": WARNING: Histogram Overflow has occurred " << fHiGainOverFlow << " in the High-Gain! " << endl;
+  if (fLoGainOverFlow)
+    *fLog << warn << GetDescriptor()
+          << ": WARNING: Histogram Overflow has occurred " << fLoGainOverFlow << " in the Low-Gain! " << endl;
+
+  for (Int_t i=0; i<fHiGainArray->GetSize(); i++)
+    {
+      
+      MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)(*this)[i];
+      MCalibrationChargePix  &pix    = (MCalibrationChargePix&)(*fCam)[i];
+      MBadPixelsPix          &bad    = (*fBadPixels)[i];
+      
+      if (histhi.IsExcluded())
+        continue;
+      
+      if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
+        {
+          pix.SetHiGainSaturation();
+          histhi.CreateFourierSpectrum();
+          continue;
+        }
+
+      FinalizeAbsTimes(histhi, pix, bad, fFirstHiGain, fLastHiGain);
+    }
+
+  for (Int_t i=0; i<fLoGainArray->GetSize(); i++)
+    {
+      
+      MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)(*this)(i);
+      MBadPixelsPix          &bad    = (*fBadPixels)[i];
+
+      if (histlo.IsExcluded())
+        continue;
+      
+      if (histlo.GetSaturated() > fNumLoGainSaturationLimit*histlo.GetHGausHist()->GetEntries())
+        {
+          *fLog << warn << "Saturated Lo Gain histogram in pixel: " << i << endl;
+          bad.SetUncalibrated( MBadPixelsPix::kLoGainSaturation ); 
+          histlo.CreateFourierSpectrum();
+          continue;
+        }
+  
+      MCalibrationChargePix &pix    = (MCalibrationChargePix&)(*fCam)[i];
+      
+      if (pix.IsHiGainSaturation())
+        FinalizeAbsTimes(histlo, pix, bad, fFirstLoGain, fLastLoGain);
+    }
+
+  for (Int_t j=0; j<fAverageHiGainAreas->GetSize(); j++)
+    {
+      
+      MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)GetAverageHiGainArea(j);      
+      MCalibrationChargePix  &pix    = (MCalibrationChargePix&)fCam->GetAverageArea(j);
+      MBadPixelsPix          &bad    = fCam->GetAverageBadArea(j);
+      
+      if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
+        {
+          pix.SetHiGainSaturation();
+          histhi.CreateFourierSpectrum();
+          continue;
+        }
+
+      FinalizeAbsTimes(histhi, pix, bad, fFirstHiGain, fLastHiGain);
+   }
+  
+  for (Int_t j=0; j<fAverageLoGainAreas->GetSize(); j++)
+    {
+      
+      MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)GetAverageLoGainArea(j);      
+      MCalibrationChargePix  &pix    = (MCalibrationChargePix&)fCam->GetAverageArea(j);
+      MBadPixelsPix          &bad    = fCam->GetAverageBadArea(j);      
+
+      if (histlo.GetSaturated() > fNumLoGainSaturationLimit*histlo.GetHGausHist()->GetEntries())
+        {
+          *fLog << warn << "Saturated Lo Gain histogram in area idx: " << j << endl;
+          histlo.CreateFourierSpectrum();
+          continue;
+        }
+
+      if (pix.IsHiGainSaturation())
+        FinalizeAbsTimes(histlo, pix, bad, fFirstLoGain, fLastLoGain);
+    }
+
+  for (Int_t j=0; j<fAverageHiGainSectors->GetSize(); j++)
+    {
+      
+      MHCalibrationChargePix &histhi = (MHCalibrationChargePix&)GetAverageHiGainSector(j);      
+      MCalibrationChargePix  &pix    = (MCalibrationChargePix&)fCam->GetAverageSector(j);
+      MBadPixelsPix          &bad    = fCam->GetAverageBadSector(j);      
+
+      if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
+        {
+          pix.SetHiGainSaturation();
+          histhi.CreateFourierSpectrum();
+          continue;
+        }
+
+      FinalizeAbsTimes(histhi, pix, bad, fFirstHiGain, fLastHiGain);
+    }
+  
+  for (Int_t j=0; j<fAverageLoGainSectors->GetSize(); j++)
+    {
+      
+      MHCalibrationChargePix &histlo = (MHCalibrationChargePix&)GetAverageLoGainSector(j);      
+      MCalibrationChargePix  &pix    = (MCalibrationChargePix&)fCam->GetAverageSector(j);
+      MBadPixelsPix          &bad    = fCam->GetAverageBadSector(j);        
+      
+      if (histlo.GetSaturated() > fNumLoGainSaturationLimit*histlo.GetHGausHist()->GetEntries())
+        {
+          *fLog << warn << "Saturated Lo Gain histogram in sector: " << j << endl;
+          bad.SetUncalibrated( MBadPixelsPix::kLoGainSaturation ); 
+          histlo.CreateFourierSpectrum();
+          continue;
+        }
+
+      if (pix.IsHiGainSaturation())
+        FinalizeAbsTimes(histlo, pix, bad, fFirstLoGain, fLastLoGain);
+    }
+  
+  //
+  // Perform the fitting for the High Gain (done in MHCalibrationCam)
+  //
+  FitHiGainArrays((MCalibrationCam&)(*fCam),(*fBadPixels),
+                  MBadPixelsPix::kHiGainNotFitted,
+                  MBadPixelsPix::kHiGainOscillating);
+  //
+  // Perform the fitting for the Low Gain (done in MHCalibrationCam)
+  //
+  FitLoGainArrays((MCalibrationCam&)(*fCam),(*fBadPixels),
+                  MBadPixelsPix::kLoGainNotFitted,
+                  MBadPixelsPix::kLoGainOscillating);
+      
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------------
+//
+// Fill the absolute time results into MCalibrationChargePix
+//
+// Check absolute time validity:
+// - Mean arrival time is at least fTimeLowerLimit slices from the lower edge 
+// - Mean arrival time is at least fUpperLimit     slices from the upper edge
+//
+void MHCalibrationChargeCam::FinalizeAbsTimes(MHCalibrationChargePix &hist, MCalibrationChargePix &pix, MBadPixelsPix &bad, 
+                                              Byte_t first, Byte_t last)
+{
+  
+  const Float_t mean = hist.GetAbsTimeMean();
+  const Float_t rms  = hist.GetAbsTimeRms();
+
+  pix.SetAbsTimeMean ( mean );
+  pix.SetAbsTimeRms  ( rms  );
+  
+  const Float_t lowerlimit = (Float_t)first + fTimeLowerLimit;
+  const Float_t upperlimit = (Float_t)last  + fTimeUpperLimit;  
+
+  if ( mean < lowerlimit)
+    {
+      *fLog << warn << GetDescriptor() 
+            << Form("%s%3.1f%s%2.1f%s%4i",": Mean ArrivalTime: ",mean," smaller than ",fTimeLowerLimit,
+                    " FADC slices from lower edge in pixel ",hist.GetPixId()) << endl;
+      bad.SetUncalibrated( MBadPixelsPix::kMeanTimeInFirstBin );
+    }
+  
+  if ( mean  > upperlimit )
+    {
+      *fLog << warn << GetDescriptor() 
+            << Form("%s%3.1f%s%2.1f%s%4i",": Mean ArrivalTime: ",mean," greater than ",fTimeUpperLimit,
+                    " FADC slices from upper edge in pixel ",hist.GetPixId()) << endl;
+      bad.SetUncalibrated( MBadPixelsPix::kMeanTimeInLast2Bins );
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Sets all pixels to MBadPixelsPix::kUnsuitableRun, if following flags are set:
+// - MBadPixelsPix::kLoGainSaturation
+//
+// Sets all pixels to MBadPixelsPix::kUnreliableRun, if following flags are set:
+// - if MBadPixelsPix::kHiGainNotFitted   and !MCalibrationPix::IsHiGainSaturation()
+// - if MBadPixelsPix::kHiGainOscillating and !MCalibrationPix::IsHiGainSaturation()
+// - if MBadPixelsPix::kLoGainNotFitted   and  MCalibrationPix::IsLoGainSaturation()
+// - if MBadPixelsPix::kLoGainOscillating and  MCalibrationPix::IsLoGainSaturation()
+//
+void MHCalibrationChargeCam::FinalizeBadPixels()
+{
+      
+  for (Int_t i=0; i<fBadPixels->GetSize(); i++)
+    {
+      
+      MBadPixelsPix    &bad    = (*fBadPixels)[i];
+      MCalibrationPix  &pix    = (*fCam)[i];
+
+      if (bad.IsUncalibrated( MBadPixelsPix::kHiGainNotFitted ))
+        if (!pix.IsHiGainSaturation())
+          bad.SetUnsuitable(   MBadPixelsPix::kUnreliableRun    );
+ 
+      if (bad.IsUncalibrated( MBadPixelsPix::kHiGainOscillating ))
+        bad.SetUnsuitable(   MBadPixelsPix::kUnreliableRun    );
+
+      if (bad.IsUncalibrated( MBadPixelsPix::kLoGainNotFitted ))
+        if (pix.IsHiGainSaturation())
+          bad.SetUnsuitable(   MBadPixelsPix::kUnreliableRun    );
+ 
+      if (bad.IsUncalibrated( MBadPixelsPix::kLoGainOscillating ))
+        if (pix.IsHiGainSaturation())
+          bad.SetUnsuitable(   MBadPixelsPix::kUnreliableRun    );
+
+      if (bad.IsUncalibrated( MBadPixelsPix::kLoGainSaturation ))
+          bad.SetUnsuitable(   MBadPixelsPix::kUnsuitableRun    );
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Dummy, needed by MCamEvent
+//
+Bool_t MHCalibrationChargeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
+{
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calls MHGausEvents::DrawClone() for pixel idx
+//
+void MHCalibrationChargeCam::DrawPixelContent(Int_t idx) const
+{
+  (*this)[idx].DrawClone();
+}
+
+
+// -----------------------------------------------------------------------------
+// 
+// Default draw:
+//
+// Displays the averaged areas, both High Gain and Low Gain 
+//
+// Calls the Draw of the fAverageHiGainAreas and fAverageLoGainAreas objects with options
+//
+void MHCalibrationChargeCam::Draw(const Option_t *opt)
+{
+
+  const Int_t nareas = fAverageHiGainAreas->GetEntries();
+  if (nareas == 0)
+    return;
+
+  TString option(opt);
+  option.ToLower();
+
+  if (!option.Contains("datacheck"))
+    {
+      MHCalibrationCam::Draw(opt);
+      return;
+    }
+
+  // 
+  // From here on , the datacheck - Draw
+  //
+  TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);  
+  pad->SetBorderMode(0);
+
+  pad->Divide(2,nareas);
+
+  for (Int_t i=0; i<nareas;i++) 
+    {
+      pad->cd(2*(i+1)-1);
+      MHCalibrationChargePix &hipix = (MHCalibrationChargePix&)GetAverageHiGainArea(i);
+
+      if (i==0)
+        DrawDataCheckPixel(hipix,gkHiGainInnerRefLines);
+      else
+        DrawDataCheckPixel(hipix,gkHiGainOuterRefLines);
+
+      pad->cd(2*(i+1));
+
+      MHCalibrationChargePix &lopix = (MHCalibrationChargePix&)GetAverageLoGainArea(i);
+
+      if (i==0)
+        DrawDataCheckPixel(lopix,gkLoGainInnerRefLines);
+      else
+        DrawDataCheckPixel(lopix,gkLoGainOuterRefLines);
+
+    }      
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Our own clone function is necessary since root 3.01/06 or Mars 0.4
+// I don't know the reason. 
+//
+// Creates new MHCalibrationCam
+//
+TObject *MHCalibrationChargeCam::Clone(const char *) const
+{
+
+  const Int_t navhi = fAverageHiGainAreas->GetEntries();
+  const Int_t navlo = fAverageLoGainAreas->GetEntries();
+  const Int_t nsehi = fAverageHiGainSectors->GetEntries();
+  const Int_t nselo = fAverageLoGainSectors->GetEntries();
+  
+  //
+  // FIXME, this might be done faster and more elegant, by direct copy.
+  //
+  MHCalibrationChargeCam *cam = new MHCalibrationChargeCam();
+
+  cam->fAverageHiGainAreas->Expand(navhi);
+  cam->fAverageLoGainAreas->Expand(navlo);
+  cam->fAverageHiGainSectors->Expand(nsehi);
+  cam->fAverageLoGainSectors->Expand(nselo);
+
+  cam->fAverageHiGainAreas->Expand(navhi);
+  cam->fAverageLoGainAreas->Expand(navlo);
+  cam->fAverageHiGainSectors->Expand(nsehi);
+  cam->fAverageLoGainSectors->Expand(nselo);
+
+  for (int i=0; i<navhi; i++)
+    (*cam->fAverageHiGainAreas)[i] = (*fAverageHiGainAreas)[i]->Clone();
+  for (int i=0; i<navlo; i++)
+    (*cam->fAverageLoGainAreas)[i] = (*fAverageLoGainAreas)[i]->Clone();
+  for (int i=0; i<nsehi; i++)
+    (*cam->fAverageHiGainSectors)[i] = (*fAverageHiGainSectors)[i]->Clone();
+  for (int i=0; i<nselo; i++)
+    (*cam->fAverageLoGainSectors)[i] = (*fAverageLoGainSectors)[i]->Clone();
+
+  cam->fAverageAreaNum         = fAverageAreaNum;
+  cam->fAverageAreaSat         = fAverageAreaSat;
+  cam->fAverageAreaSigma       = fAverageAreaSigma;      
+  cam->fAverageAreaSigmaVar    = fAverageAreaSigmaVar;   
+  cam->fAverageAreaRelSigma    = fAverageAreaRelSigma;
+  cam->fAverageAreaRelSigmaVar = fAverageAreaRelSigmaVar;   
+  cam->fAverageSectorNum       = fAverageSectorNum;      
+  cam->fRunNumbers             = fRunNumbers;
+
+  cam->fPulserFrequency        = fPulserFrequency;
+  cam->fAverageNbins           = fAverageNbins;
+
+  return cam;
+
+}
+
+void MHCalibrationChargeCam::DrawDataCheckPixel(MHCalibrationChargePix &pix, const Float_t refline[])
+{
+  
+  TVirtualPad *newpad = gPad;
+  newpad->Divide(1,2);
+  newpad->cd(1);
+  
+  gPad->SetTicks();
+  if (!pix.IsEmpty())
+    gPad->SetLogy();
+
+  gStyle->SetOptStat(0);
+
+  TH1F *hist = pix.GetHGausHist();
+  
+
+  TH2D *null = new TH2D("Null",hist->GetTitle(),100,pix.GetFirst(),pix.GetLast(),
+                        100,0.,hist->GetEntries()/10.);
+
+  null->SetDirectory(NULL);
+  null->SetBit(kCanDelete);
+  null->GetXaxis()->SetTitle(hist->GetXaxis()->GetTitle());
+  null->GetYaxis()->SetTitle(hist->GetYaxis()->GetTitle());  
+  null->GetXaxis()->CenterTitle();
+  null->GetYaxis()->CenterTitle();
+  null->Draw();
+  hist->Draw("same");
+
+  gStyle->SetOptFit();
+
+  if (pix.GetFGausFit())
+  {
+      pix.GetFGausFit()->SetLineColor(pix.IsGausFitOK() ? kGreen : kRed);
+      pix.GetFGausFit()->Draw("same");
+  }
+
+  DisplayRefLines(null,refline);
+
+
+  newpad->cd(2);
+  gPad->SetTicks();
+
+  pix.DrawEvents();
+  return;
+  
+}
+
+
+void  MHCalibrationChargeCam::DisplayRefLines(const TH2D *hist, const Float_t refline[]) const
+{
+
+  TLine *green1 = new TLine(refline[0],0.,refline[0],hist->GetYaxis()->GetXmax());
+  green1->SetBit(kCanDelete);
+  green1->SetLineColor(kGreen);
+  green1->SetLineStyle(2);
+  green1->SetLineWidth(3);
+  green1->Draw();
+
+  TLine *green5 = new TLine(refline[6],0.,refline[6],hist->GetYaxis()->GetXmax());
+  green5->SetBit(kCanDelete);
+  green5->SetLineColor(8);
+  green5->SetLineStyle(2);
+  green5->SetLineWidth(3);
+  green5->Draw();
+
+  TLine *blue1   = new TLine(refline[1],0.,refline[1],hist->GetYaxis()->GetXmax());
+  blue1->SetBit(kCanDelete);
+  blue1->SetLineColor(007);
+  blue1->SetLineStyle(2);
+  blue1->SetLineWidth(3);
+  blue1->Draw();
+
+  TLine *blue5   = new TLine(refline[2],0.,refline[2],hist->GetYaxis()->GetXmax());
+  blue5->SetBit(kCanDelete);
+  blue5->SetLineColor(062);
+  blue5->SetLineStyle(2);
+  blue5->SetLineWidth(3);
+  blue5->Draw();
+
+  TLine *blue10   = new TLine(refline[3],0.,refline[3],hist->GetYaxis()->GetXmax());
+  blue10->SetBit(kCanDelete);
+  blue10->SetLineColor(004);
+  blue10->SetLineStyle(2);
+  blue10->SetLineWidth(3);
+  blue10->Draw();
+
+  TLine *uv10    = new TLine(refline[4],0.,refline[4],hist->GetYaxis()->GetXmax());
+  uv10->SetBit(kCanDelete);
+  uv10->SetLineColor(106);
+  uv10->SetLineStyle(2);
+  uv10->SetLineWidth(3);
+  uv10->Draw();
+
+  TLine *ct1    = new TLine(refline[5],0.,refline[5],hist->GetYaxis()->GetXmax());
+  ct1->SetBit(kCanDelete);
+  ct1->SetLineColor(006);
+  ct1->SetLineStyle(2);
+  ct1->SetLineWidth(3);
+  ct1->Draw();
+
+  TLegend *leg = new TLegend(0.4,0.75,0.7,0.99);
+  leg->SetBit(kCanDelete);
+  leg->AddEntry(green1,"1 Led GREEN","l");
+  leg->AddEntry(green5,"5 Leds GREEN","l");
+  leg->AddEntry(blue1,"1 Led BLUE","l");
+  leg->AddEntry(blue5,"5 Leds BLUE","l");
+  leg->AddEntry(blue10,"10 Leds BLUE","l");
+  leg->AddEntry(uv10,"10 Leds UV","l");
+  leg->AddEntry(ct1,"CT1-Pulser","l");
+
+  leg->Draw();
+}
Index: /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargeCam.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargeCam.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargeCam.h	(revision 9661)
@@ -0,0 +1,80 @@
+#ifndef MARS_MHCalibrationChargeCam
+#define MARS_MHCalibrationChargeCam
+
+#ifndef MARS_MHCalibrationCam
+#include "MHCalibrationCam.h"
+#endif
+
+#ifndef ROOT_TArrayF
+#include "TArrayF.h"
+#endif
+
+class TH2D;
+class MRawEvtData;
+class MExtractedSignalCam;
+class MCalibrationChargePix;
+class MHCalibrationChargePix;
+class MHCalibrationChargeCam : public MHCalibrationCam
+{
+private:
+
+  static const Float_t fgNumHiGainSaturationLimit;   //! The default for fNumHiGainSaturationLimit (now at: 0.01)
+  static const Float_t fgNumLoGainSaturationLimit;   //! The default for fNumLoGainSaturationLimit (now at: 0.005)
+  static const Float_t fgTimeLowerLimit;             //! Default for fTimeLowerLimit    (now set to: 1.) 
+  static const Float_t fgTimeUpperLimit;             //! Default for fTimeUpperLimit    (now set to: 2.)
+  
+  static const Float_t gkHiGainInnerRefLines[7];
+  static const Float_t gkHiGainOuterRefLines[7];
+  static const Float_t gkLoGainInnerRefLines[7];
+  static const Float_t gkLoGainOuterRefLines[7];
+  
+  Float_t fTimeLowerLimit;            // Limit dist. to first signal slice (in units of FADC slices) 
+  Float_t fTimeUpperLimit;            // Limit dist. to last signal slice  (in units of FADC slices) 
+  Byte_t  fFirstHiGain;               // First used slice High Gain 
+  Byte_t  fLastHiGain;                // Last used slice High Gain
+  Byte_t  fFirstLoGain;               // First used slice Low Gain
+  Byte_t  fLastLoGain;                // Last used slice Low Gain
+  
+  MRawEvtData         *fRawEvt;       //!  Raw event data 
+
+  Bool_t SetupHists(const MParList *pList);
+  Bool_t ReInitHists(MParList *pList);
+  Bool_t FillHists(const MParContainer *par, const Stat_t w=1);
+
+  void   FinalizeAbsTimes (MHCalibrationChargePix &hist, MCalibrationChargePix &pix, MBadPixelsPix &bad,
+                           Byte_t first, Byte_t last);  
+  Bool_t FinalizeHists();
+  void   FinalizeBadPixels();
+
+  void   DrawDataCheckPixel(MHCalibrationChargePix &pix, const Float_t refline[]);
+  void   DisplayRefLines(const TH2D *hist, const Float_t refline[]) const;
+  
+public:
+
+  MHCalibrationChargeCam(const char *name=NULL, const char *title=NULL);
+  ~MHCalibrationChargeCam() {}
+  
+  TObject *Clone(const char *) const;
+
+  void SetTimeLowerLimit    ( const Float_t f=fgTimeLowerLimit         ) { fTimeLowerLimit    = f;   }
+  void SetTimeUpperLimit    ( const Float_t f=fgTimeUpperLimit         ) { fTimeUpperLimit    = f;   }
+  
+  Bool_t GetPixelContent ( Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
+  void   DrawPixelContent( Int_t num )  const;    
+
+  // Draw
+  void   Draw(const Option_t *opt);
+
+  ClassDef(MHCalibrationChargeCam, 1)	// Histogram class for Charge Camera Calibration 
+};
+
+#endif
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargeHiGainPix.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargeHiGainPix.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargeHiGainPix.cc	(revision 9661)
@@ -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): Markus Gaug 02/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MHCalibrationChargeHiGainPix
+//
+//  Histogram class for the charge High Gain FADC calibration. 
+//  Stores and fits the charges and stores the location of the maximum FADC 
+//  slice. Charges are taken from MExtractedSignalPix.
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MHCalibrationChargeHiGainPix.h"
+
+#include <TH1.h>
+
+ClassImp(MHCalibrationChargeHiGainPix);
+
+using namespace std;
+
+const Int_t   MHCalibrationChargeHiGainPix::fgChargeNbins     = 800;
+const Axis_t  MHCalibrationChargeHiGainPix::fgChargeFirst     = -5.5;
+const Axis_t  MHCalibrationChargeHiGainPix::fgChargeLast      = 794.5;
+const Int_t   MHCalibrationChargeHiGainPix::fgAbsTimeNbins    = 20;
+const Axis_t  MHCalibrationChargeHiGainPix::fgAbsTimeFirst    = -0.5;
+const Axis_t  MHCalibrationChargeHiGainPix::fgAbsTimeLast     = 19.5;
+// --------------------------------------------------------------------------
+//
+// Default Constructor. 
+//
+// Sets: 
+// - the default number for fNbins        (fgChargeNbins)
+// - the default number for fFirst        (fgChargeFirst)
+// - the default number for fLast         (fgChargeLast)
+// - the default number for fAbsTimeNbins (fgAbstTimeNbins)
+// - the default number for fAbsTimeFirst (fgAbsTimeFirst)
+// - the default number for fAbsTimeLast  (fgAbsTimeLast)
+//
+// - the default name of the  fHGausHist ("HCalibrationChargeHiGainPix")
+// - the default title of the fHGausHist ("Distribution of Summed Hi Gain FADC slices Pixel ")
+//
+// - the default name of the  fHAbsTime ("HAbsTimeHiGainPix")
+// - the default title of the fHAbsTime ("Distribution of Absolute Arrival Times Hi Gain Pixel ")
+//
+MHCalibrationChargeHiGainPix::MHCalibrationChargeHiGainPix(const char *name, const char *title)
+{
+
+  fName  = name  ? name  : "MHCalibrationChargeHiGainPix";
+  fTitle = title ? title : "Fill the FADC sums of the HiGainPix events and perform the fits Pixel ";
+  
+  SetNbins ( fgChargeNbins );
+  SetFirst ( fgChargeFirst );
+  SetLast  ( fgChargeLast  );
+  
+  SetAbsTimeNbins();
+  SetAbsTimeFirst();
+  SetAbsTimeLast();
+
+  fHGausHist.SetName ("HCalibrationChargeHiGainPix");
+  fHGausHist.SetTitle("Distribution of Summed Hi Gain FADC slices Pixel ");  
+
+  fHAbsTime.SetName ("HAbsTimeHiGainPix");
+  fHAbsTime.SetTitle("Distribution of Absolute Arrival Times Hi Gain Pixel ");  
+}
Index: /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargeHiGainPix.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargeHiGainPix.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargeHiGainPix.h	(revision 9661)
@@ -0,0 +1,40 @@
+#ifndef MARS_MHCalibrationChargeHiGainPix
+#define MARS_MHCalibrationChargeHiGainPix
+
+
+#ifndef MARS_MHCalibrationChargePix
+#include "MHCalibrationChargePix.h"
+#endif
+
+class TH1F;
+class MHCalibrationChargeHiGainPix : public MHCalibrationChargePix
+{
+private:
+
+  static const Int_t   fgChargeNbins;     // Default for fNbins        (now set to: 2000  )
+  static const Axis_t  fgChargeFirst;     // Default for fFirst        (now set to: -0.5  )
+  static const Axis_t  fgChargeLast;      // Default for fLast         (now set to: 1999.5)
+  static const Int_t   fgAbsTimeNbins;    // Default for fAbsTimeNbins (now set to: 20    )
+  static const Axis_t  fgAbsTimeFirst;    // Default for fAbsTimeFirst (now set to: -0.5  )
+  static const Axis_t  fgAbsTimeLast;     // Default for fAbsTimeLast  (now set to: 19.5  )
+
+public:
+
+  MHCalibrationChargeHiGainPix(const char *name=NULL, const char *title=NULL);
+  ~MHCalibrationChargeHiGainPix(){}
+
+  // Setters
+  void SetAbsTimeNbins(const Int_t  bins =fgAbsTimeNbins)        { fAbsTimeNbins = bins;    }
+  void SetAbsTimeFirst(const Axis_t first=fgAbsTimeFirst)        { fAbsTimeFirst = first;   }
+  void SetAbsTimeLast (const Axis_t last =fgAbsTimeLast)         { fAbsTimeLast  = last;    }
+
+  ClassDef(MHCalibrationChargeHiGainPix, 1)  // Histogram class for Charge High Gain Pixel Calibration 
+};
+
+#endif
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargeLoGainPix.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargeLoGainPix.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargeLoGainPix.cc	(revision 9661)
@@ -0,0 +1,92 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug 02/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MHCalibrationChargeLoGainPix
+//
+//  Histogram class for the charge Low Gain FADC calibration. 
+//  Stores and fits the charges and stores the location of the maximum FADC 
+//  slice. Charges are taken from MExtractedSignalPix.
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MHCalibrationChargeLoGainPix.h"
+
+#include <TH1.h>
+
+ClassImp(MHCalibrationChargeLoGainPix);
+
+using namespace std;
+
+const Int_t   MHCalibrationChargeLoGainPix::fgChargeNbins     = 350;
+const Axis_t  MHCalibrationChargeLoGainPix::fgChargeFirst     = -15.5;
+const Axis_t  MHCalibrationChargeLoGainPix::fgChargeLast      = 334.5;
+const Int_t   MHCalibrationChargeLoGainPix::fgAbsTimeNbins    = 15;
+const Axis_t  MHCalibrationChargeLoGainPix::fgAbsTimeFirst    = -0.5;
+const Axis_t  MHCalibrationChargeLoGainPix::fgAbsTimeLast     = 14.5;
+// --------------------------------------------------------------------------
+//
+// Default Constructor. 
+//
+// Sets: 
+// - the default number for fNbins        (fgChargeNbins)
+// - the default number for fFirst        (fgChargeFirst)
+// - the default number for fLast         (fgChargeLast)
+// - the default number for fAbsTimeNbins (fgAbstTimeNbins)
+// - the default number for fAbsTimeFirst (fgAbsTimeFirst)
+// - the default number for fAbsTimeLast  (fgAbsTimeLast)
+//
+// - the default name of the  fHGausHist ("HCalibrationChargeLoGainPix")
+// - the default title of the fHGausHist ("Distribution of Summed Lo Gain FADC slices Pixel ")
+//
+// - the default name of the  fHAbsTime ("HAbsTimeLoGainPix")
+// - the default title of the fHAbsTime ("Distribution of Absolute Arrival Times Lo Gain Pixel ")
+//
+MHCalibrationChargeLoGainPix::MHCalibrationChargeLoGainPix(const char *name, const char *title)
+{
+
+  fName  = name  ? name  : "MHCalibrationChargeLoGainPix";
+  fTitle = title ? title : "Fill the FADC sums of the Low Gain events and perform the fits Pixel ";
+  
+  SetNbins ( fgChargeNbins );
+  SetFirst ( fgChargeFirst );
+  SetLast  ( fgChargeLast  );
+  
+  SetAbsTimeNbins();
+  SetAbsTimeFirst();
+  SetAbsTimeLast();
+
+  fHGausHist.SetName ("HCalibrationChargeLoGainPix");
+  fHGausHist.SetTitle("Distribution of Summed Lo Gain FADC slices Pixel ");  
+
+  fHAbsTime.SetName ("HAbsTimeLoGainPix");
+  fHAbsTime.SetTitle("Distribution of Absolute Arrival Times Lo Gain Pixel ");  
+
+}
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargeLoGainPix.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargeLoGainPix.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargeLoGainPix.h	(revision 9661)
@@ -0,0 +1,41 @@
+#ifndef MARS_MHCalibrationChargeLoGainPix
+#define MARS_MHCalibrationChargeLoGainPix
+
+
+#ifndef MARS_MHCalibrationChargePix
+#include "MHCalibrationChargePix.h"
+#endif
+
+class MHCalibrationChargeLoGainPix : public MHCalibrationChargePix
+{
+private:
+
+  static const Int_t   fgChargeNbins;      // Default for fNbins        (now set to: 200   )
+  static const Axis_t  fgChargeFirst;      // Default for fFirst        (now set to: -0.5  )
+  static const Axis_t  fgChargeLast;       // Default for fLast         (now set to: 199.5 )
+  static const Int_t   fgAbsTimeNbins;     // Default for fAbsTimeNbins (now set to: 15    )
+  static const Axis_t  fgAbsTimeFirst;     // Default for fAbsTimeFirst (now set to: -0.5  )
+  static const Axis_t  fgAbsTimeLast;      // Default for fAbsTimeLast  (now set to: 14.5  )
+
+public:
+
+  MHCalibrationChargeLoGainPix(const char *name=NULL, const char *title=NULL);
+  ~MHCalibrationChargeLoGainPix(){}
+
+  // Setters
+  void SetAbsTimeNbins(const Int_t  bins =fgAbsTimeNbins)        { fAbsTimeNbins = bins;    }
+  void SetAbsTimeFirst(const Axis_t first=fgAbsTimeFirst)        { fAbsTimeFirst = first;   }
+  void SetAbsTimeLast (const Axis_t last =fgAbsTimeLast)         { fAbsTimeLast  = last;    }
+
+  ClassDef(MHCalibrationChargeLoGainPix, 1)  // Histogram class for Charge Low Gain Pixel Calibration
+};
+
+#endif
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargePINDiode.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargePINDiode.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargePINDiode.cc	(revision 9661)
@@ -0,0 +1,396 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug 02/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MHCalibrationChargePINDiode
+//
+//  Histogram class for the charge calibration of the PIN Diode. 
+//  Stores and fits the charges, the RMS of the charges  and stores the 
+//  location of the maximum FADC slice. Charges are taken from MExtractedSignalPINDiode.
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MHCalibrationChargePINDiode.h"
+
+#include <TH1.h>
+#include <TF1.h>
+#include <TPad.h>
+#include <TVirtualPad.h>
+#include <TCanvas.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MExtractedSignalPINDiode.h"
+#include "MCalibrationChargePINDiode.h"
+
+ClassImp(MHCalibrationChargePINDiode);
+
+using namespace std;
+
+const Axis_t  MHCalibrationChargePINDiode::fgAbsTimeFirst    = -0.5;
+const Axis_t  MHCalibrationChargePINDiode::fgAbsTimeLast     = 29.5;
+const Int_t   MHCalibrationChargePINDiode::fgAbsTimeNbins    = 30;
+const Axis_t  MHCalibrationChargePINDiode::fgChargeFirst     = -0.5;
+const Axis_t  MHCalibrationChargePINDiode::fgChargeLast      = 1999.5;
+const Int_t   MHCalibrationChargePINDiode::fgChargeNbins     = 2000;
+const Int_t   MHCalibrationChargePINDiode::fgRmsChargeNbins  = 200;
+const Axis_t  MHCalibrationChargePINDiode::fgRmsChargeFirst  = 0.;
+const Axis_t  MHCalibrationChargePINDiode::fgRmsChargeLast   = 200.;  
+const Float_t MHCalibrationChargePINDiode::fgTimeLowerLimit  = 3.;
+const Float_t MHCalibrationChargePINDiode::fgTimeUpperLimit  = 4.;
+// --------------------------------------------------------------------------
+//
+// Default Constructor. 
+//
+// Sets: 
+// - the default number for fAbsTimeFirst        (fgAbsTimeFirst)
+// - the default number for fAbsTimeLast         (fgAbsTimeLast)
+// - the default number for fAbsTimeNbins        (fgAbsTimeNbins)
+// - the default number for MHGausEvents::fNbins (fgChargeNbins)
+// - the default number for MHGausEvents::fFirst (fgChargeFirst)
+// - the default number for MHGausEvents::fLast  (fgChargeLast)
+// - the default number for fRmsChargeNbins      (fgRmsChargeNbins)
+// - the default number for fRmsChargeFirst      (fgRmsChargeFirst)
+// - the default number for fRmsChargeLast       (fgRmsChargeLast)
+// - the default number for fTimeLowerLimit      (fgTimeLowerLimit)
+// - the default number for fTimeUpperLimit      (fgTimeUpperLimit)
+//
+// - the default name of the  fHGausHist      ("HCalibrationChargePINDiode")
+// - the default title of the fHGausHist      ("Distribution of Summed FADC slices PIN Diode")
+// - the default x-axis title for fHGausHist  ("Sum FADC Slices")
+// - the default y-axis title for fHGausHist  ("Nr. of events")
+// - the default name of the  fHAbsTime       ("HAbsTimePINDiode")
+// - the default title of the fHAbsTime       ("Distribution of Absolute Arrival Times PIN Diode")
+// - the default x-axis title for fHAbsTime   ("Absolute Arrival Time [FADC slice nr]")
+// - the default y-axis title for fHAbsTime   ("Nr. of events")
+// - the default name of the  fHRmsCharge     ("HRmsChargePINDiode")
+// - the default title of the fHRmsCharge     ("Distribution of Variances of summed FADC slices PIN Diode")
+// - the default x-axis title for fHRmsCharge ("RMS (sum) [FADC slices]")
+// - the default y-axis title for fHRmsCharge ("Nr. of events")
+// - the default directory of the fHRmsCharge (NULL)
+// - the current style for fHRmsCharge (NULL)
+//
+// Initializes:
+// - fHRmsCharge()
+// - all pointers to NULL
+//
+// Calls:
+// - Clear()
+//
+MHCalibrationChargePINDiode::MHCalibrationChargePINDiode(const char *name, const char *title)
+    : fPINDiode(NULL), fSigPIN(NULL), fHRmsCharge()
+{
+
+  fName  = name  ? name  : "MHCalibrationChargePINDiode";
+  fTitle = title ? title : "Fill the FADC sums of the PINDiode events and perform the fits";
+  
+  SetAbsTimeFirst();
+  SetAbsTimeLast();
+  SetAbsTimeNbins();
+
+  SetNbins( fgChargeNbins );
+  SetFirst( fgChargeFirst );
+  SetLast ( fgChargeLast  );
+  
+  SetRmsChargeNbins();
+  SetRmsChargeFirst();
+  SetRmsChargeLast();
+  
+  SetTimeLowerLimit();
+  SetTimeUpperLimit();
+
+  fHGausHist.SetName("HCalibrationChargePINDiode");
+  fHGausHist.SetTitle("Distribution of Summed FADC slices PIN Diode");  
+  fHGausHist.SetXTitle("Sum FADC Slices");
+  fHGausHist.SetYTitle("Nr. of events");
+
+  fHAbsTime.SetName("HAbsTimePINDiode");
+  fHAbsTime.SetTitle("Distribution of Absolute Arrival Times PIN Diode");  
+  fHAbsTime.SetXTitle("Absolute Arrival Time [FADC slice nr]");
+  fHAbsTime.SetYTitle("Nr. of events");
+
+  fHRmsCharge.SetName("HRmsChargePINDiode");
+  fHRmsCharge.SetTitle("Distribution of Variances of summed FADC slices PIN Diode");  
+  fHRmsCharge.SetXTitle("RMS (sum) [FADC slices]");
+  fHRmsCharge.SetYTitle("Nr. of events");
+  fHRmsCharge.UseCurrentStyle();
+  fHRmsCharge.SetDirectory(NULL); 
+
+  Clear();
+}
+
+// --------------------------------------------------------------------------
+//
+// Initializes Binning of the following histograms:
+// - fHGausHist.SetBins(fNbins,fFirst,fLast);
+// - fHAbsTime.SetBins(fAbsTimeNbins,fAbsTimeFirst,fAbsTimeLast);
+// - fHRmsCharge.SetBins(fRmsChargeNbins,fRmsChargeFirst,fRmsChargeLast);
+//
+Bool_t MHCalibrationChargePINDiode::SetupFill(const MParList *pList) 
+{
+
+  MHGausEvents::InitBins();
+
+  fHAbsTime.  SetBins(fAbsTimeNbins,  fAbsTimeFirst,  fAbsTimeLast);
+  fHRmsCharge.SetBins(fRmsChargeNbins,fRmsChargeFirst,fRmsChargeLast);
+
+  return kTRUE;
+
+}
+
+// --------------------------------------------------------------------------
+//
+// Gets or creates the pointers to:
+// - MExtractedSignalPINDiode
+// - MCalibrationChargePINDiode
+//
+Bool_t MHCalibrationChargePINDiode::ReInit(MParList *pList)
+{
+  
+  fSigPIN = (MExtractedSignalPINDiode*)pList->FindCreateObj("MExtractedSignalPINDiode");
+  if (!fSigPIN)
+  {
+      *fLog << err << "MExtractedSignalPINDiode not found... aborting " << endl;
+      return kFALSE;
+  }
+
+  fPINDiode = (MCalibrationChargePINDiode*)pList->FindCreateObj("MCalibrationChargePINDiode");
+  if (!fPINDiode)
+  {
+      *fLog << err << "MCalibrationChargePINDiode not found... aborting " << endl;
+      return kFALSE;
+  }
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Retrieves from MExtractedSignalPINDiode:
+// - Number of used FADC samples via MExtractedSignalPINDiode::GetNumFADCSamples()
+// - Extracted signal via            MExtractedSignalPINDiode::GetExtractedSignal()
+// - Signal Rms                      MExtractedSignalPINDiode::GetExtractedRms()
+// - Arrival Time                    MExtractedSignalPINDiode::GetExtractedTime()
+//
+// Fills the following histograms:
+// - MHGausEvents::FillHistAndArray(signal)
+// - MHCalibrationChargePix::FillAbsTime(time);
+// - FillRmsCharge(rms);
+//
+Bool_t MHCalibrationChargePINDiode::Fill(const MParContainer *par, const Stat_t w)
+{
+
+  MExtractedSignalPINDiode *extractor = (MExtractedSignalPINDiode*)par;
+  
+  if (!extractor)
+    {
+      *fLog << err << "No argument in MExtractedSignalPINDiode::Fill... abort." << endl;
+      return kFALSE;
+    }
+  
+  Float_t slices = (Float_t)extractor->GetNumFADCSamples();
+  
+  if (slices == 0.)
+    {
+      *fLog << err << "Number of used signal slices in MExtractedSignalPINDiode is zero  ... abort." 
+            << endl;
+      return kFALSE;
+    }
+  
+  const Float_t signal = (float)extractor->GetExtractedSignal();
+  const Float_t time   = extractor->GetExtractedTime();
+  const Float_t rms    = extractor->GetExtractedRms();
+
+  FillHistAndArray(signal);
+  FillAbsTime(time);
+  FillRmsCharge(rms);
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns kTRUE, if empty
+//
+// Performs the following fits:
+// - MHGausEvents::FitGaus()
+// - FitRmsCharge()
+//
+// Creates the fourier spectrum (MHGausEvents::CreateFourierSpectrum() 
+// and sets bit MCalibrationChargePINDiode::SetOscillating( MHGausEvents::IsFourierSpectrumOK() )
+// Retrieves the results of the following fits and stores them in MCalibrationChargePINDiode:
+// - Mean Charge and Error 
+// - Sigma Charge and Error
+// - Fit Probability
+// - Abs Time Mean
+// - Abs Time Rms
+// - Rms Charge Mean and Error
+// - Rms Charge Sigma and Error
+// 
+// Performs one consistency check on the arrival time: 
+// The check returns kFALSE if:
+//
+// -The mean arrival time is in fTimeLowerLimit slices from the lower edge 
+//  and fUpperLimit slices from the upper edge
+//
+Bool_t MHCalibrationChargePINDiode::Finalize() 
+{
+  
+  if (IsGausFitOK() || IsEmpty())
+    return kTRUE;
+    
+  FitGaus();
+  FitRmsCharge();
+
+  CreateFourierSpectrum();
+  fPINDiode->SetOscillating  ( !IsFourierSpectrumOK() );
+
+  fPINDiode->SetMean     (  fMean     );
+  fPINDiode->SetMeanVar  (  fMeanErr  * fMeanErr );
+  fPINDiode->SetSigma    (  fSigma    );
+  fPINDiode->SetSigmaVar (  fSigmaErr * fMeanErr );
+  fPINDiode->SetProb     (  fProb     );
+
+  fPINDiode->SetAbsTimeMean(    GetAbsTimeMean() );
+  fPINDiode->SetAbsTimeRms(     GetAbsTimeRms()  );
+
+  fPINDiode->SetRmsChargeMean(     GetRmsChargeMean()        );
+  fPINDiode->SetRmsChargeMeanErr(  GetRmsChargeMeanErr()     );
+  fPINDiode->SetRmsChargeSigma(    GetRmsChargeSigma()       );
+  fPINDiode->SetRmsChargeSigmaErr( GetRmsChargeSigmaErr()    );
+
+  fPINDiode->SetValid(kTRUE);
+
+  const Byte_t  loweredge  = fSigPIN->GetFirstUsedSlice();
+  const Byte_t  upperedge  = fSigPIN->GetLastUsedSlice();
+  const Float_t lowerlimit = (Float_t)loweredge + fTimeLowerLimit;
+  const Float_t upperlimit = (Float_t)upperedge + fTimeUpperLimit;  
+
+  if (GetAbsTimeMean() < lowerlimit)
+    {
+      *fLog << warn << GetDescriptor() 
+            << Form("%s%3.1f%s%2.1f%s",": Mean ArrivalTime: ",GetAbsTimeMean()," smaller than ",
+                    lowerlimit," FADC slices from lower edge in PIN Diode") << endl;
+      *fLog << warn << GetDescriptor() << ": No PIN Diode calibration!! " << endl;
+      fPINDiode->SetValid(kFALSE);
+    }
+  
+  if ( GetAbsTimeMean() > upperlimit )
+    {
+      *fLog << warn << GetDescriptor() 
+            << Form("%s%3.1f%s%2.1f%s",": Mean ArrivalTime: ",GetAbsTimeMean()," bigger than ",
+                    upperlimit," FADC slices from upper edge in PIN Diode") << endl;
+      *fLog << warn << GetDescriptor() << ": No PIN Diode calibration!! " << endl;
+      fPINDiode->SetValid(kFALSE);
+    }
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fills fHRmsCharge with q
+// Returns kFALSE, if overflow or underflow occurred, else kTRUE
+//
+Bool_t MHCalibrationChargePINDiode::FillRmsCharge(const Float_t q)
+{
+  return fHRmsCharge.Fill(q) > -1;
+}
+
+// -----------------------------------------------------------
+//
+// Fits -- not yet implemented
+//
+Bool_t MHCalibrationChargePINDiode::FitRmsCharge(Option_t *option)
+{
+  return 1;
+}
+
+
+// -------------------------------------------------------------------------
+//
+// Draw the histogram
+//
+// The following options can be chosen:
+//
+// "": displays the fHGausHist with fits and fHRmsCharge
+// "all": executes additionally MHGausEvents::Draw(), with option "fourierevents"
+//
+void MHCalibrationChargePINDiode::Draw(const Option_t *opt)
+{
+
+  TString option(opt);
+  option.ToLower();
+  
+  Int_t win = 1;
+
+  TVirtualPad *oldpad = gPad ? gPad : MH::MakeDefCanvas(this,900, 600);
+  TVirtualPad *pad    = NULL;
+
+  oldpad->SetBorderMode(0);
+    
+  if (option.Contains("all"))
+  {
+      option.ReplaceAll("all","");
+      oldpad->Divide(2,1);
+      win = 2;
+      oldpad->cd(1);
+      TVirtualPad *newpad = gPad;
+      pad = newpad;
+      pad->Divide(1,2);
+      pad->cd(1);
+  }
+  else
+  {
+      pad = oldpad;
+      pad->Divide(1,2);
+      pad->cd(1);
+  }
+
+  if (IsEmpty())
+    return;
+
+  gPad->SetLogy();
+  gPad->SetTicks();
+
+  fHGausHist.Draw(opt); 
+  if (fFGausFit)
+  {
+      fFGausFit->SetLineColor(IsGausFitOK() ? kGreen : kRed);
+      fFGausFit->Draw("same");
+  }
+
+  pad->cd(2);
+  fHRmsCharge.Draw(opt);
+
+  oldpad->cd(2);
+  MHGausEvents::Draw("fourierevents");
+}
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargePINDiode.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargePINDiode.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargePINDiode.h	(revision 9661)
@@ -0,0 +1,84 @@
+#ifndef MARS_MHCalibrationChargePINDiode
+#define MARS_MHCalibrationChargePINDiode
+
+
+#ifndef MARS_MHCalibrationChargePix
+#include "MHCalibrationChargePix.h"
+#endif
+
+class TH1F;
+class MExtractedSignalPINDiode;
+class MCalibrationChargePINDiode;
+class MHCalibrationChargePINDiode : public MHCalibrationChargePix
+{
+private:
+
+  static const Axis_t  fgAbsTimeFirst;    //! Default for fAbsTimeFirst    (now set to: -0.5  )
+  static const Axis_t  fgAbsTimeLast;     //! Default for fAbsTimeLast     (now set to: 29.5  )
+  static const Int_t   fgAbsTimeNbins;    //! Default for fAbsTimeNBins    (now set to: 30    )
+  static const Int_t   fgChargeNbins;     //! Default for fNBins           (now set to: 200   )
+  static const Axis_t  fgChargeFirst;     //! Default for fFirst           (now set to: -0.5  )
+  static const Axis_t  fgChargeLast;      //! Default for fLast            (now set to: 199.5 )
+  static const Int_t   fgRmsChargeNbins;  //! Default for fRmsChargeNBins  (now set to: 100   )
+  static const Axis_t  fgRmsChargeFirst;  //! Default for fRmsChargeFirst  (now set to: 0.    )
+  static const Axis_t  fgRmsChargeLast;   //! Default for fRmsChargeLast   (now set to: 100.  )
+  static const Float_t fgTimeLowerLimit;  //! Default for fTimeLowerLimit    (now set to: 1.) 
+  static const Float_t fgTimeUpperLimit;  //! Default for fTimeUpperLimit    (now set to: 2.)
+  
+  MCalibrationChargePINDiode *fPINDiode;  //! Storage container of the results
+  MExtractedSignalPINDiode   *fSigPIN;    //! Storage container of extracted signal
+
+  TH1F fHRmsCharge;                       //  Histogram containing Variance of summed FADC slices
+
+  Axis_t  fRmsChargeFirst;                //  Lower bound bin used for the fHRmsCharge
+  Axis_t  fRmsChargeLast;                 //  Upper bound bin used for the fHRmsCharge
+  Int_t   fRmsChargeNbins;                //  Number of  bins used for the fHRmsCharge
+  Float_t fRmsChargeMean;                 //  Mean of the Gauss fit               
+  Float_t fRmsChargeMeanErr;              //  Error of the mean of the Gauss fit 
+  Float_t fRmsChargeSigma;                //  Sigma of the Gauss fit             
+  Float_t fRmsChargeSigmaErr;             //  Error of the sigma of the Gauss fit
+  Float_t fTimeLowerLimit;                //  Limit dist. to first signal slice (units: FADC slices) 
+  Float_t fTimeUpperLimit;                //  Limit dist. to last signal slice  (units: FADC slices) 
+  
+public:
+
+  MHCalibrationChargePINDiode(const char *name=NULL, const char *title=NULL);
+  ~MHCalibrationChargePINDiode(){}
+
+  Bool_t SetupFill(const MParList *pList);
+  Bool_t ReInit   (      MParList *pList);
+  Bool_t Fill     (const MParContainer *par, const Stat_t w=1);
+  Bool_t Finalize ();
+  
+  // Draw
+  void Draw(Option_t *opt="");
+  
+  // Getters
+        TH1F *GetHRmsCharge()                  { return &fHRmsCharge;       }
+  const TH1F *GetHRmsCharge()            const { return &fHRmsCharge;       }
+  Float_t     GetRmsChargeMean()         const { return fRmsChargeMean;     }
+  Float_t     GetRmsChargeMeanErr()      const { return fRmsChargeMeanErr;  }
+  Float_t     GetRmsChargeSigma()        const { return fRmsChargeSigma;    }
+  Float_t     GetRmsChargeSigmaErr()     const { return fRmsChargeSigmaErr; }
+
+  // Fill histos
+  Bool_t FillRmsCharge(const Float_t q);
+
+  // Fits
+  Bool_t FitRmsCharge(Option_t *option="RQ0");
+
+  // Setters
+  void SetAbsTimeNbins   ( const Int_t   bins =fgAbsTimeNbins   ) { fAbsTimeNbins   = bins;  }
+  void SetAbsTimeFirst   ( const Axis_t  first=fgAbsTimeFirst   ) { fAbsTimeFirst   = first; }
+  void SetAbsTimeLast    ( const Axis_t  last =fgAbsTimeLast    ) { fAbsTimeLast    = last;  }
+  void SetRmsChargeNbins ( const Int_t   bins =fgRmsChargeNbins ) { fRmsChargeNbins = bins;  }
+  void SetRmsChargeFirst ( const Axis_t  first=fgRmsChargeFirst ) { fRmsChargeFirst = first; }
+  void SetRmsChargeLast  ( const Axis_t  last =fgRmsChargeLast  ) { fRmsChargeLast  = last;  }
+  void SetTimeLowerLimit ( const Float_t f=fgTimeLowerLimit     ) { fTimeLowerLimit = f;     }
+  void SetTimeUpperLimit ( const Float_t f=fgTimeUpperLimit     ) { fTimeUpperLimit = f;     }
+
+  ClassDef(MHCalibrationChargePINDiode, 1)  // Histogram class for Charge PIN Diode Calibration 
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargePix.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargePix.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargePix.cc	(revision 9661)
@@ -0,0 +1,324 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug 02/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MHCalibrationChargePix
+//
+//  Histogram class for the charge calibration. 
+//  Stores and fits the charges and stores the location of the maximum FADC 
+//  slice. Charges are taken from MExtractedSignalPix.
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MHCalibrationChargePix.h"
+
+#include <TH1.h>
+#include <TF1.h>
+
+#include <TVirtualPad.h>
+#include <TCanvas.h>
+#include <TPad.h>
+#include <TGraph.h>
+
+#include "MH.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHCalibrationChargePix);
+
+using namespace std;
+
+const Int_t   MHCalibrationChargePix::fgChargeNbins     = 2000;
+const Axis_t  MHCalibrationChargePix::fgChargeFirst     = -0.5;
+const Axis_t  MHCalibrationChargePix::fgChargeLast      = 1999.5;
+const Int_t   MHCalibrationChargePix::fgAbsTimeNbins    = 15;
+const Axis_t  MHCalibrationChargePix::fgAbsTimeFirst    = -0.5;
+const Axis_t  MHCalibrationChargePix::fgAbsTimeLast     = 14.5;
+// --------------------------------------------------------------------------
+//
+// Default Constructor. 
+//
+// Sets: 
+// - the default number for fNbins        (fgChargeNbins)
+// - the default number for fFirst        (fgChargeFirst)
+// - the default number for fLast         (fgChargeLast)
+// - the default number for fAbsTimeNbins (fgAbsTimeNbins)
+// - the default number for fAbsTimeFirst (fgAbsTimeFirst)
+// - the default number for fAbsTimeLast  (fgAbsTimeLast)
+//
+// - the default name of the  fHGausHist ("HCalibrationCharge")
+// - the default title of the fHGausHist ("Distribution of Summed FADC slices Pixel ")
+// - the default x-axis title for fHGausHist ("Sum FADC Slices")
+// - the default y-axis title for fHGausHist ("Nr. of events")
+//
+// - the default name of the  fHAbsTime ("HAbsTimePixel")
+// - the default title of the fHAbsTime ("Distribution of Absolute Arrival Times Pixel ")
+// - the default x-axis title for fHAbsTime ("Absolute Arrival Time [FADC slice nr]")
+// - the default y-axis title for fHAbsTime ("Nr. of events"); 
+// - the default directory of the fHAbsTime (NULL)
+// - the current style for fHAbsTime
+//
+// Initializes:
+// - fHAbsTime()
+//
+// Calls:
+// - Clear();
+//
+MHCalibrationChargePix::MHCalibrationChargePix(const char *name, const char *title)
+    : fHAbsTime()
+{ 
+  
+  fName  = name  ? name  : "MHCalibrationChargePix";
+  fTitle = title ? title : "Statistics of the FADC sums of calibration events";
+
+  SetNbins ( fgChargeNbins );
+  SetFirst ( fgChargeFirst );
+  SetLast  ( fgChargeLast  );
+
+  SetAbsTimeNbins();
+  SetAbsTimeFirst();
+  SetAbsTimeLast();
+
+  fHGausHist.SetName("HCalibrationCharge");
+  fHGausHist.SetTitle("Distribution of Summed FADC slices Pixel");  
+  fHGausHist.SetXTitle("Sum FADC Slices");
+  fHGausHist.SetYTitle("Nr. of events");
+
+  fHAbsTime.SetName("HAbsTimePixel");
+  fHAbsTime.SetTitle("Distribution of Absolute Arrival Times Pixel ");  
+  fHAbsTime.SetXTitle("Absolute Arrival Time [FADC slice nr]");
+  fHAbsTime.SetYTitle("Nr. of events");
+
+  fHAbsTime.UseCurrentStyle();
+  fHAbsTime.SetDirectory(NULL); 
+
+  Clear();
+  
+}
+
+// --------------------------------------------------------------------------
+//
+// Sets:
+// - fHGausHist.SetBins(fNbins,fFirst,fLast);
+// - fHAbsTime.SetBins(fAbsTimeNbins,fAbsTimeFirst,fAbsTimeLast);
+//
+void MHCalibrationChargePix::InitBins()
+{
+  MHGausEvents::InitBins();
+  fHAbsTime.SetBins(fAbsTimeNbins,fAbsTimeFirst,fAbsTimeLast);
+}
+
+// --------------------------------------------------------------------------
+//
+// Sets:
+// - fSaturated to 0.
+// 
+// Executes:
+// - MHGausEvents::Clear()
+//
+void MHCalibrationChargePix::Clear(Option_t *o)
+{
+
+  fSaturated = 0.;
+
+  MHGausEvents::Clear();
+  return;
+}
+
+// --------------------------------------------------------------------------
+//
+// Empty function to overload MHGausEvents::Reset()
+//
+void MHCalibrationChargePix::Reset()
+{
+}
+
+// --------------------------------------------------------------------------
+//
+// Calls MHGausEvents::ChangeHistId()
+//
+// Add id to names and titles of: 
+// - fHAbsTime
+//
+void MHCalibrationChargePix::ChangeHistId(Int_t id)
+{
+
+  MHGausEvents::ChangeHistId(id);
+
+  fHAbsTime.SetName (Form("%s%d", fHAbsTime.GetName(),  id));
+  fHAbsTime.SetTitle(Form("%s%d", fHAbsTime.GetTitle(), id));
+
+}
+
+// --------------------------------------------------------------------------
+//
+// returns fHGausHist.Integral("width")
+//
+const Float_t MHCalibrationChargePix::GetIntegral() const 
+{ 
+   return fHGausHist.Integral("width");  
+}
+
+// --------------------------------------------------------------------------
+//
+// returns fHAbsTime.GetMean()
+//
+const Float_t MHCalibrationChargePix::GetAbsTimeMean() const 
+{
+  return fHAbsTime.GetMean();
+}
+
+// --------------------------------------------------------------------------
+//
+// returns fHAbsTime.GetRMS()
+//
+const Float_t MHCalibrationChargePix::GetAbsTimeRms()  const 
+{
+  return fHAbsTime.GetRMS();
+}
+
+// --------------------------------------------------------------------------
+//
+// Fills fHAbsTime with t
+// Returns kFALSE, if overflow or underflow occurred, else kTRUE
+//
+Bool_t MHCalibrationChargePix::FillAbsTime(Float_t t)
+{
+  return fHAbsTime.Fill(t) > -1;
+}
+
+// -----------------------------------------------------------------------------
+// 
+// Default draw:
+//
+// The following options can be chosen:
+//
+// "": displays the fHGausHist and the fHAbsTime
+// "all": executes additionally MHGausEvents::Draw(), with options
+//
+// The following picture shows a typical outcome of call to Draw("all"): 
+// One the left side:
+// - The distribution of the values with the Gauss fit are shown (points connected 
+//   with each other). The line is green, thus the Gauss fit has a probability higher 
+//   than 0.5%.
+// - The distribution of the positions of the maximum (abs. arrival times) 
+//   is displayed. Most of the events have an arrival time of slice 7 (==hardware:8)
+//
+// On the right side:
+// - The first plot shows the distribution of the values with the Gauss fit
+//   with error bars
+// - The second plot shows the TGraph with the events vs. time
+// - The third plot shows the fourier transform and a peak at 100 Hz.
+// - The fourth plot shows the projection of the fourier components and an exponential 
+//   fit, with the result that the observed deviation is not statistical, but signficant with a 
+//   probability smaller than 0.5%. 
+//
+//Begin_Html
+/*
+<img src="images/MHCalibrationChargePixDraw.gif">
+*/
+//End_Html
+//
+void MHCalibrationChargePix::Draw(const Option_t *opt)
+{
+
+  TString option(opt);
+  option.ToLower();
+  
+  Int_t win = 1;
+  
+  TVirtualPad *oldpad = gPad ? gPad : MH::MakeDefCanvas(this,600, 600);
+  TVirtualPad *pad    = NULL;
+
+  if (option.Contains("all"))
+  {
+      option.ReplaceAll("all","");
+      oldpad->Divide(2,1);
+      win = 2;
+      oldpad->cd(1);
+      TVirtualPad *newpad = gPad;
+      pad = newpad;
+      pad->Divide(1,2);
+      pad->cd(1);
+  }
+  else if (option.Contains("datacheck"))
+    {
+      MHGausEvents::Draw("events");
+      return;
+    }
+  else 
+  {
+      pad = oldpad;
+      pad->Divide(1,2);
+      pad->cd(1);
+  }
+  /*
+  else
+    {
+      option.ReplaceAll("time","");
+      pad = oldpad;
+      pad->Divide(1,2);
+      pad->cd(1);
+    }
+  */
+  if (!IsEmpty())
+      gPad->SetLogy();
+
+  gPad->SetTicks();
+
+  fHGausHist.GetXaxis()->SetLabelSize(0.06);
+  fHGausHist.GetYaxis()->SetLabelSize(0.07);
+  fHGausHist.GetXaxis()->SetLabelOffset(0.01);
+  fHGausHist.GetYaxis()->SetLabelOffset(0.01);
+  fHGausHist.GetXaxis()->SetTitleSize(0.065);
+  fHGausHist.GetYaxis()->SetTitleSize(0.07);
+  fHGausHist.GetXaxis()->SetTitleOffset(0.6);
+  fHGausHist.GetYaxis()->SetTitleOffset(0.6);
+  fHGausHist.Draw(); 
+  if (fFGausFit)
+  {
+      fFGausFit->SetLineColor(IsGausFitOK() ? kGreen : kRed);
+      fFGausFit->Draw("same");
+  }
+
+  pad->cd(2);
+  gPad->SetTicks();
+
+  fHAbsTime.GetXaxis()->SetLabelSize(0.06);
+  fHAbsTime.GetYaxis()->SetLabelSize(0.07);
+  fHAbsTime.GetXaxis()->SetLabelOffset(0.01);
+  fHAbsTime.GetYaxis()->SetLabelOffset(0.01);
+  fHAbsTime.GetXaxis()->SetTitleSize(0.065);
+  fHAbsTime.GetYaxis()->SetTitleSize(0.07);
+  fHAbsTime.GetXaxis()->SetTitleOffset(0.6);
+  fHAbsTime.GetYaxis()->SetTitleOffset(0.6);
+  fHAbsTime.Draw();
+
+  if (win < 2)
+      return;
+
+  oldpad->cd(2);
+  MHGausEvents::Draw("fourierevents");
+
+}
Index: /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargePix.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargePix.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationChargePix.h	(revision 9661)
@@ -0,0 +1,63 @@
+#ifndef MARS_MHCalibrationChargePix
+#define MARS_MHCalibrationChargePix
+
+#ifndef MARS_MHGausEvents
+#include "MHGausEvents.h"
+#endif
+
+class TH1F;
+class MHCalibrationChargePix : public MHGausEvents
+{
+
+private:
+
+  static const Int_t   fgChargeNbins;        // Default for fNBins          (now set to: 2000  )
+  static const Axis_t  fgChargeFirst;        // Default for fFirst          (now set to: -0.5  )
+  static const Axis_t  fgChargeLast;         // Default for fLast           (now set to: 1999.5)
+  static const Int_t   fgAbsTimeNbins;       // Default for fAbsTimeNbins   (now set to: 15    )
+  static const Axis_t  fgAbsTimeFirst;       // Default for fAbsTimeFirst   (now set to: -0.5  )
+  static const Axis_t  fgAbsTimeLast;        // Default for fAbsTimeLast    (now set to: 14.5  )
+
+protected:
+
+  TH1F     fHAbsTime;      // Histogram containing the absolute arrival times 
+                          
+  Int_t    fAbsTimeNbins;  // Number of  bins used for the fHAbsTime 
+  Axis_t   fAbsTimeFirst;  // Lower bound bin used for the fHAbsTime
+  Axis_t   fAbsTimeLast;   // Upper bound bin used for the fHAbsTime
+
+public:
+
+  MHCalibrationChargePix(const char *name=NULL, const char *title=NULL);
+  ~MHCalibrationChargePix() {}
+
+  virtual void Clear(Option_t *o="");
+  virtual void Reset();  
+  virtual void InitBins();
+  
+  // Setters 
+  virtual void SetAbsTimeNbins(const Int_t  bins =fgAbsTimeNbins)  { fAbsTimeNbins = bins;  }
+  virtual void SetAbsTimeFirst(const Axis_t first=fgAbsTimeFirst)  { fAbsTimeFirst = first; }
+  virtual void SetAbsTimeLast( const Axis_t last =fgAbsTimeLast)   { fAbsTimeLast  = last;  }
+
+  // Getters
+  TH1F *GetHAbsTime()                         { return &fHAbsTime;  }
+  const TH1F *GetHAbsTime()             const { return &fHAbsTime;  }
+
+  const Float_t  GetAbsTimeMean(  )     const;
+  const Float_t  GetAbsTimeRms()        const;
+  const Float_t  GetIntegral()          const;
+
+  // Fill histos
+  Bool_t FillAbsTime(const Float_t t);
+
+  // Draws
+  virtual void Draw(Option_t *opt="");
+
+  // Miscelleaneous
+  void ChangeHistId(Int_t id);
+  
+  ClassDef(MHCalibrationChargePix, 1)     // Base Histogram class for Charge Pixel Calibration
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationRelTimeCam.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationRelTimeCam.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationRelTimeCam.cc	(revision 9661)
@@ -0,0 +1,553 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug   02/2004 <mailto:markus@ifae.es>
+!              
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+/////////////////////////////////////////////////////////////////////////////
+//                                                                        
+// MHCalibrationRelTimeCam                                                
+//                                                                        
+// Fills the extracted relative arrival times of MArrivalTimeCam into 
+// the MHGausEvents-classes MHCalibrationRelTimePix for every:
+//
+// - Pixel, stored in the TObjArray's MHCalibrationCam::fHiGainArray  
+//   or MHCalibrationCam::fHiGainArray, respectively, depending if 
+//   MArrivalTimePix::IsLoGainUsed() is set.
+//
+// - Average pixel per AREA index (e.g. inner and outer for the MAGIC camera), 
+//   stored in the TObjArray's MHCalibrationCam::fAverageHiGainAreas and 
+//   MHCalibrationCam::fAverageHiGainAreas
+//
+// - Average pixel per camera SECTOR (e.g. sectors 1-6 for the MAGIC camera), 
+//   stored in the TObjArray's MHCalibrationCam::fAverageHiGainSectors 
+//   and MHCalibrationCam::fAverageHiGainSectors 
+//
+// Every relative time is calculated as the difference between the individual 
+// pixel arrival time and the one of pixel 1 (hardware number: 2). 
+// The relative times are filled into a histogram and an array, in order to perform 
+// a Fourier analysis (see MHGausEvents). The signals are moreover averaged on an 
+// event-by-event basis and written into the corresponding average pixels.
+//
+// The histograms are fitted to a Gaussian, mean and sigma with its errors 
+// and the fit probability are extracted. If none of these values are NaN's and 
+// if the probability is bigger than MHGausEvents::fProbLimit (default: 0.5%), 
+// the fit is declared valid.
+// Otherwise, the fit is repeated within ranges of the previous mean 
+// +- MHGausEvents::fPickupLimit (default: 5) sigma (see MHGausEvents::RepeatFit())
+// In case this does not make the fit valid, the histogram means and RMS's are 
+// taken directly (see MHGausEvents::BypassFit()) and the following flags are set:
+// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kRelTimeNotFitted ) and
+// - MBadPixelsPix::SetUnsuitable(   MBadPixelsPix::kUnreliableRun    ) 
+// 
+// Outliers of more than MHGausEvents::fPickupLimit (default: 5) sigmas 
+// from the mean are counted as Pickup events (stored in MHGausEvents::fPickup) 
+//
+// The class also fills arrays with the signal vs. event number, creates a fourier 
+// spectrum (see MHGausEvents::CreateFourierSpectrum()) and investigates if the 
+// projected fourier components follow an exponential distribution. 
+// In case that the probability of the exponential fit is less than 
+// MHGausEvents::fProbLimit (default: 0.5%), the following flags are set:
+// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kRelTimeOscillating ) and
+// - MBadPixelsPix::SetUnsuitable(   MBadPixelsPix::kUnreliableRun      )
+// 
+// This same procedure is performed for the average pixels.
+//
+// The following results are written into MCalibrationRelTimeCam:
+//
+// - MCalibrationPix::SetMean()
+// - MCalibrationPix::SetMeanErr()
+// - MCalibrationPix::SetSigma()
+// - MCalibrationPix::SetSigmaErr()
+// - MCalibrationPix::SetProb()
+// - MCalibrationPix::SetNumPickup()
+//
+// For all averaged areas, the fitted sigma is multiplied with the square root of 
+// the number involved pixels in order to be able to compare it to the average of 
+// sigmas in the camera.
+//                                                                         
+/////////////////////////////////////////////////////////////////////////////
+#include "MHCalibrationRelTimeCam.h"
+#include "MHCalibrationRelTimePix.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MCalibrationRelTimeCam.h"
+#include "MCalibrationPix.h"
+
+#include "MArrivalTimeCam.h"
+#include "MArrivalTimePix.h"
+
+#include "MGeomCam.h"
+#include "MGeomPix.h"
+
+#include "MBadPixelsCam.h"
+#include "MBadPixelsPix.h"
+
+#include "MHGausEvents.h"
+
+ClassImp(MHCalibrationRelTimeCam);
+
+using namespace std;
+
+const Float_t MHCalibrationRelTimeCam::fgNumHiGainSaturationLimit = 0.25;
+const UInt_t  MHCalibrationRelTimeCam::fgReferencePixel = 1;
+// --------------------------------------------------------------------------
+//
+// Default Constructor.
+//
+// Sets: 
+// - fReferencePixel to fgReferencePixel
+//
+MHCalibrationRelTimeCam::MHCalibrationRelTimeCam(const char *name, const char *title) 
+{
+
+  fName  = name  ? name  : "MHCalibrationRelTimeCam";
+  fTitle = title ? title : "Histogram class for the relative time calibration of the camera";
+
+  SetNumHiGainSaturationLimit(fgNumHiGainSaturationLimit);
+  SetReferencePixel();
+}
+
+// --------------------------------------------------------------------------
+//
+// Gets or creates the pointers to:
+// - MCalibrationRelTimeCam
+//
+// Searches pointer to:
+// - MArrivalTimeCam
+//
+// Initializes, if empty to MGeomCam::GetNumPixels():
+// - MHCalibrationCam::fHiGainArray, MHCalibrationCam::fLoGainArray
+//
+// Initializes, if empty to MGeomCam::GetNumAreas() for:
+// - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
+//
+// Initializes, if empty to MGeomCam::GetNumSectors() for:
+// - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
+// 
+// Calls MHCalibrationCam::InitHists() for every entry in:
+// - MHCalibrationCam::fHiGainArray, MHCalibrationCam::fLoGainArray
+// - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
+// - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
+//
+// Sets Titles and Names for the Histograms 
+// - MHCalibrationCam::fAverageHiGainAreas
+// - MHCalibrationCam::fAverageHiGainSectors
+// 
+// Sets number of bins to MHCalibrationCam::fAverageNbins for:
+// - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
+// - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
+//
+Bool_t MHCalibrationRelTimeCam::ReInitHists(MParList *pList)
+{
+
+  
+  fCam = (MCalibrationCam*)pList->FindObject("MCalibrationRelTimeCam");
+  if (!fCam)
+    {
+      fCam = (MCalibrationCam*)pList->FindCreateObj(AddSerialNumber("MCalibrationRelTimeCam"));
+      if (!fCam)
+        {
+          gLog << err << "Cannot find nor create MCalibrationRelTimeCam ... abort." << endl;
+          return kFALSE;
+        }
+      else 
+        fCam->Init(*fGeom);
+    }
+  
+
+  MArrivalTimeCam *signal = (MArrivalTimeCam*)pList->FindObject("MArrivalTimeCam");
+  if (!signal)
+  {
+      *fLog << err << "MArrivalTimeCam not found... abort." << endl;
+      return kFALSE;
+  }
+
+  const Int_t npixels  = fGeom->GetNumPixels();
+  const Int_t nsectors = fGeom->GetNumSectors();
+  const Int_t nareas   = fGeom->GetNumAreas();
+
+  if (fHiGainArray->GetEntries()==0)
+  {
+      fHiGainArray->Expand(npixels);
+      for (Int_t i=0; i<npixels; i++)
+      {
+	  (*fHiGainArray)[i] = new MHCalibrationRelTimePix("MHCalibrationRelTimePixHiGain",
+                                                          "Rel. Arr. Time Hi-Gain Pixel ");
+          InitHists((*this)[i],(*fBadPixels)[i],i);
+      }
+  }
+  
+  if (fLoGainArray->GetEntries()==0)
+  {
+      fLoGainArray->Expand(npixels);
+      for (Int_t i=0; i<npixels; i++)
+      {
+	  (*fLoGainArray)[i] = new MHCalibrationRelTimePix("MHCalibrationRelTimePixLoGain",
+                                                          "Rel. Arr. Time Lo-Gain Pixel ");
+          InitHists((*this)(i),(*fBadPixels)[i],i);
+      }
+  }
+
+
+  if (fAverageHiGainAreas->GetEntries()==0)
+  {
+    fAverageHiGainAreas->Expand(nareas);
+    
+    for (Int_t j=0; j<nareas; j++)
+      {
+        (*fAverageHiGainAreas)[j] = 
+          new MHCalibrationRelTimePix("MHCalibrationRelTimeAverageAreaHiGain",
+                                      "Average Rel. Arr. Times Hi-Gain Area Idx ");
+
+        GetAverageHiGainArea(j).GetHGausHist()->SetTitle("Rel. Arr. Times HiGain Area Idx ");
+        GetAverageHiGainArea(j).SetNbins(fAverageNbins);
+
+        InitHists(GetAverageHiGainArea(j),fCam->GetAverageBadArea(j),j);
+      }
+  }
+
+  if (fAverageLoGainAreas->GetEntries()==0)
+  {
+    fAverageLoGainAreas->Expand(nareas);
+    
+    for (Int_t j=0; j<nareas; j++)
+      {
+        (*fAverageLoGainAreas)[j] = 
+          new MHCalibrationRelTimePix("MHCalibrationRelTimeAverageAreaLoGain",
+                                      "Average Rel. Arr. Times Lo-Gain Area Idx ");
+
+        GetAverageLoGainArea(j).GetHGausHist()->SetTitle("Rel. Arr. Times LoGain Area Idx ");
+        GetAverageLoGainArea(j).SetNbins(fAverageNbins);
+
+        InitHists(GetAverageLoGainArea(j),fCam->GetAverageBadArea(j),j);
+      }
+  }
+  
+  if (fAverageHiGainSectors->GetEntries()==0)
+    {
+      fAverageHiGainSectors->Expand(nsectors);
+
+      for (Int_t j=0; j<nsectors; j++)
+        {
+	  (*fAverageHiGainSectors)[j] = 
+            new MHCalibrationRelTimePix("MHCalibrationRelTimeAverageSectorHiGain",
+                                        "Average Rel. Arr. Times Hi-Gain Sector ");
+          
+          GetAverageHiGainSector(j).GetHGausHist()->SetTitle("Rel. Arr. Times HiGain Sector ");
+          GetAverageHiGainSector(j).SetNbins(fAverageNbins);
+          
+          InitHists(GetAverageHiGainSector(j),fCam->GetAverageBadSector(j),j);
+      }
+  }
+  
+  if (fAverageLoGainSectors->GetEntries()==0)
+    {
+      fAverageLoGainSectors->Expand(nsectors);
+      
+      for (Int_t j=0; j<nsectors; j++)
+        {
+	  (*fAverageLoGainSectors)[j] = 
+            new MHCalibrationRelTimePix("MHCalibrationRelTimeAverageSectorLoGain",
+                                        "Average Rel. Arr. Times Lo-Gain Sector ");
+          
+          GetAverageLoGainSector(j).GetHGausHist()->SetTitle("Rel. Arr. Times LoGain Sector ");
+          GetAverageLoGainSector(j).SetNbins(fAverageNbins);
+          
+          InitHists(GetAverageLoGainSector(j),fCam->GetAverageBadSector(j),j);
+          
+        }
+    }
+
+  return kTRUE;
+}
+
+
+// -------------------------------------------------------------------------------
+//
+// Retrieves pointer to MArrivalTimeCam:
+//
+// Retrieves from MGeomCam:
+// - number of pixels
+// - number of pixel areas
+// - number of sectors
+//
+// Fills HiGain or LoGain histograms (MHGausEvents::FillHistAndArray()), respectively
+// depending on MArrivalTimePix::IsLoGainUsed(), with:
+// - MArrivalTimePix::GetArrivalTime(pixid) - MArrivalTimePix::GetArrivalTime(1);
+//   (i.e. the time difference between pixel i and pixel 1 (hardware number: 2) )
+//
+Bool_t MHCalibrationRelTimeCam::FillHists(const MParContainer *par, const Stat_t w)
+{
+
+  MArrivalTimeCam *arrtime = (MArrivalTimeCam*)par;
+  if (!arrtime)
+    {
+      gLog << err << "No argument in MArrivalTime::Fill... abort." << endl;
+      return kFALSE;
+    }
+  
+  const Int_t npixels  = fGeom->GetNumPixels();
+  const Int_t nareas   = fGeom->GetNumAreas();
+  const Int_t nsectors = fGeom->GetNumSectors();
+
+  Float_t sumareahi  [nareas],   sumarealo  [nareas];
+  Float_t sumsectorhi[nsectors], sumsectorlo[nsectors];
+  Int_t   numareahi  [nareas],   numarealo  [nareas];
+  Int_t   numsectorhi[nsectors], numsectorlo[nsectors];
+
+  memset(sumareahi,   0, nareas * sizeof(Float_t));
+  memset(sumarealo,   0, nareas * sizeof(Float_t));
+  memset(sumsectorhi, 0, nsectors*sizeof(Float_t));
+  memset(sumsectorlo, 0, nsectors*sizeof(Float_t));
+  memset(numareahi,   0, nareas * sizeof(Float_t));
+  memset(numarealo,   0, nareas * sizeof(Float_t));
+  memset(numsectorhi, 0, nsectors*sizeof(Float_t));
+  memset(numsectorlo, 0, nsectors*sizeof(Float_t));
+  
+  const MArrivalTimePix &refpix = (*arrtime)[fReferencePixel];
+  const Float_t reftime = refpix.IsLoGainUsed() 
+    ? refpix.GetArrivalTimeLoGain() : refpix.GetArrivalTimeHiGain();
+
+  for (Int_t i=0; i<npixels; i++)
+    {
+
+      MHGausEvents &histhi = (*this)[i];
+      MHGausEvents &histlo = (*this)(i);
+
+      if (histhi.IsExcluded())
+	continue;
+
+      const MArrivalTimePix &pix = (*arrtime)[i];
+      const Int_t aidx   = (*fGeom)[i].GetAidx();
+      const Int_t sector = (*fGeom)[i].GetSector();
+
+      if (pix.IsLoGainUsed())
+        { 
+          const Float_t reltime = pix.GetArrivalTimeLoGain() - reftime;
+          histhi.SetSaturated(1); 
+          histlo.FillHistAndArray(reltime);
+          sumarealo  [aidx]   += reltime;
+          numarealo  [aidx]   ++;
+          sumsectorlo[sector] += reltime;
+          numsectorlo[sector] ++;
+        }
+      else
+        {
+          const Float_t reltime = pix.GetArrivalTimeHiGain() - reftime;
+          histhi.FillHistAndArray(reltime) ;
+          sumareahi  [aidx]   += reltime;
+          numareahi  [aidx]   ++;
+          sumsectorhi[sector] += reltime;
+          numsectorhi[sector] ++;
+        }
+    }
+  
+  for (Int_t j=0; j<nareas; j++)
+    {
+      MHGausEvents &histhi = GetAverageHiGainArea(j);
+      histhi.FillHistAndArray(numareahi[j] == 0 ? 0. : sumareahi[j]/numareahi[j]);
+
+      MHGausEvents &histlo = GetAverageLoGainArea(j);
+      histlo.FillHistAndArray(numarealo[j] == 0 ? 0. : sumarealo[j]/numarealo[j]);
+    }
+  
+  for (Int_t j=0; j<nsectors; j++)
+    {
+      MHGausEvents &histhi = GetAverageHiGainSector(j);
+      histhi.FillHistAndArray(numsectorhi[j] == 0 ? 0. : sumsectorhi[j]/numsectorhi[j]);
+
+      MHGausEvents &histlo = GetAverageLoGainSector(j);
+      histlo.FillHistAndArray(numsectorlo[j] == 0 ? 0. : sumsectorlo[j]/numsectorlo[j]);
+    }
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calls:
+// - MHCalibrationCam::FitHiGainArrays() with flags:
+//   MBadPixelsPix::kRelTimeNotFitted and MBadPixelsPix::kRelTimeOscillating
+// - MHCalibrationCam::FitLoGainArrays() with flags:
+//   MBadPixelsPix::kRelTimeNotFitted and MBadPixelsPix::kRelTimeOscillating
+// 
+Bool_t MHCalibrationRelTimeCam::FinalizeHists()
+{
+
+  for (Int_t i=0; i<fHiGainArray->GetSize(); i++)
+    {
+      
+      MHCalibrationRelTimePix &histhi = (MHCalibrationRelTimePix&)(*this)[i];
+      
+      if (histhi.IsExcluded())
+        continue;
+      
+      if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
+        {
+          (*fCam)[i].SetHiGainSaturation();
+          histhi.SetExcluded();
+        }
+      else
+        (*this)(i).SetExcluded();
+      
+    }
+  
+
+  for (Int_t j=0; j<fAverageHiGainAreas->GetSize(); j++)
+    {
+      
+      MHCalibrationRelTimePix &histhi = (MHCalibrationRelTimePix&)GetAverageHiGainArea(j);      
+
+      if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
+        {
+          fCam->GetAverageArea(j).SetHiGainSaturation();
+          histhi.SetExcluded();
+        }
+      else
+        GetAverageLoGainArea(j).SetExcluded();
+
+   }
+  
+
+  for (Int_t j=0; j<fAverageHiGainSectors->GetSize(); j++)
+    {
+      
+      MHCalibrationRelTimePix &histhi = (MHCalibrationRelTimePix&)GetAverageHiGainSector(j);      
+
+      if (histhi.GetSaturated() > fNumHiGainSaturationLimit*histhi.GetHGausHist()->GetEntries())
+        {
+          fCam->GetAverageSector(j).SetHiGainSaturation();
+          histhi.SetExcluded();
+        }
+      else
+        GetAverageHiGainSector(j).SetExcluded();
+    }
+  
+
+  FitHiGainArrays((*fCam),*fBadPixels,
+                  MBadPixelsPix::kRelTimeNotFitted,
+                  MBadPixelsPix::kRelTimeOscillating);
+
+  FitLoGainArrays((*fCam),*fBadPixels,
+                  MBadPixelsPix::kRelTimeNotFitted,
+                  MBadPixelsPix::kRelTimeOscillating);
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Sets all pixels to MBadPixelsPix::kUnreliableRun, if following flags are set:
+// - MBadPixelsPix::kRelTimeNotFitted
+// - MBadPixelsPix::kRelTimeOscillating
+//
+void MHCalibrationRelTimeCam::FinalizeBadPixels()
+{
+
+  for (Int_t i=0; i<fBadPixels->GetSize(); i++)
+    {
+      
+      MBadPixelsPix          &bad    = (*fBadPixels)[i];
+
+      if (bad.IsUncalibrated( MBadPixelsPix::kRelTimeNotFitted ))
+        bad.SetUnsuitable(   MBadPixelsPix::kUnreliableRun    );
+
+      if (bad.IsUncalibrated( MBadPixelsPix::kRelTimeOscillating))
+        bad.SetUnsuitable(   MBadPixelsPix::kUnreliableRun    );
+      
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// The types are as follows:
+// 
+// Fitted values:
+// ============== 
+//
+// 0: Fitted Mean Relative Arrival Time in ns  (MHGausEvents::GetMean()*MHCalibrationRelTimePix::GetFADCSliceWidth())
+// 1: Error Mean Relative Arrival Time in ns   (MHGausEvents::GetMeanErr()*MHCalibrationRelTimePix::GetFADCSliceWidth())
+// 2: Sigma fitted Relative Arrival Time in ns (MHGausEvents::GetSigma()*MHCalibrationRelTimePix::GetFADCSliceWidth())
+// 3: Error Sigma Relative Arrival Time in ns  (MHGausEvents::GetSigmaErr()*MHCalibrationRelTimePix::GetFADCSliceWidth())
+//
+// Useful variables derived from the fit results:
+// =============================================
+//
+// 4: Returned probability of Gauss fit              (calls: MHGausEvents::GetProb())
+//
+// Localized defects:
+// ==================
+//
+// 5: Gaus fit not OK                               (calls: MHGausEvents::IsGausFitOK())
+// 6: Fourier spectrum not OK                       (calls: MHGausEvents::IsFourierSpectrumOK())
+//
+Bool_t MHCalibrationRelTimeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
+{
+
+  if (fHiGainArray->GetSize() <= idx)
+    return kFALSE;
+
+  const MHCalibrationRelTimePix &pix = (MHCalibrationRelTimePix&)(*this)[idx];
+  const Float_t fadc2ns              = pix.GetFADCSliceWidth();
+
+  switch (type)
+    {
+    case 0:
+      val = pix.GetMean()*fadc2ns;
+      break;
+    case 1:
+      val = pix.GetMeanErr()*fadc2ns;
+      break;
+    case 2:
+      val = pix.GetSigma()*fadc2ns;
+      break;
+    case 3:
+      val = pix.GetSigmaErr()*fadc2ns;
+      break;
+    case 4:
+      val = pix.GetProb();
+      break;
+    case 5:
+      if (!pix.IsGausFitOK())
+        val = 1.;
+      break;
+    case 6:
+      if (!pix.IsFourierSpectrumOK())
+        val = 1.;
+      break;
+    default:
+      return kFALSE;
+    }
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calls MHGausEvents::DrawClone() for pixel idx
+//
+void MHCalibrationRelTimeCam::DrawPixelContent(Int_t idx) const
+{
+ (*this)[idx].DrawClone();
+}
Index: /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationRelTimeCam.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationRelTimeCam.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationRelTimeCam.h	(revision 9661)
@@ -0,0 +1,39 @@
+#ifndef MARS_MHCalibrationRelTimeCam
+#define MARS_MHCalibrationRelTimeCam
+
+#ifndef MARS_MHCalibrationCam
+#include "MHCalibrationCam.h"
+#endif
+
+class MGeomCam;
+class MHCalibrationRelTimeCam : public MHCalibrationCam
+{
+
+private:
+
+  static const Float_t fgNumHiGainSaturationLimit;   //! The default for fNumHiGainSaturationLimit (now at: 0.25)
+  static const UInt_t  fgReferencePixel;             //! Default for fReferencePixel (now set to: 1)
+  UInt_t fReferencePixel;                           //  The reference pixel for rel. times
+
+  Bool_t ReInitHists(MParList *pList);
+  Bool_t FillHists(const MParContainer *par, const Stat_t w=1);
+  Bool_t FinalizeHists();
+  void    FinalizeBadPixels();
+  
+public:
+
+  MHCalibrationRelTimeCam(const char *name=NULL, const char *title=NULL);
+  ~MHCalibrationRelTimeCam() {}
+
+  UInt_t GetReferencePixel() const   { return fReferencePixel; }
+  void   SetReferencePixel(const UInt_t i=fgReferencePixel)   {  fReferencePixel = i; }
+  
+  
+  Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
+  void DrawPixelContent(Int_t idx) const;
+  
+  ClassDef(MHCalibrationRelTimeCam, 1)	// Histogram class for Relative Time Camera Calibration
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationRelTimePix.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationRelTimePix.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationRelTimePix.cc	(revision 9661)
@@ -0,0 +1,89 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug 02/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MHCalibrationRelTimePix
+//
+//  Histogram class for the relative arrival time calibration. 
+//  Stores and fits the relative arrival times between pixel fPixId and 
+//  pixel number 1 (hardware index: 2). Times are taken from MArrivalTimePix
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MHCalibrationRelTimePix.h"
+
+#include <TH1.h>
+
+ClassImp(MHCalibrationRelTimePix);
+
+using namespace std;
+//
+const Int_t   MHCalibrationRelTimePix::fgRelTimeNbins    = 900;
+const Axis_t  MHCalibrationRelTimePix::fgRelTimeFirst    = -5.;
+const Axis_t  MHCalibrationRelTimePix::fgRelTimeLast     =  5.;
+const Float_t MHCalibrationRelTimePix::fgFADCSliceWidth  =  3.3333;
+// --------------------------------------------------------------------------
+//
+// Default Constructor. 
+//
+// Sets: 
+// - the default number for fNbins  (fgRelTimeNbins)
+// - the default number for fFirst  (fgRelTimeFirst)
+// - the default number for fLast   (fgRelTimeLast)
+//
+// - the default name of the  fHGausHist ("HCalibrationRelTime")
+// - the default title of the fHGausHist ("Distribution of Relative Arrival Times Pixel ")
+// - the default x-axis title for fHGausHist ("FADC Slice")
+// - the default y-axis title for fHGausHist ("Nr. of events")
+// 
+// - the default number for fFADCSliceWidth (fgFADCSliceWidth)
+//
+MHCalibrationRelTimePix::MHCalibrationRelTimePix(const char *name, const char *title) 
+{ 
+
+  fName  = name  ? name  : "MHCalibrationRelTimePix";
+  fTitle = title ? title : "Histogrammed Calibration Relative Arrival Time events";
+
+  SetNbins ( fgRelTimeNbins );
+  SetFirst ( fgRelTimeFirst );
+  SetLast  ( fgRelTimeLast  );
+  SetFADCSliceWidth();
+
+  // Create a large number of bins, later we will rebin
+  fHGausHist.SetName("HCalibrationRelTime");
+  fHGausHist.SetTitle("Distribution of Relative Arrival Times Pixel ");
+  fHGausHist.SetXTitle("FADC Slice");
+  fHGausHist.SetYTitle("Nr. of events");
+
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Empty function to overload MHGausEvents::Reset()
+//
+void MHCalibrationRelTimePix::Reset()
+{
+}
+
Index: /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationRelTimePix.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationRelTimePix.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationRelTimePix.h	(revision 9661)
@@ -0,0 +1,36 @@
+#ifndef MARS_MHCalibrationRelTimePix
+#define MARS_MHCalibrationRelTimePix
+
+#ifndef MARS_MHGausEvents
+#include "MHGausEvents.h"
+#endif
+
+class MHCalibrationRelTimePix : public MHGausEvents
+{
+
+private:
+
+  static const Int_t   fgRelTimeNbins;      //! Default for fNbins          (now set to: 900   )
+  static const Axis_t  fgRelTimeFirst;      //! Default for fFirst          (now set to: -13.5 )
+  static const Axis_t  fgRelTimeLast;       //! Default for fLast           (now set to:  13.5 )
+  static const Float_t fgFADCSliceWidth;    //! Default for fFADCSliceWidth (now set to: 3.333)
+  
+  Float_t fFADCSliceWidth;                 //  Time FADC Slice Width in ns.
+  
+public:
+
+  MHCalibrationRelTimePix(const char *name=NULL, const char *title=NULL);
+  ~MHCalibrationRelTimePix() {}
+
+  // Getters
+  Float_t GetFADCSliceWidth() const    { return fFADCSliceWidth;  }
+  
+  // Setters
+  void SetFADCSliceWidth( const Float_t f=fgFADCSliceWidth )  {  fFADCSliceWidth = f; }
+  
+  void Reset();
+  
+  ClassDef(MHCalibrationRelTimePix, 1)     // Histogram class for Relative Time Pixel Calibration
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationTestCam.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationTestCam.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationTestCam.cc	(revision 9661)
@@ -0,0 +1,576 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug   02/2004 <mailto:markus@ifae.es>
+!              
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+/////////////////////////////////////////////////////////////////////////////
+//                                                                        
+// MHCalibrationTestCam                                                
+//                                                                        
+// Fills the calibrated signal from an MCerPhotEvt into 
+// MHCalibrationTestPix for every:
+//
+// - Pixel, stored in the TObjArray's MHCalibrationCam::fHiGainArray  
+//   or MHCalibrationCam::fHiGainArray, respectively.
+//
+// - Average pixel per AREA index (e.g. inner and outer for the MAGIC camera), 
+//   stored in the TObjArray's MHCalibrationCam::fAverageHiGainAreas and 
+//   MHCalibrationCam::fAverageHiGainAreas
+//
+// - Average pixel per camera SECTOR (e.g. sectors 1-6 for the MAGIC camera), 
+//   stored in the TObjArray's MHCalibrationCam::fAverageHiGainSectors 
+//   and MHCalibrationCam::fAverageHiGainSectors 
+//
+// The signals are filled into a histogram and an array, in order to perform 
+// a Fourier analysis (see MHGausEvents). The signals are moreover averaged on an 
+// event-by-event basis and written into the corresponding average pixels.
+//
+// The histograms are fitted to a Gaussian, mean and sigma with its errors 
+// and the fit probability are extracted. If none of these values are NaN's and 
+// if the probability is bigger than MHGausEvents::fProbLimit (default: 0.5%), 
+// the fit is declared valid.
+// Otherwise, the fit is repeated within ranges of the previous mean 
+// +- MHGausEvents::fPickupLimit (default: 5) sigma (see MHGausEvents::RepeatFit())
+// In case this does not make the fit valid, the histogram means and RMS's are 
+// taken directly (see MHGausEvents::BypassFit()) and the following flags are set:
+// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainNotFitted ) and
+// - MBadPixelsPix::SetUnsuitable(   MBadPixelsPix::kUnreliableRun    ) 
+// 
+// Outliers of more than MHGausEvents::fPickupLimit (default: 5) sigmas 
+// from the mean are counted as Pickup events (stored in MHGausEvents::fPickup) 
+//
+// The class also fills arrays with the signal vs. event number, creates a fourier 
+// spectrum (see MHGausEvents::CreateFourierSpectrum()) and investigates if the 
+// projected fourier components follow an exponential distribution. 
+// In case that the probability of the exponential fit is less than 
+// MHGausEvents::fProbLimit (default: 0.5%), the following flags are set:
+// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainOscillating ) and
+// - MBadPixelsPix::SetUnsuitable(   MBadPixelsPix::kUnreliableRun      )
+// 
+// This same procedure is performed for the average pixels.
+//
+// The following results are written into an MCalibrationCam:
+//
+// - MCalibrationPix::SetMean()
+// - MCalibrationPix::SetMeanErr()
+// - MCalibrationPix::SetSigma()
+// - MCalibrationPix::SetSigmaErr()
+// - MCalibrationPix::SetProb()
+// - MCalibrationPix::SetNumPickup()
+//
+// For all averaged areas, the fitted sigma is multiplied with the square root of 
+// the number involved pixels in order to be able to compare it to the average of 
+// sigmas in the camera.
+//                                                                         
+/////////////////////////////////////////////////////////////////////////////
+#include "MHCalibrationTestCam.h"
+#include "MHCalibrationTestPix.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MCalibrationCam.h"
+#include "MCalibrationPix.h"
+
+#include "MCerPhotEvt.h"
+#include "MCerPhotPix.h"
+
+#include "MGeomCam.h"
+#include "MGeomPix.h"
+
+#include "MBadPixelsCam.h"
+#include "MBadPixelsPix.h"
+
+ClassImp(MHCalibrationTestCam);
+
+using namespace std;
+// --------------------------------------------------------------------------
+//
+// Default Constructor. 
+//
+MHCalibrationTestCam::MHCalibrationTestCam(const char *name, const char *title) 
+{
+
+  fName  = name  ? name  : "MHCalibrationTestCam";
+  fTitle = title ? title : "Histogram class for testing the calibration";
+  
+  SetAverageNbins(5000);
+}
+
+// --------------------------------------------------------------------------
+//
+// Gets or creates the pointers to:
+// - MCalibrationTestCam
+//
+// Searches pointer to:
+// - MCerPhotEvt
+//
+// Initializes, if empty to MGeomCam::GetNumAreas() for:
+// - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
+//
+// Initializes, if empty to MGeomCam::GetNumSectors() for:
+// - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
+// 
+// Calls MHCalibrationCam::InitHists() for every entry in:
+// - MHCalibrationCam::fHiGainArray
+// - MHCalibrationCam::fAverageHiGainAreas
+// - MHCalibrationCam::fAverageHiGainSectors
+//
+// Sets Titles and Names for the Histograms 
+// - MHCalibrationCam::fAverageHiGainAreas
+// - MHCalibrationCam::fAverageHiGainSectors
+// 
+// Sets number of bins to MHCalibrationCam::fAverageNbins for:
+// - MHCalibrationCam::fAverageHiGainAreas
+// - MHCalibrationCam::fAverageHiGainSectors
+//
+Bool_t MHCalibrationTestCam::ReInitHists(MParList *pList)
+{
+
+  MCerPhotEvt *signal = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
+  if (!signal)
+  {
+      *fLog << err << "MCerPhotEvt not found... abort." << endl;
+      return kFALSE;
+  }
+
+  const Int_t npixels  = fGeom->GetNumPixels();
+  const Int_t nsectors = fGeom->GetNumSectors();
+  const Int_t nareas   = fGeom->GetNumAreas();
+
+  if (fHiGainArray->GetEntries()==0)
+  {
+      fHiGainArray->Expand(npixels);
+      for (Int_t i=0; i<npixels; i++)
+      {
+	  (*fHiGainArray)[i] = new MHCalibrationTestPix("Calibrated Events",
+                                                "Test Calibration Pixel");
+          InitHists((*this)[i],(*fBadPixels)[i],i);
+      }
+  }
+
+  if (fLoGainArray->GetEntries()==0)
+  {
+      fLoGainArray->Expand(npixels);
+      for (Int_t i=0; i<npixels; i++)
+      {
+	  (*fLoGainArray)[i] = new MHCalibrationTestPix("Calibrated Events",
+                                                "Test Calibration Pixel");
+          InitHists((*this)(i),(*fBadPixels)[i],i);
+      }
+  }
+
+
+  if (fAverageHiGainAreas->GetEntries()==0)
+  {
+    fAverageHiGainAreas->Expand(nareas);
+    
+    for (Int_t j=0; j<nareas; j++)
+      {
+        (*fAverageHiGainAreas)[j] = 
+          new MHCalibrationTestPix("MHCalibrationTestAverageArea",
+                           "Average Test Calibrations Area Idx ");
+
+        GetAverageHiGainArea(j).GetHGausHist()->SetTitle("Test Calibrations Area Idx ");
+        GetAverageHiGainArea(j).SetNbins(fAverageNbins);
+        GetAverageHiGainArea(j).InitBins();
+        GetAverageHiGainArea(j).ChangeHistId(j);
+        GetAverageHiGainArea(j).SetEventFrequency(fPulserFrequency);
+
+        TH1F *h =  GetAverageHiGainArea(j).GetHGausHist();
+        h->SetTitle( Form("%s%s", h->GetTitle()," Runs: "));
+      }
+  }
+
+  if (fAverageLoGainAreas->GetEntries()==0)
+  {
+    fAverageLoGainAreas->Expand(nareas);
+    
+    for (Int_t j=0; j<nareas; j++)
+      {
+        (*fAverageLoGainAreas)[j] = 
+          new MHCalibrationTestPix("MHCalibrationTestAverageArea",
+                           "Average Test Calibrations Area Idx ");
+
+        GetAverageLoGainArea(j).GetHGausHist()->SetTitle("Test Calibrations Area Idx ");
+        GetAverageLoGainArea(j).SetNbins(fAverageNbins);
+        GetAverageLoGainArea(j).InitBins();
+        GetAverageLoGainArea(j).ChangeHistId(j);
+        GetAverageLoGainArea(j).SetEventFrequency(fPulserFrequency);
+
+      }
+  }
+
+
+  if (fAverageHiGainSectors->GetEntries()==0)
+  {
+      fAverageHiGainSectors->Expand(nsectors);
+
+      for (Int_t j=0; j<nsectors; j++)
+      {
+	  (*fAverageHiGainSectors)[j] = 
+            new MHCalibrationTestPix("MHCalibrationTestAverageSector",
+                             "Average Test Calibrations Sector ");
+
+          GetAverageHiGainSector(j).GetHGausHist()->SetTitle("Test Calibrations Sector ");
+          GetAverageHiGainSector(j).SetNbins(fAverageNbins);
+          GetAverageHiGainSector(j).InitBins();
+          GetAverageHiGainSector(j).ChangeHistId(j);
+          GetAverageHiGainSector(j).SetEventFrequency(fPulserFrequency);
+
+          TH1F *h =  GetAverageHiGainSector(j).GetHGausHist();
+          h->SetTitle( Form("%s%s", h->GetTitle()," Runs: "));
+
+      }
+  }
+
+
+  if (fAverageLoGainSectors->GetEntries()==0)
+  {
+      fAverageLoGainSectors->Expand(nsectors);
+
+      for (Int_t j=0; j<nsectors; j++)
+      {
+	  (*fAverageLoGainSectors)[j] = 
+            new MHCalibrationTestPix("MHCalibrationTestAverageSector",
+                             "Average Test Calibrations Sector ");
+
+          GetAverageLoGainSector(j).GetHGausHist()->SetTitle("Test Calibrations Sector ");
+          GetAverageLoGainSector(j).SetNbins(fAverageNbins);
+          GetAverageLoGainSector(j).InitBins();
+          GetAverageLoGainSector(j).ChangeHistId(j);
+          GetAverageLoGainSector(j).SetEventFrequency(fPulserFrequency);
+      }
+  }
+
+
+  fMeanMeanPhotPerArea.Set(nareas);   
+  fRmsMeanPhotPerArea .Set(nareas); 
+  fMeanSigmaPhotPerArea.Set(nareas);  
+  fRmsSigmaPhotPerArea.Set(nareas);
+ 
+  return kTRUE;
+}
+
+
+// -------------------------------------------------------------------------------
+//
+// Retrieves pointer to MCerPhotEvt:
+//
+// Retrieves from MGeomCam:
+// - number of pixels
+// - number of pixel areas
+// - number of sectors
+//
+// Fills HiGain or LoGain histograms (MHGausEvents::FillHistAndArray()), respectively
+// depending on MCerPhotPix::IsLoGainUsed(), with:
+// - MCerPhotPix::GetArrivalTime(pixid) - MCerPhotPix::GetArrivalTime(1);
+//   (i.e. the time difference between pixel i and pixel 1 (hardware number: 2) )
+//
+Bool_t MHCalibrationTestCam::FillHists(const MParContainer *par, const Stat_t w)
+{
+
+  MCerPhotEvt *calibration = (MCerPhotEvt*)par;
+  if (!calibration)
+    {
+      gLog << err << "No argument in MHCalibrationRelTimeCam::Fill... abort." << endl;
+      return kFALSE;
+    }
+
+  const Int_t npixels  = fGeom->GetNumPixels();
+  const Int_t nareas   = fGeom->GetNumAreas();
+  const Int_t nsectors = fGeom->GetNumSectors();
+
+  Float_t sumareahi  [nareas]; 
+  Float_t sumsectorhi[nsectors];
+  Int_t   numareahi  [nareas]; 
+  Int_t   numsectorhi[nsectors];
+
+  memset(sumareahi,   0, nareas * sizeof(Float_t));
+  memset(sumsectorhi, 0, nsectors*sizeof(Float_t));
+  memset(numareahi,   0, nareas * sizeof(Int_t));
+  memset(numsectorhi, 0, nsectors*sizeof(Int_t));
+  
+  for (Int_t i=0; i<npixels; i++)
+    {
+
+      MHGausEvents &histhi = (*this)[i];
+
+      if (histhi.IsExcluded())
+	continue;
+
+      const MCerPhotPix *pix = calibration->GetPixById(i);
+      if (!pix)
+        continue;
+
+      const Float_t   signal = pix->GetNumPhotons();
+
+      const Int_t aidx   = (*fGeom)[i].GetAidx();
+      const Int_t sector = (*fGeom)[i].GetSector();
+
+      histhi.FillHistAndArray(signal) ;
+      sumareahi  [aidx]   += signal;
+      numareahi  [aidx]   ++;
+      sumsectorhi[sector] += signal;
+      numsectorhi[sector] ++;
+    }
+  
+  for (Int_t j=0; j<nareas; j++)
+    {
+      MHGausEvents &histhi = GetAverageHiGainArea(j);
+      histhi.FillHistAndArray(numareahi[j] == 0 ? 0. : sumareahi[j]/numareahi[j]);
+
+    }
+  
+  for (Int_t j=0; j<nsectors; j++)
+    {
+      MHGausEvents &histhi = GetAverageHiGainSector(j);
+      histhi.FillHistAndArray(numsectorhi[j] == 0 ? 0. : sumsectorhi[j]/numsectorhi[j]);
+
+    }
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calls:
+// - MHCalibrationCam::FitHiGainArrays() with flags:
+//   MBadPixelsPix::kTestNotFitted and MBadPixelsPix::kTestOscillating
+// - MHCalibrationCam::FitLoGainArrays() with flags:
+//   MBadPixelsPix::kTestNotFitted and MBadPixelsPix::kTestOscillating
+// 
+Bool_t MHCalibrationTestCam::FinalizeHists()
+{
+
+  TArrayI numaidx;
+  numaidx.Set(fGeom->GetNumAreas());
+
+  for (Int_t i=0; i<fHiGainArray->GetSize(); i++)
+    {
+      
+      MHGausEvents &hist = (*this)[i];
+      
+      if (hist.IsExcluded())
+        continue;
+      
+      if (hist.IsEmpty())
+        continue;
+      
+      if (!hist.FitGaus())
+        if (!hist.RepeatFit())
+          {
+            hist.BypassFit();
+          }
+      
+      hist.CreateFourierSpectrum();
+      
+      const Float_t area = (*fGeom)[i].GetA();
+      const Int_t   aidx = (*fGeom)[i].GetAidx();
+
+      fMeanMeanPhotPerArea[aidx]  += hist.GetMean() / area;
+      fRmsMeanPhotPerArea [aidx]  += hist.GetMean() / area * hist.GetMean()  / area;
+      fMeanSigmaPhotPerArea[aidx] += hist.GetSigma()/ area;
+      fRmsSigmaPhotPerArea [aidx] += hist.GetSigma()/ area * hist.GetSigma() / area;
+      numaidx[aidx]++;
+    }
+
+
+  for (Int_t j=0; j<fAverageHiGainAreas->GetSize(); j++)
+    {
+      
+      MHGausEvents     &hist = GetAverageHiGainArea(j);      
+      if (hist.IsEmpty())
+        continue;
+      
+      if (!hist.FitGaus())
+        if (!hist.RepeatFit())
+          {
+            hist.BypassFit();
+          }
+      
+      hist.CreateFourierSpectrum();
+      
+      fRmsMeanPhotPerArea [j]  -= fMeanMeanPhotPerArea [j]*fMeanMeanPhotPerArea [j]/numaidx[j];
+      fRmsSigmaPhotPerArea[j]  -= fMeanSigmaPhotPerArea[j]*fMeanSigmaPhotPerArea[j]/numaidx[j];
+
+      fMeanMeanPhotPerArea [j]  /=  numaidx[j];
+      fMeanSigmaPhotPerArea[j]  /=  numaidx[j];
+      fRmsMeanPhotPerArea  [j]  /=  numaidx[j]-1.;
+      fRmsSigmaPhotPerArea [j]  /=  numaidx[j]-1.; 
+
+      if (fRmsMeanPhotPerArea  [j] > 0.)
+        fRmsMeanPhotPerArea  [j]  =  TMath::Sqrt(fRmsMeanPhotPerArea  [j]);
+      if (fRmsSigmaPhotPerArea [j] > 0.)
+        fRmsSigmaPhotPerArea [j]  =  TMath::Sqrt(fRmsSigmaPhotPerArea [j]);
+  }
+
+  for (Int_t j=0; j<fAverageHiGainSectors->GetSize(); j++)
+    {
+      
+      MHGausEvents     &hist = GetAverageHiGainSector(j);      
+      if (hist.IsEmpty())
+        continue;
+      
+      if (!hist.FitGaus())
+        if (!hist.RepeatFit())
+          {
+            hist.BypassFit();
+          }
+      hist.CreateFourierSpectrum();
+      
+
+    }
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Sets all pixels to MBadPixelsPix::kUnreliableRun, if following flags are set:
+// - MBadPixelsPix::kTestNotFitted
+// - MBadPixelsPix::kTestOscillating
+//
+void MHCalibrationTestCam::FinalizeBadPixels()
+{
+
+}
+
+// --------------------------------------------------------------------------
+//
+// The types are as follows:
+// 
+// Fitted values:
+// ============== 
+//
+// 0: Fitted Mean Test Calibration (MHGausEvents::GetMean())
+// 1: Error Mean Test Calibration  (MHGausEvents::GetMeanErr())
+// 2: Sigma fitted Test Calibration (MHGausEvents::GetSigma())
+// 3: Error Sigma Test Calibration (MHGausEvents::GetSigmaErr())
+//
+// Useful variables derived from the fit results:
+// =============================================
+//
+// 4: Returned probability of Gauss fit              (calls: MHGausEvents::GetProb())
+//
+// Localized defects:
+// ==================
+//
+// 5: Gaus fit not OK                               (calls: MHGausEvents::IsGausFitOK())
+// 6: Fourier spectrum not OK                       (calls: MHGausEvents::IsFourierSpectrumOK())
+//
+// Converted values:
+// =================
+//
+// 7:  Fitted Mean Test Calibration   (MHGausEvents::GetMean())     by MGeomPix::GetA()
+// 8:  Fitted Mean Error Calibration  (MHGausEvents::GetMeanErr())  by MGeomPix::GetA()
+// 9:  Fitted Sigma Test Calibration  (MHGausEvents::GetSigma())    by MGeomPix::GetA()
+// 10: Fitted Sigma Error Calibration (MHGausEvents::GetSigmaErr()) by MGeomPix::GetA()
+//
+Bool_t MHCalibrationTestCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
+{
+
+  if (fHiGainArray->GetSize() <= idx)
+    return kFALSE;
+
+  const MHGausEvents &pix = (*this)[idx];
+
+  if (pix.IsExcluded())
+    return kFALSE;
+
+  switch (type)
+    {
+    case 0:
+      val = pix.GetMean();
+      break;
+    case 1:
+      val = pix.GetMeanErr();
+      break;
+    case 2:
+      val = pix.GetSigma();
+      break;
+    case 3:
+      val = pix.GetSigmaErr();
+      break;
+    case 4:
+      val = pix.GetProb();
+      break;
+    case 5:
+      if (!pix.IsGausFitOK())
+        val = 1.;
+      break;
+    case 6:
+      if (!pix.IsFourierSpectrumOK())
+        val = 1.;
+      break;
+    case 7:
+      val = pix.GetMean()/cam[idx].GetA();
+      break;
+    case 8:
+      val = pix.GetMeanErr()/cam[idx].GetA();
+      break;
+    case 9:
+      val = pix.GetSigma()/cam[idx].GetA();
+      break;
+    case 10:
+      val = pix.GetSigmaErr()/cam[idx].GetA();
+      break;
+    default:
+      return kFALSE;
+    }
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calls MHGausEvents::DrawClone() for pixel idx
+//
+void MHCalibrationTestCam::DrawPixelContent(Int_t idx) const
+{
+ (*this)[idx].DrawClone();
+}
+
+
+//------------------------------------------------------------
+//
+// For all averaged areas, the fitted sigma is multiplied with the square root of 
+// the number involved pixels
+//
+void MHCalibrationTestCam::CalcAverageSigma()
+{
+  
+  for (UInt_t j=0; j<fGeom->GetNumAreas(); j++)
+    {
+  
+      MHGausEvents &hist    = GetAverageHiGainArea(j);
+
+      const Float_t numsqr    = TMath::Sqrt((Float_t)fAverageAreaNum[j]);
+      fAverageAreaSigma[j]    = hist.GetSigma    () * numsqr;
+      fAverageAreaSigmaVar[j] = hist.GetSigmaErr () * hist.GetSigmaErr() * numsqr;
+
+      fAverageAreaRelSigma   [j]  = fAverageAreaSigma[j]    / hist.GetMean();
+      fAverageAreaRelSigmaVar[j]  = fAverageAreaSigmaVar[j] / (fAverageAreaSigma[j]*fAverageAreaSigma[j]);
+      fAverageAreaRelSigmaVar[j] += hist.GetMeanErr()*hist.GetMeanErr()/hist.GetMean()/hist.GetMean();
+      fAverageAreaRelSigmaVar[j] *= fAverageAreaRelSigma[j];
+    }
+}
Index: /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationTestCam.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationTestCam.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationTestCam.h	(revision 9661)
@@ -0,0 +1,46 @@
+#ifndef MARS_MHCalibrationTestCam
+#define MARS_MHCalibrationTestCam
+
+#ifndef MARS_MHCalibrationCam
+#include "MHCalibrationCam.h"
+#endif
+#ifndef ROOT_TArrayF
+#include "TArrayF.h"
+#endif
+
+class MGeomCam;
+class MHCalibrationTestCam : public MHCalibrationCam
+{
+
+private:
+
+  TArrayF fMeanMeanPhotPerArea;
+  TArrayF fRmsMeanPhotPerArea   ;
+  TArrayF fMeanSigmaPhotPerArea;
+  TArrayF fRmsSigmaPhotPerArea   ;
+  
+  Bool_t ReInitHists(MParList *pList);
+  Bool_t FillHists(const MParContainer *par, const Stat_t w=1);
+  Bool_t FinalizeHists();
+  void    FinalizeBadPixels();
+  
+public:
+
+  MHCalibrationTestCam(const char *name=NULL, const char *title=NULL);
+  ~MHCalibrationTestCam() {}
+
+  Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
+  void DrawPixelContent(Int_t idx) const;
+
+  const Float_t GetMeanMeanPhotPerArea       ( const Int_t aidx ) const   { return fMeanMeanPhotPerArea [aidx]; }
+  const Float_t GetRmsMeanPhotPerArea        ( const Int_t aidx ) const   { return fRmsMeanPhotPerArea  [aidx]; }
+  const Float_t GetMeanSigmaPhotPerArea      ( const Int_t aidx ) const   { return fMeanSigmaPhotPerArea [aidx]; }
+  const Float_t GetRmsSigmaPhotPerArea       ( const Int_t aidx ) const   { return fRmsSigmaPhotPerArea  [aidx]; }
+
+  void CalcAverageSigma();
+  
+  ClassDef(MHCalibrationTestCam, 0)	// Histogram class for Relative Time Camera Calibration
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationTestPix.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationTestPix.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationTestPix.cc	(revision 9661)
@@ -0,0 +1,106 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug 02/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MHCalibrationTestPix
+//
+//  Histogram class for the charge calibration. 
+//  Stores and fits the charges and stores the location of the maximum FADC 
+//  slice. Tests are taken from MExtractedSignalPix.
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MHCalibrationTestPix.h"
+
+#include <TH1.h>
+#include <TF1.h>
+
+#include <TVirtualPad.h>
+#include <TCanvas.h>
+#include <TPad.h>
+#include <TGraph.h>
+
+#include "MH.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHCalibrationTestPix);
+
+using namespace std;
+
+const Int_t   MHCalibrationTestPix::fgChargeNbins     = 4000;
+const Axis_t  MHCalibrationTestPix::fgChargeFirst     = -0.5;
+const Axis_t  MHCalibrationTestPix::fgChargeLast      = 39999.5;
+// --------------------------------------------------------------------------
+//
+// Default Constructor. 
+//
+// Sets: 
+// - the default number for fNbins        (fgChargeNbins)
+// - the default number for fFirst        (fgChargeFirst)
+// - the default number for fLast         (fgChargeLast)
+//
+// - the default name of the  fHGausHist ("HCalibrationTest")
+// - the default title of the fHGausHist ("Distribution of calibrated FADC slices Pixel ")
+// - the default x-axis title for fHGausHist ("Sum FADC Slices")
+// - the default y-axis title for fHGausHist ("Nr. of events")
+//
+// Calls:
+// - Clear();
+//
+MHCalibrationTestPix::MHCalibrationTestPix(const char *name, const char *title)
+{ 
+  
+  fName  = name  ? name  : "MHCalibrationTestPix";
+  fTitle = title ? title : "Statistics of the calibrated FADC sums of calibration events";
+
+  SetNbins ( fgChargeNbins );
+  SetFirst ( fgChargeFirst );
+  SetLast  ( fgChargeLast  );
+
+  fHGausHist.SetName("HCalibrationTest");
+  fHGausHist.SetTitle("Distribution of calibrated Photons Pixel ");  
+  fHGausHist.SetXTitle("Nr. Photons");
+  fHGausHist.SetYTitle("Nr. of events");
+
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Empty function to overload MHGausEvents::Reset()
+//
+void MHCalibrationTestPix::Reset()
+{
+}
+
+// --------------------------------------------------------------------------
+//
+// returns fHGausHist.Integral("width")
+//
+const Float_t MHCalibrationTestPix::GetIntegral() const 
+{ 
+   return fHGausHist.Integral("width");  
+}
+
Index: /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationTestPix.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationTestPix.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationTestPix.h	(revision 9661)
@@ -0,0 +1,30 @@
+#ifndef MARS_MHCalibrationTestPix
+#define MARS_MHCalibrationTestPix
+
+#ifndef MARS_MHGausEvents
+#include "MHGausEvents.h"
+#endif
+
+class TH1F;
+class MHCalibrationTestPix : public MHGausEvents
+{
+
+private:
+
+  static const Int_t   fgChargeNbins;        // Default for fNBins          (now set to: 2000  )
+  static const Axis_t  fgChargeFirst;        // Default for fFirst          (now set to: -0.5  )
+  static const Axis_t  fgChargeLast;         // Default for fLast           (now set to: 1999.5)
+
+public:
+
+  MHCalibrationTestPix(const char *name=NULL, const char *title=NULL);
+  ~MHCalibrationTestPix() {}
+
+  virtual void Reset();  
+  
+  const Float_t  GetIntegral()          const;
+  
+  ClassDef(MHCalibrationTestPix, 1)     // Base Histogram class for Test Pixel Calibration
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationTestTimeCam.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationTestTimeCam.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationTestTimeCam.cc	(revision 9661)
@@ -0,0 +1,514 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug   02/2004 <mailto:markus@ifae.es>
+!              
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+/////////////////////////////////////////////////////////////////////////////
+//                                                                        
+// MHCalibrationTestTimeCam                                                
+//                                                                        
+// Fills the calibrated signal from an MArrivalTime into 
+// MHCalibrationTestTimePix for every:
+//
+// - Pixel, stored in the TObjArray's MHCalibrationCam::fHiGainArray  
+//   or MHCalibrationCam::fHiGainArray, respectively.
+//
+// - Average pixel per AREA index (e.g. inner and outer for the MAGIC camera), 
+//   stored in the TObjArray's MHCalibrationCam::fAverageHiGainAreas and 
+//   MHCalibrationCam::fAverageHiGainAreas
+//
+// - Average pixel per camera SECTOR (e.g. sectors 1-6 for the MAGIC camera), 
+//   stored in the TObjArray's MHCalibrationCam::fAverageHiGainSectors 
+//   and MHCalibrationCam::fAverageHiGainSectors 
+//
+// The signals are filled into a histogram and an array, in order to perform 
+// a Fourier analysis (see MHGausEvents). The signals are moreover averaged on an 
+// event-by-event basis and written into the corresponding average pixels.
+//
+// The histograms are fitted to a Gaussian, mean and sigma with its errors 
+// and the fit probability are extracted. If none of these values are NaN's and 
+// if the probability is bigger than MHGausEvents::fProbLimit (default: 0.5%), 
+// the fit is declared valid.
+// Otherwise, the fit is repeated within ranges of the previous mean 
+// +- MHGausEvents::fPickupLimit (default: 5) sigma (see MHGausEvents::RepeatFit())
+// In case this does not make the fit valid, the histogram means and RMS's are 
+// taken directly (see MHGausEvents::BypassFit()) and the following flags are set:
+// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainNotFitted ) and
+// - MBadPixelsPix::SetUnsuitable(   MBadPixelsPix::kUnreliableRun    ) 
+// 
+// Outliers of more than MHGausEvents::fPickupLimit (default: 5) sigmas 
+// from the mean are counted as Pickup events (stored in MHGausEvents::fPickup) 
+//
+// The class also fills arrays with the signal vs. event number, creates a fourier 
+// spectrum (see MHGausEvents::CreateFourierSpectrum()) and investigates if the 
+// projected fourier components follow an exponential distribution. 
+// In case that the probability of the exponential fit is less than 
+// MHGausEvents::fProbLimit (default: 0.5%), the following flags are set:
+// - MBadPixelsPix::SetUncalibrated( MBadPixelsPix::kHiGainOscillating ) and
+// - MBadPixelsPix::SetUnsuitable(   MBadPixelsPix::kUnreliableRun      )
+// 
+// This same procedure is performed for the average pixels.
+//
+// The following results are written into an MCalibrationCam:
+//
+// - MCalibrationPix::SetMean()
+// - MCalibrationPix::SetMeanErr()
+// - MCalibrationPix::SetSigma()
+// - MCalibrationPix::SetSigmaErr()
+// - MCalibrationPix::SetProb()
+// - MCalibrationPix::SetNumPickup()
+//
+// For all averaged areas, the fitted sigma is multiplied with the square root of 
+// the number involved pixels in order to be able to compare it to the average of 
+// sigmas in the camera.
+//                                                                         
+/////////////////////////////////////////////////////////////////////////////
+#include "MHCalibrationTestTimeCam.h"
+#include "MHCalibrationTestTimePix.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MCalibrationCam.h"
+#include "MCalibrationPix.h"
+
+#include "MArrivalTime.h"
+
+#include "MGeomCam.h"
+#include "MGeomPix.h"
+
+#include "MBadPixelsCam.h"
+#include "MBadPixelsPix.h"
+
+ClassImp(MHCalibrationTestTimeCam);
+
+using namespace std;
+// --------------------------------------------------------------------------
+//
+// Default Constructor. 
+//
+MHCalibrationTestTimeCam::MHCalibrationTestTimeCam(const char *name, const char *title) 
+{
+
+  fName  = name  ? name  : "MHCalibrationTestTimeCam";
+  fTitle = title ? title : "Histogram class for testing the calibration of arrival times";
+
+  SetAverageNbins(5000);
+}
+
+// --------------------------------------------------------------------------
+//
+// Gets or creates the pointers to:
+//
+// Searches pointer to:
+// - MArrivalTime
+//
+// Initializes, if empty to MGeomCam::GetNumAreas() for:
+// - MHCalibrationCam::fAverageHiGainAreas, MHCalibrationCam::fAverageLoGainAreas
+//
+// Initializes, if empty to MGeomCam::GetNumSectors() for:
+// - MHCalibrationCam::fAverageHiGainSectors, MHCalibrationCam::fAverageLoGainSectors
+// 
+// Calls MHCalibrationCam::InitHists() for every entry in:
+// - MHCalibrationCam::fHiGainArray
+// - MHCalibrationCam::fAverageHiGainAreas
+// - MHCalibrationCam::fAverageHiGainSectors
+//
+// Sets Titles and Names for the Histograms 
+// - MHCalibrationCam::fAverageHiGainAreas
+// - MHCalibrationCam::fAverageHiGainSectors
+// 
+// Sets number of bins to MHCalibrationCam::fAverageNbins for:
+// - MHCalibrationCam::fAverageHiGainAreas
+// - MHCalibrationCam::fAverageHiGainSectors
+//
+Bool_t MHCalibrationTestTimeCam::ReInitHists(MParList *pList)
+{
+
+  MArrivalTime *signal = (MArrivalTime*)pList->FindObject("MArrivalTime");
+  if (!signal)
+  {
+      *fLog << err << "MArrivalTime not found... abort." << endl;
+      return kFALSE;
+  }
+
+  const Int_t npixels  = fGeom->GetNumPixels();
+  const Int_t nsectors = fGeom->GetNumSectors();
+  const Int_t nareas   = fGeom->GetNumAreas();
+
+  if (fHiGainArray->GetEntries()==0)
+  {
+      fHiGainArray->Expand(npixels);
+      for (Int_t i=0; i<npixels; i++)
+      {
+	  (*fHiGainArray)[i] = new MHCalibrationTestTimePix("Calibrated Events Time",
+                                                "TestTime Calibration Pixel");
+          InitHists((*this)[i],(*fBadPixels)[i],i);
+      }
+  }
+
+  if (fLoGainArray->GetEntries()==0)
+  {
+      fLoGainArray->Expand(npixels);
+      for (Int_t i=0; i<npixels; i++)
+      {
+	  (*fLoGainArray)[i] = new MHCalibrationTestTimePix("Calibrated Events Time",
+                                                "TestTime Calibration Pixel");
+          InitHists((*this)(i),(*fBadPixels)[i],i);
+      }
+  }
+
+
+  if (fAverageHiGainAreas->GetEntries()==0)
+  {
+    fAverageHiGainAreas->Expand(nareas);
+    
+    for (Int_t j=0; j<nareas; j++)
+      {
+        (*fAverageHiGainAreas)[j] = 
+          new MHCalibrationTestTimePix("MHCalibrationTestTimeAverageArea",
+                           "Average TestTime Calibrations Area Idx ");
+
+        GetAverageHiGainArea(j).GetHGausHist()->SetTitle("TestTime Calibrations Area Idx ");
+        GetAverageHiGainArea(j).SetNbins(fAverageNbins);
+        GetAverageHiGainArea(j).InitBins();
+        GetAverageHiGainArea(j).ChangeHistId(j);
+        GetAverageHiGainArea(j).SetEventFrequency(fPulserFrequency);
+
+        TH1F *h =  GetAverageHiGainArea(j).GetHGausHist();
+        h->SetTitle( Form("%s%s", h->GetTitle()," Runs: "));
+
+
+      }
+  }
+
+  if (fAverageLoGainAreas->GetEntries()==0)
+  {
+    fAverageLoGainAreas->Expand(nareas);
+    
+    for (Int_t j=0; j<nareas; j++)
+      {
+        (*fAverageLoGainAreas)[j] = 
+          new MHCalibrationTestTimePix("MHCalibrationTestTimeAverageArea",
+                           "Average TestTime Calibrations Area Idx ");
+
+        GetAverageLoGainArea(j).GetHGausHist()->SetTitle("TestTime Calibrations Area Idx ");
+        GetAverageLoGainArea(j).SetNbins(fAverageNbins);
+        GetAverageLoGainArea(j).InitBins();
+        GetAverageLoGainArea(j).ChangeHistId(j);
+        GetAverageLoGainArea(j).SetEventFrequency(fPulserFrequency);
+
+      }
+  }
+
+
+  if (fAverageHiGainSectors->GetEntries()==0)
+  {
+      fAverageHiGainSectors->Expand(nsectors);
+
+      for (Int_t j=0; j<nsectors; j++)
+      {
+	  (*fAverageHiGainSectors)[j] = 
+            new MHCalibrationTestTimePix("MHCalibrationTestTimeAverageSector",
+                             "Average TestTime Calibrations Sector ");
+
+          GetAverageHiGainSector(j).GetHGausHist()->SetTitle("TestTime Calibrations Sector ");
+          GetAverageHiGainSector(j).SetNbins(fAverageNbins);
+          GetAverageHiGainSector(j).InitBins();
+          GetAverageHiGainSector(j).ChangeHistId(j);
+          GetAverageHiGainSector(j).SetEventFrequency(fPulserFrequency);
+          TH1F *h =  GetAverageHiGainSector(j).GetHGausHist();
+          h->SetTitle( Form("%s%s", h->GetTitle()," Runs: "));
+
+
+      }
+  }
+
+
+  if (fAverageLoGainSectors->GetEntries()==0)
+  {
+      fAverageLoGainSectors->Expand(nsectors);
+
+      for (Int_t j=0; j<nsectors; j++)
+      {
+	  (*fAverageLoGainSectors)[j] = 
+            new MHCalibrationTestTimePix("MHCalibrationTestTimeAverageSector",
+                             "Average TestTime Calibrations Sector ");
+
+          GetAverageLoGainSector(j).GetHGausHist()->SetTitle("TestTime Calibrations Sector ");
+          GetAverageLoGainSector(j).SetNbins(fAverageNbins);
+          GetAverageLoGainSector(j).InitBins();
+          GetAverageLoGainSector(j).ChangeHistId(j);
+          GetAverageLoGainSector(j).SetEventFrequency(fPulserFrequency);
+      }
+  }
+    
+
+  return kTRUE;
+}
+
+
+// -------------------------------------------------------------------------------
+//
+// Retrieves pointer to MArrivalTime:
+//
+// Retrieves from MGeomCam:
+// - number of pixels
+// - number of pixel areas
+// - number of sectors
+//
+// Fills HiGain or LoGain histograms (MHGausEvents::FillHistAndArray()), respectively
+// depending on MCerPhotPix::IsLoGainUsed(), with:
+// - MCerPhotPix::GetArrivalTime(pixid) - MCerPhotPix::GetArrivalTime(1);
+//   (i.e. the time difference between pixel i and pixel 1 (hardware number: 2) )
+//
+Bool_t MHCalibrationTestTimeCam::FillHists(const MParContainer *par, const Stat_t w)
+{
+
+  MArrivalTime *calibration = (MArrivalTime*)par;
+  if (!calibration)
+    {
+      gLog << err << "No argument in MHCalibrationRelTimeCam::Fill... abort." << endl;
+      return kFALSE;
+    }
+
+  const Int_t npixels  = fGeom->GetNumPixels();
+  const Int_t nareas   = fGeom->GetNumAreas();
+  const Int_t nsectors = fGeom->GetNumSectors();
+
+  Float_t sumareahi  [nareas]; 
+  Float_t sumsectorhi[nsectors];
+  Int_t   numareahi  [nareas]; 
+  Int_t   numsectorhi[nsectors];
+
+  memset(sumareahi,   0, nareas * sizeof(Float_t));
+  memset(sumsectorhi, 0, nsectors*sizeof(Float_t));
+  memset(numareahi,   0, nareas * sizeof(Int_t));
+  memset(numsectorhi, 0, nsectors*sizeof(Int_t));
+  
+  for (Int_t i=0; i<npixels; i++)
+    {
+
+      MHGausEvents &histhi = (*this)[i];
+
+      if (histhi.IsExcluded())
+	continue;
+
+      const Float_t  time = (*calibration)[i];
+      const Int_t  aidx   = (*fGeom)[i].GetAidx();
+      const Int_t  sector = (*fGeom)[i].GetSector();
+
+      histhi.FillHistAndArray(time) ;
+      sumareahi  [aidx]   += time;
+      numareahi  [aidx]   ++;
+      sumsectorhi[sector] += time;
+      numsectorhi[sector] ++;
+    }
+  
+  for (Int_t j=0; j<nareas; j++)
+    {
+      MHGausEvents &histhi = GetAverageHiGainArea(j);
+      histhi.FillHistAndArray(numareahi[j] == 0 ? 0. : sumareahi[j]/numareahi[j]);
+
+    }
+  
+  for (Int_t j=0; j<nsectors; j++)
+    {
+      MHGausEvents &histhi = GetAverageHiGainSector(j);
+      histhi.FillHistAndArray(numsectorhi[j] == 0 ? 0. : sumsectorhi[j]/numsectorhi[j]);
+
+    }
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// 
+Bool_t MHCalibrationTestTimeCam::FinalizeHists()
+{
+
+  for (Int_t i=0; i<fHiGainArray->GetSize(); i++)
+    {
+      
+      MHGausEvents &hist = (*this)[i];
+      
+      if (hist.IsExcluded())
+        continue;
+      
+      if (hist.IsEmpty())
+        continue;
+      
+      if (!hist.FitGaus())
+        if (!hist.RepeatFit())
+          {
+            hist.BypassFit();
+          }
+      
+      hist.CreateFourierSpectrum();
+      
+    }
+  
+  for (Int_t j=0; j<fAverageHiGainAreas->GetSize(); j++)
+    {
+      
+      MHGausEvents     &hist = GetAverageHiGainArea(j);      
+      if (hist.IsEmpty())
+        continue;
+      
+      if (!hist.FitGaus())
+        if (!hist.RepeatFit())
+          {
+            hist.BypassFit();
+          }
+      
+      hist.CreateFourierSpectrum();
+      
+
+  }
+
+  for (Int_t j=0; j<fAverageHiGainSectors->GetSize(); j++)
+    {
+      
+      MHGausEvents     &hist = GetAverageHiGainSector(j);      
+      if (hist.IsEmpty())
+        continue;
+      
+      if (!hist.FitGaus())
+        if (!hist.RepeatFit())
+          {
+            hist.BypassFit();
+          }
+      hist.CreateFourierSpectrum();
+      
+
+    }
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+void MHCalibrationTestTimeCam::FinalizeBadPixels()
+{
+
+}
+
+// --------------------------------------------------------------------------
+//
+// The types are as follows:
+// 
+// Fitted values:
+// ============== 
+//
+// 0: Fitted Mean Time Calibration (MHGausEvents::GetMean())
+// 1: Error Mean Time Calibration  (MHGausEvents::GetMeanErr())
+// 2: Sigma fitted Time Calibration (MHGausEvents::GetSigma())
+// 3: Error Sigma Time Calibration (MHGausEvents::GetSigmaErr())
+//
+// Useful variables derived from the fit results:
+// =============================================
+//
+// 4: Returned probability of Gauss fit              (calls: MHGausEvents::GetProb())
+//
+// Localized defects:
+// ==================
+//
+// 5: Gaus fit not OK                               (calls: MHGausEvents::IsGausFitOK())
+// 6: Fourier spectrum not OK                       (calls: MHGausEvents::IsFourierSpectrumOK())
+//
+Bool_t MHCalibrationTestTimeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
+{
+
+  if (fHiGainArray->GetSize() <= idx)
+    return kFALSE;
+
+  const MHGausEvents &pix = (*this)[idx];
+
+  if (pix.IsExcluded())
+    return kFALSE;
+
+  switch (type)
+    {
+    case 0:
+      val = pix.GetMean();
+      break;
+    case 1:
+      val = pix.GetMeanErr();
+      break;
+    case 2:
+      val = pix.GetSigma();
+      break;
+    case 3:
+      val = pix.GetSigmaErr();
+      break;
+    case 4:
+      val = pix.GetProb();
+      break;
+    case 5:
+      if (!pix.IsGausFitOK())
+        val = 1.;
+      break;
+    case 6:
+      if (!pix.IsFourierSpectrumOK())
+        val = 1.;
+      break;
+    default:
+      return kFALSE;
+    }
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calls MHGausEvents::DrawClone() for pixel idx
+//
+void MHCalibrationTestTimeCam::DrawPixelContent(Int_t idx) const
+{
+ (*this)[idx].DrawClone();
+}
+
+
+//------------------------------------------------------------
+//
+// For all averaged areas, the fitted sigma is multiplied with the square root of 
+// the number involved pixels
+//
+void MHCalibrationTestTimeCam::CalcAverageSigma()
+{
+  
+  for (UInt_t j=0; j<fGeom->GetNumAreas(); j++)
+    {
+  
+      MHGausEvents &hist    = GetAverageHiGainArea(j);
+
+      const Float_t numsqr    = TMath::Sqrt((Float_t)fAverageAreaNum[j]);
+      fAverageAreaSigma[j]    = hist.GetSigma    () * numsqr;
+      fAverageAreaSigmaVar[j] = hist.GetSigmaErr () * hist.GetSigmaErr() * numsqr;
+
+      fAverageAreaRelSigma   [j]  = fAverageAreaSigma[j]    / hist.GetMean();
+      fAverageAreaRelSigmaVar[j]  = fAverageAreaSigmaVar[j] / (fAverageAreaSigma[j]*fAverageAreaSigma[j]);
+      fAverageAreaRelSigmaVar[j] += hist.GetMeanErr()*hist.GetMeanErr()/hist.GetMean()/hist.GetMean();
+      fAverageAreaRelSigmaVar[j] *= fAverageAreaRelSigma[j];
+    }
+}
Index: /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationTestTimeCam.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationTestTimeCam.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationTestTimeCam.h	(revision 9661)
@@ -0,0 +1,33 @@
+#ifndef MARS_MHCalibrationTestTimeCam
+#define MARS_MHCalibrationTestTimeCam
+
+#ifndef MARS_MHCalibrationCam
+#include "MHCalibrationCam.h"
+#endif
+
+class MGeomCam;
+class MHCalibrationTestTimeCam : public MHCalibrationCam
+{
+
+private:
+
+  Bool_t ReInitHists(MParList *pList);
+  Bool_t FillHists(const MParContainer *par, const Stat_t w=1);
+  Bool_t FinalizeHists();
+  void    FinalizeBadPixels();
+  
+public:
+
+  MHCalibrationTestTimeCam(const char *name=NULL, const char *title=NULL);
+  ~MHCalibrationTestTimeCam() {}
+
+  Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
+  void DrawPixelContent(Int_t idx) const;
+
+  void CalcAverageSigma();
+  
+  ClassDef(MHCalibrationTestTimeCam, 0)	// Histogram class for Relative Time Camera Calibration
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationTestTimePix.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationTestTimePix.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationTestTimePix.cc	(revision 9661)
@@ -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): Markus Gaug 05/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MHCalibrationTestTimePix
+//
+//  Histogram class for the charge calibration. 
+//  Stores and fits the charges and stores the location of the maximum FADC 
+//  slice. TestTimes are taken from MExtractedSignalPix.
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MHCalibrationTestTimePix.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHCalibrationTestTimePix);
+
+using namespace std;
+
+const Int_t   MHCalibrationTestTimePix::fgChargeNbins     = 600;
+const Axis_t  MHCalibrationTestTimePix::fgChargeFirst     = -0.5;
+const Axis_t  MHCalibrationTestTimePix::fgChargeLast      = 29.5;
+// --------------------------------------------------------------------------
+//
+// Default Constructor. 
+//
+// Sets: 
+// - the default number for fNbins        (fgChargeNbins)
+// - the default number for fFirst        (fgChargeFirst)
+// - the default number for fLast         (fgChargeLast)
+//
+// - the default name of the  fHGausHist ("HCalibrationTestTime")
+// - the default title of the fHGausHist ("Distribution of calibrated FADC slices Pixel ")
+// - the default x-axis title for fHGausHist ("Sum FADC Slices")
+// - the default y-axis title for fHGausHist ("Nr. of events")
+//
+// Calls:
+// - Clear();
+//
+MHCalibrationTestTimePix::MHCalibrationTestTimePix(const char *name, const char *title)
+{ 
+  
+  fName  = name  ? name  : "MHCalibrationTestTimePix";
+  fTitle = title ? title : "Statistics of the calibrated FADC sums of calibration events";
+
+  SetNbins ( fgChargeNbins );
+  SetFirst ( fgChargeFirst );
+  SetLast  ( fgChargeLast  );
+
+  fHGausHist.SetName("HCalibrationTestTime");
+  fHGausHist.SetTitle("Distribution of calibrated Arrival Times Pixel");  
+  fHGausHist.SetXTitle("Arrival Time [FADC units]");
+  fHGausHist.SetYTitle("Nr. of events");
+
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Empty function to overload MHGausEvents::Reset()
+//
+void MHCalibrationTestTimePix::Reset()
+{
+}
+
Index: /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationTestTimePix.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationTestTimePix.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MHCalibrationTestTimePix.h	(revision 9661)
@@ -0,0 +1,28 @@
+#ifndef MARS_MHCalibrationTestTimePix
+#define MARS_MHCalibrationTestTimePix
+
+#ifndef MARS_MHGausEvents
+#include "MHGausEvents.h"
+#endif
+
+class TH1F;
+class MHCalibrationTestTimePix : public MHGausEvents
+{
+
+private:
+
+  static const Int_t   fgChargeNbins;        // Default for fNBins          (now set to: 2000  )
+  static const Axis_t  fgChargeFirst;        // Default for fFirst          (now set to: -0.5  )
+  static const Axis_t  fgChargeLast;         // Default for fLast           (now set to: 1999.5)
+
+public:
+
+  MHCalibrationTestTimePix(const char *name=NULL, const char *title=NULL);
+  ~MHCalibrationTestTimePix() {}
+
+  virtual void Reset();  
+  
+  ClassDef(MHCalibrationTestTimePix, 1)     // Base Histogram class for TestTime Pixel Calibration
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mcalib/MHGausEvents.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MHGausEvents.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MHGausEvents.cc	(revision 9661)
@@ -0,0 +1,1006 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug 02/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MHGausEvents
+//
+//  A base class for events which are believed to follow a Gaussian distribution 
+//  with time, e.g. calibration events, observables containing white noise, ...
+//
+//  MHGausEvents derives from MH, thus all features of MH can be used by a class 
+//  deriving from MHGausEvents, especially the filling functions. 
+//
+//  The central objects are: 
+//
+//  1) The TH1F fHGausHist: 
+//     ====================
+//   
+//     It is created with a default name and title and resides in directory NULL.
+//     - Any class deriving from MHGausEvents needs to apply a binning to fHGausHist
+//       (e.g. by setting the variables fNbins, fFirst, fLast and calling the function 
+//       InitBins() or by directly calling fHGausHist.SetBins(..) )
+//     - The histogram is filled with the functions FillHist() or FillHistAndArray(). 
+//     - The histogram can be fitted with the function FitGaus(). This involves stripping 
+//       of all zeros at the lower and upper end of the histogram and re-binning to 
+//       a new number of bins, specified in the variable fBinsAfterStripping.      
+//     - The fit result's probability is compared to a reference probability fProbLimit
+//       The NDF is compared to fNDFLimit and a check is made whether results are NaNs. 
+//       Accordingly, a flag IsGausFitOK() is set.
+//     - One can repeat the fit within a given amount of sigmas from the previous mean 
+//       (specified by the variables fPickupLimit and fBlackoutLimit) with the function RepeatFit()
+//     - One can completely skip the fitting to set mean, sigma and its errors directly 
+//       from the histograms with the function BypassFit()
+// 
+//  2) The TArrayF fEvents:
+//     ==========================
+// 
+//     It is created with 0 entries and not expanded unless FillArray() or FillHistAndArray()
+//     are called.
+//     - A first call to FillArray() or FillHistAndArray() initializes fEvents by default 
+//       to 512 entries. 
+//     - Any later call to FillArray() or FillHistAndArray() fills up the array. 
+//       Reaching the limit, the array is expanded by a factor 2.
+//     - The array can be fourier-transformed into the array fPowerSpectrum. 
+//       Note that any FFT accepts only number of events which are a power of 2. 
+//       Thus, fEvents is cut to the next power of 2 smaller than its actual number of entries. 
+//       Be aware that you might lose information at the end of your analysis. 
+//     - Calling the function CreateFourierSpectrum() creates the array fPowerSpectrum 
+//       and its projection fHPowerProbability which in turn is fit to an exponential. 
+//     - The fit result's probability is compared to a referenc probability fProbLimit 
+//       and accordingly the flag IsExpFitOK() is set.
+//     - The flag IsFourierSpectrumOK() is set accordingly to IsExpFitOK(). 
+//       Later, a closer check will be installed. 
+//     - You can display all arrays by calls to: CreateGraphEvents() and 
+//       CreateGraphPowerSpectrum() and successive calls to the corresponding Getters.
+//
+// To see an example, have a look at: Draw()
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MHGausEvents.h"
+
+#include <TH1.h>
+#include <TF1.h>
+#include <TGraph.h>
+#include <TPad.h>
+#include <TVirtualPad.h>
+#include <TCanvas.h>
+#include <TStyle.h>
+
+#include "MFFT.h"
+#include "MArray.h"
+
+#include "MH.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHGausEvents);
+
+using namespace std;
+
+const Int_t    MHGausEvents::fgBinsAfterStripping   = 40;
+const Float_t  MHGausEvents::fgBlackoutLimit        = 5.;
+const Int_t    MHGausEvents::fgNDFLimit             = 2;
+const Float_t  MHGausEvents::fgPickupLimit          = 5.;
+const Float_t  MHGausEvents::fgProbLimit            = 0.001;
+const Int_t    MHGausEvents::fgPowerProbabilityBins = 20;
+// --------------------------------------------------------------------------
+//
+// Default Constructor. 
+// Sets: 
+// - the default Probability Bins for fPowerProbabilityBins (fgPowerProbabilityBins)
+// - the default Probability Limit for fProbLimit  (fgProbLimit)
+// - the default NDF Limit for fNDFLimit           (fgNDFLimit)
+// - the default number for fPickupLimit           (fgPickupLimit)
+// - the default number for fBlackoutLimit         (fgBlackoutLimit)
+// - the default number of bins after stripping for fBinsAfterStipping (fgBinsAfterStipping)
+// - the default name of the fHGausHist            ("HGausHist")
+// - the default title of the fHGausHist           ("Histogram of Events with Gaussian Distribution")
+// - the default directory of the fHGausHist       (NULL)
+// - the default for fNbins (100)
+// - the default for fFirst (0.)
+// - the default for fLast  (100.)
+//
+// Initializes:
+// - fEvents to 0 entries
+// - fHGausHist()
+// - all other pointers to NULL
+// - all variables to 0.
+// - all flags to kFALSE
+//
+MHGausEvents::MHGausEvents(const char *name, const char *title)
+    : fEventFrequency(0), fHPowerProbability(NULL), 
+      fPowerSpectrum(NULL),
+      fGraphEvents(NULL), fGraphPowerSpectrum(NULL),
+      fFGausFit(NULL), fFExpFit(NULL),
+      fFirst(0.), fLast(100.), 
+      fNbins(100), fPixId(-1)
+{ 
+
+  fName  = name  ? name  : "MHGausEvents";
+  fTitle = title ? title : "Events with expected Gaussian distributions";
+
+  Clear();
+  
+  SetBinsAfterStripping();
+  SetBlackoutLimit();
+  SetNDFLimit();
+  SetPickupLimit();
+  SetPowerProbabilityBins();
+  SetProbLimit();
+
+  fHGausHist.SetName("HGausHist");
+  fHGausHist.SetTitle("Histogram of Events with Gaussian Distribution");
+  // important, other ROOT will not draw the axes:
+  fHGausHist.UseCurrentStyle();
+  fHGausHist.SetDirectory(NULL);
+  fHGausHist.GetYaxis()->CenterTitle();
+}
+
+
+
+// --------------------------------------------------------------------------
+//
+// Default Destructor. 
+//
+// Deletes (if Pointer is not NULL):
+// 
+// - fHPowerProbability
+// - fFGausFit 
+// - fFExpFit
+// - fPowerSpectrum     
+// - fGraphEvents
+// - fGraphPowerSpectrum
+// 
+MHGausEvents::~MHGausEvents()
+{
+
+  // delete histograms
+//  if (fHPowerProbability)
+//      if (gROOT->FindObject(fHPowerProbability->GetName()))
+//	  delete fHPowerProbability;
+  
+  // delete fits
+  if (fFGausFit)
+    delete fFGausFit; 
+  if (fFExpFit)
+    delete fFExpFit;
+  
+  // delete arrays
+  if (fPowerSpectrum)  
+    delete fPowerSpectrum;     
+
+  // delete graphs
+  if (fGraphEvents)
+    delete fGraphEvents;
+  if (fGraphPowerSpectrum)
+    delete fGraphPowerSpectrum;
+}
+      
+// --------------------------------------------------------------------------
+//
+// Default Clear(), can be overloaded.
+//
+// Sets:
+// - all other pointers to NULL
+// - all variables to 0., except fPixId to -1 and keep fEventFrequency
+// - all flags to kFALSE
+// 
+// Deletes (if not NULL):
+// - all pointers
+//
+void MHGausEvents::Clear(Option_t *o)
+{
+
+  SetGausFitOK        ( kFALSE );
+  SetExpFitOK         ( kFALSE );
+  SetFourierSpectrumOK( kFALSE );
+  SetExcluded         ( kFALSE );
+
+  fMean              = 0.;
+  fSigma             = 0.;
+  fMeanErr           = 0.;
+  fSigmaErr          = 0.;
+  fProb              = 0.;
+  
+  fCurrentSize       = 0;
+
+  if (fHPowerProbability)
+    {
+	if (gROOT->FindObject(fHPowerProbability->GetName()))
+	    delete fHPowerProbability;
+	fHPowerProbability = NULL;
+    }
+  
+  // delete fits
+  if (fFGausFit)
+    {
+      delete fFGausFit; 
+      fFGausFit = NULL;
+    }
+  
+  if (fFExpFit)
+    {
+      delete fFExpFit;
+      fFExpFit = NULL;
+    }
+  
+  // delete arrays
+  if (fPowerSpectrum)  
+    {
+      delete fPowerSpectrum;     
+      fPowerSpectrum = NULL;
+    }
+
+  // delete graphs
+  if (fGraphEvents)
+    {
+      delete fGraphEvents;
+      fGraphEvents = NULL;
+    }
+
+  if (fGraphPowerSpectrum)
+    {
+      delete fGraphPowerSpectrum;
+      fGraphPowerSpectrum = NULL;
+    }
+}
+
+
+// -----------------------------------------------------------------------------
+// 
+// Bypasses the Gauss fit by taking mean and RMS from the histogram
+//
+// Errors are determined in the following way:
+// MeanErr  = RMS / Sqrt(entries)
+// SigmaErr = RMS / (2.*Sqrt(entries) )
+//
+void MHGausEvents::BypassFit()
+{
+
+  const Stat_t entries = fHGausHist.GetEntries();
+  
+  if (entries <= 0.)
+    {
+      *fLog << warn << GetDescriptor() 
+            << ": Cannot bypass fit. Number of entries smaller or equal 0 in pixel: " << fPixId << endl;
+      return;
+    }
+  
+  fMean     = fHGausHist.GetMean();
+  fMeanErr  = fHGausHist.GetRMS() / TMath::Sqrt(entries);
+  fSigma    = fHGausHist.GetRMS() ;
+  fSigmaErr = fHGausHist.GetRMS() / TMath::Sqrt(entries) / 2.;
+}
+
+
+
+// --------------------------------------------------------------------------
+//
+// - Set fPixId to id
+//
+// Add id to names and titles of:
+// - fHGausHist
+//
+void MHGausEvents::ChangeHistId(const Int_t id)
+{
+
+  fPixId = id;
+
+  fHGausHist.SetName(  Form("%s%d", fHGausHist.GetName(),  id));
+  fHGausHist.SetTitle( Form("%s%d", fHGausHist.GetTitle(), id));
+
+  fName  = Form("%s%d", fName.Data(),  id);
+  fTitle = Form("%s%d", fTitle.Data(), id);
+
+}
+
+// -----------------------------------------------------------------------------
+// 
+// Create the x-axis for the event graph
+//
+Float_t *MHGausEvents::CreateEventXaxis(Int_t n)
+{
+
+  Float_t *xaxis = new Float_t[n];  fHPowerProbability->SetDirectory(NULL);
+
+  if (fEventFrequency)
+    for (Int_t i=0;i<n;i++)
+      xaxis[i] = (Float_t)i/fEventFrequency;
+  else
+    for (Int_t i=0;i<n;i++)
+      xaxis[i] = (Float_t)i;
+
+  return xaxis;
+                 
+}
+
+
+// -------------------------------------------------------------------
+//
+// Create the fourier spectrum using the class MFFT.
+// The result is projected into a histogram and fitted by an exponential
+//   fHPowerProbability->SetDirectory(NULL);
+void MHGausEvents::CreateFourierSpectrum()
+{
+
+  if (fFExpFit)
+    return;
+
+  if (fEvents.GetSize() < 8)
+    {
+      *fLog << warn << "Cannot create Fourier spectrum in pixel: " << fPixId 
+            << ". Number of events smaller than 8 " << endl;
+      return;
+    }
+  
+
+  //
+  // The number of entries HAS to be a potence of 2, 
+  // so we can only cut out from the last potence of 2 to the rest. 
+  // Another possibility would be to fill everything with 
+  // zeros, but that gives a low frequency peak, which we would 
+  // have to cut out later again. 
+  //
+  // So, we have to live with the possibility that at the end 
+  // of the calibration run, something has happened without noticing 
+  // it...
+  //
+  
+  // This cuts only the non-used zero's, but MFFT will later cut the rest
+  MArray::StripZeros(fEvents);
+
+  if (fEvents.GetSize() < 8)
+    {
+      /*
+      *fLog << warn << "Cannot create Fourier spectrum. " << endl;
+      *fLog << warn << "Number of events (after stripping of zeros) is smaller than 8 " 
+            << "in pixel: " << fPixId << endl;
+      */
+      return;
+    }
+
+  MFFT fourier;
+
+  fPowerSpectrum     = fourier.PowerSpectrumDensity(&fEvents);
+  fHPowerProbability = ProjectArray(*fPowerSpectrum, fPowerProbabilityBins,
+                                    Form("%s%s","PowerProbability",GetName()),
+                                    "Probability of Power occurrance");
+  fHPowerProbability->SetXTitle("P(f)");
+  fHPowerProbability->SetYTitle("Counts");
+  fHPowerProbability->GetYaxis()->CenterTitle();
+  fHPowerProbability->SetDirectory(NULL);
+  fHPowerProbability->SetBit(kCanDelete);  
+  //
+  // First guesses for the fit (should be as close to reality as possible, 
+  //
+  const Double_t xmax = fHPowerProbability->GetXaxis()->GetXmax();
+
+  fFExpFit = new TF1("FExpFit","exp([0]-[1]*x)",0.,xmax);
+
+  const Double_t slope_guess  = (TMath::Log(fHPowerProbability->GetEntries())+1.)/xmax;
+  const Double_t offset_guess = slope_guess*xmax;
+
+  fFExpFit->SetParameters(offset_guess, slope_guess);
+  fFExpFit->SetParNames("Offset","Slope");
+  fFExpFit->SetParLimits(0,offset_guess/2.,2.*offset_guess);
+  fFExpFit->SetParLimits(1,slope_guess/1.5,1.5*slope_guess);
+  fFExpFit->SetRange(0.,xmax);
+
+  fHPowerProbability->Fit(fFExpFit,"RQL0");
+  
+  if (GetExpProb() > fProbLimit)
+    SetExpFitOK(kTRUE);
+  
+  //
+  // For the moment, this is the only check, later we can add more...
+  //
+  SetFourierSpectrumOK(IsExpFitOK());
+
+  return;
+}
+
+// ----------------------------------------------------------------------------------
+//
+// Create a graph to display the array fEvents
+// If the variable fEventFrequency is set, the x-axis is transformed into real time.
+//
+void MHGausEvents::CreateGraphEvents()
+{
+
+  MArray::StripZeros(fEvents);
+
+  const Int_t n = fEvents.GetSize();
+
+  fGraphEvents = new TGraph(n,CreateEventXaxis(n),fEvents.GetArray());  
+  fGraphEvents->SetTitle("Evolution of Events with time");
+  fGraphEvents->GetXaxis()->SetTitle((fEventFrequency) ? "Time [s]" : "Event Nr.");
+  fGraphEvents->GetYaxis()->SetTitle(fHGausHist.GetXaxis()->GetTitle());
+  fGraphEvents->GetYaxis()->CenterTitle();
+}
+
+// ----------------------------------------------------------------------------------
+//
+// Create a graph to display the array fPowerSpectrum
+// If the variable fEventFrequency is set, the x-axis is transformed into real frequency.
+//
+void MHGausEvents::CreateGraphPowerSpectrum()
+{
+
+  MArray::StripZeros(*fPowerSpectrum);
+
+  const Int_t n = fPowerSpectrum->GetSize();
+
+  fGraphPowerSpectrum = new TGraph(n,CreatePSDXaxis(n),fPowerSpectrum->GetArray());  
+  fGraphPowerSpectrum->SetTitle("Power Spectrum Density");
+  fGraphPowerSpectrum->GetXaxis()->SetTitle((fEventFrequency) ? "Frequency [Hz]" : "Frequency");
+  fGraphPowerSpectrum->GetYaxis()->SetTitle("P(f)");
+  fGraphPowerSpectrum->GetYaxis()->CenterTitle();
+
+}
+
+
+// -----------------------------------------------------------------------------
+// 
+// Create the x-axis for the event graph
+//
+Float_t *MHGausEvents::CreatePSDXaxis(Int_t n)
+{
+
+  Float_t *xaxis = new Float_t[n];
+
+  if (fEventFrequency)
+    for (Int_t i=0;i<n;i++)
+      xaxis[i] = 0.5*(Float_t)i*fEventFrequency/n;
+  else
+    for (Int_t i=0;i<n;i++)
+      xaxis[i] = 0.5*(Float_t)i/n;
+
+  return xaxis;
+                 
+}
+  
+// -----------------------------------------------------------------------------
+// 
+// Default draw:
+//
+// The following options can be chosen:
+//
+// "EVENTS": displays a TGraph of the array fEvents
+// "FOURIER": display a TGraph of the fourier transform of fEvents 
+//            displays the projection of the fourier transform with the fit
+//
+// The following picture shows a typical outcome of call to Draw("fourierevents"): 
+// - The first plot shows the distribution of the values with the Gauss fit
+//   (which did not succeed, in this case, for obvious reasons)
+// - The second plot shows the TGraph with the events vs. time
+// - The third plot shows the fourier transform and a small peak at about 85 Hz.
+// - The fourth plot shows the projection of the fourier components and an exponential 
+//   fit, with the result that the observed deviation is still statistical with a 
+//   probability of 0.5%. 
+//
+//Begin_Html
+/*
+<img src="images/MHGausEventsDraw.gif">
+*/
+//End_Html
+//
+void MHGausEvents::Draw(const Option_t *opt)
+{
+
+  TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this,600, 900);
+
+  TString option(opt);
+  option.ToLower();
+  
+  Int_t win = 1;
+
+  if (option.Contains("events"))
+    {
+      option.ReplaceAll("events","");
+      win += 1;
+    }
+  if (option.Contains("fourier"))
+    {
+      option.ReplaceAll("fourier","");
+      win += 2;
+    }
+  
+  pad->SetBorderMode(0);
+  pad->Divide(1,win);
+  pad->cd(1);
+
+  if (!IsEmpty())
+    gPad->SetLogy();
+
+  gPad->SetTicks();
+
+  fHGausHist.Draw(opt);
+
+  if (fFGausFit)
+    {
+      fFGausFit->SetLineColor(IsGausFitOK() ? kGreen : kRed);
+      fFGausFit->Draw("same");
+    }
+  switch (win)
+    {
+    case 2:
+      pad->cd(2);
+      DrawEvents();
+      break;
+    case 3:
+      pad->cd(2);
+      DrawPowerSpectrum(*pad,3);
+      break;
+    case 4:
+      pad->cd(2);
+      DrawEvents();
+      pad->cd(3);
+      DrawPowerSpectrum(*pad,4);
+      break;
+    }
+}
+
+void MHGausEvents::DrawEvents()
+{
+  
+  if (!fGraphEvents)
+    CreateGraphEvents();
+
+  fGraphEvents->SetBit(kCanDelete);
+  fGraphEvents->SetTitle("Events with time");
+  fGraphEvents->Draw("AL");
+  
+}
+
+
+void MHGausEvents::DrawPowerSpectrum(TVirtualPad &pad, Int_t i)
+{
+  
+  if (fPowerSpectrum)
+    {
+      if (!fGraphPowerSpectrum)
+        CreateGraphPowerSpectrum();
+      
+      fGraphPowerSpectrum->Draw("AL");          
+      fGraphPowerSpectrum->SetBit(kCanDelete);
+    }
+  
+  pad.cd(i);
+
+  if (fHPowerProbability && fHPowerProbability->GetEntries() > 0)
+    {
+      gPad->SetLogy();
+      fHPowerProbability->Draw();
+      if (fFExpFit)
+        {
+          fFExpFit->SetLineColor(IsExpFitOK() ? kGreen : kRed);
+          fFExpFit->Draw("same");
+        }
+    }
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Fill fEvents with f
+// If size of fEvents is 0, initializes it to 512
+// If size of fEvents is smaller than fCurrentSize, double the size
+// Increase fCurrentSize by 1
+//
+void MHGausEvents::FillArray(const Float_t f)
+{
+  if (fEvents.GetSize() == 0)
+    fEvents.Set(512);
+
+  if (fCurrentSize >= fEvents.GetSize())
+    fEvents.Set(fEvents.GetSize()*2);
+  
+  fEvents.AddAt(f,fCurrentSize++);
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Fills fHGausHist with f
+// Returns kFALSE, if overflow or underflow occurred, else kTRUE
+//
+Bool_t MHGausEvents::FillHist(const Float_t f)
+{
+  return fHGausHist.Fill(f) > -1;
+}
+
+// --------------------------------------------------------------------------
+//
+// Executes:
+// - FillArray()
+// - FillHist()
+//
+Bool_t MHGausEvents::FillHistAndArray(const Float_t f)
+{
+
+  FillArray(f);
+  return FillHist(f);
+}
+
+// -------------------------------------------------------------------
+//
+// Fit fGausHist with a Gaussian after stripping zeros from both ends 
+// and rebinned to the number of bins specified in fBinsAfterStripping
+//
+// The fit results are retrieved and stored in class-own variables.  
+//
+// A flag IsGausFitOK() is set according to whether the fit probability 
+// is smaller or bigger than fProbLimit, whether the NDF is bigger than 
+// fNDFLimit and whether results are NaNs.
+//
+Bool_t MHGausEvents::FitGaus(Option_t *option, const Double_t xmin, const Double_t xmax)
+{
+
+  if (IsGausFitOK())
+    return kTRUE;
+
+  //
+  // First, strip the zeros from the edges which contain only zeros and rebin 
+  // to about fBinsAfterStripping bins. 
+  //
+  // (ATTENTION: The Chisquare method is more sensitive, 
+  // the _less_ bins, you have!)
+  //
+  StripZeros(&fHGausHist,fBinsAfterStripping);
+  
+  TAxis *axe = fHGausHist.GetXaxis();
+  //
+  // Get the fitting ranges
+  //
+  Axis_t rmin = ((xmin==0.) && (xmax==0.)) ? fHGausHist.GetBinCenter(axe->GetFirst()) : xmin;
+  Axis_t rmax = ((xmin==0.) && (xmax==0.)) ? fHGausHist.GetBinCenter(axe->GetLast())  : xmax;
+
+  //
+  // First guesses for the fit (should be as close to reality as possible, 
+  //
+  const Stat_t   entries     = fHGausHist.Integral(axe->FindBin(rmin),axe->FindBin(rmax),"width");
+  const Double_t mu_guess    = fHGausHist.GetBinCenter(fHGausHist.GetMaximumBin());
+  const Double_t sigma_guess = fHGausHist.GetRMS();
+  const Double_t area_guess  = entries/TMath::Sqrt(TMath::TwoPi())/sigma_guess;
+
+  fFGausFit = new TF1("GausFit","gaus",rmin,rmax);
+
+  if (!fFGausFit) 
+    {
+    *fLog << warn << dbginf << "WARNING: Could not create fit function for Gauss fit " 
+          << "in pixel: " << fPixId << endl;
+    return kFALSE;
+    }
+  
+  fFGausFit->SetParameters(area_guess,mu_guess,sigma_guess);
+  fFGausFit->SetParNames("Area","#mu","#sigma");
+  fFGausFit->SetParLimits(0,0.,area_guess*25.);
+  fFGausFit->SetParLimits(1,rmin,rmax);
+  fFGausFit->SetParLimits(2,0.,rmax-rmin);
+  fFGausFit->SetRange(rmin,rmax);
+
+  fHGausHist.Fit(fFGausFit,option);
+
+
+  fMean     = fFGausFit->GetParameter(1);
+  fSigma    = fFGausFit->GetParameter(2);
+  fMeanErr  = fFGausFit->GetParError(1);
+  fSigmaErr = fFGausFit->GetParError(2);
+  fProb     = fFGausFit->GetProb();
+  //
+  // The fit result is accepted under condition:
+  // 1) The results are not nan's
+  // 2) The NDF is not smaller than fNDFLimit (default: fgNDFLimit)
+  // 3) The Probability is greater than fProbLimit (default: fgProbLimit)
+  //
+  if (   TMath::IsNaN(fMean) 
+      || TMath::IsNaN(fMeanErr)
+      || TMath::IsNaN(fProb)    
+      || TMath::IsNaN(fSigma)
+      || TMath::IsNaN(fSigmaErr) 
+      || fFGausFit->GetNDF() < fNDFLimit 
+      || fProb < fProbLimit )
+    return kFALSE;
+  
+  SetGausFitOK(kTRUE);
+  return kTRUE;
+}
+
+// -------------------------------------------------------------------------------
+//
+// Return the number of "blackout" events, which are events with values higher 
+// than fBlackoutLimit sigmas from the mean
+//
+//
+const Double_t MHGausEvents::GetBlackout() const 
+{
+  
+  if ((fMean == 0.) && (fSigma == 0.))
+    return -1.;
+
+  const Int_t first = fHGausHist.GetXaxis()->GetFirst();
+  const Int_t last  = fHGausHist.GetXaxis()->FindBin(fMean-fBlackoutLimit*fSigma);
+
+  if (first >= last)
+    return 0.;
+  
+  return fHGausHist.Integral(first, last, "width");
+}
+
+const Double_t MHGausEvents::GetChiSquare()  const 
+{
+  return ( fFGausFit ? fFGausFit->GetChisquare() : 0.);
+}
+
+
+const Double_t MHGausEvents::GetExpChiSquare()  const 
+{
+  return ( fFExpFit ? fFExpFit->GetChisquare() : 0.);
+}
+
+
+const Int_t MHGausEvents::GetExpNdf()  const 
+{
+  return ( fFExpFit ? fFExpFit->GetNDF() : 0);
+}
+
+
+const Double_t MHGausEvents::GetExpProb()  const 
+{
+  return ( fFExpFit ? fFExpFit->GetProb() : 0.);
+}
+
+
+const Int_t MHGausEvents::GetNdf() const 
+{
+  return ( fFGausFit ? fFGausFit->GetNDF() : 0);
+}
+
+const Double_t MHGausEvents::GetOffset()  const 
+{
+  return ( fFExpFit ? fFExpFit->GetParameter(0) : 0.);
+}
+
+
+// -------------------------------------------------------------------------------
+//
+// Return the number of "pickup" events, which are events with values higher 
+// than fPickupLimit sigmas from the mean
+//
+//
+const Double_t MHGausEvents::GetPickup() const 
+{
+  
+  if ((fMean == 0.) && (fSigma == 0.))
+    return -1.;
+
+  const Int_t first = fHGausHist.GetXaxis()->FindBin(fMean+fPickupLimit*fSigma);
+  const Int_t last  = fHGausHist.GetXaxis()->GetLast();
+
+  if (first >= last)
+    return 0.;
+  
+  return fHGausHist.Integral(first, last, "width");
+}
+
+
+const Double_t MHGausEvents::GetSlope()  const 
+{
+  return ( fFExpFit ? fFExpFit->GetParameter(1) : 0.);
+}
+
+// --------------------------------------------------------------------------
+//
+// Default InitBins, can be overloaded.
+//
+// Executes:
+// - fHGausHist.SetBins(fNbins,fFirst,fLast)
+//
+void MHGausEvents::InitBins()
+{
+  fHGausHist.SetBins(fNbins,fFirst,fLast);
+}
+
+const Bool_t MHGausEvents::IsEmpty() const
+{
+    return !(fHGausHist.GetEntries());
+}
+
+
+const Bool_t MHGausEvents::IsExcluded() const
+{
+  return TESTBIT(fFlags,kExcluded);
+}
+
+
+const Bool_t MHGausEvents::IsExpFitOK() const 
+{
+  return TESTBIT(fFlags,kExpFitOK);
+}
+
+const Bool_t MHGausEvents::IsFourierSpectrumOK() const 
+{
+  return TESTBIT(fFlags,kFourierSpectrumOK);
+}
+
+
+const Bool_t MHGausEvents::IsGausFitOK() const 
+{
+  return TESTBIT(fFlags,kGausFitOK);
+}
+
+
+// -----------------------------------------------------------------------------------
+// 
+// A default print
+//
+void MHGausEvents::Print(const Option_t *o) const 
+{
+  
+  *fLog << all                                                        << endl;
+  *fLog << all << "Results of the Gauss Fit in pixel: " << fPixId     << endl;
+  *fLog << all << "Mean: "             << GetMean()                   << endl;
+  *fLog << all << "Sigma: "            << GetSigma()                  << endl;
+  *fLog << all << "Chisquare: "        << GetChiSquare()              << endl;
+  *fLog << all << "DoF: "              << GetNdf()                    << endl;
+  *fLog << all << "Probability: "      << GetProb()                   << endl;
+  *fLog << all                                                        << endl;
+  
+}
+
+// --------------------------------------------------------------------------
+//
+// Re-normalize the results, has to be overloaded
+//
+void  MHGausEvents::Renorm()
+{
+}
+
+// -----------------------------------------------------------------------------
+//
+// If flag IsGausFitOK() is set (histogram already successfully fitted), 
+// returns kTRUE
+// 
+// If both fMean and fSigma are still zero, call FitGaus() 
+// 
+// Repeats the Gauss fit in a smaller range, defined by: 
+// 
+// min = GetMean() - fBlackoutLimit * GetSigma();
+// max = GetMean() + fPickupLimit   * GetSigma();
+//
+// The fit results are retrieved and stored in class-own variables.  
+//
+// A flag IsGausFitOK() is set according to whether the fit probability 
+// is smaller or bigger than fProbLimit, whether the NDF is bigger than 
+// fNDFLimit and whether results are NaNs.
+//
+Bool_t MHGausEvents::RepeatFit(const Option_t *option)
+{
+
+  if (IsGausFitOK())
+    return kTRUE;
+
+  if ((fMean == 0.) && (fSigma == 0.))
+    return FitGaus();
+
+  //
+  // Get new fitting ranges
+  //
+  Axis_t rmin = fMean - fBlackoutLimit * fSigma;
+  Axis_t rmax = fMean + fPickupLimit   * fSigma;
+
+  Axis_t hmin = fHGausHist.GetBinCenter(fHGausHist.GetXaxis()->GetFirst());
+  Axis_t hmax = fHGausHist.GetBinCenter(fHGausHist.GetXaxis()->GetLast()) ;
+
+  fFGausFit->SetRange(hmin < rmin ? rmin : hmin , hmax > rmax ? rmax : hmax);
+
+  fHGausHist.Fit(fFGausFit,option);
+
+  fMean     = fFGausFit->GetParameter(1);
+  fSigma    = fFGausFit->GetParameter(2);
+  fMeanErr  = fFGausFit->GetParError(1) ; 
+  fSigmaErr = fFGausFit->GetParError(2) ; 
+  fProb     = fFGausFit->GetProb()      ;      
+
+  //
+  // The fit result is accepted under condition:
+  // 1) The results are not nan's
+  // 2) The NDF is not smaller than fNDFLimit (default: fgNDFLimit)
+  // 3) The Probability is greater than fProbLimit (default: fgProbLimit)
+  //
+  if (   TMath::IsNaN ( fMean     ) 
+      || TMath::IsNaN ( fMeanErr  )
+      || TMath::IsNaN ( fProb     )    
+      || TMath::IsNaN ( fSigma    )
+      || TMath::IsNaN ( fSigmaErr ) 
+      || fFGausFit->GetNDF() < fNDFLimit 
+      || fProb < fProbLimit )
+    return kFALSE;
+  
+  SetGausFitOK(kTRUE);
+  return kTRUE;
+
+}
+
+// --------------------------------------------------------------------------
+//
+// Default Reset(), can be overloaded.
+//
+// Executes:
+// - Clear()
+// - fHGausHist.Reset()
+// - fEvents.Set(0)
+//
+void MHGausEvents::Reset()
+{
+
+  Clear();
+  fHGausHist.Reset();
+  fEvents.Set(0);
+
+}
+
+// --------------------------------------------------------------------------
+//
+// Set Excluded bit from outside
+//
+void MHGausEvents::SetExcluded(const Bool_t b)
+{
+    b ? SETBIT(fFlags,kExcluded) : CLRBIT(fFlags,kExcluded);
+}
+
+
+// -------------------------------------------------------------------
+//
+// The flag setters are to be used ONLY for Monte-Carlo!!
+//
+void  MHGausEvents::SetExpFitOK(const Bool_t b)
+{
+  
+  b ? SETBIT(fFlags,kExpFitOK) : CLRBIT(fFlags,kExpFitOK);  
+}
+
+// -------------------------------------------------------------------
+//
+// The flag setters are to be used ONLY for Monte-Carlo!!
+//
+void  MHGausEvents::SetFourierSpectrumOK(const Bool_t b)
+{
+
+  b ? SETBIT(fFlags,kFourierSpectrumOK) : CLRBIT(fFlags,kFourierSpectrumOK);    
+}
+
+
+// -------------------------------------------------------------------
+//
+// The flag setters are to be used ONLY for Monte-Carlo!!
+//
+void  MHGausEvents::SetGausFitOK(const Bool_t b)
+{
+  b ? SETBIT(fFlags,kGausFitOK) : CLRBIT(fFlags,kGausFitOK);
+
+}
+
Index: /tags/Mars_V0-8-5/Mars/mcalib/MHGausEvents.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MHGausEvents.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MHGausEvents.h	(revision 9661)
@@ -0,0 +1,174 @@
+#ifndef MARS_MHGausEvents
+#define MARS_MHGausEvents
+
+#ifndef ROOT_TH1
+#include <TH1.h>
+#endif
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+class TVirtualPad;
+class TGraph;
+class TArrayF;
+class TH1F;
+class TH1I;
+class TF1;
+class MHGausEvents : public MH
+{
+private:
+
+  const static Int_t    fgBinsAfterStripping;   //! Default for fBinsAfterStripping   (now set to: 40)
+  const static Float_t  fgBlackoutLimit;        //! Default for fBlackoutLimit        (now set to: 5. )
+  const static Int_t    fgNDFLimit;             //! Default for fNDFLimit             (now set to: 2)
+  const static Float_t  fgProbLimit;            //! Default for fProbLimit            (now set to: 0.001)
+  const static Float_t  fgPickupLimit;          //! Default for fPickupLimit          (now set to: 5. )
+  const static Int_t    fgPowerProbabilityBins; //! Default for fPowerProbabilityBins (now set to: 20)
+  
+  Int_t    fBinsAfterStripping;        // Bins for the Gauss Histogram after stripping off the zeros at both ends
+  Int_t    fCurrentSize;               // Current size of the array fEvents
+  Float_t  fEventFrequency;            // Event frequency in Hertz (to be set)
+  Byte_t   fFlags;                     // Bit field for the fit result bits
+  Int_t    fPowerProbabilityBins;      // Bins for the projected power spectrum
+  
+  TH1I    *fHPowerProbability;         // Fourier transform of fEvents projected on y-axis
+  TArrayF *fPowerSpectrum;             // Fourier transform of fEvents
+  TGraph  *fGraphEvents;               //! TGraph to display the event array (will not be cloned!!)
+  TGraph  *fGraphPowerSpectrum;        //! TGraph to display the power spectrum array (will not be cloned!!)
+
+  enum { kGausFitOK, kExpFitOK, kFourierSpectrumOK, kExcluded }; // Bits for information about fit results 
+  
+protected:
+
+  Float_t  fBlackoutLimit;             // Lower number sigmas from mean until event is considered blackout
+  TArrayF  fEvents;                    // Array which holds the entries of GausHist
+  TF1     *fFGausFit;                  // Gauss fit for fHGausHist
+  TF1     *fFExpFit;                   // Exponential fit for FHPowerProbability
+  Axis_t   fFirst;                     // Lower histogram edge  for fHGausHist (used by InitBins()) 
+  TH1F     fHGausHist;                 // Histogram to hold the Gaussian distribution
+  Axis_t   fLast;                      // Upper histogram edge  for fHGausHist (used by InitBins()) 
+  Double_t fMean;                      // Mean of the Gauss fit
+  Double_t fMeanErr;                   // Error of the mean of the Gauss fit
+  Int_t    fNbins;                     // Number histogram bins for fHGausHist (used by InitBins())
+  Int_t    fNDFLimit;                  // NDF limit for judgement if fit is OK
+  Float_t  fSaturated;                 // Number of events classified as saturated
+  Double_t fSigma;                     // Sigma of the Gauss fit
+  Double_t fSigmaErr;                  // Error of the sigma of the Gauss fit
+  Float_t  fPickupLimit;               // Upper number sigmas from mean until event is considered pickup
+  Int_t    fPixId;                     // Pixel ID 
+  Double_t fProb;                      // Probability of the Gauss fit 
+  Float_t  fProbLimit;                 // Probability limit for judgement if fit is OK 
+
+  Float_t *CreateEventXaxis(Int_t n);  // Create an x-axis for the Event TGraphs
+  Float_t *CreatePSDXaxis(Int_t n);    // Create an x-axis for the PSD TGraphs
+
+  void DrawPowerSpectrum(TVirtualPad &pad, Int_t i);  // Draw graph of fPowerSpectrum and fHPowerProbability
+
+  // Setters
+  void  SetBinsAfterStripping   ( const Int_t nbins=fgBinsAfterStripping   ) { fBinsAfterStripping  =nbins; }
+  void  SetPowerProbabilityBins ( const Int_t nbins=fgPowerProbabilityBins ) { fPowerProbabilityBins=nbins; }
+
+ public:
+
+  MHGausEvents(const char* name=NULL, const char* title=NULL);
+  ~MHGausEvents();
+
+  virtual void Clear(Option_t *o="");
+  virtual void Reset();  
+  virtual void InitBins();
+  
+  // Draws
+  virtual void Draw(Option_t *option="");         // Default Draw 
+  void DrawEvents();                                  // Draw graph of fEvents
+  
+  // Getters
+  const Double_t GetBlackout()           const;  
+  const Double_t GetChiSquare()          const;
+  const Double_t GetExpChiSquare()       const;
+  const Int_t    GetExpNdf()             const;
+  const Double_t GetExpProb()            const;
+        TArrayF *GetEvents()                   { return &fEvents;            }  
+  const TArrayF *GetEvents()             const { return &fEvents;            }
+        TF1     *GetFExpFit()                  { return fFExpFit;            }
+  const TF1     *GetFExpFit()            const { return fFExpFit;            } 
+        TF1     *GetFGausFit()                 { return fFGausFit;           }
+  const TF1     *GetFGausFit()           const { return fFGausFit;           } 
+        TGraph  *GetGraphEvents()              { return fGraphEvents;        }
+  const Double_t GetFirst()              const { return fFirst;              }
+  const Double_t GetLast ()              const { return fLast ;              }  
+  const TGraph  *GetGraphEvents()        const { return fGraphEvents;        }
+        TGraph  *GetGraphPowerSpectrum()       { return fGraphPowerSpectrum; }
+  const TGraph  *GetGraphPowerSpectrum() const { return fGraphPowerSpectrum; }
+        TH1F    *GetHGausHist()                { return &fHGausHist;         }
+  const TH1F    *GetHGausHist()          const { return &fHGausHist;         } 
+        TH1I    *GetHPowerProbability()        { return fHPowerProbability;  }
+  const TH1I    *GetHPowerProbability()  const { return fHPowerProbability;  } 
+  const Double_t GetMean()               const { return fMean;               }
+  const Double_t GetMeanErr()            const { return fMeanErr;            }
+  const Int_t    GetNdf()                const;
+  const Double_t GetOffset()             const;
+  const Double_t GetPickup()             const;
+  const Int_t    GetPixId()              const { return fPixId;              }
+        TArrayF *GetPowerSpectrum()            { return fPowerSpectrum;      }  
+  const TArrayF *GetPowerSpectrum()      const { return fPowerSpectrum;      }
+  const Double_t GetProb()               const { return fProb;               }
+  const Float_t  GetSaturated()          const { return fSaturated;          }
+  const Double_t GetSigma()              const { return fSigma;              }
+  const Double_t GetSigmaErr()           const { return fSigmaErr;           }
+  const Double_t GetSlope()              const;
+
+  const Bool_t IsExcluded()              const;
+  const Bool_t IsExpFitOK()              const; 
+  const Bool_t IsEmpty()                 const;
+  const Bool_t IsFourierSpectrumOK()     const;
+  const Bool_t IsGausFitOK()             const; 
+
+  // Fill
+  void   FillArray       ( const Float_t f );     // Fill only the array fEvents 
+  Bool_t FillHist        ( const Float_t f );     // Fill only the histogram HGausHist 
+  Bool_t FillHistAndArray( const Float_t f );     // Fill bothe the array fEvents and the histogram HGausHist
+  
+  // Fits
+  Bool_t FitGaus(  Option_t *option="RQ0",
+                   const Double_t xmin=0., 
+	           const Double_t xmax=0.);       // Fit the histogram HGausHist with a Gaussian
+  Bool_t RepeatFit(const Option_t *option="RQ0"); // Repeat fit within limits defined by fPickupLimit
+  void BypassFit();                               // Take mean and RMS from the histogram
+  
+  // Prints
+  virtual void Print(const Option_t *o="") const; // Default Print
+  
+  // Setters
+  void  SetBlackoutLimit    ( const Float_t  lim=fgBlackoutLimit ) { fBlackoutLimit  = lim; }
+  void  SetEventFrequency   ( const Float_t  f                   ) { fEventFrequency = f;   }
+  void  SetExcluded         ( const Bool_t   b=kTRUE             );  
+  void  SetExpFitOK         ( const Bool_t   b=kTRUE             );
+  void  SetFourierSpectrumOK( const Bool_t   b=kTRUE             );
+  void  SetGausFitOK        ( const Bool_t   b=kTRUE             );
+  void  SetLast             ( const Double_t d                   ) { fLast           = d;   }
+  void  SetFirst            ( const Double_t d                   ) { fFirst          = d;   }
+  void  SetMean             ( const Double_t d                   ) { fMean           = d;   }
+  void  SetMeanErr          ( const Double_t d                   ) { fMeanErr        = d;   }
+  void  SetNbins            ( const Int_t    i                   ) { fNbins          = i;   }  
+  void  SetNDFLimit         ( const Int_t    lim=fgNDFLimit      ) { fNDFLimit       = lim; }  
+  void  SetPickupLimit      ( const Float_t  lim=fgPickupLimit   ) { fPickupLimit    = lim; }
+  void  SetPixId            ( const Int_t    i                   ) { fPixId          = i;   }
+  void  SetProb             ( const Double_t d                   ) { fProb           = d;   }
+  void  SetProbLimit        ( const Float_t  lim=fgProbLimit     ) { fProbLimit      = lim; }
+  void  SetSaturated        ( const Float_t f                    ) { fSaturated     += f;   }
+  void  SetSigma            ( const Double_t d                   ) { fSigma          = d;   }
+  void  SetSigmaErr         ( const Double_t d                   ) { fSigmaErr       = d;   }
+
+  // Miscelleaneous
+  virtual void ChangeHistId(const Int_t id);      // Changes names and titles of the histogram
+  virtual void Renorm();                          // Re-normalize the results 
+  
+  void CreateFourierSpectrum();                   // Create the fourier spectrum out of fEvents
+  void CreateGraphEvents();                       // Create the TGraph fGraphEvents of fEvents 
+  void CreateGraphPowerSpectrum();                // Create the TGraph fGraphPowerSpectrum out of fPowerSpectrum
+  
+  ClassDef(MHGausEvents, 1) // Base class for events with Gaussian distributed values
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mcalib/MMcCalibrationCalc.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MMcCalibrationCalc.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MMcCalibrationCalc.cc	(revision 9661)
@@ -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): Abelardo Moralejo, 12/2003 <mailto:moralejo@pd.infn.it>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MMcCalibrationCalc
+//
+//  Input Containers:
+//   MMcConfigRunHeader
+//   MRawRunHeader
+//   MMcFadcHeader
+//   MHillas
+//   MNewImagePar
+//   MMcEvt
+//
+//  Output Containers:
+//  (containers mus exist already, they are filled with new values).
+//   MCalibrationChargeCam
+//   MCalibrationQECam  
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MMcCalibrationCalc.h"
+
+#include <TH1.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MCalibrationChargePix.h"
+#include "MCalibrationChargeCam.h"
+
+#include "MCalibrationQEPix.h"
+#include "MCalibrationQECam.h"
+
+#include "MGeomCam.h"
+#include "MRawRunHeader.h"
+#include "MMcConfigRunHeader.h"
+
+#include "MHillas.h"
+#include "MNewImagePar.h"
+
+#include "MMcEvt.hxx"
+#include "MMcFadcHeader.hxx"
+
+ClassImp(MMcCalibrationCalc);
+
+using namespace std;
+
+MMcCalibrationCalc::MMcCalibrationCalc(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MMcCalibrationCalc";
+    fTitle = title ? title : "Calculate and write conversion factors into MCalibrationChargeCam and MCalibrationQECam containers";
+
+    fHistADC2PhotEl = new TH1F(AddSerialNumber("ADC2PhotEl"), "log10(fPhotElfromShower/fSize)", 1500, -3., 3.);
+    fHistADC2PhotEl->SetXTitle("log_{10}(fPhotElfromShower / fSize) [photel/ADC count]");
+
+
+    fHistPhot2PhotEl = new TH1F(AddSerialNumber("Phot2PhotEl"), "Photon conversion efficiency", 1000, 0., 1.);
+    fHistPhot2PhotEl->SetXTitle("Overall photon conversion efficiency [photoelectron/photon]");
+
+}
+
+// --------------------------------------------------------------------------
+//
+// 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 MMcCalibrationCalc::CheckRunType(MParList *pList) const
+{
+    const MRawRunHeader *run = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
+    if (!run)
+    {
+        *fLog << warn << "Warning - cannot check file type, MRawRunHeader not found." << endl;
+        return kTRUE;
+    }
+
+    return  run->IsMonteCarloRun();
+}
+
+// --------------------------------------------------------------------------
+//
+// Make sure, that there is an MCalibrationCam Object in the Parameter List.
+//
+Int_t MMcCalibrationCalc::PreProcess(MParList *pList)
+{
+    fHistADC2PhotEl->Reset();
+    fHistPhot2PhotEl->Reset();
+
+    fADC2PhotEl = 0;
+    fPhot2PhotEl = 0;
+
+    fCalCam = (MCalibrationChargeCam*) pList->FindObject(AddSerialNumber("MCalibrationChargeCam"));
+    if (!fCalCam)
+    {
+        *fLog << err << AddSerialNumber("MCalibrationChargeCam") << "not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fQECam = (MCalibrationQECam*) pList->FindObject(AddSerialNumber("MCalibrationQECam"));
+    if (!fQECam)
+    {
+        *fLog << err << AddSerialNumber("MCalibrationQECam") << "not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fHillas = (MHillas*) pList->FindObject(AddSerialNumber("MHillas"));
+    if ( !fHillas)
+    {
+        *fLog << err << AddSerialNumber("MHillas") << "not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fNew = (MNewImagePar*)pList->FindObject(AddSerialNumber("MNewImagePar"));
+    if (!fNew)
+    {
+        *fLog << err << AddSerialNumber("MNewImagePar") << "not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fMcEvt = (MMcEvt*) pList->FindObject(AddSerialNumber("MMcEvt"));
+    if (!fMcEvt)
+    {
+        *fLog << err << AddSerialNumber("MMcEvt") << "not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Check for the runtype.
+// Search for MGeomCam and MMcFadcHeader.
+//
+Bool_t MMcCalibrationCalc::ReInit(MParList *pList)
+{
+  //
+  // If it is no MC file display error and exit
+  //
+  if (!CheckRunType(pList))
+  {
+      *fLog << err << "MMcCalibrationCalc can only be used with MC files... aborting." << endl;
+      return kFALSE;
+  }
+
+  //
+  // Now check the existence of all necessary containers.
+  //
+  fGeom = (MGeomCam*) pList->FindObject(AddSerialNumber("MGeomCam"));
+  if (!fGeom)
+  {
+      *fLog << err << AddSerialNumber("MGeomCam") << " not found... aborting." << endl;
+      return kFALSE;
+  }
+
+  fHeaderFadc = (MMcFadcHeader*)pList->FindObject(AddSerialNumber("MMcFadcHeader"));
+  if (!fHeaderFadc)
+  {
+      *fLog << err << AddSerialNumber("MMcFadcHeader") << " not found... aborting." << endl;
+      return kFALSE;
+  }
+
+  for (UInt_t ipix = 0; ipix < fGeom->GetNumPixels(); ipix++)
+  {
+      if (fHeaderFadc->GetPedestalRmsHigh(ipix) > 0 ||
+	  fHeaderFadc->GetPedestalRmsLow(ipix)  > 0 )
+      {
+          *fLog << err << "Trying to calibrate the data using a Camera file produced with added noise." << endl;
+          *fLog << "Please use a noiseless file for calibration... aborting." << endl << endl;
+	  return kFALSE;
+      }
+  }
+
+  // Now check the light collection for inner and outer pixels to
+  // calculate the ratio between the two. FIXME! Light collection
+  // depends on the incidence angle of the light w.r.t. the camera
+  // plane. For the moment we take the ratio for light impinging
+  // perpendicular to the camera plane.
+  //
+  // FIXME! We should look for AddSerialNumber("MMcConfigRunHeader") but
+  // for the moment the stereo version of camera does not write one such
+  // header per telescope (it should!)
+  //
+  MMcConfigRunHeader* mcconfig = (MMcConfigRunHeader*) pList->FindObject("MMcConfigRunHeader");
+  if (!mcconfig)
+    {
+      *fLog << err << "MMcConfigRunHeader" << " not found... aborting." << endl;
+      return kFALSE;
+    }
+  TArrayF innerlightcoll = mcconfig->GetLightCollectionFactor();
+  TArrayF outerlightcoll = mcconfig->GetLightCollectionFactorOuter();
+
+  // In principle outer pixels seem to have a different average light 
+  // collection efficiency than outer ones. We set here the factor between
+  // the two.
+
+  fOuterPixelsLightCollection = outerlightcoll[90] / innerlightcoll[90]; 
+  // (at angle = 90 deg)
+
+
+  return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Obtain average ratio of photons in camera to image Size.
+//
+Int_t MMcCalibrationCalc::Process()
+{
+    //
+    // Exclude events with some saturated pixel
+    //
+    if (fNew->GetNumSaturatedPixels()>0)
+        return kTRUE;
+
+    const Float_t size = fHillas->GetSize(); 
+    const Float_t innersize = fNew->GetInnerSize();
+
+    // Size will at this point be in ADC counts (still uncalibrated)
+    //
+    // Exclude events with low Size (larger fluctuations)
+    // FIXME? The present cut (1000 "inner-pixel-counts") is somehow
+    // arbitrary. Might it be optimized?
+    //   
+
+    if (size < 1000)
+        return kTRUE;
+
+    //
+    // PATCH: Convert number of photoelectrons in camera to the approximate number 
+    // of photoelectrons that would have been registered if all pixels had the same
+    // light collection efficiency as inner ones (called here "corrected_photel").
+    //
+ 
+    const Float_t inner_photel = (Float_t) fMcEvt->GetPhotElfromShower() * innersize / size;
+    const Float_t outer_photel = (Float_t) fMcEvt->GetPhotElfromShower() - inner_photel;
+
+    const Float_t corrected_photel = inner_photel + outer_photel / fOuterPixelsLightCollection;
+
+
+    //    fHistADC2PhotEl->Fill(TMath::Log10(fMcEvt->GetPhotElfromShower()/size));
+
+    fHistADC2PhotEl->Fill(TMath::Log10(corrected_photel/size));
+    fHistPhot2PhotEl->Fill( corrected_photel / (Float_t) fMcEvt->GetPassPhotCone() );
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the MCalibrationCam object
+//
+Int_t MMcCalibrationCalc::PostProcess()
+{
+    const Stat_t n = fHistADC2PhotEl->GetEntries();
+    if (n<1)
+    {
+        *fLog << err << "No events read... aborting." << endl;
+        return kFALSE;
+    }
+
+    fPhot2PhotEl = fHistPhot2PhotEl->GetMean();   // Average quantum efficiency
+
+    //
+    // Find peak of log10(photel/Size) histogram:
+    //
+    const Int_t reach = 2;
+    Stat_t summax = 0;
+    Int_t  mode   = 0;
+    for (Int_t ibin = 1+reach; ibin <= fHistADC2PhotEl->GetNbinsX()-reach; ibin++)
+    {
+        const Stat_t sum = fHistADC2PhotEl->Integral(ibin-reach, ibin+reach);
+
+        if (sum <= summax)
+            continue;
+
+        summax = sum;
+        mode = ibin;
+    }
+
+    fADC2PhotEl = TMath::Power(10, fHistADC2PhotEl->GetBinCenter(mode));
+
+    const Int_t num = fCalCam->GetSize();
+
+    for (int i=0; i<num; i++)
+    {
+        MCalibrationChargePix &calpix = (MCalibrationChargePix&)(*fCalCam)[i];
+	MCalibrationQEPix     &qepix  = (MCalibrationQEPix&)    (*fQECam) [i];
+
+	Float_t qe = fPhot2PhotEl;
+	if (fGeom->GetPixRatio(i) < 1.)
+	  qe *= fOuterPixelsLightCollection;
+	qepix.SetAverageQE(qe);
+
+	qepix.SetAvNormFFactor(1.);
+	// This factor should convert the default average QE for different colors to 
+        // average QE for a spectrum like that of Cherenkov light (see the documentration 
+	// of MCalibrationQEPix). 
+	// Here we obtain average QE using already a Cherenkov spectrum so AvNormFFactor
+	// must be 1.
+
+	
+	Float_t factor = fADC2PhotEl;
+
+	//
+	// We take into account the (possibly) different gain of outer pixels:
+	// FIXME: we are now assuming that all inner pixels have the same gain, and all 
+	// outer pixels have the same gain (different from inner ones though). This can 
+        // only be like this in camera 0.7, but may change in future versions of camera.
+	//
+
+	if (fGeom->GetPixRatio(i) < 1.)
+	  factor *= fHeaderFadc->GetAmplitud()/fHeaderFadc->GetAmplitudOuter();
+
+        calpix.SetMeanConvFADC2Phe(factor);
+        calpix.SetMeanConvFADC2PheVar(0.);
+
+        calpix.SetMeanFFactorFADC2Phot(0.);
+    }
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mcalib/MMcCalibrationCalc.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/MMcCalibrationCalc.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/MMcCalibrationCalc.h	(revision 9661)
@@ -0,0 +1,53 @@
+#ifndef MARS_MMcCalibrationCalc
+#define MARS_MMcCalibrationCalc
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MCalibrationChargeCam;
+class MCalibrationQECam;
+class MGeomCam;
+class MHillas;
+class MNewImagePar;
+class MMcEvt;
+class MMcFadcHeader;
+
+class TH1F;
+
+class MMcCalibrationCalc : public MTask
+{
+private:
+    MCalibrationChargeCam     *fCalCam;
+    MCalibrationQECam         *fQECam;    
+    MGeomCam                  *fGeom;
+    MHillas                   *fHillas;
+    MNewImagePar              *fNew;
+    MMcEvt                    *fMcEvt;
+    MMcFadcHeader             *fHeaderFadc;
+
+    Float_t fADC2PhotEl;   // Conversion factor (photel / ADC count). FOR INER PIXELS
+    Float_t fPhot2PhotEl;  // Conversion factor (photons / photoelectron) = average QE. FOR INER PIXELS
+    Long_t  fEvents;
+    Float_t fOuterPixelsLightCollection; // Light collection efficiency (plexiglas, light guide) of 
+                                         // outer pixels w.r.t inner ones
+
+    TH1F*   fHistADC2PhotEl;
+    TH1F*   fHistPhot2PhotEl; // Histograms for monitoring the calibration.
+
+    Bool_t CheckRunType(MParList *pList) const;
+    Int_t  PreProcess(MParList *pList);
+    Bool_t ReInit(MParList *pList);
+    Int_t  Process();
+    Int_t  PostProcess();
+
+public:
+    MMcCalibrationCalc(const char *name=NULL, const char *title=NULL);
+
+    TH1F*   GetHistADC2PhotEl() { return fHistADC2PhotEl; }
+    TH1F*   GetHistPhot2PhotEl() { return fHistPhot2PhotEl; }
+
+    ClassDef(MMcCalibrationCalc, 0)   // Task which obtains, for MC files, the calibration factor from ADC counts to photons. 
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mcalib/Makefile
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcalib/Makefile	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcalib/Makefile	(revision 9661)
@@ -0,0 +1,73 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#------------------------------------------------------------------------------
+
+#
+# Handling name of the Root Dictionary Files
+#
+CINT  = Calib
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES = -I. -I../mbase -I../mhbase -I../mgui -I../mgeom \
+           -I../manalysis -I../mraw -I../mtools -I../mmc -I../mhist  \
+           -I../mimage -I../msignal -I../mbadpixels -I../mpedestal
+
+# mhbase:    MBinning MH 
+# mgui:      MCamEvent (McalibrationCam)
+# mgeom:     MGeomCam (McalibrationCam - necessary?)
+# manalysis: MExtractedSignal, MCerPhotEvt (move to mcalib?)
+# mraw:      MRawRunHeader, MRawEvtHeader, MRawEvtPixelIter (3xMCalibrationCalc)
+# mmc:       MMcFadcHeader, MMcEvt
+# mimage     MHillas
+
+SRCFILES = MCalibrate.cc \
+	   MCalibrateData.cc \
+	   MCalibrateRelTimes.cc \
+           MCalibrationCam.cc \
+           MCalibrationPix.cc  \
+           MCalibrationRelTimeCam.cc \
+           MCalibrationRelTimePix.cc \
+	   MCalibrationRelTimeCalc.cc \
+           MCalibrationQECam.cc \
+           MCalibrationQEPix.cc  \
+           MCalibrationPedCam.cc \
+	   MCalibrationChargeCalc.cc \
+           MCalibrationChargeCam.cc \
+           MCalibrationChargePix.cc  \
+           MCalibrationChargeBlindCam.cc  \
+           MCalibrationChargeBlindPix.cc  \
+           MCalibrationChargePINDiode.cc  \
+           MHCalibrationChargeBlindPix.cc \
+           MHCalibrationChargeBlindCam.cc \
+           MHCalibrationChargePix.cc \
+           MHCalibrationCam.cc \
+           MHCalibrationChargeCam.cc \
+           MHCalibrationChargeHiGainPix.cc \
+           MHCalibrationChargeLoGainPix.cc \
+           MHCalibrationChargePINDiode.cc \
+           MHCalibrationRelTimeCam.cc \
+           MHCalibrationRelTimePix.cc \
+           MHCalibrationTestCam.cc \
+           MHCalibrationTestPix.cc  \
+           MHCalibrationTestTimeCam.cc \
+           MHCalibrationTestTimePix.cc \
+	   MMcCalibrationCalc.cc \
+	   MHGausEvents.cc 
+
+############################################################
+
+all: $(OBJS)
+
+include ../Makefile.rules
+
+mrproper:	clean rmbak
Index: /tags/Mars_V0-8-5/Mars/mcamera/CameraIncl.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcamera/CameraIncl.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcamera/CameraIncl.h	(revision 9661)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-8-5/Mars/mcamera/CameraLinkDef.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcamera/CameraLinkDef.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcamera/CameraLinkDef.h	(revision 9661)
@@ -0,0 +1,17 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class MCameraCooling+;
+#pragma link C++ class MCameraAUX+;
+#pragma link C++ class MCameraLid+;
+#pragma link C++ class MCameraLids+;
+#pragma link C++ class MCameraHV+;
+#pragma link C++ class MCameraLV+;
+#pragma link C++ class MCameraDC+;
+#pragma link C++ class MCameraCalibration+;
+#pragma link C++ class MCameraPowerSupply+;
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mcamera/MCameraAUX.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcamera/MCameraAUX.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcamera/MCameraAUX.cc	(revision 9661)
@@ -0,0 +1,34 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MCameraAUX
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCameraAUX.h"
+
+ClassImp(MCameraAUX);
+
+using namespace std;
Index: /tags/Mars_V0-8-5/Mars/mcamera/MCameraAUX.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcamera/MCameraAUX.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcamera/MCameraAUX.h	(revision 9661)
@@ -0,0 +1,32 @@
+#ifndef MARS_MCameraAUX
+#define MARS_MCameraAUX
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MCameraAUX : public MParContainer
+{
+    friend class MReportCamera;
+private:
+    Bool_t fRequestCaosLEDs; // Requested status: o=off, 1=on, bAux_CaOsLEDs_Off/On
+    Bool_t fRequestFansFADC; // Requested status: o=off, 1=on, bAux_FADC_FANs_Off/On
+    Bool_t fStatusCaosLEDs;  // Monitored status: o=off, 1=on, Cam.CaOs.LED_state
+    Bool_t fStatusFansFADC;  // Monitored status: o=off, 1=on, Cam.FADC.Fans_state
+
+public:
+    MCameraAUX()
+    {
+        fName  = "MCameraAUX";
+        fTitle = "Container storing information about the Camera auxiliary system";
+    }
+
+    Bool_t GetRequestCaosLEDs() const { return fRequestCaosLEDs; }
+    Bool_t GetRequestFansFADC() const { return fRequestFansFADC; }
+    Bool_t GetStatusCaosLEDs() const  { return fStatusCaosLEDs;  }
+    Bool_t GetStatusFansFADC() const  { return fStatusFansFADC;  }
+
+    ClassDef(MCameraAUX, 1) // Container storing information about the Camera auxiliary system
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mcamera/MCameraCalibration.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcamera/MCameraCalibration.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcamera/MCameraCalibration.cc	(revision 9661)
@@ -0,0 +1,34 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MCameraCalibration
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCameraCalibration.h"
+
+ClassImp(MCameraCalibration);
+
+using namespace std;
Index: /tags/Mars_V0-8-5/Mars/mcamera/MCameraCalibration.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcamera/MCameraCalibration.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcamera/MCameraCalibration.h	(revision 9661)
@@ -0,0 +1,42 @@
+#ifndef MARS_MCameraCalibration
+#define MARS_MCameraCalibration
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MCameraCalibration : public MParContainer
+{
+    friend class MReportCamera;
+private:
+    Byte_t fStatus;           // CaCo monitored calibration state: o=off, 1=on, CamCalib_state
+    Byte_t fStatusCANbus;     // CaCo monitored CANbus state: o=off, 1=on, Cal.CanBus_state
+    Byte_t fStatusIO;         // CaCo monitored I/O state: o=off, 1=on, Cal.IO_state
+    Byte_t fStatusLoVoltage;  // CaCo monitored LV PS state: o=off, 1=on, Cal.LV_state
+
+    Bool_t fRequestHiVoltage; // Requested status: o=off, 1=on, bcalib_HV_Off/On
+    Bool_t fRequestLoVoltage; // Requested status: o=off, 1=on, bcalib_LV_Off/On
+    Bool_t fRequestContLight; // Requested status: o=off, 1=on, bcalib_ContinuousLight_Off/On
+    Bool_t fRequestPinDiode;  // Requested status: o=off, 1=on, bcalib_PinDiode_Off/On
+
+public:
+    MCameraCalibration()
+    {
+        fName  = "MCameraCalibration";
+        fTitle = "Container storing information about the Camera calibration system";
+    }
+
+    Byte_t GetStatus() const           { return fStatus; }
+    Byte_t GetStatusCANbus() const     { return fStatusCANbus; }
+    Byte_t GetStatusIO() const         { return fStatusIO; }
+    Byte_t GetStatusLoVoltage() const  { return fStatusLoVoltage; }
+
+    Bool_t GetRequestHiVoltage() const { return fRequestHiVoltage; }
+    Bool_t GetRequestLoVoltage() const { return fRequestLoVoltage; }
+    Bool_t GetRequestContLight() const { return fRequestContLight; }
+    Bool_t GetRequestPinDiode() const  { return fRequestPinDiode; }
+
+    ClassDef(MCameraCalibration, 1) // Container storing information about the Camera calibration system
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mcamera/MCameraCooling.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcamera/MCameraCooling.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcamera/MCameraCooling.cc	(revision 9661)
@@ -0,0 +1,34 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MCameraCooling
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCameraCooling.h"
+
+ClassImp(MCameraCooling);
+
+using namespace std;
Index: /tags/Mars_V0-8-5/Mars/mcamera/MCameraCooling.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcamera/MCameraCooling.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcamera/MCameraCooling.h	(revision 9661)
@@ -0,0 +1,58 @@
+#ifndef MARS_MCameraCooling
+#define MARS_MCameraCooling
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MCameraCooling : public MParContainer
+{
+    friend class MReportCamera;
+private:
+    Byte_t  fStatus;              // CaCo Monitored cooling status: 0-9, Cam.COOLING_state
+
+    Bool_t  fStatusPressureHi;    // 0=ok,  1=Obstruct
+    Bool_t  fStatusPressureLo;    // 0=ok,  1=leakage
+    Bool_t  fStatusPump;          // 0=off, 1=on
+    Bool_t  fStatusRefrigrerator; // 0=off, 1=on
+    Bool_t  fStatusValve;         // 0=recirculate, 1=new
+    Bool_t  fStatusResistor;      // 0=off, 1=on
+    Bool_t  fStatusFans;          // 0=off, 1=on
+
+    Float_t fTempCenter;          // [deg C] Temperature at the camera center
+    Float_t fTempWall;            // [deg C] Temperature at the camera wall
+    Float_t fTempOptLink;         // [deg C] Temperature at the optical link
+    Float_t fTempWater;           // [deg C] Temperature of the water in the water tank
+
+    Byte_t  fHumWall;             // [%] Relative humidity at camera wall
+    Byte_t  fHumCenter;           // [%] Relative humidity camera center
+
+public:
+    MCameraCooling()
+    {
+        fName  = "MCameraCooling";
+        fTitle = "Container storing information about the Camera cooling system";
+    }
+
+    Byte_t  GetStatus() const              { return fStatus;              }
+
+    Bool_t  GetStatusPressureHi() const    { return fStatusPressureHi;    }
+    Bool_t  GetStatusPressureLo() const    { return fStatusPressureLo;    }
+    Bool_t  GetStatusPump() const          { return fStatusPump;          }
+    Bool_t  GetStatusRefrigrerator() const { return fStatusRefrigrerator; }
+    Bool_t  GetStatusValve() const         { return fStatusValve;         }
+    Bool_t  GetStatusResistor() const      { return fStatusResistor;      }
+    Bool_t  GetStatusFans() const          { return fStatusFans;          }
+
+    Float_t GetTempCenter() const          { return fTempCenter;          }
+    Float_t GetTempWall() const            { return fTempWall;            }
+    Float_t GetTempOptLink() const         { return fTempOptLink;         }
+    Float_t GetTempWater() const           { return fTempWater;           }
+
+    Byte_t  GetHumWall() const             { return fHumWall;             }
+    Byte_t  GetHumCenter() const           { return fHumCenter;           }
+
+    ClassDef(MCameraCooling, 1) // Container storing information about the Camera cooling
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mcamera/MCameraDC.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcamera/MCameraDC.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcamera/MCameraDC.cc	(revision 9661)
@@ -0,0 +1,86 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 5/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MCameraDC (PRELIMINARY)
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCameraDC.h"
+
+#include <TMath.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MCameraDC);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MCameraDC::MCameraDC(Int_t size, const char *name, const char *title)
+    : fArray(size)
+{
+    fName  = name  ? name  : "MCameraDC";
+    fTitle = title ? title : "Storage container for the pixel currents";
+}
+
+// --------------------------------------------------------------------------
+//
+// Print the dc currents
+//
+void MCameraDC::Print(Option_t *) const
+{
+    *fLog << all << underline << GetDescriptor() << endl;
+    for (int i=0; i<fArray.GetSize(); i++)
+        *fLog << " " << GetCurrent(i);
+    *fLog << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the minimum dc current
+//
+Float_t MCameraDC::GetMin() const
+{
+    Float_t val = (UInt_t)-1;
+    for (int i=0; i<fArray.GetSize(); i++)
+        val = TMath::Min(val, GetCurrent(i));
+    return val;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the maximum dc current
+//
+Float_t MCameraDC::GetMax() const
+{
+    Float_t val = 0;
+    for (int i=0; i<fArray.GetSize(); i++)
+        val = TMath::Max(val, GetCurrent(i));
+    return val;
+}
Index: /tags/Mars_V0-8-5/Mars/mcamera/MCameraDC.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcamera/MCameraDC.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcamera/MCameraDC.h	(revision 9661)
@@ -0,0 +1,45 @@
+#ifndef MARS_MCameraDC
+#define MARS_MCameraDC
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+#ifndef MARS_MCamEvent
+#include "MCamEvent.h"
+#endif
+
+#ifndef ROOT_TArrayF
+#include <TArrayF.h>
+#endif
+
+class MCameraDC : public MParContainer, public MCamEvent
+{
+private:
+    TArrayF fArray; // [nA] Unsigned Int!
+
+public:
+    MCameraDC(Int_t size=577, const char *name=NULL, const char *title=NULL);
+
+    void SetCurrent(Int_t i, Float_t val) { fArray[i] = (Int_t)val; }
+    Float_t GetCurrent(Int_t i) const { return (*this)[i]; }
+    Float_t &operator[](Int_t i) { return (Float_t&)fArray[i]; }
+    const Float_t &operator[](Int_t i) const { return (*const_cast<MCameraDC*>(this))[i]; }
+
+    Float_t GetMin() const;
+    Float_t GetMax() const;
+
+    void Print(Option_t *opt=NULL) const;
+
+    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const
+    {
+        val = fArray[idx];
+        return val>0;
+    }
+    void DrawPixelContent(Int_t num) const
+    {
+    }
+
+    ClassDef(MCameraDC, 1) // Storage Container for the Currents (PRELIMINARY)
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mcamera/MCameraHV.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcamera/MCameraHV.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcamera/MCameraHV.cc	(revision 9661)
@@ -0,0 +1,34 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MCameraHV
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCameraHV.h"
+
+ClassImp(MCameraHV);
+
+using namespace std;
Index: /tags/Mars_V0-8-5/Mars/mcamera/MCameraHV.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcamera/MCameraHV.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcamera/MCameraHV.h	(revision 9661)
@@ -0,0 +1,63 @@
+#ifndef MARS_MCameraHV
+#define MARS_MCameraHV
+
+#ifndef MARS_MCamEvent
+#include "MCamEvent.h"
+#endif
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#ifndef ROOT_TArrayS
+#include <TArrayS.h>
+#endif
+
+class MCameraHV : public MParContainer, public MCamEvent
+{
+    friend class MReportCamera;
+private:
+    Byte_t  fStatus;        // CaCo monitored status of the High Voltage [0-9], Cam.HV.PS_state
+    Bool_t  fStatusRamping; // CaCo monitored status of ramping the HV, Cam.HV_state
+
+    Short_t fVoltageA;      // [V] Measured voltage of power supply A, hvps1
+    Short_t fVoltageB;      // [V] Measured voltage of power supply B, hvps2
+
+    Byte_t fCurrentA;       // [mA] Measured current of power supply A, curr1
+    Byte_t fCurrentB;       // [mA] Measured current of power supply B, curr2
+
+    TArrayS fHV;            // [V] Measured high Voltages for all PMTs
+
+public:
+    MCameraHV() : fHV(577)
+    {
+        fName  = "MCameraHV";
+        fTitle = "Container storing information about the Camera HV";
+    }
+
+    Byte_t  GetStatus() const { return fStatus; }
+    Bool_t  GetStatusRamping() const { return fStatusRamping; }
+
+    Short_t GetVoltageA() const { return fVoltageA; }
+    Short_t GetVoltageB() const { return fVoltageB; }
+
+    Byte_t  GetCurrentA() const { return fCurrentA; }
+    Byte_t  GetCurrentB() const { return fCurrentB; }
+
+    Float_t GetMean() const { return fHV.GetSum()/fHV.GetSize(); }
+
+    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const
+    {
+        val = fHV[idx];
+        return val>0;
+    }
+
+    Double_t operator[](const UInt_t idx) { return fHV[idx]; }
+
+    void DrawPixelContent(Int_t num) const
+    {
+    }
+
+    ClassDef(MCameraHV, 1) // Container storing information about the Camera HV
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mcamera/MCameraLV.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcamera/MCameraLV.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcamera/MCameraLV.cc	(revision 9661)
@@ -0,0 +1,34 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MCameraLV
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCameraLV.h"
+
+ClassImp(MCameraLV);
+
+using namespace std;
Index: /tags/Mars_V0-8-5/Mars/mcamera/MCameraLV.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcamera/MCameraLV.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcamera/MCameraLV.h	(revision 9661)
@@ -0,0 +1,44 @@
+#ifndef MARS_MCameraLV
+#define MARS_MCameraLV
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#ifndef MARS_MCameraPowerSupply
+#include <MCameraPowerSupply.h>
+#endif
+
+class MCameraLV : public MParContainer
+{
+    friend class MReportCamera;
+private:
+    Byte_t  fStatus;                  // CaCo monitored LV PS status:  , Cam.LV_state
+    Bool_t  fRequestPowerSupply;      // Requested status: o=off, 1=on, blv_ps_status
+
+    Float_t fTemp;                    // Measured status: o=off, 1=on, blv_temp
+    Byte_t  fHumidity;                // Measured status: o=off, 1=on, blv_RelativeHumidity
+
+    MCameraPowerSupply fPowerSupplyA; // power supply camera part A
+    MCameraPowerSupply fPowerSupplyB; // power supply camera part B
+
+public:
+    MCameraLV()
+    {
+        fName  = "MCameraLV";
+        fTitle = "Container storing information about the Camera LV";
+    }
+
+    Byte_t  GetStatus() const { return fStatus; }
+    Bool_t  GetRequestPowerSupply() const { return fRequestPowerSupply; }
+
+    Float_t GetTemp() const { return fTemp; }
+    Byte_t  GetHumidity() const { return fHumidity; }
+
+    const MCameraPowerSupply &GetPowerSupplyA() const { return fPowerSupplyA; }
+    const MCameraPowerSupply &GetPowerSupplyB() const { return fPowerSupplyB; }
+
+    ClassDef(MCameraLV, 1) // Container storing information about the Camera LV
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mcamera/MCameraLid.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcamera/MCameraLid.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcamera/MCameraLid.cc	(revision 9661)
@@ -0,0 +1,34 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MCameraLid
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCameraLid.h"
+
+ClassImp(MCameraLid);
+
+using namespace std;
Index: /tags/Mars_V0-8-5/Mars/mcamera/MCameraLid.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcamera/MCameraLid.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcamera/MCameraLid.h	(revision 9661)
@@ -0,0 +1,42 @@
+#ifndef MARS_MCameraLid
+#define MARS_MCameraLid
+
+// Derived from MParContainer instead of TObject
+// to supress writing fUniqueId and fBits
+#ifndef MARS_MParContainer
+#include <MParContainer.h>
+#endif
+
+class MCameraLid : public MParContainer
+{
+    friend class MReportCamera;
+private:
+     Bool_t fLimitOpen;        // 0=not active, 1= active
+     Bool_t fLimitClose;       // 0=not active, 1= active
+
+     Bool_t fSafetyLimitOpen;  // 0=not active, 1= active
+     Bool_t fSafetyLimitClose; // 0=not active, 1= active
+
+     Byte_t fStatusLid;        // 0=positioning, 1=open, 2=closed
+     Byte_t fStatusMotor;      // 0=stopped, 1=opening, 2=closing
+
+public:
+    MCameraLid()
+    {
+        fName  = "MCameraLid";
+        fTitle = "Container storing information about a Camera lid";
+    }
+
+    Bool_t GetLimitOpen() const        { return fLimitOpen;        }
+    Bool_t GetLimitClose() const       { return fLimitClose;       }
+
+    Bool_t GetSafetyLimitOpen() const  { return fSafetyLimitOpen;  }
+    Bool_t GetSafetyLimitClose() const { return fSafetyLimitClose; }
+
+    Byte_t GetStatusLid() const        { return fStatusLid;        }
+    Byte_t GetStatusMotor() const      { return fStatusMotor;      }
+
+    ClassDef(MCameraLid, 1) // Container storing information about a Camera lid
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mcamera/MCameraLids.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcamera/MCameraLids.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcamera/MCameraLids.cc	(revision 9661)
@@ -0,0 +1,34 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MCameraLids
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCameraLids.h"
+
+ClassImp(MCameraLids);
+
+using namespace std;
Index: /tags/Mars_V0-8-5/Mars/mcamera/MCameraLids.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcamera/MCameraLids.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcamera/MCameraLids.h	(revision 9661)
@@ -0,0 +1,35 @@
+#ifndef MARS_MCameraLids
+#define MARS_MCameraLids
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#ifndef MARS_MCameraLid
+#include "MCameraLid.h"
+#endif
+
+class MCameraLids : public MParContainer
+{
+    friend class MReportCamera;
+private:
+    MCameraLid fLidA;
+    MCameraLid fLidB;
+
+    Byte_t fStatus; // CaCo monitored lid status, Cam.LID_state [0-9]
+public:
+    MCameraLids()
+    {
+        fName  = "MCameraLids";
+        fTitle = "Container storing information about the Camera lids";
+    }
+
+    Byte_t GetStatus() const { return fStatus; }
+
+    const MCameraLid &GetLidA() const { return fLidA; }
+    const MCameraLid &GetLidB() const { return fLidB; }
+
+    ClassDef(MCameraLids, 1) // Container storing information about the Camera lids
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mcamera/MCameraPowerSupply.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcamera/MCameraPowerSupply.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcamera/MCameraPowerSupply.cc	(revision 9661)
@@ -0,0 +1,34 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MCameraPowerSupply
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCameraPowerSupply.h"
+
+ClassImp(MCameraPowerSupply);
+
+using namespace std;
Index: /tags/Mars_V0-8-5/Mars/mcamera/MCameraPowerSupply.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcamera/MCameraPowerSupply.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcamera/MCameraPowerSupply.h	(revision 9661)
@@ -0,0 +1,42 @@
+#ifndef MARS_MCameraPowerSupply
+#define MARS_MCameraPowerSupply
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MCameraPowerSupply : public MParContainer
+{
+    friend class MReportCamera;
+private:
+    Float_t fVoltagePos5V;         // [V] voltage_pos5  (+5V)
+    Float_t fVoltagePos12V;        // [V] voltage_pos12 (+12V)
+    Float_t fVoltageNeg12V;        // [V] voltage_neg12 (-12V)
+    Float_t fVoltageOptLinkPos12V; // [V] volatge_opt_link_pos12 (+12V)
+
+    Float_t fCurrentPos5V;         // [A] current_pos5  (+5V)
+    Float_t fCurrentPos12V;        // [A] current_pos12 (+12V)
+    Float_t fCurrentNeg12V;        // [A] current_neg12 (-12V)
+    Float_t fCurrentOptLinkPos12V; // [A] current_opt_link_pos12 (+12V)
+
+public:
+    MCameraPowerSupply()
+    {
+        fName  = "MCameraPowerSupply";
+        fTitle = "Container storing information about the Camera power supply";
+    }
+
+    Float_t GetVoltagePos5V() const         { return fVoltagePos5V; }
+    Float_t GetVoltagePos12V() const        { return fVoltagePos12V; }
+    Float_t GetVoltageNeg12V() const        { return fVoltageNeg12V; }
+    Float_t GetVoltageOptLinkPos12V() const { return fVoltageOptLinkPos12V; }
+
+    Float_t GetCurrentPos5V() const         { return fCurrentPos5V; }
+    Float_t GetCurrentPos12V() const        { return fCurrentPos12V; }
+    Float_t GetCurrentNeg12V() const        { return fCurrentNeg12V; }
+    Float_t GetCurrentOptLinkPos12V() const { return fCurrentOptLinkPos12V; }
+
+    ClassDef(MCameraPowerSupply, 1) // Container storing information about the Camera power supply
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mcamera/Makefile
===================================================================
--- /tags/Mars_V0-8-5/Mars/mcamera/Makefile	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mcamera/Makefile	(revision 9661)
@@ -0,0 +1,40 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#------------------------------------------------------------------------------
+
+#
+# Handling name of the Root Dictionary Files
+#
+CINT  = Camera
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES = -I. -I../mbase -I../mgui
+# mgui - MCameraDC <MCamEvent>
+
+SRCFILES = MCameraAUX.cc \
+	   MCameraCalibration.cc\
+	   MCameraCooling.cc \
+	   MCameraHV.cc \
+	   MCameraLV.cc \
+	   MCameraDC.cc \
+	   MCameraLid.cc \
+	   MCameraLids.cc \
+	   MCameraPowerSupply.cc
+
+############################################################
+
+all: $(OBJS)
+
+include ../Makefile.rules
+
+mrproper:	clean rmbak
Index: /tags/Mars_V0-8-5/Mars/mdata/DataIncl.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mdata/DataIncl.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mdata/DataIncl.h	(revision 9661)
@@ -0,0 +1,10 @@
+#ifndef __CINT__
+
+//#include <fstream>
+
+#include <TFile.h>
+#include <TTree.h>
+
+#include <TGListBox.h>
+
+#endif // __CINT__
Index: /tags/Mars_V0-8-5/Mars/mdata/DataLinkDef.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mdata/DataLinkDef.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mdata/DataLinkDef.h	(revision 9661)
@@ -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 MData+;
+#pragma link C++ class MDataArray+;
+#pragma link C++ class MDataElement+;
+#pragma link C++ class MDataList+;
+#pragma link C++ class MDataValue+;
+#pragma link C++ class MDataMember+;
+#pragma link C++ class MDataChain+;
+#pragma link C++ class MDataFormula+;
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mdata/MData.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mdata/MData.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mdata/MData.cc	(revision 9661)
@@ -0,0 +1,86 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  04/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//   MData
+//
+//   This base class defines an interface to a generalized value.
+//   This value can be a simple number, it can also be a data member
+//   of a class or some kind of concatenation of MData objects.
+//
+//   A class inheriting from MData must implement:
+//
+//    - Double_t GetValue() const
+//      which return the value corresponding to the object
+//
+//    - Bool_t IsValid() const
+//      should tell whether the object is valid (eg if the object parses
+//      a string the result might be invalid)
+//
+//    - Bool_t PreProcess(const MParList *plist)
+//      which can be used to get some necessary data (befor processing)
+//      from the parlist.
+//
+//    - TString GetRule()
+//      returns the rule as a text which would recreate the same structure
+//      when used in a MDataChain
+//
+//    - TString GetDataMember()
+//      returns the names (seperated by a comma) used by this class. This
+//      is mainly used for the AutoScheme when reading data from a file.
+//      (s.MReadTree)
+//
+//    - void SetVariables(const TArrayD &arr)
+//      is used to distribute variable numbers through lists holding
+//      MDatas to its counterpart (mainly to MDataValue)
+//
+//   The 'must' ist represented by the =0 in the class header. In the C++
+//   language this is called an abstract member function. Because the
+//   class contains abstract member function which makes it impossible
+//   to create an instance of this class one calls it also:
+//   abstract base class
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MData.h"
+
+#include <fstream>
+
+#include "MLog.h"
+
+ClassImp(MData);
+
+using namespace std;
+
+Bool_t MData::AsciiWrite(ostream &out) const
+{
+    out << GetValue() << " ";
+    return kTRUE;
+}
+
+void MData::Print(Option_t *opt) const
+{
+    *fLog << GetRule() << flush;
+}
Index: /tags/Mars_V0-8-5/Mars/mdata/MData.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mdata/MData.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mdata/MData.h	(revision 9661)
@@ -0,0 +1,33 @@
+#ifndef MARS_MData
+#define MARS_MData
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//  MData                                                                  //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MParList;
+
+class MData : public MParContainer
+{
+public:
+    virtual Double_t GetValue() const = 0;
+    virtual Bool_t   IsValid() const = 0;
+    virtual Bool_t   PreProcess(const MParList *plist) = 0;
+    virtual TString  GetRule() const = 0;
+    virtual TString  GetDataMember() const { return ""; }
+
+    Double_t operator()() { return GetValue(); }
+
+    void Print(Option_t *opt = "") const;
+    Bool_t AsciiWrite(ostream &out) const;
+
+    ClassDef(MData, 0) // A Base class for a generalized value
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mdata/MDataArray.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mdata/MDataArray.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mdata/MDataArray.cc	(revision 9661)
@@ -0,0 +1,214 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  08/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//   MDataArray
+//
+//   An Array of MData derived classes.
+//   It can be used, eg, in MHMatrix for description of the columns.
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MDataArray.h"
+
+#include <fstream>
+
+#include <TVector.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MDataChain.h"
+
+ClassImp(MDataArray);
+
+using namespace std;
+
+static const TString gsDefName  = "MDataArray";
+static const TString gsDefTitle = "Array to store MData cntainers";
+
+// --------------------------------------------------------------------------
+//
+// Constructor
+//
+MDataArray::MDataArray(const char *name, const char *title)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+
+    gROOT->GetListOfCleanups()->Add(&fList);
+    fList.SetBit(kMustCleanup);
+}
+
+// --------------------------------------------------------------------------
+//
+// Add a new data rule as a new entry (MDataChain)
+//
+void MDataArray::AddEntry(const TString rule)
+{
+    TObject *obj = new MDataChain(rule);
+    obj->SetBit(kCanDelete);
+    fList.Add(obj);
+}
+
+// --------------------------------------------------------------------------
+//
+// Add a new data as a new entry (MData). If the destructor of MDataArray
+// should delete the object set its bit kCanDelete
+//
+void MDataArray::AddEntry(MData *data)
+{
+    data->SetBit(kMustCleanup);
+    fList.Add(data);
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the i-th entry
+//
+MData &MDataArray::operator[](Int_t i) const
+{
+    return (MData&)*((TObjArray)fList)[i];
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the data value of the i-th entry
+//
+Double_t MDataArray::operator()(Int_t i) const
+{
+    return (*this)[i].GetValue();
+}
+
+// --------------------------------------------------------------------------
+//
+// PreProcesses all members in the list
+//
+Bool_t MDataArray::PreProcess(const MParList *plist)
+{
+    if (fList.GetSize()==0)
+    {
+        *fLog << err << "Error - No Column specified... aborting." << endl;
+        return kFALSE;
+    }
+
+    TIter Next(&fList);
+    MData *data = NULL;
+    while ((data=(MData*)Next()))
+        if (!data->PreProcess(plist))
+            return kFALSE;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Print the rules for all entries of the array
+//
+void MDataArray::Print(Option_t *opt) const
+{
+    Int_t n=0;
+
+    TIter Next(&fList);
+    MData *data = NULL;
+    while ((data=(MData*)Next()))
+    {
+        *fLog << all << " Line " << setw(3) << n++ << ": " << flush;
+        data->Print();
+        *fLog << endl;
+    }
+}
+
+Bool_t MDataArray::AsciiWrite(ostream &out) const
+{
+    ((TObjArray)fList).ForEach(MParContainer, AsciiWrite)(out);
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
+void MDataArray::StreamPrimitive(ofstream &out) const
+{
+    out << "   MDataArray " << GetUniqueName();
+
+    if (fName!=gsDefName)
+    {
+        out << "(\"" << fName << "\"";
+        if (fTitle!=gsDefTitle)
+            out << ", \"" << fTitle << "\")";
+    }
+    out << ";" << endl;
+
+    TIter Next(&fList);
+    MData *data = NULL;
+    while ((data=(MData*)Next()))
+        out << "   " << GetUniqueName() << ".AddEntry(\"" << data->GetRule() << "\");" << endl;
+}
+
+TString MDataArray::GetRule(int i) const
+{
+    return (*this)[i].GetRule();
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the data members existing in this array in a comma-seperated list
+// (This is mainly used for MTask::AddToBranchList)
+//
+TString MDataArray::GetDataMember() const
+{
+    TString str;
+
+    TIter Next(&fList);
+    MData *data = NULL;
+    while ((data=(MData*)Next()))
+    {
+        if (data->GetDataMember().IsNull())
+            continue;
+
+        str += ",";
+        str += data->GetDataMember();
+    }
+    return str;
+}
+
+void MDataArray::GetData(TVector &v) const
+{
+    Int_t ncols = GetNumEntries();
+
+    v.ResizeTo(ncols);
+
+    // same as: for (int i=0; i<ncols; i++) <should be faster>
+    while (ncols--)
+        v(ncols) = (*this)(ncols);
+}
+
+void MDataArray::SetVariables(const TArrayD &arr)
+{
+    fList.ForEach(MData, SetVariables)(arr);
+}
Index: /tags/Mars_V0-8-5/Mars/mdata/MDataArray.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mdata/MDataArray.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mdata/MDataArray.h	(revision 9661)
@@ -0,0 +1,63 @@
+#ifndef MARS_MDataArray
+#define MARS_MDataArray
+
+/////////////////////////////////////////////////////////////////////////////
+//              
+//  MDataArray  
+//
+/////////////////////////////////////////////////////////////////////////////
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#ifndef ROOT_TObjArray
+#include <TObjArray.h>
+#endif
+
+class TVector;
+
+class MData;
+class MParList;
+
+class MDataArray : public MParContainer
+{
+    TObjArray fList;
+
+    void StreamPrimitive(ofstream &out) const;
+
+public:
+    MDataArray(const char *name=NULL, const char *title=NULL);
+
+    void AddEntry(const TString rule);
+    void AddEntry(MData *data);
+
+    MData &operator[](Int_t i) const;
+    Double_t operator()(Int_t i) const;
+
+    void GetData(TVector &v) const;
+
+    void operator>>(TVector &v) const
+    {
+        GetData(v);
+    }
+
+    TString GetRule(int i) const;
+
+    Bool_t PreProcess(const MParList *plist);
+
+    TString GetDataMember() const;
+
+    void Print(Option_t *opt = "") const;
+    Bool_t AsciiWrite(ostream &out) const;
+
+    Int_t GetNumEntries() const { return fList.GetEntries(); }
+
+    void Clear(Option_t *option="")  { fList.Clear(option); }
+    void Delete(Option_t *option="") { fList.Delete(option); }
+
+    void SetVariables(const TArrayD &arr);
+
+    ClassDef(MDataArray, 1) // An array of MData containers
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mdata/MDataChain.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mdata/MDataChain.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mdata/MDataChain.cc	(revision 9661)
@@ -0,0 +1,744 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  04/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MDataChain
+// ==========
+//
+// With this chain you can concatenate simple mathematical operations on
+// members of mars containers.
+//
+//
+// Rules
+// -----
+//
+// 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.
+//
+// In case you want to access a data-member which is a data member object
+// you can acces it with (Remark: it must derive from MParContainer):
+//   "MCameraLV.fPowerSupplyA.fVoltagePos5V"
+//
+// You can also use parantheses:
+//   "HillasDource.fDist / (MHillas.fLength + MHillas.fWidth)"
+//
+//
+// Operators
+// ---------
+//
+// The allowed operations are: +, -, *, /, %, ^
+//
+// While a%b returns the floating point reminder of a/b.
+// While a^b returns a to the power of b
+//
+// Warning: There is no priority rule build in. So better use parantheses
+//   to get correct results. The rule is parsed/evaluated from the left
+//   to the right, which means:
+//
+//   "MHillas.fWidth + MHillas.fLength / HillasSource.fDist"
+//
+//    is parses as
+//
+//   "(MHillas.fWidth + MHillas.fLength) / HillasSource.fDist"
+//
+// You can also use mathmatical operators, eg:
+//   "5*log10(MMcEvt.fEnergy*MHillas.fSize)"
+//
+// The allowed operators are:
+//   exp(x)    e^x
+//   log(x)    natural logarithm of x
+//   pow10(x)  10^x
+//   log2(x)   logarithm of x to base two
+//   log10(x)  logarithm of x to base ten
+//   cos(x)    cosine of x
+//   sin(x)    sine of x
+//   tan(x)    tangent of x
+//   cosh(x)   hyperbolic cosine of x
+//   sinh(x)   hyperbolic sine of x
+//   tanh(x)   hyperbolic tangent of x
+//   acosh(x)  arc hyperbolic cosine of x
+//   asinh(x)  arc hyperbolic sine of x
+//   atanh(x)  arc hyperbolic tangent of x
+//   acos(x)   arc cosine (inverse cosine) of x
+//   asin(x)   arc sine (inverse sine) of x
+//   atan(x)   arc tangent (inverse tangent) of x
+//   sqrt(x)   square root of x
+//   sqr(x)    square of x
+//   abs(x)    absolute value of x, |x|
+//   floor(x)  round down to the nearest integer (floor(9.9)=9)
+//   ceil(x)   round up   to the nearest integer (floor(9.1)=10)
+//   round(x)  round      to the nearest integer
+//   r2d(x)    transform radians to degrees
+//   d2r(x)    transform degrees to radians
+//   rand(x)   returns a uniform deviate on the interval ( 0, x ].
+//             (gRandom->Uniform(x) is returned)
+//   randp(x)  returns gRandom->Poisson(x)
+//   rande(x)  returns gRandom->Exp(x)
+//   randi(x)  returns gRandom->Integer(x)
+//   randg(x)  returns gRandom->Gaus(0, x)
+//   randl(x)  returns gRandom->Landau(0, x)
+//   isnan(x)  return 1 if x is NaN (Not a Number) otherwise 0
+//   finite(x) return 1 if the number is a valid double (not NaN, inf)
+//
+// NaN (Not a Number) means normally a number which is to small to be
+// stored in a floating point variable (eg. 0<x<1e-56 or similar) or
+// a number which function is not defined (like asin(1.5))
+//
+// inf is the symbol for an infinite number.
+//
+//
+// Constants
+// ---------
+//
+// Constants are implemented in ParseDataMember, namely:
+//   kPi:       TMath::Pi()
+//   kRad2Deg:  180/kPi
+//   kDeg2Rad:  kPi/180
+//
+// You can also defined constants which are defined in TMath by:
+//   kLn10       for   static Double_t TMath::Ln10();
+//   kLogE       for   static Double_t TMath::LogE();
+//   kRadToDeg   for   static Double_t TMath::RadToDeg();
+//   kDegToRad   for   static Double_t TMath::DegToRad();
+//   ...
+//
+// Remark:
+//  In older root versions only Pi() and E() are implemented
+//  in TMath.
+//
+//
+// Variable Parameters
+// ------------------------
+// If you want to use variables, eg for fits you can use [0], [1], ...
+// These values are initialized with 0 and set by calling
+// SetVariables().
+//
+//
+// Multi-argument functions
+// ------------------------
+// You can use multi-argument functions, too. The access is implemented
+// via TFormula, which slows down thing a lot. If you can avoid usage
+// of such expression you accelerate the access a lot. Example:
+//   "TMath::Hypot(MHillas.fMeanX, MHillas.MeanY)"
+//   "pow(MHillas.fMeanX*MHillas.MeanY, -1.2)"
+// It should be possible to use all functions which are accessible
+// via the root-dictionary.
+//
+//
+// REMARK:
+//  - All the random functions are returning 0 if gRandom==0
+//  - You may get better results if you are using a TRandom3
+//
+// To Do:
+//  - The possibility to use other objects inheriting from MData
+//    is missing.
+//  - By automatic pre-adding parantheses to the rule it would be possible
+//    to implement priorities for operators.
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MDataChain.h"
+
+#include <ctype.h>        // isalnum, ...
+#include <stdlib.h>       // strtod, ...
+
+#include <TRandom.h>
+#include <TMethodCall.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MDataList.h"
+#include "MDataValue.h"
+#include "MDataMember.h"
+#include "MDataFormula.h"
+#include "MDataElement.h"
+
+ClassImp(MDataChain);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+//  Constructor which takes a rule and a surrounding operator as argument
+//
+MDataChain::MDataChain(const char *rule, OperatorType_t op)
+    : fOperatorType(op)
+{
+    fName  = "MDataChain";
+    fTitle = rule;
+
+    fMember=ParseString(rule, 1);
+}
+
+// --------------------------------------------------------------------------
+//
+// Constructor taking a rule as an argument. For more details see
+// class description
+//
+MDataChain::MDataChain(const char *rule, const char *name, const char *title)
+    : fMember(NULL), fOperatorType(kENoop)
+{
+    fName  = name  ? name  : "MDataChain";
+    fTitle = title ? title : rule;
+
+    if (TString(rule).IsNull())
+        return;
+
+    *fLog << inf << "Trying to resolve rule... " << flush;
+    if (!(fMember=ParseString(rule, 1)))
+    {
+        *fLog << err << dbginf << "Parsing '" << rule << "' failed." << endl;
+        return;
+    }
+    *fLog << inf << "found: " << GetRule() << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// PreProcesses all members in the list
+//
+Bool_t MDataChain::PreProcess(const MParList *pList)
+{
+    return fMember ? fMember->PreProcess(pList) : kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Checks whether at least one member has the ready-to-save flag.
+//
+Bool_t MDataChain::IsReadyToSave() const
+{
+    *fLog << all << "fM=" << fMember << "/" << (int)fMember->IsReadyToSave() << " " << endl;
+    return fMember ? fMember->IsReadyToSave() : kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor. Delete filters.
+//
+MDataChain::~MDataChain()
+{
+    if (fMember)
+        delete fMember;
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the number of alphanumeric characters (including '.' and ';')
+// in the given string
+//
+Int_t MDataChain::IsAlNum(TString txt)
+{
+    int l = txt.Length();
+    for (int i=0; i<l; i++)
+    {
+        if (!isalnum(txt[i]) && txt[i]!='.' && txt[i]!=':' && txt[i]!=';' &&
+	    /*txt[i]!='['&&txt[i]!=']'&&*/
+            ((txt[i]!='-' && txt[i]!='+') || i!=0))
+            return i;
+    }
+
+    return l;
+}
+
+Int_t MDataChain::GetBracket(TString txt, char open, char close)
+{
+    Int_t first=1;
+    for (int cnt=0; first<txt.Length(); first++)
+    {
+        if (txt[first]==open)
+            cnt++;
+        if (txt[first]==close)
+            cnt--;
+        if (cnt==-1)
+            break;
+    }
+    return first;
+}
+
+// --------------------------------------------------------------------------
+//
+// Compare a given text with the known operators. If no operator match
+// kENoop is retunred, otherwise the corresponding OperatorType_t
+//
+MDataChain::OperatorType_t MDataChain::ParseOperator(TString txt) const
+{
+    txt.ToLower();
+
+    if (txt=="abs")    return kEAbs;
+    if (txt=="fabs")   return kEAbs;
+    if (txt=="log")    return kELog;
+    if (txt=="log2")   return kELog2;
+    if (txt=="log10")  return kELog10;
+    if (txt=="sin")    return kESin;
+    if (txt=="cos")    return kECos;
+    if (txt=="tan")    return kETan;
+    if (txt=="sinh")   return kESinH;
+    if (txt=="cosh")   return kECosH;
+    if (txt=="tanh")   return kETanH;
+    if (txt=="asin")   return kEASin;
+    if (txt=="acos")   return kEACos;
+    if (txt=="atan")   return kEATan;
+    if (txt=="asinh")  return kEASinH;
+    if (txt=="acosh")  return kEACosH;
+    if (txt=="atanh")  return kEATanH;
+    if (txt=="sqrt")   return kESqrt;
+    if (txt=="sqr")    return kESqr;
+    if (txt=="exp")    return kEExp;
+    if (txt=="pow10")  return kEPow10;
+    if (txt=="sgn")    return kESgn;
+    if (txt=="floor")  return kEFloor;
+    if (txt=="r2d")    return kERad2Deg;
+    if (txt=="d2r")    return kEDeg2Rad;
+    if (txt=="rand")   return kERandom;
+    if (txt=="randp")  return kERandomP;
+    if (txt=="rande")  return kERandomE;
+    if (txt=="randi")  return kERandomI;
+    if (txt=="randg")  return kERandomG;
+    if (txt=="randl")  return kERandomL;
+    if (txt=="isnan")  return kEIsNaN;
+    if (txt=="finite") return kEFinite;
+    if (txt[0]=='-')   return kENegative;
+    if (txt[0]=='+')   return kEPositive;
+
+    return kENoop;
+}
+
+// --------------------------------------------------------------------------
+//
+// Here the names of data members are interpreted. This can be used to
+// check for constants.
+//
+MData *MDataChain::ParseDataMember(TString txt)
+{
+    //txt.ToLower();
+
+    if (txt=="kRad2Deg") return new MDataValue(kRad2Deg);
+    if (txt=="kDeg2Rad") return new MDataValue(1./kRad2Deg);
+
+    if (!txt.BeginsWith("k"))
+        return new MDataMember(txt.Data());
+
+    const TString name = txt(1, txt.Length());
+    TMethodCall call(TMath::Class(), name, "");
+    switch (call.ReturnType())
+    {
+    case TMethodCall::kLong:
+        Long_t l;
+        call.Execute(l);
+        return new MDataValue(l);
+    case TMethodCall::kDouble:
+        Double_t d;
+        call.Execute(d);
+        return new MDataValue(d);
+    default:
+        break;
+    }
+
+    return new MDataMember(txt.Data());
+}
+
+void MDataChain::SimplifyString(TString &txt) const
+{
+    while (txt.First("--")>=0 || txt.First("++")>=0 ||
+           txt.First("+-")>=0 || txt.First("-+")>=0)
+    {
+        txt.ReplaceAll("--", "+");
+        txt.ReplaceAll("++", "+");
+        txt.ReplaceAll("-+", "-");
+        txt.ReplaceAll("+-", "-");
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Core of the data chain. Here the chain is constructed out of the rule.
+//
+MData *MDataChain::ParseString(TString txt, Int_t level)
+{
+    if (level==0)
+        SimplifyString(txt);
+
+    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 parantheses
+                //
+                const Int_t first=GetBracket(txt, '(', ')');
+                if (first==txt.Length())
+                {
+                    *fLog << err << dbginf << "Syntax Error: ')' missing." << endl;
+                    if (member0)
+                        delete member0;
+                    return NULL;
+                }
+
+                //
+                // Make a copy of the 'interieur' and delete the substring
+                // including the brackets
+                //
+                TString sub = txt(1, first-1);
+                txt.Remove(0, first+1);
+
+                //
+                // Parse the substring
+                //
+                newmember = ParseString(sub, level+1);
+                if (!newmember)
+                {
+                    *fLog << err << dbginf << "Parsing '" << sub << "' failed." << endl;
+                    if (member0)
+                        delete member0;
+                    return NULL;
+                }
+            }
+            break;
+
+        case ')':
+            *fLog << err << dbginf << "Syntax Error: Too many ')'" << endl;
+            if (member0)
+                delete member0;
+            return NULL;
+
+        case '+':
+        case '-':
+        case '*':
+        case '/':
+        case '%':
+        case '^':
+            if (member0)
+            {
+                //
+                // Check for the type of the symbol
+                //
+                char is = txt[0];
+                txt.Remove(0, 1);
+
+                //
+                // If no filter is available or the available filter
+                // is of a different symbols we have to create a new
+                // data list with the new symbol
+                //
+                if (/*!member0->InheritsFrom(MDataMember::Class()) ||*/ type!=is)
+                {
+                    MDataList *list = new MDataList(is);
+                    list->SetName(Form("List_%c_%d", is, 10*level+nlist++));
+
+                    list->SetOwner();
+                    list->AddToList(member0);
+
+                    member0 = list;
+
+                    type = is;
+                }
+                continue;
+            }
+
+            if (txt[0]!='-' && txt[0]!='+')
+            {
+                *fLog << err << dbginf << "Syntax Error: First argument of '";
+                *fLog << txt[0] << "' opartor missing." << endl;
+                if (member0)
+                    delete member0;
+                return NULL;
+            }
+
+            // FALLTHROU
+
+        case '0':
+        case '1':
+        case '2':
+        case '3':
+        case '4':
+        case '5':
+        case '6':
+        case '7':
+        case '8':
+        case '9':
+        case '[':
+        case ']':
+            if ((txt[0]!='-' && txt[0]!='+') || isdigit(txt[1]) || txt[1]=='.')
+            {
+                if (!txt.IsNull() && txt[0]=='[')
+                {
+                    Int_t first = GetBracket(txt, '[', ']');
+                    TString op  = txt(1, first-1);
+                    txt.Remove(0, first+1);
+
+                    newmember = new MDataValue(0, atoi(op));
+                    break;
+                }
+
+                char *end;
+                Double_t num = strtod(txt.Data(), &end);
+                if (!end || txt.Data()==end)
+                {
+                    *fLog << err << dbginf << "Error trying to convert '" << txt << "' to value." << endl;
+                    if (member0)
+                        delete member0;
+                    return NULL;
+                }
+
+                txt.Remove(0, end-txt.Data());
+
+                newmember = new MDataValue(num);
+                break;
+            }
+
+            // FALLTHROUH
+
+        default:
+            int i = IsAlNum(txt);
+
+            if (i==0)
+            {
+                *fLog << err << dbginf << "Syntax Error: Name of data member missing in '" << txt << "'" << endl;
+                if (member0)
+                    delete member0;
+                return NULL;
+            }
+
+            TString text = txt(0, i);
+
+            txt.Remove(0, i);
+            txt = txt.Strip(TString::kBoth);
+
+            if (!txt.IsNull() && txt[0]=='[')
+            {
+                Int_t first = GetBracket(txt, '[', ']');
+                TString op  = txt(1, first-1);
+                txt.Remove(0, first+1);
+
+                newmember = new MDataElement(text, atoi(op));
+                break;
+            }
+            if ((txt.IsNull() || txt[0]!='(') && text[0]!='-' && text[0]!='+')
+            {
+                newmember = ParseDataMember(text.Data());
+                break;
+            }
+
+            OperatorType_t op = ParseOperator(text);
+
+            Int_t first = GetBracket(txt, '(', ')');
+            TString sub = op==kENegative || op==kEPositive ? text.Remove(0,1) + txt : txt(1, first-1);
+            txt.Remove(0, first+1);
+
+            if (op==kENoop)
+            {
+                newmember = new MDataFormula(Form("%s(%s)", (const char*)text, (const char*)sub));
+                if (newmember->IsValid())
+                    break;
+
+                *fLog << err << dbginf << "Syntax Error: Operator '" << text << "' unknown." << endl;
+                if (member0)
+                    delete member0;
+                return NULL;
+            }
+
+            newmember = new MDataChain(sub, op);
+            if (!newmember->IsValid())
+            {
+                *fLog << err << dbginf << "Syntax Error: Error parsing contents '" << sub << "' of operator " << text << endl;
+                delete newmember;
+                if (member0)
+                    delete member0;
+                return NULL;
+            }
+        }
+
+        if (!member0)
+        {
+            member0 = newmember;
+            continue;
+        }
+
+        if (!member0->InheritsFrom(MDataList::Class()))
+            continue;
+
+        ((MDataList*)member0)->AddToList(newmember);
+    }
+
+    return member0;
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the value described by the rule
+//
+Double_t MDataChain::GetValue() const
+{
+    if (!fMember)
+    {
+        //*fLog << warn << "MDataChain not valid." << endl;
+        return 0;
+    }
+
+    const Double_t val = fMember->GetValue();
+
+    switch (fOperatorType)
+    {
+    case kEAbs:      return TMath::Abs(val);
+    case kELog:      return TMath::Log(val);
+    case kELog2:     return TMath::Log2(val);
+    case kELog10:    return TMath::Log10(val);
+    case kESin:      return TMath::Sin(val);
+    case kECos:      return TMath::Cos(val);
+    case kETan:      return TMath::Tan(val);
+    case kESinH:     return TMath::SinH(val);
+    case kECosH:     return TMath::CosH(val);
+    case kETanH:     return TMath::TanH(val);
+    case kEASin:     return TMath::ASin(val);
+    case kEACos:     return TMath::ACos(val);
+    case kEATan:     return TMath::ATan(val);
+    case kEASinH:    return TMath::ASinH(val);
+    case kEACosH:    return TMath::ACosH(val);
+    case kEATanH:    return TMath::ATanH(val);
+    case kESqrt:     return TMath::Sqrt(val);
+    case kESqr:      return val*val;
+    case kEExp:      return TMath::Exp(val);
+    case kEPow10:    return TMath::Power(10, val);
+    case kESgn:      return val<0 ? -1 : 1;
+    case kENegative: return -val;
+    case kEPositive: return val;
+    case kEFloor:    return TMath::Floor(val);
+    case kECeil:     return TMath::Ceil(val);
+    case kERound:    return TMath::Nint(val);
+    case kERad2Deg:  return val*180/TMath::Pi();
+    case kEDeg2Rad:  return val*TMath::Pi()/180;
+    case kERandom:   return gRandom ? gRandom->Uniform(val)      : 0;
+    case kERandomP:  return gRandom ? gRandom->Poisson(val)      : 0;
+    case kERandomE:  return gRandom ? gRandom->Exp(val)          : 0;
+    case kERandomI:  return gRandom ? gRandom->Integer((int)val) : 0;
+    case kERandomG:  return gRandom ? gRandom->Gaus(0, val)   : 0;
+    case kERandomL:  return gRandom ? gRandom->Landau(0, val) : 0;
+    case kEIsNaN:    return TMath::IsNaN(val);
+    case kEFinite:   return TMath::Finite(val);
+    case kENoop:     return val;
+    }
+
+    *fLog << warn << "No Case for " << fOperatorType << " available." << endl;
+
+    return 0;
+}
+
+// --------------------------------------------------------------------------
+//
+// Builds a rule from all the chain members. This is a rule which could
+// be used to rebuild the chain.
+//
+TString MDataChain::GetRule() const
+{
+    if (!fMember)
+        return "<n/a>";
+
+    TString str;
+
+    Bool_t bracket = fOperatorType!=kENoop && !fMember->InheritsFrom(MDataList::Class());
+
+    switch (fOperatorType)
+    {
+    case kEAbs:      str += "abs"   ; break;
+    case kELog:      str += "log"   ; break;
+    case kELog2:     str += "log2"  ; break;
+    case kELog10:    str += "log10" ; break;
+    case kESin:      str += "sin"   ; break;
+    case kECos:      str += "cos"   ; break;
+    case kETan:      str += "tan"   ; break;
+    case kESinH:     str += "sinh"  ; break;
+    case kECosH:     str += "cosh"  ; break;
+    case kETanH:     str += "tanh"  ; break;
+    case kEASin:     str += "asin"  ; break;
+    case kEACos:     str += "acos"  ; break;
+    case kEATan:     str += "atan"  ; break;
+    case kEASinH:    str += "asinh" ; break;
+    case kEACosH:    str += "acosh" ; break;
+    case kEATanH:    str += "atanh" ; break;
+    case kESqrt:     str += "sqrt"  ; break;
+    case kESqr:      str += "sqr"   ; break;
+    case kEExp:      str += "exp"   ; break;
+    case kEPow10:    str += "pow10" ; break;
+    case kESgn:      str += "sgn"   ; break;
+    case kENegative: str += "-"     ; break;
+    case kEPositive: str += "+"     ; break;
+    case kEFloor:    str += "floor" ; break;
+    case kECeil:     str += "ceil"  ; break;
+    case kERound:    str += "round" ; break;
+    case kERad2Deg:  str += "r2d"   ; break;
+    case kEDeg2Rad:  str += "d2r"   ; break;
+    case kERandom:   str += "rand"  ; break;
+    case kERandomP:  str += "randp" ; break;
+    case kERandomE:  str += "rande" ; break;
+    case kERandomI:  str += "randi" ; break;
+    case kERandomG:  str += "randg" ; break;
+    case kERandomL:  str += "randl" ; break;
+    case kEIsNaN:    str += "isnan" ; break;
+    case kEFinite:   str += "finite"; break;
+    case kENoop:
+        break;
+    }
+
+    if (bracket)
+        str += "(";
+
+    str += fMember->GetRule();
+
+    if (bracket)
+        str += ")";
+
+    return str;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return a comma seperated list of all data members used in the chain.
+// This is mainly used in MTask::AddToBranchList
+//
+TString MDataChain::GetDataMember() const
+{
+    return fMember->GetDataMember();
+}
+
+void MDataChain::SetVariables(const TArrayD &arr)
+{
+    return fMember->SetVariables(arr);
+}
Index: /tags/Mars_V0-8-5/Mars/mdata/MDataChain.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mdata/MDataChain.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mdata/MDataChain.h	(revision 9661)
@@ -0,0 +1,72 @@
+#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
+
+    // PLEASE, always add new enums to the end of the enumeration,
+    // otherwise you would break loading old data chains...
+    typedef enum {
+        kENoop,
+        kELog, kELog2, kELog10,
+        kEAbs,
+        kESin, kECos, kETan, kESinH, kECosH, kETanH,
+        kEASin, kEACos, kEATan, kEASinH, kEACosH, kEATanH,
+        kESqrt, kESqr, kEPow10, kEExp,
+        kESgn,
+        kEPositive,
+        kENegative,
+        kEFloor, kECeil, kERound,
+        kERad2Deg, kEDeg2Rad, kERandom,
+        kERandomP, kERandomE, kERandomI, kERandomG, kERandomL,
+        kEIsNaN, kEFinite
+    } OperatorType_t;
+
+    OperatorType_t fOperatorType;
+
+    OperatorType_t ParseOperator(TString txt) const;
+
+    Int_t IsAlNum(TString txt);
+    Int_t GetBracket(TString txt, char open, char close);
+
+    void   SimplifyString(TString &txt) const;
+    MData *ParseString(TString txt, Int_t level);
+    MData *ParseDataMember(TString txt);
+
+    MDataChain(const char *rule, OperatorType_t op);
+
+public:
+    MDataChain(const char *rule=NULL, const char *name=NULL, const char *title=NULL);
+    ~MDataChain();
+
+    Double_t GetValue() const;
+    Bool_t PreProcess(const MParList *plist);
+
+    Bool_t IsValid() const { return fMember ? kTRUE : kFALSE; }
+    Bool_t IsReadyToSave() const;
+
+//    void Print(Option_t *opt = "") const;
+
+    TString GetRule() const;
+    TString GetDataMember() const;
+
+    void SetVariables(const TArrayD &arr);
+
+    ClassDef(MDataChain, 1) // A chain/concatenation of MData objects
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mdata/MDataElement.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mdata/MDataElement.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mdata/MDataElement.cc	(revision 9661)
@@ -0,0 +1,121 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  04/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//   MDataElement
+//
+//  This MData class is used for accessing a column of an MHMatrix object.
+//    eg. MDataElement("Matrix", 5)
+//  will return the 5th column of the MHMatrix object called Matrix.
+//
+//  The row which is accessed must be set before by using
+//  MHMatrix::SetNumRow. If you want to loop through a matrix use
+//  MMatrixLoop.
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MDataElement.h"
+
+#include <fstream>
+
+#include "MHMatrix.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+ClassImp(MDataElement);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Specify the name of the MHMatrix-object and the column you want to
+// access.
+//
+MDataElement::MDataElement(const char *member, Int_t col)
+    : fMatrixName(member), fNumCol(col), fMatrix(NULL)
+{
+}
+
+// --------------------------------------------------------------------------
+//
+// Specify the pointer of the MHMatrix-object and the column you want to
+// access.
+//
+MDataElement::MDataElement(MHMatrix *mat, Int_t col)
+    : fMatrixName(mat->GetName()), fNumCol(col), fMatrix(mat)
+{
+}
+
+// --------------------------------------------------------------------------
+//
+// returns the value you requested
+//
+Double_t MDataElement::GetValue() const
+{
+    return fMatrix ? (*fMatrix)[fNumCol] : 0;
+}
+
+// --------------------------------------------------------------------------
+//
+//  If the pointer to the MHMatrix isn't yet set search for it in the
+// parameter list.
+//
+Bool_t MDataElement::PreProcess(const MParList *plist)
+{
+    if (fMatrix)
+        return kTRUE;
+
+    fMatrix = (MHMatrix*)plist->FindObject(fMatrixName, "MHMatrix");
+    if (!fMatrix)
+    {
+        *fLog << err << "MHMatrix '" << fMatrixName << "' not in parameter list... aborting." << endl;
+        return kFALSE;
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the ready-to-save flag of the data member container
+//
+Bool_t MDataElement::IsReadyToSave() const
+{
+    return IsValid() ? fMatrix->IsReadyToSave() : kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the rule used to identify this object in a datachain
+//
+TString MDataElement::GetRule() const
+{
+    TString rule = fMatrixName + "[";
+    rule += fNumCol;
+    rule += "]";
+    return rule;
+}
Index: /tags/Mars_V0-8-5/Mars/mdata/MDataElement.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mdata/MDataElement.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mdata/MDataElement.h	(revision 9661)
@@ -0,0 +1,43 @@
+#ifndef MARS_MDataElement
+#define MARS_MDataElement
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//  MDataElement                                                           //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#ifndef MARS_MData
+#include "MData.h"
+#endif
+
+class MHMatrix;
+
+class MDataElement : public MData
+{
+private:
+    TString   fMatrixName;
+    Int_t     fNumCol;
+
+    MHMatrix *fMatrix;
+
+public:
+    MDataElement(const char *member=NULL, Int_t col=-1);
+    MDataElement(MHMatrix *mat, Int_t col=-1);
+
+    Double_t GetValue() const;
+    Bool_t PreProcess(const MParList *plist);
+
+    Bool_t IsValid() const { return kTRUE; }
+    Bool_t IsReadyToSave() const;
+
+    //void Print(Option_t *opt = "") const;
+    TString GetRule() const;
+
+    Double_t operator()() { return GetValue(); }
+
+    void SetVariables(const TArrayD &arr) { }
+
+    ClassDef(MDataElement, 1) // MData object corresponding to a element of an MHMatrix
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mdata/MDataFormula.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mdata/MDataFormula.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mdata/MDataFormula.cc	(revision 9661)
@@ -0,0 +1,318 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MDataFormula
+//
+// A MDataFormula is a wrapper for TFormula. It should have access to all
+// multi-argument functions, to formulas and to single-argument functions
+// unknown by MDataChain intrinsically.
+//
+// eg.
+//  MDataFormula("myfunc(MParams.fValue)");
+//  MDataFormula("TMath::Hypot(MParams.fX, MParams.fY)");
+//  MDataFormula("TMath::Pow(MParams.fX, 7.5)");
+//  MDataFormula("TMath::Pow(MParams.fX, [6])");
+//
+// Using this should be rather slow. If you can create a 'plain' Data-Chain
+// this should be much faster.
+//
+// To do:
+//  - implement SetVariables to be used in functions like "gaus(0)" or
+//    "pol0(1)"
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MDataFormula.h"
+
+#include <TArrayD.h>
+#include <TFormula.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MDataChain.h"
+
+ClassImp(MDataFormula);
+
+using namespace std;
+
+TString MDataFormula::Parse(const char *rule)
+{
+    TString txt(rule);
+
+    Int_t pos1 = txt.First('(');
+    if (pos1<0)
+    {
+        *fLog << err << dbginf << "Syntax Error: '(' not found in " << txt << endl;
+        return "";
+    }
+
+    Int_t pos2 = txt.Last(')');
+    if (pos2<0)
+    {
+        *fLog << err << dbginf << "Syntax Error: ')' not found in " << txt << endl;
+        return "";
+    }
+
+    if (pos2<pos1+1)
+    {
+        *fLog << err << dbginf << "Syntax Error: '(' not behind ')' in " << txt << endl;
+        return "";
+    }
+
+    //TObject *func = gROOT->GetListOfFunctions()->FindObject(txt(0, pos1));
+
+    TString args = txt(pos1+1, pos2-pos1);
+    Int_t num = 0;
+
+    while (args.Length()>0 && num<5)
+    {
+        const Int_t last = args.First(',');
+        const Int_t len = last<0 ? args.Last(')') : last;
+        if (len<0)
+        {
+            *fLog << err << dbginf << "Syntax Error: ',' found after ')'" << endl;
+            return "";
+        }
+
+        const TString arg = args(0, len);
+
+        MDataChain *chain = new MDataChain(arg);
+        if (!chain->IsValid())
+        {
+            delete chain;
+            return "";
+        }
+        fMembers.AddLast(chain);
+
+        txt.ReplaceAll(arg, Form("[%d]", num++));
+        pos1 += len;
+
+        args.Remove(0, len+1);
+    }
+
+    return txt;
+}
+
+// --------------------------------------------------------------------------
+//
+//   Default Constructor. Not for usage!
+//
+MDataFormula::MDataFormula(const char *rule, const char *name, const char *title) : fFormula(0)
+{
+    fName  = name  ? name  : "MDataFormula";
+    fTitle = title ? title : rule;
+
+    fMembers.SetOwner();
+
+    if (!rule)
+        return;
+
+    const TString txt=Parse(rule);
+    if (txt.IsNull())
+    {
+        fMembers.Delete();
+        return;
+    }
+
+    fFormula = new TFormula;
+    if (fFormula->Compile(txt))
+    {
+        *fLog << err << dbginf << "Syntax Error: TFormula::Compile failed for " << txt << endl;
+        delete fFormula;
+        fFormula = 0;
+        return;
+    }
+
+    gROOT->GetListOfFunctions()->Remove(fFormula);
+}
+
+// --------------------------------------------------------------------------
+//
+//   Destructor
+//
+MDataFormula::~MDataFormula()
+{
+    if (fFormula)
+        delete fFormula;
+}
+
+// --------------------------------------------------------------------------
+//
+//   CopyConstructor
+//
+MDataFormula::MDataFormula(MDataFormula &ts)
+{
+    TFormula *f = ts.fFormula;
+
+    fName  = "MDataFormula";
+    fTitle = f ? f->GetExpFormula() : (TString)"";
+
+    fFormula = f ? (TFormula*)f->Clone() : 0;
+    gROOT->GetListOfFunctions()->Add(fFormula);
+
+    fMembers.SetOwner();
+
+    TObject *o = NULL;
+    TIter Next(&ts.fMembers);
+    while ((o=Next()))
+        fMembers.AddLast(o->Clone());
+}
+
+// --------------------------------------------------------------------------
+//
+//  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 MDataFormula::GetValue() const
+{
+    TArrayD val(fMembers.GetSize());
+
+    MData *member = NULL;
+
+    Int_t i=0;
+    TIter Next(&fMembers);
+    while ((member=(MData*)Next()))
+        val[i++] = member->GetValue();
+
+    return fFormula->EvalPar(0, val.GetArray());
+}
+
+Bool_t MDataFormula::IsValid() const
+{
+    TIter Next(&fMembers);
+
+    MData *data = NULL;
+    while ((data=(MData*)Next()))
+        if (!data->IsValid())
+            return kFALSE;
+
+    return fFormula ? kTRUE : kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Checks whether at least one member has the ready-to-save flag.
+//
+Bool_t MDataFormula::IsReadyToSave() const
+{
+    TIter Next(&fMembers);
+
+    MData *data = NULL;
+
+    while ((data=(MData*)Next()))
+        if (data->IsReadyToSave())
+            return kTRUE;
+
+    return kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+// PreProcesses all members in the list
+//
+Bool_t MDataFormula::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;
+}
+
+// --------------------------------------------------------------------------
+//
+// Builds a rule from all the list members. This is a rule which could
+// be used to rebuild the list using the constructor of a MDataChain
+//
+TString MDataFormula::GetRule() const
+{
+    if (!fFormula)
+        return "<empty>";
+
+    TString rule = fFormula->GetExpFormula();
+
+    MData *member = NULL;
+
+    Int_t i=0;
+    TIter Next(&fMembers);
+    while ((member=(MData*)Next()))
+    {
+        TString r = member->GetRule();
+        r.ReplaceAll("]", "\\]");
+        rule.ReplaceAll(Form("[%d]", i++), r);
+    }
+    rule.ReplaceAll("\\]", "]");
+
+    return rule;
+}
+/*
+// --------------------------------------------------------------------------
+//
+// Return a comma seperated list of all data members used in the chain.
+// This is mainly used in MTask::AddToBranchList
+//
+TString MDataFormula::GetDataMember() const
+{
+    TString str;
+
+    TIter Next(&fMembers);
+
+    MData *member=(MData*)Next();
+
+    if (!member->GetDataMember().IsNull())
+        str += member->GetDataMember();
+
+    while ((member=(MData*)Next()))
+    {
+        if (!member->GetDataMember().IsNull())
+        {
+            str += ",";
+            str += member->GetDataMember();
+        }
+    }
+
+    return str;
+}
+
+void MDataFormula::SetVariables(const TArrayD &arr)
+{
+    fMembers.ForEach(MData, SetVariables)(arr);
+}
+*/
Index: /tags/Mars_V0-8-5/Mars/mdata/MDataFormula.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mdata/MDataFormula.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mdata/MDataFormula.h	(revision 9661)
@@ -0,0 +1,43 @@
+#ifndef MARS_MDataFormula
+#define MARS_MDataFormula
+
+#ifndef ROOT_TOrdCollection
+#include <TOrdCollection.h>
+#endif
+
+#ifndef MARS_MData
+#include "MData.h"
+#endif
+
+class TFormula;
+class MParList;
+
+class MDataFormula : public MData
+{
+private:
+    TFormula      *fFormula;    // TFormula
+    TOrdCollection fMembers;	// Container for the filters
+
+    TString Parse(const char *rule);
+
+public:
+    MDataFormula(const char *rule=0, const char *name=0, const char *title=0);
+    MDataFormula(MDataFormula &ts);
+    ~MDataFormula();
+
+    Bool_t IsValid() const;// { return fFormula ? kTRUE : kFALSE; }
+    Bool_t IsReadyToSave() const;
+
+    Double_t GetValue() const;
+    Bool_t PreProcess(const MParList *plist);
+
+    //    void Print(Option_t *opt = "") const;
+    TString GetRule() const;
+    //    TString GetDataMember() const;
+
+    //void SetVariables(const TArrayD &arr);
+
+    ClassDef(MDataFormula, 1) // A concatenation of MData objects by one operator
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mdata/MDataList.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mdata/MDataList.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mdata/MDataList.cc	(revision 9661)
@@ -0,0 +1,401 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  04/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//   MDataList
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MDataList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MDataList);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+//   Default Constructor. Not for usage!
+//
+MDataList::MDataList()
+{
+    fSign = kENone;
+
+    gROOT->GetListOfCleanups()->Add(&fMembers);
+    fMembers.SetBit(kMustCleanup);
+}
+
+// --------------------------------------------------------------------------
+//
+//   Constructor.
+//
+//   Specify the operation which is used to evaluate the
+//   result of this list.
+//
+//   Options:
+//      *,  /,  -,  +
+//
+MDataList::MDataList(char type)
+{
+    switch (type)
+    {
+    case '*':
+        fSign = kEMult;
+        return;
+    case '/':
+        fSign = kEDiv;
+        return;
+    case '-':
+        fSign = kEMinus;
+        return;
+    case '+':
+        fSign = kEPlus;
+        return;
+    case '%':
+        fSign = kEModul;
+        return;
+    case '^':
+        fSign = kEPow;
+        return;
+    default:
+        fSign = kENone;
+    }
+
+    gROOT->GetListOfCleanups()->Add(&fMembers);
+    fMembers.SetBit(kMustCleanup);
+}
+
+// --------------------------------------------------------------------------
+//
+//   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()))
+        {
+            const Double_t d = member->GetValue();
+            if (d==0)
+            {
+                *fLog << warn << "Warning: Division by zero: " << member->GetRule() << endl;
+                return 0;
+            }
+            val /= d;
+        }
+        break;
+
+    case kEModul:
+        while ((member=(MData*)Next()))
+        {
+            const Double_t d = member->GetValue();
+            if (d==0)
+            {
+                *fLog << warn << "Warning: Modulo division by zero: " << member->GetRule() << endl;
+                return 0;
+            }
+            val = fmod(val, d);
+        }
+        break;
+    case kEPow:
+        while ((member=(MData*)Next()))
+            val = pow(val, member->GetValue());
+        break;
+    }
+    return val;
+}
+
+// --------------------------------------------------------------------------
+//
+// Checks whether at least one member has the ready-to-save flag.
+//
+Bool_t MDataList::IsReadyToSave() const
+{
+    TIter Next(&fMembers);
+
+    MData *data = NULL;
+
+    while ((data=(MData*)Next()))
+        if (data->IsReadyToSave())
+            return kTRUE;
+
+    return kFALSE;
+}
+
+Bool_t MDataList::IsValid() const
+{
+    TIter Next(&fMembers);
+
+    MData *data = NULL;
+    while ((data=(MData*)Next()))
+        if (!data->IsValid())
+            return kFALSE;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// 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;
+    }
+
+    member->SetBit(kMustCleanup);
+    fMembers.Add(member);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// PreProcesses all members in the list
+//
+Bool_t MDataList::PreProcess(const MParList *plist)
+{
+    TIter Next(&fMembers);
+
+    MData *member=NULL;
+
+    //
+    // loop over all members
+    //
+    while ((member=(MData*)Next()))
+        if (!member->PreProcess(plist))
+        {
+            *fLog << err << "Error - Preprocessing Data Member ";
+            *fLog << member->GetName() << " in " << fName << endl;
+            return kFALSE;
+        }
+
+    return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// If you want to use a verbose output ("and") instead of a symbolic ("&")
+// one the option string must conatin a "v"
+//
+/*
+void MDataList::Print(Option_t *opt) const
+{
+    *fLog << "(";
+
+    TIter Next(&fMembers);
+
+    TObject *member=Next();
+
+    //
+    // loop over all members
+    //
+    if (!member)
+    {
+        *fLog << "<empty>)" << flush;
+        return;
+    }
+
+    member->Print();
+
+    while ((member=Next()))
+    {
+        switch (fSign)
+        {
+        case kENone:
+            break;
+
+        case kEPlus:
+            *fLog << "+";
+            break;
+
+        case kEMinus:
+            *fLog << "-";
+            break;
+
+        case kEMult:
+            *fLog << "*";
+            break;
+
+        case kEDiv:
+            *fLog << "/";
+            break;
+        }
+
+        member->Print();
+    }
+
+    *fLog << ")" << flush;
+    }
+    */
+
+// --------------------------------------------------------------------------
+//
+// Builds a rule from all the list members. This is a rule which could
+// be used to rebuild the list using the constructor of a MDataChain
+//
+TString MDataList::GetRule() const
+{
+    TIter Next(&fMembers);
+
+    MData *member=(MData*)Next();
+
+    //
+    // loop over all members
+    //
+    if (!member)
+        return "(<empty>)";
+
+    TString str = "(";
+
+    str += member->GetRule();
+
+    while ((member=(MData*)Next()))
+    {
+        switch (fSign)
+        {
+        case kENone:
+            break;
+
+        case kEPlus:
+            str += "+";
+            break;
+
+        case kEMinus:
+            str += "-";
+            break;
+
+        case kEMult:
+            str += "*";
+            break;
+
+        case kEDiv:
+            str += "/";
+            break;
+
+        case kEModul:
+            str += "%";
+            break;
+
+        case kEPow:
+            str += "^";
+            break;
+        }
+
+        str += member->GetRule();
+    }
+
+    str += ")";
+
+    return str;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return a comma seperated list of all data members used in the chain.
+// This is mainly used in MTask::AddToBranchList
+//
+TString MDataList::GetDataMember() const
+{
+    TString str;
+
+    TIter Next(&fMembers);
+
+    MData *member=(MData*)Next();
+
+    if (!member->GetDataMember().IsNull())
+        str += member->GetDataMember();
+
+    while ((member=(MData*)Next()))
+    {
+        if (!member->GetDataMember().IsNull())
+        {
+            str += ",";
+            str += member->GetDataMember();
+        }
+    }
+
+    return str;
+}
+
+void MDataList::SetVariables(const TArrayD &arr)
+{
+    fMembers.ForEach(MData, SetVariables)(arr);
+}
Index: /tags/Mars_V0-8-5/Mars/mdata/MDataList.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mdata/MDataList.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mdata/MDataList.h	(revision 9661)
@@ -0,0 +1,58 @@
+#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, kEModul, kEPow } SignType_t;
+    SignType_t fSign;
+
+    enum { kIsOwner = BIT(14) };
+
+public:
+    MDataList();
+    MDataList(char type);
+    MDataList(MDataList &ts);
+    ~MDataList()
+    {
+        if (TestBit(kIsOwner))
+            fMembers.SetOwner();
+    }
+
+    Bool_t AddToList(MData *member);
+    void SetOwner(Bool_t enable=kTRUE) { enable ? SetBit(kIsOwner) : ResetBit(kIsOwner); }
+
+    Bool_t IsValid() const;// { return fMembers.GetSize() ? kTRUE : kFALSE; }
+    Bool_t IsReadyToSave() const;
+
+    Double_t GetValue() const;
+    Bool_t PreProcess(const MParList *plist);
+
+//    void Print(Option_t *opt = "") const;
+    TString GetRule() const;
+    TString GetDataMember() const;
+
+    void SetVariables(const TArrayD &arr);
+
+    ClassDef(MDataList, 1) // A concatenation of MData objects by one operator
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mdata/MDataMember.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mdata/MDataMember.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mdata/MDataMember.cc	(revision 9661)
@@ -0,0 +1,204 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  04/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//   MDataMember
+//
+//   This objects corresponds to the data member of another object.
+//   You can either specify the object as a string, eg "MHillas.fWidth"
+//   where MHillas is the name of the container in the parameterlist
+//   and fWidth is it's data member, or you can specify it by giving
+//   the pointer corresponding to the instance of your object and
+//   a TMethodCall pointer corresponding to the Member function returning
+//   the requested value.
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MDataMember.h"
+
+#include <fstream>
+
+#include <TMethodCall.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+ClassImp(MDataMember);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+//  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;
+
+    if (fCall->ReturnType()==TMethodCall::kLong)
+        SetBit(kIsInt);
+    else
+        ResetBit(kIsInt);
+
+    fDataMember = (TString)obj->GetName() + "." + call->GetName();
+}
+
+// --------------------------------------------------------------------------
+//
+//  obj is a pointer to the instance of your class from which the data
+//  should be requested. TMethodCall (s. root dox) is a pointer
+//  to a TMethodCall object which should be the getter function for
+//  the data you want to get.
+//
+MDataMember::MDataMember(MParContainer *obj, const TString call)
+{
+    fObject = obj;
+    fCall   = obj->GetterMethod(call);
+
+    if (fCall->ReturnType()==TMethodCall::kLong)
+        SetBit(kIsInt);
+    else
+        ResetBit(kIsInt);
+
+    fDataMember = (TString)obj->GetName() + "." + call;
+}
+
+// --------------------------------------------------------------------------
+//
+// returns the value you requested
+//
+Double_t MDataMember::GetValue() const
+{
+    if (!fCall)
+    {
+        *fLog << err << "No TMethodCall for " << fDataMember << " of ";
+        *fLog << fObject->GetName() << " available... returning 0." << endl;
+        return 0;
+    }
+
+    switch (fCall->ReturnType())
+    {
+    case TMethodCall::kLong:
+        Long_t l;
+        fCall->Execute(fObject, l);
+        return (Double_t)l;
+
+    case TMethodCall::kDouble:
+        Double_t v;
+        fCall->Execute(fObject, v);
+        return v;
+
+    default:
+        *fLog << err << "DataMember " << fDataMember << " of ";
+        *fLog << fObject->GetName() << " neither int nor float... returning 0." << endl;
+        return 0;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// If a string was given PreProcess try to resolv the object name and
+// tries to get it from the parlist. And also tries to resolve
+// the data member (variable) name you requested and tries to get a
+// corresponding TMethodCall from the root Dictionary.
+// Remark: If your Data Member is called fDataMember the corresponding
+//         getter Method in your class must be calles fDataMember
+//
+Bool_t MDataMember::PreProcess(const MParList *plist)
+{
+    // The following change has to be checked :
+    // In order that fCall is initialized properly
+    // the original statement "if (fCall)" is replaced by the statement
+    if (fCall && !fObject)
+            return kTRUE;
+
+    TString cname(fDataMember);
+    TString mname(fDataMember);
+
+    const char *dot = strrchr(cname, '.');
+
+    if (dot)
+    {
+        const int pos = dot-cname;
+
+        cname.Remove(pos);
+        mname.Remove(0, pos+1);
+    }
+
+    fObject = (MParContainer*)plist->FindObject(cname);
+    if (!fObject)
+    {
+        *fLog << err << "Object '" << cname << "' not in parameter list... aborting." << endl;
+        return kFALSE;
+    }
+
+    fCall = fObject->GetterMethod(mname);
+
+    return fCall ? kTRUE : kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the ready-to-save flag of the data member container
+//
+Bool_t MDataMember::IsReadyToSave() const
+{
+    return IsValid() ? fObject->IsReadyToSave() : kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Print the name of the data member without an CR.
+//
+/*
+void MDataMember::Print(Option_t *opt) const
+{
+    *fLog << fName << flush;
+}
+*/
+
+// --------------------------------------------------------------------------
+//
+// Builds a rule which cn be used in a MDataChain to describe this object
+//
+TString MDataMember::GetRule() const
+{
+    return fDataMember;
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the data member.
+// This is mainly used in MTask::AddToBranchList
+//
+TString MDataMember::GetDataMember() const
+{
+    return fDataMember;
+}
Index: /tags/Mars_V0-8-5/Mars/mdata/MDataMember.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mdata/MDataMember.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mdata/MDataMember.h	(revision 9661)
@@ -0,0 +1,50 @@
+#ifndef MARS_MDataMember
+#define MARS_MDataMember
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//  MDataMember                                                            //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MData
+#include "MData.h"
+#endif
+
+class MDataMember : public MData
+{
+private:
+    TString fDataMember;
+
+    MParContainer *fObject;
+    TMethodCall   *fCall;
+
+    enum { kIsInt = BIT(14) };
+
+public:
+    MDataMember(const char *member=NULL) : fObject(NULL), fCall(NULL)
+    {
+        fDataMember = member;
+    }
+
+    MDataMember(MParContainer *obj, TMethodCall *call);
+    MDataMember(MParContainer *obj, const TString call);
+
+    Double_t GetValue() const;
+    Bool_t PreProcess(const MParList *plist);
+
+    Bool_t IsValid() const { return fCall ? kTRUE : kFALSE; }
+    Bool_t IsReadyToSave() const;
+
+    //void Print(Option_t *opt = "") const;
+    TString GetRule() const;
+    TString GetDataMember() const;
+
+    Bool_t IsInt() const { return TestBit(kIsInt); }
+
+    void SetVariables(const TArrayD &arr) { }
+
+    ClassDef(MDataMember, 1) // MData object corresponding to a single data member of a Mars container
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mdata/MDataValue.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mdata/MDataValue.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mdata/MDataValue.cc	(revision 9661)
@@ -0,0 +1,68 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  04/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//   MDataValue
+//
+//   An MData object which corresponds to a simple value like 5.5, or 7.9
+//   it can be set as variable object by giving it an index in the
+//   constructor, only in this case SetVariables takes action
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MDataValue.h"
+
+#include <TArrayD.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MDataValue);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Return the value as a string
+//
+TString MDataValue::GetRule() const
+{
+    if (fIndex>=0)
+    {
+        TString str("[");
+        str += fIndex;
+        str += "]";
+        return str;
+    }
+
+    TString str;
+    str += fValue;
+    return str.Strip(TString::kBoth);
+}
+
+void MDataValue::SetVariables(const TArrayD &arr)
+{
+    if (fIndex>=0 && fIndex<arr.GetSize())
+        fValue = arr[fIndex];
+}
Index: /tags/Mars_V0-8-5/Mars/mdata/MDataValue.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mdata/MDataValue.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mdata/MDataValue.h	(revision 9661)
@@ -0,0 +1,34 @@
+#ifndef MARS_MDataValue
+#define MARS_MDataValue
+
+#ifndef MARS_MData
+#include "MData.h"
+#endif
+
+class TArrayD;
+
+class MDataValue : public MData
+{
+private:
+    Double_t fValue;
+    Int_t    fIndex;
+
+public:
+    MDataValue(Double_t v = 0, Int_t idx=-1) : fValue(v), fIndex(idx)
+    {
+    }
+
+    Double_t GetValue() const { return fValue; }
+    Bool_t PreProcess(const MParList *plist) { return kTRUE; }
+
+    Bool_t IsValid() const { return kTRUE; }
+    Bool_t IsReadyToSave() const { return kFALSE; }
+
+    TString GetRule() const;
+
+    void SetVariables(const TArrayD &arr);
+
+    ClassDef(MDataValue, 1) // MData object corresponding to a single value
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mdata/Makefile
===================================================================
--- /tags/Mars_V0-8-5/Mars/mdata/Makefile	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mdata/Makefile	(revision 9661)
@@ -0,0 +1,33 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#------------------------------------------------------------------------------
+
+INCLUDES = -I. -I../mbase -I../mhbase
+
+CINT     = Data
+
+SRCFILES = MData.cc \
+	   MDataArray.cc \
+           MDataElement.cc \
+	   MDataMember.cc \
+	   MDataValue.cc \
+	   MDataList.cc \
+	   MDataChain.cc \
+           MDataFormula.cc
+
+############################################################
+
+all: $(OBJS)
+
+include ../Makefile.rules
+
+mrproper:	clean rmbak
+
Index: /tags/Mars_V0-8-5/Mars/merpp.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/merpp.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/merpp.cc	(revision 9661)
@@ -0,0 +1,353 @@
+#include <TSystem.h>
+
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MEvtLoop.h"
+
+#include "MRawFileRead.h"
+#include "MSqlInsertRun.h"
+#include "MRawFileWrite.h"
+
+#include "MReportFileRead.h"
+#include "MWriteRootFile.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MArgs.h"
+#include "MTime.h"
+#include "MArray.h"
+#include "MRawEvtData.h"
+#include "MRawRunHeader.h"
+#include "MRawEvtHeader.h"
+#include "MRawCrateArray.h"
+
+#include "MFDataMember.h"
+
+using namespace std;
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+// 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")              //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+static void StartUpMessage()
+{
+    gLog << all << endl;
+
+    //                1         2         3         4         5
+    //       12345678901234567890123456789012345678901234567890
+    gLog << "==================================================" << endl;
+    gLog << "                MERPP - MARS V" << MARSVER          << endl;
+    gLog << "     MARS - Merging and Preprocessing Program"      << endl;
+    gLog << "            Compiled on <" << __DATE__ << ">"       << endl;
+    gLog << "               Using ROOT v" << ROOTVER             << endl;
+    gLog << "==================================================" << endl;
+    gLog << endl;
+}
+
+static void Usage()
+{
+    gLog << all << endl;
+    gLog << "Sorry the usage is:" << endl;
+    gLog << "   merpp [-h] [-?] [-a] [-vn] [-cn] [-u, -f]" << endl;
+    gLog << "         inputfile[.rep,[.raw],[.txt]] [outputfile[.root]]" << endl << endl;
+    gLog << "     inputfile.raw:  Magic DAQ binary file." << endl;
+    gLog << "     inputfile.rep:  Magic Central Control report file." << endl;
+    gLog << "     inputfile.txt:  Magic DC currents file." << endl;
+    gLog << "     ouputfile.root: Merpped root file." << endl;
+    gLog << "     -c#                              Compression level #=1..9 [default=2]" << endl;
+    gLog << "     -v#                              Verbosity level # [default=2]" << endl;
+    gLog << "     -u, --update                     Update file" << endl;
+    gLog << "     -a, --no-colors                  Do not use Ansii color codes" << endl;
+    gLog << "     -f                               Force overwrite of an existing file" << endl;
+    gLog << "     -ff                              Force merpp to ignore broken events <raw data only>" << endl;
+    gLog << "     --interleave=#                   Process only each i-th event [default=1]  <raw data only>" << endl;
+    gLog << "     --sql=mysql://user:password@url  Insert run into database <raw data only>" << endl;
+    gLog << "     --start=yyyy-mm-dd/hh:mm:ss.mmm  Start event time for merpping report files" << endl;
+    gLog << "     --stop=yyyy-mm-dd/hh:mm:ss.mmm   Stop  event time for merpping report files" << endl;
+    gLog << "     --run=#                          Only data corresponding to this run number" << endl;
+    gLog << "     --debug[=n]                      Enable root debugging (Default: gDebug=1)" << endl;
+    gLog << "     -?, -h, --help                   This help" << endl << endl;
+    gLog << "   REMARK: At the moment you can process a .raw _or_ a .rep file, only!" << endl << endl;
+}
+
+// FIXME: Move to MTime (maybe 'InterpreteCmdline')
+MTime AnalyseTime(TString str)
+{
+    Int_t y=0, ms=0, mon=0, d=0, h=0, m=0, s=0;
+
+    const Int_t n = sscanf(str.Data(), "%d-%d-%d/%d:%d:%d.%d", &y, &mon, &d, &h, &m, &s, &ms);
+
+    if (n<6 || n>7)
+    {
+        gLog << warn << "'" << str << "' no valid Time... ignored." << endl;
+        return MTime();
+    }
+
+    MTime t;
+    t.Set(y, mon, d, h, m, s, ms);
+    return t;
+}
+
+int main(const int argc, char **argv)
+{
+    StartUpMessage();
+
+    //
+    // Evaluate arguments
+    //
+    MArgs arg(argc, argv);
+
+    if (arg.HasOnly("-?") || arg.HasOnly("-h") || arg.HasOnly("--help"))
+    {
+        Usage();
+        return -1;
+    }
+
+    gLog.Setup(arg);
+
+    const Int_t kComprlvl = arg.HasOption("-c") ? arg.GetIntAndRemove("-c") : 2;
+    Bool_t kUpdate = arg.HasOnlyAndRemove("--update") || arg.HasOnlyAndRemove("-u");
+    const Bool_t kInterleave = arg.HasOption("--interleave=") ? arg.GetIntAndRemove("--interleave=") : 1;
+    const Bool_t kForce = arg.HasOnlyAndRemove("-f");
+    const Bool_t kForceProc = arg.HasOnlyAndRemove("-ff");
+
+    MTime kTimeStart;
+    MTime kTimeStop;
+    if (arg.HasOption("--star="))
+        kTimeStart = AnalyseTime(arg.GetStringAndRemove("--start="));
+    if (arg.HasOption("--stop="))
+        kTimeStop = AnalyseTime(arg.GetStringAndRemove("--stop="));
+
+    const Int_t   kRunNumber   = arg.HasOption("--run=") ? arg.GetIntAndRemove("--run=") : -1;
+    const TString kSqlDataBase(arg.GetStringAndRemove("--sql="));
+
+    if (kTimeStart)
+        gLog << inf << "Start Time: " << kTimeStart << endl;
+    if (kTimeStop)
+        gLog << inf << "Stop  Time: " << kTimeStop << endl;
+
+    if (arg.GetNumOptions()>0)
+    {
+        gLog << warn << "WARNING - Unknown commandline options..." << endl;
+        arg.Print("options");
+        gLog << endl;
+    }
+
+    //
+    // check for the right usage of the program
+    //
+    if (arg.GetNumArguments()<1 || arg.GetNumArguments()>2)
+    {
+        Usage();
+        return -1;
+    }
+
+    //
+    // This is to make argv[i] more readable insidethe code
+    //
+    TString kNamein  = arg.GetArgumentStr(0);
+    TString kNameout = arg.GetArgumentStr(1);
+
+    const Bool_t isreport = kNamein.EndsWith(".rep");
+    const Bool_t isdc     = kNamein.EndsWith(".txt");
+    const Bool_t israw    = !isreport && !isdc;
+
+    if (!kNamein.EndsWith(".raw") && israw)
+        kNamein += ".raw";
+
+    if (kNameout.IsNull())
+        kNameout = kNamein(0, kNamein.Last('.'));
+
+    if (!kNameout.EndsWith(".root"))
+        kNameout += ".root";
+
+    if (!kSqlDataBase.IsNull() && !israw)
+        gLog << warn << "WARNING - Option '--sql=' only valid for raw-files... ignored." << endl;
+
+    //
+    // Initialize Non-GUI (batch) mode
+    //
+    gROOT->SetBatch();
+
+    //
+    // check whether the given files are OK.
+    //
+    if (gSystem->AccessPathName(kNamein, kFileExists))
+    {
+        gLog << err << "Sorry, the input file '" << kNamein << "' doesn't exist." << endl;
+        return -1;
+    }
+
+    const Bool_t fileexist = !gSystem->AccessPathName(kNameout, kFileExists);
+    const Bool_t writeperm = !gSystem->AccessPathName(kNameout, kWritePermission);
+
+    if (fileexist && !writeperm)
+    {
+        gLog << err << "Sorry, you don't have write permission for '" << kNameout << "'." << endl;
+        return -1;
+    }
+
+    if (fileexist && !kUpdate && !kForce)
+    {
+        gLog << err << "Sorry, file '" << kNameout << "' already existing." << endl;
+        return -1;
+    }
+
+    if (!fileexist && kUpdate)
+    {
+        gLog << warn << "File '" << kNameout << "' doesn't yet exist." << endl;
+        kUpdate=kFALSE;
+    }
+
+    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;
+    tasks.SetOwner();
+    plist.AddToList(&tasks);
+
+    //
+    // ---- The 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;
+    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
+    //
+    MTask   *read   = 0;
+    MFilter *filter = 0;
+    MTask   *write  = 0;
+
+    const TString option(kUpdate ? "UPDATE" : "RECREATE");
+    if (isreport || isdc)
+    {
+        MWriteRootFile *w = new MWriteRootFile(kNameout, option, "Magic root-file", kComprlvl);
+        if (isdc)
+        {
+            w->AddContainer("MTimeCurrents",      "Currents");
+            w->AddContainer("MCameraDC",          "Currents");
+            w->AddContainer("MReportCurrents",    "Currents");
+        }
+        else
+        {
+            w->AddContainer("MReportCamera",      "Camera");
+            w->AddContainer("MTimeCamera",        "Camera");
+            w->AddContainer("MCameraAUX",         "Camera");
+            w->AddContainer("MCameraCalibration", "Camera");
+            w->AddContainer("MCameraCooling",     "Camera");
+            w->AddContainer("MCameraHV",          "Camera");
+            w->AddContainer("MCameraLV",          "Camera");
+            w->AddContainer("MCameraLids",        "Camera");
+            w->AddContainer("MReportTrigger",     "Trigger");
+            w->AddContainer("MTimeTrigger",       "Trigger");
+            w->AddContainer("MReportDrive",       "Drive");
+            w->AddContainer("MTimeDrive",         "Drive");
+            w->AddContainer("MReportCC",          "CC");
+            w->AddContainer("MTimeCC",            "CC");
+            // w->AddContainer("MReportDAQ",         "DAQ");
+            // w->AddContainer("MTimeDAQ",           "DAQ");
+        }
+        write = w;
+
+        MReportFileRead *r = new MReportFileRead(kNamein);
+        r->SetTimeStart(kTimeStart);
+        r->SetTimeStop(kTimeStop);
+        if (isdc)
+        {
+            r->SetHasNoHeader();
+            r->AddToList("MReportCurrents");
+        }
+        else
+        {
+            r->AddToList("MReportCC");
+            //r->AddToList("MReportDAQ");
+            r->AddToList("MReportDrive");
+            r->AddToList("MReportCamera");
+            r->AddToList("MReportTrigger");
+            if (kRunNumber>0)
+            {
+                r->AddToList("MReportRun");
+                filter = new MFDataMember("MReportRun.fRunNumber", '=', kRunNumber);
+                w->SetFilter(filter);
+            }
+        }
+        read = r;
+    }
+    else
+    {
+        read  = new MRawFileRead(kNamein);
+        static_cast<MRawFileRead*>(read)->SetInterleave(kInterleave);
+        static_cast<MRawFileRead*>(read)->SetForceMode(kForceProc);
+        write = new MRawFileWrite(kNameout, option, "Magic root-file", kComprlvl);
+    }
+
+    tasks.AddToList(read);
+    if (filter)
+        tasks.AddToList(filter);
+    if (israw && !kSqlDataBase.IsNull())
+    {
+        MSqlInsertRun *ins = new MSqlInsertRun(kSqlDataBase);
+        ins->SetUpdate();
+        tasks.AddToList(ins);
+    }
+    tasks.AddToList(write);
+
+    //
+    // create the looping object and tell 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 << err << "ERROR: Merging and preprocessing failed!" << endl;
+        return -1;
+    }
+
+    tasks.PrintStatistics();
+
+    gLog << all << "Merpp finished successfull!" << endl;
+    return 0;
+}
Index: /tags/Mars_V0-8-5/Mars/mfbase/FBaseIncl.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfbase/FBaseIncl.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfbase/FBaseIncl.h	(revision 9661)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-8-5/Mars/mfbase/FBaseLinkDef.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfbase/FBaseLinkDef.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfbase/FBaseLinkDef.h	(revision 9661)
@@ -0,0 +1,16 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class MFilterList+;
+
+#pragma link C++ class MF+;
+#pragma link C++ class MFEventSelector+;
+#pragma link C++ class MFEventSelector2+;
+#pragma link C++ class MFDataChain+;
+#pragma link C++ class MFDataMember+;
+#pragma link C++ class MFRealTimePeriod+;
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mfbase/MF.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfbase/MF.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfbase/MF.cc	(revision 9661)
@@ -0,0 +1,417 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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 parantheses:
+//   "MHillas.fSize>200 || (MHillas.fWidth<0.5 && MHillas.fLength<0.6)"
+//
+// If you want to use mathematic expressions (as defined in MDataChain)
+// you must encapsulate it in {}-parantheses, eg:
+//   "{log10(MHillas.fSize)}>3"
+//
+// The allowed logigal conditionals are:
+//   &&: logical and
+//   ||: logical or
+//   ^:  exclusive or
+//
+// As conditional signs, for now, only:
+//   <, >
+// are allowed.
+//
+//   -------->  '==' is NOT supported!
+//
+//
+// Warning: There is no priority rule build in. So better use parantheses
+//   to get correct results. The rule is parsed/evaluated from the left
+//   to the right, which means:
+//
+//   "MHillas.fSize>200 || MHillas.fWidth<0.5 && MHillas.fLength<0.6"
+//
+//    is parses as
+//
+//   "(MHillas.fSize>200 || MHillas.fWidth<0.5) && MHillas.fLength<0.6"
+//
+//
+// FIXME: The possibility to use also complete filters is missing.
+//        Maybe we can use gInterpreter->Calc("") for this.
+//        gROOT->ProcessLineFast("line");
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MF.h"
+
+#include <ctype.h>        // isalnum, ...
+#include <stdlib.h>       // strtod, ...
+#include <fstream>        // ofstream, ...
+
+#include <TMethodCall.h>
+
+#include "MParList.h"
+
+#include "MFilterList.h"
+#include "MFDataChain.h"
+#include "MFDataMember.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MF);
+
+using namespace std;
+
+const TString MF::gsDefName  = "MF";
+const TString MF::gsDefTitle = "Filter setup by a text-rule";
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor. Don't use.
+//
+MF::MF() : fF(NULL)
+{
+    fName  = gsDefName.Data();
+    fTitle = gsDefTitle.Data();
+}
+
+// --------------------------------------------------------------------------
+//
+// Constructor. For the text describing the filter rule please see
+// the class description above.
+//
+MF::MF(const char *text, const char *name, const char *title)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+
+    *fLog << inf << "Trying to resolve filter rule... " << flush;
+    if (!(fF=ParseString(text, 1)))
+    {
+        *fLog << err << dbginf << "Parsing '" << text << "' failed." << endl;
+        return;
+    }
+
+    *fLog << inf << "found: ";
+    fF->Print();
+    *fLog << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor. Delete filters.
+//
+MF::~MF()
+{
+    if (fF)
+        delete fF;
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the number of alphanumeric characters (including '.')
+// in the given string
+//
+Int_t MF::IsAlNum(TString txt) const
+{
+    int l = txt.Length();
+    for (int i = 0; i<l; i++)
+        if (!isalnum(txt[i]) && txt[i]!='.' && txt[i]!=';')
+            return i;
+
+    return l;
+}
+
+MFilter *MF::ParseRule(TString &txt, MFilter *filter0, Int_t level) const
+{
+    // For backward compatibility
+    txt.ReplaceAll("{", "(");
+    txt.ReplaceAll("}", ")");
+
+    const Int_t fg = txt.First('>');
+    const Int_t lg = txt.First('>');
+    const Int_t fl = txt.First('<');
+    const Int_t ll = txt.First('<');
+
+    if (fg<0 && fl<0)
+    {
+        *fLog << err << dbginf << "Syntax Error: No coditional sign found in " << txt << endl;
+        return NULL;
+    }
+    if (fg>=0 && fl>=0)
+    {
+        *fLog << err << dbginf << "Syntax Error: Two coditional signs found in " << txt << endl;
+        *fLog << "Currently you have to enclose all conditions in parantheses, like: \"(x<y) && (z<5)\"" << endl;
+        return NULL;
+    }
+    if (fg!=lg || fl!=ll)
+    {
+        *fLog << err << dbginf << "Syntax Error: Coditional sign found twice " << txt << endl;
+        return NULL;
+    }
+
+    const Int_t cond = fg<0 ? fl : fg;
+
+    const TString rule1 = txt(0, cond);
+    const TString rule2 = txt(cond+1, txt.Length());
+
+    Int_t lvl = gLog.GetDebugLevel();
+    gLog.SetDebugLevel(1);
+    MFilter *f = new MFDataChain(rule1.Data(), txt[cond], rule2.Data());
+    f->SetName(Form("Chain%02d%c", level, txt[cond]));
+    gLog.SetDebugLevel(lvl);
+
+    txt = "";
+
+    return f;
+}
+// --------------------------------------------------------------------------
+//
+// 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 parantheses
+                //
+                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 parantheses
+                //
+                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:
+            newfilter = ParseRule(txt, filter0, level++);
+            if (!newfilter)
+            {
+                if (filter0)
+                    delete filter0;
+                return NULL;
+            }
+        }
+
+        if (!filter0)
+        {
+            filter0 = newfilter;
+            continue;
+        }
+
+        if (!filter0->InheritsFrom(MFilterList::Class()))
+            continue;
+
+        ((MFilterList*)filter0)->AddToList(newfilter);
+    }
+
+    return filter0;
+}
+
+// --------------------------------------------------------------------------
+//
+// PreProcess all filters.
+//
+Int_t MF::PreProcess(MParList *plist)
+{
+    if (!fF)
+    {
+        *fLog << err << dbginf << "No filter rule available." << endl;
+        return kFALSE;
+    }
+
+    if (!fF->CallPreProcess(plist))
+    {
+        *fLog << err << dbginf << "PreProcessing filters in ";
+        *fLog << fName << " failed." << endl;
+        return kFALSE;
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Process all filters.
+//
+Int_t MF::Process()
+{
+    return fF->CallProcess();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Postprocess all filters.
+//
+Int_t MF::PostProcess()
+{
+    return fF->CallPostProcess();
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the result of the filter rule.
+//
+Bool_t MF::IsExpressionTrue() const
+{
+    return fF->IsConditionTrue();
+}
+
+void MF::StreamPrimitive(ofstream &out) const
+{
+    out << "   MF " << GetUniqueName();
+
+    if (!fF)
+    {
+        out << ";" << endl;
+        return;
+    }
+
+    out << "(\"" << fF->GetRule() << "\"";
+        if (fName!=gsDefName || fTitle!=gsDefTitle)
+    {
+        out << "(\"" << fName << "\"";
+        if (fTitle!=gsDefTitle)
+            out << ", \"" << fTitle << "\"";
+    }
+    out << ");" << endl;
+
+}
+
+void MF::Print(Option_t *opt) const
+{
+    *fLog << all << underline << GetDescriptor() << endl;
+    fF->Print();
+    *fLog << endl << endl;
+}
Index: /tags/Mars_V0-8-5/Mars/mfbase/MF.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfbase/MF.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfbase/MF.h	(revision 9661)
@@ -0,0 +1,52 @@
+#ifndef MARS_MF
+#define MARS_MF
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MF                                                                      //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MFilter
+#include "MFilter.h"
+#endif
+
+class MParList;
+class TMethodCall;
+
+class MF : public MFilter
+{
+private:
+    static const TString gsDefName;  //!
+    static const TString gsDefTitle; //!
+
+    MFilter *fF; // Filter
+
+    Int_t IsRule(TString &txt, TString &rule) const;
+    Int_t IsVal(const TString &txt) const;
+    Int_t IsAlNum(TString txt) const;
+
+    MFilter *ParseRule(TString &txt, MFilter *filter0, Int_t level) const;
+    MFilter *ParseString(TString txt, Int_t level);
+
+    void StreamPrimitive(ofstream &out) const;
+
+public:
+    MF();
+    MF(const char *text, const char *name=NULL, const char *title=NULL);
+    ~MF();
+
+    Bool_t IsExpressionTrue() const;
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
+    void Print(Option_t *opt="") const;
+
+    void SetVariables(const TArrayD &arr) { if (fF) fF->SetVariables(arr); }
+
+    ClassDef(MF, 0) // A Filter for cuts in any data member
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mfbase/MFDataChain.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfbase/MFDataChain.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfbase/MFDataChain.cc	(revision 9661)
@@ -0,0 +1,170 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  11/2002 <mailto:tbretz@astro.uni-wueruburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MFDataChain                                                              
+//
+// With this filter you can filter in all variables from Mars parameter
+// containers using rules (for more details see MDataChain).
+//
+// In the constructor you can give the filter variable, like
+//   "sqrt(MHillas.fLength*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:
+//   MFDataChain filter("sqr(MHillas.fLength)", '<', 150);
+//   MFDataChain filter("MHillas.fLength", '<', "MHillas.fWidth");
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MFDataChain.h"
+
+#include <fstream>
+
+#include <TMethodCall.h>
+
+#include "MParList.h"
+
+#include "MDataValue.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MFDataChain);
+
+using namespace std;
+
+MFDataChain::MFDataChain(const char *name, const char *title)
+    : fCond(0)
+{
+    fName  = name  ? name  : "MFDataChain";
+    fTitle = title ? title : "Filter using any data member of a class";
+}
+
+// --------------------------------------------------------------------------
+//
+MFDataChain::MFDataChain(const char *rule, const char type, const Double_t val,
+                         const char *name, const char *title)
+    : fData(rule), fCond(new MDataValue(val))
+{
+    fName  = name  ? name  : "MFDataChain";
+    fTitle = title ? title : "Filter using any data member of a class";
+
+    //AddToBranchList(member);
+
+    fFilterType = (type=='<' ? kELowerThan : kEGreaterThan);
+
+    if (type!='<' && type!='>')
+        *fLog << warn << dbginf << "Warning: Neither '<' nor '>' specified... using '>'." << endl;
+}
+
+MFDataChain::MFDataChain(const char *rule, const char type, const char *cond,
+                         const char *name, const char *title)
+    : fData(rule), fCond(new MDataChain(cond))
+{
+    fName  = name  ? name  : "MFDataChain";
+    fTitle = title ? title : "Filter using any data member of a class";
+
+    //AddToBranchList(member);
+
+    fFilterType = (type=='<' ? kELowerThan : kEGreaterThan);
+
+    if (type!='<' && type!='>')
+        *fLog << warn << dbginf << "Warning: Neither '<' nor '>' specified... using '>'." << endl;
+}
+
+MFDataChain::~MFDataChain()
+{
+    if (fCond)
+        delete fCond;
+}
+
+// --------------------------------------------------------------------------
+//
+Int_t MFDataChain::PreProcess(MParList *plist)
+{
+    if (!fCond)
+    {
+        *fLog << "No condition available - don't call default constructor!" << endl;
+        return kFALSE;
+    }
+    return fData.PreProcess(plist) && fCond->PreProcess(plist);
+}
+
+// --------------------------------------------------------------------------
+//
+Int_t MFDataChain::Process()
+{
+    const Double_t data = fData.GetValue();
+    const Double_t cond = fCond->GetValue();
+
+    switch (fFilterType)
+    {
+    case kELowerThan:
+        fResult = (data < cond);
+        return kTRUE;
+    case kEGreaterThan:
+        fResult = (data > cond);
+        return kTRUE;
+    }
+
+    return kFALSE;
+}
+
+void MFDataChain::Print(Option_t *) const
+{
+    *fLog << GetRule() << flush;
+}
+
+void MFDataChain::StreamPrimitive(ofstream &out) const
+{
+    out << "   MFDataChain " << GetUniqueName() << "(\"";
+    out << fData.GetRule() << "\", '";
+    out << (fFilterType==kELowerThan?"<":">");
+    out << "', ";
+
+    if (fCond->InheritsFrom(MDataValue::Class()))
+        out << ((MDataValue*)fCond)->GetValue();
+    else
+        out << "\"" << fCond->GetRule() << "\"";
+
+    out << ");" << endl;
+}
+
+TString MFDataChain::GetRule() const
+{
+    TString ret;// = "{";
+    ret += fData.GetRule();
+    //ret += "}";
+    ret += fFilterType==kELowerThan?"<":">";
+
+    TString str;
+    str += fCond->GetRule();
+    ret += str.Strip(TString::kBoth);
+    return ret;
+}
Index: /tags/Mars_V0-8-5/Mars/mfbase/MFDataChain.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfbase/MFDataChain.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfbase/MFDataChain.h	(revision 9661)
@@ -0,0 +1,58 @@
+#ifndef MARS_MFDataChain
+#define MARS_MFDataChain
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MFDataChain                                                                 //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MFilter
+#include "MFilter.h"
+#endif
+#ifndef MARS_MDataChain
+#include "MDataChain.h"
+#endif
+
+class MParList;
+
+class MFDataChain : public MFilter
+{
+private:
+    MDataChain fData;
+    MData     *fCond;
+
+    typedef enum { kELowerThan, kEGreaterThan } FilterType_t;
+    FilterType_t fFilterType;
+
+    Bool_t  fResult;           //!
+
+    void StreamPrimitive(ofstream &out) const;
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
+public:
+    MFDataChain(const char *name=NULL, const char *title=NULL);
+    MFDataChain(const char *rule, const char type, const Double_t val,
+                const char *name=NULL, const char *title=NULL);
+    MFDataChain(const char *rule, const char type, const char *cond,
+                const char *name=NULL, const char *title=NULL);
+    ~MFDataChain();
+
+    Bool_t IsExpressionTrue() const { return fResult; }
+
+    void Print(Option_t *opt = "") const;
+    TString GetRule() const;
+
+    void SetVariables(const TArrayD &arr)
+    {
+        fData.SetVariables(arr);
+        if (fCond)
+            fCond->SetVariables(arr);
+    }
+
+    ClassDef(MFDataChain, 1) // A Filter for cuts in any data member
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mfbase/MFDataMember.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfbase/MFDataMember.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfbase/MFDataMember.cc	(revision 9661)
@@ -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): Thomas Bretz  01/2002 <mailto:tbretz@astro.uni-wueruburg.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);
+//
+// You can test '<', '>' and '='. Warning: Using '=' may give strange results
+// in case you are comparing floating point values.
+//
+// In case the data member is detected to be an integer value, both
+// the data member and the val given as argument in the constructor
+// are castet to Long_t.
+//
+// To test != use the SetInverted() member function.
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MFDataMember.h"
+
+#include <fstream>
+
+#include <TMethodCall.h>
+
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MFDataMember);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+MFDataMember::MFDataMember(const char *member, const char type, const Double_t val,
+                           const char *name, const char *title)
+    : fData(member), fValue(val)
+{
+    fName  = name  ? name  : "MFDataMember";
+    fTitle = title ? title : "Filter using any data member of a class";
+
+    AddToBranchList(member);
+
+    switch (type)
+    {
+    case '>': fFilterType = kEGreaterThan; break;
+    case '<': fFilterType = kELowerThan;   break;
+    case '=': fFilterType = kEEqual;       break;
+    default:  fFilterType = kEGreaterThan; break;
+    }
+
+    if (type!='<' && type!='=' && type!='>')
+        *fLog << warn << dbginf << "Warning: Neither '<' nor '=' nor '>' specified... using '>'." << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+Int_t MFDataMember::PreProcess(MParList *plist)
+{
+    return fData.PreProcess(plist);
+}
+
+// --------------------------------------------------------------------------
+//
+Int_t MFDataMember::Process()
+{
+    if (fData.IsInt())
+    {
+        switch (fFilterType)
+        {
+        case kELowerThan:
+            fResult = ((Long_t)fData.GetValue() < (Long_t)fValue);
+            return kTRUE;
+        case kEGreaterThan:
+            fResult = ((Long_t)fData.GetValue() > (Long_t)fValue);
+            return kTRUE;
+        case kEEqual:
+            fResult = ((Long_t)fData.GetValue() == (Long_t)fValue);
+            return kTRUE;
+        }
+    }
+    else
+    {
+        switch (fFilterType)
+        {
+        case kELowerThan:
+            fResult = (fData.GetValue() < fValue);
+            return kTRUE;
+        case kEGreaterThan:
+            fResult = (fData.GetValue() > fValue);
+            return kTRUE;
+        case kEEqual:
+            fResult = (fData.GetValue() == fValue);
+            return kTRUE;
+        }
+    }
+
+    return kFALSE;
+}
+
+void MFDataMember::Print(Option_t *) const
+{
+    *fLog << GetRule() << flush;
+}
+
+void MFDataMember::StreamPrimitive(ofstream &out) const
+{
+    out << "   MFDataMember " << GetUniqueName() << "(\"";
+    out << fData.GetRule() << "\", '";
+    switch (fFilterType)
+    {
+    case kEGreaterThan: out << '>'; break;
+    case kELowerThan:   out << '<'; break;
+    case kEEqual:       out << '='; break;
+    }
+    out << "', " << fValue << ");" << endl;
+}
+
+TString MFDataMember::GetRule() const
+{
+    TString ret = fData.GetRule();
+    switch (fFilterType)
+    {
+    case kEGreaterThan: ret +='>'; break;
+    case kELowerThan:   ret +='<'; break;
+    case kEEqual:       ret +='='; break;
+    }
+
+    TString str;
+    str += fValue;
+
+    return ret+str.Strip(TString::kBoth);
+}
Index: /tags/Mars_V0-8-5/Mars/mfbase/MFDataMember.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfbase/MFDataMember.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfbase/MFDataMember.h	(revision 9661)
@@ -0,0 +1,46 @@
+#ifndef MARS_MFDataMember
+#define MARS_MFDataMember
+
+#ifndef MARS_MFilter
+#include "MFilter.h"
+#endif
+#ifndef MARS_MDataMember
+#include "MDataMember.h"
+#endif
+
+class MParList;
+
+class MFDataMember : public MFilter
+{
+private:
+    MDataMember fData;
+
+    typedef enum { kELowerThan, kEGreaterThan, kEEqual } FilterType_t;
+    FilterType_t fFilterType;
+
+    Bool_t  fResult;           //!
+    Double_t fValue;
+
+    void StreamPrimitive(ofstream &out) const;
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
+public:
+    enum {
+        kIsInt = BIT(14)
+    };
+    MFDataMember(const char *member, const char type, const Double_t val,
+                 const char *name=NULL, const char *title=NULL);
+
+    Bool_t IsExpressionTrue() const { return fResult; }
+
+    void Print(Option_t *opt = "") const;
+    TString GetRule() const;
+
+    void SetVariables(const TArrayD &arr) { fData.SetVariables(arr); }
+
+    ClassDef(MFDataMember, 1) // A Filter for cuts in any data member
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mfbase/MFEventSelector.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfbase/MFEventSelector.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfbase/MFEventSelector.cc	(revision 9661)
@@ -0,0 +1,228 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 01/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MFEventSelector
+//
+// This is a filter to make a selection of events from a file. At the
+// present implementation you can only use a random selection.
+//
+// This filter can be used for a random split...
+//
+// If you want to fill only 50% of your events into a histogram please use:
+//   MFEventSelector sel;
+//   sel.SetSelectionRatio(0.5);
+//   MFillH filler(...);
+//   filler.SetFilter(&sel);
+//   tlist.AddToList(&sel);
+//   tlist.AddToList(&filler);
+//
+// To get around 2000 events from all events use (Remark: This will only
+// work if the parlist has an entry called MTaskList which has a task
+// MRead inheriting from MRead):
+//   MFEventSelector sel;
+//   sel.SetNumSelectEvts(2000);
+//   MFillH filler(...);
+//   filler.SetFilter(&sel);
+//   tlist.AddToList(&sel);
+//   tlist.AddToList(&filler);
+//
+// If you don't have MRead available you have to set the number of
+// total events manually, using sel.SetNumTotalEvts(10732);
+//
+// The random number is generated using gRandom->Uniform(). You may
+// control this procedure using the global object gRandom.
+//
+// Because of the random numbers this works best for huge samples...
+//
+// Don't try to use this filter for the reading task: This won't work!
+//
+// Remark: You can also use the filter together with MContinue
+//
+//
+// FIXME: Merge MFEventSelector and MFEventSelector2
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MFEventSelector.h"
+
+#include <TRandom.h>
+
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MRead.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MFEventSelector);
+
+using namespace std;
+
+static const TString gsDefName  = "MFEventSelector";
+static const TString gsDefTitle = "Filter to select events";
+
+// --------------------------------------------------------------------------
+//
+// Constructor. For the text describing the filter rule please see
+// the class description above.
+//
+MFEventSelector::MFEventSelector(const char *name, const char *title)
+: fNumTotalEvts(-1), fNumSelectEvts(-1), fSelRatio(-1), fNumSelectedEvts(0)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+}
+
+// --------------------------------------------------------------------------
+//
+// Set a probability with which events are selected. Eg, f=0.5
+// will select roughly half of all events.
+//
+void MFEventSelector::SetSelectionRatio(Float_t f)
+{
+    if (f < 0)
+    {
+        *fLog << warn << "MFEventSelector::SetSelectionRatio: WARNING - Probability less than 0... set to 0." << endl;
+        f = 0;
+    }
+
+    if (f > 1)
+    {
+        *fLog << warn << "MFEventSelector::SetSelectionRatio: WARNING - Probability greater than 1... set to 1." << endl;
+        f = 1;
+    }
+    fSelRatio = f;
+}
+
+// --------------------------------------------------------------------------
+//
+// PreProcess all filters.
+//
+Int_t MFEventSelector::PreProcess(MParList *plist)
+{
+    fNumSelectedEvts = 0;
+
+    // In the case a ratio was set by the user we are done.
+    if (fSelRatio>0)
+        return kTRUE;
+
+    // If the number of total events wasn't set try to get it
+    if (fNumTotalEvts<0)
+    {
+        MTaskList *tlist = (MTaskList*)plist->FindObject("MTaskList");
+        if (!tlist)
+        {
+            *fLog << err << "Can't determin total number of events... no MTaskList." << endl;
+            return kFALSE;
+        }
+
+        MRead *read = (MRead*)tlist->FindObject("MRead");
+        if (!read)
+        {
+            *fLog << err << "Can't determin total number of events from 'MRead'." << endl;
+            return kFALSE;
+        }
+        fNumTotalEvts = read->GetEntries();
+
+        SetBit(kNumTotalFromFile);
+    }
+
+    // Calculate selection probability
+    fSelRatio = (Double_t)fNumSelectEvts/fNumTotalEvts;
+
+    *fLog << inf << "MFEventSelector:  Selection probability = " << fNumSelectEvts;
+    *fLog << "/" << fNumTotalEvts << " = " << Form("%.2f", fSelRatio) << endl;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Process all filters, FIXME: Make it fit the requested number of events
+// exactly like it is done in MFEventSelector2. This can be done by merging
+// both classes!
+//
+Int_t MFEventSelector::Process()
+{
+    fResult = gRandom->Uniform() < fSelRatio;
+
+    if (!fResult)
+        return kTRUE;
+
+    fNumSelectedEvts++;
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Postprocess all filters.
+//
+Int_t MFEventSelector::PostProcess()
+{
+    //---------------------------------
+    if (GetNumExecutions() != 0)
+    {
+        const Double_t sel = (Double_t)fNumSelectedEvts/GetNumExecutions();
+        const UInt_t   non = GetNumExecutions()-fNumSelectedEvts;
+
+        *fLog << inf << dec << setfill(' ') << endl;
+        *fLog << GetDescriptor() << " execution statistics:" << endl;
+
+        *fLog << " " << setw(7) << non << " (" << setw(3);
+        *fLog << (int)(100*(1-sel)) << "%) Events not selected" << endl;
+
+        *fLog << " " << setw(7) << fNumSelectedEvts << " (";
+        *fLog << (int)(100*sel) << "%) Events selected!" << endl;
+        *fLog << endl;
+    }
+
+    //---------------------------------
+    if (TestBit(kNumTotalFromFile))
+        fNumTotalEvts = -1;
+
+    return kTRUE;
+}
+
+void MFEventSelector::StreamPrimitive(ofstream &out) const
+{
+    /*
+    out << "   MF " << GetUniqueName();
+
+    if (!fFilter)
+    {
+        out << ";" << endl;
+        return;
+    }
+
+    out << "(\"" << fFilter->GetRule() << "\"";
+        if (fName!=gsDefName || fTitle!=gsDefTitle)
+    {
+        out << "(\"" << fName << "\"";
+        if (fTitle!=gsDefTitle)
+            out << ", \"" << fTitle << "\"";
+    }
+    out << ");" << endl;
+    */
+}
Index: /tags/Mars_V0-8-5/Mars/mfbase/MFEventSelector.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfbase/MFEventSelector.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfbase/MFEventSelector.h	(revision 9661)
@@ -0,0 +1,41 @@
+#ifndef MARS_MFEventSelector
+#define MARS_MFEventSelector
+
+#ifndef MARS_MFilter
+#include "MFilter.h"
+#endif
+
+class MParList;
+
+class MFEventSelector : public MFilter
+{
+private:
+    Int_t   fNumTotalEvts;    // Number of total events from which are selected
+    Int_t   fNumSelectEvts;   // Number of events to be selected
+    Float_t fSelRatio;        // Selection Probability
+
+    Int_t   fNumSelectedEvts; //! Number of events which have been selected
+
+    Bool_t  fResult;          //! Reseult of a single selection
+
+    void StreamPrimitive(ofstream &out) const;
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
+    enum { kNumTotalFromFile = BIT(14) };
+
+public:
+    MFEventSelector(const char *name=NULL, const char *title=NULL);
+
+    Bool_t IsExpressionTrue() const { return fResult; }
+
+    void SetNumTotalEvts(Int_t n)  { fNumTotalEvts = n; ResetBit(kNumTotalFromFile); }
+    void SetNumSelectEvts(Int_t n) { fNumSelectEvts = n; }
+    void SetSelectionRatio(Float_t f);
+
+    ClassDef(MFEventSelector, 0) // A filter to do a random selection of events
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mfbase/MFEventSelector2.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfbase/MFEventSelector2.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfbase/MFEventSelector2.cc	(revision 9661)
@@ -0,0 +1,500 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz,   01/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Wolfgang Wittek 11/2003 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MFEventSelector2
+//
+// This is a filter to make a selection of events from a file.
+//
+// see Construtor for more instructions and the example below:
+//
+// --------------------------------------------------------------------
+//
+// void select()
+// {
+//     MParList plist;
+//     MTaskList tlist;
+// 
+//     MStatusDisplay *d=new MStatusDisplay;
+// 
+//     plist.AddToList(&tlist);
+// 
+//     MReadTree read("Events", "myinputfile.root");
+//     read.DisableAutoScheme();
+//     // Accelerate execution...
+//     // read.EnableBranch("MMcEvt.fTelescopeTheta");
+// 
+//     // create nominal distribution (theta converted into degrees)
+//     MH3 nomdist("r2d(MMcEvt.fTelescopeTheta)");
+//     MBinning binsx;
+//     binsx.SetEdges(5, 0, 45);   // five bins from 0deg to 45deg
+//     MH::SetBinning(&nomdist.GetHist(), &binsx);
+//
+//     // use this to create a nominal distribution in 2D
+//     //  MH3 nomdist("r2d(MMcEvt.fTelescopeTheta)", "MMcEvt.fEnergy");
+//     //  MBinning binsy;
+//     //  binsy.SetEdgesLog(5, 10, 10000);
+//     //  MH::SetBinning((TH2*)&nomdist.GetHist(), &binsx, &binsy);
+//
+//     // Fill the nominal distribution with whatever you want:
+//     for (int i=0; i<nomdist.GetNbins(); i++)
+//         nomdist.GetHist().SetBinContent(i, i*i);
+// 
+//     MFEventSelector2 test(nomdist);
+//     test.SetNumMax(9999);  // total number of events selected
+//     MContinue cont(&test);
+// 
+//     MEvtLoop run;
+//     run.SetDisplay(d);
+//     run.SetParList(&plist);
+//     tlist.AddToList(&read);
+//     tlist.AddToList(&cont);
+// 
+//     if (!run.Eventloop())
+//         return;
+// 
+//     tlist.PrintStatistics();
+// }
+// 
+// --------------------------------------------------------------------
+//
+// The random number is generated using gRandom->Rndm(). You may
+// control this procedure using the global object gRandom.
+//
+// Because of the random numbers this works best for huge samples...
+//
+// Don't try to use this filter for the reading task or as a selector
+// in the reading task: This won't work!
+//
+// Remark: You can also use the filter together with MContinue
+//
+//
+// FIXME: Merge MFEventSelector and MFEventSelector2
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MFEventSelector2.h"
+
+#include <TRandom.h>        // gRandom
+#include <TCanvas.h>        // TCanvas
+
+#include "MH3.h"            // MH3
+#include "MRead.h"          // MRead
+#include "MEvtLoop.h"       // MEvtLoop
+#include "MTaskList.h"      // MTaskList
+#include "MBinning.h"       // MBinning
+#include "MFillH.h"         // MFillH
+#include "MParList.h"       // MParList
+#include "MStatusDisplay.h" // MStatusDisplay
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MFEventSelector2);
+
+using namespace std;
+
+const TString MFEventSelector2::gsDefName  = "MFEventSelector2";
+const TString MFEventSelector2::gsDefTitle = "Filter to select events with a given distribution";
+
+// --------------------------------------------------------------------------
+//
+// Constructor. Takes a reference to an MH3 which gives you
+//  1) The nominal distribution. The distribution is renormalized, so
+//     that the absolute values doesn't matter. To crop the distribution
+//     to a nominal value of total events use SetNumMax
+//  2) The dimension of the MH3 determins the dimension in which the
+//     event selector will work, eg
+//       MH3 hist("MMcEvt.fTelescopeTheta", "MMcEvt.fEnergy");
+//     Would result in a redistribution of Theta and Energy.
+//  3) The given rules are the variables which are used for the
+//     redistribution, eg:
+//       MH3 hist("MMcEvt.fTelescopeTheta");
+//     would result in redistributing Theta.
+//       MH3 hist("cos(MMcEvt.fTelescopeTheta)");
+//     would result in redistributing cos(Theta).
+//
+//  If the reference distribution doesn't contain entries (GetEntries()==0)
+//     the original distribution will be used as the nominal distribution;
+//     note that also in this case a dummy nominal distribution has to be
+//     provided in the first argument (the dummy distribution defines the
+//     variable(s) of interest and the binnings)
+//
+
+MFEventSelector2::MFEventSelector2(MH3 &hist, const char *name, const char *title)
+: fHistOrig(NULL), fHistNom(&hist), fHistRes(NULL),
+  fDataX(hist.GetRule('x')), fDataY(hist.GetRule('y')),
+  fDataZ(hist.GetRule('z')), fNumMax(-1)
+{
+    fName  = name  ? (TString)name  : gsDefName;
+    fTitle = title ? (TString)title : gsDefTitle;
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete fHistRes if instatiated
+//
+MFEventSelector2::~MFEventSelector2()
+{
+    if (fHistRes)
+        delete fHistRes;
+}
+
+//---------------------------------------------------------------------------
+//
+// Recreate a MH3 from fHistNom used as a template. Copy the Binning
+// from fHistNom to the new histogram, and return a pointer to the TH1
+// base class of the MH3.
+//
+TH1 &MFEventSelector2::InitHistogram(MH3* &hist)
+{
+    // if fHistRes is already allocated delete it first
+    if (hist)
+        delete hist;
+
+    // duplicate the fHistNom histogram
+    hist = (MH3*)fHistNom->New();
+
+    // copy binning from one histogram to the other one
+    MH::SetBinning(&hist->GetHist(), &fHistNom->GetHist());
+
+    return hist->GetHist();
+}
+
+// --------------------------------------------------------------------------
+//
+// Try to read the present distribution from the file. Therefore the
+// Reading task of the present loop is used in a new eventloop.
+//
+Bool_t MFEventSelector2::ReadDistribution(MRead &read)
+{
+    if (read.GetEntries() > kMaxUInt) // FIXME: LONG_MAX ???
+    {
+        *fLog << err << "kIntMax exceeded." << endl;
+        return kFALSE;
+    }
+
+    *fLog << inf << underline << endl;
+    *fLog << "MFEventSelector2::ReadDistribution:" << endl;
+    *fLog << " - Start of eventloop to generate the original distribution..." << endl;
+
+    MEvtLoop run(GetName());
+    MParList plist;
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+    run.SetParList(&plist);
+
+    MBinning binsx("BinningMH3X");
+    MBinning binsy("BinningMH3Y");
+    MBinning binsz("BinningMH3Z");
+    binsx.SetEdges(fHistNom->GetHist(), 'x');
+    binsy.SetEdges(fHistNom->GetHist(), 'y');
+    binsz.SetEdges(fHistNom->GetHist(), 'z');
+    plist.AddToList(&binsx);
+    plist.AddToList(&binsy);
+    plist.AddToList(&binsz);
+
+    MFillH fill(fHistOrig);
+    fill.SetBit(MFillH::kDoNotDisplay);
+    tlist.AddToList(&read);
+    tlist.AddToList(&fill);
+    run.SetDisplay(fDisplay);
+    if (!run.Eventloop())
+    {
+        *fLog << err << dbginf << "Evtloop in MFEventSelector2::ReadDistribution failed." << endl;
+        return kFALSE;
+    }
+
+    tlist.PrintStatistics();
+
+    *fLog << inf;
+    *fLog << "MFEventSelector2::ReadDistribution:" << endl;
+    *fLog << " - Original distribution has " << fHistOrig->GetHist().GetEntries() << " entries." << endl;
+    *fLog << " - End of eventloop to generate the original distribution." << endl;
+
+    return read.Rewind();
+}
+
+// --------------------------------------------------------------------------
+//
+// After reading the histograms the arrays used for the random event
+// selction are created. If a MStatusDisplay is set the histograms are
+// displayed there.
+//
+void MFEventSelector2::PrepareHistograms()
+{
+    TH1 &ho = fHistOrig->GetHist();
+
+    //-------------------
+    // if requested
+    // set the nominal distribution equal to the original distribution
+
+    const Bool_t useorigdist = fHistNom->GetHist().GetEntries()==0;
+    TH1 *hnp =  useorigdist ? (TH1*)(fHistOrig->GetHist()).Clone() : &fHistNom->GetHist();
+
+    TH1 &hn = *hnp;
+    //--------------------
+
+    // normalize to number of counts in primary distribution
+    hn.Scale(1./hn.Integral());
+
+    MH3 *h3 = NULL;
+    TH1 &hist = InitHistogram(h3);
+
+    hist.Divide(&hn, &ho);
+    hist.Scale(1./hist.GetMaximum());
+
+    if (fCanvas)
+    {
+        fCanvas->Clear();
+        fCanvas->Divide(2,2);
+
+        fCanvas->cd(1);
+        gPad->SetBorderMode(0);
+        hn.DrawCopy();
+
+        fCanvas->cd(2);
+        gPad->SetBorderMode(0);
+        ho.DrawCopy();
+    }
+    hn.Multiply(&ho, &hist);
+    hn.SetTitle("Resulting Nominal Distribution");
+
+    if (fNumMax>0)
+    {
+        *fLog << inf;
+        *fLog << "MFEventSelector2::PrepareHistograms:" << endl;
+        *fLog << " - requested number of events = " << fNumMax << endl;
+        *fLog << " - maximum number of events possible = " << hn.Integral() << endl;
+
+        if (fNumMax > hn.Integral())
+	{
+            *fLog << warn << "WARNING - Requested no.of events (" << fNumMax;
+            *fLog << ") is too high... reduced to " << hn.Integral() << endl;
+	}
+        else
+            hn.Scale(fNumMax/hn.Integral());
+    }
+
+    hn.SetEntries(hn.Integral()+0.5);
+    if (fCanvas)
+    {
+        fCanvas->cd(3);
+        gPad->SetBorderMode(0);
+        hn.DrawCopy();
+
+        fCanvas->cd(4);
+        gPad->SetBorderMode(0);
+        fHistRes->Draw();
+    }
+    delete h3;
+
+    const Int_t num = fHistRes->GetNbins();
+    fIs.Set(num);
+    fNom.Set(num);
+    for (int i=0; i<num; i++)
+    {
+        fIs[i]  = (Long_t)(ho.GetBinContent(i+1)+0.5);
+        fNom[i] = (Long_t)(hn.GetBinContent(i+1)+0.5);
+    }
+
+    if (useorigdist)
+      delete hnp;
+}
+
+// --------------------------------------------------------------------------
+//
+// PreProcess the data rules extracted from the MH3 nominal distribution
+//
+Bool_t MFEventSelector2::PreProcessData(MParList *parlist)
+{
+    switch (fHistNom->GetDimension())
+    {
+    case 3:
+        if (!fDataZ.PreProcess(parlist))
+        {
+            *fLog << err << "Preprocessing of rule for z-axis failed... abort." << endl;
+            return kFALSE;
+        }
+        // FALLTHROUGH!
+    case 2:
+        if (!fDataY.PreProcess(parlist))
+        {
+            *fLog << err << "Preprocessing of rule for y-axis failed... abort." << endl;
+            return kFALSE;
+        }
+        // FALLTHROUGH!
+    case 1:
+        if (!fDataX.PreProcess(parlist))
+        {
+            *fLog << err << "Preprocessing of rule for x-axis failed... abort." << endl;
+            return kFALSE;
+        }
+    }
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// PreProcess the filter. Means:
+//  1) Preprocess the rules
+//  2) Read The present distribution from the file.
+//  3) Initialize the histogram for the resulting distribution
+//  4) Prepare the random selection
+//  5) Repreprocess the reading task.
+//
+Int_t MFEventSelector2::PreProcess(MParList *parlist)
+{
+    memset(fCounter, 0, sizeof(fCounter));
+
+    MTaskList *tasklist = (MTaskList*)parlist->FindObject("MTaskList");
+    if (!tasklist)
+    {
+        *fLog << err << "MTaskList not found... abort." << endl;
+        return kFALSE;
+    }
+
+    MRead *read = (MRead*)tasklist->FindObject("MRead");
+    if (!read)
+    {
+        *fLog << err << "MRead not found... abort." << endl;
+        return kFALSE;
+    }
+
+    if (!PreProcessData(parlist))
+        return kFALSE;
+
+    InitHistogram(fHistOrig);
+    InitHistogram(fHistRes);
+
+    fHistNom->SetTitle("Users Nominal Distribution");
+    fHistOrig->SetTitle("Primary Distribution");
+    fHistRes->SetTitle("Resulting Distribution");
+
+    // Initialize online display if requested
+    fCanvas = fDisplay ? &fDisplay->AddTab(GetName()) : NULL;
+    if (fCanvas)
+        fHistOrig->Draw();
+
+    // Generate primary distribution
+    if (!ReadDistribution(*read))
+        return kFALSE;
+
+    // Prepare histograms and arrays for selection
+    PrepareHistograms();
+
+    return read->CallPreProcess(parlist);
+}
+
+// --------------------------------------------------------------------------
+//
+// Part of Process(). Select() at the end checks whether a selection should
+// be done or not. Under-/Overflowbins are rejected.
+//
+Bool_t MFEventSelector2::Select(Int_t bin)
+{
+    // under- and overflow bins are not counted
+    if (bin<0)
+        return kFALSE;
+
+    Bool_t rc = kFALSE;
+
+    if (gRandom->Rndm()*fIs[bin]<=fNom[bin])
+    {
+        // how many events do we still want to read in this bin
+        fNom[bin] -= 1;
+        rc = kTRUE;
+
+        // fill bin (same as Fill(valx, valy, valz))
+        TH1 &h = fHistRes->GetHist();
+        h.AddBinContent(bin+1);
+        h.SetEntries(h.GetEntries()+1);
+    }
+
+    // how many events are still pending to be read
+    fIs[bin] -= 1;
+
+    return rc;
+}
+
+// --------------------------------------------------------------------------
+//
+// fIs[i] contains the distribution of the events still to be read from
+// the file. fNom[i] contains the number of events in each bin which
+// are requested.
+// The events are selected by:
+//     gRandom->Rndm()*fIs[bin]<=fNom[bin]
+//
+Int_t MFEventSelector2::Process()
+{
+    // get x,y and z (0 if fData not valid)
+    const Double_t valx=fDataX.GetValue();
+    const Double_t valy=fDataY.GetValue();
+    const Double_t valz=fDataZ.GetValue();
+
+    // Get corresponding bin number and check
+    // whether a selection should be made
+    fResult = Select(fHistNom->FindFixBin(valx, valy, valz)-1);
+
+    fCounter[fResult ? 1 : 0]++;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Update online display if set.
+//
+Int_t MFEventSelector2::PostProcess()
+{
+    //---------------------------------
+
+    if (GetNumExecutions()>0)
+    {
+      *fLog << inf << endl;
+      *fLog << GetDescriptor() << " execution statistics:" << endl;
+      *fLog << dec << setfill(' ');
+      *fLog << " " << setw(7) << fCounter[1] << " (" << setw(3)
+            << (int)(fCounter[0]*100/GetNumExecutions())
+            << "%) Events not selected" << endl;
+
+      *fLog << " " << fCounter[0] << " ("
+            << (int)(fCounter[1]*100/GetNumExecutions())
+            << "%) Events selected" << endl;
+      *fLog << endl;
+    }
+
+    //---------------------------------
+
+    if (fDisplay && fDisplay->HasCanvas(fCanvas))
+    {
+        fCanvas->cd(4);
+        fHistRes->DrawClone("nonew");
+        fCanvas->Modified();
+        fCanvas->Update();
+    }
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mfbase/MFEventSelector2.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfbase/MFEventSelector2.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfbase/MFEventSelector2.h	(revision 9661)
@@ -0,0 +1,68 @@
+#ifndef MARS_MFEventSelector2
+#define MARS_MFEventSelector2
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MFEventSelector2                                                        //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MFilter
+#include "MFilter.h"
+#endif
+#ifndef ROOT_TArrayL
+#include <TArrayL.h>
+#endif
+#ifndef MARS_MDataChain
+#include "MDataChain.h"
+#endif
+
+class TH1;
+class TCanvas;
+
+class MH3;
+class MRead;
+
+class MFEventSelector2 : public MFilter
+{
+private:
+    static const TString gsDefName;
+    static const TString gsDefTitle;
+
+    MH3       *fHistOrig; // original distribution of the events
+    MH3       *fHistNom;  // nominal distribution
+    MH3       *fHistRes;  // resulting distribution
+    MDataChain fDataX;    // data rule for the x-axis
+    MDataChain fDataY;    // data rule for the y-axis
+    MDataChain fDataZ;    // data rule for the z-axis
+    Long_t     fNumMax;   // Maximum number of selected events
+    TArrayL    fIs;       //! array storing the original distribution
+    TArrayL    fNom;      //! array storing the nominal distribution
+    TCanvas   *fCanvas;   //! canvas for online display
+
+    Bool_t fResult;
+    Int_t  fCounter[2];
+
+    TH1   &InitHistogram(MH3* &hist);
+    Bool_t ReadDistribution(MRead &read);
+    void   PrepareHistograms();
+    Bool_t PreProcessData(MParList *parlist);
+    Bool_t Select(Int_t bin);
+
+    Int_t PreProcess(MParList *parlist);
+    Int_t Process();
+    Int_t PostProcess();
+
+public:
+    MFEventSelector2(MH3 &hist, const char *name=NULL, const char *title=NULL);
+    ~MFEventSelector2();
+
+    MH3 *GetHistOrig() { return fHistOrig; }
+
+    void SetNumMax(Long_t max=-1) { fNumMax = max; }
+    Bool_t IsExpressionTrue() const { return fResult; }
+
+    ClassDef(MFEventSelector2, 0) // FIMXE!
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mfbase/MFRealTimePeriod.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfbase/MFRealTimePeriod.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfbase/MFRealTimePeriod.cc	(revision 9661)
@@ -0,0 +1,59 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MFRealTimePeriod
+//
+//  This filter allows the execution of tasks in real time intervals. If
+//  a timeout (given in milliseconds in the constructor) was exceeded
+//  the return value for IsExpression is set to kTRUE and the timer is
+//  reset.
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MFRealTimePeriod.h"
+
+#include <TTime.h>
+#include <TSystem.h>
+
+ClassImp(MFRealTimePeriod);
+
+// --------------------------------------------------------------------------
+//
+// Check, whether the current time is greater than the stored time plus
+// the timeout time. If this is the case the return value of
+// IsExpressionTrue is set to kTRUE and the stored time is reset to the
+// current time. To get the current time gSystem->Now() is used.
+//
+Int_t MFRealTimePeriod::Process()
+{
+    const ULong_t t = (ULong_t)gSystem->Now();
+
+    fResult = t>fTime+fMilliSec;
+
+    if (fResult)
+        fTime=t;
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mfbase/MFRealTimePeriod.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfbase/MFRealTimePeriod.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfbase/MFRealTimePeriod.h	(revision 9661)
@@ -0,0 +1,31 @@
+#ifndef MARS_MFRealTimePeriod
+#define MARS_MFRealTimePeriod
+
+#ifndef MARS_MFilter
+#include "MFilter.h"
+#endif
+
+class MFRealTimePeriod : public MFilter
+{
+private:
+    ULong_t fTime;     //!
+    Bool_t  fResult;   //!
+
+    ULong_t fMilliSec;
+
+public:
+    MFRealTimePeriod(UInt_t millis=1000) : fTime(0), fMilliSec(millis)
+    {
+        fName  = "MFRealTimePeriod";
+        fTitle = "Filter allowing execution of a task only after a given real time interval";
+    }
+
+    void SetTime(UInt_t millis) { fMilliSec = millis; }
+
+    Int_t Process();
+    Bool_t IsExpressionTrue() const { return fResult; }
+
+    ClassDef(MFRealTimePeriod, 0) //Filter allowing execution of a task only after a given real time interval
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mfbase/MFilterList.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfbase/MFilterList.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfbase/MFilterList.cc	(revision 9661)
@@ -0,0 +1,420 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 07/2001 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//   MFilterList
+//
+// A filter list can be used to concatenate filter (derived from MFilter)
+// by a logical or bitwise operator. For more details see the constructor.
+//
+// The list is setup by adding filters to the list calling AddToList().
+// For example in the case of the default constructor ("&&") all results
+// are logically and'd together and the result of this and is returned.
+//
+// Because the meaning of all filters can be inverted calling SetInverted()
+// which is defined in the base class MFilter you can use this list to
+// invert the meaning of a filter, by eg:
+//
+//    MF anyfilter("MHillas.fAlpha");
+//
+//    MFilterList alist;
+//    alist.AddToList(&anyfilter);
+//
+//    alist.SetInverted();
+//
+//  or do
+//
+//    MFilterList alist(&anyfilter);
+//
+//
+// Adding the filterlist to the eventloop will process all contained filters.
+// Doing this as early as possible is a simple way of processing all filters.
+//
+// If you want to make the list delete all contained filters you may make
+// the list owner of the filters by calling SetOwner()
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MFilterList.h"
+
+#include <fstream>
+
+#include <TString.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MIter.h"
+
+ClassImp(MFilterList);
+
+using namespace std;
+
+static const TString gsDefName  = "MFilterList";
+static const TString gsDefTitle = "List combining filters logically.";
+
+// --------------------------------------------------------------------------
+//
+// Wrapper to simplify constructors.
+//
+void MFilterList::Init(const char *name, const char *title)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+
+    gROOT->GetListOfCleanups()->Add(&fFilters);
+    fFilters.SetBit(kMustCleanup);
+
+    fFilterType = kEAnd;
+}
+
+// --------------------------------------------------------------------------
+//
+//   Default 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
+//
+//   The bitwise operators are implemented for convinience. They may not
+//   make much sense. Maybe IsExpressionTrue should change its return
+//   type from Bool_t to Int_t.
+//
+MFilterList::MFilterList(const char *type, const char *name, const char *title)
+{
+    Init(name, title);
+
+    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;
+}
+
+// --------------------------------------------------------------------------
+//
+//   Constructor.
+//
+// Setup an '&&' filter list, adds the filter to the list and
+// call MFilterList::SetInverted()
+//
+// To be used as a logical NOT.
+//
+MFilterList::MFilterList(MFilter *f, const char *name, const char *title)
+{
+    Init(name, title);
+
+    SetInverted();
+    AddToList(f);
+}
+
+// --------------------------------------------------------------------------
+//
+//   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->IsConditionTrue();
+
+    //
+    // loop over all filters
+    //
+    switch (fFilterType)
+    {
+    case kEAnd:
+        while ((filter=(MFilter*)Next()))
+            rc &= filter->IsConditionTrue();
+        break;
+
+    case kEOr:
+        while ((filter=(MFilter*)Next()))
+            rc |= filter->IsConditionTrue();
+        break;
+
+    case kEXor:
+        while ((filter=(MFilter*)Next()))
+            rc ^= filter->IsConditionTrue();
+        break;
+
+    case kELAnd:
+        while ((filter=(MFilter*)Next()))
+            rc = (rc && filter->IsConditionTrue());
+        break;
+
+    case kELOr:
+        while ((filter=(MFilter*)Next()))
+            rc = (rc || filter->IsConditionTrue());
+        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 << inf << "MFilterList::AddToList - '" << name << "' exists in List already..." << endl;
+
+    *fLog << inf << "Adding " << name << " to " << GetName() << "... " << flush;
+
+    filter->SetBit(kMustCleanup);
+    fFilters.Add(filter);
+
+    *fLog << "Done." << endl;
+
+    return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// PreProcesses all filters in the list
+//
+Int_t MFilterList::PreProcess(MParList *pList)
+{
+    TIter Next(&fFilters);
+
+    MFilter *filter=NULL;
+
+    //
+    // loop over all filters
+    //
+    while ((filter=(MFilter*)Next()))
+        if (!filter->CallPreProcess(pList))
+        {
+            *fLog << err << "Error - Preprocessing Filter ";
+            *fLog << filter->GetName() << " in " << fName << endl;
+            return kFALSE;
+        }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Processes (updates) all filters in the list.
+//
+Int_t MFilterList::Process()
+{
+    TIter Next(&fFilters);
+
+    MFilter *filter=NULL;
+
+    //
+    // loop over all filters
+    //
+    while ((filter=(MFilter*)Next()))
+        if (!filter->CallProcess())
+            return kFALSE;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// PostProcesses all filters in the list.
+//
+Int_t MFilterList::PostProcess()
+{
+    TIter Next(&fFilters);
+
+    MFilter *filter=NULL;
+
+    //
+    // loop over all filters
+    //
+    while ((filter=(MFilter*)Next()))
+        if (!filter->CallPostProcess())
+            return kFALSE;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// If you want to use a verbose output ("and") instead of a symbolic ("&")
+// one the option string must conatin a "v"
+//
+void MFilterList::Print(Option_t *opt) const
+{
+    *fLog << all << GetRule(opt) << flush;
+}
+
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
+void MFilterList::StreamPrimitive(ofstream &out) const
+{
+    out << "   MFilterList " << ToLower(fName) << "(\"";
+
+    switch (fFilterType)
+    {
+    case kEAnd:
+        out << "&";
+        break;
+
+    case kEOr:
+        out  << "|";
+        break;
+
+    case kEXor:
+        out  << "^";
+        break;
+
+    case kELAnd:
+        out << "&&";
+        break;
+
+    case kELOr:
+        out << "||";
+        break;
+    }
+
+    out << "\"";
+
+    if (fName!=gsDefName || fTitle!=gsDefTitle)
+    {
+        out << ", \"" << fName << "\"";
+        if (fTitle!=gsDefTitle)
+            out << ", \"" << fTitle << "\"";
+    }
+    out << ");" << endl << endl;
+
+    MIter Next(&fFilters);
+
+    MParContainer *cont = NULL;
+    while ((cont=Next()))
+    {
+        cont->SavePrimitive(out, "");
+
+        out << "   " << ToLower(fName) << ".AddToList(&";
+        out << cont->GetUniqueName() << ");" << endl << endl;
+    }
+}
+
+TString MFilterList::GetRule(Option_t *opt) const
+{
+    TString str(opt);
+    const Bool_t verbose = str.Contains("V", TString::kIgnoreCase);
+
+    TString ret = "(";
+
+    TIter Next(&fFilters);
+
+    MFilter *filter=(MFilter*)Next();
+
+    //
+    // loop over all filters
+    //
+    if (!filter)
+        return "<empty>";
+
+    ret += filter->GetRule();
+
+    while ((filter=(MFilter*)Next()))
+    {
+        switch (fFilterType)
+        {
+        case kEAnd:
+            ret += (verbose?" and ":" & ");
+            break;
+
+        case kEOr:
+            ret += (verbose?" or ":" | ");
+            break;
+
+        case kEXor:
+            ret += (verbose?" xor ":" ^ ");
+            break;
+
+        case kELAnd:
+            ret += (verbose?" land ":" && ");
+            break;
+
+        case kELOr:
+            ret += (verbose?" lor ":" || ");
+            break;
+        }
+
+        ret += filter->GetRule();
+    }
+
+    return ret+")";
+}
+
+void MFilterList::SetVariables(const TArrayD &arr)
+{
+    fFilters.ForEach(MFilter, SetVariables)(arr);
+}
Index: /tags/Mars_V0-8-5/Mars/mfbase/MFilterList.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfbase/MFilterList.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfbase/MFilterList.h	(revision 9661)
@@ -0,0 +1,63 @@
+#ifndef MARS_MFilterList
+#define MARS_MFilterList
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//  MFilterList                                                            //
+//                                                                         //
+//  List of several filters                                                //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef ROOT_TOrdCollection
+#include <TOrdCollection.h>
+#endif
+#ifndef MARS_MFilter
+#include "MFilter.h"
+#endif
+
+class MParList;
+
+class MFilterList : public MFilter
+{
+private:
+    TOrdCollection fFilters;	// Container for the filters
+
+    typedef enum { kEAnd, kEOr, kEXor, kELAnd, kELOr } FilterType_t;
+    FilterType_t fFilterType;
+
+    enum { kIsOwner = BIT(14) };
+
+    void StreamPrimitive(ofstream &out) const;
+
+    void Init(const char *name, const char *title);
+
+public:
+    MFilterList(const char *type="&&", const char *name=NULL, const char *title=NULL);
+    MFilterList(MFilter *f, const char *name=NULL, const char *title=NULL);
+    MFilterList(MFilterList &ts);
+    ~MFilterList()
+    {
+        if (TestBit(kIsOwner))
+            fFilters.SetOwner();
+    }
+
+    Bool_t AddToList(MFilter *filter);
+    void SetOwner(Bool_t enable=kTRUE) { enable ? SetBit(kIsOwner) : ResetBit(kIsOwner); }
+
+    Bool_t IsExpressionTrue() const;
+
+    void Print(Option_t *opt = "") const;
+    TString GetRule() const { return GetRule(""); }
+    TString GetRule(Option_t *opt) const;
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
+    void SetVariables(const TArrayD &arr);
+
+    ClassDef(MFilterList, 1)		// List to combine several filters logically
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mfbase/Makefile
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfbase/Makefile	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfbase/Makefile	(revision 9661)
@@ -0,0 +1,31 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#------------------------------------------------------------------------------
+
+INCLUDES = -I. -I../mbase -I../mdata -I../mfileio -I../mhbase
+
+CINT     = FBase
+
+SRCFILES = MF.cc \
+           MFilterList.cc \
+           MFEventSelector.cc \
+           MFEventSelector2.cc \
+	   MFDataChain.cc \
+	   MFDataMember.cc \
+           MFRealTimePeriod.cc
+
+############################################################
+
+all: $(OBJS)
+
+include ../Makefile.rules
+
+mrproper:	clean rmbak
Index: /tags/Mars_V0-8-5/Mars/mfileio/FileIOIncl.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfileio/FileIOIncl.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfileio/FileIOIncl.h	(revision 9661)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-8-5/Mars/mfileio/FileIOLinkDef.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfileio/FileIOLinkDef.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfileio/FileIOLinkDef.h	(revision 9661)
@@ -0,0 +1,20 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class MChain+;
+#pragma link C++ class MRead+;
+#pragma link C++ class MReadTree+;
+#pragma link C++ class MReadReports+;
+#pragma link C++ class MReadMarsFile+;
+#pragma link C++ class MReadRflFile+;
+
+#pragma link C++ class MRootFileBranch+;
+
+#pragma link C++ class MWriteFile+;
+#pragma link C++ class MWriteAsciiFile+;
+#pragma link C++ class MWriteRootFile+;
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mfileio/MChain.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfileio/MChain.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfileio/MChain.cc	(revision 9661)
@@ -0,0 +1,60 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MChain                                                                  //
+//                                                                         //
+// Helper class for MReadTree                                              //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MChain.h"
+
+ClassImp(MChain);
+
+Int_t MChain::LoadTree(Int_t entry)
+{
+    //
+    // This is the code from TChain::LoadTree but skips the
+    // notification in LoadTree. If LoadTree raises the notification
+    // a flag is set and the notification is done by hand. This
+    // is done to be able to catch the return value from Notify. If
+    // it has not been successfull -15 is returned.
+    // This is to support return values from Notify()/Reinit()
+    //
+    TObject *notify = GetNotify();
+
+    SetNotify(this);
+
+    Int_t rc = TChain::LoadTree(entry);
+
+    if (rc >= 0 && fNotified && notify)
+        if (!notify->Notify())
+            rc = -15;
+
+    SetNotify(notify);
+
+    return rc;
+}
+
Index: /tags/Mars_V0-8-5/Mars/mfileio/MChain.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfileio/MChain.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfileio/MChain.h	(revision 9661)
@@ -0,0 +1,27 @@
+#ifndef MARS_MChain
+#define MARS_MChain
+
+#ifndef ROOT_TChain
+#include <TChain.h>
+#endif
+
+class MChain : public TChain
+{
+private:
+    Bool_t fNotified;
+
+public:
+    MChain() : TChain(), fNotified(kFALSE) {}
+    MChain(const char *name, const char *title="") : TChain(name, title), fNotified(kFALSE) {}
+
+    void ResetTree() { fTree = 0; fTreeNumber = -1; }
+
+    virtual Bool_t Notify() { fNotified = kTRUE; return kTRUE; }
+    virtual void   SetNotify(TObject *obj) { fNotify = obj; fNotified = kFALSE; }
+
+    Int_t LoadTree(Int_t entry);
+
+    ClassDef(MChain, 1) // Class derived from TChain to give access to Notify-return value
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mfileio/MRead.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfileio/MRead.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfileio/MRead.cc	(revision 9661)
@@ -0,0 +1,120 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MRead                                                                   //
+//                                                                         //
+// Base class for all reading tasks                                        //
+//                                                                         //
+// You can set a selector. Depending on the impelementation in the derived //
+// class it can be used to skip events, if the filter return kFALSE.       //
+// Make sure that the selector (filter) doesn't need information which     //
+// doesn't exist before reading an event!                                  //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MRead.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MDirIter.h"
+
+ClassImp(MRead);
+
+using namespace std;
+
+Bool_t MRead::Rewind()
+{
+    *fLog << err << "ERROR - Rewind() not implemented for " << GetDescriptor() << endl;
+    return kFALSE;
+}
+
+Int_t MRead::AddFiles(MDirIter &files)
+{
+    files.Reset();
+
+    Int_t rc = 0;
+
+    TString str;
+    while (!(str=files.Next()).IsNull())
+    {
+        const Int_t num = AddFile(str);
+        if (num<0)
+            *fLog << warn << "Warning: AddFile(\"" << str << "\") returned " << num << "... skipped." << endl;
+        else
+            rc += num;
+    }
+
+    return rc;
+}
+
+// --------------------------------------------------------------------------
+//
+// Read the setup from a TEnv:
+//   File0, File1, File2, ..., File10, ..., File100, ...
+//
+// Searching stops if the first key isn't found in the TEnv
+//
+// Enclosing quotation marks (") are removed
+//
+// Number of entries at the moment not supported
+//
+Bool_t MRead::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
+{
+    //
+    // Search (beginning with 0) all keys
+    //
+    int i=0;
+    while (1)
+    {
+        TString idx = "File";
+        idx += i;
+
+        // Output if print set to kTRUE
+        if (!IsEnvDefined(env, prefix, idx, print))
+            break;
+
+        // Try to get the file name
+        TString name = GetEnvValue(env, prefix, idx, "");
+        if (name.IsNull())
+        {
+            *fLog << warn << prefix+"."+idx << " empty." << endl;
+            continue;
+        }
+
+        if (name.BeginsWith("\"") && name.EndsWith("\""))
+        {
+            name.Remove(name.Last('\"'), 1);
+            name.Remove(name.First('\"'), 1);
+        }
+
+        *fLog << inf << "Add File: " << name << endl;
+
+        AddFile(name);
+        i++;
+    }
+
+    return i!=0;
+}
Index: /tags/Mars_V0-8-5/Mars/mfileio/MRead.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfileio/MRead.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfileio/MRead.h	(revision 9661)
@@ -0,0 +1,33 @@
+#ifndef MARS_MRead
+#define MARS_MRead
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MFilter;
+class MDirIter;
+
+class MRead : public MTask
+{
+private:
+    MFilter *fSelector;
+
+public:
+    MRead() : fSelector(NULL) {}
+
+    virtual UInt_t GetEntries() = 0;
+    virtual Bool_t Rewind();
+
+    void SetSelector(MFilter *f) { fSelector = f; }
+    MFilter *GetSelector() { return fSelector; }
+
+    virtual Int_t AddFile(const char *fname, Int_t entries=-1) { return -1; }
+    Int_t AddFiles(MDirIter &dir);
+
+    Bool_t ReadEnv(const TEnv &env, TString prefix, Bool_t print);
+
+    ClassDef(MRead, 0)	// Base class for a reading task
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mfileio/MReadMarsFile.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfileio/MReadMarsFile.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfileio/MReadMarsFile.cc	(revision 9661)
@@ -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@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MReadMarsFile                                                           //
+//                                                                         //
+// This task works more or less like MReadTree, but in addition PreProcess //
+// reads all the information from the 'RunHeader' tree.                    //
+//                                                                         //
+// Warning: Until now this works only for 'one run header per file'        //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MReadMarsFile.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MTaskList.h"
+
+#include "MRawRunHeader.h"
+#include "MStatusDisplay.h"
+
+#include "MMcRunHeader.hxx"
+
+ClassImp(MReadMarsFile);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+//  Default constructor. Don't use it.
+//
+MReadMarsFile::MReadMarsFile() : fRun(NULL)
+{
+    fName  = "MRead";
+    fTitle = "Read tree and run headers from Mars file.";
+}
+
+// --------------------------------------------------------------------------
+//
+//  Default constructor. It creates a MReadTree object to read the
+//  RunHeaders and disables Auto Scheme for this tree.
+//
+MReadMarsFile::MReadMarsFile(const char *tname, const char *fname,
+                             const char *name, const char *title)
+    : MReadTree(tname, fname)
+{
+    fName  = name  ? name  : "MRead";
+    fTitle = title ? title : "Read tree and run headers from Mars file.";
+
+    //
+    // open the input stream
+    //
+    fRun = new MReadTree("RunHeaders", fname, "ReadRunHeaders");
+
+    //
+    // This disables the auto scheme. because reading new runheader is done
+    // at a low frequency we don't loose time if we always read all
+    // runheaders
+    //
+    fRun->DisableAutoScheme();
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor. Deleted the MReadTree object for the RunHeaders
+//
+MReadMarsFile::~MReadMarsFile()
+{
+    delete fRun;
+}
+
+// --------------------------------------------------------------------------
+//
+//  see MReadTree::AddFile, too. The file is also added to the chain for
+//  the run headers. If adding file gives a different result for both
+//  chains -1 is returned, otherwise the number of files which were added.
+//
+Int_t MReadMarsFile::AddFile(const char *fname, Int_t entries)
+{
+    //
+    // 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, entries);
+
+    return n1 != n2 ? -1 : n1;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Sort the files by their file-names
+//
+void MReadMarsFile::SortFiles()
+{
+    fRun->SortFiles();
+    MReadTree::SortFiles();
+}
+
+// --------------------------------------------------------------------------
+//
+//  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()
+{
+    UInt_t runtype = 0xffff;
+
+    const MRawRunHeader *rawheader = (MRawRunHeader*)fParList->FindObject("MRawRunHeader");
+    if (rawheader)
+        runtype = rawheader->GetRunType();
+
+    //
+    // Try to read the new run headers. If reading the new run header
+    // was successfull call the ReInits
+    //
+    const Int_t idx = GetFileIndex();
+    fRun->SetEventNum(idx<0?0:idx); // Assumption: One Entry per File!
+    if (!fRun->Process())
+    {
+        *fLog << err << "ERROR - Cannot read new runheaders #" << idx;
+        *fLog << " after reading event #" << GetNumEntry() << endl;
+        return kFALSE;
+    }
+
+    if (!MReadTree::Notify())
+        return kFALSE;
+
+    if (rawheader && runtype!=0xffff && runtype != rawheader->GetRunType())
+    {
+        *fLog << warn << "Warning - You are mixing files with different run types (";
+        *fLog << runtype << ", " << rawheader->GetRunType() << ")" << endl;
+    }
+
+    if (fDisplay)
+    {
+        TString txt = GetFileName();
+        txt += " @ ";
+        txt += GetNumEntry()-1;
+        fDisplay->SetStatusLine2(txt);
+    }
+
+    const MMcRunHeader *mcheader = (MMcRunHeader*)fParList->FindObject("MMcRunHeader");
+    if (mcheader)
+    {
+        if (mcheader->GetReflVersion()<=40 && mcheader->GetTelesTheta()>15)
+        {
+            *fLog << warn << "Warning - You may use Monte Carlo data produced with a version" << endl;
+            *fLog << "of the reflector program < 0.4 and a zenith angle > 15," << endl;
+            *fLog << "in this case you may get less photons than you would expect." << endl;
+        }
+        if (mcheader->GetCamVersion()==50)
+        {
+            *fLog << warn << "Warning - You are using a file created with Camera 0.5." << endl;
+            *fLog << "In this camera version some events have undefined Impact-Values" << endl;
+            *fLog << "(MMcEvt::fImpact) Please don't use it for MC studies using the" << endl;
+            *fLog << "impact parameter." << endl;
+        }
+    }
+
+    MTaskList *tlist = (MTaskList*)fParList->FindObject("MTaskList");
+    if (!tlist)
+    {
+        *fLog << err << dbginf << "ERROR - Task List not found in Parameter List." << endl;
+        return kFALSE;
+    }
+
+    if (tlist->ReInit())
+        return kTRUE;
+
+    //MReadTree::Notify();
+
+    *fLog << err << "ERROR - ReInit of '" << tlist->GetDescriptor() << "' failed." << endl;
+    return kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  PreProcessed the MReadTree to read the run headers and its base class.
+//  see MReadTree::PreProcess for more information
+//
+Int_t MReadMarsFile::PreProcess(MParList *pList)
+{
+    fParList = pList;
+
+    if (!fRun->PreProcess(pList))
+    {
+        *fLog << err << "Error - PreProcessing MReadMarsFile::fRun... aborting." << endl;
+        return kFALSE;
+    }
+
+    /*
+    const Int_t idx = GetFileIndex();
+    fRun->SetEventNum(idx<0?0:idx); // Assumption: One Entry per File!
+    if (!fRun->Process())
+    {
+        *fLog << err << "Error - Processing MReadMarsFile::fRun... aborting." << endl;
+        return kFALSE;
+    }
+    */
+    return MReadTree::PreProcess(pList);
+}
Index: /tags/Mars_V0-8-5/Mars/mfileio/MReadMarsFile.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfileio/MReadMarsFile.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfileio/MReadMarsFile.h	(revision 9661)
@@ -0,0 +1,35 @@
+#ifndef MARS_MReadMarsFile
+#define MARS_MReadMarsFile
+
+#ifndef MARS_MReadTree
+#include "MReadTree.h"
+#endif
+
+class MParList;
+class MTaskList;
+
+class MReadMarsFile : public MReadTree
+{
+private:
+    MReadTree *fRun;
+    MParList  *fParList;  //! Parlist for reinitialization
+
+    Bool_t Notify();
+
+    Int_t PreProcess(MParList *pList);
+  
+public:
+    MReadMarsFile();
+    MReadMarsFile(const char *treename, const char *filename=NULL, const char *name=NULL, const char *title=NULL);
+    ~MReadMarsFile();
+
+    void SortFiles();
+
+    Int_t AddFile(const char *fname, Int_t entries=-1);
+
+    Bool_t Rewind() { if (fRun) fRun->Rewind(); MReadTree::Rewind(); return kTRUE; }
+
+    ClassDef(MReadMarsFile, 1)	// Reads a tree from file(s) and the information from the 'RunHeader'-tree
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mfileio/MReadReports.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfileio/MReadReports.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfileio/MReadReports.cc	(revision 9661)
@@ -0,0 +1,392 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MReadReports
+//
+// Read from a file events from different trees ordered in time, eg:
+//
+// Having a file with:
+//
+//      Tree1         Tree2         Tree3
+//      ------------  ------------  -----------
+//      (0) MTime[0]
+//                    (0) MTime[1]
+//      (1) MTime[2]
+//      (2) MTime[3]
+//                                  (0) MTime[1]
+//      (3) MTime[4]
+//
+// MReadReports will read the events in the tree in the following order:
+//   <0> (0) from Tree1
+//   <1> (0) from Tree2
+//   <2> (1) from Tree1
+//   <3> (2) from Tree1
+//   <4> (0) from Tree3
+//   <5> (3) from Tree1
+//   ...
+//
+// To tell MReadReports which Trees to read use: MReadReports::AddTree()
+// To schedule a file for reading use MReadReports::AddFile()
+//
+// All calls to AddTree _must_ be before the calls to AddFile!
+//
+// After reading from a tree with the name 'TreeName' the stream id of
+// the main tasklist ('MTaskList' found in MParList in PreProcess) is
+// set to this name. This means that only tasks having this stream id
+// are executed.
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MReadReports.h"
+
+#include <TChain.h>
+#include <TChainElement.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MTime.h"
+#include "MParList.h"
+#include "MTaskList.h"
+
+#include "MReadMarsFile.h"
+
+ClassImp(MReadReports);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. Set fName and fTitle. Instatiate fTrees and fChains.
+// Call SetOwner for fTrees and fChains
+//
+MReadReports::MReadReports() : fEnableAutoScheme(kFALSE)
+{
+    fName  = "MRead";
+    fTitle = "Reads events and reports from a root file ordered in time";
+
+    fTrees  = new MTaskList("MReadReports");
+    fChains = new TList;
+
+    fTrees->SetOwner();
+    fChains->SetOwner();
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor, delete everything which was allocated by this task...
+//
+MReadReports::~MReadReports()
+{
+    TObject *o=0;
+    TIter NextC(fChains);
+    while ((o=NextC()))
+    {
+        delete *GetTime((TChain*)o);
+        delete  GetTime((TChain*)o);
+    }
+
+    delete fTrees;
+    delete fChains;
+}
+
+void MReadReports::AddToBranchList(const char *name)
+{
+    MTask::AddToBranchList(name);
+}
+
+// --------------------------------------------------------------------------
+//
+// Schedule the contents of this tree for reading. As a default the time
+// branch which is used for the ordering is assumed to by "MTime"+tree.
+// If this is not the case you can overwrite the default specifying the
+// name in time.
+//
+// All calls to AddTree _must_ be BEFORE the calls to AddFile!
+//
+// To be done: A flag(?) telling whether the headers can be skipped.
+//
+void MReadReports::AddTree(const char *tree, const char *time, Bool_t master)
+{
+    /*
+    if (fTrees->GetNumTasks()>0)
+    {
+        *fLog << warn << "WARNING - AddTree must be called before AddFile... ignored." << endl;
+        *fLog << dbg << fTrees->GetNumTasks() << endl;
+        return kFALSE;
+    }
+    */
+
+    if (master && TestBit(kHasMaster))
+    {
+        *fLog << warn << GetDescriptor() << " already has a master tree... ignored." << endl;
+        master = kFALSE;
+    }
+
+    MReadTree *t = master ? new MReadMarsFile(tree) : new MReadTree(tree);
+    t->SetName(tree);
+    t->SetTitle(time?time:"");
+    if (master)
+        t->SetBit(kHasMaster);
+
+    if (!fEnableAutoScheme)
+        t->DisableAutoScheme();
+
+    //FIXME!
+    //t->DisableAutoScheme();
+
+    fTrees->AddToList(t);
+    //    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Schedule a file or several files (using widcards) for reading.
+//
+// All calls to AddTree _must_ be BEFORE the calls to AddFile!
+//
+Int_t MReadReports::AddFile(const char *fname, Int_t entries)
+{
+    Int_t n=0;
+
+    TIter NextT(fTrees->GetList());
+    MReadTree *tree=0;
+    while ((tree=(MReadTree*)NextT()))
+        n += tree->AddFile(fname, entries);
+
+    return n;
+}
+
+// --------------------------------------------------------------------------
+//
+// Find MTaskList and store a pointer to it in fList.
+// Delete all entries in fChains.
+// Create all chains to read the time in the trees in advance.
+// Enable only the time-branch in this chains.
+// PreProcess fTrees (a MTaskList storing MReadTree tasks for reading)
+//
+Int_t MReadReports::PreProcess(MParList *plist)
+{
+    fList = (MTask*)plist->FindObject("MTaskList");
+
+    fChains->Delete();
+
+    Int_t i=0;
+
+    TIter NextT(fTrees->GetList());
+    MReadTree *tree=0;
+    while ((tree=(MReadTree*)NextT()))
+    {
+        if (!((TChain*)tree->fChain)->GetFile())
+        {
+            *fLog << warn << "No files or no tree '" << tree->GetName() << "'... skipped." << endl;
+            fTrees->RemoveFromList(tree);
+            continue;
+        }
+
+        if (tree->GetEntries()==0)
+        {
+            *fLog << warn << "No events in tree '" << tree->GetName() << "'... skipped." << endl;
+            fTrees->RemoveFromList(tree);
+            continue;
+        }
+
+        TString tn(tree->GetTitle());
+        if (tn.IsNull())
+        {
+            tn += "MTime";
+            tn += tree->GetName();
+            tn += ".";
+        }
+
+        TString tn2(tn);
+        tn2 += "*";
+
+        // FIXME: Should be tree->AddToBranchList such that
+        //        each run a new 'table' is created, but
+        //        MRead is searching for MTaskList in the
+        //        parameter list.
+        //AddToBranchList((const char*)tn2);
+
+        //
+        // SetBranchStatus wants to have a pointer to a pointer
+        //
+        MTime **tx = new MTime*;
+        *tx = new MTime;
+
+        TChain *c=new TChain(tree->GetName());
+        c->SetBranchStatus("*", 0);
+        c->SetBranchAddress(tn, tx);
+        tn+="*";
+        c->SetBranchStatus(tn, 1);
+        c->Add((TChain*)tree->fChain);
+        c->GetEntry(0);
+
+        fChains->Add(c);
+
+        i++;
+    }
+
+    if (i==0)
+    {
+        *fLog << err << "Files do not contain any valid tree... abort." << endl;
+        return kFALSE;
+    }
+
+    fPosEntry.Set(i);
+
+    return fTrees->CallPreProcess(plist);
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the MTime corresponding to this TChain...
+//
+MTime** MReadReports::GetTime(TChain *c) const
+{
+    TChainElement *e=(TChainElement*)c->GetStatus()->At(1);
+    return (MTime**)e->GetBaddress();
+}
+
+// --------------------------------------------------------------------------
+//
+// Do not use if fChains->GetSize()==0 !!!
+//
+Int_t MReadReports::FindNextTime()
+{
+    Int_t i=0;
+
+    TIter NextC(fChains);
+    TChain *c=0;
+
+    Int_t nmin=0;
+    MTime tmin(**GetTime((TChain*)NextC()));
+
+    while ((c=(TChain*)NextC()))
+    {
+        MTime &t = **GetTime(c);
+        i++;
+
+        if (t >= tmin)
+            continue;
+
+        tmin = t;
+        nmin = i;
+    }
+    return nmin;
+}
+
+/*
+Bool_t MReadReports::Notify()
+{
+    Bool_t same = kTRUE;
+    for (int i=1; i<fPosTree.GetSize(); i++)
+        if (fPosTree[i]!=fPosTree[0])
+        {
+            same = kFALSE;
+            break;
+        }
+
+    Int_t tn = chain->GetTreeNumber();
+
+    Bool_t read=kFALSE;
+    if (fPosTree[nmin] != tn)
+    {
+        fPosTree[nmin] = tn;
+        read = kTRUE;
+    }
+
+    if (!same || !read)
+        return kTRUE;
+
+
+    *fLog << dbg << "Read Run Headers!" << endl;
+
+    return kTRUE;
+}
+*/
+
+// --------------------------------------------------------------------------
+//
+// Check which is the next tree to read from. Read an event from this tree.
+// Sets the StreamId accordingly.
+//
+Int_t MReadReports::Process()
+{
+    while (fChains->GetSize())
+    {
+        const Int_t nmin=FindNextTime();
+
+        TChain *chain = (TChain*)fChains->At(nmin);
+
+        MTask *task = (MTask*)fTrees->GetList()->At(nmin);
+
+        //Int_t before = chain->GetTreeNumber();
+        if (chain->GetEntry(++fPosEntry[nmin])>0)
+        {
+            const Int_t rc = task->CallProcess();
+            if (rc)
+            {
+                fList->SetStreamId(task->GetName());
+                return rc;
+            }
+        }
+
+        *fLog << dbg << "Removing chain " << chain->GetName() << " from list." << endl;
+
+        delete *GetTime(chain);        // Delete MTime*
+        delete  GetTime(chain);        // Delete MTime-instance
+        delete fChains->Remove(chain); // Remove chain from TList
+
+        // FIXME: Maybe MTaskList should have a member function to
+        //        reorder the tasks?
+
+        // Move this task to the end of the list so that nmin still
+        // corresponds to the correct task in the list.
+        const_cast<TList*>(fTrees->GetList())->Remove(task);
+        const_cast<TList*>(fTrees->GetList())->AddLast(task);
+    }
+
+    return kFALSE; 
+}
+
+// --------------------------------------------------------------------------
+//
+// PostProcess all MReadTree tasks in fTrees.
+//
+Int_t MReadReports::PostProcess()
+{
+    return fTrees->CallPostProcess();
+}
+
+// --------------------------------------------------------------------------
+//
+// PrintStatistics of this task and of the MReadTree tasks in fTress
+//
+void MReadReports::PrintStatistics(const Int_t lvl, Bool_t title, Double_t time) const
+{
+    MRead::PrintStatistics(lvl, title, time);
+    fTrees->PrintStatistics(lvl, title, GetCpuTime());
+}
Index: /tags/Mars_V0-8-5/Mars/mfileio/MReadReports.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfileio/MReadReports.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfileio/MReadReports.h	(revision 9661)
@@ -0,0 +1,64 @@
+#ifndef MARS_MReadReports
+#define MARS_MReadReports
+
+#ifndef MARS_MRead
+#include "MRead.h"
+#endif
+
+#ifndef ROOT_TArrayL
+#include <TArrayL.h>
+#endif
+
+class TChain;
+class MTime;
+class MTaskList;
+
+class MReadReports : public MRead
+{
+private:
+    MTaskList *fTrees;    // Hold the trees which are scheduled for reading
+    TList     *fChains;   // Hold TChains to read the times in advance
+
+    TArrayL    fPosEntry; // Store the position in each tree/chain
+    TArrayL    fPosTree;  // Number of Tree in file.
+
+    MTask     *fList;     // pointer to the task list to set the stream id
+
+    Bool_t     fEnableAutoScheme;
+
+    MTime** GetTime(TChain *c) const;
+    Int_t   FindNextTime();
+
+    UInt_t  GetEntries() { return 0; }
+
+    Int_t   PreProcess(MParList *plist);
+    Int_t   Process();
+    Int_t   PostProcess();
+
+    //Bool_t  Notify();
+
+    enum {
+        //MReadTree::kChainWasChanged = BIT(14)
+        kHasMaster = BIT(15)
+    };
+
+public:
+    MReadReports(); 
+    ~MReadReports(); 
+
+    void  AddTree(const char *tree, const char *time=NULL, Bool_t master=kFALSE);
+    void  AddTree(const char *tree, Bool_t master)
+    {
+        AddTree(tree, NULL, master);
+    }
+    Int_t AddFile(const char *fname, Int_t entries=-1);
+    void  AddToBranchList(const char *name);
+
+    void  PrintStatistics(const Int_t lvl=0, Bool_t title=kFALSE, Double_t time=0) const;
+
+    void  EnableAutoScheme(Bool_t e=kTRUE) { fEnableAutoScheme = e; } // Must be called BEFORE AddTree!
+
+    ClassDef(MReadReports, 0) // Reads events and reports from a root file ordered in time
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mfileio/MReadRflFile.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfileio/MReadRflFile.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfileio/MReadRflFile.cc	(revision 9661)
@@ -0,0 +1,451 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 5/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MReadRflFile
+//
+// Reads a output file of the reflector program
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MReadRflFile.h"
+
+#include <errno.h>
+#include <fstream>
+
+#include <TSystem.h>
+
+#include "structures_rfl.h"
+
+#include "MParList.h"
+#include "MRflEvtData.h"
+#include "MRflEvtHeader.h"
+#include "MRflRunHeader.h"
+#include "MRflSinglePhoton.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MReadRflFile);
+
+using namespace std;
+
+// ------------------------------------------------
+const char PROGNAME[] = "reflector";
+#define SIZE_OF_FLAGS           13
+#define SIZE_OF_SIGNATURE       13
+#define FLAG_START_OF_RUN       "\nSTART---RUN\n"
+#define FLAG_START_OF_EVENT     "\nSTART-EVENT\n"
+#define FLAG_END_OF_EVENT       "\nEND---EVENT\n"
+#define FLAG_END_OF_RUN         "\nEND-----RUN\n"
+#define FLAG_END_OF_FILE        "\nEND----FILE\n"
+#define FLAG_END_OF_STDIN       "\nEND---STDIN\n"
+// ------------------------------------------------
+
+Bool_t MReadRflFile::FlagIsA(const  char *s1, const char *flag)
+{
+    return strncmp(s1, flag, SIZE_OF_FLAGS)==0;
+}
+
+Bool_t MReadRflFile::ReadEvtHeader()
+{
+    if (fCurrentVersion <= 0.5)
+    {
+        RflEventHeader_old revth;
+        fIn->read((char*)&revth, sizeof(RflEventHeader_old));
+        fEvtHeader->SetEvtNumber((int)revth.EvtNumber);
+//        *fLog << "Event Number: " << revth.EvtNumber;
+//        *fLog << "  Primary ID: " << revth.PrimaryID;
+//        *fLog << "  Run Number: " << revth.RunNumber << endl;
+        return (bool)*fIn;
+    }
+    else
+    {
+        RflEventHeader revth;
+        fIn->read((char*)&revth, sizeof(RflEventHeader));
+        fEvtHeader->SetEvtNumber((int)revth.EvtNumber);
+//        *fLog << "Event Number: " << revth.EvtNumber;
+//        *fLog << "  Primary ID: " << revth.PrimaryID;
+//        *fLog << "  Run Number: " << revth.RunNumber << endl;
+        return (bool)*fIn;
+    }
+}
+
+enum {
+    kError,
+    kEndOfFile,
+    kStartOfRun,
+    kEndOfRun,
+    kStartOfEvtData,
+    kEndOfEvtData,
+    kUndefined
+};
+
+
+int MReadRflFile::ReadFlag()
+{
+    char flag[SIZE_OF_FLAGS];
+    fIn->read(flag, SIZE_OF_FLAGS);
+
+    if (!fIn)
+        return kError;
+
+    //*fLog << "<" << TString(&flag[1], 11)  << ">" <<endl;
+
+    if (FlagIsA(flag, FLAG_END_OF_FILE))
+        return kEndOfFile;
+    if (FlagIsA(flag, FLAG_END_OF_RUN))
+        return kEndOfRun;
+    if (FlagIsA(flag, FLAG_START_OF_RUN))
+        return kStartOfRun;
+    if (FlagIsA(flag, FLAG_END_OF_EVENT))
+        return kEndOfEvtData;
+    if (FlagIsA(flag, FLAG_START_OF_EVENT))
+        return kStartOfEvtData;
+
+    return kUndefined;
+}
+
+Bool_t MReadRflFile::ReadEvtData()
+{
+    Bool_t rc = kFALSE;
+    while (1)
+    {
+        cphoton data; // FIRST READ "START OF EVENT"
+        fIn->read((char*)&data, SIZE_OF_FLAGS);
+        if (!*fIn)
+            break;
+
+        if (FlagIsA((char*)&data, FLAG_END_OF_EVENT))
+        {
+            rc = kTRUE;
+            break;
+        }
+
+        fIn->read((char*)&data+SIZE_OF_FLAGS, sizeof(cphoton)-SIZE_OF_FLAGS);
+        if (!*fIn)
+            break;
+
+        MRflSinglePhoton &ph = fEvtData->GetNewPhoton();
+        ph.SetXY(data.x*10, data.y*10);
+        ph.SetCosUV(data.u, data.v);
+        ph.SetTime(data.t);
+        ph.SetHeight(data.h);
+        ph.SetInclinationAngle(data.phi);
+    }
+
+    fEvtData->FixSize();
+    return rc;
+}
+
+Int_t MReadRflFile::EvalFlag()
+{
+    const Int_t flag = ReadFlag();
+
+    switch (flag)
+    {
+    case kEndOfFile:
+        fCurrentVersion = ReadVersion();
+        if (fCurrentVersion<0)
+        {
+            *fLog << inf << "Found end of file...Everything OK." << endl;
+            break;
+        }
+
+        *fLog << warn << "Found flag of end of file, but file goes on..." << endl;
+        if (ReadFlag()<0)
+            return kError;
+        /* FALLTHROU */
+    case kStartOfRun:
+        if (fCurrentVersion>0.5)
+        {
+            RflRunHeader rrunh;
+            fIn->read((char*)&rrunh, sizeof(RflRunHeader));
+            if (*fIn)
+            {
+                *fLog << inf << "FIXME: Call ReInit" << endl;
+
+                fRunHeader->SetRunNumber((int)rrunh.RunNumber);
+                *fLog << underline << "RunHeader:" << endl;
+                *fLog << " Run Number:   " << rrunh.RunNumber << endl;
+                *fLog << " Date:         " << rrunh.date << endl;
+                *fLog << " Corsika Ver.: " << rrunh.Corsika_version << endl;
+
+                break;
+            }
+
+            *fLog << err << "Error! found end of file... But no EOF flag. Exiting." << endl;
+            return kError;
+        }
+        return kUndefined;
+
+    case kStartOfEvtData:
+    case kEndOfRun:
+        break;
+
+    case kError:
+        *fLog << err << "ERROR - Flag 'error'" << endl;
+        return kError;
+
+    case kUndefined:
+        *fLog << err << "ERROR - Flag 'undefined'" << endl;
+        return kError;
+
+    default:
+        *fLog << err << "ERROR - Unhandled flag" << endl;
+        return kError;
+
+    }
+    return flag;
+}
+
+Int_t MReadRflFile::Process()
+{
+    for (;;)
+    {
+        switch (EvalFlag())
+        {
+        case kError:
+            return kFALSE;
+
+        case kEndOfFile:
+            if (!OpenNextFile())
+                return kFALSE;
+            /* FALLTHROU */
+        case kStartOfRun:
+        case kEndOfRun:
+            continue;
+
+        case kStartOfEvtData:
+            break;
+        }
+        break;
+    }
+
+    if (!ReadEvtHeader())
+        return kFALSE;
+
+    return ReadEvtData();
+}
+
+Int_t MReadRflFile::PreProcess(MParList *plist)
+{
+    fEvtData=(MRflEvtData*)plist->FindCreateObj("MRflEvtData");
+    if (!fEvtData)
+        return kFALSE;
+
+    fEvtHeader=(MRflEvtHeader*)plist->FindCreateObj("MRflEvtHeader");
+    if (!fEvtHeader)
+        return kFALSE;
+
+    fRunHeader=(MRflRunHeader*)plist->FindCreateObj("MRflRunHeader");
+    if (!fRunHeader)
+        return kFALSE;
+
+    Rewind();
+
+    return OpenNextFile();
+}
+
+// --------------------------------------------------------------------------
+//
+// This opens the next file in the list and deletes its name from the list.
+//
+Bool_t MReadRflFile::OpenNextFile()
+{
+    //
+    // open the input stream and check if it is really open (file exists?)
+    //
+    if (fIn)
+        delete fIn;
+    fIn = NULL;
+
+    //
+    // Check for the existence of a next file to read
+    //
+    if (fNumFile >= (UInt_t)fFileNames->GetSize())
+    {
+        *fLog << inf << GetDescriptor() << ": No unread files anymore..." << endl;
+        return kFALSE;
+    }
+
+    TNamed *file = (TNamed*)fFileNames->At(fNumFile);
+
+    //TNamed *file = (TNamed*)fFileNames->GetFirst();
+    //if (!file)
+    //    return kFALSE;
+
+    //
+    // open the file which is the first one in the chain
+    //
+    const TString name = file->GetName();
+
+    const char *expname = gSystem->ExpandPathName(name);
+    const TString fname(expname);
+    delete [] expname;
+
+    //
+    // Remove this file from the list of pending files
+    //
+    //fFileNames->Remove(file);
+
+    *fLog << inf << "Open file: '" << name << "'" << endl;
+
+    fIn = new ifstream(name);
+    if (!*fIn)
+    {
+        *fLog << err << "Cannot open file " << name << ": ";
+        *fLog << strerror(errno) << endl;
+        return kFALSE;
+    }
+
+    *fLog << inf;
+    fLog->Separator(name);
+
+    fCurrentVersion = ReadVersion();
+    if (fCurrentVersion<0)
+    {
+        cout << "ERROR reading signature." << endl;
+        return kFALSE;
+    }
+    cout << "Version " << fCurrentVersion << endl << endl;
+
+    fNumFile++;
+    return kTRUE;
+}
+
+/****************************************************/
+
+float MReadRflFile::ReadVersion()
+{
+    char sign[20];
+    fIn->read(sign, SIZE_OF_SIGNATURE);
+    if (!*fIn)
+        return -1;
+
+    if (strncmp(sign, PROGNAME, strlen(PROGNAME)) != 0)
+    {
+        /* For the ascii tail of the file! : */
+        if (strncmp(sign, "\n############", SIZE_OF_SIGNATURE))
+            cout << "ERROR: Signature of .rfl file is not correct: " << sign << endl;
+
+        return -1;
+    }
+
+    float version;
+    sscanf(sign, "%*s %f", &version);
+
+    //If the version is < 0.6 the signature had one more byte
+    if (version < 0.6)
+        *fIn >> sign[0];
+
+    return version;
+}
+
+// --------------------------------------------------------------------------
+//
+// 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.
+//
+MReadRflFile::MReadRflFile(const char *fname, const char *name,
+                           const char *title) : fIn(NULL), fEntries(0)
+{
+    fName  = name  ? name  : "MRead";
+    fTitle = title ? title : "Reads a Reflector output 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.
+//
+MReadRflFile::~MReadRflFile()
+{
+    delete fFileNames;
+    if (fIn)
+        delete fIn;
+}
+
+// --------------------------------------------------------------------------
+//
+// Add this file as the last entry in the chain
+//
+Int_t MReadRflFile::AddFile(const char *txt, int)
+{
+    const char *name = gSystem->ExpandPathName(txt);
+
+    TString fname(name);
+    delete [] name;
+/*
+    if (!CheckHeader(fname))
+    {
+        *fLog << warn << "WARNING - Problem reading header... ignored." << endl;
+        return;
+    }
+
+    const Int_t n = GetNumEvents(fname);
+    if (n==0)
+    {
+        *fLog << warn << "WARNING - File contains no data... ignored." << endl;
+        return;
+    }
+
+    fEntries += n;
+
+    *fLog << inf << "File " << txt << " contains " << n << " events (Total=" << fEntries << ")" << endl;
+*/
+    fFileNames->AddLast(new TNamed(txt, ""));
+    return 1;
+}
+
+
+Bool_t MReadRflFile::SearchFor(Int_t runno, Int_t eventno)
+{
+    if (!fEvtHeader)
+        return kFALSE;
+
+    fNumFile = 0;
+    if (!OpenNextFile())
+        return kFALSE;
+
+    while (1)
+    {
+        fEvtData->Reset();
+        if (!Process())
+            return kFALSE;
+
+        if (fEvtHeader->GetEvtNumber()==eventno &&
+            fRunHeader->GetRunNumber()==runno)
+            return kTRUE;
+    }
+}
Index: /tags/Mars_V0-8-5/Mars/mfileio/MReadRflFile.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfileio/MReadRflFile.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfileio/MReadRflFile.h	(revision 9661)
@@ -0,0 +1,60 @@
+#ifndef MARS_MReadRflFile
+#define MARS_MReadRflFile
+
+#ifndef ROOT_TArrayF
+#include <TArrayF.h>
+#endif
+
+#ifndef MARS_MRead
+#include "MRead.h"
+#endif
+
+class TList;
+class MRflEvtData;
+class MRflEvtHeader;
+class MRflRunHeader;
+
+class MReadRflFile : public MRead
+{
+private:
+    ifstream *fIn;          // the inputfile
+    TList    *fFileNames;   // Array which stores the \0-terminated filenames
+
+    MRflEvtData *fEvtData;        //!
+    MRflEvtHeader *fEvtHeader;
+    MRflRunHeader *fRunHeader;
+
+    UInt_t fNumFile;
+    UInt_t fEntries; // TO BE IMPLEMENTED
+
+    Float_t fCurrentVersion; //! Version of currently open rfl file
+
+    float  ReadVersion();
+    Bool_t ReadEvtHeader();
+    Bool_t ReadEvtData();
+    int    ReadFlag();
+    Bool_t FlagIsA(const  char *s1, const char *flag);
+    Int_t  EvalFlag();
+    Bool_t OpenNextFile();
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
+public:
+    MReadRflFile(const char *filename=NULL,
+                 const char *name=NULL,
+                 const char *title=NULL);
+
+    ~MReadRflFile();
+
+    Int_t AddFile(const char *fname, int i=0);
+
+    Bool_t Rewind() { fNumFile=0; return kTRUE; }
+    UInt_t GetEntries() { return fEntries; }
+
+    Bool_t SearchFor(Int_t runno, Int_t eventno);
+
+    ClassDef(MReadRflFile, 0) // Reads reflector files
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mfileio/MReadTree.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfileio/MReadTree.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfileio/MReadTree.cc	(revision 9661)
@@ -0,0 +1,1033 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// 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>
+
+#include <TFile.h>           // TFile::GetName
+#include <TSystem.h>         // gSystem->ExpandPath
+#include <TChainElement.h>
+#include <TOrdCollection.h>
+
+#include "MChain.h"
+#include "MFilter.h"
+#include "MParList.h"
+#include "MTaskList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+
+ClassImp(MReadTree);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+//  Default constructor. Don't use it.
+//
+MReadTree::MReadTree()
+    : fNumEntry(0), fNumEntries(0), fBranchChoosing(kFALSE), fAutoEnable(kTRUE)
+{
+    fName  = "MRead";
+    fTitle = "Task to loop over all events in one single tree";
+
+    fVetoList = NULL;
+    fNotify = NULL;
+
+    fChain = NULL;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Constructor. It creates an TChain instance which represents the
+//  the Tree you want to read and adds the given file (if you gave one).
+//  More files can be added using MReadTree::AddFile.
+//  Also an empty veto list is created. This list is used if you want to
+//  veto (disable or "don't enable") a branch in the tree, it vetos also
+//  the creation of the corresponding object.
+//  An empty list of TObjects are also created. This objects are called
+//  at any time the TChain starts to read from another file.
+//
+MReadTree::MReadTree(const char *tname, const char *fname,
+                     const char *name, const char *title)
+    : fNumEntry(0), fNumEntries(0), fBranchChoosing(kFALSE), fAutoEnable(kTRUE)
+{
+    fName  = name  ? name  : "MRead";
+    fTitle = title ? title : "Task to loop over all events in one single tree";
+
+    fVetoList = new TList;
+    fVetoList->SetOwner();
+
+    fNotify = new TList;
+
+    //
+    // open the input stream
+    //
+    fChain = new MChain(tname);
+
+    // root 3.02:
+    // In TChain::Addfile remove the limitation that the file name must contain
+    // the string ".root". ".root" is necessary only in case one wants to specify
+    // a Tree in a subdirectory of a Root file with eg, the format:
+
+    if (fname)
+        AddFile(fname);
+//        if (fChain->Add(fname)>0)
+//            SetBit(kChainWasChanged);
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor. It deletes the TChain and veto list object
+//
+MReadTree::~MReadTree()
+{
+    //
+    // Delete all the pointers to pointers to the objects where the
+    // branche data gets stored. FIXME: When PreProcessed twice this
+    // creates a memory leak!
+    //
+    TIter Next(fChain->GetStatus());
+
+    TChainElement *element = NULL;
+    while ((element=(TChainElement*)Next()))
+        if (element->GetBaddress())
+            delete (MParContainer**)element->GetBaddress();
+
+    //
+    // Delete the chain and the veto list
+    //
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,03,00)
+    if (fChain->GetFile())
+        delete fChain->GetFile();
+#endif
+    delete fChain;
+
+    delete fNotify;
+    delete fVetoList;
+}
+
+// --------------------------------------------------------------------------
+//
+// This check whether all branches in the tree have the same size. If
+// this is not the case the events in the different branches cannot
+// be ordered correctly.
+//
+Bool_t MReadTree::CheckBranchSize()
+{
+    TArrayI entries(fChain->GetStatus()->GetSize());
+    Int_t num=0;
+
+    // Loop over all branches which have a corresponding container
+    TIter Next(fChain->GetStatus());
+
+    TChainElement *element = NULL;
+    while ((element=(TChainElement*)Next()))
+    {
+        // Get branch name and find pointer to corresponding branch
+        const TString name = element->GetName();
+        const TBranch *b = fChain->FindBranch(name);
+
+        // Skip element without corresponding branches (like "*")
+        if (!b)
+            continue;
+
+        entries[num++] = (Int_t)b->GetEntries();
+    }
+
+    // Check the number of entries of the branches pair-wise
+    for (int i=0; i<num; i++)
+        for (int j=i; j<num; j++)
+        {
+            if (entries[i]==entries[j])
+                continue;
+
+            *fLog << err << "ERROR - File corruption detected:" << endl;
+            *fLog << "  Due to several circumstances (such at a bug in MReadTree or wrong" << endl;
+            *fLog << "  usage of the file UPDATE mode) you may have produced a file in which" << endl;
+            *fLog << "  at least two branches in the same tree (" << fChain->GetName() << ") have different" << endl;
+            *fLog << "  number of entries. Sorry, but this file (" << GetFileName() << ")" << endl;
+            *fLog << "  is unusable." << endl;
+            return kFALSE;
+        }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  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()
+{
+    //
+    // Do a consistency check for all branches
+    //
+    if (!CheckBranchSize())
+        return kFALSE;
+
+    *fLog << inf << GetDescriptor() << ": Switching to #" << GetFileIndex();
+    *fLog << " '" << GetFileName() << "' (before event #";
+    *fLog << GetNumEntry()-1 << ")" << endl;
+
+    if (!fNotify)
+        return kTRUE;
+
+    TIter Next(fNotify);
+    TObject *o=NULL;
+    while ((o=Next()))
+        if (!o->Notify())
+        {
+            *fLog << err << "Calling Notify() for object " << o->GetName() << " failed... abort." << endl;
+            return kFALSE;
+        }
+
+    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.
+//
+//  For more information see TChain::Add
+//
+Int_t MReadTree::AddFile(const char *fname, Int_t entries)
+{
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,03,01)
+    //
+    // This is a workaround to get rid of crashed if the file doesn't
+    // exist due to non initialized TFile::fProcessIDs
+    //
+    //  (Code taken from TFile::TFile
+    //
+    TString newname; // char-array must overcome comming block
+
+    if (strrchr(fname, '?') || strrchr(fname, '*'))
+    {
+        *fLog << warn;
+        *fLog<< "WARNING: Using widcards with older root versions:" << endl;
+        *fLog << "  You may encounter crashes closing the files..." << endl;
+    }
+    else
+    {
+        const char *name;
+
+        if ((name = gSystem->ExpandPathName(fname)))
+        {
+            newname = name;
+            delete [] name;
+        }
+
+        if (newname.IsNull())
+        {
+            *fLog << err << dbginf << "Error expanding path " << fname << "." << endl;
+            return 0;
+        }
+
+        if (gSystem->AccessPathName(newname, kFileExists))
+        {
+            *fLog << err << "ERROR - File '" << fname << "' does not exist." << endl;
+            return 0;
+        }
+
+        fname = newname.Data();
+    }
+#endif
+
+    //
+    // FIXME! A check is missing whether the file already exists or not.
+    //
+    const Int_t numfiles = fChain->Add(fname, entries<0?TChain::kBigNumber:entries);
+
+    if (numfiles>0)
+    {
+        SetBit(kChainWasChanged);
+        *fLog << inf << GetDescriptor() << " - AddFile: " << numfiles << " files added from " << fname << "." << endl;
+    }
+    else
+        *fLog << warn << "WARNING: '" << fname << "' not added to " << GetDescriptor() << endl;
+
+    return numfiles;
+}
+
+/*
+ // --------------------------------------------------------------------------
+ //
+ //
+ Int_t MReadTree::AddFile(const TChainElement &obj)
+ {
+     return AddFile(obj.GetTitle(), obj.GetEntries());
+ }
+*/
+
+// --------------------------------------------------------------------------
+//
+// Adds all files from another MReadTree to this instance
+//
+// Returns the number of file which were added
+//
+Int_t MReadTree::AddFiles(const MReadTree &read)
+{
+    const Int_t rc = fChain->Add(read.fChain);
+
+    if (rc>0)
+        SetBit(kChainWasChanged);
+
+    /*
+     Int_t rc = 0;
+
+     TIter Next(read.fChain->GetListOfFiles());
+     TObject *obj = NULL;
+     while ((obj=Next()))
+         rc += AddFile(*(TChainElement*)obj);
+    */
+
+    return rc;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Sort the files by their file-names
+//
+void MReadTree::SortFiles()
+{
+    fChain->GetListOfFiles()->Sort();
+}
+
+// --------------------------------------------------------------------------
+//
+//  This function is called if Branch choosing method should get enabled.
+//  Branch choosing means, that only the enabled branches are read into
+//  memory. To use an enableing scheme we have to disable all branches first.
+//  This is done, if this function is called the first time.
+//
+void MReadTree::EnableBranchChoosing()
+{
+    if (fBranchChoosing)
+        return;
+
+    *fLog << inf << GetDescriptor() << ": Branch choosing 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)
+{
+    if (fChain->GetListOfFiles()->GetEntries()==0)
+    {
+        *fLog << err << "Chain contains no file... Branch '";
+        *fLog << name << "' ignored." << endl;
+        return;
+    }
+
+    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
+    //
+    TString bn(name);
+    if (bn.EndsWith("*"))
+        bn.Remove(bn.Length()-1);
+
+    if (fChain->GetBranch(bn))
+        SetBranchStatus(name, status);
+
+    //
+    // Remove trailing '.' if one and try to enable the subbranch without
+    // the master branch name. This is to be compatible with older mars
+    // and camera files.
+    //
+    const char *dot = strrchr(name, '.');
+    if (!dot)
+        return;
+
+    if (fChain->GetBranch(dot+1))
+        SetBranchStatus(dot+1, status);
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the status of all branches in the list to status.
+//
+void MReadTree::SetBranchStatus(const TList *list, Bool_t status)
+{
+    //
+    // Loop over all subbranches in this master branch
+    //
+    TIter Next(list);
+
+    TObject *obj;
+    while ((obj=Next()))
+        SetBranchStatus(obj, status);
+}
+
+// --------------------------------------------------------------------------
+//
+//  This is the implementation of the Auto Enabling Scheme.
+//  For more information see MTask::AddBranchToList.
+//  This function loops over all tasks and its filters in the tasklist
+//  and enables all branches which are requested by the tasks and its
+//  filters.
+//
+//  To enable 'unknown' branches which are not in the branchlist of
+//  the tasks you can call EnableBranch
+//
+void MReadTree::EnableBranches(MParList *plist)
+{
+    //
+    // check whether branch choosing must be switched on
+    //
+    EnableBranchChoosing();
+
+    //
+    // request the tasklist from the parameter list.
+    // FIXME: Tasklist can have a different name
+    //
+    const MTaskList *tlist = (MTaskList*)plist->FindObject("MTaskList");
+    if (!tlist)
+    {
+        *fLog << warn << GetDescriptor() << "Cannot use auto enabeling scheme for branches. 'MTaskList' not found." << endl;
+        return;
+    }
+
+    //
+    // This loop is not necessary. We could do it like in the commented
+    // loop below. But this loop makes sure, that we don't try to enable
+    // one branch several times. This would not harm, but we would get
+    // an output for each attempt. To have several outputs for one subbranch
+    // may confuse the user, this we don't want.
+    // This loop creates a new list of subbranches and for each branch
+    // which is added we check before whether it already exists or not.
+    //
+    TList list;
+
+    MTask *task;
+    TIter NextTask(tlist->GetList());
+    while ((task=(MTask*)NextTask()))
+    {
+        TObject *obj;
+
+        TIter NextTBranch(task->GetListOfBranches());
+        while ((obj=NextTBranch()))
+            if (!list.FindObject(obj->GetName()))
+                list.Add(obj);
+
+        const MFilter *filter = task->GetFilter();
+
+        if (!filter)
+            continue;
+
+        TIter NextFBranch(filter->GetListOfBranches());
+        while ((obj=NextFBranch()))
+            if (!list.FindObject(obj->GetName()))
+                list.Add(obj);
+    }
+
+    SetBranchStatus(&list, kTRUE);
+/*
+    //
+    // Loop over all tasks iand its filters n the task list.
+    //
+    MTask *task;
+    TIter NextTask(tlist->GetList());
+    while ((task=(MTask*)NextTask()))
+    {
+        SetBranchStatus(task->GetListOfBranches(), kTRUE);
+
+        const MFilter *filter = task->GetFilter();
+        if (!filter)
+           continue;
+
+        SetBranchStatus(filter->GetListOfBranches(), kTRUE);
+
+    }
+*/
+}
+
+// --------------------------------------------------------------------------
+//
+//  If the chain has been changed (by calling AddFile or using a file
+//  in the constructors argument) the number of entries is newly
+//  calculated from the files in the chain - this may take a while.
+//  The number of entries is returned.
+//
+UInt_t MReadTree::GetEntries()
+{
+    if (TestBit(kChainWasChanged))
+    {
+        *fLog << inf << "Scanning chain " << fChain->GetName() << "... " << flush;
+        fNumEntries = (UInt_t)fChain->GetEntries();
+        *fLog << fNumEntries << " events found." << endl;
+        ResetBit(kChainWasChanged);
+    }
+    return fNumEntries;
+}
+
+// --------------------------------------------------------------------------
+//
+//  The disables all subbranches of the given master branch.
+//
+void MReadTree::DisableSubBranches(TBranch *branch)
+{
+    //
+    // This is not necessary, it would work without. But the output
+    // may confuse the user...
+    //
+    if (fAutoEnable || fBranchChoosing)
+        return;
+
+    SetBranchStatus(branch->GetListOfBranches(), kFALSE);
+}
+
+// --------------------------------------------------------------------------
+//
+//  The PreProcess loops (till now) over the branches in the given tree.
+//  It checks if the corresponding containers (containers with the same
+//  name than the branch name) are existing in the Parameter Container List.
+//  If not, a container of objec type 'branch-name' is created (everything
+//  after the last semicolon in the branch name is stripped). Only
+//  branches which don't have a veto (see VetoBranch) are enabled If the
+//  object isn't found in the root dictionary (a list of classes known by the
+//  root environment) the branch is skipped and an error message is printed
+//  out.
+//  If a selector is specified it is preprocessed after the
+//  MReadTree::PreProcess
+//
+Int_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);
+
+    //
+    // check for files and for the tree!
+    //
+    if (!fChain->GetFile())
+    {
+        *fLog << err << GetDescriptor() << ": No file or no tree with name " << fChain->GetName() << " in file." << endl;
+        return kFALSE;
+    }
+
+    //
+    // get number of events in this tree
+    //
+    if (!GetEntries())
+    {
+        *fLog << err << GetDescriptor() << ": No entries found in file(s)" << endl;
+        return kFALSE;
+    }
+
+    //
+    // output logging information
+    //
+    *fLog << inf << fNumEntries << " entries found in file(s)." << endl;
+
+    //
+    // Get all branches of this tree and
+    // create the Iterator to loop over all branches
+    //
+    TIter Next(fChain->GetListOfBranches());
+    TBranch *branch=NULL;
+
+    Int_t num=0;
+
+    //
+    // loop over all tasks for processing
+    //
+    while ( (branch=(TBranch*)Next()) )
+    {
+        //
+        // Get Name of Branch and Object
+        //
+        const char *bname = branch->GetName();
+
+        TString oname(bname);
+        if (oname.EndsWith("."))
+            oname.Remove(oname.Length()-1);
+
+        //
+        // Check if enabeling the branch is allowed
+        //
+        if (fVetoList->FindObject(oname))
+        {
+            *fLog << inf << "Master branch " << bname << " has veto... skipped." << endl;
+            DisableSubBranches(branch);
+            continue;
+        }
+
+        //
+        // Create a pointer to the pointer to the object in which the
+        // branch data is stored. The pointers are stored in the TChain
+        // object and we get the pointers from there to delete it.
+        //
+        MParContainer **pcont= new MParContainer*;
+
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,02,06)
+        const char *classname = oname;
+#else
+        const char *classname = branch->GetClassName();
+#endif
+
+        //
+        // check if object is existing in the list
+        //
+        *pcont=pList->FindCreateObj(classname, oname);
+
+        if (!*pcont)
+        {
+            //
+            // if class is not existing in the (root) environment
+            // we cannot proceed reading this branch
+            //
+            *fLog << warn << dbginf << "Warning: Class '" << classname;
+            *fLog << "' for " << oname << " not existing in dictionary. Branch skipped." << endl;
+            DisableSubBranches(branch);
+            continue;
+        }
+
+        //
+        // Check whether a Pointer to a pointer already exists.
+        // If we created one already, delete it.
+        //
+        TChainElement *element = (TChainElement*)fChain->GetStatus()->FindObject(bname);
+        if (element)
+            delete (MParContainer**)element->GetBaddress();
+
+        //
+        // here pcont is a pointer the to container in which the data from
+        // the actual branch should be stored - enable branch.
+        //
+        fChain->SetBranchAddress(bname, pcont);
+
+        *fLog << inf << "Master branch address " << bname << " [";
+        *fLog << classname << "] setup for reading." << endl;
+
+        //*fLog << "Branch " << bname << " autodel: " << (int)branch->IsAutoDelete() << endl;
+        //branch->SetAutoDelete();
+
+        num++;
+    }
+
+    *fLog << inf << GetDescriptor() << " setup " << num << " master branches addresses." << endl;
+
+    //
+    // If auto enabling scheme isn't disabled, do auto enabling
+    //
+    if (fAutoEnable)
+        EnableBranches(pList);
+
+    //
+    // Now we can start notifying. Reset tree makes sure, that TChain thinks
+    // that the correct file is not yet initialized and reinitilizes it
+    // as soon as the first event is read. This is necessary to call
+    // the notifiers when the first event is read, but after the
+    // PreProcess-function.
+    //
+    fChain->ResetTree();
+    fChain->SetNotify(this);
+
+    return GetSelector() ? GetSelector()->CallPreProcess(pList) : 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.
+//  In case an event selector is given its value is checked before
+//  reading the event. If it returns kAFLSE the event is skipped.
+//
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,02,06)
+#include "MRawEvtData.h"
+#endif
+Int_t MReadTree::Process()
+{
+    //
+    // This is necessary due to a bug in TChain::LoadTree in root.
+    // will be fixed in 3.03
+    //
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,03,01)
+    if (fNumEntry >= GetEntries())
+        return kFALSE;
+#endif
+
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,02,06)
+    //
+    // This fixes 99.9% of a memory leak using a root version prior
+    // to 3.02/??
+    //
+    TChainElement *element=NULL;
+    TIter Next(fChain->GetStatus());
+    while ((element=(TChainElement*)Next()))
+    {
+        MParContainer **c = (MParContainer**)element->GetBaddress();
+        if (!c) continue;
+        if ((*c)->InheritsFrom(MRawEvtData::Class()))
+            static_cast<MRawEvtData*>(*c)->DeletePixels(kFALSE);
+
+    }
+#endif
+
+    if (GetSelector())
+    {
+        //
+        // Make sure selector is processed
+        //
+        if (!GetSelector()->CallProcess())
+        {
+            *fLog << err << dbginf << "Processing Selector failed." << endl;
+            return kFALSE;
+        }
+
+        //
+        // Skip Event
+        //
+        if (!GetSelector()->IsConditionTrue())
+        {
+            fNumEntry++;
+            return kCONTINUE;
+        }
+    }
+
+    const Bool_t rc = fChain->GetEntry(fNumEntry++) != 0;
+
+    if (rc)
+        SetReadyToSave();
+
+    return rc;
+}
+
+// --------------------------------------------------------------------------
+//
+//  If a selector is given the selector is post processed
+//
+Int_t MReadTree::PostProcess()
+{
+    return GetSelector() ? GetSelector()->CallPostProcess() : kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the Event with the current EventNumber fNumEntry
+//
+Bool_t MReadTree::GetEvent()
+{
+    Bool_t rc = fChain->GetEntry(fNumEntry) != 0;
+
+    if (rc)
+        SetReadyToSave();
+
+    return rc;
+}
+
+// --------------------------------------------------------------------------
+//
+// Decrease the number of the event which is read by Process() next
+// by one or more
+//
+Bool_t MReadTree::DecEventNum(UInt_t dec)
+{
+    if (fNumEntry-dec >= GetEntries())
+    {
+        *fLog << warn << GetDescriptor() << ": DecEventNum, WARNING - Event " << fNumEntry << "-";
+        *fLog << dec << "=" << (Int_t)fNumEntry-dec << " out of Range (>=";
+        *fLog << GetEntries() << ")." << endl;
+        return kFALSE;
+    }
+
+    fNumEntry -= dec;
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Increase the number of the event which is read by Process() next
+// by one or more
+//
+Bool_t MReadTree::IncEventNum(UInt_t inc)
+{
+    if (fNumEntry+inc >= GetEntries())
+    {
+        *fLog << warn << GetDescriptor() << ": IncEventNum, WARNING - Event " << fNumEntry << "+";
+        *fLog << inc << "=" << (Int_t)fNumEntry+inc << " out of Range (>=";
+        *fLog << GetEntries() << ")." << 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!=0 && nr >= GetEntries())
+    {
+        *fLog << warn << GetDescriptor() << ": SetEventNum, WARNING - " << nr << " out of Range." << endl;
+        return kFALSE;
+    }
+
+    fNumEntry = nr;
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  For the branch with the given name:
+//   1) no object is automatically created
+//   2) the branch address for this branch is not set
+//      (because we lack the object, see 1)
+//   3) The whole branch (exactly: all its subbranches) are disabled
+//      this means are not read in memory by TTree:GetEntry
+//
+void MReadTree::VetoBranch(const char *name)
+{
+    fVetoList->Add(new TNamed(name, ""));
+}
+
+// --------------------------------------------------------------------------
+//
+//  Return the name of the file we are actually reading from.
+//
+TString MReadTree::GetFileName() const
+{
+    const TFile *file = fChain->GetFile();
+
+    if (!file)
+        return TString("<unknown>");
+
+    TString name(file->GetName());
+    name.Remove(0, name.Last('/')+1);
+    return name;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Return the number of the file in the chain, -1 in case of an error
+//
+Int_t MReadTree::GetFileIndex() const
+{
+    return fChain->GetTreeNumber();
+    /*
+    const TString filename = fChain->GetFile()->GetName();
+
+    int i=0;
+    TObject *file = NULL;
+
+    TIter Next(fChain->GetListOfFiles());
+    while ((file=Next()))
+    {
+        if (filename==gSystem->ExpandPathName(file->GetTitle()))
+            return i;
+        i++;
+    }
+    return -1;
+    */
+}
+
+// --------------------------------------------------------------------------
+//
+//  This schedules a TObject which Notify(9 function is called in case
+//  of MReadTree (TChain) switches from one file in the chain to another
+//  one.
+//
+void MReadTree::AddNotify(TObject *obj)
+{
+    fNotify->Add(obj);
+}
+
+void MReadTree::Print(Option_t *o) const
+{
+    *fLog << all << underline << GetDescriptor() << ":" << endl << dec;
+    *fLog << " Files [Tree]:" << endl;
+
+    int i = 0;
+    TIter Next(fChain->GetListOfFiles());
+    TObject *obj = NULL;
+    while ((obj=Next()))
+        *fLog << " " << i++ << ") " << obj->GetTitle() << " [" << obj->GetName() << "]" << endl;
+
+    *fLog << " Total Number of Entries: " << fNumEntries << endl;
+    *fLog << " Next Entry to read: " << fNumEntry << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
+void MReadTree::StreamPrimitive(ofstream &out) const
+{
+    out << "   " << ClassName() << " " << GetUniqueName() << "(\"";
+    out << fChain->GetName() << "\", \"" << fName << "\", \"" << fTitle << "\");" << endl;
+
+    TIter Next(fChain->GetListOfFiles());
+    TObject *obj = NULL;
+    while ((obj=Next()))
+        out << "   " << GetUniqueName() << ".AddFile(\"" << obj->GetTitle() << "\");" << endl;
+
+    if (!fAutoEnable)
+        out << "   " << GetUniqueName() << ".DisableAutoScheme();" << endl;
+
+    if (fNumEntry!=0)
+       out << "   " << GetUniqueName() << ".SetEventNum(" << fNumEntry << ");" << endl;
+
+
+}
Index: /tags/Mars_V0-8-5/Mars/mfileio/MReadTree.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfileio/MReadTree.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfileio/MReadTree.h	(revision 9661)
@@ -0,0 +1,85 @@
+#ifndef MARS_MReadTree
+#define MARS_MReadTree
+
+#ifndef MARS_MRead
+#include "MRead.h"
+#endif
+
+class MChain;
+class TBranch;
+
+class MReadTree : public MRead
+{
+    friend class MReadReports;
+
+private:
+    MChain *fChain;            // Pointer to tree
+
+    UInt_t  fNumEntry;         // Number of actual entry in chain
+    UInt_t  fNumEntries;       // Number of Events in chain
+
+    Bool_t  fBranchChoosing;   // Flag for branch choosing method
+    Bool_t  fAutoEnable;       // Flag for auto enabeling scheme
+
+    TList  *fVetoList;         // List of Branches which are not allowed to get enabled
+    TList  *fNotify;           // List of TObjects to notify when switching files
+
+    enum { kChainWasChanged = BIT(14) };
+
+private:
+    void SetBranchStatus(const TList *list, Bool_t status);
+    void SetBranchStatus(TObject *branch, Bool_t status);
+    void SetBranchStatus(const char *name, Bool_t status);
+
+    void DisableSubBranches(TBranch *b);
+    void EnableBranches(MParList *plist);
+    void EnableBranchChoosing();
+
+    Bool_t CheckBranchSize();
+
+    virtual void SetReadyToSave(Bool_t flag=kTRUE);
+    virtual void StreamPrimitive(ofstream &out) const;
+
+    enum { kIsOwner = BIT(14) };
+
+public:
+    MReadTree();
+    MReadTree(const char *treename, const char *filename=NULL, const char *name=NULL, const char *title=NULL);
+    ~MReadTree();
+
+    virtual void SortFiles();
+
+    void   DisableAutoScheme() { fAutoEnable = kFALSE; }
+    void   EnableBranch(const char *name);
+    void   VetoBranch(const char *name);
+
+    Bool_t GetEvent();
+
+    Bool_t DecEventNum(UInt_t dec=1); // decrease number of event (position in tree)
+    Bool_t IncEventNum(UInt_t inc=1); // increase number of event (position in tree)
+    Bool_t SetEventNum(UInt_t nr);    // set number of event (position in tree)
+
+    UInt_t GetNumEntry() const { return fNumEntry; }
+    UInt_t GetEntries();
+
+    TString GetFileName() const;
+    Int_t   GetFileIndex() const;
+
+    virtual void AddNotify(TObject *obj);
+    virtual void SetOwner(Bool_t flag=kTRUE);
+
+    virtual Int_t AddFile(const char *fname, Int_t entries=-1);
+    virtual Int_t AddFiles(const MReadTree &read);
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
+    Bool_t Notify();
+    Bool_t Rewind() { SetEventNum(0); return kTRUE; }
+    void   Print(Option_t *opt="") const;
+
+    ClassDef(MReadTree, 1)	// Reads a tree from file(s)
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mfileio/MWriteAsciiFile.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfileio/MWriteAsciiFile.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfileio/MWriteAsciiFile.cc	(revision 9661)
@@ -0,0 +1,304 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 06/2001 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// 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>
+
+#include <TMethodCall.h> // TMethodCall, AsciiWrite
+
+#include "MDataList.h"   // MDataList
+#include "MDataChain.h"  // MDataChain
+#include "MDataValue.h"  // MDataValue
+#include "MDataMember.h" // MDataMember
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+ClassImp(MWriteAsciiFile);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Init. Replaces the same code used in all constructors.
+//
+void MWriteAsciiFile::Init(const char *filename, const char *name, const char *title)
+{
+    fName  = name  ? name  : "MWriteAsciiFile";
+    fTitle = title ? title : "Task to write one container to an ascii file";
+
+    fNameFile = filename;
+
+    fOut = new ofstream(fNameFile);
+}
+
+// --------------------------------------------------------------------------
+//
+// Specify the name of the ascii output file 'filename' and the name
+// of the container you want to write. (Normally this is the name
+// of the class (eg. MHillas) but it can also be a different name which
+// identifies the container in the parameter list.
+// Because you cannot write more than one container there is no Add-function
+// like in MWriteRootFile.
+//
+//  For Example: MWriteAsciiFile("file.txt", "MHillas");
+//
+MWriteAsciiFile::MWriteAsciiFile(const char *filename, const char *contname,
+                                 const char *name, const char *title)
+{
+    Init(filename, name, title);
+
+    if (contname)
+       AddColumns(contname);
+}
+
+// --------------------------------------------------------------------------
+//
+// Specify a the name of the ascii output file 'filename' and a pointer to
+// the container you want to write. 
+// Because you cannot write more than one container there is no Add-function
+// like in MWriteRootFile.
+//
+//  For Example: MHillas hillas;
+//               MWriteAsciiFile("file.txt", &hillas);
+//
+//
+MWriteAsciiFile::MWriteAsciiFile(const char *filename, MParContainer *cont,
+                                 const char *name, const char *title)
+{
+    Init(filename, name, title);
+
+    if (cont)
+        AddColumns(cont);
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor. Delete the output file if necessary (it is closed
+// automatically by its destructor.
+//
+MWriteAsciiFile::~MWriteAsciiFile()
+{
+    fAutoDel.SetOwner();
+    delete fOut;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return open state of the file
+//
+Bool_t MWriteAsciiFile::IsFileOpen() const
+{
+    return (bool)(*fOut);
+}
+
+// --------------------------------------------------------------------------
+//
+// Tries to get all containers from the ParList which were given by name
+// adds them to the list of pointers to the container which should be
+// written to the ascii file.
+//
+Bool_t MWriteAsciiFile::GetContainer(MParList *plist)
+{
+    TObject *obj=NULL;
+
+    TIter Next(&fList);
+    while ((obj=Next()))
+    {
+        //
+        // MData is the highest class in the inheritance tree
+        //
+        if (obj->InheritsFrom(MData::Class()))
+        {
+            if (!((MData*)obj)->PreProcess(plist))
+                return kFALSE;
+            continue;
+        }
+
+        //
+        // MParContainer is the next class in the inheritance tree
+        //
+        if (obj->InheritsFrom(MParContainer::Class()))
+            continue;
+
+        //
+        // It is neither a MData nor a MParContainer, it must be a TNamed
+        //
+        TObject *o = plist->FindObject(obj->GetName());
+        if (!o)
+            return kFALSE;
+
+        fList[fList.IndexOf(obj)] = o;
+    }
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Check if the containers are ready for writing. If so write them.
+// The containers are written in one line, one after each other.
+// If not all containers are written (because of the IsReadyToSave-flag)
+// a warning message is print.
+//
+Bool_t MWriteAsciiFile::CheckAndWrite() const
+{
+    Bool_t written = kFALSE;
+
+    MParContainer *obj = NULL;
+
+    Int_t num = fList.GetEntries();
+
+    TIter Next(&fList);
+    while ((obj=(MParContainer*)Next()))
+    {
+        //
+        // Check for the Write flag
+        //
+        if (!obj->IsReadyToSave())
+            continue;
+
+        //
+        // Write container to file
+        //
+        if (!obj->AsciiWrite(*fOut))
+            continue;
+
+        //
+        // Store that at least one container was written
+        //
+        written = kTRUE;
+
+        num--;
+    }
+
+    if (written)
+    {
+        *fOut << endl;
+
+        if (num!=0)
+            *fLog << warn << "Warning - given number of objects doesn't fit number of written objects." << endl;
+    }
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Add a rule to be written as a column to the ascii file.
+// For more information about rules see MDataChain.
+//
+//  eg: MWriteAsciiFile::AddColumn("log10(MHillas.fEnergy)/2")
+//
+void MWriteAsciiFile::AddColumn(const TString rule)
+{
+    MDataChain *chain = new MDataChain(rule);
+    fList.Add(chain);
+}
+
+// --------------------------------------------------------------------------
+//
+// Add another column to be written to the ascii file. The columns will be
+// output one after each other in one line.
+// Specify the name of the data member to be written (eg fWidth) and
+// a possible scale factor (eg. to transform millimeters to degrees)
+//
+//  eg:
+//       MMcEvt evt;
+//       MWriteAsciiFile::AddColumn(&evt, "fImpact", 0.01);
+//
+void MWriteAsciiFile::AddColumn(MParContainer *cont, const TString member, Double_t scale)
+{
+    MData *data = new MDataMember(cont, member);
+
+    if (scale!=1)
+    {
+        MDataList  *list = new MDataList('*');
+        MDataValue *val  = new MDataValue(scale);
+
+        list->SetOwner();
+        list->AddToList(data);
+        list->AddToList(val);
+
+        data = list;
+    }
+    fList.Add(data);
+    fAutoDel.Add(data);
+}
+
+// --------------------------------------------------------------------------
+//
+// Add another container (by name) to be written to the ascii file.
+// The container will be output one after each other in one line.
+// The output will be done either by MParContainer::AsciiWrite or
+// by the corresponding overloaded function.
+//
+//  eg: MWriteAsciiFile::AddColumns("MMcEvt")
+//
+void MWriteAsciiFile::AddColumns(const TString cont)
+{
+    TNamed *name = new TNamed(cont, cont);
+    fList.Add(name);
+    fAutoDel.Add(name);
+}
+
+// --------------------------------------------------------------------------
+//
+// Add another container (by pointer) to be written to the ascii file.
+// The container will be output one after each other in one line.
+// The output will be done either by MParContainer::AsciiWrite or
+// by the corresponding overloaded function.
+//
+//  eg:
+//      MMcEvt evt;
+//      MWriteAsciiFile::AddColumns(&evt);
+//
+void MWriteAsciiFile::AddColumns(MParContainer *cont)
+{
+    fList.Add(cont);
+}
Index: /tags/Mars_V0-8-5/Mars/mfileio/MWriteAsciiFile.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfileio/MWriteAsciiFile.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfileio/MWriteAsciiFile.h	(revision 9661)
@@ -0,0 +1,45 @@
+#ifndef MARS_MWriteAsciiFile
+#define MARS_MWriteAsciiFile
+
+#ifndef MARS_MWriteFile
+#include "MWriteFile.h"
+#endif
+#ifndef ROOT_TObjArray
+#include <TObjArray.h>
+#endif
+
+class MData;
+
+class MWriteAsciiFile : public MWriteFile
+{
+private:
+    ofstream *fOut;     //! ascii file
+
+    TString fNameFile;  // name of the ascii file
+
+    TObjArray fList;    // list of rules and containers to be written
+    TObjArray fAutoDel; //! List of object to be deleted in the destructor
+
+    virtual Bool_t CheckAndWrite() const;
+    virtual Bool_t IsFileOpen() const;
+    virtual Bool_t GetContainer(MParList *pList);
+    virtual const char *GetFileName() const { return fNameFile; }
+
+    void Init(const char *filename, const char *name, const char *title);
+
+public:
+    MWriteAsciiFile(const char *filename, const char *contname,
+                    const char *name=NULL, const char *title=NULL);
+    MWriteAsciiFile(const char *filename, MParContainer *cont=NULL,
+                    const char *name=NULL, const char *title=NULL);
+    ~MWriteAsciiFile();
+
+    void AddColumn(const TString rule);
+    void AddColumn(MParContainer *cont, const TString member="", Double_t scale=1);
+    void AddColumns(const TString name);
+    void AddColumns(MParContainer *cont);
+
+    ClassDef(MWriteAsciiFile, 0) // Class to write data into an ascii file
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mfileio/MWriteFile.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfileio/MWriteFile.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfileio/MWriteFile.cc	(revision 9661)
@@ -0,0 +1,114 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 6/2001 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// 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>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+ClassImp(MWriteFile);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// 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.
+//
+Int_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
+    //
+    return CheckAndWrite();
+}
+
+// --------------------------------------------------------------------------
+//
+// Checks if the SetReadyToSave flag of the output container is set. If it
+// is set the container should be written to the output.
+//
+Bool_t MWriteFile::ReInit(MParList *pList)
+{
+    return CheckAndWrite();
+}
+
+// --------------------------------------------------------------------------
+//
+// Checks if the SetReadyToSave flag of the output container is set. If it is
+// set the container should be written to the output.
+//
+Int_t MWriteFile::Process()
+{
+    return CheckAndWrite();
+}
+
+// --------------------------------------------------------------------------
+//
+// Checks if the SetReadyToSave flag of the output container is set. If it is
+// set the container should be written to the output.
+//
+Int_t MWriteFile::PostProcess()
+{
+    //
+    // check if the container changed state is set
+    //
+    return CheckAndWrite();
+}
Index: /tags/Mars_V0-8-5/Mars/mfileio/MWriteFile.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfileio/MWriteFile.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfileio/MWriteFile.h	(revision 9661)
@@ -0,0 +1,25 @@
+#ifndef MARS_MWriteFile
+#define MARS_MWriteFile
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MWriteFile : public MTask
+{
+private:
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+    Bool_t ReInit(MParList *pList);
+
+    virtual Bool_t      IsFileOpen() const = 0;
+    virtual Bool_t      CheckAndWrite() const = 0;
+    virtual Bool_t      GetContainer(MParList *pList) = 0;
+    virtual const char *GetFileName() const = 0;
+
+
+    ClassDef(MWriteFile, 0)	// Base class for tasks to write single containers to several output formats
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mfileio/MWriteRootFile.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfileio/MWriteRootFile.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfileio/MWriteRootFile.cc	(revision 9661)
@@ -0,0 +1,527 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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, 6/2001 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MWriteRootFile                                                          //
+//                                                                         //
+// This is a writer to store several containers to a root file.            //
+// The containers are added with AddContainer.                             //
+// To understand how it works, see base class MWriteFile                   //
+//                                                                         //
+// Warning: Checkout the Warning in MTaskList.                             //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MWriteRootFile.h"
+
+#include <fstream>
+
+#include <TFile.h>
+#include <TTree.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+ClassImp(MRootFileBranch);
+ClassImp(MWriteRootFile);
+
+using namespace std;
+
+static const TString gsDefName  = "MWriteRootFile";
+static const TString gsDefTitle = "Task which writes a root-output file";
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. It is there to support some root stuff.
+// Don't use it.
+//
+MWriteRootFile::MWriteRootFile() : fOut(NULL)
+{
+    fName  = gsDefName;
+    fTitle = gsDefTitle;
+
+    fBranches.SetOwner();
+}
+
+// --------------------------------------------------------------------------
+//
+// Specify the name of the root file. You can also give an option ("UPDATE"
+// and "RECREATE" would make sense only) as well as the file title and
+// compression factor. To a more detaild description of the options see
+// TFile.
+//
+MWriteRootFile::MWriteRootFile(const char *fname,
+                               const Option_t *opt,
+                               const char *ftitle,
+                               const Int_t comp,
+                               const char *name,
+                               const char *title)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+
+    //
+    // Set the Arrays the owner of its entries. This means, that the
+    // destructor of the arrays will delete all its entries.
+    //
+    fBranches.SetOwner();
+
+    //
+    // Believing the root user guide, TTree instanced are owned by the
+    // directory (file) in which they are. This means we don't have to
+    // care about their destruction.
+    //
+    //fTrees.SetOwner();
+
+    TString str(fname);
+    if (!str.EndsWith(".root", TString::kIgnoreCase))
+        str += ".root";
+
+    //
+    // Open the rootfile
+    //
+    fOut = new TFile(str, opt, ftitle, comp);
+}
+
+// --------------------------------------------------------------------------
+//
+// Prints some statistics about the file to the screen. And closes the file
+// properly.
+//
+MWriteRootFile::~MWriteRootFile()
+{
+    //
+    // Print some statistics to the looging out.
+    //
+    Print();
+
+    //
+    // If the file is still open (no error) write the keys. This is necessary
+    // for appearance of the all trees and branches.
+    //
+    if (IsFileOpen())
+        fOut->Write();
+
+    //
+    // Delete the file. This'll also close the file (if open)
+    //
+    delete fOut;
+
+    //
+    // Remark:
+    // - Trees are automatically deleted by the the file
+    //   (unless file.SetDirectory(0) was called)
+    // - Branches are automatically deleted by the tree destructor
+    //
+
+    *fLog << inf << "Output File closed and object deleted." << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Prints all trees with the actually number of written entries to log-out.
+//
+void MWriteRootFile::Print(Option_t *) const
+{
+    *fLog << all << underline << "File: " << GetFileName() << endl;
+
+    if (fTrees.GetEntries()==0)
+    {
+        *fLog << " No contents." << endl;
+        return;
+    }
+
+    TObject *obj;
+    TIter NextBranch(&fBranches);
+    while ((obj=NextBranch()))
+    {
+        MRootFileBranch *b = (MRootFileBranch*)obj;
+
+        if (!b->GetTree() || b->GetTree()->TestBit(kIsNewTree))
+            continue;
+
+        TBranch *branch = b->GetBranch();
+
+        TString name = b->GetTree()->GetName();
+        name += '.';
+        name += branch->GetName();
+
+        *fLog << " " << name.Strip(TString::kTrailing, '.') << ": \t" << branch->GetEntries() << " entries." << endl;
+    }
+
+    TTree *t = NULL;
+    TIter NextTree(&fTrees);
+    while ((t=(TTree*)NextTree()))
+        if (t->TestBit(kIsNewTree))
+            *fLog << " " << t->GetName() << ": \t" << t->GetEntries() << " entries." << endl;
+    *fLog << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Add a new Container to list of containers which should be written to the
+// file. Give the name of the container which will identify the container
+// in the parameterlist. tname is the name of the tree to which the
+// container should be written (Remark: one tree can hold more than one
+// container). The default is the same name as the container name.
+// You can slso specify a title for the tree. This is only
+// used the first time this tree in 'mentioned'. As default the title
+// is the name of the tree.
+//
+void MWriteRootFile::AddContainer(const char *cname, const char *tname, Bool_t must)
+{
+    //
+    // create a new entry in the list of branches to write and
+    // add the entry to the list.
+    //
+    MRootFileBranch *entry = new MRootFileBranch(AddSerialNumber(cname), tname, must);
+    fBranches.AddLast(entry);
+
+    if (tname && tname[0])
+        AddToBranchList(Form("%s.%s", (const char*)AddSerialNumber(cname), tname));
+}
+
+// --------------------------------------------------------------------------
+//
+// Add a new Container to list of containers which should be written to the
+// file. Give the pointer to the container. tname is the name of the tree to
+// which the container should be written (Remark: one tree can hold more than
+// one container). The default is the same name as the container name.
+// You can slso specify a title for the tree. This is only
+// used the first time this tree in 'mentioned'. As default the title
+// is the name of the tree.
+//
+void MWriteRootFile::AddContainer(MParContainer *cont, const char *tname,
+                                  Bool_t must)
+{
+    //
+    // create a new entry in the list of branches to write and
+    // add the entry to the list.
+    //
+    MRootFileBranch *entry = new MRootFileBranch(cont, tname, must);
+    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)
+{
+    //
+    // loop over all branches which are 'marked' as branches to get written.
+    //
+    MRootFileBranch *entry;
+
+    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
+                //
+                if (entry->MustHave())
+                {
+                    *fLog << err << "Cannot find parameter container '" << cname << "'." << endl;
+                    return kFALSE;
+                }
+
+                *fLog << inf << "Unnecessary parameter container '" << cname << "' not found..." << endl;
+                delete fBranches.Remove(entry);
+                continue;
+            }
+
+            //
+            // 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 TString ttitle(Form("Tree containing %s", cont->GetDescriptor()));
+
+        //
+        // if the tree name is NULL this idetifies it to use the default:
+        // the container name.
+        //
+        if (tname[0] == '\0')
+            tname = cname;
+
+        //
+        // Check if the tree is already existing (part of the file)
+        //
+        TTree *tree = (TTree*)fOut->Get(tname);
+        if (!tree)
+        {
+            //
+            // if the tree doesn't exist create a new tree. Use the tree
+            // name as title if title is NULL.
+            // And add the tree to the list of trees
+            //
+            TDirectory *save = gDirectory;
+            fOut->cd();
+
+            tree = new TTree(tname, ttitle);
+            fTrees.AddLast(tree);
+
+            //
+            // If the tree does not already exist in the file mark this
+            // tree as a branch created by MWriteRootFile
+            //
+            tree->SetBit(kIsNewTree);
+
+            gDirectory = save;
+
+            *fLog << inf << "Tree " << tname << " created." << endl;
+        }
+
+        //
+        // In case the file is opened as 'UPDATE' the tree may still not
+        // be in the list. Because it neither was created previously,
+        // nor this time, so the corresponding entries is marked as a
+        // single branch to be filled. --> Add it to the list of trees.
+        //
+        if (!fTrees.FindObject(tree))
+            fTrees.AddLast(tree);
+
+        //
+        // Now we have a valid tree. Search the list of trees for this tree
+        // Add a pointer to the entry in the tree list to this branch-entry
+        //
+        entry->SetTree(tree);
+
+        TString branchname(cname);
+        branchname.Append(".");
+
+        //
+        // Try to get the branch from the file. 
+        // If the branch already exists the user specified one branch twice.
+        //
+        TBranch *branch = tree->GetBranch(branchname);
+        if (branch)
+        {
+            *fLog << inf << "Branch '" << cname << "' already existing... updating." << endl;
+            branch->SetAddress(entry->GetAddress());
+        }
+        else
+        {
+            //
+            // 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
+            //
+            *fLog << inf << "Creating Branch " << cname << " of " << cont->ClassName();
+            *fLog << " in tree " << tree->GetName() << "... " << flush;
+
+            branch = tree->Branch(branchname, cont->ClassName(), entry->GetAddress());
+            //
+            // If the branch couldn't be created we have a problem.
+            //
+            if (!branch)
+            {
+                *fLog << endl;
+                *fLog << err << "Unable to create branch '" << cname << "'." << endl;
+                return kFALSE;
+            }
+
+            *fLog << "done." << endl;
+        }
+
+        //
+        // Tell the entry also which branch belongs to it (this is necessary
+        // for branches belonging to already existing tree, UPDATE-mode)
+        //
+        entry->SetBranch(branch);
+    }
+    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 all their
+// branches.
+// In case of a file opened in 'UPDATE' mode, single branches can be
+// filled, too. WARNING - for the moment there is no check whether
+// you filled the correct number of events into the branch, so that
+// each of the other branches in the tree has the correct corresponding
+// number of new entries in the new branch!
+// Be carefull: If only one container (corresponding to a branch) of a tree
+// has the write flag, all containers in this tree are filled!
+//
+Bool_t MWriteRootFile::CheckAndWrite() const
+{
+    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.
+        //
+        if (b->GetTree()->TestBit(kIsNewTree))
+            b->GetTree()->SetBit(kFillTree);
+        else
+        {
+            if (!b->GetBranch()->Fill())
+            {
+                *fLog << err << "ERROR - Zero bytes written to branch '" << b->GetBranch()->GetName() << "'... abort." << endl;
+                return kFALSE;
+            }
+        }
+    }
+
+    //
+    // 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->ResetBit(kFillTree);
+        if (!t->Fill())
+        {
+            *fLog << err << "ERROR - Zero bytes written to tree '" << t->GetName() << "'... abort." << endl;
+            return kFALSE;
+        }
+    }
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// return open state of the root file.
+//
+Bool_t MWriteRootFile::IsFileOpen() const
+{
+    return fOut->IsOpen();
+}
+
+// --------------------------------------------------------------------------
+//
+// return name of the root-file
+//
+const char *MWriteRootFile::GetFileName() const
+{
+    return fOut->GetName();
+}
+
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
+void MWriteRootFile::StreamPrimitive(ofstream &out) const
+{
+    out << "   MWriteRootFile " << GetUniqueName() << "(\"";
+    out << fOut->GetName() << "\", \"";
+    out << fOut->GetOption() << "\", \"";
+    out << fOut->GetTitle() << "\", ";
+    out << fOut->GetCompressionLevel();
+
+    if (fName!=gsDefName || fTitle!=gsDefTitle)
+    {
+        out << ", \"" << fName << "\"";
+        if (fTitle!=gsDefTitle)
+            out << ", \"" << fTitle << "\"";
+    }
+    out << ");" << endl;
+
+
+    MRootFileBranch *entry;
+    TIter Next(&fBranches);
+    while ((entry=(MRootFileBranch*)Next()))
+    {
+        out << "   " << GetUniqueName() << ".AddContainer(";
+
+        if  (entry->GetContainer())
+        {
+            entry->GetContainer()->SavePrimitive(out);
+            out << "&" << entry->GetContainer()->GetUniqueName();
+        }
+        else
+            out << "\"" << entry->GetContName() << "\"";
+
+        out << ", \"" << entry->GetName() << "\"";
+        if (!entry->MustHave())
+            out << ", kFALSE";
+
+        out <<");" << endl;
+    }
+}
Index: /tags/Mars_V0-8-5/Mars/mfileio/MWriteRootFile.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfileio/MWriteRootFile.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfileio/MWriteRootFile.h	(revision 9661)
@@ -0,0 +1,112 @@
+#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;
+
+    Bool_t         fMust;
+
+    void Init(const char *name, Bool_t must)
+    {
+        SetName(name?name:"");
+        fMust = must;
+    }
+
+public:
+    MRootFileBranch() : fTree(NULL), fBranch(NULL), fContainer(NULL), fMust(0)
+    {
+        Init(NULL, kFALSE);
+        fContName = "";
+    }
+
+    MRootFileBranch(const char *cname, const char *tname=NULL, Bool_t must=kFALSE)
+        : fTree(NULL), fBranch(NULL), fContainer(NULL), fMust(0)
+    {
+        Init(tname, must);
+        fContName = cname;
+    }
+
+    MRootFileBranch(MParContainer *cont, const char *tname=NULL, Bool_t must=kFALSE)
+        : fTree(NULL), fBranch(NULL), fContName(""), fMust(0)
+    {
+        Init(tname, must);
+        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; }
+    Bool_t         MustHave() const     { return fMust; }
+
+    void SetContainer(MParContainer *cont) { fContainer = cont; }
+    void SetTree(TTree *tree)              { fTree = tree; }
+    void SetBranch(TBranch *branch)        { fBranch = branch; }
+
+    ClassDef(MRootFileBranch, 1) // Storage container for MWriteRootFile to store TBranch informations
+};
+
+class MWriteRootFile : public MWriteFile
+{
+private:
+    TFile *fOut;
+
+    TObjArray fBranches;
+    TObjArray fTrees;     //!
+
+    //UInt_t fNumEvents; //! Number of events written in a run
+
+    Bool_t      CheckAndWrite() const;
+    Bool_t      IsFileOpen() const;
+    Bool_t      GetContainer(MParList *pList);
+    const char *GetFileName() const;
+
+    void StreamPrimitive(ofstream &out) const;
+    //Bool_t ReInit(MParList *pList);
+
+    enum {
+        kFillTree  = BIT(14),
+        // TBranch::kAutoDelete = BIT(15)
+        // TBranchElement::kDeleteObject = BIT(16)
+        kIsNewTree = BIT(17)
+    };
+
+public:
+    MWriteRootFile();
+    MWriteRootFile(const char *fname,
+                   const Option_t *opt="RECREATE",
+                   const char *ftitle="Untitled",
+                   const Int_t comp=9,
+                   const char *name=NULL,
+                   const char *title=NULL);
+    ~MWriteRootFile();
+
+
+    void AddContainer(const char *cname,   const char *tname=NULL, Bool_t must=kTRUE);
+    void AddContainer(MParContainer *cont, const char *tname=NULL, Bool_t must=kTRUE);
+
+
+    void Print(Option_t *t=NULL) const;
+
+    ClassDef(MWriteRootFile, 1)	// Task to write data into a root file
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mfileio/Makefile
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfileio/Makefile	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfileio/Makefile	(revision 9661)
@@ -0,0 +1,39 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#------------------------------------------------------------------------------
+
+INCLUDES = -I. -I../mbase -I../mraw -I../mmc -I../mreflector -I../mgui \
+	   -I../mdata -I../mbadpixels
+#mraw:       MRawRunHeader (MReadMaraFile)
+#mmc:        MMcRunHeader  (MReadMarsFile)
+#mreflector: MRfl*         (MReadRflFile)
+#mgui:       MCamEvent     (MReadRflFile)
+#mdata:      MData*        (MWriteAsciiFile)
+
+CINT     = FileIO
+
+SRCFILES = MRead.cc \
+           MChain.cc \
+	   MReadTree.cc \
+           MReadReports.cc \
+           MReadMarsFile.cc \
+           MReadRflFile.cc \
+           MWriteFile.cc \
+           MWriteAsciiFile.cc \
+           MWriteRootFile.cc
+
+############################################################
+
+all: $(OBJS)
+
+include ../Makefile.rules
+
+mrproper:	clean rmbak
Index: /tags/Mars_V0-8-5/Mars/mfileio/defines.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfileio/defines.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfileio/defines.h	(revision 9661)
@@ -0,0 +1,788 @@
+/******************************************************************/
+/*              GGG   AAA   M   M M   M  AAA   SSS                */
+/*             G   G A   A  MM MM MM MM A   A S   S               */
+/*             G     A   A  M M M M M M A   A  SS                 */
+/*             G  GG AAAAA  M   M M   M AAAAA   SS                */
+/*             G   G A   A  M   M M   M A   A S   S               */
+/*              GGG  A   A  M   M M   M A   A  SSS                */
+/*       Gamma Astronomer's Munich Madrid Analysis Suite          */
+/*   An Atmospheric Cherenkov Telescope Data Analysis Software    */
+/*  MPI f"ur Physik, M"unchen & Universidad Complutense, Madrid   */
+/******************************************************************/
+
+/******************************************************************/
+/* This File belongs to the programs                              */
+/*                                                                */
+/*  P R E P R O C E S S O R   and   I M A G E R                   */
+/*                                                                */
+/* Purpose: provide the structure definitions common to both      */
+/*          programs, especially the output structures of the     */
+/*          preprocessor                                          */ 
+/*                                                                */
+/******************************************************************/
+
+#ifndef _defines_h_
+#define _defines_h_ "__defines_h__"
+
+#define cIDSTRING(x,y,z) "@(#) GAMMAS "#x" version "#y", date "#z"."
+#define CAT(x,y) #x#y
+#define XCAT(x,y) CAT(x,y)
+
+#define Boolean int
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+/*************** DEFINES ******************************************/
+
+/* General defines */
+
+#define cHELLOSTRING(x,y) "This is preproc.\nVersion "#x", date "#y"\n\n"
+#define PREPROCVERSIONSTRING(x) "V"#x  
+
+#define dDEG_PER_HOUR 15.
+#define dRAD_PER_DEG 0.0174532925199 /* = 3.14159265359/180. */
+#define dSECS_PER_DAY 86400.
+#define SQUARE(x) ((x) * (x))
+
+/* defines for histograms and ntuple creation */
+
+#define HMAX 2000000 /* memory reserved for pawc common block 
+		     * used by hbook */
+#define DAB -999 /* if a histogramm parameter is to be Defined 
+		  * At Booking enter -999 */
+#define iADCHISTID 1000 /* id of the first histogram for ADC 
+			 * count spectra */
+#define cADCHISTTITLE "Pixel signals before calibration;pixel \
+number;ADC counts"
+#define iADCHIST_BINS 127 /* This is a good guess. bparametersok()
+			   * will look at parameters for the bins 
+			   * in X direction and adjust the other,
+			   * similar histograms acoordingly. */
+#define fADCHIST_LOLIMX 0.5
+#define fADCHIST_HILIMX 127.5 /* For both of them, see above. */
+
+
+
+#define iPHEHISTID 2000 /* id of the first histogram for photo 
+			 *electron spectra */
+#define cPHEHISTTITLE "Pixel signals after calibration;pixel \
+number;photo electrons"
+#define iPHEHIST_BINS 127 /* This is a good guess. bparametersok()
+			   * will look at parameters for the bins 
+			   * in X direction and adjust the other,
+			   * similar histograms acoordingly. */
+#define fPHEHIST_LOLIMX 0.5
+#define fPHEHIST_HILIMX 127.5 /* For both of them, see above. */
+
+#define iPEDONHISTID 12000 /* id of the first histogram for the 
+			    *signals taken in pedestalruns for ON */
+#define iPEDOFHISTID 11000 /* id of the first histogram for the 
+			    *signals taken in pedestalruns for OF */
+#define cPEDONHISTTITLE "Pixel signals from ON pedestal runs;\
+pixel number;ADC Counts"
+#define cPEDOFHISTTITLE "Pixel signals from OF pedestal runs;\
+pixel number;ADC Counts"
+#define iPEDONMEANHISTID 14000 /* id of the first histogram for the 
+				*signals taken in pedestalruns for ON */
+#define iPEDOFMEANHISTID 13000 /* id of the first histogram for the 
+				*signals taken in pedestalruns for OF */
+#define cPEDONMEANHISTTITLE "Pedestal Means from ON pedestal runs;\
+Event Index;ADC Counts"
+#define cPEDOFMEANHISTTITLE "Pedestal Means from OF pedestal runs;\
+Event Index;ADC Counts"
+#define iPEDONJITTHISTID 16000 /* id of the first histogram for the 
+				*signals taken in pedestalruns for ON */
+#define iPEDOFJITTHISTID 15000 /* id of the first histogram for the 
+				*signals taken in pedestalruns for OF */
+#define cPEDONJITTHISTTITLE "Deviation from Pedestal Means from \
+ON pedestal runs;Pixel Number;ADC Counts"
+#define cPEDOFJITTHISTTITLE "Deviation from Pedestal Means from \
+OF pedestal runs;Pixel Number;ADC Counts"
+#define iCALONHISTID 18000 /* id of the first histogram for the 
+			    *signals taken in laserruns for ON */
+#define iCALOFHISTID 17000 /* id of the first histogram for the 
+			    *signals taken in plaserruns for OF */
+#define cCALONHISTTITLE "Pixel signals from ON laser runs;\
+pixel number;ADC Counts"
+#define cCALOFHISTTITLE "Pixel signals from OF laser runs;\
+Pixel Number;ADC Counts"
+#define iCALONMEANHISTID 20000 /* id of the first histogram for the 
+				*signals taken in laserruns for ON */
+#define iCALOFMEANHISTID 19000 /* id of the first histogram for the 
+			    *signals taken in plaserruns for OF */
+#define cCALONMEANHISTTITLE "Laser Means from ON laser runs;\
+Event Index;ADC Counts"
+#define cCALOFMEANHISTTITLE "Laser Means from OF laser runs;\
+Event Index;ADC Counts"
+#define iCALONJITTHISTID 22000 /* id of the first histogram for the 
+				*signals taken in laserruns for ON */
+#define iCALOFJITTHISTID 21000 /* id of the first histogram for the 
+			    *signals taken in plaserruns for OF */
+#define cCALONJITTHISTTITLE "Deviation from Laser Means from \
+ON laser runs;Pixel Number;ADC counts"
+#define cCALOFJITTHISTTITLE "Deviation from Laser Means from \
+OF laser runs;Pixel Number;ADC counts"
+#define iZENONHISTID 200 /* id of the histogram for the zenith 
+			  * angle distribution before filter ON */
+#define iZENOFHISTID 100 /* id of the histogram for the zenith 
+			  * angle distribution before filter OF */
+#define cZENONHISTTITLE "zenith angle distribution before filter \
+ON;zenith angle;number of events ON"
+#define cZENOFHISTTITLE "zenith angle distribution before filter \
+OFF;zenith angle;number of events OFF"
+#define iZENHISTNUMBINS 90
+#define fZENHISTLOLIM 0.
+#define fZENHISTHILIM 90.
+/* defines for noise pickup correction of pedestal (added D.K.)
+ */
+#define iCORRPEDHISTID 400 /* id of histogram for pedestal correction values
+			      (noise pickup) */
+#define cCORRPEDHISTTIT "Pickup Correction;ADC counts;Nr. of Events"
+#define iCPEDFWHMHISTID 410 /* id of the histogram for FWHM of pedestal
+			       correction values (noise pickup) */
+#define cCPEDFWHMHISTTIT "FWHM of Pickup Correction;ADC counts;Nr. of Events"
+#define fMIN_CORRPEDHIST -20.
+#define fMAX_CORRPEDHIST 20.
+#define iCORRPEDHIST_BINS 80
+#define fMIN_CPEDFWHMHIST 0.
+#define fMAX_CPEDFWHMHIST 20
+#define iCPEDFWHMHIST_BINS 40
+#define iBIAS 50             /* is used to make the pedestals peak at 'iBIAS' */
+#define dPEDCORRSIZELIMIT 500. /* maximum event SIZE for which noise-pickup is
+				  corrected */
+/* end: defines for noise pickup correction of pedestal
+ */
+
+/* MKA May 8 2000: Version > 0.4 */
+#define cHISTOFILENAME ".hbook" 
+#define cCALNTFILENAME ".nt.hbook"
+#define cOUTDIRNAME "preproc_out/"
+#define cPROJECTNAME "check"
+#define iCALIBNTUPLE_ID  3
+#define iRECL 1024 /* the record length of the calibration ntuple */ 
+
+#define iPARTNERSEARCHDEPTH 20 /* Default search depth if not specified. */
+/* various parameters */
+
+#ifdef ALPHA
+#define iMAXNUMLASERRUNS 4 /* maximum number of laser runs 
+			    * recorded in one file 
+			    * (90 degrees * 4 minutes/degree / 20 minutes) */
+#endif
+#ifdef LINUX
+#define iMAXNUMLASERRUNS 6 /* maximum number of laser runs 
+			    * recorded in one file 
+			    * (90 degrees * 4 minutes/degree / 20 minutes) */
+#endif
+#define iMAXNUMLASEREVENTS 250 /* maximum number of laser shots
+				* recorded for one laser run */
+#ifdef ALPHA
+#define iMAXNUMPEDRUNS 4 /* maximum number of pedestal runs 
+			   * recorded in one file */
+#endif
+#ifdef LINUX
+#define iMAXNUMPEDRUNS 26 /* maximum number of pedestal runs 
+			   * recorded in one file */
+#endif
+#define iMAXNUMPEDEVENTS 500 /* maximum number of random triggers 
+			      * recorded for one pedestal run */
+#define iMAXNUMRUNEVENTS 40000 /* maximum number of events recorded 
+				* in one run data file */
+#define iNUMRMSFITXBINS 100 /* Bins in the (vector)histogram for the 
+			     * fit of the Pedestal RMS */
+#define iRMSFITXSTRETCH 50 /* strectch of the (vector)histogram for the 
+			     * fit of the Pedestal RMS */
+/* Attention: for iNUMRMSFITXBINS and iRMSFITXSTRETCH the following
+ * requirement must be fulfilled:
+ * A width of 1 must be achieveble as an integer multiple of the
+ * binwidth, i.e. 5 or 6 times (iRMSFITXSTRETCH/iNUMRMSFITXBINS) must
+ * make up 1. */
+
+#define iRMSFITXOFFSET 2 /* half a bin offset to the left: Start a bin 
+			 * with center at 0 at 1./2. binwidth earlier */
+
+#define iMAXFILENAMELENGTH 400
+/* general limit on the length of filename strings (including path) */ 
+#define iMAXNUMDIRENTRIES 1028 /* MKA: Nonsens to limit this; we 
+				* rewrite this in the future. 
+				* Make a chained list and allocate
+				* memory for it dynamically. Free
+				* this memory afterwards. 
+				* Put on to-do-list Nov 6 1999 */
+/* the maximum number of filenames expected in a directory to 
+ * be read by ireaddir() */
+#define cDIRFILENAME "preproc.dir" 
+/* intermediate file used by ireaddir() */
+#define iMAXNUMCALFILEOFFSET 400 /* That is the number of Runs, which 
+				  * is searched back to find a TelCal 
+				  * file for analysis. */
+
+#define iMAXNUMPEDFILEOFFSET 400 /* That is the number of Runs, which 
+				  * is searched back to find a TelPed 
+				  * file for analysis. */ 
+
+#define iMAXNUMTELLOGFILEOFFSET 400 /* That is the number of Runs, which 
+				     * is searched back to find a TelLog 
+				     * file for analysis. */
+
+/* keywords, numbers of arguments, values and ranges of values 
+   which define the syntax in the parameters file
+   
+   in order to introduce a new input parameter, you have to 
+   a) increase iNUMKEYWORDS
+   b) #define the keyword (cKEYWORDXX), the format for the 
+      arguments (cKEYWORDXXARG)
+      the number of arguments (iKEYWORDXXNUMARG), 
+      the minimum and maximum value 
+      (iMIN..., iMAX...) for numerical arguments
+   c) for enum-type arguments look at keywords 10 or 11 to see 
+      what to #define
+      (iKEYWORDXXARGYNUMVAL = the number of values the arguments 
+      no. Y of keyword no. XX can take, 
+      cKEYWORDXXARGYVALS  = enumeration of the different values 
+      (strings) the argument can have
+   d) put entries into the initialization of the arrays ckeyword, 
+      ckeywordarg, ikeywordnumarg, fargvalmin, fargvalmax, and 
+      for enum-type arguments declare a new array keywordXXvalues 
+      as for keywords 10 and 11
+   e) include the new parameter into the structure inputpars, 
+      and, if you wish to, in outputpars also.
+   f) add the corresponding case to the switch(k) statement in main()
+   g) modify bparametersok(), bprintinputpars() and 
+      vsetinputparsunfilled()
+   h) program the transfer of the parameter from inputpars to 
+      outputpars if necessary
+      .... to be continued  */
+
+
+#define iNUMKEYWORDS 46  /* the number of different kewords 
+			  * defined for use in the
+                          * parameters file */
+
+#define cKEYWORD01                "iTELESCOPE"
+/* keyword no. 1, this keyword must have this number, don't change it */
+#define cKEYWORD01ARG             "%d"
+#define iKEYWORD01NUMARG 1 /* number of arguments */
+#define iMINTELESCOPEID 1 /* minimum value */
+#define iMAXTELESCOPEID 2 /* maximum value */
+
+#define cKEYWORD02                "iRUNNUM"
+/* keyword no. 2, this keyword must have this number, don't change it */
+#define cKEYWORD02ARG             "%d"
+#define iKEYWORD02NUMARG 1
+#define iMINRUNNUM 0 /* minimum value */
+#define iMAXRUNNUM 99999 /* maximum value */
+
+#define cKEYWORD03                "inumpixels"
+/* keyword no. 3 */
+#define cKEYWORD03ARG             "%d"
+#define iKEYWORD03NUMARG 1
+#define iMINNUMPIX 37 /* minimum value for the number of camera 
+		       * pixels (excl. muon shield) */
+/* #define iMAXNUMPIX ..  maximum value defined in structures.h */
+
+#define cKEYWORD04                "fpixdiameter_deg"
+/* keyword no. 4 */
+#define cKEYWORD04ARG             "%f"
+#define iKEYWORD04NUMARG 1
+#define fMINPIXDIA_DEG 0.1 /* minimum value */
+#define fMAXPIXDIA_DEG 1.0 /* maximum value */
+
+#define cKEYWORD05                "ise1zeropos"
+/* keyword no. 5 */
+#define cKEYWORD05ARG             "%d"
+#define iKEYWORD05NUMARG 1
+#define iMINSE1POS 0 /* minimum value */
+#define iMAXSE1POS 50000 /* maximum value */
+
+#define cKEYWORD06                "ise2zeropos"
+/* keyword no. 6 */
+#define cKEYWORD06ARG             "%d"
+#define iKEYWORD06NUMARG 1
+#define iMINSE2POS 0 /* minimum value */
+#define iMAXSE2POS 50000 /* maximum value */
+
+#define cKEYWORD07               "idontusepix"
+/* keyword no. 7 */
+#define cKEYWORD07ARG             "%d"
+#define iKEYWORD07NUMARG 1 
+#define iMINPIXNUM 1 /* in the parameters file counting of the 
+		      * pixels starts at 1 */
+/* maximum value of this parameter is iMAXNUMPIX */
+/* negative parameters in the range -iMINPIXNUM to -iMAXNUMPIX 
+ * are also allowed: */
+/* they switch the pixel back on */
+
+#define cKEYWORD08               "isum_thresh_phot"
+/* keyword no. 8 */
+#define cKEYWORD08ARG             "%d"
+#define iKEYWORD08NUMARG 1
+#define iMINSUMTHRESH_PHOT 0 /* minimum value */
+#define iMAXSUMTHRESH_PHOT 65536 /* maximum value */
+
+#define cKEYWORD09              "i2out_thresh_phot"
+/* keyword no. 9 */
+#define cKEYWORD09ARG             "%d"
+#define iKEYWORD09NUMARG 1
+#define iMIN2OUTTHRESH_PHOT 0 /* minimum value */
+#define iMAX2OUTTHRESH_PHOT 65536 /* maximum value */
+
+#define cKEYWORD10               "usecalfile"
+/* keyword no. 10 */
+#define cKEYWORD10ARG             "%s %d %d"
+#define iKEYWORD10NUMARG 3 /* first arg: search direction, 
+			    * second arg: end of search or
+			    * search depth in case of 
+			    * pingpong method */
+#define iKEYWORD10ARG1NUMVAL 5
+#define cKEYWORD10ARG1VALS "match", "before", "after", "pingpong", "none"
+/* minimum and maximum value of the second argument are 
+ * identical with iMINRUNNUM and iMAXRUNNUM */
+
+#define cKEYWORD11               "usepedfile"
+/* keyword no. 11 */
+#define cKEYWORD11ARG             "%s %d %d"
+#define iKEYWORD11NUMARG 3 /* first arg: search direction,
+			    * second arg: end of search or
+			    * search depth in case of 
+			    * pingpong method */
+#define iKEYWORD11ARG1NUMVAL 5
+#define cKEYWORD11ARG1VALS "match", "before", "after", "pingpong", "none"
+/* minimum and maximum value of the second argument are 
+ * identical with iMINRUNNUM and iMAXRUNNUM */
+
+#define cKEYWORD12                "inummuonpixels"
+/* keyword no. 12 */
+#define cKEYWORD12ARG             "%d"
+#define iKEYWORD12NUMARG 1
+#define iMINNUMMUONPIX 0 /* minimum value */
+/* #define iMAXNUMMUONPIX ..  maximum value defined in structures.h */
+
+#define cKEYWORD13                "inumcointdcs"
+/* keyword no. 13 */
+#define cKEYWORD13ARG             "%d"
+#define iKEYWORD13NUMARG 1
+#define iMINNUMCOINTDCS 0 /* minimum value */
+/* #define iMAXNUMCOINTDCS ..  maximum value defined in structures.h */
+
+#define cKEYWORD14                "fphotoel_per_adccnt"
+/* keyword no. 14 */
+#define cKEYWORD14ARG             "%s %f"
+#define iKEYWORD14NUMARG 2
+#define fMINPHOTOEL_PER_ADCCNT 0.1 /* minimum value for the 
+				    * second argument */
+#define fMAXPHOTOEL_PER_ADCCNT 999.0 /* maximum value for the 
+				      * second argument */
+/* as first argument either a single integer number or a 
+ * range may be given (format: e.g. 10-20) minimum and 
+ * maximum value of the first argument are identical with 
+ * iMINPIXNUM and the number of pixels in the camera */
+
+#define cKEYWORD15               "bmuon_suppression"       
+/* keyword no. 15 */
+#define cKEYWORD15ARG             "%s"
+#define iKEYWORD15NUMARG 1 /* this keyword is a switch */
+#define iKEYWORD15ARG1NUMVAL 2
+#define cKEYWORD15ARG1VALS "off", "on" /* the order of this 
+					* enumeration is essential 
+					* to make off equivalent 
+					* to FALSE */
+
+#define cKEYWORD16                "ftolerated_pointerror_deg"
+/* keyword no. 16 */
+#define cKEYWORD16ARG             "%f"
+#define iKEYWORD16NUMARG 1
+#define fMINTOLERATED_POINTERROR_DEG 0. /* minimum value for 
+					 * the maximum tolerated 
+					 * pointing error in the 
+					 * position check in 
+					 * iprocessdata */
+#define fMAXTOLERATED_POINTERROR_DEG 180. /* maximum value */
+
+#define cKEYWORD17                "iratecalc_numevents_odd"
+/* keyword no. 17 */
+#define cKEYWORD17ARG             "%d"
+#define iKEYWORD17NUMARG 1
+#define iMINRATECALC_NUMEVENTS_ODD 3 /* minimum value for the 
+				      * number of events used 
+				      * in the event rate 
+				      * calculation */
+#define iMAXRATECALC_NUMEVENTS_ODD 999 /* maximum value */
+
+#define cKEYWORD18                "fdegrees_per_step1"
+/* keyword no. 18 */
+#define cKEYWORD18ARG             "%f"
+#define iKEYWORD18NUMARG 1
+#define fMINDEGREES_PER_STEP 0.0001 /* minimum value for the 
+				     * resolution of shaft encoder 1 */
+#define fMAXDEGREES_PER_STEP 0.1 /* maximum value */
+
+#define cKEYWORD19                "fdegrees_per_step2"
+/* keyword no. 19 */
+#define cKEYWORD19ARG             "%f"
+#define iKEYWORD19NUMARG 1
+/* minimum and maximum values as for keyword 18 */
+
+#define cKEYWORD20               "se1_is"
+/* keyword no. 20 */
+#define cKEYWORD20ARG             "%s"
+#define iKEYWORD20NUMARG 1 
+#define iKEYWORD20ARG1NUMVAL 4
+#define cKEYWORD20ARG1VALS "RA", "DEC", "ALT", "AZ"
+
+#define cKEYWORD21                "flongitude_deg"
+/* keyword no. 21 */
+#define cKEYWORD21ARG             "%f"
+#define iKEYWORD21NUMARG 1
+#define fMIN_LONG_DEG 0. /* minimum value for the longitude 
+			  * of the telescope position */
+#define fMAX_LONG_DEG 359.99999 /* maximum value (the 
+				 * longitude is counted 
+				 * positive towards West */
+
+#define cKEYWORD22                "flatitude_deg"
+/* keyword no. 22 */
+#define cKEYWORD22ARG             "%f"
+#define iKEYWORD22NUMARG 1
+#define fMIN_LAT_DEG  -90.0 /* minimum value for the latitude 
+			     * of the telescope position */
+#define fMAX_LAT_DEG +90.0 /* maximum value */
+
+#define cKEYWORD23                "irubminusutc_usecs"
+/* keyword no. 23 */
+#define cKEYWORD23ARG             "%d"
+#define iKEYWORD23NUMARG 1
+#define iMINRUBMINUSUTC_USECS -60E6 /* minimum value for the 
+				     * time difference between 
+				     * rubidium clock and UTC*/
+#define iMAXRUBMINUSUTC_USECS 60e6 /* maximum value */
+
+#define cKEYWORD24                "iaz_rev_track_corr"
+/* keyword no. 24 */
+#define cKEYWORD24ARG             "%d"
+#define iKEYWORD24NUMARG 1
+#define iMINAZ_REV_TRACK_CORR -1000 /* minimum value for the 
+				     * correction of the az 
+				     * shaft encoder values 
+				     * in reverse tracking mode
+				     * see Calc_corr in TIJARAFE */
+#define iMAXAZ_REV_TRACK_CORR 1000 /* maximum value */
+
+#define cKEYWORD25                "ialt_rev_track_corr"
+/* keyword no. 25 */
+#define cKEYWORD25ARG             "%d"
+#define iKEYWORD25NUMARG 1
+#define iMINALT_REV_TRACK_CORR -1000 /* minimum value for the 
+				      * correction of the alt 
+				      * shaft encoder values 
+				      * in reverse tracking mode
+				      * see Calc_corr in TIJARAFE */
+#define iMAXALT_REV_TRACK_CORR 1000 /* maximum value */
+
+#define cKEYWORD26                "fbendingcorr"
+/* keyword no. 26 */
+#define cKEYWORD26ARG             "%f"
+#define iKEYWORD26NUMARG 1
+#define fMINBENDINGCORR  -0.5 /* minimum value for the bending 
+			       * correction factor for the alt 
+			       * shaft encoder values
+			       * see Calc_corr in TIJARAFE */
+#define fMAXBENDINGCORR 0.5 /* maximum value */
+
+#define cKEYWORD27                "fextinction"
+/* keyword no. 27 */
+#define cKEYWORD27ARG             "%f"
+#define iKEYWORD27NUMARG 1
+#define fMINEXTINCTION  0. /* minimum value for the 
+			    * atmospheric extinction */
+#define fMAXEXTINCTION  1. /* maximum value */
+
+#define cKEYWORD28                "dsource_ra_hours"
+/* keyword no. 28 */
+#define cKEYWORD28ARG             "%lf"
+#define iKEYWORD28NUMARG 1
+#define fMINRA_HOURS 0.0   /* minimum value for the right 
+			    * ascension of the assumed source */
+#define fMAXRA_HOURS 23.99999999 /* maximum value */
+
+#define cKEYWORD29                "dsource_dec_deg"
+/* keyword no. 29 */
+#define cKEYWORD29ARG             "%lf"
+#define iKEYWORD29NUMARG 1
+#define fMINDEC_DEG -90.0 /* minimum value for the 
+			   * declination of the assumed source */
+#define fMAXDEC_DEG 90.0        /* maximum value */
+
+#define cKEYWORD30                "imuoncut_thresh_adccnt"
+/* keyword no. 30 */
+#define cKEYWORD30ARG             "%s %d"
+#define iKEYWORD30NUMARG 2
+#define iMINMUONCUT_THRESH_ADCCNT 0 /* minimum value for the 
+				     * second argument */
+#define iMAXMUONCUT_THRESH_ADCCNT 65536 /* maximum value for 
+					 * the second argument */
+/* as first argument either a single integer number or a 
+ * range may be given (format: e.g. 3-5) minimum and maximum 
+ * value of the first argument are the number of pixels in 
+ * the camera +1 and the number of pixels in the camera + 
+ * the number of muonpixels in the camera */
+
+#define cKEYWORD31                "fxpointcorr_deg"
+/* keyword no. 31 */
+#define cKEYWORD31ARG             "%f"
+#define iKEYWORD31NUMARG 1
+#define fMINRAPOINTERROR_DEG -10. /* minimum value for the 
+				   * pointing error correction 
+				   * along camera x axis as known 
+				   * from e.g. a pointrun */
+#define fMAXRAPOINTERROR_DEG +10. /* maximum value */
+
+#define cKEYWORD32                "fypointcorr_deg"
+/* keyword no. 32 */
+#define cKEYWORD32ARG             "%f"
+#define iKEYWORD32NUMARG 1
+#define fMINDECPOINTERROR_DEG -10. /* minimum value for the 
+				    * pointing error correction 
+				    * along camera y axis as known 
+				    * from e.g. a pointrun */
+#define fMAXDECPOINTERROR_DEG +10. /* maximum value */
+
+#define cKEYWORD33                "fcamera_align_angle_deg"
+/* keyword no. 33 */
+#define cKEYWORD33ARG             "%f"
+#define iKEYWORD33NUMARG 1
+#define fMINCAMALIGNANGLE_DEG -180. /* minimum value for the 
+				     * angle between the camera 
+				     * y-axis and the meridian 
+				     * when a culminating object
+				     * is observed (defined 
+				     * counter-clockwise looking 
+				     * at the sky) */
+#define fMAXCAMALIGNANGLE_DEG 180. /* maximum value */
+
+#define cKEYWORD34               "bhistograms"
+/* keyword no. 34 */
+#define cKEYWORD34ARG             "%s"
+#define iKEYWORD34NUMARG 1 /* this keyword is a threefold switch */
+#define iKEYWORD34ARG1NUMVAL 3
+#define cKEYWORD34ARG1VALS "off", "on", "new" /* the order of this 
+					       * enumeration is 
+					       * essential to make 
+					       * off equivalent to FALSE */
+
+#define cKEYWORD35                "iadc_histopars"
+/* keyword no. 35 */
+#define cKEYWORD35ARG             "%d %f %f"
+#define iKEYWORD35NUMARG 3
+#define iMINBINS 3
+#define iMAXBINS 300
+#define fMIN_ADCHIST_LOLIM -50.5
+#define fMAX_ADCHIST_LOLIM 1000.
+#define fMIN_ADCHIST_HILIM 0.5
+#define fMAX_ADCHIST_HILIM 65535.5
+
+#define cKEYWORD36                "iphe_histopars"
+/* keyword no. 36 */
+#define cKEYWORD36ARG             "%d %f %f"
+#define iKEYWORD36NUMARG 3
+#define fMIN_PHEHIST_LOLIM -10000.
+#define fMAX_PHEHIST_LOLIM 1000.
+#define fMIN_PHEHIST_HILIM -1000.
+#define fMAX_PHEHIST_HILIM 10000.
+
+#define cKEYWORD37                "idontusepix_in_trig"
+/* keyword no. 37 */
+#define cKEYWORD37ARG             "%s"
+#define iKEYWORD37NUMARG 1    /* in the parameters file 
+			       * counting of the pixels starts at 1
+                              * minimum value is iMINPIXNUM 
+                              * maximum value of this parameter 
+			      * is iMAXNUMPIX the pixel can only be 
+			      * taken back into trigger by resetting all
+                              * parameters */
+
+#define cKEYWORD38                "fpadlevel_phot_pix"
+/* keyword no. 38 */
+#define cKEYWORD38ARG             "%s %f"
+#define iKEYWORD38NUMARG 2
+#define fMINPADLEVEL_PHOT  0. /* minimum value for the software 
+			       * padding level for each pixel */
+#define fMAXPADLEVEL_PHOT  100. /* maximum value */
+
+#define cKEYWORD39                "frandomseeds"
+/* keyword no. 39 */
+#define cKEYWORD39ARG             "%f %f "
+#define iKEYWORD39NUMARG 2
+#define fMINSEED 1. /* minimum value for the maximum tolerated 
+		     * pointing error in the position check in 
+		     * iprocessmcdata */
+#define fMAXSEED 1.e10 /* maximum value */
+
+#define cKEYWORD40                "iswap_pixels"
+/* keyword no. 40 */
+#define cKEYWORD40ARG             "%d %d " /* the number of the 
+					    * two pixels for which 
+					    * the numbering should 
+					    * be swapped (in 
+					    * ireadrunfile, 
+					    * -pedfile, -calfile) */
+#define iKEYWORD40NUMARG 2
+/* the minimum value for this argument is iMINPIXNUM, the maximum 
+ * is iMAXNUMPIX */
+
+#define cKEYWORD41                "%"
+/* keyword no. 41 */
+#define cKEYWORD41ARG             "\n" /* using this keyword, 
+					* comments can be added 
+					* to the parameter file */
+#define iKEYWORD41NUMARG 0
+
+#define cKEYWORD42           "errortolerance"
+/* keyword no. 42 */
+#define cKEYWORD42ARG        "%s"
+#define iKEYWORD42NUMARG 1
+#define iKEYWORD42ARG1NUMVAL 3
+#define cKEYWORD42ARG1VALS "cautious", "goodphysics", "tank"
+/* cautious: exits on any reason 
+ * normal: the usual way: exit only, when the physics would 
+ *         be affected
+ * tank: exits only when all runs are processed. Otherwise
+ *       it goes through everything, even through the pain of 
+ *       a coredump. */
+
+#define cKEYWORD43           "montecarlo"
+/* keyword no. 43 */
+#define cKEYWORD43ARG        "%s"
+#define iKEYWORD43NUMARG 1
+#define iKEYWORD43ARG1NUMVAL 3
+#define cKEYWORD43ARG1VALS "all", "flag", "noflag"
+/* Whenever this one is specified, there shell apply certain 
+ * limitations: No pedestal and calibration files shall be read in. 
+ * Maybe more.... 
+ * Arguments:
+ * all: all events which survive the filter are written to the 
+ *      events NTuple. 
+ * flag: When Dorota's triggerflag is set to 1 for a particular
+ *       event, it shall be written to the output. All others shall
+ *       just be disregarded.
+ * noflag: Opposite of 'flag': only events with triggerflag = 0 shall
+ *         be treated further. */
+
+#define cKEYWORD44           "mcfile"
+/* keyword no. 44 */
+#define cKEYWORD44ARG        "%s"
+#define iKEYWORD44NUMARG 1
+
+#define cKEYWORD45           "fmean_nsb_pe_pix"
+/* keyword no. 45 */
+#define cKEYWORD45ARG             "%s %f"
+#define iKEYWORD45NUMARG 2
+#define fMIN_NSB_PE_PIX  0.
+#define fMAX_NSB_PE_PIX  2000000000. /* some ridiculous number...*/
+
+#define cKEYWORD46           "fitmypedrms"
+/* keyword no. 46 */
+/* Setting this keyword in the parameterfile shall trigger the 
+ * pedestal MEAN and SIGMA=sqrt(MEAN) to be fitted from pickup
+ * corrected pedestal data and not calculated from the pickup 
+ * corrected ADC values, as it was done up to ~November 2000. */
+
+/* Macintosh variable formats */
+#define lMACSIZEOFSHORT  2L
+#define lMACSIZEOFLONG   4L
+#define lMACSIZEOFDOUBLE 8L
+
+/* Time Offsets */
+#define iMACTIMEOFFSET 2082844800 /* offset to be subtracted 
+				   * from the Macintosh time 
+				   * read from the various data 
+				   * files to get DECSTATION/ALPHA 
+				   * time */
+
+/* TIJARAFE filename conventions */
+
+#define cCALFILENAME_TEMPLATE "Te%1sCal_*%s_%2s_*"
+#define cLOGFILENAME_TEMPLATE "Te%1sLog_*%s_%2s_*"
+#define cPEDFILENAME_TEMPLATE "Te%1sPed_*%s_%2s_???????_*"
+#define cRUNFILENAME_TEMPLATE "Te%1sRun_*%s_%2s_*"
+#define cPOIFILENAME_TEMPLATE "Te%1sPoi_*%s_%2s_*"
+#define cCTIDPOSITION_TIJ "2" /* element of the filename character 
+			   * array which contains the telescope id
+			   * a length of 1 character is assumed */
+#define cRUNNUMPOSITION_TIJ "7" /* element of the filename character 
+			     * array which contains the run number */
+#define cRUNNUMLENGTH_TIJ "4" /* number of characters in the run number */
+#define cRUNTYPEPOSITION_TIJ "12" /* element of the filename character 
+			       * array which contains the ON or OF 
+			       * string a length of 2 characters is 
+			       * assumed */
+#define iTIJ_DUMMYLENGTH 20
+
+/* ROBERTO filename conventions */
+
+#define cCTIDPOSITION_ROB "2" /* element of the filename character 
+			       * array which contains the telescope id
+			       * a length of 1 character is assumed */
+#define cRUNNUMPOSITION_ROB "7" /* element of the filename character 
+				 * array which contains the run number */
+#define cRUNNUMLENGTH_ROB "5" /* number of characters in the run number */
+#define cRUNTYPEPOSITION_ROB "13" /* element of the filename character 
+				   * array which contains the ON or OF 
+				   * string a length of 2 characters is 
+				   * assumed */
+#define iROB_DUMMYLENGTH 26
+
+/* Razmick's Method's F Factor for the PMTs: */
+/* #define FIXED_F_VALUE 1.09 */
+/* #define FIXED_F_VALUE 1.15 */
+#define FIXED_F_VALUE 1.075
+
+/* Monte Carlo defines, that _MUST_ be exactly the same as in
+ * zorp's defines.h. */
+#define iMAXNUMCTS 1
+#define iNUMENERGYBINS 19
+#define iNUMIMPACTBINS 60
+#define iNUMZENANGLEBINS 24
+#define iMAXNUMNFLSHIFTS 1
+#define fMAXIMPACTPAR 600.
+
+/* exit codes */
+
+#define iERRORINPROCESSDATA 100
+#define iERRORINMAKEFILENAME 101
+#define iERRORCT2TRACKMODE 102
+#define iERRORGAINZERO 103
+
+/*************** GLOBAL VARIABLES *********************************/
+
+#define FILEHANDLING_VERSION 4.2
+
+#endif
+
+#ifdef _defines_h_
+
+extern char G_cfilehandlingident[];
+extern char G_filehandhfilehident[];
+
+extern char G_cfatalerrortext[22];
+extern Boolean G_bhbook_is_init;
+extern float G_fpreprocversion;
+extern char G_preprocident[];
+extern char G_preprocstrucident[];
+extern char G_preprocfilehident[];
+
+extern char *calnt_var_list[22];
+extern char cprojectname[40];
+
+extern HBOOK_FILE calnt;
+extern HBOOK_FILE calhb;
+extern int G_oferfloweventID;
+extern int G_oferfloweventoffset;
+extern float pixcoords[271][2]; /* For the 2-dim camera pictures of the 
+				 * overflow events */
+#endif
Index: /tags/Mars_V0-8-5/Mars/mfileio/structures_rfl.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfileio/structures_rfl.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfileio/structures_rfl.h	(revision 9661)
@@ -0,0 +1,262 @@
+#ifndef __RFL_HEADER__
+#define __RFL_HEADER__
+
+
+/*  Event header of reflector files ver <= 0.5  */ 
+typedef struct
+{   float	EvtNumber;
+    float	PrimaryID;
+    float	Etotal;   
+    float	Thick0;   
+    float	FirstTarget;
+    float	zFirstInt;
+    float	p[3];     
+    float	Theta; 
+    float	Phi; 
+
+    float	NumRndSeq;
+    float	RndData[10][3];
+  
+    float	RunNumber;
+    float	DateRun;
+    float	Corsika_version;
+
+    float	NumObsLev;  /* Should be 1 for MAGIC simulation */
+    float	HeightLev;  /* Observation Level */
+
+    /* Changed meaning of next 9 variables. June 2002, A.Moralejo: */
+    float       num_mirrors;
+    float       mean_reflectivity;
+    float       longi_Nmax;
+    float       longi_t0;
+    float       longi_tmax;
+    float       longi_a;
+    float       longi_b;
+    float       longi_c;
+    float       longi_chi2;
+
+    float	SlopeSpec;
+    float	ELowLim;   
+    float	EUppLim;   
+
+    float	ThetaMin;
+    float	ThetaMax;
+    float	PhiMin;
+    float	PhiMax;
+
+    float	CWaveLower;       
+    float	CWaveUpper;       
+    float	CorePos[2][20];   
+    float	TimeFirst;
+    float	TimeLast;
+
+    /* AM, 23/05/2002: Changed meaning of following
+     * three variables (which were unused before): 
+     */
+    float	telescopePhi;    /* rad */
+    float	telescopeTheta;  /* rad */
+  
+    float	ViewConeRadius; /* Degrees.
+				 * Radius of "view cone" when the primaries'
+				 * directions generated by Corsika lie within
+				 * a cone around a fixed direction. This is
+				 * only possible with Corsika>6 versions. In
+				 * that case, PhiMin=PhiMax  and 
+				 * ThetaMin=ThetaMax (also in this header) 
+				 * indicate the axis of this cone.   
+				 * If ViewConeRadius==0, it means that
+				 * the VIEWCONE option was not used.
+				 */
+
+
+    float	CORSIKAPhs;	/*  Original photons written by Corsika	*/
+    float	AtmAbsPhs;	/*  Photons absorbed by the atmosphere	*/
+    float	MirrAbsPhs;	/*  Photons absorbed by the mirror	*/
+    float	OutOfMirrPhs;	/*  Photons outside the mirror		*/
+    float	BlackSpotPhs;	/*  Photons lost in the "black spot"	*/
+    float	OutOfChamPhs;	/*  Photons outside the camera		*/
+    float	CPhotons;	/*  Photons reaching the camera         */
+
+}   RflEventHeader_old;
+
+
+/* Reflector files run header (same as CORSIKA's cer files run header): */
+
+typedef struct
+{   char RUNH[4];
+    float RunNumber;
+    float date;
+    float Corsika_version;
+    float NumObsLev;
+    float HeightLev[10];
+    float SlopeSpec;  /* Slope of primaries' energy spectrum */
+    float ELowLim;  
+    float EUppLim;    /* Limits of energy range for generation */
+    float EGS4_flag;
+    float NKG_flag;
+    float Ecutoffh;  
+    float Ecutoffm;  
+    float Ecutoffe;  
+    float Ecutoffg;  
+    /* Physical constants and interaction flags (see CORSIKA manual): */
+    float C[50];
+    float wobble_mode;
+    float atmospheric_model;
+    float dummy1[18]; /* not used */
+    float CKA[40];
+    float CETA[5];
+    float CSTRBA[11];
+    float dummy2[104]; /* not used */
+    float AATM[5];
+    float BATM[5];
+    float CATM[5];
+    float NFL[4];
+
+}   RflRunHeader;
+
+
+/*  Event header of reflector_0.6 files: */ 
+
+typedef struct			
+{   char	EVTH[4];
+    float	EvtNumber;
+    float	PrimaryID;
+    float	Etotal;   
+    float	Thick0;   
+    float	FirstTarget;
+    float	zFirstInt;
+    float	p[3];     
+    float	Theta; 
+    float	Phi; 
+
+    float	NumRndSeq;
+    float	RndData[10][3];
+  
+    float	RunNumber;
+    float	DateRun;
+    float	Corsika_version;
+
+    float	NumObsLev;
+    float	HeightLev[10]; 
+
+    float	SlopeSpec;
+    float	ELowLim;   
+    float	EUppLim;   
+
+    float	Ecutoffh;  
+    float	Ecutoffm;  
+    float	Ecutoffe;  
+    float	Ecutoffg;  
+
+    float	NFLAIN;
+    float	NFLDIF;
+    float	NFLPI0;
+    float	NFLPIF;
+    float	NFLCHE;
+    float	NFRAGM; 
+ 
+    float	Bx;
+    float	By;
+  
+    float	EGS4yn;
+    float	NKGyn;
+    float	GHEISHAyn;
+    float	VENUSyn;
+    float	CERENKOVyn;
+    float	NEUTRINOyn;
+    float	HORIZONTyn;
+    float	COMPUTER;
+
+    float	ThetaMin;
+    float	ThetaMax;
+    float	PhiMin;
+    float	PhiMax;
+
+    float	CBunchSize;
+    float	CDetInX,CDetInY;
+    float	CSpacInX,CSpacInY;
+    float	CLenInX,CLenInY;
+    float	COutput;
+
+    float	AngleNorthX;
+    float	MuonInfo;
+
+    float	StepLength;
+    float	CWaveLower;       
+    float	CWaveUpper;       
+    float	Multipl;       
+    float	CorePos[2][20];   
+    float       SIBYLL[2];
+    float       QGSJET[2];
+    float       DPMJET[2];
+    float       VENUS_cross;
+    float       mu_mult_scat;
+    float       NKG_range;
+    float       EFRCTHN[2];
+    float       WMAX[2];
+    float       rthin_rmax;
+
+    float       viewcone_angles[2]; 
+    /* (degrees) Inner and outer angles in 
+     * Corsika's VIEWCONE option. This is
+     * only possible with Corsika>6 versions. In
+     * that case, PhiMin=PhiMax  and 
+     * ThetaMin=ThetaMax (also in this header) 
+     * indicate the axis of this cone.   
+     */
+
+    /* ^^^ Up to here, the info from the CORSIKA event header. */
+
+    /* Telescope orientation: */
+    float	telescopePhi;    /* rad */
+    float	telescopeTheta;  /* rad */
+
+    /* Time of first and last photon: */
+    float	TimeFirst;
+    float	TimeLast;
+
+    /* 6 parameters and chi2 of the NKG fit to the longitudinal 
+     * particle distribution (see CORSIKA manual for explanation): 
+     */
+    float       longi_Nmax;
+    float       longi_t0;
+    float       longi_tmax;
+    float       longi_a;
+    float       longi_b;
+    float       longi_c;
+    float       longi_chi2;
+
+    /* Now the photon statistics of the event: */
+    float	CORSIKAPhs;	/*  Original photons written by Corsika	*/
+    float	AtmAbsPhs;	/*  Photons absorbed by the atmosphere	*/
+    float	MirrAbsPhs;	/*  Photons absorbed by the mirror	*/
+    float	OutOfMirrPhs;	/*  Photons outside the mirror		*/
+    float	BlackSpotPhs;	/*  Photons lost in the "black spot"	*/
+    float	OutOfChamPhs;	/*  Photons outside the camera		*/
+    float	CPhotons;	/*  Photons reaching the camera         */
+ 
+    /* Now follow the fraction of photons reaching the camera produced by
+     * electrons, muons and other particles respectively: 
+     */ 
+    float       elec_cph_fraction;
+    float       muon_cph_fraction;
+    float       other_cph_fraction;
+
+    float       dummy[7];      /* not used */
+}   RflEventHeader;
+
+/*Photons data estructure*/
+typedef struct
+{   float w,                    /*  cphoton wavelength (nm)             */
+      x, y,			/*  (camera) imp. point (cm)            */
+      u, v,			/*  direction cosines                   */
+      t,			/*  arrival time (ns)                   */
+      h,			/*  production height (cm)              */
+      phi;			/*  (camera) inc. angle (rad)           */
+    }   cphoton;
+
+#endif
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mfilter/FilterIncl.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfilter/FilterIncl.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfilter/FilterIncl.h	(revision 9661)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-8-5/Mars/mfilter/FilterLinkDef.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfilter/FilterLinkDef.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfilter/FilterLinkDef.h	(revision 9661)
@@ -0,0 +1,24 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class MFAlpha+;
+#pragma link C++ class MFTriggerLvl1+;
+#pragma link C++ class MFTriggerLvl2+;
+#pragma link C++ class MFGeomag+;
+#pragma link C++ class MFParticleId+;
+
+#pragma link C++ class MFCT1SelBasic+;
+#pragma link C++ class MFCT1SelStandard+;
+#pragma link C++ class MFCT1SelFinal+;
+#pragma link C++ class MFSelBasic+;
+#pragma link C++ class MFSelStandard+;
+#pragma link C++ class MFSelFinal+;
+#pragma link C++ class MFSoftwareTrigger+;
+#pragma link C++ class MFCosmics+;
+
+#pragma link C++ class MFEnergySlope+;
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mfilter/MFAlpha.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfilter/MFAlpha.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfilter/MFAlpha.cc	(revision 9661)
@@ -0,0 +1,129 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  01/2002 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//   MFAlpha                                                               //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MFAlpha.h"
+
+#include <math.h>
+#include <fstream>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MHillasSrc.h"
+
+ClassImp(MFAlpha);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+MFAlpha::MFAlpha(const char *cname, const char type, const Float_t val,
+                 const char *name, const char *title) : fHillas(NULL)
+{
+    fContName = cname;
+    Init(type, val, name, title);
+}
+
+// --------------------------------------------------------------------------
+//
+MFAlpha::MFAlpha(MHillasSrc *hillas, const char type, const Float_t val,
+                 const char *name, const char *title) : fHillas(hillas)
+{
+    Init(type, val, name, title);
+}
+
+// --------------------------------------------------------------------------
+//
+void MFAlpha::Init(const char type, const Float_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));
+}
+
+// --------------------------------------------------------------------------
+//
+Int_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;
+}
+
+// --------------------------------------------------------------------------
+//
+Int_t MFAlpha::Process()
+{
+    const Float_t alpha = fabs(fHillas->GetAlpha());
+
+    switch (fFilterType)
+    {
+    case kELowerThan:
+        fResult = (alpha < fValue);
+        break;
+    case kEGreaterThan:
+        fResult = (alpha > fValue);
+        break;
+    }
+
+    return kTRUE;
+}
+
+void MFAlpha::StreamPrimitive(ofstream &out) const
+{
+    if (fHillas)
+        fHillas->SavePrimitive(out);
+
+    out << "   MFParticleId " << GetUniqueName() << "(";
+
+    if (fHillas)
+        out << "&" << fHillas->GetUniqueName();
+    else
+        out << "\"" << fContName << "\"";
+
+    out << ", '" << (fFilterType==kELowerThan?"<":">") << "', " << fValue << ");" << endl;
+
+}
Index: /tags/Mars_V0-8-5/Mars/mfilter/MFAlpha.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfilter/MFAlpha.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfilter/MFAlpha.h	(revision 9661)
@@ -0,0 +1,48 @@
+#ifndef MARS_MFAlpha
+#define MARS_MFAlpha
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MFAlpha                                                                 //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MFilter
+#include "MFilter.h"
+#endif
+
+class MParList;
+class MHillasSrc;
+
+class MFAlpha : public MFilter
+{
+private:
+    MHillasSrc *fHillas;
+    TString fContName;
+
+    typedef enum { kELowerThan, kEGreaterThan } FilterType_t;
+    FilterType_t fFilterType;
+
+    Bool_t  fResult; //!
+    Float_t fValue; // [deg]
+
+    void Init(const char type, const Float_t val,
+              const char *name, const char *title);
+
+    void StreamPrimitive(ofstream &out) const;
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
+public:
+    MFAlpha(const char *cname="MHillas", const char type='>', const Float_t deg=15,
+            const char *name=NULL, const char *title=NULL);
+    MFAlpha(MHillasSrc *hillas, const char type='>', const Float_t deg=15,
+            const char *name=NULL, const char *title=NULL);
+
+    Bool_t IsExpressionTrue() const { return fResult; }
+
+    ClassDef(MFAlpha, 1) // A Filter for cuts in fabs(alpha)
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mfilter/MFCT1SelBasic.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfilter/MFCT1SelBasic.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfilter/MFCT1SelBasic.cc	(revision 9661)
@@ -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): Wolfgang Wittek, 04/2003 <mailto:wittek@mppmu.mpg.de>
+!   Author(s): Thomas Bretz, 04/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MFCT1SelBasic
+//
+//  This is a class to evaluate basic cuts
+//
+//  to be called after the calibration (when the number of photons is
+//               available for all pixels)
+//
+//  The basic cuts are :
+//
+//      remove bad runs
+//      thetamin < theta < thetamax
+//      software trigger fullfilled (with minimum no.of photons = minphotons)
+//
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MFCT1SelBasic.h"
+
+#include "MParList.h"
+
+#include "MMcEvt.hxx"
+
+#include "MCerPhotEvt.h"
+#include "MRawRunHeader.h"
+
+#include "MGeomPix.h"
+#include "MGeomCam.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MFCT1SelBasic);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MFCT1SelBasic::MFCT1SelBasic(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MFCT1SelBasic";
+    fTitle = title ? title : "Filter to evaluate basic cuts";
+
+    // default values of cuts
+    SetCuts(13.0, 0.0, 60.0);
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the cut values
+// 
+//
+void MFCT1SelBasic::SetCuts(Float_t minphotons, 
+                            Float_t thetamin, Float_t thetamax)
+{
+    fMinPhotons = minphotons;
+    fThetaMin   = thetamin;
+    fThetaMax   = thetamax;
+
+    *fLog << inf << "MFCT1SelBasic cut values : fMinPhotons, fThetaMin, fThetaMax = ";
+    *fLog << fMinPhotons <<",  " << fThetaMin << ",  " << fThetaMax << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the pointers
+// 
+//
+Int_t MFCT1SelBasic::PreProcess(MParList *pList)
+{
+    fRawRun = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
+    if (!fRawRun)
+    {
+        *fLog << dbginf << "MRawRunHeader not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
+    if (!fMcEvt)
+    {
+        *fLog << dbginf << "MMcEvt not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
+    if (!fEvt)
+    {
+        *fLog << dbginf << "MCerPhotEvt not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fCam = (MGeomCam*)pList->FindObject("MGeomCam");
+    if (!fCam)
+    {
+        *fLog << dbginf << "MGeomCam (Camera Geometry) missing in Parameter List... aborting." << endl;
+        return kFALSE;
+    }
+
+    memset(fCut, 0, sizeof(fCut));
+
+    return kTRUE;
+}
+
+Int_t MFCT1SelBasic::Set(Int_t rc)
+{
+    fCut[rc]++;
+    fResult=kTRUE;
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Evaluate basic cuts
+// 
+//     bad events    : fResult = kTRUE;
+//     good events   : fResult = kFALSE;
+//
+Int_t MFCT1SelBasic::Process()
+{
+    const Double_t theta = kRad2Deg*fMcEvt->GetTelescopeTheta();
+
+    fResult  = kFALSE;
+
+    // remove bad runs for MC gammas
+    if (fMcEvt->GetEnergy() == 0.0  &&  fMcEvt->GetImpact() == 0.0)
+    {
+      if (fRawRun->GetRunNumber() == 601  ||
+          fRawRun->GetRunNumber() == 613  ||
+          fRawRun->GetRunNumber() == 614    )
+	return Set(1);
+    }
+
+    if (theta<fThetaMin)
+        return Set(2);
+
+    if (theta>fThetaMax)
+        return Set(3);
+
+    if (!SwTrigger())
+        return Set(4);
+
+    fCut[0]++;
+
+    return kTRUE;
+}
+// --------------------------------------------------------------------------
+//
+// Software trigger
+// 
+// require 2 neighboring pixels (which are not in the outermost ring), 
+//                       each having at least 'fMinPhotons' photons
+// 
+// 
+Bool_t MFCT1SelBasic::SwTrigger()
+{
+    const Int_t entries = fEvt->GetNumPixels();
+ 
+    for (Int_t i=0; i<entries; i++)
+    {
+        const MCerPhotPix &pix = (*fEvt)[i];
+
+        const Int_t id = pix.GetPixId();
+        if (!pix.IsPixelUsed())
+            continue;
+
+        const Double_t photons = pix.GetNumPhotons();
+        if (photons < fMinPhotons)
+            continue;
+
+        // this pixel is used and has the required no.of photons
+        // check whether this is also true for a neigboring pixel
+
+        const MGeomPix &gpix = (*fCam)[id];
+        if ( gpix.IsInOutermostRing() )
+            continue;
+
+        const Int_t nneighbors = gpix.GetNumNeighbors();
+        for (Int_t n=0; n<nneighbors; n++)
+        {
+            const Int_t id1 =  gpix.GetNeighbor(n);
+            if ( !fEvt->IsPixelUsed(id1) )
+                continue;
+
+            const MGeomPix &gpix1 = (*fCam)[id1];
+            if ( gpix1.IsInOutermostRing() )
+                continue;
+
+            const MCerPhotPix &pix1 = *fEvt->GetPixById(id1);
+
+            const Double_t photons1 = pix1.GetNumPhotons();
+            if (photons1 >= fMinPhotons)
+                return kTRUE;
+        }
+    }
+    return kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Prints some statistics about the Basic selections.
+//
+Int_t MFCT1SelBasic::PostProcess()
+{
+    if (GetNumExecutions()==0)
+        return kTRUE;
+
+    *fLog << inf << endl;
+    *fLog << GetDescriptor() << " execution statistics:" << endl;
+    *fLog << dec << setfill(' ');
+
+    *fLog << " " << setw(7) << fCut[1] << " (" << setw(3) ;
+    *fLog << (int)(fCut[1]*100/GetNumExecutions()) ;
+    *fLog << "%) Evts skipped due to: bad run " << endl;
+
+    *fLog << " " << setw(7) << fCut[2] << " (" << setw(3) ;
+    *fLog << (int)(fCut[2]*100/GetNumExecutions()) ;
+    *fLog << "%) Evts skipped due to: Zenith angle < " << fThetaMin << endl;
+
+    *fLog << " " << setw(7) << fCut[3] << " (" << setw(3) ;
+    *fLog << (int)(fCut[3]*100/GetNumExecutions()) ;
+    *fLog << "%) Evts skipped due to: Zenith angle > " << fThetaMax << endl;
+
+    *fLog << " " << setw(7) << fCut[4] << " (" << setw(3) ;
+    *fLog << (int)(fCut[4]*100/GetNumExecutions()) ;
+    *fLog << "%) Evts skipped due to: Software trigger not fullfilled" ;
+    *fLog << " (with fMinPhotons = " << fMinPhotons << ")" << endl;
+
+    *fLog << " " << fCut[0] << " (" << (int)(fCut[0]*100/GetNumExecutions()) ;
+    *fLog << "%) Evts survived Basic selections!" << endl;
+    *fLog << endl;
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mfilter/MFCT1SelBasic.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfilter/MFCT1SelBasic.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfilter/MFCT1SelBasic.h	(revision 9661)
@@ -0,0 +1,68 @@
+#ifndef MARS_MFCT1SelBasic
+#define MARS_MFCT1SelBasic
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MFCT1SelBasic                                                           //
+//                                                                         //
+// Class to evaluate basic cuts                                            //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MFilter
+#include "MFilter.h"
+#endif
+
+class MMcEvt;
+class MGeomCam;
+class MCerPhotEvt;
+class MPedestalCam;
+class MRawRunHeader;
+
+class MFCT1SelBasic : public MFilter
+{
+private:
+    const MMcEvt        *fMcEvt;       
+    const MGeomCam      *fCam;      // Camera Geometry 
+    const MCerPhotEvt   *fEvt;      // Cerenkov Photon Event 
+    //const MPedestalCam  *fPed;      // Pedestal information
+    const MRawRunHeader *fRawRun;
+
+    Float_t     fMinPhotons;
+    Float_t     fThetaMin;
+    Float_t     fThetaMax;
+
+    Int_t       fCut[5];
+
+    Bool_t      fResult;
+
+    Int_t Set(Int_t rc);
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
+    Bool_t IsExpressionTrue() const { return fResult; }
+
+    Bool_t SwTrigger();
+
+public:
+    MFCT1SelBasic(const char *name=NULL, const char *title=NULL);
+
+    void SetCuts(Float_t minphotons, Float_t thetamin, Float_t thetamax);
+
+    ClassDef(MFCT1SelBasic, 0)   // Class to evaluate basic cuts
+};
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mfilter/MFCT1SelFinal.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfilter/MFCT1SelFinal.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfilter/MFCT1SelFinal.cc	(revision 9661)
@@ -0,0 +1,193 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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  04/2003 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MFCT1SelFinal
+//
+//  WHAT ARE THE FINAL CUTS?
+//
+//  This is a class to evaluate the Final Cuts
+//  (these cuts define the final sample of gammas;
+//   relevant for the calculation of the effective collection areas)
+//
+//  to be called after the calculation of the hadroness
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MFCT1SelFinal.h"
+
+#include <math.h>
+
+#include "MParList.h"
+
+#include "MMcEvt.hxx"
+
+#include "MCerPhotEvt.h"
+
+#include "MGeomPix.h"
+#include "MGeomCam.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MHillasExt.h"
+#include "MHillasSrc.h"
+#include "MHadronness.h"
+
+ClassImp(MFCT1SelFinal);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MFCT1SelFinal::MFCT1SelFinal(const char *hilsrcname,
+                             const char *name, const char *title)
+    : fHilSrcName(hilsrcname), fHadronnessName("MHadronness")
+{
+    fName  = name  ? name  : "MFCT1SelFinal";
+    fTitle = title ? title : "Class to evaluate the Final Cuts";
+
+    // default values of cuts
+    SetCuts(1.0, 100.0, 10.);
+}
+
+// --------------------------------------------------------------------------
+//
+// Set cut values
+// 
+//
+void MFCT1SelFinal::SetCuts(Float_t hadmax, Float_t alphamax, Float_t distmax) 
+{ 
+    fHadronnessMax =   hadmax;
+    fAlphaMax      = alphamax;
+    fDistMax       =  distmax;
+
+    *fLog << inf << "MFCT1SelFinal cut values : fHadronnessMax, fAlphaMax, fDistMax = ";
+    *fLog << fHadronnessMax << ",  " << fAlphaMax << ",  " << fDistMax <<  endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the pointers
+//
+Int_t MFCT1SelFinal::PreProcess(MParList *pList)
+{
+    fHilSrc = (MHillasSrc*)pList->FindObject(fHilSrcName, "MHillasSrc");
+    if (!fHilSrc)
+    {
+      *fLog << dbginf << "MHillasSrc object " << fHilSrcName << " not found... aborting." << endl;
+      return kFALSE;
+    }
+
+    fHadronness = (MHadronness*)pList->FindObject(fHadronnessName, "MHadronness");
+    if (!fHadronness)
+    {
+      *fLog << dbginf << "MHadronness not found... aborting." << endl;
+      return kFALSE;
+    }
+
+    MGeomCam *cam = (MGeomCam*)pList->FindCreateObj("MGeomCamCT1","MGeomCam");
+    if (!cam)
+    {
+        *fLog << err << "MGeomCam (Camera Geometry) not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fMm2Deg = cam->GetConvMm2Deg();
+
+    memset(fCut, 0, sizeof(fCut));
+
+    return kTRUE;
+}
+
+Int_t MFCT1SelFinal::Set(Int_t rc)
+{
+    fCut[rc]++;
+    fResult=kTRUE;
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Evaluate final cuts
+// 
+// if cuts are fulfilled set fResult = kTRUE
+//
+Int_t MFCT1SelFinal::Process()
+{
+    const Double_t modalpha = fabs( fHilSrc->GetAlpha() );
+    const Double_t h = fHadronness->GetHadronness();
+
+    fResult = kFALSE;
+
+    if (h>fHadronnessMax)
+        return Set(1);
+
+    if (modalpha>fAlphaMax)
+        return Set(2);
+
+    if (fMm2Deg*fHilSrc->GetDist()>fDistMax)
+        return Set(3);
+
+    fCut[0]++;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Prints some statistics about the Final selections.
+//
+Int_t MFCT1SelFinal::PostProcess()
+{
+    if (GetNumExecutions()==0)
+        return kTRUE;
+
+    *fLog << inf << endl;
+    *fLog << GetDescriptor() << " execution statistics:" << endl;
+    *fLog << dec << setfill(' ');
+    *fLog << " " << setw(7) << fCut[1] << " (" << setw(3) ;
+    *fLog << (int)(fCut[1]*100/GetNumExecutions());
+    *fLog << "%) Evts skipped due to: hadronness > "<< fHadronnessMax;
+    *fLog << " (hadronness from '" << fHadronnessName << "')" << endl;
+
+    *fLog << " " << setw(7) << fCut[2] << " (" << setw(3) ;
+    *fLog << (int)(fCut[2]*100/GetNumExecutions());
+    *fLog << "%) Evts skipped due to: |ALPHA| > " << fAlphaMax;
+    *fLog << " [degrees]" << endl;
+
+    *fLog << " " << setw(7) << fCut[3] << " (" << setw(3) ;
+    *fLog << (int)(fCut[3]*100/GetNumExecutions());
+    *fLog << "%) Evts skipped due to: DIST > " << fDistMax;
+    *fLog << " [degrees]" << endl;
+
+    *fLog << " " << fCut[0] << " (" ;
+    *fLog << (int)(fCut[0]*100/GetNumExecutions());
+    *fLog << "%) Evts survived Final selections!" << endl;
+    *fLog << endl;
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mfilter/MFCT1SelFinal.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfilter/MFCT1SelFinal.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfilter/MFCT1SelFinal.h	(revision 9661)
@@ -0,0 +1,70 @@
+#ifndef MARS_MFCT1SelFinal
+#define MARS_MFCT1SelFinal
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MSelFinal                                                               //
+//                                                                         //
+// Class to evaluate final cuts                                            //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MFilter
+#include "MFilter.h"
+#endif
+
+class MHillas;
+class MHillasSrc;
+class MHadronness;
+
+class MFCT1SelFinal : public MFilter
+{
+private:
+    MHillasSrc  *fHilSrc;       
+    MHadronness *fHadronness;       
+
+    TString      fHilName;
+    TString      fHilSrcName;
+    TString      fHadronnessName;
+ 
+    Float_t      fHadronnessMax;
+    Float_t      fAlphaMax;
+    Float_t      fDistMax;
+
+    Double_t     fMm2Deg;   // conversion mm to degrees in camera
+
+    Int_t        fCut[4];
+
+    Bool_t       fResult;
+
+    Int_t Set(Int_t rc);
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
+    Bool_t IsExpressionTrue() const  { return fResult; }
+
+public:
+    MFCT1SelFinal(const char *HilSrcName="MHillasSrc",
+                  const char *name=NULL, const char *title=NULL);
+
+    void SetHadronnessName(const TString name) { fHadronnessName = name; }
+
+    void SetCuts(Float_t hadmax, Float_t alphamax, Float_t distmax); 
+
+    ClassDef(MFCT1SelFinal, 0)   // Class to evaluate final cuts
+};
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mfilter/MFCT1SelStandard.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfilter/MFCT1SelStandard.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfilter/MFCT1SelStandard.cc	(revision 9661)
@@ -0,0 +1,221 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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, 04/2003 <mailto:wittek@mppmu.mpg.de>
+!   Author(s): Thomas Bretz, 04/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MFCT1SelStandard
+//
+//  This is a class to evaluate the Standard Cuts
+//
+//  WHAT ARE THE STANDARD CUTS?                                                                       //
+//
+//  to be called after the calculation of the image parameters
+//               before the g/h separation
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MFCT1SelStandard.h"
+
+#include "MParList.h"
+
+#include "MMcEvt.hxx"
+
+#include "MGeomPix.h"
+#include "MGeomCam.h"
+
+#include "MCerPhotEvt.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MHillas.h"
+#include "MHillasExt.h"
+#include "MHillasSrc.h"
+#include "MNewImagePar.h"
+
+ClassImp(MFCT1SelStandard);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MFCT1SelStandard::MFCT1SelStandard(const char *hilsrcname,
+                                   const char *name, const char *title)
+    : fHilName("MHillas"), fHilSrcName(hilsrcname), fImgParName("MNewImagePar")
+{
+    fName  = name  ? name  : "MFCT1SelStandard";
+    fTitle = title ? title : "Class to evaluate the Standard Cuts";
+
+    // default values of cuts
+    SetCuts(92, 4, 60, 0.4, 1.05, 0.0, 0.0);
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the values for the cuts 
+// 
+//
+void MFCT1SelStandard::SetCuts(Float_t usedpixelsmax, Float_t corepixelsmin,
+                               Float_t sizemin, Float_t distmin, Float_t distmax,
+                               Float_t lengthmin, Float_t widthmin)
+{ 
+    fUsedPixelsMax = usedpixelsmax;
+    fCorePixelsMin = corepixelsmin;
+    fSizeMin       = sizemin;
+    fDistMin       = distmin;
+    fDistMax       = distmax;
+    fLengthMin     = lengthmin;
+    fWidthMin      = widthmin;
+
+    *fLog << inf << "MFCT1SelStandard cut values : fUsedPixelsMax, fCorePixelsMin = ";
+    *fLog << fUsedPixelsMax << ",  " << fCorePixelsMin << endl;
+    *fLog << inf << "     fSizeMin, fDistMin, fDistMax = " << fSizeMin ;
+    *fLog << ",  " << fDistMin << ",  " << fDistMax << endl;
+    *fLog << inf << "     fLengthMin, fWidthMin = " << fLengthMin ;
+    *fLog << ",  " << fWidthMin << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// MISSING
+//
+Int_t MFCT1SelStandard::PreProcess(MParList *pList)
+{
+    fHil = (MHillas*)pList->FindObject(fHilName, "MHillas");
+    if (!fHil)
+    {
+        *fLog << err << fHilName << " [MHillas] not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fHilSrc = (MHillasSrc*)pList->FindObject(fHilSrcName, "MHillasSrc");
+    if (!fHilSrc)
+    {
+        *fLog << err << fHilSrcName << " [MHillasSrc] not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fNewImgPar = (MNewImagePar*)pList->FindObject(fImgParName, "MNewImagePar");
+    if (!fNewImgPar)
+    {
+        *fLog << err << fImgParName << " [MNewImagePar] not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    MGeomCam *cam = (MGeomCam*)pList->FindObject("MGeomCam");
+    if (!cam)
+    {
+        *fLog << err << "MGeomCam (Camera Geometry) not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fMm2Deg = cam->GetConvMm2Deg();
+
+    memset(fCut, 0, sizeof(fCut));
+
+    return kTRUE;
+}
+
+Bool_t MFCT1SelStandard::Set(Int_t rc)
+{
+    fResult = kTRUE;
+    fCut[rc]++;
+    return kTRUE;
+}
+// --------------------------------------------------------------------------
+//
+// Evaluate standard cuts
+// 
+// if selections are fulfilled set fResult = kTRUE;
+// 
+//
+Int_t MFCT1SelStandard::Process()
+{
+    const Double_t length     = fHil->GetLength() * fMm2Deg;
+    const Double_t width      = fHil->GetWidth()  * fMm2Deg;
+    const Double_t dist       = fHilSrc->GetDist()* fMm2Deg;
+    //const Double_t delta      = fHil->GetDelta()  * kRad2Deg;
+    const Double_t size       = fHil->GetSize();
+    const Int_t numusedpixels = fNewImgPar->GetNumUsedPixels();
+    const Int_t numcorepixels = fNewImgPar->GetNumCorePixels();
+
+    fResult  = kFALSE;
+
+    if (numusedpixels>=fUsedPixelsMax || numcorepixels<=fCorePixelsMin)
+        return Set(1);
+
+    if (size<=fSizeMin )
+        return Set(2);
+
+    if (dist<fDistMin || dist>fDistMax)
+        return Set(3);
+
+    if (length<=fLengthMin || width<=fWidthMin)
+        return Set(4);
+
+    fCut[0]++;
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Prints some statistics about the Standard selections.
+//
+Int_t MFCT1SelStandard::PostProcess()
+{
+    if (GetNumExecutions()==0)
+        return kTRUE;
+
+    *fLog << inf << endl;
+    *fLog << GetDescriptor() << " execution statistics:" << endl;
+    *fLog << dec << setfill(' ');
+    *fLog << " " << setw(7) << fCut[1] << " (" << setw(3);
+    *fLog << (int)(fCut[1]*100/GetNumExecutions()) ;
+    *fLog << "%) Evts skipped due to: Used pixels >= " << fUsedPixelsMax ;
+    *fLog << " or Core pixels <= " << fCorePixelsMin << endl;
+
+    *fLog << " " << setw(7) << fCut[2] << " (" << setw(3) ;
+    *fLog << (int)(fCut[2]*100/GetNumExecutions()) ;
+    *fLog << "%) Evts skipped due to: SIZE <= " << fSizeMin << endl;
+
+    *fLog << " " << setw(7) << fCut[3] << " (" << setw(3) ;
+    *fLog << (int)(fCut[3]*100/GetNumExecutions()) ;
+    *fLog << "%) Evts skipped due to: DIST < " << fDistMin;
+    *fLog << " or DIST > " << fDistMax << endl;
+
+    *fLog << " " << setw(7) << fCut[4] << " (" << setw(3) ;
+    *fLog << (int)(fCut[4]*100/GetNumExecutions()) ;
+    *fLog << "%) Evts skipped due to: LENGTH <= " << fLengthMin;
+    *fLog << " or WIDTH <= " << fWidthMin << endl;
+
+    *fLog << " " << fCut[0] << " (" ;
+    *fLog << (int)(fCut[0]*100/GetNumExecutions()) ;
+    *fLog << "%) Evts survived Standard selections!" << endl;
+    *fLog << endl;
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mfilter/MFCT1SelStandard.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfilter/MFCT1SelStandard.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfilter/MFCT1SelStandard.h	(revision 9661)
@@ -0,0 +1,78 @@
+#ifndef MARS_MFCT1SelStandard
+#define MARS_MFCT1SelStandard
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MFCT1SelStandard                                                        //
+//                                                                         //
+// Class to evaluate standard cuts                                         //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MFilter
+#include "MFilter.h"
+#endif
+
+class MHillas;
+class MHillasSrc;
+class MNewImagePar;
+
+class MFCT1SelStandard : public MFilter
+{
+private:
+    MHillas      *fHil;
+    MHillasSrc   *fHilSrc;
+    MNewImagePar *fNewImgPar;
+
+    TString      fHilName;
+    TString      fHilSrcName;
+    TString      fImgParName;
+
+    Float_t      fUsedPixelsMax;
+    Float_t      fCorePixelsMin;
+    Float_t      fSizeMin;
+    Float_t      fDistMin;
+    Float_t      fDistMax;
+    Float_t      fLengthMin;
+    Float_t      fWidthMin;
+
+    Double_t     fMm2Deg;    // conversion mm to degrees in camera
+
+    Int_t        fCut[5];
+
+    Bool_t       fResult;
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
+    Bool_t IsExpressionTrue() const  { return fResult; }
+
+    Bool_t Set(Int_t rc);
+
+public:
+    MFCT1SelStandard(const char *HilSrcName="MHillasSrc",
+                     const char *name=NULL, const char *title=NULL);
+
+    void SetHillasName(const char *name) { fHilName = name; }
+    void SetImgParName(const char *name) { fImgParName = name; }
+
+    void SetCuts(Float_t usedpixelsmax, Float_t corepixelsmin,
+                 Float_t sizemin, Float_t distmin, Float_t distmax,
+                 Float_t lengthmin, Float_t widthmin);
+
+    ClassDef(MFCT1SelStandard, 0)   // Class to evaluate standard cuts
+};
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mfilter/MFCosmics.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfilter/MFCosmics.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfilter/MFCosmics.cc	(revision 9661)
@@ -0,0 +1,206 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug  02/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//   MFCosmics
+//
+//   Filter to reject cosmics by the criterion that at least 
+//   fMaxEmptyPixels of the pixels have values of lower than 3 Pedestal RMS. 
+//   fMaxEmptyPixels is set to 0.4 by default which is slightly higher 
+//   than the number of outer pixels in MAGIC (for the case that 
+//   the outer pixels have some defect).
+//
+//  Input Containers:
+//   MRawEvtData
+//   MPedestalCam
+//   MExtractedSignalCam
+//
+//  Output Containers:
+//   -/-
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MFCosmics.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MGeomCam.h"
+#include "MRawEvtPixelIter.h"
+
+#include "MPedestalCam.h"
+#include "MPedestalPix.h"
+
+#include "MExtractedSignalCam.h"
+#include "MExtractedSignalPix.h"
+
+ClassImp(MFCosmics);
+
+using namespace std;
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+MFCosmics::MFCosmics(const char *name, const char *title)
+    : fPedestals(NULL), fSignals(NULL),
+      fRawEvt(NULL), fMaxEmptyPixels(0.2)
+{
+    fName  = name  ? name  : "MFCosmics";
+    fTitle = title ? title : "Filter to reject cosmics";
+}
+
+// --------------------------------------------------------------------------
+//
+// The PreProcess searches for the following input containers:
+//  - MRawEvtData
+//  - MPedestalCam
+//  - MExtractedSignalCam
+//
+Int_t MFCosmics::PreProcess(MParList *pList)
+{
+    fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
+    if (!fRawEvt)
+    {
+      *fLog << err << "MRawEvtData not found... aborting." << endl;
+      return kFALSE;
+    }
+
+    fPedestals = (MPedestalCam*)pList->FindObject("MPedestalCam");
+    if (!fPedestals)
+    {
+        *fLog << err << "MPedestalCam not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fSignals = (MExtractedSignalCam*)pList->FindObject("MExtractedSignalCam");
+    if (!fSignals)
+    {
+        *fLog << err << "MExtractedSignalCam not found... aborting." << endl;
+        return kFALSE;
+    }
+
+
+    memset(fCut, 0, sizeof(fCut));
+    
+    return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Initialize number of used FADC slices
+//
+Bool_t MFCosmics::ReInit(MParList *pList)
+{
+    fSqrtHiGainSamples = TMath::Sqrt((Float_t) fSignals->GetNumUsedHiGainFADCSlices());
+
+    return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Retrieve the integral of the FADC time slices and compare them to the 
+// pedestal values.
+//
+Int_t MFCosmics::Process()
+{
+    fResult = CosmicsRejection();
+
+    fCut[fResult ? 0 : 1]++;
+    return kTRUE;
+}
+
+// ---------------------------------------------------------
+//
+// Cosmics rejection: 
+// 
+// Requiring less than fMaxEmptyPixels pixels to have values 
+// lower than 3 Pedestal RMS. 
+// 
+// fMaxEmptyPixels is set to 230 by default which is slightly higher 
+// than the number of outer pixels in MAGIC (for the case that 
+// the outer pixels have some defect).
+//
+Bool_t MFCosmics::CosmicsRejection() const
+{
+    MRawEvtPixelIter pixel(fRawEvt);
+
+    Int_t cosmicpix = 0;
+    Int_t allpix    = 0;
+
+    //
+    // Create a first loop to sort out the cosmics ...
+    //
+    while (pixel.Next())
+    {
+        const UInt_t idx = pixel.GetPixelId();
+
+        MExtractedSignalPix &sig =  (*fSignals)[idx];
+        MPedestalPix        &ped =  (*fPedestals)[idx];
+
+        const Float_t pedrms = ped.GetPedestalRms()*fSqrtHiGainSamples;
+        const Float_t sumhi  = sig.GetExtractedSignalHiGain();
+
+	allpix++;
+
+        //
+        // We consider a pixel as presumably due to cosmics
+        // if its sum of FADC slices is lower than 3 pedestal RMS
+        //
+        if (sumhi < 3.*pedrms )
+            cosmicpix++;
+    }
+
+    //
+    // If the camera contains more than fMaxEmptyPixels
+    // presumed pixels due to cosmics, then the event is discarted.
+    //
+    return cosmicpix > fMaxEmptyPixels*allpix;
+}
+
+Int_t MFCosmics::PostProcess()
+{
+    if (GetNumExecutions()==0)
+        return kTRUE;
+
+    *fLog << inf << endl;
+    *fLog << GetDescriptor() << " execution statistics:" << endl;
+    *fLog << dec << setfill(' ');
+
+    *fLog << " " << setw(7) << fCut[0] << " (" << setw(3) ;
+    *fLog << (int)(fCut[0]*100/GetNumExecutions()) ;
+    *fLog << "%) Detected cosmics " ;
+    *fLog << " (with fMaxEmptyPixels = " << fMaxEmptyPixels*100 << "%)" << endl;
+
+    *fLog << " " << setw(7) << fCut[1] << " (" << setw(3) ;
+    *fLog << (int)(fCut[1]*100/GetNumExecutions()) ;
+    *fLog << "%) No cosmics!" << endl;
+    *fLog << endl;
+
+    return kTRUE;
+}
+
Index: /tags/Mars_V0-8-5/Mars/mfilter/MFCosmics.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfilter/MFCosmics.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfilter/MFCosmics.h	(revision 9661)
@@ -0,0 +1,48 @@
+#ifndef MARS_MFCosmics
+#define MARS_MFCosmics
+
+#ifndef MARS_MFilter
+#include "MFilter.h"
+#endif
+
+class MRawEvtData;
+
+class MPedestalCam;
+class MExtractedSignalCam;
+
+class MFCosmics : public MFilter
+{
+private:
+    MPedestalCam        *fPedestals; // Pedestals of all pixels in the camera
+    MExtractedSignalCam *fSignals;   // Calibration events of all pixels in the camera
+
+    MRawEvtData         *fRawEvt;    // raw event data (time slices)
+
+    Int_t   fCut[2];
+    Bool_t  fResult;
+
+    Float_t fMaxEmptyPixels;         // Maximum number of empty pixels before declaring event as cosmic
+    Float_t fSqrtHiGainSamples;      // Square root of the number of used Hi-Gain Samples
+
+    Bool_t ReInit(MParList *pList);
+    Int_t  PreProcess(MParList *pList);
+    Int_t  Process();
+    Int_t  PostProcess();
+
+    Bool_t CosmicsRejection() const;
+
+    Bool_t IsExpressionTrue() const { return fResult; }
+  
+public:
+    MFCosmics(const char *name=NULL, const char *title=NULL);
+
+    void    SetMaxEmptyPixels(const Float_t n) { fMaxEmptyPixels = n;    }
+    Float_t GetMaxEmptyPixels() const          { return fMaxEmptyPixels; }
+
+    ClassDef(MFCosmics, 0)   // Filter to perform a cosmics rejection
+};
+
+#endif
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mfilter/MFEnergySlope.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfilter/MFEnergySlope.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfilter/MFEnergySlope.cc	(revision 9661)
@@ -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): Antonio Stamerra  02/2003 <mailto:antonio.stamerra@pi.infn.it>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//   MFEnergySlope                                                         //
+//                                                                         //
+//  A filter to select MC events (generated with a energy slope MCSlope)   //
+//   with a different energy slope NewSlope set by the user.               //
+//                                                                         //
+//  The new slope is set by the user with SetSlope().                      //
+//  Only negative slopes are admitted; positive ones are internally        //
+//   converted.                                                            //
+//  Events are selected following the new energy power slope, and the      //
+//   sample is normalized to the number of events at:                      //
+//    1. McMaxEnergy, if abs(NewSlope) < abs(McSlope);                     //
+//    2. McMinEnergy, if abs(NewSlope) > abs(McSlope);                     //
+//   Mc{Max,Min}Energy are set with SetMcMinEnergy() and SetMcMaxEnergy(); //
+//    with GeV values.                                                     //
+//  Default values are the min/max energy of the MC sample.                //
+//                                                                         //
+//  With this filter the statistics of the MC sample is reduced.           //
+//  camera ver.0.6 and reflector ver.0.6 are required to fetch             //
+//   the correct MC information                                            //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MFEnergySlope.h"
+
+#include <fstream>
+#include <TRandom.h>
+
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MMcEvt.hxx"
+#include "MMcCorsikaRunHeader.h"
+
+ClassImp(MFEnergySlope);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+//     Constructor
+//
+MFEnergySlope::MFEnergySlope(const char *name, const char *title):
+  fNumSelectedEvts(0), fNewSlope(-1), fMcMinEnergy(-1.), fMcMaxEnergy(-1.)
+{
+  //    fContName = cname;
+  fName  = name  ? name  : "MFEnergySlope";
+  fTitle = title ? title : "Filter to select energy with given slope";
+}
+
+// --------------------------------------------------------------------------
+//
+//   Preprocess
+//  
+//  MC slope and min/max energy are read
+//  Normalization factor is computed
+//
+Int_t MFEnergySlope::PreProcess(MParList *pList)
+{
+ 
+    MMcCorsikaRunHeader *runheader = (MMcCorsikaRunHeader*)pList->FindObject("MMcCorsikaRunHeader");
+
+    if (!runheader)
+      {
+	*fLog << err << dbginf << fName << " [MMcCorsikaRunHeader] not found... aborting." << endl;
+	return kFALSE;
+      }
+    //
+    // Read info from the MC sample (it must be generated with 
+    //   reflector ver.0.6 and camera ver. 0.6)
+    //
+    fMcSlope = runheader->GetSlopeSpec();    
+    if (fMcMinEnergy<0)
+      fMcMinEnergy = runheader->GetELowLim();
+    if (fMcMinEnergy<0)
+      fMcMaxEnergy = runheader->GetEUppLim();
+
+    *fLog << inf;
+    *fLog << "MFEnergySlope::PreProcess: fetched MC info:" << endl;
+    *fLog << "  E Slope:     " << fMcSlope << endl;
+    *fLog << "  E Min:       " << fMcMinEnergy << endl;
+    *fLog << "  E Max:       " << fMcMaxEnergy << endl;
+    *fLog << "  New E Slope: " << fNewSlope << endl;
+    
+    // Slope is used with positive values in the code
+    if (fNewSlope < 0)
+      fNewSlope *= -1; 
+    if (fMcSlope < 0)
+      fMcSlope *= -1;
+
+
+  // Set normalization on energy  
+    fN0 = pow(fNewSlope>fMcSlope?fMcMinEnergy:fMcMaxEnergy,fNewSlope-fMcSlope);
+
+  *fLog << "Normalization factor:" <<fN0 << endl;
+
+  //---
+    fEvt = (MMcEvt*)pList->FindObject("MMcEvt");
+    if (!fEvt)
+      {
+	*fLog << err << dbginf << fName << " [MMcEvt] not found... aborting." << endl;
+        return kFALSE;
+      }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//  
+//  Select events randomly according to the MC ("old") and required ("new") 
+//    energy slope.
+//  Old E slope is fMcSlope
+//  New E slope is set by the user (fval; fNewSlope)
+//  If old and new energy slope are the same skip the selection. 
+//  The MC energy slope and lower and upper limits are taken from the
+//  run header (requires reflector ver.>0.6 and camera ver.>0.6) 
+//
+Int_t MFEnergySlope::Process()
+{
+  fResult = kTRUE;
+
+  // Energy slopes are the same: skip it
+  if (fNewSlope == fMcSlope)
+    return kTRUE;
+  
+  //  The value of the normalized spectrum is compared with a 
+  //   random value in [0,1]; 
+  //   if the latter is higher the event is accepted
+  const Float_t energy = fEvt->GetEnergy();
+
+  /*
+  //
+  // If energy bounds different from MC ones are selected, then
+  // events outside these bounds are rejected, as their slope has
+  // not been changed.
+  //
+  if (energy > fMcMaxEnergy || energy < fMcMinEnergy)
+    {
+      fResult = kFALSE;
+      return kTRUE;
+    }
+  */
+
+  const Float_t Nexp = fN0 * pow(energy,fMcSlope-fNewSlope);
+  const Float_t Nrnd = gRandom->Uniform();
+
+  fResult = Nexp > Nrnd;
+
+  if (!fResult)
+      return kTRUE;
+
+  fNumSelectedEvts++;
+  return kTRUE;
+}
+
Index: /tags/Mars_V0-8-5/Mars/mfilter/MFEnergySlope.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfilter/MFEnergySlope.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfilter/MFEnergySlope.h	(revision 9661)
@@ -0,0 +1,57 @@
+#ifndef MARS_MFEnergySlope
+#define MARS_MFEnergySlope
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MFEnergySlope                                                           //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MFilter
+#include "MFilter.h"
+#endif
+
+class MParList;
+class MMcEvt;
+class MMcCorsikaRunHeader;
+
+class MFEnergySlope : public MFilter
+{
+private:
+    Int_t fNumSelectedEvts; // counter for number of selected events
+
+    MMcEvt *fEvt;           // Events used to determin energy slope
+
+    Bool_t fResult;         // Result returned by IsExpressionTrue
+    Float_t fNewSlope;      // New slope set by user
+
+    Float_t fMcSlope;       // Original energy slope from MC data
+    Float_t fMcMinEnergy;   // Starting energy of MC data
+    Float_t fMcMaxEnergy;   // Ending energy of MC data
+
+    Float_t fN0;            // Normalization factor
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
+public:
+    MFEnergySlope(const char *name=NULL, const char *title=NULL);
+
+    Bool_t IsExpressionTrue() const { return fResult; }
+
+    // Slope is used with positive values in the code 
+    void SetNewSlope(Float_t f) {fNewSlope = TMath::Abs(f);}
+    void SetMcSlope(Float_t f) {fMcSlope = TMath::Abs(f);}
+
+    void SetMcMinEnergy(Float_t f) {fMcMinEnergy = f;}
+    void SetMcMaxEnergy(Float_t f) {fMcMaxEnergy = f;}
+
+    ClassDef(MFEnergySlope, 0) // A Filter to select events with a given energy slope
+};
+
+#endif
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mfilter/MFGeomag.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfilter/MFGeomag.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfilter/MFGeomag.cc	(revision 9661)
@@ -0,0 +1,207 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): R.K.Bock 11/2003 <mailto:rkb@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//   MFGeomag
+//
+//  A filter to reject Monte Carlo events based on phi/theta/charge of the
+//  incident particle. Uses tables calculated by Adrian Biland, which contain
+//  three parameters, used with rigidity (= particle momentum / charge) :
+//         rig < min_rig:   reject unconditionally
+//         rig > max_rig:   accept unconditionally
+//         rig in between:  reject it with 'probability'
+//  the two tables, for + and - rigidity, are stored in ASCII form in mfilter/
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MFGeomag.h"
+
+#include <fstream>        //for ifstream
+
+#include <TRandom.h>      //for gRandom
+#include <TSystem.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MMcEvt.hxx"
+
+ClassImp(MFGeomag);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+MFGeomag::MFGeomag(const char *name, const char *title) : fMcEvt(NULL)
+{
+    fName  = name  ? name  : "MFGeomag";
+    fTitle = title ? title : "Filter using geomagnetic field";
+
+    fGammaElectron = kFALSE;  // logical variable, will not take gammas as electrons (default)
+
+    AddToBranchList("MMcEvt.fPartId");
+}
+
+// --------------------------------------------------------------------------
+//
+Int_t MFGeomag::PreProcess(MParList *pList)
+{
+    //  reading of tables (variables defined as 'private')
+    TString marssys(gSystem->Getenv("MARSSYS"));
+    if (!marssys.IsNull() && !marssys.EndsWith("/"))
+        marssys += "/";
+
+    //
+    // Read gcminus.txt
+    //
+    TString filename(marssys);
+    filename += "mfilter/gcplus.txt";
+
+    ifstream geomagp(filename);
+
+    if (!geomagp)
+    {
+        *fLog << err << "ERROR - file " << filename << " not found." << endl;
+        return kFALSE;
+    }
+    for (int i=0; i<1152; i++)
+    {
+        Float_t dummy;
+        geomagp >> dummy >> dummy >> fRigMin[i] >> fRigMax[i] >> fProb[i];
+    }
+    *fLog << inf << endl;
+    *fLog << "gcplus.txt - first line: ";
+    *fLog << Form ("FRigMin=%8f  fRigMax=%8f  fProb=%8f",
+                   fRigMin[0], fRigMax[0], fProb[0]) << endl;
+
+    //
+    // Read gcminus.txt
+    //
+    filename = marssys;
+    filename += "mfilter/gcminus.txt";
+
+    ifstream geomagm(filename);
+    if (!geomagm)
+    {
+        *fLog << err << "ERROR - file " << filename << " not found." << endl;
+        return kFALSE;
+    }
+    for (int i=1152; i<2304; i++)
+    {
+        Float_t dummy;
+        geomagm >> dummy >> dummy >> fRigMin[i] >> fRigMax[i] >> fProb[i];
+    }
+    *fLog << "gcminus.txt - first line: ";
+    *fLog << Form ("fRigMin=%8f  fRigMax=%8f  fProb=%8f",
+                   fRigMin[1152], fRigMax[1152], fProb[1152]) << endl;
+
+    //
+    if (fMcEvt)
+        return kTRUE;
+
+    fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
+    if (!fMcEvt)
+    {
+        *fLog << err << "MMcEvt not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    return kTRUE;
+}
+// --------------------------------------------------------------------------
+//
+void MFGeomag::SetGammElec()
+{
+    fGammaElectron = kTRUE;  // logical variable, will take gammas as electrons
+    *fLog <<" MFGeomag called to treat gammas as electrons" << endl;
+    return;
+}
+
+// --------------------------------------------------------------------------
+//
+Int_t MFGeomag::Process()
+{
+    fResult = kFALSE;
+
+    const Float_t en =  fMcEvt->GetEnergy();       // for rigidity (set P = E)
+    Float_t rig = en;
+    const Float_t az =  fMcEvt->GetTelescopePhi(); // charge theta phi are entries in table
+    const Float_t th =  fMcEvt->GetTelescopeTheta();
+
+    Int_t indadd=0;              //first part of table (positive particles)
+    switch (fMcEvt->GetPartId())
+    {
+    case MMcEvt::kGAMMA:
+        if (!fGammaElectron)     //accept gammas if not set to electrons
+            return kTRUE;
+        indadd = 1152;           //second part of table (negative particles)
+        break;
+
+    case MMcEvt::kHELIUM:
+        rig /= 2;                //double charge
+        break;
+
+    case MMcEvt::kPROTON:                //protons
+    case MMcEvt::kPOSITRON:              //positrons
+        break;
+
+    case MMcEvt::kELECTRON:              //electrons
+        indadd = 1152;           //second part of table (negative particles)
+        break;
+
+    default:
+        *fLog << err << " Unknown Monte Carlo Particle Id#: "<< fMcEvt->GetPartId() << endl;
+        return kFALSE;
+    }
+
+    // here is the cut for charged particles using the table
+
+    int it=(int)(th*11.459156);    // table steps are in 5 deg = 1/11.459 rads
+    int ia=(int)(az*11.459156);
+
+    ia = (ia+36) % 72;             // azimuth definitions differ by 180 deg
+
+    const Float_t r1=fRigMin[72*it+ia+indadd];
+    if (rig<=r1)
+    {
+        fResult=kTRUE;   // reject
+        return kTRUE;
+    }
+
+    const Float_t r2=fRigMax[72*it+ia+indadd];
+    if (rig>=r2)
+        return kTRUE;   // accept
+
+    const Float_t pr=fProb[72*it+ia+indadd];
+
+    // accept if above intermediate threshold
+    const Float_t rnd = (r2-r1)/2 * gRandom->Rndm(0);
+
+    if ((rig-r1)*pr < rnd)
+        fResult = kTRUE;                // pretty good approximation
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mfilter/MFGeomag.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfilter/MFGeomag.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfilter/MFGeomag.h	(revision 9661)
@@ -0,0 +1,35 @@
+#ifndef MARS_MFGeomag
+#define MARS_MFGeomag
+
+#ifndef MARS_MFilter
+#include "MFilter.h"
+#endif
+
+class MMcEvt;
+class MParList;
+
+class MFGeomag : public MFilter
+{
+private:
+    MMcEvt *fMcEvt;
+
+    Bool_t fResult;    //!
+    Bool_t fGammaElectron;  // switches gammas to electrons
+
+    Float_t fRigMin[2*1152];    //tables to contain cut limits
+    Float_t fRigMax[2*1152];
+    Float_t fProb  [2*1152];
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
+public:
+    MFGeomag(const char *name=NULL, const char *title=NULL);
+
+    void  SetGammElec();    // allows to use gammas like electrons
+    Bool_t IsExpressionTrue() const { return fResult; }
+
+    ClassDef(MFGeomag,0) // Filter for MC particles, by geomagnetic field
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mfilter/MFParticleId.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfilter/MFParticleId.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfilter/MFParticleId.cc	(revision 9661)
@@ -0,0 +1,153 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  07/2001 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//   MFParticleId
+//
+//  A filter to choose between different particle types, identified by
+//  their monte carlo particle type. For a list of idetifiers see
+//  mmc/MMcEvt.h
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MFParticleId.h"
+
+#include <fstream>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MMcEvt.hxx"
+
+ClassImp(MFParticleId);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+MFParticleId::MFParticleId(const char *cname, const char type, const Int_t val,
+                           const char *name, const char *title) : fMcEvt(NULL)
+{
+    fContName = cname;
+    Init(type, val, name, title);
+}
+
+// --------------------------------------------------------------------------
+//
+MFParticleId::MFParticleId(MMcEvt *mcevt, const char type, const Int_t val,
+                           const char *name, const char *title) : fMcEvt(mcevt)
+{
+    Init(type, val, name, title);
+}
+
+// --------------------------------------------------------------------------
+//
+void MFParticleId::Init(const char type, const Int_t val,
+                        const char *name, const char *title)
+{
+    fName  = name  ? name  : "MFParticleId";
+    fTitle = title ? title : "Filter using monte carlo particle id";
+
+    fFilterType = (type=='=' ? kEEqual : kENotEqual);
+
+    if (type!='=' && type!='!')
+        *fLog << warn << dbginf << "Warning: Neither '=' nor '!' specified... using '>'." << endl;
+
+    fValue = val;
+
+    AddToBranchList(Form("%s.fPartId", (const char*)fContName));
+}
+
+// --------------------------------------------------------------------------
+//
+Bool_t MFParticleId::IsExpressionTrue() const
+{
+    return fResult;
+}
+
+// --------------------------------------------------------------------------
+//
+Int_t MFParticleId::PreProcess(MParList *pList)
+{
+    if (fMcEvt)
+        return kTRUE;
+
+    fMcEvt = (MMcEvt*)pList->FindObject(fContName);
+    if (fMcEvt)
+        return kTRUE;
+
+    *fLog << err << dbginf << fContName << " [MMcEvt] not found... aborting." << endl;
+    return kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+Int_t MFParticleId::Process()
+{
+    const Int_t id = fMcEvt->GetPartId();
+
+    switch (fFilterType)
+    {
+    case kEEqual:
+        fResult = (id == fValue);
+        return kTRUE;
+    case kENotEqual:
+        fResult = (id != fValue);
+        return kTRUE;
+    }
+
+    *fLog << err << dbginf << "Operation unknown..." << endl;
+    return kFALSE;
+}
+
+void MFParticleId::StreamPrimitive(ofstream &out) const
+{
+    if (fMcEvt)
+        fMcEvt->SavePrimitive(out);
+
+    out << "   MFParticleId " << GetUniqueName() << "(";
+
+    if (fMcEvt)
+        out << "&" << fMcEvt->GetUniqueName();
+    else
+        out << "\"" << fContName << "\"";
+
+    out << ", '" << (fFilterType==kEEqual?"=":"!") << "', ";
+
+    switch (fValue)
+    {
+    case MMcEvt::kGAMMA:    out << "MMcEvt::kGAMMA";    break;
+    case MMcEvt::kPOSITRON: out << "MMcEvt::kPOSITRON"; break;
+    case MMcEvt::kELECTRON: out << "MMcEvt::kELECTRON"; break;
+    case MMcEvt::kPROTON:   out << "MMcEvt::kPROTON";   break;
+    case MMcEvt::kHELIUM:   out << "MMcEvt::kHELIUM";   break;
+    case MMcEvt::kOXYGEN:   out << "MMcEvt::kOXYGEN";   break;
+    case MMcEvt::kIRON:     out << "MMcEvt::kIRON";     break;
+    default:
+        out << fValue;
+    }
+    out << ");" << endl;
+}
Index: /tags/Mars_V0-8-5/Mars/mfilter/MFParticleId.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfilter/MFParticleId.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfilter/MFParticleId.h	(revision 9661)
@@ -0,0 +1,48 @@
+#ifndef MARS_MFParticleId
+#define MARS_MFParticleId
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MFParticleId                                                           //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MFilter
+#include "MFilter.h"
+#endif
+
+class MMcEvt;
+class MParList;
+
+class MFParticleId : public MFilter
+{
+private:
+    MMcEvt *fMcEvt;
+    TString fContName;
+
+    typedef enum { kEEqual, kENotEqual } FilterType_t;
+    FilterType_t fFilterType;
+
+    Bool_t fResult;    //!
+    Int_t  fValue;
+
+    void Init(const char type, const Int_t val,
+              const char *name, const char *title);
+
+    void StreamPrimitive(ofstream &out) const;
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
+public:
+    MFParticleId(const char *cname="MMcEvt", const char type='=', const Int_t val=0,
+                 const char *name=NULL, const char *title=NULL);
+    MFParticleId(MMcEvt *mcevt, const char type='=', const Int_t val=0,
+                 const char *name=NULL, const char *title=NULL);
+
+    Bool_t IsExpressionTrue() const;
+
+    ClassDef(MFParticleId, 1) // A Filter for the (corsika) particle Id
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mfilter/MFSelBasic.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfilter/MFSelBasic.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfilter/MFSelBasic.cc	(revision 9661)
@@ -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): Wolfgang Wittek, 04/2003 <mailto:wittek@mppmu.mpg.de>
+!   Author(s): Thomas Bretz, 04/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MFSelBasic
+//
+//  This is a class to evaluate basic cuts
+//
+//  to be called after the calibration (when the number of photons is
+//               available for all pixels)
+//
+//  The basic cuts are :
+//
+//      remove bad runs
+//      thetamin < theta < thetamax
+//      software trigger fullfilled (with minimum no.of photons = minphotons)
+//
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MFSelBasic.h"
+
+#include "MParList.h"
+
+#include "MMcEvt.hxx"
+
+#include "MCerPhotEvt.h"
+#include "MRawRunHeader.h"
+
+#include "MGeomPix.h"
+#include "MGeomCam.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MFSelBasic);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MFSelBasic::MFSelBasic(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MFSelBasic";
+    fTitle = title ? title : "Filter to evaluate basic cuts";
+
+    // default values of cuts
+    SetCuts(20.0, 0.0, 60.0);
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the cut values
+// 
+//
+void MFSelBasic::SetCuts(Float_t minphotons, 
+                            Float_t thetamin, Float_t thetamax)
+{
+    fMinPhotons = minphotons;
+    fThetaMin   = thetamin;
+    fThetaMax   = thetamax;
+
+    *fLog << inf << "MFSelBasic cut values : fMinPhotons, fThetaMin, fThetaMax = ";
+    *fLog << fMinPhotons <<",  " << fThetaMin << ",  " << fThetaMax << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the pointers
+// 
+//
+Int_t MFSelBasic::PreProcess(MParList *pList)
+{
+    fRawRun = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
+    if (!fRawRun)
+    {
+        *fLog << dbginf << "MRawRunHeader not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
+    if (!fMcEvt)
+    {
+        *fLog << dbginf << "MMcEvt not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
+    if (!fEvt)
+    {
+        *fLog << dbginf << "MCerPhotEvt not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fCam = (MGeomCam*)pList->FindObject("MGeomCam");
+    if (!fCam)
+    {
+        *fLog << dbginf << "MGeomCam (Camera Geometry) missing in Parameter List... aborting." << endl;
+        return kFALSE;
+    }
+
+    memset(fCut, 0, sizeof(fCut));
+
+    return kTRUE;
+}
+
+Int_t MFSelBasic::Set(Int_t rc)
+{
+    fCut[rc]++;
+    fResult=kTRUE;
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Evaluate basic cuts
+// 
+//     bad events    : fResult = kTRUE;
+//     good events   : fResult = kFALSE;
+//
+Int_t MFSelBasic::Process()
+{
+    const Double_t theta = kRad2Deg*fMcEvt->GetTelescopeTheta();
+
+    fResult  = kFALSE;
+
+    // remove bad runs for MC gammas
+    //if (fMcEvt->GetEnergy() == 0.0  &&  fMcEvt->GetImpact() == 0.0)
+    //{
+    //  if (fRawRun->GetRunNumber() == 601  ||
+    //      fRawRun->GetRunNumber() == 613  ||
+    //      fRawRun->GetRunNumber() == 614    )
+    //	return Set(1);
+    //}
+
+    if (theta<fThetaMin)
+        return Set(2);
+
+    if (theta>fThetaMax)
+        return Set(3);
+
+    if (!SwTrigger())
+        return Set(4);
+
+    fCut[0]++;
+
+    return kTRUE;
+}
+// --------------------------------------------------------------------------
+//
+// Software trigger
+// 
+// require 2 neighboring pixels (which are not in the outermost ring), 
+//                       each having at least 'fMinPhotons' photons
+// 
+// 
+Bool_t MFSelBasic::SwTrigger()
+{
+    const Int_t entries = fEvt->GetNumPixels();
+ 
+    for (Int_t i=0; i<entries; i++)
+    {
+        const MCerPhotPix &pix = (*fEvt)[i];
+
+        const Int_t id = pix.GetPixId();
+        if (!pix.IsPixelUsed())
+            continue;
+
+        const Double_t photons = pix.GetNumPhotons();
+        if (photons < fMinPhotons)
+            continue;
+
+        // this pixel is used and has the required no.of photons
+        // check whether this is also true for a neigboring pixel
+
+        const MGeomPix &gpix = (*fCam)[id];
+        if ( gpix.IsInOutermostRing() )
+            continue;
+
+        const Int_t nneighbors = gpix.GetNumNeighbors();
+        for (Int_t n=0; n<nneighbors; n++)
+        {
+            const Int_t id1 =  gpix.GetNeighbor(n);
+            if ( !fEvt->IsPixelUsed(id1) )
+                continue;
+
+            const MGeomPix &gpix1 = (*fCam)[id1];
+            if ( gpix1.IsInOutermostRing() )
+                continue;
+
+            const MCerPhotPix &pix1 = *fEvt->GetPixById(id1);
+
+            const Double_t photons1 = pix1.GetNumPhotons();
+            if (photons1 >= fMinPhotons)
+                return kTRUE;
+        }
+    }
+    return kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Prints some statistics about the Basic selections.
+//
+Int_t MFSelBasic::PostProcess()
+{
+    if (GetNumExecutions()==0)
+        return kTRUE;
+
+    *fLog << inf << endl;
+    *fLog << GetDescriptor() << " execution statistics:" << endl;
+    *fLog << dec << setfill(' ');
+
+    *fLog << " " << setw(7) << fCut[1] << " (" << setw(3) ;
+    *fLog << (int)(fCut[1]*100/GetNumExecutions()) ;
+    *fLog << "%) Evts skipped due to: bad run " << endl;
+
+    *fLog << " " << setw(7) << fCut[2] << " (" << setw(3) ;
+    *fLog << (int)(fCut[2]*100/GetNumExecutions()) ;
+    *fLog << "%) Evts skipped due to: Zenith angle < " << fThetaMin << endl;
+
+    *fLog << " " << setw(7) << fCut[3] << " (" << setw(3) ;
+    *fLog << (int)(fCut[3]*100/GetNumExecutions()) ;
+    *fLog << "%) Evts skipped due to: Zenith angle > " << fThetaMax << endl;
+
+    *fLog << " " << setw(7) << fCut[4] << " (" << setw(3) ;
+    *fLog << (int)(fCut[4]*100/GetNumExecutions()) ;
+    *fLog << "%) Evts skipped due to: Software trigger not fullfilled" ;
+    *fLog << " (with fMinPhotons = " << fMinPhotons << ")" << endl;
+
+    *fLog << " " << fCut[0] << " (" << (int)(fCut[0]*100/GetNumExecutions()) ;
+    *fLog << "%) Evts survived Basic selections!" << endl;
+    *fLog << endl;
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mfilter/MFSelBasic.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfilter/MFSelBasic.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfilter/MFSelBasic.h	(revision 9661)
@@ -0,0 +1,68 @@
+#ifndef MARS_MFSelBasic
+#define MARS_MFSelBasic
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MFSelBasic                                                           //
+//                                                                         //
+// Class to evaluate basic cuts                                            //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MFilter
+#include "MFilter.h"
+#endif
+
+class MMcEvt;
+class MGeomCam;
+class MCerPhotEvt;
+class MPedestalCam;
+class MRawRunHeader;
+
+class MFSelBasic : public MFilter
+{
+private:
+    const MMcEvt        *fMcEvt;       
+    const MGeomCam      *fCam;      // Camera Geometry 
+    const MCerPhotEvt   *fEvt;      // Cerenkov Photon Event 
+    //const MPedestalCam  *fPed;      // Pedestal information
+    const MRawRunHeader *fRawRun;
+
+    Float_t     fMinPhotons;
+    Float_t     fThetaMin;
+    Float_t     fThetaMax;
+
+    Int_t       fCut[5];
+
+    Bool_t      fResult;
+
+    Int_t Set(Int_t rc);
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
+    Bool_t IsExpressionTrue() const { return fResult; }
+
+    Bool_t SwTrigger();
+
+public:
+    MFSelBasic(const char *name=NULL, const char *title=NULL);
+
+    void SetCuts(Float_t minphotons, Float_t thetamin, Float_t thetamax);
+
+    ClassDef(MFSelBasic, 0)   // Class to evaluate basic cuts
+};
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mfilter/MFSelFinal.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfilter/MFSelFinal.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfilter/MFSelFinal.cc	(revision 9661)
@@ -0,0 +1,193 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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  04/2003 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MFSelFinal
+//
+//  WHAT ARE THE FINAL CUTS?
+//
+//  This is a class to evaluate the Final Cuts
+//  (these cuts define the final sample of gammas;
+//   relevant for the calculation of the effective collection areas)
+//
+//  to be called after the calculation of the hadroness
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MFSelFinal.h"
+
+#include <math.h>
+
+#include "MParList.h"
+
+#include "MMcEvt.hxx"
+
+#include "MCerPhotEvt.h"
+
+#include "MGeomPix.h"
+#include "MGeomCam.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MHillasExt.h"
+#include "MHillasSrc.h"
+#include "MHadronness.h"
+
+ClassImp(MFSelFinal);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MFSelFinal::MFSelFinal(const char *hilsrcname,
+                             const char *name, const char *title)
+    : fHilSrcName(hilsrcname), fHadronnessName("MHadronness")
+{
+    fName  = name  ? name  : "MFSelFinal";
+    fTitle = title ? title : "Class to evaluate the Final Cuts";
+
+    // default values of cuts
+    SetCuts(1.0, 100.0, 10.);
+}
+
+// --------------------------------------------------------------------------
+//
+// Set cut values
+// 
+//
+void MFSelFinal::SetCuts(Float_t hadmax, Float_t alphamax, Float_t distmax) 
+{ 
+    fHadronnessMax =   hadmax;
+    fAlphaMax      = alphamax;
+    fDistMax       =  distmax;
+
+    *fLog << inf << "MFSelFinal cut values : fHadronnessMax, fAlphaMax, fDistMax = ";
+    *fLog << fHadronnessMax << ",  " << fAlphaMax << ",  " << fDistMax <<  endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the pointers
+//
+Int_t MFSelFinal::PreProcess(MParList *pList)
+{
+    fHilSrc = (MHillasSrc*)pList->FindObject(fHilSrcName, "MHillasSrc");
+    if (!fHilSrc)
+    {
+      *fLog << dbginf << "MHillasSrc object " << fHilSrcName << " not found... aborting." << endl;
+      return kFALSE;
+    }
+
+    fHadronness = (MHadronness*)pList->FindObject(fHadronnessName, "MHadronness");
+    if (!fHadronness)
+    {
+      *fLog << dbginf << "MHadronness not found... aborting." << endl;
+      return kFALSE;
+    }
+
+    MGeomCam *cam = (MGeomCam*)pList->FindCreateObj("MGeomCamMagic","MGeomCam");
+    if (!cam)
+    {
+        *fLog << err << "MGeomCam (Camera Geometry) not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fMm2Deg = cam->GetConvMm2Deg();
+
+    memset(fCut, 0, sizeof(fCut));
+
+    return kTRUE;
+}
+
+Int_t MFSelFinal::Set(Int_t rc)
+{
+    fCut[rc]++;
+    fResult=kTRUE;
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Evaluate final cuts
+// 
+// if cuts are fulfilled set fResult = kTRUE
+//
+Int_t MFSelFinal::Process()
+{
+    const Double_t modalpha = fabs( fHilSrc->GetAlpha() );
+    const Double_t h = fHadronness->GetHadronness();
+
+    fResult = kFALSE;
+
+    if (h>fHadronnessMax)
+        return Set(1);
+
+    if (modalpha>fAlphaMax)
+        return Set(2);
+
+    if (fMm2Deg*fHilSrc->GetDist()>fDistMax)
+        return Set(3);
+
+    fCut[0]++;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Prints some statistics about the Final selections.
+//
+Int_t MFSelFinal::PostProcess()
+{
+    if (GetNumExecutions()==0)
+        return kTRUE;
+
+    *fLog << inf << endl;
+    *fLog << GetDescriptor() << " execution statistics:" << endl;
+    *fLog << dec << setfill(' ');
+    *fLog << " " << setw(7) << fCut[1] << " (" << setw(3) ;
+    *fLog << (int)(fCut[1]*100/GetNumExecutions());
+    *fLog << "%) Evts skipped due to: hadronness > "<< fHadronnessMax;
+    *fLog << " (hadronness from '" << fHadronnessName << "')" << endl;
+
+    *fLog << " " << setw(7) << fCut[2] << " (" << setw(3) ;
+    *fLog << (int)(fCut[2]*100/GetNumExecutions());
+    *fLog << "%) Evts skipped due to: |ALPHA| > " << fAlphaMax;
+    *fLog << " [degrees]" << endl;
+
+    *fLog << " " << setw(7) << fCut[3] << " (" << setw(3) ;
+    *fLog << (int)(fCut[3]*100/GetNumExecutions());
+    *fLog << "%) Evts skipped due to: DIST > " << fDistMax;
+    *fLog << " [degrees]" << endl;
+
+    *fLog << " " << fCut[0] << " (" ;
+    *fLog << (int)(fCut[0]*100/GetNumExecutions());
+    *fLog << "%) Evts survived Final selections!" << endl;
+    *fLog << endl;
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mfilter/MFSelFinal.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfilter/MFSelFinal.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfilter/MFSelFinal.h	(revision 9661)
@@ -0,0 +1,70 @@
+#ifndef MARS_MFSelFinal
+#define MARS_MFSelFinal
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MSelFinal                                                               //
+//                                                                         //
+// Class to evaluate final cuts                                            //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MFilter
+#include "MFilter.h"
+#endif
+
+class MHillas;
+class MHillasSrc;
+class MHadronness;
+
+class MFSelFinal : public MFilter
+{
+private:
+    MHillasSrc  *fHilSrc;       
+    MHadronness *fHadronness;       
+
+    TString      fHilName;
+    TString      fHilSrcName;
+    TString      fHadronnessName;
+ 
+    Float_t      fHadronnessMax;
+    Float_t      fAlphaMax;
+    Float_t      fDistMax;
+
+    Double_t     fMm2Deg;   // conversion mm to degrees in camera
+
+    Int_t        fCut[4];
+
+    Bool_t       fResult;
+
+    Int_t Set(Int_t rc);
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
+    Bool_t IsExpressionTrue() const  { return fResult; }
+
+public:
+    MFSelFinal(const char *HilSrcName="MHillasSrc",
+                  const char *name=NULL, const char *title=NULL);
+
+    void SetHadronnessName(const TString name) { fHadronnessName = name; }
+
+    void SetCuts(Float_t hadmax, Float_t alphamax, Float_t distmax); 
+
+    ClassDef(MFSelFinal, 0)   // Class to evaluate final cuts
+};
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mfilter/MFSelStandard.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfilter/MFSelStandard.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfilter/MFSelStandard.cc	(revision 9661)
@@ -0,0 +1,221 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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, 04/2003 <mailto:wittek@mppmu.mpg.de>
+!   Author(s): Thomas Bretz, 04/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MFSelStandard
+//
+//  This is a class to evaluate the Standard Cuts
+//
+//  WHAT ARE THE STANDARD CUTS?                                                                       //
+//
+//  to be called after the calculation of the image parameters
+//               before the g/h separation
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MFSelStandard.h"
+
+#include "MParList.h"
+
+#include "MMcEvt.hxx"
+
+#include "MGeomPix.h"
+#include "MGeomCam.h"
+
+#include "MCerPhotEvt.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MHillas.h"
+#include "MHillasExt.h"
+#include "MHillasSrc.h"
+#include "MNewImagePar.h"
+
+ClassImp(MFSelStandard);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MFSelStandard::MFSelStandard(const char *hilsrcname,
+                                   const char *name, const char *title)
+    : fHilName("MHillas"), fHilSrcName(hilsrcname), fImgParName("MNewImagePar")
+{
+    fName  = name  ? name  : "MFSelStandard";
+    fTitle = title ? title : "Class to evaluate the Standard Cuts";
+
+    // default values of cuts
+    SetCuts(92, 4, 60, 0.4, 1.05, 0.0, 0.0);
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the values for the cuts 
+// 
+//
+void MFSelStandard::SetCuts(Float_t usedpixelsmax, Float_t corepixelsmin,
+                               Float_t sizemin, Float_t distmin, Float_t distmax,
+                               Float_t lengthmin, Float_t widthmin)
+{ 
+    fUsedPixelsMax = usedpixelsmax;
+    fCorePixelsMin = corepixelsmin;
+    fSizeMin       = sizemin;
+    fDistMin       = distmin;
+    fDistMax       = distmax;
+    fLengthMin     = lengthmin;
+    fWidthMin      = widthmin;
+
+    *fLog << inf << "MFSelStandard cut values : fUsedPixelsMax, fCorePixelsMin = ";
+    *fLog << fUsedPixelsMax << ",  " << fCorePixelsMin << endl;
+    *fLog << inf << "     fSizeMin, fDistMin, fDistMax = " << fSizeMin ;
+    *fLog << ",  " << fDistMin << ",  " << fDistMax << endl;
+    *fLog << inf << "     fLengthMin, fWidthMin = " << fLengthMin ;
+    *fLog << ",  " << fWidthMin << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// MISSING
+//
+Int_t MFSelStandard::PreProcess(MParList *pList)
+{
+    fHil = (MHillas*)pList->FindObject(fHilName, "MHillas");
+    if (!fHil)
+    {
+        *fLog << err << fHilName << " [MHillas] not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fHilSrc = (MHillasSrc*)pList->FindObject(fHilSrcName, "MHillasSrc");
+    if (!fHilSrc)
+    {
+        *fLog << err << fHilSrcName << " [MHillasSrc] not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fNewImgPar = (MNewImagePar*)pList->FindObject(fImgParName, "MNewImagePar");
+    if (!fNewImgPar)
+    {
+        *fLog << err << fImgParName << " [MNewImagePar] not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    MGeomCam *cam = (MGeomCam*)pList->FindObject("MGeomCam");
+    if (!cam)
+    {
+        *fLog << err << "MGeomCam (Camera Geometry) not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fMm2Deg = cam->GetConvMm2Deg();
+
+    memset(fCut, 0, sizeof(fCut));
+
+    return kTRUE;
+}
+
+Bool_t MFSelStandard::Set(Int_t rc)
+{
+    fResult = kTRUE;
+    fCut[rc]++;
+    return kTRUE;
+}
+// --------------------------------------------------------------------------
+//
+// Evaluate standard cuts
+// 
+// if selections are fulfilled set fResult = kTRUE;
+// 
+//
+Int_t MFSelStandard::Process()
+{
+    const Double_t length     = fHil->GetLength() * fMm2Deg;
+    const Double_t width      = fHil->GetWidth()  * fMm2Deg;
+    const Double_t dist       = fHilSrc->GetDist()* fMm2Deg;
+    //const Double_t delta      = fHil->GetDelta()  * kRad2Deg;
+    const Double_t size       = fHil->GetSize();
+    const Int_t numusedpixels = fNewImgPar->GetNumUsedPixels();
+    const Int_t numcorepixels = fNewImgPar->GetNumCorePixels();
+
+    fResult  = kFALSE;
+
+    if (numusedpixels>=fUsedPixelsMax || numcorepixels<fCorePixelsMin)
+        return Set(1);
+
+    if (size<=fSizeMin )
+        return Set(2);
+
+    if (dist<fDistMin || dist>fDistMax)
+        return Set(3);
+
+    if (length<=fLengthMin || width<=fWidthMin)
+        return Set(4);
+
+    fCut[0]++;
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Prints some statistics about the Standard selections.
+//
+Int_t MFSelStandard::PostProcess()
+{
+    if (GetNumExecutions()==0)
+        return kTRUE;
+
+    *fLog << inf << endl;
+    *fLog << GetDescriptor() << " execution statistics:" << endl;
+    *fLog << dec << setfill(' ');
+    *fLog << " " << setw(7) << fCut[1] << " (" << setw(3);
+    *fLog << (int)(fCut[1]*100/GetNumExecutions()) ;
+    *fLog << "%) Evts skipped due to: Used pixels >= " << fUsedPixelsMax ;
+    *fLog << " or Core pixels < " << fCorePixelsMin << endl;
+
+    *fLog << " " << setw(7) << fCut[2] << " (" << setw(3) ;
+    *fLog << (int)(fCut[2]*100/GetNumExecutions()) ;
+    *fLog << "%) Evts skipped due to: SIZE <= " << fSizeMin << endl;
+
+    *fLog << " " << setw(7) << fCut[3] << " (" << setw(3) ;
+    *fLog << (int)(fCut[3]*100/GetNumExecutions()) ;
+    *fLog << "%) Evts skipped due to: DIST < " << fDistMin;
+    *fLog << " or DIST > " << fDistMax << endl;
+
+    *fLog << " " << setw(7) << fCut[4] << " (" << setw(3) ;
+    *fLog << (int)(fCut[4]*100/GetNumExecutions()) ;
+    *fLog << "%) Evts skipped due to: LENGTH <= " << fLengthMin;
+    *fLog << " or WIDTH <= " << fWidthMin << endl;
+
+    *fLog << " " << fCut[0] << " (" ;
+    *fLog << (int)(fCut[0]*100/GetNumExecutions()) ;
+    *fLog << "%) Evts survived Standard selections!" << endl;
+    *fLog << endl;
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mfilter/MFSelStandard.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfilter/MFSelStandard.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfilter/MFSelStandard.h	(revision 9661)
@@ -0,0 +1,78 @@
+#ifndef MARS_MFSelStandard
+#define MARS_MFSelStandard
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MFSelStandard                                                        //
+//                                                                         //
+// Class to evaluate standard cuts                                         //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MFilter
+#include "MFilter.h"
+#endif
+
+class MHillas;
+class MHillasSrc;
+class MNewImagePar;
+
+class MFSelStandard : public MFilter
+{
+private:
+    MHillas      *fHil;
+    MHillasSrc   *fHilSrc;
+    MNewImagePar *fNewImgPar;
+
+    TString      fHilName;
+    TString      fHilSrcName;
+    TString      fImgParName;
+
+    Float_t      fUsedPixelsMax;
+    Float_t      fCorePixelsMin;
+    Float_t      fSizeMin;
+    Float_t      fDistMin;
+    Float_t      fDistMax;
+    Float_t      fLengthMin;
+    Float_t      fWidthMin;
+
+    Double_t     fMm2Deg;    // conversion mm to degrees in camera
+
+    Int_t        fCut[5];
+
+    Bool_t       fResult;
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
+    Bool_t IsExpressionTrue() const  { return fResult; }
+
+    Bool_t Set(Int_t rc);
+
+public:
+    MFSelStandard(const char *HilSrcName="MHillasSrc",
+                     const char *name=NULL, const char *title=NULL);
+
+    void SetHillasName(const char *name) { fHilName = name; }
+    void SetImgParName(const char *name) { fImgParName = name; }
+
+    void SetCuts(Float_t usedpixelsmax, Float_t corepixelsmin,
+                 Float_t sizemin, Float_t distmin, Float_t distmax,
+                 Float_t lengthmin, Float_t widthmin);
+
+    ClassDef(MFSelStandard, 0)   // Class to evaluate standard cuts
+};
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mfilter/MFSoftwareTrigger.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfilter/MFSoftwareTrigger.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfilter/MFSoftwareTrigger.cc	(revision 9661)
@@ -0,0 +1,174 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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, 04/2003 <mailto:wittek@mppmu.mpg.de>
+!   Author(s): Thomas Bretz, 04/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MFSoftwareTrigger
+//
+//  This is a class to evaluate a software trigger
+//
+//  to be called after the calibration (when the number of photons is
+//               available for all pixels)
+//
+// require 2 neighboring pixels (which are not in the outermost ring),
+//                       each having at least 'fNumMinPhotons' photons
+//
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MFSoftwareTrigger.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MGeomPix.h"
+#include "MGeomCam.h"
+
+#include "MCerPhotEvt.h"
+
+ClassImp(MFSoftwareTrigger);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MFSoftwareTrigger::MFSoftwareTrigger(const char *name, const char *title)
+    : fNumMinPhotons(0), fNumNeighbors(2)
+{
+    fName  = name  ? name  : "MFSoftwareTrigger";
+    fTitle = title ? title : "Filter for software trigger";
+}
+
+// --------------------------------------------------------------------------
+//
+// Software trigger
+// 
+// require 2 neighboring pixels (which are not in the outermost ring), 
+//                       each having at least 'fNumMinPhotons' photons
+// 
+Bool_t MFSoftwareTrigger::SwTrigger() const
+{
+    const Int_t entries = fEvt->GetNumPixels();
+ 
+    for (Int_t i=0; i<entries; i++)
+    {
+        const MCerPhotPix &pix = (*fEvt)[i];
+        if (!pix.IsPixelUsed())
+            continue;
+
+        if (pix.GetNumPhotons()<fNumMinPhotons)
+            continue;
+
+        // this pixel is used and has the required no.of photons
+        // check whether this is also true for a neigboring pixel
+        MGeomPix &gpix = (*fCam)[pix.GetPixId()];
+        if (gpix.IsInOutermostRing())
+            continue;
+
+        Int_t num = 1;
+
+        const Int_t nneighbors = gpix.GetNumNeighbors();
+        for (Int_t n=0; n<nneighbors; n++)
+        {
+            const Int_t id = gpix.GetNeighbor(n);
+            if (!fEvt->IsPixelUsed(id))
+                continue;
+
+            if ((*fCam)[id].IsInOutermostRing())
+                continue;
+
+            const Double_t photons = fEvt->GetPixById(id)->GetNumPhotons();
+            if (photons >= fNumMinPhotons)
+                if (++num==fNumNeighbors)
+                    return kTRUE;
+        }
+    }
+    return kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Request pointer to MCerPhotEvt and MGeomCam from paremeter list
+//
+Int_t MFSoftwareTrigger::PreProcess(MParList *pList)
+{
+    fEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
+    if (!fEvt)
+    {
+        *fLog << err << "MCerPhotEvt not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fCam = (MGeomCam*)pList->FindObject("MGeomCam");
+    if (!fCam)
+    {
+        *fLog << err << "MGeomCam not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    memset(fCut, 0, sizeof(fCut));
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Evaluate software trigger
+//
+Int_t MFSoftwareTrigger::Process()
+{
+    fResult = SwTrigger();
+
+    fCut[fResult ? 0 : 1]++;
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Prints some statistics about the Basic selections.
+//
+Int_t MFSoftwareTrigger::PostProcess()
+{
+    if (GetNumExecutions()==0)
+        return kTRUE;
+
+    *fLog << inf << endl;
+    *fLog << GetDescriptor() << " execution statistics:" << endl;
+    *fLog << dec << setfill(' ');
+
+    *fLog << " " << setw(7) << fCut[0] << " (" << setw(3) ;
+    *fLog << (int)(fCut[0]*100/GetNumExecutions());
+    *fLog << "%) Evts fullfilled software trigger";
+    *fLog << " (NumPhotons>=" << fNumMinPhotons << ", NumNeighbors>=";
+    *fLog << (int)fNumNeighbors << ")" << endl;
+    *fLog << " " << setw(7) << fCut[1] << " (" << setw(3) ;
+    *fLog << (int)(fCut[1]*100/GetNumExecutions());
+    *fLog << "%) Evts didn't fullfill software trigger."  << endl;
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mfilter/MFSoftwareTrigger.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfilter/MFSoftwareTrigger.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfilter/MFSoftwareTrigger.h	(revision 9661)
@@ -0,0 +1,42 @@
+#ifndef MARS_MFSoftwareTrigger
+#define MARS_MFSoftwareTrigger
+
+#ifndef MARS_MFilter
+#include "MFilter.h"
+#endif
+
+class MMcEvt;
+class MGeomCam;
+class MCerPhotEvt;
+
+class MFSoftwareTrigger : public MFilter
+{
+private:
+    const MGeomCam    *fCam; // Camera Geometry
+    const MCerPhotEvt *fEvt; // Cerenkov Photon Event
+
+    Float_t     fNumMinPhotons; // nuber of minimum required photons
+    Byte_t      fNumNeighbors;  // number of required neighbours
+
+    Int_t       fCut[2];
+
+    Bool_t      fResult;
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
+    Bool_t SwTrigger() const;
+
+    Bool_t IsExpressionTrue() const { return fResult; }
+
+public:
+    MFSoftwareTrigger(const char *name=NULL, const char *title=NULL);
+
+    void SetNumMinPhotons(Float_t minphotons) { fNumMinPhotons = minphotons; }
+    void SetNumNeighbors(Byte_t num) { fNumNeighbors = num; }
+
+    ClassDef(MFSoftwareTrigger, 0) // Filter for software trigger
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mfilter/MFTriggerLvl1.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfilter/MFTriggerLvl1.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfilter/MFTriggerLvl1.cc	(revision 9661)
@@ -0,0 +1,135 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  07/2001 <mailto:tbretz@uni-sw.gwdg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//   MFTriggerLvl1                                                         //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MFTriggerLvl1.h"
+
+#include <fstream>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MMcTrig.hxx"
+
+ClassImp(MFTriggerLvl1);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+MFTriggerLvl1::MFTriggerLvl1(const char *cname, const char type, const Int_t val,
+                             const char *name, const char *title) : fMcTrig(NULL)
+{
+    fContName = cname;
+    Init(type, val, name, title);
+}
+
+// --------------------------------------------------------------------------
+//
+MFTriggerLvl1::MFTriggerLvl1(MMcTrig *mctrig, const char type, const Int_t val,
+                             const char *name, const char *title) : fMcTrig(mctrig)
+{
+    Init(type, val, name, title);
+}
+
+// --------------------------------------------------------------------------
+//
+void MFTriggerLvl1::Init(const char type, const Int_t val,
+                         const char *name, const char *title)
+{
+    fName  = name  ? name  : "MFTriggerLvl1";
+    fTitle = title ? title : "Filter using number of 1st level triggers";
+
+    fFilterType = (type=='<' ? kELowerThan : kEGreaterThan);
+
+    if (type!='<' && type!='>')
+        *fLog << warn << dbginf << "Warning: Neither '<' nor '>' specified... using '>'." << endl;
+
+    fValue = val;
+
+    AddToBranchList(Form("%s.fNumFirstLevel", (const char*)fContName));
+}
+
+// --------------------------------------------------------------------------
+//
+Bool_t MFTriggerLvl1::IsExpressionTrue() const
+{
+    return fResult;
+}
+
+// --------------------------------------------------------------------------
+//
+Int_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;
+}
+
+// --------------------------------------------------------------------------
+//
+Int_t MFTriggerLvl1::Process()
+{
+    const Int_t lvl1 = fMcTrig->GetFirstLevel();
+
+    switch (fFilterType)
+    {
+    case kELowerThan:
+        fResult = (lvl1 < fValue);
+        break;
+    case kEGreaterThan:
+        fResult = (lvl1 > fValue);
+        break;
+    }
+
+    return kTRUE;
+}
+
+void MFTriggerLvl1::StreamPrimitive(ofstream &out) const
+{
+    if (fMcTrig)
+        fMcTrig->SavePrimitive(out);
+
+    out << "   MFTriggerLvl1 " << GetUniqueName() << "(";
+
+    if (fMcTrig)
+        out << "&" << fMcTrig->GetUniqueName();
+    else
+        out << "\"" << fContName << "\"";
+
+    out << ", '" << (fFilterType==kELowerThan?"<":">") << "', " << fValue << ");" << endl;
+
+}
Index: /tags/Mars_V0-8-5/Mars/mfilter/MFTriggerLvl1.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfilter/MFTriggerLvl1.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfilter/MFTriggerLvl1.h	(revision 9661)
@@ -0,0 +1,48 @@
+#ifndef MARS_MFTriggerLvl1
+#define MARS_MFTriggerLvl1
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MFTriggerLvl1                                                           //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MFilter
+#include "MFilter.h"
+#endif
+
+class MMcTrig;
+class MParList;
+
+class MFTriggerLvl1 : public MFilter
+{
+private:
+    MMcTrig *fMcTrig;
+    TString fContName;
+
+    typedef enum { kELowerThan, kEGreaterThan } FilterType_t;
+    FilterType_t fFilterType; 
+
+    Bool_t fResult;             //!
+    Int_t  fValue;
+
+    void Init(const char type, const Int_t val,
+              const char *name, const char *title);
+
+    void StreamPrimitive(ofstream &out) const;
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
+public:
+    MFTriggerLvl1(const char *cname="MMcTrig", const char type='>', const Int_t val=0,
+                  const char *name=NULL, const char *title=NULL);
+    MFTriggerLvl1(MMcTrig *mctrig, const char type='>', const Int_t val=0,
+                  const char *name=NULL, const char *title=NULL);
+
+    Bool_t IsExpressionTrue() const;
+
+    ClassDef(MFTriggerLvl1, 1) // A Filter for the Level 1 Trigger
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mfilter/MFTriggerLvl2.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfilter/MFTriggerLvl2.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfilter/MFTriggerLvl2.cc	(revision 9661)
@@ -0,0 +1,143 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Antonio Stamerra  02/2003 <mailto:antonio.stamerra@pi.infn.it>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//   MFTriggerLvl2                                                         //
+//                                                                         //
+//  A Filter for the 2nd Level trigger, using the MMcTriggerLvl2 Class     //
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MFTriggerLvl2.h"
+
+#include <fstream>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MMcTriggerLvl2.h"
+
+ClassImp(MFTriggerLvl2);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor
+//
+MFTriggerLvl2::MFTriggerLvl2(const char *cname, const char type, const Int_t val,
+                             const char *name, const char *title) : fcell(NULL)
+{
+    fContName = cname;
+    Init(type, val, name, title);
+}
+
+// --------------------------------------------------------------------------
+ //
+MFTriggerLvl2::MFTriggerLvl2(MMcTriggerLvl2 *triglvl2, const char type, const Int_t val,
+                             const char *name, const char *title) : fcell(triglvl2)
+{
+    Init(type, val, name, title);
+}
+
+// --------------------------------------------------------------------------
+//
+void MFTriggerLvl2::Init(const char type, const Int_t val,
+                         const char *name, const char *title)
+{
+    fName  = name  ? name  : "MFTriggerLvl2";
+    fTitle = title ? title : "Filter using 2nd level trigger selection";
+
+    fFilterType = (type=='<' ? kELowerThan : kEGreaterThan);
+
+    if (type!='<' && type!='>')
+        *fLog << warn << dbginf << "Warning: Neither '<' nor '>' specified... using '>'." << endl;
+
+    fValue = val;
+
+} 
+// --------------------------------------------------------------------------
+//
+Bool_t MFTriggerLvl2::IsExpressionTrue() const
+{
+    return fResult;
+}
+
+// --------------------------------------------------------------------------
+//
+Int_t MFTriggerLvl2::PreProcess(MParList *pList)
+{
+    if (fcell)
+        return kTRUE;
+
+    fcell = (MMcTriggerLvl2*)pList->FindObject(fContName);
+    if (fcell)
+        return kTRUE;
+
+    *fLog << err << dbginf << fContName << " [MMcTriggerLvl2] not found... aborting." << endl;
+
+        return kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+Int_t MFTriggerLvl2::Process()
+{
+
+  //
+  //  The variable fLutPseudoSize of the class MMcTriggerLvl2 is used 
+  //   for the selection
+  //
+
+  const Int_t lvl2 = fcell->GetLutPseudoSize();
+
+    switch (fFilterType)
+    {
+    case kELowerThan:
+        fResult = (lvl2 < fValue);
+        break;
+    case kEGreaterThan:
+        fResult = (lvl2 > fValue);
+        break;
+    }
+
+    return kTRUE;
+}
+
+void MFTriggerLvl2::StreamPrimitive(ofstream &out) const
+{
+   if (fcell)
+        fcell->SavePrimitive(out);
+
+    out << "   MFTriggerLvl2 " << GetUniqueName() << "(";
+
+    if (fcell)
+        out << "&" << fcell->GetUniqueName();
+    else
+        out << "\"" << fContName << "\"";
+
+    out << ", '" << (fFilterType==kELowerThan?"<":">") << "', " << fValue << ");" << endl;
+
+}
Index: /tags/Mars_V0-8-5/Mars/mfilter/MFTriggerLvl2.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfilter/MFTriggerLvl2.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfilter/MFTriggerLvl2.h	(revision 9661)
@@ -0,0 +1,55 @@
+#ifndef MARS_MFTriggerLvl2
+#define MARS_MFTriggerLvl2
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MFTriggerLvl2
+//
+// auth. A.stamerra 
+// created 30.01.03                                                       //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MFilter
+#include "MFilter.h"
+#endif
+
+class MMcTrig;
+class MParList;
+class MMcTriggerLvl2;
+
+class MFTriggerLvl2 : public MFilter
+{
+private:
+
+    TString fContName;
+
+    MMcTriggerLvl2 *fcell;
+
+    typedef enum { kELowerThan, kEGreaterThan } FilterType_t;
+    FilterType_t fFilterType; 
+
+    Bool_t fResult;             //!
+    Int_t  fValue;
+
+    void Init(const char type, const Int_t val,
+              const char *name, const char *title);
+
+    void StreamPrimitive(ofstream &out) const;
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
+public:
+
+    MFTriggerLvl2(const char *cname="MMcTriggerLvl2", const char type='>', const Int_t val=0,
+                  const char *name=NULL, const char *title=NULL);
+    MFTriggerLvl2(MMcTriggerLvl2 *triglvl2, const char type='>', const Int_t val=0,
+                  const char *name=NULL, const char *title=NULL);
+
+    Bool_t IsExpressionTrue() const;
+
+    ClassDef(MFTriggerLvl2, 1) // A Filter for the Level 2 Trigger
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mfilter/Makefile
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfilter/Makefile	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfilter/Makefile	(revision 9661)
@@ -0,0 +1,41 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#------------------------------------------------------------------------------
+
+INCLUDES = -I. -I../mbase -I../mfbase -I../mraw -I../mmc -I../mdata \
+           -I../manalysis -I../mfileio  -I../mgeom -I../mimage      \
+           -I../mhbase -I../mmain -I../mgui -I../msignal            \
+           -I../mpedestal
+
+CINT     = Filter
+
+SRCFILES = MFTriggerLvl1.cc \
+	   MFTriggerLvl2.cc \
+	   MFGeomag.cc \
+	   MFParticleId.cc \
+	   MFAlpha.cc \
+	   MFCT1SelBasic.cc \
+	   MFCT1SelStandard.cc \
+	   MFCT1SelFinal.cc \
+	   MFSelBasic.cc \
+	   MFSelStandard.cc \
+	   MFSelFinal.cc \
+           MFSoftwareTrigger.cc \
+           MFCosmics.cc \
+	   MFEnergySlope.cc
+
+############################################################
+
+all: $(OBJS)
+
+include ../Makefile.rules
+
+mrproper:	clean rmbak
Index: /tags/Mars_V0-8-5/Mars/mfilter/gcminus.txt
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfilter/gcminus.txt	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfilter/gcminus.txt	(revision 9661)
@@ -0,0 +1,1152 @@
+       2.5       2.5    10.420    11.182     0.538
+       2.5       7.5    10.400    11.162     0.528
+       2.5      12.5    10.380    11.140     0.521
+       2.5      17.5    10.360    11.120     0.526
+       2.5      22.5    10.342    11.104     0.528
+       2.5      27.5    10.324    11.084     0.532
+       2.5      32.5    10.306    11.068     0.528
+       2.5      37.5    10.290    11.048     0.530
+       2.5      42.5    10.274    11.034     0.524
+       2.5      47.5    10.260    11.018     0.528
+       2.5      52.5    10.246    11.004     0.528
+       2.5      57.5    10.234    10.992     0.528
+       2.5      62.5    10.224    10.982     0.538
+       2.5      67.5    10.214    10.974     0.534
+       2.5      72.5    10.208    10.964     0.534
+       2.5      77.5    10.202    10.958     0.545
+       2.5      82.5    10.196    10.954     0.538
+       2.5      87.5    10.194    10.948     0.538
+       2.5      92.5    10.194    10.948     0.549
+       2.5      97.5    10.194    10.948     0.552
+       2.5     102.5    10.196    10.950     0.562
+       2.5     107.5    10.200    10.952     0.553
+       2.5     112.5    10.206    10.958     0.561
+       2.5     117.5    10.212    10.966     0.568
+       2.5     122.5    10.222    10.972     0.565
+       2.5     127.5    10.232    10.982     0.563
+       2.5     132.5    10.244    10.996     0.577
+       2.5     137.5    10.256    11.006     0.568
+       2.5     142.5    10.270    11.020     0.584
+       2.5     147.5    10.286    11.038     0.582
+       2.5     152.5    10.302    11.054     0.593
+       2.5     157.5    10.320    11.070     0.605
+       2.5     162.5    10.338    11.088     0.595
+       2.5     167.5    10.358    11.106     0.599
+       2.5     172.5    10.378    11.128     0.603
+       2.5     177.5    10.398    11.148     0.613
+       2.5     182.5    10.418    11.168     0.611
+       2.5     187.5    10.438    11.188     0.611
+       2.5     192.5    10.458    11.206     0.618
+       2.5     197.5    10.478    11.226     0.607
+       2.5     202.5    10.498    11.248     0.616
+       2.5     207.5    10.516    11.266     0.613
+       2.5     212.5    10.536    11.286     0.611
+       2.5     217.5    10.552    11.304     0.617
+       2.5     222.5    10.570    11.318     0.620
+       2.5     227.5    10.584    11.336     0.614
+       2.5     232.5    10.598    11.348     0.616
+       2.5     237.5    10.612    11.364     0.606
+       2.5     242.5    10.622    11.374     0.601
+       2.5     247.5    10.632    11.384     0.604
+       2.5     252.5    10.640    11.394     0.613
+       2.5     257.5    10.648    11.400     0.601
+       2.5     262.5    10.652    11.404     0.596
+       2.5     267.5    10.654    11.406     0.593
+       2.5     272.5    10.656    11.410     0.594
+       2.5     277.5    10.654    11.408     0.586
+       2.5     282.5    10.652    11.406     0.586
+       2.5     287.5    10.646    11.402     0.577
+       2.5     292.5    10.640    11.396     0.582
+       2.5     297.5    10.632    11.388     0.571
+       2.5     302.5    10.622    11.380     0.575
+       2.5     307.5    10.612    11.370     0.565
+       2.5     312.5    10.598    11.356     0.559
+       2.5     317.5    10.584    11.344     0.563
+       2.5     322.5    10.570    11.328     0.554
+       2.5     327.5    10.554    11.312     0.551
+       2.5     332.5    10.536    11.296     0.545
+       2.5     337.5    10.518    11.276     0.546
+       2.5     342.5    10.500    11.260     0.542
+       2.5     347.5    10.480    11.240     0.537
+       2.5     352.5    10.460    11.220     0.539
+       2.5     357.5    10.440    11.202     0.533
+       7.5       2.5    10.432    11.210     0.445
+       7.5       7.5    10.372    11.154     0.440
+       7.5      12.5    10.314    11.094     0.431
+       7.5      17.5    10.258    11.040     0.435
+       7.5      22.5    10.204    10.982     0.424
+       7.5      27.5    10.152    10.932     0.428
+       7.5      32.5    10.102    10.880     0.434
+       7.5      37.5    10.054    10.832     0.445
+       7.5      42.5    10.010    10.788     0.437
+       7.5      47.5     9.970    10.746     0.436
+       7.5      52.5     9.934    10.706     0.453
+       7.5      57.5     9.900    10.672     0.451
+       7.5      62.5     9.870    10.638     0.453
+       7.5      67.5     9.846    10.612     0.467
+       7.5      72.5     9.824    10.590     0.473
+       7.5      77.5     9.808    10.570     0.472
+       7.5      82.5     9.796    10.554     0.485
+       7.5      87.5     9.788    10.544     0.489
+       7.5      92.5     9.784    10.538     0.496
+       7.5      97.5     9.784    10.540     0.508
+       7.5     102.5     9.790    10.542     0.521
+       7.5     107.5     9.800    10.552     0.529
+       7.5     112.5     9.814    10.564     0.539
+       7.5     117.5     9.834    10.582     0.553
+       7.5     122.5     9.858    10.606     0.570
+       7.5     127.5     9.886    10.632     0.576
+       7.5     132.5     9.918    10.664     0.584
+       7.5     137.5     9.954    10.700     0.598
+       7.5     142.5     9.996    10.740     0.602
+       7.5     147.5    10.040    10.784     0.610
+       7.5     152.5    10.088    10.832     0.621
+       7.5     157.5    10.138    10.882     0.637
+       7.5     162.5    10.192    10.936     0.642
+       7.5     167.5    10.248    10.992     0.653
+       7.5     172.5    10.306    11.050     0.664
+       7.5     177.5    10.368    11.112     0.664
+       7.5     182.5    10.428    11.172     0.683
+       7.5     187.5    10.492    11.236     0.694
+       7.5     192.5    10.554    11.298     0.691
+       7.5     197.5    10.616    11.360     0.699
+       7.5     202.5    10.678    11.422     0.699
+       7.5     207.5    10.738    11.482     0.704
+       7.5     212.5    10.796    11.540     0.710
+       7.5     217.5    10.852    11.596     0.710
+       7.5     222.5    10.904    11.650     0.702
+       7.5     227.5    10.954    11.700     0.716
+       7.5     232.5    10.998    11.744     0.697
+       7.5     237.5    11.040    11.784     0.707
+       7.5     242.5    11.076    11.822     0.694
+       7.5     247.5    11.106    11.852     0.678
+       7.5     252.5    11.132    11.880     0.679
+       7.5     257.5    11.152    11.900     0.671
+       7.5     262.5    11.166    11.916     0.656
+       7.5     267.5    11.174    11.924     0.656
+       7.5     272.5    11.176    11.928     0.638
+       7.5     277.5    11.172    11.924     0.625
+       7.5     282.5    11.162    11.916     0.623
+       7.5     287.5    11.146    11.902     0.611
+       7.5     292.5    11.124    11.882     0.594
+       7.5     297.5    11.096    11.854     0.578
+       7.5     302.5    11.064    11.824     0.566
+       7.5     307.5    11.028    11.790     0.549
+       7.5     312.5    10.986    11.752     0.543
+       7.5     317.5    10.942    11.706     0.521
+       7.5     322.5    10.892    11.662     0.512
+       7.5     327.5    10.840    11.612     0.495
+       7.5     332.5    10.786    11.556     0.483
+       7.5     337.5    10.730    11.504     0.478
+       7.5     342.5    10.672    11.448     0.474
+       7.5     347.5    10.612    11.390     0.463
+       7.5     352.5    10.552    11.328     0.451
+       7.5     357.5    10.492    11.272     0.456
+      12.5       2.5    10.446    11.258     0.320
+      12.5       7.5    10.348    11.158     0.326
+      12.5      12.5    10.254    11.064     0.321
+      12.5      17.5    10.162    10.976     0.327
+      12.5      22.5    10.074    10.884     0.314
+      12.5      27.5     9.990    10.800     0.331
+      12.5      32.5     9.912    10.722     0.336
+      12.5      37.5     9.838    10.646     0.337
+      12.5      42.5     9.772    10.572     0.345
+      12.5      47.5     9.708    10.506     0.343
+      12.5      52.5     9.652    10.444     0.366
+      12.5      57.5     9.602    10.392     0.370
+      12.5      62.5     9.556    10.340     0.380
+      12.5      67.5     9.518    10.296     0.398
+      12.5      72.5     9.486    10.260     0.408
+      12.5      77.5     9.460    10.228     0.417
+      12.5      82.5     9.440    10.204     0.445
+      12.5      87.5     9.428    10.190     0.459
+      12.5      92.5     9.420    10.178     0.459
+      12.5      97.5     9.422    10.174     0.487
+      12.5     102.5     9.428    10.180     0.487
+      12.5     107.5     9.444    10.190     0.504
+      12.5     112.5     9.464    10.210     0.525
+      12.5     117.5     9.492    10.238     0.547
+      12.5     122.5     9.528    10.272     0.559
+      12.5     127.5     9.570    10.314     0.567
+      12.5     132.5     9.620    10.362     0.588
+      12.5     137.5     9.678    10.418     0.605
+      12.5     142.5     9.742    10.482     0.616
+      12.5     147.5     9.812    10.552     0.627
+      12.5     152.5     9.888    10.630     0.650
+      12.5     157.5     9.970    10.712     0.674
+      12.5     162.5    10.058    10.800     0.685
+      12.5     167.5    10.152    10.894     0.706
+      12.5     172.5    10.250    10.992     0.722
+      12.5     177.5    10.352    11.094     0.730
+      12.5     182.5    10.456    11.200     0.753
+      12.5     187.5    10.564    11.306     0.763
+      12.5     192.5    10.672    11.414     0.784
+      12.5     197.5    10.780    11.522     0.792
+      12.5     202.5    10.886    11.630     0.793
+      12.5     207.5    10.992    11.736     0.806
+      12.5     212.5    11.094    11.838     0.796
+      12.5     217.5    11.194    11.936     0.803
+      12.5     222.5    11.286    12.030     0.809
+      12.5     227.5    11.374    12.116     0.817
+      12.5     232.5    11.454    12.196     0.798
+      12.5     237.5    11.526    12.270     0.798
+      12.5     242.5    11.590    12.334     0.788
+      12.5     247.5    11.644    12.388     0.774
+      12.5     252.5    11.688    12.434     0.761
+      12.5     257.5    11.722    12.468     0.743
+      12.5     262.5    11.746    12.492     0.716
+      12.5     267.5    11.760    12.506     0.708
+      12.5     272.5    11.760    12.508     0.684
+      12.5     277.5    11.752    12.500     0.674
+      12.5     282.5    11.732    12.482     0.640
+      12.5     287.5    11.700    12.454     0.610
+      12.5     292.5    11.660    12.416     0.590
+      12.5     297.5    11.610    12.372     0.567
+      12.5     302.5    11.550    12.316     0.540
+      12.5     307.5    11.484    12.252     0.518
+      12.5     312.5    11.408    12.182     0.488
+      12.5     317.5    11.328    12.104     0.461
+      12.5     322.5    11.240    12.018     0.437
+      12.5     327.5    11.148    11.934     0.402
+      12.5     332.5    11.052    11.842     0.387
+      12.5     337.5    10.954    11.748     0.375
+      12.5     342.5    10.852    11.648     0.357
+      12.5     347.5    10.750    11.550     0.352
+      12.5     352.5    10.648    11.454     0.335
+      12.5     357.5    10.546    11.352     0.328
+      17.5       2.5    10.456    11.312     0.124
+      17.5       7.5    10.318    11.114     0.141
+      17.5      12.5    10.186    11.050     0.148
+      17.5      17.5    10.060    10.926     0.185
+      17.5      22.5     9.942    10.744     0.207
+      17.5      27.5     9.832    10.632     0.232
+      17.5      32.5     9.728    10.392     0.295
+      17.5      37.5     9.632    10.484     0.244
+      17.5      42.5     9.544    10.390     0.253
+      17.5      47.5     9.464    10.302     0.274
+      17.5      52.5     9.392    10.162     0.301
+      17.5      57.5     9.330    10.146     0.309
+      17.5      62.5     9.272    10.080     0.324
+      17.5      67.5     9.224    10.024     0.332
+      17.5      72.5     9.184     9.974     0.357
+      17.5      77.5     9.152     9.934     0.373
+      17.5      82.5     9.126     9.900     0.390
+      17.5      87.5     9.110     9.876     0.418
+      17.5      92.5     9.102     9.860     0.435
+      17.5      97.5     9.100     9.854     0.432
+      17.5     102.5     9.108     9.858     0.456
+      17.5     107.5     9.126     9.870     0.476
+      17.5     112.5     9.152     9.892     0.500
+      17.5     117.5     9.186     9.926     0.516
+      17.5     122.5     9.232     9.968     0.549
+      17.5     127.5     9.286    10.024     0.566
+      17.5     132.5     9.350    10.088     0.580
+      17.5     137.5     9.424    10.160     0.606
+      17.5     142.5     9.508    10.246     0.629
+      17.5     147.5     9.602    10.342     0.657
+      17.5     152.5     9.706    10.446     0.681
+      17.5     157.5     9.818    10.560     0.706
+      17.5     162.5     9.940    10.684     0.739
+      17.5     167.5    10.070    10.814     0.761
+      17.5     172.5    10.208    10.954     0.786
+      17.5     177.5    10.354    11.098     0.809
+      17.5     182.5    10.504    11.250     0.828
+      17.5     187.5    10.658    11.404     0.845
+      17.5     192.5    10.830    11.560     0.871
+      17.5     197.5    10.978    11.718     0.881
+      17.5     202.5    11.132    11.876     0.882
+      17.5     207.5    11.288    12.032     0.895
+      17.5     212.5    11.440    12.182     0.895
+      17.5     217.5    11.698    12.328     0.879
+      17.5     222.5    11.836    12.466     0.873
+      17.5     227.5    11.964    12.596     0.877
+      17.5     232.5    11.974    12.714     0.886
+      17.5     237.5    12.082    12.822     0.881
+      17.5     242.5    12.176    12.916     0.876
+      17.5     247.5    12.264    12.996     0.872
+      17.5     252.5    12.338    13.062     0.845
+      17.5     257.5    12.370    13.112     0.827
+      17.5     262.5    12.404    13.144     0.795
+      17.5     267.5    12.420    13.162     0.765
+      17.5     272.5    12.418    13.164     0.732
+      17.5     277.5    12.402    13.148     0.694
+      17.5     282.5    12.368    13.118     0.659
+      17.5     287.5    12.320    13.072     0.612
+      17.5     292.5    12.256    13.012     0.585
+      17.5     297.5    12.176    12.938     0.530
+      17.5     302.5    12.086    12.852     0.480
+      17.5     307.5    11.980    12.754     0.429
+      17.5     312.5    11.866    12.644     0.380
+      17.5     317.5    11.744    12.526     0.345
+      17.5     322.5    11.614    12.404     0.311
+      17.5     327.5    11.476    12.278     0.277
+      17.5     332.5    11.332    12.072     0.257
+      17.5     337.5    11.186    12.006     0.200
+      17.5     342.5    11.038    11.866     0.164
+      17.5     347.5    10.890    11.726     0.129
+      17.5     352.5    10.742    11.586     0.126
+      17.5     357.5    10.598    11.448     0.136
+      22.5       2.5    10.440    11.370     0.151
+      22.5       7.5    10.260    11.202     0.153
+      22.5      12.5    10.092    10.970     0.162
+      22.5      17.5     9.934    10.884     0.141
+      22.5      22.5     9.786    10.728     0.144
+      22.5      27.5     9.652    10.534     0.143
+      22.5      32.5     9.528    10.466     0.130
+      22.5      37.5     9.416    10.284     0.129
+      22.5      42.5     9.316    10.228     0.125
+      22.5      47.5     9.226    10.122     0.181
+      22.5      52.5     9.144     9.848     0.267
+      22.5      57.5     9.074     9.918     0.232
+      22.5      62.5     9.012     9.858     0.258
+      22.5      67.5     8.958     9.788     0.289
+      22.5      72.5     8.914     9.714     0.302
+      22.5      77.5     8.878     9.674     0.319
+      22.5      82.5     8.850     9.634     0.347
+      22.5      87.5     8.830     9.604     0.364
+      22.5      92.5     8.820     9.582     0.388
+      22.5      97.5     8.818     9.572     0.401
+      22.5     102.5     8.826     9.572     0.416
+      22.5     107.5     8.846     9.586     0.454
+      22.5     112.5     8.874     9.612     0.474
+      22.5     117.5     8.914     9.648     0.499
+      22.5     122.5     8.964     9.698     0.520
+      22.5     127.5     9.028     9.762     0.559
+      22.5     132.5     9.104     9.838     0.569
+      22.5     137.5     9.192     9.926     0.608
+      22.5     142.5     9.294    10.032     0.648
+      22.5     147.5     9.410    10.150     0.668
+      22.5     152.5     9.538    10.280     0.704
+      22.5     157.5     9.680    10.426     0.743
+      22.5     162.5     9.836    10.582     0.769
+      22.5     167.5    10.004    10.752     0.807
+      22.5     172.5    10.182    10.934     0.851
+      22.5     177.5    10.382    11.124     0.884
+      22.5     182.5    10.572    11.324     0.896
+      22.5     187.5    10.900    11.530     0.905
+      22.5     192.5    11.096    11.740     0.907
+      22.5     197.5    11.342    11.952     0.925
+      22.5     202.5    11.500    12.166     0.916
+      22.5     207.5    11.704    12.376     0.929
+      22.5     212.5    11.904    12.582     0.923
+      22.5     217.5    12.142    12.780     0.925
+      22.5     222.5    12.328    12.970     0.928
+      22.5     227.5    12.464    13.146     0.924
+      22.5     232.5    12.670    13.308     0.918
+      22.5     237.5    12.788    13.452     0.919
+      22.5     242.5    12.922    13.580     0.909
+      22.5     247.5    13.030    13.688     0.894
+      22.5     252.5    13.126    13.774     0.886
+      22.5     257.5    13.202    13.838     0.862
+      22.5     262.5    13.148    13.880     0.847
+      22.5     267.5    13.164    13.900     0.823
+      22.5     272.5    13.158    13.898     0.784
+      22.5     277.5    13.130    13.872     0.722
+      22.5     282.5    13.080    13.824     0.656
+      22.5     287.5    13.008    13.756     0.588
+      22.5     292.5    12.916    13.664     0.519
+      22.5     297.5    12.804    13.560     0.426
+      22.5     302.5    12.674    13.438     0.346
+      22.5     307.5    12.528    13.300     0.251
+      22.5     312.5    12.366    13.150     0.110
+      22.5     317.5    12.194    12.988     0.106
+      22.5     322.5    12.012    12.818     0.107
+      22.5     327.5    11.818    12.558     0.124
+      22.5     332.5    11.624    12.460     0.117
+      22.5     337.5    11.422    12.276     0.122
+      22.5     342.5    11.220    12.090     0.138
+      22.5     347.5    11.018    11.906     0.149
+      22.5     352.5    10.820    11.724     0.144
+      22.5     357.5    10.626    11.544     0.144
+      27.5       2.5    10.360    11.340     0.255
+      27.5       7.5    10.132    11.222     0.246
+      27.5      12.5     9.922    11.016     0.234
+      27.5      17.5     9.730    10.844     0.230
+      27.5      22.5     9.558    10.670     0.209
+      27.5      27.5     9.406    10.508     0.196
+      27.5      32.5     9.272    10.356     0.179
+      27.5      37.5     9.156     9.748     0.277
+      27.5      42.5     9.054     9.632     0.270
+      27.5      47.5     8.966     9.964     0.126
+      27.5      52.5     8.888     9.854     0.137
+      27.5      57.5     8.820     9.754     0.146
+      27.5      62.5     8.762     9.664     0.184
+      27.5      67.5     8.710     9.440     0.249
+      27.5      72.5     8.668     9.384     0.274
+      27.5      77.5     8.632     9.454     0.268
+      27.5      82.5     8.604     9.394     0.284
+      27.5      87.5     8.584     9.366     0.338
+      27.5      92.5     8.574     9.340     0.347
+      27.5      97.5     8.572     9.326     0.379
+      27.5     102.5     8.580     9.324     0.403
+      27.5     107.5     8.598     9.334     0.418
+      27.5     112.5     8.628     9.360     0.454
+      27.5     117.5     8.672     9.400     0.475
+      27.5     122.5     8.726     9.454     0.519
+      27.5     127.5     8.796     9.524     0.552
+      27.5     132.5     8.880     9.610     0.570
+      27.5     137.5     8.982     9.716     0.602
+      27.5     142.5     9.098     9.836     0.640
+      27.5     147.5     9.232     9.974     0.668
+      27.5     152.5     9.386    10.130     0.731
+      27.5     157.5     9.556    10.306     0.784
+      27.5     162.5     9.744    10.498     0.825
+      27.5     167.5     9.952    10.708     0.870
+      27.5     172.5    10.176    10.932     0.910
+      27.5     177.5    10.538    11.172     0.899
+      27.5     182.5    10.818    11.424     0.924
+      27.5     187.5    11.058    11.686     0.924
+      27.5     192.5    11.258    11.954     0.937
+      27.5     197.5    12.134    12.228     0.596
+      27.5     202.5    12.408    12.504     0.708
+      27.5     207.5    12.680    12.778     0.673
+      27.5     212.5    12.946    13.044     0.694
+      27.5     217.5    13.204    13.302     0.714
+      27.5     222.5    13.448    13.548     0.700
+      27.5     227.5    13.676    13.776     0.700
+      27.5     232.5    13.258    13.986     0.951
+      27.5     237.5    14.070    14.174     0.673
+      27.5     242.5    14.230    14.338     0.685
+      27.5     247.5    14.364    14.474     0.636
+      27.5     252.5    13.906    14.582     0.914
+      27.5     257.5    13.994    14.662     0.895
+      27.5     262.5    14.060    14.712     0.877
+      27.5     267.5    14.004    14.732     0.860
+      27.5     272.5    14.006    14.720     0.796
+      27.5     277.5    13.948    14.676     0.717
+      27.5     282.5    13.876    14.606     0.625
+      27.5     287.5    13.776    14.512     0.486
+      27.5     292.5    13.648    14.388     0.335
+      27.5     297.5    13.496    14.242     0.080
+      27.5     302.5    13.320    14.074     0.037
+      27.5     307.5    13.122    13.888     0.039
+      27.5     312.5    12.908    13.688     0.046
+      27.5     317.5    12.676    13.474     0.050
+      27.5     322.5    12.432    13.250     0.037
+      27.5     327.5    12.178    13.020     0.069
+      27.5     332.5    11.914    12.786     0.126
+      27.5     337.5    11.650    12.442     0.182
+      27.5     342.5    11.382    12.316     0.186
+      27.5     347.5    11.116    11.978     0.227
+      27.5     352.5    10.854    11.858     0.213
+      27.5     357.5    10.602    11.638     0.236
+      32.5       2.5    10.640    11.466     0.123
+      32.5       7.5    10.382    11.130     0.128
+      32.5      12.5    10.158    11.002     0.126
+      32.5      17.5     9.966    10.780     0.118
+      32.5      22.5     9.804    10.598     0.118
+      32.5      27.5     9.252     9.800     0.883
+      32.5      32.5     9.120    10.240     0.375
+      32.5      37.5     8.734    10.086     0.322
+      32.5      42.5     8.672     9.438     0.366
+      32.5      47.5     8.624     9.822     0.164
+      32.5      52.5     8.582     9.646     0.175
+      32.5      57.5     8.542     9.594     0.194
+      32.5      62.5     8.504     9.496     0.139
+      32.5      67.5     8.468     9.408     0.113
+      32.5      72.5     8.436     9.200     0.228
+      32.5      77.5     8.408     9.264     0.224
+      32.5      82.5     8.386     9.168     0.266
+      32.5      87.5     8.368     9.154     0.290
+      32.5      92.5     8.358     9.116     0.309
+      32.5      97.5     8.358     9.112     0.337
+      32.5     102.5     8.366     9.106     0.359
+      32.5     107.5     8.386     9.116     0.397
+      32.5     112.5     8.414     9.140     0.441
+      32.5     117.5     8.458     9.180     0.454
+      32.5     122.5     8.516     9.238     0.488
+      32.5     127.5     8.590     9.314     0.514
+      32.5     132.5     8.680     9.408     0.563
+      32.5     137.5     8.790     9.522     0.609
+      32.5     142.5     8.920     9.658     0.659
+      32.5     147.5     9.072     9.818     0.713
+      32.5     152.5     9.246     9.998     0.755
+      32.5     157.5     9.444    10.202     0.815
+      32.5     162.5     9.666    10.428     0.874
+      32.5     167.5    10.072    10.678     0.901
+      32.5     172.5    10.320    10.948     0.914
+      32.5     177.5    10.624    11.240     0.938
+      32.5     182.5    11.454    11.550     0.563
+      32.5     187.5    11.778    11.874     0.667
+      32.5     192.5    11.456    12.208     0.955
+      32.5     197.5    12.456    12.552     0.708
+      32.5     202.5    12.800    12.898     0.714
+      32.5     207.5    13.144    13.240     0.792
+      32.5     212.5    13.480    13.578     0.796
+      32.5     217.5    13.804    13.904     0.860
+      32.5     222.5    14.112    14.212     0.860
+      32.5     227.5    14.412    14.500     0.841
+      32.5     232.5    14.664    14.764     0.840
+      32.5     237.5    14.898    14.998     0.820
+      32.5     242.5    15.094    15.200     0.811
+      32.5     247.5    15.258    15.370     0.750
+      32.5     252.5    15.386    15.502     0.707
+      32.5     257.5    14.940    15.596     0.930
+      32.5     262.5    14.976    15.650     0.899
+      32.5     267.5    15.018    15.666     0.855
+      32.5     272.5    14.930    15.642     0.787
+      32.5     277.5    14.868    15.580     0.660
+      32.5     282.5    14.768    15.482     0.440
+      32.5     287.5    14.632    15.348     0.201
+      32.5     292.5    14.462    15.180     0.050
+      32.5     297.5    14.260    14.984     0.052
+      32.5     302.5    14.030    14.762     0.060
+      32.5     307.5    13.772    14.516     0.056
+      32.5     312.5    13.492    14.256     0.068
+      32.5     317.5    13.190    13.666     0.105
+      32.5     322.5    12.872    13.698     0.061
+      32.5     327.5    12.540    13.262     0.125
+      32.5     332.5    12.196    12.978     0.228
+      32.5     337.5    11.844    12.692     0.318
+      32.5     342.5    11.488    12.408     0.393
+      32.5     347.5    11.132    12.256     0.413
+      32.5     352.5    10.774    11.982     0.412
+      32.5     357.5    10.928    11.718     0.127
+      37.5       2.5    11.154    11.470     0.013
+      37.5       7.5    10.888    11.196     0.013
+      37.5      12.5    10.640    10.944     0.013
+      37.5      17.5     9.336    10.712     0.728
+      37.5      22.5     9.278    10.500     0.584
+      37.5      27.5     8.702    10.218     0.689
+      37.5      32.5     8.942    10.048     0.548
+      37.5      37.5     9.000     9.700     0.540
+      37.5      42.5     9.002     9.824     0.280
+      37.5      47.5     8.634     9.448     0.555
+      37.5      52.5     8.064     9.504     0.522
+      37.5      57.5     8.170     9.252     0.246
+      37.5      62.5     8.188     9.350     0.164
+      37.5      67.5     8.204     9.096     0.155
+      37.5      72.5     8.204     9.170     0.116
+      37.5      77.5     8.196     9.102     0.170
+      37.5      82.5     8.186     9.030     0.209
+      37.5      87.5     8.178     8.966     0.246
+      37.5      92.5     8.178     8.956     0.275
+      37.5      97.5     8.190     8.932     0.318
+      37.5     102.5     8.180     8.922     0.372
+      37.5     107.5     8.202     8.926     0.403
+      37.5     112.5     8.232     8.948     0.427
+      37.5     117.5     8.272     8.988     0.469
+      37.5     122.5     8.332     9.046     0.501
+      37.5     127.5     8.422     9.126     0.531
+      37.5     132.5     8.508     9.226     0.577
+      37.5     137.5     8.620     9.350     0.622
+      37.5     142.5     8.760     9.500     0.651
+      37.5     147.5     8.926     9.674     0.725
+      37.5     152.5     9.120     9.878     0.794
+      37.5     157.5     9.344    10.110     0.883
+      37.5     162.5     9.606    10.372     0.930
+      37.5     167.5    10.040    10.664     0.913
+      37.5     172.5    10.888    10.984     0.562
+      37.5     177.5    11.234    11.332     0.592
+      37.5     182.5    11.606    11.704     0.673
+      37.5     187.5    11.998    12.096     0.714
+      37.5     192.5    12.408    12.506     0.755
+      37.5     197.5    12.830    12.928     0.816
+      37.5     202.5    13.258    13.352     0.851
+      37.5     207.5    13.690    13.778     0.909
+      37.5     212.5    14.104    14.194     0.889
+      37.5     217.5    14.504    14.596     0.891
+      37.5     222.5    14.882    14.976     0.936
+      37.5     227.5    15.234    15.332     0.878
+      37.5     232.5    15.556    15.654     0.898
+      37.5     237.5    15.840    15.940     0.880
+      37.5     242.5    16.084    16.186     0.843
+      37.5     247.5    16.284    16.390     0.830
+      37.5     252.5    16.432    16.546     0.789
+      37.5     257.5    16.528    16.654     0.714
+      37.5     262.5    16.026    16.712     0.924
+      37.5     267.5    16.062    16.720     0.842
+      37.5     272.5    15.988    16.678     0.722
+      37.5     277.5    15.902    16.588     0.469
+      37.5     282.5    15.768    16.450     0.059
+      37.5     287.5    15.590    16.266     0.024
+      37.5     292.5    15.368    16.042     0.006
+      37.5     297.5    15.108    15.780     0.006
+      37.5     302.5    14.810    15.486     0.000
+      37.5     307.5    14.480    15.170     0.006
+      37.5     312.5    14.120    14.350     0.009
+      37.5     317.5    13.734    14.010     0.101
+      37.5     322.5    13.322    14.152     0.060
+      37.5     327.5    12.888    13.590     0.439
+      37.5     332.5    12.464    13.270     0.533
+      37.5     337.5    12.334    13.094     0.187
+      37.5     342.5    11.816    12.744     0.190
+      37.5     347.5    11.242    12.404     0.513
+      37.5     352.5    10.966    12.076     0.616
+      37.5     357.5    11.438    11.764     0.031
+      42.5       2.5    11.060    11.382     0.205
+      42.5       7.5    10.748    11.070     0.217
+      42.5      12.5    10.472    10.794     0.199
+      42.5      17.5    10.234    10.550     0.171
+      42.5      22.5    10.030    10.336     0.150
+      42.5      27.5     9.844    10.146     0.113
+      42.5      32.5     9.684     9.976     0.041
+      42.5      37.5     8.314     9.822     0.809
+      42.5      42.5     7.784     9.682     0.778
+      42.5      47.5     8.408     9.544     0.546
+      42.5      52.5     8.580     9.434     0.319
+      42.5      57.5     8.200     9.316     0.464
+      42.5      62.5     7.806     9.038     0.448
+      42.5      67.5     7.836     9.128     0.241
+      42.5      72.5     7.962     9.044     0.150
+      42.5      77.5     7.996     8.842     0.137
+      42.5      82.5     8.016     8.904     0.162
+      42.5      87.5     8.006     8.850     0.239
+      42.5      92.5     8.012     8.718     0.309
+      42.5      97.5     8.014     8.778     0.309
+      42.5     102.5     8.024     8.764     0.327
+      42.5     107.5     8.044     8.756     0.393
+      42.5     112.5     8.072     8.784     0.419
+      42.5     117.5     8.114     8.814     0.457
+      42.5     122.5     8.172     8.880     0.494
+      42.5     127.5     8.248     8.960     0.551
+      42.5     132.5     8.348     9.064     0.587
+      42.5     137.5     8.480     9.196     0.612
+      42.5     142.5     8.616     9.356     0.654
+      42.5     147.5     8.794     9.546     0.742
+      42.5     152.5     9.006     9.770     0.846
+      42.5     157.5     9.302    10.030     0.909
+      42.5     162.5     9.728    10.328     0.920
+      42.5     167.5    10.566    10.662     0.542
+      42.5     172.5    10.936    11.034     0.571
+      42.5     177.5    11.344    11.444     0.660
+      42.5     182.5    11.786    11.886     0.720
+      42.5     187.5    12.258    12.358     0.760
+      42.5     192.5    12.768    12.852     0.833
+      42.5     197.5    13.274    13.362     0.864
+      42.5     202.5    13.786    13.880     0.936
+      42.5     207.5    14.300    14.398     0.878
+      42.5     212.5    14.812    14.906     0.915
+      42.5     217.5    15.298    15.394     0.958
+      42.5     222.5    15.760    15.858     0.918
+      42.5     227.5    16.278    16.288     0.800
+      42.5     232.5    16.576    16.678     0.941
+      42.5     237.5    16.918    17.022     0.942
+      42.5     242.5    17.208    17.314     0.906
+      42.5     247.5    17.446    17.554     0.926
+      42.5     252.5    17.614    17.734     0.850
+      42.5     257.5    17.726    17.854     0.797
+      42.5     262.5    17.254    17.912     0.927
+      42.5     267.5    17.242    17.906     0.780
+      42.5     272.5    17.184    17.838     0.508
+      42.5     277.5    17.066    17.708     0.031
+      42.5     282.5    16.892    17.514     0.000
+      42.5     287.5    16.658    16.658     1.000
+      42.5     292.5    16.374    16.374     1.000
+      42.5     297.5    16.042    16.042     1.000
+      42.5     302.5    15.666    15.666     1.000
+      42.5     307.5    15.248    15.248     1.000
+      42.5     312.5    14.794    15.102     0.000
+      42.5     317.5    14.300    14.544     0.156
+      42.5     322.5    13.764    14.334     0.537
+      42.5     327.5    13.532    13.932     0.455
+      42.5     332.5    12.806    13.572     0.287
+      42.5     337.5    12.966    13.192     0.044
+      42.5     342.5    12.582    12.892     0.026
+      42.5     347.5    12.180    12.500     0.025
+      42.5     352.5    11.784    12.100     0.152
+      42.5     357.5    11.408    11.726     0.220
+      47.5       2.5    10.430    10.958     0.458
+      47.5       7.5    10.066    10.608     0.472
+      47.5      12.5     9.822    10.338     0.469
+      47.5      17.5     9.664    10.132     0.402
+      47.5      22.5     9.524     9.970     0.363
+      47.5      27.5     7.426     9.830     0.879
+      47.5      32.5     7.652     9.716     0.868
+      47.5      37.5     9.282     9.602     0.169
+      47.5      42.5     9.198     9.494     0.122
+      47.5      47.5     9.116     9.396     0.057
+      47.5      52.5     7.508     9.082     0.917
+      47.5      57.5     8.164     9.198     0.497
+      47.5      62.5     7.158     8.914     0.780
+      47.5      67.5     7.510     9.016     0.568
+      47.5      72.5     7.612     8.932     0.276
+      47.5      77.5     7.730     8.720     0.212
+      47.5      82.5     7.820     8.672     0.178
+      47.5      87.5     7.850     8.734     0.188
+      47.5      92.5     7.868     8.688     0.232
+      47.5      97.5     7.880     8.630     0.277
+      47.5     102.5     7.894     8.634     0.319
+      47.5     107.5     7.914     8.622     0.381
+      47.5     112.5     7.942     8.646     0.403
+      47.5     117.5     7.982     8.680     0.450
+      47.5     122.5     8.038     8.736     0.481
+      47.5     127.5     8.114     8.816     0.527
+      47.5     132.5     8.210     8.922     0.590
+      47.5     137.5     8.336     9.058     0.634
+      47.5     142.5     8.486     9.226     0.705
+      47.5     147.5     8.678     9.432     0.759
+      47.5     152.5     8.904     9.674     0.896
+      47.5     157.5     9.448     9.962     0.922
+      47.5     162.5     9.726    10.292     0.908
+      47.5     167.5    10.572    10.672     0.560
+      47.5     172.5    11.000    11.100     0.640
+      47.5     177.5    11.474    11.576     0.706
+      47.5     182.5    11.992    12.098     0.755
+      47.5     187.5    12.556    12.658     0.882
+      47.5     192.5    13.156    13.250     0.872
+      47.5     197.5    13.764    13.864     0.940
+      47.5     202.5    14.392    14.490     0.939
+      47.5     207.5    15.116    15.116     1.000
+      47.5     212.5    15.728    15.728     1.000
+      47.5     217.5    16.318    16.318     1.000
+      47.5     222.5    16.866    16.876     0.800
+      47.5     227.5    17.392    17.392     1.000
+      47.5     232.5    17.844    17.856     0.833
+      47.5     237.5    18.262    18.262     1.000
+      47.5     242.5    18.594    18.606     0.833
+      47.5     247.5    18.870    18.884     0.714
+      47.5     252.5    18.966    19.088     0.951
+      47.5     257.5    19.084    19.218     0.866
+      47.5     262.5    19.118    19.270     0.737
+      47.5     267.5    18.624    19.244     0.671
+      47.5     272.5    18.540    19.134     0.034
+      47.5     277.5    18.384    18.940     0.000
+      47.5     282.5    18.154    18.154     1.000
+      47.5     287.5    17.858    17.858     1.000
+      47.5     292.5    17.498    17.498     1.000
+      47.5     297.5    17.082    17.082     1.000
+      47.5     302.5    16.610    16.610     1.000
+      47.5     307.5    16.086    16.086     1.000
+      47.5     312.5    15.510    15.510     1.000
+      47.5     317.5    14.874    15.064     0.547
+      47.5     322.5    14.460    14.726     0.827
+      47.5     327.5    14.170    14.366     0.041
+      47.5     332.5    13.732    14.072     0.053
+      47.5     337.5    13.200    13.524     0.272
+      47.5     342.5    12.632    12.968     0.375
+      47.5     347.5    12.046    12.416     0.449
+      47.5     352.5    11.460    11.882     0.483
+      47.5     357.5    10.906    11.388     0.494
+      52.5       2.5     8.470     9.446     0.916
+      52.5       7.5     8.342     9.216     0.913
+      52.5      12.5     8.020     9.048     0.911
+      52.5      17.5     7.826     8.948     0.907
+      52.5      22.5     7.798     8.932     0.880
+      52.5      27.5     7.454     9.008     0.873
+      52.5      32.5     7.290     9.114     0.855
+      52.5      37.5     7.514     9.186     0.812
+      52.5      42.5     8.794     9.200     0.305
+      52.5      47.5     7.476     9.172     0.853
+      52.5      52.5     7.136     9.126     0.868
+      52.5      57.5     7.166     9.062     0.862
+      52.5      62.5     7.752     8.922     0.644
+      52.5      67.5     8.124     8.738     0.381
+      52.5      72.5     7.156     8.682     0.720
+      52.5      77.5     7.522     8.624     0.314
+      52.5      82.5     7.620     8.702     0.194
+      52.5      87.5     7.698     8.538     0.164
+      52.5      92.5     7.744     8.594     0.216
+      52.5      97.5     7.774     8.556     0.263
+      52.5     102.5     7.788     8.520     0.290
+      52.5     107.5     7.810     8.524     0.339
+      52.5     112.5     7.836     8.532     0.388
+      52.5     117.5     7.882     8.562     0.432
+      52.5     122.5     7.940     8.608     0.485
+      52.5     127.5     8.000     8.692     0.538
+      52.5     132.5     8.102     8.800     0.579
+      52.5     137.5     8.222     8.938     0.662
+      52.5     142.5     8.384     9.112     0.728
+      52.5     147.5     8.576     9.328     0.843
+      52.5     152.5     8.826     9.588     0.911
+      52.5     157.5     9.386     9.900     0.899
+      52.5     162.5     9.684    10.266     0.914
+      52.5     167.5    10.588    10.690     0.549
+      52.5     172.5    11.074    11.178     0.654
+      52.5     177.5    11.622    11.728     0.755
+      52.5     182.5    12.234    12.338     0.846
+      52.5     187.5    12.904    13.002     0.878
+      52.5     192.5    13.608    13.708     0.960
+      52.5     197.5    14.436    14.444     0.750
+      52.5     202.5    15.196    15.196     1.000
+      52.5     207.5    15.948    15.948     1.000
+      52.5     212.5    16.684    16.684     1.000
+      52.5     217.5    17.390    17.390     1.000
+      52.5     222.5    18.054    18.054     1.000
+      52.5     227.5    18.666    18.666     1.000
+      52.5     232.5    19.214    19.214     1.000
+      52.5     237.5    19.692    19.692     1.000
+      52.5     242.5    20.090    20.090     1.000
+      52.5     247.5    20.406    20.406     1.000
+      52.5     252.5    20.616    20.634     0.889
+      52.5     257.5    20.626    20.770     0.917
+      52.5     262.5    20.636    20.808     0.674
+      52.5     267.5    20.198    20.744     0.253
+      52.5     272.5    20.082    20.558     0.000
+      52.5     277.5    19.872    19.872     1.000
+      52.5     282.5    19.578    19.578     1.000
+      52.5     287.5    19.204    19.204     1.000
+      52.5     292.5    18.754    18.754     1.000
+      52.5     297.5    18.234    18.234     1.000
+      52.5     302.5    17.650    17.650     1.000
+      52.5     307.5    16.998    16.998     1.000
+      52.5     312.5    16.264    16.264     1.000
+      52.5     317.5    15.768    15.768     1.000
+      52.5     322.5    15.236    15.350     0.070
+      52.5     327.5    14.646    14.968     0.280
+      52.5     332.5    13.894    14.238     0.535
+      52.5     337.5    12.946    13.404     0.742
+      52.5     342.5    11.422    12.350     0.828
+      52.5     347.5    10.340    10.882     0.705
+      52.5     352.5     9.872    10.156     0.690
+      52.5     357.5     8.664     9.744     0.919
+      57.5       2.5     9.104     9.164     0.467
+      57.5       7.5     8.340     8.924     0.736
+      57.5      12.5     8.118     8.710     0.753
+      57.5      17.5     7.804     8.520     0.844
+      57.5      22.5     7.598     8.368     0.888
+      57.5      27.5     7.310     8.264     0.916
+      57.5      32.5     7.078     8.234     0.926
+      57.5      37.5     7.998     8.326     0.640
+      57.5      42.5     7.196     8.562     0.861
+      57.5      47.5     8.284     8.772     0.381
+      57.5      52.5     7.244     8.870     0.825
+      57.5      57.5     8.572     8.888     0.196
+      57.5      62.5     8.584     8.860     0.065
+      57.5      67.5     7.386     8.818     0.691
+      57.5      72.5     7.970     8.690     0.308
+      57.5      77.5     7.436     8.550     0.614
+      57.5      82.5     7.450     8.634     0.243
+      57.5      87.5     7.568     8.534     0.182
+      57.5      92.5     7.628     8.428     0.190
+      57.5      97.5     7.682     8.400     0.248
+      57.5     102.5     7.704     8.440     0.285
+      57.5     107.5     7.728     8.440     0.329
+      57.5     112.5     7.756     8.444     0.355
+      57.5     117.5     7.792     8.468     0.464
+      57.5     122.5     7.866     8.510     0.463
+      57.5     127.5     7.918     8.584     0.535
+      57.5     132.5     8.008     8.696     0.599
+      57.5     137.5     8.132     8.834     0.638
+      57.5     142.5     8.280     9.012     0.730
+      57.5     147.5     8.482     9.236     0.883
+      57.5     152.5     8.732     9.510     0.920
+      57.5     157.5     9.334     9.842     0.921
+      57.5     162.5    10.142    10.242     0.580
+      57.5     167.5    10.608    10.714     0.642
+      57.5     172.5    11.156    11.264     0.722
+      57.5     177.5    11.786    11.896     0.855
+      57.5     182.5    12.508    12.608     0.900
+      57.5     187.5    13.288    13.390     0.941
+      57.5     192.5    14.232    14.232     1.000
+      57.5     197.5    15.112    15.112     1.000
+      57.5     202.5    16.014    16.014     1.000
+      57.5     207.5    16.914    16.914     1.000
+      57.5     212.5    17.792    17.792     1.000
+      57.5     217.5    18.634    18.634     1.000
+      57.5     222.5    19.422    19.422     1.000
+      57.5     227.5    20.142    20.142     1.000
+      57.5     232.5    20.784    20.784     1.000
+      57.5     237.5    21.340    21.340     1.000
+      57.5     242.5    21.798    21.798     1.000
+      57.5     247.5    22.156    22.156     1.000
+      57.5     252.5    22.404    22.404     1.000
+      57.5     257.5    22.380    22.536     0.962
+      57.5     262.5    22.052    22.544     0.748
+      57.5     267.5    21.998    21.998     1.000
+      57.5     272.5    21.836    21.836     1.000
+      57.5     277.5    21.566    21.566     1.000
+      57.5     282.5    21.190    21.190     1.000
+      57.5     287.5    20.720    20.720     1.000
+      57.5     292.5    20.160    20.160     1.000
+      57.5     297.5    19.520    19.520     1.000
+      57.5     302.5    18.800    18.800     1.000
+      57.5     307.5    17.988    17.988     1.000
+      57.5     312.5    17.106    17.106     1.000
+      57.5     317.5    16.506    16.660     0.156
+      57.5     322.5    15.776    16.090     0.516
+      57.5     327.5    14.680    15.070     0.815
+      57.5     332.5    13.848    13.848     1.000
+      57.5     337.5    13.078    13.078     1.000
+      57.5     342.5    12.294    12.294     1.000
+      57.5     347.5    11.500    11.500     1.000
+      57.5     352.5    10.700    10.700     1.000
+      57.5     357.5     9.896     9.896     1.000
+      62.5       2.5    10.332    10.332     1.000
+      62.5       7.5     9.452     9.452     1.000
+      62.5      12.5     8.696     8.754     0.448
+      62.5      17.5     7.984     8.518     0.551
+      62.5      22.5     7.744     8.304     0.632
+      62.5      27.5     7.488     8.118     0.737
+      62.5      32.5     7.242     7.974     0.817
+      62.5      37.5     7.006     7.886     0.902
+      62.5      42.5     7.114     7.884     0.894
+      62.5      47.5     7.338     8.044     0.822
+      62.5      52.5     7.886     8.378     0.537
+      62.5      57.5     8.192     8.610     0.340
+      62.5      62.5     8.370     8.698     0.189
+      62.5      67.5     7.338     8.706     0.810
+      62.5      72.5     7.290     8.664     0.681
+      62.5      77.5     7.896     8.638     0.205
+      62.5      82.5     7.214     8.584     0.498
+      62.5      87.5     7.398     8.528     0.232
+      62.5      92.5     7.508     8.440     0.204
+      62.5      97.5     7.598     8.434     0.196
+      62.5     102.5     7.642     8.400     0.269
+      62.5     107.5     7.674     8.372     0.309
+      62.5     112.5     7.698     8.380     0.364
+      62.5     117.5     7.736     8.400     0.407
+      62.5     122.5     7.784     8.434     0.489
+      62.5     127.5     7.850     8.504     0.529
+      62.5     132.5     7.948     8.610     0.601
+      62.5     137.5     8.060     8.748     0.645
+      62.5     142.5     8.204     8.920     0.746
+      62.5     147.5     8.406     9.154     0.858
+      62.5     152.5     8.754     9.440     0.915
+      62.5     157.5     9.702     9.790     0.568
+      62.5     162.5    10.116    10.220     0.538
+      62.5     167.5    10.626    10.738     0.536
+      62.5     172.5    11.242    11.354     0.786
+      62.5     177.5    11.980    12.076     0.875
+      62.5     182.5    12.800    12.904     0.942
+      62.5     187.5    13.828    13.828     1.000
+      62.5     192.5    14.830    14.830     1.000
+      62.5     197.5    15.884    15.884     1.000
+      62.5     202.5    16.964    16.964     1.000
+      62.5     207.5    18.040    18.040     1.000
+      62.5     212.5    19.088    19.088     1.000
+      62.5     217.5    20.086    20.086     1.000
+      62.5     222.5    21.014    21.014     1.000
+      62.5     227.5    21.858    21.858     1.000
+      62.5     232.5    22.606    22.606     1.000
+      62.5     237.5    23.246    23.246     1.000
+      62.5     242.5    23.768    23.768     1.000
+      62.5     247.5    24.166    24.166     1.000
+      62.5     252.5    24.428    24.428     1.000
+      62.5     257.5    24.364    24.542     0.865
+      62.5     262.5    24.158    24.428     0.170
+      62.5     267.5    24.068    24.068     1.000
+      62.5     272.5    23.848    23.848     1.000
+      62.5     277.5    23.496    23.496     1.000
+      62.5     282.5    23.018    23.018     1.000
+      62.5     287.5    22.428    22.428     1.000
+      62.5     292.5    21.738    21.738     1.000
+      62.5     297.5    20.960    20.960     1.000
+      62.5     302.5    20.258    20.258     1.000
+      62.5     307.5    19.602    19.602     1.000
+      62.5     312.5    18.894    18.894     1.000
+      62.5     317.5    18.138    18.138     1.000
+      62.5     322.5    17.344    17.344     1.000
+      62.5     327.5    16.516    16.516     1.000
+      62.5     332.5    15.662    15.662     1.000
+      62.5     337.5    14.792    14.792     1.000
+      62.5     342.5    13.906    13.906     1.000
+      62.5     347.5    13.010    13.010     1.000
+      62.5     352.5    12.116    12.116     1.000
+      62.5     357.5    11.222    11.222     1.000
+      67.5       2.5    11.650    11.650     1.000
+      67.5       7.5    10.674    10.674     1.000
+      67.5      12.5     9.716     9.716     1.000
+      67.5      17.5     8.774     8.774     1.000
+      67.5      22.5     7.928     8.408     0.458
+      67.5      27.5     7.678     8.176     0.530
+      67.5      32.5     7.416     7.970     0.588
+      67.5      37.5     7.170     7.800     0.679
+      67.5      42.5     7.006     7.680     0.858
+      67.5      47.5     7.052     7.638     0.891
+      67.5      52.5     7.474     7.736     0.672
+      67.5      57.5     7.052     8.076     0.818
+      67.5      62.5     7.996     8.420     0.354
+      67.5      67.5     8.232     8.564     0.217
+      67.5      72.5     7.112     8.600     0.825
+      67.5      77.5     7.406     8.424     0.688
+      67.5      82.5     7.042     8.550     0.633
+      67.5      87.5     7.306     8.376     0.329
+      67.5      92.5     7.380     8.408     0.241
+      67.5      97.5     7.540     8.368     0.169
+      67.5     102.5     7.596     8.372     0.242
+      67.5     107.5     7.640     8.342     0.302
+      67.5     112.5     7.664     8.340     0.349
+      67.5     117.5     7.700     8.352     0.396
+      67.5     122.5     7.744     8.388     0.475
+      67.5     127.5     7.810     8.452     0.486
+      67.5     132.5     7.904     8.540     0.591
+      67.5     137.5     8.024     8.680     0.655
+      67.5     142.5     8.150     8.856     0.756
+      67.5     147.5     8.352     9.084     0.885
+      67.5     152.5     8.888     9.374     0.905
+      67.5     157.5     9.248     9.740     0.907
+      67.5     162.5    10.090    10.194     0.500
+      67.5     167.5    10.642    10.756     0.667
+      67.5     172.5    11.322    11.440     0.797
+      67.5     177.5    12.152    12.260     0.889
+      67.5     182.5    13.222    13.222     1.000
+      67.5     187.5    14.314    14.314     1.000
+      67.5     192.5    15.512    15.512     1.000
+      67.5     197.5    16.778    16.778     1.000
+      67.5     202.5    18.072    18.072     1.000
+      67.5     207.5    19.360    19.360     1.000
+      67.5     212.5    20.606    20.606     1.000
+      67.5     217.5    21.784    21.784     1.000
+      67.5     222.5    22.876    22.876     1.000
+      67.5     227.5    23.860    23.860     1.000
+      67.5     232.5    24.726    24.726     1.000
+      67.5     237.5    25.458    25.458     1.000
+      67.5     242.5    26.046    26.046     1.000
+      67.5     247.5    26.480    26.480     1.000
+      67.5     252.5    26.742    26.742     1.000
+      67.5     257.5    26.566    26.758     0.563
+      67.5     262.5    26.592    26.592     1.000
+      67.5     267.5    26.458    26.458     1.000
+      67.5     272.5    26.160    26.160     1.000
+      67.5     277.5    25.700    25.700     1.000
+      67.5     282.5    25.094    25.094     1.000
+      67.5     287.5    24.676    24.676     1.000
+      67.5     292.5    24.186    24.186     1.000
+      67.5     297.5    23.604    23.604     1.000
+      67.5     302.5    22.938    22.938     1.000
+      67.5     307.5    22.194    22.194     1.000
+      67.5     312.5    21.388    21.388     1.000
+      67.5     317.5    20.524    20.524     1.000
+      67.5     322.5    19.610    19.610     1.000
+      67.5     327.5    18.660    18.660     1.000
+      67.5     332.5    17.680    17.680     1.000
+      67.5     337.5    16.682    16.682     1.000
+      67.5     342.5    15.670    15.670     1.000
+      67.5     347.5    14.656    14.656     1.000
+      67.5     352.5    13.646    13.646     1.000
+      67.5     357.5    12.642    12.642     1.000
+      72.5       2.5    13.088    13.088     1.000
+      72.5       7.5    11.996    11.996     1.000
+      72.5      12.5    10.930    10.930     1.000
+      72.5      17.5     9.898     9.898     1.000
+      72.5      22.5     8.890     8.890     1.000
+      72.5      27.5     7.912     8.336     0.392
+      72.5      32.5     7.608     8.082     0.422
+      72.5      37.5     7.342     7.858     0.488
+      72.5      42.5     7.098     7.672     0.551
+      72.5      47.5     7.004     7.534     0.766
+      72.5      52.5     7.008     7.470     0.870
+      72.5      57.5     7.104     7.554     0.831
+      72.5      62.5     7.048     7.904     0.806
+      72.5      67.5     7.896     8.314     0.344
+      72.5      72.5     8.170     8.484     0.191
+      72.5      77.5     7.172     8.534     0.815
+      72.5      82.5     7.606     8.510     0.462
+      72.5      87.5     7.176     8.358     0.645
+      72.5      92.5     7.240     8.338     0.346
+      72.5      97.5     7.462     8.310     0.189
+      72.5     102.5     7.570     8.286     0.218
+      72.5     107.5     7.618     8.324     0.252
+      72.5     112.5     7.652     8.324     0.307
+      72.5     117.5     7.686     8.330     0.391
+      72.5     122.5     7.726     8.358     0.440
+      72.5     127.5     7.802     8.414     0.503
+      72.5     132.5     7.888     8.502     0.577
+      72.5     137.5     7.994     8.628     0.637
+      72.5     142.5     8.120     8.800     0.732
+      72.5     147.5     8.308     9.024     0.874
+      72.5     152.5     8.676     9.316     0.931
+      72.5     157.5     9.584     9.690     0.660
+      72.5     162.5    10.058    10.164     0.585
+      72.5     167.5    10.644    10.762     0.610
+      72.5     172.5    11.392    11.512     0.833
+      72.5     177.5    12.330    12.440     0.945
+      72.5     182.5    13.554    13.554     1.000
+      72.5     187.5    14.850    14.850     1.000
+      72.5     192.5    16.288    16.288     1.000
+      72.5     197.5    17.814    17.814     1.000
+      72.5     202.5    19.372    19.372     1.000
+      72.5     207.5    20.912    20.912     1.000
+      72.5     212.5    22.392    22.392     1.000
+      72.5     217.5    23.784    23.784     1.000
+      72.5     222.5    25.060    25.060     1.000
+      72.5     227.5    26.204    26.204     1.000
+      72.5     232.5    27.198    27.198     1.000
+      72.5     237.5    28.030    28.030     1.000
+      72.5     242.5    28.684    28.684     1.000
+      72.5     247.5    29.142    29.142     1.000
+      72.5     252.5    29.332    29.336     0.000
+      72.5     257.5    29.434    29.434     1.000
+      72.5     262.5    29.432    29.432     1.000
+      72.5     267.5    29.232    29.232     1.000
+      72.5     272.5    29.036    29.036     1.000
+      72.5     277.5    28.874    28.874     1.000
+      72.5     282.5    28.572    28.572     1.000
+      72.5     287.5    28.138    28.138     1.000
+      72.5     292.5    27.580    27.580     1.000
+      72.5     297.5    26.908    26.908     1.000
+      72.5     302.5    26.130    26.130     1.000
+      72.5     307.5    25.264    25.264     1.000
+      72.5     312.5    24.316    24.316     1.000
+      72.5     317.5    23.304    23.304     1.000
+      72.5     322.5    22.236    22.236     1.000
+      72.5     327.5    21.124    21.124     1.000
+      72.5     332.5    19.986    19.986     1.000
+      72.5     337.5    18.828    18.828     1.000
+      72.5     342.5    17.660    17.660     1.000
+      72.5     347.5    16.498    16.498     1.000
+      72.5     352.5    15.344    15.344     1.000
+      72.5     357.5    14.204    14.204     1.000
+      77.5       2.5    14.692    14.692     1.000
+      77.5       7.5    13.456    13.456     1.000
+      77.5      12.5    12.264    12.264     1.000
+      77.5      17.5    11.112    11.112     1.000
+      77.5      22.5    10.004    10.004     1.000
+      77.5      27.5     8.936     8.936     1.000
+      77.5      32.5     7.906     8.266     0.372
+      77.5      37.5     7.530     7.994     0.358
+      77.5      42.5     7.264     7.760     0.419
+      77.5      47.5     7.024     7.566     0.517
+      77.5      52.5     7.002     7.428     0.685
+      77.5      57.5     7.090     7.362     0.801
+      77.5      62.5     7.066     7.452     0.808
+      77.5      67.5     7.420     7.846     0.592
+      77.5      72.5     7.892     8.290     0.312
+      77.5      77.5     8.162     8.462     0.160
+      77.5      82.5     7.436     8.504     0.738
+      77.5      87.5     7.752     8.358     0.380
+      77.5      92.5     7.212     8.420     0.349
+      77.5      97.5     7.388     8.424     0.214
+      77.5     102.5     7.550     8.234     0.225
+      77.5     107.5     7.618     8.274     0.256
+      77.5     112.5     7.662     8.332     0.304
+      77.5     117.5     7.696     8.332     0.343
+      77.5     122.5     7.740     8.352     0.425
+      77.5     127.5     7.790     8.394     0.490
+      77.5     132.5     7.858     8.472     0.567
+      77.5     137.5     7.994     8.596     0.618
+      77.5     142.5     8.142     8.758     0.718
+      77.5     147.5     8.292     8.978     0.886
+      77.5     152.5     8.542     9.264     0.928
+      77.5     157.5     9.190     9.638     0.902
+      77.5     162.5    10.018    10.122     0.596
+      77.5     167.5    10.628    10.750     0.656
+      77.5     172.5    11.458    11.560     0.824
+      77.5     177.5    12.582    12.596     0.857
+      77.5     182.5    13.888    13.888     1.000
+      77.5     187.5    15.430    15.430     1.000
+      77.5     192.5    17.168    17.168     1.000
+      77.5     197.5    19.022    19.022     1.000
+      77.5     202.5    20.904    20.904     1.000
+      77.5     207.5    22.750    22.750     1.000
+      77.5     212.5    24.508    24.508     1.000
+      77.5     217.5    26.144    26.144     1.000
+      77.5     222.5    27.634    27.634     1.000
+      77.5     227.5    28.956    28.956     1.000
+      77.5     232.5    30.092    30.092     1.000
+      77.5     237.5    31.026    31.026     1.000
+      77.5     242.5    31.734    31.734     1.000
+      77.5     247.5    32.210    32.210     1.000
+      77.5     252.5    32.628    32.628     1.000
+      77.5     257.5    32.926    32.926     1.000
+      77.5     262.5    33.312    33.312     1.000
+      77.5     267.5    33.502    33.502     1.000
+      77.5     272.5    33.502    33.502     1.000
+      77.5     277.5    33.324    33.324     1.000
+      77.5     282.5    32.966    32.966     1.000
+      77.5     287.5    32.452    32.452     1.000
+      77.5     292.5    31.782    31.782     1.000
+      77.5     297.5    30.974    30.974     1.000
+      77.5     302.5    30.038    30.038     1.000
+      77.5     307.5    28.994    28.994     1.000
+      77.5     312.5    27.856    27.856     1.000
+      77.5     317.5    26.640    26.640     1.000
+      77.5     322.5    25.362    25.362     1.000
+      77.5     327.5    24.042    24.042     1.000
+      77.5     332.5    22.690    22.690     1.000
+      77.5     337.5    21.328    21.328     1.000
+      77.5     342.5    19.962    19.962     1.000
+      77.5     347.5    18.606    18.606     1.000
+      77.5     352.5    17.272    17.272     1.000
+      77.5     357.5    15.964    15.964     1.000
Index: /tags/Mars_V0-8-5/Mars/mfilter/gcplus.txt
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfilter/gcplus.txt	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfilter/gcplus.txt	(revision 9661)
@@ -0,0 +1,1152 @@
+       2.5       2.5    10.784    11.906     0.715
+       2.5       7.5    10.804    11.926     0.720
+       2.5      12.5    10.824    11.946     0.724
+       2.5      17.5    10.842    11.962     0.727
+       2.5      22.5    10.860    11.980     0.732
+       2.5      27.5    10.876    11.994     0.735
+       2.5      32.5    10.890    12.008     0.741
+       2.5      37.5    10.902    12.018     0.744
+       2.5      42.5    10.912    12.028     0.746
+       2.5      47.5    10.920    12.036     0.749
+       2.5      52.5    10.926    12.042     0.758
+       2.5      57.5    10.932    12.046     0.758
+       2.5      62.5    10.932    12.046     0.761
+       2.5      67.5    10.932    12.046     0.763
+       2.5      72.5    10.930    12.044     0.763
+       2.5      77.5    10.926    12.040     0.772
+       2.5      82.5    10.920    12.032     0.764
+       2.5      87.5    10.910    12.024     0.765
+       2.5      92.5    10.898    12.014     0.771
+       2.5      97.5    10.886    12.000     0.774
+       2.5     102.5    10.872    11.986     0.770
+       2.5     107.5    10.856    11.970     0.772
+       2.5     112.5    10.838    11.954     0.763
+       2.5     117.5    10.818    11.936     0.764
+       2.5     122.5    10.798    11.916     0.764
+       2.5     127.5    10.776    11.894     0.758
+       2.5     132.5    10.754    11.872     0.757
+       2.5     137.5    10.732    11.850     0.757
+       2.5     142.5    10.708    11.828     0.754
+       2.5     147.5    10.684    11.804     0.752
+       2.5     152.5    10.660    11.782     0.745
+       2.5     157.5    10.636    11.758     0.743
+       2.5     162.5    10.612    11.734     0.743
+       2.5     167.5    10.588    11.712     0.735
+       2.5     172.5    10.566    11.690     0.730
+       2.5     177.5    10.544    11.668     0.726
+       2.5     182.5    10.522    11.648     0.723
+       2.5     187.5    10.504    11.630     0.718
+       2.5     192.5    10.484    11.612     0.716
+       2.5     197.5    10.468    11.594     0.709
+       2.5     202.5    10.452    11.578     0.707
+       2.5     207.5    10.438    11.566     0.704
+       2.5     212.5    10.424    11.552     0.697
+       2.5     217.5    10.414    11.542     0.695
+       2.5     222.5    10.406    11.534     0.693
+       2.5     227.5    10.398    11.526     0.691
+       2.5     232.5    10.392    11.522     0.687
+       2.5     237.5    10.388    11.520     0.682
+       2.5     242.5    10.388    11.518     0.687
+       2.5     247.5    10.388    11.518     0.681
+       2.5     252.5    10.390    11.522     0.675
+       2.5     257.5    10.396    11.526     0.681
+       2.5     262.5    10.402    11.532     0.673
+       2.5     267.5    10.410    11.542     0.675
+       2.5     272.5    10.420    11.552     0.675
+       2.5     277.5    10.432    11.564     0.675
+       2.5     282.5    10.444    11.576     0.668
+       2.5     287.5    10.460    11.592     0.673
+       2.5     292.5    10.476    11.608     0.678
+       2.5     297.5    10.494    11.626     0.677
+       2.5     302.5    10.512    11.644     0.677
+       2.5     307.5    10.532    11.664     0.678
+       2.5     312.5    10.554    11.684     0.683
+       2.5     317.5    10.576    11.706     0.683
+       2.5     322.5    10.598    11.728     0.685
+       2.5     327.5    10.622    11.750     0.691
+       2.5     332.5    10.646    11.774     0.697
+       2.5     337.5    10.668    11.796     0.697
+       2.5     342.5    10.692    11.820     0.702
+       2.5     347.5    10.716    11.842     0.703
+       2.5     352.5    10.740    11.864     0.705
+       2.5     357.5    10.762    11.886     0.710
+       7.5       2.5    11.054    12.188     0.714
+       7.5       7.5    11.120    12.250     0.724
+       7.5      12.5    11.184    12.310     0.737
+       7.5      17.5    11.244    12.364     0.748
+       7.5      22.5    11.300    12.416     0.758
+       7.5      27.5    11.352    12.464     0.775
+       7.5      32.5    11.398    12.508     0.786
+       7.5      37.5    11.440    12.544     0.803
+       7.5      42.5    11.474    12.576     0.815
+       7.5      47.5    11.504    12.602     0.832
+       7.5      52.5    11.526    12.622     0.839
+       7.5      57.5    11.540    12.636     0.843
+       7.5      62.5    11.548    12.642     0.856
+       7.5      67.5    11.550    12.642     0.864
+       7.5      72.5    11.542    12.636     0.870
+       7.5      77.5    11.528    12.622     0.878
+       7.5      82.5    11.508    12.602     0.878
+       7.5      87.5    11.480    12.574     0.887
+       7.5      92.5    11.444    12.542     0.885
+       7.5      97.5    11.404    12.502     0.885
+       7.5     102.5    11.356    12.458     0.891
+       7.5     107.5    11.304    12.408     0.889
+       7.5     112.5    11.246    12.352     0.882
+       7.5     117.5    11.184    12.294     0.879
+       7.5     122.5    11.118    12.230     0.867
+       7.5     127.5    11.050    12.166     0.864
+       7.5     132.5    10.978    12.096     0.857
+       7.5     137.5    10.906    12.026     0.848
+       7.5     142.5    10.830    11.956     0.837
+       7.5     147.5    10.756    11.884     0.826
+       7.5     152.5    10.682    11.812     0.816
+       7.5     157.5    10.608    11.740     0.804
+       7.5     162.5    10.536    11.670     0.794
+       7.5     167.5    10.466    11.602     0.780
+       7.5     172.5    10.400    11.536     0.764
+       7.5     177.5    10.336    11.474     0.749
+       7.5     182.5    10.274    11.414     0.740
+       7.5     187.5    10.220    11.356     0.729
+       7.5     192.5    10.176    11.304     0.725
+       7.5     197.5    10.124    11.256     0.723
+       7.5     202.5    10.088    11.212     0.703
+       7.5     207.5    10.054    11.174     0.707
+       7.5     212.5    10.026    11.140     0.698
+       7.5     217.5     9.990    11.112     0.693
+       7.5     222.5     9.970    11.088     0.669
+       7.5     227.5     9.942    11.070     0.674
+       7.5     232.5     9.950    11.058     0.666
+       7.5     237.5     9.934    11.050     0.654
+       7.5     242.5     9.922    11.048     0.655
+       7.5     247.5     9.924    11.052     0.651
+       7.5     252.5     9.930    11.062     0.636
+       7.5     257.5     9.938    11.076     0.638
+       7.5     262.5     9.952    11.094     0.625
+       7.5     267.5     9.980    11.118     0.619
+       7.5     272.5    10.000    11.148     0.622
+       7.5     277.5    10.032    11.182     0.603
+       7.5     282.5    10.064    11.220     0.600
+       7.5     287.5    10.104    11.262     0.603
+       7.5     292.5    10.150    11.308     0.603
+       7.5     297.5    10.198    11.360     0.609
+       7.5     302.5    10.252    11.412     0.609
+       7.5     307.5    10.308    11.470     0.613
+       7.5     312.5    10.368    11.528     0.616
+       7.5     317.5    10.430    11.590     0.617
+       7.5     322.5    10.496    11.654     0.623
+       7.5     327.5    10.562    11.720     0.636
+       7.5     332.5    10.632    11.788     0.647
+       7.5     337.5    10.702    11.856     0.659
+       7.5     342.5    10.774    11.924     0.664
+       7.5     347.5    10.844    11.992     0.676
+       7.5     352.5    10.916    12.058     0.685
+       7.5     357.5    10.986    12.124     0.699
+      12.5       2.5    11.334    12.494     0.710
+      12.5       7.5    11.450    12.602     0.733
+      12.5      12.5    11.564    12.704     0.754
+      12.5      17.5    11.672    12.802     0.779
+      12.5      22.5    11.774    12.894     0.802
+      12.5      27.5    11.868    12.980     0.824
+      12.5      32.5    11.952    13.058     0.846
+      12.5      37.5    12.030    13.126     0.867
+      12.5      42.5    12.098    13.186     0.893
+      12.5      47.5    12.152    13.234     0.911
+      12.5      52.5    12.194    13.272     0.928
+      12.5      57.5    12.224    13.298     0.944
+      12.5      62.5    12.266    13.314     0.952
+      12.5      67.5    12.482    13.316     0.945
+      12.5      72.5    12.468    13.306     0.950
+      12.5      77.5    12.440    13.284     0.950
+      12.5      82.5    12.402    13.250     0.953
+      12.5      87.5    12.352    13.202     0.955
+      12.5      92.5    12.292    13.144     0.958
+      12.5      97.5    12.222    13.076     0.953
+      12.5     102.5    12.142    12.998     0.956
+      12.5     107.5    12.054    12.908     0.956
+      12.5     112.5    11.960    12.812     0.955
+      12.5     117.5    11.608    12.708     0.962
+      12.5     122.5    11.500    12.598     0.958
+      12.5     127.5    11.388    12.482     0.949
+      12.5     132.5    11.276    12.362     0.943
+      12.5     137.5    11.136    12.240     0.940
+      12.5     142.5    11.012    12.114     0.931
+      12.5     147.5    10.898    11.990     0.930
+      12.5     152.5    10.788    11.866     0.920
+      12.5     157.5    10.682    11.746     0.915
+      12.5     162.5    10.580    11.626     0.904
+      12.5     167.5    10.486    11.512     0.899
+      12.5     172.5    10.250    11.402     0.887
+      12.5     177.5    10.164    11.298     0.862
+      12.5     182.5    10.084    11.198     0.833
+      12.5     187.5    10.008    11.108     0.807
+      12.5     192.5     9.938    11.022     0.795
+      12.5     197.5     9.874    10.946     0.778
+      12.5     202.5     9.816    10.878     0.759
+      12.5     207.5     9.676    10.818     0.751
+      12.5     212.5     9.632    10.766     0.743
+      12.5     217.5     9.602    10.722     0.718
+      12.5     222.5     9.564    10.688     0.699
+      12.5     227.5     9.550    10.660     0.688
+      12.5     232.5     9.524    10.644     0.686
+      12.5     237.5     9.512    10.634     0.663
+      12.5     242.5     9.498    10.634     0.662
+      12.5     247.5     9.520    10.640     0.630
+      12.5     252.5     9.528    10.656     0.631
+      12.5     257.5     9.540    10.680     0.621
+      12.5     262.5     9.548    10.712     0.612
+      12.5     267.5     9.582    10.750     0.592
+      12.5     272.5     9.632    10.796     0.591
+      12.5     277.5     9.678    10.850     0.578
+      12.5     282.5     9.750    10.910     0.572
+      12.5     287.5     9.796    10.978     0.565
+      12.5     292.5     9.848    11.050     0.559
+      12.5     297.5     9.924    11.130     0.547
+      12.5     302.5     9.998    11.216     0.548
+      12.5     307.5    10.086    11.306     0.549
+      12.5     312.5    10.180    11.400     0.557
+      12.5     317.5    10.278    11.500     0.561
+      12.5     322.5    10.384    11.604     0.575
+      12.5     327.5    10.494    11.710     0.587
+      12.5     332.5    10.608    11.820     0.601
+      12.5     337.5    10.726    11.932     0.622
+      12.5     342.5    10.846    12.046     0.630
+      12.5     347.5    10.968    12.158     0.652
+      12.5     352.5    11.092    12.272     0.671
+      12.5     357.5    11.212    12.384     0.691
+      17.5       2.5    11.616    12.826     0.711
+      17.5       7.5    11.794    12.982     0.744
+      17.5      12.5    11.962    13.134     0.778
+      17.5      17.5    12.130    13.278     0.807
+      17.5      22.5    12.284    13.416     0.839
+      17.5      27.5    12.430    13.544     0.873
+      17.5      32.5    12.562    13.662     0.904
+      17.5      37.5    12.682    13.768     0.936
+      17.5      42.5    12.808    13.860     0.951
+      17.5      47.5    13.088    13.936     0.948
+      17.5      52.5    13.140    13.998     0.953
+      17.5      57.5    13.174    14.042     0.959
+      17.5      62.5    13.192    14.068     0.963
+      17.5      67.5    13.262    14.076     0.968
+      17.5      72.5    13.242    14.064     0.973
+      17.5      77.5    13.206    14.034     0.973
+      17.5      82.5    13.150    13.986     0.978
+      17.5      87.5    13.078    13.918     0.979
+      17.5      92.5    12.990    13.834     0.983
+      17.5      97.5    12.886    13.732     0.983
+      17.5     102.5    12.768    13.616     0.983
+      17.5     107.5    12.638    13.484     0.983
+      17.5     112.5    12.496    13.340     0.981
+      17.5     117.5    12.346    13.184     0.981
+      17.5     122.5    12.188    13.020     0.978
+      17.5     127.5    12.026    12.848     0.973
+      17.5     132.5    11.860    12.672     0.970
+      17.5     137.5    11.694    12.490     0.967
+      17.5     142.5    11.528    12.308     0.962
+      17.5     147.5    11.362    12.128     0.945
+      17.5     152.5    11.202    11.948     0.930
+      17.5     157.5    11.046    11.772     0.917
+      17.5     162.5    10.886    11.604     0.905
+      17.5     167.5    10.654    11.440     0.903
+      17.5     172.5    10.522    11.286     0.908
+      17.5     177.5    10.480    11.140     0.894
+      17.5     182.5    10.064    11.004     0.917
+      17.5     187.5     9.892    10.880     0.897
+      17.5     192.5     9.724    10.766     0.902
+      17.5     197.5     9.638    10.662     0.848
+      17.5     202.5     9.568    10.572     0.827
+      17.5     207.5     9.502    10.492     0.786
+      17.5     212.5     9.444    10.426     0.756
+      17.5     217.5     9.268    10.370     0.757
+      17.5     222.5     9.272    10.328     0.710
+      17.5     227.5     9.252    10.296     0.703
+      17.5     232.5     9.232    10.274     0.676
+      17.5     237.5     9.220    10.266     0.660
+      17.5     242.5     9.194    10.266     0.655
+      17.5     247.5     9.220    10.278     0.628
+      17.5     252.5     9.226    10.302     0.615
+      17.5     257.5     9.188    10.334     0.606
+      17.5     262.5     9.238    10.378     0.581
+      17.5     267.5     9.220    10.430     0.582
+      17.5     272.5     9.308    10.492     0.566
+      17.5     277.5     9.348    10.562     0.544
+      17.5     282.5     9.392    10.642     0.542
+      17.5     287.5     9.458    10.732     0.543
+      17.5     292.5     9.542    10.828     0.535
+      17.5     297.5     9.626    10.934     0.517
+      17.5     302.5     9.734    11.048     0.502
+      17.5     307.5     9.838    11.168     0.490
+      17.5     312.5     9.960    11.296     0.500
+      17.5     317.5    10.092    11.430     0.510
+      17.5     322.5    10.236    11.572     0.527
+      17.5     327.5    10.390    11.718     0.541
+      17.5     332.5    10.550    11.870     0.553
+      17.5     337.5    10.720    12.024     0.577
+      17.5     342.5    10.894    12.184     0.602
+      17.5     347.5    11.074    12.344     0.624
+      17.5     352.5    11.254    12.504     0.653
+      17.5     357.5    11.436    12.666     0.685
+      22.5       2.5    11.890    13.180     0.716
+      22.5       7.5    12.140    13.390     0.757
+      22.5      12.5    12.382    13.596     0.801
+      22.5      17.5    12.614    13.796     0.841
+      22.5      22.5    12.834    13.986     0.884
+      22.5      27.5    13.040    14.164     0.927
+      22.5      32.5    13.252    14.328     0.946
+      22.5      37.5    13.606    14.478     0.945
+      22.5      42.5    13.728    14.610     0.959
+      22.5      47.5    13.828    14.720     0.964
+      22.5      52.5    13.976    14.810     0.974
+      22.5      57.5    14.030    14.876     0.979
+      22.5      62.5    14.058    14.918     0.984
+      22.5      67.5    14.062    14.934     0.989
+      22.5      72.5    14.040    14.924     0.995
+      22.5      77.5    14.886    14.886     1.000
+      22.5      82.5    14.824    14.824     1.000
+      22.5      87.5    14.736    14.736     1.000
+      22.5      92.5    14.622    14.622     1.000
+      22.5      97.5    14.484    14.484     1.000
+      22.5     102.5    14.324    14.324     1.000
+      22.5     107.5    14.144    14.144     1.000
+      22.5     112.5    13.946    13.946     1.000
+      22.5     117.5    13.734    13.734     1.000
+      22.5     122.5    13.508    13.508     1.000
+      22.5     127.5    13.274    13.274     1.000
+      22.5     132.5    12.138    13.032     0.998
+      22.5     137.5    11.914    12.786     0.995
+      22.5     142.5    11.690    12.540     0.991
+      22.5     147.5    11.474    12.296     0.988
+      22.5     152.5    11.262    12.056     0.970
+      22.5     157.5    11.722    11.824     0.804
+      22.5     162.5    11.492    11.600     0.759
+      22.5     167.5    10.662    11.388     0.956
+      22.5     172.5    10.490    11.188     0.934
+      22.5     177.5    10.032    11.000     0.948
+      22.5     182.5    10.184    10.828     0.913
+      22.5     187.5     9.600    10.670     0.929
+      22.5     192.5     9.430    10.530     0.936
+      22.5     197.5     9.334    10.404     0.927
+      22.5     202.5     9.406    10.292     0.878
+      22.5     207.5     9.178    10.198     0.875
+      22.5     212.5     9.092    10.118     0.795
+      22.5     217.5     9.042    10.054     0.769
+      22.5     222.5     9.012    10.004     0.718
+      22.5     227.5     8.980     9.970     0.687
+      22.5     232.5     8.966     9.948     0.668
+      22.5     237.5     8.976     9.940     0.639
+      22.5     242.5     8.936     9.944     0.607
+      22.5     247.5     8.880     9.962     0.614
+      22.5     252.5     8.884     9.992     0.592
+      22.5     257.5     8.950    10.034     0.555
+      22.5     262.5     8.922    10.088     0.566
+      22.5     267.5     8.972    10.152     0.553
+      22.5     272.5     8.970    10.228     0.547
+      22.5     277.5     9.030    10.314     0.531
+      22.5     282.5     9.066    10.412     0.523
+      22.5     287.5     9.158    10.520     0.501
+      22.5     292.5     9.190    10.638     0.500
+      22.5     297.5     9.280    10.766     0.495
+      22.5     302.5     9.390    10.904     0.483
+      22.5     307.5     9.542    11.052     0.461
+      22.5     312.5     9.628    11.210     0.459
+      22.5     317.5     9.780    11.378     0.452
+      22.5     322.5     9.964    11.552     0.467
+      22.5     327.5    10.168    11.738     0.490
+      22.5     332.5    10.390    11.930     0.506
+      22.5     337.5    10.626    12.128     0.547
+      22.5     342.5    10.872    12.332     0.573
+      22.5     347.5    11.124    12.542     0.605
+      22.5     352.5    11.382    12.754     0.643
+      22.5     357.5    11.638    12.966     0.682
+      27.5       2.5    12.132    13.556     0.739
+      27.5       7.5    12.478    13.826     0.782
+      27.5      12.5    12.810    14.094     0.829
+      27.5      17.5    13.124    14.354     0.881
+      27.5      22.5    13.422    14.604     0.927
+      27.5      27.5    13.712    14.842     0.942
+      27.5      32.5    14.156    15.062     0.940
+      27.5      37.5    14.350    15.264     0.958
+      27.5      42.5    14.586    15.442     0.967
+      27.5      47.5    14.726    15.594     0.979
+      27.5      52.5    14.836    15.720     0.986
+      27.5      57.5    14.914    15.814     0.996
+      27.5      62.5    15.876    15.876     1.000
+      27.5      67.5    15.904    15.904     1.000
+      27.5      72.5    15.898    15.898     1.000
+      27.5      77.5    15.856    15.856     1.000
+      27.5      82.5    15.780    15.780     1.000
+      27.5      87.5    15.668    15.668     1.000
+      27.5      92.5    15.522    15.522     1.000
+      27.5      97.5    15.344    15.344     1.000
+      27.5     102.5    15.136    15.136     1.000
+      27.5     107.5    14.902    14.902     1.000
+      27.5     112.5    14.644    14.644     1.000
+      27.5     117.5    14.366    14.366     1.000
+      27.5     122.5    14.070    14.070     1.000
+      27.5     127.5    13.764    13.764     1.000
+      27.5     132.5    13.448    13.448     1.000
+      27.5     137.5    13.130    13.130     1.000
+      27.5     142.5    12.812    12.812     1.000
+      27.5     147.5    12.498    12.498     1.000
+      27.5     152.5    12.192    12.192     1.000
+      27.5     157.5    11.790    11.898     0.852
+      27.5     162.5    11.500    11.616     0.741
+      27.5     167.5    11.242    11.352     0.727
+      27.5     172.5    11.000    11.104     0.712
+      27.5     177.5    10.196    10.876     0.929
+      27.5     182.5    10.022    10.668     0.926
+      27.5     187.5     9.492    10.480     0.945
+      27.5     192.5     9.304    10.314     0.950
+      27.5     197.5     9.194    10.166     0.928
+      27.5     202.5     8.958    10.038     0.926
+      27.5     207.5     9.022     9.930     0.899
+      27.5     212.5     8.958     9.842     0.846
+      27.5     217.5     8.828     9.770     0.788
+      27.5     222.5     8.742     9.718     0.744
+      27.5     227.5     8.738     9.680     0.694
+      27.5     232.5     8.672     9.660     0.690
+      27.5     237.5     8.654     9.654     0.652
+      27.5     242.5     8.712     9.664     0.592
+      27.5     247.5     8.714     9.686     0.582
+      27.5     252.5     8.652     9.724     0.576
+      27.5     257.5     8.662     9.774     0.565
+      27.5     262.5     8.676     9.838     0.547
+      27.5     267.5     8.680     9.912     0.524
+      27.5     272.5     8.702    10.000     0.519
+      27.5     277.5     8.816    10.100     0.475
+      27.5     282.5     8.748    10.212     0.503
+      27.5     287.5     8.808    10.336     0.493
+      27.5     292.5     8.868    10.472     0.484
+      27.5     297.5     9.000    10.620     0.459
+      27.5     302.5     8.858    10.778     0.517
+      27.5     307.5     8.480    10.950     0.621
+      27.5     312.5     9.210    11.134     0.524
+      27.5     317.5     9.282    11.332     0.572
+      27.5     322.5     9.444    11.540     0.599
+      27.5     327.5     9.598    11.760     0.629
+      27.5     332.5     9.766    11.992     0.623
+      27.5     337.5     9.936    12.236     0.608
+      27.5     342.5    10.530    12.488     0.540
+      27.5     347.5    10.990    12.748     0.596
+      27.5     352.5    11.392    13.014     0.651
+      27.5     357.5    11.770    13.284     0.690
+      32.5       2.5    12.386    13.948     0.832
+      32.5       7.5    12.762    14.288     0.857
+      32.5      12.5    13.226    14.626     0.896
+      32.5      17.5    13.688    14.956     0.918
+      32.5      22.5    14.314    15.278     0.919
+      32.5      27.5    14.628    15.584     0.941
+      32.5      32.5    14.992    15.870     0.957
+      32.5      37.5    15.246    16.132     0.968
+      32.5      42.5    15.468    16.368     0.982
+      32.5      47.5    15.656    16.570     0.993
+      32.5      52.5    16.740    16.740     1.000
+      32.5      57.5    16.870    16.870     1.000
+      32.5      62.5    16.958    16.958     1.000
+      32.5      67.5    17.004    17.004     1.000
+      32.5      72.5    17.004    17.004     1.000
+      32.5      77.5    16.960    16.960     1.000
+      32.5      82.5    16.870    16.870     1.000
+      32.5      87.5    16.734    16.734     1.000
+      32.5      92.5    16.552    16.552     1.000
+      32.5      97.5    16.330    16.330     1.000
+      32.5     102.5    16.070    16.070     1.000
+      32.5     107.5    15.774    15.774     1.000
+      32.5     112.5    15.446    15.446     1.000
+      32.5     117.5    15.092    15.092     1.000
+      32.5     122.5    14.718    14.718     1.000
+      32.5     127.5    14.328    14.328     1.000
+      32.5     132.5    13.930    13.930     1.000
+      32.5     137.5    13.528    13.528     1.000
+      32.5     142.5    13.128    13.128     1.000
+      32.5     147.5    12.736    12.736     1.000
+      32.5     152.5    12.356    12.356     1.000
+      32.5     157.5    11.880    11.994     0.895
+      32.5     162.5    11.526    11.652     0.746
+      32.5     167.5    11.216    11.332     0.759
+      32.5     172.5    10.928    11.036     0.722
+      32.5     177.5    10.100    10.766     0.946
+      32.5     182.5     9.906    10.524     0.945
+      32.5     187.5     9.690    10.306     0.932
+      32.5     192.5     9.536    10.116     0.910
+      32.5     197.5     8.874     9.950     0.941
+      32.5     202.5     8.826     9.808     0.923
+      32.5     207.5     8.820     9.690     0.903
+      32.5     212.5     8.746     9.594     0.868
+      32.5     217.5     8.626     9.518     0.798
+      32.5     222.5     8.540     9.462     0.753
+      32.5     227.5     8.546     9.426     0.686
+      32.5     232.5     8.314     9.406     0.718
+      32.5     237.5     8.514     9.406     0.601
+      32.5     242.5     8.268     9.420     0.655
+      32.5     247.5     8.506     9.450     0.566
+      32.5     252.5     8.502     9.494     0.534
+      32.5     257.5     8.438     9.550     0.538
+      32.5     262.5     8.474     9.624     0.511
+      32.5     267.5     8.460     9.708     0.492
+      32.5     272.5     8.410     9.806     0.509
+      32.5     277.5     8.494     9.916     0.466
+      32.5     282.5     8.484    10.040     0.463
+      32.5     287.5     8.400    10.176     0.511
+      32.5     292.5     8.614    10.324     0.526
+      32.5     297.5     8.746    10.488     0.692
+      32.5     302.5     8.704    10.664     0.682
+      32.5     307.5     9.138    10.854     0.749
+      32.5     312.5     9.994    11.062     0.566
+      32.5     317.5    10.134    11.282     0.580
+      32.5     322.5    10.300    11.520     0.584
+      32.5     327.5    10.498    11.776     0.587
+      32.5     332.5    10.760    12.046     0.589
+      32.5     337.5    11.046    12.334     0.616
+      32.5     342.5    11.380    12.634     0.641
+      32.5     347.5    11.740    12.950     0.678
+      32.5     352.5    12.118    13.274     0.708
+      32.5     357.5    11.778    13.608     0.779
+      37.5       2.5    12.924    14.344     0.776
+      37.5       7.5    13.508    14.766     0.819
+      37.5      12.5    14.030    15.186     0.865
+      37.5      17.5    14.512    15.602     0.906
+      37.5      22.5    14.958    16.006     0.927
+      37.5      27.5    15.372    16.394     0.951
+      37.5      32.5    15.830    16.758     0.968
+      37.5      37.5    16.162    17.096     0.983
+      37.5      42.5    17.398    17.398     1.000
+      37.5      47.5    17.664    17.664     1.000
+      37.5      52.5    17.886    17.886     1.000
+      37.5      57.5    18.060    18.060     1.000
+      37.5      62.5    18.184    18.184     1.000
+      37.5      67.5    18.252    18.252     1.000
+      37.5      72.5    18.264    18.264     1.000
+      37.5      77.5    18.220    18.220     1.000
+      37.5      82.5    18.116    18.116     1.000
+      37.5      87.5    17.954    17.954     1.000
+      37.5      92.5    17.736    17.736     1.000
+      37.5      97.5    17.464    17.464     1.000
+      37.5     102.5    17.144    17.144     1.000
+      37.5     107.5    16.776    16.776     1.000
+      37.5     112.5    16.370    16.370     1.000
+      37.5     117.5    15.930    15.930     1.000
+      37.5     122.5    15.464    15.464     1.000
+      37.5     127.5    14.978    14.978     1.000
+      37.5     132.5    14.484    14.484     1.000
+      37.5     137.5    13.986    13.986     1.000
+      37.5     142.5    13.492    13.492     1.000
+      37.5     147.5    13.012    13.012     1.000
+      37.5     152.5    12.550    12.550     1.000
+      37.5     157.5    11.992    12.112     0.967
+      37.5     162.5    11.566    11.704     0.783
+      37.5     167.5    11.200    11.326     0.778
+      37.5     172.5    10.866    10.980     0.754
+      37.5     177.5    10.566    10.668     0.765
+      37.5     182.5    10.232    10.392     0.788
+      37.5     187.5     9.534    10.146     0.938
+      37.5     192.5     8.954     9.934     0.957
+      37.5     197.5     8.762     9.752     0.947
+      37.5     202.5     8.736     9.600     0.933
+      37.5     207.5     8.598     9.472     0.902
+      37.5     212.5     8.588     9.372     0.870
+      37.5     217.5     8.392     9.294     0.809
+      37.5     222.5     8.392     9.238     0.742
+      37.5     227.5     8.150     9.204     0.744
+      37.5     232.5     8.342     9.188     0.629
+      37.5     237.5     8.064     9.192     0.693
+      37.5     242.5     8.284     9.210     0.564
+      37.5     247.5     8.026     9.246     0.633
+      37.5     252.5     8.242     9.298     0.528
+      37.5     257.5     7.944     9.362     0.599
+      37.5     262.5     8.272     9.440     0.462
+      37.5     267.5     8.164     9.534     0.492
+      37.5     272.5     8.002     9.640     0.520
+      37.5     277.5     8.044     9.758     0.510
+      37.5     282.5     8.264     9.888     0.563
+      37.5     287.5     7.760    10.032     0.689
+      37.5     292.5     9.210    10.190     0.512
+      37.5     297.5     9.210    10.360     0.525
+      37.5     302.5     8.210    10.548     0.721
+      37.5     307.5     8.440    10.750     0.721
+      37.5     312.5     9.336    10.972     0.516
+      37.5     317.5     8.436    11.212     0.612
+      37.5     322.5     9.244    11.474     0.713
+      37.5     327.5     9.704    11.758     0.862
+      37.5     332.5    10.022    12.066     0.854
+      37.5     337.5    10.366    12.398     0.758
+      37.5     342.5    10.626    12.752     0.560
+      37.5     347.5    10.712    13.128     0.449
+      37.5     352.5    11.958    13.520     0.666
+      37.5     357.5    11.526    13.928     0.774
+      42.5       2.5    14.410    14.722     0.641
+      42.5       7.5    13.612    15.244     0.805
+      42.5      12.5    14.486    15.766     0.863
+      42.5      17.5    15.154    16.284     0.912
+      42.5      22.5    15.742    16.790     0.939
+      42.5      27.5    16.272    17.276     0.960
+      42.5      32.5    16.750    17.736     0.980
+      42.5      37.5    18.164    18.164     1.000
+      42.5      42.5    18.550    18.550     1.000
+      42.5      47.5    18.890    18.890     1.000
+      42.5      52.5    19.178    19.178     1.000
+      42.5      57.5    19.406    19.406     1.000
+      42.5      62.5    19.574    19.574     1.000
+      42.5      67.5    19.674    19.674     1.000
+      42.5      72.5    19.702    19.702     1.000
+      42.5      77.5    19.660    19.660     1.000
+      42.5      82.5    19.546    19.546     1.000
+      42.5      87.5    19.358    19.358     1.000
+      42.5      92.5    19.098    19.098     1.000
+      42.5      97.5    18.772    18.772     1.000
+      42.5     102.5    18.380    18.380     1.000
+      42.5     107.5    17.934    17.934     1.000
+      42.5     112.5    17.436    17.436     1.000
+      42.5     117.5    16.896    16.896     1.000
+      42.5     122.5    16.322    16.322     1.000
+      42.5     127.5    15.726    15.726     1.000
+      42.5     132.5    15.120    15.120     1.000
+      42.5     137.5    14.510    14.510     1.000
+      42.5     142.5    13.910    13.910     1.000
+      42.5     147.5    13.330    13.330     1.000
+      42.5     152.5    12.774    12.774     1.000
+      42.5     157.5    12.254    12.254     1.000
+      42.5     162.5    11.620    11.772     0.803
+      42.5     167.5    11.194    11.330     0.765
+      42.5     172.5    10.814    10.934     0.783
+      42.5     177.5    10.474    10.580     0.736
+      42.5     182.5    10.166    10.270     0.712
+      42.5     187.5     9.440    10.000     0.943
+      42.5     192.5     9.214     9.770     0.917
+      42.5     197.5     8.800     9.574     0.941
+      42.5     202.5     8.444     9.410     0.917
+      42.5     207.5     8.450     9.278     0.908
+      42.5     212.5     8.408     9.176     0.896
+      42.5     217.5     8.066     9.098     0.866
+      42.5     222.5     8.248     9.044     0.731
+      42.5     227.5     8.032     9.012     0.716
+      42.5     232.5     7.944     9.002     0.703
+      42.5     237.5     7.968     9.008     0.646
+      42.5     242.5     7.976     9.034     0.612
+      42.5     247.5     7.848     9.076     0.601
+      42.5     252.5     7.744     9.132     0.611
+      42.5     257.5     8.100     9.204     0.447
+      42.5     262.5     7.940     9.288     0.485
+      42.5     267.5     7.804     9.388     0.510
+      42.5     272.5     7.722     9.498     0.542
+      42.5     277.5     8.052     9.618     0.642
+      42.5     282.5     8.794     9.752     0.480
+      42.5     287.5     8.668     9.898     0.522
+      42.5     292.5     8.536    10.054     0.576
+      42.5     297.5     8.310    10.224     0.524
+      42.5     302.5     8.890    10.410     0.767
+      42.5     307.5    10.232    10.612     0.347
+      42.5     312.5    10.426    10.834     0.363
+      42.5     317.5    10.662    11.076     0.357
+      42.5     322.5    10.902    11.352     0.369
+      42.5     327.5    11.196    11.658     0.385
+      42.5     332.5    11.538    11.998     0.417
+      42.5     337.5    11.922    12.376     0.401
+      42.5     342.5    12.356    12.790     0.433
+      42.5     347.5    12.828    13.236     0.466
+      42.5     352.5    13.332    13.712     0.516
+      42.5     357.5    13.862    14.208     0.561
+      47.5       2.5    14.608    15.028     0.662
+      47.5       7.5    15.324    15.686     0.729
+      47.5      12.5    16.034    16.344     0.832
+      47.5      17.5    15.450    16.992     0.969
+      47.5      22.5    16.396    17.624     0.963
+      47.5      27.5    17.128    18.232     0.976
+      47.5      32.5    17.758    18.810     0.998
+      47.5      37.5    19.346    19.346     1.000
+      47.5      42.5    19.834    19.834     1.000
+      47.5      47.5    20.268    20.268     1.000
+      47.5      52.5    20.636    20.636     1.000
+      47.5      57.5    20.934    20.934     1.000
+      47.5      62.5    21.156    21.156     1.000
+      47.5      67.5    21.296    21.296     1.000
+      47.5      72.5    21.350    21.350     1.000
+      47.5      77.5    21.314    21.314     1.000
+      47.5      82.5    21.190    21.190     1.000
+      47.5      87.5    20.974    20.974     1.000
+      47.5      92.5    20.670    20.670     1.000
+      47.5      97.5    20.280    20.280     1.000
+      47.5     102.5    19.812    19.812     1.000
+      47.5     107.5    19.272    19.272     1.000
+      47.5     112.5    18.668    18.668     1.000
+      47.5     117.5    18.012    18.012     1.000
+      47.5     122.5    17.314    17.314     1.000
+      47.5     127.5    16.588    16.588     1.000
+      47.5     132.5    15.850    15.850     1.000
+      47.5     137.5    15.112    15.112     1.000
+      47.5     142.5    14.386    14.386     1.000
+      47.5     147.5    13.688    13.688     1.000
+      47.5     152.5    13.028    13.028     1.000
+      47.5     157.5    12.414    12.414     1.000
+      47.5     162.5    11.680    11.852     0.791
+      47.5     167.5    11.196    11.346     0.787
+      47.5     172.5    10.766    10.896     0.800
+      47.5     177.5    10.330    10.500     0.835
+      47.5     182.5    10.008    10.158     0.787
+      47.5     187.5     9.156     9.866     0.946
+      47.5     192.5     8.638     9.618     0.955
+      47.5     197.5     8.538     9.412     0.952
+      47.5     202.5     8.784     9.242     0.882
+      47.5     207.5     8.354     9.108     0.920
+      47.5     212.5     8.188     9.004     0.880
+      47.5     217.5     8.150     8.928     0.789
+      47.5     222.5     7.892     8.878     0.775
+      47.5     227.5     7.920     8.850     0.692
+      47.5     232.5     8.014     8.844     0.600
+      47.5     237.5     7.796     8.856     0.645
+      47.5     242.5     7.840     8.888     0.599
+      47.5     247.5     7.676     8.936     0.598
+      47.5     252.5     7.904     8.998     0.468
+      47.5     257.5     7.820     9.074     0.470
+      47.5     262.5     7.620     9.164     0.500
+      47.5     267.5     7.512     9.264     0.574
+      47.5     272.5     7.690     9.372     0.665
+      47.5     277.5     8.442     9.492     0.448
+      47.5     282.5     7.654     9.622     0.611
+      47.5     287.5     7.864     9.758     0.596
+      47.5     292.5     7.882     9.898     0.855
+      47.5     297.5     9.630    10.048     0.254
+      47.5     302.5     7.694    10.206     0.870
+      47.5     307.5     9.818    10.378     0.332
+      47.5     312.5     9.896    10.560     0.352
+      47.5     317.5     9.958    10.764     0.387
+      47.5     322.5    10.000    11.002     0.431
+      47.5     327.5    10.042    11.286     0.466
+      47.5     332.5    10.222    11.636     0.511
+      47.5     337.5    10.842    12.064     0.509
+      47.5     342.5    11.624    12.568     0.479
+      47.5     347.5    12.398    13.132     0.485
+      47.5     352.5    13.150    13.740     0.549
+      47.5     357.5    13.884    14.376     0.598
+      52.5       2.5    11.658    15.078     0.835
+      52.5       7.5    15.476    15.998     0.801
+      52.5      12.5    16.454    16.866     0.869
+      52.5      17.5    17.696    17.696     1.000
+      52.5      22.5    18.496    18.496     1.000
+      52.5      27.5    19.260    19.260     1.000
+      52.5      32.5    19.984    19.984     1.000
+      52.5      37.5    20.656    20.656     1.000
+      52.5      42.5    21.272    21.272     1.000
+      52.5      47.5    21.818    21.818     1.000
+      52.5      52.5    22.288    22.288     1.000
+      52.5      57.5    22.672    22.672     1.000
+      52.5      62.5    22.964    22.964     1.000
+      52.5      67.5    23.156    23.156     1.000
+      52.5      72.5    23.242    23.242     1.000
+      52.5      77.5    23.220    23.220     1.000
+      52.5      82.5    23.088    23.088     1.000
+      52.5      87.5    22.844    22.844     1.000
+      52.5      92.5    22.490    22.490     1.000
+      52.5      97.5    22.032    22.032     1.000
+      52.5     102.5    21.474    21.474     1.000
+      52.5     107.5    20.826    20.826     1.000
+      52.5     112.5    20.098    20.098     1.000
+      52.5     117.5    19.306    19.306     1.000
+      52.5     122.5    18.462    18.462     1.000
+      52.5     127.5    17.584    17.584     1.000
+      52.5     132.5    16.690    16.690     1.000
+      52.5     137.5    15.798    15.798     1.000
+      52.5     142.5    14.926    14.926     1.000
+      52.5     147.5    14.092    14.092     1.000
+      52.5     152.5    13.310    13.310     1.000
+      52.5     157.5    12.590    12.590     1.000
+      52.5     162.5    11.748    11.942     0.804
+      52.5     167.5    11.200    11.366     0.819
+      52.5     172.5    10.722    10.862     0.800
+      52.5     177.5    10.308    10.426     0.797
+      52.5     182.5     9.944    10.054     0.709
+      52.5     187.5     9.648     9.742     0.702
+      52.5     192.5     8.982     9.480     0.936
+      52.5     197.5     8.432     9.266     0.950
+      52.5     202.5     8.270     9.094     0.944
+      52.5     207.5     8.178     8.958     0.923
+      52.5     212.5     7.794     8.856     0.919
+      52.5     217.5     8.012     8.776     0.793
+      52.5     222.5     8.004     8.738     0.706
+      52.5     227.5     7.714     8.714     0.730
+      52.5     232.5     7.724     8.714     0.675
+      52.5     237.5     7.764     8.734     0.598
+      52.5     242.5     7.646     8.770     0.578
+      52.5     247.5     7.474     8.824     0.601
+      52.5     252.5     7.728     8.890     0.468
+      52.5     257.5     7.570     8.970     0.480
+      52.5     262.5     7.290     9.060     0.567
+      52.5     267.5     7.476     9.158     0.687
+      52.5     272.5     8.154     9.262     0.455
+      52.5     277.5     7.246     9.372     0.654
+      52.5     282.5     8.072     9.480     0.722
+      52.5     287.5     7.542     9.590     0.853
+      52.5     292.5     7.188     9.688     0.864
+      52.5     297.5     9.146     9.770     0.324
+      52.5     302.5     8.968     9.820     0.399
+      52.5     307.5     7.578     9.816     0.765
+      52.5     312.5     7.960     9.702     0.799
+      52.5     317.5     8.168     9.444     0.851
+      52.5     322.5     8.812     9.274     0.797
+      52.5     327.5     8.784     9.286     0.892
+      52.5     332.5     8.948     9.408     0.909
+      52.5     337.5     8.890     9.602     0.958
+      52.5     342.5     9.592     9.864     0.912
+      52.5     347.5     9.926    10.214     0.931
+      52.5     352.5    10.456    10.780     0.975
+      52.5     357.5    11.022    14.032     0.994
+      57.5       2.5    12.270    12.270     1.000
+      57.5       7.5    13.038    15.292     0.256
+      57.5      12.5    16.554    17.150     0.987
+      57.5      17.5    17.926    18.326     0.990
+      57.5      22.5    19.372    19.372     1.000
+      57.5      27.5    20.346    20.346     1.000
+      57.5      32.5    21.258    21.258     1.000
+      57.5      37.5    22.104    22.104     1.000
+      57.5      42.5    22.878    22.878     1.000
+      57.5      47.5    23.568    23.568     1.000
+      57.5      52.5    24.164    24.164     1.000
+      57.5      57.5    24.656    24.656     1.000
+      57.5      62.5    25.036    25.036     1.000
+      57.5      67.5    25.296    25.296     1.000
+      57.5      72.5    25.428    25.428     1.000
+      57.5      77.5    25.426    25.426     1.000
+      57.5      82.5    25.290    25.290     1.000
+      57.5      87.5    25.016    25.016     1.000
+      57.5      92.5    24.608    24.608     1.000
+      57.5      97.5    24.070    24.070     1.000
+      57.5     102.5    23.410    23.410     1.000
+      57.5     107.5    22.638    22.638     1.000
+      57.5     112.5    21.766    21.766     1.000
+      57.5     117.5    20.812    20.812     1.000
+      57.5     122.5    19.794    19.794     1.000
+      57.5     127.5    18.734    18.734     1.000
+      57.5     132.5    17.654    17.654     1.000
+      57.5     137.5    16.580    16.580     1.000
+      57.5     142.5    15.534    15.534     1.000
+      57.5     147.5    14.540    14.540     1.000
+      57.5     152.5    13.618    13.618     1.000
+      57.5     157.5    12.780    12.780     1.000
+      57.5     162.5    11.814    12.036     0.802
+      57.5     167.5    11.202    11.386     0.815
+      57.5     172.5    10.676    10.828     0.842
+      57.5     177.5    10.232    10.354     0.803
+      57.5     182.5     9.858     9.956     0.735
+      57.5     187.5     9.064     9.626     0.950
+      57.5     192.5     8.878     9.356     0.925
+      57.5     197.5     8.326     9.138     0.946
+      57.5     202.5     8.336     8.964     0.930
+      57.5     207.5     8.146     8.830     0.898
+      57.5     212.5     8.092     8.732     0.862
+      57.5     217.5     7.956     8.664     0.771
+      57.5     222.5     7.592     8.622     0.763
+      57.5     227.5     7.680     8.606     0.674
+      57.5     232.5     7.654     8.612     0.624
+      57.5     237.5     7.508     8.638     0.637
+      57.5     242.5     7.514     8.680     0.578
+      57.5     247.5     7.672     8.738     0.448
+      57.5     252.5     7.518     8.808     0.481
+      57.5     257.5     7.424     8.888     0.463
+      57.5     262.5     7.134     8.976     0.687
+      57.5     267.5     7.956     9.066     0.436
+      57.5     272.5     7.130     9.156     0.611
+      57.5     277.5     7.188     9.242     0.812
+      57.5     282.5     8.874     9.306     0.269
+      57.5     287.5     8.784     9.340     0.309
+      57.5     292.5     7.038     9.298     0.784
+      57.5     297.5     8.038     9.112     0.642
+      57.5     302.5     7.624     8.702     0.833
+      57.5     307.5     7.708     8.454     0.922
+      57.5     312.5     7.610     8.426     0.956
+      57.5     317.5     8.076     8.504     0.939
+      57.5     322.5     8.504     8.644     0.857
+      57.5     327.5     8.586     8.828     0.934
+      57.5     332.5     8.528     9.040     0.949
+      57.5     337.5     8.722     9.278     0.939
+      57.5     342.5     9.194     9.536     0.936
+      57.5     347.5     9.950     9.950     1.000
+      57.5     352.5    10.726    10.726     1.000
+      57.5     357.5    11.500    11.500     1.000
+      62.5       2.5    13.980    13.980     1.000
+      62.5       7.5    14.866    14.866     1.000
+      62.5      12.5    15.748    15.748     1.000
+      62.5      17.5    18.546    18.546     1.000
+      62.5      22.5    20.168    20.168     1.000
+      62.5      27.5    21.458    21.458     1.000
+      62.5      32.5    22.624    22.624     1.000
+      62.5      37.5    23.696    23.696     1.000
+      62.5      42.5    24.674    24.674     1.000
+      62.5      47.5    25.544    25.544     1.000
+      62.5      52.5    26.300    26.300     1.000
+      62.5      57.5    26.930    26.930     1.000
+      62.5      62.5    27.422    27.422     1.000
+      62.5      67.5    27.768    27.768     1.000
+      62.5      72.5    27.960    27.960     1.000
+      62.5      77.5    27.992    27.992     1.000
+      62.5      82.5    27.856    27.856     1.000
+      62.5      87.5    27.554    27.554     1.000
+      62.5      92.5    27.086    27.086     1.000
+      62.5      97.5    26.458    26.458     1.000
+      62.5     102.5    25.678    25.678     1.000
+      62.5     107.5    24.758    24.758     1.000
+      62.5     112.5    23.716    23.716     1.000
+      62.5     117.5    22.570    22.570     1.000
+      62.5     122.5    21.346    21.346     1.000
+      62.5     127.5    20.068    20.068     1.000
+      62.5     132.5    18.766    18.766     1.000
+      62.5     137.5    17.472    17.472     1.000
+      62.5     142.5    16.218    16.218     1.000
+      62.5     147.5    15.034    15.034     1.000
+      62.5     152.5    13.948    13.948     1.000
+      62.5     157.5    12.976    12.976     1.000
+      62.5     162.5    11.874    12.126     0.810
+      62.5     167.5    11.196    11.400     0.814
+      62.5     172.5    10.628    10.790     0.827
+      62.5     177.5    10.070    10.280     0.886
+      62.5     182.5     9.700     9.862     0.864
+      62.5     187.5     9.012     9.520     0.933
+      62.5     192.5     8.322     9.246     0.961
+      62.5     197.5     8.258     9.026     0.940
+      62.5     202.5     8.206     8.854     0.917
+      62.5     207.5     7.980     8.724     0.927
+      62.5     212.5     7.920     8.630     0.879
+      62.5     217.5     7.742     8.568     0.804
+      62.5     222.5     7.624     8.534     0.710
+      62.5     227.5     7.500     8.524     0.695
+      62.5     232.5     7.578     8.538     0.615
+      62.5     237.5     7.740     8.568     0.469
+      62.5     242.5     7.664     8.616     0.454
+      62.5     247.5     7.546     8.676     0.435
+      62.5     252.5     7.368     8.748     0.436
+      62.5     257.5     7.432     8.826     0.558
+      62.5     262.5     7.888     8.906     0.420
+      62.5     267.5     7.032     8.980     0.589
+      62.5     272.5     7.300     9.044     0.810
+      62.5     277.5     8.630     9.070     0.291
+      62.5     282.5     7.102     9.034     0.788
+      62.5     287.5     7.122     8.842     0.750
+      62.5     292.5     7.236     8.376     0.837
+      62.5     297.5     7.538     8.064     0.886
+      62.5     302.5     7.798     8.010     0.868
+      62.5     307.5     7.868     8.080     0.868
+      62.5     312.5     7.724     8.218     0.891
+      62.5     317.5     7.928     8.398     0.885
+      62.5     322.5     8.002     8.614     0.925
+      62.5     327.5     8.186     8.852     0.925
+      62.5     332.5     8.762     9.112     0.903
+      62.5     337.5     9.608     9.608     1.000
+      62.5     342.5    10.470    10.470     1.000
+      62.5     347.5    11.340    11.340     1.000
+      62.5     352.5    12.216    12.216     1.000
+      62.5     357.5    13.098    13.098     1.000
+      67.5       2.5    15.848    15.848     1.000
+      67.5       7.5    16.874    16.874     1.000
+      67.5      12.5    17.900    17.900     1.000
+      67.5      17.5    18.928    18.928     1.000
+      67.5      22.5    20.356    20.356     1.000
+      67.5      27.5    22.518    22.518     1.000
+      67.5      32.5    24.056    24.056     1.000
+      67.5      37.5    25.428    25.428     1.000
+      67.5      42.5    26.672    26.672     1.000
+      67.5      47.5    27.780    27.780     1.000
+      67.5      52.5    28.740    28.740     1.000
+      67.5      57.5    29.544    29.544     1.000
+      67.5      62.5    30.182    30.182     1.000
+      67.5      67.5    30.642    30.642     1.000
+      67.5      72.5    30.914    30.914     1.000
+      67.5      77.5    30.990    30.990     1.000
+      67.5      82.5    30.864    30.864     1.000
+      67.5      87.5    30.534    30.534     1.000
+      67.5      92.5    30.000    30.000     1.000
+      67.5      97.5    29.268    29.268     1.000
+      67.5     102.5    28.348    28.348     1.000
+      67.5     107.5    27.256    27.256     1.000
+      67.5     112.5    26.010    26.010     1.000
+      67.5     117.5    24.636    24.636     1.000
+      67.5     122.5    23.162    23.162     1.000
+      67.5     127.5    21.620    21.620     1.000
+      67.5     132.5    20.048    20.048     1.000
+      67.5     137.5    18.488    18.488     1.000
+      67.5     142.5    16.982    16.982     1.000
+      67.5     147.5    15.570    15.570     1.000
+      67.5     152.5    14.292    14.292     1.000
+      67.5     157.5    13.166    13.166     1.000
+      67.5     162.5    11.918    12.206     0.806
+      67.5     167.5    11.176    11.402     0.832
+      67.5     172.5    10.402    10.742     0.924
+      67.5     177.5    10.076    10.206     0.723
+      67.5     182.5     9.544     9.772     0.877
+      67.5     187.5     8.918     9.424     0.945
+      67.5     192.5     8.612     9.146     0.933
+      67.5     197.5     8.534     8.930     0.924
+      67.5     202.5     8.124     8.764     0.919
+      67.5     207.5     8.066     8.640     0.913
+      67.5     212.5     7.904     8.550     0.833
+      67.5     217.5     7.692     8.498     0.767
+      67.5     222.5     7.664     8.472     0.676
+      67.5     227.5     7.582     8.468     0.641
+      67.5     232.5     7.372     8.488     0.638
+      67.5     237.5     7.286     8.524     0.616
+      67.5     242.5     7.270     8.576     0.565
+      67.5     247.5     7.312     8.640     0.474
+      67.5     252.5     7.026     8.708     0.586
+      67.5     257.5     7.884     8.780     0.406
+      67.5     262.5     7.096     8.844     0.586
+      67.5     267.5     7.222     8.888     0.796
+      67.5     272.5     7.038     8.892     0.825
+      67.5     277.5     8.160     8.796     0.327
+      67.5     282.5     7.188     8.458     0.737
+      67.5     287.5     7.296     7.936     0.809
+      67.5     292.5     7.044     7.752     0.938
+      67.5     297.5     7.154     7.768     0.938
+      67.5     302.5     7.142     7.874     0.923
+      67.5     307.5     7.356     8.042     0.927
+      67.5     312.5     7.642     8.244     0.884
+      67.5     317.5     7.866     8.488     0.820
+      67.5     322.5     8.138     8.754     0.792
+      67.5     327.5     9.016     9.042     0.615
+      67.5     332.5     9.940     9.940     1.000
+      67.5     337.5    10.884    10.884     1.000
+      67.5     342.5    11.846    11.846     1.000
+      67.5     347.5    12.826    12.826     1.000
+      67.5     352.5    13.822    13.822     1.000
+      67.5     357.5    14.830    14.830     1.000
+      72.5       2.5    17.936    17.936     1.000
+      72.5       7.5    19.126    19.126     1.000
+      72.5      12.5    20.328    20.328     1.000
+      72.5      17.5    21.532    21.532     1.000
+      72.5      22.5    22.732    22.732     1.000
+      72.5      27.5    23.926    23.926     1.000
+      72.5      32.5    25.496    25.496     1.000
+      72.5      37.5    27.278    27.278     1.000
+      72.5      42.5    28.878    28.878     1.000
+      72.5      47.5    30.300    30.300     1.000
+      72.5      52.5    31.532    31.532     1.000
+      72.5      57.5    32.566    32.566     1.000
+      72.5      62.5    33.392    33.392     1.000
+      72.5      67.5    34.000    34.000     1.000
+      72.5      72.5    34.378    34.378     1.000
+      72.5      77.5    34.520    34.520     1.000
+      72.5      82.5    34.412    34.412     1.000
+      72.5      87.5    34.056    34.056     1.000
+      72.5      92.5    33.448    33.448     1.000
+      72.5      97.5    32.596    32.596     1.000
+      72.5     102.5    31.512    31.512     1.000
+      72.5     107.5    30.214    30.214     1.000
+      72.5     112.5    28.724    28.724     1.000
+      72.5     117.5    27.074    27.074     1.000
+      72.5     122.5    25.296    25.296     1.000
+      72.5     127.5    23.434    23.434     1.000
+      72.5     132.5    21.532    21.532     1.000
+      72.5     137.5    19.644    19.644     1.000
+      72.5     142.5    17.828    17.828     1.000
+      72.5     147.5    16.142    16.142     1.000
+      72.5     152.5    14.634    14.634     1.000
+      72.5     157.5    13.338    13.338     1.000
+      72.5     162.5    11.934    12.260     0.810
+      72.5     167.5    11.138    11.384     0.854
+      72.5     172.5    10.504    10.682     0.888
+      72.5     177.5     9.812    10.124     0.942
+      72.5     182.5     9.504     9.684     0.933
+      72.5     187.5     8.862     9.336     0.937
+      72.5     192.5     8.252     9.062     0.960
+      72.5     197.5     8.164     8.852     0.942
+      72.5     202.5     8.014     8.690     0.926
+      72.5     207.5     7.986     8.578     0.895
+      72.5     212.5     7.844     8.492     0.802
+      72.5     217.5     7.488     8.452     0.786
+      72.5     222.5     7.598     8.428     0.677
+      72.5     227.5     7.424     8.438     0.671
+      72.5     232.5     7.546     8.464     0.542
+      72.5     237.5     7.202     8.506     0.607
+      72.5     242.5     7.452     8.560     0.426
+      72.5     247.5     7.040     8.624     0.513
+      72.5     252.5     7.246     8.688     0.646
+      72.5     257.5     7.016     8.746     0.555
+      72.5     262.5     7.010     8.784     0.733
+      72.5     267.5     8.356     8.770     0.271
+      72.5     272.5     8.020     8.640     0.326
+      72.5     277.5     7.110     8.210     0.729
+      72.5     282.5     7.040     7.696     0.860
+      72.5     287.5     7.002     7.558     0.932
+      72.5     292.5     7.078     7.598     0.969
+      72.5     297.5     7.144     7.726     0.900
+      72.5     302.5     7.274     7.910     0.896
+      72.5     307.5     7.548     8.132     0.805
+      72.5     312.5     7.788     8.394     0.749
+      72.5     317.5     8.242     8.682     0.623
+      72.5     322.5     9.184     9.184     1.000
+      72.5     327.5    10.180    10.180     1.000
+      72.5     332.5    11.206    11.206     1.000
+      72.5     337.5    12.264    12.264     1.000
+      72.5     342.5    13.348    13.348     1.000
+      72.5     347.5    14.458    14.458     1.000
+      72.5     352.5    15.596    15.596     1.000
+      72.5     357.5    16.756    16.756     1.000
+      77.5       2.5    20.322    20.322     1.000
+      77.5       7.5    21.720    21.720     1.000
+      77.5      12.5    23.134    23.134     1.000
+      77.5      17.5    24.556    24.556     1.000
+      77.5      22.5    25.974    25.974     1.000
+      77.5      27.5    27.382    27.382     1.000
+      77.5      32.5    28.768    28.768     1.000
+      77.5      37.5    30.118    30.118     1.000
+      77.5      42.5    31.424    31.424     1.000
+      77.5      47.5    33.128    33.128     1.000
+      77.5      52.5    34.730    34.730     1.000
+      77.5      57.5    36.068    36.068     1.000
+      77.5      62.5    37.142    37.142     1.000
+      77.5      67.5    37.946    37.946     1.000
+      77.5      72.5    38.470    38.470     1.000
+      77.5      77.5    38.700    38.700     1.000
+      77.5      82.5    38.630    38.630     1.000
+      77.5      87.5    38.250    38.250     1.000
+      77.5      92.5    37.562    37.562     1.000
+      77.5      97.5    36.570    36.570     1.000
+      77.5     102.5    35.292    35.292     1.000
+      77.5     107.5    33.744    33.744     1.000
+      77.5     112.5    31.958    31.958     1.000
+      77.5     117.5    29.968    29.968     1.000
+      77.5     122.5    27.820    27.820     1.000
+      77.5     127.5    25.560    25.560     1.000
+      77.5     132.5    23.250    23.250     1.000
+      77.5     137.5    20.958    20.958     1.000
+      77.5     142.5    18.758    18.758     1.000
+      77.5     147.5    16.732    16.732     1.000
+      77.5     152.5    14.956    14.956     1.000
+      77.5     157.5    13.468    13.468     1.000
+      77.5     162.5    11.908    12.274     0.814
+      77.5     167.5    11.072    11.334     0.855
+      77.5     172.5    10.198    10.606     0.990
+      77.5     177.5     9.716    10.038     0.969
+      77.5     182.5     9.334     9.598     0.970
+      77.5     187.5     8.890     9.258     0.951
+      77.5     192.5     8.238     8.994     0.955
+      77.5     197.5     7.816     8.792     0.953
+      77.5     202.5     8.044     8.644     0.910
+      77.5     207.5     7.970     8.538     0.877
+      77.5     212.5     7.526     8.468     0.832
+      77.5     217.5     7.488     8.428     0.747
+      77.5     222.5     7.594     8.420     0.632
+      77.5     227.5     7.494     8.432     0.601
+      77.5     232.5     7.480     8.464     0.530
+      77.5     237.5     7.562     8.510     0.405
+      77.5     242.5     7.404     8.566     0.396
+      77.5     247.5     7.256     8.626     0.562
+      77.5     252.5     7.598     8.680     0.423
+      77.5     257.5     7.016     8.716     0.655
+      77.5     262.5     8.318     8.698     0.221
+      77.5     267.5     7.990     8.566     0.299
+      77.5     272.5     7.016     8.108     0.729
+      77.5     277.5     7.052     7.560     0.831
+      77.5     282.5     7.092     7.424     0.873
+      77.5     287.5     7.044     7.470     0.883
+      77.5     292.5     7.188     7.602     0.889
+      77.5     297.5     7.174     7.796     0.833
+      77.5     302.5     7.496     8.036     0.715
+      77.5     307.5     7.692     8.306     0.619
+      77.5     312.5     8.250     8.614     0.527
+      77.5     317.5     9.276     9.276     1.000
+      77.5     322.5    10.342    10.342     1.000
+      77.5     327.5    11.448    11.448     1.000
+      77.5     332.5    12.596    12.596     1.000
+      77.5     337.5    13.788    13.788     1.000
+      77.5     342.5    15.020    15.020     1.000
+      77.5     347.5    16.294    16.294     1.000
+      77.5     352.5    17.604    17.604     1.000
+      77.5     357.5    18.950    18.950     1.000
Index: /tags/Mars_V0-8-5/Mars/mfit/MTFitLoop.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfit/MTFitLoop.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfit/MTFitLoop.cc	(revision 9661)
@@ -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, 3/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MTFitLoop
+//
+// This class optimized parameters which are calculated in an eventloop.
+// For this it is unimportant whether the loop reads from a file a
+// matrix or from somewhere else...
+//
+// The parameters which are optimized must be stored in a MParContainer
+// which overwrites SetVariables(). Eg. a MDataChain or MF overwrites
+// SetVariables(). In a MF all arguments given as [0], [1] are
+// set by SetVariables (in MDataValue).
+//  eg: In you loop you have a cut like this:
+//      MF filter("MHillas.fWidth<[0]");
+//      filter.SetName("MyParameters");
+//
+//  Now for each time the eventloop is executed
+//  (MEvtLoop::Eventloop(fNumEvents)) the parameters from TMinuit are
+//  passed to MF::SetVariables and changed.
+//
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MTFitLoop.h"
+
+#include <TArrayD.h>
+#include <TMinuit.h>
+#include <TStopwatch.h>
+
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MEvtLoop.h"
+
+#include "MParameters.h"
+
+#include "MRead.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MTFitLoop);
+
+using namespace std;
+
+//------------------------------------------------------------------------
+//
+// fcn calculates the function to be minimized (using TMinuit::Migrad)
+//
+void MTFitLoop::fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)
+{
+    MTFitLoop *optim = (MTFitLoop*)gMinuit->GetObjectFit();
+
+    TMinuit *minuit = gMinuit;
+    f = optim->Fcn(npar, gin, par, iflag);
+    gMinuit = minuit;
+
+}
+Double_t MTFitLoop::Fcn(Int_t &npar, Double_t *gin, Double_t *par, Int_t iflag)
+{
+    MParList *plist = fEvtLoop->GetParList();
+
+    MParameterD   *eval = (MParameterD*)  plist->FindCreateObj("MParameterD", fFitParameter);
+    MParContainer *pars = (MParContainer*)plist->FindObject(fParametersName);
+
+    MRead *read = (MRead*)plist->FindObject("MTaskList")->FindObject("MRead");
+    if (read)
+        read->Rewind();
+
+    if (fDebug>=1)
+    {
+        Double_t fmin, fedm, errdef;
+        Int_t n1, n2, istat;
+        gMinuit->mnstat(fmin, fedm, errdef, n1, n2, istat);
+        *fLog << inf << underline << "Minimization Status so far:" << endl;
+        *fLog << " Calls:     " << gMinuit->fNfcn << endl;
+        *fLog << " Func min:  " << fmin << endl;
+        *fLog << " Found edm: " << fedm << endl;
+        *fLog << " ErrDef:    " << errdef << endl;
+        *fLog << " Status:    ";
+        switch (istat)
+        {
+        case 0:  *fLog << "n/a" << endl; break;
+        case 1:  *fLog << "approximation only, not accurate" << endl; break;
+        case 2:  *fLog << "full matrix, but forced positive-definite" << endl; break;
+        case 3:  *fLog << "full accurate covariance matrix" << endl; break;
+        default: *fLog << "undefined" << endl; break;
+        }
+    }
+
+    if (fDebug>=0)
+    {
+        *fLog << inf << "Set(" << gMinuit->fMaxpar << "): ";
+        for (Int_t i=0; i<gMinuit->fMaxpar; i++)
+            *fLog << par[i] << " ";
+        *fLog << endl;
+    }
+ 
+    pars->SetVariables(TArrayD(gMinuit->fMaxpar, par));
+
+    if (fDebug<3)
+        gLog.SetNullOutput(kTRUE);
+    fEvtLoop->Eventloop(fNumEvents);
+    if (fDebug<3)
+        gLog.SetNullOutput(kFALSE);
+
+    const Double_t f = eval->GetVal();
+
+    if (fDebug>=0)
+        *fLog << inf << "F=" << f << endl;
+
+    if (fDebug>=1)
+        fEvtLoop->GetTaskList()->PrintStatistics();
+
+    return f;
+}
+
+MTFitLoop::MTFitLoop(Int_t num) : fNum(num), fMaxIterations(1000)
+{
+    fDebug     = -1;
+    fNumEvents = -1;
+}
+
+void MTFitLoop::Optimize(MEvtLoop &loop, TArrayD &pars)
+{
+    *fLog << inf << "Event loop was setup" << endl;
+    MParList *parlist = loop.GetParList();
+    if (!parlist)
+        return;
+
+//    MParContainer *pars = (MParContainer*)parlist->FindObject(fParametersName);
+//    if (!pars)
+//        return;
+
+    fEvtLoop = &loop;
+
+//    MParContainer &parameters = *pars;
+
+    TMinuit *minsave = gMinuit;
+
+    gMinuit = new TMinuit(pars.GetSize());
+    gMinuit->SetPrintLevel(-1);
+    gMinuit->SetMaxIterations(fMaxIterations);
+
+    gMinuit->SetFCN(fcn);
+    gMinuit->SetObjectFit(this);
+
+     // For chisq fits call this // seems to be something like %)
+     //
+     // The default tolerance is 0.1, and the minimization will stop");
+     // when the estimated vertical distance to the minimum (EDM) is");
+     // less than 0.001*[tolerance]*UP (see [SET ERRordef]).");
+     //
+    if (gMinuit->SetErrorDef(1))
+    {
+        *fLog << err << dbginf << "SetErrorDef failed." << endl;
+        return;
+    }
+
+    //
+    // Set starting values and step sizes for parameters
+    //
+    for (Int_t i=0; i<pars.GetSize(); i++)
+    {
+        TString name = "par[";
+        name += i;
+        name += "]";
+        Double_t vinit = pars[i];
+        Double_t step  = fabs(pars[i]/3);
+
+        Double_t limlo = 0; // limlo=limup=0: no limits
+        Double_t limup = 2*vinit;
+
+        Bool_t rc = gMinuit->DefineParameter(i, name, vinit, step, 0, limup);
+        if (!rc)
+            continue;
+
+        *fLog << err << dbginf << "Error in defining parameter #" << i << endl;
+        return;
+    }
+
+    for (int i=0; i<pars.GetSize() && i<fFixedParams.GetSize(); i++)
+        if (fFixedParams[i]!=0)
+            gMinuit->FixParameter(i);
+
+    // Now ready for minimization step:
+
+    TStopwatch clock;
+    clock.Start();
+    const Bool_t rc = gMinuit->Migrad();
+    clock.Stop();
+    clock.Print();
+
+    if (rc)
+    {
+        *fLog << err << dbginf << "Migrad failed." << endl;
+        return;
+    }
+
+    *fLog << inf << "Resulting Chisq: " << gMinuit->fAmin << endl;
+
+    //
+    // Update values of fA, fB:
+    //
+    for (Int_t i=0; i<pars.GetSize(); i++)
+    {
+        Double_t x1, x2;
+        gMinuit->GetParameter(i,x1,x2);
+        pars[i] = x1;
+        cout << i << ": " << pars[i] << endl;
+    }
+
+    //list.SetVariables(pars);
+
+    gMinuit = minsave;
+}
Index: /tags/Mars_V0-8-5/Mars/mfit/MTFitLoop.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mfit/MTFitLoop.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mfit/MTFitLoop.h	(revision 9661)
@@ -0,0 +1,50 @@
+#ifndef MARS_MTFitLoop
+#define MARS_MTFitLoop
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#ifndef ROOT_TArrayC
+#include <TArrayC.h>
+#endif
+
+class MEvtLoop;
+
+class MTFitLoop : public MParContainer
+{
+private:
+    Int_t fDebug;     // -1 no output, 0 MTFitLoop output, 1 PrintStatistics output
+    Int_t fNumEvents;
+
+    static void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag);
+    virtual Double_t Fcn(Int_t &npar, Double_t *gin, Double_t *par, Int_t iflag);
+
+    MEvtLoop *fEvtLoop;
+
+    TString   fParametersName;
+    TString   fFitParameter;
+
+    TArrayC   fFixedParams;
+
+    Int_t fNum;
+    Int_t fMaxIterations;
+
+public:
+    MTFitLoop(const Int_t num=0);
+
+    void Optimize(MEvtLoop &loop, TArrayD &pars);
+
+    void SetNameParameters(const char *parm) { fParametersName = parm; }
+    void SetFitParameter(const char *parm)   { fFitParameter   = parm; }
+
+    void SetFixedParameters(const TArrayC &c) { fFixedParams = c; }
+    void SetMaxIterations(Int_t maxiter=500) {fMaxIterations = maxiter;} // for debugging
+
+    void SetDebug(Int_t n)     { fDebug = n; }
+    void SetNumEvents(Int_t n) { fNumEvents = n; }
+
+    ClassDef(MTFitLoop, 0) // Class which can optimize a value (chi^2, significance, etc) calculated in an eventloop
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mgeom/GeomIncl.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mgeom/GeomIncl.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mgeom/GeomIncl.h	(revision 9661)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-8-5/Mars/mgeom/GeomLinkDef.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mgeom/GeomLinkDef.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mgeom/GeomLinkDef.h	(revision 9661)
@@ -0,0 +1,23 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class MGeomPix+;
+#pragma link C++ class MGeomCam+;
+#pragma link C++ class MGeomPMT+;
+#pragma link C++ class MGeomMirror+;
+#pragma link C++ class MGeomCorsikaCT+;
+
+#pragma link C++ class MGeomCamCT1+;
+#pragma link C++ class MGeomCamCT1Daniel+;
+
+#pragma link C++ class MGeomCamMagic+;
+#pragma link C++ class MGeomCamMagicHG+;
+#pragma link C++ class MGeomCamMagic919+;
+
+#pragma link C++ class MGeomCamECO1000+;
+#pragma link C++ class MGeomCamECO1000HG+;
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mgeom/MGeomCam.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mgeom/MGeomCam.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mgeom/MGeomCam.cc	(revision 9661)
@@ -0,0 +1,349 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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>
+!              Harald Kornmayer 01/2001
+!              Markus Gaug      03/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// 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.
+//
+// We use a TObjArray for possible future usage (it is much more flexible
+// than a TClonesArray so that it can store more types of pixels (eg
+// fake pixels which are not really existing)
+//
+// Version 1:
+// ----------
+//  - first implementation
+//
+// Version 2:
+// ----------
+//  - added fPixRatio
+//  - added fPixRatioSqrt
+//
+// Version 3:
+// ----------
+//  - added fNumAreas
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MGeomCam.h"
+
+#include <TClass.h>     // IsA()->New()
+#include <TVector2.h>   // TVector2
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MGeomPix.h"
+
+ClassImp(MGeomCam);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor
+//
+MGeomCam::MGeomCam()
+    : fNumPixels(0), fCamDist(0), fConvMm2Deg(0), fMaxRadius(1), fMinRadius(1)
+{
+    fName  = "MGeomCam";
+    fTitle = "Storage container for a camera geometry";
+}
+
+// --------------------------------------------------------------------------
+//
+// Initializes a Camera Geometry with npix pixels. All pixels
+// are deleted when the corresponding array is deleted.
+//
+MGeomCam::MGeomCam(UInt_t npix, Float_t dist, const char *name, const char *title)
+    : fNumPixels(npix), fCamDist(dist), fConvMm2Deg(kRad2Deg/(dist*1000)), 
+      fPixels(npix), fMaxRadius(1), fMinRadius(1), fPixRatio(npix), fPixRatioSqrt(npix)
+{
+    fName  = name  ? name  : "MGeomCam";
+    fTitle = title ? title : "Storage container for a camera geometry";
+
+    //
+    // make sure that the destructor delete all contained objects
+    //
+    fPixels.SetOwner();
+
+    for (UInt_t i=0; i<npix; i++)
+        fPixels[i] = new MGeomPix;
+
+    SetReadyToSave();
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns a reference of the i-th entry (the pixel with the software idx i)
+// The access is unchecked (for speed reasons!) accesing non existing
+// entries may crash the program!
+//
+MGeomPix &MGeomCam::operator[](Int_t i)
+{
+    return *static_cast<MGeomPix*>(fPixels.UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns a reference of the i-th entry (the pixel with the software idx i)
+// The access is unchecked (for speed reasons!) accesing non existing
+// entries may crash the program!
+//
+MGeomPix &MGeomCam::operator[](Int_t i) const
+{
+    return *static_cast<MGeomPix*>(fPixels.UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculate and fill the arrays storing the ratio of the area of a pixel
+// i to the pixel 0 and its square root.
+// The precalculation is done for speed reasons. Having an event the
+// ratio would be calculated at least once for each pixel which is
+// an enormous amount of numerical calculations, which are time
+// consuming and which can be avoided doing the precalculation.
+//
+void MGeomCam::CalcPixRatio()
+{
+    const Double_t a0 = (*this)[0].GetA();
+
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        fPixRatio[i] = a0/(*this)[i].GetA();
+        fPixRatioSqrt[i] = TMath::Sqrt(fPixRatio[i]);
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+//  Set the kIsOuterRing flag for all pixels which have a outermost pixel
+//  as Next Neighbor and don't have the kIsOutermostRing flag itself.
+//
+void MGeomCam::InitOuterRing()
+{
+    fPixels.ForEach(MGeomPix, CheckOuterRing)(*this);
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculate the highest sector index+1 of all pixels, please make sure
+// the the sector numbers are continous.
+//
+void MGeomCam::CalcNumSectors()
+{
+    fNumSectors = 0;
+
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        const Int_t s = (*this)[i].GetSector();
+
+        if (s>fNumSectors)
+            fNumSectors = s;
+    }
+
+    fNumSectors++;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculate the highest area index+1 of all pixels, please make sure
+// the the area indices are continous.
+//
+void MGeomCam::CalcNumAreas()
+{
+    fNumAreas = 0;
+
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        const Int_t s = (*this)[i].GetAidx();
+
+        if (s>fNumAreas)
+            fNumAreas = s;
+    }
+
+    fNumAreas++;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculate the maximum radius of the camera. This is ment for GUI layout.
+//
+void MGeomCam::CalcMaxRadius()
+{
+    fMaxRadius.Set(fNumAreas+1);
+    fMinRadius.Set(fNumAreas+1);
+
+    for (Int_t i=0; i<fNumAreas+1; i++)
+    {
+        fMaxRadius[i] = 0.;
+        fMinRadius[i] = FLT_MAX;
+    }
+
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        const MGeomPix &pix = (*this)[i];
+
+        const UInt_t  s = pix.GetAidx();
+        const Float_t x = pix.GetX();
+        const Float_t y = pix.GetY();
+        const Float_t d = pix.GetD();
+
+        const Float_t r = TMath::Hypot(x, y);
+
+        const Float_t maxr = r + d;
+        const Float_t minr = r>d ? r-d : 0;
+
+        if (maxr>fMaxRadius[s+1])
+            fMaxRadius[s+1] = maxr;
+
+        if (minr<fMinRadius[s+1])
+            fMinRadius[s+1] = minr;
+
+        if (minr<fMinRadius[0])
+            fMinRadius[0] = minr;
+
+        if (maxr>fMaxRadius[0])
+            fMaxRadius[0] = maxr;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Have to call the radii of the subcameras starting to count from 1
+//
+Float_t MGeomCam::GetMaxRadius(const Int_t i) const
+{
+    return i<-1 || i>fNumAreas ? -1 : fMaxRadius[i+1];
+}
+
+// --------------------------------------------------------------------------
+//
+// Have to call the radii of the subcameras starting to count from 1
+//
+Float_t MGeomCam::GetMinRadius(const Int_t i) const
+{
+    return i<-1 || i>fNumAreas ? -1 : fMinRadius[i+1];
+}
+
+
+// --------------------------------------------------------------------------
+//
+//  returns the ratio of the area of the pixel with index 0 to the pixel
+//  with the specified index i. 0 Is returned if the index argument is
+//  out of range.
+//
+Float_t MGeomCam::GetPixRatio(UInt_t i) const
+{
+    // Former: (*this)[0].GetA()/(*this)[i].GetA();
+    // The const_cast is necessary to support older root version
+    return i<fNumPixels ? const_cast<TArrayF&>(fPixRatio)[i] : 0;
+}
+
+// --------------------------------------------------------------------------
+//
+//  returns the square root of the ratio of the area of the pixel with
+//  index 0 to the pixel with the specified index i. 0 Is returned if
+//  the index argument is out of range.
+//
+Float_t MGeomCam::GetPixRatioSqrt(UInt_t i) const
+{
+    // The const_cast is necessary to support older root version
+    return i<fNumPixels ? const_cast<TArrayF&>(fPixRatioSqrt)[i] : 0;
+}
+
+// --------------------------------------------------------------------------
+//
+//  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;
+
+    fPixels.Print();
+} 
+
+// --------------------------------------------------------------------------
+//
+//  Create a clone of this container. This is very easy, because we
+//  simply have to create a new object of the same type.
+//
+TObject *MGeomCam::Clone(const char *newname) const
+{
+    return (TObject*)IsA()->New();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Return the pixel index corresponding to the coordinates given in x, y.
+//  The coordinates are given in pixel units (millimeters)
+//  If no pixel exists return -1;
+//
+Int_t MGeomCam::GetPixelIdxXY(Float_t x, Float_t y) const
+{
+    for (unsigned int i=0; i<fNumPixels; i++)
+        if ((*this)[i].IsInside(x, y))
+            return i;
+
+    return -1;
+}
+
+Int_t MGeomCam::GetPixelIdx(const TVector2 &v) const
+{
+    return GetPixelIdxXY(v.X(), v.Y());
+}
+
+Int_t MGeomCam::GetPixelIdxDeg(const TVector2 &v) const
+{
+    return GetPixelIdxXYdeg(v.X(), v.Y());
+}
+
+/*
+void MGeomCam::Streamer(TBuffer &R__b)
+{
+   // Stream an object of class MGeomCam.
+
+    if (R__b.IsReading())
+    {
+        MGeomCam::Class()->ReadBuffer(R__b, this);
+
+        UInt_t R__s, R__c;
+        Version_t R__v = b.ReadVersion(&R__s, &R__c);
+        if (R__v > 2) {
+            MGeomCam::Class()->ReadBuffer(b, this, R__v, R__s, R__c);
+
+        Version_t v = MGeomCam::Class()->GetClassVersion();
+   }
+   else
+   {
+       MGeomCam::Class()->WriteBuffer(R__b, this);
+   }
+}
+*/
Index: /tags/Mars_V0-8-5/Mars/mgeom/MGeomCam.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mgeom/MGeomCam.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mgeom/MGeomCam.h	(revision 9661)
@@ -0,0 +1,91 @@
+#ifndef MARS_MGeomCam
+#define MARS_MGeomCam
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+#ifndef ROOT_TObjArray
+#include <TObjArray.h>
+#endif
+#ifndef ROOT_TArrayF
+#include <TArrayF.h>
+#endif
+
+class TVector2;
+class MGeomPix;
+
+class MGeomCam : public MParContainer
+{
+private:
+    UInt_t    fNumPixels;    // Number of pixels in this camera
+
+    Float_t   fCamDist;      // [m] Average distance of the camera from the mirror
+    Float_t   fConvMm2Deg;   // conversion factor to convert mm in the camera plain into degrees
+
+    TObjArray fPixels;       // Array of singel pixels storing the geometry
+
+    TArrayF   fMaxRadius;    // maximum radius of the part of the camera with the same pixel size (eg. for GUI layout)
+    TArrayF   fMinRadius;    // minimum radius of the part of the camera with the same pixel size (eg. for GUI layout)    
+    TArrayF   fPixRatio;     // Array storing the ratio between size of pixel 0 and pixel idx (for speed reasons)
+    TArrayF   fPixRatioSqrt; // Array storing the square root ratio between size of pixel 0 and pixel idx (for speed reasons)
+
+    Int_t     fNumSectors;   // Number of sectors
+    Int_t     fNumAreas;     // Number of different pixel sizes
+
+protected:
+
+    void CalcMaxRadius();
+    void CalcNumSectors();
+    void CalcNumAreas();
+    void InitOuterRing();
+    void InitGeometry()
+    {
+        CalcNumSectors();
+        CalcNumAreas();
+        CalcMaxRadius();
+        CalcPixRatio();
+        InitOuterRing();
+    }
+
+
+public:
+    MGeomCam();
+    MGeomCam(UInt_t npix, Float_t dist, const char *name=NULL, const char *title=NULL);
+
+    virtual TObject *Clone(const char *newname=NULL) const;
+
+    void CalcPixRatio(); 
+    // FIXME, workaround: this function is made public just to allow
+    // the use of some camera files from the 0.7 beta version in which the 
+    // array containing pixel ratios is not initialized.
+
+    Float_t GetCameraDist() const { return fCamDist; }
+    Float_t GetConvMm2Deg() const { return fConvMm2Deg; }
+
+    UInt_t  GetNumPixels()  const { return fNumPixels; }
+
+    Float_t GetMaxRadius(const Int_t i=-1) const;
+    Float_t GetMinRadius(const Int_t i=-1) const;
+    
+    UInt_t  GetNumSectors()                const  { return fNumSectors; }
+    UInt_t  GetNumAreas()                  const  { return fNumAreas; }
+    Float_t GetPixRatio(UInt_t i)          const;
+    Float_t GetPixRatioSqrt(UInt_t i)      const;
+
+    MGeomPix &operator[](Int_t i);
+    MGeomPix &operator[](Int_t i) const;
+
+    Int_t GetPixelIdx(const TVector2 &v) const;
+    Int_t GetPixelIdxDeg(const TVector2 &v) const;
+    Int_t GetPixelIdxXY(Float_t x, Float_t y) const;
+    Int_t GetPixelIdxXYdeg(Float_t x, Float_t y) const
+    {
+        return GetPixelIdxXY(x/fConvMm2Deg, y/fConvMm2Deg);
+    }
+
+    virtual void Print(Option_t *opt=NULL)   const;
+
+    ClassDef(MGeomCam, 4)  // Geometry base class for the camera
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mgeom/MGeomCamCT1.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mgeom/MGeomCamCT1.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mgeom/MGeomCamCT1.cc	(revision 9661)
@@ -0,0 +1,265 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Harald Kornmayer 1/2001
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// 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 "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();
+    InitGeometry();
+} 
+
+// --------------------------------------------------------------------------
+//
+//  Create Next Neighbors: Fill the NN Info into the pixel objects.
+//
+void MGeomCamCT1::CreateNN()
+{ 
+    const Short_t nn[127][6] = {       // Neighbors of #
+      {  1,   2,   3,   4,   5,   6},  // 0
+      {  0,   2,   6,   7,   8,  18},
+      {  0,   1,   3,   8,   9,  10},
+      {  0,   2,   4,  10,  11,  12},
+      {  0,   3,   5,  12,  13,  14},
+      {  0,   4,   6,  14,  15,  16},
+      {  0,   1,   5,  16,  17,  18},
+      {  1,   8,  18,  19,  20,  36},
+      {  1,   2,   7,   9,  20,  21},
+      {  2,   8,  10,  21,  22,  23},
+      {  2,   3,   9,  11,  23,  24},  // 10
+      {  3,  10,  12,  24,  25,  26},
+      {  3,   4,  11,  13,  26,  27},
+      {  4,  12,  14,  27,  28,  29},
+      {  4,   5,  13,  15,  29,  30},
+      {  5,  14,  16,  30,  31,  32},
+      {  5,   6,  15,  17,  32,  33},
+      {  6,  16,  18,  33,  34,  35},
+      {  1,   6,   7,  17,  35,  36},
+      {  7,  20,  36,  37,  38,  60},
+      {  7,   8,  19,  21,  38,  39},  // 20
+      {  8,   9,  20,  22,  39,  40},
+      {  9,  21,  23,  40,  41,  42},
+      {  9,  10,  22,  24,  42,  43},
+      { 10,  11,  23,  25,  43,  44},
+      { 11,  24,  26,  44,  45,  46},
+      { 11,  12,  25,  27,  46,  47},
+      { 12,  13,  26,  28,  47,  48},
+      { 13,  27,  29,  48,  49,  50},
+      { 13,  14,  28,  30,  50,  51},
+      { 14,  15,  29,  31,  51,  52},  // 30
+      { 15,  30,  32,  52,  53,  54},
+      { 15,  16,  31,  33,  54,  55},
+      { 16,  17,  32,  34,  55,  56},
+      { 17,  33,  35,  56,  57,  58},
+      { 17,  18,  34,  36,  58,  59},
+      {  7,  18,  19,  35,  59,  60},
+      { 19,  38,  60,  61,  62,  90},
+      { 19,  20,  37,  39,  62,  63},
+      { 20,  21,  38,  40,  63,  64},
+      { 21,  22,  39,  41,  64,  65},  // 40
+      { 22,  40,  42,  65,  66,  67},
+      { 22,  23,  41,  43,  67,  68},
+      { 23,  24,  42,  44,  68,  69},
+      { 24,  25,  43,  45,  69,  70},
+      { 25,  44,  46,  70,  71,  72},
+      { 25,  26,  45,  47,  72,  73},
+      { 26,  27,  46,  48,  73,  74},
+      { 27,  28,  47,  49,  74,  75},
+      { 28,  48,  50,  75,  76,  77},
+      { 28,  29,  49,  51,  77,  78},  // 50
+      { 29,  30,  50,  52,  78,  79},
+      { 30,  31,  51,  53,  79,  80},
+      { 31,  52,  54,  80,  81,  82},
+      { 31,  32,  53,  55,  82,  83},
+      { 32,  33,  54,  56,  83,  84},
+      { 33,  34,  55,  57,  84,  85},
+      { 34,  56,  58,  85,  86,  87},
+      { 34,  35,  57,  59,  87,  88},
+      { 35,  36,  58,  60,  88,  89},
+      { 19,  36,  37,  59,  89,  90},  // 60
+      { 37,  62,  90,  91,  92, 126},
+      { 37,  38,  61,  63,  92,  93},
+      { 38,  39,  62,  64,  93,  94},
+      { 39,  40,  63,  65,  94,  95},
+      { 40,  41,  64,  66,  95,  96},
+      { 41,  65,  67,  96,  97,  98},
+      { 41,  42,  66,  68,  98,  99},
+      { 42,  43,  67,  69,  99, 100},
+      { 43,  44,  68,  70, 100, 101},
+      { 44,  45,  69,  71, 101, 102},  // 70
+      { 45,  70,  72, 102, 103, 104},
+      { 45,  46,  71,  73, 104, 105},
+      { 46,  47,  72,  74, 105, 106},
+      { 47,  48,  73,  75, 106, 107},
+      { 48,  49,  74,  76, 107, 108},
+      { 49,  75,  77, 108, 109, 110},
+      { 49,  50,  76,  78, 110, 111},
+      { 50,  51,  77,  79, 111, 112},
+      { 51,  52,  78,  80, 112, 113},
+      { 52,  53,  79,  81, 113, 114},  // 80
+      { 53,  80,  82, 114, 115, 116},
+      { 53,  54,  81,  83, 116, 117},
+      { 54,  55,  82,  84, 117, 118},
+      { 55,  56,  83,  85, 118, 119},
+      { 56,  57,  84,  86, 119, 120},
+      { 57,  85,  87, 120, 121, 122},
+      { 57,  58,  86,  88, 122, 123},
+      { 58,  59,  87,  89, 123, 124},
+      { 59,  60,  88,  90, 124, 125},
+      { 37,  60,  61,  89, 125, 126},  // 90
+      { 61,  92, 126,  -1,  -1,  -1},
+      { 61,  62,  91,  93,  -1,  -1},
+      { 62,  63,  92,  94,  -1,  -1},
+      { 63,  64,  93,  95,  -1,  -1},
+      { 64,  65,  94,  96,  -1,  -1},
+      { 65,  66,  95,  97,  -1,  -1},
+      { 66,  96,  98,  -1,  -1,  -1},
+      { 66,  67,  97,  99,  -1,  -1},
+      { 67,  68,  98, 100,  -1,  -1},
+      { 68,  69,  99, 101,  -1,  -1},  // 100
+      { 69,  70, 100, 102,  -1,  -1},
+      { 70,  71, 101, 103,  -1,  -1},
+      { 71, 102, 104,  -1,  -1,  -1},
+      { 71,  72, 103, 105,  -1,  -1},
+      { 72,  73, 104, 106,  -1,  -1},
+      { 73,  74, 105, 107,  -1,  -1},
+      { 74,  75, 106, 108,  -1,  -1},
+      { 75,  76, 107, 109,  -1,  -1},
+      { 76, 108, 110,  -1,  -1,  -1},
+      { 76,  77, 109, 111,  -1,  -1},  // 110
+      { 77,  78, 110, 112,  -1,  -1},
+      { 78,  79, 111, 113,  -1,  -1},
+      { 79,  80, 112, 114,  -1,  -1},
+      { 80,  81, 113, 115,  -1,  -1},
+      { 81, 114, 116,  -1,  -1,  -1},
+      { 81,  82, 115, 117,  -1,  -1},
+      { 82,  83, 116, 118,  -1,  -1},
+      { 83,  84, 117, 119,  -1,  -1},
+      { 84,  85, 118, 120,  -1,  -1},
+      { 85,  86, 119, 121,  -1,  -1},  // 120
+      { 86, 120, 122,  -1,  -1,  -1},
+      { 86,  87, 121, 123,  -1,  -1},
+      { 87,  88, 122, 124,  -1,  -1},
+      { 88,  89, 123, 125,  -1,  -1},
+      { 89,  90, 124, 126,  -1,  -1},
+      { 61,  90,  91, 125,  -1,  -1}   // 126
+  };
+
+  for (Int_t i=0; i<127; i++)
+      (*this)[i].SetNeighbors(nn[i][0], nn[i][1], nn[i][2],
+                              nn[i][3], nn[i][4], nn[i][5]);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Calculate the geometry information of CT1 and fill this information
+//  into the pixel objects.
+//
+void MGeomCamCT1::CreateCam()
+{
+    //
+    // fill the geometry class with the coordinates of the CT1 camera
+    //
+    //*fLog << inf << " Create CT1 geometry " << endl;
+
+    //
+    // this algorithm is from Martin Kestel originally
+    // it was punt into a root/C++ context by Harald Kornmayer and Thomas Bretz
+   
+    const Float_t diameter = 21;    // units are mm
+    const Float_t kS32  = sqrt(3)/2;
+
+    //
+    //  add the first pixel to the list
+    //
+    Int_t pixnum = 0;
+
+    (*this)[pixnum++].Set(0, 0, diameter);
+
+    for (Int_t ring=1; ring<7; ring++)
+    {
+        //
+        // calc. coords for this ring counting from the
+        // starting number to the ending number
+        //
+        for (int i=0; i<ring; i++)
+            (*this)[pixnum++].Set((ring-i*0.5)*diameter,
+                                  i*kS32*diameter,
+                                  diameter);
+
+        for (int i=0; i<ring; i++)
+            (*this)[pixnum++].Set((ring*0.5-i)*diameter,
+                                  ring*kS32 * diameter,
+                                  diameter);
+
+        for (int i=0; i<ring; i++)
+            (*this)[pixnum++].Set(-(ring+i)*0.5*diameter,
+                                  (ring-i)*kS32*diameter,
+                                  diameter);
+
+        for (int i=0; i<ring; i++)
+            (*this)[pixnum++].Set((0.5*i-ring)*diameter,
+                                  -i*kS32*diameter,
+                                  diameter);
+
+        for (int i=0; i<ring; i++)
+            (*this)[pixnum++].Set((i-ring*0.5)*diameter,
+                                  -ring*kS32 * diameter,
+                                  diameter);
+
+        for (int i=0; i<ring; i++)
+            (*this)[pixnum++].Set((ring+i)*0.5*diameter,
+                                  (-ring+i)*kS32*diameter,
+                                  diameter);
+    }
+}
+
Index: /tags/Mars_V0-8-5/Mars/mgeom/MGeomCamCT1.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mgeom/MGeomCamCT1.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mgeom/MGeomCamCT1.h	(revision 9661)
@@ -0,0 +1,23 @@
+#ifndef MARS_MGeomCamCT1
+#define MARS_MGeomCamCT1
+
+#ifndef MARS_MGeomCam
+#include "MGeomCam.h"
+#endif
+
+class MGeomCamCT1 : public MGeomCam
+{
+private:
+
+    void CreateCam();
+    void CreateNN();
+
+public:
+
+    MGeomCamCT1(const char *name=NULL);
+
+    ClassDef(MGeomCamCT1, 1)		// Geometry class for the CT1 camera
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mgeom/MGeomCamCT1Daniel.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mgeom/MGeomCamCT1Daniel.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mgeom/MGeomCamCT1Daniel.cc	(revision 9661)
@@ -0,0 +1,269 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz    12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Harald Kornmayer 1/2001
+!   Author(s): Wolfgang Wittek 10/2003 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MGeomCamCT1Daniel
+//
+// This class stores the geometry information of the CT1 camera.
+// The next neighbor information comes from a table, the geometry layout
+// is calculated (for Algorithm see CreateCam
+//
+//
+// The only difference to MGeomCamCT1 is the second argument of MGeomCam
+// (which is the distance camera-reflector)
+//        it is        dist = 4.8129 m    (instead of 4.88  m)
+//
+// together with the pixel diameter of d = 21 mm this gives      
+// d/dist = 0.0043633 = 0.25 deg    (instead of 0.0043033 = 0.2466 deg)
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MGeomCamCT1Daniel.h"
+
+#include <math.h>     // floor
+
+#include "MGeomPix.h"
+
+ClassImp(MGeomCamCT1Daniel);
+
+// --------------------------------------------------------------------------
+//
+//  CT1 camera has 127 pixels. For geometry and Next Neighbor info see
+//  CreateCam and CreateNN
+//
+MGeomCamCT1Daniel::MGeomCamCT1Daniel(const char *name)
+    : MGeomCam(127, 4.8129, name, "Geometry information of CT1 camera")
+{
+    CreateCam();
+    CreateNN();
+    InitGeometry();
+} 
+
+// --------------------------------------------------------------------------
+//
+//  Create Next Neighbors: Fill the NN Info into the pixel objects.
+//
+void MGeomCamCT1Daniel::CreateNN()
+{ 
+    const Short_t nn[127][6] = {       // Neighbors of #
+      {  1,   2,   3,   4,   5,   6},  // 0
+      {  0,   2,   6,   7,   8,  18},
+      {  0,   1,   3,   8,   9,  10},
+      {  0,   2,   4,  10,  11,  12},
+      {  0,   3,   5,  12,  13,  14},
+      {  0,   4,   6,  14,  15,  16},
+      {  0,   1,   5,  16,  17,  18},
+      {  1,   8,  18,  19,  20,  36},
+      {  1,   2,   7,   9,  20,  21},
+      {  2,   8,  10,  21,  22,  23},
+      {  2,   3,   9,  11,  23,  24},  // 10
+      {  3,  10,  12,  24,  25,  26},
+      {  3,   4,  11,  13,  26,  27},
+      {  4,  12,  14,  27,  28,  29},
+      {  4,   5,  13,  15,  29,  30},
+      {  5,  14,  16,  30,  31,  32},
+      {  5,   6,  15,  17,  32,  33},
+      {  6,  16,  18,  33,  34,  35},
+      {  1,   6,   7,  17,  35,  36},
+      {  7,  20,  36,  37,  38,  60},
+      {  7,   8,  19,  21,  38,  39},  // 20
+      {  8,   9,  20,  22,  39,  40},
+      {  9,  21,  23,  40,  41,  42},
+      {  9,  10,  22,  24,  42,  43},
+      { 10,  11,  23,  25,  43,  44},
+      { 11,  24,  26,  44,  45,  46},
+      { 11,  12,  25,  27,  46,  47},
+      { 12,  13,  26,  28,  47,  48},
+      { 13,  27,  29,  48,  49,  50},
+      { 13,  14,  28,  30,  50,  51},
+      { 14,  15,  29,  31,  51,  52},  // 30
+      { 15,  30,  32,  52,  53,  54},
+      { 15,  16,  31,  33,  54,  55},
+      { 16,  17,  32,  34,  55,  56},
+      { 17,  33,  35,  56,  57,  58},
+      { 17,  18,  34,  36,  58,  59},
+      {  7,  18,  19,  35,  59,  60},
+      { 19,  38,  60,  61,  62,  90},
+      { 19,  20,  37,  39,  62,  63},
+      { 20,  21,  38,  40,  63,  64},
+      { 21,  22,  39,  41,  64,  65},  // 40
+      { 22,  40,  42,  65,  66,  67},
+      { 22,  23,  41,  43,  67,  68},
+      { 23,  24,  42,  44,  68,  69},
+      { 24,  25,  43,  45,  69,  70},
+      { 25,  44,  46,  70,  71,  72},
+      { 25,  26,  45,  47,  72,  73},
+      { 26,  27,  46,  48,  73,  74},
+      { 27,  28,  47,  49,  74,  75},
+      { 28,  48,  50,  75,  76,  77},
+      { 28,  29,  49,  51,  77,  78},  // 50
+      { 29,  30,  50,  52,  78,  79},
+      { 30,  31,  51,  53,  79,  80},
+      { 31,  52,  54,  80,  81,  82},
+      { 31,  32,  53,  55,  82,  83},
+      { 32,  33,  54,  56,  83,  84},
+      { 33,  34,  55,  57,  84,  85},
+      { 34,  56,  58,  85,  86,  87},
+      { 34,  35,  57,  59,  87,  88},
+      { 35,  36,  58,  60,  88,  89},
+      { 19,  36,  37,  59,  89,  90},  // 60
+      { 37,  62,  90,  91,  92, 126},
+      { 37,  38,  61,  63,  92,  93},
+      { 38,  39,  62,  64,  93,  94},
+      { 39,  40,  63,  65,  94,  95},
+      { 40,  41,  64,  66,  95,  96},
+      { 41,  65,  67,  96,  97,  98},
+      { 41,  42,  66,  68,  98,  99},
+      { 42,  43,  67,  69,  99, 100},
+      { 43,  44,  68,  70, 100, 101},
+      { 44,  45,  69,  71, 101, 102},  // 70
+      { 45,  70,  72, 102, 103, 104},
+      { 45,  46,  71,  73, 104, 105},
+      { 46,  47,  72,  74, 105, 106},
+      { 47,  48,  73,  75, 106, 107},
+      { 48,  49,  74,  76, 107, 108},
+      { 49,  75,  77, 108, 109, 110},
+      { 49,  50,  76,  78, 110, 111},
+      { 50,  51,  77,  79, 111, 112},
+      { 51,  52,  78,  80, 112, 113},
+      { 52,  53,  79,  81, 113, 114},  // 80
+      { 53,  80,  82, 114, 115, 116},
+      { 53,  54,  81,  83, 116, 117},
+      { 54,  55,  82,  84, 117, 118},
+      { 55,  56,  83,  85, 118, 119},
+      { 56,  57,  84,  86, 119, 120},
+      { 57,  85,  87, 120, 121, 122},
+      { 57,  58,  86,  88, 122, 123},
+      { 58,  59,  87,  89, 123, 124},
+      { 59,  60,  88,  90, 124, 125},
+      { 37,  60,  61,  89, 125, 126},  // 90
+      { 61,  92, 126,  -1,  -1,  -1},
+      { 61,  62,  91,  93,  -1,  -1},
+      { 62,  63,  92,  94,  -1,  -1},
+      { 63,  64,  93,  95,  -1,  -1},
+      { 64,  65,  94,  96,  -1,  -1},
+      { 65,  66,  95,  97,  -1,  -1},
+      { 66,  96,  98,  -1,  -1,  -1},
+      { 66,  67,  97,  99,  -1,  -1},
+      { 67,  68,  98, 100,  -1,  -1},
+      { 68,  69,  99, 101,  -1,  -1},  // 100
+      { 69,  70, 100, 102,  -1,  -1},
+      { 70,  71, 101, 103,  -1,  -1},
+      { 71, 102, 104,  -1,  -1,  -1},
+      { 71,  72, 103, 105,  -1,  -1},
+      { 72,  73, 104, 106,  -1,  -1},
+      { 73,  74, 105, 107,  -1,  -1},
+      { 74,  75, 106, 108,  -1,  -1},
+      { 75,  76, 107, 109,  -1,  -1},
+      { 76, 108, 110,  -1,  -1,  -1},
+      { 76,  77, 109, 111,  -1,  -1},  // 110
+      { 77,  78, 110, 112,  -1,  -1},
+      { 78,  79, 111, 113,  -1,  -1},
+      { 79,  80, 112, 114,  -1,  -1},
+      { 80,  81, 113, 115,  -1,  -1},
+      { 81, 114, 116,  -1,  -1,  -1},
+      { 81,  82, 115, 117,  -1,  -1},
+      { 82,  83, 116, 118,  -1,  -1},
+      { 83,  84, 117, 119,  -1,  -1},
+      { 84,  85, 118, 120,  -1,  -1},
+      { 85,  86, 119, 121,  -1,  -1},  // 120
+      { 86, 120, 122,  -1,  -1,  -1},
+      { 86,  87, 121, 123,  -1,  -1},
+      { 87,  88, 122, 124,  -1,  -1},
+      { 88,  89, 123, 125,  -1,  -1},
+      { 89,  90, 124, 126,  -1,  -1},
+      { 61,  90,  91, 125,  -1,  -1}   // 126
+  };
+
+  for (Int_t i=0; i<127; i++)
+      (*this)[i].SetNeighbors(nn[i][0], nn[i][1], nn[i][2],
+                              nn[i][3], nn[i][4], nn[i][5]);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Calculate the geometry information of CT1 and fill this information
+//  into the pixel objects.
+//
+void MGeomCamCT1Daniel::CreateCam()
+{
+    //
+    // fill the geometry class with the coordinates of the CT1 camera
+    //
+    //*fLog << inf << " Create CT1 geometry " << endl;
+
+    //
+    // this algorithm is from Martin Kestel originally
+    // it was punt into a root/C++ context by Harald Kornmayer and Thomas Bretz
+   
+    const Float_t diameter = 21;    // units are mm
+    const Float_t kS32  = sqrt(3)/2;
+
+    //
+    //  add the first pixel to the list
+    //
+    Int_t pixnum = 0;
+
+    (*this)[pixnum++].Set(0, 0, diameter);
+
+    for (Int_t ring=1; ring<7; ring++)
+    {
+        //
+        // calc. coords for this ring counting from the
+        // starting number to the ending number
+        //
+        for (int i=0; i<ring; i++)
+            (*this)[pixnum++].Set((ring-i*0.5)*diameter,
+                                  i*kS32*diameter,
+                                  diameter);
+
+        for (int i=0; i<ring; i++)
+            (*this)[pixnum++].Set((ring*0.5-i)*diameter,
+                                  ring*kS32 * diameter,
+                                  diameter);
+
+        for (int i=0; i<ring; i++)
+            (*this)[pixnum++].Set(-(ring+i)*0.5*diameter,
+                                  (ring-i)*kS32*diameter,
+                                  diameter);
+
+        for (int i=0; i<ring; i++)
+            (*this)[pixnum++].Set((0.5*i-ring)*diameter,
+                                  -i*kS32*diameter,
+                                  diameter);
+
+        for (int i=0; i<ring; i++)
+            (*this)[pixnum++].Set((i-ring*0.5)*diameter,
+                                  -ring*kS32 * diameter,
+                                  diameter);
+
+        for (int i=0; i<ring; i++)
+            (*this)[pixnum++].Set((ring+i)*0.5*diameter,
+                                  (-ring+i)*kS32*diameter,
+                                  diameter);
+    }
+}
+
Index: /tags/Mars_V0-8-5/Mars/mgeom/MGeomCamCT1Daniel.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mgeom/MGeomCamCT1Daniel.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mgeom/MGeomCamCT1Daniel.h	(revision 9661)
@@ -0,0 +1,23 @@
+#ifndef MARS_MGeomCamCT1Daniel
+#define MARS_MGeomCamCT1Daniel
+
+#ifndef MARS_MGeomCam
+#include "MGeomCam.h"
+#endif
+
+class MGeomCamCT1Daniel : public MGeomCam
+{
+private:
+
+    void CreateCam();
+    void CreateNN();
+
+public:
+
+    MGeomCamCT1Daniel(const char *name=NULL);
+
+    ClassDef(MGeomCamCT1Daniel, 1)  // Geometry class for the CT1 camera (daniel's version)
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mgeom/MGeomCamECO1000.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mgeom/MGeomCamECO1000.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mgeom/MGeomCamECO1000.cc	(revision 9661)
@@ -0,0 +1,895 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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, 4/2003 <mailto:blanch@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MGeomCamECO1000
+//
+// This class stores the geometry information of the ECO1000 camera.
+// All information are copied from tables, see source code.
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MGeomCamECO1000.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MGeomPix.h"
+
+ClassImp(MGeomCamECO1000);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+//  Magic camera has 577 pixels. For geometry and Next Neighbor info see
+//  CreateCam and CreateNN
+//
+MGeomCamECO1000::MGeomCamECO1000(const char *name)
+    : MGeomCam(577, 34.5, name, "Geometry information of Magic Camera")
+{
+    CreateCam();
+    CreateNN();
+    InitGeometry();
+}
+
+// --------------------------------------------------------------------------
+//
+//  This fills the geometry information from a table into the pixel objects.
+//
+void MGeomCamECO1000::CreateCam()
+{
+    //
+    //   fill the geometry class with the coordinates of the MAGIC camera
+    //
+
+    //
+    //   here define the hardwire things of the ECO 1000 telescope
+    //
+    const Float_t xtemp[577] = {
+      0, 60, 30, -30, -60, -30, 30, 120, // 0
+      90, 60, 0, -60, -90, -120, -90, -60, // 8
+      0, 60, 90, 180, 150, 120, 90, 30, // 16
+      -30, -90, -120, -150, -180, -150, -120, -90, // 24
+      -30, 30, 90, 120, 150, 240, 210, 180, // 32
+      150, 120, 60, 0, -60, -120, -150, -180, // 40
+      -210, -240, -210, -180, -150, -120, -60, 0, // 48
+      60, 120, 150, 180, 210, 300, 270, 240, // 56
+      210, 180, 150, 90, 30, -30, -90, -150, // 64
+      -180, -210, -240, -270, -300, -270, -240, -210, // 72
+      -180, -150, -90, -30, 30, 90, 150, 180, // 80
+      210, 240, 270, 360, 330, 300, 270, 240, // 88
+      210, 180, 120, 60, 0, -60, -120, -180, // 96
+      -210, -240, -270, -300, -330, -360, -330, -300, // 104
+      -270, -240, -210, -180, -120, -60, 0, 60, // 112
+      120, 180, 210, 240, 270, 300, 330, 420, // 120
+      390, 360, 330, 300, 270, 240, 210, 150, // 128
+      90, 30, -30, -90, -150, -210, -240, -270, // 136
+      -300, -330, -360, -390, -420, -390, -360, -330, // 144
+      -300, -270, -240, -210, -150, -90, -30, 30, // 152
+      90, 150, 210, 240, 270, 300, 330, 360, // 160
+      390, 480, 450, 420, 390, 360, 330, 300, // 168
+      270, 240, 180, 120, 60, 0, -60, -120, // 176
+      -180, -240, -270, -300, -330, -360, -390, -420, // 184
+      -450, -480, -450, -420, -390, -360, -330, -300, // 192
+      -270, -240, -180, -120, -60, 0, 60, 120, // 200
+      180, 240, 270, 300, 330, 360, 390, 420, // 208
+      450, 540, 510, 480, 450, 420, 390, 360, // 216
+      330, 300, 270, 210, 150, 90, 30, -30, // 224
+      -90, -150, -210, -270, -300, -330, -360, -390, // 232
+      -420, -450, -480, -510, -540, -510, -480, -450, // 240
+      -420, -390, -360, -330, -300, -270, -210, -150, // 248
+      -90, -30, 30, 90, 150, 210, 270, 300, // 256
+      330, 360, 390, 420, 450, 480, 510, 600, // 264
+      570, 540, 510, 480, 450, 420, 390, 360, // 272
+      330, 300, 240, 180, 120, 60, 0, -60, // 280
+      -120, -180, -240, -300, -330, -360, -390, -420, // 288
+      -450, -480, -510, -540, -570, -600, -570, -540, // 296
+      -510, -480, -450, -420, -390, -360, -330, -300, // 304
+      -240, -180, -120, -60, 0, 60, 120, 180, // 312
+      240, 300, 330, 360, 390, 420, 450, 480, // 320
+      510, 540, 570, 660, 630, 600, 570, 540, // 328
+      510, 480, 450, 420, 390, 360, 330, 270, // 336
+      210, 150, 90, 30, -30, -90, -150, -210, // 344
+      -270, -330, -360, -390, -420, -450, -480, -510, // 352
+      -540, -570, -600, -630, -660, -630, -600, -570, // 360
+      -540, -510, -480, -450, -420, -390, -360, -330, // 368
+      -270, -210, -150, -90, -30, 30, 90, 150, // 376
+      210, 270, 330, 360, 390, 420, 450, 480, // 384
+      510, 540, 570, 600, 630, 720, 660, 600, // 392
+      540, 480, 420, 300, 180, 60, -60, -180, // 400
+      -300, -420, -480, -540, -600, -660, -720, -720, // 408
+      -660, -600, -540, -480, -420, -300, -180, -60, // 416
+      60, 180, 300, 420, 480, 540, 600, 660, // 424
+      720, 840, 780, 720, 660, 600, 540, 480, // 432
+      360, 240, 120, 0, -120, -240, -360, -480, // 440
+      -540, -600, -660, -720, -780, -840, -840, -780, // 448
+      -720, -660, -600, -540, -480, -360, -240, -120, // 456
+      0, 120, 240, 360, 480, 540, 600, 660, // 464
+      720, 780, 840, 960, 900, 840, 780, 720, // 472
+      660, 600, 540, 420, 300, 180, 60, -60, // 480
+      -180, -300, -420, -540, -600, -660, -720, -780, // 488
+      -840, -900, -960, -960, -900, -840, -780, -720, // 496
+      -660, -600, -540, -420, -300, -180, -60, 60, // 504
+      180, 300, 420, 540, 600, 660, 720, 780, // 512
+      840, 900, 960, 1080, 1020, 960, 900, 840, // 520
+      780, 720, 660, 600, 480, 360, 240, 120, // 528
+      0, -120, -240, -360, -480, -600, -660, -720, // 536
+      -780, -840, -900, -960, -1020, -1080, -1080, -1020, // 544
+      -960, -900, -840, -780, -720, -660, -600, -480, // 552
+      -360, -240, -120, 0, 120, 240, 360, 480, // 560
+      600, 660, 720, 780, 840, 900, 960, 1020, // 568
+      1080                        //576
+    };
+ 
+    const Float_t ytemp[577] = {
+      0, 0, 51.962, 51.962, 0, -51.962, -51.962, 0, // 0
+      51.962, 103.922, 103.922, 103.922, 51.962, 0, -51.962, -103.922, // 8
+      -103.922, -103.922, -51.962, 0, 51.962, 103.922, 155.884, 155.884, // 16
+      155.884, 155.884, 103.922, 51.962, 0, -51.962, -103.922, -155.884, // 24
+      -155.884, -155.884, -155.884, -103.922, -51.962, 0, 51.962, 103.922, // 32
+      155.884, 207.846, 207.846, 207.846, 207.846, 207.846, 155.884, 103.922, // 40
+      51.962, 0, -51.962, -103.922, -155.884, -207.846, -207.846, -207.846, // 48
+      -207.846, -207.846, -155.884, -103.922, -51.962, 0, 51.962, 103.922, // 56
+      155.884, 207.846, 259.808, 259.808, 259.808, 259.808, 259.808, 259.808, // 64
+      207.846, 155.884, 103.922, 51.962, 0, -51.962, -103.922, -155.884, // 72
+      -207.846, -259.808, -259.808, -259.808, -259.808, -259.808, -259.808, -207.846, // 80
+      -155.884, -103.922, -51.962, 0, 51.962, 103.922, 155.884, 207.846, // 88
+      259.808, 311.77, 311.77, 311.77, 311.77, 311.77, 311.77, 311.77, // 96
+      259.808, 207.846, 155.884, 103.922, 51.962, 0, -51.962, -103.922, // 104
+      -155.884, -207.846, -259.808, -311.77, -311.77, -311.77, -311.77, -311.77, // 112
+      -311.77, -311.77, -259.808, -207.846, -155.884, -103.922, -51.962, 0, // 120
+      51.962, 103.922, 155.884, 207.846, 259.808, 311.77, 363.73, 363.73, // 128
+      363.73, 363.73, 363.73, 363.73, 363.73, 363.73, 311.77, 259.808, // 136
+      207.846, 155.884, 103.922, 51.962, 0, -51.962, -103.922, -155.884, // 144
+      -207.846, -259.808, -311.77, -363.73, -363.73, -363.73, -363.73, -363.73, // 152
+      -363.73, -363.73, -363.73, -311.77, -259.808, -207.846, -155.884, -103.922, // 160
+      -51.962, 0, 51.962, 103.922, 155.884, 207.846, 259.808, 311.77, // 168
+      363.73, 415.692, 415.692, 415.692, 415.692, 415.692, 415.692, 415.692, // 176
+      415.692, 415.692, 363.73, 311.77, 259.808, 207.846, 155.884, 103.922, // 184
+      51.962, 0, -51.962, -103.922, -155.884, -207.846, -259.808, -311.77, // 192
+      -363.73, -415.692, -415.692, -415.692, -415.692, -415.692, -415.692, -415.692, // 200
+      -415.692, -415.692, -363.73, -311.77, -259.808, -207.846, -155.884, -103.922, // 208
+      -51.962, 0, 51.962, 103.922, 155.884, 207.846, 259.808, 311.77, // 216
+      363.73, 415.692, 467.654, 467.654, 467.654, 467.654, 467.654, 467.654, // 224
+      467.654, 467.654, 467.654, 467.654, 415.692, 363.73, 311.77, 259.808, // 232
+      207.846, 155.884, 103.922, 51.962, 0, -51.962, -103.922, -155.884, // 240
+      -207.846, -259.808, -311.77, -363.73, -415.692, -467.654, -467.654, -467.654, // 248
+      -467.654, -467.654, -467.654, -467.654, -467.654, -467.654, -467.654, -415.692, // 256
+      -363.73, -311.77, -259.808, -207.846, -155.884, -103.922, -51.962, 0, // 264
+      51.962, 103.922, 155.884, 207.846, 259.808, 311.77, 363.73, 415.692, // 272
+      467.654, 519.616, 519.616, 519.616, 519.616, 519.616, 519.616, 519.616, // 280
+      519.616, 519.616, 519.616, 519.616, 467.654, 415.692, 363.73, 311.77, // 288
+      259.808, 207.846, 155.884, 103.922, 51.962, 0, -51.962, -103.922, // 296
+      -155.884, -207.846, -259.808, -311.77, -363.73, -415.692, -467.654, -519.616, // 304
+      -519.616, -519.616, -519.616, -519.616, -519.616, -519.616, -519.616, -519.616, // 312
+      -519.616, -519.616, -467.654, -415.692, -363.73, -311.77, -259.808, -207.846, // 320
+      -155.884, -103.922, -51.962, 0, 51.962, 103.922, 155.884, 207.846, // 328
+      259.808, 311.77, 363.73, 415.692, 467.654, 519.616, 571.576, 571.576, // 336
+      571.576, 571.576, 571.576, 571.576, 571.576, 571.576, 571.576, 571.576, // 344
+      571.576, 571.576, 519.616, 467.654, 415.692, 363.73, 311.77, 259.808, // 352
+      207.846, 155.884, 103.922, 51.962, 0, -51.962, -103.922, -155.884, // 360
+      -207.846, -259.808, -311.77, -363.73, -415.692, -467.654, -519.616, -571.576, // 368
+      -571.576, -571.576, -571.576, -571.576, -571.576, -571.576, -571.576, -571.576, // 376
+      -571.576, -571.576, -571.576, -519.616, -467.654, -415.692, -363.73, -311.77, // 384
+      -259.808, -207.846, -155.884, -103.922, -51.962, 69.282, 173.206, 277.128, // 392
+      381.052, 484.974, 588.898, 658.18, 658.18, 658.18, 658.18, 658.18, // 400
+      658.18, 588.898, 484.974, 381.052, 277.128, 173.206, 69.282, -69.282, // 408
+      -173.206, -277.128, -381.052, -484.974, -588.898, -658.18, -658.18, -658.18, // 416
+      -658.18, -658.18, -658.18, -588.898, -484.974, -381.052, -277.128, -173.206, // 424
+      -69.282, 69.282, 173.206, 277.128, 381.052, 484.974, 588.898, 692.82, // 432
+      762.102, 762.102, 762.102, 762.102, 762.102, 762.102, 762.102, 692.82, // 440
+      588.898, 484.974, 381.052, 277.128, 173.206, 69.282, -69.282, -173.206, // 448
+      -277.128, -381.052, -484.974, -588.898, -692.82, -762.102, -762.102, -762.102, // 456
+      -762.102, -762.102, -762.102, -762.102, -692.82, -588.898, -484.974, -381.052, // 464
+      -277.128, -173.206, -69.282, 69.282, 173.206, 277.128, 381.052, 484.974, // 472
+      588.898, 692.82, 796.744, 866.026, 866.026, 866.026, 866.026, 866.026, // 480
+      866.026, 866.026, 866.026, 796.744, 692.82, 588.898, 484.974, 381.052, // 488
+      277.128, 173.206, 69.282, -69.282, -173.206, -277.128, -381.052, -484.974, // 496
+      -588.898, -692.82, -796.744, -866.026, -866.026, -866.026, -866.026, -866.026, // 504
+      -866.026, -866.026, -866.026, -796.744, -692.82, -588.898, -484.974, -381.052, // 512
+      -277.128, -173.206, -69.282, 69.282, 173.206, 277.128, 381.052, 484.974, // 520
+      588.898, 692.82, 796.744, 900.666, 969.948, 969.948, 969.948, 969.948, // 528
+      969.948, 969.948, 969.948, 969.948, 969.948, 900.666, 796.744, 692.82, // 536
+      588.898, 484.974, 381.052, 277.128, 173.206, 69.282, -69.282, -173.206, // 544
+      -277.128, -381.052, -484.974, -588.898, -692.82, -796.744, -900.666, -969.948, // 552
+      -969.948, -969.948, -969.948, -969.948, -969.948, -969.948, -969.948, -969.948, // 560
+      -900.666, -796.744, -692.82, -588.898, -484.974, -381.052, -277.128, -173.206, // 568
+      -69.282                        //576
+};
+
+    const Float_t rtemp[577] = {
+      60, 60, 60, 60, 60, 60, 60, 60, // 0
+      60, 60, 60, 60, 60, 60, 60, 60, // 8
+      60, 60, 60, 60, 60, 60, 60, 60, // 16
+      60, 60, 60, 60, 60, 60, 60, 60, // 24
+      60, 60, 60, 60, 60, 60, 60, 60, // 32
+      60, 60, 60, 60, 60, 60, 60, 60, // 40
+      60, 60, 60, 60, 60, 60, 60, 60, // 48
+      60, 60, 60, 60, 60, 60, 60, 60, // 56
+      60, 60, 60, 60, 60, 60, 60, 60, // 64
+      60, 60, 60, 60, 60, 60, 60, 60, // 72
+      60, 60, 60, 60, 60, 60, 60, 60, // 80
+      60, 60, 60, 60, 60, 60, 60, 60, // 88
+      60, 60, 60, 60, 60, 60, 60, 60, // 96
+      60, 60, 60, 60, 60, 60, 60, 60, // 104
+      60, 60, 60, 60, 60, 60, 60, 60, // 112
+      60, 60, 60, 60, 60, 60, 60, 60, // 120
+      60, 60, 60, 60, 60, 60, 60, 60, // 128
+      60, 60, 60, 60, 60, 60, 60, 60, // 136
+      60, 60, 60, 60, 60, 60, 60, 60, // 144
+      60, 60, 60, 60, 60, 60, 60, 60, // 152
+      60, 60, 60, 60, 60, 60, 60, 60, // 160
+      60, 60, 60, 60, 60, 60, 60, 60, // 168
+      60, 60, 60, 60, 60, 60, 60, 60, // 176
+      60, 60, 60, 60, 60, 60, 60, 60, // 184
+      60, 60, 60, 60, 60, 60, 60, 60, // 192
+      60, 60, 60, 60, 60, 60, 60, 60, // 200
+      60, 60, 60, 60, 60, 60, 60, 60, // 208
+      60, 60, 60, 60, 60, 60, 60, 60, // 216
+      60, 60, 60, 60, 60, 60, 60, 60, // 224
+      60, 60, 60, 60, 60, 60, 60, 60, // 232
+      60, 60, 60, 60, 60, 60, 60, 60, // 240
+      60, 60, 60, 60, 60, 60, 60, 60, // 248
+      60, 60, 60, 60, 60, 60, 60, 60, // 256
+      60, 60, 60, 60, 60, 60, 60, 60, // 264
+      60, 60, 60, 60, 60, 60, 60, 60, // 272
+      60, 60, 60, 60, 60, 60, 60, 60, // 280
+      60, 60, 60, 60, 60, 60, 60, 60, // 288
+      60, 60, 60, 60, 60, 60, 60, 60, // 296
+      60, 60, 60, 60, 60, 60, 60, 60, // 304
+      60, 60, 60, 60, 60, 60, 60, 60, // 312
+      60, 60, 60, 60, 60, 60, 60, 60, // 320
+      60, 60, 60, 60, 60, 60, 60, 60, // 328
+      60, 60, 60, 60, 60, 60, 60, 60, // 336
+      60, 60, 60, 60, 60, 60, 60, 60, // 344
+      60, 60, 60, 60, 60, 60, 60, 60, // 352
+      60, 60, 60, 60, 60, 60, 60, 60, // 360
+      60, 60, 60, 60, 60, 60, 60, 60, // 368
+      60, 60, 60, 60, 60, 60, 60, 60, // 376
+      60, 60, 60, 60, 60, 60, 60, 60, // 384
+      60, 60, 60, 60, 60, 120, 120, 120, // 392
+      120, 120, 120, 120, 120, 120, 120, 120, // 400
+      120, 120, 120, 120, 120, 120, 120, 120, // 408
+      120, 120, 120, 120, 120, 120, 120, 120, // 416
+      120, 120, 120, 120, 120, 120, 120, 120, // 424
+      120, 120, 120, 120, 120, 120, 120, 120, // 432
+      120, 120, 120, 120, 120, 120, 120, 120, // 440
+      120, 120, 120, 120, 120, 120, 120, 120, // 448
+      120, 120, 120, 120, 120, 120, 120, 120, // 456
+      120, 120, 120, 120, 120, 120, 120, 120, // 464
+      120, 120, 120, 120, 120, 120, 120, 120, // 472
+      120, 120, 120, 120, 120, 120, 120, 120, // 480
+      120, 120, 120, 120, 120, 120, 120, 120, // 488
+      120, 120, 120, 120, 120, 120, 120, 120, // 496
+      120, 120, 120, 120, 120, 120, 120, 120, // 504
+      120, 120, 120, 120, 120, 120, 120, 120, // 512
+      120, 120, 120, 120, 120, 120, 120, 120, // 520
+      120, 120, 120, 120, 120, 120, 120, 120, // 528
+      120, 120, 120, 120, 120, 120, 120, 120, // 536
+      120, 120, 120, 120, 120, 120, 120, 120, // 544
+      120, 120, 120, 120, 120, 120, 120, 120, // 552
+      120, 120, 120, 120, 120, 120, 120, 120, // 560
+      120, 120, 120, 120, 120, 120, 120, 120, // 568
+      120                        //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 MGeomCamECO1000::CreateNN()
+{
+    const Short_t nn[577][6] = {         // Neighbors of #
+        {   1,   2,   3,   4,   5,   6}, // 0
+        {   0,   2,   6,   7,   8,  18},
+        {   0,   1,   3,   8,   9,  10},
+        {   0,   2,   4,  10,  11,  12},
+        {   0,   3,   5,  12,  13,  14},
+        {   0,   4,   6,  14,  15,  16},
+        {   0,   1,   5,  16,  17,  18},
+        {   1,   8,  18,  19,  20,  36},
+        {   1,   2,   7,   9,  20,  21},
+        {   2,   8,  10,  21,  22,  23},
+        {   2,   3,   9,  11,  23,  24},
+        {   3,  10,  12,  24,  25,  26},
+        {   3,   4,  11,  13,  26,  27},
+        {   4,  12,  14,  27,  28,  29},
+        {   4,   5,  13,  15,  29,  30},
+        {   5,  14,  16,  30,  31,  32},
+        {   5,   6,  15,  17,  32,  33},
+        {   6,  16,  18,  33,  34,  35},
+        {   1,   6,   7,  17,  35,  36},
+        {   7,  20,  36,  37,  38,  60},
+        {   7,   8,  19,  21,  38,  39}, // 20
+        {   8,   9,  20,  22,  39,  40},
+        {   9,  21,  23,  40,  41,  42},
+        {   9,  10,  22,  24,  42,  43},
+        {  10,  11,  23,  25,  43,  44},
+        {  11,  24,  26,  44,  45,  46},
+        {  11,  12,  25,  27,  46,  47},
+        {  12,  13,  26,  28,  47,  48},
+        {  13,  27,  29,  48,  49,  50},
+        {  13,  14,  28,  30,  50,  51},
+        {  14,  15,  29,  31,  51,  52},
+        {  15,  30,  32,  52,  53,  54},
+        {  15,  16,  31,  33,  54,  55},
+        {  16,  17,  32,  34,  55,  56},
+        {  17,  33,  35,  56,  57,  58},
+        {  17,  18,  34,  36,  58,  59},
+        {   7,  18,  19,  35,  59,  60},
+        {  19,  38,  60,  61,  62,  90},
+        {  19,  20,  37,  39,  62,  63},
+        {  20,  21,  38,  40,  63,  64},
+        {  21,  22,  39,  41,  64,  65}, // 40
+        {  22,  40,  42,  65,  66,  67},
+        {  22,  23,  41,  43,  67,  68},
+        {  23,  24,  42,  44,  68,  69},
+        {  24,  25,  43,  45,  69,  70},
+        {  25,  44,  46,  70,  71,  72},
+        {  25,  26,  45,  47,  72,  73},
+        {  26,  27,  46,  48,  73,  74},
+        {  27,  28,  47,  49,  74,  75},
+        {  28,  48,  50,  75,  76,  77},
+        {  28,  29,  49,  51,  77,  78},
+        {  29,  30,  50,  52,  78,  79},
+        {  30,  31,  51,  53,  79,  80},
+        {  31,  52,  54,  80,  81,  82},
+        {  31,  32,  53,  55,  82,  83},
+        {  32,  33,  54,  56,  83,  84},
+        {  33,  34,  55,  57,  84,  85},
+        {  34,  56,  58,  85,  86,  87},
+        {  34,  35,  57,  59,  87,  88},
+        {  35,  36,  58,  60,  88,  89},
+        {  19,  36,  37,  59,  89,  90}, // 60
+        {  37,  62,  90,  91,  92, 126},
+        {  37,  38,  61,  63,  92,  93},
+        {  38,  39,  62,  64,  93,  94},
+        {  39,  40,  63,  65,  94,  95},
+        {  40,  41,  64,  66,  95,  96},
+        {  41,  65,  67,  96,  97,  98},
+        {  41,  42,  66,  68,  98,  99},
+        {  42,  43,  67,  69,  99, 100},
+        {  43,  44,  68,  70, 100, 101},
+        {  44,  45,  69,  71, 101, 102},
+        {  45,  70,  72, 102, 103, 104},
+        {  45,  46,  71,  73, 104, 105},
+        {  46,  47,  72,  74, 105, 106},
+        {  47,  48,  73,  75, 106, 107},
+        {  48,  49,  74,  76, 107, 108},
+        {  49,  75,  77, 108, 109, 110},
+        {  49,  50,  76,  78, 110, 111},
+        {  50,  51,  77,  79, 111, 112},
+        {  51,  52,  78,  80, 112, 113},
+        {  52,  53,  79,  81, 113, 114}, // 80
+        {  53,  80,  82, 114, 115, 116},
+        {  53,  54,  81,  83, 116, 117},
+        {  54,  55,  82,  84, 117, 118},
+        {  55,  56,  83,  85, 118, 119},
+        {  56,  57,  84,  86, 119, 120},
+        {  57,  85,  87, 120, 121, 122},
+        {  57,  58,  86,  88, 122, 123},
+        {  58,  59,  87,  89, 123, 124},
+        {  59,  60,  88,  90, 124, 125},
+        {  37,  60,  61,  89, 125, 126},
+        {  61,  92, 126, 127, 128, 168},
+        {  61,  62,  91,  93, 128, 129},
+        {  62,  63,  92,  94, 129, 130},
+        {  63,  64,  93,  95, 130, 131},
+        {  64,  65,  94,  96, 131, 132},
+        {  65,  66,  95,  97, 132, 133},
+        {  66,  96,  98, 133, 134, 135},
+        {  66,  67,  97,  99, 135, 136},
+        {  67,  68,  98, 100, 136, 137},
+        {  68,  69,  99, 101, 137, 138}, // 100
+        {  69,  70, 100, 102, 138, 139},
+        {  70,  71, 101, 103, 139, 140},
+        {  71, 102, 104, 140, 141, 142},
+        {  71,  72, 103, 105, 142, 143},
+        {  72,  73, 104, 106, 143, 144},
+        {  73,  74, 105, 107, 144, 145},
+        {  74,  75, 106, 108, 145, 146},
+        {  75,  76, 107, 109, 146, 147},
+        {  76, 108, 110, 147, 148, 149},
+        {  76,  77, 109, 111, 149, 150},
+        {  77,  78, 110, 112, 150, 151},
+        {  78,  79, 111, 113, 151, 152},
+        {  79,  80, 112, 114, 152, 153},
+        {  80,  81, 113, 115, 153, 154},
+        {  81, 114, 116, 154, 155, 156},
+        {  81,  82, 115, 117, 156, 157},
+        {  82,  83, 116, 118, 157, 158},
+        {  83,  84, 117, 119, 158, 159},
+        {  84,  85, 118, 120, 159, 160},
+        {  85,  86, 119, 121, 160, 161}, // 120
+        {  86, 120, 122, 161, 162, 163},
+        {  86,  87, 121, 123, 163, 164},
+        {  87,  88, 122, 124, 164, 165},
+        {  88,  89, 123, 125, 165, 166},
+        {  89,  90, 124, 126, 166, 167},
+        {  61,  90,  91, 125, 167, 168},
+        {  91, 128, 168, 169, 170, 216},
+        {  91,  92, 127, 129, 170, 171},
+        {  92,  93, 128, 130, 171, 172},
+        {  93,  94, 129, 131, 172, 173},
+        {  94,  95, 130, 132, 173, 174},
+        {  95,  96, 131, 133, 174, 175},
+        {  96,  97, 132, 134, 175, 176},
+        {  97, 133, 135, 176, 177, 178},
+        {  97,  98, 134, 136, 178, 179},
+        {  98,  99, 135, 137, 179, 180},
+        {  99, 100, 136, 138, 180, 181},
+        { 100, 101, 137, 139, 181, 182},
+        { 101, 102, 138, 140, 182, 183},
+        { 102, 103, 139, 141, 183, 184}, // 140
+        { 103, 140, 142, 184, 185, 186},
+        { 103, 104, 141, 143, 186, 187},
+        { 104, 105, 142, 144, 187, 188},
+        { 105, 106, 143, 145, 188, 189},
+        { 106, 107, 144, 146, 189, 190},
+        { 107, 108, 145, 147, 190, 191},
+        { 108, 109, 146, 148, 191, 192},
+        { 109, 147, 149, 192, 193, 194},
+        { 109, 110, 148, 150, 194, 195},
+        { 110, 111, 149, 151, 195, 196},
+        { 111, 112, 150, 152, 196, 197},
+        { 112, 113, 151, 153, 197, 198},
+        { 113, 114, 152, 154, 198, 199},
+        { 114, 115, 153, 155, 199, 200},
+        { 115, 154, 156, 200, 201, 202},
+        { 115, 116, 155, 157, 202, 203},
+        { 116, 117, 156, 158, 203, 204},
+        { 117, 118, 157, 159, 204, 205},
+        { 118, 119, 158, 160, 205, 206},
+        { 119, 120, 159, 161, 206, 207}, // 160
+        { 120, 121, 160, 162, 207, 208},
+        { 121, 161, 163, 208, 209, 210},
+        { 121, 122, 162, 164, 210, 211},
+        { 122, 123, 163, 165, 211, 212},
+        { 123, 124, 164, 166, 212, 213},
+        { 124, 125, 165, 167, 213, 214},
+        { 125, 126, 166, 168, 214, 215},
+        {  91, 126, 127, 167, 215, 216},
+        { 127, 170, 216, 217, 218, 270},
+        { 127, 128, 169, 171, 218, 219},
+        { 128, 129, 170, 172, 219, 220},
+        { 129, 130, 171, 173, 220, 221},
+        { 130, 131, 172, 174, 221, 222},
+        { 131, 132, 173, 175, 222, 223},
+        { 132, 133, 174, 176, 223, 224},
+        { 133, 134, 175, 177, 224, 225},
+        { 134, 176, 178, 225, 226, 227},
+        { 134, 135, 177, 179, 227, 228},
+        { 135, 136, 178, 180, 228, 229},
+        { 136, 137, 179, 181, 229, 230}, // 180
+        { 137, 138, 180, 182, 230, 231},
+        { 138, 139, 181, 183, 231, 232},
+        { 139, 140, 182, 184, 232, 233},
+        { 140, 141, 183, 185, 233, 234},
+        { 141, 184, 186, 234, 235, 236},
+        { 141, 142, 185, 187, 236, 237},
+        { 142, 143, 186, 188, 237, 238},
+        { 143, 144, 187, 189, 238, 239},
+        { 144, 145, 188, 190, 239, 240},
+        { 145, 146, 189, 191, 240, 241},
+        { 146, 147, 190, 192, 241, 242},
+        { 147, 148, 191, 193, 242, 243},
+        { 148, 192, 194, 243, 244, 245},
+        { 148, 149, 193, 195, 245, 246},
+        { 149, 150, 194, 196, 246, 247},
+        { 150, 151, 195, 197, 247, 248},
+        { 151, 152, 196, 198, 248, 249},
+        { 152, 153, 197, 199, 249, 250},
+        { 153, 154, 198, 200, 250, 251},
+        { 154, 155, 199, 201, 251, 252}, // 200
+        { 155, 200, 202, 252, 253, 254},
+        { 155, 156, 201, 203, 254, 255},
+        { 156, 157, 202, 204, 255, 256},
+        { 157, 158, 203, 205, 256, 257},
+        { 158, 159, 204, 206, 257, 258},
+        { 159, 160, 205, 207, 258, 259},
+        { 160, 161, 206, 208, 259, 260},
+        { 161, 162, 207, 209, 260, 261},
+        { 162, 208, 210, 261, 262, 263},
+        { 162, 163, 209, 211, 263, 264},
+        { 163, 164, 210, 212, 264, 265},
+        { 164, 165, 211, 213, 265, 266},
+        { 165, 166, 212, 214, 266, 267},
+        { 166, 167, 213, 215, 267, 268},
+        { 167, 168, 214, 216, 268, 269},
+        { 127, 168, 169, 215, 269, 270},
+        { 169, 218, 270, 271, 272, 330},
+        { 169, 170, 217, 219, 272, 273},
+        { 170, 171, 218, 220, 273, 274},
+        { 171, 172, 219, 221, 274, 275}, // 220
+        { 172, 173, 220, 222, 275, 276},
+        { 173, 174, 221, 223, 276, 277},
+        { 174, 175, 222, 224, 277, 278},
+        { 175, 176, 223, 225, 278, 279},
+        { 176, 177, 224, 226, 279, 280},
+        { 177, 225, 227, 280, 281, 282},
+        { 177, 178, 226, 228, 282, 283},
+        { 178, 179, 227, 229, 283, 284},
+        { 179, 180, 228, 230, 284, 285},
+        { 180, 181, 229, 231, 285, 286},
+        { 181, 182, 230, 232, 286, 287},
+        { 182, 183, 231, 233, 287, 288},
+        { 183, 184, 232, 234, 288, 289},
+        { 184, 185, 233, 235, 289, 290},
+        { 185, 234, 236, 290, 291, 292},
+        { 185, 186, 235, 237, 292, 293},
+        { 186, 187, 236, 238, 293, 294},
+        { 187, 188, 237, 239, 294, 295},
+        { 188, 189, 238, 240, 295, 296},
+        { 189, 190, 239, 241, 296, 297}, // 240
+        { 190, 191, 240, 242, 297, 298},
+        { 191, 192, 241, 243, 298, 299},
+        { 192, 193, 242, 244, 299, 300},
+        { 193, 243, 245, 300, 301, 302},
+        { 193, 194, 244, 246, 302, 303},
+        { 194, 195, 245, 247, 303, 304},
+        { 195, 196, 246, 248, 304, 305},
+        { 196, 197, 247, 249, 305, 306},
+        { 197, 198, 248, 250, 306, 307},
+        { 198, 199, 249, 251, 307, 308},
+        { 199, 200, 250, 252, 308, 309},
+        { 200, 201, 251, 253, 309, 310},
+        { 201, 252, 254, 310, 311, 312},
+        { 201, 202, 253, 255, 312, 313},
+        { 202, 203, 254, 256, 313, 314},
+        { 203, 204, 255, 257, 314, 315},
+        { 204, 205, 256, 258, 315, 316},
+        { 205, 206, 257, 259, 316, 317},
+        { 206, 207, 258, 260, 317, 318},
+        { 207, 208, 259, 261, 318, 319}, // 260
+        { 208, 209, 260, 262, 319, 320},
+        { 209, 261, 263, 320, 321, 322},
+        { 209, 210, 262, 264, 322, 323},
+        { 210, 211, 263, 265, 323, 324},
+        { 211, 212, 264, 266, 324, 325},
+        { 212, 213, 265, 267, 325, 326},
+        { 213, 214, 266, 268, 326, 327},
+        { 214, 215, 267, 269, 327, 328},
+        { 215, 216, 268, 270, 328, 329},
+        { 169, 216, 217, 269, 329, 330},
+        { 217, 272, 330, 331, 332, 396},
+        { 217, 218, 271, 273, 332, 333},
+        { 218, 219, 272, 274, 333, 334},
+        { 219, 220, 273, 275, 334, 335},
+        { 220, 221, 274, 276, 335, 336},
+        { 221, 222, 275, 277, 336, 337},
+        { 222, 223, 276, 278, 337, 338},
+        { 223, 224, 277, 279, 338, 339},
+        { 224, 225, 278, 280, 339, 340},
+        { 225, 226, 279, 281, 340, 341}, // 280
+        { 226, 280, 282, 341, 342, 343},
+        { 226, 227, 281, 283, 343, 344},
+        { 227, 228, 282, 284, 344, 345},
+        { 228, 229, 283, 285, 345, 346},
+        { 229, 230, 284, 286, 346, 347},
+        { 230, 231, 285, 287, 347, 348},
+        { 231, 232, 286, 288, 348, 349},
+        { 232, 233, 287, 289, 349, 350},
+        { 233, 234, 288, 290, 350, 351},
+        { 234, 235, 289, 291, 351, 352},
+        { 235, 290, 292, 352, 353, 354},
+        { 235, 236, 291, 293, 354, 355},
+        { 236, 237, 292, 294, 355, 356},
+        { 237, 238, 293, 295, 356, 357},
+        { 238, 239, 294, 296, 357, 358},
+        { 239, 240, 295, 297, 358, 359},
+        { 240, 241, 296, 298, 359, 360},
+        { 241, 242, 297, 299, 360, 361},
+        { 242, 243, 298, 300, 361, 362},
+        { 243, 244, 299, 301, 362, 363}, // 300
+        { 244, 300, 302, 363, 364, 365},
+        { 244, 245, 301, 303, 365, 366},
+        { 245, 246, 302, 304, 366, 367},
+        { 246, 247, 303, 305, 367, 368},
+        { 247, 248, 304, 306, 368, 369},
+        { 248, 249, 305, 307, 369, 370},
+        { 249, 250, 306, 308, 370, 371},
+        { 250, 251, 307, 309, 371, 372},
+        { 251, 252, 308, 310, 372, 373},
+        { 252, 253, 309, 311, 373, 374},
+        { 253, 310, 312, 374, 375, 376},
+        { 253, 254, 311, 313, 376, 377},
+        { 254, 255, 312, 314, 377, 378},
+        { 255, 256, 313, 315, 378, 379},
+        { 256, 257, 314, 316, 379, 380},
+        { 257, 258, 315, 317, 380, 381},
+        { 258, 259, 316, 318, 381, 382},
+        { 259, 260, 317, 319, 382, 383},
+        { 260, 261, 318, 320, 383, 384},
+        { 261, 262, 319, 321, 384, 385}, // 320
+        { 262, 320, 322, 385, 386, 387},
+        { 262, 263, 321, 323, 387, 388},
+        { 263, 264, 322, 324, 388, 389},
+        { 264, 265, 323, 325, 389, 390},
+        { 265, 266, 324, 326, 390, 391},
+        { 266, 267, 325, 327, 391, 392},
+        { 267, 268, 326, 328, 392, 393},
+        { 268, 269, 327, 329, 393, 394},
+        { 269, 270, 328, 330, 394, 395},
+        { 217, 270, 271, 329, 395, 396},
+        { 271, 332, 396, 397, 432,  -1},
+        { 271, 272, 331, 333, 397,  -1},
+        { 272, 273, 332, 334, 398,  -1},
+        { 273, 274, 333, 335, 398,  -1},
+        { 274, 275, 334, 336, 399,  -1},
+        { 275, 276, 335, 337, 399,  -1},
+        { 276, 277, 336, 338, 400,  -1},
+        { 277, 278, 337, 339, 400,  -1},
+        { 278, 279, 338, 340, 401,  -1},
+        { 279, 280, 339, 341, 401,  -1}, // 340
+        { 280, 281, 340, 342, 402,  -1},
+        { 281, 341, 343, 402, 403,  -1},
+        { 281, 282, 342, 344, 403,  -1},
+        { 282, 283, 343, 345, 404,  -1},
+        { 283, 284, 344, 346, 404,  -1},
+        { 284, 285, 345, 347, 405,  -1},
+        { 285, 286, 346, 348, 405,  -1},
+        { 286, 287, 347, 349, 406,  -1},
+        { 287, 288, 348, 350, 406,  -1},
+        { 288, 289, 349, 351, 407,  -1},
+        { 289, 290, 350, 352, 407,  -1},
+        { 290, 291, 351, 353, 408,  -1},
+        { 291, 352, 354, 408, 409,  -1},
+        { 291, 292, 353, 355, 409,  -1},
+        { 292, 293, 354, 356, 410,  -1},
+        { 293, 294, 355, 357, 410,  -1},
+        { 294, 295, 356, 358, 411,  -1},
+        { 295, 296, 357, 359, 411,  -1},
+        { 296, 297, 358, 360, 412,  -1},
+        { 297, 298, 359, 361, 412,  -1}, // 360
+        { 298, 299, 360, 362, 413,  -1},
+        { 299, 300, 361, 363, 413,  -1},
+        { 300, 301, 362, 364, 414,  -1},
+        { 301, 363, 365, 414, 415,  -1},
+        { 301, 302, 364, 366, 415,  -1},
+        { 302, 303, 365, 367, 416,  -1},
+        { 303, 304, 366, 368, 416,  -1},
+        { 304, 305, 367, 369, 417,  -1},
+        { 305, 306, 368, 370, 417,  -1},
+        { 306, 307, 369, 371, 418,  -1},
+        { 307, 308, 370, 372, 418,  -1},
+        { 308, 309, 371, 373, 419,  -1},
+        { 309, 310, 372, 374, 419,  -1},
+        { 310, 311, 373, 375, 420,  -1},
+        { 311, 374, 376, 420, 421,  -1},
+        { 311, 312, 375, 377, 421,  -1},
+        { 312, 313, 376, 378, 422,  -1},
+        { 313, 314, 377, 379, 422,  -1},
+        { 314, 315, 378, 380, 423,  -1},
+        { 315, 316, 379, 381, 423,  -1}, // 380
+        { 316, 317, 380, 382, 424,  -1},
+        { 317, 318, 381, 383, 424,  -1},
+        { 318, 319, 382, 384, 425,  -1},
+        { 319, 320, 383, 385, 425,  -1},
+        { 320, 321, 384, 386, 426,  -1},
+        { 321, 385, 387, 426, 427,  -1},
+        { 321, 322, 386, 388, 427,  -1},
+        { 322, 323, 387, 389, 428,  -1},
+        { 323, 324, 388, 390, 428,  -1},
+        { 324, 325, 389, 391, 429,  -1},
+        { 325, 326, 390, 392, 429,  -1},
+        { 326, 327, 391, 393, 430,  -1},
+        { 327, 328, 392, 394, 430,  -1},
+        { 328, 329, 393, 395, 431,  -1},
+        { 329, 330, 394, 396, 431,  -1},
+        { 271, 330, 331, 395, 432,  -1},
+        { 331, 332, 398, 432, 433, 434},
+        { 333, 334, 397, 399, 434, 435},
+        { 335, 336, 398, 400, 435, 436},
+        { 337, 338, 399, 401, 436, 437}, // 400
+        { 339, 340, 400, 402, 437, 438},
+        { 341, 342, 401, 403, 438, 439},
+        { 342, 343, 402, 404, 440, 441},
+        { 344, 345, 403, 405, 441, 442},
+        { 346, 347, 404, 406, 442, 443},
+        { 348, 349, 405, 407, 443, 444},
+        { 350, 351, 406, 408, 444, 445},
+        { 352, 353, 407, 409, 445, 446},
+        { 353, 354, 408, 410, 447, 448},
+        { 355, 356, 409, 411, 448, 449},
+        { 357, 358, 410, 412, 449, 450},
+        { 359, 360, 411, 413, 450, 451},
+        { 361, 362, 412, 414, 451, 452},
+        { 363, 364, 413, 415, 452, 453},
+        { 364, 365, 414, 416, 454, 455},
+        { 366, 367, 415, 417, 455, 456},
+        { 368, 369, 416, 418, 456, 457},
+        { 370, 371, 417, 419, 457, 458},
+        { 372, 373, 418, 420, 458, 459},
+        { 374, 375, 419, 421, 459, 460}, // 420
+        { 375, 376, 420, 422, 461, 462},
+        { 377, 378, 421, 423, 462, 463},
+        { 379, 380, 422, 424, 463, 464},
+        { 381, 382, 423, 425, 464, 465},
+        { 383, 384, 424, 426, 465, 466},
+        { 385, 386, 425, 427, 466, 467},
+        { 386, 387, 426, 428, 468, 469},
+        { 388, 389, 427, 429, 469, 470},
+        { 390, 391, 428, 430, 470, 471},
+        { 392, 393, 429, 431, 471, 472},
+        { 394, 395, 430, 432, 472, 473},
+        { 331, 396, 397, 431, 473, 474},
+        { 397, 434, 474, 475, 476,  -1},
+        { 397, 398, 433, 435, 476, 477},
+        { 398, 399, 434, 436, 477, 478},
+        { 399, 400, 435, 437, 478, 479},
+        { 400, 401, 436, 438, 479, 480},
+        { 401, 402, 437, 439, 480, 481},
+        { 402, 438, 440, 481, 482,  -1},
+        { 403, 439, 441, 483, 484,  -1}, // 440
+        { 403, 404, 440, 442, 484, 485},
+        { 404, 405, 441, 443, 485, 486},
+        { 405, 406, 442, 444, 486, 487},
+        { 406, 407, 443, 445, 487, 488},
+        { 407, 408, 444, 446, 488, 489},
+        { 408, 445, 447, 489, 490,  -1},
+        { 409, 446, 448, 491, 492,  -1},
+        { 409, 410, 447, 449, 492, 493},
+        { 410, 411, 448, 450, 493, 494},
+        { 411, 412, 449, 451, 494, 495},
+        { 412, 413, 450, 452, 495, 496},
+        { 413, 414, 451, 453, 496, 497},
+        { 414, 452, 454, 497, 498,  -1},
+        { 415, 453, 455, 499, 500,  -1},
+        { 415, 416, 454, 456, 500, 501},
+        { 416, 417, 455, 457, 501, 502},
+        { 417, 418, 456, 458, 502, 503},
+        { 418, 419, 457, 459, 503, 504},
+        { 419, 420, 458, 460, 504, 505},
+        { 420, 459, 461, 505, 506,  -1}, // 460
+        { 421, 460, 462, 507, 508,  -1},
+        { 421, 422, 461, 463, 508, 509},
+        { 422, 423, 462, 464, 509, 510},
+        { 423, 424, 463, 465, 510, 511},
+        { 424, 425, 464, 466, 511, 512},
+        { 425, 426, 465, 467, 512, 513},
+        { 426, 466, 468, 513, 514,  -1},
+        { 427, 467, 469, 515, 516,  -1},
+        { 427, 428, 468, 470, 516, 517},
+        { 428, 429, 469, 471, 517, 518},
+        { 429, 430, 470, 472, 518, 519},
+        { 430, 431, 471, 473, 519, 520},
+        { 431, 432, 472, 474, 520, 521},
+        { 432, 433, 473, 521, 522,  -1},
+        { 433, 476, 522, 523, 524,  -1},
+        { 433, 434, 475, 477, 524, 525},
+        { 434, 435, 476, 478, 525, 526},
+        { 435, 436, 477, 479, 526, 527},
+        { 436, 437, 478, 480, 527, 528},
+        { 437, 438, 479, 481, 528, 529}, // 480
+        { 438, 439, 480, 482, 529, 530},
+        { 439, 481, 483, 530, 531,  -1},
+        { 440, 482, 484, 532, 533,  -1},
+        { 440, 441, 483, 485, 533, 534},
+        { 441, 442, 484, 486, 534, 535},
+        { 442, 443, 485, 487, 535, 536},
+        { 443, 444, 486, 488, 536, 537},
+        { 444, 445, 487, 489, 537, 538},
+        { 445, 446, 488, 490, 538, 539},
+        { 446, 489, 491, 539, 540,  -1},
+        { 447, 490, 492, 541, 542,  -1},
+        { 447, 448, 491, 493, 542, 543},
+        { 448, 449, 492, 494, 543, 544},
+        { 449, 450, 493, 495, 544, 545},
+        { 450, 451, 494, 496, 545, 546},
+        { 451, 452, 495, 497, 546, 547},
+        { 452, 453, 496, 498, 547, 548},
+        { 453, 497, 499, 548, 549,  -1},
+        { 454, 498, 500, 550, 551,  -1},
+        { 454, 455, 499, 501, 551, 552}, // 500
+        { 455, 456, 500, 502, 552, 553},
+        { 456, 457, 501, 503, 553, 554},
+        { 457, 458, 502, 504, 554, 555},
+        { 458, 459, 503, 505, 555, 556},
+        { 459, 460, 504, 506, 556, 557},
+        { 460, 505, 507, 557, 558,  -1},
+        { 461, 506, 508, 559, 560,  -1},
+        { 461, 462, 507, 509, 560, 561},
+        { 462, 463, 508, 510, 561, 562},
+        { 463, 464, 509, 511, 562, 563},
+        { 464, 465, 510, 512, 563, 564},
+        { 465, 466, 511, 513, 564, 565},
+        { 466, 467, 512, 514, 565, 566},
+        { 467, 513, 515, 566, 567,  -1},
+        { 468, 514, 516, 568, 569,  -1},
+        { 468, 469, 515, 517, 569, 570},
+        { 469, 470, 516, 518, 570, 571},
+        { 470, 471, 517, 519, 571, 572},
+        { 471, 472, 518, 520, 572, 573},
+        { 472, 473, 519, 521, 573, 574}, // 520
+        { 473, 474, 520, 522, 574, 575},
+        { 474, 475, 521, 575, 576,  -1},
+        { 475, 524, 576,  -1,  -1,  -1},
+        { 475, 476, 523, 525,  -1,  -1},
+        { 476, 477, 524, 526,  -1,  -1},
+        { 477, 478, 525, 527,  -1,  -1},
+        { 478, 479, 526, 528,  -1,  -1},
+        { 479, 480, 527, 529,  -1,  -1},
+        { 480, 481, 528, 530,  -1,  -1},
+        { 481, 482, 529, 531,  -1,  -1},
+        { 482, 530, 532,  -1,  -1,  -1},
+        { 483, 531, 533,  -1,  -1,  -1},
+        { 483, 484, 532, 534,  -1,  -1},
+        { 484, 485, 533, 535,  -1,  -1},
+        { 485, 486, 534, 536,  -1,  -1},
+        { 486, 487, 535, 537,  -1,  -1},
+        { 487, 488, 536, 538,  -1,  -1},
+        { 488, 489, 537, 539,  -1,  -1},
+        { 489, 490, 538, 540,  -1,  -1},
+        { 490, 539, 541,  -1,  -1,  -1}, // 540
+        { 491, 540, 542,  -1,  -1,  -1},
+        { 491, 492, 541, 543,  -1,  -1},
+        { 492, 493, 542, 544,  -1,  -1},
+        { 493, 494, 543, 545,  -1,  -1},
+        { 494, 495, 544, 546,  -1,  -1},
+        { 495, 496, 545, 547,  -1,  -1},
+        { 496, 497, 546, 548,  -1,  -1},
+        { 497, 498, 547, 549,  -1,  -1},
+        { 498, 548, 550,  -1,  -1,  -1},
+        { 499, 549, 551,  -1,  -1,  -1},
+        { 499, 500, 550, 552,  -1,  -1},
+        { 500, 501, 551, 553,  -1,  -1},
+        { 501, 502, 552, 554,  -1,  -1},
+        { 502, 503, 553, 555,  -1,  -1},
+        { 503, 504, 554, 556,  -1,  -1},
+        { 504, 505, 555, 557,  -1,  -1},
+        { 505, 506, 556, 558,  -1,  -1},
+        { 506, 557, 559,  -1,  -1,  -1},
+        { 507, 558, 560,  -1,  -1,  -1},
+        { 507, 508, 559, 561,  -1,  -1}, // 560
+        { 508, 509, 560, 562,  -1,  -1},
+        { 509, 510, 561, 563,  -1,  -1},
+        { 510, 511, 562, 564,  -1,  -1},
+        { 511, 512, 563, 565,  -1,  -1},
+        { 512, 513, 564, 566,  -1,  -1},
+        { 513, 514, 565, 567,  -1,  -1},
+        { 514, 566, 568,  -1,  -1,  -1},
+        { 515, 567, 569,  -1,  -1,  -1},
+        { 515, 516, 568, 570,  -1,  -1},
+        { 516, 517, 569, 571,  -1,  -1}, // 570
+        { 517, 518, 570, 572,  -1,  -1},
+        { 518, 519, 571, 573,  -1,  -1},
+        { 519, 520, 572, 574,  -1,  -1},
+        { 520, 521, 573, 575,  -1,  -1},
+        { 521, 522, 574, 576,  -1,  -1},
+        { 522, 523, 575,  -1,  -1,  -1}  // 576
+    };
+
+  for (Int_t i=0; i<577; i++)
+      (*this)[i].SetNeighbors(nn[i][0], nn[i][1], nn[i][2],
+                              nn[i][3], nn[i][4], nn[i][5]);
+}
Index: /tags/Mars_V0-8-5/Mars/mgeom/MGeomCamECO1000.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mgeom/MGeomCamECO1000.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mgeom/MGeomCamECO1000.h	(revision 9661)
@@ -0,0 +1,21 @@
+#ifndef MARS_MGeomCamECO1000
+#define MARS_MGeomCamECO1000
+
+#ifndef MARS_MGeomCam
+#include "MGeomCam.h"
+#endif
+
+class MGeomCamECO1000 : public MGeomCam
+{
+private:
+    void CreateCam();
+    void CreateNN();
+
+public:
+    MGeomCamECO1000(const char *name=NULL);
+
+    ClassDef(MGeomCamECO1000, 1) // Geometry class for the ECO1000 camera
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mgeom/MGeomCamECO1000HG.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mgeom/MGeomCamECO1000HG.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mgeom/MGeomCamECO1000HG.cc	(revision 9661)
@@ -0,0 +1,3408 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Harald Kornmayer 1/2001
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MGeomCamECO1000HG
+//
+// This class stores the geometry information of the Magic camera.
+// All information are copied from tables, see source code.
+//
+////////////////////////////////////////////////////////////////////////////
+
+#include "MGeomCamECO1000HG.h"
+
+#include "TCanvas.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MGeomPix.h"
+
+ClassImp(MGeomCamECO1000HG);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+//  Magic camera has 577 pixels. For geometry and Next Neighbor info see
+//  CreateCam and CreateNN
+//
+MGeomCamECO1000HG::MGeomCamECO1000HG(const char *name)
+    : MGeomCam(2401, 34.5, name, "Geometry information of ECO1000 HG Camera")
+{
+    CreateCam();
+    CreateNN();
+    InitGeometry();
+}
+
+// --------------------------------------------------------------------------
+//
+//  This fills the geometry information from a table into the pixel objects.
+//
+void MGeomCamECO1000HG::CreateCam()
+{
+    //
+    //   here define the hardwire things of the ECO 1000 telescope
+    //
+
+
+    //
+    //   fill the pixels list with this data
+    //
+const float xtemp[2401] = {
+  0, 30, 15, -15, -30, -15, 15, 60, // 0
+  45, 30, 0, -30, -45, -60, -45, -30, // 8
+  0, 30, 45, 90, 75, 60, 45, 15, // 16
+  -15, -45, -60, -75, -90, -75, -60, -45, // 24
+  -15, 15, 45, 60, 75, 120, 105, 90, // 32
+  75, 60, 30, 0, -30, -60, -75, -90, // 40
+  -105, -120, -105, -90, -75, -60, -30, 0, // 48
+  30, 60, 75, 90, 105, 150, 135, 120, // 56
+  105, 90, 75, 45, 15, -15, -45, -75, // 64
+  -90, -105, -120, -135, -150, -135, -120, -105, // 72
+  -90, -75, -45, -15, 15, 45, 75, 90, // 80
+  105, 120, 135, 180, 165, 150, 135, 120, // 88
+  105, 90, 60, 30, 0, -30, -60, -90, // 96
+  -105, -120, -135, -150, -165, -180, -165, -150, // 104
+  -135, -120, -105, -90, -60, -30, 0, 30, // 112
+  60, 90, 105, 120, 135, 150, 165, 210, // 120
+  195, 180, 165, 150, 135, 120, 105, 75, // 128
+  45, 15, -15, -45, -75, -105, -120, -135, // 136
+  -150, -165, -180, -195, -210, -195, -180, -165, // 144
+  -150, -135, -120, -105, -75, -45, -15, 15, // 152
+  45, 75, 105, 120, 135, 150, 165, 180, // 160
+  195, 240, 225, 210, 195, 180, 165, 150, // 168
+  135, 120, 90, 60, 30, 0, -30, -60, // 176
+  -90, -120, -135, -150, -165, -180, -195, -210, // 184
+  -225, -240, -225, -210, -195, -180, -165, -150, // 192
+  -135, -120, -90, -60, -30, 0, 30, 60, // 200
+  90, 120, 135, 150, 165, 180, 195, 210, // 208
+  225, 270, 255, 240, 225, 210, 195, 180, // 216
+  165, 150, 135, 105, 75, 45, 15, -15, // 224
+  -45, -75, -105, -135, -150, -165, -180, -195, // 232
+  -210, -225, -240, -255, -270, -255, -240, -225, // 240
+  -210, -195, -180, -165, -150, -135, -105, -75, // 248
+  -45, -15, 15, 45, 75, 105, 135, 150, // 256
+  165, 180, 195, 210, 225, 240, 255, 300, // 264
+  285, 270, 255, 240, 225, 210, 195, 180, // 272
+  165, 150, 120, 90, 60, 30, 0, -30, // 280
+  -60, -90, -120, -150, -165, -180, -195, -210, // 288
+  -225, -240, -255, -270, -285, -300, -285, -270, // 296
+  -255, -240, -225, -210, -195, -180, -165, -150, // 304
+  -120, -90, -60, -30, 0, 30, 60, 90, // 312
+  120, 150, 165, 180, 195, 210, 225, 240, // 320
+  255, 270, 285, 330, 315, 300, 285, 270, // 328
+  255, 240, 225, 210, 195, 180, 165, 135, // 336
+  105, 75, 45, 15, -15, -45, -75, -105, // 344
+  -135, -165, -180, -195, -210, -225, -240, -255, // 352
+  -270, -285, -300, -315, -330, -315, -300, -285, // 360
+  -270, -255, -240, -225, -210, -195, -180, -165, // 368
+  -135, -105, -75, -45, -15, 15, 45, 75, // 376
+  105, 135, 165, 180, 195, 210, 225, 240, // 384
+  255, 270, 285, 300, 315, 360, 345, 330, // 392
+  315, 300, 285, 270, 255, 240, 225, 210, // 400
+  195, 180, 150, 120, 90, 60, 30, 0, // 408
+  -30, -60, -90, -120, -150, -180, -195, -210, // 416
+  -225, -240, -255, -270, -285, -300, -315, -330, // 424
+  -345, -360, -345, -330, -315, -300, -285, -270, // 432
+  -255, -240, -225, -210, -195, -180, -150, -120, // 440
+  -90, -60, -30, 0, 30, 60, 90, 120, // 448
+  150, 180, 195, 210, 225, 240, 255, 270, // 456
+  285, 300, 315, 330, 345, 390, 375, 360, // 464
+  345, 330, 315, 300, 285, 270, 255, 240, // 472
+  225, 210, 195, 165, 135, 105, 75, 45, // 480
+  15, -15, -45, -75, -105, -135, -165, -195, // 488
+  -210, -225, -240, -255, -270, -285, -300, -315, // 496
+  -330, -345, -360, -375, -390, -375, -360, -345, // 504
+  -330, -315, -300, -285, -270, -255, -240, -225, // 512
+  -210, -195, -165, -135, -105, -75, -45, -15, // 520
+  15, 45, 75, 105, 135, 165, 195, 210, // 528
+  225, 240, 255, 270, 285, 300, 315, 330, // 536
+  345, 360, 375, 420, 405, 390, 375, 360, // 544
+  345, 330, 315, 300, 285, 270, 255, 240, // 552
+  225, 210, 180, 150, 120, 90, 60, 30, // 560
+  0, -30, -60, -90, -120, -150, -180, -210, // 568
+  -225, -240, -255, -270, -285, -300, -315, -330, // 576
+  -345, -360, -375, -390, -405, -420, -405, -390, // 584
+  -375, -360, -345, -330, -315, -300, -285, -270, // 592
+  -255, -240, -225, -210, -180, -150, -120, -90, // 600
+  -60, -30, 0, 30, 60, 90, 120, 150, // 608
+  180, 210, 225, 240, 255, 270, 285, 300, // 616
+  315, 330, 345, 360, 375, 390, 405, 450, // 624
+  435, 420, 405, 390, 375, 360, 345, 330, // 632
+  315, 300, 285, 270, 255, 240, 225, 195, // 640
+  165, 135, 105, 75, 45, 15, -15, -45, // 648
+  -75, -105, -135, -165, -195, -225, -240, -255, // 656
+  -270, -285, -300, -315, -330, -345, -360, -375, // 664
+  -390, -405, -420, -435, -450, -435, -420, -405, // 672
+  -390, -375, -360, -345, -330, -315, -300, -285, // 680
+  -270, -255, -240, -225, -195, -165, -135, -105, // 688
+  -75, -45, -15, 15, 45, 75, 105, 135, // 696
+  165, 195, 225, 240, 255, 270, 285, 300, // 704
+  315, 330, 345, 360, 375, 390, 405, 420, // 712
+  435, 480, 465, 450, 435, 420, 405, 390, // 720
+  375, 360, 345, 330, 315, 300, 285, 270, // 728
+  255, 240, 210, 180, 150, 120, 90, 60, // 736
+  30, 0, -30, -60, -90, -120, -150, -180, // 744
+  -210, -240, -255, -270, -285, -300, -315, -330, // 752
+  -345, -360, -375, -390, -405, -420, -435, -450, // 760
+  -465, -480, -465, -450, -435, -420, -405, -390, // 768
+  -375, -360, -345, -330, -315, -300, -285, -270, // 776
+  -255, -240, -210, -180, -150, -120, -90, -60, // 784
+  -30, 0, 30, 60, 90, 120, 150, 180, // 792
+  210, 240, 255, 270, 285, 300, 315, 330, // 800
+  345, 360, 375, 390, 405, 420, 435, 450, // 808
+  465, 510, 495, 480, 465, 450, 435, 420, // 816
+  405, 390, 375, 360, 345, 330, 315, 300, // 824
+  285, 270, 255, 225, 195, 165, 135, 105, // 832
+  75, 45, 15, -15, -45, -75, -105, -135, // 840
+  -165, -195, -225, -255, -270, -285, -300, -315, // 848
+  -330, -345, -360, -375, -390, -405, -420, -435, // 856
+  -450, -465, -480, -495, -510, -495, -480, -465, // 864
+  -450, -435, -420, -405, -390, -375, -360, -345, // 872
+  -330, -315, -300, -285, -270, -255, -225, -195, // 880
+  -165, -135, -105, -75, -45, -15, 15, 45, // 888
+  75, 105, 135, 165, 195, 225, 255, 270, // 896
+  285, 300, 315, 330, 345, 360, 375, 390, // 904
+  405, 420, 435, 450, 465, 480, 495, 540, // 912
+  525, 510, 495, 480, 465, 450, 435, 420, // 920
+  405, 390, 375, 360, 345, 330, 315, 300, // 928
+  285, 270, 240, 210, 180, 150, 120, 90, // 936
+  60, 30, 0, -30, -60, -90, -120, -150, // 944
+  -180, -210, -240, -270, -285, -300, -315, -330, // 952
+  -345, -360, -375, -390, -405, -420, -435, -450, // 960
+  -465, -480, -495, -510, -525, -540, -525, -510, // 968
+  -495, -480, -465, -450, -435, -420, -405, -390, // 976
+  -375, -360, -345, -330, -315, -300, -285, -270, // 984
+  -240, -210, -180, -150, -120, -90, -60, -30, // 992
+  0, 30, 60, 90, 120, 150, 180, 210, // 1000
+  240, 270, 285, 300, 315, 330, 345, 360, // 1008
+  375, 390, 405, 420, 435, 450, 465, 480, // 1016
+  495, 510, 525, 570, 555, 540, 525, 510, // 1024
+  495, 480, 465, 450, 435, 420, 405, 390, // 1032
+  375, 360, 345, 330, 315, 300, 285, 255, // 1040
+  225, 195, 165, 135, 105, 75, 45, 15, // 1048
+  -15, -45, -75, -105, -135, -165, -195, -225, // 1056
+  -255, -285, -300, -315, -330, -345, -360, -375, // 1064
+  -390, -405, -420, -435, -450, -465, -480, -495, // 1072
+  -510, -525, -540, -555, -570, -555, -540, -525, // 1080
+  -510, -495, -480, -465, -450, -435, -420, -405, // 1088
+  -390, -375, -360, -345, -330, -315, -300, -285, // 1096
+  -255, -225, -195, -165, -135, -105, -75, -45, // 1104
+  -15, 15, 45, 75, 105, 135, 165, 195, // 1112
+  225, 255, 285, 300, 315, 330, 345, 360, // 1120
+  375, 390, 405, 420, 435, 450, 465, 480, // 1128
+  495, 510, 525, 540, 555, 600, 585, 570, // 1136
+  555, 540, 525, 510, 495, 480, 465, 450, // 1144
+  435, 420, 405, 390, 375, 360, 345, 330, // 1152
+  315, 300, 270, 240, 210, 180, 150, 120, // 1160
+  90, 60, 30, 0, -30, -60, -90, -120, // 1168
+  -150, -180, -210, -240, -270, -300, -315, -330, // 1176
+  -345, -360, -375, -390, -405, -420, -435, -450, // 1184
+  -465, -480, -495, -510, -525, -540, -555, -570, // 1192
+  -585, -600, -585, -570, -555, -540, -525, -510, // 1200
+  -495, -480, -465, -450, -435, -420, -405, -390, // 1208
+  -375, -360, -345, -330, -315, -300, -270, -240, // 1216
+  -210, -180, -150, -120, -90, -60, -30, 0, // 1224
+  30, 60, 90, 120, 150, 180, 210, 240, // 1232
+  270, 300, 315, 330, 345, 360, 375, 390, // 1240
+  405, 420, 435, 450, 465, 480, 495, 510, // 1248
+  525, 540, 555, 570, 585, 630, 615, 600, // 1256
+  585, 570, 555, 540, 525, 510, 495, 480, // 1264
+  465, 450, 435, 420, 405, 390, 375, 360, // 1272
+  345, 330, 315, 285, 255, 225, 195, 165, // 1280
+  135, 105, 75, 45, 15, -15, -45, -75, // 1288
+  -105, -135, -165, -195, -225, -255, -285, -315, // 1296
+  -330, -345, -360, -375, -390, -405, -420, -435, // 1304
+  -450, -465, -480, -495, -510, -525, -540, -555, // 1312
+  -570, -585, -600, -615, -630, -615, -600, -585, // 1320
+  -570, -555, -540, -525, -510, -495, -480, -465, // 1328
+  -450, -435, -420, -405, -390, -375, -360, -345, // 1336
+  -330, -315, -285, -255, -225, -195, -165, -135, // 1344
+  -105, -75, -45, -15, 15, 45, 75, 105, // 1352
+  135, 165, 195, 225, 255, 285, 315, 330, // 1360
+  345, 360, 375, 390, 405, 420, 435, 450, // 1368
+  465, 480, 495, 510, 525, 540, 555, 570, // 1376
+  585, 600, 615, 660, 645, 630, 615, 600, // 1384
+  585, 570, 555, 540, 525, 510, 495, 480, // 1392
+  465, 450, 435, 420, 405, 390, 375, 360, // 1400
+  345, 330, 300, 270, 240, 210, 180, 150, // 1408
+  120, 90, 60, 30, 0, -30, -60, -90, // 1416
+  -120, -150, -180, -210, -240, -270, -300, -330, // 1424
+  -345, -360, -375, -390, -405, -420, -435, -450, // 1432
+  -465, -480, -495, -510, -525, -540, -555, -570, // 1440
+  -585, -600, -615, -630, -645, -660, -645, -630, // 1448
+  -615, -600, -585, -570, -555, -540, -525, -510, // 1456
+  -495, -480, -465, -450, -435, -420, -405, -390, // 1464
+  -375, -360, -345, -330, -300, -270, -240, -210, // 1472
+  -180, -150, -120, -90, -60, -30, 0, 30, // 1480
+  60, 90, 120, 150, 180, 210, 240, 270, // 1488
+  300, 330, 345, 360, 375, 390, 405, 420, // 1496
+  435, 450, 465, 480, 495, 510, 525, 540, // 1504
+  555, 570, 585, 600, 615, 630, 645, 690, // 1512
+  675, 660, 645, 630, 615, 600, 585, 570, // 1520
+  555, 540, 525, 510, 495, 480, 465, 450, // 1528
+  435, 420, 405, 390, 375, 360, 345, 315, // 1536
+  285, 255, 225, 195, 165, 135, 105, 75, // 1544
+  45, 15, -15, -45, -75, -105, -135, -165, // 1552
+  -195, -225, -255, -285, -315, -345, -360, -375, // 1560
+  -390, -405, -420, -435, -450, -465, -480, -495, // 1568
+  -510, -525, -540, -555, -570, -585, -600, -615, // 1576
+  -630, -645, -660, -675, -690, -675, -660, -645, // 1584
+  -630, -615, -600, -585, -570, -555, -540, -525, // 1592
+  -510, -495, -480, -465, -450, -435, -420, -405, // 1600
+  -390, -375, -360, -345, -315, -285, -255, -225, // 1608
+  -195, -165, -135, -105, -75, -45, -15, 15, // 1616
+  45, 75, 105, 135, 165, 195, 225, 255, // 1624
+  285, 315, 345, 360, 375, 390, 405, 420, // 1632
+  435, 450, 465, 480, 495, 510, 525, 540, // 1640
+  555, 570, 585, 600, 615, 630, 645, 660, // 1648
+  675, 720, 690, 660, 630, 600, 570, 540, // 1656
+  510, 480, 450, 420, 390, 330, 270, 210, // 1664
+  150, 90, 30, -30, -90, -150, -210, -270, // 1672
+  -330, -390, -420, -450, -480, -510, -540, -570, // 1680
+  -600, -630, -660, -690, -720, -720, -690, -660, // 1688
+  -630, -600, -570, -540, -510, -480, -450, -420, // 1696
+  -390, -330, -270, -210, -150, -90, -30, 30, // 1704
+  90, 150, 210, 270, 330, 390, 420, 450, // 1712
+  480, 510, 540, 570, 600, 630, 660, 690, // 1720
+  720, 780, 750, 720, 690, 660, 630, 600, // 1728
+  570, 540, 510, 480, 450, 420, 360, 300, // 1736
+  240, 180, 120, 60, 0, -60, -120, -180, // 1744
+  -240, -300, -360, -420, -450, -480, -510, -540, // 1752
+  -570, -600, -630, -660, -690, -720, -750, -780, // 1760
+  -780, -750, -720, -690, -660, -630, -600, -570, // 1768
+  -540, -510, -480, -450, -420, -360, -300, -240, // 1776
+  -180, -120, -60, 0, 60, 120, 180, 240, // 1784
+  300, 360, 420, 450, 480, 510, 540, 570, // 1792
+  600, 630, 660, 690, 720, 750, 780, 840, // 1800
+  810, 780, 750, 720, 690, 660, 630, 600, // 1808
+  570, 540, 510, 480, 450, 390, 330, 270, // 1816
+  210, 150, 90, 30, -30, -90, -150, -210, // 1824
+  -270, -330, -390, -450, -480, -510, -540, -570, // 1832
+  -600, -630, -660, -690, -720, -750, -780, -810, // 1840
+  -840, -840, -810, -780, -750, -720, -690, -660, // 1848
+  -630, -600, -570, -540, -510, -480, -450, -390, // 1856
+  -330, -270, -210, -150, -90, -30, 30, 90, // 1864
+  150, 210, 270, 330, 390, 450, 480, 510, // 1872
+  540, 570, 600, 630, 660, 690, 720, 750, // 1880
+  780, 810, 840, 900, 870, 840, 810, 780, // 1888
+  750, 720, 690, 660, 630, 600, 570, 540, // 1896
+  510, 480, 420, 360, 300, 240, 180, 120, // 1904
+  60, 0, -60, -120, -180, -240, -300, -360, // 1912
+  -420, -480, -510, -540, -570, -600, -630, -660, // 1920
+  -690, -720, -750, -780, -810, -840, -870, -900, // 1928
+  -900, -870, -840, -810, -780, -750, -720, -690, // 1936
+  -660, -630, -600, -570, -540, -510, -480, -420, // 1944
+  -360, -300, -240, -180, -120, -60, 0, 60, // 1952
+  120, 180, 240, 300, 360, 420, 480, 510, // 1960
+  540, 570, 600, 630, 660, 690, 720, 750, // 1968
+  780, 810, 840, 870, 900, 960, 930, 900, // 1976
+  870, 840, 810, 780, 750, 720, 690, 660, // 1984
+  630, 600, 570, 540, 510, 450, 390, 330, // 1992
+  270, 210, 150, 90, 30, -30, -90, -150, // 2000
+  -210, -270, -330, -390, -450, -510, -540, -570, // 2008
+  -600, -630, -660, -690, -720, -750, -780, -810, // 2016
+  -840, -870, -900, -930, -960, -960, -930, -900, // 2024
+  -870, -840, -810, -780, -750, -720, -690, -660, // 2032
+  -630, -600, -570, -540, -510, -450, -390, -330, // 2040
+  -270, -210, -150, -90, -30, 30, 90, 150, // 2048
+  210, 270, 330, 390, 450, 510, 540, 570, // 2056
+  600, 630, 660, 690, 720, 750, 780, 810, // 2064
+  840, 870, 900, 930, 960, 1020, 990, 960, // 2072
+  930, 900, 870, 840, 810, 780, 750, 720, // 2080
+  690, 660, 630, 600, 570, 540, 480, 420, // 2088
+  360, 300, 240, 180, 120, 60, 0, -60, // 2096
+  -120, -180, -240, -300, -360, -420, -480, -540, // 2104
+  -570, -600, -630, -660, -690, -720, -750, -780, // 2112
+  -810, -840, -870, -900, -930, -960, -990, -1020, // 2120
+  -1020, -990, -960, -930, -900, -870, -840, -810, // 2128
+  -780, -750, -720, -690, -660, -630, -600, -570, // 2136
+  -540, -480, -420, -360, -300, -240, -180, -120, // 2144
+  -60, 0, 60, 120, 180, 240, 300, 360, // 2152
+  420, 480, 540, 570, 600, 630, 660, 690, // 2160
+  720, 750, 780, 810, 840, 870, 900, 930, // 2168
+  960, 990, 1020, 1080, 1050, 1020, 990, 960, // 2176
+  930, 900, 870, 840, 810, 780, 750, 720, // 2184
+  690, 660, 630, 600, 570, 510, 450, 390, // 2192
+  330, 270, 210, 150, 90, 30, -30, -90, // 2200
+  -150, -210, -270, -330, -390, -450, -510, -570, // 2208
+  -600, -630, -660, -690, -720, -750, -780, -810, // 2216
+  -840, -870, -900, -930, -960, -990, -1020, -1050, // 2224
+  -1080, -1080, -1050, -1020, -990, -960, -930, -900, // 2232
+  -870, -840, -810, -780, -750, -720, -690, -660, // 2240
+  -630, -600, -570, -510, -450, -390, -330, -270, // 2248
+  -210, -150, -90, -30, 30, 90, 150, 210, // 2256
+  270, 330, 390, 450, 510, 570, 600, 630, // 2264
+  660, 690, 720, 750, 780, 810, 840, 870, // 2272
+  900, 930, 960, 990, 1020, 1050, 1080, 1140, // 2280
+  1110, 1080, 1050, 1020, 990, 960, 930, 900, // 2288
+  870, 840, 810, 780, 750, 720, 690, 660, // 2296
+  630, 600, 540, 480, 420, 360, 300, 240, // 2304
+  180, 120, 60, 0, -60, -120, -180, -240, // 2312
+  -300, -360, -420, -480, -540, -600, -630, -660, // 2320
+  -690, -720, -750, -780, -810, -840, -870, -900, // 2328
+  -930, -960, -990, -1020, -1050, -1080, -1110, -1140, // 2336
+  -1140, -1110, -1080, -1050, -1020, -990, -960, -930, // 2344
+  -900, -870, -840, -810, -780, -750, -720, -690, // 2352
+  -660, -630, -600, -540, -480, -420, -360, -300, // 2360
+  -240, -180, -120, -60, 0, 60, 120, 180, // 2368
+  240, 300, 360, 420, 480, 540, 600, 630, // 2376
+  660, 690, 720, 750, 780, 810, 840, 870, // 2384
+  900, 930, 960, 990, 1020, 1050, 1080, 1110, // 2392
+  1140                        //2400
+};
+
+const float ytemp[2401] = {
+  0, 0, 25.9808, 25.9808, -0, -25.9808, -25.9808, 0, // 0
+  25.9808, 51.9615, 51.9615, 51.9615, 25.9808, -0, -25.9808, -51.9615, // 8
+  -51.9615, -51.9615, -25.9808, 0, 25.9808, 51.9615, 77.9423, 77.9423, // 16
+  77.9423, 77.9423, 51.9615, 25.9808, -0, -25.9808, -51.9615, -77.9423, // 24
+  -77.9423, -77.9423, -77.9423, -51.9615, -25.9808, 0, 25.9808, 51.9615, // 32
+  77.9423, 103.923, 103.923, 103.923, 103.923, 103.923, 77.9423, 51.9615, // 40
+  25.9808, -0, -25.9808, -51.9615, -77.9423, -103.923, -103.923, -103.923, // 48
+  -103.923, -103.923, -77.9423, -51.9615, -25.9808, 0, 25.9808, 51.9615, // 56
+  77.9423, 103.923, 129.904, 129.904, 129.904, 129.904, 129.904, 129.904, // 64
+  103.923, 77.9423, 51.9615, 25.9808, -0, -25.9808, -51.9615, -77.9423, // 72
+  -103.923, -129.904, -129.904, -129.904, -129.904, -129.904, -129.904, -103.923, // 80
+  -77.9423, -51.9615, -25.9808, 0, 25.9808, 51.9615, 77.9423, 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.9423, 51.9615, 25.9808, -0, -25.9808, -51.9615, // 104
+  -77.9423, -103.923, -129.904, -155.885, -155.885, -155.885, -155.885, -155.885, // 112
+  -155.885, -155.885, -129.904, -103.923, -77.9423, -51.9615, -25.9808, 0, // 120
+  25.9808, 51.9615, 77.9423, 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.9423, 51.9615, 25.9808, -0, -25.9808, -51.9615, -77.9423, // 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.9423, -51.9615, // 160
+  -25.9808, 0, 25.9808, 51.9615, 77.9423, 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.9423, 51.9615, // 184
+  25.9808, -0, -25.9808, -51.9615, -77.9423, -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.9423, -51.9615, // 208
+  -25.9808, 0, 25.9808, 51.9615, 77.9423, 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.9423, 51.9615, 25.9808, -0, -25.9808, -51.9615, -77.9423, // 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.9423, -51.9615, -25.9808, 0, // 264
+  25.9808, 51.9615, 77.9423, 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.9423, 51.9615, 25.9808, -0, -25.9808, -51.9615, // 296
+  -77.9423, -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
+  -77.9423, -51.9615, -25.9808, 0, 25.9808, 51.9615, 77.9423, 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.9423, 51.9615, 25.9808, -0, -25.9808, -51.9615, -77.9423, // 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.9423, -51.9615, -25.9808, 0, 25.9808, 51.9615, // 392
+  77.9423, 103.923, 129.904, 155.885, 181.865, 207.846, 233.827, 259.808, // 400
+  285.788, 311.769, 311.769, 311.769, 311.769, 311.769, 311.769, 311.769, // 408
+  311.769, 311.769, 311.769, 311.769, 311.769, 311.769, 285.788, 259.808, // 416
+  233.827, 207.846, 181.865, 155.885, 129.904, 103.923, 77.9423, 51.9615, // 424
+  25.9808, -0, -25.9808, -51.9615, -77.9423, -103.923, -129.904, -155.885, // 432
+  -181.865, -207.846, -233.827, -259.808, -285.788, -311.769, -311.769, -311.769, // 440
+  -311.769, -311.769, -311.769, -311.769, -311.769, -311.769, -311.769, -311.769, // 448
+  -311.769, -311.769, -285.788, -259.808, -233.827, -207.846, -181.865, -155.885, // 456
+  -129.904, -103.923, -77.9423, -51.9615, -25.9808, 0, 25.9808, 51.9615, // 464
+  77.9423, 103.923, 129.904, 155.885, 181.865, 207.846, 233.827, 259.808, // 472
+  285.788, 311.769, 337.75, 337.75, 337.75, 337.75, 337.75, 337.75, // 480
+  337.75, 337.75, 337.75, 337.75, 337.75, 337.75, 337.75, 337.75, // 488
+  311.769, 285.788, 259.808, 233.827, 207.846, 181.865, 155.885, 129.904, // 496
+  103.923, 77.9423, 51.9615, 25.9808, -0, -25.9808, -51.9615, -77.9423, // 504
+  -103.923, -129.904, -155.885, -181.865, -207.846, -233.827, -259.808, -285.788, // 512
+  -311.769, -337.75, -337.75, -337.75, -337.75, -337.75, -337.75, -337.75, // 520
+  -337.75, -337.75, -337.75, -337.75, -337.75, -337.75, -337.75, -311.769, // 528
+  -285.788, -259.808, -233.827, -207.846, -181.865, -155.885, -129.904, -103.923, // 536
+  -77.9423, -51.9615, -25.9808, 0, 25.9808, 51.9615, 77.9423, 103.923, // 544
+  129.904, 155.885, 181.865, 207.846, 233.827, 259.808, 285.788, 311.769, // 552
+  337.75, 363.731, 363.731, 363.731, 363.731, 363.731, 363.731, 363.731, // 560
+  363.731, 363.731, 363.731, 363.731, 363.731, 363.731, 363.731, 363.731, // 568
+  337.75, 311.769, 285.788, 259.808, 233.827, 207.846, 181.865, 155.885, // 576
+  129.904, 103.923, 77.9423, 51.9615, 25.9808, -0, -25.9808, -51.9615, // 584
+  -77.9423, -103.923, -129.904, -155.885, -181.865, -207.846, -233.827, -259.808, // 592
+  -285.788, -311.769, -337.75, -363.731, -363.731, -363.731, -363.731, -363.731, // 600
+  -363.731, -363.731, -363.731, -363.731, -363.731, -363.731, -363.731, -363.731, // 608
+  -363.731, -363.731, -337.75, -311.769, -285.788, -259.808, -233.827, -207.846, // 616
+  -181.865, -155.885, -129.904, -103.923, -77.9423, -51.9615, -25.9808, 0, // 624
+  25.9808, 51.9615, 77.9423, 103.923, 129.904, 155.885, 181.865, 207.846, // 632
+  233.827, 259.808, 285.788, 311.769, 337.75, 363.731, 389.711, 389.711, // 640
+  389.711, 389.711, 389.711, 389.711, 389.711, 389.711, 389.711, 389.711, // 648
+  389.711, 389.711, 389.711, 389.711, 389.711, 389.711, 363.731, 337.75, // 656
+  311.769, 285.788, 259.808, 233.827, 207.846, 181.865, 155.885, 129.904, // 664
+  103.923, 77.9423, 51.9615, 25.9808, -0, -25.9808, -51.9615, -77.9423, // 672
+  -103.923, -129.904, -155.885, -181.865, -207.846, -233.827, -259.808, -285.788, // 680
+  -311.769, -337.75, -363.731, -389.711, -389.711, -389.711, -389.711, -389.711, // 688
+  -389.711, -389.711, -389.711, -389.711, -389.711, -389.711, -389.711, -389.711, // 696
+  -389.711, -389.711, -389.711, -363.731, -337.75, -311.769, -285.788, -259.808, // 704
+  -233.827, -207.846, -181.865, -155.885, -129.904, -103.923, -77.9423, -51.9615, // 712
+  -25.9808, 0, 25.9808, 51.9615, 77.9423, 103.923, 129.904, 155.885, // 720
+  181.865, 207.846, 233.827, 259.808, 285.788, 311.769, 337.75, 363.731, // 728
+  389.711, 415.692, 415.692, 415.692, 415.692, 415.692, 415.692, 415.692, // 736
+  415.692, 415.692, 415.692, 415.692, 415.692, 415.692, 415.692, 415.692, // 744
+  415.692, 415.692, 389.711, 363.731, 337.75, 311.769, 285.788, 259.808, // 752
+  233.827, 207.846, 181.865, 155.885, 129.904, 103.923, 77.9423, 51.9615, // 760
+  25.9808, -0, -25.9808, -51.9615, -77.9423, -103.923, -129.904, -155.885, // 768
+  -181.865, -207.846, -233.827, -259.808, -285.788, -311.769, -337.75, -363.731, // 776
+  -389.711, -415.692, -415.692, -415.692, -415.692, -415.692, -415.692, -415.692, // 784
+  -415.692, -415.692, -415.692, -415.692, -415.692, -415.692, -415.692, -415.692, // 792
+  -415.692, -415.692, -389.711, -363.731, -337.75, -311.769, -285.788, -259.808, // 800
+  -233.827, -207.846, -181.865, -155.885, -129.904, -103.923, -77.9423, -51.9615, // 808
+  -25.9808, 0, 25.9808, 51.9615, 77.9423, 103.923, 129.904, 155.885, // 816
+  181.865, 207.846, 233.827, 259.808, 285.788, 311.769, 337.75, 363.731, // 824
+  389.711, 415.692, 441.673, 441.673, 441.673, 441.673, 441.673, 441.673, // 832
+  441.673, 441.673, 441.673, 441.673, 441.673, 441.673, 441.673, 441.673, // 840
+  441.673, 441.673, 441.673, 441.673, 415.692, 389.711, 363.731, 337.75, // 848
+  311.769, 285.788, 259.808, 233.827, 207.846, 181.865, 155.885, 129.904, // 856
+  103.923, 77.9423, 51.9615, 25.9808, -0, -25.9808, -51.9615, -77.9423, // 864
+  -103.923, -129.904, -155.885, -181.865, -207.846, -233.827, -259.808, -285.788, // 872
+  -311.769, -337.75, -363.731, -389.711, -415.692, -441.673, -441.673, -441.673, // 880
+  -441.673, -441.673, -441.673, -441.673, -441.673, -441.673, -441.673, -441.673, // 888
+  -441.673, -441.673, -441.673, -441.673, -441.673, -441.673, -441.673, -415.692, // 896
+  -389.711, -363.731, -337.75, -311.769, -285.788, -259.808, -233.827, -207.846, // 904
+  -181.865, -155.885, -129.904, -103.923, -77.9423, -51.9615, -25.9808, 0, // 912
+  25.9808, 51.9615, 77.9423, 103.923, 129.904, 155.885, 181.865, 207.846, // 920
+  233.827, 259.808, 285.788, 311.769, 337.75, 363.731, 389.711, 415.692, // 928
+  441.673, 467.654, 467.654, 467.654, 467.654, 467.654, 467.654, 467.654, // 936
+  467.654, 467.654, 467.654, 467.654, 467.654, 467.654, 467.654, 467.654, // 944
+  467.654, 467.654, 467.654, 467.654, 441.673, 415.692, 389.711, 363.731, // 952
+  337.75, 311.769, 285.788, 259.808, 233.827, 207.846, 181.865, 155.885, // 960
+  129.904, 103.923, 77.9423, 51.9615, 25.9808, -0, -25.9808, -51.9615, // 968
+  -77.9423, -103.923, -129.904, -155.885, -181.865, -207.846, -233.827, -259.808, // 976
+  -285.788, -311.769, -337.75, -363.731, -389.711, -415.692, -441.673, -467.654, // 984
+  -467.654, -467.654, -467.654, -467.654, -467.654, -467.654, -467.654, -467.654, // 992
+  -467.654, -467.654, -467.654, -467.654, -467.654, -467.654, -467.654, -467.654, // 1000
+  -467.654, -467.654, -441.673, -415.692, -389.711, -363.731, -337.75, -311.769, // 1008
+  -285.788, -259.808, -233.827, -207.846, -181.865, -155.885, -129.904, -103.923, // 1016
+  -77.9423, -51.9615, -25.9808, 0, 25.9808, 51.9615, 77.9423, 103.923, // 1024
+  129.904, 155.885, 181.865, 207.846, 233.827, 259.808, 285.788, 311.769, // 1032
+  337.75, 363.731, 389.711, 415.692, 441.673, 467.654, 493.634, 493.634, // 1040
+  493.634, 493.634, 493.634, 493.634, 493.634, 493.634, 493.634, 493.634, // 1048
+  493.634, 493.634, 493.634, 493.634, 493.634, 493.634, 493.634, 493.634, // 1056
+  493.634, 493.634, 467.654, 441.673, 415.692, 389.711, 363.731, 337.75, // 1064
+  311.769, 285.788, 259.808, 233.827, 207.846, 181.865, 155.885, 129.904, // 1072
+  103.923, 77.9423, 51.9615, 25.9808, -0, -25.9808, -51.9615, -77.9423, // 1080
+  -103.923, -129.904, -155.885, -181.865, -207.846, -233.827, -259.808, -285.788, // 1088
+  -311.769, -337.75, -363.731, -389.711, -415.692, -441.673, -467.654, -493.634, // 1096
+  -493.634, -493.634, -493.634, -493.634, -493.634, -493.634, -493.634, -493.634, // 1104
+  -493.634, -493.634, -493.634, -493.634, -493.634, -493.634, -493.634, -493.634, // 1112
+  -493.634, -493.634, -493.634, -467.654, -441.673, -415.692, -389.711, -363.731, // 1120
+  -337.75, -311.769, -285.788, -259.808, -233.827, -207.846, -181.865, -155.885, // 1128
+  -129.904, -103.923, -77.9423, -51.9615, -25.9808, 0, 25.9808, 51.9615, // 1136
+  77.9423, 103.923, 129.904, 155.885, 181.865, 207.846, 233.827, 259.808, // 1144
+  285.788, 311.769, 337.75, 363.731, 389.711, 415.692, 441.673, 467.654, // 1152
+  493.634, 519.615, 519.615, 519.615, 519.615, 519.615, 519.615, 519.615, // 1160
+  519.615, 519.615, 519.615, 519.615, 519.615, 519.615, 519.615, 519.615, // 1168
+  519.615, 519.615, 519.615, 519.615, 519.615, 519.615, 493.634, 467.654, // 1176
+  441.673, 415.692, 389.711, 363.731, 337.75, 311.769, 285.788, 259.808, // 1184
+  233.827, 207.846, 181.865, 155.885, 129.904, 103.923, 77.9423, 51.9615, // 1192
+  25.9808, -0, -25.9808, -51.9615, -77.9423, -103.923, -129.904, -155.885, // 1200
+  -181.865, -207.846, -233.827, -259.808, -285.788, -311.769, -337.75, -363.731, // 1208
+  -389.711, -415.692, -441.673, -467.654, -493.634, -519.615, -519.615, -519.615, // 1216
+  -519.615, -519.615, -519.615, -519.615, -519.615, -519.615, -519.615, -519.615, // 1224
+  -519.615, -519.615, -519.615, -519.615, -519.615, -519.615, -519.615, -519.615, // 1232
+  -519.615, -519.615, -493.634, -467.654, -441.673, -415.692, -389.711, -363.731, // 1240
+  -337.75, -311.769, -285.788, -259.808, -233.827, -207.846, -181.865, -155.885, // 1248
+  -129.904, -103.923, -77.9423, -51.9615, -25.9808, 0, 25.9808, 51.9615, // 1256
+  77.9423, 103.923, 129.904, 155.885, 181.865, 207.846, 233.827, 259.808, // 1264
+  285.788, 311.769, 337.75, 363.731, 389.711, 415.692, 441.673, 467.654, // 1272
+  493.634, 519.615, 545.596, 545.596, 545.596, 545.596, 545.596, 545.596, // 1280
+  545.596, 545.596, 545.596, 545.596, 545.596, 545.596, 545.596, 545.596, // 1288
+  545.596, 545.596, 545.596, 545.596, 545.596, 545.596, 545.596, 545.596, // 1296
+  519.615, 493.634, 467.654, 441.673, 415.692, 389.711, 363.731, 337.75, // 1304
+  311.769, 285.788, 259.808, 233.827, 207.846, 181.865, 155.885, 129.904, // 1312
+  103.923, 77.9423, 51.9615, 25.9808, -0, -25.9808, -51.9615, -77.9423, // 1320
+  -103.923, -129.904, -155.885, -181.865, -207.846, -233.827, -259.808, -285.788, // 1328
+  -311.769, -337.75, -363.731, -389.711, -415.692, -441.673, -467.654, -493.634, // 1336
+  -519.615, -545.596, -545.596, -545.596, -545.596, -545.596, -545.596, -545.596, // 1344
+  -545.596, -545.596, -545.596, -545.596, -545.596, -545.596, -545.596, -545.596, // 1352
+  -545.596, -545.596, -545.596, -545.596, -545.596, -545.596, -545.596, -519.615, // 1360
+  -493.634, -467.654, -441.673, -415.692, -389.711, -363.731, -337.75, -311.769, // 1368
+  -285.788, -259.808, -233.827, -207.846, -181.865, -155.885, -129.904, -103.923, // 1376
+  -77.9423, -51.9615, -25.9808, 0, 25.9808, 51.9615, 77.9423, 103.923, // 1384
+  129.904, 155.885, 181.865, 207.846, 233.827, 259.808, 285.788, 311.769, // 1392
+  337.75, 363.731, 389.711, 415.692, 441.673, 467.654, 493.634, 519.615, // 1400
+  545.596, 571.577, 571.577, 571.577, 571.577, 571.577, 571.577, 571.577, // 1408
+  571.577, 571.577, 571.577, 571.577, 571.577, 571.577, 571.577, 571.577, // 1416
+  571.577, 571.577, 571.577, 571.577, 571.577, 571.577, 571.577, 571.577, // 1424
+  545.596, 519.615, 493.634, 467.654, 441.673, 415.692, 389.711, 363.731, // 1432
+  337.75, 311.769, 285.788, 259.808, 233.827, 207.846, 181.865, 155.885, // 1440
+  129.904, 103.923, 77.9423, 51.9615, 25.9808, -0, -25.9808, -51.9615, // 1448
+  -77.9423, -103.923, -129.904, -155.885, -181.865, -207.846, -233.827, -259.808, // 1456
+  -285.788, -311.769, -337.75, -363.731, -389.711, -415.692, -441.673, -467.654, // 1464
+  -493.634, -519.615, -545.596, -571.577, -571.577, -571.577, -571.577, -571.577, // 1472
+  -571.577, -571.577, -571.577, -571.577, -571.577, -571.577, -571.577, -571.577, // 1480
+  -571.577, -571.577, -571.577, -571.577, -571.577, -571.577, -571.577, -571.577, // 1488
+  -571.577, -571.577, -545.596, -519.615, -493.634, -467.654, -441.673, -415.692, // 1496
+  -389.711, -363.731, -337.75, -311.769, -285.788, -259.808, -233.827, -207.846, // 1504
+  -181.865, -155.885, -129.904, -103.923, -77.9423, -51.9615, -25.9808, 0, // 1512
+  25.9808, 51.9615, 77.9423, 103.923, 129.904, 155.885, 181.865, 207.846, // 1520
+  233.827, 259.808, 285.788, 311.769, 337.75, 363.731, 389.711, 415.692, // 1528
+  441.673, 467.654, 493.634, 519.615, 545.596, 571.577, 597.558, 597.558, // 1536
+  597.558, 597.558, 597.558, 597.558, 597.558, 597.558, 597.558, 597.558, // 1544
+  597.558, 597.558, 597.558, 597.558, 597.558, 597.558, 597.558, 597.558, // 1552
+  597.558, 597.558, 597.558, 597.558, 597.558, 597.558, 571.577, 545.596, // 1560
+  519.615, 493.634, 467.654, 441.673, 415.692, 389.711, 363.731, 337.75, // 1568
+  311.769, 285.788, 259.808, 233.827, 207.846, 181.865, 155.885, 129.904, // 1576
+  103.923, 77.9423, 51.9615, 25.9808, -0, -25.9808, -51.9615, -77.9423, // 1584
+  -103.923, -129.904, -155.885, -181.865, -207.846, -233.827, -259.808, -285.788, // 1592
+  -311.769, -337.75, -363.731, -389.711, -415.692, -441.673, -467.654, -493.634, // 1600
+  -519.615, -545.596, -571.577, -597.558, -597.558, -597.558, -597.558, -597.558, // 1608
+  -597.558, -597.558, -597.558, -597.558, -597.558, -597.558, -597.558, -597.558, // 1616
+  -597.558, -597.558, -597.558, -597.558, -597.558, -597.558, -597.558, -597.558, // 1624
+  -597.558, -597.558, -597.558, -571.577, -545.596, -519.615, -493.634, -467.654, // 1632
+  -441.673, -415.692, -389.711, -363.731, -337.75, -311.769, -285.788, -259.808, // 1640
+  -233.827, -207.846, -181.865, -155.885, -129.904, -103.923, -77.9423, -51.9615, // 1648
+  -25.9808, 34.641, 86.6025, 138.564, 190.526, 242.487, 294.449, 346.41, // 1656
+  398.372, 450.333, 502.295, 554.256, 606.218, 640.859, 640.859, 640.859, // 1664
+  640.859, 640.859, 640.859, 640.859, 640.859, 640.859, 640.859, 640.859, // 1672
+  640.859, 606.218, 554.256, 502.295, 450.333, 398.372, 346.41, 294.449, // 1680
+  242.487, 190.526, 138.564, 86.6025, 34.641, -34.641, -86.6025, -138.564, // 1688
+  -190.526, -242.487, -294.449, -346.41, -398.372, -450.333, -502.295, -554.256, // 1696
+  -606.218, -640.859, -640.859, -640.859, -640.859, -640.859, -640.859, -640.859, // 1704
+  -640.859, -640.859, -640.859, -640.859, -640.859, -606.218, -554.256, -502.295, // 1712
+  -450.333, -398.372, -346.41, -294.449, -242.487, -190.526, -138.564, -86.6025, // 1720
+  -34.641, 34.641, 86.6025, 138.564, 190.526, 242.487, 294.449, 346.41, // 1728
+  398.372, 450.333, 502.295, 554.256, 606.218, 658.179, 692.82, 692.82, // 1736
+  692.82, 692.82, 692.82, 692.82, 692.82, 692.82, 692.82, 692.82, // 1744
+  692.82, 692.82, 692.82, 658.179, 606.218, 554.256, 502.295, 450.333, // 1752
+  398.372, 346.41, 294.449, 242.487, 190.526, 138.564, 86.6025, 34.641, // 1760
+  -34.641, -86.6025, -138.564, -190.526, -242.487, -294.449, -346.41, -398.372, // 1768
+  -450.333, -502.295, -554.256, -606.218, -658.179, -692.82, -692.82, -692.82, // 1776
+  -692.82, -692.82, -692.82, -692.82, -692.82, -692.82, -692.82, -692.82, // 1784
+  -692.82, -692.82, -658.179, -606.218, -554.256, -502.295, -450.333, -398.372, // 1792
+  -346.41, -294.449, -242.487, -190.526, -138.564, -86.6025, -34.641, 34.641, // 1800
+  86.6025, 138.564, 190.526, 242.487, 294.449, 346.41, 398.372, 450.333, // 1808
+  502.295, 554.256, 606.218, 658.179, 710.141, 744.782, 744.782, 744.782, // 1816
+  744.782, 744.782, 744.782, 744.782, 744.782, 744.782, 744.782, 744.782, // 1824
+  744.782, 744.782, 744.782, 710.141, 658.179, 606.218, 554.256, 502.295, // 1832
+  450.333, 398.372, 346.41, 294.449, 242.487, 190.526, 138.564, 86.6025, // 1840
+  34.641, -34.641, -86.6025, -138.564, -190.526, -242.487, -294.449, -346.41, // 1848
+  -398.372, -450.333, -502.295, -554.256, -606.218, -658.179, -710.141, -744.782, // 1856
+  -744.782, -744.782, -744.782, -744.782, -744.782, -744.782, -744.782, -744.782, // 1864
+  -744.782, -744.782, -744.782, -744.782, -744.782, -710.141, -658.179, -606.218, // 1872
+  -554.256, -502.295, -450.333, -398.372, -346.41, -294.449, -242.487, -190.526, // 1880
+  -138.564, -86.6025, -34.641, 34.641, 86.6025, 138.564, 190.526, 242.487, // 1888
+  294.449, 346.41, 398.372, 450.333, 502.295, 554.256, 606.218, 658.179, // 1896
+  710.141, 762.102, 796.743, 796.743, 796.743, 796.743, 796.743, 796.743, // 1904
+  796.743, 796.743, 796.743, 796.743, 796.743, 796.743, 796.743, 796.743, // 1912
+  796.743, 762.102, 710.141, 658.179, 606.218, 554.256, 502.295, 450.333, // 1920
+  398.372, 346.41, 294.449, 242.487, 190.526, 138.564, 86.6025, 34.641, // 1928
+  -34.641, -86.6025, -138.564, -190.526, -242.487, -294.449, -346.41, -398.372, // 1936
+  -450.333, -502.295, -554.256, -606.218, -658.179, -710.141, -762.102, -796.743, // 1944
+  -796.743, -796.743, -796.743, -796.743, -796.743, -796.743, -796.743, -796.743, // 1952
+  -796.743, -796.743, -796.743, -796.743, -796.743, -796.743, -762.102, -710.141, // 1960
+  -658.179, -606.218, -554.256, -502.295, -450.333, -398.372, -346.41, -294.449, // 1968
+  -242.487, -190.526, -138.564, -86.6025, -34.641, 34.641, 86.6025, 138.564, // 1976
+  190.526, 242.487, 294.449, 346.41, 398.372, 450.333, 502.295, 554.256, // 1984
+  606.218, 658.179, 710.141, 762.102, 814.064, 848.705, 848.705, 848.705, // 1992
+  848.705, 848.705, 848.705, 848.705, 848.705, 848.705, 848.705, 848.705, // 2000
+  848.705, 848.705, 848.705, 848.705, 848.705, 814.064, 762.102, 710.141, // 2008
+  658.179, 606.218, 554.256, 502.295, 450.333, 398.372, 346.41, 294.449, // 2016
+  242.487, 190.526, 138.564, 86.6025, 34.641, -34.641, -86.6025, -138.564, // 2024
+  -190.526, -242.487, -294.449, -346.41, -398.372, -450.333, -502.295, -554.256, // 2032
+  -606.218, -658.179, -710.141, -762.102, -814.064, -848.705, -848.705, -848.705, // 2040
+  -848.705, -848.705, -848.705, -848.705, -848.705, -848.705, -848.705, -848.705, // 2048
+  -848.705, -848.705, -848.705, -848.705, -848.705, -814.064, -762.102, -710.141, // 2056
+  -658.179, -606.218, -554.256, -502.295, -450.333, -398.372, -346.41, -294.449, // 2064
+  -242.487, -190.526, -138.564, -86.6025, -34.641, 34.641, 86.6025, 138.564, // 2072
+  190.526, 242.487, 294.449, 346.41, 398.372, 450.333, 502.295, 554.256, // 2080
+  606.218, 658.179, 710.141, 762.102, 814.064, 866.025, 900.666, 900.666, // 2088
+  900.666, 900.666, 900.666, 900.666, 900.666, 900.666, 900.666, 900.666, // 2096
+  900.666, 900.666, 900.666, 900.666, 900.666, 900.666, 900.666, 866.025, // 2104
+  814.064, 762.102, 710.141, 658.179, 606.218, 554.256, 502.295, 450.333, // 2112
+  398.372, 346.41, 294.449, 242.487, 190.526, 138.564, 86.6025, 34.641, // 2120
+  -34.641, -86.6025, -138.564, -190.526, -242.487, -294.449, -346.41, -398.372, // 2128
+  -450.333, -502.295, -554.256, -606.218, -658.179, -710.141, -762.102, -814.064, // 2136
+  -866.025, -900.666, -900.666, -900.666, -900.666, -900.666, -900.666, -900.666, // 2144
+  -900.666, -900.666, -900.666, -900.666, -900.666, -900.666, -900.666, -900.666, // 2152
+  -900.666, -900.666, -866.025, -814.064, -762.102, -710.141, -658.179, -606.218, // 2160
+  -554.256, -502.295, -450.333, -398.372, -346.41, -294.449, -242.487, -190.526, // 2168
+  -138.564, -86.6025, -34.641, 34.641, 86.6025, 138.564, 190.526, 242.487, // 2176
+  294.449, 346.41, 398.372, 450.333, 502.295, 554.256, 606.218, 658.179, // 2184
+  710.141, 762.102, 814.064, 866.025, 917.987, 952.628, 952.628, 952.628, // 2192
+  952.628, 952.628, 952.628, 952.628, 952.628, 952.628, 952.628, 952.628, // 2200
+  952.628, 952.628, 952.628, 952.628, 952.628, 952.628, 952.628, 917.987, // 2208
+  866.025, 814.064, 762.102, 710.141, 658.179, 606.218, 554.256, 502.295, // 2216
+  450.333, 398.372, 346.41, 294.449, 242.487, 190.526, 138.564, 86.6025, // 2224
+  34.641, -34.641, -86.6025, -138.564, -190.526, -242.487, -294.449, -346.41, // 2232
+  -398.372, -450.333, -502.295, -554.256, -606.218, -658.179, -710.141, -762.102, // 2240
+  -814.064, -866.025, -917.987, -952.628, -952.628, -952.628, -952.628, -952.628, // 2248
+  -952.628, -952.628, -952.628, -952.628, -952.628, -952.628, -952.628, -952.628, // 2256
+  -952.628, -952.628, -952.628, -952.628, -952.628, -917.987, -866.025, -814.064, // 2264
+  -762.102, -710.141, -658.179, -606.218, -554.256, -502.295, -450.333, -398.372, // 2272
+  -346.41, -294.449, -242.487, -190.526, -138.564, -86.6025, -34.641, 34.641, // 2280
+  86.6025, 138.564, 190.526, 242.487, 294.449, 346.41, 398.372, 450.333, // 2288
+  502.295, 554.256, 606.218, 658.179, 710.141, 762.102, 814.064, 866.025, // 2296
+  917.987, 969.948, 1004.59, 1004.59, 1004.59, 1004.59, 1004.59, 1004.59, // 2304
+  1004.59, 1004.59, 1004.59, 1004.59, 1004.59, 1004.59, 1004.59, 1004.59, // 2312
+  1004.59, 1004.59, 1004.59, 1004.59, 1004.59, 969.948, 917.987, 866.025, // 2320
+  814.064, 762.102, 710.141, 658.179, 606.218, 554.256, 502.295, 450.333, // 2328
+  398.372, 346.41, 294.449, 242.487, 190.526, 138.564, 86.6025, 34.641, // 2336
+  -34.641, -86.6025, -138.564, -190.526, -242.487, -294.449, -346.41, -398.372, // 2344
+  -450.333, -502.295, -554.256, -606.218, -658.179, -710.141, -762.102, -814.064, // 2352
+  -866.025, -917.987, -969.948, -1004.59, -1004.59, -1004.59, -1004.59, -1004.59, // 2360
+  -1004.59, -1004.59, -1004.59, -1004.59, -1004.59, -1004.59, -1004.59, -1004.59, // 2368
+  -1004.59, -1004.59, -1004.59, -1004.59, -1004.59, -1004.59, -969.948, -917.987, // 2376
+  -866.025, -814.064, -762.102, -710.141, -658.179, -606.218, -554.256, -502.295, // 2384
+  -450.333, -398.372, -346.41, -294.449, -242.487, -190.526, -138.564, -86.6025, // 2392
+  -34.641                        //2400
+};
+
+
+
+ const float rtemp[2401] = {
+   30, 30, 30, 30, 30, 30, 30, 30, // 0
+   30, 30, 30, 30, 30, 30, 30, 30, // 8
+   30, 30, 30, 30, 30, 30, 30, 30, // 16
+   30, 30, 30, 30, 30, 30, 30, 30, // 24
+   30, 30, 30, 30, 30, 30, 30, 30, // 32
+   30, 30, 30, 30, 30, 30, 30, 30, // 40
+   30, 30, 30, 30, 30, 30, 30, 30, // 48
+   30, 30, 30, 30, 30, 30, 30, 30, // 56
+   30, 30, 30, 30, 30, 30, 30, 30, // 64
+   30, 30, 30, 30, 30, 30, 30, 30, // 72
+   30, 30, 30, 30, 30, 30, 30, 30, // 80
+   30, 30, 30, 30, 30, 30, 30, 30, // 88
+   30, 30, 30, 30, 30, 30, 30, 30, // 96
+   30, 30, 30, 30, 30, 30, 30, 30, // 104
+   30, 30, 30, 30, 30, 30, 30, 30, // 112
+   30, 30, 30, 30, 30, 30, 30, 30, // 120
+   30, 30, 30, 30, 30, 30, 30, 30, // 128
+   30, 30, 30, 30, 30, 30, 30, 30, // 136
+   30, 30, 30, 30, 30, 30, 30, 30, // 144
+   30, 30, 30, 30, 30, 30, 30, 30, // 152
+   30, 30, 30, 30, 30, 30, 30, 30, // 160
+   30, 30, 30, 30, 30, 30, 30, 30, // 168
+   30, 30, 30, 30, 30, 30, 30, 30, // 176
+   30, 30, 30, 30, 30, 30, 30, 30, // 184
+   30, 30, 30, 30, 30, 30, 30, 30, // 192
+   30, 30, 30, 30, 30, 30, 30, 30, // 200
+   30, 30, 30, 30, 30, 30, 30, 30, // 208
+   30, 30, 30, 30, 30, 30, 30, 30, // 216
+   30, 30, 30, 30, 30, 30, 30, 30, // 224
+   30, 30, 30, 30, 30, 30, 30, 30, // 232
+   30, 30, 30, 30, 30, 30, 30, 30, // 240
+   30, 30, 30, 30, 30, 30, 30, 30, // 248
+   30, 30, 30, 30, 30, 30, 30, 30, // 256
+   30, 30, 30, 30, 30, 30, 30, 30, // 264
+   30, 30, 30, 30, 30, 30, 30, 30, // 272
+   30, 30, 30, 30, 30, 30, 30, 30, // 280
+   30, 30, 30, 30, 30, 30, 30, 30, // 288
+   30, 30, 30, 30, 30, 30, 30, 30, // 296
+   30, 30, 30, 30, 30, 30, 30, 30, // 304
+   30, 30, 30, 30, 30, 30, 30, 30, // 312
+   30, 30, 30, 30, 30, 30, 30, 30, // 320
+   30, 30, 30, 30, 30, 30, 30, 30, // 328
+   30, 30, 30, 30, 30, 30, 30, 30, // 336
+   30, 30, 30, 30, 30, 30, 30, 30, // 344
+   30, 30, 30, 30, 30, 30, 30, 30, // 352
+   30, 30, 30, 30, 30, 30, 30, 30, // 360
+   30, 30, 30, 30, 30, 30, 30, 30, // 368
+   30, 30, 30, 30, 30, 30, 30, 30, // 376
+   30, 30, 30, 30, 30, 30, 30, 30, // 384
+   30, 30, 30, 30, 30, 30, 30, 30, // 392
+   30, 30, 30, 30, 30, 30, 30, 30, // 400
+   30, 30, 30, 30, 30, 30, 30, 30, // 408
+   30, 30, 30, 30, 30, 30, 30, 30, // 416
+   30, 30, 30, 30, 30, 30, 30, 30, // 424
+   30, 30, 30, 30, 30, 30, 30, 30, // 432
+   30, 30, 30, 30, 30, 30, 30, 30, // 440
+   30, 30, 30, 30, 30, 30, 30, 30, // 448
+   30, 30, 30, 30, 30, 30, 30, 30, // 456
+   30, 30, 30, 30, 30, 30, 30, 30, // 464
+   30, 30, 30, 30, 30, 30, 30, 30, // 472
+   30, 30, 30, 30, 30, 30, 30, 30, // 480
+   30, 30, 30, 30, 30, 30, 30, 30, // 488
+   30, 30, 30, 30, 30, 30, 30, 30, // 496
+   30, 30, 30, 30, 30, 30, 30, 30, // 504
+   30, 30, 30, 30, 30, 30, 30, 30, // 512
+   30, 30, 30, 30, 30, 30, 30, 30, // 520
+   30, 30, 30, 30, 30, 30, 30, 30, // 528
+   30, 30, 30, 30, 30, 30, 30, 30, // 536
+   30, 30, 30, 30, 30, 30, 30, 30, // 544
+   30, 30, 30, 30, 30, 30, 30, 30, // 552
+   30, 30, 30, 30, 30, 30, 30, 30, // 560
+   30, 30, 30, 30, 30, 30, 30, 30, // 568
+   30, 30, 30, 30, 30, 30, 30, 30, // 576
+   30, 30, 30, 30, 30, 30, 30, 30, // 584
+   30, 30, 30, 30, 30, 30, 30, 30, // 592
+   30, 30, 30, 30, 30, 30, 30, 30, // 600
+   30, 30, 30, 30, 30, 30, 30, 30, // 608
+   30, 30, 30, 30, 30, 30, 30, 30, // 616
+   30, 30, 30, 30, 30, 30, 30, 30, // 624
+   30, 30, 30, 30, 30, 30, 30, 30, // 632
+   30, 30, 30, 30, 30, 30, 30, 30, // 640
+   30, 30, 30, 30, 30, 30, 30, 30, // 648
+   30, 30, 30, 30, 30, 30, 30, 30, // 656
+   30, 30, 30, 30, 30, 30, 30, 30, // 664
+   30, 30, 30, 30, 30, 30, 30, 30, // 672
+   30, 30, 30, 30, 30, 30, 30, 30, // 680
+   30, 30, 30, 30, 30, 30, 30, 30, // 688
+   30, 30, 30, 30, 30, 30, 30, 30, // 696
+   30, 30, 30, 30, 30, 30, 30, 30, // 704
+   30, 30, 30, 30, 30, 30, 30, 30, // 712
+   30, 30, 30, 30, 30, 30, 30, 30, // 720
+   30, 30, 30, 30, 30, 30, 30, 30, // 728
+   30, 30, 30, 30, 30, 30, 30, 30, // 736
+   30, 30, 30, 30, 30, 30, 30, 30, // 744
+   30, 30, 30, 30, 30, 30, 30, 30, // 752
+   30, 30, 30, 30, 30, 30, 30, 30, // 760
+   30, 30, 30, 30, 30, 30, 30, 30, // 768
+   30, 30, 30, 30, 30, 30, 30, 30, // 776
+   30, 30, 30, 30, 30, 30, 30, 30, // 784
+   30, 30, 30, 30, 30, 30, 30, 30, // 792
+   30, 30, 30, 30, 30, 30, 30, 30, // 800
+   30, 30, 30, 30, 30, 30, 30, 30, // 808
+   30, 30, 30, 30, 30, 30, 30, 30, // 816
+   30, 30, 30, 30, 30, 30, 30, 30, // 824
+   30, 30, 30, 30, 30, 30, 30, 30, // 832
+   30, 30, 30, 30, 30, 30, 30, 30, // 840
+   30, 30, 30, 30, 30, 30, 30, 30, // 848
+   30, 30, 30, 30, 30, 30, 30, 30, // 856
+   30, 30, 30, 30, 30, 30, 30, 30, // 864
+   30, 30, 30, 30, 30, 30, 30, 30, // 872
+   30, 30, 30, 30, 30, 30, 30, 30, // 880
+   30, 30, 30, 30, 30, 30, 30, 30, // 888
+   30, 30, 30, 30, 30, 30, 30, 30, // 896
+   30, 30, 30, 30, 30, 30, 30, 30, // 904
+   30, 30, 30, 30, 30, 30, 30, 30, // 912
+   30, 30, 30, 30, 30, 30, 30, 30, // 920
+   30, 30, 30, 30, 30, 30, 30, 30, // 928
+   30, 30, 30, 30, 30, 30, 30, 30, // 936
+   30, 30, 30, 30, 30, 30, 30, 30, // 944
+   30, 30, 30, 30, 30, 30, 30, 30, // 952
+   30, 30, 30, 30, 30, 30, 30, 30, // 960
+   30, 30, 30, 30, 30, 30, 30, 30, // 968
+   30, 30, 30, 30, 30, 30, 30, 30, // 976
+   30, 30, 30, 30, 30, 30, 30, 30, // 984
+   30, 30, 30, 30, 30, 30, 30, 30, // 992
+   30, 30, 30, 30, 30, 30, 30, 30, // 1000
+   30, 30, 30, 30, 30, 30, 30, 30, // 1008
+   30, 30, 30, 30, 30, 30, 30, 30, // 1016
+   30, 30, 30, 30, 30, 30, 30, 30, // 1024
+   30, 30, 30, 30, 30, 30, 30, 30, // 1032
+   30, 30, 30, 30, 30, 30, 30, 30, // 1040
+   30, 30, 30, 30, 30, 30, 30, 30, // 1048
+   30, 30, 30, 30, 30, 30, 30, 30, // 1056
+   30, 30, 30, 30, 30, 30, 30, 30, // 1064
+   30, 30, 30, 30, 30, 30, 30, 30, // 1072
+   30, 30, 30, 30, 30, 30, 30, 30, // 1080
+   30, 30, 30, 30, 30, 30, 30, 30, // 1088
+   30, 30, 30, 30, 30, 30, 30, 30, // 1096
+   30, 30, 30, 30, 30, 30, 30, 30, // 1104
+   30, 30, 30, 30, 30, 30, 30, 30, // 1112
+   30, 30, 30, 30, 30, 30, 30, 30, // 1120
+   30, 30, 30, 30, 30, 30, 30, 30, // 1128
+   30, 30, 30, 30, 30, 30, 30, 30, // 1136
+   30, 30, 30, 30, 30, 30, 30, 30, // 1144
+   30, 30, 30, 30, 30, 30, 30, 30, // 1152
+   30, 30, 30, 30, 30, 30, 30, 30, // 1160
+   30, 30, 30, 30, 30, 30, 30, 30, // 1168
+   30, 30, 30, 30, 30, 30, 30, 30, // 1176
+   30, 30, 30, 30, 30, 30, 30, 30, // 1184
+   30, 30, 30, 30, 30, 30, 30, 30, // 1192
+   30, 30, 30, 30, 30, 30, 30, 30, // 1200
+   30, 30, 30, 30, 30, 30, 30, 30, // 1208
+   30, 30, 30, 30, 30, 30, 30, 30, // 1216
+   30, 30, 30, 30, 30, 30, 30, 30, // 1224
+   30, 30, 30, 30, 30, 30, 30, 30, // 1232
+   30, 30, 30, 30, 30, 30, 30, 30, // 1240
+   30, 30, 30, 30, 30, 30, 30, 30, // 1248
+   30, 30, 30, 30, 30, 30, 30, 30, // 1256
+   30, 30, 30, 30, 30, 30, 30, 30, // 1264
+   30, 30, 30, 30, 30, 30, 30, 30, // 1272
+   30, 30, 30, 30, 30, 30, 30, 30, // 1280
+   30, 30, 30, 30, 30, 30, 30, 30, // 1288
+   30, 30, 30, 30, 30, 30, 30, 30, // 1296
+   30, 30, 30, 30, 30, 30, 30, 30, // 1304
+   30, 30, 30, 30, 30, 30, 30, 30, // 1312
+   30, 30, 30, 30, 30, 30, 30, 30, // 1320
+   30, 30, 30, 30, 30, 30, 30, 30, // 1328
+   30, 30, 30, 30, 30, 30, 30, 30, // 1336
+   30, 30, 30, 30, 30, 30, 30, 30, // 1344
+   30, 30, 30, 30, 30, 30, 30, 30, // 1352
+   30, 30, 30, 30, 30, 30, 30, 30, // 1360
+   30, 30, 30, 30, 30, 30, 30, 30, // 1368
+   30, 30, 30, 30, 30, 30, 30, 30, // 1376
+   30, 30, 30, 30, 30, 30, 30, 30, // 1384
+   30, 30, 30, 30, 30, 30, 30, 30, // 1392
+   30, 30, 30, 30, 30, 30, 30, 30, // 1400
+   30, 30, 30, 30, 30, 30, 30, 30, // 1408
+   30, 30, 30, 30, 30, 30, 30, 30, // 1416
+   30, 30, 30, 30, 30, 30, 30, 30, // 1424
+   30, 30, 30, 30, 30, 30, 30, 30, // 1432
+   30, 30, 30, 30, 30, 30, 30, 30, // 1440
+   30, 30, 30, 30, 30, 30, 30, 30, // 1448
+   30, 30, 30, 30, 30, 30, 30, 30, // 1456
+   30, 30, 30, 30, 30, 30, 30, 30, // 1464
+   30, 30, 30, 30, 30, 30, 30, 30, // 1472
+   30, 30, 30, 30, 30, 30, 30, 30, // 1480
+   30, 30, 30, 30, 30, 30, 30, 30, // 1488
+   30, 30, 30, 30, 30, 30, 30, 30, // 1496
+   30, 30, 30, 30, 30, 30, 30, 30, // 1504
+   30, 30, 30, 30, 30, 30, 30, 30, // 1512
+   30, 30, 30, 30, 30, 30, 30, 30, // 1520
+   30, 30, 30, 30, 30, 30, 30, 30, // 1528
+   30, 30, 30, 30, 30, 30, 30, 30, // 1536
+   30, 30, 30, 30, 30, 30, 30, 30, // 1544
+   30, 30, 30, 30, 30, 30, 30, 30, // 1552
+   30, 30, 30, 30, 30, 30, 30, 30, // 1560
+   30, 30, 30, 30, 30, 30, 30, 30, // 1568
+   30, 30, 30, 30, 30, 30, 30, 30, // 1576
+   30, 30, 30, 30, 30, 30, 30, 30, // 1584
+   30, 30, 30, 30, 30, 30, 30, 30, // 1592
+   30, 30, 30, 30, 30, 30, 30, 30, // 1600
+   30, 30, 30, 30, 30, 30, 30, 30, // 1608
+   30, 30, 30, 30, 30, 30, 30, 30, // 1616
+   30, 30, 30, 30, 30, 30, 30, 30, // 1624
+   30, 30, 30, 30, 30, 30, 30, 30, // 1632
+   30, 30, 30, 30, 30, 30, 30, 30, // 1640
+   30, 30, 30, 30, 30, 30, 30, 30, // 1648
+   30, 60, 60, 60, 60, 60, 60, 60, // 1656
+   60, 60, 60, 60, 60, 60, 60, 60, // 1664
+   60, 60, 60, 60, 60, 60, 60, 60, // 1672
+   60, 60, 60, 60, 60, 60, 60, 60, // 1680
+   60, 60, 60, 60, 60, 60, 60, 60, // 1688
+   60, 60, 60, 60, 60, 60, 60, 60, // 1696
+   60, 60, 60, 60, 60, 60, 60, 60, // 1704
+   60, 60, 60, 60, 60, 60, 60, 60, // 1712
+   60, 60, 60, 60, 60, 60, 60, 60, // 1720
+   60, 60, 60, 60, 60, 60, 60, 60, // 1728
+   60, 60, 60, 60, 60, 60, 60, 60, // 1736
+   60, 60, 60, 60, 60, 60, 60, 60, // 1744
+   60, 60, 60, 60, 60, 60, 60, 60, // 1752
+   60, 60, 60, 60, 60, 60, 60, 60, // 1760
+   60, 60, 60, 60, 60, 60, 60, 60, // 1768
+   60, 60, 60, 60, 60, 60, 60, 60, // 1776
+   60, 60, 60, 60, 60, 60, 60, 60, // 1784
+   60, 60, 60, 60, 60, 60, 60, 60, // 1792
+   60, 60, 60, 60, 60, 60, 60, 60, // 1800
+   60, 60, 60, 60, 60, 60, 60, 60, // 1808
+   60, 60, 60, 60, 60, 60, 60, 60, // 1816
+   60, 60, 60, 60, 60, 60, 60, 60, // 1824
+   60, 60, 60, 60, 60, 60, 60, 60, // 1832
+   60, 60, 60, 60, 60, 60, 60, 60, // 1840
+   60, 60, 60, 60, 60, 60, 60, 60, // 1848
+   60, 60, 60, 60, 60, 60, 60, 60, // 1856
+   60, 60, 60, 60, 60, 60, 60, 60, // 1864
+   60, 60, 60, 60, 60, 60, 60, 60, // 1872
+   60, 60, 60, 60, 60, 60, 60, 60, // 1880
+   60, 60, 60, 60, 60, 60, 60, 60, // 1888
+   60, 60, 60, 60, 60, 60, 60, 60, // 1896
+   60, 60, 60, 60, 60, 60, 60, 60, // 1904
+   60, 60, 60, 60, 60, 60, 60, 60, // 1912
+   60, 60, 60, 60, 60, 60, 60, 60, // 1920
+   60, 60, 60, 60, 60, 60, 60, 60, // 1928
+   60, 60, 60, 60, 60, 60, 60, 60, // 1936
+   60, 60, 60, 60, 60, 60, 60, 60, // 1944
+   60, 60, 60, 60, 60, 60, 60, 60, // 1952
+   60, 60, 60, 60, 60, 60, 60, 60, // 1960
+   60, 60, 60, 60, 60, 60, 60, 60, // 1968
+   60, 60, 60, 60, 60, 60, 60, 60, // 1976
+   60, 60, 60, 60, 60, 60, 60, 60, // 1984
+   60, 60, 60, 60, 60, 60, 60, 60, // 1992
+   60, 60, 60, 60, 60, 60, 60, 60, // 2000
+   60, 60, 60, 60, 60, 60, 60, 60, // 2008
+   60, 60, 60, 60, 60, 60, 60, 60, // 2016
+   60, 60, 60, 60, 60, 60, 60, 60, // 2024
+   60, 60, 60, 60, 60, 60, 60, 60, // 2032
+   60, 60, 60, 60, 60, 60, 60, 60, // 2040
+   60, 60, 60, 60, 60, 60, 60, 60, // 2048
+   60, 60, 60, 60, 60, 60, 60, 60, // 2056
+   60, 60, 60, 60, 60, 60, 60, 60, // 2064
+   60, 60, 60, 60, 60, 60, 60, 60, // 2072
+   60, 60, 60, 60, 60, 60, 60, 60, // 2080
+   60, 60, 60, 60, 60, 60, 60, 60, // 2088
+   60, 60, 60, 60, 60, 60, 60, 60, // 2096
+   60, 60, 60, 60, 60, 60, 60, 60, // 2104
+   60, 60, 60, 60, 60, 60, 60, 60, // 2112
+   60, 60, 60, 60, 60, 60, 60, 60, // 2120
+   60, 60, 60, 60, 60, 60, 60, 60, // 2128
+   60, 60, 60, 60, 60, 60, 60, 60, // 2136
+   60, 60, 60, 60, 60, 60, 60, 60, // 2144
+   60, 60, 60, 60, 60, 60, 60, 60, // 2152
+   60, 60, 60, 60, 60, 60, 60, 60, // 2160
+   60, 60, 60, 60, 60, 60, 60, 60, // 2168
+   60, 60, 60, 60, 60, 60, 60, 60, // 2176
+   60, 60, 60, 60, 60, 60, 60, 60, // 2184
+   60, 60, 60, 60, 60, 60, 60, 60, // 2192
+   60, 60, 60, 60, 60, 60, 60, 60, // 2200
+   60, 60, 60, 60, 60, 60, 60, 60, // 2208
+   60, 60, 60, 60, 60, 60, 60, 60, // 2216
+   60, 60, 60, 60, 60, 60, 60, 60, // 2224
+   60, 60, 60, 60, 60, 60, 60, 60, // 2232
+   60, 60, 60, 60, 60, 60, 60, 60, // 2240
+   60, 60, 60, 60, 60, 60, 60, 60, // 2248
+   60, 60, 60, 60, 60, 60, 60, 60, // 2256
+   60, 60, 60, 60, 60, 60, 60, 60, // 2264
+   60, 60, 60, 60, 60, 60, 60, 60, // 2272
+   60, 60, 60, 60, 60, 60, 60, 60, // 2280
+   60, 60, 60, 60, 60, 60, 60, 60, // 2288
+   60, 60, 60, 60, 60, 60, 60, 60, // 2296
+   60, 60, 60, 60, 60, 60, 60, 60, // 2304
+   60, 60, 60, 60, 60, 60, 60, 60, // 2312
+   60, 60, 60, 60, 60, 60, 60, 60, // 2320
+   60, 60, 60, 60, 60, 60, 60, 60, // 2328
+   60, 60, 60, 60, 60, 60, 60, 60, // 2336
+   60, 60, 60, 60, 60, 60, 60, 60, // 2344
+   60, 60, 60, 60, 60, 60, 60, 60, // 2352
+   60, 60, 60, 60, 60, 60, 60, 60, // 2360
+   60, 60, 60, 60, 60, 60, 60, 60, // 2368
+   60, 60, 60, 60, 60, 60, 60, 60, // 2376
+   60, 60, 60, 60, 60, 60, 60, 60, // 2384
+   60, 60, 60, 60, 60, 60, 60, 60, // 2392
+   60                        //2400
+ };
+
+
+ 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 MGeomCamECO1000HG::CreateNN()
+{
+  const Short_t nn[2401][6] = {       // Neighbours 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,  398,  468},
+    {  271,  272,  331,  333,  398,  399},
+    {  272,  273,  332,  334,  399,  400},
+    {  273,  274,  333,  335,  400,  401},
+    {  274,  275,  334,  336,  401,  402},
+    {  275,  276,  335,  337,  402,  403},
+    {  276,  277,  336,  338,  403,  404},
+    {  277,  278,  337,  339,  404,  405},
+    {  278,  279,  338,  340,  405,  406},
+    {  279,  280,  339,  341,  406,  407}, // 340
+    {  280,  281,  340,  342,  407,  408},
+    {  281,  341,  343,  408,  409,  410},
+    {  281,  282,  342,  344,  410,  411},
+    {  282,  283,  343,  345,  411,  412},
+    {  283,  284,  344,  346,  412,  413},
+    {  284,  285,  345,  347,  413,  414},
+    {  285,  286,  346,  348,  414,  415},
+    {  286,  287,  347,  349,  415,  416},
+    {  287,  288,  348,  350,  416,  417},
+    {  288,  289,  349,  351,  417,  418},
+    {  289,  290,  350,  352,  418,  419},
+    {  290,  291,  351,  353,  419,  420},
+    {  291,  352,  354,  420,  421,  422},
+    {  291,  292,  353,  355,  422,  423},
+    {  292,  293,  354,  356,  423,  424},
+    {  293,  294,  355,  357,  424,  425},
+    {  294,  295,  356,  358,  425,  426},
+    {  295,  296,  357,  359,  426,  427},
+    {  296,  297,  358,  360,  427,  428},
+    {  297,  298,  359,  361,  428,  429}, // 360
+    {  298,  299,  360,  362,  429,  430},
+    {  299,  300,  361,  363,  430,  431},
+    {  300,  301,  362,  364,  431,  432},
+    {  301,  363,  365,  432,  433,  434},
+    {  301,  302,  364,  366,  434,  435},
+    {  302,  303,  365,  367,  435,  436},
+    {  303,  304,  366,  368,  436,  437},
+    {  304,  305,  367,  369,  437,  438},
+    {  305,  306,  368,  370,  438,  439},
+    {  306,  307,  369,  371,  439,  440},
+    {  307,  308,  370,  372,  440,  441},
+    {  308,  309,  371,  373,  441,  442},
+    {  309,  310,  372,  374,  442,  443},
+    {  310,  311,  373,  375,  443,  444},
+    {  311,  374,  376,  444,  445,  446},
+    {  311,  312,  375,  377,  446,  447},
+    {  312,  313,  376,  378,  447,  448},
+    {  313,  314,  377,  379,  448,  449},
+    {  314,  315,  378,  380,  449,  450},
+    {  315,  316,  379,  381,  450,  451}, // 380
+    {  316,  317,  380,  382,  451,  452},
+    {  317,  318,  381,  383,  452,  453},
+    {  318,  319,  382,  384,  453,  454},
+    {  319,  320,  383,  385,  454,  455},
+    {  320,  321,  384,  386,  455,  456},
+    {  321,  385,  387,  456,  457,  458},
+    {  321,  322,  386,  388,  458,  459},
+    {  322,  323,  387,  389,  459,  460},
+    {  323,  324,  388,  390,  460,  461},
+    {  324,  325,  389,  391,  461,  462},
+    {  325,  326,  390,  392,  462,  463},
+    {  326,  327,  391,  393,  463,  464},
+    {  327,  328,  392,  394,  464,  465},
+    {  328,  329,  393,  395,  465,  466},
+    {  329,  330,  394,  396,  466,  467},
+    {  271,  330,  331,  395,  467,  468},
+    {  331,  398,  468,  469,  470,  546},
+    {  331,  332,  397,  399,  470,  471},
+    {  332,  333,  398,  400,  471,  472},
+    {  333,  334,  399,  401,  472,  473}, // 400
+    {  334,  335,  400,  402,  473,  474},
+    {  335,  336,  401,  403,  474,  475},
+    {  336,  337,  402,  404,  475,  476},
+    {  337,  338,  403,  405,  476,  477},
+    {  338,  339,  404,  406,  477,  478},
+    {  339,  340,  405,  407,  478,  479},
+    {  340,  341,  406,  408,  479,  480},
+    {  341,  342,  407,  409,  480,  481},
+    {  342,  408,  410,  481,  482,  483},
+    {  342,  343,  409,  411,  483,  484},
+    {  343,  344,  410,  412,  484,  485},
+    {  344,  345,  411,  413,  485,  486},
+    {  345,  346,  412,  414,  486,  487},
+    {  346,  347,  413,  415,  487,  488},
+    {  347,  348,  414,  416,  488,  489},
+    {  348,  349,  415,  417,  489,  490},
+    {  349,  350,  416,  418,  490,  491},
+    {  350,  351,  417,  419,  491,  492},
+    {  351,  352,  418,  420,  492,  493},
+    {  352,  353,  419,  421,  493,  494}, // 420
+    {  353,  420,  422,  494,  495,  496},
+    {  353,  354,  421,  423,  496,  497},
+    {  354,  355,  422,  424,  497,  498},
+    {  355,  356,  423,  425,  498,  499},
+    {  356,  357,  424,  426,  499,  500},
+    {  357,  358,  425,  427,  500,  501},
+    {  358,  359,  426,  428,  501,  502},
+    {  359,  360,  427,  429,  502,  503},
+    {  360,  361,  428,  430,  503,  504},
+    {  361,  362,  429,  431,  504,  505},
+    {  362,  363,  430,  432,  505,  506},
+    {  363,  364,  431,  433,  506,  507},
+    {  364,  432,  434,  507,  508,  509},
+    {  364,  365,  433,  435,  509,  510},
+    {  365,  366,  434,  436,  510,  511},
+    {  366,  367,  435,  437,  511,  512},
+    {  367,  368,  436,  438,  512,  513},
+    {  368,  369,  437,  439,  513,  514},
+    {  369,  370,  438,  440,  514,  515},
+    {  370,  371,  439,  441,  515,  516}, // 440
+    {  371,  372,  440,  442,  516,  517},
+    {  372,  373,  441,  443,  517,  518},
+    {  373,  374,  442,  444,  518,  519},
+    {  374,  375,  443,  445,  519,  520},
+    {  375,  444,  446,  520,  521,  522},
+    {  375,  376,  445,  447,  522,  523},
+    {  376,  377,  446,  448,  523,  524},
+    {  377,  378,  447,  449,  524,  525},
+    {  378,  379,  448,  450,  525,  526},
+    {  379,  380,  449,  451,  526,  527},
+    {  380,  381,  450,  452,  527,  528},
+    {  381,  382,  451,  453,  528,  529},
+    {  382,  383,  452,  454,  529,  530},
+    {  383,  384,  453,  455,  530,  531},
+    {  384,  385,  454,  456,  531,  532},
+    {  385,  386,  455,  457,  532,  533},
+    {  386,  456,  458,  533,  534,  535},
+    {  386,  387,  457,  459,  535,  536},
+    {  387,  388,  458,  460,  536,  537},
+    {  388,  389,  459,  461,  537,  538}, // 460
+    {  389,  390,  460,  462,  538,  539},
+    {  390,  391,  461,  463,  539,  540},
+    {  391,  392,  462,  464,  540,  541},
+    {  392,  393,  463,  465,  541,  542},
+    {  393,  394,  464,  466,  542,  543},
+    {  394,  395,  465,  467,  543,  544},
+    {  395,  396,  466,  468,  544,  545},
+    {  331,  396,  397,  467,  545,  546},
+    {  397,  470,  546,  547,  548,  630},
+    {  397,  398,  469,  471,  548,  549},
+    {  398,  399,  470,  472,  549,  550},
+    {  399,  400,  471,  473,  550,  551},
+    {  400,  401,  472,  474,  551,  552},
+    {  401,  402,  473,  475,  552,  553},
+    {  402,  403,  474,  476,  553,  554},
+    {  403,  404,  475,  477,  554,  555},
+    {  404,  405,  476,  478,  555,  556},
+    {  405,  406,  477,  479,  556,  557},
+    {  406,  407,  478,  480,  557,  558},
+    {  407,  408,  479,  481,  558,  559}, // 480
+    {  408,  409,  480,  482,  559,  560},
+    {  409,  481,  483,  560,  561,  562},
+    {  409,  410,  482,  484,  562,  563},
+    {  410,  411,  483,  485,  563,  564},
+    {  411,  412,  484,  486,  564,  565},
+    {  412,  413,  485,  487,  565,  566},
+    {  413,  414,  486,  488,  566,  567},
+    {  414,  415,  487,  489,  567,  568},
+    {  415,  416,  488,  490,  568,  569},
+    {  416,  417,  489,  491,  569,  570},
+    {  417,  418,  490,  492,  570,  571},
+    {  418,  419,  491,  493,  571,  572},
+    {  419,  420,  492,  494,  572,  573},
+    {  420,  421,  493,  495,  573,  574},
+    {  421,  494,  496,  574,  575,  576},
+    {  421,  422,  495,  497,  576,  577},
+    {  422,  423,  496,  498,  577,  578},
+    {  423,  424,  497,  499,  578,  579},
+    {  424,  425,  498,  500,  579,  580},
+    {  425,  426,  499,  501,  580,  581}, // 500
+    {  426,  427,  500,  502,  581,  582},
+    {  427,  428,  501,  503,  582,  583},
+    {  428,  429,  502,  504,  583,  584},
+    {  429,  430,  503,  505,  584,  585},
+    {  430,  431,  504,  506,  585,  586},
+    {  431,  432,  505,  507,  586,  587},
+    {  432,  433,  506,  508,  587,  588},
+    {  433,  507,  509,  588,  589,  590},
+    {  433,  434,  508,  510,  590,  591},
+    {  434,  435,  509,  511,  591,  592},
+    {  435,  436,  510,  512,  592,  593},
+    {  436,  437,  511,  513,  593,  594},
+    {  437,  438,  512,  514,  594,  595},
+    {  438,  439,  513,  515,  595,  596},
+    {  439,  440,  514,  516,  596,  597},
+    {  440,  441,  515,  517,  597,  598},
+    {  441,  442,  516,  518,  598,  599},
+    {  442,  443,  517,  519,  599,  600},
+    {  443,  444,  518,  520,  600,  601},
+    {  444,  445,  519,  521,  601,  602}, // 520
+    {  445,  520,  522,  602,  603,  604},
+    {  445,  446,  521,  523,  604,  605},
+    {  446,  447,  522,  524,  605,  606},
+    {  447,  448,  523,  525,  606,  607},
+    {  448,  449,  524,  526,  607,  608},
+    {  449,  450,  525,  527,  608,  609},
+    {  450,  451,  526,  528,  609,  610},
+    {  451,  452,  527,  529,  610,  611},
+    {  452,  453,  528,  530,  611,  612},
+    {  453,  454,  529,  531,  612,  613},
+    {  454,  455,  530,  532,  613,  614},
+    {  455,  456,  531,  533,  614,  615},
+    {  456,  457,  532,  534,  615,  616},
+    {  457,  533,  535,  616,  617,  618},
+    {  457,  458,  534,  536,  618,  619},
+    {  458,  459,  535,  537,  619,  620},
+    {  459,  460,  536,  538,  620,  621},
+    {  460,  461,  537,  539,  621,  622},
+    {  461,  462,  538,  540,  622,  623},
+    {  462,  463,  539,  541,  623,  624}, // 540
+    {  463,  464,  540,  542,  624,  625},
+    {  464,  465,  541,  543,  625,  626},
+    {  465,  466,  542,  544,  626,  627},
+    {  466,  467,  543,  545,  627,  628},
+    {  467,  468,  544,  546,  628,  629},
+    {  397,  468,  469,  545,  629,  630},
+    {  469,  548,  630,  631,  632,  720},
+    {  469,  470,  547,  549,  632,  633},
+    {  470,  471,  548,  550,  633,  634},
+    {  471,  472,  549,  551,  634,  635},
+    {  472,  473,  550,  552,  635,  636},
+    {  473,  474,  551,  553,  636,  637},
+    {  474,  475,  552,  554,  637,  638},
+    {  475,  476,  553,  555,  638,  639},
+    {  476,  477,  554,  556,  639,  640},
+    {  477,  478,  555,  557,  640,  641},
+    {  478,  479,  556,  558,  641,  642},
+    {  479,  480,  557,  559,  642,  643},
+    {  480,  481,  558,  560,  643,  644},
+    {  481,  482,  559,  561,  644,  645}, // 560
+    {  482,  560,  562,  645,  646,  647},
+    {  482,  483,  561,  563,  647,  648},
+    {  483,  484,  562,  564,  648,  649},
+    {  484,  485,  563,  565,  649,  650},
+    {  485,  486,  564,  566,  650,  651},
+    {  486,  487,  565,  567,  651,  652},
+    {  487,  488,  566,  568,  652,  653},
+    {  488,  489,  567,  569,  653,  654},
+    {  489,  490,  568,  570,  654,  655},
+    {  490,  491,  569,  571,  655,  656},
+    {  491,  492,  570,  572,  656,  657},
+    {  492,  493,  571,  573,  657,  658},
+    {  493,  494,  572,  574,  658,  659},
+    {  494,  495,  573,  575,  659,  660},
+    {  495,  574,  576,  660,  661,  662},
+    {  495,  496,  575,  577,  662,  663},
+    {  496,  497,  576,  578,  663,  664},
+    {  497,  498,  577,  579,  664,  665},
+    {  498,  499,  578,  580,  665,  666},
+    {  499,  500,  579,  581,  666,  667}, // 580
+    {  500,  501,  580,  582,  667,  668},
+    {  501,  502,  581,  583,  668,  669},
+    {  502,  503,  582,  584,  669,  670},
+    {  503,  504,  583,  585,  670,  671},
+    {  504,  505,  584,  586,  671,  672},
+    {  505,  506,  585,  587,  672,  673},
+    {  506,  507,  586,  588,  673,  674},
+    {  507,  508,  587,  589,  674,  675},
+    {  508,  588,  590,  675,  676,  677},
+    {  508,  509,  589,  591,  677,  678},
+    {  509,  510,  590,  592,  678,  679},
+    {  510,  511,  591,  593,  679,  680},
+    {  511,  512,  592,  594,  680,  681},
+    {  512,  513,  593,  595,  681,  682},
+    {  513,  514,  594,  596,  682,  683},
+    {  514,  515,  595,  597,  683,  684},
+    {  515,  516,  596,  598,  684,  685},
+    {  516,  517,  597,  599,  685,  686},
+    {  517,  518,  598,  600,  686,  687},
+    {  518,  519,  599,  601,  687,  688}, // 600
+    {  519,  520,  600,  602,  688,  689},
+    {  520,  521,  601,  603,  689,  690},
+    {  521,  602,  604,  690,  691,  692},
+    {  521,  522,  603,  605,  692,  693},
+    {  522,  523,  604,  606,  693,  694},
+    {  523,  524,  605,  607,  694,  695},
+    {  524,  525,  606,  608,  695,  696},
+    {  525,  526,  607,  609,  696,  697},
+    {  526,  527,  608,  610,  697,  698},
+    {  527,  528,  609,  611,  698,  699},
+    {  528,  529,  610,  612,  699,  700},
+    {  529,  530,  611,  613,  700,  701},
+    {  530,  531,  612,  614,  701,  702},
+    {  531,  532,  613,  615,  702,  703},
+    {  532,  533,  614,  616,  703,  704},
+    {  533,  534,  615,  617,  704,  705},
+    {  534,  616,  618,  705,  706,  707},
+    {  534,  535,  617,  619,  707,  708},
+    {  535,  536,  618,  620,  708,  709},
+    {  536,  537,  619,  621,  709,  710}, // 620
+    {  537,  538,  620,  622,  710,  711},
+    {  538,  539,  621,  623,  711,  712},
+    {  539,  540,  622,  624,  712,  713},
+    {  540,  541,  623,  625,  713,  714},
+    {  541,  542,  624,  626,  714,  715},
+    {  542,  543,  625,  627,  715,  716},
+    {  543,  544,  626,  628,  716,  717},
+    {  544,  545,  627,  629,  717,  718},
+    {  545,  546,  628,  630,  718,  719},
+    {  469,  546,  547,  629,  719,  720},
+    {  547,  632,  720,  721,  722,  816},
+    {  547,  548,  631,  633,  722,  723},
+    {  548,  549,  632,  634,  723,  724},
+    {  549,  550,  633,  635,  724,  725},
+    {  550,  551,  634,  636,  725,  726},
+    {  551,  552,  635,  637,  726,  727},
+    {  552,  553,  636,  638,  727,  728},
+    {  553,  554,  637,  639,  728,  729},
+    {  554,  555,  638,  640,  729,  730},
+    {  555,  556,  639,  641,  730,  731}, // 640
+    {  556,  557,  640,  642,  731,  732},
+    {  557,  558,  641,  643,  732,  733},
+    {  558,  559,  642,  644,  733,  734},
+    {  559,  560,  643,  645,  734,  735},
+    {  560,  561,  644,  646,  735,  736},
+    {  561,  645,  647,  736,  737,  738},
+    {  561,  562,  646,  648,  738,  739},
+    {  562,  563,  647,  649,  739,  740},
+    {  563,  564,  648,  650,  740,  741},
+    {  564,  565,  649,  651,  741,  742},
+    {  565,  566,  650,  652,  742,  743},
+    {  566,  567,  651,  653,  743,  744},
+    {  567,  568,  652,  654,  744,  745},
+    {  568,  569,  653,  655,  745,  746},
+    {  569,  570,  654,  656,  746,  747},
+    {  570,  571,  655,  657,  747,  748},
+    {  571,  572,  656,  658,  748,  749},
+    {  572,  573,  657,  659,  749,  750},
+    {  573,  574,  658,  660,  750,  751},
+    {  574,  575,  659,  661,  751,  752}, // 660
+    {  575,  660,  662,  752,  753,  754},
+    {  575,  576,  661,  663,  754,  755},
+    {  576,  577,  662,  664,  755,  756},
+    {  577,  578,  663,  665,  756,  757},
+    {  578,  579,  664,  666,  757,  758},
+    {  579,  580,  665,  667,  758,  759},
+    {  580,  581,  666,  668,  759,  760},
+    {  581,  582,  667,  669,  760,  761},
+    {  582,  583,  668,  670,  761,  762},
+    {  583,  584,  669,  671,  762,  763},
+    {  584,  585,  670,  672,  763,  764},
+    {  585,  586,  671,  673,  764,  765},
+    {  586,  587,  672,  674,  765,  766},
+    {  587,  588,  673,  675,  766,  767},
+    {  588,  589,  674,  676,  767,  768},
+    {  589,  675,  677,  768,  769,  770},
+    {  589,  590,  676,  678,  770,  771},
+    {  590,  591,  677,  679,  771,  772},
+    {  591,  592,  678,  680,  772,  773},
+    {  592,  593,  679,  681,  773,  774}, // 680
+    {  593,  594,  680,  682,  774,  775},
+    {  594,  595,  681,  683,  775,  776},
+    {  595,  596,  682,  684,  776,  777},
+    {  596,  597,  683,  685,  777,  778},
+    {  597,  598,  684,  686,  778,  779},
+    {  598,  599,  685,  687,  779,  780},
+    {  599,  600,  686,  688,  780,  781},
+    {  600,  601,  687,  689,  781,  782},
+    {  601,  602,  688,  690,  782,  783},
+    {  602,  603,  689,  691,  783,  784},
+    {  603,  690,  692,  784,  785,  786},
+    {  603,  604,  691,  693,  786,  787},
+    {  604,  605,  692,  694,  787,  788},
+    {  605,  606,  693,  695,  788,  789},
+    {  606,  607,  694,  696,  789,  790},
+    {  607,  608,  695,  697,  790,  791},
+    {  608,  609,  696,  698,  791,  792},
+    {  609,  610,  697,  699,  792,  793},
+    {  610,  611,  698,  700,  793,  794},
+    {  611,  612,  699,  701,  794,  795}, // 700
+    {  612,  613,  700,  702,  795,  796},
+    {  613,  614,  701,  703,  796,  797},
+    {  614,  615,  702,  704,  797,  798},
+    {  615,  616,  703,  705,  798,  799},
+    {  616,  617,  704,  706,  799,  800},
+    {  617,  705,  707,  800,  801,  802},
+    {  617,  618,  706,  708,  802,  803},
+    {  618,  619,  707,  709,  803,  804},
+    {  619,  620,  708,  710,  804,  805},
+    {  620,  621,  709,  711,  805,  806},
+    {  621,  622,  710,  712,  806,  807},
+    {  622,  623,  711,  713,  807,  808},
+    {  623,  624,  712,  714,  808,  809},
+    {  624,  625,  713,  715,  809,  810},
+    {  625,  626,  714,  716,  810,  811},
+    {  626,  627,  715,  717,  811,  812},
+    {  627,  628,  716,  718,  812,  813},
+    {  628,  629,  717,  719,  813,  814},
+    {  629,  630,  718,  720,  814,  815},
+    {  547,  630,  631,  719,  815,  816}, // 720
+    {  631,  722,  816,  817,  818,  918},
+    {  631,  632,  721,  723,  818,  819},
+    {  632,  633,  722,  724,  819,  820},
+    {  633,  634,  723,  725,  820,  821},
+    {  634,  635,  724,  726,  821,  822},
+    {  635,  636,  725,  727,  822,  823},
+    {  636,  637,  726,  728,  823,  824},
+    {  637,  638,  727,  729,  824,  825},
+    {  638,  639,  728,  730,  825,  826},
+    {  639,  640,  729,  731,  826,  827},
+    {  640,  641,  730,  732,  827,  828},
+    {  641,  642,  731,  733,  828,  829},
+    {  642,  643,  732,  734,  829,  830},
+    {  643,  644,  733,  735,  830,  831},
+    {  644,  645,  734,  736,  831,  832},
+    {  645,  646,  735,  737,  832,  833},
+    {  646,  736,  738,  833,  834,  835},
+    {  646,  647,  737,  739,  835,  836},
+    {  647,  648,  738,  740,  836,  837},
+    {  648,  649,  739,  741,  837,  838}, // 740
+    {  649,  650,  740,  742,  838,  839},
+    {  650,  651,  741,  743,  839,  840},
+    {  651,  652,  742,  744,  840,  841},
+    {  652,  653,  743,  745,  841,  842},
+    {  653,  654,  744,  746,  842,  843},
+    {  654,  655,  745,  747,  843,  844},
+    {  655,  656,  746,  748,  844,  845},
+    {  656,  657,  747,  749,  845,  846},
+    {  657,  658,  748,  750,  846,  847},
+    {  658,  659,  749,  751,  847,  848},
+    {  659,  660,  750,  752,  848,  849},
+    {  660,  661,  751,  753,  849,  850},
+    {  661,  752,  754,  850,  851,  852},
+    {  661,  662,  753,  755,  852,  853},
+    {  662,  663,  754,  756,  853,  854},
+    {  663,  664,  755,  757,  854,  855},
+    {  664,  665,  756,  758,  855,  856},
+    {  665,  666,  757,  759,  856,  857},
+    {  666,  667,  758,  760,  857,  858},
+    {  667,  668,  759,  761,  858,  859}, // 760
+    {  668,  669,  760,  762,  859,  860},
+    {  669,  670,  761,  763,  860,  861},
+    {  670,  671,  762,  764,  861,  862},
+    {  671,  672,  763,  765,  862,  863},
+    {  672,  673,  764,  766,  863,  864},
+    {  673,  674,  765,  767,  864,  865},
+    {  674,  675,  766,  768,  865,  866},
+    {  675,  676,  767,  769,  866,  867},
+    {  676,  768,  770,  867,  868,  869},
+    {  676,  677,  769,  771,  869,  870},
+    {  677,  678,  770,  772,  870,  871},
+    {  678,  679,  771,  773,  871,  872},
+    {  679,  680,  772,  774,  872,  873},
+    {  680,  681,  773,  775,  873,  874},
+    {  681,  682,  774,  776,  874,  875},
+    {  682,  683,  775,  777,  875,  876},
+    {  683,  684,  776,  778,  876,  877},
+    {  684,  685,  777,  779,  877,  878},
+    {  685,  686,  778,  780,  878,  879},
+    {  686,  687,  779,  781,  879,  880}, // 780
+    {  687,  688,  780,  782,  880,  881},
+    {  688,  689,  781,  783,  881,  882},
+    {  689,  690,  782,  784,  882,  883},
+    {  690,  691,  783,  785,  883,  884},
+    {  691,  784,  786,  884,  885,  886},
+    {  691,  692,  785,  787,  886,  887},
+    {  692,  693,  786,  788,  887,  888},
+    {  693,  694,  787,  789,  888,  889},
+    {  694,  695,  788,  790,  889,  890},
+    {  695,  696,  789,  791,  890,  891},
+    {  696,  697,  790,  792,  891,  892},
+    {  697,  698,  791,  793,  892,  893},
+    {  698,  699,  792,  794,  893,  894},
+    {  699,  700,  793,  795,  894,  895},
+    {  700,  701,  794,  796,  895,  896},
+    {  701,  702,  795,  797,  896,  897},
+    {  702,  703,  796,  798,  897,  898},
+    {  703,  704,  797,  799,  898,  899},
+    {  704,  705,  798,  800,  899,  900},
+    {  705,  706,  799,  801,  900,  901}, // 800
+    {  706,  800,  802,  901,  902,  903},
+    {  706,  707,  801,  803,  903,  904},
+    {  707,  708,  802,  804,  904,  905},
+    {  708,  709,  803,  805,  905,  906},
+    {  709,  710,  804,  806,  906,  907},
+    {  710,  711,  805,  807,  907,  908},
+    {  711,  712,  806,  808,  908,  909},
+    {  712,  713,  807,  809,  909,  910},
+    {  713,  714,  808,  810,  910,  911},
+    {  714,  715,  809,  811,  911,  912},
+    {  715,  716,  810,  812,  912,  913},
+    {  716,  717,  811,  813,  913,  914},
+    {  717,  718,  812,  814,  914,  915},
+    {  718,  719,  813,  815,  915,  916},
+    {  719,  720,  814,  816,  916,  917},
+    {  631,  720,  721,  815,  917,  918},
+    {  721,  818,  918,  919,  920,  1026},
+    {  721,  722,  817,  819,  920,  921},
+    {  722,  723,  818,  820,  921,  922},
+    {  723,  724,  819,  821,  922,  923}, // 820
+    {  724,  725,  820,  822,  923,  924},
+    {  725,  726,  821,  823,  924,  925},
+    {  726,  727,  822,  824,  925,  926},
+    {  727,  728,  823,  825,  926,  927},
+    {  728,  729,  824,  826,  927,  928},
+    {  729,  730,  825,  827,  928,  929},
+    {  730,  731,  826,  828,  929,  930},
+    {  731,  732,  827,  829,  930,  931},
+    {  732,  733,  828,  830,  931,  932},
+    {  733,  734,  829,  831,  932,  933},
+    {  734,  735,  830,  832,  933,  934},
+    {  735,  736,  831,  833,  934,  935},
+    {  736,  737,  832,  834,  935,  936},
+    {  737,  833,  835,  936,  937,  938},
+    {  737,  738,  834,  836,  938,  939},
+    {  738,  739,  835,  837,  939,  940},
+    {  739,  740,  836,  838,  940,  941},
+    {  740,  741,  837,  839,  941,  942},
+    {  741,  742,  838,  840,  942,  943},
+    {  742,  743,  839,  841,  943,  944}, // 840
+    {  743,  744,  840,  842,  944,  945},
+    {  744,  745,  841,  843,  945,  946},
+    {  745,  746,  842,  844,  946,  947},
+    {  746,  747,  843,  845,  947,  948},
+    {  747,  748,  844,  846,  948,  949},
+    {  748,  749,  845,  847,  949,  950},
+    {  749,  750,  846,  848,  950,  951},
+    {  750,  751,  847,  849,  951,  952},
+    {  751,  752,  848,  850,  952,  953},
+    {  752,  753,  849,  851,  953,  954},
+    {  753,  850,  852,  954,  955,  956},
+    {  753,  754,  851,  853,  956,  957},
+    {  754,  755,  852,  854,  957,  958},
+    {  755,  756,  853,  855,  958,  959},
+    {  756,  757,  854,  856,  959,  960},
+    {  757,  758,  855,  857,  960,  961},
+    {  758,  759,  856,  858,  961,  962},
+    {  759,  760,  857,  859,  962,  963},
+    {  760,  761,  858,  860,  963,  964},
+    {  761,  762,  859,  861,  964,  965}, // 860
+    {  762,  763,  860,  862,  965,  966},
+    {  763,  764,  861,  863,  966,  967},
+    {  764,  765,  862,  864,  967,  968},
+    {  765,  766,  863,  865,  968,  969},
+    {  766,  767,  864,  866,  969,  970},
+    {  767,  768,  865,  867,  970,  971},
+    {  768,  769,  866,  868,  971,  972},
+    {  769,  867,  869,  972,  973,  974},
+    {  769,  770,  868,  870,  974,  975},
+    {  770,  771,  869,  871,  975,  976},
+    {  771,  772,  870,  872,  976,  977},
+    {  772,  773,  871,  873,  977,  978},
+    {  773,  774,  872,  874,  978,  979},
+    {  774,  775,  873,  875,  979,  980},
+    {  775,  776,  874,  876,  980,  981},
+    {  776,  777,  875,  877,  981,  982},
+    {  777,  778,  876,  878,  982,  983},
+    {  778,  779,  877,  879,  983,  984},
+    {  779,  780,  878,  880,  984,  985},
+    {  780,  781,  879,  881,  985,  986}, // 880
+    {  781,  782,  880,  882,  986,  987},
+    {  782,  783,  881,  883,  987,  988},
+    {  783,  784,  882,  884,  988,  989},
+    {  784,  785,  883,  885,  989,  990},
+    {  785,  884,  886,  990,  991,  992},
+    {  785,  786,  885,  887,  992,  993},
+    {  786,  787,  886,  888,  993,  994},
+    {  787,  788,  887,  889,  994,  995},
+    {  788,  789,  888,  890,  995,  996},
+    {  789,  790,  889,  891,  996,  997},
+    {  790,  791,  890,  892,  997,  998},
+    {  791,  792,  891,  893,  998,  999},
+    {  792,  793,  892,  894,  999,  1000},
+    {  793,  794,  893,  895,  1000,  1001},
+    {  794,  795,  894,  896,  1001,  1002},
+    {  795,  796,  895,  897,  1002,  1003},
+    {  796,  797,  896,  898,  1003,  1004},
+    {  797,  798,  897,  899,  1004,  1005},
+    {  798,  799,  898,  900,  1005,  1006},
+    {  799,  800,  899,  901,  1006,  1007}, // 900
+    {  800,  801,  900,  902,  1007,  1008},
+    {  801,  901,  903,  1008,  1009,  1010},
+    {  801,  802,  902,  904,  1010,  1011},
+    {  802,  803,  903,  905,  1011,  1012},
+    {  803,  804,  904,  906,  1012,  1013},
+    {  804,  805,  905,  907,  1013,  1014},
+    {  805,  806,  906,  908,  1014,  1015},
+    {  806,  807,  907,  909,  1015,  1016},
+    {  807,  808,  908,  910,  1016,  1017},
+    {  808,  809,  909,  911,  1017,  1018},
+    {  809,  810,  910,  912,  1018,  1019},
+    {  810,  811,  911,  913,  1019,  1020},
+    {  811,  812,  912,  914,  1020,  1021},
+    {  812,  813,  913,  915,  1021,  1022},
+    {  813,  814,  914,  916,  1022,  1023},
+    {  814,  815,  915,  917,  1023,  1024},
+    {  815,  816,  916,  918,  1024,  1025},
+    {  721,  816,  817,  917,  1025,  1026},
+    {  817,  920,  1026,  1027,  1028,  1140},
+    {  817,  818,  919,  921,  1028,  1029}, // 920
+    {  818,  819,  920,  922,  1029,  1030},
+    {  819,  820,  921,  923,  1030,  1031},
+    {  820,  821,  922,  924,  1031,  1032},
+    {  821,  822,  923,  925,  1032,  1033},
+    {  822,  823,  924,  926,  1033,  1034},
+    {  823,  824,  925,  927,  1034,  1035},
+    {  824,  825,  926,  928,  1035,  1036},
+    {  825,  826,  927,  929,  1036,  1037},
+    {  826,  827,  928,  930,  1037,  1038},
+    {  827,  828,  929,  931,  1038,  1039},
+    {  828,  829,  930,  932,  1039,  1040},
+    {  829,  830,  931,  933,  1040,  1041},
+    {  830,  831,  932,  934,  1041,  1042},
+    {  831,  832,  933,  935,  1042,  1043},
+    {  832,  833,  934,  936,  1043,  1044},
+    {  833,  834,  935,  937,  1044,  1045},
+    {  834,  936,  938,  1045,  1046,  1047},
+    {  834,  835,  937,  939,  1047,  1048},
+    {  835,  836,  938,  940,  1048,  1049},
+    {  836,  837,  939,  941,  1049,  1050}, // 940
+    {  837,  838,  940,  942,  1050,  1051},
+    {  838,  839,  941,  943,  1051,  1052},
+    {  839,  840,  942,  944,  1052,  1053},
+    {  840,  841,  943,  945,  1053,  1054},
+    {  841,  842,  944,  946,  1054,  1055},
+    {  842,  843,  945,  947,  1055,  1056},
+    {  843,  844,  946,  948,  1056,  1057},
+    {  844,  845,  947,  949,  1057,  1058},
+    {  845,  846,  948,  950,  1058,  1059},
+    {  846,  847,  949,  951,  1059,  1060},
+    {  847,  848,  950,  952,  1060,  1061},
+    {  848,  849,  951,  953,  1061,  1062},
+    {  849,  850,  952,  954,  1062,  1063},
+    {  850,  851,  953,  955,  1063,  1064},
+    {  851,  954,  956,  1064,  1065,  1066},
+    {  851,  852,  955,  957,  1066,  1067},
+    {  852,  853,  956,  958,  1067,  1068},
+    {  853,  854,  957,  959,  1068,  1069},
+    {  854,  855,  958,  960,  1069,  1070},
+    {  855,  856,  959,  961,  1070,  1071}, // 960
+    {  856,  857,  960,  962,  1071,  1072},
+    {  857,  858,  961,  963,  1072,  1073},
+    {  858,  859,  962,  964,  1073,  1074},
+    {  859,  860,  963,  965,  1074,  1075},
+    {  860,  861,  964,  966,  1075,  1076},
+    {  861,  862,  965,  967,  1076,  1077},
+    {  862,  863,  966,  968,  1077,  1078},
+    {  863,  864,  967,  969,  1078,  1079},
+    {  864,  865,  968,  970,  1079,  1080},
+    {  865,  866,  969,  971,  1080,  1081},
+    {  866,  867,  970,  972,  1081,  1082},
+    {  867,  868,  971,  973,  1082,  1083},
+    {  868,  972,  974,  1083,  1084,  1085},
+    {  868,  869,  973,  975,  1085,  1086},
+    {  869,  870,  974,  976,  1086,  1087},
+    {  870,  871,  975,  977,  1087,  1088},
+    {  871,  872,  976,  978,  1088,  1089},
+    {  872,  873,  977,  979,  1089,  1090},
+    {  873,  874,  978,  980,  1090,  1091},
+    {  874,  875,  979,  981,  1091,  1092}, // 980
+    {  875,  876,  980,  982,  1092,  1093},
+    {  876,  877,  981,  983,  1093,  1094},
+    {  877,  878,  982,  984,  1094,  1095},
+    {  878,  879,  983,  985,  1095,  1096},
+    {  879,  880,  984,  986,  1096,  1097},
+    {  880,  881,  985,  987,  1097,  1098},
+    {  881,  882,  986,  988,  1098,  1099},
+    {  882,  883,  987,  989,  1099,  1100},
+    {  883,  884,  988,  990,  1100,  1101},
+    {  884,  885,  989,  991,  1101,  1102},
+    {  885,  990,  992,  1102,  1103,  1104},
+    {  885,  886,  991,  993,  1104,  1105},
+    {  886,  887,  992,  994,  1105,  1106},
+    {  887,  888,  993,  995,  1106,  1107},
+    {  888,  889,  994,  996,  1107,  1108},
+    {  889,  890,  995,  997,  1108,  1109},
+    {  890,  891,  996,  998,  1109,  1110},
+    {  891,  892,  997,  999,  1110,  1111},
+    {  892,  893,  998,  1000,  1111,  1112},
+    {  893,  894,  999,  1001,  1112,  1113}, // 1000
+    {  894,  895,  1000,  1002,  1113,  1114},
+    {  895,  896,  1001,  1003,  1114,  1115},
+    {  896,  897,  1002,  1004,  1115,  1116},
+    {  897,  898,  1003,  1005,  1116,  1117},
+    {  898,  899,  1004,  1006,  1117,  1118},
+    {  899,  900,  1005,  1007,  1118,  1119},
+    {  900,  901,  1006,  1008,  1119,  1120},
+    {  901,  902,  1007,  1009,  1120,  1121},
+    {  902,  1008,  1010,  1121,  1122,  1123},
+    {  902,  903,  1009,  1011,  1123,  1124},
+    {  903,  904,  1010,  1012,  1124,  1125},
+    {  904,  905,  1011,  1013,  1125,  1126},
+    {  905,  906,  1012,  1014,  1126,  1127},
+    {  906,  907,  1013,  1015,  1127,  1128},
+    {  907,  908,  1014,  1016,  1128,  1129},
+    {  908,  909,  1015,  1017,  1129,  1130},
+    {  909,  910,  1016,  1018,  1130,  1131},
+    {  910,  911,  1017,  1019,  1131,  1132},
+    {  911,  912,  1018,  1020,  1132,  1133},
+    {  912,  913,  1019,  1021,  1133,  1134}, // 1020
+    {  913,  914,  1020,  1022,  1134,  1135},
+    {  914,  915,  1021,  1023,  1135,  1136},
+    {  915,  916,  1022,  1024,  1136,  1137},
+    {  916,  917,  1023,  1025,  1137,  1138},
+    {  917,  918,  1024,  1026,  1138,  1139},
+    {  817,  918,  919,  1025,  1139,  1140},
+    {  919,  1028,  1140,  1141,  1142,  1260},
+    {  919,  920,  1027,  1029,  1142,  1143},
+    {  920,  921,  1028,  1030,  1143,  1144},
+    {  921,  922,  1029,  1031,  1144,  1145},
+    {  922,  923,  1030,  1032,  1145,  1146},
+    {  923,  924,  1031,  1033,  1146,  1147},
+    {  924,  925,  1032,  1034,  1147,  1148},
+    {  925,  926,  1033,  1035,  1148,  1149},
+    {  926,  927,  1034,  1036,  1149,  1150},
+    {  927,  928,  1035,  1037,  1150,  1151},
+    {  928,  929,  1036,  1038,  1151,  1152},
+    {  929,  930,  1037,  1039,  1152,  1153},
+    {  930,  931,  1038,  1040,  1153,  1154},
+    {  931,  932,  1039,  1041,  1154,  1155}, // 1040
+    {  932,  933,  1040,  1042,  1155,  1156},
+    {  933,  934,  1041,  1043,  1156,  1157},
+    {  934,  935,  1042,  1044,  1157,  1158},
+    {  935,  936,  1043,  1045,  1158,  1159},
+    {  936,  937,  1044,  1046,  1159,  1160},
+    {  937,  1045,  1047,  1160,  1161,  1162},
+    {  937,  938,  1046,  1048,  1162,  1163},
+    {  938,  939,  1047,  1049,  1163,  1164},
+    {  939,  940,  1048,  1050,  1164,  1165},
+    {  940,  941,  1049,  1051,  1165,  1166},
+    {  941,  942,  1050,  1052,  1166,  1167},
+    {  942,  943,  1051,  1053,  1167,  1168},
+    {  943,  944,  1052,  1054,  1168,  1169},
+    {  944,  945,  1053,  1055,  1169,  1170},
+    {  945,  946,  1054,  1056,  1170,  1171},
+    {  946,  947,  1055,  1057,  1171,  1172},
+    {  947,  948,  1056,  1058,  1172,  1173},
+    {  948,  949,  1057,  1059,  1173,  1174},
+    {  949,  950,  1058,  1060,  1174,  1175},
+    {  950,  951,  1059,  1061,  1175,  1176}, // 1060
+    {  951,  952,  1060,  1062,  1176,  1177},
+    {  952,  953,  1061,  1063,  1177,  1178},
+    {  953,  954,  1062,  1064,  1178,  1179},
+    {  954,  955,  1063,  1065,  1179,  1180},
+    {  955,  1064,  1066,  1180,  1181,  1182},
+    {  955,  956,  1065,  1067,  1182,  1183},
+    {  956,  957,  1066,  1068,  1183,  1184},
+    {  957,  958,  1067,  1069,  1184,  1185},
+    {  958,  959,  1068,  1070,  1185,  1186},
+    {  959,  960,  1069,  1071,  1186,  1187},
+    {  960,  961,  1070,  1072,  1187,  1188},
+    {  961,  962,  1071,  1073,  1188,  1189},
+    {  962,  963,  1072,  1074,  1189,  1190},
+    {  963,  964,  1073,  1075,  1190,  1191},
+    {  964,  965,  1074,  1076,  1191,  1192},
+    {  965,  966,  1075,  1077,  1192,  1193},
+    {  966,  967,  1076,  1078,  1193,  1194},
+    {  967,  968,  1077,  1079,  1194,  1195},
+    {  968,  969,  1078,  1080,  1195,  1196},
+    {  969,  970,  1079,  1081,  1196,  1197}, // 1080
+    {  970,  971,  1080,  1082,  1197,  1198},
+    {  971,  972,  1081,  1083,  1198,  1199},
+    {  972,  973,  1082,  1084,  1199,  1200},
+    {  973,  1083,  1085,  1200,  1201,  1202},
+    {  973,  974,  1084,  1086,  1202,  1203},
+    {  974,  975,  1085,  1087,  1203,  1204},
+    {  975,  976,  1086,  1088,  1204,  1205},
+    {  976,  977,  1087,  1089,  1205,  1206},
+    {  977,  978,  1088,  1090,  1206,  1207},
+    {  978,  979,  1089,  1091,  1207,  1208},
+    {  979,  980,  1090,  1092,  1208,  1209},
+    {  980,  981,  1091,  1093,  1209,  1210},
+    {  981,  982,  1092,  1094,  1210,  1211},
+    {  982,  983,  1093,  1095,  1211,  1212},
+    {  983,  984,  1094,  1096,  1212,  1213},
+    {  984,  985,  1095,  1097,  1213,  1214},
+    {  985,  986,  1096,  1098,  1214,  1215},
+    {  986,  987,  1097,  1099,  1215,  1216},
+    {  987,  988,  1098,  1100,  1216,  1217},
+    {  988,  989,  1099,  1101,  1217,  1218}, // 1100
+    {  989,  990,  1100,  1102,  1218,  1219},
+    {  990,  991,  1101,  1103,  1219,  1220},
+    {  991,  1102,  1104,  1220,  1221,  1222},
+    {  991,  992,  1103,  1105,  1222,  1223},
+    {  992,  993,  1104,  1106,  1223,  1224},
+    {  993,  994,  1105,  1107,  1224,  1225},
+    {  994,  995,  1106,  1108,  1225,  1226},
+    {  995,  996,  1107,  1109,  1226,  1227},
+    {  996,  997,  1108,  1110,  1227,  1228},
+    {  997,  998,  1109,  1111,  1228,  1229},
+    {  998,  999,  1110,  1112,  1229,  1230},
+    {  999,  1000,  1111,  1113,  1230,  1231},
+    {  1000,  1001,  1112,  1114,  1231,  1232},
+    {  1001,  1002,  1113,  1115,  1232,  1233},
+    {  1002,  1003,  1114,  1116,  1233,  1234},
+    {  1003,  1004,  1115,  1117,  1234,  1235},
+    {  1004,  1005,  1116,  1118,  1235,  1236},
+    {  1005,  1006,  1117,  1119,  1236,  1237},
+    {  1006,  1007,  1118,  1120,  1237,  1238},
+    {  1007,  1008,  1119,  1121,  1238,  1239}, // 1120
+    {  1008,  1009,  1120,  1122,  1239,  1240},
+    {  1009,  1121,  1123,  1240,  1241,  1242},
+    {  1009,  1010,  1122,  1124,  1242,  1243},
+    {  1010,  1011,  1123,  1125,  1243,  1244},
+    {  1011,  1012,  1124,  1126,  1244,  1245},
+    {  1012,  1013,  1125,  1127,  1245,  1246},
+    {  1013,  1014,  1126,  1128,  1246,  1247},
+    {  1014,  1015,  1127,  1129,  1247,  1248},
+    {  1015,  1016,  1128,  1130,  1248,  1249},
+    {  1016,  1017,  1129,  1131,  1249,  1250},
+    {  1017,  1018,  1130,  1132,  1250,  1251},
+    {  1018,  1019,  1131,  1133,  1251,  1252},
+    {  1019,  1020,  1132,  1134,  1252,  1253},
+    {  1020,  1021,  1133,  1135,  1253,  1254},
+    {  1021,  1022,  1134,  1136,  1254,  1255},
+    {  1022,  1023,  1135,  1137,  1255,  1256},
+    {  1023,  1024,  1136,  1138,  1256,  1257},
+    {  1024,  1025,  1137,  1139,  1257,  1258},
+    {  1025,  1026,  1138,  1140,  1258,  1259},
+    {  919,  1026,  1027,  1139,  1259,  1260}, // 1140
+    {  1027,  1142,  1260,  1261,  1262,  1386},
+    {  1027,  1028,  1141,  1143,  1262,  1263},
+    {  1028,  1029,  1142,  1144,  1263,  1264},
+    {  1029,  1030,  1143,  1145,  1264,  1265},
+    {  1030,  1031,  1144,  1146,  1265,  1266},
+    {  1031,  1032,  1145,  1147,  1266,  1267},
+    {  1032,  1033,  1146,  1148,  1267,  1268},
+    {  1033,  1034,  1147,  1149,  1268,  1269},
+    {  1034,  1035,  1148,  1150,  1269,  1270},
+    {  1035,  1036,  1149,  1151,  1270,  1271},
+    {  1036,  1037,  1150,  1152,  1271,  1272},
+    {  1037,  1038,  1151,  1153,  1272,  1273},
+    {  1038,  1039,  1152,  1154,  1273,  1274},
+    {  1039,  1040,  1153,  1155,  1274,  1275},
+    {  1040,  1041,  1154,  1156,  1275,  1276},
+    {  1041,  1042,  1155,  1157,  1276,  1277},
+    {  1042,  1043,  1156,  1158,  1277,  1278},
+    {  1043,  1044,  1157,  1159,  1278,  1279},
+    {  1044,  1045,  1158,  1160,  1279,  1280},
+    {  1045,  1046,  1159,  1161,  1280,  1281}, // 1160
+    {  1046,  1160,  1162,  1281,  1282,  1283},
+    {  1046,  1047,  1161,  1163,  1283,  1284},
+    {  1047,  1048,  1162,  1164,  1284,  1285},
+    {  1048,  1049,  1163,  1165,  1285,  1286},
+    {  1049,  1050,  1164,  1166,  1286,  1287},
+    {  1050,  1051,  1165,  1167,  1287,  1288},
+    {  1051,  1052,  1166,  1168,  1288,  1289},
+    {  1052,  1053,  1167,  1169,  1289,  1290},
+    {  1053,  1054,  1168,  1170,  1290,  1291},
+    {  1054,  1055,  1169,  1171,  1291,  1292},
+    {  1055,  1056,  1170,  1172,  1292,  1293},
+    {  1056,  1057,  1171,  1173,  1293,  1294},
+    {  1057,  1058,  1172,  1174,  1294,  1295},
+    {  1058,  1059,  1173,  1175,  1295,  1296},
+    {  1059,  1060,  1174,  1176,  1296,  1297},
+    {  1060,  1061,  1175,  1177,  1297,  1298},
+    {  1061,  1062,  1176,  1178,  1298,  1299},
+    {  1062,  1063,  1177,  1179,  1299,  1300},
+    {  1063,  1064,  1178,  1180,  1300,  1301},
+    {  1064,  1065,  1179,  1181,  1301,  1302}, // 1180
+    {  1065,  1180,  1182,  1302,  1303,  1304},
+    {  1065,  1066,  1181,  1183,  1304,  1305},
+    {  1066,  1067,  1182,  1184,  1305,  1306},
+    {  1067,  1068,  1183,  1185,  1306,  1307},
+    {  1068,  1069,  1184,  1186,  1307,  1308},
+    {  1069,  1070,  1185,  1187,  1308,  1309},
+    {  1070,  1071,  1186,  1188,  1309,  1310},
+    {  1071,  1072,  1187,  1189,  1310,  1311},
+    {  1072,  1073,  1188,  1190,  1311,  1312},
+    {  1073,  1074,  1189,  1191,  1312,  1313},
+    {  1074,  1075,  1190,  1192,  1313,  1314},
+    {  1075,  1076,  1191,  1193,  1314,  1315},
+    {  1076,  1077,  1192,  1194,  1315,  1316},
+    {  1077,  1078,  1193,  1195,  1316,  1317},
+    {  1078,  1079,  1194,  1196,  1317,  1318},
+    {  1079,  1080,  1195,  1197,  1318,  1319},
+    {  1080,  1081,  1196,  1198,  1319,  1320},
+    {  1081,  1082,  1197,  1199,  1320,  1321},
+    {  1082,  1083,  1198,  1200,  1321,  1322},
+    {  1083,  1084,  1199,  1201,  1322,  1323}, // 1200
+    {  1084,  1200,  1202,  1323,  1324,  1325},
+    {  1084,  1085,  1201,  1203,  1325,  1326},
+    {  1085,  1086,  1202,  1204,  1326,  1327},
+    {  1086,  1087,  1203,  1205,  1327,  1328},
+    {  1087,  1088,  1204,  1206,  1328,  1329},
+    {  1088,  1089,  1205,  1207,  1329,  1330},
+    {  1089,  1090,  1206,  1208,  1330,  1331},
+    {  1090,  1091,  1207,  1209,  1331,  1332},
+    {  1091,  1092,  1208,  1210,  1332,  1333},
+    {  1092,  1093,  1209,  1211,  1333,  1334},
+    {  1093,  1094,  1210,  1212,  1334,  1335},
+    {  1094,  1095,  1211,  1213,  1335,  1336},
+    {  1095,  1096,  1212,  1214,  1336,  1337},
+    {  1096,  1097,  1213,  1215,  1337,  1338},
+    {  1097,  1098,  1214,  1216,  1338,  1339},
+    {  1098,  1099,  1215,  1217,  1339,  1340},
+    {  1099,  1100,  1216,  1218,  1340,  1341},
+    {  1100,  1101,  1217,  1219,  1341,  1342},
+    {  1101,  1102,  1218,  1220,  1342,  1343},
+    {  1102,  1103,  1219,  1221,  1343,  1344}, // 1220
+    {  1103,  1220,  1222,  1344,  1345,  1346},
+    {  1103,  1104,  1221,  1223,  1346,  1347},
+    {  1104,  1105,  1222,  1224,  1347,  1348},
+    {  1105,  1106,  1223,  1225,  1348,  1349},
+    {  1106,  1107,  1224,  1226,  1349,  1350},
+    {  1107,  1108,  1225,  1227,  1350,  1351},
+    {  1108,  1109,  1226,  1228,  1351,  1352},
+    {  1109,  1110,  1227,  1229,  1352,  1353},
+    {  1110,  1111,  1228,  1230,  1353,  1354},
+    {  1111,  1112,  1229,  1231,  1354,  1355},
+    {  1112,  1113,  1230,  1232,  1355,  1356},
+    {  1113,  1114,  1231,  1233,  1356,  1357},
+    {  1114,  1115,  1232,  1234,  1357,  1358},
+    {  1115,  1116,  1233,  1235,  1358,  1359},
+    {  1116,  1117,  1234,  1236,  1359,  1360},
+    {  1117,  1118,  1235,  1237,  1360,  1361},
+    {  1118,  1119,  1236,  1238,  1361,  1362},
+    {  1119,  1120,  1237,  1239,  1362,  1363},
+    {  1120,  1121,  1238,  1240,  1363,  1364},
+    {  1121,  1122,  1239,  1241,  1364,  1365}, // 1240
+    {  1122,  1240,  1242,  1365,  1366,  1367},
+    {  1122,  1123,  1241,  1243,  1367,  1368},
+    {  1123,  1124,  1242,  1244,  1368,  1369},
+    {  1124,  1125,  1243,  1245,  1369,  1370},
+    {  1125,  1126,  1244,  1246,  1370,  1371},
+    {  1126,  1127,  1245,  1247,  1371,  1372},
+    {  1127,  1128,  1246,  1248,  1372,  1373},
+    {  1128,  1129,  1247,  1249,  1373,  1374},
+    {  1129,  1130,  1248,  1250,  1374,  1375},
+    {  1130,  1131,  1249,  1251,  1375,  1376},
+    {  1131,  1132,  1250,  1252,  1376,  1377},
+    {  1132,  1133,  1251,  1253,  1377,  1378},
+    {  1133,  1134,  1252,  1254,  1378,  1379},
+    {  1134,  1135,  1253,  1255,  1379,  1380},
+    {  1135,  1136,  1254,  1256,  1380,  1381},
+    {  1136,  1137,  1255,  1257,  1381,  1382},
+    {  1137,  1138,  1256,  1258,  1382,  1383},
+    {  1138,  1139,  1257,  1259,  1383,  1384},
+    {  1139,  1140,  1258,  1260,  1384,  1385},
+    {  1027,  1140,  1141,  1259,  1385,  1386}, // 1260
+    {  1141,  1262,  1386,  1387,  1388,  1518},
+    {  1141,  1142,  1261,  1263,  1388,  1389},
+    {  1142,  1143,  1262,  1264,  1389,  1390},
+    {  1143,  1144,  1263,  1265,  1390,  1391},
+    {  1144,  1145,  1264,  1266,  1391,  1392},
+    {  1145,  1146,  1265,  1267,  1392,  1393},
+    {  1146,  1147,  1266,  1268,  1393,  1394},
+    {  1147,  1148,  1267,  1269,  1394,  1395},
+    {  1148,  1149,  1268,  1270,  1395,  1396},
+    {  1149,  1150,  1269,  1271,  1396,  1397},
+    {  1150,  1151,  1270,  1272,  1397,  1398},
+    {  1151,  1152,  1271,  1273,  1398,  1399},
+    {  1152,  1153,  1272,  1274,  1399,  1400},
+    {  1153,  1154,  1273,  1275,  1400,  1401},
+    {  1154,  1155,  1274,  1276,  1401,  1402},
+    {  1155,  1156,  1275,  1277,  1402,  1403},
+    {  1156,  1157,  1276,  1278,  1403,  1404},
+    {  1157,  1158,  1277,  1279,  1404,  1405},
+    {  1158,  1159,  1278,  1280,  1405,  1406},
+    {  1159,  1160,  1279,  1281,  1406,  1407}, // 1280
+    {  1160,  1161,  1280,  1282,  1407,  1408},
+    {  1161,  1281,  1283,  1408,  1409,  1410},
+    {  1161,  1162,  1282,  1284,  1410,  1411},
+    {  1162,  1163,  1283,  1285,  1411,  1412},
+    {  1163,  1164,  1284,  1286,  1412,  1413},
+    {  1164,  1165,  1285,  1287,  1413,  1414},
+    {  1165,  1166,  1286,  1288,  1414,  1415},
+    {  1166,  1167,  1287,  1289,  1415,  1416},
+    {  1167,  1168,  1288,  1290,  1416,  1417},
+    {  1168,  1169,  1289,  1291,  1417,  1418},
+    {  1169,  1170,  1290,  1292,  1418,  1419},
+    {  1170,  1171,  1291,  1293,  1419,  1420},
+    {  1171,  1172,  1292,  1294,  1420,  1421},
+    {  1172,  1173,  1293,  1295,  1421,  1422},
+    {  1173,  1174,  1294,  1296,  1422,  1423},
+    {  1174,  1175,  1295,  1297,  1423,  1424},
+    {  1175,  1176,  1296,  1298,  1424,  1425},
+    {  1176,  1177,  1297,  1299,  1425,  1426},
+    {  1177,  1178,  1298,  1300,  1426,  1427},
+    {  1178,  1179,  1299,  1301,  1427,  1428}, // 1300
+    {  1179,  1180,  1300,  1302,  1428,  1429},
+    {  1180,  1181,  1301,  1303,  1429,  1430},
+    {  1181,  1302,  1304,  1430,  1431,  1432},
+    {  1181,  1182,  1303,  1305,  1432,  1433},
+    {  1182,  1183,  1304,  1306,  1433,  1434},
+    {  1183,  1184,  1305,  1307,  1434,  1435},
+    {  1184,  1185,  1306,  1308,  1435,  1436},
+    {  1185,  1186,  1307,  1309,  1436,  1437},
+    {  1186,  1187,  1308,  1310,  1437,  1438},
+    {  1187,  1188,  1309,  1311,  1438,  1439},
+    {  1188,  1189,  1310,  1312,  1439,  1440},
+    {  1189,  1190,  1311,  1313,  1440,  1441},
+    {  1190,  1191,  1312,  1314,  1441,  1442},
+    {  1191,  1192,  1313,  1315,  1442,  1443},
+    {  1192,  1193,  1314,  1316,  1443,  1444},
+    {  1193,  1194,  1315,  1317,  1444,  1445},
+    {  1194,  1195,  1316,  1318,  1445,  1446},
+    {  1195,  1196,  1317,  1319,  1446,  1447},
+    {  1196,  1197,  1318,  1320,  1447,  1448},
+    {  1197,  1198,  1319,  1321,  1448,  1449}, // 1320
+    {  1198,  1199,  1320,  1322,  1449,  1450},
+    {  1199,  1200,  1321,  1323,  1450,  1451},
+    {  1200,  1201,  1322,  1324,  1451,  1452},
+    {  1201,  1323,  1325,  1452,  1453,  1454},
+    {  1201,  1202,  1324,  1326,  1454,  1455},
+    {  1202,  1203,  1325,  1327,  1455,  1456},
+    {  1203,  1204,  1326,  1328,  1456,  1457},
+    {  1204,  1205,  1327,  1329,  1457,  1458},
+    {  1205,  1206,  1328,  1330,  1458,  1459},
+    {  1206,  1207,  1329,  1331,  1459,  1460},
+    {  1207,  1208,  1330,  1332,  1460,  1461},
+    {  1208,  1209,  1331,  1333,  1461,  1462},
+    {  1209,  1210,  1332,  1334,  1462,  1463},
+    {  1210,  1211,  1333,  1335,  1463,  1464},
+    {  1211,  1212,  1334,  1336,  1464,  1465},
+    {  1212,  1213,  1335,  1337,  1465,  1466},
+    {  1213,  1214,  1336,  1338,  1466,  1467},
+    {  1214,  1215,  1337,  1339,  1467,  1468},
+    {  1215,  1216,  1338,  1340,  1468,  1469},
+    {  1216,  1217,  1339,  1341,  1469,  1470}, // 1340
+    {  1217,  1218,  1340,  1342,  1470,  1471},
+    {  1218,  1219,  1341,  1343,  1471,  1472},
+    {  1219,  1220,  1342,  1344,  1472,  1473},
+    {  1220,  1221,  1343,  1345,  1473,  1474},
+    {  1221,  1344,  1346,  1474,  1475,  1476},
+    {  1221,  1222,  1345,  1347,  1476,  1477},
+    {  1222,  1223,  1346,  1348,  1477,  1478},
+    {  1223,  1224,  1347,  1349,  1478,  1479},
+    {  1224,  1225,  1348,  1350,  1479,  1480},
+    {  1225,  1226,  1349,  1351,  1480,  1481},
+    {  1226,  1227,  1350,  1352,  1481,  1482},
+    {  1227,  1228,  1351,  1353,  1482,  1483},
+    {  1228,  1229,  1352,  1354,  1483,  1484},
+    {  1229,  1230,  1353,  1355,  1484,  1485},
+    {  1230,  1231,  1354,  1356,  1485,  1486},
+    {  1231,  1232,  1355,  1357,  1486,  1487},
+    {  1232,  1233,  1356,  1358,  1487,  1488},
+    {  1233,  1234,  1357,  1359,  1488,  1489},
+    {  1234,  1235,  1358,  1360,  1489,  1490},
+    {  1235,  1236,  1359,  1361,  1490,  1491}, // 1360
+    {  1236,  1237,  1360,  1362,  1491,  1492},
+    {  1237,  1238,  1361,  1363,  1492,  1493},
+    {  1238,  1239,  1362,  1364,  1493,  1494},
+    {  1239,  1240,  1363,  1365,  1494,  1495},
+    {  1240,  1241,  1364,  1366,  1495,  1496},
+    {  1241,  1365,  1367,  1496,  1497,  1498},
+    {  1241,  1242,  1366,  1368,  1498,  1499},
+    {  1242,  1243,  1367,  1369,  1499,  1500},
+    {  1243,  1244,  1368,  1370,  1500,  1501},
+    {  1244,  1245,  1369,  1371,  1501,  1502},
+    {  1245,  1246,  1370,  1372,  1502,  1503},
+    {  1246,  1247,  1371,  1373,  1503,  1504},
+    {  1247,  1248,  1372,  1374,  1504,  1505},
+    {  1248,  1249,  1373,  1375,  1505,  1506},
+    {  1249,  1250,  1374,  1376,  1506,  1507},
+    {  1250,  1251,  1375,  1377,  1507,  1508},
+    {  1251,  1252,  1376,  1378,  1508,  1509},
+    {  1252,  1253,  1377,  1379,  1509,  1510},
+    {  1253,  1254,  1378,  1380,  1510,  1511},
+    {  1254,  1255,  1379,  1381,  1511,  1512}, // 1380
+    {  1255,  1256,  1380,  1382,  1512,  1513},
+    {  1256,  1257,  1381,  1383,  1513,  1514},
+    {  1257,  1258,  1382,  1384,  1514,  1515},
+    {  1258,  1259,  1383,  1385,  1515,  1516},
+    {  1259,  1260,  1384,  1386,  1516,  1517},
+    {  1141,  1260,  1261,  1385,  1517,  1518},
+    {  1261,  1388,  1518,  1519,  1520,  1656},
+    {  1261,  1262,  1387,  1389,  1520,  1521},
+    {  1262,  1263,  1388,  1390,  1521,  1522},
+    {  1263,  1264,  1389,  1391,  1522,  1523},
+    {  1264,  1265,  1390,  1392,  1523,  1524},
+    {  1265,  1266,  1391,  1393,  1524,  1525},
+    {  1266,  1267,  1392,  1394,  1525,  1526},
+    {  1267,  1268,  1393,  1395,  1526,  1527},
+    {  1268,  1269,  1394,  1396,  1527,  1528},
+    {  1269,  1270,  1395,  1397,  1528,  1529},
+    {  1270,  1271,  1396,  1398,  1529,  1530},
+    {  1271,  1272,  1397,  1399,  1530,  1531},
+    {  1272,  1273,  1398,  1400,  1531,  1532},
+    {  1273,  1274,  1399,  1401,  1532,  1533}, // 1400
+    {  1274,  1275,  1400,  1402,  1533,  1534},
+    {  1275,  1276,  1401,  1403,  1534,  1535},
+    {  1276,  1277,  1402,  1404,  1535,  1536},
+    {  1277,  1278,  1403,  1405,  1536,  1537},
+    {  1278,  1279,  1404,  1406,  1537,  1538},
+    {  1279,  1280,  1405,  1407,  1538,  1539},
+    {  1280,  1281,  1406,  1408,  1539,  1540},
+    {  1281,  1282,  1407,  1409,  1540,  1541},
+    {  1282,  1408,  1410,  1541,  1542,  1543},
+    {  1282,  1283,  1409,  1411,  1543,  1544},
+    {  1283,  1284,  1410,  1412,  1544,  1545},
+    {  1284,  1285,  1411,  1413,  1545,  1546},
+    {  1285,  1286,  1412,  1414,  1546,  1547},
+    {  1286,  1287,  1413,  1415,  1547,  1548},
+    {  1287,  1288,  1414,  1416,  1548,  1549},
+    {  1288,  1289,  1415,  1417,  1549,  1550},
+    {  1289,  1290,  1416,  1418,  1550,  1551},
+    {  1290,  1291,  1417,  1419,  1551,  1552},
+    {  1291,  1292,  1418,  1420,  1552,  1553},
+    {  1292,  1293,  1419,  1421,  1553,  1554}, // 1420
+    {  1293,  1294,  1420,  1422,  1554,  1555},
+    {  1294,  1295,  1421,  1423,  1555,  1556},
+    {  1295,  1296,  1422,  1424,  1556,  1557},
+    {  1296,  1297,  1423,  1425,  1557,  1558},
+    {  1297,  1298,  1424,  1426,  1558,  1559},
+    {  1298,  1299,  1425,  1427,  1559,  1560},
+    {  1299,  1300,  1426,  1428,  1560,  1561},
+    {  1300,  1301,  1427,  1429,  1561,  1562},
+    {  1301,  1302,  1428,  1430,  1562,  1563},
+    {  1302,  1303,  1429,  1431,  1563,  1564},
+    {  1303,  1430,  1432,  1564,  1565,  1566},
+    {  1303,  1304,  1431,  1433,  1566,  1567},
+    {  1304,  1305,  1432,  1434,  1567,  1568},
+    {  1305,  1306,  1433,  1435,  1568,  1569},
+    {  1306,  1307,  1434,  1436,  1569,  1570},
+    {  1307,  1308,  1435,  1437,  1570,  1571},
+    {  1308,  1309,  1436,  1438,  1571,  1572},
+    {  1309,  1310,  1437,  1439,  1572,  1573},
+    {  1310,  1311,  1438,  1440,  1573,  1574},
+    {  1311,  1312,  1439,  1441,  1574,  1575}, // 1440
+    {  1312,  1313,  1440,  1442,  1575,  1576},
+    {  1313,  1314,  1441,  1443,  1576,  1577},
+    {  1314,  1315,  1442,  1444,  1577,  1578},
+    {  1315,  1316,  1443,  1445,  1578,  1579},
+    {  1316,  1317,  1444,  1446,  1579,  1580},
+    {  1317,  1318,  1445,  1447,  1580,  1581},
+    {  1318,  1319,  1446,  1448,  1581,  1582},
+    {  1319,  1320,  1447,  1449,  1582,  1583},
+    {  1320,  1321,  1448,  1450,  1583,  1584},
+    {  1321,  1322,  1449,  1451,  1584,  1585},
+    {  1322,  1323,  1450,  1452,  1585,  1586},
+    {  1323,  1324,  1451,  1453,  1586,  1587},
+    {  1324,  1452,  1454,  1587,  1588,  1589},
+    {  1324,  1325,  1453,  1455,  1589,  1590},
+    {  1325,  1326,  1454,  1456,  1590,  1591},
+    {  1326,  1327,  1455,  1457,  1591,  1592},
+    {  1327,  1328,  1456,  1458,  1592,  1593},
+    {  1328,  1329,  1457,  1459,  1593,  1594},
+    {  1329,  1330,  1458,  1460,  1594,  1595},
+    {  1330,  1331,  1459,  1461,  1595,  1596}, // 1460
+    {  1331,  1332,  1460,  1462,  1596,  1597},
+    {  1332,  1333,  1461,  1463,  1597,  1598},
+    {  1333,  1334,  1462,  1464,  1598,  1599},
+    {  1334,  1335,  1463,  1465,  1599,  1600},
+    {  1335,  1336,  1464,  1466,  1600,  1601},
+    {  1336,  1337,  1465,  1467,  1601,  1602},
+    {  1337,  1338,  1466,  1468,  1602,  1603},
+    {  1338,  1339,  1467,  1469,  1603,  1604},
+    {  1339,  1340,  1468,  1470,  1604,  1605},
+    {  1340,  1341,  1469,  1471,  1605,  1606},
+    {  1341,  1342,  1470,  1472,  1606,  1607},
+    {  1342,  1343,  1471,  1473,  1607,  1608},
+    {  1343,  1344,  1472,  1474,  1608,  1609},
+    {  1344,  1345,  1473,  1475,  1609,  1610},
+    {  1345,  1474,  1476,  1610,  1611,  1612},
+    {  1345,  1346,  1475,  1477,  1612,  1613},
+    {  1346,  1347,  1476,  1478,  1613,  1614},
+    {  1347,  1348,  1477,  1479,  1614,  1615},
+    {  1348,  1349,  1478,  1480,  1615,  1616},
+    {  1349,  1350,  1479,  1481,  1616,  1617}, // 1480
+    {  1350,  1351,  1480,  1482,  1617,  1618},
+    {  1351,  1352,  1481,  1483,  1618,  1619},
+    {  1352,  1353,  1482,  1484,  1619,  1620},
+    {  1353,  1354,  1483,  1485,  1620,  1621},
+    {  1354,  1355,  1484,  1486,  1621,  1622},
+    {  1355,  1356,  1485,  1487,  1622,  1623},
+    {  1356,  1357,  1486,  1488,  1623,  1624},
+    {  1357,  1358,  1487,  1489,  1624,  1625},
+    {  1358,  1359,  1488,  1490,  1625,  1626},
+    {  1359,  1360,  1489,  1491,  1626,  1627},
+    {  1360,  1361,  1490,  1492,  1627,  1628},
+    {  1361,  1362,  1491,  1493,  1628,  1629},
+    {  1362,  1363,  1492,  1494,  1629,  1630},
+    {  1363,  1364,  1493,  1495,  1630,  1631},
+    {  1364,  1365,  1494,  1496,  1631,  1632},
+    {  1365,  1366,  1495,  1497,  1632,  1633},
+    {  1366,  1496,  1498,  1633,  1634,  1635},
+    {  1366,  1367,  1497,  1499,  1635,  1636},
+    {  1367,  1368,  1498,  1500,  1636,  1637},
+    {  1368,  1369,  1499,  1501,  1637,  1638}, // 1500
+    {  1369,  1370,  1500,  1502,  1638,  1639},
+    {  1370,  1371,  1501,  1503,  1639,  1640},
+    {  1371,  1372,  1502,  1504,  1640,  1641},
+    {  1372,  1373,  1503,  1505,  1641,  1642},
+    {  1373,  1374,  1504,  1506,  1642,  1643},
+    {  1374,  1375,  1505,  1507,  1643,  1644},
+    {  1375,  1376,  1506,  1508,  1644,  1645},
+    {  1376,  1377,  1507,  1509,  1645,  1646},
+    {  1377,  1378,  1508,  1510,  1646,  1647},
+    {  1378,  1379,  1509,  1511,  1647,  1648},
+    {  1379,  1380,  1510,  1512,  1648,  1649},
+    {  1380,  1381,  1511,  1513,  1649,  1650},
+    {  1381,  1382,  1512,  1514,  1650,  1651},
+    {  1382,  1383,  1513,  1515,  1651,  1652},
+    {  1383,  1384,  1514,  1516,  1652,  1653},
+    {  1384,  1385,  1515,  1517,  1653,  1654},
+    {  1385,  1386,  1516,  1518,  1654,  1655},
+    {  1261,  1386,  1387,  1517,  1655,  1656},
+    {  1387,  1520,  1656,  -1,  -1,  -1},
+    {  1387,  1388,  1519,  1521,  1657,  -1}, // 1520
+    {  1388,  1389,  1520,  1522,  -1,  -1},
+    {  1389,  1390,  1521,  1523,  1658,  -1},
+    {  1390,  1391,  1522,  1524,  -1,  -1},
+    {  1391,  1392,  1523,  1525,  1659,  -1},
+    {  1392,  1393,  1524,  1526,  -1,  -1},
+    {  1393,  1394,  1525,  1527,  1660,  -1},
+    {  1394,  1395,  1526,  1528,  -1,  -1},
+    {  1395,  1396,  1527,  1529,  1661,  -1},
+    {  1396,  1397,  1528,  1530,  -1,  -1},
+    {  1397,  1398,  1529,  1531,  1662,  -1},
+    {  1398,  1399,  1530,  1532,  -1,  -1},
+    {  1399,  1400,  1531,  1533,  1663,  -1},
+    {  1400,  1401,  1532,  1534,  -1,  -1},
+    {  1401,  1402,  1533,  1535,  1664,  -1},
+    {  1402,  1403,  1534,  1536,  -1,  -1},
+    {  1403,  1404,  1535,  1537,  1665,  -1},
+    {  1404,  1405,  1536,  1538,  -1,  -1},
+    {  1405,  1406,  1537,  1539,  1666,  -1},
+    {  1406,  1407,  1538,  1540,  -1,  -1},
+    {  1407,  1408,  1539,  1541,  1667,  -1}, // 1540
+    {  1408,  1409,  1540,  1542,  -1,  -1},
+    {  1409,  1541,  1543,  1668,  -1,  -1},
+    {  1409,  1410,  1542,  1544,  -1,  -1},
+    {  1410,  1411,  1543,  1545,  -1,  -1},
+    {  1411,  1412,  1544,  1546,  -1,  -1},
+    {  1412,  1413,  1545,  1547,  -1,  -1},
+    {  1413,  1414,  1546,  1548,  -1,  -1},
+    {  1414,  1415,  1547,  1549,  -1,  -1},
+    {  1415,  1416,  1548,  1550,  -1,  -1},
+    {  1416,  1417,  1549,  1551,  -1,  -1},
+    {  1417,  1418,  1550,  1552,  -1,  -1},
+    {  1418,  1419,  1551,  1553,  -1,  -1},
+    {  1419,  1420,  1552,  1554,  -1,  -1},
+    {  1420,  1421,  1553,  1555,  -1,  -1},
+    {  1421,  1422,  1554,  1556,  -1,  -1},
+    {  1422,  1423,  1555,  1557,  -1,  -1},
+    {  1423,  1424,  1556,  1558,  -1,  -1},
+    {  1424,  1425,  1557,  1559,  -1,  -1},
+    {  1425,  1426,  1558,  1560,  -1,  -1},
+    {  1426,  1427,  1559,  1561,  -1,  -1}, // 1560
+    {  1427,  1428,  1560,  1562,  -1,  -1},
+    {  1428,  1429,  1561,  1563,  -1,  -1},
+    {  1429,  1430,  1562,  1564,  -1,  -1},
+    {  1430,  1431,  1563,  1565,  -1,  -1},
+    {  1431,  1564,  1566,  -1,  -1,  -1},
+    {  1431,  1432,  1565,  1567,  -1,  -1},
+    {  1432,  1433,  1566,  1568,  -1,  -1},
+    {  1433,  1434,  1567,  1569,  -1,  -1},
+    {  1434,  1435,  1568,  1570,  -1,  -1},
+    {  1435,  1436,  1569,  1571,  -1,  -1},
+    {  1436,  1437,  1570,  1572,  -1,  -1},
+    {  1437,  1438,  1571,  1573,  -1,  -1},
+    {  1438,  1439,  1572,  1574,  -1,  -1},
+    {  1439,  1440,  1573,  1575,  -1,  -1},
+    {  1440,  1441,  1574,  1576,  -1,  -1},
+    {  1441,  1442,  1575,  1577,  -1,  -1},
+    {  1442,  1443,  1576,  1578,  -1,  -1},
+    {  1443,  1444,  1577,  1579,  -1,  -1},
+    {  1444,  1445,  1578,  1580,  -1,  -1},
+    {  1445,  1446,  1579,  1581,  -1,  -1}, // 1580
+    {  1446,  1447,  1580,  1582,  -1,  -1},
+    {  1447,  1448,  1581,  1583,  -1,  -1},
+    {  1448,  1449,  1582,  1584,  -1,  -1},
+    {  1449,  1450,  1583,  1585,  -1,  -1},
+    {  1450,  1451,  1584,  1586,  -1,  -1},
+    {  1451,  1452,  1585,  1587,  -1,  -1},
+    {  1452,  1453,  1586,  1588,  -1,  -1},
+    {  1453,  1587,  1589,  -1,  -1,  -1},
+    {  1453,  1454,  1588,  1590,  -1,  -1},
+    {  1454,  1455,  1589,  1591,  -1,  -1},
+    {  1455,  1456,  1590,  1592,  -1,  -1},
+    {  1456,  1457,  1591,  1593,  -1,  -1},
+    {  1457,  1458,  1592,  1594,  -1,  -1},
+    {  1458,  1459,  1593,  1595,  -1,  -1},
+    {  1459,  1460,  1594,  1596,  -1,  -1},
+    {  1460,  1461,  1595,  1597,  -1,  -1},
+    {  1461,  1462,  1596,  1598,  -1,  -1},
+    {  1462,  1463,  1597,  1599,  -1,  -1},
+    {  1463,  1464,  1598,  1600,  -1,  -1},
+    {  1464,  1465,  1599,  1601,  -1,  -1}, // 1600
+    {  1465,  1466,  1600,  1602,  -1,  -1},
+    {  1466,  1467,  1601,  1603,  -1,  -1},
+    {  1467,  1468,  1602,  1604,  -1,  -1},
+    {  1468,  1469,  1603,  1605,  -1,  -1},
+    {  1469,  1470,  1604,  1606,  -1,  -1},
+    {  1470,  1471,  1605,  1607,  -1,  -1},
+    {  1471,  1472,  1606,  1608,  -1,  -1},
+    {  1472,  1473,  1607,  1609,  -1,  -1},
+    {  1473,  1474,  1608,  1610,  -1,  -1},
+    {  1474,  1475,  1609,  1611,  -1,  -1},
+    {  1475,  1610,  1612,  -1,  -1,  -1},
+    {  1475,  1476,  1611,  1613,  -1,  -1},
+    {  1476,  1477,  1612,  1614,  -1,  -1},
+    {  1477,  1478,  1613,  1615,  -1,  -1},
+    {  1478,  1479,  1614,  1616,  -1,  -1},
+    {  1479,  1480,  1615,  1617,  -1,  -1},
+    {  1480,  1481,  1616,  1618,  -1,  -1},
+    {  1481,  1482,  1617,  1619,  -1,  -1},
+    {  1482,  1483,  1618,  1620,  -1,  -1},
+    {  1483,  1484,  1619,  1621,  -1,  -1}, // 1620
+    {  1484,  1485,  1620,  1622,  -1,  -1},
+    {  1485,  1486,  1621,  1623,  -1,  -1},
+    {  1486,  1487,  1622,  1624,  -1,  -1},
+    {  1487,  1488,  1623,  1625,  -1,  -1},
+    {  1488,  1489,  1624,  1626,  -1,  -1},
+    {  1489,  1490,  1625,  1627,  -1,  -1},
+    {  1490,  1491,  1626,  1628,  -1,  -1},
+    {  1491,  1492,  1627,  1629,  -1,  -1},
+    {  1492,  1493,  1628,  1630,  -1,  -1},
+    {  1493,  1494,  1629,  1631,  -1,  -1},
+    {  1494,  1495,  1630,  1632,  -1,  -1},
+    {  1495,  1496,  1631,  1633,  -1,  -1},
+    {  1496,  1497,  1632,  1634,  -1,  -1},
+    {  1497,  1633,  1635,  1717,  -1,  -1},
+    {  1497,  1498,  1634,  1636,  -1,  -1},
+    {  1498,  1499,  1635,  1637,  1718,  -1},
+    {  1499,  1500,  1636,  1638,  -1,  -1},
+    {  1500,  1501,  1637,  1639,  1719,  -1},
+    {  1501,  1502,  1638,  1640,  -1,  -1},
+    {  1502,  1503,  1639,  1641,  1720,  -1}, // 1640
+    {  1503,  1504,  1640,  1642,  -1,  -1},
+    {  1504,  1505,  1641,  1643,  1721,  -1},
+    {  1505,  1506,  1642,  1644,  -1,  -1},
+    {  1506,  1507,  1643,  1645,  1722,  -1},
+    {  1507,  1508,  1644,  1646,  -1,  -1},
+    {  1508,  1509,  1645,  1647,  1723,  -1},
+    {  1509,  1510,  1646,  1648,  -1,  -1},
+    {  1510,  1511,  1647,  1649,  1724,  -1},
+    {  1511,  1512,  1648,  1650,  -1,  -1},
+    {  1512,  1513,  1649,  1651,  1725,  -1},
+    {  1513,  1514,  1650,  1652,  -1,  -1},
+    {  1514,  1515,  1651,  1653,  1726,  -1},
+    {  1515,  1516,  1652,  1654,  -1,  -1},
+    {  1516,  1517,  1653,  1655,  1727,  -1},
+    {  1517,  1518,  1654,  1656,  -1,  -1},
+    {  1387,  1518,  1519,  1655,  1728,  -1},
+    {  1658,  1729,  1730,  -1,  -1,  -1},
+    {  1657,  1659,  1730,  1731,  -1,  -1},
+    {  1658,  1660,  1731,  1732,  -1,  -1},
+    {  1659,  1661,  1732,  1733,  -1,  -1}, // 1660
+    {  1660,  1662,  1733,  1734,  -1,  -1},
+    {  1661,  1663,  1734,  1735,  -1,  -1},
+    {  1662,  1664,  1735,  1736,  -1,  -1},
+    {  1663,  1665,  1736,  1737,  -1,  -1},
+    {  1664,  1666,  1737,  1738,  -1,  -1},
+    {  1665,  1667,  1738,  1739,  -1,  -1},
+    {  1666,  1668,  1739,  1740,  -1,  -1},
+    {  1667,  1740,  1741,  -1,  -1,  -1},
+    {  1670,  1742,  1743,  -1,  -1,  -1},
+    {  1669,  1671,  1743,  1744,  -1,  -1},
+    {  1670,  1672,  1744,  1745,  -1,  -1},
+    {  1671,  1673,  1745,  1746,  -1,  -1},
+    {  1672,  1674,  1746,  1747,  -1,  -1},
+    {  1673,  1675,  1747,  1748,  -1,  -1},
+    {  1674,  1676,  1748,  1749,  -1,  -1},
+    {  1675,  1677,  1749,  1750,  -1,  -1},
+    {  1676,  1678,  1750,  1751,  -1,  -1},
+    {  1677,  1679,  1751,  1752,  -1,  -1},
+    {  1678,  1680,  1752,  1753,  -1,  -1},
+    {  1679,  1753,  1754,  -1,  -1,  -1}, // 1680
+    {  1682,  1755,  1756,  -1,  -1,  -1},
+    {  1681,  1683,  1756,  1757,  -1,  -1},
+    {  1682,  1684,  1757,  1758,  -1,  -1},
+    {  1683,  1685,  1758,  1759,  -1,  -1},
+    {  1684,  1686,  1759,  1760,  -1,  -1},
+    {  1685,  1687,  1760,  1761,  -1,  -1},
+    {  1686,  1688,  1761,  1762,  -1,  -1},
+    {  1687,  1689,  1762,  1763,  -1,  -1},
+    {  1688,  1690,  1763,  1764,  -1,  -1},
+    {  1689,  1691,  1764,  1765,  -1,  -1},
+    {  1690,  1692,  1765,  1766,  -1,  -1},
+    {  1691,  1766,  1767,  -1,  -1,  -1},
+    {  1694,  1768,  1769,  -1,  -1,  -1},
+    {  1693,  1695,  1769,  1770,  -1,  -1},
+    {  1694,  1696,  1770,  1771,  -1,  -1},
+    {  1695,  1697,  1771,  1772,  -1,  -1},
+    {  1696,  1698,  1772,  1773,  -1,  -1},
+    {  1697,  1699,  1773,  1774,  -1,  -1},
+    {  1698,  1700,  1774,  1775,  -1,  -1},
+    {  1699,  1701,  1775,  1776,  -1,  -1}, // 1700
+    {  1700,  1702,  1776,  1777,  -1,  -1},
+    {  1701,  1703,  1777,  1778,  -1,  -1},
+    {  1702,  1704,  1778,  1779,  -1,  -1},
+    {  1703,  1779,  1780,  -1,  -1,  -1},
+    {  1706,  1781,  1782,  -1,  -1,  -1},
+    {  1705,  1707,  1782,  1783,  -1,  -1},
+    {  1706,  1708,  1783,  1784,  -1,  -1},
+    {  1707,  1709,  1784,  1785,  -1,  -1},
+    {  1708,  1710,  1785,  1786,  -1,  -1},
+    {  1709,  1711,  1786,  1787,  -1,  -1},
+    {  1710,  1712,  1787,  1788,  -1,  -1},
+    {  1711,  1713,  1788,  1789,  -1,  -1},
+    {  1712,  1714,  1789,  1790,  -1,  -1},
+    {  1713,  1715,  1790,  1791,  -1,  -1},
+    {  1714,  1716,  1791,  1792,  -1,  -1},
+    {  1715,  1792,  1793,  -1,  -1,  -1},
+    {  1718,  1794,  1795,  -1,  -1,  -1},
+    {  1717,  1719,  1795,  1796,  -1,  -1},
+    {  1718,  1720,  1796,  1797,  -1,  -1},
+    {  1719,  1721,  1797,  1798,  -1,  -1}, // 1720
+    {  1720,  1722,  1798,  1799,  -1,  -1},
+    {  1721,  1723,  1799,  1800,  -1,  -1},
+    {  1722,  1724,  1800,  1801,  -1,  -1},
+    {  1723,  1725,  1801,  1802,  -1,  -1},
+    {  1724,  1726,  1802,  1803,  -1,  -1},
+    {  1725,  1727,  1803,  1804,  -1,  -1},
+    {  1726,  1728,  1804,  1805,  -1,  -1},
+    {  1727,  1805,  1806,  -1,  -1,  -1},
+    {  1657,  1730,  1807,  1808,  -1,  -1},
+    {  1657,  1658,  1729,  1731,  1808,  1809},
+    {  1658,  1659,  1730,  1732,  1809,  1810},
+    {  1659,  1660,  1731,  1733,  1810,  1811},
+    {  1660,  1661,  1732,  1734,  1811,  1812},
+    {  1661,  1662,  1733,  1735,  1812,  1813},
+    {  1662,  1663,  1734,  1736,  1813,  1814},
+    {  1663,  1664,  1735,  1737,  1814,  1815},
+    {  1664,  1665,  1736,  1738,  1815,  1816},
+    {  1665,  1666,  1737,  1739,  1816,  1817},
+    {  1666,  1667,  1738,  1740,  1817,  1818},
+    {  1667,  1668,  1739,  1741,  1818,  1819}, // 1740
+    {  1668,  1740,  1819,  1820,  -1,  -1},
+    {  1669,  1743,  1821,  1822,  -1,  -1},
+    {  1669,  1670,  1742,  1744,  1822,  1823},
+    {  1670,  1671,  1743,  1745,  1823,  1824},
+    {  1671,  1672,  1744,  1746,  1824,  1825},
+    {  1672,  1673,  1745,  1747,  1825,  1826},
+    {  1673,  1674,  1746,  1748,  1826,  1827},
+    {  1674,  1675,  1747,  1749,  1827,  1828},
+    {  1675,  1676,  1748,  1750,  1828,  1829},
+    {  1676,  1677,  1749,  1751,  1829,  1830},
+    {  1677,  1678,  1750,  1752,  1830,  1831},
+    {  1678,  1679,  1751,  1753,  1831,  1832},
+    {  1679,  1680,  1752,  1754,  1832,  1833},
+    {  1680,  1753,  1833,  1834,  -1,  -1},
+    {  1681,  1756,  1835,  1836,  -1,  -1},
+    {  1681,  1682,  1755,  1757,  1836,  1837},
+    {  1682,  1683,  1756,  1758,  1837,  1838},
+    {  1683,  1684,  1757,  1759,  1838,  1839},
+    {  1684,  1685,  1758,  1760,  1839,  1840},
+    {  1685,  1686,  1759,  1761,  1840,  1841}, // 1760
+    {  1686,  1687,  1760,  1762,  1841,  1842},
+    {  1687,  1688,  1761,  1763,  1842,  1843},
+    {  1688,  1689,  1762,  1764,  1843,  1844},
+    {  1689,  1690,  1763,  1765,  1844,  1845},
+    {  1690,  1691,  1764,  1766,  1845,  1846},
+    {  1691,  1692,  1765,  1767,  1846,  1847},
+    {  1692,  1766,  1847,  1848,  -1,  -1},
+    {  1693,  1769,  1849,  1850,  -1,  -1},
+    {  1693,  1694,  1768,  1770,  1850,  1851},
+    {  1694,  1695,  1769,  1771,  1851,  1852},
+    {  1695,  1696,  1770,  1772,  1852,  1853},
+    {  1696,  1697,  1771,  1773,  1853,  1854},
+    {  1697,  1698,  1772,  1774,  1854,  1855},
+    {  1698,  1699,  1773,  1775,  1855,  1856},
+    {  1699,  1700,  1774,  1776,  1856,  1857},
+    {  1700,  1701,  1775,  1777,  1857,  1858},
+    {  1701,  1702,  1776,  1778,  1858,  1859},
+    {  1702,  1703,  1777,  1779,  1859,  1860},
+    {  1703,  1704,  1778,  1780,  1860,  1861},
+    {  1704,  1779,  1861,  1862,  -1,  -1}, // 1780
+    {  1705,  1782,  1863,  1864,  -1,  -1},
+    {  1705,  1706,  1781,  1783,  1864,  1865},
+    {  1706,  1707,  1782,  1784,  1865,  1866},
+    {  1707,  1708,  1783,  1785,  1866,  1867},
+    {  1708,  1709,  1784,  1786,  1867,  1868},
+    {  1709,  1710,  1785,  1787,  1868,  1869},
+    {  1710,  1711,  1786,  1788,  1869,  1870},
+    {  1711,  1712,  1787,  1789,  1870,  1871},
+    {  1712,  1713,  1788,  1790,  1871,  1872},
+    {  1713,  1714,  1789,  1791,  1872,  1873},
+    {  1714,  1715,  1790,  1792,  1873,  1874},
+    {  1715,  1716,  1791,  1793,  1874,  1875},
+    {  1716,  1792,  1875,  1876,  -1,  -1},
+    {  1717,  1795,  1877,  1878,  -1,  -1},
+    {  1717,  1718,  1794,  1796,  1878,  1879},
+    {  1718,  1719,  1795,  1797,  1879,  1880},
+    {  1719,  1720,  1796,  1798,  1880,  1881},
+    {  1720,  1721,  1797,  1799,  1881,  1882},
+    {  1721,  1722,  1798,  1800,  1882,  1883},
+    {  1722,  1723,  1799,  1801,  1883,  1884}, // 1800
+    {  1723,  1724,  1800,  1802,  1884,  1885},
+    {  1724,  1725,  1801,  1803,  1885,  1886},
+    {  1725,  1726,  1802,  1804,  1886,  1887},
+    {  1726,  1727,  1803,  1805,  1887,  1888},
+    {  1727,  1728,  1804,  1806,  1888,  1889},
+    {  1728,  1805,  1889,  1890,  -1,  -1},
+    {  1729,  1808,  1891,  1892,  -1,  -1},
+    {  1729,  1730,  1807,  1809,  1892,  1893},
+    {  1730,  1731,  1808,  1810,  1893,  1894},
+    {  1731,  1732,  1809,  1811,  1894,  1895},
+    {  1732,  1733,  1810,  1812,  1895,  1896},
+    {  1733,  1734,  1811,  1813,  1896,  1897},
+    {  1734,  1735,  1812,  1814,  1897,  1898},
+    {  1735,  1736,  1813,  1815,  1898,  1899},
+    {  1736,  1737,  1814,  1816,  1899,  1900},
+    {  1737,  1738,  1815,  1817,  1900,  1901},
+    {  1738,  1739,  1816,  1818,  1901,  1902},
+    {  1739,  1740,  1817,  1819,  1902,  1903},
+    {  1740,  1741,  1818,  1820,  1903,  1904},
+    {  1741,  1819,  1904,  1905,  -1,  -1}, // 1820
+    {  1742,  1822,  1906,  1907,  -1,  -1},
+    {  1742,  1743,  1821,  1823,  1907,  1908},
+    {  1743,  1744,  1822,  1824,  1908,  1909},
+    {  1744,  1745,  1823,  1825,  1909,  1910},
+    {  1745,  1746,  1824,  1826,  1910,  1911},
+    {  1746,  1747,  1825,  1827,  1911,  1912},
+    {  1747,  1748,  1826,  1828,  1912,  1913},
+    {  1748,  1749,  1827,  1829,  1913,  1914},
+    {  1749,  1750,  1828,  1830,  1914,  1915},
+    {  1750,  1751,  1829,  1831,  1915,  1916},
+    {  1751,  1752,  1830,  1832,  1916,  1917},
+    {  1752,  1753,  1831,  1833,  1917,  1918},
+    {  1753,  1754,  1832,  1834,  1918,  1919},
+    {  1754,  1833,  1919,  1920,  -1,  -1},
+    {  1755,  1836,  1921,  1922,  -1,  -1},
+    {  1755,  1756,  1835,  1837,  1922,  1923},
+    {  1756,  1757,  1836,  1838,  1923,  1924},
+    {  1757,  1758,  1837,  1839,  1924,  1925},
+    {  1758,  1759,  1838,  1840,  1925,  1926},
+    {  1759,  1760,  1839,  1841,  1926,  1927}, // 1840
+    {  1760,  1761,  1840,  1842,  1927,  1928},
+    {  1761,  1762,  1841,  1843,  1928,  1929},
+    {  1762,  1763,  1842,  1844,  1929,  1930},
+    {  1763,  1764,  1843,  1845,  1930,  1931},
+    {  1764,  1765,  1844,  1846,  1931,  1932},
+    {  1765,  1766,  1845,  1847,  1932,  1933},
+    {  1766,  1767,  1846,  1848,  1933,  1934},
+    {  1767,  1847,  1934,  1935,  -1,  -1},
+    {  1768,  1850,  1936,  1937,  -1,  -1},
+    {  1768,  1769,  1849,  1851,  1937,  1938},
+    {  1769,  1770,  1850,  1852,  1938,  1939},
+    {  1770,  1771,  1851,  1853,  1939,  1940},
+    {  1771,  1772,  1852,  1854,  1940,  1941},
+    {  1772,  1773,  1853,  1855,  1941,  1942},
+    {  1773,  1774,  1854,  1856,  1942,  1943},
+    {  1774,  1775,  1855,  1857,  1943,  1944},
+    {  1775,  1776,  1856,  1858,  1944,  1945},
+    {  1776,  1777,  1857,  1859,  1945,  1946},
+    {  1777,  1778,  1858,  1860,  1946,  1947},
+    {  1778,  1779,  1859,  1861,  1947,  1948}, // 1860
+    {  1779,  1780,  1860,  1862,  1948,  1949},
+    {  1780,  1861,  1949,  1950,  -1,  -1},
+    {  1781,  1864,  1951,  1952,  -1,  -1},
+    {  1781,  1782,  1863,  1865,  1952,  1953},
+    {  1782,  1783,  1864,  1866,  1953,  1954},
+    {  1783,  1784,  1865,  1867,  1954,  1955},
+    {  1784,  1785,  1866,  1868,  1955,  1956},
+    {  1785,  1786,  1867,  1869,  1956,  1957},
+    {  1786,  1787,  1868,  1870,  1957,  1958},
+    {  1787,  1788,  1869,  1871,  1958,  1959},
+    {  1788,  1789,  1870,  1872,  1959,  1960},
+    {  1789,  1790,  1871,  1873,  1960,  1961},
+    {  1790,  1791,  1872,  1874,  1961,  1962},
+    {  1791,  1792,  1873,  1875,  1962,  1963},
+    {  1792,  1793,  1874,  1876,  1963,  1964},
+    {  1793,  1875,  1964,  1965,  -1,  -1},
+    {  1794,  1878,  1966,  1967,  -1,  -1},
+    {  1794,  1795,  1877,  1879,  1967,  1968},
+    {  1795,  1796,  1878,  1880,  1968,  1969},
+    {  1796,  1797,  1879,  1881,  1969,  1970}, // 1880
+    {  1797,  1798,  1880,  1882,  1970,  1971},
+    {  1798,  1799,  1881,  1883,  1971,  1972},
+    {  1799,  1800,  1882,  1884,  1972,  1973},
+    {  1800,  1801,  1883,  1885,  1973,  1974},
+    {  1801,  1802,  1884,  1886,  1974,  1975},
+    {  1802,  1803,  1885,  1887,  1975,  1976},
+    {  1803,  1804,  1886,  1888,  1976,  1977},
+    {  1804,  1805,  1887,  1889,  1977,  1978},
+    {  1805,  1806,  1888,  1890,  1978,  1979},
+    {  1806,  1889,  1979,  1980,  -1,  -1},
+    {  1807,  1892,  1981,  1982,  -1,  -1},
+    {  1807,  1808,  1891,  1893,  1982,  1983},
+    {  1808,  1809,  1892,  1894,  1983,  1984},
+    {  1809,  1810,  1893,  1895,  1984,  1985},
+    {  1810,  1811,  1894,  1896,  1985,  1986},
+    {  1811,  1812,  1895,  1897,  1986,  1987},
+    {  1812,  1813,  1896,  1898,  1987,  1988},
+    {  1813,  1814,  1897,  1899,  1988,  1989},
+    {  1814,  1815,  1898,  1900,  1989,  1990},
+    {  1815,  1816,  1899,  1901,  1990,  1991}, // 1900
+    {  1816,  1817,  1900,  1902,  1991,  1992},
+    {  1817,  1818,  1901,  1903,  1992,  1993},
+    {  1818,  1819,  1902,  1904,  1993,  1994},
+    {  1819,  1820,  1903,  1905,  1994,  1995},
+    {  1820,  1904,  1995,  1996,  -1,  -1},
+    {  1821,  1907,  1997,  1998,  -1,  -1},
+    {  1821,  1822,  1906,  1908,  1998,  1999},
+    {  1822,  1823,  1907,  1909,  1999,  2000},
+    {  1823,  1824,  1908,  1910,  2000,  2001},
+    {  1824,  1825,  1909,  1911,  2001,  2002},
+    {  1825,  1826,  1910,  1912,  2002,  2003},
+    {  1826,  1827,  1911,  1913,  2003,  2004},
+    {  1827,  1828,  1912,  1914,  2004,  2005},
+    {  1828,  1829,  1913,  1915,  2005,  2006},
+    {  1829,  1830,  1914,  1916,  2006,  2007},
+    {  1830,  1831,  1915,  1917,  2007,  2008},
+    {  1831,  1832,  1916,  1918,  2008,  2009},
+    {  1832,  1833,  1917,  1919,  2009,  2010},
+    {  1833,  1834,  1918,  1920,  2010,  2011},
+    {  1834,  1919,  2011,  2012,  -1,  -1}, // 1920
+    {  1835,  1922,  2013,  2014,  -1,  -1},
+    {  1835,  1836,  1921,  1923,  2014,  2015},
+    {  1836,  1837,  1922,  1924,  2015,  2016},
+    {  1837,  1838,  1923,  1925,  2016,  2017},
+    {  1838,  1839,  1924,  1926,  2017,  2018},
+    {  1839,  1840,  1925,  1927,  2018,  2019},
+    {  1840,  1841,  1926,  1928,  2019,  2020},
+    {  1841,  1842,  1927,  1929,  2020,  2021},
+    {  1842,  1843,  1928,  1930,  2021,  2022},
+    {  1843,  1844,  1929,  1931,  2022,  2023},
+    {  1844,  1845,  1930,  1932,  2023,  2024},
+    {  1845,  1846,  1931,  1933,  2024,  2025},
+    {  1846,  1847,  1932,  1934,  2025,  2026},
+    {  1847,  1848,  1933,  1935,  2026,  2027},
+    {  1848,  1934,  2027,  2028,  -1,  -1},
+    {  1849,  1937,  2029,  2030,  -1,  -1},
+    {  1849,  1850,  1936,  1938,  2030,  2031},
+    {  1850,  1851,  1937,  1939,  2031,  2032},
+    {  1851,  1852,  1938,  1940,  2032,  2033},
+    {  1852,  1853,  1939,  1941,  2033,  2034}, // 1940
+    {  1853,  1854,  1940,  1942,  2034,  2035},
+    {  1854,  1855,  1941,  1943,  2035,  2036},
+    {  1855,  1856,  1942,  1944,  2036,  2037},
+    {  1856,  1857,  1943,  1945,  2037,  2038},
+    {  1857,  1858,  1944,  1946,  2038,  2039},
+    {  1858,  1859,  1945,  1947,  2039,  2040},
+    {  1859,  1860,  1946,  1948,  2040,  2041},
+    {  1860,  1861,  1947,  1949,  2041,  2042},
+    {  1861,  1862,  1948,  1950,  2042,  2043},
+    {  1862,  1949,  2043,  2044,  -1,  -1},
+    {  1863,  1952,  2045,  2046,  -1,  -1},
+    {  1863,  1864,  1951,  1953,  2046,  2047},
+    {  1864,  1865,  1952,  1954,  2047,  2048},
+    {  1865,  1866,  1953,  1955,  2048,  2049},
+    {  1866,  1867,  1954,  1956,  2049,  2050},
+    {  1867,  1868,  1955,  1957,  2050,  2051},
+    {  1868,  1869,  1956,  1958,  2051,  2052},
+    {  1869,  1870,  1957,  1959,  2052,  2053},
+    {  1870,  1871,  1958,  1960,  2053,  2054},
+    {  1871,  1872,  1959,  1961,  2054,  2055}, // 1960
+    {  1872,  1873,  1960,  1962,  2055,  2056},
+    {  1873,  1874,  1961,  1963,  2056,  2057},
+    {  1874,  1875,  1962,  1964,  2057,  2058},
+    {  1875,  1876,  1963,  1965,  2058,  2059},
+    {  1876,  1964,  2059,  2060,  -1,  -1},
+    {  1877,  1967,  2061,  2062,  -1,  -1},
+    {  1877,  1878,  1966,  1968,  2062,  2063},
+    {  1878,  1879,  1967,  1969,  2063,  2064},
+    {  1879,  1880,  1968,  1970,  2064,  2065},
+    {  1880,  1881,  1969,  1971,  2065,  2066},
+    {  1881,  1882,  1970,  1972,  2066,  2067},
+    {  1882,  1883,  1971,  1973,  2067,  2068},
+    {  1883,  1884,  1972,  1974,  2068,  2069},
+    {  1884,  1885,  1973,  1975,  2069,  2070},
+    {  1885,  1886,  1974,  1976,  2070,  2071},
+    {  1886,  1887,  1975,  1977,  2071,  2072},
+    {  1887,  1888,  1976,  1978,  2072,  2073},
+    {  1888,  1889,  1977,  1979,  2073,  2074},
+    {  1889,  1890,  1978,  1980,  2074,  2075},
+    {  1890,  1979,  2075,  2076,  -1,  -1}, // 1980
+    {  1891,  1982,  2077,  2078,  -1,  -1},
+    {  1891,  1892,  1981,  1983,  2078,  2079},
+    {  1892,  1893,  1982,  1984,  2079,  2080},
+    {  1893,  1894,  1983,  1985,  2080,  2081},
+    {  1894,  1895,  1984,  1986,  2081,  2082},
+    {  1895,  1896,  1985,  1987,  2082,  2083},
+    {  1896,  1897,  1986,  1988,  2083,  2084},
+    {  1897,  1898,  1987,  1989,  2084,  2085},
+    {  1898,  1899,  1988,  1990,  2085,  2086},
+    {  1899,  1900,  1989,  1991,  2086,  2087},
+    {  1900,  1901,  1990,  1992,  2087,  2088},
+    {  1901,  1902,  1991,  1993,  2088,  2089},
+    {  1902,  1903,  1992,  1994,  2089,  2090},
+    {  1903,  1904,  1993,  1995,  2090,  2091},
+    {  1904,  1905,  1994,  1996,  2091,  2092},
+    {  1905,  1995,  2092,  2093,  -1,  -1},
+    {  1906,  1998,  2094,  2095,  -1,  -1},
+    {  1906,  1907,  1997,  1999,  2095,  2096},
+    {  1907,  1908,  1998,  2000,  2096,  2097},
+    {  1908,  1909,  1999,  2001,  2097,  2098}, // 2000
+    {  1909,  1910,  2000,  2002,  2098,  2099},
+    {  1910,  1911,  2001,  2003,  2099,  2100},
+    {  1911,  1912,  2002,  2004,  2100,  2101},
+    {  1912,  1913,  2003,  2005,  2101,  2102},
+    {  1913,  1914,  2004,  2006,  2102,  2103},
+    {  1914,  1915,  2005,  2007,  2103,  2104},
+    {  1915,  1916,  2006,  2008,  2104,  2105},
+    {  1916,  1917,  2007,  2009,  2105,  2106},
+    {  1917,  1918,  2008,  2010,  2106,  2107},
+    {  1918,  1919,  2009,  2011,  2107,  2108},
+    {  1919,  1920,  2010,  2012,  2108,  2109},
+    {  1920,  2011,  2109,  2110,  -1,  -1},
+    {  1921,  2014,  2111,  2112,  -1,  -1},
+    {  1921,  1922,  2013,  2015,  2112,  2113},
+    {  1922,  1923,  2014,  2016,  2113,  2114},
+    {  1923,  1924,  2015,  2017,  2114,  2115},
+    {  1924,  1925,  2016,  2018,  2115,  2116},
+    {  1925,  1926,  2017,  2019,  2116,  2117},
+    {  1926,  1927,  2018,  2020,  2117,  2118},
+    {  1927,  1928,  2019,  2021,  2118,  2119}, // 2020
+    {  1928,  1929,  2020,  2022,  2119,  2120},
+    {  1929,  1930,  2021,  2023,  2120,  2121},
+    {  1930,  1931,  2022,  2024,  2121,  2122},
+    {  1931,  1932,  2023,  2025,  2122,  2123},
+    {  1932,  1933,  2024,  2026,  2123,  2124},
+    {  1933,  1934,  2025,  2027,  2124,  2125},
+    {  1934,  1935,  2026,  2028,  2125,  2126},
+    {  1935,  2027,  2126,  2127,  -1,  -1},
+    {  1936,  2030,  2128,  2129,  -1,  -1},
+    {  1936,  1937,  2029,  2031,  2129,  2130},
+    {  1937,  1938,  2030,  2032,  2130,  2131},
+    {  1938,  1939,  2031,  2033,  2131,  2132},
+    {  1939,  1940,  2032,  2034,  2132,  2133},
+    {  1940,  1941,  2033,  2035,  2133,  2134},
+    {  1941,  1942,  2034,  2036,  2134,  2135},
+    {  1942,  1943,  2035,  2037,  2135,  2136},
+    {  1943,  1944,  2036,  2038,  2136,  2137},
+    {  1944,  1945,  2037,  2039,  2137,  2138},
+    {  1945,  1946,  2038,  2040,  2138,  2139},
+    {  1946,  1947,  2039,  2041,  2139,  2140}, // 2040
+    {  1947,  1948,  2040,  2042,  2140,  2141},
+    {  1948,  1949,  2041,  2043,  2141,  2142},
+    {  1949,  1950,  2042,  2044,  2142,  2143},
+    {  1950,  2043,  2143,  2144,  -1,  -1},
+    {  1951,  2046,  2145,  2146,  -1,  -1},
+    {  1951,  1952,  2045,  2047,  2146,  2147},
+    {  1952,  1953,  2046,  2048,  2147,  2148},
+    {  1953,  1954,  2047,  2049,  2148,  2149},
+    {  1954,  1955,  2048,  2050,  2149,  2150},
+    {  1955,  1956,  2049,  2051,  2150,  2151},
+    {  1956,  1957,  2050,  2052,  2151,  2152},
+    {  1957,  1958,  2051,  2053,  2152,  2153},
+    {  1958,  1959,  2052,  2054,  2153,  2154},
+    {  1959,  1960,  2053,  2055,  2154,  2155},
+    {  1960,  1961,  2054,  2056,  2155,  2156},
+    {  1961,  1962,  2055,  2057,  2156,  2157},
+    {  1962,  1963,  2056,  2058,  2157,  2158},
+    {  1963,  1964,  2057,  2059,  2158,  2159},
+    {  1964,  1965,  2058,  2060,  2159,  2160},
+    {  1965,  2059,  2160,  2161,  -1,  -1}, // 2060
+    {  1966,  2062,  2162,  2163,  -1,  -1},
+    {  1966,  1967,  2061,  2063,  2163,  2164},
+    {  1967,  1968,  2062,  2064,  2164,  2165},
+    {  1968,  1969,  2063,  2065,  2165,  2166},
+    {  1969,  1970,  2064,  2066,  2166,  2167},
+    {  1970,  1971,  2065,  2067,  2167,  2168},
+    {  1971,  1972,  2066,  2068,  2168,  2169},
+    {  1972,  1973,  2067,  2069,  2169,  2170},
+    {  1973,  1974,  2068,  2070,  2170,  2171},
+    {  1974,  1975,  2069,  2071,  2171,  2172},
+    {  1975,  1976,  2070,  2072,  2172,  2173},
+    {  1976,  1977,  2071,  2073,  2173,  2174},
+    {  1977,  1978,  2072,  2074,  2174,  2175},
+    {  1978,  1979,  2073,  2075,  2175,  2176},
+    {  1979,  1980,  2074,  2076,  2176,  2177},
+    {  1980,  2075,  2177,  2178,  -1,  -1},
+    {  1981,  2078,  2179,  2180,  -1,  -1},
+    {  1981,  1982,  2077,  2079,  2180,  2181},
+    {  1982,  1983,  2078,  2080,  2181,  2182},
+    {  1983,  1984,  2079,  2081,  2182,  2183}, // 2080
+    {  1984,  1985,  2080,  2082,  2183,  2184},
+    {  1985,  1986,  2081,  2083,  2184,  2185},
+    {  1986,  1987,  2082,  2084,  2185,  2186},
+    {  1987,  1988,  2083,  2085,  2186,  2187},
+    {  1988,  1989,  2084,  2086,  2187,  2188},
+    {  1989,  1990,  2085,  2087,  2188,  2189},
+    {  1990,  1991,  2086,  2088,  2189,  2190},
+    {  1991,  1992,  2087,  2089,  2190,  2191},
+    {  1992,  1993,  2088,  2090,  2191,  2192},
+    {  1993,  1994,  2089,  2091,  2192,  2193},
+    {  1994,  1995,  2090,  2092,  2193,  2194},
+    {  1995,  1996,  2091,  2093,  2194,  2195},
+    {  1996,  2092,  2195,  2196,  -1,  -1},
+    {  1997,  2095,  2197,  2198,  -1,  -1},
+    {  1997,  1998,  2094,  2096,  2198,  2199},
+    {  1998,  1999,  2095,  2097,  2199,  2200},
+    {  1999,  2000,  2096,  2098,  2200,  2201},
+    {  2000,  2001,  2097,  2099,  2201,  2202},
+    {  2001,  2002,  2098,  2100,  2202,  2203},
+    {  2002,  2003,  2099,  2101,  2203,  2204}, // 2100
+    {  2003,  2004,  2100,  2102,  2204,  2205},
+    {  2004,  2005,  2101,  2103,  2205,  2206},
+    {  2005,  2006,  2102,  2104,  2206,  2207},
+    {  2006,  2007,  2103,  2105,  2207,  2208},
+    {  2007,  2008,  2104,  2106,  2208,  2209},
+    {  2008,  2009,  2105,  2107,  2209,  2210},
+    {  2009,  2010,  2106,  2108,  2210,  2211},
+    {  2010,  2011,  2107,  2109,  2211,  2212},
+    {  2011,  2012,  2108,  2110,  2212,  2213},
+    {  2012,  2109,  2213,  2214,  -1,  -1},
+    {  2013,  2112,  2215,  2216,  -1,  -1},
+    {  2013,  2014,  2111,  2113,  2216,  2217},
+    {  2014,  2015,  2112,  2114,  2217,  2218},
+    {  2015,  2016,  2113,  2115,  2218,  2219},
+    {  2016,  2017,  2114,  2116,  2219,  2220},
+    {  2017,  2018,  2115,  2117,  2220,  2221},
+    {  2018,  2019,  2116,  2118,  2221,  2222},
+    {  2019,  2020,  2117,  2119,  2222,  2223},
+    {  2020,  2021,  2118,  2120,  2223,  2224},
+    {  2021,  2022,  2119,  2121,  2224,  2225}, // 2120
+    {  2022,  2023,  2120,  2122,  2225,  2226},
+    {  2023,  2024,  2121,  2123,  2226,  2227},
+    {  2024,  2025,  2122,  2124,  2227,  2228},
+    {  2025,  2026,  2123,  2125,  2228,  2229},
+    {  2026,  2027,  2124,  2126,  2229,  2230},
+    {  2027,  2028,  2125,  2127,  2230,  2231},
+    {  2028,  2126,  2231,  2232,  -1,  -1},
+    {  2029,  2129,  2233,  2234,  -1,  -1},
+    {  2029,  2030,  2128,  2130,  2234,  2235},
+    {  2030,  2031,  2129,  2131,  2235,  2236},
+    {  2031,  2032,  2130,  2132,  2236,  2237},
+    {  2032,  2033,  2131,  2133,  2237,  2238},
+    {  2033,  2034,  2132,  2134,  2238,  2239},
+    {  2034,  2035,  2133,  2135,  2239,  2240},
+    {  2035,  2036,  2134,  2136,  2240,  2241},
+    {  2036,  2037,  2135,  2137,  2241,  2242},
+    {  2037,  2038,  2136,  2138,  2242,  2243},
+    {  2038,  2039,  2137,  2139,  2243,  2244},
+    {  2039,  2040,  2138,  2140,  2244,  2245},
+    {  2040,  2041,  2139,  2141,  2245,  2246}, // 2140
+    {  2041,  2042,  2140,  2142,  2246,  2247},
+    {  2042,  2043,  2141,  2143,  2247,  2248},
+    {  2043,  2044,  2142,  2144,  2248,  2249},
+    {  2044,  2143,  2249,  2250,  -1,  -1},
+    {  2045,  2146,  2251,  2252,  -1,  -1},
+    {  2045,  2046,  2145,  2147,  2252,  2253},
+    {  2046,  2047,  2146,  2148,  2253,  2254},
+    {  2047,  2048,  2147,  2149,  2254,  2255},
+    {  2048,  2049,  2148,  2150,  2255,  2256},
+    {  2049,  2050,  2149,  2151,  2256,  2257},
+    {  2050,  2051,  2150,  2152,  2257,  2258},
+    {  2051,  2052,  2151,  2153,  2258,  2259},
+    {  2052,  2053,  2152,  2154,  2259,  2260},
+    {  2053,  2054,  2153,  2155,  2260,  2261},
+    {  2054,  2055,  2154,  2156,  2261,  2262},
+    {  2055,  2056,  2155,  2157,  2262,  2263},
+    {  2056,  2057,  2156,  2158,  2263,  2264},
+    {  2057,  2058,  2157,  2159,  2264,  2265},
+    {  2058,  2059,  2158,  2160,  2265,  2266},
+    {  2059,  2060,  2159,  2161,  2266,  2267}, // 2160
+    {  2060,  2160,  2267,  2268,  -1,  -1},
+    {  2061,  2163,  2269,  2270,  -1,  -1},
+    {  2061,  2062,  2162,  2164,  2270,  2271},
+    {  2062,  2063,  2163,  2165,  2271,  2272},
+    {  2063,  2064,  2164,  2166,  2272,  2273},
+    {  2064,  2065,  2165,  2167,  2273,  2274},
+    {  2065,  2066,  2166,  2168,  2274,  2275},
+    {  2066,  2067,  2167,  2169,  2275,  2276},
+    {  2067,  2068,  2168,  2170,  2276,  2277},
+    {  2068,  2069,  2169,  2171,  2277,  2278},
+    {  2069,  2070,  2170,  2172,  2278,  2279},
+    {  2070,  2071,  2171,  2173,  2279,  2280},
+    {  2071,  2072,  2172,  2174,  2280,  2281},
+    {  2072,  2073,  2173,  2175,  2281,  2282},
+    {  2073,  2074,  2174,  2176,  2282,  2283},
+    {  2074,  2075,  2175,  2177,  2283,  2284},
+    {  2075,  2076,  2176,  2178,  2284,  2285},
+    {  2076,  2177,  2285,  2286,  -1,  -1},
+    {  2077,  2180,  2287,  2288,  -1,  -1},
+    {  2077,  2078,  2179,  2181,  2288,  2289}, // 2180
+    {  2078,  2079,  2180,  2182,  2289,  2290},
+    {  2079,  2080,  2181,  2183,  2290,  2291},
+    {  2080,  2081,  2182,  2184,  2291,  2292},
+    {  2081,  2082,  2183,  2185,  2292,  2293},
+    {  2082,  2083,  2184,  2186,  2293,  2294},
+    {  2083,  2084,  2185,  2187,  2294,  2295},
+    {  2084,  2085,  2186,  2188,  2295,  2296},
+    {  2085,  2086,  2187,  2189,  2296,  2297},
+    {  2086,  2087,  2188,  2190,  2297,  2298},
+    {  2087,  2088,  2189,  2191,  2298,  2299},
+    {  2088,  2089,  2190,  2192,  2299,  2300},
+    {  2089,  2090,  2191,  2193,  2300,  2301},
+    {  2090,  2091,  2192,  2194,  2301,  2302},
+    {  2091,  2092,  2193,  2195,  2302,  2303},
+    {  2092,  2093,  2194,  2196,  2303,  2304},
+    {  2093,  2195,  2304,  2305,  -1,  -1},
+    {  2094,  2198,  2306,  2307,  -1,  -1},
+    {  2094,  2095,  2197,  2199,  2307,  2308},
+    {  2095,  2096,  2198,  2200,  2308,  2309},
+    {  2096,  2097,  2199,  2201,  2309,  2310}, // 2200
+    {  2097,  2098,  2200,  2202,  2310,  2311},
+    {  2098,  2099,  2201,  2203,  2311,  2312},
+    {  2099,  2100,  2202,  2204,  2312,  2313},
+    {  2100,  2101,  2203,  2205,  2313,  2314},
+    {  2101,  2102,  2204,  2206,  2314,  2315},
+    {  2102,  2103,  2205,  2207,  2315,  2316},
+    {  2103,  2104,  2206,  2208,  2316,  2317},
+    {  2104,  2105,  2207,  2209,  2317,  2318},
+    {  2105,  2106,  2208,  2210,  2318,  2319},
+    {  2106,  2107,  2209,  2211,  2319,  2320},
+    {  2107,  2108,  2210,  2212,  2320,  2321},
+    {  2108,  2109,  2211,  2213,  2321,  2322},
+    {  2109,  2110,  2212,  2214,  2322,  2323},
+    {  2110,  2213,  2323,  2324,  -1,  -1},
+    {  2111,  2216,  2325,  2326,  -1,  -1},
+    {  2111,  2112,  2215,  2217,  2326,  2327},
+    {  2112,  2113,  2216,  2218,  2327,  2328},
+    {  2113,  2114,  2217,  2219,  2328,  2329},
+    {  2114,  2115,  2218,  2220,  2329,  2330},
+    {  2115,  2116,  2219,  2221,  2330,  2331}, // 2220
+    {  2116,  2117,  2220,  2222,  2331,  2332},
+    {  2117,  2118,  2221,  2223,  2332,  2333},
+    {  2118,  2119,  2222,  2224,  2333,  2334},
+    {  2119,  2120,  2223,  2225,  2334,  2335},
+    {  2120,  2121,  2224,  2226,  2335,  2336},
+    {  2121,  2122,  2225,  2227,  2336,  2337},
+    {  2122,  2123,  2226,  2228,  2337,  2338},
+    {  2123,  2124,  2227,  2229,  2338,  2339},
+    {  2124,  2125,  2228,  2230,  2339,  2340},
+    {  2125,  2126,  2229,  2231,  2340,  2341},
+    {  2126,  2127,  2230,  2232,  2341,  2342},
+    {  2127,  2231,  2342,  2343,  -1,  -1},
+    {  2128,  2234,  2344,  2345,  -1,  -1},
+    {  2128,  2129,  2233,  2235,  2345,  2346},
+    {  2129,  2130,  2234,  2236,  2346,  2347},
+    {  2130,  2131,  2235,  2237,  2347,  2348},
+    {  2131,  2132,  2236,  2238,  2348,  2349},
+    {  2132,  2133,  2237,  2239,  2349,  2350},
+    {  2133,  2134,  2238,  2240,  2350,  2351},
+    {  2134,  2135,  2239,  2241,  2351,  2352}, // 2240
+    {  2135,  2136,  2240,  2242,  2352,  2353},
+    {  2136,  2137,  2241,  2243,  2353,  2354},
+    {  2137,  2138,  2242,  2244,  2354,  2355},
+    {  2138,  2139,  2243,  2245,  2355,  2356},
+    {  2139,  2140,  2244,  2246,  2356,  2357},
+    {  2140,  2141,  2245,  2247,  2357,  2358},
+    {  2141,  2142,  2246,  2248,  2358,  2359},
+    {  2142,  2143,  2247,  2249,  2359,  2360},
+    {  2143,  2144,  2248,  2250,  2360,  2361},
+    {  2144,  2249,  2361,  2362,  -1,  -1},
+    {  2145,  2252,  2363,  2364,  -1,  -1},
+    {  2145,  2146,  2251,  2253,  2364,  2365},
+    {  2146,  2147,  2252,  2254,  2365,  2366},
+    {  2147,  2148,  2253,  2255,  2366,  2367},
+    {  2148,  2149,  2254,  2256,  2367,  2368},
+    {  2149,  2150,  2255,  2257,  2368,  2369},
+    {  2150,  2151,  2256,  2258,  2369,  2370},
+    {  2151,  2152,  2257,  2259,  2370,  2371},
+    {  2152,  2153,  2258,  2260,  2371,  2372},
+    {  2153,  2154,  2259,  2261,  2372,  2373}, // 2260
+    {  2154,  2155,  2260,  2262,  2373,  2374},
+    {  2155,  2156,  2261,  2263,  2374,  2375},
+    {  2156,  2157,  2262,  2264,  2375,  2376},
+    {  2157,  2158,  2263,  2265,  2376,  2377},
+    {  2158,  2159,  2264,  2266,  2377,  2378},
+    {  2159,  2160,  2265,  2267,  2378,  2379},
+    {  2160,  2161,  2266,  2268,  2379,  2380},
+    {  2161,  2267,  2380,  2381,  -1,  -1},
+    {  2162,  2270,  2382,  2383,  -1,  -1},
+    {  2162,  2163,  2269,  2271,  2383,  2384},
+    {  2163,  2164,  2270,  2272,  2384,  2385},
+    {  2164,  2165,  2271,  2273,  2385,  2386},
+    {  2165,  2166,  2272,  2274,  2386,  2387},
+    {  2166,  2167,  2273,  2275,  2387,  2388},
+    {  2167,  2168,  2274,  2276,  2388,  2389},
+    {  2168,  2169,  2275,  2277,  2389,  2390},
+    {  2169,  2170,  2276,  2278,  2390,  2391},
+    {  2170,  2171,  2277,  2279,  2391,  2392},
+    {  2171,  2172,  2278,  2280,  2392,  2393},
+    {  2172,  2173,  2279,  2281,  2393,  2394}, // 2280
+    {  2173,  2174,  2280,  2282,  2394,  2395},
+    {  2174,  2175,  2281,  2283,  2395,  2396},
+    {  2175,  2176,  2282,  2284,  2396,  2397},
+    {  2176,  2177,  2283,  2285,  2397,  2398},
+    {  2177,  2178,  2284,  2286,  2398,  2399},
+    {  2178,  2285,  2399,  2400,  -1,  -1},
+    {  2179,  2288,  -1,  -1,  -1,  -1},
+    {  2179,  2180,  2287,  2289,  -1,  -1},
+    {  2180,  2181,  2288,  2290,  -1,  -1},
+    {  2181,  2182,  2289,  2291,  -1,  -1},
+    {  2182,  2183,  2290,  2292,  -1,  -1},
+    {  2183,  2184,  2291,  2293,  -1,  -1},
+    {  2184,  2185,  2292,  2294,  -1,  -1},
+    {  2185,  2186,  2293,  2295,  -1,  -1},
+    {  2186,  2187,  2294,  2296,  -1,  -1},
+    {  2187,  2188,  2295,  2297,  -1,  -1},
+    {  2188,  2189,  2296,  2298,  -1,  -1},
+    {  2189,  2190,  2297,  2299,  -1,  -1},
+    {  2190,  2191,  2298,  2300,  -1,  -1},
+    {  2191,  2192,  2299,  2301,  -1,  -1}, // 2300
+    {  2192,  2193,  2300,  2302,  -1,  -1},
+    {  2193,  2194,  2301,  2303,  -1,  -1},
+    {  2194,  2195,  2302,  2304,  -1,  -1},
+    {  2195,  2196,  2303,  2305,  -1,  -1},
+    {  2196,  2304,  -1,  -1,  -1,  -1},
+    {  2197,  2307,  -1,  -1,  -1,  -1},
+    {  2197,  2198,  2306,  2308,  -1,  -1},
+    {  2198,  2199,  2307,  2309,  -1,  -1},
+    {  2199,  2200,  2308,  2310,  -1,  -1},
+    {  2200,  2201,  2309,  2311,  -1,  -1},
+    {  2201,  2202,  2310,  2312,  -1,  -1},
+    {  2202,  2203,  2311,  2313,  -1,  -1},
+    {  2203,  2204,  2312,  2314,  -1,  -1},
+    {  2204,  2205,  2313,  2315,  -1,  -1},
+    {  2205,  2206,  2314,  2316,  -1,  -1},
+    {  2206,  2207,  2315,  2317,  -1,  -1},
+    {  2207,  2208,  2316,  2318,  -1,  -1},
+    {  2208,  2209,  2317,  2319,  -1,  -1},
+    {  2209,  2210,  2318,  2320,  -1,  -1},
+    {  2210,  2211,  2319,  2321,  -1,  -1}, // 2320
+    {  2211,  2212,  2320,  2322,  -1,  -1},
+    {  2212,  2213,  2321,  2323,  -1,  -1},
+    {  2213,  2214,  2322,  2324,  -1,  -1},
+    {  2214,  2323,  -1,  -1,  -1,  -1},
+    {  2215,  2326,  -1,  -1,  -1,  -1},
+    {  2215,  2216,  2325,  2327,  -1,  -1},
+    {  2216,  2217,  2326,  2328,  -1,  -1},
+    {  2217,  2218,  2327,  2329,  -1,  -1},
+    {  2218,  2219,  2328,  2330,  -1,  -1},
+    {  2219,  2220,  2329,  2331,  -1,  -1},
+    {  2220,  2221,  2330,  2332,  -1,  -1},
+    {  2221,  2222,  2331,  2333,  -1,  -1},
+    {  2222,  2223,  2332,  2334,  -1,  -1},
+    {  2223,  2224,  2333,  2335,  -1,  -1},
+    {  2224,  2225,  2334,  2336,  -1,  -1},
+    {  2225,  2226,  2335,  2337,  -1,  -1},
+    {  2226,  2227,  2336,  2338,  -1,  -1},
+    {  2227,  2228,  2337,  2339,  -1,  -1},
+    {  2228,  2229,  2338,  2340,  -1,  -1},
+    {  2229,  2230,  2339,  2341,  -1,  -1}, // 2340
+    {  2230,  2231,  2340,  2342,  -1,  -1},
+    {  2231,  2232,  2341,  2343,  -1,  -1},
+    {  2232,  2342,  -1,  -1,  -1,  -1},
+    {  2233,  2345,  -1,  -1,  -1,  -1},
+    {  2233,  2234,  2344,  2346,  -1,  -1},
+    {  2234,  2235,  2345,  2347,  -1,  -1},
+    {  2235,  2236,  2346,  2348,  -1,  -1},
+    {  2236,  2237,  2347,  2349,  -1,  -1},
+    {  2237,  2238,  2348,  2350,  -1,  -1},
+    {  2238,  2239,  2349,  2351,  -1,  -1},
+    {  2239,  2240,  2350,  2352,  -1,  -1},
+    {  2240,  2241,  2351,  2353,  -1,  -1},
+    {  2241,  2242,  2352,  2354,  -1,  -1},
+    {  2242,  2243,  2353,  2355,  -1,  -1},
+    {  2243,  2244,  2354,  2356,  -1,  -1},
+    {  2244,  2245,  2355,  2357,  -1,  -1},
+    {  2245,  2246,  2356,  2358,  -1,  -1},
+    {  2246,  2247,  2357,  2359,  -1,  -1},
+    {  2247,  2248,  2358,  2360,  -1,  -1},
+    {  2248,  2249,  2359,  2361,  -1,  -1}, // 2360
+    {  2249,  2250,  2360,  2362,  -1,  -1},
+    {  2250,  2361,  -1,  -1,  -1,  -1},
+    {  2251,  2364,  -1,  -1,  -1,  -1},
+    {  2251,  2252,  2363,  2365,  -1,  -1},
+    {  2252,  2253,  2364,  2366,  -1,  -1},
+    {  2253,  2254,  2365,  2367,  -1,  -1},
+    {  2254,  2255,  2366,  2368,  -1,  -1},
+    {  2255,  2256,  2367,  2369,  -1,  -1},
+    {  2256,  2257,  2368,  2370,  -1,  -1},
+    {  2257,  2258,  2369,  2371,  -1,  -1},
+    {  2258,  2259,  2370,  2372,  -1,  -1},
+    {  2259,  2260,  2371,  2373,  -1,  -1},
+    {  2260,  2261,  2372,  2374,  -1,  -1},
+    {  2261,  2262,  2373,  2375,  -1,  -1},
+    {  2262,  2263,  2374,  2376,  -1,  -1},
+    {  2263,  2264,  2375,  2377,  -1,  -1},
+    {  2264,  2265,  2376,  2378,  -1,  -1},
+    {  2265,  2266,  2377,  2379,  -1,  -1},
+    {  2266,  2267,  2378,  2380,  -1,  -1},
+    {  2267,  2268,  2379,  2381,  -1,  -1}, // 2380
+    {  2268,  2380,  -1,  -1,  -1,  -1},
+    {  2269,  2383,  -1,  -1,  -1,  -1},
+    {  2269,  2270,  2382,  2384,  -1,  -1},
+    {  2270,  2271,  2383,  2385,  -1,  -1},
+    {  2271,  2272,  2384,  2386,  -1,  -1},
+    {  2272,  2273,  2385,  2387,  -1,  -1},
+    {  2273,  2274,  2386,  2388,  -1,  -1},
+    {  2274,  2275,  2387,  2389,  -1,  -1},
+    {  2275,  2276,  2388,  2390,  -1,  -1},
+    {  2276,  2277,  2389,  2391,  -1,  -1},
+    {  2277,  2278,  2390,  2392,  -1,  -1},
+    {  2278,  2279,  2391,  2393,  -1,  -1},
+    {  2279,  2280,  2392,  2394,  -1,  -1},
+    {  2280,  2281,  2393,  2395,  -1,  -1},
+    {  2281,  2282,  2394,  2396,  -1,  -1},
+    {  2282,  2283,  2395,  2397,  -1,  -1},
+    {  2283,  2284,  2396,  2398,  -1,  -1},
+    {  2284,  2285,  2397,  2399,  -1,  -1},
+    {  2285,  2286,  2398,  2400,  -1,  -1},
+    {  2286,  2399,  -1,  -1,  -1,  -1} // 2400
+  };
+
+  for (Int_t i=0; i<2401; 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-8-5/Mars/mgeom/MGeomCamECO1000HG.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mgeom/MGeomCamECO1000HG.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mgeom/MGeomCamECO1000HG.h	(revision 9661)
@@ -0,0 +1,21 @@
+#ifndef MARS_MGeomCamECO1000HG
+#define MARS_MGeomCamECO1000HG
+
+#ifndef MARS_MGeomCam
+#include "MGeomCam.h"
+#endif
+
+class MGeomCamECO1000HG : public MGeomCam
+{
+private:
+    void CreateCam();
+    void CreateNN();
+
+public:
+    MGeomCamECO1000HG(const char *name=NULL);
+
+    ClassDef(MGeomCamECO1000HG, 1)		// Geometry class for the Magic camera
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mgeom/MGeomCamMagic.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mgeom/MGeomCamMagic.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mgeom/MGeomCamMagic.cc	(revision 9661)
@@ -0,0 +1,925 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Harald Kornmayer 1/2001
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MGeomCamMagic
+//
+// This class stores the geometry information of the Magic camera.
+// All information are copied from tables, see source code.
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MGeomCamMagic.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();
+    InitGeometry();
+}
+
+// --------------------------------------------------------------------------
+//
+//  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 dtemp[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
+*/
+    const Byte_t sector[577] = {
+        0, 1, 2, 3, 4, 5, 6, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
+        1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 1,
+        1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5,
+        6, 6, 6, 6, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3,
+        4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 1, 1, 1, 1,
+        1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4,
+        4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 1, 1, 1, 1, 1, 1,
+        1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4,
+        4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 1, 1,
+        1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3,
+        3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5,
+        6, 6, 6, 6, 6, 6, 6, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2,
+        2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4,
+        4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6,
+        6, 6, 6, 6, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2,
+        2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4,
+        4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6,
+        6, 6, 6, 6, 6, 6, 6, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+        2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
+        3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5,
+        5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 1, 1,
+        1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4,
+        4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 1, 1, 1, 1,
+        1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4,
+        4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6,
+        1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3,
+        3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5,
+        5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+        2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4,
+        4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6,
+        6, 6, 6, 6, 6, 6, 6 };
+
+    //
+    //   fill the pixels list with this data
+    //
+    for (UInt_t i=0; i<GetNumPixels(); i++)
+        (*this)[i].Set(xtemp[i], ytemp[i], i>396?60:30, sector[i], i>396?1:0);
+    // (*this)[i].Set(xtemp[i], ytemp[i], i>396?60:30, i>396?sector[i]+6:sector[i]);
+}
+
+// --------------------------------------------------------------------------
+//
+//  This fills the next neighbor information from a table into the pixel
+//  objects.
+//
+void MGeomCamMagic::CreateNN()
+{
+    const Short_t nn[577][6] = {         // Neighbors of #
+        {   1,   2,   3,   4,   5,   6}, // 0
+        {   0,   2,   6,   7,   8,  18},
+        {   0,   1,   3,   8,   9,  10},
+        {   0,   2,   4,  10,  11,  12},
+        {   0,   3,   5,  12,  13,  14},
+        {   0,   4,   6,  14,  15,  16},
+        {   0,   1,   5,  16,  17,  18},
+        {   1,   8,  18,  19,  20,  36},
+        {   1,   2,   7,   9,  20,  21},
+        {   2,   8,  10,  21,  22,  23},
+        {   2,   3,   9,  11,  23,  24},
+        {   3,  10,  12,  24,  25,  26},
+        {   3,   4,  11,  13,  26,  27},
+        {   4,  12,  14,  27,  28,  29},
+        {   4,   5,  13,  15,  29,  30},
+        {   5,  14,  16,  30,  31,  32},
+        {   5,   6,  15,  17,  32,  33},
+        {   6,  16,  18,  33,  34,  35},
+        {   1,   6,   7,  17,  35,  36},
+        {   7,  20,  36,  37,  38,  60},
+        {   7,   8,  19,  21,  38,  39}, // 20
+        {   8,   9,  20,  22,  39,  40},
+        {   9,  21,  23,  40,  41,  42},
+        {   9,  10,  22,  24,  42,  43},
+        {  10,  11,  23,  25,  43,  44},
+        {  11,  24,  26,  44,  45,  46},
+        {  11,  12,  25,  27,  46,  47},
+        {  12,  13,  26,  28,  47,  48},
+        {  13,  27,  29,  48,  49,  50},
+        {  13,  14,  28,  30,  50,  51},
+        {  14,  15,  29,  31,  51,  52},
+        {  15,  30,  32,  52,  53,  54},
+        {  15,  16,  31,  33,  54,  55},
+        {  16,  17,  32,  34,  55,  56},
+        {  17,  33,  35,  56,  57,  58},
+        {  17,  18,  34,  36,  58,  59},
+        {   7,  18,  19,  35,  59,  60},
+        {  19,  38,  60,  61,  62,  90},
+        {  19,  20,  37,  39,  62,  63},
+        {  20,  21,  38,  40,  63,  64},
+        {  21,  22,  39,  41,  64,  65}, // 40
+        {  22,  40,  42,  65,  66,  67},
+        {  22,  23,  41,  43,  67,  68},
+        {  23,  24,  42,  44,  68,  69},
+        {  24,  25,  43,  45,  69,  70},
+        {  25,  44,  46,  70,  71,  72},
+        {  25,  26,  45,  47,  72,  73},
+        {  26,  27,  46,  48,  73,  74},
+        {  27,  28,  47,  49,  74,  75},
+        {  28,  48,  50,  75,  76,  77},
+        {  28,  29,  49,  51,  77,  78},
+        {  29,  30,  50,  52,  78,  79},
+        {  30,  31,  51,  53,  79,  80},
+        {  31,  52,  54,  80,  81,  82},
+        {  31,  32,  53,  55,  82,  83},
+        {  32,  33,  54,  56,  83,  84},
+        {  33,  34,  55,  57,  84,  85},
+        {  34,  56,  58,  85,  86,  87},
+        {  34,  35,  57,  59,  87,  88},
+        {  35,  36,  58,  60,  88,  89},
+        {  19,  36,  37,  59,  89,  90}, // 60
+        {  37,  62,  90,  91,  92, 126},
+        {  37,  38,  61,  63,  92,  93},
+        {  38,  39,  62,  64,  93,  94},
+        {  39,  40,  63,  65,  94,  95},
+        {  40,  41,  64,  66,  95,  96},
+        {  41,  65,  67,  96,  97,  98},
+        {  41,  42,  66,  68,  98,  99},
+        {  42,  43,  67,  69,  99, 100},
+        {  43,  44,  68,  70, 100, 101},
+        {  44,  45,  69,  71, 101, 102},
+        {  45,  70,  72, 102, 103, 104},
+        {  45,  46,  71,  73, 104, 105},
+        {  46,  47,  72,  74, 105, 106},
+        {  47,  48,  73,  75, 106, 107},
+        {  48,  49,  74,  76, 107, 108},
+        {  49,  75,  77, 108, 109, 110},
+        {  49,  50,  76,  78, 110, 111},
+        {  50,  51,  77,  79, 111, 112},
+        {  51,  52,  78,  80, 112, 113},
+        {  52,  53,  79,  81, 113, 114}, // 80
+        {  53,  80,  82, 114, 115, 116},
+        {  53,  54,  81,  83, 116, 117},
+        {  54,  55,  82,  84, 117, 118},
+        {  55,  56,  83,  85, 118, 119},
+        {  56,  57,  84,  86, 119, 120},
+        {  57,  85,  87, 120, 121, 122},
+        {  57,  58,  86,  88, 122, 123},
+        {  58,  59,  87,  89, 123, 124},
+        {  59,  60,  88,  90, 124, 125},
+        {  37,  60,  61,  89, 125, 126},
+        {  61,  92, 126, 127, 128, 168},
+        {  61,  62,  91,  93, 128, 129},
+        {  62,  63,  92,  94, 129, 130},
+        {  63,  64,  93,  95, 130, 131},
+        {  64,  65,  94,  96, 131, 132},
+        {  65,  66,  95,  97, 132, 133},
+        {  66,  96,  98, 133, 134, 135},
+        {  66,  67,  97,  99, 135, 136},
+        {  67,  68,  98, 100, 136, 137},
+        {  68,  69,  99, 101, 137, 138}, // 100
+        {  69,  70, 100, 102, 138, 139},
+        {  70,  71, 101, 103, 139, 140},
+        {  71, 102, 104, 140, 141, 142},
+        {  71,  72, 103, 105, 142, 143},
+        {  72,  73, 104, 106, 143, 144},
+        {  73,  74, 105, 107, 144, 145},
+        {  74,  75, 106, 108, 145, 146},
+        {  75,  76, 107, 109, 146, 147},
+        {  76, 108, 110, 147, 148, 149},
+        {  76,  77, 109, 111, 149, 150},
+        {  77,  78, 110, 112, 150, 151},
+        {  78,  79, 111, 113, 151, 152},
+        {  79,  80, 112, 114, 152, 153},
+        {  80,  81, 113, 115, 153, 154},
+        {  81, 114, 116, 154, 155, 156},
+        {  81,  82, 115, 117, 156, 157},
+        {  82,  83, 116, 118, 157, 158},
+        {  83,  84, 117, 119, 158, 159},
+        {  84,  85, 118, 120, 159, 160},
+        {  85,  86, 119, 121, 160, 161}, // 120
+        {  86, 120, 122, 161, 162, 163},
+        {  86,  87, 121, 123, 163, 164},
+        {  87,  88, 122, 124, 164, 165},
+        {  88,  89, 123, 125, 165, 166},
+        {  89,  90, 124, 126, 166, 167},
+        {  61,  90,  91, 125, 167, 168},
+        {  91, 128, 168, 169, 170, 216},
+        {  91,  92, 127, 129, 170, 171},
+        {  92,  93, 128, 130, 171, 172},
+        {  93,  94, 129, 131, 172, 173},
+        {  94,  95, 130, 132, 173, 174},
+        {  95,  96, 131, 133, 174, 175},
+        {  96,  97, 132, 134, 175, 176},
+        {  97, 133, 135, 176, 177, 178},
+        {  97,  98, 134, 136, 178, 179},
+        {  98,  99, 135, 137, 179, 180},
+        {  99, 100, 136, 138, 180, 181},
+        { 100, 101, 137, 139, 181, 182},
+        { 101, 102, 138, 140, 182, 183},
+        { 102, 103, 139, 141, 183, 184}, // 140
+        { 103, 140, 142, 184, 185, 186},
+        { 103, 104, 141, 143, 186, 187},
+        { 104, 105, 142, 144, 187, 188},
+        { 105, 106, 143, 145, 188, 189},
+        { 106, 107, 144, 146, 189, 190},
+        { 107, 108, 145, 147, 190, 191},
+        { 108, 109, 146, 148, 191, 192},
+        { 109, 147, 149, 192, 193, 194},
+        { 109, 110, 148, 150, 194, 195},
+        { 110, 111, 149, 151, 195, 196},
+        { 111, 112, 150, 152, 196, 197},
+        { 112, 113, 151, 153, 197, 198},
+        { 113, 114, 152, 154, 198, 199},
+        { 114, 115, 153, 155, 199, 200},
+        { 115, 154, 156, 200, 201, 202},
+        { 115, 116, 155, 157, 202, 203},
+        { 116, 117, 156, 158, 203, 204},
+        { 117, 118, 157, 159, 204, 205},
+        { 118, 119, 158, 160, 205, 206},
+        { 119, 120, 159, 161, 206, 207}, // 160
+        { 120, 121, 160, 162, 207, 208},
+        { 121, 161, 163, 208, 209, 210},
+        { 121, 122, 162, 164, 210, 211},
+        { 122, 123, 163, 165, 211, 212},
+        { 123, 124, 164, 166, 212, 213},
+        { 124, 125, 165, 167, 213, 214},
+        { 125, 126, 166, 168, 214, 215},
+        {  91, 126, 127, 167, 215, 216},
+        { 127, 170, 216, 217, 218, 270},
+        { 127, 128, 169, 171, 218, 219},
+        { 128, 129, 170, 172, 219, 220},
+        { 129, 130, 171, 173, 220, 221},
+        { 130, 131, 172, 174, 221, 222},
+        { 131, 132, 173, 175, 222, 223},
+        { 132, 133, 174, 176, 223, 224},
+        { 133, 134, 175, 177, 224, 225},
+        { 134, 176, 178, 225, 226, 227},
+        { 134, 135, 177, 179, 227, 228},
+        { 135, 136, 178, 180, 228, 229},
+        { 136, 137, 179, 181, 229, 230}, // 180
+        { 137, 138, 180, 182, 230, 231},
+        { 138, 139, 181, 183, 231, 232},
+        { 139, 140, 182, 184, 232, 233},
+        { 140, 141, 183, 185, 233, 234},
+        { 141, 184, 186, 234, 235, 236},
+        { 141, 142, 185, 187, 236, 237},
+        { 142, 143, 186, 188, 237, 238},
+        { 143, 144, 187, 189, 238, 239},
+        { 144, 145, 188, 190, 239, 240},
+        { 145, 146, 189, 191, 240, 241},
+        { 146, 147, 190, 192, 241, 242},
+        { 147, 148, 191, 193, 242, 243},
+        { 148, 192, 194, 243, 244, 245},
+        { 148, 149, 193, 195, 245, 246},
+        { 149, 150, 194, 196, 246, 247},
+        { 150, 151, 195, 197, 247, 248},
+        { 151, 152, 196, 198, 248, 249},
+        { 152, 153, 197, 199, 249, 250},
+        { 153, 154, 198, 200, 250, 251},
+        { 154, 155, 199, 201, 251, 252}, // 200
+        { 155, 200, 202, 252, 253, 254},
+        { 155, 156, 201, 203, 254, 255},
+        { 156, 157, 202, 204, 255, 256},
+        { 157, 158, 203, 205, 256, 257},
+        { 158, 159, 204, 206, 257, 258},
+        { 159, 160, 205, 207, 258, 259},
+        { 160, 161, 206, 208, 259, 260},
+        { 161, 162, 207, 209, 260, 261},
+        { 162, 208, 210, 261, 262, 263},
+        { 162, 163, 209, 211, 263, 264},
+        { 163, 164, 210, 212, 264, 265},
+        { 164, 165, 211, 213, 265, 266},
+        { 165, 166, 212, 214, 266, 267},
+        { 166, 167, 213, 215, 267, 268},
+        { 167, 168, 214, 216, 268, 269},
+        { 127, 168, 169, 215, 269, 270},
+        { 169, 218, 270, 271, 272, 330},
+        { 169, 170, 217, 219, 272, 273},
+        { 170, 171, 218, 220, 273, 274},
+        { 171, 172, 219, 221, 274, 275}, // 220
+        { 172, 173, 220, 222, 275, 276},
+        { 173, 174, 221, 223, 276, 277},
+        { 174, 175, 222, 224, 277, 278},
+        { 175, 176, 223, 225, 278, 279},
+        { 176, 177, 224, 226, 279, 280},
+        { 177, 225, 227, 280, 281, 282},
+        { 177, 178, 226, 228, 282, 283},
+        { 178, 179, 227, 229, 283, 284},
+        { 179, 180, 228, 230, 284, 285},
+        { 180, 181, 229, 231, 285, 286},
+        { 181, 182, 230, 232, 286, 287},
+        { 182, 183, 231, 233, 287, 288},
+        { 183, 184, 232, 234, 288, 289},
+        { 184, 185, 233, 235, 289, 290},
+        { 185, 234, 236, 290, 291, 292},
+        { 185, 186, 235, 237, 292, 293},
+        { 186, 187, 236, 238, 293, 294},
+        { 187, 188, 237, 239, 294, 295},
+        { 188, 189, 238, 240, 295, 296},
+        { 189, 190, 239, 241, 296, 297}, // 240
+        { 190, 191, 240, 242, 297, 298},
+        { 191, 192, 241, 243, 298, 299},
+        { 192, 193, 242, 244, 299, 300},
+        { 193, 243, 245, 300, 301, 302},
+        { 193, 194, 244, 246, 302, 303},
+        { 194, 195, 245, 247, 303, 304},
+        { 195, 196, 246, 248, 304, 305},
+        { 196, 197, 247, 249, 305, 306},
+        { 197, 198, 248, 250, 306, 307},
+        { 198, 199, 249, 251, 307, 308},
+        { 199, 200, 250, 252, 308, 309},
+        { 200, 201, 251, 253, 309, 310},
+        { 201, 252, 254, 310, 311, 312},
+        { 201, 202, 253, 255, 312, 313},
+        { 202, 203, 254, 256, 313, 314},
+        { 203, 204, 255, 257, 314, 315},
+        { 204, 205, 256, 258, 315, 316},
+        { 205, 206, 257, 259, 316, 317},
+        { 206, 207, 258, 260, 317, 318},
+        { 207, 208, 259, 261, 318, 319}, // 260
+        { 208, 209, 260, 262, 319, 320},
+        { 209, 261, 263, 320, 321, 322},
+        { 209, 210, 262, 264, 322, 323},
+        { 210, 211, 263, 265, 323, 324},
+        { 211, 212, 264, 266, 324, 325},
+        { 212, 213, 265, 267, 325, 326},
+        { 213, 214, 266, 268, 326, 327},
+        { 214, 215, 267, 269, 327, 328},
+        { 215, 216, 268, 270, 328, 329},
+        { 169, 216, 217, 269, 329, 330},
+        { 217, 272, 330, 331, 332, 396},
+        { 217, 218, 271, 273, 332, 333},
+        { 218, 219, 272, 274, 333, 334},
+        { 219, 220, 273, 275, 334, 335},
+        { 220, 221, 274, 276, 335, 336},
+        { 221, 222, 275, 277, 336, 337},
+        { 222, 223, 276, 278, 337, 338},
+        { 223, 224, 277, 279, 338, 339},
+        { 224, 225, 278, 280, 339, 340},
+        { 225, 226, 279, 281, 340, 341}, // 280
+        { 226, 280, 282, 341, 342, 343},
+        { 226, 227, 281, 283, 343, 344},
+        { 227, 228, 282, 284, 344, 345},
+        { 228, 229, 283, 285, 345, 346},
+        { 229, 230, 284, 286, 346, 347},
+        { 230, 231, 285, 287, 347, 348},
+        { 231, 232, 286, 288, 348, 349},
+        { 232, 233, 287, 289, 349, 350},
+        { 233, 234, 288, 290, 350, 351},
+        { 234, 235, 289, 291, 351, 352},
+        { 235, 290, 292, 352, 353, 354},
+        { 235, 236, 291, 293, 354, 355},
+        { 236, 237, 292, 294, 355, 356},
+        { 237, 238, 293, 295, 356, 357},
+        { 238, 239, 294, 296, 357, 358},
+        { 239, 240, 295, 297, 358, 359},
+        { 240, 241, 296, 298, 359, 360},
+        { 241, 242, 297, 299, 360, 361},
+        { 242, 243, 298, 300, 361, 362},
+        { 243, 244, 299, 301, 362, 363}, // 300
+        { 244, 300, 302, 363, 364, 365},
+        { 244, 245, 301, 303, 365, 366},
+        { 245, 246, 302, 304, 366, 367},
+        { 246, 247, 303, 305, 367, 368},
+        { 247, 248, 304, 306, 368, 369},
+        { 248, 249, 305, 307, 369, 370},
+        { 249, 250, 306, 308, 370, 371},
+        { 250, 251, 307, 309, 371, 372},
+        { 251, 252, 308, 310, 372, 373},
+        { 252, 253, 309, 311, 373, 374},
+        { 253, 310, 312, 374, 375, 376},
+        { 253, 254, 311, 313, 376, 377},
+        { 254, 255, 312, 314, 377, 378},
+        { 255, 256, 313, 315, 378, 379},
+        { 256, 257, 314, 316, 379, 380},
+        { 257, 258, 315, 317, 380, 381},
+        { 258, 259, 316, 318, 381, 382},
+        { 259, 260, 317, 319, 382, 383},
+        { 260, 261, 318, 320, 383, 384},
+        { 261, 262, 319, 321, 384, 385}, // 320
+        { 262, 320, 322, 385, 386, 387},
+        { 262, 263, 321, 323, 387, 388},
+        { 263, 264, 322, 324, 388, 389},
+        { 264, 265, 323, 325, 389, 390},
+        { 265, 266, 324, 326, 390, 391},
+        { 266, 267, 325, 327, 391, 392},
+        { 267, 268, 326, 328, 392, 393},
+        { 268, 269, 327, 329, 393, 394},
+        { 269, 270, 328, 330, 394, 395},
+        { 217, 270, 271, 329, 395, 396},
+        { 271, 332, 396, 397, 432,  -1},
+        { 271, 272, 331, 333, 397,  -1},
+        { 272, 273, 332, 334, 398,  -1},
+        { 273, 274, 333, 335, 398,  -1},
+        { 274, 275, 334, 336, 399,  -1},
+        { 275, 276, 335, 337, 399,  -1},
+        { 276, 277, 336, 338, 400,  -1},
+        { 277, 278, 337, 339, 400,  -1},
+        { 278, 279, 338, 340, 401,  -1},
+        { 279, 280, 339, 341, 401,  -1}, // 340
+        { 280, 281, 340, 342, 402,  -1},
+        { 281, 341, 343, 402, 403,  -1},
+        { 281, 282, 342, 344, 403,  -1},
+        { 282, 283, 343, 345, 404,  -1},
+        { 283, 284, 344, 346, 404,  -1},
+        { 284, 285, 345, 347, 405,  -1},
+        { 285, 286, 346, 348, 405,  -1},
+        { 286, 287, 347, 349, 406,  -1},
+        { 287, 288, 348, 350, 406,  -1},
+        { 288, 289, 349, 351, 407,  -1},
+        { 289, 290, 350, 352, 407,  -1},
+        { 290, 291, 351, 353, 408,  -1},
+        { 291, 352, 354, 408, 409,  -1},
+        { 291, 292, 353, 355, 409,  -1},
+        { 292, 293, 354, 356, 410,  -1},
+        { 293, 294, 355, 357, 410,  -1},
+        { 294, 295, 356, 358, 411,  -1},
+        { 295, 296, 357, 359, 411,  -1},
+        { 296, 297, 358, 360, 412,  -1},
+        { 297, 298, 359, 361, 412,  -1}, // 360
+        { 298, 299, 360, 362, 413,  -1},
+        { 299, 300, 361, 363, 413,  -1},
+        { 300, 301, 362, 364, 414,  -1},
+        { 301, 363, 365, 414, 415,  -1},
+        { 301, 302, 364, 366, 415,  -1},
+        { 302, 303, 365, 367, 416,  -1},
+        { 303, 304, 366, 368, 416,  -1},
+        { 304, 305, 367, 369, 417,  -1},
+        { 305, 306, 368, 370, 417,  -1},
+        { 306, 307, 369, 371, 418,  -1},
+        { 307, 308, 370, 372, 418,  -1},
+        { 308, 309, 371, 373, 419,  -1},
+        { 309, 310, 372, 374, 419,  -1},
+        { 310, 311, 373, 375, 420,  -1},
+        { 311, 374, 376, 420, 421,  -1},
+        { 311, 312, 375, 377, 421,  -1},
+        { 312, 313, 376, 378, 422,  -1},
+        { 313, 314, 377, 379, 422,  -1},
+        { 314, 315, 378, 380, 423,  -1},
+        { 315, 316, 379, 381, 423,  -1}, // 380
+        { 316, 317, 380, 382, 424,  -1},
+        { 317, 318, 381, 383, 424,  -1},
+        { 318, 319, 382, 384, 425,  -1},
+        { 319, 320, 383, 385, 425,  -1},
+        { 320, 321, 384, 386, 426,  -1},
+        { 321, 385, 387, 426, 427,  -1},
+        { 321, 322, 386, 388, 427,  -1},
+        { 322, 323, 387, 389, 428,  -1},
+        { 323, 324, 388, 390, 428,  -1},
+        { 324, 325, 389, 391, 429,  -1},
+        { 325, 326, 390, 392, 429,  -1},
+        { 326, 327, 391, 393, 430,  -1},
+        { 327, 328, 392, 394, 430,  -1},
+        { 328, 329, 393, 395, 431,  -1},
+        { 329, 330, 394, 396, 431,  -1},
+        { 271, 330, 331, 395, 432,  -1},
+        { 331, 332, 398, 432, 433, 434},
+        { 333, 334, 397, 399, 434, 435},
+        { 335, 336, 398, 400, 435, 436},
+        { 337, 338, 399, 401, 436, 437}, // 400
+        { 339, 340, 400, 402, 437, 438},
+        { 341, 342, 401, 403, 438, 439},
+        { 342, 343, 402, 404, 440, 441},
+        { 344, 345, 403, 405, 441, 442},
+        { 346, 347, 404, 406, 442, 443},
+        { 348, 349, 405, 407, 443, 444},
+        { 350, 351, 406, 408, 444, 445},
+        { 352, 353, 407, 409, 445, 446},
+        { 353, 354, 408, 410, 447, 448},
+        { 355, 356, 409, 411, 448, 449},
+        { 357, 358, 410, 412, 449, 450},
+        { 359, 360, 411, 413, 450, 451},
+        { 361, 362, 412, 414, 451, 452},
+        { 363, 364, 413, 415, 452, 453},
+        { 364, 365, 414, 416, 454, 455},
+        { 366, 367, 415, 417, 455, 456},
+        { 368, 369, 416, 418, 456, 457},
+        { 370, 371, 417, 419, 457, 458},
+        { 372, 373, 418, 420, 458, 459},
+        { 374, 375, 419, 421, 459, 460}, // 420
+        { 375, 376, 420, 422, 461, 462},
+        { 377, 378, 421, 423, 462, 463},
+        { 379, 380, 422, 424, 463, 464},
+        { 381, 382, 423, 425, 464, 465},
+        { 383, 384, 424, 426, 465, 466},
+        { 385, 386, 425, 427, 466, 467},
+        { 386, 387, 426, 428, 468, 469},
+        { 388, 389, 427, 429, 469, 470},
+        { 390, 391, 428, 430, 470, 471},
+        { 392, 393, 429, 431, 471, 472},
+        { 394, 395, 430, 432, 472, 473},
+        { 331, 396, 397, 431, 473, 474},
+        { 397, 434, 474, 475, 476,  -1},
+        { 397, 398, 433, 435, 476, 477},
+        { 398, 399, 434, 436, 477, 478},
+        { 399, 400, 435, 437, 478, 479},
+        { 400, 401, 436, 438, 479, 480},
+        { 401, 402, 437, 439, 480, 481},
+        { 402, 438, 440, 481, 482,  -1},
+        { 403, 439, 441, 483, 484,  -1}, // 440
+        { 403, 404, 440, 442, 484, 485},
+        { 404, 405, 441, 443, 485, 486},
+        { 405, 406, 442, 444, 486, 487},
+        { 406, 407, 443, 445, 487, 488},
+        { 407, 408, 444, 446, 488, 489},
+        { 408, 445, 447, 489, 490,  -1},
+        { 409, 446, 448, 491, 492,  -1},
+        { 409, 410, 447, 449, 492, 493},
+        { 410, 411, 448, 450, 493, 494},
+        { 411, 412, 449, 451, 494, 495},
+        { 412, 413, 450, 452, 495, 496},
+        { 413, 414, 451, 453, 496, 497},
+        { 414, 452, 454, 497, 498,  -1},
+        { 415, 453, 455, 499, 500,  -1},
+        { 415, 416, 454, 456, 500, 501},
+        { 416, 417, 455, 457, 501, 502},
+        { 417, 418, 456, 458, 502, 503},
+        { 418, 419, 457, 459, 503, 504},
+        { 419, 420, 458, 460, 504, 505},
+        { 420, 459, 461, 505, 506,  -1}, // 460
+        { 421, 460, 462, 507, 508,  -1},
+        { 421, 422, 461, 463, 508, 509},
+        { 422, 423, 462, 464, 509, 510},
+        { 423, 424, 463, 465, 510, 511},
+        { 424, 425, 464, 466, 511, 512},
+        { 425, 426, 465, 467, 512, 513},
+        { 426, 466, 468, 513, 514,  -1},
+        { 427, 467, 469, 515, 516,  -1},
+        { 427, 428, 468, 470, 516, 517},
+        { 428, 429, 469, 471, 517, 518},
+        { 429, 430, 470, 472, 518, 519},
+        { 430, 431, 471, 473, 519, 520},
+        { 431, 432, 472, 474, 520, 521},
+        { 432, 433, 473, 521, 522,  -1},
+        { 433, 476, 522, 523, 524,  -1},
+        { 433, 434, 475, 477, 524, 525},
+        { 434, 435, 476, 478, 525, 526},
+        { 435, 436, 477, 479, 526, 527},
+        { 436, 437, 478, 480, 527, 528},
+        { 437, 438, 479, 481, 528, 529}, // 480
+        { 438, 439, 480, 482, 529, 530},
+        { 439, 481, 483, 530, 531,  -1},
+        { 440, 482, 484, 532, 533,  -1},
+        { 440, 441, 483, 485, 533, 534},
+        { 441, 442, 484, 486, 534, 535},
+        { 442, 443, 485, 487, 535, 536},
+        { 443, 444, 486, 488, 536, 537},
+        { 444, 445, 487, 489, 537, 538},
+        { 445, 446, 488, 490, 538, 539},
+        { 446, 489, 491, 539, 540,  -1},
+        { 447, 490, 492, 541, 542,  -1},
+        { 447, 448, 491, 493, 542, 543},
+        { 448, 449, 492, 494, 543, 544},
+        { 449, 450, 493, 495, 544, 545},
+        { 450, 451, 494, 496, 545, 546},
+        { 451, 452, 495, 497, 546, 547},
+        { 452, 453, 496, 498, 547, 548},
+        { 453, 497, 499, 548, 549,  -1},
+        { 454, 498, 500, 550, 551,  -1},
+        { 454, 455, 499, 501, 551, 552}, // 500
+        { 455, 456, 500, 502, 552, 553},
+        { 456, 457, 501, 503, 553, 554},
+        { 457, 458, 502, 504, 554, 555},
+        { 458, 459, 503, 505, 555, 556},
+        { 459, 460, 504, 506, 556, 557},
+        { 460, 505, 507, 557, 558,  -1},
+        { 461, 506, 508, 559, 560,  -1},
+        { 461, 462, 507, 509, 560, 561},
+        { 462, 463, 508, 510, 561, 562},
+        { 463, 464, 509, 511, 562, 563},
+        { 464, 465, 510, 512, 563, 564},
+        { 465, 466, 511, 513, 564, 565},
+        { 466, 467, 512, 514, 565, 566},
+        { 467, 513, 515, 566, 567,  -1},
+        { 468, 514, 516, 568, 569,  -1},
+        { 468, 469, 515, 517, 569, 570},
+        { 469, 470, 516, 518, 570, 571},
+        { 470, 471, 517, 519, 571, 572},
+        { 471, 472, 518, 520, 572, 573},
+        { 472, 473, 519, 521, 573, 574}, // 520
+        { 473, 474, 520, 522, 574, 575},
+        { 474, 475, 521, 575, 576,  -1},
+        { 475, 524, 576,  -1,  -1,  -1},
+        { 475, 476, 523, 525,  -1,  -1},
+        { 476, 477, 524, 526,  -1,  -1},
+        { 477, 478, 525, 527,  -1,  -1},
+        { 478, 479, 526, 528,  -1,  -1},
+        { 479, 480, 527, 529,  -1,  -1},
+        { 480, 481, 528, 530,  -1,  -1},
+        { 481, 482, 529, 531,  -1,  -1},
+        { 482, 530, 532,  -1,  -1,  -1},
+        { 483, 531, 533,  -1,  -1,  -1},
+        { 483, 484, 532, 534,  -1,  -1},
+        { 484, 485, 533, 535,  -1,  -1},
+        { 485, 486, 534, 536,  -1,  -1},
+        { 486, 487, 535, 537,  -1,  -1},
+        { 487, 488, 536, 538,  -1,  -1},
+        { 488, 489, 537, 539,  -1,  -1},
+        { 489, 490, 538, 540,  -1,  -1},
+        { 490, 539, 541,  -1,  -1,  -1}, // 540
+        { 491, 540, 542,  -1,  -1,  -1},
+        { 491, 492, 541, 543,  -1,  -1},
+        { 492, 493, 542, 544,  -1,  -1},
+        { 493, 494, 543, 545,  -1,  -1},
+        { 494, 495, 544, 546,  -1,  -1},
+        { 495, 496, 545, 547,  -1,  -1},
+        { 496, 497, 546, 548,  -1,  -1},
+        { 497, 498, 547, 549,  -1,  -1},
+        { 498, 548, 550,  -1,  -1,  -1},
+        { 499, 549, 551,  -1,  -1,  -1},
+        { 499, 500, 550, 552,  -1,  -1},
+        { 500, 501, 551, 553,  -1,  -1},
+        { 501, 502, 552, 554,  -1,  -1},
+        { 502, 503, 553, 555,  -1,  -1},
+        { 503, 504, 554, 556,  -1,  -1},
+        { 504, 505, 555, 557,  -1,  -1},
+        { 505, 506, 556, 558,  -1,  -1},
+        { 506, 557, 559,  -1,  -1,  -1},
+        { 507, 558, 560,  -1,  -1,  -1},
+        { 507, 508, 559, 561,  -1,  -1}, // 560
+        { 508, 509, 560, 562,  -1,  -1},
+        { 509, 510, 561, 563,  -1,  -1},
+        { 510, 511, 562, 564,  -1,  -1},
+        { 511, 512, 563, 565,  -1,  -1},
+        { 512, 513, 564, 566,  -1,  -1},
+        { 513, 514, 565, 567,  -1,  -1},
+        { 514, 566, 568,  -1,  -1,  -1},
+        { 515, 567, 569,  -1,  -1,  -1},
+        { 515, 516, 568, 570,  -1,  -1},
+        { 516, 517, 569, 571,  -1,  -1}, // 570
+        { 517, 518, 570, 572,  -1,  -1},
+        { 518, 519, 571, 573,  -1,  -1},
+        { 519, 520, 572, 574,  -1,  -1},
+        { 520, 521, 573, 575,  -1,  -1},
+        { 521, 522, 574, 576,  -1,  -1},
+        { 522, 523, 575,  -1,  -1,  -1}  // 576
+    };
+
+    for (Int_t i=0; i<577; i++)
+        (*this)[i].SetNeighbors(nn[i][0], nn[i][1], nn[i][2],
+                                nn[i][3], nn[i][4], nn[i][5]);
+}
Index: /tags/Mars_V0-8-5/Mars/mgeom/MGeomCamMagic.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mgeom/MGeomCamMagic.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mgeom/MGeomCamMagic.h	(revision 9661)
@@ -0,0 +1,21 @@
+#ifndef MARS_MGeomCamMagic
+#define MARS_MGeomCamMagic
+
+#ifndef MARS_MGeomCam
+#include "MGeomCam.h"
+#endif
+
+class MGeomCamMagic : public MGeomCam
+{
+private:
+    void CreateCam();
+    void CreateNN();
+
+public:
+    MGeomCamMagic(const char *name=NULL);
+
+    ClassDef(MGeomCamMagic, 1)		// Geometry class for the Magic camera
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mgeom/MGeomCamMagic919.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mgeom/MGeomCamMagic919.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mgeom/MGeomCamMagic919.cc	(revision 9661)
@@ -0,0 +1,1363 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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 07/2003 <mailto:blanch@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MGeomCamMagic919
+//
+// This class stores the geometry information of Magic camera,
+// which only has small pixels.
+// All information are copied from tables, see source code.
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MGeomCamMagic919.h"
+
+#include "MGeomPix.h"
+
+ClassImp(MGeomCamMagic919);
+
+// --------------------------------------------------------------------------
+//
+//  This Magic camera has 919 pixels. For geometry and Next Neighbor info see
+//  CreateCam and CreateNN
+//
+MGeomCamMagic919::MGeomCamMagic919(const char *name)
+    : MGeomCam(919, 17, name, 
+	       "Geometry information of Magic Camera with only small pixels")
+{
+    CreateCam();
+    CreateNN();
+    InitGeometry();
+}
+
+// --------------------------------------------------------------------------
+//
+//  This fills the geometry information from a table into the pixel objects.
+//
+void MGeomCamMagic919::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 xtemp[919] = {
+	0, 30, 15, -15, -30, -15, 15, 60, // 0
+	45, 30, 0, -30, -45, -60, -45, -30, // 8
+	0, 30, 45, 90, 75, 60, 45, 15, // 16
+	-15, -45, -60, -75, -90, -75, -60, -45, // 24
+	-15, 15, 45, 60, 75, 120, 105, 90, // 32
+	75, 60, 30, 0, -30, -60, -75, -90, // 40
+	-105, -120, -105, -90, -75, -60, -30, 0, // 48
+	30, 60, 75, 90, 105, 150, 135, 120, // 56
+	105, 90, 75, 45, 15, -15, -45, -75, // 64
+	-90, -105, -120, -135, -150, -135, -120, -105, // 72
+	-90, -75, -45, -15, 15, 45, 75, 90, // 80
+	105, 120, 135, 180, 165, 150, 135, 120, // 88
+	105, 90, 60, 30, 0, -30, -60, -90, // 96
+	-105, -120, -135, -150, -165, -180, -165, -150, // 104
+	-135, -120, -105, -90, -60, -30, 0, 30, // 112
+	60, 90, 105, 120, 135, 150, 165, 210, // 120
+	195, 180, 165, 150, 135, 120, 105, 75, // 128
+	45, 15, -15, -45, -75, -105, -120, -135, // 136
+	-150, -165, -180, -195, -210, -195, -180, -165, // 144
+	-150, -135, -120, -105, -75, -45, -15, 15, // 152
+	45, 75, 105, 120, 135, 150, 165, 180, // 160
+	195, 240, 225, 210, 195, 180, 165, 150, // 168
+	135, 120, 90, 60, 30, 0, -30, -60, // 176
+	-90, -120, -135, -150, -165, -180, -195, -210, // 184
+	-225, -240, -225, -210, -195, -180, -165, -150, // 192
+	-135, -120, -90, -60, -30, 0, 30, 60, // 200
+	90, 120, 135, 150, 165, 180, 195, 210, // 208
+	225, 270, 255, 240, 225, 210, 195, 180, // 216
+	165, 150, 135, 105, 75, 45, 15, -15, // 224
+	-45, -75, -105, -135, -150, -165, -180, -195, // 232
+	-210, -225, -240, -255, -270, -255, -240, -225, // 240
+	-210, -195, -180, -165, -150, -135, -105, -75, // 248
+	-45, -15, 15, 45, 75, 105, 135, 150, // 256
+	165, 180, 195, 210, 225, 240, 255, 300, // 264
+	285, 270, 255, 240, 225, 210, 195, 180, // 272
+	165, 150, 120, 90, 60, 30, 0, -30, // 280
+	-60, -90, -120, -150, -165, -180, -195, -210, // 288
+	-225, -240, -255, -270, -285, -300, -285, -270, // 296
+	-255, -240, -225, -210, -195, -180, -165, -150, // 304
+	-120, -90, -60, -30, 0, 30, 60, 90, // 312
+	120, 150, 165, 180, 195, 210, 225, 240, // 320
+	255, 270, 285, 330, 315, 300, 285, 270, // 328
+	255, 240, 225, 210, 195, 180, 165, 135, // 336
+	105, 75, 45, 15, -15, -45, -75, -105, // 344
+	-135, -165, -180, -195, -210, -225, -240, -255, // 352
+	-270, -285, -300, -315, -330, -315, -300, -285, // 360
+	-270, -255, -240, -225, -210, -195, -180, -165, // 368
+	-135, -105, -75, -45, -15, 15, 45, 75, // 376
+	105, 135, 165, 180, 195, 210, 225, 240, // 384
+	255, 270, 285, 300, 315, 360, 345, 330, // 392
+	315, 300, 285, 270, 255, 240, 225, 210, // 400
+	195, 180, 150, 120, 90, 60, 30, 0, // 408
+	-30, -60, -90, -120, -150, -180, -195, -210, // 416
+	-225, -240, -255, -270, -285, -300, -315, -330, // 424
+	-345, -360, -345, -330, -315, -300, -285, -270, // 432
+	-255, -240, -225, -210, -195, -180, -150, -120, // 440
+	-90, -60, -30, 0, 30, 60, 90, 120, // 448
+	150, 180, 195, 210, 225, 240, 255, 270, // 456
+	285, 300, 315, 330, 345, 390, 375, 360, // 464
+	345, 330, 315, 300, 285, 270, 255, 240, // 472
+	225, 210, 195, 165, 135, 105, 75, 45, // 480
+	15, -15, -45, -75, -105, -135, -165, -195, // 488
+	-210, -225, -240, -255, -270, -285, -300, -315, // 496
+	-330, -345, -360, -375, -390, -375, -360, -345, // 504
+	-330, -315, -300, -285, -270, -255, -240, -225, // 512
+	-210, -195, -165, -135, -105, -75, -45, -15, // 520
+	15, 45, 75, 105, 135, 165, 195, 210, // 528
+	225, 240, 255, 270, 285, 300, 315, 330, // 536
+	345, 360, 375, 420, 405, 390, 375, 360, // 544
+	345, 330, 315, 300, 285, 270, 255, 240, // 552
+	225, 210, 180, 150, 120, 90, 60, 30, // 560
+	0, -30, -60, -90, -120, -150, -180, -210, // 568
+	-225, -240, -255, -270, -285, -300, -315, -330, // 576
+	-345, -360, -375, -390, -405, -420, -405, -390, // 584
+	-375, -360, -345, -330, -315, -300, -285, -270, // 592
+	-255, -240, -225, -210, -180, -150, -120, -90, // 600
+	-60, -30, 0, 30, 60, 90, 120, 150, // 608
+	180, 210, 225, 240, 255, 270, 285, 300, // 616
+	315, 330, 345, 360, 375, 390, 405, 450, // 624
+	435, 420, 405, 390, 375, 360, 345, 330, // 632
+	315, 300, 285, 270, 255, 240, 225, 195, // 640
+	165, 135, 105, 75, 45, 15, -15, -45, // 648
+	-75, -105, -135, -165, -195, -225, -240, -255, // 656
+	-270, -285, -300, -315, -330, -345, -360, -375, // 664
+	-390, -405, -420, -435, -450, -435, -420, -405, // 672
+	-390, -375, -360, -345, -330, -315, -300, -285, // 680
+	-270, -255, -240, -225, -195, -165, -135, -105, // 688
+	-75, -45, -15, 15, 45, 75, 105, 135, // 696
+	165, 195, 225, 240, 255, 270, 285, 300, // 704
+	315, 330, 345, 360, 375, 390, 405, 420, // 712
+	435, 480, 465, 450, 435, 420, 405, 390, // 720
+	375, 360, 345, 330, 315, 300, 285, 270, // 728
+	255, 240, 210, 180, 150, 120, 90, 60, // 736
+	30, 0, -30, -60, -90, -120, -150, -180, // 744
+	-210, -240, -255, -270, -285, -300, -315, -330, // 752
+	-345, -360, -375, -390, -405, -420, -435, -450, // 760
+	-465, -480, -465, -450, -435, -420, -405, -390, // 768
+	-375, -360, -345, -330, -315, -300, -285, -270, // 776
+	-255, -240, -210, -180, -150, -120, -90, -60, // 784
+	-30, 0, 30, 60, 90, 120, 150, 180, // 792
+	210, 240, 255, 270, 285, 300, 315, 330, // 800
+	345, 360, 375, 390, 405, 420, 435, 450, // 808
+	465, 510, 495, 480, 465, 450, 435, 420, // 816
+	405, 390, 375, 360, 345, 330, 315, 300, // 824
+	285, 270, 255, 225, 195, 165, 135, 105, // 832
+	75, 45, 15, -15, -45, -75, -105, -135, // 840
+	-165, -195, -225, -255, -270, -285, -300, -315, // 848
+	-330, -345, -360, -375, -390, -405, -420, -435, // 856
+	-450, -465, -480, -495, -510, -495, -480, -465, // 864
+	-450, -435, -420, -405, -390, -375, -360, -345, // 872
+	-330, -315, -300, -285, -270, -255, -225, -195, // 880
+	-165, -135, -105, -75, -45, -15, 15, 45, // 888
+	75, 105, 135, 165, 195, 225, 255, 270, // 896
+	285, 300, 315, 330, 345, 360, 375, 390, // 904
+	405, 420, 435, 450, 465, 480, 495//919
+  };
+
+  const float ytemp[919] = {
+	0, 0, 25.9808, 25.9808, -0, -25.9808, -25.9808, 0, // 0
+	25.9808, 51.9615, 51.9615, 51.9615, 25.9808, -0, -25.9808, -51.9615, // 8
+	-51.9615, -51.9615, -25.9808, 0, 25.9808, 51.9615, 77.9423, 77.9423, // 16
+	77.9423, 77.9423, 51.9615, 25.9808, -0, -25.9808, -51.9615, -77.9423, // 24
+	-77.9423, -77.9423, -77.9423, -51.9615, -25.9808, 0, 25.9808, 51.9615, // 32
+	77.9423, 103.923, 103.923, 103.923, 103.923, 103.923, 77.9423, 51.9615, // 40
+	25.9808, -0, -25.9808, -51.9615, -77.9423, -103.923, -103.923, -103.923, // 48
+	-103.923, -103.923, -77.9423, -51.9615, -25.9808, 0, 25.9808, 51.9615, // 56
+	77.9423, 103.923, 129.904, 129.904, 129.904, 129.904, 129.904, 129.904, // 64
+	103.923, 77.9423, 51.9615, 25.9808, -0, -25.9808, -51.9615, -77.9423, // 72
+	-103.923, -129.904, -129.904, -129.904, -129.904, -129.904, -129.904, -103.923, // 80
+	-77.9423, -51.9615, -25.9808, 0, 25.9808, 51.9615, 77.9423, 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.9423, 51.9615, 25.9808, -0, -25.9808, -51.9615, // 104
+	-77.9423, -103.923, -129.904, -155.885, -155.885, -155.885, -155.885, -155.885, // 112
+	-155.885, -155.885, -129.904, -103.923, -77.9423, -51.9615, -25.9808, 0, // 120
+	25.9808, 51.9615, 77.9423, 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.9423, 51.9615, 25.9808, -0, -25.9808, -51.9615, -77.9423, // 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.9423, -51.9615, // 160
+	-25.9808, 0, 25.9808, 51.9615, 77.9423, 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.9423, 51.9615, // 184
+	25.9808, -0, -25.9808, -51.9615, -77.9423, -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.9423, -51.9615, // 208
+	-25.9808, 0, 25.9808, 51.9615, 77.9423, 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.9423, 51.9615, 25.9808, -0, -25.9808, -51.9615, -77.9423, // 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.9423, -51.9615, -25.9808, 0, // 264
+	25.9808, 51.9615, 77.9423, 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.9423, 51.9615, 25.9808, -0, -25.9808, -51.9615, // 296
+	-77.9423, -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
+	-77.9423, -51.9615, -25.9808, 0, 25.9808, 51.9615, 77.9423, 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.9423, 51.9615, 25.9808, -0, -25.9808, -51.9615, -77.9423, // 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.9423, -51.9615, -25.9808, 0, 25.9808, 51.9615, // 392
+	77.9423, 103.923, 129.904, 155.885, 181.865, 207.846, 233.827, 259.808, // 400
+	285.788, 311.769, 311.769, 311.769, 311.769, 311.769, 311.769, 311.769, // 408
+	311.769, 311.769, 311.769, 311.769, 311.769, 311.769, 285.788, 259.808, // 416
+	233.827, 207.846, 181.865, 155.885, 129.904, 103.923, 77.9423, 51.9615, // 424
+	25.9808, -0, -25.9808, -51.9615, -77.9423, -103.923, -129.904, -155.885, // 432
+	-181.865, -207.846, -233.827, -259.808, -285.788, -311.769, -311.769, -311.769, // 440
+	-311.769, -311.769, -311.769, -311.769, -311.769, -311.769, -311.769, -311.769, // 448
+	-311.769, -311.769, -285.788, -259.808, -233.827, -207.846, -181.865, -155.885, // 456
+	-129.904, -103.923, -77.9423, -51.9615, -25.9808, 0, 25.9808, 51.9615, // 464
+	77.9423, 103.923, 129.904, 155.885, 181.865, 207.846, 233.827, 259.808, // 472
+	285.788, 311.769, 337.75, 337.75, 337.75, 337.75, 337.75, 337.75, // 480
+	337.75, 337.75, 337.75, 337.75, 337.75, 337.75, 337.75, 337.75, // 488
+	311.769, 285.788, 259.808, 233.827, 207.846, 181.865, 155.885, 129.904, // 496
+	103.923, 77.9423, 51.9615, 25.9808, -0, -25.9808, -51.9615, -77.9423, // 504
+	-103.923, -129.904, -155.885, -181.865, -207.846, -233.827, -259.808, -285.788, // 512
+	-311.769, -337.75, -337.75, -337.75, -337.75, -337.75, -337.75, -337.75, // 520
+	-337.75, -337.75, -337.75, -337.75, -337.75, -337.75, -337.75, -311.769, // 528
+	-285.788, -259.808, -233.827, -207.846, -181.865, -155.885, -129.904, -103.923, // 536
+	-77.9423, -51.9615, -25.9808, 0, 25.9808, 51.9615, 77.9423, 103.923, // 544
+	129.904, 155.885, 181.865, 207.846, 233.827, 259.808, 285.788, 311.769, // 552
+	337.75, 363.731, 363.731, 363.731, 363.731, 363.731, 363.731, 363.731, // 560
+	363.731, 363.731, 363.731, 363.731, 363.731, 363.731, 363.731, 363.731, // 568
+	337.75, 311.769, 285.788, 259.808, 233.827, 207.846, 181.865, 155.885, // 576
+	129.904, 103.923, 77.9423, 51.9615, 25.9808, -0, -25.9808, -51.9615, // 584
+	-77.9423, -103.923, -129.904, -155.885, -181.865, -207.846, -233.827, -259.808, // 592
+	-285.788, -311.769, -337.75, -363.731, -363.731, -363.731, -363.731, -363.731, // 600
+	-363.731, -363.731, -363.731, -363.731, -363.731, -363.731, -363.731, -363.731, // 608
+	-363.731, -363.731, -337.75, -311.769, -285.788, -259.808, -233.827, -207.846, // 616
+	-181.865, -155.885, -129.904, -103.923, -77.9423, -51.9615, -25.9808, 0, // 624
+	25.9808, 51.9615, 77.9423, 103.923, 129.904, 155.885, 181.865, 207.846, // 632
+	233.827, 259.808, 285.788, 311.769, 337.75, 363.731, 389.711, 389.711, // 640
+	389.711, 389.711, 389.711, 389.711, 389.711, 389.711, 389.711, 389.711, // 648
+	389.711, 389.711, 389.711, 389.711, 389.711, 389.711, 363.731, 337.75, // 656
+	311.769, 285.788, 259.808, 233.827, 207.846, 181.865, 155.885, 129.904, // 664
+	103.923, 77.9423, 51.9615, 25.9808, -0, -25.9808, -51.9615, -77.9423, // 672
+	-103.923, -129.904, -155.885, -181.865, -207.846, -233.827, -259.808, -285.788, // 680
+	-311.769, -337.75, -363.731, -389.711, -389.711, -389.711, -389.711, -389.711, // 688
+	-389.711, -389.711, -389.711, -389.711, -389.711, -389.711, -389.711, -389.711, // 696
+	-389.711, -389.711, -389.711, -363.731, -337.75, -311.769, -285.788, -259.808, // 704
+	-233.827, -207.846, -181.865, -155.885, -129.904, -103.923, -77.9423, -51.9615, // 712
+	-25.9808, 0, 25.9808, 51.9615, 77.9423, 103.923, 129.904, 155.885, // 720
+	181.865, 207.846, 233.827, 259.808, 285.788, 311.769, 337.75, 363.731, // 728
+	389.711, 415.692, 415.692, 415.692, 415.692, 415.692, 415.692, 415.692, // 736
+	415.692, 415.692, 415.692, 415.692, 415.692, 415.692, 415.692, 415.692, // 744
+	415.692, 415.692, 389.711, 363.731, 337.75, 311.769, 285.788, 259.808, // 752
+	233.827, 207.846, 181.865, 155.885, 129.904, 103.923, 77.9423, 51.9615, // 760
+	25.9808, -0, -25.9808, -51.9615, -77.9423, -103.923, -129.904, -155.885, // 768
+	-181.865, -207.846, -233.827, -259.808, -285.788, -311.769, -337.75, -363.731, // 776
+	-389.711, -415.692, -415.692, -415.692, -415.692, -415.692, -415.692, -415.692, // 784
+	-415.692, -415.692, -415.692, -415.692, -415.692, -415.692, -415.692, -415.692, // 792
+	-415.692, -415.692, -389.711, -363.731, -337.75, -311.769, -285.788, -259.808, // 800
+	-233.827, -207.846, -181.865, -155.885, -129.904, -103.923, -77.9423, -51.9615, // 808
+	-25.9808, 0, 25.9808, 51.9615, 77.9423, 103.923, 129.904, 155.885, // 816
+	181.865, 207.846, 233.827, 259.808, 285.788, 311.769, 337.75, 363.731, // 824
+	389.711, 415.692, 441.673, 441.673, 441.673, 441.673, 441.673, 441.673, // 832
+	441.673, 441.673, 441.673, 441.673, 441.673, 441.673, 441.673, 441.673, // 840
+	441.673, 441.673, 441.673, 441.673, 415.692, 389.711, 363.731, 337.75, // 848
+	311.769, 285.788, 259.808, 233.827, 207.846, 181.865, 155.885, 129.904, // 856
+	103.923, 77.9423, 51.9615, 25.9808, -0, -25.9808, -51.9615, -77.9423, // 864
+	-103.923, -129.904, -155.885, -181.865, -207.846, -233.827, -259.808, -285.788, // 872
+	-311.769, -337.75, -363.731, -389.711, -415.692, -441.673, -441.673, -441.673, // 880
+	-441.673, -441.673, -441.673, -441.673, -441.673, -441.673, -441.673, -441.673, // 888
+	-441.673, -441.673, -441.673, -441.673, -441.673, -441.673, -441.673, -415.692, // 896
+	-389.711, -363.731, -337.75, -311.769, -285.788, -259.808, -233.827, -207.846, // 904
+	-181.865, -155.885, -129.904, -103.923, -77.9423, -51.9615, -25.9808 //919
+  };
+
+  const float rtemp[919] = {
+	30, 30, 30, 30, 30, 30, 30, 30, // 0
+	30, 30, 30, 30, 30, 30, 30, 30, // 8
+	30, 30, 30, 30, 30, 30, 30, 30, // 16
+	30, 30, 30, 30, 30, 30, 30, 30, // 24
+	30, 30, 30, 30, 30, 30, 30, 30, // 32
+	30, 30, 30, 30, 30, 30, 30, 30, // 40
+	30, 30, 30, 30, 30, 30, 30, 30, // 48
+	30, 30, 30, 30, 30, 30, 30, 30, // 56
+	30, 30, 30, 30, 30, 30, 30, 30, // 64
+	30, 30, 30, 30, 30, 30, 30, 30, // 72
+	30, 30, 30, 30, 30, 30, 30, 30, // 80
+	30, 30, 30, 30, 30, 30, 30, 30, // 88
+	30, 30, 30, 30, 30, 30, 30, 30, // 96
+	30, 30, 30, 30, 30, 30, 30, 30, // 104
+	30, 30, 30, 30, 30, 30, 30, 30, // 112
+	30, 30, 30, 30, 30, 30, 30, 30, // 120
+	30, 30, 30, 30, 30, 30, 30, 30, // 128
+	30, 30, 30, 30, 30, 30, 30, 30, // 136
+	30, 30, 30, 30, 30, 30, 30, 30, // 144
+	30, 30, 30, 30, 30, 30, 30, 30, // 152
+	30, 30, 30, 30, 30, 30, 30, 30, // 160
+	30, 30, 30, 30, 30, 30, 30, 30, // 168
+	30, 30, 30, 30, 30, 30, 30, 30, // 176
+	30, 30, 30, 30, 30, 30, 30, 30, // 184
+	30, 30, 30, 30, 30, 30, 30, 30, // 192
+	30, 30, 30, 30, 30, 30, 30, 30, // 200
+	30, 30, 30, 30, 30, 30, 30, 30, // 208
+	30, 30, 30, 30, 30, 30, 30, 30, // 216
+	30, 30, 30, 30, 30, 30, 30, 30, // 224
+	30, 30, 30, 30, 30, 30, 30, 30, // 232
+	30, 30, 30, 30, 30, 30, 30, 30, // 240
+	30, 30, 30, 30, 30, 30, 30, 30, // 248
+	30, 30, 30, 30, 30, 30, 30, 30, // 256
+	30, 30, 30, 30, 30, 30, 30, 30, // 264
+	30, 30, 30, 30, 30, 30, 30, 30, // 272
+	30, 30, 30, 30, 30, 30, 30, 30, // 280
+	30, 30, 30, 30, 30, 30, 30, 30, // 288
+	30, 30, 30, 30, 30, 30, 30, 30, // 296
+	30, 30, 30, 30, 30, 30, 30, 30, // 304
+	30, 30, 30, 30, 30, 30, 30, 30, // 312
+	30, 30, 30, 30, 30, 30, 30, 30, // 320
+	30, 30, 30, 30, 30, 30, 30, 30, // 328
+	30, 30, 30, 30, 30, 30, 30, 30, // 336
+	30, 30, 30, 30, 30, 30, 30, 30, // 344
+	30, 30, 30, 30, 30, 30, 30, 30, // 352
+	30, 30, 30, 30, 30, 30, 30, 30, // 360
+	30, 30, 30, 30, 30, 30, 30, 30, // 368
+	30, 30, 30, 30, 30, 30, 30, 30, // 376
+	30, 30, 30, 30, 30, 30, 30, 30, // 384
+	30, 30, 30, 30, 30, 30, 30, 30, // 392
+	30, 30, 30, 30, 30, 30, 30, 30, // 400
+	30, 30, 30, 30, 30, 30, 30, 30, // 408
+	30, 30, 30, 30, 30, 30, 30, 30, // 416
+	30, 30, 30, 30, 30, 30, 30, 30, // 424
+	30, 30, 30, 30, 30, 30, 30, 30, // 432
+	30, 30, 30, 30, 30, 30, 30, 30, // 440
+	30, 30, 30, 30, 30, 30, 30, 30, // 448
+	30, 30, 30, 30, 30, 30, 30, 30, // 456
+	30, 30, 30, 30, 30, 30, 30, 30, // 464
+	30, 30, 30, 30, 30, 30, 30, 30, // 472
+	30, 30, 30, 30, 30, 30, 30, 30, // 480
+	30, 30, 30, 30, 30, 30, 30, 30, // 488
+	30, 30, 30, 30, 30, 30, 30, 30, // 496
+	30, 30, 30, 30, 30, 30, 30, 30, // 504
+	30, 30, 30, 30, 30, 30, 30, 30, // 512
+	30, 30, 30, 30, 30, 30, 30, 30, // 520
+	30, 30, 30, 30, 30, 30, 30, 30, // 528
+	30, 30, 30, 30, 30, 30, 30, 30, // 536
+	30, 30, 30, 30, 30, 30, 30, 30, // 544
+	30, 30, 30, 30, 30, 30, 30, 30, // 552
+	30, 30, 30, 30, 30, 30, 30, 30, // 560
+	30, 30, 30, 30, 30, 30, 30, 30, // 568
+	30, 30, 30, 30, 30, 30, 30, 30, // 576
+	30, 30, 30, 30, 30, 30, 30, 30, // 584
+	30, 30, 30, 30, 30, 30, 30, 30, // 592
+	30, 30, 30, 30, 30, 30, 30, 30, // 600
+	30, 30, 30, 30, 30, 30, 30, 30, // 608
+	30, 30, 30, 30, 30, 30, 30, 30, // 616
+	30, 30, 30, 30, 30, 30, 30, 30, // 624
+	30, 30, 30, 30, 30, 30, 30, 30, // 632
+	30, 30, 30, 30, 30, 30, 30, 30, // 640
+	30, 30, 30, 30, 30, 30, 30, 30, // 648
+	30, 30, 30, 30, 30, 30, 30, 30, // 656
+	30, 30, 30, 30, 30, 30, 30, 30, // 664
+	30, 30, 30, 30, 30, 30, 30, 30, // 672
+	30, 30, 30, 30, 30, 30, 30, 30, // 680
+	30, 30, 30, 30, 30, 30, 30, 30, // 688
+	30, 30, 30, 30, 30, 30, 30, 30, // 696
+	30, 30, 30, 30, 30, 30, 30, 30, // 704
+	30, 30, 30, 30, 30, 30, 30, 30, // 712
+	30, 30, 30, 30, 30, 30, 30, 30, // 720
+	30, 30, 30, 30, 30, 30, 30, 30, // 728
+	30, 30, 30, 30, 30, 30, 30, 30, // 736
+	30, 30, 30, 30, 30, 30, 30, 30, // 744
+	30, 30, 30, 30, 30, 30, 30, 30, // 752
+	30, 30, 30, 30, 30, 30, 30, 30, // 760
+	30, 30, 30, 30, 30, 30, 30, 30, // 768
+	30, 30, 30, 30, 30, 30, 30, 30, // 776
+	30, 30, 30, 30, 30, 30, 30, 30, // 784
+	30, 30, 30, 30, 30, 30, 30, 30, // 792
+	30, 30, 30, 30, 30, 30, 30, 30, // 800
+	30, 30, 30, 30, 30, 30, 30, 30, // 808
+	30, 30, 30, 30, 30, 30, 30, 30, // 816
+	30, 30, 30, 30, 30, 30, 30, 30, // 824
+	30, 30, 30, 30, 30, 30, 30, 30, // 832
+	30, 30, 30, 30, 30, 30, 30, 30, // 840
+	30, 30, 30, 30, 30, 30, 30, 30, // 848
+	30, 30, 30, 30, 30, 30, 30, 30, // 856
+	30, 30, 30, 30, 30, 30, 30, 30, // 864
+	30, 30, 30, 30, 30, 30, 30, 30, // 872
+	30, 30, 30, 30, 30, 30, 30, 30, // 880
+	30, 30, 30, 30, 30, 30, 30, 30, // 888
+	30, 30, 30, 30, 30, 30, 30, 30, // 896
+	30, 30, 30, 30, 30, 30, 30, 30, // 904
+	30, 30, 30, 30, 30, 30, 30//919
+};
+
+    //
+    //   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 MGeomCamMagic919::CreateNN()
+{
+  const Short_t nn[919][6] = {       // Neighbours 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,	398,	468},
+	{  271,	272,	331,	333,	398,	399},
+	{  272,	273,	332,	334,	399,	400},
+	{  273,	274,	333,	335,	400,	401},
+	{  274,	275,	334,	336,	401,	402},
+	{  275,	276,	335,	337,	402,	403},
+	{  276,	277,	336,	338,	403,	404},
+	{  277,	278,	337,	339,	404,	405},
+	{  278,	279,	338,	340,	405,	406},
+	{  279,	280,	339,	341,	406,	407},// 340
+	{  280,	281,	340,	342,	407,	408},
+	{  281,	341,	343,	408,	409,	410},
+	{  281,	282,	342,	344,	410,	411},
+	{  282,	283,	343,	345,	411,	412},
+	{  283,	284,	344,	346,	412,	413},
+	{  284,	285,	345,	347,	413,	414},
+	{  285,	286,	346,	348,	414,	415},
+	{  286,	287,	347,	349,	415,	416},
+	{  287,	288,	348,	350,	416,	417},
+	{  288,	289,	349,	351,	417,	418},
+	{  289,	290,	350,	352,	418,	419},
+	{  290,	291,	351,	353,	419,	420},
+	{  291,	352,	354,	420,	421,	422},
+	{  291,	292,	353,	355,	422,	423},
+	{  292,	293,	354,	356,	423,	424},
+	{  293,	294,	355,	357,	424,	425},
+	{  294,	295,	356,	358,	425,	426},
+	{  295,	296,	357,	359,	426,	427},
+	{  296,	297,	358,	360,	427,	428},
+	{  297,	298,	359,	361,	428,	429},// 360
+	{  298,	299,	360,	362,	429,	430},
+	{  299,	300,	361,	363,	430,	431},
+	{  300,	301,	362,	364,	431,	432},
+	{  301,	363,	365,	432,	433,	434},
+	{  301,	302,	364,	366,	434,	435},
+	{  302,	303,	365,	367,	435,	436},
+	{  303,	304,	366,	368,	436,	437},
+	{  304,	305,	367,	369,	437,	438},
+	{  305,	306,	368,	370,	438,	439},
+	{  306,	307,	369,	371,	439,	440},
+	{  307,	308,	370,	372,	440,	441},
+	{  308,	309,	371,	373,	441,	442},
+	{  309,	310,	372,	374,	442,	443},
+	{  310,	311,	373,	375,	443,	444},
+	{  311,	374,	376,	444,	445,	446},
+	{  311,	312,	375,	377,	446,	447},
+	{  312,	313,	376,	378,	447,	448},
+	{  313,	314,	377,	379,	448,	449},
+	{  314,	315,	378,	380,	449,	450},
+	{  315,	316,	379,	381,	450,	451},// 380
+	{  316,	317,	380,	382,	451,	452},
+	{  317,	318,	381,	383,	452,	453},
+	{  318,	319,	382,	384,	453,	454},
+	{  319,	320,	383,	385,	454,	455},
+	{  320,	321,	384,	386,	455,	456},
+	{  321,	385,	387,	456,	457,	458},
+	{  321,	322,	386,	388,	458,	459},
+	{  322,	323,	387,	389,	459,	460},
+	{  323,	324,	388,	390,	460,	461},
+	{  324,	325,	389,	391,	461,	462},
+	{  325,	326,	390,	392,	462,	463},
+	{  326,	327,	391,	393,	463,	464},
+	{  327,	328,	392,	394,	464,	465},
+	{  328,	329,	393,	395,	465,	466},
+	{  329,	330,	394,	396,	466,	467},
+	{  271,	330,	331,	395,	467,	468},
+	{  331,	398,	468,	469,	470,	546},
+	{  331,	332,	397,	399,	470,	471},
+	{  332,	333,	398,	400,	471,	472},
+	{  333,	334,	399,	401,	472,	473},// 400
+	{  334,	335,	400,	402,	473,	474},
+	{  335,	336,	401,	403,	474,	475},
+	{  336,	337,	402,	404,	475,	476},
+	{  337,	338,	403,	405,	476,	477},
+	{  338,	339,	404,	406,	477,	478},
+	{  339,	340,	405,	407,	478,	479},
+	{  340,	341,	406,	408,	479,	480},
+	{  341,	342,	407,	409,	480,	481},
+	{  342,	408,	410,	481,	482,	483},
+	{  342,	343,	409,	411,	483,	484},
+	{  343,	344,	410,	412,	484,	485},
+	{  344,	345,	411,	413,	485,	486},
+	{  345,	346,	412,	414,	486,	487},
+	{  346,	347,	413,	415,	487,	488},
+	{  347,	348,	414,	416,	488,	489},
+	{  348,	349,	415,	417,	489,	490},
+	{  349,	350,	416,	418,	490,	491},
+	{  350,	351,	417,	419,	491,	492},
+	{  351,	352,	418,	420,	492,	493},
+	{  352,	353,	419,	421,	493,	494},// 420
+	{  353,	420,	422,	494,	495,	496},
+	{  353,	354,	421,	423,	496,	497},
+	{  354,	355,	422,	424,	497,	498},
+	{  355,	356,	423,	425,	498,	499},
+	{  356,	357,	424,	426,	499,	500},
+	{  357,	358,	425,	427,	500,	501},
+	{  358,	359,	426,	428,	501,	502},
+	{  359,	360,	427,	429,	502,	503},
+	{  360,	361,	428,	430,	503,	504},
+	{  361,	362,	429,	431,	504,	505},
+	{  362,	363,	430,	432,	505,	506},
+	{  363,	364,	431,	433,	506,	507},
+	{  364,	432,	434,	507,	508,	509},
+	{  364,	365,	433,	435,	509,	510},
+	{  365,	366,	434,	436,	510,	511},
+	{  366,	367,	435,	437,	511,	512},
+	{  367,	368,	436,	438,	512,	513},
+	{  368,	369,	437,	439,	513,	514},
+	{  369,	370,	438,	440,	514,	515},
+	{  370,	371,	439,	441,	515,	516},// 440
+	{  371,	372,	440,	442,	516,	517},
+	{  372,	373,	441,	443,	517,	518},
+	{  373,	374,	442,	444,	518,	519},
+	{  374,	375,	443,	445,	519,	520},
+	{  375,	444,	446,	520,	521,	522},
+	{  375,	376,	445,	447,	522,	523},
+	{  376,	377,	446,	448,	523,	524},
+	{  377,	378,	447,	449,	524,	525},
+	{  378,	379,	448,	450,	525,	526},
+	{  379,	380,	449,	451,	526,	527},
+	{  380,	381,	450,	452,	527,	528},
+	{  381,	382,	451,	453,	528,	529},
+	{  382,	383,	452,	454,	529,	530},
+	{  383,	384,	453,	455,	530,	531},
+	{  384,	385,	454,	456,	531,	532},
+	{  385,	386,	455,	457,	532,	533},
+	{  386,	456,	458,	533,	534,	535},
+	{  386,	387,	457,	459,	535,	536},
+	{  387,	388,	458,	460,	536,	537},
+	{  388,	389,	459,	461,	537,	538},// 460
+	{  389,	390,	460,	462,	538,	539},
+	{  390,	391,	461,	463,	539,	540},
+	{  391,	392,	462,	464,	540,	541},
+	{  392,	393,	463,	465,	541,	542},
+	{  393,	394,	464,	466,	542,	543},
+	{  394,	395,	465,	467,	543,	544},
+	{  395,	396,	466,	468,	544,	545},
+	{  331,	396,	397,	467,	545,	546},
+	{  397,	470,	546,	547,	548,	630},
+	{  397,	398,	469,	471,	548,	549},
+	{  398,	399,	470,	472,	549,	550},
+	{  399,	400,	471,	473,	550,	551},
+	{  400,	401,	472,	474,	551,	552},
+	{  401,	402,	473,	475,	552,	553},
+	{  402,	403,	474,	476,	553,	554},
+	{  403,	404,	475,	477,	554,	555},
+	{  404,	405,	476,	478,	555,	556},
+	{  405,	406,	477,	479,	556,	557},
+	{  406,	407,	478,	480,	557,	558},
+	{  407,	408,	479,	481,	558,	559},// 480
+	{  408,	409,	480,	482,	559,	560},
+	{  409,	481,	483,	560,	561,	562},
+	{  409,	410,	482,	484,	562,	563},
+	{  410,	411,	483,	485,	563,	564},
+	{  411,	412,	484,	486,	564,	565},
+	{  412,	413,	485,	487,	565,	566},
+	{  413,	414,	486,	488,	566,	567},
+	{  414,	415,	487,	489,	567,	568},
+	{  415,	416,	488,	490,	568,	569},
+	{  416,	417,	489,	491,	569,	570},
+	{  417,	418,	490,	492,	570,	571},
+	{  418,	419,	491,	493,	571,	572},
+	{  419,	420,	492,	494,	572,	573},
+	{  420,	421,	493,	495,	573,	574},
+	{  421,	494,	496,	574,	575,	576},
+	{  421,	422,	495,	497,	576,	577},
+	{  422,	423,	496,	498,	577,	578},
+	{  423,	424,	497,	499,	578,	579},
+	{  424,	425,	498,	500,	579,	580},
+	{  425,	426,	499,	501,	580,	581},// 500
+	{  426,	427,	500,	502,	581,	582},
+	{  427,	428,	501,	503,	582,	583},
+	{  428,	429,	502,	504,	583,	584},
+	{  429,	430,	503,	505,	584,	585},
+	{  430,	431,	504,	506,	585,	586},
+	{  431,	432,	505,	507,	586,	587},
+	{  432,	433,	506,	508,	587,	588},
+	{  433,	507,	509,	588,	589,	590},
+	{  433,	434,	508,	510,	590,	591},
+	{  434,	435,	509,	511,	591,	592},
+	{  435,	436,	510,	512,	592,	593},
+	{  436,	437,	511,	513,	593,	594},
+	{  437,	438,	512,	514,	594,	595},
+	{  438,	439,	513,	515,	595,	596},
+	{  439,	440,	514,	516,	596,	597},
+	{  440,	441,	515,	517,	597,	598},
+	{  441,	442,	516,	518,	598,	599},
+	{  442,	443,	517,	519,	599,	600},
+	{  443,	444,	518,	520,	600,	601},
+	{  444,	445,	519,	521,	601,	602},// 520
+	{  445,	520,	522,	602,	603,	604},
+	{  445,	446,	521,	523,	604,	605},
+	{  446,	447,	522,	524,	605,	606},
+	{  447,	448,	523,	525,	606,	607},
+	{  448,	449,	524,	526,	607,	608},
+	{  449,	450,	525,	527,	608,	609},
+	{  450,	451,	526,	528,	609,	610},
+	{  451,	452,	527,	529,	610,	611},
+	{  452,	453,	528,	530,	611,	612},
+	{  453,	454,	529,	531,	612,	613},
+	{  454,	455,	530,	532,	613,	614},
+	{  455,	456,	531,	533,	614,	615},
+	{  456,	457,	532,	534,	615,	616},
+	{  457,	533,	535,	616,	617,	618},
+	{  457,	458,	534,	536,	618,	619},
+	{  458,	459,	535,	537,	619,	620},
+	{  459,	460,	536,	538,	620,	621},
+	{  460,	461,	537,	539,	621,	622},
+	{  461,	462,	538,	540,	622,	623},
+	{  462,	463,	539,	541,	623,	624},// 540
+	{  463,	464,	540,	542,	624,	625},
+	{  464,	465,	541,	543,	625,	626},
+	{  465,	466,	542,	544,	626,	627},
+	{  466,	467,	543,	545,	627,	628},
+	{  467,	468,	544,	546,	628,	629},
+	{  397,	468,	469,	545,	629,	630},
+	{  469,	548,	630,	631,	632,	720},
+	{  469,	470,	547,	549,	632,	633},
+	{  470,	471,	548,	550,	633,	634},
+	{  471,	472,	549,	551,	634,	635},
+	{  472,	473,	550,	552,	635,	636},
+	{  473,	474,	551,	553,	636,	637},
+	{  474,	475,	552,	554,	637,	638},
+	{  475,	476,	553,	555,	638,	639},
+	{  476,	477,	554,	556,	639,	640},
+	{  477,	478,	555,	557,	640,	641},
+	{  478,	479,	556,	558,	641,	642},
+	{  479,	480,	557,	559,	642,	643},
+	{  480,	481,	558,	560,	643,	644},
+	{  481,	482,	559,	561,	644,	645},// 560
+	{  482,	560,	562,	645,	646,	647},
+	{  482,	483,	561,	563,	647,	648},
+	{  483,	484,	562,	564,	648,	649},
+	{  484,	485,	563,	565,	649,	650},
+	{  485,	486,	564,	566,	650,	651},
+	{  486,	487,	565,	567,	651,	652},
+	{  487,	488,	566,	568,	652,	653},
+	{  488,	489,	567,	569,	653,	654},
+	{  489,	490,	568,	570,	654,	655},
+	{  490,	491,	569,	571,	655,	656},
+	{  491,	492,	570,	572,	656,	657},
+	{  492,	493,	571,	573,	657,	658},
+	{  493,	494,	572,	574,	658,	659},
+	{  494,	495,	573,	575,	659,	660},
+	{  495,	574,	576,	660,	661,	662},
+	{  495,	496,	575,	577,	662,	663},
+	{  496,	497,	576,	578,	663,	664},
+	{  497,	498,	577,	579,	664,	665},
+	{  498,	499,	578,	580,	665,	666},
+	{  499,	500,	579,	581,	666,	667},// 580
+	{  500,	501,	580,	582,	667,	668},
+	{  501,	502,	581,	583,	668,	669},
+	{  502,	503,	582,	584,	669,	670},
+	{  503,	504,	583,	585,	670,	671},
+	{  504,	505,	584,	586,	671,	672},
+	{  505,	506,	585,	587,	672,	673},
+	{  506,	507,	586,	588,	673,	674},
+	{  507,	508,	587,	589,	674,	675},
+	{  508,	588,	590,	675,	676,	677},
+	{  508,	509,	589,	591,	677,	678},
+	{  509,	510,	590,	592,	678,	679},
+	{  510,	511,	591,	593,	679,	680},
+	{  511,	512,	592,	594,	680,	681},
+	{  512,	513,	593,	595,	681,	682},
+	{  513,	514,	594,	596,	682,	683},
+	{  514,	515,	595,	597,	683,	684},
+	{  515,	516,	596,	598,	684,	685},
+	{  516,	517,	597,	599,	685,	686},
+	{  517,	518,	598,	600,	686,	687},
+	{  518,	519,	599,	601,	687,	688},// 600
+	{  519,	520,	600,	602,	688,	689},
+	{  520,	521,	601,	603,	689,	690},
+	{  521,	602,	604,	690,	691,	692},
+	{  521,	522,	603,	605,	692,	693},
+	{  522,	523,	604,	606,	693,	694},
+	{  523,	524,	605,	607,	694,	695},
+	{  524,	525,	606,	608,	695,	696},
+	{  525,	526,	607,	609,	696,	697},
+	{  526,	527,	608,	610,	697,	698},
+	{  527,	528,	609,	611,	698,	699},
+	{  528,	529,	610,	612,	699,	700},
+	{  529,	530,	611,	613,	700,	701},
+	{  530,	531,	612,	614,	701,	702},
+	{  531,	532,	613,	615,	702,	703},
+	{  532,	533,	614,	616,	703,	704},
+	{  533,	534,	615,	617,	704,	705},
+	{  534,	616,	618,	705,	706,	707},
+	{  534,	535,	617,	619,	707,	708},
+	{  535,	536,	618,	620,	708,	709},
+	{  536,	537,	619,	621,	709,	710},// 620
+	{  537,	538,	620,	622,	710,	711},
+	{  538,	539,	621,	623,	711,	712},
+	{  539,	540,	622,	624,	712,	713},
+	{  540,	541,	623,	625,	713,	714},
+	{  541,	542,	624,	626,	714,	715},
+	{  542,	543,	625,	627,	715,	716},
+	{  543,	544,	626,	628,	716,	717},
+	{  544,	545,	627,	629,	717,	718},
+	{  545,	546,	628,	630,	718,	719},
+	{  469,	546,	547,	629,	719,	720},
+	{  547,	632,	720,	721,	722,	816},
+	{  547,	548,	631,	633,	722,	723},
+	{  548,	549,	632,	634,	723,	724},
+	{  549,	550,	633,	635,	724,	725},
+	{  550,	551,	634,	636,	725,	726},
+	{  551,	552,	635,	637,	726,	727},
+	{  552,	553,	636,	638,	727,	728},
+	{  553,	554,	637,	639,	728,	729},
+	{  554,	555,	638,	640,	729,	730},
+	{  555,	556,	639,	641,	730,	731},// 640
+	{  556,	557,	640,	642,	731,	732},
+	{  557,	558,	641,	643,	732,	733},
+	{  558,	559,	642,	644,	733,	734},
+	{  559,	560,	643,	645,	734,	735},
+	{  560,	561,	644,	646,	735,	736},
+	{  561,	645,	647,	736,	737,	738},
+	{  561,	562,	646,	648,	738,	739},
+	{  562,	563,	647,	649,	739,	740},
+	{  563,	564,	648,	650,	740,	741},
+	{  564,	565,	649,	651,	741,	742},
+	{  565,	566,	650,	652,	742,	743},
+	{  566,	567,	651,	653,	743,	744},
+	{  567,	568,	652,	654,	744,	745},
+	{  568,	569,	653,	655,	745,	746},
+	{  569,	570,	654,	656,	746,	747},
+	{  570,	571,	655,	657,	747,	748},
+	{  571,	572,	656,	658,	748,	749},
+	{  572,	573,	657,	659,	749,	750},
+	{  573,	574,	658,	660,	750,	751},
+	{  574,	575,	659,	661,	751,	752},// 660
+	{  575,	660,	662,	752,	753,	754},
+	{  575,	576,	661,	663,	754,	755},
+	{  576,	577,	662,	664,	755,	756},
+	{  577,	578,	663,	665,	756,	757},
+	{  578,	579,	664,	666,	757,	758},
+	{  579,	580,	665,	667,	758,	759},
+	{  580,	581,	666,	668,	759,	760},
+	{  581,	582,	667,	669,	760,	761},
+	{  582,	583,	668,	670,	761,	762},
+	{  583,	584,	669,	671,	762,	763},
+	{  584,	585,	670,	672,	763,	764},
+	{  585,	586,	671,	673,	764,	765},
+	{  586,	587,	672,	674,	765,	766},
+	{  587,	588,	673,	675,	766,	767},
+	{  588,	589,	674,	676,	767,	768},
+	{  589,	675,	677,	768,	769,	770},
+	{  589,	590,	676,	678,	770,	771},
+	{  590,	591,	677,	679,	771,	772},
+	{  591,	592,	678,	680,	772,	773},
+	{  592,	593,	679,	681,	773,	774},// 680
+	{  593,	594,	680,	682,	774,	775},
+	{  594,	595,	681,	683,	775,	776},
+	{  595,	596,	682,	684,	776,	777},
+	{  596,	597,	683,	685,	777,	778},
+	{  597,	598,	684,	686,	778,	779},
+	{  598,	599,	685,	687,	779,	780},
+	{  599,	600,	686,	688,	780,	781},
+	{  600,	601,	687,	689,	781,	782},
+	{  601,	602,	688,	690,	782,	783},
+	{  602,	603,	689,	691,	783,	784},
+	{  603,	690,	692,	784,	785,	786},
+	{  603,	604,	691,	693,	786,	787},
+	{  604,	605,	692,	694,	787,	788},
+	{  605,	606,	693,	695,	788,	789},
+	{  606,	607,	694,	696,	789,	790},
+	{  607,	608,	695,	697,	790,	791},
+	{  608,	609,	696,	698,	791,	792},
+	{  609,	610,	697,	699,	792,	793},
+	{  610,	611,	698,	700,	793,	794},
+	{  611,	612,	699,	701,	794,	795},// 700
+	{  612,	613,	700,	702,	795,	796},
+	{  613,	614,	701,	703,	796,	797},
+	{  614,	615,	702,	704,	797,	798},
+	{  615,	616,	703,	705,	798,	799},
+	{  616,	617,	704,	706,	799,	800},
+	{  617,	705,	707,	800,	801,	802},
+	{  617,	618,	706,	708,	802,	803},
+	{  618,	619,	707,	709,	803,	804},
+	{  619,	620,	708,	710,	804,	805},
+	{  620,	621,	709,	711,	805,	806},
+	{  621,	622,	710,	712,	806,	807},
+	{  622,	623,	711,	713,	807,	808},
+	{  623,	624,	712,	714,	808,	809},
+	{  624,	625,	713,	715,	809,	810},
+	{  625,	626,	714,	716,	810,	811},
+	{  626,	627,	715,	717,	811,	812},
+	{  627,	628,	716,	718,	812,	813},
+	{  628,	629,	717,	719,	813,	814},
+	{  629,	630,	718,	720,	814,	815},
+	{  547,	630,	631,	719,	815,	816},// 720
+	{  631,	722,	816,	817,	818,	918},
+	{  631,	632,	721,	723,	818,	819},
+	{  632,	633,	722,	724,	819,	820},
+	{  633,	634,	723,	725,	820,	821},
+	{  634,	635,	724,	726,	821,	822},
+	{  635,	636,	725,	727,	822,	823},
+	{  636,	637,	726,	728,	823,	824},
+	{  637,	638,	727,	729,	824,	825},
+	{  638,	639,	728,	730,	825,	826},
+	{  639,	640,	729,	731,	826,	827},
+	{  640,	641,	730,	732,	827,	828},
+	{  641,	642,	731,	733,	828,	829},
+	{  642,	643,	732,	734,	829,	830},
+	{  643,	644,	733,	735,	830,	831},
+	{  644,	645,	734,	736,	831,	832},
+	{  645,	646,	735,	737,	832,	833},
+	{  646,	736,	738,	833,	834,	835},
+	{  646,	647,	737,	739,	835,	836},
+	{  647,	648,	738,	740,	836,	837},
+	{  648,	649,	739,	741,	837,	838},// 740
+	{  649,	650,	740,	742,	838,	839},
+	{  650,	651,	741,	743,	839,	840},
+	{  651,	652,	742,	744,	840,	841},
+	{  652,	653,	743,	745,	841,	842},
+	{  653,	654,	744,	746,	842,	843},
+	{  654,	655,	745,	747,	843,	844},
+	{  655,	656,	746,	748,	844,	845},
+	{  656,	657,	747,	749,	845,	846},
+	{  657,	658,	748,	750,	846,	847},
+	{  658,	659,	749,	751,	847,	848},
+	{  659,	660,	750,	752,	848,	849},
+	{  660,	661,	751,	753,	849,	850},
+	{  661,	752,	754,	850,	851,	852},
+	{  661,	662,	753,	755,	852,	853},
+	{  662,	663,	754,	756,	853,	854},
+	{  663,	664,	755,	757,	854,	855},
+	{  664,	665,	756,	758,	855,	856},
+	{  665,	666,	757,	759,	856,	857},
+	{  666,	667,	758,	760,	857,	858},
+	{  667,	668,	759,	761,	858,	859},// 760
+	{  668,	669,	760,	762,	859,	860},
+	{  669,	670,	761,	763,	860,	861},
+	{  670,	671,	762,	764,	861,	862},
+	{  671,	672,	763,	765,	862,	863},
+	{  672,	673,	764,	766,	863,	864},
+	{  673,	674,	765,	767,	864,	865},
+	{  674,	675,	766,	768,	865,	866},
+	{  675,	676,	767,	769,	866,	867},
+	{  676,	768,	770,	867,	868,	869},
+	{  676,	677,	769,	771,	869,	870},
+	{  677,	678,	770,	772,	870,	871},
+	{  678,	679,	771,	773,	871,	872},
+	{  679,	680,	772,	774,	872,	873},
+	{  680,	681,	773,	775,	873,	874},
+	{  681,	682,	774,	776,	874,	875},
+	{  682,	683,	775,	777,	875,	876},
+	{  683,	684,	776,	778,	876,	877},
+	{  684,	685,	777,	779,	877,	878},
+	{  685,	686,	778,	780,	878,	879},
+	{  686,	687,	779,	781,	879,	880},// 780
+	{  687,	688,	780,	782,	880,	881},
+	{  688,	689,	781,	783,	881,	882},
+	{  689,	690,	782,	784,	882,	883},
+	{  690,	691,	783,	785,	883,	884},
+	{  691,	784,	786,	884,	885,	886},
+	{  691,	692,	785,	787,	886,	887},
+	{  692,	693,	786,	788,	887,	888},
+	{  693,	694,	787,	789,	888,	889},
+	{  694,	695,	788,	790,	889,	890},
+	{  695,	696,	789,	791,	890,	891},
+	{  696,	697,	790,	792,	891,	892},
+	{  697,	698,	791,	793,	892,	893},
+	{  698,	699,	792,	794,	893,	894},
+	{  699,	700,	793,	795,	894,	895},
+	{  700,	701,	794,	796,	895,	896},
+	{  701,	702,	795,	797,	896,	897},
+	{  702,	703,	796,	798,	897,	898},
+	{  703,	704,	797,	799,	898,	899},
+	{  704,	705,	798,	800,	899,	900},
+	{  705,	706,	799,	801,	900,	901},// 800
+	{  706,	800,	802,	901,	902,	903},
+	{  706,	707,	801,	803,	903,	904},
+	{  707,	708,	802,	804,	904,	905},
+	{  708,	709,	803,	805,	905,	906},
+	{  709,	710,	804,	806,	906,	907},
+	{  710,	711,	805,	807,	907,	908},
+	{  711,	712,	806,	808,	908,	909},
+	{  712,	713,	807,	809,	909,	910},
+	{  713,	714,	808,	810,	910,	911},
+	{  714,	715,	809,	811,	911,	912},
+	{  715,	716,	810,	812,	912,	913},
+	{  716,	717,	811,	813,	913,	914},
+	{  717,	718,	812,	814,	914,	915},
+	{  718,	719,	813,	815,	915,	916},
+	{  719,	720,	814,	816,	916,	917},
+	{  631,	720,	721,	815,	917,	918},
+	{  721,	818,	918,	-1,	-1,	-1},
+	{  721,	722,	817,	819,	-1,	-1},
+	{  722,	723,	818,	820,	-1,	-1},
+	{  723,	724,	819,	821,	-1,	-1},// 820
+	{  724,	725,	820,	822,	-1,	-1},
+	{  725,	726,	821,	823,	-1,	-1},
+	{  726,	727,	822,	824,	-1,	-1},
+	{  727,	728,	823,	825,	-1,	-1},
+	{  728,	729,	824,	826,	-1,	-1},
+	{  729,	730,	825,	827,	-1,	-1},
+	{  730,	731,	826,	828,	-1,	-1},
+	{  731,	732,	827,	829,	-1,	-1},
+	{  732,	733,	828,	830,	-1,	-1},
+	{  733,	734,	829,	831,	-1,	-1},
+	{  734,	735,	830,	832,	-1,	-1},
+	{  735,	736,	831,	833,	-1,	-1},
+	{  736,	737,	832,	834,	-1,	-1},
+	{  737,	833,	835,	-1,	-1,	-1},
+	{  737,	738,	834,	836,	-1,	-1},
+	{  738,	739,	835,	837,	-1,	-1},
+	{  739,	740,	836,	838,	-1,	-1},
+	{  740,	741,	837,	839,	-1,	-1},
+	{  741,	742,	838,	840,	-1,	-1},
+	{  742,	743,	839,	841,	-1,	-1},// 840
+	{  743,	744,	840,	842,	-1,	-1},
+	{  744,	745,	841,	843,	-1,	-1},
+	{  745,	746,	842,	844,	-1,	-1},
+	{  746,	747,	843,	845,	-1,	-1},
+	{  747,	748,	844,	846,	-1,	-1},
+	{  748,	749,	845,	847,	-1,	-1},
+	{  749,	750,	846,	848,	-1,	-1},
+	{  750,	751,	847,	849,	-1,	-1},
+	{  751,	752,	848,	850,	-1,	-1},
+	{  752,	753,	849,	851,	-1,	-1},
+	{  753,	850,	852,	-1,	-1,	-1},
+	{  753,	754,	851,	853,	-1,	-1},
+	{  754,	755,	852,	854,	-1,	-1},
+	{  755,	756,	853,	855,	-1,	-1},
+	{  756,	757,	854,	856,	-1,	-1},
+	{  757,	758,	855,	857,	-1,	-1},
+	{  758,	759,	856,	858,	-1,	-1},
+	{  759,	760,	857,	859,	-1,	-1},
+	{  760,	761,	858,	860,	-1,	-1},
+	{  761,	762,	859,	861,	-1,	-1},// 860
+	{  762,	763,	860,	862,	-1,	-1},
+	{  763,	764,	861,	863,	-1,	-1},
+	{  764,	765,	862,	864,	-1,	-1},
+	{  765,	766,	863,	865,	-1,	-1},
+	{  766,	767,	864,	866,	-1,	-1},
+	{  767,	768,	865,	867,	-1,	-1},
+	{  768,	769,	866,	868,	-1,	-1},
+	{  769,	867,	869,	-1,	-1,	-1},
+	{  769,	770,	868,	870,	-1,	-1},
+	{  770,	771,	869,	871,	-1,	-1},
+	{  771,	772,	870,	872,	-1,	-1},
+	{  772,	773,	871,	873,	-1,	-1},
+	{  773,	774,	872,	874,	-1,	-1},
+	{  774,	775,	873,	875,	-1,	-1},
+	{  775,	776,	874,	876,	-1,	-1},
+	{  776,	777,	875,	877,	-1,	-1},
+	{  777,	778,	876,	878,	-1,	-1},
+	{  778,	779,	877,	879,	-1,	-1},
+	{  779,	780,	878,	880,	-1,	-1},
+	{  780,	781,	879,	881,	-1,	-1},// 880
+	{  781,	782,	880,	882,	-1,	-1},
+	{  782,	783,	881,	883,	-1,	-1},
+	{  783,	784,	882,	884,	-1,	-1},
+	{  784,	785,	883,	885,	-1,	-1},
+	{  785,	884,	886,	-1,	-1,	-1},
+	{  785,	786,	885,	887,	-1,	-1},
+	{  786,	787,	886,	888,	-1,	-1},
+	{  787,	788,	887,	889,	-1,	-1},
+	{  788,	789,	888,	890,	-1,	-1},
+	{  789,	790,	889,	891,	-1,	-1},
+	{  790,	791,	890,	892,	-1,	-1},
+	{  791,	792,	891,	893,	-1,	-1},
+	{  792,	793,	892,	894,	-1,	-1},
+	{  793,	794,	893,	895,	-1,	-1},
+	{  794,	795,	894,	896,	-1,	-1},
+	{  795,	796,	895,	897,	-1,	-1},
+	{  796,	797,	896,	898,	-1,	-1},
+	{  797,	798,	897,	899,	-1,	-1},
+	{  798,	799,	898,	900,	-1,	-1},
+	{  799,	800,	899,	901,	-1,	-1},// 900
+	{  800,	801,	900,	902,	-1,	-1},
+	{  801,	901,	903,	-1,	-1,	-1},
+	{  801,	802,	902,	904,	-1,	-1},
+	{  802,	803,	903,	905,	-1,	-1},
+	{  803,	804,	904,	906,	-1,	-1},
+	{  804,	805,	905,	907,	-1,	-1},
+	{  805,	806,	906,	908,	-1,	-1},
+	{  806,	807,	907,	909,	-1,	-1},
+	{  807,	808,	908,	910,	-1,	-1},
+	{  808,	809,	909,	911,	-1,	-1},
+	{  809,	810,	910,	912,	-1,	-1},
+	{  810,	811,	911,	913,	-1,	-1},
+	{  811,	812,	912,	914,	-1,	-1},
+	{  812,	813,	913,	915,	-1,	-1},
+	{  813,	814,	914,	916,	-1,	-1},
+	{  814,	815,	915,	917,	-1,	-1},
+	{  815,	816,	916,	918,	-1,	-1},
+	{  721,	816,	817,	917,	-1,	-1}
+  };
+
+  for (UInt_t i=0; i<GetNumPixels(); 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-8-5/Mars/mgeom/MGeomCamMagic919.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mgeom/MGeomCamMagic919.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mgeom/MGeomCamMagic919.h	(revision 9661)
@@ -0,0 +1,21 @@
+#ifndef MARS_MGeomCamMagic919
+#define MARS_MGeomCamMagic919
+
+#ifndef MARS_MGeomCam
+#include "MGeomCam.h"
+#endif
+
+class MGeomCamMagic919 : public MGeomCam
+{
+private:
+    void CreateCam();
+    void CreateNN();
+
+public:
+    MGeomCamMagic919(const char *name=NULL);
+
+    ClassDef(MGeomCamMagic919, 1)		// Geometry class for Magic camera with only small pixels
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mgeom/MGeomCamMagicHG.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mgeom/MGeomCamMagicHG.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mgeom/MGeomCamMagicHG.cc	(revision 9661)
@@ -0,0 +1,3397 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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 <mailto:blanch@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MGeomCamMagicHG
+//
+// This class stores the geometry information of the hipotethic Magic camera
+// with high granularity
+// All information are copied from tables, see source code.
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MGeomCamMagicHG.h"
+
+#include "MGeomPix.h"
+
+ClassImp(MGeomCamMagicHG);
+
+// --------------------------------------------------------------------------
+//
+//  Magic high Granularity camera could have 2401 pixels. For geometry and Next Neighbor 
+//  info see CreateCam and CreateNN
+//
+MGeomCamMagicHG::MGeomCamMagicHG(const char *name)
+    : MGeomCam(2401, 17, name, "Geometry information of high Granularity Magic Camera")
+{
+    CreateCam();
+    CreateNN();
+    InitGeometry();
+}
+
+// --------------------------------------------------------------------------
+//
+//  This fills the geometry information from a table into the pixel objects.
+//
+void MGeomCamMagicHG::CreateCam()
+{
+
+    //
+    //   here define the hardwire things of the magic telescope
+    //
+  const float xtemp[2401] = {
+    0, 15, 7.5, -7.5, -15, -7.5, 7.5, 30, // 0
+    22.5, 15, 0, -15, -22.5, -30, -22.5, -15, // 8
+    0, 15, 22.5, 45, 37.5, 30, 22.5, 7.5, // 16
+    -7.5, -22.5, -30, -37.5, -45, -37.5, -30, -22.5, // 24
+    -7.5, 7.5, 22.5, 30, 37.5, 60, 52.5, 45, // 32
+    37.5, 30, 15, 0, -15, -30, -37.5, -45, // 40
+    -52.5, -60, -52.5, -45, -37.5, -30, -15, 0, // 48
+    15, 30, 37.5, 45, 52.5, 75, 67.5, 60, // 56
+    52.5, 45, 37.5, 22.5, 7.5, -7.5, -22.5, -37.5, // 64
+    -45, -52.5, -60, -67.5, -75, -67.5, -60, -52.5, // 72
+    -45, -37.5, -22.5, -7.5, 7.5, 22.5, 37.5, 45, // 80
+    52.5, 60, 67.5, 90, 82.5, 75, 67.5, 60, // 88
+    52.5, 45, 30, 15, 0, -15, -30, -45, // 96
+    -52.5, -60, -67.5, -75, -82.5, -90, -82.5, -75, // 104
+    -67.5, -60, -52.5, -45, -30, -15, 0, 15, // 112
+    30, 45, 52.5, 60, 67.5, 75, 82.5, 105, // 120
+    97.5, 90, 82.5, 75, 67.5, 60, 52.5, 37.5, // 128
+    22.5, 7.5, -7.5, -22.5, -37.5, -52.5, -60, -67.5, // 136
+    -75, -82.5, -90, -97.5, -105, -97.5, -90, -82.5, // 144
+    -75, -67.5, -60, -52.5, -37.5, -22.5, -7.5, 7.5, // 152
+    22.5, 37.5, 52.5, 60, 67.5, 75, 82.5, 90, // 160
+    97.5, 120, 112.5, 105, 97.5, 90, 82.5, 75, // 168
+    67.5, 60, 45, 30, 15, 0, -15, -30, // 176
+    -45, -60, -67.5, -75, -82.5, -90, -97.5, -105, // 184
+    -112.5, -120, -112.5, -105, -97.5, -90, -82.5, -75, // 192
+    -67.5, -60, -45, -30, -15, 0, 15, 30, // 200
+    45, 60, 67.5, 75, 82.5, 90, 97.5, 105, // 208
+    112.5, 135, 127.5, 120, 112.5, 105, 97.5, 90, // 216
+    82.5, 75, 67.5, 52.5, 37.5, 22.5, 7.5, -7.5, // 224
+    -22.5, -37.5, -52.5, -67.5, -75, -82.5, -90, -97.5, // 232
+    -105, -112.5, -120, -127.5, -135, -127.5, -120, -112.5, // 240
+    -105, -97.5, -90, -82.5, -75, -67.5, -52.5, -37.5, // 248
+    -22.5, -7.5, 7.5, 22.5, 37.5, 52.5, 67.5, 75, // 256
+    82.5, 90, 97.5, 105, 112.5, 120, 127.5, 150, // 264
+    142.5, 135, 127.5, 120, 112.5, 105, 97.5, 90, // 272
+    82.5, 75, 60, 45, 30, 15, 0, -15, // 280
+    -30, -45, -60, -75, -82.5, -90, -97.5, -105, // 288
+    -112.5, -120, -127.5, -135, -142.5, -150, -142.5, -135, // 296
+    -127.5, -120, -112.5, -105, -97.5, -90, -82.5, -75, // 304
+    -60, -45, -30, -15, 0, 15, 30, 45, // 312
+    60, 75, 82.5, 90, 97.5, 105, 112.5, 120, // 320
+    127.5, 135, 142.5, 165, 157.5, 150, 142.5, 135, // 328
+    127.5, 120, 112.5, 105, 97.5, 90, 82.5, 67.5, // 336
+    52.5, 37.5, 22.5, 7.5, -7.5, -22.5, -37.5, -52.5, // 344
+    -67.5, -82.5, -90, -97.5, -105, -112.5, -120, -127.5, // 352
+    -135, -142.5, -150, -157.5, -165, -157.5, -150, -142.5, // 360
+    -135, -127.5, -120, -112.5, -105, -97.5, -90, -82.5, // 368
+    -67.5, -52.5, -37.5, -22.5, -7.5, 7.5, 22.5, 37.5, // 376
+    52.5, 67.5, 82.5, 90, 97.5, 105, 112.5, 120, // 384
+    127.5, 135, 142.5, 150, 157.5, 180, 172.5, 165, // 392
+    157.5, 150, 142.5, 135, 127.5, 120, 112.5, 105, // 400
+    97.5, 90, 75, 60, 45, 30, 15, 0, // 408
+    -15, -30, -45, -60, -75, -90, -97.5, -105, // 416
+    -112.5, -120, -127.5, -135, -142.5, -150, -157.5, -165, // 424
+    -172.5, -180, -172.5, -165, -157.5, -150, -142.5, -135, // 432
+    -127.5, -120, -112.5, -105, -97.5, -90, -75, -60, // 440
+    -45, -30, -15, 0, 15, 30, 45, 60, // 448
+    75, 90, 97.5, 105, 112.5, 120, 127.5, 135, // 456
+    142.5, 150, 157.5, 165, 172.5, 195, 187.5, 180, // 464
+    172.5, 165, 157.5, 150, 142.5, 135, 127.5, 120, // 472
+    112.5, 105, 97.5, 82.5, 67.5, 52.5, 37.5, 22.5, // 480
+    7.5, -7.5, -22.5, -37.5, -52.5, -67.5, -82.5, -97.5, // 488
+    -105, -112.5, -120, -127.5, -135, -142.5, -150, -157.5, // 496
+    -165, -172.5, -180, -187.5, -195, -187.5, -180, -172.5, // 504
+    -165, -157.5, -150, -142.5, -135, -127.5, -120, -112.5, // 512
+    -105, -97.5, -82.5, -67.5, -52.5, -37.5, -22.5, -7.5, // 520
+    7.5, 22.5, 37.5, 52.5, 67.5, 82.5, 97.5, 105, // 528
+    112.5, 120, 127.5, 135, 142.5, 150, 157.5, 165, // 536
+    172.5, 180, 187.5, 210, 202.5, 195, 187.5, 180, // 544
+    172.5, 165, 157.5, 150, 142.5, 135, 127.5, 120, // 552
+    112.5, 105, 90, 75, 60, 45, 30, 15, // 560
+    0, -15, -30, -45, -60, -75, -90, -105, // 568
+    -112.5, -120, -127.5, -135, -142.5, -150, -157.5, -165, // 576
+    -172.5, -180, -187.5, -195, -202.5, -210, -202.5, -195, // 584
+    -187.5, -180, -172.5, -165, -157.5, -150, -142.5, -135, // 592
+    -127.5, -120, -112.5, -105, -90, -75, -60, -45, // 600
+    -30, -15, 0, 15, 30, 45, 60, 75, // 608
+    90, 105, 112.5, 120, 127.5, 135, 142.5, 150, // 616
+    157.5, 165, 172.5, 180, 187.5, 195, 202.5, 225, // 624
+    217.5, 210, 202.5, 195, 187.5, 180, 172.5, 165, // 632
+    157.5, 150, 142.5, 135, 127.5, 120, 112.5, 97.5, // 640
+    82.5, 67.5, 52.5, 37.5, 22.5, 7.5, -7.5, -22.5, // 648
+    -37.5, -52.5, -67.5, -82.5, -97.5, -112.5, -120, -127.5, // 656
+    -135, -142.5, -150, -157.5, -165, -172.5, -180, -187.5, // 664
+    -195, -202.5, -210, -217.5, -225, -217.5, -210, -202.5, // 672
+    -195, -187.5, -180, -172.5, -165, -157.5, -150, -142.5, // 680
+    -135, -127.5, -120, -112.5, -97.5, -82.5, -67.5, -52.5, // 688
+    -37.5, -22.5, -7.5, 7.5, 22.5, 37.5, 52.5, 67.5, // 696
+    82.5, 97.5, 112.5, 120, 127.5, 135, 142.5, 150, // 704
+    157.5, 165, 172.5, 180, 187.5, 195, 202.5, 210, // 712
+    217.5, 240, 232.5, 225, 217.5, 210, 202.5, 195, // 720
+    187.5, 180, 172.5, 165, 157.5, 150, 142.5, 135, // 728
+    127.5, 120, 105, 90, 75, 60, 45, 30, // 736
+    15, 0, -15, -30, -45, -60, -75, -90, // 744
+    -105, -120, -127.5, -135, -142.5, -150, -157.5, -165, // 752
+    -172.5, -180, -187.5, -195, -202.5, -210, -217.5, -225, // 760
+    -232.5, -240, -232.5, -225, -217.5, -210, -202.5, -195, // 768
+    -187.5, -180, -172.5, -165, -157.5, -150, -142.5, -135, // 776
+    -127.5, -120, -105, -90, -75, -60, -45, -30, // 784
+    -15, 0, 15, 30, 45, 60, 75, 90, // 792
+    105, 120, 127.5, 135, 142.5, 150, 157.5, 165, // 800
+    172.5, 180, 187.5, 195, 202.5, 210, 217.5, 225, // 808
+    232.5, 255, 247.5, 240, 232.5, 225, 217.5, 210, // 816
+    202.5, 195, 187.5, 180, 172.5, 165, 157.5, 150, // 824
+    142.5, 135, 127.5, 112.5, 97.5, 82.5, 67.5, 52.5, // 832
+    37.5, 22.5, 7.5, -7.5, -22.5, -37.5, -52.5, -67.5, // 840
+    -82.5, -97.5, -112.5, -127.5, -135, -142.5, -150, -157.5, // 848
+    -165, -172.5, -180, -187.5, -195, -202.5, -210, -217.5, // 856
+    -225, -232.5, -240, -247.5, -255, -247.5, -240, -232.5, // 864
+    -225, -217.5, -210, -202.5, -195, -187.5, -180, -172.5, // 872
+    -165, -157.5, -150, -142.5, -135, -127.5, -112.5, -97.5, // 880
+    -82.5, -67.5, -52.5, -37.5, -22.5, -7.5, 7.5, 22.5, // 888
+    37.5, 52.5, 67.5, 82.5, 97.5, 112.5, 127.5, 135, // 896
+    142.5, 150, 157.5, 165, 172.5, 180, 187.5, 195, // 904
+    202.5, 210, 217.5, 225, 232.5, 240, 247.5, 270, // 912
+    262.5, 255, 247.5, 240, 232.5, 225, 217.5, 210, // 920
+    202.5, 195, 187.5, 180, 172.5, 165, 157.5, 150, // 928
+    142.5, 135, 120, 105, 90, 75, 60, 45, // 936
+    30, 15, 0, -15, -30, -45, -60, -75, // 944
+    -90, -105, -120, -135, -142.5, -150, -157.5, -165, // 952
+    -172.5, -180, -187.5, -195, -202.5, -210, -217.5, -225, // 960
+    -232.5, -240, -247.5, -255, -262.5, -270, -262.5, -255, // 968
+    -247.5, -240, -232.5, -225, -217.5, -210, -202.5, -195, // 976
+    -187.5, -180, -172.5, -165, -157.5, -150, -142.5, -135, // 984
+    -120, -105, -90, -75, -60, -45, -30, -15, // 992
+    0, 15, 30, 45, 60, 75, 90, 105, // 1000
+    120, 135, 142.5, 150, 157.5, 165, 172.5, 180, // 1008
+    187.5, 195, 202.5, 210, 217.5, 225, 232.5, 240, // 1016
+    247.5, 255, 262.5, 285, 277.5, 270, 262.5, 255, // 1024
+    247.5, 240, 232.5, 225, 217.5, 210, 202.5, 195, // 1032
+    187.5, 180, 172.5, 165, 157.5, 150, 142.5, 127.5, // 1040
+    112.5, 97.5, 82.5, 67.5, 52.5, 37.5, 22.5, 7.5, // 1048
+    -7.5, -22.5, -37.5, -52.5, -67.5, -82.5, -97.5, -112.5, // 1056
+    -127.5, -142.5, -150, -157.5, -165, -172.5, -180, -187.5, // 1064
+    -195, -202.5, -210, -217.5, -225, -232.5, -240, -247.5, // 1072
+    -255, -262.5, -270, -277.5, -285, -277.5, -270, -262.5, // 1080
+    -255, -247.5, -240, -232.5, -225, -217.5, -210, -202.5, // 1088
+    -195, -187.5, -180, -172.5, -165, -157.5, -150, -142.5, // 1096
+    -127.5, -112.5, -97.5, -82.5, -67.5, -52.5, -37.5, -22.5, // 1104
+    -7.5, 7.5, 22.5, 37.5, 52.5, 67.5, 82.5, 97.5, // 1112
+    112.5, 127.5, 142.5, 150, 157.5, 165, 172.5, 180, // 1120
+    187.5, 195, 202.5, 210, 217.5, 225, 232.5, 240, // 1128
+    247.5, 255, 262.5, 270, 277.5, 300, 292.5, 285, // 1136
+    277.5, 270, 262.5, 255, 247.5, 240, 232.5, 225, // 1144
+    217.5, 210, 202.5, 195, 187.5, 180, 172.5, 165, // 1152
+    157.5, 150, 135, 120, 105, 90, 75, 60, // 1160
+    45, 30, 15, 0, -15, -30, -45, -60, // 1168
+    -75, -90, -105, -120, -135, -150, -157.5, -165, // 1176
+    -172.5, -180, -187.5, -195, -202.5, -210, -217.5, -225, // 1184
+    -232.5, -240, -247.5, -255, -262.5, -270, -277.5, -285, // 1192
+    -292.5, -300, -292.5, -285, -277.5, -270, -262.5, -255, // 1200
+    -247.5, -240, -232.5, -225, -217.5, -210, -202.5, -195, // 1208
+    -187.5, -180, -172.5, -165, -157.5, -150, -135, -120, // 1216
+    -105, -90, -75, -60, -45, -30, -15, 0, // 1224
+    15, 30, 45, 60, 75, 90, 105, 120, // 1232
+    135, 150, 157.5, 165, 172.5, 180, 187.5, 195, // 1240
+    202.5, 210, 217.5, 225, 232.5, 240, 247.5, 255, // 1248
+    262.5, 270, 277.5, 285, 292.5, 315, 307.5, 300, // 1256
+    292.5, 285, 277.5, 270, 262.5, 255, 247.5, 240, // 1264
+    232.5, 225, 217.5, 210, 202.5, 195, 187.5, 180, // 1272
+    172.5, 165, 157.5, 142.5, 127.5, 112.5, 97.5, 82.5, // 1280
+    67.5, 52.5, 37.5, 22.5, 7.5, -7.5, -22.5, -37.5, // 1288
+    -52.5, -67.5, -82.5, -97.5, -112.5, -127.5, -142.5, -157.5, // 1296
+    -165, -172.5, -180, -187.5, -195, -202.5, -210, -217.5, // 1304
+    -225, -232.5, -240, -247.5, -255, -262.5, -270, -277.5, // 1312
+    -285, -292.5, -300, -307.5, -315, -307.5, -300, -292.5, // 1320
+    -285, -277.5, -270, -262.5, -255, -247.5, -240, -232.5, // 1328
+    -225, -217.5, -210, -202.5, -195, -187.5, -180, -172.5, // 1336
+    -165, -157.5, -142.5, -127.5, -112.5, -97.5, -82.5, -67.5, // 1344
+    -52.5, -37.5, -22.5, -7.5, 7.5, 22.5, 37.5, 52.5, // 1352
+    67.5, 82.5, 97.5, 112.5, 127.5, 142.5, 157.5, 165, // 1360
+    172.5, 180, 187.5, 195, 202.5, 210, 217.5, 225, // 1368
+    232.5, 240, 247.5, 255, 262.5, 270, 277.5, 285, // 1376
+    292.5, 300, 307.5, 330, 322.5, 315, 307.5, 300, // 1384
+    292.5, 285, 277.5, 270, 262.5, 255, 247.5, 240, // 1392
+    232.5, 225, 217.5, 210, 202.5, 195, 187.5, 180, // 1400
+    172.5, 165, 150, 135, 120, 105, 90, 75, // 1408
+    60, 45, 30, 15, 0, -15, -30, -45, // 1416
+    -60, -75, -90, -105, -120, -135, -150, -165, // 1424
+    -172.5, -180, -187.5, -195, -202.5, -210, -217.5, -225, // 1432
+    -232.5, -240, -247.5, -255, -262.5, -270, -277.5, -285, // 1440
+    -292.5, -300, -307.5, -315, -322.5, -330, -322.5, -315, // 1448
+    -307.5, -300, -292.5, -285, -277.5, -270, -262.5, -255, // 1456
+    -247.5, -240, -232.5, -225, -217.5, -210, -202.5, -195, // 1464
+    -187.5, -180, -172.5, -165, -150, -135, -120, -105, // 1472
+    -90, -75, -60, -45, -30, -15, 0, 15, // 1480
+    30, 45, 60, 75, 90, 105, 120, 135, // 1488
+    150, 165, 172.5, 180, 187.5, 195, 202.5, 210, // 1496
+    217.5, 225, 232.5, 240, 247.5, 255, 262.5, 270, // 1504
+    277.5, 285, 292.5, 300, 307.5, 315, 322.5, 345, // 1512
+    337.5, 330, 322.5, 315, 307.5, 300, 292.5, 285, // 1520
+    277.5, 270, 262.5, 255, 247.5, 240, 232.5, 225, // 1528
+    217.5, 210, 202.5, 195, 187.5, 180, 172.5, 157.5, // 1536
+    142.5, 127.5, 112.5, 97.5, 82.5, 67.5, 52.5, 37.5, // 1544
+    22.5, 7.5, -7.5, -22.5, -37.5, -52.5, -67.5, -82.5, // 1552
+    -97.5, -112.5, -127.5, -142.5, -157.5, -172.5, -180, -187.5, // 1560
+    -195, -202.5, -210, -217.5, -225, -232.5, -240, -247.5, // 1568
+    -255, -262.5, -270, -277.5, -285, -292.5, -300, -307.5, // 1576
+    -315, -322.5, -330, -337.5, -345, -337.5, -330, -322.5, // 1584
+    -315, -307.5, -300, -292.5, -285, -277.5, -270, -262.5, // 1592
+    -255, -247.5, -240, -232.5, -225, -217.5, -210, -202.5, // 1600
+    -195, -187.5, -180, -172.5, -157.5, -142.5, -127.5, -112.5, // 1608
+    -97.5, -82.5, -67.5, -52.5, -37.5, -22.5, -7.5, 7.5, // 1616
+    22.5, 37.5, 52.5, 67.5, 82.5, 97.5, 112.5, 127.5, // 1624
+    142.5, 157.5, 172.5, 180, 187.5, 195, 202.5, 210, // 1632
+    217.5, 225, 232.5, 240, 247.5, 255, 262.5, 270, // 1640
+    277.5, 285, 292.5, 300, 307.5, 315, 322.5, 330, // 1648
+    337.5, 360, 345, 330, 315, 300, 285, 270, // 1656
+    255, 240, 225, 210, 195, 165, 135, 105, // 1664
+    75, 45, 15, -15, -45, -75, -105, -135, // 1672
+    -165, -195, -210, -225, -240, -255, -270, -285, // 1680
+    -300, -315, -330, -345, -360, -360, -345, -330, // 1688
+    -315, -300, -285, -270, -255, -240, -225, -210, // 1696
+    -195, -165, -135, -105, -75, -45, -15, 15, // 1704
+    45, 75, 105, 135, 165, 195, 210, 225, // 1712
+    240, 255, 270, 285, 300, 315, 330, 345, // 1720
+    360, 390, 375, 360, 345, 330, 315, 300, // 1728
+    285, 270, 255, 240, 225, 210, 180, 150, // 1736
+    120, 90, 60, 30, 0, -30, -60, -90, // 1744
+    -120, -150, -180, -210, -225, -240, -255, -270, // 1752
+    -285, -300, -315, -330, -345, -360, -375, -390, // 1760
+    -390, -375, -360, -345, -330, -315, -300, -285, // 1768
+    -270, -255, -240, -225, -210, -180, -150, -120, // 1776
+    -90, -60, -30, 0, 30, 60, 90, 120, // 1784
+    150, 180, 210, 225, 240, 255, 270, 285, // 1792
+    300, 315, 330, 345, 360, 375, 390, 420, // 1800
+    405, 390, 375, 360, 345, 330, 315, 300, // 1808
+    285, 270, 255, 240, 225, 195, 165, 135, // 1816
+    105, 75, 45, 15, -15, -45, -75, -105, // 1824
+    -135, -165, -195, -225, -240, -255, -270, -285, // 1832
+    -300, -315, -330, -345, -360, -375, -390, -405, // 1840
+    -420, -420, -405, -390, -375, -360, -345, -330, // 1848
+    -315, -300, -285, -270, -255, -240, -225, -195, // 1856
+    -165, -135, -105, -75, -45, -15, 15, 45, // 1864
+    75, 105, 135, 165, 195, 225, 240, 255, // 1872
+    270, 285, 300, 315, 330, 345, 360, 375, // 1880
+    390, 405, 420, 450, 435, 420, 405, 390, // 1888
+    375, 360, 345, 330, 315, 300, 285, 270, // 1896
+    255, 240, 210, 180, 150, 120, 90, 60, // 1904
+    30, 0, -30, -60, -90, -120, -150, -180, // 1912
+    -210, -240, -255, -270, -285, -300, -315, -330, // 1920
+    -345, -360, -375, -390, -405, -420, -435, -450, // 1928
+    -450, -435, -420, -405, -390, -375, -360, -345, // 1936
+    -330, -315, -300, -285, -270, -255, -240, -210, // 1944
+    -180, -150, -120, -90, -60, -30, 0, 30, // 1952
+    60, 90, 120, 150, 180, 210, 240, 255, // 1960
+    270, 285, 300, 315, 330, 345, 360, 375, // 1968
+    390, 405, 420, 435, 450, 480, 465, 450, // 1976
+    435, 420, 405, 390, 375, 360, 345, 330, // 1984
+    315, 300, 285, 270, 255, 225, 195, 165, // 1992
+    135, 105, 75, 45, 15, -15, -45, -75, // 2000
+    -105, -135, -165, -195, -225, -255, -270, -285, // 2008
+    -300, -315, -330, -345, -360, -375, -390, -405, // 2016
+    -420, -435, -450, -465, -480, -480, -465, -450, // 2024
+    -435, -420, -405, -390, -375, -360, -345, -330, // 2032
+    -315, -300, -285, -270, -255, -225, -195, -165, // 2040
+    -135, -105, -75, -45, -15, 15, 45, 75, // 2048
+    105, 135, 165, 195, 225, 255, 270, 285, // 2056
+    300, 315, 330, 345, 360, 375, 390, 405, // 2064
+    420, 435, 450, 465, 480, 510, 495, 480, // 2072
+    465, 450, 435, 420, 405, 390, 375, 360, // 2080
+    345, 330, 315, 300, 285, 270, 240, 210, // 2088
+    180, 150, 120, 90, 60, 30, 0, -30, // 2096
+    -60, -90, -120, -150, -180, -210, -240, -270, // 2104
+    -285, -300, -315, -330, -345, -360, -375, -390, // 2112
+    -405, -420, -435, -450, -465, -480, -495, -510, // 2120
+    -510, -495, -480, -465, -450, -435, -420, -405, // 2128
+    -390, -375, -360, -345, -330, -315, -300, -285, // 2136
+    -270, -240, -210, -180, -150, -120, -90, -60, // 2144
+    -30, 0, 30, 60, 90, 120, 150, 180, // 2152
+    210, 240, 270, 285, 300, 315, 330, 345, // 2160
+    360, 375, 390, 405, 420, 435, 450, 465, // 2168
+    480, 495, 510, 540, 525, 510, 495, 480, // 2176
+    465, 450, 435, 420, 405, 390, 375, 360, // 2184
+    345, 330, 315, 300, 285, 255, 225, 195, // 2192
+    165, 135, 105, 75, 45, 15, -15, -45, // 2200
+    -75, -105, -135, -165, -195, -225, -255, -285, // 2208
+    -300, -315, -330, -345, -360, -375, -390, -405, // 2216
+    -420, -435, -450, -465, -480, -495, -510, -525, // 2224
+    -540, -540, -525, -510, -495, -480, -465, -450, // 2232
+    -435, -420, -405, -390, -375, -360, -345, -330, // 2240
+    -315, -300, -285, -255, -225, -195, -165, -135, // 2248
+    -105, -75, -45, -15, 15, 45, 75, 105, // 2256
+    135, 165, 195, 225, 255, 285, 300, 315, // 2264
+    330, 345, 360, 375, 390, 405, 420, 435, // 2272
+    450, 465, 480, 495, 510, 525, 540, 570, // 2280
+    555, 540, 525, 510, 495, 480, 465, 450, // 2288
+    435, 420, 405, 390, 375, 360, 345, 330, // 2296
+    315, 300, 270, 240, 210, 180, 150, 120, // 2304
+    90, 60, 30, 0, -30, -60, -90, -120, // 2312
+    -150, -180, -210, -240, -270, -300, -315, -330, // 2320
+    -345, -360, -375, -390, -405, -420, -435, -450, // 2328
+    -465, -480, -495, -510, -525, -540, -555, -570, // 2336
+    -570, -555, -540, -525, -510, -495, -480, -465, // 2344
+    -450, -435, -420, -405, -390, -375, -360, -345, // 2352
+    -330, -315, -300, -270, -240, -210, -180, -150, // 2360
+    -120, -90, -60, -30, 0, 30, 60, 90, // 2368
+    120, 150, 180, 210, 240, 270, 300, 315, // 2376
+    330, 345, 360, 375, 390, 405, 420, 435, // 2384
+    450, 465, 480, 495, 510, 525, 540, 555, // 2392
+    570                        //2400
+  };
+
+  const float ytemp[2401] = {
+    0, 0, 12.9904, 12.9904, -0, -12.9904, -12.9904, 0, // 0
+    12.9904, 25.9808, 25.9808, 25.9808, 12.9904, -0, -12.9904, -25.9808, // 8
+    -25.9808, -25.9808, -12.9904, 0, 12.9904, 25.9808, 38.9711, 38.9711, // 16
+    38.9711, 38.9711, 25.9808, 12.9904, -0, -12.9904, -25.9808, -38.9711, // 24
+    -38.9711, -38.9711, -38.9711, -25.9808, -12.9904, 0, 12.9904, 25.9808, // 32
+    38.9711, 51.9615, 51.9615, 51.9615, 51.9615, 51.9615, 38.9711, 25.9808, // 40
+    12.9904, -0, -12.9904, -25.9808, -38.9711, -51.9615, -51.9615, -51.9615, // 48
+    -51.9615, -51.9615, -38.9711, -25.9808, -12.9904, 0, 12.9904, 25.9808, // 56
+    38.9711, 51.9615, 64.9519, 64.9519, 64.9519, 64.9519, 64.9519, 64.9519, // 64
+    51.9615, 38.9711, 25.9808, 12.9904, -0, -12.9904, -25.9808, -38.9711, // 72
+    -51.9615, -64.9519, -64.9519, -64.9519, -64.9519, -64.9519, -64.9519, -51.9615, // 80
+    -38.9711, -25.9808, -12.9904, 0, 12.9904, 25.9808, 38.9711, 51.9615, // 88
+    64.9519, 77.9423, 77.9423, 77.9423, 77.9423, 77.9423, 77.9423, 77.9423, // 96
+    64.9519, 51.9615, 38.9711, 25.9808, 12.9904, -0, -12.9904, -25.9808, // 104
+    -38.9711, -51.9615, -64.9519, -77.9423, -77.9423, -77.9423, -77.9423, -77.9423, // 112
+    -77.9423, -77.9423, -64.9519, -51.9615, -38.9711, -25.9808, -12.9904, 0, // 120
+    12.9904, 25.9808, 38.9711, 51.9615, 64.9519, 77.9423, 90.9327, 90.9327, // 128
+    90.9327, 90.9327, 90.9327, 90.9327, 90.9327, 90.9327, 77.9423, 64.9519, // 136
+    51.9615, 38.9711, 25.9808, 12.9904, -0, -12.9904, -25.9808, -38.9711, // 144
+    -51.9615, -64.9519, -77.9423, -90.9327, -90.9327, -90.9327, -90.9327, -90.9327, // 152
+    -90.9327, -90.9327, -90.9327, -77.9423, -64.9519, -51.9615, -38.9711, -25.9808, // 160
+    -12.9904, 0, 12.9904, 25.9808, 38.9711, 51.9615, 64.9519, 77.9423, // 168
+    90.9327, 103.923, 103.923, 103.923, 103.923, 103.923, 103.923, 103.923, // 176
+    103.923, 103.923, 90.9327, 77.9423, 64.9519, 51.9615, 38.9711, 25.9808, // 184
+    12.9904, -0, -12.9904, -25.9808, -38.9711, -51.9615, -64.9519, -77.9423, // 192
+    -90.9327, -103.923, -103.923, -103.923, -103.923, -103.923, -103.923, -103.923, // 200
+    -103.923, -103.923, -90.9327, -77.9423, -64.9519, -51.9615, -38.9711, -25.9808, // 208
+    -12.9904, 0, 12.9904, 25.9808, 38.9711, 51.9615, 64.9519, 77.9423, // 216
+    90.9327, 103.923, 116.913, 116.913, 116.913, 116.913, 116.913, 116.913, // 224
+    116.913, 116.913, 116.913, 116.913, 103.923, 90.9327, 77.9423, 64.9519, // 232
+    51.9615, 38.9711, 25.9808, 12.9904, -0, -12.9904, -25.9808, -38.9711, // 240
+    -51.9615, -64.9519, -77.9423, -90.9327, -103.923, -116.913, -116.913, -116.913, // 248
+    -116.913, -116.913, -116.913, -116.913, -116.913, -116.913, -116.913, -103.923, // 256
+    -90.9327, -77.9423, -64.9519, -51.9615, -38.9711, -25.9808, -12.9904, 0, // 264
+    12.9904, 25.9808, 38.9711, 51.9615, 64.9519, 77.9423, 90.9327, 103.923, // 272
+    116.913, 129.904, 129.904, 129.904, 129.904, 129.904, 129.904, 129.904, // 280
+    129.904, 129.904, 129.904, 129.904, 116.913, 103.923, 90.9327, 77.9423, // 288
+    64.9519, 51.9615, 38.9711, 25.9808, 12.9904, -0, -12.9904, -25.9808, // 296
+    -38.9711, -51.9615, -64.9519, -77.9423, -90.9327, -103.923, -116.913, -129.904, // 304
+    -129.904, -129.904, -129.904, -129.904, -129.904, -129.904, -129.904, -129.904, // 312
+    -129.904, -129.904, -116.913, -103.923, -90.9327, -77.9423, -64.9519, -51.9615, // 320
+    -38.9711, -25.9808, -12.9904, 0, 12.9904, 25.9808, 38.9711, 51.9615, // 328
+    64.9519, 77.9423, 90.9327, 103.923, 116.913, 129.904, 142.894, 142.894, // 336
+    142.894, 142.894, 142.894, 142.894, 142.894, 142.894, 142.894, 142.894, // 344
+    142.894, 142.894, 129.904, 116.913, 103.923, 90.9327, 77.9423, 64.9519, // 352
+    51.9615, 38.9711, 25.9808, 12.9904, -0, -12.9904, -25.9808, -38.9711, // 360
+    -51.9615, -64.9519, -77.9423, -90.9327, -103.923, -116.913, -129.904, -142.894, // 368
+    -142.894, -142.894, -142.894, -142.894, -142.894, -142.894, -142.894, -142.894, // 376
+    -142.894, -142.894, -142.894, -129.904, -116.913, -103.923, -90.9327, -77.9423, // 384
+    -64.9519, -51.9615, -38.9711, -25.9808, -12.9904, 0, 12.9904, 25.9808, // 392
+    38.9711, 51.9615, 64.9519, 77.9423, 90.9327, 103.923, 116.913, 129.904, // 400
+    142.894, 155.885, 155.885, 155.885, 155.885, 155.885, 155.885, 155.885, // 408
+    155.885, 155.885, 155.885, 155.885, 155.885, 155.885, 142.894, 129.904, // 416
+    116.913, 103.923, 90.9327, 77.9423, 64.9519, 51.9615, 38.9711, 25.9808, // 424
+    12.9904, -0, -12.9904, -25.9808, -38.9711, -51.9615, -64.9519, -77.9423, // 432
+    -90.9327, -103.923, -116.913, -129.904, -142.894, -155.885, -155.885, -155.885, // 440
+    -155.885, -155.885, -155.885, -155.885, -155.885, -155.885, -155.885, -155.885, // 448
+    -155.885, -155.885, -142.894, -129.904, -116.913, -103.923, -90.9327, -77.9423, // 456
+    -64.9519, -51.9615, -38.9711, -25.9808, -12.9904, 0, 12.9904, 25.9808, // 464
+    38.9711, 51.9615, 64.9519, 77.9423, 90.9327, 103.923, 116.913, 129.904, // 472
+    142.894, 155.885, 168.875, 168.875, 168.875, 168.875, 168.875, 168.875, // 480
+    168.875, 168.875, 168.875, 168.875, 168.875, 168.875, 168.875, 168.875, // 488
+    155.885, 142.894, 129.904, 116.913, 103.923, 90.9327, 77.9423, 64.9519, // 496
+    51.9615, 38.9711, 25.9808, 12.9904, -0, -12.9904, -25.9808, -38.9711, // 504
+    -51.9615, -64.9519, -77.9423, -90.9327, -103.923, -116.913, -129.904, -142.894, // 512
+    -155.885, -168.875, -168.875, -168.875, -168.875, -168.875, -168.875, -168.875, // 520
+    -168.875, -168.875, -168.875, -168.875, -168.875, -168.875, -168.875, -155.885, // 528
+    -142.894, -129.904, -116.913, -103.923, -90.9327, -77.9423, -64.9519, -51.9615, // 536
+    -38.9711, -25.9808, -12.9904, 0, 12.9904, 25.9808, 38.9711, 51.9615, // 544
+    64.9519, 77.9423, 90.9327, 103.923, 116.913, 129.904, 142.894, 155.885, // 552
+    168.875, 181.865, 181.865, 181.865, 181.865, 181.865, 181.865, 181.865, // 560
+    181.865, 181.865, 181.865, 181.865, 181.865, 181.865, 181.865, 181.865, // 568
+    168.875, 155.885, 142.894, 129.904, 116.913, 103.923, 90.9327, 77.9423, // 576
+    64.9519, 51.9615, 38.9711, 25.9808, 12.9904, -0, -12.9904, -25.9808, // 584
+    -38.9711, -51.9615, -64.9519, -77.9423, -90.9327, -103.923, -116.913, -129.904, // 592
+    -142.894, -155.885, -168.875, -181.865, -181.865, -181.865, -181.865, -181.865, // 600
+    -181.865, -181.865, -181.865, -181.865, -181.865, -181.865, -181.865, -181.865, // 608
+    -181.865, -181.865, -168.875, -155.885, -142.894, -129.904, -116.913, -103.923, // 616
+    -90.9327, -77.9423, -64.9519, -51.9615, -38.9711, -25.9808, -12.9904, 0, // 624
+    12.9904, 25.9808, 38.9711, 51.9615, 64.9519, 77.9423, 90.9327, 103.923, // 632
+    116.913, 129.904, 142.894, 155.885, 168.875, 181.865, 194.856, 194.856, // 640
+    194.856, 194.856, 194.856, 194.856, 194.856, 194.856, 194.856, 194.856, // 648
+    194.856, 194.856, 194.856, 194.856, 194.856, 194.856, 181.865, 168.875, // 656
+    155.885, 142.894, 129.904, 116.913, 103.923, 90.9327, 77.9423, 64.9519, // 664
+    51.9615, 38.9711, 25.9808, 12.9904, -0, -12.9904, -25.9808, -38.9711, // 672
+    -51.9615, -64.9519, -77.9423, -90.9327, -103.923, -116.913, -129.904, -142.894, // 680
+    -155.885, -168.875, -181.865, -194.856, -194.856, -194.856, -194.856, -194.856, // 688
+    -194.856, -194.856, -194.856, -194.856, -194.856, -194.856, -194.856, -194.856, // 696
+    -194.856, -194.856, -194.856, -181.865, -168.875, -155.885, -142.894, -129.904, // 704
+    -116.913, -103.923, -90.9327, -77.9423, -64.9519, -51.9615, -38.9711, -25.9808, // 712
+    -12.9904, 0, 12.9904, 25.9808, 38.9711, 51.9615, 64.9519, 77.9423, // 720
+    90.9327, 103.923, 116.913, 129.904, 142.894, 155.885, 168.875, 181.865, // 728
+    194.856, 207.846, 207.846, 207.846, 207.846, 207.846, 207.846, 207.846, // 736
+    207.846, 207.846, 207.846, 207.846, 207.846, 207.846, 207.846, 207.846, // 744
+    207.846, 207.846, 194.856, 181.865, 168.875, 155.885, 142.894, 129.904, // 752
+    116.913, 103.923, 90.9327, 77.9423, 64.9519, 51.9615, 38.9711, 25.9808, // 760
+    12.9904, -0, -12.9904, -25.9808, -38.9711, -51.9615, -64.9519, -77.9423, // 768
+    -90.9327, -103.923, -116.913, -129.904, -142.894, -155.885, -168.875, -181.865, // 776
+    -194.856, -207.846, -207.846, -207.846, -207.846, -207.846, -207.846, -207.846, // 784
+    -207.846, -207.846, -207.846, -207.846, -207.846, -207.846, -207.846, -207.846, // 792
+    -207.846, -207.846, -194.856, -181.865, -168.875, -155.885, -142.894, -129.904, // 800
+    -116.913, -103.923, -90.9327, -77.9423, -64.9519, -51.9615, -38.9711, -25.9808, // 808
+    -12.9904, 0, 12.9904, 25.9808, 38.9711, 51.9615, 64.9519, 77.9423, // 816
+    90.9327, 103.923, 116.913, 129.904, 142.894, 155.885, 168.875, 181.865, // 824
+    194.856, 207.846, 220.836, 220.836, 220.836, 220.836, 220.836, 220.836, // 832
+    220.836, 220.836, 220.836, 220.836, 220.836, 220.836, 220.836, 220.836, // 840
+    220.836, 220.836, 220.836, 220.836, 207.846, 194.856, 181.865, 168.875, // 848
+    155.885, 142.894, 129.904, 116.913, 103.923, 90.9327, 77.9423, 64.9519, // 856
+    51.9615, 38.9711, 25.9808, 12.9904, -0, -12.9904, -25.9808, -38.9711, // 864
+    -51.9615, -64.9519, -77.9423, -90.9327, -103.923, -116.913, -129.904, -142.894, // 872
+    -155.885, -168.875, -181.865, -194.856, -207.846, -220.836, -220.836, -220.836, // 880
+    -220.836, -220.836, -220.836, -220.836, -220.836, -220.836, -220.836, -220.836, // 888
+    -220.836, -220.836, -220.836, -220.836, -220.836, -220.836, -220.836, -207.846, // 896
+    -194.856, -181.865, -168.875, -155.885, -142.894, -129.904, -116.913, -103.923, // 904
+    -90.9327, -77.9423, -64.9519, -51.9615, -38.9711, -25.9808, -12.9904, 0, // 912
+    12.9904, 25.9808, 38.9711, 51.9615, 64.9519, 77.9423, 90.9327, 103.923, // 920
+    116.913, 129.904, 142.894, 155.885, 168.875, 181.865, 194.856, 207.846, // 928
+    220.836, 233.827, 233.827, 233.827, 233.827, 233.827, 233.827, 233.827, // 936
+    233.827, 233.827, 233.827, 233.827, 233.827, 233.827, 233.827, 233.827, // 944
+    233.827, 233.827, 233.827, 233.827, 220.836, 207.846, 194.856, 181.865, // 952
+    168.875, 155.885, 142.894, 129.904, 116.913, 103.923, 90.9327, 77.9423, // 960
+    64.9519, 51.9615, 38.9711, 25.9808, 12.9904, -0, -12.9904, -25.9808, // 968
+    -38.9711, -51.9615, -64.9519, -77.9423, -90.9327, -103.923, -116.913, -129.904, // 976
+    -142.894, -155.885, -168.875, -181.865, -194.856, -207.846, -220.836, -233.827, // 984
+    -233.827, -233.827, -233.827, -233.827, -233.827, -233.827, -233.827, -233.827, // 992
+    -233.827, -233.827, -233.827, -233.827, -233.827, -233.827, -233.827, -233.827, // 1000
+    -233.827, -233.827, -220.836, -207.846, -194.856, -181.865, -168.875, -155.885, // 1008
+    -142.894, -129.904, -116.913, -103.923, -90.9327, -77.9423, -64.9519, -51.9615, // 1016
+    -38.9711, -25.9808, -12.9904, 0, 12.9904, 25.9808, 38.9711, 51.9615, // 1024
+    64.9519, 77.9423, 90.9327, 103.923, 116.913, 129.904, 142.894, 155.885, // 1032
+    168.875, 181.865, 194.856, 207.846, 220.836, 233.827, 246.817, 246.817, // 1040
+    246.817, 246.817, 246.817, 246.817, 246.817, 246.817, 246.817, 246.817, // 1048
+    246.817, 246.817, 246.817, 246.817, 246.817, 246.817, 246.817, 246.817, // 1056
+    246.817, 246.817, 233.827, 220.836, 207.846, 194.856, 181.865, 168.875, // 1064
+    155.885, 142.894, 129.904, 116.913, 103.923, 90.9327, 77.9423, 64.9519, // 1072
+    51.9615, 38.9711, 25.9808, 12.9904, -0, -12.9904, -25.9808, -38.9711, // 1080
+    -51.9615, -64.9519, -77.9423, -90.9327, -103.923, -116.913, -129.904, -142.894, // 1088
+    -155.885, -168.875, -181.865, -194.856, -207.846, -220.836, -233.827, -246.817, // 1096
+    -246.817, -246.817, -246.817, -246.817, -246.817, -246.817, -246.817, -246.817, // 1104
+    -246.817, -246.817, -246.817, -246.817, -246.817, -246.817, -246.817, -246.817, // 1112
+    -246.817, -246.817, -246.817, -233.827, -220.836, -207.846, -194.856, -181.865, // 1120
+    -168.875, -155.885, -142.894, -129.904, -116.913, -103.923, -90.9327, -77.9423, // 1128
+    -64.9519, -51.9615, -38.9711, -25.9808, -12.9904, 0, 12.9904, 25.9808, // 1136
+    38.9711, 51.9615, 64.9519, 77.9423, 90.9327, 103.923, 116.913, 129.904, // 1144
+    142.894, 155.885, 168.875, 181.865, 194.856, 207.846, 220.836, 233.827, // 1152
+    246.817, 259.808, 259.808, 259.808, 259.808, 259.808, 259.808, 259.808, // 1160
+    259.808, 259.808, 259.808, 259.808, 259.808, 259.808, 259.808, 259.808, // 1168
+    259.808, 259.808, 259.808, 259.808, 259.808, 259.808, 246.817, 233.827, // 1176
+    220.836, 207.846, 194.856, 181.865, 168.875, 155.885, 142.894, 129.904, // 1184
+    116.913, 103.923, 90.9327, 77.9423, 64.9519, 51.9615, 38.9711, 25.9808, // 1192
+    12.9904, -0, -12.9904, -25.9808, -38.9711, -51.9615, -64.9519, -77.9423, // 1200
+    -90.9327, -103.923, -116.913, -129.904, -142.894, -155.885, -168.875, -181.865, // 1208
+    -194.856, -207.846, -220.836, -233.827, -246.817, -259.808, -259.808, -259.808, // 1216
+    -259.808, -259.808, -259.808, -259.808, -259.808, -259.808, -259.808, -259.808, // 1224
+    -259.808, -259.808, -259.808, -259.808, -259.808, -259.808, -259.808, -259.808, // 1232
+    -259.808, -259.808, -246.817, -233.827, -220.836, -207.846, -194.856, -181.865, // 1240
+    -168.875, -155.885, -142.894, -129.904, -116.913, -103.923, -90.9327, -77.9423, // 1248
+    -64.9519, -51.9615, -38.9711, -25.9808, -12.9904, 0, 12.9904, 25.9808, // 1256
+    38.9711, 51.9615, 64.9519, 77.9423, 90.9327, 103.923, 116.913, 129.904, // 1264
+    142.894, 155.885, 168.875, 181.865, 194.856, 207.846, 220.836, 233.827, // 1272
+    246.817, 259.808, 272.798, 272.798, 272.798, 272.798, 272.798, 272.798, // 1280
+    272.798, 272.798, 272.798, 272.798, 272.798, 272.798, 272.798, 272.798, // 1288
+    272.798, 272.798, 272.798, 272.798, 272.798, 272.798, 272.798, 272.798, // 1296
+    259.808, 246.817, 233.827, 220.836, 207.846, 194.856, 181.865, 168.875, // 1304
+    155.885, 142.894, 129.904, 116.913, 103.923, 90.9327, 77.9423, 64.9519, // 1312
+    51.9615, 38.9711, 25.9808, 12.9904, -0, -12.9904, -25.9808, -38.9711, // 1320
+    -51.9615, -64.9519, -77.9423, -90.9327, -103.923, -116.913, -129.904, -142.894, // 1328
+    -155.885, -168.875, -181.865, -194.856, -207.846, -220.836, -233.827, -246.817, // 1336
+    -259.808, -272.798, -272.798, -272.798, -272.798, -272.798, -272.798, -272.798, // 1344
+    -272.798, -272.798, -272.798, -272.798, -272.798, -272.798, -272.798, -272.798, // 1352
+    -272.798, -272.798, -272.798, -272.798, -272.798, -272.798, -272.798, -259.808, // 1360
+    -246.817, -233.827, -220.836, -207.846, -194.856, -181.865, -168.875, -155.885, // 1368
+    -142.894, -129.904, -116.913, -103.923, -90.9327, -77.9423, -64.9519, -51.9615, // 1376
+    -38.9711, -25.9808, -12.9904, 0, 12.9904, 25.9808, 38.9711, 51.9615, // 1384
+    64.9519, 77.9423, 90.9327, 103.923, 116.913, 129.904, 142.894, 155.885, // 1392
+    168.875, 181.865, 194.856, 207.846, 220.836, 233.827, 246.817, 259.808, // 1400
+    272.798, 285.788, 285.788, 285.788, 285.788, 285.788, 285.788, 285.788, // 1408
+    285.788, 285.788, 285.788, 285.788, 285.788, 285.788, 285.788, 285.788, // 1416
+    285.788, 285.788, 285.788, 285.788, 285.788, 285.788, 285.788, 285.788, // 1424
+    272.798, 259.808, 246.817, 233.827, 220.836, 207.846, 194.856, 181.865, // 1432
+    168.875, 155.885, 142.894, 129.904, 116.913, 103.923, 90.9327, 77.9423, // 1440
+    64.9519, 51.9615, 38.9711, 25.9808, 12.9904, -0, -12.9904, -25.9808, // 1448
+    -38.9711, -51.9615, -64.9519, -77.9423, -90.9327, -103.923, -116.913, -129.904, // 1456
+    -142.894, -155.885, -168.875, -181.865, -194.856, -207.846, -220.836, -233.827, // 1464
+    -246.817, -259.808, -272.798, -285.788, -285.788, -285.788, -285.788, -285.788, // 1472
+    -285.788, -285.788, -285.788, -285.788, -285.788, -285.788, -285.788, -285.788, // 1480
+    -285.788, -285.788, -285.788, -285.788, -285.788, -285.788, -285.788, -285.788, // 1488
+    -285.788, -285.788, -272.798, -259.808, -246.817, -233.827, -220.836, -207.846, // 1496
+    -194.856, -181.865, -168.875, -155.885, -142.894, -129.904, -116.913, -103.923, // 1504
+    -90.9327, -77.9423, -64.9519, -51.9615, -38.9711, -25.9808, -12.9904, 0, // 1512
+    12.9904, 25.9808, 38.9711, 51.9615, 64.9519, 77.9423, 90.9327, 103.923, // 1520
+    116.913, 129.904, 142.894, 155.885, 168.875, 181.865, 194.856, 207.846, // 1528
+    220.836, 233.827, 246.817, 259.808, 272.798, 285.788, 298.779, 298.779, // 1536
+    298.779, 298.779, 298.779, 298.779, 298.779, 298.779, 298.779, 298.779, // 1544
+    298.779, 298.779, 298.779, 298.779, 298.779, 298.779, 298.779, 298.779, // 1552
+    298.779, 298.779, 298.779, 298.779, 298.779, 298.779, 285.788, 272.798, // 1560
+    259.808, 246.817, 233.827, 220.836, 207.846, 194.856, 181.865, 168.875, // 1568
+    155.885, 142.894, 129.904, 116.913, 103.923, 90.9327, 77.9423, 64.9519, // 1576
+    51.9615, 38.9711, 25.9808, 12.9904, -0, -12.9904, -25.9808, -38.9711, // 1584
+    -51.9615, -64.9519, -77.9423, -90.9327, -103.923, -116.913, -129.904, -142.894, // 1592
+    -155.885, -168.875, -181.865, -194.856, -207.846, -220.836, -233.827, -246.817, // 1600
+    -259.808, -272.798, -285.788, -298.779, -298.779, -298.779, -298.779, -298.779, // 1608
+    -298.779, -298.779, -298.779, -298.779, -298.779, -298.779, -298.779, -298.779, // 1616
+    -298.779, -298.779, -298.779, -298.779, -298.779, -298.779, -298.779, -298.779, // 1624
+    -298.779, -298.779, -298.779, -285.788, -272.798, -259.808, -246.817, -233.827, // 1632
+    -220.836, -207.846, -194.856, -181.865, -168.875, -155.885, -142.894, -129.904, // 1640
+    -116.913, -103.923, -90.9327, -77.9423, -64.9519, -51.9615, -38.9711, -25.9808, // 1648
+    -12.9904, 17.3205, 43.3013, 69.282, 95.2628, 121.244, 147.224, 173.205, // 1656
+    199.186, 225.167, 251.147, 277.128, 303.109, 320.429, 320.429, 320.429, // 1664
+    320.429, 320.429, 320.429, 320.429, 320.429, 320.429, 320.429, 320.429, // 1672
+    320.429, 303.109, 277.128, 251.147, 225.167, 199.186, 173.205, 147.224, // 1680
+    121.244, 95.2628, 69.282, 43.3013, 17.3205, -17.3205, -43.3013, -69.282, // 1688
+    -95.2628, -121.244, -147.224, -173.205, -199.186, -225.167, -251.147, -277.128, // 1696
+    -303.109, -320.429, -320.429, -320.429, -320.429, -320.429, -320.429, -320.429, // 1704
+    -320.429, -320.429, -320.429, -320.429, -320.429, -303.109, -277.128, -251.147, // 1712
+    -225.167, -199.186, -173.205, -147.224, -121.244, -95.2628, -69.282, -43.3013, // 1720
+    -17.3205, 17.3205, 43.3013, 69.282, 95.2628, 121.244, 147.224, 173.205, // 1728
+    199.186, 225.167, 251.147, 277.128, 303.109, 329.09, 346.41, 346.41, // 1736
+    346.41, 346.41, 346.41, 346.41, 346.41, 346.41, 346.41, 346.41, // 1744
+    346.41, 346.41, 346.41, 329.09, 303.109, 277.128, 251.147, 225.167, // 1752
+    199.186, 173.205, 147.224, 121.244, 95.2628, 69.282, 43.3013, 17.3205, // 1760
+    -17.3205, -43.3013, -69.282, -95.2628, -121.244, -147.224, -173.205, -199.186, // 1768
+    -225.167, -251.147, -277.128, -303.109, -329.09, -346.41, -346.41, -346.41, // 1776
+    -346.41, -346.41, -346.41, -346.41, -346.41, -346.41, -346.41, -346.41, // 1784
+    -346.41, -346.41, -329.09, -303.109, -277.128, -251.147, -225.167, -199.186, // 1792
+    -173.205, -147.224, -121.244, -95.2628, -69.282, -43.3013, -17.3205, 17.3205, // 1800
+    43.3013, 69.282, 95.2628, 121.244, 147.224, 173.205, 199.186, 225.167, // 1808
+    251.147, 277.128, 303.109, 329.09, 355.07, 372.391, 372.391, 372.391, // 1816
+    372.391, 372.391, 372.391, 372.391, 372.391, 372.391, 372.391, 372.391, // 1824
+    372.391, 372.391, 372.391, 355.07, 329.09, 303.109, 277.128, 251.147, // 1832
+    225.167, 199.186, 173.205, 147.224, 121.244, 95.2628, 69.282, 43.3013, // 1840
+    17.3205, -17.3205, -43.3013, -69.282, -95.2628, -121.244, -147.224, -173.205, // 1848
+    -199.186, -225.167, -251.147, -277.128, -303.109, -329.09, -355.07, -372.391, // 1856
+    -372.391, -372.391, -372.391, -372.391, -372.391, -372.391, -372.391, -372.391, // 1864
+    -372.391, -372.391, -372.391, -372.391, -372.391, -355.07, -329.09, -303.109, // 1872
+    -277.128, -251.147, -225.167, -199.186, -173.205, -147.224, -121.244, -95.2628, // 1880
+    -69.282, -43.3013, -17.3205, 17.3205, 43.3013, 69.282, 95.2628, 121.244, // 1888
+    147.224, 173.205, 199.186, 225.167, 251.147, 277.128, 303.109, 329.09, // 1896
+    355.07, 381.051, 398.372, 398.372, 398.372, 398.372, 398.372, 398.372, // 1904
+    398.372, 398.372, 398.372, 398.372, 398.372, 398.372, 398.372, 398.372, // 1912
+    398.372, 381.051, 355.07, 329.09, 303.109, 277.128, 251.147, 225.167, // 1920
+    199.186, 173.205, 147.224, 121.244, 95.2628, 69.282, 43.3013, 17.3205, // 1928
+    -17.3205, -43.3013, -69.282, -95.2628, -121.244, -147.224, -173.205, -199.186, // 1936
+    -225.167, -251.147, -277.128, -303.109, -329.09, -355.07, -381.051, -398.372, // 1944
+    -398.372, -398.372, -398.372, -398.372, -398.372, -398.372, -398.372, -398.372, // 1952
+    -398.372, -398.372, -398.372, -398.372, -398.372, -398.372, -381.051, -355.07, // 1960
+    -329.09, -303.109, -277.128, -251.147, -225.167, -199.186, -173.205, -147.224, // 1968
+    -121.244, -95.2628, -69.282, -43.3013, -17.3205, 17.3205, 43.3013, 69.282, // 1976
+    95.2628, 121.244, 147.224, 173.205, 199.186, 225.167, 251.147, 277.128, // 1984
+    303.109, 329.09, 355.07, 381.051, 407.032, 424.352, 424.352, 424.352, // 1992
+    424.352, 424.352, 424.352, 424.352, 424.352, 424.352, 424.352, 424.352, // 2000
+    424.352, 424.352, 424.352, 424.352, 424.352, 407.032, 381.051, 355.07, // 2008
+    329.09, 303.109, 277.128, 251.147, 225.167, 199.186, 173.205, 147.224, // 2016
+    121.244, 95.2628, 69.282, 43.3013, 17.3205, -17.3205, -43.3013, -69.282, // 2024
+    -95.2628, -121.244, -147.224, -173.205, -199.186, -225.167, -251.147, -277.128, // 2032
+    -303.109, -329.09, -355.07, -381.051, -407.032, -424.352, -424.352, -424.352, // 2040
+    -424.352, -424.352, -424.352, -424.352, -424.352, -424.352, -424.352, -424.352, // 2048
+    -424.352, -424.352, -424.352, -424.352, -424.352, -407.032, -381.051, -355.07, // 2056
+    -329.09, -303.109, -277.128, -251.147, -225.167, -199.186, -173.205, -147.224, // 2064
+    -121.244, -95.2628, -69.282, -43.3013, -17.3205, 17.3205, 43.3013, 69.282, // 2072
+    95.2628, 121.244, 147.224, 173.205, 199.186, 225.167, 251.147, 277.128, // 2080
+    303.109, 329.09, 355.07, 381.051, 407.032, 433.013, 450.333, 450.333, // 2088
+    450.333, 450.333, 450.333, 450.333, 450.333, 450.333, 450.333, 450.333, // 2096
+    450.333, 450.333, 450.333, 450.333, 450.333, 450.333, 450.333, 433.013, // 2104
+    407.032, 381.051, 355.07, 329.09, 303.109, 277.128, 251.147, 225.167, // 2112
+    199.186, 173.205, 147.224, 121.244, 95.2628, 69.282, 43.3013, 17.3205, // 2120
+    -17.3205, -43.3013, -69.282, -95.2628, -121.244, -147.224, -173.205, -199.186, // 2128
+    -225.167, -251.147, -277.128, -303.109, -329.09, -355.07, -381.051, -407.032, // 2136
+    -433.013, -450.333, -450.333, -450.333, -450.333, -450.333, -450.333, -450.333, // 2144
+    -450.333, -450.333, -450.333, -450.333, -450.333, -450.333, -450.333, -450.333, // 2152
+    -450.333, -450.333, -433.013, -407.032, -381.051, -355.07, -329.09, -303.109, // 2160
+    -277.128, -251.147, -225.167, -199.186, -173.205, -147.224, -121.244, -95.2628, // 2168
+    -69.282, -43.3013, -17.3205, 17.3205, 43.3013, 69.282, 95.2628, 121.244, // 2176
+    147.224, 173.205, 199.186, 225.167, 251.147, 277.128, 303.109, 329.09, // 2184
+    355.07, 381.051, 407.032, 433.013, 458.993, 476.314, 476.314, 476.314, // 2192
+    476.314, 476.314, 476.314, 476.314, 476.314, 476.314, 476.314, 476.314, // 2200
+    476.314, 476.314, 476.314, 476.314, 476.314, 476.314, 476.314, 458.993, // 2208
+    433.013, 407.032, 381.051, 355.07, 329.09, 303.109, 277.128, 251.147, // 2216
+    225.167, 199.186, 173.205, 147.224, 121.244, 95.2628, 69.282, 43.3013, // 2224
+    17.3205, -17.3205, -43.3013, -69.282, -95.2628, -121.244, -147.224, -173.205, // 2232
+    -199.186, -225.167, -251.147, -277.128, -303.109, -329.09, -355.07, -381.051, // 2240
+    -407.032, -433.013, -458.993, -476.314, -476.314, -476.314, -476.314, -476.314, // 2248
+    -476.314, -476.314, -476.314, -476.314, -476.314, -476.314, -476.314, -476.314, // 2256
+    -476.314, -476.314, -476.314, -476.314, -476.314, -458.993, -433.013, -407.032, // 2264
+    -381.051, -355.07, -329.09, -303.109, -277.128, -251.147, -225.167, -199.186, // 2272
+    -173.205, -147.224, -121.244, -95.2628, -69.282, -43.3013, -17.3205, 17.3205, // 2280
+    43.3013, 69.282, 95.2628, 121.244, 147.224, 173.205, 199.186, 225.167, // 2288
+    251.147, 277.128, 303.109, 329.09, 355.07, 381.051, 407.032, 433.013, // 2296
+    458.993, 484.974, 502.295, 502.295, 502.295, 502.295, 502.295, 502.295, // 2304
+    502.295, 502.295, 502.295, 502.295, 502.295, 502.295, 502.295, 502.295, // 2312
+    502.295, 502.295, 502.295, 502.295, 502.295, 484.974, 458.993, 433.013, // 2320
+    407.032, 381.051, 355.07, 329.09, 303.109, 277.128, 251.147, 225.167, // 2328
+    199.186, 173.205, 147.224, 121.244, 95.2628, 69.282, 43.3013, 17.3205, // 2336
+    -17.3205, -43.3013, -69.282, -95.2628, -121.244, -147.224, -173.205, -199.186, // 2344
+    -225.167, -251.147, -277.128, -303.109, -329.09, -355.07, -381.051, -407.032, // 2352
+    -433.013, -458.993, -484.974, -502.295, -502.295, -502.295, -502.295, -502.295, // 2360
+    -502.295, -502.295, -502.295, -502.295, -502.295, -502.295, -502.295, -502.295, // 2368
+    -502.295, -502.295, -502.295, -502.295, -502.295, -502.295, -484.974, -458.993, // 2376
+    -433.013, -407.032, -381.051, -355.07, -329.09, -303.109, -277.128, -251.147, // 2384
+    -225.167, -199.186, -173.205, -147.224, -121.244, -95.2628, -69.282, -43.3013, // 2392
+    -17.3205                        //2400
+  };
+
+  const float dtemp[2401] = {
+    15, 15, 15, 15, 15, 15, 15, 15, // 0
+    15, 15, 15, 15, 15, 15, 15, 15, // 8
+    15, 15, 15, 15, 15, 15, 15, 15, // 16
+    15, 15, 15, 15, 15, 15, 15, 15, // 24
+    15, 15, 15, 15, 15, 15, 15, 15, // 32
+    15, 15, 15, 15, 15, 15, 15, 15, // 40
+    15, 15, 15, 15, 15, 15, 15, 15, // 48
+    15, 15, 15, 15, 15, 15, 15, 15, // 56
+    15, 15, 15, 15, 15, 15, 15, 15, // 64
+    15, 15, 15, 15, 15, 15, 15, 15, // 72
+    15, 15, 15, 15, 15, 15, 15, 15, // 80
+    15, 15, 15, 15, 15, 15, 15, 15, // 88
+    15, 15, 15, 15, 15, 15, 15, 15, // 96
+    15, 15, 15, 15, 15, 15, 15, 15, // 104
+    15, 15, 15, 15, 15, 15, 15, 15, // 112
+    15, 15, 15, 15, 15, 15, 15, 15, // 120
+    15, 15, 15, 15, 15, 15, 15, 15, // 128
+    15, 15, 15, 15, 15, 15, 15, 15, // 136
+    15, 15, 15, 15, 15, 15, 15, 15, // 144
+    15, 15, 15, 15, 15, 15, 15, 15, // 152
+    15, 15, 15, 15, 15, 15, 15, 15, // 160
+    15, 15, 15, 15, 15, 15, 15, 15, // 168
+    15, 15, 15, 15, 15, 15, 15, 15, // 176
+    15, 15, 15, 15, 15, 15, 15, 15, // 184
+    15, 15, 15, 15, 15, 15, 15, 15, // 192
+    15, 15, 15, 15, 15, 15, 15, 15, // 200
+    15, 15, 15, 15, 15, 15, 15, 15, // 208
+    15, 15, 15, 15, 15, 15, 15, 15, // 216
+    15, 15, 15, 15, 15, 15, 15, 15, // 224
+    15, 15, 15, 15, 15, 15, 15, 15, // 232
+    15, 15, 15, 15, 15, 15, 15, 15, // 240
+    15, 15, 15, 15, 15, 15, 15, 15, // 248
+    15, 15, 15, 15, 15, 15, 15, 15, // 256
+    15, 15, 15, 15, 15, 15, 15, 15, // 264
+    15, 15, 15, 15, 15, 15, 15, 15, // 272
+    15, 15, 15, 15, 15, 15, 15, 15, // 280
+    15, 15, 15, 15, 15, 15, 15, 15, // 288
+    15, 15, 15, 15, 15, 15, 15, 15, // 296
+    15, 15, 15, 15, 15, 15, 15, 15, // 304
+    15, 15, 15, 15, 15, 15, 15, 15, // 312
+    15, 15, 15, 15, 15, 15, 15, 15, // 320
+    15, 15, 15, 15, 15, 15, 15, 15, // 328
+    15, 15, 15, 15, 15, 15, 15, 15, // 336
+    15, 15, 15, 15, 15, 15, 15, 15, // 344
+    15, 15, 15, 15, 15, 15, 15, 15, // 352
+    15, 15, 15, 15, 15, 15, 15, 15, // 360
+    15, 15, 15, 15, 15, 15, 15, 15, // 368
+    15, 15, 15, 15, 15, 15, 15, 15, // 376
+    15, 15, 15, 15, 15, 15, 15, 15, // 384
+    15, 15, 15, 15, 15, 15, 15, 15, // 392
+    15, 15, 15, 15, 15, 15, 15, 15, // 400
+    15, 15, 15, 15, 15, 15, 15, 15, // 408
+    15, 15, 15, 15, 15, 15, 15, 15, // 416
+    15, 15, 15, 15, 15, 15, 15, 15, // 424
+    15, 15, 15, 15, 15, 15, 15, 15, // 432
+    15, 15, 15, 15, 15, 15, 15, 15, // 440
+    15, 15, 15, 15, 15, 15, 15, 15, // 448
+    15, 15, 15, 15, 15, 15, 15, 15, // 456
+    15, 15, 15, 15, 15, 15, 15, 15, // 464
+    15, 15, 15, 15, 15, 15, 15, 15, // 472
+    15, 15, 15, 15, 15, 15, 15, 15, // 480
+    15, 15, 15, 15, 15, 15, 15, 15, // 488
+    15, 15, 15, 15, 15, 15, 15, 15, // 496
+    15, 15, 15, 15, 15, 15, 15, 15, // 504
+    15, 15, 15, 15, 15, 15, 15, 15, // 512
+    15, 15, 15, 15, 15, 15, 15, 15, // 520
+    15, 15, 15, 15, 15, 15, 15, 15, // 528
+    15, 15, 15, 15, 15, 15, 15, 15, // 536
+    15, 15, 15, 15, 15, 15, 15, 15, // 544
+    15, 15, 15, 15, 15, 15, 15, 15, // 552
+    15, 15, 15, 15, 15, 15, 15, 15, // 560
+    15, 15, 15, 15, 15, 15, 15, 15, // 568
+    15, 15, 15, 15, 15, 15, 15, 15, // 576
+    15, 15, 15, 15, 15, 15, 15, 15, // 584
+    15, 15, 15, 15, 15, 15, 15, 15, // 592
+    15, 15, 15, 15, 15, 15, 15, 15, // 600
+    15, 15, 15, 15, 15, 15, 15, 15, // 608
+    15, 15, 15, 15, 15, 15, 15, 15, // 616
+    15, 15, 15, 15, 15, 15, 15, 15, // 624
+    15, 15, 15, 15, 15, 15, 15, 15, // 632
+    15, 15, 15, 15, 15, 15, 15, 15, // 640
+    15, 15, 15, 15, 15, 15, 15, 15, // 648
+    15, 15, 15, 15, 15, 15, 15, 15, // 656
+    15, 15, 15, 15, 15, 15, 15, 15, // 664
+    15, 15, 15, 15, 15, 15, 15, 15, // 672
+    15, 15, 15, 15, 15, 15, 15, 15, // 680
+    15, 15, 15, 15, 15, 15, 15, 15, // 688
+    15, 15, 15, 15, 15, 15, 15, 15, // 696
+    15, 15, 15, 15, 15, 15, 15, 15, // 704
+    15, 15, 15, 15, 15, 15, 15, 15, // 712
+    15, 15, 15, 15, 15, 15, 15, 15, // 720
+    15, 15, 15, 15, 15, 15, 15, 15, // 728
+    15, 15, 15, 15, 15, 15, 15, 15, // 736
+    15, 15, 15, 15, 15, 15, 15, 15, // 744
+    15, 15, 15, 15, 15, 15, 15, 15, // 752
+    15, 15, 15, 15, 15, 15, 15, 15, // 760
+    15, 15, 15, 15, 15, 15, 15, 15, // 768
+    15, 15, 15, 15, 15, 15, 15, 15, // 776
+    15, 15, 15, 15, 15, 15, 15, 15, // 784
+    15, 15, 15, 15, 15, 15, 15, 15, // 792
+    15, 15, 15, 15, 15, 15, 15, 15, // 800
+    15, 15, 15, 15, 15, 15, 15, 15, // 808
+    15, 15, 15, 15, 15, 15, 15, 15, // 816
+    15, 15, 15, 15, 15, 15, 15, 15, // 824
+    15, 15, 15, 15, 15, 15, 15, 15, // 832
+    15, 15, 15, 15, 15, 15, 15, 15, // 840
+    15, 15, 15, 15, 15, 15, 15, 15, // 848
+    15, 15, 15, 15, 15, 15, 15, 15, // 856
+    15, 15, 15, 15, 15, 15, 15, 15, // 864
+    15, 15, 15, 15, 15, 15, 15, 15, // 872
+    15, 15, 15, 15, 15, 15, 15, 15, // 880
+    15, 15, 15, 15, 15, 15, 15, 15, // 888
+    15, 15, 15, 15, 15, 15, 15, 15, // 896
+    15, 15, 15, 15, 15, 15, 15, 15, // 904
+    15, 15, 15, 15, 15, 15, 15, 15, // 912
+    15, 15, 15, 15, 15, 15, 15, 15, // 920
+    15, 15, 15, 15, 15, 15, 15, 15, // 928
+    15, 15, 15, 15, 15, 15, 15, 15, // 936
+    15, 15, 15, 15, 15, 15, 15, 15, // 944
+    15, 15, 15, 15, 15, 15, 15, 15, // 952
+    15, 15, 15, 15, 15, 15, 15, 15, // 960
+    15, 15, 15, 15, 15, 15, 15, 15, // 968
+    15, 15, 15, 15, 15, 15, 15, 15, // 976
+    15, 15, 15, 15, 15, 15, 15, 15, // 984
+    15, 15, 15, 15, 15, 15, 15, 15, // 992
+    15, 15, 15, 15, 15, 15, 15, 15, // 1000
+    15, 15, 15, 15, 15, 15, 15, 15, // 1008
+    15, 15, 15, 15, 15, 15, 15, 15, // 1016
+    15, 15, 15, 15, 15, 15, 15, 15, // 1024
+    15, 15, 15, 15, 15, 15, 15, 15, // 1032
+    15, 15, 15, 15, 15, 15, 15, 15, // 1040
+    15, 15, 15, 15, 15, 15, 15, 15, // 1048
+    15, 15, 15, 15, 15, 15, 15, 15, // 1056
+    15, 15, 15, 15, 15, 15, 15, 15, // 1064
+    15, 15, 15, 15, 15, 15, 15, 15, // 1072
+    15, 15, 15, 15, 15, 15, 15, 15, // 1080
+    15, 15, 15, 15, 15, 15, 15, 15, // 1088
+    15, 15, 15, 15, 15, 15, 15, 15, // 1096
+    15, 15, 15, 15, 15, 15, 15, 15, // 1104
+    15, 15, 15, 15, 15, 15, 15, 15, // 1112
+    15, 15, 15, 15, 15, 15, 15, 15, // 1120
+    15, 15, 15, 15, 15, 15, 15, 15, // 1128
+    15, 15, 15, 15, 15, 15, 15, 15, // 1136
+    15, 15, 15, 15, 15, 15, 15, 15, // 1144
+    15, 15, 15, 15, 15, 15, 15, 15, // 1152
+    15, 15, 15, 15, 15, 15, 15, 15, // 1160
+    15, 15, 15, 15, 15, 15, 15, 15, // 1168
+    15, 15, 15, 15, 15, 15, 15, 15, // 1176
+    15, 15, 15, 15, 15, 15, 15, 15, // 1184
+    15, 15, 15, 15, 15, 15, 15, 15, // 1192
+    15, 15, 15, 15, 15, 15, 15, 15, // 1200
+    15, 15, 15, 15, 15, 15, 15, 15, // 1208
+    15, 15, 15, 15, 15, 15, 15, 15, // 1216
+    15, 15, 15, 15, 15, 15, 15, 15, // 1224
+    15, 15, 15, 15, 15, 15, 15, 15, // 1232
+    15, 15, 15, 15, 15, 15, 15, 15, // 1240
+    15, 15, 15, 15, 15, 15, 15, 15, // 1248
+    15, 15, 15, 15, 15, 15, 15, 15, // 1256
+    15, 15, 15, 15, 15, 15, 15, 15, // 1264
+    15, 15, 15, 15, 15, 15, 15, 15, // 1272
+    15, 15, 15, 15, 15, 15, 15, 15, // 1280
+    15, 15, 15, 15, 15, 15, 15, 15, // 1288
+    15, 15, 15, 15, 15, 15, 15, 15, // 1296
+    15, 15, 15, 15, 15, 15, 15, 15, // 1304
+    15, 15, 15, 15, 15, 15, 15, 15, // 1312
+    15, 15, 15, 15, 15, 15, 15, 15, // 1320
+    15, 15, 15, 15, 15, 15, 15, 15, // 1328
+    15, 15, 15, 15, 15, 15, 15, 15, // 1336
+    15, 15, 15, 15, 15, 15, 15, 15, // 1344
+    15, 15, 15, 15, 15, 15, 15, 15, // 1352
+    15, 15, 15, 15, 15, 15, 15, 15, // 1360
+    15, 15, 15, 15, 15, 15, 15, 15, // 1368
+    15, 15, 15, 15, 15, 15, 15, 15, // 1376
+    15, 15, 15, 15, 15, 15, 15, 15, // 1384
+    15, 15, 15, 15, 15, 15, 15, 15, // 1392
+    15, 15, 15, 15, 15, 15, 15, 15, // 1400
+    15, 15, 15, 15, 15, 15, 15, 15, // 1408
+    15, 15, 15, 15, 15, 15, 15, 15, // 1416
+    15, 15, 15, 15, 15, 15, 15, 15, // 1424
+    15, 15, 15, 15, 15, 15, 15, 15, // 1432
+    15, 15, 15, 15, 15, 15, 15, 15, // 1440
+    15, 15, 15, 15, 15, 15, 15, 15, // 1448
+    15, 15, 15, 15, 15, 15, 15, 15, // 1456
+    15, 15, 15, 15, 15, 15, 15, 15, // 1464
+    15, 15, 15, 15, 15, 15, 15, 15, // 1472
+    15, 15, 15, 15, 15, 15, 15, 15, // 1480
+    15, 15, 15, 15, 15, 15, 15, 15, // 1488
+    15, 15, 15, 15, 15, 15, 15, 15, // 1496
+    15, 15, 15, 15, 15, 15, 15, 15, // 1504
+    15, 15, 15, 15, 15, 15, 15, 15, // 1512
+    15, 15, 15, 15, 15, 15, 15, 15, // 1520
+    15, 15, 15, 15, 15, 15, 15, 15, // 1528
+    15, 15, 15, 15, 15, 15, 15, 15, // 1536
+    15, 15, 15, 15, 15, 15, 15, 15, // 1544
+    15, 15, 15, 15, 15, 15, 15, 15, // 1552
+    15, 15, 15, 15, 15, 15, 15, 15, // 1560
+    15, 15, 15, 15, 15, 15, 15, 15, // 1568
+    15, 15, 15, 15, 15, 15, 15, 15, // 1576
+    15, 15, 15, 15, 15, 15, 15, 15, // 1584
+    15, 15, 15, 15, 15, 15, 15, 15, // 1592
+    15, 15, 15, 15, 15, 15, 15, 15, // 1600
+    15, 15, 15, 15, 15, 15, 15, 15, // 1608
+    15, 15, 15, 15, 15, 15, 15, 15, // 1616
+    15, 15, 15, 15, 15, 15, 15, 15, // 1624
+    15, 15, 15, 15, 15, 15, 15, 15, // 1632
+    15, 15, 15, 15, 15, 15, 15, 15, // 1640
+    15, 15, 15, 15, 15, 15, 15, 15, // 1648
+    15, 30, 30, 30, 30, 30, 30, 30, // 1656
+    30, 30, 30, 30, 30, 30, 30, 30, // 1664
+    30, 30, 30, 30, 30, 30, 30, 30, // 1672
+    30, 30, 30, 30, 30, 30, 30, 30, // 1680
+    30, 30, 30, 30, 30, 30, 30, 30, // 1688
+    30, 30, 30, 30, 30, 30, 30, 30, // 1696
+    30, 30, 30, 30, 30, 30, 30, 30, // 1704
+    30, 30, 30, 30, 30, 30, 30, 30, // 1712
+    30, 30, 30, 30, 30, 30, 30, 30, // 1720
+    30, 30, 30, 30, 30, 30, 30, 30, // 1728
+    30, 30, 30, 30, 30, 30, 30, 30, // 1736
+    30, 30, 30, 30, 30, 30, 30, 30, // 1744
+    30, 30, 30, 30, 30, 30, 30, 30, // 1752
+    30, 30, 30, 30, 30, 30, 30, 30, // 1760
+    30, 30, 30, 30, 30, 30, 30, 30, // 1768
+    30, 30, 30, 30, 30, 30, 30, 30, // 1776
+    30, 30, 30, 30, 30, 30, 30, 30, // 1784
+    30, 30, 30, 30, 30, 30, 30, 30, // 1792
+    30, 30, 30, 30, 30, 30, 30, 30, // 1800
+    30, 30, 30, 30, 30, 30, 30, 30, // 1808
+    30, 30, 30, 30, 30, 30, 30, 30, // 1816
+    30, 30, 30, 30, 30, 30, 30, 30, // 1824
+    30, 30, 30, 30, 30, 30, 30, 30, // 1832
+    30, 30, 30, 30, 30, 30, 30, 30, // 1840
+    30, 30, 30, 30, 30, 30, 30, 30, // 1848
+    30, 30, 30, 30, 30, 30, 30, 30, // 1856
+    30, 30, 30, 30, 30, 30, 30, 30, // 1864
+    30, 30, 30, 30, 30, 30, 30, 30, // 1872
+    30, 30, 30, 30, 30, 30, 30, 30, // 1880
+    30, 30, 30, 30, 30, 30, 30, 30, // 1888
+    30, 30, 30, 30, 30, 30, 30, 30, // 1896
+    30, 30, 30, 30, 30, 30, 30, 30, // 1904
+    30, 30, 30, 30, 30, 30, 30, 30, // 1912
+    30, 30, 30, 30, 30, 30, 30, 30, // 1920
+    30, 30, 30, 30, 30, 30, 30, 30, // 1928
+    30, 30, 30, 30, 30, 30, 30, 30, // 1936
+    30, 30, 30, 30, 30, 30, 30, 30, // 1944
+    30, 30, 30, 30, 30, 30, 30, 30, // 1952
+    30, 30, 30, 30, 30, 30, 30, 30, // 1960
+    30, 30, 30, 30, 30, 30, 30, 30, // 1968
+    30, 30, 30, 30, 30, 30, 30, 30, // 1976
+    30, 30, 30, 30, 30, 30, 30, 30, // 1984
+    30, 30, 30, 30, 30, 30, 30, 30, // 1992
+    30, 30, 30, 30, 30, 30, 30, 30, // 2000
+    30, 30, 30, 30, 30, 30, 30, 30, // 2008
+    30, 30, 30, 30, 30, 30, 30, 30, // 2016
+    30, 30, 30, 30, 30, 30, 30, 30, // 2024
+    30, 30, 30, 30, 30, 30, 30, 30, // 2032
+    30, 30, 30, 30, 30, 30, 30, 30, // 2040
+    30, 30, 30, 30, 30, 30, 30, 30, // 2048
+    30, 30, 30, 30, 30, 30, 30, 30, // 2056
+    30, 30, 30, 30, 30, 30, 30, 30, // 2064
+    30, 30, 30, 30, 30, 30, 30, 30, // 2072
+    30, 30, 30, 30, 30, 30, 30, 30, // 2080
+    30, 30, 30, 30, 30, 30, 30, 30, // 2088
+    30, 30, 30, 30, 30, 30, 30, 30, // 2096
+    30, 30, 30, 30, 30, 30, 30, 30, // 2104
+    30, 30, 30, 30, 30, 30, 30, 30, // 2112
+    30, 30, 30, 30, 30, 30, 30, 30, // 2120
+    30, 30, 30, 30, 30, 30, 30, 30, // 2128
+    30, 30, 30, 30, 30, 30, 30, 30, // 2136
+    30, 30, 30, 30, 30, 30, 30, 30, // 2144
+    30, 30, 30, 30, 30, 30, 30, 30, // 2152
+    30, 30, 30, 30, 30, 30, 30, 30, // 2160
+    30, 30, 30, 30, 30, 30, 30, 30, // 2168
+    30, 30, 30, 30, 30, 30, 30, 30, // 2176
+    30, 30, 30, 30, 30, 30, 30, 30, // 2184
+    30, 30, 30, 30, 30, 30, 30, 30, // 2192
+    30, 30, 30, 30, 30, 30, 30, 30, // 2200
+    30, 30, 30, 30, 30, 30, 30, 30, // 2208
+    30, 30, 30, 30, 30, 30, 30, 30, // 2216
+    30, 30, 30, 30, 30, 30, 30, 30, // 2224
+    30, 30, 30, 30, 30, 30, 30, 30, // 2232
+    30, 30, 30, 30, 30, 30, 30, 30, // 2240
+    30, 30, 30, 30, 30, 30, 30, 30, // 2248
+    30, 30, 30, 30, 30, 30, 30, 30, // 2256
+    30, 30, 30, 30, 30, 30, 30, 30, // 2264
+    30, 30, 30, 30, 30, 30, 30, 30, // 2272
+    30, 30, 30, 30, 30, 30, 30, 30, // 2280
+    30, 30, 30, 30, 30, 30, 30, 30, // 2288
+    30, 30, 30, 30, 30, 30, 30, 30, // 2296
+    30, 30, 30, 30, 30, 30, 30, 30, // 2304
+    30, 30, 30, 30, 30, 30, 30, 30, // 2312
+    30, 30, 30, 30, 30, 30, 30, 30, // 2320
+    30, 30, 30, 30, 30, 30, 30, 30, // 2328
+    30, 30, 30, 30, 30, 30, 30, 30, // 2336
+    30, 30, 30, 30, 30, 30, 30, 30, // 2344
+    30, 30, 30, 30, 30, 30, 30, 30, // 2352
+    30, 30, 30, 30, 30, 30, 30, 30, // 2360
+    30, 30, 30, 30, 30, 30, 30, 30, // 2368
+    30, 30, 30, 30, 30, 30, 30, 30, // 2376
+    30, 30, 30, 30, 30, 30, 30, 30, // 2384
+    30, 30, 30, 30, 30, 30, 30, 30, // 2392
+    30                        //2400
+  };
+  
+    //
+    //   fill the pixels list with this data
+    //
+
+    for (UInt_t i=0; i<GetNumPixels(); i++)
+        (*this)[i].Set(xtemp[i], ytemp[i], dtemp[i]);
+}
+
+// --------------------------------------------------------------------------
+//
+//  This fills the next neighbor information from a table into the pixel
+//  objects.
+//
+void MGeomCamMagicHG::CreateNN()
+{
+  const Short_t nn[2401][6] = {       // Neighbours 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,  398,  468},
+    {  271,  272,  331,  333,  398,  399},
+    {  272,  273,  332,  334,  399,  400},
+    {  273,  274,  333,  335,  400,  401},
+    {  274,  275,  334,  336,  401,  402},
+    {  275,  276,  335,  337,  402,  403},
+    {  276,  277,  336,  338,  403,  404},
+    {  277,  278,  337,  339,  404,  405},
+    {  278,  279,  338,  340,  405,  406},
+    {  279,  280,  339,  341,  406,  407}, // 340
+    {  280,  281,  340,  342,  407,  408},
+    {  281,  341,  343,  408,  409,  410},
+    {  281,  282,  342,  344,  410,  411},
+    {  282,  283,  343,  345,  411,  412},
+    {  283,  284,  344,  346,  412,  413},
+    {  284,  285,  345,  347,  413,  414},
+    {  285,  286,  346,  348,  414,  415},
+    {  286,  287,  347,  349,  415,  416},
+    {  287,  288,  348,  350,  416,  417},
+    {  288,  289,  349,  351,  417,  418},
+    {  289,  290,  350,  352,  418,  419},
+    {  290,  291,  351,  353,  419,  420},
+    {  291,  352,  354,  420,  421,  422},
+    {  291,  292,  353,  355,  422,  423},
+    {  292,  293,  354,  356,  423,  424},
+    {  293,  294,  355,  357,  424,  425},
+    {  294,  295,  356,  358,  425,  426},
+    {  295,  296,  357,  359,  426,  427},
+    {  296,  297,  358,  360,  427,  428},
+    {  297,  298,  359,  361,  428,  429}, // 360
+    {  298,  299,  360,  362,  429,  430},
+    {  299,  300,  361,  363,  430,  431},
+    {  300,  301,  362,  364,  431,  432},
+    {  301,  363,  365,  432,  433,  434},
+    {  301,  302,  364,  366,  434,  435},
+    {  302,  303,  365,  367,  435,  436},
+    {  303,  304,  366,  368,  436,  437},
+    {  304,  305,  367,  369,  437,  438},
+    {  305,  306,  368,  370,  438,  439},
+    {  306,  307,  369,  371,  439,  440},
+    {  307,  308,  370,  372,  440,  441},
+    {  308,  309,  371,  373,  441,  442},
+    {  309,  310,  372,  374,  442,  443},
+    {  310,  311,  373,  375,  443,  444},
+    {  311,  374,  376,  444,  445,  446},
+    {  311,  312,  375,  377,  446,  447},
+    {  312,  313,  376,  378,  447,  448},
+    {  313,  314,  377,  379,  448,  449},
+    {  314,  315,  378,  380,  449,  450},
+    {  315,  316,  379,  381,  450,  451}, // 380
+    {  316,  317,  380,  382,  451,  452},
+    {  317,  318,  381,  383,  452,  453},
+    {  318,  319,  382,  384,  453,  454},
+    {  319,  320,  383,  385,  454,  455},
+    {  320,  321,  384,  386,  455,  456},
+    {  321,  385,  387,  456,  457,  458},
+    {  321,  322,  386,  388,  458,  459},
+    {  322,  323,  387,  389,  459,  460},
+    {  323,  324,  388,  390,  460,  461},
+    {  324,  325,  389,  391,  461,  462},
+    {  325,  326,  390,  392,  462,  463},
+    {  326,  327,  391,  393,  463,  464},
+    {  327,  328,  392,  394,  464,  465},
+    {  328,  329,  393,  395,  465,  466},
+    {  329,  330,  394,  396,  466,  467},
+    {  271,  330,  331,  395,  467,  468},
+    {  331,  398,  468,  469,  470,  546},
+    {  331,  332,  397,  399,  470,  471},
+    {  332,  333,  398,  400,  471,  472},
+    {  333,  334,  399,  401,  472,  473}, // 400
+    {  334,  335,  400,  402,  473,  474},
+    {  335,  336,  401,  403,  474,  475},
+    {  336,  337,  402,  404,  475,  476},
+    {  337,  338,  403,  405,  476,  477},
+    {  338,  339,  404,  406,  477,  478},
+    {  339,  340,  405,  407,  478,  479},
+    {  340,  341,  406,  408,  479,  480},
+    {  341,  342,  407,  409,  480,  481},
+    {  342,  408,  410,  481,  482,  483},
+    {  342,  343,  409,  411,  483,  484},
+    {  343,  344,  410,  412,  484,  485},
+    {  344,  345,  411,  413,  485,  486},
+    {  345,  346,  412,  414,  486,  487},
+    {  346,  347,  413,  415,  487,  488},
+    {  347,  348,  414,  416,  488,  489},
+    {  348,  349,  415,  417,  489,  490},
+    {  349,  350,  416,  418,  490,  491},
+    {  350,  351,  417,  419,  491,  492},
+    {  351,  352,  418,  420,  492,  493},
+    {  352,  353,  419,  421,  493,  494}, // 420
+    {  353,  420,  422,  494,  495,  496},
+    {  353,  354,  421,  423,  496,  497},
+    {  354,  355,  422,  424,  497,  498},
+    {  355,  356,  423,  425,  498,  499},
+    {  356,  357,  424,  426,  499,  500},
+    {  357,  358,  425,  427,  500,  501},
+    {  358,  359,  426,  428,  501,  502},
+    {  359,  360,  427,  429,  502,  503},
+    {  360,  361,  428,  430,  503,  504},
+    {  361,  362,  429,  431,  504,  505},
+    {  362,  363,  430,  432,  505,  506},
+    {  363,  364,  431,  433,  506,  507},
+    {  364,  432,  434,  507,  508,  509},
+    {  364,  365,  433,  435,  509,  510},
+    {  365,  366,  434,  436,  510,  511},
+    {  366,  367,  435,  437,  511,  512},
+    {  367,  368,  436,  438,  512,  513},
+    {  368,  369,  437,  439,  513,  514},
+    {  369,  370,  438,  440,  514,  515},
+    {  370,  371,  439,  441,  515,  516}, // 440
+    {  371,  372,  440,  442,  516,  517},
+    {  372,  373,  441,  443,  517,  518},
+    {  373,  374,  442,  444,  518,  519},
+    {  374,  375,  443,  445,  519,  520},
+    {  375,  444,  446,  520,  521,  522},
+    {  375,  376,  445,  447,  522,  523},
+    {  376,  377,  446,  448,  523,  524},
+    {  377,  378,  447,  449,  524,  525},
+    {  378,  379,  448,  450,  525,  526},
+    {  379,  380,  449,  451,  526,  527},
+    {  380,  381,  450,  452,  527,  528},
+    {  381,  382,  451,  453,  528,  529},
+    {  382,  383,  452,  454,  529,  530},
+    {  383,  384,  453,  455,  530,  531},
+    {  384,  385,  454,  456,  531,  532},
+    {  385,  386,  455,  457,  532,  533},
+    {  386,  456,  458,  533,  534,  535},
+    {  386,  387,  457,  459,  535,  536},
+    {  387,  388,  458,  460,  536,  537},
+    {  388,  389,  459,  461,  537,  538}, // 460
+    {  389,  390,  460,  462,  538,  539},
+    {  390,  391,  461,  463,  539,  540},
+    {  391,  392,  462,  464,  540,  541},
+    {  392,  393,  463,  465,  541,  542},
+    {  393,  394,  464,  466,  542,  543},
+    {  394,  395,  465,  467,  543,  544},
+    {  395,  396,  466,  468,  544,  545},
+    {  331,  396,  397,  467,  545,  546},
+    {  397,  470,  546,  547,  548,  630},
+    {  397,  398,  469,  471,  548,  549},
+    {  398,  399,  470,  472,  549,  550},
+    {  399,  400,  471,  473,  550,  551},
+    {  400,  401,  472,  474,  551,  552},
+    {  401,  402,  473,  475,  552,  553},
+    {  402,  403,  474,  476,  553,  554},
+    {  403,  404,  475,  477,  554,  555},
+    {  404,  405,  476,  478,  555,  556},
+    {  405,  406,  477,  479,  556,  557},
+    {  406,  407,  478,  480,  557,  558},
+    {  407,  408,  479,  481,  558,  559}, // 480
+    {  408,  409,  480,  482,  559,  560},
+    {  409,  481,  483,  560,  561,  562},
+    {  409,  410,  482,  484,  562,  563},
+    {  410,  411,  483,  485,  563,  564},
+    {  411,  412,  484,  486,  564,  565},
+    {  412,  413,  485,  487,  565,  566},
+    {  413,  414,  486,  488,  566,  567},
+    {  414,  415,  487,  489,  567,  568},
+    {  415,  416,  488,  490,  568,  569},
+    {  416,  417,  489,  491,  569,  570},
+    {  417,  418,  490,  492,  570,  571},
+    {  418,  419,  491,  493,  571,  572},
+    {  419,  420,  492,  494,  572,  573},
+    {  420,  421,  493,  495,  573,  574},
+    {  421,  494,  496,  574,  575,  576},
+    {  421,  422,  495,  497,  576,  577},
+    {  422,  423,  496,  498,  577,  578},
+    {  423,  424,  497,  499,  578,  579},
+    {  424,  425,  498,  500,  579,  580},
+    {  425,  426,  499,  501,  580,  581}, // 500
+    {  426,  427,  500,  502,  581,  582},
+    {  427,  428,  501,  503,  582,  583},
+    {  428,  429,  502,  504,  583,  584},
+    {  429,  430,  503,  505,  584,  585},
+    {  430,  431,  504,  506,  585,  586},
+    {  431,  432,  505,  507,  586,  587},
+    {  432,  433,  506,  508,  587,  588},
+    {  433,  507,  509,  588,  589,  590},
+    {  433,  434,  508,  510,  590,  591},
+    {  434,  435,  509,  511,  591,  592},
+    {  435,  436,  510,  512,  592,  593},
+    {  436,  437,  511,  513,  593,  594},
+    {  437,  438,  512,  514,  594,  595},
+    {  438,  439,  513,  515,  595,  596},
+    {  439,  440,  514,  516,  596,  597},
+    {  440,  441,  515,  517,  597,  598},
+    {  441,  442,  516,  518,  598,  599},
+    {  442,  443,  517,  519,  599,  600},
+    {  443,  444,  518,  520,  600,  601},
+    {  444,  445,  519,  521,  601,  602}, // 520
+    {  445,  520,  522,  602,  603,  604},
+    {  445,  446,  521,  523,  604,  605},
+    {  446,  447,  522,  524,  605,  606},
+    {  447,  448,  523,  525,  606,  607},
+    {  448,  449,  524,  526,  607,  608},
+    {  449,  450,  525,  527,  608,  609},
+    {  450,  451,  526,  528,  609,  610},
+    {  451,  452,  527,  529,  610,  611},
+    {  452,  453,  528,  530,  611,  612},
+    {  453,  454,  529,  531,  612,  613},
+    {  454,  455,  530,  532,  613,  614},
+    {  455,  456,  531,  533,  614,  615},
+    {  456,  457,  532,  534,  615,  616},
+    {  457,  533,  535,  616,  617,  618},
+    {  457,  458,  534,  536,  618,  619},
+    {  458,  459,  535,  537,  619,  620},
+    {  459,  460,  536,  538,  620,  621},
+    {  460,  461,  537,  539,  621,  622},
+    {  461,  462,  538,  540,  622,  623},
+    {  462,  463,  539,  541,  623,  624}, // 540
+    {  463,  464,  540,  542,  624,  625},
+    {  464,  465,  541,  543,  625,  626},
+    {  465,  466,  542,  544,  626,  627},
+    {  466,  467,  543,  545,  627,  628},
+    {  467,  468,  544,  546,  628,  629},
+    {  397,  468,  469,  545,  629,  630},
+    {  469,  548,  630,  631,  632,  720},
+    {  469,  470,  547,  549,  632,  633},
+    {  470,  471,  548,  550,  633,  634},
+    {  471,  472,  549,  551,  634,  635},
+    {  472,  473,  550,  552,  635,  636},
+    {  473,  474,  551,  553,  636,  637},
+    {  474,  475,  552,  554,  637,  638},
+    {  475,  476,  553,  555,  638,  639},
+    {  476,  477,  554,  556,  639,  640},
+    {  477,  478,  555,  557,  640,  641},
+    {  478,  479,  556,  558,  641,  642},
+    {  479,  480,  557,  559,  642,  643},
+    {  480,  481,  558,  560,  643,  644},
+    {  481,  482,  559,  561,  644,  645}, // 560
+    {  482,  560,  562,  645,  646,  647},
+    {  482,  483,  561,  563,  647,  648},
+    {  483,  484,  562,  564,  648,  649},
+    {  484,  485,  563,  565,  649,  650},
+    {  485,  486,  564,  566,  650,  651},
+    {  486,  487,  565,  567,  651,  652},
+    {  487,  488,  566,  568,  652,  653},
+    {  488,  489,  567,  569,  653,  654},
+    {  489,  490,  568,  570,  654,  655},
+    {  490,  491,  569,  571,  655,  656},
+    {  491,  492,  570,  572,  656,  657},
+    {  492,  493,  571,  573,  657,  658},
+    {  493,  494,  572,  574,  658,  659},
+    {  494,  495,  573,  575,  659,  660},
+    {  495,  574,  576,  660,  661,  662},
+    {  495,  496,  575,  577,  662,  663},
+    {  496,  497,  576,  578,  663,  664},
+    {  497,  498,  577,  579,  664,  665},
+    {  498,  499,  578,  580,  665,  666},
+    {  499,  500,  579,  581,  666,  667}, // 580
+    {  500,  501,  580,  582,  667,  668},
+    {  501,  502,  581,  583,  668,  669},
+    {  502,  503,  582,  584,  669,  670},
+    {  503,  504,  583,  585,  670,  671},
+    {  504,  505,  584,  586,  671,  672},
+    {  505,  506,  585,  587,  672,  673},
+    {  506,  507,  586,  588,  673,  674},
+    {  507,  508,  587,  589,  674,  675},
+    {  508,  588,  590,  675,  676,  677},
+    {  508,  509,  589,  591,  677,  678},
+    {  509,  510,  590,  592,  678,  679},
+    {  510,  511,  591,  593,  679,  680},
+    {  511,  512,  592,  594,  680,  681},
+    {  512,  513,  593,  595,  681,  682},
+    {  513,  514,  594,  596,  682,  683},
+    {  514,  515,  595,  597,  683,  684},
+    {  515,  516,  596,  598,  684,  685},
+    {  516,  517,  597,  599,  685,  686},
+    {  517,  518,  598,  600,  686,  687},
+    {  518,  519,  599,  601,  687,  688}, // 600
+    {  519,  520,  600,  602,  688,  689},
+    {  520,  521,  601,  603,  689,  690},
+    {  521,  602,  604,  690,  691,  692},
+    {  521,  522,  603,  605,  692,  693},
+    {  522,  523,  604,  606,  693,  694},
+    {  523,  524,  605,  607,  694,  695},
+    {  524,  525,  606,  608,  695,  696},
+    {  525,  526,  607,  609,  696,  697},
+    {  526,  527,  608,  610,  697,  698},
+    {  527,  528,  609,  611,  698,  699},
+    {  528,  529,  610,  612,  699,  700},
+    {  529,  530,  611,  613,  700,  701},
+    {  530,  531,  612,  614,  701,  702},
+    {  531,  532,  613,  615,  702,  703},
+    {  532,  533,  614,  616,  703,  704},
+    {  533,  534,  615,  617,  704,  705},
+    {  534,  616,  618,  705,  706,  707},
+    {  534,  535,  617,  619,  707,  708},
+    {  535,  536,  618,  620,  708,  709},
+    {  536,  537,  619,  621,  709,  710}, // 620
+    {  537,  538,  620,  622,  710,  711},
+    {  538,  539,  621,  623,  711,  712},
+    {  539,  540,  622,  624,  712,  713},
+    {  540,  541,  623,  625,  713,  714},
+    {  541,  542,  624,  626,  714,  715},
+    {  542,  543,  625,  627,  715,  716},
+    {  543,  544,  626,  628,  716,  717},
+    {  544,  545,  627,  629,  717,  718},
+    {  545,  546,  628,  630,  718,  719},
+    {  469,  546,  547,  629,  719,  720},
+    {  547,  632,  720,  721,  722,  816},
+    {  547,  548,  631,  633,  722,  723},
+    {  548,  549,  632,  634,  723,  724},
+    {  549,  550,  633,  635,  724,  725},
+    {  550,  551,  634,  636,  725,  726},
+    {  551,  552,  635,  637,  726,  727},
+    {  552,  553,  636,  638,  727,  728},
+    {  553,  554,  637,  639,  728,  729},
+    {  554,  555,  638,  640,  729,  730},
+    {  555,  556,  639,  641,  730,  731}, // 640
+    {  556,  557,  640,  642,  731,  732},
+    {  557,  558,  641,  643,  732,  733},
+    {  558,  559,  642,  644,  733,  734},
+    {  559,  560,  643,  645,  734,  735},
+    {  560,  561,  644,  646,  735,  736},
+    {  561,  645,  647,  736,  737,  738},
+    {  561,  562,  646,  648,  738,  739},
+    {  562,  563,  647,  649,  739,  740},
+    {  563,  564,  648,  650,  740,  741},
+    {  564,  565,  649,  651,  741,  742},
+    {  565,  566,  650,  652,  742,  743},
+    {  566,  567,  651,  653,  743,  744},
+    {  567,  568,  652,  654,  744,  745},
+    {  568,  569,  653,  655,  745,  746},
+    {  569,  570,  654,  656,  746,  747},
+    {  570,  571,  655,  657,  747,  748},
+    {  571,  572,  656,  658,  748,  749},
+    {  572,  573,  657,  659,  749,  750},
+    {  573,  574,  658,  660,  750,  751},
+    {  574,  575,  659,  661,  751,  752}, // 660
+    {  575,  660,  662,  752,  753,  754},
+    {  575,  576,  661,  663,  754,  755},
+    {  576,  577,  662,  664,  755,  756},
+    {  577,  578,  663,  665,  756,  757},
+    {  578,  579,  664,  666,  757,  758},
+    {  579,  580,  665,  667,  758,  759},
+    {  580,  581,  666,  668,  759,  760},
+    {  581,  582,  667,  669,  760,  761},
+    {  582,  583,  668,  670,  761,  762},
+    {  583,  584,  669,  671,  762,  763},
+    {  584,  585,  670,  672,  763,  764},
+    {  585,  586,  671,  673,  764,  765},
+    {  586,  587,  672,  674,  765,  766},
+    {  587,  588,  673,  675,  766,  767},
+    {  588,  589,  674,  676,  767,  768},
+    {  589,  675,  677,  768,  769,  770},
+    {  589,  590,  676,  678,  770,  771},
+    {  590,  591,  677,  679,  771,  772},
+    {  591,  592,  678,  680,  772,  773},
+    {  592,  593,  679,  681,  773,  774}, // 680
+    {  593,  594,  680,  682,  774,  775},
+    {  594,  595,  681,  683,  775,  776},
+    {  595,  596,  682,  684,  776,  777},
+    {  596,  597,  683,  685,  777,  778},
+    {  597,  598,  684,  686,  778,  779},
+    {  598,  599,  685,  687,  779,  780},
+    {  599,  600,  686,  688,  780,  781},
+    {  600,  601,  687,  689,  781,  782},
+    {  601,  602,  688,  690,  782,  783},
+    {  602,  603,  689,  691,  783,  784},
+    {  603,  690,  692,  784,  785,  786},
+    {  603,  604,  691,  693,  786,  787},
+    {  604,  605,  692,  694,  787,  788},
+    {  605,  606,  693,  695,  788,  789},
+    {  606,  607,  694,  696,  789,  790},
+    {  607,  608,  695,  697,  790,  791},
+    {  608,  609,  696,  698,  791,  792},
+    {  609,  610,  697,  699,  792,  793},
+    {  610,  611,  698,  700,  793,  794},
+    {  611,  612,  699,  701,  794,  795}, // 700
+    {  612,  613,  700,  702,  795,  796},
+    {  613,  614,  701,  703,  796,  797},
+    {  614,  615,  702,  704,  797,  798},
+    {  615,  616,  703,  705,  798,  799},
+    {  616,  617,  704,  706,  799,  800},
+    {  617,  705,  707,  800,  801,  802},
+    {  617,  618,  706,  708,  802,  803},
+    {  618,  619,  707,  709,  803,  804},
+    {  619,  620,  708,  710,  804,  805},
+    {  620,  621,  709,  711,  805,  806},
+    {  621,  622,  710,  712,  806,  807},
+    {  622,  623,  711,  713,  807,  808},
+    {  623,  624,  712,  714,  808,  809},
+    {  624,  625,  713,  715,  809,  810},
+    {  625,  626,  714,  716,  810,  811},
+    {  626,  627,  715,  717,  811,  812},
+    {  627,  628,  716,  718,  812,  813},
+    {  628,  629,  717,  719,  813,  814},
+    {  629,  630,  718,  720,  814,  815},
+    {  547,  630,  631,  719,  815,  816}, // 720
+    {  631,  722,  816,  817,  818,  918},
+    {  631,  632,  721,  723,  818,  819},
+    {  632,  633,  722,  724,  819,  820},
+    {  633,  634,  723,  725,  820,  821},
+    {  634,  635,  724,  726,  821,  822},
+    {  635,  636,  725,  727,  822,  823},
+    {  636,  637,  726,  728,  823,  824},
+    {  637,  638,  727,  729,  824,  825},
+    {  638,  639,  728,  730,  825,  826},
+    {  639,  640,  729,  731,  826,  827},
+    {  640,  641,  730,  732,  827,  828},
+    {  641,  642,  731,  733,  828,  829},
+    {  642,  643,  732,  734,  829,  830},
+    {  643,  644,  733,  735,  830,  831},
+    {  644,  645,  734,  736,  831,  832},
+    {  645,  646,  735,  737,  832,  833},
+    {  646,  736,  738,  833,  834,  835},
+    {  646,  647,  737,  739,  835,  836},
+    {  647,  648,  738,  740,  836,  837},
+    {  648,  649,  739,  741,  837,  838}, // 740
+    {  649,  650,  740,  742,  838,  839},
+    {  650,  651,  741,  743,  839,  840},
+    {  651,  652,  742,  744,  840,  841},
+    {  652,  653,  743,  745,  841,  842},
+    {  653,  654,  744,  746,  842,  843},
+    {  654,  655,  745,  747,  843,  844},
+    {  655,  656,  746,  748,  844,  845},
+    {  656,  657,  747,  749,  845,  846},
+    {  657,  658,  748,  750,  846,  847},
+    {  658,  659,  749,  751,  847,  848},
+    {  659,  660,  750,  752,  848,  849},
+    {  660,  661,  751,  753,  849,  850},
+    {  661,  752,  754,  850,  851,  852},
+    {  661,  662,  753,  755,  852,  853},
+    {  662,  663,  754,  756,  853,  854},
+    {  663,  664,  755,  757,  854,  855},
+    {  664,  665,  756,  758,  855,  856},
+    {  665,  666,  757,  759,  856,  857},
+    {  666,  667,  758,  760,  857,  858},
+    {  667,  668,  759,  761,  858,  859}, // 760
+    {  668,  669,  760,  762,  859,  860},
+    {  669,  670,  761,  763,  860,  861},
+    {  670,  671,  762,  764,  861,  862},
+    {  671,  672,  763,  765,  862,  863},
+    {  672,  673,  764,  766,  863,  864},
+    {  673,  674,  765,  767,  864,  865},
+    {  674,  675,  766,  768,  865,  866},
+    {  675,  676,  767,  769,  866,  867},
+    {  676,  768,  770,  867,  868,  869},
+    {  676,  677,  769,  771,  869,  870},
+    {  677,  678,  770,  772,  870,  871},
+    {  678,  679,  771,  773,  871,  872},
+    {  679,  680,  772,  774,  872,  873},
+    {  680,  681,  773,  775,  873,  874},
+    {  681,  682,  774,  776,  874,  875},
+    {  682,  683,  775,  777,  875,  876},
+    {  683,  684,  776,  778,  876,  877},
+    {  684,  685,  777,  779,  877,  878},
+    {  685,  686,  778,  780,  878,  879},
+    {  686,  687,  779,  781,  879,  880}, // 780
+    {  687,  688,  780,  782,  880,  881},
+    {  688,  689,  781,  783,  881,  882},
+    {  689,  690,  782,  784,  882,  883},
+    {  690,  691,  783,  785,  883,  884},
+    {  691,  784,  786,  884,  885,  886},
+    {  691,  692,  785,  787,  886,  887},
+    {  692,  693,  786,  788,  887,  888},
+    {  693,  694,  787,  789,  888,  889},
+    {  694,  695,  788,  790,  889,  890},
+    {  695,  696,  789,  791,  890,  891},
+    {  696,  697,  790,  792,  891,  892},
+    {  697,  698,  791,  793,  892,  893},
+    {  698,  699,  792,  794,  893,  894},
+    {  699,  700,  793,  795,  894,  895},
+    {  700,  701,  794,  796,  895,  896},
+    {  701,  702,  795,  797,  896,  897},
+    {  702,  703,  796,  798,  897,  898},
+    {  703,  704,  797,  799,  898,  899},
+    {  704,  705,  798,  800,  899,  900},
+    {  705,  706,  799,  801,  900,  901}, // 800
+    {  706,  800,  802,  901,  902,  903},
+    {  706,  707,  801,  803,  903,  904},
+    {  707,  708,  802,  804,  904,  905},
+    {  708,  709,  803,  805,  905,  906},
+    {  709,  710,  804,  806,  906,  907},
+    {  710,  711,  805,  807,  907,  908},
+    {  711,  712,  806,  808,  908,  909},
+    {  712,  713,  807,  809,  909,  910},
+    {  713,  714,  808,  810,  910,  911},
+    {  714,  715,  809,  811,  911,  912},
+    {  715,  716,  810,  812,  912,  913},
+    {  716,  717,  811,  813,  913,  914},
+    {  717,  718,  812,  814,  914,  915},
+    {  718,  719,  813,  815,  915,  916},
+    {  719,  720,  814,  816,  916,  917},
+    {  631,  720,  721,  815,  917,  918},
+    {  721,  818,  918,  919,  920,  1026},
+    {  721,  722,  817,  819,  920,  921},
+    {  722,  723,  818,  820,  921,  922},
+    {  723,  724,  819,  821,  922,  923}, // 820
+    {  724,  725,  820,  822,  923,  924},
+    {  725,  726,  821,  823,  924,  925},
+    {  726,  727,  822,  824,  925,  926},
+    {  727,  728,  823,  825,  926,  927},
+    {  728,  729,  824,  826,  927,  928},
+    {  729,  730,  825,  827,  928,  929},
+    {  730,  731,  826,  828,  929,  930},
+    {  731,  732,  827,  829,  930,  931},
+    {  732,  733,  828,  830,  931,  932},
+    {  733,  734,  829,  831,  932,  933},
+    {  734,  735,  830,  832,  933,  934},
+    {  735,  736,  831,  833,  934,  935},
+    {  736,  737,  832,  834,  935,  936},
+    {  737,  833,  835,  936,  937,  938},
+    {  737,  738,  834,  836,  938,  939},
+    {  738,  739,  835,  837,  939,  940},
+    {  739,  740,  836,  838,  940,  941},
+    {  740,  741,  837,  839,  941,  942},
+    {  741,  742,  838,  840,  942,  943},
+    {  742,  743,  839,  841,  943,  944}, // 840
+    {  743,  744,  840,  842,  944,  945},
+    {  744,  745,  841,  843,  945,  946},
+    {  745,  746,  842,  844,  946,  947},
+    {  746,  747,  843,  845,  947,  948},
+    {  747,  748,  844,  846,  948,  949},
+    {  748,  749,  845,  847,  949,  950},
+    {  749,  750,  846,  848,  950,  951},
+    {  750,  751,  847,  849,  951,  952},
+    {  751,  752,  848,  850,  952,  953},
+    {  752,  753,  849,  851,  953,  954},
+    {  753,  850,  852,  954,  955,  956},
+    {  753,  754,  851,  853,  956,  957},
+    {  754,  755,  852,  854,  957,  958},
+    {  755,  756,  853,  855,  958,  959},
+    {  756,  757,  854,  856,  959,  960},
+    {  757,  758,  855,  857,  960,  961},
+    {  758,  759,  856,  858,  961,  962},
+    {  759,  760,  857,  859,  962,  963},
+    {  760,  761,  858,  860,  963,  964},
+    {  761,  762,  859,  861,  964,  965}, // 860
+    {  762,  763,  860,  862,  965,  966},
+    {  763,  764,  861,  863,  966,  967},
+    {  764,  765,  862,  864,  967,  968},
+    {  765,  766,  863,  865,  968,  969},
+    {  766,  767,  864,  866,  969,  970},
+    {  767,  768,  865,  867,  970,  971},
+    {  768,  769,  866,  868,  971,  972},
+    {  769,  867,  869,  972,  973,  974},
+    {  769,  770,  868,  870,  974,  975},
+    {  770,  771,  869,  871,  975,  976},
+    {  771,  772,  870,  872,  976,  977},
+    {  772,  773,  871,  873,  977,  978},
+    {  773,  774,  872,  874,  978,  979},
+    {  774,  775,  873,  875,  979,  980},
+    {  775,  776,  874,  876,  980,  981},
+    {  776,  777,  875,  877,  981,  982},
+    {  777,  778,  876,  878,  982,  983},
+    {  778,  779,  877,  879,  983,  984},
+    {  779,  780,  878,  880,  984,  985},
+    {  780,  781,  879,  881,  985,  986}, // 880
+    {  781,  782,  880,  882,  986,  987},
+    {  782,  783,  881,  883,  987,  988},
+    {  783,  784,  882,  884,  988,  989},
+    {  784,  785,  883,  885,  989,  990},
+    {  785,  884,  886,  990,  991,  992},
+    {  785,  786,  885,  887,  992,  993},
+    {  786,  787,  886,  888,  993,  994},
+    {  787,  788,  887,  889,  994,  995},
+    {  788,  789,  888,  890,  995,  996},
+    {  789,  790,  889,  891,  996,  997},
+    {  790,  791,  890,  892,  997,  998},
+    {  791,  792,  891,  893,  998,  999},
+    {  792,  793,  892,  894,  999,  1000},
+    {  793,  794,  893,  895,  1000,  1001},
+    {  794,  795,  894,  896,  1001,  1002},
+    {  795,  796,  895,  897,  1002,  1003},
+    {  796,  797,  896,  898,  1003,  1004},
+    {  797,  798,  897,  899,  1004,  1005},
+    {  798,  799,  898,  900,  1005,  1006},
+    {  799,  800,  899,  901,  1006,  1007}, // 900
+    {  800,  801,  900,  902,  1007,  1008},
+    {  801,  901,  903,  1008,  1009,  1010},
+    {  801,  802,  902,  904,  1010,  1011},
+    {  802,  803,  903,  905,  1011,  1012},
+    {  803,  804,  904,  906,  1012,  1013},
+    {  804,  805,  905,  907,  1013,  1014},
+    {  805,  806,  906,  908,  1014,  1015},
+    {  806,  807,  907,  909,  1015,  1016},
+    {  807,  808,  908,  910,  1016,  1017},
+    {  808,  809,  909,  911,  1017,  1018},
+    {  809,  810,  910,  912,  1018,  1019},
+    {  810,  811,  911,  913,  1019,  1020},
+    {  811,  812,  912,  914,  1020,  1021},
+    {  812,  813,  913,  915,  1021,  1022},
+    {  813,  814,  914,  916,  1022,  1023},
+    {  814,  815,  915,  917,  1023,  1024},
+    {  815,  816,  916,  918,  1024,  1025},
+    {  721,  816,  817,  917,  1025,  1026},
+    {  817,  920,  1026,  1027,  1028,  1140},
+    {  817,  818,  919,  921,  1028,  1029}, // 920
+    {  818,  819,  920,  922,  1029,  1030},
+    {  819,  820,  921,  923,  1030,  1031},
+    {  820,  821,  922,  924,  1031,  1032},
+    {  821,  822,  923,  925,  1032,  1033},
+    {  822,  823,  924,  926,  1033,  1034},
+    {  823,  824,  925,  927,  1034,  1035},
+    {  824,  825,  926,  928,  1035,  1036},
+    {  825,  826,  927,  929,  1036,  1037},
+    {  826,  827,  928,  930,  1037,  1038},
+    {  827,  828,  929,  931,  1038,  1039},
+    {  828,  829,  930,  932,  1039,  1040},
+    {  829,  830,  931,  933,  1040,  1041},
+    {  830,  831,  932,  934,  1041,  1042},
+    {  831,  832,  933,  935,  1042,  1043},
+    {  832,  833,  934,  936,  1043,  1044},
+    {  833,  834,  935,  937,  1044,  1045},
+    {  834,  936,  938,  1045,  1046,  1047},
+    {  834,  835,  937,  939,  1047,  1048},
+    {  835,  836,  938,  940,  1048,  1049},
+    {  836,  837,  939,  941,  1049,  1050}, // 940
+    {  837,  838,  940,  942,  1050,  1051},
+    {  838,  839,  941,  943,  1051,  1052},
+    {  839,  840,  942,  944,  1052,  1053},
+    {  840,  841,  943,  945,  1053,  1054},
+    {  841,  842,  944,  946,  1054,  1055},
+    {  842,  843,  945,  947,  1055,  1056},
+    {  843,  844,  946,  948,  1056,  1057},
+    {  844,  845,  947,  949,  1057,  1058},
+    {  845,  846,  948,  950,  1058,  1059},
+    {  846,  847,  949,  951,  1059,  1060},
+    {  847,  848,  950,  952,  1060,  1061},
+    {  848,  849,  951,  953,  1061,  1062},
+    {  849,  850,  952,  954,  1062,  1063},
+    {  850,  851,  953,  955,  1063,  1064},
+    {  851,  954,  956,  1064,  1065,  1066},
+    {  851,  852,  955,  957,  1066,  1067},
+    {  852,  853,  956,  958,  1067,  1068},
+    {  853,  854,  957,  959,  1068,  1069},
+    {  854,  855,  958,  960,  1069,  1070},
+    {  855,  856,  959,  961,  1070,  1071}, // 960
+    {  856,  857,  960,  962,  1071,  1072},
+    {  857,  858,  961,  963,  1072,  1073},
+    {  858,  859,  962,  964,  1073,  1074},
+    {  859,  860,  963,  965,  1074,  1075},
+    {  860,  861,  964,  966,  1075,  1076},
+    {  861,  862,  965,  967,  1076,  1077},
+    {  862,  863,  966,  968,  1077,  1078},
+    {  863,  864,  967,  969,  1078,  1079},
+    {  864,  865,  968,  970,  1079,  1080},
+    {  865,  866,  969,  971,  1080,  1081},
+    {  866,  867,  970,  972,  1081,  1082},
+    {  867,  868,  971,  973,  1082,  1083},
+    {  868,  972,  974,  1083,  1084,  1085},
+    {  868,  869,  973,  975,  1085,  1086},
+    {  869,  870,  974,  976,  1086,  1087},
+    {  870,  871,  975,  977,  1087,  1088},
+    {  871,  872,  976,  978,  1088,  1089},
+    {  872,  873,  977,  979,  1089,  1090},
+    {  873,  874,  978,  980,  1090,  1091},
+    {  874,  875,  979,  981,  1091,  1092}, // 980
+    {  875,  876,  980,  982,  1092,  1093},
+    {  876,  877,  981,  983,  1093,  1094},
+    {  877,  878,  982,  984,  1094,  1095},
+    {  878,  879,  983,  985,  1095,  1096},
+    {  879,  880,  984,  986,  1096,  1097},
+    {  880,  881,  985,  987,  1097,  1098},
+    {  881,  882,  986,  988,  1098,  1099},
+    {  882,  883,  987,  989,  1099,  1100},
+    {  883,  884,  988,  990,  1100,  1101},
+    {  884,  885,  989,  991,  1101,  1102},
+    {  885,  990,  992,  1102,  1103,  1104},
+    {  885,  886,  991,  993,  1104,  1105},
+    {  886,  887,  992,  994,  1105,  1106},
+    {  887,  888,  993,  995,  1106,  1107},
+    {  888,  889,  994,  996,  1107,  1108},
+    {  889,  890,  995,  997,  1108,  1109},
+    {  890,  891,  996,  998,  1109,  1110},
+    {  891,  892,  997,  999,  1110,  1111},
+    {  892,  893,  998,  1000,  1111,  1112},
+    {  893,  894,  999,  1001,  1112,  1113}, // 1000
+    {  894,  895,  1000,  1002,  1113,  1114},
+    {  895,  896,  1001,  1003,  1114,  1115},
+    {  896,  897,  1002,  1004,  1115,  1116},
+    {  897,  898,  1003,  1005,  1116,  1117},
+    {  898,  899,  1004,  1006,  1117,  1118},
+    {  899,  900,  1005,  1007,  1118,  1119},
+    {  900,  901,  1006,  1008,  1119,  1120},
+    {  901,  902,  1007,  1009,  1120,  1121},
+    {  902,  1008,  1010,  1121,  1122,  1123},
+    {  902,  903,  1009,  1011,  1123,  1124},
+    {  903,  904,  1010,  1012,  1124,  1125},
+    {  904,  905,  1011,  1013,  1125,  1126},
+    {  905,  906,  1012,  1014,  1126,  1127},
+    {  906,  907,  1013,  1015,  1127,  1128},
+    {  907,  908,  1014,  1016,  1128,  1129},
+    {  908,  909,  1015,  1017,  1129,  1130},
+    {  909,  910,  1016,  1018,  1130,  1131},
+    {  910,  911,  1017,  1019,  1131,  1132},
+    {  911,  912,  1018,  1020,  1132,  1133},
+    {  912,  913,  1019,  1021,  1133,  1134}, // 1020
+    {  913,  914,  1020,  1022,  1134,  1135},
+    {  914,  915,  1021,  1023,  1135,  1136},
+    {  915,  916,  1022,  1024,  1136,  1137},
+    {  916,  917,  1023,  1025,  1137,  1138},
+    {  917,  918,  1024,  1026,  1138,  1139},
+    {  817,  918,  919,  1025,  1139,  1140},
+    {  919,  1028,  1140,  1141,  1142,  1260},
+    {  919,  920,  1027,  1029,  1142,  1143},
+    {  920,  921,  1028,  1030,  1143,  1144},
+    {  921,  922,  1029,  1031,  1144,  1145},
+    {  922,  923,  1030,  1032,  1145,  1146},
+    {  923,  924,  1031,  1033,  1146,  1147},
+    {  924,  925,  1032,  1034,  1147,  1148},
+    {  925,  926,  1033,  1035,  1148,  1149},
+    {  926,  927,  1034,  1036,  1149,  1150},
+    {  927,  928,  1035,  1037,  1150,  1151},
+    {  928,  929,  1036,  1038,  1151,  1152},
+    {  929,  930,  1037,  1039,  1152,  1153},
+    {  930,  931,  1038,  1040,  1153,  1154},
+    {  931,  932,  1039,  1041,  1154,  1155}, // 1040
+    {  932,  933,  1040,  1042,  1155,  1156},
+    {  933,  934,  1041,  1043,  1156,  1157},
+    {  934,  935,  1042,  1044,  1157,  1158},
+    {  935,  936,  1043,  1045,  1158,  1159},
+    {  936,  937,  1044,  1046,  1159,  1160},
+    {  937,  1045,  1047,  1160,  1161,  1162},
+    {  937,  938,  1046,  1048,  1162,  1163},
+    {  938,  939,  1047,  1049,  1163,  1164},
+    {  939,  940,  1048,  1050,  1164,  1165},
+    {  940,  941,  1049,  1051,  1165,  1166},
+    {  941,  942,  1050,  1052,  1166,  1167},
+    {  942,  943,  1051,  1053,  1167,  1168},
+    {  943,  944,  1052,  1054,  1168,  1169},
+    {  944,  945,  1053,  1055,  1169,  1170},
+    {  945,  946,  1054,  1056,  1170,  1171},
+    {  946,  947,  1055,  1057,  1171,  1172},
+    {  947,  948,  1056,  1058,  1172,  1173},
+    {  948,  949,  1057,  1059,  1173,  1174},
+    {  949,  950,  1058,  1060,  1174,  1175},
+    {  950,  951,  1059,  1061,  1175,  1176}, // 1060
+    {  951,  952,  1060,  1062,  1176,  1177},
+    {  952,  953,  1061,  1063,  1177,  1178},
+    {  953,  954,  1062,  1064,  1178,  1179},
+    {  954,  955,  1063,  1065,  1179,  1180},
+    {  955,  1064,  1066,  1180,  1181,  1182},
+    {  955,  956,  1065,  1067,  1182,  1183},
+    {  956,  957,  1066,  1068,  1183,  1184},
+    {  957,  958,  1067,  1069,  1184,  1185},
+    {  958,  959,  1068,  1070,  1185,  1186},
+    {  959,  960,  1069,  1071,  1186,  1187},
+    {  960,  961,  1070,  1072,  1187,  1188},
+    {  961,  962,  1071,  1073,  1188,  1189},
+    {  962,  963,  1072,  1074,  1189,  1190},
+    {  963,  964,  1073,  1075,  1190,  1191},
+    {  964,  965,  1074,  1076,  1191,  1192},
+    {  965,  966,  1075,  1077,  1192,  1193},
+    {  966,  967,  1076,  1078,  1193,  1194},
+    {  967,  968,  1077,  1079,  1194,  1195},
+    {  968,  969,  1078,  1080,  1195,  1196},
+    {  969,  970,  1079,  1081,  1196,  1197}, // 1080
+    {  970,  971,  1080,  1082,  1197,  1198},
+    {  971,  972,  1081,  1083,  1198,  1199},
+    {  972,  973,  1082,  1084,  1199,  1200},
+    {  973,  1083,  1085,  1200,  1201,  1202},
+    {  973,  974,  1084,  1086,  1202,  1203},
+    {  974,  975,  1085,  1087,  1203,  1204},
+    {  975,  976,  1086,  1088,  1204,  1205},
+    {  976,  977,  1087,  1089,  1205,  1206},
+    {  977,  978,  1088,  1090,  1206,  1207},
+    {  978,  979,  1089,  1091,  1207,  1208},
+    {  979,  980,  1090,  1092,  1208,  1209},
+    {  980,  981,  1091,  1093,  1209,  1210},
+    {  981,  982,  1092,  1094,  1210,  1211},
+    {  982,  983,  1093,  1095,  1211,  1212},
+    {  983,  984,  1094,  1096,  1212,  1213},
+    {  984,  985,  1095,  1097,  1213,  1214},
+    {  985,  986,  1096,  1098,  1214,  1215},
+    {  986,  987,  1097,  1099,  1215,  1216},
+    {  987,  988,  1098,  1100,  1216,  1217},
+    {  988,  989,  1099,  1101,  1217,  1218}, // 1100
+    {  989,  990,  1100,  1102,  1218,  1219},
+    {  990,  991,  1101,  1103,  1219,  1220},
+    {  991,  1102,  1104,  1220,  1221,  1222},
+    {  991,  992,  1103,  1105,  1222,  1223},
+    {  992,  993,  1104,  1106,  1223,  1224},
+    {  993,  994,  1105,  1107,  1224,  1225},
+    {  994,  995,  1106,  1108,  1225,  1226},
+    {  995,  996,  1107,  1109,  1226,  1227},
+    {  996,  997,  1108,  1110,  1227,  1228},
+    {  997,  998,  1109,  1111,  1228,  1229},
+    {  998,  999,  1110,  1112,  1229,  1230},
+    {  999,  1000,  1111,  1113,  1230,  1231},
+    {  1000,  1001,  1112,  1114,  1231,  1232},
+    {  1001,  1002,  1113,  1115,  1232,  1233},
+    {  1002,  1003,  1114,  1116,  1233,  1234},
+    {  1003,  1004,  1115,  1117,  1234,  1235},
+    {  1004,  1005,  1116,  1118,  1235,  1236},
+    {  1005,  1006,  1117,  1119,  1236,  1237},
+    {  1006,  1007,  1118,  1120,  1237,  1238},
+    {  1007,  1008,  1119,  1121,  1238,  1239}, // 1120
+    {  1008,  1009,  1120,  1122,  1239,  1240},
+    {  1009,  1121,  1123,  1240,  1241,  1242},
+    {  1009,  1010,  1122,  1124,  1242,  1243},
+    {  1010,  1011,  1123,  1125,  1243,  1244},
+    {  1011,  1012,  1124,  1126,  1244,  1245},
+    {  1012,  1013,  1125,  1127,  1245,  1246},
+    {  1013,  1014,  1126,  1128,  1246,  1247},
+    {  1014,  1015,  1127,  1129,  1247,  1248},
+    {  1015,  1016,  1128,  1130,  1248,  1249},
+    {  1016,  1017,  1129,  1131,  1249,  1250},
+    {  1017,  1018,  1130,  1132,  1250,  1251},
+    {  1018,  1019,  1131,  1133,  1251,  1252},
+    {  1019,  1020,  1132,  1134,  1252,  1253},
+    {  1020,  1021,  1133,  1135,  1253,  1254},
+    {  1021,  1022,  1134,  1136,  1254,  1255},
+    {  1022,  1023,  1135,  1137,  1255,  1256},
+    {  1023,  1024,  1136,  1138,  1256,  1257},
+    {  1024,  1025,  1137,  1139,  1257,  1258},
+    {  1025,  1026,  1138,  1140,  1258,  1259},
+    {  919,  1026,  1027,  1139,  1259,  1260}, // 1140
+    {  1027,  1142,  1260,  1261,  1262,  1386},
+    {  1027,  1028,  1141,  1143,  1262,  1263},
+    {  1028,  1029,  1142,  1144,  1263,  1264},
+    {  1029,  1030,  1143,  1145,  1264,  1265},
+    {  1030,  1031,  1144,  1146,  1265,  1266},
+    {  1031,  1032,  1145,  1147,  1266,  1267},
+    {  1032,  1033,  1146,  1148,  1267,  1268},
+    {  1033,  1034,  1147,  1149,  1268,  1269},
+    {  1034,  1035,  1148,  1150,  1269,  1270},
+    {  1035,  1036,  1149,  1151,  1270,  1271},
+    {  1036,  1037,  1150,  1152,  1271,  1272},
+    {  1037,  1038,  1151,  1153,  1272,  1273},
+    {  1038,  1039,  1152,  1154,  1273,  1274},
+    {  1039,  1040,  1153,  1155,  1274,  1275},
+    {  1040,  1041,  1154,  1156,  1275,  1276},
+    {  1041,  1042,  1155,  1157,  1276,  1277},
+    {  1042,  1043,  1156,  1158,  1277,  1278},
+    {  1043,  1044,  1157,  1159,  1278,  1279},
+    {  1044,  1045,  1158,  1160,  1279,  1280},
+    {  1045,  1046,  1159,  1161,  1280,  1281}, // 1160
+    {  1046,  1160,  1162,  1281,  1282,  1283},
+    {  1046,  1047,  1161,  1163,  1283,  1284},
+    {  1047,  1048,  1162,  1164,  1284,  1285},
+    {  1048,  1049,  1163,  1165,  1285,  1286},
+    {  1049,  1050,  1164,  1166,  1286,  1287},
+    {  1050,  1051,  1165,  1167,  1287,  1288},
+    {  1051,  1052,  1166,  1168,  1288,  1289},
+    {  1052,  1053,  1167,  1169,  1289,  1290},
+    {  1053,  1054,  1168,  1170,  1290,  1291},
+    {  1054,  1055,  1169,  1171,  1291,  1292},
+    {  1055,  1056,  1170,  1172,  1292,  1293},
+    {  1056,  1057,  1171,  1173,  1293,  1294},
+    {  1057,  1058,  1172,  1174,  1294,  1295},
+    {  1058,  1059,  1173,  1175,  1295,  1296},
+    {  1059,  1060,  1174,  1176,  1296,  1297},
+    {  1060,  1061,  1175,  1177,  1297,  1298},
+    {  1061,  1062,  1176,  1178,  1298,  1299},
+    {  1062,  1063,  1177,  1179,  1299,  1300},
+    {  1063,  1064,  1178,  1180,  1300,  1301},
+    {  1064,  1065,  1179,  1181,  1301,  1302}, // 1180
+    {  1065,  1180,  1182,  1302,  1303,  1304},
+    {  1065,  1066,  1181,  1183,  1304,  1305},
+    {  1066,  1067,  1182,  1184,  1305,  1306},
+    {  1067,  1068,  1183,  1185,  1306,  1307},
+    {  1068,  1069,  1184,  1186,  1307,  1308},
+    {  1069,  1070,  1185,  1187,  1308,  1309},
+    {  1070,  1071,  1186,  1188,  1309,  1310},
+    {  1071,  1072,  1187,  1189,  1310,  1311},
+    {  1072,  1073,  1188,  1190,  1311,  1312},
+    {  1073,  1074,  1189,  1191,  1312,  1313},
+    {  1074,  1075,  1190,  1192,  1313,  1314},
+    {  1075,  1076,  1191,  1193,  1314,  1315},
+    {  1076,  1077,  1192,  1194,  1315,  1316},
+    {  1077,  1078,  1193,  1195,  1316,  1317},
+    {  1078,  1079,  1194,  1196,  1317,  1318},
+    {  1079,  1080,  1195,  1197,  1318,  1319},
+    {  1080,  1081,  1196,  1198,  1319,  1320},
+    {  1081,  1082,  1197,  1199,  1320,  1321},
+    {  1082,  1083,  1198,  1200,  1321,  1322},
+    {  1083,  1084,  1199,  1201,  1322,  1323}, // 1200
+    {  1084,  1200,  1202,  1323,  1324,  1325},
+    {  1084,  1085,  1201,  1203,  1325,  1326},
+    {  1085,  1086,  1202,  1204,  1326,  1327},
+    {  1086,  1087,  1203,  1205,  1327,  1328},
+    {  1087,  1088,  1204,  1206,  1328,  1329},
+    {  1088,  1089,  1205,  1207,  1329,  1330},
+    {  1089,  1090,  1206,  1208,  1330,  1331},
+    {  1090,  1091,  1207,  1209,  1331,  1332},
+    {  1091,  1092,  1208,  1210,  1332,  1333},
+    {  1092,  1093,  1209,  1211,  1333,  1334},
+    {  1093,  1094,  1210,  1212,  1334,  1335},
+    {  1094,  1095,  1211,  1213,  1335,  1336},
+    {  1095,  1096,  1212,  1214,  1336,  1337},
+    {  1096,  1097,  1213,  1215,  1337,  1338},
+    {  1097,  1098,  1214,  1216,  1338,  1339},
+    {  1098,  1099,  1215,  1217,  1339,  1340},
+    {  1099,  1100,  1216,  1218,  1340,  1341},
+    {  1100,  1101,  1217,  1219,  1341,  1342},
+    {  1101,  1102,  1218,  1220,  1342,  1343},
+    {  1102,  1103,  1219,  1221,  1343,  1344}, // 1220
+    {  1103,  1220,  1222,  1344,  1345,  1346},
+    {  1103,  1104,  1221,  1223,  1346,  1347},
+    {  1104,  1105,  1222,  1224,  1347,  1348},
+    {  1105,  1106,  1223,  1225,  1348,  1349},
+    {  1106,  1107,  1224,  1226,  1349,  1350},
+    {  1107,  1108,  1225,  1227,  1350,  1351},
+    {  1108,  1109,  1226,  1228,  1351,  1352},
+    {  1109,  1110,  1227,  1229,  1352,  1353},
+    {  1110,  1111,  1228,  1230,  1353,  1354},
+    {  1111,  1112,  1229,  1231,  1354,  1355},
+    {  1112,  1113,  1230,  1232,  1355,  1356},
+    {  1113,  1114,  1231,  1233,  1356,  1357},
+    {  1114,  1115,  1232,  1234,  1357,  1358},
+    {  1115,  1116,  1233,  1235,  1358,  1359},
+    {  1116,  1117,  1234,  1236,  1359,  1360},
+    {  1117,  1118,  1235,  1237,  1360,  1361},
+    {  1118,  1119,  1236,  1238,  1361,  1362},
+    {  1119,  1120,  1237,  1239,  1362,  1363},
+    {  1120,  1121,  1238,  1240,  1363,  1364},
+    {  1121,  1122,  1239,  1241,  1364,  1365}, // 1240
+    {  1122,  1240,  1242,  1365,  1366,  1367},
+    {  1122,  1123,  1241,  1243,  1367,  1368},
+    {  1123,  1124,  1242,  1244,  1368,  1369},
+    {  1124,  1125,  1243,  1245,  1369,  1370},
+    {  1125,  1126,  1244,  1246,  1370,  1371},
+    {  1126,  1127,  1245,  1247,  1371,  1372},
+    {  1127,  1128,  1246,  1248,  1372,  1373},
+    {  1128,  1129,  1247,  1249,  1373,  1374},
+    {  1129,  1130,  1248,  1250,  1374,  1375},
+    {  1130,  1131,  1249,  1251,  1375,  1376},
+    {  1131,  1132,  1250,  1252,  1376,  1377},
+    {  1132,  1133,  1251,  1253,  1377,  1378},
+    {  1133,  1134,  1252,  1254,  1378,  1379},
+    {  1134,  1135,  1253,  1255,  1379,  1380},
+    {  1135,  1136,  1254,  1256,  1380,  1381},
+    {  1136,  1137,  1255,  1257,  1381,  1382},
+    {  1137,  1138,  1256,  1258,  1382,  1383},
+    {  1138,  1139,  1257,  1259,  1383,  1384},
+    {  1139,  1140,  1258,  1260,  1384,  1385},
+    {  1027,  1140,  1141,  1259,  1385,  1386}, // 1260
+    {  1141,  1262,  1386,  1387,  1388,  1518},
+    {  1141,  1142,  1261,  1263,  1388,  1389},
+    {  1142,  1143,  1262,  1264,  1389,  1390},
+    {  1143,  1144,  1263,  1265,  1390,  1391},
+    {  1144,  1145,  1264,  1266,  1391,  1392},
+    {  1145,  1146,  1265,  1267,  1392,  1393},
+    {  1146,  1147,  1266,  1268,  1393,  1394},
+    {  1147,  1148,  1267,  1269,  1394,  1395},
+    {  1148,  1149,  1268,  1270,  1395,  1396},
+    {  1149,  1150,  1269,  1271,  1396,  1397},
+    {  1150,  1151,  1270,  1272,  1397,  1398},
+    {  1151,  1152,  1271,  1273,  1398,  1399},
+    {  1152,  1153,  1272,  1274,  1399,  1400},
+    {  1153,  1154,  1273,  1275,  1400,  1401},
+    {  1154,  1155,  1274,  1276,  1401,  1402},
+    {  1155,  1156,  1275,  1277,  1402,  1403},
+    {  1156,  1157,  1276,  1278,  1403,  1404},
+    {  1157,  1158,  1277,  1279,  1404,  1405},
+    {  1158,  1159,  1278,  1280,  1405,  1406},
+    {  1159,  1160,  1279,  1281,  1406,  1407}, // 1280
+    {  1160,  1161,  1280,  1282,  1407,  1408},
+    {  1161,  1281,  1283,  1408,  1409,  1410},
+    {  1161,  1162,  1282,  1284,  1410,  1411},
+    {  1162,  1163,  1283,  1285,  1411,  1412},
+    {  1163,  1164,  1284,  1286,  1412,  1413},
+    {  1164,  1165,  1285,  1287,  1413,  1414},
+    {  1165,  1166,  1286,  1288,  1414,  1415},
+    {  1166,  1167,  1287,  1289,  1415,  1416},
+    {  1167,  1168,  1288,  1290,  1416,  1417},
+    {  1168,  1169,  1289,  1291,  1417,  1418},
+    {  1169,  1170,  1290,  1292,  1418,  1419},
+    {  1170,  1171,  1291,  1293,  1419,  1420},
+    {  1171,  1172,  1292,  1294,  1420,  1421},
+    {  1172,  1173,  1293,  1295,  1421,  1422},
+    {  1173,  1174,  1294,  1296,  1422,  1423},
+    {  1174,  1175,  1295,  1297,  1423,  1424},
+    {  1175,  1176,  1296,  1298,  1424,  1425},
+    {  1176,  1177,  1297,  1299,  1425,  1426},
+    {  1177,  1178,  1298,  1300,  1426,  1427},
+    {  1178,  1179,  1299,  1301,  1427,  1428}, // 1300
+    {  1179,  1180,  1300,  1302,  1428,  1429},
+    {  1180,  1181,  1301,  1303,  1429,  1430},
+    {  1181,  1302,  1304,  1430,  1431,  1432},
+    {  1181,  1182,  1303,  1305,  1432,  1433},
+    {  1182,  1183,  1304,  1306,  1433,  1434},
+    {  1183,  1184,  1305,  1307,  1434,  1435},
+    {  1184,  1185,  1306,  1308,  1435,  1436},
+    {  1185,  1186,  1307,  1309,  1436,  1437},
+    {  1186,  1187,  1308,  1310,  1437,  1438},
+    {  1187,  1188,  1309,  1311,  1438,  1439},
+    {  1188,  1189,  1310,  1312,  1439,  1440},
+    {  1189,  1190,  1311,  1313,  1440,  1441},
+    {  1190,  1191,  1312,  1314,  1441,  1442},
+    {  1191,  1192,  1313,  1315,  1442,  1443},
+    {  1192,  1193,  1314,  1316,  1443,  1444},
+    {  1193,  1194,  1315,  1317,  1444,  1445},
+    {  1194,  1195,  1316,  1318,  1445,  1446},
+    {  1195,  1196,  1317,  1319,  1446,  1447},
+    {  1196,  1197,  1318,  1320,  1447,  1448},
+    {  1197,  1198,  1319,  1321,  1448,  1449}, // 1320
+    {  1198,  1199,  1320,  1322,  1449,  1450},
+    {  1199,  1200,  1321,  1323,  1450,  1451},
+    {  1200,  1201,  1322,  1324,  1451,  1452},
+    {  1201,  1323,  1325,  1452,  1453,  1454},
+    {  1201,  1202,  1324,  1326,  1454,  1455},
+    {  1202,  1203,  1325,  1327,  1455,  1456},
+    {  1203,  1204,  1326,  1328,  1456,  1457},
+    {  1204,  1205,  1327,  1329,  1457,  1458},
+    {  1205,  1206,  1328,  1330,  1458,  1459},
+    {  1206,  1207,  1329,  1331,  1459,  1460},
+    {  1207,  1208,  1330,  1332,  1460,  1461},
+    {  1208,  1209,  1331,  1333,  1461,  1462},
+    {  1209,  1210,  1332,  1334,  1462,  1463},
+    {  1210,  1211,  1333,  1335,  1463,  1464},
+    {  1211,  1212,  1334,  1336,  1464,  1465},
+    {  1212,  1213,  1335,  1337,  1465,  1466},
+    {  1213,  1214,  1336,  1338,  1466,  1467},
+    {  1214,  1215,  1337,  1339,  1467,  1468},
+    {  1215,  1216,  1338,  1340,  1468,  1469},
+    {  1216,  1217,  1339,  1341,  1469,  1470}, // 1340
+    {  1217,  1218,  1340,  1342,  1470,  1471},
+    {  1218,  1219,  1341,  1343,  1471,  1472},
+    {  1219,  1220,  1342,  1344,  1472,  1473},
+    {  1220,  1221,  1343,  1345,  1473,  1474},
+    {  1221,  1344,  1346,  1474,  1475,  1476},
+    {  1221,  1222,  1345,  1347,  1476,  1477},
+    {  1222,  1223,  1346,  1348,  1477,  1478},
+    {  1223,  1224,  1347,  1349,  1478,  1479},
+    {  1224,  1225,  1348,  1350,  1479,  1480},
+    {  1225,  1226,  1349,  1351,  1480,  1481},
+    {  1226,  1227,  1350,  1352,  1481,  1482},
+    {  1227,  1228,  1351,  1353,  1482,  1483},
+    {  1228,  1229,  1352,  1354,  1483,  1484},
+    {  1229,  1230,  1353,  1355,  1484,  1485},
+    {  1230,  1231,  1354,  1356,  1485,  1486},
+    {  1231,  1232,  1355,  1357,  1486,  1487},
+    {  1232,  1233,  1356,  1358,  1487,  1488},
+    {  1233,  1234,  1357,  1359,  1488,  1489},
+    {  1234,  1235,  1358,  1360,  1489,  1490},
+    {  1235,  1236,  1359,  1361,  1490,  1491}, // 1360
+    {  1236,  1237,  1360,  1362,  1491,  1492},
+    {  1237,  1238,  1361,  1363,  1492,  1493},
+    {  1238,  1239,  1362,  1364,  1493,  1494},
+    {  1239,  1240,  1363,  1365,  1494,  1495},
+    {  1240,  1241,  1364,  1366,  1495,  1496},
+    {  1241,  1365,  1367,  1496,  1497,  1498},
+    {  1241,  1242,  1366,  1368,  1498,  1499},
+    {  1242,  1243,  1367,  1369,  1499,  1500},
+    {  1243,  1244,  1368,  1370,  1500,  1501},
+    {  1244,  1245,  1369,  1371,  1501,  1502},
+    {  1245,  1246,  1370,  1372,  1502,  1503},
+    {  1246,  1247,  1371,  1373,  1503,  1504},
+    {  1247,  1248,  1372,  1374,  1504,  1505},
+    {  1248,  1249,  1373,  1375,  1505,  1506},
+    {  1249,  1250,  1374,  1376,  1506,  1507},
+    {  1250,  1251,  1375,  1377,  1507,  1508},
+    {  1251,  1252,  1376,  1378,  1508,  1509},
+    {  1252,  1253,  1377,  1379,  1509,  1510},
+    {  1253,  1254,  1378,  1380,  1510,  1511},
+    {  1254,  1255,  1379,  1381,  1511,  1512}, // 1380
+    {  1255,  1256,  1380,  1382,  1512,  1513},
+    {  1256,  1257,  1381,  1383,  1513,  1514},
+    {  1257,  1258,  1382,  1384,  1514,  1515},
+    {  1258,  1259,  1383,  1385,  1515,  1516},
+    {  1259,  1260,  1384,  1386,  1516,  1517},
+    {  1141,  1260,  1261,  1385,  1517,  1518},
+    {  1261,  1388,  1518,  1519,  1520,  1656},
+    {  1261,  1262,  1387,  1389,  1520,  1521},
+    {  1262,  1263,  1388,  1390,  1521,  1522},
+    {  1263,  1264,  1389,  1391,  1522,  1523},
+    {  1264,  1265,  1390,  1392,  1523,  1524},
+    {  1265,  1266,  1391,  1393,  1524,  1525},
+    {  1266,  1267,  1392,  1394,  1525,  1526},
+    {  1267,  1268,  1393,  1395,  1526,  1527},
+    {  1268,  1269,  1394,  1396,  1527,  1528},
+    {  1269,  1270,  1395,  1397,  1528,  1529},
+    {  1270,  1271,  1396,  1398,  1529,  1530},
+    {  1271,  1272,  1397,  1399,  1530,  1531},
+    {  1272,  1273,  1398,  1400,  1531,  1532},
+    {  1273,  1274,  1399,  1401,  1532,  1533}, // 1400
+    {  1274,  1275,  1400,  1402,  1533,  1534},
+    {  1275,  1276,  1401,  1403,  1534,  1535},
+    {  1276,  1277,  1402,  1404,  1535,  1536},
+    {  1277,  1278,  1403,  1405,  1536,  1537},
+    {  1278,  1279,  1404,  1406,  1537,  1538},
+    {  1279,  1280,  1405,  1407,  1538,  1539},
+    {  1280,  1281,  1406,  1408,  1539,  1540},
+    {  1281,  1282,  1407,  1409,  1540,  1541},
+    {  1282,  1408,  1410,  1541,  1542,  1543},
+    {  1282,  1283,  1409,  1411,  1543,  1544},
+    {  1283,  1284,  1410,  1412,  1544,  1545},
+    {  1284,  1285,  1411,  1413,  1545,  1546},
+    {  1285,  1286,  1412,  1414,  1546,  1547},
+    {  1286,  1287,  1413,  1415,  1547,  1548},
+    {  1287,  1288,  1414,  1416,  1548,  1549},
+    {  1288,  1289,  1415,  1417,  1549,  1550},
+    {  1289,  1290,  1416,  1418,  1550,  1551},
+    {  1290,  1291,  1417,  1419,  1551,  1552},
+    {  1291,  1292,  1418,  1420,  1552,  1553},
+    {  1292,  1293,  1419,  1421,  1553,  1554}, // 1420
+    {  1293,  1294,  1420,  1422,  1554,  1555},
+    {  1294,  1295,  1421,  1423,  1555,  1556},
+    {  1295,  1296,  1422,  1424,  1556,  1557},
+    {  1296,  1297,  1423,  1425,  1557,  1558},
+    {  1297,  1298,  1424,  1426,  1558,  1559},
+    {  1298,  1299,  1425,  1427,  1559,  1560},
+    {  1299,  1300,  1426,  1428,  1560,  1561},
+    {  1300,  1301,  1427,  1429,  1561,  1562},
+    {  1301,  1302,  1428,  1430,  1562,  1563},
+    {  1302,  1303,  1429,  1431,  1563,  1564},
+    {  1303,  1430,  1432,  1564,  1565,  1566},
+    {  1303,  1304,  1431,  1433,  1566,  1567},
+    {  1304,  1305,  1432,  1434,  1567,  1568},
+    {  1305,  1306,  1433,  1435,  1568,  1569},
+    {  1306,  1307,  1434,  1436,  1569,  1570},
+    {  1307,  1308,  1435,  1437,  1570,  1571},
+    {  1308,  1309,  1436,  1438,  1571,  1572},
+    {  1309,  1310,  1437,  1439,  1572,  1573},
+    {  1310,  1311,  1438,  1440,  1573,  1574},
+    {  1311,  1312,  1439,  1441,  1574,  1575}, // 1440
+    {  1312,  1313,  1440,  1442,  1575,  1576},
+    {  1313,  1314,  1441,  1443,  1576,  1577},
+    {  1314,  1315,  1442,  1444,  1577,  1578},
+    {  1315,  1316,  1443,  1445,  1578,  1579},
+    {  1316,  1317,  1444,  1446,  1579,  1580},
+    {  1317,  1318,  1445,  1447,  1580,  1581},
+    {  1318,  1319,  1446,  1448,  1581,  1582},
+    {  1319,  1320,  1447,  1449,  1582,  1583},
+    {  1320,  1321,  1448,  1450,  1583,  1584},
+    {  1321,  1322,  1449,  1451,  1584,  1585},
+    {  1322,  1323,  1450,  1452,  1585,  1586},
+    {  1323,  1324,  1451,  1453,  1586,  1587},
+    {  1324,  1452,  1454,  1587,  1588,  1589},
+    {  1324,  1325,  1453,  1455,  1589,  1590},
+    {  1325,  1326,  1454,  1456,  1590,  1591},
+    {  1326,  1327,  1455,  1457,  1591,  1592},
+    {  1327,  1328,  1456,  1458,  1592,  1593},
+    {  1328,  1329,  1457,  1459,  1593,  1594},
+    {  1329,  1330,  1458,  1460,  1594,  1595},
+    {  1330,  1331,  1459,  1461,  1595,  1596}, // 1460
+    {  1331,  1332,  1460,  1462,  1596,  1597},
+    {  1332,  1333,  1461,  1463,  1597,  1598},
+    {  1333,  1334,  1462,  1464,  1598,  1599},
+    {  1334,  1335,  1463,  1465,  1599,  1600},
+    {  1335,  1336,  1464,  1466,  1600,  1601},
+    {  1336,  1337,  1465,  1467,  1601,  1602},
+    {  1337,  1338,  1466,  1468,  1602,  1603},
+    {  1338,  1339,  1467,  1469,  1603,  1604},
+    {  1339,  1340,  1468,  1470,  1604,  1605},
+    {  1340,  1341,  1469,  1471,  1605,  1606},
+    {  1341,  1342,  1470,  1472,  1606,  1607},
+    {  1342,  1343,  1471,  1473,  1607,  1608},
+    {  1343,  1344,  1472,  1474,  1608,  1609},
+    {  1344,  1345,  1473,  1475,  1609,  1610},
+    {  1345,  1474,  1476,  1610,  1611,  1612},
+    {  1345,  1346,  1475,  1477,  1612,  1613},
+    {  1346,  1347,  1476,  1478,  1613,  1614},
+    {  1347,  1348,  1477,  1479,  1614,  1615},
+    {  1348,  1349,  1478,  1480,  1615,  1616},
+    {  1349,  1350,  1479,  1481,  1616,  1617}, // 1480
+    {  1350,  1351,  1480,  1482,  1617,  1618},
+    {  1351,  1352,  1481,  1483,  1618,  1619},
+    {  1352,  1353,  1482,  1484,  1619,  1620},
+    {  1353,  1354,  1483,  1485,  1620,  1621},
+    {  1354,  1355,  1484,  1486,  1621,  1622},
+    {  1355,  1356,  1485,  1487,  1622,  1623},
+    {  1356,  1357,  1486,  1488,  1623,  1624},
+    {  1357,  1358,  1487,  1489,  1624,  1625},
+    {  1358,  1359,  1488,  1490,  1625,  1626},
+    {  1359,  1360,  1489,  1491,  1626,  1627},
+    {  1360,  1361,  1490,  1492,  1627,  1628},
+    {  1361,  1362,  1491,  1493,  1628,  1629},
+    {  1362,  1363,  1492,  1494,  1629,  1630},
+    {  1363,  1364,  1493,  1495,  1630,  1631},
+    {  1364,  1365,  1494,  1496,  1631,  1632},
+    {  1365,  1366,  1495,  1497,  1632,  1633},
+    {  1366,  1496,  1498,  1633,  1634,  1635},
+    {  1366,  1367,  1497,  1499,  1635,  1636},
+    {  1367,  1368,  1498,  1500,  1636,  1637},
+    {  1368,  1369,  1499,  1501,  1637,  1638}, // 1500
+    {  1369,  1370,  1500,  1502,  1638,  1639},
+    {  1370,  1371,  1501,  1503,  1639,  1640},
+    {  1371,  1372,  1502,  1504,  1640,  1641},
+    {  1372,  1373,  1503,  1505,  1641,  1642},
+    {  1373,  1374,  1504,  1506,  1642,  1643},
+    {  1374,  1375,  1505,  1507,  1643,  1644},
+    {  1375,  1376,  1506,  1508,  1644,  1645},
+    {  1376,  1377,  1507,  1509,  1645,  1646},
+    {  1377,  1378,  1508,  1510,  1646,  1647},
+    {  1378,  1379,  1509,  1511,  1647,  1648},
+    {  1379,  1380,  1510,  1512,  1648,  1649},
+    {  1380,  1381,  1511,  1513,  1649,  1650},
+    {  1381,  1382,  1512,  1514,  1650,  1651},
+    {  1382,  1383,  1513,  1515,  1651,  1652},
+    {  1383,  1384,  1514,  1516,  1652,  1653},
+    {  1384,  1385,  1515,  1517,  1653,  1654},
+    {  1385,  1386,  1516,  1518,  1654,  1655},
+    {  1261,  1386,  1387,  1517,  1655,  1656},
+    {  1387,  1520,  1656,  -1,  -1,  -1},
+    {  1387,  1388,  1519,  1521,  1657,  -1}, // 1520
+    {  1388,  1389,  1520,  1522,  -1,  -1},
+    {  1389,  1390,  1521,  1523,  1658,  -1},
+    {  1390,  1391,  1522,  1524,  -1,  -1},
+    {  1391,  1392,  1523,  1525,  1659,  -1},
+    {  1392,  1393,  1524,  1526,  -1,  -1},
+    {  1393,  1394,  1525,  1527,  1660,  -1},
+    {  1394,  1395,  1526,  1528,  -1,  -1},
+    {  1395,  1396,  1527,  1529,  1661,  -1},
+    {  1396,  1397,  1528,  1530,  -1,  -1},
+    {  1397,  1398,  1529,  1531,  1662,  -1},
+    {  1398,  1399,  1530,  1532,  -1,  -1},
+    {  1399,  1400,  1531,  1533,  1663,  -1},
+    {  1400,  1401,  1532,  1534,  -1,  -1},
+    {  1401,  1402,  1533,  1535,  1664,  -1},
+    {  1402,  1403,  1534,  1536,  -1,  -1},
+    {  1403,  1404,  1535,  1537,  1665,  -1},
+    {  1404,  1405,  1536,  1538,  -1,  -1},
+    {  1405,  1406,  1537,  1539,  1666,  -1},
+    {  1406,  1407,  1538,  1540,  -1,  -1},
+    {  1407,  1408,  1539,  1541,  1667,  -1}, // 1540
+    {  1408,  1409,  1540,  1542,  -1,  -1},
+    {  1409,  1541,  1543,  1668,  -1,  -1},
+    {  1409,  1410,  1542,  1544,  -1,  -1},
+    {  1410,  1411,  1543,  1545,  -1,  -1},
+    {  1411,  1412,  1544,  1546,  -1,  -1},
+    {  1412,  1413,  1545,  1547,  -1,  -1},
+    {  1413,  1414,  1546,  1548,  -1,  -1},
+    {  1414,  1415,  1547,  1549,  -1,  -1},
+    {  1415,  1416,  1548,  1550,  -1,  -1},
+    {  1416,  1417,  1549,  1551,  -1,  -1},
+    {  1417,  1418,  1550,  1552,  -1,  -1},
+    {  1418,  1419,  1551,  1553,  -1,  -1},
+    {  1419,  1420,  1552,  1554,  -1,  -1},
+    {  1420,  1421,  1553,  1555,  -1,  -1},
+    {  1421,  1422,  1554,  1556,  -1,  -1},
+    {  1422,  1423,  1555,  1557,  -1,  -1},
+    {  1423,  1424,  1556,  1558,  -1,  -1},
+    {  1424,  1425,  1557,  1559,  -1,  -1},
+    {  1425,  1426,  1558,  1560,  -1,  -1},
+    {  1426,  1427,  1559,  1561,  -1,  -1}, // 1560
+    {  1427,  1428,  1560,  1562,  -1,  -1},
+    {  1428,  1429,  1561,  1563,  -1,  -1},
+    {  1429,  1430,  1562,  1564,  -1,  -1},
+    {  1430,  1431,  1563,  1565,  -1,  -1},
+    {  1431,  1564,  1566,  -1,  -1,  -1},
+    {  1431,  1432,  1565,  1567,  -1,  -1},
+    {  1432,  1433,  1566,  1568,  -1,  -1},
+    {  1433,  1434,  1567,  1569,  -1,  -1},
+    {  1434,  1435,  1568,  1570,  -1,  -1},
+    {  1435,  1436,  1569,  1571,  -1,  -1},
+    {  1436,  1437,  1570,  1572,  -1,  -1},
+    {  1437,  1438,  1571,  1573,  -1,  -1},
+    {  1438,  1439,  1572,  1574,  -1,  -1},
+    {  1439,  1440,  1573,  1575,  -1,  -1},
+    {  1440,  1441,  1574,  1576,  -1,  -1},
+    {  1441,  1442,  1575,  1577,  -1,  -1},
+    {  1442,  1443,  1576,  1578,  -1,  -1},
+    {  1443,  1444,  1577,  1579,  -1,  -1},
+    {  1444,  1445,  1578,  1580,  -1,  -1},
+    {  1445,  1446,  1579,  1581,  -1,  -1}, // 1580
+    {  1446,  1447,  1580,  1582,  -1,  -1},
+    {  1447,  1448,  1581,  1583,  -1,  -1},
+    {  1448,  1449,  1582,  1584,  -1,  -1},
+    {  1449,  1450,  1583,  1585,  -1,  -1},
+    {  1450,  1451,  1584,  1586,  -1,  -1},
+    {  1451,  1452,  1585,  1587,  -1,  -1},
+    {  1452,  1453,  1586,  1588,  -1,  -1},
+    {  1453,  1587,  1589,  -1,  -1,  -1},
+    {  1453,  1454,  1588,  1590,  -1,  -1},
+    {  1454,  1455,  1589,  1591,  -1,  -1},
+    {  1455,  1456,  1590,  1592,  -1,  -1},
+    {  1456,  1457,  1591,  1593,  -1,  -1},
+    {  1457,  1458,  1592,  1594,  -1,  -1},
+    {  1458,  1459,  1593,  1595,  -1,  -1},
+    {  1459,  1460,  1594,  1596,  -1,  -1},
+    {  1460,  1461,  1595,  1597,  -1,  -1},
+    {  1461,  1462,  1596,  1598,  -1,  -1},
+    {  1462,  1463,  1597,  1599,  -1,  -1},
+    {  1463,  1464,  1598,  1600,  -1,  -1},
+    {  1464,  1465,  1599,  1601,  -1,  -1}, // 1600
+    {  1465,  1466,  1600,  1602,  -1,  -1},
+    {  1466,  1467,  1601,  1603,  -1,  -1},
+    {  1467,  1468,  1602,  1604,  -1,  -1},
+    {  1468,  1469,  1603,  1605,  -1,  -1},
+    {  1469,  1470,  1604,  1606,  -1,  -1},
+    {  1470,  1471,  1605,  1607,  -1,  -1},
+    {  1471,  1472,  1606,  1608,  -1,  -1},
+    {  1472,  1473,  1607,  1609,  -1,  -1},
+    {  1473,  1474,  1608,  1610,  -1,  -1},
+    {  1474,  1475,  1609,  1611,  -1,  -1},
+    {  1475,  1610,  1612,  -1,  -1,  -1},
+    {  1475,  1476,  1611,  1613,  -1,  -1},
+    {  1476,  1477,  1612,  1614,  -1,  -1},
+    {  1477,  1478,  1613,  1615,  -1,  -1},
+    {  1478,  1479,  1614,  1616,  -1,  -1},
+    {  1479,  1480,  1615,  1617,  -1,  -1},
+    {  1480,  1481,  1616,  1618,  -1,  -1},
+    {  1481,  1482,  1617,  1619,  -1,  -1},
+    {  1482,  1483,  1618,  1620,  -1,  -1},
+    {  1483,  1484,  1619,  1621,  -1,  -1}, // 1620
+    {  1484,  1485,  1620,  1622,  -1,  -1},
+    {  1485,  1486,  1621,  1623,  -1,  -1},
+    {  1486,  1487,  1622,  1624,  -1,  -1},
+    {  1487,  1488,  1623,  1625,  -1,  -1},
+    {  1488,  1489,  1624,  1626,  -1,  -1},
+    {  1489,  1490,  1625,  1627,  -1,  -1},
+    {  1490,  1491,  1626,  1628,  -1,  -1},
+    {  1491,  1492,  1627,  1629,  -1,  -1},
+    {  1492,  1493,  1628,  1630,  -1,  -1},
+    {  1493,  1494,  1629,  1631,  -1,  -1},
+    {  1494,  1495,  1630,  1632,  -1,  -1},
+    {  1495,  1496,  1631,  1633,  -1,  -1},
+    {  1496,  1497,  1632,  1634,  -1,  -1},
+    {  1497,  1633,  1635,  1717,  -1,  -1},
+    {  1497,  1498,  1634,  1636,  -1,  -1},
+    {  1498,  1499,  1635,  1637,  1718,  -1},
+    {  1499,  1500,  1636,  1638,  -1,  -1},
+    {  1500,  1501,  1637,  1639,  1719,  -1},
+    {  1501,  1502,  1638,  1640,  -1,  -1},
+    {  1502,  1503,  1639,  1641,  1720,  -1}, // 1640
+    {  1503,  1504,  1640,  1642,  -1,  -1},
+    {  1504,  1505,  1641,  1643,  1721,  -1},
+    {  1505,  1506,  1642,  1644,  -1,  -1},
+    {  1506,  1507,  1643,  1645,  1722,  -1},
+    {  1507,  1508,  1644,  1646,  -1,  -1},
+    {  1508,  1509,  1645,  1647,  1723,  -1},
+    {  1509,  1510,  1646,  1648,  -1,  -1},
+    {  1510,  1511,  1647,  1649,  1724,  -1},
+    {  1511,  1512,  1648,  1650,  -1,  -1},
+    {  1512,  1513,  1649,  1651,  1725,  -1},
+    {  1513,  1514,  1650,  1652,  -1,  -1},
+    {  1514,  1515,  1651,  1653,  1726,  -1},
+    {  1515,  1516,  1652,  1654,  -1,  -1},
+    {  1516,  1517,  1653,  1655,  1727,  -1},
+    {  1517,  1518,  1654,  1656,  -1,  -1},
+    {  1387,  1518,  1519,  1655,  1728,  -1},
+    {  1658,  1729,  1730,  -1,  -1,  -1},
+    {  1657,  1659,  1730,  1731,  -1,  -1},
+    {  1658,  1660,  1731,  1732,  -1,  -1},
+    {  1659,  1661,  1732,  1733,  -1,  -1}, // 1660
+    {  1660,  1662,  1733,  1734,  -1,  -1},
+    {  1661,  1663,  1734,  1735,  -1,  -1},
+    {  1662,  1664,  1735,  1736,  -1,  -1},
+    {  1663,  1665,  1736,  1737,  -1,  -1},
+    {  1664,  1666,  1737,  1738,  -1,  -1},
+    {  1665,  1667,  1738,  1739,  -1,  -1},
+    {  1666,  1668,  1739,  1740,  -1,  -1},
+    {  1667,  1740,  1741,  -1,  -1,  -1},
+    {  1670,  1742,  1743,  -1,  -1,  -1},
+    {  1669,  1671,  1743,  1744,  -1,  -1},
+    {  1670,  1672,  1744,  1745,  -1,  -1},
+    {  1671,  1673,  1745,  1746,  -1,  -1},
+    {  1672,  1674,  1746,  1747,  -1,  -1},
+    {  1673,  1675,  1747,  1748,  -1,  -1},
+    {  1674,  1676,  1748,  1749,  -1,  -1},
+    {  1675,  1677,  1749,  1750,  -1,  -1},
+    {  1676,  1678,  1750,  1751,  -1,  -1},
+    {  1677,  1679,  1751,  1752,  -1,  -1},
+    {  1678,  1680,  1752,  1753,  -1,  -1},
+    {  1679,  1753,  1754,  -1,  -1,  -1}, // 1680
+    {  1682,  1755,  1756,  -1,  -1,  -1},
+    {  1681,  1683,  1756,  1757,  -1,  -1},
+    {  1682,  1684,  1757,  1758,  -1,  -1},
+    {  1683,  1685,  1758,  1759,  -1,  -1},
+    {  1684,  1686,  1759,  1760,  -1,  -1},
+    {  1685,  1687,  1760,  1761,  -1,  -1},
+    {  1686,  1688,  1761,  1762,  -1,  -1},
+    {  1687,  1689,  1762,  1763,  -1,  -1},
+    {  1688,  1690,  1763,  1764,  -1,  -1},
+    {  1689,  1691,  1764,  1765,  -1,  -1},
+    {  1690,  1692,  1765,  1766,  -1,  -1},
+    {  1691,  1766,  1767,  -1,  -1,  -1},
+    {  1694,  1768,  1769,  -1,  -1,  -1},
+    {  1693,  1695,  1769,  1770,  -1,  -1},
+    {  1694,  1696,  1770,  1771,  -1,  -1},
+    {  1695,  1697,  1771,  1772,  -1,  -1},
+    {  1696,  1698,  1772,  1773,  -1,  -1},
+    {  1697,  1699,  1773,  1774,  -1,  -1},
+    {  1698,  1700,  1774,  1775,  -1,  -1},
+    {  1699,  1701,  1775,  1776,  -1,  -1}, // 1700
+    {  1700,  1702,  1776,  1777,  -1,  -1},
+    {  1701,  1703,  1777,  1778,  -1,  -1},
+    {  1702,  1704,  1778,  1779,  -1,  -1},
+    {  1703,  1779,  1780,  -1,  -1,  -1},
+    {  1706,  1781,  1782,  -1,  -1,  -1},
+    {  1705,  1707,  1782,  1783,  -1,  -1},
+    {  1706,  1708,  1783,  1784,  -1,  -1},
+    {  1707,  1709,  1784,  1785,  -1,  -1},
+    {  1708,  1710,  1785,  1786,  -1,  -1},
+    {  1709,  1711,  1786,  1787,  -1,  -1},
+    {  1710,  1712,  1787,  1788,  -1,  -1},
+    {  1711,  1713,  1788,  1789,  -1,  -1},
+    {  1712,  1714,  1789,  1790,  -1,  -1},
+    {  1713,  1715,  1790,  1791,  -1,  -1},
+    {  1714,  1716,  1791,  1792,  -1,  -1},
+    {  1715,  1792,  1793,  -1,  -1,  -1},
+    {  1718,  1794,  1795,  -1,  -1,  -1},
+    {  1717,  1719,  1795,  1796,  -1,  -1},
+    {  1718,  1720,  1796,  1797,  -1,  -1},
+    {  1719,  1721,  1797,  1798,  -1,  -1}, // 1720
+    {  1720,  1722,  1798,  1799,  -1,  -1},
+    {  1721,  1723,  1799,  1800,  -1,  -1},
+    {  1722,  1724,  1800,  1801,  -1,  -1},
+    {  1723,  1725,  1801,  1802,  -1,  -1},
+    {  1724,  1726,  1802,  1803,  -1,  -1},
+    {  1725,  1727,  1803,  1804,  -1,  -1},
+    {  1726,  1728,  1804,  1805,  -1,  -1},
+    {  1727,  1805,  1806,  -1,  -1,  -1},
+    {  1657,  1730,  1807,  1808,  -1,  -1},
+    {  1657,  1658,  1729,  1731,  1808,  1809},
+    {  1658,  1659,  1730,  1732,  1809,  1810},
+    {  1659,  1660,  1731,  1733,  1810,  1811},
+    {  1660,  1661,  1732,  1734,  1811,  1812},
+    {  1661,  1662,  1733,  1735,  1812,  1813},
+    {  1662,  1663,  1734,  1736,  1813,  1814},
+    {  1663,  1664,  1735,  1737,  1814,  1815},
+    {  1664,  1665,  1736,  1738,  1815,  1816},
+    {  1665,  1666,  1737,  1739,  1816,  1817},
+    {  1666,  1667,  1738,  1740,  1817,  1818},
+    {  1667,  1668,  1739,  1741,  1818,  1819}, // 1740
+    {  1668,  1740,  1819,  1820,  -1,  -1},
+    {  1669,  1743,  1821,  1822,  -1,  -1},
+    {  1669,  1670,  1742,  1744,  1822,  1823},
+    {  1670,  1671,  1743,  1745,  1823,  1824},
+    {  1671,  1672,  1744,  1746,  1824,  1825},
+    {  1672,  1673,  1745,  1747,  1825,  1826},
+    {  1673,  1674,  1746,  1748,  1826,  1827},
+    {  1674,  1675,  1747,  1749,  1827,  1828},
+    {  1675,  1676,  1748,  1750,  1828,  1829},
+    {  1676,  1677,  1749,  1751,  1829,  1830},
+    {  1677,  1678,  1750,  1752,  1830,  1831},
+    {  1678,  1679,  1751,  1753,  1831,  1832},
+    {  1679,  1680,  1752,  1754,  1832,  1833},
+    {  1680,  1753,  1833,  1834,  -1,  -1},
+    {  1681,  1756,  1835,  1836,  -1,  -1},
+    {  1681,  1682,  1755,  1757,  1836,  1837},
+    {  1682,  1683,  1756,  1758,  1837,  1838},
+    {  1683,  1684,  1757,  1759,  1838,  1839},
+    {  1684,  1685,  1758,  1760,  1839,  1840},
+    {  1685,  1686,  1759,  1761,  1840,  1841}, // 1760
+    {  1686,  1687,  1760,  1762,  1841,  1842},
+    {  1687,  1688,  1761,  1763,  1842,  1843},
+    {  1688,  1689,  1762,  1764,  1843,  1844},
+    {  1689,  1690,  1763,  1765,  1844,  1845},
+    {  1690,  1691,  1764,  1766,  1845,  1846},
+    {  1691,  1692,  1765,  1767,  1846,  1847},
+    {  1692,  1766,  1847,  1848,  -1,  -1},
+    {  1693,  1769,  1849,  1850,  -1,  -1},
+    {  1693,  1694,  1768,  1770,  1850,  1851},
+    {  1694,  1695,  1769,  1771,  1851,  1852},
+    {  1695,  1696,  1770,  1772,  1852,  1853},
+    {  1696,  1697,  1771,  1773,  1853,  1854},
+    {  1697,  1698,  1772,  1774,  1854,  1855},
+    {  1698,  1699,  1773,  1775,  1855,  1856},
+    {  1699,  1700,  1774,  1776,  1856,  1857},
+    {  1700,  1701,  1775,  1777,  1857,  1858},
+    {  1701,  1702,  1776,  1778,  1858,  1859},
+    {  1702,  1703,  1777,  1779,  1859,  1860},
+    {  1703,  1704,  1778,  1780,  1860,  1861},
+    {  1704,  1779,  1861,  1862,  -1,  -1}, // 1780
+    {  1705,  1782,  1863,  1864,  -1,  -1},
+    {  1705,  1706,  1781,  1783,  1864,  1865},
+    {  1706,  1707,  1782,  1784,  1865,  1866},
+    {  1707,  1708,  1783,  1785,  1866,  1867},
+    {  1708,  1709,  1784,  1786,  1867,  1868},
+    {  1709,  1710,  1785,  1787,  1868,  1869},
+    {  1710,  1711,  1786,  1788,  1869,  1870},
+    {  1711,  1712,  1787,  1789,  1870,  1871},
+    {  1712,  1713,  1788,  1790,  1871,  1872},
+    {  1713,  1714,  1789,  1791,  1872,  1873},
+    {  1714,  1715,  1790,  1792,  1873,  1874},
+    {  1715,  1716,  1791,  1793,  1874,  1875},
+    {  1716,  1792,  1875,  1876,  -1,  -1},
+    {  1717,  1795,  1877,  1878,  -1,  -1},
+    {  1717,  1718,  1794,  1796,  1878,  1879},
+    {  1718,  1719,  1795,  1797,  1879,  1880},
+    {  1719,  1720,  1796,  1798,  1880,  1881},
+    {  1720,  1721,  1797,  1799,  1881,  1882},
+    {  1721,  1722,  1798,  1800,  1882,  1883},
+    {  1722,  1723,  1799,  1801,  1883,  1884}, // 1800
+    {  1723,  1724,  1800,  1802,  1884,  1885},
+    {  1724,  1725,  1801,  1803,  1885,  1886},
+    {  1725,  1726,  1802,  1804,  1886,  1887},
+    {  1726,  1727,  1803,  1805,  1887,  1888},
+    {  1727,  1728,  1804,  1806,  1888,  1889},
+    {  1728,  1805,  1889,  1890,  -1,  -1},
+    {  1729,  1808,  1891,  1892,  -1,  -1},
+    {  1729,  1730,  1807,  1809,  1892,  1893},
+    {  1730,  1731,  1808,  1810,  1893,  1894},
+    {  1731,  1732,  1809,  1811,  1894,  1895},
+    {  1732,  1733,  1810,  1812,  1895,  1896},
+    {  1733,  1734,  1811,  1813,  1896,  1897},
+    {  1734,  1735,  1812,  1814,  1897,  1898},
+    {  1735,  1736,  1813,  1815,  1898,  1899},
+    {  1736,  1737,  1814,  1816,  1899,  1900},
+    {  1737,  1738,  1815,  1817,  1900,  1901},
+    {  1738,  1739,  1816,  1818,  1901,  1902},
+    {  1739,  1740,  1817,  1819,  1902,  1903},
+    {  1740,  1741,  1818,  1820,  1903,  1904},
+    {  1741,  1819,  1904,  1905,  -1,  -1}, // 1820
+    {  1742,  1822,  1906,  1907,  -1,  -1},
+    {  1742,  1743,  1821,  1823,  1907,  1908},
+    {  1743,  1744,  1822,  1824,  1908,  1909},
+    {  1744,  1745,  1823,  1825,  1909,  1910},
+    {  1745,  1746,  1824,  1826,  1910,  1911},
+    {  1746,  1747,  1825,  1827,  1911,  1912},
+    {  1747,  1748,  1826,  1828,  1912,  1913},
+    {  1748,  1749,  1827,  1829,  1913,  1914},
+    {  1749,  1750,  1828,  1830,  1914,  1915},
+    {  1750,  1751,  1829,  1831,  1915,  1916},
+    {  1751,  1752,  1830,  1832,  1916,  1917},
+    {  1752,  1753,  1831,  1833,  1917,  1918},
+    {  1753,  1754,  1832,  1834,  1918,  1919},
+    {  1754,  1833,  1919,  1920,  -1,  -1},
+    {  1755,  1836,  1921,  1922,  -1,  -1},
+    {  1755,  1756,  1835,  1837,  1922,  1923},
+    {  1756,  1757,  1836,  1838,  1923,  1924},
+    {  1757,  1758,  1837,  1839,  1924,  1925},
+    {  1758,  1759,  1838,  1840,  1925,  1926},
+    {  1759,  1760,  1839,  1841,  1926,  1927}, // 1840
+    {  1760,  1761,  1840,  1842,  1927,  1928},
+    {  1761,  1762,  1841,  1843,  1928,  1929},
+    {  1762,  1763,  1842,  1844,  1929,  1930},
+    {  1763,  1764,  1843,  1845,  1930,  1931},
+    {  1764,  1765,  1844,  1846,  1931,  1932},
+    {  1765,  1766,  1845,  1847,  1932,  1933},
+    {  1766,  1767,  1846,  1848,  1933,  1934},
+    {  1767,  1847,  1934,  1935,  -1,  -1},
+    {  1768,  1850,  1936,  1937,  -1,  -1},
+    {  1768,  1769,  1849,  1851,  1937,  1938},
+    {  1769,  1770,  1850,  1852,  1938,  1939},
+    {  1770,  1771,  1851,  1853,  1939,  1940},
+    {  1771,  1772,  1852,  1854,  1940,  1941},
+    {  1772,  1773,  1853,  1855,  1941,  1942},
+    {  1773,  1774,  1854,  1856,  1942,  1943},
+    {  1774,  1775,  1855,  1857,  1943,  1944},
+    {  1775,  1776,  1856,  1858,  1944,  1945},
+    {  1776,  1777,  1857,  1859,  1945,  1946},
+    {  1777,  1778,  1858,  1860,  1946,  1947},
+    {  1778,  1779,  1859,  1861,  1947,  1948}, // 1860
+    {  1779,  1780,  1860,  1862,  1948,  1949},
+    {  1780,  1861,  1949,  1950,  -1,  -1},
+    {  1781,  1864,  1951,  1952,  -1,  -1},
+    {  1781,  1782,  1863,  1865,  1952,  1953},
+    {  1782,  1783,  1864,  1866,  1953,  1954},
+    {  1783,  1784,  1865,  1867,  1954,  1955},
+    {  1784,  1785,  1866,  1868,  1955,  1956},
+    {  1785,  1786,  1867,  1869,  1956,  1957},
+    {  1786,  1787,  1868,  1870,  1957,  1958},
+    {  1787,  1788,  1869,  1871,  1958,  1959},
+    {  1788,  1789,  1870,  1872,  1959,  1960},
+    {  1789,  1790,  1871,  1873,  1960,  1961},
+    {  1790,  1791,  1872,  1874,  1961,  1962},
+    {  1791,  1792,  1873,  1875,  1962,  1963},
+    {  1792,  1793,  1874,  1876,  1963,  1964},
+    {  1793,  1875,  1964,  1965,  -1,  -1},
+    {  1794,  1878,  1966,  1967,  -1,  -1},
+    {  1794,  1795,  1877,  1879,  1967,  1968},
+    {  1795,  1796,  1878,  1880,  1968,  1969},
+    {  1796,  1797,  1879,  1881,  1969,  1970}, // 1880
+    {  1797,  1798,  1880,  1882,  1970,  1971},
+    {  1798,  1799,  1881,  1883,  1971,  1972},
+    {  1799,  1800,  1882,  1884,  1972,  1973},
+    {  1800,  1801,  1883,  1885,  1973,  1974},
+    {  1801,  1802,  1884,  1886,  1974,  1975},
+    {  1802,  1803,  1885,  1887,  1975,  1976},
+    {  1803,  1804,  1886,  1888,  1976,  1977},
+    {  1804,  1805,  1887,  1889,  1977,  1978},
+    {  1805,  1806,  1888,  1890,  1978,  1979},
+    {  1806,  1889,  1979,  1980,  -1,  -1},
+    {  1807,  1892,  1981,  1982,  -1,  -1},
+    {  1807,  1808,  1891,  1893,  1982,  1983},
+    {  1808,  1809,  1892,  1894,  1983,  1984},
+    {  1809,  1810,  1893,  1895,  1984,  1985},
+    {  1810,  1811,  1894,  1896,  1985,  1986},
+    {  1811,  1812,  1895,  1897,  1986,  1987},
+    {  1812,  1813,  1896,  1898,  1987,  1988},
+    {  1813,  1814,  1897,  1899,  1988,  1989},
+    {  1814,  1815,  1898,  1900,  1989,  1990},
+    {  1815,  1816,  1899,  1901,  1990,  1991}, // 1900
+    {  1816,  1817,  1900,  1902,  1991,  1992},
+    {  1817,  1818,  1901,  1903,  1992,  1993},
+    {  1818,  1819,  1902,  1904,  1993,  1994},
+    {  1819,  1820,  1903,  1905,  1994,  1995},
+    {  1820,  1904,  1995,  1996,  -1,  -1},
+    {  1821,  1907,  1997,  1998,  -1,  -1},
+    {  1821,  1822,  1906,  1908,  1998,  1999},
+    {  1822,  1823,  1907,  1909,  1999,  2000},
+    {  1823,  1824,  1908,  1910,  2000,  2001},
+    {  1824,  1825,  1909,  1911,  2001,  2002},
+    {  1825,  1826,  1910,  1912,  2002,  2003},
+    {  1826,  1827,  1911,  1913,  2003,  2004},
+    {  1827,  1828,  1912,  1914,  2004,  2005},
+    {  1828,  1829,  1913,  1915,  2005,  2006},
+    {  1829,  1830,  1914,  1916,  2006,  2007},
+    {  1830,  1831,  1915,  1917,  2007,  2008},
+    {  1831,  1832,  1916,  1918,  2008,  2009},
+    {  1832,  1833,  1917,  1919,  2009,  2010},
+    {  1833,  1834,  1918,  1920,  2010,  2011},
+    {  1834,  1919,  2011,  2012,  -1,  -1}, // 1920
+    {  1835,  1922,  2013,  2014,  -1,  -1},
+    {  1835,  1836,  1921,  1923,  2014,  2015},
+    {  1836,  1837,  1922,  1924,  2015,  2016},
+    {  1837,  1838,  1923,  1925,  2016,  2017},
+    {  1838,  1839,  1924,  1926,  2017,  2018},
+    {  1839,  1840,  1925,  1927,  2018,  2019},
+    {  1840,  1841,  1926,  1928,  2019,  2020},
+    {  1841,  1842,  1927,  1929,  2020,  2021},
+    {  1842,  1843,  1928,  1930,  2021,  2022},
+    {  1843,  1844,  1929,  1931,  2022,  2023},
+    {  1844,  1845,  1930,  1932,  2023,  2024},
+    {  1845,  1846,  1931,  1933,  2024,  2025},
+    {  1846,  1847,  1932,  1934,  2025,  2026},
+    {  1847,  1848,  1933,  1935,  2026,  2027},
+    {  1848,  1934,  2027,  2028,  -1,  -1},
+    {  1849,  1937,  2029,  2030,  -1,  -1},
+    {  1849,  1850,  1936,  1938,  2030,  2031},
+    {  1850,  1851,  1937,  1939,  2031,  2032},
+    {  1851,  1852,  1938,  1940,  2032,  2033},
+    {  1852,  1853,  1939,  1941,  2033,  2034}, // 1940
+    {  1853,  1854,  1940,  1942,  2034,  2035},
+    {  1854,  1855,  1941,  1943,  2035,  2036},
+    {  1855,  1856,  1942,  1944,  2036,  2037},
+    {  1856,  1857,  1943,  1945,  2037,  2038},
+    {  1857,  1858,  1944,  1946,  2038,  2039},
+    {  1858,  1859,  1945,  1947,  2039,  2040},
+    {  1859,  1860,  1946,  1948,  2040,  2041},
+    {  1860,  1861,  1947,  1949,  2041,  2042},
+    {  1861,  1862,  1948,  1950,  2042,  2043},
+    {  1862,  1949,  2043,  2044,  -1,  -1},
+    {  1863,  1952,  2045,  2046,  -1,  -1},
+    {  1863,  1864,  1951,  1953,  2046,  2047},
+    {  1864,  1865,  1952,  1954,  2047,  2048},
+    {  1865,  1866,  1953,  1955,  2048,  2049},
+    {  1866,  1867,  1954,  1956,  2049,  2050},
+    {  1867,  1868,  1955,  1957,  2050,  2051},
+    {  1868,  1869,  1956,  1958,  2051,  2052},
+    {  1869,  1870,  1957,  1959,  2052,  2053},
+    {  1870,  1871,  1958,  1960,  2053,  2054},
+    {  1871,  1872,  1959,  1961,  2054,  2055}, // 1960
+    {  1872,  1873,  1960,  1962,  2055,  2056},
+    {  1873,  1874,  1961,  1963,  2056,  2057},
+    {  1874,  1875,  1962,  1964,  2057,  2058},
+    {  1875,  1876,  1963,  1965,  2058,  2059},
+    {  1876,  1964,  2059,  2060,  -1,  -1},
+    {  1877,  1967,  2061,  2062,  -1,  -1},
+    {  1877,  1878,  1966,  1968,  2062,  2063},
+    {  1878,  1879,  1967,  1969,  2063,  2064},
+    {  1879,  1880,  1968,  1970,  2064,  2065},
+    {  1880,  1881,  1969,  1971,  2065,  2066},
+    {  1881,  1882,  1970,  1972,  2066,  2067},
+    {  1882,  1883,  1971,  1973,  2067,  2068},
+    {  1883,  1884,  1972,  1974,  2068,  2069},
+    {  1884,  1885,  1973,  1975,  2069,  2070},
+    {  1885,  1886,  1974,  1976,  2070,  2071},
+    {  1886,  1887,  1975,  1977,  2071,  2072},
+    {  1887,  1888,  1976,  1978,  2072,  2073},
+    {  1888,  1889,  1977,  1979,  2073,  2074},
+    {  1889,  1890,  1978,  1980,  2074,  2075},
+    {  1890,  1979,  2075,  2076,  -1,  -1}, // 1980
+    {  1891,  1982,  2077,  2078,  -1,  -1},
+    {  1891,  1892,  1981,  1983,  2078,  2079},
+    {  1892,  1893,  1982,  1984,  2079,  2080},
+    {  1893,  1894,  1983,  1985,  2080,  2081},
+    {  1894,  1895,  1984,  1986,  2081,  2082},
+    {  1895,  1896,  1985,  1987,  2082,  2083},
+    {  1896,  1897,  1986,  1988,  2083,  2084},
+    {  1897,  1898,  1987,  1989,  2084,  2085},
+    {  1898,  1899,  1988,  1990,  2085,  2086},
+    {  1899,  1900,  1989,  1991,  2086,  2087},
+    {  1900,  1901,  1990,  1992,  2087,  2088},
+    {  1901,  1902,  1991,  1993,  2088,  2089},
+    {  1902,  1903,  1992,  1994,  2089,  2090},
+    {  1903,  1904,  1993,  1995,  2090,  2091},
+    {  1904,  1905,  1994,  1996,  2091,  2092},
+    {  1905,  1995,  2092,  2093,  -1,  -1},
+    {  1906,  1998,  2094,  2095,  -1,  -1},
+    {  1906,  1907,  1997,  1999,  2095,  2096},
+    {  1907,  1908,  1998,  2000,  2096,  2097},
+    {  1908,  1909,  1999,  2001,  2097,  2098}, // 2000
+    {  1909,  1910,  2000,  2002,  2098,  2099},
+    {  1910,  1911,  2001,  2003,  2099,  2100},
+    {  1911,  1912,  2002,  2004,  2100,  2101},
+    {  1912,  1913,  2003,  2005,  2101,  2102},
+    {  1913,  1914,  2004,  2006,  2102,  2103},
+    {  1914,  1915,  2005,  2007,  2103,  2104},
+    {  1915,  1916,  2006,  2008,  2104,  2105},
+    {  1916,  1917,  2007,  2009,  2105,  2106},
+    {  1917,  1918,  2008,  2010,  2106,  2107},
+    {  1918,  1919,  2009,  2011,  2107,  2108},
+    {  1919,  1920,  2010,  2012,  2108,  2109},
+    {  1920,  2011,  2109,  2110,  -1,  -1},
+    {  1921,  2014,  2111,  2112,  -1,  -1},
+    {  1921,  1922,  2013,  2015,  2112,  2113},
+    {  1922,  1923,  2014,  2016,  2113,  2114},
+    {  1923,  1924,  2015,  2017,  2114,  2115},
+    {  1924,  1925,  2016,  2018,  2115,  2116},
+    {  1925,  1926,  2017,  2019,  2116,  2117},
+    {  1926,  1927,  2018,  2020,  2117,  2118},
+    {  1927,  1928,  2019,  2021,  2118,  2119}, // 2020
+    {  1928,  1929,  2020,  2022,  2119,  2120},
+    {  1929,  1930,  2021,  2023,  2120,  2121},
+    {  1930,  1931,  2022,  2024,  2121,  2122},
+    {  1931,  1932,  2023,  2025,  2122,  2123},
+    {  1932,  1933,  2024,  2026,  2123,  2124},
+    {  1933,  1934,  2025,  2027,  2124,  2125},
+    {  1934,  1935,  2026,  2028,  2125,  2126},
+    {  1935,  2027,  2126,  2127,  -1,  -1},
+    {  1936,  2030,  2128,  2129,  -1,  -1},
+    {  1936,  1937,  2029,  2031,  2129,  2130},
+    {  1937,  1938,  2030,  2032,  2130,  2131},
+    {  1938,  1939,  2031,  2033,  2131,  2132},
+    {  1939,  1940,  2032,  2034,  2132,  2133},
+    {  1940,  1941,  2033,  2035,  2133,  2134},
+    {  1941,  1942,  2034,  2036,  2134,  2135},
+    {  1942,  1943,  2035,  2037,  2135,  2136},
+    {  1943,  1944,  2036,  2038,  2136,  2137},
+    {  1944,  1945,  2037,  2039,  2137,  2138},
+    {  1945,  1946,  2038,  2040,  2138,  2139},
+    {  1946,  1947,  2039,  2041,  2139,  2140}, // 2040
+    {  1947,  1948,  2040,  2042,  2140,  2141},
+    {  1948,  1949,  2041,  2043,  2141,  2142},
+    {  1949,  1950,  2042,  2044,  2142,  2143},
+    {  1950,  2043,  2143,  2144,  -1,  -1},
+    {  1951,  2046,  2145,  2146,  -1,  -1},
+    {  1951,  1952,  2045,  2047,  2146,  2147},
+    {  1952,  1953,  2046,  2048,  2147,  2148},
+    {  1953,  1954,  2047,  2049,  2148,  2149},
+    {  1954,  1955,  2048,  2050,  2149,  2150},
+    {  1955,  1956,  2049,  2051,  2150,  2151},
+    {  1956,  1957,  2050,  2052,  2151,  2152},
+    {  1957,  1958,  2051,  2053,  2152,  2153},
+    {  1958,  1959,  2052,  2054,  2153,  2154},
+    {  1959,  1960,  2053,  2055,  2154,  2155},
+    {  1960,  1961,  2054,  2056,  2155,  2156},
+    {  1961,  1962,  2055,  2057,  2156,  2157},
+    {  1962,  1963,  2056,  2058,  2157,  2158},
+    {  1963,  1964,  2057,  2059,  2158,  2159},
+    {  1964,  1965,  2058,  2060,  2159,  2160},
+    {  1965,  2059,  2160,  2161,  -1,  -1}, // 2060
+    {  1966,  2062,  2162,  2163,  -1,  -1},
+    {  1966,  1967,  2061,  2063,  2163,  2164},
+    {  1967,  1968,  2062,  2064,  2164,  2165},
+    {  1968,  1969,  2063,  2065,  2165,  2166},
+    {  1969,  1970,  2064,  2066,  2166,  2167},
+    {  1970,  1971,  2065,  2067,  2167,  2168},
+    {  1971,  1972,  2066,  2068,  2168,  2169},
+    {  1972,  1973,  2067,  2069,  2169,  2170},
+    {  1973,  1974,  2068,  2070,  2170,  2171},
+    {  1974,  1975,  2069,  2071,  2171,  2172},
+    {  1975,  1976,  2070,  2072,  2172,  2173},
+    {  1976,  1977,  2071,  2073,  2173,  2174},
+    {  1977,  1978,  2072,  2074,  2174,  2175},
+    {  1978,  1979,  2073,  2075,  2175,  2176},
+    {  1979,  1980,  2074,  2076,  2176,  2177},
+    {  1980,  2075,  2177,  2178,  -1,  -1},
+    {  1981,  2078,  2179,  2180,  -1,  -1},
+    {  1981,  1982,  2077,  2079,  2180,  2181},
+    {  1982,  1983,  2078,  2080,  2181,  2182},
+    {  1983,  1984,  2079,  2081,  2182,  2183}, // 2080
+    {  1984,  1985,  2080,  2082,  2183,  2184},
+    {  1985,  1986,  2081,  2083,  2184,  2185},
+    {  1986,  1987,  2082,  2084,  2185,  2186},
+    {  1987,  1988,  2083,  2085,  2186,  2187},
+    {  1988,  1989,  2084,  2086,  2187,  2188},
+    {  1989,  1990,  2085,  2087,  2188,  2189},
+    {  1990,  1991,  2086,  2088,  2189,  2190},
+    {  1991,  1992,  2087,  2089,  2190,  2191},
+    {  1992,  1993,  2088,  2090,  2191,  2192},
+    {  1993,  1994,  2089,  2091,  2192,  2193},
+    {  1994,  1995,  2090,  2092,  2193,  2194},
+    {  1995,  1996,  2091,  2093,  2194,  2195},
+    {  1996,  2092,  2195,  2196,  -1,  -1},
+    {  1997,  2095,  2197,  2198,  -1,  -1},
+    {  1997,  1998,  2094,  2096,  2198,  2199},
+    {  1998,  1999,  2095,  2097,  2199,  2200},
+    {  1999,  2000,  2096,  2098,  2200,  2201},
+    {  2000,  2001,  2097,  2099,  2201,  2202},
+    {  2001,  2002,  2098,  2100,  2202,  2203},
+    {  2002,  2003,  2099,  2101,  2203,  2204}, // 2100
+    {  2003,  2004,  2100,  2102,  2204,  2205},
+    {  2004,  2005,  2101,  2103,  2205,  2206},
+    {  2005,  2006,  2102,  2104,  2206,  2207},
+    {  2006,  2007,  2103,  2105,  2207,  2208},
+    {  2007,  2008,  2104,  2106,  2208,  2209},
+    {  2008,  2009,  2105,  2107,  2209,  2210},
+    {  2009,  2010,  2106,  2108,  2210,  2211},
+    {  2010,  2011,  2107,  2109,  2211,  2212},
+    {  2011,  2012,  2108,  2110,  2212,  2213},
+    {  2012,  2109,  2213,  2214,  -1,  -1},
+    {  2013,  2112,  2215,  2216,  -1,  -1},
+    {  2013,  2014,  2111,  2113,  2216,  2217},
+    {  2014,  2015,  2112,  2114,  2217,  2218},
+    {  2015,  2016,  2113,  2115,  2218,  2219},
+    {  2016,  2017,  2114,  2116,  2219,  2220},
+    {  2017,  2018,  2115,  2117,  2220,  2221},
+    {  2018,  2019,  2116,  2118,  2221,  2222},
+    {  2019,  2020,  2117,  2119,  2222,  2223},
+    {  2020,  2021,  2118,  2120,  2223,  2224},
+    {  2021,  2022,  2119,  2121,  2224,  2225}, // 2120
+    {  2022,  2023,  2120,  2122,  2225,  2226},
+    {  2023,  2024,  2121,  2123,  2226,  2227},
+    {  2024,  2025,  2122,  2124,  2227,  2228},
+    {  2025,  2026,  2123,  2125,  2228,  2229},
+    {  2026,  2027,  2124,  2126,  2229,  2230},
+    {  2027,  2028,  2125,  2127,  2230,  2231},
+    {  2028,  2126,  2231,  2232,  -1,  -1},
+    {  2029,  2129,  2233,  2234,  -1,  -1},
+    {  2029,  2030,  2128,  2130,  2234,  2235},
+    {  2030,  2031,  2129,  2131,  2235,  2236},
+    {  2031,  2032,  2130,  2132,  2236,  2237},
+    {  2032,  2033,  2131,  2133,  2237,  2238},
+    {  2033,  2034,  2132,  2134,  2238,  2239},
+    {  2034,  2035,  2133,  2135,  2239,  2240},
+    {  2035,  2036,  2134,  2136,  2240,  2241},
+    {  2036,  2037,  2135,  2137,  2241,  2242},
+    {  2037,  2038,  2136,  2138,  2242,  2243},
+    {  2038,  2039,  2137,  2139,  2243,  2244},
+    {  2039,  2040,  2138,  2140,  2244,  2245},
+    {  2040,  2041,  2139,  2141,  2245,  2246}, // 2140
+    {  2041,  2042,  2140,  2142,  2246,  2247},
+    {  2042,  2043,  2141,  2143,  2247,  2248},
+    {  2043,  2044,  2142,  2144,  2248,  2249},
+    {  2044,  2143,  2249,  2250,  -1,  -1},
+    {  2045,  2146,  2251,  2252,  -1,  -1},
+    {  2045,  2046,  2145,  2147,  2252,  2253},
+    {  2046,  2047,  2146,  2148,  2253,  2254},
+    {  2047,  2048,  2147,  2149,  2254,  2255},
+    {  2048,  2049,  2148,  2150,  2255,  2256},
+    {  2049,  2050,  2149,  2151,  2256,  2257},
+    {  2050,  2051,  2150,  2152,  2257,  2258},
+    {  2051,  2052,  2151,  2153,  2258,  2259},
+    {  2052,  2053,  2152,  2154,  2259,  2260},
+    {  2053,  2054,  2153,  2155,  2260,  2261},
+    {  2054,  2055,  2154,  2156,  2261,  2262},
+    {  2055,  2056,  2155,  2157,  2262,  2263},
+    {  2056,  2057,  2156,  2158,  2263,  2264},
+    {  2057,  2058,  2157,  2159,  2264,  2265},
+    {  2058,  2059,  2158,  2160,  2265,  2266},
+    {  2059,  2060,  2159,  2161,  2266,  2267}, // 2160
+    {  2060,  2160,  2267,  2268,  -1,  -1},
+    {  2061,  2163,  2269,  2270,  -1,  -1},
+    {  2061,  2062,  2162,  2164,  2270,  2271},
+    {  2062,  2063,  2163,  2165,  2271,  2272},
+    {  2063,  2064,  2164,  2166,  2272,  2273},
+    {  2064,  2065,  2165,  2167,  2273,  2274},
+    {  2065,  2066,  2166,  2168,  2274,  2275},
+    {  2066,  2067,  2167,  2169,  2275,  2276},
+    {  2067,  2068,  2168,  2170,  2276,  2277},
+    {  2068,  2069,  2169,  2171,  2277,  2278},
+    {  2069,  2070,  2170,  2172,  2278,  2279},
+    {  2070,  2071,  2171,  2173,  2279,  2280},
+    {  2071,  2072,  2172,  2174,  2280,  2281},
+    {  2072,  2073,  2173,  2175,  2281,  2282},
+    {  2073,  2074,  2174,  2176,  2282,  2283},
+    {  2074,  2075,  2175,  2177,  2283,  2284},
+    {  2075,  2076,  2176,  2178,  2284,  2285},
+    {  2076,  2177,  2285,  2286,  -1,  -1},
+    {  2077,  2180,  2287,  2288,  -1,  -1},
+    {  2077,  2078,  2179,  2181,  2288,  2289}, // 2180
+    {  2078,  2079,  2180,  2182,  2289,  2290},
+    {  2079,  2080,  2181,  2183,  2290,  2291},
+    {  2080,  2081,  2182,  2184,  2291,  2292},
+    {  2081,  2082,  2183,  2185,  2292,  2293},
+    {  2082,  2083,  2184,  2186,  2293,  2294},
+    {  2083,  2084,  2185,  2187,  2294,  2295},
+    {  2084,  2085,  2186,  2188,  2295,  2296},
+    {  2085,  2086,  2187,  2189,  2296,  2297},
+    {  2086,  2087,  2188,  2190,  2297,  2298},
+    {  2087,  2088,  2189,  2191,  2298,  2299},
+    {  2088,  2089,  2190,  2192,  2299,  2300},
+    {  2089,  2090,  2191,  2193,  2300,  2301},
+    {  2090,  2091,  2192,  2194,  2301,  2302},
+    {  2091,  2092,  2193,  2195,  2302,  2303},
+    {  2092,  2093,  2194,  2196,  2303,  2304},
+    {  2093,  2195,  2304,  2305,  -1,  -1},
+    {  2094,  2198,  2306,  2307,  -1,  -1},
+    {  2094,  2095,  2197,  2199,  2307,  2308},
+    {  2095,  2096,  2198,  2200,  2308,  2309},
+    {  2096,  2097,  2199,  2201,  2309,  2310}, // 2200
+    {  2097,  2098,  2200,  2202,  2310,  2311},
+    {  2098,  2099,  2201,  2203,  2311,  2312},
+    {  2099,  2100,  2202,  2204,  2312,  2313},
+    {  2100,  2101,  2203,  2205,  2313,  2314},
+    {  2101,  2102,  2204,  2206,  2314,  2315},
+    {  2102,  2103,  2205,  2207,  2315,  2316},
+    {  2103,  2104,  2206,  2208,  2316,  2317},
+    {  2104,  2105,  2207,  2209,  2317,  2318},
+    {  2105,  2106,  2208,  2210,  2318,  2319},
+    {  2106,  2107,  2209,  2211,  2319,  2320},
+    {  2107,  2108,  2210,  2212,  2320,  2321},
+    {  2108,  2109,  2211,  2213,  2321,  2322},
+    {  2109,  2110,  2212,  2214,  2322,  2323},
+    {  2110,  2213,  2323,  2324,  -1,  -1},
+    {  2111,  2216,  2325,  2326,  -1,  -1},
+    {  2111,  2112,  2215,  2217,  2326,  2327},
+    {  2112,  2113,  2216,  2218,  2327,  2328},
+    {  2113,  2114,  2217,  2219,  2328,  2329},
+    {  2114,  2115,  2218,  2220,  2329,  2330},
+    {  2115,  2116,  2219,  2221,  2330,  2331}, // 2220
+    {  2116,  2117,  2220,  2222,  2331,  2332},
+    {  2117,  2118,  2221,  2223,  2332,  2333},
+    {  2118,  2119,  2222,  2224,  2333,  2334},
+    {  2119,  2120,  2223,  2225,  2334,  2335},
+    {  2120,  2121,  2224,  2226,  2335,  2336},
+    {  2121,  2122,  2225,  2227,  2336,  2337},
+    {  2122,  2123,  2226,  2228,  2337,  2338},
+    {  2123,  2124,  2227,  2229,  2338,  2339},
+    {  2124,  2125,  2228,  2230,  2339,  2340},
+    {  2125,  2126,  2229,  2231,  2340,  2341},
+    {  2126,  2127,  2230,  2232,  2341,  2342},
+    {  2127,  2231,  2342,  2343,  -1,  -1},
+    {  2128,  2234,  2344,  2345,  -1,  -1},
+    {  2128,  2129,  2233,  2235,  2345,  2346},
+    {  2129,  2130,  2234,  2236,  2346,  2347},
+    {  2130,  2131,  2235,  2237,  2347,  2348},
+    {  2131,  2132,  2236,  2238,  2348,  2349},
+    {  2132,  2133,  2237,  2239,  2349,  2350},
+    {  2133,  2134,  2238,  2240,  2350,  2351},
+    {  2134,  2135,  2239,  2241,  2351,  2352}, // 2240
+    {  2135,  2136,  2240,  2242,  2352,  2353},
+    {  2136,  2137,  2241,  2243,  2353,  2354},
+    {  2137,  2138,  2242,  2244,  2354,  2355},
+    {  2138,  2139,  2243,  2245,  2355,  2356},
+    {  2139,  2140,  2244,  2246,  2356,  2357},
+    {  2140,  2141,  2245,  2247,  2357,  2358},
+    {  2141,  2142,  2246,  2248,  2358,  2359},
+    {  2142,  2143,  2247,  2249,  2359,  2360},
+    {  2143,  2144,  2248,  2250,  2360,  2361},
+    {  2144,  2249,  2361,  2362,  -1,  -1},
+    {  2145,  2252,  2363,  2364,  -1,  -1},
+    {  2145,  2146,  2251,  2253,  2364,  2365},
+    {  2146,  2147,  2252,  2254,  2365,  2366},
+    {  2147,  2148,  2253,  2255,  2366,  2367},
+    {  2148,  2149,  2254,  2256,  2367,  2368},
+    {  2149,  2150,  2255,  2257,  2368,  2369},
+    {  2150,  2151,  2256,  2258,  2369,  2370},
+    {  2151,  2152,  2257,  2259,  2370,  2371},
+    {  2152,  2153,  2258,  2260,  2371,  2372},
+    {  2153,  2154,  2259,  2261,  2372,  2373}, // 2260
+    {  2154,  2155,  2260,  2262,  2373,  2374},
+    {  2155,  2156,  2261,  2263,  2374,  2375},
+    {  2156,  2157,  2262,  2264,  2375,  2376},
+    {  2157,  2158,  2263,  2265,  2376,  2377},
+    {  2158,  2159,  2264,  2266,  2377,  2378},
+    {  2159,  2160,  2265,  2267,  2378,  2379},
+    {  2160,  2161,  2266,  2268,  2379,  2380},
+    {  2161,  2267,  2380,  2381,  -1,  -1},
+    {  2162,  2270,  2382,  2383,  -1,  -1},
+    {  2162,  2163,  2269,  2271,  2383,  2384},
+    {  2163,  2164,  2270,  2272,  2384,  2385},
+    {  2164,  2165,  2271,  2273,  2385,  2386},
+    {  2165,  2166,  2272,  2274,  2386,  2387},
+    {  2166,  2167,  2273,  2275,  2387,  2388},
+    {  2167,  2168,  2274,  2276,  2388,  2389},
+    {  2168,  2169,  2275,  2277,  2389,  2390},
+    {  2169,  2170,  2276,  2278,  2390,  2391},
+    {  2170,  2171,  2277,  2279,  2391,  2392},
+    {  2171,  2172,  2278,  2280,  2392,  2393},
+    {  2172,  2173,  2279,  2281,  2393,  2394}, // 2280
+    {  2173,  2174,  2280,  2282,  2394,  2395},
+    {  2174,  2175,  2281,  2283,  2395,  2396},
+    {  2175,  2176,  2282,  2284,  2396,  2397},
+    {  2176,  2177,  2283,  2285,  2397,  2398},
+    {  2177,  2178,  2284,  2286,  2398,  2399},
+    {  2178,  2285,  2399,  2400,  -1,  -1},
+    {  2179,  2288,  -1,  -1,  -1,  -1},
+    {  2179,  2180,  2287,  2289,  -1,  -1},
+    {  2180,  2181,  2288,  2290,  -1,  -1},
+    {  2181,  2182,  2289,  2291,  -1,  -1},
+    {  2182,  2183,  2290,  2292,  -1,  -1},
+    {  2183,  2184,  2291,  2293,  -1,  -1},
+    {  2184,  2185,  2292,  2294,  -1,  -1},
+    {  2185,  2186,  2293,  2295,  -1,  -1},
+    {  2186,  2187,  2294,  2296,  -1,  -1},
+    {  2187,  2188,  2295,  2297,  -1,  -1},
+    {  2188,  2189,  2296,  2298,  -1,  -1},
+    {  2189,  2190,  2297,  2299,  -1,  -1},
+    {  2190,  2191,  2298,  2300,  -1,  -1},
+    {  2191,  2192,  2299,  2301,  -1,  -1}, // 2300
+    {  2192,  2193,  2300,  2302,  -1,  -1},
+    {  2193,  2194,  2301,  2303,  -1,  -1},
+    {  2194,  2195,  2302,  2304,  -1,  -1},
+    {  2195,  2196,  2303,  2305,  -1,  -1},
+    {  2196,  2304,  -1,  -1,  -1,  -1},
+    {  2197,  2307,  -1,  -1,  -1,  -1},
+    {  2197,  2198,  2306,  2308,  -1,  -1},
+    {  2198,  2199,  2307,  2309,  -1,  -1},
+    {  2199,  2200,  2308,  2310,  -1,  -1},
+    {  2200,  2201,  2309,  2311,  -1,  -1},
+    {  2201,  2202,  2310,  2312,  -1,  -1},
+    {  2202,  2203,  2311,  2313,  -1,  -1},
+    {  2203,  2204,  2312,  2314,  -1,  -1},
+    {  2204,  2205,  2313,  2315,  -1,  -1},
+    {  2205,  2206,  2314,  2316,  -1,  -1},
+    {  2206,  2207,  2315,  2317,  -1,  -1},
+    {  2207,  2208,  2316,  2318,  -1,  -1},
+    {  2208,  2209,  2317,  2319,  -1,  -1},
+    {  2209,  2210,  2318,  2320,  -1,  -1},
+    {  2210,  2211,  2319,  2321,  -1,  -1}, // 2320
+    {  2211,  2212,  2320,  2322,  -1,  -1},
+    {  2212,  2213,  2321,  2323,  -1,  -1},
+    {  2213,  2214,  2322,  2324,  -1,  -1},
+    {  2214,  2323,  -1,  -1,  -1,  -1},
+    {  2215,  2326,  -1,  -1,  -1,  -1},
+    {  2215,  2216,  2325,  2327,  -1,  -1},
+    {  2216,  2217,  2326,  2328,  -1,  -1},
+    {  2217,  2218,  2327,  2329,  -1,  -1},
+    {  2218,  2219,  2328,  2330,  -1,  -1},
+    {  2219,  2220,  2329,  2331,  -1,  -1},
+    {  2220,  2221,  2330,  2332,  -1,  -1},
+    {  2221,  2222,  2331,  2333,  -1,  -1},
+    {  2222,  2223,  2332,  2334,  -1,  -1},
+    {  2223,  2224,  2333,  2335,  -1,  -1},
+    {  2224,  2225,  2334,  2336,  -1,  -1},
+    {  2225,  2226,  2335,  2337,  -1,  -1},
+    {  2226,  2227,  2336,  2338,  -1,  -1},
+    {  2227,  2228,  2337,  2339,  -1,  -1},
+    {  2228,  2229,  2338,  2340,  -1,  -1},
+    {  2229,  2230,  2339,  2341,  -1,  -1}, // 2340
+    {  2230,  2231,  2340,  2342,  -1,  -1},
+    {  2231,  2232,  2341,  2343,  -1,  -1},
+    {  2232,  2342,  -1,  -1,  -1,  -1},
+    {  2233,  2345,  -1,  -1,  -1,  -1},
+    {  2233,  2234,  2344,  2346,  -1,  -1},
+    {  2234,  2235,  2345,  2347,  -1,  -1},
+    {  2235,  2236,  2346,  2348,  -1,  -1},
+    {  2236,  2237,  2347,  2349,  -1,  -1},
+    {  2237,  2238,  2348,  2350,  -1,  -1},
+    {  2238,  2239,  2349,  2351,  -1,  -1},
+    {  2239,  2240,  2350,  2352,  -1,  -1},
+    {  2240,  2241,  2351,  2353,  -1,  -1},
+    {  2241,  2242,  2352,  2354,  -1,  -1},
+    {  2242,  2243,  2353,  2355,  -1,  -1},
+    {  2243,  2244,  2354,  2356,  -1,  -1},
+    {  2244,  2245,  2355,  2357,  -1,  -1},
+    {  2245,  2246,  2356,  2358,  -1,  -1},
+    {  2246,  2247,  2357,  2359,  -1,  -1},
+    {  2247,  2248,  2358,  2360,  -1,  -1},
+    {  2248,  2249,  2359,  2361,  -1,  -1}, // 2360
+    {  2249,  2250,  2360,  2362,  -1,  -1},
+    {  2250,  2361,  -1,  -1,  -1,  -1},
+    {  2251,  2364,  -1,  -1,  -1,  -1},
+    {  2251,  2252,  2363,  2365,  -1,  -1},
+    {  2252,  2253,  2364,  2366,  -1,  -1},
+    {  2253,  2254,  2365,  2367,  -1,  -1},
+    {  2254,  2255,  2366,  2368,  -1,  -1},
+    {  2255,  2256,  2367,  2369,  -1,  -1},
+    {  2256,  2257,  2368,  2370,  -1,  -1},
+    {  2257,  2258,  2369,  2371,  -1,  -1},
+    {  2258,  2259,  2370,  2372,  -1,  -1},
+    {  2259,  2260,  2371,  2373,  -1,  -1},
+    {  2260,  2261,  2372,  2374,  -1,  -1},
+    {  2261,  2262,  2373,  2375,  -1,  -1},
+    {  2262,  2263,  2374,  2376,  -1,  -1},
+    {  2263,  2264,  2375,  2377,  -1,  -1},
+    {  2264,  2265,  2376,  2378,  -1,  -1},
+    {  2265,  2266,  2377,  2379,  -1,  -1},
+    {  2266,  2267,  2378,  2380,  -1,  -1},
+    {  2267,  2268,  2379,  2381,  -1,  -1}, // 2380
+    {  2268,  2380,  -1,  -1,  -1,  -1},
+    {  2269,  2383,  -1,  -1,  -1,  -1},
+    {  2269,  2270,  2382,  2384,  -1,  -1},
+    {  2270,  2271,  2383,  2385,  -1,  -1},
+    {  2271,  2272,  2384,  2386,  -1,  -1},
+    {  2272,  2273,  2385,  2387,  -1,  -1},
+    {  2273,  2274,  2386,  2388,  -1,  -1},
+    {  2274,  2275,  2387,  2389,  -1,  -1},
+    {  2275,  2276,  2388,  2390,  -1,  -1},
+    {  2276,  2277,  2389,  2391,  -1,  -1},
+    {  2277,  2278,  2390,  2392,  -1,  -1},
+    {  2278,  2279,  2391,  2393,  -1,  -1},
+    {  2279,  2280,  2392,  2394,  -1,  -1},
+    {  2280,  2281,  2393,  2395,  -1,  -1},
+    {  2281,  2282,  2394,  2396,  -1,  -1},
+    {  2282,  2283,  2395,  2397,  -1,  -1},
+    {  2283,  2284,  2396,  2398,  -1,  -1},
+    {  2284,  2285,  2397,  2399,  -1,  -1},
+    {  2285,  2286,  2398,  2400,  -1,  -1},
+    {  2286,  2399,  -1,  -1,  -1,  -1} // 2400
+};
+
+    for (Int_t i=0; i<2401; 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-8-5/Mars/mgeom/MGeomCamMagicHG.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mgeom/MGeomCamMagicHG.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mgeom/MGeomCamMagicHG.h	(revision 9661)
@@ -0,0 +1,21 @@
+#ifndef MARS_MGeomCamMagicHG
+#define MARS_MGeomCamMagicHG
+
+#ifndef MARS_MGeomCam
+#include "MGeomCam.h"
+#endif
+
+class MGeomCamMagicHG : public MGeomCam
+{
+private:
+    void CreateCam();
+    void CreateNN();
+
+public:
+    MGeomCamMagicHG(const char *name=NULL);
+
+    ClassDef(MGeomCamMagicHG, 1)		// Geometry class for a high granularity Magic camera
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mgeom/MGeomCorsikaCT.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mgeom/MGeomCorsikaCT.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mgeom/MGeomCorsikaCT.cc	(revision 9661)
@@ -0,0 +1,76 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Oscar Blanch 11/2002 <mailto:blanch@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MGeomCorsikaCT
+//
+// This is the base class of the PMT characteristics. 
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MGeomCorsikaCT.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MGeomCorsikaCT);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Initializes a Telescope geometry.
+//
+MGeomCorsikaCT::MGeomCorsikaCT(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MGeomCorsikaCT";
+    fTitle = title ? title : "Storage container for CT Telescope characteristics";
+}
+
+// --------------------------------------------------------------------------
+//
+// It fills the member variable of this class
+//
+void MGeomCorsikaCT::Fill(Float_t ctx, Float_t cty, Float_t ctz,
+			  Float_t cttheta, Float_t ctphi,
+			  Float_t ctdiam, Float_t ctfocal){
+  
+  fCTx=ctx;
+  fCTy=cty;
+  fCTz=ctz;
+  fCTtheta=cttheta;
+  fCTphi=ctphi;
+  fCTdiam=ctdiam;
+  fCTfocal=ctfocal;
+}
+// --------------------------------------------------------------------------
+//
+// Print the geometry information of one pixel.
+//
+void MGeomCorsikaCT::Print(Option_t *opt) const
+{ 
+    //   information about a telescope
+  *fLog << all << "x = " << fCTx << ", y = " << fCTy << ", z = " 
+	<< fCTz << " cm " << endl;
+}
Index: /tags/Mars_V0-8-5/Mars/mgeom/MGeomCorsikaCT.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mgeom/MGeomCorsikaCT.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mgeom/MGeomCorsikaCT.h	(revision 9661)
@@ -0,0 +1,39 @@
+#ifndef MARS_MGeomCorsikaCT
+#define MARS_MGeomCorsikaCT
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MGeomCorsikaCT : public MParContainer
+{
+private:
+
+    Float_t fCTx;  // X position of the CT center
+    Float_t fCTy;  // Y position of the CT center
+    Float_t fCTz;  // Z above high position of the CT center
+    Float_t fCTtheta; // 
+    Float_t fCTphi;   //
+    Float_t fCTdiam;  // Diameter where the Cph are stored at MMCs level
+    Float_t fCTfocal; // Focal of the CT
+
+public:
+
+    MGeomCorsikaCT(const char *name=NULL, const char *title=NULL);
+
+    void Print(Option_t *opt=NULL) const;
+
+    void Fill(Float_t ctx, Float_t cty, Float_t ctz,
+	      Float_t cttheta, Float_t ctphi,
+	      Float_t ctdiam, Float_t ctfocal);
+
+    Float_t GetCTx() { return fCTx; }
+    Float_t GetCTy() { return fCTy; }
+    Float_t GetCTz() { return fCTz; }
+
+    ClassDef(MGeomCorsikaCT, 1)  // class containing information about CTelescope
+};
+
+#endif
+
+
Index: /tags/Mars_V0-8-5/Mars/mgeom/MGeomMirror.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mgeom/MGeomMirror.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mgeom/MGeomMirror.cc	(revision 9661)
@@ -0,0 +1,156 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Oscar Blanch 11/2002 <mailto:blanch@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MGeomMirror
+//
+// This is the base class of the Mirror geometry. 
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MGeomMirror.h"
+
+#include <TRotation.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MGeomMirror);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Initializes a Mirror geometry with 0 values, except for fMirrorID.
+//
+MGeomMirror::MGeomMirror(Int_t mir, const char *name, const char *title)
+    : fReflector(0)
+{
+    fName  = name  ? name  : "MGeomMirror";
+    fTitle = title ? title : "Storage container for  a mirror geometry";
+
+    fMirrorId=mir;   // the Mirror Id
+
+    fFocalDist=0.;   //  focal distance of that mirror [cm]
+    fSX=0.;          // curvilinear coordinate of mirror's center in X[cm]
+    fSY=0.;          // curvilinear coordinate of mirror's center in X[cm]
+    fX=0.;           // x coordinate of the center of the mirror [cm]
+    fY=0.;           // y coordinate of the center of the mirror [cm]
+    fZ=0.;           // z coordinate of the center of the mirror [cm]
+    fThetaN=0.;      // polar theta angle of the direction 
+                     //  where the mirror points to
+    fPhiN=0.;        // polar phi angle of the direction
+                     // where the mirror points to
+    fXN=0.;          // xn coordinate of the normal vector
+                     // in the center
+    fYN=0.;          // yn coordinate of the normal vector
+                     // in the center
+    fZN=0.;          // zn coordinate of the normal vector
+                     // in the center
+                     // Note: fXN^2*fYN^2*fZN^2 = 1
+    fDeviationX=0.;  // deviation in x [cm]
+    fDeviationY=0.;  // deviation in y [cm]
+                     // of the spot of a single mirror on the camera plane
+
+}
+
+// --------------------------------------------------------------------------
+//
+// DESCRIPTION MISSING: Please contact Oscar
+//
+void MGeomMirror::SetMirrorContent(Int_t mir, Float_t focal, Float_t curv_x,
+                                   Float_t curv_y, Float_t lin_x, Float_t lin_y,
+				   Float_t lin_z, Float_t theta, Float_t phi,
+				   Float_t x_n, Float_t y_n, Float_t z_n){
+    fMirrorId=mir;   // the Mirror Id
+
+    fFocalDist=focal;   //  focal distance of that mirror [cm]
+    fSX=curv_x;          // curvilinear coordinate of mirror's center in X[cm]
+    fSY=curv_y;          // curvilinear coordinate of mirror's center in X[cm]
+    fX=lin_x;           // x coordinate of the center of the mirror [cm]
+    fY=lin_y;           // y coordinate of the center of the mirror [cm]
+    fZ=lin_z;           // z coordinate of the center of the mirror [cm]
+    fThetaN=theta;      // polar theta angle of the direction 
+                     //  where the mirror points to
+    fPhiN=phi;        // polar phi angle of the direction
+                     // where the mirror points to
+    fXN=x_n;          // xn coordinate of the normal vector
+                     // in the center
+    fYN=y_n;          // yn coordinate of the normal vector
+                     // in the center
+    fZN=z_n;          // zn coordinate of the normal vector
+                     // in the center
+                     // Note: fXN^2*fYN^2*fZN^2 = 1
+}
+
+void MGeomMirror::SetMirrorDeviations(Float_t dev_x, Float_t dev_y)
+{
+    fDeviationX=dev_x;  // deviation in x [cm]
+    fDeviationY=dev_y;  // deviation in y [cm]
+                     // of the spot of a single mirror on the camera plane
+}
+
+// --------------------------------------------------------------------------
+//
+// Setting function to store the mirror reflectivity (ref) at different
+// wavelength (wav).
+//
+void MGeomMirror::SetReflectivity(const TArrayF &wav, const TArrayF &ref)
+{
+    if (fWavelength.GetSize()!=wav.GetSize() ||
+        fReflectivity.GetSize()!=ref.GetSize())
+    {
+        *fLog << err << dbginf << " fWavelength or fQE do not have ";
+        *fLog << "size of setting arrays" << endl;
+        return;
+    }
+
+    fWavelength = wav;
+    fReflectivity = ref;
+}
+
+TVector3 MGeomMirror::GetReflection(const TVector3 &star, Double_t dist)
+{
+    if (!fReflector)
+    {
+        fReflector = new TRotation; // unit matrix
+        fReflector->Rotate(TMath::Pi(), GetMirrorNorm());
+    }
+
+    // Reflect star on the mirror (done by a rotation
+    // around the normal vector of the mirror center
+    TVector3 light(star);
+    light *= *fReflector;
+
+    if (dist<0)
+        return light;
+
+    // calculate distance to the camera (stretch vector such, that
+    // its Z component is the distance between the camera and
+    // the mirror
+    const TVector3 &pos = GetMirrorCenter();
+    const Double_t d = (dist - pos.Z()) / light.Z();
+
+    return light*d + pos;
+}
Index: /tags/Mars_V0-8-5/Mars/mgeom/MGeomMirror.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mgeom/MGeomMirror.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mgeom/MGeomMirror.h	(revision 9661)
@@ -0,0 +1,67 @@
+#ifndef MARS_MGeomMirror
+#define MARS_MGeomMirror
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#ifndef ROOT_TVector3
+#include <TVector3.h>
+#endif
+
+#ifndef ROOT_TArrayF
+#include <TArrayF.h>
+#endif
+
+class TRotation;
+class MGeomMirror : public MParContainer
+{
+private:
+    Int_t   fMirrorId;     // the Mirror Id
+
+    Float_t fFocalDist;    // [cm] focal distance of that mirror
+    Float_t fSX;           // [cm] curvilinear coordinate of mirror's center in X
+    Float_t fSY;           // [cm] curvilinear coordinate of mirror's center in Y
+    Float_t fX;            // [cm] x coordinate of the center of the mirror
+    Float_t fY;            // [cm] y coordinate of the center of the mirror
+    Float_t fZ;            // [cm] z coordinate of the center of the mirror
+    Float_t fThetaN;       // polar theta angle of the direction where the mirror points to
+    Float_t fPhiN;         // polar phi angle of the direction where the mirror points to
+    Float_t fXN;           // xn coordinate of the normal vector in the center
+    Float_t fYN;           // yn coordinate of the normal vector in the center
+    Float_t fZN;           // zn coordinate of the normal vector in the center
+                           // Note: fXN^2*fYN^2*fZN^2 = 1
+    Float_t fDeviationX;   // [cm] deviation in x of the spot of a single mirror on the camera plane
+    Float_t fDeviationY;   // [cm] deviation in y of the spot of a single mirror on the camera plane
+
+    TArrayF fWavelength;   // List of wavelength
+    TArrayF fReflectivity; // Mirror reflectivity
+
+    TRotation *fReflector; //! Store this for acceleration
+
+public:
+    MGeomMirror(Int_t mir=-1, const char *name=NULL, const char *title=NULL);
+
+    Int_t GetMirrorId() const         { return fMirrorId;   }
+
+    void  SetMirrorContent(Int_t mir, Float_t focal, Float_t curv_x,
+                           Float_t curv_y, Float_t lin_x, Float_t lin_y,
+                           Float_t lin_z, Float_t theta, Float_t phi,
+                           Float_t x_n, Float_t y_n, Float_t z_n);
+    void  SetMirrorDeviations(Float_t dev_x, Float_t dev_y);
+
+    void  SetReflectivity(const TArrayF &wav, const TArrayF &ref);
+
+    void  SetArraySize(Int_t dim) { fWavelength.Set(dim); fReflectivity.Set(dim); }
+
+    TVector3 GetMirrorCenter() const { return TVector3(fX/100, fY/100, fZ/100); }
+    TVector3 GetMirrorNorm()   const { return TVector3(fXN, fYN, fZN); }
+
+    TVector3 GetReflection(const TVector3 &star, Double_t dist=-1);
+
+    ClassDef(MGeomMirror, 2)  // geometry class describing one mirror
+};
+
+#endif
+
+
Index: /tags/Mars_V0-8-5/Mars/mgeom/MGeomPMT.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mgeom/MGeomPMT.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mgeom/MGeomPMT.cc	(revision 9661)
@@ -0,0 +1,70 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Oscar Blanch 11/2002 <mailto:blanch@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MGeomPMT
+//
+// This is the base class of the PMT characteristics. 
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MGeomPMT.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MGeomPMT);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Initializes a Mirror geometry with 0 values, except for fMirrorID.
+//
+MGeomPMT::MGeomPMT(Int_t pmt, const char *name, const char *title)
+    : fPMTId(pmt), fWavelength(0), fQE(0)
+{
+    fName  = name  ? name  : "MGeomPMT";
+    fTitle = title ? title : "Storage container for  a PMT characteristics";
+}
+
+// --------------------------------------------------------------------------
+//
+// DESCRIPTION MISSING Please contact Oscar
+//
+void MGeomPMT::SetPMTContent(Int_t pmt, const TArrayF &wav, const TArrayF &qe)
+{
+    if (fWavelength.GetSize()!=wav.GetSize() ||
+        fQE.GetSize()!=qe.GetSize())
+    {
+        *fLog << err << dbginf << " fWavelength or fQE do not have ";
+        *fLog << "size of setting arrays" << endl;
+        return;
+    }
+
+    fPMTId = pmt;
+
+    fWavelength = wav;
+    fQE = qe;
+}
Index: /tags/Mars_V0-8-5/Mars/mgeom/MGeomPMT.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mgeom/MGeomPMT.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mgeom/MGeomPMT.h	(revision 9661)
@@ -0,0 +1,34 @@
+#ifndef MARS_MGeomPMT
+#define MARS_MGeomPMT
+
+#ifndef ROOT_TArrayF
+#include <TArrayF.h>
+#endif
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MGeomPMT : public MParContainer
+{
+private:
+    Int_t   fPMTId;        // the PMT Id
+
+    TArrayF fWavelength;  // List of wavelength
+    TArrayF fQE;          // QE values
+
+public:
+
+    MGeomPMT(Int_t pmt=-1,const char *name=NULL, const char *title=NULL);
+
+    Int_t   GetPMTId() const         { return fPMTId;   }
+
+    void    SetArraySize(Int_t dim) { fWavelength.Set(dim); fQE.Set(dim); }
+
+    void    SetPMTContent(Int_t pmt, const TArrayF &wav, const TArrayF &qe);
+
+    ClassDef(MGeomPMT, 1)  // class containing information about PMTs
+};
+
+#endif
+
+
Index: /tags/Mars_V0-8-5/Mars/mgeom/MGeomPix.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mgeom/MGeomPix.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mgeom/MGeomPix.cc	(revision 9661)
@@ -0,0 +1,171 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Harald Kornmayer 1/2001
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// MGeomPix
+//
+// This container stores the geometry (position) information of
+// a single pixel together with the information about next neighbors.
+//
+// The BIT(22) and BIT(23) is used to flag the pixels in the outer
+// and outermost ring. Please don't use this bits in conjuction with
+// MGeomPix.
+//
+//
+// Version 1:
+// ----------
+//  - first implementation
+//
+// Version 2:
+// ----------
+//  - added fA
+//
+// Version 3:
+// ----------
+//  - added fAidx
+//
+//
+// FIXME: According to an agreement we have to change the name 'Id' to 'idx'
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MGeomPix.h"
+
+#include <math.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MGeomCam.h"
+
+ClassImp(MGeomPix);
+
+using namespace std;
+
+const Float_t MGeomPix::gsTan60 = tan(60/kRad2Deg);
+
+// --------------------------------------------------------------------------
+//
+// Initializes one pixel
+//
+MGeomPix::MGeomPix(Float_t x, Float_t y, Float_t r, UInt_t s, UInt_t a)
+{
+    //  default constructor
+    Set(x, y, r, s, a);
+}
+
+// --------------------------------------------------------------------------
+//
+// Initializes Next Neighbors.
+//
+// WARNING: This function is public, but it is not meant for user access.
+// It should only be used from geometry classes (like MGeomCam)
+//
+void MGeomPix::SetNeighbors(Short_t i0, Short_t i1, Short_t i2,
+                            Short_t i3, Short_t i4, Short_t i5)
+{
+    fNeighbors[0] = i0;
+    fNeighbors[1] = i1;
+    fNeighbors[2] = i2;
+    fNeighbors[3] = i3;
+    fNeighbors[4] = i4;
+    fNeighbors[5] = i5;
+
+    int i;
+    for (i=0; i<6; i++)
+        if (fNeighbors[i]<0)
+            break;
+
+    fNumNeighbors = i;
+
+    if (fNumNeighbors<5)
+        SetBit(kIsInOutermostRing);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Set the kIsOuterRing flag if this pixel has a outermost pixel
+//  as Next Neighbor and don't have the kIsOutermostRing flag itself.
+//
+void MGeomPix::CheckOuterRing(const MGeomCam &cam)
+{
+    if (IsInOutermostRing())
+        return;
+
+    for (int i=0; i<fNumNeighbors; i++)
+        if (cam[fNeighbors[i]].IsInOutermostRing())
+        {
+            SetBit(kIsInOuterRing);
+            return;
+        }
+}
+
+// --------------------------------------------------------------------------
+//
+// Print the geometry information of one pixel.
+//
+void MGeomPix::Print(Option_t *opt) const
+{ 
+    //   information about a pixel
+    *fLog << all << "MPixGeom:  x= " << fX << "mm  y= " << fY << "mm ";
+    *fLog << "d= " << fD << "mm  A= " << fA << "mm²" << endl;
+}
+
+// ------------------------------------------------------------------------
+//
+// compute the distance of a point (px,py) to the Hexagon center in
+// MGeomPix coordinates. Return kTRUE if inside.
+//
+Bool_t MGeomPix::IsInside(Float_t px, Float_t py) const
+{
+    //
+    //  compute the distance of the Point to the center of the Hexagon
+    //
+    const Double_t dx = px-fX;
+
+    //
+    // Now check if point is outside of hexagon; just check x coordinate
+    // in three coordinate systems: the default one, in which two sides of
+    // the hexagon are paralel to the y axis (see camera displays) and two 
+    // more, rotated with respect to that one by +- 60 degrees.
+    //
+    if (TMath::Abs(dx)*2>fD)
+        return kFALSE;
+
+    const Double_t dy = py-fY;
+
+    const static Double_t cos60 = TMath::Cos(60/kRad2Deg);
+    const static Double_t sin60 = TMath::Sin(60/kRad2Deg);
+
+    const Double_t dx2 = dx*cos60 + dy*sin60;
+    if  (TMath::Abs(dx2)*2>fD)
+        return kFALSE;
+
+    const Double_t dx3 = dx*cos60 - dy*sin60;
+    if (TMath::Abs(dx3)*2>fD)
+        return kFALSE;
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mgeom/MGeomPix.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mgeom/MGeomPix.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mgeom/MGeomPix.h	(revision 9661)
@@ -0,0 +1,74 @@
+#ifndef MARS_MGeomPix
+#define MARS_MGeomPix
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MGeomCam;
+
+class MGeomPix : public MParContainer
+{ 
+private:
+    static const Float_t gsTan60; // tan(60/kRad2Deg);
+
+    enum {
+        kIsInOutermostRing = BIT(22),
+        kIsInOuterRing     = BIT(23),
+        kUserBits          = 0x1fc000 // 14-21 are allowed
+    };
+
+    Float_t fX;            // [mm]   the x coordinate of the center
+    Float_t fY;            // [mm]   the y coordinate of the center
+    Float_t fD;            // [mm]   the d coordinate of the pixel (dist between two parallel sides)
+    Float_t fA;            // [mm^2] Area of the pixel
+
+    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)
+
+    UInt_t fSector;        // Number of sector the pixels corresponds to
+    UInt_t fAidx;          // Area index of the pixel
+
+public:
+    MGeomPix(Float_t x=0, Float_t y=0, Float_t d=0, UInt_t s=0, UInt_t aidx=0);
+
+    void Print(Option_t *opt=NULL) const;
+
+    void Set(Float_t x, Float_t y, Float_t d, UInt_t s=0, UInt_t aidx=0) { fX=x; fY=y; fD=d; fA=d*d*gsTan60/2; fSector=s; fAidx=aidx; }
+
+    void SetNeighbors(Short_t i0=-1, Short_t i1=-1, Short_t i2=-1,
+                      Short_t i3=-1, Short_t i4=-1, Short_t i5=-1);
+
+    void CheckOuterRing(const MGeomCam &cam);
+
+    Float_t GetX() const  { return fX; }
+    Float_t GetY() const  { return fY; }
+    Float_t GetD() const  { return fD; }
+    UInt_t  GetSector() const { return fSector; }
+
+    Float_t GetA() const    { return fA; /*fD*fD*gsTan60/2;*/ }
+    Int_t   GetAidx() const { return fAidx; }
+
+    Byte_t  GetNumNeighbors() const { return fNumNeighbors; }
+    Short_t GetNeighbor(Byte_t i) const { return fNeighbors[i]; }
+
+    Bool_t IsInOutermostRing() const { return TestBit(kIsInOutermostRing); }
+    Bool_t IsInOuterRing() const     { return TestBit(kIsInOuterRing); }
+
+    Bool_t IsInside(Float_t px, Float_t py) const;
+
+    /*
+     //
+     // These function are for future usage. They are not virtual in
+     // root by now.
+     //
+     void SetBit(UInt_t f, Bool_t set) { set ? TObject::SetBit(f) : TObject::ResetBit(f); }
+     void SetBit(UInt_t f)    { TObject::SetBit(f & kUserBits); }
+     void ResetBit(UInt_t f)  { TObject::ResetBit(f & kUserBits); }
+     void InvertBit(UInt_t f) { TObject InvertBit(f & kUserBits); }
+     */
+
+    ClassDef(MGeomPix, 3) // Geometry class describing the geometry of one pixel
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mgeom/Makefile
===================================================================
--- /tags/Mars_V0-8-5/Mars/mgeom/Makefile	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mgeom/Makefile	(revision 9661)
@@ -0,0 +1,42 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#------------------------------------------------------------------------------
+
+#
+# Handling name of the Root Dictionary Files
+#
+CINT  = Geom
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES = -I. -I../mbase -I../MBase
+
+SRCFILES = MGeomPix.cc \
+           MGeomCam.cc \
+           MGeomCamCT1.cc \
+           MGeomCamCT1Daniel.cc \
+           MGeomCamMagic.cc \
+           MGeomCamMagicHG.cc \
+           MGeomCamMagic919.cc \
+           MGeomCamECO1000.cc \
+           MGeomCamECO1000HG.cc \
+           MGeomCorsikaCT.cc \
+	   MGeomMirror.cc \
+	   MGeomPMT.cc
+
+############################################################
+
+all: $(OBJS)
+
+include ../Makefile.rules
+
+mrproper:	clean rmbak
Index: /tags/Mars_V0-8-5/Mars/mgui/GuiIncl.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mgui/GuiIncl.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mgui/GuiIncl.h	(revision 9661)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-8-5/Mars/mgui/GuiLinkDef.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mgui/GuiLinkDef.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mgui/GuiLinkDef.h	(revision 9661)
@@ -0,0 +1,10 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class MHexagon+;
+#pragma link C++ class MCamEvent+;
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mgui/MAitoff.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mgui/MAitoff.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mgui/MAitoff.cc	(revision 9661)
@@ -0,0 +1,86 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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, 7/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// MAitoff
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MAitoff.h"
+
+#include <TMath.h>
+#include <TMarker.h>
+#include <TVirtualPad.h>
+
+#include "MH.h"
+
+ClassImp(MAitoff);
+
+using namespace std;
+
+void MAitoff::Transform(Double_t lon, Double_t lat, Double_t &x, Double_t &y)
+{
+    Double_t b = lon;
+    Double_t sa = lat;
+
+    Double_t alpha2 = sa/kRad2Deg /2.;
+    Double_t delta = b/kRad2Deg;
+
+    Double_t r2 = sqrt(2.);
+    Double_t f = 2.*r2/TMath::Pi();
+    Double_t cdec = cos(delta);
+    Double_t denom = sqrt(1.+cdec*cos(alpha2));
+    x = cdec*sin(alpha2)*2.*r2/denom;
+    y = sin(delta);
+
+    x /= f/kRad2Deg;
+    y /= f/kRad2Deg;
+}
+
+void MAitoff::Draw(Option_t *)
+{
+    if (!gPad)
+        MH::MakeDefCanvas();
+
+    gPad->Range(-200, -80, 200, 80);
+
+    TMarker m;
+    Double_t x, y;
+
+    for (int i=-180; i<180; i+=3) { Transform( 60, i, x, y); m.DrawMarker(x, y); }
+    for (int i=-180; i<180; i+=3) { Transform( 30, i, x, y); m.DrawMarker(x, y); }
+    for (int i=-180; i<180; i+=3) { Transform(  0, i, x, y); m.DrawMarker(x, y); }
+    for (int i=-180; i<180; i+=3) { Transform(-30, i, x, y); m.DrawMarker(x, y); }
+    for (int i=-180; i<180; i+=3) { Transform(-60, i, x, y); m.DrawMarker(x, y); }
+
+    for (int i=-90; i<90; i++) { Transform(i, -180, x, y); m.DrawMarker(x, y); }
+    for (int i=-90; i<90; i++) { Transform(i, -135, x, y); m.DrawMarker(x, y); }
+    for (int i=-90; i<90; i++) { Transform(i,  -90, x, y); m.DrawMarker(x, y); }
+    for (int i=-90; i<90; i++) { Transform(i,  -45, x, y); m.DrawMarker(x, y); }
+    for (int i=-90; i<90; i++) { Transform(i,    0, x, y); m.DrawMarker(x, y); }
+    for (int i=-90; i<90; i++) { Transform(i,   45, x, y); m.DrawMarker(x, y); }
+    for (int i=-90; i<90; i++) { Transform(i,   90, x, y); m.DrawMarker(x, y); }
+    for (int i=-90; i<90; i++) { Transform(i,  135, x, y); m.DrawMarker(x, y); }
+    for (int i=-90; i<90; i++) { Transform(i,  180, x, y); m.DrawMarker(x, y); }
+}
Index: /tags/Mars_V0-8-5/Mars/mgui/MAitoff.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mgui/MAitoff.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mgui/MAitoff.h	(revision 9661)
@@ -0,0 +1,31 @@
+#ifndef MARS_MAitoff
+#define MARS_MAitoff
+
+//////////////////////////////////////////////////////////////
+//
+//   MAitoff
+//
+//   A Hexagon for the MAGIC event display
+//
+//////////////////////////////////////////////////////////////
+
+#ifndef MARS_MAGIC
+#include "MAGIC.h"
+#endif
+
+#ifndef ROOT_TPad
+#include <TPad.h>
+#endif 
+
+class MAitoff
+{
+public:
+    static void Transform(Double_t lon, Double_t lat, Double_t &x, Double_t &y);
+
+    void Draw(Option_t *o="");
+
+    ClassDef(MAitoff, 1)    // A hexagon for MAGIC
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mgui/MCamEvent.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mgui/MCamEvent.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mgui/MCamEvent.cc	(revision 9661)
@@ -0,0 +1,42 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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, 6/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// MCamEvent
+//
+// A base class describing an event in the camera.
+//
+// If GetPixelContent returns kFALSE, it must not touch 'val'.
+//
+// You can derive a class in addition to TObject from MCamEvent, too.
+//
+// MCamEvent MUST be after TObject:
+//  ALLOWED:   class MyClass : public TObject, public MCamEvent
+//  FORBIDDEN: class MyClass : public MCamEvent, public TObject
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MCamEvent.h"
+
+ClassImp(MCamEvent);
Index: /tags/Mars_V0-8-5/Mars/mgui/MCamEvent.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mgui/MCamEvent.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mgui/MCamEvent.h	(revision 9661)
@@ -0,0 +1,20 @@
+#ifndef MARS_MCamEvent
+#define MARS_MCamEvent
+
+#ifndef ROOT_TROOT
+#include <TROOT.h>
+#endif
+
+class MGeomCam;
+
+class MCamEvent
+{
+public:
+    virtual Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const = 0;
+    virtual void   DrawPixelContent(Int_t num) const = 0;
+
+    ClassDef(MCamEvent, 0) // A camera event
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mgui/MHexagon.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mgui/MHexagon.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mgui/MHexagon.cc	(revision 9661)
@@ -0,0 +1,348 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Harald Kornmayer 1/2001
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+// MHexagon                                                                 //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MHexagon.h"
+
+#include <fstream>
+#include <iostream>
+
+#include <TVirtualPad.h>  // gPad
+
+#include "MGeomPix.h"     // GetX
+
+ClassImp(MHexagon);
+
+using namespace std;
+
+// ------------------------------------------------------------------------
+//
+//   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(const MGeomPix &pix)
+: TAttLine(1, 1, 1), TAttFill(0, 1001)
+{
+    fX = pix.GetX();
+    fY = pix.GetY();
+    fD = pix.GetD();
+}
+
+// ------------------------------------------------------------------------
+//
+//    copy constructor for MHexagon
+//
+MHexagon::MHexagon(const MHexagon &hexagon) : TObject(hexagon), TAttLine(hexagon), TAttFill(hexagon)
+{
+    fX = hexagon.fX;
+    fY = hexagon.fY;
+    fD = hexagon.fD;
+} 
+
+// ------------------------------------------------------------------------
+//
+//     copy this hexagon to hexagon
+//
+void MHexagon::Copy(TObject &obj)
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,04,01)
+const
+#endif
+{
+    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, Float_t conv)
+{
+    //
+    //  compute the distance of the Point to the center of the Hexagon
+    //
+    const Int_t pxhex = gPad->XtoAbsPixel(fX*conv);
+    const Int_t pyhex = gPad->YtoAbsPixel(fY*conv);
+
+    const Double_t x = TMath::Abs(px-pxhex);
+    const Double_t y = TMath::Abs(py-pyhex);
+
+    const Double_t disthex = TMath::Sqrt(x*x + y*y);
+
+    if (disthex==0)
+        return 0;
+
+    const Double_t cosa = x / disthex;
+    const Double_t sina = y / disthex;
+
+    //
+    // comput the distance of hexagon center to pixel border
+    //
+    const Double_t dx = fD/2 * cosa;
+    const Double_t dy = fD/2 * sina;
+
+    const Int_t pxborder = gPad->XtoAbsPixel((fX + dx)*conv);
+    const Int_t pyborder = gPad->YtoAbsPixel((fY + dy)*conv);
+
+    const Double_t bx = pxhex-pxborder;
+    const Double_t by = pyhex-pyborder;
+
+    const Double_t distborder = TMath::Sqrt(bx*bx + by*by);
+
+    //
+    //  compute the distance from the border of Pixel
+    //  here in the first implementation is just circle inside
+    //
+    return distborder < disthex ? (int)((disthex-distborder)/conv+1) : 0;
+}
+
+// ------------------------------------------------------------------------
+//
+// compute the distance of a point (px,py) to the Hexagon center in world
+// coordinates. Return -1 if inside.
+//
+Float_t MHexagon::DistanceToPrimitive(Float_t px, Float_t py)
+{
+    //
+    //  compute the distance of the Point to the center of the Hexagon
+    //
+    const Double_t dx = px-fX;
+    const Double_t dy = py-fY;
+    const Double_t disthex = TMath::Sqrt(dx*dx + dy*dy);
+
+    //
+    // Now check if point is outside of hexagon; just check x coordinate
+    // in three coordinate systems: the default one, in which two sides of
+    // the hexagon are paralel to the y axis (see camera displays) and two 
+    // more, rotated with respect to that one by +- 60 degrees.
+    //
+
+    if (TMath::Abs(dx) > fD/2.)
+      return disthex;
+
+    const static Double_t cos60 = TMath::Cos(60/kRad2Deg);
+    const static Double_t sin60 = TMath::Sin(60/kRad2Deg);
+
+    const Double_t dx2 = dx*cos60 + dy*sin60;
+
+    if  (TMath::Abs(dx2) > fD/2.)
+      return disthex;
+
+    const Double_t dx3 = dx*cos60 - dy*sin60;
+
+    if  (TMath::Abs(dx3) > fD/2.)
+      return disthex;
+
+    return -1;
+}
+
+/*
+Float_t MHexagon::DistanceToPrimitive(Float_t px, Float_t py)
+{
+    //
+    //  compute the distance of the Point to the center of the Hexagon
+    //
+    const Double_t dx = px-fX;
+    const Double_t dy = py-fY;
+
+    const Double_t disthex = TMath::Sqrt(dx*dx + dy*dy);
+
+    //
+    //  compute the distance from the border of Pixel
+    //  here in the first implementation is just circle outside
+    //
+    return fD*0.5772 < disthex ? disthex-fD*0.5772 : -1;
+    //
+    // FIXME: this approximate method results in some photons being 
+    // assigned to two or even three different pixels.
+    //
+}
+*/
+
+// ------------------------------------------------------------------------
+//
+//  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 };
+
+    //
+    //  calculate the positions of the pixel corners
+    //
+    Float_t x[np+1], y[np+1];
+    for (Int_t i=0; i<np+1; i++)
+    {
+        x[i] = inX + dx[i]*inD;
+        y[i] = inY + dy[i]*inD;
+    }
+
+    TAttLine::Modify();    // Change line attributes only if neccessary
+    TAttFill::Modify();    // Change fill attributes only if neccessary
+
+    //
+    //   paint the pixel
+    //
+    if (GetFillColor())
+        gPad->PaintFillArea(np, x, y);
+
+    if (GetLineStyle())
+        gPad->PaintPolyLine(np+1, x, y);
+}
+
+// ------------------------------------------------------------------------
+//
+//  print/dump this hexagon with its attributes
+//
+void MHexagon::Print(Option_t *) const
+{
+    cout << "MHexagon: ";
+    cout << "x=" << fX << "mm y=" << fY << "mm r=" << fD << "mm" << endl;
+
+    cout << " Line:";
+    cout << " Color=" << GetLineColor() << ",";
+    cout << " Style=" << GetLineStyle() << ",";
+    cout << " Width=" << GetLineWidth() << endl;
+    cout << " Fill:";
+    cout << " Color=" << GetFillColor() << ",";
+    cout << " Style=" << GetFillStyle() << endl;
+}
+
+// ------------------------------------------------------------------------
+//
+// Save primitive as a C++ statement(s) on output stream out
+//
+void MHexagon::SavePrimitive(ofstream &out, Option_t *)
+{
+    if (gROOT->ClassSaved(Class()))
+       out << "   ";
+    else
+       out << "   MHexagon *";
+
+    out << "hexagon = new MHexagon(" << fX << "," << fY << "," << fD << ");" << endl;
+
+    SaveFillAttributes(out, "hexagon");
+    SaveLineAttributes(out, "hexagon");
+
+    out << "   hexagon->Draw();" << endl;
+}
+
Index: /tags/Mars_V0-8-5/Mars/mgui/MHexagon.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mgui/MHexagon.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mgui/MHexagon.h	(revision 9661)
@@ -0,0 +1,75 @@
+#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(const MGeomPix &pix);
+    MHexagon(const MHexagon &hexagon);
+
+    virtual void  Copy(TObject &hexagon)
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,04,01)
+const
+#endif
+        ;
+
+    Int_t DistancetoPrimitive(Int_t px, Int_t py, Float_t conv);
+    virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
+    {
+        return DistancetoPrimitive(px, py, 1);
+    }
+    virtual Float_t DistanceToPrimitive(Float_t px, Float_t py);
+    virtual void  DrawHexagon(Float_t x, Float_t y, Float_t d);
+
+    //virtual void  ExecuteEvent(Int_t event, Int_t px, Int_t py);
+
+    virtual void  ls(const Option_t *Option="") const;
+    virtual void  Paint(Option_t *Option="");
+    virtual void  PaintHexagon(Float_t x, Float_t y, Float_t d);
+    virtual void  Print(Option_t *Option="") const; // *MENU*
+    virtual void  SavePrimitive(ofstream &out, Option_t *);
+
+    Float_t GetX() const { return fX; }
+    Float_t GetY() const { return fY; }
+    Float_t GetD() const { return fD; }
+
+    ClassDef(MHexagon, 1)    // A hexagon for MAGIC
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mgui/Makefile
===================================================================
--- /tags/Mars_V0-8-5/Mars/mgui/Makefile	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mgui/Makefile	(revision 9661)
@@ -0,0 +1,32 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#------------------------------------------------------------------------------
+
+#
+# Handling name of the Root Dictionary Files
+#
+CINT  = Gui
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES = -I. -I../mbase -I../mgeom
+
+SRCFILES = MHexagon.cc \
+	   MCamEvent.cc
+           
+############################################################
+
+all: $(OBJS)
+
+include ../Makefile.rules
+
+mrproper:	clean rmbak
Index: /tags/Mars_V0-8-5/Mars/mhbase/HBaseIncl.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhbase/HBaseIncl.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhbase/HBaseIncl.h	(revision 9661)
@@ -0,0 +1,6 @@
+#ifndef __CINT__
+
+#include <TF1.h>
+#include <TArrayI.h>
+
+#endif // __CINT__
Index: /tags/Mars_V0-8-5/Mars/mhbase/HBaseLinkDef.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhbase/HBaseLinkDef.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhbase/HBaseLinkDef.h	(revision 9661)
@@ -0,0 +1,17 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class MFillH+;
+
+#pragma link C++ class MH+;
+#pragma link C++ class MH3+;
+#pragma link C++ class MHArray+;
+#pragma link C++ class MHMatrix+;
+
+#pragma link C++ class MBinning+;
+#pragma link C++ class MWeight+;
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mhbase/MBinning.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhbase/MBinning.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhbase/MBinning.cc	(revision 9661)
@@ -0,0 +1,234 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 01/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MBinning                                                                //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+#include "MBinning.h"
+
+#include <ctype.h>      // tolower
+#include <fstream>
+
+#include <TH1.h>        // InheritsFrom
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MH.h"
+
+ClassImp(MBinning);
+
+using namespace std;
+
+static const TString gsDefName  = "MBinning";
+static const TString gsDefTitle = "Container describing the binning of an axis";
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor. It sets name and title only. Typically you won't
+// need to change this.
+//
+MBinning::MBinning(const char *name, const char *title)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+
+    SetEdges(10, 0, 1);
+    fType = kIsDefault;
+}
+
+MBinning::MBinning(Int_t nbins, Axis_t lo, Axis_t hi, const char *name, const char *opt, const char *title)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+
+    SetEdges(nbins, lo, hi, opt);
+
+}
+void MBinning::SetEdges(const TAxis &axe)
+{
+    const TArrayD &arr = *((TAxis&)axe).GetXbins();
+    if (arr.GetSize()>0)
+    {
+        SetEdges(arr);
+        return;
+    }
+
+    SetEdges(axe.GetNbins(), axe.GetXmin(), axe.GetXmax());
+}
+
+void MBinning::SetEdges(const TH1 &h, const Char_t axis)
+{
+    TH1 &hist = (TH1&)h; // get rid of const qualifier
+    switch (tolower(axis))
+    {
+    case 'x':
+        SetEdges(*hist.GetXaxis());
+        return;
+    case 'y':
+        SetEdges(*hist.GetYaxis());
+        return;
+    case 'z':
+        SetEdges(*hist.GetZaxis());
+        return;
+    default:
+        *fLog << warn << "MBinning::SetEdges: Axis '" << axis << "' unknown... using x." << endl;
+        SetEdges(*hist.GetXaxis());
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Specify the number of bins <nbins> (not the number of edges), the
+// lowest <lo> and highest <up> Edge (of your histogram)
+//
+void MBinning::SetEdges(const Int_t nbins, const Axis_t lo, Axis_t up)
+{
+    const Double_t binsize = (up-lo)/nbins;
+    fEdges.Set(nbins+1);
+    for (int i=0; i<=nbins; i++)
+            fEdges[i] = binsize*i + lo;
+
+    fType = kIsLinear;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calls SetEdgesLog if opt contains "log"
+// Calls SetEdgesCos if opt contains "cos"
+// Calls SetEdges in all other cases
+//
+void MBinning::SetEdges(const Int_t nbins, const Axis_t lo, Axis_t up, const char *opt)
+{
+    const TString o(opt);
+    if (o.Contains("log", TString::kIgnoreCase))
+    {
+        SetEdgesLog(nbins, lo, up);
+        return;
+    }
+    if (o.Contains("cos", TString::kIgnoreCase))
+    {
+        SetEdgesCos(nbins, lo, up);
+        return;
+    }
+    SetEdges(nbins, lo, up);
+}
+
+// --------------------------------------------------------------------------
+//
+// Specify the number of bins <nbins> (not the number of edges), the
+// lowest <lo> and highest <up> Edge (of your histogram)
+//
+void MBinning::SetEdgesLog(const Int_t nbins, const Axis_t lo, Axis_t up)
+{
+    // if (lo==0) ...
+
+    const Double_t binsize = log10(up/lo)/nbins;
+    fEdges.Set(nbins+1);
+    for (int i=0; i<=nbins; i++)
+        fEdges[i] = pow(10, binsize*i) * lo;
+
+    fType = kIsLogarithmic;
+}
+
+// --------------------------------------------------------------------------
+//
+// Specify the number of bins <nbins> (not the number of edges), the
+// lowest [deg] <lo> and highest [deg] <up> Edge (of your histogram)
+//
+void MBinning::SetEdgesCos(const Int_t nbins, const Axis_t lo, Axis_t up)
+{
+    // if (lo==0) ...
+    const Axis_t ld = lo/kRad2Deg;
+    const Axis_t ud = up/kRad2Deg;
+
+    const Double_t binsize = (cos(ld)-cos(ud))/nbins;
+    fEdges.Set(nbins+1);
+    for (int i=0; i<=nbins; i++)
+        fEdges[i] = acos(cos(ld)-binsize*i)*kRad2Deg;
+
+    fType = kIsCosinic;
+}
+
+// --------------------------------------------------------------------------
+//
+// Apply this binning to the given histogram.
+// (By definition this works only for 1D-histograms. For 2D- and 3D-
+//  histograms use MH::SetBinning directly)
+//
+void MBinning::Apply(TH1 &h)
+{
+    if (h.InheritsFrom("TH2") || h.InheritsFrom("TH3"))
+    {
+        *fLog << warn << "MBinning::Apply: '" << h.GetName() << "' is not a basic TH1 object... no binning applied." << endl;
+        return;
+    }
+
+    MH::SetBinning(&h, this);
+}
+
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
+void MBinning::StreamPrimitive(ofstream &out) const
+{
+    out << "   MBinning " << GetUniqueName();
+    if (fName!=gsDefName || fTitle!=gsDefTitle)
+    {
+        out << "(\"" << fName << "\"";
+        if (fTitle!=gsDefTitle)
+            out << ", \"" << fTitle << "\"";
+        out <<")";
+    }
+    out << ";" << endl;
+
+    if (IsDefault())
+        return;
+
+    if (IsLinear() || IsLogarithmic() || IsCosinic())
+    {
+        out << "   " << GetUniqueName() << ".SetEdges";
+        if (IsLogarithmic())
+            out << "Log";
+        if (IsCosinic())
+            out << "Cos";
+        out << "(" << GetNumBins() << ", " << GetEdgeLo() << ", " << GetEdgeHi() << ");" << endl;
+        return;
+    }
+
+    out << "   {" << endl;
+    out << "      TArrayD dummy;" << endl;
+    for (int i=0; i<GetNumEdges(); i++)
+        out << "      dummy[" << i << "]=" << GetEdges()[i] << ";" << endl;
+    out << "      " << GetUniqueName() << ".SetEdges(dummy);" << endl;
+    out << "   }" << endl;
+}
Index: /tags/Mars_V0-8-5/Mars/mhbase/MBinning.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhbase/MBinning.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhbase/MBinning.h	(revision 9661)
@@ -0,0 +1,88 @@
+#ifndef MARS_MBinning
+#define MARS_MBinning
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#ifndef ROOT_TArrayD
+#include <TArrayD.h>
+#endif
+
+class TH1;
+class TAxis;
+
+class MBinning : public MParContainer
+{
+private:
+    TArrayD fEdges;
+
+    Byte_t  fType;
+
+    void StreamPrimitive(ofstream &out) const;
+
+    enum {
+        kIsDefault,
+        kIsLinear,
+        kIsLogarithmic,
+        kIsCosinic,
+        kIsUserArray
+    };
+
+public:
+    MBinning(const char *name=NULL, const char *title=NULL);
+    MBinning(Int_t nbins, Axis_t lo, Axis_t hi, const char *name, const char *opt="", const char *title=NULL);
+
+    void SetEdges(const TArrayD &arr)
+    {
+        fEdges = arr;
+        fType = kIsUserArray;
+    }
+
+    void SetEdges(const TAxis &axe);
+    void SetEdges(const TH1 &h, const Char_t axis='x');
+    void SetEdges(const Int_t nbins, const Axis_t lo, Axis_t up);
+    void SetEdges(const Int_t nbins, const Axis_t lo, Axis_t up, const char *opt);
+    void SetEdgesLog(const Int_t nbins, const Axis_t lo, Axis_t up);
+    void SetEdgesCos(const Int_t nbins, const Axis_t lo, Axis_t up);
+
+    Int_t FindLoEdge(Double_t val) const
+    {
+        if (val<GetEdgeLo() || val>=GetEdgeHi())
+            return -1;
+
+	for (int i=1; i<fEdges.GetSize(); i++)
+        {
+            if (((TArrayD)fEdges)[i] >= val)
+                return i-1;
+        }
+        return -1;
+    }
+    Int_t FindHiEdge(Double_t val) const
+    {
+        const Int_t i = FindLoEdge(val);
+        return i<0 ? -1 : i+1;
+    }
+
+    // FIXME: ROOT workaround: "operator[] const" missing
+    Double_t GetEdgeLo() const { return ((TArrayD)fEdges)[0]; }
+    Double_t GetEdgeHi() const { return ((TArrayD)fEdges)[fEdges.GetSize()-1]; }
+
+    Int_t GetNumEdges() const { return fEdges.GetSize(); }
+    Int_t GetNumBins() const { return fEdges.GetSize()-1; }
+
+    Double_t *GetEdges() const { return (Double_t*)fEdges.GetArray(); }
+
+    Bool_t IsLinear() const { return fType==kIsLinear; }
+    Bool_t IsLogarithmic() const { return fType==kIsLogarithmic; }
+    Bool_t IsCosinic() const { return fType==kIsCosinic; }
+    Bool_t IsDefault() const { return fType==kIsDefault; }
+    Bool_t IsUserArray() const { return fType==kIsUserArray; }
+
+    void Apply(TH1 &);
+
+    ClassDef(MBinning, 1) //Container to store the binning of a histogram
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mhbase/MFillH.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhbase/MFillH.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhbase/MFillH.cc	(revision 9661)
@@ -0,0 +1,618 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 07/2001 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  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.                                                //
+//                                                                          //
+// To use a weight for each event filled in a histogram call                //
+// SetWeight(). You can eithe use the name of a MWeight container stored    //
+// in the parameter list or a pointer to it as an argument.                 //
+//                                                                          //
+//                                                                          //
+//  WARNING:                                                                //
+//   Because MFillH is a generalized task to fill histograms it doesn't     //
+//   know about which branches from a file are necessary to fill the        //
+//   histograms. If you are reading data from a file which is directly      //
+//   filled into a histogram via MFillH, please call either                 //
+//   MReadTree::DisableAutoScheme() or enable the necessary branches by     //
+//   yourself, using MReadTree::EnableBranch()                              //
+//                                                                          //
+//   Checkout the Warning in MTaskList.                                     //
+//                                                                          //
+//  Input Containers:                                                       //
+//   A parameter container                                                  //
+//                                                                          //
+//  Output Containers:                                                      //
+//   A histogram container                                                  //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+#include "MFillH.h"
+
+#include <fstream>
+
+#include <TClass.h>
+#include <TCanvas.h>
+
+#include "MDataChain.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MH.h"
+#include "MHArray.h"
+
+#include "MWeight.h"
+
+#include "MParList.h"
+#include "MStatusDisplay.h"
+
+ClassImp(MFillH);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Initializes name and title of the object. It is called by all
+// constructors.
+//
+void MFillH::Init(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MFillH";
+    fTitle = title ? title : "Task to fill Mars histograms";
+
+    fH            = NULL;
+    fParContainer = NULL;
+
+    fIndex  = NULL;
+    fCanvas = NULL;
+
+    fWeight     = NULL;
+    fWeightName = "";
+}
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor. This is to support some root-stuff.
+// Never try to use it yourself!
+//
+MFillH::MFillH()
+{
+    Init(NULL, NULL);
+}
+
+// --------------------------------------------------------------------------
+//
+// Constructor.
+//
+// 1) - par is the name of the parameter container which should be filled into
+//      the histogram
+//    - hist is the name of the histogram container (which must have been
+//      derived from MH)
+//
+//    In this case MH::Fill is called with a pointer to the corresponding
+//    histogram instance.
+//
+// 2) - hist is the name and/or type of the histogram.
+//      1) The name and type is identical, eg: "MHHillas"
+//      2) They are not identical, eg: "MyHistogram [MHHillas]"
+//         This searches for a class instance of MHHillas with the name
+//         "MyHistogram". If it doesn't exist one is created.
+//
+//    In this case PreProcess calls MH::SetupFill with a pointer to the
+//    parameter list and MH::Fill is called with a NULL-pointer.
+//
+MFillH::MFillH(const char *hist, const char *par, const char *name, const char *title)
+{
+    Init(name, title);
+
+    fHName = hist;
+    fParContainerName = par;
+
+    AddToBranchList(Form("%s.*", (const char*)ExtractName(hist)));
+    if (par)
+        AddToBranchList(Form("%s.*", (const char*)ExtractName(par)));
+
+    if (title)
+        return;
+
+    fTitle = "Fill " + fHName;
+    if (fParContainerName.IsNull())
+        return;
+
+    fTitle += " from " + fParContainerName;
+}
+
+// --------------------------------------------------------------------------
+//
+// Constructor.
+//
+// 1) - par is a pointer to the instance of your parameter container from which
+//      the data should be used to fill the histogram.
+//    - hist is the name of the histogram container (which must have been
+//      derived from MH)
+//
+//    In this case MH::Fill is called with a pointer to the corresponding
+//    histogram instance.
+//
+// 2) - hist is the name and/or type of the histogram.
+//      1) The name and type is identical, eg: "MHHillas"
+//      2) They are not identical, eg: "MyHistogram [MHHillas]"
+//         This searches for a class instance of MHHillas with the name
+//         "MyHistogram". If it doesn't exist one is created. Everything
+//         which is between the first '[' and the last ']' in the string
+//         is used as the histogram type.
+//
+//    In this case PreProcess calls MH::SetupFill with a pointer to the
+//    parameter list and MH::Fill is called with a NULL-pointer.
+//
+//
+MFillH::MFillH(const char *hist, MParContainer *par, const char *name, const char *title)
+{
+    Init(name, title);
+
+    fHName = hist;
+    fParContainer = par;
+    fParContainerName = par->GetName();
+
+    AddToBranchList(Form("%s.*", (const char*)ExtractName(hist)));
+    AddToBranchList(Form("%s.*", par->GetName()));
+
+    if (!title)
+        fTitle = "Fill " + fHName + " from " + par->GetDescriptor();
+}
+
+// --------------------------------------------------------------------------
+//
+// Constructor.
+//
+// - par is a pointer to the instance of your parameter container from which
+//   the data should be used to fill the histogram.
+// - hist is a pointer to the instance of your histogram container (which must
+//   have been derived from MH) into which the data should flow
+//
+MFillH::MFillH(MH *hist, const char *par, const char *name, const char *title)
+{
+    Init(name, title);
+
+    fH = hist;
+    fHName = hist->GetName();
+    fParContainerName = par;
+
+    AddToBranchList(fH->GetDataMember());
+    if (par)
+        AddToBranchList(Form("%s.*", (const char*)ExtractName(par)));
+
+    if (title)
+        return;
+
+    fTitle = (TString)"Fill " + hist->GetDescriptor();
+    if (!par)
+        return;
+
+    fTitle += " from " + fParContainerName;
+}
+
+// --------------------------------------------------------------------------
+//
+// Constructor.
+//
+// - par is a pointer to the instance of your parameter container from which
+//   the data should be used to fill the histogram.
+// - hist is the name of the histogram container (which must have been
+//   derived from MH)
+//
+MFillH::MFillH(MH *hist, MParContainer *par, const char *name, const char *title)
+{
+    Init(name, title);
+
+    fH = hist;
+    fHName = hist->GetName();
+    fParContainer = par;
+    fParContainerName = par->GetName();
+
+    AddToBranchList(fH->GetDataMember());
+    AddToBranchList(Form("%s.*", par->GetName()));
+
+    if (!title)
+        fTitle = (TString)"Fill " + hist->GetDescriptor() + " from " + par->GetDescriptor();
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor. Delete fData if existing and kCanDelete is set.
+//
+MFillH::~MFillH()
+{
+    if (fIndex)
+        if (fIndex->TestBit(kCanDelete))
+            delete fIndex;
+}
+
+// --------------------------------------------------------------------------
+//
+// If the histogram to be filles is a MHArray you can specify a 'rule'
+// This rule is used to create an MDataChain. The return value of the chain
+// is casted to int. Each int acts as a key. For each (new) key a new
+// histogram is created in the array. (eg for the rule
+// "MRawEvtHeader::fRunNumber" you would get one histogram per run-number)
+//
+void MFillH::SetRuleForIdx(const TString rule)
+{
+    fIndex = new MDataChain(rule);
+    fIndex->SetBit(kCanDelete);
+}
+
+// --------------------------------------------------------------------------
+//
+// If the histogram to be filles is a MHArray you can specify a MData-object
+// The return value of the object is casted to int. Each int acts as a key.
+// For each (new) key a new histogram is created in the array. (eg for
+// MDataMember("MRawEvtHeader::fRunNumber") you would get one histogram per
+// run-number)
+//
+void MFillH::SetRuleForIdx(MData *data)
+{
+    fIndex = data;
+}
+
+// --------------------------------------------------------------------------
+//
+// Extracts the name of the histogram from the MFillH argument
+//
+TString MFillH::ExtractName(const char *name) const
+{
+    TString type = name;
+
+    const Ssiz_t first = type.First('[');
+    const Ssiz_t last  = type.First(']');
+
+    if (!first || !last || first>=last)
+        return type;
+
+    return type.Remove(first).Strip(TString::kBoth);
+}
+
+// --------------------------------------------------------------------------
+//
+// Extracts the class-name of the histogram from the MFillH argument
+//
+TString MFillH::ExtractClass(const char *name) const
+{
+    TString type = name;
+
+    const Ssiz_t first = type.First('[');
+    const Ssiz_t last  = type.First(']');
+
+    if (!first || !last || first>=last)
+        return type;
+
+    const Ssiz_t length = last-first-1;
+
+    TString strip = fHName(first+1, length);
+    return strip.Strip(TString::kBoth);
+}
+
+// --------------------------------------------------------------------------
+//
+// Use this to set a draw option used when drawing automatically to the
+// status display.
+//
+void MFillH::SetDrawOption(Option_t *option)
+{
+    fDrawOption = option;
+}
+
+// --------------------------------------------------------------------------
+//
+// Creates a new tab in a status display with the name of the MH class,
+// if fDisplay is set and the MH-class overwrites the Draw function
+//
+Bool_t MFillH::DrawToDisplay()
+{
+    fCanvas = NULL;
+
+    if (!fDisplay)
+        return kTRUE;
+
+    if (!fH->OverwritesDraw())
+        return kTRUE;
+
+    if (TestBit(kDoNotDisplay))
+        return kTRUE;
+
+    fCanvas = &fDisplay->AddTab(fNameTab.IsNull() ? fH->GetName() : fNameTab.Data());
+    fH->Draw(fDrawOption);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// 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.
+//
+Int_t MFillH::PreProcess(MParList *pList)
+{
+    if (fIndex)
+    {
+        if (!fIndex->PreProcess(pList))
+        {
+            *fLog << all << "PreProcessing of Index rule failed... aborting." << endl;
+            return kFALSE;
+        }
+
+        if (!fIndex->IsValid())
+        {
+            *fLog << all << "Given Index rule invalid... aborting." << endl;
+            return kFALSE;
+        }
+    }
+
+    //
+    // If the user defined the use of a weight: search for it.
+    //
+    if (!fWeight && !fWeightName.IsNull())
+    {
+        fWeight = (MWeight*)pList->FindObject(fWeightName, "MWeight");
+
+	if (!fWeight)
+        {
+            *fLog << err << fWeightName << " [MWeight] not found... aborting." << endl;
+            return kFALSE;
+        }
+    }
+
+    //
+    // Try to get the histogram container with name fHName from list
+    // or create one with this name
+    //
+    if (!fH)
+    {
+        const TString cls  = ExtractClass(fHName);
+        const TString name = ExtractName(fHName);
+
+        TObject *obj=NULL;
+        if (cls==name)
+            obj = pList->FindObject(fHName);
+
+        if (!obj)
+        {
+            /*
+            if (cls==name)
+            *fLog << inf << "Object '" << fHName << "' not found in parlist... creating." << endl;
+            */
+            obj = pList->FindCreateObj(cls, name);
+        }
+
+        if (!obj)
+            return kFALSE;
+
+        //
+        // We were successfull getting it. Check whether it really inherits
+        // from MH, FindCreateObj does only check for inheritance from
+        // 'type'.
+        //
+        TClass *tcls = fIndex ? MHArray::Class() : MH::Class();
+        if (!obj->InheritsFrom(tcls))
+        {
+            *fLog << err << obj->GetName() << " doesn't inherit ";
+            *fLog << "from " << tcls->GetName() << " - cannot be used for MFillH...";
+            *fLog << "aborting." << endl;
+            return kFALSE;
+        }
+
+        fH = (MH*)obj;
+    }
+
+    //
+    // Now we have the histogram container available. Try to Setup Fill.
+    //
+    fH->SetSerialNumber(GetSerialNumber());
+    if (!fH->SetupFill(pList))
+    {
+        *fLog << (TestBit(kCanSkip) ? warn : err);
+        *fLog << (TestBit(kCanSkip) ? "WARNING" : "ERROR");
+        *fLog << " - Calling SetupFill for " << fH->GetDescriptor() << "...";
+        *fLog << (TestBit(kCanSkip) ? "skipped." : "aborting.") << endl;
+
+        return TestBit(kCanSkip) ? kSKIP : kFALSE;
+    }
+
+    //
+    // If also a parameter container is already set we are done.
+    //
+    if (fParContainer)
+        return DrawToDisplay();
+
+    //
+    // This case means, that the MH sets up its container to be filled
+    // by itself. Check there if it has something to be filled with!
+    //
+    if (fParContainerName.IsNull())
+    {
+        fParContainer = NULL;
+        return DrawToDisplay();
+    }
+
+    fParContainer = (MParContainer*)pList->FindObject(fParContainerName);
+    if (fParContainer)
+        return DrawToDisplay();
+
+    if (TestBit(kCanSkip))
+    {
+        *fLog << warn << fParContainerName << " [MParContainer] not found... skipped." << endl;
+        return kSKIP;
+    }
+
+    *fLog << err << fParContainerName << " [MParContainer] not found... aborting." << endl;
+    return kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Call the ReInit function of the contained Histogram
+//
+Bool_t MFillH::ReInit(MParList *pList)
+{
+    return fH->ReInit(pList);
+} 
+
+// --------------------------------------------------------------------------
+//
+// Fills the data from the parameter conatiner into the histogram container
+//
+Int_t MFillH::Process()
+{
+    if (fIndex)
+        ((MHArray*)fH)->SetIndexByKey(fIndex->GetValue());
+    /*
+     const Int_t key = (Int_t)fIndex->GetValue();
+     const Int_t idx = fMapIdx->Add(key);
+     ((MHArray*)fH)->SetIndex(idx);
+     */
+
+    TVirtualPad *save = gPad;
+    if (fCanvas)
+        fCanvas->cd();
+
+    const Bool_t rc = fH->Fill(fParContainer, fWeight?fWeight->GetWeight():1);
+
+    if (save && fCanvas)
+        save->cd();
+
+    return rc;
+} 
+
+// --------------------------------------------------------------------------
+//
+// Set the ReadyToSave flag of the histogram container, because now all data
+// has been filled into the histogram.
+//
+Int_t MFillH::PostProcess()
+{
+    //
+    // Now all data is in the histogram. Maybe some final action is
+    // necessary.
+    //
+    if (!fH->Finalize())
+    {
+        *fLog << err << "ERROR - Calling Finalize for ";
+        *fLog << fH->GetDescriptor() << "... aborting." << endl;
+        return kFALSE;
+    }
+
+    fH->SetReadyToSave();
+
+    //
+    // Check whether fDisplay has previously been used (fCanvas),
+    // fDisplay is still open and the corresponding Canvas/Tab is
+    // still existing.
+    //
+    if (fDisplay && fDisplay->HasCanvas(fCanvas))
+    {
+        const TString opt(Form("nonew %s", fDrawOption.Data()));
+        fCanvas->cd();
+        fH->DrawClone(opt);
+        fCanvas->Modified();
+        fCanvas->Update();
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
+void MFillH::StreamPrimitive(ofstream &out) const
+{
+    if (fH)
+        fH->SavePrimitive(out);
+
+    if (fParContainer)
+        fParContainer->SavePrimitive(out);
+
+    if (fWeight)
+        fWeight->SavePrimitive(out);
+
+    out << "   MFillH " << GetUniqueName() << "(";
+
+    if (fH)
+        out << "&" << fH->GetUniqueName();
+    else
+        out << "\"" << fHName << "\"";
+
+    if (fParContainer)
+        out << ", &" << fParContainer->GetUniqueName();
+    else
+        if (!fParContainerName.IsNull())
+            out << ", \"" << fParContainerName << "\"";
+
+    out << ");" << endl;
+
+    if (fWeight || !fWeightName.IsNull())
+    {
+        out << "   " << GetUniqueName() << ".SetWeight(";
+        if (fWeight)
+            out << "&" << fWeight->GetUniqueName() << ");" << endl;
+        else
+            if (!fWeightName.IsNull())
+                out << "\"" << fWeightName << "\");" << endl;
+    }
+
+    if (fIndex)
+    {
+        out << "   " << GetUniqueName() << ".SetRuleForIdx(\"";
+        out << fIndex->GetRule() << "\");" << endl;
+    }
+}
Index: /tags/Mars_V0-8-5/Mars/mhbase/MFillH.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhbase/MFillH.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhbase/MFillH.h	(revision 9661)
@@ -0,0 +1,81 @@
+#ifndef MARS_MFillH
+#define MARS_MFillH
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MH;
+class MMap;
+class MData;
+class MWeight;
+class MParList;
+
+class TCanvas;
+
+class MFillH : public MTask
+{
+public:
+    enum {
+        kDoNotDisplay = BIT(17),
+        kCanSkip      = BIT(18)
+    };
+
+private:
+    MParContainer *fParContainer; // Pointer to the data container storing
+    TString fParContainerName;    // Name to a data container
+
+    MH* fH;                       // Pointer to the MH container to get filled
+    TString fHName;               // Name to a MH container to get filled
+    TString fNameTab;
+
+    MWeight *fWeight;             // Pointer to the container storing a weight
+    TString fWeightName;          // Name of a container storing a weight
+
+    MData *fIndex;                // MData object describing the 'key' to an automatic index for an MHArray
+    MMap  *fMapIdx;               //! Map to map key-index-pair for an MHArray (MMap see MFillH.cc)
+
+    TCanvas *fCanvas;             //! Canvas used to update a MStatusDisplay at the end of a loop
+
+    TString fDrawOption;          // Draw option for status display
+
+    TString ExtractName(const char *name) const;
+    TString ExtractClass(const char *name) const;
+
+    void Init(const char *name, const char *title);
+
+    void StreamPrimitive(ofstream &out) const;
+
+    Bool_t DrawToDisplay();
+
+public:
+    MFillH();
+    MFillH(const char *hist, const char *par=NULL, const char *name=NULL, const char *title=NULL);
+    MFillH(const char *hist, MParContainer *par,   const char *name=NULL, const char *title=NULL);
+    MFillH(MH *hist,         const char *par=NULL, const char *name=NULL, const char *title=NULL);
+    MFillH(MH *hist,         MParContainer *par,   const char *name=NULL, const char *title=NULL);
+    ~MFillH();
+
+    void SetNameTab(const char *n="") { fNameTab = n; }
+
+    void SetRuleForIdx(const TString rule);
+    void SetRuleForIdx(MData *rule);
+
+    void SetWeight(MWeight *w)       { fWeight = w; }
+    void SetWeight(const char *name) { fWeightName = name; }
+
+    void      SetDrawOption(Option_t *option="");
+    Option_t *GetDrawOption() const { return fDrawOption; }
+
+    Int_t  PreProcess(MParList *pList);
+    Bool_t ReInit(MParList *pList);
+    Int_t  Process();
+    Int_t  PostProcess();
+
+    TCanvas *GetCanvas() { return fCanvas; }
+
+    ClassDef(MFillH, 2) // Task to fill a histogram with data from a parameter container
+};
+    
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mhbase/MH.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhbase/MH.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhbase/MH.cc	(revision 9661)
@@ -0,0 +1,1179 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  07/2001 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MH                                                                      //
+//                                                                          //
+//  This is a base tasks for mars histograms. It defines a common interface //
+//  for filling the histograms with events (MH::Fill) which is used by a    //
+//  common 'filler' And a SetupFill member function which may be used       //
+//  by MFillH. The idea is:                                                 //
+//   1) If your Histogram can become filled by one single container         //
+//      (like MHHillas) you overload MH::Fill and it gets called with       //
+//      a pointer to the container with which it should be filled.          //
+//                                                                          //
+//   2) You histogram needs several containers to get filled. Than you      //
+//      have to overload MH::SetupFill and get the necessary objects from   //
+//      the parameter list. Use this objects in Fill to fill your           //
+//      histogram.                                                          //
+//                                                                          //
+//  If you want to create your own histogram class the new class must be    //
+//  derived from MH (instead of the base MParContainer) and you must        //
+//  the fill function of MH. This is the function which is called to fill   //
+//  the histogram(s) by the data of a corresponding parameter container.    //
+//                                                                          //
+//  Remark: the static member function (eg MakeDefCanvas) can be called     //
+//          from everywhere using: MH::MakeDefCanvas(...)                   //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MH.h"
+
+#include <TH1.h>
+#include <TH2.h>
+#include <TH3.h>
+#include <TStyle.h>       // TStyle::GetScreenFactor
+#include <TGaxis.h>
+#include <TCanvas.h>
+#include <TLegend.h>
+#include <TPaveStats.h>
+#include <TBaseClass.h>
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,04,01)
+#include <THLimitsFinder.h>
+#endif
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MParContainer.h"
+
+#include "MBinning.h"
+
+ClassImp(MH);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor. It sets name and title only. Typically you won't
+// need to change this.
+//
+MH::MH(const char *name, const char *title)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MH";
+    fTitle = title ? title : "Base class for Mars histograms";
+}
+
+// --------------------------------------------------------------------------
+//
+// If you want to use the automatic filling of your derived class you
+// must overload this function. If it is not overloaded you cannot use
+// FillH with this class. The argument is a pointer to a container
+// in your paremeter list which is specified in the MFillH constructor.
+// If you are not going to use it you should at least add
+//   Bool_t MH::Fill(const MParContainer *) { return kTRUE; }
+// to your class definition.
+//
+Bool_t MH::Fill(const MParContainer *par, const Stat_t w)
+{
+    *fLog << warn << GetDescriptor() << ": Fill not overloaded! Can't be used!" << endl;
+    return kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+// This virtual function is ment as a generalized interface to retrieve
+// a pointer to a root histogram from the MH-derived class.
+//
+TH1 *MH::GetHistByName(const TString name)
+{
+    *fLog << warn << GetDescriptor() << ": GetHistByName not overloaded! Can't be used!" << endl;
+    return NULL;
+}
+
+// --------------------------------------------------------------------------
+//
+// This is a function which should replace the creation of default
+// canvases like root does. Because this is inconvinient in some aspects.
+// need to change this.
+// You can specify a name for the default canvas and a title. Also
+// width and height can be given.
+// MakeDefCanvas looks for a canvas with the given name. If now name is
+// given the DefCanvasName of root is used. If no such canvas is existing
+// it is created and returned. If such a canvas already exists a new canvas
+// with a name plus anumber is created (the number is calculated by the
+// number of all existing canvases plus one)
+//
+// Normally the canvas size is scaled with gStyle->GetScreenFactor() so
+// that on all screens it looks like the same part of the screen.
+// To suppress this scaling use usescreenfactor=kFALSE. In this case
+// you specify directly the size of the embedded pad.
+//
+TCanvas *MH::MakeDefCanvas(TString name, const char *title,
+                           UInt_t w, UInt_t h, Bool_t usescreenfactor)
+{
+    const TList *list = (TList*)gROOT->GetListOfCanvases();
+
+    if (name.IsNull())
+        name = gROOT->GetDefCanvasName();
+
+    if (list->FindObject(name))
+        name += Form(" <%d>", list->GetSize()+1);
+
+    if (!usescreenfactor)
+    {
+        const Float_t cx = gStyle->GetScreenFactor();
+        w += 4;
+        h += 28;
+        w = (int)(w/cx+1);
+        h = (int)(h/cx+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.
+//
+// Normally the canvas size is scaled with gStyle->GetScreenFactor() so
+// that on all screens it looks like the same part of the screen.
+// To suppress this scaling use usescreenfactor=kFALSE. In this case
+// you specify directly the size of the embedded pad.
+//
+TCanvas *MH::MakeDefCanvas(const TObject *obj,
+                           UInt_t w, UInt_t h, Bool_t usescreenfactor)
+{
+    if (!usescreenfactor)
+    {
+        const Float_t cx = gStyle->GetScreenFactor();
+        w += 4;
+        h += 28;
+        h = (int)(h/cx+1);
+        w = (int)(w/cx+1);
+    }
+
+    return MakeDefCanvas(obj->GetName(), obj->GetTitle(), w, h);
+}
+
+// --------------------------------------------------------------------------
+//
+// Applies a given binning to a 1D-histogram
+//
+void MH::SetBinning(TH1 *h, const MBinning *binsx)
+{
+    //
+    // Another strange behaviour: TAxis::Set deletes the axis title!
+    //
+    TAxis &x = *h->GetXaxis();
+
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,03,03)
+    TString xtitle = x.GetTitle();
+#endif
+
+    //
+    // This is a necessary workaround if one wants to set
+    // non-equidistant bins after the initialization
+    // TH1D::fNcells must be set correctly.
+    //
+    h->SetBins(binsx->GetNumBins(), 0, 1);
+
+    //
+    // Set the binning of the current histogram to the binning
+    // in one of the two given histograms
+    //
+    x.Set(binsx->GetNumBins(), binsx->GetEdges());
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,03,03)
+    x.SetTitle(xtitle);
+#endif
+}
+
+// --------------------------------------------------------------------------
+//
+// Applies given binnings to the two axis of a 2D-histogram
+//
+void MH::SetBinning(TH2 *h, const MBinning *binsx, const MBinning *binsy)
+{
+    TAxis &x = *h->GetXaxis();
+    TAxis &y = *h->GetYaxis();
+
+    //
+    // Another strange behaviour: TAxis::Set deletes the axis title!
+    //
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,03,03)
+    TString xtitle = x.GetTitle();
+    TString ytitle = y.GetTitle();
+#endif
+
+    //
+    // This is a necessary workaround if one wants to set
+    // non-equidistant bins after the initialization
+    // TH1D::fNcells must be set correctly.
+    //
+    h->SetBins(binsx->GetNumBins(), 0, 1,
+               binsy->GetNumBins(), 0, 1);
+
+    //
+    // Set the binning of the current histogram to the binning
+    // in one of the two given histograms
+    //
+    x.Set(binsx->GetNumBins(), binsx->GetEdges());
+    y.Set(binsy->GetNumBins(), binsy->GetEdges());
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,03,03)
+    x.SetTitle(xtitle);
+    y.SetTitle(ytitle);
+#endif
+}
+
+// --------------------------------------------------------------------------
+//
+// Applies given binnings to the three axis of a 3D-histogram
+//
+void MH::SetBinning(TH3 *h, const MBinning *binsx, const MBinning *binsy, const MBinning *binsz)
+{
+    //
+    // Another strange behaviour: TAxis::Set deletes the axis title!
+    //
+    TAxis &x = *h->GetXaxis();
+    TAxis &y = *h->GetYaxis();
+    TAxis &z = *h->GetZaxis();
+
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,03,03)
+    TString xtitle = x.GetTitle();
+    TString ytitle = y.GetTitle();
+    TString ztitle = z.GetTitle();
+#endif
+
+    //
+    // This is a necessary workaround if one wants to set
+    // non-equidistant bins after the initialization
+    // TH1D::fNcells must be set correctly.
+    //
+    h->SetBins(binsx->GetNumBins(), 0, 1,
+               binsy->GetNumBins(), 0, 1,
+               binsz->GetNumBins(), 0, 1);
+
+    //
+    // Set the binning of the current histogram to the binning
+    // in one of the two given histograms
+    //
+    x.Set(binsx->GetNumBins(), binsx->GetEdges());
+    y.Set(binsy->GetNumBins(), binsy->GetEdges());
+    z.Set(binsz->GetNumBins(), binsz->GetEdges());
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,03,03)
+    x.SetTitle(xtitle);
+    y.SetTitle(ytitle);
+    z.SetTitle(ztitle);
+#endif
+}
+
+// --------------------------------------------------------------------------
+//
+// Applies given binning (the n+1 edges)  to the axis of a 1D-histogram
+//
+void MH::SetBinning(TH1 *h, const TArrayD &binsx)
+{
+    MBinning bx;
+    bx.SetEdges(binsx);
+    SetBinning(h, &bx);
+}
+
+// --------------------------------------------------------------------------
+//
+// Applies given binning (the n+1 edges) to the two axis of a
+// 2D-histogram
+//
+void MH::SetBinning(TH2 *h, const TArrayD &binsx, const TArrayD &binsy)
+{
+    MBinning bx;
+    MBinning by;
+    bx.SetEdges(binsx);
+    by.SetEdges(binsy);
+    SetBinning(h, &bx, &by);
+}
+
+// --------------------------------------------------------------------------
+//
+// Applies given binning (the n+1 edges) to the three axis of a
+// 3D-histogram
+//
+void MH::SetBinning(TH3 *h, const TArrayD &binsx, const TArrayD &binsy, const TArrayD &binsz)
+{
+    MBinning bx;
+    MBinning by;
+    MBinning bz;
+    bx.SetEdges(binsx);
+    by.SetEdges(binsy);
+    bz.SetEdges(binsz);
+    SetBinning(h, &bx, &by, &bz);
+}
+
+// --------------------------------------------------------------------------
+//
+// Applies the binning of a TAxis (eg from a root histogram) to the axis
+// of a 1D-histogram
+//
+void MH::SetBinning(TH1 *h, const TAxis *binsx)
+{
+    const Int_t nx = binsx->GetNbins();
+
+    TArrayD bx(nx+1);
+    for (int i=0; i<nx; i++) bx[i] = binsx->GetBinLowEdge(i+1);
+    bx[nx] = binsx->GetXmax();
+
+    SetBinning(h, bx);
+}
+
+// --------------------------------------------------------------------------
+//
+// Applies the binnings of the TAxis' (eg from a root histogram) to the
+// two axis' of a 2D-histogram
+//
+void MH::SetBinning(TH2 *h, const TAxis *binsx, const TAxis *binsy)
+{
+    const Int_t nx = binsx->GetNbins();
+    const Int_t ny = binsy->GetNbins();
+
+    TArrayD bx(nx+1);
+    TArrayD by(ny+1);
+    for (int i=0; i<nx; i++) bx[i] = binsx->GetBinLowEdge(i+1);
+    for (int i=0; i<ny; i++) by[i] = binsy->GetBinLowEdge(i+1);
+    bx[nx] = binsx->GetXmax();
+    by[ny] = binsy->GetXmax();
+
+    SetBinning(h, bx, by);
+}
+
+// --------------------------------------------------------------------------
+//
+// Applies the binnings of the TAxis' (eg from a root histogram) to the
+// three axis' of a 3D-histogram
+//
+void MH::SetBinning(TH3 *h, const TAxis *binsx, const TAxis *binsy, const TAxis *binsz)
+{
+    const Int_t nx = binsx->GetNbins();
+    const Int_t ny = binsy->GetNbins();
+    const Int_t nz = binsz->GetNbins();
+
+    TArrayD bx(nx+1);
+    TArrayD by(ny+1);
+    TArrayD bz(nz+1);
+    for (int i=0; i<nx; i++) bx[i] = binsx->GetBinLowEdge(i+1);
+    for (int i=0; i<ny; i++) by[i] = binsy->GetBinLowEdge(i+1);
+    for (int i=0; i<nz; i++) bz[i] = binsz->GetBinLowEdge(i+1);
+    bx[nx] = binsx->GetXmax();
+    by[ny] = binsy->GetXmax();
+    bz[nz] = binsz->GetXmax();
+
+    SetBinning(h, bx, by, bz);
+}
+
+// --------------------------------------------------------------------------
+//
+// Applies the binnings of one root-histogram x to another one h
+// Both histograms must be of the same type: TH1, TH2 or TH3
+//
+void MH::SetBinning(TH1 *h, const TH1 *x)
+{
+    if (h->InheritsFrom(TH3::Class()) && x->InheritsFrom(TH3::Class()))
+    {
+        SetBinning((TH3*)h, ((TH1*)x)->GetXaxis(), ((TH1*)x)->GetYaxis(), ((TH1*)x)->GetZaxis());
+        return;
+    }
+    if (h->InheritsFrom(TH3::Class()) || x->InheritsFrom(TH3::Class()))
+        return;
+    if (h->InheritsFrom(TH2::Class()) && x->InheritsFrom(TH2::Class()))
+    {
+        SetBinning((TH2*)h, ((TH1*)x)->GetXaxis(), ((TH1*)x)->GetYaxis());
+        return;
+    }
+    if (h->InheritsFrom(TH2::Class()) || x->InheritsFrom(TH2::Class()))
+        return;
+    if (h->InheritsFrom(TH1::Class()) && x->InheritsFrom(TH1::Class()))
+    {
+        SetBinning(h, ((TH1*)x)->GetXaxis());
+        return;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Multiplies all entries in a TArrayD by a float f
+//
+void MH::ScaleArray(TArrayD &bins, Double_t f)
+{
+    for (int i=0; i<bins.GetSize(); i++)
+        bins[i] *= f;
+}
+
+// --------------------------------------------------------------------------
+//
+// Scales the binning of a TAxis by a float f
+//
+TArrayD MH::ScaleAxis(TAxis &axe, Double_t f)
+{
+    TArrayD arr(axe.GetNbins()+1);
+
+    for (int i=1; i<=axe.GetNbins()+1; i++)
+        arr[i-1] = axe.GetBinLowEdge(i);
+
+    ScaleArray(arr, f);
+
+    return arr;
+}
+
+// --------------------------------------------------------------------------
+//
+// Scales the binning of one, two or three axis of a histogram by a float f
+//
+void MH::ScaleAxis(TH1 *h, Double_t fx, Double_t fy, Double_t fz)
+{
+    if (h->InheritsFrom(TH3::Class()))
+    {
+        SetBinning((TH3*)h,
+                   ScaleAxis(*h->GetXaxis(), fx),
+                   ScaleAxis(*h->GetYaxis(), fy),
+                   ScaleAxis(*h->GetZaxis(), fz));
+        return;
+    }
+
+    if (h->InheritsFrom(TH2::Class()))
+    {
+        SetBinning((TH2*)h,
+                   ScaleAxis(*h->GetXaxis(), fx),
+                   ScaleAxis(*h->GetYaxis(), fy));
+        return;
+    }
+
+    if (h->InheritsFrom(TH1::Class()))
+        SetBinning(h, ScaleAxis(*h->GetXaxis(), fx));
+}
+
+// --------------------------------------------------------------------------
+//
+// Tries to find a MBinning container with the name "Binning"+name
+// in the given parameter list. If it was found it is applied to the
+// given histogram. This is only valid for 1D-histograms
+//
+Bool_t MH::ApplyBinning(const MParList &plist, TString name, TH1 *h)
+{
+    if (h->InheritsFrom(TH2::Class()) || h->InheritsFrom(TH3::Class()))
+    {
+        gLog << warn << "MH::ApplyBinning: '" << h->GetName() << "' is not a basic TH1 object... no binning applied." << endl;
+        return kFALSE;
+    }
+
+    const MBinning *bins = (MBinning*)plist.FindObject("Binning"+name);
+    if (!bins)
+    {
+        gLog << inf << "Object 'Binning" << name << "' [MBinning] not found... no binning applied." << endl;
+        return kFALSE;
+    }
+
+    SetBinning(h, bins);
+    return kTRUE;
+}
+
+void MH::FindGoodLimits(Int_t nbins, Int_t &newbins, Double_t &xmin, Double_t &xmax, Bool_t isInteger)
+{
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,04,01)
+    THLimitsFinder::OptimizeLimits(nbins, newbins, xmin, xmax, isInteger);
+#else
+//*-*-*-*-*-*-*-*-*Find reasonable bin values*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
+//*-*              ==========================
+
+    Double_t dx = 0.1*(xmax-xmin);
+    Double_t umin = xmin - dx;
+    Double_t umax = xmax + dx;
+
+    if (umin < 0 && xmin >= 0)
+        umin = 0;
+
+    if (umax > 0 && xmax <= 0)
+        umax = 0;
+
+    Double_t binlow  =0;
+    Double_t binhigh =0;
+    Double_t binwidth=0;
+
+    TGaxis::Optimize(umin, umax, nbins, binlow, binhigh, nbins, binwidth, "");
+
+    if (binwidth <= 0 || binwidth > 1.e+39)
+    {
+        xmin = -1;
+        xmax = 1;
+    }
+    else
+    {
+        xmin = binlow;
+        xmax = binhigh;
+    }
+
+    if (isInteger)
+    {
+        Int_t ixmin = (Int_t)xmin;
+        Int_t ixmax = (Int_t)xmax;
+        Double_t dxmin = (Double_t)ixmin;
+        Double_t dxmax = (Double_t)ixmax;
+
+        xmin = xmin<0 && xmin!=dxmin ? dxmin - 1 : dxmin;
+        xmax = xmax>0 && xmax!=dxmax ? dxmax + 1 : dxmax;
+
+        if (xmin>=xmax)
+            xmax = xmin+1;
+
+        Int_t bw = 1 + (Int_t)((xmax-xmin)/nbins);
+
+        nbins = (Int_t)((xmax-xmin)/bw);
+
+        if (xmin+nbins*bw < xmax)
+        {
+            nbins++;
+            xmax = xmin +nbins*bw;
+        }
+    }
+
+    newbins = nbins;
+#endif
+}
+
+// --------------------------------------------------------------------------
+//
+//  Returns the lowest entry in a histogram which is greater than gt (eg >0)
+//
+Double_t MH::GetMinimumGT(const TH1 &h, Double_t gt)
+{
+    Double_t min = FLT_MAX;
+
+    const TAxis &axex = *((TH1&)h).GetXaxis();
+    const TAxis &axey = *((TH1&)h).GetYaxis();
+    const TAxis &axez = *((TH1&)h).GetZaxis();
+
+    for (int iz=1; iz<=axez.GetNbins(); iz++)
+        for (int iy=1; iy<=axey.GetNbins(); iy++)
+            for (int ix=1; ix<=axex.GetNbins(); ix++)
+            {
+                const Double_t v = h.GetBinContent(h.GetBin(ix, iy, iz));
+                if (gt<v && v<min)
+                    min = v;
+            }
+    return min;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Returns the bin center in a logarithmic scale. If the given bin
+//  number is <1 it is set to 1. If it is =GetNbins() it is set to
+//  GetNbins()
+//
+Double_t MH::GetBinCenterLog(const TAxis &axe, Int_t nbin)
+{
+    if (nbin>axe.GetNbins())
+        nbin = axe.GetNbins();
+
+    if (nbin<1)
+        nbin = 1;
+
+    const Double_t lo = axe.GetBinLowEdge(nbin);
+    const Double_t hi = axe.GetBinUpEdge(nbin);
+
+    const Double_t val = log10(lo) + log10(hi);
+
+    return pow(10, val/2);
+}
+
+// --------------------------------------------------------------------------
+//
+// Draws a copy of the two given histograms. Uses title as the pad title.
+// Also layout the two statistic boxes and a legend.
+//
+void MH::DrawSameCopy(const TH1 &hist1, const TH1 &hist2, const TString title)
+{
+    //
+    // Draw first histogram
+    //
+    TH1 *h1 = ((TH1&)hist1).DrawCopy();
+    gPad->SetBorderMode(0);
+    gPad->Update();
+
+    // FIXME: Also align max/min with set Maximum/Minimum
+    const Double_t maxbin1 = hist1.GetBinContent(hist1.GetMaximumBin());
+    const Double_t maxbin2 = hist2.GetBinContent(hist2.GetMaximumBin());
+    const Double_t minbin1 = hist1.GetBinContent(hist1.GetMinimumBin());
+    const Double_t minbin2 = hist2.GetBinContent(hist2.GetMinimumBin());
+
+    const Double_t max = TMath::Max(maxbin1, maxbin2);
+    const Double_t min = TMath::Min(minbin1, minbin2);
+
+    h1->SetMaximum(max>0?max*1.05:max*0.95);
+    h1->SetMinimum(max>0?min*0.95:min*1.05);
+
+    TPaveText *t = (TPaveText*)gPad->FindObject("title");
+    if (t)
+    {
+        t->SetName((TString)"MHTitle");     // rename object
+        t->Clear();                         // clear old lines
+        t->AddText((TString)" "+title+" "); // add the new title
+        t->SetBit(kCanDelete);              // make sure object is deleted
+
+        //
+        // FIXME: This is a stupid workaround to hide the redrawn
+        // (see THistPainter::PaintTitle) title
+        //
+        gPad->Modified();  // indicates a change
+        gPad->Update();    // recreates the original title
+        t->Pop();          // bring our title on top
+    }
+
+    //
+    // Rename first statistics box
+    //
+    TPaveStats *s1 = (TPaveStats*)gPad->FindObject("stats");
+    if (!s1)
+        s1 = (TPaveStats*)hist1.GetListOfFunctions()->FindObject("stats");
+    else
+        s1->SetName((TString)"Stat"+hist1.GetTitle());
+
+    if (s1 && s1->GetX2NDC()>0.95)
+    {
+        const Double_t x1 = s1->GetX1NDC()-0.01;
+        s1->SetX1NDC(x1-(s1->GetX2NDC()-s1->GetX1NDC()));
+        s1->SetX2NDC(x1);
+    }
+
+    //
+    // Draw second histogram
+    //
+    TH1 *h2 = ((TH1&)hist2).DrawCopy("sames");
+    gPad->Update();
+
+    //
+    // Draw Legend
+    //
+    TPaveStats *s2 = (TPaveStats*)gPad->FindObject("stats");
+    if (!s2)
+        s2 = (TPaveStats*)hist2.GetListOfFunctions()->FindObject("stats");
+
+    if (s2)
+    {
+        TLegend &l = *new TLegend(s2->GetX1NDC(),
+                                  s2->GetY1NDC()-0.015-(s2->GetY2NDC()-s2->GetY1NDC())/2,
+                                  s2->GetX2NDC(),
+                                  s2->GetY1NDC()-0.01
+                                 );
+        l.AddEntry(h1, h1->GetTitle());
+        l.AddEntry(h2, h2->GetTitle());
+        l.SetTextSize(s2->GetTextSize());
+        l.SetTextFont(s2->GetTextFont());
+        l.SetBorderSize(s2->GetBorderSize());
+        l.SetBit(kCanDelete);
+        l.Draw();
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Draws the two given histograms. Uses title as the pad title.
+// Also layout the two statistic boxes and a legend.
+//
+void MH::DrawSame(TH1 &hist1, TH1 &hist2, const TString title)
+{
+    //
+    // Draw first histogram
+    //
+    hist1.Draw();
+    gPad->SetBorderMode(0);
+    gPad->Update();
+
+    if (hist1.GetEntries()>0 && hist2.GetEntries()>0)
+    {
+        const Double_t maxbin1 = hist1.GetBinContent(hist1.GetMaximumBin());
+        const Double_t maxbin2 = hist2.GetBinContent(hist2.GetMaximumBin());
+        const Double_t minbin1 = hist1.GetBinContent(hist1.GetMinimumBin());
+        const Double_t minbin2 = hist2.GetBinContent(hist2.GetMinimumBin());
+
+        const Double_t max = TMath::Max(maxbin1, maxbin2);
+        const Double_t min = TMath::Min(minbin1, minbin2);
+
+        if (max!=min)
+        {
+            hist1.SetMaximum(max>0?max*1.05:max*0.95);
+            hist1.SetMinimum(max>0?min*0.95:min*1.05);
+        }
+    }
+
+    TPaveText *t = (TPaveText*)gPad->FindObject("title");
+    if (t)
+    {
+        t->SetName((TString)"MHTitle");     // rename object
+        t->Clear();                         // clear old lines
+        t->AddText((TString)" "+title+" "); // add the new title
+        t->SetBit(kCanDelete);              // make sure object is deleted
+
+        //
+        // FIXME: This is a stupid workaround to hide the redrawn
+        // (see THistPainter::PaintTitle) title
+        //
+        gPad->Modified();  // indicates a change
+        gPad->Update();    // recreates the original title
+        t->Pop();          // bring our title on top
+    }
+
+    //
+    // Rename first statistics box
+    //
+    // Where to get the TPaveStats depends on the root version
+    TPaveStats *s1 = (TPaveStats*)gPad->FindObject("stats");
+    if (!s1)
+        s1 = (TPaveStats*)hist1.GetListOfFunctions()->FindObject("stats");
+    else
+        s1->SetName((TString)"Stat"+hist1.GetTitle());
+
+    if (s1 && s1->GetX2NDC()>0.95)
+    {
+        const Double_t x1 = s1->GetX1NDC()-0.01;
+        s1->SetX1NDC(x1-(s1->GetX2NDC()-s1->GetX1NDC()));
+        s1->SetX2NDC(x1);
+    }
+
+    //
+    // Draw second histogram
+    //
+    hist2.Draw("sames");
+    gPad->Update();
+
+    //
+    // Draw Legend
+    //
+    // Where to get the TPaveStats depends on the root version
+    TPaveStats *s2 = (TPaveStats*)gPad->FindObject("stats");
+    if (!s2)
+        s2 = (TPaveStats*)hist2.GetListOfFunctions()->FindObject("stats");
+
+    if (s2)
+    {
+        TLegend &l = *new TLegend(s2->GetX1NDC(),
+                                  s2->GetY1NDC()-0.015-(s2->GetY2NDC()-s2->GetY1NDC())/2,
+                                  s2->GetX2NDC(),
+                                  s2->GetY1NDC()-0.01
+                                 );
+        l.AddEntry(&hist1, hist1.GetTitle());
+        l.AddEntry(&hist2, hist2.GetTitle());
+        l.SetTextSize(s2->GetTextSize());
+        l.SetTextFont(s2->GetTextFont());
+        l.SetBorderSize(s2->GetBorderSize());
+        l.SetBit(kCanDelete);
+        l.Draw();
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// If the opt string contains 'nonew' or gPad is not given NULL is returned.
+// Otherwise the present gPad is returned.
+//
+TVirtualPad *MH::GetNewPad(TString &opt)
+{
+    opt.ToLower();
+
+    if (!opt.Contains("nonew"))
+        return NULL;
+
+    opt.ReplaceAll("nonew", "");
+
+    return gPad;
+}
+
+// --------------------------------------------------------------------------
+//
+// Encapsulate the TObject::Clone such, that a cloned TH1 (or derived)
+// object is not added to the current directory, when cloned.
+//
+TObject *MH::Clone(const char *name) const
+{
+    const Bool_t store = TH1::AddDirectoryStatus();
+
+    TH1::AddDirectory(kFALSE);
+    TObject *o = MParContainer::Clone(name);
+    TH1::AddDirectory(store);
+
+    return o;
+}
+
+// --------------------------------------------------------------------------
+//
+// If the opt string contains 'nonew' or gPad is not given a new canvas
+// with size w/h is created. Otherwise the object is cloned and drawn
+// to the present pad. The kCanDelete bit is set for the clone.
+//
+TObject *MH::DrawClone(Option_t *opt, Int_t w, Int_t h) const
+{
+    TString option(opt);
+
+    TVirtualPad *p = GetNewPad(option);
+    if (!p)
+        p = MakeDefCanvas(this, w, h);
+    else
+        if (!option.Contains("same", TString::kIgnoreCase))
+            p->Clear();
+
+    gROOT->SetSelectedPad(NULL);
+
+    TObject *o = MParContainer::DrawClone(option);
+    o->SetBit(kCanDelete);
+    return o;
+}
+
+// --------------------------------------------------------------------------
+//
+// Check whether a class inheriting from MH overwrites the Draw function
+//
+Bool_t MH::OverwritesDraw(TClass *cls) const
+{
+    if (!cls)
+        cls = IsA();
+
+    //
+    // Check whether we reached the base class MTask
+    //
+    if (TString(cls->GetName())=="MH")
+        return kFALSE;
+
+    //
+    // Check whether the class cls overwrites Draw
+    //
+    if (cls->GetMethodAny("Draw"))
+        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 (OverwritesDraw(base->GetClassPointer()))
+            return kTRUE;
+    }
+
+    return kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Cuts the bins containing only zeros at the edges.
+//
+//  A new number of bins can be defined with nbins != 0
+//        In the case of nbins == 0, no rebinning will take place
+//
+//  Returns the new (real) number of bins
+//
+Int_t MH::StripZeros(TH1 *h, Int_t nbins)
+{
+    TAxis &axe = *h->GetXaxis();
+
+    const Int_t min1   = axe.GetFirst();
+    const Int_t max1   = axe.GetLast();
+    const Int_t range1 = max1-min1;
+
+    //
+    // Check for useless zeros
+    //
+    if (range1 == 0)
+        return 0;
+
+    Int_t min2 = 0;
+    for (int i=min1; i<=max1; i++)
+        if (h->GetBinContent(i) != 0)
+        {
+            min2 = i;
+            break;
+        }
+
+    //
+    // If the histogram consists of zeros only
+    //
+    if (min2 == max1)
+        return 0;
+
+    Int_t max2 = 0;
+    for (int i=max1; i>=min2; i--)
+        if (h->GetBinContent(i) != 0)
+        {
+            max2 = i;
+            break;
+        }
+
+    //
+    // Appying TAxis->SetRange before ReBin does not work ...
+    // But this workaround helps quite fine
+    //
+    Axis_t min = h->GetBinLowEdge(min2);
+    Axis_t max = h->GetBinLowEdge(max2)+h->GetBinWidth(max2);
+
+    Int_t nbins2 = max2-min2;
+    //
+    // Check for rebinning
+    //
+    if (nbins > 0)
+      {
+        const Int_t ngroup = (Int_t)(nbins2*h->GetNbinsX()/nbins/(max1-min1));
+        if (ngroup > 1)
+          {
+            h->Rebin(ngroup);
+            nbins2 /= ngroup;
+          }
+      }
+    
+    Int_t newbins = 0;
+    FindGoodLimits(nbins2, newbins, min, max, kFALSE);
+    axe.SetRangeUser(min,max);
+    return axe.GetLast()-axe.GetFirst();
+}
+
+void MH::ProjectionX(TH1D &dest, const TH2 &src, Int_t firstybin, Int_t lastybin)
+{
+    //*-*-*-*-*Project a 2-D histogram into a 1-D histogram along X*-*-*-*-*-*-*
+    //*-*      ====================================================
+    //
+    //   The projection dest is always of the type TH1D.
+    //   The projection is made from the channels along the Y axis
+    //   ranging from firstybin to lastybin included.
+    //   By default, bins 1 to ny are included
+    //   When all bins are included, the number of entries in the projection
+    //   is set to the number of entries of the 2-D histogram, otherwise
+    //   the number of entries is incremented by 1 for all non empty cells.
+    //
+    //   if Sumw2() was called for dest, the errors are computed.
+    //
+    TAxis &axex = *((TH2&)src).GetXaxis();
+    TAxis &axey = *((TH2&)src).GetYaxis();
+
+    const Int_t nx = axex.GetNbins();
+    const Int_t ny = axey.GetNbins();
+    if (firstybin < 0)
+        firstybin = 1;
+    if (lastybin > ny)
+        lastybin = ny;
+
+    dest.Reset();
+    SetBinning(&dest, &axex);
+
+    // Create the projection histogram
+    const Bool_t computeErrors = dest.GetSumw2N() ? 1 : 0;
+
+    // Fill the projected histogram
+    for (Int_t binx=0; binx<=nx+1; binx++)
+    {
+        Double_t err2 = 0;
+        for (Int_t biny=firstybin; biny<=lastybin; biny++)
+        {
+            const Double_t cont = src.GetCellContent(binx,biny);
+            const Double_t err1 = src.GetCellError(binx,biny);
+            err2 += err1*err1;
+            if (cont)
+                dest.Fill(axex.GetBinCenter(binx), cont);
+        }
+        if (computeErrors)
+            dest.SetBinError(binx, TMath::Sqrt(err2));
+    }
+    if (firstybin <=1 && lastybin >= ny)
+        dest.SetEntries(src.GetEntries());
+}
+
+void MH::ProjectionY(TH1D &dest, const TH2 &src, Int_t firstxbin, Int_t lastxbin)
+{
+    //*-*-*-*-*Project a 2-D histogram into a 1-D histogram along X*-*-*-*-*-*-*
+    //*-*      ====================================================
+    //
+    //   The projection dest is always of the type TH1D.
+    //   The projection is made from the channels along the Y axis
+    //   ranging from firstybin to lastybin included.
+    //   By default, bins 1 to ny are included
+    //   When all bins are included, the number of entries in the projection
+    //   is set to the number of entries of the 2-D histogram, otherwise
+    //   the number of entries is incremented by 1 for all non empty cells.
+    //
+    //   if Sumw2() was called for dest, the errors are computed.
+    //
+    TAxis &axex = *((TH2&)src).GetXaxis();
+    TAxis &axey = *((TH2&)src).GetYaxis();
+
+    const Int_t nx = axex.GetNbins();
+    const Int_t ny = axey.GetNbins();
+    if (firstxbin < 0)
+        firstxbin = 1;
+    if (lastxbin > nx)
+        lastxbin = nx;
+
+    dest.Reset();
+    SetBinning(&dest, &axey);
+
+    // Create the projection histogram
+    const Bool_t computeErrors = dest.GetSumw2N() ? 1 : 0;
+
+    // Fill the projected histogram
+    for (Int_t biny=0; biny<=ny+1; biny++)
+    {
+        Double_t err2 = 0;
+        for (Int_t binx=firstxbin; binx<=lastxbin; binx++)
+        {
+            const Double_t cont = src.GetCellContent(binx,biny);
+            const Double_t err1 = src.GetCellError(binx,biny);
+            err2 += err1*err1;
+            if (cont)
+                dest.Fill(axey.GetBinCenter(biny), cont);
+        }
+        if (computeErrors)
+            dest.SetBinError(biny, TMath::Sqrt(err2));
+    }
+    if (firstxbin <=1 && lastxbin >= nx)
+        dest.SetEntries(src.GetEntries());
+}
+
+// --------------------------------------------------------------------------
+//
+// In contradiction to TPad::FindObject this function searches recursively
+// in a pad for an object. gPad is the default.
+//
+TObject *MH::FindObjectInPad(const char *name, TVirtualPad *pad)
+{
+    if (!pad)
+        pad = gPad;
+
+    if (!pad)
+        return NULL;
+
+    TObject *o;
+
+    TIter Next(pad->GetListOfPrimitives());
+    while ((o=Next()))
+    {
+        if (!strcmp(o->GetName(), name))
+            return o;
+
+        if (o->InheritsFrom("TPad"))
+            if ((o = FindObjectInPad(name, (TVirtualPad*)o)))
+                return o;
+    }
+    return NULL;
+}
+
+// --------------------------------------------------------------------------
+//
+// M.Gaug added this withouz Documentation
+//
+TH1I* MH::ProjectArray(const TArrayF &array, Int_t nbins, const char* name, const char* title)
+{
+    const Int_t size = array.GetSize();
+
+    TH1I *h1=0;
+
+    //check if histogram with identical name exist
+    TObject *h1obj = gROOT->FindObject(name);
+    if (h1obj && h1obj->InheritsFrom("TH1I"))
+    {
+        h1 = (TH1I*)h1obj;
+        h1->Reset();
+    }
+
+    Double_t min = size>0 ? array[0] : 0;
+    Double_t max = size>0 ? array[0] : 1;
+
+    // first loop over array to find the min and max
+    for (Int_t i=1; i<size;i++)
+    {
+        max = TMath::Max((Double_t)array[i], max);
+        min = TMath::Min((Double_t)array[i], min);
+    }
+
+    Int_t newbins = 0;
+    FindGoodLimits(nbins, newbins, min, max, kFALSE);
+
+    if (!h1)
+    {
+        h1 = new TH1I(name, title, nbins, min, max);
+        h1->SetXTitle("");
+        h1->SetYTitle("Counts");
+        h1->SetDirectory(gROOT);
+    }
+
+    // Second loop to fill the histogram
+    for (Int_t i=0;i<size;i++)
+        h1->Fill(array[i]);
+
+    return h1;
+}
+
+// --------------------------------------------------------------------------
+//
+// M.Gaug added this withouz Documentation
+//
+TH1I* MH::ProjectArray(const TArrayD &array, Int_t nbins, const char* name, const char* title)
+{
+    const Int_t size = array.GetSize();
+    TH1I *h1=0;
+
+    //check if histogram with identical name exist
+    TObject *h1obj = gROOT->FindObject(name);
+    if (h1obj && h1obj->InheritsFrom("TH1I"))
+    {
+        h1 = (TH1I*)h1obj;
+        h1->Reset();
+    }
+
+    Double_t min = size>0 ? array[0] : 0;
+    Double_t max = size>0 ? array[0] : 1;
+
+    // first loop over array to find the min and max
+    for (Int_t i=1; i<size;i++)
+    {
+        max = TMath::Max(array[i], max);
+        min = TMath::Min(array[i], min);
+    }
+
+    Int_t newbins = 0;
+    FindGoodLimits(nbins, newbins, min, max, kFALSE);
+
+    if (!h1)
+    {
+        h1 = new TH1I(name, title, newbins, min, max);
+        h1->SetXTitle("");
+        h1->SetYTitle("Counts");
+        h1->SetDirectory(gROOT);
+    }
+
+    // Second loop to fill the histogram
+    for (Int_t i=0;i<size;i++)
+        h1->Fill(array[i]);
+
+    return h1;
+}
+
Index: /tags/Mars_V0-8-5/Mars/mhbase/MH.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhbase/MH.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhbase/MH.h	(revision 9661)
@@ -0,0 +1,108 @@
+#ifndef MARS_MH
+#define MARS_MH
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class TH1;
+class TH1I;
+class TH1D;
+class TH2;
+class TH3;
+class TAxis;
+class TArrayF;
+class TArrayD;
+class TCanvas;
+
+class MBinning;
+class MParList;
+
+class MH : public MParContainer
+{
+private:
+    Byte_t fSerialNumber;
+
+public:
+    MH(const char *name=NULL, const char *title=NULL);
+
+
+    virtual void SetSerialNumber(Byte_t num) { fSerialNumber = num; }
+    Byte_t  GetSerialNumber() const { return fSerialNumber; }
+    TString AddSerialNumber(const char *str) const { TString s(str); if (fSerialNumber==0) return s; s += ";"; s += fSerialNumber; return s; }
+    TString AddSerialNumber(const TString &str) const { return AddSerialNumber((const char*)str); }
+
+    Bool_t OverwritesDraw(TClass *cls=NULL) const;
+
+    virtual Bool_t SetupFill(const MParList *pList) { return kTRUE; }
+    virtual Bool_t ReInit(MParList *pList) { return kTRUE; }
+    virtual Bool_t Fill(const MParContainer *par, const Stat_t weight=1);
+    virtual Bool_t Finalize() { return kTRUE; }
+
+    virtual TString GetDataMember() const { return ""; }
+
+    virtual TH1 *GetHistByName(const TString name);
+
+    static TCanvas *MakeDefCanvas(TString name="", const char *title="",
+                                  UInt_t w=625, UInt_t h=440,
+                                  Bool_t usescreenfactor=kTRUE);
+    static TCanvas *MakeDefCanvas(const TObject *obj,
+                                  UInt_t w=625, UInt_t h=440,
+                                  Bool_t usescreenfactor=kFALSE);
+
+    // FIXME: * --> & !!!
+
+    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, const TH1 *x);
+
+    static Bool_t ApplyBinning(const MParList &plist, TString name, TH1 *h);
+
+    static void    ScaleArray(TArrayD &bins, Double_t f);
+    static TArrayD ScaleAxis(TAxis &axe, Double_t f);
+    static void    ScaleAxis(TH1 *bins, Double_t fx=1, Double_t fy=1, Double_t fz=1);
+
+    static Double_t GetBinCenterLog(const TAxis &axe, Int_t nbin);
+
+    static void DrawSameCopy(const TH1 &hist1, const TH1 &hist2, const TString title);
+    static void DrawSame(TH1 &hist1, TH1 &hist2, const TString title);
+
+    TObject *Clone(const char *name="") const;
+
+    TObject *DrawClone(Option_t *opt, Int_t w, Int_t h) const;
+    TObject *DrawClone(Option_t *opt="") const
+    {
+        return MH::DrawClone(opt, 625, 440);
+    }
+
+    static TVirtualPad *GetNewPad(TString &opt);
+
+    static void FindGoodLimits(Int_t nbins, Int_t &newbins, Double_t &xmin, Double_t &xmax, Bool_t isInteger);
+    static Double_t GetMinimumGT(const TH1 &h, Double_t gt=0);
+    static Int_t StripZeros(TH1 *h, Int_t nbins);
+
+    static TH1I* ProjectArray(const TArrayF &array, Int_t nbins=30,
+                              const char* name="ProjectArray", const char* title="Projected Array");
+    static TH1I* ProjectArray(const TArrayD &array, Int_t nbins=30,
+                              const char* name="ProjectArray", const char* title="Projected Array");
+    
+    static void ProjectionX(TH1D &dest, const TH2 &src, Int_t firstybin=-1, Int_t lastybin=9999);
+    static void ProjectionY(TH1D &dest, const TH2 &src, Int_t firstxbin=-1, Int_t lastxbin=9999);
+
+    static TObject *FindObjectInPad(const char *name, TVirtualPad *pad=NULL);
+
+    ClassDef(MH, 1) //A base class for Mars histograms
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mhbase/MH3.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhbase/MH3.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhbase/MH3.cc	(revision 9661)
@@ -0,0 +1,722 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  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 <ctype.h>   // tolower
+#include <fstream>
+
+#include <TPad.h>
+#include <TStyle.h>
+#include <TCanvas.h>
+
+#include <TH2.h>
+#include <TH3.h>
+#include <TProfile.h>
+#include <TProfile2D.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MBinning.h"
+#include "MDataChain.h"
+
+ClassImp(MH3);
+
+using namespace std;
+
+static const TString gsDefName  = "MH3";
+static const TString gsDefTitle = "Container for a %dD Mars Histogram";
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MH3::MH3(const unsigned int dim)
+    : fDimension(dim>3?3:dim), fHist(NULL)
+{  
+    switch (fDimension)
+    {
+    case 1:
+        fHist = new TH1F;
+        fHist->SetYTitle("Counts");
+        break;
+    case 2:
+        fHist = new TH2F;
+        fHist->SetZTitle("Counts");
+        break;
+    case 3:
+        fHist = new TH3F;
+        break;
+    }
+
+    fData[0] = NULL;
+    fData[1] = NULL;
+    fData[2] = NULL;
+
+    fName  = gsDefName;
+    fTitle = Form(gsDefTitle.Data(), 1);
+
+    if (fHist)
+    {
+        fHist->SetDirectory(NULL);
+        fHist->UseCurrentStyle();
+    }
+
+    fScale[0] = 1;
+    fScale[1] = 1;
+    fScale[2] = 1;
+}
+
+// --------------------------------------------------------------------------
+//
+// Creates an TH1F. memberx is filled into the X-bins. For a more detailed
+// description see the class description above.
+//
+MH3::MH3(const char *memberx)
+    : fDimension(1)
+{
+    fHist = new TH1F;
+
+    fData[0] = new MDataChain(memberx);
+    fData[1] = NULL;
+    fData[2] = NULL;
+
+    fName  = gsDefName;
+    fTitle = Form(gsDefTitle.Data(), 1);
+
+    fHist->UseCurrentStyle();
+    fHist->SetDirectory(NULL);
+    fHist->SetYTitle("Counts");
+
+    fScale[0] = 1;
+    fScale[1] = 1;
+    fScale[2] = 1;
+}
+
+// --------------------------------------------------------------------------
+//
+// Creates an TH2F. memberx is filled into the X-bins. membery is filled
+// into the Y-bins. For a more detailed description see the class
+// description above.
+//
+MH3::MH3(const char *memberx, const char *membery)
+    : fDimension(2)
+{
+    fHist = new TH2F;
+
+    fData[0] = new MDataChain(memberx);
+    fData[1] = new MDataChain(membery);
+    fData[2] = NULL;
+
+    fName  = gsDefName;
+    fTitle = Form(gsDefTitle.Data(), 2);
+
+    fHist->UseCurrentStyle();
+    fHist->SetDirectory(NULL);
+    fHist->SetZTitle("Counts");
+
+    fScale[0] = 1;
+    fScale[1] = 1;
+    fScale[2] = 1;
+}
+
+// --------------------------------------------------------------------------
+//
+// Creates an TH3F. memberx is filled into the X-bins. membery is filled
+// into the Y-bins. membery is filled into the Z-bins. For a more detailed
+// description see the class description above.
+//
+MH3::MH3(const char *memberx, const char *membery, const char *memberz)
+    : fDimension(3)
+{
+    fHist = new TH3F;
+
+    fData[0] = new MDataChain(memberx);
+    fData[1] = new MDataChain(membery);
+    fData[2] = new MDataChain(memberz);
+
+    fName  = gsDefName;
+    fTitle = Form(gsDefTitle.Data(), 3);
+
+    fHist->UseCurrentStyle();
+    fHist->SetDirectory(NULL);
+
+    fScale[0] = 1;
+    fScale[1] = 1;
+    fScale[2] = 1;
+}
+
+// --------------------------------------------------------------------------
+//
+// Deletes the histogram
+//
+MH3::~MH3()
+{
+    delete fHist;
+
+    for (int i=0; i<3; i++)
+        if (fData[i])
+            delete fData[i];
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the data members used by the data chain to be used in
+// MTask::AddBranchToList
+//
+TString MH3::GetDataMember() const
+{
+    TString str=fData[0]->GetDataMember();
+    if (fData[1])
+    {
+        str += ";";
+        str += fData[1]->GetDataMember();
+    }
+    if (fData[2])
+    {
+        str += ";";
+        str += fData[2]->GetDataMember();
+    }
+    return str;
+}
+
+// --------------------------------------------------------------------------
+//
+// Setup the Binning for the histograms automatically if the correct
+// instances of MBinning are found in the parameter list
+// For a more detailed description see class description above.
+//
+Bool_t MH3::SetupFill(const MParList *plist)
+{
+    // reset histogram (necessary if the same eventloop is run more than once) 
+    fHist->Reset();
+
+    TString bname("Binning");
+    bname += fName;
+
+    MBinning *binsx = NULL;
+    MBinning *binsy = NULL;
+    MBinning *binsz = NULL;
+
+    switch (fDimension)
+    {
+    case 3:
+        binsz = (MBinning*)plist->FindObject(bname+"Z", "MBinning");
+        if (!binsz)
+        {
+            *fLog << err << dbginf << "MBinning '" << bname << "X' not found... aborting." << endl;
+            return kFALSE;
+        }
+        if (binsz->IsLogarithmic())
+            fHist->SetBit(kIsLogz);
+        if (fData[2]) fHist->SetZTitle(fData[2]->GetTitle());
+        if (fData[2] && !fData[2]->PreProcess(plist))
+            return kFALSE;
+    case 2:
+        binsy = (MBinning*)plist->FindObject(bname+"Y", "MBinning");
+        if (!binsy)
+        {
+            *fLog << err << dbginf << "MBinning '" << bname << "Y' not found... aborting." << endl;
+            return kFALSE;
+        }
+        if (binsy->IsLogarithmic())
+            fHist->SetBit(kIsLogy);
+        if (fData[1]) fHist->SetYTitle(fData[1]->GetTitle());
+        if (fData[1] && !fData[1]->PreProcess(plist))
+            return kFALSE;
+    case 1:
+        binsx = (MBinning*)plist->FindObject(bname+"X", "MBinning");
+        if (!binsx)
+        {
+            if (fDimension==1)
+                binsx = (MBinning*)plist->FindObject(bname, "MBinning");
+
+            if (!binsx)
+            {
+                *fLog << err << dbginf << "Neither MBinning '" << bname << "X' nor '" << bname << "' found... aborting." << endl;
+                return kFALSE;
+            }
+
+        }
+        if (binsx->IsLogarithmic())
+            fHist->SetBit(kIsLogx);
+
+      if (fData[0]!=NULL)  fHist->SetXTitle(fData[0]->GetTitle());
+        if (fData[0] && !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;
+    }
+    cout << "Still alive...?" << endl;
+    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, const Stat_t w)
+{
+    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, w);
+        return kTRUE;
+    case 2:
+        ((TH2*)fHist)->Fill(x, y, w);
+        return kTRUE;
+    case 1:
+        fHist->Fill(x, w);
+        return kTRUE;
+    }
+
+    return kFALSE;
+}
+/*
+// --------------------------------------------------------------------------
+//
+// Set the palette you wanna use:
+//  - you could set the root "Pretty Palette Violet->Red" by
+//    gStyle->SetPalette(1, 0), but in some cases this may look
+//    confusing
+//  - The maximum colors root allowes us to set by ourself
+//    is 50 (idx: 51-100). This colors are set to a grayscaled
+//    palette
+//  - the number of contours must be two less than the number
+//    of palette entries
+//
+void MHStarMap::PrepareDrawing() const
+{
+    const Int_t numg = 32; // number of gray scaled colors
+    const Int_t numw = 32; // number of white
+
+    Int_t palette[numg+numw];
+
+    //
+    // The first half of the colors are white.
+    // This is some kind of optical background supression
+    //
+    gROOT->GetColor(51)->SetRGB(1, 1, 1);
+
+    Int_t i;
+    for (i=0; i<numw; i++)
+        palette[i] = 51;
+
+    //
+    // now the (gray) scaled part is coming
+    //
+    for (;i<numw+numg; i++)
+    {
+        const Float_t gray = 1.0-(float)(i-numw)/(numg-1.0);
+
+        gROOT->GetColor(52+i)->SetRGB(gray, gray, gray);
+        palette[i] = 52+i;
+    }
+
+    //
+    // Set the palette and the number of contour levels
+    //
+    gStyle->SetPalette(numg+numw, palette);
+    fStarMap->SetContour(numg+numw-2);
+}
+*/
+// --------------------------------------------------------------------------
+//
+// Setup a inversed deep blue sea palette for the fCenter histogram.
+//
+void MH3::SetColors() const
+{
+    // FIXME: This must be redone each time the canvas is repainted....
+    gStyle->SetPalette(51, NULL);
+    Int_t c[50];
+    for (int i=0; i<50; i++)
+        c[49-i] = gStyle->GetColorPalette(i);
+    gStyle->SetPalette(50, c);
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw clone of histogram. So that the object can be deleted
+//
+// Possible options are:
+//   PROFX: Draw a x-profile into the histogram (for 2D histograms only)
+//   PROFY: Draw a y-profile into the histogram (for 2D histograms only)
+//   ONLY:  Draw the profile histogram only (for 2D histograms only)
+//
+// If the kIsLog?-Bit is set the axis is displayed lkogarithmically.
+// eg this is set when applying a logarithmic MBinning
+//
+// and the histogram is still visible in the canvas.
+// The cloned object are deleted together with the canvas if the canvas is
+// destroyed. If you want to handle destroying the canvas you can get a
+// pointer to it from this function
+//
+/*
+TObject *MH3::DrawClone(Option_t *opt) const
+{
+    TString str(opt);
+
+    TVirtualPad *c = gPad;
+    if (!str.Contains("nonew", TString::kIgnoreCase))
+    {
+        c = MH::MakeDefCanvas(fHist);
+
+        //
+        // This is necessary to get the expected bahviour of DrawClone
+        //
+        gROOT->SetSelectedPad(NULL);
+    }
+
+    if (str.Contains("COL", TString::kIgnoreCase))
+        SetColors();
+
+    Bool_t only = str.Contains("ONLY", TString::kIgnoreCase) && fDimension==2;
+    if (!only)
+        fHist->DrawCopy(opt);
+
+    if (str.Contains("PROFX", TString::kIgnoreCase) && fDimension==2)
+    {
+        TProfile *p = ((TH2*)fHist)->ProfileX("_pfx", -1, 9999, "s");
+        p->SetLineColor(kBlue);
+        p->Draw(only?"":"same");
+        p->SetBit(kCanDelete);
+        p->SetDirectory(NULL);
+    }
+    if (str.Contains("PROFY", TString::kIgnoreCase) && fDimension==2)
+    {
+        TProfile *p = ((TH2*)fHist)->ProfileY("_pfy", -1, 9999, "s");
+        p->SetLineColor(kBlue);
+        p->Draw(only?"":"same");
+        p->SetBit(kCanDelete);
+        p->SetDirectory(NULL);
+    }
+
+    if (fHist->TestBit(kIsLogx)) c->SetLogx();
+    if (fHist->TestBit(kIsLogy)) c->SetLogy();
+    if (fHist->TestBit(kIsLogz)) c->SetLogz();
+
+    c->Modified();
+    c->Update();
+
+    return c;
+}
+*/
+
+// --------------------------------------------------------------------------
+//
+// Creates a new canvas and draws the histogram into it.
+//
+// Possible options are:
+//   PROFX: Draw a x-profile into the histogram (for 2D histograms only)
+//   PROFY: Draw a y-profile into the histogram (for 2D histograms only)
+//   ONLY:  Draw the profile histogram only (for 2D histograms only)
+//
+// If the kIsLog?-Bit is set the axis is displayed lkogarithmically.
+// eg this is set when applying a logarithmic MBinning
+//
+// Be careful: The histogram belongs to this object and won't get deleted
+// together with the canvas.
+//
+void MH3::Draw(Option_t *opt)
+{
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(fHist);
+    pad->SetBorderMode(0);
+
+    AppendPad("");
+
+    TString str(opt);
+
+    // FIXME: Do it in Paint()
+    if (str.Contains("COL", TString::kIgnoreCase))
+        SetColors();
+
+    fHist->SetFillStyle(4000);
+
+    Bool_t only = str.Contains("ONLY", TString::kIgnoreCase) && fDimension==2;
+    if (!only)
+        fHist->Draw(opt);
+
+    if (str.Contains("PROFX", TString::kIgnoreCase) && fDimension==2)
+    {
+        TProfile *p = ((TH2*)fHist)->ProfileX("_pfx", -1, 9999, "s");
+        p->SetLineColor(kBlue);
+        p->Draw(only?"":"same");
+        p->SetBit(kCanDelete);
+        p->SetDirectory(NULL);
+    }
+    if (str.Contains("PROFY", TString::kIgnoreCase) && fDimension==2)
+    {
+        TProfile *p = ((TH2*)fHist)->ProfileY("_pfy", -1, 9999, "s");
+        p->SetLineColor(kBlue);
+        p->Draw(only?"":"same");
+        p->SetBit(kCanDelete);
+        p->SetDirectory(NULL);
+    }
+
+    if (fHist->TestBit(kIsLogx)) pad->SetLogx();
+    if (fHist->TestBit(kIsLogy)) pad->SetLogy();
+    if (fHist->TestBit(kIsLogz)) pad->SetLogz();
+
+    pad->Modified();
+    pad->Update();
+}
+
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
+void MH3::StreamPrimitive(ofstream &out) const
+{
+    TString name = GetUniqueName();
+
+    out << "   MH3 " << name << "(\"";
+    out << fData[0]->GetRule() << "\"";
+    if (fDimension>1)
+        out << ", \"" << fData[1]->GetRule() << "\"";
+    if (fDimension>2)
+        out << ", \"" << fData[2]->GetRule() << "\"";
+
+    out << ");" << endl;
+
+    if (fName!=gsDefName)
+        out << "   " << name << ".SetName(\"" << fName << "\");" << endl;
+
+    if (fTitle!=Form(gsDefTitle.Data(), fDimension))
+        out << "   " << name << ".SetTitle(\"" << fTitle << "\");" << endl;
+
+    switch (fDimension)
+    {
+    case 3:
+        if (fScale[2]!=1)
+            out << "   " << name << ".SetScaleZ(" << fScale[2] << ");" << endl;
+    case 2:
+        if (fScale[1]!=1)
+            out << "   " << name << ".SetScaleY(" << fScale[1] << ");" << endl;
+    case 1:
+        if (fScale[0]!=1)
+            out << "   " << name << ".SetScaleX(" << fScale[0] << ");" << endl;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Used to rebuild a MH3 object of the same type (data members,
+// dimension, ...)
+//
+MParContainer *MH3::New() const
+{
+    MH3 *h = NULL;
+
+    if (fData[0] == NULL)
+        h=new MH3(fDimension);
+    else
+        switch (fDimension)
+        {
+        case 1:
+            h=new MH3(fData[0]->GetRule());
+            break;
+        case 2:
+            h=new MH3(fData[0]->GetRule(), fData[1]->GetRule());
+            break;
+        case 3:
+            h=new MH3(fData[0]->GetRule(), fData[1]->GetRule(), fData[2]->GetRule());
+            break;
+        }
+    switch (fDimension)
+    {
+    case 3:
+        h->SetScaleZ(fScale[2]);
+    case 2:
+        h->SetScaleY(fScale[1]);
+    case 1:
+        h->SetScaleX(fScale[0]);
+    }
+    return h;
+}
+
+TString MH3::GetRule(const Char_t axis) const
+{
+    switch (tolower(axis))
+    {
+    case 'x':
+        return fData[0] ? fData[0]->GetRule() : TString("");
+    case 'y':
+        return fData[1] ? fData[1]->GetRule() : TString("");
+    case 'z':
+        return fData[2] ? fData[2]->GetRule() : TString("");
+    default:
+        return "<n/a>";
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the total number of bins in a histogram (excluding under- and
+// overflow bins)
+//
+Int_t MH3::GetNbins() const
+{
+    Int_t num = 1;
+
+    switch (fDimension)
+    {
+    case 3:
+        num *= fHist->GetNbinsZ()+2;
+    case 2:
+        num *= fHist->GetNbinsY()+2;
+    case 1:
+        num *= fHist->GetNbinsX()+2;
+    }
+
+    return num;
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the total number of bins in a histogram (excluding under- and
+// overflow bins) Return -1 if bin is underflow or overflow
+//
+Int_t MH3::FindFixBin(Double_t x, Double_t y, Double_t z) const
+{
+    const TAxis &axex = *fHist->GetXaxis();
+    const TAxis &axey = *fHist->GetYaxis();
+    const TAxis &axez = *fHist->GetZaxis();
+
+    Int_t binz = 0;
+    Int_t biny = 0;
+    Int_t binx = 0;
+
+    switch (fDimension)
+    {
+    case 3:
+        binz = axez.FindFixBin(z);
+        if (binz>axez.GetLast() || binz<axez.GetFirst())
+            return -1;
+    case 2:
+        biny = axey.FindFixBin(y);
+        if (biny>axey.GetLast() || biny<axey.GetFirst())
+            return -1;
+    case 1:
+        binx = axex.FindFixBin(x);
+        if (binx<axex.GetFirst() || binx>axex.GetLast())
+            return -1;
+    }
+
+    const Int_t nx = fHist->GetNbinsX()+2;
+    const Int_t ny = fHist->GetNbinsY()+2;
+
+    return binx + nx*(biny +ny*binz);
+}
Index: /tags/Mars_V0-8-5/Mars/mhbase/MH3.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhbase/MH3.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhbase/MH3.h	(revision 9661)
@@ -0,0 +1,69 @@
+#ifndef MARS_MH3
+#define MARS_MH3
+
+#ifndef ROOT_TH1
+#include <TH1.h>
+#endif
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+class TH1;
+class TMethodCall;
+class MDataChain;
+
+class MH3 : public MH
+{
+protected:
+    // Could be const but root < 3.02/06 doesn't like this...
+    Int_t       fDimension;      // Number of dimensions of histogram
+    TH1        *fHist;           // Histogram to fill
+    MDataChain *fData[3];        // Object from which the data is filled
+    Double_t    fScale[3];       // Scale for the three axis (eg unit)
+
+    void StreamPrimitive(ofstream &out) const;
+
+    enum {
+        kIsLogx = BIT(17),
+        kIsLogy = BIT(18),
+        kIsLogz = BIT(19)
+    };
+
+public:
+    MH3(const unsigned int dim=0);
+    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; }
+    Int_t GetNbins() const;
+    Int_t FindFixBin(Double_t x, Double_t y=0, Double_t z=0) const;
+
+    void SetName(const char *name);
+    void SetTitle(const char *title);
+
+    Bool_t SetupFill(const MParList *pList);
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+
+    TString GetDataMember() const;
+    TString GetRule(const Char_t axis='x') const;
+
+    TH1 &GetHist() { return *fHist; }
+    const TH1 &GetHist() const { return *fHist; }
+
+    TH1 *GetHistByName(const TString name="") { return fHist; }
+
+    void SetColors() const;
+    void Draw(Option_t *opt=NULL);
+
+    MParContainer *New() const;
+
+    ClassDef(MH3, 1) // Generalized 1/2/3D-histogram for Mars variables
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mhbase/MHArray.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhbase/MHArray.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhbase/MHArray.cc	(revision 9661)
@@ -0,0 +1,772 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  07/2001 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MHArray
+//
+//  is a sequential collection of mars histograms. If the given index to
+//  call the Fill function of the histogram excceeds the size of the
+//  array by 1 a new entry is created.
+//
+//  With Set/Inc/DecIndex you may specify the actual index of the histogram
+//  wich should be filles by Fill.
+//
+//  Use GetH to get the current histogram, the []-operator get the histogram
+//  by its index.
+//
+//  To access the histograms by a key instead of an index use SetIndexByKey
+//  instead of Set/Inc/DecIndex. It will take the integerpart of the
+//  floating point value (2 in case of 2.9). For each new key a new
+//  index in the Mapping Table is created. So that you can access your
+//  histograms by the key (eg in case of the Angle Theta=23.2deg use
+//  SetIndexByKey(23.2)
+//
+//  If the index is equal to the number of histograms in the array a call
+//  to the Fill-member-function will create a new histogram.
+//
+//  In the constructor istempl leads to two different behaviours of the
+//  MHArray:
+//
+//  - istempl=kTRUE tells MHArray to use the first histogram retrieved from
+//    the Parameterlist by hname to be used as a template. New histograms
+//    are not created using the root dictionary, but the New-member function
+//    (see MParConatiner)
+//  - In the case istempl=kFALSE new histograms are created using the root
+//    dictionary while hname is the class name. For the creation their
+//    default constructor is used.
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MHArray.h"
+
+#include <TH1.h>
+#include <TH2.h>
+#include <TH3.h>
+#include <TStyle.h>
+#include <TGaxis.h>
+#include <TCanvas.h>
+#include <TLegend.h>
+#include <TPaveStats.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MParContainer.h"
+
+#include "MBinning.h"
+
+ClassImp(MHArray);
+
+using namespace std;
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// MMap
+//
+// This class maps a key-value to a given value. In its simple versions it
+// maps a key to an index.
+//
+//////////////////////////////////////////////////////////////////////////////
+#include <TArrayI.h>
+
+class MMap
+{
+private:
+    TArrayI fKeys;
+    TArrayI fValues;
+
+    Int_t K(Int_t i) const { return ((TArrayI)fKeys)[i]; }
+    Int_t V(Int_t i) const { return ((TArrayI)fValues)[i]; }
+
+public:
+    // --------------------------------------------------------------------------
+    //
+    // Return the size of the table
+    //
+    Int_t GetSize() const
+    {
+        return fKeys.GetSize();
+    }
+
+    // --------------------------------------------------------------------------
+    //
+    // Get the value which corresponds to the given key-value
+    //
+    Int_t GetValue(Int_t key) const
+    {
+        const Int_t n = fKeys.GetSize();
+        for (int i=0; i<n; i++)
+        {
+            if (K(i)==key)
+                return V(i);
+        }
+        return -1;
+    }
+
+    // --------------------------------------------------------------------------
+    //
+    // Get the key which corresponds to the given index
+    //
+    Int_t GetKey(Int_t value) const
+    {
+        const Int_t n = fKeys.GetSize();
+        for (int i=0; i<n; i++)
+        {
+            if (V(i)==value)
+                return K(i);
+        }
+        return -1;
+    }
+
+    // --------------------------------------------------------------------------
+    //
+    // Adds a new pair key-value. While the key is the key to the value.
+    // if the key already exists the pair is ignored.
+    //
+    void Add(Int_t key, Int_t value)
+    {
+        if (GetValue(key)>=0)
+            return;
+
+        const Int_t n = fKeys.GetSize();
+
+        fKeys.Set(n+1);
+        fValues.Set(n+1);
+
+        fKeys[n] = key;
+        fValues[n] = value;
+    }
+
+    // --------------------------------------------------------------------------
+    //
+    // Adds a new pair key-value. While the key is the key to the value.
+    // In this case the value is an automatically sequential created index.
+    // if the key already exists the pair is ignored.
+    //
+    Int_t Add(Int_t key)
+    {
+        const Int_t k = GetValue(key);
+        if (k>=0)
+            return k;
+
+        const Int_t n = fKeys.GetSize();
+
+        fKeys.Set(n+1);
+        fValues.Set(n+1);
+
+        fKeys[n] = key;
+        fValues[n] = n;
+
+        return n;
+    }
+};
+
+void MHArray::Init(const char *name)
+{
+    fName  = name  ? name  : "MHArray";
+
+    fMapIdx = new MMap;
+
+    fArray = new TList;
+    fArray->SetOwner();
+}
+
+// --------------------------------------------------------------------------
+//
+// Can replace a constructor. Use the default constructor and afterwards
+// the Set function of your need.
+//
+void MHArray::Set(const TString hname, Bool_t istempl)
+{
+    if (fTemplate || fClass || fTemplateName!="<dummy>")
+    {
+        *fLog << warn << "WARNING - MHArray already setup... Set ignored." << endl;
+        return;
+    }
+
+    if (istempl)
+    {
+        fTemplateName = hname;
+        return;
+    }
+
+    //
+    // try to get class from root environment
+    //
+    fClass = gROOT->GetClass(hname);
+    if (!fClass)
+    {
+        //
+        // if class is not existing in the root environment
+        //
+        *fLog << err << dbginf << "Class '" << hname << "' not existing in dictionary." << endl;
+    }
+
+    //
+    // check for ineritance from MH
+    //
+    if (!fClass->InheritsFrom(MH::Class()))
+    {
+        //
+        // if class doesn't inherit from MH --> error
+        //
+        *fLog << err << dbginf << "Class '" << hname << "' doesn't inherit from MH." << endl;
+        fClass = NULL;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Can replace a constructor. Use the default constructor and afterwards
+// the Set function of your need.
+//
+void MHArray::Set(const MH *hist)
+{
+    fIdx=0;
+    fClass=NULL;
+    fTemplate=hist;
+    fTemplateName="<dummy>";
+}
+
+
+// --------------------------------------------------------------------------
+//
+// hname is the name of the histogram class which is in the array.
+//
+// istempl=kTRUE tells MHArray to use the first histogram retrieved from the
+// ParameterList by hname to be used as a template. New histograms are not
+// created using the root dictionary, but the New-member function (see
+// MParConatiner)
+// In the case istempl=kFALSE new histograms are created using the root
+// dictionary while hname is the class name. For the creation their
+// default constructor is used.
+//
+MHArray::MHArray(const TString hname, Bool_t istempl, const char *name, const char *title)
+    : fIdx(0), fClass(NULL), fTemplate(NULL)
+{
+    //
+    //   set the name and title of this object
+    //
+    Init(name);
+    fTitle = title ? TString(title) : (TString("Base class for Mars histogram arrays:") + hname);
+
+    Set(hname, istempl);
+}
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. Use MHArray::Set to setup the MHArray afterwards
+//
+MHArray::MHArray(const char *name, const char *title)
+    : fIdx(0), fClass(NULL), fTemplate(NULL), fTemplateName("<dummy>")
+{
+    //
+    //   set the name and title of this object
+    //
+    Init(name);
+    fTitle = title ? title : "A Mars histogram array";
+}
+
+// --------------------------------------------------------------------------
+//
+// hname is the name of the histogram class which is in the array.
+//
+// istempl=kTRUE tells MHArray to use the first histogram retrieved from the
+// ParameterList by hname to be used as a template. New histograms are not
+// created using the root dictionary, but the New-member function (see
+// MParConatiner)
+// In the case istempl=kFALSE new histograms are created using the root
+// dictionary while hname is the class name. For the creation their
+// default constructor is used.
+//
+MHArray::MHArray(const MH *hist, const char *name, const char *title)
+    : fIdx(0), fClass(NULL), fTemplate(hist), fTemplateName("<dummy>")
+{
+    //
+    //   set the name and title of this object
+    //
+    Init(name);
+    fTitle = title ? TString(title) : (TString("Base class for Mars histogram arrays:") + hist->GetName());
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor: Deleteing the array and all histograms which are part of the
+// array.
+//
+MHArray::~MHArray()
+{
+    fArray->Delete();
+    delete fArray;
+    delete fMapIdx;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Use this to access the histograms by a key. If you use values like
+//   (in this order) 2.5, 7.2, 2.5, 9.3, 9.3, 3.3, 2.2, 1.1
+//  it will be mapped to the following indices internally:
+//                    0    1    0    2    2    3    4    5
+//
+//  WARNING: Make sure that you don't create new histograms by setting
+//           a new index (SetIndex or IncIndex) which is equal the size
+//           of the array and create new histogram by CreateH. In this
+//           case you will confuse the mapping completely.
+//
+void MHArray::SetIndexByKey(Double_t key)
+{
+    fIdx = fMapIdx->Add((Int_t)key);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Use this function to access a histogram by its index in the array.
+//  Becarefull the index isn't checked!
+//
+MH &MHArray::operator[](Int_t i)
+{
+    return *(MH*)fArray->At(i);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Use this function to access a histogram by its index in the array.
+//  Becarefull the index isn't checked!
+//
+MH *MHArray::At(Int_t i)
+{
+    return (MH*)fArray->At(i);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Use this function to access the histogram corresponding to the
+//  currently set index (by Set/Inc/DecIndex or SetIndexByKey)
+//  Becarefull the index set isn't checked!
+//
+MH *MHArray::GetH()
+{
+    return (MH*)fArray->At(fIdx);
+}
+
+// --------------------------------------------------------------------------
+//
+// Tries to create a new histogram, adds it as last entry to the array
+// and tries to call SetupFill for it. In case of success the last entry
+// in the array is the new histogram and kTRUE is returned. Otherwise
+// kFALSE is returned.
+//
+Bool_t MHArray::CreateH()
+{
+    TString cname = fClass ? fClass->GetName() : fTemplate->IsA()->GetName();
+
+    MH *hist = NULL;
+    if (fTemplate)
+    {
+        //
+        // create the parameter container as a clone of the existing
+        // template histogram.
+        //
+        hist = (MH*)fTemplate->New();
+    }
+    else
+    {
+        //
+        // create the parameter container of the the given class type
+        //
+        hist = (MH*)fClass->New();
+    }
+    if (!hist)
+    {
+        *fLog << err << dbginf << "Cannot create new instance of class '";
+        *fLog << cname << "' (Maybe no def. constructor)" << endl;
+        return kFALSE;
+    }
+
+    //
+    // Set the name of the container
+    //
+    if (!fTemplate)
+    {
+        TString name = TString(hist->GetName())+";";
+        name += fIdx;
+
+        hist->SetName(name);
+    }
+
+    //
+    // Try to setup filling for the histogram
+    //
+    if (!hist->SetupFill(fParList))
+    {
+        *fLog << err << dbginf << "SetupFill for new histogram of type '";
+        *fLog << cname << "' with Index #" << fIdx << " failed." << endl;
+        delete hist;
+        return kFALSE;
+    }
+
+    fArray->AddLast(hist);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns kFALSE if the class couldn't be found in the root dictionary or
+// if it doesn't inherit from MH.
+// The parameter list is remembert to be used for SetupFill in case a new
+// histogram is created.
+// The index is reset to 0
+//
+Bool_t MHArray::SetupFill(const MParList *pList)
+{
+    fParList = pList;
+    fIdx = 0;
+
+    if (fTemplate)
+        return kTRUE;
+
+    if (!fTemplateName.IsNull())
+    {
+        fTemplate = (MH*)pList->FindObject(fTemplateName, "MH");
+        return fTemplate ? kTRUE : kFALSE;
+    }
+
+    return fClass ? kTRUE : kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Call Fill for the present histogram index. If the index is out of
+// bounds the event is skipped. If the index is the number of current
+// histograms in the array a new histogram is created and if creation was
+// successfull filled.
+//
+Bool_t MHArray::Fill(const MParContainer *par, const Stat_t w)
+{
+    const Int_t n = fArray->GetSize();
+
+    if (fIdx<0 || fIdx>n)
+    {
+        *fLog << warn << "Histogram Index #" << fIdx << " out of bounds (>";
+        *fLog << n << ")... skipped." << endl;
+        return kCONTINUE;
+    }
+
+    if (fIdx==n)
+        if (!CreateH())
+            return kFALSE;
+
+    return GetH()->Fill(par, w);
+}
+
+Bool_t MHArray::AddHistogram()
+{
+    fIdx=fArray->GetSize();
+
+    return CreateH();
+}
+
+// --------------------------------------------------------------------------
+//
+// Calls Finalize for all histograms in the list. If at least one Finalize
+// fails kFALSE is returned.
+//
+Bool_t MHArray::Finalize()
+{
+    Bool_t rc = kTRUE;
+
+    TIter Next(fArray);
+    MH *hist = NULL;
+
+    while ((hist=(MH*)Next()))
+        if (!hist->Finalize())
+            rc = kFALSE;
+
+    return rc;
+}
+
+// --------------------------------------------------------------------------
+//
+// Print the number of entries in the array
+//
+void MHArray::Print(Option_t *option) const
+{
+    *fLog << all << GetDescriptor() << " contains " << fArray->GetSize();
+    *fLog << " histograms." << endl;
+
+    if (fMapIdx->GetSize()<=0)
+        return;
+
+    *fLog << " idx\t     key" << endl;
+    for (int i=0; i<fMapIdx->GetSize(); i++)
+        *fLog << "  " << i << "\t<-->  " << fMapIdx->GetKey(i) << endl;
+    *fLog << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Adds the given object to the given legend (if != NULL). The Legend
+// entry name is created from the key...
+//
+void MHArray::AddLegendEntry(TLegend *leg, TObject *obj, Int_t idx) const
+{
+    if (!leg)
+        return;
+
+    TString name = " ";
+    name += fMapIdx->GetKey(idx);
+    leg->AddEntry(obj, name, "lpf"); // l=line, p=polymarker, f=fill
+}
+
+
+// --------------------------------------------------------------------------
+//
+// The option is the name of the histogram, used to get a histogram from
+// the MH entries by calling their GetHist function.
+//
+void MHArray::Draw(Option_t *opt)
+{
+    if (!gPad)
+        MH::MakeDefCanvas(this);
+
+    const Int_t sstyle = gStyle->GetOptStat();
+    gStyle->SetOptStat(0);
+
+    //
+    // if the keymapping is used create a legend to identify the histograms
+    //
+    TLegend *leg = NULL;
+    if (fMapIdx->GetSize()>0)
+    {
+        leg = new TLegend(0.85, 0.80, 0.99, 0.99);
+        leg->SetBit(kCanDelete);
+    }
+
+    TIter Next(fArray);
+    MH *hist = (MH*)Next();
+
+    Int_t idx=0;
+    Double_t max=0;
+    Double_t min=0;
+
+    TH1 *h1=NULL;
+
+    //
+    // If the array has at least one entry:
+    //  - find the starting boundaries
+    //  - draw it and set its line color
+    //
+    if (hist)
+    {
+        if ((h1 = hist->GetHistByName(opt)))
+        {
+            h1->Draw();
+            h1->SetLineColor(idx+2);
+            max = h1->GetMaximum();
+            min = h1->GetMinimum();
+
+            AddLegendEntry(leg, h1, idx);
+        }
+    }
+
+    //
+    // For all following histograms:
+    //  - update the boundaries
+    //  - draw it and set its line color
+    //
+    while ((hist=(MH*)Next()))
+    {
+        TH1 *h=NULL;
+
+        if (!(h = hist->GetHistByName(opt)))
+            continue;
+
+        h->Draw("same");
+        h->SetLineColor(idx+2);
+        if (max<h->GetMaximum())
+            max = h->GetMaximum();
+        if (min>h->GetMinimum())
+            min = h->GetMinimum();
+
+        AddLegendEntry(leg, h, idx++);
+    }
+
+    //
+    // Now update the drawing region so that everything is displayed
+    //
+    if (h1)
+    {
+        h1->SetMinimum(min>0 ? min*0.95 : min*1.05);
+        h1->SetMaximum(max>0 ? max*1.05 : max*0.95);
+    }
+
+    if (leg)
+        leg->Draw();
+
+    gPad->Modified();
+    gPad->Update();
+
+    gStyle->SetOptStat(sstyle);
+}
+
+// --------------------------------------------------------------------------
+//
+// The option is the name of the histogram, used to get a histogram from
+// the MH entries by calling their GetHistByName function.
+// If the option also contains 'nonew' no new canvas is created.
+// The option "Scale=1" scales the area of all histogram to 1
+// The option "Scale=max" scales the maximum of all histogram to 1
+//
+TObject *MHArray::DrawClone(Option_t *opt) const
+{
+    TString o(opt);
+
+    TCanvas *c = NULL;
+
+    Int_t scale1   = o.Index("scale=1",   TString::kIgnoreCase);
+    Int_t scalemax = o.Index("scale=max", TString::kIgnoreCase);
+    Int_t nonew    = o.Index("nonew",     TString::kIgnoreCase);
+
+    if (o.BeginsWith("scale=1", TString::kIgnoreCase))
+        scale1 = 0;
+    if (o.BeginsWith("scale=max", TString::kIgnoreCase))
+        scalemax = 0;
+    if (o.BeginsWith("nonew", TString::kIgnoreCase))
+        nonew = 0;
+
+    if (nonew>=0)
+    {
+        c = MH::MakeDefCanvas(this);
+
+        //
+        // This is necessary to get the expected bahviour of DrawClone
+        //
+        gROOT->SetSelectedPad(NULL);
+
+        o.Remove(nonew, 5);
+    }
+    if (scale1>=0)
+        o.Remove(scale1, 7);
+    if (scalemax>=0)
+        o.Remove(scalemax, 9);
+
+    const Int_t sstyle = gStyle->GetOptStat();
+    gStyle->SetOptStat(0);
+
+    //
+    // if the keymapping is used create a legend to identify the histograms
+    //
+    TLegend *leg = NULL;
+    if (fMapIdx->GetSize()>0)
+    {
+        leg = new TLegend(0.85, 0.80, 0.99, 0.99);
+        leg->SetBit(kCanDelete);
+    }
+
+    TIter Next(fArray);
+    MH *hist = (MH*)Next();
+
+    Int_t idx=0;
+    Double_t max=0;
+    Double_t min=0;
+
+    TH1 *h1=NULL;
+
+     //
+    // If the array has at least one entry:
+    //  - find the starting boundaries
+    //  - draw it and set its line color
+    //
+    if (hist)
+    {
+        if ((h1 = hist->GetHistByName(o)))
+        {
+            h1 = (TH1*)h1->DrawCopy();
+
+            if (scale1>=0)
+                h1->Scale(1./h1->Integral());
+            if (scalemax>=0)
+                h1->Scale(1./h1->GetMaximum());
+
+            h1->SetMarkerColor(idx);
+            h1->SetLineColor(idx+2);
+            h1->SetFillStyle(4000);
+            max = h1->GetMaximum();
+            min = h1->GetMinimum();
+
+            AddLegendEntry(leg, h1, idx++);
+        }
+    }
+
+    //
+    // For all following histograms:
+    //  - update the boundaries
+    //  - draw it and set its line color
+    //
+    while ((hist=(MH*)Next()))
+    {
+        TH1 *h=NULL;
+
+        if (!(h = hist->GetHistByName(o)))
+            continue;
+
+        h = (TH1*)h->DrawCopy("same");
+
+        if (scale1>=0)
+            h->Scale(1./h->Integral());
+        if (scalemax>=0)
+            h->Scale(1./h->GetMaximum());
+
+        h->SetMarkerColor(idx);
+        h->SetLineColor(idx+2);
+        h->SetFillStyle(4000); // transperent (why is this necessary?)
+        if (max<h->GetMaximum())
+            max = h->GetMaximum();
+        if (min>h->GetMinimum())
+            min = h->GetMinimum();
+
+        AddLegendEntry(leg, h, idx++);
+    }
+
+    //
+    // Now update the drawing region so that everything is displayed
+    //
+    if (h1)
+    {
+        h1->SetMinimum(min>0 ? min*0.95 : min*1.05);
+        h1->SetMaximum(max>0 ? max*1.05 : max*0.95);
+    }
+
+    if (leg)
+        leg->Draw();
+
+    gPad->Modified();
+    gPad->Update();
+
+    gStyle->SetOptStat(sstyle);
+
+    return c;
+}
Index: /tags/Mars_V0-8-5/Mars/mhbase/MHArray.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhbase/MHArray.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhbase/MHArray.h	(revision 9661)
@@ -0,0 +1,71 @@
+#ifndef MARS_MHArray
+#define MARS_MHArray
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+class TList;
+class TLegend;
+
+class MMap;
+
+class MHArray : public MH
+{
+private:
+    Int_t  fIdx;              // current index for the fill function
+    TList *fArray;            //-> Array storing the histograms
+
+    const MParList *fParList; //! pointer to parameter list used for SetupFill when a new Hist is created
+    TClass *fClass;           // pointer to class entry in root dictionary
+
+    const MH *fTemplate;      //-> pointer to a template histogram
+    TString fTemplateName;    // name of the template class
+
+    MMap *fMapIdx;            //! Table to map keys to array indices
+
+    Bool_t CreateH();
+    void   AddLegendEntry(TLegend *leg, TObject *obj, Int_t idx) const;
+
+    enum { kUseTemplate=BIT(14) };
+
+    void Init(const char *name);
+
+public:
+    MHArray(const char *name=NULL, const char *title=NULL);
+    MHArray(const TString hname, Bool_t istempl=kFALSE, const char *name=NULL, const char *title=NULL);
+    MHArray(const MH *hist, const char *name=NULL, const char *title=NULL);
+    ~MHArray();
+
+    void Set(const TString hname, Bool_t istempl=kFALSE);
+    void Set(const MH *hist);
+
+    Bool_t SetupFill(const MParList *pList);
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+    Bool_t Finalize();
+
+    Bool_t AddHistogram();
+
+    MH &operator[](Int_t i);
+    MH *At(Int_t i);
+
+    MH *GetH();
+
+    void SetIndexByKey(Double_t key);
+
+    void SetIndex(Int_t i) { fIdx=i; }
+    void IncIndex() { fIdx++; }
+    void DecIndex() { fIdx--; }
+
+    Int_t GetIndex() const { return fIdx; }
+
+    void Print(Option_t *option="") const;
+
+    void Draw(Option_t *opt="");
+    TObject *DrawClone(Option_t *opt="") const;
+
+    ClassDef(MHArray, 0) //A histogram class for an array of Mars histograms
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mhbase/MHMatrix.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhbase/MHMatrix.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhbase/MHMatrix.cc	(revision 9661)
@@ -0,0 +1,1191 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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>
+!              Rudy Boeck     2003 <mailto:
+!              Wolfgang Wittek2003 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHMatrix
+//
+// This is a histogram container which holds a matrix with one column per
+// data variable. The data variable can be a complex rule (MDataChain).
+// Each event for wich Fill is called (by MFillH) is added as a new
+// row to the matrix.
+//
+// For example:
+//   MHMatrix m;
+//   m.AddColumn("MHillas.fSize");
+//   m.AddColumn("MMcEvt.fImpact/100");
+//   m.AddColumn("HillasSource.fDist*MGeomCam.fConvMm2Deg");
+//   MFillH fillm(&m);
+//   taskliost.AddToList(&fillm);
+//   [...]
+//   m.Print();
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MHMatrix.h"
+
+#include <fstream>
+
+#include <TList.h>
+#include <TArrayF.h>
+#include <TArrayD.h>
+#include <TArrayI.h>
+
+#include <TH1.h>
+#include <TCanvas.h>
+#include <TRandom3.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MFillH.h"
+#include "MEvtLoop.h"
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MProgressBar.h"
+
+#include "MData.h"
+#include "MDataArray.h"
+#include "MFilter.h"
+
+ClassImp(MHMatrix);
+
+using namespace std;
+
+const TString MHMatrix::gsDefName  = "MHMatrix";
+const TString MHMatrix::gsDefTitle = "Multidimensional Matrix";
+
+// --------------------------------------------------------------------------
+//
+//  Default Constructor
+//
+MHMatrix::MHMatrix(const char *name, const char *title)
+    : fNumRows(0), fData(NULL)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Default Constructor
+//
+MHMatrix::MHMatrix(const TMatrix &m, const char *name, const char *title)
+    : fNumRows(m.GetNrows()), fM(m), fData(NULL)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Constructor. Initializes the columns of the matrix with the entries
+//  from a MDataArray
+//
+MHMatrix::MHMatrix(MDataArray *mat, const char *name, const char *title)
+    : fNumRows(0), fData(mat)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Destructor. Does not deleted a user given MDataArray, except IsOwner
+//  was called.
+//
+MHMatrix::~MHMatrix()
+{
+    if (TestBit(kIsOwner) && fData)
+        delete fData;
+}
+
+// --------------------------------------------------------------------------
+//
+Bool_t MHMatrix::SetNumRow(Int_t row) 
+{
+    if (row>=fM.GetNrows() || row<0) return kFALSE;
+    fRow = row;
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Add a new column to the matrix. This can only be done before the first
+// event (row) was filled into the matrix. For the syntax of the rule
+// see MDataChain.
+// Returns the index of the new column, -1 in case of failure.
+// (0, 1, 2, ... for the 1st, 2nd, 3rd, ...)
+//
+Int_t MHMatrix::AddColumn(const char *rule)
+{
+    if (fM.IsValid())
+    {
+        *fLog << warn << "Warning - matrix is already in use. Can't add a new column... skipped." << endl;
+        return -1;
+    }
+
+    if (TestBit(kIsLocked))
+    {
+        *fLog << warn << "Warning - matrix is locked. Can't add new column... skipped." << endl;
+        return -1;
+    }
+
+    if (!fData)
+    {
+        fData = new MDataArray;
+        SetBit(kIsOwner);
+    }
+
+    fData->AddEntry(rule);
+    return fData->GetNumEntries()-1;
+}
+
+// --------------------------------------------------------------------------
+//
+void MHMatrix::AddColumns(MDataArray *matrix)
+{
+    if (fM.IsValid())
+    {
+        *fLog << warn << "Warning - matrix is already in use. Can't add new columns... skipped." << endl;
+        return;
+    }
+
+    if (TestBit(kIsLocked))
+    {
+        *fLog << warn << "Warning - matrix is locked. Can't add new columns... skipped." << endl;
+        return;
+    }
+
+    if (fData)
+        *fLog << warn << "Warning - columns already added... replacing." << endl;
+
+    if (fData && TestBit(kIsOwner))
+    {
+        delete fData;
+        ResetBit(kIsOwner);
+    }
+
+    fData = matrix;
+}
+
+// --------------------------------------------------------------------------
+//
+// Checks whether at least one column is available and PreProcesses all
+// data chains.
+//
+Bool_t MHMatrix::SetupFill(const MParList *plist)
+{
+    if (!fData)
+    {
+        *fLog << err << "Error - No Columns initialized... aborting." << endl;
+        return kFALSE;
+    }
+
+    return fData->PreProcess(plist);
+}
+
+// --------------------------------------------------------------------------
+//
+// If the matrix has not enough rows double the number of available rows.
+//
+void MHMatrix::AddRow()
+{
+    fNumRows++;
+
+    if (fM.GetNrows() > fNumRows)
+        return;
+
+    if (!fM.IsValid())
+    {
+        fM.ResizeTo(1, fData->GetNumEntries());
+        return;
+    }
+
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,05,07)
+    TMatrix m(fM);
+#endif
+    fM.ResizeTo(fM.GetNrows()*2, fData->GetNumEntries());
+
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,05,07)
+    TVector vold(fM.GetNcols());
+    for (int x=0; x<m.GetNrows(); x++)
+        TMatrixRow(fM, x) = vold = TMatrixRow(m, x);
+#endif
+}
+
+// --------------------------------------------------------------------------
+//
+// Add the values correspoding to the columns to the new row
+//
+Bool_t MHMatrix::Fill(const MParContainer *par, const Stat_t w)
+{
+    AddRow();
+
+    for (int col=0; col<fData->GetNumEntries(); col++)
+        fM(fNumRows-1, col) = (*fData)(col);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Resize the matrix to a number of rows which corresponds to the number of
+// rows which have really been filled with values.
+//
+Bool_t MHMatrix::Finalize()
+{
+    //
+    // It's not a fatal error so we don't need to stop PostProcessing...
+    //
+    if (fData->GetNumEntries()==0 || fNumRows<1)
+        return kTRUE;
+
+    if (fNumRows != fM.GetNrows())
+    {
+        TMatrix m(fM);
+        CopyCrop(fM, m, fNumRows);
+    }
+
+    return kTRUE;
+}
+
+/*
+// --------------------------------------------------------------------------
+//
+// Draw clone of histogram. So that the object can be deleted
+// and the histogram is still visible in the canvas.
+// The cloned object are deleted together with the canvas if the canvas is
+// destroyed. If you want to handle destroying the canvas you can get a
+// pointer to it from this function
+//
+TObject *MHMatrix::DrawClone(Option_t *opt) const
+{
+    TCanvas &c = *MH::MakeDefCanvas(fHist);
+
+    //
+    // This is necessary to get the expected bahviour of DrawClone
+    //
+    gROOT->SetSelectedPad(NULL);
+
+    fHist->DrawCopy(opt);
+
+    TString str(opt);
+    if (str.Contains("PROFX", TString::kIgnoreCase) && fDimension==2)
+    {
+        TProfile *p = ((TH2*)fHist)->ProfileX();
+        p->Draw("same");
+        p->SetBit(kCanDelete);
+    }
+    if (str.Contains("PROFY", TString::kIgnoreCase) && fDimension==2)
+    {
+        TProfile *p = ((TH2*)fHist)->ProfileY();
+        p->Draw("same");
+        p->SetBit(kCanDelete);
+    }
+
+    c.Modified();
+    c.Update();
+
+    return &c;
+}
+
+// --------------------------------------------------------------------------
+//
+// Creates a new canvas and draws the histogram into it.
+// Be careful: The histogram belongs to this object and won't get deleted
+// together with the canvas.
+//
+void MHMatrix::Draw(Option_t *opt)
+{
+    if (!gPad)
+        MH::MakeDefCanvas(fHist);
+
+    fHist->Draw(opt);
+
+    TString str(opt);
+    if (str.Contains("PROFX", TString::kIgnoreCase) && fDimension==2)
+    {
+        TProfile *p = ((TH2*)fHist)->ProfileX();
+        p->Draw("same");
+        p->SetBit(kCanDelete);
+    }
+    if (str.Contains("PROFY", TString::kIgnoreCase) && fDimension==2)
+    {
+        TProfile *p = ((TH2*)fHist)->ProfileY();
+        p->Draw("same");
+        p->SetBit(kCanDelete);
+    }
+
+    gPad->Modified();
+    gPad->Update();
+}
+*/
+
+// --------------------------------------------------------------------------
+//
+// Prints the meaning of the columns and the contents of the matrix.
+// Becareful, this can take a long time for matrices with many rows.
+// Use the option 'size' to print the size of the matrix.
+// Use the option 'cols' to print the culumns
+// Use the option 'data' to print the contents
+//
+void MHMatrix::Print(Option_t *o) const
+{
+    TString str(o);
+
+    *fLog << all << flush;
+
+    if (str.Contains("size", TString::kIgnoreCase))
+    {
+        *fLog << GetDescriptor() << ": NumColumns=" << fM.GetNcols();
+        *fLog << " NumRows=" << fM.GetNrows() << endl;
+    }
+
+    if (!fData && str.Contains("cols", TString::kIgnoreCase))
+        *fLog << "Sorry, no column information available." << endl;
+
+    if (fData && str.Contains("cols", TString::kIgnoreCase))
+        fData->Print();
+
+    if (str.Contains("data", TString::kIgnoreCase))
+        fM.Print();
+}
+
+// --------------------------------------------------------------------------
+//
+const TMatrix *MHMatrix::InvertPosDef()
+{
+    TMatrix m(fM);
+
+    const Int_t rows = m.GetNrows();
+    const Int_t cols = m.GetNcols();
+
+    for (int x=0; x<cols; x++)
+    {
+        Double_t avg = 0;
+        for (int y=0; y<rows; y++)
+            avg += fM(y, x);
+
+        avg /= rows;
+
+        TMatrixColumn(m, x) += -avg;
+    }
+
+    TMatrix *m2 = new TMatrix(m, TMatrix::kTransposeMult, m);
+
+    Double_t det;
+    m2->Invert(&det);
+    if (det==0)
+    {
+        *fLog << err << "ERROR - MHMatrix::InvertPosDef failed (Matrix is singular)." << endl;
+        delete m2;
+        return NULL;
+    }
+
+    // m2->Print();
+
+    return m2;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculated the distance of vector evt from the reference sample
+// represented by the covariance metrix m.
+//  - If n<0 the kernel method is applied and
+//    -log(sum(epx(-d/h))/n) is returned.
+//  - For n>0 the n nearest neighbors are summed and
+//    sqrt(sum(d)/n) is returned.
+//  - if n==0 all distances are summed
+//
+Double_t MHMatrix::CalcDist(const TMatrix &m, const TVector &evt, Int_t num) const
+{
+    if (num==0) // may later be used for another method
+    {
+        TVector d = evt;
+        d *= m;
+        return TMath::Sqrt(d*evt);
+    }
+
+    const Int_t rows = fM.GetNrows();
+    const Int_t cols = fM.GetNcols();
+
+    TArrayD dists(rows);
+
+    //
+    // Calculate:  v^T * M * v
+    //
+    for (int i=0; i<rows; i++)
+    {
+        TVector col(cols);
+        col = TMatrixRow(fM, i);
+
+        TVector d = evt;
+        d -= col;
+
+        TVector d2 = d;
+        d2 *= m;
+
+        dists[i] = d2*d; // square of distance
+
+        //
+        // This corrects for numerical uncertanties in cases of very
+        // small distances...
+        //
+        if (dists[i]<0)
+            dists[i]=0;
+    }
+
+    TArrayI idx(rows);
+    TMath::Sort(dists.GetSize(), dists.GetArray(), idx.GetArray(), kFALSE);
+
+    Int_t from = 0;
+    Int_t to   = TMath::Abs(num)<rows ? TMath::Abs(num) : rows;
+    //
+    // This is a zero-suppression for the case a test- and trainings
+    // sample is identical. This would result in an unwanted leading
+    // zero in the array. To suppress also numerical uncertanties of
+    // zero we cut at 1e-5. Due to Rudy this should be enough. If
+    // you encounter problems we can also use (eg) 1e-25
+    //
+    if (dists[idx[0]]<1e-5)
+    {
+        from++;
+        to ++;
+        if (to>rows)
+            to = rows;
+    }
+
+    if (num<0)
+    {
+        //
+        // Kernel function sum (window size h set according to literature)
+        //
+        const Double_t h    = TMath::Power(rows, -1./(cols+4));
+        const Double_t hwin = h*h*2;
+
+        Double_t res = 0;
+        for (int i=from; i<to; i++)
+            res += TMath::Exp(-dists[idx[i]]/hwin);
+
+        return -TMath::Log(res/(to-from));
+    }
+    else
+    {
+        //
+        // Nearest Neighbor sum
+        //
+        Double_t res = 0;
+        for (int i=from; i<to; i++)
+            res += dists[idx[i]];
+
+        return TMath::Sqrt(res/(to-from));
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Calls calc dist. In the case of the first call the covariance matrix
+// fM2 is calculated.
+//  - If n<0 it is divided by (nrows-1)/h while h is the kernel factor.
+//
+Double_t MHMatrix::CalcDist(const TVector &evt, Int_t num)
+{
+    if (!fM2.IsValid())
+    {
+        if (!fM.IsValid())
+        {
+            *fLog << err << "MHMatrix::CalcDist - ERROR: fM not valid." << endl;
+            return -1;
+        }
+
+        const TMatrix *m = InvertPosDef();
+        if (!m)
+            return -1;
+
+        fM2.ResizeTo(*m);
+        fM2 = *m;
+        fM2 *= fM.GetNrows()-1;
+        delete m;
+    }
+
+    return CalcDist(fM2, evt, num);
+}
+
+// --------------------------------------------------------------------------
+//
+void MHMatrix::Reassign()
+{
+    TMatrix m = fM;
+    fM.ResizeTo(1,1);
+    fM.ResizeTo(m);
+    fM = m;
+}
+
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
+void MHMatrix::StreamPrimitive(ofstream &out) const
+{
+    Bool_t data = fData && !TestBit(kIsOwner);
+
+    if (data)
+    {
+        fData->SavePrimitive(out);
+        out << endl;
+    }
+
+    out << "   MHMatrix " << GetUniqueName();
+
+    if (data || fName!=gsDefName || fTitle!=gsDefTitle)
+    {
+        out << "(";
+        if (data)
+            out << "&" << fData->GetUniqueName();
+        if (fName!=gsDefName || fTitle!=gsDefTitle)
+        {
+            if (data)
+                out << ", ";
+            out << "\"" << fName << "\"";
+            if (fTitle!=gsDefTitle)
+                out << ", \"" << fTitle << "\"";
+        }
+    }
+    out << ");" << endl;
+
+    if (fData && TestBit(kIsOwner))
+        for (int i=0; i<fData->GetNumEntries(); i++)
+            out << "   " << GetUniqueName() << ".AddColumn(\"" << (*fData)[i].GetRule() << "\");" << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+const TArrayI MHMatrix::GetIndexOfSortedColumn(Int_t ncol, Bool_t desc) const
+{
+    TMatrixColumn col(fM, ncol);
+
+    const Int_t n = fM.GetNrows();
+
+    TArrayF array(n);
+
+    for (int i=0; i<n; i++)
+        array[i] = col(i);
+
+    TArrayI idx(n);
+    TMath::Sort(n, array.GetArray(), idx.GetArray(), desc);
+
+    return idx;
+}
+
+// --------------------------------------------------------------------------
+//
+void MHMatrix::SortMatrixByColumn(Int_t ncol, Bool_t desc)
+{
+    TArrayI idx = GetIndexOfSortedColumn(ncol, desc);
+
+    const Int_t n = fM.GetNrows();
+
+    TMatrix m(n, fM.GetNcols());
+    TVector vold(fM.GetNcols());
+    for (int i=0; i<n; i++)
+        TMatrixRow(m, i) = vold = TMatrixRow(fM, idx[i]);
+
+    fM = m;
+}
+
+// --------------------------------------------------------------------------
+//
+Bool_t MHMatrix::Fill(MParList *plist, MTask *read, MFilter *filter)
+{
+    //
+    // Read data into Matrix
+    //
+    const Bool_t is = plist->IsOwner();
+    plist->SetOwner(kFALSE);
+
+    MTaskList tlist;
+    plist->Replace(&tlist);
+
+    MFillH fillh(this);
+
+    tlist.AddToList(read);
+
+    if (filter)
+    {
+        tlist.AddToList(filter);
+        fillh.SetFilter(filter);
+    }
+
+    tlist.AddToList(&fillh);
+
+    //MProgressBar bar;
+    MEvtLoop evtloop("MHMatrix::Fill-EvtLoop");
+    evtloop.SetParList(plist);
+    //evtloop.SetProgressBar(&bar);
+
+    if (!evtloop.Eventloop())
+        return kFALSE;
+
+    tlist.PrintStatistics();
+
+    plist->Remove(&tlist);
+    plist->SetOwner(is);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return a comma seperated list of all data members used in the matrix.
+// This is mainly used in MTask::AddToBranchList
+//
+TString MHMatrix::GetDataMember() const
+{
+    return fData ? fData->GetDataMember() : TString("");
+}
+
+// --------------------------------------------------------------------------
+//
+//
+void MHMatrix::ReduceNumberOfRows(UInt_t numrows, const TString opt)
+{
+    UInt_t rows = fM.GetNrows();
+
+    if (rows==numrows)
+    {
+        *fLog << warn << "Matrix has already the correct number of rows..." << endl;
+        return;
+    }
+
+    Float_t ratio = (Float_t)numrows/fM.GetNrows();
+
+    if (ratio>=1)
+    {
+        *fLog << warn << "Matrix cannot be enlarged..." << endl;
+        return;
+    }
+
+    Double_t sum = 0;
+
+    UInt_t oldrow = 0;
+    UInt_t newrow = 0;
+
+    TVector vold(fM.GetNcols());
+    while (oldrow<rows)
+    {
+        sum += ratio;
+
+        if (newrow<=(unsigned int)sum)
+            TMatrixRow(fM, newrow++) = vold = TMatrixRow(fM, oldrow);
+
+        oldrow++;
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+//  Used in DefRefMatrix to display the result graphically
+//
+void MHMatrix::DrawDefRefInfo(const TH1 &hth, const TH1 &hthd, const TH1 &thsh, Int_t refcolumn)
+{
+    //
+    // Fill a histogram with the distribution after raduction
+    //
+    TH1F hta;
+    hta.SetDirectory(NULL);
+    hta.SetName("hta");
+    hta.SetTitle("Distribution after reduction");
+    SetBinning(&hta, &hth);
+
+    for (Int_t i=0; i<fM.GetNrows(); i++)
+        hta.Fill(fM(i, refcolumn));
+
+    TCanvas *th1 = MakeDefCanvas(this);
+    th1->Divide(2,2);
+
+    th1->cd(1);
+    ((TH1&)hth).DrawCopy();   // real histogram before
+
+    th1->cd(2);
+    ((TH1&)hta).DrawCopy();   // histogram after
+
+    th1->cd(3);
+    ((TH1&)hthd).DrawCopy();  // correction factors
+
+    th1->cd(4);
+    ((TH1&)thsh).DrawCopy();  // target
+}
+
+// ------------------------------------------------------------------------
+//
+//  Resizes th etarget matrix to rows*source.GetNcol() and copies
+//  the data from the first (n)rows or the source into the target matrix.
+//
+void MHMatrix::CopyCrop(TMatrix &target, const TMatrix &source, Int_t rows)
+{
+    TVector v(source.GetNcols());
+
+    target.ResizeTo(rows, source.GetNcols());
+    for (Int_t ir=0; ir<rows; ir++)
+        TMatrixRow(target, ir) = v = TMatrixRow(source, ir);
+}
+
+// ------------------------------------------------------------------------
+//
+// Define the reference matrix
+//   refcolumn  number of the column (starting at 0) containing the variable,
+//              for which a target distribution may be given;
+//   thsh       histogram containing the target distribution of the variable
+//   nmaxevts   the number of events the reference matrix should have after 
+//              the renormalization
+//   rest       a TMatrix conatining the resulting (not choosen)
+//              columns of the primary matrix. Maybe NULL if you
+//              are not interested in this
+//
+Bool_t MHMatrix::DefRefMatrix(const UInt_t refcolumn, const TH1F &thsh,
+                              Int_t nmaxevts, TMatrix *rest)
+{
+    if (!fM.IsValid())
+    {
+        *fLog << err << dbginf << "Matrix not initialized" << endl;
+        return kFALSE;
+    }
+
+    if (thsh.GetMinimum()<0)
+    {
+        *fLog << err << dbginf << "Renormalization not possible: ";
+        *fLog << "Target Distribution has values < 0" << endl;
+        return kFALSE;
+    }
+
+
+    if (nmaxevts>fM.GetNrows())
+    {
+        *fLog << warn << dbginf << "No.requested (" << nmaxevts;
+        *fLog << ") > available events (" << fM.GetNrows() << ")... ";
+        *fLog << "setting equal." << endl;
+        nmaxevts = fM.GetNrows();
+    }
+
+
+    if (nmaxevts<0)
+    {
+        *fLog << err << dbginf << "Number of requested events < 0" << endl;
+        return kFALSE;
+    }
+
+    if (nmaxevts==0)
+        nmaxevts = fM.GetNrows();
+
+    //
+    // refcol is the column number starting at 0; it is >= 0
+    //
+    // number of the column (count from 0) containing
+    // the variable for which the target distribution is given
+    //
+
+    //
+    // Calculate normalization factors
+    //
+    //const int    nbins   = thsh.GetNbinsX();
+    //const double frombin = thsh.GetBinLowEdge(1);
+    //const double tobin   = thsh.GetBinLowEdge(nbins+1);
+    //const double dbin    = thsh.GetBinWidth(1);
+
+    const Int_t  nrows   = fM.GetNrows();
+    const Int_t  ncols   = fM.GetNcols();
+
+    //
+    // set up the real histogram (distribution before)
+    //
+    //TH1F hth("th", "Distribution before reduction", nbins, frombin, tobin);
+    TH1F hth;
+    hth.SetNameTitle("th", "Distribution before reduction");
+    SetBinning(&hth, &thsh);
+    hth.SetDirectory(NULL);
+    for (Int_t j=0; j<nrows; j++)
+        hth.Fill(fM(j, refcolumn));
+
+    //TH1F hthd("thd", "Correction factors", nbins, frombin, tobin);
+    TH1F hthd;
+    hthd.SetNameTitle("thd", "Correction factors");
+    SetBinning(&hthd, &thsh);
+    hthd.SetDirectory(NULL);
+    hthd.Divide((TH1F*)&thsh, &hth, 1, 1);
+
+    if (hthd.GetMaximum() <= 0)
+    {
+        *fLog << err << dbginf << "Maximum correction factor <= 0... abort." << endl;
+        return kFALSE;
+    }
+
+    //
+    // ===== obtain correction factors (normalization factors)
+    //
+    hthd.Scale(1/hthd.GetMaximum());
+
+    //
+    // get random access
+    //
+    TArrayI ind(nrows);
+    GetRandomArrayI(ind);
+
+    //
+    // define  new matrix
+    //
+    Int_t evtcount1 = -1;
+    Int_t evtcount2 =  0;
+
+    TMatrix mnewtmp(nrows, ncols);
+    TMatrix mrest(nrows, ncols);
+
+    TArrayF cumulweight(nrows); // keep track for each bin how many events
+
+    //
+    // Project values in reference column into [0,1]
+    //
+    TVector v(fM.GetNrows());
+    v = TMatrixColumn(fM, refcolumn);
+    //v += -frombin;
+    //v *= 1/dbin;
+
+    //
+    // select events (distribution after renormalization)
+    //
+    Int_t ir;
+    TVector vold(fM.GetNcols());
+    for (ir=0; ir<nrows; ir++)
+    {
+        // const Int_t indref = (Int_t)v(ind[ir]);
+        const Int_t indref = hthd.FindBin(v(ind[ir])) - 1;
+        cumulweight[indref] += hthd.GetBinContent(indref+1);
+        if (cumulweight[indref]<=0.5)
+        {
+            TMatrixRow(mrest, evtcount2++) = vold = TMatrixRow(fM, ind[ir]);
+            continue;
+        }
+
+        cumulweight[indref] -= 1.;
+        if (++evtcount1 >=  nmaxevts)
+            break;
+
+        TMatrixRow(mnewtmp, evtcount1) = vold = TMatrixRow(fM, ind[ir]);
+    }
+
+    for (/*empty*/; ir<nrows; ir++)
+        TMatrixRow(mrest, evtcount2++) = vold = TMatrixRow(fM, ind[ir]);
+
+    //
+    // reduce size
+    //
+    // matrix fM having the requested distribution
+    // and the requested number of rows;
+    // this is the matrix to be used in the g/h separation
+    //
+    CopyCrop(fM, mnewtmp, evtcount1);
+    fNumRows = evtcount1;
+
+    if (evtcount1 < nmaxevts)
+        *fLog << warn << "Reference sample contains less events (" << evtcount1 << ") than requested (" << nmaxevts << ")" << endl;
+
+    if (TestBit(kEnableGraphicalOutput))
+        DrawDefRefInfo(hth, hthd, thsh, refcolumn);
+
+    if (rest)
+        CopyCrop(*rest, mrest, evtcount2);
+
+    return kTRUE;
+}
+
+// ------------------------------------------------------------------------
+//
+// Returns a array containing randomly sorted indices
+//
+void MHMatrix::GetRandomArrayI(TArrayI &ind) const
+{
+    const Int_t rows = ind.GetSize();
+
+    TArrayF ranx(rows);
+
+    TRandom3 rnd(0);
+    for (Int_t i=0; i<rows; i++)
+        ranx[i] = rnd.Rndm(i);
+
+    TMath::Sort(rows, ranx.GetArray(), ind.GetArray(), kTRUE);
+}
+
+// ------------------------------------------------------------------------
+//
+// Define the reference matrix
+//   nmaxevts   maximum number of events in the reference matrix
+//   rest       a TMatrix conatining the resulting (not choosen)
+//              columns of the primary matrix. Maybe NULL if you
+//              are not interested in this
+//
+//              the target distribution will be set
+//              equal to the real distribution; the events in the reference
+//              matrix will then be simply a random selection of the events 
+//              in the original matrix.
+//
+Bool_t MHMatrix::DefRefMatrix(Int_t nmaxevts, TMatrix *rest)
+{
+    if (!fM.IsValid())
+    {
+        *fLog << err << dbginf << "Matrix not initialized" << endl;
+        return kFALSE;
+    }
+
+    if (nmaxevts>fM.GetNrows())
+    {
+      *fLog << dbginf << "No.of requested events (" << nmaxevts 
+            << ") exceeds no.of available events (" << fM.GetNrows() 
+            << ")" << endl;
+        *fLog << dbginf 
+              << "        set no.of requested events = no.of available events" 
+              << endl;
+        nmaxevts = fM.GetNrows();
+    }
+
+    if (nmaxevts<0)
+    {
+        *fLog << err << dbginf << "Number of requested events < 0" << endl;
+        return kFALSE;
+    }
+
+    if (nmaxevts==0)
+        nmaxevts = fM.GetNrows();
+
+    const Int_t nrows = fM.GetNrows();
+    const Int_t ncols = fM.GetNcols();
+
+    //
+    // get random access
+    //
+    TArrayI ind(nrows);
+    GetRandomArrayI(ind);
+
+    //
+    // define  new matrix
+    //
+    Int_t evtcount1 = 0;
+    Int_t evtcount2 = 0;
+
+    TMatrix mnewtmp(nrows, ncols);
+    TMatrix mrest(nrows, ncols);
+
+    //
+    // select events (distribution after renormalization)
+    //
+    TVector vold(fM.GetNcols());
+    for (Int_t ir=0; ir<nmaxevts; ir++)
+        TMatrixRow(mnewtmp, evtcount1++) = vold = TMatrixRow(fM, ind[ir]);
+
+    for (Int_t ir=nmaxevts; ir<nrows; ir++)
+        TMatrixRow(mrest, evtcount2++) = vold = TMatrixRow(fM, ind[ir]);
+
+    //
+    // reduce size
+    //
+    // matrix fM having the requested distribution
+    // and the requested number of rows;
+    // this is the matrix to be used in the g/h separation
+    //
+    CopyCrop(fM, mnewtmp, evtcount1);
+    fNumRows = evtcount1;
+
+    if (evtcount1 < nmaxevts)
+        *fLog << warn << "The reference sample contains less events (" << evtcount1 << ") than requested (" << nmaxevts << ")" << endl;
+
+    if (!rest)
+        return kTRUE;
+
+    CopyCrop(*rest, mrest, evtcount2);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// overload TOject member function read 
+// in order to reset the name of the object read
+//
+Int_t MHMatrix::Read(const char *name)
+{
+    Int_t ret = TObject::Read(name);
+    SetName(name);
+
+    return ret;
+}
+
+// --------------------------------------------------------------------------
+//
+// Read the setup from a TEnv:
+//   Column0, Column1, Column2, ..., Column10, ..., Column100, ...
+//
+// Searching stops if the first key isn't found in the TEnv. Empty
+// columns are not allowed
+//
+// eg.
+//     MHMatrix.Column0: cos(MMcEvt.fTelescopeTheta)
+//     MHMatrix.Column1: MHillasSrc.fAlpha
+//
+Bool_t MHMatrix::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
+{
+    if (fM.IsValid())
+    {
+        *fLog << err << "ERROR - matrix is already in use. Can't add a new column from TEnv... skipped." << endl;
+        return kERROR;
+    }
+
+    if (TestBit(kIsLocked))
+    {
+        *fLog << err << "ERROR - matrix is locked. Can't add new column from TEnv... skipped." << endl;
+        return kERROR;
+    }
+
+    //
+    // Search (beginning with 0) all keys
+    //
+    int i=0;
+    while (1)
+    {
+        TString idx = "Column";
+        idx += i;
+
+        // Output if print set to kTRUE
+        if (!IsEnvDefined(env, prefix, idx, print))
+            break;
+
+        // Try to get the file name
+        TString name = GetEnvValue(env, prefix, idx, "");
+        if (name.IsNull())
+        {
+            *fLog << warn << prefix+"."+idx << " empty." << endl;
+            continue;
+        }
+
+        if (i==0)
+            if (fData)
+            {
+                *fLog << inf << "Removing all existing columns in " << GetDescriptor() << endl;
+                fData->Delete();
+            }
+            else
+            {
+                fData = new MDataArray;
+                SetBit(kIsOwner);
+            }
+
+        fData->AddEntry(name);
+        i++;
+    }
+
+    return i!=0;
+}
+
+// --------------------------------------------------------------------------
+//
+// ShuffleEvents. Shuffles the order of the matrix rows.
+// 
+//
+void MHMatrix::ShuffleRows(UInt_t seed)
+{
+    TRandom rnd(seed);
+
+    TVector v(fM.GetNcols());
+    TVector tmp(fM.GetNcols());
+    for (Int_t irow = 0; irow<fNumRows; irow++)
+    {
+        const Int_t jrow = rnd.Integer(fNumRows);
+
+        v = TMatrixRow(fM, irow);
+        TMatrixRow(fM, irow) = tmp = TMatrixRow(fM, jrow);
+        TMatrixRow(fM, jrow) = v;
+    }
+
+    *fLog << warn << GetDescriptor() << ": Attention! Matrix rows have been shuffled." << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Reduces the number of rows to the given number num by cutting out the
+// last rows.
+//
+void MHMatrix::ReduceRows(UInt_t num)
+{
+    if ((Int_t)num>=fM.GetNrows())
+    {
+        *fLog << warn << GetDescriptor() << ": Warning - " << num << " >= rows=" << fM.GetNrows() << endl;
+        return;
+    }
+
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,05,07)
+    const TMatrix m(fM);
+#endif
+    fM.ResizeTo(num, fM.GetNcols());
+
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,05,07)
+    TVector tmp(fM.GetNcols());
+    for (UInt_t irow=0; irow<num; irow++)
+        TMatrixRow(fM, irow) = tmp = TMatrixRow(m, irow);
+#endif
+}
+
+// --------------------------------------------------------------------------
+//
+// Remove rows which contains numbers not fullfilling TMath::Finite
+//
+Bool_t MHMatrix::RemoveInvalidRows()
+{
+    TMatrix m(fM);
+
+    const Int_t ncol=fM.GetNcols();
+    TVector vold(ncol);
+    int irow=0;
+
+    for (int i=0; i<m.GetNrows(); i++)
+    {
+        const TMatrixRow &row = TMatrixRow(m, i);
+
+        // finite (-> math.h) checks for NaN as well as inf
+        int jcol;
+        for (jcol=0; jcol<ncol; jcol++)
+            if (!TMath::Finite(vold(jcol)))
+                break;
+
+        if (jcol==ncol)
+            TMatrixRow(fM, irow++) = vold = row;
+        else
+            *fLog << warn << "Warning - MHMatrix::RemoveInvalidRows: row #" << i<< " removed." << endl;
+    }
+
+    // Do not use ResizeTo (in older root versions this doesn't save the contents
+    ReduceRows(irow);
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mhbase/MHMatrix.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhbase/MHMatrix.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhbase/MHMatrix.h	(revision 9661)
@@ -0,0 +1,124 @@
+#ifndef MARS_MHMatrix
+#define MARS_MHMatrix
+
+#ifdef MARS_MLogManip
+#error Please make ensure that MLogManip.h are included _after_ MHMatrix.h
+#endif
+
+#ifndef ROOT_TMatrix
+#include <TMatrix.h>
+#endif
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+#include <TArrayF.h>
+
+class TArrayI;
+class TArrayF;
+
+class TH1F;
+class MTask;
+class MParList;
+class MDataArray;
+class MFilter;
+
+class MHMatrix : public MH
+{
+private:
+    static const TString gsDefName;  //! Default Name
+    static const TString gsDefTitle; //! Default Title
+
+    Int_t   fNumRows;   //! Number of rows filled into the matrix (this is NOT the number of rows of the matrix!)
+    Int_t   fRow;       //! Present row
+    TMatrix fM;         // Matrix to be filled
+
+    TMatrix fM2;        //! Covariance Matrix
+
+    MDataArray *fData;  // List of data members (columns)
+
+
+    enum {
+        kIsOwner  = BIT(14),
+        kIsLocked = BIT(17)
+    };
+
+    void AddRow();
+
+    Bool_t SetupFill(const MParList *pList);
+
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+    Bool_t Finalize();
+
+    void DrawDefRefInfo(const TH1 &hth, const TH1 &hthd, const TH1 &thsh, Int_t refcolumn);
+    void GetRandomArrayI(TArrayI &ind) const;
+
+    void StreamPrimitive(ofstream &out) const;
+
+public:
+    MHMatrix(const char *name=NULL, const char *title=NULL);
+    MHMatrix(MDataArray *mat, const char *name=NULL, const char *title=NULL);
+    MHMatrix(const TMatrix &m, const char *name=NULL, const char *title=NULL);
+    ~MHMatrix();
+
+    static void CopyCrop(TMatrix &target, const TMatrix &source, Int_t rows);
+
+    void Lock()   { SetBit(kIsLocked); }
+    void Unlock() { ResetBit(kIsLocked); }
+
+    Int_t AddColumn(const char *name);
+    void AddColumns(MDataArray *mat);
+
+    MDataArray *GetColumns() { return fData; }
+
+    const TMatrix &GetM() const { return fM; }
+
+    Bool_t IsValid() const { return fM.IsValid(); }
+    Int_t  GetNumRows() const { return fM.GetNrows(); }
+
+    //void Draw(Option_t *opt=NULL);
+    //TObject *DrawClone(Option_t *opt=NULL) const;
+
+    void Print(Option_t *) const;
+
+    const TMatrix *InvertPosDef();
+
+    Double_t CalcDist(const TMatrix &m, const TVector &v, Int_t num = 25) const;
+    Double_t CalcDist(const TVector &v, Int_t num = 25);
+
+    void SetOwner(Bool_t b=kTRUE) { b ? SetBit(kIsOwner) : ResetBit(kIsOwner); }
+
+    void Reassign();
+
+    const TArrayI GetIndexOfSortedColumn(Int_t ncol=0, Bool_t desc=kTRUE) const;
+    void SortMatrixByColumn(Int_t ncol=0, Bool_t desc=kTRUE);
+
+    Bool_t SetNumRow(Int_t row); 
+ 
+    Int_t GetNumRow() const { return fRow; };
+    Double_t operator[](Int_t col) { return fM(fRow, col); }
+
+    Bool_t Fill(MParList *plist, MTask *read, MFilter *filter=NULL);
+
+    TString GetDataMember() const;
+
+    void ReduceNumberOfRows(UInt_t numrows, const TString opt);
+    Bool_t RemoveInvalidRows();
+
+    Int_t Read(const char *name);
+
+    Bool_t DefRefMatrix(const UInt_t refcolumn, const TH1F &thsh,
+                        Int_t nmaxevts=0, TMatrix *mrest=NULL);
+    Bool_t DefRefMatrix(Int_t nmaxevts=0, TMatrix *mrest=NULL);
+
+    Bool_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
+
+    void ShuffleRows(UInt_t seed);
+    void ReduceRows(UInt_t num);
+
+    ClassDef(MHMatrix, 1) // Multidimensional Matrix to store events
+};
+
+#endif
+
+
Index: /tags/Mars_V0-8-5/Mars/mhbase/MWeight.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhbase/MWeight.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhbase/MWeight.cc	(revision 9661)
@@ -0,0 +1,35 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  04/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//   MWeight
+//
+//   Storage container for a weight to fill histograms
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MWeight.h"
+
+ClassImp(MWeight);
+
Index: /tags/Mars_V0-8-5/Mars/mhbase/MWeight.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhbase/MWeight.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhbase/MWeight.h	(revision 9661)
@@ -0,0 +1,32 @@
+#ifndef MARS_MWeight
+#define MARS_MWeight
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//  MWeight                                                                //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MWeight : public MParContainer
+{
+private:
+    Double_t fWeight;
+
+public:
+    MWeight(const char *name=NULL, const char *title=NULL) : fWeight(1)
+    {
+        fName  = name  ? name  : "MWeight";
+        fTitle = title ? title : "A weight for filling histograms";
+    }
+
+    void SetWeight(Double_t weight) { fWeight = weight; }
+    Double_t GetWeight() const { return fWeight; }
+
+    ClassDef(MWeight, 1) // A weight for filling histograms
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mhbase/Makefile
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhbase/Makefile	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhbase/Makefile	(revision 9661)
@@ -0,0 +1,37 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#------------------------------------------------------------------------------
+
+#
+# Handling name of the Root Dictionary Files
+#
+CINT  = HBase
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES = -I. -I../mbase -I../mdata
+
+SRCFILES = MFillH.cc \
+           MBinning.cc \
+           MWeight.cc \
+           MH.cc \
+           MH3.cc \
+           MHArray.cc \
+           MHMatrix.cc
+
+############################################################
+
+all: $(OBJS)
+
+include ../Makefile.rules
+
+mrproper:	clean rmbak
Index: /tags/Mars_V0-8-5/Mars/mhist/HistIncl.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/HistIncl.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/HistIncl.h	(revision 9661)
@@ -0,0 +1,6 @@
+#ifndef __CINT__
+
+#include <TF1.h>
+#include <TArrayI.h>
+
+#endif // __CINT__
Index: /tags/Mars_V0-8-5/Mars/mhist/HistLinkDef.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/HistLinkDef.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/HistLinkDef.h	(revision 9661)
@@ -0,0 +1,42 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class MHFadcCam+;
+#pragma link C++ class MHFadcPix+;
+
+#pragma link C++ class MHEvent+;
+#pragma link C++ class MHCamEvent+;
+#pragma link C++ class MHTriggerLvl0+;
+
+#pragma link C++ class MHStarMap+;
+#pragma link C++ class MHEnergyTime+;
+#pragma link C++ class MHEnergyTheta+;
+#pragma link C++ class MHAlphaEnergyTime+;
+#pragma link C++ class MHAlphaEnergyTheta+;
+#pragma link C++ class MHGamma+;
+#pragma link C++ class MHFlux;
+#pragma link C++ class MHEffOnTime+;
+#pragma link C++ class MHTimeDiffTime+;
+#pragma link C++ class MHTimeDiffTheta+;
+#pragma link C++ class MHThetabarTime+;
+#pragma link C++ class MHThetabarTheta+;
+#pragma link C++ class MHSigmabarTheta+;
+#pragma link C++ class MHSigmaPixel+;
+#pragma link C++ class MHOnSubtraction+;
+#pragma link C++ class MHFindSignificance+;
+#pragma link C++ class MHCT1Supercuts+;
+#pragma link C++ class MHSupercuts+;
+
+#pragma link C++ class MHCompProb+;
+#pragma link C++ class MHHadronness+;    
+
+#pragma link C++ class MHCamera+;
+
+#pragma link C++ class MHAlpha+;
+#pragma link C++ class MHFalseSource+;
+#pragma link C++ class MHCamEventRot+;
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mhist/MHAlpha.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHAlpha.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHAlpha.cc	(revision 9661)
@@ -0,0 +1,563 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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, 3/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// MHAlpha
+//
+// Create a single Alpha-Plot. The alpha-plot is fitted online. You can
+// check the result when it is filles in the MStatusDisplay
+// For more information see MHFalseSource::FitSignificance
+//
+// For convinience (fit) the output significance is stored in a
+// container in the parlisrt
+//
+// PRELIMINARY!
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MHAlpha.h"
+
+#include <TF1.h>
+#include <TH2.h>
+#include <TGraph.h>
+#include <TStyle.h>
+#include <TCanvas.h>
+#include <TPaveText.h>
+#include <TStopwatch.h>
+
+#include "MGeomCam.h"
+#include "MSrcPosCam.h"
+#include "MHillasSrc.h"
+#include "MTime.h"
+#include "MObservatory.h"
+#include "MPointingPos.h"
+#include "MAstroSky2Local.h"
+#include "MStatusDisplay.h"
+#include "MParameters.h"
+#include "MHMatrix.h"
+
+#include "MBinning.h"
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHAlpha);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor
+//
+MHAlpha::MHAlpha(const char *name, const char *title)
+    : fAlphaCut(12.5), fBgMean(55), fResult(0), fMatrix(0)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHAlpha";
+    fTitle = title ? title : "Alpha plot";
+
+    fHist.SetDirectory(NULL);
+
+    fHist.SetName("Alpha");
+    fHist.SetTitle("Alpha");
+    fHist.SetXTitle("|\\alpha| [\\circ]");
+    fHist.SetYTitle("Counts");
+    fHist.UseCurrentStyle();
+
+    MBinning binsa;
+    binsa.SetEdges(18, 0, 90);
+    binsa.Apply(fHist);
+
+    fSigInt=15;
+    fSigMax=75;
+    fBgMin=45;
+    fBgMax=90;
+    fPolynom=1;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculate Significance as
+// significance = (s-b)/sqrt(s+k*k*b) mit k=s/b
+// 
+Double_t MHAlpha::Significance(Double_t s, Double_t b)
+{
+    const Double_t k = b==0 ? 0 : s/b;
+    const Double_t f = s+k*k*b;
+
+    return f==0 ? 0 : (s-b)/TMath::Sqrt(f);
+}
+
+Bool_t MHAlpha::SetupFill(const MParList *pl)
+{
+    fHist.Reset();
+
+    fResult = (MParameterD*)pl->FindObject("Significance", "MParameterD");
+    if (!fResult)
+        *fLog << warn << "Significance [MParameterD] not found... ignored." << endl;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the histogram. For details see the code or the class description
+// 
+Bool_t MHAlpha::Fill(const MParContainer *par, const Stat_t w)
+{
+    Double_t alpha;
+
+    if (fMatrix)
+        alpha = (*fMatrix)[fMap];
+    else
+    {
+        const MHillasSrc *hil = dynamic_cast<const MHillasSrc*>(par);
+        if (!par)
+            return kFALSE;
+
+        alpha = hil->GetAlpha();
+    }
+
+    fHist.Fill(TMath::Abs(alpha), w);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Update the projections
+//
+void MHAlpha::Paint(Option_t *opt)
+{
+    Float_t sigint=fSigInt;
+    Float_t sigmax=fSigMax;
+    Float_t bgmin =fBgMin;
+    Float_t bgmax =fBgMax;
+    Byte_t polynom=fPolynom;
+
+    // Implementing the function yourself is only about 5% faster
+    TF1 func("", Form("gaus(0) + pol%d(3)", polynom), 0, 90);
+    //TF1 func("", Form("[0]*(TMath::Gaus(x, [1], [2])+TMath::Gaus(x, -[1], [2]))+pol%d(3)", polynom), 0, 90);
+    TArrayD maxpar(func.GetNpar());
+
+    func.FixParameter(1, 0);
+    func.FixParameter(4, 0);
+    func.SetParLimits(2, 0, 90);
+    func.SetParLimits(3, -1, 1);
+
+    TH1 *h=&fHist;
+    //const Double_t alpha0 = h->GetBinContent(1);
+    //const Double_t alphaw = h->GetXaxis()->GetBinWidth(1);
+
+    // Check for the regios which is not filled...
+    const Double_t alpha0 = h->GetBinContent(1);
+    if (alpha0==0)
+        return;
+
+    // First fit a polynom in the off region
+    func.FixParameter(0, 0);
+    func.FixParameter(2, 1);
+    func.ReleaseParameter(3);
+
+    for (int i=5; i<func.GetNpar(); i++)
+        func.ReleaseParameter(i);
+
+    //h->Fit(&func, "N0Q", "", bgmin, bgmax);
+    h->Fit(&func, "N0Q", "", bgmin, bgmax);
+    func.SetRange(0, 90);
+    func.SetLineColor(kRed);
+    func.Paint("same");
+
+    //h4a.Fill(func.GetChisquare());
+    //h5a.Fill(func.GetProb());
+
+    func.ReleaseParameter(0);
+    //func.ReleaseParameter(1);
+    func.ReleaseParameter(2);
+    func.FixParameter(3, func.GetParameter(3));
+    for (int i=5; i<func.GetNpar(); i++)
+        func.FixParameter(i, func.GetParameter(i));
+
+    // Do not allow signals smaller than the background
+    const Double_t A  = alpha0-func.GetParameter(3);
+    const Double_t dA = TMath::Abs(A);
+    func.SetParLimits(0, -dA*4, dA*4);
+    func.SetParLimits(2, 0, 90);
+
+    // Now fit a gaus in the on region on top of the polynom
+    func.SetParameter(0, A);
+    func.SetParameter(2, sigmax*0.75);
+
+    //h->Fit(&func, "N0Q", "", 0, sigmax);
+    h->Fit(&func, "N0Q", "", 0, sigmax);
+    func.SetLineColor(kGreen);
+    func.Paint("same");
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw the histogram
+//
+void MHAlpha::Draw(Option_t *opt)
+{
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    fHist.Draw();
+
+    AppendPad("");
+}
+
+// --------------------------------------------------------------------------
+//
+// This is a preliminary implementation of a alpha-fit procedure for
+// all possible source positions. It will be moved into its own
+// more powerfull class soon.
+//
+// The fit function is "gaus(0)+pol2(3)" which is equivalent to:
+//   [0]*exp(-0.5*((x-[1])/[2])^2) + [3] + [4]*x + [5]*x^2
+// or
+//   A*exp(-0.5*((x-mu)/sigma)^2) + a + b*x + c*x^2
+//
+// Parameter [1] is fixed to 0 while the alpha peak should be
+// symmetric around alpha=0.
+//
+// Parameter [4] is fixed to 0 because the first derivative at
+// alpha=0 should be 0, too.
+//
+// In a first step the background is fitted between bgmin and bgmax,
+// while the parameters [0]=0 and [2]=1 are fixed.
+//
+// In a second step the signal region (alpha<sigmax) is fittet using
+// the whole function with parameters [1], [3], [4] and [5] fixed.
+//
+// The number of excess and background events are calculated as
+//   s = int(0, sigint, gaus(0)+pol2(3))
+//   b = int(0, sigint,         pol2(3))
+//
+// The Significance is calculated using the Significance() member
+// function.
+//
+Bool_t MHAlpha::Finalize()
+{
+    //*fLog << dbg << "Fitting..." << endl;
+
+    Float_t sigint=fSigInt;
+    Float_t sigmax=fSigMax;
+    Float_t bgmin=fBgMin;
+    Float_t bgmax=fBgMax;
+    Byte_t polynom=fPolynom;
+
+    //                      xmin, xmax, npar
+    //TF1 func("MyFunc", fcn, 0, 90, 6);
+    // Implementing the function yourself is only about 5% faster
+    TF1 func("", Form("gaus(0) + pol%d(3)", polynom), 0, 90);
+    TArrayD maxpar(func.GetNpar());
+
+    //*fLog << "Setup pars..." << endl;
+
+    func.FixParameter(1, 0);
+    func.FixParameter(4, 0);
+    func.SetParLimits(2, 0, 90);
+    func.SetParLimits(3, -1, 1);
+
+    //    TStopwatch clk;
+    //    clk.Start();
+   /*
+    *fLog << inf;
+    *fLog << "Signal fit:     alpha < " << sigmax << endl;
+    *fLog << "Integration:    alpha < " << sigint << endl;
+    *fLog << "Background fit: " << bgmin << " < alpha < " << bgmax << endl;
+    *fLog << "Polynom order:  " << (int)polynom << endl;
+    *fLog << "Fitting False Source Plot..." << flush;
+    */
+    TH1 *h=&fHist;
+    const Double_t alpha0 = h->GetBinContent(1);
+    const Double_t alphaw = h->GetXaxis()->GetBinWidth(1);
+
+    // Check for the regios which is not filled...
+    if (alpha0==0)
+    {
+        *fLog << warn << "Histogram empty." << endl;
+        return kTRUE;
+    }
+
+    // First fit a polynom in the off region
+    func.FixParameter(0, 0);
+    func.FixParameter(2, 1);
+    func.ReleaseParameter(3);
+
+    //*fLog << "Release pars..." << endl;
+
+    for (int i=5; i<func.GetNpar(); i++)
+        func.ReleaseParameter(i);
+
+    //*fLog << dbg << "Fit 1" << endl;
+    //h->Fit(&func, "N0Q", "", bgmin, bgmax);
+    h->Fit(&func, "N0Q", "", bgmin, bgmax);
+    //*fLog << dbg << ix << "/" << iy << ":  " << func.GetParameter(3) << "    " << func.GetParameter(4) << endl;
+
+    //h4a.Fill(func.GetChisquare());
+    //h5a.Fill(func.GetProb());
+
+    //func.SetParLimits(0, 0.5*h->GetBinContent(1), 1.5*h->GetBinContent(1));
+    //func.SetParLimits(2, 5, 90);
+
+    //*fLog << dbg << "Change params..." << endl;
+
+    func.ReleaseParameter(0);
+    //func.ReleaseParameter(1);
+    func.ReleaseParameter(2);
+    func.FixParameter(3, func.GetParameter(3));
+    for (int i=5; i<func.GetNpar(); i++)
+        func.FixParameter(i, func.GetParameter(i));
+
+    // Do not allow signals smaller than the background
+    const Double_t A  = alpha0-func.GetParameter(3);
+    const Double_t dA = TMath::Abs(A);
+    func.SetParLimits(0, -dA*4, dA*4);
+    func.SetParLimits(2, 0, 90);
+
+    // Now fit a gaus in the on region on top of the polynom
+    func.SetParameter(0, A);
+    func.SetParameter(2, sigmax*0.75);
+
+    //*fLog << dbg << "Fit 2..." << endl;
+    //h->Fit(&func, "N0Q", "", 0, sigmax);
+    h->Fit(&func, "N0Q", "", 0, sigmax);
+    //*fLog << dbg << "     " << func.GetParameter(0) << "    " << func.GetParameter(1) << "    " << func.GetParameter(2) << endl;
+
+    //*fLog << dbg << "Copy par..." << endl;
+    TArrayD p(func.GetNpar(), func.GetParameters());
+
+    // Fill results into some histograms
+    /*
+    h0a.Fill(p[0]);
+    h0b.Fill(p[3]);
+    h1.Fill(p[1]);
+    h2.Fill(p[2]);
+    if (polynom>1)
+        h3.Fill(p[5]);
+    h4b.Fill(func.GetChisquare());
+    //h5b.Fill(func.GetProb());
+    */
+    // Implementing the integral as analytical function
+    // gives the same result in the order of 10e-5
+    // and it is not faster at all...
+
+    //*fLog << dbg << "Int1 par..." << endl;
+    const Double_t s = func.Integral(0, sigint)/alphaw;
+
+    func.SetParameter(0, 0);
+    //func.SetParameter(2, 1);
+
+    //*fLog << dbg << "Int2 par..." << endl;
+    const Double_t b   = func.Integral(0, sigint)/alphaw;
+    const Double_t sig = Significance(s, b);
+
+    //*fLog << dbg << "Set Val "<<sig<<" ..." << fResult << endl;
+    if (fResult)
+        fResult->SetVal(sig);
+
+    *fLog << inf << "Found Significance: " << sig << "  (width=";
+    *fLog << func.GetParameter(2) << "°, excess=" << s-b << ")" << endl;
+
+    //*fLog << dbg << "Done." << endl;
+    return kTRUE;
+    /*
+    if (sig!=0)
+        h6.Fill(sig);
+
+    if (sig<maxs)
+    {
+        maxs = sig;
+        maxx = ix;
+        maxy = iy;
+        maxpar = p;
+        }
+       */
+/*
+
+    *fLog << inf << "done." << endl;
+
+    h0a.GetXaxis()->SetRangeUser(0, maxalpha0*1.5);
+    h0b.GetXaxis()->SetRangeUser(0, maxalpha0*1.5);
+
+    //hists->SetMinimum(GetMinimumGT(*hists));
+    histb->SetMinimum(GetMinimumGT(*histb));
+
+//    clk.Stop();
+//    clk.Print();
+    TCanvas *c=new TCanvas;
+
+    c->Divide(3,2, 0, 0);
+    c->cd(1);
+    gPad->SetBorderMode(0);
+    hists->Draw("colz");
+    hists->SetBit(kCanDelete);
+    c->cd(2);
+    gPad->SetBorderMode(0);
+    hist->Draw("colz");
+    hist->SetBit(kCanDelete);
+    c->cd(3);
+    gPad->SetBorderMode(0);
+    histb->Draw("colz");
+    histb->SetBit(kCanDelete);
+    c->cd(4);
+    gPad->Divide(1,3, 0, 0);
+    TVirtualPad *p=gPad;
+    p->SetBorderMode(0);
+    p->cd(1);
+    gPad->SetBorderMode(0);
+    h0b.DrawCopy();
+    h0a.DrawCopy("same");
+    p->cd(2);
+    gPad->SetBorderMode(0);
+    h3.DrawCopy();
+    p->cd(3);
+    gPad->SetBorderMode(0);
+    h2.DrawCopy();
+    c->cd(6);
+    gPad->Divide(1,2, 0, 0);
+    TVirtualPad *q=gPad;
+    q->SetBorderMode(0);
+    q->cd(1);
+    gPad->SetBorderMode(0);
+    gPad->SetBorderMode(0);
+    h4b.DrawCopy();
+    h4a.DrawCopy("same");
+    h6.DrawCopy("same");
+    q->cd(2);
+    gPad->SetBorderMode(0);
+    //h5b.DrawCopy();
+    //h5a.DrawCopy("same");
+    c->cd(5);
+    gPad->SetBorderMode(0);
+    if (maxx>0 && maxy>0)
+    {
+        const char *title = Form(" \\alpha for x=%.2f y=%.2f (\\sigma_{max}=%.1f) ",
+                                 fHist.GetXaxis()->GetBinCenter(maxx),
+                                 fHist.GetYaxis()->GetBinCenter(maxy), maxs);
+
+        TH1 *result = fHist.ProjectionZ("AlphaFit", maxx, maxx, maxy, maxy);
+        result->SetDirectory(NULL);
+        result->SetNameTitle("Result \\alpha", title);
+        result->SetBit(kCanDelete);
+        result->SetXTitle("\\alpha [\\circ]");
+        result->SetYTitle("Counts");
+        result->Draw();
+
+        TF1 f1("", func.GetExpFormula(), 0, 90);
+        TF1 f2("", func.GetExpFormula(), 0, 90);
+        f1.SetParameters(maxpar.GetArray());
+        f2.SetParameters(maxpar.GetArray());
+        f2.FixParameter(0, 0);
+        f2.FixParameter(1, 0);
+        f2.FixParameter(2, 1);
+        f1.SetLineColor(kGreen);
+        f2.SetLineColor(kRed);
+
+        f2.DrawCopy("same");
+        f1.DrawCopy("same");
+
+        TPaveText *leg = new TPaveText(0.35, 0.10, 0.90, 0.35, "brNDC");
+        leg->SetBorderSize(1);
+        leg->SetTextSize(0.04);
+        leg->AddText(0.5, 0.82, Form("A * exp(-(\\frac{x-\\mu}{\\sigma})^{2}/2) + pol%d", polynom))->SetTextAlign(22);
+        //leg->AddText(0.5, 0.82, "A * exp(-(\\frac{x-\\mu}{\\sigma})^{2}/2) + b*x^{2} + a")->SetTextAlign(22);
+        leg->AddLine(0, 0.65, 0, 0.65);
+        leg->AddText(0.06, 0.54, Form("A=%.2f", maxpar[0]))->SetTextAlign(11);
+        leg->AddText(0.06, 0.34, Form("\\sigma=%.2f", maxpar[2]))->SetTextAlign(11);
+        leg->AddText(0.06, 0.14, Form("\\mu=%.2f (fix)", maxpar[1]))->SetTextAlign(11);
+        leg->AddText(0.60, 0.54, Form("a=%.2f", maxpar[3]))->SetTextAlign(11);
+        leg->AddText(0.60, 0.34, Form("b=%.2f (fix)", maxpar[4]))->SetTextAlign(11);
+        if (polynom>1)
+            leg->AddText(0.60, 0.14, Form("c=%.2f", maxpar[5]))->SetTextAlign(11);
+        leg->SetBit(kCanDelete);
+        leg->Draw();
+
+        q->cd(2);
+
+        TGraph *g = new TGraph;
+        g->SetPoint(0, 0, 0);
+
+        Int_t max=0;
+        Float_t maxsig=0;
+        for (int i=1; i<89; i++)
+        {
+            const Double_t s = f1.Integral(0, (float)i);
+            const Double_t b = f2.Integral(0, (float)i);
+
+            const Double_t sig = Significance(s, b);
+
+            g->SetPoint(g->GetN(), i, sig);
+
+            if (sig>maxsig)
+            {
+                max = i;
+                maxsig = sig;
+            }
+        }
+
+        g->SetNameTitle("SigVs\\alpha", "Significance vs \\alpha");
+        g->GetHistogram()->SetXTitle("\\alpha_{0} [\\circ]");
+        g->GetHistogram()->SetYTitle("Significance");
+        g->SetBit(kCanDelete);
+        g->Draw("AP");
+
+        leg = new TPaveText(0.35, 0.10, 0.90, 0.25, "brNDC");
+        leg->SetBorderSize(1);
+        leg->SetTextSize(0.1);
+        leg->AddText(Form("\\sigma_{max}=%.1f at \\alpha_{max}=%d\\circ", maxsig, max));
+        leg->SetBit(kCanDelete);
+        leg->Draw();
+    }*/
+}
+
+// --------------------------------------------------------------------------
+//
+// You can use this function if you want to use a MHMatrix instead of
+// MMcEvt. This function adds all necessary columns to the
+// given matrix. Afterward you should fill the matrix with the corresponding
+// data (eg from a file by using MHMatrix::Fill). If you now loop
+// through the matrix (eg using MMatrixLoop) MHHadronness::Fill
+// will take the values from the matrix instead of the containers.
+//
+void MHAlpha::InitMapping(MHMatrix *mat)
+{
+    if (fMatrix)
+        return;
+
+    fMatrix = mat;
+
+    fMap = fMatrix->AddColumn("MHillasSrc.fAlpha");
+}
+
+void MHAlpha::StopMapping()
+{
+    fMatrix = NULL; 
+}
Index: /tags/Mars_V0-8-5/Mars/mhist/MHAlpha.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHAlpha.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHAlpha.h	(revision 9661)
@@ -0,0 +1,53 @@
+#ifndef MARS_MHAlpha
+#define MARS_MHAlpha
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+#ifndef ROOT_TH1
+#include <TH1.h>
+#endif
+
+class MParList;
+class MParameterD;
+class MHMatrix;
+
+class MHAlpha : public MH
+{
+private:
+    Float_t fAlphaCut;        // Alpha cut
+    Float_t fBgMean;          // Background mean
+
+    Float_t fSigInt;
+    Float_t fSigMax;
+    Float_t fBgMin;
+    Float_t fBgMax;
+    Int_t   fPolynom;
+
+    TH1D    fHist;            // Alpha vs. x and y
+
+    MParameterD *fResult;
+
+    MHMatrix *fMatrix;        //!
+    Int_t fMap;               //!
+
+public:
+    MHAlpha(const char *name=NULL, const char *title=NULL);
+
+    Bool_t SetupFill(const MParList *pl);
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+    Bool_t Finalize();
+
+    void Paint(Option_t *opt="");
+    void Draw(Option_t *option="");
+
+    void InitMapping(MHMatrix *mat);
+    void StopMapping();
+
+    static Double_t Significance(Double_t s, Double_t b);
+
+    ClassDef(MHAlpha, 1) // Alpha-Plot which is fitted online
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mhist/MHAlphaEnergyTheta.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHAlphaEnergyTheta.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHAlphaEnergyTheta.cc	(revision 9661)
@@ -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): Thomas Bretz    1/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Wolfgang Wittek 1/2002 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MHAlphaEnergyTheta                                                      //
+//                                                                          //
+//  3D-histogram in alpha, E-est and Theta                                  //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MHAlphaEnergyTheta.h"
+
+#include <TCanvas.h>
+
+#include <math.h>
+
+#include "MMcEvt.hxx"
+#include "MHillasSrc.h"
+#include "MEnergyEst.h"
+
+#include "MBinning.h"
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHAlphaEnergyTheta);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// 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* binsalphaflux  = (MBinning*)plist->FindObject("BinningAlphaFlux");
+   MBinning* binstheta  = (MBinning*)plist->FindObject("BinningTheta");
+   if (!binsenergy || !binsalphaflux || !binstheta)
+   {
+       *fLog << err << dbginf << "At least one MBinning not found... aborting." << endl;
+       return kFALSE;      
+   }
+
+   SetBinning(&fHist, binsalphaflux, binsenergy, binstheta);
+
+   fHist.Sumw2(); 
+
+   return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the histogram
+// 
+Bool_t MHAlphaEnergyTheta::Fill(const MParContainer *par, const Stat_t w)
+{
+    MHillasSrc &hil = *(MHillasSrc*)par;
+
+    fHist.Fill(hil.GetAlpha(), fEnergy->GetEnergy(),
+               fMcEvt->GetTelescopeTheta()*kRad2Deg, w);
+    
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw the histogram
+// 
+void MHAlphaEnergyTheta::Draw(Option_t *opt)
+{
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    AppendPad("");
+
+    pad->Divide(2,2);
+
+    TH1 *h;
+
+    pad->cd(1);
+    gPad->SetBorderMode(0);
+    h = fHist.Project3D("expro");
+    h->SetTitle("Distribution of \\alpha [\\circ]");
+    h->SetXTitle("\\alpha [\\circ]");
+    h->SetYTitle("Counts");
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
+
+    pad->cd(2);
+    gPad->SetBorderMode(0);
+    gPad->SetLogx();
+    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);
+
+    pad->cd(3);
+    gPad->SetBorderMode(0);
+    h = fHist.Project3D("ezpro");
+    h->SetTitle("Distribution of \\Theta [\\circ]");
+    h->SetXTitle("\\Theta [\\circ]");
+    h->SetYTitle("Counts");
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
+
+    pad->cd(4);
+    gPad->SetBorderMode(0);
+    fHist.Draw(opt);
+
+    pad->Modified();
+    pad->Update();
+}
Index: /tags/Mars_V0-8-5/Mars/mhist/MHAlphaEnergyTheta.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHAlphaEnergyTheta.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHAlphaEnergyTheta.h	(revision 9661)
@@ -0,0 +1,42 @@
+#ifndef MARS_MHAlphaEnergyTheta
+#define MARS_MHAlphaEnergyTheta
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+#ifndef ROOT_TH3
+#include <TH3.h>
+#endif
+
+class MMcEvt;
+class MHillasSrc;
+class MEnergyEst;
+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);
+
+    Bool_t SetupFill(const MParList *pList);
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+
+    const TH3D *GetHist()       { return &fHist; }
+    const TH3D *GetHist() const { return &fHist; }
+
+    TH1 *GetHistByName(const TString name) { return &fHist; }
+
+    void Draw(Option_t *option="");
+
+    ClassDef(MHAlphaEnergyTheta, 0) //3D-histogram in alpha, Energy and theta
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mhist/MHAlphaEnergyTime.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHAlphaEnergyTime.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHAlphaEnergyTime.cc	(revision 9661)
@@ -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    1/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Wolfgang Wittek 1/2002 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MHAlphaEnergyTime                                                       //
+//                                                                          //
+//  3D-histogram in alpha, E-est and time                                   //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MHAlphaEnergyTime.h"
+
+#include <TCanvas.h>
+
+#include <math.h>
+
+#include "MHillasSrc.h"
+#include "MEnergyEst.h"
+#include "MTime.h"
+
+#include "MBinning.h"
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHAlphaEnergyTime);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor. It sets name and title of the histogram. 
+//
+MHAlphaEnergyTime::MHAlphaEnergyTime(const char *name, const char *title) 
+  : fHist()
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHAlphaEnergyTime";
+    fTitle = title ? title : "3-D histogram in alpha, energy and time";
+
+    fHist.SetDirectory(NULL);
+
+    fHist.SetTitle("3D-plot of alpha, E-est, time");
+    fHist.SetXTitle("\\alpha [\\circ]");
+    fHist.SetYTitle("E-est [GeV]            ");
+    fHist.SetZTitle("time [s]");
+}
+
+// --------------------------------------------------------------------------
+//
+// Set binnings and prepare filling of the histogram
+// 
+Bool_t MHAlphaEnergyTime::SetupFill(const MParList *plist)
+{
+   fEnergy = (MEnergyEst*)plist->FindObject("MEnergyEst");
+   if (!fEnergy)
+   {
+       *fLog << err << dbginf << "MHAlphaEnergyTime : MEnergyEst not found... aborting." << endl;
+       return kFALSE;
+   }
+
+   fTime = (MTime*)plist->FindObject("MTime");
+   if (!fTime)
+   {
+       *fLog << err << dbginf << "MHAlphaEnergyTime : MTime not found... aborting." << endl;
+       return kFALSE;
+   }
+
+   MBinning* binsenergy = (MBinning*)plist->FindObject("BinningE");
+   MBinning* binsalphaflux  = (MBinning*)plist->FindObject("BinningAlphaFlux");
+   MBinning* binstime   = (MBinning*)plist->FindObject("BinningTime");
+   if (!binsenergy || !binsalphaflux || !binstime)
+   {
+       *fLog << err << dbginf << "MHAlphaEnergyTime : At least one MBinning not found... aborting." << endl;
+       return kFALSE;      
+   }
+
+   SetBinning(&fHist, binsalphaflux, binsenergy, binstime);
+
+   fHist.Sumw2();
+
+   return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the histogram
+// 
+Bool_t MHAlphaEnergyTime::Fill(const MParContainer *par, const Stat_t w)
+{
+    MHillasSrc &hil = *(MHillasSrc*)par;
+
+    fHist.Fill(fabs(hil.GetAlpha()), fEnergy->GetEnergy(), *fTime, w);
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw the histogram
+// 
+void MHAlphaEnergyTime::Draw(Option_t *opt)
+{
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    pad->Divide(2,2);
+
+    TH1 *h;
+
+    pad->cd(1);
+    gPad->SetBorderMode(0);
+    h = fHist.Project3D("ex");
+    h->SetTitle("Distribution of \\alpha [\\circ]");
+    h->SetXTitle("\\alpha [\\circ]");
+    h->SetYTitle("Counts");
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
+
+    pad->cd(2);
+    gPad->SetBorderMode(0);
+    gPad->SetLogx();
+    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);
+
+    pad->cd(3);
+    gPad->SetBorderMode(0);
+    h = fHist.Project3D("ez");
+    h->SetTitle("Distribution of time [s]");
+    h->SetXTitle("time [s]");
+    h->SetYTitle("Counts");
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
+
+    pad->cd(4);
+    gPad->SetBorderMode(0);
+    fHist.Draw(opt);
+
+    pad->Modified();
+    pad->Update();
+
+}
+
+// --------------------------------------------------------------------------
+//
+// Integrate fHist     (Alpha,E-est,Time) over the Time to get
+//           fAlphaEest(Alpha,E-est)
+// 
+TH2D *MHAlphaEnergyTime::IntegrateTime(const char *title, Bool_t draw)
+{
+    Int_t nzbins = fHist.GetNbinsZ();
+    TAxis &axez  = *fHist.GetZaxis();
+    axez.SetRange(1,nzbins);
+
+    TH2D &fAlphaEest = *(TH2D *)fHist.Project3D("exy");
+
+    fAlphaEest.SetTitle(title);
+    fAlphaEest.SetXTitle("E-est [GeV]            ");
+    fAlphaEest.SetYTitle("\\alpha  [  \\circ]");
+
+    if (draw == kTRUE)
+    {
+      TCanvas &c = *MakeDefCanvas(title, title);
+
+      gROOT->SetSelectedPad(NULL);
+
+      fAlphaEest.DrawCopy();
+      gPad->SetLogx();
+
+      c.Modified();
+      c.Update();
+    }
+
+    return &fAlphaEest;
+}
+
+// --------------------------------------------------------------------------
+//
+// Integrate fHist     (Alpha,E-est,Time) over E-est to get
+//           fAlphaTime(Alpha,Time)
+// 
+TH2D *MHAlphaEnergyTime::IntegrateEest(const char *title, Bool_t draw)
+{
+    Int_t nybins = fHist.GetNbinsY();
+    TAxis &axey  = *fHist.GetYaxis();
+    axey.SetRange(1,nybins);
+
+    TH2D &fAlphaTime = *(TH2D *)fHist.Project3D("exz");
+
+    fAlphaTime.SetTitle(title);
+    fAlphaTime.SetXTitle("Time [s]");
+    fAlphaTime.SetYTitle("\\alpha  [  \\circ]");
+
+    if (draw == kTRUE)
+    {
+      TCanvas &c = *MakeDefCanvas(title, title);
+
+      gROOT->SetSelectedPad(NULL);
+
+      fAlphaTime.DrawCopy();
+
+      c.Modified();
+      c.Update();
+    }
+
+    return &fAlphaTime;
+}
+
+// --------------------------------------------------------------------------
+//
+// Integrate fHist (Alpha,E-est,Time) over Eest and Time to get
+//           fAlpha(Alpha)
+// 
+TH1D *MHAlphaEnergyTime::IntegrateEestTime(const char *title, Bool_t draw)
+{
+    Int_t nybins = fHist.GetNbinsY();
+    TAxis &axey  = *fHist.GetYaxis();
+    axey.SetRange(1,nybins);
+
+    Int_t nzbins = fHist.GetNbinsZ();
+    TAxis &axez  = *fHist.GetZaxis();
+    axez.SetRange(1,nzbins);
+
+    TH1D &fAlpha = *(TH1D *)fHist.Project3D("ex");
+
+    fAlpha.SetTitle(title);
+    fAlpha.SetXTitle("\\alpha  [  \\circ]");
+    fAlpha.SetYTitle("Counts");
+
+    if (draw == kTRUE)
+    {
+      TCanvas &c = *MakeDefCanvas(title, title);
+
+      gROOT->SetSelectedPad(NULL);
+
+      fAlpha.DrawCopy();
+
+      c.Modified();
+      c.Update();
+    }
+
+    return &fAlpha;
+}
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mhist/MHAlphaEnergyTime.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHAlphaEnergyTime.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHAlphaEnergyTime.h	(revision 9661)
@@ -0,0 +1,57 @@
+#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);
+
+    Bool_t SetupFill(const MParList *pList);
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+
+    const TH3D *GetHist()       { return &fHist; }
+    const TH3D *GetHist() const { return &fHist; }
+
+    TH1 *GetHistByName(const TString name) { return &fHist; }
+
+    void Draw(Option_t *option="");
+
+    TH2D *IntegrateTime    (const char *title, Bool_t Draw);
+    TH2D *IntegrateEest    (const char *title, Bool_t Draw);
+    TH1D *IntegrateEestTime(const char *title, Bool_t Draw);
+   
+    ClassDef(MHAlphaEnergyTime, 0) //3D-histogram in alpha, Energy and time
+};
+
+#endif
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mhist/MHCT1Supercuts.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHCT1Supercuts.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHCT1Supercuts.cc	(revision 9661)
@@ -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): Wolfgang Wittek  2003 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////
+//
+// MHCT1Supercuts
+//
+// This class contains histograms for the supercuts
+//
+// the histograms are filled during the optimization of the supercuts
+//
+///////////////////////////////////////////////////////////////////////
+#include "MHCT1Supercuts.h"
+
+#include <math.h>
+
+#include <TH1.h>
+#include <TH2.h>
+#include <TPad.h>
+#include <TCanvas.h>
+
+#include "MParList.h"
+#include "MHFindSignificance.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHCT1Supercuts);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Setup four histograms for Alpha, and Dist
+//
+MHCT1Supercuts::MHCT1Supercuts(const char *name, const char *title)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHCT1Supercuts";
+    fTitle = title ? title : "Container for histograms for the supercuts";
+
+
+    fDegree = new TH1F("Degree", "Degree of polynomial",   5, -0.5,  4.5);
+    fProb   = new TH1F("Prob",   "chi2 probability",      40,    0,  1.0);
+    fNdf    = new TH1F("NDF",    "NDF of polynomial fit", 60, -0.5, 59.5);
+    fGamma  = new TH1F("gamma",  "gamma",                 40,  0.0,  8.0);
+    fNexNon = new TH1F("NexNon", "Nex / Non",             50,  0.0,  1.0);
+    fSigLiMa= new TH1F("Significance", "significance of gamma signal",   
+                                                          60,  0.0, 120.0);
+    fSigtoBackg= new TH2F("SigtoBackg", "Significance vs signal/backg ratio",
+                          50,  0.0,  10.0, 60, 0.0, 120.0);
+    fSigDegree = new TH2F("SigDegree", "Significance vs Degree of polynomial",
+                           5, -0.5,   4.5, 60, 0.0, 120.0);
+    fSigNbins  = new TH2F("SigNbins", "Significance vs number of bins",
+                           40, -0.5, 79.5, 60, 0.0, 120.0);
+
+    fDegree->SetDirectory(NULL);
+    fProb->SetDirectory(NULL);
+    fNdf->SetDirectory(NULL);
+    fGamma->SetDirectory(NULL);
+    fNexNon->SetDirectory(NULL);
+    fSigLiMa->SetDirectory(NULL);
+    fSigtoBackg->SetDirectory(NULL);
+    fSigDegree->SetDirectory(NULL);
+    fSigNbins->SetDirectory(NULL);
+
+    fDegree->SetXTitle("order of polynomial");
+    fProb->SetXTitle("chi2 probability of polynomial fit");
+    fNdf->SetXTitle("NDF of polynomial fit");
+    fGamma->SetXTitle("gamma");
+    fNexNon->SetXTitle("Nex / Non");
+    fSigLiMa->SetXTitle("significance");
+
+    fSigtoBackg->SetXTitle("signa./background ratio");
+    fSigtoBackg->SetYTitle("significance");
+
+    fSigDegree->SetXTitle("order of polynomial");
+    fSigDegree->SetYTitle("significance");
+
+    fSigNbins->SetXTitle("number of bins");
+    fSigNbins->SetYTitle("significance");
+
+    fDegree->SetYTitle("Counts");
+    fProb->SetYTitle("Counts");
+    fNdf->SetYTitle("Counts");
+    fGamma->SetYTitle("Counts");
+    fNexNon->SetYTitle("Counts");
+    fSigLiMa->SetYTitle("Counts");
+
+    fSigtoBackg->SetZTitle("Counts");
+    fSigDegree->SetZTitle("Counts");
+    fSigNbins->SetZTitle("Counts");
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the histograms
+//
+MHCT1Supercuts::~MHCT1Supercuts()
+{
+    delete fDegree;
+    delete fProb;
+    delete fNdf;
+    delete fGamma;
+    delete fNexNon;
+    delete fSigLiMa;
+
+    delete fSigtoBackg;
+    delete fSigDegree;
+    delete fSigNbins;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the histograms from the 'MHFindSignificance' container
+//
+Bool_t MHCT1Supercuts::Fill(const MParContainer *par, const Stat_t w)
+{
+    if (!par)
+    {
+        *fLog << err << "MHCT1Supercuts::Fill: Pointer (!=NULL) expected." << endl;
+        return kFALSE;
+    }
+
+    MHFindSignificance &h = *(MHFindSignificance*)par;
+
+    fDegree    ->Fill(h.GetDegree( ), w);
+    fProb      ->Fill(h.GetProb(),    w);
+    fNdf       ->Fill(h.GetNdf(),     w);
+    fGamma     ->Fill(h.GetGamma(),   w);
+
+    Double_t ratio = h.GetNon()>0.0 ? h.GetNex()/h.GetNon() : 0.0;
+    fNexNon    ->Fill(ratio,          w);
+
+    fSigLiMa   ->Fill(h.GetSigLiMa(), w);
+
+    Double_t sigtobackg = h.GetNbg()!=0.0 ? h.GetNex() / h.GetNbg() : 0.0;
+    fSigtoBackg->Fill(sigtobackg,    h.GetSigLiMa(), w);
+
+    fSigDegree ->Fill(h.GetDegree(), h.GetSigLiMa(), w);
+    fSigNbins  ->Fill(h.GetMbins(),  h.GetSigLiMa(), w);
+
+    return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// 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 MHCT1Supercuts::Draw(Option_t *)
+{
+  //TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
+  //pad->SetBorderMode(0);
+  //AppendPad("");
+
+    TCanvas *pad = new TCanvas("Supercuts", "Supercut plots", 900, 900);
+    gROOT->SetSelectedPad(NULL);
+
+    pad->Divide(3, 3);
+
+    pad->cd(1);
+    gPad->SetBorderMode(0);
+    fDegree->Draw();
+
+    pad->cd(2);
+    gPad->SetBorderMode(0);
+    fProb->Draw();
+
+    pad->cd(3);
+    gPad->SetBorderMode(0);
+    fNdf->Draw();
+
+    pad->cd(4);
+    gPad->SetBorderMode(0);
+    fGamma->Draw();
+
+    pad->cd(5);
+    gPad->SetBorderMode(0);
+    fNexNon->Draw();
+
+    pad->cd(6);
+    gPad->SetBorderMode(0);
+    fSigLiMa->Draw();
+
+    pad->cd(7);
+    gPad->SetBorderMode(0);
+    fSigtoBackg->Draw();
+
+    pad->cd(8);
+    gPad->SetBorderMode(0);
+    fSigDegree->Draw();
+
+    pad->cd(9);
+    gPad->SetBorderMode(0);
+    fSigNbins->Draw();
+
+    pad->Modified();
+    pad->Update();
+}
Index: /tags/Mars_V0-8-5/Mars/mhist/MHCT1Supercuts.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHCT1Supercuts.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHCT1Supercuts.h	(revision 9661)
@@ -0,0 +1,42 @@
+#ifndef MARS_MHCT1Supercuts
+#define MARS_MHCT1Supercuts
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+class TH1F;
+class TH2F;
+
+class MHCT1Supercuts : public MH
+{
+private:
+    TH1F *fDegree;     // order of polynomial for background fit
+    TH1F *fProb;       // chi2 probability of polynomial fit
+    TH1F *fNdf;        // NDF of polynomial fit
+    TH1F *fGamma;      // Nbg = gamma * Noff
+    TH1F *fNexNon;     // no.of excess events / no.of events in signal region 
+    TH1F *fSigLiMa;    // significance of gamma signal
+
+    TH2F *fSigtoBackg; // significance vs signal to background ratio (Nex/Nbg)
+    TH2F *fSigDegree;  // significance vs order of polynomial
+    TH2F *fSigNbins;   // significance vs number of bins
+
+
+public:
+    MHCT1Supercuts(const char *name=NULL, const char *title=NULL);
+    ~MHCT1Supercuts();
+
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+
+    void Draw(Option_t *opt=NULL);
+
+    ClassDef(MHCT1Supercuts, 1) // Container which holds histograms for the supercuts
+};
+
+#endif
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mhist/MHCamEvent.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHCamEvent.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHCamEvent.cc	(revision 9661)
@@ -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/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHCamEvent
+//
+// A histogram to store the sum of camera events. This can be photons,
+// currents or enything else derived from MCamEvent
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MHCamEvent.h"
+
+#include <TCanvas.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MCamEvent.h"
+#include "MHCamera.h"
+
+#include "MGeomCam.h"
+
+ClassImp(MHCamEvent);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Initialize the name and title of the task.
+// Resets the sum histogram
+//
+MHCamEvent::MHCamEvent(const char *name, const char *title)
+    : fSum(NULL), fRms(NULL), fEvt(NULL), fType(0)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHCamEvent";
+    fTitle = title ? title : "Average of MCamEvents";
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the corresponding camera display if available
+//
+MHCamEvent::~MHCamEvent()
+{
+    if (fSum)
+        delete fSum;
+    if (fRms)
+        delete fRms;
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the event (MCamEvent) the histogram might be filled with. If
+// it is not given, it is assumed, that it is filled with the argument
+// of the Fill function.
+// Looks for the camera geometry MGeomCam and resets the sum histogram.
+//
+Bool_t MHCamEvent::SetupFill(const MParList *plist)
+{
+    fEvt = (MCamEvent*)plist->FindObject(fNameEvt, "MCamEvent");
+    if (!fEvt)
+    {
+        if (!fNameEvt.IsNull())
+        {
+            *fLog << err << GetDescriptor() << ": No " << fNameEvt <<" [MCamEvent] available..." << endl;
+            return kFALSE;
+        }
+        *fLog << warn << GetDescriptor() << ": No MCamEvent available..." << endl;
+    }
+
+    MGeomCam *cam = (MGeomCam*)plist->FindObject("MGeomCam");
+    if (!cam)
+    {
+        *fLog << err << GetDescriptor() << ": No MGeomCam found." << endl;
+        return kFALSE;
+    }
+
+    if (fSum)
+        delete (fSum);
+    if (fRms)
+        delete (fRms);
+
+    const TString name = fNameEvt.IsNull() ? fName : fNameEvt;
+
+    fSum = new MHCamera(*cam, name+";avg", fTitle);
+    fSum->SetYTitle("a.u.");
+    fSum->SetBit(MHCamera::kProfile);
+    if(TestBit(MHCamera::kVariance))
+      fSum->SetBit(MHCamera::kVariance);
+
+    fRms = new MHCamera(*cam, name+";rms", fTitle);
+    fRms->SetYTitle("a.u.");
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the histograms with data from a MCamEvent-Container.
+//
+Bool_t MHCamEvent::Fill(const MParContainer *par, const Stat_t w)
+{
+    const MCamEvent *evt = par ? dynamic_cast<const MCamEvent*>(par) : fEvt;
+    if (!evt)
+    {
+        *fLog << err << dbginf << "Got no MCamEvent as argument of Fill()..." << endl;
+        return kFALSE;
+    }
+    fSum->AddCamContent(*evt, fType);
+    fRms->SetCamContent(*fSum, 1);
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Scale the sum container with the number of entries
+//
+Bool_t MHCamEvent::Finalize()
+{
+    //fRms->AddCamContent(*fSum, 1);
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Take the mean of the sum histogram and print all pixel indices
+// which are above sum+s*rms
+//
+void MHCamEvent::PrintOutliers(Float_t s) const
+{
+    const Double_t mean = fSum->GetMean();
+    const Double_t rms  = fSum->GetRMS();
+
+    *fLog << all << underline << GetDescriptor() << ": Mean=" << mean << ", Rms=" << rms << endl;
+
+    for (UInt_t i=0; i<fSum->GetNumPixels(); i++)
+    {
+        if (!fSum->IsUsed(i))
+            continue;
+
+        if ((*fSum)[i+1]>mean+s*rms)
+            *fLog << "Contents of Pixel-Index #" << i << ": " << (*fSum)[i+1] << " > " << s << "*rms" << endl;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Return fSum for "sum" and fRms for "rms"
+//
+TH1 *MHCamEvent::GetHistByName(const TString name)
+{
+//    name.ToLower();
+
+    if (name=="sum")
+        return fSum;
+    if (name=="rms")
+        return fRms;
+
+    return NULL;
+}
+
+void MHCamEvent::Draw(Option_t *)
+{
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    pad->Divide(1,2);
+
+    pad->cd(1);
+    gPad->SetBorderMode(0);
+    fSum->Draw("EPhist");
+
+    pad->cd(2);
+    gPad->SetBorderMode(0);
+    gPad->Divide(2, 1);
+    pad = gPad;
+
+    pad->cd(1);
+    gPad->SetBorderMode(0);
+    fSum->Draw();
+
+    pad->cd(2);
+    gPad->SetBorderMode(0);
+    fRms->Draw();
+}
Index: /tags/Mars_V0-8-5/Mars/mhist/MHCamEvent.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHCamEvent.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHCamEvent.h	(revision 9661)
@@ -0,0 +1,42 @@
+#ifndef MARS_MHCamEvent
+#define MARS_MHCamEvent
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+class MHCamera;
+class MCamEvent;
+
+class MHCamEvent : public MH
+{
+private:
+    MHCamera  *fSum; // storing the sum
+    MHCamera  *fRms; // storing the rms
+    MCamEvent *fEvt; //! the current event
+
+    TString fNameEvt;
+
+    Int_t fType;
+
+    Bool_t SetupFill(const MParList *pList);
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+    Bool_t Finalize();
+
+public:
+    MHCamEvent(const char *name=NULL, const char *title=NULL);
+    ~MHCamEvent();
+
+    void SetNameEvt(const TString name) { fNameEvt = name; }
+    void SetType(Int_t type) { fType = type; }
+
+    TH1 *GetHistByName(const TString name="");
+
+    void Draw(Option_t *o="");
+
+    void PrintOutliers(Float_t s) const;
+
+    ClassDef(MHCamEvent, 1) // Histogram to sum camera events
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mhist/MHCamEventRot.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHCamEventRot.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHCamEventRot.cc	(revision 9661)
@@ -0,0 +1,240 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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, 4/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// MHCamEventRot
+//
+// Derotate MCamEvent before filling a 2D histogram.
+//
+// To be done: Set the sky position of the center of the display and
+//             correct if the pointing position of the telescope is
+//             different
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MHCamEventRot.h"
+
+#include <TF1.h>
+#include <TH2.h>
+#include <TGraph.h>
+#include <TStyle.h>
+#include <TCanvas.h>
+#include <TPaveText.h>
+#include <TStopwatch.h>
+
+#include "MGeomCam.h"
+#include "MSrcPosCam.h"
+#include "MHillasSrc.h"
+#include "MTime.h"
+#include "MObservatory.h"
+#include "MPointingPos.h"
+#include "MAstroCatalog.h"
+#include "MAstroSky2Local.h"
+#include "MStatusDisplay.h"
+#include "MMath.h"
+
+#include "MBinning.h"
+#include "MParList.h"
+#include "MCamEvent.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHCamEventRot);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor
+//
+MHCamEventRot::MHCamEventRot(const char *name, const char *title)
+    : fTime(0), fPointPos(0), fObservatory(0), fType(0), fNameTime("MTime")
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHCamEventRot";
+    fTitle = title ? title : "Plot showing derotated MCamEvent data";
+
+    fHist.SetDirectory(NULL);
+
+    fHist.SetName("Alpha");
+    fHist.SetTitle("2D-plot of MCamEvents (derotated)");
+    fHist.SetXTitle("x [\\circ]");
+    fHist.SetYTitle("y [\\circ]");
+    fHist.SetZTitle("Counts");
+}
+
+// --------------------------------------------------------------------------
+//
+// Set binnings (takes BinningCamEvent) and prepare filling of the
+// histogram.
+//
+// Also search for MTime, MObservatory and MPointingPos
+// 
+Bool_t MHCamEventRot::SetupFill(const MParList *plist)
+{
+    fGeom = (MGeomCam*)plist->FindObject("MGeomCam");
+    if (!fGeom)
+    {
+        *fLog << err << "MGeomCam not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    const MBinning *bins = (MBinning*)plist->FindObject("BinningCamEvent");
+    if (!bins)
+    {
+        const Float_t r = fGeom->GetMaxRadius()*fGeom->GetConvMm2Deg();
+
+        MBinning b;
+        b.SetEdges(41, -r, r);
+        SetBinning(&fHist, &b, &b);
+    }
+    else
+        SetBinning(&fHist, bins, bins);
+
+    fPointPos = (MPointingPos*)plist->FindObject(AddSerialNumber("MPointingPos"));
+    if (!fPointPos)
+        *fLog << warn << "MPointingPos not found... no derotation." << endl;
+
+    fTime = (MTime*)plist->FindObject(AddSerialNumber(fNameTime));
+    if (!fTime)
+        *fLog << warn << "MTime not found... no derotation." << endl;
+
+    fObservatory = (MObservatory*)plist->FindObject(AddSerialNumber("MObservatory"));
+    if (!fObservatory)
+        *fLog << warn << "MObservatory not found... no derotation." << endl;
+
+    // FIXME: Because the pointing position could change we must check
+    // for the current pointing position and add a offset in the
+    // Fill function!
+    if (fPointPos)
+    {
+        fRa  = fPointPos->GetRa();
+        fDec = fPointPos->GetDec();
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the histogram. For details see the code or the class description
+// 
+Bool_t MHCamEventRot::Fill(const MParContainer *par, const Stat_t w)
+{
+    const MCamEvent *evt = dynamic_cast<const MCamEvent*>(par);
+    if (!evt)
+    {
+        *fLog << err << "MHCamEventRot::Fill: No container specified!" << endl;
+        return kFALSE;
+    }
+
+    // Get max radius...
+    // const Double_t maxr = fGeom->GetMaxRadius()*fGeom->GetConvMm2Deg();
+
+    // Get camera rotation angle
+    Double_t rho = 0;
+    if (fTime && fObservatory && fPointPos)
+        rho = fPointPos->RotationAngle(*fObservatory, *fTime);
+    //if (fPointPos)
+    //    rho = fPointPos->RotationAngle(*fObservatory);
+
+    // Get number of bins and bin-centers
+    const Int_t nx = fHist.GetNbinsX();
+    const Int_t ny = fHist.GetNbinsY();
+    Axis_t cx[nx];
+    Axis_t cy[ny];
+    fHist.GetXaxis()->GetCenter(cx);
+    fHist.GetYaxis()->GetCenter(cy);
+
+    for (int ix=0; ix<nx; ix++)
+    {
+        for (int iy=0; iy<ny; iy++)
+        {
+            // check distance... to get a circle plot
+            //if (TMath::Hypot(cx[ix], cy[iy])>maxr)
+            //    continue;
+
+            // rotate center of bin
+            TVector2 v(cx[ix], cy[iy]);
+            if (rho!=0)
+                v=v.Rotate(rho);
+
+            // FIXME: slow! Create Lookup table instead!
+            const Int_t idx = fGeom->GetPixelIdxDeg(v);
+
+            Double_t val;
+            if (idx<0 || !evt->GetPixelContent(val, idx, *fGeom, fType))
+                continue;
+
+            // Fill histogram
+            fHist.Fill(cx[ix], cy[iy], val);
+        }
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the MAstroCatalog corresponding to fRa, fDec. The limiting magnitude
+// is set to 9, while the fov is equal to the current fov of the false
+// source plot.
+//
+TObject *MHCamEventRot::GetCatalog()
+{
+    const Double_t maxr = 0.98*TMath::Abs(fHist.GetBinCenter(1));
+
+    // Create catalog...
+    MAstroCatalog stars;
+    stars.SetLimMag(9);
+    stars.SetGuiActive(kFALSE);
+    stars.SetRadiusFOV(maxr);
+    stars.SetRaDec(fRa*TMath::DegToRad()*15, fDec*TMath::DegToRad());
+    stars.ReadBSC("bsc5.dat");
+
+    TObject *o = (MAstroCatalog*)stars.Clone();
+    o->SetBit(kCanDelete);
+
+    return o;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw the histogram
+//
+void MHCamEventRot::Draw(Option_t *opt)
+{
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    AppendPad("");
+
+    // draw the 2D histogram Sigmabar versus Theta
+    fHist.Draw(opt);
+    TObject *catalog = GetCatalog();
+    catalog->Draw("mirror same");
+}
Index: /tags/Mars_V0-8-5/Mars/mhist/MHCamEventRot.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHCamEventRot.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHCamEventRot.h	(revision 9661)
@@ -0,0 +1,54 @@
+#ifndef MARS_MHCamEventRot
+#define MARS_MHCamEventRot
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+#ifndef ROOT_TH2
+#include <TH2.h>
+#endif
+
+class TH2D;
+
+class MGeomCam;
+class MParList;
+class MTime;
+class MPointingPos;
+class MObservatory;
+
+class MHCamEventRot : public MH
+{
+private:
+    MGeomCam      *fGeom;        //! container storing the camera geometry
+    MTime         *fTime;        //! container to take the event time from
+    MPointingPos  *fPointPos;    //! container to take pointing position from
+    MObservatory  *fObservatory; //! conteiner to take observatory location from
+
+    TH2D    fHist;               // Alpha vs. x and y
+
+    Int_t fType;
+
+    Double_t fRa;
+    Double_t fDec;
+
+    TString fNameTime;
+
+    TObject *GetCatalog();
+
+public:
+    MHCamEventRot(const char *name=NULL, const char *title=NULL);
+
+    Bool_t SetupFill(const MParList *pList);
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+
+    TH1 *GetHistByName(const TString name) { return &fHist; }
+
+    void SetNameTime(const char *name) { fNameTime=name; }
+
+    void Draw(Option_t *option="");
+
+    ClassDef(MHCamEventRot, 1) //2D-histogram in MCamEvent data (derotated)
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mhist/MHCamera.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHCamera.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHCamera.cc	(revision 9661)
@@ -0,0 +1,2074 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 05/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Harald Kornmayer, 1/2001
+!   Author(s): Markus Gaug, 03/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHCamera
+//
+// Camera Display, based on a TH1D. Pleas be carefull using the
+// underlaying TH1D.
+//
+// To change the scale to a logarithmic scale SetLogy() of the Pad.
+//
+// You can correct for the abberation. Assuming that the distance
+// between the mean position of the light distribution and the position
+// of a perfect reflection on a perfect mirror in the distance r on
+// the camera plane is dr it is  d = a*dr  while a is the abberation
+// constant (for the MAGIC mirror it is roughly 0.0713). You can
+// set this constant by calling SetAbberation(a) which results in a
+// 'corrected' display (all outer pixels are shifted towards the center
+// of the camera to correct for this abberation)
+//
+// Be carefull: Entries in this context means Entries/bin or Events
+//
+// FIXME? Maybe MHCamera can take the fLog object from MGeomCam?
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MHCamera.h"
+
+#include <fstream>
+#include <iostream>
+
+#include <TBox.h>
+#include <TArrow.h>
+#include <TLatex.h>
+#include <TStyle.h>
+#include <TCanvas.h>
+#include <TArrayF.h>
+#include <TRandom.h>
+#include <TPaveText.h>
+#include <TPaveStats.h>
+#include <TClonesArray.h>
+#include <THistPainter.h>
+#include <THLimitsFinder.h>
+#include <TProfile.h>
+#include <TH1.h>
+#include <TF1.h>
+#include <TCanvas.h>
+#include <TLegend.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MH.h"
+#include "MHexagon.h"
+
+#include "MGeomPix.h"
+#include "MGeomCam.h"
+
+#include "MCamEvent.h"
+
+#define kItemsLegend 48 // see SetPalette(1,0)
+
+ClassImp(MHCamera);
+
+using namespace std;
+
+void MHCamera::Init()
+{
+    UseCurrentStyle();
+
+    SetDirectory(NULL);
+
+    SetLineColor(kGreen);
+    SetMarkerStyle(kFullDotMedium);
+    SetXTitle("Pixel Index");
+
+    fNotify  = new TList;
+    fNotify->SetBit(kMustCleanup);
+    gROOT->GetListOfCleanups()->Add(fNotify);
+
+    TVirtualPad *save = gPad;
+    gPad = 0;
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,01,06)
+    SetPalette(1, 0);
+#else
+    SetInvDeepBlueSeaPalette();
+#endif
+    gPad = save;
+}
+
+// ------------------------------------------------------------------------
+//
+//  Default Constructor. To be used by the root system ONLY.
+//
+MHCamera::MHCamera() : TH1D(), fGeomCam(NULL), fColors(kItemsLegend), fAbberation(0)
+{
+    Init();
+}
+
+// ------------------------------------------------------------------------
+//
+//  Constructor. Makes a clone of MGeomCam. Removed the TH1D from the
+// current directory. Calls Sumw2(). Set the histogram line color
+// (for error bars) to Green and the marker style to kFullDotMedium.
+//
+MHCamera::MHCamera(const MGeomCam &geom, const char *name, const char *title)
+: fGeomCam(NULL), fColors(kItemsLegend), fAbberation(0)
+{
+    //fGeomCam = (MGeomCam*)geom.Clone();
+    SetGeometry(geom, name, title);
+    Init();
+
+    //
+    // 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.
+}
+
+void MHCamera::SetGeometry(const MGeomCam &geom, const char *name, const char *title)
+{
+    SetNameTitle(name, title);
+
+    TAxis &x = *GetXaxis();
+
+    SetBins(geom.GetNumPixels(), 0, 1);
+    x.Set(geom.GetNumPixels(), -0.5, geom.GetNumPixels()-0.5);
+
+    //SetBins(geom.GetNumPixels(), -0.5, geom.GetNumPixels()-0.5);
+    //Rebuild();
+
+    Sumw2(); // necessary?
+
+    if (fGeomCam)
+        delete fGeomCam;
+    fGeomCam = (MGeomCam*)geom.Clone();
+
+    fUsed.Set(geom.GetNumPixels());
+    for (Int_t i=0; i<fNcells-2; i++)
+      ResetUsed(i);
+}
+
+// ------------------------------------------------------------------------
+//
+// Destructor. Deletes the cloned fGeomCam and the notification list.
+//
+MHCamera::~MHCamera()
+{
+    if (fGeomCam)
+      delete fGeomCam;
+    if (fNotify)
+      delete fNotify;
+}
+
+// ------------------------------------------------------------------------
+//
+// Return kTRUE for sector<0. Otherwise return kTRUE only if the specified
+// sector idx matches the sector of the pixel with index idx.
+//
+Bool_t MHCamera::MatchSector(Int_t idx, const TArrayI &sector, const TArrayI &aidx) const
+{
+    const MGeomPix &pix = (*fGeomCam)[idx];
+    return FindVal(sector, pix.GetSector()) && FindVal(aidx, pix.GetAidx());
+}
+
+// ------------------------------------------------------------------------
+//
+// Taken from TH1D::Fill(). Uses the argument directly as bin index.
+// Doesn't increment the number of entries.
+//
+//   -*-*-*-*-*-*-*-*Increment bin with abscissa X by 1*-*-*-*-*-*-*-*-*-*-*
+//                   ==================================
+//
+//    if x is less than the low-edge of the first bin, the Underflow bin is incremented
+//    if x is greater than the upper edge of last bin, the Overflow bin is incremented
+//
+//    If the storage of the sum of squares of weights has been triggered,
+//    via the function Sumw2, then the sum of the squares of weights is incremented
+//    by 1 in the bin corresponding to x.
+//
+//   -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
+Int_t MHCamera::Fill(Axis_t x)
+{
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,05,00)
+   if (fBuffer) return BufferFill(x,1);
+#endif
+   const Int_t bin = (Int_t)x+1;
+   AddBinContent(bin);
+   if (fSumw2.fN)
+       fSumw2.fArray[bin]++;
+
+   if (bin<=0 || bin>fNcells-2)
+       return -1;
+
+   fTsumw++;
+   fTsumw2++;
+   fTsumwx  += x;
+   fTsumwx2 += x*x;
+   return bin;
+}
+
+// ------------------------------------------------------------------------
+//
+// Taken from TH1D::Fill(). Uses the argument directly as bin index.
+// Doesn't increment the number of entries.
+//
+//   -*-*-*-*-*-*Increment bin with abscissa X with a weight w*-*-*-*-*-*-*-*
+//               =============================================
+//
+//    if x is less than the low-edge of the first bin, the Underflow bin is incremented
+//    if x is greater than the upper edge of last bin, the Overflow bin is incremented
+//
+//    If the storage of the sum of squares of weights has been triggered,
+//    via the function Sumw2, then the sum of the squares of weights is incremented
+//    by w^2 in the bin corresponding to x.
+//
+//   -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
+Int_t MHCamera::Fill(Axis_t x, Stat_t w)
+{
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,05,00)
+   if (fBuffer) return BufferFill(x,w);
+#endif
+   const Int_t bin = (Int_t)x+1;
+   AddBinContent(bin, w);
+   if (fSumw2.fN)
+       fSumw2.fArray[bin] += w*w;
+
+   if (bin<=0 || bin>fNcells-2)
+       return -1;
+
+   const Stat_t z = (w > 0 ? w : -w);
+   fTsumw   += z;
+   fTsumw2  += z*z;
+   fTsumwx  += z*x;
+   fTsumwx2 += z*x*x;
+   return bin;
+}
+
+// ------------------------------------------------------------------------
+//
+// Use x and y in millimeters
+//
+Int_t MHCamera::Fill(Axis_t x, Axis_t y, Stat_t w)
+{
+    if (fNcells<=1 || IsFreezed())
+        return -1;
+
+    for (Int_t idx=0; idx<fNcells-2; idx++)
+    {
+        MHexagon hex((*fGeomCam)[idx]);
+        if (hex.DistanceToPrimitive(x, y)>0)
+            continue;
+
+        SetUsed(idx);
+        return Fill(idx, w);
+    }
+    return -1;
+}
+
+// ------------------------------------------------------------------------
+//
+// Call this if you want to change the display status (displayed or not)
+// for all pixels. val==0 means that the pixel is not displayed.
+//
+void MHCamera::SetUsed(const TArrayC &arr)
+{
+    if (fNcells-2 != arr.GetSize())
+    {
+        gLog << warn << "WARNING - MHCamera::SetUsed: array size mismatch... ignored." << endl;
+        return;
+    }
+
+    for (Int_t idx=0; idx<fNcells-2; idx++)
+        arr[idx] ? SetUsed(idx) : ResetUsed(idx);
+}
+
+// ------------------------------------------------------------------------
+//
+// Return the mean value of all entries which are used if all=kFALSE and
+// of all entries if all=kTRUE if sector<0. If sector>=0 only
+// entries with match the given sector are taken into account.
+//
+Stat_t MHCamera::GetMeanSectors(const TArrayI &sector, const TArrayI &aidx, Bool_t all) const
+{
+    if (fNcells<=1)
+        return 0;
+
+    Int_t n=0;
+
+    Stat_t mean = 0;
+    for (int i=0; i<fNcells-2; i++)
+    {
+        if ((all || IsUsed(i)) && MatchSector(i, sector, aidx))
+        {
+            mean += fArray[i+1];
+            n++;
+        }
+    }
+
+    return n==0 ? 0 : Profile(mean/n);
+}
+
+// ------------------------------------------------------------------------
+//
+// Return the variance of all entries which are used if all=kFALSE and
+// of all entries if all=kTRUE if sector<0. If sector>=0 only
+// entries with match the given sector are taken into account.
+//
+Stat_t MHCamera::GetRmsSectors(const TArrayI &sector, const TArrayI &aidx, Bool_t all) const
+{
+    if (fNcells<=1)
+        return -1;
+
+    Int_t n=0;
+
+    Stat_t sum = 0;
+    Stat_t sq  = 0;
+    for (int i=0; i<fNcells-2; i++)
+    {
+        if ((all || IsUsed(i)) && MatchSector(i, sector, aidx))
+        {
+            sum += fArray[i+1];
+            sq  += fArray[i+1]*fArray[i+1];
+            n++;
+        }
+    }
+
+    if (n==0)
+        return 0;
+
+    sum /= n;
+    sq  /= n;
+
+    return Profile(TMath::Sqrt(sq-sum*sum));
+}
+
+// ------------------------------------------------------------------------
+//
+// Return the minimum contents of all pixels (if all is set, otherwise
+// only of all 'used' pixels), fMinimum if fMinimum set. If sector>=0
+// only pixels with matching sector number are taken into account.
+//
+Double_t MHCamera::GetMinimumSectors(const TArrayI &sector, const TArrayI &aidx, Bool_t all) const
+{
+    if (fMinimum != -1111)
+        return fMinimum;
+
+    if (fNcells<=1)
+        return 0;
+
+    Double_t minimum=FLT_MAX;
+
+    for (Int_t idx=0; idx<fNcells-2; idx++)
+        if (MatchSector(idx, sector, aidx) && (all || IsUsed(idx)) && fArray[idx+1]<minimum)
+            minimum = fArray[idx+1];
+
+    return Profile(minimum);
+}
+
+// ------------------------------------------------------------------------
+//
+// Return the maximum contents of all pixels (if all is set, otherwise
+// only of all 'used' pixels), fMaximum if fMaximum set. If sector>=0
+// only pixels with matching sector number are taken into account.
+//
+Double_t MHCamera::GetMaximumSectors(const TArrayI &sector, const TArrayI &aidx, Bool_t all) const
+{
+    if (fMaximum!=-1111)
+        return fMaximum;
+
+    if (fNcells<=1)
+        return 1;
+
+    Double_t maximum=-FLT_MAX;
+    for (Int_t idx=0; idx<fNcells-2; idx++)
+        if (MatchSector(idx, sector, aidx) && (all || IsUsed(idx)) && fArray[idx+1]>maximum)
+            maximum = fArray[idx+1];
+
+    return Profile(maximum);
+}
+
+// ------------------------------------------------------------------------
+//
+// 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. (To access the 'real' pad containing the camera you have
+// to do a cd(1) in the current layer.
+//
+// To draw a camera into its own pad do something like:
+//
+//   MGeomCamMagic m;
+//   MHCamera *d=new MHCamera(m);
+//
+//   TCanvas *c = new TCanvas;
+//   c->Divide(2,1);
+//   c->cd(1);
+//
+//   d->FillRandom();
+//   d->Draw();
+//   d->SetBit(kCanDelete);
+//
+// There are several drawing options:
+//   'hist'        Draw as a standard TH1 histogram (value vs. pixel index)
+//   'box'         Draw hexagons which size is in respect to its contents
+//   'nocol'       Leave the 'boxed' hexagons empty
+//   'pixelindex'  Display the pixel index in each pixel
+//   'sectorindex' Display the sector index in each pixel
+//   'content'     Display the relative content aligned to GetMaximum() and
+//                 GeMinimum() ((val-min)/(max-min))
+//   'proj'        Display the y-projection of the histogram
+//   'same'        Draw trandparent pixels on top of an existing pad. This
+//                 makes it possible to draw the camera image on top of an
+//                 existing TH2, but also allows for distorted camera images
+//
+void MHCamera::Draw(Option_t *option)
+{
+    const Bool_t hassame = TString(option).Contains("same", TString::kIgnoreCase) && gPad;
+
+    // root 3.02:
+    // gPad->SetFixedAspectRatio()
+    const Color_t col = gPad ? gPad->GetFillColor() : 16;
+    TVirtualPad  *pad = gPad ? gPad : MH::MakeDefCanvas("CamDisplay", "Mars Camera Display", 656, 600);
+
+    if (!hassame)
+    {
+        pad->SetBorderMode(0);
+        pad->SetFillColor(col);
+
+        //
+        // Create an own pad for the MHCamera-Object which can be
+        // resized in paint to keep the correct aspect ratio
+        //
+        pad->Divide(1, 1, 0, 0, col);
+        pad->cd(1);
+        gPad->SetBorderMode(0);
+    }
+
+    AppendPad(option);
+    //fGeomCam->AppendPad();
+
+    //
+    // Do not change gPad. The user should not see, that Draw
+    // changes gPad...
+    //
+    if (!hassame)
+        pad->cd();
+}
+
+// ------------------------------------------------------------------------
+//
+// This is TObject::DrawClone but completely ignores
+// gROOT->GetSelectedPad(). tbretz had trouble with this in the past.
+// If this makes trouble please write a bug report.
+//
+TObject *MHCamera::DrawClone(Option_t *option) const 
+{
+   // Draw a clone of this object in the current pad
+
+   //TVirtualPad *pad = gROOT->GetSelectedPad();
+   TVirtualPad *padsav = gPad;
+   //if (pad) pad->cd();
+
+   TObject *newobj = Clone();
+
+   if (!newobj)
+       return 0;
+
+   /*
+   if (pad) {
+      if (strlen(option)) pad->GetListOfPrimitives()->Add(newobj,option);
+      else                pad->GetListOfPrimitives()->Add(newobj,GetDrawOption());
+      pad->Modified(kTRUE);
+      pad->Update();
+      if (padsav) padsav->cd();
+      return newobj;
+   }
+   */
+
+   TString opt(option);
+   opt.ToLower();
+
+   newobj->Draw(opt.IsNull() ? GetDrawOption() : option);
+
+   if (padsav)
+       padsav->cd();
+
+   return newobj;
+}
+
+// ------------------------------------------------------------------------
+//
+// Creates a TH1D which contains the projection of the contents of the
+// MHCamera onto the y-axis. The maximum and minimum are calculated
+// such that a slighly wider range than (GetMinimum(), GetMaximum()) is
+// displayed using THLimitsFinder::OptimizeLimits.
+//
+// If no name is given the newly allocated histogram is removed from
+// the current directory calling SetDirectory(0) in any other case
+// the newly created histogram is removed from the current directory
+// and added to gROOT such the gROOT->FindObject can find the histogram.
+//
+// If the standard name "_py" is given "_py" is appended to the name
+// of the MHCamera and the corresponding histogram is searched using
+// gROOT->FindObject and updated with the present projection.
+//
+// It is the responsibility of the user to make sure, that the newly
+// created histogram is freed correctly.
+//
+// Currently the new histogram is restrictred to 50 bins.
+// Maybe a optimal number can be calulated from the number of
+// bins on the x-axis of the MHCamera?
+//
+// The code was taken mainly from TH2::ProjectX such the interface
+// is more or less the same than to TH2-projections.
+//
+// If sector>=0 only entries with matching sector index are taken
+// into account.
+//
+TH1D *MHCamera::ProjectionS(const TArrayI &sector, const TArrayI &aidx, const char *name, const Int_t nbins) const
+{
+
+    // Create the projection histogram
+    TString pname(name);
+    if (name=="_py")
+    {
+        pname.Prepend(GetName());
+        if (sector.GetSize()>0)
+        {
+            pname += ";";
+            for (int i=0; i<sector.GetSize(); i++)
+                pname += sector[i];
+        }
+        if (aidx.GetSize()>0)
+        {
+            pname += ";";
+            for (int i=0; i<aidx.GetSize(); i++)
+                pname += aidx[i];
+        }
+    }
+
+    TH1D *h1=0;
+
+    //check if histogram with identical name exist
+    TObject *h1obj = gROOT->FindObject(pname);
+    if (h1obj && h1obj->InheritsFrom("TH1D")) {
+        h1 = (TH1D*)h1obj;
+        h1->Reset();
+    }
+
+    if (!h1)
+    {
+        Double_t min = GetMinimumSectors(sector, aidx);
+        Double_t max = GetMaximumSectors(sector, aidx);
+
+        Int_t newbins=0;
+
+        THLimitsFinder::OptimizeLimits(nbins, newbins, min, max, kFALSE);
+
+        h1 = new TH1D(pname, GetTitle(), nbins, min, max);
+        h1->SetDirectory(pname.IsNull() ? NULL : gROOT);
+        h1->SetXTitle(GetYaxis()->GetTitle());
+        h1->SetYTitle("Counts");
+        //h1->Sumw2();
+    }
+
+    // Fill the projected histogram
+    for (Int_t idx=0; idx<fNcells-2; idx++)
+        if (IsUsed(idx) && MatchSector(idx, sector, aidx))
+            h1->Fill(GetBinContent(idx+1));
+
+    return h1;
+}
+
+// ------------------------------------------------------------------------
+//
+// Creates a TH1D which contains the projection of the contents of the
+// MHCamera onto the radius from the camera center. 
+// The maximum and minimum are calculated
+// such that a slighly wider range than (GetMinimum(), GetMaximum()) is
+// displayed using THLimitsFinder::OptimizeLimits.
+//
+// If no name is given the newly allocated histogram is removed from
+// the current directory calling SetDirectory(0) in any other case
+// the newly created histogram is removed from the current directory
+// and added to gROOT such the gROOT->FindObject can find the histogram.
+//
+// If the standard name "_rad" is given "_rad" is appended to the name
+// of the MHCamera and the corresponding histogram is searched using
+// gROOT->FindObject and updated with the present projection.
+//
+// It is the responsibility of the user to make sure, that the newly
+// created histogram is freed correctly.
+//
+// Currently the new histogram is restrictred to 50 bins.
+// Maybe a optimal number can be calulated from the number of
+// bins on the x-axis of the MHCamera?
+//
+// The code was taken mainly from TH2::ProjectX such the interface
+// is more or less the same than to TH2-projections.
+//
+// If sector>=0 only entries with matching sector index are taken
+// into account.
+//
+TProfile *MHCamera::RadialProfileS(const TArrayI &sector, const TArrayI &aidx, const char *name, const Int_t nbins) const
+{
+  
+  // Create the projection histogram
+  TString pname(name);
+  if (name=="_rad")
+    {
+      pname.Prepend(GetName());
+      if (sector.GetSize()>0)
+        {
+          pname += ";";
+          for (int i=0; i<sector.GetSize(); i++)
+            pname += sector[i];
+        }
+      if (aidx.GetSize()>0)
+        {
+          pname += ";";
+          for (int i=0; i<aidx.GetSize(); i++)
+            pname += aidx[i];
+        }
+    }
+  
+  TProfile *h1=0;
+  
+  //check if histogram with identical name exist
+  TObject *h1obj = gROOT->FindObject(pname);
+  if (h1obj && h1obj->InheritsFrom("TProfile")) {
+    h1 = (TProfile*)h1obj;
+    h1->Reset();
+  }
+  
+  if (!h1)
+    {
+      
+      Double_t min = 0.;
+      Double_t max = fGeomCam->GetMaxRadius();
+      
+      Int_t newbins=0;
+      
+      THLimitsFinder::OptimizeLimits(nbins, newbins, min, max, kFALSE);
+      
+      h1 = new TProfile(pname, GetTitle(), nbins, min, max);
+      h1->SetDirectory(pname.IsNull() ? NULL : gROOT);
+      h1->SetXTitle("Radius from camera center [mm]");
+      h1->SetYTitle(GetYaxis()->GetTitle());
+    }
+  
+  // Fill the projected histogram
+  for (Int_t idx=0; idx<fNcells-2; idx++)
+    if (IsUsed(idx) && MatchSector(idx, sector, aidx))
+      h1->Fill(TMath::Hypot((*fGeomCam)[idx].GetX(),(*fGeomCam)[idx].GetY()),
+               GetBinContent(idx+1));
+  return h1;
+}
+
+
+// ------------------------------------------------------------------------
+//
+// Creates a TH1D which contains the projection of the contents of the
+// MHCamera onto the azimuth angle in the camera. 
+//
+// If no name is given the newly allocated histogram is removed from
+// the current directory calling SetDirectory(0) in any other case
+// the newly created histogram is removed from the current directory
+// and added to gROOT such the gROOT->FindObject can find the histogram.
+//
+// If the standard name "_azi" is given "_azi" is appended to the name
+// of the MHCamera and the corresponding histogram is searched using
+// gROOT->FindObject and updated with the present projection.
+//
+// It is the responsibility of the user to make sure, that the newly
+// created histogram is freed correctly.
+//
+// Currently the new histogram is restrictred to 60 bins.
+// Maybe a optimal number can be calulated from the number of
+// bins on the x-axis of the MHCamera?
+//
+// The code was taken mainly from TH2::ProjectX such the interface
+// is more or less the same than to TH2-projections.
+//
+TProfile *MHCamera::AzimuthProfileA(const TArrayI &aidx, const char *name, const Int_t nbins) const
+{
+  
+  // Create the projection histogram
+  TString pname(name);
+  if (name=="_azi")
+    {
+      pname.Prepend(GetName());
+      if (aidx.GetSize()>0)
+        {
+          pname += ";";
+          for (int i=0; i<aidx.GetSize(); i++)
+            pname += aidx[i];
+        }
+    }
+  
+  TProfile *h1=0;
+  
+  //check if histogram with identical name exist
+  TObject *h1obj = gROOT->FindObject(pname);
+  if (h1obj && h1obj->InheritsFrom("TProfile")) {
+    h1 = (TProfile*)h1obj;
+    h1->Reset();
+  }
+  
+  if (!h1)
+    {
+      
+      Double_t min = -0.5;
+      Double_t max = 359.5;
+      
+      Int_t newbins=0;
+      
+      THLimitsFinder::OptimizeLimits(nbins, newbins, min, max, kFALSE);
+      
+      h1 = new TProfile(pname, GetTitle(), nbins, min, max);
+      h1->SetDirectory(pname.IsNull() ? NULL : gROOT);
+      h1->SetXTitle("Azimuth in camera [deg]");
+      h1->SetYTitle(GetYaxis()->GetTitle());
+    }
+  
+  // Fill the projected histogram
+  for (Int_t idx=0; idx<fNcells-2; idx++)
+    {
+      if (IsUsed(idx) && MatchSector(idx, TArrayI(), aidx))
+        h1->Fill(TMath::ATan2((*fGeomCam)[idx].GetY(),(*fGeomCam)[idx].GetX())*180./TMath::Pi()+180.,
+                 GetPixContent(idx));
+      
+    }
+  
+  return h1;
+}
+
+
+// ------------------------------------------------------------------------
+//
+// Resizes the current pad so that the camera is displayed in its
+// correct aspect ratio
+//
+void MHCamera::SetRange()
+{
+    const Float_t range = fGeomCam->GetMaxRadius()*1.05;
+
+    //
+    // Maintain aspect ratio
+    //
+    const float ratio = TestBit(kNoLegend) ? 1 : 1.15;
+
+    //
+    // Calculate width and height of the current pad in pixels
+    //
+    Float_t w = gPad->GetWw();
+    Float_t h = gPad->GetWh()*ratio;
+
+    //
+    // This prevents the pad from resizing itself wrongly
+    //
+    if (gPad->GetMother() != gPad)
+    {
+        w *= gPad->GetMother()->GetAbsWNDC();
+        h *= gPad->GetMother()->GetAbsHNDC();
+    }
+
+    //
+    // Set Range (coordinate system) of pad
+    //
+    gPad->Range(-range, -range, (2*ratio-1)*range, range);
+
+    //
+    // Resize Pad to given ratio
+    //
+    if (h<w)
+        gPad->SetPad((1.-h/w)/2, 0, (h/w+1.)/2, 1);
+    else
+        gPad->SetPad(0, (1.-w/h)/2, 1, (w/h+1.)/2);
+}
+
+// ------------------------------------------------------------------------
+//
+// Updates the pixel colors and paints the pixels
+//
+void MHCamera::Update(Bool_t islog, Bool_t isbox, Bool_t iscol, Bool_t issame)
+{
+    Double_t min = GetMinimum(kFALSE);
+    Double_t max = GetMaximum(kFALSE);
+    if (min==FLT_MAX)
+    {
+        min = 0;
+        max = 1;
+    }
+
+    if (min==max)
+        max += 1;
+
+    if (!issame)
+        UpdateLegend(min, max, islog);
+
+    // Try to estimate the units of the current display. This is only
+    // necessary for 'same' option and allows distorted images of the camera!
+    const Float_t maxr = (1-fGeomCam->GetConvMm2Deg())*fGeomCam->GetMaxRadius()/2;
+    const Float_t conv = !issame ||
+        gPad->GetX1()<-maxr || gPad->GetY1()<-maxr ||
+        gPad->GetX2()> maxr || gPad->GetY2()>maxr ? 1 : fGeomCam->GetConvMm2Deg();
+
+    MHexagon hex;
+    for (Int_t i=0; i<fNcells-2; i++)
+    {
+        hex.SetFillStyle(issame ? 0 : 1001);
+
+        if (!issame)
+        {
+            if (IsUsed(i) && iscol)
+            {
+                if (TMath::IsNaN(fArray[i+1]))
+                    gLog << warn << "MHCamera::Update: " << GetName() << " <" << GetTitle() << "> - Pixel Index #" << i << " contents is NaN (Not a Number)..." << endl;
+
+                hex.SetFillColor(GetColor(GetBinContent(i+1), min, max, islog));
+            }
+            else
+                hex.SetFillColor(10);
+        }
+
+        const MGeomPix &pix = (*fGeomCam)[i];
+
+        Float_t x = pix.GetX()*conv/(fAbberation+1);
+        Float_t y = pix.GetY()*conv/(fAbberation+1);
+        Float_t d = pix.GetD()*conv;
+
+        if (!isbox)
+            hex.PaintHexagon(x, y, d);
+        else
+            if (IsUsed(i) && !TMath::IsNaN(fArray[i+1]))
+            {
+                Float_t size = d*(GetBinContent(i+1)-min)/(max-min);
+                if (size>d)
+                    size=d;
+                hex.PaintHexagon(x, y, size);
+            }
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// Print minimum and maximum
+//
+void MHCamera::Print(Option_t *) const
+{
+    gLog << all << "Minimum: " << GetMinimum();
+    if (fMinimum==-1111)
+        gLog << " <autoscaled>";
+    gLog << endl;
+    gLog << "Maximum: " << GetMaximum();
+    if (fMaximum==-1111)
+        gLog << " <autoscaled>";
+    gLog << endl;
+}
+
+// ------------------------------------------------------------------------
+//
+// Paint the y-axis title
+//
+void MHCamera::PaintAxisTitle()
+{
+    const Float_t range = fGeomCam->GetMaxRadius()*1.05;
+    const Float_t w = (1 + 1.5/sqrt((float)(fNcells-2)))*range;
+
+    TLatex *ptitle = new TLatex(w, -.90*range, GetYaxis()->GetTitle());
+
+    ptitle->SetTextSize(0.05);
+    ptitle->SetTextAlign(21);
+
+    // box with the histogram title
+    ptitle->SetTextColor(gStyle->GetTitleTextColor());
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,05,01)
+    ptitle->SetTextFont(gStyle->GetTitleFont(""));
+#endif
+    ptitle->Paint();
+}
+
+// ------------------------------------------------------------------------
+//
+// Paints the camera.
+//
+void MHCamera::Paint(Option_t *o)
+{
+    if (fNcells<=1)
+        return;
+
+    TString opt(o);
+    opt.ToLower();
+
+    if (opt.Contains("hist"))
+    {
+        opt.ReplaceAll("hist", "");
+        TH1D::Paint(opt);
+        return;
+    }
+
+    if (opt.Contains("proj"))
+    {
+      opt.ReplaceAll("proj", "");
+      Projection(GetName())->Paint(opt);
+      return;
+    }
+
+    const Bool_t hassame = opt.Contains("same");
+    const Bool_t hasbox  = opt.Contains("box");
+    const Bool_t hascol  = hasbox ? !opt.Contains("nocol") : kTRUE;
+
+    if (!hassame)
+    {
+        gPad->Clear();
+
+        // Maintain aspect ratio
+        SetRange();
+
+        if (GetPainter())
+        {
+            // Paint statistics
+            if (!TestBit(TH1::kNoStats))
+                fPainter->PaintStat(gStyle->GetOptStat(), NULL);
+
+            // Paint primitives (pixels, color legend, photons, ...)
+            if (fPainter->InheritsFrom(THistPainter::Class()))
+            {
+                static_cast<THistPainter*>(fPainter)->MakeChopt("");
+                static_cast<THistPainter*>(fPainter)->PaintTitle();
+            }
+        }
+    }
+
+    // Update Contents of the pixels and paint legend
+    Update(gPad->GetLogy(), hasbox, hascol, hassame);
+
+    if (!hassame)
+        PaintAxisTitle();
+
+    if (opt.Contains("pixelindex"))
+        PaintIndices(0);
+    if (opt.Contains("sectorindex"))
+        PaintIndices(1);
+    if (opt.Contains("content"))
+        PaintIndices(2);
+}
+
+// ------------------------------------------------------------------------
+//
+// With this function you can change the color palette. For more
+// information see TStyle::SetPalette. Only palettes with 50 colors
+// are allowed.
+// In addition you can use SetPalette(52, 0) to create an inverse
+// deep blue sea palette
+//
+void MHCamera::SetPalette(Int_t ncolors, Int_t *colors)
+{
+    //
+    // If not enough colors are specified skip this.
+    //
+    if (ncolors>1 && ncolors<50)
+    {
+        gLog << err << "MHCamera::SetPalette: Only default palettes with 50 colors are allowed... ignored." << endl;
+        return;
+    }
+
+    //
+    // If ncolors==52 create a reversed deep blue sea palette
+    //
+    if (ncolors==52)
+    {
+        gStyle->SetPalette(51, NULL);
+        TArrayI c(kItemsLegend);
+        for (int i=0; i<kItemsLegend; i++)
+            c[kItemsLegend-i-1] = gStyle->GetColorPalette(i);
+        gStyle->SetPalette(kItemsLegend, c.GetArray());
+    }
+    else
+        gStyle->SetPalette(ncolors, colors);
+
+    fColors.Set(kItemsLegend);
+    for (int i=0; i<kItemsLegend; i++)
+        fColors[i] = gStyle->GetColorPalette(i);
+}
+
+
+// ------------------------------------------------------------------------
+//
+// Changes the palette of the displayed camera histogram.
+//
+// Change to the right pad first - otherwise GetDrawOption() might fail.
+//
+void MHCamera::SetPrettyPalette()
+{
+    if (!TString(GetDrawOption()).Contains("hist", TString::kIgnoreCase))
+        SetPalette(1, 0);
+}
+
+// ------------------------------------------------------------------------
+//
+// Changes the palette of the displayed camera histogram.
+//
+// Change to the right pad first - otherwise GetDrawOption() might fail.
+//
+void MHCamera::SetDeepBlueSeaPalette()
+{
+    if (!TString(GetDrawOption()).Contains("hist", TString::kIgnoreCase))
+        SetPalette(51, 0);
+}
+
+// ------------------------------------------------------------------------
+//
+// Changes the palette of the displayed camera histogram.
+//
+// Change to the right pad first - otherwise GetDrawOption() might fail.
+//
+void MHCamera::SetInvDeepBlueSeaPalette()
+{
+    if (!TString(GetDrawOption()).Contains("hist", TString::kIgnoreCase))
+        SetPalette(52, 0);
+}
+
+// ------------------------------------------------------------------------
+//
+// Paint indices (as text) inside the pixels. Depending of the type-
+// argument we paint:
+//  0: pixel number
+//  1: sector number
+//  2: content
+//
+void MHCamera::PaintIndices(Int_t type)
+{
+    if (fNcells<=1)
+        return;
+
+    const Double_t min = GetMinimum();
+    const Double_t max = GetMaximum();
+
+    if (type==2 && max==min)
+        return;
+
+    TText txt;
+    txt.SetTextFont(122);
+    txt.SetTextAlign(22);   // centered/centered
+
+    for (Int_t i=0; i<fNcells-2; i++)
+    {
+        const MGeomPix &h = (*fGeomCam)[i];
+
+        TString num;
+        switch (type)
+        {
+        case 0: num += i; break;
+        case 1: num += h.GetSector(); break;
+        case 2: num += (Int_t)((fArray[i+1]-min)/(max-min)); break;
+        }
+
+        // FIXME: Should depend on the color of the pixel...
+        //(GetColor(GetBinContent(i+1), min, max, 0));
+        txt.SetTextColor(kRed);
+        txt.SetTextSize(0.3*h.GetD()/fGeomCam->GetMaxRadius()/1.05);
+        txt.PaintText(h.GetX(), h.GetY(), num);
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// Call this function to add a MCamEvent on top of the present contents.
+//
+void MHCamera::AddCamContent(const MCamEvent &event, Int_t type)
+{
+    if (fNcells<=1 || IsFreezed())
+        return;
+
+    // FIXME: Security check missing!
+    for (Int_t idx=0; idx<fNcells-2; idx++)
+    {
+        Double_t val=0;
+        if (event.GetPixelContent(val, idx, *fGeomCam, type)/* && !IsUsed(idx)*/)
+            SetUsed(idx);
+
+        Fill(idx, val); // FIXME: Slow!
+    }
+    fEntries++;
+}
+
+// ------------------------------------------------------------------------
+//
+// Call this function to add a MCamEvent on top of the present contents.
+//
+void MHCamera::SetCamError(const MCamEvent &evt, Int_t type)
+{
+
+    if (fNcells<=1 || IsFreezed())
+        return;
+
+    // FIXME: Security check missing!
+    for (Int_t idx=0; idx<fNcells-2; idx++)
+    {
+        Double_t val=0;
+        if (evt.GetPixelContent(val, idx, *fGeomCam, type)/* && !IsUsed(idx)*/)
+            SetUsed(idx);
+
+        SetBinError(idx+1, val); // FIXME: Slow!
+    }
+}
+
+Stat_t MHCamera::GetBinError(Int_t bin) const
+{
+    Double_t rc = 0;
+    if (TestBit(kVariance) && GetEntries()>0) // error on the mean
+    {
+        const Double_t error = fSumw2.fArray[bin]/GetEntries();
+        const Double_t val   = fArray[bin]/GetEntries();
+        rc = TMath::Sqrt(error - val*val);
+    }
+    else
+      {
+        rc = TH1D::GetBinError(bin);
+	rc = Profile(rc);
+      }
+
+    return rc;
+}
+
+// ------------------------------------------------------------------------
+//
+// Call this function to add a MHCamera on top of the present contents.
+// Type:
+//  0) bin content
+//  1) errors
+//  2) rel. errors
+//
+void MHCamera::AddCamContent(const MHCamera &d, Int_t type)
+{
+    if (fNcells!=d.fNcells || IsFreezed())
+        return;
+
+    // FIXME: Security check missing!
+    for (Int_t idx=0; idx<fNcells-2; idx++)
+        if (d.IsUsed(idx))
+            SetUsed(idx);
+
+    switch (type)
+    {
+    case 1:
+        for (Int_t idx=0; idx<fNcells-2; idx++)
+            Fill(idx, d.GetBinError(idx+1));
+        break;
+    case 2:
+        for (Int_t idx=0; idx<fNcells-2; idx++)
+            if (d.GetBinContent(idx+1)!=0)
+                Fill(idx, TMath::Abs(d.GetBinError(idx+1)/d.GetBinContent(idx+1)));
+        break;
+    default:
+        for (Int_t idx=0; idx<fNcells-2; idx++)
+            Fill(idx, d.GetBinContent(idx+1));
+        break;
+    }
+    fEntries++;
+}
+
+// ------------------------------------------------------------------------
+//
+// Call this function to add a TArrayD on top of the present contents.
+//
+void MHCamera::AddCamContent(const TArrayD &event, const TArrayC *used)
+{
+    if (event.GetSize()!=fNcells-2 || IsFreezed())
+        return;
+
+    if (used && used->GetSize()!=fNcells-2)
+        return;
+
+    for (Int_t idx=0; idx<fNcells-2; idx++)
+    {
+        Fill(idx, const_cast<TArrayD&>(event)[idx]); // FIXME: Slow!
+
+        if (!used || (*const_cast<TArrayC*>(used))[idx])
+            SetUsed(idx);
+    }
+    fEntries++;
+}
+
+// ------------------------------------------------------------------------
+//
+// Call this function to add a MCamEvent on top of the present contents.
+// 1 is added to each pixel if the contents of MCamEvent>threshold (in case isabove is set to kTRUE == default)
+// 1 is added to each pixel if the contents of MCamEvent<threshold (in case isabove is set to kFALSE)
+//
+void MHCamera::CntCamContent(const MCamEvent &event, Double_t threshold, Int_t type, Bool_t isabove)
+{
+    if (fNcells<=1 || IsFreezed())
+        return;
+
+    // FIXME: Security check missing!
+    for (Int_t idx=0; idx<fNcells-2; idx++)
+    {
+        Double_t val=threshold;
+        if (event.GetPixelContent(val, idx, *fGeomCam, type)/* && !IsUsed(idx)*/)
+            SetUsed(idx);
+
+        if (val>threshold && isabove)
+            Fill(idx);
+        if (val<threshold && !isabove)
+            Fill(idx);
+    }
+    fEntries++;
+}
+
+// ------------------------------------------------------------------------
+//
+// Call this function to add a MCamEvent on top of the present contents.
+// 1 is added to each pixel if the contents of MCamEvent>threshold (in case isabove is set to kTRUE == default)
+// 1 is added to each pixel if the contents of MCamEvent<threshold (in case isabove is set to kFALSE)
+//
+void MHCamera::CntCamContent(const MCamEvent &event, TArrayD threshold, Int_t type, Bool_t isabove)
+{
+    if (fNcells<=1 || IsFreezed())
+        return;
+
+    // FIXME: Security check missing!
+    for (Int_t idx=0; idx<fNcells-2; idx++)
+    {
+        Double_t val=threshold[idx];
+        if (event.GetPixelContent(val, idx, *fGeomCam, type)/* && !IsUsed(idx)*/)
+            SetUsed(idx);
+
+        if (val>threshold[idx] && isabove)
+            Fill(idx);
+        if (val<threshold[idx] && !isabove)
+            Fill(idx);
+    }
+    fEntries++;
+}
+
+// ------------------------------------------------------------------------
+//
+// Call this function to add a TArrayD on top of the present contents.
+// 1 is added to each pixel if the contents of MCamEvent>threshold
+//
+void MHCamera::CntCamContent(const TArrayD &event, Double_t threshold, Bool_t ispos)
+{
+    if (event.GetSize()!=fNcells-2 || IsFreezed())
+        return;
+
+    for (Int_t idx=0; idx<fNcells-2; idx++)
+    {
+        if (const_cast<TArrayD&>(event)[idx]>threshold)
+            Fill(idx);
+
+        if (!ispos || fArray[idx+1]>0)
+            SetUsed(idx);
+    }
+    fEntries++;
+}
+
+// ------------------------------------------------------------------------
+//
+// Fill the pixels with random contents.
+//
+void MHCamera::FillRandom()
+{
+    if (fNcells<=1 || IsFreezed())
+        return;
+
+    Reset();
+
+    // FIXME: Security check missing!
+    for (Int_t idx=0; idx<fNcells-2; idx++)
+    {
+        Fill(idx, gRandom->Uniform()*fGeomCam->GetPixRatio(idx));
+        SetUsed(idx);
+    }
+    fEntries=1;
+}
+
+
+// ------------------------------------------------------------------------
+//
+// The array must be in increasing order, eg: 2.5, 3.7, 4.9
+// The values in each bin are replaced by the interval in which the value
+// fits. In the example we have four intervals
+// (<2.5, 2.5-3.7, 3.7-4.9, >4.9). Maximum and minimum are set
+// accordingly.
+//
+void MHCamera::SetLevels(const TArrayF &arr)
+{
+    if (fNcells<=1)
+        return;
+
+    for (Int_t i=0; i<fNcells-2; i++)
+    {
+        if (!IsUsed(i))
+            continue;
+
+        Int_t j = arr.GetSize();
+        while (j && fArray[i+1]<arr[j-1])
+            j--;
+
+        fArray[i+1] = j;
+    }
+    SetMaximum(arr.GetSize());
+    SetMinimum(0);
+}
+
+// ------------------------------------------------------------------------
+//
+// Reset the all pixel colors to a default value
+//
+void MHCamera::Reset(Option_t *opt)
+{
+    if (fNcells<=1 || IsFreezed())
+        return;
+
+    TH1::Reset(opt);
+
+    for (Int_t i=0; i<fNcells-2; i++)
+    {
+        fArray[i+1]=0;
+        ResetUsed(i);
+    }
+    fArray[0]         = 0;
+    fArray[fNcells-1] = 0;
+} 
+
+// ------------------------------------------------------------------------
+//
+//  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 MHCamera::GetColor(Float_t val, Float_t min, Float_t max, Bool_t islog)
+{
+    if (TMath::IsNaN(val)) // FIXME: gLog!
+        return 10;
+
+    //
+    //   first treat the over- and under-flows
+    //
+    const Int_t maxcolidx = kItemsLegend-1;
+
+    if (val >= max)
+        return fColors[maxcolidx];
+
+    if (val <= min)
+        return fColors[0];
+
+    //
+    // calculate the color index
+    //
+    Float_t ratio;
+    if (islog && min>0)
+        ratio = log10(val/min) / log10(max/min);
+    else
+        ratio = (val-min) / (max-min);
+
+    const Int_t colidx = (Int_t)(ratio*maxcolidx + .5);
+    return fColors[colidx];
+}
+
+TPaveStats *MHCamera::GetStatisticBox()
+{
+    TObject *obj = 0;
+
+    TIter Next(fFunctions);
+    while ((obj = Next()))
+        if (obj->InheritsFrom(TPaveStats::Class()))
+            return static_cast<TPaveStats*>(obj);
+
+    return NULL;
+}
+
+// ------------------------------------------------------------------------
+//
+//  Change the text on the legend according to the range of the Display
+//
+void MHCamera::UpdateLegend(Float_t min, Float_t max, Bool_t islog)
+{
+    const Float_t range = fGeomCam->GetMaxRadius()*1.05;
+
+    TArrow arr;
+    arr.PaintArrow(-range*.9, -range*.9, -range*.6, -range*.9, 0.025);
+    arr.PaintArrow(-range*.9, -range*.9, -range*.9, -range*.6, 0.025);
+
+    TString text;
+    text += (int)(range*.3);
+    text += "mm";
+
+    TText newtxt2;
+    newtxt2.SetTextSize(0.04);
+    newtxt2.PaintText(-range*.85, -range*.85, text);
+
+    text = "";
+    text += (float)((int)(range*.3*fGeomCam->GetConvMm2Deg()*10))/10;
+    text += "\\circ";
+    text = text.Strip(TString::kLeading);
+
+    TLatex latex;
+    latex.PaintLatex(-range*.85, -range*.75, 0, 0.04, text);
+
+    if (TestBit(kNoLegend))
+        return;
+
+    TPaveStats *stats = GetStatisticBox();
+
+    const Float_t hndc   = 0.92 - (stats ? stats->GetY1NDC() : 1);
+    const Float_t H      = (0.75-hndc)*range;
+    const Float_t offset = hndc*range;
+
+    const Float_t h = 2./kItemsLegend;
+    const Float_t w = range/sqrt((float)(fNcells-2));
+
+    TBox newbox;
+    TText newtxt;
+    newtxt.SetTextSize(0.03);
+    newtxt.SetTextAlign(12);
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+    newtxt.SetBit(/*kNoContextMenu|*/kCannotPick);
+    newbox.SetBit(/*kNoContextMenu|*/kCannotPick);
+#endif
+
+    const Float_t step   = (islog && min>0 ? log10(max/min) : max-min) / kItemsLegend;
+    const Int_t   firsts = step*3 < 1e-8 ? 8 : (Int_t)floor(log10(step*3));
+    const TString opt    = Form("%%.%if", firsts>0 ? 0 : TMath::Abs(firsts));
+
+    for (Int_t i=0; i<kItemsLegend+1; i+=3)
+    {
+        Float_t val;
+        if (islog && min>0)
+            val = pow(10, step*i) * min;
+        else
+            val = min + step*i;
+
+        //const bool dispexp = max-min>1.5 && fabs(val)>0.1 && fabs(val)<1e6;
+        newtxt.PaintText(range+1.5*w, H*(i*h-1)-offset, Form(opt, val));
+    }
+
+    for (Int_t i=0; i<kItemsLegend; i++)
+    {
+        newbox.SetFillColor(fColors[i]);
+        newbox.PaintBox(range, H*(i*h-1)-offset, range+w, H*((i+1)*h-1)-offset);
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// Save primitive as a C++ statement(s) on output stream out
+//
+void MHCamera::SavePrimitive(ofstream &out, Option_t *opt)
+{
+    gLog << err << "MHCamera::SavePrimitive: Must be rewritten!" << endl;
+    /*
+    if (!gROOT->ClassSaved(TCanvas::Class()))
+        fDrawingPad->SavePrimitive(out, opt);
+
+    out << "   " << fDrawingPad->GetName() << "->SetWindowSize(";
+    out << fDrawingPad->GetWw() << "," << fDrawingPad->GetWh() << ");" << endl;
+    */
+}
+
+// ------------------------------------------------------------------------
+//
+// compute the distance of a point (px,py) to the Camera
+// this functions needed for graphical primitives, that
+// means without this function you are not able to interact
+// with the graphical primitive with the mouse!!!
+//
+// All calcutations are done in pixel coordinates
+//
+Int_t MHCamera::DistancetoPrimitive(Int_t px, Int_t py)
+{
+    if (fNcells<=1)
+        return 999999;
+
+    TPaveStats *box = (TPaveStats*)gPad->GetPrimitive("stats");
+    if (box)
+    {
+        const Double_t w = box->GetY2NDC()-box->GetY1NDC();
+        box->SetX1NDC(gStyle->GetStatX()-gStyle->GetStatW());
+        box->SetY1NDC(gStyle->GetStatY()-w);
+        box->SetX2NDC(gStyle->GetStatX());
+        box->SetY2NDC(gStyle->GetStatY());
+    }
+
+    if (TString(GetDrawOption()).Contains("hist", TString::kIgnoreCase))
+        return TH1D::DistancetoPrimitive(px, py);
+
+    const Bool_t issame = TString(GetDrawOption()).Contains("same", TString::kIgnoreCase);
+
+    const Float_t maxr = (1-fGeomCam->GetConvMm2Deg())*fGeomCam->GetMaxRadius()/2;
+    const Float_t conv = !issame ||
+        gPad->GetX1()<-maxr || gPad->GetY1()<-maxr ||
+        gPad->GetX2()> maxr || gPad->GetY2()>maxr ? 1 : fGeomCam->GetConvMm2Deg();
+
+    if (GetPixelIndex(px, py, conv)>=0)
+        return 0;
+
+    if (!box)
+        return 999999;
+
+    const Int_t dist = box->DistancetoPrimitive(px, py);
+    if (dist > TPad::GetMaxPickDistance())
+        return 999999;
+
+    gPad->SetSelected(box);
+    return dist;
+}
+
+// ------------------------------------------------------------------------
+//
+//
+Int_t MHCamera::GetPixelIndex(Int_t px, Int_t py, Float_t conv) const
+{
+    if (fNcells<=1)
+        return -1;
+
+    Int_t i;
+    for (i=0; i<fNcells-2; i++)
+    {
+        MHexagon hex((*fGeomCam)[i]);
+        if (hex.DistancetoPrimitive(px, py, conv)>0)
+            continue;
+
+        return i;
+    }
+    return -1;
+}
+
+// ------------------------------------------------------------------------
+//
+// Returns string containing info about the object at position (px,py).
+// Returned string will be re-used (lock in MT environment).
+//
+char *MHCamera::GetObjectInfo(Int_t px, Int_t py) const
+{
+    if (TString(GetDrawOption()).Contains("hist", TString::kIgnoreCase))
+        return TH1D::GetObjectInfo(px, py);
+
+    static char info[128];
+
+    const Int_t idx=GetPixelIndex(px, py);
+
+    if (idx<0)
+        return TObject::GetObjectInfo(px, py);
+
+    sprintf(info, "Software Pixel Index: %d (Hardware Id=%d)", idx, idx+1);
+    return info;
+}
+
+// ------------------------------------------------------------------------
+//
+// Add a MCamEvent which should be displayed when the user clicks on a
+// pixel.
+// Warning: The object MUST inherit from TObject AND MCamEvent
+//
+void MHCamera::AddNotify(TObject *obj)
+{
+    // Make sure, that the object derives from MCamEvent!
+    MCamEvent *evt = dynamic_cast<MCamEvent*>(obj);
+    if (!evt)
+    {
+        gLog << err << "ERROR: MHCamera::AddNotify - TObject doesn't inherit from MCamEvent... ignored." << endl;
+        return;
+    }
+
+    // Make sure, that it is deleted from the list too, if the obj is deleted
+    obj->SetBit(kMustCleanup);
+
+    // Add object to list
+    fNotify->Add(obj);
+}
+
+// ------------------------------------------------------------------------
+//
+// Execute a mouse event on the camera
+//
+void MHCamera::ExecuteEvent(Int_t event, Int_t px, Int_t py)
+{
+    if (TString(GetDrawOption()).Contains("hist", TString::kIgnoreCase))
+    {
+        TH1D::ExecuteEvent(event, px, py);
+        return;
+    }
+    //if (event==kMouseMotion && fStatusBar)
+    //    fStatusBar->SetText(GetObjectInfo(px, py), 0);
+    if (event!=kButton1Down)
+        return;
+
+    const Int_t idx = GetPixelIndex(px, py);
+    if (idx<0)
+        return;
+
+    gLog << all << GetTitle() << " <" << GetName() << ">" << endl;
+    gLog << "Software Pixel Idx: " << idx << endl;
+    gLog << "Hardware Pixel Id:  " << idx+1 << endl;
+    gLog << "Contents:           " << GetBinContent(idx+1);
+    if (GetBinError(idx+1)>0)
+        gLog << " +/- " << GetBinError(idx+1);
+    gLog << "  <" << (IsUsed(idx)?"on":"off") << ">" << endl;
+
+    if (fNotify && fNotify->GetSize()>0)
+    {
+        // FIXME: Is there a simpler and more convinient way?
+
+        // The name which is created here depends on the instance of
+        // MHCamera and on the pad on which it is drawn --> The name
+        // is unique. For ExecuteEvent gPad is always correctly set.
+        const TString name = Form("%p;%p;PixelContent", this, gPad);
+
+        TCanvas *old = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(name);
+        if (old)
+            old->cd();
+        else
+            new TCanvas(name);
+
+        /*
+         TIter Next(gPad->GetListOfPrimitives());
+         TObject *o;
+         while (o=Next()) cout << o << ": " << o->GetName() << " " << o->IsA()->GetName() << endl;
+         */
+
+        // FIXME: Make sure, that the old histograms are really deleted.
+        //        Are they already deleted?
+
+        // The dynamic_cast is necessary here: We cannot use ForEach
+        TIter Next(fNotify);
+        MCamEvent *evt;
+        while ((evt=dynamic_cast<MCamEvent*>(Next())))
+            evt->DrawPixelContent(idx);
+
+        gPad->Modified();
+        gPad->Update();
+    }
+}
+
+UInt_t MHCamera::GetNumPixels() const
+{
+    return fGeomCam->GetNumPixels();
+}
+
+TH1 *MHCamera::DrawCopy() const
+{
+    gPad=NULL;
+    return TH1D::DrawCopy(fName+";cpy");
+} 
+
+
+// --------------------------------------------------------------------------
+//
+// Draw a projection of MHCamera onto the y-axis values. Depending on the 
+// variable fit, the following fits are performed:
+//
+// 0: No fit, simply draw the projection
+// 1: Single Gauss (for distributions flat-fielded over the whole camera)
+// 2: Double Gauss (for distributions different for inner and outer pixels)
+// 3: Triple Gauss (for distributions with inner, outer pixels and outliers)
+// 4: flat         (for the probability distributions)
+// (1-4:) Moreover, sectors 6,1 and 2 of the camera and sectors 3,4 and 5 are 
+//        drawn separately, for inner and outer pixels.
+// 5: Fit Inner and Outer pixels separately by a single Gaussian 
+//                 (only for MAGIC cameras)
+// 6: Fit Inner and Outer pixels separately by a single Gaussian and display 
+//                 additionally the two camera halfs separately (for MAGIC camera)
+// 7: Single Gauss with TLegend to show the meaning of the colours
+//
+//
+void MHCamera::DrawProjection(Int_t fit) const
+{
+  
+  TArrayI inner(1);
+  inner[0] = 0;
+  
+  TArrayI outer(1);
+  outer[0] = 1;
+          
+  if (fit==5 || fit==6)
+    {
+      
+      if (GetGeomCam().InheritsFrom("MGeomCamMagic"))
+        {
+          TArrayI s0(6);
+          s0[0] = 6;
+          s0[1] = 1;
+          s0[2] = 2;
+          s0[3] = 3;
+          s0[4] = 4;
+          s0[5] = 5;
+
+          TArrayI s1(3);
+          s1[0] = 6;
+          s1[1] = 1;
+          s1[2] = 2;
+          
+          TArrayI s2(3);
+          s2[0] = 3;
+          s2[1] = 4;
+          s2[2] = 5;
+
+          gPad->Clear();
+          TVirtualPad *pad = gPad;
+          pad->Divide(2,1);
+          
+          TH1D *inout[2];
+          inout[0] = ProjectionS(s0, inner, "Inner");
+          inout[1] = ProjectionS(s0, outer, "Outer");
+          
+          inout[0]->SetDirectory(NULL);
+          inout[1]->SetDirectory(NULL);
+
+          for (int i=0; i<2; i++)
+            {
+              pad->cd(i+1);
+              inout[i]->SetLineColor(kRed+i);
+              inout[i]->SetBit(kCanDelete);
+              inout[i]->Draw();
+              inout[i]->Fit("gaus","Q");
+              
+              
+              if (fit == 6)
+                {
+                  TH1D *half[2];
+                  half[0] = ProjectionS(s1, i==0 ? inner : outer , "Sector 6-1-2");
+                  half[1] = ProjectionS(s2, i==0 ? inner : outer , "Sector 3-4-5");
+                  
+                  for (int j=0; j<2; j++)
+                    {
+                      half[j]->SetLineColor(kRed+i+2*j+1);
+                      half[j]->SetDirectory(NULL);
+                      half[j]->SetBit(kCanDelete);
+                      half[j]->Draw("same");
+                    }
+                }
+              
+            }
+          
+          gLog << all << GetName() 
+               << Form("%s%5.3f%s%3.2f"," Inner Pixels: ",
+                       inout[0]->GetFunction("gaus")->GetParameter(1),"+-",
+                       inout[0]->GetFunction("gaus")->GetParameter(2));
+          gLog << Form("%s%5.3f%s%3.2f"," Outer Pixels: ",
+                       inout[1]->GetFunction("gaus")->GetParameter(1),"+-",
+                       inout[1]->GetFunction("gaus")->GetParameter(2)) << endl;
+
+        }
+      return;
+    }
+  
+  TH1D *obj2 = (TH1D*)Projection(GetName());
+  obj2->SetDirectory(0);
+  obj2->Draw();
+  obj2->SetBit(kCanDelete);
+  
+  if (fit == 0)
+    return;
+  
+  if (GetGeomCam().InheritsFrom("MGeomCamMagic"))
+    {
+      TArrayI s0(3);
+      s0[0] = 6;
+      s0[1] = 1;
+      s0[2] = 2;
+      
+      TArrayI s1(3);
+      s1[0] = 3;
+      s1[1] = 4;
+      s1[2] = 5;
+      
+      
+      TH1D *halfInOut[4];
+      
+      // Just to get the right (maximum) binning
+      halfInOut[0] = ProjectionS(s0, inner, "Sector 6-1-2 Inner");
+      halfInOut[1] = ProjectionS(s1, inner, "Sector 3-4-5 Inner");
+      halfInOut[2] = ProjectionS(s0, outer, "Sector 6-1-2 Outer");
+      halfInOut[3] = ProjectionS(s1, outer, "Sector 3-4-5 Outer");
+
+      TLegend *leg = new TLegend(0.05,0.65,0.35,0.9);
+      
+      for (int i=0; i<4; i++)
+        {
+          halfInOut[i]->SetLineColor(kRed+i);
+          halfInOut[i]->SetDirectory(0);
+          halfInOut[i]->SetBit(kCanDelete);
+          halfInOut[i]->Draw("same");
+          leg->AddEntry(halfInOut[i],halfInOut[i]->GetTitle(),"l");
+        }
+
+      if (fit==7)
+        leg->Draw();
+      
+      gPad->Modified();
+      gPad->Update();
+    }
+  
+  const Double_t min   = obj2->GetBinCenter(obj2->GetXaxis()->GetFirst());
+  const Double_t max   = obj2->GetBinCenter(obj2->GetXaxis()->GetLast());
+  const Double_t integ = obj2->Integral("width")/2.5;
+  const Double_t mean  = obj2->GetMean();
+  const Double_t rms   = obj2->GetRMS();
+  const Double_t width = max-min;
+  
+  const TString dgausformula = "([0]-[3])/[2]*exp(-0.5*(x-[1])*(x-[1])/[2]/[2])"
+    "+[3]/[5]*exp(-0.5*(x-[4])*(x-[4])/[5]/[5])";
+  
+  const TString tgausformula = "([0]-[3]-[6])/[2]*exp(-0.5*(x-[1])*(x-[1])/[2]/[2])"
+    "+[3]/[5]*exp(-0.5*(x-[4])*(x-[4])/[5]/[5])"
+    "+[6]/[8]*exp(-0.5*(x-[7])*(x-[7])/[8]/[8])";
+  TF1 *f=0;
+  switch (fit)
+    {
+    case 1:
+      f = new TF1("sgaus", "gaus(0)", min, max);
+      f->SetLineColor(kYellow);
+      f->SetBit(kCanDelete);
+      f->SetParNames("Area", "#mu", "#sigma");
+      f->SetParameters(integ/rms, mean, rms);
+      f->SetParLimits(0, 0,   integ);
+      f->SetParLimits(1, min, max);
+      f->SetParLimits(2, 0,   width/1.5);
+      
+      obj2->Fit(f, "QLR");
+      break;
+      
+    case 2:
+      f = new TF1("dgaus",dgausformula.Data(),min,max);
+      f->SetLineColor(kYellow);
+      f->SetBit(kCanDelete);
+      f->SetParNames("A_{tot}", "#mu1", "#sigma1", "A2", "#mu2", "#sigma2");
+      f->SetParameters(integ,(min+mean)/2.,width/4.,
+                       integ/width/2.,(max+mean)/2.,width/4.);
+      // The left-sided Gauss
+      f->SetParLimits(0,integ-1.5      , integ+1.5);
+      f->SetParLimits(1,min+(width/10.), mean);
+      f->SetParLimits(2,0              , width/2.);
+      // The right-sided Gauss
+      f->SetParLimits(3,0   , integ);
+      f->SetParLimits(4,mean, max-(width/10.));
+      f->SetParLimits(5,0   , width/2.);
+      obj2->Fit(f,"QLRM");
+      break;
+      
+    case 3:
+      f = new TF1("tgaus",tgausformula.Data(),min,max);
+      f->SetLineColor(kYellow);
+      f->SetBit(kCanDelete);
+      f->SetParNames("A_{tot}","#mu_{1}","#sigma_{1}",
+                     "A_{2}","#mu_{2}","#sigma_{2}",
+                     "A_{3}","#mu_{3}","#sigma_{3}");
+      f->SetParameters(integ,(min+mean)/2,width/4.,
+                       integ/width/3.,(max+mean)/2.,width/4.,
+                       integ/width/3.,mean,width/2.);
+      // The left-sided Gauss
+      f->SetParLimits(0,integ-1.5,integ+1.5);
+      f->SetParLimits(1,min+(width/10.),mean);
+      f->SetParLimits(2,width/15.,width/2.);
+      // The right-sided Gauss
+      f->SetParLimits(3,0.,integ);
+      f->SetParLimits(4,mean,max-(width/10.));
+      f->SetParLimits(5,width/15.,width/2.);
+      // The Gauss describing the outliers
+      f->SetParLimits(6,0.,integ);
+      f->SetParLimits(7,min,max);
+      f->SetParLimits(8,width/4.,width/1.5);
+      obj2->Fit(f,"QLRM");
+      break;
+      
+    case 4:
+      obj2->Fit("pol0", "Q");
+      obj2->GetFunction("pol0")->SetLineColor(kYellow);
+      break;
+      
+    case 9:
+      break;
+      
+    default:
+      obj2->Fit("gaus", "Q");
+      obj2->GetFunction("gaus")->SetLineColor(kYellow);
+      break;
+    }
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Draw a projection of MHCamera vs. the radius from the central pixel. 
+//
+// The inner and outer pixels are drawn separately, both fitted by a polynomial
+// of grade 1.
+//
+void MHCamera::DrawRadialProfile() const
+{
+  
+  TProfile *obj2 = (TProfile*)RadialProfile(GetName());
+  obj2->SetDirectory(0);
+  obj2->Draw();
+  obj2->SetBit(kCanDelete);
+  
+  if (GetGeomCam().InheritsFrom("MGeomCamMagic"))
+    {
+
+      TArrayI s0(6);
+      s0[0] = 1;
+      s0[1] = 2;
+      s0[2] = 3;
+      s0[3] = 4;
+      s0[4] = 5;
+      s0[5] = 6;
+
+      TArrayI inner(1);
+      inner[0] = 0;
+      
+      TArrayI outer(1);
+      outer[0] = 1;
+      
+      // Just to get the right (maximum) binning
+      TProfile *half[2];
+      half[0] = RadialProfileS(s0, inner,Form("%s%s",GetName(),"Inner"));
+      half[1] = RadialProfileS(s0, outer,Form("%s%s",GetName(),"Outer"));
+      
+      for (Int_t i=0; i<2; i++)
+        {
+          Double_t min = GetGeomCam().GetMinRadius(i);
+          Double_t max = GetGeomCam().GetMaxRadius(i);
+
+          half[i]->SetLineColor(kRed+i);
+          half[i]->SetDirectory(0);
+          half[i]->SetBit(kCanDelete);
+          half[i]->Draw("same");
+          half[i]->Fit("pol1","Q","",min,max);
+          half[i]->GetFunction("pol1")->SetLineColor(kRed+i);
+          half[i]->GetFunction("pol1")->SetLineWidth(1);
+        }
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw a projection of MHCamera vs. the azimuth angle inside the camera.
+//
+// The inner and outer pixels are drawn separately. 
+// The general azimuth profile is fitted by a straight line
+//
+void MHCamera::DrawAzimuthProfile() const
+{
+  
+  TProfile *obj2 = (TProfile*)AzimuthProfile(GetName());
+  obj2->SetDirectory(0);
+  obj2->Draw();
+  obj2->SetBit(kCanDelete);
+  obj2->Fit("pol0","Q","");
+  obj2->GetFunction("pol0")->SetLineWidth(1);
+  
+  if (GetGeomCam().InheritsFrom("MGeomCamMagic"))
+    {
+
+      TArrayI inner(1);
+      inner[0] = 0;
+      
+      TArrayI outer(1);
+      outer[0] = 1;
+      
+      // Just to get the right (maximum) binning
+      TProfile *half[2];
+      half[0] = AzimuthProfileA(inner,Form("%s%s",GetName(),"Inner"));
+      half[1] = AzimuthProfileA(outer,Form("%s%s",GetName(),"Outer"));
+      
+      for (Int_t i=0; i<2; i++)
+        {
+          half[i]->SetLineColor(kRed+i);
+          half[i]->SetDirectory(0);
+          half[i]->SetBit(kCanDelete);
+          half[i]->SetMarkerSize(0.5);
+          half[i]->Draw("same");
+        }
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw the MHCamera into the MStatusDisplay: 
+// 
+// 1) Draw it as histogram (MHCamera::DrawCopy("hist")
+// 2) Draw it as a camera, with MHCamera::SetPrettyPalette() set. 
+// 3) If "rad" is not zero, draw its values vs. the radius from the camera center. 
+//    (DrawRadialProfile())
+// 4) Depending on the variable "fit", draw the values projection on the y-axis
+//    (DrawProjection()):
+//    0: don't draw
+//    1: Draw fit to Single Gauss (for distributions flat-fielded over the whole camera)
+//    2: Draw and fit to Double Gauss (for distributions different for inner and outer pixels)
+//    3: Draw and fit to Triple Gauss (for distributions with inner, outer pixels and outliers)
+//    4: Draw and fit to Polynomial grade 0: (for the probability distributions)
+//    >4: Draw and don;t fit.
+//
+void MHCamera::CamDraw(TCanvas &c, const Int_t x, const Int_t y, 
+                       const Int_t fit, const Int_t rad, const Int_t azi,
+                       TObject *notify)
+{
+
+  c.cd(x);
+  gPad->SetBorderMode(0);
+  gPad->SetTicks();
+  MHCamera *obj1=(MHCamera*)DrawCopy("hist");
+  obj1->SetDirectory(NULL);
+  
+  if (notify)
+    obj1->AddNotify(notify);
+
+  c.cd(x+y);
+  gPad->SetBorderMode(0);
+  obj1->SetPrettyPalette();
+  obj1->Draw();
+
+  Int_t cnt = 2;
+
+  if (rad)
+    {
+      c.cd(x+2*y);
+      gPad->SetBorderMode(0);
+      gPad->SetTicks();
+      DrawRadialProfile();
+      cnt++;
+    }
+  
+  if (azi)
+    {
+      c.cd(x+cnt*y);
+      gPad->SetBorderMode(0);
+      gPad->SetTicks();
+      DrawAzimuthProfile();
+      cnt++;
+    }
+  
+  if (!fit)
+    return;
+  
+  c.cd(x + cnt*y);
+  gPad->SetBorderMode(0);
+  gPad->SetTicks();
+  DrawProjection(fit);
+}
+
+
Index: /tags/Mars_V0-8-5/Mars/mhist/MHCamera.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHCamera.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHCamera.h	(revision 9661)
@@ -0,0 +1,439 @@
+#ifndef MARS_MHCamera
+#define MARS_MHCamera
+
+#ifndef MARS_MAGIC
+#include "MAGIC.h"
+#endif
+#ifndef ROOT_TArrayC
+#include <TArrayC.h>
+#endif
+#ifndef ROOT_TArrayI
+#include <TArrayI.h>
+#endif
+#ifndef ROOT_TArrayD
+#include <TArrayD.h>
+#endif
+#ifndef ROOT_TClonesArray
+#include <TClonesArray.h>
+#endif
+#ifndef ROOT_TH1
+#include <TH1.h>
+#endif
+#ifndef ROOT_TCanvas
+#include <TCanvas.h>
+#endif
+
+class TPaveStats;
+class TProfile;
+
+class MGeomCam;
+class MCamEvent;
+class MRflEvtData;
+class MCerPhotEvt;
+class MImgCleanStd;
+
+class MHCamera : public TH1D
+{
+public:
+    enum {
+        kProfile  = BIT(18), // FIXME: When changing change max/min!
+        kFreezed  = BIT(19),
+        kNoLegend = BIT(20),
+        kVariance = BIT(21)
+    };
+private:
+    MGeomCam      *fGeomCam;     // pointer to camera geometry (y-axis)
+    TArrayC        fUsed;        // array containing flags
+
+    TArrayI        fColors;      //! Color conversion table
+    TList         *fNotify;      //!
+
+//#if ROOT_VERSION_CODE < ROOT_VERSION(4,00,03)
+    Bool_t         fFreezed;     //! Just a dummy!!!! ([Set,Is]Freezed)
+//#endif
+
+    Float_t fAbberation;
+
+    void Init();
+
+    Stat_t Profile(Stat_t val) const
+    {
+        if (!TestBit(kProfile))
+            return val;
+
+        const Stat_t n = TH1D::GetEntries();
+        return n>0 ? val/n : val;
+    }
+
+    Int_t GetColor(Float_t val, Float_t min, Float_t max, Bool_t islog);
+
+    void  PaintIndices(Int_t type);
+    void  Update(Bool_t islog, Bool_t isbox, Bool_t iscol, Bool_t issame);
+    void  UpdateLegend(Float_t min, Float_t max, Bool_t islog);
+    void  SetRange();
+
+    TPaveStats *GetStatisticBox();
+
+    Int_t GetPixelIndex(Int_t px, Int_t py, Float_t conv=1) const;
+
+    void PaintAxisTitle();
+
+    enum {
+        kIsUsed = BIT(1)
+    };
+
+    void   ResetUsed(Int_t idx)    { CLRBIT(fUsed[idx], kIsUsed); }
+
+    Bool_t FindVal(const TArrayI &arr, Int_t val) const
+    {
+        const Int_t n = arr.GetSize();
+        if (n==0)
+            return kTRUE;
+
+        const Int_t *p = arr.GetArray();
+        const Int_t *end = p+n;
+        while (p<end)
+            if (val==*p++)
+                return kTRUE;
+
+        return kFALSE;
+    }
+    Bool_t MatchSector(Int_t idx, const TArrayI &sector, const TArrayI &aidx) const;
+
+    // This is a trick to remove TH1 entries from the context menu
+    TH1 *Rebin(Int_t ngroup=2, const char*newname="") { return this; }
+    void DrawPanel() {}
+
+    Int_t Fill(Axis_t x);
+    Int_t Fill(const char *name, Stat_t w) { return -1; }
+    void  FillN(Int_t ntimes, const Axis_t *x, const Double_t *w, Int_t stride=1) {}
+    void  FillN(Int_t, const Axis_t *, const Axis_t *, const Double_t *, Int_t) {}
+
+public:
+    MHCamera();
+    MHCamera(const MGeomCam &geom, const char *name="", const char *title="");
+    ~MHCamera();
+
+    void SetGeometry(const MGeomCam &geom, const char *name="", const char *title="");
+    const MGeomCam* GetGeometry() const { return fGeomCam; }
+
+    Bool_t IsUsed(Int_t idx) const { return TESTBIT(const_cast<TArrayC&>(fUsed)[idx], kIsUsed); }
+    void   SetUsed(Int_t idx)      { SETBIT(fUsed[idx], kIsUsed); }
+
+    Int_t Fill(Axis_t x, Axis_t y, Stat_t w);
+    Int_t Fill(Axis_t x, Stat_t w);
+
+    //void     AddPixContent(Int_t idx) const { AddBinContent(idx+1); }
+    //void     AddPixContent(Int_t idx, Stat_t w) const { AddBinContent(idx+1, w); }
+
+    // This is a trick to remove TH1 entries from the context menu
+    /*
+     void Add(const TH1 *h1, const TH1 *h2, Double_t c1=1, Double_t c2=1) { TH1::Add(h1, h2, c1, c2); }
+     void Add(TF1 *h1, Double_t c1=1) { TH1::Add(h1, c1); }
+     void Add(const TH1 *h1, Double_t c1=1) { TH1::Add(h1, c1); }
+     void Divide(TF1 *f1, Double_t c1=1) { TH1::Divide(f1, c1); }
+     void Divide(const TH1 *h1) { TH1::Divide(h1); }
+     void Divide(const TH1 *h1, const TH1 *h2, Double_t c1=1, Double_t c2=1, Option_t *option="") { TH1::Divide(h1, h2, c1, c2, option); }
+     void Multiply(TF1 *h1, Double_t c1=1) { TH1::Multiply(h1, c1); }
+     void Multiply(const TH1 *h1) { TH1::Multiply(h1); }
+     void Multiply(const TH1 *h1, const TH1 *h2, Double_t c1=1, Double_t c2=1, Option_t *option="") { TH1::Multiply(h1, h2, c1, c2, option); }
+     */
+
+    void FitPanel() { TH1::FitPanel(); }
+
+    virtual Double_t GetPixContent(Int_t idx) const { return GetBinContent(idx+1); }
+    virtual void     AddCamContent(const MCamEvent &evt, Int_t type=0);
+    virtual void     AddCamContent(const MHCamera &evt, Int_t type=0);
+    virtual void     AddCamContent(const TArrayD &arr, const TArrayC *used=NULL);
+    virtual void     SetCamContent(const MCamEvent &evt, Int_t type=0) { Reset(); AddCamContent(evt, type); }
+    virtual void     SetCamContent(const TArrayD &evt, const TArrayC *used=NULL) { Reset(); AddCamContent(evt, used); }
+    virtual void     SetCamContent(const MHCamera &d, Int_t type=0) { Reset(); AddCamContent(d, type); fEntries=d.fEntries; }
+
+    virtual void     SetCamError(const MCamEvent &evt, Int_t type=0);
+    virtual void     SetUsed(const TArrayC &arr);
+
+    virtual void     CntCamContent(const MCamEvent &evt, Double_t threshold, Int_t type=0, Bool_t isabove=kTRUE);
+    virtual void     CntCamContent(const MCamEvent &evt, TArrayD threshold, Int_t type=0, Bool_t isabove=kTRUE);
+    virtual void     CntCamContent(const TArrayD &evt, Double_t threshold, Bool_t ispos=kTRUE);
+
+    Stat_t   GetBinContent(Int_t bin) const { return Profile(TH1D::GetBinContent(bin)); }
+    Stat_t   GetBinContent(Int_t binx, Int_t biny) const { return GetBinContent(binx); }
+    Stat_t   GetBinContent(Int_t binx, Int_t biny, Int_t binz) const { return GetBinContent(binx); }
+    Stat_t   GetBinError(Int_t bin) const;
+    Stat_t   GetBinError(Int_t binx, Int_t biny) const { return GetBinError(binx); }
+    Stat_t   GetBinError(Int_t binx, Int_t biny, Int_t binz) const { return GetBinError(binx); }
+
+    Double_t GetMinimum(Bool_t all) const { return GetMinimumSectors(TArrayI(), TArrayI(), all); }
+    Double_t GetMaximum(Bool_t all) const { return GetMaximumSectors(TArrayI(), TArrayI(), all); }
+
+    Double_t GetMinimum() const { return GetMinimumSectors(TArrayI(), TArrayI(), kFALSE); }
+    Double_t GetMaximum() const { return GetMaximumSectors(TArrayI(), TArrayI(), kFALSE); }
+
+    Double_t GetMinimumSector(Int_t sector, Int_t aidx, Bool_t all=kFALSE) const
+    {
+        return GetMinimumSectors(TArrayI(1, &sector), TArrayI(1, &aidx), all);
+    }
+    Double_t GetMaximumSector(Int_t sector, Int_t aidx, Bool_t all=kFALSE) const
+    {
+        return GetMaximumSectors(TArrayI(1, &sector), TArrayI(1, &aidx), all);
+    }
+    Double_t GetMinimumSectors(const TArrayI &sector, const TArrayI &aidx, Bool_t all=kFALSE) const;
+    Double_t GetMaximumSectors(const TArrayI &sector, const TArrayI &aidx, Bool_t all=kFALSE) const;
+
+    void     SetLevels(const TArrayF &arr);
+
+    void     FillRandom(const char *fname, Int_t ntimes=5000) { TH1::FillRandom(fname, ntimes); }
+    void     FillRandom(TH1 *h, Int_t ntimes=5000) { TH1::FillRandom(h, ntimes); }
+    void     FillRandom();
+
+    void     PrintInfo() const { Print(""); } // *MENU*
+    void     Reset(Option_t *);
+    void     Reset() { Reset(""); } // *MENU*
+    TH1     *DrawCopy() const/* { gPad=NULL; return TH1D::DrawCopy(); }*/; // *MENU*
+    TH1     *DrawCopy(Option_t *o) const { return TH1D::DrawCopy(o); }
+
+    void     Print(Option_t *) const;
+    void     Paint(Option_t *option="");
+    void     Draw(Option_t *option="");
+    TObject *DrawClone(Option_t *option="") const;
+    void     DrawProjection (Int_t fit=0) const;
+    void     DrawRadialProfile()           const;
+    void     DrawAzimuthProfile()          const;
+
+    void     SavePrimitive(ofstream &out, Option_t *);
+    Int_t    DistancetoPrimitive(Int_t px, Int_t py);
+    char    *GetObjectInfo(Int_t px, Int_t py) const;
+    void     ExecuteEvent(Int_t event, Int_t px, Int_t py);
+
+    void     SetPalette(Int_t ncolors, Int_t *colors);
+
+    void     SetPrettyPalette(); // *MENU*
+    void     SetDeepBlueSeaPalette(); // *MENU*
+    void     SetInvDeepBlueSeaPalette(); // *MENU*
+
+    void     SetAutoScale() { fMinimum = fMaximum = -1111; } // *MENU*
+    void     DisplayAsHistogram() { SetDrawOption("histEP"); } // *MENU*
+    void     DisplayAsCamera() { SetDrawOption(""); } // *MENU*
+
+    void     SetFreezed(Bool_t f=kTRUE) { f ? SetBit(kFreezed) : ResetBit(kFreezed); } // *TOGGLE* *GETTER=IsFreezed
+    Bool_t   IsFreezed() const { return TestBit(kFreezed); }
+    //void  SetOptStat(Int_t os=-1) { fOptStat = os; } // *MENU*
+
+    void     SetAbberation(Float_t f=0.0713) { fAbberation=f; } // *MENU*
+
+    void     AddNotify(TObject *event);
+
+    Stat_t   GetMean(Bool_t all) const { return GetMeanSectors(TArrayI(), TArrayI(), all); }
+    Stat_t   GetRMS(Bool_t all)  const { return GetRmsSectors(TArrayI(), TArrayI(), all); }
+
+    Stat_t   GetMean(Int_t=0) const { return GetMeanSectors(TArrayI(), TArrayI(), kFALSE); }
+    Stat_t   GetRMS(Int_t=0)  const { return GetRmsSectors(TArrayI(), TArrayI(), kFALSE); }
+
+    Stat_t   GetMeanSector(Int_t sector, Int_t aidx, Bool_t all=kFALSE) const
+    {
+        return GetMeanSectors(TArrayI(1, &sector), TArrayI(1, &aidx), all);
+    }
+    Stat_t   GetRmsSector(Int_t sector, Int_t aidx, Bool_t all=kFALSE) const
+    {
+        return GetRmsSectors(TArrayI(1, &sector), TArrayI(1, &aidx), all);
+    }
+
+    Stat_t   GetMeanSectors(const TArrayI &sector, const TArrayI &aidx, Bool_t all=kFALSE) const;
+    Stat_t   GetRmsSectors(const TArrayI &sector, const TArrayI &aidx, Bool_t all=kFALSE) const;
+
+    UInt_t   GetNumPixels() const;
+
+    TH1D    *Projection(const char *name="_py", const Int_t nbins=50) const
+      {
+        return ProjectionS(TArrayI(), TArrayI(), name,nbins);
+      }
+    TH1D    *ProjectionS(Int_t sector, Int_t aidx, const char *name="_py", const Int_t nbins=50) const
+    {
+        return ProjectionS(TArrayI(1, &sector), TArrayI(1, &aidx), name, nbins);
+    }
+    TH1D    *ProjectionS(const TArrayI &sector, const TArrayI &aidx, const char *name="_py", const Int_t nbins=50) const;
+
+    TProfile *RadialProfile(const char *name="_rad") const { return  RadialProfileS(TArrayI(), TArrayI(), name);}
+    TProfile *RadialProfileS(Int_t sector, Int_t aidx, const char *name="_rad", const Int_t nbins=25) const
+    {
+        return RadialProfileS(TArrayI(1, &sector), TArrayI(1, &aidx), name, nbins);
+    }
+    TProfile *RadialProfileS(const TArrayI &sector, const TArrayI &aidx, const char *name="_rad", const Int_t nbins=25) const;
+
+    TProfile *AzimuthProfile(const char *name="_azi") const { return  AzimuthProfileA(TArrayI(), name);  }
+    TProfile *AzimuthProfile(Int_t aidx, const char *name="_rad", const Int_t nbins=25) const
+      {
+        return AzimuthProfileA(TArrayI(1, &aidx), name, nbins);
+      }
+    TProfile *AzimuthProfileA(const TArrayI &aidx, const char *name="_rad", const Int_t nbins=25) const;
+    
+    void CamDraw(TCanvas &c, const Int_t x, const Int_t y, 
+                 const Int_t fit, const Int_t rad=0, const Int_t azi=0,
+                 TObject *notify=NULL);             
+    
+    const MGeomCam &GetGeomCam() const { return *fGeomCam; }
+
+    ClassDef(MHCamera, 1) // Displays the magic camera
+};
+
+#endif
+
+/* ------------ OK ---------------
+ virtual void     Browse(TBrowser *b);
+ virtual void     FillRandom(const char *fname, Int_t ntimes=5000);
+ virtual void     FillRandom(TH1 *h, Int_t ntimes=5000);
+
+ virtual Int_t    GetQuantiles(Int_t nprobSum, Double_t *q, const Double_t *probSum=0);
+ virtual Axis_t   GetRandom();
+ virtual void     GetStats(Stat_t *stats) const;
+ virtual Stat_t   GetSumOfWeights() const;
+ virtual Int_t    GetSumw2N() const {return fSumw2.fN;}
+ virtual Stat_t   GetRMS(Int_t axis=1) const;
+
+ virtual Int_t    GetNbinsX() const {return fXaxis.GetNbins();}
+ virtual Int_t    GetNbinsY() const {return fYaxis.GetNbins();}
+ virtual Int_t    GetNbinsZ() const {return fZaxis.GetNbins();}
+
+ // ------------- to check -------------------
+
+ virtual Double_t ComputeIntegral();
+ virtual Int_t    DistancetoPrimitive(Int_t px, Int_t py);
+ virtual void     Draw(Option_t *option="");
+ virtual TH1     *DrawCopy(Option_t *option="") const;
+ virtual TH1     *DrawNormalized(Option_t *option="", Double_t norm=1) const;
+ virtual Int_t    BufferEmpty(Bool_t deleteBuffer=kFALSE);
+ virtual void     Eval(TF1 *f1, Option_t *option="");
+ virtual void     ExecuteEvent(Int_t event, Int_t px, Int_t py);
+ virtual void     FillN(Int_t ntimes, const Axis_t *x, const Double_t *w, Int_t stride=1);
+ virtual void     FillN(Int_t, const Axis_t *, const Axis_t *, const Double_t *, Int_t) {;}
+ virtual Int_t    FindBin(Axis_t x, Axis_t y=0, Axis_t z=0);
+ virtual TObject *FindObject(const char *name) const;
+ virtual TObject *FindObject(const TObject *obj) const;
+ virtual Int_t    Fit(const char *formula ,Option_t *option="" ,Option_t *goption="", Axis_t xmin=0, Axis_t xmax=0); // *MENU*
+ virtual Int_t    Fit(TF1 *f1 ,Option_t *option="" ,Option_t *goption="", Axis_t xmin=0, Axis_t xmax=0);
+ virtual void     FitPanel(); // *MENU*
+ TH1             *GetAsymmetry(TH1* h2, Double_t c2=1, Double_t dc2=0);
+ Int_t            GetBufferLength() const {return (Int_t)fBuffer[0];}
+ Int_t            GetBufferSize  () const {return fBufferSize;}
+ const   Double_t *GetBuffer() const {return fBuffer;}
+ static  Int_t    GetDefaultBufferSize();
+ virtual Double_t *GetIntegral() {return fIntegral;}
+
+ TList           *GetListOfFunctions() const { return fFunctions; }
+
+ virtual Int_t    GetNdivisions(Option_t *axis="X") const;
+ virtual Color_t  GetAxisColor(Option_t *axis="X") const;
+ virtual Color_t  GetLabelColor(Option_t *axis="X") const;
+ virtual Style_t  GetLabelFont(Option_t *axis="X") const;
+ virtual Float_t  GetLabelOffset(Option_t *axis="X") const;
+ virtual Float_t  GetLabelSize(Option_t *axis="X") const;
+ virtual Float_t  GetTitleOffset(Option_t *axis="X") const;
+ virtual Float_t  GetTitleSize(Option_t *axis="X") const;
+ virtual Float_t  GetTickLength(Option_t *axis="X") const;
+ virtual Float_t  GetBarOffset() const {return Float_t(0.001*Float_t(fBarOffset));}
+ virtual Float_t  GetBarWidth() const  {return Float_t(0.001*Float_t(fBarWidth));}
+ virtual Int_t    GetContour(Double_t *levels=0);
+ virtual Double_t GetContourLevel(Int_t level) const;
+ virtual Double_t GetContourLevelPad(Int_t level) const;
+
+ virtual void     GetCenter(Axis_t *center) const {fXaxis.GetCenter(center);}
+ TDirectory      *GetDirectory() const {return fDirectory;}
+ virtual Stat_t   GetEntries() const;
+ virtual TF1     *GetFunction(const char *name) const;
+ virtual Int_t    GetDimension() const { return fDimension; }
+ virtual void     GetLowEdge(Axis_t *edge) const {fXaxis.GetLowEdge(edge);}
+ virtual Double_t GetMaximum() const;
+ virtual Int_t    GetMaximumBin() const;
+ virtual Int_t    GetMaximumBin(Int_t &locmax, Int_t &locmay, Int_t &locmaz) const;
+ virtual Double_t GetMaximumStored() const {return fMaximum;}
+ virtual Double_t GetMinimum() const;
+ virtual Int_t    GetMinimumBin() const;
+ virtual Int_t    GetMinimumBin(Int_t &locmix, Int_t &locmiy, Int_t &locmiz) const;
+ virtual Double_t GetMinimumStored() const {return fMinimum;}
+ virtual Stat_t   GetMean(Int_t axis=1) const;
+ virtual Double_t GetNormFactor() const {return fNormFactor;}
+ virtual char    *GetObjectInfo(Int_t px, Int_t py) const;
+ Option_t        *GetOption() const {return fOption.Data();}
+
+ TVirtualHistPainter *GetPainter();
+
+ TAxis   *GetXaxis() const;
+ TAxis   *GetYaxis() const;
+ TAxis   *GetZaxis() const;
+ virtual Stat_t   Integral(Option_t *option="") const;
+ virtual Stat_t   Integral(Int_t binx1, Int_t binx2, Option_t *option="") const;
+ virtual Stat_t   Integral(Int_t, Int_t, Int_t, Int_t, Option_t * ="") const {return 0;}
+ virtual Stat_t   Integral(Int_t, Int_t, Int_t, Int_t, Int_t, Int_t, Option_t * ="" ) const {return 0;}
+ virtual Double_t KolmogorovTest(TH1 *h2, Option_t *option="") const;
+ virtual void     LabelsDeflate(Option_t *axis="X");
+ virtual void     LabelsInflate(Option_t *axis="X");
+ virtual void     LabelsOption(Option_t *option="h", Option_t *axis="X");
+ virtual Int_t    Merge(TCollection *list);
+ virtual void     Multiply(TF1 *h1, Double_t c1=1);
+ virtual void     Multiply(const TH1 *h1);
+ virtual void     Multiply(const TH1 *h1, const TH1 *h2, Double_t c1=1, Double_t c2=1, Option_t *option=""); // *MENU*
+ virtual void     Paint(Option_t *option="");
+ virtual void     Print(Option_t *option="") const;
+ virtual void     PutStats(Stat_t *stats);
+ virtual TH1     *Rebin(Int_t ngroup=2, const char*newname="");  // *MENU*
+ virtual void     RebinAxis(Axis_t x, Option_t *axis="X");
+ virtual void     Rebuild(Option_t *option="");
+ virtual void     RecursiveRemove(TObject *obj);
+ virtual void     Reset(Option_t *option="");
+ virtual void     SavePrimitive(ofstream &out, Option_t *option);
+ virtual void     Scale(Double_t c1=1);
+ virtual void     SetAxisColor(Color_t color=1, Option_t *axis="X");
+ virtual void     SetAxisRange(Axis_t xmin, Axis_t xmax, Option_t *axis="X");
+ virtual void     SetBarOffset(Float_t offset=0.25) {fBarOffset = Short_t(1000*offset);}
+ virtual void     SetBarWidth(Float_t width=0.5) {fBarWidth = Short_t(1000*width);}
+ virtual void     SetBinContent(Int_t bin, Stat_t content);
+ virtual void     SetBinContent(Int_t binx, Int_t biny, Stat_t content);
+ virtual void     SetBinContent(Int_t binx, Int_t biny, Int_t binz, Stat_t content);
+ virtual void     SetBinError(Int_t bin, Stat_t error);
+ virtual void     SetBinError(Int_t binx, Int_t biny, Stat_t error);
+ virtual void     SetBinError(Int_t binx, Int_t biny, Int_t binz, Stat_t error);
+ virtual void     SetBins(Int_t nx, Axis_t xmin, Axis_t xmax);
+ virtual void     SetBins(Int_t nx, Axis_t xmin, Axis_t xmax, Int_t ny, Axis_t ymin, Axis_t ymax);
+ virtual void     SetBins(Int_t nx, Axis_t xmin, Axis_t xmax, Int_t ny, Axis_t ymin, Axis_t ymax,
+ Int_t nz, Axis_t zmin, Axis_t zmax);
+ virtual void     SetBinsLength(Int_t = -1) { } //refefined in derived classes
+ virtual void     SetBuffer(Int_t buffersize, Option_t *option="");
+ virtual void     SetCellContent(Int_t binx, Int_t biny, Stat_t content);
+ virtual void     SetCellError(Int_t binx, Int_t biny, Stat_t content);
+ virtual void     SetContent(const Stat_t *content);
+ virtual void     SetContour(Int_t nlevels, const Double_t *levels=0);
+ virtual void     SetContourLevel(Int_t level, Double_t value);
+ static  void     SetDefaultBufferSize(Int_t buffersize=1000);
+ virtual void     SetDirectory(TDirectory *dir);
+ virtual void     SetEntries(Stat_t n) {fEntries = n;};
+ virtual void     SetError(const Stat_t *error);
+ virtual void     SetLabelColor(Color_t color=1, Option_t *axis="X");
+ virtual void     SetLabelFont(Style_t font=62, Option_t *axis="X");
+ virtual void     SetLabelOffset(Float_t offset=0.005, Option_t *axis="X");
+ virtual void     SetLabelSize(Float_t size=0.02, Option_t *axis="X");
+
+ virtual void     SetMaximum(Double_t maximum=-1111); // *MENU*
+ virtual void     SetMinimum(Double_t minimum=-1111); // *MENU*
+ virtual void     SetName(const char *name); // *MENU*
+ virtual void     SetNameTitle(const char *name, const char *title);
+ virtual void     SetNdivisions(Int_t n=510, Option_t *axis="X");
+ virtual void     SetNormFactor(Double_t factor=1) {fNormFactor = factor;}
+ virtual void     SetStats(Bool_t stats=kTRUE);
+ virtual void     SetOption(Option_t *option=" ") {fOption = option;}
+ virtual void     SetTickLength(Float_t length=0.02, Option_t *axis="X");
+ virtual void     SetTitleOffset(Float_t offset=1, Option_t *axis="X");
+ virtual void     SetTitleSize(Float_t size=0.02, Option_t *axis="X");
+ virtual void     SetTitle(const char *title);
+ virtual void     SetXTitle(const char *title) {fXaxis.SetTitle(title);}
+ virtual void     SetYTitle(const char *title) {fYaxis.SetTitle(title);}
+ virtual void     SetZTitle(const char *title) {fZaxis.SetTitle(title);}
+ virtual void     Smooth(Int_t ntimes=1); // *MENU*
+ static  void     SmoothArray(Int_t NN, Double_t *XX, Int_t ntimes=1);
+ static Double_t  SmoothMedian(Int_t n, Double_t *a);
+ virtual void     Sumw2();
+ void             UseCurrentStyle();
+
+ ClassDef(TH1,4)  //1-Dim histogram base class
+};
+
+*/
Index: /tags/Mars_V0-8-5/Mars/mhist/MHCerPhotEvt.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHCerPhotEvt.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHCerPhotEvt.cc	(revision 9661)
@@ -0,0 +1,161 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHCerPhotEvt
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MHCerPhotEvt.h"
+
+#include <TCanvas.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MCamEvent.h"
+#include "MCamDisplay.h"
+
+#include "MGeomCam.h"
+#include "MGeomPix.h"
+
+ClassImp(MHCerPhotEvt);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Initialize the name and title of the task.
+// Resets the sum histogram
+//
+MHCerPhotEvt::MHCerPhotEvt(const char *name, const char *title)
+    : fSum(NULL), fEvt(NULL)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHCerPhotEvt";
+    fTitle = title ? title : "Average of MCerPhotEvts";
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the corresponding camera display if available
+//
+MHCerPhotEvt::~MHCerPhotEvt()
+{
+    if (fSum)
+        delete fSum;
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the event (MCerPhotEvt) the histogram might be filled with. If
+// it is not given, it is assumed, that it is filled with the argument
+// of the Fill function.
+// Looks for the camera geometry MGeomCam and resets the sum histogram.
+//
+Bool_t MHCerPhotEvt::SetupFill(const MParList *plist)
+{
+    fEvt = (MCamEvent*)plist->FindObject(fNameEvt, "MCamEvent");
+    if (!fEvt)
+        *fLog << warn << GetDescriptor() << ": No MCerPhotEvt available..." << endl;
+
+    MGeomCam *cam = (MGeomCam*)plist->FindObject("MGeomCam");
+    if (!cam)
+        *fLog << warn << GetDescriptor() << ": No MGeomCam found." << endl;
+
+    if (fSum)
+        delete (fSum);
+    fSum = new MCamDisplay(*cam, fNameEvt+";avg", fNameEvt+" Avarage");
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the histograms with data from a MCerPhotEvt-Container.
+//
+Bool_t MHCerPhotEvt::Fill(const MParContainer *par, const Stat_t w)
+{
+    const MCamEvent *evt = par ? dynamic_cast<const MCamEvent*>(par) : fEvt;
+    if (!evt)
+    {
+        *fLog << err << dbginf << "No MCerPhotEvt found..." << endl;
+        return kFALSE;
+    }
+    fSum->AddCamContent(*evt);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Scale the sum container with the number of entries
+//
+Bool_t MHCerPhotEvt::Finalize()
+{
+    if (fSum->GetEntries()>0)
+        fSum->Scale(1./fSum->GetEntries());
+    return kTRUE;
+}
+/*
+// --------------------------------------------------------------------------
+//
+// Draw the present 'fill status'
+//
+void MHCerPhotEvt::Draw(Option_t *)
+{
+    if (!fSum)
+    {
+        *fLog << warn << "WARNING - Cannot draw " << GetDescriptor() << ": No Camera Geometry available." << endl;
+        return;
+    }
+
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this, 750, 600);
+    pad->SetBorderMode(0);
+    //pad->Divide(1,1);
+    //gPad->SetBorderMode(0);
+
+    AppendPad("");
+}
+
+// --------------------------------------------------------------------------
+//
+// If a camera display is not yet assigned, assign a new one.
+//
+void MHCerPhotEvt::Paint(Option_t *option)
+{
+    if (!fSum)
+        return;
+
+    fSum->Paint();
+}
+*/
+
+TH1 *MHCerPhotEvt::GetHistByName(const TString name)
+{
+    return fSum;
+}
Index: /tags/Mars_V0-8-5/Mars/mhist/MHCerPhotEvt.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHCerPhotEvt.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHCerPhotEvt.h	(revision 9661)
@@ -0,0 +1,34 @@
+#ifndef MARS_MHCerPhotEvt
+#define MARS_MHCerPhotEvt
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+class MCamDisplay;
+class MCamEvent;
+
+class MHCerPhotEvt : public MH
+{
+private:
+    MCamDisplay *fSum;      // storing the sum
+    MCamEvent   *fEvt;      //! the current event
+
+    TString fNameEvt;
+
+    Bool_t SetupFill(const MParList *pList);
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+    Bool_t Finalize();
+
+public:
+    MHCerPhotEvt(const char *name=NULL, const char *title=NULL);
+    ~MHCerPhotEvt();
+
+    void SetNameEvt(const TString name) { fNameEvt = name; }
+
+    TH1 *GetHistByName(const TString name="");
+
+    ClassDef(MHCerPhotEvt, 1) // Histogram to sum camera events
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mhist/MHCompProb.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHCompProb.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHCompProb.cc	(revision 9661)
@@ -0,0 +1,243 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Abelardo Moralejo <mailto:moralejo@pd.infn.it>
+!   Author(s): Thomas Bretz, 5/2002 <mailto:moralejo@pd.infn.it>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////
+//
+// MHCompProb
+//
+// This class contains different histograms of the Hillas parameters
+//   and composite probabilities based on them.
+//
+///////////////////////////////////////////////////////////////////////
+
+#include "MHCompProb.h"
+
+#include <TH2.h>
+#include <TPad.h>
+#include <TText.h>
+#include <TStyle.h>
+#include <TCanvas.h>
+#include <TProfile.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MBinning.h"
+#include "MDataChain.h"
+
+#include "MMcEvt.hxx"
+
+ClassImp(MHCompProb);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Setup histograms
+//
+MHCompProb::MHCompProb(Int_t nbins, const char *name, const char *title)
+    : fNumLoop(0)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHCompProb";
+    fTitle = title ? title : "Gamma/Hadron Separation Quality Histograms";
+
+    fData    = new TList;
+    fRules   = new TList;
+    fHists   = new TList;
+    fHistVar = new TList;
+
+    fData->SetOwner();
+    fRules->SetOwner();
+    fHists->SetOwner();
+    fHistVar->SetOwner();
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the histograms
+//
+MHCompProb::~MHCompProb()
+{
+    delete fData;
+    delete fRules;
+    delete fHists;
+    delete fHistVar;
+}
+
+// --------------------------------------------------------------------------
+//
+//
+//
+void MHCompProb::Add(const char *rule, Int_t n, Float_t min, Float_t max)
+{
+    MDataChain &chain = *new MDataChain(rule);
+    fData->Add(&chain);
+
+    TNamed &name = *new TNamed(rule, "");
+    fRules->Add(&name);
+
+    TH1D &hist = *new TH1D(Form("Hist_%s", rule), rule, n, min, max);
+    hist.SetXTitle(rule);
+    hist.SetYTitle("Counts");
+    hist.SetDirectory(NULL);
+    fHists->Add(&hist);
+
+    TH1D &varhist = *new TH1D;
+    varhist.SetName(Form("Var_%s", rule));
+    varhist.SetTitle(rule);
+    varhist.SetXTitle(rule);
+    varhist.SetYTitle("Counts");
+    varhist.SetDirectory(NULL);
+    fHistVar->Add(&varhist);
+}
+
+// --------------------------------------------------------------------------
+//
+//
+//
+Bool_t MHCompProb::SetupFill(const MParList *plist)
+{
+    if (fData->GetSize()==0)
+    {
+        *fLog << err << "No data members spcified for usage... aborting." << endl;
+        return kFALSE;
+    }
+
+    TIter Next(fData);
+    MData *data=NULL;
+    while ((data=(MData*)Next()))
+        if (!data->PreProcess(plist))
+            return kFALSE;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//
+//
+void MHCompProb::Fill(TList &list)
+{
+    MData *data = NULL;
+
+    TIter NextD(fData);
+    TIter NextH(&list);
+
+    while ((data=(MData*)NextD()))
+    {
+        TH1D *hist = (TH1D*)NextH();
+        hist->Fill(data->GetValue());
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+//
+//
+Bool_t MHCompProb::Fill(const MParContainer *par, const Stat_t w)
+{
+    const MMcEvt &mcevt = *(MMcEvt*)par;
+
+    switch (fNumLoop)
+    {
+    case 0:  // First loop : fill the fixed-bin histograms with gammas.
+        if (mcevt.GetPartId() == MMcEvt::kGAMMA)
+            Fill(*fHists);
+        return kTRUE;
+
+    case 1:   //  Second Loop: fill the variable-bin histograms with protons.
+        if (mcevt.GetPartId() != MMcEvt::kGAMMA)
+            Fill(*fHistVar);
+        return kTRUE;
+    default:
+        *fLog << err << "Error - Invalid Loop Number... aborting." << endl;
+        return kFALSE;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+//
+//
+Bool_t MHCompProb::Finalize()
+{
+    switch (fNumLoop++)
+    {
+    case 0:
+        *fLog << inf << "Finished filling fixed bin size histograms with gamma-data." << endl;
+        SetBinningHistVar();
+        fHists->Delete();
+        return kTRUE;
+    case 1:
+        *fLog << inf << "Finished filling variable bin size histogram with proton data." << endl;
+        return kTRUE;
+    default:
+        *fLog << err << "Error - Invalid Loop Number... aborting." << endl;
+        return kFALSE;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+//
+//
+void MHCompProb::SetBinningHistVar()
+{
+    Int_t nedges = 51; // Number of bins in variable-bin histograms.
+
+    TIter NextH(fHists);
+    TIter NextV(fHistVar);
+    TH1D *hist = NULL;
+    while ((hist=(TH1D*)NextH()))
+    {
+        Int_t n = hist->GetNbinsX();
+
+        TArrayD edges(nedges);
+
+        edges[0]        = hist->GetBinLowEdge(1);
+        edges[nedges-1] = hist->GetBinLowEdge(n+1);
+
+        Float_t newwidth = hist->Integral(1, n)/nedges;
+
+        Int_t jbin = 1;
+        for (Int_t j=1; j<n && jbin<nedges-1; j++)
+        {
+            if (hist->Integral(1, j) <= jbin*newwidth)
+                continue;
+
+            edges[jbin++] = hist->GetBinLowEdge(j+1);
+        }
+
+        MBinning bins;
+        bins.SetEdges(edges);
+
+        SetBinning((TH1D*)NextV(), &bins);
+    }
+}
+
Index: /tags/Mars_V0-8-5/Mars/mhist/MHCompProb.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHCompProb.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHCompProb.h	(revision 9661)
@@ -0,0 +1,40 @@
+#ifndef MARS_MHCompProb
+#define MARS_MHCompProb
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+class MParList;
+
+class MHCompProb : public MH
+{
+private:
+    Int_t fNumLoop;   //! Counter of the loop (two eventloops needed)
+
+    TList *fRules;    // Rules describing the used data sets
+
+    TList *fData;     //! MDataChain objects
+    TList *fHists;    //! fixed bin size histograms
+    TList *fHistVar;  // variable bin size histograms
+
+    void Fill(TList &list);
+    void SetBinningHistVar();
+
+public:
+    MHCompProb(Int_t nbins, const char *name=NULL, const char *title=NULL);
+    ~MHCompProb();
+
+    void Add(const char *rule, Int_t n, Float_t min, Float_t max);
+
+    Bool_t SetupFill(const MParList *plist);
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+    Bool_t Finalize();
+
+    const TList *GetRules() const   { return fRules; }
+    TList *GetHistVar() const { return fHistVar; }
+
+    ClassDef(MHCompProb, 1) // Histogram to be used for the calculation of the composite probabilities
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mhist/MHCurrents.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHCurrents.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHCurrents.cc	(revision 9661)
@@ -0,0 +1,246 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHCurrents
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MHCurrents.h"
+
+#include <TCanvas.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MBinning.h"
+#include "MCurrents.h"
+#include "MCamDisplay.h"
+
+#include "MGeomCam.h"
+#include "MGeomPix.h"
+
+ClassImp(MHCurrents);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Reset all pixels to 0 and reset fEntries to 0.
+//
+void MHCurrents::Clear(const Option_t *)
+{
+    const Int_t n = fCam ? fCam->GetNumPixels() : 577;
+
+    // FIXME: Implement a clear function with setmem
+    fSum.Set(n); // also clears memory
+    fRms.Set(n);
+/*    for (int i=0; i<577; i++)
+    {
+        fSum[i] = 0;
+        fRms[i] = 0;
+    }*/
+
+    fEntries = 0;
+}
+
+// --------------------------------------------------------------------------
+//
+// Initialize the name and title of the task.
+// Resets the sum histogram
+//
+MHCurrents::MHCurrents(const char *name, const char *title)
+    : /*fSum(577), fRms(577), */fCam(NULL), fEvt(NULL), fDispl(NULL)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHCurrents";
+    fTitle = title ? title : "Average of MCurrents";
+
+    Clear();
+
+    fHist.SetName("currents;avg");
+    fHist.SetTitle("Avg.Currents [nA]");
+    fHist.SetXTitle("Pixel Index");
+    fHist.SetYTitle("A [nA]");
+    fHist.SetDirectory(NULL);
+    fHist.SetLineColor(kGreen);
+    fHist.SetMarkerStyle(kFullDotMedium);
+    fHist.SetMarkerSize(0.3);
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the corresponding camera display if available
+//
+MHCurrents::~MHCurrents()
+{
+    if (fDispl)
+        delete fDispl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the event (MCerPhotEvt) the histogram might be filled with. If
+// it is not given, it is assumed, that it is filled with the argument
+// of the Fill function.
+// Looks for the camera geometry MGeomCam and resets the sum histogram.
+//
+Bool_t MHCurrents::SetupFill(const MParList *plist)
+{
+    fEvt = (MCurrents*)plist->FindObject("MCurrents");
+    if (!fEvt)
+        *fLog << warn << GetDescriptor() << ": No MCerPhotEvt available..." << endl;
+
+    fCam = (MGeomCam*)plist->FindObject("MGeomCam");
+    /*
+    if (!fCam)
+        *fLog << warn << GetDescriptor() << ": No MGeomCam found... assuming Magic geometry!" << endl;
+    */
+    if (!fCam)
+    {
+        *fLog << err << GetDescriptor() << ": No MGeomCam found... aborting." << endl;
+        return kFALSE;
+    }
+
+    Clear();
+
+    const Int_t n = fSum.GetSize();
+
+    MBinning bins;
+    bins.SetEdges(n, -0.5, n-0.5);
+    bins.Apply(fHist);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the histograms with data from a MCerPhotEvt-Container.
+//
+Bool_t MHCurrents::Fill(const MParContainer *par, const Stat_t w)
+{
+    const MCurrents *evt = par ? (MCurrents*)par : fEvt;
+    if (!evt)
+    {
+        *fLog << err << dbginf << "No MCurrents found..." << endl;
+        return kFALSE;
+    }
+
+    const Int_t n = fSum.GetSize();
+    for (UInt_t idx=0; idx<n; idx++)
+    {
+        Float_t val;
+        if (!evt->GetPixelContent(val, idx))
+            continue;
+
+        fSum[idx] += val;
+        fRms[idx] += val*val;
+
+    }
+
+    fEntries++;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Scale the sum container with the number of entries
+//
+Bool_t MHCurrents::Finalize()
+{
+    if (fEntries<2)
+    {
+        *fLog << warn << "WARNING - " << GetDescriptor() << " doesn't contain enough entries." << endl;
+        return kTRUE;
+    }
+
+    const Int_t n = fSum.GetSize();
+    for (UInt_t i=0; i<n; i++)
+    {
+        // calc sdev^2 for pixel index i
+        // var^2 = (sum[xi^2] - sum[xi]^2/n) / (n-1);
+        fRms[i] -= fSum[i]*fSum[i]/fEntries;
+        fRms[i] /= fEntries-1;
+
+        if (fRms[i]<0)
+        {
+            *fLog << warn << "WARNING - fRms[" << i <<"]= " << fRms[i] << " -> was set to 0 " << endl;
+            fRms[i]=0;
+        }
+
+        else
+            fRms[i]  = TMath::Sqrt(fRms[i]);
+
+        // calc mean value for pixel index i
+        fSum[i] /= fEntries;
+
+        fHist.SetBinContent(i+1, fSum[i]);
+        fHist.SetBinError(  i+1, fRms[i]);
+    }
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw the present 'fill status'
+//
+void MHCurrents::Draw(Option_t *o)
+{
+    if (!fCam)
+    {
+        *fLog << warn << "WARNING - Cannot draw " << GetDescriptor() << ": No Camera Geometry available." << endl;
+        return;
+    }
+
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this, 750, 600);
+    pad->SetBorderMode(0);
+
+    SetDrawOption(o);
+    AppendPad("");
+}
+
+// --------------------------------------------------------------------------
+//
+// If a camera display is not yet assigned, assign a new one.
+//
+void MHCurrents::Paint(Option_t *option)
+{
+    if (!fCam)
+    {
+        *fLog << warn << "WARNING - Cannot paint " << GetDescriptor() << ": No Camera Geometry available." << endl;
+        return;
+    }
+
+    if (!fDispl)
+        fDispl = new MCamDisplay(fCam);
+
+    TString opt(GetDrawOption());
+
+    fDispl->Fill(opt.Contains("rms", TString::kIgnoreCase) ? fRms : fSum);
+    fDispl->Paint();
+}
Index: /tags/Mars_V0-8-5/Mars/mhist/MHCurrents.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHCurrents.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHCurrents.h	(revision 9661)
@@ -0,0 +1,55 @@
+#ifndef MARS_MHCurrents
+#define MARS_MHCurrents
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+#ifndef ROOT_TH1
+#include <TH1.h>
+#endif
+
+#ifndef ROOT_TArrayF
+#include <TArrayF.h>
+#endif
+
+class MCurrents;
+class MGeomCam;
+class MCamDisplay;
+
+class MHCurrents : public MH
+{
+private:
+    TArrayF      fSum;      // storing the sum
+    TArrayF      fRms;      // storing the rms
+    Int_t        fEntries;  // number of entries in the histogram
+    MGeomCam    *fCam;      // the present geometry
+    MCurrents   *fEvt;      //! the current event
+    MCamDisplay *fDispl;    //! the camera display
+
+    TH1F         fHist;
+
+public:
+    MHCurrents(const char *name=NULL, const char *title=NULL);
+    ~MHCurrents();
+
+    void Clear(const Option_t *o="");
+
+    Bool_t SetupFill(const MParList *pList);
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+    Bool_t Finalize();
+
+    TH1 *GetHistByName(const TString name) { return NULL; }
+
+    const TArrayF &GetSum() const { return fSum; }
+    const TArrayF &GetRms() const { return fRms; }
+
+    const TH1F    &GetHist() const { return fHist; }
+
+    void Draw(Option_t *opt="");
+    void Paint(Option_t *option="");
+
+    ClassDef(MHCurrents, 1) // Histogram to sum camera events
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mhist/MHEffOnTime.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHEffOnTime.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHEffOnTime.cc	(revision 9661)
@@ -0,0 +1,397 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Wolfgang Wittek 5/2002 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MHEffOnTime                                                             //
+//                                                                          //
+//  calculates the effective on time for each bin in the variable Var       //
+//             (Var may be time or Theta)                                   //
+//                                                                          //
+//  Important : The sample of events used for this should be as close       //
+//              to the sample of recorded events as possible.               //
+//              This means that NO additional cuts (be it quality cuts or   //
+//              gamma/hadron cuts) should be applied (see MAGIC-TDAS 02-02).//
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MHEffOnTime.h"
+
+#include <TStyle.h>
+
+#include <TMinuit.h>
+#include <TFitter.h>
+
+#include <TF1.h>
+#include <TH2.h>
+#include <TCanvas.h>
+
+#include "MBinning.h"
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MHTimeDiffTheta.h"
+
+ClassImp(MHEffOnTime);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor. It sets the name of the variable ("Time" or "Theta")
+//                      and the units of the variable ("[s]" or "[\\circ])")
+//
+MHEffOnTime::MHEffOnTime(const char *varname, const char *unit)
+    : fHEffOn(), fHProb(), fHLambda(), fHRdead()
+{
+    fVarname  = varname;
+    fUnit     = unit;
+
+    TString strg = fVarname + " " + fUnit;
+
+    //
+    //   set the name and title of this object
+    //
+    fName  = TString("MHEffOnTime-")+fVarname;
+    fTitle = "1-D histogram of Eff On Time";
+
+    // effective on time versus Var
+    fHEffOn.SetName("EffOn");
+    fHEffOn.SetTitle(TString("T_{on, eff} vs. ")+fVarname);
+
+    fHEffOn.SetDirectory(NULL);
+
+    fHEffOn.SetXTitle(strg);
+    fHEffOn.SetYTitle("T_{on, eff} [s]");
+
+    // chi2-probability versus Var
+    fHProb.SetName("Chi2-prob");
+    TString strg3("\\chi^{2}-prob of OnTimeFit vs. ");
+    strg3 += fVarname;
+    fHProb.SetTitle(strg3);
+
+    fHProb.SetDirectory(NULL);
+
+    fHProb.SetXTitle(strg);
+    fHProb.SetYTitle("\\chi^{2}-probability");
+
+    // lambda versus Var
+    fHLambda.SetName("lambda");
+    fHLambda.SetTitle(TString("\\lambda from OnTimeFit vs. ")+fVarname);
+
+    fHLambda.SetDirectory(NULL);
+
+    fHLambda.SetXTitle(strg);
+    fHLambda.SetYTitle("\\lambda [Hz]");
+
+    // Rdead versus Var
+    // Rdead is the fraction from real time lost by the dead time
+    fHRdead.SetName("Rdead");
+
+    fHRdead.SetTitle(TString("Rdead of OnTimeFit vs. ")+fVarname);
+
+    fHRdead.SetDirectory(NULL);
+
+    fHRdead.SetXTitle(strg);
+    fHRdead.SetYTitle("Rdead");
+
+}
+
+// --------------------------------------------------------------------
+//
+//  determine range (yq[0], yq[1]) of time differences
+//  where fit should be performed;
+//  require a fraction >=min of all entries to lie below yq[0]
+//      and a fraction <=max of all entries to lie below yq[1];
+//  within the range (yq[0], yq[1]) there must be no empty bin;
+//
+void MHEffOnTime::GetQuantiles(const TH1 &h, Double_t min, Double_t max, Double_t yq[2]) const
+{
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,02,07)
+    // WOrkaround for missing const qualifier of TH1::Integral
+    TH1 &h1 = (TH1&)h;
+
+    // choose pedestrian approach as long as GetQuantiles is
+    // not available
+    const Int_t    jbins = h1.GetNbinsX();
+    const Double_t Nm    = h1.Integral();
+
+    const Double_t xq[2] = { 0.15*Nm, 0.98*Nm };
+
+    yq[0] = yq[1] = h1.GetBinLowEdge(jbins+1);
+
+    for (int j=1; j<=jbins; j++)
+        if (h1.Integral(2, j) >= xq[0])
+        {
+            yq[0] = h1.GetBinLowEdge(j);
+            break;
+        }
+
+    for (int j=1; j<=jbins; j++)
+        if (h1.Integral(1, j) >= xq[1] || h1.GetBinContent(j)==0)
+        {
+            yq[1] = h1.GetBinLowEdge(j);
+            break;
+        }
+#else
+    // GetQuantiles doesn't seem to be available in root 3.01/06
+    Double_t xq[2] = { min, max };
+    ((TH1&)h).GetQuantiles(2, yq, xq);
+#endif
+}
+
+void MHEffOnTime::DrawBin(TH1 &h, Int_t i) const
+{
+    TString strg1 = fVarname+"-bin #";
+    strg1 += i;
+
+    new TCanvas(strg1, strg1);
+
+    gPad->SetLogy();
+    gStyle->SetOptFit(1011);
+
+    TString name="Bin_";
+    name += i;
+
+    h.SetName(name);
+    h.SetXTitle("\\Delta t [s]");
+    h.SetYTitle("Counts");
+    h.DrawCopy();
+}
+
+Bool_t MHEffOnTime::CalcResults(const TF1 &func, Double_t Nm, Int_t i)
+{
+    const Double_t lambda = func.GetParameter(0);
+    const Double_t N0     = func.GetParameter(1);
+    const Double_t prob   = func.GetProb();
+    const Int_t    NDF    = func.GetNDF();
+
+    Double_t xmin, xmax;
+    ((TF1&)func).GetRange(xmin, xmax);
+
+    *fLog << inf;
+    *fLog << "Fitted bin #" << i << " from " << xmin << " to " << xmax;
+    *fLog << ",  got: lambda=" << lambda << "Hz N0=" << N0 << endl;
+
+    if (prob<=0.01)
+    {
+        *fLog << warn << "WARN - Fit bin#" << i << " gives:";
+        *fLog << " Chi^2-Probab(" << prob << ")<0.01";
+        *fLog << " NoFitPts=" << func.GetNumberFitPoints();
+        *fLog << " Chi^2=" << func.GetChisquare();
+    }
+
+    // was fit successful ?
+    if (NDF<=0 || /*prob<=0.001 ||*/ lambda<=0 || N0<=0)
+    {
+        *fLog << warn << dbginf << "Fit failed bin #" << i << ": ";
+        if (NDF<=0)
+            *fLog << " NDF(Number of Degrees of Freedom)=0";
+        if (lambda<=0)
+            *fLog << " Parameter#0(lambda)=0";
+        if (N0<=0)
+            *fLog << " Parameter#1(N0)=0";
+        *fLog << endl;
+
+        return kFALSE;
+    }
+
+    //
+    // -------------- start error calculation ----------------
+    //
+    Double_t emat[2][2];
+    gMinuit->mnemat(&emat[0][0], 2);
+
+    //
+    // Rdead : fraction of real time lost by the dead time
+    // kappa = number of observed events (Nm) divided by
+    //         the number of genuine events (N0)
+    // Teff  : effective on-time
+    //
+    const Double_t Teff  = Nm/lambda;
+    const Double_t kappa = Nm/N0;
+    const Double_t Rdead = 1.0 - kappa;
+
+    const Double_t dldl   = emat[0][0];
+    const Double_t dN0dN0 = emat[1][1];
+
+    const Double_t dTeff = Teff * sqrt(dldl/(lambda*lambda) + 1.0/Nm);
+    const Double_t dl = sqrt(dldl);
+    const Double_t dRdead = kappa * sqrt(dN0dN0/(N0*N0) + 1.0/Nm);
+    //
+    // -------------- end error calculation ----------------
+    //
+
+    // the effective on time is Nm/lambda
+    fHEffOn.SetBinContent(i,  Teff);
+    fHEffOn.SetBinError  (i, dTeff);
+
+    // plot chi2-probability of fit
+    fHProb.SetBinContent(i, prob);
+
+    // lambda from fit
+    fHLambda.SetBinContent(i, lambda);
+    fHLambda.SetBinError  (i,     dl);
+
+    // Rdead from fit
+    fHRdead.SetBinContent(i, Rdead);
+    fHRdead.SetBinError  (i,dRdead);
+
+    return kTRUE;
+}
+
+void MHEffOnTime::ResetBin(Int_t i)
+{
+    fHEffOn.SetBinContent (i, 1.e-20);
+    fHProb.SetBinContent  (i, 1.e-20);
+    fHLambda.SetBinContent(i, 1.e-20);
+    fHRdead.SetBinContent (i, 1.e-20);
+}
+
+// -----------------------------------------------------------------------
+//
+// Calculate the effective on time by fitting the distribution of
+// time differences
+//
+void MHEffOnTime::Calc(const TH2D *hist, const Bool_t draw)
+{
+    // nbins = number of Var bins
+    const Int_t nbins = hist->GetNbinsY();
+
+    for (int i=1; i<=nbins; i++)
+    {
+        TH1D &h = *((TH2D*)hist)->ProjectionX(TString("Calc-")+fVarname,
+                                              i, i, "E");
+        if (draw)
+            DrawBin(h, i);
+
+        ResetBin(i);
+
+        // Nmdel = Nm * binwidth,  with Nm = number of observed events
+        const Double_t Nm    = h.Integral();
+        const Double_t Nmdel = h.Integral("width");
+        if (Nm <= 0)
+        {
+            *fLog << warn << dbginf << "Nm<0 for bin #" << i << endl;
+            delete &h;
+            continue;
+        }
+
+        Double_t yq[2];
+        GetQuantiles(h, 0.15, 0.95, yq);
+
+        //
+        // Setup Poisson function for the fit:
+        // lambda [Hz], N0 = ideal no of evts, del = bin width of dt
+        //
+        TF1 func("Poisson", " [1]*[2] * [0] * exp(-[0] *x)", yq[0], yq[1]);
+        func.SetParNames("lambda", "N0", "del");
+
+        func.SetParameter(0, 1);
+        func.SetParameter(1, Nm);
+        func.FixParameter(2, Nmdel/Nm);
+
+        // For me (TB) it seems that setting parameter limits isn't necessary
+
+        // For a description of the options see TH1::Fit
+        h.Fit("Poisson", "0IRQ");
+
+        // Calc and fill results of fit into the histograms
+        const Bool_t rc = CalcResults(func, Nm, i);
+
+        // draw the distribution of time differences if requested
+        if (rc && draw)
+            func.DrawCopy("same");
+
+        delete &h;
+    }
+}
+
+// -------------------------------------------------------------------------
+//
+// Set the binnings and prepare the filling of the histograms
+//
+Bool_t MHEffOnTime::SetupFill(const MParList *plist)
+{
+    TString bn = "Binning"+fVarname;
+
+    const MBinning* binsVar = (MBinning*)plist->FindObject(bn);
+
+    if (!binsVar)
+    {
+        *fLog << err << dbginf << bn << " [MBinning] not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    SetBinning(&fHEffOn,  binsVar);
+    SetBinning(&fHProb,   binsVar);
+    SetBinning(&fHLambda, binsVar);
+    SetBinning(&fHRdead,  binsVar);
+
+    fHEffOn.Sumw2();
+    fHProb.Sumw2();
+    fHLambda.Sumw2();
+    fHRdead.Sumw2();
+
+    return kTRUE;
+}
+
+// -------------------------------------------------------------------------
+//
+// Draw the histogram
+//
+void MHEffOnTime::Draw(Option_t *opt) 
+{
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    pad->Divide(2,2);
+
+    pad->cd(1);
+    gPad->SetBorderMode(0);
+    fHEffOn.Draw(opt);
+
+    pad->cd(2);
+    gPad->SetBorderMode(0);
+    fHProb.Draw(opt);
+
+    pad->cd(3);
+    gPad->SetBorderMode(0);
+    fHLambda.Draw(opt);
+
+    pad->cd(4);
+    gPad->SetBorderMode(0);
+    fHRdead.Draw(opt);
+
+    pad->Modified();
+    pad->Update();
+}
+
+void MHEffOnTime::Calc(const MHTimeDiffTheta &hist, const Bool_t Draw)
+{
+    Calc(hist.GetHist(), Draw);
+}
+
Index: /tags/Mars_V0-8-5/Mars/mhist/MHEffOnTime.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHEffOnTime.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHEffOnTime.h	(revision 9661)
@@ -0,0 +1,48 @@
+#ifndef MARS_MHEffOnTime
+#define MARS_MHEffOnTime
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+#ifndef ROOT_TH1
+#include <TH1.h>
+#endif
+
+class TH2D;
+class MHTimeDiffTheta;
+class MParList;
+
+class MHEffOnTime : public MH
+{
+private:
+    TH1D fHEffOn;
+    TH1D fHProb;
+    TH1D fHLambda;
+    TH1D fHRdead;
+
+    TString fVarname;
+    TString fUnit;
+
+    void ResetBin(Int_t i);
+    Bool_t CalcResults(const TF1 &func, Double_t Nm, Int_t i);
+    void DrawBin(TH1 &h, Int_t i) const;
+    void GetQuantiles(const TH1 &h, Double_t min, Double_t max, Double_t yq[2]) const;
+
+public:
+    MHEffOnTime(const char *varname=NULL, const char *unit=NULL);
+
+    Bool_t SetupFill(const MParList *pList);
+
+    const TH1D *GetHist() { return &fHEffOn; }
+    const TH1D *GetHist() const { return &fHEffOn; }
+
+    void Calc(const TH2D *hist, const Bool_t Draw);
+    void Calc(const MHTimeDiffTheta &hist, const Bool_t Draw);
+
+    void Draw(Option_t *option="");
+
+    ClassDef(MHEffOnTime, 0) //1D-plot of Delta t vs. Var
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mhist/MHEffOnTimeTheta.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHEffOnTimeTheta.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHEffOnTimeTheta.cc	(revision 9661)
@@ -0,0 +1,286 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz    1/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Wolfgang Wittek 1/2002 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MHEffOnTimeTheta                                                        //
+//                                                                          //
+//  calculates the effective on time for each bin in Theta                  //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MHEffOnTimeTheta.h"
+
+#include <TStyle.h>
+
+#include <TF1.h>
+#include <TH2.h>
+#include <TCanvas.h>
+
+#include "MTime.h"
+
+#include "MBinning.h"
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHEffOnTimeTheta);
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor. It sets name and title of the histograms. 
+//
+MHEffOnTimeTheta::MHEffOnTimeTheta(const char *name, const char *title)
+    : fHEffOn()
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHEffOnTimeTheta";
+    fTitle = title ? title : "1-D histogram of Eff On Time";
+
+    // effective on time versus theta
+    fHEffOn.SetName("EffOn");
+    fHEffOn.SetTitle("Effective On Time vs. Theta");
+
+    fHEffOn.SetDirectory(NULL);
+
+    fHEffOn.SetXTitle("\\Theta [\\circ]");
+    fHEffOn.SetYTitle("t_{eff} [s]");
+
+    // chi2/NDF versus theta
+    fHChi2.SetName("Chi2/NDF");
+    fHChi2.SetTitle("Chi2/NDF of OnTimeFit vs. Theta");
+
+    fHChi2.SetDirectory(NULL);
+
+    fHChi2.SetXTitle("\\Theta [\\circ]");
+    fHChi2.SetYTitle("chi^{2}/NDF");
+
+    // lambda versus theta
+    fHLambda.SetName("lambda");
+    fHLambda.SetTitle("lambda of OnTimeFit vs. Theta");
+
+    fHLambda.SetDirectory(NULL);
+
+    fHLambda.SetXTitle("\\Theta [\\circ]");
+    fHLambda.SetYTitle("\\lambda [Hz]");
+
+    // N0del versus theta
+    fHN0del.SetName("N0del");
+    fHN0del.SetTitle("N0del of OnTimeFit vs. Theta");
+
+    fHN0del.SetDirectory(NULL);
+
+    fHN0del.SetXTitle("\\Theta [\\circ]");
+    fHN0del.SetYTitle("N0del");
+}
+
+// -----------------------------------------------------------------------
+//
+// Calculate the effective on time by fitting the distribution of
+// time differences
+//
+void MHEffOnTimeTheta::Calc(TH2D *hist)
+{
+    // nbins = number of Theta bins
+    const Int_t nbins = hist->GetNbinsY();
+
+    for (int i=1; i<=nbins; i++)
+    {
+        //        TH1D &h = *hist->ProjectionX("Calc-theta", i, i);
+        TH1D &h = *hist->ProjectionX("Calc-theta", i, i, "E");
+
+        // Nmdel = Nm * binwidth,  with Nm = number of observed events
+        const Double_t Nmdel = h.Integral("width");
+        const Double_t Nm    = h.Integral();
+        //        Double_t mean  = h->GetMean();
+
+        //...................................................
+        // determine range (yq[0], yq[1]) of time differences 
+        // where fit should be performed;
+        // require a fraction >=xq[0] of all entries to lie below yq[0]
+        //     and a fraction <=xq[1] of all entries to lie below yq[1];  
+        // within the range (yq[0], yq[1]) there must be no empty bin;
+        // choose pedestrian approach as long as GetQuantiles is not available
+
+        Double_t xq[2] = { 0.15, 0.95 };
+        Double_t yq[2];
+
+        // GetQuantiles doesn't seem to be available in root 3.01/06
+	// h->GetQuantiles(2,yq,xq);
+
+        const Double_t sumtot = h.Integral();
+        const Int_t    jbins  = h.GetNbinsX();
+
+        if (sumtot > 0.0)
+        {
+            Double_t sum1 = 0.0;
+            yq[0] = h.GetBinLowEdge(jbins+1);
+            for (int j=1; j<=jbins; j++)
+            {
+                if (sum1 >= xq[0]*sumtot)
+                {
+                    yq[0] = h.GetBinLowEdge(j);
+                    break;
+                }
+                sum1 += h.GetBinContent(j);
+            }
+
+            Double_t sum2 = 0.0;
+            yq[1] = h.GetBinLowEdge(jbins+1);
+            for (int j=1; j<=jbins; j++)
+            {
+                Double_t content = h.GetBinContent(j);
+                sum2 += content;
+                if (sum2 >= xq[1]*sumtot || content == 0.0)
+                {
+                    yq[1] = h.GetBinLowEdge(j);
+                    break;
+                }
+            }
+
+            //...................................................
+
+            // parameter 0 = lambda
+            // parameter 1 = N0*del        with N0 = ideal number of events
+            //                             and del = bin width of time difference
+            TF1 func("Poisson", "[1] * [0] * exp(-[0] *x)", yq[0], yq[1]);
+
+            func.SetParameter(0, 100); // [Hz]
+            func.SetParameter(1, Nmdel);
+
+            func.SetParLimits(0, 0, 1000);    // [Hz]
+            func.SetParLimits(1, 0, 10*Nmdel);
+
+            func.SetParName(0, "lambda");
+            func.SetParName(1, "Nmdel");
+
+            // options : 0  do not plot the function
+            //           I  use integral of function in bin rather than value at bin center
+            //           R  use the range specified in the function range
+            //           Q  quiet mode
+            h.Fit("Poisson", "0IRQ");
+
+            // gPad->SetLogy();
+            // gStyle->SetOptFit(1011);
+            // h->GetXaxis()->SetTitle("time difference [s]");
+            // h->GetYaxis()->SetTitle("Counts");
+            // h->DrawCopy();
+
+            // func.SetRange(yq[0], yq[1]); // Range of Drawing
+            // func.DrawCopy("same");
+
+            const Double_t lambda = func.GetParameter(0);
+            const Double_t N0del  = func.GetParameter(1);
+            const Double_t chi2   = func.GetChisquare();
+            const Int_t    NDF    = func.GetNDF();
+
+            // was fit successful ?
+            if (NDF>0 && chi2<2.5*NDF)
+            {
+                // the effective on time is Nm/lambda
+                fHEffOn.SetBinContent(i, Nm/lambda);
+
+                // plot chi2/NDF of fit
+                fHChi2.SetBinContent(i, NDF ? chi2/NDF : 0.0);
+
+                // lambda of fit
+                fHLambda.SetBinContent(i, lambda);
+
+                // N0del of fit
+                fHN0del.SetBinContent(i, N0del);
+
+                delete &h;
+                continue;
+            }
+        }
+
+        fHEffOn.SetBinContent (i, 1.e-20);
+        fHChi2.SetBinContent  (i, 1.e-20);
+        fHLambda.SetBinContent(i, 1.e-20);
+        fHN0del.SetBinContent (i, 1.e-20);
+
+        delete &h;
+    }
+}
+
+// -------------------------------------------------------------------------
+//
+// Set the binnings and prepare the filling of the histograms
+//
+Bool_t MHEffOnTimeTheta::SetupFill(const MParList *plist)
+{
+   const MBinning* bins = (MBinning*)plist->FindObject("BinningTheta");
+   if (!bins)
+   {
+       *fLog << err << dbginf << "BinningTheta [MBinning] not found... aborting." << endl;
+       return kFALSE;
+   }
+
+   SetBinning(&fHEffOn,  bins);
+   SetBinning(&fHChi2,   bins);
+   SetBinning(&fHLambda, bins);
+   SetBinning(&fHN0del,  bins);
+
+   fHEffOn.Sumw2();
+   fHChi2.Sumw2();
+   fHLambda.Sumw2();
+   fHN0del.Sumw2();
+
+   return kTRUE;
+}
+
+// -------------------------------------------------------------------------
+//
+// Draw the histogram
+//
+void MHEffOnTimeTheta::Draw(Option_t *opt)
+{
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    pad->Divide(2,2);
+
+    pad->cd(1);
+    gPad->SetBorderMode(0);
+    fHEffOn.Draw(opt);
+
+    pad->cd(2);
+    gPad->SetBorderMode(0);
+    fHChi2.Draw(opt);
+
+    pad->cd(3);
+    gPad->SetBorderMode(0);
+    fHLambda.Draw(opt);
+
+    pad->cd(4);
+    gPad->SetBorderMode(0);
+    fHN0del.Draw(opt);
+
+    pad->Modified();
+    pad->Update();
+}
Index: /tags/Mars_V0-8-5/Mars/mhist/MHEffOnTimeTheta.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHEffOnTimeTheta.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHEffOnTimeTheta.h	(revision 9661)
@@ -0,0 +1,40 @@
+#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);
+
+    Bool_t SetupFill(const MParList *pList);
+
+    const TH1D *GetHist() { return &fHEffOn; }
+    const TH1D *GetHist() const { return &fHEffOn; }
+
+    void Calc(TH2D *hist);
+
+    void Draw(Option_t *option="");
+
+    ClassDef(MHEffOnTimeTheta, 0) //1D-plot of Delta t vs. Theta
+};
+
+#endif
+
+
Index: /tags/Mars_V0-8-5/Mars/mhist/MHEffOnTimeTime.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHEffOnTimeTime.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHEffOnTimeTime.cc	(revision 9661)
@@ -0,0 +1,298 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz    1/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Wolfgang Wittek 1/2002 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MHEffOnTimeTime                                                         //
+//                                                                          //
+//  calculates the effective on time for each bin in time                   //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MHEffOnTimeTime.h"
+
+#include <TStyle.h>
+
+#include <TF1.h>
+#include <TH2.h>
+#include <TCanvas.h>
+
+#include "MTime.h"
+
+#include "MBinning.h"
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHEffOnTimeTime);
+
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor. It sets name and title of the histograms.
+//
+MHEffOnTimeTime::MHEffOnTimeTime(const char *name, const char *title)
+    : fHEffOn()
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHEffOnTimeTime";
+    fTitle = title ? title : "1-D histogram of Eff On Time";
+
+    // effective on time versus time
+    fHEffOn.SetName("EffOn");
+    fHEffOn.SetTitle("Effective On Time vs. Time");
+
+    fHEffOn.SetDirectory(NULL);
+
+    fHEffOn.SetXTitle("time [s]");
+    fHEffOn.SetYTitle("t_{eff} [s]");
+
+    // chi2/NDF versus time
+    fHChi2.SetName("Chi2/NDF");
+    fHChi2.SetTitle("Chi2/NDF of OnTimeFit vs. Time");
+
+    fHChi2.SetDirectory(NULL);
+
+    fHChi2.SetXTitle("time [s]");
+    fHChi2.SetYTitle("chi^{2}/NDF");
+
+    // lambda versus time
+    fHLambda.SetName("lambda");
+    fHLambda.SetTitle("lambda of OnTimeFit vs. Time");
+
+    fHLambda.SetDirectory(NULL);
+
+    fHLambda.SetXTitle("time [s]");
+    fHLambda.SetYTitle("\\lambda [Hz]");
+
+    // N0del versus time
+    fHN0del.SetName("N0del");
+    fHN0del.SetTitle("N0del of OnTimeFit vs. Time");
+
+    fHN0del.SetDirectory(NULL);
+
+    fHN0del.SetXTitle("time [s]");
+    fHN0del.SetYTitle("N0del");
+}
+
+// -----------------------------------------------------------------------
+//
+// Calculate the effective on time by fitting the distribution of
+// time differences
+//
+void MHEffOnTimeTime::Calc(TH2D *hist)
+{
+    // nbins = number of time bins
+    const Int_t nbins = hist->GetNbinsY();
+
+    for (int i=1; i<=nbins; i++)
+    {
+
+        //        TH1D &h = *hist->ProjectionX("Calc-time", i, i, "E");
+        TH1D &h = *hist->ProjectionX("Calc-time", i, i, "E");
+
+
+        // Nmdel = Nm * binwidth,  with Nm = number of observed events
+        const Double_t Nmdel = h.Integral("width");
+        const Double_t Nm    = h.Integral();
+	//        Double_t mean  = h->GetMean();
+
+        //...................................................
+        // determine range (yq[0], yq[1]) of time differences 
+        // where fit should be performed;
+        // require a fraction >=xq[0] of all entries to lie below yq[0]
+        //     and a fraction <=xq[1] of all entries to lie below yq[1];  
+        // within the range (yq[0], yq[1]) there must be no empty bin;
+        // choose pedestrian approach as long as GetQuantiles is not available
+
+        Double_t xq[2] = { 0.15, 0.95 };
+        Double_t yq[2];
+
+        // GetQuantiles doesn't seem to be available in root 3.01/06
+	// h->GetQuantiles(2,yq,xq);
+
+        const Double_t sumtot = h.Integral();
+        const Int_t    jbins  = h.GetNbinsX();
+       
+        if (sumtot > 0.0)
+        {
+            // char txt[100];
+            // sprintf(txt, "time_bin:%d", i);
+            // new TCanvas(txt, txt);
+
+            Double_t sum1 = 0.0;
+            yq[0]  = h.GetBinLowEdge(jbins+1);
+            for (int j=1; j<=jbins; j++)
+            {
+                if (sum1 >= xq[0]*sumtot)
+                {
+                    yq[0] = h.GetBinLowEdge(j);
+                    break;
+                }
+                sum1 += h.GetBinContent(j);
+            }
+        
+            Double_t sum2 = 0.0;
+            yq[1] = h.GetBinLowEdge(jbins+1);
+            for (int j=1; j<=jbins; j++)
+            {
+                const Double_t content = h.GetBinContent(j);
+                sum2 += content;
+                if (sum2 >= xq[1]*sumtot || content == 0.0)
+                {
+                    yq[1] = h.GetBinLowEdge(j);
+                    break;
+                }
+            }
+
+            //...................................................
+
+            // parameter 0 = lambda
+            // parameter 1 = N0*del        with N0 = ideal number of events
+            //                             and del = bin width of time difference
+            TF1 func("Poisson", "[1] * [0] * exp(-[0] *x)", yq[0], yq[1]);
+
+            func.SetParameter(0, 100); // [Hz]
+            func.SetParameter(1, Nmdel);
+
+            func.SetParLimits(0, 0, 1000);    // [Hz]
+            func.SetParLimits(1, 0, 10*Nmdel);
+
+            func.SetParName(0, "lambda");
+            func.SetParName(1, "Nmdel");
+
+            // options : 0  (=zero) do not plot the function
+            //           I  use integral of function in bin rather than value at bin center
+            //           R  use the range specified in the function range
+            //           Q  quiet mode
+            h.Fit("Poisson", "0IRQ");
+
+            // gPad->SetLogy();
+            // gStyle->SetOptFit(1011);
+            // h->GetXaxis()->SetTitle("time difference [s]");
+            // h->GetYaxis()->SetTitle("Counts");
+            // h->DrawCopy();
+
+            // func.SetRange(yq[0], yq[1]); // Range of Drawing
+            // func.DrawCopy("same");
+
+            const Double_t lambda = func.GetParameter(0);
+            const Double_t N0del  = func.GetParameter(1);
+            const Double_t chi2   = func.GetChisquare();
+            const Int_t    NDF    = func.GetNDF();
+
+            // was fit successful ?
+            if (NDF>0  &&  chi2<2.5*NDF)
+            {
+                // the effective on time is Nm/lambda
+                fHEffOn.SetBinContent(i, Nm/lambda);
+
+                // plot chi2/NDF of fit
+                fHChi2.SetBinContent(i, NDF ? chi2/NDF : 0.0);
+
+                // lambda of fit
+                fHLambda.SetBinContent(i, lambda);
+
+                // N0del of fit
+                fHN0del.SetBinContent(i, N0del);
+
+                delete &h;
+                continue;
+            }
+        }
+
+        fHEffOn.SetBinContent (i, 1.e-20);
+        fHChi2.SetBinContent  (i, 1.e-20);
+        fHLambda.SetBinContent(i, 1.e-20);
+        fHN0del.SetBinContent (i, 1.e-20);
+
+        delete &h;
+    }
+}
+
+// -------------------------------------------------------------------------
+//
+// Set the binnings and prepare the filling of the histograms
+//
+Bool_t MHEffOnTimeTime::SetupFill(const MParList *plist)
+{
+    const MBinning* binstime = (MBinning*)plist->FindObject("BinningTime");
+    if (!binstime)
+    {
+        *fLog << err << dbginf << "BinningTime [MBinning] not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    SetBinning(&fHEffOn,  binstime);
+    SetBinning(&fHChi2,   binstime);
+    SetBinning(&fHLambda, binstime);
+    SetBinning(&fHN0del,  binstime);
+
+    fHEffOn.Sumw2();
+    fHChi2.Sumw2();
+    fHLambda.Sumw2();
+    fHN0del.Sumw2();
+
+    return kTRUE;
+}
+
+// -------------------------------------------------------------------------
+//
+// Draw the histogram
+//
+void MHEffOnTimeTime::Draw(Option_t *opt)
+{
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    pad->Divide(2,2);
+
+    pad->cd(1);
+    gPad->SetBorderMode(0);
+    fHEffOn.Draw(opt);
+
+    pad->cd(2);
+    gPad->SetBorderMode(0);
+    fHChi2.Draw(opt);
+
+    pad->cd(3);
+    gPad->SetBorderMode(0);
+    fHLambda.Draw(opt);
+
+    pad->cd(4);
+    gPad->SetBorderMode(0);
+    fHN0del.Draw(opt);
+
+    pad->Modified();
+    pad->Update();
+}
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mhist/MHEffOnTimeTime.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHEffOnTimeTime.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHEffOnTimeTime.h	(revision 9661)
@@ -0,0 +1,39 @@
+#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);
+
+    Bool_t SetupFill(const MParList *pList);
+
+    const TH1D *GetHist() { return &fHEffOn; }
+    const TH1D *GetHist() const { return &fHEffOn; }
+
+    void Calc(TH2D *hist);
+
+    void Draw(Option_t *option="");
+
+    ClassDef(MHEffOnTimeTime, 0) //1D-plot of Delta t vs. time
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mhist/MHEnergyTheta.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHEnergyTheta.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHEnergyTheta.cc	(revision 9661)
@@ -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  1/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MHEnergyTheta                                                           //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MHEnergyTheta.h"
+
+#include <TCanvas.h>
+
+#include "MH.h"
+#include "MBinning.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MMcEvt.hxx"
+
+#include "MParList.h"
+
+ClassImp(MHEnergyTheta);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+//  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;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill data into the histogram which contains all showers
+//
+Bool_t MHEnergyTheta::Fill(const MParContainer *par, const Stat_t w)
+{
+    const MMcEvt &mcevt = *(MMcEvt*)par;
+
+    fHist.Fill(mcevt.GetEnergy(), mcevt.GetTheta(), w);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw the histogram with all showers
+//
+void MHEnergyTheta::Draw(Option_t* option)
+{
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+    pad->SetLogy();
+
+    fHist.Draw(option);
+
+    pad->Modified();
+    pad->Update();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Calculate the Efficiency (collection area) and set the 'ReadyToSave'
+//  flag
+//
+void MHEnergyTheta::Divide(const TH2D *h1, const TH2D *h2)
+{
+    // Description!
+
+    fHist.Sumw2();
+    fHist.Divide((TH2D*)h1, (TH2D*)h2);
+
+    SetReadyToSave();
+}
Index: /tags/Mars_V0-8-5/Mars/mhist/MHEnergyTheta.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHEnergyTheta.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHEnergyTheta.h	(revision 9661)
@@ -0,0 +1,42 @@
+#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);
+
+    Bool_t Fill(const MParContainer *cont, const Stat_t w=1);
+
+    void Draw(Option_t *option="");
+
+    Bool_t SetupFill(const MParList *plist);
+
+    const TH2D *GetHist() { return &fHist; }
+    const TH2D *GetHist() const { return &fHist; }
+
+    TH1 *GetHistByName(const TString name) { return &fHist; }
+
+    void Divide(const TH2D *h1, const TH2D *h2);
+    void Divide(const MHEnergyTheta *h1, const MHEnergyTheta *h2)
+    {
+        Divide(h1->GetHist(), h2->GetHist());
+    }
+
+    ClassDef(MHEnergyTheta, 1)  // Histogram: Energy vs. Theta
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mhist/MHEnergyTime.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHEnergyTime.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHEnergyTime.cc	(revision 9661)
@@ -0,0 +1,142 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  1/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MHEnergyTime                                                            //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MHEnergyTime.h" 
+
+#include <TCanvas.h>
+
+#include "MMcEvt.hxx"
+#include "MTime.h"
+
+#include "MH.h"
+#include "MBinning.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+ClassImp(MHEnergyTime);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+//  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;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill data into the histogram which contains all showers
+//
+Bool_t MHEnergyTime::Fill(const MParContainer *par, const Stat_t w)
+{
+    const MMcEvt &mcevt = *(MMcEvt*)par;
+
+    fHist.Fill(mcevt.GetEnergy(), *fTime, w);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw the histogram with all showers
+//
+void MHEnergyTime::Draw(Option_t* option)
+{
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    AppendPad("");
+
+    pad->SetLogy();
+    fHist.DrawCopy(option);
+
+    pad->Modified();
+    pad->Update();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Calculate the Efficiency (collection area) and set the 'ReadyToSave'
+//  flag
+//
+void MHEnergyTime::Divide(const TH2D *h1, const TH2D *h2)
+{
+    // Description!
+
+    fHist.Sumw2();
+    fHist.Divide((TH2D*)h1, (TH2D*)h2);
+
+    SetReadyToSave();
+}
Index: /tags/Mars_V0-8-5/Mars/mhist/MHEnergyTime.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHEnergyTime.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHEnergyTime.h	(revision 9661)
@@ -0,0 +1,43 @@
+#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);
+
+    Bool_t Fill(const MParContainer *cont,  const Stat_t w=1);
+
+    void Draw(Option_t *option="");
+
+    Bool_t SetupFill(const MParList *plist);
+
+    const TH2D *GetHist() { return &fHist; }
+    const TH2D *GetHist() const { return &fHist; }
+
+    TH1 *GetHistByName(const TString name) { return &fHist; }
+
+    void Divide(const TH2D *h1, const TH2D *h2);
+    void Divide(const MHEnergyTime *h1, const MHEnergyTime *h2)
+    {
+        Divide(h1->GetHist(), h2->GetHist());
+    }
+
+    ClassDef(MHEnergyTime, 1)  // Histogram: Energy vs. Time
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mhist/MHEvent.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHEvent.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHEvent.cc	(revision 9661)
@@ -0,0 +1,289 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          
+//  MHEvent
+//                                                                          
+//  Display a single event in a canvas with as many informations as
+//  possible, such as event number, run number, ...
+//
+//  WARNING: This class is not yet ready!
+//
+//  Input Containers:
+//   MGeomCam
+//   [MTaskList]
+//   [MImgCleanStd]
+//   [MRawEvtData]
+//   [MRawRunHeader]
+//   [MRawEvtHeader]
+//
+//  Output Containers:
+//   -/-
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MHEvent.h"
+
+#include <TStyle.h>
+#include <TCanvas.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MMcEvt.hxx"
+#include "MMcTrig.hxx"
+
+#include "MHCamera.h"
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MParList.h"
+#include "MCerPhotEvt.h"
+#include "MRawEvtHeader.h"
+#include "MRawRunHeader.h"
+#include "MRawEvtData.h"
+#include "MImgCleanStd.h"
+
+ClassImp(MHEvent);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+MHEvent::MHEvent(EventType_t type) : fHist(NULL), fType(type)
+{
+    fName = "MHEvent";
+    fTitle = "Single Event display task";
+
+    fClone = new MRawEvtData("MHEventData");
+}
+
+// --------------------------------------------------------------------------
+//
+MHEvent::~MHEvent()
+{
+    if (fHist)
+        delete fHist;
+
+    delete fClone;
+}
+
+Bool_t MHEvent::SetupFill(const MParList *plist)
+{
+    MTaskList *tlist = (MTaskList*)plist->FindObject("MTaskList");
+
+    fImgCleanStd = tlist ? (MImgCleanStd*)tlist->FindObject("MImgCleanStd") : NULL;
+    fMcEvt       = (MMcEvt*)plist->FindObject("MMcEvt");
+
+     fRawEvtData = (MRawEvtData*)plist->FindObject("MRawEvtData");
+     if (!fRawEvtData)
+        *fLog << warn << "MRawEvtData not found..." << endl;
+
+    fRawRunHeader = (MRawRunHeader*)plist->FindObject("MRawRunHeader");
+    if (!fRawRunHeader)
+        *fLog << warn << dbginf << "MRawRunHeader not found..." << endl;
+
+    fRawEvtHeader = (MRawEvtHeader*)plist->FindObject("MRawEvtHeader");
+    if (!fRawEvtHeader)
+        *fLog << warn << dbginf << "MRawEvtHeader not found..." << endl;
+
+    MGeomCam *cam = (MGeomCam*)plist->FindObject("MGeomCam");
+    if (!cam)
+    {
+        *fLog << err << GetDescriptor() << ": No MGeomCam found... aborting." << endl;
+        return kFALSE;
+    }
+
+    if (fHist)
+        delete (fHist);
+
+    fHist = new MHCamera(*cam);
+    fHist->AddNotify(fClone);
+
+    switch (fType)
+    {
+    case kEvtSignalRaw:
+        fHist->SetName("Signal (raw)");
+        fHist->SetYTitle("S [au]");
+        break;
+    case kEvtSignalDensity:
+        fHist->SetName("Signal density");
+        fHist->SetYTitle("S [au]");
+        break;
+    case kEvtPedestal:
+        fHist->SetName("Pedestal");
+        fHist->SetYTitle("P [au]");
+        break;
+    case kEvtPedestalRMS:
+        fHist->SetName("Pedestal RMS");
+        fHist->SetYTitle("\\sigma_{P} [au]");
+        break;
+    case kEvtRelativeSignal:
+        fHist->SetName("Signal/PedRMS");
+        fHist->SetYTitle("S/P_{rms}");
+        break;
+    case kEvtCleaningLevels:
+        if (!fImgCleanStd)
+        {
+            *fLog << err << "MImgCleanStd not found... aborting." << endl;
+            return kFALSE;
+        }
+        fHist->SetName("CleanLevels");
+        fHist->SetYTitle("L");
+        break;
+     case kEvtIdxMax:
+        fHist->SetName("Max Slice Idx");
+        fHist->SetYTitle("t [slice id]");
+	fHist->SetPrettyPalette();
+        break;
+     case kEvtArrTime:
+        fHist->SetName("Arrival Time");
+        fHist->SetYTitle("t [slice id]");
+	fHist->SetPrettyPalette();
+        break;
+     case kEvtTrigPix:
+        fHist->SetName("Triggered pix");
+        fHist->SetYTitle("ON/OFF");
+	fHist->SetPrettyPalette();
+        break;
+    }
+
+    return kTRUE;
+}
+
+Bool_t MHEvent::Fill(const MParContainer *par, const Stat_t weight)
+{
+    if (fHist->IsFreezed())
+        return kTRUE;
+
+    if (!par)
+        return kFALSE;
+
+    const MCamEvent *event = dynamic_cast<const MCamEvent*>(par);
+    if (!event)
+    {
+        *fLog << err << par->GetDescriptor() << " doesn't inherit from MCamEvent... abort." << endl;
+        return kFALSE;
+    }
+
+    if (fRawEvtData)
+        fRawEvtData->Copy(*fClone);
+
+    switch (fType)
+    {
+    case kEvtSignalRaw:   // Get Content without pixel-size scaling
+        fHist->SetCamContent(*event, 3);
+        break;
+    case kEvtSignalDensity:
+        fHist->SetCamContent(*event, 0);
+        break;
+    case kEvtPedestal:
+        fHist->SetCamContent(*event, 0);
+        break;
+    case kEvtPedestalRMS:
+        fHist->SetCamContent(*event, 1);
+        break;
+    case kEvtRelativeSignal:
+        fHist->SetCamContent(*event, 0);
+        break;
+    case kEvtCleaningLevels:
+        {
+            TArrayF lvl(2);
+            lvl[0] = fImgCleanStd->GetCleanLvl2();
+            lvl[1] = fImgCleanStd->GetCleanLvl1();
+            fHist->SetCamContent(*event, 0);
+            fHist->SetLevels(lvl);
+        }
+        break;
+    case kEvtIdxMax:
+        fHist->SetCamContent(*event, 5);
+        break;
+    case kEvtArrTime:
+        fHist->SetCamContent(*event, 0);
+        break; 
+    case kEvtTrigPix:
+        fHist->SetCamContent(*event, 0);
+        break; 
+    }
+
+    TString s;
+    if (fRawEvtHeader)
+    {
+        s += "Event #";
+        s += fRawEvtHeader->GetDAQEvtNumber();
+    }
+    if (fRawEvtHeader && fRawRunHeader)
+        s += " of ";
+
+    if (fRawRunHeader)
+    {
+        s += "Run #";
+        s += fRawRunHeader->GetRunNumber();
+    }
+
+    if (fMcEvt)
+    {
+        TString txt("#splitline{");
+
+        txt += fMcEvt->GetParticleName();
+        txt += " ";
+
+        s.Insert(0, txt);
+
+        s += "}{  E=";
+
+        s+= fMcEvt->GetEnergyStr();
+
+        s += " r=";
+        s += (int)(fMcEvt->GetImpact()/100+.5);
+        s += "m Zd=";
+        s += (int)(fMcEvt->GetTheta()*180/TMath::Pi()+.5);
+        s += "\\circ ";
+        if (fMcEvt->GetPhotElfromShower()>=10000)
+            s += Form("%dk", (Int_t)(fMcEvt->GetPhotElfromShower()/1000.+.5));
+        else
+            if (fMcEvt->GetPhotElfromShower()>=1000)
+                s += Form("%.1fk", fMcEvt->GetPhotElfromShower()/1000.);
+            else
+                s += fMcEvt->GetPhotElfromShower();
+        s += "PhEl}";
+    }
+
+    gPad=NULL;
+    fHist->SetTitle(s);
+
+    return kTRUE;
+}
+
+void MHEvent::Draw(Option_t *)
+{
+    if (!fHist)
+    {
+        *fLog << warn << "MHEvent::Draw - fHist==NULL not initialized." << endl;
+        return;
+    }
+
+    if (!gPad)
+        MakeDefCanvas(this);
+    fHist->Draw();
+}
Index: /tags/Mars_V0-8-5/Mars/mhist/MHEvent.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHEvent.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHEvent.h	(revision 9661)
@@ -0,0 +1,61 @@
+#ifndef MARS_MHEvent
+#define MARS_MHEvent
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+class MHCamera;
+class MRawEvtData;
+class MRawRunHeader;
+class MRawEvtHeader;
+
+class MMcEvt;
+class MMcTrig;
+class MCerPhotEvt;
+class MImgCleanStd;
+class MCameraSignal;
+
+class MHEvent : public MH
+{
+public:
+    enum EventType_t {
+        kEvtSignalRaw, kEvtSignalDensity, kEvtPedestal, 
+        kEvtPedestalRMS, kEvtRelativeSignal, kEvtCleaningLevels,
+        kEvtIdxMax, kEvtArrTime, kEvtTrigPix 
+    };
+
+private:
+    MRawEvtData   *fRawEvtData;    //!
+    MRawRunHeader *fRawRunHeader;  //!
+    MRawEvtHeader *fRawEvtHeader;  //!
+
+    MMcEvt        *fMcEvt;         //!
+    MMcTrig       *fMcTrig;        //!
+    MCerPhotEvt   *fCerPhotEvt;    //!
+    MImgCleanStd  *fImgCleanStd;   //!
+    MCameraSignal *fCamSignal;     //!
+
+    MRawEvtData   *fClone;         //->
+
+    MHCamera *fHist;
+
+    EventType_t fType;
+
+    TH1 *GetHistByName(const TString name) { return (TH1*)fHist; }
+
+    Bool_t SetupFill(const MParList *plist);
+    Bool_t Fill(const MParContainer *par, const Stat_t weight=1);
+
+public:
+    MHEvent(EventType_t type=kEvtSignalRaw);
+    ~MHEvent();
+
+    MHCamera *GetHist() { return fHist; }
+
+    void Draw(Option_t *o="");
+ 
+    ClassDef(MHEvent, 1)
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mhist/MHFadcCam.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHFadcCam.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHFadcCam.cc	(revision 9661)
@@ -0,0 +1,194 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Harald Kornmayer 1/2001
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////
+//
+// MHFadcCam
+//
+// This class contains a list of MHFadcPix.
+//
+///////////////////////////////////////////////////////////////////////
+
+#include "MHFadcCam.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MGeomCam.h"
+
+#include "MRawEvtData.h"
+#include "MRawEvtPixelIter.h"
+
+ClassImp(MHFadcCam);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+//  default constructor
+//  creates an a list of histograms for all pixels and both gain channels
+//
+MHFadcCam::MHFadcCam(/*const Int_t n,*/ MHFadcPix::Type_t t, const char *name, const char *title)
+    : fNumHiGains(-1), fNumLoGains(-1), fType(t)
+{
+    //
+    // 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;
+    fArray->SetOwner();
+
+    //    for (Int_t i=0; i<n; i++)
+    //        (*fArray)[i] = new MHFadcPix(i, fType);
+}
+
+// --------------------------------------------------------------------------
+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
+{
+    const Int_t n = fArray->GetSize();
+
+    //
+    // FIXME, this might be done faster and more elegant, by direct copy.
+    //
+    MHFadcCam *cam = new MHFadcCam(fType);
+
+    cam->fArray->Expand(n);
+
+    for (int i=0; i<n; i++)
+    {
+        delete (*cam->fArray)[i];
+        (*cam->fArray)[i] = (MHFadcPix*)(*fArray)[i]->Clone();
+    }
+    return cam;
+}
+
+// --------------------------------------------------------------------------
+//
+// To setup the object we get the number of pixels from a MGeomCam object
+// in the Parameter list.
+//
+Bool_t MHFadcCam::SetupFill(const MParList *pList)
+{
+    MGeomCam *cam = (MGeomCam*)pList->FindObject("MGeomCam");
+    if (!cam)
+    {
+        *fLog << err << "MGeomCam (Camera Geometry) missing in Parameter List... aborting." << endl;
+        return kFALSE;
+    }
+
+    const Int_t n = cam->GetNumPixels();
+
+    fArray->Delete();
+    fArray->Expand(n);
+
+    for (Int_t i=0; i<n; i++)
+        (*fArray)[i] = new MHFadcPix(i, fType);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+Bool_t MHFadcCam::Fill(const MParContainer *par, const Stat_t w)
+{
+    return Fill((MRawEvtData*)par);
+}
+
+Bool_t MHFadcCam::Fill(const MRawEvtData *par)
+{
+    const Int_t n = fArray->GetSize();
+
+    if (fType==MHFadcPix::kSlices)
+    {
+        const Int_t nhi = par->GetNumHiGainSamples();
+
+        //
+        // skip MC events without FADC information stored
+        //
+        if (nhi==0)
+            return kTRUE;
+
+        const Int_t nlo = par->GetNumLoGainSamples();
+
+        //
+        // First call with nhi!=0
+        //
+        if (fNumHiGains<0)
+            for (int i=0; i<n; i++)
+                (*this)[i].Init(nhi, nlo);
+        else
+        {
+            if (fNumLoGains!=nlo)
+            {
+                *fLog << err << dbginf << "ERROR - Number of lo-gain samples changed from " << fNumLoGains << " to " << nlo << endl;
+                return kFALSE;
+            }
+            if (fNumHiGains!=nhi)
+            {
+                *fLog << err << dbginf << "ERROR - Number of hi-gain samples changed from " << fNumHiGains << " to " << nhi << endl;
+                return kFALSE;
+            }
+        }
+
+        fNumHiGains = nhi;
+        fNumLoGains = nlo;
+    }
+
+    for (int i=0; i<n; i++)
+        if (!(*this)[i].Fill(*par))
+            return kFALSE;
+
+    return kTRUE;
+}
+
+void MHFadcCam::ResetHistograms()
+{
+    const Int_t n = fArray->GetSize();
+    for (Int_t i=0; i<n; i++)
+        ResetEntry(i);
+}
+
+void MHFadcCam::ResetEntry(Int_t i)
+{
+    GetHistHi(i)->Reset();
+    GetHistLo(i)->Reset();
+}
Index: /tags/Mars_V0-8-5/Mars/mhist/MHFadcCam.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHFadcCam.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHFadcCam.h	(revision 9661)
@@ -0,0 +1,75 @@
+#ifndef MARS_MHFadcCam
+#define MARS_MHFadcCam
+
+#ifndef ROOT_TObjArray
+#include <TObjArray.h>
+#endif
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+#ifndef MARS_MHFadcPix
+#include "MHFadcPix.h"
+#endif
+
+#ifndef ROOT_TH1
+#include <TH1.h>
+#endif
+
+class MRawEvtData;
+
+class MHFadcCam : public MH
+{
+private:
+    TObjArray *fArray;	//-> List of Lo/Hi gain Histograms
+
+    //    void FillHi(UInt_t ipix, Byte_t data) { (*this)[ipix]->FillHi(data); }
+    //    void FillLo(UInt_t ipix, Byte_t data) { (*this)[ipix]->FillLo(data); }
+
+    Int_t fNumHiGains; //!
+    Int_t fNumLoGains; //!
+
+    MHFadcPix::Type_t fType; //!
+
+public:
+    MHFadcCam(/*const Int_t n=577,*/ MHFadcPix::Type_t t=MHFadcPix::kValue, const char *name=NULL, const char *title=NULL);
+    ~MHFadcCam();
+
+    MHFadcPix &operator[](UInt_t i) { return *(MHFadcPix*)(fArray->At(i)); }
+    const MHFadcPix &operator[](UInt_t i) const { return *(MHFadcPix*)(fArray->At(i)); }
+
+    TH1F *GetHistHi(UInt_t i)  { return (*this)[i].GetHistHi(); }
+    TH1F *GetHistLo(UInt_t i)  { return (*this)[i].GetHistLo(); }
+
+    const TH1F *GetHistHi(UInt_t i) const { return (*this)[i].GetHistHi(); }
+    const TH1F *GetHistLo(UInt_t i) const { return (*this)[i].GetHistLo(); }
+
+    Bool_t SetupFill(const MParList *pList);
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+    Bool_t Fill(const MRawEvtData *par);
+
+    void ResetHistograms();
+    void ResetEntry(Int_t i);
+
+    //
+    // 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(); }
+
+    Bool_t HasLo(UInt_t i) const { return GetHistLo(i)->GetEntries()>0; }
+    Bool_t HasHi(UInt_t i) const { return GetHistHi(i)->GetEntries()>0; }
+
+    Bool_t Exists(UInt_t i) const { return HasLo(i) && HasHi(i); }
+
+    void DrawPix(UInt_t i)     { (*this)[i].Draw(); }
+
+    Int_t GetEntries() const   { return fArray->GetEntries(); }
+
+    TObject *Clone(const char *opt="") const;
+
+    ClassDef(MHFadcCam, 1) // A list of histograms storing the Fadc spektrum of one pixel
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mhist/MHFadcPix.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHFadcPix.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHFadcPix.cc	(revision 9661)
@@ -0,0 +1,171 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Harald Kornmayer 1/2001
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////
+//
+// MHFadcPix
+//
+// This container stores a histogram to display an Fadc Spektrum.
+// The spektrum of all the values measured by the Fadcs.
+//
+///////////////////////////////////////////////////////////////////////
+#include "MHFadcPix.h"
+
+#include <TPad.h>
+
+#include "MH.h"
+#include "MBinning.h"
+
+#include "MRawEvtData.h"
+#include "MRawEvtPixelIter.h"
+
+ClassImp(MHFadcPix);
+
+// --------------------------------------------------------------------------
+//
+// Creates the histograms for lo and hi gain of one pixel
+//
+MHFadcPix::MHFadcPix(Int_t pixid, Type_t t)
+    : fPixId(pixid), fType(t)
+{
+    fHistHi.SetName(pixid>=0 ? Form("HiGain%03d", pixid) : "HiGain");
+    fHistHi.SetTitle(pixid>=0 ? Form("Hi Gain Pixel #%d", pixid) : "Hi Gain Samples");
+    fHistHi.SetDirectory(NULL);
+    fHistHi.UseCurrentStyle();
+
+    fHistLo.SetName(pixid>=0 ? Form("LoGain%03d", pixid) : "LoGain");
+    fHistLo.SetTitle(pixid>=0 ? Form("Lo Gain Pixel #%d", pixid) : "Lo Gain Samples");
+    fHistLo.SetDirectory(NULL);
+    fHistLo.UseCurrentStyle();
+
+    if (fType==kValue)
+    {
+        fHistHi.SetXTitle("Signal/FADC Units");
+        fHistLo.SetXTitle("Signal/FADC Units");
+        fHistHi.SetYTitle("Count");
+        fHistLo.SetYTitle("Count");
+
+        MBinning bins;
+        bins.SetEdges(255, -.5, 255.5);
+
+        bins.Apply(fHistHi);
+        bins.Apply(fHistLo);
+    }
+    else
+    {
+        fHistHi.SetXTitle("Time/FADC Slices");
+        fHistLo.SetXTitle("Time/FADC Slices");
+        fHistLo.SetYTitle("Sum Signal/FADC Units");
+        fHistHi.SetYTitle("Sum Signal/FADC Units");
+    }
+}
+
+void MHFadcPix::Init(Byte_t nhi, Byte_t nlo)
+{
+    MBinning bins;
+
+    bins.SetEdges(nhi, -.5, -.5+nhi);
+    bins.Apply(fHistHi);
+
+    bins.SetEdges(nlo, -.5, -.5+nlo);
+    bins.Apply(fHistLo);
+}
+
+Bool_t MHFadcPix::Fill(const MRawEvtData &evt)
+{
+    MRawEvtPixelIter pixel((MRawEvtData*)&evt);
+
+    if (!pixel.Jump(fPixId))
+        return kTRUE;
+
+    const Int_t nhisamples = evt.GetNumHiGainSamples();
+
+    if (fType==kValue)
+        for (Int_t i=0; i<nhisamples; i++)
+            fHistHi.Fill(pixel.GetHiGainSamples()[i]);
+    else
+        for (Int_t i=0; i<nhisamples; i++)
+            fHistHi.Fill(i, pixel.GetHiGainSamples()[i]);
+
+    if (!pixel.HasLoGain())
+        return kTRUE;
+
+    const Int_t nlosamples = evt.GetNumLoGainSamples();
+
+    if (fType==kValue)
+        for (Int_t i=0; i<nlosamples; i++)
+            fHistLo.Fill(pixel.GetLoGainSamples()[i]);
+    else
+        for (Int_t i=0; i<nlosamples; i++)
+            fHistLo.Fill(i, pixel.GetLoGainSamples()[i]);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+void MHFadcPix::DrawHi()
+{
+    fHistHi.Draw();
+}
+
+// --------------------------------------------------------------------------
+void MHFadcPix::DrawLo()
+{
+    fHistLo.Draw();
+}
+
+// --------------------------------------------------------------------------
+//
+// We need our own clone function to get rid of the histogram in any
+// directory
+//
+TObject *MHFadcPix::Clone(const char *) const
+{
+    MHFadcPix &pix = *(MHFadcPix*)TObject::Clone();
+
+    pix.fHistHi.SetDirectory(NULL);
+    pix.fHistLo.SetDirectory(NULL);
+
+    return &pix;
+}
+
+// --------------------------------------------------------------------------
+void MHFadcPix::Draw(Option_t *)
+{
+    if (!gPad)
+    {
+        const char *name = StrDup(fPixId ? Form("Pixel #%d", fPixId) : "Pixel");
+        MH::MakeDefCanvas(name, fPixId ? Form("%s FADC Samples", name) : "FADC Samples");
+        delete [] name;
+    }
+
+    gPad->Divide(1, 2);
+
+    gPad->cd(1);
+    fHistHi.Draw();
+
+    gPad->cd(2);
+    fHistLo.Draw();
+}
Index: /tags/Mars_V0-8-5/Mars/mhist/MHFadcPix.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHFadcPix.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHFadcPix.h	(revision 9661)
@@ -0,0 +1,50 @@
+#ifndef MARS_MHFadcPix
+#define MARS_MHFadcPix
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#ifndef ROOT_TH1
+#include <TH1.h>
+#endif
+
+class MRawEvtData;
+
+class MHFadcPix : public MParContainer
+{
+public:
+    enum Type_t { kSlices, kValue };
+
+private:
+    TH1F fHistHi;
+    TH1F fHistLo;
+
+    UInt_t fPixId;
+
+    Type_t fType;
+
+public:
+    MHFadcPix(Int_t pixid=-1, Type_t t=kValue);
+
+    TH1F *GetHistHi() { return &fHistHi; }
+    TH1F *GetHistLo() { return &fHistLo; }
+
+    const TH1F *GetHistHi() const { return &fHistHi; }
+    const TH1F *GetHistLo() const { return &fHistLo; }
+
+    void Init(Byte_t nhi, Byte_t nlo);
+    Bool_t Fill(const MRawEvtData &evt);
+
+    void DrawHi();
+    void DrawLo();
+
+    TObject *Clone(const char *) const;
+
+    void Draw(Option_t *opt=NULL);
+
+    ClassDef(MHFadcPix, 1) // Conatiner to hold two histograms container spektrums for the lo-/hi gain of one pixel
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mhist/MHFalseSource.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHFalseSource.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHFalseSource.cc	(revision 9661)
@@ -0,0 +1,1085 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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, 3/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// MHFalseSource
+//
+// Create a false source plot. For the Binning in x,y the object MBinning
+// "BinningFalseSource" is taken from the paremeter list.
+//
+// The binning in alpha is currently fixed as 18bins from 0 to 90deg.
+//
+// If MTime, MObservatory and MPointingPos is available in the paremeter
+// list each image is derotated.
+//
+// MHFalseSource fills a 3D histogram with alpha distribution for
+// each (derotated) x and y position.
+//
+// Only a radius of 1.2deg around the camera center is taken into account.
+//
+// The displayed histogram is the projection of alpha<fAlphaCut into
+// the x,y plain and the projection of alpha>90-fAlphaCut
+//
+// By using the context menu (find it in a small region between the single
+// pads) you can change the AlphaCut 'online'
+//
+// Each Z-Projection (Alpha-histogram) is scaled such, that the number
+// of entries fits the maximum number of entries in all Z-Projections.
+// This should correct for the different acceptance in the center
+// and at the vorder of the camera. This, however, produces more noise
+// at the border.
+//
+// Here is a slightly simplified version of the algorithm:
+// ------------------------------------------------------
+//    MHillas hil; // Taken as second argument in MFillH
+//
+//    MSrcPosCam src;
+//    MHillasSrc hsrc;
+//    hsrc.SetSrcPos(&src);
+//
+//    for (int ix=0; ix<nx; ix++)
+//        for (int iy=0; iy<ny; iy++)
+//        {
+//            TVector2 v(cx[ix], cy[iy]); //cx center of x-bin ix
+//            if (rho!=0)                 //cy center of y-bin iy
+//                v=v.Rotate(rho);         //image rotation angle
+//
+//            src.SetXY(v);               //source position in the camera
+//
+//            if (!hsrc.Calc(hil))        //calc source dependant hillas
+//                return;
+//
+//            //fill absolute alpha into histogram
+//            const Double_t alpha = hsrc.GetAlpha();
+//            fHist.Fill(cx[ix], cy[iy], TMath::Abs(alpha), w);
+//        }
+//    }
+//
+// Use MHFalse Source like this:
+// -----------------------------
+//    MFillH fill("MHFalseSource", "MHillas");
+// or
+//    MHFalseSource hist;
+//    hist.SetAlphaCut(12.5);  // The default value
+//    hist.SetBgmean(55);      // The default value
+//    MFillH fill(&hist, "MHillas");
+//
+// To be implemented:
+// ------------------
+//  - a switch to use alpha or |alpha|
+//  - taking the binning for alpha from the parlist (binning is
+//    currently fixed)
+//  - a possibility to change the fit-function (eg using a different TF1)
+//  - a possibility to change the fit algorithm (eg which paremeters
+//    are fixed at which time)
+//  - use a different varaible than alpha
+//  - a possiblity to change the algorithm which is used to calculate
+//    alpha (or another parameter) is missing (this could be done using
+//    a tasklist somewhere...)
+//  - a more clever (and faster) algorithm to fill the histogram, eg by
+//    calculating alpha once and fill the two coils around the mean
+//  - more drawing options...
+//  - Move Significance() to a more 'general' place and implement
+//    also different algorithms like (Li/Ma)
+//  - implement fit for best alpha distribution -- online (Paint)
+//  - currently a constant pointing position is assumed in Fill()
+//  - the center of rotation need not to be the camera center
+//  - ERRORS on each alpha bin to estimate the chi^2 correctly!
+//    (sqrt(N)/binwidth) needed for WOlfgangs proposed caluclation
+//    of alpha(Li/Ma)
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MHFalseSource.h"
+
+#include <TF1.h>
+#include <TH2.h>
+#include <TGraph.h>
+#include <TStyle.h>
+#include <TCanvas.h>
+#include <TPaveText.h>
+#include <TStopwatch.h>
+
+#include "MGeomCam.h"
+#include "MSrcPosCam.h"
+#include "MHillasSrc.h"
+#include "MTime.h"
+#include "MObservatory.h"
+#include "MPointingPos.h"
+#include "MAstroCatalog.h"
+#include "MAstroSky2Local.h"
+#include "MStatusDisplay.h"
+#include "MMath.h"
+
+#include "MBinning.h"
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHFalseSource);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor
+//
+MHFalseSource::MHFalseSource(const char *name, const char *title)
+    : fTime(0), fPointPos(0), fObservatory(0), fMm2Deg(-1), fAlphaCut(12.5),
+    fBgMean(55), fMinDist(-1), fMaxDist(-1), fMinLD(-1), fMaxLD(-1)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHFalseSource";
+    fTitle = title ? title : "3D-plot of Alpha vs x, y";
+
+    fHist.SetDirectory(NULL);
+
+    fHist.SetName("Alpha");
+    fHist.SetTitle("3D-plot of Alpha vs x, y");
+    fHist.SetXTitle("x [\\circ]");
+    fHist.SetYTitle("y [\\circ]");
+    fHist.SetZTitle("\\alpha [\\circ]");
+}
+
+void MHFalseSource::MakeSymmetric(TH1 *h)
+{
+    const Float_t min = TMath::Abs(h->GetMinimum());
+    const Float_t max = TMath::Abs(h->GetMaximum());
+
+    const Float_t absmax = TMath::Max(min, max)*1.002;
+
+    h->SetMaximum( absmax);
+    h->SetMinimum(-absmax);
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the alpha cut (|alpha|<fAlphaCut) which is use to estimate the
+// number of excess events
+//
+void MHFalseSource::SetAlphaCut(Float_t alpha)
+{
+    if (alpha<0)
+        *fLog << warn << "Alpha<0... taking absolute value." << endl;
+
+    fAlphaCut = TMath::Abs(alpha);
+
+    Modified();
+}
+
+// --------------------------------------------------------------------------
+//
+// Set mean alpha around which the off sample is determined
+// (fBgMean-fAlphaCut/2<|fAlpha|<fBgMean+fAlphaCut/2) which is use
+// to estimate the number of off events
+//
+void MHFalseSource::SetBgMean(Float_t alpha)
+{
+    if (alpha<0)
+        *fLog << warn << "Alpha<0... taking absolute value." << endl;
+
+    fBgMean = TMath::Abs(alpha);
+
+    Modified();
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculate Significance as
+// significance = (s-b)/sqrt(s+k*k*b) mit k=s/b
+//
+// s: total number of events in signal region
+// b: number of background events in signal region
+// 
+Double_t MHFalseSource::Significance(Double_t s, Double_t b)
+{
+    return MMath::SignificanceSym(s, b);
+}
+
+// --------------------------------------------------------------------------
+//
+//  calculates the significance according to Li & Ma
+//  ApJ 272 (1983) 317, Formula 17
+//
+//  s                    // s: number of on events
+//  b                    // b: number of off events
+//  alpha = t_on/t_off;  // t: observation time
+//
+Double_t MHFalseSource::SignificanceLiMa(Double_t s, Double_t b, Double_t alpha)
+{
+    return MMath::SignificanceLiMaSigned(s, b);
+}
+
+// --------------------------------------------------------------------------
+//
+// Set binnings (takes BinningFalseSource) and prepare filling of the
+// histogram.
+//
+// Also search for MTime, MObservatory and MPointingPos
+// 
+Bool_t MHFalseSource::SetupFill(const MParList *plist)
+{
+    const MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam");
+    if (!geom)
+    {
+        *fLog << err << "MGeomCam not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fMm2Deg = geom->GetConvMm2Deg();
+
+    MBinning binsa;
+    binsa.SetEdges(18, 0, 90);
+
+    const MBinning *bins = (MBinning*)plist->FindObject("BinningFalseSource");
+    if (!bins)
+    {
+        const Float_t r = (geom ? geom->GetMaxRadius()/3 : 200)*fMm2Deg;
+
+        MBinning b;
+        b.SetEdges(20, -r, r);
+        SetBinning(&fHist, &b, &b, &binsa);
+    }
+    else
+        SetBinning(&fHist, bins, bins, &binsa);
+
+    fPointPos = (MPointingPos*)plist->FindObject(AddSerialNumber("MPointingPos"));
+    if (!fPointPos)
+        *fLog << warn << "MPointingPos not found... no derotation." << endl;
+
+    fTime = (MTime*)plist->FindObject(AddSerialNumber("MTime"));
+    if (!fTime)
+        *fLog << warn << "MTime not found... no derotation." << endl;
+
+    fObservatory = (MObservatory*)plist->FindObject(AddSerialNumber("MObservatory"));
+    if (!fObservatory)
+        *fLog << warn << "MObservatory not found... no derotation." << endl;
+
+    // FIXME: Because the pointing position could change we must check
+    // for the current pointing position and add a offset in the
+    // Fill function!
+    fRa  = fPointPos->GetRa();
+    fDec = fPointPos->GetDec();
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the histogram. For details see the code or the class description
+// 
+Bool_t MHFalseSource::Fill(const MParContainer *par, const Stat_t w)
+{
+    const MHillas *hil = dynamic_cast<const MHillas*>(par);
+    if (!hil)
+    {
+        *fLog << err << "MHFalseSource::Fill: No container specified!" << endl;
+        return kFALSE;
+    }
+
+    // Get max radius...
+    const Double_t maxr = 0.98*TMath::Abs(fHist.GetBinCenter(1));
+
+    // Get camera rotation angle
+    Double_t rho = 0;
+    if (fTime && fObservatory && fPointPos)
+        rho = fPointPos->RotationAngle(*fObservatory, *fTime);
+    //if (fPointPos)
+    //    rho = fPointPos->RotationAngle(*fObservatory);
+
+    // Create necessary containers for calculation
+    MSrcPosCam src;
+    MHillasSrc hsrc;
+    hsrc.SetSrcPos(&src);
+
+    // Get number of bins and bin-centers
+    const Int_t nx = fHist.GetNbinsX();
+    const Int_t ny = fHist.GetNbinsY();
+    Axis_t cx[nx];
+    Axis_t cy[ny];
+    fHist.GetXaxis()->GetCenter(cx);
+    fHist.GetYaxis()->GetCenter(cy);
+
+    for (int ix=0; ix<nx; ix++)
+    {
+        for (int iy=0; iy<ny; iy++)
+        {
+            // check distance... to get a circle plot
+            if (TMath::Hypot(cx[ix], cy[iy])>maxr)
+                continue;
+
+            // rotate center of bin
+            // precalculation of sin/cos doesn't accelerate
+            TVector2 v(cx[ix], cy[iy]);
+            if (rho!=0)
+                v=v.Rotate(rho);
+
+            // convert degrees to millimeters
+            v *= 1./fMm2Deg;
+            src.SetXY(v);
+
+            // Source dependant hillas parameters
+            if (!hsrc.Calc(hil))
+            {
+                *fLog << warn << "Calculation of MHillasSrc failed for x=" << cx[ix] << " y=" << cy[iy] << endl;
+                return kFALSE;
+            }
+
+            // FIXME: This should be replaced by an external MFilter
+            //        and/or MTaskList
+            // Source dependant distance cut
+            if (fMinDist>0 && hsrc.GetDist()*fMm2Deg<fMinDist)
+                continue;
+            if (fMaxDist>0 && hsrc.GetDist()*fMm2Deg>fMaxDist)
+                continue;
+
+            if (fMaxLD>0 && hil->GetLength()>fMaxLD*hsrc.GetDist())
+                continue;
+            if (fMinLD>0 && hil->GetLength()<fMinLD*hsrc.GetDist())
+                continue;
+
+            // Fill histogram
+            const Double_t alpha = hsrc.GetAlpha();
+            fHist.Fill(cx[ix], cy[iy], TMath::Abs(alpha), w);
+        }
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Create projection for off data, taking sum of bin contents of
+// range (fBgMean-fAlphaCut/2, fBgMean+fAlphaCut) Making sure to take
+// the same number of bins than for on-data
+//
+void MHFalseSource::ProjectOff(TH2D *h2, TH2D *all)
+{
+    TAxis &axe = *fHist.GetZaxis();
+
+    // Find range to cut (left edge and width)
+    const Int_t f = axe.FindBin(fBgMean-fAlphaCut/2);
+    const Int_t l = axe.FindBin(fAlphaCut)+f-1;
+
+    axe.SetRange(f, l);
+    const Float_t cut1 = axe.GetBinLowEdge(f);
+    const Float_t cut2 = axe.GetBinUpEdge(l);
+    h2->SetTitle(Form("Distribution of %.1f\\circ<|\\alpha|<%.1f\\circ in x,y", cut1, cut2));
+
+    // Get projection for range
+    TH2D *p = (TH2D*)fHist.Project3D("yx_off");
+
+    // Reset range
+    axe.SetRange(0,9999);
+
+    // Move contents from projection to h2
+    h2->Reset();
+    h2->Add(p, all->GetMaximum());
+    h2->Divide(all);
+
+    // Delete p
+    delete p;
+
+    // Set Minimum as minimum value Greater Than 0
+    h2->SetMinimum(GetMinimumGT(*h2));
+}
+
+// --------------------------------------------------------------------------
+//
+// Create projection for on data, taking sum of bin contents of
+// range (0, fAlphaCut)
+//
+void MHFalseSource::ProjectOn(TH2D *h3, TH2D *all)
+{
+    TAxis &axe = *fHist.GetZaxis();
+
+    // Find range to cut
+    axe.SetRangeUser(0, fAlphaCut);
+    const Float_t cut = axe.GetBinUpEdge(axe.GetLast());
+    h3->SetTitle(Form("Distribution of |\\alpha|<%.1f\\circ in x,y", cut));
+
+    // Get projection for range
+    TH2D *p = (TH2D*)fHist.Project3D("yx_on");
+
+    // Reset range
+    axe.SetRange(0,9999);
+
+    // Move contents from projection to h3
+    h3->Reset();
+    h3->Add(p, all->GetMaximum());
+    h3->Divide(all);
+
+    // Delete p
+    delete p;
+
+    // Set Minimum as minimum value Greater Than 0
+    h3->SetMinimum(GetMinimumGT(*h3));
+}
+
+// --------------------------------------------------------------------------
+//
+// Create projection for all data, taking sum of bin contents of
+// range (0, 90) - corresponding to the number of entries in this slice.
+//
+void MHFalseSource::ProjectAll(TH2D *h3)
+{
+    h3->SetTitle("Number of entries");
+
+    // Get projection for range
+    TH2D *p = (TH2D*)fHist.Project3D("yx_all");
+
+    // Move contents from projection to h3
+    h3->Reset();
+    h3->Add(p);
+    delete p;
+
+    // Set Minimum as minimum value Greater Than 0
+    h3->SetMinimum(GetMinimumGT(*h3));
+}
+
+// --------------------------------------------------------------------------
+//
+// Update the projections and paint them
+//
+void MHFalseSource::Paint(Option_t *opt)
+{
+    // Set pretty color palette
+    gStyle->SetPalette(1, 0);
+
+    TVirtualPad *padsave = gPad;
+
+    TH1D* h1;
+    TH2D* h0;
+    TH2D* h2;
+    TH2D* h3;
+    TH2D* h4;
+    TH2D* h5;
+
+    // Update projection of all-events
+    padsave->GetPad(2)->cd(3);
+    if ((h0 = (TH2D*)gPad->FindObject("Alpha_yx_all")))
+        ProjectAll(h0);
+
+    // Update projection of on-events
+    padsave->GetPad(1)->cd(1);
+    if ((h3 = (TH2D*)gPad->FindObject("Alpha_yx_on")))
+        ProjectOn(h3, h0);
+
+    // Update projection of off-events
+    padsave->GetPad(1)->cd(3);
+    if ((h2 = (TH2D*)gPad->FindObject("Alpha_yx_off")))
+        ProjectOff(h2, h0);
+
+    padsave->GetPad(2)->cd(2);
+    if ((h5 = (TH2D*)gPad->FindObject("Alpha_yx_diff")))
+    {
+        h5->Add(h3, h2, -1);
+        MakeSymmetric(h5);
+    }
+
+    // Update projection of significance
+    padsave->GetPad(1)->cd(2);
+    if (h2 && h3 && (h4 = (TH2D*)gPad->FindObject("Alpha_yx_sig")))
+    {
+        const Int_t nx = h4->GetXaxis()->GetNbins();
+        const Int_t ny = h4->GetYaxis()->GetNbins();
+        //const Int_t nr = nx*nx + ny*ny;
+
+        Int_t maxx=nx/2;
+        Int_t maxy=ny/2;
+
+        Int_t max = h4->GetBin(nx, ny);
+
+        for (int ix=1; ix<=nx; ix++)
+            for (int iy=1; iy<=ny; iy++)
+            {
+                const Int_t n = h4->GetBin(ix, iy);
+
+                const Double_t s = h3->GetBinContent(n);
+                const Double_t b = h2->GetBinContent(n);
+
+                const Double_t sig = SignificanceLiMa(s, b);
+
+                h4->SetBinContent(n, sig);
+
+                if (sig>h4->GetBinContent(max) && sig>0/* && (ix-nx/2)*(ix-nx/2)+(iy-ny/2)*(iy-ny/2)<nr*nr/9*/)
+                {
+                    max = n;
+                    maxx=ix;
+                    maxy=iy;
+                }
+            }
+
+        MakeSymmetric(h4);
+
+        // Update projection of 'the best alpha-plot'
+        padsave->GetPad(2)->cd(1);
+        if ((h1 = (TH1D*)gPad->FindObject("Alpha")) && max>0)
+        {
+            const Double_t x = h4->GetXaxis()->GetBinCenter(maxx);
+            const Double_t y = h4->GetYaxis()->GetBinCenter(maxy);
+            const Double_t s = h4->GetBinContent(max);
+
+            // This is because a 3D histogram x and y are vice versa
+            // Than for their projections
+            TH1 *h = fHist.ProjectionZ("Alpha", maxx, maxx, maxy, maxy);
+            h->SetTitle(Form("Distribution of \\alpha for x=%.2f y=%.2f (\\sigma_{max}=%.1f)", x, y, s));
+        }
+    }
+
+    gPad = padsave;
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the MAstroCatalog corresponding to fRa, fDec. The limiting magnitude
+// is set to 9, while the fov is equal to the current fov of the false
+// source plot.
+//
+TObject *MHFalseSource::GetCatalog()
+{
+    const Double_t maxr = 0.98*TMath::Abs(fHist.GetBinCenter(1));
+
+    // Create catalog...
+    MAstroCatalog stars;
+    stars.SetLimMag(9);
+    stars.SetGuiActive(kFALSE);
+    stars.SetRadiusFOV(maxr);
+    stars.SetRaDec(fRa*TMath::DegToRad()*15, fDec*TMath::DegToRad());
+    stars.ReadBSC("bsc5.dat");
+
+    TObject *o = (MAstroCatalog*)stars.Clone();
+    o->SetBit(kCanDelete);
+
+    return o;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw the histogram
+//
+void MHFalseSource::Draw(Option_t *opt)
+{
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    AppendPad("");
+
+    pad->Divide(1, 2, 0, 0.03);
+
+    TObject *catalog = GetCatalog();
+
+    // Initialize upper part
+    pad->cd(1);
+    gPad->SetBorderMode(0);
+    gPad->Divide(3, 1);
+
+    // PAD #1
+    pad->GetPad(1)->cd(1);
+    gPad->SetBorderMode(0);
+    fHist.GetZaxis()->SetRangeUser(0,fAlphaCut);
+    TH1 *h3 = fHist.Project3D("yx_on");
+    fHist.GetZaxis()->SetRange(0,9999);
+    h3->SetDirectory(NULL);
+    h3->SetXTitle(fHist.GetXaxis()->GetTitle());
+    h3->SetYTitle(fHist.GetYaxis()->GetTitle());
+    h3->Draw("colz");
+    h3->SetBit(kCanDelete);
+    catalog->Draw("mirror same");
+
+    // PAD #2
+    pad->GetPad(1)->cd(2);
+    gPad->SetBorderMode(0);
+    fHist.GetZaxis()->SetRange(0,0);
+    TH1 *h4 = fHist.Project3D("yx_sig"); // Do this to get the correct binning....
+    fHist.GetZaxis()->SetRange(0,9999);
+    h4->SetTitle("Significance");
+    h4->SetDirectory(NULL);
+    h4->SetXTitle(fHist.GetXaxis()->GetTitle());
+    h4->SetYTitle(fHist.GetYaxis()->GetTitle());
+    h4->Draw("colz");
+    h4->SetBit(kCanDelete);
+    catalog->Draw("mirror same");
+
+    // PAD #3
+    pad->GetPad(1)->cd(3);
+    gPad->SetBorderMode(0);
+    fHist.GetZaxis()->SetRangeUser(fBgMean-fAlphaCut/2, fBgMean+fAlphaCut/2);
+    TH1 *h2 = fHist.Project3D("yx_off");
+    h2->SetDirectory(NULL);
+    h2->SetXTitle(fHist.GetXaxis()->GetTitle());
+    h2->SetYTitle(fHist.GetYaxis()->GetTitle());
+    h2->Draw("colz");
+    h2->SetBit(kCanDelete);
+    catalog->Draw("mirror same");
+
+    // Initialize lower part
+    pad->cd(2);
+    gPad->SetBorderMode(0);
+    gPad->Divide(3, 1);
+
+    // PAD #4
+    pad->GetPad(2)->cd(1);
+    gPad->SetBorderMode(0);
+    TH1 *h1 = fHist.ProjectionZ("Alpha");
+    h1->SetDirectory(NULL);
+    h1->SetTitle("Distribution of \\alpha");
+    h1->SetXTitle(fHist.GetZaxis()->GetTitle());
+    h1->SetYTitle("Counts");
+    h1->Draw(opt);
+    h1->SetBit(kCanDelete);
+
+    // PAD #5
+    pad->GetPad(2)->cd(2);
+    gPad->SetBorderMode(0);
+    TH1 *h5 = (TH1*)h3->Clone("Alpha_yx_diff");
+    h5->Add(h2, -1);
+    h5->SetTitle("Difference of on- and off-distribution");
+    h5->SetDirectory(NULL);
+    h5->Draw("colz");
+    h5->SetBit(kCanDelete);
+    catalog->Draw("mirror same");
+
+    // PAD #6
+    pad->GetPad(2)->cd(3);
+    gPad->SetBorderMode(0);
+    TH1 *h0 = fHist.Project3D("yx_all");
+    h0->SetDirectory(NULL);
+    h0->SetXTitle(fHist.GetXaxis()->GetTitle());
+    h0->SetYTitle(fHist.GetYaxis()->GetTitle());
+    h0->Draw("colz");
+    h0->SetBit(kCanDelete);
+    catalog->Draw("mirror same");
+}
+
+// --------------------------------------------------------------------------
+//
+// Everything which is in the main pad belongs to this class!
+//
+Int_t MHFalseSource::DistancetoPrimitive(Int_t px, Int_t py)
+{
+    return 0;
+}
+
+// --------------------------------------------------------------------------
+//
+// Set all sub-pads to Modified()
+//
+void MHFalseSource::Modified()
+{
+    if (!gPad)
+        return;
+
+    TVirtualPad *padsave = gPad;
+    padsave->Modified();
+    padsave->GetPad(1)->cd(1);
+    gPad->Modified();
+    padsave->GetPad(1)->cd(3);
+    gPad->Modified();
+    padsave->GetPad(2)->cd(1);
+    gPad->Modified();
+    padsave->GetPad(2)->cd(2);
+    gPad->Modified();
+    padsave->GetPad(2)->cd(3);
+    gPad->Modified();
+    gPad->cd();
+}
+
+// --------------------------------------------------------------------------
+//
+// This is a preliminary implementation of a alpha-fit procedure for
+// all possible source positions. It will be moved into its own
+// more powerfull class soon.
+//
+// The fit function is "gaus(0)+pol2(3)" which is equivalent to:
+//   [0]*exp(-0.5*((x-[1])/[2])^2) + [3] + [4]*x + [5]*x^2
+// or
+//   A*exp(-0.5*((x-mu)/sigma)^2) + a + b*x + c*x^2
+//
+// Parameter [1] is fixed to 0 while the alpha peak should be
+// symmetric around alpha=0.
+//
+// Parameter [4] is fixed to 0 because the first derivative at
+// alpha=0 should be 0, too.
+//
+// In a first step the background is fitted between bgmin and bgmax,
+// while the parameters [0]=0 and [2]=1 are fixed.
+//
+// In a second step the signal region (alpha<sigmax) is fittet using
+// the whole function with parameters [1], [3], [4] and [5] fixed.
+//
+// The number of excess and background events are calculated as
+//   s = int(0, sigint, gaus(0)+pol2(3))
+//   b = int(0, sigint,         pol2(3))
+//
+// The Significance is calculated using the Significance() member
+// function.
+//
+void MHFalseSource::FitSignificance(Float_t sigint, Float_t sigmax, Float_t bgmin, Float_t bgmax, Byte_t polynom)
+{
+    TObject *catalog = GetCatalog();
+
+    TH1D h0a("A",          "", 50,   0, 4000);
+    TH1D h4a("chisq1",     "", 50,   0,   35);
+    //TH1D h5a("prob1",      "", 50,   0,  1.1);
+    TH1D h6("signifcance", "", 50, -20,   20);
+
+    TH1D h1("mu",    "Parameter \\mu",    50,   -1,    1);
+    TH1D h2("sigma", "Parameter \\sigma", 50,    0,   90);
+    TH1D h3("b",     "Parameter b",       50, -0.1,  0.1);
+
+    TH1D h0b("a",         "Parameter a (red), A (blue)", 50, 0, 4000);
+    TH1D h4b("\\chi^{2}", "\\chi^{2} (red, green) / significance (black)", 50, 0, 35);
+    //TH1D h5b("prob",      "Fit probability: Bg(red), F(blue)", 50, 0, 1.1);
+
+    h0a.SetLineColor(kBlue);
+    h4a.SetLineColor(kBlue);
+    //h5a.SetLineColor(kBlue);
+    h0b.SetLineColor(kRed);
+    h4b.SetLineColor(kRed);
+    //h5b.SetLineColor(kRed);
+
+    TH1 *hist  = fHist.Project3D("yx_fit");
+    hist->SetDirectory(0);
+    TH1 *hists = fHist.Project3D("yx_fit");
+    hists->SetDirectory(0);
+    TH1 *histb = fHist.Project3D("yx_fit");
+    histb->SetDirectory(0);
+    hist->Reset();
+    hists->Reset();
+    histb->Reset();
+    hist->SetNameTitle("Significance",
+                       Form("Fit Region: Signal<%.1f\\circ, %.1f\\circ<Bg<%.1f\\circ",
+                            sigmax, bgmin, bgmax));
+    hists->SetName("Excess");
+    histb->SetName("Background");
+    hist->SetXTitle(fHist.GetXaxis()->GetTitle());
+    hists->SetXTitle(fHist.GetXaxis()->GetTitle());
+    histb->SetXTitle(fHist.GetXaxis()->GetTitle());
+    hist->SetYTitle(fHist.GetYaxis()->GetTitle());
+    hists->SetYTitle(fHist.GetYaxis()->GetTitle());
+    histb->SetYTitle(fHist.GetYaxis()->GetTitle());
+
+    const Double_t w = fHist.GetZaxis()->GetBinWidth(1);
+
+    //                      xmin, xmax, npar
+    //TF1 func("MyFunc", fcn, 0, 90, 6);
+    // Implementing the function yourself is only about 5% faster
+    TF1 func("", Form("gaus(0) + pol%d(3)", polynom), 0, 90);
+    //TF1 func("", Form("[0]*(TMath::Gaus(x, [1], [2])+TMath::Gaus(x, -[1], [2]))+pol%d(3)", polynom), 0, 90);
+    TArrayD maxpar(func.GetNpar());
+
+    /*  func.SetParName(0, "A");
+     *  func.SetParName(1, "mu");
+     *  func.SetParName(2, "sigma");
+    */
+
+    func.FixParameter(1, 0);
+    func.FixParameter(4, 0);
+    func.SetParLimits(2, 0, 90);
+    func.SetParLimits(3, -1, 1);
+
+    const Int_t nx = hist->GetXaxis()->GetNbins();
+    const Int_t ny = hist->GetYaxis()->GetNbins();
+    //const Int_t nr = nx*nx+ny*ny;
+
+    Double_t maxalpha0=0;
+    Double_t maxs=3;
+
+    Int_t maxx=0;
+    Int_t maxy=0;
+
+    TStopwatch clk;
+    clk.Start();
+
+    *fLog << inf;
+    *fLog << "Signal fit:     alpha < " << sigmax << endl;
+    *fLog << "Integration:    alpha < " << sigint << endl;
+    *fLog << "Background fit: " << bgmin << " < alpha < " << bgmax << endl;
+    *fLog << "Polynom order:  " << (int)polynom << endl;
+    *fLog << "Fitting False Source Plot..." << flush;
+
+    TH1 *h0 = fHist.Project3D("yx_entries");
+    Float_t entries = h0->GetMaximum();
+    delete h0;
+
+    TH1 *h=0;
+    for (int ix=1; ix<=nx; ix++)
+        for (int iy=1; iy<=ny; iy++)
+        {
+            // This is because a 3D histogram x and y are vice versa
+            // Than for their projections
+            h = fHist.ProjectionZ("AlphaFit", ix, ix, iy, iy);
+
+            const Double_t alpha0 = h->GetBinContent(1);
+
+            // Check for the regios which is not filled...
+            if (alpha0==0)
+                continue;
+
+            h->Scale(entries/h->GetEntries());
+
+            if (alpha0>maxalpha0)
+                maxalpha0=alpha0;
+
+            // First fit a polynom in the off region
+            func.FixParameter(0, 0);
+            func.FixParameter(2, 1);
+            func.ReleaseParameter(3);
+
+            for (int i=5; i<func.GetNpar(); i++)
+                func.ReleaseParameter(i);
+
+            h->Fit(&func, "N0Q", "", bgmin, bgmax);
+
+            h4a.Fill(func.GetChisquare());
+            //h5a.Fill(func.GetProb());
+
+            //func.SetParLimits(0, 0.5*h->GetBinContent(1), 1.5*h->GetBinContent(1));
+            //func.SetParLimits(2, 5, 90);
+
+            func.ReleaseParameter(0);
+            //func.ReleaseParameter(1);
+            func.ReleaseParameter(2);
+            func.FixParameter(3, func.GetParameter(3));
+            for (int i=5; i<func.GetNpar(); i++)
+                func.FixParameter(i, func.GetParameter(i));
+
+            // Do not allow signals smaller than the background
+            const Double_t A  = alpha0-func.GetParameter(3);
+            const Double_t dA = TMath::Abs(A);
+            func.SetParLimits(0, -dA*4, dA*4);
+            func.SetParLimits(2, 0, 90);
+
+            // Now fit a gaus in the on region on top of the polynom
+            func.SetParameter(0, A);
+            func.SetParameter(2, sigmax*0.75);
+
+            h->Fit(&func, "N0Q", "", 0, sigmax);
+
+            TArrayD p(func.GetNpar(), func.GetParameters());
+
+            // Fill results into some histograms
+            h0a.Fill(p[0]);
+            h0b.Fill(p[3]);
+            h1.Fill(p[1]);
+            h2.Fill(p[2]);
+            if (polynom>1)
+                h3.Fill(p[5]);
+            h4b.Fill(func.GetChisquare());
+            //h5b.Fill(func.GetProb());
+
+            // Implementing the integral as analytical function
+            // gives the same result in the order of 10e-5
+            // and it is not faster at all...
+            //const Bool_t ok = /*p[0]>=0 && /*p[0]<alpha0*2 &&*/ p[2]>1.75;// && p[2]<88.5;
+            /*
+            if (p[0]<-fabs(alpha0-p[3])*7 && p[2]<alphaw/3)
+            {
+                func.SetParameter(0, alpha0-p[3]);
+                cout << p[2] << " " << p[0] << " " << alpha0-p[3] << endl;
+            }
+            */
+
+            // The fitted function returned units of
+            // counts bin binwidth. To get the correct number
+            // of events we must adapt the functions by dividing
+            // the result of the integration by the bin-width
+            const Double_t s = func.Integral(0, sigint)/w;
+
+            func.SetParameter(0, 0);
+            func.SetParameter(2, 1);
+
+            const Double_t b   = func.Integral(0, sigint)/w;
+            const Double_t sig = SignificanceLiMa(s, b);
+
+            const Int_t n = hist->GetBin(ix, iy);
+            hists->SetBinContent(n, s-b);
+            histb->SetBinContent(n, b);
+
+            hist->SetBinContent(n, sig);
+            if (sig!=0)
+                h6.Fill(sig);
+
+            if (sig>maxs/* && (ix-nx/2)*(ix-nx/2)+(iy-ny/2)*(iy-ny/2)<nr*nr/9*/)
+            {
+                maxs = sig;
+                maxx = ix;
+                maxy = iy;
+                maxpar = p;
+            }
+        }
+
+    *fLog << inf << "done." << endl;
+
+    h0a.GetXaxis()->SetRangeUser(0, maxalpha0*1.5);
+    h0b.GetXaxis()->SetRangeUser(0, maxalpha0*1.5);
+
+    hists->SetTitle(Form("Excess events for \\alpha<%.0f\\circ (N_{max}=%d)", sigint, (int)hists->GetMaximum()));
+    histb->SetTitle(Form("Background events for \\alpha<%.0f\\circ", sigint));
+
+    //hists->SetMinimum(GetMinimumGT(*hists));
+    histb->SetMinimum(GetMinimumGT(*histb));
+
+    MakeSymmetric(hists);
+    MakeSymmetric(hist);
+
+    clk.Stop();
+    clk.Print("m");
+
+    TCanvas *c=new TCanvas;
+
+    gStyle->SetPalette(1, 0);
+
+    c->Divide(3,2, 0, 0);
+    c->cd(1);
+    gPad->SetBorderMode(0);
+    hists->Draw("colz");
+    hists->SetBit(kCanDelete);
+    catalog->Draw("mirror same");
+    c->cd(2);
+    gPad->SetBorderMode(0);
+    hist->Draw("colz");
+    hist->SetBit(kCanDelete);
+    catalog->Draw("mirror same");
+    c->cd(3);
+    gPad->SetBorderMode(0);
+    histb->Draw("colz");
+    histb->SetBit(kCanDelete);
+    catalog->Draw("mirror same");
+    c->cd(4);
+    gPad->Divide(1,3, 0, 0);
+    TVirtualPad *p=gPad;
+    p->SetBorderMode(0);
+    p->cd(1);
+    gPad->SetBorderMode(0);
+    h0b.DrawCopy();
+    h0a.DrawCopy("same");
+    p->cd(2);
+    gPad->SetBorderMode(0);
+    h3.DrawCopy();
+    p->cd(3);
+    gPad->SetBorderMode(0);
+    h2.DrawCopy();
+    c->cd(6);
+    gPad->Divide(1,2, 0, 0);
+    TVirtualPad *q=gPad;
+    q->SetBorderMode(0);
+    q->cd(1);
+    gPad->SetBorderMode(0);
+    gPad->SetBorderMode(0);
+    h4b.DrawCopy();
+    h4a.DrawCopy("same");
+    h6.DrawCopy("same");
+    q->cd(2);
+    gPad->SetBorderMode(0);
+    //h5b.DrawCopy();
+    //h5a.DrawCopy("same");
+    c->cd(5);
+    gPad->SetBorderMode(0);
+    if (maxx>0 && maxy>0)
+    {
+        const char *title = Form(" \\alpha for x=%.2f y=%.2f (\\sigma_{max}=%.1f) ",
+                                 hist->GetXaxis()->GetBinCenter(maxx),
+                                 hist->GetYaxis()->GetBinCenter(maxy), maxs);
+
+        TH1 *result = fHist.ProjectionZ("AlphaFit", maxx, maxx, maxy, maxy);
+        result->Scale(entries/h->GetEntries());
+
+        result->SetDirectory(NULL);
+        result->SetNameTitle("Result \\alpha", title);
+        result->SetBit(kCanDelete);
+        result->SetXTitle("\\alpha [\\circ]");
+        result->SetYTitle("Counts");
+        result->Draw();
+
+        TF1 f1("", func.GetExpFormula(), 0, 90);
+        TF1 f2("", func.GetExpFormula(), 0, 90);
+        f1.SetParameters(maxpar.GetArray());
+        f2.SetParameters(maxpar.GetArray());
+        f2.FixParameter(0, 0);
+        f2.FixParameter(1, 0);
+        f2.FixParameter(2, 1);
+        f1.SetLineColor(kGreen);
+        f2.SetLineColor(kRed);
+
+        f2.DrawCopy("same");
+        f1.DrawCopy("same");
+
+        TPaveText *leg = new TPaveText(0.35, 0.10, 0.90, 0.35, "brNDC");
+        leg->SetBorderSize(1);
+        leg->SetTextSize(0.04);
+        leg->AddText(0.5, 0.82, Form("A * exp(-(\\frac{x-\\mu}{\\sigma})^{2}/2) + pol%d", polynom))->SetTextAlign(22);
+        //leg->AddText(0.5, 0.82, "A * exp(-(\\frac{x-\\mu}{\\sigma})^{2}/2) + b*x^{2} + a")->SetTextAlign(22);
+        leg->AddLine(0, 0.65, 0, 0.65);
+        leg->AddText(0.06, 0.54, Form("A=%.2f", maxpar[0]))->SetTextAlign(11);
+        leg->AddText(0.06, 0.34, Form("\\sigma=%.2f", maxpar[2]))->SetTextAlign(11);
+        leg->AddText(0.06, 0.14, Form("\\mu=%.2f (fix)", maxpar[1]))->SetTextAlign(11);
+        leg->AddText(0.60, 0.54, Form("a=%.2f", maxpar[3]))->SetTextAlign(11);
+        leg->AddText(0.60, 0.34, Form("b=%.2f (fix)", maxpar[4]))->SetTextAlign(11);
+        if (polynom>1)
+            leg->AddText(0.60, 0.14, Form("c=%.2f", maxpar[5]))->SetTextAlign(11);
+        leg->SetBit(kCanDelete);
+        leg->Draw();
+
+        q->cd(2);
+
+        TGraph *g = new TGraph;
+        g->SetPoint(0, 0, 0);
+
+        Int_t max=0;
+        Float_t maxsig=0;
+        for (int i=1; i<89; i++)
+        {
+            const Double_t s = f1.Integral(0, (float)i)/w;
+            const Double_t b = f2.Integral(0, (float)i)/w;
+
+            const Double_t sig = SignificanceLiMa(s, b);
+
+            g->SetPoint(g->GetN(), i, sig);
+
+            if (sig>maxsig)
+            {
+                max = i;
+                maxsig = sig;
+            }
+        }
+
+        g->SetNameTitle("SigVs\\alpha", "Significance vs \\alpha");
+        g->GetHistogram()->SetXTitle("\\alpha_{0} [\\circ]");
+        g->GetHistogram()->SetYTitle("Significance");
+        g->SetBit(kCanDelete);
+        g->Draw("AP");
+
+        leg = new TPaveText(0.35, 0.10, 0.90, 0.25, "brNDC");
+        leg->SetBorderSize(1);
+        leg->SetTextSize(0.1);
+        leg->AddText(Form("\\sigma_{max}=%.1f at \\alpha_{max}=%d\\circ", maxsig, max));
+        leg->SetBit(kCanDelete);
+        leg->Draw();
+    }
+}
Index: /tags/Mars_V0-8-5/Mars/mhist/MHFalseSource.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHFalseSource.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHFalseSource.h	(revision 9661)
@@ -0,0 +1,86 @@
+#ifndef MARS_MHFalseSource
+#define MARS_MHFalseSource
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+#ifndef ROOT_TH3
+#include <TH3.h>
+#endif
+
+class TH2D;
+
+class MParList;
+class MTime;
+class MPointingPos;
+class MObservatory;
+
+class MHFalseSource : public MH
+{
+private:
+    MTime         *fTime;        //! container to take the event time from
+    MPointingPos  *fPointPos;    //! container to take pointing position from
+    MObservatory  *fObservatory; //! conteiner to take observatory location from
+
+    Float_t fMm2Deg;             // conversion factor for display in degrees
+
+    Float_t fAlphaCut;           // Alpha cut
+    Float_t fBgMean;             // Background mean
+
+    Float_t fMinDist;            // Min dist
+    Float_t fMaxDist;            // Max dist
+
+    Float_t fMinLD;              // Minimum distance in percent of dist
+    Float_t fMaxLD;              // Maximum distance in percent of dist
+
+    TH3D    fHist;               // Alpha vs. x and y
+
+    Double_t fRa;
+    Double_t fDec;
+
+    Int_t DistancetoPrimitive(Int_t px, Int_t py);
+    void Modified();
+
+    void ProjectAll(TH2D *h);
+    void ProjectOff(TH2D *h, TH2D *all);
+    void ProjectOn(TH2D *h, TH2D *all);
+
+    TObject *GetCatalog();
+
+    void MakeSymmetric(TH1 *h);
+
+public:
+    MHFalseSource(const char *name=NULL, const char *title=NULL);
+
+    Bool_t SetupFill(const MParList *pList);
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+
+    TH1 *GetHistByName(const TString name) { return &fHist; }
+
+    void FitSignificance(Float_t sigint=15, Float_t sigmax=70, Float_t bgmin=40, Float_t bgmax=70, Byte_t polynom=1); //*MENU*
+    void FitSignificanceStd() { FitSignificance(); } //*MENU*
+
+    void SetMinDist(Float_t dist) { fMinDist = dist; } // Absolute minimum distance
+    void SetMaxDist(Float_t dist) { fMaxDist = dist; } // Absolute maximum distance
+    void SetMinLD(Float_t ratio)  { fMinLD = ratio; }  // Minimum ratio between length/dist
+    void SetMaxLD(Float_t ratio)  { fMaxLD = ratio; }  // Maximum ratio between length/dist
+
+    void SetAlphaCut(Float_t alpha); //*MENU*
+    void SetAlphaPlus5()  { SetAlphaCut(fAlphaCut+5); } //*MENU*
+    void SetAlphaMinus5() { SetAlphaCut(fAlphaCut-5); } //*MENU*
+
+    void SetBgMean(Float_t alpha); //*MENU*
+    void SetBgMeanPlus5()  { SetBgMean(fBgMean+5); } //*MENU*
+    void SetBgMeanMinus5() { SetBgMean(fBgMean-5); } //*MENU*
+
+    void Paint(Option_t *opt="");
+    void Draw(Option_t *option="");
+
+    static Double_t Significance(Double_t s, Double_t b);
+    static Double_t SignificanceLiMa(Double_t s, Double_t b, Double_t alpha=1);
+
+    ClassDef(MHFalseSource, 1) //3D-histogram in alpha, x and y
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mhist/MHFindSignificance.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHFindSignificance.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHFindSignificance.cc	(revision 9661)
@@ -0,0 +1,2047 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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,  July 2003      <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHFindSignificance
+//
+// determines the significance of a gamma signal in an |alpha| plot
+// 
+//
+// Input : TH1 histogram of |alpha| : with 0 < |alpha| < 90 degrees
+//         alphamin, alphamax :     defining the background region
+//         alphasig           :     defining the signal region for which
+//                                  the significance is calculated
+//         degree : the degree of the polynomial to be fitted to the background
+//                  ( a0 + a1*x + a2*x**2 + a3*x**3 + ...) 
+//
+// Output : 
+//
+//   - polynomial which describes the background in the background region
+//   - the number of events in the signal region (Non)
+//     the number of background events in the signal region (Nbg)
+//   - the number of excess events in the signal region (Nex = Non - Nbg)
+//   - thew effective number of background events (Noff), and gamma :
+//     Nbg = gamma * Noff
+//   - the significance of the gamma signal according to Li & Ma               
+//
+//
+// call member function 'FindSigma' 
+//      to fit the background and to determine the significance  
+//
+// call the member function 'SigmaVsAlpha'
+//      to determine the significance as a function of alphasig
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MHFindSignificance.h"
+
+#include <fstream>
+#include <math.h>
+
+#include <TArrayD.h>
+#include <TArrayI.h>
+#include <TH1.h>
+#include <TF1.h>
+#include <TCanvas.h>
+#include <TFitter.h>
+#include <TMinuit.h>
+#include <TPaveText.h>
+#include <TStyle.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+#include "MMinuitInterface.h"
+
+
+ClassImp(MHFindSignificance);
+
+using namespace std;
+
+const TString MHFindSignificance::gsDefName  = "MHFindSignificance";
+const TString MHFindSignificance::gsDefTitle = "Find Significance in alpha plot";
+
+
+
+// --------------------------------------------------------------------------
+//
+// fcnpoly
+//
+// calculates the chi2 for the fit of the polynomial function 'poly' 
+// to the histogram 'fhist'
+//
+// it is called by CallMinuit() (which is called in FitPolynomial()) 
+//
+// bins of fhist with huge errors are ignored in the calculation of the chi2
+// (the huge errors were set in 'FitPolynomial()')
+//
+
+static void fcnpoly(Int_t &npar, Double_t *gin, Double_t &f, 
+                    Double_t *par, Int_t iflag)
+{
+    TH1 *fhist = (TH1*)gMinuit->GetObjectFit();
+    TF1 *fpoly = fhist->GetFunction("Poly");    
+
+
+    //-------------------------------------------
+
+    Double_t chi2 = 0.0;
+
+    Int_t nbins = fhist->GetNbinsX();
+    Int_t mbins = 0;
+    for (Int_t i=1; i<=nbins; i++)
+    {
+      Double_t content = fhist->GetBinContent(i);
+      Double_t error   = fhist->GetBinError(i);
+      Double_t center  = fhist->GetBinCenter(i);
+
+      //-----------------------------
+      // ignore unwanted points
+      if (error > 1.e19)
+        continue;
+
+      if (content <= 0.0)
+      {
+        gLog << "fcnpoly : bin with zero content; i, content, error = "
+             << i << ",  " << content << ",  " << error << endl;
+        continue;
+      }        
+
+      if (error <= 0.0)
+      {
+        gLog << "fcnpoly : bin with zero error; i, content, error = "
+             << i << ",  " << content << ",  " << error << endl;
+        continue;
+      }        
+
+      //-----------------------------
+      mbins++;
+
+      Double_t fu;
+      fu = fpoly->EvalPar(&center, par);
+
+      // the fitted function must not be negative
+      if (fu <= 0.0)
+      {
+        chi2 = 1.e10;
+        break;
+      }
+
+      Double_t temp = (content - fu) / error;
+      chi2 += temp*temp;
+    }
+
+    //-------------------------------------------
+
+    f = chi2;
+
+    //-------------------------------------------
+    // final calculations
+    //if (iflag == 3)
+    //{
+    //}    
+
+    //-------------------------------------------------------------
+}
+
+
+// --------------------------------------------------------------------------
+//
+// fcnpolygauss
+//
+// calculates the chi2 for the fit of the (polynomial+Gauss) function 
+// 'PolyGauss' to the histogram 'fhist'
+//
+// it is called by CallMinuit() (which is called in FitGaussPoly()) 
+//
+// bins of fhist with huge errors are ignored in the calculation of the chi2
+// (the huge errors were set in 'FitGaussPoly()')
+//
+
+static void fcnpolygauss(Int_t &npar, Double_t *gin, Double_t &f, 
+                         Double_t *par, Int_t iflag)
+{
+    TH1 *fhist = (TH1*)gMinuit->GetObjectFit();
+    TF1 *fpolygauss = fhist->GetFunction("PolyGauss");    
+
+
+    //-------------------------------------------
+
+    Double_t chi2 = 0.0;
+
+    Int_t nbins = fhist->GetNbinsX();
+    Int_t mbins = 0;
+    for (Int_t i=1; i<=nbins; i++)
+    {
+      Double_t content = fhist->GetBinContent(i);
+      Double_t error   = fhist->GetBinError(i);
+      Double_t center  = fhist->GetBinCenter(i);
+
+      //-----------------------------
+      // ignore unwanted points
+      if (error > 1.e19)
+        continue;
+
+      if (content <= 0.0)
+      {
+        gLog << "fcnpolygauss : bin with zero content; i, content, error = "
+             << i << ",  " << content << ",  " << error << endl;
+        continue;
+      }        
+
+      if (error <= 0.0)
+      {
+        gLog << "fcnpolygauss : bin with zero error; i, content, error = "
+             << i << ",  " << content << ",  " << error << endl;
+        continue;
+      }        
+
+      //-----------------------------
+      mbins++;
+
+      Double_t fu;
+      fu = fpolygauss->EvalPar(&center, par);
+
+      // the fitted function must not be negative
+      if (fu <= 0.0)
+      {
+        chi2 = 1.e10;
+        break;
+      }
+
+      Double_t temp = (content - fu) / error;
+      chi2 += temp*temp;
+    }
+
+    //-------------------------------------------
+
+    f = chi2;
+
+    //-------------------------------------------
+    // final calculations
+    //if (iflag == 3)
+    //{
+    //}    
+
+    //-------------------------------------------------------------
+}
+
+
+
+// --------------------------------------------------------------------------
+//
+//  Constructor
+//
+MHFindSignificance::MHFindSignificance(const char *name, const char *title)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+
+    fSigVsAlpha = NULL;
+
+    fPoly   = NULL;
+    fGPoly  = NULL;
+    fGBackg = NULL;
+
+    fHist     = NULL;
+    fHistOrig = NULL;
+
+    // allow rebinning of the alpha plot
+    fRebin = kTRUE;
+
+    // allow reducing the degree of the polynomial
+    fReduceDegree = kTRUE;
+
+    fCanvas = NULL;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Destructor. 
+//
+// =====>  it is not clear why one obtains sometimes a segmentation violation
+//         when the destructor is active     <=======================
+//
+// therefore the 'return'statement
+//
+
+MHFindSignificance::~MHFindSignificance()
+{
+  return;
+
+  *fLog << "destructor of MHFindSignificance is called" << endl;
+ 
+    //delete fHist;
+
+    delete fSigVsAlpha;
+    delete fPoly;
+    delete fGPoly;
+    delete fGBackg;
+    //delete fCanvas;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Set flag fRebin 
+//
+//  if flag is kTRUE rebinning of the alpha plot is allowed
+//
+//
+void MHFindSignificance::SetRebin(Bool_t b)
+{
+  fRebin = b;
+
+  *fLog << "MHFindSignificance::SetRebin; flag fRebin set to " 
+        << (b? "kTRUE" : "kFALSE") << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Set flag fReduceDegree 
+//
+//  if flag is kTRUE reducing of the degree of the polynomial is allowed
+//
+//
+void MHFindSignificance::SetReduceDegree(Bool_t b)
+{
+  fReduceDegree = b;
+
+  *fLog << "MHFindSignificance::SetReduceDegree; flag fReduceDegree set to " 
+        << (b? "kTRUE" : "kFALSE") << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+//  FindSigma
+//
+//  calls FitPolynomial     to fit the background in the background region
+//  calls DetExcess         to determine the number of excess events
+//                          using an extrapolation of the polynomial
+//                          into the signal region
+//  calls SigmaLiMa         to determine the significance of the gamma signal
+//                          in the range |alpha| < alphasig
+//  calls FitGaussPoly      to fit a (polynomial+Gauss) function in the
+//                          whole |alpha| region
+//
+//
+Bool_t MHFindSignificance::FindSigma(TH1 *fhist,  Double_t alphamin,
+       Double_t alphamax, Int_t degree, Double_t alphasig, 
+       Bool_t drawpoly,   Bool_t fitgauss, Bool_t print)
+{
+  //*fLog << "MHFindSignificance::FindSigma;" << endl;
+
+  fHistOrig = fhist;
+
+  fHist = (TH1*)fHistOrig->Clone();
+  fHist->SetName(fhist->GetName());
+  if ( !fHist )
+  {
+    *fLog << "MHFindSignificance::FindSigma; Clone of histogram could not be generated" 
+          << endl;
+    return kFALSE;
+  }
+  
+  fHist->Sumw2();
+  //fHist->SetNameTitle("Alpha", "alpha plot");
+  fHist->SetXTitle("|alpha|  [\\circ]");
+  fHist->SetYTitle("Counts");
+  fHist->UseCurrentStyle();
+
+  fAlphamin = alphamin;
+  fAlphamax = alphamax;
+  fAlphammm = (alphamin+alphamax)/2.0;
+  fDegree   = degree;
+  fAlphasig = alphasig;
+
+  fDraw     = drawpoly;
+  fFitGauss = fitgauss;
+
+
+  //--------------------------------------------
+  // fit a polynomial in the background region
+
+  //*fLog << "MHFindSignificance::FindSigma;  calling FitPolynomial()" << endl;
+  if ( !FitPolynomial() )
+  {
+    *fLog << "MHFindSignificance::FindSigma; FitPolynomial failed"
+	  << endl;  
+    return kFALSE;
+  }
+
+
+  //--------------------------------------------
+  // calculate the number of excess events in the signal region
+
+  //*fLog << "MHFindSignificance::FindSigma;  calling DetExcess()" << endl;
+  if ( !DetExcess() )
+  {
+    *fLog << "MHFindSignificance::FindSigma; DetExcess failed"
+	  << endl;  
+    return kFALSE;
+  }
+
+
+  //--------------------------------------------
+  // calculate the significance of the excess
+
+  //*fLog << "MHFindSignificance::FindSigma;  calling SigmaLiMa()" << endl;
+  Double_t siglima = 0.0;
+  if ( !SigmaLiMa(fNon, fNoff, fGamma, &siglima) )
+  {
+    *fLog << "MHFindSignificance::FindSigma; SigmaLiMa failed"
+	  << endl;  
+    return kFALSE;
+  }
+  fSigLiMa = siglima;
+
+  //--------------------------------------------
+  // calculate the error of the number of excess events
+
+  fdNex = fNex / fSigLiMa;
+
+
+  //--------------------------------------------
+
+  //*fLog << "MHFindSignificance::FindSigma;  calling PrintPoly()" << endl;
+  if (print)
+    PrintPoly();
+
+
+  //--------------------------------------------
+  // fit a (polynomial + Gauss) function
+
+  if (fFitGauss)
+  {
+    //--------------------------------------------------
+    // delete objects from this fit
+    // in order to have independent starting conditions for the next fit
+
+      delete gMinuit;
+      gMinuit = NULL;
+    //--------------------------------------------------
+
+      //*fLog << "MHFindSignificance::FindSigma;  calling FitGaussPoly()" 
+      //      << endl;
+    if ( !FitGaussPoly() )
+    {
+      *fLog << "MHFindSignificance::FindSigma; FitGaussPoly failed"  
+      	    << endl;  
+      return kFALSE;
+    }
+
+    if (print)
+    {
+      //*fLog << "MHFindSignificance::FindSigma;  calling PrintPolyGauss()" 
+      //      << endl;
+      PrintPolyGauss();
+    }
+  }
+
+  //--------------------------------------------------
+  // draw the histogram if requested
+
+  if (fDraw)
+  {
+    //*fLog << "MHFindSignificance::FindSigma;  calling DrawFit()" << endl;
+    if ( !DrawFit() )
+    {
+      *fLog << "MHFindSignificance::FindSigma; DrawFit failed"  
+      	    << endl;  
+      return kFALSE;
+    }
+  }
+
+
+  //--------------------------------------------------
+  // delete objects from this fit
+  // in order to have independent starting conditions for the next fit
+
+    delete gMinuit;
+    gMinuit = NULL;
+  //--------------------------------------------------
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  SigmaVsAlpha  (like FindSigma. However, alphasig is scanned and
+//                 the significance is plotted versus alphasig)
+//
+//  calls FitPolynomial     to fit the background in the background region
+//
+//  scan alphasig; for a given alphasig :
+//       calls DetExcess    to determine the number of excess events
+//       calls SigmaLiMa    to determine the significance of the gamma signal
+//                          in the range fAlphalow < |alpha| < alphasig
+//
+
+Bool_t MHFindSignificance::SigmaVsAlpha(TH1 *fhist,  Double_t alphamin,
+                    Double_t alphamax, Int_t degree, Bool_t print)
+{
+  //*fLog << "MHFindSignificance::SigmaVsAlpha;" << endl;
+
+  fHistOrig = fhist;
+
+  fHist = (TH1*)fHistOrig->Clone();
+  fHist->SetName(fhist->GetName());
+  fHist->Sumw2();
+  //fHist->SetNameTitle("alpha", "alpha plot");
+  fHist->SetXTitle("|alpha|  [\\circ]");
+  fHist->SetYTitle("Counts");
+  fHist->UseCurrentStyle();
+
+  fAlphamin = alphamin;
+  fAlphamax = alphamax;
+  fAlphammm = (alphamin+alphamax)/2.0;
+  fDegree   = degree;
+
+
+  //--------------------------------------------
+  // fit a polynomial in the background region
+
+  //*fLog << "MHFindSignificance::SigmaVsAlpha  calling FitPolynomial()" 
+  //      << endl;
+  if ( !FitPolynomial() )  
+    {
+      *fLog << "MHFindSignificance::SigmaVsAlpha;  FitPolynomial() failed" 
+            << endl;
+      return kFALSE;
+    }
+
+
+  //--------------------------------------------
+  // loop over different signal regions
+
+  Int_t    nsteps    =  15;
+
+  fSigVsAlpha = new TH1D("SigVsAlpha","Sigma vs Alpha", nsteps, 0.0, alphamin);
+  fSigVsAlpha->SetXTitle("upper edge of signal region in |alpha|  [\\circ]");
+  fSigVsAlpha->SetYTitle("Significance of gamma signal");
+
+  for (Int_t i=1; i<=nsteps; i++)
+  {
+    fAlphasig = fSigVsAlpha->GetBinCenter(i);
+
+    if ( !DetExcess() )
+    {
+      *fLog << "MHFindSignificance::SigmaVsAlpha;  DetExcess() failed" << endl;
+      continue;
+    }
+
+    Double_t siglima = 0.0;
+    if ( !SigmaLiMa(fNon, fNoff, fGamma, &siglima) )
+    {
+      *fLog << "MHFindSignificance::SigmaVsAlpha;  SigmaLiMa() failed" << endl;
+      continue;
+    }
+
+    fdNex = fNex / siglima;
+    fSigVsAlpha->SetBinContent(i, siglima);
+
+    if (print)
+      PrintPoly();
+  }
+
+  //--------------------------------------------
+  // plot significance versus alphasig
+ 
+  TCanvas *ccc = new TCanvas("SigVsAlpha", "Sigma vs Alpha", 600, 600);
+ 
+  gROOT->SetSelectedPad(NULL);
+  gStyle->SetPadLeftMargin(0.05);
+
+  ccc->cd();
+  fSigVsAlpha->DrawCopy();
+
+  ccc->Modified();
+  ccc->Update();
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  FitPolynomial
+//
+//  - create a clone 'fHist' of the |alpha| distribution 'fHistOrig'
+//  - fit a polynomial of degree 'fDegree' to the alpha distribution 
+//    'fHist' in the region alphamin < |alpha| < alphamax
+//
+//  in pathological cases the histogram is rebinned before fitting
+//     (this is done only if fRebin is kTRUE)
+//
+//  if the highest coefficient of the polynomial is compatible with zero
+//     the fit is repeated with a polynomial of lower degree
+//     (this is done only if fReduceDegree is kTRUE)
+//
+//
+Bool_t MHFindSignificance::FitPolynomial()
+{
+  //--------------------------------------------------
+  // check the histogram :
+  //       - calculate initial values of the parameters
+  //       - check for bins with zero entries
+  //       - set minimum errors
+  //       - save the original errors
+  //       - set errors huge outside the fit range
+  //         (in 'fcnpoly' points with huge errors will be ignored)
+
+
+  Double_t dummy = 1.e20;
+
+  Double_t mean;
+  Double_t rms;
+  Double_t nclose;
+  Double_t nfar;
+  Double_t a2init = 0.0;
+  TArrayD  saveError;
+
+  Int_t nbins;
+  Int_t nrebin = 1;
+
+  //----------------   start while loop for rebinning   -----------------
+  while(1)
+  {
+
+  fNzero   = 0;
+  fMbins   = 0;
+  fMlow    = 0;
+  fNbgtot  = 0.0;
+
+  fAlphami =  10000.0;
+  fAlphamm =  10000.0;
+  fAlphama = -10000.0;
+
+  mean   = 0.0;
+  rms    = 0.0;
+  nclose = 0.0;
+  nfar   = 0.0;
+
+  nbins = fHist->GetNbinsX();
+  saveError.Set(nbins);
+
+  for (Int_t i=1; i<=nbins; i++)
+  {
+    saveError[i-1] = fHist->GetBinError(i);
+
+    // bin should be completely contained in the fit range
+    // (fAlphamin, fAlphamax)
+    Double_t  xlo = fHist->GetBinLowEdge(i);
+    Double_t  xup = fHist->GetBinLowEdge(i+1);
+
+    if ( xlo >= fAlphamin-fEps  &&  xlo <= fAlphamax+fEps  &&
+	 xup >= fAlphamin-fEps  &&  xup <= fAlphamax+fEps     )
+    {
+      fMbins++;
+
+      if ( xlo < fAlphami )
+        fAlphami = xlo;
+
+      if ( xup > fAlphama )
+        fAlphama = xup;
+
+      Double_t content = fHist->GetBinContent(i);
+      fNbgtot += content;
+
+      mean += content;
+      rms  += content*content;
+
+      // count events in low-alpha and high-alpha region
+      if ( xlo >= fAlphammm-fEps  &&  xup >= fAlphammm-fEps)
+      {
+        nfar   += content;
+        if ( xlo < fAlphamm )
+          fAlphamm = xlo;
+        if ( xup < fAlphamm )
+          fAlphamm = xup; 
+      }
+      else
+      {
+        nclose += content;
+        if ( xlo > fAlphamm )
+          fAlphamm = xlo;
+        if ( xup > fAlphamm )
+          fAlphamm = xup; 
+      }
+
+      // count bins with zero entry
+      if (content <= 0.0)
+        fNzero++;
+     
+      // set minimum error
+      if (content < 9.0)
+      {
+        fMlow += 1;
+        fHist->SetBinError(i, 3.0);
+      }
+
+      //*fLog << "Take : i, content, error = " << i << ",  " 
+      //      << fHist->GetBinContent(i) << ",  "
+      //      << fHist->GetBinError(i)   << endl;
+
+      continue;
+    }    
+    // bin is not completely contained in the fit range : set error huge
+
+    fHist->SetBinError(i, dummy);
+
+    //*fLog << "Omit : i, content, error = " << i << ",  " 
+    //      << fHist->GetBinContent(i) << ",  " << fHist->GetBinError(i) 
+    //      << endl;
+
+  }
+
+  // mean of entries/bin in the fit range
+  if (fMbins > 0)
+  {
+    mean /= ((Double_t) fMbins);
+    rms  /= ((Double_t) fMbins);
+  }
+
+  rms = sqrt( rms - mean*mean );
+
+  // if there are no events in the background region
+  //    there is no reason for rebinning
+  //    and this is the condition for assuming a constant background (= 0)
+  if (mean <= 0.0)
+    break;
+
+  Double_t helpmi = fAlphami*fAlphami*fAlphami;
+  Double_t helpmm = fAlphamm*fAlphamm*fAlphamm;
+  Double_t helpma = fAlphama*fAlphama*fAlphama;
+  Double_t help   =   (helpma-helpmm) * (fAlphamm-fAlphami)    
+	            - (helpmm-helpmi) * (fAlphama-fAlphamm);
+  if (help != 0.0)
+    a2init =  ( (fAlphamm-fAlphami)*nfar - (fAlphama-fAlphamm)*nclose )
+                * 1.5 * fHist->GetBinWidth(1) / help;
+  else
+    a2init = 0.0;
+
+
+  //--------------------------------------------
+  // rebin the histogram
+  //   - if a bin has no entries 
+  //   - or if there are too many bins with too few entries
+  //   - or if the new bin width would exceed half the size of the 
+  //     signal region
+
+  if ( !fRebin  ||
+       ( fNzero <= 0 && (Double_t)fMlow<0.05*(Double_t)fMbins )  || 
+       (Double_t)(nrebin+1)/(Double_t)nrebin * fHist->GetBinWidth(1) 
+                                                           > fAlphasig/2.0 )
+  {
+    //*fLog << "before break" << endl;
+    break;
+  }
+
+  nrebin += 1;
+  TString histname = fHist->GetName();
+  delete fHist;
+  fHist = NULL;
+
+  *fLog << "MHFindSignificance::FitPolynomial; rebin the |alpha| plot, grouping "
+        << nrebin << " bins together" << endl;
+
+  // TH1::Rebin doesn't work properly
+  //fHist = fHistOrig->Rebin(nrebin, "Rebinned");
+  // use private routine RebinHistogram()
+  fHist = new TH1F;
+  fHist->Sumw2();
+  fHist->SetNameTitle(histname, histname);
+  fHist->UseCurrentStyle();
+
+  // do rebinning such that x0 remains a lower bin edge
+  Double_t x0 = 0.0;
+  if ( !RebinHistogram(x0, nrebin) )
+  {
+    *fLog << "MHFindSignificance::FitPolynomial; RebinHistgram() failed" 
+          << endl;
+    return kFALSE;
+  }
+
+  fHist->SetXTitle("|alpha|  [\\circ]");
+  fHist->SetYTitle("Counts");
+
+  }
+  //----------------   end of while loop for rebinning   -----------------
+
+
+  // if there are still too many bins with too few entries don't fit
+  // and assume a constant background
+
+  fConstantBackg = kFALSE;
+  if ( fNzero > 0  ||  (Double_t)fMlow>0.05*(Double_t)fMbins ) 
+  {
+    *fLog << "MHFindSignificance::FitPolynomial; polynomial fit not possible,  fNzero, fMlow, fMbins = "
+          << fNzero << ",  " << fMlow << ",  " << fMbins << endl;
+    *fLog << "                    assume a constant background" << endl;
+
+    fConstantBackg = kTRUE;
+    fDegree        = 0;
+
+    TString funcname = "Poly";
+    Double_t xmin =   0.0;
+    Double_t xmax =  90.0;
+
+    TString formula = "[0]";
+
+    fPoly = new TF1(funcname, formula, xmin, xmax);
+    TList *funclist = fHist->GetListOfFunctions();
+    funclist->Add(fPoly);
+
+    //--------------------
+    Int_t nparfree = 1;
+    fChisq         = 0.0; 
+    fNdf           = fMbins - nparfree;
+    fProb          = 0.0;
+    fIstat         = 0;
+
+    fValues.Set(1);
+    fErrors.Set(1);
+
+    Double_t val, err;
+    val = mean;
+    err = sqrt( mean / (Double_t)fMbins );
+
+    fPoly->SetParameter(0, val);
+    fPoly->SetParError (0, err);
+
+    fValues[0] = val;
+    fErrors[0] = err; 
+
+    fEma[0][0]  = err*err;
+    fCorr[0][0] = 1.0;
+    //--------------------
+
+    //--------------------------------------------------
+    // reset the errors of the points in the histogram
+    for (Int_t i=1; i<=nbins; i++)
+    {
+      fHist->SetBinError(i, saveError[i-1]);
+    }
+
+
+    return kTRUE;
+  }
+
+
+  //===========   start loop for reducing the degree   ==================
+  //              of the polynomial
+  while (1)
+  {
+      //--------------------------------------------------
+      // prepare fit of a polynomial :   (a0 + a1*x + a2*x**2 + a3*x**3 + ...)
+
+      TString funcname = "Poly";
+      Double_t xmin =   0.0;
+      Double_t xmax =  90.0;
+
+      TString formula = "[0]";
+      TString bra1     = "+[";
+      TString bra2     =    "]";
+      TString xpower   = "*x";
+      TString newpower = "*x";
+      for (Int_t i=1; i<=fDegree; i++)
+      {
+          formula += bra1;
+          formula += i;
+          formula += bra2;
+          formula += xpower;
+
+          xpower += newpower;
+      }
+
+      //*fLog << "FitPolynomial : formula = " << formula << endl;
+
+      fPoly = new TF1(funcname, formula, xmin, xmax);
+      TList *funclist = fHist->GetListOfFunctions();
+      funclist->Add(fPoly);
+
+      //------------------------
+      // attention : the dimensions must agree with those in CallMinuit()
+      const UInt_t npar = fDegree+1;
+
+      TString parname[npar];
+      TArrayD vinit(npar);
+      TArrayD  step(npar);
+      TArrayD limlo(npar);
+      TArrayD limup(npar);
+      TArrayI   fix(npar);
+
+      vinit[0] =   mean;
+      vinit[2] = a2init;
+
+      for (UInt_t j=0; j<npar; j++)
+      {
+          parname[j]  = "p";
+          parname[j] += j+1;
+
+          step[j] = vinit[j] != 0.0 ? TMath::Abs(vinit[j]) / 10.0 : 0.000001;
+      }
+
+      // limit the first coefficient of the polynomial to positive values
+      // because the background must not be negative
+      limup[0] = fHist->GetEntries();
+
+      // use the subsequernt loop if you want to apply the
+      // constraint : uneven derivatives (at alpha=0) = zero
+      for (UInt_t j=1; j<npar; j+=2)
+      {
+          vinit[j] = 0;
+          step[j]  = 0;
+          fix[j]   = 1;
+      }
+
+      //*fLog << "FitPolynomial : before CallMinuit()" << endl;
+
+      MMinuitInterface inter;
+      const Bool_t rc = inter.CallMinuit(fcnpoly, parname, vinit, step,
+                                         limlo, limup, fix, fHist, "Migrad",
+                                         kFALSE);
+
+      //*fLog << "FitPolynomial : after CallMinuit()" << endl;
+
+      if (rc != 0)
+      {
+          //  *fLog << "MHFindSignificance::FitPolynomial; polynomial fit failed"
+          //        << endl;
+          //  return kFALSE;
+      }
+
+
+      //-------------------
+      // get status of minimization
+      Double_t fmin   = 0;
+      Double_t fedm   = 0;
+      Double_t errdef = 0;
+      Int_t    npari  = 0;
+      Int_t    nparx  = 0;
+
+      if (gMinuit)
+          gMinuit->mnstat(fmin, fedm, errdef, npari, nparx, fIstat);
+
+      *fLog << "MHFindSignificance::FitPolynomial; fmin, fedm, errdef, npari, nparx, fIstat = "
+            << fmin << ",  " << fedm << ",  " << errdef << ",  " << npari
+            << ",  " << nparx << ",  " << fIstat << endl;
+
+
+      //-------------------
+      // store the results
+
+      Int_t nparfree = gMinuit!=NULL ? gMinuit->GetNumFreePars() : 0;
+      fChisq         = fmin;
+      fNdf           = fMbins - nparfree;
+      fProb          = TMath::Prob(fChisq, fNdf);
+
+
+      // get fitted parameter values and errors
+      fValues.Set(npar);
+      fErrors.Set(npar);
+
+      for (Int_t j=0; j<=fDegree; j++)
+      {
+          Double_t val, err;
+          if (gMinuit)
+              gMinuit->GetParameter(j, val, err);
+
+          fPoly->SetParameter(j, val);
+          fPoly->SetParError(j, err);
+
+          fValues[j] = val;
+          fErrors[j] = err;
+      }
+
+
+      //--------------------------------------------------
+      // if the highest coefficient (j0) of the polynomial
+      // is consistent with zero reduce the degree of the polynomial
+
+      Int_t j0 = 0;
+      for (Int_t j=fDegree; j>1; j--)
+      {
+          // ignore fixed parameters
+          if (fErrors[j] == 0)
+              continue;
+
+          // this is the highest coefficient
+          j0 = j;
+          break;
+      }
+
+      if (!fReduceDegree || j0==0 || TMath::Abs(fValues[j0]) > fErrors[j0])
+          break;
+
+      // reduce the degree of the polynomial
+      *fLog << "MHFindSignificance::FitPolynomial; reduce the degree of the polynomial from "
+          << fDegree << " to " << (j0-2) << endl;
+      fDegree = j0 - 2;
+
+      funclist->Remove(fPoly);
+      //if (fPoly)
+      delete fPoly;
+      fPoly = NULL;
+
+      // delete the Minuit object in order to have independent starting
+      // conditions for the next minimization
+      //if (gMinuit)
+      delete gMinuit;
+      gMinuit = NULL;
+  }
+  //===========   end of loop for reducing the degree   ==================
+  //              of the polynomial
+
+
+  //--------------------------------------------------
+  // get the error matrix of the fitted parameters
+
+
+  if (fIstat >= 1)
+  {
+      // error matrix was calculated
+      if (gMinuit)
+          gMinuit->mnemat(&fEmat[0][0], fNdim);
+
+      // copy covariance matrix into a matrix which includes also the fixed
+      // parameters
+      TString  name;
+      Double_t bnd1, bnd2, val, err;
+      Int_t    jvarbl;
+      Int_t    kvarbl;
+      for (Int_t j=0; j<=fDegree; j++)
+      {
+          if (gMinuit)
+              gMinuit->mnpout(j, name, val, err, bnd1, bnd2, jvarbl);
+
+          for (Int_t k=0; k<=fDegree; k++)
+          {
+              if (gMinuit)
+                  gMinuit->mnpout(k, name, val, err, bnd1, bnd2, kvarbl);
+
+              fEma[j][k] = jvarbl==0 || kvarbl==0 ? 0 : fEmat[jvarbl-1][kvarbl-1];
+          }
+      }
+  }
+  else
+  {
+      // error matrix was not calculated, construct it
+      *fLog << "MHFindSignificance::FitPolynomial; error matrix not defined"
+          << endl;
+      for (Int_t j=0; j<=fDegree; j++)
+      {
+          for (Int_t k=0; k<=fDegree; k++)
+              fEma[j][k] = 0;
+
+          fEma[j][j] = fErrors[j]*fErrors[j];
+      }
+  }
+
+
+  //--------------------------------------------------
+  // calculate correlation matrix
+  for (Int_t j=0; j<=fDegree; j++)
+      for (Int_t k=0; k<=fDegree; k++)
+      {
+          const Double_t sq = fEma[j][j]*fEma[k][k];
+          fCorr[j][k] = sq==0 ? 0 : fEma[j][k] / TMath::Sqrt(fEma[j][j]*fEma[k][k]);
+      }
+
+
+  //--------------------------------------------------
+  // reset the errors of the points in the histogram
+  for (Int_t i=1; i<=nbins; i++)
+      fHist->SetBinError(i, saveError[i-1]);
+
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// ReBinHistogram
+//
+// rebin the histogram 'fHistOrig' by grouping 'nrebin' bins together 
+// put the result into the histogram 'fHist'
+// the rebinning is made such that 'x0' remains a lower bound of a bin
+//
+
+Bool_t MHFindSignificance::RebinHistogram(Double_t x0, Int_t nrebin)
+{
+  //-----------------------------------------
+  // search bin i0 which has x0 as lower edge
+
+  Int_t i0 = -1;
+  Int_t nbold = fHistOrig->GetNbinsX();
+  for (Int_t i=1; i<=nbold; i++)
+  {
+      if (TMath::Abs(fHistOrig->GetBinLowEdge(i) - x0) < 1.e-4 )
+      {
+          i0 = i;
+          break;
+      }
+  }
+
+  if (i0 == -1)
+  {
+    i0 = 1;
+    *fLog << "MHFindsignificance::Rebin; no bin found with " << x0
+          << " as lower edge,  start rebinning with bin 1" << endl;
+  }
+
+  Int_t istart = i0 - nrebin * ( (i0-1)/nrebin );
+
+  //-----------------------------------------
+  // get new bin edges
+
+  const Int_t    nbnew = (nbold-istart+1) / nrebin;
+  const Double_t xmin  = fHistOrig->GetBinLowEdge(istart);
+  const Double_t xmax  = xmin + (Double_t)nbnew * nrebin * fHistOrig->GetBinWidth(1);
+  fHist->SetBins(nbnew, xmin, xmax);
+
+  *fLog << "MHFindSignificance::ReBin; x0, i0, nbold, nbnew, xmin, xmax = "
+        << x0 << ",  " << i0 << ",  " << nbold << ",  " << nbnew << ",  "
+        << xmin << ",  " << xmax << endl;
+
+  //-----------------------------------------
+  // get new bin entries
+
+  for (Int_t i=1; i<=nbnew; i++)
+  {
+      Int_t j = nrebin*(i-1) + istart;
+
+      Double_t content = 0;
+      Double_t error2  = 0;
+      for (Int_t k=0; k<nrebin; k++)
+      {
+          content += fHistOrig->GetBinContent(j+k);
+          error2  += fHistOrig->GetBinError(j+k) * fHistOrig->GetBinError(j+k);
+      }
+      fHist->SetBinContent(i, content);
+      fHist->SetBinError  (i, sqrt(error2));
+  }
+  fHist->SetEntries( fHistOrig->GetEntries() );
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  FitGaussPoly
+//
+//  fits a (Gauss + polynomial function) to the alpha distribution 'fhist' 
+//
+//
+Bool_t MHFindSignificance::FitGaussPoly()
+{
+  *fLog << "Entry FitGaussPoly" << endl;
+
+  //--------------------------------------------------
+  // check the histogram :
+  //       - calculate initial values of the parameters
+  //       - check for bins with zero entries
+  //       - set minimum errors
+  //       - save the original errors
+  //       - set errors huge outside the fit range
+  //         (in 'fcnpoly' points with huge errors will be ignored)
+
+
+  Double_t dummy = 1.e20;
+
+  fGNzero   = 0;
+  fGMbins   = 0;
+
+  //------------------------------------------
+  // if a constant background has been assumed (due to low statistics)
+  // fit only in the signal region
+  if ( !fConstantBackg )
+  {
+    fAlphalow = 0.0;
+    fAlphahig = fAlphamax;
+  }
+  else
+  {
+    fAlphalow = 0.0;
+    fAlphahig = 2.0*fAlphasig>25.0 ? 25.0 : 2.0*fAlphasig;
+  }
+  //------------------------------------------
+
+
+  fAlphalo =  10000.0;
+  fAlphahi = -10000.0;
+
+
+  Int_t nbins = fHist->GetNbinsX();
+  TArrayD saveError(nbins);
+
+  for (Int_t i=1; i<=nbins; i++)
+  {
+    saveError[i-1] = fHist->GetBinError(i);
+
+    // bin should be completely contained in the fit range
+    // (fAlphalow, fAlphahig)
+    Double_t  xlo = fHist->GetBinLowEdge(i);
+    Double_t  xup = fHist->GetBinLowEdge(i+1);
+
+    if ( xlo >= fAlphalow-fEps  &&  xlo <= fAlphahig+fEps  &&
+	 xup >= fAlphalow-fEps  &&  xup <= fAlphahig+fEps     )
+    {
+      fGMbins++;
+
+      if ( xlo < fAlphalo )
+        fAlphalo = xlo;
+
+      if ( xup > fAlphahi )
+        fAlphahi = xup;
+
+      Double_t content = fHist->GetBinContent(i);
+
+
+      // count bins with zero entry
+      if (content <= 0.0)
+        fGNzero++;
+     
+      // set minimum error
+      if (content < 9.0)
+        fHist->SetBinError(i, 3.0);
+
+      //*fLog << "Take : i, content, error = " << i << ",  " 
+      //      << fHist->GetBinContent(i) << ",  "
+      //      << fHist->GetBinError(i)   << endl;
+
+      continue;
+    }    
+    // bin is not completely contained in the fit range : set error huge
+
+    fHist->SetBinError(i, dummy);
+
+    //*fLog << "Omit : i, content, error = " << i << ",  " 
+    //      << fHist->GetBinContent(i) << ",  " << fHist->GetBinError(i) 
+    //      << endl;
+
+  }
+
+
+  // if a bin has no entries don't fit
+  if (fGNzero > 0)
+  {
+    *fLog << "MHFindSignificance::FitGaussPoly; out of " << fGMbins 
+          << " bins there are " << fGNzero
+          << " bins with zero entry" << endl;
+
+    fGPoly = NULL;
+    return kFALSE;
+  }
+
+
+  //--------------------------------------------------
+  // prepare fit of a (polynomial+Gauss) :   
+  // (a0 + a1*x + a2*x**2 + a3*x**3 + ...) + A*exp( -0.5*((x-x0)/sigma)**2 )
+
+  TString funcname = "PolyGauss";
+  Double_t xmin =   0.0;
+  Double_t xmax =  90.0;
+
+  TString xpower   = "*x";
+  TString newpower = "*x";
+
+  TString formulaBackg = "[0]";
+  for (Int_t i=1; i<=fDegree; i++)
+      formulaBackg += Form("+[%d]*x^%d", i, i);
+
+  const TString formulaGauss = 
+        Form("[%d]/[%d]*exp(-0.5*((x-[%d])/[%d])^2)",
+             fDegree+1, fDegree+3, fDegree+2, fDegree+3);
+
+  TString formula = formulaBackg;
+  formula += "+";
+  formula += formulaGauss;
+
+  *fLog << "FitGaussPoly : formulaBackg = " << formulaBackg << endl;
+  *fLog << "FitGaussPoly : formulaGauss = " << formulaGauss << endl;
+  *fLog << "FitGaussPoly : formula = " << formula << endl;
+
+  fGPoly = new TF1(funcname, formula, xmin, xmax);
+  TList *funclist = fHist->GetListOfFunctions();
+  funclist->Add(fGPoly);
+
+  fGBackg = new TF1("Backg", formulaBackg, xmin, xmax);
+  funclist->Add(fGBackg);
+
+  //------------------------
+  // attention : the dimensions must agree with those in CallMinuit()
+  Int_t npar = fDegree+1 + 3;
+
+  TString parname[npar];
+  TArrayD vinit(npar);
+  TArrayD  step(npar); 
+  TArrayD limlo(npar); 
+  TArrayD limup(npar); 
+  TArrayI   fix(npar);
+
+
+  // take as initial values for the polynomial 
+  // the result from the polynomial fit
+  for (Int_t j=0; j<=fDegree; j++)
+    vinit[j] = fPoly->GetParameter(j);
+
+  Double_t sigma = 8;
+  vinit[fDegree+1] = 2.0 * fNex * fHist->GetBinWidth(1) / TMath::Sqrt(TMath::Pi()*2);
+  vinit[fDegree+2] = 0;
+  vinit[fDegree+3] = sigma;
+
+  *fLog << "FitGaussPoly : starting value for Gauss-amplitude = " 
+        << vinit[fDegree+1] << endl;
+
+  for (Int_t j=0; j<npar; j++)
+  {
+      parname[j]  = "p";
+      parname[j] += j+1;
+
+      step[j] = vinit[j]!=0 ? TMath::Abs(vinit[j]) / 10.0 : 0.000001;
+  }
+
+  // limit the first coefficient of the polynomial to positive values
+  // because the background must not be negative
+  limup[0] = fHist->GetEntries()*10;
+
+  // limit the sigma of the Gauss function
+  limup[fDegree+3] = 20;
+
+
+  // use the subsequernt loop if you want to apply the
+  // constraint : uneven derivatives (at alpha=0) = zero
+  for (Int_t j=1; j<=fDegree; j+=2)
+  {
+      vinit[j] = 0;
+      step[j]  = 0;
+      fix[j]   = 1;
+  }
+
+  // fix position of Gauss function
+  vinit[fDegree+2] = 0;
+  step[fDegree+2]  = 0;
+  fix[fDegree+2]   = 1;
+   
+  // if a constant background has been assumed (due to low statistics)
+  // fix the background
+  if (fConstantBackg)
+  {
+      step[0] = 0;
+      fix[0]  = 1;
+  }
+
+  MMinuitInterface inter;
+  const Bool_t rc = inter.CallMinuit(fcnpolygauss, parname, vinit, step,
+                                     limlo, limup, fix, fHist, "Migrad",
+                                     kFALSE);
+
+  if (rc != 0)
+  {
+  //  *fLog << "MHFindSignificance::FitGaussPoly; (polynomial+Gauss) fit failed"
+  //        << endl;
+  //  return kFALSE;
+  }
+
+
+  //-------------------
+  // get status of the minimization
+  Double_t fmin;
+  Double_t fedm;
+  Double_t errdef;
+  Int_t    npari;
+  Int_t    nparx;
+
+  if (gMinuit)
+    gMinuit->mnstat(fmin, fedm, errdef, npari, nparx, fGIstat);
+
+  *fLog << "MHFindSignificance::FitGaussPoly; fmin, fedm, errdef, npari, nparx, fGIstat = "
+        << fmin << ",  " << fedm << ",  " << errdef << ",  " << npari
+        << ",  " << nparx << ",  " << fGIstat << endl;
+
+
+  //-------------------
+  // store the results
+
+  Int_t nparfree  = gMinuit!=NULL ? gMinuit->GetNumFreePars() : 0;
+  fGChisq         = fmin; 
+  fGNdf           = fGMbins - nparfree;
+  fGProb          = TMath::Prob(fGChisq, fGNdf);
+
+
+  // get fitted parameter values and errors
+  fGValues.Set(npar);
+  fGErrors.Set(npar);
+
+  for (Int_t j=0; j<npar; j++)
+  {
+    Double_t val, err;
+    if (gMinuit)
+      gMinuit->GetParameter(j, val, err);
+
+    fGPoly->SetParameter(j, val);
+    fGPoly->SetParError(j, err);
+
+    fGValues[j] = val;
+    fGErrors[j] = err; 
+
+    if (j <=fDegree)
+    {
+      fGBackg->SetParameter(j, val);
+      fGBackg->SetParError(j, err);
+    }
+  }
+
+  fSigmaGauss  = fGValues[fDegree+3];
+  fdSigmaGauss = fGErrors[fDegree+3];
+  // fitted total number of excess events 
+  fNexGauss = fGValues[fDegree+1] * TMath::Sqrt(TMath::Pi()*2) /
+                                         (fHist->GetBinWidth(1)*2 );
+  fdNexGauss = fNexGauss * fGErrors[fDegree+1]/fGValues[fDegree+1];
+
+  //--------------------------------------------------
+  // get the error matrix of the fitted parameters
+
+
+  if (fGIstat >= 1)
+  {
+    // error matrix was calculated
+    if (gMinuit)
+      gMinuit->mnemat(&fGEmat[0][0], fGNdim);
+
+    // copy covariance matrix into a matrix which includes also the fixed
+    // parameters
+    TString  name;
+    Double_t bnd1, bnd2, val, err;
+    Int_t    jvarbl;
+    Int_t    kvarbl;
+    for (Int_t j=0; j<npar; j++)
+    {
+        if (gMinuit)
+            gMinuit->mnpout(j, name, val, err, bnd1, bnd2, jvarbl);
+
+        for (Int_t k=0; k<npar; k++)
+        {
+            if (gMinuit)
+                gMinuit->mnpout(k, name, val, err, bnd1, bnd2, kvarbl);
+
+            fGEma[j][k] = jvarbl==0 || kvarbl==0 ? 0 : fGEmat[jvarbl-1][kvarbl-1];
+        }
+    }
+  }
+  else
+  {
+    // error matrix was not calculated, construct it
+    *fLog << "MHFindSignificance::FitPolynomial; error matrix not defined" 
+          << endl;
+    for (Int_t j=0; j<npar; j++)
+    {
+        for (Int_t k=0; k<npar; k++)
+            fGEma[j][k] = 0;
+
+        fGEma[j][j] = fGErrors[j]*fGErrors[j];
+    }
+  }
+
+
+  //--------------------------------------------------
+  // calculate correlation matrix
+  for (Int_t j=0; j<npar; j++)
+  {
+    for (Int_t k=0; k<npar; k++)
+    {
+        const Double_t sq = fGEma[j][j]*fGEma[k][k];
+        fGCorr[j][k] = sq==0 ? 0 : fGEma[j][k] / sqrt( fGEma[j][j]*fGEma[k][k] );
+    }
+  }
+
+
+  //--------------------------------------------------
+  // reset the errors of the points in the histogram
+  for (Int_t i=1; i<=nbins; i++)
+    fHist->SetBinError(i, saveError[i-1]);
+
+  return kTRUE;
+
+}
+
+// --------------------------------------------------------------------------
+//
+//  DetExcess
+//
+//  using the result of the polynomial fit (fValues), DetExcess determines
+//
+//  - the total number of events in the signal region (fNon)
+//  - the number of backgound events in the signal region (fNbg)
+//  - the number of excess events (fNex)
+//  - the effective number of background events (fNoff), and fGamma :
+//    fNbg = fGamma * fNoff;  fdNbg = fGamma * sqrt(fNoff);
+//
+//  It assumed that the polynomial is defined as
+//               a0 + a1*x + a2*x**2 + a3*x**3 + ..
+//
+//  and that the alpha distribution has the range 0 < alpha < 90 degrees
+//
+
+Bool_t MHFindSignificance::DetExcess()
+{
+  //*fLog << "MHFindSignificance::DetExcess;" << endl;
+
+  //--------------------------------------------
+  // calculate the total number of events (fNon) in the signal region
+
+  fNon  = 0.0;
+  fdNon = 0.0;
+
+  Double_t alphaup = -1000.0; 
+  Double_t binwidth = fHist->GetBinWidth(1);
+
+  Int_t nbins = fHist->GetNbinsX();
+  for (Int_t i=1; i<=nbins; i++)
+  {
+    Double_t  xlo = fHist->GetBinLowEdge(i);
+    Double_t  xup = fHist->GetBinLowEdge(i+1);
+ 
+    // bin must be completely contained in the signal region
+    if ( xlo <= (fAlphasig+fEps)  &&  xup <= (fAlphasig+fEps)    )
+    {
+      Double_t width = fabs(xup-xlo);
+      if (fabs(width-binwidth) > fEps)
+      {
+        *fLog << "MHFindSignificance::DetExcess; alpha plot has variable binning, which is not allowed" 
+          << endl;
+        return kFALSE;
+      }
+
+      if (xup > alphaup)
+        alphaup = xup;
+
+      fNon  += fHist->GetBinContent(i);
+      fdNon += fHist->GetBinError(i) * fHist->GetBinError(i);
+    }
+  }
+  fdNon = sqrt(fdNon);
+
+  // the actual signal range is :
+  if (alphaup == -1000.0)
+    return kFALSE;
+
+  fAlphasi = alphaup;
+
+  //*fLog << "fAlphasi, fNon, fdNon, binwidth, fDegree = " << fAlphasi << ",  "
+  //      << fNon << ",  " << fdNon << ",  " << binwidth << ",  "
+  //      << fDegree << endl;
+
+  //--------------------------------------------
+  // calculate the number of background events (fNbg) in the signal region
+  // and its error (fdNbg) 
+
+  Double_t fac = 1.0/binwidth;
+
+  fNbg         = 0.0;
+  Double_t altothejplus1 = fAlphasi;
+  for (Int_t j=0; j<=fDegree; j++)
+  {
+    fNbg += fValues[j] * altothejplus1 / ((Double_t)(j+1));
+    altothejplus1 *= fAlphasi;
+  }
+  fNbg *= fac;
+
+  // derivative of Nbg 
+  Double_t facj;
+  Double_t fack;
+
+  Double_t sum = 0.0;
+  altothejplus1 = fAlphasi;
+  for (Int_t j=0; j<=fDegree; j++)
+  {
+    facj = altothejplus1 / ((Double_t)(j+1));
+
+    Double_t altothekplus1 = fAlphasi;    
+    for (Int_t k=0; k<=fDegree; k++)
+    {
+      fack = altothekplus1 / ((Double_t)(k+1));
+
+      sum   += facj * fack * fEma[j][k];
+      altothekplus1 *= fAlphasi;
+    }
+    altothejplus1 *= fAlphasi;
+  }
+  sum  *= fac*fac;
+
+  if (sum < 0.0)
+  {
+    *fLog << "MHFindsignificance::DetExcess; error squared is negative" 
+          << endl;
+    return kFALSE;
+  }
+
+  fdNbg = sqrt(sum);
+
+
+  //--------------------------------------------
+  // AS A CHECK :
+  // calculate the number of background events (fNbgtotFitted) in the 
+  // background region, and its error (fdNbgtotFitted) 
+  // expect fdnbg to be approximately equal to sqrt(fNbgtotFitted)
+
+  Double_t fNmi = 0.0;
+  altothejplus1 = fAlphami;
+  for (Int_t j=0; j<=fDegree; j++)
+  {
+    fNmi += fValues[j] * altothejplus1 / ((Double_t)(j+1));
+    altothejplus1 *= fAlphami;
+  }
+  fNmi *= fac;
+
+  Double_t fNma = 0.0;
+  altothejplus1 = fAlphama;
+  for (Int_t j=0; j<=fDegree; j++)
+  {
+    fNma += fValues[j] * altothejplus1 / ((Double_t)(j+1));
+    altothejplus1 *= fAlphama;
+  }
+  fNma *= fac;
+
+  fNbgtotFitted  = fNma - fNmi;
+
+  //----------------------
+
+  sum = 0.0;
+  Double_t altothejma = fAlphama;
+  Double_t altothejmi = fAlphami;
+  for (Int_t j=0; j<=fDegree; j++)
+  {
+    facj = (altothejma-altothejmi) / ((Double_t)(j+1));
+
+    Double_t altothekma = fAlphama;    
+    Double_t altothekmi = fAlphami;    
+    for (Int_t k=0; k<=fDegree; k++)
+    {
+      fack = (altothekma-altothekmi) / ((Double_t)(k+1));
+
+      sum   += facj * fack * fEma[j][k];
+      altothekma *= fAlphama;
+      altothekmi *= fAlphami;
+    }
+    altothejma *= fAlphama;
+    altothejmi *= fAlphami;
+  }
+  sum  *= fac*fac;
+
+  fdNbgtotFitted = sqrt(sum);
+  if ( fabs(fdNbgtotFitted - sqrt(fNbgtotFitted)) > 0.2 * sqrt(fNbgtotFitted) )
+  {
+    *fLog << "MHFindSignificance::DetExcess; error of calculated number of background events (in the background region) does not agree with the expectation :"
+          << endl;
+    *fLog << "                    fNbgtotFitted, fdNbgtotFitted = " 
+          << fNbgtotFitted << ",  " << fdNbgtotFitted
+          << ",  expected : " << sqrt(fNbgtotFitted) << endl;         
+  } 
+
+
+  //--------------------------------------------
+  // calculate the number of excess events in the signal region
+
+  fNex = fNon - fNbg;
+
+  //--------------------------------------------
+  // calculate the effective number of background events (fNoff) , and fGamma :
+  // fNbg = fGamma * fNoff;   dfNbg = fGamma * sqrt(fNoff);
+
+  if (fNbg < 0.0)
+  {
+    *fLog << "MHFindSignificamce::DetExcess; number of background events is negative,  fNbg, fdNbg = "
+          << fNbg  << ",  " << fdNbg << endl;
+
+    fGamma = 1.0;
+    fNoff  = 0.0;
+    return kFALSE;
+  }
+
+  if (fNbg > 0.0)
+  {
+    fGamma = fdNbg*fdNbg / fNbg;
+    fNoff  =  fNbg*fNbg  / (fdNbg*fdNbg);
+  }
+  else
+  {
+    fGamma = 1.0;
+    fNoff  = 0.0;
+  }
+
+  //*fLog << "Exit DetExcess()" << endl;
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  SigmaLiMa
+//
+//  calculates the significance according to Li & Ma
+//  ApJ 272 (1983) 317
+//
+Bool_t MHFindSignificance::SigmaLiMa(Double_t non,   Double_t noff, 
+                                     Double_t gamma, Double_t *siglima)
+{
+  if (gamma <= 0.0  ||  non <= 0.0  ||  noff <= 0.0)
+  {
+    *siglima = 0.0;
+    return kFALSE;
+  }
+
+  Double_t help1 = non  * log( (1.0+gamma)*non  / (gamma*(non+noff)) );
+  Double_t help2 = noff * log( (1.0+gamma)*noff / (       non+noff ) );
+  *siglima = sqrt( 2.0 * (help1+help2) );
+
+  Double_t nex = non - gamma*noff;
+  if (nex < 0.0)
+    *siglima = - *siglima;
+
+  //*fLog << "MHFindSignificance::SigmaLiMa; non, noff, gamma, *siglima = "
+  //      << non << ",  " << noff << ",  " << gamma << ",  " << *siglima << endl;
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+Bool_t MHFindSignificance::DrawFit(const Option_t *opt)
+{
+    if (fHist == NULL)
+      *fLog << "MHFindSignificance::DrawFit; fHist = NULL" << endl;
+
+
+    //TCanvas *fCanvas = new TCanvas("Alpha", "Alpha plot", 600, 600);
+    fCanvas = new TCanvas(fHist->GetName(), "Alpha plot", 600, 600);
+
+    //gStyle->SetOptFit(1011);
+
+    gROOT->SetSelectedPad(NULL);    
+    gStyle->SetPadLeftMargin(0.1);
+
+    fCanvas->cd();
+
+
+    if (fHist)
+    {
+      fHist->DrawCopy();
+    }
+
+    TF1 *fpoly = fHist->GetFunction("Poly");    
+    if (fpoly == NULL)
+      *fLog << "MHFindSignificance::DrawFit; fpoly = NULL" << endl;
+
+    if (fpoly)
+    {
+      // 2, 1 is red and solid
+      fpoly->SetLineColor(2);
+      fpoly->SetLineStyle(1);
+      fpoly->SetLineWidth(2);
+      fpoly->DrawCopy("same");
+    }
+
+    if (fFitGauss)
+    {
+      TF1 *fpolygauss = fHist->GetFunction("PolyGauss");    
+      if (fpolygauss == NULL)
+        *fLog << "MHFindSignificance::DrawFit; fpolygauss = NULL" << endl;
+
+      if (fpolygauss)
+      {
+        // 4, 1 is blue and solid
+        fpolygauss->SetLineColor(4);
+        fpolygauss->SetLineStyle(1);
+        fpolygauss->SetLineWidth(4);
+        fpolygauss->DrawCopy("same");
+      }
+
+      TF1 *fbackg = fHist->GetFunction("Backg");    
+      if (fbackg == NULL)
+        *fLog << "MHFindSignificance::DrawFit; fbackg = NULL" << endl;
+
+      if (fbackg)
+      {
+        // 6, 4 is pink and dotted
+        fbackg->SetLineColor(4);
+        fbackg->SetLineStyle(4);
+        fbackg->SetLineWidth(4);
+        fbackg->DrawCopy("same");
+      }
+    }
+
+
+    //-------------------------------
+    // print results onto the figure
+    TPaveText *pt = new TPaveText(0.30, 0.35, 0.70, 0.90, "NDC");
+    char tx[100];
+
+    sprintf(tx, "Results of polynomial fit (order %2d) :", fDegree);
+    TText *t1 = pt->AddText(tx);
+    t1->SetTextSize(0.03);
+    t1->SetTextColor(2);
+
+    sprintf(tx, "   (%6.2f< |alpha| <%6.2f [\\circ])", fAlphami, fAlphama);
+    pt->AddText(tx);
+
+    sprintf(tx, "   chi2 = %8.2f,  Ndof = %4d,  Prob = %6.2f", 
+            fChisq, fNdf, fProb);
+    pt->AddText(tx);
+
+    sprintf(tx, "   Nbgtot(fit) = %8.1f #pm %8.1f", 
+            fNbgtotFitted, fdNbgtotFitted);
+    pt->AddText(tx);
+
+    sprintf(tx, "   Nbgtot(meas) = %8.1f", fNbgtot);
+    pt->AddText(tx);
+
+
+    //sprintf(tx, "     ");
+    //pt->AddText(tx);
+
+    //--------------
+    sprintf(tx, "Results for |alpha|< %6.2f [\\circ] :", fAlphasi);
+    TText *t6 = pt->AddText(tx);
+    t6->SetTextSize(0.03);
+    t6->SetTextColor(8);
+
+    sprintf(tx, "   Non = %8.1f #pm %8.1f", fNon, fdNon);
+    pt->AddText(tx);
+
+    sprintf(tx, "   Nex = %8.1f #pm %8.1f", fNex, fdNex);
+    pt->AddText(tx);
+
+    sprintf(tx, "   Nbg = %8.1f #pm %8.1f,    gamma = %6.1f", 
+            fNbg, fdNbg, fGamma);
+    pt->AddText(tx);
+
+    Double_t ratio = fNbg>0.0 ? fNex/fNbg : 0.0;
+    sprintf(tx, "   Significance = %6.2f,    Nex/Nbg = %6.2f", 
+            fSigLiMa, ratio);
+    pt->AddText(tx);
+
+    //sprintf(tx, "     ");
+    //pt->AddText(tx);
+
+    //--------------
+    if (fFitGauss)
+    {
+      sprintf(tx, "Results of (polynomial+Gauss) fit  :");
+      TText *t7 = pt->AddText(tx);
+      t7->SetTextSize(0.03);
+      t7->SetTextColor(4);
+
+      sprintf(tx, "   chi2 = %8.2f,  Ndof = %4d,  Prob = %6.2f", 
+              fGChisq, fGNdf, fGProb);
+      pt->AddText(tx);
+
+      sprintf(tx, "   Sigma of Gauss = %8.1f #pm %8.1f  [\\circ]", 
+              fSigmaGauss, fdSigmaGauss);
+      pt->AddText(tx);
+
+      sprintf(tx, "   total no.of excess events = %8.1f #pm %8.1f", 
+              fNexGauss, fdNexGauss);
+      pt->AddText(tx);
+    }
+    //--------------
+
+    pt->SetFillStyle(0);
+    pt->SetBorderSize(0);
+    pt->SetTextAlign(12);
+
+    pt->Draw();
+
+    fCanvas->Modified();
+    fCanvas->Update();
+
+    return kTRUE;
+}
+
+
+
+// --------------------------------------------------------------------------
+//
+// Print the results of the polynomial fit to the alpha distribution
+// 
+//
+void MHFindSignificance::PrintPoly(Option_t *o) 
+{
+  *fLog << "---------------------------" << endl;
+  *fLog << "MHFindSignificance::PrintPoly :" << endl; 
+
+  *fLog << "fAlphami, fAlphama, fDegree, fAlphasi = "
+        << fAlphami << ",  " << fAlphama << ",  " << fDegree << ",  " 
+        << fAlphasi << endl;
+
+  *fLog << "fMbins, fNzero, fIstat = " << fMbins << ",  "
+        << fNzero << ",  " << fIstat << endl;
+
+  *fLog << "fChisq, fNdf, fProb = " << fChisq << ",  " 
+        << fNdf << ",  " << fProb << endl; 
+
+  *fLog << "fNon, fNbg, fdNbg, fNbgtot, fNbgtotFitted, fdNbgtotFitted = "
+        << fNon << ",  " << fNbg << ",  " << fdNbg << ",  " << fNbgtot 
+        << ",  " << fNbgtotFitted << ",  " << fdNbgtotFitted << endl;
+
+  Double_t sigtoback = fNbg>0.0 ? fNex/fNbg : 0.0;
+  *fLog << "fNex, fdNex, fGamma, fNoff, fSigLiMa, sigtoback = "
+        << fNex << ",  " << fdNex << ",  " << fGamma << ",  " << fNoff 
+        << ",  " << fSigLiMa << ",  " << sigtoback << endl;
+
+  //------------------------------------
+  // get errors
+
+  /*
+  Double_t eplus; 
+  Double_t eminus; 
+  Double_t eparab; 
+  Double_t gcc;
+  Double_t errdiag;
+
+
+  if ( !fConstantBackg )
+  {
+    *fLog << "parameter value     error     eplus     eminus    eparab   errdiag   gcc"
+          << endl; 
+
+    for (Int_t j=0; j<=fDegree; j++)
+    {
+      if (gMinuit)
+        gMinuit->mnerrs(j, eplus, eminus, eparab, gcc);
+      errdiag = sqrt(fEma[j][j]);
+      *fLog << j << "  " << fValues[j] << "  "   << fErrors[j] << "  "
+            << eplus     << "  "       << eminus << "  " << eparab     << "  " 
+            <<  errdiag  << "  "       << gcc    << endl;
+    }
+  }  
+  else
+  {
+    *fLog << "parameter value     error     errdiag "
+          << endl; 
+
+    for (Int_t j=0; j<=fDegree; j++)
+    {
+      errdiag = sqrt(fEma[j][j]);
+      *fLog << j << "  " << fValues[j] << "  "   << fErrors[j] << "  "
+            <<  errdiag  << endl;
+    }
+  }  
+  */
+
+  //----------------------------------------
+  /*
+  *fLog << "Covariance matrix :" << endl;
+  for (Int_t j=0; j<=fDegree; j++)
+  {
+    *fLog << "j = " << j << " :   ";
+    for (Int_t k=0; k<=fDegree; k++)
+    {
+      *fLog << fEma[j][k] << "   ";
+    }
+    *fLog << endl;
+  }
+
+  *fLog << "Correlation matrix :" << endl;
+  for (Int_t j=0; j<=fDegree; j++)
+  {
+    *fLog << "j = " << j << " :   ";
+    for (Int_t k=0; k<=fDegree; k++)
+    {
+      *fLog << fCorr[j][k] << "   ";
+    }
+    *fLog << endl;
+  }
+  */
+
+  *fLog << "---------------------------" << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Print the results of the (polynomial+Gauss) fit to the alpha distribution
+// 
+//
+void MHFindSignificance::PrintPolyGauss(Option_t *o) 
+{
+  *fLog << "---------------------------" << endl;
+  *fLog << "MHFindSignificance::PrintPolyGauss :" << endl; 
+
+  *fLog << "fAlphalo, fAlphahi = "
+        << fAlphalo << ",  " << fAlphahi << endl;
+
+  *fLog << "fGMbins, fGNzero, fGIstat = " << fGMbins << ",  "
+        << fGNzero << ",  " << fGIstat << endl;
+
+  *fLog << "fGChisq, fGNdf, fGProb = " << fGChisq << ",  " 
+        << fGNdf << ",  " << fGProb << endl; 
+
+
+  //------------------------------------
+  // get errors
+
+  Double_t eplus; 
+  Double_t eminus; 
+  Double_t eparab; 
+  Double_t gcc;
+  Double_t errdiag;
+
+  *fLog << "parameter value     error     eplus     eminus    eparab   errdiag   gcc"
+        << endl; 
+  for (Int_t j=0; j<=(fDegree+3); j++)
+  {
+    if (gMinuit)
+      gMinuit->mnerrs(j, eplus, eminus, eparab, gcc);
+    errdiag = sqrt(fGEma[j][j]);
+    *fLog << j << "  " << fGValues[j] << "  "   << fGErrors[j] << "  "
+          << eplus     << "  "       << eminus << "  " << eparab     << "  " 
+          <<  errdiag  << "  "       << gcc    << endl;
+  }
+
+  
+  *fLog << "Covariance matrix :" << endl;
+  for (Int_t j=0; j<=(fDegree+3); j++)
+  {
+    *fLog << "j = " << j << " :   ";
+    for (Int_t k=0; k<=(fDegree+3); k++)
+    {
+      *fLog << fGEma[j][k] << "   ";
+    }
+    *fLog << endl;
+  }
+
+  *fLog << "Correlation matrix :" << endl;
+  for (Int_t j=0; j<=(fDegree+3); j++)
+  {
+    *fLog << "j = " << j << " :   ";
+    for (Int_t k=0; k<=(fDegree+3); k++)
+    {
+      *fLog << fGCorr[j][k] << "   ";
+    }
+    *fLog << endl;
+  }
+
+  *fLog << "---------------------------" << endl;
+}
+
+//============================================================================
+
Index: /tags/Mars_V0-8-5/Mars/mhist/MHFindSignificance.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHFindSignificance.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHFindSignificance.h	(revision 9661)
@@ -0,0 +1,193 @@
+#ifndef MARS_MHFindSignificance
+#define MARS_MHFindSignificance
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+#ifndef ROOT_TArrayD
+#include <TArrayD.h>
+#endif
+
+class TF1;
+class TH1;
+class TCanvas;
+
+class MHFindSignificance : public MH
+{
+private:
+
+    TH1  *fHistOrig;  // original plot of |alpha| (0.0 to 90.0 degrees)
+    TH1  *fHist;      // copy of fHistOrig or rebinned histogram
+
+    TH1D    *fSigVsAlpha;
+
+    Double_t fAlphamin;  // requested lower limit of fit range
+    Double_t fAlphammm;  // center of fit range
+    Double_t fAlphamax;  // requested lower limit of fit range
+
+    Double_t fAlphami;  // actual lower limit of fit range 
+    Double_t fAlphamm;  // actual center of fit range 
+    Double_t fAlphama;  // actual upper limit of fit range
+
+    Double_t fAlphasig; // requested signal range
+    Double_t fAlphasi;  // actual signal range
+
+    Double_t fAlphalow; // requested lower edge of signal range
+    Double_t fAlphalo;  // actual lower edge of signal range
+
+    Double_t fAlphahig; // requested upper edge of background range
+    Double_t fAlphahi;  // actual upper edge of background range
+ 
+    // number of events in signal region
+    Double_t fNon;     // total number of events in signal region
+    Double_t fNbg;     // number of background events in signal region
+    Double_t fNex;     // number of excess events in signal region
+
+    Double_t fdNon;
+    Double_t fdNbg;
+    Double_t fdNex;
+
+    // number of events in background region
+    Double_t fNbgtot;  // total number of events in background region
+    Double_t fNbgtotFitted;  // fitted total no. of events in background region
+    Double_t fdNbgtotFitted; // fitted error of this number
+
+    // effective number of background events
+    Double_t fNoff;
+    Double_t fGamma;   // Nbg = Non - gamma * Noff
+
+    Double_t fSigLiMa; // significance of gamma signal according to Li & Ma
+
+    const static Double_t fEps = 1.e-4;  // tolerance for floating point comparisons
+
+    Bool_t fDraw;          // if true : draw plots
+    Bool_t fFitGauss;      // if true : do the (polynomial+Gauss fit)
+    Bool_t fRebin;         // if true : allow rebinning of the alpha plot    
+    Bool_t fReduceDegree;  // if true : allow reducing of the order of the polynomial
+
+    Bool_t fConstantBackg; // if set true if background fit is not possible
+                           // due to low statistics
+
+    TCanvas  *fCanvas;
+
+    Double_t fNexGauss;    // total number of excess events 
+                           // (from fitted Gauss function)
+    Double_t fdNexGauss;   // error of the total number of excess events
+ 
+    Double_t fSigmaGauss;  // sigma of fitted Gauss function
+    Double_t fdSigmaGauss; // error of this sigma
+
+    //--------------------
+    TF1      *fPoly;   // polynomial function
+    Int_t    fFitBad;  // if != 0 fit failed
+    Int_t    fDegree;  // degree of polynomial to be fitted to the background
+    Int_t    fNdf;     // number of degrees of freedom of polynomial fit
+    Double_t fChisq;   // chi squared of polynomial fit
+    Double_t fProb;    // chi squared probability ofg polynomial fit 
+
+    TArrayD fValues;
+    TArrayD fErrors;
+
+    const static Int_t    fNdim = 6;
+    Double_t fEmat[fNdim][fNdim];
+    Double_t fEma [fNdim][fNdim];
+    Double_t fCorr[fNdim][fNdim];
+
+    Int_t  fMbins;     // number of bins in the fit range
+    Int_t  fMlow;      // number of bins in the fit range with too few entries
+    Int_t  fNzero;     // number of bins in the fit range with zero entry
+    Int_t  fIstat;
+
+    //--------------------
+
+    //--------------------
+    TF1      *fGPoly;   // (Gauss+polynomial) function
+    TF1      *fGBackg;  // polynomial part of (Gauss+polynomial) function
+    Int_t    fGFitBad;  // if != 0 fit failed
+    Int_t    fGDegree;  // degree of polynomial to be fitted to the background
+    Int_t    fGNdf;     // number of degrees of freedom of polynomial fit
+    Double_t fGChisq;   // chi squared of polynomial fit
+    Double_t fGProb;    // chi squared probability ofg polynomial fit 
+
+    TArrayD fGValues;
+    TArrayD fGErrors;
+
+    const static Int_t    fGNdim = 9;
+    Double_t fGEmat[fGNdim][fGNdim];
+    Double_t fGEma[fGNdim][fGNdim];
+    Double_t fGCorr[fGNdim][fGNdim];
+
+    Int_t  fGMbins;     // number of bins in the fit range
+    Int_t  fGNzero;     // numnber of bins in the fit range with zero entry
+    Int_t  fGIstat;
+
+    //--------------------
+
+    static const TString gsDefName;  //! Default Name
+    static const TString gsDefTitle; //! Default Title
+
+    Bool_t DetExcess(); 
+    Bool_t FitPolynomial();
+    Bool_t FitGaussPoly();
+    Bool_t RebinHistogram(Double_t x0, Int_t nrebin);
+
+public:
+    MHFindSignificance(const char *name=NULL, const char *title=NULL);
+    ~MHFindSignificance();
+
+    Bool_t FindSigma(TH1 *fhist,  Double_t alphamin, Double_t alphamax, 
+                     Int_t degree, Double_t alphasig, 
+                     Bool_t drawpoly, Bool_t fitgauss, Bool_t print);
+
+    Bool_t SigmaLiMa(Double_t non, Double_t noff, Double_t gamma,
+                     Double_t *siglima);
+
+    Bool_t SigmaVsAlpha(TH1 *fhist,   Double_t alphamin, Double_t alphamax, 
+                        Int_t degree, Bool_t print);
+
+    Double_t GetSignificance()   { return fSigLiMa; }
+
+    Bool_t DrawFit(Option_t *opt=NULL);
+
+    Float_t GetDegree()     const { return fDegree;  }
+    Float_t GetProb()       const { return fProb;    }
+    Float_t GetNdf()        const { return fNdf;     }
+    Float_t GetGamma()      const { return fGamma;   }
+    Float_t GetNon()        const { return fNon;     }
+    Float_t GetNex()        const { return fNex;     }
+    Float_t GetNbg()        const { return fNbg;     }
+    Float_t GetSigLiMa()    const { return fSigLiMa; }
+    Float_t GetMbins()      const { return fMbins;   }
+    Float_t GetAlphasi()    const { return fAlphasi; }
+
+    void SetRebin(Bool_t b=kTRUE);
+    void SetReduceDegree(Bool_t b=kTRUE);
+
+    void PrintPoly(Option_t *opt=NULL);
+    void PrintPolyGauss(Option_t *opt=NULL);
+
+    ClassDef(MHFindSignificance, 1) // Determine significance from alpha plot
+};
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mhist/MHFlux.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHFlux.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHFlux.cc	(revision 9661)
@@ -0,0 +1,586 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Wolfgang Wittek 5/2002 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MHFlux                                                                 //
+//                                                                          //
+//  calculates absolute photon fluxes                                       //
+//             from the distributions of the estimated energy               //
+//                      for the different bins in some variable 'Var'       //
+//                      (Var = Theta or time)                               //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MHFlux.h"
+
+#include <TStyle.h>
+
+#include <TF1.h>
+#include <TH2.h>
+#include <TProfile.h>
+
+#include <TCanvas.h>
+
+#include "MTime.h"
+
+#include "MBinning.h"
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MHThetabarTheta.h"
+#include "MHEffOnTime.h"
+#include "MHGamma.h"
+
+ClassImp(MHFlux);
+
+using namespace std;
+
+MHFlux::MHFlux(const MHGamma &hist, const TString varname, const TString unit)
+    : fHOrig(), fHUnfold(), fHFlux()
+{
+    const TH2D &h2d = *hist.GetProject();
+
+    if (varname.IsNull() || unit.IsNull())
+        *fLog << warn << dbginf << "varname or unit not defined" << endl;
+
+    fVarname = varname;
+    fUnit    = unit;
+
+    // char txt[100];
+
+    // original distribution of E-est for different bins 
+    //                       of the variable (Theta or time)
+    // sprintf(txt, "gammas vs. E-est and %s",varname);
+
+    ((TH2D&)h2d).Copy(fHOrig);
+
+    fHOrig.SetName("E_est");
+    fHOrig.SetTitle(TString("No.of gammas vs. E-est and ")+fVarname);
+
+    fHOrig.SetDirectory(NULL);
+    fHOrig.SetXTitle("E_{est} [GeV]");
+    fHOrig.SetYTitle(fVarname+fUnit);
+    //fHOrig.Sumw2();
+
+    SetBinning((TH2*)&fHOrig, (TH2*)&h2d);
+
+    fHOrig.Copy(fHUnfold);
+
+    // unfolded distribution of E-unfold for different bins 
+    //                       of the variable (Theta or time)
+    // sprintf(txt, "gammas vs. E-unfold and %s",varname);
+    fHUnfold.SetName("E-unfolded");
+    fHUnfold.SetTitle(TString("No.of gammas vs. E-unfold and ")+fVarname);
+
+    fHUnfold.SetDirectory(NULL);
+    fHUnfold.SetXTitle("E_{unfold} [GeV]");
+    fHUnfold.SetYTitle(fVarname+fUnit);
+    //fHUnfold.Sumw2();
+    
+    SetBinning((TH2*)&fHUnfold, (TH2*)&fHOrig);
+
+
+    // absolute photon flux vs. E-unfold
+    //          for different bins of the variable (Theta or time)
+    //
+    // sprintf(txt, "gamma flux [1/(s m2 GeV) vs. E-unfold and %s",varname);
+    fHFlux.SetName("photon flux");
+    fHFlux.SetTitle(TString("Gamma flux [1/(s m^2 GeV) vs. E-unfold and ")+fVarname);
+
+    fHFlux.SetDirectory(NULL);
+    fHFlux.SetXTitle("E_{unfold} [GeV]");
+    fHFlux.SetYTitle(fVarname+fUnit);
+    fHFlux.Sumw2();
+
+    SetBinning((TH2*)&fHFlux, (TH2*)&fHUnfold);
+}
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor. It sets the variable name (Theta or time)
+//                      and the units for the variable
+// 
+MHFlux::MHFlux(const TH2D &h2d, const TString varname, const TString unit)
+    : fHOrig(), fHUnfold(), fHFlux()
+{
+    if (varname.IsNull() || unit.IsNull())
+        *fLog << warn << dbginf << "varname or unit not defined" << endl;
+
+    fVarname = varname;
+    fUnit    = unit;
+
+    // char txt[100];
+
+    // original distribution of E-est for different bins 
+    //                       of the variable (Theta or time)
+    // sprintf(txt, "gammas vs. E-est and %s",varname);
+
+    ((TH2D&)h2d).Copy(fHOrig);
+
+    fHOrig.SetName("E_est");
+    fHOrig.SetTitle(TString("No.of gammas vs. E-est and ")+fVarname);
+
+    fHOrig.SetDirectory(NULL);
+    fHOrig.SetXTitle("E_{est} [GeV]");
+    fHOrig.SetYTitle(fVarname+fUnit);
+    //fHOrig.Sumw2();
+
+    // copy fHOrig into fHUnfold in case no unfolding is done
+    fHOrig.Copy(fHUnfold);
+
+    SetBinning((TH2*)&fHOrig, (TH2*)&h2d);
+
+
+    // unfolded distribution of E-unfold for different bins 
+    //                       of the variable (Theta or time)
+    // sprintf(txt, "gammas vs. E-unfold and %s",varname);
+    fHUnfold.SetName("E-unfolded");
+    fHUnfold.SetTitle(TString("No.of gammas vs. E-unfold and ")+fVarname);
+
+    fHUnfold.SetDirectory(NULL);
+    fHUnfold.SetXTitle("E_{unfold} [GeV]");
+    fHUnfold.SetYTitle(fVarname+fUnit);
+    //fHUnfold.Sumw2();
+    
+    SetBinning((TH2*)&fHUnfold, (TH2*)&fHOrig);
+
+
+    // absolute photon flux vs. E-unfold
+    //          for different bins of the variable (Theta or time)
+    //
+    // sprintf(txt, "gamma flux [1/(s m2 GeV) vs. E-unfold and %s",varname);
+    fHFlux.SetName("photon flux");
+    fHFlux.SetTitle(TString("Gamma flux [1/(s m^{2} GeV)] vs. E-unfold and ")+fVarname);
+
+    fHFlux.SetDirectory(NULL);
+    fHFlux.SetXTitle("E_{unfold} [GeV]");
+    fHFlux.SetYTitle(fVarname+fUnit);
+    fHFlux.Sumw2();
+
+    SetBinning((TH2*)&fHFlux, (TH2*)&fHUnfold);
+}
+
+// -------------------------------------------------------------------------
+//
+// Unfold the distribution in E-est
+//
+void MHFlux::Unfold()
+{
+}
+
+void MHFlux::CalcFlux(const MHEffOnTime &teff, const MHThetabarTheta &thetabar,
+                      const TH2D *aeff)
+{
+    CalcFlux(teff.GetHist(), thetabar.GetHist(), aeff);
+}
+
+Double_t MHFlux::ParabInterpolLog(const TAxis &axe, Int_t j,
+                                  Double_t y[], Double_t Ebar) const
+{
+    const double t1 = log10(axe.GetBinLowEdge(j-1)) + log10(axe.GetBinUpEdge(j-1));
+    const double t2 = log10(axe.GetBinLowEdge(j))   + log10(axe.GetBinUpEdge(j));
+    const double t3 = log10(axe.GetBinLowEdge(j+1)) + log10(axe.GetBinUpEdge(j+1));
+
+    const Double_t lebar = log10(Ebar);
+
+    return Parab(t1/2, t2/2, t3/2, y[j-2], y[j-1], y[j], lebar);
+}
+
+// --------------------------------------------------------------------
+//
+//  determine bins for interpolation (k3 is the middle one) in bar.
+//  k0 denotes the bin from which the error is copied
+//
+void MHFlux::FindBins(const TAxis &axe, const Double_t bar, Int_t &k3, Int_t &k0) const
+{
+    const Int_t n = axe.GetNbins();
+
+    k3 = axe.FindFixBin(bar);
+    k0 = k3;
+
+    if (k3<2)
+    {
+        k3 = 2;
+        if (bar<axe.GetBinLowEdge(2))
+            k0 = 1;
+    }
+
+    if (k3>n-1)
+    {
+        k3 = n-1;
+        if (bar>axe.GetBinLowEdge(n))
+            k0 = n;
+    }
+
+    if (bar>=axe.GetBinLowEdge(1) && bar<=axe.GetBinUpEdge(n))
+        return;
+
+    *fLog << dbginf << "extrapolation: bar = " << bar;
+    *fLog << ", min =" << axe.GetBinLowEdge(1);
+    *fLog << ", max =" << axe.GetBinUpEdge(n) << endl;
+}
+
+Double_t MHFlux::ParabInterpolCos(const TAxis &axe, const TH2D *aeff, Int_t j, Int_t k3, Double_t val) const
+{
+    const double t1 = cos( axe.GetBinCenter (k3-1) );
+    const double t2 = cos( axe.GetBinCenter (k3)   );
+    const double t3 = cos( axe.GetBinCenter (k3+1) );
+
+    const double a1 = aeff->GetBinContent(j, k3-1);
+    const double a2 = aeff->GetBinContent(j, k3);
+    const double a3 = aeff->GetBinContent(j, k3+1);
+
+    return Parab(t1, t2, t3, a1, a2, a3, val);
+}
+
+// -------------------------------------------------------------------------
+//
+// Calculate photon flux by dividing the distribution in Eunf (fHUnfold) by
+//                       the width of the energy interval     (deltaE)
+//                       the effective ontime                 (*teff)
+//                       and the effective collection area    (*aeff)
+//
+void MHFlux::CalcFlux(const TH1D *teff, const TProfile *thetabar,
+                      const TH2D *aeff)
+{
+    //
+    // Note that fHUnfold  has bins in Eunf and Var
+    //           *teff     has bins in Var  (the same bins in Var as fHUnfold)
+    //           *thetabar has bins in Var  (the same bins in Var as fHUnfold)
+    //           *aeff     has bins in Etru and Theta
+    //                     (where in general the binning in Etru is different
+    //                      from the binning in Eunf)
+    // The variable Var may be 'time' or 'Theta'
+
+    const TAxis &axex = *((TH2*)aeff)->GetXaxis();
+    const TAxis &axey = *((TH2*)aeff)->GetYaxis();
+
+    if (axex.GetNbins()<3)
+    {
+        *fLog << err << "ERROR - Number of Energy bins <3 not implemented!" << endl;
+        return;
+    }
+
+    if (axey.GetNbins()<3)
+        *fLog << warn << "WARNING - Less than 3 theta-bins not supported very well!" << endl;
+
+    //
+    // calculate effective collection area
+    //    for the Eunf and Var bins of the histogram fHUnfold
+    //    from the histogram *aeff, which has bins in Etru and Theta
+    // the result is the histogram fHAeff
+    //
+    TH2D fHAeff;
+    SetBinning((TH2*)&fHAeff, (TH2*)&fHUnfold);
+    fHAeff.Sumw2();
+
+    //
+    // ------ start loops ------
+    //
+    const Int_t nEtru = aeff->GetNbinsX();
+
+    Double_t *aeffbar  = new Double_t[nEtru];
+    Double_t *daeffbar = new Double_t[nEtru];
+
+    const Int_t nVar = fHFlux.GetNbinsY();
+    for (int n=1; n<=nVar; n++)
+    {
+        const Double_t tbar = thetabar->GetBinContent(n);
+        const Double_t costbar = cos(tbar/kRad2Deg);
+
+        // determine bins for interpolation (k3, k0)
+        Int_t kv, ke;
+        FindBins(axey, tbar, kv, ke);
+
+        //
+        // calculate effective collection area at Theta = Thetabar
+        // by quadratic interpolation in cos(Theta);
+        // do this for each bin of Etru
+        //
+        for (int j=1; j<=nEtru; j++)
+        {
+            if (axey.GetNbins()<3)
+            {
+                // FIXME: Other interpolation?
+                aeffbar[j-1]  = aeff->GetBinContent(j, n);
+                daeffbar[j-1] = aeff->GetBinError(j, n);
+            }
+            else
+            {
+                aeffbar[j-1]  = ParabInterpolCos(axey, aeff, j, kv, costbar);
+                daeffbar[j-1] = aeff->GetBinError(j, ke);
+            }
+        }
+
+        //
+        // calculate effective collection area at (E = Ebar, Theta = Thetabar)
+        // by quadratic interpolation in log10(Etru)
+        // do this for each bin of Eunf
+        //
+        CalcEffCol(axex, fHAeff, n, aeffbar, daeffbar);
+    }
+
+    delete aeffbar;
+    delete daeffbar;
+
+    //
+    // now calculate the absolute gamma flux
+    //
+    CalcAbsGammaFlux(*teff, fHAeff);
+}
+
+// --------------------------------------------------------------------
+//
+//  calculate effective collection area at (E = Ebar, Theta = Thetabar)
+//  by quadratic interpolation in log10(Etru)
+//  do this for each bin of Eunf
+//
+void MHFlux::CalcEffCol(const TAxis &axex, TH2D &fHAeff, Int_t n, Double_t aeffbar[], Double_t daeffbar[])
+{
+    const Int_t nEunf = fHFlux.GetNbinsX();
+
+    const TAxis &unfx = *fHUnfold.GetXaxis();
+
+    for (int m=1; m<=nEunf; m++)
+    {
+        const Double_t Ebar = GetBinCenterLog(unfx, m);
+
+        Int_t j0, j3;
+        FindBins(axex, Ebar, j3, j0);
+
+        const Double_t v = ParabInterpolLog(axex, j3, aeffbar, Ebar);
+
+        fHAeff.SetBinContent(m,n, v);
+        fHAeff.SetBinError(m,n, daeffbar[j0-1]);
+    }
+}
+
+// --------------------------------------------------------------------
+//
+//  calculate the absolute gamma flux
+//
+void MHFlux::CalcAbsGammaFlux(const TH1D &teff, const TH2D &fHAeff)
+{
+    const Int_t nEunf = fHFlux.GetNbinsX();
+    const Int_t nVar  = fHFlux.GetNbinsY();
+
+    for (int m=1; m<=nEunf; m++)
+    {
+        const Double_t DeltaE = fHFlux.GetXaxis()->GetBinWidth(m);
+
+        for (int n=1; n<=nVar; n++)
+        {
+            const Double_t Ngam  = fHUnfold.GetBinContent(m,n);
+            const Double_t Aeff  = fHAeff.GetBinContent(m,n);
+            const Double_t Effon = teff.GetBinContent(n);
+
+            const Double_t c1 = fHUnfold.GetBinError(m,n)/Ngam;
+            const Double_t c2 = teff.GetBinError(n)      /Effon;
+            const Double_t c3 = fHAeff.GetBinError(m,n)  /Aeff;
+
+            const Double_t cont  = Ngam / (DeltaE * Effon * Aeff);
+            const Double_t dcont = sqrt(c1*c1 + c2*c2 + c3*c3);
+
+            //
+            // Out of Range
+            //
+            const Bool_t oor = Ngam<=0 || DeltaE<=0 || Effon<=0 || Aeff<=0;
+
+            if (oor)
+                *fLog << warn << "MHFlux::CalcAbsGammaFlux(" << m << "," << n << ") ";
+
+            if (Ngam<=0)
+                *fLog << " Ngam=0";
+            if (DeltaE<=0)
+                *fLog << " DeltaE=0";
+            if (Effon<=0)
+                *fLog << " Effon=0";
+            if (Aeff<=0)
+                *fLog << " Aeff=0";
+
+            if (oor)
+                *fLog << endl;
+
+            fHFlux.SetBinContent(m,n, oor ? 1e-20 : cont);
+            fHFlux.SetBinError(m,n,   oor ? 1e-20 : dcont*cont);
+        }
+    }
+}
+
+// --------------------------------------------------------------------
+//
+// draw the differential photon flux vs. E-unf
+// for the individual bins of the variable Var
+//
+void MHFlux::DrawFluxProjectionX(Option_t *opt) const
+{
+    const Int_t nVar = fHFlux.GetNbinsY();
+
+    for (int n=1; n<=nVar; n++)
+    {
+        TString strg0("Flux-");
+
+        TH1D &h = *((TH2D)fHFlux).ProjectionX(strg0+fVarname, n, n, "E");
+
+        TString strg1 = "Photon flux vs. E_{unfold} for ";
+        TString strg2 = fVarname+"-bin #";
+        strg2 += n;
+
+        new TCanvas(strg2, strg1+strg2);
+        gPad->SetLogx();
+        gPad->SetLogy();
+
+        TString name = fVarname+"bin_";
+        name += n;
+
+        h.SetName(name);
+        h.SetTitle(strg1+strg2);
+        h.SetXTitle("E_{unfold} [GeV]");
+        h.SetYTitle("photons / (s m^{2} GeV)");
+        h.GetXaxis()->SetLabelOffset(-0.025);
+        h.GetXaxis()->SetTitleOffset(1.1);
+        h.GetXaxis()->SetNdivisions(1);
+        h.GetYaxis()->SetTitleOffset(1.25);
+        h.DrawCopy();
+     }
+}
+
+void MHFlux::DrawOrigProjectionX(Option_t *opt) const
+{
+    const Int_t nVar = fHOrig.GetNbinsY();
+
+    for (int n=1; n<=nVar; n++)
+    {
+        TString strg0 = "Orig-";
+        strg0 += fVarname;
+        strg0 += "_";
+        strg0 += n;
+
+        TH1D &h = *((TH2D)fHOrig).ProjectionX(strg0, n, n, "E");
+
+        TString strg1("No.of photons vs. E-est for ");
+        strg1 += fVarname+"-bin ";
+        strg1 += n;
+
+        new TCanvas(strg0, strg1);
+
+        gPad->SetLogx();
+        gPad->SetLogy();
+
+        h.SetName(strg0);
+        h.SetTitle(strg1);
+        h.SetXTitle("E_{est} [GeV]");
+        h.GetXaxis()->SetLabelOffset(-0.025);
+        h.GetXaxis()->SetTitleOffset(1.1);
+        h.GetXaxis()->SetNdivisions(1);
+        h.SetYTitle("No.of photons");
+        h.DrawCopy();
+    }
+}
+
+// -------------------------------------------------------------------------
+//
+//  Draw the histograms
+//
+void MHFlux::Draw(Option_t *opt)
+{
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    AppendPad("");
+
+    pad->Divide(2,2);
+
+    pad->cd(1);
+    gPad->SetBorderMode(0);
+    fHOrig.Draw(opt);
+
+    pad->cd(2);
+    gPad->SetBorderMode(0);
+    fHUnfold.Draw(opt);
+
+    pad->cd(3);
+    gPad->SetBorderMode(0);
+    fHFlux.Draw(opt);
+
+    pad->Modified();
+    pad->Update();
+}
+
+Double_t MHFlux::Parab(Double_t x1, Double_t x2, Double_t x3,
+                       Double_t y1, Double_t y2, Double_t y3,
+                       Double_t val)
+{
+    Double_t c0, c1, c2;
+    Parab(x1, x2, x3, y1, y2, y3, &c0, &c1, &c2);
+    return c0 + c1*val + c2*val*val;
+}
+
+// -------------------------------------------------------------------------
+//
+// Quadratic interpolation
+//
+// *** calculate the parameters of a parabula 
+//                      y = a + b*x + c*x**2 = F(x)
+//     such that       yi = F(xi)       for (i=1,3)
+//
+Bool_t MHFlux::Parab(Double_t x1, Double_t x2, Double_t x3,
+                     Double_t y1, Double_t y2, Double_t y3,
+                     Double_t *a, Double_t *b, Double_t *c)
+{
+    const double det =
+        + x2*x3*x3 + x1*x2*x2 + x3*x1*x1
+        - x2*x1*x1 - x3*x2*x2 - x1*x3*x3;
+
+    if (det==0)
+    {
+        *a = 0;
+        *b = 0;
+        *c = 0;
+        return kFALSE;
+    }
+
+    const double det1 = 1.0/det;
+
+    const double ai11 = x2*x3*x3 - x3*x2*x2;
+    const double ai12 = x3*x1*x1 - x1*x3*x3;
+    const double ai13 = x1*x2*x2 - x2*x1*x1;
+
+    const double ai21 = x2*x2 - x3*x3;
+    const double ai22 = x3*x3 - x1*x1;
+    const double ai23 = x1*x1 - x2*x2;
+
+    const double ai31 = x3 - x2;
+    const double ai32 = x1 - x3;
+    const double ai33 = x2 - x1;
+
+    *a = (ai11*y1 + ai12*y2 + ai13*y3) * det1;
+    *b = (ai21*y1 + ai22*y2 + ai23*y3) * det1;
+    *c = (ai31*y1 + ai32*y2 + ai33*y3) * det1;
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mhist/MHFlux.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHFlux.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHFlux.h	(revision 9661)
@@ -0,0 +1,92 @@
+#ifndef MARS_MHFlux
+#define MARS_MHFlux
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#ifndef ROOT_TH1
+#include <TH1.h>
+#endif
+
+#ifndef ROOT_TH2
+#include <TH2.h>
+#endif
+
+class TH2D;
+
+class MHGamma;
+class MHEffOnTime;
+class MHThetabarTheta;
+
+// base class MH is used because it defines "MakeDefCanvas"
+// if base class MH is used one has to define the member function Fill
+//                          because in MH Fill is set to zero
+class MHFlux : public MH 
+{
+private:
+
+    TString fVarname;
+    TString fUnit;
+
+    TH2D fHOrig;       // original distribution of E-est 
+    TH2D fHUnfold;     // unfolded distribution of E-unfold
+    TH2D fHFlux;       // absolute differential photon flux versus E-unfold
+    // all these plots for different bins of the variable (Theta or time)
+
+    void CalcEffCol(const TAxis &axex, TH2D &aeff, Int_t n, Double_t aeffbar[], Double_t daeffbar[]);
+    Double_t ParabInterpolCos(const TAxis &axe, const TH2D *aeff, Int_t j, Int_t k3, Double_t val) const;
+    void FindBins(const TAxis &axe, const Double_t bar, Int_t &k3, Int_t &k0) const;
+    void CalcAbsGammaFlux(const TH1D &teff, const TH2D &fHAeff);
+    Double_t ParabInterpolLog(const TAxis &axe, Int_t j,
+                              Double_t y[], Double_t Ebar) const;
+
+public:
+    MHFlux(const TH2D &h2d, const TString varname, const TString unit);
+    MHFlux(const MHGamma &h2d, const TString varname, const TString unit);
+
+    void Unfold();
+    void CalcFlux(const TH1D *teff, const TProfile *thetabar,
+                  const TH2D *aeff);
+
+    void CalcFlux(const MHEffOnTime &teff,
+                  const MHThetabarTheta &thetabar,
+                  const TH2D *aeff);
+
+    void Draw(Option_t *option="");
+
+    void DrawFluxProjectionX(Option_t *opt="") const;
+    void DrawOrigProjectionX(Option_t *opt="") const;
+
+    const TH2D *GetHOrig()       { return &fHOrig; }
+    const TH2D *GetHUnfold()     { return &fHUnfold; }
+    const TH2D *GetHFlux()       { return &fHFlux; }
+
+    static Bool_t Parab(double x1, double x2, double x3,
+                        double y1, double y2, double y3,
+                        double *a, double *b, double *c);
+
+    static Double_t Parab(double x1, double x2, double x3,
+                          double y1, double y2, double y3,
+                          double val);
+
+    ClassDef(MHFlux, 0) //2D-plots (original, unfolded, flux)
+};
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mhist/MHGamma.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHGamma.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHGamma.cc	(revision 9661)
@@ -0,0 +1,286 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and time saving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Wolfgang Wittek 6/2002 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MHGamma                                                                 //
+//                                                                          //
+//  manipulation of alpha distributions                                     //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MHGamma.h"
+
+#include <TCanvas.h>
+#include <TPad.h>
+
+#include <math.h>
+
+#include <TH2.h>
+#include <TH3.h>
+
+#include "MHAlphaEnergyTheta.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHGamma);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor. 
+//
+MHGamma::MHGamma(const TString &name, const TString &title)
+    : fHist(NULL), fProject(NULL)
+{
+    fName  = name.IsNull()  ? (TString)"MHGamma" : name;
+    fTitle = title.IsNull() ? (TString)"3D-histogram of Alpha, E_est, Theta (Gamma sample)" : title;
+}
+
+TH3D *MHGamma::Subtract(const MHAlphaEnergyTheta &h1, const MHAlphaEnergyTheta &h2)
+{
+    return Subtract(h1.GetHist(), h2.GetHist());
+}
+
+TObject *MHGamma::DrawClone(Option_t *opt) const
+{
+    DrawClone1();
+    DrawClone2();
+
+    return NULL;
+}
+
+void MHGamma::DrawClone1() const
+{
+    if (!fHist)
+        return;
+
+    //
+    // ------------- Part 1 ---------------------
+    //
+    TString titlex = fHist->GetXaxis()->GetTitle();
+    TString titley = fHist->GetYaxis()->GetTitle();
+    TString titlez = fHist->GetYaxis()->GetTitle();
+
+    TString canvtitle = "3D-plot "; //of ";
+    /*
+     canvtitle += titlex;
+     canvtitle += ", ";
+     canvtitle += titley;
+     canvtitle += ", ";
+     canvtitle += titlez+" ";
+     */
+    canvtitle += "for 'gamma' sample";
+
+    TCanvas &c = *MakeDefCanvas("Alpha", canvtitle);
+
+    c.Divide(2, 2);
+
+    gROOT->SetSelectedPad(NULL);
+
+    TH1 *h;
+
+    c.cd(1);
+    h = ((TH3D*)(fHist))->Project3D(fName+"_ex");
+
+    TString title= "Source-Antisource: ";
+    h->SetTitle(title + titlex);
+    h->SetXTitle(titlex);
+    h->SetYTitle("Counts");
+
+    h->Draw();
+    h->SetBit(kCanDelete);
+
+    c.cd(2);
+    h = ((TH3D*)(fHist))->Project3D(fName+"_ey");
+
+    h->SetTitle(title + titley);
+    h->SetXTitle(titley);
+    h->SetYTitle("Counts");
+
+    h->Draw();
+    h->SetBit(kCanDelete);
+    gPad->SetLogx();
+
+    c.cd(3);
+    h = ((TH3D*)(fHist))->Project3D(fName+"_ez");
+
+    h->SetTitle(title + titlez);
+    h->SetXTitle(titlez);
+    h->SetYTitle("Counts");
+
+    h->Draw();
+    h->SetBit(kCanDelete);
+
+    c.cd(4);
+    ((TH3D*)fHist)->DrawCopy();
+
+    c.Modified();
+    c.Update();
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Calculate the histogram as the difference of two histograms :
+//          fHist(gamma) = h1(source) - h2(antisource)
+// 
+TH3D *MHGamma::Subtract(const TH3D *h1, const TH3D *h2)
+{
+    if (fHist)
+        delete fHist;
+
+    fHist = new TH3D;
+    fHist->SetName(fName);
+    fHist->SetTitle(fTitle);
+    fHist->SetDirectory(NULL);
+
+    SetBinning((TH1*)fHist, (TH1*)h1);
+
+    fHist->SetXTitle((((TH1*)h1)->GetXaxis())->GetTitle());
+    fHist->SetYTitle((((TH1*)h1)->GetYaxis())->GetTitle());
+    fHist->SetZTitle((((TH1*)h1)->GetZaxis())->GetTitle());
+
+    fHist->Add((TH1*)h1, (TH1*)h2, 1, -1); // ROOT: FIXME!
+
+    return fHist;
+}
+
+// --------------------------------------------------------------------------
+//
+// Integrate fHist(gamma) in the alpha range (lo, up)
+// 
+TH2D *MHGamma::GetAlphaProjection(Axis_t lo, Axis_t up)
+{
+    if (up < lo)
+    {
+        *fLog << err << fName << "MHGamma : Alpha projection not possible: lo=" << lo << " up=" << up << endl;
+        return NULL;
+    }
+
+    TAxis &axe = *fHist->GetXaxis();
+
+    Int_t ilo = axe.FindFixBin(lo);
+    Int_t iup = axe.FindFixBin(up);
+
+    const Double_t epslo1 = lo-axe.GetBinLowEdge(ilo);
+    const Double_t epslo2 = axe.GetBinUpEdge(ilo)-lo;
+
+    const Double_t epsup1 = up-axe.GetBinLowEdge(iup);
+    const Double_t epsup2 = axe.GetBinUpEdge(iup)-up;
+
+    const Double_t epslo = epslo1<epslo2 ? epslo1 : epslo2;
+    const Double_t epsup = epsup1<epsup2 ? epsup1 : epsup2;
+
+    if (epslo1>epslo2)
+        ilo++;
+
+    if (epsup1<epsup2)
+        iup--;
+
+    if (epslo>0.01*axe.GetBinWidth(ilo) || epsup>0.01*axe.GetBinWidth(iup))
+    {
+        *fLog << err << fName << "MHGamma : binning is not adequate for the requested projection:" << endl;
+        *fLog << "Please specify a lower or upper limit which is not more than 1% away from a bin edge" << endl;
+        *fLog << " epslo = " << epslo << endl;
+        *fLog << " epsup = " << epsup << endl;
+        *fLog << " dwl   = " << axe.GetBinWidth(ilo) << endl;
+        *fLog << " dwu   = " << axe.GetBinWidth(iup) << endl;
+        return NULL;
+    }
+
+    axe.SetRange(ilo, iup);
+
+    fLo = lo;
+    fHi = up;
+
+    if (fProject)
+        delete fProject;
+    fProject = (TH2D*)fHist->Project3D(fName+"_ezy");
+
+    const TString title = "2D-plot of ";
+    const TString titley = fHist->GetYaxis()->GetTitle();
+    const TString titlez = fHist->GetZaxis()->GetTitle();
+
+    fProject->SetTitle(title + titley + " vs. " + titlez);
+    fProject->SetXTitle(titley);
+    fProject->SetYTitle(titlez);
+
+    return fProject;
+}
+
+void MHGamma::DrawClone2() const
+{
+    if (!fProject)
+        return;
+
+    const TString titley = fHist->GetYaxis()->GetTitle();
+    const TString titlez = fHist->GetZaxis()->GetTitle();
+
+    TString canvtitle = "No.of Gammas ";//vs. ";
+    /*
+     canvtitle += titley;
+     canvtitle += " and ";
+     canvtitle += titlez;
+     */
+    canvtitle += Form("(%.1f < alpha < %.1f deg)", fLo, fHi);
+
+    TCanvas &c = *MakeDefCanvas("Gamma", canvtitle);
+
+    c.Divide(2, 2);
+
+    gROOT->SetSelectedPad(NULL);
+
+    TH1 *h;
+
+    c.cd(1);
+    h = fProject->ProjectionX(fName+"_xpro", -1, 9999, "E");
+    TString title = "No.of gammas: ";
+    h->SetTitle(title+titley);
+    h->SetXTitle(titley);
+    h->SetYTitle("Counts");
+
+    h->Draw();
+    h->SetBit(kCanDelete);
+    gPad->SetLogx();
+
+    c.cd(2);
+    h = fProject->ProjectionY(fName+"_ypro", -1, 9999, "E");
+    h->SetTitle(title+titlez);
+    h->SetXTitle(titlez);
+    h->SetYTitle("Counts");
+
+    h->Draw();
+    h->SetBit(kCanDelete);
+
+    c.cd(3);
+
+    fProject->DrawCopy();
+    gPad->SetLogx();
+
+    c.Modified();
+    c.Update();
+}
Index: /tags/Mars_V0-8-5/Mars/mhist/MHGamma.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHGamma.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHGamma.h	(revision 9661)
@@ -0,0 +1,46 @@
+#ifndef MARS_MHGamma
+#define MARS_MHGamma
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+class TH2D;
+class TH3D;
+
+class MHAlphaEnergyTheta;
+
+class MHGamma : public MH 
+{
+private:
+    TH3D *fHist;    //!
+    TH2D *fProject; //!
+
+    Axis_t fLo; //!
+    Axis_t fHi; //!
+
+public:
+    MHGamma(const TString &name="", const TString &title="");
+
+    TH3D *Subtract(const TH3D *h1, const TH3D *h2);
+
+    TH3D *Subtract(const MHAlphaEnergyTheta &h1, const MHAlphaEnergyTheta &h2);
+
+    TH2D *GetAlphaProjection(Axis_t lo, Axis_t up);
+
+    TObject *DrawClone(Option_t *opt="") const;
+    void DrawClone1() const;
+    void DrawClone2() const;
+
+    const TH2D *GetProject() const { return fProject; }
+
+    ClassDef(MHGamma, 0) // manipulation of alpha distributions
+};
+
+#endif
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mhist/MHHadronness.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHHadronness.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHHadronness.cc	(revision 9661)
@@ -0,0 +1,576 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 5/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Abelardo Moralejo <mailto:moralejo@pd.infn.it>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHHadronness
+//
+// This is histogram is a way to evaluate the quality of a gamma/hadron
+// seperation method. It is filled from a MHadronness container, which
+// stores a hadroness for the current event. The Value must be in the
+// range [0,1]. To fill the histograms correctly the information
+// whether it is a gamma or hadron (not a gamma) must be available from
+// a MMcEvt container.
+//
+// In the constructor you can change the number of used bns for the
+// evaluation.
+//
+// The meaning of the histograms (Draw, DrawClone) are the following:
+//  * Upper Left Corner:
+//    - black: histogram of all hadronesses for gammas
+//    - red:   histogram of all hadronesses for non gammas
+//  * Upper Right Corner:
+//    - black: acceptance of gammas (Ag) vs. the hadroness
+//    - red:   acceptance of non gammas (Ah) vs. the hadroness
+//  * Bottom Left Corner:
+//    Naive quality factor: Ag/sqrt(Ah)
+//  * Bottom Right Corner:
+//    - black: Acceprtance Gammas vs. Acceptance Hadrons
+//    - blue cross: minimum of distance to (0, 1)
+//
+// As a default MHHadronness searches for the container "MHadronness".
+// This can be overwritten by a different pointer specified in the
+// Fill function (No type check is done!) Use a different name in
+// MFillH.
+//
+// If you are using filtercuts which gives you only two discrete values
+// of the hadronness (0.25 and 0.75) you may want to use MHHadronness(2).
+// If you request Q05() from such a MHHadronness instance you will get
+// Acc_g/sqrt(Acc_h)
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MHHadronness.h"
+
+#include <TPad.h>
+#include <TGraph.h>
+#include <TStyle.h>
+#include <TCanvas.h>
+#include <TMarker.h>
+
+#include "MParList.h"
+#include "MBinning.h"
+#include "MHMatrix.h"
+#include "MHadronness.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MMcEvt.hxx"
+
+ClassImp(MHHadronness);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Setup histograms, nbins is the number of bins used for the evaluation.
+// The default is 100 bins.
+//
+MHHadronness::MHHadronness(Int_t nbins, const char *name, const char *title)
+    : fMatrix(NULL)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHHadronness";
+    fTitle = title ? title : "Gamma/Hadron Separation Quality Histograms";
+
+    fGraph = new TGraph;
+    fGraph->SetTitle("Acceptance Gammas vs. Hadrons");
+    fGraph->SetMarkerStyle(kFullDotSmall);
+
+    fGhness = new TH1D("Ghness", "Acceptance vs. Hadronness (Gammas)",  nbins, 0, 1);
+    fPhness = new TH1D("Phness", "Acceptance vs. Hadronness (Hadrons)", nbins, 0, 1);
+    fGhness->SetXTitle("Hadronness");
+    fPhness->SetXTitle("Hadronness");
+    fGhness->SetYTitle("Acceptance");
+    fPhness->SetYTitle("Acceptance");
+    fPhness->SetLineColor(kRed);
+    fGhness->SetDirectory(NULL);
+    fPhness->SetDirectory(NULL);
+    
+    fIntGhness = new TH1D("AccGammas",  "Integral Acceptance vs. Hadronness (Gammas)", nbins, 0, 1);
+    fIntPhness = new TH1D("AccHadrons", "Integral Acceptance vs. Hadronness (Hadrons)", nbins, 0, 1);
+    fIntGhness->SetXTitle("Hadronness");
+    fIntPhness->SetXTitle("Hadronness");
+    fIntGhness->SetYTitle("Acceptance");
+    fIntPhness->SetYTitle("Acceptance");
+    fIntGhness->SetMaximum(1.1);
+    fIntPhness->SetMaximum(1.1);
+    fIntGhness->SetDirectory(NULL);
+    fIntPhness->SetDirectory(NULL);
+    fIntPhness->SetLineColor(kRed);
+    fIntGhness->SetBit(TH1::kNoStats);
+    fIntPhness->SetBit(TH1::kNoStats);
+
+    fQfac = new TGraph;
+    fQfac->SetTitle(" Naive Quality factor ");
+    fQfac->SetMarkerStyle(kFullDotSmall);
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the histograms.
+//
+MHHadronness::~MHHadronness()
+{
+    delete fGhness;
+    delete fIntGhness;
+    delete fPhness;
+    delete fIntPhness;
+    delete fQfac;
+    delete fGraph;
+}
+
+// --------------------------------------------------------------------------
+//
+// Setup Filling of the histograms. It needs:
+//  MMcEvt and MHadronness
+//
+Bool_t MHHadronness::SetupFill(const MParList *plist)
+{
+    if (!fMatrix)
+    {
+        fMcEvt = (MMcEvt*)plist->FindObject(AddSerialNumber("MMcEvt"));
+        if (!fMcEvt)
+        {
+            *fLog << err << dbginf << AddSerialNumber("MMcEvt");
+            *fLog << " not found... aborting." << endl;
+            return kFALSE;
+        }
+    }
+
+    fHadronness = (MHadronness*)plist->FindObject("MHadronness");
+
+    fGhness->Reset();
+    fPhness->Reset();
+
+    /*
+     MBinning* bins = (MBinning*)plist->FindObject("BinningHadronness");
+     if (!bins)
+     {
+     *fLog << err << dbginf << "BinningHadronness [MBinning] not found... aborting." << endl;
+     return kFALSE;
+     }
+
+     SetBinning(&fHist, binsalpha, binsenergy, binstheta);
+
+     fHist.Sumw2();
+     */
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the Hadronness from a MHadronness container into the corresponding
+// histogram dependant on the particle id.
+//
+// Every particle Id different than kGAMMA is considered a hadron.
+//
+// If you call Fill with a pointer (eg. from MFillH) this container is
+// used as a hadronness (Warning: No type check is done!) otherwise
+// the default is used ("MHadronness")
+//
+// Sometimes a distance is calculated as NaN (not a number). Such events
+// are skipped at the moment.
+//
+Bool_t MHHadronness::Fill(const MParContainer *par, const Stat_t w)
+{
+    // Preliminary Workaround: FIXME!
+    if (!par && !fHadronness)
+    {
+        *fLog << err << "MHHadronness::Fill: No MHadronness container specified!" << endl;
+        return kFALSE;
+    }
+
+    const MHadronness &had = par ? *(MHadronness*)par : *fHadronness;
+
+    const Double_t h = had.GetHadronness();
+
+    if (TMath::IsNaN(h))
+        return kCONTINUE;
+
+    const Int_t particleid = fMatrix ? (Int_t)(*fMatrix)[fMap] : fMcEvt->GetPartId();
+
+    if (particleid==MMcEvt::kGAMMA)
+        fGhness->Fill(h, w);
+    else
+        fPhness->Fill(h, w);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the quality factor at gamma acceptance 0.5.
+//
+// If the histogram containes only two bins we return the
+// naive quality: ag/sqrt(ah)
+// with ag the acceptance of gammas and ah the acceptance of hadrons.
+//
+// You can use this (nbins=2) in case of some kind of filter cuts giving
+// only a result: gamma yes/no (means discrete values of hadronness 0.25
+// or 0.75)
+//
+// FIXME: In the later case weights cannot be used!
+//
+Float_t MHHadronness::GetQ05() const
+{
+    if (fGhness->GetNbinsX()==2)
+    {
+        // acceptance of all gamma-like gammas  (h<0.5)
+        const Double_t ig = fGhness->GetBinContent(1);
+
+        // acceptance of all gamma-like hadrons (h<0.5)
+        const Double_t ip = fPhness->GetBinContent(1);
+
+        if (ip==0)
+            return 0; // FIXME!
+
+        // naive quality factor
+        const Double_t q = ig / sqrt(ip);
+
+        *fLog << all << ip << "/" << ig << ": " << q << endl;
+
+        return q;
+    }
+
+    const Int_t n = fQfac->GetN();
+
+    Double_t val1x=0;
+    Double_t val2x=1;
+
+    Double_t val1y=0;
+    Double_t val2y=0;
+
+    for (Int_t i=1; i<=n; i++)
+    {
+        Double_t x, y;
+
+        fQfac->GetPoint(i, x, y);
+
+        if (x<0.5 && x>val1x)
+        {
+            val1x = x;
+            val1y = y;
+        }
+
+        if (x>0.5 && x<val2x)
+        {
+            val2x = x;
+            val2y = y;
+        }
+    }
+
+    //*fLog << dbg << val1x << "/" << val1y << "  " << val2x << "/" << val2y << endl;
+
+    return val2x-val1x == 0 ? 0 : val1y - (val2y-val1y)/(val2x-val1x) * (val1x-0.5);
+}
+
+// --------------------------------------------------------------------------
+//
+// Finalize the histograms:
+//  - integrate the hadroness histograms --> acceptance
+//  - fill the Minimum Distance histogram (formular see class description)
+//  - fill the Quality histogram (formular see class description)
+//
+void MHHadronness::CalcGraph(Double_t sumg, Double_t sump)
+{
+    Int_t n = fGhness->GetNbinsX();
+
+    fGraph->Set(n);
+    fQfac->Set(n);
+
+    // Calculate acceptances
+    Float_t max=0;
+
+    for (Int_t i=1; i<=n; i++)
+    {
+        const Stat_t ip = fPhness->Integral(1, i)/sump;
+        const Stat_t ig = fGhness->Integral(1, i)/sumg;
+
+        fIntPhness->SetBinContent(i, ip);
+        fIntGhness->SetBinContent(i, ig);
+
+        fGraph->SetPoint(i, ip, ig);
+
+        if (ip<=0)
+            continue;
+
+        const Double_t val = ig/sqrt(ip);
+        fQfac->SetPoint(i, ig, val);
+
+        if (val>max)
+            max = val;
+    }
+
+    fQfac->SetMaximum(max*1.05);
+}
+
+Bool_t MHHadronness::Finalize()
+{
+    const Stat_t sumg = fGhness->Integral();
+    const Stat_t sump = fPhness->Integral();
+
+    *fLog << inf << "Sum Hadronness: gammas=" << sumg << " hadrons=" << sump << endl;
+
+    // Normalize photon distribution
+    if (sumg>0)
+        fGhness->Scale(1./sumg);
+    else
+        *fLog << warn << "Cannot calculate hadronness for 'gammas'." << endl;
+
+    // Normalize hadron distribution
+    if (sump>0)
+        fPhness->Scale(1./sump);
+    else
+        *fLog << warn << "Cannot calculate hadronness for 'hadrons'." << endl;
+
+    CalcGraph(1, 1);
+
+    return kTRUE;
+}
+
+void MHHadronness::Paint(Option_t *opt)
+{
+    Stat_t sumg = fGhness->Integral();
+    Stat_t sump = fPhness->Integral();
+
+    // Normalize photon distribution
+    if (sumg<=0)
+        sumg=1;
+
+    // Normalize hadron distribution
+    if (sump<=0)
+        sump=1;
+
+    CalcGraph(sumg, sump);
+}
+
+// --------------------------------------------------------------------------
+//
+// Search the corresponding points for the given hadron acceptance (acchad)
+// and interpolate the tow points (linear)
+//
+Double_t MHHadronness::GetGammaAcceptance(Double_t acchad) const
+{
+    const Int_t n = fGraph->GetN();
+    const Double_t *x = fGraph->GetX();
+    const Double_t *y = fGraph->GetY();
+
+    Int_t i = 0;
+    while (i<n && x[i]<acchad)
+        i++;
+
+    if (i==0 || i==n)
+        return 0;
+
+    if (i==n-1)
+        i--;
+
+    const Double_t x1 = x[i-1];
+    const Double_t y1 = y[i-1];
+
+    const Double_t x2 = x[i];
+    const Double_t y2 = y[i];
+
+    return (y2-y1)/(x2-x1) * (acchad-x2) + y2;
+}
+
+// --------------------------------------------------------------------------
+//
+// Search the corresponding points for the given gamma acceptance (accgam)
+// and interpolate the tow points (linear)
+//
+Double_t MHHadronness::GetHadronAcceptance(Double_t accgam) const
+{
+    const Int_t n = fGraph->GetN();
+    const Double_t *x = fGraph->GetX();
+    const Double_t *y = fGraph->GetY();
+
+    Int_t i = 0;
+    while (i<n && y[i]<accgam)
+        i++;
+
+    if (i==0 || i==n)
+        return 0;
+
+    if (i==n-1)
+        i--;
+
+    const Double_t x1 = y[i-1];
+    const Double_t y1 = x[i-1];
+
+    const Double_t x2 = y[i];
+    const Double_t y2 = x[i];
+
+    return (y2-y1)/(x2-x1) * (accgam-x2) + y2;
+}
+
+// --------------------------------------------------------------------------
+//
+// Search the hadronness corresponding to a given hadron acceptance.
+//
+Double_t MHHadronness::GetHadronness(Double_t acchad) const
+{
+    for (int i=1; i<fIntPhness->GetNbinsX()+1; i++)
+        if (fIntPhness->GetBinContent(i)>acchad)
+            return fIntPhness->GetBinLowEdge(i);
+
+    return -1;
+}
+
+// --------------------------------------------------------------------------
+//
+// Print the corresponding Gammas Acceptance for a hadron acceptance of
+// 10%, 20%, 30%, 40% and 50%. Also the minimum distance to the optimum
+// acceptance and the corresponding acceptances and hadroness value is
+// printed, together with the maximum Q-factor.
+//
+void MHHadronness::Print(Option_t *) const
+{
+    *fLog << all;
+    *fLog << underline << GetDescriptor() << endl;
+
+    if (fGraph->GetN()==0)
+    {
+        *fLog << " <No Entries>" << endl;
+        return;
+    }
+
+    *fLog << "Used " << fGhness->GetEntries() << " Gammas and " << fPhness->GetEntries() << " Hadrons." << endl;
+    *fLog << "acc(hadron) acc(gamma) acc(g)/acc(h)  h" << endl <<endl;
+
+    *fLog << "    0.005    " << Form("%6.3f", GetGammaAcceptance(0.005)) << "      " << Form("%6.3f", GetGammaAcceptance(0.005)/0.005) << "      " << GetHadronness(0.005) << endl;
+    *fLog << "    0.02     " << Form("%6.3f", GetGammaAcceptance(0.02))  << "      " << Form("%6.3f", GetGammaAcceptance(0.02)/0.02)   << "      " << GetHadronness(0.02) << endl;
+    *fLog << "    0.05     " << Form("%6.3f", GetGammaAcceptance(0.05))  << "      " << Form("%6.3f", GetGammaAcceptance(0.05)/0.05)   << "      " << GetHadronness(0.05) << endl;
+    *fLog << "    0.1      " << Form("%6.3f", GetGammaAcceptance(0.1 ))  << "      " << Form("%6.3f", GetGammaAcceptance(0.1)/0.1)     << "      " << GetHadronness(0.1) << endl;
+    *fLog << "    0.2      " << Form("%6.3f", GetGammaAcceptance(0.2 ))  << "      " << Form("%6.3f", GetGammaAcceptance(0.2)/0.2)     << "      " << GetHadronness(0.2) << endl;
+    *fLog << "    0.3      " << Form("%6.3f", GetGammaAcceptance(0.3 ))  << "      " << Form("%6.3f", GetGammaAcceptance(0.3)/0.3)     << "      " << GetHadronness(0.3) << endl;
+    *fLog << Form("%6.3f", GetHadronAcceptance(0.1)) << "        0.1  " << endl;
+    *fLog << Form("%6.3f", GetHadronAcceptance(0.2)) << "        0.2  " << endl;
+    *fLog << Form("%6.3f", GetHadronAcceptance(0.3)) << "        0.3  " << endl;
+    *fLog << Form("%6.3f", GetHadronAcceptance(0.4)) << "        0.4  " << endl;
+    *fLog << Form("%6.3f", GetHadronAcceptance(0.5)) << "        0.5  " << endl;
+    *fLog << Form("%6.3f", GetHadronAcceptance(0.6)) << "        0.6  " << endl;
+    *fLog << Form("%6.3f", GetHadronAcceptance(0.7)) << "        0.7  " << endl;
+    *fLog << Form("%6.3f", GetHadronAcceptance(0.8)) << "        0.8  " << endl;
+    *fLog << endl;
+
+    *fLog << "Q-Factor @ Acc Gammas=0.5: Q(0.5)=" << Form("%.1f", GetQ05()) << endl;
+    *fLog << "  Acc Hadrons = " << Form("%5.1f", GetHadronAcceptance(0.5)*100) << "%" << endl;
+    *fLog << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw all histograms. (For the Meaning see class description)
+//
+void MHHadronness::Draw(Option_t *)
+{
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas("Hadronness", fTitle);
+    pad->SetBorderMode(0);
+
+    AppendPad("");
+
+    pad->Divide(2, 2);
+
+    TH1 *h;
+
+    pad->cd(1);
+    gPad->SetBorderMode(0);
+    //gStyle->SetOptStat(10);
+    MH::DrawSame(*fGhness, *fPhness, "Hadronness"); // Displ both stat boxes
+
+    pad->cd(2);
+    gPad->SetBorderMode(0);
+    gPad->SetGridx();
+    gPad->SetGridy();
+    fIntGhness->Draw();
+    fIntPhness->Draw("same");
+
+    pad->cd(3);
+    gPad->SetBorderMode(0);
+    gPad->SetGridx();
+    gPad->SetGridy();
+    fQfac->Draw("A*");
+    gPad->Modified();
+    gPad->Update();
+    if ((h=fQfac->GetHistogram()))
+    {
+        h->GetXaxis()->SetRangeUser(0, 1);
+        h->SetXTitle("Acceptance Gammas");
+        h->SetYTitle("Quality");
+        fQfac->Draw("P");
+        gPad->Modified();
+        gPad->Update();
+    }
+
+    pad->cd(4);
+    gPad->SetBorderMode(0);
+    gPad->SetGridx();
+    gPad->SetGridy();
+    fGraph->Draw("AC");
+    gPad->Modified();
+    gPad->Update();
+    if ((h=fGraph->GetHistogram()))
+    {
+        h->GetXaxis()->SetRangeUser(0, 1);
+        h->SetXTitle("Acceptance Hadrons");
+        h->SetYTitle("Acceptance Gammas");
+        fGraph->SetMaximum(1);
+        fGraph->Draw("P");
+        gPad->Modified();
+        gPad->Update();
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// You can use this function if you want to use a MHMatrix instead of
+// MMcEvt. This function adds all necessary columns to the
+// given matrix. Afterward you should fill the matrix with the corresponding
+// data (eg from a file by using MHMatrix::Fill). If you now loop
+// through the matrix (eg using MMatrixLoop) MHHadronness::Fill
+// will take the values from the matrix instead of the containers.
+//
+void MHHadronness::InitMapping(MHMatrix *mat)
+{
+    if (fMatrix)
+        return;
+
+    fMatrix = mat;
+
+    TString str = AddSerialNumber("MMcEvt");
+    str += ".fPartId";
+
+    fMap = fMatrix->AddColumn(str);
+}
+
+void MHHadronness::StopMapping()
+{
+    fMatrix = NULL; 
+}
Index: /tags/Mars_V0-8-5/Mars/mhist/MHHadronness.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHHadronness.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHHadronness.h	(revision 9661)
@@ -0,0 +1,64 @@
+#ifndef MARS_MHHadronness
+#define MARS_MHHadronness
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+class TH1D;
+class TGraph;
+class MParList;
+class MMcEvt;
+class MHadronness;
+class MHMatrix;
+
+class MHHadronness : public MH
+{
+private:
+    const MMcEvt *fMcEvt;           //!
+    const MHadronness *fHadronness; //!
+    MHMatrix *fMatrix;        //!
+    Int_t fMap;                     //!
+
+    TH1D* fPhness;    //-> Hadrons Hadronness
+    TH1D* fGhness;    //-> Gammas  Hadronness
+    TH1D* fIntPhness; //-> Hadrons Acceptance
+    TH1D* fIntGhness; //-> Gammas  Acceptance
+
+    TGraph *fQfac;    //-> Quality factor
+    TGraph *fGraph;   //-> gamma acceptance vs. hadron acceptance
+
+    void Paint(Option_t *opt="");
+    void CalcGraph(Double_t sumg, Double_t sump);
+
+public:
+    MHHadronness(Int_t nbins=100, const char *name=NULL, const char *title=NULL);
+    ~MHHadronness();
+
+    Double_t GetGammaAcceptance(Double_t acchad) const;
+    Double_t GetHadronAcceptance(Double_t accgam) const;
+    Double_t GetHadronness(Double_t acchad) const;
+
+    TH1D *Getghness() const  { return fGhness; }
+    TH1D *Getphness() const  { return fPhness; }
+    TH1D *Getighness() const { return fIntGhness; }
+    TH1D *Getiphness() const { return fIntPhness; }
+    //TH2D *GetHist() const    { return fHist; }
+
+    Float_t GetQ05() const;
+
+    Bool_t SetupFill(const MParList *plist);
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+    Bool_t Finalize();
+
+    void InitMapping(MHMatrix *mat);
+    void StopMapping();
+
+    void Print(Option_t *option="") const;
+
+    void Draw(Option_t *opt="");
+
+    ClassDef(MHHadronness, 1) // Gamma/Hadron Separation Quality Histograms
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mhist/MHOnSubtraction.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHOnSubtraction.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHOnSubtraction.cc	(revision 9661)
@@ -0,0 +1,1767 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without expressed
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Robert Wagner 9/2002 <mailto:rw@rwagner.de>
+!   Author(s): Robert Wagner 3/2003 <mailto:rw@rwagner.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MHOnSubtraction                                                         //
+//                                                                          //
+//                                                                          //
+//  extracts the gamma signal from a pure ON-signal given in an             //
+//  ALPHA-Energy-Theta histogram. The class will take this histogram from   //
+//  the parameter list and will provide result histograms in the            //
+//  parameter list.                                                         //
+//                                                                          //
+//  This class still is work in progress.                                   //
+//                                                                          //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+// This part of MARS is code still evolving. Please do not change the code 
+// without prior feedback by the author.
+
+#include "MHOnSubtraction.h"
+
+#include <TPaveText.h>
+#include <TPaveLabel.h>
+#include <TF1.h>
+#include <TLegend.h>
+#include <TCanvas.h>
+#include <TStyle.h>
+#include <TGraph.h>
+
+#include "MBinning.h"
+#include "MParList.h"
+#include "MHArray.h"
+#include "MH3.h"
+
+#include "MHAlphaEnergyTheta.h"
+#include "MHAlphaEnergyTime.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHOnSubtraction);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor.
+//
+MHOnSubtraction::MHOnSubtraction(const char *name, const char *title) : fMaxSignif(0),	fMaxRedChiSq(0), fSlope(20.0)
+{ 
+  fName  = name  ? name  : "MHOnSubtraction";
+  fTitle = title ? title : "Extracts Gamma signal from pure ON data";
+  fHistogramType = "Theta";
+  fChiSquareHisto=0;
+  fSignificanceHisto=0;
+  fSummedAlphaPlots=0;
+  fThetaBin=0;
+  
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Destructor.
+//
+MHOnSubtraction::~MHOnSubtraction()
+{ 
+  if (fChiSquareHisto) delete fChiSquareHisto;
+  if (fSignificanceHisto) delete fSignificanceHisto;
+  if (fSummedAlphaPlots) delete fSummedAlphaPlots;
+}
+
+// -----------------------------------------------------------------------
+//
+// Calculate Significance according to Li and Ma, ApJ 272 (1983) 317, eq
+// (17). n_{On}, n_{Off} and the ratio of On-times for On and Off 
+// measurements have to be provided.
+//
+// This function underestimates the true significance for it does not take
+// into account errors on the event numbers. A more accurate variation wil
+// be provided soon
+//
+Double_t MHOnSubtraction::CalcSignificance(Double_t nOn, Double_t nOff, Double_t theta)
+{ 
+  if (nOn<=0)
+    *fLog << warn << "Got " << nOn << " total events, " << flush;
+  if (nOff<=0)
+    *fLog << warn << "Got " << nOff << " background events, " << flush;
+  if (nOn<=0 || nOff<=0.0) {
+    *fLog << warn << "returning significance of 0.0" << endl;
+    return 0.0;
+  }
+  return sqrt(2*(nOn*log((1+theta)*nOn/(theta*(nOn+nOff)))
+		 +nOff*log((1+theta)*(nOff/(nOn+nOff)))));
+}
+
+// -----------------------------------------------------------------------
+//
+// This function takes a first look at a given ALPHA distribution
+// and determines if a fit is applicable.
+//
+// Fits a given TH1 containing an ALPHA distribution with a combined
+// gaussian plus polynomial of third grade and returns the fitted 
+// function. By signalRegionFactor the width of the region in which
+// signal extraction is to be performed can be specified in units of
+// sigma of the gaussian which is fitted to the distribution (default: 
+// 3.5). Accordingly, FitHistogram returns the range in which it suggests 
+// signal extraction (lowerBin < ALPHA < upperBin). An estimated 
+// significance of the signal is also provided. draw specifies whether
+// FitHistogram should draw the distribution.
+//
+Bool_t MHOnSubtraction::FitHistogram(TH1 &alphaHisto, Double_t &sigLiMa,
+			       Double_t &lowerBin, Double_t &upperBin,
+			       Float_t signalRegionFactor, const Bool_t draw,
+			       TString funcName)
+{
+  if (alphaHisto.GetEntries() == 0) {
+    *fLog << warn << "Histogram contains no entries. Returning. " << endl;
+    lowerBin=0;
+    upperBin=0;
+    sigLiMa=0;    
+    if (draw) {
+      TPaveLabel* lab = new TPaveLabel(0.1,0.2,0.9,0.8,"(no events)");
+      lab->SetFillStyle(0);
+      lab->SetBorderSize(0);
+      lab->Draw();  
+    }
+    return kFALSE;
+  }
+  
+  //cosmetics
+  alphaHisto.GetXaxis()->SetTitle("ALPHA");
+  alphaHisto.GetYaxis()->SetTitle("events");
+
+  Double_t outerEvents = 0.0;
+  Double_t innerEvents = 0.0;
+  Int_t outerBins = 0;
+  Int_t innerBins = 0;
+  Int_t outerBinsZero = 0;
+  Int_t innerBinsZero = 0;
+
+  for (Int_t alphaBin = 1; alphaBin < alphaHisto.GetNbinsX(); alphaBin++) {
+    if ((alphaHisto.GetBinLowEdge(alphaBin) >= -35.)&& //inner Region
+  	(alphaHisto.GetBinLowEdge(alphaBin+1) <= 35.0)) {
+      innerEvents+=alphaHisto.GetBinContent(alphaBin);
+      innerBins++;
+      if (alphaHisto.GetBinContent(alphaBin)==0.0)
+  	innerBinsZero++;     
+    } else {
+      if ((alphaHisto.GetBinLowEdge(alphaBin) >= -89.5)&& //outer Region
+	  (alphaHisto.GetBinLowEdge(alphaBin+1) <=89.5)) {
+	outerEvents+=alphaHisto.GetBinContent(alphaBin);
+	outerBins++;
+	if (alphaHisto.GetBinContent(alphaBin)==0.0)
+	  outerBinsZero++;     
+      }
+    }
+  }
+
+   *fLog << dbg << "Plot contains " << 
+     outerEvents << " outer ev (" << outerEvents/outerBins << "/bin), " <<
+     innerEvents << " inner ev (" << innerEvents/innerBins << "/bin) " << endl;
+
+  if ((outerBinsZero!=0) || (innerBinsZero != 0))
+    *fLog << warn << "There are ";
+  if (outerBinsZero != 0)
+    *fLog << dbg << outerBinsZero << " empty outer bins ";
+  if (innerBinsZero != 0)
+    *fLog << dbg <<innerBinsZero << " empty inner bins ";
+  if ((outerBinsZero!=0) || (innerBinsZero != 0))
+    *fLog << endl;
+
+  if (outerEvents == 0.0) {
+     *fLog << warn << "No events in OFF region. Assuming background = 0" 
+	   << endl;
+     TF1 *po = new TF1("pol0"+funcName,"pol0(0)",-89.5,89.5);
+     po->SetLineWidth(2);
+     po->SetLineColor(2);
+     po->SetParNames("c");
+     po->SetParameter(0,0.0);
+     alphaHisto.GetListOfFunctions()->Add(po);
+     alphaHisto.SetLineColor(97);
+     if (draw) {
+       alphaHisto.DrawCopy(); //rwagner
+       po->Draw("SAME");
+     }
+     sigLiMa = 0;
+     lowerBin = 1;
+     upperBin = alphaHisto.GetNbinsX()-1;
+     signalRegionFactor = 0;
+    
+     return kFALSE; //No gaus fit applied
+  }
+
+  if (outerEvents/outerBins < 2.5) {
+    *fLog << warn << "Only " << /*setprecision(2) <<*/ outerEvents/outerBins 
+	  << " events/bin in OFF region: "
+	  << "Assuming this as background." << endl;
+   
+     TF1 *po = new TF1("pol0"+funcName,"pol0(0)",-89.5,89.5);
+     po->SetLineWidth(2);
+     po->SetLineColor(94);
+     po->SetParNames("c");
+     po->SetParameter(0,outerEvents/outerBins);
+     alphaHisto.GetListOfFunctions()->Add(po);    
+     if (draw) {
+       alphaHisto.DrawCopy(); //rwagner
+       po->Draw("SAME");
+     }
+    
+     Int_t centerBin = alphaHisto.GetXaxis()->FindBin((Double_t)0.0);
+     Int_t maxBin    = centerBin > alphaHisto.GetNbinsX() - centerBin ? 
+       alphaHisto.GetNbinsX()- centerBin : centerBin;
+     
+     Int_t lowerSignalEdge = centerBin;
+     for (Int_t i=3; i < maxBin; i++) {
+       if ((Double_t)alphaHisto.GetBinContent(centerBin-i) 
+	   < outerEvents/outerBins) {
+	 lowerSignalEdge = centerBin-i+1;
+	 break;
+       }
+     }
+     if (centerBin<lowerSignalEdge) lowerSignalEdge=centerBin;
+
+     Int_t upperSignalEdge = centerBin;
+     for (Int_t i=3; i < maxBin; i++) {
+       if ((Double_t)alphaHisto.GetBinContent(centerBin+i) 
+	   <= outerEvents/outerBins) {
+	 upperSignalEdge=centerBin+i-1;
+	 break;
+       } 
+     }
+     if (centerBin>upperSignalEdge) upperSignalEdge=centerBin;
+
+     Double_t nOnInt = 0;
+     for (Int_t i=1; i < alphaHisto.GetNbinsX(); i++)
+       nOnInt += alphaHisto.GetBinContent(i) - outerEvents/outerBins;
+     
+     Double_t nOffInt = (upperSignalEdge - lowerSignalEdge + 1) 
+       * (outerEvents/outerBins);
+     
+     sigLiMa = CalcSignificance(nOnInt, nOffInt, 1);
+
+     if (sigLiMa < 3) 
+       alphaHisto.SetLineColor(2);   
+
+   
+     *fLog << inf << "Estimated significance is " << sigLiMa 
+	   << " sigma " << endl;   
+     *fLog << inf << "Signal region is " 
+	   << lowerBin << " < ALPHA < " << upperBin 
+	   << " (Most likely you wanna ignore this)" << endl;
+
+     return kFALSE; //No gaus fit applied    
+  }
+  
+  //fit combined gaus+pol3 to data
+  TF1 *gp = new TF1("gauspol3"+funcName,"gaus(0)+pol3(3)",-89.5,89.5);
+  gp->SetLineWidth(2);
+  gp->SetLineColor(2);
+  gp->SetParNames("Excess","A","sigma","a","b","c","d");
+  gp->SetParLimits(0, 200,2000); 
+  gp->SetParLimits(1, -4.,4.); 
+  gp->SetParLimits(2, 2.,20.);
+  // gp->SetParameter(6,  0.0000); // include for slope(0)=0 constrain
+  TString gpDrawOptions = draw ? "RIQ" : "RIQ0";
+  gpDrawOptions = "RIQ0"; // rwagner
+  alphaHisto.Fit("gauspol3"+funcName,gpDrawOptions);
+  alphaHisto.DrawCopy(); //rwagner
+  alphaHisto.SetDirectory(NULL); //rwagner
+  
+  Double_t gausMean  = gp->GetParameter(1);
+  Double_t gausSigma = gp->GetParameter(2);
+
+//   TF1 *p3 = new TF1("p3"+funcName,"pol3(0)",-signalRegionFactor*gausSigma+gausMean,
+// 		    signalRegionFactor*gausSigma+gausMean);
+  TF1 *p3 = new TF1("p3"+funcName,"pol3(0)",-100,
+		    100);
+  p3->SetParameters(gp->GetParameter(3),gp->GetParameter(4),
+		    gp->GetParameter(5),gp->GetParameter(6));
+  // p3->SetLineStyle(2);
+  p3->SetLineColor(4);
+  p3->SetLineWidth(1);
+  if (draw) p3->Draw("SAME");   
+   
+  TF1 *ga = new TF1("ga"+funcName,"gaus(0)",-40,40);
+  ga->SetParameters(gp->GetParameter(0),gp->GetParameter(1),gp->GetParameter(2));
+  ga->SetLineColor(93);
+  ga->SetLineWidth(2);
+  //  if (draw) ga->Draw("SAME");
+
+  // identify the signal region: signalRegionFactor*gausSigma
+  // this allows us to
+  // (1) determine n_{ON}, n_{OFF}
+  Double_t scalingFactor = 
+    (alphaHisto.GetXaxis()->GetBinLowEdge(alphaHisto.GetNbinsX()+1)
+     - alphaHisto.GetXaxis()->GetBinLowEdge(1)) / alphaHisto.GetNbinsX();
+  
+  Double_t nOnInt  = (gp->Integral(-signalRegionFactor*gausSigma+gausMean, 
+				 signalRegionFactor*gausSigma+gausMean) / scalingFactor);
+  Double_t nOffInt = (p3->Integral(-signalRegionFactor*gausSigma+gausMean, 
+				 signalRegionFactor*gausSigma+gausMean) / scalingFactor);
+
+  // (2) determine the signal region from fit in degrees
+  // we do it a bit more complicated: assuming that the binning in all 
+  // histograms is the same, we want to be sure that summing up is always
+  // done over the same bins.
+
+  lowerBin = alphaHisto.GetXaxis()->FindBin(-signalRegionFactor*gausSigma+gausMean);
+  upperBin = alphaHisto.GetXaxis()->FindBin( signalRegionFactor*gausSigma+gausMean);
+
+  lowerBin = alphaHisto.GetBinLowEdge((Int_t)lowerBin);
+  upperBin = alphaHisto.GetBinLowEdge((Int_t)upperBin)+alphaHisto.GetBinWidth((Int_t)upperBin);
+  
+  sigLiMa = CalcSignificance(nOnInt, nOffInt, 1);
+//   if (sigLiMa < 3)
+//     alphaHisto.SetLineColor(2);   
+
+
+  *fLog << inf << "Fit estimates significance to be " 
+	<< sigLiMa << " sigma " << endl; 
+
+  *fLog << inf << "Fit yields signal region to be " 
+	<< lowerBin << " < ALPHA < " << upperBin
+	<< " (Chisquare/dof=" << gp->GetChisquare()/gp->GetNDF() 
+	<< ", prob="  <<  gp->GetProb() << ")" << endl;
+
+  return kTRUE; //returning gaus fit
+}
+
+
+
+
+
+// -----------------------------------------------------------------------
+//
+// Does the actual extraction of the gamma signal. For performance 
+// reasons, fits already done by MHOnSubtraction::FitHistogram are used 
+// and not redone.
+// From it, a polynomial function for the background is evaluated and the
+// gamma signal is extracted in the region given by lowerBin < ALPHA < 
+// upperBin.
+// Significance of the signal is also provided. draw specifies whether
+// FitHistogram should draw the distribution.
+//
+Bool_t MHOnSubtraction::ExtractSignal(TH1 &alphaHisto, Double_t &sigLiMa,
+   Double_t &lowerBin, Double_t &upperBin,
+   Double_t &gammaSignal, Double_t &errorGammaSignal,
+   Double_t &off, Double_t &errorOff,
+   Float_t signalRegionFactor, const Bool_t draw, TString funcName,
+   TPad *drawPad, Int_t drawBase)
+{
+  TF1 *gausPol = alphaHisto.GetFunction("gauspol3"+funcName);
+  TF1 *pol = alphaHisto.GetFunction("pol0"+funcName);
+  
+  if (!gausPol && !pol) {
+    *fLog << err << "Fatal: ALPHA histogram has no gauspol or pol "  
+	  << " fit attached to it." << endl;
+    TPaveLabel* lab = new TPaveLabel(0.1,0.2,0.9,0.8,"(no fit)");
+    lab->SetFillStyle(3000);
+    lab->SetBorderSize(0);
+    lab->DrawClone();  
+    lab->SetBit(kCanDelete);
+    return kFALSE;
+  } 
+
+  TF1* po;
+  po = NULL;
+
+  if (gausPol) {
+    Double_t gausMean  = gausPol->GetParameter(1);
+    Double_t gausSigma = gausPol->GetParameter(2);
+    po = new TF1("po"+funcName,"pol3(0)",
+		  -signalRegionFactor*gausSigma+gausMean,
+		  signalRegionFactor*gausSigma+gausMean);
+    po->SetParameters(gausPol->GetParameter(3),gausPol->GetParameter(4),
+		      gausPol->GetParameter(5),gausPol->GetParameter(6));
+
+    TF1 *ga = new TF1("ga"+funcName,"gaus(0)",-40,40);
+    ga->SetParameters(gausPol->GetParameter(0),gausPol->GetParameter(1),
+		      gausPol->GetParameter(2));
+    
+    if (draw) {
+      alphaHisto.Draw();
+      gausPol->Draw("SAME"); //Maybe not even necessary?
+      
+      po->SetLineColor(4);
+      po->SetLineWidth(2);
+      po->Draw("SAME");   
+      
+      ga->SetLineColor(93);
+      ga->SetLineWidth(2);    
+      ga->Draw("SAME");   
+      
+      char legendTitle[80];
+      sprintf(legendTitle, "Signal region: %2.1f < #alpha < %2.1f", 
+	      lowerBin, upperBin);
+      
+      TLegend *legend = new TLegend(0.13, 0.52, 0.47, 0.72, legendTitle);
+      
+      legend->SetBorderSize(0);
+      legend->SetFillColor(10);
+      legend->SetFillStyle(0);
+      legend->AddEntry(gausPol, "combined N_{on}","l");
+      legend->AddEntry(po,"polynomial N_{bg} Signal region","l");
+      legend->AddEntry(ga, "putative gaussian N_{S}","l");
+      legend->Draw();
+    }
+  } // gausPol
+
+
+  if (pol) {
+    po = pol;
+    
+    if (draw) {
+      alphaHisto.Draw();
+      
+      po->SetLineColor(6);
+      po->SetLineWidth(2);
+      po->Draw("SAME");   
+            
+      char legendTitle[80];
+      sprintf(legendTitle, "Signal region: %2.1f < #alpha < %2.1f", 
+	      lowerBin, upperBin);
+      
+      TLegend *legend = new TLegend(0.13, 0.52, 0.47, 0.72, legendTitle);
+      
+      legend->SetBorderSize(0);
+      legend->SetFillColor(10);
+      legend->SetFillStyle(0);
+      legend->AddEntry(po,"polynomial N_{bg} Signal region","l");
+      legend->Draw();
+    }
+  } // pol
+    
+  Double_t nOn = 0;
+  Double_t eNOn = 0;
+
+  Int_t binNumberLow = alphaHisto.GetXaxis()->FindBin(lowerBin);
+  Int_t binNumberHigh = alphaHisto.GetXaxis()->FindBin(upperBin);
+  
+  for (Int_t bin=binNumberLow; bin<binNumberHigh+1; bin++) {
+    nOn += alphaHisto.GetBinContent(bin);
+    eNOn += alphaHisto.GetBinError(bin) * alphaHisto.GetBinError(bin);
+  } //for bin
+  eNOn = sqrt(eNOn);
+     
+  // Evaluate background
+  
+  Double_t nOff = 0;
+  Double_t eNOff = 0;
+  for (Int_t bin=binNumberLow; bin<binNumberHigh+1; bin++) {
+    Double_t x = .5*(alphaHisto.GetBinLowEdge(bin)+alphaHisto.GetBinLowEdge(bin+1));
+    Double_t offEvts = po->Eval(x);
+    //cout << bin << ": " << offEvts << endl;
+    nOff += offEvts;
+  } //for bin
+  eNOff = sqrt(fabs(nOff));
+  
+  if (nOn==0)   // there should not be a negative number of signal events
+    nOff=0;
+  
+  if (nOff<0) { // there should not be a negative number of off events
+    nOff=0;
+    eNOff=0;
+  }
+    
+  *fLog << inf << "nEvts = " << nOn << "+-" << eNOn << ", ";
+
+  off = nOff;              errorOff = eNOff;
+  gammaSignal = nOn-nOff;  errorGammaSignal = sqrt(eNOn*eNOn + eNOff*eNOff); 
+
+  *fLog << inf << "nBack = " << nOff << "+-" << eNOff << ", ";
+  *fLog << inf << "nSig = " << gammaSignal << "+-" << errorGammaSignal << endl;
+
+  sigLiMa = CalcSignificance(nOn, nOff, 1);  
+  //  Double_t sigFit=(ga->GetParameter(1))/(ga->GetParError(1)); //Mean / sigMean
+  
+  *fLog << inf << "Significance: "<<sigLiMa<<" sigma "<<endl;
+
+  if (draw) { 
+    TPaveText *pt = new TPaveText(0.11,.74,.57,.88,"NDC ");
+    char tx[60];
+    sprintf(tx, "Excess: %2.2f #pm %2.2f", nOn-nOff, sqrt(eNOn*eNOn + eNOff*eNOff));
+    pt->AddText(tx);
+    sprintf(tx, "Off:    %2.2f #pm %2.2f", nOff, eNOff);
+    pt->AddText(tx);
+    sprintf(tx, "Significance: %2.2f   #sigma", sigLiMa);
+    pt->AddText(tx);
+    pt->SetFillStyle(0);
+    pt->SetBorderSize(0);
+    pt->SetTextAlign(12);
+    pt->Draw("");
+  }  
+  if (draw||drawPad) {
+
+    // Plot significance vs alpha_cut
+    
+    Int_t centerBin = alphaHisto.GetXaxis()->FindBin((Double_t)0.0);
+    Int_t maxBin    = centerBin > alphaHisto.GetNbinsX()- centerBin ? 
+      alphaHisto.GetNbinsX()- centerBin : centerBin;
+         
+    const Int_t totalBins = centerBin;
+    Float_t alpha[totalBins];
+    Float_t signi[totalBins];
+    Float_t maxSigni = 0;
+    
+    for (Int_t i=0; i < maxBin; i++) {
+      Double_t nOn = 0;  Double_t eNOn = 0;
+      Double_t nOff = 0; Double_t eNOff = 0;
+      for (Int_t bin=centerBin-i; bin<centerBin+i+1; bin++) {
+	nOn += alphaHisto.GetBinContent(bin);
+	eNOn += alphaHisto.GetBinError(bin) * alphaHisto.GetBinError(bin);
+	Double_t x = .5*(alphaHisto.GetBinLowEdge(bin)+alphaHisto.GetBinLowEdge(bin+1));
+	Double_t offEvts = po->Eval(x);
+	nOff += offEvts;
+      } //for bin
+      eNOn = sqrt(eNOn);
+      eNOff = sqrt(nOff);  
+      alpha[i] = 
+	(alphaHisto.GetXaxis()->GetBinLowEdge(centerBin+i+1)-
+	 alphaHisto.GetXaxis()->GetBinLowEdge(centerBin-i))/2;
+      signi[i] = CalcSignificance(nOn, nOff, 1);  
+      maxSigni = maxSigni > signi[i] ? maxSigni : signi[i];
+    }
+
+    if (!drawPad) {
+      TCanvas *c3 = new TCanvas("c3"+funcName, "Significance vs ALPHA cut", 800,600);
+      c3->cd();
+    }
+
+    if (drawPad) 
+      drawPad->cd(drawBase-1);
+    
+    TGraph* gr = new TGraph(totalBins-2,alpha,signi);
+    TString drawOpt = "L";
+    
+    if (draw || (drawPad && fSigniPlotIndex == 0))
+      drawOpt += "A";
+    
+    gr->Draw(drawOpt);
+    if (drawPad && fSigniPlotIndex == 0) {
+      gr->GetXaxis()->SetTitle("|#alpha_{max}|");
+      gr->GetYaxis()->SetTitle("Significance");
+    }
+    gr->SetMarkerStyle(2);
+    gr->SetMarkerSize(1);
+    gr->SetMarkerColor(4+fSigniPlotIndex);
+    gr->SetLineColor(4+fSigniPlotIndex);
+    gr->SetLineWidth(1);
+    gr->SetTitle("Significance vs ALPHA integration range");
+    gr->Draw("L");
+
+    fSigniPlotIndex++;      
+    
+  } //draw
+
+  return kTRUE;
+}
+
+// -----------------------------------------------------------------------
+//
+// Extraction of Gamma signal is performed on a MHAlphaEnergyTheta or 
+// MHAlphaEnergyTime object expected in the ParList.
+//
+Bool_t MHOnSubtraction::Calc(MParList *parlist, const Bool_t Draw)
+{
+  //Find source histograms
+  fHistogramType = "Theta";
+  MHAlphaEnergyTheta* mhisttheta = (MHAlphaEnergyTheta*)parlist->FindObject("MHAlphaEnergyTheta"); 
+  if (mhisttheta) return Calc((TH3D*)mhisttheta->GetHist(), parlist, Draw);
+
+  fHistogramType = "Time";
+  MHAlphaEnergyTime* mhisttime = (MHAlphaEnergyTime*)parlist->FindObject("MHAlphaEnergyTime");  
+  if (mhisttime) return Calc((TH3D*)mhisttime->GetHist(), parlist, Draw);
+
+  *fLog << err << "No MHAlphaEnergyTheta type object found in the parameter list. Aborting." << endl;
+  return kFALSE; 
+}
+
+// -----------------------------------------------------------------------
+//
+// Extraction of Gamma signal is performed on a TH3D histogram in
+// ALPHA, Energy and Theta.
+//
+Bool_t MHOnSubtraction::CalcAET(TH3D *aetHisto, MParList *parlist, const Bool_t Draw)
+{
+  // Analyze aetHisto
+  // -------------------------------------
+  Int_t alphaBins =  aetHisto->GetNbinsX();  // # of alpha bins 
+  Int_t energyBins = aetHisto->GetNbinsY();  
+  Int_t thetaBins =  aetHisto->GetNbinsZ();  
+  
+  // We output an array of histograms to the parlist.
+  // Create a template for such a histogram, needed by MHArray
+  // -------------------------------------
+  MBinning *binsfft = new MBinning("BinningMH3X");
+  binsfft->SetEdgesLog(energyBins,aetHisto->GetYaxis()->GetBinLowEdge(1),
+		aetHisto->GetYaxis()->GetBinLowEdge(energyBins+1));
+  parlist->AddToList(binsfft);  
+  MH3 *energyHistogram = new MH3(1); // The template histogram in energy
+                                     // for a given theta value
+  energyHistogram->SetName("MHOnSubtractionEnergyHistogramTemplate");
+  parlist->AddToList(energyHistogram);
+
+  fThetaHistoArray = new MHArray("MHOnSubtractionEnergyHistogramTemplate", kTRUE, 
+				 "MHOnSubtractionGammaSignalArray", 
+				 "Array of histograms in energy bins");
+  fThetaHistoArray->SetupFill(parlist);
+  parlist->AddToList(fThetaHistoArray);
+  
+  // Canvases---direct debug output for the time being
+  // -------------------------------------
+  TCanvas *c3 = new TCanvas("c3", "Plots by MHOnSubtraction::ExtractSignal", 800,600);
+  cout << thetaBins << " x " << energyBins << endl;
+  c3->Divide(thetaBins,energyBins);
+
+  TCanvas *c4a = new TCanvas("c4a", "Energy distributions for different ZA", 800,600);
+  
+  TH1D* histalphaon[energyBins*thetaBins]; // ALPHA histograms
+
+  fChiSquareHisto = new TH1D("fChiSquareHisto", "#chi^{2}/d.o.f. of fits", 50, 0, 5);
+  fSignificanceHisto = new TH1D("fSignificanceHisto", "Significances", 41, -0.5, 40.5);
+  fSummedAlphaPlots = new TH1D("fSummedAlphaPlots", "Cumulative Alpha", 
+			       alphaBins,aetHisto->GetXaxis()->GetBinLowEdge(1),
+			       aetHisto->GetXaxis()->GetBinLowEdge(alphaBins+1));
+  
+  // -------------------------------------
+
+  fThetaLegend = new TLegend(0.83, 0.07, 0.98, 0.42, "Energy Distributions");  
+  fThetaLegend->SetBorderSize(1);
+  
+  Double_t overallSigLiMa = 0;
+
+  for (Int_t thetaBin = 1; thetaBin < thetaBins+1; thetaBin++) {
+    
+    char hname[80];  
+    sprintf(hname, "Energy distribution for %s bin %d", fHistogramType.Data(), 
+	    thetaBin);
+    *fLog << all << "Calculating " << hname << endl;
+
+    Double_t minLowerBin = -10; // minimum integration range
+    Double_t maxUpperBin =  10; // minimum integration range
+    Double_t maxAlpha =  70; // maximum integration range
+
+    Double_t sumSigLiMa = 0;
+    
+    // This loop just fixes the integration range
+    // And alerts when no significant excess is found.
+
+    for (Int_t energyBin = 1; energyBin < energyBins+1; energyBin++) {
+
+      sprintf(hname, "histalphaon%d", (thetaBin-1)*(energyBins)+energyBin);
+      histalphaon[(thetaBin-1)*(energyBins)+energyBin] = 
+	new TH1D(hname, "ALPHA histogram",
+		 alphaBins,aetHisto->GetXaxis()->GetBinLowEdge(1),
+		 aetHisto->GetXaxis()->GetBinLowEdge(alphaBins+1));
+      histalphaon[(thetaBin-1)*(energyBins)+energyBin]->Sumw2();    
+      histalphaon[(thetaBin-1)*(energyBins)+energyBin]->SetTitle(hname);
+     
+      sprintf(hname,"ALPHA distribution for E bin %d, theta bin %d",
+	      energyBin, thetaBin);
+      *fLog << inf << hname << endl;
+
+      // now we fill one histogram for one particular set
+      // of Energy and Theta...
+      
+      if (aetHisto->InheritsFrom("TH3D")||aetHisto->InheritsFrom("TH2D")) {
+	aetHisto->GetYaxis()->SetRange(energyBin,energyBin); // E
+	if (aetHisto->InheritsFrom("TH3D"))
+	  aetHisto->GetZaxis()->SetRange(thetaBin,thetaBin); // theta
+	histalphaon[(thetaBin-1)*(energyBins)+energyBin] = (TH1D*)aetHisto->Project3D("xe");
+      } else {
+	histalphaon[(thetaBin-1)*(energyBins)+energyBin] = (TH1D*)aetHisto;
+      }
+
+      *fLog << inf << "This histogram has " 
+	    << histalphaon[(thetaBin-1)*(energyBins)+energyBin]->GetEntries()
+	    << " entries" << endl;
+
+      sprintf(hname, "histalphaon%d", (thetaBin-1)*(energyBins)+energyBin);
+      histalphaon[(thetaBin-1)*(energyBins)+energyBin]->SetName(hname);
+      
+      // Test: Find signal region and significance in histogram
+      Double_t lowerBin, upperBin, sSigLiMa;
+      FitHistogram(*histalphaon[(thetaBin-1)*(energyBins)+energyBin],
+		   sSigLiMa, lowerBin, upperBin, (Float_t)3.5, kFALSE);
+
+      Double_t redChiSq = histalphaon[(thetaBin-1)*(energyBins)+energyBin]->GetFunction("gauspol3")->GetChisquare()/histalphaon[(thetaBin-1)*(energyBins)+energyBin]->GetFunction("gauspol3")->GetNDF();
+
+      fChiSquareHisto->Fill(redChiSq);
+      fMaxRedChiSq = redChiSq > fMaxRedChiSq ? redChiSq : fMaxRedChiSq;
+
+      // histalphaon[(thetaBin-1)*(energyBins)+energyBin]->GetFunction("gauspol3")->GetProb() <<endl;
+
+      fSummedAlphaPlots->Add(histalphaon[(thetaBin-1)*(energyBins)+energyBin], 1);
+      
+      if (sSigLiMa < 3)
+	*fLog << inf << "No significant excess for this bin (sigma="<< sSigLiMa <<")!"<<endl;
+      sumSigLiMa+=sSigLiMa;
+   
+      // Evaluate integration range
+
+      lowerBin = (lowerBin < -maxAlpha) ? -maxAlpha : lowerBin;
+      minLowerBin = (lowerBin < minLowerBin) ? lowerBin : minLowerBin;
+
+      upperBin = (upperBin > maxAlpha) ? maxAlpha : upperBin;
+      maxUpperBin = (upperBin > maxUpperBin) ? upperBin : maxUpperBin;
+
+    } //energyBin
+    
+    *fLog << inf << "Integration range for this " << fHistogramType 
+	  << " value will be " << minLowerBin << " < ALPHA < "
+	  << maxUpperBin << endl;
+    
+    *fLog << inf << "Summed estd. significance for this " << fHistogramType 
+	  << " value is " << sumSigLiMa << endl;
+
+    // Create Histogram in Energy for this Theta value
+    cout << "STARTIGN REAL CALC1 "<< endl;
+    fThetaHistoArray->AddHistogram();
+    cout << "STARTIGN REAL CALC1a "<< endl;
+    fThetaHistoArray->SetIndex(thetaBin-1);
+    
+    MH3 &mThetaHisto = *(MH3*)(fThetaHistoArray->GetH());
+    mThetaHisto.Print();
+   
+    TH1D &thetaHisto = (TH1D&)(mThetaHisto.GetHist());
+    sprintf(hname,"Energy distribution for theta bin %d", thetaBin);
+    thetaHisto.SetTitle(hname);
+    thetaHisto.SetEntries(0);
+      
+    // we have a rough idea of what is going on in the ALPHA plot...
+    // So now we can indeed extract the signal.
+         
+//     cout << "STARTIGN REAL CALC "<< endl;
+
+    sumSigLiMa = 0;
+    for (Int_t energyBin = 1; energyBin < energyBins+1; energyBin++) {
+
+      sprintf(hname,"ALPHA distribution for E bin %d, theta bin %d",
+	      energyBin, thetaBin);
+      *fLog << inf << hname << endl;
+  
+      Double_t gammaSignal, errorGammaSignal, off, errorOff, sigLiMa;
+
+      c3->cd((thetaBin-1)*(energyBins)+energyBin);
+  
+      ExtractSignal(*histalphaon[(thetaBin-1)*(energyBins)+energyBin],
+		    sigLiMa, minLowerBin, maxUpperBin, 
+		    gammaSignal, errorGammaSignal, 
+		    off, errorOff, (Float_t)3, kTRUE);
+      
+      fSignificanceHisto->Fill(sigLiMa);
+      fMaxSignif = sigLiMa > fMaxSignif ? sigLiMa : fMaxSignif;
+
+      thetaHisto.SetBinContent(energyBin, gammaSignal*TMath::Exp(7-energyBin));
+      thetaHisto.SetBinError(energyBin, errorGammaSignal);
+      thetaHisto.SetEntries(thetaHisto.GetEntries()+gammaSignal);
+     
+      sumSigLiMa += sigLiMa;
+      
+    }//energyBin
+
+    *fLog << inf << "Summed significance for this " << fHistogramType 
+	  << " value is " << sumSigLiMa << endl;
+
+    //fit exponential function to data
+    TF1* e = new TF1("expF","expo",0,5);
+    e->SetLineWidth(3);
+    e->SetLineColor(thetaBin);
+    // e->SetParLimits(1, -0.5,3); //limits on slope
+    
+     if (fSlope!=20.0) {
+       e->SetParameter(1, fSlope);
+       *fLog << inf << "Fixing slope to " << e->GetParameter(1) << endl;
+     }
+
+    TString eDrawOptions = Draw ? "RIQ" : "RIQ0";
+    cout << "doing the fit" << endl;
+    thetaHisto.Fit("expF");
+    
+    Double_t expoSlope = e->GetParameter(1);
+    
+    *fLog << inf << "Determined slope for energy distribution is " 
+	  << expoSlope << endl;
+
+    Double_t integralEvts =
+      e->Integral(aetHisto->GetYaxis()->GetBinLowEdge(1), 
+		  aetHisto->GetYaxis()->GetBinLowEdge(energyBins+1));
+    
+    *fLog << inf << "Integral in E range [" <<
+      aetHisto->GetYaxis()->GetBinLowEdge(1) << ";" <<
+      aetHisto->GetYaxis()->GetBinLowEdge(energyBins+1) << "] is " << 
+      integralEvts << endl;
+      
+    // Plot Energy histogram
+  
+    c4a->cd(0);
+    thetaHisto.SetLineColor(thetaBin);
+    if (thetaBin==1) {      
+      thetaHisto.Draw();
+    } else {
+      thetaHisto.Draw("SAME");
+    }
+
+    sprintf(hname,"Theta bin %d",thetaBin);
+    fThetaLegend->AddEntry(&thetaHisto, hname, "l");
+
+    overallSigLiMa += sumSigLiMa;
+
+  } //thetaBin
+
+  fThetaLegend->Draw();
+
+  Double_t sigLiMa, lowerBin, upperBin;    
+  FitHistogram(*fSummedAlphaPlots, sigLiMa, lowerBin, upperBin);
+  fSummedAlphaPlots->SetTitle("Cumulative ALPHA distribution");
+
+  *fLog << inf << "Summed overall significance is " << overallSigLiMa << endl;
+
+  *fLog << inf << "Setting range for Significance histo " << fMaxSignif << endl;
+  // fSignificanceHisto->GetXaxis()->SetRange(0,fMaxSignif+1);
+
+  // *fLog << inf << "Setting range for chisq histo " << fMaxRedChiSq << endl;
+  // fChiSquareHisto->GetXaxis()->SetRange(0,fMaxRedChiSq+5);
+  
+  return kTRUE;
+}
+
+
+
+
+
+
+
+
+// -----------------------------------------------------------------------
+//
+// Extraction of Gamma signal is performed on a TH3D histogram in
+// ALPHA, Energy and Theta. Output to parameter list: TH2 histograms
+// in energy and Theta.
+//
+Bool_t MHOnSubtraction::Calc(TH3 *aetHisto, MParList *parlist, const Bool_t Draw)
+{
+  // Analyze aetHisto
+  // -------------------------------------
+  Int_t energyBins = aetHisto->GetNbinsY();  
+  Int_t thetaBins =  aetHisto->GetNbinsZ();  
+
+  *fLog << "Total events:     " << aetHisto->GetEntries() << endl;
+  *fLog << "Total energy bins: " << energyBins << endl;
+  *fLog << "Total theta bins:  " << thetaBins << endl;
+  
+  // We output results in an array of histograms to the parameter list.
+  // Create a template for such a histogram, needed by MH3
+  // -------------------------------------
+  MBinning *binsmh3x = new MBinning("BinningMH3X");
+  // dummy binning, real one follows some lines down
+  binsmh3x->SetEdgesLog(energyBins,aetHisto->GetYaxis()->GetBinLowEdge(1),
+			aetHisto->GetYaxis()->GetBinLowEdge(energyBins+1));
+  parlist->AddToList(binsmh3x);  
+
+  MBinning *binsmh3y = new MBinning("BinningMH3Y");
+  // dummy binning, real one follows some lines down
+  binsmh3y->SetEdges(thetaBins,aetHisto->GetZaxis()->GetBinLowEdge(1),
+		     aetHisto->GetZaxis()->GetBinLowEdge(thetaBins+1));
+  parlist->AddToList(binsmh3y);  
+  
+  MH3 *signalHisto = new MH3(2); // Signal(E,t)
+  signalHisto->SetupFill(parlist);
+  parlist->AddToList(signalHisto);
+  signalHisto->SetName("MHOnSubtractionSignal");
+  signalHisto->SetTitle("Gamma Events");
+
+  MH3 *offHisto = new MH3(2); // Off(E,t)
+  offHisto->SetupFill(parlist);
+  parlist->AddToList(offHisto);
+  offHisto->SetName("MHOnSubtractionOff");
+  offHisto->SetTitle("Background Events");
+
+  MH3 *signifHisto = new MH3(2); // Significance(E,t)
+  signifHisto->SetupFill(parlist);
+  parlist->AddToList(signifHisto);
+  signifHisto->SetName("MHOnSubtractionSignif");
+  signifHisto->SetTitle("Significance");
+
+//   if (!fChiSquareHisto) 
+//     fChiSquareHisto = new TH1D("fChiSquareHisto", "#chi^{2}/d.o.f. of fits", 50, 0, 5);
+//   if (!fSignificanceHisto) 
+//     fSignificanceHisto = new TH1D("fSignificanceHisto", "Significances", 40.5, -0.5, 41);
+//   if (!fSummedAlphaPlots)
+//     fSummedAlphaPlots = new TH1D("fSummedAlphaPlots", "Cumulative Alpha", 
+// 				 alphaBins,aetHisto->GetXaxis()->GetBinLowEdge(1),
+// 				 aetHisto->GetXaxis()->GetBinLowEdge(alphaBins+1));
+  
+  TCanvas *c4 = new TCanvas("c4", "MHOnSubtraction Detailed Result Plots", 800,600);
+  c4->Divide(energyBins+3,thetaBins,0,0,0);
+  
+  TH2D& signalTH2DHist = (TH2D&)signalHisto->GetHist();
+  TH2D& offTH2DHist =    (TH2D&)offHisto->GetHist();
+  TH2D& signifTH2DHist = (TH2D&)signifHisto->GetHist();
+  
+  signalTH2DHist.Reset();
+  signalTH2DHist.SetTitle("Gamma Signal");
+  signalTH2DHist.SetXTitle("E [GeV]");
+  signalTH2DHist.SetYTitle("theta [deg]");
+  signalHisto->SetBinning(&signalTH2DHist, aetHisto->GetYaxis(), aetHisto->GetZaxis());
+  signalTH2DHist.Sumw2();
+  
+  offTH2DHist.Reset();
+  offTH2DHist.SetTitle("Off Signal");
+  offTH2DHist.SetXTitle("E [GeV]");
+  offTH2DHist.SetYTitle("theta [deg]");
+  offHisto->SetBinning(&offTH2DHist, aetHisto->GetYaxis(), aetHisto->GetZaxis());
+  offTH2DHist.Sumw2();  
+
+  signifTH2DHist.Reset();
+  signifTH2DHist.SetTitle("Significance");
+  signifTH2DHist.SetXTitle("E [GeV]");
+  signifTH2DHist.SetYTitle("theta [deg]");
+  signifHisto->SetBinning(&signifTH2DHist, aetHisto->GetYaxis(), aetHisto->GetZaxis());
+  signifTH2DHist.Sumw2();
+ 
+  for (Int_t thetaBin = 1; thetaBin < thetaBins+1; thetaBin++) {  
+
+    *fLog << dbg << "--------------------------------------" << endl;
+    *fLog << dbg << "Processing ALPHA plots for theta bin " << thetaBin << endl;           
+    *fLog << dbg << "--------------------------------------" << endl;
+    aetHisto->GetZaxis()->SetRange(thetaBin, thetaBin);
+    TH2F* aeHisto = (TH2F*)aetHisto->Project3D("yxe");
+    aeHisto->SetDirectory(NULL);
+    char hname[80];
+    sprintf(hname, "%2.1f < #theta < %2.1f", 
+	    aetHisto->GetZaxis()->GetBinLowEdge(thetaBin),
+	    aetHisto->GetZaxis()->GetBinLowEdge(thetaBin+1));
+    *fLog << inf << "There are " << aeHisto->GetEntries() 
+ 	  << " entries in " << hname << endl;
+    aeHisto->SetTitle(hname);
+    sprintf(hname, "MHOnSubtractionThetaBin%d", thetaBin);
+    aeHisto->SetName(hname);
+
+    c4->cd((energyBins+3)*(thetaBin-1)+1);
+    aeHisto->SetMarkerColor(3);
+    aeHisto->DrawCopy();
+
+    c4->Update();
+
+    // We hand over a nonstandard parameter list, which
+    // contails lower-dimensional result histograms 
+    // signalHisto, offHisto and signifHisto
+
+//     cout << fLog->GetDebugLevel() << endl;
+    fLog->SetDebugLevel(1);
+
+    MParList *parlistth2 = new MParList();
+    //    parlistth2->SetNullOutput();
+    parlistth2->AddToList(binsmh3x);  
+
+    MH3* signalHisto2 = new MH3(1); // Signal(E)
+    signalHisto2->SetupFill(parlistth2);
+    parlistth2->AddToList(signalHisto2);
+    signalHisto2->SetName("MHOnSubtractionSignal");
+    signalHisto2->SetTitle("Gamma Events");
+
+    MH3* offHisto2 = new MH3(1); // Off(E)
+    offHisto2->SetupFill(parlistth2);
+    parlistth2->AddToList(offHisto2);
+    offHisto2->SetName("MHOnSubtractionOff");
+    offHisto2->SetTitle("Background Events");
+
+    MH3* signifHisto2 = new MH3(1); // Significance(E)
+    signifHisto2->SetupFill(parlistth2);
+    parlistth2->AddToList(signifHisto2);
+    signifHisto2->SetName("MHOnSubtractionSignif");
+    signifHisto2->SetTitle("Significance");
+
+    fLog->SetDebugLevel(-1);
+
+    TH1D& signalTH1DHist = (TH1D&)signalHisto2->GetHist();
+    TH1D& offTH1DHist =    (TH1D&)offHisto2->GetHist();
+    TH1D& signifTH1DHist = (TH1D&)signifHisto2->GetHist();
+
+    signalTH1DHist.Sumw2();
+    offTH1DHist.Sumw2();
+    signifTH1DHist.Sumw2();
+
+    TH2Calc(aeHisto, parlistth2, kFALSE, c4,   
+	    (energyBins+3)*(thetaBin-1)+4);
+
+
+    for (Int_t energyBin = 1; energyBin < energyBins+1; energyBin++) {  
+    
+   //    cout << "filling " << thetaBin << " " << energyBin << ": " 
+// 		      << signalTH1DHist.GetBinContent(energyBin) << "+-" 
+// 	   << signalTH1DHist.GetBinError(energyBin)  <<  " " 
+// 		      << offTH1DHist.GetBinContent(energyBin) << "+-" 
+// 		      << offTH1DHist.GetBinError(energyBin) << endl;
+        
+      if (signalTH1DHist.GetBinContent(energyBin)>=0.0) {
+	signalTH2DHist.SetBinContent(energyBin, thetaBin,
+				     signalTH1DHist.GetBinContent(energyBin));
+	signalTH2DHist.SetBinError(energyBin, thetaBin,
+				   signalTH1DHist.GetBinError(energyBin));
+      }
+      
+      if (offTH1DHist.GetBinContent(energyBin)>=0.0) {
+	offTH2DHist.SetBinContent(energyBin, thetaBin, 
+				  offTH1DHist.GetBinContent(energyBin));
+	offTH2DHist.SetBinError(energyBin, thetaBin,
+				offTH1DHist.GetBinError(energyBin));
+      }
+      
+      signifTH2DHist.SetBinContent(energyBin, thetaBin,
+ 				   signifTH1DHist.GetBinContent(energyBin));
+      signifTH2DHist.SetBinError(energyBin, thetaBin,
+ 				 signifTH1DHist.GetBinError(energyBin));           
+    } //energyBin
+
+  
+    c4->cd((energyBins+3)*(thetaBin-1)+2);
+    sprintf(hname,"c4_%d",(energyBins+3)*(thetaBin-1)+2);     
+    TPad* tp = (TPad*)(gROOT->FindObject(hname));
+    tp->SetLogx();     
+    signalTH1DHist.SetLineColor(2);
+    signalTH1DHist.DrawCopy();     
+    offTH1DHist.SetLineColor(4);
+    offTH1DHist.DrawCopy("SAME");          
+    c4->Update();
+           
+    signalTH2DHist.SetEntries(signalTH2DHist.GetEntries()+signalTH1DHist.GetEntries());
+    offTH2DHist.SetEntries(offTH2DHist.GetEntries()+offTH1DHist.GetEntries());
+    signifTH2DHist.SetEntries(signifTH2DHist.GetEntries()+signifTH1DHist.GetEntries());
+    
+    delete signifHisto2;
+    delete offHisto2;
+    delete signalHisto2;
+    delete parlistth2;
+  
+  }
+
+
+  c4->Update();
+
+  return kTRUE;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/*
+
+// -----------------------------------------------------------------------
+//
+// Extraction of Gamma signal is performed on a TH3D histogram in
+// ALPHA, Energy and Theta. Output to parameter list: TH2 histograms
+// in energy and Theta.
+//
+Bool_t MHOnSubtraction::CalcLightCurve(TH3 *aetHisto, MParList *parlist, const Bool_t draw)
+{
+  // Analyze aetHisto
+  // -------------------------------------
+  Int_t alphaBins = aetHisto->GetNbinsX(); 
+  Int_t energyBins = aetHisto->GetNbinsY();  
+  Int_t timeBins =  aetHisto->GetNbinsZ();  
+
+  *fLog << "Total events:      " << aetHisto->GetEntries() << endl;
+  *fLog << "Total energy bins: " << energyBins << endl;
+  *fLog << "Total time bins:   " << timeBins << endl;
+
+  // We output results in an array of histograms to the parameter list.
+  // Create a template for such a histogram, needed by MH3
+  // -------------------------------------
+  MBinning *binsmh3x = new MBinning("BinningMH3X");
+  // dummy binning, real one follows some lines down
+  binsmh3x->SetEdges(timeBins,aetHisto->GetZaxis()->GetBinLowEdge(1),
+		     aetHisto->GetZaxis()->GetBinLowEdge(timeBins+1));
+  parlist->AddToList(binsmh3x); 
+  
+  MH3 *signalHisto = new MH3(1); // Signal(t)
+  signalHisto->SetupFill(parlist);
+  parlist->AddToList(signalHisto);
+  signalHisto->SetName("MHOnSubtractionSignal");
+  signalHisto->SetTitle("Gamma Events");
+
+  MH3 *offHisto = new MH3(1); // Off(t)
+  offHisto->SetupFill(parlist);
+  parlist->AddToList(offHisto);
+  offHisto->SetName("MHOnSubtractionOff");
+  offHisto->SetTitle("Background Events");
+
+  MH3 *signifHisto = new MH3(1); // Significance(t)
+  signifHisto->SetupFill(parlist);
+  parlist->AddToList(signifHisto);
+  signifHisto->SetName("MHOnSubtractionSignif");
+  signifHisto->SetTitle("Significance");
+
+  TH1D& signalTH1DHist = (TH1D&)signalHisto->GetHist();
+  TH1D& offTH1DHist =    (TH1D&)offHisto->GetHist();
+  TH1D& signifTH1DHist = (TH1D&)signifHisto->GetHist();
+  
+  signalTH1DHist.Reset();
+  signalTH1DHist.SetTitle("Gamma Signal");
+  signalTH1DHist.SetXTitle("Time [MJD]");
+  signalTH1DHist.SetYTitle("Events");
+  signalHisto->SetBinning(&signalTH1DHist, aetHisto->GetZaxis());
+  signalTH1DHist.Sumw2();
+  
+  offTH1DHist.Reset();
+  offTH1DHist.SetTitle("Background Signal");
+  offTH1DHist.SetXTitle("Time [MJD]");
+  offTH1DHist.SetYTitle("Events");
+  offHisto->SetBinning(&offTH1DHist,  aetHisto->GetZaxis());
+  offTH1DHist.Sumw2();  
+
+  signifTH1DHist.Reset();
+  signifTH1DHist.SetTitle("Significance");
+  signifTH1DHist.SetXTitle("Time [MJD]");
+  signifTH1DHist.SetYTitle("Significance #sigma");
+  signifHisto->SetBinning(&signifTH1DHist, aetHisto->GetZaxis());
+  signifTH1DHist.Sumw2();
+ 
+  //The following histogram is an additional histogram needed for
+  //the light curve
+
+  TCanvas *c4 = new TCanvas("c4", "MHOnSubtraction Detailed Result Plots", 800,600);
+  c4->Divide(8,7,0,0,0);
+
+ 
+
+  // The following loop fixes a common integration region for each
+  // energy bin and alerts when no significant excess is found.
+  
+  Double_t minLowerBin = -10; // minimum integration range
+  Double_t maxUpperBin =  10; // minimum integration range
+  Double_t maxAlpha =  70; // maximum integration range
+  Double_t sumSigLiMa = 0;
+
+  TH1F* alphaHisto[timeBins];
+
+  for (Int_t timeBin = 1; timeBin < timeBins+1; timeBin++) {  
+
+    *fLog << dbg << "--------------------------------------" << endl;
+    *fLog << dbg << "Processing ALPHA plots for time bin " << timeBin << endl;           
+    *fLog << dbg << "--------------------------------------" << endl;
+   
+    aetHisto->GetZaxis()->SetRange(timeBin, timeBin);
+
+    char hname[80];
+    sprintf(hname, "MHOnSubtractionTimeBin%d", timeBin);    
+    alphaHisto[timeBin-1] =
+      new TH1F(hname, "ALPHA histogram",
+	       alphaBins,aetHisto->GetXaxis()->GetBinLowEdge(1),
+	       aetHisto->GetXaxis()->GetBinLowEdge(alphaBins+1));
+    alphaHisto[timeBin-1]->SetDirectory(NULL);
+    alphaHisto[timeBin-1]->Sumw2();
+    alphaHisto[timeBin-1] = (TH1F*)aetHisto->Project3D("xe");
+    alphaHisto[timeBin-1]->SetName(hname);
+    alphaHisto[timeBin-1]->SetDirectory(NULL);
+
+    sprintf(hname, "%6.0f < t < %6.0f", 
+	    aetHisto->GetZaxis()->GetBinLowEdge(timeBin),
+	    aetHisto->GetZaxis()->GetBinLowEdge(timeBin+1));
+    *fLog << inf << "There are " << alphaHisto[timeBin-1]->GetEntries() 
+ 	  << " entries in " << hname << endl;
+    alphaHisto[timeBin-1]->SetTitle(hname);
+      
+    // Find signal region and significance in histogram
+    Double_t lowerBin, upperBin, sSigLiMa;
+    char funcName[20];
+    sprintf(funcName, "%2d", timeBin);
+
+    Bool_t drawFit = kTRUE;
+
+    c4->cd(timeBin);
+//     alphaHisto[timeBin-1]->SetMarkerColor(3);
+    alphaHisto[timeBin-1]->DrawCopy();
+
+    c4->Update();
+
+    fSigniPlotColor = 0;
+ ;
+    Bool_t fit = FitHistogram(*alphaHisto[timeBin-1], sSigLiMa, 
+			      lowerBin, upperBin, (Float_t)3.0, drawFit, 
+			      funcName);
+
+    if (fit) { 
+      if (sSigLiMa < 3)
+	*fLog << warn << "No significant excess for this bin (sigma="<< sSigLiMa <<")!"<<endl;
+      sumSigLiMa+=sSigLiMa;
+   
+      // Evaluate integration range
+      lowerBin = (lowerBin < -maxAlpha) ? -maxAlpha : lowerBin;
+      minLowerBin = (lowerBin < minLowerBin) ? lowerBin : minLowerBin;    
+      upperBin = (upperBin > maxAlpha) ? maxAlpha : upperBin;
+      maxUpperBin = (upperBin > maxUpperBin) ? upperBin : maxUpperBin;
+    }
+
+
+    
+
+
+
+  } //timeBin
+  
+  *fLog << inf << "=> Integration range will be " << minLowerBin << " < ALPHA < "
+	<< maxUpperBin << "," << endl;    
+  *fLog << inf << "   Summed estimated significance is " << sumSigLiMa << endl;
+      
+  // we have an idea of what is going on in the ALPHA plot...
+  // So now we can indeed extract the signal.
+         
+  sumSigLiMa = 0;
+  for (Int_t timeBin = 1; timeBin < timeBins+1; timeBin++) {
+    *fLog << inf << "Processing ALPHA distribution for time bin " << timeBin << endl;
+    if (alphaHisto[timeBin-1]->GetEntries() == 0) {
+       *fLog << warn << "No attempt to extract a signal from 0 events." << endl;       
+       if (draw) {
+	 TPaveLabel* lab = new TPaveLabel(0.2,0.4,0.8,0.6,"-(nothing to extract)-");
+	 lab->SetBorderSize(0);
+	 lab->Draw();  
+       }
+    } else {
+      char funcName[20];
+      sprintf(funcName, "%2d", timeBin);
+      
+      Double_t gammaSignal, errorGammaSignal, off, errorOff, sigLiMa;    
+
+      Bool_t drawFit = kFALSE;     
+
+      ExtractSignal(*alphaHisto[timeBin-1],
+		    sigLiMa, minLowerBin, maxUpperBin, 
+		    gammaSignal, errorGammaSignal, off, errorOff, (Float_t)3, drawFit,
+		    funcName, NULL, 1);
+
+      sumSigLiMa += sigLiMa;      
+
+      fMaxSignif = sigLiMa > fMaxSignif ? sigLiMa : fMaxSignif;
+
+      // Fill Signal 
+      TH1D &h = (TH1D&)(signalHisto->GetHist());
+      h.SetBinContent(timeBin, gammaSignal);
+      h.SetBinError(timeBin, errorGammaSignal);
+      h.SetEntries(h.GetEntries()+gammaSignal);
+      
+      // Fill Off Events
+      TH1D &ho = (TH1D&)(offHisto->GetHist());
+      ho.SetBinContent(timeBin, off);
+      ho.SetBinError(timeBin, errorOff);
+      ho.SetEntries(ho.GetEntries()+off);
+      
+      // Fill Significance
+      TH1D &hg = (TH1D&)(signifHisto->GetHist());
+      hg.SetBinContent(timeBin, sigLiMa);
+      hg.SetEntries(hg.GetEntries()+sigLiMa);           
+    }
+    
+  }//timeBin
+
+  *fLog << inf << "Summed significance is " << sumSigLiMa << endl;
+
+
+  if (draw) {
+    Double_t sigLiMa, lowerBin, upperBin;    
+    FitHistogram(*fSummedAlphaPlots, sigLiMa, lowerBin, upperBin);
+    fSummedAlphaPlots->SetTitle("Cumulative ALPHA distribution");
+
+    *fLog << inf << "Setting range for Significance histo " << fMaxSignif << endl;
+    // fSignificanceHisto->GetXaxis()->SetRange(0,fMaxSignif+1);
+    
+    // *fLog << inf << "Setting range for chisq histo " << fMaxRedChiSq << endl;
+    // fChiSquareHisto->GetXaxis()->SetRange(0,fMaxRedChiSq+5);
+    
+    fChiSquareHisto->DrawClone();
+    fSignificanceHisto->DrawClone();
+    fSummedAlphaPlots->DrawClone();
+  }
+  
+  return kTRUE;
+}
+
+
+
+
+
+*/
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+// -----------------------------------------------------------------------
+//
+// Extraction of Gamma signal is performed on a TH2 histogram in
+// ALPHA and Energy. Output to parameter list is TH1 histogram in
+// energy
+//
+Bool_t MHOnSubtraction::TH2Calc(TH2 *aeHisto, MParList *parlist, const Bool_t draw, TPad *drawPad, Int_t drawBase)
+{
+
+  fSigniPlotColor = 0;
+
+  // Analyze aeHisto
+  // -------------------------------------
+  const Int_t alphaBins =  aeHisto->GetNbinsX();  // # of alpha bins 
+  const Int_t energyBins = aeHisto->GetNbinsY();  
+
+  // Check availability of result histograms
+  // -------------------------------------
+
+  MH3* signalHisto = (MH3*)parlist->FindObject("MHOnSubtractionSignal","MH3");
+  MH3* offHisto =    (MH3*)parlist->FindObject("MHOnSubtractionOff","MH3");
+  MH3* signifHisto = (MH3*)parlist->FindObject("MHOnSubtractionSignif","MH3");
+
+  if (signalHisto && offHisto && signifHisto) {  
+//     *fLog << dbg << "Result histograms are present in parameter list " <<
+//       "and will be used further." << endl;
+  } else {
+
+    *fLog << warn << "Result histograms are not present in parameter " <<
+      "list and thus are going to be created now." << endl;
+
+    MBinning *binsmh3x = new MBinning("BinningMH3X");
+    binsmh3x->SetEdgesLog(energyBins,aeHisto->GetYaxis()->GetBinLowEdge(1),
+		       aeHisto->GetYaxis()->GetBinLowEdge(energyBins+1));
+    parlist->AddToList(binsmh3x);  
+  
+    signalHisto = new MH3(1); // Signal(E)
+    signalHisto->SetName("MHOnSubtractionSignal");
+    signalHisto->SetTitle("Extracted Signal");
+    parlist->AddToList(signalHisto);
+    signalHisto->SetBinning(&((TH1D&)signalHisto->GetHist()), 
+			    aeHisto->GetYaxis());
+
+    offHisto = new MH3(1); // Off(E)
+    offHisto->SetName("MHOnSubtractionOff");
+    offHisto->SetTitle("Off Signal");
+    parlist->AddToList(offHisto);
+    offHisto->SetBinning(&((TH1D&)offHisto->GetHist()), 
+			    aeHisto->GetYaxis());
+    
+    signifHisto = new MH3(1); // Significance(E)
+    signifHisto->SetName("MHOnSubtractionSignif");
+    signifHisto->SetTitle("Significance");
+    parlist->AddToList(signifHisto);
+    signifHisto->SetBinning(&((TH1D&)signifHisto->GetHist()), 
+			    aeHisto->GetYaxis());
+
+  }
+  if (fChiSquareHisto==0x0)
+    fChiSquareHisto = new TH1D("fChiSquareHisto", "#chi^{2}/d.o.f. of fits", 50, 0, 5);
+  if (fSignificanceHisto==0x0)
+    fSignificanceHisto = new TH1D("fSignificanceHisto", "Significances", 41, -0.5, 40.5);
+  if (fSummedAlphaPlots==0x0)
+    fSummedAlphaPlots = new TH1D("fSummedAlphaPlots", "Cumulative Alpha", 
+				 alphaBins,aeHisto->GetXaxis()->GetBinLowEdge(1),
+				 aeHisto->GetXaxis()->GetBinLowEdge(alphaBins+1));  
+         
+  // The following loop fixes a common integration region for each
+  // energy bin and alerts when no significant excess is found.
+  
+  Double_t minLowerBin = -10; // minimum integration range
+  Double_t maxUpperBin =  10; // minimum integration range
+  Double_t maxAlpha =  70; // maximum integration range
+  Double_t sumSigLiMa = 0;
+
+  TH1F* alphaHisto[energyBins];
+
+  fSigniPlotIndex = 0; // cf. ExtractSignal
+ 
+  for (Int_t energyBin = 1; energyBin < energyBins+1; energyBin++) {
+    *fLog << inf << "Preprocessing ALPHA distribution for E bin " << energyBin << endl;
+    char hname[80];
+    sprintf(hname, "MHOnSubtractionAlpha%d", energyBin);    
+    alphaHisto[energyBin-1] =
+      new TH1F(hname, "ALPHA histogram",
+	       alphaBins,aeHisto->GetXaxis()->GetBinLowEdge(1),
+	       aeHisto->GetXaxis()->GetBinLowEdge(alphaBins+1));
+    alphaHisto[energyBin-1]->SetDirectory(NULL);
+    alphaHisto[energyBin-1]->Sumw2();
+    alphaHisto[energyBin-1] = (TH1F*)aeHisto->ProjectionX("xe", energyBin, energyBin);
+    alphaHisto[energyBin-1]->SetName(hname);
+    alphaHisto[energyBin-1]->SetDirectory(NULL);
+
+    sprintf(hname, "%2.1f < E < %2.1f", 
+	    aeHisto->GetYaxis()->GetBinLowEdge(energyBin),
+	    aeHisto->GetYaxis()->GetBinLowEdge(energyBin+1));
+    alphaHisto[energyBin-1]->SetTitle(hname);
+    //    alphaHisto[energyBin-1]->DrawCopy();
+    alphaHisto[energyBin-1]->SetDirectory(NULL);
+      
+    // Find signal region and significance in histogram
+    Double_t lowerBin, upperBin, sSigLiMa;
+    char funcName[20];
+    sprintf(funcName, "%2d", energyBin);
+
+    Bool_t drawFit = kFALSE;
+
+    if (drawPad) {
+      drawPad->cd(drawBase+energyBin-1);
+      drawFit = kTRUE;
+    }
+
+    Bool_t fit = FitHistogram(*alphaHisto[energyBin-1], sSigLiMa, 
+			      lowerBin, upperBin, (Float_t)3.0, drawFit, 
+			      funcName);
+
+    if (fit) { 
+      Double_t redChiSq = alphaHisto[energyBin-1]->GetFunction("gauspol3"+(TString)funcName)->GetChisquare()/
+	alphaHisto[energyBin-1]->GetFunction("gauspol3"+(TString)funcName)->GetNDF();
+      fChiSquareHisto->Fill(redChiSq);
+      fMaxRedChiSq = redChiSq > fMaxRedChiSq ? redChiSq : fMaxRedChiSq;
+      fSummedAlphaPlots->Add(alphaHisto[energyBin-1], 1);
+      if (sSigLiMa < 3)
+	*fLog << warn << "No significant excess for this bin (sigma="<< sSigLiMa <<")!"<<endl;
+      sumSigLiMa+=sSigLiMa;
+   
+      // Evaluate integration range
+      lowerBin = (lowerBin < -maxAlpha) ? -maxAlpha : lowerBin;
+      minLowerBin = (lowerBin < minLowerBin) ? lowerBin : minLowerBin;    
+      upperBin = (upperBin > maxAlpha) ? maxAlpha : upperBin;
+      maxUpperBin = (upperBin > maxUpperBin) ? upperBin : maxUpperBin;
+    } else {
+      fChiSquareHisto->Fill(0);
+    }
+
+//     debugOut->Update();
+
+  } //energyBin
+  
+  *fLog << inf << "=> Integration range for this theta bin will be " << minLowerBin << " < ALPHA < "
+	<< maxUpperBin << "," << endl;    
+  *fLog << inf << "   Summed estimated significance is " << sumSigLiMa << endl;
+      
+  // we have an idea of what is going on in the ALPHA plot...
+  // So now we can indeed extract the signal.
+         
+  sumSigLiMa = 0;
+  for (Int_t energyBin = 1; energyBin < energyBins+1; energyBin++) {
+    *fLog << inf << "Processing ALPHA distribution for E bin " << energyBin << endl;
+    if (alphaHisto[energyBin-1]->GetEntries() == 0) {
+       *fLog << warn << "No attempt to extract a signal from 0 events." << endl;       
+       if (draw) {
+	 TPaveLabel* lab = new TPaveLabel(0.2,0.4,0.8,0.6,"-(nothing to extract)-");
+	 lab->SetBorderSize(0);
+	 lab->Draw();  
+       }
+    } else {
+      char funcName[20];
+      sprintf(funcName, "%2d", energyBin);
+      
+      Double_t gammaSignal, errorGammaSignal, off, errorOff, sigLiMa;    
+
+      Bool_t drawFit = kFALSE;
+      
+//       if (drawPad) {
+// 	cout << "Going to use pad " <<drawBase+energyBin-1 << endl;
+// 	drawPad->cd(drawBase+energyBin-1);
+// 	drawFit = kTRUE;
+//       }
+
+
+      ExtractSignal(*alphaHisto[energyBin-1],
+		    sigLiMa, minLowerBin, maxUpperBin, 
+		    gammaSignal, errorGammaSignal, off, errorOff, (Float_t)3, drawFit,
+		    funcName, drawPad, drawBase);
+
+      sumSigLiMa += sigLiMa;      
+      fSignificanceHisto->Fill(sigLiMa);
+      fMaxSignif = sigLiMa > fMaxSignif ? sigLiMa : fMaxSignif;
+
+      // Fill Signal 
+      TH1D &h = (TH1D&)(signalHisto->GetHist());
+      h.SetBinContent(energyBin, gammaSignal);
+      h.SetBinError(energyBin, errorGammaSignal);
+      h.SetEntries(h.GetEntries()+gammaSignal);
+      
+      // Fill Off Events
+      TH1D &ho = (TH1D&)(offHisto->GetHist());
+      ho.SetBinContent(energyBin, off);
+      ho.SetBinError(energyBin, errorOff);
+      ho.SetEntries(ho.GetEntries()+off);
+      
+      // Fill Significance
+      TH1D &hg = (TH1D&)(signifHisto->GetHist());
+      hg.SetBinContent(energyBin, sigLiMa);
+      hg.SetEntries(hg.GetEntries()+sigLiMa);           
+    }
+    
+  }//energyBin
+
+  *fLog << inf << "Summed significance is " << sumSigLiMa << endl;
+
+
+  if (draw) {
+    Double_t sigLiMa, lowerBin, upperBin;    
+    FitHistogram(*fSummedAlphaPlots, sigLiMa, lowerBin, upperBin);
+    fSummedAlphaPlots->SetTitle("Cumulative ALPHA distribution");
+
+    *fLog << inf << "Setting range for Significance histo " << fMaxSignif << endl;
+    // fSignificanceHisto->GetXaxis()->SetRange(0,fMaxSignif+1);
+    
+    // *fLog << inf << "Setting range for chisq histo " << fMaxRedChiSq << endl;
+    // fChiSquareHisto->GetXaxis()->SetRange(0,fMaxRedChiSq+5);
+    
+    fChiSquareHisto->DrawClone();
+    fSignificanceHisto->DrawClone();
+    fSummedAlphaPlots->DrawClone();
+  }
+  
+  return kTRUE;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+// -----------------------------------------------------------------------
+//
+// Extraction of Gamma signal is performed on a TH1 histogram in ALPHA
+// 
+//
+Bool_t MHOnSubtraction::Calc(TH1 *aHisto, MParList *parlist, 
+			     const Bool_t draw, Float_t signalRegion)
+{ 
+  // Find signal region and estimate significance
+  Double_t lowerBin, upperBin, sigLiMa;
+  FitHistogram(*aHisto,	sigLiMa, lowerBin, upperBin, (Float_t)3.5, kFALSE);
+
+  //if (sigLiMa < 3)
+  //  *fLog << err << "No significant excess (sigma=" << sigLiMa <<")!"<<endl;
+
+  if (signalRegion!=0) {
+    lowerBin = -signalRegion;
+    upperBin =  signalRegion;
+  }
+       
+  Double_t gammaSignal, errorGammaSignal, off, errorOff;
+
+  ExtractSignal(*aHisto, sigLiMa, lowerBin, upperBin, 
+		gammaSignal, errorGammaSignal, off, errorOff, 
+		(Float_t)3.0, draw);
+
+  fSignificance = sigLiMa;
+  
+  *fLog << inf << "Signal is " 
+	<< gammaSignal << "+-" << errorGammaSignal << endl
+	<< inf << "Significance is " << sigLiMa << endl;
+
+  return kTRUE;
+}
+
+// -------------------------------------------------------------------------
+//
+// Draw a copy of the histogram
+//
+TObject *MHOnSubtraction::DrawClone(Option_t *opt) const
+{  
+    TCanvas &c = *MakeDefCanvas("OnSubtraction", "Results from OnSubtraction");
+    c.Divide(2,2);
+
+    gROOT->SetSelectedPad(NULL);
+    gStyle->SetOptStat(0);
+
+    c.cd(1);
+    fSummedAlphaPlots->DrawCopy(opt);
+
+    c.cd(2);
+    fSignificanceHisto->DrawCopy(opt);
+
+    c.cd(3);  
+    TString drawopt="";
+    for (fThetaHistoArray->SetIndex(0); 
+ 	 MH3* h=(MH3*)(fThetaHistoArray->GetH()); 
+ 	 fThetaHistoArray->IncIndex())
+      {
+	// Get the current histogram
+	TH1D& hist = (TH1D&)h->GetHist();
+	fSummedAlphaPlots->SetTitle("Energy distributions for different theta bins");
+	hist.Draw(drawopt);
+	drawopt="SAME";
+      }
+    fThetaLegend->Draw();
+    
+    c.cd(4);
+    fChiSquareHisto->DrawCopy(opt);
+    
+    c.Modified();
+    c.Update();
+
+    return &c;
+}
+
+// -------------------------------------------------------------------------
+//
+// Draw the histogram
+//
+void MHOnSubtraction::Draw(Option_t *opt) 
+{ 
+    if (!gPad)
+      MakeDefCanvas("OnSubtraction", "Results from OnSubtraction");
+
+    gPad->Divide(2,3);
+
+// Ok, at some point this will be implemented
+
+    gPad->Modified();
+    gPad->Update();
+}
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mhist/MHOnSubtraction.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHOnSubtraction.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHOnSubtraction.h	(revision 9661)
@@ -0,0 +1,75 @@
+#ifndef MARS_MHOnSubtraction
+#define MARS_MHOnSubtraction
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+class TH1D;
+class TH3D;
+class TPad;
+class TGraph;
+class TLegend;
+class TPaveLabel;
+
+class MHArray;
+
+class MHOnSubtraction : public MH
+{
+private:
+  TString fHistogramType;
+  TH1D*   fChiSquareHisto;
+  TH1D*   fSignificanceHisto;
+  TH1D*   fSummedAlphaPlots;
+  MHArray *fThetaHistoArray;
+  TLegend *fThetaLegend;
+  Double_t fMaxSignif;
+  Double_t fMaxRedChiSq;
+  Double_t fSlope;             // slope for exponential fit
+  Int_t fThetaBin;
+  Int_t fSigniPlotIndex;
+  Int_t fSigniPlotColor;
+
+  Double_t fSignificance;
+
+  Bool_t CalcAET(TH3D *histon, MParList *parlist, const Bool_t Draw);
+
+  Bool_t FitHistogram(TH1 &alphaHisto, Double_t &sigLiMa,
+		      Double_t &lowerBin, Double_t &upperBin,
+		      Float_t signalRegionFactor = 3, const Bool_t draw = kFALSE,
+		      TString funcName = "");
+
+  Bool_t ExtractSignal(TH1 &alphaHisto, Double_t &sigLiMa,
+		       Double_t &lowerBin, Double_t &upperBin,
+		       Double_t &gammaSignal, Double_t &errorGammaSignal,
+		       Double_t &off, Double_t &errorOff,
+ 		       Float_t signalRegionFactor = 3, const Bool_t draw = kFALSE,
+ 		       TString funcName = "", TPad *drawPad = 0, Int_t drawBase = 0);
+
+
+
+public:
+  MHOnSubtraction(const char *name=NULL, const char *title=NULL);
+  ~MHOnSubtraction();
+
+  Double_t CalcSignificance(Double_t nOn, Double_t nOff, Double_t theta);
+  Double_t GetSignificance()  { return fSignificance; };
+
+  void SetExpoSlope(Double_t slope) { fSlope = slope; }
+  
+  Bool_t Calc(MParList *parlist, const Bool_t Draw);
+
+  Bool_t Calc(TH3 *histon, MParList *parlist, const Bool_t Draw);
+  Bool_t TH2Calc(TH2 *aeHisto, MParList *parlist, const Bool_t Draw, 
+		 TPad *drawPad = 0, Int_t drawBase = 0);
+  Bool_t Calc(TH1 *histon, MParList *parlist, const Bool_t Draw,
+	      Float_t signalRegion = 0);
+
+  void Draw(Option_t *option="");
+  TObject *DrawClone(Option_t *option="") const;
+
+  ClassDef(MHOnSubtraction, 1) //Extracts gamma signals from pure ON-data
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mhist/MHSigmaPixel.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHSigmaPixel.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHSigmaPixel.cc	(revision 9661)
@@ -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): Robert Wagner 10/2002 <mailto:magicsoft@rwagner.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MHSigmaPixel                                                            //
+//                                                                          //
+//  2D-Histogram pedestal sigma vs pixel number                             //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MHSigmaPixel.h"
+
+#include <TCanvas.h>
+
+#include <math.h>
+
+#include "MPedestalCam.h"
+#include "MPedestalPix.h"
+#include "MSigmabar.h"
+
+#include "MBinning.h"
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHSigmaPixel);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor. It sets name and title of the histogram. 
+//
+MHSigmaPixel::MHSigmaPixel(const char *name, const char *title)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHSigmaPixel";
+    fTitle = title ? title : "2-D histogram in sigma and pixel";
+
+    fHist.SetDirectory(NULL);
+
+    fHist.SetTitle("Sigma vs pixel #");
+    fHist.SetXTitle("pixel #");
+    fHist.SetYTitle("\\sigma");
+    fHist.SetZTitle("N");
+}
+
+// --------------------------------------------------------------------------
+//
+// Set binnings and prepare filling of the histogram. The binning for the
+// pixel axis is derived automagically from the MPedestalCam container
+// expected to be found in the MParList *plist.
+// 
+Bool_t MHSigmaPixel::SetupFill(const MParList *plist)
+{
+  fPedestalCam = (MPedestalCam*)plist->FindObject("MPedestalCam");
+  if (!fPedestalCam)
+    {
+      *fLog << err << "MPedestalCam not found... aborting." << endl;
+      return kFALSE;
+    }
+  
+  MBinning* binssigma = (MBinning*)plist->FindObject("BinningSigma");
+  if (!binssigma)
+    {
+      *fLog << err << "BinningSigma [MBinning] not found... aborting." << endl;
+      return kFALSE;      
+    }
+
+  const Int_t n = fPedestalCam->GetSize();
+
+  MBinning binspixel;
+  binspixel.SetEdges(n, -0.5, -0.5+n);
+
+  SetBinning(&fHist, &binspixel, binssigma);
+
+  fHist.Sumw2();
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the histogram
+// 
+Bool_t MHSigmaPixel::Fill(const MParContainer *par, const Stat_t w)
+{
+    const MPedestalCam &ped = *(MPedestalCam*)par;
+    for (Int_t i=0;i<(ped.GetSize());i++)
+    {
+        const MPedestalPix pix = ped[i];
+        fHist.Fill(i, pix.GetPedestalRms());
+    }
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw the histogram
+// 
+void MHSigmaPixel::Draw(Option_t *opt)
+{
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    AppendPad("");
+
+    fHist.Draw(opt);
+
+    gPad->Modified();
+    gPad->Update();
+}
+
Index: /tags/Mars_V0-8-5/Mars/mhist/MHSigmaPixel.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHSigmaPixel.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHSigmaPixel.h	(revision 9661)
@@ -0,0 +1,46 @@
+#ifndef MARS_MHSigmaPixel
+#define MARS_MHSigmaPixel
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+#ifndef ROOT_TH2
+#include <TH2.h>
+#endif
+
+class TH2D;
+
+class MMcEvt;
+class MParList;
+class MPedestalCam;
+
+class MHSigmaPixel : public MH
+{
+private:
+    MPedestalCam *fPedestalCam; //!
+
+    TH2D fHist;
+
+public:
+    MHSigmaPixel(const char *name=NULL, const char *title=NULL);
+
+    Bool_t SetupFill(const MParList *pList);
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+
+    const TH2D *GetHist()       { return &fHist; }
+    const TH2D *GetHist() const { return &fHist; }
+
+    TH1 *GetHistByName(const TString name) { return &fHist; }
+
+    void Draw(Option_t *option="");
+
+    ClassDef(MHSigmaPixel, 1) //2D-histogram in Sigma and Pixel number
+};
+
+#endif
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mhist/MHSigmaTheta.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHSigmaTheta.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHSigmaTheta.cc	(revision 9661)
@@ -0,0 +1,351 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:wittek@mppmu.mpg.de>
+!   Author(s): Thomas Bretz 4/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MHSigmaTheta (extension of Robert's MHSigmabarTheta)                    //
+//                                                                          //
+//  calculates - the 2D-histogram   sigmabar vs. Theta, and                 //
+//             - the 3D-histogram   sigma, pixel no., Theta                 //
+//             - the 3D-histogram   (sigma^2-sigmabar^2), pixel no., Theta  //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MHSigmaTheta.h"
+
+#include <TCanvas.h>
+
+#include "MTime.h"
+#include "MMcEvt.hxx"
+
+#include "MBinning.h"
+#include "MParList.h"
+#include "MSigmabar.h"
+
+#include "MGeomCam.h"
+
+#include "MPedPhotCam.h"
+#include "MPedPhotPix.h"
+
+#include "MCerPhotEvt.h"
+#include "MCerPhotPix.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHSigmaTheta);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor. It sets name and title of the histogram.
+//
+MHSigmaTheta::MHSigmaTheta(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MHSigmaTheta";
+    fTitle = title ? title : "2D histogram sigmabar vs. Theta";
+
+    fSigmaTheta.SetDirectory(NULL);
+    fSigmaTheta.SetName("2D-ThetaSigmabar");
+    fSigmaTheta.SetTitle("2D: \\bar{\\sigma}, \\Theta");
+    fSigmaTheta.SetXTitle("\\Theta [\\circ]");
+    fSigmaTheta.SetYTitle("Sigmabar");
+
+    fSigmaPixTheta.SetDirectory(NULL);
+    fSigmaPixTheta.SetName("3D-ThetaPixSigma");
+    fSigmaPixTheta.SetTitle("3D: \\Theta, Pixel Id, \\sigma");
+    fSigmaPixTheta.SetXTitle("\\Theta [\\circ]");
+    fSigmaPixTheta.SetYTitle("Pixel Id");
+    fSigmaPixTheta.SetZTitle("\\sigma");
+
+    fDiffPixTheta.SetDirectory(NULL);
+    fDiffPixTheta.SetName("3D-ThetaPixDiff");
+    fDiffPixTheta.SetTitle("3D: \\Theta, Pixel Id, {\\sigma}^{2}-\\bar{\\sigma}^{2}");
+    fDiffPixTheta.SetXTitle("\\Theta [\\circ]");
+    fDiffPixTheta.SetYTitle("Pixel Id");
+    fDiffPixTheta.SetZTitle("{\\sigma}^{2}-\\bar{\\sigma}^{2}");
+
+    // Set default binning
+    // FIXME: Maybe ist's necessary to adapt the value to the
+    // Magic default values
+    MBinning binsb;
+    MBinning binst;
+    MBinning binsd;
+    binsd.SetEdges(100, -10, 20);
+    binsb.SetEdges(100, 0, 10);
+    binst.SetEdgesCos(10, 0, 90);
+
+    MBinning binspix("BinningPixel");
+    binspix.SetEdges(578, -0.5, 577.5);
+
+    SetBinning(&fSigmaTheta,    &binst, &binsb);
+    SetBinning(&fSigmaPixTheta, &binst, &binspix, &binsb);
+    SetBinning(&fDiffPixTheta,  &binst, &binspix, &binsd);
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the binnings and prepare the filling of the histogram
+//
+Bool_t MHSigmaTheta::SetupFill(const MParList *plist)
+{
+    fCam = (MGeomCam*)plist->FindObject("MGeomCam");
+    if (!fCam)
+    {
+        *fLog << err << "MGeomCam not found (no geometry information available)... aborting." << endl;
+        return kFALSE;
+    }
+
+    fMcEvt = (MMcEvt*)plist->FindObject("MMcEvt");
+    if (!fMcEvt)
+        *fLog << warn << "MMcEvt not found... aborting." << endl;
+
+
+    fPed = (MPedPhotCam*)plist->FindObject("MPedPhotCam");
+    if (!fPed)
+    {
+        *fLog << err << "MPedPhotCam not found... aborting." << endl;
+        return kFALSE;
+    }
+    fPed->InitSize(fCam->GetNumPixels());
+
+
+    fEvt = (MCerPhotEvt*)plist->FindObject("MCerPhotEvt");
+    if (!fEvt)
+    {
+        *fLog << err << "MCerPhotEvt not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fSigmabar = (MSigmabar*)plist->FindObject("MSigmabar");
+    if (!fSigmabar)
+    {
+        *fLog << err << "MSigmabar not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    // Get Theta Binning
+    MBinning* binstheta  = (MBinning*)plist->FindObject("BinningTheta", "MBinning");
+    if (!binstheta)
+    {
+        *fLog << warn << "Object 'BinningTheta' [MBinning] not found... no binning applied." << endl;
+        return kTRUE;
+    }
+
+    // Get Sigmabar binning
+    MBinning* binssigma = (MBinning*)plist->FindObject("BinningSigmabar", "MBinning");
+    if (!binssigma)
+        *fLog << warn << "Object 'BinningSigmabar' [MBinning] not found... no binning applied." << endl;
+
+    // Get binning for (sigma^2-sigmabar^2)
+    MBinning* binsdiff  = (MBinning*)plist->FindObject("BinningDiffsigma2", "MBinning");
+    if (!binsdiff)
+        *fLog << warn << "Object 'BinningDiffsigma2' [MBinning] not found... no binning applied." << endl;
+
+    //FIXME: Missing: Apply new binning to only one axis!
+
+    // Get binning for pixel number
+    const UInt_t npix1 = fPed->GetSize()+1;
+    *fLog << "npix1 = " << npix1 << endl;
+    MBinning binspix("BinningPixel");
+    binspix.SetEdges(npix1, -0.5, npix1-0.5);
+
+    // Set binnings in histograms
+    if (binssigma)
+    {
+        SetBinning(&fSigmaTheta, binstheta, binssigma);
+        SetBinning(&fSigmaPixTheta, binstheta, &binspix, binssigma);
+    }
+
+    if (binsdiff)
+        SetBinning(&fDiffPixTheta,  binstheta, &binspix, binsdiff);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Fill the histograms
+//
+Bool_t MHSigmaTheta::Fill(const MParContainer *par, const Stat_t w)
+{
+    Double_t theta = fMcEvt ? fMcEvt->GetTelescopeTheta()*kRad2Deg : 0;
+    fSigmabar->Calc(*fCam, *fPed, *fEvt);
+    Double_t mysig = fSigmabar->GetSigmabarInner();
+
+    //*fLog << "theta, mysig = " << theta << ",  " << mysig << endl;
+
+    fSigmaTheta.Fill(theta, mysig);
+
+    const UInt_t npix = fEvt->GetNumPixels();
+
+    for (UInt_t i=0; i<npix; i++)
+    {
+        MCerPhotPix cerpix = (*fEvt)[i];
+        if (!cerpix.IsPixelUsed())
+            continue;
+
+        const Int_t id = cerpix.GetPixId();
+        const MPedPhotPix &pix = (*fPed)[id];
+
+        // ratio is the area of pixel 0 
+        //          divided by the area of the current pixel
+        const Double_t ratio = fCam->GetPixRatio(id);
+        const Double_t sigma = pix.GetRms();
+
+        fSigmaPixTheta.Fill(theta, (Double_t)id, sigma*sqrt(ratio));
+
+        const Double_t diff = sigma*sigma*ratio - mysig*mysig;
+        fDiffPixTheta.Fill(theta, (Double_t)id, diff);
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Update the projections and (if possible) set log scales before painting
+//
+void MHSigmaTheta::Paint(Option_t *opt)
+{
+    TVirtualPad *padsave = gPad;
+
+    TH1D* h;
+
+    padsave->cd(1);
+    if ((h = (TH1D*)gPad->FindObject("ProjX-Theta")))
+    {
+        ProjectionX(*h, fSigmaTheta);
+        if (h->GetEntries()!=0)
+            gPad->SetLogy();
+    }
+
+    padsave->cd(4);
+    if ((h = (TH1D*)gPad->FindObject("ProjY-sigma")))
+        ProjectionY(*h, fSigmaTheta);
+
+    gPad = padsave;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw the histogram
+//
+void MHSigmaTheta::Draw(Option_t *opt)
+{
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    AppendPad("");
+
+    pad->Divide(3, 2);
+
+    // draw the 2D histogram Sigmabar versus Theta
+    TH1 *h;
+
+    pad->cd(1);
+    gPad->SetBorderMode(0);
+    h = fSigmaTheta.ProjectionX("ProjX-Theta", -1, 9999, "E");
+    h->SetDirectory(NULL);
+    h->SetTitle("Distribution of \\Theta");
+    h->SetXTitle("\\Theta [\\circ]");
+    h->SetYTitle("No.of events");
+    h->Draw(opt);
+    h->SetBit(kCanDelete);
+
+    pad->cd(2);
+    gPad->SetBorderMode(0);
+    h = fDiffPixTheta.Project3D("zx");
+    h->SetDirectory(NULL);
+    h->SetTitle("\\sigma_{ped}^{2}-\\bar{\\sigma}_{ped}^{2} vs. \\Theta (all pixels)");
+    h->SetXTitle("\\Theta [\\circ]");
+    h->SetYTitle("\\sigma_{ped}^{2}-\\bar{\\sigma}_{ped}^{2}");
+    h->Draw("box");
+    h->SetBit(kCanDelete);
+
+    pad->cd(3);
+    gPad->SetBorderMode(0);
+    h = fSigmaPixTheta.Project3D("zx");
+    h->SetDirectory(NULL);
+    h->SetTitle("\\sigma_{ped} vs. \\Theta (all pixels)");
+    h->SetXTitle("\\Theta [\\circ]");
+    h->SetYTitle("\\sigma_{ped}");
+    h->Draw("box");
+    h->SetBit(kCanDelete);
+
+    //pad->cd(7);
+    //gPad->SetBorderMode(0);
+    //h = fSigmaTheta.ProjectionY("ProjY-sigma", -1, 9999, "E");
+    //h->SetDirectory(NULL);
+    //h->SetTitle("Distribution of \\bar{\\sigma}_{ped}");
+    //h->SetXTitle("\\bar{\\sigma}_{ped}");
+    //h->SetYTitle("No.of events");
+    //h->Draw(opt);
+    //h->SetBit(kCanDelete);
+
+    pad->cd(5);
+    gPad->SetBorderMode(0);
+    h = fDiffPixTheta.Project3D("zy");
+    h->SetDirectory(NULL);
+    h->SetTitle("\\sigma_{ped}^{2}-\\bar{\\sigma}_{ped}^{2} vs. pixel Id (all  \\Theta)");
+    h->SetXTitle("Pixel Id");
+    h->SetYTitle("\\sigma_{ped}^{2}-\\bar{\\sigma}_{ped}^{2}");
+    h->Draw("box");
+    h->SetBit(kCanDelete);
+
+    pad->cd(6);
+    gPad->SetBorderMode(0);
+    h = fSigmaPixTheta.Project3D("zy");
+    h->SetDirectory(NULL);
+    h->SetTitle("\\sigma_{ped} vs. pixel Id (all  \\Theta)");
+    h->SetXTitle("Pixel Id");
+    h->SetYTitle("\\sigma_{ped}");
+    h->Draw("box");
+    h->SetBit(kCanDelete);
+
+    pad->cd(4);
+    fSigmaTheta.Draw(opt);
+
+    //pad->cd(8);
+    //fDiffPixTheta.Draw(opt);
+
+    //pad->cd(9);
+    //fSigmaPixTheta.Draw(opt);
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mhist/MHSigmaTheta.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHSigmaTheta.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHSigmaTheta.h	(revision 9661)
@@ -0,0 +1,65 @@
+#ifndef MARS_MHSigmaTheta
+#define MARS_MHSigmaTheta
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+#ifndef ROOT_TH2
+#include <TH2.h>
+#endif
+
+#ifndef ROOT_TH3
+#include <TH3.h>
+#endif
+
+class MGeomCam;
+class MCerPhotEvt;
+class MMcEvt;
+class MPedPhotCam;
+class MSigmabar;
+class MParList;
+
+
+class MHSigmaTheta : public MH
+{
+private:
+    const MGeomCam *fCam;        //!
+    MPedPhotCam    *fPed;        //!
+    MCerPhotEvt    *fEvt;        //!
+    MSigmabar      *fSigmabar;   //!
+    MMcEvt         *fMcEvt;      //!
+ 
+    TH2D fSigmaTheta;    // 2D-distribution sigmabar versus Theta; 
+                         // sigmabar is the average pedestasl sigma in an event
+    TH3D fSigmaPixTheta; // 3D-distr.:Theta, pixel, pedestal sigma
+    TH3D fDiffPixTheta;  // 3D-distr.:Theta, pixel, sigma^2-sigmabar^2
+
+    void Paint(Option_t *opt="");
+
+public:
+    MHSigmaTheta(const char *name=NULL, const char *title=NULL);
+
+    Bool_t SetupFill(const MParList *plist);
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+
+    const TH2D *GetSigmaTheta() { return &fSigmaTheta; }
+    const TH2D *GetSigmaTheta() const { return &fSigmaTheta; }
+
+    const TH3D *GetSigmaPixTheta() { return &fSigmaPixTheta; }
+    const TH3D *GetSigmaPixTheta() const { return &fSigmaPixTheta; }
+
+    const TH3D *GetDiffPixTheta() { return &fDiffPixTheta; }
+    const TH3D *GetDiffPixTheta() const { return &fDiffPixTheta; }
+
+    void Draw(Option_t *option="");
+
+    ClassDef(MHSigmaTheta, 1) //2D-histogram  sigmabar vs. Theta
+};
+
+#endif
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mhist/MHSigmabarTheta.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHSigmabarTheta.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHSigmabarTheta.cc	(revision 9661)
@@ -0,0 +1,137 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Robert Wagner 10/2002 <mailto:magicsoft@rwagner.de>
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MHSigmabarTheta                                                         //
+//                                                                          //
+//  2D-Histogram in Sigmabar and Theta                                      //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MHSigmabarTheta.h"
+
+#include <TCanvas.h>
+
+#include <math.h>
+
+#include "MMcEvt.hxx"
+#include "MSigmabar.h"
+
+#include "MBinning.h"
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHSigmabarTheta);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor. It sets name and title of the histogram. 
+//
+MHSigmabarTheta::MHSigmabarTheta(const char *name, const char *title)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHSigmabarTheta";
+    fTitle = title ? title : "3-D histogram in sigmabar and theta";
+
+    fHist.SetDirectory(NULL);
+
+    fHist.SetTitle("3D-plot of sigmabar and theta");
+    fHist.SetXTitle("\\theta [\\circ]");
+    fHist.SetYTitle("\\bar{\\sigma}");
+    fHist.SetZTitle("N");
+}
+
+// --------------------------------------------------------------------------
+//
+// Set binnings and prepare filling of the histogram
+// 
+Bool_t MHSigmabarTheta::SetupFill(const MParList *plist)
+{
+   fMcEvt = (MMcEvt*)plist->FindObject("MMcEvt");
+   if (!fMcEvt)
+   {
+       *fLog << err << "MMcEvt not found... aborting." << endl;
+       return kFALSE;
+   }
+
+   fSigmabar = (MSigmabar*)plist->FindObject("MSigmabar");
+   if (!fSigmabar)
+   {
+       *fLog << err << "MSigmabar not found... aborting." << endl;
+       return kFALSE;
+   }
+
+   MBinning* binstheta  = (MBinning*)plist->FindObject("BinningTheta");
+   if (!binstheta)
+   {
+       *fLog << err << "BinningTheta [MBinning] not found... aborting." << endl;
+       return kFALSE;      
+   }
+   MBinning* binssigmabar = (MBinning*)plist->FindObject("BinningSigmabar");
+   if (!binssigmabar)
+   {
+       *fLog << err << "BinningSigmabar [MBinning] not found... aborting." << endl;
+       return kFALSE;      
+   }
+
+   SetBinning(&fHist, binstheta, binssigmabar);
+
+   fHist.Sumw2(); 
+
+   return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the histogram
+// 
+Bool_t MHSigmabarTheta::Fill(const MParContainer *par, const Stat_t w)
+{
+    fHist.Fill(fMcEvt->GetTheta()*kRad2Deg, fSigmabar->GetSigmabar(), w);
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw the histogram
+// 
+void MHSigmabarTheta::Draw(Option_t *opt)
+{
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    AppendPad("");
+
+    fHist.Draw(opt);
+    
+    pad->Modified();
+    pad->Update();
+}
+
Index: /tags/Mars_V0-8-5/Mars/mhist/MHSigmabarTheta.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHSigmabarTheta.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHSigmabarTheta.h	(revision 9661)
@@ -0,0 +1,47 @@
+#ifndef MARS_MHSigmabarTheta
+#define MARS_MHSigmabarTheta
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+#ifndef ROOT_TH2
+#include <TH2.h>
+#endif
+
+class MMcEvt;
+class MSigmabar;
+class TH2D;
+class MParList;
+
+
+class MHSigmabarTheta : public MH
+{
+private:
+    MMcEvt    *fMcEvt;        //!
+    MSigmabar *fSigmabar;     //!
+
+    TH2D fHist;
+
+public:
+    MHSigmabarTheta(const char *name=NULL, const char *title=NULL);
+
+    Bool_t SetupFill(const MParList *pList);
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+
+    const TH2D *GetHist()       { return &fHist; }
+    const TH2D *GetHist() const { return &fHist; }
+
+    TH1 *GetHistByName(const TString name) { return &fHist; }
+
+    void Draw(Option_t *option="");
+
+    ClassDef(MHSigmabarTheta, 1) //3D-histogram in alpha, Energy and theta
+};
+
+#endif
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mhist/MHStarMap.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHStarMap.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHStarMap.cc	(revision 9661)
@@ -0,0 +1,420 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz    12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Wolfgang Wittek 02/2004 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// 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.
+//
+// For a given a shower, a series of points along its main axis are filled 
+// into the 2-dim histogram (x, y) of the camera plane.
+//
+// Before filling a point (x, y) into the histogram it is
+//        - shifted by (xSrc, ySrc)   (the expected source position)
+//        - and rotated in order to compensate the rotation of the
+//          sky image in the camera
+//
+// To be done:
+//  - simplification of the algorithm, by doing all translation before
+//    calculation of the line
+//  - the center of rotation need not to be the camera center
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MHStarMap.h"
+
+#include <TH2.h>
+#include <TStyle.h>   // gStyle
+#include <TColor.h>   // SetRGB
+#include <TCanvas.h>  // TCanvas
+#include <TVector2.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MAstro.h"
+#include "MGeomCam.h"
+#include "MHillas.h"
+#include "MBinning.h"
+#include "MSrcPosCam.h"
+#include "MObservatory.h"
+#include "MPointingPos.h"
+
+ClassImp(MHStarMap);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Create the star map histogram
+//
+MHStarMap::MHStarMap(const char *name, const char *title)
+    : fMm2Deg(-1), fUseMmScale(kTRUE)
+{
+    //
+    //  default constructor
+    //  creates an a list of histograms for all pixels and both gain channels
+    //
+
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHStarMap" ;
+    fTitle = title ? title : "Container for a Star Map" ;
+
+    //
+    //   loop over all Pixels and create two histograms
+    //   one for the Low and one for the High gain
+    //   connect all the histogram with the container fHist
+    //
+    fStarMap = new TH2F("StarMap", " 2D Hillas Star Map ",
+                        150, -300, 300,
+                        150, -300, 300);
+
+    fStarMap->SetDirectory(NULL);
+
+    fStarMap->SetXTitle("x [mm]");
+    fStarMap->SetYTitle("y [mm]");
+    fStarMap->SetZTitle("Counts");
+}
+
+// --------------------------------------------------------------------------
+//
+// delete the histogram instance
+//
+MHStarMap::~MHStarMap()
+{
+    delete fStarMap;
+}
+
+// --------------------------------------------------------------------------
+//
+// Setup the Binning for the histograms automatically if the correct
+// instances of MBinning (with the names 'BinningCamera')
+// are found in the parameter list
+// Use this function if you want to set the conversion factor which
+// is used to convert the mm-scale in the camera plain into the deg-scale
+// used for histogram presentations. The conversion factor is part of
+// the camera geometry. Please create a corresponding MGeomCam container.
+//
+Bool_t MHStarMap::SetupFill(const MParList *plist)
+{
+    const MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam");
+    if (geom)
+    {
+        fMm2Deg = geom->GetConvMm2Deg();
+        fUseMmScale = kFALSE;
+
+        fStarMap->SetXTitle("x [\\circ]");
+        fStarMap->SetYTitle("y [\\circ]");
+    }
+
+    fPointPos = (MPointingPos*)plist->FindObject("MPointingPos");
+    if (!fPointPos)
+        *fLog << warn << "MPointingPos not found... no derotation." << endl;
+
+    fSrcPos = (MSrcPosCam*)plist->FindObject(AddSerialNumber("MSrcPosCam"));
+    if (!fSrcPos)
+        *fLog << warn << "MSrcPosCam not found...  no source translation." << endl;
+
+
+    const MBinning *bins = (MBinning*)plist->FindObject("BinningStarMap");
+    if (!bins)
+    {
+        float r = geom ? geom->GetMaxRadius() : 600;
+        r *= 5./6;
+        if (!fUseMmScale)
+            r *= fMm2Deg;
+
+        MBinning b;
+        b.SetEdges(100, -r, r);
+        SetBinning(fStarMap, &b, &b);
+    }
+    else
+        SetBinning(fStarMap, bins, bins);
+
+    if (!geom)
+    {
+        *fLog << warn << "No Camera Geometry available. Using mm-scale for histograms." << endl;
+        return kTRUE;
+    }
+
+    *fLog << warn << "WARNING - Using MHStarMap doesn't take care of the Source Position!" << endl;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the observatory location "MObservatory" from parameter list
+// 
+Bool_t MHStarMap::ReInit(MParList *pList)
+{
+    fObservatory = (MObservatory*)pList->FindObject(AddSerialNumber("MObservatory"));
+    if (!fObservatory)
+        *fLog << err << "MObservatory not found... no derotation." << endl;
+
+    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 Stat_t w)
+{
+    const MHillas &h = *(MHillas*)par;
+
+    const Float_t delta = h.GetDelta();
+
+    const Float_t m    = TMath::Tan(delta);
+
+    const Float_t cosd = 1.0/TMath::Sqrt(m*m+1);
+    const Float_t sind = TMath::Sqrt(1-cosd*cosd);
+
+    Float_t t = h.GetMeanY() - m*h.GetMeanX();
+
+    TVector2 src;
+    if (fSrcPos)
+        src = fSrcPos->GetXY();
+
+    if (!fUseMmScale)
+    {
+        t   *= fMm2Deg;
+        src *= fMm2Deg;
+    }
+
+    // get step size ds along the main axis of the ellipse
+    const TAxis &axex = *fStarMap->GetXaxis();
+    const Float_t xmin = axex.GetXmin();
+    const Float_t xmax = axex.GetXmax();
+
+    // FIXME: Fixed number?
+    const Float_t ds = (xmax-xmin) / 200.0;
+
+    // Fill points along the main axis of the shower into the histogram;
+    // before filling 
+    //   - perform a translation by (xSource, ySource)
+    //   - and perform a rotation to compensate the rotation of the
+    //     sky image in the camera
+    const Double_t rho = fPointPos && fObservatory ?
+        fPointPos->RotationAngle(*fObservatory) : 0;
+
+    if (m>-1 && m<1)
+    {
+        const Float_t dx = ds * cosd;
+
+        for (float x=xmin+dx/2; x<(xmax-xmin)+dx; x+=dx)
+        {
+            TVector2 v(x, m*x+t);
+            v -= src;
+            v=v.Rotate(-rho);
+
+            fStarMap->Fill(v.X(), v.Y(), w);
+        }
+    }
+    else
+    {
+        const TAxis &axey = *fStarMap->GetYaxis();
+        const Float_t ymin = axey.GetXmin();
+        const Float_t ymax = axey.GetXmax();
+
+        const float dy = ds * sind;
+
+        for (float y=ymin+dy/2; y<(ymax-ymin)+dy; y+=dy)
+        {
+            TVector2 v((y-t)/m, y);
+            v -= src;
+            v=v.Rotate(-rho);
+
+            fStarMap->Fill(v.X(), v.Y(), w);
+        }
+    }
+
+    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
+{
+    return MH::DrawClone(opt, 500, 500);
+}
+
+// --------------------------------------------------------------------------
+//
+// 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 *)
+{
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this, 500, 500);
+    pad->SetBorderMode(0);
+
+    pad->Divide(1,1);
+
+    pad->cd(1);
+    gPad->SetBorderMode(0);
+
+    AppendPad("");
+}
+
+void MHStarMap::Paint(Option_t *opt)
+{
+    //
+    // Maintain aspect ratio
+    //
+    const float w = gPad->GetWw();
+    const float h = gPad->GetWh();
+
+    if (h<w)
+        gPad->SetPad((1.-h/w)/2, 0, (h/w+1)/2, 1);
+    else
+        gPad->SetPad(0, (1.-w/h)/2, 1, (w/h+1)/2);
+
+    //
+    // Maintain colors
+    //
+    PrepareDrawing();
+
+    //
+    // Paint Histogram
+    //
+    fStarMap->Paint("colz");
+}
Index: /tags/Mars_V0-8-5/Mars/mhist/MHStarMap.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHStarMap.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHStarMap.h	(revision 9661)
@@ -0,0 +1,57 @@
+#ifndef MARS_MHStarMap
+#define MARS_MHStarMap
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+class TH2F;
+class MHillas;
+class MSrcPosCam;
+class MObservatory;
+class MPointingPos;
+
+class MHStarMap : public MH
+{
+private:
+    MSrcPosCam   *fSrcPos;      //!
+    MPointingPos *fPointPos;    //!
+    MObservatory *fObservatory; //!
+
+    TH2F *fStarMap;      //->
+
+    Float_t fMm2Deg;
+
+    Bool_t fUseMmScale;
+
+    Float_t fCosLat;  //!
+    Float_t fSinLat;  //!
+
+    void PrepareDrawing() const;
+
+    void Paint(Option_t *opt="");
+
+    Bool_t SetupFill(const MParList *pList);
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+
+    Bool_t ReInit(MParList *pList);
+    void GetRotationAngle(Double_t &sin, Double_t &cos);
+
+public:
+    MHStarMap(const char *name=NULL, const char *title=NULL);
+    ~MHStarMap();
+
+    void SetMmScale(Bool_t mmscale=kTRUE);
+    void SetMm2Deg(Float_t mmdeg);
+
+    TH1 *GetHistByName(const TString name) { return (TH1*)fStarMap; }
+
+    TH2F *GetHist() { return fStarMap; }
+
+    void Draw(Option_t *opt=NULL);
+    TObject *DrawClone(Option_t *opt=NULL) const;
+
+    ClassDef(MHStarMap, 1) // Container to hold the Starmap
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mhist/MHSupercuts.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHSupercuts.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHSupercuts.cc	(revision 9661)
@@ -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): Wolfgang Wittek  2003 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////
+//
+// MHSupercuts
+//
+// This class contains histograms for the supercuts
+//
+// the histograms are filled during the optimization of the supercuts
+//
+///////////////////////////////////////////////////////////////////////
+#include "MHSupercuts.h"
+
+#include <math.h>
+
+#include <TH1.h>
+#include <TH2.h>
+#include <TPad.h>
+#include <TCanvas.h>
+
+#include "MParList.h"
+#include "MHFindSignificance.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHSupercuts);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Setup four histograms for Alpha, and Dist
+//
+MHSupercuts::MHSupercuts(const char *name, const char *title)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHSupercuts";
+    fTitle = title ? title : "Container for histograms for the supercuts";
+
+
+    fDegree = new TH1F("Degree", "Degree of polynomial",   5, -0.5,  4.5);
+    fProb   = new TH1F("Prob",   "chi2 probability",      40,    0,  1.0);
+    fNdf    = new TH1F("NDF",    "NDF of polynomial fit", 60, -0.5, 59.5);
+    fGamma  = new TH1F("gamma",  "gamma",                 40,  0.0,  8.0);
+    fNexNon = new TH1F("NexNon", "Nex / Non",             50,  0.0,  1.0);
+    fSigLiMa= new TH1F("Significance", "significance of gamma signal",   
+                                                          60,  0.0, 120.0);
+    fSigtoBackg= new TH2F("SigtoBackg", "Significance vs signal/backg ratio",
+                          50,  0.0,  10.0, 60, 0.0, 120.0);
+    fSigDegree = new TH2F("SigDegree", "Significance vs Degree of polynomial",
+                           5, -0.5,   4.5, 60, 0.0, 120.0);
+    fSigNbins  = new TH2F("SigNbins", "Significance vs number of bins",
+                           40, -0.5, 79.5, 60, 0.0, 120.0);
+
+    fDegree->SetDirectory(NULL);
+    fProb->SetDirectory(NULL);
+    fNdf->SetDirectory(NULL);
+    fGamma->SetDirectory(NULL);
+    fNexNon->SetDirectory(NULL);
+    fSigLiMa->SetDirectory(NULL);
+    fSigtoBackg->SetDirectory(NULL);
+    fSigDegree->SetDirectory(NULL);
+    fSigNbins->SetDirectory(NULL);
+
+    fDegree->SetXTitle("order of polynomial");
+    fProb->SetXTitle("chi2 probability of polynomial fit");
+    fNdf->SetXTitle("NDF of polynomial fit");
+    fGamma->SetXTitle("gamma");
+    fNexNon->SetXTitle("Nex / Non");
+    fSigLiMa->SetXTitle("significance");
+
+    fSigtoBackg->SetXTitle("signa./background ratio");
+    fSigtoBackg->SetYTitle("significance");
+
+    fSigDegree->SetXTitle("order of polynomial");
+    fSigDegree->SetYTitle("significance");
+
+    fSigNbins->SetXTitle("number of bins");
+    fSigNbins->SetYTitle("significance");
+
+    fDegree->SetYTitle("Counts");
+    fProb->SetYTitle("Counts");
+    fNdf->SetYTitle("Counts");
+    fGamma->SetYTitle("Counts");
+    fNexNon->SetYTitle("Counts");
+    fSigLiMa->SetYTitle("Counts");
+
+    fSigtoBackg->SetZTitle("Counts");
+    fSigDegree->SetZTitle("Counts");
+    fSigNbins->SetZTitle("Counts");
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the histograms
+//
+MHSupercuts::~MHSupercuts()
+{
+    delete fDegree;
+    delete fProb;
+    delete fNdf;
+    delete fGamma;
+    delete fNexNon;
+    delete fSigLiMa;
+
+    delete fSigtoBackg;
+    delete fSigDegree;
+    delete fSigNbins;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the histograms from the 'MHFindSignificance' container
+//
+Bool_t MHSupercuts::Fill(const MParContainer *par, const Stat_t w)
+{
+    if (!par)
+    {
+        *fLog << err << "MHSupercuts::Fill: Pointer (!=NULL) expected." << endl;
+        return kFALSE;
+    }
+
+    MHFindSignificance &h = *(MHFindSignificance*)par;
+
+    fDegree    ->Fill(h.GetDegree( ), w);
+    fProb      ->Fill(h.GetProb(),    w);
+    fNdf       ->Fill(h.GetNdf(),     w);
+    fGamma     ->Fill(h.GetGamma(),   w);
+
+    Double_t ratio = h.GetNon()>0.0 ? h.GetNex()/h.GetNon() : 0.0;
+    fNexNon    ->Fill(ratio,          w);
+
+    fSigLiMa   ->Fill(h.GetSigLiMa(), w);
+
+    Double_t sigtobackg = h.GetNbg()!=0.0 ? h.GetNex() / h.GetNbg() : 0.0;
+    fSigtoBackg->Fill(sigtobackg,    h.GetSigLiMa(), w);
+
+    fSigDegree ->Fill(h.GetDegree(), h.GetSigLiMa(), w);
+    fSigNbins  ->Fill(h.GetMbins(),  h.GetSigLiMa(), w);
+
+    return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// 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 MHSupercuts::Draw(Option_t *)
+{
+  //TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
+  //pad->SetBorderMode(0);
+  //AppendPad("");
+
+    TCanvas *pad = new TCanvas("Supercuts", "Supercut plots", 900, 900);
+    gROOT->SetSelectedPad(NULL);
+
+    pad->Divide(3, 3);
+
+    pad->cd(1);
+    gPad->SetBorderMode(0);
+    fDegree->Draw();
+
+    pad->cd(2);
+    gPad->SetBorderMode(0);
+    fProb->Draw();
+
+    pad->cd(3);
+    gPad->SetBorderMode(0);
+    fNdf->Draw();
+
+    pad->cd(4);
+    gPad->SetBorderMode(0);
+    fGamma->Draw();
+
+    pad->cd(5);
+    gPad->SetBorderMode(0);
+    fNexNon->Draw();
+
+    pad->cd(6);
+    gPad->SetBorderMode(0);
+    fSigLiMa->Draw();
+
+    pad->cd(7);
+    gPad->SetBorderMode(0);
+    fSigtoBackg->Draw();
+
+    pad->cd(8);
+    gPad->SetBorderMode(0);
+    fSigDegree->Draw();
+
+    pad->cd(9);
+    gPad->SetBorderMode(0);
+    fSigNbins->Draw();
+
+    pad->Modified();
+    pad->Update();
+}
Index: /tags/Mars_V0-8-5/Mars/mhist/MHSupercuts.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHSupercuts.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHSupercuts.h	(revision 9661)
@@ -0,0 +1,42 @@
+#ifndef MARS_MHSupercuts
+#define MARS_MHSupercuts
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+class TH1F;
+class TH2F;
+
+class MHSupercuts : public MH
+{
+private:
+    TH1F *fDegree;     // order of polynomial for background fit
+    TH1F *fProb;       // chi2 probability of polynomial fit
+    TH1F *fNdf;        // NDF of polynomial fit
+    TH1F *fGamma;      // Nbg = gamma * Noff
+    TH1F *fNexNon;     // no.of excess events / no.of events in signal region 
+    TH1F *fSigLiMa;    // significance of gamma signal
+
+    TH2F *fSigtoBackg; // significance vs signal to background ratio (Nex/Nbg)
+    TH2F *fSigDegree;  // significance vs order of polynomial
+    TH2F *fSigNbins;   // significance vs number of bins
+
+
+public:
+    MHSupercuts(const char *name=NULL, const char *title=NULL);
+    ~MHSupercuts();
+
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+
+    void Draw(Option_t *opt=NULL);
+
+    ClassDef(MHSupercuts, 1) // Container which holds histograms for the supercuts
+};
+
+#endif
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mhist/MHThetabarTheta.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHThetabarTheta.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHThetabarTheta.cc	(revision 9661)
@@ -0,0 +1,121 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): 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);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor. It sets name and title of the histogram.
+//
+MHThetabarTheta::MHThetabarTheta(const char *name, const char *title)
+    : fHist()
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHThetabarTheta";
+    fTitle = title ? title : "1-D profile histogram Thetabar vs. Theta";
+
+    fHist.SetDirectory(NULL);
+
+    fHist.SetXTitle("\\Theta [\\circ]");
+    fHist.SetYTitle("\\bar{\\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 the histogram
+//
+void MHThetabarTheta::Draw(Option_t *opt)
+{
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    AppendPad("");
+
+    fHist.Draw(opt);
+
+    pad->Modified();
+    pad->Update();
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the histogram
+//
+Bool_t MHThetabarTheta::Fill(const MParContainer *par, const Stat_t w)
+{
+    const Double_t theta = fMcEvt->GetTelescopeTheta()*kRad2Deg;
+
+    fHist.Fill(theta, theta, w);
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mhist/MHThetabarTheta.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHThetabarTheta.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHThetabarTheta.h	(revision 9661)
@@ -0,0 +1,52 @@
+#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);
+
+    Bool_t SetupFill(const MParList *pList);
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+
+    const TProfile *GetHist() { return &fHist; }
+    const TProfile *GetHist() const { return &fHist; }
+
+    TH1 *GetHistByName(const TString name) { return &fHist; }
+
+    void Draw(Option_t *option="");
+
+    ClassDef(MHThetabarTheta, 0) //Profile histogram Thetabar vs. time
+
+};
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mhist/MHThetabarTime.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHThetabarTime.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHThetabarTime.cc	(revision 9661)
@@ -0,0 +1,127 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): 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);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// 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("t [s]");
+    fHist.SetYTitle("\\bar{\\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 the histogram
+//
+void MHThetabarTime::Draw(Option_t *opt)
+{
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    AppendPad("");
+
+    fHist.Draw(opt);
+
+    pad->Modified();
+    pad->Update();
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the histogram
+//
+Bool_t MHThetabarTime::Fill(const MParContainer *par, const Stat_t w)
+{
+    fHist.Fill(*fTime, fMcEvt->GetTheta()*kRad2Deg, w);
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mhist/MHThetabarTime.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHThetabarTime.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHThetabarTime.h	(revision 9661)
@@ -0,0 +1,44 @@
+#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);
+
+    Bool_t SetupFill(const MParList *pList);
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+
+    const TProfile *GetHist() { return &fHist; }
+    const TProfile *GetHist() const { return &fHist; }
+
+    TH1 *GetHistByName(const TString name) { return &fHist; }
+
+    void Draw(Option_t *option="");
+
+    ClassDef(MHThetabarTime, 0) //Profile histogram Thetabar vs. time
+
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mhist/MHTimeDiffTheta.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHTimeDiffTheta.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHTimeDiffTheta.cc	(revision 9661)
@@ -0,0 +1,155 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): 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);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// 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 the histogram
+//
+void MHTimeDiffTheta::Draw(Option_t *opt)
+{
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    AppendPad("");
+
+    TH1 *h;
+
+    pad->Divide(2,2);
+
+    pad->cd(1);
+    gPad->SetLogy();
+    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);;
+
+    pad->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);;
+
+    pad->cd(3);
+    fHist.Draw(opt);
+
+    pad->Modified();
+    pad->Update();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Fill the histogram
+//
+Bool_t MHTimeDiffTheta::Fill(const MParContainer *par, const Stat_t w)
+{
+    const Double_t time = *fTime;
+
+    fHist.Fill(time-fLastTime, fMcEvt->GetTelescopeTheta()*kRad2Deg, w);
+    fLastTime = time;
+
+    return kTRUE;
+}
+
Index: /tags/Mars_V0-8-5/Mars/mhist/MHTimeDiffTheta.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHTimeDiffTheta.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHTimeDiffTheta.h	(revision 9661)
@@ -0,0 +1,42 @@
+#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;  //!
+    Double_t fLastTime;
+
+    TH2D    fHist;
+
+public:
+    MHTimeDiffTheta(const char *name=NULL, const char *title=NULL);
+
+    Bool_t SetupFill(const MParList *pList);
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+
+    const TH2D *GetHist() { return &fHist; }
+    const TH2D *GetHist() const { return &fHist; }
+
+    TH1 *GetHistByName(const TString name) { return &fHist; }
+
+    void Draw(Option_t *option="");
+
+    ClassDef(MHTimeDiffTheta, 0) //2D-histogram  time-diff vs. Theta
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mhist/MHTimeDiffTime.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHTimeDiffTime.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHTimeDiffTime.cc	(revision 9661)
@@ -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    1/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Wolfgang Wittek 1/2002 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  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);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// 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 the histogram
+//
+void MHTimeDiffTime::Draw(Option_t *opt)
+{
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    AppendPad("");
+
+    pad->Divide(2,2);
+
+    TH1D *h;
+
+    pad->cd(1);
+    gPad->SetLogy();
+    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);
+
+    pad->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);
+
+    pad->cd(3);
+    fHist.DrawCopy(opt);
+
+    pad->Modified();
+    pad->Update();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Fill the histogram
+//
+Bool_t MHTimeDiffTime::Fill(const MParContainer *par, const Stat_t w)
+{
+    const Double_t time = *fTime;
+
+    fHist.Fill(time-fLastTime, time, w);
+    fLastTime = time;
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mhist/MHTimeDiffTime.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHTimeDiffTime.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHTimeDiffTime.h	(revision 9661)
@@ -0,0 +1,40 @@
+#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;   //!
+    Double_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 Stat_t w=1);
+
+    const TH2D *GetHist() { return &fHist; }
+    const TH2D *GetHist() const { return &fHist; }
+
+    TH1 *GetHistByName(const TString name) { return &fHist; }
+
+    void Draw(Option_t *option="");
+
+    ClassDef(MHTimeDiffTime, 0) //2D-histogram  time-diff vs. time
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mhist/MHTrigLvl0.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHTrigLvl0.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHTrigLvl0.cc	(revision 9661)
@@ -0,0 +1,234 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Abelardo Moralejo 06/2003 <mailto:moralejo@pd.infn.it>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHTrigLvl0
+//
+// This is intended to be a sort of "level 0 trigger display". What it really
+// does is to store the number of events of a data file in which each pixel 
+// has gone above a given threshold (fPixelThreshold) which is chosen when
+// calling the constructor. Displaying a camera view with these values can
+// help identify noisy pixels. See the macro pixfixrate.C to see an example
+// of its use. Many things are to be fixed. Only inner pixels are shown now
+// (which are anyhow those involved in the trigger), and the camera geometry
+// (number of pixels, and how many inner ones) is not yet read from the input 
+// file. 
+// The "pedestal" we are using is just the signal in the first ADC slice 
+// (seems reasonable from the inspection of the available test data files).
+//
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MHTrigLvl0.h"
+
+#include <TCanvas.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MRawEvtData.h"
+#include "MRawEvtPixelIter.h"
+#include "MCamDisplay.h"
+
+#include "MGeomCam.h"
+#include "MGeomPix.h"
+
+ClassImp(MHTrigLvl0);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Reset all pixels to 0 and reset fEntries to 0.
+//
+void MHTrigLvl0::Clear()
+{
+    fSum.Reset();
+    for (int i=0; i<577; i++)
+    {
+        fSum.AddPixel(i, 0, 0);
+        fSum[i].SetPixelUnused();
+    }
+    fSum.FixSize();
+    fEntries = 0;
+}
+
+// --------------------------------------------------------------------------
+//
+// Initialize the name and title of the task.
+// Resets the sum histogram
+//
+MHTrigLvl0::MHTrigLvl0(const Float_t pixelthreshold, 
+		       const char *name, const char *title)
+    : fCam(NULL), fRawEvt(NULL), fDispl(NULL)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHTrigLvl0";
+    fTitle = title ? title : "Number of hits above per pixel";
+    fPixelThreshold = pixelthreshold;
+
+    Clear();
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the corresponding camera display if available
+//
+MHTrigLvl0::~MHTrigLvl0()
+{
+    if (fDispl)
+        delete fDispl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the event (MRawEvtData) the histogram might be filled with. If
+// it is not given, it is assumed, that it is filled with the argument
+// of the Fill function.
+// Looks for the camera geometry MGeomCam and resets the sum histogram.
+//
+Bool_t MHTrigLvl0::SetupFill(const MParList *plist)
+{
+    fRawEvt = (MRawEvtData*)plist->FindObject("MRawEvtData");
+    if (!fRawEvt)
+    {
+        *fLog << dbginf << "MRawEvtData not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fCam = (MGeomCam*)plist->FindObject("MGeomCam");
+    if (!fCam)
+        *fLog << warn << GetDescriptor() << ": No MGeomCam found." << endl;
+
+    Clear();
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the histograms with data from a MCerPhotEvt-Container.
+//
+Bool_t MHTrigLvl0::Fill(const MParContainer *par, const Stat_t w)
+{
+    MRawEvtData *rawevt = par ? (MRawEvtData*) par : fRawEvt;
+    if (!rawevt)
+    {
+        *fLog << err << dbginf << "No MRawEvtData found..." << endl;
+        return kFALSE;
+    }
+
+    MRawEvtPixelIter pixel(rawevt);
+
+    while(pixel.Next())
+    {
+      const UInt_t pixid = pixel.GetPixelId();
+
+      // FIXME: number of inner pixels should be read from file
+      if (pixid > 396)
+	break;
+      if (pixid == 0)
+	continue;
+
+      fSum[pixid].SetPixelUsed();
+
+      //
+      // FIXME: we now use as "pedestal" the value of the first ADC slice!
+      //
+      Float_t baseline = rawevt->GetNumHiGainSamples() *
+	pixel.GetHiGainSamples()[0];
+
+      Float_t pixel_signal = pixel.GetSumHiGainSamples() - baseline;
+
+      Float_t pixel_is_on = ( pixel_signal > fPixelThreshold)? 1. : 0.;
+
+      fSum[pixid].AddNumPhotons(pixel_is_on);
+    }
+
+    fEntries++;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Set to Unused outer pixels.
+//
+Bool_t MHTrigLvl0::Finalize()
+{
+  //
+  // Show only pixels in the inner region of the camera:
+  // (otherwise, problem with the too different ranges) 
+  //
+  for (Int_t i=0; i<577; i++)
+    // FIXME: read number of total and inner pixels from file
+    {
+      if (i > 396)
+	fSum[i].SetPixelUnused();
+    }
+
+  //  fSum.Scale(fEntries); Now disabled, scale was not readable otherwise.
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw the present 'fill status'
+//
+void MHTrigLvl0::Draw(Option_t *)
+{
+    if (!fCam)
+    {
+        *fLog << warn << "WARNING - Cannot draw " << GetDescriptor() << ": No Camera Geometry available." << endl;
+        return;
+    }
+
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this, 750, 600);
+    pad->SetBorderMode(0);
+
+    AppendPad("");
+}
+
+// --------------------------------------------------------------------------
+//
+// If a camera display is not yet assigned, assign a new one.
+//
+void MHTrigLvl0::Paint(Option_t *option)
+{
+    if (!fCam)
+    {
+        *fLog << warn << "WARNING - Cannot paint " << GetDescriptor() << ": No Camera Geometry available." << endl;
+        return;
+    }
+
+    if (!fDispl)
+        fDispl = new MCamDisplay(fCam);
+
+    fDispl->Fill(fSum);
+    fDispl->Paint();
+}
Index: /tags/Mars_V0-8-5/Mars/mhist/MHTrigLvl0.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHTrigLvl0.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHTrigLvl0.h	(revision 9661)
@@ -0,0 +1,46 @@
+#ifndef MARS_MHTrigLvl0
+#define MARS_MHTrigLvl0
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+#ifndef MARS_MCerPhotEvt
+#include "MCerPhotEvt.h"
+#endif
+
+class TH1D;
+class MCamDisplay;
+class MRawEvtData;
+
+class MHTrigLvl0 : public MH
+{
+private:
+    MCerPhotEvt  fSum;            // storing the sum of triggers
+    Int_t        fEntries;        // number of entries in the histogram
+    MGeomCam    *fCam;            // the present geometry
+    MRawEvtData *fRawEvt;         //! ADC info of the current event
+    MCamDisplay *fDispl;          //! the camera display
+    Float_t      fPixelThreshold; // Threshold (ADC counts a.p.) to consider
+                                  // a pixel as "fired".
+
+public:
+    MHTrigLvl0(const Float_t pixelthreshold = 0, 
+	       const char *name=NULL, const char *title=NULL);
+    ~MHTrigLvl0();
+
+    void Clear();
+
+    Bool_t SetupFill(const MParList *pList);
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+    Bool_t Finalize();
+
+    const MCerPhotEvt &GetSum() const { return fSum; }
+
+    void Draw(Option_t *opt="");
+    void Paint(Option_t *option="");
+
+    ClassDef(MHTrigLvl0, 1) // Histogram to sum level 0 triggers in all pixels
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mhist/MHTriggerLvl0.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHTriggerLvl0.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHTriggerLvl0.cc	(revision 9661)
@@ -0,0 +1,193 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Abelardo Moralejo, 06/2003 <mailto:moralejo@pd.infn.it>
+!   Author(s): Thomas Bretz, 06/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHTriggerLvl0
+//
+// This is intended to be a sort of "level 0 trigger display". What it
+// really does is to store the number of events of a data file in which
+// each pixel has gone above a given threshold (fPixelThreshold) which
+// is chosen when calling the constructor. Displaying a camera view with
+// these values can help identify noisy pixels. See the macro pixfixrate.C
+// to see an example of its use.
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MHTriggerLvl0.h"
+
+#include <TCanvas.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MCamEvent.h"
+#include "MHCamera.h"
+
+#include "MGeomCam.h"
+
+ClassImp(MHTriggerLvl0);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Initialize the name and title of the task.
+// Resets the sum histogram
+//
+MHTriggerLvl0::MHTriggerLvl0(Double_t t, const char *name, const char *title)
+    : fSum(NULL), fEvt(NULL), fType(0), fThreshold(t)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHTriggerLvl0";
+    fTitle = title ? title : "Number of hits above threshold per pixel";
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the corresponding camera display if available
+//
+MHTriggerLvl0::~MHTriggerLvl0()
+{
+    if (fSum)
+        delete fSum;
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the event (MRawEvtData) the histogram might be filled with. If
+// it is not given, it is assumed, that it is filled with the argument
+// of the Fill function.
+// Looks for the camera geometry MGeomCam and resets the sum histogram.
+//
+Bool_t MHTriggerLvl0::SetupFill(const MParList *plist)
+{
+    fEvt = (MCamEvent*)plist->FindObject(fNameEvt, "MCamEvent");
+    if (!fEvt)
+    {
+        if (!fNameEvt.IsNull())
+        {
+            *fLog << err << GetDescriptor() << ": No " << fNameEvt <<" [MCamEvent] available..." << endl;
+            return kFALSE;
+        }
+        *fLog << warn << GetDescriptor() << ": No MCamEvent available..." << endl;
+    }
+
+    MGeomCam *cam = (MGeomCam*)plist->FindObject("MGeomCam");
+    if (!cam)
+    {
+        *fLog << err << GetDescriptor() << ": No MGeomCam found... aborting." << endl;
+        return kFALSE;
+    }
+
+    if (fSum)
+        delete (fSum);
+
+    const TString name = fNameEvt.IsNull() ? fName : fNameEvt;
+
+    fSum = new MHCamera(*cam, name+";avg", fTitle);
+    fSum->SetBit(MHCamera::kProfile);
+    fSum->SetYTitle("% [1]");
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the histograms with data from a MCamEvent-Container.
+//
+Bool_t MHTriggerLvl0::Fill(const MParContainer *par, const Stat_t w)
+{
+    const MCamEvent *evt = par ? dynamic_cast<const MCamEvent*>(par) : fEvt;
+    if (!evt)
+    {
+        *fLog << err << dbginf << "Got no MCamEvent as argument of Fill()..." << endl;
+        return kFALSE;
+    }
+
+    fSum->CntCamContent(*evt, fThreshold, fType);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Scale by the number of events
+//
+Bool_t MHTriggerLvl0::Finalize()
+{
+    //    if (fSum->GetEntries()>0)
+    //        fSum->Scale(100);
+    return kTRUE;
+}
+
+void MHTriggerLvl0::PrintOutliers(Float_t s) const
+{
+    const Double_t mean = fSum->GetMean();
+    const Double_t rms  = fSum->GetRMS();
+
+    *fLog << all << underline << GetDescriptor() << ": Mean=" << mean << ", Rms=" << rms << endl;
+
+    for (unsigned int i=0; i<fSum->GetNumPixels(); i++)
+    {
+        if (!fSum->IsUsed(i))
+            continue;
+
+        if ((*fSum)[i+1]>mean+s*rms)
+            *fLog << "Contents of Pixel-Index #" << i << ": " << (*fSum)[i+1] << " > " << s << "*rms" << endl;
+        // if ((*fSum)[i+1]==0)
+        //     *fLog << "Contents of Pixel-Index #" << i << ": " << (*fSum)[i+1] << " == 0" << endl;
+        // if ((*fSum)[i+1]<fSum->GetMean()-s*fSum->GetRMS())
+        //     *fLog << "Contents of Pixel-Index #" << i << ": " << (*fSum)[i+1] << " < " << s << "*rms" << endl;
+    }
+}
+
+TH1 *MHTriggerLvl0::GetHistByName(const TString name)
+{
+    return fSum;
+}
+
+void MHTriggerLvl0::Draw(Option_t *)
+{
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    pad->Divide(1,2);
+
+    pad->cd(1);
+    /*
+     gPad->SetBorderMode(0);
+     gPad->Divide(1,1);
+     gPad->cd(1);
+     gPad->SetBorderMode(0);
+     */
+    fSum->Draw();
+
+    pad->cd(2);
+    gPad->SetBorderMode(0);
+    fSum->Draw("EPhist");
+}
Index: /tags/Mars_V0-8-5/Mars/mhist/MHTriggerLvl0.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/MHTriggerLvl0.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/MHTriggerLvl0.h	(revision 9661)
@@ -0,0 +1,43 @@
+#ifndef MARS_MHTriggerLvl0
+#define MARS_MHTriggerLvl0
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+class MHCamera;
+class MCamEvent;
+
+class MHTriggerLvl0 : public MH
+{
+private:
+    MHCamera  *fSum;  // storing the sum
+    MCamEvent *fEvt;  //! the current event
+
+    TString fNameEvt;
+
+    Int_t fType;
+    Double_t fThreshold;
+
+    Bool_t SetupFill(const MParList *pList);
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+    Bool_t Finalize();
+
+public:
+    MHTriggerLvl0(Double_t t=0, const char *name=NULL, const char *title=NULL);
+    ~MHTriggerLvl0();
+
+    void SetNameEvt(const TString name) { fNameEvt = name; }
+    void SetType(Int_t type) { fType = type; }
+    void SetThreshold(Double_t t) { fThreshold = t; }
+
+    TH1 *GetHistByName(const TString name="");
+
+    void Draw(Option_t * ="");
+
+    void PrintOutliers(Float_t s) const;
+
+    ClassDef(MHTriggerLvl0, 1) // Histogram to count how often a pixel is above threshold
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mhist/Makefile
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhist/Makefile	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhist/Makefile	(revision 9661)
@@ -0,0 +1,63 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#------------------------------------------------------------------------------
+
+#
+# Handling name of the Root Dictionary Files
+#
+CINT  = Hist
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES = -I. -I../mbase -I../mhbase -I../mraw -I../manalysis      \
+	   -I../mgui -I../mgeom -I../mdata -I../mfilter -I../mimage \
+           -I../mmain -I../mmc -I../mreflector -I../mpointing       \
+           -I../mastro -I../mpedestal
+
+SRCFILES = MHEvent.cc \
+	   MHAlpha.cc \
+           MHCamEvent.cc \
+           MHCamEventRot.cc \
+           MHFadcPix.cc \
+           MHFadcCam.cc \
+           MHStarMap.cc \
+           MHFalseSource.cc \
+           MHEnergyTime.cc \
+           MHEnergyTheta.cc \
+           MHAlphaEnergyTime.cc \
+           MHAlphaEnergyTheta.cc \
+           MHEffOnTime.cc \
+           MHTimeDiffTime.cc \
+           MHTimeDiffTheta.cc \
+           MHCompProb.cc \
+           MHHadronness.cc \
+           MHThetabarTime.cc \
+           MHThetabarTheta.cc \
+           MHGamma.cc \
+           MHFlux.cc \
+	   MHSigmaPixel.cc \
+	   MHSigmabarTheta.cc \
+	   MHTriggerLvl0.cc \
+	   MHOnSubtraction.cc \
+	   MHFindSignificance.cc \
+	   MHCT1Supercuts.cc \
+           MHCamera.cc \
+           MHSupercuts.cc 
+#           MHCurrents.cc \
+
+############################################################
+
+all: $(OBJS)
+
+include ../Makefile.rules
+
+mrproper:	clean rmbak
Index: /tags/Mars_V0-8-5/Mars/mhistmc/HistMcIncl.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhistmc/HistMcIncl.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhistmc/HistMcIncl.h	(revision 9661)
@@ -0,0 +1,6 @@
+#ifndef __CINT__
+
+#include <TF1.h>
+#include <TArrayI.h>
+
+#endif // __CINT__
Index: /tags/Mars_V0-8-5/Mars/mhistmc/HistMcLinkDef.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhistmc/HistMcLinkDef.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhistmc/HistMcLinkDef.h	(revision 9661)
@@ -0,0 +1,20 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#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+;
+#pragma link C++ class MHMcCT1CollectionArea+;
+#pragma link C++ class MHMcTriggerLvl2+;
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mhistmc/MHMcCT1CollectionArea.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhistmc/MHMcCT1CollectionArea.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhistmc/MHMcCT1CollectionArea.cc	(revision 9661)
@@ -0,0 +1,575 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): A. Moralejo 3/2003  <mailto:moralejo@pd.infn.it>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MHMcCT1CollectionArea                                                   //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MHMcCT1CollectionArea.h" 
+
+#include <TH2.h>
+#include <TCanvas.h>
+
+#include "MMcEvt.hxx"
+#include "MH.h"
+#include "MBinning.h"
+#include "MParList.h"
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHMcCT1CollectionArea);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+//  Creates the three necessary histograms:
+//   - selected showers (input)
+//   - all showers (input)
+//   - collection area (result)
+//
+MHMcCT1CollectionArea::MHMcCT1CollectionArea(const char *name, const char *title) :
+    fEaxis(kLog10)
+{ 
+  //
+  //   nbins, minEnergy, maxEnergy defaults:
+  //   we set the energy range from 100 Gev to 30000 GeV (in log, 3.5 orders
+  //   of magnitude) and for each order we take 10 subdivisions --> 35 xbins
+  //   we set the theta range from 12.5 to 48 deg, with 6 bins (the latter
+  //   choice has been done to make the bin centers as close as possible to 
+  //   the actual zenith angles in the CT1 MC sample).
+  //
+
+  fName  = name  ? name  : "MHMcCT1CollectionArea";
+  fTitle = title ? title : "Collection Area vs. log10 Energy";
+
+  fHistAll = new TH2D;
+  fHistSel = new TH2D;
+  fHistCol = new TH2D;
+
+  fHistCol->SetName(fName);
+  fHistAll->SetName("AllEvents");
+  fHistSel->SetName("SelectedEvents");
+
+  fHistCol->SetTitle(fTitle);
+  fHistAll->SetTitle("All showers - Theta vs log10 Energy distribution");
+  fHistSel->SetTitle("Selected showers - Theta vs log10 Energy distribution");
+
+  fHistAll->SetDirectory(NULL);
+  fHistSel->SetDirectory(NULL);
+  fHistCol->SetDirectory(NULL);
+
+  fHistAll->SetXTitle("log10(E [GeV])");
+  fHistAll->SetYTitle("\\Theta [\\circ]");
+  fHistAll->SetZTitle("Counts");
+
+  fHistSel->SetXTitle("log10(E [GeV])");
+  fHistSel->SetYTitle("\\Theta [\\circ]");
+  fHistSel->SetZTitle("Counts");
+
+  fHistCol->SetXTitle("log10(E [GeV])");
+  fHistCol->SetYTitle("theta [deg]");
+  fHistCol->SetZTitle("A [m^{2}]");
+
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the three histograms
+//
+MHMcCT1CollectionArea::~MHMcCT1CollectionArea()
+{
+  delete fHistAll;
+  delete fHistSel;
+  delete fHistCol;
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the binnings and prepare the filling of the histograms
+//
+Bool_t MHMcCT1CollectionArea::SetupFill(const MParList *plist)
+{
+    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.";
+        *fLog << endl;
+        return kFALSE;
+    }
+
+    SetBinning(fHistAll, binsenergy, binstheta);
+    SetBinning(fHistSel, binsenergy, binstheta);
+    SetBinning(fHistCol, binsenergy, binstheta);
+
+    fHistAll->Sumw2();
+    fHistSel->Sumw2();
+    fHistCol->Sumw2();
+
+    if (fEaxis == kLinear)
+    {
+        fTitle = "Collection Area vs. Energy";
+        fHistCol->SetTitle(fTitle);
+        fHistAll->SetTitle("All showers - Theta vs Energy distribution");
+        fHistSel->SetTitle("Selected showers - Theta vs Energy distribution");
+        fHistCol->SetXTitle("E [GeV]");
+        fHistAll->SetXTitle("E [GeV]");
+        fHistSel->SetXTitle("E [GeV]");
+    }
+
+    return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Fill data into the histogram which contains the selected showers
+//
+Bool_t MHMcCT1CollectionArea::Fill(const MParContainer *par, const Stat_t w)
+{ 
+  MMcEvt &mcevt = *(MMcEvt*)par;
+
+  const Double_t E = fEaxis==kLinear ? mcevt.GetEnergy() : log10(mcevt.GetEnergy());
+
+  fHistSel->Fill(E, kRad2Deg*mcevt.GetTelescopeTheta(), w);
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw the histogram with all showers
+//
+void MHMcCT1CollectionArea::DrawAll(Option_t* option)
+{
+  if (!gPad)
+    MH::MakeDefCanvas(fHistAll);
+
+  fHistAll->Draw(option);
+
+  gPad->Modified();
+  gPad->Update();
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw the histogram with the selected showers only.
+//
+void MHMcCT1CollectionArea::DrawSel(Option_t* option)
+{
+  if (!gPad)
+    MH::MakeDefCanvas(fHistSel);
+
+  fHistSel->Draw(option);
+
+  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 *MHMcCT1CollectionArea::DrawClone(Option_t* option) const
+{
+  TCanvas &c = *MakeDefCanvas("CollArea", "Collection area plots", 600, 600);
+  c.Divide(2,2);
+
+  //
+  // This is necessary to get the expected behaviour of DrawClone
+  //
+  gROOT->SetSelectedPad(NULL);
+
+  c.cd(1);
+  if (fEaxis == kLinear)
+    gPad->SetLogx();
+  fHistCol->SetDirectory(NULL);
+  fHistCol->DrawCopy(option);
+
+  c.cd(2);
+  if (fEaxis == kLinear)
+    gPad->SetLogx();
+  fHistSel->SetDirectory(NULL);
+  fHistSel->DrawCopy(option);
+
+  c.cd(3);
+  if (fEaxis == kLinear)
+    gPad->SetLogx();
+  fHistAll->SetDirectory(NULL);
+  fHistAll->DrawCopy(option);
+
+
+  c.Modified();
+  c.Update();
+
+  return &c;
+}
+
+void MHMcCT1CollectionArea::Draw(Option_t* option)
+{
+  if (!gPad)
+    MH::MakeDefCanvas(fHistCol);
+
+  fHistCol->Draw(option);
+
+  gPad->Modified();
+  gPad->Update();
+}
+
+//
+//  Calculate the Efficiency (collection area) for the CT1 MC sample
+//  and set the 'ReadyToSave' flag
+//
+void MHMcCT1CollectionArea::CalcEfficiency()
+{
+  //
+  // Here we estimate the total number of showers in each energy bin
+  // from the known the energy range and spectral index of the generated 
+  // showers. This procedure is intended for the CT1 MC files. The total 
+  // number of generated events, collection area, spectral index etc will be 
+  // set here by hand, so make sure that the MC sample you are using is the 
+  // right one (check all these quantities in your files and compare with
+  // what is written below. In some theta bins, there are two different 
+  // productions, with different energy limits but with the same spectral 
+  // slope. We account for this when calculating the original number of 
+  // events in each energy bin.
+  //
+  // The theta angle with which the MC data (from D. Kranich) were produced 
+  // is not exactly the center of the theta bins we are using (the bin limits 
+  // should be 0.0, 17.5, 23.5, 29.5, 35.5, 42., 50.). The theta variable in 
+  // the MC root file has nevertheless been changed (W.Wittek) to correspond 
+  // to the centers of these bins. Only in the first bin is the difference big:
+  // the data were produced at theta = 15 degrees, whreas the bin center is at
+  // 8.75 degrees. Howeverm at such low z.a. the shower characteristics change 
+  // very slowly with theta.
+  //
+  //
+  //
+  // Only for the binning taken from D. Kranich :
+  //
+
+  for (Int_t thetabin = 1; thetabin <= fHistAll->GetNbinsY(); thetabin++)
+    {
+      // This theta is not exactly the one of the MC events, just about 
+      // the same (bins have been selected so):
+
+      Float_t theta = fHistAll->GetYaxis()->GetBinCenter(thetabin);
+      Float_t thetalo = fHistAll->GetYaxis()->GetBinLowEdge(thetabin);
+      Float_t thetahi = fHistAll->GetYaxis()->GetBinLowEdge(thetabin+1);
+
+      Float_t emin[4];       // Minimum energy in MC sample
+      Float_t emax[4];       // Maximum energy in MC sample
+      Float_t index[4];      // Spectral index
+      Float_t numevts[4];    // Number of events
+      Float_t multfactor[4]; // Factor by which the original number of events in an MC 
+                             // sample has been multiplied to account for the differences
+                             // in the generation areas of the various samples.
+      Float_t rmax;          // Maximum impact parameter range (on ground up to 45 degrees, 
+                             // on a plane perpendicular to Shower axis for 55 and 65 deg).
+
+      memset(emin,    0, 4*sizeof(Float_t));
+      memset(emax,    0, 4*sizeof(Float_t));
+      memset(index,   0, 4*sizeof(Float_t));
+      memset(numevts, 0, 4*sizeof(Float_t));
+      rmax = 0.;
+
+      multfactor[0] = 1.;
+      multfactor[1] = 1.;
+      multfactor[2] = 1.;
+      multfactor[3] = 1.;
+
+      //
+      // rmin and rmax are the minimum and maximum values of the impact 
+      // parameter of the shower on the ground (horizontal plane).
+      //
+
+      Int_t num_MC_samples = 0;
+
+      //if (theta > 8 && theta < 9)   // 8.75 deg
+      if (  thetalo<8.75  && 8.75<thetahi)   // 8.75 deg
+	{
+	  emin[0] = 300.;
+	  emax[0] = 400.;  // Energies in GeV.
+	  index[0] = 1.5;
+	  numevts[0] = 4000.;
+
+	  emin[1] = 400.;
+	  emax[1] = 30000.;
+	  index[1] = 1.5;
+	  numevts[1] = 25740.;
+
+	  rmax = 250.;     //meters
+	  num_MC_samples = 2;
+	}
+      //else if (theta > 20 && theta < 21)  // 20.5 deg 
+      else if (  thetalo<20.5  && 20.5<thetahi)   // 20.5 deg
+	{
+	  emin[0] = 300.;
+	  emax[0] = 400.;  // Energies in GeV.
+	  index[0] = 1.5;
+	  numevts[0] = 6611.;
+
+	  emin[1] = 400.;
+	  emax[1] = 30000.;
+	  index[1] = 1.5;
+	  numevts[1] = 24448.;
+
+	  rmax = 263.;
+	  num_MC_samples = 2;
+	}
+      //else if (theta > 26 && theta < 27)  // 26.5 degrees
+      else if (  thetalo<26.5  && 26.5<thetahi)   // 26.5 deg
+	{
+	  emin[0] = 300.;
+	  emax[0] = 400.;  // Energies in GeV.
+	  index[0] = 1.5;
+	  numevts[0] = 4000.;
+
+	  emin[1] = 400.;
+	  emax[1] = 30000.;
+	  index[1] = 1.5;
+	  numevts[1] = 26316.;
+
+	  rmax = 290.;     //meters
+	  num_MC_samples = 2;
+	}
+      //else if (theta > 32 && theta < 33)  // 32.5 degrees
+      else if (  thetalo<32.5  && 32.5<thetahi)   // 32.5 deg
+	{
+	  emin[0] = 300.;
+	  emax[0] = 30000.;  // Energies in GeV.
+	  index[0] = 1.5;
+	  numevts[0] = 33646.;
+
+	  rmax = 350.;     //meters
+	  num_MC_samples = 1;
+	}
+      //else if (theta > 38 && theta < 39)  // 38.75 degrees
+      else if (  thetalo<38.75  && 38.75<thetahi)   // 38.75 deg
+	{
+	  emin[0] = 300.;
+	  emax[0] = 30000.;  // Energies in GeV.
+	  index[0] = 1.5;
+	  numevts[0] = 38415.;
+
+	  rmax = 380.;     //meters
+	  num_MC_samples = 1;
+	}
+      //else if (theta > 45 && theta < 47)  // 46 degrees
+      else if (  thetalo<46  && 46<thetahi)   // 46 deg
+	{
+	  emin[0] = 300.;
+	  emax[0] = 50000.;  // Energies in GeV.
+	  index[0] = 1.5;
+	  numevts[0] = 30197.;
+
+	  rmax = 565.;     //meters
+	  num_MC_samples = 1;
+	}
+      //else if (theta > 54 && theta < 56)  // 55 degrees
+      else if (  thetalo<55  && 55<thetahi)   // 55 deg
+	{
+	  //
+	  // The value of numevts in the first sample (below) has been
+	  // changed to simplify calculations. We have multiplied it
+	  // times 1.2808997 to convert it to the number it would be if 
+	  // the generation area was equal to that of the other samples 
+	  // at 55 degrees (pi*600**2 m2). This has to be taken into account 
+	  // in the error in the number of events.
+	  //
+
+	  emin[0] = 500.;
+	  emax[0] = 50000.;  // Energies in GeV.
+	  index[0] = 1.5;
+	  numevts[0] = 3298.;
+	  multfactor[0] = 1.2808997;
+
+	  emin[1] = 1500.;
+	  emax[1] = 50000.;  // Energies in GeV.
+	  index[1] = 1.5;
+	  numevts[1] = 22229.;
+
+	  emin[2] = 1500.;
+	  emax[2] = 50000.;  // Energies in GeV.
+	  index[2] = 1.7;
+	  numevts[2] = 7553.;
+
+	  rmax = 600;     //meters
+	  num_MC_samples = 3;
+	}
+
+      //else if (theta > 64 && theta < 66)  // 65 degrees
+      else if (  thetalo<65  && 65<thetahi)   // 65 deg
+	{
+	  emin[0] = 2000.;
+	  emax[0] = 50000.;  // Energies in GeV.
+	  index[0] = 1.5;
+	  numevts[0] = 16310.;
+
+	  emin[1] = 2000.;
+	  emax[1] = 50000.;  // Energies in GeV.
+	  index[1] = 1.7;
+	  numevts[1] = 3000.;
+
+	  //
+	  // The value of numevts in the next two samples (below) has been
+	  // changed to simplify calculations. We have converted them to the
+	  // number it would be if the generation area was equal to that of 
+	  // the first two samples at 65 degrees (pi*800**2 m2) (four times 
+	  // as many, since the original maximum impact parameter was 400
+	  // instead of 800. This is taken into account in the error too.
+	  //
+
+	  emin[2] = 5000.;
+	  emax[2] = 50000.;  // Energies in GeV.
+	  index[2] = 1.5;
+	  numevts[2] = 56584.;
+	  multfactor[2] = 4;
+
+	  emin[3] = 5000.;
+	  emax[3] = 50000.;  // Energies in GeV.
+	  index[3] = 1.7;
+	  numevts[3] = 11464;
+	  multfactor[3] = 4;
+
+	  rmax = 800;     // meters
+	  num_MC_samples = 4;
+	}
+
+
+      for (Int_t i=1; i <= fHistAll->GetNbinsX(); i++)
+	{
+	  Float_t e1;
+	  Float_t e2;
+
+	  if (fEaxis == kLog10)
+	    {
+	      e1 = pow(10.,fHistAll->GetXaxis()->GetBinLowEdge(i));
+	      e2 = pow(10.,fHistAll->GetXaxis()->GetBinLowEdge(i+1));
+	    }
+	  else
+	    {
+	      e1 = fHistAll->GetXaxis()->GetBinLowEdge(i);
+	      e2 = fHistAll->GetXaxis()->GetBinLowEdge(i+1);
+	    }
+
+	  Float_t events = 0.;
+	  Float_t errevents = 0.;
+
+	  for (Int_t sample = 0; sample < num_MC_samples; sample++)
+	    {
+	      Float_t expo = 1.-index[sample];
+	      Float_t k = numevts[sample] / (pow(emax[sample],expo) - pow(emin[sample],expo));
+
+	      if (e2 < emin[sample] || e1 > emax[sample])
+		continue;
+
+	      if (emin[sample] > e1) 
+		e1 = emin[sample];
+
+	      if (emax[sample] < e2) 
+		e2 = emax[sample];
+
+	      events += k * (pow(e2, expo) - pow(e1, expo));
+	      errevents += multfactor[sample] * events;
+	    }
+
+	  errevents= sqrt(errevents);
+
+	  fHistAll->SetBinContent(i, thetabin, events);
+	  fHistAll->SetBinError(i, thetabin, errevents);
+	}
+
+      // -----------------------------------------------------------
+
+      const Float_t dr = TMath::Pi() * rmax * rmax;
+
+      for (Int_t ix = 1; ix <= fHistAll->GetNbinsX(); ix++)
+	{
+	  const Float_t Na = fHistAll->GetBinContent(ix,thetabin);
+
+	  if (Na <= 0)
+	    {
+	      //
+	      // If energy is large, this case means that no or very few events
+	      // were generated at this energy bin. In this case we assign it 
+	      // the effective area of the bin below it in energy. If energy is
+	      // below 1E4, it means that no events triggered -> eff area = 0
+	      //
+	      // NOW DISABLED: because collection area after analysis does not
+	      // saturate at high E!
+	      //
+
+	      /*
+	      if (fHistSel->GetXaxis()->GetBinLowEdge(ix) > 4.)
+		{
+		  fHistCol->SetBinContent(ix, thetabin, fHistCol->GetBinContent(ix-1, thetabin));
+		  fHistCol->SetBinError(ix, thetabin, fHistCol->GetBinError(ix-1, thetabin));
+		}
+	      */
+	      continue;
+	    }
+
+	  const Float_t Ns = fHistSel->GetBinContent(ix,thetabin);
+
+	  // 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 efferr = sqrt((1.-eff)*Ns)/Na;
+
+	  //
+	  // Now we get the total area, perpendicular to the observation direction
+	  // in which the events were generated (correct for cos theta):
+	  //
+
+	  Float_t area = dr;
+
+	  if (theta < 50)
+	    area *= cos(theta*TMath::Pi()/180.);
+
+	  // Above 50 degrees MC was generated with Corsika 6.xx, and the cores
+	  // were distributed on a circle perpendicular to the observation direction, 
+	  // and not on ground, hence the correction for cos(theta) is not necessary.
+	  //
+
+
+	  fHistCol->SetBinContent(ix, thetabin, eff*area);
+	  fHistCol->SetBinError(ix, thetabin, efferr*area);
+
+	}
+    }
+
+  SetReadyToSave();
+}
Index: /tags/Mars_V0-8-5/Mars/mhistmc/MHMcCT1CollectionArea.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhistmc/MHMcCT1CollectionArea.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhistmc/MHMcCT1CollectionArea.h	(revision 9661)
@@ -0,0 +1,53 @@
+#ifndef MARS_MHMcCT1CollectionArea
+#define MARS_MHMcCT1CollectionArea
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+class TH2D;
+
+class MHMcCT1CollectionArea : public MH
+{
+public:
+    enum FillType_t {
+        kLog10,
+        kLinear
+    };
+
+private:
+    TH2D *fHistAll; //  all simulated showers
+    TH2D *fHistSel; //  the selected showers
+    TH2D *fHistCol; //  the collection area
+
+    FillType_t fEaxis;
+
+public:
+    MHMcCT1CollectionArea(const char *name=NULL, const char *title=NULL);
+    ~MHMcCT1CollectionArea();
+
+    Bool_t SetupFill(const MParList *pList);
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+
+    void DrawAll(Option_t *option="");
+    void DrawSel(Option_t *option="");
+
+    void SetEaxis(FillType_t x) { fEaxis = x; }
+
+    const TH2D *GetHist() const { return fHistCol; }
+    const TH2D *GetHAll() const { return fHistAll; }
+    const TH2D *GetHSel() const { return fHistSel; }
+
+    void Draw(Option_t *option="");
+    TObject *DrawClone(Option_t *option="") const;
+
+    void CalcEfficiency();
+
+    ClassDef(MHMcCT1CollectionArea, 1)  // Data Container to calculate Collection Area
+};
+
+#endif
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mhistmc/MHMcCollectionArea.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhistmc/MHMcCollectionArea.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhistmc/MHMcCollectionArea.cc	(revision 9661)
@@ -0,0 +1,340 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Harald Kornmayer 1/2001
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MHMcCollectionArea                                                      //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MHMcCollectionArea.h" 
+
+#include <TH2.h>
+#include <TCanvas.h>
+
+#include "MH.h"
+#include "MBinning.h"
+#include "MHMcEfficiency.h"
+#include "MHMcEnergyImpact.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHMcCollectionArea);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+//  Creates the three necessary histograms:
+//   - selected showers (input)
+//   - all showers (input)
+//   - collection area (result)
+//
+MHMcCollectionArea::MHMcCollectionArea(const char *name, const char *title)
+  : fMCAreaRadius(300.)
+{ 
+    //   initialize the histogram for the distribution r vs E
+    //
+    //   we set the energy range from 2 Gev to 20000 GeV (in log 4 orders
+    //   of magnitude) and for each order we take 25 subdivision --> 100 xbins
+    //
+    //   we set the radius range from 0 m to 500 m with 10 m bin --> 50 ybins
+    //
+    fName  = name  ? name  : "MHMcCollectionArea";
+    fTitle = title ? title : "Collection Area vs. Energy";
+
+    MBinning binsx;
+    MBinning binsy;
+    binsx.SetEdgesLog(100, 2., 20000);
+    binsy.SetEdges   (50,  0,   500);
+
+    fHistAll = new TH2D;
+    fHistSel = new TH2D;
+    fHistCol = new TH1D;
+ 
+    MH::SetBinning(fHistAll, &binsx, &binsy);
+    MH::SetBinning(fHistSel, &binsx, &binsy);
+
+    fHistCol->SetName(fName);
+    fHistAll->SetName("AllEvents");
+    fHistSel->SetName("SelectedEvents");
+
+    fHistCol->SetTitle(fTitle);
+    fHistAll->SetTitle("All showers - Radius vs Energy distribution");
+    fHistSel->SetTitle("Selected showers - Radius vs Energy distribution");
+
+    fHistAll->SetDirectory(NULL);
+    fHistSel->SetDirectory(NULL);
+    fHistCol->SetDirectory(NULL);
+
+    fHistAll->UseCurrentStyle();
+    fHistSel->UseCurrentStyle();
+    fHistCol->UseCurrentStyle();
+
+    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(Double_t energy, Double_t radius)
+{
+    fHistAll->Fill(energy, radius);
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill data into the histogram which contains the selected showers
+//
+void MHMcCollectionArea::FillSel(Double_t energy, Double_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();
+}
+
+void MHMcCollectionArea::Draw(Option_t* option)
+{
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    fHistCol->Draw(option);
+
+    pad->SetLogx();
+
+    pad->Modified();
+    pad->Update();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Calculate the Efficiency (collection area) and set the 'ReadyToSave'
+//  flag
+//
+void MHMcCollectionArea::CalcEfficiency()
+{
+    Calc(*fHistSel, *fHistAll);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Calculate the Efficiency (collection area) and set the 'ReadyToSave'
+//  flag
+//
+void MHMcCollectionArea::Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall)
+{
+    Calc((TH2D&)*mcsel.GetHist(), (TH2D&)*mcall.GetHist());
+}
+
+// --------------------------------------------------------------------------
+//
+//  Calculate the Efficiency (collection area) and set the 'ReadyToSave'
+//  flag
+//
+void MHMcCollectionArea::Calc(TH2D &hsel, TH2D &hall)
+{
+    MH::SetBinning(fHistCol, hsel.GetXaxis());
+
+    fHistCol->Sumw2();
+
+    TH1D &psel = *hsel.ProjectionX();
+    TH1D &pall = *hall.ProjectionX();
+
+    TH1D &pally = *hall.ProjectionY();
+
+    Double_t max = 0.;
+    for (Int_t i = hall.GetNbinsY(); i > 0; i--)
+      if (pally.GetBinContent(i) > 0)
+	{
+	  max = pally.GetBinLowEdge(i+1);
+	  break;
+	}
+
+    fHistCol->Divide(&psel, &pall, TMath::Pi()*max*max, 1);
+    fHistCol->SetEntries(hsel.GetEntries());
+
+    delete &psel;
+    delete &pall;
+    delete &pally;
+
+    SetReadyToSave();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Calculate the Efficiency (collection area) and set the 'ReadyToSave'
+//  flag
+//
+void MHMcCollectionArea::CalcEfficiency2()
+{
+    TH1D &histsel = *fHistSel->ProjectionX();
+    TH1D &histall = *fHistAll->ProjectionX();
+
+    TAxis &xaxis = *histsel.GetXaxis();
+    MH::SetBinning(fHistCol, &xaxis);
+    const Int_t nbinx = xaxis.GetNbins();
+
+    // -----------------------------------------------------------
+    //
+    // Impact parameter range:  TO BE FIXED! Impact parameter shoud be
+    // read from run header, but it is not yet in!!
+    //
+    const Float_t r1 = 0;
+    const Float_t r2 = fMCAreaRadius;
+
+    *fLog << warn << endl << dbginf << "WARNING! I will assume a maximum impact parameter of " << fMCAreaRadius << " meters for the MC events. Check that this is the true one!" <<endl<<endl;
+    const Float_t total_area = TMath::Pi() * (r2*r2 - r1*r1);
+
+    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 efferr = sqrt((1.-eff)*Ns)/Na;
+	
+	const Float_t col_area  =  eff * total_area;
+	const Float_t col_area_error =  efferr * total_area;
+
+        fHistCol->SetBinContent(ix, col_area);
+        fHistCol->SetBinError(ix, col_area_error);
+    }
+
+    delete &histsel;
+
+    SetReadyToSave();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Calculate the Efficiency (collection area) and set the 'ReadyToSave'
+//  flag
+//
+void MHMcCollectionArea::Calc(const MHMcEfficiency &heff)
+{
+    //
+    //  now calculate the Collection area for different
+    //  energies
+    //
+    TH2D &h = (TH2D&)*heff.GetHist();
+
+    MH::SetBinning(fHistCol, h.GetXaxis());
+
+    const Int_t nbinx = h.GetXaxis()->GetNbins();
+    const Int_t nbiny = h.GetYaxis()->GetNbins();
+
+    for (Int_t ix=1; ix<=nbinx; ix++)
+    {
+        Double_t errA = 0;
+        Double_t colA = 0;
+
+        for (Int_t iy=1; iy<=nbiny; iy++)
+        {
+            TAxis *yaxis = h.GetYaxis();
+
+            const Double_t r1  = yaxis->GetBinLowEdge(iy);
+            const Double_t r2  = yaxis->GetBinLowEdge(iy+1);
+
+            const Double_t A   = TMath::Pi() * (r2*r2 - r1*r1);
+
+            const Double_t eff = h.GetCellContent(ix, iy);
+            const Double_t efferr = h.GetCellError(ix, iy);
+
+            colA += eff*A;
+            errA += A*A * efferr*efferr;
+        }
+
+        fHistCol->SetBinContent(ix, colA);
+        fHistCol->SetBinError(ix, sqrt(errA));
+    }
+
+    SetReadyToSave();
+}
Index: /tags/Mars_V0-8-5/Mars/mhistmc/MHMcCollectionArea.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhistmc/MHMcCollectionArea.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhistmc/MHMcCollectionArea.h	(revision 9661)
@@ -0,0 +1,56 @@
+#ifndef MARS_MHMcCollectionArea
+#define MARS_MHMcCollectionArea
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+class TH1D;
+class TH2D;
+
+class MHMcEfficiency;
+class MHMcEnergyImpact;
+
+class MHMcCollectionArea : public MH
+{
+private:
+    TH2D *fHistAll; //! all simulated showers
+    TH2D *fHistSel; //! the selected showers
+
+    TH1D *fHistCol; //  the collection area
+
+    Float_t fMCAreaRadius; // [m] Radius of circle within which the cores 
+                           // of Corsika events have been uniformly 
+                           // distributed.
+
+    void Calc(TH2D &hsel, TH2D &hall);
+
+public:
+    MHMcCollectionArea(const char *name=NULL, const char *title=NULL);
+    ~MHMcCollectionArea();
+
+    void FillAll(Double_t energy, Double_t radius);
+    void FillSel(Double_t energy, Double_t radius);
+
+    void DrawAll(Option_t *option="");
+    void DrawSel(Option_t *option="");
+
+    const TH1D *GetHist()       { return fHistCol; }
+    const TH1D *GetHist() const { return fHistCol; }
+
+    TH2D *GetHistAll()    { return fHistAll; }
+
+    void Draw(Option_t *option="");
+
+    void CalcEfficiency();
+    void CalcEfficiency2();
+
+    void Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall);
+    void Calc(const MHMcEfficiency &heff);
+
+    void SetMCAreaRadius(Float_t x) { fMCAreaRadius = x; } 
+
+    ClassDef(MHMcCollectionArea, 1)  // Data Container to calculate Collection Area
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mhistmc/MHMcDifRate.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhistmc/MHMcDifRate.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhistmc/MHMcDifRate.cc	(revision 9661)
@@ -0,0 +1,158 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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);
+}
+
+// ------------------------------------------------------------------------
+// 
+// Drawing function. It creates its own canvas.
+//
+void MHMcDifRate::Draw(Option_t *option)
+{
+    TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    AppendPad("");
+
+    pad->SetLogx();
+
+    fHist.Draw(option);
+
+    pad->Modified();
+    pad->Update();
+}
+/*
+void MHMcDifRate::Calc(const TH2D &hsel, const TH2D &hall)
+{
+    //
+    // Set the binning from the two axis of one of the two histograms
+    //
+    MH::SetBinning(&fHist, ((TH2D&)hsel).GetXaxis(), ((TH2D&)hsel).GetYaxis());
+
+    //
+    // This is necessary to initialize thze error calculation correctly
+    // (Nothing important: The histogram set the size of its internal
+    // array storing the errors to the correct size)
+    //
+    fHist.Sumw2();
+
+    //
+    // Calculate the efficiency by dividing the number of selected
+    // (eg. triggered) showers by the number of all showers per bin.
+    // Both histograms are weighted with weight 1, and for the error
+    // calculation we assume a binomial error calculation.
+    //
+    fHist.Divide((TH2D*)&hsel, (TH2D*)&hall, 1, 1, "B");
+
+    SetReadyToSave();
+}
+*/
+
+// --------------------------------------------------------------------------
+//
+//  Calculate the DifRate and set the 'ReadyToSave' flag.
+//  The DifRate is calculated as the number of selected showers
+//  (eg. triggered ones) divided by the number of all showers.
+//  For error calculation Binomial errors are computed.
+//
+void MHMcDifRate::Calc(const MHMcCollectionArea &cola, const TF1 &spect)
+{
+    /*const*/ TH1D &hcol = (TH1D&)*cola.GetHist();
+
+    fHist.Reset();
+
+    //
+    // Set the binning from the two axis of one of the two histograms
+    //
+    MH::SetBinning(&fHist, hcol.GetXaxis());
+
+    //
+    // This is necessary to initialize thze error calculation correctly
+    // (Nothing important: The histogram set the size of its internal
+    // array storing the errors to the correct size)
+    //
+    fHist.Sumw2();
+
+    fHist.Add(&hcol);
+    fHist.Multiply((TF1*)&spect);
+
+    SetReadyToSave();
+}
Index: /tags/Mars_V0-8-5/Mars/mhistmc/MHMcDifRate.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhistmc/MHMcDifRate.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhistmc/MHMcDifRate.h	(revision 9661)
@@ -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);
+
+    void SetName(const char *name);
+    void SetTitle(const char *title);
+
+    const TH1D *GetHist()       { return &fHist; }
+    const TH1D *GetHist() const { return &fHist; }
+
+    TH1 *GetHistByName(const TString name) { return &fHist; }
+
+    void Draw(Option_t* option = "");
+
+//    void Calc(const TH2D &hsel, const TH2D &hall);
+    void Calc(const MHMcCollectionArea &cola, const TF1 &spect);
+
+    ClassDef(MHMcDifRate, 1)  // Histogram container for differential trigger rate
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mhistmc/MHMcEfficiency.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhistmc/MHMcEfficiency.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhistmc/MHMcEfficiency.cc	(revision 9661)
@@ -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): 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);
+}
+
+// ------------------------------------------------------------------------
+// 
+// Drawing function. It creates its own canvas.
+//
+void MHMcEfficiency::Draw(Option_t *option)
+{
+    TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    AppendPad("");
+
+    pad->SetLogx();
+
+    fHist.Draw(option);
+
+    pad->Modified();
+    pad->Update();
+}
+
+void MHMcEfficiency::Calc(const TH2D &hsel, const TH2D &hall)
+{
+    //
+    // Set the binning from the two axis of one of the two histograms
+    //
+    MH::SetBinning(&fHist, ((TH2D&)hsel).GetXaxis(), ((TH2D&)hsel).GetYaxis());
+
+    //
+    // This is necessary to initialize thze error calculation correctly
+    // (Nothing important: The histogram set the size of its internal
+    // array storing the errors to the correct size)
+    //
+    fHist.Sumw2();
+
+    //
+    // Calculate the efficiency by dividing the number of selected
+    // (eg. triggered) showers by the number of all showers per bin.
+    // Both histograms are weighted with weight 1, and for the error
+    // calculation we assume a binomial error calculation.
+    //
+    fHist.Divide((TH2D*)&hsel, (TH2D*)&hall, 1, 1, "B");
+
+    SetReadyToSave();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Calculate the Efficiency and set the 'ReadyToSave' flag.
+//  The Efficiency is calculated as the number of selected showers
+//  (eg. triggered ones) divided by the number of all showers.
+//  For error calculation Binomial errors are computed.
+//
+void MHMcEfficiency::Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall)
+{
+    Calc(*mcsel.GetHist(), *mcall.GetHist());
+
+}
Index: /tags/Mars_V0-8-5/Mars/mhistmc/MHMcEfficiency.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhistmc/MHMcEfficiency.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhistmc/MHMcEfficiency.h	(revision 9661)
@@ -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);
+
+    void SetName(const char *name);
+    void SetTitle(const char *title);
+
+    const TH2D *GetHist()       { return &fHist; }
+    const TH2D *GetHist() const { return &fHist; }
+
+    TH1 *GetHistByName(const TString name) { return &fHist; }
+
+    void Draw(Option_t* option = "");
+
+    void Calc(const TH2D &hsel, const TH2D &hall);
+    void Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall);
+
+    ClassDef(MHMcEfficiency, 1)  // Histogram container for 2D trigger efficiency
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mhistmc/MHMcEfficiencyEnergy.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhistmc/MHMcEfficiencyEnergy.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhistmc/MHMcEfficiencyEnergy.cc	(revision 9661)
@@ -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): 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);
+}
+
+// ------------------------------------------------------------------------
+// 
+// Drawing function. It creates its own canvas.
+//
+void MHMcEfficiencyEnergy::Draw(Option_t *option)
+{
+    TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    AppendPad("");
+
+    pad->SetLogx();
+
+    fHist.Draw(option);
+
+    pad->Modified();
+    pad->Update();
+}
+
+void MHMcEfficiencyEnergy::Calc(const TH2D &hsel, const TH2D &hall)
+{
+    //
+    // Set the binning from the two axis of one of the two histograms
+    //
+    MH::SetBinning(&fHist, ((TH2D&)hsel).GetXaxis());
+
+    //
+    // This is necessary to initialize thze error calculation correctly
+    // (Nothing important: The histogram set the size of its internal
+    // array storing the errors to the correct size)
+    //
+    fHist.Sumw2();
+
+    //
+    // Calculate the efficiency by dividing the number of selected
+    // (eg. triggered) showers by the number of all showers per bin.
+    // Both histograms are weighted with weight 1, and for the error
+    // calculation we assume a binomial error calculation.
+    //
+    TH1D &tsel = *((TH2D&)hsel).ProjectionX();
+    TH1D &tall = *((TH2D&)hall).ProjectionX();
+    fHist.Divide(&tsel, &tall, 1, 1);
+    delete &tsel;
+    delete &tall;
+
+    SetReadyToSave();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Calculate the EfficiencyEnergy and set the 'ReadyToSave' flag.
+//  The EfficiencyEnergy is calculated as the number of selected showers
+//  (eg. triggered ones) divided by the number of all showers.
+//  For error calculation Binomial errors are computed.
+//
+void MHMcEfficiencyEnergy::Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall)
+{
+    Calc(*mcsel.GetHist(), *mcall.GetHist());
+}
Index: /tags/Mars_V0-8-5/Mars/mhistmc/MHMcEfficiencyEnergy.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhistmc/MHMcEfficiencyEnergy.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhistmc/MHMcEfficiencyEnergy.h	(revision 9661)
@@ -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);
+
+    void SetName(const char *name);
+    void SetTitle(const char *title);
+
+    const TH1D *GetHist()       { return &fHist; }
+    const TH1D *GetHist() const { return &fHist; }
+
+    TH1 *GetHistByName(const TString name) { return &fHist; }
+
+    void Draw(Option_t* option = "");
+
+    void Calc(const TH2D &hsel, const TH2D &hall);
+    void Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall);
+
+    ClassDef(MHMcEfficiencyEnergy, 1)  // Histogram container for 1D trigger efficiency in energy
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mhistmc/MHMcEfficiencyImpact.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhistmc/MHMcEfficiencyImpact.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhistmc/MHMcEfficiencyImpact.cc	(revision 9661)
@@ -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): 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);
+}
+
+// ------------------------------------------------------------------------
+// 
+// Drawing function. It creates its own canvas.
+//
+void MHMcEfficiencyImpact::Draw(Option_t *option)
+{
+    TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    AppendPad("");
+
+    pad->SetLogx();
+
+    fHist.Draw(option);
+
+    pad->Modified();
+    pad->Update();
+}
+
+void MHMcEfficiencyImpact::Calc(const TH2D &hsel, const TH2D &hall)
+{
+    //
+    // Set the binning from the two axis of one of the two histograms
+    //
+    MH::SetBinning(&fHist, ((TH2D&)hsel).GetYaxis());
+
+    //
+    // This is necessary to initialize thze error calculation correctly
+    // (Nothing important: The histogram set the size of its internal
+    // array storing the errors to the correct size)
+    //
+    fHist.Sumw2();
+
+    //
+    // Calculate the efficiency by dividing the number of selected
+    // (eg. triggered) showers by the number of all showers per bin.
+    // Both histograms are weighted with weight 1, and for the error
+    // calculation we assume a binomial error calculation.
+    //
+    TH1D &tsel = *((TH2D&)hsel).ProjectionY();
+    TH1D &tall = *((TH2D&)hall).ProjectionY();
+    fHist.Divide(&tsel, &tall, 1, 1);
+    delete &tsel;
+    delete &tall;
+
+    SetReadyToSave();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Calculate the EfficiencyImpact and set the 'ReadyToSave' flag.
+//  The EfficiencyImpact is calculated as the number of selected showers
+//  (eg. triggered ones) divided by the number of all showers.
+//  For error calculation Binomial errors are computed.
+//
+void MHMcEfficiencyImpact::Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall)
+{
+    Calc(*mcsel.GetHist(), *mcall.GetHist());
+}
Index: /tags/Mars_V0-8-5/Mars/mhistmc/MHMcEfficiencyImpact.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhistmc/MHMcEfficiencyImpact.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhistmc/MHMcEfficiencyImpact.h	(revision 9661)
@@ -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);
+
+    void SetName(const char *name);
+    void SetTitle(const char *title);
+
+    const TH1D *GetHist()       { return &fHist; }
+    const TH1D *GetHist() const { return &fHist; }
+
+    TH1 *GetHistByName(const TString name) { return &fHist; }
+
+    void Draw(Option_t* option = "");
+
+    void Calc(const TH2D &hsel, const TH2D &hall);
+    void Calc(const MHMcEnergyImpact &mcsel, const MHMcEnergyImpact &mcall);
+
+    ClassDef(MHMcEfficiencyImpact, 1) // Histogram container for 1D trigger efficiency in impact
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mhistmc/MHMcEnergy.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhistmc/MHMcEnergy.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhistmc/MHMcEnergy.cc	(revision 9661)
@@ -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): 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>
+
+#include <TH1.h> 
+#include <TF1.h> 
+#include <TCanvas.h>
+#include <TPaveLabel.h> 
+
+#include "MH.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHMcEnergy);
+
+using namespace std;
+
+// -------------------------------------------------------------------------
+//
+//  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)
+{
+    TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    AppendPad("");
+
+    fHist->Draw(option);
+
+    DrawLegend();
+
+    pad->Modified();
+    pad->Update();
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the number of bins in the histogran.
+//
+void MHMcEnergy::SetNumBins(Int_t nbins)
+{
+    fHist->SetBins(nbins, 0.5, 4.5);
+}
+// --------------------------------------------------------------------------
+//
+// Write the threshold and its error in the standard output
+//
+void MHMcEnergy::Print(Option_t*) const
+{
+    *fLog << all << "Threshold: " << fThreshold << " +- " << fThresholdErr << endl;
+}
+
+// -------------------------------------------------------------------------
+//
+//  Return the threshold
+//
+Float_t MHMcEnergy::CalcThreshold(TF1 *gauss)
+{
+    const Float_t p1 = gauss->GetParameter(1);
+
+    return pow(10, p1);
+}
+
+// -------------------------------------------------------------------------
+//
+// Return the error of the threshold.
+//
+Float_t MHMcEnergy::CalcThresholdErr(TF1 *gauss)
+{
+    const Float_t lg10  = log(10.);
+    const Float_t p1    = gauss->GetParameter(1);
+    const Float_t p1err = gauss->GetParError(1);
+
+    // The error has into accuont the error in the fit
+    return pow(10, p1) * p1err * lg10;
+}
+
+// -------------------------------------------------------------------------
+//
+// Return the peak of the fitted gaussan function.
+//
+Float_t MHMcEnergy::CalcGaussPeak(TF1 *gauss)
+{
+    return gauss->GetParameter(1);
+}
+
+// -------------------------------------------------------------------------
+//
+// Return the sigma of the fitted gaussan function.
+//
+Float_t MHMcEnergy::CalcGaussSigma(TF1 *gauss)
+{
+    return gauss->GetParameter(2);
+}
+
+TH1 *MHMcEnergy::GetHistByName(const TString name)
+{
+    return fHist;
+}
Index: /tags/Mars_V0-8-5/Mars/mhistmc/MHMcEnergy.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhistmc/MHMcEnergy.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhistmc/MHMcEnergy.h	(revision 9661)
@@ -0,0 +1,57 @@
+#ifndef MARS_MHMcEnergy
+#define MARS_MHMcEnergy
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class TH1;
+class TH1F;
+class TF1;
+
+class MHMcEnergy : public MParContainer
+{
+private:
+
+    TH1F *fHist;  // histogram with the logarith of the energy
+
+    Float_t fThreshold;
+    Float_t fThresholdErr;
+    Float_t fGaussPeak;
+    Float_t fGaussSigma;
+
+    Float_t CalcThreshold(TF1 *gauss);
+    Float_t CalcThresholdErr(TF1 *gauss);
+
+    Float_t CalcGaussPeak(TF1 *gauss);
+    Float_t CalcGaussSigma(TF1 *gauss);
+
+    void DrawLegend() const;
+
+public:
+
+    MHMcEnergy(const char *name=NULL, const char *title=NULL);
+    ~MHMcEnergy();
+
+    void SetName(const char *name);
+
+    Float_t GetThreshold() const { return fThreshold; }
+    Float_t GetThresholdErr() const { return fThresholdErr; }
+
+    Float_t GetGaussPeak() const { return fGaussPeak; }
+    Float_t GetGaussSigma() const { return fGaussSigma; };
+
+    void Fill(Float_t log10E, Float_t w);
+    void Fit(Axis_t xxmin, Axis_t xxmax);
+    void SetNumBins(Int_t nbins = 100);
+
+    TH1 *GetHistByName(const TString name);
+
+    void Draw(Option_t* option = "");
+
+    void Print(Option_t* option = NULL) const;
+
+    ClassDef(MHMcEnergy, 1)  // Histogram container for montecarlo energy threshold
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mhistmc/MHMcEnergyImpact.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhistmc/MHMcEnergyImpact.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhistmc/MHMcEnergyImpact.cc	(revision 9661)
@@ -0,0 +1,141 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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);
+}
+
+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 Stat_t w)
+{
+    const MMcEvt &mcevt = *(MMcEvt*)cont;
+
+    const Float_t energy = mcevt.GetEnergy();
+    const Float_t impact = mcevt.GetImpact()/100.;
+
+    fHist.Fill(energy, impact, w);
+
+    return kTRUE;
+}
+
+// ------------------------------------------------------------------------
+// 
+// Drawing function. It creates its own canvas.
+//
+void MHMcEnergyImpact::Draw(Option_t *option)
+{
+    TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    AppendPad("");
+
+    pad->SetLogx();
+
+    fHist.Draw(option);
+
+    pad->Modified();
+    pad->Update();
+}
Index: /tags/Mars_V0-8-5/Mars/mhistmc/MHMcEnergyImpact.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhistmc/MHMcEnergyImpact.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhistmc/MHMcEnergyImpact.h	(revision 9661)
@@ -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);
+
+    void SetName(const char *name);
+    void SetTitle(const char *title);
+
+    Bool_t SetupFill(const MParList *pList);
+    Bool_t Fill(const MParContainer *pcont=NULL, const Stat_t w=1);
+
+    const TH2D *GetHist()       { return &fHist; }
+    const TH2D *GetHist() const { return &fHist; }
+
+    TH1 *GetHistByName(const TString name) { return &fHist; }
+
+    void Draw(Option_t* option = "");
+
+    ClassDef(MHMcEnergyImpact, 1)  // Histogram container for 2D histogram in Energy and Impact
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mhistmc/MHMcEnergyMigration.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhistmc/MHMcEnergyMigration.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhistmc/MHMcEnergyMigration.cc	(revision 9661)
@@ -0,0 +1,311 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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>
+!              Abelardo Moralejo 5/2003 <mailto:moralejo@pd.infn.it>
+!
+!   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"
+#include <TProfile.h>
+
+ClassImp(MHMcEnergyMigration);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor. It sets name and title of the histogram.
+//
+MHMcEnergyMigration::MHMcEnergyMigration(const char *name, const char *title)
+  : fHist(), fHist2(), fHistImp()
+{
+    //
+    //   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_{EST}  E_{TRUE}  \\Theta");
+    fHist.SetXTitle("E_{EST} [GeV]");
+    fHist.SetYTitle("E_{TRUE} [GeV]");
+    fHist.SetZTitle("\\Theta [\\circ]");
+
+    fHist2.SetDirectory(NULL);
+    fHist2.SetTitle("3D-plot \\Delta E / E  vs E_{EST} E_{TRUE}");
+    fHist2.SetXTitle("E_{EST} [GeV]");
+    fHist2.SetYTitle("E_{TRUE} [GeV]");
+    fHist2.SetZTitle("\\frac{E_{EST} - E_{TRUE}}{E_{TRUE}}");
+
+    fHistImp.SetDirectory(NULL);
+    fHistImp.SetTitle("\\Delta E / E  vs Impact parameter");
+    fHistImp.SetXTitle("Impact parameter (m)");
+    fHistImp.SetYTitle("\\frac{E_{EST} - E_{TRUE}}{E_{TRUE}}");
+
+}
+
+// --------------------------------------------------------------------------
+//
+// 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();
+
+    const MBinning* binsde = (MBinning*)plist->FindObject("BinningDE");
+    const MBinning* binsimpact = (MBinning*)plist->FindObject("BinningImpact");
+    SetBinning(&fHistImp, binsimpact, binsde);
+
+    fHistImp.Sumw2();
+
+    SetBinning(&fHist2, binsenergy, binsenergy, binsde);
+    fHist2.Sumw2();
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw the histogram
+//
+void MHMcEnergyMigration::Draw(Option_t *opt)
+{
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    AppendPad("");
+
+    pad->Divide(2,2);
+    
+    TH1 *h;
+
+    pad->cd(1);
+    gPad->SetBorderMode(0);
+    gPad->SetLogx();
+    h = fHist.Project3D("ey_pro");
+    h->SetTitle("Distribution of E_{TRUE}");
+    h->SetXTitle("E_{TRUE} [GeV]");
+    h->SetBit(kCanDelete);
+    h->Draw(opt);
+    h->SetDirectory(NULL);
+
+    pad->cd(2);
+    gPad->SetBorderMode(0);
+    gPad->SetLogx();
+    h = fHist.Project3D("ex_pro");
+    h->SetTitle("Distribution of E_{EST}");
+    h->SetXTitle("E_{est} [GeV]");
+    h->SetBit(kCanDelete);
+    h->Draw(opt);
+    Double_t minEest = h->GetXaxis()->GetXmin();
+    h->SetDirectory(NULL);
+
+    pad->cd(3);
+    gPad->SetBorderMode(0);
+    h = fHist.Project3D("z_pro");
+    h->SetTitle("Distribution of \\Theta");
+    h->SetXTitle("\\Theta [\\circ]");
+    h->SetBit(kCanDelete);
+    h->SetLineWidth(2);
+    h->Draw(opt);
+    h->SetDirectory(NULL);
+
+    pad->cd(4);
+    gPad->SetBorderMode(0);
+    TH1D* hpx;
+    hpx = fHistImp.ProjectionX("_px", 1, fHistImp.GetNbinsY(),"e");
+    hpx->SetTitle("Distribution of Impact parameter");
+    hpx->SetXTitle("Impact parameter (m)");
+    hpx->SetBit(kCanDelete);
+    hpx->Draw(opt);
+    hpx->SetDirectory(NULL);
+    fHistImp.SetDirectory(NULL);
+
+    pad->Modified();
+    pad->Update();
+
+    TVirtualPad *pad2 = MakeDefCanvas((TString)GetName()+"2");
+    pad2->SetBorderMode(0);
+
+    AppendPad("");
+
+    pad2->Divide(2,2);
+    
+    TH2D *h2;
+
+    pad2->cd(1);
+    gPad->SetBorderMode(0);
+    gPad->SetLogx();
+    gPad->SetLogy();
+    h2 = (TH2D*) fHist.Project3D("yx");
+
+    TProfile* h2pfx;
+    h2pfx = h2->ProfileX("_pfx", 1, h2->GetNbinsY(),"S");
+    h2pfx->SetXTitle("E_{TRUE} (GeV)");
+    h2pfx->SetYTitle("E_{EST} (GeV)");
+    h2pfx->SetTitle("E_{EST} vs E_{TRUE}");
+    h2pfx->SetBit(kCanDelete);
+    h2pfx->SetFillColor(41);
+    h2pfx->SetFillStyle(1001);
+    h2pfx->SetMinimum(minEest);
+    h2pfx->SetStats(kFALSE);
+    h2pfx->DrawCopy("E3");
+
+    h2->SetBit(kCanDelete);
+    h2->SetFillColor(1);
+    h2->Draw("box,same");
+    h2->SetDirectory(NULL);
+
+    h2pfx->SetLineColor(2);
+    h2pfx->SetLineWidth(2);
+    h2pfx->SetFillColor(0);
+    h2pfx->DrawCopy("C,hist,same");
+    h2pfx->SetDirectory(NULL);
+
+    pad2->cd(2);
+
+    gPad->SetBorderMode(0);
+    gPad->SetLogx();
+    gPad->SetLeftMargin(0.15);
+    h2 = (TH2D*) fHist2.Project3D("zy");
+    h2->SetBit(kCanDelete);
+    h2pfx = h2->ProfileX("_pfx", 1, h2->GetNbinsY(),"S");
+    h2pfx->SetTitle("\\Delta E / E vs E_{TRUE}");
+    h2pfx->SetXTitle("E_{TRUE} (GeV)");
+    h2pfx->SetYTitle("\\frac{E_{EST} - E_{TRUE}}{E_{TRUE}}");
+    h2pfx->SetBit(kCanDelete);
+    h2pfx->SetFillColor(41);
+    h2pfx->SetFillStyle(1001);
+    h2pfx->GetYaxis()->SetTitleOffset(1.4);
+    h2pfx->SetStats(kFALSE);
+    h2pfx->DrawCopy("E3");
+    h2->SetFillColor(1);
+    h2->Draw("same,box");
+    h2->SetDirectory(NULL);
+    h2pfx->SetLineColor(2);
+    h2pfx->SetLineWidth(2);
+    h2pfx->SetFillColor(0);
+    h2pfx->DrawCopy("C,hist,same");
+    h2pfx->SetDirectory(NULL);
+    
+    pad2->cd(3);
+    gPad->SetBorderMode(0);
+    gPad->SetLogx();
+    gPad->SetLeftMargin(0.15);
+    h2 = (TH2D*) fHist2.Project3D("zx");
+    h2->SetBit(kCanDelete);
+    h2pfx = h2->ProfileX("_pfx", 1, h2->GetNbinsY(),"S");
+    h2pfx->SetTitle("\\Delta E / E vs E_{EST}");
+    h2pfx->SetXTitle("E_{EST} (GeV)");
+    h2pfx->SetYTitle("\\frac{E_{EST} - E_{TRUE}}{E_{TRUE}}");
+    h2pfx->SetBit(kCanDelete);
+    h2pfx->SetFillColor(41);
+    h2pfx->SetFillStyle(1001);
+    h2pfx->GetYaxis()->SetTitleOffset(1.4);
+    h2pfx->SetStats(kFALSE);
+    h2pfx->SetMinimum(-1.);
+    h2pfx->SetMaximum(1.);
+    h2pfx->DrawCopy("E3");
+    
+    h2->SetFillColor(1);
+    h2->Draw("same,box");
+    h2->SetDirectory(NULL);
+    h2pfx->SetLineColor(2);
+    h2pfx->SetLineWidth(2);
+    h2pfx->SetFillColor(0);
+    h2pfx->DrawCopy("L,histo,same");
+    h2pfx->SetDirectory(NULL);
+    
+    pad2->cd(4);
+    gPad->SetBorderMode(0);
+    h = fHist2.ProjectionZ("_pz",1,fHist2.GetNbinsX(),1,fHist2.GetNbinsY(),"e");
+    h->SetBit(kCanDelete);
+    h->Draw();
+    h->SetDirectory(NULL);
+
+    pad2->Modified();
+    pad2->Update();
+
+    fHist.SetDirectory(NULL);
+    fHist2.SetDirectory(NULL);
+
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the histogram
+//
+Bool_t MHMcEnergyMigration::Fill(const MParContainer *par, const Stat_t w)
+{
+    // get E-true from fMcEvt and E-est from fEnergy
+
+    fHist.Fill(fEnergy->GetEnergy(), fMcEvt->GetEnergy(), fMcEvt->GetTelescopeTheta()*kRad2Deg, w);
+
+    fHist2.Fill(fEnergy->GetEnergy(), fMcEvt->GetEnergy(), (fEnergy->GetEnergy()-fMcEvt->GetEnergy())/fMcEvt->GetEnergy(), w);
+
+    fHistImp.Fill(fMcEvt->GetImpact()/100., (fEnergy->GetEnergy()-fMcEvt->GetEnergy())/fMcEvt->GetEnergy(), w);
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mhistmc/MHMcEnergyMigration.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhistmc/MHMcEnergyMigration.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhistmc/MHMcEnergyMigration.h	(revision 9661)
@@ -0,0 +1,49 @@
+#ifndef MARS_MHMcEnergyMigration
+#define MARS_MHMcEnergyMigration
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+#ifndef ROOT_TH3
+#include <TH3.h>
+#endif
+
+#ifndef ROOT_TH2
+#include <TH2.h>
+#endif
+
+class MMcEvt;
+class MEnergyEst;
+class MParList;
+
+class MHMcEnergyMigration : public MH
+{
+private:
+    MMcEvt      *fMcEvt; //!
+    MEnergyEst  *fEnergy; //!
+
+    TH3D        fHist;
+    TH3D        fHist2;
+    TH2D        fHistImp;
+
+public:
+    MHMcEnergyMigration(const char *name=NULL, const char *title=NULL);
+
+    Bool_t SetupFill(const MParList *pList);
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+
+    const TH3D *GetHist() { return &fHist; }
+    const TH3D *GetHist() const { return &fHist; }
+    TH1 *GetHistByName(const TString name) { return &fHist; }
+
+    const TH3D *GetHist2() { return &fHist2; }
+    const TH2D *GetHistImp() { return &fHistImp; }
+
+    void Draw(Option_t *option="");
+
+    ClassDef(MHMcEnergyMigration, 1) //3D-histogram   E-true E-est Theta
+
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mhistmc/MHMcIntRate.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhistmc/MHMcIntRate.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhistmc/MHMcIntRate.cc	(revision 9661)
@@ -0,0 +1,132 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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);
+
+using namespace std;
+
+// -------------------------------------------------------------------------
+//
+//  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);
+}
+
+// ------------------------------------------------------------------------
+// 
+// Drawing function. It creates its own canvas.
+//
+void MHMcIntRate::Draw(Option_t *option)
+{
+    TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    AppendPad("");
+
+    pad->SetLogx();
+
+    fHist.Draw(option);
+
+    pad->Modified();
+    pad->Update();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Calculate the IntRate and set the 'ReadyToSave' flag.
+//  The IntRate is calculated as the number of selected showers
+//  (eg. triggered ones) divided by the number of all showers.
+//  For error calculation Binomial errors are computed.
+//
+void MHMcIntRate::Calc(const MHMcDifRate &rate)
+{
+    /*const*/ TH1D  &hist = (TH1D&)*rate.GetHist();
+    const TAxis &axis = *hist.GetXaxis();
+
+    //
+    // Set the binning from the two axis of one of the two histograms
+    //
+    MH::SetBinning(&fHist, &axis);
+
+    const Int_t nbinsx = axis.GetNbins();
+
+    for (Int_t i=1; i<=nbinsx; i++)
+    {
+        fHist.SetBinContent(i, hist.Integral(i, nbinsx, "width"));
+        fHist.SetBinError(i, hist.GetBinError(i)*axis.GetBinWidth(i));
+    }
+
+    fHist.SetEntries(hist.GetEntries());
+
+    SetReadyToSave();
+}
Index: /tags/Mars_V0-8-5/Mars/mhistmc/MHMcIntRate.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhistmc/MHMcIntRate.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhistmc/MHMcIntRate.h	(revision 9661)
@@ -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);
+
+    void SetName(const char *name);
+    void SetTitle(const char *title);
+
+    const TH1D *GetHist()       { return &fHist; }
+    const TH1D *GetHist() const { return &fHist; }
+
+    TH1 *GetHistByName(const TString name) { return &fHist; }
+
+    void Draw(Option_t* option = "");
+
+    void Calc(const MHMcDifRate &rate);
+
+    ClassDef(MHMcIntRate, 1)  // Histogram container for integral event rate
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mhistmc/MHMcRate.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhistmc/MHMcRate.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhistmc/MHMcRate.cc	(revision 9661)
@@ -0,0 +1,258 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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): Abelardo Moralejo 2/2003
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//   Explanations on the rate calculation can be found in
+//   chapter 7 of the following diploma thesis:
+//   http://www.pd.infn.it/magic/tesi2.ps.gz (in Italian)
+//
+////////////////////////////////////////////////////////////////////////////
+
+#include "MHMcRate.h" 
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHMcRate);
+
+using namespace std;
+
+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 (TeV)
+    fEnergyMin=1000000.0;    // Minimum Energy (TeV)
+
+    fSolidAngle = -1.;       // Solid angle within which incident directions
+                             // are distributed
+    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
+
+    fMultiplicity = -1;      // Multiplicity of the trigger condition
+    fMeanThreshold = -1.;    // Discr. threshold of the trigger condition
+    fTriggerCondNum = 0;     // Trigger condition number within camera file
+
+}
+
+// --------------------------------------------------------------------------
+//
+//  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 Night Sky Background:
+//
+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((double)fEnergyMax, specidx);
+    const Double_t epowmin = pow((double)fEnergyMin, specidx);
+
+    if (fShowerRate <= 0)
+      fShowerRate = fFlux0/specidx*(epowmax-epowmin);
+
+    if (fSolidAngle < 0.)
+      fSolidAngle = (fPhiMax-fPhiMin)*(cos(fThetaMin)-cos(fThetaMax));
+
+    if (fPartId!=1)
+      fShowerRate *= fSolidAngle;
+
+    fShowerRate *= TMath::Pi()*(fImpactMax/100.0*fImpactMax/100.0 - 
+				fImpactMin/100.0*fImpactMin/100.0);
+
+    fShowerRateError = sqrt(fShowerRate);
+
+    // The simulated trigger time in the camera program is 160 ns:
+    // 9/10/2002, AM: Fixed error below in calculation of "anal2"
+    // ( added factor fShowerRate/simu )
+
+    const Double_t anal2 = 1.0-fShowerRate*(anal/simu)*160.0e-9;
+    const Double_t back2 = fBackSim*160.0e-9;
+
+    // Then the trigger rate and its error is evaluated
+    if(fBackTrig<0){
+        fTriggerRateError = sqrt((trig*fShowerRate*fShowerRate/(simu*simu)) +
+                                 (anal2*anal2*1/(fBackSim*back2*back2)));
+        fBackTrig=0;
+    }
+    else
+        fTriggerRateError = sqrt((trig*fShowerRate*fShowerRate/(simu*simu)) +
+                                 (anal2*anal2*fBackTrig/(back2*back2)));
+
+    fTriggerRate = trig*fShowerRate/simu + anal2*fBackTrig/back2;
+
+    SetReadyToSave();
+}
+
+// --------------------------------------------------------------------------
+//
+//  print the trigger rate
+//
+void MHMcRate::Print(Option_t *) const
+{
+    *fLog << all << "Incident rate " << fShowerRate << " Hz " << endl;
+    *fLog << "Multiplicity: " << fMultiplicity << ",  Discr. threshold: " << fMeanThreshold << 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;
+}
+
Index: /tags/Mars_V0-8-5/Mars/mhistmc/MHMcRate.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhistmc/MHMcRate.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhistmc/MHMcRate.h	(revision 9661)
@@ -0,0 +1,99 @@
+#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 [TeV]
+    Float_t fEnergyMin;         // Minimum Energy [TeV]
+
+    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 fSolidAngle;        // Solid angle within which incident directions are distributed [sr]
+
+    Float_t fImpactMax;         //[cm] Maximum impact parameter [cm]
+    Float_t fImpactMin;         //[cm] Minimum impact parameter [cm]
+
+    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
+
+    Float_t fMeanThreshold;     // Mean discriminator threshold of trigger pixels [mV]
+
+    Short_t fMultiplicity;      // L1 trigger multiplicity.
+
+    Short_t fTriggerCondNum;    // Trigger condition number, for the case of running over camra files containing several.
+
+    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 SetImpactMax(Float_t Impact) {fImpactMax=Impact;}
+    void SetImpactMin(Float_t Impact) {fImpactMin=Impact;}
+
+    void SetThetaMax(Float_t Theta) {fThetaMax=Theta;}
+    void SetThetaMin(Float_t Theta) {fThetaMin=Theta;}
+    void SetPhiMax(Float_t Phi) {fPhiMax=Phi;}
+    void SetPhiMin(Float_t Phi) {fPhiMin=Phi;}
+
+    void SetSolidAngle(Float_t Solid) {fSolidAngle=Solid;}
+    void SetEnergyMax(Float_t Energy) {fEnergyMax=Energy;}
+    void SetEnergyMin(Float_t Energy) {fEnergyMin=Energy;}
+
+    void SetMultiplicity(Short_t nMul) {fMultiplicity = nMul;}
+    void SetMeanThreshold(Float_t thresh) {fMeanThreshold = thresh;}
+
+    void SetTriggerCondNum(Short_t num) {fTriggerCondNum = num;}
+
+    void UpdateBoundaries(Float_t energy, Float_t theta, Float_t phi, Float_t impact);
+
+    Float_t GetTriggerRate() {return fTriggerRate;}
+    Float_t GetTriggerRateError() {return fTriggerRateError;}
+
+    Short_t GetMultiplicity() {return fMultiplicity;}
+    Float_t GetMeanThreshold() {return fMeanThreshold;}
+    Short_t GetTriggerCondNum() {return fTriggerCondNum;}
+
+
+    void CalcRate(Float_t trig, Float_t anal, Float_t simu);
+
+    void Print(Option_t *o=NULL) const;
+
+    void Draw(Option_t *o=NULL);
+
+    ClassDef(MHMcRate, 1)  // Data Container to calculate trigger rate
+};
+
+#endif 
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mhistmc/MHMcTriggerLvl2.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhistmc/MHMcTriggerLvl2.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhistmc/MHMcTriggerLvl2.cc	(revision 9661)
@@ -0,0 +1,422 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Nicola Galante, 2003 <mailto:nicola.galante@pi.infn.it>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHMcTriggerLvl2
+//
+// This class contains histograms for the Trigger Level2 image parameters
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MHMcTriggerLvl2.h"
+
+#include <TMath.h>
+
+#include <TH2.h>
+#include <TH1.h>
+#include <TF1.h>
+#include <TPad.h>
+#include <TStyle.h>
+#include <TCanvas.h>
+#include <TPaveLabel.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MMcTriggerLvl2.h"
+
+using namespace std;
+
+/* Use this insteadif you want to have some value which is the same for all
+ your instances of MHMcTriggerLvl2, if not define the values in the constructor
+ and remove the 'static'
+ */
+
+Int_t MHMcTriggerLvl2::fColorLps = 1;
+Int_t MHMcTriggerLvl2::fColorCps = 1;
+Int_t MHMcTriggerLvl2::fColorSbc = 1;
+Int_t MHMcTriggerLvl2::fColorPs = 1;
+Int_t MHMcTriggerLvl2::fColorPsE = 1;
+Int_t MHMcTriggerLvl2::fColorCPsE = 1;
+Int_t MHMcTriggerLvl2::fColorLPsE = 1;
+Int_t MHMcTriggerLvl2::fColorSBCE = 1;
+
+
+ClassImp(MHMcTriggerLvl2);
+
+// --------------------------------------------------------------------------
+//
+// Setup three histograms for fLutPseudoSize, fPseudoSize, fSizeBiggerCell
+//
+MHMcTriggerLvl2::MHMcTriggerLvl2(const char *name, const char *title)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHMcTriggerLvl2";
+    fTitle = title ? title : "Trigger L2 image parameters";
+
+    fHistLutPseudoSize = new TH1F("fHistLutPseudoSize",  "Lut Pseudo Size",                13,   0, 13);
+    fHistPseudoSize = new TH1F("fHistPseudoSize",   "Pseudo Size",    397,   0, 397);
+    fHistCellPseudoSize = new TH1F("fHistCellPseudoSize",   "Cell Pseudo Size",    37,   0, 37);
+    fHistSizeBiggerCell = new TH1F("fHistSizeBiggerCell",   "Size in Bigger Cell",            37,   0, 37);
+
+    fHistLutPseudoSizeNorm = new TH1F("fHistLutPseudoSizeNorm",  "Normalized Lut Pseudo Size",                13,   0, 13);
+    fHistPseudoSizeNorm = new TH1F("fHistPseudoSizeNorm",   "Normalized Pseudo Size",    397,   0, 397);
+    fHistSizeBiggerCellNorm = new TH1F("fHistSizeBiggerCellNorm",   "Normalized Size in Bigger Cell",            37,   0, 37);
+    fHistCellPseudoSizeNorm = new TH1F("fHistCellPseudoSizeNorm",   "Normalized Cell Pseudo Size",    37,   0, 37);
+
+    fHistLutPseudoSize->SetDirectory(NULL);
+    fHistLutPseudoSizeNorm->SetDirectory(NULL);
+    fHistPseudoSize->SetDirectory(NULL);
+    fHistPseudoSizeNorm->SetDirectory(NULL);
+    fHistSizeBiggerCell->SetDirectory(NULL);
+    fHistSizeBiggerCellNorm->SetDirectory(NULL);
+    fHistCellPseudoSize->SetDirectory(NULL);
+    fHistCellPseudoSizeNorm->SetDirectory(NULL);
+
+    fHistLutPseudoSize->SetXTitle("Number of Pixels");
+    fHistLutPseudoSizeNorm->SetXTitle("Number of Pixels");
+    fHistPseudoSize->SetXTitle("Number of Pixels");
+    fHistPseudoSizeNorm->SetXTitle("Number of Pixels");
+    fHistSizeBiggerCell->SetXTitle("Number of Pixels");
+    fHistSizeBiggerCellNorm->SetXTitle("Number of Pixels");
+    fHistCellPseudoSize->SetXTitle("Number of Pixels");
+    fHistCellPseudoSizeNorm->SetXTitle("Number of Pixels");
+
+    fHistLutPseudoSize->SetYTitle("Counts");
+    fHistLutPseudoSizeNorm->SetYTitle("Counts/Total Counts");
+    fHistPseudoSize->SetYTitle("Counts");
+    fHistPseudoSizeNorm->SetYTitle("Counts/Total Counts");
+    fHistSizeBiggerCell->SetYTitle("Counts");
+    fHistSizeBiggerCellNorm->SetYTitle("Counts/Total Counts");
+    fHistCellPseudoSize->SetYTitle("Counts");
+    fHistCellPseudoSizeNorm->SetYTitle("Counts/Total Counts");
+
+    fHistPseudoSizeEnergy = new TH2D("fHistPseudoSizeEnergy","Ps Size vs Energy", 40, 1, 5, 397, 0,397);
+    fHistCellPseudoSizeEnergy = new TH2D("fHistCellPseudoSizeEnergy","CPS Size vs Energy", 40, 1, 5, 397, 0,397);
+    fHistLutPseudoSizeEnergy = new TH2D("fHistLutPseudoSizeEnergy","Ps Size vs Energy", 40, 1, 5, 397, 0,397);
+    fHistSizeBiggerCellEnergy = new TH2D("fHistSizeBiggerCellEnergy","Ps Size vs Energy", 40, 1, 5, 397, 0,397);
+ 
+    fHistPseudoSizeEnergy->SetName("fHistPseudoSizeEnergy");
+    fHistPseudoSizeEnergy->SetTitle("PseudoSize vs. Energy");
+    fHistPseudoSizeEnergy->SetXTitle("Log(E[GeV])");
+    fHistPseudoSizeEnergy->SetYTitle("PseudoSize");
+
+    fHistCellPseudoSizeEnergy->SetName("fHistCellPseudoSizeEnergy");
+    fHistCellPseudoSizeEnergy->SetTitle("CellPseudoSize vs. Energy");
+    fHistCellPseudoSizeEnergy->SetXTitle("Log(E[GeV])");
+    fHistCellPseudoSizeEnergy->SetYTitle("CellPseudoSize");
+
+    fHistLutPseudoSizeEnergy->SetName("fHistLutPseudoSizeEnergy");
+    fHistLutPseudoSizeEnergy->SetTitle("LutPseudoSize vs. Energy");
+    fHistLutPseudoSizeEnergy->SetXTitle("Log(E[GeV])");
+    fHistLutPseudoSizeEnergy->SetYTitle("LutPseudoSize");
+
+    fHistSizeBiggerCellEnergy->SetName("fHistSizeBiggerCellEnergy");
+    fHistSizeBiggerCellEnergy->SetTitle("Size Bigger Cell vs. Energy");
+    fHistSizeBiggerCellEnergy->SetXTitle("Log(E[GeV])");
+    fHistSizeBiggerCellEnergy->SetYTitle("Size Bigger Cell");
+
+		
+
+		
+    fFNorm = new TF1("FNorm", "1", -1, 397);
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the histograms
+//
+MHMcTriggerLvl2::~MHMcTriggerLvl2()
+{
+    delete fHistLutPseudoSize;
+    delete fHistPseudoSize;
+    delete fHistCellPseudoSize;
+    delete fHistSizeBiggerCell;
+    delete fHistLutPseudoSizeNorm;
+    delete fHistPseudoSizeNorm;
+    delete fHistCellPseudoSizeNorm;
+    delete fHistSizeBiggerCellNorm;
+    delete fHistPseudoSizeEnergy;
+    delete fHistCellPseudoSizeEnergy;
+    delete fHistLutPseudoSizeEnergy;
+    delete fHistSizeBiggerCellEnergy;
+    delete fFNorm;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Fill the histograms with data from a MMcTriggerLvl2-Container.
+// Be careful: Only call this with an object of type MMcTriggerLvl2
+//
+Bool_t MHMcTriggerLvl2::Fill(const MParContainer *par, const Stat_t w)
+{
+  const MMcTriggerLvl2 &h = *(MMcTriggerLvl2 *)par;
+ 
+  fHistLutPseudoSize->Fill(h.GetLutPseudoSize());
+  fHistPseudoSize->Fill(h.GetPseudoSize());
+  fHistCellPseudoSize->Fill(h.GetCellPseudoSize());
+  fHistSizeBiggerCell->Fill(h.GetSizeBiggerCell());
+  fHistPseudoSizeEnergy->Fill(TMath::Log10(h.GetEnergy()), h.GetPseudoSize());
+  fHistCellPseudoSizeEnergy->Fill(TMath::Log10(h.GetEnergy()), h.GetCellPseudoSize());
+  fHistLutPseudoSizeEnergy->Fill(TMath::Log10(h.GetEnergy()), h.GetLutPseudoSize());
+  fHistSizeBiggerCellEnergy->Fill(TMath::Log10(h.GetEnergy()), h.GetSizeBiggerCell());
+
+  return kTRUE;
+}
+
+
+
+
+// --------------------------------------------------------------------------
+//
+// This is the private function member which draw a clone of a histogram. 
+// This method is called by the DrawClone method.
+//
+TObject *MHMcTriggerLvl2::DrawHist(TH1 &hist, TH1 &histNorm, const TString &canvasname, Int_t &col) const
+{
+    col++;
+
+    TCanvas *c = (TCanvas*)gROOT->FindObject(canvasname);
+
+    Bool_t same = kTRUE;
+    if (!c)
+    {
+        c = MakeDefCanvas(canvasname,canvasname, 800, 610);
+        c->Divide(2,1);
+        same = kFALSE;
+    }
+
+    c->cd(1);
+    hist.SetLineColor(col);
+    hist.DrawCopy(same?"same":"");
+
+    c->cd(2);
+    histNorm.SetLineColor(col);
+    histNorm.DrawCopy(same?"same":"");
+
+    return c;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// This is the private function member which draw a clone of a 2D-histogram. 
+// This method is called by the DrawClone method.
+//
+TObject *MHMcTriggerLvl2::Draw2DHist(TH1 &hist, const TString &canvasname, Int_t &col) const
+{
+    col++;
+
+    TCanvas *c = (TCanvas*)gROOT->FindObject(canvasname);
+
+    Bool_t same = kTRUE;
+    if (!c)
+    {
+        c = MakeDefCanvas(canvasname,canvasname, 800, 600);
+        same = kFALSE;
+    }
+
+    hist.SetLineColor(col);
+    hist.DrawCopy(same?"same":"");
+
+    return c;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Draw a clone of a data member 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 dostroying the canvas you can get a
+// pointer to it from this function
+// Possible options are:
+//      "lps" for the fLutPseudoSize histogram;
+//      "sbc" for the fSizeBiggerCell histogram;
+//      "ps" for the fPseudoSize histogram;
+//      "lut-energy" for the fLutPseudoSize vs. energy 2D histogram
+//      "size-energy" for the fPseudoSize vs. energy 2D histogram
+//      "big-energy" for the fSizeBiggerCell vs. energy 2D histogram
+//      
+//      default: "ps"
+//
+TObject *MHMcTriggerLvl2::DrawClone(Option_t *opt) const
+{
+    TString str(opt);
+
+    if (str.IsNull())
+        str = "ps";
+
+    if (!str.Contains("lps", TString::kIgnoreCase) &&
+	!str.Contains("cps", TString::kIgnoreCase) &&
+        !str.Contains("sbc", TString::kIgnoreCase) &&
+        !str.Contains("ps",  TString::kIgnoreCase) &&
+        !str.Contains("lut-energy",  TString::kIgnoreCase) &&
+	!str.Contains("size-energy",  TString::kIgnoreCase) &&
+	!str.Contains("cellsize-energy",  TString::kIgnoreCase) &&
+	!str.Contains("big-energy",  TString::kIgnoreCase))
+    {
+        *fLog << "ARGH!@! Possible options are \"lps\", \"cps\", \"sbc\", \"ps\", \"lut-energy\", \"size-energy\", \"cellsize-energy\", \"big-energy\" or NULL!" <<endl;
+        return NULL;
+    }
+
+    if (str.Contains("lps",TString::kIgnoreCase)){
+      TH1 *hist=NormalizeHist(*fHistLutPseudoSizeNorm, fHistLutPseudoSize);
+      return DrawHist(*fHistLutPseudoSize, *hist, "CanvasLPS", fColorLps);
+    }
+
+    if (str.Contains("cps",TString::kIgnoreCase)){
+      TH1 *hist=NormalizeHist(*fHistCellPseudoSizeNorm, fHistCellPseudoSize);
+      return DrawHist(*fHistCellPseudoSize, *hist, "CanvasCPS", fColorCps);
+    }
+
+    if (str.Contains("sbc",TString::kIgnoreCase)){
+      TH1 *hist=NormalizeHist(*fHistSizeBiggerCellNorm, fHistSizeBiggerCell);
+      return DrawHist(*fHistSizeBiggerCell, *hist, "CanvasSBC", fColorSbc);
+    }
+
+    if (str.Contains("ps",TString::kIgnoreCase)){
+      TH1 *hist=NormalizeHist(*fHistPseudoSizeNorm, fHistPseudoSize);
+      return DrawHist(*fHistPseudoSize, *hist, "CanvasPS", fColorPs);
+    }
+
+    if (str.Contains("size-energy",TString::kIgnoreCase))
+      return Draw2DHist(*fHistPseudoSizeEnergy, "CanvasPSE", fColorPsE);
+
+    if (str.Contains("cellsize-energy",TString::kIgnoreCase))
+      return Draw2DHist(*fHistCellPseudoSizeEnergy, "CanvasCPSE", fColorCPsE);
+
+    if (str.Contains("lut-energy",TString::kIgnoreCase))
+      return Draw2DHist(*fHistLutPseudoSizeEnergy, "CanvasLPSE", fColorLPsE);
+
+    if (str.Contains("big-energy",TString::kIgnoreCase))
+      return Draw2DHist(*fHistSizeBiggerCellEnergy, "CanvasSBCE", fColorSBCE);
+    
+
+    return NULL;
+}
+
+
+
+// --------------------------------------------------------------------------
+//
+// Creates a new canvas and draws the three histograms into it.
+// Be careful: The histograms belongs to this object and won't get deleted
+// together with the canvas.
+//
+void MHMcTriggerLvl2::Draw(Option_t *)
+{
+  MakeDefCanvas("c","L2T Parameters", 720, 810);
+  
+  TPad* pad1 = new TPad("pad1","Pad with fLutPseudoSize", 0.003, 0.7, 0.4, 0.997);
+  TPad* pad2 = new TPad("pad2","Pad with fSizeBiggerCell", 0.403, 0.7, 0.997, 0.997);
+  TPad* pad3 = new TPad("pad3","Pad with fPseudoSize", 0.003, 0.003, 0.997, 0.697);
+  pad1->Draw();
+  pad2->Draw();
+  pad3->Draw();
+  
+  pad1->cd();
+  fHistLutPseudoSize->Draw();
+  
+  pad2->cd();
+  fHistSizeBiggerCell->Draw();
+  
+  pad3->cd();
+  fHistPseudoSize->Draw();
+}
+
+
+
+// --------------------------------------------------------------------------
+//
+//  Return the histogram by its name. This method returns a (TObject *)
+//  so remember to cast the returned object if you want to work with it.
+//
+TH1 *MHMcTriggerLvl2::GetHistByName(const TString name)
+{
+  
+    if (name.Contains("fHistLutPseudoSizeEnergy", TString::kIgnoreCase))
+	return fHistLutPseudoSizeEnergy;
+    if (name.Contains("fHistSizeBiggerCellEnergy", TString::kIgnoreCase))
+        return fHistSizeBiggerCellEnergy;
+    if (name.Contains("fHistPseudoSizeEnergy", TString::kIgnoreCase))
+        return fHistPseudoSizeEnergy;
+    if (name.Contains("fHistCellPseudoSizeEnergy", TString::kIgnoreCase))
+        return fHistCellPseudoSizeEnergy;
+
+    if (name.Contains("fHistLutPseudoSizeNorm", TString::kIgnoreCase))
+      return fHistLutPseudoSizeNorm;
+    if (name.Contains("fHistSizeBiggerCellNorm", TString::kIgnoreCase))
+        return fHistSizeBiggerCellNorm;
+    if (name.Contains("fHistPseudoSizeNorm", TString::kIgnoreCase))
+        return fHistPseudoSizeNorm;
+    if (name.Contains("fHistCellPseudoSizeNorm", TString::kIgnoreCase))
+        return fHistCellPseudoSizeNorm;
+	    
+    if (name.Contains("fHistLutPseudoSize", TString::kIgnoreCase))
+      return fHistLutPseudoSize;
+    if (name.Contains("fHistSizeBiggerCell", TString::kIgnoreCase))
+        return fHistSizeBiggerCell;
+    if (name.Contains("fHistPseudoSize", TString::kIgnoreCase))
+        return fHistPseudoSize;
+    if (name.Contains("fHistCellPseudoSize", TString::kIgnoreCase))
+        return fHistCellPseudoSize;
+
+    
+    return NULL;
+}
+
+
+
+// --------------------------------------------------------------------------
+//
+// Normalize the histogram on its integral, i.e.  normalize the
+// values of the histogram on the statistics. This method creates
+// a copy (histNorm) of the histogram to normalize (hist) and normalize
+// the copy (histNorm) on its integral. It returns histNorm.
+//
+TH1 *MHMcTriggerLvl2::NormalizeHist(TH1 &histNorm, TH1 *hist) const
+{
+  if (&histNorm == hist){
+    *fLog << "ARGH!@! You cannot pass the same histogram into each argument!" << endl;
+    return NULL;
+  }
+
+  if ((hist == NULL) || (hist->Integral() == (Stat_t)0)){
+    *fLog << "ARGH!@! You are trying to normalize the histogram to 0!" << endl;
+    return NULL;
+  }
+  
+  histNorm.Reset("ICE");
+  histNorm.Add(hist, 1);
+  histNorm.Divide(fFNorm, (Double_t)(hist->Integral()));
+
+  return &histNorm;
+}
Index: /tags/Mars_V0-8-5/Mars/mhistmc/MHMcTriggerLvl2.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhistmc/MHMcTriggerLvl2.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhistmc/MHMcTriggerLvl2.h	(revision 9661)
@@ -0,0 +1,74 @@
+#ifndef MARS_MHMcTriggerLvl2
+#define MARS_MHMcTriggerLvl2
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+class TH2D;
+class TH1F;
+class TF1;
+class MMcTriggerLvl2;
+
+class MHMcTriggerLvl2 : public MH
+{
+private:
+
+    TH1F *fHistLutPseudoSize;        // Histogram of fLutPseudoSize
+    TH1F *fHistLutPseudoSizeNorm;    // Histogram of fLutPseudoSize normalized on integral of distribution
+    TH1F *fHistPseudoSize;           // Histogram of fPseudoSize
+    TH1F *fHistPseudoSizeNorm;       // Histogram of fPseudoSize normalized on integral of distribution
+    TH1F *fHistCellPseudoSize;           // Histogram of fCellPseudoSize
+    TH1F *fHistCellPseudoSizeNorm;       // Histogram of fCellPseudoSize normalized on integral of distribution
+    TH1F *fHistSizeBiggerCell;       // Histogram of fSizeBiggerCell
+    TH1F *fHistSizeBiggerCellNorm;   // Histogram of fSizeBiggerCell normalized on integral of distribution
+    TH2D *fHistPseudoSizeEnergy;     // 2D-Histogram of fPseudoSize vs. Energy
+    TH2D *fHistLutPseudoSizeEnergy;  // 2D-Histogram of fLutPseudoSize vs. Energy
+    TH2D *fHistCellPseudoSizeEnergy;  // 2D-Histogram of fCellPseudoSize vs. Energy
+    TH2D *fHistSizeBiggerCellEnergy; // 2D-Histogram of fSizeBiggerCell vs. Energy
+    TF1* fFNorm;                     // Function used to normalize histograms
+
+    static Int_t fColorLps;
+    static Int_t fColorSbc;
+    static Int_t fColorPs;
+    static Int_t fColorCps;
+    static Int_t fColorPsE;
+    static Int_t fColorLPsE;
+    static Int_t fColorCPsE;
+    static Int_t fColorSBCE;
+    
+
+    TObject *DrawHist(TH1 &hist, TH1 &histNorm, const TString &canvasname, Int_t &colore) const;
+    TObject *Draw2DHist(TH1 &hist, const TString &canvasname, Int_t &col) const;
+    
+public:
+    MHMcTriggerLvl2(const char *name=NULL, const char *title=NULL);
+    ~MHMcTriggerLvl2();
+
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+
+    TH1 *GetHistByName(const TString name);
+
+    TH1F *GetHistLutPseudoSize() const { return fHistLutPseudoSize; }
+    TH1F *GetHistLutPseudoSizeNorm() const { return fHistLutPseudoSizeNorm; }
+    TH1F *GetHistPseudoSize()  const { return fHistPseudoSize; }
+    TH1F *GetHistPseudoSizeNorm()  const { return fHistPseudoSizeNorm; }
+    TH1F *GetHistCellPseudoSize()  const { return fHistCellPseudoSize; }
+    TH1F *GetHistCellPseudoSizeNorm()  const { return fHistCellPseudoSizeNorm; }
+    TH1F *GetHistSizeBiggerCell()  const { return fHistSizeBiggerCell; }
+    TH1F *GetHistSizeBiggerCellNorm()  const { return fHistSizeBiggerCellNorm; }
+    TH2D *GetHistLutPseudoSizeEnergy() const { return fHistLutPseudoSizeEnergy; }
+    TH2D *GetHistPseudoSizeEnergy() const { return fHistPseudoSizeEnergy; }
+    TH2D *GetHistSizeBiggerCellEnergy() const { return fHistSizeBiggerCellEnergy; }
+    
+
+    void Draw(Option_t *opt=NULL);
+    TObject *DrawClone(Option_t *opt=NULL) const;
+
+    TH1 *NormalizeHist(TH1 &histNorm, TH1 *hist) const;
+
+    ClassDef(MHMcTriggerLvl2, 1) // Container which holds histograms for the Trigger Level2 image parameters
+};
+
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mhistmc/Makefile
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhistmc/Makefile	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhistmc/Makefile	(revision 9661)
@@ -0,0 +1,43 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#------------------------------------------------------------------------------
+
+#
+# Handling name of the Root Dictionary Files
+#
+CINT  = HistMc
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES = -I. -I../mbase -I../mhbase -I../mhist -I../mmc -I../manalysis \
+    	   -I../mimage -I../mgeom -I../mgui
+
+SRCFILES = MHMcEnergy.cc \
+           MHMcEfficiency.cc \
+           MHMcEfficiencyImpact.cc \
+           MHMcEfficiencyEnergy.cc \
+           MHMcEnergyImpact.cc \
+	   MHMcRate.cc \
+	   MHMcCollectionArea.cc \
+           MHMcIntRate.cc \
+           MHMcDifRate.cc \
+           MHMcEnergyMigration.cc \
+	   MHMcCT1CollectionArea.cc \
+	   MHMcTriggerLvl2.cc
+
+############################################################
+
+all: $(OBJS)
+
+include ../Makefile.rules
+
+mrproper:	clean rmbak
Index: /tags/Mars_V0-8-5/Mars/mhvstime/HVsTimeIncl.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhvstime/HVsTimeIncl.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhvstime/HVsTimeIncl.h	(revision 9661)
@@ -0,0 +1,6 @@
+#ifndef __CINT__
+
+#include <TF1.h>
+#include <TArrayI.h>
+
+#endif // __CINT__
Index: /tags/Mars_V0-8-5/Mars/mhvstime/HVsTimeLinkDef.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhvstime/HVsTimeLinkDef.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhvstime/HVsTimeLinkDef.h	(revision 9661)
@@ -0,0 +1,11 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class MHVsTime+;
+#pragma link C++ class MHPixVsTime+;
+#pragma link C++ class MHSectorVsTime+;
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mhvstime/MHPixVsTime.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhvstime/MHPixVsTime.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhvstime/MHPixVsTime.cc	(revision 9661)
@@ -0,0 +1,217 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHPixVsTime
+//
+// Display the pixel content versus time or event number
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MHPixVsTime.h"
+
+#include <TCanvas.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MCamEvent.h"
+
+#include "MGeomCam.h"
+
+#include "MRawEvtHeader.h"
+#include "MTime.h"
+
+ClassImp(MHPixVsTime);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Initialize the name and title of the task.
+//
+MHPixVsTime::MHPixVsTime(Int_t idx, const char *name, const char *title)
+    : fIndex(idx), fEvt(NULL), fType(0), fTypeErr(-1)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHPixVsTime";
+    fTitle = title ? title : "Average of MPixVsTimes";
+
+    TString t("Pixel Index #");
+    t += idx;
+    t += " vs Time";
+
+    fGraph = new TGraphErrors;
+    fGraph->SetName("MCamEvent");
+    fGraph->SetTitle(t);
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the corresponding camera display if available
+//
+MHPixVsTime::~MHPixVsTime()
+{
+  if(fGraph)
+    delete fGraph;
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the event (MPixVsTime) the histogram might be filled with. If
+// it is not given, it is assumed, that it is filled with the argument
+// of the Fill function.
+// Looks for the camera geometry MGeomCam and resets the sum histogram.
+//
+Bool_t MHPixVsTime::SetupFill(const MParList *plist)
+{
+    fEvt = (MCamEvent*)plist->FindObject(fNameEvt, "MCamEvent");
+    if (!fEvt)
+    {
+        if (!fNameEvt.IsNull())
+        {
+            *fLog << err << GetDescriptor() << ": No " << fNameEvt <<" [MCamEvent] available..." << endl;
+            return kFALSE;
+        }
+        *fLog << warn << GetDescriptor() << ": No MCamEvent available..." << endl;
+    }
+
+    fCam = (MGeomCam*)plist->FindObject("MGeomCam");
+    if (!fCam)
+    {
+        *fLog << err << "MGeomCam not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    if (!fNameTime.IsNull())
+    {
+        fTime = (MTime*)plist->FindObject(fNameTime, "MTime");
+        if (!fTime)
+        {
+            *fLog << err << fNameTime << " [MTime] not found... abort." << endl;
+            return kFALSE;
+        }
+    }
+    else
+    {
+        fHeader = (MRawEvtHeader*)plist->FindObject("MRawEvtHeader");
+        if (!fHeader)
+            *fLog << warn << "MRawEvtHeader not found... using counter." << endl;
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the histograms with data from a MPixVsTime-Container.
+//
+Bool_t MHPixVsTime::Fill(const MParContainer *par, const Stat_t w)
+{
+    const MCamEvent *evt = par ? dynamic_cast<const MCamEvent*>(par) : fEvt;
+    if (!evt)
+    {
+        *fLog << err << dbginf << "No MCamEvent found..." << endl;
+        return kFALSE;
+    }
+
+    Double_t val = 0;
+    Double_t rms = 0;
+    evt->GetPixelContent(val, fIndex, *fCam, fType);
+    if (TMath::IsNaN(val))
+        return kCONTINUE;
+
+    Double_t t = 0;
+    if (!fNameTime.IsNull())
+        t = fTime->GetAxisTime();
+    else
+        t = fHeader ? fHeader->GetDAQEvtNumber() : fGraph->GetN();
+
+    fGraph->SetPoint(fGraph->GetN(), t, val);
+
+    if (fTypeErr>=0)
+    {
+        evt->GetPixelContent(rms, fIndex, *fCam, fType);
+        if (TMath::IsNaN(rms))
+            return kCONTINUE;
+    }
+
+    fGraph->SetPointError(fGraph->GetN()-1, 0, rms);
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return histogram of TGraph
+//
+TH1 *MHPixVsTime::GetHistByName(const TString name)
+{
+    return fGraph->GetHistogram();
+}
+
+void MHPixVsTime::Draw(Option_t *opt)
+{
+
+    if (fGraph->GetN()==0)
+        return;
+
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    AppendPad("");
+
+    TString str(opt);
+
+    TH1 *h = fGraph->GetHistogram();
+
+    h->SetXTitle("Time");
+    h->SetYTitle("");
+    if (!fNameTime.IsNull())
+    {
+        TAxis *axe = h->GetXaxis();
+        axe->SetTimeFormat("%H:%M:%S %F1995-01-01 00:00:00");
+        axe->SetTimeDisplay(1);
+        axe->SetLabelSize(0.033);
+    }
+
+
+    if (!str.Contains("A"))
+        str += "A";
+    if (!str.Contains("P"))
+        str += "P";
+
+    if (str.Contains("same", TString::kIgnoreCase))
+    {
+        str.ReplaceAll("same", "");
+        str.ReplaceAll("A", "");
+    }
+
+    fGraph->Draw(str);
+
+    pad->Modified();
+    pad->Update();
+}
Index: /tags/Mars_V0-8-5/Mars/mhvstime/MHPixVsTime.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhvstime/MHPixVsTime.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhvstime/MHPixVsTime.h	(revision 9661)
@@ -0,0 +1,59 @@
+#ifndef MARS_MHPixVsTime
+#define MARS_MHPixVsTime
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+#ifndef ROOT_TGraphErrors
+#include <TGraphErrors.h>
+#endif
+
+class MHCamera;
+class MCamEvent;
+class MGeomCam;
+
+class MRawEvtHeader;
+class MTime;
+
+class MHPixVsTime : public MH
+{
+private:
+    TGraphErrors *fGraph;
+    Int_t fIndex;
+
+    MCamEvent *fEvt; //! the current event
+    MGeomCam  *fCam; //! the camera geometry
+
+    MRawEvtHeader *fHeader; //!
+    MTime         *fTime;   //!
+
+    TString fNameEvt;
+    TString fNameTime;
+
+    Int_t fType;
+    Int_t fTypeErr;
+
+    Bool_t SetupFill(const MParList *pList);
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+
+public:
+    MHPixVsTime(Int_t idx=0, const char *name=NULL, const char *title=NULL);
+    ~MHPixVsTime();
+
+    void SetNameEvt(const TString name) { fNameEvt = name; }
+    void SetNameTime(const TString name) { fNameTime = name; }
+    void SetType(Int_t type, Int_t e=-1) { fType = type; fTypeErr=e; }
+
+    TH1 *GetHistByName(const TString name="");
+    TGraph *GetGraph() { return fGraph; }
+
+    void Draw(Option_t *o=NULL);
+
+    ClassDef(MHPixVsTime, 1) // Histogram to sum camera events
+};
+
+#endif
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mhvstime/MHSectorVsTime.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhvstime/MHSectorVsTime.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhvstime/MHSectorVsTime.cc	(revision 9661)
@@ -0,0 +1,280 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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, 3/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHSectorVsTime
+//
+// Display the mean and its variance vs time of the whole camera or a
+// single sector
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MHSectorVsTime.h"
+
+#include <TCanvas.h>
+#include <TGraphErrors.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MCamEvent.h"
+
+#include "MGeomCam.h"
+
+#include "MRawEvtHeader.h"
+#include "MTime.h"
+
+ClassImp(MHSectorVsTime);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Initialize the name and title of the task. If fErrType>=0 the variance is
+// taken into account.
+//
+MHSectorVsTime::MHSectorVsTime(const char *name, const char *title)
+    : fGraph(0), fEvt(NULL), fType(0), fTypeErr(-1)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHSectorVsTime";
+    fTitle = title ? title : "Sector mean vs time";
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the fGraph
+//
+MHSectorVsTime::~MHSectorVsTime()
+{
+    if (fGraph)
+        delete fGraph;
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the event (MPixVsTime) the histogram might be filled with. If
+// it is not given, it is assumed, that it is filled with the argument
+// of the Fill function.
+// Looks for the camera geometry MGeomCam and resets the sum histogram.
+// Create and/or initialize fGraph
+//
+Bool_t MHSectorVsTime::SetupFill(const MParList *plist)
+{
+    fEvt = dynamic_cast<MCamEvent*>(plist->FindObject(fNameEvt, "MCamEvent"));
+    if (!fEvt)
+    {
+        if (!fNameEvt.IsNull())
+        {
+            *fLog << err << GetDescriptor() << ": No " << fNameEvt <<" [MCamEvent] available..." << endl;
+            return kFALSE;
+        }
+        *fLog << warn << GetDescriptor() << ": No MCamEvent available..." << endl;
+    }
+
+    fCam = (MGeomCam*)plist->FindObject("MGeomCam");
+    if (!fCam)
+    {
+        *fLog << err << "MGeomCam not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fHCamera.SetGeometry(*fCam);
+
+    if (!fNameTime.IsNull())
+    {
+        fTime = (MTime*)plist->FindObject(fNameTime, "MTime");
+        if (!fTime)
+        {
+            *fLog << err << fNameTime << " [MTime] not found... abort." << endl;
+            return kFALSE;
+        }
+    }
+    else
+    {
+        fHeader = (MRawEvtHeader*)plist->FindObject("MRawEvtHeader");
+        if (!fHeader)
+            *fLog << warn << "MRawEvtHeader not found... using counter." << endl;
+    }
+
+    if (fGraph)
+        delete fGraph;
+
+    fGraph = fTypeErr<0 ? new TGraph : new TGraphErrors;
+    fGraph->SetName(fEvt ? dynamic_cast<TObject*>(fEvt)->GetName() : "MCamEvent");
+    fGraph->SetTitle("Camera");
+
+    fMin =  FLT_MAX;
+    fMax = -FLT_MAX;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the histograms with data from a MCamEvent
+//
+Bool_t MHSectorVsTime::Fill(const MParContainer *par, const Stat_t w)
+{
+    const MCamEvent *evt = par ? dynamic_cast<const MCamEvent*>(par) : fEvt;
+    if (!evt)
+    {
+        *fLog << err << dbginf << "No MCamEvent found..." << endl;
+        return kFALSE;
+    }
+
+    Double_t t = 0;
+    if (!fNameTime.IsNull())
+        t = fTime->GetAxisTime();
+    else
+        t = fHeader ? fHeader->GetDAQEvtNumber() : fGraph->GetN();
+
+
+    fHCamera.SetCamContent(*evt, fType);
+
+    const Double_t val0 = fHCamera.GetMeanSectors(fSectors, fAreaIndex);
+
+    if (TMath::IsNaN(val0)/* || TMath::IsNaN(rms0)*/)
+        return kCONTINUE;
+
+    fGraph->SetPoint(fGraph->GetN(), t, val0);
+
+    if (fTypeErr>=0)
+    {
+        const Double_t rms0 = fHCamera.GetRmsSectors(fSectors, fAreaIndex);
+        if (TMath::IsNaN(rms0))
+            return kCONTINUE;
+        ((TGraphErrors*)fGraph)->SetPointError(fGraph->GetN()-1, 0, rms0);
+    }
+
+    fMin = TMath::Min(fMin, val0);
+    fMax = TMath::Max(fMax, val0);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Set Minimum and Maximum;
+//
+Bool_t MHSectorVsTime::Finalize()
+{
+    const Double_t add = (fMax-fMin)*0.15;
+
+    fGraph->SetMinimum(fMin-add);
+    fGraph->SetMaximum(fMax+add);
+
+    *fLog << dbg << "Min=" << fMin << " " << fMin-add << endl;
+    *fLog << dbg << "Max=" << fMax << " " << fMax+add << endl;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return fHistogram from TGraph
+//
+TH1 *MHSectorVsTime::GetHistByName(const TString name)
+{
+    return fGraph->GetHistogram();
+}
+
+void MHSectorVsTime::Draw(Option_t *opt)
+{
+    /*
+    if (fGraph->GetN()==0)
+        return;
+        */
+
+    if (fGraph->GetN()==0)
+        return;
+
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    AppendPad("");
+
+    TString str(opt);
+    /*
+    fGraph->GetHistogram()->SetXTitle("Time");
+    fGraph->GetHistogram()->GetXaxis()->SetTimeFormat("%H:%M:%S %F1995-01-01 00:00:00");
+    fGraph->GetHistogram()->GetXaxis()->SetTimeDisplay(1);
+    fGraph->GetHistogram()->GetXaxis()->SetLabelSize(0.033);
+
+    fGraph->GetHistogram()->SetYTitle("");
+     */
+    if (!str.Contains("A"))
+        str += "A";
+    if (!str.Contains("L"))
+        str += "L";
+
+    if (str.Contains("same", TString::kIgnoreCase))
+    {
+        str.ReplaceAll("same", "");
+        str.ReplaceAll("A", "");
+    }
+
+    TH1 *h = fGraph->GetHistogram();
+
+    h->SetXTitle("Time");
+    h->SetYTitle("");
+
+    if (!fNameTime.IsNull())
+    {
+        TAxis *axe = h->GetXaxis();
+        axe->SetTimeFormat("%H:%M:%S %F1995-01-01 00:00:00");
+        axe->SetTimeDisplay(1);
+        axe->SetLabelSize(0.025);
+    }
+
+    *fLog << dbg << "Draw: " << str << endl;
+    fGraph->Draw(str);
+/*
+    str.ReplaceAll("same", "");
+    str.ReplaceAll("A", "");
+
+    Int_t i=-1;
+    Int_t col=kRed;
+    while ((g=(TGraphErrors*)Next()))
+    {
+        i++;
+        *fLog << dbg << "Check" << i << ": " << str << endl;
+
+        while ((fMinSector>=0 && i<fMinSector) || (fMaxSector>=0 && i>fMaxSector))
+            i++;
+
+        h = g->GetHistogram();
+        g->SetLineColor(col++);
+
+        *fLog << dbg << "Draw" << i << ": " << g->GetTitle() << endl;
+        g->Draw(str);
+
+    }
+
+    pad->Modified();
+    pad->Update();*/
+}
Index: /tags/Mars_V0-8-5/Mars/mhvstime/MHSectorVsTime.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhvstime/MHSectorVsTime.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhvstime/MHSectorVsTime.h	(revision 9661)
@@ -0,0 +1,70 @@
+#ifndef MARS_MHSectorVsTime
+#define MARS_MHSectorVsTime
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+#ifndef MARS_MHCamera
+#include "MHCamera.h"
+#endif
+
+class MHCamera;
+class MCamEvent;
+class MGeomCam;
+
+class MRawEvtHeader;
+class MTime;
+class TGraph;
+
+class MHSectorVsTime : public MH
+{
+private:
+    TGraph *fGraph;
+
+    MCamEvent *fEvt;        //! the current event
+    MGeomCam  *fCam;        //! the camera geometry
+
+    MRawEvtHeader *fHeader; //!
+    MTime         *fTime;   //!
+
+    MHCamera fHCamera;      //!
+
+    Double_t fMin;          //!
+    Double_t fMax;          //!
+
+    TString fNameEvt;
+    TString fNameTime;
+
+    Int_t fType;
+    Int_t fTypeErr;
+
+    TArrayI fSectors;
+    TArrayI fAreaIndex;
+
+    Bool_t SetupFill(const MParList *pList);
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+    Bool_t Finalize();
+
+public:
+    MHSectorVsTime(const char *name=NULL, const char *title=NULL);
+    ~MHSectorVsTime();
+
+    void SetNameEvt(const TString name)  { fNameEvt = name; }
+    void SetNameTime(const TString name) { fNameTime = name; }
+    void SetType(Int_t type, Int_t e=-1) { fType = type; fTypeErr=e; }
+    void SetSectors(const TArrayI &s)    { fSectors=s; }
+    void SetAreaIndex(const TArrayI &a)  { fAreaIndex=a; }
+
+    TH1 *GetHistByName(const TString name="");
+    //TGraph *GetGraph() { return fGraph; }
+
+    void Draw(Option_t *o=NULL);
+
+    ClassDef(MHSectorVsTime, 1) // Histogram to sum camera events
+};
+
+#endif
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mhvstime/MHVsTime.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhvstime/MHVsTime.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhvstime/MHVsTime.cc	(revision 9661)
@@ -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, 11/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHVsTime
+//
+// Preliminary: the docu may be wrong!
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MHVsTime.h"
+
+#include <ctype.h>   // tolower
+#include <fstream>
+
+#include <TPad.h>
+#include <TStyle.h>
+#include <TCanvas.h>
+
+#include <TGraph.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MTime.h"
+#include "MParList.h"
+#include "MDataChain.h"
+#include "MRawEvtHeader.h"
+
+ClassImp(MHVsTime);
+
+using namespace std;
+
+static const TString gsDefName  = "MHVsTime";
+static const TString gsDefTitle = "Container for a graph vs time/evtnumber";
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MHVsTime::MHVsTime(const char *rule)
+    : fGraph(NULL), fData(NULL), fScale(1), fUseEventNumber(0)
+{  
+    fName  = gsDefName;
+    fTitle = gsDefTitle;
+
+    if (!rule)
+        return;
+
+    fGraph = new TGraph;
+    fData = new MDataChain(rule);
+}
+
+// --------------------------------------------------------------------------
+//
+// Deletes the histogram
+//
+MHVsTime::~MHVsTime()
+{
+    if (fGraph)
+        delete fGraph;
+
+    if (fData)
+        delete fData;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the data members used by the data chain to be used in
+// MTask::AddBranchToList
+//
+TString MHVsTime::GetDataMember() const
+{
+    return fData ? fData->GetDataMember() : (TString)"";
+}
+
+// --------------------------------------------------------------------------
+//
+// 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 MHVsTime::SetupFill(const MParList *plist)
+{
+    // reset histogram (necessary if the same eventloop is run more than once) 
+    //fGraph->Reset();
+
+    if (fData && !fData->PreProcess(plist))
+        return kFALSE;
+
+    if (fGraph)
+    {
+        delete fGraph;
+        fGraph = new TGraph;
+    }
+
+    TString title(fData ? GetRule() : (TString)"Histogram");
+    title += " vs ";
+    title += fUseEventNumber ? "Event Number" : "Time";
+
+    fGraph->SetNameTitle(fName, title);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the name of the histogram ant the MHVsTime container
+//
+void MHVsTime::SetName(const char *name)
+{
+    fGraph->SetName(name);
+    MParContainer::SetName(name);
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the title of the histogram ant the MHVsTime container
+//
+void MHVsTime::SetTitle(const char *title)
+{
+    fGraph->SetTitle(title);
+    MParContainer::SetTitle(title);
+}
+
+// --------------------------------------------------------------------------
+//
+// Fills the one, two or three data members into our histogram
+//
+Bool_t MHVsTime::Fill(const MParContainer *par, const Stat_t w)
+{
+    Double_t t = 0;
+    if (fUseEventNumber)
+    {
+        const MRawEvtHeader *h = dynamic_cast<const MRawEvtHeader*>(par);
+        t = h ? h->GetDAQEvtNumber() : fGraph->GetN();
+    }
+    else
+    {
+        const MTime *tm = dynamic_cast<const MTime*>(par);
+        if (!tm)
+        {
+            *fLog << err << dbginf << "No MTime found..." << endl;
+            return kFALSE;
+        }
+	if (!*tm)
+            return kTRUE;
+        t = tm->GetAxisTime();
+    }
+
+    const Double_t v = fData->GetValue()*fScale;
+
+    fGraph->SetPoint(fGraph->GetN(), t, v);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Creates a new canvas and draws the histogram into it.
+//
+// Possible options are:
+//   PROFX: Draw a x-profile into the histogram (for 2D histograms only)
+//   PROFY: Draw a y-profile into the histogram (for 2D histograms only)
+//   ONLY:  Draw the profile histogram only (for 2D histograms only)
+//
+// If the kIsLog?-Bit is set the axis is displayed lkogarithmically.
+// eg this is set when applying a logarithmic MBinning
+//
+// Be careful: The histogram belongs to this object and won't get deleted
+// together with the canvas.
+//
+void MHVsTime::Draw(Option_t *opt)
+{
+    if (fGraph->GetN()==0)
+        return;
+
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(fGraph);
+    pad->SetBorderMode(0);
+
+    AppendPad("");
+
+    TString str(opt);
+
+    if (fUseEventNumber)
+        fGraph->GetHistogram()->SetXTitle("Event Number");
+    else
+    {
+        fGraph->GetHistogram()->SetXTitle("Time");
+        fGraph->GetHistogram()->GetXaxis()->SetTimeFormat("%H:%M:%S %F1995-01-01 00:00:00");
+        fGraph->GetHistogram()->GetXaxis()->SetTimeDisplay(1);
+        fGraph->GetHistogram()->GetXaxis()->SetLabelSize(0.033);
+    }
+    fGraph->GetHistogram()->SetYTitle(GetRule());
+
+    if (!str.Contains("A"))
+        str += "A";
+    if (!str.Contains("P"))
+        str += "P";
+
+    if (str.Contains("same", TString::kIgnoreCase))
+    {
+        str.ReplaceAll("same", "");
+        str.ReplaceAll("A", "");
+    }
+
+    fGraph->Draw(str);
+    if (fGraph->TestBit(kIsLogy))
+        pad->SetLogy();
+
+    pad->Modified();
+    pad->Update();
+}
+
+// --------------------------------------------------------------------------
+//
+// Used to rebuild a MHVsTime object of the same type (data members,
+// dimension, ...)
+//
+MParContainer *MHVsTime::New() const
+{
+    MHVsTime *h=new MHVsTime(fData ? (const char*)GetRule() : NULL);
+    h->SetScale(fScale);
+    if (fUseEventNumber)
+        h->SetUseEventNumber();
+    return h;
+}
+
+TString MHVsTime::GetRule() const
+{
+    return fData ? fData->GetRule() : (TString)"";
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the total number of bins in a histogram (excluding under- and
+// overflow bins)
+//
+Int_t MHVsTime::GetNbins() const
+{
+    return fGraph->GetN();
+}
+/*
+TH1 *MHVsTime::GetHist()
+{
+    return fGraph ? fGraph->GetHistogram() : 0;
+}
+
+const TH1 *MHVsTime::GetHist() const
+{
+    return fGraph ? fGraph->GetHistogram() : 0;
+}
+
+TH1 *MHVsTime::GetHistByName(const TString name)
+{
+    return GetHist();
+}
+*/
Index: /tags/Mars_V0-8-5/Mars/mhvstime/MHVsTime.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhvstime/MHVsTime.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhvstime/MHVsTime.h	(revision 9661)
@@ -0,0 +1,60 @@
+#ifndef MARS_MHVsTime
+#define MARS_MHVsTime
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+class TGraph;
+class MDataChain;
+
+class MHVsTime : public MH
+{
+protected:
+    // Could be const but root < 3.02/06 doesn't like this...
+    TGraph     *fGraph;  // Histogram to fill
+    MDataChain *fData;  // Object from which the data is filled
+    Double_t    fScale; // Scale for axis (eg unit)
+
+    enum {
+        kIsLogy = BIT(18),
+        kUseEventNumber = BIT(20)
+    };
+
+    Bool_t fUseEventNumber;
+
+public:
+    MHVsTime(const char *rule=NULL);
+    ~MHVsTime();
+
+    void SetScale(Double_t scale) { fScale = scale; }
+
+    Int_t GetNbins() const;
+
+    void SetName(const char *name);
+    void SetTitle(const char *title);
+
+    Bool_t SetupFill(const MParList *pList);
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+
+    TString GetDataMember() const;
+    TString GetRule() const;
+
+    /*
+//    const TH1 *GetHist() const;
+//    TH1 *GetHist();
+//    TH1 *GetHistByName(const TString name="");
+*/
+    const TGraph *GetGraph() const { return fGraph; }
+    TGraph *GetGraph() { return fGraph; }
+
+    void SetUseEventNumber(Bool_t use = kTRUE) { fUseEventNumber = use; }
+
+    void Draw(Option_t *opt=NULL);
+
+    MParContainer *New() const;
+
+    ClassDef(MHVsTime, 1) // Generalized 1/2/3D-histogram for Mars variables
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mhvstime/Makefile
===================================================================
--- /tags/Mars_V0-8-5/Mars/mhvstime/Makefile	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mhvstime/Makefile	(revision 9661)
@@ -0,0 +1,37 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#------------------------------------------------------------------------------
+
+#
+# Handling name of the Root Dictionary Files
+#
+CINT  = HVsTime
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES = -I. -I../mbase -I../mhbase -I../mgeom -I../mhist \
+	   -I../mgui -I../mraw -I../mdata
+# mhist (MHCamera)
+# mgui  (MCamEvent)
+# mraw  (MRawEvtHeader)
+
+SRCFILES = MHVsTime.cc \
+           MHPixVsTime.cc \
+           MHSectorVsTime.cc
+
+############################################################
+
+all: $(OBJS)
+
+include ../Makefile.rules
+
+mrproper:	clean rmbak
Index: /tags/Mars_V0-8-5/Mars/mimage/ImageIncl.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mimage/ImageIncl.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mimage/ImageIncl.h	(revision 9661)
@@ -0,0 +1,5 @@
+#ifndef __CINT__
+
+#include <TVector2.h>
+
+#endif // __CINT__
Index: /tags/Mars_V0-8-5/Mars/mimage/ImageLinkDef.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mimage/ImageLinkDef.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mimage/ImageLinkDef.h	(revision 9661)
@@ -0,0 +1,27 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class MImgCleanStd+;
+#pragma link C++ class MImgCleanTGB+;
+#pragma link C++ class MCameraSmooth+;
+
+#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 MNewImagePar+;
+#pragma link C++ class MConcentration+;
+
+#pragma link C++ class MHHillas+;
+#pragma link C++ class MHHillasSrc+;
+#pragma link C++ class MHHillasExt+;
+#pragma link C++ class MHNewImagePar+;
+#pragma link C++ class MStereoPar+;
+#pragma link C++ class MStereoCalc+;
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mimage/MCameraSmooth.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mimage/MCameraSmooth.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mimage/MCameraSmooth.cc	(revision 9661)
@@ -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): Thomas Bretz 08/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//  MCameraSmooth                                                          //
+//                                                                         //
+//  This task fills each pixel in the camera with the average of the       //
+//  number of cerenkov photons from its surrounding pixels. This can       //
+//  be done using the central pixel or ignoring the central pixel.         //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MCameraSmooth.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MGeomPix.h"
+#include "MGeomCam.h"
+#include "MCerPhotPix.h"
+#include "MCerPhotEvt.h"
+
+ClassImp(MCameraSmooth);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. You can specify the numer of loops how often a
+// smoothing should be done. The default is 1.
+//
+MCameraSmooth::MCameraSmooth(Byte_t n, const char *name, const char *title)
+    : fCounts(n), fUseCentralPixel(kTRUE)
+{
+    fName  = name  ? name  : "MCameraSmooth";
+    fTitle = title ? title : "Task to smooth the camera";
+}
+
+// --------------------------------------------------------------------------
+//
+//  - get the MCerPhotEvt from the parlist (abort if missing)
+//  - get MGeomCam from the parameter list
+//
+Int_t MCameraSmooth::PreProcess (MParList *pList)
+{
+    fEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
+    if (!fEvt)
+    {
+        *fLog << err << dbginf << "MCerPhotEvt not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fGeomCam = (MGeomCam*)pList->FindObject("MGeomCam");
+    if (!fGeomCam)
+    {
+        *fLog << warn << dbginf << "No camera geometry available... aborting." << endl;
+
+        return kFALSE;
+    }
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Do the smoothing
+//
+Int_t MCameraSmooth::Process()
+{
+    const UShort_t entries = fEvt->GetNumPixels();
+
+    //
+    // remove the pixels in fPixelsID if they are set to be used,
+    // (set them to 'unused' state)
+    //
+
+    Double_t *photons = new Double_t[entries];
+    Double_t *errors  = new Double_t[entries];
+
+    for (int n=0; n<fCounts; n++)
+    {
+        for (UShort_t i=0; i<entries; i++)
+        {
+            MCerPhotPix &pix = (*fEvt)[i];
+
+            const Int_t id = pix.GetPixId();
+
+            const MGeomPix &gpix = (*fGeomCam)[id];
+
+            const Int_t n = gpix.GetNumNeighbors();
+
+            Int_t num  = fUseCentralPixel ? 1 : 0;
+            photons[i] = fUseCentralPixel ? pix.GetNumPhotons() : 0;
+            errors[i]  = fUseCentralPixel ? pix.GetErrorPhot()  : 0;
+
+            for (int j=0; j<n; j++)
+            {
+                const UShort_t nid = gpix.GetNeighbor(j);
+
+                const MCerPhotPix *evtpix = fEvt->GetPixById(nid);
+                if (evtpix)
+                {
+                    photons[i] += evtpix->GetNumPhotons();
+                    errors[i]  += evtpix->GetErrorPhot();
+                }
+                num++;
+            }
+
+            photons[i] /= num;
+            errors[i]  /= num;
+        }
+
+        for (UShort_t i=0; i<entries; i++)
+            (*fEvt)[i].Set(photons[i], errors[i]);
+    }
+
+    delete photons;
+    delete errors;
+
+    return kTRUE;
+}
+
Index: /tags/Mars_V0-8-5/Mars/mimage/MCameraSmooth.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mimage/MCameraSmooth.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mimage/MCameraSmooth.h	(revision 9661)
@@ -0,0 +1,36 @@
+#ifndef MARS_MCameraSmooth
+#define MARS_MCameraSmooth
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+#ifndef ROOT_TArrayS
+#include <TArrayS.h>
+#endif
+
+class MGeomCam;
+class MCerPhotEvt;
+
+class MCameraSmooth : public MTask
+{
+private:
+    MCerPhotEvt *fEvt;     //! Pointer to data to smooth
+    MGeomCam    *fGeomCam; //! Camera geometry
+
+    Byte_t fCounts;           // number of smoothing loops
+    Bool_t fUseCentralPixel;  // use also the central pixel
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
+public:
+    MCameraSmooth(Byte_t cnt=1, const char *name=NULL, const char *title=NULL);
+
+    void SetUseCentralPixel(Bool_t b=kTRUE) { fUseCentralPixel=kTRUE; }
+
+    ClassDef(MCameraSmooth, 0) // task to smooth the camera contants
+}; 
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mimage/MConcentration.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mimage/MConcentration.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mimage/MConcentration.cc	(revision 9661)
@@ -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 <mailto:tbretz@uni-sw.gwdg.de>
+!   Author(s): Harald Kornmayer 1/2001
+!   Author(s): Rudolf Bock     10/2001 <mailto:Rudolf.Bock@cern.ch>
+!   Author(s): Wolfgang Wittek  6/2002 <mailto:wittek@mppmu.mpg.de>
+!   Author(s): Oscar Blanch     3/2004 <mailto:blanch@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MConcentration
+//
+// Storage Container for Concentration parameters
+//
+//
+// Version 1:
+// ----------
+// fConc[i]    [ratio] Number of photons in the i+1 more populated pixels
+//                     over the event size (till i=7).
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MConcentration.h"
+
+
+#include <TArrayF.h>
+#include <TArrayI.h>
+
+#include "MHillas.h"
+
+#include "MGeomPix.h"
+#include "MGeomCam.h"
+
+#include "MCerPhotPix.h"
+#include "MCerPhotEvt.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MConcentration);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MConcentration::MConcentration(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MConcentration";
+    fTitle = title ? title : "Storage container for concentrations";
+
+    Reset();
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor. 
+//
+MConcentration::~MConcentration()
+{
+}
+
+// --------------------------------------------------------------------------
+//
+// Initializes the values with defaults. For the default values see the
+// source code.
+//
+void MConcentration::Reset()
+{
+    for (int i=0; i<9; i++)
+        fConc[i] = -1;
+}
+
+// --------------------------------------------------------------------------
+//
+// Print the Concetration Parameters to *fLog
+//
+void MConcentration::Print(Option_t *) const
+{
+    *fLog << all;
+    *fLog << "Concentrations (" << GetName() << ")" << endl;
+    for(int i=0;i<9;i++)
+      *fLog << "Conc" << i+1 <<" = "<< fConc[i] << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculate the Concentrations from a Cherenkov photon event
+// assuming Cher.photons/pixel, their standard hillas parameters 
+// and  pixel coordinates are given.
+// In case you don't call Calc from within an eventloop make sure, that
+// you call the Reset member function before.
+// Returns:
+//    Nothing.
+
+Int_t MConcentration::Calc(const MGeomCam &geom, const MCerPhotEvt &evt, const MHillas &hillas)
+{
+    Float_t maxpix[9] = {0,0,0,0,0,0,0,0,0};             // [#phot]
+
+    TIter Next(evt);
+    MCerPhotPix *pix = 0;
+    while ((pix=(MCerPhotPix*)Next()))
+    {
+        const Int_t    pixid = pix->GetPixId();
+        const Double_t nphot = pix->GetNumPhotons()* geom.GetPixRatio(pixid);
+
+	// Get number of photons in the 8 most populated pixels	
+        if (maxpix[0]<=nphot)
+        {
+            for(int i=0;i<8;i++)
+                maxpix[8-i]=maxpix[7-i];
+            maxpix[0]=nphot;
+            continue;
+        }
+
+	// Check if the latest value is 'somewhere in between'
+        for (int i=0; i<8; i++)
+        {
+            if (nphot>=maxpix[7-i])
+                continue;
+
+            for(int j=0;j<i-1;j++)
+                maxpix[7-j]=maxpix[6-j];                 // [#phot]
+
+            maxpix[8-i]=nphot;
+            break;
+        }
+    }
+
+    // Compute concentrations from the 8 pixels with higher signal
+    fConc[0]=maxpix[0];
+
+    // No calculate the integral of the n highest pixels
+    for(int i=1; i<8; i++)
+        fConc[i] = fConc[i-1]+maxpix[i];
+
+    for(int i=0; i<8; i++)
+        fConc[i] /= hillas.GetSize();                    // [ratio]
+
+    SetReadyToSave();
+
+    return 0;
+}
Index: /tags/Mars_V0-8-5/Mars/mimage/MConcentration.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mimage/MConcentration.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mimage/MConcentration.h	(revision 9661)
@@ -0,0 +1,40 @@
+#ifndef MARS_MConcentration
+#define MARS_MConcentration
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MHillas;
+class MGeomCam;
+class MCerPhotEvt;
+
+class MConcentration : public MParContainer
+{
+private:
+    Float_t fConc[9];       // [ratio] Num photons in i+1 pixels over size of event 
+
+public:
+    MConcentration(const char *name=NULL, const char *title=NULL);
+    ~MConcentration();
+
+    void Reset();
+
+    Int_t Calc(const MGeomCam &geom, const MCerPhotEvt &pix, const MHillas &hil);
+
+    void Print(Option_t *opt=NULL) const;
+
+    Float_t GetConc1() const { return fConc[0]; }
+    Float_t GetConc2() const { return fConc[1]; }
+    Float_t GetConc3() const { return fConc[2]; }
+    Float_t GetConc4() const { return fConc[3]; }
+    Float_t GetConc5() const { return fConc[4]; }
+    Float_t GetConc6() const { return fConc[5]; }
+    Float_t GetConc7() const { return fConc[6]; }
+    Float_t GetConc8() const { return fConc[7]; }
+    Float_t GetConc9() const { return fConc[8]; }
+
+    ClassDef(MConcentration, 1) // Storage Container for Concentration Parameter
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mimage/MHHillas.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mimage/MHHillas.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mimage/MHHillas.cc	(revision 9661)
@@ -0,0 +1,348 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  2001 <mailto:tbretz@uni-sw.gwdg.de>
+!              Wolfgang Wittek  2002 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHHillas
+//
+// This class contains histograms for the source independent image parameters
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MHHillas.h"
+
+#include <math.h>
+
+#include <TH1.h>
+#include <TH2.h>
+#include <TPad.h>
+#include <TStyle.h>
+#include <TCanvas.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MHillas.h"
+#include "MGeomCam.h"
+#include "MBinning.h"
+
+
+ClassImp(MHHillas);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Setup four histograms for Width, Length
+//
+MHHillas::MHHillas(const char *name, const char *title)
+    : fMm2Deg(1), fUseMmScale(kTRUE)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHHillas";
+    fTitle = title ? title : "Source independent image parameters";
+
+    fLength  = new TH1F("Length",  "Length of Ellipse",               100,   0, 296.7);
+    fWidth   = new TH1F("Width",   "Width of Ellipse",                100,   0, 296.7);
+    fDistC   = new TH1F("DistC",   "Distance from center of camera",  100,   0, 445);
+    fDelta   = new TH1F("Delta",   "Angle (Main axis - x-axis)",      101, -90,  90);
+
+    fLength->SetLineColor(kBlue);
+
+    fLength->SetDirectory(NULL);
+    fWidth->SetDirectory(NULL);
+    fDistC->SetDirectory(NULL);
+    fDelta->SetDirectory(NULL);
+
+    fLength->SetXTitle("Length [mm]");
+    fWidth->SetXTitle("Width [mm]");
+    fDistC->SetXTitle("Distance [mm]");
+    fDelta->SetXTitle("Delta [\\circ]");
+
+    fLength->SetYTitle("Counts");
+    fWidth->SetYTitle("Counts");
+    fDistC->SetYTitle("Counts");
+    fDelta->SetYTitle("Counts");
+
+    MBinning bins;
+    bins.SetEdgesLog(50, 1, 1e7);
+
+    fSize  = new TH1F;
+    fSize->SetName("Size");
+    fSize->SetTitle("Number of Photons");
+    fSize->SetDirectory(NULL);
+    fSize->SetXTitle("Size");
+    fSize->SetYTitle("Counts");
+    fSize->GetXaxis()->SetTitleOffset(1.2);
+    fSize->GetXaxis()->SetLabelOffset(-0.015);
+    fSize->SetFillStyle(4000);
+    fSize->UseCurrentStyle();
+
+    bins.Apply(*fSize);
+
+    fCenter = new TH2F("Center", "Center of Ellipse", 51, -445, 445, 51, -445, 445);
+    fCenter->SetDirectory(NULL);
+    fCenter->SetXTitle("x [mm]");
+    fCenter->SetYTitle("y [mm]");
+    fCenter->SetZTitle("Counts");
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the histograms
+//
+MHHillas::~MHHillas()
+{
+    delete fLength;
+    delete fWidth;
+
+    delete fDistC;
+    delete fDelta;
+
+    delete fSize;
+    delete fCenter;
+}
+
+// --------------------------------------------------------------------------
+//
+// Setup the Binning for the histograms automatically if the correct
+// instances of MBinning (with the names 'BinningWidth' and 'BinningLength')
+// are found in the parameter list
+// Use this function if you want to set the conversion factor which
+// is used to convert the mm-scale in the camera plain into the deg-scale
+// used for histogram presentations. The conversion factor is part of
+// the camera geometry. Please create a corresponding MGeomCam container.
+//
+Bool_t MHHillas::SetupFill(const MParList *plist)
+{
+    const MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam");
+    if (!geom)
+        *fLog << warn << GetDescriptor() << ": No Camera Geometry available. Using mm-scale for histograms." << endl;
+    else
+    {
+        fMm2Deg = geom->GetConvMm2Deg();
+        SetMmScale(kFALSE);
+    }
+
+    ApplyBinning(*plist, "Width",  fWidth);
+    ApplyBinning(*plist, "Length", fLength);
+    ApplyBinning(*plist, "Dist",   fDistC);
+    ApplyBinning(*plist, "Delta",  fDelta);
+    ApplyBinning(*plist, "Size",   fSize);
+
+    const MBinning *bins = (MBinning*)plist->FindObject("BinningCamera");
+    if (!bins)
+    {
+        float r = geom ? geom->GetMaxRadius() : 600;
+        r *= 0.9;
+        if (!fUseMmScale)
+            r *= fMm2Deg;
+
+        MBinning b;
+        b.SetEdges(61, -r, r);
+        SetBinning(fCenter, &b, &b);
+    }
+    else
+        SetBinning(fCenter, bins, bins);
+
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Use this function to setup your own conversion factor between degrees
+// and millimeters. The conversion factor should be the one calculated in
+// MGeomCam. Use this function with Caution: You could create wrong values
+// by setting up your own scale factor.
+//
+void MHHillas::SetMm2Deg(Float_t mmdeg)
+{
+    if (mmdeg<0)
+    {
+        *fLog << warn << dbginf << "Warning - Conversion factor < 0 - nonsense. Ignored." << endl;
+        return;
+    }
+
+    if (fMm2Deg>=0)
+        *fLog << warn << dbginf << "Warning - Conversion factor already set. Overwriting" << endl;
+
+    fMm2Deg = mmdeg;
+}
+
+// --------------------------------------------------------------------------
+//
+// With this function you can convert the histogram ('on the fly') between
+// degrees and millimeters.
+//
+void MHHillas::SetMmScale(Bool_t mmscale)
+{
+    if (fUseMmScale == mmscale)
+        return;
+
+    if (fMm2Deg<0)
+    {
+        *fLog << warn << dbginf << "Warning - Sorry, no conversion factor for conversion available." << endl;
+        return;
+    }
+
+    const Double_t scale = mmscale ? 1./fMm2Deg : fMm2Deg;
+    MH::ScaleAxis(fLength, scale);
+    MH::ScaleAxis(fWidth,  scale);
+    MH::ScaleAxis(fDistC,  scale);
+    MH::ScaleAxis(fCenter, scale, scale);
+
+    if (mmscale)
+    {
+        fLength->SetXTitle("Length [mm]");
+        fWidth->SetXTitle("Width [mm]");
+        fDistC->SetXTitle("Distance [mm]");
+        fCenter->SetXTitle("x [mm]");
+        fCenter->SetYTitle("y [mm]");
+    }
+    else
+    {
+        fLength->SetXTitle("Length [\\circ]");
+        fWidth->SetXTitle("Width [\\circ]");
+        fDistC->SetXTitle("Distance [\\circ]");
+        fCenter->SetXTitle("x [\\circ]");
+        fCenter->SetYTitle("y [\\circ]");
+    }
+
+    fUseMmScale = mmscale;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the histograms with data from a MHillas-Container.
+// Be careful: Only call this with an object of type MHillas
+//
+Bool_t MHHillas::Fill(const MParContainer *par, const Stat_t w)
+{
+    if (!par)
+    {
+        *fLog << err << "MHHillas::Fill: Pointer (!=NULL) expected." << endl;
+        return kFALSE;
+    }
+
+    const MHillas &h = *(MHillas*)par;
+
+    const Double_t d = sqrt(h.GetMeanX()*h.GetMeanX() + h.GetMeanY()*h.GetMeanY());
+    const Double_t scale = fUseMmScale ? 1 : fMm2Deg;
+
+    fLength->Fill(scale*h.GetLength(), w);
+    fWidth ->Fill(scale*h.GetWidth(), w);
+    fDistC ->Fill(scale*d, w);
+    fCenter->Fill(scale*h.GetMeanX(), scale*h.GetMeanY(), w);
+    fDelta ->Fill(kRad2Deg*h.GetDelta(), w);
+    fSize  ->Fill(h.GetSize(), w);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Setup a inversed deep blue sea palette for the fCenter histogram.
+//
+void MHHillas::SetColors() const
+{
+    gStyle->SetPalette(51, NULL);
+    Int_t c[50];
+    for (int i=0; i<50; i++)
+        c[49-i] = gStyle->GetColorPalette(i);
+    gStyle->SetPalette(50, c);
+}
+
+// --------------------------------------------------------------------------
+//
+// 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 *)
+{
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    AppendPad("");
+
+    pad->Divide(2,3);
+
+    pad->cd(1);
+    gPad->SetBorderMode(0);
+    MH::DrawSame(*fWidth, *fLength, "Width'n'Length");
+
+    pad->cd(2);
+    gPad->SetBorderMode(0);
+    fDistC->Draw();
+
+    pad->cd(3);
+    gPad->SetBorderMode(0);
+    gPad->SetLogx();
+    fSize->Draw();
+
+    pad->cd(4);
+    gPad->SetBorderMode(0);
+    gPad->SetPad(0.51, 0.01, 0.99, 0.65);
+    SetColors();
+    fCenter->Draw("colz");
+
+    pad->cd(5);
+    gPad->SetBorderMode(0);
+    fDelta->Draw();
+
+    pad->cd(6);
+    delete gPad;
+
+    pad->Modified();
+    pad->Update();
+}
+
+TH1 *MHHillas::GetHistByName(const TString name)
+{
+    if (name.Contains("Width", TString::kIgnoreCase))
+        return fWidth;
+    if (name.Contains("Length", TString::kIgnoreCase))
+        return fLength;
+    if (name.Contains("Size", TString::kIgnoreCase))
+        return fSize;
+    if (name.Contains("Delta", TString::kIgnoreCase))
+        return fDelta;
+    if (name.Contains("DistC", TString::kIgnoreCase))
+        return fDistC;
+    if (name.Contains("Center", TString::kIgnoreCase))
+        return fCenter;
+
+    return NULL;
+}
+
+void MHHillas::Paint(Option_t *opt)
+{
+    SetColors();
+    MH::Paint();
+}
Index: /tags/Mars_V0-8-5/Mars/mimage/MHHillas.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mimage/MHHillas.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mimage/MHHillas.h	(revision 9661)
@@ -0,0 +1,60 @@
+#ifndef MARS_MHHillas
+#define MARS_MHHillas
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+class TH1F;
+class TH2F;
+class MHillas;
+
+class MHHillas : public MH
+{
+private:
+
+    TH1F *fLength;  //-> Length
+    TH1F *fWidth;   //-> Width
+
+    TH1F *fDistC;   //-> Distance to Camera Center
+    TH1F *fDelta;   //-> Angle between Length axis and x-axis
+
+    TH1F *fSize;    //-> Sum of used pixels
+    TH2F *fCenter;  //-> Center
+
+    void SetColors() const;
+
+    Float_t fMm2Deg;
+    Bool_t  fUseMmScale;
+
+    void Paint(Option_t *opt="");
+
+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, const Stat_t w=1);
+
+    TH1 *GetHistByName(const TString name);
+
+    TH1F *GetHistLength() { return fLength; }
+    TH1F *GetHistWidth()  { return fWidth; }
+
+    TH1F *GetHistDistC()  { return fDistC; }
+    TH1F *GetHistDelta()  { return fDelta; }
+
+    TH1F *GetHistSize()   { return fSize; }
+    TH2F *GetHistCenter() { return fCenter; }
+
+    void Draw(Option_t *opt=NULL);
+
+    //Int_t DistancetoPrimitive(Int_t px, Int_t py) { return 0; }
+
+    ClassDef(MHHillas, 1) // Container which holds histograms for the source independent image parameters
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mimage/MHHillasExt.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mimage/MHHillasExt.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mimage/MHHillasExt.cc	(revision 9661)
@@ -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@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHHillasExt
+//
+// This class contains histograms for every Hillas parameter
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MHHillasExt.h"
+
+#include <math.h>
+
+#include <TH1.h>
+#include <TPad.h>
+#include <TLegend.h>
+#include <TCanvas.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MGeomCam.h"
+
+#include "MParList.h"
+
+#include "MBinning.h"
+#include "MHillasExt.h"
+#include "MHillasSrc.h"
+
+ClassImp(MHHillasExt);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Setup four histograms for Width, Length
+//
+MHHillasExt::MHHillasExt(const char *name, const char *title)
+    : fMm2Deg(1), fUseMmScale(kTRUE), fHilName("MHillasExt")
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHHillasExt";
+    fTitle = title ? title : "Container for extended Hillas histograms";
+
+    //
+    // loop over all Pixels and create two histograms
+    // one for the Low and one for the High gain
+    // connect all the histogram with the container fHist
+    //
+    fHAsym.SetDirectory(NULL);
+    fHM3Long.SetDirectory(NULL);
+    fHM3Trans.SetDirectory(NULL);
+    fHMaxDist.SetDirectory(NULL);
+
+    fHAsym.UseCurrentStyle();
+    fHM3Long.UseCurrentStyle();
+    fHM3Trans.UseCurrentStyle();
+    fHMaxDist.UseCurrentStyle();
+
+    fHAsym.SetName("Asymmetry");
+    fHM3Long.SetName("3rd Mom Long");
+    fHM3Trans.SetName("3rd Mom Trans");
+    fHMaxDist.SetName("Max Dist");
+
+    fHAsym.SetTitle("Asymmetry");
+    fHM3Long.SetTitle("3^{rd} Moment Longitudinal");
+    fHM3Trans.SetTitle("3^{rd} Moment Transverse");
+    fHMaxDist.SetTitle("Distance of max distant pixel");
+
+    fHAsym.SetXTitle("Asym [mm]");
+    fHM3Long.SetXTitle("3^{rd} M_{l} [mm]");
+    fHM3Trans.SetXTitle("3^{rd} M_{t} [mm]");
+    fHMaxDist.SetXTitle("D_{max} [mm]");
+
+    fHAsym.SetYTitle("Counts");
+    fHM3Long.SetYTitle("Counts");
+    fHM3Trans.SetYTitle("Counts");
+    fHMaxDist.SetYTitle("Counts");
+
+    fHAsym.SetFillStyle(4000);
+    fHM3Long.SetFillStyle(4000);
+    fHM3Trans.SetFillStyle(4000);
+    fHMaxDist.SetFillStyle(4000);
+
+    fHM3Trans.SetLineColor(kBlue);
+
+    MBinning bins;
+
+    bins.SetEdges(51, -326, 326);
+    bins.Apply(fHM3Long);
+    bins.Apply(fHM3Trans);
+
+    bins.SetEdges(51, -593, 593);
+    bins.Apply(fHAsym);
+
+    bins.SetEdges(101, 0, 593);
+    bins.Apply(fHMaxDist);
+}
+
+// --------------------------------------------------------------------------
+//
+// 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)
+{
+    fHillasExt = (MHillasExt*)plist->FindObject(fHilName, "MHillasExt");
+    if (!fHillasExt)
+    {
+        *fLog << err << fHilName << "[MHillasExt] not found in parameter list... aborting." << endl;
+        return kFALSE;
+    }
+
+    const MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam");
+    if (!geom)
+        *fLog << warn << GetDescriptor() << ": No Camera Geometry available. Using mm-scale for histograms." << endl;
+    else
+    {
+        fMm2Deg = geom->GetConvMm2Deg();
+        SetMmScale(kFALSE);
+    }
+
+    ApplyBinning(*plist, "Asym",    &fHAsym);
+    ApplyBinning(*plist, "M3Long",  &fHM3Long);
+    ApplyBinning(*plist, "M3Trans", &fHM3Trans);
+    ApplyBinning(*plist, "MaxDist", &fHMaxDist);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the four histograms with data from a MHillas-Container.
+// Be careful: Only call this with an object of type MHillas
+//
+Bool_t MHHillasExt::Fill(const MParContainer *par, const Stat_t w)
+{
+    const MHillasSrc *src = (MHillasSrc*)par;
+
+    const Double_t scale = TMath::Sign(fUseMmScale?1:fMm2Deg, (src ? src->GetCosDeltaAlpha() : 1));
+
+    fHAsym.Fill(scale*fHillasExt->GetAsym(), w);
+    fHM3Long.Fill(scale*fHillasExt->GetM3Long(), w);
+    fHM3Trans.Fill(scale*fHillasExt->GetM3Trans(), w);
+    fHMaxDist.Fill(TMath::Abs(scale*fHillasExt->GetMaxDist()), w);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// With this function you can convert the histogram ('on the fly') between
+// degrees and millimeters.
+//
+void MHHillasExt::SetMmScale(Bool_t mmscale)
+{
+    if (fUseMmScale == mmscale)
+        return;
+
+    if (fMm2Deg<0)
+    {
+        *fLog << warn << dbginf << "Warning - Sorry, no conversion factor for conversion available." << endl;
+        return;
+    }
+
+    const Double_t scale = mmscale ? 1./fMm2Deg : fMm2Deg;
+    MH::ScaleAxis(&fHAsym,    scale);
+    MH::ScaleAxis(&fHM3Long,  scale);
+    MH::ScaleAxis(&fHM3Trans, scale);
+    MH::ScaleAxis(&fHMaxDist, scale);
+
+    if (mmscale)
+    {
+        fHAsym.SetXTitle("Asym [mm]");
+        fHM3Long.SetXTitle("3^{rd} M_{l} [mm]");
+        fHM3Trans.SetXTitle("3^{rd} M_{t} [mm]");
+        fHMaxDist.SetXTitle("D_{max} [mm]");
+    }
+    else
+    {
+        fHAsym.SetXTitle("Asym [\\circ]");
+        fHM3Long.SetXTitle("3^{rd} M_{l} [\\circ]");
+        fHM3Trans.SetXTitle("3^{rd} M_{t} [\\circ]");
+        fHMaxDist.SetXTitle("D_{max} [\\circ]");
+    }
+
+    fUseMmScale = mmscale;
+}
+
+// --------------------------------------------------------------------------
+//
+// Use this function to setup your own conversion factor between degrees
+// and millimeters. The conversion factor should be the one calculated in
+// MGeomCam. Use this function with Caution: You could create wrong values
+// by setting up your own scale factor.
+//
+void MHHillasExt::SetMm2Deg(Float_t mmdeg)
+{
+    if (mmdeg<0)
+    {
+        *fLog << warn << dbginf << "Warning - Conversion factor < 0 - nonsense. Ignored." << endl;
+        return;
+    }
+
+    if (fMm2Deg>=0)
+        *fLog << warn << dbginf << "Warning - Conversion factor already set. Overwriting" << endl;
+
+    fMm2Deg = mmdeg;
+}
+
+// --------------------------------------------------------------------------
+//
+// 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 *)
+{
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    AppendPad("");
+
+    pad->Divide(2, 2);
+
+    pad->cd(1);
+    gPad->SetBorderMode(0);
+    MH::DrawSame(fHM3Long, fHM3Trans, "3^{rd} Moments");
+
+    pad->cd(3);
+    gPad->SetBorderMode(0);
+    fHAsym.Draw();
+
+    pad->cd(2);
+    gPad->SetBorderMode(0);
+    fHMaxDist.Draw();
+
+    delete pad->GetPad(4);
+
+    pad->Modified();
+    pad->Update();
+}
+
+TH1 *MHHillasExt::GetHistByName(const TString name)
+{
+    if (name.Contains("Asym", TString::kIgnoreCase))
+        return &fHAsym;
+    if (name.Contains("M3Long", TString::kIgnoreCase))
+        return &fHM3Long;
+    if (name.Contains("M3Trans", TString::kIgnoreCase))
+        return &fHM3Trans;
+    if (name.Contains("MaxDist", TString::kIgnoreCase))
+        return &fHMaxDist;
+
+    return NULL;
+}
Index: /tags/Mars_V0-8-5/Mars/mimage/MHHillasExt.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mimage/MHHillasExt.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mimage/MHHillasExt.h	(revision 9661)
@@ -0,0 +1,46 @@
+#ifndef MARS_MHHillasExt
+#define MARS_MHHillasExt
+
+#ifndef ROOT_TH1
+#include <TH1.h>
+#endif
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+class MHillasExt;
+
+class MHHillasExt : public MH
+{
+private:
+    MHillasExt *fHillasExt; //! Pointer to the MHillasExt container
+
+    TH1F 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
+    TH1F fHMaxDist; // [mm]    Distance between shower center maximum distant pixel
+
+    Float_t fMm2Deg;
+    Bool_t  fUseMmScale;
+
+    TString fHilName;
+
+public:
+    MHHillasExt(const char *name=NULL, const char *title=NULL);
+
+    void SetHillasName(const char *name) { fHilName = name; }
+
+    void SetMmScale(Bool_t mmscale=kTRUE);
+    virtual void SetMm2Deg(Float_t mmdeg);
+
+    Bool_t SetupFill(const MParList *pList);
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+
+    TH1 *GetHistByName(const TString name);
+
+    void Draw(Option_t *opt=NULL);
+
+    ClassDef(MHHillasExt, 1) // Container which holds histograms for the extended hillas parameters
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mimage/MHHillasSrc.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mimage/MHHillasSrc.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mimage/MHHillasSrc.cc	(revision 9661)
@@ -0,0 +1,251 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Setup four histograms for Alpha, and Dist
+//
+MHHillasSrc::MHHillasSrc(const char *name, const char *title)
+    : fUseMmScale(kTRUE)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHHillasSrc";
+    fTitle = title ? title : "Container for Hillas histograms";
+
+    //
+    // loop over all Pixels and create two histograms
+    // one for the Low and one for the High gain
+    // connect all the histogram with the container fHist
+    //
+    fAlpha = new TH1F("Alpha", "Alpha of Ellipse",            181, -90,  90);
+    fDist  = new TH1F("Dist",  "Dist of Ellipse",             100,   0, 445);
+    fCosDA = new TH1F("CosDA", "cos(Delta,Alpha) of Ellipse", 101,  -1,   1);
+
+    fAlpha->SetDirectory(NULL);
+    fDist->SetDirectory(NULL);
+    fCosDA->SetDirectory(NULL);
+
+    fAlpha->SetXTitle("\\alpha [\\circ]");
+    fDist->SetXTitle("Dist [mm]");
+    fCosDA->SetXTitle("cos(\\delta,\\alpha)");
+
+    fAlpha->SetYTitle("Counts");
+    fDist->SetYTitle("Counts");
+    fCosDA->SetYTitle("Counts");
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the four histograms
+//
+MHHillasSrc::~MHHillasSrc()
+{
+    delete fAlpha;
+    delete fDist;
+    delete fCosDA;
+}
+
+// --------------------------------------------------------------------------
+//
+// Setup the Binning for the histograms automatically if the correct
+// instances of MBinning (with the names 'BinningAlpha' and 'BinningDist')
+// are found in the parameter list
+// Use this function if you want to set the conversion factor which
+// is used to convert the mm-scale in the camera plain into the deg-scale
+// used for histogram presentations. The conversion factor is part of
+// the camera geometry. Please create a corresponding MGeomCam container.
+//
+Bool_t MHHillasSrc::SetupFill(const MParList *plist)
+{
+    const MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam");
+    if (!geom)
+        *fLog << warn << dbginf << "No Camera Geometry available. Using mm-scale for histograms." << endl;
+    else
+    {
+        fMm2Deg = geom->GetConvMm2Deg();
+        SetMmScale(kFALSE);
+    }
+
+    ApplyBinning(*plist, "Alpha",    fAlpha);
+    ApplyBinning(*plist, "Dist",     fDist);
+
+    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 Stat_t w)
+{
+    if (!par)
+    {
+        *fLog << err << "MHHillasSrc::Fill: Pointer (!=NULL) expected." << endl;
+        return kFALSE;
+    }
+
+    const MHillasSrc &h = *(MHillasSrc*)par;
+
+    fAlpha->Fill(h.GetAlpha(), w);
+    fDist ->Fill(fUseMmScale ? h.GetDist() : fMm2Deg*h.GetDist(), w);
+    fCosDA->Fill(h.GetCosDeltaAlpha(), w);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Use this function to setup your own conversion factor between degrees
+// and millimeters. The conversion factor should be the one calculated in
+// MGeomCam. Use this function with Caution: You could create wrong values
+// by setting up your own scale factor.
+//
+void MHHillasSrc::SetMm2Deg(Float_t mmdeg)
+{
+    if (mmdeg<=0)
+    {
+        *fLog << warn << dbginf << "Warning - Conversion factor <= 0 - nonsense. Ignored." << endl;
+        return;
+    }
+
+    if (fMm2Deg>0)
+        *fLog << warn << dbginf << "Warning - Conversion factor already set. Overwriting" << endl;
+
+    fMm2Deg = mmdeg;
+}
+
+// --------------------------------------------------------------------------
+//
+// With this function you can convert the histogram ('on the fly') between
+// degrees and millimeters.
+//
+void MHHillasSrc::SetMmScale(Bool_t mmscale)
+{
+    if (fUseMmScale == mmscale)
+        return;
+
+    if (fMm2Deg<0)
+    {
+        *fLog << warn << GetDescriptor() << ": Warning - Sorry, no conversion factor for conversion available." << endl;
+        return;
+    }
+
+    const Double_t scale = mmscale ? 1./fMm2Deg : fMm2Deg;
+    MH::ScaleAxis(fDist, scale);
+
+    fDist->SetXTitle(mmscale ? "Dist [mm]" : "Dist [\\circ]");
+
+    fUseMmScale = mmscale;
+}
+
+// --------------------------------------------------------------------------
+//
+// 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 *)
+{
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    AppendPad("");
+
+    // FIXME: Display Source position
+
+    pad->Divide(2, 2);
+
+    pad->cd(1);
+    gPad->SetBorderMode(0);
+    fAlpha->Draw();
+
+    pad->cd(2);
+    gPad->SetBorderMode(0);
+    fDist->Draw();
+
+    delete pad->GetPad(3);
+
+    pad->cd(4);
+    gPad->SetBorderMode(0);
+    //gPad->SetLogy();
+    fCosDA->Draw();
+
+    pad->Modified();
+    pad->Update();
+}
+
+void MHHillasSrc::Paint(Option_t *opt)
+{
+    if (fCosDA->GetEntries()==0)
+        return;
+
+    TVirtualPad *savepad = gPad;
+    savepad->cd(4);
+    gPad->SetLogy();
+    gPad = savepad;
+}
+
+TH1 *MHHillasSrc::GetHistByName(const TString name)
+{
+    if (name.Contains("Alpha", TString::kIgnoreCase))
+        return fAlpha;
+    if (name.Contains("Dist", TString::kIgnoreCase))
+        return fDist;
+    if (name.Contains("CosDA", TString::kIgnoreCase))
+        return fCosDA;
+
+    return NULL;
+}
Index: /tags/Mars_V0-8-5/Mars/mimage/MHHillasSrc.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mimage/MHHillasSrc.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mimage/MHHillasSrc.h	(revision 9661)
@@ -0,0 +1,44 @@
+#ifndef MARS_MHHillasSrc
+#define MARS_MHHillasSrc
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+class TH1F;
+class MHillas;
+
+class MHHillasSrc : public MH
+{
+private:
+    TH1F *fAlpha;     //->
+    TH1F *fDist;      //->
+    TH1F *fCosDA;     //->
+
+    Float_t fMm2Deg;
+    Bool_t  fUseMmScale;
+
+public:
+    MHHillasSrc(const char *name=NULL, const char *title=NULL);
+    ~MHHillasSrc();
+
+    void SetMmScale(Bool_t mmscale=kTRUE);
+    void SetMm2Deg(Float_t mmdeg);
+
+    Bool_t SetupFill(const MParList *pList);
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+
+    TH1 *GetHistByName(const TString name);
+
+    TH1F *GetHistAlpha()         { return fAlpha; }
+    TH1F *GetHistDist()          { return fDist; }
+    TH1F *GetHistCosDeltaAlpha() { return fCosDA; }
+
+    void Draw(Option_t *opt=NULL);
+    void Paint(Option_t *opt);
+
+
+    ClassDef(MHHillasSrc, 1) // Container which holds histograms for the source dependant parameters
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mimage/MHNewImagePar.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mimage/MHNewImagePar.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mimage/MHNewImagePar.cc	(revision 9661)
@@ -0,0 +1,259 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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, 03/2003 <mailto:wittek@mppmu.mpg.de>
+!   Author(s): Thomas Bretz, 04/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHNewImagePar
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MHNewImagePar.h"
+
+#include <math.h>
+
+#include <TH1.h>
+#include <TPad.h>
+#include <TCanvas.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MGeomCam.h"
+#include "MBinning.h"
+#include "MParList.h"
+
+#include "MHillas.h"
+#include "MNewImagePar.h"
+
+ClassImp(MHNewImagePar);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Setup histograms 
+//
+MHNewImagePar::MHNewImagePar(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MHNewImagePar";
+    fTitle = title ? title : "Histograms of new image parameters";
+
+    fHistLeakage1.SetName("Leakage1");
+    fHistLeakage1.SetTitle("Leakage_{1}");
+    fHistLeakage1.SetXTitle("Leakage");
+    fHistLeakage1.SetYTitle("Counts");
+    fHistLeakage1.SetDirectory(NULL);
+    fHistLeakage1.UseCurrentStyle();
+    fHistLeakage1.SetFillStyle(4000);
+
+    fHistLeakage2.SetName("Leakage2");
+    fHistLeakage2.SetTitle("Leakage_{2}");
+    fHistLeakage2.SetXTitle("Leakage");
+    fHistLeakage2.SetYTitle("Counts");
+    fHistLeakage2.SetDirectory(NULL);
+    fHistLeakage2.UseCurrentStyle();
+    fHistLeakage2.SetLineColor(kBlue);
+    fHistLeakage2.SetFillStyle(4000);
+ 
+    fHistUsedPix.SetName("UsedPix");
+    fHistUsedPix.SetTitle("Number of used pixels");
+    fHistUsedPix.SetXTitle("Number of Pixels");
+    fHistUsedPix.SetYTitle("Counts");
+    fHistUsedPix.SetDirectory(NULL);
+    fHistUsedPix.UseCurrentStyle();
+    fHistUsedPix.SetLineColor(kBlue);
+    fHistUsedPix.SetFillStyle(4000);
+
+    fHistCorePix.SetName("CorePix");
+    fHistCorePix.SetTitle("Number of core pixels");
+    fHistCorePix.SetXTitle("Number of Pixels");
+    fHistCorePix.SetYTitle("Counts");
+    fHistCorePix.SetDirectory(NULL);
+    fHistCorePix.UseCurrentStyle();
+    fHistCorePix.SetLineColor(kBlack);
+    fHistCorePix.SetFillStyle(4000);
+
+    fHistUsedArea.SetName("UsedArea");
+    fHistUsedArea.SetTitle("Area of used pixels");
+    fHistUsedArea.SetXTitle("Area [m^2]");
+    fHistUsedArea.SetYTitle("Counts");
+    fHistUsedArea.SetDirectory(NULL);
+    fHistUsedArea.UseCurrentStyle();
+    fHistUsedArea.SetLineColor(kBlue);
+    fHistUsedArea.SetFillStyle(4000);
+
+    fHistCoreArea.SetName("CoreArea");
+    fHistCoreArea.SetTitle("Area of core pixels");
+    fHistCoreArea.SetXTitle("Area [m^2]");
+    fHistCoreArea.SetYTitle("Counts");
+    fHistCoreArea.SetDirectory(NULL);
+    fHistCoreArea.UseCurrentStyle();
+    fHistCoreArea.SetLineColor(kBlack);
+    fHistCoreArea.SetFillStyle(4000);
+
+    fHistConc.SetDirectory(NULL);
+    fHistConc1.SetDirectory(NULL);
+    fHistConc.SetName("Conc2");
+    fHistConc1.SetName("Conc1");
+    fHistConc.SetTitle("Ratio: Conc");
+    fHistConc1.SetTitle("Ratio: Conc1");
+    fHistConc.SetXTitle("Ratio");
+    fHistConc1.SetXTitle("Ratio");
+    fHistConc.SetYTitle("Counts");
+    fHistConc1.SetYTitle("Counts");
+    fHistConc1.UseCurrentStyle();
+    fHistConc.UseCurrentStyle();
+    fHistConc.SetFillStyle(4000);
+    fHistConc1.SetFillStyle(4000);
+    fHistConc1.SetLineColor(kBlue);
+    fHistConc.SetFillStyle(0);
+
+
+    MBinning bins;
+
+    bins.SetEdges(100, 0, 1);
+    bins.Apply(fHistLeakage1);
+    bins.Apply(fHistLeakage2);
+    bins.Apply(fHistConc);
+    bins.Apply(fHistConc1);
+
+    bins.SetEdges(75, 0, 150);
+    bins.Apply(fHistUsedPix);
+    bins.Apply(fHistCorePix);
+
+    bins.SetEdges(75, 0, 0.249);
+    bins.Apply(fHistUsedArea);
+    bins.Apply(fHistCoreArea);
+}
+
+// --------------------------------------------------------------------------
+//
+// Setup the Binning for the histograms automatically if the correct
+// instances of MBinning
+//
+Bool_t MHNewImagePar::SetupFill(const MParList *plist)
+{
+    ApplyBinning(*plist, "Leakage", &fHistLeakage1);
+    ApplyBinning(*plist, "Leakage", &fHistLeakage2);
+
+    ApplyBinning(*plist, "Pixels",  &fHistUsedPix);
+    ApplyBinning(*plist, "Pixels",  &fHistCorePix);
+
+    ApplyBinning(*plist, "Area",    &fHistUsedArea);
+    ApplyBinning(*plist, "Area",    &fHistCoreArea);
+
+    ApplyBinning(*plist, "Conc",    &fHistConc);
+    ApplyBinning(*plist, "Conc1",   &fHistConc1);
+
+    return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Fill the histograms with data from a MNewImagePar container.
+//
+Bool_t MHNewImagePar::Fill(const MParContainer *par, const Stat_t w)
+{
+    if (!par)
+    {
+        *fLog << err << "MHNewImagePar::Fill: Pointer (!=NULL) expected." << endl;
+        return kFALSE;
+    }
+
+    const MNewImagePar &h = *(MNewImagePar*)par;
+
+    fHistLeakage1.Fill(h.GetLeakage1(), w);
+    fHistLeakage2.Fill(h.GetLeakage2(), w);
+
+    fHistUsedPix.Fill(h.GetNumUsedPixels(), w);
+    fHistCorePix.Fill(h.GetNumCorePixels(), w);
+
+    fHistUsedArea.Fill(h.GetUsedArea()/1000000, w);
+    fHistCoreArea.Fill(h.GetCoreArea()/1000000, w);
+
+    fHistConc.Fill(h.GetConc(), w);
+    fHistConc1.Fill(h.GetConc1(), w);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// 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 MHNewImagePar::Draw(Option_t *)
+{
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    AppendPad("");
+
+    pad->Divide(2,2);
+
+    pad->cd(1);
+    gPad->SetBorderMode(0);
+    TAxis &x = *fHistLeakage1.GetXaxis();
+    x.SetRangeUser(0.0, x.GetXmax());
+    MH::DrawSame(fHistLeakage1, fHistLeakage2, "Leakage1 and Leakage2");
+
+    pad->cd(2);
+    gPad->SetBorderMode(0);
+    MH::DrawSame(fHistCorePix, fHistUsedPix, "Number of core/used Pixels");
+
+    pad->cd(3);
+    gPad->SetBorderMode(0);
+    MH::DrawSame(fHistConc1, fHistConc, "Concentrations");
+
+    pad->cd(4);
+    gPad->SetBorderMode(0);
+    MH::DrawSame(fHistCoreArea, fHistUsedArea, "Area of core/used Pixels");
+
+    pad->Modified();
+    pad->Update();
+}
+
+TH1 *MHNewImagePar::GetHistByName(const TString name)
+{
+    if (name.Contains("Leakage1", TString::kIgnoreCase))
+        return &fHistLeakage1;
+    if (name.Contains("Leakage2", TString::kIgnoreCase))
+        return &fHistLeakage2;
+    if (name.Contains("Conc", TString::kIgnoreCase))
+        return &fHistConc;
+    if (name.Contains("Conc1", TString::kIgnoreCase))
+        return &fHistConc1;
+    if (name.Contains("UsedPix", TString::kIgnoreCase))
+        return &fHistUsedPix;
+    if (name.Contains("CorePix", TString::kIgnoreCase))
+        return &fHistCorePix;
+    if (name.Contains("UsedArea", TString::kIgnoreCase))
+        return &fHistUsedArea;
+    if (name.Contains("CoreArea", TString::kIgnoreCase))
+        return &fHistCoreArea;
+
+    return NULL;
+}
Index: /tags/Mars_V0-8-5/Mars/mimage/MHNewImagePar.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mimage/MHNewImagePar.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mimage/MHNewImagePar.h	(revision 9661)
@@ -0,0 +1,55 @@
+#ifndef MARS_MHNewImagePar
+#define MARS_MHNewImagePar
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+#ifndef ROOT_TH1
+#include <TH1.h>
+#endif
+
+class MHillas;
+
+class MHNewImagePar : public MH
+{
+private:
+    TH1F fHistLeakage1;  //
+    TH1F fHistLeakage2;  //
+
+    TH1F fHistUsedPix;   // Number of used pixels
+    TH1F fHistCorePix;   // Number of core pixels
+
+    TH1F fHistUsedArea;  // Area of used pixels
+    TH1F fHistCoreArea;  // Area of core pixels
+
+    TH1F fHistConc;      // [ratio] concentration ratio: sum of the two highest pixels / fSize
+    TH1F fHistConc1;     // [ratio] concentration ratio: sum of the highest pixel / fSize
+
+public:
+    MHNewImagePar(const char *name=NULL, const char *title=NULL);
+
+    Bool_t SetupFill(const MParList *plist);
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+
+    TH1 *GetHistByName(const TString name);
+
+    TH1F &GetHistLeakage1()  { return fHistLeakage1; }
+    TH1F &GetHistLeakage2()  { return fHistLeakage2; }
+
+    TH1F &GetHistUsedPix()   { return fHistUsedPix; }
+    TH1F &GetHistCorePix()   { return fHistCorePix; }
+
+    TH1F &GetHistUsedArea()  { return fHistUsedArea; }
+    TH1F &GetHistCoreArea()  { return fHistCoreArea; }
+
+    TH1F &GetHistConc()      { return fHistConc; }
+    TH1F &GetHistConc1()     { return fHistConc1; }
+
+    void Draw(Option_t *opt=NULL);
+
+    ClassDef(MHNewImagePar, 1) // Histograms of new image parameters
+};
+
+#endif
+
+
Index: /tags/Mars_V0-8-5/Mars/mimage/MHillas.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mimage/MHillas.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mimage/MHillas.cc	(revision 9661)
@@ -0,0 +1,342 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz    12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!   Author(s): Harald Kornmayer 1/2001
+!   Author(s): Rudolf Bock     10/2001 <mailto:Rudolf.Bock@cern.ch>
+!   Author(s): Wolfgang Wittek  6/2002 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHillas
+//
+// Storage Container for image parameters
+//
+//    basic image parameters
+//
+// Version 1:
+// ----------
+// fLength   [mm]       major axis of ellipse
+// fWidth    [mm]       minor axis
+// fDelta    [rad]      angle of major axis with x-axis
+//                      by definition the major axis is pointing into
+//                      the hemisphere x>0, thus -pi/2 < delta < pi/2
+// fSize     [#CerPhot] total sum of pixels
+// fMeanX    [mm]       x of center of ellipse
+// fMeanY    [mm]       y of center of ellipse
+//
+// Version 2:
+// ----------
+// fNumCorePixels  number of pixels called core
+// fNumUsedPixels  number of pixels which survived the cleaning
+//
+// Version 3:
+// ----------
+// fNumCorePixels  moved to MNewImagePar
+// fNumUsedPixels  moved to MNewImagePar
+// fCosDelta       added
+// fSinDelte       added
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MHillas.h"
+
+#include <fstream>
+
+#include <TArrayF.h>
+#include <TEllipse.h>
+#include <TVector2.h>
+
+#include "MGeomPix.h"
+#include "MGeomCam.h"
+
+#include "MCerPhotPix.h"
+#include "MCerPhotEvt.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHillas);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MHillas::MHillas(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MHillas";
+    fTitle = title ? title : "Storage container for image parameters of one event";
+
+    Reset();
+}
+
+// --------------------------------------------------------------------------
+//
+// Initializes the values with defaults. For the default values see the
+// source code.
+//
+void MHillas::Reset()
+{
+    fLength = -1;
+    fWidth  = -1;
+    fDelta  =  0;
+
+    fSize   = -1;
+    fMeanX  =  0;
+    fMeanY  =  0;
+}
+
+// --------------------------------------------------------------------------
+//
+//  return the mean position as TVector2(meanx, meany)
+//
+TVector2 MHillas::GetMean() const
+{
+    return TVector2(fMeanX, fMeanY);
+}
+
+// --------------------------------------------------------------------------
+//
+// Print the hillas Parameters to *fLog
+//
+void MHillas::Print(Option_t *) const
+{
+    Double_t atg = atan2(fMeanY, fMeanX)*kRad2Deg;
+
+    if (atg<0)
+        atg += 180;
+
+    *fLog << all;
+    *fLog << "Basic Image Parameters (" << GetName() << ")" << endl;
+    *fLog << " - Length         [mm]  = " << fLength << endl;
+    *fLog << " - Width          [mm]  = " << fWidth  << endl;
+    *fLog << " - Delta          [deg] = " << fDelta*kRad2Deg << endl;
+    *fLog << " - Size           [1]   = " << fSize   << " #CherPhot"   << endl;
+    *fLog << " - Meanx          [mm]  = " << fMeanX  << endl;
+    *fLog << " - Meany          [mm]  = " << fMeanY  << endl;
+    *fLog << " - atg(y/x)       [deg] = " << atg     << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Print the hillas Parameters to *fLog, depending on the geometry in
+// units of deg
+//
+void MHillas::Print(const MGeomCam &geom) const
+{
+    Double_t atg = atan2(fMeanY, fMeanX)*kRad2Deg;
+
+    if (atg<0)
+        atg += 180;
+
+    *fLog << all;
+    *fLog << "Basic Image Parameters (" << GetName() << ")" << endl;
+    *fLog << " - Length         [deg] = " << fLength*geom.GetConvMm2Deg() << endl;
+    *fLog << " - Width          [deg] = " << fWidth *geom.GetConvMm2Deg() << endl;
+    *fLog << " - Delta          [deg] = " << fDelta*kRad2Deg << endl;
+    *fLog << " - Size           [1]   = " << fSize   << " #CherPhot"   << endl;
+    *fLog << " - Meanx          [deg] = " << fMeanX *geom.GetConvMm2Deg() << endl;
+    *fLog << " - Meany          [deg] = " << fMeanY *geom.GetConvMm2Deg() << endl;
+    *fLog << " - atg(y/x)       [deg] = " << atg     << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Paint the ellipse corresponding to the parameters
+//
+void MHillas::Paint(Option_t *opt)
+{
+    if (fLength<0 || fWidth<0)
+        return;
+
+    TEllipse e(fMeanX, fMeanY, fLength, fWidth, 0, 360, fDelta*kRad2Deg+180);
+    e.SetLineWidth(2);
+    e.Paint();
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculate the image parameters from a Cherenkov photon event
+// assuming Cher.photons/pixel and pixel coordinates are given
+// In case you don't call Calc from within an eventloop make sure, that
+// you call the Reset member function before.
+// Returns:
+//   0  no error
+//   1  number of pixels < 3
+//   2  size==0
+//   3  number of used pixel < 3
+//   4  CorrXY == 0
+//
+Int_t MHillas::Calc(const MGeomCam &geom, const MCerPhotEvt &evt)
+{
+    //
+    // sanity check 1
+    //
+    if (evt.GetNumPixels()<3)
+        return 1;
+
+    //
+    // calculate mean value of pixel coordinates and fSize
+    // -----------------------------------------------------
+    //
+    // Because this are only simple sums of roughly 600 values
+    // with an accuracy less than three digits there should not
+    // be any need to use double precision (Double_t) for the
+    // calculation of fMeanX, fMeanY and fSize.
+    //
+    fMeanX = 0;
+    fMeanY = 0;
+    fSize  = 0;
+
+    MCerPhotPix *pix = 0;
+
+    TIter Next(evt);
+    UInt_t numused = 0;
+    while ((pix=(MCerPhotPix*)Next()))
+    {
+        const MGeomPix &gpix = geom[pix->GetPixId()];
+
+        const Float_t nphot = pix->GetNumPhotons();
+
+        fSize  += nphot;		             // [counter]
+        fMeanX += nphot * gpix.GetX();               // [mm]
+        fMeanY += nphot * gpix.GetY();               // [mm]
+
+        numused++;
+    }
+
+    //
+    // sanity check 2
+    //
+    if (fSize==0)
+        return 2;
+
+    fMeanX /= fSize;                                 // [mm]
+    fMeanY /= fSize;                                 // [mm]
+
+    //
+    // sanity check 3
+    //
+    if (numused<3)
+        return 3;
+
+    //
+    // calculate 2nd moments
+    // ---------------------
+    //
+    // To make sure that the more complicated sum is evaluated as
+    // accurate as possible (because it is needed for more
+    // complicated calculations (see below) we calculate it using
+    // double prcision.
+    //
+    Double_t corrxx=0;                               // [m^2]
+    Double_t corrxy=0;                               // [m^2]
+    Double_t corryy=0;                               // [m^2]
+
+    Next.Reset();
+    while ((pix=(MCerPhotPix*)Next()))
+    {
+        const MGeomPix &gpix = geom[pix->GetPixId()];
+
+        const Float_t dx = gpix.GetX() - fMeanX;     // [mm]
+        const Float_t dy = gpix.GetY() - fMeanY;     // [mm]
+
+        const Float_t nphot = pix->GetNumPhotons();  // [#phot]
+
+        corrxx += nphot * dx*dx;                     // [mm^2]
+        corrxy += nphot * dx*dy;                     // [mm^2]
+        corryy += nphot * dy*dy;                     // [mm^2]
+    }
+
+    //
+    // If corrxy=0 (which should happen not very often, because fSize>0)
+    // we cannot calculate Length and Width.
+    // In reallity it is almost impossible to have a distribution of
+    // cerenkov photons in the used pixels which is exactly symmetric
+    // along one of the axis.
+    // It seems to be less than 0.1% of all events.
+    //
+    if (corrxy==0)
+        return 4;
+
+    //
+    // calculate the basic Hillas parameters: orientation and size of axes
+    // -------------------------------------------------------------------
+    //
+    // fDelta is the angle between the major axis of the ellipse and
+    //  the x axis. It is independent of the position of the ellipse
+    //  in the camera it has values between -pi/2 and pi/2 degrees
+    //
+    // Rem: I tested replacing sqrt() by hypot() but they exactly
+    //      consume the same amount of time
+    //
+    const Double_t d0    = corryy - corrxx;
+    const Double_t d1    = corrxy*2;
+    const Double_t d2    = d0 + TMath::Sqrt(d0*d0 + d1*d1);
+    const Double_t tand  = d2 / d1;
+    const Double_t tand2 = tand*tand;
+
+    fDelta = TMath::ATan(tand);
+
+    const Double_t s2 = tand2+1;
+    const Double_t s  = TMath::Sqrt(s2);
+
+    fCosDelta =  1.0/s;   // need these in derived classes
+    fSinDelta = tand/s;   // like MHillasExt
+
+    const Double_t axis1 = (tand2*corryy + d2 + corrxx)/s2/fSize;
+    const Double_t axis2 = (tand2*corrxx - d2 + corryy)/s2/fSize;
+
+    //
+    // fLength^2 is the second moment along the major axis of the ellipse
+    // fWidth^2  is the second moment along the minor axis of the ellipse
+    //
+    // From the algorithm we get: fWidth <= fLength is always true
+    //
+    // very small numbers can get negative by rounding
+    //
+    fLength = axis1<0 ? 0 : TMath::Sqrt(axis1);  // [mm]
+    fWidth  = axis2<0 ? 0 : TMath::Sqrt(axis2);  // [mm]
+
+    SetReadyToSave();
+
+    return 0;
+}
+
+// --------------------------------------------------------------------------
+//
+// This function is ment for special usage, please never try to set
+// values via this function
+//
+void MHillas::Set(const TArrayF &arr)
+{
+    if (arr.GetSize() != 6)
+        return;
+
+    fLength = arr.At(0);  // [mm]        major axis of ellipse
+    fWidth  = arr.At(1);  // [mm]        minor axis of ellipse
+    fDelta  = arr.At(2);  // [rad]       angle of major axis with x-axis
+    fSize   = arr.At(3);  // [#CerPhot]  sum of content of all pixels (number of Cherenkov photons)
+    fMeanX  = arr.At(4);  // [mm]        x-coordinate of center of ellipse
+    fMeanY  = arr.At(5);  // [mm]        y-coordinate of center of ellipse
+}
Index: /tags/Mars_V0-8-5/Mars/mimage/MHillas.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mimage/MHillas.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mimage/MHillas.h	(revision 9661)
@@ -0,0 +1,56 @@
+#ifndef MARS_MHillas
+#define MARS_MHillas
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class TArrayF;
+class TVector2;
+
+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)
+
+public:
+    MHillas(const char *name=NULL, const char *title=NULL);
+
+    void Reset();
+
+    Int_t Calc(const MGeomCam &geom, const MCerPhotEvt &pix);
+
+    void Print(const MGeomCam &geom) const;
+    void Print(Option_t *opt=NULL) const;
+    void Paint(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; }
+
+    TVector2 GetMean() const;
+
+    Float_t GetCosDelta() const { return fCosDelta; }
+    Float_t GetSinDelta() const { return fSinDelta; }
+
+    void Set(const TArrayF &arr);
+
+    ClassDef(MHillas, 3) // Storage Container for Hillas Parameter
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mimage/MHillasCalc.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mimage/MHillasCalc.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mimage/MHillasCalc.cc	(revision 9661)
@@ -0,0 +1,222 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Harald Kornmayer, 1/2001
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MHillasCalc
+//
+//  This is a task to calculate the Hillas parameters from each event
+//
+//  By default MHillas, MHillasExt and MNewImagePar are calculated
+//  with the information from MCerPhotEvt and MGeomCam.
+//
+//  To switch of the calculation you may use:
+//   - Disable(MHillasCalc::kCalcHillas)
+//   - Disable(MHillasCalc::kCalcHillasExt)
+//   - Disable(MHillasCalc::kCalcNewImagePar)
+//
+//  If the calculation of MHillas is switched off a container MHillas
+//  in the parameter list is nevertheless necessary for the calculation
+//  of MHillasExt and MNewImagePar.
+//
+//  The names of the containers to be used can be set with:
+//   - SetNameHillas("NewName")
+//   - SetNameHillasExt("NewName")
+//   - SetNameNewImgPar("NewName")
+//
+//  Input Containers:
+//   MCerPhotEvt
+//   MGeomCam
+//   [MHillas]
+//
+//  Output Containers:
+//   [MHillas]
+//   MHillasExt
+//   MNewImagePar
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MHillasCalc.h"
+
+#include "MParList.h"
+
+#include "MHillas.h"
+#include "MHillasExt.h"
+#include "MNewImagePar.h"
+#include "MConcentration.h"
+#include "MCerPhotEvt.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHillasCalc);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MHillasCalc::MHillasCalc(const char *name, const char *title)
+    : fHilName("MHillas"), fHilExtName("MHillasExt"),
+    fImgParName("MNewImagePar"), fConcName("MConcentration"),
+    fFlags(0xff), fErrors(5)
+{
+    fName  = name  ? name  : "MHillasCalc";
+    fTitle = title ? title : "Calculate Hillas and other image parameters";
+}
+
+// --------------------------------------------------------------------------
+//
+// Check for a MCerPhotEvt object from which the Hillas are calculated.
+// Try to find the Geometry conatiner. Depending on the flags
+// try to find (and maybe create) the containers MHillas, MHillasExt,
+// MNewImagePar, too.
+//
+Int_t MHillasCalc::PreProcess(MParList *pList)
+{
+    // necessary
+    fCerPhotEvt = (MCerPhotEvt*)pList->FindObject(AddSerialNumber("MCerPhotEvt"));
+    if (!fCerPhotEvt)
+    {
+        *fLog << err << "MCerPhotEvt not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    // necessary
+    fGeomCam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
+    if (!fGeomCam)
+    {
+        *fLog << err << "MGeomCam (Camera Geometry) missing in Parameter List... aborting." << endl;
+        return kFALSE;
+    }
+
+    // depend on whether MHillas is an in- or output container
+    if (TestFlag(kCalcHillas))
+        fHillas = (MHillas*)pList->FindCreateObj("MHillas", AddSerialNumber(fHilName));
+    else
+    {
+        fHillas = (MHillas*)pList->FindObject(AddSerialNumber(fHilName), "MHillas");
+        *fLog << err << fHilName << " [MHillas] not found... aborting." << endl;
+    }
+    if (!fHillas)
+        return kFALSE;
+
+    // if enabled
+    if (TestFlag(kCalcHillasExt))
+    {
+        fHillasExt = (MHillasExt*)pList->FindCreateObj("MHillasExt", AddSerialNumber(fHilExtName));
+        if (!fHillasExt)
+            return kFALSE;
+    }
+
+    // if enabled
+    if (TestFlag(kCalcNewImagePar))
+    {
+        fNewImgPar = (MNewImagePar*)pList->FindCreateObj("MNewImagePar", AddSerialNumber(fImgParName));
+        if (!fNewImgPar)
+            return kFALSE;
+    }
+
+     // if enabled
+    if (TestFlag(kCalcConc))
+    {
+        fConc = (MConcentration*)pList->FindCreateObj("MConcentration", fConcName);
+        if (!fConc)
+            return kFALSE;
+    }
+
+   memset(fErrors.GetArray(), 0, sizeof(Char_t)*fErrors.GetSize());
+
+    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
+//
+Int_t MHillasCalc::Process()
+{
+    if (TestFlag(kCalcHillas))
+    {
+        Int_t rc = fHillas->Calc(*fGeomCam, *fCerPhotEvt);
+        if (rc<0 || rc>4)
+        {
+            *fLog << err << dbginf << "MHillas::Calc returned unknown error code!" << endl;
+            return kFALSE;
+        }
+        fErrors[rc]++;
+        if (rc>0)
+            return kCONTINUE;
+    }
+
+    if (TestFlag(kCalcHillasExt))
+        fHillasExt->Calc(*fGeomCam, *fCerPhotEvt, *fHillas);
+
+    if (TestFlag(kCalcNewImagePar))
+        fNewImgPar->Calc(*fGeomCam, *fCerPhotEvt, *fHillas);
+
+    if (TestFlag(kCalcConc))
+        fConc->Calc(*fGeomCam, *fCerPhotEvt, *fHillas);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  This is used to print the output in the PostProcess. Later (having
+//  millions of events) we may want to improve the output.
+//
+void MHillasCalc::PrintSkipped(int i, const char *str) const
+{
+    *fLog << " " << setw(7) << fErrors[i] << " (";
+    *fLog << setw(3) << (int)(100.*fErrors[i]/GetNumExecutions());
+    *fLog << "%) Evts skipped: " << str << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Prints some statistics about the hillas calculation. The percentage
+//  is calculated with respect to the number of executions of this task.
+//
+Int_t MHillasCalc::PostProcess()
+{
+    if (GetNumExecutions()==0)
+        return kTRUE;
+
+    *fLog << inf << endl;
+    *fLog << GetDescriptor() << " execution statistics:" << endl;
+    *fLog << dec << setfill(' ');
+    PrintSkipped(1, "Less than 3 pixels (before cleaning)");
+    PrintSkipped(2, "Calculated Size == 0 (after cleaning)");
+    PrintSkipped(3, "Number of used pixels < 3");
+    PrintSkipped(4, "CorrXY==0");
+    *fLog << " " << (int)fErrors[0] << " (" << (int)(100.*fErrors[0]/GetNumExecutions()) << "%) Evts survived Hillas calculation!" << endl;
+    *fLog << endl;
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mimage/MHillasCalc.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mimage/MHillasCalc.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mimage/MHillasCalc.h	(revision 9661)
@@ -0,0 +1,75 @@
+#ifndef MARS_MHillasCalc
+#define MARS_MHillasCalc
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MHillasCalkc                                                            //
+//                                                                         //
+// Task to calculate Hillas Parameters                                     //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+#ifndef ROOT_TArrayL
+#include <TArrayL.h>
+#endif
+
+class MGeomCam;
+class MCerPhotEvt;
+class MHillas;
+class MHillasExt;
+class MNewImagePar;
+class MConcentration;
+
+class MHillasCalc : public MTask
+{
+    const MGeomCam    *fGeomCam;    //! Camera Geometry used to calculate Hillas
+    const MCerPhotEvt *fCerPhotEvt; //! Cerenkov Photon Event used for calculation
+
+    MHillas      *fHillas;          //! output container to store result
+    MHillasExt   *fHillasExt;       //! output container to store result
+    MNewImagePar *fNewImgPar;       //! output container to store result
+    MConcentration *fConc;          //! output container to store result
+
+    TString      fHilName;          // name of the 'MHillas' container
+    TString      fHilExtName;       // name of the 'MHillasExt' container
+    TString      fImgParName;       // name of the 'MNewImagePar' container
+    TString      fConcName;         // name of the 'MConcentration' container
+
+    Int_t        fFlags;            // Flags defining the behaviour of MHillasCalc
+
+    TArrayL      fErrors;           //! Error counter. Do we have to change to Double?
+
+    void PrintSkipped(int i, const char *str) const;
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
+public:
+    enum CalcCont_t {
+        kCalcHillas      = BIT(0),
+        kCalcHillasExt   = BIT(1),
+        //kCalcHillasSrc   = BIT(2),
+        kCalcNewImagePar = BIT(3),
+        kCalcConc        = BIT(4)
+    };
+
+    MHillasCalc(const char *name=NULL, const char *title=NULL);
+
+    void SetNameHillas(const char *name)    { fHilName = name;    }
+    void SetNameHillasExt(const char *name) { fHilExtName = name; }
+    void SetNameNewImgPar(const char *name) { fImgParName = name; }
+    void SetNameConc(const char *name) { fConcName = name; }
+
+    void SetFlags(Int_t f) { fFlags  =  f; }
+    void Enable(Int_t f)   { fFlags |=  f; }
+    void Disable(Int_t f)  { fFlags &= ~f; }
+    Bool_t TestFlag(CalcCont_t i) const { return fFlags&i; }
+
+    ClassDef(MHillasCalc, 0) // Task to calculate Hillas and other image parameters
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mimage/MHillasExt.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mimage/MHillasExt.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mimage/MHillasExt.cc	(revision 9661)
@@ -0,0 +1,234 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz    12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Rudolf Bock     10/2001 <mailto:Rudolf.Bock@cern.ch>
+!   Author(s): Wolfgang Wittek 06/2002 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHillasExt
+//
+// Storage Container for extended image parameters
+//
+//    extended image parameters
+//
+//
+// Version 1:
+// ----------
+// 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
+//
+// Version 2:
+// ----------
+// fConc     removed
+// fConc1    removed
+//
+// Version 3:
+// ----------
+// fMaxDist  added. Distance between center and most distant used pixel
+//
+//
+// WARNING: Before you can use fAsym, fM3Long and fM3Trans you must
+//          multiply by the sign of MHillasSrc::fCosDeltaAlpha
+//
+////////////////////////////////////////////////////////////////////////////
+/*
+ // fAsymna   d/(d na) of ( sum(x*q^na)/sum(q^na), sum(y*q^na)/sum(q^na) )
+ //           projected onto the major axis
+ // fAsym0    (F-B)/(F+B) along the major axis
+ */
+#include "MHillasExt.h"
+
+#include <fstream>
+#include <TArrayF.h>
+
+#include "MGeomPix.h"
+#include "MGeomCam.h"
+
+#include "MCerPhotPix.h"
+#include "MCerPhotEvt.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MHillas.h"
+
+ClassImp(MHillasExt);
+
+using namespace std;
+
+// -------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MHillasExt::MHillasExt(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MHillasExt";
+    fTitle = title ? title : "Storage container for extended parameter set of one event";
+
+    Reset();
+}
+
+// -------------------------------------------------------------------------
+//
+void MHillasExt::Reset()
+{
+    fAsym    =  0;
+    fM3Long  =  0;
+    fM3Trans =  0;
+
+    fMaxDist =  0;
+}
+
+// -------------------------------------------------------------------------
+//
+// Print contents of MHillasExt to *fLog.
+//
+void MHillasExt::Print(Option_t *) const
+{
+    *fLog << all;
+    *fLog << "Extended Image Parameters (" << GetName() << ")" << endl;
+    *fLog << " - Asymmetry            = " << fAsym    << endl;
+    *fLog << " - 3.Moment Long  [mm]  = " << fM3Long  << endl;
+    *fLog << " - 3.Moment Trans [mm]  = " << fM3Trans << endl;
+    *fLog << " - Max.Dist       [mm]  = " << fMaxDist << endl;
+}
+
+// -------------------------------------------------------------------------
+//
+// Print contents of MHillasExt to *fLog, depending on the geometry in
+// units of deg.
+//
+void MHillasExt::Print(const MGeomCam &geom) const
+{
+    *fLog << all;
+    *fLog << "Extended Image Parameters (" << GetName() << ")" << endl;
+    *fLog << " - Asymmetry            = " << fAsym   *geom.GetConvMm2Deg() << endl;
+    *fLog << " - 3.Moment Long  [deg] = " << fM3Long *geom.GetConvMm2Deg() << endl;
+    *fLog << " - 3.Moment Trans [deg] = " << fM3Trans*geom.GetConvMm2Deg() << endl;
+    *fLog << " - Max.Dist       [deg] = " << fMaxDist*geom.GetConvMm2Deg() << endl;
+}
+
+// -------------------------------------------------------------------------
+//
+// calculation of additional parameters based on the camera geometry
+// and the cerenkov photon event
+//
+Int_t MHillasExt::Calc(const MGeomCam &geom, const MCerPhotEvt &evt, const MHillas &hil)
+{
+    //
+    //   calculate the additional image parameters
+    // --------------------------------------------
+    //
+    //  loop to get third moments along ellipse axes and two max pixels
+    //
+    //  For the moments double precision is used to make sure, that
+    //  the complex matrix multiplication and sum is evaluated correctly.
+    //
+    Double_t m3x = 0;
+    Double_t m3y = 0;
+
+    const UInt_t npixevt = evt.GetNumPixels();
+
+    Int_t maxpixid  = 0;
+    Float_t maxpix  = 0;
+    Float_t maxdist = 0;
+
+    for (UInt_t i=0; i<npixevt; i++)
+    {
+        const MCerPhotPix &pix = evt[i];
+        if (!pix.IsPixelUsed())
+            continue;
+
+        const Int_t pixid = pix.GetPixId();
+
+        const MGeomPix &gpix = geom[pixid];
+        const Double_t dx = gpix.GetX() - hil.GetMeanX();      // [mm]
+        const Double_t dy = gpix.GetY() - hil.GetMeanY();      // [mm]
+
+        Double_t nphot = pix.GetNumPhotons();                  // [1]
+
+        const Double_t dzx =  hil.GetCosDelta()*dx + hil.GetSinDelta()*dy; // [mm]
+        const Double_t dzy = -hil.GetSinDelta()*dx + hil.GetCosDelta()*dy; // [mm]
+
+        const Double_t dist = dx*dx+dy*dy;
+        if (TMath::Abs(dist)>TMath::Abs(maxdist))
+            maxdist = dzx<0 ? -dist : dist;                    // [mm^2]
+
+        m3x += nphot * dzx*dzx*dzx;                            // [mm^3]
+        m3y += nphot * dzy*dzy*dzy;                            // [mm^3]
+
+        //
+        // Now we are working on absolute values of nphot, which
+        // must take pixel size into account
+        //
+        nphot *= geom.GetPixRatio(pixid);
+
+        if (nphot>maxpix)
+        {
+            maxpix   = nphot;                                  // [1]
+            maxpixid = pixid;
+            continue;                                          // [1]
+        }
+    }
+
+    const MGeomPix &maxp = geom[maxpixid];
+
+    fAsym = (hil.GetMeanX()-maxp.GetX())*hil.GetCosDelta() +
+            (hil.GetMeanY()-maxp.GetY())*hil.GetSinDelta();            // [mm]
+
+    //
+    // Third moments along axes get normalized
+    //
+    m3x /= hil.GetSize();
+    m3y /= hil.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]
+
+    const Double_t md = TMath::Sqrt(TMath::Abs(maxdist));
+    fMaxDist = maxdist<0 ? -md : md;                           // [mm]
+
+    SetReadyToSave();
+
+    return 0;
+}
+
+// --------------------------------------------------------------------------
+//
+// This function is ment for special usage, please never try to set
+// values via this function
+//
+void MHillasExt::Set(const TArrayF &arr)
+{
+    if (arr.GetSize() != 4)
+        return;
+
+    fAsym    = arr.At(0);
+    fM3Long  = arr.At(1);
+    fM3Trans = arr.At(2);
+    fMaxDist = arr.At(3);
+}
Index: /tags/Mars_V0-8-5/Mars/mimage/MHillasExt.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mimage/MHillasExt.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mimage/MHillasExt.h	(revision 9661)
@@ -0,0 +1,44 @@
+#ifndef MARS_MHillasExt
+#define MARS_MHillasExt
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class TArrayF;
+
+class MHillas;
+class MGeomCam;
+class MCerPhotEvt;
+
+class MHillasExt : public MParContainer
+{
+private:
+    // for description see MExtHillas.cc
+    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
+
+    Float_t fMaxDist; // Distance between center and most distant used pixel
+
+public:
+    MHillasExt(const char *name=NULL, const char *title=NULL);
+
+    void Reset();
+
+    Float_t GetAsym() const    { return fAsym; }
+    Float_t GetM3Long() const  { return fM3Long; }
+    Float_t GetM3Trans() const { return fM3Trans; }
+
+    Float_t GetMaxDist() const { return fMaxDist; }
+
+    Int_t Calc(const MGeomCam &geom, const MCerPhotEvt &pix, const MHillas &hil);
+
+    void Print(Option_t *opt=NULL) const;
+    void Print(const MGeomCam &geom) const;
+
+    void Set(const TArrayF &arr);
+
+    ClassDef(MHillasExt, 3) // Storage Container for extended Hillas Parameter
+};
+#endif
Index: /tags/Mars_V0-8-5/Mars/mimage/MHillasSrc.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mimage/MHillasSrc.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mimage/MHillasSrc.cc	(revision 9661)
@@ -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>
+!   Author(s): Harald Kornmayer 1/2001
+!   Author(s): Rudolf Bock     10/2001 <mailto:Rudolf.Bock@cern.ch>
+!   Author(s): Wolfgang Wittek 06/2002 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHillasSrc
+//
+// Storage Container for image parameters
+//
+//    source-dependent image parameters
+//
+//
+// Version 1:
+// ----------
+//  fAlpha          angle between major axis and line source-to-center
+//  fDist           distance from source to center of ellipse
+//
+//
+// Version 2:
+// ----------
+//  fHeadTail       added
+//
+//
+// Version 3:
+// ----------
+//  fCosDeltaAlpha  cosine of angle between d and a, where
+//                   - d is the vector from the source position to the
+//                     center of the ellipse
+//                   - a is a vector along the main axis of the ellipse,
+//                     defined with positive x-component
+//
+//
+// Version 4:
+// ----------
+//
+// fHeadTail        removed
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MHillasSrc.h"
+
+#include <fstream>
+#include <TArrayF.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MGeomCam.h"
+#include "MSrcPosCam.h"
+
+ClassImp(MHillasSrc);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MHillasSrc::MHillasSrc(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MHillasSrc";
+    fTitle = title ? title : "Parameters depending in source position";
+}
+
+void MHillasSrc::Reset()
+{
+    fDist          = -1;
+    fAlpha         =  0;
+    fCosDeltaAlpha =  0;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Calculation of source-dependent parameters
+//  In case you don't call Calc from within an eventloop make sure, that
+//  you call the Reset member function before.
+//
+Bool_t MHillasSrc::Calc(const MHillas *hillas)
+{
+    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 = hillas->GetSinDelta();  // [1]
+    const Double_t cd = hillas->GetCosDelta();  // [1]
+
+    //
+    // Distance from source position to center of ellipse.
+    // If the distance is 0 distance, Alpha is not specified.
+    // The calculation has failed and returnes kFALSE.
+    //
+    const Double_t dist = sqrt(sx*sx + sy*sy);  // [mm]
+    if (dist==0)
+        return kFALSE;
+
+    //
+    // Calculate Alpha and Cosda = cos(d,a)
+    // The sign of Cosda will be used for quantities containing 
+    // a head-tail information
+    //
+    // *OLD* const Double_t arg = (sy-tand*sx) / (dist*sqrt(tand*tand+1));
+    // *OLD* fAlpha = asin(arg)*kRad2Deg;
+    //
+    const Double_t arg1 = cd*sy-sd*sx;          // [mm]
+    const Double_t arg2 = cd*sx+sd*sy;          // [mm]
+
+    //
+    // Due to numerical uncertanties in the calculation of the
+    // square root (dist) and arg1 it can happen (in less than 1e-5 cases)
+    // that the absolute value of arg exceeds 1. Because this uncertainty
+    // results in an Delta Alpha which is still less than 1e-3 we don't care
+    // about this uncertainty in general and simply set values which exceed
+    // to 1 saving its sign.
+    //
+    const Double_t arg = arg1/dist;
+    fAlpha = TMath::Abs(arg)>1 ? TMath::Sign(90., arg) : asin(arg)*kRad2Deg;  // [deg]
+
+    fCosDeltaAlpha = arg2/dist;                 // [1]
+    fDist          = dist;                      // [mm]
+
+    SetReadyToSave();
+
+    return kTRUE;
+} 
+
+// --------------------------------------------------------------------------
+//
+// Print contents of MHillasSrc to *fLog
+//
+void MHillasSrc::Print(Option_t *) const
+{
+    *fLog << all;
+    *fLog << "Source dependant Image Parameters (" << GetName() << ")" << endl;
+    *fLog << " - Dist           [mm]  = " << fDist << endl;
+    *fLog << " - Alpha          [deg] = " << fAlpha << endl;
+    *fLog << " - CosDeltaAlpha        = " << fCosDeltaAlpha << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Print contents of MHillasSrc to *fLog depending on the geometry in
+// units of deg.
+//
+void MHillasSrc::Print(const MGeomCam &geom) const
+{
+    *fLog << all;
+    *fLog << "Source dependant Image Parameters (" << GetName() << ")" << endl;
+    *fLog << " - Dist           [deg] = " << fDist*geom.GetConvMm2Deg() << endl;
+    *fLog << " - Alpha          [deg] = " << fAlpha << endl;
+    *fLog << " - CosDeltaAlpha        = " << fCosDeltaAlpha << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// This function is ment for special usage, please never try to set
+// values via this function
+//
+void MHillasSrc::Set(const TArrayF &arr)
+{
+    if (arr.GetSize() != 3)
+        return;
+
+    fAlpha = arr.At(0);         // [deg]  angle of major axis with vector to src
+    fDist  = arr.At(1);         // [mm]   distance between src and center of ellipse
+    fCosDeltaAlpha = arr.At(2); // [1]    cosine of angle between d and a
+}
Index: /tags/Mars_V0-8-5/Mars/mimage/MHillasSrc.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mimage/MHillasSrc.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mimage/MHillasSrc.h	(revision 9661)
@@ -0,0 +1,41 @@
+#ifndef MARS_MHillasSrc
+#define MARS_MHillasSrc
+
+#ifndef MARS_MHillas
+#include "MHillas.h"
+#endif
+
+class MSrcPosCam;
+
+class MHillasSrc : public MParContainer
+{
+private:
+    const MSrcPosCam *fSrcPos; //! Source position in the camere
+
+    Float_t fAlpha;         // [deg]  angle of major axis with vector to src
+    Float_t fDist;          // [mm]   distance between src and center of ellipse
+    Float_t fCosDeltaAlpha; // [1]    cosine of angle between d and a
+
+public:
+    MHillasSrc(const char *name=NULL, const char *title=NULL);
+
+    void SetSrcPos(const MSrcPosCam *pos) { fSrcPos = pos; }
+    const MSrcPosCam *GetSrcPos() const   { return fSrcPos; }
+
+    void Reset();
+
+    Float_t GetAlpha()         const { return fAlpha; }
+    Float_t GetDist()          const { return fDist; }
+    Float_t GetCosDeltaAlpha() const { return fCosDeltaAlpha; }
+
+    void Print(Option_t *opt=NULL) const;
+    void Print(const MGeomCam &geom) const;
+
+    virtual Bool_t Calc(const MHillas *hillas);
+
+    void Set(const TArrayF &arr);
+
+    ClassDef(MHillasSrc, 4) // Container to hold source position dependant parameters
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mimage/MHillasSrcCalc.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mimage/MHillasSrcCalc.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mimage/MHillasSrcCalc.cc	(revision 9661)
@@ -0,0 +1,182 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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
+//
+// FIXME: Merge with MHillasCalc
+//
+//  Input Containers:
+//   MHillas
+//   [MSrcPosCam]
+//
+//  Output Containers:
+//   MHillasSrc
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MHillasSrcCalc.h"
+
+#include <fstream>
+
+#include "MParList.h"
+
+#include "MSrcPosCam.h"
+#include "MHillasSrc.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHillasSrcCalc);
+
+using namespace std;
+
+static const TString gsDefName  = "MHillasSrcCalc";
+static const TString gsDefTitle = "Calculate position dependant image parameters";
+
+// -------------------------------------------------------------------------
+//
+// Default constructor. The first argument is the name of a container
+// containing the source position in the camera plain (MScrPosCam).
+// The default is "MSrcPosCam". hil is the name of a container
+// of type MHillasSrc (or derived) in which the parameters are stored
+// The default is "MHillasSrc"
+//
+MHillasSrcCalc::MHillasSrcCalc(const char *src, const char *hil,
+                               const char *name, const char *title)
+    : fHillas(NULL), fSrcPos(NULL), fHillasSrc(NULL)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+
+    fSrcName     = src;
+    fHillasName  = hil;
+    fHillasInput = "MHillas";
+}
+
+// -------------------------------------------------------------------------
+//
+Int_t MHillasSrcCalc::PreProcess(MParList *pList)
+{
+    fHillas = (MHillas*)pList->FindObject(AddSerialNumber(fHillasInput), "MHillas");
+    if (!fHillas)
+    {
+        *fLog << err << dbginf << "MHillas not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fSrcPos = (MSrcPosCam*)pList->FindObject(AddSerialNumber(fSrcName), "MSrcPosCam");
+    if (!fSrcPos)
+    {
+        *fLog << warn << AddSerialNumber(fSrcName) << " [MSrcPosCam] not found... creating default container." << endl;
+        fSrcPos = (MSrcPosCam*)pList->FindCreateObj("MSrcPosCam", AddSerialNumber(fSrcName));
+        if (!fSrcPos)
+            return kFALSE;
+    }
+
+    fHillasSrc = (MHillasSrc*)pList->FindCreateObj("MHillasSrc", AddSerialNumber(fHillasName));
+    if (!fHillasSrc)
+        return kFALSE;
+
+    fHillasSrc->SetSrcPos(fSrcPos);
+
+    fErrors = 0;
+
+    return kTRUE;
+}
+
+// -------------------------------------------------------------------------
+//
+Int_t MHillasSrcCalc::Process()
+{
+    if (!fHillasSrc->Calc(fHillas))
+    {
+        fErrors++;
+        return kCONTINUE;
+
+    }
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Prints some statistics about the hillas calculation. The percentage
+//  is calculated with respect to the number of executions of this task.
+//
+Int_t MHillasSrcCalc::PostProcess()
+{
+    if (GetNumExecutions()==0)
+        return kTRUE;
+
+    *fLog << inf << endl;
+    *fLog << GetDescriptor() << " execution statistics:" << endl;
+    *fLog << dec << setfill(' ');
+    *fLog << " " << fErrors << " (" << (int)(fErrors*100/GetNumExecutions()) << "%) Evts skipped due to: Dist==0" << endl;
+    *fLog << endl;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
+void MHillasSrcCalc::StreamPrimitive(ofstream &out) const
+{
+    if (fHillas)
+        fHillas->SavePrimitive(out);
+
+    if (fSrcPos)
+        fSrcPos->SavePrimitive(out);
+
+    if (fHillasSrc)
+        fHillasSrc->SavePrimitive(out);
+
+    out << "   MHillasSrcCalc " << GetUniqueName() << "(";
+
+    if (fSrcPos)
+        out << "&" << fSrcPos->GetUniqueName();
+    else
+        out << "\"" << fSrcName << "\"";
+
+    out << ", ";
+
+    if (fHillasSrc)
+        out << "&" << fHillasSrc->GetUniqueName();
+    else
+        out << "\"" << fHillasName << "\"";
+
+    if (fName!=gsDefName || fTitle!=gsDefTitle)
+    {
+        out << ", \"" << fName << "\"";
+        if (fTitle!=gsDefTitle)
+            out << ", \"" << fTitle << "\"";
+    }
+    out << ");" << endl;
+}
Index: /tags/Mars_V0-8-5/Mars/mimage/MHillasSrcCalc.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mimage/MHillasSrcCalc.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mimage/MHillasSrcCalc.h	(revision 9661)
@@ -0,0 +1,41 @@
+#ifndef MARS_MHillasSrcCalc
+#define MARS_MHillasSrcCalc
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MHillas;
+class MHillasSrc;
+class MSrcPosCam;
+
+class MHillasSrcCalc : public MTask
+{
+private:
+    MHillas    *fHillas;     //! Pointer to the source independant hillas parameters
+    MSrcPosCam *fSrcPos;     //! Pointer to the source position
+    MHillasSrc *fHillasSrc;  //! Pointer to the output container for the source dependant parameters
+
+    TString     fSrcName;
+    TString     fHillasName;
+    TString     fHillasInput;
+
+    Int_t       fErrors;
+
+    void StreamPrimitive(ofstream &out) const;
+
+    Int_t PreProcess(MParList *plist);
+    Int_t Process();
+    Int_t PostProcess();
+
+public:
+    MHillasSrcCalc(const char *src="MSrcPosCam", const char *hil="MHillasSrc",
+                   const char *name=NULL, const char *title=NULL);
+
+    void SetInput(TString hilname) { fHillasInput = hilname; }
+
+    ClassDef(MHillasSrcCalc, 1) // task to calculate the source position depandant hillas parameters
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mimage/MImgCleanStd.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mimage/MImgCleanStd.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mimage/MImgCleanStd.cc	(revision 9661)
@@ -0,0 +1,720 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Harald Kornmayer, 1/2001
+!   Author(s): Nadia Tonello, 4/2003 <mailto:tonello@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MImgCleanStd
+//
+// The Image Cleaning task selects the pixels you use for the Hillas
+// parameters calculation.
+//
+// There are two methods to make the selection: the standard one, as done
+// in the analysis of CT1 data, and the democratic one, as suggested by
+// W.Wittek. The number of photo-electrons of a pixel is compared with the
+// pedestal RMS of the pixel itself (standard method) or with the average
+// RMS of the inner pixels (democratic method).
+// In both cases, the possibility to have a camera with pixels of
+// different area is taken into account.
+// The too noisy pixels can be recognized and eventally switched off
+// (Unmap: set blind pixels to UNUSED) separately, using the
+// MBlindPixelCalc Class. In the MBlindPixelCalc class there is also the
+// function to replace the value of the noisy pixels with the interpolation
+// of the content of the neighbors (SetUseInterpolation).
+//
+// Example:
+// ...
+// MBlindPixelCalc blind;
+// blind.SetUseInterpolation();
+// blind.SetUseBlindPixels();
+//
+// MImgCleanStd clean;
+// ...
+// tlist.AddToList(&blind);
+// tlist.AddToList(&clean);
+//
+// Look at the MBlindPixelCalc Class for more details.
+//
+// Starting point: default values ----------------------------------------
+//
+// When an event is read, before the image cleaning, all the pixels that
+// are in MCerPhotEvt are set as USED and NOT CORE. All the pixels belong
+// to RING number 1 (like USED pixels).
+// Look at MCerPhotPix.h to see how these informations of the pixel are
+// stored.
+// The default  cleaning METHOD is the STANDARD one and the number of the
+// rings around the CORE pixel it analyzes is 1. Look at the Constructor
+// of the class in MImgCleanStd.cc to see (or change) the default values.
+//
+// Example: To modify this setting, use the member functions
+// SetMethod(MImgCleanStd::kDemocratic) and SetCleanRings(UShort_t n).
+//
+// MImgCleanStd:CleanStep1 -----------------------------------------------
+//
+// The first step of cleaning defines the CORE pixels. The CORE pixels are
+// the ones which contain the informations about the core of the electro-
+// magnetic shower.
+// The ratio  (A_0/A_i) is calculated from fCam->GetPixRatio(i). A_0 is
+// the area of the central pixel of the camera, A_i is the area of the
+// examined pixel. In this way, if we have a MAGIC-like camera, with the
+// outer pixels bigger than the inner ones, the level of cleaning in the
+// two different regions is weighted.
+// This avoids problems of deformations of the shower images.
+// The signal S_i and the pedestal RMS Prms_i of the pixel are called from
+// the object MCerPhotPix.
+// If (default method = kStandard)
+//Begin_Html
+//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="images/MImgCleanStd-f1.png">
+//End_Html
+// the pixel is set as CORE pixel. L_1 (n=1) is called "first level of
+// cleaning" (default: fCleanLvl1 = 3).
+// All the other pixels are set as UNUSED and belong to RING 0.
+// After this point, only the CORE pixels are set as USED, with RING
+// number 1.
+//
+// MImgCleanStd:CleanStep2 ----------------------------------------------
+//
+// The second step of cleaning looks at the isolated CORE pixels and sets
+// them to UNUSED. An isolated pixel is a pixel without CORE neighbors.
+// At the end of this point, we have set as USED only CORE pixels with at
+// least one CORE neighbor.
+//
+// MImgCleanStd:CleanStep3  ----------------------------------------------
+//
+// The third step of cleaning looks at all the pixels (USED or UNUSED) that
+// surround the USED pixels.
+// If the content of the analyzed pixel survives at the second level of
+// cleaning, i.e. if
+//Begin_Html
+//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="images/MImgCleanStd-f1.png">
+//End_Html
+// the pixel is set as USED. L_2 (n=2) is called "second level of cleaning"
+// (default:fCleanLvl2 = 2.5).
+//
+// When the number of RINGS to analyze is 1 (default value), only the
+// pixels that have a neighbor CORE pixel are analyzed.
+//
+// There is the option to decide the number of times you want to repeat
+// this procedure (number of RINGS analyzed around the core pixels = n).
+// Every time the level of cleaning is the same (fCleanLvl2) and the pixel
+// will belong to ring r+1, 1 < r < n+1. This is described in
+// MImgCleanStd:CleanStep4 .
+//
+// Dictionary and member functions ---------------------------------------
+//
+// Here there is the detailed description of the member functions and of
+// the terms commonly used in the class.
+//
+//
+// STANDARD CLEANING:
+// =================
+// This is the method used for the CT1 data analysis. It is the default
+// method of the class.
+// The number of photo-electrons of a pixel (S_i) is compared to the
+// pedestal RMS of the pixel itself (Prms_i). To have the comparison to
+// the same photon density for all the pixels, taking into account they
+// can have different areas, we have to keep in mind that the number of
+// photons that hit each pixel, goes linearly with the area of the pixel.
+// The fluctuations of the LONS are proportional to sqrt(A_i), so when we
+// compare S_i with Prms_i, only a factor  sqrt(A_0/A_i) is missing to
+// have the same (N.photons/Area) threshold for all the pixels.
+//
+//              !!WARNING: if noise independent from the
+//         pixel size (example: electronic noise) is introduced,
+//         then the noise fluctuations are no longer proportional
+//         to sqrt(A_i), and then the cut value (for a camera with
+//         pixels of different sizes) resulting from the above
+//         procedure  would not be proportional to pixel size as we 
+//         intend. In that case, democratic cleaning is preferred.
+//
+// If
+//Begin_Html
+//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="images/MImgCleanStd-f1.png">
+//End_Html
+// the pixel survives the cleaning and it is set as CORE (when L_n is the
+// first level of cleaning, fCleanLvl1) or USED (when L_n is the second
+// level of cleaning, fCleanLvl2).
+//
+// Example:
+//
+// MImgCleanStd clean;
+// //creates a default Cleaning object, with default setting
+// ...
+// tlist.AddToList(&clean);
+// // add the image cleaning to the main task list
+//
+//
+// DEMOCRATIC CLEANING:
+// ===================
+// You use this cleaning method when you want to compare the number of
+// photo-electons of each pixel with the average pedestal RMS of the
+// inner pixels (for the MAGIC camera they are the smaller ones):
+//Begin_Html
+//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="images/MImgCleanStd-f2.png">
+//End_Html
+// In this case, the simple ratio (A_0/A_i) is used to weight the level of
+// cleaning, because both the inner and the outer pixels (that in MAGIC
+// have a different area) are compared to the same pedestal RMS, coming
+// from the inner pixels.
+//
+// Make sure that you used a class calculating the MPedPhotCam which also
+// updated the contents of the mean values (Recalc) correctly.
+//
+//
+// Member Function:  SetMethod()
+// ============================
+// When you call the MImgCleanStd task, the default method is kStandard.
+//
+// If you want to switch to the kDemocratic method you have to
+// call this member function.
+//
+// Example:
+//
+// MImgCleanStd clean;
+// //creates a default Cleaning object, with default setting
+//
+// clean.SetMethod(MImgCleanStd::kDemocratic);
+// //now the method of cleaning is changed to Democratic
+//
+//
+// FIRST AND SECOND CLEANING LEVEL
+// ===============================
+// When you call the MImgCleanStd task, the default cleaning levels are
+// fCleanLvl1 = 3, fCleanLvl2 = 2.5. You can change them easily when you
+// create the MImgCleanStd object.
+//
+// Example:
+//
+// MImgCleanStd clean(Float_t lvl1,Float_t lvl2);
+// //creates a default cleaning object, but the cleaning levels are now
+// //lvl1 and lvl2.
+//
+// RING NUMBER
+// ===========
+// The standard cleaning procedure is such that it looks for the
+// informations of the boundary part of the shower only on the first
+// neighbors of the CORE pixels.
+// There is the possibility now to look not only at the firs neighbors
+// (first ring),but also further away, around the CORE pixels. All the new
+// pixels you can find with this method, are tested with the second level
+// of cleaning and have to have at least an USED neighbor.
+//
+// They will be also set as USED and will be taken into account during the
+// calculation of the image parameters.
+// The only way to distinguish them from the other USED pixels, is the
+// Ring number, that is bigger than 1.
+//
+// Example: You can decide how many rings you want to analyze using:
+//
+// MImgCleanStd clean;
+// //creates a default cleaning object (default number of rings =1)
+// clean.SetCleanRings(UShort_t r);
+// //now it looks r times around the CORE pixels to find new pixels with
+// //signal.
+//
+//
+//  Input Containers:
+//   MGeomCam
+//   MPedPhotCam
+//   MCerPhotEvt
+//
+//  Output Containers:
+//   MCerPhotEvt
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MImgCleanStd.h"
+
+#include <stdlib.h>       // atof					  
+#include <fstream>        // ofstream, SavePrimitive
+
+#include <TGFrame.h>      // TGFrame
+#include <TGLabel.h>      // TGLabel
+#include <TGTextEntry.h>  // TGTextEntry
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MCameraData.h"
+
+#include "MGeomPix.h"
+#include "MGeomCam.h"
+
+#include "MCerPhotPix.h"
+#include "MCerPhotEvt.h"
+
+#include "MGGroupFrame.h" // MGGroupFrame
+
+ClassImp(MImgCleanStd);
+
+using namespace std;
+
+enum {
+    kImgCleanLvl1,
+    kImgCleanLvl2
+};
+
+static const TString gsDefName  = "MImgCleanStd";
+static const TString gsDefTitle = "Task to perform image cleaning";
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. Here you can specify the cleaning method and levels. 
+// If you don't specify them the 'common standard' values 3.0 and 2.5 (sigma
+// above mean) are used.
+// Here you can also specify how many rings around the core pixels you want 
+// to analyze (with the fixed lvl2). The default value for "rings" is 1.
+//
+MImgCleanStd::MImgCleanStd(const Float_t lvl1, const Float_t lvl2,
+                           const char *name, const char *title)
+    : fCleaningMethod(kStandard), fCleanLvl1(lvl1),
+    fCleanLvl2(lvl2), fCleanRings(1)
+
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+
+    Print();
+}
+
+// --------------------------------------------------------------------------
+//
+// The first step of cleaning defines the CORE pixels. All the other pixels
+// are set as UNUSED and belong to RING 0.
+// After this point, only the CORE pixels are set as USED, with RING
+// number 1.
+//
+//  NT 28/04/2003: now the option to use the standard method or the
+//  democratic method is implemented:
+//
+//  kStandard:   This method looks for all pixels with an entry (photons)
+//               that is three times bigger than the noise of the pixel
+//               (default: 3 sigma, clean level 1)
+//
+//  kDemocratic: this method looks for all pixels with an entry (photons)
+//               that is n times bigger than the noise of the mean of the
+//               inner pixels (default: 3 sigmabar, clean level 1)
+//
+//
+void MImgCleanStd::CleanStep1()
+{
+    const TArrayD &data = fData->GetData();
+
+    //
+    // check the number of all pixels against the noise level and
+    // set them to 'unused' state if necessary
+    //
+    MCerPhotPix *pix;
+
+    // Loop over all pixels
+    MCerPhotEvtIter Next(fEvt, kFALSE);
+    while ((pix=static_cast<MCerPhotPix*>(Next())))
+        if (!pix->IsPixelUnmapped() && data[pix->GetPixId()] <= fCleanLvl1)
+            pix->SetPixelUnused();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Check if the survived pixel have a neighbor, that also
+//  survived, otherwise set pixel to unused (removes pixels without
+//  neighbors).
+//
+void MImgCleanStd::CleanStep2()
+{
+    MCerPhotPix *pix;
+
+    // Loop over used pixels only
+    TIter Next(*fEvt);
+
+    while ((pix=static_cast<MCerPhotPix*>(Next())))
+    {
+        // get pixel id of this entry
+        const Int_t idx = pix->GetPixId();
+ 
+        // check for 'used' neighbors of this pixel
+        const MGeomPix &gpix  = (*fCam)[idx];
+        const Int_t     nnmax = gpix.GetNumNeighbors();
+
+        Bool_t hasNeighbor = kFALSE;
+
+	//loop on the neighbors to check if they are used
+        for (Int_t j=0; j<nnmax; j++)
+        {
+            const Int_t idx2 = gpix.GetNeighbor(j);
+
+	    // when you find an used neighbor, break the loop
+            if (fEvt->IsPixelUsed(idx2))
+            {
+                hasNeighbor = kTRUE;
+                break;
+            }
+        }
+
+	if (hasNeighbor == kFALSE)
+            pix->SetPixelUnused();
+    }
+
+    //
+    // now we declare all pixels that survive as CorePixels
+    //
+
+    Next.Reset();
+    while ((pix=static_cast<MCerPhotPix*>(Next())))
+    {
+	if (pix->IsPixelUsed())
+            pix->SetPixelCore();
+    }
+} 
+
+void MImgCleanStd::CleanStep3b(MCerPhotPix &pix)
+{
+    const Int_t idx = 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)[idx];
+    const Int_t nnmax = gpix.GetNumNeighbors();
+
+    for (Int_t j=0; j<nnmax; j++)
+    {
+        const Int_t idx2 = gpix.GetNeighbor(j);
+
+	if (!fEvt->IsPixelCore(idx2))
+            continue;
+
+        pix.SetPixelUsed();
+       	break;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+//   NT: Add option "rings": default value = 1. 
+//   Look n (n>1) times for the boundary pixels around the used pixels.
+//   If a pixel has more than 2.5 (clean level 2.5) sigma,
+//   it is declared as used.
+//
+//   If a value<2 for fCleanRings is used, no CleanStep4 is done.
+//
+void MImgCleanStd::CleanStep4(UShort_t r, MCerPhotPix &pix)
+{
+    //
+    // Skip events that have already a defined status;
+    //
+    if (pix.GetRing() != 0)
+        return;
+
+    //
+    // check if the pixel's next neighbor is a used pixel.
+    // if it is a used pixel set pixel state to: used,
+    // and tell to which ring it belongs to.
+    //
+    const Int_t idx = pix.GetPixId();
+
+    MGeomPix  &gpix  = (*fCam)[idx];
+
+    const Int_t nnmax = gpix.GetNumNeighbors();
+
+    for (Int_t j=0; j<nnmax; j++)
+    {
+        const Int_t idx2 = gpix.GetNeighbor(j);
+
+        MCerPhotPix *npix = fEvt->GetPixById(idx2);
+        if (!npix || !npix->IsPixelUsed() || npix->GetRing()>r-1 ) 
+            continue;
+
+        pix.SetRing(r);
+        break;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+//  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 TArrayD &data = fData->GetData();
+
+    for (UShort_t r=1; r<fCleanRings+1; r++)
+    {
+        MCerPhotPix *pix;
+
+        // Loop over all pixels
+
+        MCerPhotEvtIter NextAll(fEvt, kFALSE);
+        while ((pix=static_cast<MCerPhotPix*>(NextAll())))
+        {
+            //
+	    // if pixel is a core pixel or unmapped, go to the next pixel
+            //
+            if (pix->IsPixelCore() || pix->IsPixelUnmapped())
+                continue;
+
+            if (data[pix->GetPixId()] <= fCleanLvl2)
+                continue;
+
+            if (r==1)
+                CleanStep3b(*pix);
+            else
+                CleanStep4(r, *pix);
+        }
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+//  Check if MEvtHeader exists in the Parameter list already.
+//  if not create one and add them to the list
+//
+Int_t MImgCleanStd::PreProcess (MParList *pList)
+{
+    fCam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
+    if (!fCam)
+    {
+        *fLog << dbginf << "MGeomCam not found (no geometry information available)... aborting." << endl;
+        return kFALSE;
+    }
+
+    fEvt = (MCerPhotEvt*)pList->FindObject(AddSerialNumber("MCerPhotEvt"));
+    if (!fEvt)
+    {
+        *fLog << dbginf << "MCerPhotEvt not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fPed = (MPedPhotCam*)pList->FindObject(AddSerialNumber("MPedPhotCam"));
+    if (!fPed)
+    {
+        *fLog << dbginf << "MPedPhotCam not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fData = (MCameraData*)pList->FindCreateObj(AddSerialNumber("MCameraData"));
+    if (!fData)
+        return kFALSE;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Cleans the image.
+//
+Int_t MImgCleanStd::Process()
+{
+    switch (fCleaningMethod)
+    {
+    case kStandard:
+        fData->CalcCleaningLevel(*fEvt, *fPed, *fCam);
+        break;
+    case kScaled:
+        fData->CalcCleaningLevel2(*fEvt, *fPed, *fCam);
+        break;
+    case kDemocratic:
+        fData->CalcCleaningLevelDemocratic(*fEvt, *fPed, *fCam);
+        break;
+    }
+
+#ifdef DEBUG
+    *fLog << all << "CleanStep 1" << endl;
+#endif
+    CleanStep1();
+
+    // For speed reasons skip the rest of the cleaning if no
+    // action will be taken!
+    if (fCleanLvl1>=fCleanLvl2)
+        return kTRUE;
+
+#ifdef DEBUG
+    *fLog << all << "CleanStep 2" << endl;
+#endif
+    CleanStep2();
+#ifdef DEBUG
+    *fLog << all << "CleanStep 3" << endl;
+#endif
+    CleanStep3();
+#ifdef DEBUG
+    *fLog << all << "Done." << endl;
+#endif
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Print descriptor and cleaning levels.
+//
+void MImgCleanStd::Print(Option_t *o) const
+{
+    *fLog << all << GetDescriptor() << " using ";
+    switch (fCleaningMethod)
+    {
+    case kDemocratic:
+        *fLog << "democratic";
+        break;
+    case kStandard:
+        *fLog << "standard";
+        break;
+    case kScaled:
+        *fLog << "scaled";
+        break;
+    }
+    *fLog << " cleaning initialized with noise level " << fCleanLvl1 << " and " << fCleanLvl2;
+    *fLog << " (CleanRings=" << fCleanRings << ")" << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Create two text entry fields, one for each cleaning level and a
+//  describing text line.
+//
+void MImgCleanStd::CreateGuiElements(MGGroupFrame *f)
+{
+    //
+    // Create a frame for line 3 and 4 to be able
+    // to align entry field and label in one line
+    //
+    TGHorizontalFrame *f1 = new TGHorizontalFrame(f, 0, 0);
+    TGHorizontalFrame *f2 = new TGHorizontalFrame(f, 0, 0);
+    
+    /*
+     * --> use with root >=3.02 <--
+     *
+     
+     TGNumberEntry *fNumEntry1 = new TGNumberEntry(frame, 3.0, 2, M_NENT_LVL1, kNESRealOne, kNEANonNegative);
+     TGNumberEntry *fNumEntry2 = new TGNumberEntry(frame, 2.5, 2, M_NENT_LVL1, kNESRealOne, kNEANonNegative);
+  
+    */
+    TGTextEntry *entry1 = new TGTextEntry(f1, "****", kImgCleanLvl1);
+    TGTextEntry *entry2 = new TGTextEntry(f2, "****", kImgCleanLvl2);
+    
+    // --- doesn't work like expected (until root 3.02?) --- fNumEntry1->SetAlignment(kTextRight);
+    // --- doesn't work like expected (until root 3.02?) --- fNumEntry2->SetAlignment(kTextRight);
+    
+    entry1->SetText("3.0");
+    entry2->SetText("2.5");
+    
+    entry1->Associate(f);
+    entry2->Associate(f);
+    
+    TGLabel *l1 = new TGLabel(f1, "Cleaning Level 1");
+    TGLabel *l2 = new TGLabel(f2, "Cleaning Level 2");
+    
+    l1->SetTextJustify(kTextLeft);
+    l2->SetTextJustify(kTextLeft);
+    
+    //
+    // Align the text of the label centered, left in the row
+    // with a left padding of 10
+    //
+    TGLayoutHints *laylabel = new TGLayoutHints(kLHintsCenterY|kLHintsLeft, 10);
+    TGLayoutHints *layframe = new TGLayoutHints(kLHintsCenterY|kLHintsLeft,  5, 0, 10);
+    
+    //
+    // Add one entry field and the corresponding label to each line
+    //
+    f1->AddFrame(entry1);
+    f2->AddFrame(entry2);
+    
+    f1->AddFrame(l1, laylabel);
+    f2->AddFrame(l2, laylabel);
+    
+    f->AddFrame(f1, layframe);
+    f->AddFrame(f2, layframe);
+    
+    f->AddToList(entry1);
+    f->AddToList(entry2);
+    f->AddToList(l1);
+    f->AddToList(l2);
+    f->AddToList(laylabel);
+    f->AddToList(layframe);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Process the GUI Events comming from the two text entry fields.
+//
+Bool_t MImgCleanStd::ProcessMessage(Int_t msg, Int_t submsg, Long_t param1, Long_t param2)
+{
+    if (msg!=kC_TEXTENTRY || submsg!=kTE_ENTER)
+        return kTRUE;
+
+    TGTextEntry *txt = (TGTextEntry*)FindWidget(param1);
+
+    if (!txt)
+        return kTRUE;
+
+    Float_t lvl = atof(txt->GetText());
+
+    switch (param1)
+    {
+    case kImgCleanLvl1:
+        fCleanLvl1 = lvl;
+        *fLog << "Cleaning level 1 set to " << lvl << " sigma." << endl;
+        return kTRUE;
+
+    case kImgCleanLvl2:
+        fCleanLvl2 = lvl;
+        *fLog << "Cleaning level 2 set to " << lvl << " sigma." << endl;
+        return kTRUE;
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
+void MImgCleanStd::StreamPrimitive(ofstream &out) const
+{
+    out << "   MImgCleanStd " << GetUniqueName() << "(";
+    out << fCleanLvl1 << ", " << fCleanLvl2;
+
+    if (fName!=gsDefName || fTitle!=gsDefTitle)
+    {
+        out << ", \"" << fName << "\"";
+        if (fTitle!=gsDefTitle)
+            out << ", \"" << fTitle << "\"";
+    }
+    out << ");" << endl;
+
+    if (fCleaningMethod!=kDemocratic)
+        return;
+
+    out << "   " << GetUniqueName() << ".SetMethod(MImgCleanStd::kDemocratic);" << endl;
+
+    if (fCleanRings==1)
+        return;
+
+    out << "   " << GetUniqueName() << ".SetCleanRings(" << fCleanRings << ");" << endl;
+}
Index: /tags/Mars_V0-8-5/Mars/mimage/MImgCleanStd.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mimage/MImgCleanStd.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mimage/MImgCleanStd.h	(revision 9661)
@@ -0,0 +1,71 @@
+#ifndef MARS_MImgCleanStd
+#define MARS_MImgCleanStd
+
+#ifndef MARS_MGTask
+#include "MGTask.h"
+#endif
+
+class MGeomCam;
+class MSigmabar;
+class MCerPhotPix;
+class MCerPhotEvt;
+class MPedPhotCam;
+class MCameraData;
+
+class MGGroupFrame;
+
+class MImgCleanStd : public MGTask
+{
+public:
+    typedef enum {
+        kStandard,
+        kScaled,
+        kDemocratic
+    } CleaningMethod_t;
+
+private:
+    const MGeomCam    *fCam;  //!
+          MCerPhotEvt *fEvt;  //!
+          MPedPhotCam *fPed;  //!
+          MCameraData *fData; //!
+
+    CleaningMethod_t fCleaningMethod;
+
+    Float_t fCleanLvl1;
+    Float_t fCleanLvl2;
+
+    UShort_t fCleanRings;
+
+    Float_t fInnerNoise;      //!
+
+    void CreateGuiElements(MGGroupFrame *f);
+    void StreamPrimitive(ofstream &out) const;
+
+    void   CleanStep3b(MCerPhotPix &pix);
+    void   CleanStep4(UShort_t r, MCerPhotPix &pix);
+
+    void  CleanStep1();
+    void  CleanStep2();
+    void  CleanStep3();
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
+public:
+    MImgCleanStd(const Float_t lvl1=3.0, const Float_t lvl2=2.5,
+              const char *name=NULL, const char *title=NULL);
+    void Print(Option_t *o="") const;
+
+    Float_t  GetCleanLvl1() const { return fCleanLvl1; }
+    Float_t  GetCleanLvl2() const { return fCleanLvl2; }
+    UShort_t GetCleanRings() const { return fCleanRings;}
+
+    void SetCleanRings(UShort_t r) { if(r==0) r=1; fCleanRings=r; }
+    void SetMethod(CleaningMethod_t m) { fCleaningMethod = m; }
+
+    Bool_t ProcessMessage(Int_t msg, Int_t submsg, Long_t param1, Long_t param2);
+
+    ClassDef(MImgCleanStd, 2)    // task doing the image cleaning
+}; 
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mimage/MImgCleanTGB.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mimage/MImgCleanTGB.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mimage/MImgCleanTGB.cc	(revision 9661)
@@ -0,0 +1,456 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Harald Kornmayer, 1/2001
+!   Author(s): Nadia Tonello, 4/2003 <mailto:tonello@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MImgCleanTGB
+//
+//
+//  Input Containers:
+//   MGeomCam, MCerPhotEvt, MSigmabar
+//
+//  Output Containers:
+//   MCerPhotEvt
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MImgCleanTGB.h"
+
+#include <stdlib.h>       // atof					  
+#include <fstream>        // ofstream, SavePrimitive
+
+#include <TGFrame.h>      // TGFrame
+#include <TGLabel.h>      // TGLabel
+#include <TArrayC.h>      // TArrayC
+#include <TGTextEntry.h>  // TGTextEntry
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MSigmabar.h"
+
+#include "MGeomPix.h"
+#include "MGeomCam.h"
+
+#include "MCerPhotPix.h"
+#include "MCerPhotEvt.h"
+
+#include "MPedPhotPix.h"
+#include "MPedPhotCam.h"
+
+#include "MGGroupFrame.h" // MGGroupFrame
+
+ClassImp(MImgCleanTGB);
+
+using namespace std;
+
+enum {
+    kImgCleanLvl1,
+    kImgCleanLvl2
+};
+
+static const TString gsDefName  = "MImgCleanTGB";
+static const TString gsDefTitle = "Task to perform image cleaning";
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. Here you can specify the cleaning method and levels. 
+// If you don't specify them the 'common standard' values 3.0 and 2.5 (sigma
+// above mean) are used.
+// Here you can also specify how many rings around the core pixels you want 
+// to analyze (with the fixed lvl2). The default value for "rings" is 1.
+//
+MImgCleanTGB::MImgCleanTGB(const Float_t lvl1, const Float_t lvl2,
+                               const char *name, const char *title)
+    : fSgb(NULL), fCleaningMethod(kStandard), fCleanLvl1(lvl1),
+    fCleanLvl2(lvl2), fCleanRings(1)
+
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+
+    Print();
+}
+
+
+Int_t MImgCleanTGB::CleanStep3b(MCerPhotPix &pix)
+{
+    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();
+
+    Int_t rc = 0;
+
+    for (Int_t j=0; j<nnmax; j++)
+    {
+        const Int_t id2 = gpix.GetNeighbor(j);
+
+	if (fEvt->GetPixById(id2) && fEvt->IsPixelUsed(id2))
+            rc++;
+    }
+    return rc;
+}
+
+// --------------------------------------------------------------------------
+//
+//   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 MImgCleanTGB::CleanStep3(Int_t num1, Int_t num2)
+{
+    const Int_t entries = fEvt->GetNumPixels();
+
+    Int_t *u = new Int_t[entries];
+
+    for (Int_t i=0; i<entries; i++)
+    {
+        //
+        // get pixel as entry il from list
+        //
+        MCerPhotPix &pix = (*fEvt)[i];
+        u[i] = CleanStep3b(pix);
+    }
+
+    for (Int_t i=0; i<entries; i++)
+    {
+        MCerPhotPix &pix = (*fEvt)[i];
+        if (u[i]<num1)
+            pix.SetPixelUnused();
+        if (u[i]>num2)
+            pix.SetPixelUsed();
+    }
+
+    delete u;
+}
+
+void MImgCleanTGB::CleanStep3(Byte_t *nb, Int_t num1, Int_t num2)
+{
+    const Int_t entries = fEvt->GetNumPixels();
+
+    for (Int_t i=0; i<entries; i++)
+    {
+        MCerPhotPix &pix = (*fEvt)[i];
+
+        const Int_t idx = pix.GetPixId();
+
+        if (nb[idx]<num1 && pix.IsPixelUsed())
+        {
+            const MGeomPix &gpix = (*fCam)[idx];
+            const Int_t nnmax = gpix.GetNumNeighbors();
+            for (Int_t j=0; j<nnmax; j++)
+                nb[gpix.GetNeighbor(j)]--;
+
+            pix.SetPixelUnused();
+        }
+    }
+
+    for (Int_t i=0; i<entries; i++)
+    {
+        MCerPhotPix &pix = (*fEvt)[i];
+
+        const Int_t idx = pix.GetPixId();
+        if (nb[idx]>num2 && !pix.IsPixelUsed())
+        {
+            const MGeomPix &gpix = (*fCam)[idx];
+            const Int_t nnmax = gpix.GetNumNeighbors();
+            for (Int_t j=0; j<nnmax; j++)
+                nb[gpix.GetNeighbor(j)]++;
+
+            pix.SetPixelUsed();
+        }
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+//  Check if MEvtHeader exists in the Parameter list already.
+//  if not create one and add them to the list
+//
+Int_t MImgCleanTGB::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;
+    }
+
+    if (fCleaningMethod == kDemocratic)
+    {
+        fSgb = (MSigmabar*)pList->FindObject("MSigmabar");
+        if (!fSgb)
+        {
+            *fLog << dbginf << "MSigmabar not found... aborting." << endl;
+            return kFALSE;
+        }
+    }
+    else
+    {
+        fPed = (MPedPhotCam*)pList->FindObject("MPedPhotCam");
+        if (!fPed)
+        {
+            *fLog << dbginf << "MPedPhotCam not found... aborting." << endl;
+            return kFALSE;
+        }
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Cleans the image.
+//
+Int_t MImgCleanTGB::Process()
+{
+    const Int_t entries = fEvt->GetNumPixels();
+
+    Double_t sum = 0;
+    Double_t sq  = 0;
+    Double_t w   = 0;
+    Double_t w2  = 0;
+    for (Int_t i=0; i<entries; i++)
+    {
+        //
+        // get pixel as entry il from list
+        //
+        MCerPhotPix &pix = (*fEvt)[i];
+
+        const Int_t    idx        = pix.GetPixId();
+        const Double_t entry      = pix.GetNumPhotons();
+        const Double_t factor     = fCam->GetPixRatio(idx);
+        const Double_t factorsqrt = fCam->GetPixRatioSqrt(idx);
+        const Float_t  noise      = (*fPed)[idx].GetRms();
+
+        if (entry * factorsqrt <= fCleanLvl2 * noise)
+        {
+            sum += entry*factor;
+            sq  += entry*entry*factor*factor;
+            w   += factor;
+            w2  += factor*factor;
+        }
+    }
+
+    Double_t mean = sum/w;
+    Double_t sdev = sqrt(sq/w2 - mean*mean);
+
+    TArrayC n(fCam->GetNumPixels());
+    Byte_t *nb = (Byte_t*)n.GetArray();
+    //Byte_t *nb = new Byte_t[1000];
+    //memset(nb, 0, 577);
+
+    for (Int_t i=0; i<entries; i++)
+    {
+        //
+        // get pixel as entry il from list
+        //
+        MCerPhotPix &pix = (*fEvt)[i];
+        const Int_t idx = pix.GetPixId();
+
+        const Double_t entry  = pix.GetNumPhotons();
+        const Double_t factor = fCam->GetPixRatio(idx);
+
+        if (entry*factor > fCleanLvl1*sdev)
+        {
+            pix.SetPixelUsed();
+
+            const MGeomPix &gpix = (*fCam)[idx];
+            const Int_t nnmax = gpix.GetNumNeighbors();
+            for (Int_t j=0; j<nnmax; j++)
+                nb[gpix.GetNeighbor(j)]++;
+        }
+        else
+            pix.SetPixelUnused();
+    }
+
+    CleanStep3(nb, 2, 3);
+    //CleanStep3(nb, 2, 3);
+    //CleanStep3(nb, 2, 3);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Print descriptor and cleaning levels.
+//
+void MImgCleanTGB::Print(Option_t *o) const
+{
+    *fLog << all << GetDescriptor() << " using ";
+    switch (fCleaningMethod)
+    {
+    case kDemocratic:
+        *fLog << "democratic";
+        break;
+    case kStandard:
+        *fLog << "standard";
+        break;
+    }
+    *fLog << " cleaning initialized with noise level " << fCleanLvl1 << " and " << fCleanLvl2;
+    *fLog << " (CleanRings=" << fCleanRings << ")" << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Create two text entry fields, one for each cleaning level and a
+//  describing text line.
+//
+void MImgCleanTGB::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 MImgCleanTGB::ProcessMessage(Int_t msg, Int_t submsg, Long_t param1, Long_t param2)
+{
+    if (msg!=kC_TEXTENTRY || submsg!=kTE_ENTER)
+        return kTRUE;
+
+    TGTextEntry *txt = (TGTextEntry*)FindWidget(param1);
+
+    if (!txt)
+        return kTRUE;
+
+    Float_t lvl = atof(txt->GetText());
+
+    switch (param1)
+    {
+    case kImgCleanLvl1:
+        fCleanLvl1 = lvl;
+        *fLog << "Cleaning level 1 set to " << lvl << " sigma." << endl;
+        return kTRUE;
+
+    case kImgCleanLvl2:
+        fCleanLvl2 = lvl;
+        *fLog << "Cleaning level 2 set to " << lvl << " sigma." << endl;
+        return kTRUE;
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
+void MImgCleanTGB::StreamPrimitive(ofstream &out) const
+{
+    out << "   MImgCleanTGB " << GetUniqueName() << "(";
+    out << fCleanLvl1 << ", " << fCleanLvl2;
+
+    if (fName!=gsDefName || fTitle!=gsDefTitle)
+    {
+        out << ", \"" << fName << "\"";
+        if (fTitle!=gsDefTitle)
+            out << ", \"" << fTitle << "\"";
+    }
+    out << ");" << endl;
+
+    if (fCleaningMethod!=kDemocratic)
+        return;
+
+    out << "   " << GetUniqueName() << ".SetMethod(MImgCleanTGB::kDemocratic);" << endl;
+
+    if (fCleanRings==1)
+        return;
+
+    out << "   " << GetUniqueName() << ".SetCleanRings(" << fCleanRings << ");" << endl;
+}
Index: /tags/Mars_V0-8-5/Mars/mimage/MImgCleanTGB.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mimage/MImgCleanTGB.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mimage/MImgCleanTGB.h	(revision 9661)
@@ -0,0 +1,66 @@
+#ifndef MARS_MImgCleanTGB
+#define MARS_MImgCleanTGB
+
+#ifndef MARS_MGTask
+#include "MGTask.h"
+#endif
+
+class MGeomCam;
+class MSigmabar;
+class MCerPhotPix;
+class MCerPhotEvt;
+class MPedPhotCam;
+
+class MGGroupFrame;
+
+class MImgCleanTGB : public MGTask
+{
+public:
+    typedef enum {
+        kStandard,
+        kDemocratic
+    } CleaningMethod_t;
+
+private:
+    const MGeomCam    *fCam;  //!
+          MCerPhotEvt *fEvt;  //!
+          MSigmabar   *fSgb;  //!
+          MPedPhotCam *fPed;  //!
+
+    CleaningMethod_t fCleaningMethod;
+
+    Float_t fCleanLvl1;
+    Float_t fCleanLvl2;
+
+    UShort_t fCleanRings;
+
+    Float_t fInnerNoise;      //!
+
+    void CreateGuiElements(MGGroupFrame *f);
+    void StreamPrimitive(ofstream &out) const;
+
+    Int_t CleanStep3b(MCerPhotPix &pix);
+    void  CleanStep3(Int_t num1, Int_t num2);
+    void  CleanStep3(Byte_t *nb, Int_t num1, Int_t num2);
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
+public:
+    MImgCleanTGB(const Float_t lvl1=3.0, const Float_t lvl2=2.5,
+              const char *name=NULL, const char *title=NULL);
+    void Print(Option_t *o="") const;
+
+    Float_t  GetCleanLvl1() const { return fCleanLvl1; }
+    Float_t  GetCleanLvl2() const { return fCleanLvl2; }
+    UShort_t GetCleanRings() const { return fCleanRings;}
+
+    void SetCleanRings(UShort_t r) { if(r==0) r=1; fCleanRings=r; }
+    void SetMethod(CleaningMethod_t m) { fCleaningMethod = m; }
+
+    Bool_t ProcessMessage(Int_t msg, Int_t submsg, Long_t param1, Long_t param2);
+
+    ClassDef(MImgCleanTGB, 2)    // task doing the image cleaning
+}; 
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mimage/MNewImagePar.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mimage/MNewImagePar.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mimage/MNewImagePar.cc	(revision 9661)
@@ -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): Wolfgang Wittek 03/2003 <mailto:wittek@mppmu.mpg.de>
+!   Author(s): Thomas Bretz            <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MNewImagePar
+//
+// Storage Container for new image parameters
+//
+//    Float_t fLeakage1;             // (photons in most outer ring of pixels) over fSize
+//    Float_t fLeakage2;             // (photons in the 2 outer rings of pixels) over fSize
+//    Float_t fInnerLeakage1;        // (photons in most outer rings of inner pixels) over fInnerSize
+//    Float_t fInnerLeakage2;        // (photons in the 2 outer rings of inner pixels) over fInnerSize
+//    Float_t fInnerSize;            //
+//
+//    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 fUsedArea;             // Area of pixels which survived the image cleaning
+//    Float_t fCoreArea;             // Area of core pixels
+//    Short_t fNumUsedPixels;        // Number of pixels which survived the image cleaning
+//    Short_t fNumCorePixels;        // number of core pixels
+//    Short_t fNumHGSaturatedPixels; // number of pixels with saturating hi-gains
+//    Short_t fNumSaturatedPixels;   // number of pixels with saturating lo-gains
+//
+// Version 2:
+// ----------
+//  - added fNumSaturatedPixels
+// 
+// Version 3:
+// ----------
+//  - added fNumHGSaturatedPixels
+//  - added fInnerLeakage1
+//  - added fInnerLeakage2
+//  - added fInnerSize
+//  - added fUsedArea
+//  - added fCoreArea
+//
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MNewImagePar.h"
+
+#include <fstream>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MHillas.h"
+
+#include "MGeomCam.h"
+#include "MGeomPix.h"
+
+#include "MCerPhotEvt.h"
+#include "MCerPhotPix.h"
+
+ClassImp(MNewImagePar);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MNewImagePar::MNewImagePar(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MNewImagePar";
+    fTitle = title ? title : "New image parameters";
+}
+
+// --------------------------------------------------------------------------
+//
+void MNewImagePar::Reset()
+{
+    fLeakage1 = -1;
+    fLeakage2 = -1;
+
+    fInnerLeakage1 = -1;
+    fInnerLeakage2 = -1;
+    fInnerSize = -1;
+
+    fConc  = -1;
+    fConc1 = -1;
+
+    fNumUsedPixels = -1;
+    fNumCorePixels = -1;
+
+    fUsedArea = -1;
+    fCoreArea = -1;
+
+    fNumSaturatedPixels = -1;
+    fNumHGSaturatedPixels = -1;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Calculation of new image parameters
+//
+void MNewImagePar::Calc(const MGeomCam &geom, const MCerPhotEvt &evt,
+                        const MHillas &hillas)
+{
+    fNumUsedPixels = 0;
+    fNumCorePixels = 0;
+
+    fUsedArea = 0;
+    fCoreArea = 0;
+
+    fNumSaturatedPixels = 0;
+    fNumHGSaturatedPixels = 0;
+
+    fInnerSize = 0;
+
+    const UInt_t npixevt = evt.GetNumPixels();
+
+    Double_t edgepix1 = 0;
+    Double_t edgepix2 = 0;
+
+    Double_t edgepixin1 = 0;
+    Double_t edgepixin2 = 0;
+
+    Float_t maxpix1 = 0;                                 // [#phot]
+    Float_t maxpix2 = 0;                                 // [#phot]
+
+    for (UInt_t i=0; i<npixevt; i++)
+    {
+        const MCerPhotPix &pix = evt[i];
+
+        // count saturated pixels
+	if (pix.IsPixelHGSaturated())
+            fNumHGSaturatedPixels++;
+	if (pix.IsPixelSaturated())
+            fNumSaturatedPixels++;
+
+        // skip unused pixels
+        if (!pix.IsPixelUsed())
+            continue;
+
+        // Get geometry of pixel
+        const Int_t pixid = pix.GetPixId();
+        const MGeomPix &gpix = geom[pixid];
+
+        // count used and core pixels
+        if (pix.IsPixelCore())
+        {
+            fNumCorePixels++;
+            fCoreArea += gpix.GetA();
+        }
+
+        // count used pixels
+        fNumUsedPixels++;
+        fUsedArea += gpix.GetA();
+
+        Double_t nphot = pix.GetNumPhotons();
+
+        //
+        // count photons in outer rings of camera
+        //
+        if (gpix.IsInOutermostRing())
+           edgepix1 += nphot;
+        if (gpix.IsInOuterRing())
+           edgepix2 += nphot;
+
+        //
+        // Now we are working on absolute values of nphot, which
+        // must take pixel size into account
+        //
+        nphot *= geom.GetPixRatio(pixid);
+
+	// count inner pixels: To dependent on MAGIC Camera --> FIXME
+
+        if (pixid<397){
+            fInnerSize += nphot;
+            if(pixid>270){
+                edgepixin2 += nphot;
+                if(pixid>330)
+                    edgepixin1 += nphot;
+            }
+        }
+
+	// Compute Concentration 1-2
+        if (nphot>maxpix1)
+        {
+            maxpix2  = maxpix1;
+            maxpix1  = nphot;                            // [1]
+            continue;                                    // [1]
+        }
+
+        if (nphot>maxpix2)
+            maxpix2 = nphot;                             // [1]
+    }
+    
+    fInnerLeakage1 = edgepixin1 / fInnerSize;
+    fInnerLeakage2 = edgepixin2 / fInnerSize;
+    fLeakage1 = edgepix1 / hillas.GetSize();
+    fLeakage2 = edgepix2 / hillas.GetSize();
+
+    fConc  = (maxpix1+maxpix2)/hillas.GetSize();         // [ratio]
+    fConc1 = maxpix1/hillas.GetSize();                   // [ratio]
+
+    SetReadyToSave();
+} 
+
+// --------------------------------------------------------------------------
+//
+void MNewImagePar::Print(Option_t *) const
+{
+    *fLog << all;
+    *fLog << "New Image Parameters (" << GetName() << ")" << endl;
+    *fLog << " - Leakage1       [1]   = " << fLeakage1             << endl;
+    *fLog << " - Leakage2       [1]   = " << fLeakage2             << endl;
+    *fLog << " - InnerLeakage1  [1]   = " << fInnerLeakage1        << endl;
+    *fLog << " - InnerLeakage2  [1]   = " << fInnerLeakage2        << endl;
+    *fLog << " - InnerSize      [#]   = " << fInnerSize            << " CerPhot" << endl;
+    *fLog << " - Conc           [1]   = " << fConc                 << " (ratio)" << endl;
+    *fLog << " - Conc1          [1]   = " << fConc1                << " (ratio)" << endl;
+    *fLog << " - Used Pixels    [#]   = " << fNumUsedPixels        << " Pixels" << endl;
+    *fLog << " - Core Pixels    [#]   = " << fNumCorePixels        << " Pixels" << endl;
+    *fLog << " - Used Area     [mm^2] = " << fUsedArea             << endl;
+    *fLog << " - Core Area     [mm^2] = " << fCoreArea             << endl;
+    *fLog << " - Sat.Pixels/HG  [#]   = " << fNumHGSaturatedPixels << " Pixels" << endl;
+    *fLog << " - Sat.Pixels/LG  [#]   = " << fNumSaturatedPixels   << " Pixels" << endl;
+}
+
+// -------------------------------------------------------------------------
+//
+// Print contents of MNewImagePar to *fLog, depending on the geometry in
+// units of deg.
+//
+void MNewImagePar::Print(const MGeomCam &geom) const
+{
+    *fLog << all;
+    *fLog << "New Image Parameters (" << GetName() << ")" << endl;
+    *fLog << " - Leakage1       [1]   = " << fLeakage1             << endl;
+    *fLog << " - Leakage2       [1]   = " << fLeakage2             << endl;
+    *fLog << " - InnerLeakage1  [1]   = " << fInnerLeakage1        << endl;
+    *fLog << " - InnerLeakage2  [1]   = " << fInnerLeakage2        << endl;
+    *fLog << " - InnerSize      [#]   = " << fInnerSize            << " CerPhot" << endl;
+    *fLog << " - Conc           [1]   = " << fConc                 << " (ratio)" << endl;
+    *fLog << " - Conc1          [1]   = " << fConc1                << " (ratio)" << endl;
+    *fLog << " - Used Pixels    [#]   = " << fNumUsedPixels        << " Pixels" << endl;
+    *fLog << " - Core Pixels    [#]   = " << fNumCorePixels        << " Pixels" << endl;
+    *fLog << " - Used Area    [deg^2] = " << fUsedArea*geom.GetConvMm2Deg()*geom.GetConvMm2Deg() << endl;
+    *fLog << " - Core Area    [deg^2] = " << fCoreArea*geom.GetConvMm2Deg()*geom.GetConvMm2Deg() << endl;
+    *fLog << " - Sat.Pixels/HG  [#]   = " << fNumHGSaturatedPixels << " Pixels" << endl;
+    *fLog << " - Sat.Pixels/LG  [#]   = " << fNumSaturatedPixels   << " Pixels" << endl;
+}
Index: /tags/Mars_V0-8-5/Mars/mimage/MNewImagePar.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mimage/MNewImagePar.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mimage/MNewImagePar.h	(revision 9661)
@@ -0,0 +1,64 @@
+#ifndef MARS_MNewImagePar
+#define MARS_MNewImagePar
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MHillas;
+class MGeomCam;
+class MCerPhotEvt;
+
+class MNewImagePar : public MParContainer
+{
+private:
+    Float_t fLeakage1;             // (photons in most outer ring of pixels) over fSize
+    Float_t fLeakage2;             // (photons in the 2 outer rings of pixels) over fSize
+    Float_t fInnerLeakage1;        // (photons in most outer rings of inner pixels) over fInnerSize
+    Float_t fInnerLeakage2;        // (photons in the 2 outer rings of inner pixels) over fInnerSize
+    Float_t fInnerSize;            //
+
+    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 fUsedArea;             // Area of pixels which survived the image cleaning
+    Float_t fCoreArea;             // Area of core pixels
+    Short_t fNumUsedPixels;        // Number of pixels which survived the image cleaning
+    Short_t fNumCorePixels;        // number of core pixels
+    Short_t fNumHGSaturatedPixels; // number of pixels with saturating hi-gains
+    Short_t fNumSaturatedPixels;   // number of pixels with saturating lo-gains
+
+public:
+    MNewImagePar(const char *name=NULL, const char *title=NULL);
+
+    void Reset();
+
+    Float_t GetLeakage1() const { return fLeakage1; }
+    Float_t GetLeakage2() const { return fLeakage2; }
+
+    Float_t GetInnerLeakage1() const { return fInnerLeakage1; }
+    Float_t GetInnerLeakage2() const { return fInnerLeakage2; }
+    Float_t GetInnerSize()     const { return fInnerSize; }
+
+    Float_t GetConc() const  { return fConc;  }
+    Float_t GetConc1() const { return fConc1; }
+
+    Short_t GetNumUsedPixels() const { return fNumUsedPixels; }
+    Short_t GetNumCorePixels() const { return fNumCorePixels; }
+
+    Float_t GetUsedArea() const { return fUsedArea; }
+    Float_t GetCoreArea() const { return fCoreArea; }
+
+    Short_t GetNumSaturatedPixels() const { return fNumSaturatedPixels; }
+    Short_t GetNumHGSaturatedPixels() const { return fNumHGSaturatedPixels; }
+
+    void Print(Option_t *opt=NULL) const;
+    void Print(const MGeomCam &geom) const;
+
+    void Calc(const MGeomCam &geom, const MCerPhotEvt &evt,
+              const MHillas &hillas);
+
+    ClassDef(MNewImagePar, 3) // Container to hold new image parameters
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mimage/MNewImageParCalc.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mimage/MNewImageParCalc.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mimage/MNewImageParCalc.cc	(revision 9661)
@@ -0,0 +1,146 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Wolfgang Wittek     03/2003 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// MNewImageParCalc
+//
+// Task to calculate the source dependant part of the hillas parameters
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MNewImageParCalc.h"
+
+#include <fstream.h>
+
+#include "MParList.h"
+
+#include "MGeomCam.h"
+#include "MSrcPosCam.h"
+#include "MCerPhotEvt.h"
+#include "MNewImagePar.h"
+#include "MNewImagePar.h"
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MNewImageParCalc);
+
+static const TString gsDefName  = "MNewImageParCalc";
+static const TString gsDefTitle = "Calculate new image parameters";
+
+// -------------------------------------------------------------------------
+//
+// Default constructor. The first argument is the name of a container
+// containing the source position in the camera plain (MScrPosCam).
+// The default is "MSrcPosCam". newpar is the name of a container
+// of type MNewImagePar, in which the parameters are stored.
+// The default is "MNewImagePar"
+//
+//
+MNewImageParCalc::MNewImageParCalc(const char *src, const char *newpar,
+                                   const char *name, const char *title)
+    : fHillas(NULL), fSrcPos(NULL), fNewImagePar(NULL)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+
+    fSrcName     = src;
+    fNewParName  = newpar;
+    fHillasInput = "MHillas";
+}
+
+// -------------------------------------------------------------------------
+//
+Int_t MNewImageParCalc::PreProcess(MParList *pList)
+{
+    fHillas = (MHillas*)pList->FindObject(fHillasInput, "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;
+    }
+
+    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;
+    }
+
+    fNewImagePar = (MNewImagePar*)pList->FindCreateObj("MNewImagePar", fNewParName);
+    if (!fNewImagePar)
+        return kFALSE;
+
+    //fErrors = 0;
+
+    return kTRUE;
+}
+
+// -------------------------------------------------------------------------
+//
+Int_t MNewImageParCalc::Process()
+{
+
+    /*if (!*/fNewImagePar->Calc(*fGeomCam, *fCerPhotEvt, *fHillas);/*)
+    {
+        fErrors++;
+        return kCONTINUE;
+
+    }*/
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Prints some statistics about the hillas calculation. The percentage
+//  is calculated with respect to the number of executions of this task.
+//
+/*
+Bool_t MNewImageParCalc::PostProcess()
+{
+    if (GetNumExecutions()==0)
+        return kTRUE;
+
+    *fLog << inf << endl;
+    *fLog << GetDescriptor() << " execution statistics:" << endl;
+    *fLog << dec << setfill(' ');
+    *fLog << " " << fErrors << " (" << (int)(fErrors*100/GetNumExecutions()) << "%) Evts skipped due to: calculation failed" << endl;
+    *fLog << endl;
+
+    return kTRUE;
+}
+*/
Index: /tags/Mars_V0-8-5/Mars/mimage/MNewImageParCalc.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mimage/MNewImageParCalc.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mimage/MNewImageParCalc.h	(revision 9661)
@@ -0,0 +1,47 @@
+#ifndef MARS_MNewImageParCalc
+#define MARS_MNewImageParCalc
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MHillas;
+class MNewImagePar;
+class MSrcPosCam;
+class MGeomCam;
+class MCerPhotEvt;
+
+class MNewImageParCalc : public MTask
+{
+private:
+    MGeomCam    *fGeomCam;
+    MCerPhotEvt *fCerPhotEvt;
+
+    MHillas      *fHillas;       //! Pointer to the source independent hillas parameters
+    MSrcPosCam   *fSrcPos;       //! Pointer to the source position
+    MNewImagePar *fNewImagePar;  //! Pointer to the output container for the new image parameters
+
+    TString fSrcName;
+    TString fNewParName;
+    TString fHillasInput;
+
+    //Int_t       fErrors;
+
+    Int_t PreProcess(MParList *plist);
+    Int_t Process();
+    //Bool_t PostProcess();
+
+public:
+    MNewImageParCalc(const char *src="MSrcPosCam", const char *newpar="MNewImagePar",
+                     const char *name=NULL,        const char *title=NULL);
+
+    void SetInput(TString hilname) { fHillasInput = hilname; }
+
+    ClassDef(MNewImageParCalc, 0) // task to calculate new image parameters
+};
+
+#endif
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mimage/MStereoCalc.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mimage/MStereoCalc.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mimage/MStereoCalc.cc	(revision 9661)
@@ -0,0 +1,162 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Abelardo Moralejo, 11/2003 <mailto:moralejo@pd.infn.it>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MStereoCalc
+//
+//  This is a task to calculate some shower parameters from the images of
+//  two telescopes in stereo mode. 
+//
+//  Input Containers:
+//   MGeomCam
+//   MHillas
+//   MMcEvt
+//
+//  Output Containers:
+//   MStereoPar
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MStereoCalc.h"
+
+#include "MParList.h"
+
+#include "MHillas.h"
+#include "MMcEvt.hxx"
+#include "MStereoPar.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MStereoCalc);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MStereoCalc::MStereoCalc(const char *name, const char *title)
+    : fStereoParName("MStereoPar")
+{
+    fName  = name  ? name  : "MStereoCalc";
+    fTitle = title ? title : "Calculate shower parameters in stereo mode";
+
+}
+
+// --------------------------------------------------------------------------
+//
+// Check for MMcEvt and MHillas containers.
+// Try to find the Geometry conatiner.
+// Try to find (and maybe create) the container MStereoPar.
+//
+Int_t MStereoCalc::PreProcess(MParList *pList)
+{
+    // necessary
+
+    fmcevt1 = (MMcEvt*)pList->FindObject(AddSerialNumber("MMcEvt",fCT1id));
+    if (!fmcevt1)
+    {
+        *fLog << err << AddSerialNumber("MMcEvt",fCT1id) << " not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    // necessary
+    fmcevt2 = (MMcEvt*)pList->FindObject(AddSerialNumber("MMcEvt",fCT2id));
+    if (!fmcevt2)
+    {
+      *fLog << err << AddSerialNumber("MMcEvt",fCT2id) << " not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    // necessary
+    TString geomname = "MGeomCam;";
+    geomname += fCT1id;
+    fGeomCam1 = (MGeomCam*)pList->FindObject(geomname);
+    if (!fGeomCam1)
+    {
+        *fLog << err << geomname << " (Camera Geometry) missing in Parameter List... aborting." << endl;
+        return kFALSE;
+    }
+
+    // necessary
+    geomname = "MGeomCam;";
+    geomname += fCT2id;
+    fGeomCam2 = (MGeomCam*)pList->FindObject(geomname);
+    if (!fGeomCam2)
+    {
+        *fLog << err << geomname << " (Camera Geometry) missing in Parameter List... aborting." << endl;
+        return kFALSE;
+    }
+
+    // necessary
+    TString hillasname = "MHillas;";
+    hillasname += fCT1id;
+    fHillas1 = (MHillas*)pList->FindObject(hillasname);
+    if (!fHillas1)
+    {
+        *fLog << err << hillasname << " missing in Parameter List... aborting." << endl;
+        return kFALSE;
+    }
+
+    // necessary
+    hillasname = "MHillas;";
+    hillasname += fCT2id;
+    fHillas2 = (MHillas*)pList->FindObject(hillasname);
+    if (!fHillas2)
+    {
+        *fLog << err << hillasname << " missing in Parameter List... aborting." << endl;
+        return kFALSE;
+    }
+
+    fStereoPar = (MStereoPar*)pList->FindCreateObj("MStereoPar");
+    if (!fStereoPar)
+    {
+	*fLog << err << "Could not create MStereoPar... aborting" << endl;
+	return kFALSE;
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Call the Calc procedure of the MStereoPar object, where the 
+// calculations combining the data from the two telescopes are performed.
+//
+Int_t MStereoCalc::Process()
+{
+    fStereoPar->Calc(*fHillas1, *fmcevt1, *fGeomCam1, fCT1x, fCT1y, *fHillas2, *fmcevt2, *fGeomCam2, fCT2x, fCT2y);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Does nothing at the moment.
+//
+Int_t MStereoCalc::PostProcess()
+{
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mimage/MStereoCalc.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mimage/MStereoCalc.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mimage/MStereoCalc.h	(revision 9661)
@@ -0,0 +1,65 @@
+#ifndef MARS_MStereoCalc
+#define MARS_MStereoCalc
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MStereoCalc                                                             //
+//                                                                         //
+// Task to calculate some shower parameters in stereo mode                 //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+#ifndef ROOT_TArrayL
+#include <TArrayL.h>
+#endif
+
+class MGeomCam;
+class MHillas;
+class MMcEvt;
+class MStereoPar;
+
+class MStereoCalc : public MTask
+{
+    const MGeomCam    *fGeomCam1;    //! Camera Geometry CT1
+    const MHillas     *fHillas1;     //! input
+    const MMcEvt      *fmcevt1;      //! input
+
+    const MGeomCam    *fGeomCam2;    //! Camera Geometry CT2
+    const MHillas     *fHillas2;     //! input
+    const MMcEvt      *fmcevt2;      //! input
+
+    Int_t fCT1id;   //! 
+    Int_t fCT2id;   //! Identifiers of the two analyzed telescopes.
+
+    Float_t fCT1x;   //!
+    Float_t fCT1y;   //! Position of first telescope
+    Float_t fCT2x;   //!
+    Float_t fCT2y;   //! Position of second telescope
+
+    MStereoPar   *fStereoPar;     //! output container to store result
+    TString       fStereoParName; // name of the 'MStereoPar' container
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
+
+public:
+
+    MStereoCalc(const char *name=NULL, const char *title=NULL);
+
+    void SetNameStereoPar(const char *name) { fStereoParName = name; }
+
+    void SetCTids(Int_t i, Int_t j) { fCT1id = i; fCT2id = j; }
+    void SetCT1coor(Float_t x, Float_t y) { fCT1x = x; fCT1y = y; } // in m
+    void SetCT2coor(Float_t x, Float_t y) { fCT2x = x; fCT2y = y; } // in m
+
+    ClassDef(MStereoCalc, 0) // Task to calculate some shower parameters in stereo mode
+};
+
+#endif
+
+
Index: /tags/Mars_V0-8-5/Mars/mimage/MStereoPar.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mimage/MStereoPar.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mimage/MStereoPar.cc	(revision 9661)
@@ -0,0 +1,309 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! * 
+!
+!
+!   Author(s): Abelardo Moralejo 11/2003 <mailto:moralejo@pd.infn.it>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MStereoPar
+//
+// Storage Container for shower parameters estimated using the information
+// from two telescopes (presently for MC studies)
+//
+// 
+/////////////////////////////////////////////////////////////////////////////
+#include "MStereoPar.h"
+#include <fstream>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MHillas.h"
+#include "MMcEvt.hxx"
+#include "MGeomCam.h"
+
+
+ClassImp(MStereoPar);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MStereoPar::MStereoPar(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MStereoPar";
+    fTitle = title ? title : "Stereo image parameters";
+
+
+}
+
+
+// --------------------------------------------------------------------------
+//
+void MStereoPar::Reset()
+{
+    fCoreX = 0.;
+    fCoreY = 0.;
+    fSourceX = 0.;
+    fSourceY = 0.;
+}
+
+
+// --------------------------------------------------------------------------
+//
+//  Calculation of shower parameters
+//
+void MStereoPar::Calc(const MHillas &hillas1, const MMcEvt &mcevt1, const MGeomCam &mgeom1, const Float_t ct1_x, const Float_t ct1_y, const MHillas &hillas2, const MMcEvt &mcevt2, const MGeomCam &mgeom2, const Float_t ct2_x, const Float_t ct2_y)
+{
+    //
+    // Get the direction corresponding to the c.o.g. of the image on 
+    // the camera
+    //
+
+    Float_t ct1_cosx_a;
+    Float_t ct1_cosy_a;
+    Float_t ct1_cosz_a; // Direction from ct1 to the shower c.o.g.
+
+    Camera2direction(1e3*mgeom1.GetCameraDist(), mcevt1.GetTelescopePhi(), mcevt1.GetTelescopeTheta(), hillas1.GetMeanX(), hillas1.GetMeanY(), &ct1_cosx_a, &ct1_cosy_a, &ct1_cosz_a);
+
+    //
+    // Now we get another (arbitrary) point along the image long axis,
+    // fMeanX + cosdelta, fMeanY + sindelta, and calculate the direction 
+    // to which it corresponds.
+    //
+    
+    Float_t ct1_cosx_b;
+    Float_t ct1_cosy_b;
+    Float_t ct1_cosz_b;
+
+    Camera2direction(1e3*mgeom1.GetCameraDist(), mcevt1.GetTelescopePhi(), mcevt1.GetTelescopeTheta(), hillas1.GetMeanX()+hillas1.GetCosDelta(), hillas1.GetMeanY()+hillas1.GetSinDelta(), &ct1_cosx_b, &ct1_cosy_b, &ct1_cosz_b);
+
+    //
+    // The vectorial product of the latter two vectors is a vector 
+    // perpendicular to the plane which contains the shower axis and 
+    // passes through the telescope center (center of reflector). 
+    // The vectorial product of that vector and (0,0,1) is a vector on
+    // the horizontal plane pointing from the telescope center to the 
+    // shower core position on the z=0 plane (ground).
+    //
+
+    Float_t ct1_coreVersorX = ct1_cosz_a*ct1_cosx_b - ct1_cosx_a*ct1_cosz_b;
+    Float_t ct1_coreVersorY = ct1_cosz_a*ct1_cosy_b - ct1_cosy_a*ct1_cosz_b;
+
+    //
+    // Now we calculate again the versor, now assuming that the source 
+    // direction is paralel to the telescope axis (camera position 0,0)  
+    // This increases the precision of the core determination if the showers
+    // actually come from that direction (like for gammas from a point source)
+
+    Camera2direction(1e3*mgeom1.GetCameraDist(), mcevt1.GetTelescopePhi(), mcevt1.GetTelescopeTheta(), 0., 0., &ct1_cosx_b, &ct1_cosy_b, &ct1_cosz_b);
+
+    Float_t ct1_coreVersorX_best = ct1_cosz_a*ct1_cosx_b - ct1_cosx_a*ct1_cosz_b;
+    Float_t ct1_coreVersorY_best = ct1_cosz_a*ct1_cosy_b - ct1_cosy_a*ct1_cosz_b;
+    
+    //
+    // Now the second telescope
+    //
+
+    Float_t ct2_cosx_a;
+    Float_t ct2_cosy_a;
+    Float_t ct2_cosz_a; // Direction from ct2 to the shower c.o.g.
+
+
+    Camera2direction(1e3*mgeom2.GetCameraDist(), mcevt2.GetTelescopePhi(), mcevt2.GetTelescopeTheta(), hillas2.GetMeanX(), hillas2.GetMeanY(), &ct2_cosx_a, &ct2_cosy_a, &ct2_cosz_a);
+
+    Float_t ct2_cosx_b;
+    Float_t ct2_cosy_b;
+    Float_t ct2_cosz_b;
+
+    Camera2direction(1e3*mgeom2.GetCameraDist(), mcevt2.GetTelescopePhi(), mcevt2.GetTelescopeTheta(), hillas2.GetMeanX()+hillas2.GetCosDelta(), hillas2.GetMeanY()+hillas2.GetSinDelta(), &ct2_cosx_b, &ct2_cosy_b, &ct2_cosz_b);
+
+
+    Float_t ct2_coreVersorX = ct2_cosz_a*ct2_cosx_b - ct2_cosx_a*ct2_cosz_b;
+    Float_t ct2_coreVersorY = ct2_cosz_a*ct2_cosy_b - ct2_cosy_a*ct2_cosz_b;
+
+
+    Camera2direction(1e3*mgeom2.GetCameraDist(), mcevt2.GetTelescopePhi(), mcevt2.GetTelescopeTheta(), 0., 0., &ct2_cosx_b, &ct2_cosy_b, &ct2_cosz_b);
+
+    Float_t ct2_coreVersorX_best = ct2_cosz_a*ct2_cosx_b - ct2_cosx_a*ct2_cosz_b;
+    Float_t ct2_coreVersorY_best = ct2_cosz_a*ct2_cosy_b - ct2_cosy_a*ct2_cosz_b;
+    
+    //
+    // Estimate core position:
+    //
+    Float_t t = ct1_x - ct2_x - ct2_coreVersorX/ct2_coreVersorY*(ct1_y-ct2_y);
+    t /= (ct2_coreVersorX/ct2_coreVersorY*ct1_coreVersorY - ct1_coreVersorX);
+
+    fCoreX = ct1_x + t * ct1_coreVersorX;
+    fCoreY = ct1_y + t * ct1_coreVersorY;
+
+    // fCoreX, fCoreY, fCoreX2, fCoreY2 will have the same units 
+    // as ct1_x, ct1_y, ct2_x, ct2_y
+
+
+    //
+    // Now the estimated core position assuming the source is located in 
+    // the center of the camera:
+    //
+    t = ct1_x - ct2_x - ct2_coreVersorX_best / 
+	ct2_coreVersorY_best*(ct1_y-ct2_y);
+    t /= (ct2_coreVersorX_best/ct2_coreVersorY_best*ct1_coreVersorY_best - 
+	  ct1_coreVersorX_best);
+
+    fCoreX2 = ct1_x + t * ct1_coreVersorX_best;
+    fCoreY2 = ct1_y + t * ct1_coreVersorY_best;
+
+    //
+    // Be careful, the coordinates in MMcEvt.fCoreX,fCoreY are actually 
+    // those of the vector going *from the shower core to the telescope*.
+    // Ours are those of the vector which goes from telescope 1 to the 
+    // core estimated core.
+    //
+
+    /////////////////////////////////////////////////////////////////////
+    //
+    // Now estimate the source location on the camera by intersecting 
+    // major axis of the ellipses. This assumes both telescopes are 
+    // pointing paralel! We introduce the camera scale to account for
+    // the use of telescopes with different focal distances. 
+    //
+
+    Float_t scale1 = mgeom1.GetConvMm2Deg();
+    Float_t scale2 = mgeom2.GetConvMm2Deg();
+
+    t = scale2*hillas2.GetMeanY() - scale1*hillas1.GetMeanY() +
+	(scale1*hillas1.GetMeanX() - scale2*hillas2.GetMeanX()) * 
+	hillas2.GetSinDelta() / hillas2.GetCosDelta();
+
+    t /= (hillas1.GetSinDelta() - 
+	  hillas2.GetSinDelta()/hillas2.GetCosDelta()*hillas1.GetCosDelta());
+
+    fSourceX = scale1*hillas1.GetMeanX() + t * hillas1.GetCosDelta();
+    fSourceY = scale1*hillas1.GetMeanY() + t * hillas1.GetSinDelta();
+
+    //
+    // Squared angular distance from reconstructed source position to 
+    // camera center.
+    //
+    fTheta2 = fSourceX*fSourceX+fSourceY*fSourceY;
+
+    //
+    // Get the direction corresponding to the intersection of axes
+    //
+
+    Float_t source_direction[3];
+
+    Camera2direction(1e3*mgeom1.GetCameraDist(), mcevt1.GetTelescopePhi(), mcevt1.GetTelescopeTheta(), fSourceX/scale1, fSourceY/scale1, &(source_direction[0]), &(source_direction[1]), &(source_direction[2]));
+
+
+    //
+    // Calculate impact parameters
+    //
+
+    Float_t scalar = (fCoreX-ct1_x)*source_direction[0] +
+	(fCoreY-ct1_y)*source_direction[1];
+    fCT1Impact = sqrt( (fCoreX-ct1_x)*(fCoreX-ct1_x) +
+		       (fCoreY-ct1_y)*(fCoreY-ct1_y) -
+		       scalar * scalar );
+
+    scalar = (fCoreX-ct2_x)*source_direction[0] +
+	(fCoreY-ct2_y)*source_direction[1];
+    fCT2Impact = sqrt( (fCoreX-ct2_x)*(fCoreX-ct2_x) +
+		       (fCoreY-ct2_y)*(fCoreY-ct2_y) -
+		       scalar * scalar );
+
+    //
+    // Now calculate i.p. assuming source is point-like and placed in
+    // the center of the camera.
+    //
+    scalar = (fCoreX2-ct1_x)*(-sin(mcevt1.GetTelescopeTheta())*
+			     cos(mcevt1.GetTelescopePhi()))  +
+      (fCoreY2-ct1_y)*(-sin(mcevt1.GetTelescopeTheta())*
+		      sin(mcevt1.GetTelescopePhi()));
+
+    fCT1Impact2 = sqrt( (fCoreX2-ct1_x)*(fCoreX2-ct1_x) +
+		       (fCoreY2-ct1_y)*(fCoreY2-ct1_y) -
+		       scalar * scalar );
+
+    scalar = (fCoreX2-ct2_x)*(-sin(mcevt2.GetTelescopeTheta())*
+			     cos(mcevt2.GetTelescopePhi()))  +
+      (fCoreY2-ct2_y)*(-sin(mcevt2.GetTelescopeTheta())*
+		      sin(mcevt2.GetTelescopePhi()));
+
+    fCT2Impact2 = sqrt( (fCoreX2-ct2_x)*(fCoreX2-ct2_x) +
+		       (fCoreY2-ct2_y)*(fCoreY2-ct2_y) -
+		       scalar * scalar );
+
+ 
+    SetReadyToSave();
+} 
+
+// --------------------------------------------------------------------------
+//
+// Transformation of coordinates, from a point on the camera x, y , to
+// the director cosines of the corresponding direction, in the system of 
+// coordinates in which X-axis is North, Y-axis is west, and Z-axis 
+// points to the zenith. The transformation has been taken from TDAS 01-05,
+// although the final system of coordinates is not the same defined there,
+// but the one defined in Corsika (for convenience). 
+//
+// rc is the distance from the reflector center to the camera. CTphi and 
+// CTtheta indicate the telescope orientation. The angle CTphi is the 
+// azimuth of the vector going along the telescope axis from the camera 
+// towards the reflector, measured from the North direction anticlockwise 
+// ( being West: phi=pi/2, South: phi=pi, East: phi=3pi/2 )
+//
+// rc and x,y must be given in the same units!
+//
+  
+
+void MStereoPar::Camera2direction(Float_t rc, Float_t CTphi, Float_t CTtheta, Float_t x, Float_t y, Float_t* cosx, Float_t* cosy, Float_t* cosz)
+{
+    //
+    // We convert phi to the convention defined in TDAS 01-05
+    //
+    Float_t sinphi = sin(2*TMath::Pi()-CTphi);
+    Float_t cosphi = cos(CTphi);
+    Float_t costheta = cos(CTtheta);
+    Float_t sintheta = sin(CTtheta);
+
+    Float_t xc = x/rc;
+    Float_t yc = y/rc;
+
+    Float_t norm = 1/sqrt(1+xc*xc+yc*yc);
+
+    Float_t xref = xc * norm;
+    Float_t yref = yc * norm;
+    Float_t zref = -1 * norm;
+
+    *cosx =  xref * sinphi + yref * costheta*cosphi - zref * sintheta*cosphi;
+    *cosy = -xref * cosphi + yref * costheta*sinphi - zref * sintheta*sinphi;
+    *cosz =                  yref * sintheta        + zref * costheta; 
+
+    //  Now change from system A of TDAS 01-05 to Corsika system:
+
+    *cosy *= -1;
+    *cosz *= -1; 
+
+}
Index: /tags/Mars_V0-8-5/Mars/mimage/MStereoPar.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mimage/MStereoPar.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mimage/MStereoPar.h	(revision 9661)
@@ -0,0 +1,92 @@
+#ifndef MARS_MStereoPar
+#define MARS_MStereoPar
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MHillas;
+class MGeomCam;
+class MMcEvt;
+
+class MStereoPar : public MParContainer
+{
+private:
+
+    Float_t fCoreX;
+    Float_t fCoreY;   // Estimated core position on ground
+
+    Float_t fCoreX2;  // Estimated core position on ground assuming 
+    Float_t fCoreY2;  // that the source direction is paralel to the 
+                      // telescope axis.
+
+    Float_t fSourceX; // Estimated source position on the camera
+    Float_t fSourceY; // Units are degrees! 
+
+    Float_t fTheta2;  // deg^2; Squared angular distance of estimated
+                      // source position to cameracenter.
+
+    Float_t fCT1Impact; // Estimated shower impact parameter from CT1
+    Float_t fCT2Impact; // Estimated shower impact parameter from CT2
+
+    Float_t fCT1Impact2; // Estimated shower impact parameter from CT1
+                         // assuming that the source direction is paralel 
+                         // to the telescope axis.
+
+    Float_t fCT2Impact2; // Estimated shower impact parameter from CT2
+                         // assuming that the source direction is paralel 
+                         // to the telescope axis.
+
+
+    void Camera2direction(Float_t rc, Float_t CTphi, Float_t CTtheta, Float_t x, Float_t y, Float_t* cosx, Float_t* cosy, Float_t* cosz);
+
+
+public:
+    MStereoPar(const char *name=NULL, const char *title=NULL);
+
+    void Reset();
+
+    Float_t GetCoreX() const { return fCoreX; }
+    Float_t GetCoreY() const { return fCoreY; }
+    Float_t GetSourceX() const { return fSourceX; }
+    Float_t GetSourceY() const { return fSourceY; }
+    Float_t GetTheta2() const { return fTheta2; }
+    Float_t GetCT1Impact() const { return fCT1Impact; }
+    Float_t GetCT2Impact() const { return fCT2Impact; }
+    Float_t GetCT1Impact2() const { return fCT1Impact2; }
+    Float_t GetCT2Impact2() const { return fCT2Impact2; }
+
+
+    void Calc(const MHillas &hillas1, const MMcEvt &mcevt1, const MGeomCam &mgeom1, const Float_t ct1_x, const Float_t ct1_y, const MHillas &hillas2, const MMcEvt &mcevt2, const MGeomCam &mgeom2, const Float_t ct2_x, const Float_t ct2_y);
+
+    ClassDef(MStereoPar, 1) // Container to hold new image parameters
+};
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mimage/Makefile
===================================================================
--- /tags/Mars_V0-8-5/Mars/mimage/Makefile	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mimage/Makefile	(revision 9661)
@@ -0,0 +1,47 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#------------------------------------------------------------------------------
+
+#
+# Handling name of the Root Dictionary Files
+#
+CINT  = Image
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES = -I. -I../mbase -I../mhbase -I../mgeom -I../manalysis \
+	   -I../mgui -I../mmc -I../mpointing -I../mpedestal
+
+SRCFILES = MImgCleanStd.cc \
+	   MImgCleanTGB.cc \
+           MCameraSmooth.cc \
+           MHillas.cc \
+           MHillasSrc.cc \
+           MHillasExt.cc \
+           MHillasCalc.cc \
+           MHillasSrcCalc.cc \
+	   MNewImagePar.cc \
+	   MConcentration.cc \
+           MHHillas.cc \
+           MHHillasSrc.cc \
+           MHHillasExt.cc \
+	   MHNewImagePar.cc \
+	   MStereoPar.cc \
+	   MStereoCalc.cc
+
+############################################################
+
+all: $(OBJS)
+
+include ../Makefile.rules
+
+mrproper:	clean rmbak
Index: /tags/Mars_V0-8-5/Mars/mjobs/JobsIncl.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mjobs/JobsIncl.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mjobs/JobsIncl.h	(revision 9661)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-8-5/Mars/mjobs/JobsLinkDef.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mjobs/JobsLinkDef.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mjobs/JobsLinkDef.h	(revision 9661)
@@ -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 MJPedestal+;
+#pragma link C++ class MJCalibration+;
+#pragma link C++ class MJExtractSignal+;
+#pragma link C++ class MJExtractCalibTest+;
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mjobs/MJCalibration.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mjobs/MJCalibration.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mjobs/MJCalibration.cc	(revision 9661)
@@ -0,0 +1,1285 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!              Markus Gaug, 02/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MJCalibration
+//
+//  Do one calibration loop over serious of runs with the same pulser 
+//  colour and the same intensity. The following containers (rectangular) and 
+//  tasks (ellipses) are called to produce an MCalibrationChargeCam and to 
+//  update the MCalibrationQECam: (MCalibrate is not called from this class)
+//
+//Begin_Html
+/*
+<img src="images/CalibClasses.gif">
+*/
+//End_Html
+//
+// Different signal extractors can be set with the command SetExtractor()
+// Only extractors deriving from MExtractor can be set, default is MExtractSlidingWindow
+//
+// Different arrival time extractors can be set with the command SetTimeExtractor()
+// Only extractors deriving from MExtractTime can be set, default is MExtractTimeSpline
+//
+// At the end of the eventloop, plots and results are displayed, depending on 
+// the flags set (see DisplayResult()) 
+// 
+// If the flag SetFullDisplay() is set, all MHCameras will be displayed. 
+// if the flag SetDataCheckDisplay() is set, only the most important ones are displayed 
+// Otherwise, (default: SetNormalDisplay()), a good selection of plots is given
+//
+// If the flag SetDataCheck() is set, the calibration is used as in the data check at 
+// La Palma, which mean especially running on raw data files.
+// 
+// The absolute light calibration devices Blind Pixel and PIN Diode can be switched on
+// and off with the commands:
+//
+// - SetUseBlindPixel(Bool_t )
+// - SetUsePINDiode(Bool_t )
+//
+// See also: MHCalibrationChargePix, MHCalibrationChargeCam, MHGausEvents
+//           MHCalibrationChargeBlindPix, MHCalibrationChargePINDiode
+//           MCalibrationChargePix, MCalibrationChargeCam, MCalibrationChargeCalc
+//           MCalibrationChargeBlindPix, MCalibrationChargePINDiode,
+//           MCalibrationQECam, MBadPixelsPix, MBadPixelsCam
+//
+// If the flag RelTimeCalibration() is set, a calibration of the relative arrival 
+// times is also performed. The following containers (rectangular) and 
+// tasks (ellipses) are called to produce an MCalibrationRelTimeCam used by  
+// MCalibrateTime to correct timing offset between pixels: (MCalibrateTime is not 
+// called from this class)
+//
+//Begin_Html
+/*
+<img src="images/RelTimeClasses.gif">
+*/
+//End_Html
+//
+// Different arrival time extractors can be set directly with the command SetTimeExtractor(MExtractor *)
+//
+// See also: MHCalibrationRelTimePix, MHCalibrationRelTimeCam, MHGausEvents
+//           MCalibrationRelTimePix, MCalibrationRelTimeCam
+//           MBadPixelsPix, MBadPixelsCam
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MJCalibration.h"
+
+#include <TFile.h>
+#include <TStyle.h>
+#include <TCanvas.h>
+#include <TSystem.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MRunIter.h"
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MEvtLoop.h"
+
+#include "MHCamera.h"
+#include "MGeomCam.h"
+
+#include "MPedestalCam.h"
+#include "MCalibrationCam.h"
+#include "MCalibrationQECam.h"
+#include "MCalibrationChargeCam.h"
+#include "MCalibrationChargePINDiode.h"
+#include "MCalibrationChargeBlindPix.h"
+#include "MCalibrationChargeCalc.h"
+
+#include "MHGausEvents.h"
+#include "MHCalibrationCam.h"
+#include "MHCalibrationChargeCam.h"
+#include "MHCalibrationChargeBlindPix.h"
+#include "MHCalibrationRelTimeCam.h"
+#include "MCalibrationRelTimeCam.h"
+#include "MCalibrationRelTimeCalc.h"
+
+#include "MReadMarsFile.h"
+#include "MRawFileRead.h"
+#include "MGeomApply.h"
+#include "MBadPixelsMerge.h"
+#include "MBadPixelsCam.h"
+#include "MExtractTime.h"
+#include "MExtractor.h"
+#include "MExtractPINDiode.h"
+#include "MExtractBlindPixel.h"
+#include "MExtractSlidingWindow.h"
+#include "MExtractTimeFastSpline.h"
+#include "MFCosmics.h"
+#include "MContinue.h"
+#include "MFillH.h"
+
+#include "MArrivalTimeCam.h"
+
+#include "MStatusDisplay.h"
+
+ClassImp(MJCalibration);
+
+using namespace std;
+
+const Int_t MJCalibration::gkIFAEBoxInaugurationRun = 20113;
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+// - Sets fRuns to 0, fExtractor to NULL, fTimeExtractor to NULL, fColor to kNONE, 
+//   fDisplay to kNormalDisplay, fRelTime to kFALSE, fDataCheck to kFALSE, 
+// - SetUseBlindPixel()
+// - SetUsePINDiode()
+//
+MJCalibration::MJCalibration(const char *name, const char *title) 
+    : fRuns(0), fExtractor(NULL), fTimeExtractor(NULL), 
+      fColor(MCalibrationCam::kNONE), fDisplayType(kNormalDisplay),
+      fRelTimes(kFALSE), fDataCheck(kFALSE), fDebug(kFALSE)
+{
+
+  fName  = name  ? name  : "MJCalibration";
+  fTitle = title ? title : "Tool to create the calibration constants for one calibration run";
+
+  SetUseBlindPixel();
+  SetUsePINDiode();
+
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Display the results in MStatusDisplay: 
+//
+// - Add "Calibration" to the MStatusDisplay title
+// - Retrieve the MGeomCam from MParList
+// - Initialize the following MHCamera's:
+//   1)  MCalibrationPix::GetMean()
+//   2)  MCalibrationPix::Sigma()
+//   3)  MCalibrationChargePix::GetRSigma()
+//   4)  MCalibrationChargePix::GetRSigmaPerCharge()
+//   5)  MCalibrationChargePix::GetPheFFactorMethod()
+//   6)  MCalibrationChargePix::GetMeanConvFADC2Phe()
+//   7)  MCalibrationChargePix::GetMeanFFactorFADC2Phot()
+//   8)  MCalibrationQEPix::GetQECascadesFFactor()
+//   9)  MCalibrationQEPix::GetQECascadesBlindPixel()
+//   10) MCalibrationQEPix::GetQECascadesPINDiode()
+//   11) MCalibrationQEPix::GetQECascadesCombined()
+//   12) MCalibrationQEPix::IsAverageQEFFactorAvailable()
+//   13) MCalibrationQEPix::IsAverageQEBlindPixelAvailable()
+//   14) MCalibrationQEPix::IsAverageQEPINDiodeAvailable()
+//   15) MCalibrationQEPix::IsAverageQECombinedAvailable()
+//   16) MCalibrationChargePix::IsHiGainSaturation()
+//   17) MCalibrationPix::GetHiLoMeansDivided()
+//   18) MCalibrationPix::GetHiLoSigmasDivided()
+//   19) MCalibrationChargePix::GetHiGainPickup()
+//   20) MCalibrationChargePix::GetLoGainPickup()
+//   21) MCalibrationChargePix::GetHiGainBlackout()
+//   22) MCalibrationChargePix::GetLoGainBlackout()
+//   23) MCalibrationPix::IsExcluded()
+//   24) MBadPixelsPix::IsUnsuitable(MBadPixelsPix::kUnsuitableRun)
+//   25) MBadPixelsPix::IsUnsuitable(MBadPixelsPix::kUnreliableRun)
+//   26) MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kHiGainOscillating)
+//   27) MBadPixelsPix::IsUncalibrated(MBadPixelsPix::kLoGainOscillating)
+//   28) MCalibrationChargePix::GetAbsTimeMean()
+//   29) MCalibrationChargePix::GetAbsTimeRms()
+//
+// If the flag SetFullDisplay() is set, all MHCameras will be displayed. 
+// if the flag SetDataCheckDisplay() is set, only the most important ones are displayed 
+// and otherwise, (default: SetNormalDisplay()), a good selection of plots is given
+//
+void MJCalibration::DisplayResult(MParList &plist)
+{
+    if (!fDisplay)
+        return;
+
+    //
+    // Update display
+    //
+    TString title = fDisplay->GetTitle();
+    title += "--  Calibration ";
+    title += fRuns->GetRunsAsString();
+    title += "  --";
+    fDisplay->SetTitle(title);
+
+    //
+    // Get container from list
+    //
+    MGeomCam &geomcam = *(MGeomCam*)plist.FindObject("MGeomCam");
+
+    // Create histograms to display
+    MHCamera disp1 (geomcam, Form("%s%s","Charge",(fRuns->GetRunsAsFileName()).Data()),
+                    "Fitted Mean Charges");
+    MHCamera disp2 (geomcam, Form("%s%s","SigmaCharge",(fRuns->GetRunsAsFileName()).Data()),
+                    "Sigma of Fitted Charges");
+    MHCamera disp3 (geomcam, Form("%s%s","RSigma",(fRuns->GetRunsAsFileName()).Data()),
+                    "Reduced Sigmas");
+    MHCamera disp4 (geomcam, Form("%s%s","RSigmaPerCharge",(fRuns->GetRunsAsFileName()).Data()),  
+                    "Reduced Sigma per Charge");
+    MHCamera disp5 (geomcam, Form("%s%s","NumPhes",(fRuns->GetRunsAsFileName()).Data()),
+                    "Nr. of Phe's (F-Factor Method)");
+    MHCamera disp6 (geomcam, Form("%s%s","ConvFADC2Phes",(fRuns->GetRunsAsFileName()).Data()),
+                    "Conversion Factor (F-Factor Method)");
+    MHCamera disp7 (geomcam, Form("%s%s","TotalFFactor",(fRuns->GetRunsAsFileName()).Data()),
+                    "Total F-Factor (F-Factor Method)");
+    MHCamera disp8 (geomcam, Form("%s%s","CascadesQEFFactor",(fRuns->GetRunsAsFileName()).Data()),
+                    "Cascades QE (F-Factor Method)");
+    MHCamera disp9 (geomcam, Form("%s%s","CascadesQEBlindPix",(fRuns->GetRunsAsFileName()).Data()),
+                    "Cascades QE (Blind Pixel Method)");
+    MHCamera disp10(geomcam, Form("%s%s","CascadesQEPINDiode",(fRuns->GetRunsAsFileName()).Data()),
+                    "Cascades QE (PIN Diode Method)");
+    MHCamera disp11(geomcam, Form("%s%s","CascadesQECombined",(fRuns->GetRunsAsFileName()).Data()),
+                    "Cascades QE (Combined Method)");
+    MHCamera disp12(geomcam, Form("%s%s","FFactorValid",(fRuns->GetRunsAsFileName()).Data()),
+                    "Pixels with valid F-Factor calibration");
+    MHCamera disp13(geomcam, Form("%s%s","BlindPixelValid",(fRuns->GetRunsAsFileName()).Data()), 
+                    "Pixels with valid BlindPixel calibration");
+    MHCamera disp14(geomcam, Form("%s%s","PINdiodeValid",(fRuns->GetRunsAsFileName()).Data()),
+                    "Pixels with valid PINDiode calibration");
+    MHCamera disp15(geomcam, Form("%s%s","CombinedValid",(fRuns->GetRunsAsFileName()).Data()),
+                    "Pixels with valid Combined calibration");
+    MHCamera disp16(geomcam, Form("%s%s","Saturation",(fRuns->GetRunsAsFileName()).Data()),
+                    "Pixels with saturated Hi Gain");
+    MHCamera disp17(geomcam, Form("%s%s","ConversionMeans",(fRuns->GetRunsAsFileName()).Data()), 
+                    "Conversion HiGain.vs.LoGain Means");
+    MHCamera disp18(geomcam, Form("%s%s","ConversionSigmas",(fRuns->GetRunsAsFileName()).Data()), 
+                    "Conversion HiGain.vs.LoGain Sigmas");
+    MHCamera disp19(geomcam, Form("%s%s","HiGainPickup",(fRuns->GetRunsAsFileName()).Data()),
+                    "Number Pickup events Hi Gain");
+    MHCamera disp20(geomcam, Form("%s%s","LoGainPickup",(fRuns->GetRunsAsFileName()).Data()),
+                    "Number Pickup events Lo Gain");
+    MHCamera disp21(geomcam, Form("%s%s","HiGainBlackout",(fRuns->GetRunsAsFileName()).Data()),
+                    "Number Blackout events Hi Gain");
+    MHCamera disp22(geomcam, Form("%s%s","LoGainBlackout",(fRuns->GetRunsAsFileName()).Data()), 
+                    "Number Blackout events Lo Gain");
+    MHCamera disp23(geomcam, Form("%s%s","Excluded",(fRuns->GetRunsAsFileName()).Data()),
+                    "Pixels previously excluded");
+    MHCamera disp24(geomcam, Form("%s%s","UnSuitable",(fRuns->GetRunsAsFileName()).Data()),
+                    "Pixels not suited for further analysis");
+    MHCamera disp25(geomcam, Form("%s%s","UnReliable",(fRuns->GetRunsAsFileName()).Data()),
+                    "Pixels not reliable for further analysis");
+    MHCamera disp26(geomcam, Form("%s%s","HiGainOscillating",(fRuns->GetRunsAsFileName()).Data()),
+                    "Oscillating Pixels High Gain");
+    MHCamera disp27(geomcam, Form("%s%s","LoGainOscillating",(fRuns->GetRunsAsFileName()).Data()),
+                    "Oscillating Pixels Low Gain");
+    MHCamera disp28(geomcam, Form("%s%s","AbsTimeMean",(fRuns->GetRunsAsFileName()).Data()),
+                    "Abs. Arrival Times");
+    MHCamera disp29(geomcam, Form("%s%s","AbsTimeRms",(fRuns->GetRunsAsFileName()).Data()),
+                    "RMS of Arrival Times");
+    MHCamera disp30(geomcam, Form("%s%s","MeanTime",(fRuns->GetRunsAsFileName()).Data()),
+                    "Mean Rel. Arrival Times");
+    MHCamera disp31(geomcam, Form("%s%s","SigmaTime",(fRuns->GetRunsAsFileName()).Data()),
+                    "Sigma Rel. Arrival Times");
+    MHCamera disp32(geomcam, Form("%s%s","TimeProb",(fRuns->GetRunsAsFileName()).Data()),
+                    "Probability of Time Fit");
+    MHCamera disp33(geomcam, Form("%s%s","TimeNotFitValid",(fRuns->GetRunsAsFileName()).Data()),
+                    "Pixels with not valid fit results");
+    MHCamera disp34(geomcam, Form("%s%s","TimeOscillating",(fRuns->GetRunsAsFileName()).Data()),
+                    "Oscillating Pixels");
+
+    // Fitted charge means and sigmas
+    disp1.SetCamContent(fCalibrationCam,  0);
+    disp1.SetCamError(  fCalibrationCam,  1);
+    disp2.SetCamContent(fCalibrationCam,  2);
+    disp2.SetCamError(  fCalibrationCam,  3);
+
+    // Reduced Sigmas and reduced sigmas per charge
+    disp3.SetCamContent(fCalibrationCam,  5);
+    disp3.SetCamError(  fCalibrationCam,  6);
+    disp4.SetCamContent(fCalibrationCam,  7);
+    disp4.SetCamError(  fCalibrationCam,  8);
+
+    // F-Factor Method
+    disp5.SetCamContent(fCalibrationCam,  9);
+    disp5.SetCamError(  fCalibrationCam, 10);
+    disp6.SetCamContent(fCalibrationCam, 11);
+    disp6.SetCamError(  fCalibrationCam, 12);
+    disp7.SetCamContent(fCalibrationCam, 13);
+    disp7.SetCamError(  fCalibrationCam, 14);
+
+    // Quantum Efficiencies
+    disp8.SetCamContent (fQECam, 0 );
+    disp8.SetCamError   (fQECam, 1 );
+    disp9.SetCamContent (fQECam, 2 );
+    disp9.SetCamError   (fQECam, 3 );
+    disp10.SetCamContent(fQECam, 4 );
+    disp10.SetCamError  (fQECam, 5 );
+    disp11.SetCamContent(fQECam, 6 );
+    disp11.SetCamError  (fQECam, 7 );
+
+    // Valid flags
+    disp12.SetCamContent(fQECam, 8 );
+    disp13.SetCamContent(fQECam, 9 );
+    disp14.SetCamContent(fQECam, 10);
+    disp15.SetCamContent(fQECam, 11);
+
+    // Conversion Hi-Lo
+    disp16.SetCamContent(fCalibrationCam, 25);
+    disp17.SetCamContent(fCalibrationCam, 16);
+    disp17.SetCamError  (fCalibrationCam, 17);
+    disp18.SetCamContent(fCalibrationCam, 18);
+    disp18.SetCamError  (fCalibrationCam, 19);
+
+    // Pickup and Blackout
+    disp19.SetCamContent(fCalibrationCam, 21);
+    disp20.SetCamContent(fCalibrationCam, 22);
+    disp21.SetCamContent(fCalibrationCam, 23);
+    disp22.SetCamContent(fCalibrationCam, 24);
+
+    // Pixels with defects
+    disp23.SetCamContent(fCalibrationCam, 20);
+    disp24.SetCamContent(fBadPixels, 1);
+    disp25.SetCamContent(fBadPixels, 3);
+
+    // Oscillations
+    disp26.SetCamContent(fBadPixels, 10);
+    disp27.SetCamContent(fBadPixels, 11);
+
+    // Arrival Times
+    disp28.SetCamContent(fCalibrationCam, 26);
+    disp28.SetCamError(  fCalibrationCam, 27);
+    disp29.SetCamContent(fCalibrationCam, 27);
+
+    disp1.SetYTitle("Q [FADC counts]");
+    disp2.SetYTitle("\\sigma_{Q} [FADC counts]");
+
+    disp3.SetYTitle("\\sqrt{\\sigma^{2}_{Q} - RMS^{2}_{Ped}} [FADC Counts]");
+    disp4.SetYTitle("Red.Sigma/<Q> [1]");
+
+    disp5.SetYTitle("Nr. Phe's [1]");
+    disp6.SetYTitle("Conv.Factor [PhE/FADC counts]");
+    disp7.SetYTitle("Total F-Factor [1]");
+
+    disp8.SetYTitle("QE [1]");
+    disp9.SetYTitle("QE [1]");
+    disp10.SetYTitle("QE [1]");
+    disp11.SetYTitle("QE [1]");
+
+    disp12.SetYTitle("[1]");
+    disp13.SetYTitle("[1]");
+    disp14.SetYTitle("[1]");
+    disp15.SetYTitle("[1]");
+    disp16.SetYTitle("[1]");
+
+    disp17.SetYTitle("<Q>(High)/<Q>(Low) [1]");
+    disp18.SetYTitle("\\sigma_{Q}(High)/\\sigma_{Q}(Low) [1]");
+
+    disp19.SetYTitle("[1]");
+    disp20.SetYTitle("[1]");
+    disp21.SetYTitle("[1]");
+    disp22.SetYTitle("[1]");
+    disp23.SetYTitle("[1]");
+    disp24.SetYTitle("[1]");
+    disp25.SetYTitle("[1]");
+    disp26.SetYTitle("[1]");
+    disp27.SetYTitle("[1]");
+
+    disp28.SetYTitle("Mean Abs. Time [FADC slice]");
+    disp29.SetYTitle("RMS Abs. Time [FADC slices]");
+
+    if (fRelTimes)
+      {
+
+        disp30.SetCamContent(fRelTimeCam,0);
+        disp30.SetCamError(  fRelTimeCam,1);
+        disp31.SetCamContent(fRelTimeCam,2);
+        disp31.SetCamError(  fRelTimeCam,3);
+        disp32.SetCamContent(fRelTimeCam,4);
+        disp33.SetCamContent(fBadPixels,20);
+        disp34.SetCamContent(fBadPixels,21);
+    
+        disp30.SetYTitle("Time Offset [FADC units]");
+        disp31.SetYTitle("Timing resolution [FADC units]");
+        disp32.SetYTitle("P_{Time} [1]");
+        disp33.SetYTitle("[1]");
+        disp34.SetYTitle("[1]");
+      }
+    
+    if (fDisplayType == kDataCheckDisplay)
+      {
+        TCanvas &c1 = fDisplay->AddTab("Fit.Charge");
+        c1.Divide(3, 3);
+        
+        disp1.CamDraw(c1, 1, 3, 5);
+        disp4.CamDraw(c1, 2, 3, 5);
+        disp28.CamDraw(c1, 3, 3, 5);
+
+        //  F-Factor
+        TCanvas &c2 = fDisplay->AddTab("Phe's");
+        c2.Divide(3,4);
+        
+        disp6.CamDraw(c2, 1, 3,  5, 1);
+        disp7.CamDraw(c2, 2, 3,  5, 1);
+        disp8.CamDraw(c2, 3, 3,  5, 1);
+
+        // QE's
+        TCanvas &c3 = fDisplay->AddTab("QE's");
+        c3.Divide(3,4);
+
+        disp8.CamDraw(c3, 1, 3,  5, 1);
+        disp9.CamDraw(c3, 2, 3,  5, 1);
+        disp10.CamDraw(c3, 3, 3,  5, 1);
+
+        // Defects
+        TCanvas &c4 = fDisplay->AddTab("Defect");
+        c4.Divide(2,2);
+
+        disp24.CamDraw(c4, 1, 2, 0);
+        disp25.CamDraw(c4, 2, 2, 0);
+
+        if (fRelTimes)
+          {
+            // Rel. Times
+            TCanvas &c5 = fDisplay->AddTab("Rel. Times");
+            c5.Divide(2,4);
+            
+            disp30.CamDraw(c5, 1, 2, 2);
+            disp31.CamDraw(c5, 2, 2, 2);
+          }
+
+
+        return;
+      }
+    
+    if (fDisplayType == kNormalDisplay)
+      {
+
+        // Charges
+        TCanvas &c11 = fDisplay->AddTab("Fit.Charge");
+        c11.Divide(2, 4);
+        
+        disp1.CamDraw(c11, 1, 2, 5, 1);
+        disp2.CamDraw(c11, 2, 2, 5, 1);
+        
+        // Reduced Sigmas
+        TCanvas &c12 = fDisplay->AddTab("Red.Sigma");
+        c12.Divide(2,4);
+        
+        disp3.CamDraw(c12, 1, 2, 5, 1);
+        disp4.CamDraw(c12, 2, 2, 5, 1);
+        
+        //  F-Factor
+        TCanvas &c13 = fDisplay->AddTab("Phe's");
+        c13.Divide(3,4);
+        
+        disp5.CamDraw(c13, 1, 3, 5, 1);
+        disp6.CamDraw(c13, 2, 3, 5, 1);
+        disp7.CamDraw(c13, 3, 3, 5, 1);
+        
+        // QE's
+        TCanvas &c14 = fDisplay->AddTab("QE's");
+        c14.Divide(4,4);
+        
+        disp8.CamDraw(c14, 1, 4, 5, 1);
+        disp9.CamDraw(c14, 2, 4, 5, 1);
+        disp10.CamDraw(c14, 3, 4, 5, 1);
+        disp11.CamDraw(c14, 4, 4, 5, 1);
+        
+        // Defects
+        TCanvas &c15 = fDisplay->AddTab("Defect");
+        //      c15.Divide(5,2);
+        c15.Divide(4,2);
+        
+        /*
+        disp23.CamDraw(c15, 1, 5, 0);
+        disp24.CamDraw(c15, 2, 5, 0);
+        disp25.CamDraw(c15, 3, 5, 0);
+        disp26.CamDraw(c15, 4, 5, 0);
+        disp27.CamDraw(c15, 5, 5, 0);
+        */
+        disp24.CamDraw(c15, 1, 4, 0);
+        disp25.CamDraw(c15, 2, 4, 0);
+        disp26.CamDraw(c15, 3, 4, 0);
+        disp27.CamDraw(c15, 4, 4, 0);
+        
+        // Abs. Times
+        TCanvas &c16 = fDisplay->AddTab("Abs. Times");
+        c16.Divide(2,3);
+        
+        disp28.CamDraw(c16, 1, 2, 5);
+        disp29.CamDraw(c16, 2, 2, 5);
+
+        if (fRelTimes)
+          {
+            // Rel. Times
+            TCanvas &c17 = fDisplay->AddTab("Rel. Times");
+            c17.Divide(2,4);
+            
+            disp30.CamDraw(c17, 1, 2, 5, 1);
+            disp31.CamDraw(c17, 2, 2, 5, 1);
+          }
+        
+        return;
+      }
+    
+    if (fDisplayType == kFullDisplay)
+      {
+
+        MHCalibrationCam *cam = (MHCalibrationCam*)plist.FindObject("MHCalibrationChargeCam");
+
+        for (Int_t sector=1;sector<cam->GetAverageSectors();sector++)
+          {
+            cam->GetAverageHiGainSector(sector).DrawClone("all");
+            cam->GetAverageLoGainSector(sector).DrawClone("all");
+          }
+
+        // Charges
+        TCanvas &c21 = fDisplay->AddTab("Fit.Charge");
+        c21.Divide(2, 4);
+        
+        disp1.CamDraw(c21, 1, 2, 2, 1);
+        disp2.CamDraw(c21, 2, 2, 2, 1);
+        
+        // Reduced Sigmas
+        TCanvas &c23 = fDisplay->AddTab("Red.Sigma");
+        c23.Divide(2,4);
+        
+        disp3.CamDraw(c23, 1, 2, 2, 1);
+        disp4.CamDraw(c23, 2, 2, 2, 1);
+        
+        //  F-Factor
+        TCanvas &c24 = fDisplay->AddTab("Phe's");
+        c24.Divide(3,5);
+        
+        disp5.CamDraw(c24, 1, 3, 2, 1, 1);
+        disp6.CamDraw(c24, 2, 3, 2, 1, 1);
+        disp7.CamDraw(c24, 3, 3, 2, 1, 1);
+        
+        // QE's
+        TCanvas &c25 = fDisplay->AddTab("QE's");
+        c25.Divide(4,5);
+        
+        disp8.CamDraw(c25, 1, 4, 2, 1, 1);
+        disp9.CamDraw(c25, 2, 4, 2, 1, 1);
+        disp10.CamDraw(c25, 3, 4, 2, 1, 1);
+        disp11.CamDraw(c25, 4, 4, 2, 1, 1);
+        
+        // Validity
+        TCanvas &c26 = fDisplay->AddTab("Valid");
+        c26.Divide(4,2);
+        
+        disp12.CamDraw(c26, 1, 4, 0);
+        disp13.CamDraw(c26, 2, 4, 0);
+        disp14.CamDraw(c26, 3, 4, 0);
+        disp15.CamDraw(c26, 4, 4, 0);
+        
+        // Other info
+        TCanvas &c27 = fDisplay->AddTab("HiLoGain");
+        c27.Divide(3,3);
+        
+        disp16.CamDraw(c27, 1, 3, 0);
+        disp17.CamDraw(c27, 2, 3, 1);
+        disp18.CamDraw(c27, 3, 3, 1);
+        
+        // Pickup
+        TCanvas &c28 = fDisplay->AddTab("Pickup");
+        c28.Divide(4,2);
+        
+        disp19.CamDraw(c28, 1, 4, 0);
+        disp20.CamDraw(c28, 2, 4, 0);
+        disp21.CamDraw(c28, 3, 4, 0);
+        disp22.CamDraw(c28, 4, 4, 0);
+        
+        // Defects
+        TCanvas &c29 = fDisplay->AddTab("Defect");
+        //      c29.Divide(5,2);
+        c29.Divide(4,2);
+        
+        disp24.CamDraw(c29, 1, 4, 0);
+        disp25.CamDraw(c29, 2, 4, 0);
+        disp26.CamDraw(c29, 3, 4, 0);
+        disp27.CamDraw(c29, 4, 4, 0);
+        
+        // Abs. Times
+        TCanvas &c30 = fDisplay->AddTab("Abs. Times");
+        c30.Divide(2,3);
+        
+        disp28.CamDraw(c30, 1, 2, 2);
+        disp29.CamDraw(c30, 2, 2, 1);
+
+        if (fRelTimes)
+          {
+            // Rel. Times
+            TCanvas &c31 = fDisplay->AddTab("Rel. Times");
+            c31.Divide(3,5);
+            
+            disp30.CamDraw(c31, 1, 3, 2, 1, 1);
+            disp31.CamDraw(c31, 2, 3, 2, 1, 1);
+            disp32.CamDraw(c31, 3, 3, 4, 1, 1);
+
+            // Time Defects
+            TCanvas &c32 = fDisplay->AddTab("Time Def.");
+            c32.Divide(2,2);
+            
+            disp33.CamDraw(c32, 1, 2, 0);
+            disp34.CamDraw(c32, 2, 2, 0);
+
+            MHCalibrationCam *cam = (MHCalibrationCam*)plist.FindObject("MHCalibrationRelTimeCam");
+            
+            for (Int_t sector=1;sector<cam->GetAverageSectors();sector++)
+              {
+                cam->GetAverageHiGainSector(sector).DrawClone("fourierevents");
+                cam->GetAverageLoGainSector(sector).DrawClone("fourierevents");
+              }
+            
+          }
+
+        return;
+      }
+}
+
+
+
+// --------------------------------------------------------------------------
+//
+// Find the colour of the pulsing LED:
+// - If the run number is smaller than gkIFAEBoxInaugurationRun, take MCalibrationCam::kCT1
+// - Otherwise find the colour out of the run name
+// - If no colour is found, return kFALSE
+// 
+Bool_t MJCalibration::FindColor() 
+{
+
+  const UInt_t nruns = fRuns->GetNumRuns();
+
+  if (nruns == 0)
+    return kFALSE;
+  
+  TArrayI arr = fRuns->GetRuns();
+
+  if (arr[nruns-1] < gkIFAEBoxInaugurationRun)
+    {
+      *fLog << "Found colour kCT1 in runs: " << fRuns->GetRunsAsString() << endl;
+      fColor = MCalibrationCam::kCT1;
+      return kTRUE;
+    }
+  
+  TString filenames;
+  ((MDirIter*)fRuns)->Reset();
+
+  while (!(filenames=((MDirIter*)fRuns)->Next()).IsNull())
+    {
+
+      filenames.ToLower();
+
+      //
+      // Here starts the list of runs where the shifters did not put 
+      // a colour, but which have been found out by other means
+      //
+      if (filenames.Contains("_27474_"))
+        if (fColor == MCalibrationCam::kNONE)
+          {
+            *fLog << "Sorry, run 27474 was taken with CLOSED LIDS. It should not be used! "
+                  << "Selected runs were: " << filenames << endl;
+            fColor = MCalibrationCam::kNONE;
+            return kFALSE;
+          }
+        else if (fColor != MCalibrationCam::kNONE)
+          {
+            *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
+            return kFALSE;
+          }
+
+      if (filenames.Contains("_26924_"))
+        if (fColor == MCalibrationCam::kNONE)
+          {
+            *fLog << "Found colour: kGREEN  in " << filenames << endl;
+            fColor = MCalibrationCam::kGREEN;
+          }
+        else if (fColor != MCalibrationCam::kGREEN)
+          {
+            *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
+            return kFALSE;
+          }
+
+
+      if (filenames.Contains("_26568_"))
+        if (fColor == MCalibrationCam::kNONE)
+          {
+            *fLog << "Found colour: kGREEN  in " << filenames << endl;
+            fColor = MCalibrationCam::kGREEN;
+          }
+        else if (fColor != MCalibrationCam::kGREEN)
+          {
+            *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
+            return kFALSE;
+          }
+
+      if (filenames.Contains("_26412_"))
+        if (fColor == MCalibrationCam::kNONE)
+          {
+            *fLog << "Found colour: kGREEN  in " << filenames << endl;
+            fColor = MCalibrationCam::kGREEN;
+          }
+        else if (fColor != MCalibrationCam::kGREEN)
+          {
+            *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
+            return kFALSE;
+          }
+
+
+      if (filenames.Contains("_26409_"))
+        if (fColor == MCalibrationCam::kNONE)
+          {
+            *fLog << "Found colour: kGREEN  in " << filenames << endl;
+            fColor = MCalibrationCam::kGREEN;
+          }
+        else if (fColor != MCalibrationCam::kGREEN)
+          {
+            *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
+            return kFALSE;
+          }
+
+      if (filenames.Contains("_26408_"))
+        if (fColor == MCalibrationCam::kNONE)
+          {
+            *fLog << "Found colour: kGREEN  in " << filenames << endl;
+            fColor = MCalibrationCam::kGREEN;
+          }
+        else if (fColor != MCalibrationCam::kGREEN)
+          {
+            *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
+            return kFALSE;
+          }
+
+
+      if (filenames.Contains("_26402_"))
+        if (fColor == MCalibrationCam::kNONE)
+          {
+            *fLog << "Found colour: kBLUE  in " << filenames << endl;
+            fColor = MCalibrationCam::kBLUE;
+          }
+        else if (fColor != MCalibrationCam::kBLUE)
+          {
+            *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
+            return kFALSE;
+          }
+
+      if (filenames.Contains("_20661_"))
+        if (fColor == MCalibrationCam::kNONE)
+          {
+            *fLog << "Found colour: kGREEN  in " << filenames << endl;
+            fColor = MCalibrationCam::kGREEN;
+          }
+        else if (fColor != MCalibrationCam::kGREEN)
+          {
+            *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
+            return kFALSE;
+          }
+
+      if (filenames.Contains("_20660_"))
+        if (fColor == MCalibrationCam::kNONE)
+          {
+            *fLog << "Found colour: kGREEN  in " << filenames << endl;
+            fColor = MCalibrationCam::kGREEN;
+          }
+        else if (fColor != MCalibrationCam::kGREEN)
+          {
+            *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
+            return kFALSE;
+          }
+
+      //
+      // Here start the runs where the shifter put 
+      // the colour
+      //
+      if (filenames.Contains("green"))
+        if (fColor == MCalibrationCam::kNONE)
+          {
+            *fLog << "Found colour: kGREEN  in " << filenames << endl;
+            fColor = MCalibrationCam::kGREEN;
+          }
+        else if (fColor != MCalibrationCam::kGREEN)
+          {
+            *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
+            return kFALSE;
+          }
+
+      if (filenames.Contains("blue"))
+        if (fColor == MCalibrationCam::kNONE)
+          {
+            *fLog << "Found colour: kBLUE  in " << filenames << endl;
+            fColor = MCalibrationCam::kBLUE;
+          }
+        else if (fColor != MCalibrationCam::kBLUE)
+          {
+            *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
+            return kFALSE;
+          }
+
+      if (filenames.Contains("uv"))
+        if (fColor == MCalibrationCam::kNONE)
+          {
+            *fLog << "Found colour: kUV in " << filenames << endl;
+            fColor = MCalibrationCam::kUV;
+          }
+        else if (fColor != MCalibrationCam::kUV)
+          {
+            *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
+            return kFALSE;
+          }
+
+      if (filenames.Contains("ct1"))
+        if (fColor == MCalibrationCam::kNONE)
+          {
+            *fLog << "Found colour: kCT1  in " << filenames << endl;
+            fColor = MCalibrationCam::kCT1;
+          }
+        else if (fColor != MCalibrationCam::kCT1)
+          {
+            *fLog << err << "Different colour found in " << filenames << "... abort" << endl;
+            return kFALSE;
+          }
+      
+    }
+  
+  if (fColor == MCalibrationCam::kNONE)
+    {
+      *fLog <<  "No colour found in filenames of runs: " << fRuns->GetRunsAsString() 
+           << "... abort" << endl;
+      return kFALSE;      
+    }
+
+  return kTRUE;
+}
+
+
+
+
+// --------------------------------------------------------------------------
+//
+// Retrieve the output file written by WriteResult()
+// 
+const char* MJCalibration::GetOutputFile() const
+{
+
+  if (!fRuns)
+    return "";
+  
+  return Form("%s/%s-F1.root", (const char*)fOutputPath, (const char*)fRuns->GetRunsAsFileName());
+}
+
+
+Bool_t MJCalibration::IsUseBlindPixel() const 
+{
+  return TESTBIT(fDevices,kUseBlindPixel);
+}
+
+
+Bool_t MJCalibration::IsUsePINDiode() const 
+{
+  return TESTBIT(fDevices,kUsePINDiode);
+}
+
+  
+
+
+
+// --------------------------------------------------------------------------
+//
+// Call the ProcessFile(MPedestalCam)
+// 
+Bool_t MJCalibration::Process(MPedestalCam &pedcam)
+{
+    if (!ReadCalibrationCam())
+        return ProcessFile(pedcam);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Execute the task list and the eventloop:
+//
+// - Check if there are fRuns, otherwise return
+// - Check the colour of the files in fRuns (FindColor()), otherwise return
+// - Check for consistency between run numbers and number of files
+// - Add fRuns to MReadMarsFile
+// - Put into MParList:
+//   1) MPedestalCam          (pedcam)
+//   2) MCalibrationQECam     (fQECam)
+//   3) MCalibrationChargeCam (fCalibrationCam)
+//   4) MCalibrationRelTimeCam (fRelTimeCam)   (only if flag fRelTimes is chosen)
+//   5) MBadPixelsCam         (fBadPixels)
+//   6) MCalibrationChargePINDiode
+//   7) MCalibrationChargeBlindPix
+// - Put into the MTaskList:
+//   1)  MReadMarsFile
+//   2)  MBadPixelsMerge
+//   3)  MGeomApply
+//   4)  MExtractor
+//   5)  MExtractPINDiode
+//   6)  MExtractBlindPixel
+//   7)  MExtractTime (only if flag fRelTimes is chosen)
+//   8)  MContinue(MFCosmics)
+//   9)  MFillH("MHCalibrationChargePINDiode", "MExtractedSignalPINDiode")
+//   10) MFillH("MHCalibrationChargeBlindPix", "MExtractedSignalBlindPixel")
+//   11) MFillH("MHCalibrationChargeCam",      "MExtractedSignalCam")
+//   12) MFillH("MHCalibrationChargeCam",      "MExtractedSignalCam")
+//   13) MCalibrationChargeCalc
+//   14) MFillH("MHCalibrationRelTimeCam",     "MArrivalTimeCam") (only if flag fRelTimes is chosen)
+//   15) MCalibrationRelTimeCalc
+// - Execute MEvtLoop
+// - DisplayResult()
+// - WriteResult()
+//
+Bool_t MJCalibration::ProcessFile(MPedestalCam &pedcam)
+{
+  if (!fRuns)
+    {
+      *fLog << err << "No Runs choosen... abort." << endl;
+      return kFALSE;
+    }
+  
+  if (fRuns->GetNumRuns() != fRuns->GetNumEntries())
+    {
+      *fLog << err << "Number of files found doesn't match number of runs... abort." 
+            << fRuns->GetNumRuns() << " vs. " << fRuns->GetNumEntries() << endl;
+      return kFALSE;
+    }
+
+  *fLog << inf;
+  fLog->Separator(GetDescriptor());
+
+  if (!FindColor())
+    return kFALSE;
+  
+  *fLog << "Calculate MCalibrationCam from Runs " << fRuns->GetRunsAsString() << endl;
+  *fLog << endl;
+  
+  // Setup Tasklist
+  MParList plist;
+  MTaskList tlist;
+  plist.AddToList(&tlist);
+  
+  MReadMarsFile read("Events");
+  MRawFileRead rawread(NULL);
+
+  if (fDataCheck)
+  {
+     rawread.AddFiles(*fRuns); 
+     tlist.AddToList(&rawread);
+  }
+  else
+  {
+      read.DisableAutoScheme();
+      static_cast<MRead&>(read).AddFiles(*fRuns);
+      tlist.AddToList(&read);
+  }
+
+  MHCalibrationChargeCam   chargecam;
+
+  plist.AddToList(&pedcam);
+  plist.AddToList(&chargecam);
+  plist.AddToList(&fBadPixels);
+  plist.AddToList(&fQECam);
+  plist.AddToList(&fCalibrationCam);
+  plist.AddToList(&fCalibrationBlindPix);
+  plist.AddToList(&fCalibrationPINDiode);
+  plist.AddToList(&fRelTimeCam);
+
+  MGeomApply               apply;
+  //    MBadPixelsMerge          merge(&fBadPixels);
+  MExtractPINDiode         pinext;
+  MExtractBlindPixel       blindext;
+  MExtractSlidingWindow    extract2;
+  MExtractTimeFastSpline   timespline;
+  MCalibrationChargeCalc   calcalc;
+  calcalc.SetOutputPath(fOutputPath);
+  calcalc.SetOutputFile(Form("%s-ChargeCalibStat.txt",(const char*)fRuns->GetRunsAsFileName()));
+
+  if (fDebug)
+    {
+      chargecam.SetDebug();
+      calcalc.SetDebug();      
+    }
+
+  MCalibrationRelTimeCalc  timecalc;
+  timecalc.SetOutputPath(fOutputPath);
+  timecalc.SetOutputFile(Form("%s-TimeCalibStat.txt",(const char*)fRuns->GetRunsAsFileName()));
+  
+  // 
+  // As long as there are no DM's, have to colour by hand 
+  //
+  calcalc.SetPulserColor(fColor);
+  
+  MFillH fillpin("MHCalibrationChargePINDiode", "MExtractedSignalPINDiode");
+  MFillH fillbnd("MHCalibrationChargeBlindPix", "MExtractedSignalBlindPixel");
+  MFillH fillcam("MHCalibrationChargeCam",      "MExtractedSignalCam");
+  MFillH filltme("MHCalibrationRelTimeCam",     "MArrivalTimeCam");
+  fillpin.SetNameTab("PINDiode");
+  fillbnd.SetNameTab("BlindPix");
+  fillcam.SetNameTab("Charge");
+  filltme.SetNameTab("RelTimes");
+
+  if (fDisplayType == kDataCheckDisplay)
+    {
+      fillcam.SetDrawOption("datacheck");
+      fillbnd.SetDrawOption("datacheck");
+      fillpin.SetDrawOption("datacheck");
+      filltme.SetDrawOption("datacheck");
+    }
+
+  if (fDisplayType == kFullDisplay)
+    {
+      fillcam.SetDrawOption("all");
+      filltme.SetDrawOption("all");
+    }
+  
+  
+  // 
+  // Apply a filter against cosmics
+  // (will have to be needed in the future
+  // when the calibration hardware-trigger is working)
+  // 
+  MFCosmics cosmics;
+  MContinue cont(&cosmics);
+  
+  //    tlist.AddToList(&merge);
+  tlist.AddToList(&apply);
+
+  if (fExtractor)
+    tlist.AddToList(fExtractor);
+  else
+    {
+      *fLog << warn << GetDescriptor() 
+            << ": No extractor has been chosen, take default MExtractSlidingWindow " << endl;
+      tlist.AddToList(&extract2);
+    }
+  
+
+  tlist.AddToList(&pinext);  
+  tlist.AddToList(&blindext);
+  
+  if (fRelTimes)
+    {
+      if (fTimeExtractor)
+        tlist.AddToList(fTimeExtractor);
+      else
+        {
+          *fLog << warn << GetDescriptor() 
+                << ": No extractor has been chosen, take default MTimeExtractSpline " << endl;
+          tlist.AddToList(&timespline);
+        }
+    }
+
+  if (fColor == MCalibrationCam::kCT1)
+    tlist.AddToList(&cont);
+
+  tlist.AddToList(&fillcam);
+
+  if (IsUsePINDiode())
+    tlist.AddToList(&fillpin);
+  if (IsUseBlindPixel())
+    tlist.AddToList(&fillbnd);
+
+  tlist.AddToList(&calcalc);
+
+  if (fRelTimes)
+    {
+      tlist.AddToList(&filltme);
+      tlist.AddToList(&timecalc);
+    }
+  
+
+  // Create and setup the eventloop
+  MEvtLoop evtloop(fName);
+  evtloop.SetParList(&plist);
+  evtloop.SetDisplay(fDisplay);
+  evtloop.SetLogStream(fLog);
+  
+  // Execute first analysis
+  if (!evtloop.Eventloop())
+    {
+      *fLog << err << GetDescriptor() << ": Failed." << endl;
+      return kFALSE;
+    }
+  
+  tlist.PrintStatistics();
+
+  DisplayResult(plist);
+
+  if (!WriteResult())
+    return kFALSE;
+  
+  *fLog << inf << GetDescriptor() << ": Done." << endl;
+  
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Read the following containers from GetOutputFile()
+// - MCalibrationChargeCam
+// - MCalibrationQECam
+// - MBadPixelsCam
+//
+Bool_t MJCalibration::ReadCalibrationCam()
+{
+
+  const TString fname = GetOutputFile();
+  
+  if (gSystem->AccessPathName(fname, kFileExists))
+    {
+      *fLog << err << "Input file " << fname << " doesn't exist." << endl;
+      return kFALSE;
+    }
+  
+  *fLog << inf << "Reading from file: " << fname << endl;
+
+  TFile file(fname, "READ");
+  if (fCalibrationCam.Read()<=0)
+    {
+      *fLog << err << "Unable to read MCalibrationChargeCam from " << fname << endl;
+      return kFALSE;
+    }
+  
+  if (fQECam.Read()<=0)
+    {
+      *fLog << err << "Unable to read MCalibrationQECam from " << fname << endl;
+      return kFALSE;
+    }
+  
+
+  if (fRelTimes)
+    if (fRelTimeCam.Read()<=0)
+      {
+        *fLog << err << "Unable to read MCalibrationRelTimeCam from " << fname << endl;
+        return kFALSE;
+      }
+  
+  if (file.FindKey("MBadPixelsCam"))
+    {
+      MBadPixelsCam bad;
+      if (bad.Read()<=0)
+        {
+          *fLog << err << "Unable to read MBadPixelsCam from " << fname << endl;
+          return kFALSE;
+        }
+      fBadPixels.Merge(bad);
+    }
+  
+  if (fDisplay /*&& !fDisplay->GetCanvas("Pedestals")*/) // FIXME!
+    fDisplay->Read();
+  
+  return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Set the path for output files, written by WriteResult()
+// 
+void MJCalibration::SetOutputPath(const char *path)
+{
+    fOutputPath = path;
+    if (fOutputPath.EndsWith("/"))
+        fOutputPath = fOutputPath(0, fOutputPath.Length()-1);
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the useage of the Blind Pixel device 
+// 
+void MJCalibration::SetUseBlindPixel(const Bool_t b)
+{
+  b ? SETBIT(fDevices,kUseBlindPixel) : CLRBIT(fDevices,kUseBlindPixel);
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the useage of the PIN Diode device 
+// 
+void MJCalibration::SetUsePINDiode(const Bool_t b)
+{
+  b ? SETBIT(fDevices,kUsePINDiode) : CLRBIT(fDevices,kUsePINDiode);
+}
+
+// --------------------------------------------------------------------------
+//
+// Write the result into the output file GetOutputFile(), if fOutputPath exists.
+// 
+// The following containers are written:
+// - MStatusDisplay
+// - MCalibrationChargeCam
+// - MCalibrationChargeBlindPix
+// - MCalibrationQECam
+// - MBadPixelsCam
+//
+Bool_t MJCalibration::WriteResult()
+{
+    if (fOutputPath.IsNull())
+        return kTRUE;
+
+    const TString oname(GetOutputFile());
+
+    *fLog << inf << "Writing to file: " << oname << endl;
+
+    TFile file(oname, "UPDATE");
+
+    if (fDisplay && fDisplay->Write()<=0)
+    {
+        *fLog << err << "Unable to write MStatusDisplay to " << oname << endl;
+        return kFALSE;
+    }
+
+    if (fCalibrationCam.Write()<=0)
+    {
+        *fLog << err << "Unable to write MCalibrationChargeCam to " << oname << endl;
+        return kFALSE;
+    }
+
+    if (fCalibrationBlindPix.Write()<=0)
+    {
+        *fLog << err << "Unable to write MCalibrationChargeBlindPix to " << oname << endl;
+        return kFALSE;
+    }
+
+    if (fCalibrationPINDiode.Write()<=0)
+    {
+        *fLog << err << "Unable to write MCalibrationChargePINDiode to " << oname << endl;
+        return kFALSE;
+    }
+
+    if (fQECam.Write()<=0)
+    {
+        *fLog << err << "Unable to write MCalibrationQECam to " << oname << endl;
+        return kFALSE;
+    }
+
+    if (fRelTimes)
+	if (fRelTimeCam.Write()<=0)
+	{
+	    *fLog << err << "Unable to write MCalibrationQECam to " << oname << endl;
+	    return kFALSE;
+	}
+
+    if (fBadPixels.Write()<=0)
+    {
+        *fLog << err << "Unable to write MBadPixelsCam to " << oname << endl;
+        return kFALSE;
+    }
+
+    return kTRUE;
+
+}
+
Index: /tags/Mars_V0-8-5/Mars/mjobs/MJCalibration.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mjobs/MJCalibration.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mjobs/MJCalibration.h	(revision 9661)
@@ -0,0 +1,114 @@
+#ifndef MARS_MJCalibration
+#define MARS_MJCalibration
+
+#ifndef MARS_MCalibrationChargeCam
+#include "MCalibrationChargeCam.h"
+#endif
+#ifndef MARS_MCalibrationChargeBlindPix
+#include "MCalibrationChargeBlindPix.h"
+#endif
+#ifndef MARS_MCalibrationChargePINDiode
+#include "MCalibrationChargePINDiode.h"
+#endif
+#ifndef MARS_MCalibrationRelTimeCam
+#include "MCalibrationRelTimeCam.h"
+#endif
+#ifndef MARS_MCalibrationQECam
+#include "MCalibrationQECam.h"
+#endif
+#ifndef MARS_MBadPixelsCam
+#include "MBadPixelsCam.h"
+#endif
+
+class MRunIter;
+class MParList;
+class MPedestalCam;
+class MExtractor;
+class MExtractTime;
+class MJCalibration : public MParContainer
+{
+private:
+
+  static const Int_t gkIFAEBoxInaugurationRun;              // Run number of first IFAE box calibration
+
+  TString fOutputPath;                                     // Path to the output files
+  
+  MRunIter       *fRuns;                                   // Calibration files
+  MExtractor     *fExtractor;                              // Signal extractor
+  MExtractTime   *fTimeExtractor;                          // Arrival Time extractor
+  
+  MBadPixelsCam              fBadPixels;                   // Bad Pixels cam, can be set from previous runs
+  MCalibrationChargeCam      fCalibrationCam;              // Calibration conversion factors FADC2Phe
+  MCalibrationChargeBlindPix fCalibrationBlindPix;         // Calibration from Blind Pixel
+  MCalibrationChargePINDiode fCalibrationPINDiode;         // Calibration from PIN Diode
+  MCalibrationQECam          fQECam;                       // Quantum efficiency, can be set from previous runs
+  MCalibrationRelTimeCam     fRelTimeCam;                  // Calibration constants rel. times
+
+  MCalibrationCam::PulserColor_t fColor;                   // Colour of the pulsed LEDs
+
+  enum  Display_t   { kFullDisplay, kDataCheckDisplay, kNormalDisplay }; // Possible Display types
+  
+  Display_t fDisplayType;                                  // Chosen Display type
+
+  enum  Device_t    { kUseBlindPixel, kUsePINDiode  };     // Possible devices for calibration
+
+  Byte_t fDevices;                                         // Bit-field for used devices for calibration
+  
+  Bool_t fRelTimes;                                        // Flag if relative times have to be calibrated
+  Bool_t fDataCheck;                                       // Flag if the data check is run on raw data
+  Bool_t fDebug;
+
+  void   DisplayResult(MParList &plist);
+  Bool_t WriteResult();
+  Bool_t FindColor();
+  
+public:
+
+  MJCalibration(const char *name=NULL, const char *title=NULL);
+  ~MJCalibration() {}
+  
+  const char* GetOutputFile() const;
+
+  MCalibrationChargeCam  &GetCalibrationCam()     { return fCalibrationCam; }  
+  MCalibrationRelTimeCam &GetRelTimeCam()         { return fRelTimeCam;     }
+  MCalibrationQECam      &GetQECam()              { return fQECam;          }    
+  MBadPixelsCam          &GetBadPixels()          { return fBadPixels;      }
+
+  Bool_t IsUseBlindPixel() const;
+  Bool_t IsUsePINDiode()   const;
+  
+  void SetBadPixels(const MBadPixelsCam &bad)     { bad.Copy(fBadPixels);   }
+  void SetExtractor(MExtractor* ext)              { fExtractor = ext; }
+  void SetTimeExtractor(MExtractTime* ext)       { fTimeExtractor = ext; }
+  void SetQECam    (const MCalibrationQECam &qe) { qe.Copy(fQECam);        }    
+  void SetColor    (const MCalibrationCam::PulserColor_t color) { fColor = color; }
+
+  void SetInput(MRunIter *iter) { fRuns=iter; }
+  void SetOutputPath(const char *path=".");
+  
+  // Displays
+  void SetFullDisplay()      { fDisplayType = kFullDisplay;      }
+  void SetDataCheckDisplay() { fDisplayType = kDataCheckDisplay; }
+  void SetNormalDisplay()    { fDisplayType = kNormalDisplay;    }
+
+  // Rel. Time
+  void SetRelTimeCalibration(const Bool_t b=kTRUE) { fRelTimes         = b; }
+
+  // Data Check
+  void SetDataCheck         (const Bool_t b=kTRUE) { fDataCheck        = b; SetDataCheckDisplay(); }
+
+  // Debug
+  void SetDebug             (const Bool_t b=kTRUE) { fDebug           = b; }
+  
+  // Devices
+  void SetUseBlindPixel( const Bool_t b=kTRUE );
+  void SetUsePINDiode  ( const Bool_t b=kTRUE );  
+  
+  Bool_t ReadCalibrationCam();
+  Bool_t ProcessFile( MPedestalCam &pedcam );
+  Bool_t Process    ( MPedestalCam &pedcam );
+  
+  ClassDef(MJCalibration, 0) // Tool to run a calibration per pulser colour and intensity
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mjobs/MJExtractCalibTest.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mjobs/MJExtractCalibTest.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mjobs/MJExtractCalibTest.cc	(revision 9661)
@@ -0,0 +1,526 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug, 04/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MJExtractCalibTest
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MJExtractCalibTest.h"
+
+#include <TFile.h>
+#include <TStyle.h>
+#include <TCanvas.h>
+#include <TSystem.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MRunIter.h"
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MEvtLoop.h"
+
+#include "MHCamera.h"
+
+#include "MPedestalCam.h"
+#include "MBadPixelsCam.h"
+#include "MBadPixelsTreat.h"
+#include "MCerPhotEvt.h"
+#include "MArrivalTime.h"
+#include "MCalibrationChargeCam.h"
+#include "MCalibrationRelTimeCam.h"
+#include "MCalibrationQECam.h"
+#include "MHCamEvent.h"
+
+#include "MReadMarsFile.h"
+#include "MGeomApply.h"
+#include "MExtractSlidingWindow.h"
+#include "MExtractor.h"
+#include "MExtractTime.h"
+#include "MExtractTimeFastSpline.h"
+#include "MFCosmics.h"
+#include "MContinue.h"
+#include "MFillH.h"
+#include "MCalibrate.h"
+#include "MCalibrateRelTimes.h"
+#include "MPedPhotCalc.h"
+
+#include "MStatusDisplay.h"
+
+ClassImp(MJExtractCalibTest);
+
+using namespace std;
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+// Sets fUseCosmicsFilter to kTRUE, fRuns to 0, fExtractor to NULL, fTimeExtractor to NULL
+//
+MJExtractCalibTest::MJExtractCalibTest(const char *name, const char *title) 
+    : fUseCosmicsFilter(kTRUE), fRuns(NULL), fExtractor(NULL), fTimeExtractor(NULL)
+{
+    fName  = name  ? name  : "MJExtractCalibTest";
+    fTitle = title ? title : "Tool to extract, calibrate and test signals from a file";
+}
+
+
+void MJExtractCalibTest::DisplayResult(MParList &plist)
+{
+  if (!fDisplay)
+    return;
+  
+  //
+  // Update display
+  //
+  TString title = fDisplay->GetTitle();
+  title += "--  Extraction-Calibration-Test ";
+  title += fRuns->GetRunsAsString();
+  title += "  --";
+  fDisplay->SetTitle(title);
+
+  //
+  // Get container from list
+  //
+  MGeomCam &geomcam = *(MGeomCam*)plist.FindObject("MGeomCam");
+  
+  // Create histograms to display
+  MHCamera disp1 (geomcam, "Test;Photons",           "Mean of calibrated Photons");
+  MHCamera disp2 (geomcam, "Test;SigmaPhotons",      "Sigma of calibrated photons");
+  MHCamera disp3 (geomcam, "Test;PhotonsPerArea",    "Equiv. Cherenkov Photons per Area");
+  MHCamera disp4 (geomcam, "Test;SigmaPhotPerArea",  "Sigma equiv. Cher. Photons per Area");
+
+  // Fitted charge means and sigmas
+  disp1.SetCamContent(fTestCam,  0);
+  disp1.SetCamError(  fTestCam,  1);
+  disp2.SetCamContent(fTestCam,  2);
+  disp2.SetCamError(  fTestCam,  3);
+  disp3.SetCamContent(fTestCam,  7);
+  disp3.SetCamError(  fTestCam,  8);
+  disp4.SetCamContent(fTestCam,  9);
+  disp4.SetCamError(  fTestCam,  10);
+
+  disp1.SetYTitle("Photons");
+  disp2.SetYTitle("\\sigma_{phot}");
+  disp3.SetYTitle("Photons per Area [mm^{-2}]");
+  disp4.SetYTitle("\\sigma_{phot} per Area [mm^{-2}]");
+  
+  gStyle->SetOptStat(1111);
+  gStyle->SetOptFit();
+
+  TCanvas &c = fDisplay->AddTab("TestCharges");
+  c.Divide(4,4);
+
+  disp1.CamDraw(c, 1, 4, 2, 1);
+  disp2.CamDraw(c, 2, 4, 2, 1);        
+  disp3.CamDraw(c, 3, 4, 1, 1);        
+  disp4.CamDraw(c, 4, 4, 2, 1);        
+
+  return;
+
+}
+
+
+void MJExtractCalibTest::DisplayResultT(MParList &plist)
+{
+  if (!fDisplay)
+    return;
+  
+  //
+  // Update display
+  //
+  TString title = fDisplay->GetTitle();
+  title += "--  Extraction-Calibration-Test-Time";
+  title += fRuns->GetRunsAsString();
+  title += "  --";
+  fDisplay->SetTitle(title);
+
+  //
+  // Get container from list
+  //
+  MGeomCam &geomcam = *(MGeomCam*)plist.FindObject("MGeomCam");
+  
+  // Create histograms to display
+  MHCamera disp1 (geomcam, "Test;Arr.Times",           "Mean of calibrated Arr.Times");
+  MHCamera disp2 (geomcam, "Test;SigmaArr.Times",      "Sigma of calibrated Arr.Times");
+
+  // Fitted charge means and sigmas
+  disp1.SetCamContent(fTestTimeCam,  0);
+  disp1.SetCamError(  fTestTimeCam,  1);
+  disp2.SetCamContent(fTestTimeCam,  2);
+  disp2.SetCamError(  fTestTimeCam,  3);
+
+  disp1.SetYTitle("Mean Arr.Times [FADC units]");
+  disp2.SetYTitle("\\sigma_{t} [FADC units]");
+  
+  gStyle->SetOptStat(1111);
+  gStyle->SetOptFit();
+
+  TCanvas &c = fDisplay->AddTab("TestTimes");
+  c.Divide(2,4);
+
+  disp1.CamDraw(c, 1, 2,  5, 1);
+  disp2.CamDraw(c, 2, 2,  5, 1);        
+
+  return;
+
+}
+
+
+void MJExtractCalibTest::SetOutputPath(const char *path)
+{
+  fOutputPath = path;
+  if (fOutputPath.EndsWith("/"))
+    fOutputPath = fOutputPath(0, fOutputPath.Length()-1);
+}
+
+const char* MJExtractCalibTest::GetOutputFile() const
+{
+  if (!fRuns)
+    return "";
+  
+  return Form("%s/%s-Test.root", (const char*)fOutputPath, (const char*)fRuns->GetRunsAsFileName());
+}
+
+
+Bool_t MJExtractCalibTest::ProcessD(MPedestalCam &pedcam, MCalibrationChargeCam &calcam, MCalibrationQECam &qecam)
+{
+    // const TString fname = GetOutputFile();
+  
+//  if (gSystem->AccessPathName(fname, kFileExists))
+    return ProcessFileD(pedcam,calcam,qecam);
+  
+    // return kTRUE;
+}
+
+Bool_t MJExtractCalibTest::ProcessFileD(MPedestalCam &pedcam, MCalibrationChargeCam &calcam, MCalibrationQECam &qecam)
+{
+  if (!fRuns)
+    {
+      *fLog << err << "No Runs choosen... abort." << endl;
+      return kFALSE;
+    }
+  if (fRuns->GetNumRuns() != fRuns->GetNumEntries())
+    {
+      *fLog << err << "Number of files found doesn't match number of runs... abort." << endl;
+      return kFALSE;
+    }
+  
+  *fLog << inf;
+  fLog->Separator(GetDescriptor());
+  *fLog << "Calculate MExtractedSignalCam from Runs " << fRuns->GetRunsAsString() << endl;
+  *fLog << endl;
+  
+  MCerPhotEvt    cerphot;
+  MPedPhotCam    pedphot;
+
+  // Setup Lists
+  MParList plist;
+  plist.AddToList(&pedcam);
+  plist.AddToList(&calcam);
+  plist.AddToList(&qecam);
+  plist.AddToList(&cerphot);
+  plist.AddToList(&pedphot);
+  plist.AddToList(&fTestCam);
+  plist.AddToList(&fBadPixels);
+
+  MTaskList tlist;
+  plist.AddToList(&tlist);
+
+  // Setup Task-lists
+  MReadMarsFile read("Events");
+  read.DisableAutoScheme();
+  static_cast<MRead&>(read).AddFiles(*fRuns);
+  
+  MGeomApply            apply; // Only necessary to craete geometry
+  MExtractSlidingWindow extract2;
+  MCalibrate            photcalc;
+  photcalc.SetCalibrationMode(MCalibrate::kFfactor);
+  MPedPhotCalc          pedphotcalc;  
+  MBadPixelsTreat       badtreat;
+  badtreat.SetUseInterpolation();
+
+  MHCamEvent evt("ExtSignal");
+  evt.SetType(0);
+  MFillH fill(&evt, "MExtractedSignalCam");
+  
+  MFillH fillcam("MHCalibrationTestCam", "MCerPhotEvt");
+  fillcam.SetNameTab("Test");
+
+  MFCosmics cosmics;
+  MContinue cont(&cosmics);
+  
+  tlist.AddToList(&read);
+  tlist.AddToList(&apply);
+
+  if (fExtractor)
+    tlist.AddToList(fExtractor);
+  else
+  {
+      *fLog << warn << GetDescriptor() 
+            << ": No extractor has been chosen, take default MExtractSlidingWindow " << endl;
+      tlist.AddToList(&extract2);
+  }
+
+
+  if (fUseCosmicsFilter)
+    tlist.AddToList(&cont);
+
+  tlist.AddToList(&fill);
+  tlist.AddToList(&photcalc);
+  tlist.AddToList(&pedphotcalc);
+  //  tlist.AddToList(&badtreat);
+  tlist.AddToList(&fillcam);
+  
+  // Create and setup the eventloop
+  MEvtLoop evtloop(fName);
+  evtloop.SetParList(&plist);
+  evtloop.SetDisplay(fDisplay);
+  evtloop.SetLogStream(fLog);
+  
+  // Execute first analysis
+  if (!evtloop.Eventloop())
+    {
+      *fLog << err << GetDescriptor() << ": Failed." << endl;
+      return kFALSE;
+    }
+  
+  tlist.PrintStatistics();
+  
+  DisplayResult(plist);
+
+  if (!WriteResultD())
+    return kFALSE;
+
+  *fLog << inf << GetDescriptor() << ": Done." << endl;
+  
+  return kTRUE;
+}
+
+Bool_t MJExtractCalibTest::ProcessT(MPedestalCam &pedcam, MCalibrationRelTimeCam &relcam)
+{
+
+//  const TString fname = GetOutputFile();
+  
+//  if (gSystem->AccessPathName(fname, kFileExists))
+    return ProcessFileT(pedcam,relcam);
+  
+//  return kTRUE;
+}
+
+Bool_t MJExtractCalibTest::ProcessFileT(MPedestalCam &pedcam, MCalibrationRelTimeCam &relcam)
+{
+
+  if (!fRuns)
+    {
+      *fLog << err << "No Runs choosen... abort." << endl;
+      return kFALSE;
+    }
+  if (fRuns->GetNumRuns() != fRuns->GetNumEntries())
+    {
+      *fLog << err << "Number of files found doesn't match number of runs... abort." << endl;
+      return kFALSE;
+    }
+  
+  *fLog << inf;
+  fLog->Separator(GetDescriptor());
+  *fLog << "Calculate MExtractedSignalCam from Runs " << fRuns->GetRunsAsString() << endl;
+  *fLog << endl;
+  
+  MArrivalTime     arrtime;
+
+  // Setup Lists
+  MParList plist;
+  plist.AddToList(&pedcam);
+  plist.AddToList(&relcam);
+  plist.AddToList(&arrtime);
+  plist.AddToList(&fTestTimeCam);
+  plist.AddToList(&fBadPixels);
+  
+  MTaskList tlist;
+  plist.AddToList(&tlist);
+
+  // Setup Task-lists
+  MReadMarsFile read("Events");
+  read.DisableAutoScheme();
+  static_cast<MRead&>(read).AddFiles(*fRuns);
+  
+  MGeomApply             apply; // Only necessary to craete geometry
+  MExtractTimeFastSpline extract;
+  MExtractSlidingWindow  extcharge; // Only for the cosmics filter
+  MCalibrateRelTimes     timecalc;
+  MFCosmics              cosmics;
+  MContinue              cont(&cosmics);
+
+  MHCamEvent evt("ExtTimes");
+  evt.SetType(0);
+  MFillH fill(&evt, "MArrivalTimeCam");
+  
+  MFillH fillcam("MHCalibrationTestTimeCam", "MArrivalTime");
+  fillcam.SetNameTab("TestTime");
+
+  tlist.AddToList(&read);
+  tlist.AddToList(&apply);
+
+  if (fTimeExtractor)
+    tlist.AddToList(fTimeExtractor);
+  else
+  {
+      *fLog << warn << GetDescriptor() 
+            << ": No extractor has been chosen, take default MExtractTimeFastSpline " << endl;
+      tlist.AddToList(&extract);
+  }
+
+  tlist.AddToList(&extcharge);
+  tlist.AddToList(&cont);
+  tlist.AddToList(&fill);
+  tlist.AddToList(&timecalc);
+  tlist.AddToList(&fillcam);
+  
+  // Create and setup the eventloop
+  MEvtLoop evtloop(fName);
+  evtloop.SetParList(&plist);
+  evtloop.SetDisplay(fDisplay);
+  evtloop.SetLogStream(fLog);
+  
+  // Execute first analysis
+  if (!evtloop.Eventloop())
+    {
+      *fLog << err << GetDescriptor() << ": Failed." << endl;
+      return kFALSE;
+    }
+  
+  tlist.PrintStatistics();
+  
+  DisplayResultT(plist);
+
+  if (!WriteResultT())
+    return kFALSE;
+
+  *fLog << inf << GetDescriptor() << ": Done." << endl;
+  
+  return kTRUE;
+}
+
+
+Bool_t MJExtractCalibTest::ReadPedPhotCam()
+{
+
+  const TString fname = GetOutputFile();
+  
+  if (gSystem->AccessPathName(fname, kFileExists))
+    {
+      *fLog << err << "Input file " << fname << " doesn't exist." << endl;
+      return kFALSE;
+    }
+  
+  *fLog << inf << "Reading from file: " << fname << endl;
+  
+  TFile file(fname, "READ");
+  if (fPedPhotCam.Read()<=0)
+    {
+      *fLog << "Unable to read MPedPhotCam from " << fname << endl;
+      return kFALSE;
+    }
+
+  if (file.FindKey("MBadPixelsCam"))
+    {
+      MBadPixelsCam bad;
+      if (bad.Read()<=0)
+        {
+          *fLog << "Unable to read MBadPixelsCam from " << fname << endl;
+          return kFALSE;
+        }
+      fBadPixels.Merge(bad);
+    }
+  
+  if (fDisplay /*&& !fDisplay->GetCanvas("Pedestals")*/) // FIXME!
+    fDisplay->Read();
+  
+  return kTRUE;
+}
+
+Bool_t MJExtractCalibTest::WriteResultD()
+{
+    
+    if (fOutputPath.IsNull())
+        return kTRUE;
+    
+    const TString oname(GetOutputFile());
+
+    *fLog << inf << "Writing to file: " << oname << endl;
+    
+    TFile file(oname, "UPDATE");
+    
+    if (fDisplay && fDisplay->Write()<=0)
+    {
+        *fLog << err << "Unable to write MStatusDisplay to " << oname << endl;
+        return kFALSE;
+    }
+
+    if (fPedPhotCam.Write()<=0)
+    {
+        *fLog << err << "Unable to write MPedPhotCam to " << oname << endl;
+        return kFALSE;
+    }
+
+    if (fTestCam.Write()<=0)
+    {
+        *fLog << err << "Unable to write MHCalibrationTestCam to " << oname << endl;
+        return kFALSE;
+    }
+
+    return kTRUE;
+
+}
+
+Bool_t MJExtractCalibTest::WriteResultT()
+{
+    
+    if (fOutputPath.IsNull())
+        return kTRUE;
+    
+    const TString oname(GetOutputFile());
+
+    *fLog << inf << "Writing to file: " << oname << endl;
+    
+    TFile file(oname, "UPDATE");
+    
+    if (fDisplay && fDisplay->Write()<=0)
+    {
+        *fLog << err << "Unable to write MStatusDisplay to " << oname << endl;
+        return kFALSE;
+    }
+
+    if (fTestTimeCam.Write()<=0)
+    {
+        *fLog << err << "Unable to write MHCalibrationTestTimeCam to " << oname << endl;
+        return kFALSE;
+    }
+
+    return kTRUE;
+
+}
+
+
Index: /tags/Mars_V0-8-5/Mars/mjobs/MJExtractCalibTest.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mjobs/MJExtractCalibTest.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mjobs/MJExtractCalibTest.h	(revision 9661)
@@ -0,0 +1,76 @@
+#ifndef MARS_MJExtractCalibTest
+#define MARS_MJExtractCalibTest
+
+#ifndef MARS_MHCalibrationTestCam
+#include "MHCalibrationTestCam.h"
+#endif
+#ifndef MARS_MHCalibrationTestTimeCam
+#include "MHCalibrationTestTimeCam.h"
+#endif
+#ifndef MARS_MPedPhotCam
+#include "MPedPhotCam.h"
+#endif
+#ifndef MARS_MBadPixelsCam
+#include "MBadPixelsCam.h"
+#endif
+
+class MRunIter;
+class MParList;
+class MPedestalCam;
+class MCalibrationRelTimeCam;
+class MCalibrationChargeCam;
+class MCalibrationQECam;
+class MExtractor;
+class MExtractTime;
+class MJExtractCalibTest : public MParContainer
+{
+private:
+
+  TString fOutputPath;
+  Bool_t  fUseCosmicsFilter;
+  
+  MRunIter     *fRuns;                       // Data files
+  MExtractor   *fExtractor;                  // Signal extractor
+  MExtractTime *fTimeExtractor;              // Arrival time extractor  
+  
+  MBadPixelsCam            fBadPixels;
+  MHCalibrationTestCam     fTestCam;
+  MHCalibrationTestTimeCam fTestTimeCam;
+  MPedPhotCam              fPedPhotCam;
+
+  Bool_t ReadPedPhotCam();
+  
+  void   DisplayResult(MParList &plist);
+  void   DisplayResultT(MParList &plist);
+
+  Bool_t WriteResultD();
+  Bool_t WriteResultT();
+  
+  Bool_t ProcessFileD(MPedestalCam &pedcam, MCalibrationChargeCam &calcam, MCalibrationQECam &qecam);
+  Bool_t ProcessFileT(MPedestalCam &pedcam, MCalibrationRelTimeCam &relcam);  
+
+public:
+  MJExtractCalibTest(const char *name=NULL, const char *title=NULL);
+  
+  void SetInput(MRunIter *iter) { fRuns = iter; }
+  void SetOutputPath(const char *path=".");
+  
+  const char* GetOutputFile() const;
+  
+  MHCalibrationTestCam     &GetTestCam()      { return fTestCam; }
+  MHCalibrationTestTimeCam &GetTestTimeCam()  { return fTestTimeCam; }  
+  MPedPhotCam          &GetPedPhotCam() { return fPedPhotCam; }
+  const MBadPixelsCam &GetBadPixels()  const { return fBadPixels; }
+  
+  void SetExtractor(MExtractor* ext)              { fExtractor = ext; }
+  void SetTimeExtractor(MExtractTime* ext)         { fTimeExtractor = ext; }
+  void SetBadPixels(const MBadPixelsCam &bad) { bad.Copy(fBadPixels); }
+  void SetUseCosmicsFilter( const Bool_t b )    { fUseCosmicsFilter = b;  }
+     
+  Bool_t ProcessD(MPedestalCam &pedcam, MCalibrationChargeCam &calcam, MCalibrationQECam &qecam);
+  Bool_t ProcessT(MPedestalCam &pedcam, MCalibrationRelTimeCam &relcam);  
+  
+  ClassDef(MJExtractCalibTest, 0) // Tool to extract, calibrate and test the signal 
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mjobs/MJExtractSignal.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mjobs/MJExtractSignal.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mjobs/MJExtractSignal.cc	(revision 9661)
@@ -0,0 +1,538 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MJExtractSignal
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MJExtractSignal.h"
+
+#include <TFile.h>
+#include <TStyle.h>
+#include <TCanvas.h>
+#include <TSystem.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MRunIter.h"
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MEvtLoop.h"
+#include "MPrint.h"
+
+#include "MHCamera.h"
+
+#include "MPedestalCam.h"
+#include "MCalibrationChargeCam.h"
+#include "MCalibrationQECam.h"
+#include "MHCamEvent.h"
+
+#include "MReadMarsFile.h"
+#include "MGeomApply.h"
+#include "MBadPixelsMerge.h"
+#include "MExtractSignal.h"
+#include "MFillH.h"
+#include "MCalibrate.h"
+#include "MPedPhotCalc.h"
+#include "MWriteRootFile.h"
+
+#include "MExtractSlidingWindow.h"
+#include "MExtractor.h"
+#include "MExtractTime.h"
+#include "MExtractTimeFastSpline.h"
+
+#include "MJExtractSignal.h"
+#include "MStatusDisplay.h"
+
+
+ClassImp(MJExtractSignal);
+
+using namespace std;
+
+MJExtractSignal::MJExtractSignal(const char *name, const char *title)
+    : fRuns(0), fExtractor(NULL), fTimeExtractor(NULL)
+{
+    fName  = name  ? name  : "MJExtractSignal";
+    fTitle = title ? title : "Tool to create a pedestal file (MPedestalCam)";
+}
+
+Bool_t MJExtractSignal::WriteResult()
+{
+    if (fOutputPath.IsNull())
+        return kTRUE;
+
+    const TString oname = GetOutputFileP();
+
+    *fLog << inf << "Writing to file: " << oname << endl;
+
+    TFile file(oname, "UPDATE");
+
+    if (fDisplay && fDisplay->Write()<=0)
+    {
+        *fLog << err << "Unable to write MStatusDisplay to " << oname << endl;
+        return kFALSE;
+    }
+
+    if (fPedPhotCam.Write()<=0)
+    {
+        *fLog << err << "Unable to write MPedPhotCam to " << oname << endl;
+        return kFALSE;
+    }
+
+    if (fBadPixels.Write()<=0)
+    {
+        *fLog << err << "Unable to write MBadPixelsCam to " << oname << endl;
+        return kFALSE;
+    }
+
+    return kTRUE;
+
+}
+
+void MJExtractSignal::SetOutputPath(const char *path)
+{
+    fOutputPath = path;
+    if (fOutputPath.EndsWith("/"))
+        fOutputPath = fOutputPath(0, fOutputPath.Length()-1);
+}
+
+TString MJExtractSignal::GetOutputFileD() const
+{
+    if (!fRuns)
+        return "";
+
+    return Form("%s/%s-F3.root", (const char*)fOutputPath, (const char*)fRuns->GetRunsAsFileName());
+}
+TString MJExtractSignal::GetOutputFileP() const
+{
+    if (!fRuns)
+        return "";
+
+    return Form("%s/%s-F2.root", (const char*)fOutputPath, (const char*)fRuns->GetRunsAsFileName());
+}
+
+Bool_t MJExtractSignal::ProcessD(MPedestalCam &pedcam)
+{
+    const TString fname = GetOutputFileD();
+
+    if (gSystem->AccessPathName(fname, kFileExists))
+        return ProcessFileD(pedcam);
+
+    return kTRUE;
+}
+
+Bool_t MJExtractSignal::ProcessFileD(MPedestalCam &pedcam)
+{
+
+  if (!fRuns)
+    {
+      *fLog << err << "No Runs choosen... abort." << endl;
+      return kFALSE;
+    }
+  if (fRuns->GetNumRuns() != fRuns->GetNumEntries())
+    {
+        *fLog << err << "Number of files found doesn't match number of runs... abort." << endl;
+        return kFALSE;
+    }
+  
+  *fLog << inf;
+  fLog->Separator(GetDescriptor());
+  *fLog << "Calculate MExtractedSignalCam from Runs " << fRuns->GetRunsAsString() << endl;
+  *fLog << endl;
+  
+  // Setup Lists
+  MParList plist;
+  plist.AddToList(&pedcam);
+  
+  MTaskList tlist;
+  plist.AddToList(&tlist);
+
+  // Setup Parameters
+  
+  // Make sure, that at least an empty MBadPixelsCam is available
+  // This is necessary for input which don't contain a MBadPixelsCam
+  MBadPixelsCam badcam;
+  plist.AddToList(&badcam);
+  
+  // Setup Task-lists
+  MReadMarsFile read("Events");
+  read.DisableAutoScheme();
+  static_cast<MRead&>(read).AddFiles(*fRuns);
+  
+  MGeomApply               apply; // Only necessary to craete geometry
+  MBadPixelsMerge          merge(&fBadPixels);
+  MExtractTimeFastSpline   exttime;
+  MExtractSlidingWindow    extcharge; // Only for the cosmics filter
+  
+  MHCamEvent evt("ExtSignal");
+  evt.SetType(0);
+  MFillH fill(&evt, "MExtractedSignalCam");
+  
+  MWriteRootFile write(GetOutputFileD(), "RECREATE", fRuns->GetRunsAsString(), 2);
+  write.AddContainer("MExtractedSignalCam", "Events");
+  write.AddContainer("MArrivalTimeCam",     "Events");
+  write.AddContainer("MTime",               "Events");
+  write.AddContainer("MRawEvtHeader",       "Events");
+  write.AddContainer("MPedestalCam",        "RunHeaders");
+  write.AddContainer("MRawRunHeader",       "RunHeaders");
+  write.AddContainer("MBadPixelsCam",       "RunHeaders");
+  
+  tlist.AddToList(&read);
+  tlist.AddToList(&apply);
+  tlist.AddToList(&merge);
+  
+  if (fTimeExtractor)
+    tlist.AddToList(fTimeExtractor);
+  else
+  {
+      *fLog << warn << GetDescriptor() 
+            << ": No extractor has been chosen, take default MExtractTimeFastSpline " << endl;
+      tlist.AddToList(&exttime);
+  }
+
+  if (fExtractor)
+    tlist.AddToList(fExtractor);
+  else
+  {
+      *fLog << warn << GetDescriptor() 
+            << ": No extractor has been chosen, take default MExtractSlidingWindow " << endl;
+      tlist.AddToList(&extcharge);
+  }
+
+//  MPrint print("MExtractedSignalCam");
+//  tlist.AddToList(&print);
+  
+  if (TestBit(kEnableGraphicalOutput))
+    tlist.AddToList(&fill);
+  tlist.AddToList(&write);
+  
+  // Create and setup the eventloop
+  MEvtLoop evtloop(fName);
+  evtloop.SetParList(&plist);
+  evtloop.SetDisplay(fDisplay);
+  evtloop.SetLogStream(fLog);
+  
+  // Execute first analysis
+  if (!evtloop.Eventloop())
+    {
+      *fLog << err << GetDescriptor() << ": Failed." << endl;
+      return kFALSE;
+    }
+  
+  tlist.PrintStatistics();
+  
+  //DisplayResult(plist);
+  
+  //if (!WriteResult())
+  //    return kFALSE;
+  
+  *fLog << inf << GetDescriptor() << ": Done." << endl;
+  
+  return kTRUE;
+}
+
+Bool_t MJExtractSignal::ReadPedPhotCam()
+{
+    const TString fname = GetOutputFileP();
+
+    if (gSystem->AccessPathName(fname, kFileExists))
+    {
+        *fLog << err << "Input file " << fname << " doesn't exist." << endl;
+        return kFALSE;
+    }
+
+    *fLog << inf << "Reading from file: " << fname << endl;
+
+    TFile file(fname, "READ");
+    if (fPedPhotCam.Read()<=0)
+    {
+        *fLog << "Unable to read MPedPhotCam from " << fname << endl;
+        return kFALSE;
+    }
+
+    if (file.FindKey("MBadPixelsCam"))
+    {
+        MBadPixelsCam bad;
+        if (bad.Read()<=0)
+        {
+            *fLog << "Unable to read MBadPixelsCam from " << fname << endl;
+            return kFALSE;
+        }
+        fBadPixels.Merge(bad);
+    }
+
+    if (fDisplay /*&& !fDisplay->GetCanvas("Pedestals")*/) // FIXME!
+        fDisplay->Read();
+
+    return kTRUE;
+}
+
+Bool_t MJExtractSignal::ProcessP(MPedestalCam &pedcam, MCalibrationChargeCam &calcam, MCalibrationQECam &qecam)
+{
+    if (!ReadPedPhotCam())
+        return ProcessFileP(pedcam, calcam, qecam);
+
+    return kTRUE;
+}
+
+Bool_t MJExtractSignal::ProcessFileP(MPedestalCam &pedcam, MCalibrationChargeCam &calcam, MCalibrationQECam &qecam)
+{
+    if (!fRuns)
+    {
+        *fLog << err << "No Runs choosen... abort." << endl;
+        return kFALSE;
+    }
+    if (fRuns->GetNumRuns() != fRuns->GetNumEntries())
+    {
+        *fLog << err << "Number of files found doesn't match number of runs... abort." << endl;
+        return kFALSE;
+    }
+
+    *fLog << inf;
+    fLog->Separator(GetDescriptor());
+    *fLog << "Calculate MExtractedSignalCam from Runs " << fRuns->GetRunsAsString() << endl;
+    *fLog << endl;
+
+    MReadMarsFile read("Events");
+    read.DisableAutoScheme();
+    static_cast<MRead&>(read).AddFiles(*fRuns);
+
+    // Setup Tasklist
+    MParList plist;
+    plist.AddToList(&pedcam);
+    plist.AddToList(&calcam);
+    plist.AddToList(&qecam);
+    plist.AddToList(&fPedPhotCam);
+    plist.AddToList(&fBadPixels);
+
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    MGeomApply      apply; // Only necessary to craete geometry
+    MBadPixelsMerge merge(&fBadPixels);
+    MExtractSignal  extract;
+    MCalibrate      calib;
+    MPedPhotCalc    calc;
+
+    MHCamEvent evt1("ExtOffset");
+    MHCamEvent evt2("CalOffset");
+    evt1.SetType(0);
+    evt2.SetType(0);
+    MFillH fill1(&evt1, "MExtractedSignalCam", "FillExtractedSignal");
+    MFillH fill2(&evt2, "MCerPhotEvt",         "FillCerPhotEvt");
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&apply);
+    tlist.AddToList(&merge);
+    tlist.AddToList(&extract);
+    if (TestBit(kEnableGraphicalOutput))
+        tlist.AddToList(&fill1);
+    tlist.AddToList(&calib);
+    tlist.AddToList(&calc);
+    if (TestBit(kEnableGraphicalOutput))
+        tlist.AddToList(&fill2);
+
+    // Create and setup the eventloop
+    MEvtLoop evtloop(fName);
+    evtloop.SetParList(&plist);
+    evtloop.SetDisplay(fDisplay);
+    evtloop.SetLogStream(fLog);
+
+    // Execute first analysis
+    if (!evtloop.Eventloop())
+    {
+        *fLog << err << GetDescriptor() << ": Failed." << endl;
+        return kFALSE;
+    }
+
+    tlist.PrintStatistics();
+
+    //DisplayResult(plist);
+
+    if (!WriteResult())
+        return kFALSE;
+
+    *fLog << inf << GetDescriptor() << ": Done." << endl;
+
+    return kTRUE;
+}
+
+/*
+Bool_t MJExtractSignal::ProcessFile(MPedestalCam *pedcam, MCalibrationChargeCam *calcam)
+{
+    if (!fRuns)
+    {
+        *fLog << err << "No Runs choosen... abort." << endl;
+        return kFALSE;
+    }
+    if (fRuns->GetNumRuns() != fRuns->GetNumEntries())
+    {
+        *fLog << err << "Number of files found doesn't match number of runs... abort." << endl;
+        return kFALSE;
+    }
+
+    Int_t type = 0;
+    if (pedcam &&  calcam) type = 2;
+    if (pedcam && !calcam) type = 3;
+
+    *fLog << inf;
+    fLog->Separator(GetDescriptor());
+    *fLog << "Calculating from Runs " << fRuns->GetRunsAsString() << endl;
+    *fLog << endl;
+
+    MReadMarsFile read("Events");
+    read.DisableAutoScheme();
+    static_cast<MRead&>(read).AddFiles(*fRuns);
+
+    // Setup Tasklist
+    MParList plist;
+    switch (type)
+    {
+    case 2:
+        plist.AddToList(calcam);
+        plist.AddToList(&fPedPhotCam);
+    case 3:
+        plist.AddToList(pedcam);
+    }
+
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    MGeomApply     apply; // Only necessary to craete geometry
+    MExtractSignal extract;
+    MCalibrate     calib;
+    MPedPhotCalc   calc;
+
+
+    MHCamEvent evt1("ExtOffset");
+    MHCamEvent evt2("CalOffset");
+    evt1.SetType(0);
+    evt2.SetType(0);
+    MFillH fill1(&evt1, "MExtractedSignalCam", "FillExtractedSignal");
+    MFillH fill2(&evt2, "MCerPhotEvt",         "FillCerPhotEvt");
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&apply);
+    tlist.AddToList(&extract);
+    if (TestBit(kEnableGraphicalOutput))
+        tlist.AddToList(&fill1);
+    tlist.AddToList(&calib);
+    tlist.AddToList(&calc);
+    if (TestBit(kEnableGraphicalOutput))
+        tlist.AddToList(&fill2);
+
+
+    MHCamEvent evt("ExtSignal");
+    evt.SetType(0);
+    MFillH fill(&evt, "MExtractedSignalCam");
+
+    MWriteRootFile write(GetOutputFileD(), "RECREATE", fRuns->GetRunsAsString(), 2);
+    write.AddContainer("MExtractedSignalCam", "Events");
+    write.AddContainer("MTime",               "Events");
+    write.AddContainer("MRawRunHeader",       "RunHeaders");
+    write.AddContainer("MPedestalCam",        "RunHeaders");
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&apply);
+    tlist.AddToList(&extract);
+    if (TestBit(kEnableGraphicalOutput))
+        tlist.AddToList(&fill);
+    tlist.AddToList(&write);
+
+    // Create and setup the eventloop
+    MEvtLoop evtloop(fName);
+    evtloop.SetParList(&plist);
+    evtloop.SetDisplay(fDisplay);
+    evtloop.SetLogStream(fLog);
+
+    // Execute first analysis
+    if (!evtloop.Eventloop())
+    {
+        *fLog << err << GetDescriptor() << ": Failed." << endl;
+        return kFALSE;
+    }
+
+    tlist.PrintStatistics();
+
+    //DisplayResult(plist);
+
+    //if (!WriteResult())
+    //    return kFALSE;
+
+    *fLog << inf << GetDescriptor() << ": Done." << endl;
+
+    return kTRUE;
+
+
+    // ------------------------------------------------------
+
+    MGeomApply     apply; // Only necessary to craete geometry
+    MExtractSignal extract;
+    MCalibrate     calib;
+    MPedPhotCalc   calc;
+
+    MHCamEvent evt1("ExtOffset");
+    MHCamEvent evt2("CalOffset");
+    evt1.SetType(0);
+    evt2.SetType(0);
+    MFillH fill1(&evt1, "MExtractedSignalCam", "FillExtractedSignal");
+    MFillH fill2(&evt2, "MCerPhotEvt",         "FillCerPhotEvt");
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&apply);
+    tlist.AddToList(&extract);
+    if (TestBit(kEnableGraphicalOutput))
+        tlist.AddToList(&fill1);
+    tlist.AddToList(&calib);
+    tlist.AddToList(&calc);
+    if (TestBit(kEnableGraphicalOutput))
+        tlist.AddToList(&fill2);
+
+    // Create and setup the eventloop
+    MEvtLoop evtloop(fName);
+    evtloop.SetParList(&plist);
+    evtloop.SetDisplay(fDisplay);
+    evtloop.SetLogStream(fLog);
+
+    // Execute first analysis
+    if (!evtloop.Eventloop())
+    {
+        *fLog << err << GetDescriptor() << ": Failed." << endl;
+        return kFALSE;
+    }
+
+    tlist.PrintStatistics();
+
+    //DisplayResult(plist);
+
+    if (!WriteResult())
+        return kFALSE;
+
+    *fLog << inf << GetDescriptor() << ": Done." << endl;
+
+    return kTRUE;
+    }
+    */
Index: /tags/Mars_V0-8-5/Mars/mjobs/MJExtractSignal.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mjobs/MJExtractSignal.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mjobs/MJExtractSignal.h	(revision 9661)
@@ -0,0 +1,65 @@
+#ifndef MARS_MJExtractSignal
+#define MARS_MJExtractSignal
+
+#ifndef MARS_MPedPhotCam
+#include "MPedPhotCam.h"
+#endif
+#ifndef MARS_MBadPixelsCam
+#include "MBadPixelsCam.h"
+#endif
+
+class TCanvas;
+class MHCamera;
+class MCamEvent;
+class MRunIter;
+class MParList;
+class MPedestalCam;
+class MCalibrationChargeCam;
+class MCalibrationQECam;
+class MExtractor;
+class MExtractTime;
+
+class MJExtractSignal : public MParContainer
+{
+private:
+    TString fOutputPath;
+
+    MRunIter *fRuns;
+    
+    MExtractor   *fExtractor;                  // Signal extractor
+    MExtractTime *fTimeExtractor;              // Arrival time extractor  
+
+    MPedPhotCam   fPedPhotCam;
+    MBadPixelsCam fBadPixels;
+
+    void   DisplayResult(MParList &plist);
+    Bool_t WriteResult();
+
+    Bool_t ReadPedPhotCam();
+
+    Bool_t ProcessFileD(MPedestalCam &pedcam);
+    Bool_t ProcessFileP(MPedestalCam &pedcam, MCalibrationChargeCam &calcam, MCalibrationQECam &qecam);
+
+public:
+    MJExtractSignal(const char *name=NULL, const char *title=NULL);
+
+    void SetInput(MRunIter *iter) { fRuns = iter; }
+    void SetOutputPath(const char *path=".");
+
+    TString GetOutputFileP() const;
+    TString GetOutputFileD() const;
+
+    MPedPhotCam &GetPedPhotCam() { return fPedPhotCam; }
+    const MBadPixelsCam &GetBadPixels()  const { return fBadPixels; }
+
+    void SetExtractor(MExtractor* ext)              { fExtractor = ext; }
+    void SetTimeExtractor(MExtractTime* ext)         { fTimeExtractor = ext; }
+    void SetBadPixels(const MBadPixelsCam &bad) { bad.Copy(fBadPixels); }
+
+    Bool_t ProcessD(MPedestalCam &pedcam);
+    Bool_t ProcessP(MPedestalCam &pedcam, MCalibrationChargeCam &calcam, MCalibrationQECam &qecam);
+
+    ClassDef(MJExtractSignal, 0) // Tool to create a pedestal file (MPedestalCam)
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mjobs/MJPedestal.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mjobs/MJPedestal.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mjobs/MJPedestal.cc	(revision 9661)
@@ -0,0 +1,514 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!              Markus Gaug ,04/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MJPedestal
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MJPedestal.h"
+
+#include <TF1.h>
+#include <TEnv.h>
+#include <TFile.h>
+#include <TLine.h>
+#include <TLatex.h>
+#include <TString.h>
+#include <TCanvas.h>
+#include <TSystem.h>
+#include <TLegend.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MRunIter.h"
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MEvtLoop.h"
+#include "MExtractor.h"
+
+#include "MStatusDisplay.h"
+
+#include "MGeomCam.h"
+#include "MHCamera.h"
+#include "MPedestalCam.h"
+#include "MBadPixelsCam.h"
+
+#include "MReadMarsFile.h"
+#include "MRawFileRead.h"
+#include "MGeomApply.h"
+#include "MBadPixelsMerge.h"
+#include "MPedCalcPedRun.h"
+
+ClassImp(MJPedestal);
+
+using namespace std;
+
+const Double_t MJPedestal::fgPedestalMin = 4.;
+const Double_t MJPedestal::fgPedestalMax = 16.;
+const Double_t MJPedestal::fgPedRmsMin   = 0.;
+const Double_t MJPedestal::fgPedRmsMax   = 20.;
+
+const Float_t  MJPedestal::fgRefPedClosedLids       = 9.635;
+const Float_t  MJPedestal::fgRefPedExtraGalactic    = 9.93;
+const Float_t  MJPedestal::fgRefPedGalactic         = 10.03;
+const Float_t  MJPedestal::fgRefPedRmsClosedLids    = 1.7;
+const Float_t  MJPedestal::fgRefPedRmsExtraGalactic = 5.6;
+const Float_t  MJPedestal::fgRefPedRmsGalactic      = 6.92;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+// Sets fRuns to 0, fExtractor to NULL, fDataCheck to kFALSE
+//
+MJPedestal::MJPedestal(const char *name, const char *title) 
+    : fEnv(0), fRuns(0), fExtractor(NULL), fDataCheck(kFALSE)
+{
+    fName  = name  ? name  : "MJPedestal";
+    fTitle = title ? title : "Tool to create a pedestal file (MPedestalCam)";
+}
+
+MJPedestal::~MJPedestal()
+{
+    if (fEnv)
+        delete fEnv;
+}
+
+const char* MJPedestal::GetOutputFile() const
+{
+    if (!fRuns)
+        return "";
+
+    return Form("%s/%s-F0.root", (const char*)fOutputPath, (const char*)fRuns->GetRunsAsFileName());
+}
+
+Bool_t MJPedestal::ReadPedestalCam()
+{
+    const TString fname = GetOutputFile();
+
+    if (gSystem->AccessPathName(fname, kFileExists))
+    {
+        *fLog << warn << "Input file " << fname << " doesn't exist, will create it." << endl;
+        return kFALSE;
+    }
+
+    *fLog << inf << "Reading from file: " << fname << endl;
+
+    TFile file(fname, "READ");
+    if (fPedestalCam.Read()<=0)
+    {
+        *fLog << err << "Unable to read MPedestalCam from " << fname << endl;
+        return kFALSE;
+    }
+
+    if (file.FindKey("MBadPixelsCam"))
+    {
+        MBadPixelsCam bad;
+        if (bad.Read()<=0)
+        {
+            *fLog << err << "Unable to read MBadPixelsCam from " << fname << endl;
+            return kFALSE;
+        }
+        fBadPixels.Merge(bad);
+    }
+
+    if (fDisplay && !fDisplay->GetCanvas("Pedestals"))
+        fDisplay->Read();
+
+    return kTRUE;
+}
+
+
+void MJPedestal::DisplayResult(MParList &plist)
+{
+    if (!fDisplay)
+        return;
+
+    //
+    // Update display
+    //
+    TString title = fDisplay->GetTitle();
+    title += "--  Pedestal ";
+    if (fRuns)  // FIXME: What to do if an environmentfile was used?
+        title += fRuns->GetRunsAsString();
+    title += "  --";
+    fDisplay->SetTitle(title);
+
+    //
+    // Get container from list
+    //
+    MGeomCam &geomcam = *(MGeomCam*)plist.FindObject("MGeomCam");
+
+    //
+    // Create container to display
+    //
+    MHCamera disp0(geomcam, "MPedestalCam;ped", "Mean Pedestal");
+    MHCamera disp1(geomcam, "MPedestalCam;RMS", "Pedestal RMS");
+
+    disp0.SetCamContent(fPedestalCam, 0);
+    disp0.SetCamError  (fPedestalCam, 1);
+
+    disp1.SetCamContent(fPedestalCam, 2);
+    disp1.SetCamError  (fPedestalCam, 3);
+
+    disp0.SetYTitle("P [fadc/slice]");
+    disp1.SetYTitle("\\sigma_{P} [fadc/slice]");
+
+
+    //
+    // Display data
+    //
+    TCanvas &c3 = fDisplay->AddTab("Pedestals");
+    c3.Divide(2,3);
+
+    if (!fDataCheck)
+    {
+        disp0.CamDraw(c3, 1, 2, 1);
+        disp1.CamDraw(c3, 2, 2, 6);
+        return;
+    }
+
+    c3.cd(1);
+    gPad->SetBorderMode(0);
+    gPad->SetTicks();
+    MHCamera *obj1=(MHCamera*)disp0.DrawCopy("hist");
+    obj1->SetDirectory(NULL);
+
+    //
+    // for the datacheck, fix the ranges!!
+    //
+    obj1->SetMinimum(fgPedestalMin);
+    obj1->SetMaximum(fgPedestalMax);
+
+    //
+    // set reference lines
+    //
+    DisplayReferenceLines(obj1,0);
+
+    //
+    // end reference lines
+    //
+    c3.cd(3);
+    gPad->SetBorderMode(0);
+    obj1->SetPrettyPalette();
+    obj1->Draw();
+
+    c3.cd(5);
+    gPad->SetBorderMode(0);
+    gPad->SetTicks();
+    obj1->DrawProjection(7);
+
+    c3.cd(2);
+    gPad->SetBorderMode(0);
+    gPad->SetTicks();
+    MHCamera *obj2=(MHCamera*)disp1.DrawCopy("hist");
+    obj2->SetDirectory(NULL);
+    obj2->SetMinimum(fgPedRmsMin);
+    obj2->SetMaximum(fgPedRmsMax);
+
+    //
+    // set reference lines
+    //
+    DisplayReferenceLines(obj1,1);
+
+    c3.cd(4);
+    gPad->SetBorderMode(0);
+    obj2->SetPrettyPalette();
+    obj2->Draw();
+
+    c3.cd(6);
+    gPad->SetBorderMode(0);
+    gPad->SetTicks();
+
+    TArrayI inner(1);
+    inner[0] = 0;
+
+    TArrayI outer(1);
+    outer[0] = 1;
+
+    if (geomcam.InheritsFrom("MGeomCamMagic"))
+    {
+        TArrayI s0(6);
+        s0[0] = 6;
+        s0[1] = 1;
+        s0[2] = 2;
+        s0[3] = 3;
+        s0[4] = 4;
+        s0[5] = 5;
+
+        TArrayI s1(3);
+        s1[0] = 6;
+        s1[1] = 1;
+        s1[2] = 2;
+
+        TArrayI s2(3);
+        s2[0] = 3;
+        s2[1] = 4;
+        s2[2] = 5;
+
+        gPad->Clear();
+        TVirtualPad *pad = gPad;
+        pad->Divide(2,1);
+
+        TH1D *inout[2];
+        inout[0] = disp1.ProjectionS(s0, inner, "Inner");
+        inout[1] = disp1.ProjectionS(s0, outer, "Outer");
+
+        inout[0]->SetDirectory(NULL);
+        inout[1]->SetDirectory(NULL);
+
+        for (int i=0; i<2; i++)
+        {
+            TLegend *leg2 = new TLegend(0.6,0.2,0.9,0.55);
+            leg2->SetHeader(inout[i]->GetName());
+            pad->cd(i+1);
+            inout[i]->SetLineColor(kRed+i);
+            inout[i]->SetBit(kCanDelete);
+            inout[i]->Draw();
+            inout[i]->Fit("gaus","Q");
+            leg2->AddEntry(inout[i],inout[i]->GetName(),"l");
+
+            //
+            // Display the outliers as dead and noisy pixels
+            //
+            DisplayOutliers(inout[i]);
+
+            //
+            // Display the two half of the camera separately
+            //
+            TH1D *half[2];
+            half[0] = disp1.ProjectionS(s1, i==0 ? inner : outer , "Sector 6-1-2");
+            half[1] = disp1.ProjectionS(s2, i==0 ? inner : outer , "Sector 3-4-5");
+
+            for (int j=0; j<2; j++)
+            {
+                half[j]->SetLineColor(kRed+i+2*j+1);
+                half[j]->SetDirectory(NULL);
+                half[j]->SetBit(kCanDelete);
+                half[j]->Draw("same");
+                leg2->AddEntry(half[j],half[j]->GetName(),"l");
+            }
+            leg2->Draw();
+        }
+    }
+}
+
+void  MJPedestal::DisplayReferenceLines(MHCamera *cam, const Int_t what) const
+{
+    const Double_t x = cam->GetNbinsX();
+
+    TLine line;
+    line.SetLineStyle(kDashed);
+    line.SetLineWidth(3);
+    
+    line.SetLineColor(kBlue);
+    TLine *l1 = line.DrawLine(0, what ? fgRefPedRmsGalactic : fgRefPedGalactic,
+                              x, what ? fgRefPedRmsGalactic : fgRefPedGalactic);
+
+    line.SetLineColor(kYellow);
+    TLine *l2 = line.DrawLine(0, what ? fgRefPedRmsExtraGalactic : fgRefPedExtraGalactic,
+                              x, what ? fgRefPedRmsExtraGalactic : fgRefPedExtraGalactic);
+
+    line.SetLineColor(kMagenta);
+    TLine *l3 = line.DrawLine(0, what ? fgRefPedRmsClosedLids : fgRefPedClosedLids,
+                              x, what ? fgRefPedRmsClosedLids : fgRefPedClosedLids);
+
+    
+    TLegend *leg = new TLegend(0.4,0.75,0.7,0.99);
+    leg->SetBit(kCanDelete);
+    leg->AddEntry(l1, "Galactic Source","l");
+    leg->AddEntry(l2, "Extra-Galactic Source","l");
+    leg->AddEntry(l3, "Closed Lids","l");
+    leg->Draw();
+}
+
+void  MJPedestal::DisplayOutliers(TH1D *hist) const
+{
+    const Float_t mean  = hist->GetFunction("gaus")->GetParameter(1);
+    const Float_t lolim = mean - 3.5*hist->GetFunction("gaus")->GetParameter(2);
+    const Float_t uplim = mean + 3.5*hist->GetFunction("gaus")->GetParameter(2);
+    const Stat_t  dead  = hist->Integral(0,hist->FindBin(lolim)-1);
+    const Stat_t  noisy = hist->Integral(hist->FindBin(uplim)+1,hist->GetNbinsX()+1);
+
+    TLatex deadtex;
+    deadtex.SetTextSize(0.06);
+    deadtex.DrawLatex(0.1,hist->GetBinContent(hist->GetMaximumBin())/1.1,Form("%3i dead pixels",(Int_t)dead));
+
+    TLatex noisytex;
+    noisytex.SetTextSize(0.06);
+    noisytex.DrawLatex(0.1,hist->GetBinContent(hist->GetMaximumBin())/1.2,Form("%3i noisy pixels",(Int_t)noisy));
+}
+
+Bool_t MJPedestal::WriteResult()
+{
+    if (fOutputPath.IsNull())
+        return kTRUE;
+
+    const TString oname(GetOutputFile());
+
+    *fLog << inf << "Writing to file: " << oname << endl;
+
+    TFile file(oname, "UPDATE");
+
+    if (fDisplay && fDisplay->Write()<=0)
+    {
+        *fLog << err << "Unable to write MStatusDisplay to " << oname << endl;
+        return kFALSE;
+    }
+
+    if (fPedestalCam.Write()<=0)
+    {
+        *fLog << err << "Unable to write MPedestalCam to " << oname << endl;
+        return kFALSE;
+    }
+
+    if (fBadPixels.Write()<=0)
+    {
+        *fLog << err << "Unable to write MBadPixelsCam to " << oname << endl;
+        return kFALSE;
+    }
+
+    return kTRUE;
+}
+
+void MJPedestal::SetOutputPath(const char *path)
+{
+    fOutputPath = path;
+    if (fOutputPath.EndsWith("/"))
+        fOutputPath = fOutputPath(0, fOutputPath.Length()-1);
+}
+
+void MJPedestal::SetEnv(const char *env)
+{
+    if (fEnv)
+        delete fEnv;
+    fEnv = new TEnv(env);
+}
+
+Bool_t MJPedestal::Process()
+{
+    if (!ReadPedestalCam())
+        return ProcessFile();
+
+    return kTRUE;
+}
+
+Bool_t MJPedestal::ProcessFile()
+{
+    if (!fRuns && !fEnv)
+    {
+        *fLog << err << "Neither AddRuns was called nor SetEnv was used... abort." << endl;
+        return kFALSE;
+    }
+    if (fRuns && fRuns->GetNumRuns() != fRuns->GetNumEntries())
+    {
+        *fLog << err << "Number of files found doesn't match number of runs... abort." << endl;
+        return kFALSE;
+    }
+
+    *fLog << inf;
+    fLog->Separator(GetDescriptor());
+    *fLog << "Calculate MPedestalCam from Runs ";
+    if (fRuns)
+        *fLog << fRuns->GetRunsAsString() << endl;
+    else
+        *fLog << "in " << fEnv->GetName() << endl;
+    *fLog << endl;
+
+    MParList  plist;
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    MReadMarsFile read("Events");
+    MRawFileRead rawread(NULL);
+
+    if (fDataCheck)
+    {
+        if (fRuns)
+            rawread.AddFiles(*fRuns);
+	tlist.AddToList(&rawread);
+    }
+    else
+    {
+        read.DisableAutoScheme();
+        if (fRuns)
+            static_cast<MRead&>(read).AddFiles(*fRuns);
+	tlist.AddToList(&read);
+    }
+    // Enable logging to file
+    //*fLog.SetOutputFile(lname, kTRUE);
+
+    // Setup Tasklist
+    plist.AddToList(&fPedestalCam);
+    plist.AddToList(&fBadPixels);
+
+    MGeomApply      geomapl;
+    MBadPixelsMerge merge(&fBadPixels);
+    MPedCalcPedRun  pedcalc;
+
+    if (fExtractor)
+    {
+        pedcalc.SetWindowSize((Int_t)fExtractor->GetNumHiGainSamples());
+        pedcalc.SetRange(fExtractor->GetHiGainFirst(), fExtractor->GetHiGainLast());
+    }
+    else
+    {
+        *fLog << warn << GetDescriptor();
+        *fLog << ": No extractor has been chosen, take default number of FADC samples " << endl;
+    }
+
+    tlist.AddToList(&geomapl);
+    tlist.AddToList(&merge);
+    tlist.AddToList(&pedcalc);
+
+    //
+    // Execute the eventloop
+    //
+    MEvtLoop evtloop(fName);
+    evtloop.SetParList(&plist);
+    evtloop.SetDisplay(fDisplay);
+    evtloop.SetLogStream(fLog);
+    if (fEnv)
+        evtloop.ReadEnv(*fEnv);
+
+    // Execute first analysis
+    if (!evtloop.Eventloop())
+    {
+        *fLog << err << GetDescriptor() << ": Failed." << endl;
+        return kFALSE;
+    }
+
+    tlist.PrintStatistics();
+
+    DisplayResult(plist);
+
+    if (!WriteResult())
+        return kFALSE;
+
+    *fLog << inf << GetDescriptor() << ": Done." << endl;
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mjobs/MJPedestal.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mjobs/MJPedestal.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mjobs/MJPedestal.h	(revision 9661)
@@ -0,0 +1,78 @@
+#ifndef MARS_MJPedestal
+#define MARS_MJPedestal
+
+#ifndef MARS_MPedestalCam
+#include "MPedestalCam.h"
+#endif
+#ifndef MARS_MBadPixelsCam
+#include "MBadPixelsCam.h"
+#endif
+
+class TEnv;
+class TCanvas;
+class MParList;
+class MRunIter;
+class MHCamera;
+class TH1D;
+class MExtractor;
+
+class MJPedestal : public MParContainer
+{
+private:
+    static const Double_t fgPedestalMin;
+    static const Double_t fgPedestalMax;
+    static const Double_t fgPedRmsMin;
+    static const Double_t fgPedRmsMax;
+
+    static const Float_t  fgRefPedClosedLids;
+    static const Float_t  fgRefPedExtraGalactic;
+    static const Float_t  fgRefPedGalactic;
+
+    static const Float_t  fgRefPedRmsClosedLids;
+    static const Float_t  fgRefPedRmsExtraGalactic;
+    static const Float_t  fgRefPedRmsGalactic;
+
+    TString fOutputPath;
+
+    TEnv       *fEnv;           // Input setup-file
+
+    MRunIter   *fRuns;
+    MExtractor *fExtractor;     // Signal extractor, used to find the nr. of used FADC slices
+
+    MPedestalCam  fPedestalCam;
+    MBadPixelsCam fBadPixels;
+
+    Bool_t fDataCheck;          // Flag if the data check is run on raw data
+
+    Bool_t ReadPedestalCam();
+    Bool_t WriteResult();
+
+    void   DisplayResult(MParList &plist);
+    void   DisplayReferenceLines(MHCamera *cam, const Int_t what) const;
+    void   DisplayOutliers(TH1D *hist) const;
+
+public:
+    MJPedestal(const char *name=NULL, const char *title=NULL);
+    ~MJPedestal();
+
+    MPedestalCam &GetPedestalCam()            { return fPedestalCam; }
+    const MBadPixelsCam &GetBadPixels() const { return fBadPixels;   }
+
+    const char* GetOutputFile() const;
+    const Bool_t IsDataCheck() const    { return fDataCheck;  }
+
+    Bool_t Process();
+    Bool_t ProcessFile();
+
+    void SetBadPixels(const MBadPixelsCam &bad) { bad.Copy(fBadPixels); }
+    void SetExtractor(MExtractor* ext   ) { fExtractor = ext;     }
+    void SetInput(MRunIter *iter) { fRuns = iter; }
+    void SetOutputPath(const char *path=".");
+    void SetEnv(const char *env);
+
+    void SetDataCheck(const Bool_t b=kTRUE) { fDataCheck = b; }
+
+    ClassDef(MJPedestal, 0) // Tool to create a pedestal file (MPedestalCam)
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mjobs/Makefile
===================================================================
--- /tags/Mars_V0-8-5/Mars/mjobs/Makefile	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mjobs/Makefile	(revision 9661)
@@ -0,0 +1,38 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#------------------------------------------------------------------------------
+
+#
+# Handling name of the Root Dictionary Files
+#
+CINT  = Jobs
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES = -I. -I../mbase -I../mgui -I../mgeom -I../mdata -I../mhbase \
+	   -I../mfileio -I../mfilter -I../manalysis -I../mhist -I../mcalib \
+           -I../mbadpixels -I../msignal -I../mraw -I../mpedestal -I../mtools
+
+#manalysis: MChisqEval (MParameters)
+
+SRCFILES = MJPedestal.cc \
+           MJCalibration.cc \
+           MJExtractSignal.cc \
+           MJExtractCalibTest.cc
+
+############################################################
+
+all: $(OBJS)
+
+include ../Makefile.rules
+
+mrproper:	clean rmbak
Index: /tags/Mars_V0-8-5/Mars/mmain/MAnalysis.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmain/MAnalysis.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mmain/MAnalysis.cc	(revision 9661)
@@ -0,0 +1,326 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+#include "MAnalysis.h"
+
+#include <iostream>
+
+#include <TGLabel.h>       // TGlabel
+#include <TGButton.h>      // TGTextButton
+#include <TGTextEntry.h>   // TGNumberEntry
+
+#include "MGList.h"
+#include "MImgCleanStd.h"  // MImgCleanStd
+
+ClassImp(MAnalysis);
+
+using namespace std;
+
+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 "MStatusDisplay.h"
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MGeomCamMagic.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 "MHillasCalc.h"
+#include "MHillasSrcCalc.h"
+#include "MSrcPosCam.h"
+#include "MFillH.h"
+#include "MEvtLoop.h"
+#include "MHillas.h"
+#include "MGeomApply.h"
+
+void MAnalysis::CalculateHillas()
+{
+    //
+    // This is a demonstration program which calculates the Hillas
+    // parameter out of a Magic root file.
+
+    const Bool_t displhillas  = kTRUE;//fCheckButton1->GetState();
+    const Bool_t displstarmap = kTRUE;//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;
+    plist.AddToList(&source);
+    /*
+     MSrcPosCam source("Source");
+     source.SetXY(0, 0);
+     plist.AddToList(&source);
+
+     MSrcPosCam antisrc("AntiSrc");
+     antisrc.SetXY(240, 0);
+     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);
+    //read.DisableAutoScheme();
+
+    MGeomApply         apply;
+    MMcPedestalCopy    pcopy;
+    MMcPedestalNSBAdd  pdnsb;
+    MCerPhotCalc       ncalc;
+    //MBlindPixelCalc    blind;
+    MHillasCalc        hcalc;
+    MHillasSrcCalc     csrc1;
+    /*
+     MHillasSrcCalc     csrc1("Source",  "HillasSource");
+     MHillasSrcCalc     csrc2("AntiSrc", "HillasAntiSrc");
+     */
+
+    MFillH hfill("MHHillas",       "MHillas");
+    MFillH hfill2("MHHillasExt",   "MHillasSrc");
+    MFillH hfill2s("MHHillasSrc",  "MHillasSrc");
+    MFillH hfill3("MHNewImagePar", "MNewImagePar");
+    MFillH sfill("MHStarMap",      "MHillas");
+    /*
+     MFillH hfill2s("HistSource  [MHHillasSrc]", "HillasSource");
+     MFillH hfill2a("HistAntiSrc [MHHillasSrc]", "HillasAntiSrc");
+     */
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&apply);
+    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(&hfill2);
+        tlist.AddToList(&hfill2s);
+        tlist.AddToList(&hfill3);
+    }
+
+    if (displstarmap)
+        tlist.AddToList(&sfill);
+
+    //
+    // Create and setup the eventloop
+    //
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    //
+    // Add ProgressBar to window
+    //
+    TGProgressBar *bar = NULL;
+    if (displhillas || displstarmap)
+    {
+        MStatusDisplay *d=new MStatusDisplay;
+        evtloop.SetDisplay(d);
+    }
+    else
+    {
+        bar = CreateProgressBar(fTop2);
+        evtloop.SetProgressBar(bar);
+    }
+
+
+    //
+    // Execute your analysis
+    //
+    /*Bool_t rc =*/ evtloop.Eventloop();
+
+    //
+    // Remove progressbar from window
+    //
+    if (bar)
+        DestroyProgressBar(bar);
+
+ /*
+    if (!rc)
+        return;
+
+    //
+    // After the analysis is finished we can display the histograms
+    //
+    if (displhillas)
+    {
+        plist.FindObject("MHHillas")->DrawClone();
+        plist.FindObject("MHHillasExt")->DrawClone();
+        plist.FindObject("MHHillasSrc")->DrawClone();
+        plist.FindObject("MHNewImagePar")->DrawClone();
+    }
+
+    if (displstarmap)
+        plist.FindObject("MHStarMap")->DrawClone();
+
+    cout << endl;
+    cout << "Calculation of Hillas Parameters finished without error!" << endl;
+ */
+}
+
+// ======================================================================
+
+Bool_t MAnalysis::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
+{
+    // Process events generated by the buttons in the frame.
+
+    if (GET_MSG(msg)!=kC_COMMAND || GET_SUBMSG(msg)!=kCM_BUTTON)
+        return MBrowser::ProcessMessage(msg, parm1, parm2);
+
+    switch (parm1)
+    {
+    case kButHillas:
+        if (!InputFileSelected())
+        {
+            DisplError("No Input (root) File selected!");
+            return kTRUE;
+        }
+
+        switch (parm1)
+        {
+        case kButHillas:
+            CalculateHillas();
+            return kTRUE;
+        }
+        return kTRUE;
+    }
+
+    return MBrowser::ProcessMessage(msg, parm1, parm2);
+}
Index: /tags/Mars_V0-8-5/Mars/mmain/MAnalysis.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmain/MAnalysis.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mmain/MAnalysis.h	(revision 9661)
@@ -0,0 +1,40 @@
+#ifndef MARS_MAnalysis
+#define MARS_MAnalysis
+
+#ifndef MARS_MBrowser
+#include "MBrowser.h"
+#endif
+
+class TGTextEntry;
+class TGCheckButton;
+
+class MImgCleanStd;
+
+class MAnalysis : public MBrowser
+{
+private:
+    TGCheckButton *fCheckButton1;
+    TGCheckButton *fCheckButton2;
+
+//    TGTextEntry   *fNumEntry1;
+//    TGTextEntry   *fNumEntry2;
+
+    MImgCleanStd  *fImgClean;
+
+    void CalculateHillas();
+
+    void AddButtons();
+    void AddSetupTab();
+
+public:
+    MAnalysis(/*const TGWindow *main=NULL,*/ const TGWindow *p=NULL,
+              const UInt_t w=500, const UInt_t h=500) ;
+
+    Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
+
+    ClassDef(MAnalysis, 0) // GUI: The 'Analysis' browser.
+};
+
+#endif
+
+
Index: /tags/Mars_V0-8-5/Mars/mmain/MBrowser.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmain/MBrowser.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mmain/MBrowser.cc	(revision 9661)
@@ -0,0 +1,604 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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>
+#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);
+
+using namespace std;
+
+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);
+
+    const TGPicture *pic0 = fList->GetPicture("magic_t.xpm");
+    if (pic0)
+    {
+        dir->GetListBox()->Resize(100, 150);
+        TGTreeLBEntry *entry = new TGTreeLBEntry(dir->GetListBox()->GetContainer(),
+                                                 new TGString("/data/MAGIC"), pic0, 6000,
+                                                 new TGString("/data/MAGIC"));
+        TGLayoutHints *laylb = new TGLayoutHints(kLHintsLeft|kLHintsTop, 14, 0, 0, 0);
+        dir->AddEntry(entry, laylb);
+        // Not necessary - deleted in ~TGLBContainer: fList->Add(laylb);
+        // fList->Add(laylb);
+    }
+
+    //
+    // 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)
+: TGMainFrame(p?p:gClient->GetRoot(), w, h)
+{
+    fList = new MGList;
+    fList->SetOwner();
+
+    CreateMenuBar();
+
+    TGLayoutHints *laylinesep  = new TGLayoutHints(kLHintsTop|kLHintsExpandX);
+    fList->Add(laylinesep);
+
+    TGHorizontal3DLine *linesep = new TGHorizontal3DLine(this);
+    fList->Add(linesep);
+    AddFrame(linesep, laylinesep);
+
+    //
+    // ---- Create the top window with a lot of buttons ----
+    //
+    TGLayoutHints *layframetop = new TGLayoutHints(kLHintsExpandX);
+    fList->Add(layframetop);
+
+    TGCompositeFrame *frametop = new TGCompositeFrame(this, 300, 100, kVerticalFrame);
+    fList->Add(frametop);
+    AddFrame(frametop, layframetop);
+
+    linesep = new TGHorizontal3DLine(this);
+    fList->Add(linesep);
+    AddFrame(linesep, laylinesep);
+
+    //
+    // ---- Create the low window with a tabs in it ----
+    //
+    TGLayoutHints *layframelow = new TGLayoutHints(kLHintsExpandX|kLHintsExpandY);
+    fList->Add(layframelow);
+
+    TGCompositeFrame *framelow = new TGCompositeFrame(this, 300, 100, kHorizontalFrame);
+    fList->Add(framelow);
+
+    AddFrame(framelow, layframelow);
+
+    CreateUpperFrame(frametop);
+    CreateLowerFrame(framelow);
+
+    //
+    //   Map the window, set up the layout, etc.
+    //
+    ChangeDir();
+    SetWMSizeHints(400, 350, 1000, 1000, 10, 10); // set the smallest and biggest size of the Main frame
+    Move(rand()%100+50, rand()%100+50);
+}
+
+
+MBrowser::~MBrowser()
+{
+    delete fList;
+} 
+
+TGProgressBar *MBrowser::CreateProgressBar(TGHorizontalFrame *frame)
+{
+    static TGLayoutHints laybar(kLHintsCenterY|kLHintsRight/*|kLHintsExpandX*/,
+                                10, 10);
+
+    TGHProgressBar *bar=new TGHProgressBar(frame);
+
+    bar->SetWidth(150);
+    bar->ShowPosition();
+
+    frame->AddFrame(bar, &laybar);
+
+    Layout();
+    MapSubwindows();
+
+    return bar;
+}
+
+void MBrowser::DestroyProgressBar(TGProgressBar *bar)
+{
+    TGHorizontalFrame *frame = (TGHorizontalFrame*)bar->GetParent();
+
+    frame->RemoveFrame(bar);
+
+    Layout();
+    MapSubwindows();
+
+    delete bar;
+}
+
+void MBrowser::CloseWindow()
+{
+   // Got close message for this MainFrame. Calls parent CloseWindow()
+   // (which destroys the window) and terminate the application.
+   // The close message is generated by the window manager when its close
+   // window menu item is selected.
+
+    delete this;
+}
+
+Bool_t MBrowser::InputFileSelected() 
+{
+    //
+    // Checks if there is a selected input root file
+    //
+    return !fInputFile.IsNull(); //[0]!='\0';
+}
+
+void MBrowser::DisplError(const char *txt)
+{
+    Int_t retval;
+    new TGMsgBox(fClient->GetRoot(), this, "Error!", txt,
+                 kMBIconExclamation, 4, &retval);
+}
+
+void MBrowser::DisplWarning(const char *txt)
+{
+    Int_t retval;
+    new TGMsgBox(fClient->GetRoot(), this, "Warning!", txt,
+                 kMBIconExclamation, 4, &retval);
+}
+
+void MBrowser::DisplInfo(const char *txt)
+{
+    Int_t retval;
+    new TGMsgBox(fClient->GetRoot(), this, "Information!", txt,
+                 kMBIconExclamation, 4, &retval);
+}
+
+void MBrowser::ChangeDir(const char *txt)
+{
+    fFileCont->ChangeDirectory(txt?txt:gSystem->WorkingDirectory());
+
+    const char *dir = fFileCont->GetDirectory();
+
+    TGFSComboBox *cbox = (TGFSComboBox*)fList->FindWidget(kCBDirectory);
+    if (cbox)
+        cbox->Update(dir);
+}
+
+void MBrowser::SetFileName(TString name)
+{
+    if (name[0]!='/')
+    {
+        name.Insert(0, "/");
+        name.Insert(0, fFileCont->GetDirectory());
+    }
+
+    if (gSystem->AccessPathName(name, kFileExists))
+        return;
+
+    if (name.EndsWith(".root", TString::kIgnoreCase))
+        fInputFile = name;
+
+    fEntry->SetText(gSystem->BaseName(name));
+
+    ChangeDir(gSystem->DirName(name));
+}
+
+void MBrowser::SetDir()
+{
+    TGFSComboBox *cbox = (TGFSComboBox*)fList->FindWidget(kCBDirectory);
+    if(!cbox)
+        return;
+
+    const TGTreeLBEntry *entry = (TGTreeLBEntry*)cbox->GetSelectedEntry();
+
+    ChangeDir(entry->GetPath()->GetString());
+}
+
+void MBrowser::SetFilter()
+{
+    //
+    // Try to get widget from list
+    //
+    TGComboBox *filter = (TGComboBox*)fList->FindWidget(kCBFilter);
+    if (!filter)
+        return;
+
+    //
+    // Get the selected text from the list box
+    //
+    const TGTextLBEntry *selected = (TGTextLBEntry*)filter->GetListBox()->GetSelectedEntry();
+
+    //
+    // find filter and remove leading spaces
+    //
+    TString txt = selected->GetText()->GetString();
+    if (txt.First('<') < 0)
+        return;
+
+    //
+    // Set new filter and refresh the file container
+    //
+    txt.Remove(txt.First('<'));
+
+    TString ftxt = txt.Strip();
+    fFileCont->SetFilter(ftxt);
+    fFileCont->DisplayDirectory();
+}
+
+void MBrowser::SetViewMode(const Int_t mode)
+{
+    fFileView->SetViewMode(mode ? kLVList : kLVDetails);
+
+    TGButton *but = (TGButton*)fList->FindWidget(mode);
+    if(!but)
+        return;
+
+    but->SetState(kButtonUp);
+}
+
+// --------------------------------------------------------------------------
+//
+// Process events generated by the gui elements in the frame.
+//
+Bool_t MBrowser::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
+{
+    switch (GET_MSG(msg))
+    {
+    case kC_TEXTENTRY:
+        if (GET_SUBMSG(msg)!=kTE_ENTER)
+            return kTRUE;
+
+        SetFileName(fEntry->GetText());
+        return kTRUE;
+
+    case kC_COMMAND:
+        switch (GET_SUBMSG(msg))
+        {
+        case kCM_MENU:
+            switch (parm1)
+            {
+            case kFileClose:
+                CloseWindow();
+                return kTRUE;
+
+            case kFileTBrowser:
+                new TBrowser();
+                return kTRUE;
+            }
+            return kTRUE;
+
+        case kCM_BUTTON:
+            switch (parm1)
+            {
+            case kButDirUp:
+                //
+                //  goto the parent directory
+                //
+                ChangeDir("..");
+                return kTRUE;
+
+            case kButListMode:
+            case kButDetailMode:
+                SetViewMode(parm1);
+                return kTRUE;
+            }
+            return kTRUE;
+
+        case kCM_COMBOBOX:
+            switch (parm1)
+            {
+            case kCBDirectory:
+                SetDir();
+                return kTRUE;
+            case kCBFilter:
+                SetFilter();
+                return kTRUE;
+            }
+            return kTRUE;
+        }
+        return kTRUE;
+
+    case kC_CONTAINER:
+        switch (GET_SUBMSG(msg))
+        {
+
+            //      case kCT_ITEMCLICK:
+            // 	printf ("itemclick\n");
+            //      break;
+
+        case kCT_ITEMDBLCLICK:
+            //
+            //  process the double click in the file view container
+            //
+            if (parm1 != kButton1 || fFileCont->NumSelected() != 1)
+                return kTRUE;
+
+            //
+            //  one file selected
+            //
+            void *dummy = NULL;
+            const TGFileItem *item = (TGFileItem *)fFileCont->GetNextSelected(&dummy);
+
+            const char *str = item->GetItemName()->GetString();
+
+            //
+            // if the user choose a directory
+            // change to this directory
+            //
+            if (S_ISDIR(item->GetType()))
+            {
+                ChangeDir(str);
+                return kTRUE;
+            }
+
+            SetFileName(str);
+            return kTRUE;
+        }
+    }
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mmain/MBrowser.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmain/MBrowser.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mmain/MBrowser.h	(revision 9661)
@@ -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 TGMainFrame/*TGTransientFrame*/
+{
+private:
+    TGTab            *fTabs;
+
+    TGTextEntry      *fEntry;
+
+    TGFileContainer  *fFileCont;
+    TGListView       *fFileView;
+
+    void CreateMenuBar();
+    void CreateTab1();
+    void CreateUpperFrame(TGCompositeFrame *frameup);
+    void CreateLowerFrame(TGCompositeFrame *framelow);
+    void CreateDirListMenu(TGCompositeFrame *frame);
+    void CreateDirListBox(TGCompositeFrame *frame);
+
+    void SetFileName(TString name);
+
+    void SetFilter();
+    void SetDir();
+    void SetViewMode(const Int_t mode);
+
+protected:
+    MGList *fList;
+    TString fInputFile;
+
+    TGCompositeFrame *CreateNewTab(const char *name);
+
+    void DisplError(const char *txt);
+    void DisplWarning(const char *txt);
+    void DisplInfo(const char *txt);
+
+    void ChangeDir(const char *txt=NULL);
+
+    TGProgressBar *CreateProgressBar(TGHorizontalFrame *frame);
+    void DestroyProgressBar(TGProgressBar *bar);
+
+    TGHorizontalFrame *fTop1;
+    TGHorizontalFrame *fTop2;
+    TGHorizontalFrame *fTop3;
+
+ public: 
+     MBrowser(/*const TGWindow *main=NULL,*/ const TGWindow *p=NULL,
+              const UInt_t w=500, const UInt_t h=500) ;
+
+     virtual ~MBrowser();
+
+     void   CloseWindow();
+
+     Bool_t InputFileSelected();
+
+     virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
+
+     ClassDef(MBrowser, 0)   // Base class for the Gui-Browsers
+} ; 
+
+#endif
+
+
Index: /tags/Mars_V0-8-5/Mars/mmain/MCameraDisplay.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmain/MCameraDisplay.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mmain/MCameraDisplay.cc	(revision 9661)
@@ -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@astro.uni-wuerzburg.de>
+!   Author(s): Harald Kornmayer 1/2001
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+#include "MCameraDisplay.h"
+
+#include <TGButton.h>  // TGTextButton
+
+#include "MGList.h"
+#include "MEventDisplay.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 MEventDisplay(fInputFile, "ped.root", "cal.root");
+            return kTRUE;
+        }
+        return kTRUE;
+    }
+
+    return MBrowser::ProcessMessage(msg, parm1, parm2);
+}
Index: /tags/Mars_V0-8-5/Mars/mmain/MCameraDisplay.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmain/MCameraDisplay.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mmain/MCameraDisplay.h	(revision 9661)
@@ -0,0 +1,21 @@
+#ifndef MARS_MCameraDisplay
+#define MARS_MCameraDisplay
+
+#ifndef MARS_MBrowser
+#include "MBrowser.h"
+#endif
+
+class MCameraDisplay : public MBrowser
+{
+public:
+    MCameraDisplay(/*const TGWindow *main=NULL,*/ const TGWindow *p=NULL,
+                   const UInt_t w=500, const UInt_t h=500) ;
+
+    Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
+
+    ClassDef(MCameraDisplay, 0) // GUI: The 'camera display' browser.
+};
+
+#endif
+
+
Index: /tags/Mars_V0-8-5/Mars/mmain/MDataCheck.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmain/MDataCheck.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mmain/MDataCheck.cc	(revision 9661)
@@ -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
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+#include "MDataCheck.h"
+
+#include <TGButton.h>  // TGTextButton
+
+#include "MGList.h"
+#include "MFillH.h"
+#include "MParList.h"
+#include "MEvtLoop.h"
+#include "MHFadcCam.h"
+#include "MTaskList.h"
+#include "MReadTree.h"
+#include "MGeomApply.h"
+#include "MGDisplayAdc.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MDataCheck);
+
+using namespace std;
+
+// ---
+
+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 Spectra of Cosmics", kButEvtAdc);
+    TGTextButton *evttdc = new TGTextButton(fTop1, "Time Spectra of Cosmics", kButEvtTdc);
+    //TGTextButton *crtdc  = new TGTextButton(fTop3, "Run Spectra of Cosmics",    kButEvtTdc);
+
+    //pedadc->Associate(this);
+    cradc ->Associate(this);
+    evttdc->Associate(this);
+    //crtdc ->Associate(this);
+
+    //fList->Add(pedadc);
+    fList->Add(cradc);
+    fList->Add(evttdc);
+    //fList->Add(crtdc);
+
+    TGLayoutHints *laybut = new TGLayoutHints(kLHintsTop|kLHintsLeft, 10, 10, 5, 5);
+    fList->Add(laybut);
+
+    //fTop1->AddFrame(pedadc, laybut);
+    fTop1->AddFrame(cradc,  laybut);
+    fTop1->AddFrame(evttdc,  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::View(const char *inputfile, const char *treeName, MHFadcPix::Type_t t)
+{
+    //
+    // 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();
+
+    MGeomApply geomapl;
+
+    MHFadcCam hist(t);
+    plist.AddToList(&hist);
+
+    MFillH fill(&hist, "MRawEvtData");
+
+    tasks.AddToList(&read);
+    tasks.AddToList(&geomapl);
+    tasks.AddToList(&fill);
+
+    //
+    // set up the loop for the processing
+    //
+    MEvtLoop magic;
+    magic.SetParList(&plist);
+
+    //
+    // Add ProgressBar to window
+    //
+    TGProgressBar *bar = CreateProgressBar(fTop1);
+    magic.SetProgressBar(bar);
+
+    //
+    // Execute your analysis
+    //
+    Bool_t rc = magic.Eventloop();
+
+    //
+    // Remove progressbar from window
+    //
+    DestroyProgressBar(bar);
+
+    if (!rc)
+        return;
+
+    new MGDisplayAdc(&hist);
+}
+
+// --------------------------------------------------------------------------
+//
+//  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:
+            View(fInputFile, "PedEvents", MHFadcPix::kValue);
+            return kTRUE;
+
+        case kButEvtAdc:
+            View(fInputFile, "Events", MHFadcPix::kValue);
+            return kTRUE;
+
+        case kButPedTdc:
+            View(fInputFile, "PedEvents", MHFadcPix::kSlices);
+            return kTRUE;
+
+        case kButEvtTdc:
+            View(fInputFile, "Events", MHFadcPix::kSlices);
+            return kTRUE;
+        }
+        return kTRUE;
+    }
+
+    return MBrowser::ProcessMessage(msg, parm1, parm2);
+}
Index: /tags/Mars_V0-8-5/Mars/mmain/MDataCheck.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmain/MDataCheck.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mmain/MDataCheck.h	(revision 9661)
@@ -0,0 +1,28 @@
+#ifndef MARS_MDataCheck
+#define MARS_MDataCheck
+
+#ifndef MARS_MBrowser
+#include "MBrowser.h"
+#endif
+
+#ifndef MARS_MHFadcPix
+#include "MHFadcPix.h"
+#endif
+
+class MDataCheck : public MBrowser
+{
+private:
+    void View(const char *inputfile, const char *treeName, MHFadcPix::Type_t t);
+
+public:
+    MDataCheck(/*const TGWindow *main=NULL,*/ const TGWindow *p=NULL,
+               const UInt_t w=500, const UInt_t h=500) ;
+
+    Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
+
+    ClassDef(MDataCheck, 0) // GUI: The 'data-check' browser.
+};
+
+#endif
+
+
Index: /tags/Mars_V0-8-5/Mars/mmain/MEventDisplay.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmain/MEventDisplay.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mmain/MEventDisplay.cc	(revision 9661)
@@ -0,0 +1,680 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+#include "MEventDisplay.h"
+
+//
+// C-lib
+//
+#include <stdlib.h>              // atoi
+
+//
+// root
+//
+#include <TFile.h>               // TFile
+#include <TList.h>               // TList::Add
+#include <TStyle.h>              // gStyle->SetOptStat
+#include <TCanvas.h>             // TCanvas::cd
+
+//
+// root GUI
+//
+#include <TGLabel.h>             // TGLabel
+#include <TGButton.h>            // TGPictureButton
+#include <TG3DLine.h>            // TGHorizontal3DLine
+#include <TGTextEntry.h>         // TGTextEntry
+#include <TGButtonGroup.h>       // TGVButtonGroup
+#include <TRootEmbeddedCanvas.h> // TRootEmbeddedCanvas
+
+//
+// General
+//
+#include "MGList.h"              // MGList
+
+#include "MParList.h"            // MParList::AddToList
+#include "MEvtLoop.h"            // MEvtLoop::GetParList
+#include "MTaskList.h"           // MTaskList::AddToList
+
+//
+// Tasks
+//
+#include "MReadMarsFile.h"        // MReadMarsFile
+#include "MGeomApply.h"           // MGeomApply
+#include "MFDataMember.h"         // MFDataMember
+#include "MMcPedestalCopy.h"      // MMcPedestalCopy
+#include "MMcPedestalNSBAdd.h"    // MMcPedestalNSBAdd
+
+#include "MCerPhotAnal2.h"        // MCerPhotAnal2
+#include "MImgCleanStd.h"         // MImgCleanStd
+#include "MHillasCalc.h"          // MHillasCalc
+#include "MHillasSrcCalc.h"       // MHillasSrcCalc
+//#include "MBlindPixelCalc.h"      // MBlindPixelCalc
+#include "MArrivalTimeCalc.h"     // MArrivalTimeCalc
+#include "MFillH.h"               // MFillH
+#include "MExtractSignal.h"       // MExtractsignal
+#include "MMcCalibrationUpdate.h" // MMcCalibrationUpdate
+#include "MCalibrate.h"           // MCalibrate
+#include "MMcTriggerLvl2Calc.h"   // MMcTriggerLvl2Calc
+
+//
+// Container
+//
+#include "MHillas.h"               // MHillas::Print(const MGeomCam&)
+#include "MHillasExt.h"            // MHillasExt::Print(const MGeomCam&)
+#include "MHillasSrc.h"            // MHillasSrc::Print(const MGeomCam&)
+#include "MNewImagePar.h"          // MNewImagePar::Print(const MGeomCam&)
+#include "MHEvent.h"               // MHEvent
+#include "MHCamera.h"              // MHCamera
+#include "MRawEvtData.h"           // MRawEvtData
+#include "MArrivalTimeCam.h"       // MArrivalTimeCam
+#include "MBadPixelsCam.h"         // MBadPixelsCam
+#include "MPedPhotCam.h"           // MPedPhotCam
+#include "MCalibrationChargeCam.h" // MCalibrationChargeCam
+#include "MMcTriggerLvl2.h"        // MMcTriggerLvl2
+
+ClassImp(MEventDisplay);
+
+// --------------------------------------------------------------------------
+//
+//  Constructor.
+//
+MEventDisplay::MEventDisplay(const char *fname, const char *pname, const char *cname) : MStatusDisplay()
+{
+    //
+    // Setup Task list for hillas calculation
+    //
+    SetupTaskList("Events", fname, pname, cname);
+
+    //
+    // Add MEventDisplay GUI elements to the display
+    //
+    AddUserFrame(fname);
+
+    //
+    // Show new part of the window, resize to correct aspect ratio
+    //
+    // FIXME: This should be done by MStatusDisplay automatically
+    Resize(GetWidth(), GetHeight() + fUserFrame->GetDefaultHeight());
+    SetWindowName("Event Display");
+    MapSubwindows();
+
+    //
+    // Readin first event and display it
+    //
+    ReadFirstEvent();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Destructor: PostProcess eventloop, delete eventloop with all containers
+//
+MEventDisplay::~MEventDisplay()
+{
+    fEvtLoop->PostProcess();
+    delete fEvtLoop;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Setup Task and parameter list for hillas calculation,
+//  preprocess tasks and read in first event (process)
+//
+void MEventDisplay::SetupTaskList(const char *tname, const char *fname,
+                                  const char *pname, const char *cname)
+{
+    MCalibrationChargeCam *ccam=0;
+    MPedPhotCam           *pcam=0;
+
+    MBadPixelsCam *badpix = new MBadPixelsCam;
+
+    TFile file(pname, "READ");
+    if (!file.IsZombie())
+        pcam = new MPedPhotCam;
+    if (pcam)
+    {
+        if (pcam->Read()<=0)
+        {
+            delete pcam;
+            pcam = NULL;
+        }
+
+        if (file.FindKey("MBadPixelsCam"))
+        {
+            MBadPixelsCam bad;
+            if (bad.Read()>0)
+                badpix->Merge(bad);
+        }
+    }
+    file.Close();
+    file.Open(cname, "READ");
+    if (!file.IsZombie())
+        ccam = new MCalibrationChargeCam;
+    if (ccam)
+    {
+        if (ccam->Read()<=0)
+        {
+            delete ccam;
+            ccam = NULL;
+        }
+
+        if (file.FindKey("MBadPixelsCam"))
+        {
+            MBadPixelsCam bad;
+            if (bad.Read()>0)
+                badpix->Merge(bad);
+        }
+    }
+    file.Close();
+
+    //
+    // Setup an empty job, with a reader task only.
+    // All tasks and parameter containers are deleted automatically
+    // (via SetOwner())
+    //
+    MTaskList *tlist = new MTaskList;
+    tlist->SetOwner();
+
+    MReadMarsFile *read = new MReadMarsFile(tname, fname);
+    read->DisableAutoScheme();
+    tlist->AddToList(read);
+
+    MGeomApply *apl = new MGeomApply;
+    tlist->AddToList(apl);
+
+    MParList *plist = new MParList;
+    plist->SetOwner();
+    plist->AddToList(tlist);
+    plist->AddToList(badpix);
+    if (pcam)
+        plist->AddToList(pcam);
+    if (ccam)
+        plist->AddToList(ccam);
+
+    fEvtLoop = new MEvtLoop;
+    fEvtLoop->SetOwner();
+    fEvtLoop->SetParList(plist);
+
+    MHEvent *evt1 = new MHEvent(MHEvent::kEvtSignalRaw);
+    MHEvent *evt2 = new MHEvent(MHEvent::kEvtSignalRaw);
+    MHEvent *evt3 = new MHEvent(MHEvent::kEvtPedestal);
+    MHEvent *evt4 = new MHEvent(MHEvent::kEvtPedestalRMS);
+    MHEvent *evt5 = new MHEvent(MHEvent::kEvtRelativeSignal);
+    MHEvent *evt6 = new MHEvent(MHEvent::kEvtCleaningLevels);
+    MHEvent *evt7 = new MHEvent(MHEvent::kEvtIdxMax);
+    MHEvent *evt8 = new MHEvent(MHEvent::kEvtArrTime);
+    MHEvent *evt9 = new MHEvent(MHEvent::kEvtTrigPix);
+
+    evt1->SetName("Signal");
+    evt2->SetName("Cleaned");
+    evt3->SetName("Pedestal");
+    evt4->SetName("PedRMS");
+    evt5->SetName("Signal/PedRMS");
+    evt6->SetName("CleanLevels");
+    evt7->SetName("Max Slice Idx");
+    evt8->SetName("Arrival Time");
+    evt9->SetName("Trigger");
+
+    // This makes sure, that the containers are deleted...
+    plist->AddToList(evt1);
+    plist->AddToList(evt2);
+    plist->AddToList(evt3);
+    plist->AddToList(evt4);
+    plist->AddToList(evt5);
+    plist->AddToList(evt6);
+    plist->AddToList(evt7);
+    plist->AddToList(evt8);
+    plist->AddToList(evt9);
+
+    MCerPhotAnal2     *nanal = new MCerPhotAnal2;
+    MFillH            *fill1 = new MFillH(evt1, "MCerPhotEvt", "MFillH1");
+    MImgCleanStd      *clean = new MImgCleanStd;
+    MFillH            *fill2 = new MFillH(evt2, "MCerPhotEvt", "MFillH2");
+    MFillH            *fill3 = new MFillH(evt3, "MPedPhotCam", "MFillH3");
+    MFillH            *fill4 = new MFillH(evt4, "MPedPhotCam", "MFillH4");
+    MFillH            *fill5 = new MFillH(evt5, "MCameraData", "MFillH5");
+    MFillH            *fill6 = new MFillH(evt6, "MCameraData", "MFillH6");
+//    MBlindPixelCalc   *blind = new MBlindPixelCalc;
+    MHillasCalc       *hcalc = new MHillasCalc;
+    MHillasSrcCalc    *scalc = new MHillasSrcCalc;
+    MMcTriggerLvl2Calc *trcal = new MMcTriggerLvl2Calc;
+    MFillH            *fill9 = new MFillH(evt9, "MMcTriggerLvl2", "MFillH9");
+
+    // If no pedestal or no calibration file is availble
+    if (!pcam || !ccam)
+    {
+        MFilter *f1=new MFDataMember("MRawRunHeader.fRunType", '>', 255.5);
+        MFilter *f2=new MFDataMember("MRawRunHeader.fRunType", '<', 255.5);
+        f1->SetName("MFMonteCarlo");
+        f2->SetName("MFRealData");
+
+        MMcPedestalCopy   *pcopy = new MMcPedestalCopy;
+        MMcPedestalNSBAdd *pdnsb = new MMcPedestalNSBAdd;
+
+        MExtractSignal* extra = new MExtractSignal();
+	extra->SetRange(0, 14, 0, 14);
+	extra->SetSaturationLimit(240);
+
+        MMcCalibrationUpdate* mcupd = new MMcCalibrationUpdate;
+        mcupd->SetOuterPixelsGainScaling(kFALSE);
+
+        MCalibrate* mccal = new MCalibrate;
+        mccal->SetCalibrationMode(MCalibrate::kFfactor);
+
+        // MC
+        extra->SetFilter(f1);
+        mcupd->SetFilter(f1);
+        mccal->SetFilter(f1);
+	trcal->SetFilter(f1);
+
+        // Data
+        nanal->SetFilter(f2);
+
+        // TaskList
+        tlist->AddToList(f1);
+        tlist->AddToList(f2);
+        tlist->AddToList(pcopy);
+        tlist->AddToList(pdnsb);
+
+        tlist->AddToList(extra);
+        tlist->AddToList(mcupd);
+        tlist->AddToList(mccal);
+
+  
+	tlist->AddToList(nanal);
+    }
+    else
+    {
+        MCalibrate* calib = new MCalibrate;
+        tlist->AddToList(calib);
+    }
+
+    tlist->AddToList(fill1);
+    tlist->AddToList(clean);
+    tlist->AddToList(fill2);
+    tlist->AddToList(fill3);
+    tlist->AddToList(fill4);
+    tlist->AddToList(fill5);
+    tlist->AddToList(fill6);
+//    tlist->AddToList(blind);
+    tlist->AddToList(hcalc);
+    tlist->AddToList(scalc);
+
+    if (!pcam || !ccam)
+    {
+        MArrivalTimeCalc  *tcalc = new MArrivalTimeCalc;
+        MFillH            *fill7 = new MFillH(evt7, "MRawEvtData",     "MFillH7");
+        MFillH            *fill8 = new MFillH(evt8, "MArrivalTimeCam", "MFillH8");
+        tlist->AddToList(tcalc);
+        tlist->AddToList(fill7);
+        tlist->AddToList(fill8);
+
+	tlist->AddToList(trcal);
+	tlist->AddToList(fill9);
+    }
+
+    //
+    // Now distribute Display to all tasks
+    //
+    tlist->SetDisplay(this);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Add the top part of the frame: This is filename and treename display
+//
+void MEventDisplay::AddTopFramePart1(TGCompositeFrame *frame,
+                                    const char *filename,
+                                    const char *treename)
+{
+    //
+    //  --- the top1 part of the window ---
+    //
+    TGHorizontalFrame *top1 = new TGHorizontalFrame(frame, 1, 1);
+    fList->Add(top1);
+
+    //
+    // create gui elements
+    //
+    TGLabel *file = new TGLabel(top1, new TGString(Form("%s#%s", filename, treename)));
+    fList->Add(file);
+
+    //
+    // layout and add gui elements in/to frame
+    //
+    TGLayoutHints *laystd = new TGLayoutHints(kLHintsCenterX, 5, 5);
+    fList->Add(laystd);
+
+    top1->AddFrame(file,  laystd);
+
+    //
+    //  --- the top1 part of the window ---
+    //
+    TGHorizontalFrame *top2 = new TGHorizontalFrame(frame, 1, 1);
+    fList->Add(top2);
+
+    //
+    // layout and add frames
+    //
+    TGLayoutHints *laytop1 = new TGLayoutHints(kLHintsCenterX, 5, 5, 5);
+    fList->Add(laytop1);
+    frame->AddFrame(top1, laytop1);
+    frame->AddFrame(top2, laytop1);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Add the second part of the top frame: This are the event number controls
+//
+void MEventDisplay::AddTopFramePart2(TGCompositeFrame *frame)
+{
+    //
+    // --- the top2 part of the window ---
+    //
+    TGHorizontalFrame *top2 = new TGHorizontalFrame(frame, 1, 1);
+    fList->Add(top2);
+
+    //
+    // Create the gui elements
+    //
+    TGTextButton *prevevt = new TGTextButton(top2, " << ", kEvtPrev);
+    prevevt->Associate(this);
+
+    TGLabel *evtnr = new TGLabel(top2, new TGString("Event:"));
+
+    TGTextEntry *entry=new TGTextEntry(top2, new TGTextBuffer(100), kEvtNumber);
+    entry->Resize(60, entry->GetDefaultHeight());
+    entry->Associate(this);
+
+    fNumOfEvts = new TGLabel(top2, "of           .");
+
+    TGTextButton *nextevt = new TGTextButton (top2, " >> ", kEvtNext);
+    nextevt->Associate(this);
+
+    //
+    // Add gui elements to 'atotodel'
+    //
+    fList->Add(prevevt);
+    fList->Add(evtnr);
+    fList->Add(entry);
+    fList->Add(fNumOfEvts);
+    fList->Add(nextevt);
+
+    //
+    // add the gui elements to the frame
+    //
+    TGLayoutHints *laystd = new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 5, 5);
+    fList->Add(laystd);
+
+    top2->AddFrame(prevevt,    laystd);
+    top2->AddFrame(evtnr,      laystd);
+    top2->AddFrame(entry,      laystd);
+    top2->AddFrame(fNumOfEvts, laystd);
+    top2->AddFrame(nextevt,    laystd);
+
+    TGLayoutHints *laystd2 = new TGLayoutHints(kLHintsCenterX, 5, 5, 5, 5);
+    fList->Add(laystd2);
+    frame->AddFrame(top2, laystd2);
+
+    //
+    // Add trailing line...
+    //
+    TGHorizontal3DLine *line = new TGHorizontal3DLine(frame);
+    TGLayoutHints *layline = new TGLayoutHints(kLHintsExpandX);
+    fList->Add(line);
+    fList->Add(layline);
+    frame->AddFrame(line, layline);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Add the user frame part of the display
+//
+void MEventDisplay::AddUserFrame(const char* filename)
+{
+    fUserFrame->ChangeOptions(kHorizontalFrame);
+
+    TGCompositeFrame *vf1 = new TGVerticalFrame(fUserFrame, 1, 1);
+    TGCompositeFrame *vf2 = new TGVerticalFrame(fUserFrame, 1, 1);
+
+    AddTopFramePart1(vf1, filename, "Events");
+    AddTopFramePart2(vf1);
+
+    // create root embedded canvas and add it to the tab
+    TRootEmbeddedCanvas *ec = new TRootEmbeddedCanvas("Slices", vf2, vf1->GetDefaultHeight()*3/2, vf1->GetDefaultHeight(), 0);
+    vf2->AddFrame(ec);
+    fList->Add(ec);
+
+    // set background and border mode of the canvas
+    fCanvas = ec->GetCanvas();
+    fCanvas->SetBorderMode(0);
+    gROOT->GetListOfCanvases()->Add(fCanvas);
+    //fCanvas->SetBorderSize(1);
+    //fCanvas->SetBit(kNoContextMenu);
+    //fCanvas->SetFillColor(16);
+
+    TGLayoutHints *lay = new TGLayoutHints(kLHintsExpandX);
+    fUserFrame->AddFrame(vf1, lay);
+    fUserFrame->AddFrame(vf2);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Checks if the event number is valid, and if so reads the new event
+//  and updates the display
+//
+void MEventDisplay::ReadinEvent(Int_t dir)
+{
+    MParList    *plist = (MParList*)   fEvtLoop->GetParList();
+    MTaskList   *tlist = (MTaskList*)  fEvtLoop->GetTaskList();
+    MGeomCam    *geom  = (MGeomCam*)   plist->FindObject("MGeomCam");
+    MRawEvtData *raw   = (MRawEvtData*)plist->FindObject("MRawEvtData");
+
+    //
+    // Read first event.
+    //
+    MReadTree *reader = (MReadTree*)fEvtLoop->FindTask("MRead");
+
+    const Int_t num = reader->GetNumEntry();
+
+    do
+    {
+        if (dir<0 && !reader->DecEventNum())
+        {
+            reader->SetEventNum(num);
+            return;
+        }
+        if (dir>0 && !reader->IncEventNum())
+        {
+            reader->SetEventNum(num);
+            return;
+        }
+
+        if (!tlist->Process())
+            return;
+
+        reader->DecEventNum();
+
+    } while (raw && raw->GetNumPixels()<1 && dir!=0);
+
+    //
+    // Cleare the 'FADC canvas'
+    //
+    fCanvas->Clear();
+    fCanvas->Modified();
+    fCanvas->Update();
+
+    //
+    // Print parameters
+    //
+    ((MHillas*)     plist->FindObject("MHillas"))->Print(*geom);
+    ((MHillasExt*)  plist->FindObject("MHillasExt"))->Print(*geom);
+    ((MHillasSrc*)  plist->FindObject("MHillasSrc"))->Print(*geom);
+    ((MNewImagePar*)plist->FindObject("MNewImagePar"))->Print(*geom);
+    
+    //
+    // UpdateDisplay
+    //
+    gStyle->SetOptStat(1101);
+    Update();
+
+    TGTextEntry *entry = (TGTextEntry*)fList->FindWidget(kEvtNumber);
+    entry->SetText(Form("%d", reader->GetNumEntry()+1));
+}
+
+// --------------------------------------------------------------------------
+//
+//  Read first event to get display booted
+//
+void MEventDisplay::ReadFirstEvent()
+{
+    if (!fEvtLoop->PreProcess())
+        return;
+
+    //
+    // Get parlist
+    //
+    MParList *plist = (MParList*)fEvtLoop->GetParList();
+
+    //
+    // Add Geometry tab
+    //
+    AddGeometryTabs();
+
+    //
+    // Now read event...
+    //
+    ReadinEvent();
+
+    MReadTree *reader = (MReadTree*)fEvtLoop->FindTask("MRead");
+    TGString *txt = new TGString(Form("of %d", reader->GetEntries()));
+    fNumOfEvts->SetText(txt);
+
+    //
+    // Draw ellipse on top of all pads
+    //
+    TObject *hillas = plist->FindObject("MHillas");
+    for (int i=1; i<7;i++)
+    {
+        TCanvas *c = GetCanvas(i);
+        c->GetPad(1)->cd(1);
+        hillas->Draw();
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+//  Adds the geometry tab 
+//
+void MEventDisplay::AddGeometryTabs()
+{
+    MGeomCam *geom = (MGeomCam*)fEvtLoop->GetParList()->FindObject("MGeomCam");
+    if (!geom)
+        return;
+
+    TCanvas &c1=AddTab("Geometry");
+
+    MHCamera *cam = new MHCamera(*geom);
+    cam->SetBit(TH1::kNoStats|MHCamera::kNoLegend|kCanDelete);
+    cam->Draw("pixelindex");
+
+    c1.Modified();
+    c1.Update();
+
+    TCanvas &c2=AddTab("Sectors");
+
+    cam = new MHCamera(*geom);
+    cam->SetBit(TH1::kNoStats|MHCamera::kNoLegend|kCanDelete);
+    cam->Draw("sectorindex");
+
+    c2.Modified();
+    c2.Update();
+}
+
+// --------------------------------------------------------------------------
+//
+//  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 MEventDisplay::ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2)
+{
+    switch (GET_MSG(msg))
+    {
+    case kC_TEXTENTRY:
+        switch(GET_SUBMSG(msg))
+        {
+        case kTE_ENTER:
+            switch(GET_SUBMSG(msg))
+            {
+            case kTE_ENTER:
+                {
+                    TGTextEntry *entry = (TGTextEntry*)fList->FindWidget(kEvtNumber);
+                    MReadTree *reader  = (MReadTree*)fEvtLoop->FindTask("MRead");
+                    if (reader->SetEventNum(atoi(entry->GetText())-1))
+                        ReadinEvent();
+                }
+                return kTRUE;
+            }
+            return kTRUE;
+        }
+        break;
+
+    case kC_COMMAND:
+        switch (GET_SUBMSG(msg))
+        {
+        case kCM_TAB:
+            {
+                //
+                // Set name for 'FADC canvas'. The name is the anchor for MHCamera.
+                // and clear the canvas
+                TCanvas *c = GetCanvas(mp1);
+                if (!c)
+                    break;
+                MHEvent *o = (MHEvent*)fEvtLoop->GetParList()->FindObject(c->GetName());
+                if (!o)
+                    break;
+                fCanvas->SetName(Form("%p;%p;PixelContent", o->GetHist(), c->GetPad(1)));
+            }
+            break;
+
+        case kCM_BUTTON:
+            switch (mp1)
+            {
+            case kEvtPrev:
+                ReadinEvent(-1);
+                return kTRUE;
+
+            case kEvtNext:
+                ReadinEvent(+1);
+                return kTRUE;
+            }
+            return kTRUE;
+        }
+        break;
+    }
+
+    return MStatusDisplay::ProcessMessage(msg, mp1, mp2);
+}
Index: /tags/Mars_V0-8-5/Mars/mmain/MEventDisplay.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmain/MEventDisplay.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mmain/MEventDisplay.h	(revision 9661)
@@ -0,0 +1,57 @@
+#ifndef MARS_MEventDisplay
+#define MARS_MEventDisplay
+
+#ifndef MARS_MStatusDisplay
+#include "MStatusDisplay.h"
+#endif
+
+class TGLabel;
+class TGTextEntry;
+class MEvtLoop;
+
+class MParList;
+class MTaskList;
+class MReadTree;
+
+class MEventDisplay : public MStatusDisplay
+{
+private:
+    enum
+    {
+        kEvtPrev = MStatusDisplay::kSearch + 1,
+        kEvtNext,
+        kEvtNumber
+    };
+
+    TGCompositeFrame *fTab1;
+    TGCompositeFrame *fTab2;
+
+    TGLabel  *fNumOfEvts;
+    TCanvas  *fCanvas;
+    MEvtLoop *fEvtLoop;
+
+    void AddTopFramePart1(TGCompositeFrame *frame,
+                          const char *filename, const char *treename);
+    void AddTopFramePart2(TGCompositeFrame *frame);
+    void AddGeometryTabs();
+    void AddUserFrame(const char *filename);
+
+    void UpdateDisplay();
+    void SetupTaskList(const char *tname, const char *fname,
+                       const char *pname=0, const char *cname=0);
+
+    void ReadFirstEvent();
+    void ReadinEvent(Int_t dir=0);
+
+    Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
+
+public:
+    MEventDisplay(const char *fname, const char *pname=0, const char *cname=0);
+    ~MEventDisplay();
+
+    ClassDef(MEventDisplay, 0) // Display for camera images (cerenkov events)
+};
+
+#endif
+
+
Index: /tags/Mars_V0-8-5/Mars/mmain/MGDisplayAdc.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmain/MGDisplayAdc.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mmain/MGDisplayAdc.cc	(revision 9661)
@@ -0,0 +1,463 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Harald Kornmayer, 1/2001
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+#include "MGDisplayAdc.h"
+
+#include <stdlib.h>              // mkstemp
+#include <iostream>              // cout for debugging
+
+#include <TSystem.h>             // gSystem
+#include <TCanvas.h>             // TCanvas.h
+#include <TGSlider.h>            // TGVSlider
+#include <TGButton.h>            // TGTextButton
+#include <TGMsgBox.h>            // TGMsgBox
+#include <TGListBox.h>           // TGListBox
+#include <TGButtonGroup.h>       // TGVButtonGroup
+#include <TRootEmbeddedCanvas.h> // TRootEmbeddedCanvas
+
+#include "MHFadcCam.h"
+
+using namespace std;
+
+ClassImp(MGDisplayAdc);
+
+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);
+
+    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 entry with id 1
+    //
+    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();
+
+    Int_t n=1;
+    for (Int_t i=0; i<nhi; i++)
+        if (fHists->HasHi(i))
+            fHistoList->AddEntry(fHists->GetHistHi(i)->GetName(), n++);
+
+    fSlider->SetRange(1, n);
+
+    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();
+
+    const Int_t idx = fHistoList->GetSelectedEntry()->EntryId()-1; //selected-1;
+
+    if (!fHists->HasHi(idx))
+        return;
+
+    const Int_t type = fHists->HasLo(idx) ? fHistoType : M_RADIO_HI;
+
+    switch (type)
+    {
+    case M_RADIO_HI:
+    case M_RADIO_LO:
+        fCanvas->Divide(1, 1);
+
+        fCanvas->cd();
+        if (type==M_RADIO_HI)
+            fHists->DrawHi(idx);
+        else
+            fHists->DrawLo(idx);
+        break;
+
+    case M_RADIO_LH:
+        fCanvas->Divide(1, 2);
+
+        fCanvas->cd(1);
+        fHists->DrawHi(idx);
+
+        fCanvas->cd(2);
+        fHists->DrawLo(idx);
+        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:
+                fCanvas->SaveAs();
+                cout << "Sorry, no well implemented!" << endl;
+                return kTRUE;
+
+            case M_BUTTON_PRINT:
+                {
+                    char *txt = (char*)"canvasXXXXXX";
+                    mkstemp(txt);
+                    TString name = txt;
+                    name += ".ps";
+                    fCanvas->SaveAs(name);
+                    cout << "Calling 'lpr " << name << ".ps'" << endl;
+                    gSystem->Exec(TString("lpr ")+name+".ps");
+                    gSystem->Exec(TString("rm ")+name+".ps");
+                }
+                cout << "Sorry, not well 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==fHistoList->GetNumberOfEntries()))
+                        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 synchronise with TGListBox
+        if (parm2<1 || parm2>fHistoList->GetNumberOfEntries())
+            return kTRUE;
+
+        fHistoList->Select(parm2);
+        UpdateHist();
+        return kTRUE;
+    }
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mmain/MGDisplayAdc.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmain/MGDisplayAdc.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mmain/MGDisplayAdc.h	(revision 9661)
@@ -0,0 +1,57 @@
+#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);
+
+    ClassDef(MGDisplayAdc, 0)
+};
+
+#endif
+
+
Index: /tags/Mars_V0-8-5/Mars/mmain/MMars.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmain/MMars.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mmain/MMars.cc	(revision 9661)
@@ -0,0 +1,320 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
+!   Author(s): Harald Kornmayer 1/2001
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+#include "MMars.h"
+
+#include <iostream>
+
+#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 "MAnalysis.h"
+#include "MDataCheck.h"
+#include "MMonteCarlo.h"
+#include "MCameraDisplay.h"
+
+ClassImp(MMars);
+
+using namespace std;
+
+enum {
+    kFileExit,
+    kFileAbout,
+
+    kPicMagic,
+    kPicMars,
+
+    //kButEvtDisplay,
+    kButDataCheck,
+    kButAnalysis,
+    kButMonteCarlo,
+    kButCameraDisplay
+};
+
+void MMars::CreateMenuBar()
+{
+    TGLayoutHints *laymenubar  = new TGLayoutHints(kLHintsTop|kLHintsLeft|kLHintsExpandX, 2, 2, 2, 2);
+    TGLayoutHints *laymenuitem = new TGLayoutHints(kLHintsTop|kLHintsLeft, 0, 4, 0, 0);
+    TGLayoutHints *laylinesep  = new TGLayoutHints(kLHintsTop|kLHintsExpandX);
+
+    fList->Add(laymenubar);
+    fList->Add(laymenuitem);
+    fList->Add(laylinesep);
+
+    TGPopupMenu *filemenu = new TGPopupMenu(gClient->GetRoot());
+    filemenu->AddEntry("E&xit", kFileExit);
+    filemenu->Associate(this);
+
+    TGMenuBar *menubar = new TGMenuBar(this, 1, 1, kHorizontalFrame);
+    menubar->AddPopup("&File", filemenu, laymenuitem);
+    AddFrame(menubar, laymenubar);
+
+    TGHorizontal3DLine *linesep = new TGHorizontal3DLine(this);
+    AddFrame(linesep, laylinesep);
+
+    fList->Add(filemenu);
+    fList->Add(menubar);
+    fList->Add(linesep);
+}
+
+void MMars::CreateTopFrame(TGHorizontalFrame *top)
+{
+    const TGPicture *pic1 = fList->GetPicture("magiclogo.xpm");
+    if (pic1)
+    {
+        TGPictureButton *magic = new TGPictureButton(top, pic1, kPicMagic);
+        fList->Add(magic);
+        magic->Associate(this);
+        TGLayoutHints *lay1 = new TGLayoutHints(kLHintsLeft,  10, 10, 20, 10);
+        fList->Add(lay1);
+        top->AddFrame(magic, lay1);
+    }
+
+    const TGPicture *pic2 = fList->GetPicture("marslogo.xpm");
+    if (pic2)
+    {
+        TGPictureButton *mars  = new TGPictureButton(top, pic2, kPicMars);
+        fList->Add(mars);
+        mars->Associate(this);
+        TGLayoutHints *lay2 = new TGLayoutHints(kLHintsRight, 10, 10, 10, 10);
+        fList->Add(lay2);
+        top->AddFrame(mars,  lay2);
+    }
+}
+
+#include <TGLabel.h>
+
+void MMars::CreateTextButton(TGVerticalFrame *tab,
+                             const char *text, const char *descr,
+                             const UInt_t id) const
+{
+    //
+    // Create the button
+    //
+    TGHorizontalFrame *frame  = new TGHorizontalFrame(tab, 1, 1);
+    TGTextButton      *button = new TGTextButton(frame, text, id);
+    TGLabel           *label  = new TGLabel(frame, descr);
+    TGLayoutHints     *hints1 = new TGLayoutHints(kLHintsLeft|kLHintsCenterY|kLHintsExpandX, 5, 5, 2, 2);
+
+    //
+    // Add button for 'auto-delete'
+    //
+    fList->Add(hints1);
+    fList->Add(button);
+    fList->Add(label);
+    fList->Add(frame);
+
+    //
+    // Send button events (meesages) to this object (s. ProcessMessage)
+    //
+    button->Associate(this);
+
+    //
+    // Add button with corresponding layout to containing frame
+    //
+    tab->AddFrame(frame,    hints1);
+    frame->AddFrame(button, hints1);
+    frame->AddFrame(label,  hints1);
+}
+
+void MMars::CreateBottomFrame(TGHorizontalFrame *low)
+{
+    //
+    // Create Tab Container
+    //
+    TGLayoutHints *laytabs = new TGLayoutHints(kLHintsBottom|kLHintsExpandX|kLHintsExpandY, 5, 5, 5, 5);
+    fList->Add(laytabs);
+
+    TGTab *tabs = new TGTab(low, 1, 1);
+    fList->Add(tabs);
+    low->AddFrame(tabs, laytabs);
+
+    //
+    // Create Tab1
+    //
+    TGCompositeFrame *tf = tabs->AddTab("Control");
+
+    TGLayoutHints   *laytab = new TGLayoutHints(kLHintsCenterY|kLHintsExpandX);
+    TGVerticalFrame *tab    = new TGVerticalFrame(tf, 1, 1);
+    fList->Add(laytab);
+    fList->Add(tab);
+
+//    CreateTextButton(tab, "Event Display",  "Histograms: Pix per Event",
+//                     kButEvtDisplay);
+    CreateTextButton(tab, "Data Check",     "Histograms: Pix per Run",
+                     kButDataCheck);
+    CreateTextButton(tab, "Analysis",       "Calculate image parameters",
+                     kButAnalysis);
+    CreateTextButton(tab, "Monte Carlo",    "Calculate MC stuff",
+                     kButMonteCarlo);
+    CreateTextButton(tab, "Camera Display", "Display Cerenkov Photons",
+                     kButCameraDisplay);
+
+    tf->AddFrame(tab, laytab);
+}
+
+MMars::MMars()
+: TGMainFrame(gClient->GetRoot(), 400, 400, kVerticalFrame)
+{
+    //
+    // Create the deletion list
+    //
+    fList = new MGList;
+    fList->SetOwner();
+
+    //
+    // Create the MenuBar
+    //
+    CreateMenuBar();
+
+    //
+    // create and layout the frame/contents
+    //
+    TGHorizontalFrame *top = new TGHorizontalFrame(this, 1, 1);
+    TGHorizontalFrame *low = new TGHorizontalFrame(this, 1, 1);
+
+    TGHorizontal3DLine *linesep = new TGHorizontal3DLine(this);
+
+    fList->Add(top);
+    fList->Add(low);
+    fList->Add(linesep);
+
+    CreateTopFrame(top);
+    CreateBottomFrame(low);
+
+    TGLayoutHints *layout1 = new TGLayoutHints(kLHintsTop|kLHintsExpandX);
+    TGLayoutHints *layout2 = new TGLayoutHints(kLHintsTop|kLHintsExpandX|kLHintsExpandY);
+    fList->Add(layout1);
+    fList->Add(layout2);
+
+    AddFrame(top,     layout1);
+    AddFrame(linesep, layout1);
+    AddFrame(low,     layout2);
+
+    //
+    //   Map the window, set up the layout, etc.
+    //
+    Move(rand()%100, rand()%100);
+
+    Layout();
+
+    MapSubwindows();
+
+    SetWindowName("MARS Main Window");
+    SetIconName("MARS");
+
+    MapWindow();
+} 
+
+// ======================================================================
+
+MMars::~MMars()
+{
+    delete fList;
+}  
+// ======================================================================
+
+void MMars::CloseWindow()
+{
+   // Got close message for this MainFrame. Calls parent CloseWindow()
+   // (which destroys the window) and terminate the application.
+   // The close message is generated by the window manager when its close
+   // window menu item is selected.
+
+   TGMainFrame::CloseWindow();
+   gROOT->GetApplication()->Terminate(0);
+}
+
+void MMars::DisplWarning(const char *txt)
+{
+    Int_t retval;
+    new TGMsgBox(fClient->GetRoot(), this,
+                 "WARNING!", txt,
+                 kMBIconExclamation, 4, &retval);
+}
+
+Bool_t MMars::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
+{     
+    // Process events generated by the buttons in the frame.
+
+    switch (GET_MSG(msg))
+    {
+    case kC_COMMAND:
+        switch (GET_SUBMSG(msg))
+        {
+        case kCM_BUTTON:
+
+            switch (parm1)
+            {
+/*
+            case kButEvtDisplay:
+                new MEvtDisp();
+                return kTRUE;
+*/
+            case kButDataCheck:
+                new MDataCheck(/*this*/);
+                return kTRUE;
+
+            case kButAnalysis:
+                new MAnalysis(/*this*/);
+                return kTRUE;
+
+            case kButMonteCarlo:
+                new MMonteCarlo(/*this*/);
+                return kTRUE;
+
+            case kButCameraDisplay:
+                new MCameraDisplay(/*this*/);
+                return kTRUE;
+
+            case kPicMagic:
+                cout << "Trying to start 'netscape http://hegra1.mppmu.mpg.de/MAGICWeb/'..." << endl;
+                gSystem->Exec("netscape http://hegra1.mppmu.mpg.de/MAGICWeb/ &");
+                return kTRUE;
+
+            case kPicMars:
+                cout << "Trying to start 'netscape http://magic.astro.uni-wuerzburg.de/mars/'..." << endl;
+                gSystem->Exec("netscape http://magic.astro.uni-wuerzburg.de/mars/ &");
+                return kTRUE;
+            }
+
+	case kCM_MENU:
+            if (parm1!=kFileExit)
+                return kTRUE;
+
+            CloseWindow();
+            return kTRUE;
+	}
+    }
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mmain/MMars.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmain/MMars.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mmain/MMars.h	(revision 9661)
@@ -0,0 +1,44 @@
+#ifndef MARS_MMars
+#define MARS_MMars
+
+#ifndef MMARS_MAGIC
+#include "MAGIC.h"
+#endif
+
+#ifndef ROOT_TGFrame
+#include <TGFrame.h>
+#endif
+
+class MGList;
+class TGVerticalFrame;
+class TGLayoutHints;
+
+class MMars : public TGMainFrame
+{
+private:
+
+    MGList *fList;
+
+    void CreateTextButton(TGVerticalFrame *tab, const char *text,
+                          const char *descr, const UInt_t id) const;
+
+    void CreateMenuBar();
+    void CreateTopFrame(TGHorizontalFrame *top);
+    void CreateBottomFrame(TGHorizontalFrame *low);
+
+    void DisplWarning(const char *txt);
+
+public:
+    MMars();
+    ~MMars();
+
+    void CloseWindow();
+
+    Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
+
+    ClassDef(MMars, 0) // GUI: Mars - the main window
+};
+
+#endif
+
+
Index: /tags/Mars_V0-8-5/Mars/mmain/MMonteCarlo.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmain/MMonteCarlo.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mmain/MMonteCarlo.cc	(revision 9661)
@@ -0,0 +1,488 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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>
+
+#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);
+
+using namespace std;
+
+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
+     GetMainFrame 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 "MReadMarsFile.h"
+
+#include "MHMcRate.h"
+#include "MHMcEnergy.h"
+
+#include "MMcTriggerRateCalc.h"
+#include "MMcThresholdCalc.h"
+#include "MMcCollectionAreaCalc.h"
+
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,05,05)
+#include "../mmc/MMcTrig.hxx" // FIXME: see FIXME below
+#endif
+
+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);
+
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,05,05)
+    //
+    // 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;
+#endif
+
+    //
+    // Setup out tasks:
+    //  - First we have to read the events
+    //  - Then we can fill the efficiency histograms
+    //
+    MReadMarsFile read("Events", fInputFile);
+    tlist.AddToList(&read);
+
+    MMcCollectionAreaCalc effi;
+    tlist.AddToList(&effi);
+
+    //
+    // set up the loop for the processing
+    //
+    MEvtLoop magic;
+    magic.SetParList(&plist);
+
+    //
+    // Add ProgressBar to window
+    //
+    TGProgressBar *bar = CreateProgressBar(fTop2);
+    magic.SetProgressBar(bar);
+
+    //
+    // Execute your analysis
+    //
+    Bool_t rc = magic.Eventloop();
+
+    //
+    // Remove progressbar from window
+    //
+    DestroyProgressBar(bar);
+
+    if (!rc)
+        return;
+
+    //
+    // Now the histogram we wanted to get out of the data is
+    // filled and can be displayd
+    //
+    plist.FindObject("MHMcCollectionArea")->DrawClone();
+}
+
+void MMonteCarlo::CalculateTriggerRate()
+{
+    //
+    // 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.
+    //
+    const Int_t dim = GetDim();
+
+    MParList plist;
+    MTaskList tlist;
+
+    //
+    // Setup the parameter list.
+    //
+    plist.AddToList(&tlist);
+
+    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;
+
+    //
+    // Set for each MHMcRate object the trigger condition number in the 
+    // camera file (for the case of camera files with several conditions,
+    // produced with the trigger_loop option.
+    //
+    if (dim < 0)
+        ((MHMcRate*)(hists[0]))->SetTriggerCondNum(to);
+    else
+        for (UInt_t i=from; i<=to; i++)
+            ((MHMcRate*)(hists[i-1]))->SetTriggerCondNum(i);
+
+    //
+    // Add the histograms to the parameter list.
+    //
+    plist.AddToList(&hists);
+
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,05,05)
+    //
+    // 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;
+#endif
+
+    //
+    // 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[])
+    //
+    MReadMarsFile read("Events", fInputFile);
+    tlist.AddToList(&read);
+
+    // We calculate only shower rate (not including NSB-only triggers)
+    Float_t* BgR = new Float_t[num];
+    memset(BgR, 0, num*sizeof(Float_t));
+
+    MMcTriggerRateCalc crate(dim, BgR, 100000);
+    tlist.AddToList(&crate);
+
+    //
+    // set up the loop for the processing
+    //
+    MEvtLoop magic;
+    magic.SetParList(&plist);
+
+    //
+    // Add ProgressBar to window
+    //
+    TGProgressBar *bar = CreateProgressBar(fTop2);
+    magic.SetProgressBar(bar);
+
+    //
+    // Execute your analysis
+    //
+    Bool_t rc = magic.Eventloop();
+
+    //
+    // Remove progressbar from window
+    //
+    DestroyProgressBar(bar);
+
+    delete BgR;
+
+    if (!rc)
+        return;
+
+    hists.Print();
+}
+
+void MMonteCarlo::CalculateThreshold()
+{
+    const Int_t dim = GetDim();
+
+    MParList plist;
+
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    //
+    // 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);
+
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,05,05)
+    //
+    // 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;
+#endif
+
+    //
+    // Setup the task list
+    //
+    MReadTree read("Events", fInputFile);
+
+    MMcThresholdCalc calc(dim);
+    tlist.AddToList(&read);
+    tlist.AddToList(&calc);
+
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    //
+    // Add ProgressBar to window
+    //
+    TGProgressBar *bar = CreateProgressBar(fTop2);
+    evtloop.SetProgressBar(bar);
+
+    //
+    // Execute your analysis
+    //
+    Bool_t rc = evtloop.Eventloop();
+
+    //
+    // Remove progressbar from window
+    //
+    DestroyProgressBar(bar);
+
+    if (!rc)
+        return;
+
+    //
+    // Now you can display the results
+    //
+    hists.ForEach(TObject, DrawClone)();
+}
+
+// ======================================================================
+
+Bool_t MMonteCarlo::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
+{
+    if (GET_MSG(msg) == kC_COMMAND && GET_SUBMSG(msg) == kCM_BUTTON)
+        switch (parm1)
+        {
+        case kButCollArea:
+            CalculateCollectionArea();
+            return kTRUE;
+
+        case kButTrigRate:
+            CalculateTriggerRate();
+            return kTRUE;
+
+        case kButThreshold:
+            CalculateThreshold();
+            return kTRUE;
+        }
+
+    return MBrowser::ProcessMessage(msg, parm1, parm2);
+}
Index: /tags/Mars_V0-8-5/Mars/mmain/MMonteCarlo.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmain/MMonteCarlo.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mmain/MMonteCarlo.h	(revision 9661)
@@ -0,0 +1,40 @@
+#ifndef MARS_MMonteCarlo
+#define MARS_MMonteCarlo
+
+#ifndef MARS_MBrowser
+#include "MBrowser.h"
+#endif
+
+class TGTextEntry;
+class TGRadioButton;
+
+class MMonteCarlo : public MBrowser
+{
+private:
+    TGRadioButton *fRadioButton1;
+    TGRadioButton *fRadioButton2;
+    TGRadioButton *fRadioButton3;
+
+    TGTextEntry   *fNumEntry;
+
+    Int_t GetDim() const;
+
+    void CalculateCollectionArea();
+    void CalculateTriggerRate();
+    void CalculateThreshold();
+
+    void AddButtons();
+    void AddSetupTab();
+
+public:
+    MMonteCarlo(/*const TGWindow *main=NULL,*/ const TGWindow *p=NULL,
+                const UInt_t w=500, const UInt_t h=500);
+
+    Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
+
+    ClassDef(MMonteCarlo, 0) // GUI: The 'monte-carlo' browser
+};
+
+#endif
+
+
Index: /tags/Mars_V0-8-5/Mars/mmain/MOnlineDisplay.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmain/MOnlineDisplay.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mmain/MOnlineDisplay.cc	(revision 9661)
@@ -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): Thomas Bretz, 11/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+#include "MOnlineDisplay.h"
+
+//
+// C-lib
+//
+#include <stdlib.h>              // atoi
+
+//
+// root
+//
+#include <TList.h>               // TList::Add
+#include <TStyle.h>              // gStyle->SetOptStat
+#include <TCanvas.h>             // TCanvas::cd
+
+//
+// root GUI
+//
+#include <TGLabel.h>             // TGLabel
+#include <TGButton.h>            // TGPictureButton
+#include <TGSlider.h>            // TGSlider
+#include <TG3DLine.h>            // TGHorizontal3DLine
+#include <TGTextEntry.h>         // TGTextEntry
+#include <TGButtonGroup.h>       // TGVButtonGroup
+#include <TRootEmbeddedCanvas.h> // TRootEmbeddedCanvas
+
+//
+// General
+//
+#include "MGList.h"              // MGList
+
+#include "MParList.h"            // MParList::AddToList
+#include "MEvtLoop.h"            // MEvtLoop::GetParList
+#include "MTaskList.h"           // MTaskList::AddToList
+
+//
+// Tasks
+//
+#include "MReadMarsFile.h"       // MReadMarsFile
+#include "MGeomApply.h"          // MGeomApply
+#include "MFDataMember.h"        // MFDataMember
+#include "MMcPedestalCopy.h"     // MMcPedestalCopy
+#include "MMcPedestalNSBAdd.h"   // MMcPedestalNSBAdd
+#include "MCerPhotCalc.h"        // MCerPhotCalc
+#include "MCerPhotAnal2.h"       // MCerPhotAnal2
+#include "MImgCleanStd.h"        // MImgCleanStd
+#include "MHillasCalc.h"         // MHillasCalc
+#include "MHillasSrcCalc.h"      // MHillasSrcCalc
+#include "MFillH.h"              // MFillH
+#include "MGTask.h"              // MGTask
+
+//
+// Container
+//
+#include "MHEvent.h"             // MHEvent
+#include "MHCamera.h"            // MHCamera
+#include "MRawEvtData.h"         // MRawEvtData
+
+ClassImp(MOnlineDisplay);
+
+// --------------------------------------------------------------------------
+//
+//  Constructor.
+//
+MOnlineDisplay::MOnlineDisplay() : MStatusDisplay(), fTask(0)
+{
+    //
+    // Add MOnlineDisplay GUI elements to the display
+    //
+    AddUserFrame();
+
+    //
+    // Show new part of the window, resize to correct aspect ratio
+    //
+    // FIXME: This should be done by MStatusDisplay automatically
+    Resize(GetWidth(), GetHeight() + fUserFrame->GetDefaultHeight());
+    SetWindowName("Online Display");
+    MapSubwindows();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Add the top part of the frame: This is filename and treename display
+//
+void MOnlineDisplay::AddTopFramePart1(TGCompositeFrame *vf1)
+{
+    TGLabel *file = new TGLabel(vf1, new TGString("Magic Online Analysis -- MONA"));
+    TGLayoutHints *laystd = new TGLayoutHints(kLHintsCenterX, 5, 5);
+    fList->Add(file);
+    fList->Add(laystd);
+    vf1->AddFrame(file,  laystd);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Add the second part of the top frame: This are the event number controls
+//
+void MOnlineDisplay::AddTopFramePart2(TGCompositeFrame *vf1)
+{
+    //
+    // --- the top2 part of the window ---
+    //
+    TGHorizontalFrame *top2 = new TGHorizontalFrame(vf1, 1, 1);
+    fList->Add(top2);
+
+    //
+    // Create the gui elements
+    //
+    TGTextButton *freeze = new TGTextButton(top2, " Freeze ", kFreeze);
+    freeze->SetUserData(freeze);
+    freeze->Associate(this);
+    freeze->SetToolTipText("Freeze the current Event");
+
+    fList->Add(freeze);
+
+    //
+    // add the gui elements to the frame
+    //
+    TGLayoutHints *laystd = new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 5, 5);
+    fList->Add(laystd);
+
+    top2->AddFrame(freeze, laystd);
+
+    TGLayoutHints *laystd2 = new TGLayoutHints(kLHintsCenterX, 5, 5, 5, 5);
+    fList->Add(laystd2);
+    vf1->AddFrame(top2, laystd2);
+
+    //
+    // Add trailing line...
+    //
+    TGHorizontal3DLine *line = new TGHorizontal3DLine(vf1);
+    TGLayoutHints *layline = new TGLayoutHints(kLHintsExpandX);
+    fList->Add(line);
+    fList->Add(layline);
+    vf1->AddFrame(line, layline);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Add the user frame part of the display
+//
+void MOnlineDisplay::AddUserFrame()
+{
+    fUserFrame->ChangeOptions(kHorizontalFrame);
+
+    // Slider
+    TGVSlider *slider = new TGVSlider(fUserFrame, 1, kSlider1, kSlider);
+    slider->SetRange(10, 300);
+    slider->SetScale(15);
+    slider->SetPosition(10);
+    slider->Associate(this);
+    //slider->SetToolTipText("Change the update frequency of the event display (1-30s)");
+
+    // frame1/2
+    TGCompositeFrame *vf1 = new TGVerticalFrame(fUserFrame, 1, 1);
+    TGCompositeFrame *vf2 = new TGVerticalFrame(fUserFrame, 1, 1);
+
+    AddTopFramePart1(vf1);
+    AddTopFramePart2(vf1);
+
+    // create root embedded canvas and add it to the tab
+    TRootEmbeddedCanvas *ec = new TRootEmbeddedCanvas("Slices", vf2, vf1->GetDefaultHeight()*3/2, vf1->GetDefaultHeight(), 0);
+    vf2->AddFrame(ec);
+    fList->Add(ec);
+
+    // set background and border mode of the canvas
+    fCanvas = ec->GetCanvas();
+    fCanvas->SetBorderMode(0);
+    gROOT->GetListOfCanvases()->Add(fCanvas);
+    //fCanvas->SetBorderSize(1);
+    //fCanvas->SetBit(kNoContextMenu);
+    //fCanvas->SetFillColor(16);
+
+    // layout
+    TGLayoutHints *lays = new TGLayoutHints(kLHintsExpandY);
+    TGLayoutHints *lay = new TGLayoutHints(kLHintsExpandX);
+    fUserFrame->AddFrame(slider, lays);
+    fUserFrame->AddFrame(vf1, lay);
+    fUserFrame->AddFrame(vf2);
+
+    fList->Add(lay);
+    fList->Add(lays);
+    fList->Add(vf1);
+    fList->Add(vf2);
+    fList->Add(slider);
+}
+
+// --------------------------------------------------------------------------
+//
+//  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 MOnlineDisplay::ProcessMessage(Long_t msg, Long_t mp1, Long_t mp2)
+{
+    if (fTask && fTask->ProcessMessage(GET_MSG(msg), GET_SUBMSG(msg), mp1, mp2))
+        return kTRUE;
+
+    return MStatusDisplay::ProcessMessage(msg, mp1, mp2);
+}
Index: /tags/Mars_V0-8-5/Mars/mmain/MOnlineDisplay.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmain/MOnlineDisplay.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mmain/MOnlineDisplay.h	(revision 9661)
@@ -0,0 +1,53 @@
+#ifndef MARS_MOnlineDisplay
+#define MARS_MOnlineDisplay
+
+#ifndef MARS_MStatusDisplay
+#include "MStatusDisplay.h"
+#endif
+
+class TGLabel;
+class TGTextEntry;
+class MEvtLoop;
+
+class MParList;
+class MTaskList;
+class MReadTree;
+class MGTask;
+
+class MOnlineDisplay : public MStatusDisplay
+{
+    friend class MOnlineDump;
+public:
+    enum
+    {
+        kSlider = MStatusDisplay::kSearch + 1,
+        kFreeze
+    };
+
+private:
+    TGCompositeFrame *fTab1;
+    TGCompositeFrame *fTab2;
+
+    TCanvas *fCanvas;
+
+    MGTask *fTask;
+
+    void AddTopFramePart1(TGCompositeFrame *frame);
+    void AddTopFramePart2(TGCompositeFrame *frame);
+    void AddUserFrame();
+
+    void UpdateDisplay();
+
+    Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
+
+public:
+    MOnlineDisplay();
+
+    void SetTask(MGTask *t) { fTask=t; }
+
+    ClassDef(MOnlineDisplay, 0) // Display for camera images (cerenkov events)
+};
+
+#endif
+
+
Index: /tags/Mars_V0-8-5/Mars/mmain/MOnlineDump.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmain/MOnlineDump.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mmain/MOnlineDump.cc	(revision 9661)
@@ -0,0 +1,248 @@
+#include "MOnlineDump.h"
+
+#include <TCanvas.h>
+#include <TSystem.h>
+
+#include <TGButton.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MTime.h"
+#include "MRawRunHeader.h"
+#include "MRawEvtHeader.h"
+
+#include "MOnlineDisplay.h"
+
+#include "MFRealTimePeriod.h"
+#include "MHEvent.h"
+#include "MHCamera.h"
+#include "MHCamEvent.h"
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MFillH.h"
+#include "MEventRate.h"
+
+ClassImp(MOnlineDump);
+
+using namespace std;
+
+void MOnlineDump::SetNoContextMenu(TObject *c)
+{
+    if (fDisplay->HasCanvas((TCanvas*)c))
+        c->ResetBit(kNoContextMenu);
+}
+
+void MOnlineDump::DisplayTriggerRate()
+{
+    Bool_t set = kFALSE;
+
+    if (!*fEvtTime)
+    {
+        fEvtTime->Now();
+        set = kTRUE;
+    }
+
+    const UInt_t  evts = fRawEvtHeader->GetDAQEvtNumber() - fEvtNumber;
+    const Double_t sec = *fEvtTime-fTime;
+
+    fEvtNumber = fRawEvtHeader->GetDAQEvtNumber();
+    fTime      = *fEvtTime;
+
+    if (evts>0 && sec>0 && fDisplay)
+        fDisplay->SetStatusLine2(Form("%sTrigger Rate: %.1fHz / Event Rate: %.1fHz",
+                                      (set?"Arb. ":""), evts/sec, fRate->GetRate()));
+
+    if (set)
+        fEvtTime->Reset();
+}
+
+Bool_t MOnlineDump::ProcessMessage(Int_t msg, Int_t submsg, Long_t mp1, Long_t mp2)
+{
+    switch (msg)
+    {
+    case kC_VSLIDER:
+        switch (submsg)
+        {
+        case kSL_POS:
+            if (mp1==MOnlineDisplay::kSlider && GetFilter())
+            {
+                ((MFRealTimePeriod*)GetFilter())->SetTime(mp2*100);
+                *fLog << dbg << "Update Time: " << Form("%.1fs", mp2/10.) << endl;
+            }
+            return kTRUE;
+        }
+        return kFALSE;
+    case kC_COMMAND:
+        switch(submsg)
+        {
+        case kCM_TAB:
+            {
+                //
+                // Set name for 'FADC canvas'. The name is the anchor for MHCamera.
+                // and clear the canvas
+                //
+                if (!fPlist || !fDisplay)
+                    return kTRUE;
+
+                TCanvas *c = fDisplay->GetCanvas(mp1);
+                if (!c)
+                    return kTRUE;
+
+                MHEvent *o = (MHEvent*)fPlist->FindObject(c->GetName());
+                if (o)
+                    ((MOnlineDisplay*)fDisplay)->fCanvas->SetName(Form("%p;%p;PixelContent", o->GetHist(),
+                                                                       c->GetPad(1)));
+            }
+            break;
+
+        case kCM_BUTTON:
+            if (mp1==MOnlineDisplay::kFreeze)
+            {
+                TGButton *but = (TGButton*)mp2;
+                if (!but->IsDown())
+                {
+                    but->AllowStayDown(kTRUE);
+                    fCamEvent->SetFreezed();
+                }
+                else
+                {
+                    but->AllowStayDown(kFALSE);
+                    fCamEvent->SetFreezed(kFALSE);
+                }
+                but->Toggle();
+            }
+            return kTRUE;
+        }
+        return kFALSE;
+    }
+    return kFALSE;
+}
+
+MOnlineDump::~MOnlineDump()
+{
+    if (fDisplay)
+        ((MOnlineDisplay*)fDisplay)->SetTask(0);
+}
+
+Int_t MOnlineDump::PreProcess(MParList *pList)
+{
+    fPlist = pList;
+
+    if (gROOT->IsBatch())
+    {
+        *fLog << err << "We are in batch mode!" << endl;
+        return kFALSE;
+    }
+    if (!fDisplay)
+    {
+        *fLog << err << "fDisplay not set." << endl;
+        return kFALSE;
+    }
+
+    MTaskList *tasks = (MTaskList*)pList->FindObject("MTaskList");
+    if (!tasks)
+    {
+        *fLog << err << "MTaskList not found... abort." << endl;
+        return kFALSE;
+    }
+
+    fFill1 = (MFillH*)tasks->FindObject("MFillCamEvent");
+    if (!fFill1)
+    {
+        *fLog << err << "MFillCamEvent not found... abort." << endl;
+        return kFALSE;
+    }
+    fFill2 = (MFillH*)tasks->FindObject("MFillEvent");
+    if (!fFill2)
+    {
+        *fLog << err << "MFillEvent not found... abort." << endl;
+        return kFALSE;
+    }
+    fFill3 = (MFillH*)tasks->FindObject("MFillTriggerLvl0");
+    if (!fFill3)
+    {
+        *fLog << err << "MFillTriggerLvl0 not found... abort." << endl;
+        return kFALSE;
+    }
+
+    MHCamEvent *idxhi = (MHCamEvent*)pList->FindObject("MaxIdxHi");
+    MHCamEvent *idxlo = (MHCamEvent*)pList->FindObject("MaxIdxLo");
+    if (!idxhi || !idxlo)
+    {
+        *fLog << err << "MaxIdxHi or MaxIdxLo not found... abort." << endl;
+        return kFALSE;
+    }
+
+    idxhi->GetHistByName("sum")->SetMinimum(0);
+    idxlo->GetHistByName("sum")->SetMinimum(0);
+    idxhi->GetHistByName("sum")->SetMaximum(15);
+    idxlo->GetHistByName("sum")->SetMaximum(15);
+
+
+    fRawEvtHeader = (MRawEvtHeader*)pList->FindObject("MRawEvtHeader");
+    if (!fRawEvtHeader)
+    {
+        *fLog << err << "MRawEvtHeader not found... abort." << endl;
+        return kFALSE;
+    }
+
+    fRawRunHeader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
+    if (!fRawRunHeader)
+    {
+        *fLog << err << "MRawRunHeader not found... abort." << endl;
+        return kFALSE;
+    }
+
+    fEvtTime = (MTime*)pList->FindObject("MTime");
+    if (!fEvtTime)
+    {
+        *fLog << err << "MTime not found... abort." << endl;
+        return kFALSE;
+    }
+
+    fRate = (MEventRate*)pList->FindObject("MEventRate");
+    if (!fRate)
+    {
+        *fLog << err << "MEventRate not found... abort." << endl;
+        return kFALSE;
+    }
+
+    MHEvent *hevent = (MHEvent*)pList->FindObject("MHEvent");
+    if (!hevent)
+    {
+        *fLog << err << "MHEvent not found... abort." << endl;
+        return kFALSE;
+    }
+    fCamEvent = hevent->GetHist();
+
+    fRunNumber = 0xffffffff;
+    fEvtNumber = 0;
+
+    SetNoContextMenu((TObject*)fFill1->GetCanvas());
+    SetNoContextMenu((TObject*)fFill2->GetCanvas());
+    SetNoContextMenu((TObject*)fFill3->GetCanvas());
+
+    return kTRUE;
+}
+
+Int_t MOnlineDump::Process()
+{
+    DisplayTriggerRate();
+
+    if (fDisplay && fRawRunHeader->GetNumEvents())
+        fDisplay->SetProgressBarPosition((Float_t)fEvtNumber/fRawRunHeader->GetNumEvents());
+
+    return kTRUE;
+}
+
+Int_t MOnlineDump::PostProcess()
+{
+    if (fDisplay)
+    {
+        fDisplay->SetProgressBarPosition(1);
+        //fDisplay->Reset();
+    }
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mmain/MOnlineDump.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmain/MOnlineDump.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mmain/MOnlineDump.h	(revision 9661)
@@ -0,0 +1,53 @@
+#ifndef MARS_MOnlineDump
+#define MARS_MOnlineDump
+
+#ifndef MARS_MGTask
+#include "MGTask.h"
+#endif
+
+class MFillH;
+class MHCamera;
+class MRawEvtHeader;
+class MRawRunHeader;
+class MTime;
+class MParList;
+class MEventRate;
+
+class MOnlineDump : public MGTask
+{
+private:
+    MFillH *fFill1;
+    MFillH *fFill2;
+    MFillH *fFill3;
+
+    MHCamera *fCamEvent;
+
+    UInt_t fRunNumber;
+    UInt_t fEvtNumber;
+
+    MRawEvtHeader *fRawEvtHeader;
+    MRawRunHeader *fRawRunHeader;
+    MEventRate    *fRate;
+
+    MTime *fEvtTime;
+    Double_t fTime;
+
+    MParList *fPlist;
+
+    void SetNoContextMenu(TObject *c);
+    void DisplayTriggerRate();
+
+    Bool_t ProcessMessage(Int_t msg, Int_t submsg, Long_t mp1, Long_t mp2);
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
+public:
+    MOnlineDump() : fPlist(NULL) { fName = "MOnlineDump"; }
+    ~MOnlineDump();
+
+    ClassDef(MOnlineDump, 0) // Task to fill a histogram with data from a parameter container
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mmain/MainIncl.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmain/MainIncl.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mmain/MainIncl.h	(revision 9661)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-8-5/Mars/mmain/MainLinkDef.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmain/MainLinkDef.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mmain/MainLinkDef.h	(revision 9661)
@@ -0,0 +1,21 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class MBrowser+;
+
+#pragma link C++ class MMars+;
+#pragma link C++ class MAnalysis+;
+#pragma link C++ class MDataCheck+;
+#pragma link C++ class MMonteCarlo+;
+
+#pragma link C++ class MCameraDisplay+;
+#pragma link C++ class MEventDisplay+;
+#pragma link C++ class MOnlineDisplay+;
+#pragma link C++ class MOnlineDump+;
+
+#pragma link C++ class MGDisplayAdc+;
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mmain/Makefile
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmain/Makefile	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mmain/Makefile	(revision 9661)
@@ -0,0 +1,44 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#------------------------------------------------------------------------------
+
+#
+# Handling name of the Root Dictionary Files
+#
+CINT  = Main
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES = -I. -I../mbase -I../manalysis -I../mdatacheck -I../mraw        \
+	   -I../mgui -I../mgeom -I../mhbase -I../mhist -I../mmontecarlo   \
+           -I../mfileio -I../mimage -I../mhistmc -I../mgbase -I../mfbase  \
+           -I../mdata -I../msignal -I../mcalib -I../mbadpixels            \
+           -I../mpointing -I../mpedestal
+
+SRCFILES = MBrowser.cc \
+	   MDataCheck.cc \
+	   MMars.cc \
+           MAnalysis.cc \
+	   MMonteCarlo.cc \
+           MGDisplayAdc.cc \
+	   MEventDisplay.cc \
+	   MOnlineDisplay.cc \
+	   MOnlineDump.cc \
+           MCameraDisplay.cc
+
+############################################################
+
+all: $(OBJS)
+
+include ../Makefile.rules
+
+mrproper:	clean rmbak
Index: /tags/Mars_V0-8-5/Mars/mmontecarlo/MMcCollectionAreaCalc.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmontecarlo/MMcCollectionAreaCalc.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mmontecarlo/MMcCollectionAreaCalc.cc	(revision 9661)
@@ -0,0 +1,223 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Harald Kornmayer 1/2001
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MHMcCollectionAreaCalc
+//
+//  Remark: The initialization is mainly done in the ReInit function.
+//          Please make sure, that you don't use MReadTree when processing
+//          a file. Use a 'ReInit'-calling task like MReadMarsFile
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MMcCollectionAreaCalc.h"
+
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MMcEvt.hxx"
+#include "MMcTrig.hxx"
+#include "MMcRunHeader.hxx"
+#include "MMcCorsikaRunHeader.h"
+
+#include "MHMcCollectionArea.h"
+
+ClassImp(MMcCollectionAreaCalc);
+
+using namespace std;
+
+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");
+
+    fCorsikaVersion           =  0;
+    fAllEvtsTriggered         =  kFALSE;
+    fTotalNumSimulatedShowers =  0;
+    fTheta                    = -1.;
+
+} 
+
+Int_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;
+    }
+
+    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;
+    }
+
+    MMcCorsikaRunHeader *corrunheader  = (MMcCorsikaRunHeader*)plist->FindObject("MMcCorsikaRunHeader");
+    if (!corrunheader)
+    {
+        *fLog << err << dbginf << "Error - MMcCorsikaRunHeader 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 (";
+        *fLog << fTheta << ", " << runheader->GetTelesTheta() << ")..." << endl;
+    }
+    fTheta = runheader->GetTelesTheta();
+
+
+    if (fCorsikaVersion!=0 && fCorsikaVersion!=runheader->GetCorsikaVersion())
+        *fLog << warn << dbginf << "Warning - Read files have different Corsika versions..." << endl;
+    fCorsikaVersion = runheader->GetCorsikaVersion();
+
+
+    fAllEvtsTriggered |= runheader->GetAllEvtsTriggered();
+    *fLog << inf << "Only triggered events avail: " << (fAllEvtsTriggered?"yes":"no") << endl;
+
+
+    fCollArea = (MHMcCollectionArea*)plist->FindCreateObj("MHMcCollectionArea");
+    if (!fCollArea)
+        return kFALSE;
+
+    if (fAllEvtsTriggered)
+      {
+	//
+	// Calculate approximately the original number of events in each 
+	// energy bin:
+	//
+
+	const Float_t emin = corrunheader->GetELowLim();
+	const Float_t emax = corrunheader->GetEUppLim();
+	const Float_t expo = 1 + corrunheader->GetSlopeSpec();
+	const Float_t k = runheader->GetNumSimulatedShowers() / 
+	  (pow(emax,expo) - pow(emin,expo)) ;
+
+        TH2 &hall = *fCollArea->GetHistAll();
+
+	const Int_t nbinx = hall.GetNbinsX();
+
+        TAxis &axe = *hall.GetXaxis();
+	for (Int_t i = 1; i <= nbinx; i++)
+	  {
+	    const Float_t e1 = axe.GetBinLowEdge(i);
+	    const Float_t e2 = axe.GetBinLowEdge(i+1);
+
+	    if (e1 < emin || e2 > emax)
+	      continue;
+
+	    const Float_t events = k * (pow(e2, expo) - pow(e1, expo));
+	    //
+	    // We fill the i-th energy bin, with the total number of events
+	    // Second argument of Fill would be impact parameter of each
+	    // event, but we don't really need it for the collection area,
+	    // so we just put a dummy value (1.)
+	    //
+
+	    const Float_t energy = (e1+e2)/2.;
+	    hall.Fill(energy, 1., events);
+	  }
+
+        return kTRUE;
+      }
+
+    fMcTrig = (MMcTrig*)plist->FindObject(fObjName);
+    if (!fMcTrig)
+    {
+        *fLog << err << dbginf << fObjName << " [MMcTrig] not found... exit." << endl;
+        return kFALSE;
+    }
+
+    return kTRUE;
+}
+
+Int_t MMcCollectionAreaCalc::Process()
+{
+    const Double_t energy = fMcEvt->GetEnergy();
+    const Double_t impact = fMcEvt->GetImpact()/100.;
+
+    //
+    // This happens for camera files created with Camera 0.5
+    //
+    if (TMath::IsNaN(impact))
+    {
+        *fLog << err << dbginf << "ERROR - Impact=NaN (Not a number)... abort." << endl;
+        return kERROR;
+    }
+
+    if (!fAllEvtsTriggered)
+    {
+        fCollArea->FillAll(energy, impact);
+
+        if (fMcTrig->GetFirstLevel() <= 0)
+            return kTRUE;
+    }
+
+    fCollArea->FillSel(energy, impact);
+
+    return kTRUE;
+}
+
+Int_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->CalcEfficiency2();
+    }
+
+    return kTRUE;
+}
+
Index: /tags/Mars_V0-8-5/Mars/mmontecarlo/MMcCollectionAreaCalc.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmontecarlo/MMcCollectionAreaCalc.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mmontecarlo/MMcCollectionAreaCalc.h	(revision 9661)
@@ -0,0 +1,44 @@
+#ifndef MARS_MMcCollectionAreaCalc
+#define MARS_MMcCollectionAreaCalc
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+#include <TH2.h>
+
+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;
+    Bool_t fAllEvtsTriggered;
+    Float_t fTheta;
+
+    Bool_t ReInit(MParList *plist);
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
+public:
+    MMcCollectionAreaCalc(const char *input=NULL,
+                          const char *name=NULL, const char *title=NULL);
+
+    ClassDef(MMcCollectionAreaCalc, 0) // Task to calculate the collection area histogram
+};
+
+#endif 
+
Index: /tags/Mars_V0-8-5/Mars/mmontecarlo/MMcEnergyEst.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmontecarlo/MMcEnergyEst.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mmontecarlo/MMcEnergyEst.cc	(revision 9661)
@@ -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  1/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Wolfgang Wittek 1/2002 <mailto:wittek@mppmu.mpg.de>
+!   Author(s): Abelardo Moralejo 4/2003 <mailto:moralejo@pd.infn.it>
+!   Author(s): Marcos Lopez 5/2004 <mailto:marcos@gae.ucm.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MMcEnergyEst
+//
+// Class for otimizing the parameters of the energy estimator
+//
+// FIXME: the class must be made more flexible, allowing for different
+// parametrizations to be used. Also a new class is needed, a container
+// for the parameters of the energy estimator.
+// FIXME: the starting values of the parameters are now fixed.
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MMcEnergyEst.h"
+
+#include <math.h>            // fabs on Alpha
+
+#include <TMinuit.h>
+#include <TStopwatch.h>
+#include <TVirtualFitter.h>
+
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MGeomCamCT1.h"
+#include "MFEventSelector.h"
+#include "MReadTree.h"
+#include "MFCT1SelFinal.h"
+#include "MHMatrix.h"
+#include "MEnergyEstParam.h"
+#include "MMatrixLoop.h"
+#include "MChisqEval.h"
+#include "MEvtLoop.h"
+#include "MDataElement.h"
+#include "MDataMember.h"
+#include "MLog.h"
+#include "MLogManip.h"
+#include "MParameters.h"
+
+ClassImp(MMcEnergyEst);
+
+using namespace std;
+
+//------------------------------------------------------------------------
+//
+// fcn calculates the function to be minimized (using TMinuit::Migrad)
+//
+static void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)
+{
+    MEvtLoop *evtloop = (MEvtLoop*)gMinuit->GetObjectFit();
+
+    MParList  *plist  = evtloop->GetParList();
+    MTaskList *tlist = (MTaskList*)plist->FindObject("MTaskList");
+ 
+
+    // Pass current minuit parameters to the energy estimation class 
+    MEnergyEstParam *eest = (MEnergyEstParam*)tlist->FindObject("MEnergyEstParam");
+    eest->SetCoeff(TArrayD(eest->GetNumCoeff(), par));
+
+    
+    evtloop->Eventloop();
+
+
+    // Get result of the ChiSquare 
+    MParameterD *eval = (MParameterD*)plist->FindObject("MFitResult", "MParameterD");
+    
+    f = eval->GetVal();
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MMcEnergyEst::MMcEnergyEst(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MMcEnergyEst";
+    fTitle = title ? title : "Optimizer of the energy estimator";
+
+    SetHillasName("MHillas");
+    SetHillasSrcName("MHillasSrc");
+
+    //
+    // Set initial values of the parameters (close enough to the final 
+    // ones, taken from previous runs of the procedure). Parameter 
+    // fA[4] is not used in the default energy estimation model (from 
+    // D. Kranich).
+    //
+    fA.Set(5);
+    fB.Set(7);
+
+    fA[0] =  21006.2;
+    fA[1] = -43.2648;
+    fA[2] = -690.403;
+    fA[3] = -0.0428544;
+    fA[4] =  1.;
+    fB[0] = -3391.05;
+    fB[1] =  136.58;
+    fB[2] =  0.253807;
+    fB[3] =  254.363;
+    fB[4] =  61.0386;
+    fB[5] = -0.0190984;
+    fB[6] = -421695;
+}
+
+Bool_t MMcEnergyEst::SetCoeff(TArrayD &coeff)
+{
+  if (coeff.GetSize() != fA.GetSize()+fB.GetSize())
+    {
+      *fLog << err << dbginf << "Wrong number of parameters!" << endl;
+      return(kFALSE);
+    }
+
+  for (Int_t i = 0; i < fA.GetSize(); i++)
+    fA[i] = coeff[i];
+  for (Int_t i = 0; i < fB.GetSize(); i++)
+    fB[i] = coeff[i+fA.GetSize()];
+
+  return(kTRUE);
+
+}
+
+//------------------------------------------------------------------------
+//
+// Optimization (via migrad minimization) of parameters of energy estimation.
+//
+void MMcEnergyEst::FindParams()
+{
+  MParList parlist;
+
+  MFEventSelector selector;
+  selector.SetNumSelectEvts(fNevents);
+  *fLog << inf << "Read events from file '" << fInFile << "'" << endl;    
+
+  MReadTree read("Events");
+  read.AddFile(fInFile);
+  read.DisableAutoScheme();
+  read.SetSelector(&selector);
+
+  *fLog << inf << "Define columns of matrix" << endl;
+  MHMatrix matrix;
+  Int_t colenergy = matrix.AddColumn("MMcEvt.fEnergy");
+  Int_t colimpact = matrix.AddColumn("MMcEvt.fImpact");
+
+  if (colenergy < 0  ||  colimpact < 0)
+  {
+    *fLog << err << dbginf << "colenergy, colimpact = " << colenergy << ",  " 
+	  << colimpact << endl;
+    return;
+  }
+
+  MEnergyEstParam eest(fHillasName);
+  eest.Add(fHillasSrcName);
+  eest.InitMapping(&matrix);
+  
+  *fLog << inf << "--------------------------------------" << endl;
+  *fLog << inf << "Fill events into the matrix" << endl;
+  if ( !matrix.Fill(&parlist, &read, fEventFilter) )
+    return;
+  *fLog << inf << "Matrix was filled with " << matrix.GetNumRows() 
+	<< inf << " events" << endl;  
+
+  //-----------------------------------------------------------------------
+  //
+  // Setup the eventloop which will be executed in the fcn of MINUIT 
+  //
+  *fLog << inf << "--------------------------------------" << endl;
+  *fLog << inf << "Setup event loop to be used in 'fcn'" << endl;
+
+  MTaskList tasklist;
+
+  MMatrixLoop loop(&matrix);
+
+  MChisqEval eval;
+  eval.SetY1(new MDataElement(&matrix, colenergy));
+  eval.SetY2(new MDataMember("MEnergyEst.fEnergy"));
+  eval.SetOwner();
+
+  //
+  // Entries in MParList
+
+  parlist.AddToList(&tasklist);
+
+  //
+  // Entries in MTaskList
+
+  tasklist.AddToList(&loop);
+  tasklist.AddToList(&eest);
+  tasklist.AddToList(&eval);
+
+
+  *fLog << inf << "Event loop was setup" << endl;
+  MEvtLoop evtloop;
+  evtloop.SetParList(&parlist);
+
+  //
+  //----------   Start of minimization part   -------------------- 
+  //
+  // Do the minimization with MINUIT
+  //
+  // Be careful: This is not thread safe
+  //
+  *fLog << inf << "--------------------------------------" << endl;
+  *fLog << inf << "Start minimization for the energy estimator" << endl;
+
+  gMinuit = new TMinuit(12);
+  gMinuit->SetPrintLevel(-1);
+
+  gMinuit->SetFCN(fcn);
+  gMinuit->SetObjectFit(&evtloop);
+
+  // Ready for: gMinuit->mnexcm("SET ERR", arglist, 1, ierflg)
+
+  if (gMinuit->SetErrorDef(1))
+    {
+      *fLog << err << dbginf << "SetErrorDef failed." << endl;
+      return;
+    }
+
+  //
+  // Set starting values and step sizes for parameters
+  //
+  for (Int_t i=0; i<fA.GetSize(); i++)
+    {
+      TString name = "fA[";
+      name += i;
+      name += "]";
+      Double_t vinit = fA[i];
+      Double_t step  = fabs(fA[i]/3);
+
+      Double_t limlo = 0; // limlo=limup=0: no limits
+      Double_t limup = 0; 
+
+      Bool_t rc = gMinuit->DefineParameter(i, name, vinit, step, limlo, limup);
+      if (!rc)
+	continue;
+
+      *fLog << err << dbginf << "Error in defining parameter #" << i << endl;
+      return;
+    }
+
+  for (Int_t i=0; i<fB.GetSize(); i++)
+    {
+      TString name = "fB[";
+      name += i;
+      name += "]";
+      Double_t vinit = fB[i];
+      Double_t step  = fabs(fB[i]/3);
+
+      Double_t limlo = 0; // limlo=limup=0: no limits
+      Double_t limup = 0;
+
+      Bool_t rc = gMinuit->DefineParameter(i+fA.GetSize(), name, vinit, step, limlo, limup);
+      if (!rc)
+	continue;
+
+      *fLog << err << dbginf << "Error in defining parameter #" << i+fA.GetSize() << endl;
+      return;
+    }
+
+  TStopwatch clock;
+  clock.Start();
+
+  // Now ready for minimization step:
+
+  gLog.SetNullOutput(kTRUE);
+  Bool_t rc = gMinuit->Migrad();
+  gLog.SetNullOutput(kFALSE);
+  
+  if (rc)
+    {
+      *fLog << err << dbginf << "Migrad failed." << endl;
+      return;
+    }
+
+  *fLog << inf << endl;
+  clock.Stop();
+  clock.Print();
+  *fLog << inf << endl;
+
+  *fLog << inf << "Resulting Chisq: " << gMinuit->fAmin << endl;
+
+  //
+  // Update values of fA, fB:
+  //
+  for (Int_t i = 0; i < fA.GetSize(); i++)
+    {
+      Double_t x1, x2;
+      gMinuit->GetParameter(i,x1,x2);
+      fA[i] = x1;
+    }
+  for (Int_t i = fA.GetSize(); i < fA.GetSize()+fB.GetSize(); i++)
+    {
+      Double_t x1, x2;
+      gMinuit->GetParameter(i,x1,x2);
+      fB[i-fA.GetSize()] = x1;
+    }
+
+  //    eest.Print();
+  eest.StopMapping();
+  *fLog << inf << "Minimization for the energy estimator finished" << endl;
+
+}
+
+//------------------------------------------------------------------------
+//
+// Print current values of parameters
+//
+void MMcEnergyEst::Print(Option_t *o) const
+{
+  for (Int_t i = 0; i < fA.GetSize(); i++)
+    *fLog << inf << "Parameter " << i << ": " << const_cast<TArrayD&>(fA)[i] << endl;
+
+  for (Int_t i = fA.GetSize(); i < fA.GetSize()+fB.GetSize(); i++)
+    *fLog << inf << "Parameter " << i << ": " << const_cast<TArrayD&>(fB)[i-fA.GetSize()] << endl;
+
+  /*
+    // Print results
+    Double_t amin, edm, errdef;
+    Int_t nvpar, nparx, icstat;
+    gMinuit->mnstat(amin, edm, errdef, nvpar, nparx, icstat);
+    gMinuit->mnprin(3, amin);
+  */
+
+}
Index: /tags/Mars_V0-8-5/Mars/mmontecarlo/MMcEnergyEst.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmontecarlo/MMcEnergyEst.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mmontecarlo/MMcEnergyEst.h	(revision 9661)
@@ -0,0 +1,58 @@
+#ifndef MARS_MMcEnergyEst
+#define MARS_MMcEnergyEst
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#ifndef ROOT_TArrayD
+#include <TArrayD.h>
+#endif
+
+#include "MFilter.h"
+
+class MMcEnergyEst : public MParContainer
+{
+private:
+
+  TString fInFile, fOutFile;
+  TString fHillasName;
+  TString fHillasSrcName;
+  Int_t   fNevents;
+
+  MFilter *fEventFilter; //!
+
+  TArrayD fA;
+  TArrayD fB;
+
+public:
+  MMcEnergyEst(const char *name=NULL, const char *title=NULL);
+
+  void SetInFile(const TString &name)         {fInFile = name;}
+  void SetOutFile(const TString &name)        {fOutFile = name;}
+  void SetHillasName(const TString &name)     {fHillasName = name;}
+  void SetHillasSrcName(const TString &name)  {fHillasSrcName = name;}
+  void SetEventFilter(MFilter *filter)        {fEventFilter = filter;}
+  void SetNevents(Int_t n)                    {fNevents = n;}
+
+  TString GetInFile()         const {return fInFile;}
+  TString GetOutFile()        const {return fOutFile;}
+  TString GetHillasName()     const {return fHillasName;}
+  TString GetHillasSrcName()  const {return fHillasSrcName;}
+  Int_t   GetNevents()        const {return fNevents;}
+
+  Int_t   GetNumCoeffA()      const {return fA.GetSize(); }
+  Int_t   GetNumCoeffB()      const {return fB.GetSize(); }
+
+  Double_t GetCoeff(Int_t i) { return i<fA.GetSize()? fA[i] : fB[i-fA.GetSize()]; }
+
+  Bool_t SetCoeff(TArrayD &coeff);
+
+  void FindParams();
+  void Print(Option_t *o="") const;
+
+  ClassDef(MMcEnergyEst, 1) // Class for optimization of Energy estimator
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mmontecarlo/MMcThresholdCalc.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmontecarlo/MMcThresholdCalc.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mmontecarlo/MMcThresholdCalc.cc	(revision 9661)
@@ -0,0 +1,185 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): 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);
+
+using namespace std;
+
+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
+//
+Int_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.
+//
+Int_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.
+//
+Int_t MMcThresholdCalc::PostProcess()
+{
+    for (UInt_t i=0; i<fNum; i++)
+    {
+        MHMcEnergy &hist = *GetHEnergy(i);
+
+        Float_t peak;
+        Float_t sigma;
+
+        hist.Fit(1, 3);
+
+        peak  = hist.GetGaussPeak();
+        sigma = hist.GetGaussSigma();
+        hist.Fit(peak - 2.   *sigma, peak + 2.   *sigma);
+
+        peak  = hist.GetGaussPeak();
+        sigma = hist.GetGaussSigma();
+        hist.Fit(peak - fSqrt2*sigma, peak + fSqrt2*sigma);
+
+        hist.SetReadyToSave();
+    }
+    return kTRUE;
+}
+
Index: /tags/Mars_V0-8-5/Mars/mmontecarlo/MMcThresholdCalc.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmontecarlo/MMcThresholdCalc.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mmontecarlo/MMcThresholdCalc.h	(revision 9661)
@@ -0,0 +1,56 @@
+#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]; }
+
+    Int_t PreProcess(MParList* pList);
+    Int_t Process();
+    Int_t PostProcess();
+
+public:
+    MMcThresholdCalc(const Int_t dim = 0,
+                     const char* name = NULL, const char* title = NULL);
+    ~MMcThresholdCalc();
+
+    ClassDef(MMcThresholdCalc, 0) // Task to compute the energy threshold
+};
+
+#endif
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mmontecarlo/MMcTimeGenerate.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmontecarlo/MMcTimeGenerate.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mmontecarlo/MMcTimeGenerate.cc	(revision 9661)
@@ -0,0 +1,90 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Harald Kornmayer 1/2001
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+#include "MMcTimeGenerate.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MTime.h"
+
+ClassImp(MMcTimeGenerate);
+
+// --------------------------------------------------------------------------
+//
+MMcTimeGenerate::MMcTimeGenerate(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MMcTimeGenerate";
+    fTitle = title ? title : "Task to generate a random event time";
+
+    const Double_t lambda = 100; // [Hz]
+
+    fFunc = new TF1("Poisson", "[0] * exp(-[0]*x)", 0, 1);
+    fFunc->SetParameter(0, lambda);
+
+    fDeadTime = 0.1/lambda;
+}
+
+MMcTimeGenerate::~MMcTimeGenerate()
+{
+    delete fFunc;
+}
+
+
+// --------------------------------------------------------------------------
+//
+//  The PreProcess connects the raw data with this task. It checks if the 
+//  input containers exist, if not a kFalse flag is returned. It also checks
+//  if the output contaniers exist, if not they are created.
+//  This task can read either Montecarlo files with multiple trigger
+//  options, either Montecarlo files with a single trigger option.
+//
+Int_t MMcTimeGenerate::PreProcess (MParList *pList)
+{
+    // connect the raw data with this task
+
+    fTime = (MTime*)pList->FindCreateObj("MTime");
+    if (!fTime)
+        return kFALSE;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//
+Int_t MMcTimeGenerate::Process()
+{
+    Double_t dt;
+
+    do dt = fFunc->GetRandom();
+    while (dt < fDeadTime);
+
+#warning SetTime not valid anymore!
+//    fTime->SetTime(*fTime+dt/1e4); // [0.1ms]
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mmontecarlo/MMcTimeGenerate.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmontecarlo/MMcTimeGenerate.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mmontecarlo/MMcTimeGenerate.h	(revision 9661)
@@ -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;
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
+public:
+    MMcTimeGenerate(const char *name=NULL, const char *title=NULL);
+
+    ~MMcTimeGenerate();
+
+    ClassDef(MMcTimeGenerate, 0) // To generate a random time
+};
+
+#endif 
Index: /tags/Mars_V0-8-5/Mars/mmontecarlo/MMcTriggerRateCalc.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmontecarlo/MMcTriggerRateCalc.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mmontecarlo/MMcTriggerRateCalc.cc	(revision 9661)
@@ -0,0 +1,433 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Harald Kornmayer 1/2001
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Modified 4/7/2002 Abelardo Moralejo: now the dimension of fTrigger is
+//  set dinamically, to allow an arbitrary large number of trigger
+//  conditions to be processed.
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MMcTriggerRateCalc.h"
+
+#include <math.h>
+
+#include <TCanvas.h>
+#include <TGraphErrors.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MMcEvt.hxx"
+#include "MMcTrig.hxx"
+#include "MMcRunHeader.hxx"
+#include "MMcTrigHeader.hxx"
+#include "MMcCorsikaRunHeader.h"
+
+#include "MH.h"
+#include "MHMcRate.h"
+
+ClassImp(MMcTriggerRateCalc);
+
+using namespace std;
+
+void MMcTriggerRateCalc::Init(int dim, 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;
+
+    fTrigNSB = trigbg;
+    fSimNSB = simbg;
+
+    fPartId = -1; 
+
+    fShowers = 0;
+    fAnalShow = 0;
+
+    fFirst = dim>0 ?   1 : -dim;
+    fLast  = dim>0 ? dim : -dim;
+
+    fNum = fLast-fFirst+1;
+    fTrigger = new float[fNum];
+
+    for (UInt_t i=0;i<fNum;i++)
+      fTrigger[i]=0;
+
+    AddToBranchList("MMcEvt.fPartId");
+    AddToBranchList("MMcEvt.fImpact");
+    AddToBranchList("MMcEvt.fEnergy");
+    AddToBranchList("MMcEvt.fPhi");
+    AddToBranchList("MMcEvt.fTheta");
+    AddToBranchList("MMcEvt.fPhotElfromShower");
+    AddToBranchList("MMcTrig", "fNumFirstLevel", fFirst, fLast);
+
+}
+
+// ReInit: read run header to get some info later:
+
+Bool_t MMcTriggerRateCalc::ReInit(MParList *pList)
+{
+    fMcRunHeader = (MMcRunHeader*) pList->FindObject("MMcRunHeader");
+    if (!fMcRunHeader)
+    {
+        *fLog << err << dbginf << "Error - MMcRunHeader not found... exit." << endl;
+        return kFALSE;
+    }
+
+    fMcCorRunHeader = (MMcCorsikaRunHeader*) pList->FindObject("MMcCorsikaRunHeader");
+    if (!fMcCorRunHeader)
+    {
+        *fLog << err << dbginf << "Error - MMcCorsikaRunHeader not found... exit." << endl;
+        return kFALSE;
+    }
+
+    fShowers += fMcRunHeader->GetNumSimulatedShowers();
+
+    if (fMcRunHeader->GetAllEvtsTriggered())
+      {
+          *fLog << warn;
+          *fLog << "WARNING - the input data file contains only the" << endl;
+          *fLog << "events that triggered. I will assume the standard value" << endl;
+          *fLog << "for maximum impact parameter (400 m)" <<endl;
+
+
+          if (fTrigNSB[0] > 0)
+          {
+              *fLog << warn;
+              *fLog << "WARNING - NSB rate can be overestimated by up to 5%." << endl;
+              *fLog << "For a precise estimate of the total rate including NSB" << endl;
+              *fLog << "accidental triggers I need a file containing all event headers." << endl;
+          }
+          else
+          {
+            *fLog << warn << "WARNING - calculating only shower rate (no NSB accidental triggers)" << endl;
+          }
+      }
+
+    *fLog << endl << warn <<
+      "WARNING: I will assume the standard maximum off axis angle" << endl <<
+      "(5 degrees) for the original showers" << endl;
+
+
+    for (UInt_t i=0; i<fNum; i++)
+      {
+	if (fMcRunHeader->GetAllEvtsTriggered())
+	  {
+	    GetRate(i)->SetImpactMin(0.);
+	    GetRate(i)->SetImpactMax(40000.);   // in cm
+	  }
+	GetRate(i)->SetSolidAngle(2.390941702e-2);  // sr
+
+	//
+	// Set limits of energy range, coverting from GeV to TeV:
+	//
+	GetRate(i)->SetEnergyMin(fMcCorRunHeader->GetELowLim()/1000.);
+	GetRate(i)->SetEnergyMax(fMcCorRunHeader->GetEUppLim()/1000.);
+
+        TString th("MMcTrigHeader");
+	if (GetRate(i)->GetTriggerCondNum() > 0)
+	  {
+	    th += ";";
+	    th += GetRate(i)->GetTriggerCondNum();
+	  }
+
+	MMcTrigHeader* trighead = (MMcTrigHeader*) pList->FindObject(th);
+	GetRate(i)->SetMeanThreshold(trighead->GetMeanThreshold());
+	GetRate(i)->SetMultiplicity(trighead->GetMultiplicity());
+
+      }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  overloaded constructor I
+//
+//      dim:     fDimension
+//      *trigbg: number of NSB triggers for
+//               a given trigger condition.
+//      simbg:   Number of simulated events for the NSB
+//      rate:    rate of incident showers
+//
+MMcTriggerRateCalc::MMcTriggerRateCalc(float rate, int dim,
+                                       float *trigbg, float simbg,
+                                       const char *name, const char *title)
+{
+    Init(dim, trigbg, simbg, name, title);
+}
+
+
+// --------------------------------------------------------------------------
+//
+//  overloaded constructor II
+//
+//      dim:     fDimension
+//      *trigbg: number of NSB triggers for
+//               a given trigger condition.
+//      simbg:   Number of simulated events for the NSB
+//
+MMcTriggerRateCalc::MMcTriggerRateCalc(int dim, float *trigbg,float simbg,
+                                       const char *name, const char *title)
+{
+    Init(dim, 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.
+//
+Int_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);
+
+	if (fTrigNSB)
+	  rate.SetBackground(fTrigNSB[i], fSimNSB);
+	else
+	  rate.SetBackground(0., fSimNSB);
+      }
+
+    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.
+//
+Int_t MMcTriggerRateCalc::Process()
+{
+    //
+    //  Counting analysed showers (except in the case in which the file 
+    //  contains only events that triggered, since then we do not know
+    //  how many showers were analysed).
+    //
+
+    if ( ! fMcRunHeader->GetAllEvtsTriggered() &&
+	 fMcEvt->GetPhotElfromShower() )
+      fAnalShow++;
+
+    //
+    // Set PartId and check it is the same for all events
+    //
+    if (fPartId < 0)
+      fPartId = fMcEvt->GetPartId();
+    else if (fPartId != fMcEvt->GetPartId())
+      {
+	*fLog << err << dbginf << "Incident particle type seems to change";
+	*fLog << "from " << fPartId << " to " << fMcEvt->GetPartId() << endl;
+	*fLog << "in input data files... aborting." << endl;
+	return kFALSE;
+      }
+
+    //
+    //  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] ++; 
+
+	if ( ! fMcRunHeader->GetAllEvtsTriggered())
+	  GetRate(i)->UpdateBoundaries(ener, theta, phi, param);
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  The PostProcess-function calculates and shows the trigger rate
+//
+Int_t MMcTriggerRateCalc::PostProcess()
+{
+    for (UInt_t i=0; i<fNum; i++)
+    {
+        MHMcRate &rate = *GetRate(i);
+
+        rate.SetParticle(fPartId);
+        switch (fPartId)
+        {
+        case MMcEvt::kPROTON:
+	  if ((Int_t)floor(-100*fMcCorRunHeader->GetSlopeSpec()+0.5) != 275)
+	    {
+                *fLog << err << "Spectrum slope as read from input file (";
+                *fLog << fMcCorRunHeader->GetSlopeSpec() << ") does not match the expected ";
+                *fLog << "one (-2.75) for protons" << endl << "... aborting." << endl;
+                return kFALSE;
+            }
+	  rate.SetFlux(0.1091, 2.75);
+	  break;
+        case MMcEvt::kHELIUM:
+	  if ((Int_t)floor(-100*fMcCorRunHeader->GetSlopeSpec()+0.5) != 262)
+	    {
+                *fLog << err << "Spectrum slope as read from input file (";
+                *fLog << fMcCorRunHeader->GetSlopeSpec() << ") does not match the expected ";
+                *fLog << "one (-2.62) for Helium" << endl << "... aborting." << endl;
+                return kFALSE;
+	    }
+	  rate.SetFlux(0.0660, 2.62);
+	  break;
+        default:
+	  *fLog << err << "Unknown incident flux parameters for ";
+	  *fLog << fPartId<< " particle Id ... aborting." << endl;
+	  return kFALSE;
+	}
+    }
+
+    //
+    // Computing trigger rate
+    //
+    for (UInt_t i=0; i<fNum; i++)
+        GetRate(i)->CalcRate(fTrigger[i], fAnalShow, fShowers);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw rate as a funtion of discriminator threshold.
+//
+void MMcTriggerRateCalc::Draw(Option_t *)
+{
+    /*
+     Commented out, because this is creating a memory leak!
+     The histograms are neither deleted anywhere, nor it is made
+     sure, that the histograms are not overwritten.
+     Also the comment for the function doesn't match the rules.
+     BTW: please replace all arrays by Root lists (TArray*, TList, etc)
+  TCanvas *c = MH::MakeDefCanvas("Rate");
+
+  Float_t xmin = GetRate(0)->GetMeanThreshold()-0.55;
+  Float_t xmax = GetRate(fNum-1)->GetMeanThreshold()+0.55;
+  Int_t  nbins = (Int_t)((xmax-xmin)*10);
+
+  fHist[1] = new TH1F("Rate2","Trigger rate, mult. 2", nbins, xmin, xmax);
+  fHist[2] = new TH1F("Rate3","Trigger rate, mult. 3", nbins, xmin, xmax);
+  fHist[3] = new TH1F("Rate4","Trigger rate, mult. 4", nbins, xmin, xmax);
+  fHist[4] = new TH1F("Rate5","Trigger rate, mult. 5", nbins, xmin, xmax);
+
+  for (UInt_t i=0; i<fNum; i++)
+    {
+      Short_t mult = GetRate(i)->GetMultiplicity();
+
+      fHist[mult-1]->SetBinContent(fHist[mult-1]->FindBin(GetRate(i)->GetMeanThreshold()), GetRate(i)->GetTriggerRate());
+
+      fHist[mult-1]->SetBinError(fHist[mult-1]->FindBin(GetRate(i)->GetMeanThreshold()), GetRate(i)->GetTriggerRateError());
+    }
+
+  for (Int_t i = 1; i <=4; i++)
+    {
+      fHist[i]->SetLineWidth(2);
+      fHist[i]->SetMarkerStyle(20);
+      fHist[i]->SetMarkerSize(.5);
+    }
+
+  c->DrawFrame (xmin, 0.5*GetRate(fNum-1)->GetTriggerRate(), xmax, 1.2*GetRate(0)->GetTriggerRate(), "Trigger rate for multiplicity = 3, 4, 5");
+
+  c->SetLogy();
+  c->SetGridy();
+  c->SetGridx();
+
+  fHist[2]->SetLineColor(1);
+  fHist[2]->SetMarkerColor(1);
+  fHist[2]->SetMinimum(0.5*GetRate(fNum-1)->GetTriggerRate());
+  fHist[2]->GetXaxis()->SetTitle("Discr. threshold (mV)");
+  fHist[2]->GetYaxis()->SetTitle("Trigger rate (Hz)");
+  fHist[2]->GetYaxis()->SetTitleOffset(1.2);
+  fHist[2]->Draw("axis");
+  fHist[2]->Draw("same");
+
+  fHist[3]->SetLineColor(3);
+  fHist[3]->SetMarkerColor(3);
+  fHist[3]->Draw("same");
+
+  fHist[4]->SetLineColor(4);
+  fHist[4]->Draw("same");
+  fHist[4]->SetMarkerColor(4);
+     */
+}
+
Index: /tags/Mars_V0-8-5/Mars/mmontecarlo/MMcTriggerRateCalc.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmontecarlo/MMcTriggerRateCalc.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mmontecarlo/MMcTriggerRateCalc.h	(revision 9661)
@@ -0,0 +1,73 @@
+#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 MMcRunHeader;
+class MMcCorsikaRunHeader;
+class MMcTrig;
+class MHMcRate;
+class TH1F;
+
+class MMcTriggerRateCalc : public MTask
+{
+private:
+    MMcEvt    *fMcEvt;     //!
+
+    TObjArray *fMcRate;
+    TObjArray *fMcTrig;
+
+    MMcRunHeader *fMcRunHeader; 
+    MMcCorsikaRunHeader *fMcCorRunHeader; 
+
+    UInt_t     fNum;       // decoded dimension
+    UInt_t     fFirst;
+    UInt_t     fLast;
+
+    Float_t   *fTrigNSB;   // Number of triggers due to NSB alone
+    Float_t    fSimNSB;    // Number of simulated NSB-only events
+
+    Float_t   *fTrigger;   // Number of triggered showers
+    Float_t    fShowers;   // Number of simulated showers
+    Float_t    fAnalShow;  // Number of analysed showers
+
+    Int_t      fPartId;    // Incident particle that generates showers
+
+    TH1F      *fHist[5];
+
+    void Init(int dim, 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]); }
+
+    Bool_t ReInit(MParList *plist);
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
+public:
+    MMcTriggerRateCalc(int dim=0, float *trigbg=NULL, float simbg=100000,
+                       const char *name=NULL, const char *title=NULL);
+
+    MMcTriggerRateCalc(float rate, int dim, float *trigbg, float simbg,
+                       const char *name=NULL, const char *title=NULL);
+
+    ~MMcTriggerRateCalc();
+
+    TH1F* GetHist(Int_t i) {return fHist[i];}
+
+    void Draw(const Option_t *o="");
+
+    ClassDef(MMcTriggerRateCalc, 0)	// Task to compute the trigger rate
+};
+
+#endif 
Index: /tags/Mars_V0-8-5/Mars/mmontecarlo/MMcWeightEnergySpecCalc.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmontecarlo/MMcWeightEnergySpecCalc.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mmontecarlo/MMcWeightEnergySpecCalc.cc	(revision 9661)
@@ -0,0 +1,378 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Marcos Lopez  10/2003 <mailto:marcos@gae.ucm.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MMcWeightEnergySlopeCalc
+//               
+//  Change the spectrum of the MC showers simulated with Corsika (a power law)
+//  to a new one, which can be either, again a power law but with a different
+//  spectral index, or a generalizeed spectrum. The new spectrum can be 
+//  pass to this class in different ways:
+//    1. Is the new spectrum will be a power law, just introduce the slope
+//       of this power law.
+//    2. Is the new spectrum will have a general shape, different options are
+//       available:
+//       a) The new spectrum is pass as a TF1 function 
+//       b) The new spectrum is pass as a char*
+//       c) The new spectrum is pass as a "interpreted function", i.e., a 
+//          function defined inside a ROOT macro, which will be invoked by the
+//          ROOT Cint itself. This is the case when we use ROOT macros.
+//       d) The new spectrum is pass as a "real function", i.e., a 
+//          function defined inside normal c++ file.
+//
+//  Method:
+//  ------ 
+//                                 
+//  -Corsika spectrun: dN/dE = A * E^(a)  
+//    with a = fCorsikaSlope, and A = N/integral{E*de} from ELowLim to EUppLim
+//
+//  -New spectrum:     dN/dE = B * g(E)
+//    where B = N/integral{g*dE} from ELowLim to EUppLim, and N=NumEvents 
+//
+//  For converting the spectrum simulated with Corsika to the new one, we apply
+//  a weight to each event, given by:
+//
+//     W(E) = B/A * g(E)/E^(a) 
+//
+//  In the case the new spectrum is simply a power law: dN/dE = B * E^(b), we
+//  have: 
+//
+//     W(E) = B/A * E^(b-a) 
+//
+//  (The factor B/A is used in order both the original and new spectrum have 
+//   the same area (i.e. in order they represent the same number of showers))
+//
+//  Note:
+//  ------
+//   -If the the new spectrum is just a power law (i.e. the user only specify
+//     the slope), the needed calculations (such as the integral of the 
+//     spectrum) are done analytically. But if the new spectrum is given as a 
+//     TF1 object, the calculations is done numerically.
+//
+//  ToDo:
+//  ----- 
+//   -Give to the user also the possibility to specify the integral of the 
+//    spectrum as another TF1 object (or C++ function)
+//
+//
+//  Input Containers:                         
+//   MMcEvt, MMcRunHeader, MMcCorsikaRunHeader
+//                                            
+//  Output Container:                        
+//   MWeight  
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MMcWeightEnergySpecCalc.h"
+
+#include "MParList.h"
+#include "MLog.h"
+#include "MLogManip.h"
+#include "MMcEvt.hxx"
+#include "MMcRunHeader.hxx"
+#include "MMcCorsikaRunHeader.h"
+#include "MWeight.h"
+
+#include "TF1.h"
+#include "TGraph.h"
+
+ClassImp(MMcWeightEnergySpecCalc);
+
+using namespace std;
+
+
+
+void MMcWeightEnergySpecCalc::Init(const char *name, const char *title)
+{
+
+    fName  = name  ? name  : "MMcWeightEnergySpecCalc";
+    fTitle = title ? title : "Task to calculate weights to change the energy spectrum"; 
+    
+    AddToBranchList("MMcEvt.fEnergy");
+
+    fAllEvtsTriggered         =  kFALSE;
+    fTotalNumSimulatedShowers =  0;
+}
+
+
+// ---------------------------------------------------------------------------
+//
+// Constructor. The new spectrum will be just a power law.
+//
+MMcWeightEnergySpecCalc::MMcWeightEnergySpecCalc(Float_t slope, 
+					  const char *name, const char *title)
+{
+    fNewSpecIsPowLaw = kTRUE;
+    fNewSlope = slope; 
+
+    fNewSpectrum = NULL; 
+
+    Init(name,title);
+} 
+
+//
+// Constructor. The new spectrum will have a general shape, given by the user 
+// as a TF1 function.
+//
+MMcWeightEnergySpecCalc::MMcWeightEnergySpecCalc(const TF1& spectrum, 
+					  const char *name, const char *title)
+{
+    fNewSpecIsPowLaw = kFALSE;
+    fNewSpectrum = (TF1*)spectrum.Clone();
+
+    Init(name,title);
+} 
+
+//
+// As before, but the function which represent the new spectrum is given as
+// a char* . Starting from it, we build a TF1 function
+//
+MMcWeightEnergySpecCalc::MMcWeightEnergySpecCalc(const char* spectrum, 
+					  const char *name, const char *title)
+{
+    fNewSpecIsPowLaw = kFALSE;
+    fNewSpectrum = new TF1("NewSpectrum",spectrum);
+
+    Init(name,title);
+} 
+
+//
+// As before, but the new spectrum is given as a intrepreted C++ function. 
+// Starting from it we build a TF1 function.
+// This constructor is called for interpreted functions by CINT, i.e., when
+// the functions are declared inside a ROOT macro.
+//
+// NOTE: you muss do a casting to (void*) of the function that you pass to this
+//       constructor before invoking it in a macro, e.g.
+//
+//       Double_t myfunction(Double_t *x, Double_t *par)
+//         {
+//           ...
+//         }
+//
+//        MMcWeightEnergySpecCalc wcalc((void*)myfunction); 
+//
+//        tasklist.AddToList(&wcalc);
+//
+//        otherwise ROOT will invoke the constructor McWeightEnergySpecCalc(
+//         const char* spectrum, const char *name, const char *title)
+//
+MMcWeightEnergySpecCalc::MMcWeightEnergySpecCalc(void* function, 
+					  const char *name, const char *title)
+{
+    fNewSpecIsPowLaw = kFALSE;
+    fNewSpectrum = new TF1("NewSpectrum",function,0,1,1);
+
+    Init(name,title);
+} 
+
+//
+// As before, but this is the constructor for real functions, i.e. it is called
+// when invoked with the normal C++ compiler, i.e. not inside a ROOT macro.
+//
+MMcWeightEnergySpecCalc::MMcWeightEnergySpecCalc(Double_t (*function)(Double_t*x, Double_t* par), const Int_t npar,  const char *name, const char *title)
+{
+    fNewSpecIsPowLaw = kFALSE;
+    fNewSpectrum = new TF1("NewSpectrum",function,0,1,1);
+
+    Init(name,title);
+} 
+
+
+
+// ----------------------------------------------------------------------------
+//
+// Destructor. Deletes the cloned fNewSpectrum.
+//
+MMcWeightEnergySpecCalc::~MMcWeightEnergySpecCalc()
+{
+  if (fNewSpectrum)
+    delete fNewSpectrum; 
+}
+
+
+
+// ---------------------------------------------------------------------------
+//
+//
+Int_t MMcWeightEnergySpecCalc::PreProcess (MParList *pList)
+{
+
+    fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
+    if (!fMcEvt)
+      {
+	*fLog << err << dbginf << "MMcEvt not found... exit." << endl;
+	return kFALSE;
+      }
+
+    fWeight = (MWeight*)pList->FindCreateObj("MWeight");
+    if (!fWeight)
+      {
+	*fLog << err << dbginf << "MWeight not found... exit." << endl;
+	return kFALSE;
+      }
+    
+    return kTRUE;
+}
+
+
+
+// ----------------------------------------------------------------------------
+//
+// Executed each time a new root file is loaded
+// We will need fCorsikaSlope and fE{Upp,Low}Lim to calculate the weights
+//
+Bool_t MMcWeightEnergySpecCalc::ReInit(MParList *plist)
+{
+    MMcRunHeader *runheader = (MMcRunHeader*)plist->FindObject("MMcRunHeader");
+    if (!runheader)
+    {
+      *fLog << err << dbginf << "Error - MMcRunHeader not found... exit." << endl;
+      return kFALSE;
+    }
+
+    MMcCorsikaRunHeader *corrunheader  = (MMcCorsikaRunHeader*)plist->FindObject("MMcCorsikaRunHeader");
+    if (!corrunheader)
+      {
+	*fLog << err << dbginf << "Error - MMcCorsikaRunHeader not found... exit." << endl;
+	return kFALSE;
+      }
+
+
+    fCorsikaSlope = (Double_t)corrunheader->GetSlopeSpec();
+    fELowLim      = (Double_t)corrunheader->GetELowLim();
+    fEUppLim      = (Double_t)corrunheader->GetEUppLim();
+
+    fTotalNumSimulatedShowers += runheader->GetNumSimulatedShowers();    
+    fAllEvtsTriggered |= runheader->GetAllEvtsTriggered();    
+
+
+
+    *fLog << inf << "Slope of primaries' energy spectrum of Simulated showers: " << fCorsikaSlope << endl;
+    *fLog << inf << "Limits of energy range of Simulated showers: " 
+	  << fELowLim <<" - " << fEUppLim << endl;
+    *fLog << inf << "New Slope for Simulated showers: " << fNewSlope << endl;
+    *fLog << inf << "Total Number of Simulated showers: " 
+	  << fTotalNumSimulatedShowers << endl;    
+    *fLog << inf << "Only triggered events avail: " << (fAllEvtsTriggered?"yes":"no") << endl;
+
+
+
+    //
+    // Sanity checks to be sure that we won't divide by zero later on
+    //
+    if(fCorsikaSlope == -1. || fNewSlope == -1.) 
+      {
+	*fLog << err << "The Slope of the power law must be different of -1... exit" << endl;
+	return kFALSE;
+      }
+
+
+    //
+    // Starting from fCorsikaSlope and fE{Upp,Low}Lim, calculate the integrals
+    // of both, the original Corsika spectrum and the new one.
+    //
+    //
+    // For the Corsika simulated spectrum (just a power law), we have:
+    //
+    fCorSpecInt = ( pow(fEUppLim,1+fCorsikaSlope) - pow(fELowLim,1+fCorsikaSlope) ) / ( 1+fCorsikaSlope );
+ 
+ 
+    //
+    // For the new spectrum:
+    //
+    if (fNewSpecIsPowLaw)     // just the integral of a power law
+      {
+	fNewSpecInt = ( pow(fEUppLim,1+fNewSlope) - pow(fELowLim,1+fNewSlope) )/ ( 1+fNewSlope );
+      }
+    else
+      { 
+	fNewSpectrum->SetRange(fELowLim, fEUppLim);
+
+	// In this case we have to integrate the new spectrum numerically. We 
+	// could do simply fNewSpectrum->Integral(fELowLim,fEUppLim), but ROOT
+	// fails integrating up to fEUppLim for a sharp cutoff spectrum
+	
+	//
+	// Trick to calculate the integral numerically (it works better than 
+	// fNewSpectrum->Integral(fELowLim,fEUppLim) (although not perfectlly)
+	//
+	fNewSpectrum->SetNpx(1000);
+	TGraph gr(fNewSpectrum,"i");
+	Int_t Npx = gr.GetN();
+	Double_t* y = gr.GetY();
+
+	const Double_t integral = y[Npx-1];
+	fNewSpecInt = integral; 
+    }
+
+
+    return kTRUE;
+}
+
+
+
+// ----------------------------------------------------------------------------
+//
+//
+Int_t MMcWeightEnergySpecCalc::Process()
+{
+    const Double_t energy = fMcEvt->GetEnergy();
+
+    const Double_t C = fCorSpecInt / fNewSpecInt;
+    Double_t weight;
+
+
+    if (fNewSpecIsPowLaw)   
+      weight = C * pow(energy,fNewSlope-fCorsikaSlope);
+    else
+      weight = C * fNewSpectrum->Eval(energy) / pow(energy,fCorsikaSlope);
+     
+
+    fWeight->SetWeight( weight );
+
+    return kTRUE;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mmontecarlo/MMcWeightEnergySpecCalc.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmontecarlo/MMcWeightEnergySpecCalc.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mmontecarlo/MMcWeightEnergySpecCalc.h	(revision 9661)
@@ -0,0 +1,76 @@
+#ifndef MARS_MMcWeightEnergySpecCalc
+#define MARS_MWeigthEnergySlopeCalc
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+
+class MParList;
+class MMcEvt;
+class MWeight;
+class TF1;
+
+
+class MMcWeightEnergySpecCalc : public MTask
+{
+
+ private:
+
+    const MMcEvt *fMcEvt;
+    MWeight  *fWeight;
+
+    TF1*     fNewSpectrum;     // Function with the new spectrum
+
+    Bool_t   fNewSpecIsPowLaw; // Tells whether the new spectrum is introduced 
+                               //as a TF1 object or not
+    Double_t fCorsikaSlope; // Slope of energy spectrum generated with Corsika
+    Double_t fNewSlope;     // Slope of the new spectrum (if it is a power law)
+    Double_t fELowLim;      
+    Double_t fEUppLim;      // Limits of energy range for generation
+    Double_t fCorSpecInt;   // Value of the integrals of the Corsika and new
+    Double_t fNewSpecInt;   //spectrum respectively, between fElow and fUppLim
+
+    UInt_t   fTotalNumSimulatedShowers;
+    Bool_t   fAllEvtsTriggered;
+
+    void   Init(const char *name, const char *title);
+    Bool_t ReInit(MParList *plist); 
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+   
+
+ public:
+
+    MMcWeightEnergySpecCalc(const Float_t slope,
+			    const char *name=NULL, const char *title=NULL);
+
+    MMcWeightEnergySpecCalc(const TF1& spectrum,
+			    const char *name=NULL, const char *title=NULL);
+
+    MMcWeightEnergySpecCalc(const char* spectrum,
+			    const char *name=NULL, const char *title=NULL);
+   
+    MMcWeightEnergySpecCalc(void *function,
+			    const char *name=NULL, const char *title=NULL);
+ 
+    MMcWeightEnergySpecCalc(Double_t (*function)(Double_t* x, Double_t* par),
+	      const Int_t npar, const char *name=NULL, const char *title=NULL);
+    
+
+    ~MMcWeightEnergySpecCalc();
+
+
+    ClassDef(MMcWeightEnergySpecCalc, 0) // Task to convert the spectrum of the MC showers simulated with Corsika to a different one, by using weights
+};
+
+#endif 
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mmontecarlo/Makefile
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmontecarlo/Makefile	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mmontecarlo/Makefile	(revision 9661)
@@ -0,0 +1,38 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#------------------------------------------------------------------------------
+
+#
+# Handling name of the Root Dictionary Files
+#
+CINT  = MonteCarlo
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES = -I. -I../mbase -I../mmc -I../mhbase -I../mhist -I../mhistmc \
+	   -I../mgeom -I../manalysis -I../mtools -I../mfileio          \
+           -I../mfilter -I../mdata -I../mfbase
+
+SRCFILES = MMcCollectionAreaCalc.cc \
+	   MMcThresholdCalc.cc \
+           MMcTimeGenerate.cc \
+	   MMcTriggerRateCalc.cc \
+	   MMcEnergyEst.cc \
+	   MMcWeightEnergySpecCalc.cc
+
+############################################################
+
+all: $(OBJS)
+
+include ../Makefile.rules
+
+mrproper:	clean rmbak
Index: /tags/Mars_V0-8-5/Mars/mmontecarlo/MonteCarloIncl.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmontecarlo/MonteCarloIncl.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mmontecarlo/MonteCarloIncl.h	(revision 9661)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-8-5/Mars/mmontecarlo/MonteCarloLinkDef.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mmontecarlo/MonteCarloLinkDef.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mmontecarlo/MonteCarloLinkDef.h	(revision 9661)
@@ -0,0 +1,14 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class MMcThresholdCalc+;
+#pragma link C++ class MMcTimeGenerate+;
+#pragma link C++ class MMcCollectionAreaCalc+;
+#pragma link C++ class MMcTriggerRateCalc+;
+#pragma link C++ class MMcEnergyEst+;
+#pragma link C++ class MMcWeightEnergySpecCalc+;
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mona.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mona.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mona.cc	(revision 9661)
@@ -0,0 +1,347 @@
+#include <TApplication.h>
+
+#include <TThread.h>
+#include <TCanvas.h>
+#include <TMethod.h>          // GetMenuItems
+
+#include <TGButton.h>
+
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MEvtLoop.h"
+
+#include "MLogManip.h"
+
+#include "MRawSocketRead.h"
+#include "MGeomApply.h"
+#include "MCerPhotAnal2.h"
+#include "MFillH.h"
+#include "MFRealTimePeriod.h"
+#include "MHTriggerLvl0.h"
+#include "MHCamera.h"         // ::Class(), SetFreezed
+#include "MHCamEvent.h"       // MHCamEvent
+#include "MHEvent.h"          // MHEvent::GetHist()
+
+#include "MOnlineDump.h"
+#include "MOnlineDisplay.h"
+
+#include "MImgCleanStd.h"
+#include "MHillasCalc.h"
+#include "MHillasSrcCalc.h"
+#include "MEventRateCalc.h"
+
+#include "MArgs.h"
+
+// --------------------------------------------------------------------
+
+#include "MTime.h"
+#include "MRawEvtHeader.h"       // MRawEvtHeader
+#include "MRawRunHeader.h"       // MRawRunHeader
+
+using namespace std;
+
+void StartUpMessage()
+{
+    gLog << all << endl;
+
+    //                1         2         3         4         5
+    //       12345678901234567890123456789012345678901234567890
+    gLog << "==================================================" << endl;
+    gLog << "                    MONA V" << MARSVER << "                      " << endl;
+    gLog << "              Magic Online Analysis               " << endl;
+    gLog << "            Compiled on <" << __DATE__ << ">"       << endl;
+    gLog << "               Using ROOT v" << ROOTVER             << endl;
+    gLog << "==================================================" << endl;
+    gLog << endl;
+}
+
+void Remove(TMethod *m, const char *name)
+{
+    if (TString(m->GetName()).BeginsWith(name))
+        m->SetMenuItem(kMenuNoMenu);
+}
+
+void ChangeContextMenus()
+{
+    TList l;
+    MHCamera::Class()->GetMenuItems(&l);
+    TIter Next(&l);
+    TMethod *m=NULL;
+    while ((m=(TMethod*)Next()))
+    {
+        Remove(m, "DrawClone");
+        Remove(m, "SetName");
+        Remove(m, "Delete");
+        Remove(m, "DrawClass");
+        Remove(m, "Dump");
+        Remove(m, "Inspect");
+        Remove(m, "Smooth");
+        Remove(m, "Fit");
+        Remove(m, "Divide");
+        Remove(m, "Add");
+        Remove(m, "Multiply");
+        Remove(m, "Delete");
+        Remove(m, "SetLineAttributes");
+        Remove(m, "SetFillAttributes");
+        Remove(m, "SetMarkerAttributes");
+        Remove(m, "SetDrawOption");
+    }
+}
+
+#include "MPedPhotCam.h"
+Bool_t Loop(MOnlineDisplay *display, Int_t port)
+{
+    display->Reset();
+
+    //
+    // 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
+    //
+    MRawSocketRead reader;
+    reader.SetPort(port);
+
+    //
+    // 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);
+    tasks.AddToList(&reader);
+
+    MPedPhotCam pcam;
+    plist.AddToList(&pcam);
+
+    MGeomApply geomapl;
+    MCerPhotAnal2 ncalc;
+    tasks.AddToList(&geomapl);
+    tasks.AddToList(&ncalc);
+
+    MEventRateCalc tcalc;
+    tcalc.SetNumEvents(100);
+    tasks.AddToList(&tcalc);
+
+    MFillH fill1("MHEvent",    "MCerPhotEvt", "MFillEvent");
+    MFillH fill2("MHCamEvent", "MCerPhotEvt", "MFillCamEvent");
+
+    MFRealTimePeriod filter;
+    fill1.SetFilter(&filter);
+
+    MHTriggerLvl0 trigmap(128, "Above 128");
+    MFillH fill3(&trigmap, "MRawEvtData", "MFillTriggerLvl0");
+
+    tasks.AddToList(&filter);
+
+    tasks.AddToList(&fill1);
+    tasks.AddToList(&fill2);
+    tasks.AddToList(&fill3);
+
+    MHCamEvent hist("PedestalRms");
+    hist.SetType(1);
+    plist.AddToList(&hist);
+
+    // -------------------------------------------
+
+    MHCamEvent maxhi("MaxIdxHi", "Index of slice with maximum content (hi-gain)");
+    MHCamEvent maxlo("MaxIdxLo", "Index of slice with maximum content (lo-gain)");
+    maxhi.SetType(3);
+    maxlo.SetType(4);
+    plist.AddToList(&maxhi);
+    plist.AddToList(&maxlo);
+
+    // -------------------------------------------
+
+    MFillH hfilla("MaxIdxHi", "MRawEvtData", "FillMaxIdxHi");
+    MFillH hfillb("MaxIdxLo", "MRawEvtData", "FillMaxIdxLo");
+    MFillH hfillc("Pedestals [MHCamEvent]", "MPedPhotCam", "FillPedestal");
+    MFillH hfilld("PedestalRms", "MPedPhotCam", "FillPedestalRms");
+    tasks.AddToList(&hfilla);
+    tasks.AddToList(&hfillb);
+    tasks.AddToList(&hfillc);
+    tasks.AddToList(&hfilld);
+
+    MOnlineDump dump;
+    dump.SetFilter(&filter);
+    display->SetTask(&dump);
+    tasks.AddToList(&dump);
+
+
+    MImgCleanStd      clean;
+    MHillasCalc       hcalc;
+    MHillasSrcCalc    scalc; // !!Preliminary!! Will be removed later!
+    MFillH hfill3("MHHillas",   "MHillas",    "MFillHillas");
+    MFillH hfill4("MHHillasSrc","MHillasSrc", "MFillHillasSrc");
+    tasks.AddToList(&clean);
+    tasks.AddToList(&hcalc);
+    tasks.AddToList(&scalc);
+    tasks.AddToList(&hfill3);
+    tasks.AddToList(&hfill4);
+
+    MEvtLoop magic;
+    magic.SetParList(&plist);
+
+    magic.SetDisplay(display);
+    magic.SetProgressBar((TGProgressBar*)NULL);
+
+    if (!magic.Eventloop())
+    {
+        gLog << err << "Mona Eventloop error..." << endl;
+        return kFALSE;
+    }
+
+    tasks.PrintStatistics();
+    return kTRUE;
+}
+
+//
+// By defining the function return type 'void' instead of
+// 'void*' we tell TThread to create a detached thread,
+// but calling Exit() in a detached thread results in a crash
+// when the TGApplication is terminated.
+//
+void *thread(void *ptr)
+{
+    const Int_t port = *((Int_t**)ptr)[0];
+    MOnlineDisplay &d = *((MOnlineDisplay**)ptr)[1];
+
+    //
+    // If a loop is stopped reinitialize a new loop until the
+    // user requested to exit the program.
+    //
+    while (d.CheckStatus()!=MStatusDisplay::kFileExit)
+        Loop(&d, port);
+
+
+    gLog << dbg << "Loop stopped... exit thread()" << endl;
+
+    return 0;
+}
+
+/*
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,10,02)
+#include <TRootGuiFactory.h>
+#include <TPluginManager.h>
+void InitGuiFactory()
+{
+   if (gROOT->IsBatch())
+       gROOT->SetBatch(kFALSE);
+
+    //
+    // Must be loaded by hand, because it is not loaded by TGApplication.
+    // We could also use TApplication instead, but TApplication doesn't
+    // deal with the DISPLAY variable in a convient way.
+    //
+    TPluginHandler *h;
+    if ((h = gROOT->GetPluginManager()->FindHandler("TGuiFactory", "root")))
+    {
+        if (h->LoadPlugin() == -1)
+            return;
+        gGuiFactory = (TGuiFactory*)h->ExecPlugin(0);
+    }
+}
+#endif
+*/
+
+static void Usage()
+{
+    gLog << all << endl;
+    gLog << "Sorry the usage is:" << endl;
+    gLog << "   mona [-?] [-h] [-a0] [-h] [-pn] [-vn]" << endl << endl;
+    gLog << "     -a0: Do not use Ansii codes." << endl;
+    gLog << "     -pn: TCP/IP port n [default=7000]" << endl;
+    gLog << "     -vn: Verbosity level n [default=2]" << endl << endl;
+    gLog << "     -?/-h: This help" << endl << endl;
+}
+
+
+int main(int argc, char **argv)
+{
+    StartUpMessage();
+
+    //
+    // Evaluate arguments
+    //
+    MArgs arg(argc, argv);
+
+    if (arg.HasOption("-?") || arg.HasOption("-h"))
+    {
+        Usage();
+        return -1;
+    }
+
+    //
+    // Set verbosity to highest level.
+    //
+    gLog.SetDebugLevel(arg.HasOption("-v") ? arg.GetIntAndRemove("-v") : 2);
+
+    if (arg.HasOption("-a") && arg.GetIntAndRemove("-a")==0)
+        gLog.SetNoColors();
+
+    const Int_t port = arg.HasOption("-p") ? arg.GetIntAndRemove("-p") : 7000;
+
+    //
+    // check for the right usage of the program
+    //
+    if (arg.GetNumArguments()>0)
+    {
+        Usage();
+        return -1;
+    }
+
+    TApplication app("Mona", &argc, argv);
+    if (gROOT->IsBatch() || !gClient)
+    {
+        gLog << "Bombing... maybe your DISPLAY variable is not set correctly!" << endl;
+        return 1;
+    }
+
+    /*
+    TGApplication app("Mona", &argc, argv);
+
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,10,02)
+    InitGuiFactory();
+#endif
+    */
+
+    ChangeContextMenus();
+
+    //
+    // Starting MStatusDisplay in the thread results in hangs
+    // if the thread is terminated (by return)
+    //
+    gLog << dbg << "Starting Display..." << flush;
+    MOnlineDisplay d;
+    d.SetWindowName("Magic ONline Analysis");
+    d.SetIconName("Mona");
+
+    d.SetBit(MStatusDisplay::kExitLoopOnExit);
+    gLog << "done." << endl;
+
+    // gDebug=1;
+
+    gLog << dbg << "Starting Thread..." << flush;
+    const void *ptr[2] = { &port, &d };
+    TThread t(thread, ptr);
+    t.Run();
+    gLog << "done." << endl;
+
+    gLog << dbg << "Starting System loop... " << endl;
+    app.Run(kTRUE);
+    gLog << dbg << "System loop stopped." << endl;
+
+    d.UnmapWindow();
+
+    gLog << dbg << "Waiting for termination of thread... (be patient)" << endl;
+    while (t.GetState()!=TThread::kCanceledState)
+        gSystem->ProcessEvents();
+
+    gLog << dbg << "Thread terminated... joining." << endl;
+
+    TThread::Join(t.GetId()); //- seems that it is implicitly done... why?
+
+    gLog << dbg << "Exit MONA." << endl;
+
+    return 0;
+}
Index: /tags/Mars_V0-8-5/Mars/mpedestal/MMcPedestalCopy.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mpedestal/MMcPedestalCopy.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mpedestal/MMcPedestalCopy.cc	(revision 9661)
@@ -0,0 +1,167 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MMcPedestalCopy
+//
+//  This task looks for the ìnformation about FADC pedestals in
+//  MMcFadcHeader and translates it to the pedestal values in
+//  MPedestalCam
+//
+//  Input Containers:
+//   MMcFadcHeader
+//   [MMcRunHeader]
+//   [MRawRunHeader]
+//
+//  Output Containers:
+//   MPedestalCam
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MMcPedestalCopy.h"
+
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MPedestalPix.h"
+#include "MPedestalCam.h"
+
+#include "MRawRunHeader.h"
+#include "MMcRunHeader.hxx"
+#include "MMcFadcHeader.hxx"
+
+ClassImp(MMcPedestalCopy);
+
+using namespace std;
+
+MMcPedestalCopy::MMcPedestalCopy(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MMcPedestalCopy";
+    fTitle = title ? title : "Copy MC 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->IsMonteCarloRun();
+}
+
+
+
+// --------------------------------------------------------------------------
+//
+// Make sure that there is a MPedestalCam object in the parameter list.
+//
+Int_t  MMcPedestalCopy::PreProcess(MParList *pList)
+{
+  if ( ! pList->FindObject(AddSerialNumber("MPedestalCam")) )
+    pList->FindCreateObj(AddSerialNumber("MPedestalCam"));
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Check for the runtype.
+// Search for MPedestalCam and MMcFadcHeader.
+//
+Bool_t MMcPedestalCopy::ReInit(MParList *pList)
+{
+    //
+    // If it is no MC file skip this function...
+    //
+    if (!CheckRunType(pList))
+      {
+	*fLog << inf << "This is no MC file... skipping." << endl;
+        return kTRUE;
+      }
+
+    //
+    // Now check the existance of all necessary containers. This has
+    // to be done only if this is a MC file.
+    //
+    MMcFadcHeader *fadc = (MMcFadcHeader*)pList->FindObject(AddSerialNumber("MMcFadcHeader"));
+    if (!fadc)
+    {
+        *fLog << err << dbginf << "MMcFadcHeader not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    MPedestalCam *pedcam = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
+    if (!pedcam)
+      {
+        *fLog << err << dbginf << "Cannot create " << AddSerialNumber("MPedestalCam") <<"... Exiting." << endl;
+
+        return kFALSE;
+      }
+
+    MMcRunHeader *mcrun = (MMcRunHeader*)pList->FindObject("MMcRunHeader");
+    if (!mcrun)
+        *fLog << warn << dbginf << "MMcRunHeader not found... assuming camera<0.7" << endl;
+
+    const int num = pedcam->GetSize();
+
+    const Bool_t camver70 = mcrun && mcrun->GetCamVersion()>=70;
+
+    for (int i=0; i<num; i++)
+    {
+        MPedestalPix &pix = (*pedcam)[i];
+
+        // Here one should compute the Pedestal taking into account how
+        // the MC makes the transformation analogic-digital for the FADC.
+        // This is done only once per file -> not time critical.
+
+        const Float_t pedest = fadc->GetPedestal(i);
+        const Float_t sigma  = camver70 ? fadc->GetPedestalRmsHigh(i) : fadc->GetElecNoise(i);
+
+        pix.Set(pedest, sigma);
+
+    }
+
+    if (camver70)
+        pedcam->SetReadyToSave();
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mpedestal/MMcPedestalCopy.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mpedestal/MMcPedestalCopy.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mpedestal/MMcPedestalCopy.h	(revision 9661)
@@ -0,0 +1,21 @@
+#ifndef MARS_MMcPedestalCopy
+#define MARS_MMcPedestalCopy
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MMcPedestalCopy : public MTask
+{
+private:
+    Bool_t CheckRunType(MParList *pList) const;
+    Int_t  PreProcess(MParList *pList);
+    Bool_t ReInit(MParList *pList);
+
+public:
+    MMcPedestalCopy(const char *name=NULL, const char *title=NULL);
+
+    ClassDef(MMcPedestalCopy, 0)   // Task which copies the pedestals from the MC into the standard container
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mpedestal/MMcPedestalNSBAdd.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mpedestal/MMcPedestalNSBAdd.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mpedestal/MMcPedestalNSBAdd.cc	(revision 9661)
@@ -0,0 +1,227 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Oscar Blanch, 11/2001 <mailto:blanch@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2001
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MMcPedestalNSBAdd
+//  -----------------
+//
+//  This Task adds the contribution of the diffuse NSB to the FADC
+//  pedestals. We assume that NSB introduces larger fluctuation but does
+//  not change the mean value.
+//  To be precise we add quadratically to the rms, which is already in
+//  MPedestalCam, the NSB contribution.
+//  The number of photons from the diffuse NSB follows a poisson
+//  distribution with expected mean value X, then its standard deviation
+//  is sqrt(X).
+//  X is the number of phe per ns so we have to convert in FADC counts per
+//  slice:
+//
+//  Y = sqrt(X * FADC_time / Number_of_slices * pixel_size)
+//      * Amp_single_phe_response
+//
+//  Input Containers:
+//   MMcFadcHeader
+//   MRawRunHeader
+//   [MMcRunHeader]
+//
+//  Output Containers:
+//   MPedestalCam
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MMcPedestalNSBAdd.h"
+
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MGeomCam.h"
+#include "MGeomPix.h"
+
+#include "MPedestalPix.h"
+#include "MPedestalCam.h"
+
+#include "MRawRunHeader.h"
+#include "MMcRunHeader.hxx"
+#include "MMcFadcHeader.hxx"
+
+ClassImp(MMcPedestalNSBAdd);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MMcPedestalNSBAdd::MMcPedestalNSBAdd(const Float_t difnsb,
+                                     const char *name, const char *title)
+    : fDnsbPixel(difnsb)
+{
+    fName  = name  ? name  : "MMcPedestalNSBAdd";
+    fTitle = title ? title : "Add diffuse NSB to the pedestal signal";
+
+    //
+    // 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->IsMonteCarloRun();
+}
+
+// --------------------------------------------------------------------------
+//
+// Check for the camera version. This class should not be used with
+// camera files >= 0.7
+//
+Bool_t MMcPedestalNSBAdd::CheckCamVersion(MParList *pList) const
+{
+    const MMcRunHeader *run = (MMcRunHeader*)pList->FindObject("MMcRunHeader");
+    if (!run)
+        *fLog << warn << dbginf << "MMcRunHeader not found... assuming camera<0.7" << endl;
+
+    return !run || run->GetCamVersion()<70;
+}
+
+// --------------------------------------------------------------------------
+//
+// 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 it is no MC file skip this function...
+    //
+    if (!CheckRunType(pList))
+        return kTRUE;
+
+    //
+    // If it is the wrong camera version this algorithm is not needed...
+    //
+    if (!CheckCamVersion(pList))
+        return kTRUE;
+
+    //
+    // Now check the existance of all necessary containers. This has
+    // to be done only if this is a MC file and the camera version
+    // is correct.
+    //
+    MPedestalCam *pedcam = (MPedestalCam*)pList->FindCreateObj(AddSerialNumber("MPedestalCam"));
+    if (!pedcam)
+	return kFALSE;
+
+    MMcFadcHeader *fadc = (MMcFadcHeader*)pList->FindObject(AddSerialNumber("MMcFadcHeader"));
+    if (!fadc)
+    {
+        *fLog << err << dbginf << "MMcFadcHeader not found... aborting." << endl;
+	return kFALSE;
+    }
+
+    MGeomCam *geom = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
+    if (!geom)
+    {
+        *fLog << err << dbginf << "MGeomCam not found... aborting." << endl;
+	return kFALSE;
+    }
+
+    const Float_t dnsbpix = GetDnsb(pList) * 50.0/15.0;
+
+    if (dnsbpix < 0)
+        return kFALSE;
+
+    const int num = pedcam->GetSize();
+
+    for (int i=0; i<num; i++)
+    {
+        MPedestalPix &pix    = (*pedcam)[i];
+
+        const Float_t pedrms = pix.GetPedestalRms();
+        const Float_t ratio  = geom->GetPixRatio(i);
+        const Float_t ampl   = fadc->GetAmplitud();
+
+	pix.SetPedestalRms(sqrt(pedrms*pedrms + dnsbpix*ampl*ampl/ratio));
+    }
+
+    pedcam->SetReadyToSave();
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mpedestal/MMcPedestalNSBAdd.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mpedestal/MMcPedestalNSBAdd.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mpedestal/MMcPedestalNSBAdd.h	(revision 9661)
@@ -0,0 +1,27 @@
+#ifndef MARS_MMcPedestalNSBAdd
+#define MARS_MMcPedestalNSBAdd
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MMcPedestalNSBAdd : public MTask
+{
+private:
+    Float_t fDnsbPixel;
+
+    Bool_t CheckCamVersion(MParList *pList) const;
+    Bool_t CheckRunType(MParList *pList) const;
+
+    Float_t GetDnsb(MParList *pList) const;
+
+    Bool_t ReInit(MParList *pList);
+
+public:
+    MMcPedestalNSBAdd(const Float_t difnsb = -1.0,
+                      const char *name=NULL, const char *title=NULL);
+
+    ClassDef(MMcPedestalNSBAdd, 0)   // Task which adds the NSB fluctuations to the pedestals rms
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mpedestal/MPedCalcFromData.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mpedestal/MPedCalcFromData.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mpedestal/MPedCalcFromData.cc	(revision 9661)
@@ -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 expressed
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Josep Flix 06/2004 <mailto:jflix@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//   MPedCalcFromData                                                      //
+//                                                                         //
+//  Input Containers:                                                      //
+//   MRawEvtData                                                           //
+//                                                                         //
+//  Output Containers:                                                     //
+//   MPedestalCam                                                          //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MPedCalcFromData.h"
+#include "MExtractor.h"
+
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MRawRunHeader.h"  
+#include "MRawEvtPixelIter.h"
+#include "MRawEvtData.h"
+
+#include "MPedestalPix.h"
+#include "MPedestalCam.h"
+
+ClassImp(MPedCalcFromData);
+
+using namespace std;
+
+MPedCalcFromData::MPedCalcFromData(const char *name, const char *title) 
+{
+    fName  = name  ? name  : "MPedCalcFromData";
+    fTitle = title ? title : "Task to calculate pedestals from data runs";
+
+    AddToBranchList("fHiGainPixId");
+    AddToBranchList("fHiGainFadcSamples");
+
+    SetRange(fLoGainFirst, fLoGainLast);
+    Clear();
+}
+
+void MPedCalcFromData::Clear(const Option_t *o)
+{
+
+  fRawEvt    = NULL;
+  fRunHeader = NULL;
+
+}
+
+void MPedCalcFromData::SetLoRange(Byte_t lofirst, Byte_t lolast)
+{
+    fLoGainFirst = lofirst;
+    fLoGainLast = lolast;
+    
+    fWindowSizeLoGain = lolast - lofirst;
+
+}
+
+Int_t MPedCalcFromData::PreProcess( MParList *pList )
+{
+    Clear();
+    
+    fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
+    if (!fRawEvt)
+    {
+	*fLog << err << "MRawEvtData not found... aborting." << endl;
+	return kFALSE;
+    }
+    
+    fRunHeader = (MRawRunHeader*)pList->FindObject(AddSerialNumber("MRawRunHeader"));
+    if (!fRunHeader)
+    {
+	*fLog << err << AddSerialNumber("MRawRunHeader") << " not found... aborting." << endl;
+	return kFALSE;
+    }
+    
+    fPedestals = (MPedestalCam*)pList->FindCreateObj("MPedestalCam");
+    if (!fPedestals)
+	return kFALSE;
+    
+    return kTRUE;
+}
+
+
+Bool_t MPedCalcFromData::ReInit(MParList *pList)
+{
+  
+  Int_t npixels  = fPedestals->GetSize();
+  
+  if (fSumx.GetSize()==0)
+    {
+      fSumx. Set(npixels);
+      fSumx2.Set(npixels);
+      fEvtCounter.Set(npixels);
+      fTotalCounter.Set(npixels);
+
+      fEvtCounter.Reset();
+      fTotalCounter.Reset();
+      fSumx.Reset();
+      fSumx2.Reset();
+    }
+  
+  return kTRUE;
+      
+}
+
+Int_t MPedCalcFromData::Process()
+{
+
+  MRawEvtPixelIter pixel(fRawEvt);
+  
+  while (pixel.Next())
+    {
+
+      const UInt_t idx    = pixel.GetPixelId();
+      
+      if ( (UInt_t)pixel.GetMaxHiGainSample() < fHiGainThreshold ) {
+	  
+	  fEvtCounter[idx]++;
+
+	  Byte_t *ptr = pixel.GetLoGainSamples() + fLoGainFirst;
+	  Byte_t *end = ptr + fWindowSizeLoGain;
+	  
+	  UInt_t sum = 0;
+	  UInt_t sqr = 0;
+	  
+	  if (fWindowSizeLoGain != 0)
+	  {
+	      do
+	      {
+		  sum += *ptr;
+		  sqr += *ptr * *ptr;
+	      }
+	      while (++ptr != end);
+	  }
+	  
+	  const Float_t msum = (Float_t)sum;
+	  fSumx[idx]          += msum;
+	  
+	  const Float_t sqrsum  = msum*msum;
+	  fSumx2[idx]          += sqrsum;
+
+	  if ((UInt_t)fEvtCounter[idx] == fDump){
+	      
+	      // Compute pedestals and rms from the sample
+	      const ULong_t n     = fWindowSizeLoGain*fDump;
+
+	      const Float_t sum  = fSumx.At(idx);
+	      const Float_t sum2 = fSumx2.At(idx);
+	      const Float_t higainped = sum/n;	      
+
+	      // 1. Calculate the Variance of the sums:
+	      Float_t higainVar = (sum2-sum*sum/fDump)/(fDump-1.);
+	      // 2. Scale the variance to the number of slices:
+	      higainVar /= (Float_t)(fWindowSizeLoGain);
+	      // 3. Calculate the RMS from the Variance:
+	      (*fPedestals)[idx].Set(higainped, higainVar < 0 ? 0. : TMath::Sqrt(higainVar));
+
+	      fTotalCounter[idx]++;
+	      fEvtCounter[idx]=0;
+	      fSumx[idx]=0;
+	      fSumx2[idx]=0;
+	  };
+      }
+      
+    };
+  
+  fPedestals->SetReadyToSave();
+  return kTRUE;
+}
+
Index: /tags/Mars_V0-8-5/Mars/mpedestal/MPedCalcFromData.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mpedestal/MPedCalcFromData.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mpedestal/MPedCalcFromData.h	(revision 9661)
@@ -0,0 +1,59 @@
+#ifndef MARS_MPedCalcFromData
+#define MARS_MPedCalcFromData
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         
+// MPedCalcFromData
+//                                                                         
+// Evaluate the pedestal from real data. Uses pixels which have no switched to Low Gain
+// to take pedestals from Low Gain samples.
+//
+// Author: J. Flix (jflix@ifae.es)
+// Date: 25-06-2004
+//                                                                         
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef ROOT_TArrayD
+#include <TArrayD.h>
+#endif
+
+#ifndef ROOT_TArrayI
+#include <TArrayI.h>
+#endif
+
+#ifndef MARS_MExtractor
+#include "MExtractor.h"
+#endif
+
+class MPedCalcFromData : public MExtractor
+{
+
+    UInt_t fDump; // Number for dumping.
+    Byte_t fLoGainFirst;      // First FADC slice Lo-Gain (currently set to: 3) 
+    Byte_t fLoGainLast;       // Last FADC slice Lo-Gain (currently set to: 14) 
+    Byte_t fWindowSizeLoGain;             // Number of Lo Gain slices in window
+    Byte_t fHiGainThreshold;
+
+    TArrayD fSumx;         // sum of values
+    TArrayD fSumx2;        // sum of squared values
+
+    TArrayI fEvtCounter; // Counter for dumping values to Pedestal Container
+    TArrayI fTotalCounter; // Counter for dumping values to Pedestal Container
+
+    Int_t  PreProcess ( MParList *pList );
+    Bool_t ReInit     ( MParList *pList );
+    Int_t  Process    ();
+
+public:
+
+    MPedCalcFromData(const char *name=NULL, const char *title=NULL);
+ 
+    void Clear(const Option_t *o="");
+    void SetDumpEvents(UInt_t dumpevents = 0){fDump = dumpevents;}
+    void SetfHiGainThreshold(Byte_t Threshold = 0){fHiGainThreshold = Threshold;}
+    void SetLoRange(Byte_t lofirst=0, Byte_t lolast=0);
+
+    ClassDef(MPedCalcFromData, 0)   // Task to calculate pedestals from data runs 
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mpedestal/MPedCalcFromLoGain.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mpedestal/MPedCalcFromLoGain.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mpedestal/MPedCalcFromLoGain.cc	(revision 9661)
@@ -0,0 +1,633 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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@astro.uni-wuerzburg.de>
+!   Author(s): Sebastian Commichau 12/2003 
+!   Author(s): Javier Rico 01/2004 <mailto:jrico@ifae.es>
+!   Author(s): Markus Gaug 01/2004 <mailto:markus@ifae.es>
+!   Author(s): Florian Goebel 06/2004 <mailto:fgoebel@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+/////////////////////////////////////////////////////////////////////////////
+//
+//   MPedCalcLoGain
+//
+//
+//  This task is devide form MPedCalcPedRun, described below. However, It 
+//  calculates the pedstals using the low gain slices, whenever the difference 
+//  between the highest and the lowest slice in the high gain
+//  slices is below a given threshold (SetMaxHiGainVar). In this case the receiver
+//  boards do not switch to lo gain and the so called lo gain slices are actually
+//  high gain slices. 
+//
+//  MPedCalcLoGain also fills the ABoffset in MPedestalPix which allows to correct 
+//  the 150 MHz clock noise.
+//
+//  This task takes a pedestal run file and fills MPedestalCam during
+//  the Process() with the pedestal and rms computed in an event basis.
+//  In the PostProcess() MPedestalCam is finally filled with the pedestal
+//  mean and rms computed in a run basis.
+//  More than one run (file) can be merged
+//
+//  MPedCalcPedRun applies the following formula (1):
+// 
+//  Pedestal per slice = sum(x_i) / n / slices
+//  PedRMS per slice   = Sqrt(  ( sum(x_i^2) - sum(x_i)^2/n ) / n-1 / slices )
+// 
+//  where x_i is the sum of "slices" FADC slices and sum means the sum over all
+//  events. "n" is the number of events, "slices" is the number of summed FADC samples.
+// 
+//  Note that the slice-to-slice fluctuations are not Gaussian, but Poissonian, thus 
+//  asymmetric and they are correlated.
+// 
+//  It is important to know that the Pedestal per slice and PedRMS per slice depend 
+//  on the number of used FADC slices, as seen in the following plots:
+//
+//Begin_Html
+/*
+<img src="images/PedestalStudyInner.gif">
+*/
+//End_Html
+//
+//Begin_Html
+/*
+<img src="images/PedestalStudyOuter.gif">
+*/
+//
+// The plots show the inner and outer pixels, respectivly and have the following meaning:
+// 
+// 1) The calculated mean pedestal per slice (from MPedCalcFromLoGain)
+// 2) The fitted mean pedestal per slice     (from MHPedestalCam)
+// 3) The calculated pedestal RMS per slice  (from MPedCalcFromLoGain)
+// 4) The fitted sigma of the pedestal distribution per slice
+//                                           (from MHPedestalCam)
+// 5) The relative difference between calculation and histogram fit
+//    for the mean
+// 6) The relative difference between calculation and histogram fit
+//    for the sigma or RMS, respectively.
+// 
+// The calculated means do not change significantly except for the case of 2 slices, 
+// however the RMS changes from 5.7 per slice in the case of 2 extracted slices 
+// to 8.3 per slice in the case of 26 extracted slices. This change is very significant.
+// 
+// The plots have been produced on run 20123. You can reproduce them using
+// the macro pedestalstudies.C
+// 
+//  Usage of this class: 
+//  ====================
+// 
+//  Call: SetRange(higainfirst, higainlast, logainfirst, logainlast) 
+//  to modify the ranges in which the window is allowed to move. 
+//  Defaults are: 
+// 
+//   fHiGainFirst =  fgHiGainFirst =  0 
+//   fHiGainLast  =  fgHiGainLast  =  29
+//   fLoGainFirst =  fgLoGainFirst =  0 
+//   fLoGainLast  =  fgLoGainLast  =  14
+//
+//  Call: SetWindowSize(windowhigain, windowlogain) 
+//  to modify the sliding window widths. Windows have to be an even number. 
+//  In case of odd numbers, the window will be modified.
+//
+//  Defaults are:
+//
+//   fHiGainWindowSize = fgHiGainWindowSize = 14
+//   fLoGainWindowSize = fgLoGainWindowSize = 0
+//
+//  Input Containers:
+//   MRawEvtData
+//   MRawRunHeader
+//   MGeomCam
+//
+//  Output Containers:
+//   MPedestalCam
+//
+//  See also: MPedestalCam, MPedestalPix, MHPedestalCam, MExtractor
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MPedCalcFromLoGain.h"
+#include "MExtractor.h"
+
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MRawRunHeader.h"  
+#include "MRawEvtPixelIter.h"
+#include "MRawEvtData.h"
+
+#include "MPedestalPix.h"
+#include "MPedestalCam.h"
+
+#include "MGeomPix.h"
+#include "MGeomCam.h"
+
+#include "MBadPixelsPix.h"
+#include "MBadPixelsCam.h"
+
+#include "MGeomCamMagic.h"
+
+ClassImp(MPedCalcFromLoGain);
+
+using namespace std;
+
+const Byte_t MPedCalcFromLoGain::fgHiGainFirst      = 0;
+const Byte_t MPedCalcFromLoGain::fgHiGainLast       = 11;
+const Byte_t MPedCalcFromLoGain::fgLoGainFirst      = 1;
+const Byte_t MPedCalcFromLoGain::fgLoGainLast       = 14;
+const Byte_t MPedCalcFromLoGain::fgHiGainWindowSize = 12;
+const Byte_t MPedCalcFromLoGain::fgLoGainWindowSize = 14;
+const Byte_t MPedCalcFromLoGain::fgMaxHiGainVar     = 20;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor: 
+//
+// Sets:
+// - all pointers to NULL
+// - fWindowSizeHiGain to fgHiGainWindowSize
+// - fWindowSizeLoGain to fgLoGainWindowSize
+//
+// Calls: 
+// - AddToBranchList("fHiGainPixId");
+// - AddToBranchList("fHiGainFadcSamples");
+// - SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast)
+// - Clear()
+//
+MPedCalcFromLoGain::MPedCalcFromLoGain(const char *name, const char *title)
+    : fWindowSizeHiGain(fgHiGainWindowSize), 
+      fWindowSizeLoGain(fgLoGainWindowSize), 
+      fGeom(NULL),fBad(NULL)
+{
+  fName  = name  ? name  : "MPedCalcFromLoGain";
+  fTitle = title ? title : "Task to calculate pedestals from pedestal runs raw data";
+  
+  AddToBranchList("fHiGainPixId");
+  AddToBranchList("fHiGainFadcSamples");
+  
+  SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast);
+
+  SetMaxHiGainVar(fgMaxHiGainVar);
+  SetPedestalUpdate(kTRUE);
+  Clear();
+}
+
+// --------------------------------------------------------------------------
+//
+// Sets:
+// - fNumSamplesTot to 0
+// - fRawEvt to NULL
+// - fRunHeader to NULL
+// - fPedestals to NULL
+//
+void MPedCalcFromLoGain::Clear(const Option_t *o)
+{
+
+  fRawEvt    = NULL;
+  fRunHeader = NULL;
+  fPedestals = NULL;
+}
+
+// --------------------------------------------------------------------------
+//
+// SetRange: 
+//
+// Calls:
+// - MExtractor::SetRange(hifirst,hilast,lofirst,lolast);
+// - SetWindowSize(fWindowSizeHiGain,fWindowSizeLoGain);
+//
+void MPedCalcFromLoGain::SetRange(Byte_t hifirst, Byte_t hilast, Byte_t lofirst, Byte_t lolast)
+{
+
+  MExtractor::SetRange(hifirst,hilast,lofirst,lolast);
+
+  //
+  // Redo the checks if the window is still inside the ranges
+  //
+  SetWindowSize(fWindowSizeHiGain,fWindowSizeLoGain);
+  
+}
+
+
+// --------------------------------------------------------------------------
+//
+void MPedCalcFromLoGain::SetMaxHiGainVar(Byte_t maxvar) {
+  fMaxHiGainVar = maxvar;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Checks:
+// - if a window is odd, subtract one
+// - if a window is bigger than the one defined by the ranges, set it to the available range
+// - if a window is smaller than 2, set it to 2
+// 
+// Sets:
+// - fNumHiGainSamples to: (Float_t)fWindowSizeHiGain
+// - fNumLoGainSamples to: (Float_t)fWindowSizeLoGain
+// - fSqrtHiGainSamples to: TMath::Sqrt(fNumHiGainSamples)
+// - fSqrtLoGainSamples to: TMath::Sqrt(fNumLoGainSamples)  
+//  
+void MPedCalcFromLoGain::SetWindowSize(Byte_t windowh, Byte_t windowl)
+{
+  
+  fWindowSizeHiGain = windowh & ~1;
+  fWindowSizeLoGain = windowl & ~1;
+
+  if (fWindowSizeHiGain != windowh)
+    *fLog << warn << GetDescriptor() << ": Hi Gain window size has to be even, set to: " 
+          << int(fWindowSizeHiGain) << " samples " << endl;
+  
+  if (fWindowSizeLoGain != windowl)
+    *fLog << warn << GetDescriptor() << ": Lo Gain window size has to be even, set to: " 
+          << int(fWindowSizeLoGain) << " samples " << endl;
+    
+  const Byte_t availhirange = (fHiGainLast-fHiGainFirst+1) & ~1;
+  const Byte_t availlorange = (fLoGainLast-fLoGainFirst+1) & ~1;
+
+  if (fWindowSizeHiGain > availhirange)
+    {
+      *fLog << warn << GetDescriptor() 
+            << Form("%s%2i%s%2i%s%2i%s",": Hi Gain window size: ",(int)fWindowSizeHiGain,
+                    " is bigger than available range: [",(int)fHiGainFirst,",",(int)fHiGainLast,"]") << endl;
+      *fLog << warn << GetDescriptor() 
+            << ": Will set window size to: " << (int)availhirange << endl;
+      fWindowSizeHiGain = availhirange;
+    }
+  
+  if (fWindowSizeLoGain > availlorange)
+    {
+      *fLog << warn << GetDescriptor() 
+            << Form("%s%2i%s%2i%s%2i%s",": Lo Gain window size: ",(int)fWindowSizeLoGain,
+                    " is bigger than available range: [",(int)fLoGainFirst,",",(int)fLoGainLast,"]") << endl;
+      *fLog << warn << GetDescriptor() 
+            << ": Will set window size to: " << (int)availlorange << endl;
+      fWindowSizeLoGain = availlorange;
+    }
+  
+  
+  fNumHiGainSamples = (Float_t)fWindowSizeHiGain;
+  fNumLoGainSamples = (Float_t)fWindowSizeLoGain;
+  
+  fSqrtHiGainSamples = TMath::Sqrt(fNumHiGainSamples);
+  fSqrtLoGainSamples = TMath::Sqrt(fNumLoGainSamples);
+
+}
+
+  
+    
+// --------------------------------------------------------------------------
+//
+// Look for the following input containers:
+//
+//  - MRawEvtData
+//  - MRawRunHeader
+//  - MGeomCam
+//  - MBadPixelsCam
+// 
+// The following output containers are also searched and created if
+// they were not found:
+//
+//  - MPedestalCam
+//
+Int_t MPedCalcFromLoGain::PreProcess( MParList *pList )
+{
+
+  Clear();
+  
+  fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
+  if (!fRawEvt)
+    {
+      *fLog << err << "MRawEvtData not found... aborting." << endl;
+      return kFALSE;
+    }
+  
+  fRunHeader = (MRawRunHeader*)pList->FindObject(AddSerialNumber("MRawRunHeader"));
+  if (!fRunHeader)
+    {
+      *fLog << err << AddSerialNumber("MRawRunHeader") << " not found... aborting." << endl;
+      return kFALSE;
+    }
+
+  fGeom   =  (MGeomCam*)pList->FindObject("MGeomCam");
+  if (!fGeom)
+    {
+      *fLog << err << "MGeomCam not found... aborting." << endl;
+      return kFALSE;
+    }
+
+  fPedestals = (MPedestalCam*)pList->FindCreateObj("MPedestalCam");
+  if (!fPedestals)
+    return kFALSE;
+
+  fBad       =  (MBadPixelsCam*)pList->FindObject("MBadPixelsCam");
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// The ReInit searches for:
+// -  MRawRunHeader::GetNumSamplesHiGain()
+// -  MRawRunHeader::GetNumSamplesLoGain()
+//
+// In case that the variables fHiGainLast and fLoGainLast are smaller than 
+// the even part of the number of samples obtained from the run header, a
+// warning is given an the range is set back accordingly. A call to:  
+// - SetRange(fHiGainFirst, fHiGainLast-diff, fLoGainFirst, fLoGainLast) or 
+// - SetRange(fHiGainFirst, fHiGainLast, fLoGainFirst, fLoGainLast-diff) 
+// is performed in that case. The variable diff means here the difference 
+// between the requested range (fHiGainLast) and the available one. Note that 
+// the functions SetRange() are mostly overloaded and perform more checks, 
+// modifying the ranges again, if necessary.
+//
+// A loop over the MBadPixelsCam is performed and bad pixels are set
+// to MPedestalPix::SetValid(kFALSE);
+//
+Bool_t MPedCalcFromLoGain::ReInit(MParList *pList)
+{
+      
+  Int_t lastdesired   = (Int_t)fLoGainLast;
+  Int_t lastavailable = (Int_t)fRunHeader->GetNumSamplesLoGain()-1;
+  
+  if (lastdesired > lastavailable)
+    {
+      const Int_t diff = lastdesired - lastavailable;
+      *fLog << endl; 
+      *fLog << warn << GetDescriptor()
+            << Form("%s%2i%s%2i%s%2i%s",": Selected Lo Gain FADC Window [",
+                    (int)fLoGainFirst,",",lastdesired,
+                    "] ranges out of the available limits: [0,",lastavailable,"].") << endl;
+      *fLog << GetDescriptor() << ": Will reduce the upper edge to " << (int)(fLoGainLast - diff) << endl;
+      SetRange(fHiGainFirst, fHiGainLast, fLoGainFirst, fLoGainLast-diff);
+    }
+
+  lastdesired   = (Int_t)fHiGainLast;
+  lastavailable = (Int_t)fRunHeader->GetNumSamplesHiGain()-1;
+  
+  if (lastdesired > lastavailable)
+    {
+      const Int_t diff = lastdesired - lastavailable;
+      *fLog << endl;
+      *fLog << warn << GetDescriptor()
+            << Form("%s%2i%s%2i%s%2i%s",": Selected Hi Gain Range [",
+                    (int)fHiGainFirst,",",lastdesired,
+                    "] ranges out of the available limits: [0,",lastavailable,"].") << endl;
+      *fLog << warn << GetDescriptor() 
+            << Form("%s%2i%s",": Will possibly use ",diff," samples from the Low-Gain for the High-Gain range")
+            << endl;
+      fHiGainLast -= diff;
+      fHiLoLast    = diff;
+    }
+
+  lastdesired   = (Int_t)fHiGainFirst+fWindowSizeHiGain-1;
+  lastavailable = (Int_t)fRunHeader->GetNumSamplesHiGain()-1;
+  
+  if (lastdesired > lastavailable)
+    {
+      const Int_t diff = lastdesired - lastavailable;
+      *fLog << endl;
+      *fLog << warn << GetDescriptor()
+            << Form("%s%2i%s%2i%s",": Selected Hi Gain FADC Window size ",
+                    (int)fWindowSizeHiGain,
+                    " ranges out of the available limits: [0,",lastavailable,"].") << endl;
+      *fLog << warn << GetDescriptor() 
+            << Form("%s%2i%s",": Will use ",diff," samples from the Low-Gain for the High-Gain extraction")
+            << endl;
+
+      if ((Int_t)fWindowSizeHiGain > diff)
+        {
+          fWindowSizeHiGain -= diff;
+          fWindowSizeLoGain += diff;
+        }
+      else
+        {
+          fWindowSizeLoGain += fWindowSizeHiGain;
+          fLoGainFirst       = diff-fWindowSizeHiGain;
+          fWindowSizeHiGain  = 0;
+        }
+    }
+
+
+  Int_t npixels  = fPedestals->GetSize();
+  
+  if (fSumx.GetSize()==0)
+    {
+      fSumx. Set(npixels);
+      fSumx2.Set(npixels);
+      fSumAB0.Set(npixels);
+      fSumAB1.Set(npixels);
+      fNumEventsUsed.Set(npixels);
+      fTotalCounter.Set(npixels);
+      
+      fSumx.Reset();
+      fSumx2.Reset();
+      fSumAB0.Reset();
+      fSumAB1.Reset();
+      fNumEventsUsed.Reset();
+      fTotalCounter.Reset();
+    }
+  
+  if (fWindowSizeHiGain == 0 && fWindowSizeLoGain == 0)
+    {
+      *fLog << err << GetDescriptor() 
+            << ": Number of extracted Slices is 0, abort ... " << endl;
+      return kFALSE;
+    }
+  
+  
+  *fLog << endl;
+  *fLog << inf << GetDescriptor() << ": Taking " << (int)fWindowSizeHiGain
+        << " HiGain FADC samples starting with slice: " << (int)fHiGainFirst << endl;
+  *fLog << inf << GetDescriptor() << ": Taking " << (int)fWindowSizeLoGain
+        << " LoGain FADC samples starting with slice: " << (int)fLoGainFirst << endl;
+  
+  
+  if (fBad)
+    {
+      const Int_t nbads = fBad->GetSize();
+      for (Int_t i=0; i<(nbads>npixels?npixels:nbads);i++)
+        if ((*fBad)[i].IsBad())
+          (*fPedestals)[i].SetValid(kFALSE);
+    }
+  
+  return kTRUE;
+      
+}
+// --------------------------------------------------------------------------
+//
+// Fill the MPedestalCam container with the signal mean and rms for the event.
+// Store the measured signal in arrays fSumx and fSumx2 so that we can 
+// calculate the overall mean and rms in the PostProcess()
+//
+Int_t MPedCalcFromLoGain::Process()
+{
+
+  MRawEvtPixelIter pixel(fRawEvt);
+  
+  //   cout << "fHiGainFirst: " << (Int_t)fHiGainFirst << " fWindowSizeHiGain: " << (Int_t)fWindowSizeHiGain << " fLoGainFirst: " << (Int_t)fLoGainFirst << " fWindowSizeLoGain: " << (Int_t)fWindowSizeLoGain << endl;
+
+
+  while (pixel.Next()) {
+    
+    const UInt_t idx    = pixel.GetPixelId();
+    
+    Byte_t *ptr = pixel.GetHiGainSamples() + fHiGainFirst;
+    Byte_t *end = ptr + fWindowSizeHiGain;
+
+    UInt_t sum = 0;
+    UInt_t sqr = 0;
+    
+    UInt_t max = 0;
+    UInt_t min = 255;
+    
+    // Find the maximum and minimum signal per slice in the high gain window
+    do {
+      if (*ptr > max) {
+	max = *ptr;
+      }
+      if (*ptr < min) {
+	min = *ptr;
+      }
+    } while (++ptr != end);
+    
+    // If the maximum in the high gain window is smaller than 
+    if ((max-min < fMaxHiGainVar) && (max < 255)) {
+      
+      Byte_t *firstSlice = pixel.GetLoGainSamples() + fLoGainFirst;
+      Byte_t *lastSlice  = firstSlice + fWindowSizeLoGain;
+      
+      Byte_t *slice = firstSlice;
+      do {
+	sum += *slice;
+	sqr += *slice * *slice;
+      } while (++slice != lastSlice);
+
+      const Float_t msum = (Float_t)sum;
+      const Float_t sqrsum  = msum*msum;
+      
+      fSumx[idx]  += msum;
+      fSumx2[idx] += sqrsum;
+      fNumEventsUsed[idx]++;
+
+      // Calculate the amplitude of the 150MHz "AB" noise
+
+      Int_t abFlag = (fRunHeader->GetNumSamplesHiGain()
+		       + fLoGainFirst
+		       + pixel.HasABFlag()) & 0x1;
+      for (Int_t islice=0; islice<fWindowSizeLoGain; islice+=2) {
+	Int_t sliceAB0 = islice + abFlag;
+	Int_t sliceAB1 = islice + 1 - abFlag;
+	fSumAB0[idx] += firstSlice[sliceAB0];
+	fSumAB1[idx] += firstSlice[sliceAB1];
+      }
+
+      if (fPedestalUpdate && (fNumEventsUsed[idx] == fNumEventsDump)) {
+
+	const ULong_t n = fNumEventsDump;
+
+	const ULong_t nsamplestot = n*fWindowSizeLoGain;
+	
+	const Float_t sum  = fSumx.At(idx);
+	const Float_t sum2 = fSumx2.At(idx);
+	const Float_t ped  = sum/(nsamplestot);
+    
+	// 1. Calculate the Variance of the sums:
+	Float_t var = (sum2-sum*sum/n)/(n-1.);
+	
+	// 2. Scale the variance to the number of slices:
+	var /= (Float_t)(fWindowSizeLoGain);
+	
+	// 3. Calculate the RMS from the Variance:
+	Float_t rms = var < 0 ? 0. : TMath::Sqrt(var);
+
+	// 4. Calculate the amplitude of the 150MHz "AB" noise
+	Float_t abOffs = (fSumAB0[idx] - fSumAB1[idx]) / nsamplestot;
+
+	(*fPedestals)[idx].Set(ped, rms, abOffs, n);
+	
+	fTotalCounter[idx]++;
+	fNumEventsUsed[idx]=0;
+	fSumx[idx]=0;
+	fSumx2[idx]=0;
+	fSumAB0[idx]=0;
+	fSumAB1[idx]=0;
+      }
+    }
+  }
+  
+  fPedestals->SetReadyToSave();
+  
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Compute signal mean and rms in the whole run and store it in MPedestalCam
+//
+Int_t MPedCalcFromLoGain::PostProcess()
+{
+
+  // Compute pedestals and rms from the whole run
+
+  if (!fPedestalUpdate) {
+
+    MRawEvtPixelIter pixel(fRawEvt);
+    
+    while (pixel.Next()) {
+      
+      const Int_t  idx = pixel.GetPixelId();
+      
+      const ULong_t n = fNumEventsUsed[idx];
+      
+      if (n < 2)
+	continue;
+      
+      const ULong_t nsamplestot = n*fWindowSizeLoGain;
+      
+      const Float_t sum  = fSumx.At(idx);
+      const Float_t sum2 = fSumx2.At(idx);
+      const Float_t ped  = sum/(nsamplestot);
+      
+      // 1. Calculate the Variance of the sums:
+      Float_t var = (sum2-sum*sum/n)/(n-1.);
+      
+      // 2. Scale the variance to the number of slices:
+      var /= (Float_t)(fWindowSizeLoGain);
+      
+      // 3. Calculate the RMS from the Variance:
+      Float_t rms = var < 0 ? 0. : TMath::Sqrt(var);
+      
+      // 4. Calculate the amplitude of the 150MHz "AB" noise
+      Float_t abOffs = (fSumAB0[idx] - fSumAB1[idx]) / nsamplestot;
+      
+      (*fPedestals)[idx].Set(ped, rms, abOffs, n);
+      
+      fTotalCounter[idx]++;
+    }
+
+    fPedestals->SetReadyToSave();
+  }
+
+  return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mpedestal/MPedCalcFromLoGain.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mpedestal/MPedCalcFromLoGain.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mpedestal/MPedCalcFromLoGain.h	(revision 9661)
@@ -0,0 +1,69 @@
+#ifndef MARS_MPedCalcFromLoGain
+#define MARS_MPedCalcFromLoGain
+
+#ifndef MARS_MExtractor
+#include "MExtractor.h"
+#endif
+
+#ifndef ROOT_TArrayD
+#include <TArrayD.h>
+#endif
+
+#ifndef ROOT_TArrayI
+#include <TArrayI.h>
+#endif
+
+class MGeomCam;
+class MBadPixelsCam;
+class MPedCalcFromLoGain : public MExtractor
+{
+
+  static const Byte_t fgHiGainFirst;      // First FADC slice Hi-Gain (currently set to: 3) 
+  static const Byte_t fgHiGainLast;       // Last FADC slice Hi-Gain (currently set to: 14) 
+  static const Byte_t fgLoGainFirst;      // First FADC slice Lo-Gain (currently set to: 3) 
+  static const Byte_t fgLoGainLast;       // Last FADC slice Lo-Gain (currently set to: 14) 
+  static const Byte_t fgHiGainWindowSize; // The extraction window Hi-Gain
+  static const Byte_t fgLoGainWindowSize; // The extraction window Lo-Gain
+  static const Byte_t fgMaxHiGainVar;     // The maximum difference between the highest and lowest slice 
+                                          // in the high gain window allowed in order to use low gain 
+                                          // for pedestal calculation
+  Int_t   fNumEventsDump; // Number of event after which MPedestalCam gets updated
+
+  Byte_t  fMaxHiGainVar;
+  Byte_t  fWindowSizeHiGain;             // Number of Hi Gain slices in window
+  Byte_t  fWindowSizeLoGain;             // Number of Lo Gain slices in window  
+
+  Bool_t  fPedestalUpdate;
+  
+  MGeomCam     *fGeom;       // Camera geometry
+  MBadPixelsCam *fBad;       // Bad Pixels
+  
+  TArrayI fNumEventsUsed;   // Number of events used for pedestal calc for each pixel
+  TArrayI fTotalCounter;    // Counter for dumping values to Pedestal Container
+  TArrayD fSumx;            // sum of values
+  TArrayD fSumx2;           // sum of squared values
+  TArrayD fSumAB0;          // sum of ABFlag=0 slices
+  TArrayD fSumAB1;          // sum of ABFlag=1 slices
+  
+  Int_t  PreProcess ( MParList *pList );
+  Bool_t ReInit     ( MParList *pList );
+  Int_t  Process    ();
+  Int_t  PostProcess();
+  
+public:
+
+  MPedCalcFromLoGain(const char *name=NULL, const char *title=NULL);
+  
+  void Clear(const Option_t *o="");
+  void SetRange(Byte_t hifirst=0, Byte_t hilast=0, Byte_t lofirst=0, Byte_t lolast=0);
+  void SetWindowSize(Byte_t windowh=0, Byte_t windowl=0);
+  void SetMaxHiGainVar(Byte_t maxvar=0);
+  void SetDumpEvents(UInt_t dumpevents = 0) {fNumEventsDump = dumpevents;}
+  void SetPedestalUpdate(Bool_t pedupdate)  {fPedestalUpdate = pedupdate;}
+  
+  TArrayI *GetNumEventsUsed() {return &fNumEventsUsed;};
+  
+  ClassDef(MPedCalcFromLoGain, 0)   // Task to calculate pedestals from pedestal runs raw data
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mpedestal/MPedCalcPedRun.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mpedestal/MPedCalcPedRun.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mpedestal/MPedCalcPedRun.cc	(revision 9661)
@@ -0,0 +1,653 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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@astro.uni-wuerzburg.de>
+!   Author(s): Sebastian Commichau 12/2003 
+!   Author(s): Javier Rico 01/2004 <mailto:jrico@ifae.es>
+!   Author(s): Markus Gaug 01/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+/////////////////////////////////////////////////////////////////////////////
+//
+//   MPedCalcPedRun
+//
+//  This task takes a pedestal run file and fills MPedestalCam during
+//  the Process() with the pedestal and rms computed in an event basis.
+//  In the PostProcess() MPedestalCam is finally filled with the pedestal
+//  mean and rms computed in a run basis.
+//  More than one run (file) can be merged
+//
+//  MPedCalcPedRun applies the following formula (1):
+// 
+//  Pedestal per slice = sum(x_i) / n / slices
+//  PedRMS per slice   = Sqrt(  ( sum(x_i^2) - sum(x_i)^2/n ) / n-1 / slices )
+// 
+//  where x_i is the sum of "slices" FADC slices and sum means the sum over all
+//  events. "n" is the number of events, "slices" is the number of summed FADC samples.
+// 
+//  Note that the slice-to-slice fluctuations are not Gaussian, but Poissonian, thus 
+//  asymmetric and they are correlated.
+// 
+//  It is important to know that the Pedestal per slice and PedRMS per slice depend 
+//  on the number of used FADC slices, as seen in the following plots:
+//
+//Begin_Html
+/*
+<img src="images/PedestalStudyInner.gif">
+*/
+//End_Html
+//
+//Begin_Html
+/*
+<img src="images/PedestalStudyOuter.gif">
+*/
+//
+// The plots show the inner and outer pixels, respectivly and have the following meaning:
+// 
+// 1) The calculated mean pedestal per slice (from MPedCalcPedRun)
+// 2) The fitted mean pedestal per slice     (from MHPedestalCam)
+// 3) The calculated pedestal RMS per slice  (from MPedCalcPedRun)
+// 4) The fitted sigma of the pedestal distribution per slice
+//                                           (from MHPedestalCam)
+// 5) The relative difference between calculation and histogram fit
+//    for the mean
+// 6) The relative difference between calculation and histogram fit
+//    for the sigma or RMS, respectively.
+// 
+// The calculated means do not change significantly except for the case of 2 slices, 
+// however the RMS changes from 5.7 per slice in the case of 2 extracted slices 
+// to 8.3 per slice in the case of 26 extracted slices. This change is very significant.
+// 
+// The plots have been produced on run 20123. You can reproduce them using
+// the macro pedestalstudies.C
+// 
+//  Usage of this class: 
+//  ====================
+// 
+//  Call: SetRange(higainfirst, higainlast, logainfirst, logainlast) 
+//  to modify the ranges in which the window is allowed to move. 
+//  Defaults are: 
+// 
+//   fHiGainFirst =  fgHiGainFirst =  0 
+//   fHiGainLast  =  fgHiGainLast  =  29
+//   fLoGainFirst =  fgLoGainFirst =  0 
+//   fLoGainLast  =  fgLoGainLast  =  14
+//
+//  Call: SetWindowSize(windowhigain, windowlogain) 
+//  to modify the sliding window widths. Windows have to be an even number. 
+//  In case of odd numbers, the window will be modified.
+//
+//  Defaults are:
+//
+//   fHiGainWindowSize = fgHiGainWindowSize = 14
+//   fLoGainWindowSize = fgLoGainWindowSize = 0
+//
+//
+// ToDo:
+//   - Take a setup file (ReadEnv-implementation) as input
+//
+//
+//  Input Containers:
+//   MRawEvtData
+//   MRawRunHeader
+//   MGeomCam
+//
+//  Output Containers:
+//   MPedestalCam
+//
+//  See also: MPedestalCam, MPedestalPix, MHPedestalCam, MExtractor
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MPedCalcPedRun.h"
+#include "MExtractor.h"
+
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MRawRunHeader.h"  
+#include "MRawEvtPixelIter.h"
+#include "MRawEvtData.h"
+
+#include "MPedestalPix.h"
+#include "MPedestalCam.h"
+
+#include "MGeomPix.h"
+#include "MGeomCam.h"
+
+#include "MBadPixelsPix.h"
+#include "MBadPixelsCam.h"
+
+#include "MGeomCamMagic.h"
+
+ClassImp(MPedCalcPedRun);
+
+using namespace std;
+
+const Byte_t MPedCalcPedRun::fgHiGainFirst      = 0;
+const Byte_t MPedCalcPedRun::fgHiGainLast       = 29;
+const Byte_t MPedCalcPedRun::fgLoGainFirst      = 0;
+const Byte_t MPedCalcPedRun::fgLoGainLast       = 14;
+const Byte_t MPedCalcPedRun::fgHiGainWindowSize = 14;
+const Byte_t MPedCalcPedRun::fgLoGainWindowSize = 0;
+// --------------------------------------------------------------------------
+//
+// Default constructor: 
+//
+// Sets:
+// - all pointers to NULL
+// - fWindowSizeHiGain to fgHiGainWindowSize
+// - fWindowSizeLoGain to fgLoGainWindowSize
+//
+// Calls: 
+// - AddToBranchList("fHiGainPixId");
+// - AddToBranchList("fHiGainFadcSamples");
+// - SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast)
+// - Clear()
+//
+MPedCalcPedRun::MPedCalcPedRun(const char *name, const char *title)
+    : fWindowSizeHiGain(fgHiGainWindowSize), 
+      fWindowSizeLoGain(fgLoGainWindowSize), 
+      fGeom(NULL),fBad(NULL)
+{
+  fName  = name  ? name  : "MPedCalcPedRun";
+  fTitle = title ? title : "Task to calculate pedestals from pedestal runs raw data";
+  
+  AddToBranchList("fHiGainPixId");
+  AddToBranchList("fHiGainFadcSamples");
+  
+  SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast);
+  Clear();
+}
+
+// --------------------------------------------------------------------------
+//
+// Sets:
+// - fNumSamplesTot to 0
+// - fRawEvt to NULL
+// - fRunHeader to NULL
+// - fPedestals to NULL
+//
+void MPedCalcPedRun::Clear(const Option_t *o)
+{
+
+  fNumSamplesTot    = 0;
+
+  fRawEvt    = NULL;
+  fRunHeader = NULL;
+  fPedestals = NULL;
+}
+
+// --------------------------------------------------------------------------
+//
+// SetRange: 
+//
+// Calls:
+// - MExtractor::SetRange(hifirst,hilast,lofirst,lolast);
+// - SetWindowSize(fWindowSizeHiGain,fWindowSizeLoGain);
+//
+void MPedCalcPedRun::SetRange(Byte_t hifirst, Byte_t hilast, Byte_t lofirst, Byte_t lolast)
+{
+
+  MExtractor::SetRange(hifirst,hilast,lofirst,lolast);
+
+  //
+  // Redo the checks if the window is still inside the ranges
+  //
+  SetWindowSize(fWindowSizeHiGain,fWindowSizeLoGain);
+  
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Checks:
+// - if a window is odd, subtract one
+// - if a window is bigger than the one defined by the ranges, set it to the available range
+// - if a window is smaller than 2, set it to 2
+// 
+// Sets:
+// - fNumHiGainSamples to: (Float_t)fWindowSizeHiGain
+// - fNumLoGainSamples to: (Float_t)fWindowSizeLoGain
+// - fSqrtHiGainSamples to: TMath::Sqrt(fNumHiGainSamples)
+// - fSqrtLoGainSamples to: TMath::Sqrt(fNumLoGainSamples)  
+//  
+void MPedCalcPedRun::SetWindowSize(Byte_t windowh, Byte_t windowl)
+{
+  
+  fWindowSizeHiGain = windowh & ~1;
+  fWindowSizeLoGain = windowl & ~1;
+
+  if (fWindowSizeHiGain != windowh)
+    *fLog << warn << GetDescriptor() << ": Hi Gain window size has to be even, set to: " 
+          << int(fWindowSizeHiGain) << " samples " << endl;
+  
+  if (fWindowSizeLoGain != windowl)
+    *fLog << warn << GetDescriptor() << ": Lo Gain window size has to be even, set to: " 
+          << int(fWindowSizeLoGain) << " samples " << endl;
+    
+  const Byte_t availhirange = (fHiGainLast-fHiGainFirst+1) & ~1;
+  const Byte_t availlorange = (fLoGainLast-fLoGainFirst+1) & ~1;
+
+  if (fWindowSizeHiGain > availhirange)
+    {
+      *fLog << warn << GetDescriptor() 
+            << Form("%s%2i%s%2i%s%2i%s",": Hi Gain window size: ",(int)fWindowSizeHiGain,
+                    " is bigger than available range: [",(int)fHiGainFirst,",",(int)fHiGainLast,"]") << endl;
+      *fLog << warn << GetDescriptor() 
+            << ": Will set window size to: " << (int)availhirange << endl;
+      fWindowSizeHiGain = availhirange;
+    }
+  
+  if (fWindowSizeLoGain > availlorange)
+    {
+      *fLog << warn << GetDescriptor() 
+            << Form("%s%2i%s%2i%s%2i%s",": Lo Gain window size: ",(int)fWindowSizeLoGain,
+                    " is bigger than available range: [",(int)fLoGainFirst,",",(int)fLoGainLast,"]") << endl;
+      *fLog << warn << GetDescriptor() 
+            << ": Will set window size to: " << (int)availlorange << endl;
+      fWindowSizeLoGain = availlorange;
+    }
+  
+    
+  fNumHiGainSamples = (Float_t)fWindowSizeHiGain;
+  fNumLoGainSamples = (Float_t)fWindowSizeLoGain;
+  
+  fSqrtHiGainSamples = TMath::Sqrt(fNumHiGainSamples);
+  fSqrtLoGainSamples = TMath::Sqrt(fNumLoGainSamples);
+
+}
+
+  
+    
+// --------------------------------------------------------------------------
+//
+// Look for the following input containers:
+//
+//  - MRawEvtData
+//  - MRawRunHeader
+//  - MGeomCam
+//  - MBadPixelsCam
+// 
+// The following output containers are also searched and created if
+// they were not found:
+//
+//  - MPedestalCam
+//
+Int_t MPedCalcPedRun::PreProcess( MParList *pList )
+{
+
+  Clear();
+  
+  fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
+  if (!fRawEvt)
+    {
+      *fLog << err << "MRawEvtData not found... aborting." << endl;
+      return kFALSE;
+    }
+  
+  fRunHeader = (MRawRunHeader*)pList->FindObject(AddSerialNumber("MRawRunHeader"));
+  if (!fRunHeader)
+    {
+      *fLog << err << AddSerialNumber("MRawRunHeader") << " not found... aborting." << endl;
+      return kFALSE;
+    }
+
+  fGeom   =  (MGeomCam*)pList->FindObject("MGeomCam");
+  if (!fGeom)
+    {
+      *fLog << err << "MGeomCam not found... aborting." << endl;
+      return kFALSE;
+    }
+
+  fPedestals = (MPedestalCam*)pList->FindCreateObj("MPedestalCam");
+  if (!fPedestals)
+    return kFALSE;
+
+  fBad       =  (MBadPixelsCam*)pList->FindObject("MBadPixelsCam");
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// The ReInit searches for:
+// -  MRawRunHeader::GetNumSamplesHiGain()
+// -  MRawRunHeader::GetNumSamplesLoGain()
+//
+// In case that the variables fHiGainLast and fLoGainLast are smaller than 
+// the even part of the number of samples obtained from the run header, a
+// warning is given an the range is set back accordingly. A call to:  
+// - SetRange(fHiGainFirst, fHiGainLast-diff, fLoGainFirst, fLoGainLast) or 
+// - SetRange(fHiGainFirst, fHiGainLast, fLoGainFirst, fLoGainLast-diff) 
+// is performed in that case. The variable diff means here the difference 
+// between the requested range (fHiGainLast) and the available one. Note that 
+// the functions SetRange() are mostly overloaded and perform more checks, 
+// modifying the ranges again, if necessary.
+//
+// A loop over the MBadPixelsCam is performed and bad pixels are set
+// to MPedestalPix::SetValid(kFALSE);
+//
+Bool_t MPedCalcPedRun::ReInit(MParList *pList)
+{
+  
+    
+  Int_t lastdesired   = (Int_t)fLoGainLast;
+  Int_t lastavailable = (Int_t)fRunHeader->GetNumSamplesLoGain()-1;
+  
+  if (lastdesired > lastavailable)
+    {
+      const Int_t diff = lastdesired - lastavailable;
+      *fLog << endl; 
+      *fLog << warn << GetDescriptor()
+            << Form("%s%2i%s%2i%s%2i%s",": Selected Lo Gain FADC Window [",
+                    (int)fLoGainFirst,",",lastdesired,
+                    "] ranges out of the available limits: [0,",lastavailable,"].") << endl;
+      *fLog << GetDescriptor() << ": Will reduce the upper edge to " << (int)(fLoGainLast - diff) << endl;
+      SetRange(fHiGainFirst, fHiGainLast, fLoGainFirst, fLoGainLast-diff);
+    }
+
+  lastdesired   = (Int_t)fHiGainLast;
+  lastavailable = (Int_t)fRunHeader->GetNumSamplesHiGain()-1;
+  
+  if (lastdesired > lastavailable)
+    {
+      const Int_t diff = lastdesired - lastavailable;
+      *fLog << endl;
+      *fLog << warn << GetDescriptor()
+            << Form("%s%2i%s%2i%s%2i%s",": Selected Hi Gain Range [",
+                    (int)fHiGainFirst,",",lastdesired,
+                    "] ranges out of the available limits: [0,",lastavailable,"].") << endl;
+      *fLog << warn << GetDescriptor() 
+            << Form("%s%2i%s",": Will possibly use ",diff," samples from the Low-Gain for the High-Gain range")
+            << endl;
+      fHiGainLast -= diff;
+      fHiLoLast    = diff;
+    }
+
+  lastdesired   = (Int_t)fHiGainFirst+fWindowSizeHiGain-1;
+  lastavailable = (Int_t)fRunHeader->GetNumSamplesHiGain()-1;
+  
+  if (lastdesired > lastavailable)
+    {
+      const Int_t diff = lastdesired - lastavailable;
+      *fLog << endl;
+      *fLog << warn << GetDescriptor()
+            << Form("%s%2i%s%2i%s",": Selected Hi Gain FADC Window size ",
+                    (int)fWindowSizeHiGain,
+                    " ranges out of the available limits: [0,",lastavailable,"].") << endl;
+      *fLog << warn << GetDescriptor() 
+            << Form("%s%2i%s",": Will use ",diff," samples from the Low-Gain for the High-Gain extraction")
+            << endl;
+
+      if ((Int_t)fWindowSizeHiGain > diff)
+        {
+          fWindowSizeHiGain -= diff;
+          fWindowSizeLoGain += diff;
+        }
+      else
+        {
+          fWindowSizeLoGain += fWindowSizeHiGain;
+          fLoGainFirst       = diff-fWindowSizeHiGain;
+          fWindowSizeHiGain  = 0;
+        }
+    }
+
+
+  Int_t npixels  = fPedestals->GetSize();
+  Int_t areas    = fPedestals->GetAverageAreas();
+  Int_t sectors  = fPedestals->GetAverageSectors();
+  
+  if (fSumx.GetSize()==0)
+    {
+      fSumx. Set(npixels);
+      fSumx2.Set(npixels);
+      
+      fAreaSumx. Set(areas);
+      fAreaSumx2.Set(areas);
+      fAreaValid.Set(areas);
+      
+      fSectorSumx. Set(sectors);
+      fSectorSumx2.Set(sectors);
+      fSectorValid.Set(sectors);
+      
+      fSumx.Reset();
+      fSumx2.Reset();
+    }
+  
+  if (fWindowSizeHiGain == 0 && fWindowSizeLoGain == 0)
+    {
+      *fLog << err << GetDescriptor() 
+            << ": Number of extracted Slices is 0, abort ... " << endl;
+      return kFALSE;
+    }
+  
+
+  *fLog << endl;
+  *fLog << inf << GetDescriptor() << ": Taking " << (int)fWindowSizeHiGain
+        << " HiGain FADC samples starting with slice: " << (int)fHiGainFirst << endl;
+  *fLog << inf << GetDescriptor() << ": Taking " << (int)fWindowSizeLoGain
+        << " LoGain FADC samples starting with slice: " << (int)fLoGainFirst << endl;
+
+
+  if (fBad)
+    {
+      const Int_t nbads = fBad->GetSize();
+      for (Int_t i=0; i<(nbads>npixels?npixels:nbads);i++)
+        if ((*fBad)[i].IsBad())
+          (*fPedestals)[i].SetValid(kFALSE);
+    }
+  
+  return kTRUE;
+      
+}
+// --------------------------------------------------------------------------
+//
+// Fill the MPedestalCam container with the signal mean and rms for the event.
+// Store the measured signal in arrays fSumx and fSumx2 so that we can 
+// calculate the overall mean and rms in the PostProcess()
+//
+Int_t MPedCalcPedRun::Process()
+{
+
+  MRawEvtPixelIter pixel(fRawEvt);
+  
+  while (pixel.Next())
+    {
+
+      const UInt_t idx    = pixel.GetPixelId();
+      const UInt_t aidx   = (*fGeom)[idx].GetAidx();
+      const UInt_t sector = (*fGeom)[idx].GetSector();      
+
+      Byte_t *ptr = pixel.GetHiGainSamples() + fHiGainFirst;
+      Byte_t *end = ptr + fWindowSizeHiGain;
+      
+      UInt_t sum = 0;
+      UInt_t sqr = 0;
+
+      if (fWindowSizeHiGain != 0)
+        {
+          do
+            {
+              sum += *ptr;
+              sqr += *ptr * *ptr;
+            }
+          while (++ptr != end);
+        }
+      
+      if (fWindowSizeLoGain != 0)
+        {
+          
+          ptr = pixel.GetLoGainSamples() + fLoGainFirst;
+          end = ptr + fWindowSizeLoGain;
+      
+          do
+            {
+              sum += *ptr;
+              sqr += *ptr * *ptr;
+            }
+          while (++ptr != end);
+          
+        }
+      
+      const Float_t msum = (Float_t)sum;
+      
+      //
+      // These three lines have been uncommented by Markus Gaug
+      // If anybody needs them, please contact me!!
+      //
+      //	const Float_t higainped = msum/fNumHiGainSlices;
+      //	const Float_t higainrms = TMath::Sqrt((msqr-msum*msum/fNumHiGainSlices)/(fNumHiGainSlices-1.));
+      //	(*fPedestals)[idx].Set(higainped, higainrms);
+      
+      fSumx[idx]          += msum;
+      fAreaSumx[aidx]     += msum;
+      fSectorSumx[sector] += msum;      
+      //
+      // The old version:
+      //
+      //       const Float_t msqr = (Float_t)sqr;
+      //	fSumx2[idx] += msqr;
+      //
+      // The new version:
+      //
+      const Float_t sqrsum  = msum*msum;
+      fSumx2[idx]          += sqrsum;
+      fAreaSumx2[aidx]     += sqrsum;
+      fSectorSumx2[sector] += sqrsum;      
+    }
+  
+  fPedestals->SetReadyToSave();
+  fNumSamplesTot += fWindowSizeHiGain + fWindowSizeLoGain;
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Compute signal mean and rms in the whole run and store it in MPedestalCam
+//
+Int_t MPedCalcPedRun::PostProcess()
+{
+
+  // Compute pedestals and rms from the whole run
+  const ULong_t n     = fNumSamplesTot;
+  const ULong_t nevts = GetNumExecutions();
+
+  MRawEvtPixelIter pixel(fRawEvt);
+  
+  while (pixel.Next())
+    {
+
+      const Int_t  pixid  = pixel.GetPixelId();
+      const UInt_t aidx   = (*fGeom)[pixid].GetAidx();
+      const UInt_t sector = (*fGeom)[pixid].GetSector();      
+      
+      fAreaValid  [aidx]++;
+      fSectorValid[sector]++;
+
+      const Float_t sum  = fSumx.At(pixid);
+      const Float_t sum2 = fSumx2.At(pixid);
+      const Float_t higainped = sum/n;
+      //
+      // The old version:
+      //
+      //      const Float_t higainrms = TMath::Sqrt((sum2-sum*sum/n)/(n-1.));
+      //
+      // The new version:
+      //
+      // 1. Calculate the Variance of the sums:
+      Float_t higainVar = (sum2-sum*sum/nevts)/(nevts-1.);
+      // 2. Scale the variance to the number of slices:
+      higainVar /= (Float_t)(fWindowSizeHiGain+fWindowSizeLoGain);
+      // 3. Calculate the RMS from the Variance:
+      (*fPedestals)[pixid].Set(higainped, higainVar < 0 ? 0. : TMath::Sqrt(higainVar));
+
+    }
+
+  //
+  // Loop over the (two) area indices to get the averaged pedestal per aidx
+  //
+  for (Int_t aidx=0; aidx<fAreaValid.GetSize(); aidx++)
+    {
+      
+      const Int_t   napix = fAreaValid.At(aidx);
+
+      if (napix == 0)
+        continue;
+
+      const Float_t sum   = fAreaSumx.At(aidx);
+      const Float_t sum2  = fAreaSumx2.At(aidx);
+      const ULong_t an    = napix * n;
+      const ULong_t aevts = napix * nevts;
+      
+      const Float_t higainped = sum/an;
+
+      // 1. Calculate the Variance of the sums:
+      Float_t higainVar = (sum2-sum*sum/aevts)/(aevts-1.);
+      // 2. Scale the variance to the number of slices:
+      higainVar /= fWindowSizeHiGain+fWindowSizeLoGain;
+      // 3. Calculate the RMS from the Variance:
+      Float_t higainrms = TMath::Sqrt(higainVar);
+      // 4. Re-scale it with the square root of the number of involved pixels 
+      //    in order to be comparable to the mean of pedRMS of that area
+      higainrms *= TMath::Sqrt((Float_t)napix);
+
+      fPedestals->GetAverageArea(aidx).Set(higainped, higainrms);
+    }
+  
+  //
+  // Loop over the (six) sector indices to get the averaged pedestal per sector
+  //
+  for (Int_t sector=0; sector<fSectorValid.GetSize(); sector++)
+    {
+      
+      const Int_t   nspix = fSectorValid.At(sector);
+
+      if (nspix == 0)
+        continue;
+      
+      const Float_t sum   = fSectorSumx.At(sector);
+      const Float_t sum2  = fSectorSumx2.At(sector);
+      const ULong_t sn    = nspix * n;
+      const ULong_t sevts = nspix * nevts;
+      
+      const Float_t higainped = sum/sn;
+
+      // 1. Calculate the Variance of the sums:
+      Float_t higainVar = (sum2-sum*sum/sevts)/(sevts-1.);
+      // 2. Scale the variance to the number of slices:
+      higainVar /= fWindowSizeHiGain+fWindowSizeLoGain;
+      // 3. Calculate the RMS from the Variance:
+      Float_t higainrms = TMath::Sqrt(higainVar);
+      // 4. Re-scale it with the square root of the number of involved pixels 
+      //    in order to be comparable to the mean of pedRMS of that sector
+      higainrms *= TMath::Sqrt((Float_t)nspix);
+
+      fPedestals->GetAverageSector(sector).Set(higainped, higainrms);
+    }
+  
+  fPedestals->SetTotalEntries(fNumSamplesTot);
+  fPedestals->SetReadyToSave();
+
+  return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mpedestal/MPedCalcPedRun.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mpedestal/MPedCalcPedRun.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mpedestal/MPedCalcPedRun.h	(revision 9661)
@@ -0,0 +1,60 @@
+#ifndef MARS_MPedCalcPedRun
+#define MARS_MPedCalcPedRun
+
+#ifndef MARS_MExtractor
+#include "MExtractor.h"
+#endif
+
+#ifndef ROOT_TArrayD
+#include <TArrayD.h>
+#endif
+
+#ifndef ROOT_TArrayI
+#include <TArrayI.h>
+#endif
+
+class MGeomCam;
+class MBadPixelsCam;
+class MPedCalcPedRun : public MExtractor
+{
+
+  static const Byte_t fgHiGainFirst;      // First FADC slice Hi-Gain (currently set to: 3) 
+  static const Byte_t fgHiGainLast;       // Last FADC slice Hi-Gain (currently set to: 14) 
+  static const Byte_t fgLoGainFirst;      // First FADC slice Lo-Gain (currently set to: 3) 
+  static const Byte_t fgLoGainLast;       // Last FADC slice Lo-Gain (currently set to: 14) 
+  static const Byte_t fgHiGainWindowSize; // The extraction window Hi-Gain
+  static const Byte_t fgLoGainWindowSize; // The extraction window Lo-Gain
+
+  UInt_t  fNumSamplesTot;
+  Byte_t  fWindowSizeHiGain;             // Number of Hi Gain slices in window
+  Byte_t  fWindowSizeLoGain;             // Number of Lo Gain slices in window  
+  
+  MGeomCam     *fGeom;       // Camera geometry
+  MBadPixelsCam *fBad;       // Bad Pixels
+  
+  TArrayD fSumx;         // sum of values
+  TArrayD fSumx2;        // sum of squared values
+  TArrayD fAreaSumx;     // averaged sum of values per area idx
+  TArrayD fAreaSumx2;    // averaged sum of squared values per area idx
+  TArrayI fAreaValid;    // number of valid pixel with area idx  
+  TArrayD fSectorSumx;   // averaged sum of values per sector 
+  TArrayD fSectorSumx2;  // averaged sum of squared values per sector
+  TArrayI fSectorValid;  // number of valid pixel with sector idx  
+  
+  Int_t  PreProcess ( MParList *pList );
+  Bool_t ReInit     ( MParList *pList );
+  Int_t  Process    ();
+  Int_t  PostProcess();
+  
+public:
+
+  MPedCalcPedRun(const char *name=NULL, const char *title=NULL);
+  
+  void Clear(const Option_t *o="");
+  void SetRange(Byte_t hifirst=0, Byte_t hilast=0, Byte_t lofirst=0, Byte_t lolast=0);
+  void SetWindowSize(Byte_t windowh=0, Byte_t windowl=0);
+  
+  ClassDef(MPedCalcPedRun, 0)   // Task to calculate pedestals from pedestal runs raw data
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mpedestal/MPedPhotCalc.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mpedestal/MPedPhotCalc.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mpedestal/MPedPhotCalc.cc	(revision 9661)
@@ -0,0 +1,203 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Josep Flix 1/2004 <mailto:jflix@ifae.es>
+!   Author(s): Javier Rico 1/2004 <mailto:jrico@ifae.es>
+!   Author(s): Markus Gaug 4/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//   MPedPhotCalc
+//
+//  This is a Task class to compute, for each pixel, the signal mean and
+//  rms from a pedestal run file that has undergone the standard signal
+//  extration  and calibration procedure. The signal rms can be used as
+//  reference to compute the significance of the measured signals in the
+//  following data runs (e.g. during the image cleaning).
+//
+//  Input Containers:
+//   MCerPhotEvt
+//
+//  Output Containers:
+//   MPedPhotCam
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MPedPhotCalc.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MRawRunHeader.h"
+
+#include "MCerPhotPix.h"
+#include "MCerPhotEvt.h"
+
+#include "MPedPhotPix.h"
+#include "MPedPhotCam.h"
+
+#include "MBadPixelsPix.h"
+#include "MBadPixelsCam.h"
+
+ClassImp(MPedPhotCalc);
+
+using namespace std;
+
+//
+// Default constructor
+//
+MPedPhotCalc::MPedPhotCalc(const char *name, const char *title)
+    : fPedestals(NULL), fCerPhot(NULL), fBadPixels(NULL)
+{
+  fName  = name  ? name  : "MPedPhotCalc";
+  fTitle = title ? title : "Task to calculate pedestals in units of photons";
+}
+
+// --------------------------------------------------------------------------
+//
+// Look for the following input containers:
+//
+//  - MCerPhotEvt
+//  - MBadPixelsCam
+// 
+// The following output containers are also searched and created if
+// they were not found:
+//
+//  - MPedPhotCam
+//
+Int_t MPedPhotCalc::PreProcess( MParList *pList )
+{      
+  // Look for input container
+  fCerPhot = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
+  if (!fCerPhot)
+    {
+      *fLog << err << "MPedPhotCalc::PreProcess Error: MCerPhotEvt not found... aborting." << endl;
+      return kFALSE;
+    }
+
+
+  fBadPixels = (MBadPixelsCam*)pList->FindObject("MBadPixelsCam");
+  if (!fBadPixels)
+    {
+      *fLog << warn << "MPedPhotCalc::PreProcess Warning: No MBadPixelsCam found." << endl;
+    }
+
+  // Create output container
+  fPedestals = (MPedPhotCam*)pList->FindCreateObj("MPedPhotCam");
+  if (!fPedestals)
+    return kFALSE;
+  
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// The ReInit searches for the following input containers:
+//  - MRawRunHeader
+//
+// It also initializes the data arrays fSumx and fSumx2 
+// (only for the first read file)
+// 
+Bool_t MPedPhotCalc::ReInit(MParList *pList)
+{
+  const MRawRunHeader *runheader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
+  if (!runheader)
+  {
+      *fLog << warn << dbginf;
+      *fLog << "Warning - cannot check file type, MRawRunHeader not found." << endl;
+  }
+  else
+      if (runheader->IsMonteCarloRun())
+          return kTRUE;
+  
+
+  // Initialize arrays
+  if(fSumx.GetSize()==0)
+  {
+      const UShort_t num = fPedestals->GetSize();
+
+      fSumx.Set(num);
+      fSumx2.Set(num);
+
+      memset(fSumx.GetArray(),  0, sizeof(Float_t)*num);
+      memset(fSumx2.GetArray(), 0, sizeof(Float_t)*num);
+  }
+
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Store the measured number of photons in arrays fSumx and fSumx2
+// so that we can calculate the mean and rms in the PostProcess()
+//
+Int_t MPedPhotCalc::Process()
+{
+    for(UInt_t i=0;i<fCerPhot->GetNumPixels();i++)
+    {
+ 
+       const MCerPhotPix &pix = (*fCerPhot)[i];
+       const Int_t pixidx = pix.GetPixId();
+
+       const Float_t nphot = pix.GetNumPhotons();
+       
+       fSumx[pixidx]  += nphot;
+       fSumx2[pixidx] += nphot*nphot;
+    }
+
+    fPedestals->SetReadyToSave();
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Compute mean and rms of the measured charge distribution (in photons)
+//
+Int_t MPedPhotCalc::PostProcess()
+{
+    // Compute pedestals and rms from fSumx and fSumx2 arrays
+    const Int_t n    = GetNumExecutions();
+    const Int_t npix = fSumx.GetSize();
+
+    for(Int_t i=0; i<npix; i++)
+    {
+
+      if (fBadPixels)
+        {
+          const MBadPixelsPix &bad = (*fBadPixels)[i];
+          if (bad.IsBad())
+            continue;
+        }
+
+      const Float_t sum  = fSumx[i];
+      const Float_t sum2 = fSumx2[i];
+      
+      const Float_t photped = sum/n;
+      const Float_t photrms = TMath::Sqrt((sum2-sum*sum/n)/(n-1.));
+      
+      (*fPedestals)[i].Set(photped,photrms);
+    }
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mpedestal/MPedPhotCalc.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mpedestal/MPedPhotCalc.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mpedestal/MPedPhotCalc.h	(revision 9661)
@@ -0,0 +1,37 @@
+#ifndef MARS_MPedPhotCalc
+#define MARS_MPedPhotCalc
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+#ifndef ROOT_TArrayF
+#include <TArrayF.h>
+#endif
+
+class MPedPhotCam;
+class MCerPhotEvt;
+class MBadPixelsCam;
+class MPedPhotCalc : public MTask
+{
+
+  MPedPhotCam   *fPedestals;  // Pedestals of all pixels in the camera
+  MCerPhotEvt   *fCerPhot;    // Calibrated Cherenkov events 
+  MBadPixelsCam *fBadPixels;  // Bad Pixels
+  
+  TArrayF fSumx;   // sum of values
+  TArrayF fSumx2;  // sum of squared values
+
+  Bool_t ReInit(MParList *pList);
+
+  Int_t PreProcess(MParList *pList);
+  Int_t Process();
+  Int_t PostProcess();
+  
+public:
+  MPedPhotCalc(const char *name=NULL, const char *title=NULL);
+
+  ClassDef(MPedPhotCalc, 0) //Task to calculate pedestals in units of photons
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mpedestal/MPedPhotCam.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mpedestal/MPedPhotCam.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mpedestal/MPedPhotCam.cc	(revision 9661)
@@ -0,0 +1,357 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!              Hendrik Bartko, 07/2003 <mailto:hbartko@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MPedPhotCam
+//
+// Hold the Pedestal information for all pixels in the camera (in usints
+// of photons)
+//
+// Version 2:
+// ----------
+//   - added fAreas
+//   - added fSectors
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MPedPhotCam.h"
+
+#include <TArrayI.h>
+#include <TArrayD.h>
+#include <TClonesArray.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MPedPhotPix.h"
+
+#include "MGeomCam.h"
+#include "MGeomPix.h"
+
+#include "MBadPixelsCam.h"
+#include "MBadPixelsPix.h"
+
+ClassImp(MPedPhotCam);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. Creates a MPedPhotPix object for each pixel
+//
+MPedPhotCam::MPedPhotCam(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MPedPhotCam";
+    fTitle = title ? title : "Storage container for all Pedestal Information in the camera (in units of photons)";
+
+    fArray   = new TClonesArray("MPedPhotPix", 1);
+    fAreas   = new TClonesArray("MPedPhotPix", 1);
+    fSectors = new TClonesArray("MPedPhotPix", 1);
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the array conatining the pixel pedest information
+//
+MPedPhotCam::~MPedPhotCam()
+{
+    delete fArray;
+    delete fAreas;
+    delete fSectors;
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the size of the camera
+//
+void MPedPhotCam::InitSize(const UInt_t i)
+{
+    fArray->ExpandCreate(i);
+}
+
+// -------------------------------------------------------------------
+//
+// Calls TClonesArray::ExpandCreate() for:
+// - fAverageAreas
+//
+void MPedPhotCam::InitAreas(const UInt_t i)
+{
+    fAreas->ExpandCreate(i);
+}
+
+// -------------------------------------------------------------------
+//
+// Calls TClonesArray::ExpandCreate() for:
+// - fAverageSectors
+//
+void MPedPhotCam::InitSectors(const UInt_t i)
+{
+    fSectors->ExpandCreate(i);
+}
+
+// -------------------------------------------------------------------
+//
+// Calls:
+// - InitSize()
+// - InitAverageAreas()
+// - InitAverageSectors()
+//
+void MPedPhotCam::Init(const MGeomCam &geom)
+{
+    InitSize(geom.GetNumPixels());
+    InitAreas(geom.GetNumAreas());
+    InitSectors(geom.GetNumSectors());
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Get the size of the MPedPhotCam
+//
+Int_t MPedPhotCam::GetSize() const
+{
+    return fArray->GetEntriesFast();
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the size of the MPedPhotCam
+//
+Int_t MPedPhotCam::GetNumSectors() const
+{
+    return fSectors->GetEntriesFast();
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the size of the MPedPhotCam
+//
+Int_t MPedPhotCam::GetNumAreas() const
+{
+    return fAreas->GetEntriesFast();
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th pixel (pixel number)
+//
+MPedPhotPix &MPedPhotCam::operator[](Int_t i)
+{
+    return *static_cast<MPedPhotPix*>(fArray->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th pixel (pixel number)
+//
+const MPedPhotPix &MPedPhotCam::operator[](Int_t i) const
+{
+    return *static_cast<MPedPhotPix*>(fArray->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th average pixel (area number)
+//
+MPedPhotPix &MPedPhotCam::GetArea(UInt_t i)
+{
+    return *static_cast<MPedPhotPix*>(fAreas->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th average pixel (sector number)
+//
+MPedPhotPix &MPedPhotCam::GetSector(UInt_t i)
+{
+    return *static_cast<MPedPhotPix*>(fSectors->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th average pixel (area number)
+//
+const MPedPhotPix &MPedPhotCam::GetArea(UInt_t i)const
+{
+    return *static_cast<MPedPhotPix*>(fAreas->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th average pixel (sector number)
+//
+const MPedPhotPix &MPedPhotCam::GetSector(UInt_t i) const
+{
+    return *static_cast<MPedPhotPix*>(fSectors->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Call clear of all three TClonesArray
+//
+void MPedPhotCam::Clear(Option_t *o)
+{
+    { fArray->ForEach(TObject, Clear)(); }
+    { fAreas->ForEach(TObject, Clear)(); }
+    { fSectors->ForEach(TObject, Clear)(); }
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculates the avarage pedestal and pedestal rms for all sectors
+// and pixel sizes. The geometry container is used to get the necessary
+// geometry information (sector number, size index) If the bad pixel
+// container is given all pixels which have the flag 'bad' are ignored
+// in the calculation of the sector and size average.
+//
+void MPedPhotCam::ReCalc(const MGeomCam &geom, MBadPixelsCam *bad)
+{
+    
+    const Int_t np = GetSize();
+    const Int_t ns = GetNumSectors();
+    const Int_t na = GetNumAreas();
+
+    
+
+    TArrayI acnt(na);
+    TArrayI scnt(ns);
+    TArrayD asumx(na);
+    TArrayD ssumx(ns);
+    TArrayD asumr(na);
+    TArrayD ssumr(ns);
+
+
+    for (int i=0; i<np; i++)
+    {
+        
+
+      if (bad && (*bad)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
+	continue; //was: .IsBad()       
+
+        // Create sums for areas and sectors
+        const UInt_t aidx = geom[i].GetAidx();
+        const UInt_t sect = geom[i].GetSector();
+
+        const MPedPhotPix &pix = (*this)[i];
+
+        const UInt_t  ne   = pix.GetNumEvents();
+        const Float_t mean = pix.GetMean();
+	const Float_t rms  = pix.GetRms();
+
+        asumx[aidx] += ne*mean;
+	asumr[aidx] += ne*rms;
+        acnt[aidx]  += ne;
+
+        ssumx[sect] += ne*mean;
+	ssumr[sect] += ne*rms;
+        scnt[sect]  += ne;
+    
+
+    }
+
+    for (int i=0; i<ns; i++){
+      if (scnt[i]>0)  GetSector(i).Set(ssumx[i]/scnt[i], ssumr[i]/scnt[i], scnt[i]);
+      else GetSector(i).Set(-1., -1., 0);
+    }
+
+    for (int i=0; i<na; i++){
+      if (acnt[i]>0) GetArea(i).Set(asumx[i]/acnt[i], asumr[i]/acnt[i], acnt[i]);
+      else  GetArea(i).Set(-1., -1., 0);
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// print contents
+//
+void MPedPhotCam::Print(Option_t *o) const
+{
+    *fLog << all << GetDescriptor() << ":" << endl;
+    int id = 0;
+
+    TIter Next(fArray);
+    MPedPhotPix *pix;
+    while ((pix=(MPedPhotPix*)Next()))
+    {
+        id++;
+
+        if (!pix->IsValid())
+            continue;
+
+        *fLog << id-1 << ": ";
+        *fLog << pix->GetMean() << " " << pix->GetRms() << endl;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// See MCamEvent
+//
+Bool_t MPedPhotCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
+{
+
+    const Float_t ped      = (*this)[idx].GetMean();
+    const Float_t rms      = (*this)[idx].GetRms();
+    const UInt_t  nevt     = (*this)[idx].GetNumEvents();
+
+
+    Float_t pederr;
+    Float_t rmserr; 
+
+    if (nevt>0)
+    {
+        pederr = rms/TMath::Sqrt((Float_t)nevt);
+        rmserr = rms/TMath::Sqrt((Float_t)nevt)/2.;
+    }
+    else
+    {
+        pederr = -1;
+        rmserr = -1;
+    }
+
+    switch (type)
+    {
+    case 0:
+        val = ped;// (*this)[idx].GetMean();
+        break;
+    case 1:
+        val = rms; // (*this)[idx].GetRms();
+        break;
+    case 2:
+        val = pederr; // new
+        break;
+    case 3:
+      val = rmserr; // new
+        break;
+    default:
+	return kFALSE;
+    }
+    return val>=0;
+}
+
+void MPedPhotCam::DrawPixelContent(Int_t num) const
+{
+    *fLog << warn << "MPedPhotCam::DrawPixelContent - not available." << endl;
+}
Index: /tags/Mars_V0-8-5/Mars/mpedestal/MPedPhotCam.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mpedestal/MPedPhotCam.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mpedestal/MPedPhotCam.h	(revision 9661)
@@ -0,0 +1,62 @@
+#ifndef MARS_MPedPhotCam
+#define MARS_MPedPhotCam
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+#ifndef MARS_MCamEvent
+#include "MCamEvent.h"
+#endif
+
+class TClonesArray;
+
+class MGeomCam;
+class MPedPhotPix;
+class MBadPixelsCam;
+
+class MPedPhotCam : public MParContainer, public MCamEvent
+{
+private:
+    TClonesArray *fArray;    // FIXME: Change TClonesArray away from a pointer?
+    TClonesArray *fAreas;    //-> Array of MPedPhotPix, one per pixel area
+    TClonesArray *fSectors;  //-> Array of MPedPhotPix, one per camera sector
+
+    //  void InitSize(const UInt_t i);
+    void InitAreas(const UInt_t i);
+    void InitSectors(const UInt_t i);
+
+public:
+    MPedPhotCam(const char *name=NULL, const char *title=NULL);
+    ~MPedPhotCam();
+
+    void Clear(Option_t *o="");
+
+    void Init(const MGeomCam &geom);
+    void InitSize(const UInt_t i); // HB
+    Int_t GetSize() const;
+
+    MPedPhotPix &operator[](Int_t i);
+    const MPedPhotPix &operator[](Int_t i) const;
+
+          MPedPhotPix &GetArea(UInt_t i);
+    const MPedPhotPix &GetArea(UInt_t i) const;
+
+    Int_t GetNumAreas() const;
+
+          MPedPhotPix &GetSector(UInt_t i);
+    const MPedPhotPix &GetSector(UInt_t i) const;
+
+    Int_t GetNumSectors() const;
+
+    void Print(Option_t *o="") const;
+
+    void ReCalc(const MGeomCam &geom, MBadPixelsCam *bad);
+
+    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
+    void DrawPixelContent(Int_t num) const;
+
+    ClassDef(MPedPhotCam, 2)	// Storage Container for all pedestal information of the camera (in units of photons)
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mpedestal/MPedPhotPix.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mpedestal/MPedPhotPix.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mpedestal/MPedPhotPix.cc	(revision 9661)
@@ -0,0 +1,57 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MPedPhotPix
+//
+// This is the storage container to hold informations about the pedestal
+// (offset) value of one Pixel (PMT) in units of photons.
+//
+// Version 2:
+// ----------
+//   - added fNumEvents
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MPedPhotPix.h"
+
+#include "MLog.h"
+
+ClassImp(MPedPhotPix);
+
+MPedPhotPix::MPedPhotPix()
+{
+    Clear();
+}
+
+// ------------------------------------------------------------------------
+//
+// Invalidate values
+//
+void MPedPhotPix::Clear(Option_t *o)
+{
+    fMean = -1;
+    fRms  = -1;
+    fNumEvents = 0;
+}
Index: /tags/Mars_V0-8-5/Mars/mpedestal/MPedPhotPix.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mpedestal/MPedPhotPix.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mpedestal/MPedPhotPix.h	(revision 9661)
@@ -0,0 +1,35 @@
+#ifndef MARS_MPedPhotPix
+#define MARS_MPedPhotPix
+
+#ifndef ROOT_TObject
+#include <TObject.h>
+#endif
+
+class MPedPhotPix : public TObject
+{
+private:
+    Float_t fMean;      // [phot] mean value of pedestal (should be 0)
+    Float_t fRms;       // [phot] rms of mean
+
+    UInt_t  fNumEvents; // [n] number of events used to calculate mean (0=n/a)
+
+public:
+    MPedPhotPix();
+
+    void Clear(Option_t *o="");
+
+    Float_t GetMean() const      { return fMean; }
+    Float_t GetRms() const       { return fRms; }
+    UInt_t  GetNumEvents() const { return fNumEvents; }
+
+    //void SetMean(Float_t f) { fMean = f; }
+    void SetRms(Float_t f)  { fRms  = f; }
+    void Set(Float_t m, Float_t r, UInt_t n=1) { fMean = m; fRms = r; fNumEvents=n; }
+
+    Bool_t IsValid() const { return fRms>=0; }
+
+    ClassDef(MPedPhotPix, 2) // Storage Container for Pedestal information of one pixel in units of photons
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mpedestal/MPedestalCalc.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mpedestal/MPedestalCalc.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mpedestal/MPedestalCalc.cc	(revision 9661)
@@ -0,0 +1,229 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Josep Flix 11/2002 <mailto:jflix@ifae.es>
+!   Author(s): Thomas Bretz 11/2002 <mailto:tbretz@astro.uni-wuerburg.de>
+!
+!   Copyright: MAGIC Software Development, 2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MPedestalCalc
+//
+//  Task to calculate the pedestals from the event stream.
+//
+//  From the events two streams of pedestals are created like in the
+//  following table
+//  MRawEvtData:    1   2   3   4   5   6   7   8   9  10  11  12
+//  MPedestalCam;1: ------1------   ------2------   ------3------...
+//  MPedestalCam;2:         ------1------   ------2------  ------...
+//
+//  Input Containers:
+//   MRawEvtData
+//
+//  Output Containers:
+//   MPedestalCam;1
+//   MPedestalCam;2
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MPedestalCalc.h"
+
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MTime.h"
+#include "MHFadcCam.h"
+#include "MRawEvtPixelIter.h"
+
+#include "MPedestalCam.h"
+#include "MPedestalPix.h"
+
+ClassImp(MPedestalCalc);
+
+MPedestalCalc::MPedestalCalc(const char *name, const char *title)
+    : fNumBranches(2), fTimeSlot(6), fHists(NULL)
+{
+    fName  = name  ? name  : "MPedestalCalc";
+    fTitle = title ? title : "Task to calculate pedestals from pedestal runs raw data";
+
+    AddToBranchList("fHiGainPixId");
+    AddToBranchList("fLoGainPixId");
+    AddToBranchList("fHiGainFadcSamples");
+    AddToBranchList("fLoGainFadcSamples");
+}
+
+Int_t MPedestalCalc::PreProcess(MParList *pList)
+{
+    if (fHists)
+    {
+        *fLog << err << "ERROR - Previous PostProcess not called." << endl;
+        return kFALSE;
+    }
+
+    fHists = new MHFadcCam[fNumBranches];
+    fStart = new MTime    [fNumBranches];
+
+    fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
+    if (!fRawEvt)
+    {
+        *fLog << dbginf << "MRawEvtData not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fPedestals = (MPedestalCam*)pList->FindCreateObj("MPedestalCam");
+    if (!fPedestals)
+        return kFALSE;
+
+    fPedTime = (MTime*)pList->FindCreateObj("MTime", "MPedestalTime");
+    if (!fPedTime)
+        return kFALSE;
+
+    //
+    // Fixme: FindCreateObj --> FindObject
+    //
+    fEvtTime = (MTime*)pList->FindCreateObj("MTime", "MRawEvtTime");
+    if (!fEvtTime)
+        return kFALSE;
+
+    for (int i=0; i<fNumBranches; i++)
+        fStart[i].SetTime(fTimeSlot*10/fNumBranches*i, 0);
+
+    fPedTime->SetDuration(fTimeSlot);
+    fEvtTime->SetTime(0, 0);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Checks whether the current event exceed the validity range of a pedestal
+//  in one of the streams. If this is the case the data from the histogram
+//  is dumped as pedestals into the corresponding containers and the
+//  histograms are reset.
+//
+//  Then the current event is filled into the histograms.
+//
+Int_t MPedestalCalc::Process()
+{
+    //
+    // Time when filling of stream a/b must be restarted
+    //
+    for (int i=0; i<fNumBranches; i++)
+    {
+        Check(i);
+        Fill(i);
+    }
+
+    fEvtTime->SetTime(fEvtTime->GetTimeLo()+10, 0);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Fill the event in the histogram if the current time of the
+//  event is _after_ the start time for filling
+//
+void MPedestalCalc::Fill(Int_t i)
+{
+    if (*fEvtTime < fStart[i])
+        return;
+
+    fHists[i].Fill(fRawEvt);
+}
+
+// --------------------------------------------------------------------------
+//
+//  If the current time of the event is equal or after the time
+//  which is given by the start time plus the validity range
+//  calculate the corresponding set of pedestals and reset the
+//  histograms
+//
+void MPedestalCalc::Check(Int_t i)
+{
+    if (*fEvtTime-fStart[i] < fTimeSlot*10)
+        return;
+
+    Calc(i);
+
+    fStart[i] = *fEvtTime;
+    fHists[i].ResetHistograms();
+}
+
+// --------------------------------------------------------------------------
+//
+//  Deletes all dynamicly allocated arrays
+//
+Bool_t MPedestalCalc::PostProcess()
+{
+    delete fHists;
+    delete fStart;
+
+    fHists=NULL;
+
+    return kTRUE;
+}
+
+/*
+ #include "MRawEvtData.h"
+ */
+// --------------------------------------------------------------------------
+//
+//  Dumps the mean, rms and their errors from the filled histograms into
+//  the Pedestal container. Sets the ReadyToSaveFlag of the MPedestalCam
+//  container.
+//
+void MPedestalCalc::Calc(Int_t i) const
+{
+    // FIXME! Fit +- 3 sigma to avoid outliers...
+
+    MRawEvtPixelIter pixel(fRawEvt);
+    while (pixel.Next())
+    {
+        const UInt_t pixid = pixel.GetPixelId();
+
+        const TH1 &h = *fHists[i].GetHistHi(pixid);
+
+        const Int_t   entries = (Int_t)h.GetEntries();
+        const Float_t meanhi  = h.GetMean();
+        const Float_t rmshi   = h.GetRMS();
+
+        const Float_t meanhierr = rmshi/sqrt(entries);
+        const Float_t rmshierr  = rmshi/sqrt(entries*2);
+
+        MPedestalPix &pix = (*fPedestals)[pixid];
+        pix.SetPedestal(meanhi, rmshi);
+        pix.SetPedestalRms(meanhierr, rmshierr);
+    }
+
+    *fPedTime = fStart[i];
+
+    fPedTime->SetReadyToSave();
+    fPedestals->SetReadyToSave();
+
+    /*
+     *fLog << i << "[" << fHists[i].GetHistHi(0)->GetEntries()/fRawEvt->GetNumHiGainSamples() << "]:  ";
+     *fLog << fEvtTime->GetTimeLo() << ": Calc [";
+     *fLog << fStart[i].GetTimeLo() << " < ";
+     *fLog << fStart[i].GetTimeLo()+fTimeSlot*10 << "]" << endl;
+     */
+}
Index: /tags/Mars_V0-8-5/Mars/mpedestal/MPedestalCalc.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mpedestal/MPedestalCalc.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mpedestal/MPedestalCalc.h	(revision 9661)
@@ -0,0 +1,59 @@
+#ifndef MARS_MPedestalCalc
+#define MARS_MPedestalCalc
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MPedestalCalc                                                           //
+//                                                                         //
+// Implementation of ped. Eval. defined in Jan 02                          //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+#ifndef MARS_MHFadCam
+#include "MHFadcCam.h"
+#endif
+
+class MTime;
+class MRawEvtData;
+class MPedestalCam;
+
+class MPedestalCalc : public MTask 
+{
+private:
+    Int_t   fNumBranches;
+    Float_t fTimeSlot;
+
+    MRawEvtData  *fRawEvt;
+    MPedestalCam *fPedestals;  //
+
+    MHFadcCam *fHists;         //[fNumBranches]
+
+    MTime     *fPedTime; // time of the pedestal event
+    MTime     *fEvtTime; // time of the current event
+    MTime     *fStart;   //[fNumBranches] starting time of the current pedestal
+
+
+    void Calc(Int_t i) const;
+    void Fill(Int_t i);
+    void Check(Int_t i);
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
+public:
+    MPedestalCalc(const char *name=NULL, const char *title=NULL);
+
+    void SetTimeSlot(Float_t newslot) { fTimeSlot = newslot; }
+    void SetNumBranches(Int_t num) { fNumBranches = num; }
+
+    ClassDef(MPedestalCalc, 0) // Task to calculate the pestels from pedestal events
+};
+
+#endif
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mpedestal/MPedestalCam.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mpedestal/MPedestalCam.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mpedestal/MPedestalCam.cc	(revision 9661)
@@ -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>
+!              Markus Gaug    02/2004 <mailto:markus@ifae.es>
+!              Florian Goebel 06/2004 <mailto:fgoebel@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MPedestalCam                                                            //
+//                                                                         //
+// Hold the Pedestal information for all pixels in the camera              //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MPedestalCam.h"
+#include "MPedestalPix.h"
+
+#include <TClonesArray.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MGeomCam.h"
+
+ClassImp(MPedestalCam);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+// Creates a TClonesArray of MPedestalPix containers, initialized to 1 entry, destinated 
+// to hold one container per pixel. Later, a call to MPedestalCam::InitSize() 
+// has to be performed (in MGeomApply). 
+//
+// Creates a TClonesArray of MPedestalPix containers, initialized to 1 entry, destinated 
+// to hold one container per pixel AREA. Later, a call to MPedestalCam::InitAreas() 
+// has to be performed (in MGeomApply). 
+//
+// Creates a TClonesArray of MPedestalPix containers, initialized to 1 entry, destinated
+// to hold one container per camera SECTOR. Later, a call to MPedestalCam::InitSectors() 
+// has to be performed (in MGeomApply). 
+//
+MPedestalCam::MPedestalCam(const char *name, const char *title) 
+    : fTotalEntries(0)
+{
+  fName  = name  ? name  : "MPedestalCam";
+  fTitle = title ? title : "Storage container for all Pedestal Information in the camera";
+  
+  fArray            = new TClonesArray("MPedestalPix", 1);
+  fAverageAreas     = new TClonesArray("MPedestalPix", 1);
+  fAverageSectors   = new TClonesArray("MPedestalPix", 1);
+}
+
+// --------------------------------------------------------------------------
+//
+// Deletes the following TClonesArray's of MPedestalPix containers (if exist):
+// - fArray
+// - fAverageAreas
+// - fAverageSectors
+//  
+MPedestalCam::~MPedestalCam()
+{
+  delete fArray;
+  delete fAverageAreas;
+  delete fAverageSectors;
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the size of the camera
+//
+void MPedestalCam::InitSize(const UInt_t i)
+{
+    fArray->ExpandCreate(i);
+}
+
+// -------------------------------------------------------------------
+//
+// Calls TClonesArray::ExpandCreate() for:
+// - fAverageAreas
+//
+void MPedestalCam::InitAverageAreas(const UInt_t i)
+{
+  fAverageAreas->ExpandCreate(i);
+}
+
+// -------------------------------------------------------------------
+//
+// Calls TClonesArray::ExpandCreate() for:
+// - fAverageSectors
+//
+void MPedestalCam::InitAverageSectors(const UInt_t i)
+{
+  fAverageSectors->ExpandCreate(i);
+}
+
+// -------------------------------------------------------------------
+//
+// Calls:
+// - InitSize()
+// - InitAverageAreas()
+// - InitAverageSectors()
+//
+void MPedestalCam::Init(const MGeomCam &geom)
+{
+  InitSize          (geom.GetNumPixels() );
+  InitAverageAreas  (geom.GetNumAreas()  );
+  InitAverageSectors(geom.GetNumSectors());
+}
+
+// --------------------------------------------------------------------------
+//
+// This function returns the current size of the TClonesArray 
+// independently if the MPedestalPix is filled with values or not.
+//
+// Get the size of the MPedestalCam
+//
+Int_t MPedestalCam::GetSize() const
+{
+    return fArray->GetEntriesFast();
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the current size of the TClonesArray fAverageAreas
+// independently if the MPedestalPix is filled with values or not.
+//
+const Int_t MPedestalCam::GetAverageAreas() const
+{
+  return fAverageAreas->GetEntriesFast();
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the current size of the TClonesArray fAverageSectors
+// independently if the MPedestalPix is filled with values or not.
+//
+const Int_t MPedestalCam::GetAverageSectors() const
+{
+  return fAverageSectors->GetEntriesFast();
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th pixel (pixel number)
+//
+MPedestalPix &MPedestalCam::operator[](Int_t i)
+{
+    return *static_cast<MPedestalPix*>(fArray->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th pixel (pixel number)
+//
+const MPedestalPix &MPedestalCam::operator[](Int_t i) const
+{
+    return *static_cast<MPedestalPix*>(fArray->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th average pixel (area number)
+//
+MPedestalPix &MPedestalCam::GetAverageArea(UInt_t i)
+{
+  return *static_cast<MPedestalPix*>(fAverageAreas->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th average pixel (area number)
+//
+const MPedestalPix &MPedestalCam::GetAverageArea(UInt_t i) const 
+{
+  return *static_cast<MPedestalPix*>(fAverageAreas->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th average pixel (sector number)
+//
+MPedestalPix &MPedestalCam::GetAverageSector(UInt_t i)
+{
+  return *static_cast<MPedestalPix*>(fAverageSectors->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th average pixel (sector number)
+//
+const MPedestalPix &MPedestalCam::GetAverageSector(UInt_t i) const 
+{
+  return *static_cast<MPedestalPix*>(fAverageSectors->UncheckedAt(i));
+}
+
+// --------------------------------------
+//
+// Calls the ForEach macro for the TClonesArray fArray with the argument Clear()
+// 
+// Loops over the fAverageAreas, calling the function Clear() for 
+// every entry in fAverageAreas
+//
+// Loops over the fAverageSectors, calling the function Clear() for 
+// every entry in fAverageSectors
+// 
+void MPedestalCam::Clear(Option_t *o)
+{
+  fArray->ForEach(TObject, Clear)();
+  
+  //
+  // another ForEach does not compile, thus have to do the loop ourselves:
+  //
+  for (Int_t i=0;i<GetAverageAreas();i++)
+    fAverageAreas[i].Clear();
+
+
+  //
+  // another ForEach does not compile, thus have to do the loop ourselves:
+  //
+  for (Int_t i=0;i<GetAverageSectors();i++)
+    fAverageSectors[i].Clear();
+  
+  fTotalEntries = 0;
+}
+
+void MPedestalCam::Print(Option_t *o) const
+{
+    *fLog << all << GetDescriptor() << ":" << endl;
+    int id = 0;
+
+    TIter Next(fArray);
+    MPedestalPix *pix;
+    while ((pix=(MPedestalPix*)Next()))
+    {
+        id++;
+
+        if (!pix->IsValid())
+            continue;
+
+        *fLog << id-1 << ": ";
+        *fLog << pix->GetPedestal() << " " << pix->GetPedestalRms() << endl;
+    }
+}
+
+Float_t MPedestalCam::GetPedestalMin(const MGeomCam *geom) const
+{
+    if (fArray->GetEntries() <= 0)
+        return 50.;
+
+    Float_t minval = (*this)[0].GetPedestalRms();
+
+    for (Int_t i=1; i<fArray->GetEntries(); i++)
+    {
+        const MPedestalPix &pix = (*this)[i];
+
+        Float_t testval = pix.GetPedestalRms();
+
+        if (geom)
+            testval *= geom->GetPixRatio(i);
+
+        if (testval < minval)
+            minval = testval;
+    }
+    return minval;
+}
+
+Float_t MPedestalCam::GetPedestalMax(const MGeomCam *geom) const
+{
+    if (fArray->GetEntries() <= 0)
+        return 50.;
+
+    Float_t maxval = (*this)[0].GetPedestalRms();
+
+    for (Int_t i=1; i<fArray->GetEntries(); i++)
+    {
+        const MPedestalPix &pix = (*this)[i];
+
+        Float_t testval = pix.GetPedestalRms();
+
+        if (geom)
+            testval *= geom->GetPixRatio(i);
+
+        if (testval > maxval)
+            maxval = testval;
+    }
+    return maxval;
+}
+
+Bool_t MPedestalCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const {
+
+  if (GetSize() <= idx)
+    return kFALSE;
+
+  if (!(*this)[idx].IsValid())
+    return kFALSE;
+
+  switch (type) {
+    case 0:
+      val = (*this)[idx].GetPedestal();
+      break;
+    case 1:
+      val = fTotalEntries > 0 ? 
+	  (*this)[idx].GetPedestalRms()/TMath::Sqrt((Float_t)fTotalEntries) 
+	: (*this)[idx].GetPedestalError();
+      break;
+    case 2:
+      val = (*this)[idx].GetPedestalRms();
+      break;
+    case 3:
+      val = fTotalEntries > 0 ?
+	  (*this)[idx].GetPedestalRms()/TMath::Sqrt((Float_t)fTotalEntries)/2. 
+	: (*this)[idx].GetPedestalRmsError();
+      break;
+    default:
+      return kFALSE;
+    }
+  return kTRUE;
+}
+
+void MPedestalCam::DrawPixelContent(Int_t idx) const
+{
+  *fLog << warn << "MPedestalCam::DrawPixelContent - not available." << endl;
+}
Index: /tags/Mars_V0-8-5/Mars/mpedestal/MPedestalCam.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mpedestal/MPedestalCam.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mpedestal/MPedestalCam.h	(revision 9661)
@@ -0,0 +1,64 @@
+#ifndef MARS_MPedestalCam
+#define MARS_MPedestalCam
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+#ifndef MARS_MCamEvent
+#include "MCamEvent.h"
+#endif
+
+class TClonesArray;
+
+class MGeomCam;
+class MPedestalPix;
+
+class MPedestalCam : public MParContainer, public MCamEvent
+{
+private:
+
+  TClonesArray *fArray;           //-> FIXME: Change TClonesArray away from a pointer?
+  TClonesArray *fAverageAreas;    //-> Array of MPedestalPix, one per pixel area
+  TClonesArray *fAverageSectors;  //-> Array of MPedestalPix, one per camera sector
+
+  UInt_t fTotalEntries;  // Total number of times, the Process was executed (to estimate the error of pedestal)
+
+public:
+
+  MPedestalCam(const char *name=NULL, const char *title=NULL);
+  ~MPedestalCam();
+  
+  void Clear(Option_t *o="");
+  
+  // Getters 
+        MPedestalPix &GetAverageArea   ( UInt_t i );
+  const MPedestalPix &GetAverageArea   ( UInt_t i )            const;
+  const Int_t         GetAverageAreas  ()                      const;
+        MPedestalPix &GetAverageSector ( UInt_t i );
+  const MPedestalPix &GetAverageSector ( UInt_t i )            const;
+  const Int_t         GetAverageSectors()                      const;
+  Float_t             GetPedestalMin   ( const MGeomCam *cam ) const;
+  Float_t             GetPedestalMax   ( const MGeomCam *cam ) const;
+  Int_t               GetSize          ()                      const;
+  ULong_t             GetTotalEntries  ()                      const { return fTotalEntries; }
+  
+        MPedestalPix &operator[]       ( Int_t i             );
+  const MPedestalPix &operator[]       ( Int_t i             ) const;
+
+  void  Init                           ( const MGeomCam &geom);
+  void  InitSize                       ( const UInt_t i      );
+  void  InitAverageAreas               ( const UInt_t i      );
+  void  InitAverageSectors             ( const UInt_t i      );
+
+  void Print(Option_t *o="") const;
+  
+  // Setters
+  void SetTotalEntries(const ULong_t n) { fTotalEntries = n; }
+
+  Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
+  void DrawPixelContent(Int_t idx) const;
+
+  ClassDef(MPedestalCam, 1)	// Storage Container for all pedestal information of the camera
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mpedestal/MPedestalPix.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mpedestal/MPedestalPix.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mpedestal/MPedestalPix.cc	(revision 9661)
@@ -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>
+!              Markus Gaug    04/2004 <mailto:markus@ifae.es>               
+!              Florian Goebel 06/2004 <mailto:fgoebel@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MPedestalPix                                                            //
+//                                                                         //
+// This is the storage container to hold informations about the pedestal   //
+// (offset) value of one Pixel (PMT).                                      //
+//                                                                         //
+// version 2:                                                              //
+// ----------                                                              //
+// added:                                                                  //
+//  fPedestalABoffset   difference between pedestal mean of odd slices and //
+//                      the total pedestal mean (fPedestal)                //
+//  fNumEvents          number of times, the Process was executed          //
+//                      (to estimate the error of pedestal)                //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MPedestalPix.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MPedestalPix);
+
+using namespace std;
+
+MPedestalPix::MPedestalPix()
+  : fValid(kTRUE)
+{
+  Clear();
+}
+
+
+// ------------------------------------------------------------------------
+//
+// Invalidate values
+//
+void MPedestalPix::Clear(Option_t *o)
+{
+  fPedestal         = -1.;
+  fPedestalRms      = -1.;
+  fPedestalABoffset = -1.;
+  fNumEvents        = 0;
+}
+
+void MPedestalPix::InitUseHists()
+{
+
+  fPedestal         = 0.;
+  fPedestalRms      = 0.;
+  fPedestalABoffset = 0.;
+  fNumEvents        = 0;
+}
+
+
+void MPedestalPix::Set(Float_t m, Float_t r, Float_t offs, UInt_t n)
+{
+  fPedestal         = m; 
+  fPedestalRms      = r; 
+  fPedestalABoffset = offs;
+  fNumEvents        = n;
+}
+
+
+Bool_t MPedestalPix::IsValid() const
+{
+ 
+  if (!fValid)
+    return kFALSE;
+ 
+ return fPedestal>=0||fPedestalRms>=0;
+}
Index: /tags/Mars_V0-8-5/Mars/mpedestal/MPedestalPix.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mpedestal/MPedestalPix.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mpedestal/MPedestalPix.h	(revision 9661)
@@ -0,0 +1,50 @@
+#ifndef MARS_MPedestalPix
+#define MARS_MPedestalPix
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MPedestalPix : public MParContainer
+{
+private:
+
+  Float_t fPedestal;     // mean value of pedestal (PMT offset)
+  Float_t fPedestalRms;  // root mean square / sigma  / standard deviation of pedestal
+  Float_t fPedestalABoffset; // the difference between odd slice pedestal mean and the 
+                             // total pedestal mean (fPedestal). For even slices pedestal
+                             // use -fPedestalABoffset.
+  UInt_t fNumEvents; // number of times, the Process was executed (to estimate the error of pedestal)
+  Bool_t fValid;   // flag to set pixel valid
+  
+public:
+  MPedestalPix();
+  
+  void Clear(Option_t *o="");
+  
+  // Using histograms
+  void InitUseHists();
+  
+    // Setters
+  void SetPedestal(const Float_t f)         { fPedestal = f; }
+  void SetPedestalRms(const Float_t f)      { fPedestalRms = f; }
+  void SetPedestalABoffset(const Float_t f) { fPedestalABoffset = f; }
+  void SetNumEvents(const UInt_t n)         { fNumEvents = n; }
+
+  void Set(const Float_t m, const Float_t r, const Float_t offs=0, const UInt_t n=0);
+  void SetValid(const Bool_t b=kTRUE)    { fValid = b;  }
+  
+  // Getters
+  Float_t GetPedestal()    const { return fPedestal; }
+  Float_t GetPedestalRms() const { return fPedestalRms; }
+  Float_t GetPedestalABoffset() const { return fPedestalABoffset; }
+  Float_t GetPedestalError()    const { return fNumEvents>0 ? fPedestalRms/TMath::Sqrt((Float_t)fNumEvents)   : 0; }
+  Float_t GetPedestalRmsError() const { return fNumEvents>0 ? fPedestalRms/TMath::Sqrt((Float_t)fNumEvents/2) : 0; }
+  
+  Bool_t IsValid()         const;
+
+  ClassDef(MPedestalPix, 2)	// Storage Container for Pedestal information of one pixel
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mpedestal/Makefile
===================================================================
--- /tags/Mars_V0-8-5/Mars/mpedestal/Makefile	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mpedestal/Makefile	(revision 9661)
@@ -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  = Pedestal
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES = -I. -I../mbase -I../mgui -I../mraw -I../mmc -I../mgeom \
+           -I../msignal -I../manalysis -I../mbadpixels
+# MCamEvent
+# MMcPedestalCopy   (MRawRunHeader)
+# MMcPedestalCopy   (MMcRunHeader)
+# MMcPedestalNSBAdd (MGeomCam)
+# MPedCalcPedRun    (MExtractedSignal)
+# MPedPhotCalc      (MCerPhotEvt)
+# MPedPhotCalc      (MBadPixelsCam)
+
+SRCFILES = MMcPedestalCopy.cc \
+           MMcPedestalNSBAdd.cc \
+           MPedCalcPedRun.cc \
+	   MPedCalcFromLoGain.cc \
+           MPedPhotCalc.cc \
+           MPedPhotCam.cc \
+           MPedPhotPix.cc \
+           MPedestalCam.cc \
+	   MPedestalPix.cc \
+	   MPedCalcFromData.cc
+
+############################################################
+
+all: $(OBJS)
+
+include ../Makefile.rules
+
+clean:	rmcint rmobjs rmcore rmlib
+
+mrproper:	clean rmbak
Index: /tags/Mars_V0-8-5/Mars/mpedestal/PedestalIncl.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mpedestal/PedestalIncl.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mpedestal/PedestalIncl.h	(revision 9661)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-8-5/Mars/mpedestal/PedestalLinkDef.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mpedestal/PedestalLinkDef.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mpedestal/PedestalLinkDef.h	(revision 9661)
@@ -0,0 +1,20 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class MMcPedestalCopy++;
+#pragma link C++ class MMcPedestalNSBAdd++;
+
+#pragma link C++ class MPedPhotCalc++;
+#pragma link C++ class MPedPhotCam++;
+#pragma link C++ class MPedPhotPix++;
+
+#pragma link C++ class MPedCalcPedRun++;
+#pragma link C++ class MPedCalcFromLoGain++;
+#pragma link C++ class MPedestalCam++;
+#pragma link C++ class MPedestalPix++;
+#pragma link C++ class MPedCalcFromData++;
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mpointing/MPointingPos.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mpointing/MPointingPos.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mpointing/MPointingPos.cc	(revision 9661)
@@ -0,0 +1,76 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MPointingPos
+//
+// In this container we store the corrected pointing position of the
+// telscope. The pointing coordinates are read into MReportDrive together
+// with its time.
+//
+// MPointingPosCalc afterwards calculates corrections and checks for the
+// cosistency of the coordinates. The result (the real coordinates)
+// are stored in this container. No further correction should be necessary
+// using MPointingPos.
+//
+// If you need the rotation angle of the starfield in the camera you can
+// get it from here.
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MPointingPos.h"
+
+#include "MTime.h"
+#include "MObservatory.h"
+#include "MAstroSky2Local.h"
+
+ClassImp(MPointingPos);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Get the corresponding rotation angle of the sky coordinate system
+// seen with an Alt/Az telescope calculated from the stored local
+// (Zd/Az) coordinates.
+//
+// For more information see MAstro::RotationAngle
+//
+Double_t MPointingPos::RotationAngle(const MObservatory &o) const
+{
+    return o.RotationAngle(fZd*TMath::DegToRad(), fAz*TMath::DegToRad());
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the corresponding rotation angle of the sky coordinate system
+// seen with an Alt/Az telescope calculated from the stored sky
+// (Ra/Dec) coordinates.
+//
+// For more information see MAstro::RotationAngle
+//
+Double_t MPointingPos::RotationAngle(const MObservatory &o, const MTime &t) const
+{
+    return MAstroSky2Local(t, o).RotationAngle(GetRaRad(), GetDecRad());
+}
Index: /tags/Mars_V0-8-5/Mars/mpointing/MPointingPos.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mpointing/MPointingPos.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mpointing/MPointingPos.h	(revision 9661)
@@ -0,0 +1,50 @@
+#ifndef MARS_MPointingPos
+#define MARS_MPointingPos
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MTime;
+class MObservatory;
+
+class MPointingPos : public MParContainer
+{
+private:
+    Double_t fZd;  // [deg] Zenith distance (ZA)
+    Double_t fAz;  // [deg] Azimuth
+
+    Double_t fRa;  // [h]   Right ascension
+    Double_t fHa;  // [h]   Hour angle
+    Double_t fDec; // [deg] Declination
+
+public:
+    MPointingPos(const char *name=0, const char *title=0)
+    {
+        fName  = name ? name   : "MPointingPos";
+        fTitle = title ? title : "Container storing the (corrected) telescope pointing position";
+    }
+
+    void SetLocalPosition(Double_t zd, Double_t az) { fZd=zd; fAz=az; }
+    void SetSkyPosition(Double_t ra, Double_t dec, Double_t ha=0) { fRa=ra; fDec=dec; fHa=ha; }
+
+    Double_t GetZd() const  { return fZd; }
+    Double_t GetAz() const  { return fAz; }
+
+    Double_t GetRa() const  { return fRa; }
+    Double_t GetDec() const { return fDec; }
+
+    Double_t GetRaRad() const  { return fRa*TMath::DegToRad()*15; }
+    Double_t GetDecRad() const { return fDec*TMath::DegToRad(); }
+
+    Double_t RotationAngle(const MObservatory &o) const;
+    Double_t RotationAngle(const MObservatory &o, const MTime &t) const;
+    Double_t RotationAngle(const MObservatory &o, const MTime *t) const
+    {
+        return t ? RotationAngle(o, *t) : RotationAngle(o);
+    }
+
+    ClassDef(MPointingPos, 1) //Container storing the (corrected) telescope pointing position
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mpointing/MPointingPosCalc.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mpointing/MPointingPosCalc.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mpointing/MPointingPosCalc.cc	(revision 9661)
@@ -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): Thomas Bretz, 11/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MPointingPosCalc
+//
+// Currently:
+//
+//  * MC files:  Copy the simulated telescope position (Telescope Theta,
+//               Telescope Phi in MMcEvt) to MPointingPosition
+//
+//  * Real Data: Copy the nominal poiting position (Nominal Zd, Nominal Az
+//               in MReportDrive) to MPointingPosition
+//
+// Future: Interpolate the pointing position for each event between two
+//         consecutive drive reports.
+//
+// Input Container:
+//   MRawRunHeader
+//   [MMcEvt, MReportDrive]
+//
+// Output Container:
+//   MPointingPosition
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MPointingPosCalc.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MPointingPos.h"
+#include "MRawRunHeader.h"
+#include "MReportDrive.h"
+#include "MMcEvt.hxx"
+
+ClassImp(MPointingPosCalc);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Search for MRawRunHeader. Get the run type from there. Depending on
+// the run type search either for MMcEvt or MReportDrive.
+//
+Bool_t MPointingPosCalc::ReInit(MParList *plist)
+{
+    MRawRunHeader *run = (MRawRunHeader*)plist->FindObject("MRawRunHeader");
+    if (!run)
+    {
+        *fLog << err << "MRawRunHeader not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fRunType = run->GetRunType();
+
+    switch (fRunType)
+    {
+    case MRawRunHeader::kRTData:
+        fReport = (MReportDrive*)plist->FindObject("MReportDrive");
+        if (!fReport)
+        {
+            *fLog << err << "MReportDrive not found... aborting." << endl;
+            return kFALSE;
+        }
+        return kTRUE;
+
+    case MRawRunHeader::kRTMonteCarlo:
+        fMcEvt = (MMcEvt*)plist->FindObject("MMcEvt");
+        if (!fMcEvt)
+        {
+            *fLog << err << "MMcEvt not found... aborting." << endl;
+            return kFALSE;
+        }
+        return kTRUE;
+
+    case MRawRunHeader::kRTPedestal:
+        *fLog << err << "Cannot work in a pedestal Run!... aborting." << endl;
+        return kFALSE;
+
+    case MRawRunHeader::kRTCalibration:
+        *fLog << err << "Cannot work in a calibration Run!... aborting." << endl;
+        return kFALSE;
+
+    default:
+        *fLog << err << "Run Type " << fRunType << " unknown!... aborting." << endl;
+        return kFALSE;
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Search for 'MPointingPos'. Create if not found.
+//
+Int_t MPointingPosCalc::PreProcess(MParList *plist)
+{
+    fPosition = (MPointingPos*)plist->FindCreateObj("MPointingPos");
+    return fPosition ? kTRUE : kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  See class description.
+//
+Int_t MPointingPosCalc::Process()
+{
+    switch (fRunType)
+    {
+    case MRawRunHeader::kRTData:
+        fPosition->SetLocalPosition(fReport->GetNominalZd(), fReport->GetNominalAz());
+        fPosition->SetSkyPosition(fReport->GetRa()*TMath::DegToRad()/15, fReport->GetDec()*TMath::DegToRad());
+        return kTRUE;
+
+    case MRawRunHeader::kRTMonteCarlo:
+        fPosition->SetLocalPosition(fMcEvt->GetTelescopeTheta()*TMath::RadToDeg(), fMcEvt->GetTelescopePhi()*TMath::RadToDeg());
+        return kTRUE;
+    }
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mpointing/MPointingPosCalc.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mpointing/MPointingPosCalc.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mpointing/MPointingPosCalc.h	(revision 9661)
@@ -0,0 +1,35 @@
+#ifndef MARS_MPointingPositionCalc
+#define MARS_MPointingPositionCalc
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MMcEvt;
+class MReportDrive;
+class MPointingPos;
+
+class MPointingPosCalc : public MTask
+{
+private:
+    MMcEvt       *fMcEvt;    //! MMcEvt to get simulated poiting position from
+    MReportDrive *fReport;   //! MReportDrive to get real poiting position from
+    MPointingPos *fPosition; //! Output container to store pointing position
+
+    UShort_t fRunType;            //! Run Type to decide where to get pointing position from
+
+    Bool_t ReInit(MParList *plist);
+    Int_t  PreProcess(MParList *plist);
+    Int_t  Process();
+
+public:
+    MPointingPosCalc()
+    {
+        fName  = "MPointingPosCalc";
+        fTitle = "Task calculating the pointing position";
+    }
+
+    ClassDef(MPointingPosCalc, 0) //Task calculating the pointing position
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mpointing/MSrcPosCalc.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mpointing/MSrcPosCalc.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mpointing/MSrcPosCalc.cc	(revision 9661)
@@ -0,0 +1,192 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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 3/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// MSrcPosCalc
+//
+// Calculate the current source position in the camera from the (already
+// corrected) local pointing position of the telescope (MPointingPos) by
+// derotating the position (given in x and y coordinates in the camera
+// plane) at culmination time by the current rotation angle of the
+// starfield dtermined from MObservatory and MPointingPos
+//
+// The conversion factor between the camera plain (mm) and the
+// sky (deg) is taken from MGeomCam.
+//
+// Input Container:
+//   MPointingPos
+//   MObservatory
+//   MGeomCam
+//
+// Output Container:
+//   MSrcPosCam
+//
+// To be done:
+//   - wobble mode missing
+//   - a switch between using sky-coordinates and time or local-coordinates
+//     from MPointingPos for determin the rotation angle
+//   - the center of rotation need not to be the camera center
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MSrcPosCalc.h"
+
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MRawRunHeader.h"
+#include "MObservatory.h"
+#include "MSrcPosCam.h"
+#include "MAstroSky2Local.h"
+#include "MPointingPos.h"
+#include "MGeomCam.h"
+
+ClassImp(MSrcPosCalc);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Initialize fY and fY with 0
+//
+MSrcPosCalc::MSrcPosCalc(const char *name, const char *title)
+    : fX(0), fY(0)
+{
+    fName  = name  ? name  : "MSrcPosCalc";
+    fTitle = title ? title : "Derotates the source position in the camera";
+}
+
+// --------------------------------------------------------------------------
+//
+// Search and if necessary create MSrcPosCam in the parameter list
+//
+Int_t MSrcPosCalc::PreProcess(MParList *pList)
+{
+    fGeom = (MGeomCam*)pList->FindObject("MGeomCam");
+    if (!fGeom)
+    {
+        *fLog << err << "MGeomCam not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fPointPos = (MPointingPos*)pList->FindObject("MPointingPos");
+    if (!fPointPos)
+    {
+        *fLog << err << "MPointPos not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fObservatory = (MObservatory*)pList->FindObject("MObservatory");
+    if (!fObservatory)
+    {
+        *fLog << err << "MObservatory not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fTime = (MTime*)pList->FindObject("MTime");
+    if (!fTime)
+    {
+        *fLog << err << "MTime not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fSrcPos = (MSrcPosCam*)pList->FindCreateObj("MSrcPosCam");
+    if (!fSrcPos)
+        return kFALSE;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Search the parameter list for MObservatory and MTime
+//
+Bool_t MSrcPosCalc::ReInit(MParList *pList)
+{
+    if (fX!=0 || fY!=0)
+        return kTRUE;
+
+    *fLog << warn << "fX==0 && fY==0: Using arbitrary source position!" << endl;
+
+    //
+    // This is a workaround for current crab misspointing - DO NOT USE!
+    // It will be removed soon!
+    //
+    const MRawRunHeader *h = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
+    if (!h)
+    {
+        *fLog << err << "MRawRunHeader not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    const MTime &t = h->GetRunStart();
+
+    const Double_t rho = fPointPos->RotationAngle(*fObservatory, t);
+
+    // Calculate x, y of Zeta Tauri
+
+    Double_t tm = t.GetAxisTime();
+
+    Double_t x = 1.7267e6-6.03285e-3*tm; // [mm]
+    Double_t y = -189.823+974.908*exp(-52.3083*(tm*1e-5-2861.5)); // [mm]
+
+    const Double_t cs = TMath::Cos(rho-fDrho);
+    const Double_t sn = TMath::Sin(rho-fDrho);
+
+    const Double_t dx = fR*cs;
+    const Double_t dy = fR*sn;
+
+    fSrcPos->SetXY(x-dx, y-dy);
+
+    *fLog << dbg << t << " - Position: x=" << x-dx << "mm y=" << y-dy << "mm" << endl;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Derotate fX/fY by the current rotation angle, set MSrcPosCam
+//
+Int_t MSrcPosCalc::Process()
+{
+    if (fX==0 && fY==0)
+        return kTRUE;
+
+    // rotate the source position by the current rotation angle
+    const Double_t rho = fPointPos->RotationAngle(*fObservatory, *fTime);
+
+    // Define source position in the camera plain
+    TVector2 v(fX, fY);
+    v=v.Rotate(rho);
+
+    // Convert coordinates into camera plain (mm)
+    v *= 1./fGeom->GetConvMm2Deg();
+
+    // Set current source position
+    fSrcPos->SetXY(v);
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mpointing/MSrcPosCalc.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mpointing/MSrcPosCalc.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mpointing/MSrcPosCalc.h	(revision 9661)
@@ -0,0 +1,47 @@
+#ifndef MARS_MSrcPosCalc
+#define MARS_MSrcPosCalc
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MObservatory;
+class MPointingPos;
+class MSrcPosCam;
+class MGeomCam;
+class MTime;
+
+class MSrcPosCalc : public MTask
+{
+private:
+    MObservatory *fObservatory;
+    MPointingPos *fPointPos;
+    MSrcPosCam   *fSrcPos;
+    MGeomCam     *fGeom;
+    MTime        *fTime;
+
+    Double_t fR;    // Distance of source to a fitted star
+    Double_t fDrho; // angle between the two stars
+
+    Double_t fX;    // [deg] x-position of source
+    Double_t fY;    // [deg] y-position of source
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Bool_t ReInit(MParList *pList);
+
+public:
+    MSrcPosCalc(const char *name=NULL, const char *title=NULL);
+
+    // Use is deprecated!
+    void SetOffset(Double_t r, Double_t drho)
+    {
+        fDrho = drho*TMath::DegToRad();
+        fR    = r;
+    }
+    void SetPositionXY(Double_t x, Double_t y) { fX=x; fY=y; }
+
+    ClassDef(MSrcPosCalc, 0) // Derotates the source position in the camera
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mpointing/MSrcPosCam.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mpointing/MSrcPosCam.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mpointing/MSrcPosCam.cc	(revision 9661)
@@ -0,0 +1,120 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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>
+
+#include <TVector2.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MSrcPosCam);
+
+using namespace std;
+
+static const TString gsDefName  = "MSrcPosCam";
+static const TString gsDefTitle = "Virtual source position in the camera";
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MSrcPosCam::MSrcPosCam(const char *name, const char *title) : fX(0), fY(0)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+}
+
+// -----------------------------------------------------------------------
+//
+void MSrcPosCam::Print(Option_t *) const
+{
+    *fLog << all;
+    *fLog << "Source position in the camera plain (" << GetName() << ")" << endl;
+    *fLog << " - x [mm] = " << fX << endl;
+    *fLog << " - y [mm] = " << fY << endl;
+}
+
+void MSrcPosCam::SetXY(const TVector2 &v)
+{
+    fX = v.X();
+    fY = v.Y();
+}
+
+TVector2 MSrcPosCam::GetXY() const
+{
+    return TVector2(fX, fY);
+}
+
+/*
+// -----------------------------------------------------------------------
+//
+// overloaded MParContainer to read MSrcPosCam from an ascii file
+//
+void MSrcPosCam::AsciiRead(ifstream &fin)
+{
+    fin >> fX;
+    fin >> fY;
+}
+
+// -----------------------------------------------------------------------
+//
+// overloaded MParContainer to write MSrcPosCam to an ascii file
+//
+void MSrcPosCam::AsciiWrite(ofstream &fout) const
+{
+    fout << fX << " " << fY;
+}
+*/
+
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
+void MSrcPosCam::StreamPrimitive(ofstream &out) const
+{
+    out << "   MSrcPosCam " << GetUniqueName();
+    if (fName!=gsDefName)
+    {
+        out << "(\"" << fName << "\"";
+        if (fTitle!=gsDefTitle)
+            out << ", \"" << fTitle << "\"";
+        out <<")";
+    }
+    out << ";" << endl;
+
+    out << "   " << GetUniqueName() << ".SetXY(" << fX << ", " << fY << ");" << endl;}
Index: /tags/Mars_V0-8-5/Mars/mpointing/MSrcPosCam.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mpointing/MSrcPosCam.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mpointing/MSrcPosCam.h	(revision 9661)
@@ -0,0 +1,40 @@
+#ifndef MARS_MSrcPosCam
+#define MARS_MSrcPosCam
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class TVector2;
+
+class MSrcPosCam : public MParContainer
+{
+private:
+    Float_t fX; // [mm] x position of source in camera
+    Float_t fY; // [mm] y position of source in camera
+
+    void StreamPrimitive(ofstream &out) const;
+
+public:
+    MSrcPosCam(const char *name=NULL, const char *title=NULL);
+
+    void Clear(Option_t *)           { fX = 0; fY = 0; }
+
+    void SetX(Float_t x)             { fX = x; }
+    void SetY(Float_t y)             { fY = y; }
+    void SetXY(Float_t x, Float_t y) { fX = x; fY = y; }
+    void SetXY(const TVector2 &v);
+
+    Float_t GetX() const             { return fX; }
+    Float_t GetY() const             { return fY; }
+    TVector2 GetXY() const;
+
+    void Print(Option_t *opt=NULL) const;
+
+    //void AsciiRead(ifstream &fin);
+    //void AsciiWrite(ofstream &fout) const;
+
+    ClassDef(MSrcPosCam, 1) // container to store source position in the camera plain
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mpointing/Makefile
===================================================================
--- /tags/Mars_V0-8-5/Mars/mpointing/Makefile	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mpointing/Makefile	(revision 9661)
@@ -0,0 +1,35 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#------------------------------------------------------------------------------
+
+#
+# Handling name of the Root Dictionary Files
+#
+CINT = Pointing
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES = -I. -I../mbase -I../mraw -I../mreport -I../mmc \
+           -I../mastro -I../mgeom
+
+SRCFILES = MPointingPos.cc \
+	   MPointingPosCalc.cc \
+           MSrcPosCam.cc \
+           MSrcPosCalc.cc
+
+############################################################
+
+all: $(OBJS)
+
+include ../Makefile.rules
+
+mrproper:	clean rmbak
Index: /tags/Mars_V0-8-5/Mars/mpointing/PointingIncl.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mpointing/PointingIncl.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mpointing/PointingIncl.h	(revision 9661)
@@ -0,0 +1,5 @@
+#ifndef __CINT__
+
+#include <TVector2.h>
+
+#endif // __CINT__
Index: /tags/Mars_V0-8-5/Mars/mpointing/PointingLinkDef.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mpointing/PointingLinkDef.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mpointing/PointingLinkDef.h	(revision 9661)
@@ -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 MPointingPos+;
+#pragma link C++ class MPointingPosCalc+;
+
+#pragma link C++ class MSrcPosCalc+;
+#pragma link C++ class MSrcPosCam+;
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mranforest/MHRanForest.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mranforest/MHRanForest.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mranforest/MHRanForest.cc	(revision 9661)
@@ -0,0 +1,194 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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 Hengstebeck 3/2003 <mailto:hengsteb@alwa02.physik.uni-siegen.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHRanForest
+//
+// This histogram shows the evolution of the standard deviation 
+// of est. hadronness as the number of trees increases. 
+// It helps you to find out how many trees are really needed in g/h-sep.
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MHRanForest.h"
+
+#include <TPad.h>
+#include <TGraph.h>
+#include <TStyle.h>
+#include <TCanvas.h>
+#include <TMarker.h>
+
+#include "MParList.h"
+#include "MBinning.h"
+#include "MRanForest.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MMcEvt.hxx"
+
+ClassImp(MHRanForest);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Setup histograms, nbins is the number of bins used for the evaluation.
+// The default is 100 bins.
+//
+MHRanForest::MHRanForest(Int_t nbins, const char *name, const char *title)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHRanForest";
+    fTitle = title ? title : "Histogram showing Standard deviation of estimated hadronness";
+
+    fGraphSigma = new TGraph;
+    fGraphSigma->SetTitle("Evolution of Standard deviation of estimated hadronness in tree combination");
+    fGraphSigma->SetMarkerStyle(kFullDotSmall);
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the histograms.
+//
+MHRanForest::~MHRanForest()
+{
+    delete fGraphSigma;
+}
+
+// --------------------------------------------------------------------------
+//
+// Setup Filling of the histograms. It needs:
+//  MMcEvt and MRanForest
+//
+Bool_t MHRanForest::SetupFill(const MParList *plist)
+{
+    fMcEvt = (MMcEvt*)plist->FindObject(AddSerialNumber("MMcEvt"));
+    if (!fMcEvt)
+    {
+        *fLog << err << AddSerialNumber("MMcEvt") << " not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fRanForest = (MRanForest*)plist->FindObject("MRanForest");
+    if (!fRanForest)
+    {
+        *fLog << err << "MRanForest not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fSigma.Set(fRanForest->GetNumTrees());
+    fNumEvent=0;
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//
+Bool_t MHRanForest::Fill(const MParContainer *par, const Stat_t w)
+{
+    fNumEvent++;
+
+    Double_t hest=0;
+    Double_t htrue=fMcEvt->GetPartId()==MMcEvt::kGAMMA ? 0. : 1.;
+
+    Int_t ntrees=fRanForest->GetNumTrees();
+
+    for (Int_t i=0;i<ntrees;i++)
+    {
+        for(Int_t j=0;j<=i;j++)
+            hest+=fRanForest->GetTreeHad(j);
+
+        hest/=i+1;
+
+        const Double_t val = htrue-hest;
+        fSigma[i] += val*val;
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Finalize the histogram:
+// calculate standard deviation and set histogram max and min
+//
+Bool_t MHRanForest::Finalize()
+{
+    Int_t n = fSigma.GetSize();
+
+    fGraphSigma->Set(n);
+
+    Stat_t max=0.;
+    Stat_t min=0.;
+    for (Int_t i=0; i<n; i++)
+    {
+	fSigma[i] = TMath::Sqrt(fSigma[i]/fNumEvent);
+
+        const Stat_t ig = fSigma[i];
+        if (ig>max) max = ig;
+        if (ig<min) min = ig;
+        fGraphSigma->SetPoint(i, i+1, ig);
+    }
+
+    // This is used in root>3.04/? so that SetMaximum/Minimum can succeed
+    fGraphSigma->GetHistogram();
+
+    fGraphSigma->SetMaximum(1.05*max);
+    fGraphSigma->SetMinimum(0.95*min);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw histogram. (For the Meaning see class description)
+//
+void MHRanForest::Draw(Option_t *)
+{
+   if (fGraphSigma->GetN()==0)
+        return;
+
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    AppendPad("");
+
+    fGraphSigma->Draw("ALP");
+    pad->Modified();
+    pad->Update();
+
+    TH1 *h=fGraphSigma->GetHistogram();
+    if (!h)
+        return;
+
+    //h->GetXaxis()->SetRangeUser(0, fNumEvent+1);
+    h->SetXTitle("No.of Trees");
+    h->SetYTitle("\\sigma of est.hadronness");
+
+    pad->Modified();
+    pad->Update();
+}
Index: /tags/Mars_V0-8-5/Mars/mranforest/MHRanForest.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mranforest/MHRanForest.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mranforest/MHRanForest.h	(revision 9661)
@@ -0,0 +1,43 @@
+#ifndef MARS_MHRanForest
+#define MARS_MHRanForest
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+#ifndef ROOT_TArrayF
+#include <TArrayF.h>
+#endif
+
+class TH1D;
+class TGraph;
+class MParList;
+class MMcEvt;
+class MRanForest;
+
+class MHRanForest : public MH
+{
+private:
+    const MMcEvt *fMcEvt;           //!
+    const MRanForest *fRanForest;   //!
+
+    TArrayF fSigma;                 //!
+    Int_t fNumEvent;                //!
+    TGraph *fGraphSigma;            //->
+
+public:
+    MHRanForest(Int_t nbins=100, const char *name=NULL, const char *title=NULL);
+    ~MHRanForest();
+
+    TGraph *GetGraphSigma() const  { return fGraphSigma; }
+
+    Bool_t SetupFill(const MParList *plist);
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+    Bool_t Finalize();
+
+    void Draw(Option_t *opt="");
+
+    ClassDef(MHRanForest, 1) // Histogram showing variance of estimated Hadronness
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mranforest/MHRanForestGini.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mranforest/MHRanForestGini.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mranforest/MHRanForestGini.cc	(revision 9661)
@@ -0,0 +1,174 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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 Hengstebeck 3/2003 <mailto:hengsteb@alwa02.physik.uni-siegen.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHRanForest
+//
+// This histogram shows a measure of variable importance (mean decrease in
+// Gini-index)
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MHRanForestGini.h"
+
+#include <TPad.h>
+#include <TGraph.h>
+#include <TStyle.h>
+#include <TCanvas.h>
+#include <TMarker.h>
+
+#include "MParList.h"
+#include "MBinning.h"
+#include "MRanTree.h"
+#include "MRanForest.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MHRanForestGini);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Setup histograms, nbins is the number of bins used for the evaluation.
+// The default is 100 bins.
+//
+MHRanForestGini::MHRanForestGini(Int_t nbins, const char *name, const char *title)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHRanForestGini";
+    fTitle = title ? title : "Measure of importance of Random Forest-input parameters";
+
+    fGraphGini = new TGraph;
+    fGraphGini->SetTitle("Importance of RF-input parameters measured by mean Gini decrease");
+    fGraphGini->SetMarkerStyle(kFullDotSmall);
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the histograms.
+//
+MHRanForestGini::~MHRanForestGini()
+{
+    delete fGraphGini;
+}
+
+// --------------------------------------------------------------------------
+//
+// Setup Filling of the histograms. It needs:
+//  MMcEvt and MRanForest
+//
+Bool_t MHRanForestGini::SetupFill(const MParList *plist)
+{
+    fRanForest = (MRanForest*)plist->FindObject("MRanForest");
+    if (!fRanForest)
+    {
+        *fLog << err << dbginf << "MRanForest not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fGini.Set(fRanForest->GetNumDim());
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the RanForest from a MRanForest container into the corresponding
+// histogram dependant on the particle id.
+//
+//
+Bool_t MHRanForestGini::Fill(const MParContainer *par, const Stat_t w)
+{
+    for (Int_t i=0;i<fRanForest->GetNumDim();i++)
+        fGini[i]+=fRanForest->GetCurTree()->GetGiniDec(i);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//
+Bool_t MHRanForestGini::Finalize()
+{
+    const Int_t n = fGini.GetSize();
+
+    fGraphGini->Set(n);
+
+    Stat_t max=0;
+    Stat_t min=0;
+    for (Int_t i=0; i<n; i++)
+    {
+        fGini[i] /= fRanForest->GetNumTrees();
+        fGini[i] /= fRanForest->GetNumData();
+
+        const Stat_t ip = i+1;
+        const Stat_t ig = fGini[i];
+
+        if (ig>max) max=ig;
+        if (ig<min) min=ig;
+
+        fGraphGini->SetPoint(i,ip,ig);
+    }
+
+    // This is used in root>3.04/? so that SetMaximum/Minimum can succeed
+    fGraphGini->GetHistogram();
+
+    fGraphGini->SetMaximum(1.05*max);
+    fGraphGini->SetMinimum(0.95*min);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Draw histogram. (For the Meaning see class description)
+//
+void MHRanForestGini::Draw(Option_t *)
+{
+    if (fGraphGini->GetN()==0)
+        return;
+
+    TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
+    pad->SetBorderMode(0);
+
+    AppendPad("");
+
+    fGraphGini->Draw("ALP");
+    pad->Modified();
+    pad->Update();
+
+    TH1 *h = fGraphGini->GetHistogram();
+    if (!h)
+        return;
+
+    //h->GetXaxis()->SetRangeUser(0, fGini.GetSize()+1);
+    h->SetXTitle("No.of RF-input parameter");
+    h->SetYTitle("Mean decrease in Gini-index [a.u.]");
+
+    pad->Modified();
+    pad->Update();
+}
Index: /tags/Mars_V0-8-5/Mars/mranforest/MHRanForestGini.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mranforest/MHRanForestGini.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mranforest/MHRanForestGini.h	(revision 9661)
@@ -0,0 +1,41 @@
+#ifndef MARS_MHRanForestGini
+#define MARS_MHRanForestGini
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+#ifndef ROOT_TArrayF
+#include <TArrayF.h>
+#endif
+
+class TH1D;
+class TGraph;
+class MParList;
+class MRanForest;
+class MRanTree;
+
+class MHRanForestGini : public MH
+{
+private:
+    MRanForest *fRanForest;  //!
+
+    TArrayF fGini;           //!
+    TGraph *fGraphGini;      //->
+
+public:
+    MHRanForestGini(Int_t nbins=100, const char *name=NULL, const char *title=NULL);
+    ~MHRanForestGini();
+
+    TGraph *GetGraphGini() const  { return fGraphGini; }
+
+    Bool_t SetupFill(const MParList *plist);
+    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+    Bool_t Finalize();
+
+    void Draw(Option_t *opt="");
+
+    ClassDef(MHRanForestGini, 1)
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mranforest/MRanForest.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mranforest/MRanForest.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mranforest/MRanForest.cc	(revision 9661)
@@ -0,0 +1,438 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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 Hengstebeck 3/2003 <mailto:hengsteb@alwa02.physik.uni-siegen.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MRanForest                                                              //
+//                                                                         //
+// ParameterContainer for Forest structure                                 //
+//                                                                         //
+// A random forest can be grown by calling GrowForest.                     //
+// In advance SetupGrow must be called in order to initialize arrays and   //
+// do some preprocessing.                                                  //
+// GrowForest() provides the training data for a single tree (bootstrap    //
+// aggregate procedure)                                                    //
+//                                                                         //
+// Essentially two random elements serve to provide a "random" forest,     //
+// namely bootstrap aggregating (which is done in GrowForest()) and random //
+// split selection (which is subject to MRanTree::GrowTree())              //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MRanForest.h"
+
+#include <TMatrix.h>
+#include <TRandom3.h>
+
+#include "MHMatrix.h"
+#include "MRanTree.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MRanForest);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MRanForest::MRanForest(const char *name, const char *title) : fNumTrees(100), fRanTree(NULL),fUsePriors(kFALSE)
+{
+    fName  = name  ? name  : "MRanForest";
+    fTitle = title ? title : "Storage container for Random Forest";
+
+    fForest=new TObjArray();
+    fForest->SetOwner(kTRUE);
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor. 
+//
+MRanForest::~MRanForest()
+{
+    delete fForest;
+}
+
+void MRanForest::SetNumTrees(Int_t n)
+{
+    //at least 1 tree
+    fNumTrees=TMath::Max(n,1);
+    fTreeHad.Set(fNumTrees);
+    fTreeHad.Reset();
+}
+
+void MRanForest::SetPriors(Float_t prior_had, Float_t prior_gam)
+{
+    const Float_t sum=prior_gam+prior_had;
+
+    prior_gam/=sum;
+    prior_had/=sum;
+
+    fPrior[0]=prior_had;
+    fPrior[1]=prior_gam;
+
+    fUsePriors=kTRUE;
+}
+
+Int_t MRanForest::GetNumDim() const
+{
+    return fGammas ? fGammas->GetM().GetNcols() : 0;
+}
+
+
+Double_t MRanForest::CalcHadroness(const TVector &event)
+{
+    Double_t hadroness=0;
+    Int_t ntree=0;
+
+    TIter Next(fForest);
+
+    MRanTree *tree;
+    while ((tree=(MRanTree*)Next()))
+    {
+        fTreeHad[ntree]=tree->TreeHad(event);
+        hadroness+=fTreeHad[ntree];
+        ntree++;
+    }
+    return hadroness/ntree;
+}
+
+Bool_t MRanForest::AddTree(MRanTree *rantree=NULL)
+{
+    if (rantree)
+        fRanTree=rantree;
+    if (!fRanTree)
+        return kFALSE;
+
+    fForest->Add((MRanTree*)fRanTree->Clone());
+
+    return kTRUE;
+}
+
+Int_t MRanForest::GetNumData() const
+{
+    return fHadrons && fGammas ? fHadrons->GetM().GetNrows()+fGammas->GetM().GetNrows() : 0;
+}
+
+Bool_t MRanForest::SetupGrow(MHMatrix *mhad,MHMatrix *mgam)
+{
+    // pointer to training data
+    fHadrons=mhad;
+    fGammas=mgam;
+
+    // determine data entries and dimension of Hillas-parameter space
+    //fNumHad=fHadrons->GetM().GetNrows();
+    //fNumGam=fGammas->GetM().GetNrows();
+
+    const Int_t dim = GetNumDim();
+
+    if (dim!=fGammas->GetM().GetNcols())
+        return kFALSE;
+
+    const Int_t numdata = GetNumData();
+
+    // allocating and initializing arrays
+    fHadTrue.Set(numdata);
+    fHadTrue.Reset();
+    fHadEst.Set(numdata);
+
+    fPrior.Set(2);
+    fClassPop.Set(2);
+    fWeight.Set(numdata);
+    fNTimesOutBag.Set(numdata);
+    fNTimesOutBag.Reset();
+
+    fDataSort.Set(dim*numdata);
+    fDataRang.Set(dim*numdata);
+
+    // calculating class populations (= no. of gammas and hadrons)
+    fClassPop.Reset();
+    for(Int_t n=0;n<numdata;n++)
+        fClassPop[fHadTrue[n]]++;
+
+    // setting weights taking into account priors
+    if (!fUsePriors)
+        fWeight.Reset(1.);
+    else
+    {
+        for(Int_t j=0;j<2;j++)
+            fPrior[j] *= (fClassPop[j]>=1) ? (Float_t)numdata/fClassPop[j]:0;
+
+        for(Int_t n=0;n<numdata;n++)
+            fWeight[n]=fPrior[fHadTrue[n]];
+    }
+
+    // create fDataSort
+    CreateDataSort();
+
+    if(!fRanTree)
+    {
+        *fLog << err << dbginf << "MRanForest, fRanTree not initialized... aborting." << endl;
+        return kFALSE;
+    }
+    fRanTree->SetRules(fGammas->GetColumns());
+    fTreeNo=0;
+
+    return kTRUE;
+}
+
+void MRanForest::InitHadEst(Int_t from, Int_t to, const TMatrix &m, TArrayI &jinbag)
+{
+    for (Int_t ievt=from;ievt<to;ievt++)
+    {
+        if (jinbag[ievt]>0)
+            continue;
+        fHadEst[ievt] += fRanTree->TreeHad(m, ievt-from);
+        fNTimesOutBag[ievt]++;
+    }
+}
+
+Bool_t MRanForest::GrowForest()
+{
+    if(!gRandom)
+    {
+        *fLog << err << dbginf << "gRandom not initialized... aborting." << endl;
+        return kFALSE;
+    }
+
+    fTreeNo++;
+
+    // initialize running output
+    if (fTreeNo==1)
+    {
+        *fLog << inf << endl;
+        *fLog << underline; // << "1st col        2nd col" << endl;
+        *fLog << "no. of tree    error in % (calulated using oob-data -> overestim. of error)" << endl;
+    }
+
+    const Int_t numdata = GetNumData();
+
+    // bootstrap aggregating (bagging) -> sampling with replacement:
+    //
+    // The integer k is randomly (uniformly) chosen from the set
+    // {0,1,...,fNumData-1}, which is the set of the index numbers of
+    // all events in the training sample
+    TArrayF classpopw(2);
+    TArrayI jinbag(numdata); // Initialization includes filling with 0
+    TArrayF winbag(numdata); // Initialization includes filling with 0
+
+    for (Int_t n=0; n<numdata; n++)
+    {
+        const Int_t k = Int_t(gRandom->Rndm()*numdata);
+
+        classpopw[fHadTrue[k]]+=fWeight[k];
+        winbag[k]+=fWeight[k];
+        jinbag[k]=1;
+    }
+
+    // modifying sorted-data array for in-bag data:
+    //
+    // In bagging procedure ca. 2/3 of all elements in the original
+    // training sample are used to build the in-bag data
+    TArrayI datsortinbag=fDataSort;
+    Int_t ninbag=0;
+
+    ModifyDataSort(datsortinbag, ninbag, jinbag);
+
+    const TMatrix &hadrons=fHadrons->GetM();
+    const TMatrix &gammas =fGammas->GetM();
+
+    // growing single tree
+    fRanTree->GrowTree(hadrons,gammas,fHadTrue,datsortinbag,
+                       fDataRang,classpopw,jinbag,winbag);
+
+    // error-estimates from out-of-bag data (oob data):
+    //
+    // For a single tree the events not(!) contained in the bootstrap sample of
+    // this tree can be used to obtain estimates for the classification error of
+    // this tree.
+    // If you take a certain event, it is contained in the oob-data of 1/3 of
+    // the trees (see comment to ModifyData). This means that the classification error
+    // determined from oob-data is underestimated, but can still be taken as upper limit.
+
+    const Int_t numhad = hadrons.GetNrows();
+    InitHadEst(0, numhad, hadrons, jinbag);
+    InitHadEst(numhad, numdata, gammas, jinbag);
+    /*
+    for (Int_t ievt=0;ievt<numhad;ievt++)
+    {
+        if (jinbag[ievt]>0)
+            continue;
+        fHadEst[ievt] += fRanTree->TreeHad(hadrons, ievt);
+        fNTimesOutBag[ievt]++;
+    }
+
+    for (Int_t ievt=numhad;ievt<numdata;ievt++)
+    {
+        if (jinbag[ievt]>0)
+            continue;
+        fHadEst[ievt] += fRanTree->TreeHad(gammas, ievt-numhad);
+        fNTimesOutBag[ievt]++;
+    }
+    */
+    Int_t n=0;
+    Double_t ferr=0;
+    for (Int_t ievt=0;ievt<numdata;ievt++)
+        if (fNTimesOutBag[ievt]!=0)
+        {
+            const Double_t val = fHadEst[ievt]/fNTimesOutBag[ievt]-fHadTrue[ievt];
+            ferr += val*val;
+            n++;
+        }
+
+    ferr = TMath::Sqrt(ferr/n);
+
+    // give running output
+    *fLog << inf << setw(5) << fTreeNo << Form("%15.2f", ferr*100) << endl;
+
+    // adding tree to forest
+    AddTree();
+
+    return fTreeNo<fNumTrees;
+}
+
+void MRanForest::CreateDataSort()
+{
+    // The values of concatenated data arrays fHadrons and fGammas (denoted in the following by fData,
+    // which does actually not exist) are sorted from lowest to highest.
+    //
+    //
+    //                   fHadrons(0,0) ... fHadrons(0,nhad-1)   fGammas(0,0) ... fGammas(0,ngam-1)
+    //                        .                 .                   .                .
+    //  fData(m,n)   =        .                 .                   .                .
+    //                        .                 .                   .                .
+    //                   fHadrons(m-1,0)...fHadrons(m-1,nhad-1) fGammas(m-1,0)...fGammas(m-1,ngam-1)
+    //
+    //
+    // Then fDataSort(m,n) is the event number in which fData(m,n) occurs.
+    // fDataRang(m,n) is the rang of fData(m,n), i.e. if rang = r, fData(m,n) is the r-th highest
+    // value of all fData(m,.). There may be more then 1 event with rang r (due to bagging).
+    const Int_t numdata = GetNumData();
+
+    TArrayF v(numdata);
+    TArrayI isort(numdata);
+
+    const TMatrix &hadrons=fHadrons->GetM();
+    const TMatrix &gammas=fGammas->GetM();
+
+    const Int_t numgam = gammas.GetNrows();
+    const Int_t numhad = hadrons.GetNrows();
+
+    for (Int_t j=0;j<numhad;j++)
+        fHadTrue[j]=1;
+
+    for (Int_t j=0;j<numgam;j++)
+        fHadTrue[j+numhad]=0;
+
+    const Int_t dim = GetNumDim();
+    for (Int_t mvar=0;mvar<dim;mvar++)
+    {
+        for(Int_t n=0;n<numhad;n++)
+        {
+            v[n]=hadrons(n,mvar);
+            isort[n]=n;
+        }
+
+        for(Int_t n=0;n<numgam;n++)
+        {
+            v[n+numhad]=gammas(n,mvar);
+            isort[n+numhad]=n;
+        }
+
+        TMath::Sort(numdata,v.GetArray(),isort.GetArray(),kFALSE);
+
+        // this sorts the v[n] in ascending order. isort[n] is the event number
+        // of that v[n], which is the n-th from the lowest (assume the original
+        // event numbers are 0,1,...).
+
+        for(Int_t n=0;n<numdata-1;n++)
+        {
+            const Int_t n1=isort[n];
+            const Int_t n2=isort[n+1];
+
+            fDataSort[mvar*numdata+n]=n1;
+            if(n==0) fDataRang[mvar*numdata+n1]=0;
+            if(v[n1]<v[n2])
+            {
+                fDataRang[mvar*numdata+n2]=fDataRang[mvar*numdata+n1]+1;
+            }else{
+                fDataRang[mvar*numdata+n2]=fDataRang[mvar*numdata+n1];
+            }
+        }
+        fDataSort[(mvar+1)*numdata-1]=isort[numdata-1];
+    }
+}
+
+void MRanForest::ModifyDataSort(TArrayI &datsortinbag, Int_t ninbag, const TArrayI &jinbag)
+{
+    const Int_t numdim=GetNumDim();
+    const Int_t numdata=GetNumData();
+
+    ninbag=0;
+    for (Int_t n=0;n<numdata;n++)
+        if(jinbag[n]==1) ninbag++;
+
+    for(Int_t m=0;m<numdim;m++)
+    {
+        Int_t k=0;
+        Int_t nt=0;
+        for(Int_t n=0;n<numdata;n++)
+        {
+            if(jinbag[datsortinbag[m*numdata+k]]==1)
+            {
+                datsortinbag[m*numdata+nt]=datsortinbag[m*numdata+k];
+                k++;
+            }else{
+                for(Int_t j=1;j<numdata-k;j++)
+                {
+                    if(jinbag[datsortinbag[m*numdata+k+j]]==1)
+                    {
+                        datsortinbag[m*numdata+nt]=datsortinbag[m*numdata+k+j];
+                        k+=j+1;
+                        break;
+                    }
+                }
+            }
+            nt++;
+            if(nt>=ninbag) break;
+        }
+    }
+}
+
+Bool_t MRanForest::AsciiWrite(ostream &out) const
+{
+    Int_t n=0;
+    MRanTree *tree;
+    TIter forest(fForest);
+
+    while ((tree=(MRanTree*)forest.Next()))
+    {
+        tree->AsciiWrite(out);
+        n++;
+    }
+
+    return n==fNumTrees;
+}
Index: /tags/Mars_V0-8-5/Mars/mranforest/MRanForest.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mranforest/MRanForest.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mranforest/MRanForest.h	(revision 9661)
@@ -0,0 +1,102 @@
+#ifndef MARS_MRanForest
+#define MARS_MRanForest
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#ifndef ROOT_TArrayI
+#include <TArrayI.h>
+#endif
+
+#ifndef ROOT_TArrayF
+#include <TArrayF.h>
+#endif
+
+#ifndef ROOT_TArrayD
+#include <TArrayD.h>
+#endif
+
+#ifndef ROOT_TObjArray
+#include <TObjArray.h>
+#endif
+
+#ifndef ROOT_TRandom
+#include <TRandom.h>
+#endif
+
+class MHMatrix;
+class MRanTree;
+class TVector;
+class TMatrix;
+
+class MRanForest : public MParContainer
+{
+private:
+    Int_t fNumTrees;
+    Int_t fTreeNo;
+
+    MRanTree *fRanTree;
+    TObjArray *fForest;
+
+    // training data
+    MHMatrix *fGammas;
+    MHMatrix *fHadrons;
+
+    // true  and estimated hadronness
+    TArrayI fHadTrue;
+    TArrayF fHadEst;
+
+    // data sorted according to parameters
+    TArrayI fDataSort;
+    TArrayI fDataRang;
+    TArrayI fClassPop;
+
+    // weights
+    Bool_t  fUsePriors;
+    TArrayF fPrior;
+    TArrayF fWeight;
+    TArrayI fNTimesOutBag;
+
+    // estimates for classification error of growing forest
+    TArrayD fTreeHad;
+
+    void InitHadEst(Int_t from, Int_t to, const TMatrix &m, TArrayI &jinbag);
+
+protected:
+    // create and modify (->due to bagging) fDataSort
+    void CreateDataSort();
+    void ModifyDataSort(TArrayI &datsortinbag, Int_t ninbag, const TArrayI &jinbag);
+
+public:
+    MRanForest(const char *name=NULL, const char *title=NULL);
+    ~MRanForest();
+
+    // initialize forest
+    void SetPriors(Float_t prior_had, Float_t prior_gam);
+    void SetNumTrees(Int_t n);
+
+    // tree growing
+    //void   SetupForest();
+    Bool_t SetupGrow(MHMatrix *mhad,MHMatrix *mgam);
+    Bool_t GrowForest();
+    void SetCurTree(MRanTree *rantree) { fRanTree=rantree; }
+    Bool_t AddTree(MRanTree *rantree);
+
+    // getter methods
+    TObjArray *GetForest() { return fForest; }
+    MRanTree *GetCurTree() { return fRanTree; }
+    Int_t      GetNumTrees() const { return fNumTrees; }
+    Int_t      GetNumData() const;
+    Int_t      GetNumDim() const;
+    Double_t   GetTreeHad(Int_t i) const { return fTreeHad.At(i); }
+ 
+    // use forest to calculate hadronness of event
+    Double_t CalcHadroness(const TVector &event);
+
+    Bool_t AsciiWrite(ostream &out) const;
+
+    ClassDef(MRanForest, 0) // Storage container for tree structure
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mranforest/MRanForestCalc.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mranforest/MRanForestCalc.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mranforest/MRanForestCalc.cc	(revision 9661)
@@ -0,0 +1,254 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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 Hengstebeck 3/2003 <mailto:hengsteb@alwa02.physik.uni-siegen.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MRanForestCalc
+//
+//  Calculates the hadroness of an event. It calculates a mean value of all
+//  classifications by the trees in a previously grown random forest.
+//
+//  To use only n trees for your calculation use:
+//  MRanForestCalc::SetUseNumTrees(n);
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MRanForestCalc.h"
+
+#include "MHMatrix.h" // must be before MLogManip.h
+#include "MDataArray.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MRanTree.h"
+#include "MRanForest.h"
+
+#include "MHadronness.h"
+
+#include "MEvtLoop.h"
+#include "MTaskList.h"
+#include "MFillH.h"
+#include "MStatusDisplay.h"
+#include "MRanForestGrow.h"
+#include "MRanForestFill.h"
+
+#include "MWriteRootFile.h"
+#include "MReadTree.h"
+
+ClassImp(MRanForestCalc);
+
+using namespace std;
+
+static const TString gsDefName  = "MRanForestCalc";
+static const TString gsDefTitle = "Tree Classification Loop 1/2";
+
+// --------------------------------------------------------------------------
+//
+// Setup histograms and the number of distances which are used for
+// avaraging in CalcDist
+//
+MRanForestCalc::MRanForestCalc(const char *name, const char *title)
+    : fNum(100), fHadronnessName("MHadronness"), fData(NULL)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the data chains
+//
+MRanForestCalc::~MRanForestCalc()
+{
+    //    delete fData;
+}
+
+// --------------------------------------------------------------------------
+//
+// Needs:
+//  - MatrixGammas  [MHMatrix]
+//  - MatrixHadrons [MHMatrix]
+//  - MHadronness
+//  - all data containers used to build the matrixes
+//
+// The matrix object can be filles using MFillH. And must be of the same
+// number of columns (with the same meaning).
+//
+Int_t MRanForestCalc::PreProcess(MParList *plist)
+{
+    fRanForest = (MRanForest*)plist->FindObject("MRanForest");
+    if (!fRanForest)
+    {
+        *fLog << err << dbginf << "MRanForest not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fRanTree = (MRanTree*)plist->FindObject("MRanTree");
+    if (!fRanTree)
+    {
+        *fLog << err << dbginf << "MRanTree not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    /*if(!fRanForest->GetCurTree())
+    {
+        *fLog << err << dbginf << "MRanForest does not contain trees... aborting." << endl;
+        return kFALSE;
+    }*/
+
+    fData = fRanTree->GetRules();
+
+    if (!fData)
+    {
+        *fLog << err << dbginf << "Error matrix doesn't contain columns... aborting." << endl;
+        return kFALSE;
+    }
+
+    if (!fData->PreProcess(plist))
+    {
+        *fLog << err << dbginf << "PreProcessing of the MDataArray failed for the columns failed... aborting." << endl;
+        return kFALSE;
+    }
+
+    fHadroness = (MHadronness*)plist->FindCreateObj("MHadronness", fHadronnessName);
+    if (!fHadroness)
+        return kFALSE;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//
+Int_t MRanForestCalc::Process()
+{
+    // first copy the data from the data array to a vector event
+    TVector event;
+    *fData >> event;
+
+    Double_t hadroness=fRanForest->CalcHadroness(event);
+    fHadroness->SetHadronness(hadroness);
+
+    return kTRUE;
+}
+
+Bool_t MRanForestCalc::Grow(MHMatrix *matrixg,MHMatrix *matrixh,Int_t ntree,
+                            Int_t numtry,Int_t ndsize,const char* treefile,
+                            const char* treename,const char* contname,
+                            const char* hgininame)
+{
+
+    treename  = treename  ? treename  : "Tree";
+    contname  = contname  ? contname  : "MRanTree";
+    hgininame  = hgininame  ? hgininame  : "MHRanForestGini";
+
+    if (!matrixg->IsValid())
+    {
+        *fLog << err << dbginf << " MRanForestCalc::Grow - ERROR: matrixg not valid." << endl;
+        return kFALSE;
+    }
+    if(!matrixh->IsValid())
+    {
+        *fLog << err << dbginf << " MRanForestCalc::Grow - ERROR: matrixh not valid." << endl;
+        return kFALSE;
+    }
+
+    MEvtLoop run(GetName());
+    MTaskList tlist;
+    MParList plist;
+    plist.AddToList(&tlist);
+    plist.AddToList(matrixg);
+    plist.AddToList(matrixh);
+
+    // creating training task and setting parameters
+    MRanForestGrow rfgrow;
+    rfgrow.SetNumTrees(ntree); // number of trees
+    rfgrow.SetNumTry(numtry);  // number of trials in random split selection
+    rfgrow.SetNdSize(ndsize);  // limit for nodesize
+    tlist.AddToList(&rfgrow);
+
+    if(treefile){
+        MWriteRootFile rfwrite(treefile);
+        rfwrite.AddContainer(contname,treename);
+        tlist.AddToList(&rfwrite);
+    }
+
+    MFillH fillh(hgininame);
+    tlist.AddToList(&fillh);
+
+    run.SetParList(&plist);
+    
+    // Execute tree growing
+    if (!run.Eventloop())
+    {
+        *fLog << err << dbginf << "Evtloop in MRanForestCalc::Grow failed." << endl;
+        return kFALSE;
+    }
+    tlist.PrintStatistics(0, kTRUE);
+
+    if (TestBit(kEnableGraphicalOutput))
+        plist.FindObject(hgininame)->DrawClone();
+
+    return kTRUE;
+}
+
+Bool_t MRanForestCalc::Fill(Int_t ntree,const char* treefile,const char* treename)
+{
+    treefile  = treefile  ? treefile  : "RF.root";
+    treename  = treename  ? treename  : "Tree";
+
+    MParList  plist;
+
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    MReadTree read(treename,treefile);
+    read.DisableAutoScheme();
+
+    MRanForestFill rffill;
+    rffill.SetNumTrees(ntree);
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&rffill);
+
+    MEvtLoop run(GetName());
+    run.SetParList(&plist);
+
+    //
+    // Execute tree reading
+    //
+    if (!run.Eventloop())
+    {
+        *fLog << err << dbginf << "Evtloop in MRanForestCalc::Fill failed." << endl;
+        return kFALSE;
+    }
+    tlist.PrintStatistics(0, kTRUE);
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mranforest/MRanForestCalc.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mranforest/MRanForestCalc.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mranforest/MRanForestCalc.h	(revision 9661)
@@ -0,0 +1,53 @@
+#ifndef MARS_MRanForestCalc
+#define MARS_MRanForestCalc
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+#ifndef MARS_MHMatrix
+#include "MHMatrix.h"
+#endif
+
+class MParList;
+class MHadronness;
+class MDataArray;
+class MRanTree;
+class MRanForest;
+
+class MRanForestCalc : public MTask
+{
+private:
+    Int_t  fNum;              // number of trees used to compute hadronness
+
+    TString fHadronnessName;  // Name of container storing hadronness
+
+    MHadronness *fHadroness;  //! Output container for calculated hadroness
+    MDataArray  *fData;       //! Used to store the MDataChains to get the event values
+    MRanForest  *fRanForest;
+    MRanTree    *fRanTree;
+
+    Int_t PreProcess(MParList *plist);
+    Int_t Process();
+
+public:
+    MRanForestCalc(const char *name=NULL, const char *title=NULL);
+    ~MRanForestCalc();
+
+    void SetHadronnessName(const TString name) { fHadronnessName = name; }
+    TString GetHadronnessName() const { return fHadronnessName; }
+
+    void SetUseNumTrees(UShort_t n=100) { fNum = n; }
+
+    Bool_t Grow(MHMatrix *matrixg,MHMatrix *matrixh,Int_t ntree,
+                Int_t numtry,Int_t ndsize,const char* treefile=0,
+                const char* treename=0,const char* contname=0,
+                const char* hgininame=0);
+
+    Bool_t Fill(Int_t ntree,const char* treefile=0,const char* treename=0);
+
+
+    ClassDef(MRanForestCalc, 0) // Task
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mranforest/MRanForestFill.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mranforest/MRanForestFill.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mranforest/MRanForestFill.cc	(revision 9661)
@@ -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 Hengstebeck 3/2003 <mailto:hengsteb@alwa02.physik.uni-siegen.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MRanForestFill
+//
+//  Calculates the hadroness of an event. It calculates a mean value of all
+//  classifications by the trees in a previously grown random forest.
+//
+//  To use only n trees for your calculation use:
+//  MRanForestFill::SetUseNumTrees(n);
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MRanForestFill.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MRanForest.h"
+
+ClassImp(MRanForestFill);
+
+using namespace std;
+
+static const TString gsDefName  = "MRanForestFill";
+static const TString gsDefTitle = "Tree Classification Loop";
+
+// --------------------------------------------------------------------------
+//
+//
+MRanForestFill::MRanForestFill(const char *name, const char *title):fNumTrees(-1)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the data chains
+//
+MRanForestFill::~MRanForestFill()
+{
+    //    delete fData;
+}
+
+// --------------------------------------------------------------------------
+Int_t MRanForestFill::PreProcess(MParList *plist)
+{
+    fRanTree = (MRanTree*)plist->FindObject("MRanTree");
+    if (!fRanTree)
+    {
+        *fLog << err << dbginf << "MRanTree not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fRanForest = (MRanForest*)plist->FindCreateObj("MRanForest");
+    if (!fRanForest)
+    {
+        *fLog << err << dbginf << "MRanForest not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fNum=0;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//
+Int_t MRanForestFill::Process()
+{
+    if (!(fRanForest->AddTree(fRanTree)))
+        return kFALSE;
+
+    fNum++;
+
+    return fNumTrees<0 ? kTRUE : fNum<fNumTrees;
+}
+
+Int_t MRanForestFill::PostProcess()
+{
+    fRanForest->SetNumTrees(fNum);
+    return kTRUE;
+}
+
Index: /tags/Mars_V0-8-5/Mars/mranforest/MRanForestFill.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mranforest/MRanForestFill.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mranforest/MRanForestFill.h	(revision 9661)
@@ -0,0 +1,35 @@
+#ifndef MARS_MRanForestFill
+#define MARS_MRanForestFill
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MRanTree;
+class MRanForest;
+class MParList;
+class MDataArray;
+
+class MRanForestFill : public MTask
+{
+private:
+    MRanTree *fRanTree;
+    MRanForest *fRanForest;
+    MDataArray *fData;
+    Int_t fNumTrees;
+    Int_t fNum;
+
+    Int_t PreProcess(MParList *plist);
+    Int_t Process();
+    Int_t PostProcess();
+
+public:
+    MRanForestFill(const char *name=NULL, const char *title=NULL);
+    ~MRanForestFill();
+
+    void SetNumTrees(UShort_t n=100) { fNumTrees = n; }
+
+    ClassDef(MRanForestFill, 0) // Task
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mranforest/MRanForestGrow.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mranforest/MRanForestGrow.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mranforest/MRanForestGrow.cc	(revision 9661)
@@ -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 Hengstebeck 3/2003 <mailto:hengsteb@alwa02.physik.uni-siegen.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//  MRanForestGrow                                                         //
+//                                                                         //
+//  Grows a random forest.                                                 //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MRanForestGrow.h"
+
+#include "MHMatrix.h" // must be before MLogManip.h
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MRanTree.h"
+#include "MRanForest.h"
+
+ClassImp(MRanForestGrow);
+
+using namespace std;
+
+static const TString gsDefName  = "MRanForestGrow";
+static const TString gsDefTitle = "Tree Classification Loop 1/2";
+
+// --------------------------------------------------------------------------
+//
+// Setup histograms and the number of distances which are used for
+// avaraging in CalcDist
+//
+MRanForestGrow::MRanForestGrow(const char *name, const char *title)
+    : fNumTrees(100),fNumTry(3),fNdSize(1)
+{
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+}
+
+// --------------------------------------------------------------------------
+//
+// Needs:
+//  - MatrixGammas  [MHMatrix]
+//  - MatrixHadrons {MHMatrix]
+//  - MHadroness
+//  - all data containers used to build the matrixes
+//
+// The matrix object can be filles using MFillH. And must be of the same
+// number of columns (with the same meaning).
+//
+Int_t MRanForestGrow::PreProcess(MParList *plist)
+{
+    fMGammas = (MHMatrix*)plist->FindObject("MatrixGammas", "MHMatrix");
+    if (!fMGammas)
+    {
+        *fLog << err << dbginf << "MatrixGammas [MHMatrix] not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fMHadrons = (MHMatrix*)plist->FindObject("MatrixHadrons", "MHMatrix");
+    if (!fMHadrons)
+    {
+        *fLog << err << dbginf << "MatrixHadrons [MHMatrix] not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    if (fMGammas->GetM().GetNcols() != fMHadrons->GetM().GetNcols())
+    {
+        *fLog << err << dbginf << "Error matrices have different numbers of columns... aborting." << endl;
+        return kFALSE;
+    }
+
+    fRanTree = (MRanTree*)plist->FindCreateObj("MRanTree");
+    if (!fRanTree)
+    {
+        *fLog << err << dbginf << "MRanTree not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fRanForest = (MRanForest*)plist->FindCreateObj("MRanForest");
+    if (!fRanForest)
+    {
+        *fLog << err << dbginf << "MRanForest not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fRanTree->SetNumTry(fNumTry);
+    fRanTree->SetNdSize(fNdSize);
+    fRanForest->SetCurTree(fRanTree);
+    fRanForest->SetNumTrees(fNumTrees);
+
+    return fRanForest->SetupGrow(fMHadrons,fMGammas);
+}
+
+// --------------------------------------------------------------------------
+//
+//
+Int_t MRanForestGrow::Process()
+{
+    Bool_t not_last=fRanForest->GrowForest();
+    fRanTree->SetReadyToSave();
+
+    return not_last;
+}
+
+Int_t MRanForestGrow::PostProcess()
+{
+    fRanTree->SetReadyToSave();
+    fRanForest->SetReadyToSave();
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mranforest/MRanForestGrow.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mranforest/MRanForestGrow.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mranforest/MRanForestGrow.h	(revision 9661)
@@ -0,0 +1,48 @@
+#ifndef MARS_MRanForestGrow
+#define MARS_MRanForestGrow
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MRanForestGrow                                                          //
+//                                                                         //
+// Task to grow (train) a random forest                                    //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MHMatrix;
+class MParList;
+class MRanForest;
+class MRanTree;
+
+class MRanForestGrow : public MTask
+{
+private:
+    MRanTree   *fRanTree;
+    MRanForest *fRanForest;
+    MHMatrix   *fMGammas;   //! Gammas describing matrix
+    MHMatrix   *fMHadrons;  //! Hadrons (non gammas) describing matrix
+
+    Int_t fNumTrees;
+    Int_t fNumTry;
+    Int_t fNdSize;
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
+public:
+    MRanForestGrow(const char *name=NULL, const char *title=NULL);
+
+    void SetNumTrees(Int_t n){    fNumTrees=n;}
+    void SetNumTry(Int_t n)  {    fNumTry=n;  }
+    void SetNdSize(Int_t n)  {    fNdSize=n;  }
+
+    ClassDef(MRanForestGrow, 0) // Task to grow a random forest
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mranforest/MRanTree.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mranforest/MRanTree.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mranforest/MRanTree.cc	(revision 9661)
@@ -0,0 +1,522 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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 Hengstebeck 3/2003 <mailto:hengsteb@alwa02.physik.uni-siegen.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MRanTree
+//
+// ParameterContainer for Tree structure
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MRanTree.h"
+
+#include <iostream>
+
+#include <TVector.h>
+#include <TMatrix.h>
+#include <TRandom.h>
+
+#include "MDataArray.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MRanTree);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MRanTree::MRanTree(const char *name, const char *title):fNdSize(0), fNumTry(3), fData(NULL)
+{
+
+    fName  = name  ? name  : "MRanTree";
+    fTitle = title ? title : "Storage container for structure of a single tree";
+}
+
+void MRanTree::SetNdSize(Int_t n)
+{
+    // threshold nodesize of terminal nodes, i.e. the training data is splitted
+    // until there is only pure date in the subsets(=terminal nodes) or the
+    // subset size is LE n
+
+    fNdSize=TMath::Max(1,n);//at least 1 event per node
+}
+
+void MRanTree::SetNumTry(Int_t n)
+{
+    // number of trials in random split selection:
+    // choose at least 1 variable to split in
+
+    fNumTry=TMath::Max(1,n);
+}
+
+void MRanTree::GrowTree(const TMatrix &mhad, const TMatrix &mgam,
+                        const TArrayI &hadtrue, TArrayI &datasort,
+                        const TArrayI &datarang, TArrayF &tclasspop, TArrayI &jinbag,
+                        const TArrayF &winbag)
+{
+    // arrays have to be initialized with generous size, so number of total nodes (nrnodes)
+    // is estimated for worst case
+    const Int_t numdim =mhad.GetNcols();
+    const Int_t numdata=winbag.GetSize();
+    const Int_t nrnodes=2*numdata+1;
+
+    // number of events in bootstrap sample
+    Int_t ninbag=0;
+    for (Int_t n=0;n<numdata;n++)
+        if(jinbag[n]==1) ninbag++;
+
+    TArrayI bestsplit(nrnodes);
+    TArrayI bestsplitnext(nrnodes);
+
+    fBestVar.Set(nrnodes);
+    fTreeMap1.Set(nrnodes);
+    fTreeMap2.Set(nrnodes);
+    fBestSplit.Set(nrnodes);
+
+    fTreeMap1.Reset();
+    fTreeMap2.Reset();
+    fBestSplit.Reset();
+
+    fGiniDec.Set(numdim);
+    fGiniDec.Reset();
+
+    // tree growing
+    BuildTree(datasort,datarang,hadtrue,bestsplit,
+              bestsplitnext,tclasspop,winbag,ninbag);
+
+    // post processing, determine cut (or split) values fBestSplit
+    Int_t nhad=mhad.GetNrows();
+
+    for(Int_t k=0; k<nrnodes; k++)
+    {
+        if (GetNodeStatus(k)==-1)
+            continue;
+
+        const Int_t &bsp =bestsplit[k];
+        const Int_t &bspn=bestsplitnext[k];
+        const Int_t &msp =fBestVar[k];
+
+        fBestSplit[k]  = bsp<nhad  ? mhad(bsp, msp):mgam(bsp-nhad, msp);
+        fBestSplit[k] += bspn<nhad ? mhad(bspn,msp):mgam(bspn-nhad,msp);
+        fBestSplit[k] /= 2;
+    }
+
+    // resizing arrays to save memory
+    fBestVar.Set(fNumNodes);
+    fTreeMap1.Set(fNumNodes);
+    fTreeMap2.Set(fNumNodes);
+    fBestSplit.Set(fNumNodes);
+}
+
+Int_t MRanTree::FindBestSplit(const TArrayI &datasort,const TArrayI &datarang,
+                              const TArrayI &hadtrue,Int_t ndstart,Int_t ndend,TArrayF &tclasspop,
+                              Int_t &msplit,Float_t &decsplit,Int_t &nbest,
+                              const TArrayF &winbag)
+{
+    const Int_t nrnodes = fBestSplit.GetSize();
+    const Int_t numdata = (nrnodes-1)/2;
+    const Int_t mdim = fGiniDec.GetSize();
+
+    // weighted class populations after split
+    TArrayF wc(2); 
+    TArrayF wr(2); // right node
+
+    // For the best split, msplit is the index of the variable (e.g Hillas par., zenith angle ,...)
+    // split on. decsplit is the decreae in impurity measured by Gini-index.
+    // nsplit is the case number of value of msplit split on,
+    // and nsplitnext is the case number of the next larger value of msplit.
+
+    Int_t nbestvar=0;
+
+    // compute initial values of numerator and denominator of Gini-index,
+    // Gini index= pno/dno
+    Double_t pno=0;
+    Double_t pdo=0;
+    for (Int_t j=0; j<2; j++)
+    {
+        pno+=tclasspop[j]*tclasspop[j];
+        pdo+=tclasspop[j];
+    }
+
+    const Double_t crit0=pno/pdo;
+    Int_t jstat=0;
+
+    // start main loop through variables to find best split,
+    // (Gini-index as criterium crit)
+
+    Double_t critmax=-FLT_MAX;
+
+    // random split selection, number of trials = fNumTry
+    for (Int_t mt=0; mt<fNumTry; mt++)
+    {
+        const Int_t mvar=Int_t(gRandom->Rndm()*mdim);
+        const Int_t mn  = mvar*numdata;
+
+        // Gini index = rrn/rrd+rln/rld
+        Double_t rrn=pno;
+        Double_t rrd=pdo;
+        Double_t rln=0;
+        Double_t rld=0;
+
+        TArrayF wl(2); // left node
+        wr = tclasspop;
+
+        Double_t critvar=-1.0e20;
+
+        for(Int_t nsp=ndstart;nsp<=ndend-1;nsp++)
+        {
+            const Int_t &nc=datasort[mn+nsp];
+            const Int_t &k=hadtrue[nc];
+
+            const Float_t &u=winbag[nc];
+
+            rln+=u*(2*wl[k]+u);
+            rrn+=u*(-2*wr[k]+u);
+            rld+=u;
+            rrd-=u;
+
+            wl[k]+=u;
+            wr[k]-=u;
+
+            if (datarang[mn+nc]>=datarang[mn+datasort[mn+nsp+1]])
+                continue;
+            if (TMath::Min(rrd,rld)<=1.0e-5)
+                continue;
+
+            const Double_t crit=(rln/rld)+(rrn/rrd);
+            if (crit<=critvar)
+                continue;
+
+            nbestvar=nsp;
+            critvar=crit;
+        }
+
+        if (critvar<=critmax)
+            continue;
+
+        msplit=mvar;
+        nbest=nbestvar;
+        critmax=critvar;
+    }
+
+    decsplit=critmax-crit0;
+
+    return critmax<-1.0e10 ? 1 : jstat;
+}
+
+void MRanTree::MoveData(TArrayI &datasort,Int_t ndstart,
+                        Int_t ndend,TArrayI &idmove,TArrayI &ncase,Int_t msplit,
+                        Int_t nbest,Int_t &ndendl)
+{
+    // This is the heart of the BuildTree construction. Based on the best split
+    // the data in the part of datasort corresponding to the current node is moved to the
+    // left if it belongs to the left child and right if it belongs to the right child-node.
+    const Int_t numdata = ncase.GetSize();
+    const Int_t mdim    = fGiniDec.GetSize();
+
+    TArrayI tdatasort(numdata);
+
+    // compute idmove = indicator of case nos. going left
+
+    for (Int_t nsp=ndstart;nsp<=ndend;nsp++)
+    {
+        const Int_t &nc=datasort[msplit*numdata+nsp];
+        idmove[nc]= nsp<=nbest?1:0;
+    }
+    ndendl=nbest;
+
+    // shift case. nos. right and left for numerical variables.
+
+    for(Int_t msh=0;msh<mdim;msh++)
+    {
+        Int_t k=ndstart-1;
+        for (Int_t n=ndstart;n<=ndend;n++)
+        {
+            const Int_t &ih=datasort[msh*numdata+n];
+            if (idmove[ih]==1)
+                tdatasort[++k]=datasort[msh*numdata+n];
+        }
+
+        for (Int_t n=ndstart;n<=ndend;n++)
+        {
+            const Int_t &ih=datasort[msh*numdata+n];
+            if (idmove[ih]==0)
+                tdatasort[++k]=datasort[msh*numdata+n];
+        }
+
+        for(Int_t m=ndstart;m<=ndend;m++)
+            datasort[msh*numdata+m]=tdatasort[m];
+    }
+
+    // compute case nos. for right and left nodes.
+
+    for(Int_t n=ndstart;n<=ndend;n++)
+        ncase[n]=datasort[msplit*numdata+n];
+}
+
+void MRanTree::BuildTree(TArrayI &datasort,const TArrayI &datarang,
+                         const TArrayI &hadtrue, TArrayI &bestsplit,
+                         TArrayI &bestsplitnext, TArrayF &tclasspop,
+                         const TArrayF &winbag, Int_t ninbag)
+{
+    // Buildtree consists of repeated calls to two void functions, FindBestSplit and MoveData.
+    // Findbestsplit does just that--it finds the best split of the current node.
+    // MoveData moves the data in the split node right and left so that the data
+    // corresponding to each child node is contiguous.
+    //
+    // buildtree bookkeeping:
+    // ncur is the total number of nodes to date.  nodestatus(k)=1 if the kth node has been split.
+    // nodestatus(k)=2 if the node exists but has not yet been split, and =-1 if the node is
+    // terminal.  A node is terminal if its size is below a threshold value, or if it is all
+    // one class, or if all the data-values are equal.  If the current node k is split, then its
+    // children are numbered ncur+1 (left), and ncur+2(right), ncur increases to ncur+2 and
+    // the next node to be split is numbered k+1.  When no more nodes can be split, buildtree
+    // returns.
+    const Int_t mdim    = fGiniDec.GetSize();
+    const Int_t nrnodes = fBestSplit.GetSize();
+    const Int_t numdata = (nrnodes-1)/2;
+
+    TArrayI nodepop(nrnodes);
+    TArrayI nodestart(nrnodes);
+    TArrayI parent(nrnodes);
+
+    TArrayI ncase(numdata);
+    TArrayI idmove(numdata);
+    TArrayI iv(mdim);
+
+    TArrayF classpop(nrnodes*2);
+    TArrayI nodestatus(nrnodes);
+
+    for (Int_t j=0;j<2;j++)
+        classpop[j*nrnodes+0]=tclasspop[j];
+
+    Int_t ncur=0;
+    nodepop[0]=ninbag;
+    nodestatus[0]=2;
+
+    // start main loop
+    for (Int_t kbuild=0; kbuild<nrnodes; kbuild++)
+    {
+          if (kbuild>ncur) break;
+          if (nodestatus[kbuild]!=2) continue;
+
+          // initialize for next call to FindBestSplit
+
+          const Int_t ndstart=nodestart[kbuild];
+          const Int_t ndend=ndstart+nodepop[kbuild]-1;
+          for (Int_t j=0;j<2;j++)
+              tclasspop[j]=classpop[j*nrnodes+kbuild];
+
+          Int_t msplit, nbest;
+          Float_t decsplit=0;
+          const Int_t jstat=FindBestSplit(datasort,datarang,hadtrue,
+                                          ndstart,ndend,tclasspop,msplit,
+                                          decsplit,nbest,winbag);
+
+          if (jstat==1)
+          {
+              nodestatus[kbuild]=-1;
+              continue;
+          }
+
+          fBestVar[kbuild]=msplit;
+          fGiniDec[msplit]+=decsplit;
+
+          bestsplit[kbuild]=datasort[msplit*numdata+nbest];
+          bestsplitnext[kbuild]=datasort[msplit*numdata+nbest+1];
+
+          Int_t ndendl;
+          MoveData(datasort,ndstart,ndend,idmove,ncase,
+                   msplit,nbest,ndendl);
+
+          // leftnode no.= ncur+1, rightnode no. = ncur+2.
+
+          nodepop[ncur+1]=ndendl-ndstart+1;
+          nodepop[ncur+2]=ndend-ndendl;
+          nodestart[ncur+1]=ndstart;
+          nodestart[ncur+2]=ndendl+1;
+
+          // find class populations in both nodes
+
+          for (Int_t n=ndstart;n<=ndendl;n++)
+          {
+              const Int_t &nc=ncase[n];
+              const Int_t &j=hadtrue[nc];
+              classpop[j*nrnodes+ncur+1]+=winbag[nc];
+          }
+
+          for (Int_t n=ndendl+1;n<=ndend;n++)
+          {
+              const Int_t &nc=ncase[n];
+              const Int_t &j=hadtrue[nc];
+              classpop[j*nrnodes+ncur+2]+=winbag[nc];
+          }
+
+          // check on nodestatus
+
+          nodestatus[ncur+1]=2;
+          nodestatus[ncur+2]=2;
+          if (nodepop[ncur+1]<=fNdSize) nodestatus[ncur+1]=-1;
+          if (nodepop[ncur+2]<=fNdSize) nodestatus[ncur+2]=-1;
+
+          Double_t popt1=0;
+          Double_t popt2=0;
+          for (Int_t j=0;j<2;j++)
+          {
+              popt1+=classpop[j*nrnodes+ncur+1];
+              popt2+=classpop[j*nrnodes+ncur+2];
+          }
+
+          for (Int_t j=0;j<2;j++)
+          {
+              if (classpop[j*nrnodes+ncur+1]==popt1) nodestatus[ncur+1]=-1;
+              if (classpop[j*nrnodes+ncur+2]==popt2) nodestatus[ncur+2]=-1;
+          }
+
+          fTreeMap1[kbuild]=ncur+1;
+          fTreeMap2[kbuild]=ncur+2;
+          parent[ncur+1]=kbuild;
+          parent[ncur+2]=kbuild;
+          nodestatus[kbuild]=1;
+          ncur+=2;
+          if (ncur>=nrnodes) break;
+    }
+
+    // determine number of nodes
+    fNumNodes=nrnodes;
+    for (Int_t k=nrnodes-1;k>=0;k--)
+    {
+        if (nodestatus[k]==0) fNumNodes-=1;
+        if (nodestatus[k]==2) nodestatus[k]=-1;
+    }
+
+    fNumEndNodes=0;
+    for (Int_t kn=0;kn<fNumNodes;kn++)
+        if(nodestatus[kn]==-1)
+        {
+            fNumEndNodes++;
+            Double_t pp=0;
+            for (Int_t j=0;j<2;j++)
+            {
+                if(classpop[j*nrnodes+kn]>pp)
+                {
+                    // class + status of node kn coded into fBestVar[kn]
+                    fBestVar[kn]=j-2;
+                    pp=classpop[j*nrnodes+kn];
+                }
+            }
+            fBestSplit[kn] =classpop[1*nrnodes+kn];
+            fBestSplit[kn]/=(classpop[0*nrnodes+kn]+classpop[1*nrnodes+kn]);
+        }
+}
+
+void MRanTree::SetRules(MDataArray *rules)
+{
+    fData=rules;
+}
+
+Double_t MRanTree::TreeHad(const TVector &event)
+{
+    Int_t kt=0;
+    // to optimize on storage space node status and node class
+    // are coded into fBestVar:
+    // status of node kt = TMath::Sign(1,fBestVar[kt])
+    // class  of node kt = fBestVar[kt]+2 (class defined by larger
+    //  node population, actually not used)
+    // hadronness assigned to node kt = fBestSplit[kt]
+
+    for (Int_t k=0;k<fNumNodes;k++)
+    {
+        if (fBestVar[kt]<0)
+            break;
+
+        const Int_t m=fBestVar[kt];
+        kt = event(m)<=fBestSplit[kt] ? fTreeMap1[kt] : fTreeMap2[kt];
+    }
+
+    return fBestSplit[kt];
+}
+
+Double_t MRanTree::TreeHad(const TMatrixRow &event)
+{
+    Int_t kt=0;
+    // to optimize on storage space node status and node class
+    // are coded into fBestVar:
+    // status of node kt = TMath::Sign(1,fBestVar[kt])
+    // class  of node kt = fBestVar[kt]+2 (class defined by larger
+    //  node population, actually not used)
+    // hadronness assigned to node kt = fBestSplit[kt]
+
+    for (Int_t k=0;k<fNumNodes;k++)
+    {
+        if (fBestVar[kt]<0)
+            break;
+
+        const Int_t m=fBestVar[kt];
+        kt = event(m)<=fBestSplit[kt] ? fTreeMap1[kt] : fTreeMap2[kt];
+    }
+
+    return fBestSplit[kt];
+}
+
+Double_t MRanTree::TreeHad(const TMatrix &m, Int_t ievt)
+{
+    return TreeHad(TMatrixRow(m, ievt));
+}
+
+Double_t MRanTree::TreeHad()
+{
+    TVector event;
+    *fData >> event;
+
+    return TreeHad(event);
+}
+
+Bool_t MRanTree::AsciiWrite(ostream &out) const
+{
+    TString str;
+    Int_t k;
+
+    out.width(5);out<<fNumNodes<<endl;
+
+    for (k=0;k<fNumNodes;k++)
+    {
+        str=Form("%f",GetBestSplit(k));
+
+        out.width(5);  out << k;
+        out.width(5);  out << GetNodeStatus(k);
+        out.width(5);  out << GetTreeMap1(k);
+        out.width(5);  out << GetTreeMap2(k);
+        out.width(5);  out << GetBestVar(k);
+        out.width(15); out << str<<endl;
+        out.width(5);  out << GetNodeClass(k);
+    }
+    out<<endl;
+
+    return k==fNumNodes;
+}
Index: /tags/Mars_V0-8-5/Mars/mranforest/MRanTree.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mranforest/MRanTree.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mranforest/MRanTree.h	(revision 9661)
@@ -0,0 +1,95 @@
+#ifndef MARS_MRanTree
+#define MARS_MRanTree
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#ifndef ROOT_TArrayI
+#include <TArrayI.h>
+#endif
+
+#ifndef ROOT_TArrayF
+#include <TArrayF.h>
+#endif
+
+class TMatrix;
+class TMatrixRow;
+class TVector;
+class TRandom;
+class MDataArray;
+
+class MRanTree : public MParContainer
+{
+private:
+    Int_t fNdSize;
+    Int_t fNumTry;
+
+    Int_t fNumNodes;
+    Int_t fNumEndNodes;
+    MDataArray *fData;
+
+    TArrayI fBestVar;
+    TArrayI fTreeMap1;
+    TArrayI fTreeMap2;
+    TArrayF fBestSplit;
+
+    TArrayF fGiniDec;
+
+    Int_t FindBestSplit(const TArrayI &datasort, const TArrayI &datarang,
+                        const TArrayI &hadtrue,
+                        Int_t ndstart, Int_t ndend, TArrayF &tclasspop,
+                        Int_t &msplit, Float_t &decsplit, Int_t &nbest,
+                        const TArrayF &winbag);
+
+    void MoveData(TArrayI &datasort, Int_t ndstart, Int_t ndend,
+                  TArrayI &idmove, TArrayI &ncase, Int_t msplit,
+                  Int_t nbest, Int_t &ndendl);
+
+    void BuildTree(TArrayI &datasort, const TArrayI &datarang,
+                   const TArrayI &hadtrue,
+                   TArrayI &bestsplit,TArrayI &bestsplitnext,
+                   TArrayF &tclasspop,
+                   const TArrayF &winbag,
+                   Int_t ninbag);
+
+public:
+    MRanTree(const char *name=NULL, const char *title=NULL);
+
+    void SetNdSize(Int_t n);
+    void SetNumTry(Int_t n);
+    void SetRules(MDataArray *rules);
+
+    MDataArray *GetRules() { return fData;}
+
+    Int_t GetNdSize() const { return fNdSize; }
+    Int_t GetNumTry() const { return fNumTry; }
+    Int_t GetNumNodes()          const { return fNumNodes; }
+    Int_t GetNumEndNodes()       const { return fNumEndNodes; }
+
+    Int_t GetBestVar(Int_t i)    const { return fBestVar.At(i); }
+    Int_t GetTreeMap1(Int_t i)   const { return fTreeMap1.At(i); }
+    Int_t GetTreeMap2(Int_t i)   const { return fTreeMap2.At(i); }
+    Int_t GetNodeClass(Int_t i)  const { return fBestVar.At(i)+2; }
+    Int_t GetNodeStatus(Int_t i) const { return TMath::Sign(1,fBestVar.At(i));}
+    Float_t GetBestSplit(Int_t i)const { return fBestSplit.At(i); }
+
+    Float_t GetGiniDec(Int_t i)  const { return fGiniDec.At(i); }
+
+    // functions used in tree growing process
+    void GrowTree(const TMatrix &mhad, const TMatrix &mgam,
+                  const TArrayI &hadtrue, TArrayI &datasort,
+                  const TArrayI &datarang,
+                  TArrayF &tclasspop, TArrayI &jinbag, const TArrayF &winbag);
+
+    Double_t TreeHad(const TVector &event);
+    Double_t TreeHad(const TMatrixRow &event);
+    Double_t TreeHad(const TMatrix &m, Int_t ievt);
+    Double_t TreeHad();
+
+    Bool_t AsciiWrite(ostream &out) const;
+
+    ClassDef(MRanTree, 1) // Storage container for tree structure
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mranforest/Makefile
===================================================================
--- /tags/Mars_V0-8-5/Mars/mranforest/Makefile	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mranforest/Makefile	(revision 9661)
@@ -0,0 +1,38 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#------------------------------------------------------------------------------
+
+#
+# Handling name of the Root Dictionary Files
+#
+CINT  = RanForest
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES = -I. -I../mbase -I../mhbase -I../mdata -I../manalysis -I../mmc -I../mfileio
+#               MParContainer MH     MDataArray MHadronness    MMcEvt
+
+SRCFILES = MRanTree.cc \
+           MRanForest.cc \
+           MRanForestGrow.cc \
+           MRanForestCalc.cc \
+           MRanForestFill.cc \
+	   MHRanForest.cc \
+	   MHRanForestGini.cc
+
+############################################################
+
+all: $(OBJS)
+
+include ../Makefile.rules
+
+mrproper:	clean rmbak
Index: /tags/Mars_V0-8-5/Mars/mranforest/RanForestIncl.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mranforest/RanForestIncl.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mranforest/RanForestIncl.h	(revision 9661)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-8-5/Mars/mranforest/RanForestLinkDef.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mranforest/RanForestLinkDef.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mranforest/RanForestLinkDef.h	(revision 9661)
@@ -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 MRanTree+;  
+#pragma link C++ class MRanForest+;
+#pragma link C++ class MRanForestGrow+;
+#pragma link C++ class MRanForestCalc+;
+#pragma link C++ class MRanForestFill+;    
+
+#pragma link C++ class MHRanForest+;
+#pragma link C++ class MHRanForestGini+;
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mraw/MRawCrateArray.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mraw/MRawCrateArray.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mraw/MRawCrateArray.cc	(revision 9661)
@@ -0,0 +1,128 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  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::Print(Option_t *t) const
+{
+    fArray->Print();
+}
+
+void MRawCrateArray::SetSize(Int_t i)
+{
+    if (fArray->GetEntriesFast() == i)
+        return;
+
+    fArray->ExpandCreateFast(i);
+}
+
+Int_t MRawCrateArray::GetSize() const
+{
+    return fArray->GetEntriesFast();
+}
+
+// --------------------------------------------------------------------------
+//
+// Return a pointer the i-th entry in the array, without range check
+//
+MRawCrateData *MRawCrateArray::GetEntry(Int_t i)
+{
+    return (MRawCrateData*)fArray->UncheckedAt(i); // AddrAt would be with rcheck
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the i-th entry in the array, with range check
+//
+MRawCrateData* &MRawCrateArray::operator[](Int_t i)
+{
+    return (MRawCrateData*&)(*fArray)[i];
+}
+
+// --------------------------------------------------------------------------
+//
+// return a pointer to the pointer of the array
+// (actually not used. You may need it if you want to write
+//  the TClonesArray directly)
+//
+TClonesArray **MRawCrateArray::GetArray()
+{
+    return &fArray;
+}
Index: /tags/Mars_V0-8-5/Mars/mraw/MRawCrateArray.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mraw/MRawCrateArray.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mraw/MRawCrateArray.h	(revision 9661)
@@ -0,0 +1,39 @@
+#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 Print(Option_t *t=NULL) const;
+
+    void SetSize(Int_t i);
+    Int_t GetSize() const;
+    MRawCrateData *GetEntry(Int_t i);
+
+    MRawCrateData* &operator[](Int_t i);
+
+    TClonesArray **GetArray();
+
+    ClassDef(MRawCrateArray, 1)	// Mapping container for the MRawCrateData TClonesArray
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mraw/MRawCrateData.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mraw/MRawCrateData.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mraw/MRawCrateData.cc	(revision 9661)
@@ -0,0 +1,81 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MRawCrateData
+//
+//  This container stores the information about one crate. A list of this
+//  informations can be find at MRawCrateArray
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MRawCrateData.h"
+
+#include <iostream>
+#include <iomanip>
+
+#include <fstream>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MRawCrateData);
+
+using namespace std;
+
+MRawCrateData::MRawCrateData() : fDAQCrateNumber(0), fFADCEvtNumber(0), fFADCClockTick(0), fABFlags(0)
+{
+}
+
+// --------------------------------------------------------------------------
+//
+//  read the information from a binary input stream about the CRATE DATA,
+//  like specified in a TDAS note
+//
+void MRawCrateData::ReadEvt(istream& fin, UShort_t ver)
+{
+    fin.read((char*)&fDAQCrateNumber, 2);
+    fin.read((char*)&fFADCEvtNumber,  4);
+    fin.read((char*)&fFADCClockTick,  4);
+    if (ver>1)
+       fin.read((char*)&fABFlags, 1);
+}
+
+void MRawCrateData::SkipEvt(istream &fin, UShort_t ver)
+{
+    fin.seekg(ver>1?11:10);
+}
+
+// --------------------------------------------------------------------------
+//
+//  print all stored information to gLog
+//
+void MRawCrateData::Print(Option_t *t) const
+{
+    *fLog << all;
+    *fLog << "Crate Number " << dec << fDAQCrateNumber << ":  ";
+    *fLog << "FADCEventNr   = " << fFADCEvtNumber << "  ";
+    *fLog << "FADCClockTick = " << fFADCClockTick << " (20MHz)" << endl;
+    *fLog << "ABFlags       = " << hex << fABFlags << endl;
+}
Index: /tags/Mars_V0-8-5/Mars/mraw/MRawCrateData.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mraw/MRawCrateData.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mraw/MRawCrateData.h	(revision 9661)
@@ -0,0 +1,36 @@
+#ifndef MARS_MRawCrateData
+#define MARS_MRawCrateData
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+//gcc 3.2
+//class ifstream;
+#include <iosfwd>
+
+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)
+    Byte_t   fABFlags;         // flag describing in which two-slice block the trigger was raised
+
+public:
+    MRawCrateData();
+
+    UChar_t GetDAQCrateNumber() const  { return fDAQCrateNumber; }
+    UInt_t  GetFADCEvtNumber() const   { return fFADCEvtNumber;  }
+    UInt_t  GetFADCClockTick() const   { return fFADCClockTick;  }
+    Byte_t  GetABFlags() const         { return fABFlags;        }
+
+    void Print(Option_t *t=NULL) const;
+
+    void ReadEvt(istream& fin, UShort_t ver);
+    void SkipEvt(istream& fin, UShort_t ver);
+
+    ClassDef(MRawCrateData, 2) //Container to store the Raw CRATE DATA
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mraw/MRawEvtData.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mraw/MRawEvtData.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mraw/MRawEvtData.cc	(revision 9661)
@@ -0,0 +1,598 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  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
+//
+//
+//   Version 3:
+//   ----------
+//    - Added fABFlags
+//
+//   Version 2:
+//   ----------
+//    - Derives from MCamEvent now
+//
+//   Version 1:
+//   ----------
+//    - First implementation
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MRawEvtData.h"
+
+#include <fstream>
+
+#include <TH1.h>
+#include <TGraph.h>
+#include <TArrayC.h>
+#include <TVirtualPad.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MArrayS.h"
+#include "MArrayB.h"
+#include "MGeomCam.h"
+
+#include "MRawCrateArray.h"
+#include "MRawCrateData.h"
+
+#include "MRawRunHeader.h"
+#include "MRawEvtPixelIter.h"
+
+ClassImp(MRawEvtData);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// 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();
+    fABFlags->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++)
+    {
+        const UShort_t idx = (*fHiGainPixId)[i];
+
+        *fLog << endl;
+        *fLog << " " << setfill(' ') << setw(3) << dec << i << " - " << setw(3);
+        *fLog << dec << idx << " <" << hex << setfill('0') << setw(2);
+        *fLog << ((Int_t)(*fABFlags)[idx/8]&0xff) << "> ";
+
+        *fLog << (manip?dec:hex) << (manip ? setfill(' ') : 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 << ' ';
+        }
+
+        if (!(l<nLoPix && (*fLoGainPixId)[l]==idx))
+            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 << ' ';
+        }
+        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
+//     <index>      The pixel with the given index is drawn
+//
+void MRawEvtData::Draw(Option_t *opt)
+{
+    if (GetNumPixels()==0)
+    {
+        *fLog << warn << "Sorry, no pixel to draw!" << endl;
+        return;
+    }
+
+    TString str(opt);
+    str.ToLower();
+
+    UInt_t id = 0;
+
+    if (str.BeginsWith("graph"))
+        if (str.Length()>5)
+            sscanf(&str[5], "%d", &id);
+    if (str.BeginsWith("hist"))
+        if (str.Length()>4)
+            sscanf(&str[4], "%d", &id);
+
+    MRawEvtPixelIter pix(this);
+    if (!pix.Jump(id))
+    {
+        *fLog << warn << dec << "Pixel Idx #" << id << " doesn't exist!" << endl;
+        return;
+    }
+
+    const Byte_t *higains = pix.GetHiGainSamples();
+    const Byte_t *logains = pix.GetLoGainSamples();
+
+    const Int_t nh = GetNumHiGainSamples();
+    const Int_t nl = GetNumLoGainSamples();
+
+    TString name = "Pixel Idx.";
+    name += pix.GetPixelId();
+
+    Bool_t same = str.Contains("same");
+
+    if (str.BeginsWith("graph"))
+    {
+        *fLog << inf << "Drawing Graph: Pixel Idx #" << dec << pix.GetPixelId();
+        *fLog << " of " << (int)GetNumPixels() << "Pixels" << endl;
+
+        TGraph *graphhi = new TGraph;
+
+        for (int i=0; i<nh; i++)
+            graphhi->SetPoint(graphhi->GetN(), i, higains[i]);
+
+        graphhi->SetMaximum(256);
+        graphhi->SetMinimum(0);
+
+        graphhi->SetBit(kCanDelete);
+        graphhi->Draw(same ? "C*" : "AC*");
+
+        TH1F *histhi = graphhi->GetHistogram();
+        histhi->SetMinimum(0);
+        histhi->SetMaximum(255);
+ 
+        histhi->SetXTitle("Time/FADC Slices");
+        histhi->SetYTitle("Signal/FADC Units");
+
+        if (nl>0)
+        {
+            TGraph *graphlo = new TGraph;
+
+            for (int i=0; i<nl; i++)
+                graphlo->SetPoint(graphlo->GetN(), i, logains[i]);
+
+            graphlo->SetMaximum(256);
+            graphlo->SetMinimum(0);
+            graphlo->SetLineColor(kBlue);
+
+            graphlo->SetBit(kCanDelete);
+            graphlo->Draw("C*");
+
+            TH1F *histlo = graphlo->GetHistogram();
+
+            histlo->SetXTitle("Time/FADC Slices");
+            histlo->SetYTitle("Signal/FADC Units");
+        }
+
+        return;
+    }
+
+    if (str.BeginsWith("hist"))
+    {
+        // FIXME: Add Legend
+        *fLog << inf << "Drawing Histogram of Pixel with Idx #" << dec << pix.GetPixelId() << " to " << gPad << endl;
+
+        TH1F *histh = new TH1F(name, "FADC Samples", nh, -0.5, nh-.5);
+        histh->SetMinimum(0);
+        histh->SetMaximum(255);
+        histh->SetXTitle("Time [FADC Slices]");
+        histh->SetYTitle("Signal [FADC Units]");
+        histh->SetDirectory(NULL);
+        for (int i=0; i<nh; i++)
+            histh->Fill(i, higains[i]);
+        histh->SetBit(kCanDelete);
+        histh->Draw(same ? "same" : "");
+
+        if (nl>0)
+        {
+            TH1F *histl = new TH1F(name+";2", "FADC Samples", nl, -0.5, nl-.5);
+            histl->SetLineColor(kBlue);
+            histl->SetDirectory(NULL);
+            for (int i=0; i<nl; i++)
+                histl->Fill(i, logains[i]);
+            histl->SetBit(kCanDelete);
+            histl->Draw("same");
+        }
+        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();
+        const int npix = fRunHeader->GetNumConnectedPixels();
+
+        if (fArraySize == npix)
+        {
+            fPosInArray = 0;
+            fConnectedPixels = 0;
+            return;
+        }
+    }
+
+    DeleteArrays();
+    InitArrays(flag);
+}
+
+// --------------------------------------------------------------------------
+//
+//  Deletes all the arrays
+//
+void MRawEvtData::DeleteArrays()
+{
+    delete fHiGainPixId;
+    delete fLoGainPixId;
+    delete fHiGainFadcSamples;
+    delete fLoGainFadcSamples;
+    delete fABFlags;
+}
+
+// --------------------------------------------------------------------------
+//
+//  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();
+        const int npix = fRunHeader->GetNumConnectedPixels();
+
+        fHiGainPixId       = new MArrayS(npix);
+        fLoGainPixId       = new MArrayS(npix);
+        fHiGainFadcSamples = new MArrayB(npix*fRunHeader->GetNumSamplesHiGain());
+        fLoGainFadcSamples = new MArrayB(npix*fRunHeader->GetNumSamplesLoGain());
+        fABFlags           = new TArrayC(fRunHeader->GetMaxPixId());
+
+        fArraySize  = npix;
+    }
+    else
+    {
+        fHiGainPixId       = new MArrayS(0);
+        fLoGainPixId       = new MArrayS(0);
+        fHiGainFadcSamples = new MArrayB(0);
+        fLoGainFadcSamples = new MArrayB(0);
+        fABFlags           = new TArrayC(0);
+
+        fArraySize = 0;
+    }
+
+    fPosInArray = 0;
+    fConnectedPixels = 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 " << ns << " doesn't match current number " << nSamp << 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;
+
+    const Byte_t ab = fCrateArray->GetEntry(fPosInArray)->GetABFlags();
+
+    Byte_t *higainsam = fHiGainFadcSamples->GetArray()+nhi*fConnectedPixels;
+    Byte_t *logainsam = fLoGainFadcSamples->GetArray()+nlo*fConnectedPixels;
+
+    for (int i=0; i<npic; i++)
+    {
+        fin.read((char*)higainsam, nhi);
+        fin.read((char*)logainsam, nlo);
+
+        // calc the spiral hardware pixel number
+        const UShort_t ipos = npos+i;
+
+        // -1 converts the hardware pixel Id into the software pixel index
+        const Int_t npix = (Int_t)fRunHeader->GetPixAssignment(ipos)-1;
+
+        // Check whether the pixel is connected or not
+        if (npix<0)
+            continue;
+
+        //
+        //  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, fConnectedPixels);
+        higainsam += nhi;
+
+        // FIXME: Not implemented in the raw files yet
+        //if (IsLoGainOn(i, j))
+        //{
+        fLoGainPixId->AddAt(npix, fConnectedPixels);
+        logainsam += nlo;
+        //}
+
+        if (TESTBIT(ab, i))
+            SETBIT((*fABFlags)[npix/8], npix%8);
+        else
+            CLRBIT((*fABFlags)[npix/8], npix%8);
+
+        fConnectedPixels++;
+    }
+
+    fPosInArray++;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the size in bytes of one event data block
+//
+Int_t MRawEvtData::GetNumBytes() const
+{
+    const UShort_t nlo  = fRunHeader->GetNumSamplesLoGain();
+    const UShort_t nhi  = fRunHeader->GetNumSamplesHiGain();
+    const UShort_t npic = fRunHeader->GetNumPixInCrate();
+
+    return (nhi+nlo)*npic;
+}
+
+// --------------------------------------------------------------------------
+//
+// Make sure, that you skip the whole event. This function only skips a part
+// of the event - see MRawRead::SkipEvent
+//
+void MRawEvtData::SkipEvt(istream &fin)
+{
+    fin.seekg(GetNumBytes(), ios::cur);
+}
+
+Bool_t MRawEvtData::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
+{
+    MRawEvtPixelIter Next(const_cast<MRawEvtData*>(this));
+    if (!Next.Jump(idx))
+        return kFALSE;
+
+    switch (type)
+    {
+    case 0:
+        val = Next.GetSumHiGainSamples()-(float)GetNumHiGainSamples()*fHiGainFadcSamples->GetArray()[0];
+        val*= cam.GetPixRatio(idx);
+        break;
+    case 1:
+        val = Next.GetMaxHiGainSample();
+        break;
+    case 2:
+        val = Next.GetMaxLoGainSample();
+        break;
+    case 3:
+        val = Next.GetIdxMaxHiGainSample();
+        break;
+    case 4:
+        val = Next.GetIdxMaxLoGainSample();
+        break;
+    case 5:
+        val = Next.GetIdxMaxHiLoGainSample();
+        return val >= 0;
+    }
+
+    return kTRUE;
+}
+
+void MRawEvtData::Copy(TObject &named)
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,04,01)
+const
+#endif
+{
+    MRawEvtData &evt = (MRawEvtData &)named;
+
+    *evt.fHiGainPixId = *fHiGainPixId;
+    *evt.fLoGainPixId = *fLoGainPixId;
+
+    *evt.fHiGainFadcSamples = *fHiGainFadcSamples;
+    *evt.fLoGainFadcSamples = *fLoGainFadcSamples;
+
+    *evt.fABFlags = *fABFlags;
+
+    evt.fPosInArray      = fPosInArray;
+    evt.fConnectedPixels = fConnectedPixels;
+    evt.fArraySize       = fArraySize;
+}
Index: /tags/Mars_V0-8-5/Mars/mraw/MRawEvtData.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mraw/MRawEvtData.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mraw/MRawEvtData.h	(revision 9661)
@@ -0,0 +1,94 @@
+#ifndef MARS_MRawEvtData
+#define MARS_MRawEvtData
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+#ifndef MARS_MCamEvent
+#include "MCamEvent.h"
+#endif
+
+// gcc 3.2
+//class ifstream;
+#include <iosfwd>
+
+class MRawRunHeader;
+class MRawCrateArray;
+
+class TArrayC;
+class MArrayS;
+class MArrayB;
+
+class MRawEvtData : public MParContainer, public MCamEvent
+{
+    friend class MRawEvtPixelIter;
+private:
+    MRawRunHeader  *fRunHeader;   //! provides information about numbers
+    MRawCrateArray *fCrateArray;  //! provides information about ab flag
+
+    // 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)
+
+    TArrayC *fABFlags;            //-> A information about the exact trigger position
+
+    Int_t fPosInArray;        //!
+    Int_t fConnectedPixels;   //!
+    Int_t fArraySize;         //!
+
+    void InitArrays(Bool_t flag=kFALSE);
+    void DeleteArrays();
+
+    Int_t GetNumBytes() const;
+
+public:
+    MRawEvtData(const char *name=NULL, const char *title=NULL);
+    ~MRawEvtData();
+
+    void Init(MRawRunHeader *rh, MRawCrateArray *arr)
+    {
+        //
+        // you have to set this before you can read information
+        // from a magic binary file
+        //
+        fRunHeader  = rh;
+        fCrateArray = arr;
+    }
+
+    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);
+    void SkipEvt(istream &fin);
+
+    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
+    void   DrawPixelContent(Int_t num) const
+    {
+        TString s("HIST");
+        s += num;
+        const_cast<MRawEvtData*>(this)->Draw(s);
+    }
+
+    void Copy(TObject &named)
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,04,01)
+        const
+#endif
+        ;
+
+    ClassDef(MRawEvtData, 4) //Container to store the raw Event Data
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mraw/MRawEvtHeader.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mraw/MRawEvtHeader.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mraw/MRawEvtHeader.cc	(revision 9661)
@@ -0,0 +1,380 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// 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 should 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>
+#include <fstream>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MTime.h"
+#include "MArrayB.h"
+#include "MRawRunHeader.h"
+
+ClassImp(MRawEvtHeader);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// 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;
+
+    TString str(o);
+    str.ToLower();
+
+    if (str.Contains("nogains"))
+        return;
+
+    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;
+        }
+    }
+    if (fPixLoGainOn->GetSize())
+        *fLog << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the size in bytes of the event header.
+//
+Int_t MRawEvtHeader::GetNumBytes() const
+{
+    return 36+fPixLoGainOn->GetSize();
+}
+
+// --------------------------------------------------------------------------
+//
+// Used to set the header information. This is for MC only. NEVER, NEVER
+// use this somewhere else!
+//
+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);
+}
+
+// --------------------------------------------------------------------------
+//
+// Decode the binary Time Stamp. For more detailed information see the
+// source code.
+//
+Bool_t MRawEvtHeader::DecodeTime(UInt_t abstime[2]) const
+{
+    //
+    // SuperSecond (20 bits giving hh:mm:ss)
+    // ------------
+    // 
+    // Reading the hours:
+    // Swap bits: 23->16, 22->17, 21->16, 20->19
+    //
+    abstime[0] =
+        abstime[0]>>7 & 0x00010000 |
+        abstime[0]>>5 & 0x00020000 |
+        abstime[0]>>3 & 0x00040000 |
+        abstime[0]>>1 & 0x00080000 |
+        abstime[0]    & 0xff00ffff;
+
+    // 
+    // SubSecond (24 bits giving number of clock ticks of a 5Mhz signal since 
+    // the beginning of last second, i.e., number of ns with a precision of to
+    // 200 ns) 
+    // ----------
+    //
+    // Due to a problem with one Digital Module, three of the less significant
+    // eight bits of the subsecond are corrupted. So, until new DM's arrive to
+    // La Palma, we won't use the eight first bits of the subsecond. 
+    // This reduces the precision from 200 ns to of 51.2 us.
+    //
+    abstime[1] &= 0xffffff00;
+
+    //
+    // Decode Time Stamp
+    //
+    const Byte_t h  = (abstime[0]>>18 & 0x3)*10 + (abstime[0]>>14 & 0xf);
+    const Byte_t m  = (abstime[0]>>11 & 0x7)*10 + (abstime[0]>> 7 & 0xf);
+    const Byte_t s  = (abstime[0]>> 4 & 0x7)*10 + (abstime[0]>> 0 & 0xf);
+    const UInt_t ns =  abstime[1]*200;
+
+    //
+    // Update the time stamp with the current event time.
+    // Make sure, that the time stamp was initialized correctly
+    // with the start-date/time of the run (after reading the run header)
+    //
+    if (fTime->UpdMagicTime(h, m, s, ns))
+        return kTRUE;
+
+    *fLog << warn << "WARNING - Time (" << Form("%2d:%02d:%02d,%09d", h, m, s, ns);
+    *fLog << ") in header of event #" << dec << fDAQEvtNumber << " invalid..." << endl;
+ 
+    return kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+// read the EVENT HEADER information from the input stream
+// return FALSE if there is now header anymore, else TRUE
+//
+// For version>2 we expect to have a valid time-stamp in the files.
+//
+// Updates the time stamp with the current event time.
+// Make sure, that the time stamp was initialized correctly
+// with the start-date/time of the run (after reading the run header)
+//
+// Remark: This 'feature' disallows single runs of more than 11h!
+//
+Int_t MRawEvtHeader::ReadEvt(istream &fin, UShort_t ver)
+{
+    Bool_t rc = kTRUE;
+
+    fin.read((char*)&fDAQEvtNumber, 4);  // Total=4
+    if (!fin)
+        return kFALSE;
+
+    UInt_t abstime[2];
+    fin.read((char*)abstime,        8);  // Total=12
+
+    if (ver>2)
+        if (!DecodeTime(abstime))
+            rc = kCONTINUE;
+
+    Byte_t dummy[4];
+    fin.read((char*)&fNumTrigLvl1,  4);  // Total=16
+    fin.read((char*)&fNumTrigLvl2,  4);  // Total=20
+    fin.read((char*)fTrigPattern,   8);  // Total=28
+    fin.read((char*)&fTrigType,     2);  // Total=30
+    fin.read((char*)dummy,          2);  // Total=32, was fAllLoGainOn
+    fin.read((char*)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((char*)&dummy, 4);
+
+    return fin.eof() ? kFALSE : rc;
+}
+
+void MRawEvtHeader::SkipEvt(istream &fin, UShort_t ver)
+{
+    fin.seekg(GetNumBytes(), ios::cur);
+}
+
+// --------------------------------------------------------------------------
+//
+//   Low level decoding of the trigger pattern.
+//   The trigger pattern consists of 16 bits (8+8 bits) generated by the 
+//   trigger system.
+//   The first 8 bits correspond to the trigger configuration before the
+//   prescaling, the others after prescaling.
+//   The meaning of the configuration depends on the chosen trigger table
+//   (that is how the trigger has been programmed) and must be interpreted 
+//    at higher level by the analysis. 
+//   Bit structure:
+//          not prscd | prscaled
+//           xxxx xxxx xxxx xxxx    <-- pattern (x=0,1)
+//     bit   7654 3210 7654 3210
+//          H                   L
+//
+//    e.g.   1000 0000 1000 1000 (hex: 8080) is the pattern when no
+//         L2 trigger selection and no prescaling is applied. 
+//       
+//    Up to now only fTrigPattern[0] is used.
+//
+UInt_t MRawEvtHeader::GetTriggerID() const
+{
+    return fTrigPattern[0];
+}
Index: /tags/Mars_V0-8-5/Mars/mraw/MRawEvtHeader.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mraw/MRawEvtHeader.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mraw/MRawEvtHeader.h	(revision 9661)
@@ -0,0 +1,75 @@
+#ifndef MARS_MRawEvtHeader
+#define MARS_MRawEvtHeader
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+// gcc 3.2
+//class ifstream;
+#include <iosfwd>
+
+class MTime;
+class MArrayB;
+class MRawRunHeader;
+
+class MRawEvtHeader : public MParContainer
+{
+public:
+    //
+    // Trigger Type (TT)
+    //
+    enum {
+        kTTEvent       = 0,
+        kTTPedestal    = 1,
+        kTTCalibration = 2
+    };
+
+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
+
+    Bool_t DecodeTime(UInt_t abstime[2]) const;
+
+    Int_t GetNumBytes() const;
+
+public:
+    MRawEvtHeader(const char *name=NULL, const char *title=NULL);
+    ~MRawEvtHeader();
+
+    void Init(MRawRunHeader *rh, MTime *t);
+
+    void Clear(Option_t * = NULL);
+    void Print(Option_t * = NULL) const;
+
+    void FillHeader(UInt_t, Float_t=0);
+
+    UShort_t GetTrigType() const     { return fTrigType; }
+    UInt_t   GetNumTrigLvl1() const  { return fNumTrigLvl1; }
+    UInt_t   GetNumTrigLvl2() const  { return fNumTrigLvl2; }
+    UInt_t   GetDAQEvtNumber() const { return fDAQEvtNumber; }
+    
+    UInt_t GetTriggerID() const;
+
+    Int_t ReadEvt(istream& fin, UShort_t ver);
+    void SkipEvt(istream& fin, UShort_t ver);
+
+    ClassDef(MRawEvtHeader, 1) // Parameter Conatiner for raw EVENT HEADER
+}; 
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mraw/MRawEvtPixelIter.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mraw/MRawEvtPixelIter.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mraw/MRawEvtPixelIter.cc	(revision 9661)
@@ -0,0 +1,349 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Markus Gaus 10/2002 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////////////
+//
+//  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 <TArrayC.h>
+
+#include "MRawEvtData.h"
+
+#include "MArrayS.h"
+#include "MArrayB.h"
+
+ClassImp(MRawEvtPixelIter);
+
+using namespace std;
+
+MRawEvtPixelIter::MRawEvtPixelIter(MRawEvtData *dat) : fData(dat)
+{
+    fNumHiGainSamples = dat->GetNumHiGainSamples();
+    fNumLoGainSamples = dat->GetNumLoGainSamples();
+
+    Reset();
+}
+
+// --------------------------------------------------------------------------
+//
+// 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 (HasLoGain())
+        {
+            //
+            // 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();
+    fHiGainPos  = fData->fHiGainFadcSamples->GetArray()-fNumHiGainSamples;
+    fLoGainPos  = fData->fLoGainFadcSamples->GetArray()-fNumLoGainSamples;
+    fABFlags    = fData->fABFlags->GetArray();
+
+    //
+    // In case fLoGainPixId.GetSize()=0 some root versions seems to
+    // initialize the array with NULL. This makes both cases work.
+    //
+    if (fLoGainId)
+        fLoGainId -= 1;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calls the draw-function of the actual pixel (see MRawEvtData::Draw)
+//
+void MRawEvtPixelIter::Draw(Option_t *t)
+{ 
+    fData->Draw(Form("%s%d", t, *fHiGainId));
+}
+
+// --------------------------------------------------------------------------
+//
+// returns the sum of all hi gain fadc samples of the actual pixel
+//
+ULong_t MRawEvtPixelIter::GetSumHiGainSamples() const
+{
+    //
+    // return the sum of the hi gain samples of the present pixel
+    //
+    Byte_t *ptr = fHiGainPos;
+    const Byte_t *end = ptr + fNumHiGainSamples;
+
+    ULong_t sum=0;
+
+    do sum += *ptr++;
+    while (ptr != end);
+
+    return sum;
+}
+
+// --------------------------------------------------------------------------
+//
+// returns the sum of squares of all hi gain fadc sample of the actual pixel
+//
+ULong_t MRawEvtPixelIter::GetSumSqrHiGainSamples() const
+{
+    //
+    // return the sum of the squares of the hi gain samples of the present pixel
+    //
+    Byte_t *ptr = fHiGainPos;
+    const Byte_t *end = ptr + fNumHiGainSamples;
+
+    ULong_t sum=0;
+
+    do sum += (*ptr)*(*ptr);
+    while (++ptr != end);
+
+    return sum;
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the variance (sigma^2) of the HiGainSamples
+//
+Float_t MRawEvtPixelIter::GetVarHiGainSamples() const
+{
+    Byte_t *ptr = fHiGainPos;
+    const Byte_t *end = ptr + fNumHiGainSamples;
+
+    ULong_t sum=0;
+    ULong_t sqsum=0;
+
+    do {
+        sum += *ptr;
+        sqsum += (*ptr)*(*ptr);
+    } while (++ptr != end);
+
+    return (sqsum-(Float_t)sum*sum/fNumHiGainSamples)/(fNumHiGainSamples-1);
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the index of the FADC slice the maximum signal in. If the highest
+// slices have the same value the last one is returned.
+//
+Byte_t MRawEvtPixelIter::GetIdxMaxHiGainSample() const
+{
+    Byte_t *ptr = fHiGainPos+1;
+    Byte_t *max = fHiGainPos;
+    const Byte_t *end = ptr + fNumHiGainSamples;
+
+    do if (*ptr>*max) max = ptr;
+    while (++ptr != end);
+
+    return max-fHiGainPos;
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the index of the FADC slice the maximum signal in. If no lo-gains
+// are available -1 is returned. If the highest slices have the same value the
+// last one is returned.
+//
+Short_t MRawEvtPixelIter::GetIdxMaxLoGainSample(const Byte_t lofirst) const
+{
+
+  if (!HasLoGain())
+    return -1; // means: not found
+  
+  Byte_t *ptr = fLoGainPos+lofirst+1;
+  Byte_t *max = fLoGainPos+lofirst;
+  const Byte_t *end = fLoGainPos + fNumLoGainSamples;
+	
+  do if (*ptr>*max) max = ptr;
+  while (++ptr != end);
+  
+  return max-fLoGainPos;
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the index of the maximum FADC slice from high gain at first. If 
+// high gain is saturated it returns the low gain one.
+// If no lo-gains are existing and the hi-gains have saturating values
+// a negative value (-1) is returned.
+// 
+Short_t MRawEvtPixelIter::GetIdxMaxHiLoGainSample() const
+{
+    Byte_t max  = 0;
+    Char_t maxi = 0;
+
+    for (int i=fNumHiGainSamples-1; i>=0; i--)
+        if (fHiGainPos[i]>max)
+        {
+            max  = fHiGainPos[i];
+            maxi = i;
+        }
+
+    return max<0xff ? maxi : GetIdxMaxLoGainSample();
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the maximum signal of all sliced in the hi gain samples
+//
+Byte_t MRawEvtPixelIter::GetMaxHiGainSample() const
+{
+    Byte_t max = 0;
+
+    for (int i=0; i<fNumHiGainSamples; i++)
+        if (fHiGainPos[i]>max)
+            max = fHiGainPos[i];
+
+    return max;
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the maximum signal of all sliced in the hi gain samples
+//
+Byte_t MRawEvtPixelIter::GetMaxLoGainSample() const
+{
+
+    Byte_t max = 0;
+
+    for (int i=fNumLoGainSamples-1; i>=0; i--)
+        if (fLoGainPos[i]>max)
+            max = fLoGainPos[i];
+
+    return max;
+}
+
+// --------------------------------------------------------------------------
+//
+// returns the sum of all lo gain fadc samples of the actual pixel.
+// if no lo gain information is available 0 is returned.
+//
+ULong_t MRawEvtPixelIter::GetSumLoGainSamples() const
+{
+    //
+    // return the sum of the lo gain samples of the present pixel
+    //
+    if (!HasLoGain())
+        return 0;
+
+    Byte_t *ptr = fLoGainPos;
+    const Byte_t *end = ptr + fNumLoGainSamples;
+
+    ULong_t sum=0;
+
+    do sum += *ptr++;
+    while (ptr != end);
+
+    return sum;
+}
+
+// --------------------------------------------------------------------------
+//
+// returns the sum of squares of all hi gain fadc sample of the actual pixel
+//
+ULong_t MRawEvtPixelIter::GetSumSqrLoGainSamples() const
+{
+    //
+    // return the sum of the lo gain samples squares of the present pixel
+    //
+    if (!HasLoGain())
+        return 0;
+
+    Byte_t *ptr = fLoGainPos;
+    const Byte_t *end = ptr + fNumLoGainSamples;
+
+    ULong_t sum=0;
+
+    do sum += (*ptr)*(*ptr);
+    while (++ptr != end);
+
+    return sum;
+}
Index: /tags/Mars_V0-8-5/Mars/mraw/MRawEvtPixelIter.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mraw/MRawEvtPixelIter.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mraw/MRawEvtPixelIter.h	(revision 9661)
@@ -0,0 +1,133 @@
+#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
+
+    Char_t   *fABFlags;         //! pointer to AB flags
+
+    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 *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;
+    }
+
+    Byte_t  GetNumHiGainSamples() const    { return fNumHiGainSamples ; }
+    Byte_t  GetNumLoGainSamples() const    { return fNumLoGainSamples ; }
+
+    ULong_t GetSumHiGainSamples() const;
+    ULong_t GetSumSqrHiGainSamples() const;
+    Float_t GetVarHiGainSamples() const;
+
+    Byte_t  GetMaxHiGainSample() const;
+    Byte_t  GetMaxLoGainSample() const;
+    Byte_t  GetIdxMaxHiGainSample() const;
+    Short_t GetIdxMaxLoGainSample(const Byte_t lofirst=0) const;
+    Short_t GetIdxMaxHiLoGainSample() const;
+
+    Bool_t HasLoGain() const
+    {
+        //
+        // return kTRUE  the lo gains exist for the actual pixel, else return kFALSE
+        //
+        return fLoGainId && *fHiGainId==*fLoGainId;
+    }
+    Bool_t HasABFlag() const
+    {
+        //
+        // return kTRUE  the lo gains exist for the actual pixel, else return kFALSE
+        //
+        return TESTBIT(fABFlags[GetPixelId()/8], GetPixelId()%8);
+    }
+    Byte_t GetABFlag() const
+    {
+        //
+        // return kTRUE  the lo gains exist for the actual pixel, else return kFALSE
+        //
+        return (Byte_t)fABFlags[GetPixelId()/8];
+    }
+
+    Byte_t *GetLoGainSamples() const
+    {
+        //
+        // return a pointer to the fadc samples of the lo gains if they exist
+        // for the actual pixel, else return zero
+        //
+        return HasLoGain() ? fLoGainPos : NULL;
+    }
+
+    ULong_t GetSumLoGainSamples() const;
+    ULong_t GetSumSqrLoGainSamples() const;
+
+    void Reset();
+
+    void Draw(Option_t *t="GRAPH");
+
+    ClassDef(MRawEvtPixelIter, 0) // iterates over all pixels of one MRawEvtData object
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mraw/MRawFileRead.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mraw/MRawFileRead.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mraw/MRawFileRead.cc	(revision 9661)
@@ -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@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  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.
+//
+//  Use SetInterleave() if you don't want to read all events, eg
+//    SetInterleave(5) reads only each 5th event.
+//
+//  Input Containers:
+//   -/-
+//
+//  Output Containers:
+//   MRawRunHeader, MRawEvtHeader, MRawEvtData, MRawCrateArray, MRawEvtTime
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MRawFileRead.h"
+
+#include <errno.h>
+#include <fstream>
+
+#include <TSystem.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);
+
+using namespace std;
+
+/*  ----------- 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)
+    : fFileNames(NULL), fNumFile(0), fIn(NULL), fParList(NULL), fInterleave(1)
+{
+    fName  = name  ? name  : "MRawFileRead";
+    fTitle = title ? title : "Read task to read DAQ binary files";
+
+    fFileNames = new TList;
+    fFileNames->SetOwner();
+
+    if(fname!=NULL)
+      AddFile(fname);
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor. Delete input stream.
+//
+MRawFileRead::~MRawFileRead()
+{
+    delete fFileNames;
+    if (fIn)
+        delete fIn;
+}
+
+// --------------------------------------------------------------------------
+//
+// Add a new file to a list of files to be processed, Returns the number
+// of files added. (We can enhance this with a existance chack and
+// wildcard support)
+//
+Int_t MRawFileRead::AddFile(const char *fname, Int_t entries)
+{
+    TNamed *name = new TNamed(fname, "");
+    fFileNames->AddLast(name);
+    return 1;
+
+}
+
+// --------------------------------------------------------------------------
+//
+// This opens the next file in the list and deletes its name from the list.
+//
+Bool_t MRawFileRead::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
+    //
+    TObject *file = fFileNames->At(fNumFile);
+    if (!file)
+        return kFALSE;
+
+    //
+    // open the file which is the first one in the chain
+    //
+    const char *name = file->GetName();
+
+    const char *expname = gSystem->ExpandPathName(name);
+    fIn = new ifstream(expname);
+
+    const Bool_t noexist = !(*fIn);
+    if (noexist)
+    {
+        *fLog << err << "Cannot open file " << expname << ": ";
+        *fLog << strerror(errno) << endl;
+    }
+    else
+        *fLog << inf << "Open file: '" << name << "'" << endl;
+
+    delete [] expname;
+
+    if (noexist)
+        return kFALSE;
+
+    fNumFile++;
+
+    //
+    // Read RUN HEADER (see specification) from input stream
+    //
+    if (!fRawRunHeader->ReadEvt(*fIn))
+        return kFALSE;
+
+    if (!(*fIn))
+    {
+        *fLog << err << "Error: Accessing file '" << name << "'" << endl;
+        return kFALSE;
+    }
+
+    //
+    // Print Run Header
+    //
+    fRawRunHeader->Print();
+    *fRawEvtTime = fRawRunHeader->GetRunStart();
+
+    fNumEvents += fRawRunHeader->GetNumEvents();
+
+    //
+    // Give the run header information to the 'sub-classes'
+    // Run header must be valid!
+    //
+    fRawEvtHeader->Init(fRawRunHeader, fRawEvtTime);
+    fRawEvtData  ->Init(fRawRunHeader, fRawCrateArray);
+
+    //
+    // Search for MTaskList
+    //
+    MTask *tlist = (MTask*)fParList->FindObject("MTaskList");
+    if (!tlist)
+    {
+        *fLog << err << dbginf << "MTaskList not found... abort." << endl;
+        return kFALSE;
+    }
+
+    //
+    // A new file has been opened and new headers have been read.
+    //  --> ReInit tasklist
+    //
+    return tlist->ReInit(fParList);
+}
+
+// --------------------------------------------------------------------------
+//
+// Return file name of current file.
+//
+const TString MRawFileRead::GetFileName() const
+{
+    const TObject *file = fFileNames->At(fNumFile-1);
+    return file ? file->GetName() : "";
+}
+
+// --------------------------------------------------------------------------
+//
+// Restart with the first file
+//
+Bool_t MRawFileRead::Rewind()
+{
+    fNumFile=0;
+    fNumEvents=0;
+    return OpenNextFile();
+}
+
+// --------------------------------------------------------------------------
+//
+// 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.
+//
+Int_t MRawFileRead::PreProcess(MParList *pList)
+{
+    fParList = pList;
+
+    //
+    // open the input stream
+    // first of all check if opening the file in the constructor was
+    // successfull
+    //
+    if (!MRawRead::PreProcess(pList))
+        return kFALSE;
+
+    //
+    // Now open next (first) file
+    //
+//      if (!Rewind())
+//          return kFALSE;
+
+
+    fNumFile=0;
+    fNumEvents=0; 
+
+    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
+//
+Int_t MRawFileRead::Process()
+{
+    while (1)
+    {
+        if (fIn)
+        {
+            //
+            // skip events if requested
+            //
+            if (fInterleave>1 && GetNumExecutions()%fInterleave>0 && fIn->peek()!=EOF)
+            {
+                SkipEvent(*fIn);
+                return kCONTINUE;
+            }
+
+            //
+            // Read a single event from file
+            //
+            const Bool_t rc = ReadEvent(*fIn);
+            if (rc!=kFALSE)
+                return rc;
+        }
+
+        //
+        // If an event could not be read from file try to open new file
+        //
+        if (!OpenNextFile())
+            return kFALSE;
+    }
+    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.
+//
+Int_t MRawFileRead::PostProcess()
+{
+    //
+    // Sanity check for the number of events
+    //
+    if (fNumEvents==GetNumExecutions()-1 || GetNumExecutions()==0)
+        return kTRUE;
+
+    *fLog << warn << dec;
+    *fLog << "Warning - number of read events (" << GetNumExecutions()-1;
+    *fLog << ") doesn't match number in run header(s) (";
+    *fLog << fNumEvents << ")." << endl;
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mraw/MRawFileRead.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mraw/MRawFileRead.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mraw/MRawFileRead.h	(revision 9661)
@@ -0,0 +1,44 @@
+#ifndef MARS_MRawFileRead
+#define MARS_MRawFileRead
+
+#ifndef MARS_MRawRead
+#include "MRawRead.h"
+#endif
+
+class TList;
+class MTaskList;
+
+class MRawFileRead : public MRawRead
+{
+private:
+    TList     *fFileNames; // list of file names
+    UInt_t     fNumFile;   //! number of next file
+    UInt_t     fNumEvents; //! input stream (file to read from)
+
+    ifstream  *fIn;        //! input stream (file to read from)
+
+    MParList  *fParList;   //! tasklist to call ReInit from
+
+    UInt_t     fInterleave;
+
+    Bool_t OpenNextFile();
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
+public:
+    MRawFileRead(const char *filename, const char *name=NULL, const char *title=NULL);
+    ~MRawFileRead();
+
+    void SetInterleave(UInt_t i) { fInterleave = i; }
+
+    const TString GetFileName() const;
+
+    Int_t  AddFile(const char *fname, Int_t entries=-1);
+    Bool_t Rewind();
+
+    ClassDef(MRawFileRead, 0)	// Task to read the raw data binary file
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mraw/MRawFileWrite.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mraw/MRawFileWrite.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mraw/MRawFileWrite.cc	(revision 9661)
@@ -0,0 +1,271 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+////////////////////////////////////////////////////////////////////////
+//
+//  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);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// 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
+    //
+    TString str(fname);
+    if (!str.EndsWith(".root", TString::kIgnoreCase))
+        str += ".root";
+
+    fOut = new TFile(str, 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
+//  - 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.
+//
+Int_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;
+    }
+
+    fTime = (MTime*)pList->FindObject("MTime");
+    if (!fTime)
+    {
+        *fLog << err << dbginf << "MTime 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
+    //
+    fTRunHeader = new TTree("RunHeaders", "Run headers of all runs in this file");
+    fTRunHeader->Branch("MRawRunHeader.", "MRawRunHeader", &fRawRunHeader, 32000);
+
+    //
+    // create data trees for the three types of data
+    //
+    fTData        = new TTree("Events",      "Normal Triggered Events");
+    fTPedestal    = new TTree("Pedestals",   "Pedestal Triggered Events");
+    fTCalibration = new TTree("Calibration", "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",          &fTime,          32000);
+    fTPedestal   ->Branch("MTime.",          "MTime",          &fTime,          32000);
+    fTCalibration->Branch("MTime.",          "MTime",          &fTime,          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;
+}
+
+// --------------------------------------------------------------------------
+//
+// Write the run header information to the file
+//
+Bool_t MRawFileWrite::ReInit(MParList *pList)
+{
+    fTRunHeader->Fill();
+    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.
+//
+Int_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 MRawEvtHeader::kTTEvent:
+        fTData->Fill();
+        return kTRUE;
+
+    case MRawEvtHeader::kTTPedestal:
+        fTPedestal->Fill();
+        return kTRUE;
+
+    case MRawEvtHeader::kTTCalibration:
+        fTCalibration->Fill();
+        return kTRUE;
+    }
+
+    *fLog << warn << dbginf << "Got wrong number for the trigger type: " << type;
+    *fLog << " - skipped" << endl;
+
+    return kCONTINUE;
+}
+
Index: /tags/Mars_V0-8-5/Mars/mraw/MRawFileWrite.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mraw/MRawFileWrite.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mraw/MRawFileWrite.h	(revision 9661)
@@ -0,0 +1,52 @@
+#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          *fTime;
+    MRawRunHeader  *fRawRunHeader;
+    MRawEvtHeader  *fRawEvtHeader;
+    MRawEvtData    *fRawEvtData;
+    MRawCrateArray *fRawCrateArray;
+
+    TTree *fTData;                  //!
+    TTree *fTPedestal;              //!
+    TTree *fTCalibration;           //!
+
+    TTree *fTRunHeader;             //!
+
+    TFile *fOut;                    //!
+
+    Int_t  PreProcess(MParList *pList);
+    Bool_t ReInit(MParList *pList);
+    Int_t  Process();
+
+public:
+    MRawFileWrite(const char *fname,
+                  const Option_t *opt="RECREATE",
+                  const char *ftitle="Untitled",
+                  const Int_t comp=2,
+                  const char *name=NULL, const char *title=NULL);
+    ~MRawFileWrite();
+
+    ClassDef(MRawFileWrite, 0)	// Task to write the raw data containers to a root file
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mraw/MRawRead.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mraw/MRawRead.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mraw/MRawRead.cc	(revision 9661)
@@ -0,0 +1,230 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          
+//  MRawRead
+//                                                                          
+//  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 "MRawRead.h"
+
+#include <fstream>
+
+#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(MRawRead);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. It tries to open the given file.
+//
+MRawRead::MRawRead(const char *name, const char *title)
+    : fForceMode(kFALSE)
+{
+    fName  = name  ? name  : "MRawRead";
+    fTitle = title ? title : "Bas class for reading DAQ files";
+}
+
+// --------------------------------------------------------------------------
+//
+// 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.
+//
+Int_t MRawRead::PreProcess(MParList *pList)
+{
+    if (!OpenStream())
+        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");
+    if (!fRawEvtTime)
+        return kFALSE;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// This is a workaround for the oldest runs (file version<3)
+// for which no time stamp was available.
+// For this runs a fake time stamp is created
+//
+// Be carefull: This is NOT thread safe!
+//
+void MRawRead::CreateFakeTime() const
+{
+    static Double_t tm = 0; // Range of roughly 8min
+    const UInt_t ct = (*fRawCrateArray)[0]->GetFADCClockTick();
+
+    tm = ct<tm ? fmod(tm, (UInt_t)(-1))+(UInt_t)(-1)+ct : ct;
+
+    const Double_t mhz = 9.375;                        // [1e6 ticks/s]
+    const Double_t t   = tm/mhz;                       // [us]
+    const UInt_t ns    = (UInt_t)fmod(t*1e3, 1e6);
+    //const UShort_t ms  = (UShort_t)fmod(t/1e3, 1e3);
+    const Byte_t s     = (Byte_t)fmod(t/1e6, 60);
+
+    // Create an artificial time stamp!
+    UInt_t m = (Byte_t)fmod(t/60e6, 60);
+    //const Byte_t h     = (Byte_t)(t/3600e6);
+    m += fRawRunHeader->GetRunNumber()*10;
+    m %= 360; // 6h
+
+    fRawEvtTime->UpdMagicTime(m/60, m%60, s, ns);
+}
+
+// --------------------------------------------------------------------------
+//
+// Read a single event from the stream
+//
+Bool_t MRawRead::ReadEvent(istream &fin)
+{
+    //
+    //  Get file format version
+    //
+    const UShort_t ver = fRawRunHeader->GetFormatVersion();
+
+    //
+    // Read in the next EVENT HEADER (see specification),
+    // if there is no next event anymore stop eventloop
+    //
+    const Int_t rc = fRawEvtHeader->ReadEvt(fin, ver);
+    if (rc==kCONTINUE && fForceMode==kFALSE)
+    {
+        *fLog << err << "Problem found reading the event header... abort." << endl;
+        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, ver);
+        if (!fin)
+            return kFALSE;
+
+        fRawEvtData->ReadEvt(fin);
+        if (!fin)
+            return kFALSE;
+    }
+
+    // This is a workaround for the oldest runs (version<3)
+    // for which no time stamp was available.
+    // For this runs a fake time stamp is created
+    if (ver<3)
+        CreateFakeTime();
+
+    if (rc==kCONTINUE && fForceMode==kTRUE)
+        return kCONTINUE;
+
+    return kTRUE;
+}
+
+void MRawRead::SkipEvent(istream &fin)
+{
+    //
+    //  Get file format version
+    //
+    const UShort_t ver = fRawRunHeader->GetFormatVersion();
+    fRawEvtHeader->SkipEvt(fin, ver);
+
+    const UShort_t nc = fRawRunHeader->GetNumCrates();
+    for (int i=0; i<nc; i++)
+    {
+        fRawCrateArray->GetEntry(i)->SkipEvt(fin, ver);
+        fRawEvtData->SkipEvt(fin);
+    }
+}
Index: /tags/Mars_V0-8-5/Mars/mraw/MRawRead.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mraw/MRawRead.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mraw/MRawRead.h	(revision 9661)
@@ -0,0 +1,46 @@
+#ifndef MARS_MRawRead
+#define MARS_MRawRead
+
+#ifndef MARS_MRead
+#include "MRead.h"
+#endif
+
+class MTime;
+class MParList;
+class MRawRunHeader;
+class MRawEvtHeader;
+class MRawEvtData;
+class MRawCrateArray;
+
+class MRawRead : public MRead
+{
+protected:
+    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
+
+    Bool_t          fForceMode;     // Force mode skipping defect events
+
+    void CreateFakeTime() const;
+
+    Bool_t ReadEvent(istream &fin);
+    void   SkipEvent(istream &fin);
+    Int_t  PreProcess(MParList *pList);
+
+private:
+    virtual Bool_t OpenStream() { return kTRUE; }
+
+public:
+    MRawRead(const char *name=NULL, const char *title=NULL);
+
+    UInt_t GetEntries() { return 0; }
+    Bool_t Rewind() {return kTRUE; }
+
+    void SetForceMode(Bool_t b=kTRUE) { fForceMode = b; }
+
+    ClassDef(MRawRead, 0)	// Task to read the raw data binary file
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mraw/MRawRunHeader.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mraw/MRawRunHeader.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mraw/MRawRunHeader.cc	(revision 9661)
@@ -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@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MRawRunHeader
+//
+// Root storage container for the RUN HEADER information
+//
+//  Format Version 2:
+//  -----------------
+//   - removed mjd from data
+//   - added start time
+//   - added stop  time
+//
+//  Class Version 2:
+//  ----------------
+//   - removed fMJD, fYear, fMonth, fDay
+//   - added fRunStart
+//   - added fRunStop
+// 
+//  Class Version 1:
+//  ----------------
+//   - first implementation
+//
+////////////////////////////////////////////////////////////////////////////
+
+#include "MRawRunHeader.h"
+
+#include <fstream>
+#include <iomanip>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MArrayS.h"
+
+ClassImp(MRawRunHeader);
+
+using namespace std;
+
+const UShort_t MRawRunHeader::kMagicNumber      = 0xc0c0;
+const Byte_t   MRawRunHeader::kMaxFormatVersion =      3;
+
+// --------------------------------------------------------------------------
+//
+// 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);
+
+    fFormatVersion=0;
+    fSoftVersion=0;
+    fRunType=kRTNone;  // use 0xffff for invalidation, 0 means: Data run
+    fRunNumber=0;
+    fProjectName[0]=0;
+    fSourceName[0]=0;
+    fSourceEpochChar[0]=0;
+    fSourceEpochDate=0;
+    fNumCrates=0;
+    fNumPixInCrate=0;
+    fNumSamplesLoGain=0;
+    fNumSamplesHiGain=0;
+    fNumEvents=0;
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor. Deletes the 'pixel-assignment-array'
+//
+MRawRunHeader::~MRawRunHeader()
+{
+    delete fPixAssignment;
+}
+
+// --------------------------------------------------------------------------
+//
+// Read in one run header from the binary file
+//
+Bool_t MRawRunHeader::ReadEvt(istream& fin)
+{
+    //
+    // read one RUN HEADER from the input stream
+    //
+    fMagicNumber = 0;
+
+    fin.read((char*)&fMagicNumber, 2);          // Total=2
+
+    //
+    // check whether the the file has the right file type or not
+    //
+    if (fMagicNumber != kMagicNumber && fMagicNumber != kMagicNumber+1)
+    {
+        *fLog << err << "Error: Wrong Magic Number (0x" << hex << fMagicNumber << "): Not a Magic File!" << endl;
+        return kFALSE;
+    }
+
+    if (fMagicNumber == kMagicNumber+1)
+        *fLog << warn << "WARNING - This file maybe broken (0xc0c1) - DAQ didn't close it correctly!" << endl;
+
+    Byte_t dummy[16];
+
+    fin.read((char*)&fFormatVersion,    2);     // Total=4
+    if (fFormatVersion>kMaxFormatVersion)
+    {
+        *fLog << err << "WARNING - File vormat V" << fFormatVersion << " not implemented!" << endl;
+        return kFALSE;
+    }
+
+    fin.read((char*)&fSoftVersion,      2);     // Total=6
+    fin.read((char*)&fRunType,          2);     // Total=8
+    fin.read((char*)&fRunNumber,        4);     // Total=12
+    fin.read((char*)&fProjectName,     22);     // Total=34
+    fin.read((char*)&fSourceName,      12);     // Total=46
+    fin.read((char*)dummy,              4); // was RA  (moved to tracking system)
+    fin.read((char*)dummy,              4); // was DEC (moved to tracking system)
+    fin.read((char*)&fSourceEpochChar,  2);     // Total=56
+    fin.read((char*)&fSourceEpochDate,  2);     // Total=58
+    if (fFormatVersion<2)                       // Total += 10
+    {
+        UShort_t y, m, d;
+        fin.read((char*)dummy, 4); // Former fMJD[4],
+        fin.read((char*)&y,    2); // Former fDateYear[2]
+        fin.read((char*)&m,    2); // Former fDateMonth[2]
+        fin.read((char*)&d,    2); // Former fDateDay[2]
+        fRunStart.Set(y, m, d, 0, 0, 0, 0);
+    }
+    fin.read((char*)&fNumCrates,        2);     // Total=60
+    fin.read((char*)&fNumPixInCrate,    2);     // Total=62
+    fin.read((char*)&fNumSamplesLoGain, 2);     // Total=64
+    fin.read((char*)&fNumSamplesHiGain, 2);     // Total=66
+    fin.read((char*)&fNumEvents,        4);     // Total=70
+    if (fFormatVersion>1)
+    {
+        fRunStart.ReadBinary(fin);              // Total += 7
+        fRunStop.ReadBinary(fin);               // Total += 7
+    }
+
+    //
+    // calculate size of array, create it and fill it
+    //
+    Int_t nPixel = fNumCrates*fNumPixInCrate;
+    fPixAssignment->Set(nPixel);
+
+    fin.read((char*)fPixAssignment->GetArray(), nPixel*2);
+    fin.read((char*)&dummy, 16);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the run type as string ("Data", "Pedestal", ...), for example
+// to print it as readable text.
+//
+const char *MRawRunHeader::GetRunTypeStr() const
+{
+    switch (fRunType)
+    {
+    case kRTData:
+        return "Data";
+    case kRTPedestal:
+        return "Pedestal";
+    case kRTCalibration:
+        return "Calibration";
+    case kRTPointRun:
+        return "Point-Run";
+    case kRTMonteCarlo:
+        return "Monte Carlo";
+    case kRTNone:
+        return "<none>";
+    default:
+        return "<unknown>";
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// print run header information on *fLog
+//
+void MRawRunHeader::Print(Option_t *t) const
+{
+    *fLog << all << endl;
+    *fLog << "MagicNumber:  0x" << hex << fMagicNumber << " - ";
+    switch (fMagicNumber)
+    {
+    case kMagicNumber:   *fLog << "OK";               break;
+    case kMagicNumber+1: *fLog << "File not closed!"; break;
+    default:             *fLog << "Wrong!";           break;
+    }
+    *fLog << endl;
+    *fLog << "Version:      " << dec << "Format=" << fFormatVersion << "  ";
+    *fLog << "Software=" << fSoftVersion << endl;
+    *fLog << "RunNumber:    " << fRunNumber << " (Type=" << GetRunTypeStr() << ")" << endl;
+    *fLog << "ProjectName: '" << fProjectName << "'" << endl;
+    *fLog << "Source:      '" << fSourceName << "' " << "  ";
+    *fLog << fSourceEpochChar << dec << fSourceEpochDate << endl;
+    *fLog << "Run Start:    " << fRunStart << endl;
+    *fLog << "Run Stop:     " << fRunStop << 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 << inf << hex;
+    for (int i=0; i<GetNumPixel(); i++)
+        *fLog << setfill('0') << setw(3) << (*fPixAssignment)[i] << " ";
+
+    *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 which are markes as connected in the
+// pix assignment (>0)
+//
+UShort_t MRawRunHeader::GetNumConnectedPixels() const
+{
+    const Int_t num = fPixAssignment->GetSize();
+
+    UShort_t rc = 0;
+    for (int i=0; i<num; i++)
+    {
+        if (GetPixAssignment(i)>0)
+            rc++;
+    }
+    return rc;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the maximum id which exists in the pix assignment
+//
+UShort_t MRawRunHeader::GetMaxPixId() const
+{
+    const Int_t num = fPixAssignment->GetSize();
+
+    UShort_t rc = 0;
+    for (int i=0; i<num; i++)
+        rc = TMath::Max(GetPixAssignment(i), rc);
+
+    return rc;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the number of pixel in this event.
+//
+// WARNING: This is the number of pixels stored in this file which is
+//          a multiple of the number of pixels per crate and in general
+//          a number which is larger than the camera size!
+//
+//          To know the range of the pixel indices please use the geometry
+//          container!
+//
+UShort_t MRawRunHeader::GetNumPixel() const
+{
+    return fPixAssignment->GetSize();
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns absolute size in bytes of the run header as read from a raw file.
+// This must be done _after_ the header is read, because the header doesn't
+// have a fixed size (used in MRawSocketRead)
+//
+Int_t MRawRunHeader::GetNumTotalBytes() const
+{
+    switch (fFormatVersion)
+    {
+    case 1:
+        return 80+fNumCrates*fNumPixInCrate*2+16;
+    case 2:
+        return 84+fNumCrates*fNumPixInCrate*2+16;
+    }
+    return 0;
+}
Index: /tags/Mars_V0-8-5/Mars/mraw/MRawRunHeader.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mraw/MRawRunHeader.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mraw/MRawRunHeader.h	(revision 9661)
@@ -0,0 +1,117 @@
+#ifndef MARS_MRawRunHeader
+#define MARS_MRawRunHeader
+///////////////////////////////////////////////////////////////////////
+//                                                                   //
+// MRunHeader                                                        //
+//                                                                   //
+///////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MTime
+#include "MTime.h"
+#endif
+
+class TBuffer;
+class MArrayS;
+
+class MRawRunHeader : public MParContainer
+{
+public:
+    //
+    // enum for the Run Type. Monte Carlo Runs have
+    // to have a value greater than 255 (>0xff)
+    //
+    enum {
+        kRTData        = 0x0000,
+        kRTPedestal    = 0x0001,
+        kRTCalibration = 0x0002,
+        kRTPointRun    = 0x0007,
+        kRTMonteCarlo  = 0x0100,
+        kRTNone        = 0xffff
+    };
+
+    //
+    // Magic number to detect the magic file type
+    //
+    static const UShort_t kMagicNumber;
+    static const Byte_t   kMaxFormatVersion;
+
+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];
+    Char_t    fSourceEpochChar[2];
+    UShort_t  fSourceEpochDate;
+    UShort_t  fNumCrates;
+    UShort_t  fNumPixInCrate;
+    UShort_t  fNumSamplesLoGain;
+    UShort_t  fNumSamplesHiGain;
+    UInt_t    fNumEvents;
+    MTime     fRunStart;
+    MTime     fRunStop;
+    MArrayS  *fPixAssignment;
+
+public:
+    MRawRunHeader(const char *name=NULL, const char *title=NULL);
+    ~MRawRunHeader();
+
+    // This is to be used in the MC chain only!
+    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; }
+    void SetRunTime(Float_t start, Float_t stop)
+    { fRunStart.SetMjd(start); fRunStop.SetMjd(stop); }
+
+    // This is to get the numbers...
+    UShort_t GetMagicNumber() const       { return fMagicNumber; }
+    UShort_t GetFormatVersion() const     { return fFormatVersion; }
+    UShort_t GetSoftVersion() const       { return fSoftVersion; }
+    UInt_t   GetRunNumber() const         { return fRunNumber; }
+    UShort_t GetRunType() const           { return fRunType; }
+    const Char_t *GetRunTypeStr() const;
+    const Char_t *GetProjectName() const { return fProjectName; }
+    const Char_t *GetSourceName() const  { return fSourceName; }
+    const Char_t *GetSourceEpocheChar() const { return fSourceEpochChar; }
+    UShort_t GetSourceEpocheDate() const  { return fSourceEpochDate; }
+    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; }
+    const MTime &GetRunStart() const      { return fRunStart; }
+    const MTime &GetRunEnd() const        { return fRunStop; }
+    UShort_t GetPixAssignment(UShort_t i) const;
+    UShort_t GetMaxPixId() const;
+    UShort_t GetNumConnectedPixels() const;
+
+    UInt_t GetNumSamplesPerCrate() const
+    {
+        return fNumPixInCrate*(fNumSamplesLoGain+fNumSamplesHiGain);
+    }
+
+    UShort_t GetNumPixel() const;
+    Int_t GetNumTotalBytes() const;
+
+    Bool_t IsMonteCarloRun() const { return fRunType>0x00ff; }
+
+    void Print(Option_t *t=NULL) const;
+
+    Bool_t ReadEvt(istream& fin);
+
+    ClassDef(MRawRunHeader, 2)	// storage container for general info
+};
+#endif
Index: /tags/Mars_V0-8-5/Mars/mraw/MRawSocketRead.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mraw/MRawSocketRead.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mraw/MRawSocketRead.cc	(revision 9661)
@@ -0,0 +1,292 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 10/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MRawSocketRead
+//
+//  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
+//   MTime
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MRawSocketRead.h"
+
+#include <stdlib.h>  // atoi
+
+#include <TArrayC.h> // TAraayC
+
+#include "MReadSocket.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MEvtLoop.h"
+
+#include "MTime.h"
+#include "MRawRunHeader.h"
+#include "MRawEvtHeader.h"
+#include "MRawEvtData.h"
+#include "MRawCrateData.h"
+#include "MRawCrateArray.h"
+
+#include "MStatusDisplay.h"
+
+ClassImp(MRawSocketRead);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. It tries to open the given file.
+//
+MRawSocketRead::MRawSocketRead(const char *name, const char *title)
+    : fIn(NULL), fPort(-1)
+{
+    fName  = name  ? name  : "MRawSocketRead";
+    fTitle = title ? title : "Task to read DAQ binary data from tcp/ip socket";
+
+    fIn = new MReadSocket;
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor. Delete input stream.
+//
+MRawSocketRead::~MRawSocketRead()
+{
+    delete fIn;
+}
+
+// --------------------------------------------------------------------------
+//
+// Open the socket. This blocks until the connection has been established,
+// an error occured opening the connection or the user requested to
+// quit the application.
+//
+Bool_t MRawSocketRead::OpenSocket()
+{
+    if (fDisplay)
+        fDisplay->SetStatusLine2(Form("Waiting for connection on port #%d...", fPort));
+
+    //
+    // Open socket connection
+    //
+    while (1)
+    {
+        //
+        // If port could be opened eveything is ok
+        //
+        if (fIn->Open(fPort))
+            return kTRUE;
+
+        //
+        // If a MStatusDisplay is attached the user might have
+        // requested to quit the application
+        //
+        if (fDisplay)
+            switch (fDisplay->CheckStatus())
+            {
+            case MStatusDisplay::kFileClose:
+            case MStatusDisplay::kFileExit:
+                *fLog << inf << "MRawSocketRead::PreProcess - MStatusDisplay triggered exit." << endl;
+                return kFALSE;
+            default:
+                break;
+            }
+
+        //
+        // If an error occured during opening the socket stop
+        //
+        if (fIn->fail())
+            break;
+    }
+
+    *fLog << err << "ERROR - Cannot open port #" << fPort << endl;
+
+    return kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+// 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
+//   MTime <output>           if not found it is created
+//
+// 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.
+//
+Int_t MRawSocketRead::PreProcess(MParList *pList)
+{
+    if (!OpenSocket())
+        return kFALSE;
+
+    if (!MRawRead::PreProcess(pList))
+        return kFALSE;
+
+    fParList = pList;
+    fRunNumber = (UInt_t)-1;
+    fEvtNumber = (UInt_t)-1;
+
+    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
+//
+Int_t MRawSocketRead::Process()
+{
+    //
+    // Tag which could possibly be used for synchronizing the
+    // data stream. At the moment we check only its correctness.
+    // Synchronisation seems to work well - Why?
+    //
+    char dummy[4];
+    fIn->read(dummy, 4);   // \nEVT
+
+    if (!(dummy[0]=='\n' && dummy[1]=='E' && dummy[2]=='V' &&dummy[3]=='T'))
+    {
+        *fLog << warn << "EVT tag not found. Stream out of sync. Please try to restart..." << endl;
+        // FIXME: Synchronization missing...
+        return kFALSE;
+    }
+
+    //
+    // No we get some size information (each 5 bytes ascii)
+    //
+    char sizecc[6] = {0,0,0,0,0,0}; // 5 bytes plus trailing 0-byte
+    char sizerh[6] = {0,0,0,0,0,0}; // 5 bytes plus trailing 0-byte
+    char sizeev[6] = {0,0,0,0,0,0}; // 5 bytes plus trailing 0-byte
+    fIn->read(sizecc, 5); // Size CC info string
+    fIn->read(sizerh, 5); // Size run header
+    fIn->read(sizeev, 5); // Size Event (+ event header)
+
+    //
+    // Currently we skip the CC info string. We may decode this string
+    // in the future to get additional information
+    //
+    TArrayC dummy2(atoi(sizecc));
+    fIn->read(dummy2.GetArray(), dummy2.GetSize());
+
+    //
+    // Read RUN HEADER (see specification) from input stream
+    //
+    fLog->SetNullOutput();
+    const Bool_t rc = fRawRunHeader->ReadEvt(*fIn);
+    fLog->SetNullOutput(kFALSE);
+
+    if (!rc)
+    {
+        *fLog << err << "Reading MRawRunHeader failed." << endl;
+        return kFALSE;
+    }
+
+    if (fRunNumber!=fRawRunHeader->GetRunNumber())
+    {
+        fRawRunHeader->Print();
+
+        MTaskList *tlist = (MTaskList*)fParList->FindObject("MTaskList");
+        if (!tlist)
+        {
+            *fLog << err << dbginf << "ERROR - Task List not found in Parameter List." << endl;
+            return kFALSE;
+        }
+
+        if (!tlist->ReInit())
+            return kFALSE;
+
+        fRunNumber = fRawRunHeader->GetRunNumber();
+    }
+
+    if (atoi(sizerh)==fRawRunHeader->GetNumTotalBytes())
+    {
+        *fLog << err << "Retrieved size of run header mismatch... stopped." << endl;
+        return kFALSE;
+    }
+
+    if (atoi(sizeev)==0)
+    {
+        *fLog << dbg << "Event contains only run header information... skipped." << endl;
+        return kCONTINUE;
+    }
+
+    *fRawEvtTime = fRawRunHeader->GetRunStart();
+
+    //
+    // Give the run header information to the 'sub-classes'
+    // Run header must be valid!
+    //
+    fRawEvtHeader->Init(fRawRunHeader, fRawEvtTime);
+    fRawEvtData  ->Init(fRawRunHeader, fRawCrateArray);
+
+    if (!ReadEvent(*fIn))
+        return kFALSE;
+
+    //
+    // If no new event was recorded the DAQ resends an old event
+    //
+    if (fEvtNumber==fRawEvtHeader->GetDAQEvtNumber())
+    {
+        *fLog << dbg << "Event number #" << dec << fEvtNumber << " didn't change... skipped." << endl;
+        return kCONTINUE;
+    }
+
+    fEvtNumber=fRawEvtHeader->GetDAQEvtNumber();
+
+    return kTRUE;
+}
+
+Int_t MRawSocketRead::PostProcess()
+{
+    //
+    // Close Socket connection
+    //
+    fIn->Close();
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mraw/MRawSocketRead.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mraw/MRawSocketRead.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mraw/MRawSocketRead.h	(revision 9661)
@@ -0,0 +1,36 @@
+#ifndef MARS_MRawSocketRead
+#define MARS_MRawSocketRead
+
+#ifndef MARS_MRawRead
+#include "MRawRead.h"
+#endif
+
+class MReadSocket;
+
+class MRawSocketRead : public MRawRead
+{
+private:
+    MReadSocket *fIn;         //! buffered input stream (file to read from)
+    MParList    *fParList;    //!
+
+    UInt_t       fRunNumber;  //!
+    UInt_t       fEvtNumber;  //!
+
+    Int_t        fPort;       // Port on which we wait for the connection
+
+    Bool_t OpenSocket();
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
+public:
+    MRawSocketRead(const char *name=NULL, const char *title=NULL);
+    ~MRawSocketRead();
+
+    void SetPort(int port) { fPort = port; }
+
+    ClassDef(MRawSocketRead, 0)	//Task to read DAQ binary data from tcp/ip socket
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mraw/Makefile
===================================================================
--- /tags/Mars_V0-8-5/Mars/mraw/Makefile	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mraw/Makefile	(revision 9661)
@@ -0,0 +1,41 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#------------------------------------------------------------------------------
+
+#
+# Handling name of the Root Dictionary Files
+#
+CINT  = Raw
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES = -I. -I../mbase -I../mgui -I../mgeom -I../MBase -I../mfileio
+# mgui (MCamEvent), mgeom(MGeomCam)
+
+SRCFILES = MRawRunHeader.cc \
+	   MRawEvtHeader.cc \
+	   MRawEvtData.cc \
+	   MRawEvtPixelIter.cc \
+	   MRawCrateArray.cc \
+	   MRawCrateData.cc \
+           MRawRead.cc \
+           MRawFileWrite.cc \
+           MRawFileRead.cc \
+           MRawSocketRead.cc
+
+############################################################
+
+all: $(OBJS)
+
+include ../Makefile.rules
+
+mrproper:	clean rmbak
Index: /tags/Mars_V0-8-5/Mars/mraw/RawIncl.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mraw/RawIncl.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mraw/RawIncl.h	(revision 9661)
@@ -0,0 +1,7 @@
+#ifndef __CINT__
+
+#include <TArrayC.h>
+#include "MArrayB.h"
+#include "MArrayS.h"
+
+#endif // __CINT__
Index: /tags/Mars_V0-8-5/Mars/mraw/RawLinkDef.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mraw/RawLinkDef.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mraw/RawLinkDef.h	(revision 9661)
@@ -0,0 +1,21 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class 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 MRawRead+;
+#pragma link C++ class MRawSocketRead+;
+#pragma link C++ class MRawFileRead+;
+#pragma link C++ class MRawFileWrite+;
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mreflector/MRflEvtData.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mreflector/MRflEvtData.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mreflector/MRflEvtData.cc	(revision 9661)
@@ -0,0 +1,159 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 5/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MRflEvtData
+//
+// All Photons of a event from the reflector program
+//
+// Should be filled like this:
+//   MRflEvtData evt;
+//   evt.Reset();
+//   for (int i=0; i<10; i++)
+//      MRflSinglePhoton &ph = evt.GetNewPhoton();
+//   evt.FixSize();
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MRflEvtData.h"
+
+#include <TMarker.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MHexagon.h"
+#include "MGeomCam.h"
+
+#include "MRflSinglePhoton.h"
+
+ClassImp(MRflEvtData);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Creates a MCerPhotPix object for each pixel in the event
+//
+MRflEvtData::MRflEvtData(const char *name, const char *title)
+   : fList("MRflSinglePhoton", 0), fPos(0)
+{
+    fName  = name  ? name  : "MRflEvtData";
+    fTitle = title ? title : "All Photons from a reflector event";
+}
+
+const MRflSinglePhoton &MRflEvtData::GetPhoton(Int_t i) const
+{
+    return *static_cast<MRflSinglePhoton*>(fList.UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Dump informations off all photons
+//
+void MRflEvtData::Print(Option_t *o) const
+{
+    *fLog << all << underline << GetDescriptor() << ":" << endl;
+    fList.Print();
+}
+
+// --------------------------------------------------------------------------
+//
+// Add a new photon to the list
+//
+MRflSinglePhoton &MRflEvtData::GetNewPhoton()
+{
+    // If necessary the []-operator creates a new element
+    // Warning: The virtual table may not be set correctly,
+    //          this is why you have to call the new-operator.
+    return *new (fList[fPos++]) MRflSinglePhoton;
+}
+
+// --------------------------------------------------------------------------
+//
+// If you have added all photon fix the size of the container.
+//
+void MRflEvtData::FixSize()
+{
+    if (fList.GetEntriesFast() == fPos)
+        return;
+
+    fList.ExpandCreate(fPos);
+}
+
+void MRflEvtData::DrawPixelContent(Int_t num) const
+{
+}
+
+// ------------------------------------------------------------------------
+//
+// Fill a reflector event. Sums all pixels in each pixel as the
+// pixel contents.
+//
+// WARNING: Due to the estimation in DistanceToPrimitive and the
+//          calculation in pixels instead of x, y this is only a
+//          rough estimate.
+//
+Bool_t MRflEvtData::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
+{
+    //
+    // sum the photons content in each pixel
+    //
+    val = 0;
+
+    MHexagon hex(cam[idx]);
+
+    MRflSinglePhoton *ph=NULL;
+
+    TIter Next(&fList);
+    while ((ph=(MRflSinglePhoton*)Next()))
+        if (hex.DistanceToPrimitive(ph->GetX(), ph->GetY())<=0)
+            val += cam.GetPixRatio(idx);
+
+    return val>0;
+}
+
+// ------------------------------------------------------------------------
+//
+// You can call Draw() to add the photons to the current pad.
+// The photons are painted each tim ethe pad is updated.
+// Make sure that you use the right (world) coordinate system,
+// like created, eg. by the MHCamera histogram.
+//
+void MRflEvtData::Paint(Option_t *)
+{
+    MRflSinglePhoton *ph=NULL;
+
+    TMarker m;
+    m.SetMarkerStyle(kFullDotMedium); // Gtypes.h
+
+    TIter Next(&fList);
+    while ((ph=(MRflSinglePhoton*)Next()))
+    {
+        m.SetX(ph->GetX());
+        m.SetY(ph->GetY());
+        m.Paint();
+    }
+}
+
Index: /tags/Mars_V0-8-5/Mars/mreflector/MRflEvtData.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mreflector/MRflEvtData.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mreflector/MRflEvtData.h	(revision 9661)
@@ -0,0 +1,44 @@
+#ifndef MARS_MRflEvtData
+#define MARS_MRflEvtData
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#ifndef MARS_MCamEvent
+#include "MCamEvent.h"
+#endif
+
+#ifndef ROOT_TClonesArray
+#include <TClonesArray.h>
+#endif
+
+class MRflSinglePhoton;
+
+class MRflEvtData : public MParContainer, public MCamEvent
+{
+    TClonesArray fList;
+    Int_t fPos;
+
+public:
+    MRflEvtData(const char *name=NULL, const char *title=NULL);
+
+    void Reset() { fPos = 0; }
+
+    Int_t GetNumPhotons() const { return fList.GetEntriesFast(); }
+
+    MRflSinglePhoton &GetNewPhoton();
+    void FixSize();
+
+    const MRflSinglePhoton &GetPhoton(Int_t i) const;
+
+    void Print(Option_t *o="") const;
+    void Paint(Option_t *o="");
+
+    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
+    void   DrawPixelContent(Int_t num) const;
+
+    ClassDef(MRflEvtData, 0) // All Photons of a event from the reflector program
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mreflector/MRflEvtHeader.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mreflector/MRflEvtHeader.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mreflector/MRflEvtHeader.cc	(revision 9661)
@@ -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, 5/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MRflEvtHeader
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MRflEvtHeader.h"
+
+ClassImp(MRflEvtHeader);
+
+// --------------------------------------------------------------------------
+//
+MRflEvtHeader::MRflEvtHeader(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MRflEvtHeader";
+    fTitle = title ? title : "Event header information from a reflector event";
+}
+
Index: /tags/Mars_V0-8-5/Mars/mreflector/MRflEvtHeader.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mreflector/MRflEvtHeader.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mreflector/MRflEvtHeader.h	(revision 9661)
@@ -0,0 +1,21 @@
+#ifndef MARS_MRflEvtHeader
+#define MARS_MRflEvtHeader
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MRflEvtHeader : public MParContainer
+{
+    Int_t fEvtNumber;
+
+public:
+    MRflEvtHeader(const char *name=NULL, const char *title=NULL);
+
+    Int_t GetEvtNumber() const { return fEvtNumber; }
+    void SetEvtNumber(Int_t n) { fEvtNumber = n; }
+
+    ClassDef(MRflEvtHeader, 0) // Header of an event from the reflector program
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mreflector/MRflRunHeader.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mreflector/MRflRunHeader.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mreflector/MRflRunHeader.cc	(revision 9661)
@@ -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, 5/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MRflRunHeader
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MRflRunHeader.h"
+
+ClassImp(MRflRunHeader);
+
+// --------------------------------------------------------------------------
+//
+MRflRunHeader::MRflRunHeader(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MRflRunHeader";
+    fTitle = title ? title : "Run header information from a reflector event";
+}
+
Index: /tags/Mars_V0-8-5/Mars/mreflector/MRflRunHeader.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mreflector/MRflRunHeader.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mreflector/MRflRunHeader.h	(revision 9661)
@@ -0,0 +1,21 @@
+#ifndef MARS_MRflRunHeader
+#define MARS_MRflRunHeader
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MRflRunHeader : public MParContainer
+{
+    Int_t fRunNumber;
+
+public:
+    MRflRunHeader(const char *name=NULL, const char *title=NULL);
+
+    Int_t GetRunNumber() const { return fRunNumber; }
+    void SetRunNumber(Int_t n) { fRunNumber = n; }
+
+    ClassDef(MRflRunHeader, 0) // Header of an run from the reflector program
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mreflector/MRflSinglePhoton.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mreflector/MRflSinglePhoton.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mreflector/MRflSinglePhoton.cc	(revision 9661)
@@ -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, 5/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MRflSinglePhoton
+//
+// Single Photon of a event from the reflector program
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MRflSinglePhoton.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MRflSinglePhoton);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Dump all photon information
+//
+void MRflSinglePhoton::Print(Option_t *o) const
+{
+    *fLog << all << "x=" << fX << " y=" << fY << endl;
+}
Index: /tags/Mars_V0-8-5/Mars/mreflector/MRflSinglePhoton.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mreflector/MRflSinglePhoton.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mreflector/MRflSinglePhoton.h	(revision 9661)
@@ -0,0 +1,34 @@
+#ifndef MARS_MRflSinglePhoton
+#define MARS_MRflSinglePhoton
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MRflSinglePhoton : public MParContainer
+{
+private:
+    Float_t fX;      // [mm] camera impact point
+    Float_t fY;      // [mm] camera impact point
+    Float_t fCosU;   // [1] camera direction cosine
+    Float_t fCosV;   // [1] camera direction cosine
+    Float_t fTime;   // [ns] arrival time
+    Float_t fHeight; // [cm] production height
+    Float_t fPhi;    // [rad] camera inc. angle (rad)
+public:
+    void SetXY(Float_t x, Float_t y) { fX = x; fY=y; }
+    void SetCosUV(Float_t u, Float_t v) { fCosU = u; fCosV=v; }
+    void SetTime(Float_t t) { fTime = t; }
+    void SetHeight(Float_t h) { fHeight = h; }
+    void SetInclinationAngle(Float_t phi) { fPhi = phi; }
+
+    Float_t GetX() const { return fX; }
+    Float_t GetY() const { return fY; }
+
+    void Print(Option_t *o="") const;
+
+    ClassDef(MRflSinglePhoton, 0) // Single Photon of a event from the reflector program
+
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mreflector/Makefile
===================================================================
--- /tags/Mars_V0-8-5/Mars/mreflector/Makefile	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mreflector/Makefile	(revision 9661)
@@ -0,0 +1,34 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#------------------------------------------------------------------------------
+
+#
+# Handling name of the Root Dictionary Files
+#
+CINT  = Reflector
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES = -I. -I../mbase -I../mgui -I../mgeom
+
+SRCFILES = MRflEvtData.cc \
+	   MRflEvtHeader.cc \
+	   MRflRunHeader.cc \
+	   MRflSinglePhoton.cc
+
+############################################################
+
+all: $(OBJS)
+
+include ../Makefile.rules
+
+mrproper:	clean rmbak
Index: /tags/Mars_V0-8-5/Mars/mreflector/ReflectorIncl.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mreflector/ReflectorIncl.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mreflector/ReflectorIncl.h	(revision 9661)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-8-5/Mars/mreflector/ReflectorLinkDef.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mreflector/ReflectorLinkDef.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mreflector/ReflectorLinkDef.h	(revision 9661)
@@ -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 MRflEvtData+;
+#pragma link C++ class MRflEvtHeader+;
+#pragma link C++ class MRflRunHeader+;
+#pragma link C++ class MRflSinglePhoton+;
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mreport/MReport.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mreport/MReport.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mreport/MReport.cc	(revision 9661)
@@ -0,0 +1,161 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MReport
+//
+//  This is a base class for all reports comming from subsystems stored in
+//  a report file.
+//
+//  Be carefull: The class name of all classes derived from this class
+//               should start with 'MReport', see SetupReading
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MReport.h"
+
+#include "MLogManip.h"
+
+#include "MTime.h"
+#include "MParList.h"
+
+ClassImp(MReport);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Interpretes the beginning of a line which starts like:
+//   status hour minute second millisec skip skip skip skip skip
+// The identifier is assumed to be removed.
+//
+// While skip are numbers which won't enter the analysis
+//
+// SetupReading must be called successfully before.
+//
+Bool_t MReport::InterpreteHeader(TString &str)
+{
+    int len, state;
+    int yea, mon, day, hor, min, sec, ms;
+
+    int n = sscanf(str.Data(),
+                   fHasReportTime ?
+                   " %d %d %d %d %d %d %d %d %*d %*d %*d %*d %*d %*d %*d %*d %n" :
+                   " %d %d %d %d %d %d %d %d %n",
+                   &state, &yea, &mon, &day, &hor, &min, &sec, &ms, &len);
+    if (n!=8)
+    {
+        *fLog << err << "ERROR - Cannot interprete Body of " << fIdentifier << " (n=" << n << ")" << endl;
+        return kFALSE;
+    }
+
+    fState=state;
+    if (!fTime->Set(yea, mon, day, hor, min, sec, ms))
+    {
+        *fLog << err << "ERROR - Event has invalid time: ";
+        *fLog << Form("%d.%d.%d %02d:%02d:%02d.%03d", day, mon, yea, hor, min, sec, ms);
+        *fLog << "... abort." << endl;
+        return kFALSE;
+    }
+
+    str.Remove(0, len);
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Report Body must be overwritten. It will get the line idetified to belong
+// to fIdentifier without the leading status and time infomration as an
+// argument.
+//
+Int_t MReport::InterpreteBody(TString &str)
+{
+    *fLog << warn << "No interpreter existing for: " << fIdentifier << endl;
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Interprets Header and Body of a report file line. Calls SetReadyToSave()
+// in case the interpretation was successfull. And fTime->SetReadyToSave()
+// when a corresponding time container exists.
+//
+// SetupReading must be called successfully before.
+//
+Int_t MReport::Interprete(TString &str, const MTime &start, const MTime &stop)
+{
+    if (!InterpreteHeader(str))
+        return kFALSE;
+
+    // return -1: This is the special case: out of time limit
+    if (start && *fTime<start)
+        return -1;
+    if (stop  && *fTime>stop)
+        return -1;
+
+    const Int_t rc = InterpreteBody(str);
+    if (rc != kTRUE)
+        return rc;
+
+    SetReadyToSave();
+    fTime->SetReadyToSave();
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Check for the existance of a corresponding MTime in the given parameter
+// list. If it is not found a new one will be created. The name of the
+// MTime object is created by taking the ClassName() of the derived MReport
+// class and stripping the leading MReport
+//
+Bool_t MReport::SetupReading(MParList &plist)
+{
+    fTime = NULL;
+
+    TString id(ClassName());
+    if (!id.BeginsWith("MReport"))
+    {
+        *fLog << warn << " WARNING - Class name '" << id << "' ";
+        *fLog << " doesn't begin with 'MReport'... no MTime assigned." << endl;
+        return kFALSE;
+    }
+
+    id.Remove(0, 7);
+    if (id.IsNull())
+    {
+        *fLog << warn << " WARNING - No postfix existing... no MTime assigned." << endl;
+        return kFALSE;
+    }
+
+    id.Prepend("MTime");
+
+    fTime = (MTime*)plist.FindCreateObj("MTime", id);
+    if (!fTime)
+        return kFALSE;
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mreport/MReport.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mreport/MReport.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mreport/MReport.h	(revision 9661)
@@ -0,0 +1,48 @@
+#ifndef MARS_MReport
+#define MARS_MReport
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MTime;
+class MParList;
+
+class MReport : public MParContainer
+{
+private:
+    const TString fIdentifier;    //! Identifier of the subsystem
+    const Bool_t  fHasReportTime; //! Intermediate solution for DC currents
+
+    Byte_t  fState;               // Status of the subsystem
+    MTime  *fTime;                //! pointer to the corresponding time stamp
+
+    ULong_t Hash() const { return fIdentifier.Hash(); }
+    Bool_t InterpreteHeader(TString &str);
+
+public:
+    MReport(const char *id, Bool_t time=kTRUE) : fIdentifier(id), fHasReportTime(time), fState(0xff), fTime(0) { }
+
+    virtual Bool_t SetupReading(MParList &plist);
+    virtual Int_t  InterpreteBody(TString &str);
+
+    Int_t  Interprete(TString &str, const MTime &start, const MTime &stop);
+    Bool_t CheckIdentifier(TString &str) const
+    {
+        if (!str.BeginsWith(fIdentifier))
+            return kFALSE;
+
+        str.Remove(0, fIdentifier.Length());
+        str = str.Strip(TString::kBoth);
+
+        return kTRUE;
+    }
+
+    const TString &GetIdentifier() const { return fIdentifier; }
+
+    Byte_t GetState() const { return fState; }
+
+    ClassDef(MReport, 1) // Base class for control reports
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mreport/MReportCC.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mreport/MReportCC.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mreport/MReportCC.cc	(revision 9661)
@@ -0,0 +1,89 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MReportCC
+//
+// This is the class interpreting and storing the CC-REPORT information.
+//
+// From here maily weather station data is decoded such as
+// temperature, humidity, wind-speed and solar radiation
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MReportCC.h"
+
+#include "MLogManip.h"
+
+#include "MAstro.h"
+
+ClassImp(MReportCC);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default construtor. Initialize identifier to "CC-REPORT" Report
+// is expected to have no 'subsystem' time.
+//
+MReportCC::MReportCC() : MReport("CC-REPORT", kFALSE)
+{
+    fName  = "MReportCC";
+    fTitle = "Class for CC-REPORT information";
+}
+
+// --------------------------------------------------------------------------
+//
+// Interprete the body of the CC-REPORT string
+//
+Int_t MReportCC::InterpreteBody(TString &str)
+{
+    // Remove the 30 tokens of the subsystem status
+    //  table 12.1 p59
+    for (int i=0; i<30; i++)
+        str.Remove(0, str.First(' ')+1);
+
+    Int_t len;
+    const Int_t n=sscanf(str.Data(),
+                         "%*f %*f %*f %*f %f %f %f %f %*f %*f %n",
+                         &fTemperature, &fSolarRadiation, &fWindSpeed,
+                         &fHumidity, &len);
+    if (n!=4)
+    {
+        *fLog << warn << "WARNING - Wrong number of arguments." << endl;
+        return kCONTINUE;
+    }
+    /*
+    str.Remove(0, len);
+
+    *fLog << dbg << str << endl;
+
+    if (str!=(TString)"OVER")
+    {
+        *fLog << err << "ERROR - Termination (OVER) too far away." << endl;
+        return kFALSE;
+    }
+    */
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mreport/MReportCC.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mreport/MReportCC.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mreport/MReportCC.h	(revision 9661)
@@ -0,0 +1,29 @@
+#ifndef MARS_MReportCC
+#define MARS_MReportCC
+
+#ifndef MARS_MReport
+#include "MReport.h"
+#endif
+
+class MReportCC : public MReport
+{
+private:
+    Float_t fHumidity;       // [%]
+    Float_t fTemperature;    // [deg] celsius
+    Float_t fWindSpeed;      // [km/h]
+    Float_t fSolarRadiation; // [W/m^2] IR-Radiation
+
+    Int_t InterpreteBody(TString &str);
+
+public:
+    MReportCC();
+
+    Float_t GetHumidity() const       { return fHumidity; }
+    Float_t GetTemperature() const    { return fTemperature; }
+    Float_t GetWindSpeed() const      { return fWindSpeed; }
+    Float_t GetSolarRadiation() const { return fSolarRadiation; }
+
+    ClassDef(MReportCC, 1) // Class for CC-REPORT information
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mreport/MReportCamera.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mreport/MReportCamera.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mreport/MReportCamera.cc	(revision 9661)
@@ -0,0 +1,458 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MReportCamera
+//
+// This is the class interpreting and storing the CAMERA-REPORT information.
+//
+// Most of the information is redirected to the classes MCamera* and stored
+// there.
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MReportCamera.h"
+
+#include "MLogManip.h"
+
+#include "MAstro.h"
+#include "MParList.h"
+
+#include "MCameraCalibration.h"
+#include "MCameraCooling.h"
+#include "MCameraHV.h"
+#include "MCameraLV.h"
+#include "MCameraAUX.h"
+#include "MCameraLids.h"
+
+ClassImp(MReportCamera);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default construtor. Initialize identifier to "CAMERA-REPORT"
+//
+MReportCamera::MReportCamera() : MReport("CAMERA-REPORT")
+{
+    fName = "MReportCamera";
+    fTitle = "Class for CAMERA-REPORT information";
+}
+
+// --------------------------------------------------------------------------
+//
+// FindCreate the following objects:
+//  - MCameraCooling
+//  - MCameraLids
+//  - MCameraAUX
+//  - MCameraHV
+//  - MCameraLV
+//  - MCameraCalibration
+//
+Bool_t MReportCamera::SetupReading(MParList &plist)
+{
+    fCooling = (MCameraCooling*)plist.FindCreateObj("MCameraCooling");
+    if (!fCooling)
+        return kFALSE;
+
+    fLids = (MCameraLids*)plist.FindCreateObj("MCameraLids");
+    if (!fLids)
+        return kFALSE;
+
+    fAUX = (MCameraAUX*)plist.FindCreateObj("MCameraAUX");
+    if (!fAUX)
+        return kFALSE;
+
+    fHV = (MCameraHV*)plist.FindCreateObj("MCameraHV");
+    if (!fHV)
+        return kFALSE;
+
+    fLV = (MCameraLV*)plist.FindCreateObj("MCameraLV");
+    if (!fLV)
+        return kFALSE;
+
+    fCalibration = (MCameraCalibration*)plist.FindCreateObj("MCameraCalibration");
+    if (!fCalibration)
+        return kFALSE;
+
+    return MReport::SetupReading(plist);
+}
+
+// --------------------------------------------------------------------------
+//
+// Check whether the given TString begins with the given tag. Remove
+// the tag from the string.
+//
+Bool_t MReportCamera::CheckTag(TString &str, const char *tag) const
+{
+    if (!str.BeginsWith(tag))
+    {
+        *fLog << warn << "WARNING - '" << tag << "' tag not found." << endl;
+        return kFALSE;
+    }
+    str.Remove(0, strlen(tag)); // Remove DC currents
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Interprete the DC* part of the report
+//
+Bool_t MReportCamera::InterpreteDC(TString &str)
+{
+    if (!CheckTag(str, "DC "))
+        return kFALSE;
+
+    str.Remove(0, 577*4); // Remove DC currents
+    str=str.Strip(TString::kLeading);
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Interprete the HV* part of the report
+//
+Bool_t MReportCamera::InterpreteHV(TString &str)
+{
+    if (!CheckTag(str, "HV "))
+        return kFALSE;
+
+    const char *pos = str.Data();
+    const char *end = str.Data()+577*3;
+
+    Int_t i=0;
+    while (pos<end)
+    {
+        const Char_t hex[4] = { pos[0], pos[1], pos[2], 0 };
+        pos += 3;
+
+        const Int_t n=sscanf(hex, "%3hx", &fHV->fHV[i++]);
+        if (n==1)
+            continue;
+
+        *fLog << warn << "WARNING - Reading hexadecimal HV information." << endl;
+        return kFALSE;
+    }
+
+    str.Remove(0, end-str.Data()); // Remove DC currents
+    str=str.Strip(TString::kLeading);
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Interprete the COOL* part of the report
+//
+Bool_t MReportCamera::InterpreteCOOL(TString &str)
+{
+    if (!CheckTag(str, "COOL "))
+        return kFALSE;
+
+    Int_t len;
+
+    Int_t wall, opt, center, water;
+    Short_t hwall, hcenter, hip, lop, pump, ref, valv, res, fans;
+    const Int_t n=sscanf(str.Data(), "%d %d %d %d %hu %hu %hu %hu %hu %hu %hu %hu %hu %n",
+                         &wall, &opt, &center, &water, &hwall, &hcenter,
+                         &hip,  &lop, &pump, &ref, &valv, &res, &fans, &len);
+    if (n!=13)
+    {
+        *fLog << warn << "WARNING - Reading information of 'COOL' section." << endl;
+        return kFALSE;
+    }
+
+    fCooling->fTempWall            = 0.1*wall;
+    fCooling->fTempOptLink         = 0.1*opt;
+    fCooling->fTempCenter          = 0.1*center;
+    fCooling->fTempWater           = 0.1*water;
+    fCooling->fHumWall             = (Byte_t)hwall;
+    fCooling->fHumCenter           = (Byte_t)hcenter;
+    fCooling->fStatusPressureHi    = (Bool_t)hip;
+    fCooling->fStatusPressureLo    = (Bool_t)lop;
+    fCooling->fStatusPump          = (Bool_t)pump;
+    fCooling->fStatusRefrigrerator = (Bool_t)ref;
+    fCooling->fStatusValve         = (Bool_t)valv;
+    fCooling->fStatusResistor      = (Bool_t)res;
+    fCooling->fStatusFans          = (Bool_t)fans;
+
+    str.Remove(0, len);
+    str=str.Strip(TString::kLeading);
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Interprete the LID* part of the report
+//
+Bool_t MReportCamera::InterpreteLID(TString &str)
+{
+    if (!CheckTag(str, "LID "))
+        return kFALSE;
+
+    Int_t len;
+    Short_t limao, limac, limbo, limbc;
+    Short_t slimao, slimac, slimbo, slimbc;
+    Short_t slida, slidb, mlida, mlidb;
+    const Int_t n=sscanf(str.Data(), "%hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %n",
+                         &limao, &limac, &limbo, &limbc,
+                         &slimao, &slimac, &slimbo, &slimbc,
+                         &slida, &slidb, &mlida, &mlidb,
+                         &len);
+    if (n!=12)
+    {
+        *fLog << warn << "WARNING - Reading information of 'LID' section." << endl;
+        return kFALSE;
+    }
+
+    fLids->fLidA.fLimitOpen       = (Bool_t)limao;
+    fLids->fLidA.fLimitClose      = (Bool_t)limac;
+    fLids->fLidA.fSafetyLimitOpen = (Bool_t)slimao;
+    fLids->fLidA.fSafetyLimitClose= (Bool_t)slimac;
+    fLids->fLidA.fStatusLid       = (Byte_t)slida;
+    fLids->fLidA.fStatusMotor     = (Byte_t)mlida;
+
+    fLids->fLidB.fLimitOpen       = (Bool_t)limbo;
+    fLids->fLidB.fLimitClose      = (Bool_t)limbc;
+    fLids->fLidB.fSafetyLimitOpen = (Bool_t)slimbo;
+    fLids->fLidB.fSafetyLimitClose= (Bool_t)slimbc;
+    fLids->fLidB.fStatusLid       = (Byte_t)slidb;
+    fLids->fLidB.fStatusMotor     = (Byte_t)mlidb;
+
+    str.Remove(0, len);
+    str=str.Strip(TString::kLeading);
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Interprete the HVPS* part of the report
+//
+Bool_t MReportCamera::InterpreteHVPS(TString &str)
+{
+    if (!CheckTag(str, "HVPS "))
+        return kFALSE;
+
+    Int_t len;
+    Short_t c1, c2;
+    const Int_t n=sscanf(str.Data(), "%hd %hd %hd %hd %n",
+                         &fHV->fVoltageA, &fHV->fVoltageB, &c1, &c2, &len);
+    if (n!=4)
+    {
+        *fLog << warn << "WARNING - Reading information of 'HVPS' section." << endl;
+        return kFALSE;
+    }
+
+    fHV->fCurrentA = (Byte_t)c1;
+    fHV->fCurrentB = (Byte_t)c2;
+
+    str.Remove(0, len);
+    str=str.Strip(TString::kLeading);
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Interprete the LV* part of the report
+//
+Bool_t MReportCamera::InterpreteLV(TString &str)
+{
+    if (!CheckTag(str, "LV "))
+        return kFALSE;
+
+    Int_t len;
+    Short_t vap5, vap12, van12, vbp5, vbp12, vbn12;
+    Short_t valp12, vblp12, cap5, cap12, can12, cbp5, cbp12;
+    Short_t cbn12, calp12, cblp12, lvps, temp, hum;
+    const Int_t n=sscanf(str.Data(), "%hd %hd %hd %hd %hd %hd %hd %hd %hd %hd %hd %hd %hd %hd %hd %hd %hd %hd %hd %n",
+                         &vap5, &vap12, &van12, &vbp5, &vbp12, &vbn12,
+                         &valp12, &vblp12, &cap5, &cap12, &can12, &cbp5, &cbp12,
+                         &cbn12, &calp12, &cblp12, &lvps, &temp, &hum, &len);
+    if (n!=19)
+    {
+        *fLog << warn << "WARNING - Reading information of 'LV' section." << endl;
+        return kFALSE;
+    }
+
+    fLV->fRequestPowerSupply = (Bool_t)lvps;
+    fLV->fTemp = 0.1*temp;
+    fLV->fHumidity = (Byte_t)hum;
+
+    fLV->fPowerSupplyA.fVoltagePos5V         = 0.01*vap5;
+    fLV->fPowerSupplyA.fVoltagePos12V        = 0.01*vap12;
+    fLV->fPowerSupplyA.fVoltageNeg12V        = 0.01*van12;
+    fLV->fPowerSupplyA.fVoltageOptLinkPos12V = 0.01*valp12;
+    fLV->fPowerSupplyA.fCurrentPos5V         = 0.001*cap5;
+    fLV->fPowerSupplyA.fCurrentPos12V        = 0.001*cap12;
+    fLV->fPowerSupplyA.fCurrentNeg12V        = 0.001*can12;
+    fLV->fPowerSupplyA.fCurrentOptLinkPos12V = 0.001*calp12;
+
+    fLV->fPowerSupplyB.fVoltagePos5V         = 0.01*vbp5;
+    fLV->fPowerSupplyB.fVoltagePos12V        = 0.01*vbp12;
+    fLV->fPowerSupplyB.fVoltageNeg12V        = 0.01*vbn12;
+    fLV->fPowerSupplyB.fVoltageOptLinkPos12V = 0.01*vblp12;
+    fLV->fPowerSupplyB.fCurrentPos5V         = 0.001*cbp5;
+    fLV->fPowerSupplyB.fCurrentPos12V        = 0.001*cbp12;
+    fLV->fPowerSupplyB.fCurrentNeg12V        = 0.001*cbn12;
+    fLV->fPowerSupplyB.fCurrentOptLinkPos12V = 0.001*cblp12;
+
+    str.Remove(0, len);
+    str=str.Strip(TString::kLeading);
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Interprete the AUX* part of the report
+//
+Bool_t MReportCamera::InterpreteAUX(TString &str)
+{
+    if (!CheckTag(str, "AUX "))
+        return kFALSE;
+
+    Int_t len;
+    Short_t led, fan;
+    const Int_t n=sscanf(str.Data(), "%hd %hd %n", &led, &fan, &len);
+    if (n!=2)
+    {
+        *fLog << warn << "WARNING - Reading information of 'AUX' section." << endl;
+        return kFALSE;
+    }
+
+    fAUX->fRequestCaosLEDs=(Bool_t)led;
+    fAUX->fRequestFansFADC=(Bool_t)fan;
+
+    str.Remove(0, len);
+    str=str.Strip(TString::kLeading);
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Interprete the CAL* part of the report
+//
+Bool_t MReportCamera::InterpreteCAL(TString &str)
+{
+    if (!CheckTag(str, "CAL "))
+        return kFALSE;
+
+    Int_t len;
+    Short_t hv, lv, cont, pin;
+
+    const Int_t n=sscanf(str.Data(), "%hd %hd %hd %hd %n", &hv, &lv, &cont, &pin, &len);
+    if (n!=4)
+    {
+        *fLog << warn << "WARNING - Reading information of 'CAL' section." << endl;
+        return kFALSE;
+    }
+
+    fCalibration->fRequestHiVoltage = (Bool_t)hv;
+    fCalibration->fRequestLoVoltage = (Bool_t)lv;
+    fCalibration->fRequestContLight = (Bool_t)cont;
+    fCalibration->fRequestPinDiode  = (Bool_t)pin;
+
+    str.Remove(0, len);
+    str=str.Strip(TString::kBoth);
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Interprete the CAMERA-REPORT part
+//
+Bool_t MReportCamera::InterpreteCamera(TString &str)
+{
+    //
+    // I have tried to do it with pure pointer arithmentics, but most of the time is spent
+    // to do the sscanf. So we gain less than 5% not using TString like it is done here.
+    Int_t len;
+    Short_t cal, stat, hvps, lid, lv, cool, hv, dc, led, fan, can, io, clv;
+    Int_t n=sscanf(str.Data(), " %hd %hd %hd %hd %hd %hd %hd %hd %hd %hd %hd %hd %hd %n",
+                   &cal, &stat, &hvps, &lid, &lv, &cool, &hv,
+                   &dc, &led, &fan, &can, &io, &clv, &len);
+    if (n!=13)
+    {
+        *fLog << warn << "WARNING - Cannot interprete status' of subsystems." << endl;
+        return kFALSE;
+    }
+    str.Remove(0, len);
+    str=str.Strip(TString::kLeading);
+
+    fHV->fStatus                   = (Byte_t)hvps;
+    fLids->fStatus                 = (Byte_t)lid;
+    fLV->fStatus                   = (Byte_t)lv;
+    fCooling->fStatus              = (Byte_t)cool;
+    fHV->fStatusRamping            = (Byte_t)hv;
+    fAUX->fStatusCaosLEDs          = (Bool_t)led;
+    fAUX->fStatusFansFADC          = (Bool_t)fan;
+    fCalibration->fStatus          = (Bool_t)cal;
+    fCalibration->fStatusCANbus    = (Bool_t)can;
+    fCalibration->fStatusIO        = (Bool_t)io;
+    fCalibration->fStatusLoVoltage = (Bool_t)clv;
+    fStatus                        = (Byte_t)stat;
+    fStatusDC                      = (Byte_t)dc;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Interprete the body of the CAMERA-REPORT string
+//
+Int_t MReportCamera::InterpreteBody(TString &str)
+{
+    if (!InterpreteCamera(str))
+        return kCONTINUE;
+
+    if (!InterpreteDC(str))
+        return kCONTINUE;
+
+    if (!InterpreteHV(str))
+        return kCONTINUE;
+
+    if (!InterpreteCOOL(str))
+        return kCONTINUE;
+
+    if (!InterpreteLID(str))
+        return kCONTINUE;
+
+    if (!InterpreteHVPS(str))
+        return kCONTINUE;
+
+    if (!InterpreteLV(str))
+        return kCONTINUE;
+
+    if (!InterpreteAUX(str))
+        return kCONTINUE;
+
+    if (!InterpreteCAL(str))
+        return kCONTINUE;
+
+    if (str!="OVER")
+    {
+        *fLog << warn << "WARNING - 'OVER' tag not found." << endl;
+        return kCONTINUE;
+    }
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mreport/MReportCamera.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mreport/MReportCamera.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mreport/MReportCamera.h	(revision 9661)
@@ -0,0 +1,52 @@
+#ifndef MARS_MReportCamera
+#define MARS_MReportCamera
+
+#ifndef MARS_MReport
+#include "MReport.h"
+#endif
+
+class MCameraCooling;
+class MCameraLids;
+class MCameraHV;
+class MCameraLV;
+class MCameraAUX;
+class MCameraCalibration;
+
+class MReportCamera : public MReport
+{
+private:
+    Byte_t fStatus;   // CaCo monitored status of the sentinel (0-9), Sentinel_state
+    Byte_t fStatusDC; // CaCo monitored status of the DC currents (0-9), Cam.DC_state
+
+    MCameraCooling     *fCooling;     //!
+    MCameraLids        *fLids;        //!
+    MCameraAUX         *fAUX;         //!
+    MCameraHV          *fHV;          //!
+    MCameraLV          *fLV;          //!
+    MCameraCalibration *fCalibration; //!
+
+    Bool_t SetupReading(MParList &plist);
+    Bool_t CheckTag(TString &str, const char *tag) const;
+
+    Bool_t InterpreteCamera(TString &str);
+    Bool_t InterpreteDC(TString &str);
+    Bool_t InterpreteHV(TString &str);
+    Bool_t InterpreteCOOL(TString &str);
+    Bool_t InterpreteLID(TString &str);
+    Bool_t InterpreteHVPS(TString &str);
+    Bool_t InterpreteLV(TString &str);
+    Bool_t InterpreteAUX(TString &str);
+    Bool_t InterpreteCAL(TString &str);
+
+    Int_t  InterpreteBody(TString &str);
+
+public:
+    MReportCamera();
+
+    Byte_t GetStatus() const { return  fStatus; }
+    Byte_t GetStatusDC() const { return fStatusDC; }
+
+    ClassDef(MReportCamera, 1) // Class for CAMERA-REPORT information
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mreport/MReportCurrents.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mreport/MReportCurrents.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mreport/MReportCurrents.cc	(revision 9661)
@@ -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, 11/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MReportCurrents
+//
+// This is the class interpreting and storing the DC-REPORT information.
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MReportCurrents.h"
+
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MCameraDC.h"
+
+ClassImp(MReportCurrents);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default construtor. Initialize identifier to "DC-REPORT" Reports
+// are expected to have no 'subsystem' time.
+//
+MReportCurrents::MReportCurrents() : MReport("DC-REPORT", kFALSE)
+{
+    fName  = "MReportCurrents";
+    fTitle = "Class for DC-REPORT information";
+}
+
+// --------------------------------------------------------------------------
+//
+// FindCreate the following objects:
+//  - MCameraDC
+//
+Bool_t MReportCurrents::SetupReading(MParList &plist)
+{
+    fDC = (MCameraDC*)plist.FindCreateObj("MCameraDC");
+    if (!fDC)
+        return kFALSE;
+
+    return MReport::SetupReading(plist);
+}
+
+// --------------------------------------------------------------------------
+//
+// Interprete the body of the DC-REPORT string
+//
+Int_t MReportCurrents::InterpreteBody(TString &str)
+{
+    Int_t len;
+    Short_t err1, err2;
+    const Int_t n=sscanf(str.Data(), " %hd %hd %n", &err1, &err2, &len);
+    if (n!=2)
+    {
+        *fLog << warn << "WARNING - Reading status information." << endl;
+        return kCONTINUE;
+    }
+
+    fStatus1 = (Byte_t)err1;
+    fStatus2 = (Byte_t)err2;
+
+    const char *pos = str.Data()+len;
+    const char *end = pos+577*4;
+
+    Int_t i=0;
+    while (pos<end)
+    {
+        Int_t c;
+        const Char_t hex[5] = { pos[0], pos[1], pos[2], pos[3], 0 };
+        pos += 4;
+
+        const Int_t n=sscanf(hex, "%4x", &c);
+        if (n!=1)
+        {
+            *fLog << warn << "WARNING - Reading hexadecimal DC information." << endl;
+            return kCONTINUE;
+        }
+
+        (*fDC)[i++] = 0.001*c;
+    }
+
+    str.Remove(0, pos-str.Data()); // Remove DC currents
+    str=str.Strip(TString::kLeading);
+
+    return str.IsNull() ? kTRUE : kCONTINUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mreport/MReportCurrents.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mreport/MReportCurrents.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mreport/MReportCurrents.h	(revision 9661)
@@ -0,0 +1,27 @@
+#ifndef MARS_MReportCurrents
+#define MARS_MReportCurrents
+
+#ifndef MARS_MReport
+#include "MReport.h"
+#endif
+
+class MCameraDC;
+
+class MReportCurrents : public MReport
+{
+private:
+    Byte_t fStatus1;
+    Byte_t fStatus2;
+
+    MCameraDC *fDC; //!
+
+    Bool_t SetupReading(MParList &plist);
+    Int_t InterpreteBody(TString &str);
+
+public:
+    MReportCurrents();
+
+    ClassDef(MReportCurrents, 1) // Class for DC-REPORT information
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mreport/MReportDAQ.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mreport/MReportDAQ.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mreport/MReportDAQ.cc	(revision 9661)
@@ -0,0 +1,54 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MReportDAQ
+//
+// This is the class interpreting and storing the DAQ-REPORT information.
+//
+// --> Currently unused
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MReportDAQ.h"
+
+#include "MLogManip.h"
+
+#include "MAstro.h"
+
+ClassImp(MReportDAQ);
+
+using namespace std;
+
+MReportDAQ::MReportDAQ() : MReport("DAQ-REPORT")
+{
+    fName = "MReportDAQ";
+    fTitle = "Class for DAQ-REPORT information";
+}
+
+Int_t MReportDAQ::InterpreteBody(TString &str)
+{
+    *fLog << dbg << "D" << flush;
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mreport/MReportDAQ.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mreport/MReportDAQ.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mreport/MReportDAQ.h	(revision 9661)
@@ -0,0 +1,19 @@
+#ifndef MARS_MReportDAQ
+#define MARS_MReportDAQ
+
+#ifndef MARS_MReport
+#include "MReport.h"
+#endif
+
+class MReportDAQ : public MReport
+{
+private:
+    Int_t InterpreteBody(TString &str);
+
+public:
+    MReportDAQ();
+
+    ClassDef(MReportDAQ, 1) // Class for DAQ-REPORT information
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mreport/MReportDrive.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mreport/MReportDrive.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mreport/MReportDrive.cc	(revision 9661)
@@ -0,0 +1,155 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 11/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MReportDrive
+//
+// This is the class interpreting and storing the DRIVE-REPORT information.
+//
+// This is NOT the place to get the pointing position from. The class
+// definition might change. But it is the place to calculate the
+// correct pointing position from.
+//
+//
+// Double_t fMjd;        // Modified Julian Date send by the drive system
+//  This is the MJD as it was calculated by the drive system when the report
+//  was send.
+//
+// Double_t fRa;         // [h]   Right ascension
+// Double_t fDec;        // [deg] Declination
+// Double_t fHa;         // [h]   Hour angle
+//  Currently this descries the nominal source position
+//
+// Double_t fNominalZd;  // [deg] Nominal zenith distance
+// Double_t fNominalAz;  // [deg] Nominal azimuth
+//  The nominal local position like it was calculated in the last
+//  control loop for time at which the last shaftencoder value has changed
+//
+// Double_t fCurrentZd;  // [deg] current zenith distance
+// Double_t fCurrentAz;  // [deg] current azimuth
+//  The current local position like it was calculated in the last
+//  control loop from interpolated shaftencoder values for time at which
+//  the last shaftencoder value has changed
+//
+// Double_t fErrorZd;    // [?] system error in the zenith angle axis
+// Double_t fErrorAz;    // [?] sistem error in the azimuth angle axis
+//  The system error on both axis derived from the two values above. Be
+//  carefull, eg near the zenith we a huge deviation in azimuth
+//  while having a small deviation in zenith angle might be meaingless.
+//  Please use GetAbsError to get the absolute distance between the
+//  twopositions.
+//
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MReportDrive.h"
+
+#include "MLogManip.h"
+
+#include "MAstro.h"
+
+ClassImp(MReportDrive);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default construtor. Initialize identifier to "DRIVE-REPORT"
+//
+MReportDrive::MReportDrive() : MReport("DRIVE-REPORT")
+{
+    fName  = "MReportDrive";
+    fTitle = "Class for DRIVE-REPORT information (raw telescope position)";
+}
+
+// --------------------------------------------------------------------------
+//
+// Interprete the body of the DRIVE-REPORT string
+//
+Int_t MReportDrive::InterpreteBody(TString &str)
+{
+    MAstro::String2Angle(str, fRa);
+    MAstro::String2Angle(str, fDec);
+    MAstro::String2Angle(str, fHa);
+
+    Int_t len;
+    Int_t n=sscanf(str.Data(), "%lf %n", &fMjd, &len);
+    if (n!=1)
+    {
+        *fLog << warn << "WARNING - Not enough arguments." << endl;
+        return kCONTINUE;
+    }
+
+    str.Remove(0, len);
+
+    MAstro::String2Angle(str, fNominalZd);
+    MAstro::String2Angle(str, fNominalAz);
+    MAstro::String2Angle(str, fCurrentZd);
+    MAstro::String2Angle(str, fCurrentAz);
+
+    n=sscanf(str.Data(), "%lf %lf %n", &fErrorZd, &fErrorAz, &len);
+    if (n!=2)
+    {
+        *fLog << warn << "WARNING - Not enough arguments." << endl;
+        return kCONTINUE;
+    }
+
+    str.Remove(0, len);
+
+    str = str.Strip(TString::kBoth);
+
+    return str.IsNull() ? kTRUE : kCONTINUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the absolute deviation from the nominal position calculated
+// from the system error.
+//
+Double_t MReportDrive::GetAbsError() const
+{
+    const Double_t pzd = fNominalZd*TMath::DegToRad();
+    const Double_t azd = fErrorZd  *TMath::DegToRad();
+    const Double_t aaz = fErrorAz  *TMath::DegToRad();
+
+    const double el = TMath::Pi()/2-pzd;
+
+    const double dphi2 = aaz/2.;
+    const double cos2  = cos(dphi2)*cos(dphi2);
+    const double sin2  = sin(dphi2)*sin(dphi2);
+    const double d     = cos(azd)*cos2 - cos(2*el)*sin2;
+
+    //
+    // Original:
+    //   cos(Zd1)*cos(Zd2)+sin(Zd1)*sin(Zd2)*cos(dAz)
+    //
+    // Correct:
+    //   const double d = cos(azd)*cos2 - cos(el1+el2)*sin2;
+    //
+    // Estimated:
+    //   const double d = cos(azd)*cos2 - cos(2*el)*sin2;
+    //
+
+    return acos(d)*TMath::RadToDeg();
+}
Index: /tags/Mars_V0-8-5/Mars/mreport/MReportDrive.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mreport/MReportDrive.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mreport/MReportDrive.h	(revision 9661)
@@ -0,0 +1,49 @@
+#ifndef MARS_MReportDrive
+#define MARS_MReportDrive
+
+#ifndef MARS_MReport
+#include "MReport.h"
+#endif
+
+class MReportDrive : public MReport
+{
+private:
+    Double_t fMjd;        // Modified Julian Date send by the drive system
+
+    Double_t fRa;         // [h]   Right ascension
+    Double_t fDec;        // [deg] Declination
+    Double_t fHa;         // [h]   Hour angle
+
+    Double_t fNominalZd;  // [deg] Nominal zenith distance
+    Double_t fNominalAz;  // [deg] Nominal azimuth
+    Double_t fCurrentZd;  // [deg] current zenith distance
+    Double_t fCurrentAz;  // [deg] current azimuth
+
+    Double_t fErrorZd;    // [?] system error in the zenith angle axis
+    Double_t fErrorAz;    // [?] sistem error in the azimuth angle axis
+
+    Int_t InterpreteBody(TString &str);
+
+public:
+    MReportDrive();
+
+    Double_t GetMjd() const       { return fMjd;       }
+
+    Double_t GetRa() const        { return fRa;        }
+    Double_t GetDec() const       { return fDec;       }
+    Double_t GetHa() const        { return fHa;        }
+
+    Double_t GetNominalZd() const { return fNominalZd; }
+    Double_t GetNominalAz() const { return fNominalAz; }
+    Double_t GetCurrentZd() const { return fCurrentZd; }
+    Double_t GetCurrentAz() const { return fCurrentAz; }
+
+    Double_t GetErrorZd() const   { return fErrorZd;   }
+    Double_t GetErrorAz() const   { return fErrorAz;   }
+
+    Double_t GetAbsError() const;
+
+    ClassDef(MReportDrive, 1) // Class for DRIVE-REPORT information
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mreport/MReportFileRead.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mreport/MReportFileRead.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mreport/MReportFileRead.cc	(revision 9661)
@@ -0,0 +1,311 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MReportFileRead
+//
+// Task to read the central control report file. For more information see
+// the base class of all reports MReport.
+//
+// To add a report which should be read use AddToList.
+//
+// eg. AddToList("Drive") will assume the existance of a class called
+//     MReportDrive. It will create such an object automatically. It will
+//     send all lines starting with 'MReportDrive::fIndetifier-REPORT'
+//     to this class.
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MReportFileRead.h"
+
+#include <errno.h>
+#include <fstream>
+
+#include <TRegexp.h>
+#include <THashTable.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MReportHelp.h"
+
+ClassImp(MReportFileRead);
+
+using namespace std;
+
+const TString MReportFileRead::gsReportHeader ="[CC Report File]";
+const TString MReportFileRead::gsVersionPrefix="Arehucas Version Number";
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. It tries to open the given file and creates a
+// THashTable which allows faster access to the MReport* objects.
+//
+MReportFileRead::MReportFileRead(const char *fname, const char *name, const char *title)
+    : fFileName(fname), fIn(NULL)
+{
+    fName  = name  ? name  : "MReportFileRead";
+    fTitle = title ? title : "Read task to read Central Control report files";
+
+    fIn = new ifstream;
+    fList = new THashTable(1,1);
+    fList->SetOwner();
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor. Delete input stream and hash table.
+//
+MReportFileRead::~MReportFileRead()
+{
+    delete fIn;
+    delete fList;
+}
+
+// --------------------------------------------------------------------------
+//
+// Wrapper. Returns the MReportHelp with the given identifier from the
+// hash table.
+//
+MReportHelp *MReportFileRead::GetReportHelp(const TString &str) const
+{
+    return (MReportHelp*)fList->FindObject(str);
+}
+
+// --------------------------------------------------------------------------
+//
+// Wrapper. Returns the MReport stored in the given MReportHelp
+//
+MReport *MReportFileRead::GetReport(MReportHelp *help) const
+{
+    return help ? help->GetReport() : 0;
+}
+
+// --------------------------------------------------------------------------
+//
+// Wrapper. Returns the MReport stored in the MReportHelp given by its
+// identifier.
+//
+MReport *MReportFileRead::GetReport(const TString &str) const
+{
+    return GetReport(GetReportHelp(str));
+}
+
+// --------------------------------------------------------------------------
+//
+// Add a new MReport* to the list (eg 'Drive' will add MReportDrive)
+// For convinience the object is created as a MReportHelp object.
+//
+Bool_t MReportFileRead::AddToList(const char *name) const
+{
+    MReportHelp *help = new MReportHelp(name, fLog);
+
+    if (!help->GetReport())
+        return kFALSE;
+
+    if (GetReport(help->GetName()))
+    {
+        *fLog << warn << "WARNING - Report with Identifier '";
+        *fLog << help->GetName() << "' already added to the list... ";
+        *fLog << "ignored." << endl;
+        delete help;
+        return kFALSE;
+    }
+
+    fList->Add(help);
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Check whether the file header corresponds to a central control file
+// header and check for the existance of a correct version number.
+// The version number may later be used to be able to read different
+// file versions
+//
+Int_t MReportFileRead::CheckFileHeader() const
+{
+    Int_t line = 0;
+
+    TString str;
+    str.ReadLine(*fIn);   // Read to EOF or newline
+    if (str != gsReportHeader)
+    {
+        *fLog << err << "ERROR - First line doesn't match '" << gsReportHeader <<"' ";
+        *fLog << "in file '" << fFileName << "'"<<endl;
+        return line;
+    }
+    line++;
+
+    str.ReadLine(*fIn);   // Read to EOF or newline
+    if (!str.BeginsWith(gsVersionPrefix))
+    {
+        *fLog << err << "ERROR - Version prefix '" << gsVersionPrefix <<"' ";
+        *fLog << "not found in second line of file '" << fFileName << "'"<<endl;
+        return line;
+    }
+    line++;
+
+    str.Remove(0, gsVersionPrefix.Length());
+    str = str.Strip(TString::kBoth);
+
+    TString ver = str(TRegexp("^[0-9][0-9][0-9][0-9][0-9][0-9]-[0-9]$"));
+    if (ver.IsNull())
+    {
+        *fLog << err << "ERROR - Version string '" << str <<"' doesn't ";
+        *fLog << "match regular expression." << endl;
+        return line;
+    }
+
+    *fLog << dbg << "Report File version: <" << ver << ">" << endl;
+
+    return line;
+}
+
+// --------------------------------------------------------------------------
+//
+// Call SetupReading for all MReportHelp objects scheduled.
+// Try to open the file and check the file header.
+//
+Int_t MReportFileRead::PreProcess(MParList *pList)
+{
+    //MTime *time = (MTime*)pList->FindCreateObj("MTime");
+    //if (!time)
+    //    return kFALSE;
+    fNumLine = 0;
+
+    TIter Next(fList);
+    MReportHelp *help=0;
+    while ((help=(MReportHelp*)Next()))
+        if (!help->SetupReading(*pList))
+            return kFALSE;
+
+    fList->ForEach(MReportHelp, AddToList)(*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 << "Cannot open file " << fFileName << ": ";
+        *fLog << strerror(errno) << endl;
+        return kFALSE;
+    }
+
+    if (TestBit(kHasNoHeader))
+        return kTRUE;
+
+    const Int_t n = CheckFileHeader();
+    fNumLine += n;
+    return n==2;
+}
+
+// --------------------------------------------------------------------------
+//
+// Read the file line by line as long as a matching MReport* class is found.
+// In this case call its interpreter (Interprete()) and remove the identifier
+// first (XYZ-REPORT)
+//
+Int_t MReportFileRead::Process()
+{
+    TString str;
+
+    MReportHelp *rep=NULL;
+    while (!GetReport(rep))
+    {
+        str.ReadLine(*fIn);
+        if (!*fIn)
+        {
+            *fLog << dbg << "EOF detected." << endl;
+            return kFALSE;
+        }
+
+        fNumLine++;
+
+        const Int_t pos = str.First(' ');
+        if (pos<=0)
+            continue;
+
+        rep = GetReportHelp(str(0,pos));
+        if (GetReport(rep))
+            str.Remove(0, pos);
+    }
+
+    const Int_t rc = rep->Interprete(str, fStart, fStop);
+
+    switch (rc)
+    {
+    case kFALSE:
+        *fLog << err << "ERROR - Interpretation of '" << rep->GetName() << "' failed (Line #" << fNumLine << ")... abort." << endl;
+        break;
+    case kCONTINUE:
+        *fLog << warn << "WARNING - Interpretation of '" << rep->GetName() << "' failed (Line #" << fNumLine << ")... skipped." << endl;
+        break;
+    case -1: // This is the special case: out of time limit
+        return kCONTINUE;
+    }
+
+    return rc;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Close the file and print some execution statistics
+//
+Int_t MReportFileRead::PostProcess()
+{
+    fIn->close();
+
+    if (!GetNumExecutions())
+        return kTRUE;
+
+    *fLog << inf << endl;
+    *fLog << GetDescriptor() << " statistics:" << endl;
+    *fLog << dec << setfill(' ');
+
+    TIter Next(fList);
+    MReportHelp *rep=0;
+
+    while ((rep=(MReportHelp*)Next()))
+    {
+        *fLog << inf;
+        *fLog << " " << setw(7) << rep->GetNumReports() << " (";
+        *fLog << setw(3) << (int)(100.*rep->GetNumReports()/GetNumExecutions());
+        *fLog << "%): " << rep->GetName() << endl;
+
+        if (rep->GetNumSkipped()==0)
+            continue;
+
+        *fLog << warn;
+        *fLog << " " << setw(7) << rep->GetNumSkipped() << " (";
+        *fLog << setw(3) << (int)(100.*rep->GetNumSkipped()/GetNumExecutions());
+        *fLog << "%): " << rep->GetName() << " skipped!" << endl;
+    }
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mreport/MReportFileRead.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mreport/MReportFileRead.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mreport/MReportFileRead.h	(revision 9661)
@@ -0,0 +1,62 @@
+#ifndef MARS_MReportFileRead
+#define MARS_MReportFileRead
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+#ifndef MARS_MTime
+#include "MTime.h"
+#endif
+
+/*// gcc 3.2
+//class ifstream;
+#include <iosfwd>
+*/
+
+class THashTable;
+
+class MTime;
+class MReport;
+class MReportHelp;
+
+class MReportFileRead : public MTask
+{
+private:
+    static const TString gsReportHeader;
+    static const TString gsVersionPrefix;
+
+    TString     fFileName;
+    ifstream   *fIn;         //! buffered input stream (file to read from)
+
+    THashTable *fList;
+
+    MTime fStart;            // Time range which should be read from file
+    MTime fStop;             // Time range which should be read from file
+
+    ULong_t fNumLine;        // line counter
+
+    enum { kHasNoHeader = BIT(14) };
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
+    Int_t CheckFileHeader() const;
+    MReport *GetReport(const TString &str) const;
+    MReport *GetReport(MReportHelp *help) const;
+    MReportHelp *GetReportHelp(const TString &str) const;
+
+public:
+    MReportFileRead(const char *filename, const char *name=NULL, const char *title=NULL);
+    ~MReportFileRead();
+
+    void SetHasNoHeader() { SetBit(kHasNoHeader); }
+    void SetTimeStart(const MTime &tm) { fStart = tm; }
+    void SetTimeStop(const MTime &tm)  { fStop = tm; }
+
+    Bool_t AddToList(const char *name) const;
+
+    ClassDef(MReportFileRead, 0)// Task to read the central control report file
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mreport/MReportHelp.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mreport/MReportHelp.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mreport/MReportHelp.cc	(revision 9661)
@@ -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): Thomas Bretz, 11/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MReportHelp
+//
+// This is a wrapper class for MReport derived files. It provides root-like
+// access to the identifier of the report, such that this identifiers can
+// be used in hast tables to be able to speed up access to the class
+// corresponding to a report identifier. It also provides access to the
+// class by the name of the identifier.
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MReportHelp.h"
+
+#include <TROOT.h>  // gROOT->GeClass
+#include <TClass.h> // TClass
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MReport.h"
+#include "MParList.h"
+
+ClassImp(MReportHelp);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Construtor. Takes the name of the MReport-class (eg MReportDrive) and
+// a log-stream as an argument. The log-stream is used for output in the
+// constructor  An instance of the MReport-class is created using its
+// default constructor.
+//
+MReportHelp::MReportHelp(const char *name, MLog *fLog) : fReport(NULL), fNumReports(0), fNumSkipped(0)
+{
+    TClass *cls = gROOT->GetClass(name);
+    Int_t rc = 0;
+    if (!cls)
+        rc =1;
+    else
+    {
+        if (!cls->Property())
+            rc = 5;
+        if (!cls->Size())
+            rc = 4;
+        if (!cls->IsLoaded())
+            rc = 3;
+        if (!cls->HasDefaultConstructor())
+            rc = 2;
+    }
+
+    if (rc)
+    {
+        *fLog << err << dbginf << "Cannot create new instance of class '" << name << "': ";
+        switch (rc)
+        {
+        case 1:
+            *fLog << "gROOT->GetClass() returned NULL." << endl;
+            return;
+        case 2:
+            *fLog << "no default constructor." << endl;
+            return;
+        case 3:
+            *fLog << "not loaded." << endl;
+            return;
+        case 4:
+            *fLog << "zero size." << endl;
+            return;
+        case 5:
+            *fLog << "no property." << endl;
+            return;
+        }
+    }
+
+    //
+    // create the parameter container of the the given class type
+    //
+    fReport = (MReport*)cls->New();
+}
+
+// --------------------------------------------------------------------------
+//
+// The instance of the MReport-class is deleted
+//
+MReportHelp::~MReportHelp()
+{
+    if (fReport)
+        delete fReport;
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the Identifier ("DRIVE-REPORT") as name. This allows
+// calling FindObject("[identifier]") in lists.
+//
+const char *MReportHelp::GetName() const
+{
+    return fReport->GetIdentifier();
+}
+
+// --------------------------------------------------------------------------
+//
+// Return the Identifier ("DRIVE-REPORT") hash value as hash value. This
+// allows faster access b usage of a THashTable
+//
+ULong_t MReportHelp::Hash() const
+{
+    return fReport->GetIdentifier().Hash();
+}
+
+// --------------------------------------------------------------------------
+//
+// Calls the Interprete function of the report and counts the number of
+// successfull interpretations.
+//
+Int_t MReportHelp::Interprete(TString &str, const MTime &start, const MTime &stop)
+{
+    const Int_t rc = fReport->Interprete(str, start, stop);
+
+    switch (rc)
+    {
+    case kTRUE:     fNumReports++; break;
+    case kCONTINUE: fNumSkipped++; break;
+    }
+    return rc;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calls the Setip function for reading of the report
+//
+Bool_t MReportHelp::SetupReading(MParList &plist)
+{
+    return fReport->SetupReading(plist);
+}
+
+// --------------------------------------------------------------------------
+//
+// Add the report to the given parameter list.
+//
+void MReportHelp::AddToList(MParList &plist)
+{
+    plist.AddToList(fReport);
+}
Index: /tags/Mars_V0-8-5/Mars/mreport/MReportHelp.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mreport/MReportHelp.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mreport/MReportHelp.h	(revision 9661)
@@ -0,0 +1,41 @@
+#ifndef MARS_MReportHelp
+#define MARS_MReportHelp
+
+#ifndef ROOT_TObject
+#include <TObject.h>
+#endif
+
+class TString;
+
+class MLog;
+class MTime;
+class MReport;
+class MParList;
+
+class MReportHelp : public TObject
+{
+private:
+    MReport *fReport;
+    ULong_t  fNumReports;
+    ULong_t  fNumSkipped;
+
+public:
+    MReportHelp(const char *name, MLog *fLog);
+    ~MReportHelp();
+
+    const char *GetName() const;
+    ULong_t GetNumReports() const { return fNumReports; }
+    ULong_t GetNumSkipped() const { return fNumSkipped; }
+    ULong_t Hash() const;
+    MReport *GetReport() { return fReport; }
+
+    Int_t Interprete(TString &str, const MTime &start, const MTime &stop);
+
+    Bool_t SetupReading(MParList &plist);
+    
+    void AddToList(MParList &plist);
+
+    ClassDef(MReportHelp, 0) // Wrapper class for MReport to speed up finding the correct MReport-class
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mreport/MReportRun.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mreport/MReportRun.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mreport/MReportRun.cc	(revision 9661)
@@ -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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MReportRun
+//
+// This is the class interpreting and storing the RUN-REPORT information.
+//
+// PRELIMINARY!
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MReportRun.h"
+
+#include "MLogManip.h"
+
+#include "MAstro.h"
+
+ClassImp(MReportRun);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default construtor. Initialize identifier to "RUN-REPORT" No subsystem
+// is expected.
+//
+MReportRun::MReportRun() : MReport("RUN-REPORT", kFALSE), fRunNumber(-1)
+{
+    fName  = "MReportRun";
+    fTitle = "Class for RUN-REPORT information";
+}
+
+// --------------------------------------------------------------------------
+//
+// Interprete the body of the RUN-REPORT string
+//
+Int_t MReportRun::InterpreteBody(TString &str)
+{
+    const Int_t ws = str.First(' ');
+    if (ws<0)
+    {
+        *fLog << warn << "WARNING - Token not found." << endl;
+        return kCONTINUE;
+    }
+    const TString tok=str(0, ws);
+
+    str.Remove(0, ws);
+    str = str.Strip(TString::kBoth);
+
+    Int_t len, run;
+    const Int_t n=sscanf(str.Data(), "%d %n", &run, &len);
+    if (n!=1)
+    {
+        *fLog << warn << "WARNING - Wrong number of arguments." << endl;
+        return kCONTINUE;
+    }
+    str.Remove(0, len);
+
+    if (tok=="START")
+    {
+        if (fRunNumber!=-1)
+            *fLog << warn << "WARNING - RUN-REPORT STOP missing for run #" << dec << fRunNumber <<  endl;
+        fRunNumber = run;
+    }
+    if (tok=="STOP")
+    {
+        if (fRunNumber==-1)
+            *fLog << warn << "WARNING - RUN-REPORT START missing for run #" << dec << fRunNumber << endl;
+        fRunNumber = -1;
+    }
+
+    Ssiz_t pos = str.First(' ');
+    if (pos<0)
+        pos = str.Length();
+    fSourceName = str(0, pos+1);
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mreport/MReportRun.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mreport/MReportRun.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mreport/MReportRun.h	(revision 9661)
@@ -0,0 +1,27 @@
+#ifndef MARS_MReportRun
+#define MARS_MReportRun
+
+#ifndef MARS_MReport
+#include "MReport.h"
+#endif
+
+class MReportRun : public MReport
+{
+private:
+    Int_t   fRunNumber;
+    TString fSourceName;
+
+    Int_t InterpreteBody(TString &str);
+
+public:
+    MReportRun();
+
+    const TString &GetSourceName() const { return fSourceName; }
+    TString GetSourceName() { return fSourceName; }
+
+    Int_t GetRunNumber() const { return fRunNumber; }
+
+    ClassDef(MReportRun, 0) // Class for RUN-REPORT information
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mreport/MReportTrigger.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mreport/MReportTrigger.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mreport/MReportTrigger.cc	(revision 9661)
@@ -0,0 +1,103 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MReportTrigger
+//
+// This is the class interpreting and storing the TRIGGER-REPORT information.
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MReportTrigger.h"
+
+#include "MLogManip.h"
+
+ClassImp(MReportTrigger);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default construtor. Initialize identifier to "TRIGGER-REPORT"
+//
+MReportTrigger::MReportTrigger() : MReport("TRIGGER-REPORT"), fPrescalerRates(19)
+{
+    fName  = "MReportTrigger";
+    fTitle = "Class for TRIGGER-REPORT information";
+}
+
+// --------------------------------------------------------------------------
+//
+// Interprete the body of the TRIGGER-REPORT string
+//
+Int_t MReportTrigger::InterpreteBody(TString &str)
+{
+    str = str.Strip(TString::kLeading);
+
+    const Int_t ws = str.First(' ');
+    if (ws<=0)
+    {
+        *fLog << warn << "WARNING - Cannot determin name of trigger table." << endl;
+        return kCONTINUE;
+    }
+
+    TString tablename = str(0, ws);
+    str.Remove(0, ws);
+
+    Int_t len, n;
+
+    const char *pos = str.Data();
+    for (int i=0; i<19; i++)
+    {
+        n = sscanf(pos, " %f %n", &fPrescalerRates[i], &len);
+        if (n!=1)
+        {
+            *fLog << warn << "WARNING - Scaler Value #" << i << " missing." << endl;
+            return kCONTINUE;
+        }
+        pos += len;
+    }
+    n = sscanf(pos, " %f %f %n", &fL2BeforePrescaler, &fL2AfterPrescaler, &len);
+    if (n!=2)
+    {
+        *fLog << warn << "WARNING - Couldn't read Trigger rates." << endl;
+        return kFALSE;
+    }
+    pos += len;
+    for (int i=0; i<11; i++)
+    {
+        Float_t dummy;
+        n = sscanf(pos, " %f %n", &dummy/*fRates[i]*/, &len);
+        if (n!=1)
+        {
+            *fLog << warn << "WARNING - Rate #" << i << " missing." << endl;
+            return kFALSE;
+        }
+        pos += len;
+    }
+    str.Remove(0, pos-str.Data());
+    str.Strip(TString::kBoth);
+
+    return str==(TString)"OVER" ? kTRUE : kCONTINUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mreport/MReportTrigger.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mreport/MReportTrigger.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mreport/MReportTrigger.h	(revision 9661)
@@ -0,0 +1,48 @@
+#ifndef MARS_MReportTrigger
+#define MARS_MReportTrigger
+
+#ifndef MARS_MReport
+#include "MReport.h"
+#endif
+#ifndef MARS_MCamEvent
+#include "MCamEvent.h"
+#endif
+
+#ifndef ROOT_TArrayF
+#include <TArrayF.h>
+#endif
+
+class MReportTrigger : public MReport, public MCamEvent
+{
+private:
+    Float_t fL2BeforePrescaler; // L2 trigger rate before prescaler
+    Float_t fL2AfterPrescaler;  // L2 trigger rate after prescaler
+
+    TArrayF fPrescalerRates;    //[Hz] L2 prescaler rates
+    //TArrayF fRates;           //[Hz] currently undefined
+
+    Int_t InterpreteBody(TString &str);
+
+public:
+    MReportTrigger();
+
+    Float_t GetL2BeforePrescaler() const { return fL2BeforePrescaler; }
+    Float_t GetL2AfterPrescaler() const { return fL2AfterPrescaler; }
+
+    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const
+    {
+        if(idx>18)
+            return kFALSE;
+
+        val = fPrescalerRates[idx];
+        return kTRUE;
+    }
+
+    void DrawPixelContent(Int_t num) const
+    {
+    }
+
+    ClassDef(MReportTrigger, 1) // Class for TRIGGER-REPORT information
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mreport/Makefile
===================================================================
--- /tags/Mars_V0-8-5/Mars/mreport/Makefile	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mreport/Makefile	(revision 9661)
@@ -0,0 +1,41 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#------------------------------------------------------------------------------
+
+#
+# Handling name of the Root Dictionary Files
+#
+CINT  = Report
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES = -I. -I../mbase -I../mastro -I../mcamera -I../mgui
+# mgui - MCameraDC <MCamEvent>
+
+SRCFILES = MReport.cc \
+           MReportCC.cc \
+           MReportRun.cc \
+           MReportDAQ.cc \
+           MReportHelp.cc \
+           MReportDrive.cc \
+           MReportCamera.cc \
+           MReportTrigger.cc \
+           MReportCurrents.cc \
+           MReportFileRead.cc
+
+############################################################
+
+all: $(OBJS)
+
+include ../Makefile.rules
+
+mrproper:	clean rmbak
Index: /tags/Mars_V0-8-5/Mars/mreport/ReportIncl.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mreport/ReportIncl.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mreport/ReportIncl.h	(revision 9661)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-8-5/Mars/mreport/ReportLinkDef.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mreport/ReportLinkDef.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mreport/ReportLinkDef.h	(revision 9661)
@@ -0,0 +1,20 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class MReport+;
+
+#pragma link C++ class MReportCC+;
+#pragma link C++ class MReportRun+;
+#pragma link C++ class MReportDAQ+;
+#pragma link C++ class MReportDrive+;
+#pragma link C++ class MReportCamera+;
+#pragma link C++ class MReportTrigger+;
+#pragma link C++ class MReportCurrents+;
+
+#pragma link C++ class MReportHelp+;
+#pragma link C++ class MReportFileRead+;
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/msignal/MArrivalTime.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MArrivalTime.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MArrivalTime.cc	(revision 9661)
@@ -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): Sebastian Raducci, 12/2003 <mailto:raducci@fisica.uniud.it>
+!   Author(s): Markus Gaug        04/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MArrivalTime
+//
+// Times are calculated using the TSpline5 Root Class
+// 
+/////////////////////////////////////////////////////////////////////////////
+#include "MArrivalTime.h"
+
+#include "MGeomCam.h"
+#include "MGeomPix.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MRawEvtPixelIter.h"
+#include "MRawEvtData.h"
+
+ClassImp(MArrivalTime);
+
+using namespace std;
+
+
+// --------------------------------------------------------------------------
+//
+// Creates an object containing the arrival time for each pixel in the event
+//
+MArrivalTime::MArrivalTime(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MArrivalTime";
+    fTitle = title ? title : "Photons arrival times Information";
+}
+
+// -------------------------------------------------------------------------
+//
+// Sets every pixel arrival time to -1
+//
+void MArrivalTime::Reset()
+{
+  fData.Reset(-1);
+  fDataErr.Reset(-1);
+}
+
+void MArrivalTime::InitSize(Int_t i)
+{
+  fData.Set(i);
+  fDataErr.Set(i);
+}
+
+// -------------------------------------------------------------------------
+// 
+// Set the arrival time in one pixel
+//
+void MArrivalTime::SetTime(const Int_t i, const Float_t t)
+{
+    fData[i] = t;
+}
+      
+
+// -------------------------------------------------------------------------
+// 
+// Set the arrival time error in one pixel
+//
+void MArrivalTime::SetTimeErr(const Int_t i, const Float_t t)
+{
+    fDataErr[i] = t;
+}
+      
+// --------------------------------------------------------------------------
+//
+// Returns the arrival time value
+//
+Bool_t MArrivalTime::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
+{
+    if (idx<0 || idx>=fData.GetSize())
+        return kFALSE;
+
+    switch (type)
+    {
+    case 0:
+    case 1:
+        val = fData[idx];
+        break;
+    }
+
+    return kTRUE;
+}
+
+void MArrivalTime::DrawPixelContent(Int_t num) const
+{
+    *fLog << warn << "MArrivalTime::DrawPixelContent - not available." << endl;
+}
Index: /tags/Mars_V0-8-5/Mars/msignal/MArrivalTime.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MArrivalTime.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MArrivalTime.h	(revision 9661)
@@ -0,0 +1,51 @@
+#ifndef MARS_MArrivalTime
+#define MARS_MArrivalTime
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+#ifndef MARS_MCamEvent
+#include "MCamEvent.h"
+#endif
+
+#ifndef ROOT_TArrayF
+#include <TArrayF.h>
+#endif
+#ifndef ROOT_TArrayS
+#include <TArrayS.h>
+#endif
+
+class MRawEvtData;
+
+class MArrivalTime : public MParContainer, public MCamEvent
+{
+private:
+  TArrayF fData;     // Stores the calibrated arrival times
+  TArrayF fDataErr;  // Stores the calibrated arrival time errors
+
+public:
+
+    MArrivalTime(const char *name=NULL, const char *title=NULL);
+    ~MArrivalTime() { }
+
+    void   Reset();
+    void   InitSize(Int_t i);
+
+    UInt_t GetSize() const { return fData.GetSize(); }
+
+    void SetTime(const Int_t i, const Float_t time);
+    void SetTimeErr(const Int_t i, const Float_t timeerr);    
+    
+    const TArrayF &GetData() const { return fData; }
+    const TArrayF &GetDataErr() const { return fDataErr; }
+
+    Double_t operator[](int i) { return fData[i]; }
+    Double_t operator()(int i) { return fDataErr[i]; }    
+
+    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
+    void DrawPixelContent(Int_t num) const;
+
+     ClassDef(MArrivalTime, 0)    // class for an event containing the arrival times
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/msignal/MArrivalTimeCalc.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MArrivalTimeCalc.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MArrivalTimeCalc.cc	(revision 9661)
@@ -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): Sebastian Raducci 12/2003 <mailto:raducci@fisica.uniud.it>
+!
+!   Copyright: MAGIC Software Development, 2002-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//   MArrivalTimeCalc
+//
+//   This is a task that calculates the arrival times of photons. 
+//   It returns the absolute maximum of the spline that interpolates
+//   the FADC slices 
+//
+// Input Containers:
+//   MRawEvtData
+//
+// Output Containers:
+//   MArrivalTime
+//   MRawEvtData
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MArrivalTimeCalc.h"
+
+#include "MCubicSpline.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MGeomCam.h"
+#include "MArrivalTimeCam.h"
+#include "MArrivalTimePix.h"
+
+#include "MRawEvtData.h"      
+#include "MRawEvtPixelIter.h"
+
+#include "MPedestalCam.h"
+#include "MPedestalPix.h"
+
+ClassImp(MArrivalTimeCalc);
+
+using namespace std;
+
+const Byte_t MArrivalTimeCalc::fgSaturationLimit = 254;
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+// 
+MArrivalTimeCalc::MArrivalTimeCalc(const char *name, const char *title) 
+{
+
+    fName  = name  ? name  : "MArrivalTimeCalc";
+    fTitle = title ? title : "Calculate photons arrival time";
+    
+    SetSaturationLimit();
+}
+
+// --------------------------------------------------------------------------
+//
+// The PreProcess searches for the following input containers:
+//  - MRawEvtData
+//  - MPedestalCam
+//
+// The following output containers are also searched and created if
+// they were not found:
+//  - MArrivalTimeCam
+//
+
+Int_t MArrivalTimeCalc::PreProcess(MParList *pList)
+{
+
+    fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData"));
+    if (!fRawEvt)
+    {
+        *fLog << err << "MRawEvtData not found... aborting." << endl;
+        return kFALSE;
+    }
+    
+    fPedestals = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
+    if (!fPedestals)
+    {
+        *fLog << err << AddSerialNumber("MPedestalCam") << " not found... aborting" << endl;
+        return kFALSE;
+    }
+
+
+    fArrTime = (MArrivalTimeCam*)pList->FindCreateObj(AddSerialNumber("MArrivalTimeCam"));
+    if (!fArrTime)
+        return kFALSE;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Evaluation of the mean arrival times (spline interpolation)
+// per pixel and store them in the MArrivalTime container.
+//
+Int_t MArrivalTimeCalc::Process()
+{
+
+  MRawEvtPixelIter pixel(fRawEvt);
+  
+  while (pixel.Next())
+    {
+      
+      const UInt_t idx = pixel.GetPixelId();
+      Float_t time = 0.;
+
+
+      //
+      // If pixel is saturated we use LoGains
+      //
+      if ((pixel.GetMaxHiGainSample() >= fSaturationLimit) && pixel.HasLoGain())
+        {
+          
+          const Short_t nslices = fRawEvt->GetNumLoGainSamples();
+          time = Calc(pixel.GetLoGainSamples(),nslices,idx);
+        }
+      
+
+      //
+      // Use HiGains
+      //
+      else if (pixel.HasLoGain())
+        {
+          
+          const Short_t nslices = fRawEvt->GetNumHiGainSamples();
+          time = Calc(pixel.GetHiGainSamples(),nslices,idx);
+        }
+      
+      //
+      // If pixel is saturated and hasn't lo gains we do nothing, it's value remains -1
+      //
+      MArrivalTimePix &pix = (*fArrTime)[idx];
+      pix.SetArrivalTime(time,0.);
+    }
+    
+  fArrTime->SetReadyToSave();
+  
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculates the arrival time for each pixel 
+// Possible Methods 
+// Case 1: MCubicSpline (3rd order spline)
+//
+Float_t MArrivalTimeCalc::Calc(const Byte_t *fadcSamples, const Short_t nslices, const UInt_t idx)
+{
+
+  //
+  // Initialize the spline
+  //
+  MCubicSpline *spline = new MCubicSpline(fadcSamples);  
+
+  //
+  // Now find the maximum  
+  //
+  Double_t abMaximum = spline->EvalAbMax();
+  Double_t maximum = spline->EvalMax();
+  const MPedestalPix &ped = (*fPedestals)[idx];
+  const Double_t pedestal = ped.GetPedestal();
+  const Double_t halfMax = (maximum + pedestal)/2.;
+  Float_t time = (halfMax > pedestal) ? (Float_t ) spline->FindVal(halfMax,abMaximum,'l'): 0.0;
+  delete spline;
+  return time;
+    
+}
+
Index: /tags/Mars_V0-8-5/Mars/msignal/MArrivalTimeCalc.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MArrivalTimeCalc.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MArrivalTimeCalc.h	(revision 9661)
@@ -0,0 +1,42 @@
+#ifndef MARS_MArrivalTimeCalc
+#define MARS_MArrivalTimeCalc
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MRawEvtData;
+class MRawRunHeader;
+class MArrivalTimeCam;
+class MPedestalCam;
+class MArrivalTimeCalc : public MTask
+{
+
+  static const Byte_t fgSaturationLimit; // Default for fSaturationLimit
+  Byte_t              fSaturationLimit; // Maximum FADC counts before being considered as saturated
+  
+  MRawEvtData    *fRawEvt;     // raw event data (time slices)
+  MRawRunHeader  *fRunHeader;  // RunHeader information
+  MPedestalCam   *fPedestals;  // pedestal information
+  
+  MArrivalTimeCam *fArrTime;   // Container with the photons arrival times
+  
+  Int_t PreProcess(MParList *pList);
+  Int_t Process();
+  Int_t PostProcess() {return kTRUE;}
+  
+  Float_t Calc(const Byte_t *fadcSamples, const Short_t nslices, const UInt_t idx);
+  
+public:
+    MArrivalTimeCalc(const char *name=NULL, const char *title=NULL);
+    ~MArrivalTimeCalc(){}
+ 
+    void SetSaturationLimit(const Byte_t lim=fgSaturationLimit) { fSaturationLimit = lim; }
+    
+    ClassDef(MArrivalTimeCalc, 0)   // Task to calculate Arrival Times from raw data
+};
+
+#endif
+
+
+
Index: /tags/Mars_V0-8-5/Mars/msignal/MArrivalTimeCalc2.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MArrivalTimeCalc2.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MArrivalTimeCalc2.cc	(revision 9661)
@@ -0,0 +1,259 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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, 02/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!              Hendrik Bartko, 02/2004 <mailto:hbartko@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//   MArrivalTimeCalc2
+//
+//  Calculates the arrival time as the mean time of the fWindowSize time slices
+//  which have the highest integral content.
+//
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MArrivalTimeCalc2.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MRawEvtData.h"
+#include "MRawEvtPixelIter.h"
+
+#include "MPedestalCam.h"
+#include "MPedestalPix.h"
+
+#include "MArrivalTimeCam.h"
+#include "MArrivalTimePix.h"
+
+
+ClassImp(MArrivalTimeCalc2);
+
+using namespace std;
+
+const Byte_t MArrivalTimeCalc2::fgSaturationLimit = 254;
+const Byte_t MArrivalTimeCalc2::fgFirst  =  0;
+const Byte_t MArrivalTimeCalc2::fgLast   = 14;
+const Byte_t MArrivalTimeCalc2::fgWindowSize = 6;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+MArrivalTimeCalc2::MArrivalTimeCalc2(const char *name, const char *title)
+  : fSaturationLimit(fgSaturationLimit)
+{
+
+    fName  = name  ? name  : "MArrivalTimeCalc2";
+    fTitle = title ? title : "Task to extract the signal from the FADC slices";
+
+    AddToBranchList("MRawEvtData.*");
+
+    SetRange();
+}
+
+void MArrivalTimeCalc2::SetRange(Byte_t hifirst, Byte_t hilast, Byte_t lofirst, Byte_t lolast, Byte_t windowsize)
+{
+    fNumHiGainSamples = hilast-hifirst+1;
+    fNumLoGainSamples = lolast-lofirst+1;
+
+    fHiGainFirst = hifirst;
+    fLoGainFirst = lofirst;
+
+    fWindowSize = windowsize & ~1;
+
+    if (fWindowSize != windowsize)
+      *fLog << warn << "MArrivalTimeCalc2::SetRange - window size has to be even, set to: " << int(fWindowSize) << " samples " << endl;
+
+    if (fWindowSize<2) 
+    {
+      fWindowSize = 2;
+      *fLog << warn << "MArrivalTimeCalc2::SetRange - window size set to two samples" << endl;
+    }
+
+    if (fWindowSize > fNumHiGainSamples)
+    {
+      fWindowSize = fNumLoGainSamples & ~1;
+      *fLog << warn << "MArrivalTimeCalc2::SetRange - window size set to " << int(fWindowSize) << " samples " << endl;
+    }
+
+    if (fWindowSize > fNumLoGainSamples)
+    {
+      fWindowSize = fNumLoGainSamples & ~1;
+      *fLog << warn << "MArrivalTimeCalc2::SetRange - window size set to " << int(fWindowSize) << " samples " << endl;
+    }
+
+    fWindowSizeSqrt = TMath::Sqrt((Float_t)fWindowSize);
+}
+
+// --------------------------------------------------------------------------
+//
+// The PreProcess searches for the following input containers:
+//  - MRawEvtData
+//  - MPedestalCam
+//
+// The following output containers are also searched and created if
+// they were not found:
+//
+//  - MExtractedSignalCam
+//
+Int_t MArrivalTimeCalc2::PreProcess(MParList *pList)
+{
+    fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData"));
+    if (!fRawEvt)
+    {
+        *fLog << err << AddSerialNumber("MRawEvtData") << " not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fPedestals = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
+    if (!fPedestals)
+    {
+        *fLog << err << AddSerialNumber("MPedestalCam") << " not found... aborting" << endl;
+        return kFALSE;
+    }
+
+    fArrivalTime = (MArrivalTimeCam*)pList->FindCreateObj(AddSerialNumber("MArrivalTimeCam"));
+    if (!fArrivalTime)
+        return kFALSE;
+
+    return kTRUE;
+}
+
+void MArrivalTimeCalc2::FindSignalTime(Byte_t *ptr, Byte_t size, Float_t &time, Float_t &deltatime, Int_t &sat, Float_t pedes, Float_t pedrms) const
+{
+    const Byte_t *end = ptr + size;
+
+    Int_t sum=0;    // integral content of the actual window
+    Int_t max = 0;  // highest integral content of all windows
+
+    //
+    // Calculate the sum of the first fWindowSize slices
+    //
+    sat = 0;
+    Byte_t *p = ptr;
+
+    while (p<ptr+fWindowSize)
+    {
+        sum += *p;
+        if (*p++ >= fSaturationLimit)
+            sat++;
+    }
+
+    //
+    // Check for saturation in all other slices
+    //
+    while (p<end)
+        if (*p++ >= fSaturationLimit)
+            sat++;
+
+    //
+    // Calculate the i-th sum as
+    //    sum_i+1 = sum_i + slice[i+8] - slice[i]
+    // This is fast and accurate (because we are using int's)
+    //
+    max=sum;
+    Byte_t *ptrmax=ptr;  // pointer to the first slice of the maximum window
+
+    for (p=ptr; p+fWindowSize<end; p++)
+    {
+        sum += *(p+fWindowSize) - *p;
+		
+	if (sum>max)
+	{
+	  max = sum;
+	  ptrmax = p+1;
+	}
+    }
+
+    // now calculate the time for the maximum window
+    Int_t timesignalsum = 0;
+    Int_t timesquaredsum =0;
+    Int_t timesum =0;
+
+    for (p=ptrmax; p < ptrmax + fWindowSize; p++)
+    {
+        timesignalsum += *p*(p-ptr);
+        timesum += p-ptr;
+        timesquaredsum  += (p-ptr)*(p-ptr);
+    }
+
+    const Float_t pedsubsum = max - fWindowSize*pedes;
+    const Float_t pedsubtimesignalsum = timesignalsum - timesum*pedes;
+
+    time      = pedsubsum != 0 ? pedsubtimesignalsum / pedsubsum : 1;
+    deltatime = pedsubsum != 0 ? pedrms / pedsubsum * sqrt(timesquaredsum - fWindowSize*time) : 1;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Calculates the arrival time as the mean time of the fWindowSize time slices
+//  which have the highest integral content.
+//
+Int_t MArrivalTimeCalc2::Process()
+{
+    MRawEvtPixelIter pixel(fRawEvt);
+
+    Int_t sat=0;
+    while (pixel.Next())
+    {
+        //
+        // Find signal in hi- and lo-gain
+        //
+        Float_t timehi, timelo, deltatimehi, deltatimelo;
+        Int_t sathi, satlo;
+
+	//
+        // Take correspodning pedestal
+        //
+        const Int_t pixid = pixel.GetPixelId();
+
+	const MPedestalPix  &ped = (*fPedestals)[pixid];
+
+	MArrivalTimePix &pix = (*fArrivalTime)[pixid];
+
+	const Float_t pedes  = ped.GetPedestal();
+	const Float_t pedrms = ped.GetPedestalRms();
+
+	FindSignalTime(pixel.GetHiGainSamples()+fHiGainFirst, fNumHiGainSamples, timehi, deltatimehi, sathi, pedes, pedrms);
+        FindSignalTime(pixel.GetLoGainSamples()+fLoGainFirst, fNumLoGainSamples, timelo, deltatimelo, satlo, pedes, pedrms);
+
+        if (satlo)
+            sat++;
+
+        pix.SetArrivalTime(timehi+ Float_t(fHiGainFirst), deltatimehi, timelo + Float_t(fLoGainFirst), deltatimelo); 
+	pix.SetGainSaturation(sathi, sathi, satlo);
+    }
+
+    fArrivalTime->SetReadyToSave();
+
+    //
+    // Print a warning if event has saturationg lo-gains
+    //
+    //    if (sat)
+    //        *fLog << warn << "WARNING - Lo Gain saturated in " << sat << " pixels." << endl;
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/msignal/MArrivalTimeCalc2.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MArrivalTimeCalc2.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MArrivalTimeCalc2.h	(revision 9661)
@@ -0,0 +1,58 @@
+#ifndef MARS_MArrivalTimeCalc2
+#define MARS_MArrivalTimeCalc2
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MRawEvtData;
+class MRawRunHeader;
+
+class MPedestalCam;
+class MArrivalTimeCam;
+
+class MArrivalTimeCalc2 : public MTask
+{
+private:
+    static const Byte_t fgSaturationLimit;
+    static const Byte_t fgFirst;
+    static const Byte_t fgLast;
+    static const Byte_t fgWindowSize;
+
+    MPedestalCam        *fPedestals;    // Pedestals of all pixels in the camera
+
+    MRawEvtData         *fRawEvt;       // raw event data (time slices)
+    MRawRunHeader       *fRunHeader;    // RunHeader information
+
+    
+    MArrivalTimeCam        *fArrivalTime;  // Arrival Time of FADC sample
+     
+  
+    Byte_t  fHiGainFirst;       // First hi gain to be used
+    Byte_t  fLoGainFirst;       // First lo gain to be used
+
+    Byte_t  fNumHiGainSamples;  // Number of hi gain to be used
+    Byte_t  fNumLoGainSamples;  // Number of lo gain to be used
+
+    Byte_t  fWindowSize;            // Number of gains in window
+    Float_t fWindowSizeSqrt;        // Sqaure root of number of gains in window
+
+    Byte_t  fSaturationLimit;
+
+    void   FindSignalTime(Byte_t *ptr, Byte_t size, Float_t &time,  Float_t &deltatime, Int_t &sat, Float_t pedes, Float_t pedrms) const;
+
+    Int_t  PreProcess(MParList *pList);
+    Int_t  Process();
+
+public:
+    MArrivalTimeCalc2(const char *name=NULL, const char *title=NULL);
+
+    void SetRange(Byte_t hifirst=fgFirst, Byte_t hilast=fgLast, Byte_t lofirst=fgFirst, Byte_t lolast=fgLast, Byte_t windowsize=fgWindowSize);
+    void SetSaturationLimit(Byte_t lim) { fSaturationLimit = lim; }
+
+    ClassDef(MArrivalTimeCalc2, 0) // Calculates the arrival time as the mean time of the fWindowSize time slices
+};
+
+#endif
+
+
Index: /tags/Mars_V0-8-5/Mars/msignal/MArrivalTimeCam.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MArrivalTimeCam.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MArrivalTimeCam.cc	(revision 9661)
@@ -0,0 +1,169 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug  12/2003 <mailto:markus@ifae.es>
+!   Author(s): Thomas Bretz 12/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Hendrik Bartko 02/2004 <mailto:hbartko@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MArrivalTimeCam
+//
+// Hold the ArrivalTime information for all pixels in the camera
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MArrivalTimeCam.h"
+
+#include <TClonesArray.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MArrivalTimePix.h"
+
+ClassImp(MArrivalTimeCam);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. Creates a MArrivalTimePix object for each pixel
+//
+MArrivalTimeCam::MArrivalTimeCam(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MArrivalTimeCam";
+    fTitle = title ? title : "Storage container for all Extracted Signal Information in the camera";
+
+    fArray = new TClonesArray("MArrivalTimePix", 1);
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the array conatining the pixel pedest information
+//
+MArrivalTimeCam::~MArrivalTimeCam()
+{
+    delete fArray;
+}
+
+// --------------------------------------------------------------------------
+//
+// Distribute logging stream to all childs
+//
+void MArrivalTimeCam::SetLogStream(MLog *lg)
+{
+    fArray->ForEach(MParContainer, SetLogStream)(lg);
+    MParContainer::SetLogStream(lg);
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the size of the camera
+//
+void MArrivalTimeCam::InitSize(const UInt_t i)
+{
+    fArray->ExpandCreate(i);
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the size of the MArrivalTimeCam
+//
+Int_t MArrivalTimeCam::GetSize() const
+{
+    return fArray->GetEntriesFast();
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th pixel (pixel index)
+//
+MArrivalTimePix &MArrivalTimeCam::operator[](Int_t i)
+{
+    return *static_cast<MArrivalTimePix*>(fArray->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th pixel (pixel index)
+//
+const MArrivalTimePix &MArrivalTimeCam::operator[](Int_t i) const
+{
+    return *static_cast<MArrivalTimePix*>(fArray->UncheckedAt(i));
+}
+
+void MArrivalTimeCam::Clear(Option_t *o)
+{
+    fArray->ForEach(TObject, Clear)();
+}
+
+void MArrivalTimeCam::Print(Option_t *o) const
+{
+    *fLog << all << GetDescriptor() << ":" << endl;
+    int idx = -1;
+
+    TIter Next(fArray);
+    MArrivalTimePix *pix;
+    while ((pix=(MArrivalTimePix*)Next()))
+    {
+        idx++;
+
+        if (!pix->IsValid())
+            continue;
+
+        *fLog << idx << ": ";
+	pix->Print();
+    }
+}
+
+Bool_t MArrivalTimeCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
+{
+    switch (type)
+    {
+    case 0:
+        val = (*this)[idx].GetArrivalTimeHiGain();
+        break;
+    case 1:
+        val = (*this)[idx].GetArrivalTimeHiGainError();
+        break;
+    case 2:
+        val = (*this)[idx].GetArrivalTimeLoGain();
+        break;
+    case 3:
+        val = (*this)[idx].GetArrivalTimeLoGainError();
+        break;
+    case 4:
+	if ((*this)[idx].GetNumHiGainSaturated() > 0)
+	    val = (*this)[idx].GetArrivalTimeLoGain();
+	else
+	    val = (*this)[idx].GetArrivalTimeHiGain();
+        break;
+    default:
+	return kFALSE;
+    }
+    return val>=0;
+}
+
+void MArrivalTimeCam::DrawPixelContent(Int_t num) const
+{
+    *fLog << warn << "MArrivalTimeCam::DrawPixelContent - not available." << endl;
+}
Index: /tags/Mars_V0-8-5/Mars/msignal/MArrivalTimeCam.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MArrivalTimeCam.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MArrivalTimeCam.h	(revision 9661)
@@ -0,0 +1,67 @@
+#ifndef MARS_MArrivalTimeCam
+#define MARS_MArrivalTimeCam
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#ifndef MARS_MCamEvent
+#include "MCamEvent.h"
+#endif
+
+class TClonesArray;
+class MArrivalTimePix;
+
+class MArrivalTimeCam : public MParContainer, public MCamEvent
+{
+private:
+    TClonesArray *fArray; //-> FIXME: Change TClonesArray away from a pointer?
+
+    Byte_t fFirstUsedSliceHiGain;
+    Byte_t fFirstUsedSliceLoGain;
+
+    Byte_t fLastUsedSliceHiGain;
+    Byte_t fLastUsedSliceLoGain;
+
+public:
+
+    MArrivalTimeCam(const char *name=NULL, const char *title=NULL);
+    ~MArrivalTimeCam();
+
+    void Print(Option_t *o="") const;
+    void Clear(Option_t *o="");
+    void SetLogStream(MLog *lg);
+
+    void InitSize(const UInt_t i);
+    Int_t GetSize() const;
+
+    Byte_t GetNumUsedFADCSlices() const       { return fLastUsedSliceHiGain-fFirstUsedSliceHiGain+1; }
+    Byte_t GetNumUsedHiGainFADCSlices() const { return fLastUsedSliceHiGain-fFirstUsedSliceHiGain+1; }
+    Byte_t GetNumUsedLoGainFADCSlices() const { return fLastUsedSliceLoGain-fFirstUsedSliceLoGain+1; }
+
+    Byte_t GetFirstUsedSliceHiGain() const    { return fFirstUsedSliceHiGain; }
+    Byte_t GetLastUsedSliceHiGain() const     { return fLastUsedSliceHiGain; }
+
+    Byte_t GetFirstUsedSliceLoGain() const    { return fFirstUsedSliceLoGain; }
+    Byte_t GetLastUsedSliceLoGain() const     { return fLastUsedSliceLoGain; }
+
+    void   SetUsedFADCSlices(Byte_t firsth, Byte_t lasth, 
+                             Byte_t firstl, Byte_t lastl)
+    {
+      fFirstUsedSliceHiGain    = firsth;
+      fLastUsedSliceHiGain     = lasth;
+      fFirstUsedSliceLoGain    = firstl;
+      fLastUsedSliceLoGain     = lastl;
+    }
+
+    MArrivalTimePix &operator[](Int_t i);
+    const MArrivalTimePix &operator[](Int_t i) const;
+
+    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
+    void DrawPixelContent(Int_t num) const;
+
+    ClassDef(MArrivalTimeCam, 1)	// Storage Container for the ArrivalTime in the camera
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/msignal/MArrivalTimePix.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MArrivalTimePix.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MArrivalTimePix.cc	(revision 9661)
@@ -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): Markus Gaug  12/2003 <mailto:markus@ifae.es>
+!   Author(s): Thomas Bretz 12/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Hendrik Bartko 02/2004 <mailto:hbartko@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MArrivalTimePix
+//
+// This is the storage container to hold informations about the ArrivalTime
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MArrivalTimePix.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MArrivalTimePix);
+
+using namespace std;
+
+static const Float_t gkSignalInitializer = 99999.9;
+
+// ------------------------------------------------------------------------
+//
+// MArrivalTimePix holds the ArrivalTime (HiGain and LoGain) 
+// of the FADC slices and its error. 
+//
+// Additionally, the number of saturated HiGain and LoGain Slices are stored. 
+// 
+// Default values for the ArrivalTime are: 99999.9 
+//
+MArrivalTimePix::MArrivalTimePix(const char* name, const char* title)
+  : fArrivalTimeHiGain(gkSignalInitializer),
+    fArrivalTimeHiGainError(gkSignalInitializer),
+    fArrivalTimeLoGain(gkSignalInitializer),
+    fArrivalTimeLoGainError(gkSignalInitializer),
+    fNumHiGainSaturated(0),
+    fNumLoGainSaturated(0)
+{
+  fName  = name  ? name  : "MArrivalTimePix";
+  fTitle = title ? title : "Container of the Extracted Signals";
+}
+
+// ------------------------------------------------------------------------
+//
+// Invalidate values
+//
+void MArrivalTimePix::Clear(Option_t *o)
+{
+  fArrivalTimeHiGain      = gkSignalInitializer;
+  fArrivalTimeHiGainError = gkSignalInitializer;
+  fArrivalTimeLoGain      = gkSignalInitializer;
+  fArrivalTimeLoGainError = gkSignalInitializer;
+  
+  fNumHiGainSaturated = 0;
+  fNumLoGainSaturated = 0;
+}
+
+void MArrivalTimePix::SetArrivalTime(Float_t sig, Float_t sigerr)   
+{
+  fArrivalTimeHiGain      = sig; 
+  fArrivalTimeHiGainError = sigerr;
+}
+
+void MArrivalTimePix::SetArrivalTime(Float_t sighi, Float_t sighierr,
+                                     Float_t siglo, Float_t sigloerr)   
+{
+  fArrivalTimeHiGain = sighi;
+  fArrivalTimeHiGainError = sighierr;
+  fArrivalTimeLoGain = siglo;
+  fArrivalTimeLoGainError = sigloerr;
+}
+
+Bool_t MArrivalTimePix::IsValid() const
+{
+    return fArrivalTimeHiGain >= 0. || fArrivalTimeHiGainError >= 0.;
+}
+
+void MArrivalTimePix::SetGainSaturation(Bool_t sat, Byte_t higain, Byte_t logain) 
+{
+
+  fNumHiGainSaturated = higain; 
+  fNumLoGainSaturated = logain;
+}
+
+void MArrivalTimePix::Print(Option_t *o) const
+{
+    *fLog << " Signal: " << fArrivalTimeHiGain
+        << " +- " << fArrivalTimeHiGainError
+        << " Nr. Sat. Hi Gain: " <<  fNumHiGainSaturated
+        << " Nr. Sat. Lo Gain: " <<  fNumLoGainSaturated
+        << endl;
+}
Index: /tags/Mars_V0-8-5/Mars/msignal/MArrivalTimePix.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MArrivalTimePix.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MArrivalTimePix.h	(revision 9661)
@@ -0,0 +1,46 @@
+#ifndef MARS_MArrivalTimePix
+#define MARS_MArrivalTimePix
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MArrivalTimePix : public MParContainer
+{
+private:
+  Float_t fArrivalTimeHiGain;      // mean value of the ArrivalTime
+  Float_t fArrivalTimeHiGainError; // error of the mean value of the ArrivalTime
+  Float_t fArrivalTimeLoGain;      // mean value of the ArrivalTime
+  Float_t fArrivalTimeLoGainError; // error of the mean value of the ArrivalTime
+
+  Byte_t fNumHiGainSaturated;
+  Byte_t fNumLoGainSaturated;
+
+public:
+    MArrivalTimePix(const char* name=NULL, const char* title=NULL);
+
+    void Clear(Option_t *o="");
+    void Print(Option_t *o="") const;
+
+    // Setter
+    void SetArrivalTime(Float_t sig, Float_t sigerr);
+    void SetArrivalTime(Float_t sighi, Float_t sighierr,Float_t siglo, Float_t sigloerr);
+    void SetGainSaturation(Bool_t sat, Byte_t higain, Byte_t logain);
+
+    // Getter
+    Float_t GetArrivalTimeHiGain()      const { return fArrivalTimeHiGain; }
+    Float_t GetArrivalTimeHiGainError() const { return fArrivalTimeHiGainError; }
+
+    Float_t GetArrivalTimeLoGain()      const { return fArrivalTimeLoGain; }
+    Float_t GetArrivalTimeLoGainError() const { return fArrivalTimeLoGainError; }
+
+    Byte_t GetNumHiGainSaturated()      const { return fNumHiGainSaturated; }
+    Byte_t GetNumLoGainSaturated()      const { return fNumLoGainSaturated; }
+
+    Bool_t IsLoGainUsed() const { return fNumHiGainSaturated > 0; }
+    Bool_t IsValid() const;   
+
+    ClassDef(MArrivalTimePix, 1)	// Storage Container for ArrivalTime information of one pixel
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractAmplitudeSpline.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractAmplitudeSpline.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractAmplitudeSpline.cc	(revision 9661)
@@ -0,0 +1,644 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analyzing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!   Author(s): Markus Gaug       05/2004 <mailto:markus@ifae.es> 
+!
+!   Copyright: MAGIC Software Development, 2002-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//   MExtractTimeAndChargeSpline
+//
+//   Fast Spline extractor using a cubic spline algorithm of Numerical Recipes. 
+//   It returns the integral below the interpolating spline. 
+// 
+//   Call: SetRange(fHiGainFirst, fHiGainLast, fLoGainFirst, fLoGainLast) 
+//         to modify the ranges. Ranges have to be an even number. In case of odd 
+//         ranges, the last slice will be reduced by one.
+//
+//  Defaults are: 
+// 
+//   fHiGainFirst =  fgHiGainFirst =  3 
+//   fHiGainLast  =  fgHiGainLast  =  14
+//   fLoGainFirst =  fgLoGainFirst =  3 
+//   fLoGainLast  =  fgLoGainLast  =  14
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MExtractAmplitudeSpline.h"
+
+#include "MExtractedSignalCam.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MExtractAmplitudeSpline);
+
+using namespace std;
+
+const Byte_t  MExtractAmplitudeSpline::fgHiGainFirst  = 2;
+const Byte_t  MExtractAmplitudeSpline::fgHiGainLast   = 14;
+const Byte_t  MExtractAmplitudeSpline::fgLoGainFirst  = 3;
+const Byte_t  MExtractAmplitudeSpline::fgLoGainLast   = 14;
+const Float_t MExtractAmplitudeSpline::fgResolution   = 0.003;
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+// Calls: 
+// - SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast)
+// 
+MExtractAmplitudeSpline::MExtractAmplitudeSpline(const char *name, const char *title) 
+    : fHiGainSignal(NULL), fLoGainSignal(NULL),
+      fHiGainFirstDeriv(NULL), fLoGainFirstDeriv(NULL),
+      fHiGainSecondDeriv(NULL), fLoGainSecondDeriv(NULL)
+{
+
+  fName  = name  ? name  : "MExtractAmplitudeSpline";
+  fTitle = title ? title : "Signal Extractor for a fixed FADC window using a fast spline";
+
+  SetResolution();
+  SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast);
+}
+
+MExtractAmplitudeSpline::~MExtractAmplitudeSpline()
+{
+  
+  if (fHiGainSignal)
+    delete [] fHiGainSignal;
+  if (fLoGainSignal)
+    delete [] fLoGainSignal;
+  if (fHiGainFirstDeriv)
+    delete [] fHiGainFirstDeriv;
+  if (fLoGainFirstDeriv)
+    delete [] fLoGainFirstDeriv;
+  if (fHiGainSecondDeriv)
+    delete [] fHiGainSecondDeriv;
+  if (fLoGainSecondDeriv)
+    delete [] fLoGainSecondDeriv;
+  
+}
+
+// --------------------------------------------------------------------------
+//
+// SetRange: 
+//
+// Checks: 
+// - if the window defined by (fHiGainLast-fHiGainFirst-1) are odd, subtract one
+// - if the window defined by (fLoGainLast-fLoGainFirst-1) are odd, subtract one
+// - if the Hi Gain window is smaller than 2, set fHiGainLast to fHiGainFirst+1
+// - if the Lo Gain window is smaller than 2, set fLoGainLast to fLoGainFirst+1
+// 
+// Calls:
+// - MExtractor::SetRange(hifirst,hilast,lofirst,lolast);
+// 
+// Sets:
+// - fNumHiGainSamples to: (Float_t)(fHiGainLast-fHiGainFirst+1)
+// - fNumLoGainSamples to: (Float_t)(fLoGainLast-fLoGainFirst+1)
+// - fSqrtHiGainSamples to: TMath::Sqrt(fNumHiGainSamples)
+// - fSqrtLoGainSamples to: TMath::Sqrt(fNumLoGainSamples)  
+//  
+void MExtractAmplitudeSpline::SetRange(Byte_t hifirst, Byte_t hilast, Byte_t lofirst, Byte_t lolast)
+{
+
+
+  MExtractor::SetRange(hifirst,hilast,lofirst,lolast);
+
+  fNumHiGainSamples = 2.;
+  fNumLoGainSamples = 2.;
+
+  fSqrtHiGainSamples = TMath::Sqrt(fNumHiGainSamples);
+  fSqrtLoGainSamples = TMath::Sqrt(fNumLoGainSamples);
+
+  fHiLoLast  = 0;
+  
+}
+
+// --------------------------------------------------------------------------
+//
+// ReInit
+//
+// Calls:
+// - MExtractor::ReInit(pList);
+// - fSignals->SetUsedFADCSlices(fHiGainFirst, fHiGainLast+fHiLoLast, fNumHiGainSamples,
+//                                fLoGainFirst, fLoGainLast, fNumLoGainSamples);
+// 
+// Deletes all arrays, if not NULL
+// Creates new arrays according to the extraction range
+//
+Bool_t MExtractAmplitudeSpline::ReInit(MParList *pList)
+{
+
+  if (!MExtractor::ReInit(pList))
+    return kFALSE;
+
+  fSignals->SetUsedFADCSlices(fHiGainFirst, fHiGainLast+fHiLoLast, fNumHiGainSamples,
+                              fLoGainFirst, fLoGainLast, fNumLoGainSamples);
+
+  if (fHiGainSignal)
+    delete [] fHiGainSignal;
+  if (fHiGainFirstDeriv)
+    delete [] fHiGainFirstDeriv;
+  if (fHiGainSecondDeriv)
+    delete [] fHiGainSecondDeriv;
+  if (fLoGainSignal)
+    delete [] fLoGainSignal;
+  if (fLoGainFirstDeriv)
+    delete [] fLoGainFirstDeriv;
+  if (fLoGainSecondDeriv)
+    delete [] fLoGainSecondDeriv;
+  
+  Int_t range = fHiGainLast - fHiGainFirst + 1 + fHiLoLast;
+
+  fHiGainSignal = new Float_t[range];
+  memset(fHiGainSignal,0,range*sizeof(Float_t));
+  fHiGainFirstDeriv  = new Float_t[range];
+  memset(fHiGainFirstDeriv,0,range*sizeof(Float_t));
+  fHiGainSecondDeriv = new Float_t[range];
+  memset(fHiGainSecondDeriv,0,range*sizeof(Float_t));
+
+  *fLog << endl;
+  *fLog << inf << GetDescriptor() << ": Using for High-Gain Extraction " << range
+        << " FADC samples from " 
+        << Form("%s%2i%s"," High Gain slice ",(Int_t)fHiGainFirst," to (including) ")
+        << Form("%s%2i",fHiLoLast ? "Low Gain slice " : " High Gain slice ",
+                fHiLoLast ?  (Int_t)fHiLoLast : (Int_t)fHiGainLast ) 
+        << endl;
+
+  range = fLoGainLast - fLoGainFirst + 1;
+
+  fLoGainSignal = new Float_t[range];
+  memset(fLoGainSignal,0,range*sizeof(Float_t));
+  fLoGainFirstDeriv  = new Float_t[range];
+  memset(fLoGainFirstDeriv,0,range*sizeof(Float_t));
+  fLoGainSecondDeriv = new Float_t[range];
+  memset(fLoGainSecondDeriv,0,range*sizeof(Float_t));
+
+  *fLog << endl;
+  *fLog << inf << GetDescriptor() << ": Using for Low-Gain Extraction " << range
+        << " FADC samples from " 
+        << Form("%s%2i%s%2i"," Low Gain slice ",(Int_t)fLoGainFirst,
+                " to (including) ",(Int_t)fLoGainLast) << endl;
+
+  return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// FindSignalHiGain:
+//
+// - Loop from ptr to (ptr+fHiGainLast-fHiGainFirst)
+// - Sum up contents of *ptr
+// - If *ptr is greater than fSaturationLimit, raise sat by 1
+// 
+// - If fHiLoLast is not 0, loop also from logain to (logain+fHiLoLast)
+// - Sum up contents of logain
+// - If *logain is greater than fSaturationLimit, raise sat by 1
+//
+void MExtractAmplitudeSpline::FindSignalHiGain(Byte_t *ptr, Byte_t *logain, Float_t &sum, Byte_t &sat) const
+{
+  
+  Int_t count   = 0;
+  Float_t abmaxpos = 0.;
+  Byte_t max    = 0;
+  Byte_t maxpos = 0;
+  
+  Int_t range = fHiGainLast - fHiGainFirst + 1;
+  Byte_t *end = ptr + range;
+  Byte_t *p     = ptr;
+  //
+  // Check for saturation in all other slices
+  //
+  while (++p<end)
+    {
+      
+      fHiGainSignal[count] = (Float_t)*p;
+      
+      if (*p > max)
+        {
+          max    = *p;
+          maxpos =  count;
+        }
+      
+      count++;
+      
+      if (*p >= fSaturationLimit)
+        {
+          sat++;
+              break;
+        }
+    }
+  
+  if (fHiLoLast != 0)
+    {
+      
+      p    = logain;
+      end  = logain + fHiLoLast + 1;
+      
+      while (p<end)
+        {
+          
+          fHiGainSignal[count] = (Float_t)*p;
+
+          if (*p > max)
+            {
+              max    = *p;
+              maxpos =  count;
+            }
+          
+          range++;
+          count++;
+
+          if (*p++ >= fSaturationLimit)
+            {
+              sat++;
+              break;
+            }
+        }
+    }
+
+  //
+  // allow one saturated slice 
+  //
+  if (sat > 1)
+    return;
+
+  //
+  // Don't start if the maxpos is too close to the left limit.
+  //
+  if (maxpos < 2)
+    return;
+
+  Float_t pp;
+  fHiGainSecondDeriv[0] = 0.;
+  fHiGainFirstDeriv[0]  = 0.;
+
+  for (Int_t i=1;i<range-1;i++)
+    {
+      pp = fHiGainSecondDeriv[i-1] + 4.;
+      fHiGainSecondDeriv[i] = -1.0/pp;
+      fHiGainFirstDeriv [i] = fHiGainSignal[i+1] - fHiGainSignal[i] - fHiGainSignal[i] + fHiGainSignal[i-1];
+      fHiGainFirstDeriv [i] = (6.0*fHiGainFirstDeriv[i]-fHiGainFirstDeriv[i-1])/pp;
+      p++;
+    }
+
+  fHiGainSecondDeriv[range-1] = 0.;
+  for (Int_t k=range-2;k>=0;k--)
+    fHiGainSecondDeriv[k] = (fHiGainSecondDeriv[k]*fHiGainSecondDeriv[k+1] + fHiGainFirstDeriv[k])/6.;
+  
+  //
+  // Now find the maximum  
+  //
+  Float_t step  = 0.2; // start with step size of 1ns and loop again with the smaller one
+  Float_t lower = (Float_t)maxpos-1.;
+  Float_t upper = (Float_t)maxpos;
+  Float_t x     = lower;
+  Float_t y     = 0.;
+  Float_t a     = 1.;
+  Float_t b     = 0.;
+  Int_t   klo = maxpos-1;
+  Int_t   khi = maxpos;
+  Float_t klocont = fHiGainSignal[klo];
+  Float_t khicont = fHiGainSignal[khi];
+  sum       = khicont;
+  abmaxpos  = lower;
+
+  //
+  // Search for the maximum, starting in interval maxpos-1. If no maximum is found, go to 
+  // interval maxpos+1.
+  //
+  while (x<upper-0.3)
+    {
+
+      x += step;
+      a -= step;
+      b += step;
+
+      y = a*klocont
+        + b*khicont
+        + (a*a*a-a)*fHiGainSecondDeriv[klo] 
+        + (b*b*b-b)*fHiGainSecondDeriv[khi];
+
+      if (y > sum)
+        {
+          sum      = y;
+          abmaxpos = x;
+        }
+    }
+
+  if (abmaxpos > upper-0.1)
+    {
+      
+      upper = (Float_t)maxpos+1;
+      lower = (Float_t)maxpos;
+      x     = lower;
+      a     = 1.;
+      b     = 0.;
+      khi   = maxpos+1;
+      klo   = maxpos;
+      klocont = fHiGainSignal[klo];
+      khicont = fHiGainSignal[khi];
+
+      while (x<upper-0.3)
+        {
+
+          x += step;
+          a -= step;
+          b += step;
+          
+          y = a* klocont
+            + b* khicont
+            + (a*a*a-a)*fHiGainSecondDeriv[klo] 
+            + (b*b*b-b)*fHiGainSecondDeriv[khi];
+          
+          if (y > sum)
+            {
+              sum    = y;
+              abmaxpos = x;
+            }
+        }
+    }
+
+ const Float_t up = abmaxpos+step-0.055;
+ const Float_t lo = abmaxpos-step+0.055;
+ const Float_t maxpossave = abmaxpos;
+ 
+ x     = abmaxpos;
+ a     = upper - x;
+ b     = x - lower;
+
+  step  = 0.04; // step size of 83 ps 
+
+  while (x<up)
+    {
+
+      x += step;
+      a -= step;
+      b += step;
+      
+      y = a* klocont
+        + b* khicont
+        + (a*a*a-a)*fHiGainSecondDeriv[klo] 
+        + (b*b*b-b)*fHiGainSecondDeriv[khi];
+      
+      if (y > sum)
+        {
+          sum    = y;
+          abmaxpos = x;
+        }
+    }
+
+ if (abmaxpos < klo + 0.02)
+    {
+      klo--;
+      khi--;
+      klocont = fHiGainSignal[klo];
+      khicont = fHiGainSignal[khi];
+      upper--;
+      lower--;
+    }
+ 
+  x     = maxpossave;
+  a     = upper - x;
+  b     = x - lower;
+
+  while (x>lo)
+    {
+
+      x -= step;
+      a += step;
+      b -= step;
+      
+      y = a* klocont
+        + b* khicont
+        + (a*a*a-a)*fHiGainSecondDeriv[klo] 
+        + (b*b*b-b)*fHiGainSecondDeriv[khi];
+      
+      if (y > sum)
+        sum      = y;
+    }
+}
+
+
+// --------------------------------------------------------------------------
+//
+// FindSignalLoGain:
+//
+// - Loop from ptr to (ptr+fLoGainLast-fLoGainFirst)
+// - Sum up contents of *ptr
+// - If *ptr is greater than fSaturationLimit, raise sat by 1
+// 
+void MExtractAmplitudeSpline::FindSignalLoGain(Byte_t *ptr, Float_t &sum, Byte_t &sat) const
+{
+  
+  Int_t count   = 0;
+  Float_t abmaxpos = 0.;
+  Byte_t max    = 0;
+  Byte_t maxpos = 0;
+  
+  Int_t range = fLoGainLast - fLoGainFirst + 1;
+  Byte_t *end = ptr + range;
+  Byte_t *p   = ptr;
+  //
+  // Check for saturation in all other slices
+  //
+  while (++p<end)
+    {
+      
+      fLoGainSignal[count] = (Float_t)*p;
+      
+      if (*p > max)
+        {
+          max    = *p;
+          maxpos =  count;
+        }
+      
+      range++;
+      count++;
+      
+      if (*p >= fSaturationLimit)
+        {
+          sat++;
+              break;
+        }
+    }
+  
+
+  //
+  // allow one saturated slice 
+  //
+  if (sat > 1)
+    return;
+
+  //
+  // Don't start if the maxpos is too close to the left limit.
+  //
+  if (maxpos < 2)
+    return;
+
+  Float_t pp;
+  fLoGainSecondDeriv[0] = 0.;
+  fLoGainFirstDeriv[0]  = 0.;
+
+  for (Int_t i=1;i<range-1;i++)
+    {
+      pp = fLoGainSecondDeriv[i-1] + 4.;
+      fLoGainSecondDeriv[i] = -1.0/pp;
+      fLoGainFirstDeriv [i] = fLoGainSignal[i+1] - fLoGainSignal[i] - fLoGainSignal[i] + fLoGainSignal[i-1];
+      fLoGainFirstDeriv [i] = (6.0*fLoGainFirstDeriv[i]-fLoGainFirstDeriv[i-1])/pp;
+      p++;
+    }
+
+  fLoGainSecondDeriv[range-1] = 0.;
+  for (Int_t k=range-2;k>=0;k--)
+    fLoGainSecondDeriv[k] = (fLoGainSecondDeriv[k]*fLoGainSecondDeriv[k+1] + fLoGainFirstDeriv[k])/6.;
+  
+  //
+  // Now find the maximum  
+  //
+  Float_t step  = 0.2; // start with step size of 1ns and loop again with the smaller one
+  Float_t lower = (Float_t)maxpos-1.;
+  Float_t upper = (Float_t)maxpos;
+  Float_t x     = lower;
+  Float_t y     = 0.;
+  Float_t a     = 1.;
+  Float_t b     = 0.;
+  Int_t   klo = maxpos-1;
+  Int_t   khi = maxpos;
+  Float_t klocont = fLoGainSignal[klo];
+  Float_t khicont = fLoGainSignal[khi];
+  sum       = khicont;
+  abmaxpos  = lower;
+
+  //
+  // Search for the maximum, starting in interval maxpos-1. If no maximum is found, go to 
+  // interval maxpos+1.
+  //
+  while (x<upper-0.3)
+    {
+
+      x += step;
+      a -= step;
+      b += step;
+
+      y = a*klocont
+        + b*khicont
+        + (a*a*a-a)*fLoGainSecondDeriv[klo] 
+        + (b*b*b-b)*fLoGainSecondDeriv[khi];
+
+      if (y > sum)
+        {
+          sum      = y;
+          abmaxpos = x;
+        }
+    }
+
+  if (abmaxpos > upper-0.1)
+    {
+      
+      upper = (Float_t)maxpos+1;
+      lower = (Float_t)maxpos;
+      x     = lower;
+      a     = 1.;
+      b     = 0.;
+      khi   = maxpos+1;
+      klo   = maxpos;
+      klocont = fLoGainSignal[klo];
+      khicont = fLoGainSignal[khi];
+
+      while (x<upper-0.3)
+        {
+
+          x += step;
+          a -= step;
+          b += step;
+          
+          y = a* klocont
+            + b* khicont
+            + (a*a*a-a)*fLoGainSecondDeriv[klo] 
+            + (b*b*b-b)*fLoGainSecondDeriv[khi];
+          
+          if (y > sum)
+            {
+              sum    = y;
+              abmaxpos = x;
+            }
+        }
+    }
+
+ const Float_t up = abmaxpos+step-0.055;
+ const Float_t lo = abmaxpos-step+0.055;
+ const Float_t maxpossave = abmaxpos;
+ 
+ x     = abmaxpos;
+ a     = upper - x;
+ b     = x - lower;
+
+  step  = 0.04; // step size of 83 ps 
+
+  while (x<up)
+    {
+
+      x += step;
+      a -= step;
+      b += step;
+      
+      y = a* klocont
+        + b* khicont
+        + (a*a*a-a)*fLoGainSecondDeriv[klo] 
+        + (b*b*b-b)*fLoGainSecondDeriv[khi];
+      
+      if (y > sum)
+        {
+          sum    = y;
+          abmaxpos = x;
+        }
+    }
+
+ if (abmaxpos < klo + 0.02)
+    {
+      klo--;
+      khi--;
+      klocont = fLoGainSignal[klo];
+      khicont = fLoGainSignal[khi];
+      upper--;
+      lower--;
+    }
+ 
+  x     = maxpossave;
+  a     = upper - x;
+  b     = x - lower;
+
+  while (x>lo)
+    {
+
+      x -= step;
+      a += step;
+      b -= step;
+      
+      y = a* klocont
+        + b* khicont
+        + (a*a*a-a)*fLoGainSecondDeriv[klo] 
+        + (b*b*b-b)*fLoGainSecondDeriv[khi];
+      
+      if (y > sum)
+        sum      = y;
+    }
+}
+
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractAmplitudeSpline.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractAmplitudeSpline.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractAmplitudeSpline.h	(revision 9661)
@@ -0,0 +1,47 @@
+#ifndef MARS_MExtractAmplitudeSpline
+#define MARS_MExtractAmplitudeSpline
+
+#ifndef MARS_MExtractor
+#include "MExtractor.h"
+#endif
+
+class MExtractAmplitudeSpline : public MExtractor
+{
+
+private:
+  
+  static const Byte_t  fgHiGainFirst;    // Default for fHiGainFirst  (now set to: 2)
+  static const Byte_t  fgHiGainLast;     // Default for fHiGainLast   (now set to: 14)
+  static const Byte_t  fgLoGainFirst;    // Default for fLOGainFirst  (now set to: 3)
+  static const Byte_t  fgLoGainLast;     // Default for fLoGainLast   (now set to: 14)
+  static const Float_t fgResolution;     // Default for fResolution   (now set to: 0.003)
+
+  Float_t *fHiGainSignal;                     // Need fast access to the signals in a float way
+  Float_t *fLoGainSignal;                     // Need fast access to the signals in a float way  
+  Float_t *fHiGainFirstDeriv;
+  Float_t *fLoGainFirstDeriv;  
+  Float_t *fHiGainSecondDeriv;
+  Float_t *fLoGainSecondDeriv;  
+
+  Float_t fResolution;                        // The time resolution in FADC units
+  
+  Bool_t ReInit    (MParList *pList);
+  
+  void   FindSignalHiGain(Byte_t *ptr, Byte_t *logain, Float_t &sum, Byte_t &sat) const;
+  void   FindSignalLoGain(Byte_t *ptr, Float_t &sum, Byte_t &sat) const;
+
+public:
+
+  MExtractAmplitudeSpline(const char *name=NULL, const char *title=NULL);
+  ~MExtractAmplitudeSpline();
+  
+  void SetRange(Byte_t hifirst=0, Byte_t hilast=0, Byte_t lofirst=0, Byte_t lolast=0);
+  void SetResolution(Float_t f=fgResolution)     { fResolution = f;  }
+  
+  ClassDef(MExtractAmplitudeSpline, 0)   // Task to Extract the Amplitude using a Fast Spline
+};
+
+#endif
+
+
+
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractBlindPixel.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractBlindPixel.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractBlindPixel.cc	(revision 9661)
@@ -0,0 +1,745 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug, 02/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//   MExtractBlindPixel
+//
+//  Extracts the signal from a fixed window in a given range.
+//
+//  Before run 31693 (gkModificationRun):
+//
+//    Call: SetRange(fHiGainFirst, fHiGainLast, fLoGainFirst, fLoGainLast) 
+//    to modify the ranges. The "low-gain" ranges are used for the NSB rejection 
+//    whereas the high-gain ranges for blind pixel signal extraction. "High-gain" 
+//    ranges can extend to the slices stored as "low-gain" in MRawEvtPixelIter
+//
+//    Defaults are: 
+// 
+//     fHiGainFirst =  fgHiGainFirst =  10 
+//     fHiGainLast  =  fgHiGainLast  =  29
+//     fLoGainFirst =  fgLoGainFirst =  0 
+//     fLoGainLast  =  fgLoGainLast  =  7
+//
+//  After run 31693 (gkModificationRun):
+//
+//   Call: SetFirst(), SetLast() to modify the ranges. No filter is applied, 
+//   but instead the signal amplitude is extracted using Cubic spline. 
+// 
+//    Defaults are: 
+// 
+//     fHiGainFirst =  fgFirst =  0 
+//     fHiGainLast  =  fgLast  =  7
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MExtractBlindPixel.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MRawEvtData.h"
+#include "MRawRunHeader.h"
+#include "MRawEvtPixelIter.h"
+
+#include "MExtractedSignalBlindPixel.h"
+
+#include "MPedestalCam.h"
+#include "MPedestalPix.h"
+
+ClassImp(MExtractBlindPixel);
+
+using namespace std;
+
+const UInt_t  MExtractBlindPixel::fgBlindPixelIds[3] = { 559, 560, 561 };
+const UInt_t  MExtractBlindPixel::fgBlindPixelIdx    = 559;
+const Byte_t  MExtractBlindPixel::fgFirst            =   0;
+const Byte_t  MExtractBlindPixel::fgLast             =   7;
+const Byte_t  MExtractBlindPixel::fgHiGainFirst      =  10;
+const Byte_t  MExtractBlindPixel::fgHiGainLast       =  19;
+const Byte_t  MExtractBlindPixel::fgLoGainFirst      =   0;
+const Byte_t  MExtractBlindPixel::fgLoGainLast       =   7;
+const Int_t   MExtractBlindPixel::fgNSBFilterLimit   =  70;
+const Float_t MExtractBlindPixel::fgResolution       = 0.003;
+const UInt_t  MExtractBlindPixel::gkModificationRun  = 31693;
+const Float_t MExtractBlindPixel::gkOverflow         = 300.;
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+// Initializes:
+// - fBlindPixelIdx to fgBlindPixelIdx
+// - fNSBFilterLimit to fgNSBFilterLimit
+// - fResolution to fgResolution
+// - fExtractionType to 0.
+//
+// Calls:
+// - SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast);
+//
+MExtractBlindPixel::MExtractBlindPixel(const char *name, const char *title)
+    : fHiGainSignal(NULL),
+      fHiGainFirstDeriv(NULL), 
+      fHiGainSecondDeriv(NULL)
+{
+  
+  fName  = name  ? name  : "MExtractBlindPixel";
+  fTitle = title ? title : "Task to extract the signal from the FADC slices";
+  
+  AddToBranchList("MRawEvtData.*");
+
+  SetResolution();
+  SetNSBFilterLimit();
+  SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast);
+  
+  SetFirst();
+  SetLast();
+
+  Clear();
+
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor: 
+// 
+// - Deletes, (if not NULL):
+//   fHiGainSignal;
+//   fHiGainFirstDeriv;
+//   fHiGainSecondDeriv;
+// 
+MExtractBlindPixel::~MExtractBlindPixel()
+{
+
+  if (fHiGainSignal)
+    delete [] fHiGainSignal;
+  if (fHiGainFirstDeriv)
+    delete [] fHiGainFirstDeriv;
+  if (fHiGainSecondDeriv)
+    delete [] fHiGainSecondDeriv;
+
+}
+
+// --------------------------------------------------------------------------
+//
+// Clear
+//
+// Initializes:
+// - fModified to kFALSE
+// - fBlindPixelIdx to 0
+// - fExtractionType to 0
+// 
+// Calls:
+// - SetBlindPixelIdx()
+// 
+// Deletes and sets to NULL (if exists):
+// - fHiGainSignal
+// - fHiGainFirstDeriv
+// - fHiGainSecondDeriv
+//
+void MExtractBlindPixel::Clear( const Option_t *o)
+{
+
+  fModified       = kFALSE;
+  fExtractionType = 0;
+
+  fBlindPixelIdx.Set(0);
+  SetBlindPixelIdx();
+
+  if (fHiGainSignal)
+    {
+      delete [] fHiGainSignal;
+      fHiGainSignal = NULL;
+    }
+  if (fHiGainFirstDeriv)
+    {
+      delete [] fHiGainFirstDeriv;
+      fHiGainFirstDeriv = NULL;
+    }
+  if (fHiGainSecondDeriv)
+    {
+      delete [] fHiGainSecondDeriv;
+      fHiGainSecondDeriv = NULL;
+    }
+
+}
+
+void MExtractBlindPixel::SetRange(Byte_t hifirst, Byte_t hilast, Byte_t lofirst, Byte_t lolast)
+{
+
+  MExtractor::SetRange(hifirst,hilast,lofirst,lolast);
+
+  fNumHiGainSamples = (Float_t)(fHiGainLast-fHiGainFirst+1);
+  fNumLoGainSamples = (Float_t)(fLoGainLast-fLoGainFirst+1);  
+
+  fSqrtHiGainSamples = TMath::Sqrt(fNumHiGainSamples);
+  fSqrtLoGainSamples = TMath::Sqrt(fNumLoGainSamples);  
+  
+  fHiLoFirst = 0;
+  fHiLoLast  = 0;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calls: 
+// - MExtractor::PreProcess(pList)
+//
+// Sets fModified to kTRUE if the current run number is greater or equal gkModificationRun
+//
+// The following output containers are also searched and created if
+// they were not found:
+//
+//  - MExtractedBlindPixel
+//
+// 
+//
+Int_t MExtractBlindPixel::PreProcess(MParList *pList)
+{
+
+  if (!MExtractor::PreProcess(pList))
+    return kFALSE;
+
+  fBlindPixel = (MExtractedSignalBlindPixel*)pList->FindCreateObj(AddSerialNumber("MExtractedSignalBlindPixel"));
+  if (!fBlindPixel)
+    return kFALSE;
+
+  
+  return kTRUE;
+}
+
+// -------------------------------------------------------------------------- //
+//
+// The ReInit searches for:
+// -  MRawRunHeader::GetNumSamplesHiGain()
+// -  MRawRunHeader::GetNumSamplesLoGain()
+//
+// In case that the variables fHiGainLast and fLoGainLast are smaller than 
+// the even part of the number of samples obtained from the run header, a
+// warning is given an the range is set back accordingly. A call to:  
+// - SetRange(fHiGainFirst, fHiGainLast-diff, fLoGainFirst, fLoGainLast) or 
+// - SetRange(fHiGainFirst, fHiGainLast, fLoGainFirst, fLoGainLast-diff) 
+// is performed in that case. The variable diff means here the difference 
+// between the requested range (fHiGainLast) and the available one. Note that 
+// the functions SetRange() are mostly overloaded and perform more checks, 
+// modifying the ranges again, if necessary.
+//
+Bool_t MExtractBlindPixel::ReInit(MParList *pList)
+{
+  
+  if (fHiGainSignal)
+    delete [] fHiGainSignal;
+  if (fHiGainFirstDeriv)
+    delete [] fHiGainFirstDeriv;
+  if (fHiGainSecondDeriv)
+    delete [] fHiGainSecondDeriv;
+
+  if ( fRunHeader->GetRunNumber() >= gkModificationRun )
+  {
+      fModified = kTRUE;
+      SetExtractionType(kAmplitude);
+      SetRange(fFirst,fLast);
+      for (Int_t i=0;i<3;i++)
+      {
+	  SetBlindPixelIdx(fgBlindPixelIds[i],i);
+	  fBlindPixel->SetBlindPixelIdx(fgBlindPixelIds[i],i);
+      }
+  }
+  else
+  {
+      fBlindPixel->SetBlindPixelIdx(fBlindPixelIdx.At(0));
+      SetExtractionType(kIntegral);
+      SetExtractionType(kFilter);
+  }
+
+  fBlindPixel->SetExtractionType(fExtractionType);
+
+  for (Int_t i=0;i<fBlindPixelIdx.GetSize();i++)
+  {
+
+      MPedestalPix &pedpix  = (*fPedestals)[fBlindPixelIdx.At(i)];    
+      
+      if (&pedpix)
+      {
+	  fBlindPixel->SetPed      ( pedpix.GetPedestal()   * fNumLoGainSamples, i );
+	  fBlindPixel->SetPedErr   ( pedpix.GetPedestalRms()* fNumLoGainSamples 
+                                 / TMath::Sqrt((Float_t)fPedestals->GetTotalEntries()), i );
+	  fBlindPixel->SetPedRms   ( pedpix.GetPedestalRms()* TMath::Sqrt((Float_t)fNumLoGainSamples), i );
+	  fBlindPixel->SetPedRmsErr( fBlindPixel->GetPedErr()/2., i );
+      }
+  }
+
+  const Int_t firstdesired   = (Int_t)fHiGainFirst;
+  Int_t lastavailable  = (Int_t)fRunHeader->GetNumSamplesHiGain()-1;
+  
+  if (firstdesired > lastavailable)
+  {
+      const Int_t diff = firstdesired - lastavailable;
+      *fLog << endl;
+      *fLog << warn << GetDescriptor()
+            << Form("%s%2i%s%2i%s",": Selected First Hi Gain FADC slice ",
+                    (int)fHiGainFirst,
+                    " ranges out of the available limits: [0,",lastavailable,"].") << endl;
+      *fLog << warn << GetDescriptor() 
+            << Form("%s%2i%s",": Will start with slice ",diff," of the Low-Gain for the High-Gain extraction")
+            << endl;
+      
+      fHiLoFirst   = diff;
+    }
+
+  const Int_t lastdesired   = (Int_t)fHiGainLast;
+  
+  if (lastdesired > lastavailable)
+    {
+      Int_t diff = lastdesired - lastavailable;
+      lastavailable += (Int_t)fRunHeader->GetNumSamplesLoGain()-1;
+      
+      if (lastdesired > lastavailable)
+        {
+          *fLog << endl;
+          *fLog << warn << GetDescriptor()
+                << Form("%s%2i%s%2i%s",": Selected Last Hi Gain FADC slice ",
+                        (int)fHiGainLast,
+                        " ranges out of the available limits: [0,",lastavailable,"].") << endl;
+          *fLog << warn << GetDescriptor() 
+                << Form("%s%2i",": Will reduce upper limit by ",diff)
+                << endl;
+          diff        = (Int_t)fRunHeader->GetNumSamplesLoGain();
+        }
+
+      fHiGainLast = (Int_t)fRunHeader->GetNumSamplesHiGain() - 1;
+      fHiLoLast = diff;
+    }
+
+  const Int_t range = fHiLoFirst ? fHiLoLast - fHiLoFirst + 1 : fHiGainLast - fHiGainFirst + fHiLoLast + 1;
+
+  fHiGainSignal      = new Float_t[range];
+  memset(fHiGainSignal,0,range*sizeof(Float_t));
+  fHiGainFirstDeriv  = new Float_t[range];
+  memset(fHiGainFirstDeriv,0,range*sizeof(Float_t));
+  fHiGainSecondDeriv = new Float_t[range];
+  memset(fHiGainSecondDeriv,0,range*sizeof(Float_t));
+
+  *fLog << endl;
+  *fLog << inf << GetDescriptor() << ": Extracting " 
+	<< Form("%s",IsExtractionType(kAmplitude) ? "Amplitude " : " Integral ")
+	<< " using " << range << " FADC samples from " 
+        << Form("%s%2i",fHiLoFirst ? "Low Gain slice " : " High Gain slice ",
+                fHiLoFirst ? (Int_t)fHiLoFirst : (Int_t)fHiGainFirst) 
+        << " to (including)  " 
+        << Form("%s%2i",fHiLoLast ? "Low Gain slice " : " High Gain slice ",
+                fHiLoLast ?  (Int_t)fHiLoLast-1 : (Int_t)fHiGainLast ) 
+        << endl;
+  if (IsExtractionType(kFilter))
+    *fLog << inf << GetDescriptor() << ": Will use Filter using " 
+	  << (Int_t)(fLoGainLast-fLoGainFirst+1) << " FADC slices " 
+	  << "from High Gain slice " << (Int_t)fLoGainFirst 
+	  << " to High Gain slice " << (Int_t)fLoGainLast << endl;
+
+  fBlindPixel->SetUsedFADCSlices(fHiGainFirst, range);
+
+  return kTRUE;
+
+}
+
+// --------------------------------------------------------------------------
+//
+// FindSignalHiGain:
+//
+// - Loop from ptr to (ptr+fHiGainLast-fHiGainFirst)
+// - Sum up contents of *ptr
+// - If *ptr is greater than fSaturationLimit, raise sat by 1
+// - If fHiLoLast is set, loop from logain to (logain+fHiLoLast)
+// - Add contents of *logain to sum
+// 
+void MExtractBlindPixel::FindIntegral(Byte_t *ptr, Byte_t *logain, Float_t &sum, Byte_t &sat)
+{
+
+  Int_t summ = 0;
+  Byte_t *p     = ptr;
+  Byte_t *end = ptr + fHiGainLast - fHiGainFirst + 1;
+
+  if (fHiLoFirst == 0)
+    {
+
+      while (p<end)
+        {
+          summ += *ptr;
+          
+          if (*p++ >= fSaturationLimit)
+            sat++;
+        }
+      
+    }
+  
+  p   = logain + fHiLoFirst;  
+  end = logain + fHiLoLast;
+  while (p<end)
+    {
+      summ += *p;
+
+      if (*p++ >= fSaturationLimit)
+            sat++;
+    }
+
+  sum = (Float_t)summ;
+}
+
+// --------------------------------------------------------------------------
+//
+// FindSignalPhe:
+//
+// - Loop from ptr to (ptr+fHiGainLast-fHiGainFirst)
+// - Sum up contents of *ptr
+// - If *ptr is greater than fSaturationLimit, raise sat by 1
+// - If fHiLoLast is set, loop from logain to (logain+fHiLoLast)
+// - Add contents of *logain to sum
+// 
+void MExtractBlindPixel::FindAmplitude(Byte_t *ptr, Byte_t *logain, Float_t &sum, Byte_t &sat) 
+{
+
+  Int_t range   = 0;
+  Int_t count   = 0;
+  Float_t abmaxpos = 0.;
+  Byte_t *p     = ptr;
+  Byte_t *end;
+  Byte_t max    = 0;
+  Byte_t maxpos = 0;
+  Int_t summ   = 0;
+
+  if (fHiLoFirst == 0)
+    {
+
+      range = fHiGainLast - fHiGainFirst + 1;
+
+      end   = ptr + range;
+      //
+      // Check for saturation in all other slices
+      //
+      while (p++<end)
+        {
+          
+          fHiGainSignal[count] = (Float_t)*p;
+          summ += *p;
+
+          if (*p > max)
+            {
+              max    = *p;
+              maxpos =  count;
+            }
+          
+          count++;
+
+          if (*p >= fSaturationLimit)
+              sat++;
+        }
+    }
+  
+  if (fHiLoLast != 0)
+    {
+      
+      p    = logain + fHiLoFirst;
+      end  = logain + fHiLoLast;
+      
+      while (p<end)
+        {
+          
+          fHiGainSignal[count] = (Float_t)*p;
+          summ += *p;
+
+          if (*p > max)
+            {
+              max    = *p;
+              maxpos =  count;
+            }
+          
+          range++;
+          count++;
+
+          if (*p++ >= fSaturationLimit)
+              sat++;
+        }
+    }
+
+  //
+  // allow one saturated slice 
+  //
+  if (sat > 1)
+  {
+    sum = gkOverflow;
+    return;
+  }
+
+  //
+  // Don't start if the maxpos is too close to the left limit.
+  //
+  if (maxpos < 2)
+  {
+    sum = (Float_t)max;
+    return;
+  }
+
+  Float_t pp;
+
+  for (Int_t i=1;i<range-1;i++)
+    {
+      pp = fHiGainSecondDeriv[i-1] + 4.;
+      fHiGainSecondDeriv[i] = -1.0/pp;
+      fHiGainFirstDeriv [i] = fHiGainSignal[i+1] - fHiGainSignal[i] - fHiGainSignal[i] + fHiGainSignal[i-1];
+      fHiGainFirstDeriv [i] = (6.0*fHiGainFirstDeriv[i]-fHiGainFirstDeriv[i-1])/pp;
+      p++;
+    }
+
+  fHiGainSecondDeriv[range-1] = 0.;
+  for (Int_t k=range-2;k>=0;k--)
+    fHiGainSecondDeriv[k] = (fHiGainSecondDeriv[k]*fHiGainSecondDeriv[k+1] + fHiGainFirstDeriv[k])/6.;
+  
+  //
+  // Now find the maximum  
+  //
+  Float_t step  = 0.2; // start with step size of 1ns and loop again with the smaller one
+  Float_t lower = (Float_t)maxpos-1.;
+  Float_t upper = (Float_t)maxpos;
+  Float_t x     = lower;
+  Float_t y     = 0.;
+  Float_t a     = 1.;
+  Float_t b     = 0.;
+  Int_t   klo = maxpos-1;
+  Int_t   khi = maxpos;
+  Float_t klocont = fHiGainSignal[klo];
+  Float_t khicont = fHiGainSignal[khi];
+  sum       = (Float_t)khicont;
+  abmaxpos  = lower;
+
+  //
+  // Search for the maximum, starting in interval maxpos-1. If no maximum is found, go to 
+  // interval maxpos+1.
+  //
+  while (x<upper-0.3)
+    {
+
+      x += step;
+      a -= step;
+      b += step;
+
+      y = a*klocont
+        + b*khicont
+        + (a*a*a-a)*fHiGainSecondDeriv[klo] 
+        + (b*b*b-b)*fHiGainSecondDeriv[khi];
+
+      if (y > sum)
+        {
+          sum      = y;
+          abmaxpos = x;
+        }
+    }
+
+  if (abmaxpos > upper-0.1)
+    {
+      
+      upper = (Float_t)maxpos+1;
+      lower = (Float_t)maxpos;
+      x     = lower;
+      a     = 1.;
+      b     = 0.;
+      khi   = maxpos+1;
+      klo   = maxpos;
+      klocont = fHiGainSignal[klo];
+      khicont = fHiGainSignal[khi];
+
+      while (x<upper-0.3)
+        {
+
+          x += step;
+          a -= step;
+          b += step;
+          
+          y = a* klocont
+            + b* khicont
+            + (a*a*a-a)*fHiGainSecondDeriv[klo] 
+            + (b*b*b-b)*fHiGainSecondDeriv[khi];
+          
+          if (y > sum)
+            {
+              sum    = y;
+              abmaxpos = x;
+            }
+        }
+    }
+
+ const Float_t up = abmaxpos+step-0.055;
+ const Float_t lo = abmaxpos-step+0.055;
+ const Float_t maxpossave = abmaxpos;
+ 
+ x     = abmaxpos;
+ a     = upper - x;
+ b     = x - lower;
+
+  step  = 0.04; // step size of 83 ps 
+
+  while (x<up)
+    {
+
+      x += step;
+      a -= step;
+      b += step;
+      
+      y = a* klocont
+        + b* khicont
+        + (a*a*a-a)*fHiGainSecondDeriv[klo] 
+        + (b*b*b-b)*fHiGainSecondDeriv[khi];
+      
+      if (y > sum)
+        {
+          sum    = y;
+          abmaxpos = x;
+        }
+    }
+
+ if (abmaxpos < klo + 0.02)
+    {
+      klo--;
+      khi--;
+      klocont = fHiGainSignal[klo];
+      khicont = fHiGainSignal[khi];
+      upper--;
+      lower--;
+    }
+ 
+  x     = maxpossave;
+  a     = upper - x;
+  b     = x - lower;
+
+  while (x>lo)
+    {
+
+      x -= step;
+      a += step;
+      b -= step;
+      
+      y = a* klocont
+        + b* khicont
+        + (a*a*a-a)*fHiGainSecondDeriv[klo] 
+        + (b*b*b-b)*fHiGainSecondDeriv[khi];
+      
+      if (y > sum)
+        {
+          sum    = y;
+          abmaxpos = x;
+        }
+    }
+
+}
+
+// --------------------------------------------------------------------------
+//
+// FindSignalFilter:
+//
+// - Loop from ptr to (ptr+fLoGainLast-fLoGainFirst)
+// - Sum up contents of *ptr
+// - If *ptr is greater than fSaturationLimit, raise sat by 1
+// 
+void MExtractBlindPixel::FindSignalFilter(Byte_t *ptr, Int_t &sum, Byte_t &sat) const
+{
+
+  Byte_t *end = ptr + fLoGainLast - fLoGainFirst + 1;
+  
+  while (ptr<end)
+    {
+      sum += *ptr;
+      
+      if (*ptr++ >= fSaturationLimit)
+        sat++;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculate the integral of the FADC time slices and store them as a new
+// pixel in the MExtractedBlindPixel container.
+//
+Int_t MExtractBlindPixel::Process()
+{
+
+  MRawEvtPixelIter pixel(fRawEvt);
+  
+  fBlindPixel->Clear();
+  
+  for (Int_t id=0;id<fBlindPixelIdx.GetSize();id++)
+    {
+  
+      pixel.Jump(fBlindPixelIdx[id]);
+      
+      Int_t sum   = 0;
+      Byte_t sat  = 0;
+
+      if (!fModified)
+      {
+
+	  FindSignalFilter(pixel.GetHiGainSamples()+fLoGainFirst, sum, sat);
+	  
+	  if (sum > fNSBFilterLimit)
+	  {
+	      fBlindPixel->SetExtractedSignal(-1.,id);
+	      fBlindPixel->SetNumSaturated(sat,id);
+	      fBlindPixel->SetReadyToSave();
+	      continue;
+	  }
+      }
+
+      Float_t newsum = 0.;
+      sat = 0;
+      
+      if (IsExtractionType(kAmplitude))
+	FindAmplitude   (pixel.GetHiGainSamples()+fHiGainFirst, pixel.GetLoGainSamples(), newsum, sat);
+      else
+	FindIntegral    (pixel.GetHiGainSamples()+fHiGainFirst, pixel.GetLoGainSamples(), newsum, sat);
+  
+      fBlindPixel->SetExtractedSignal(newsum,id);
+      fBlindPixel->SetNumSaturated(sat,id);
+    }
+  
+  fBlindPixel->SetReadyToSave();
+  return kTRUE;
+}
+
+// ------------------------------------------------------------------------------------
+//
+// Returns true if the extraction type. Available are: kAmplitude, kIntegral and kFilter
+// The flags kIntegral and kFilter may be set both. 
+//
+Bool_t MExtractBlindPixel::IsExtractionType( const ExtractionType_t typ )
+{
+  
+  return TESTBIT( fExtractionType, typ );
+
+}
+
+// --------------------------------------------------------------------------
+//
+// Sets the extraction type. Available are: kAmplitude and kIntegral
+//
+void MExtractBlindPixel::SetExtractionType( const ExtractionType_t typ )
+{
+  SETBIT( fExtractionType, typ );
+}
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractBlindPixel.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractBlindPixel.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractBlindPixel.h	(revision 9661)
@@ -0,0 +1,87 @@
+#ifndef MARS_MExtractBlindPixel
+#define MARS_MExtractBlindPixel
+
+#ifndef MARS_MExtractor
+#include "MExtractor.h"
+#endif
+
+#ifndef ROOT_TArrayI
+#include <TArrayI.h>
+#endif
+
+class MExtractedSignalBlindPixel;
+class MExtractBlindPixel : public MExtractor
+{
+private:
+
+  static const UInt_t  fgBlindPixelIds[3]; //! Default blind pixel indices after modification run
+  static const UInt_t  fgBlindPixelIdx;    //! Default blind pixels index before modification run
+  static const Byte_t  fgFirst;            //! Default First FADC slice after modification run (currently set to: 2  ) 
+  static const Byte_t  fgLast ;            //! Default Last  FADC slice after modification run (currently set to: 13 ) 
+  static const Byte_t  fgHiGainFirst;      //! Default First FADC slice Hi-Gain Signal (currently set to: 10   ) 
+  static const Byte_t  fgHiGainLast;       //! Default Last  FADC slice Hi-Gain Signal (currently set to: 29   ) 
+  static const Byte_t  fgLoGainFirst;      //! Default First FADC slice Filter         (currently set to: 0    ) 
+  static const Byte_t  fgLoGainLast;       //! Default Last  FADC slice Filter         (currently set to: 6    ) 
+  static const Int_t   fgNSBFilterLimit;   //! Default for fNSBFilterLimit
+  static const Float_t fgResolution;       //! Default for fResolution         (currently set to: 0.003)
+  static const Float_t gkOverflow;         //! Default sum to assign overflow in case of saturation
+  static const UInt_t  gkModificationRun;  //! Run number from which on three blind pixels are used
+
+  MExtractedSignalBlindPixel *fBlindPixel; // Extracted signal of the Blind Pixel
+
+  Byte_t   fFirst;                         // First extraction slice for runs after modification
+  Byte_t   fLast;                          // Last extraction slice for runs after modification
+  Byte_t   fHiLoFirst;                     // If not zero, start extraction from fHiLoFirst slice of Low-Gain
+
+  Float_t *fHiGainSignal;                  // Need fast access to the signals in a float way
+  Float_t *fHiGainFirstDeriv;              // First derivative at intersection
+  Float_t *fHiGainSecondDeriv;             // Second derivative at intersection
+
+  Float_t fResolution;                     // The time resolution in FADC units
+  TArrayI fBlindPixelIdx;                  // Array holding the IDs of the blind pixel(s)
+  Int_t   fNSBFilterLimit;                 // Limit of sum of FADC slices for filter part
+
+  Bool_t  fModified;                       // Is the run taken after the modifications? 
+  Byte_t  fExtractionType;                 // What extraction type has been chosen?
+
+public:
+  enum ExtractionType_t { kAmplitude, kIntegral, kFilter };
+
+
+private:
+  void FindAmplitude   (Byte_t *firstused, Byte_t *lowgain, Float_t &sum, Byte_t &sat);
+  void FindIntegral    (Byte_t *firstused, Byte_t *lowgain, Float_t &sum, Byte_t &sat);
+  void FindSignalFilter(Byte_t *ptr,                          Int_t &sum, Byte_t &sat) const;
+  
+  Int_t  PreProcess(MParList *pList);
+  Bool_t ReInit(MParList *pList);
+  Int_t  Process();
+
+public:
+
+  MExtractBlindPixel(const char *name=NULL, const char *title=NULL);
+  ~MExtractBlindPixel();
+
+  void Clear( const Option_t *o ="");
+  
+  // Getters
+  Bool_t IsExtractionType ( const ExtractionType_t typ );
+
+  // Setters
+  void SetBlindPixelIdx(  const Int_t  idx=fgBlindPixelIdx, const Int_t nr=0 ) {
+    if (nr>fBlindPixelIdx.GetSize()-1)
+      fBlindPixelIdx.Set(nr+1);
+    fBlindPixelIdx.AddAt(idx,nr); }
+  void SetExtractionType( const ExtractionType_t typ=kAmplitude );
+  void SetFirst         ( const Byte_t         first=fgFirst )  { fFirst          = first; }
+  void SetLast          ( const Byte_t         last =fgLast  )  { fLast           = last;  }
+  void SetNSBFilterLimit( const Int_t   lim=fgNSBFilterLimit )  { fNSBFilterLimit = lim;   }     
+  void SetRange         ( const Byte_t  hifirst=0, const Byte_t hilast=0, 
+   		          const Byte_t  lofirst=0, const Byte_t lolast=0 );
+  void SetResolution    ( const Float_t f=fgResolution       )  { fResolution     = f;     }
+  
+  ClassDef(MExtractBlindPixel, 0) // Signal Extractor for the Blind Pixel
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractFixedWindow.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractFixedWindow.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractFixedWindow.cc	(revision 9661)
@@ -0,0 +1,283 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug, 04/2004 <mailto:markus@ifae.es>
+!              Thomas Bretz, 01/2004 
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MExtractFixedWindow
+//
+//  Extracts the signal from a fixed window in a given range by summing up the 
+//  slice contents.
+//
+//  Call: SetRange(fHiGainFirst, fHiGainLast, fLoGainFirst, fLoGainLast) 
+//  to modify the ranges. Ranges have to be an even number. In case of odd 
+//  ranges, the last slice will be reduced by one.
+//  Defaults are: 
+// 
+//   fHiGainFirst =  fgHiGainFirst =  3 
+//   fHiGainLast  =  fgHiGainLast  =  14
+//   fLoGainFirst =  fgLoGainFirst =  3 
+//   fLoGainLast  =  fgLoGainLast  =  14
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MExtractFixedWindow.h"
+#include "MExtractor.h"
+
+#include <fstream>
+
+#include "MExtractedSignalCam.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MExtractFixedWindow);
+
+using namespace std;
+
+const Byte_t MExtractFixedWindow::fgHiGainFirst =  3;
+const Byte_t MExtractFixedWindow::fgHiGainLast  =  14;
+const Byte_t MExtractFixedWindow::fgLoGainFirst =  3;
+const Byte_t MExtractFixedWindow::fgLoGainLast  =  14;
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+// Calls:
+// - SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast)
+//
+MExtractFixedWindow::MExtractFixedWindow(const char *name, const char *title)
+{
+  fName  = name  ? name  : "MExtractFixedWindow";
+  fTitle = title ? title : "Signal Extractor for a fixed FADC window";
+
+  SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast);
+
+}
+
+// --------------------------------------------------------------------------
+//
+// SetRange: 
+//
+// Checks: 
+// - if the window defined by (fHiGainLast-fHiGainFirst-1) are odd, subtract one
+// - if the window defined by (fLoGainLast-fLoGainFirst-1) are odd, subtract one
+// - if the Hi Gain window is smaller than 2, set fHiGainLast to fHiGainFirst+1
+// - if the Lo Gain window is smaller than 2, set fLoGainLast to fLoGainFirst+1
+// 
+// Calls:
+// - MExtractor::SetRange(hifirst,hilast,lofirst,lolast);
+// 
+// Sets:
+// - fNumHiGainSamples to: (Float_t)(fHiGainLast-fHiGainFirst+1)
+// - fNumLoGainSamples to: (Float_t)(fLoGainLast-fLoGainFirst+1)
+// - fSqrtHiGainSamples to: TMath::Sqrt(fNumHiGainSamples)
+// - fSqrtLoGainSamples to: TMath::Sqrt(fNumLoGainSamples)  
+//  
+void MExtractFixedWindow::SetRange(Byte_t hifirst, Byte_t hilast, Byte_t lofirst, Byte_t lolast)
+{
+
+  const Byte_t windowhi = hilast-hifirst+1;
+  const Byte_t windowlo = lolast-lofirst+1;
+  
+  const Byte_t whieven = windowhi & ~1;
+  const Byte_t wloeven = windowlo & ~1;
+
+  if (whieven != windowhi)
+    {
+      *fLog << warn << GetDescriptor() 
+            << Form("%s%2i%s%2i",": Hi Gain window size has to be even, set last slice from "
+                    ,(int)hilast," to ",(int)(hilast-1)) << endl;
+      hilast -= 1;
+    }
+  
+  if (wloeven != windowlo)
+    {
+      *fLog << warn << GetDescriptor() 
+            << Form("%s%2i%s%2i",": Lo Gain window size has to be even, set last slice from "
+                    ,(int)lolast," to ",(int)(lolast-1)) << endl;
+      lolast -= 1;
+    }
+  
+  if (whieven<2) 
+    {
+      *fLog << warn << GetDescriptor() 
+            << Form("%s%2i%s%2i",": Hi Gain window is smaller than 2 FADC sampes, set last slice from" 
+                    ,(int)hilast," to ",(int)(hifirst+1)) << endl;
+      hilast = hifirst+1;
+    }
+  
+  if (wloeven<2) 
+    {
+      *fLog << warn << GetDescriptor() 
+            << Form("%s%2i%s%2i",": Lo Gain window is smaller than 2 FADC sampes, set last slice from" 
+                    ,(int)lolast," to ",(int)(lofirst+1)) << endl;
+      lolast = lofirst+1;        
+    }
+
+
+  MExtractor::SetRange(hifirst,hilast,lofirst,lolast);
+
+  fNumHiGainSamples = (Float_t)(fHiGainLast-fHiGainFirst+1);
+  fNumLoGainSamples = (Float_t)(fLoGainLast-fLoGainFirst+1);  
+
+  fSqrtHiGainSamples = TMath::Sqrt(fNumHiGainSamples);
+  fSqrtLoGainSamples = TMath::Sqrt(fNumLoGainSamples);  
+  
+}
+
+// --------------------------------------------------------------------------
+//
+// The ReInit calls:
+// -  MExtractor::ReInit()
+// -  fSignals->SetUsedFADCSlices(fHiGainFirst, fHiGainLast+fHiLoLast, fNumHiGainSamples,
+//                                fLoGainFirst, fLoGainLast, fNumLoGainSamples);
+//
+Bool_t MExtractFixedWindow::ReInit(MParList *pList)
+{
+
+  MExtractor::ReInit(pList);
+  
+  fSignals->SetUsedFADCSlices(fHiGainFirst, fHiGainLast+fHiLoLast, fNumHiGainSamples,
+                              fLoGainFirst, fLoGainLast, fNumLoGainSamples);
+
+
+  *fLog << endl;
+  *fLog << inf << GetDescriptor() << ": Taking " << fNumHiGainSamples
+        << " HiGain FADC samples from slice: " << (Int_t)fHiGainFirst 
+        << " to (including) slice: " << (Int_t)(fHiGainLast+fHiLoLast) << endl;
+  *fLog << inf << GetDescriptor() << ": Taking " << fNumLoGainSamples
+        << " LoGain FADC samples from slice: " << (Int_t)fLoGainFirst 
+        << " to (including) slice: " << (Int_t)fLoGainLast << endl;
+  return kTRUE;
+  
+}
+
+// --------------------------------------------------------------------------
+//
+// FindSignalHiGain:
+//
+// - Loop from ptr to (ptr+fHiGainLast-fHiGainFirst)
+// - Sum up contents of *ptr
+// - If *ptr is greater than fSaturationLimit, raise sat by 1
+// 
+// - If fHiLoLast is not 0, loop also from logain to (logain+fHiLoLast)
+// - Sum up contents of logain
+// - If *logain is greater than fSaturationLimit, raise sat by 1
+//
+void MExtractFixedWindow::FindSignalHiGain(Byte_t *ptr, Byte_t *logain, Float_t &sum, Byte_t &sat) const
+{
+
+  Int_t summ = 0;
+
+  Byte_t *end = ptr + fHiGainLast - fHiGainFirst + 1;
+
+  while (ptr<end)
+    {
+      summ += *ptr;
+      if (*ptr++ >= fSaturationLimit)
+        sat++;
+    }
+
+  Byte_t *p = logain;
+  end = logain + fHiLoLast;
+  while (p<end)
+    {
+      summ += *p;
+      if (*p++ >= fSaturationLimit)
+        sat++;
+    }
+
+  sum = (Float_t)summ;
+
+  return;
+}
+
+// --------------------------------------------------------------------------
+//
+// FindSignalLoGain:
+//
+// - Loop from ptr to (ptr+fLoGainLast-fLoGainFirst)
+// - Sum up contents of *ptr
+// - If *ptr is greater than fSaturationLimit, raise sat by 1
+// - If fHiLoLast is set, loop from logain to (logain+fHiLoLast)
+// - Add contents of *logain to sum
+// 
+void MExtractFixedWindow::FindSignalLoGain(Byte_t *ptr, Float_t &sum, Byte_t &sat) const
+{
+
+  Int_t summ = 0;
+
+  Byte_t *end = ptr + fLoGainLast - fLoGainFirst + 1;
+  
+  while (ptr<end)
+    {
+      summ += *ptr;
+      
+      if (*ptr++ >= fSaturationLimit)
+        sat++;
+    }
+
+  sum = (Float_t)summ;
+}
+
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
+void MExtractFixedWindow::StreamPrimitive(ofstream &out) const
+{
+
+  out << "   " << ClassName() << " " << GetUniqueName() << "(\"";
+  out << "\"" << fName << "\", \"" << fTitle << "\");" << endl;
+  
+  if (fSaturationLimit!=fgSaturationLimit)
+    {
+      out << "   " << GetUniqueName() << ".SetSaturationLimit(";
+      out << (int)fSaturationLimit << ");" << endl;
+    }
+  
+  const Bool_t arg4 = fNumLoGainSamples+fLoGainFirst-1 != fgLoGainLast;
+  const Bool_t arg3 = arg4 || fLoGainFirst != fgLoGainFirst;
+  const Bool_t arg2 = arg3 || fNumHiGainSamples+fHiGainFirst-1 != fgHiGainLast;
+  const Bool_t arg1 = arg2 || fHiGainFirst != fgHiGainFirst;
+  
+  if (!arg1)
+    return;
+  
+  out << "   " << GetUniqueName() << ".SetRange(";
+  out << (int)fLoGainFirst;
+  if (arg2)
+    {
+      out << ", " << (int)(fNumHiGainSamples+fHiGainFirst-1);
+      if (arg3)
+        {
+          out << ", " << (int)fLoGainFirst;
+          if (arg4)
+            out << ", " << (int)(fNumLoGainSamples+fLoGainFirst-1);
+        }
+    }
+  out << ");" << endl;
+}
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractFixedWindow.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractFixedWindow.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractFixedWindow.h	(revision 9661)
@@ -0,0 +1,39 @@
+#ifndef MARS_MExtractFixedWindow
+#define MARS_MExtractFixedWindow
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MExtractFixedWindow                                                          //
+//                                                                         //
+// Integrates the time slices of the all pixels in a fixed window          //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MExtractor
+#include "MExtractor.h"
+#endif
+
+class MExtractFixedWindow : public MExtractor
+{
+private:
+  static const Byte_t fgHiGainFirst;     // First FADC slice Hi-Gain (currently set to: 3) 
+  static const Byte_t fgHiGainLast;      // Last FADC slice Hi-Gain (currently set to: 14) 
+  static const Byte_t fgLoGainFirst;     // First FADC slice Lo-Gain (currently set to: 3) 
+  static const Byte_t fgLoGainLast;      // Last FADC slice Lo-Gain (currently set to: 14) 
+
+  void   FindSignalHiGain(Byte_t *ptr, Byte_t *logain, Float_t &sum, Byte_t &sat) const;
+  void   FindSignalLoGain(Byte_t *ptr, Float_t &sum, Byte_t &sat) const;
+  void   StreamPrimitive(ofstream &out) const;
+  
+  Bool_t ReInit(MParList *pList);
+
+public:
+
+  MExtractFixedWindow(const char *name=NULL, const char *title=NULL);
+
+  void SetRange(Byte_t hifirst=0, Byte_t hilast=0, Byte_t lofirst=0, Byte_t lolast=0);
+  
+  ClassDef(MExtractFixedWindow, 0) // Signal Extractor for a fixed extraction window
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractFixedWindowPeakSearch.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractFixedWindowPeakSearch.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractFixedWindowPeakSearch.cc	(revision 9661)
@@ -0,0 +1,466 @@
+/* ======================================================================== *\
+   !
+   ! *
+   ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+   ! * Software. It is distributed to you in the hope that it can be a useful
+   ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+   ! * It is distributed WITHOUT ANY WARRANTY.
+   ! *
+   ! * Permission to use, copy, modify and distribute this software and its
+   ! * documentation for any purpose is hereby granted without fee,
+   ! * provided that the above copyright notice appear in all copies and
+   ! * that both that copyright notice and this permission notice appear
+   ! * in supporting documentation. It is provided "as is" without express
+   ! * or implied warranty.
+   ! *
+   !
+   !
+   !   Author(s): Abelardo Moralejo,04/2004 <mailto:moralejo@pd.infn.it>
+   !              Markus Gaug      ,04/2004 <mailto:markus@ifae.es>
+   !   Copyright: MAGIC Software Development, 2000-2004
+   !
+   !
+   \* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//   MExtractFixedWindowPeakSearch
+//
+//  Calculate the signal integrating fWindowSize time slices, the same for 
+//  all pixels. The integrated slices change from event to event, since the
+//  pulse positions in the FADC jump between events, but apparently in a 
+//  "coherent" fashion. We first loop over all pixels and find the one 
+//  which has the highest sum of fPeakSearchWindowSize (default: 4) consecutive 
+//  non-saturated high gain slices. The position of the peak in this pixel 
+//  determines the integration window position for all pixels of this event. 
+//  For the moment we neglect time delays between pixels (which are in most 
+//  cases small). The class is based on MExtractSlidingWindow.
+//
+//  Call: SetRange(higainfirst, higainlast, logainfirst, logainlast) 
+//  to modify the ranges in which the window is allowed to move. 
+//  Defaults are: 
+// 
+//   fHiGainFirst =  fgHiGainFirst =  0 
+//   fHiGainLast  =  fgHiGainLast  =  14
+//   fLoGainFirst =  fgLoGainFirst =  3 
+//   fLoGainLast  =  fgLoGainLast  =  14
+//
+//  Call: SetWindows(windowhigain, windowlogain,peaksearchwindow) 
+//  to modify the sliding window widths. Windows have to be an even number. 
+//  In case of odd numbers, the window will be modified.
+//
+//  Defaults are:
+//
+//   fHiGainWindowSize     = fgHiGainWindowSize     = 6
+//   fLoGainWindowSize     = fgLoGainWindowSize     = 6
+//   fPeakSearchWindowSize = fgPeakSearchWindowSize = 4
+//   fLowGainPeakShift     = fgLowGainPeakShift     = 0
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MExtractFixedWindowPeakSearch.h"
+#include "MExtractor.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MRawEvtPixelIter.h"
+
+#include "MExtractedSignalCam.h"
+#include "MExtractedSignalPix.h"
+
+#include "MPedestalCam.h"
+#include "MPedestalPix.h"
+
+ClassImp(MExtractFixedWindowPeakSearch);
+
+using namespace std;
+
+const Byte_t MExtractFixedWindowPeakSearch::fgHiGainFirst          = 0;
+const Byte_t MExtractFixedWindowPeakSearch::fgHiGainLast           = 14;
+const Byte_t MExtractFixedWindowPeakSearch::fgLoGainFirst          = 3;
+const Byte_t MExtractFixedWindowPeakSearch::fgLoGainLast           = 14;
+const Byte_t MExtractFixedWindowPeakSearch::fgHiGainWindowSize     = 6;
+const Byte_t MExtractFixedWindowPeakSearch::fgLoGainWindowSize     = 6;
+const Byte_t MExtractFixedWindowPeakSearch::fgPeakSearchWindowSize = 4;
+const Byte_t MExtractFixedWindowPeakSearch::fgOffsetFromWindow     = 1;
+const Byte_t MExtractFixedWindowPeakSearch::fgLowGainPeakShift     = 0;
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+// Sets:
+// - fWindowSizeHiGain to fgWindowSizeHiGain
+// - fWindowSizeLoGain to fgWindowSizeLoGain
+// - fPeakSearchWindowSize to fgPeakSearchWindowSize
+// - fLowGainPeakShift to fgLowGainPeakShift
+//
+// Calls: 
+// - SetOffsetFromWindow()
+// - SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast)
+//
+MExtractFixedWindowPeakSearch::MExtractFixedWindowPeakSearch(const char *name, const char *title)
+    : fWindowSizeHiGain(fgHiGainWindowSize), 
+      fWindowSizeLoGain(fgLoGainWindowSize),
+      fPeakSearchWindowSize(fgPeakSearchWindowSize),
+      fLowGainPeakShift(fgLowGainPeakShift)
+{
+
+  fName  = name  ? name  : "MExtractFixedWindowPeakSearch";
+  fTitle = title ? title : "Task to extract the signal from the FADC slices";
+
+  SetOffsetFromWindow();
+  SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast);
+}
+
+// --------------------------------------------------------------------------
+//
+// SetRange: 
+//
+// Calls:
+// - MExtractor::SetRange(hifirst,hilast,lofirst,lolast);
+// - SetWindows(fWindowSizeHiGain,fWindowSizeLoGain,fPeakSearchWindowSize);
+//
+void MExtractFixedWindowPeakSearch::SetRange(Byte_t hifirst, Byte_t hilast, Byte_t lofirst, Byte_t lolast)
+{
+
+  MExtractor::SetRange(hifirst,hilast,lofirst,lolast);
+
+  //
+  // Redo the checks if the window is still inside the ranges
+  //
+  SetWindows(fWindowSizeHiGain,fWindowSizeLoGain,fPeakSearchWindowSize);
+  
+}
+
+// --------------------------------------------------------------------------
+//
+// Checks:
+// - if a window is odd, subtract one
+// - if a window is bigger than the one defined by the ranges, set it to the available range
+// - if a window is smaller than 2, set it to 2
+// 
+// Sets:
+// - fNumHiGainSamples to: (Float_t)fWindowSizeHiGain
+// - fNumLoGainSamples to: (Float_t)fWindowSizeLoGain
+// - fSqrtHiGainSamples to: TMath::Sqrt(fNumHiGainSamples)
+// - fSqrtLoGainSamples to: TMath::Sqrt(fNumLoGainSamples)  
+//  
+void MExtractFixedWindowPeakSearch::SetWindows(Byte_t windowh, Byte_t windowl, Byte_t peaksearchwindow)
+{
+
+  fWindowSizeHiGain     = windowh & ~1;
+  fWindowSizeLoGain     = windowl & ~1;
+  fPeakSearchWindowSize = peaksearchwindow & ~1;
+
+  if (fWindowSizeHiGain != windowh)
+    *fLog << warn << GetDescriptor() << ": Hi Gain window size has to be even, set to: " 
+          << int(fWindowSizeHiGain) << " samples " << endl;
+  
+  if (fWindowSizeLoGain != windowl)
+    *fLog << warn << GetDescriptor() << ": Lo Gain window size has to be even, set to: " 
+          << int(fWindowSizeLoGain) << " samples " << endl;
+    
+  if (fPeakSearchWindowSize != peaksearchwindow)
+    *fLog << warn << GetDescriptor() << ": Peak Search window size has to be even, set to: " 
+          << int(fPeakSearchWindowSize) << " samples " << endl;
+
+  const Byte_t availhirange = (fHiGainLast-fHiGainFirst+1) & ~1;
+  const Byte_t availlorange = (fLoGainLast-fLoGainFirst+1) & ~1;
+
+  if (fWindowSizeHiGain > availhirange)
+    {
+      *fLog << warn << GetDescriptor() 
+            << Form("%s%2i%s%2i%s%2i%s",": Hi Gain window size: ",(int)fWindowSizeHiGain,
+                    " is bigger than available range: [",(int)fHiGainFirst,",",(int)fHiGainLast,"]") << endl;
+      *fLog << warn << GetDescriptor() 
+            << ": Will set window size to: " << (int)availhirange << endl;
+      fWindowSizeHiGain = availhirange;
+    }
+  
+  
+  if (fWindowSizeLoGain > availlorange)
+    {
+      *fLog << warn << GetDescriptor() 
+            << Form("%s%2i%s%2i%s%2i%s",": Lo Gain window size: ",(int)fWindowSizeLoGain,
+                    " is bigger than available range: [",(int)fLoGainFirst,",",(int)fLoGainLast,"]") << endl;
+      *fLog << warn << GetDescriptor() 
+            << ": Will set window size to: " << (int)availlorange << endl;
+      fWindowSizeLoGain = availlorange;
+    }
+  
+  if (fWindowSizeHiGain<2) 
+    {
+      fWindowSizeHiGain = 2;
+      *fLog << warn << GetDescriptor() << ": Hi Gain window size set to two samples" << endl;
+    }
+  
+  if (fWindowSizeLoGain<2) 
+    {
+      fWindowSizeLoGain = 2;
+      *fLog << warn << GetDescriptor() << ": Lo Gain window size set to two samples" << endl;
+    }
+
+  if (fPeakSearchWindowSize<2) 
+    {
+      fPeakSearchWindowSize = 2;
+      *fLog << warn << GetDescriptor() 
+            << ": Peak Search window size set to two samples" << endl;
+    }
+
+  fNumHiGainSamples = (Float_t)fWindowSizeHiGain;
+  fNumLoGainSamples = (Float_t)fWindowSizeLoGain;
+
+  fSqrtHiGainSamples = TMath::Sqrt(fNumHiGainSamples);
+  fSqrtLoGainSamples = TMath::Sqrt(fNumLoGainSamples);
+}
+
+
+// --------------------------------------------------------------------------
+//
+// The ReInit calls:
+// -  MExtractor::ReInit()
+// -  fSignals->SetUsedFADCSlices(fHiGainFirst, fHiGainLast+fHiLoLast, fNumHiGainSamples,
+//                                fLoGainFirst, fLoGainLast, fNumLoGainSamples);
+//
+Bool_t MExtractFixedWindowPeakSearch::ReInit(MParList *pList)
+{
+
+  MExtractor::ReInit(pList);
+  
+  fSignals->SetUsedFADCSlices(fHiGainFirst, fHiGainLast+fHiLoLast, fNumHiGainSamples,
+                              fLoGainFirst, fLoGainLast, fNumLoGainSamples);
+
+  return kTRUE;
+  
+}
+
+// --------------------------------------------------------------------------
+//
+// FindPeak
+// Finds highest sum of "window" consecutive FADC slices in a pixel, and store
+// in "startslice" the first slice of the group which yields the maximum sum.
+// In "max" the value of the maximum sum is stored, in "sat" the number of 
+// saturated slices.
+//
+void MExtractFixedWindowPeakSearch::FindPeak(Byte_t *ptr, Byte_t window, Byte_t &startslice, Int_t &max, Int_t &sat) const
+{
+
+  const Byte_t *end = ptr + fHiGainLast - fHiGainFirst + 1;
+
+  sat = 0;
+  startslice = 0;
+  Int_t sum=0;
+
+  //
+  // Calculate the sum of the first "window" slices
+  //
+  sat = 0;
+  Byte_t *p = ptr;
+
+  while (p<ptr+window)
+    {
+      sum += *p;
+      if (*p++ >= fSaturationLimit)
+	sat++;
+    }
+
+  //
+  // Check for saturation in all other slices
+  //
+  while (p<end)
+    if (*p++ >= fSaturationLimit)
+      sat++;
+
+  //
+  // Calculate the i-th sum of n as
+  //    sum_i+1 = sum_i + slice[i+window] - slice[i]
+  // This is fast and accurate (because we are using int's)
+  //
+  max=sum;
+  for (p=ptr; p+window<end; p++)
+    {
+      sum += *(p+window) - *p;
+      if (sum > max)
+	{
+	  max = sum;
+	  startslice = p-ptr;
+	}
+    }
+
+  return;
+}
+
+// --------------------------------------------------------------------------
+//
+// FindSignalHiGain:
+//
+// - Loop from ptr to (ptr+fWindowSizeHiGain)
+// - Sum up contents of *ptr
+// - If *ptr is greater than fSaturationLimit, raise sat by 1
+// 
+void MExtractFixedWindowPeakSearch::FindSignalHiGain(Byte_t *ptr, Byte_t *logain, Float_t &sum, Byte_t &sat) const
+{
+
+  Byte_t *end = ptr + fWindowSizeHiGain-fHiLoLast;
+
+  Int_t summ = 0;
+  //
+  // Calculate the sum of the "window" slices starting in ptr
+  //
+  while (ptr<end)
+    {
+      summ += *ptr;
+      if (*ptr++ >= fSaturationLimit)
+	sat++;
+    }
+
+  //
+  // If part of the "low-Gain" slices are used, 
+  // repeat steps one and two for the logain part until fHiLoLast
+  //
+  Byte_t *p = logain;
+  end = logain + fHiLoLast;
+  while (p<end)
+    {
+  
+      summ += *p;
+      if (*p++ >= fSaturationLimit)
+        sat++;
+    }
+
+  sum = (Float_t)summ;
+  return;
+}
+
+// --------------------------------------------------------------------------
+//
+// FindSignalLoGain:
+//
+// - Loop from ptr to (ptr+fWindowSizeLoGain)
+// - Sum up contents of *ptr
+// - If *ptr is greater than fSaturationLimit, raise sat by 1
+// 
+void MExtractFixedWindowPeakSearch::FindSignalLoGain(Byte_t *ptr, Float_t &sum, Byte_t &sat) const
+{
+  //
+  // Calculate the sum of the "window" slices starting in ptr
+  //
+  Byte_t *p = ptr;
+  Int_t summ = 0;
+
+  while (p<ptr+fWindowSizeLoGain)
+    {
+      summ += *p;
+      if (*p++ >= fSaturationLimit)
+	sat++;
+    }
+
+  sum = (Float_t)summ;
+  return;
+}
+
+// --------------------------------------------------------------------------
+//
+// Process
+// First find the pixel with highest sum of fPeakSearchWindowSize slices (default:4)
+// "startslice" will mark the slice at which the highest sum begins for that pixel.
+// Then define the beginning of the integration window for ALL pixels as the slice
+// before that: startslice-fOffsetFromWindow, unless of course startslice-fOffsetFromWindow<=0,
+// in which case we start at 0. We will also check that the integration window does not 
+// go beyond the FADC limits.
+//
+Int_t MExtractFixedWindowPeakSearch::Process()
+{
+
+  MRawEvtPixelIter pixel(fRawEvt);
+
+  Int_t sat;
+  Int_t maxsumhi = -1000000;
+  Byte_t startslice;
+  Byte_t hiGainFirst = 0;
+  Byte_t loGainFirst = 0;
+  Byte_t hilolastsave = fHiLoLast;
+
+  while (pixel.Next())
+    {
+      Int_t sumhi;
+      sat = 0;
+
+      FindPeak(pixel.GetHiGainSamples()+fHiGainFirst, fPeakSearchWindowSize, startslice, sumhi, sat);
+
+      if (sumhi > maxsumhi && sat == 0 )
+	{
+	  maxsumhi = sumhi;
+	  if ((startslice-fOffsetFromWindow) > 0)
+            hiGainFirst = fHiGainFirst + startslice - fOffsetFromWindow;
+	  else
+	    hiGainFirst = fHiGainFirst;
+	}
+    }
+
+
+  loGainFirst = ( hiGainFirst+fLowGainPeakShift > fLoGainFirst ) ? 
+      hiGainFirst+fLowGainPeakShift : fLoGainFirst;
+
+  // Make sure we will not integrate beyond the hi gain limit:
+  if (hiGainFirst+fWindowSizeHiGain > pixel.GetNumHiGainSamples())
+    fHiLoLast = hiGainFirst+fWindowSizeHiGain - pixel.GetNumHiGainSamples();
+  //    hiGainFirst = pixel.GetNumHiGainSamples()-fWindowSizeHiGain;
+
+  // Make sure we will not integrate beyond the lo gain limit:
+  if (loGainFirst+fWindowSizeLoGain > pixel.GetNumLoGainSamples())
+    loGainFirst = pixel.GetNumLoGainSamples()-fWindowSizeLoGain;
+
+  pixel.Reset();
+  fSignals->Clear();
+
+  sat = 0;
+  while (pixel.Next())
+    {
+      //
+      // Find signal in hi- and lo-gain
+      //
+      Float_t sumhi=0.;
+      Byte_t sathi=0;
+
+      FindSignalHiGain(pixel.GetHiGainSamples()+hiGainFirst, pixel.GetLoGainSamples(), sumhi, sathi);
+
+      Float_t sumlo=0.;
+      Byte_t satlo=0;
+      if (pixel.HasLoGain())
+        {
+	  FindSignalLoGain(pixel.GetLoGainSamples()+loGainFirst, sumlo, satlo);
+	  if (satlo)
+	    sat++;
+        }
+
+      //
+      // Take corresponding pedestal
+      //
+      const Int_t pixid = pixel.GetPixelId();
+
+      const MPedestalPix  &ped = (*fPedestals)[pixid];
+      MExtractedSignalPix &pix = (*fSignals)[pixid];
+
+      const Float_t pedes  = ped.GetPedestal();
+      const Float_t pedrms = ped.GetPedestalRms();
+
+      //
+      // Set extracted signal with pedestal substracted
+      //
+      pix.SetExtractedSignal(sumhi - pedes*fNumHiGainSamples, pedrms*fSqrtHiGainSamples,
+                             sumlo - pedes*fNumLoGainSamples, pedrms*fSqrtLoGainSamples);
+
+      pix.SetGainSaturation(sathi, sathi, satlo);
+
+      //      pix.SetNumHiGainSlices(fNumHiGainSamples);
+      //      pix.SetNumLoGainSlices(fNumLoGainSamples);      
+      
+    } /* while (pixel.Next()) */
+
+
+  fHiLoLast = hilolastsave;
+  fSignals->SetReadyToSave();
+
+  return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractFixedWindowPeakSearch.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractFixedWindowPeakSearch.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractFixedWindowPeakSearch.h	(revision 9661)
@@ -0,0 +1,50 @@
+#ifndef MARS_MExtractFixedWindowPeakSearch
+#define MARS_MExtractFixedWindowPeakSearch
+
+#ifndef MARS_MExtractor
+#include "MExtractor.h"
+#endif
+
+class MExtractFixedWindowPeakSearch : public MExtractor
+{
+private:
+
+  static const Byte_t fgHiGainFirst;
+  static const Byte_t fgHiGainLast;
+  static const Byte_t fgLoGainFirst;
+  static const Byte_t fgLoGainLast;
+  static const Byte_t fgHiGainWindowSize;     // Default for fWindowSizeHiGain (now set to: 6)
+  static const Byte_t fgLoGainWindowSize;     // Default for fWindowSizeLoGain (now set to: 6)
+  static const Byte_t fgPeakSearchWindowSize; // Default for fPeakSearchWindowSize (now set to: 4)
+  static const Byte_t fgOffsetFromWindow;     // Default for fOffsetFromWindow (now set to: 1)
+  static const Byte_t fgLowGainPeakShift;     // Default for fLowGainPeakShift (now set to: 0)
+
+  Byte_t  fWindowSizeHiGain;     // Number of Hi Gain slices in window
+  Byte_t  fWindowSizeLoGain;     // Number of Lo Gain slices in window
+  Byte_t  fPeakSearchWindowSize; // Size of FADC window in the search for the highest peak of all pixels.
+  Byte_t  fOffsetFromWindow;     // Number of slices to start extraction before search window
+  Byte_t  fLowGainPeakShift;     // Shift of the low gain pulse with respect to the high gain pulse, in slices: it is 0 if the low gain is delayed with respect to HG by 15 slices.
+
+  void   FindSignalHiGain(Byte_t *ptr, Byte_t *logain, Float_t &sum, Byte_t &sat) const;
+  void   FindSignalLoGain(Byte_t *ptr, Float_t &sum, Byte_t &sat) const;  
+
+  void   FindPeak(Byte_t *ptr, Byte_t window, Byte_t &startslice, Int_t &signal, Int_t &sat) const;
+
+  Bool_t  ReInit(MParList *pList);
+  Int_t  Process();
+  
+public:
+
+    MExtractFixedWindowPeakSearch(const char *name=NULL, const char *title=NULL);
+
+    void SetRange(Byte_t hifirst=0, Byte_t hilast=0, Byte_t lofirst=0, Byte_t lolast=0);    
+    void SetWindows(Byte_t windowh=fgHiGainWindowSize, Byte_t windowl=fgLoGainWindowSize, 
+		    Byte_t peaksearchwindow=fgPeakSearchWindowSize);
+    void SetOffsetFromWindow(Byte_t offset=fgOffsetFromWindow)  {  fOffsetFromWindow = offset; }
+
+    void SetLowGainPeakShift(Byte_t shift=fgLowGainPeakShift) { fLowGainPeakShift = shift; }
+    
+    ClassDef(MExtractFixedWindowPeakSearch, 0) // Signal Extractor for fixed size trigger-corrected extraction window 
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractFixedWindowSpline.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractFixedWindowSpline.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractFixedWindowSpline.cc	(revision 9661)
@@ -0,0 +1,358 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analyzing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!   Author(s): Markus Gaug       05/2004 <mailto:markus@ifae.es> 
+!
+!   Copyright: MAGIC Software Development, 2002-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//   MExtractTimeAndChargeSpline
+//
+//   Fast Spline extractor using a cubic spline algorithm of Numerical Recipes. 
+//   It returns the integral below the interpolating spline. 
+// 
+//   Call: SetRange(fHiGainFirst, fHiGainLast, fLoGainFirst, fLoGainLast) 
+//         to modify the ranges. Ranges have to be an even number. In case of odd 
+//         ranges, the last slice will be reduced by one.
+//
+//  Defaults are: 
+// 
+//   fHiGainFirst =  fgHiGainFirst =  3 
+//   fHiGainLast  =  fgHiGainLast  =  14
+//   fLoGainFirst =  fgLoGainFirst =  3 
+//   fLoGainLast  =  fgLoGainLast  =  14
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MExtractFixedWindowSpline.h"
+
+#include "MExtractedSignalCam.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MExtractFixedWindowSpline);
+
+using namespace std;
+
+const Byte_t  MExtractFixedWindowSpline::fgHiGainFirst  = 2;
+const Byte_t  MExtractFixedWindowSpline::fgHiGainLast   = 14;
+const Byte_t  MExtractFixedWindowSpline::fgLoGainFirst  = 3;
+const Byte_t  MExtractFixedWindowSpline::fgLoGainLast   = 14;
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+// Calls: 
+// - SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast)
+// 
+MExtractFixedWindowSpline::MExtractFixedWindowSpline(const char *name, const char *title) 
+    : fHiGainFirstDeriv(NULL), fLoGainFirstDeriv(NULL),
+      fHiGainSecondDeriv(NULL), fLoGainSecondDeriv(NULL)
+{
+
+  fName  = name  ? name  : "MExtractFixedWindowSpline";
+  fTitle = title ? title : "Signal Extractor for a fixed FADC window using a fast spline";
+
+  SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast);
+}
+
+MExtractFixedWindowSpline::~MExtractFixedWindowSpline()
+{
+  
+  if (fHiGainFirstDeriv)
+    delete [] fHiGainFirstDeriv;
+  if (fLoGainFirstDeriv)
+    delete [] fLoGainFirstDeriv;
+  if (fHiGainSecondDeriv)
+    delete [] fHiGainSecondDeriv;
+  if (fLoGainSecondDeriv)
+    delete [] fLoGainSecondDeriv;
+  
+}
+
+// --------------------------------------------------------------------------
+//
+// SetRange: 
+//
+// Checks: 
+// - if the window defined by (fHiGainLast-fHiGainFirst-1) are odd, subtract one
+// - if the window defined by (fLoGainLast-fLoGainFirst-1) are odd, subtract one
+// - if the Hi Gain window is smaller than 2, set fHiGainLast to fHiGainFirst+1
+// - if the Lo Gain window is smaller than 2, set fLoGainLast to fLoGainFirst+1
+// 
+// Calls:
+// - MExtractor::SetRange(hifirst,hilast,lofirst,lolast);
+// 
+// Sets:
+// - fNumHiGainSamples to: (Float_t)(fHiGainLast-fHiGainFirst+1)
+// - fNumLoGainSamples to: (Float_t)(fLoGainLast-fLoGainFirst+1)
+// - fSqrtHiGainSamples to: TMath::Sqrt(fNumHiGainSamples)
+// - fSqrtLoGainSamples to: TMath::Sqrt(fNumLoGainSamples)  
+//  
+void MExtractFixedWindowSpline::SetRange(Byte_t hifirst, Byte_t hilast, Byte_t lofirst, Byte_t lolast)
+{
+
+  const Byte_t windowhi = hilast-hifirst+1;
+  const Byte_t windowlo = lolast-lofirst+1;
+  
+  const Byte_t whieven = windowhi & ~1;
+  const Byte_t wloeven = windowlo & ~1;
+
+  if (whieven != windowhi)
+    {
+      *fLog << warn << GetDescriptor() 
+            << Form("%s%2i%s%2i",": Hi Gain window size has to be even, set last slice from "
+                    ,(int)hilast," to ",(int)(hilast-1)) << endl;
+      hilast -= 1;
+    }
+  
+  if (wloeven != windowlo)
+    {
+      *fLog << warn << GetDescriptor() 
+            << Form("%s%2i%s%2i",": Lo Gain window size has to be even, set last slice from "
+                    ,(int)lolast," to ",(int)(lolast-1)) << endl;
+      lolast -= 1;
+    }
+  
+  if (whieven<2) 
+    {
+      *fLog << warn << GetDescriptor() 
+            << Form("%s%2i%s%2i",": Hi Gain window is smaller than 2 FADC sampes, set last slice from" 
+                    ,(int)hilast," to ",(int)(hifirst+1)) << endl;
+      hilast = hifirst+1;
+    }
+  
+  if (wloeven<2) 
+    {
+      *fLog << warn << GetDescriptor() 
+            << Form("%s%2i%s%2i",": Lo Gain window is smaller than 2 FADC sampes, set last slice from" 
+                    ,(int)lolast," to ",(int)(lofirst+1)) << endl;
+      lolast = lofirst+1;        
+    }
+
+
+  MExtractor::SetRange(hifirst,hilast,lofirst,lolast);
+
+  //
+  // Very important: Because the spline interpolates between the slice, 
+  //                 the number of samples for the pedestal subtraction 
+  //                 is now 1 less than with e.g. MExtractFixedWindow
+  //
+  fNumHiGainSamples = (Float_t)(fHiGainLast-fHiGainFirst);
+  fNumLoGainSamples = (Float_t)(fLoGainLast-fLoGainFirst);  
+
+  fSqrtHiGainSamples = TMath::Sqrt(fNumHiGainSamples);
+  fSqrtLoGainSamples = TMath::Sqrt(fNumLoGainSamples);  
+  
+}
+
+// --------------------------------------------------------------------------
+//
+// ReInit
+//
+// Calls:
+// - MExtractor::ReInit(pList);
+// - fSignals->SetUsedFADCSlices(fHiGainFirst, fHiGainLast+fHiLoLast, fNumHiGainSamples,
+//                                fLoGainFirst, fLoGainLast, fNumLoGainSamples);
+// 
+// Deletes all arrays, if not NULL
+// Creates new arrays according to the extraction range
+//
+Bool_t MExtractFixedWindowSpline::ReInit(MParList *pList)
+{
+
+  if (!MExtractor::ReInit(pList))
+    return kFALSE;
+
+  fSignals->SetUsedFADCSlices(fHiGainFirst, fHiGainLast+fHiLoLast, fNumHiGainSamples,
+                              fLoGainFirst, fLoGainLast, fNumLoGainSamples);
+
+  if (fHiGainFirstDeriv)
+    delete [] fHiGainFirstDeriv;
+  if (fLoGainFirstDeriv)
+    delete [] fLoGainFirstDeriv;
+  if (fHiGainSecondDeriv)
+    delete [] fHiGainSecondDeriv;
+  if (fLoGainSecondDeriv)
+    delete [] fLoGainSecondDeriv;
+  
+  Int_t range = fHiGainLast - fHiGainFirst + 1 + fHiLoLast;
+
+  fHiGainFirstDeriv  = new Float_t[range];
+  memset(fHiGainFirstDeriv,0,range*sizeof(Float_t));
+  fHiGainSecondDeriv = new Float_t[range];
+  memset(fHiGainSecondDeriv,0,range*sizeof(Float_t));
+
+  range = fLoGainLast - fLoGainFirst + 1;
+
+  fLoGainFirstDeriv  = new Float_t[range];
+  memset(fLoGainFirstDeriv,0,range*sizeof(Float_t));
+  fLoGainSecondDeriv = new Float_t[range];
+  memset(fLoGainSecondDeriv,0,range*sizeof(Float_t));
+
+  return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// FindSignalHiGain:
+//
+// - Loop from ptr to (ptr+fHiGainLast-fHiGainFirst)
+// - Sum up contents of *ptr
+// - If *ptr is greater than fSaturationLimit, raise sat by 1
+// 
+// - If fHiLoLast is not 0, loop also from logain to (logain+fHiLoLast)
+// - Sum up contents of logain
+// - If *logain is greater than fSaturationLimit, raise sat by 1
+//
+void MExtractFixedWindowSpline::FindSignalHiGain(Byte_t *ptr, Byte_t *logain, Float_t &sum, Byte_t &sat) const
+{
+  
+  const Byte_t *end = ptr + fHiGainLast - fHiGainFirst;
+  Int_t range = fHiGainLast - fHiGainFirst + fHiLoLast + 1;
+  
+  Float_t pp;
+  Int_t   i = 0;
+
+  Int_t summ = 0;
+  sum = (Float_t)*ptr++/2.;
+  //
+  // Check for saturation in all other slices
+  //
+  while (ptr<end)
+    {
+
+      summ += *ptr;
+      i++;
+
+      pp = fHiGainSecondDeriv[i-1] + 4.;
+      fHiGainSecondDeriv[i] = -1.0/pp;
+      fHiGainFirstDeriv [i] = *(ptr+1) - 2.* *(ptr) + *(ptr-1);
+      fHiGainFirstDeriv [i] = (6.0*fHiGainFirstDeriv[i]-fHiGainFirstDeriv[i-1])/pp;
+
+      if (*ptr++ >= fSaturationLimit)
+        sat++;
+    }
+  
+  if (*ptr++ >= fSaturationLimit)
+    sat++;
+
+  if (fHiLoLast == 0)
+    {
+      sum += (Float_t)*ptr/2.;
+      fHiGainSecondDeriv[++i] = 0.;      
+
+    }
+  else
+    {
+      summ += *ptr;
+      i++;
+
+      pp = fHiGainSecondDeriv[i-1] + 4.;
+      fHiGainSecondDeriv[i] = -1.0/pp;
+      fHiGainFirstDeriv [i] = *(logain) - 2.* *(ptr) + *(ptr-1);
+      fHiGainFirstDeriv [i] = (6.0*fHiGainFirstDeriv[i]-fHiGainFirstDeriv[i-1])/pp;
+
+      end    = logain + fHiLoLast - 1;
+
+      while (logain<end)
+        {
+
+          summ += *logain;
+          i++;
+          
+          pp = fHiGainSecondDeriv[i-1] + 4.;
+          fHiGainSecondDeriv[i] = -1.0/pp;
+          fHiGainFirstDeriv [i] = *(logain+1) - 2.* *(logain) + *(ptr-1);
+          fHiGainFirstDeriv [i] = (6.0*fHiGainFirstDeriv[i]-fHiGainFirstDeriv[i-1])/pp;
+
+          if (*logain++ >= fSaturationLimit)
+            sat++;
+          
+        }
+      sum += (Float_t)*logain/2;
+      fHiGainSecondDeriv[++i] = 0.;
+    }
+
+  for (Int_t k=range-2;k>0;k--)
+    {
+      fHiGainSecondDeriv[k] = fHiGainSecondDeriv[k]*fHiGainSecondDeriv[k+1] + fHiGainFirstDeriv[k];
+      sum += 0.25*fHiGainSecondDeriv[k];
+    }
+  
+  sum += (Float_t)summ;
+}
+
+// --------------------------------------------------------------------------
+//
+// FindSignalLoGain:
+//
+// - Loop from ptr to (ptr+fLoGainLast-fLoGainFirst)
+// - Sum up contents of *ptr
+// - If *ptr is greater than fSaturationLimit, raise sat by 1
+// 
+void MExtractFixedWindowSpline::FindSignalLoGain(Byte_t *ptr, Float_t &sum, Byte_t &sat) const
+{
+  
+  const Byte_t *end = ptr + fLoGainLast - fLoGainFirst;
+  Int_t range = fLoGainLast - fLoGainFirst + 1;
+  
+  Float_t pp;
+  Int_t   i = 0;
+
+  fLoGainSecondDeriv[0] = 0.;
+  fLoGainFirstDeriv[0]  = 0.;
+
+  Int_t summ = 0;
+  sum = (Float_t)*ptr++/2.;
+  //
+  // Check for saturation in all other slices
+  //
+  while (ptr<end)
+    {
+
+      summ += *ptr;
+      i++;
+
+      pp = fLoGainSecondDeriv[i-1] + 4.;
+      fLoGainSecondDeriv[i] = -1.0/pp;
+      fLoGainFirstDeriv [i] = *(ptr+1) - 2.* *(ptr) + *(ptr-1);
+      fLoGainFirstDeriv [i] = (6.0*fLoGainFirstDeriv[i]-fLoGainFirstDeriv[i-1])/pp;
+
+      if (*ptr++ >= fSaturationLimit)
+        sat++;
+    }
+  
+  if (*ptr++ >= fSaturationLimit)
+    sat++;
+
+  sum += (Float_t)*ptr/2.;
+  fLoGainSecondDeriv[++i] = 0.;      
+  
+  for (Int_t k=range-2;k>0;k--)
+    {
+      fLoGainSecondDeriv[k] = fLoGainSecondDeriv[k]*fLoGainSecondDeriv[k+1] + fLoGainFirstDeriv[k];
+      sum += 0.25*fLoGainSecondDeriv[k];
+    }
+  
+  sum += (Float_t)summ;
+}
+
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractFixedWindowSpline.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractFixedWindowSpline.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractFixedWindowSpline.h	(revision 9661)
@@ -0,0 +1,41 @@
+#ifndef MARS_MExtractFixedWindowSpline
+#define MARS_MExtractFixedWindowSpline
+
+#ifndef MARS_MExtractor
+#include "MExtractor.h"
+#endif
+
+class MExtractFixedWindowSpline : public MExtractor
+{
+
+private:
+  
+  static const Byte_t  fgHiGainFirst;    // Default for fHiGainFirst  (now set to: 2)
+  static const Byte_t  fgHiGainLast;     // Default for fHiGainLast   (now set to: 14)
+  static const Byte_t  fgLoGainFirst;    // Default for fLOGainFirst  (now set to: 3)
+  static const Byte_t  fgLoGainLast;     // Default for fLoGainLast   (now set to: 14)
+
+  Float_t *fHiGainFirstDeriv;
+  Float_t *fLoGainFirstDeriv;  
+  Float_t *fHiGainSecondDeriv;
+  Float_t *fLoGainSecondDeriv;  
+
+  Bool_t ReInit    (MParList *pList);
+  
+  void   FindSignalHiGain(Byte_t *ptr, Byte_t *logain, Float_t &sum, Byte_t &sat) const;
+  void   FindSignalLoGain(Byte_t *ptr, Float_t &sum, Byte_t &sat) const;
+
+public:
+
+  MExtractFixedWindowSpline(const char *name=NULL, const char *title=NULL);
+  ~MExtractFixedWindowSpline();
+  
+  void SetRange(Byte_t hifirst=0, Byte_t hilast=0, Byte_t lofirst=0, Byte_t lolast=0);
+  
+  ClassDef(MExtractFixedWindowSpline, 0)   // Task to Extract the Arrival Times using a Fast Spline
+};
+
+#endif
+
+
+
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractPINDiode.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractPINDiode.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractPINDiode.cc	(revision 9661)
@@ -0,0 +1,278 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug, 02/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//   MExtractPINDiode
+//
+//  Extracts the signal from a fixed window in a given range.
+//
+//  Call: SetRange(fHiGainFirst, fHiGainLast, fLoGainFirst, fLoGainLast) 
+//  to modify the ranges. Ranges have to be an even number. In case of odd 
+//  ranges, the last slice will be reduced by one.
+//  Defaults are: 
+// 
+//   fHiGainFirst =  fgHiGainFirst =  3 
+//   fHiGainLast  =  fgHiGainLast  =  14
+//   fLoGainFirst =  fgLoGainFirst =  3 
+//   fLoGainLast  =  fgLoGainLast  =  14
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MExtractPINDiode.h"
+
+#include <fstream>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MRawEvtData.h"
+#include "MRawEvtPixelIter.h"
+
+#include "MPedestalCam.h"
+#include "MPedestalPix.h"
+
+#include "MExtractedSignalPINDiode.h"
+
+ClassImp(MExtractPINDiode);
+
+using namespace std;
+
+const UInt_t MExtractPINDiode::fgPINDiodeIdx     = 100;
+const Byte_t MExtractPINDiode::fgHiGainFirst =  0;
+const Byte_t MExtractPINDiode::fgHiGainLast  =  14;
+const Byte_t MExtractPINDiode::fgLoGainFirst =  0;
+const Byte_t MExtractPINDiode::fgLoGainLast  =  14;
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+// Calls: 
+// - SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast)
+// - SetPINDiodeIdx()
+//
+MExtractPINDiode::MExtractPINDiode(const char *name, const char *title)
+{
+  
+  fName  = name  ? name  : "MExtractPINDiode";
+  fTitle = title ? title : "Task to extract the signal from the FADC slices";
+  
+  SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast);
+  SetPINDiodeIdx();
+}
+
+// --------------------------------------------------------------------------
+//
+// SetRange: 
+//
+// Checks: 
+// - if the window defined by (fHiGainLast-fHiGainFirst-1) are odd, subtract one
+// - if the window defined by (fLoGainLast-fLoGainFirst-1) are odd, subtract one
+// - if the Hi Gain window is smaller than 2, set fHiGainLast to fHiGainFirst+1
+// - if the Lo Gain window is smaller than 2, set fLoGainLast to fLoGainFirst+1
+// 
+// Calls:
+// - MExtractor::SetRange(hifirst,hilast,lofirst,lolast);
+// 
+// Sets:
+// - fNumHiGainSamples to: (Float_t)(fHiGainLast-fHiGainFirst+1)
+// - fNumLoGainSamples to: (Float_t)(fLoGainLast-fLoGainFirst+1)
+// - fSqrtHiGainSamples to: TMath::Sqrt(fNumHiGainSamples)
+// - fSqrtLoGainSamples to: TMath::Sqrt(fNumLoGainSamples)  
+//  
+void MExtractPINDiode::SetRange(Byte_t hifirst, Byte_t hilast, Byte_t lofirst, Byte_t lolast)
+{
+
+  const Byte_t window = hilast-hifirst+1+lolast-lofirst+1;
+  const Byte_t weven  = window & ~1;
+
+  if (weven != window)
+    {
+      *fLog << warn << GetDescriptor() 
+            << Form("%s%2i%s%2i",": Total window size has to be even, set last slice from "
+                    ,(int)lolast," to ",(int)(lolast-1)) << endl;
+      lolast -= 1;
+    }
+  
+  if (window<2) 
+    {
+      *fLog << warn << GetDescriptor() 
+            << Form("%s%2i%s%2i",": Total window is smaller than 2 FADC sampes, set last slice from" 
+                    ,(int)lolast," to ",(int)(lofirst+1)) << endl;
+      hilast = hifirst+1;
+    }
+  
+
+  MExtractor::SetRange(hifirst,hilast,lofirst,lolast);
+
+
+  fNumHiGainSamples = (Float_t)(fHiGainLast-fHiGainFirst+1);
+  fNumLoGainSamples = (Float_t)(fLoGainLast-fLoGainFirst+1);  
+
+  fSqrtHiGainSamples = TMath::Sqrt(fNumHiGainSamples);
+  fSqrtLoGainSamples = TMath::Sqrt(fNumLoGainSamples);  
+  
+  fNumSamples = fHiGainLast-fHiGainFirst+1+fLoGainLast-fLoGainFirst+1;
+  fSqrtSamples = TMath::Sqrt((Float_t)fNumSamples);
+  
+}
+
+// --------------------------------------------------------------------------
+//
+// Calls: 
+// - MExtractor::PreProcess
+//
+// The following output containers are also searched and created if
+// they were not found:
+//
+//  - MExtractedPINDiode
+//
+Int_t MExtractPINDiode::PreProcess(MParList *pList)
+{
+
+  if (!MExtractor::PreProcess(pList))
+    return kFALSE;
+  
+  fPINDiode = (MExtractedSignalPINDiode*)pList->FindCreateObj(AddSerialNumber("MExtractedSignalPINDiode"));
+  if (!fPINDiode)
+    return kFALSE;
+
+  const MPedestalPix &ped   = (*fPedestals)[fPINDiodeIdx]; 
+
+    if (&ped)
+      {
+        fPedestal = ped.GetPedestal();
+        fPedRms   = ped.GetPedestalRms();
+      }
+    else
+      {
+        *fLog << err << " Cannot find MPedestalPix of the PIN Diode (idx=" 
+              << fPINDiodeIdx << ")" << endl;
+        return kFALSE;
+      }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// The ReInit calls:
+// -  MExtractor::ReInit()
+// -  fPINDiode->SetUsedFADCSlices(fHiGainFirst, fLoGainLast);
+//
+Bool_t MExtractPINDiode::ReInit(MParList *pList)
+{
+
+  MExtractor::ReInit(pList);
+  
+  fPINDiode->SetUsedFADCSlices(fHiGainFirst, fLoGainLast);
+  
+  return kTRUE;
+  
+}
+
+
+
+void MExtractPINDiode::FindSignalandVarianceHiGain(Byte_t *ptr, Int_t &sum, Int_t &sum2, Byte_t &sat) const
+{
+
+  Byte_t *end = ptr + fHiGainLast - fHiGainFirst + 1;
+
+  while (ptr<end)
+    {
+      sum  += *ptr;
+      sum2 += *ptr * *ptr;
+
+      if (*ptr++ >= fSaturationLimit)
+        sat++;
+    }
+}
+
+void MExtractPINDiode::FindSignalandVarianceLoGain(Byte_t *ptr, Int_t &sum, Int_t &sum2, Byte_t &sat) const
+{
+
+  Byte_t *end = ptr +  fLoGainLast - fLoGainFirst  + 1;
+
+  while (ptr<end)
+    {
+      sum  += *ptr;
+      sum2 += *ptr * *ptr;
+      
+      if (*ptr++ >= fSaturationLimit)
+        sat++;
+    }
+}
+
+
+
+// --------------------------------------------------------------------------
+//
+// Calculate the integral of the FADC time slices and store them as a new
+// pixel in the MExtractedPINDiode container.
+//
+Int_t MExtractPINDiode::Process()
+{
+
+
+  MRawEvtPixelIter pixel(fRawEvt);
+  
+  fPINDiode->Clear();
+  
+  pixel.Jump(fPINDiodeIdx);
+  
+  Int_t sum   = 0;
+  Int_t sum2  = 0;
+  Byte_t sat  = 0;
+  Int_t max   = 0;
+  
+  // 
+  // Calculate first the time:
+  //
+  const Int_t maxhi = pixel.GetIdxMaxHiGainSample();
+  const Int_t maxlo = pixel.GetIdxMaxLoGainSample();
+  
+  if (maxhi > maxlo)
+    max = maxhi;
+  else
+    max = maxlo + pixel.GetNumHiGainSamples();
+  
+  FindSignalandVarianceHiGain(pixel.GetHiGainSamples()+fHiGainFirst,sum,sum2,sat);
+  FindSignalandVarianceLoGain(pixel.GetLoGainSamples()+fLoGainFirst,sum,sum2,sat);
+
+  const Float_t var = ((Float_t)sum2 - (Float_t)sum*sum/fNumSamples)/(fNumSamples-1);
+  const Float_t rms = TMath::Sqrt(var);
+  
+  // 
+  // FIXME: The following formulae have to be revised!!
+  //
+  fPINDiode->SetExtractedSignal(sum - fPedestal*fNumSamples, fPedRms*fSqrtSamples);
+  fPINDiode->SetExtractedRms   (rms, rms/2./fSqrtSamples);
+  fPINDiode->SetExtractedTime  (max, rms/fSqrtSamples);
+  fPINDiode->SetSaturation(sat);
+  fPINDiode->SetReadyToSave();
+  
+  return kTRUE;
+}
+
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractPINDiode.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractPINDiode.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractPINDiode.h	(revision 9661)
@@ -0,0 +1,54 @@
+#ifndef MARS_MExtractPINDiode
+#define MARS_MExtractPINDiode
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MExtractPINDiode                                                        //
+//                                                                         //
+// Integrates the time slices of the all pixels of a calibration event     //
+// and substract the pedestal value                                        //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MExtractor
+#include "MExtractor.h"
+#endif
+
+class MExtractedSignalPINDiode;
+class MExtractPINDiode : public MExtractor
+{
+private:
+
+  static const UInt_t fgPINDiodeIdx;  
+  static const Byte_t fgHiGainFirst;     // First FADC slice Hi-Gain (currently set to: 3) 
+  static const Byte_t fgHiGainLast;      // Last FADC slice Hi-Gain (currently set to: 14) 
+  static const Byte_t fgLoGainFirst;     // First FADC slice Lo-Gain (currently set to: 3) 
+  static const Byte_t fgLoGainLast;      // Last FADC slice Lo-Gain (currently set to: 14) 
+
+  MExtractedSignalPINDiode  *fPINDiode;     // Extracted signal of the PIN Diode
+
+  UInt_t  fPINDiodeIdx;
+  Float_t fPedestal;
+  Float_t fPedRms;
+  Int_t   fNumSamples;
+  Float_t fSqrtSamples;
+  
+  void   FindSignalandVarianceHiGain(Byte_t *ptr, Int_t &sum, Int_t &sum2, Byte_t &sat) const;
+  void   FindSignalandVarianceLoGain(Byte_t *ptr, Int_t &sum, Int_t &sum2, Byte_t &sat) const;
+
+  Int_t  PreProcess(MParList *pList);
+  Bool_t ReInit(MParList *pList);  
+  Int_t  Process();
+  
+public:
+
+  MExtractPINDiode(const char *name=NULL, const char *title=NULL);
+
+  // Setters
+  void SetRange(Byte_t hifirst=0, Byte_t hilast=0, Byte_t lofirst=0, Byte_t lolast=0);
+  void SetPINDiodeIdx(    const UInt_t idx=fgPINDiodeIdx    ) { fPINDiodeIdx     = idx; }   
+
+  ClassDef(MExtractPINDiode, 0) // Signal Extractor for the PIN Diode
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractSignal.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractSignal.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractSignal.cc	(revision 9661)
@@ -0,0 +1,228 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug, 09/2003 <mailto:markus@ifae.es>
+!              Thomas Bretz, 01/2004 
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//   MExtractSignal
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MExtractSignal.h"
+
+#include <fstream>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MRawEvtData.h"
+#include "MRawEvtPixelIter.h"
+
+#include "MPedestalCam.h"
+#include "MPedestalPix.h"
+
+#include "MExtractedSignalCam.h"
+#include "MExtractedSignalPix.h"
+
+ClassImp(MExtractSignal);
+
+using namespace std;
+
+const Byte_t MExtractSignal::fgSaturationLimit = 254;
+const Byte_t MExtractSignal::fgFirst =  3;
+const Byte_t MExtractSignal::fgLast  = 14;
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+MExtractSignal::MExtractSignal(const char *name, const char *title)
+    : fSaturationLimit(fgSaturationLimit)
+{
+
+    fName  = name  ? name  : "MExtractSignal";
+    fTitle = title ? title : "Task to extract the signal from the FADC slices";
+
+    AddToBranchList("MRawEvtData.*");
+
+    SetRange();
+}
+
+void MExtractSignal::SetRange(Byte_t hifirst, Byte_t hilast, Byte_t lofirst, Byte_t lolast)
+{
+
+    fNumHiGainSamples = hilast-hifirst+1;
+    fNumLoGainSamples = lolast-lofirst+1;
+
+    fHiGainFirst = hifirst;
+    fLoGainFirst = lofirst;
+
+    fSqrtHiGainSamples = TMath::Sqrt((Float_t)fNumHiGainSamples);
+    fSqrtLoGainSamples = TMath::Sqrt((Float_t)fNumLoGainSamples);
+}
+
+// --------------------------------------------------------------------------
+//
+// The PreProcess searches for the following input containers:
+//  - MRawEvtData
+//  - MPedestalCam
+//
+// The following output containers are also searched and created if
+// they were not found:
+//
+//  - MExtractedSignalCam
+//
+Int_t MExtractSignal::PreProcess(MParList *pList)
+{
+    fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData"));
+    if (!fRawEvt)
+    {
+        *fLog << err << AddSerialNumber("MRawEvtData") << " not found... aborting." << endl;
+        return kFALSE;
+    }
+
+
+    fSignals = (MExtractedSignalCam*)pList->FindCreateObj(AddSerialNumber("MExtractedSignalCam"));
+    if (!fSignals)
+        return kFALSE;
+
+    fSignals->SetUsedFADCSlices(fHiGainFirst, fHiGainFirst+fNumHiGainSamples-1, (Float_t)fNumHiGainSamples,
+                                fLoGainFirst, fLoGainFirst+fNumLoGainSamples-1, (Float_t)fNumLoGainSamples);
+
+    fPedestals = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
+
+    if (!fPedestals)
+    {
+        *fLog << err << AddSerialNumber("MPedestalCam") << " not found... aborting" << endl;
+        return kFALSE;
+    }
+
+    return kTRUE;
+}
+
+void MExtractSignal::FindSignal(Byte_t *ptr, Int_t size, Int_t &sum, Byte_t &sat) const
+{
+
+  Byte_t *end = ptr + size;
+  
+  sum = 0;
+  sat = 0;
+  
+  while (ptr<end)
+    {
+      sum += *ptr;
+      
+      if (*ptr++ >= fSaturationLimit)
+        sat++;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculate the integral of the FADC time slices and store them as a new
+// pixel in the MExtractedSignalCam container.
+//
+Int_t MExtractSignal::Process()
+{
+    MRawEvtPixelIter pixel(fRawEvt);
+    fSignals->Clear();
+
+    UInt_t  sat=0;
+
+    while (pixel.Next())
+    {
+        Int_t sumhi;
+        Byte_t sathi;
+
+        FindSignal(pixel.GetHiGainSamples()+fHiGainFirst, fNumHiGainSamples, sumhi, sathi);
+
+        Int_t  sumlo = 0;
+        Byte_t satlo = 0;
+        if (pixel.HasLoGain())
+        {
+            FindSignal(pixel.GetLoGainSamples()+fLoGainFirst, fNumLoGainSamples, sumlo, satlo);
+
+            if (satlo)
+              sat++;
+        }
+
+        const Int_t pixid = pixel.GetPixelId();
+
+        const MPedestalPix  &ped = (*fPedestals)[pixid]; 
+	MExtractedSignalPix &pix = (*fSignals)[pixid];
+
+        const Float_t pedes  = ped.GetPedestal();
+        const Float_t pedrms = ped.GetPedestalRms();
+
+        pix.SetExtractedSignal(sumhi - pedes*fNumHiGainSamples, pedrms*fSqrtHiGainSamples,
+                               sumlo - pedes*fNumLoGainSamples, pedrms*fSqrtLoGainSamples);
+
+	pix.SetGainSaturation(sathi, sathi, satlo);
+
+    } /* while (pixel.Next()) */
+
+    fSignals->SetReadyToSave();
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
+void MExtractSignal::StreamPrimitive(ofstream &out) const
+{
+    out << "   " << ClassName() << " " << GetUniqueName() << "(\"";
+    out << "\"" << fName << "\", \"" << fTitle << "\");" << endl;
+
+    if (fSaturationLimit!=fgSaturationLimit)
+    {
+        out << "   " << GetUniqueName() << ".SetSaturationLimit(";
+        out << (int)fSaturationLimit << ");" << endl;
+    }
+
+    const Bool_t arg4 = fNumLoGainSamples+fLoGainFirst-1 != fgLast;
+    const Bool_t arg3 = arg4 || fLoGainFirst != fgFirst;
+    const Bool_t arg2 = arg3 || fNumHiGainSamples+fHiGainFirst-1 != fgLast;
+    const Bool_t arg1 = arg2 || fHiGainFirst != fgFirst;
+
+    if (!arg1)
+        return;
+
+    out << "   " << GetUniqueName() << ".SetRange(";
+    out << (int)fLoGainFirst;
+    if (arg2)
+    {
+        out << ", " << (int)(fNumHiGainSamples+fHiGainFirst-1);
+        if (arg3)
+        {
+            out << ", " << (int)fLoGainFirst;
+            if (arg4)
+                out << ", " << (int)(fNumLoGainSamples+fLoGainFirst-1);
+        }
+    }
+    out << ");" << endl;
+}
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractSignal.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractSignal.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractSignal.h	(revision 9661)
@@ -0,0 +1,62 @@
+#ifndef MARS_MExtractSignal
+#define MARS_MExtractSignal
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MExtractSignal                                                          //
+//                                                                         //
+// Integrates the time slices of the all pixels of a calibration event     //
+// and substract the pedestal value                                        //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MRawEvtData;
+class MRawRunHeader;
+
+class MPedestalCam;
+class MExtractedSignalCam;
+
+class MExtractSignal : public MTask
+{
+private:
+    static const Byte_t fgSaturationLimit;
+    static const Byte_t fgFirst;
+    static const Byte_t fgLast;
+
+    MPedestalCam        *fPedestals;    // Pedestals of all pixels in the camera
+    MExtractedSignalCam *fSignals;      // Extracted signal of all pixels in the camera
+
+    MRawEvtData         *fRawEvt;       // raw event data (time slices)
+    MRawRunHeader       *fRunHeader;    // RunHeader information
+
+    Byte_t  fHiGainFirst;
+    Byte_t  fLoGainFirst;
+
+    Byte_t  fNumHiGainSamples;
+    Byte_t  fNumLoGainSamples;
+
+    Float_t fSqrtHiGainSamples;
+    Float_t fSqrtLoGainSamples;
+
+    Byte_t  fSaturationLimit;
+
+    void   FindSignal(Byte_t *ptr, Int_t size, Int_t &sum, Byte_t &sat) const;
+
+    Int_t  PreProcess(MParList *pList);
+    Int_t  Process();
+    void   StreamPrimitive(ofstream &out) const;
+
+public:
+    MExtractSignal(const char *name=NULL, const char *title=NULL);
+
+    void SetRange(Byte_t hifirst=fgFirst, Byte_t hilast=fgLast, Byte_t lofirst=fgFirst, Byte_t lolast=fgLast);
+    void SetSaturationLimit(Byte_t lim) { fSaturationLimit = lim; }
+
+    ClassDef(MExtractSignal, 0) // Task to fill the Extracted Signal Containers from raw data
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractSignal2.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractSignal2.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractSignal2.cc	(revision 9661)
@@ -0,0 +1,259 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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, 02/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!              Hendrik Bartko, 01/2004 <mailto:hbartko@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//   MExtractSignal2
+//
+//  Calculate the signal as the fWindowSize time slices which have the highest
+// integral contents.
+//
+// 
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MExtractSignal2.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MRawEvtData.h"
+#include "MRawEvtPixelIter.h"
+
+#include "MPedestalCam.h"
+#include "MPedestalPix.h"
+
+#include "MExtractedSignalCam.h"
+#include "MExtractedSignalPix.h"
+
+//#include "MArrivalTime.h"
+
+ClassImp(MExtractSignal2);
+
+using namespace std;
+
+const Byte_t MExtractSignal2::fgSaturationLimit = 254;
+const Byte_t MExtractSignal2::fgFirst      =  3;
+const Byte_t MExtractSignal2::fgLast       = 14;
+const Byte_t MExtractSignal2::fgWindowSize = 6;
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+MExtractSignal2::MExtractSignal2(const char *name, const char *title)
+  : fSaturationLimit(fgSaturationLimit)
+{
+
+    fName  = name  ? name  : "MExtractSignal2";
+    fTitle = title ? title : "Task to extract the signal from the FADC slices";
+
+    AddToBranchList("MRawEvtData.*");
+
+    SetRange();
+}
+
+void MExtractSignal2::SetRange(Byte_t hifirst, Byte_t hilast, Byte_t windowh, Byte_t lofirst, Byte_t lolast, Byte_t windowl)
+{
+
+    fNumHiGainSamples = hilast-hifirst+1;
+    fNumLoGainSamples = lolast-lofirst+1;
+
+    fHiGainFirst = hifirst;
+    fLoGainFirst = lofirst;
+
+    fWindowSizeHiGain = windowh & ~1;
+    fWindowSizeLoGain = windowl & ~1;
+
+    if (fWindowSizeHiGain != windowh)
+      *fLog << warn << "MExtractSignal2::SetRange - Hi Gain window size has to be even, set to: " 
+            << int(fWindowSizeHiGain) << " samples " << endl;
+    
+    if (fWindowSizeLoGain != windowl)
+      *fLog << warn << "MExtractSignal2::SetRange - Lo Gain window size has to be even, set to: " 
+            << int(fWindowSizeLoGain) << " samples " << endl;
+    
+    if (fWindowSizeHiGain<2) 
+    {
+      fWindowSizeHiGain = 2;
+      *fLog << warn << "MExtractSignal2::SetRange - Hi Gain window size set to two samples" << endl;
+    }
+
+    if (fWindowSizeLoGain<2) 
+    {
+      fWindowSizeLoGain = 2;
+      *fLog << warn << "MExtractSignal2::SetRange - Lo Gain window size set to two samples" << endl;
+    }
+
+    if (fWindowSizeHiGain > fNumHiGainSamples)
+    {
+      fWindowSizeHiGain = fNumHiGainSamples & ~1;
+      *fLog << warn << "MExtractSignal2::SetRange - Hi Gain window size set to " 
+            << int(fWindowSizeHiGain) << " samples " << endl;
+    }
+    
+    if (fWindowSizeLoGain > fNumLoGainSamples)
+    {
+      fWindowSizeLoGain = fNumLoGainSamples & ~1;
+      *fLog << warn << "MExtractSignal2::SetRange - Lo Gain window size set to " 
+            << int(fWindowSizeLoGain) << " samples " << endl;
+    }
+
+    fWindowSqrtHiGain = TMath::Sqrt((Float_t)fWindowSizeHiGain);
+    fWindowSqrtLoGain = TMath::Sqrt((Float_t)fWindowSizeLoGain);
+
+}
+
+
+
+// --------------------------------------------------------------------------
+//
+// The PreProcess searches for the following input containers:
+//  - MRawEvtData
+//  - MPedestalCam
+//
+// The following output containers are also searched and created if
+// they were not found:
+//
+//  - MExtractedSignalCam
+//
+Int_t MExtractSignal2::PreProcess(MParList *pList)
+{
+    fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData"));
+    if (!fRawEvt)
+    {
+        *fLog << err << AddSerialNumber("MRawEvtData") << " not found... aborting." << endl;
+        return kFALSE;
+    }
+
+
+    fSignals = (MExtractedSignalCam*)pList->FindCreateObj(AddSerialNumber("MExtractedSignalCam"));
+    if (!fSignals)
+        return kFALSE;
+
+    fSignals->SetUsedFADCSlices(fHiGainFirst, fHiGainFirst+fNumHiGainSamples-1, (Float_t)fWindowSizeHiGain,
+                                fLoGainFirst, fLoGainFirst+fNumLoGainSamples-1, (Float_t)fWindowSizeLoGain);
+
+    fPedestals = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
+    if (!fPedestals)
+    {
+        *fLog << err << AddSerialNumber("MPedestalCam") << " not found... aborting" << endl;
+        return kFALSE;
+    }
+    return kTRUE;
+}
+
+void MExtractSignal2::FindSignal(Byte_t *ptr, Byte_t size, Byte_t window, Int_t &max, Int_t &sat) const
+{
+    const Byte_t *end = ptr + size;
+
+    Int_t sum=0;
+
+    //
+    // Calculate the sum of the first fWindowSize slices
+    //
+    sat = 0;
+    Byte_t *p = ptr;
+    while (p<ptr+window)
+    {
+        sum += *p;
+        if (*p++ >= fSaturationLimit)
+            sat++;
+    }
+
+    //
+    // Check for saturation in all other slices
+    //
+    while (p<end)
+        if (*p++ >= fSaturationLimit)
+            sat++;
+
+    //
+    // Calculate the i-th sum as
+    //    sum_i+1 = sum_i + slice[i+8] - slice[i]
+    // This is fast and accurate (because we are using int's)
+    //
+    max=sum;
+    for (p=ptr; p+window<end; p++)
+    {
+        sum += *(p+window) - *p;
+        if (sum>max)
+            max = sum;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculate the integral of the FADC of fWindowSize time slices which have the
+// highest signal
+//
+Int_t MExtractSignal2::Process()
+{
+    MRawEvtPixelIter pixel(fRawEvt);
+    fSignals->Clear();
+
+    Int_t sat=0;
+    while (pixel.Next())
+    {
+        //
+        // Find signal in hi- and lo-gain
+        //
+        Int_t sumhi, sathi;
+        FindSignal(pixel.GetHiGainSamples()+fHiGainFirst, fNumHiGainSamples, fWindowSizeHiGain, sumhi, sathi);
+
+        Int_t sumlo=0;
+        Int_t satlo=0;
+        if (pixel.HasLoGain())
+        {
+            FindSignal(pixel.GetLoGainSamples()+fLoGainFirst, fNumLoGainSamples, fWindowSizeLoGain, sumlo, satlo);
+            if (satlo)
+                sat++;
+        }
+
+        //
+        // Take correspodning pedestal
+        //
+        const Int_t pixid = pixel.GetPixelId();
+
+        const MPedestalPix  &ped = (*fPedestals)[pixid];
+        MExtractedSignalPix &pix = (*fSignals)[pixid];
+
+        const Float_t pedes  = ped.GetPedestal();
+        const Float_t pedrms = ped.GetPedestalRms();
+
+        //
+        // Set extracted signal with pedestal substracted
+        //
+        pix.SetExtractedSignal(sumhi - pedes*fWindowSizeHiGain, pedrms*fWindowSqrtHiGain,
+                               sumlo - pedes*fWindowSizeLoGain, pedrms*fWindowSqrtLoGain);
+
+        pix.SetGainSaturation(sathi, sathi, satlo);
+    } /* while (pixel.Next()) */
+
+
+    fSignals->SetReadyToSave();
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractSignal2.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractSignal2.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractSignal2.h	(revision 9661)
@@ -0,0 +1,62 @@
+#ifndef MARS_MExtractSignal2
+#define MARS_MExtractSignal2
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MRawEvtData;
+class MRawRunHeader;
+
+class MPedestalCam;
+class MExtractedSignalCam;
+//class MArrivalTime;
+
+class MExtractSignal2 : public MTask
+{
+private:
+    static const Byte_t fgSaturationLimit;
+    static const Byte_t fgFirst;
+    static const Byte_t fgLast;
+    static const Byte_t fgWindowSize;
+
+    MPedestalCam        *fPedestals;    // Pedestals of all pixels in the camera
+    MExtractedSignalCam *fSignals;      // Extracted signal of all pixels in the camera
+
+    MRawEvtData         *fRawEvt;       // raw event data (time slices)
+    MRawRunHeader       *fRunHeader;    // RunHeader information
+
+    /*
+     MArrivalTime        *fArrivalTime;  // Arrival Time of FADC sample
+     */
+  
+    Byte_t  fHiGainFirst;       // First hi gain to be used
+    Byte_t  fLoGainFirst;       // First lo gain to be used
+
+    Byte_t  fNumHiGainSamples;  // Number of hi gain to be used
+    Byte_t  fNumLoGainSamples;  // Number of lo gain to be used
+
+    Byte_t  fWindowSizeHiGain;  // Number of Hi Gain slices in window
+    Float_t fWindowSqrtHiGain;  // Sqaure root of number of Hi Gain slices in window
+
+    Byte_t  fWindowSizeLoGain;  // Number of Lo Gain slices in window
+    Float_t fWindowSqrtLoGain;  // Sqaure root of number of Lo Gain slices in window
+
+    Byte_t  fSaturationLimit;
+
+    void   FindSignal(Byte_t *ptr, Byte_t size, Byte_t window, Int_t &max, Int_t &sat) const;
+
+    Int_t  PreProcess(MParList *pList);
+    Int_t  Process();
+
+public:
+    MExtractSignal2(const char *name=NULL, const char *title=NULL);
+
+    void SetRange(Byte_t hifirst=fgFirst, Byte_t hilast=fgLast, Byte_t windowh=fgWindowSize,
+                  Byte_t lofirst=fgFirst, Byte_t lolast=fgLast, Byte_t windowl=fgWindowSize);
+    void SetSaturationLimit(Byte_t lim) { fSaturationLimit = lim; }
+
+    ClassDef(MExtractSignal2, 0) // Extracted Signal as highest integral content
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractSignal3.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractSignal3.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractSignal3.cc	(revision 9661)
@@ -0,0 +1,365 @@
+/* ======================================================================== *\
+   !
+   ! *
+   ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+   ! * Software. It is distributed to you in the hope that it can be a useful
+   ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+   ! * It is distributed WITHOUT ANY WARRANTY.
+   ! *
+   ! * Permission to use, copy, modify and distribute this software and its
+   ! * documentation for any purpose is hereby granted without fee,
+   ! * provided that the above copyright notice appear in all copies and
+   ! * that both that copyright notice and this permission notice appear
+   ! * in supporting documentation. It is provided "as is" without express
+   ! * or implied warranty.
+   ! *
+   !
+   !
+   !   Author(s): Abelardo Moralejo, 4/2004 <mailto:moralejo@pd.infn.it>
+   !
+   !   Copyright: MAGIC Software Development, 2000-2004
+   !
+   !
+   \* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//   MExtractSignal3
+//
+//  Calculate the signal integrating fWindowSize time slices, the same for 
+//  all pixels. The integrated slices change from event to event, since the
+//  pulse positions in the FADC jump between events, but apparently in a 
+//  "coherent" fashion. We first loop over all pixels and find the one 
+//  which has the highest sum of fPeakSearchWindowSize (default: 4) consecutive 
+//  non-saturated high gain slices. The position of the peak in this pixel 
+//  determines the integration window position for all pixels of this event. 
+//  For the moment we neglect time delays between pixels (which are in most 
+//  cases small). The class is based on MExtractSignal2.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MExtractSignal3.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MRawEvtData.h"
+#include "MRawEvtPixelIter.h"
+
+#include "MPedestalCam.h"
+#include "MPedestalPix.h"
+
+#include "MExtractedSignalCam.h"
+#include "MExtractedSignalPix.h"
+
+ClassImp(MExtractSignal3);
+
+using namespace std;
+
+const Byte_t MExtractSignal3::fgSaturationLimit = 254;
+const Byte_t MExtractSignal3::fgFirst  =  0;
+const Byte_t MExtractSignal3::fgLast   = 14;
+const Byte_t MExtractSignal3::fgWindowSize = 6;
+const Byte_t MExtractSignal3::fgPeakSearchWindowSize = 4;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+MExtractSignal3::MExtractSignal3(const char *name, const char *title)
+  : fNumHiGainSamples(15), fNumLoGainSamples(15), fSaturationLimit(fgSaturationLimit)
+{
+
+  fName  = name  ? name  : "MExtractSignal3";
+  fTitle = title ? title : "Task to extract the signal from the FADC slices";
+
+  AddToBranchList("MRawEvtData.*");
+
+  SetWindows();
+}
+
+void MExtractSignal3::SetWindows(Byte_t windowh, Byte_t windowl, Byte_t peaksearchwindow)
+{
+  //
+  // Set windows to even number of slices due to clock noise (odd/even slice effect).
+  //
+  fWindowSizeHiGain = windowh & ~1;
+  fWindowSizeLoGain = windowl & ~1;
+  fPeakSearchWindowSize = peaksearchwindow & ~1;
+
+
+  if (fWindowSizeHiGain != windowh)
+    *fLog << endl << warn << 
+      "MExtractSignal3::SetWindows - Hi Gain window size has to be even, set to: " 
+	  << int(fWindowSizeHiGain) << " samples " << endl;
+    
+  if (fWindowSizeLoGain != windowl)
+    *fLog << endl << warn << 
+      "MExtractSignal3::SetWindows - Lo Gain window size has to be even, set to: " 
+	  << int(fWindowSizeLoGain) << " samples " << endl;
+
+  if (fPeakSearchWindowSize != peaksearchwindow)
+    *fLog << endl << warn << 
+      "MExtractSignal3::SetWindows - Peak Search window size has to be even, set to: " 
+	  << int(fPeakSearchWindowSize) << " samples " << endl;
+
+
+  if (fWindowSizeHiGain<2) 
+    {
+      fWindowSizeHiGain = 2;
+      *fLog << warn << "MExtractSignal3::SetWindows - Hi Gain window size set to two samples" << endl;
+    }
+
+  if (fWindowSizeLoGain<2) 
+    {
+      fWindowSizeLoGain = 2;
+      *fLog << warn << "MExtractSignal3::SetWindows - Lo Gain window size set to two samples" << endl;
+    }
+
+  if (fPeakSearchWindowSize<2) 
+    {
+      fPeakSearchWindowSize = 2;
+      *fLog << warn << "MExtractSignal3::SetWindows - Peak Search window size set to two samples" << endl;
+    }
+
+
+  if (fWindowSizeHiGain > fNumHiGainSamples)
+    {
+      fWindowSizeHiGain = fNumHiGainSamples & ~1;
+      *fLog << warn << "MExtractSignal3::SetWindows - Hi Gain window size set to " 
+            << int(fWindowSizeHiGain) << " samples " << endl;
+    }
+  
+  if (fWindowSizeLoGain > fNumLoGainSamples)
+    {
+      fWindowSizeLoGain = fNumLoGainSamples & ~1;
+      *fLog << warn << "MExtractSignal3::SetWindows - Lo Gain window size set to " 
+            << int(fWindowSizeLoGain) << " samples " << endl;
+    }
+
+  fWindowSqrtHiGain = TMath::Sqrt((Float_t)fWindowSizeHiGain);
+  fWindowSqrtLoGain = TMath::Sqrt((Float_t)fWindowSizeLoGain);
+
+}
+
+
+// --------------------------------------------------------------------------
+//
+// The PreProcess searches for the following input containers:
+//  - MRawEvtData
+//  - MPedestalCam
+//
+// The following output containers are also searched and created if
+// they were not found:
+//
+//  - MExtractedSignalCam
+//
+Int_t MExtractSignal3::PreProcess(MParList *pList)
+{
+  fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData"));
+  if (!fRawEvt)
+    {
+      *fLog << err << AddSerialNumber("MRawEvtData") << " not found... aborting." << endl;
+      return kFALSE;
+    }
+
+  fSignals = (MExtractedSignalCam*)pList->FindCreateObj(AddSerialNumber("MExtractedSignalCam"));
+  if (!fSignals)
+    return kFALSE;
+
+  //
+  // FIXME? We should keep track in MExtractedSignalCam of the signal extraction method used.
+  //
+  fSignals->SetUsedFADCSlices(0, fNumHiGainSamples-1, (Float_t)fWindowSizeHiGain,
+			      0, fNumLoGainSamples-1, (Float_t)fWindowSizeLoGain);
+
+  fPedestals = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
+  if (!fPedestals)
+    {
+      *fLog << err << AddSerialNumber("MPedestalCam") << " not found... aborting" << endl;
+      return kFALSE;
+    }
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// FindPeak
+// Finds highest sum of "window" consecutive FADC slices in a pixel, and store
+// in "startslice" the first slice of the group which yields the maximum sum.
+// In "max" the value of the maximum sum is stored, in "sat" the number of 
+// saturated slices.
+//
+void MExtractSignal3::FindPeak(Byte_t *ptr, Byte_t window, Byte_t &startslice, 
+			       Int_t &max, Int_t &sat) const
+{
+  const Byte_t *end = ptr + fNumHiGainSamples;
+
+  Int_t sum=0;
+
+  //
+  // Calculate the sum of the first "window" slices
+  //
+  sat = 0;
+  Byte_t *p = ptr;
+
+  while (p<ptr+window)
+    {
+      sum += *p;
+      if (*p++ >= fSaturationLimit)
+	sat++;
+    }
+
+  //
+  // Check for saturation in all other slices
+  //
+  while (p<end)
+    if (*p++ >= fSaturationLimit)
+      sat++;
+
+  //
+  // Calculate the i-th sum of n as
+  //    sum_i+1 = sum_i + slice[i+window] - slice[i]
+  // This is fast and accurate (because we are using int's)
+  //
+  max=sum;
+  for (p=ptr; p+window<end; p++)
+    {
+      sum += *(p+window) - *p;
+      if (sum > max)
+	{
+	  max = sum;
+	  startslice = p-ptr;
+	}
+    }
+
+  return;
+}
+
+// --------------------------------------------------------------------------
+//
+// FindSignal
+// Adds up "window" slices starting in slice to which "ptr" points. The result 
+// is stored in "sum", and the number of saturated  slices in "sat".
+//
+void MExtractSignal3::FindSignal(Byte_t *ptr, Byte_t window, Int_t &sum, Int_t &sat) const
+{
+  //
+  // Calculate the sum of the "window" slices starting in ptr
+  //
+  sum=0;
+  sat = 0;
+  Byte_t *p = ptr;
+
+  while (p<ptr+window)
+    {
+      sum += *p;
+      if (*p++ >= fSaturationLimit)
+	sat++;
+    }
+
+  return;
+}
+
+// --------------------------------------------------------------------------
+//
+// Process
+// First find the pixel with highest sum of fPeakSearchWindowSize slices (default:4)
+// "startslice" will mark the slice at which the highest sum begins for that pixel.
+// Then define the beginning of the integration window for ALL pixels as the slice
+// before that: startslice-1 (this is somehow arbitrary), unless of course startslice=0,
+// in which case we start at 0. We will also check that the integration window does not 
+// go beyond the FADC limits.
+//
+Int_t MExtractSignal3::Process()
+{
+  MRawEvtPixelIter pixel(fRawEvt);
+
+  Int_t sat;
+  Int_t maxsumhi = 0;
+  Byte_t startslice;
+  Byte_t hiGainFirst = 0;
+  Byte_t loGainFirst = 0;
+
+  while (pixel.Next())
+    {
+      Int_t sumhi;
+      sat = 0;
+
+      FindPeak(pixel.GetHiGainSamples(), fPeakSearchWindowSize, startslice, sumhi, sat);
+      if (sumhi > maxsumhi && sat == 0 )
+	{
+	  maxsumhi = sumhi;
+	  if (startslice > 0)
+	    hiGainFirst = startslice-1;
+	  else
+	    hiGainFirst = 0;
+	}
+    }
+
+
+  loGainFirst = hiGainFirst;
+
+  // Make sure we will not integrate beyond the hi gain limit:
+  if (hiGainFirst+fWindowSizeHiGain > pixel.GetNumHiGainSamples())
+    hiGainFirst = pixel.GetNumHiGainSamples()-fWindowSizeHiGain;
+
+  // Make sure we will not integrate beyond the lo gain limit:
+  if (loGainFirst+fWindowSizeLoGain > pixel.GetNumLoGainSamples())
+    loGainFirst = pixel.GetNumLoGainSamples()-fWindowSizeLoGain;
+
+  pixel.Reset();
+  fSignals->Clear();
+
+  sat = 0;
+  while (pixel.Next())
+    {
+      //
+      // Find signal in hi- and lo-gain
+      //
+      Int_t sumhi, sathi;
+
+      FindSignal(pixel.GetHiGainSamples()+hiGainFirst, fWindowSizeHiGain, sumhi, sathi);
+
+      Int_t sumlo=0;
+      Int_t satlo=0;
+      if (pixel.HasLoGain())
+        {
+	  FindSignal(pixel.GetLoGainSamples()+loGainFirst, fWindowSizeLoGain, sumlo, satlo);
+	  if (satlo)
+	    sat++;
+        }
+
+      //
+      // Take corresponding pedestal
+      //
+      const Int_t pixid = pixel.GetPixelId();
+
+      const MPedestalPix  &ped = (*fPedestals)[pixid];
+      MExtractedSignalPix &pix = (*fSignals)[pixid];
+
+      const Float_t pedes  = ped.GetPedestal();
+      const Float_t pedrms = ped.GetPedestalRms();
+
+      //
+      // Set extracted signal with pedestal substracted
+      //
+      pix.SetExtractedSignal(sumhi - pedes*fWindowSizeHiGain, pedrms*fWindowSqrtHiGain,
+			     sumlo - pedes*fWindowSizeLoGain, pedrms*fWindowSqrtLoGain);
+
+      pix.SetGainSaturation(sathi, sathi, satlo);
+    } /* while (pixel.Next()) */
+
+  //
+  // Print a warning if event has saturationg lo-gains
+  //
+  if (sat)
+    *fLog << warn << "WARNING - Lo Gain saturated in " << sat << " pixels." << endl;
+
+  fSignals->SetReadyToSave();
+
+  return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractSignal3.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractSignal3.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractSignal3.h	(revision 9661)
@@ -0,0 +1,63 @@
+#ifndef MARS_MExtractSignal3
+#define MARS_MExtractSignal3
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MRawEvtData;
+class MRawRunHeader;
+
+class MPedestalCam;
+class MExtractedSignalCam;
+
+class MExtractSignal3 : public MTask
+{
+private:
+    static const Byte_t fgSaturationLimit;
+    static const Byte_t fgFirst;
+    static const Byte_t fgLast;
+    static const Byte_t fgWindowSize;
+    static const Byte_t fgPeakSearchWindowSize;
+
+    MPedestalCam        *fPedestals;    // Pedestals of all pixels in the camera
+    MExtractedSignalCam *fSignals;      // Extracted signal of all pixels in the camera
+
+    MRawEvtData         *fRawEvt;       // raw event data (time slices)
+    MRawRunHeader       *fRunHeader;    // RunHeader information
+
+
+    Byte_t  fPeakSearchWindowSize; // Size of FADC window in the search for the highest peak
+                                   // of all pixels.
+
+    Byte_t  fNumHiGainSamples;
+    Byte_t  fNumLoGainSamples;
+
+    Byte_t  fWindowSizeHiGain;  // Number of Hi Gain slices in window
+    Float_t fWindowSqrtHiGain;  // Square root of number of Hi Gain slices in window
+
+    Byte_t  fWindowSizeLoGain;  // Number of Lo Gain slices in window
+    Float_t fWindowSqrtLoGain;  // Square root of number of Lo Gain slices in window
+
+    Byte_t  fSaturationLimit;
+
+    void   FindSignal(Byte_t *ptr, Byte_t window, Int_t &sum, Int_t &sat) const;
+
+    void   FindPeak(Byte_t *ptr, Byte_t window, Byte_t &startslice, Int_t &signal, Int_t &sat) const;
+
+
+    Int_t  PreProcess(MParList *pList);
+    Int_t  Process();
+
+public:
+    MExtractSignal3(const char *name=NULL, const char *title=NULL);
+
+    void SetWindows(Byte_t windowh=fgWindowSize, Byte_t windowl=fgWindowSize, 
+		    Byte_t peaksearchwindow=fgPeakSearchWindowSize);
+
+    void SetSaturationLimit(Byte_t lim) { fSaturationLimit = lim; }
+
+    ClassDef(MExtractSignal3, 0) // Extracted Signal algorithm #3
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractSignalABcorr.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractSignalABcorr.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractSignalABcorr.cc	(revision 9661)
@@ -0,0 +1,248 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug, 09/2003 <mailto:markus@ifae.es>
+!              Thomas Bretz, 01/2004 
+!              Florian Goebel, 06/2004
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//   MExtractSignalABcorr
+//
+//   this class is basically a copy of MExtractSignal and is mainly ment as 
+//   an example of how to use the "AB pedestal offset" to correct for the 
+//   150 MHz clock noise. It allows to extract a signal using an odd number 
+//   of slices 
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MExtractSignalABcorr.h"
+
+#include <fstream>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MRawEvtData.h"
+#include "MRawEvtPixelIter.h"
+
+#include "MPedestalCam.h"
+#include "MPedestalPix.h"
+
+#include "MExtractedSignalCam.h"
+#include "MExtractedSignalPix.h"
+
+ClassImp(MExtractSignalABcorr);
+
+using namespace std;
+
+const Byte_t MExtractSignalABcorr::fgSaturationLimit = 254;
+const Byte_t MExtractSignalABcorr::fgFirst =  3;
+const Byte_t MExtractSignalABcorr::fgLast  = 14;
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+MExtractSignalABcorr::MExtractSignalABcorr(const char *name, const char *title)
+    : fSaturationLimit(fgSaturationLimit)
+{
+
+    fName  = name  ? name  : "MExtractSignalABcorr";
+    fTitle = title ? title : "Task to extract the signal from the FADC slices";
+
+    AddToBranchList("MRawEvtData.*");
+
+    SetRange();
+}
+
+void MExtractSignalABcorr::SetRange(Byte_t hifirst, Byte_t hilast, Byte_t lofirst, Byte_t lolast)
+{
+
+    fNumHiGainSamples = hilast-hifirst+1;
+    fNumLoGainSamples = lolast-lofirst+1;
+
+    fHiGainFirst = hifirst;
+    fLoGainFirst = lofirst;
+
+    fSqrtHiGainSamples = TMath::Sqrt((Float_t)fNumHiGainSamples);
+    fSqrtLoGainSamples = TMath::Sqrt((Float_t)fNumLoGainSamples);
+}
+
+// --------------------------------------------------------------------------
+//
+// The PreProcess searches for the following input containers:
+//  - MRawEvtData
+//  - MPedestalCam
+//
+// The following output containers are also searched and created if
+// they were not found:
+//
+//  - MExtractedSignalCam
+//
+Int_t MExtractSignalABcorr::PreProcess(MParList *pList)
+{
+    fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData"));
+    if (!fRawEvt)
+    {
+        *fLog << err << AddSerialNumber("MRawEvtData") << " not found... aborting." << endl;
+        return kFALSE;
+    }
+
+
+    fSignals = (MExtractedSignalCam*)pList->FindCreateObj(AddSerialNumber("MExtractedSignalCam"));
+    if (!fSignals)
+        return kFALSE;
+
+    fSignals->SetUsedFADCSlices(fHiGainFirst, fHiGainFirst+fNumHiGainSamples-1, (Float_t)fNumHiGainSamples,
+                                fLoGainFirst, fLoGainFirst+fNumLoGainSamples-1, (Float_t)fNumLoGainSamples);
+
+    fPedestals = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
+
+    if (!fPedestals)
+    {
+        *fLog << err << AddSerialNumber("MPedestalCam") << " not found... aborting" << endl;
+        return kFALSE;
+    }
+
+    return kTRUE;
+}
+
+void MExtractSignalABcorr::FindSignal(Byte_t *ptr, Int_t size, Int_t &sum, Byte_t &sat) const
+{
+
+  Byte_t *end = ptr + size;
+  
+  sum = 0;
+  sat = 0;
+  
+  while (ptr<end)
+    {
+      sum += *ptr;
+      
+      if (*ptr++ >= fSaturationLimit)
+        sat++;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculate the integral of the FADC time slices and store them as a new
+// pixel in the MExtractedSignalCam container.
+//
+Int_t MExtractSignalABcorr::Process()
+{
+    MRawEvtPixelIter pixel(fRawEvt);
+    fSignals->Clear();
+
+    UInt_t  sat=0;
+
+    const Bool_t ApplyABcorrHi = fNumHiGainSamples&0x1;
+    const Bool_t ApplyABcorrLo = fNumLoGainSamples&0x1;
+
+    while (pixel.Next())
+    {
+        Int_t sumhi;
+        Byte_t sathi;
+
+        FindSignal(pixel.GetHiGainSamples()+fHiGainFirst, fNumHiGainSamples, sumhi, sathi);
+
+        Int_t  sumlo = 0;
+        Byte_t satlo = 0;
+        if (pixel.HasLoGain())
+        {
+            FindSignal(pixel.GetLoGainSamples()+fLoGainFirst, fNumLoGainSamples, sumlo, satlo);
+
+            if (satlo)
+              sat++;
+        }
+
+        const Int_t pixid   = pixel.GetPixelId();
+	const Bool_t ABFlag = pixel.HasABFlag();
+
+        const MPedestalPix  &ped = (*fPedestals)[pixid]; 
+	MExtractedSignalPix &pix = (*fSignals)[pixid];
+
+        const Float_t pedes  = ped.GetPedestal();
+        const Float_t pedrms = ped.GetPedestalRms();
+	const Float_t ABoffs = ped.GetPedestalABoffset();
+
+	Float_t pedtothi = pedes*fNumHiGainSamples;
+	Float_t pedtotlo = pedes*fNumLoGainSamples;
+
+	if (ApplyABcorrHi) {
+	  pedtothi += ABoffs*(1-2*((fHiGainFirst+ABFlag)&0x1));
+	}
+	if (ApplyABcorrLo) {
+	  pedtotlo += ABoffs*(1-2*((fLoGainFirst+ABFlag)&0x1));
+	}
+
+        pix.SetExtractedSignal(sumhi - pedtothi, pedrms*fSqrtHiGainSamples,
+                               sumlo - pedtotlo, pedrms*fSqrtLoGainSamples);
+
+	pix.SetGainSaturation(sathi, sathi, satlo);
+
+    } /* while (pixel.Next()) */
+
+    fSignals->SetReadyToSave();
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
+void MExtractSignalABcorr::StreamPrimitive(ofstream &out) const
+{
+    out << "   " << ClassName() << " " << GetUniqueName() << "(\"";
+    out << "\"" << fName << "\", \"" << fTitle << "\");" << endl;
+
+    if (fSaturationLimit!=fgSaturationLimit)
+    {
+        out << "   " << GetUniqueName() << ".SetSaturationLimit(";
+        out << (int)fSaturationLimit << ");" << endl;
+    }
+
+    const Bool_t arg4 = fNumLoGainSamples+fLoGainFirst-1 != fgLast;
+    const Bool_t arg3 = arg4 || fLoGainFirst != fgFirst;
+    const Bool_t arg2 = arg3 || fNumHiGainSamples+fHiGainFirst-1 != fgLast;
+    const Bool_t arg1 = arg2 || fHiGainFirst != fgFirst;
+
+    if (!arg1)
+        return;
+
+    out << "   " << GetUniqueName() << ".SetRange(";
+    out << (int)fLoGainFirst;
+    if (arg2)
+    {
+        out << ", " << (int)(fNumHiGainSamples+fHiGainFirst-1);
+        if (arg3)
+        {
+            out << ", " << (int)fLoGainFirst;
+            if (arg4)
+                out << ", " << (int)(fNumLoGainSamples+fLoGainFirst-1);
+        }
+    }
+    out << ");" << endl;
+}
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractSignalABcorr.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractSignalABcorr.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractSignalABcorr.h	(revision 9661)
@@ -0,0 +1,62 @@
+#ifndef MARS_MExtractSignalABcorr
+#define MARS_MExtractSignalABcorr
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MExtractSignalABcorr                                                          //
+//                                                                         //
+// Integrates the time slices of the all pixels of a calibration event     //
+// and substract the pedestal value                                        //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MRawEvtData;
+class MRawRunHeader;
+
+class MPedestalCam;
+class MExtractedSignalCam;
+
+class MExtractSignalABcorr : public MTask
+{
+private:
+    static const Byte_t fgSaturationLimit;
+    static const Byte_t fgFirst;
+    static const Byte_t fgLast;
+
+    MPedestalCam        *fPedestals;    // Pedestals of all pixels in the camera
+    MExtractedSignalCam *fSignals;      // Extracted signal of all pixels in the camera
+
+    MRawEvtData         *fRawEvt;       // raw event data (time slices)
+    MRawRunHeader       *fRunHeader;    // RunHeader information
+
+    Byte_t  fHiGainFirst;
+    Byte_t  fLoGainFirst;
+
+    Byte_t  fNumHiGainSamples;
+    Byte_t  fNumLoGainSamples;
+
+    Float_t fSqrtHiGainSamples;
+    Float_t fSqrtLoGainSamples;
+
+    Byte_t  fSaturationLimit;
+
+    void   FindSignal(Byte_t *ptr, Int_t size, Int_t &sum, Byte_t &sat) const;
+
+    Int_t  PreProcess(MParList *pList);
+    Int_t  Process();
+    void   StreamPrimitive(ofstream &out) const;
+
+public:
+    MExtractSignalABcorr(const char *name=NULL, const char *title=NULL);
+
+    void SetRange(Byte_t hifirst=fgFirst, Byte_t hilast=fgLast, Byte_t lofirst=fgFirst, Byte_t lolast=fgLast);
+    void SetSaturationLimit(Byte_t lim) { fSaturationLimit = lim; }
+
+    ClassDef(MExtractSignalABcorr, 0) // Task to fill the Extracted Signal Containers from raw data
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractSlidingWindow.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractSlidingWindow.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractSlidingWindow.cc	(revision 9661)
@@ -0,0 +1,331 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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, 02/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!              Hendrik Bartko, 01/2004 <mailto:hbartko@mppmu.mpg.de>
+!              Markus Gaug   , 04/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//   MExtractSlidingWindow
+//
+//  Extracts the signal from a sliding window of size fHiGainWindowSize and 
+//  fLoGainWindowSize. The signal is the one which maximizes the integral 
+//  contents. 
+//
+//  Call: SetRange(higainfirst, higainlast, logainfirst, logainlast) 
+//  to modify the ranges in which the window is allowed to move. 
+//  Defaults are: 
+// 
+//   fHiGainFirst =  fgHiGainFirst =  0 
+//   fHiGainLast  =  fgHiGainLast  =  14
+//   fLoGainFirst =  fgLoGainFirst =  3 
+//   fLoGainLast  =  fgLoGainLast  =  14
+//
+//  Call: SetWindowSize(windowhigain, windowlogain) 
+//  to modify the sliding window widths. Windows have to be an even number. 
+//  In case of odd numbers, the window will be modified.
+//
+//  Defaults are:
+//
+//   fHiGainWindowSize = fgHiGainWindowSize = 6
+//   fLoGainWindowSize = fgLoGainWindowSize = 6
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MExtractSlidingWindow.h"
+#include "MExtractor.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MExtractedSignalCam.h"
+
+ClassImp(MExtractSlidingWindow);
+
+using namespace std;
+
+const Byte_t MExtractSlidingWindow::fgHiGainFirst      = 0;
+const Byte_t MExtractSlidingWindow::fgHiGainLast       = 14;
+const Byte_t MExtractSlidingWindow::fgLoGainFirst      = 3;
+const Byte_t MExtractSlidingWindow::fgLoGainLast       = 14;
+const Byte_t MExtractSlidingWindow::fgHiGainWindowSize = 6;
+const Byte_t MExtractSlidingWindow::fgLoGainWindowSize = 6;
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+// Sets:
+// - fWindowSizeHiGain to fgHiGainWindowSize
+// - fWindowSizeLoGain to fgLoGainWindowSize
+//
+// Calls: 
+// - SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast)
+//
+MExtractSlidingWindow::MExtractSlidingWindow(const char *name, const char *title)
+    : fWindowSizeHiGain(fgHiGainWindowSize), 
+      fWindowSizeLoGain(fgLoGainWindowSize)
+{
+
+  fName  = name  ? name  : "MExtractSlidingWindow";
+  fTitle = title ? title : "Signal Extractor for a sliding FADC window";
+
+  SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast);
+}
+
+// --------------------------------------------------------------------------
+//
+// SetRange: 
+//
+// Calls:
+// - MExtractor::SetRange(hifirst,hilast,lofirst,lolast);
+// - SetWindowSize(fWindowSizeHiGain,fWindowSizeLoGain);
+//
+void MExtractSlidingWindow::SetRange(Byte_t hifirst, Byte_t hilast, Byte_t lofirst, Byte_t lolast)
+{
+
+  MExtractor::SetRange(hifirst,hilast,lofirst,lolast);
+
+  //
+  // Redo the checks if the window is still inside the ranges
+  //
+
+  SetWindowSize(fWindowSizeHiGain,fWindowSizeLoGain);
+  
+}
+
+
+// --------------------------------------------------------------------------
+//
+// The ReInit calls:
+// -  MExtractor::ReInit()
+// -  fSignals->SetUsedFADCSlices(fHiGainFirst, fHiGainLast+fHiLoLast, fNumHiGainSamples,
+//                                fLoGainFirst, fLoGainLast, fNumLoGainSamples);
+//
+Bool_t MExtractSlidingWindow::ReInit(MParList *pList)
+{
+
+  MExtractor::ReInit(pList);
+  
+  fSignals->SetUsedFADCSlices(fHiGainFirst, fHiGainLast+fHiLoLast, fNumHiGainSamples,
+                              fLoGainFirst, fLoGainLast, fNumLoGainSamples);
+
+  return kTRUE;
+  
+}
+
+// --------------------------------------------------------------------------
+//
+// Checks:
+// - if a window is odd, subtract one
+// - if a window is bigger than the one defined by the ranges, set it to the available range
+// - if a window is smaller than 2, set it to 2
+// 
+// Sets:
+// - fNumHiGainSamples to: (Float_t)fWindowSizeHiGain
+// - fNumLoGainSamples to: (Float_t)fWindowSizeLoGain
+// - fSqrtHiGainSamples to: TMath::Sqrt(fNumHiGainSamples)
+// - fSqrtLoGainSamples to: TMath::Sqrt(fNumLoGainSamples)  
+//  
+void MExtractSlidingWindow::SetWindowSize(Byte_t windowh, Byte_t windowl)
+{
+  
+  fWindowSizeHiGain = windowh & ~1;
+  fWindowSizeLoGain = windowl & ~1;
+
+  if (fWindowSizeHiGain != windowh)
+    *fLog << warn << GetDescriptor() << ": Hi Gain window size has to be even, set to: " 
+          << int(fWindowSizeHiGain) << " samples " << endl;
+  
+  if (fWindowSizeLoGain != windowl)
+    *fLog << warn << GetDescriptor() << ": Lo Gain window size has to be even, set to: " 
+          << int(fWindowSizeLoGain) << " samples " << endl;
+    
+  const Byte_t availhirange = (fHiGainLast-fHiGainFirst+1) & ~1;
+  const Byte_t availlorange = (fLoGainLast-fLoGainFirst+1) & ~1;
+
+  if (fWindowSizeHiGain > availhirange)
+    {
+      *fLog << warn << GetDescriptor() 
+            << Form("%s%2i%s%2i%s%2i%s",": Hi Gain window size: ",(int)fWindowSizeHiGain,
+                    " is bigger than available range: [",(int)fHiGainFirst,",",(int)fHiGainLast,"]") << endl;
+      *fLog << warn << GetDescriptor() 
+            << ": Will set window size to: " << (int)availhirange << endl;
+      fWindowSizeHiGain = availhirange;
+    }
+  
+  if (fWindowSizeLoGain > availlorange)
+    {
+      *fLog << warn << GetDescriptor() 
+            << Form("%s%2i%s%2i%s%2i%s",": Lo Gain window size: ",(int)fWindowSizeLoGain,
+                    " is bigger than available range: [",(int)fLoGainFirst,",",(int)fLoGainLast,"]") << endl;
+      *fLog << warn << GetDescriptor() 
+            << ": Will set window size to: " << (int)availlorange << endl;
+      fWindowSizeLoGain = availlorange;
+    }
+  
+  if (fWindowSizeHiGain<2) 
+    {
+      fWindowSizeHiGain = 2;
+      *fLog << warn << GetDescriptor() << ": Hi Gain window size set to two samples" << endl;
+    }
+  
+  if (fWindowSizeLoGain<2) 
+    {
+      fWindowSizeLoGain = 2;
+      *fLog << warn << GetDescriptor() << ": Lo Gain window size set to two samples" << endl;
+    }
+    
+  fNumHiGainSamples = (Float_t)fWindowSizeHiGain;
+  fNumLoGainSamples = (Float_t)fWindowSizeLoGain;
+  
+  fSqrtHiGainSamples = TMath::Sqrt(fNumHiGainSamples);
+  fSqrtLoGainSamples = TMath::Sqrt(fNumLoGainSamples);
+
+}
+
+
+// --------------------------------------------------------------------------
+//
+// FindSignalHiGain:
+//
+// - Loop from ptr to (ptr+fWindowSizeHiGain)
+// - Sum up contents of *ptr
+// - If *ptr is greater than fSaturationLimit, raise sat by 1
+// - Loop from (ptr+fWindowSizeHiGain) to (ptr+fHiGainLast-fHiGainFirst)
+// - Sum the content of *(ptr+fWindowSizeHiGain) and subtract *ptr
+// - Check if the sum has become bigger and store it in case yes.
+// 
+void MExtractSlidingWindow::FindSignalHiGain(Byte_t *ptr, Byte_t *logain, Float_t &max, Byte_t &sat) const
+{
+    const Byte_t *end = ptr + fHiGainLast - fHiGainFirst + 1;
+
+    Int_t sum=0;
+    Int_t sumtot =0;
+
+    //
+    // Calculate the sum of the first fWindowSize slices
+    //
+    sat = 0;
+    Byte_t *p = ptr;
+    
+    while (p<ptr+fWindowSizeHiGain-fHiLoLast)
+    {
+        sum += *p;
+        if (*p++ >= fSaturationLimit)
+            sat++;
+    }
+
+    //
+    // Check for saturation in all other slices
+    //
+    while (p<end)
+        if (*p++ >= fSaturationLimit)
+            sat++;
+
+    //
+    // If part of the "low-Gain" slices are used, 
+    // repeat steps one and two for the logain part until fHiLoLast
+    //
+    Byte_t *l = logain;
+    while (l<logain+fHiLoLast)
+      {
+        sum += *l;
+        if (*l++ >= fSaturationLimit)
+            sat++;
+      }
+
+
+    //
+    // Calculate the i-th sum as
+    //    sum_i+1 = sum_i + slice[i+8] - slice[i]
+    // This is fast and accurate (because we are using int's)
+    //
+    sumtot=sum;
+    for (p=ptr; p+fWindowSizeHiGain-fHiLoLast<end; p++)
+    {
+        sum += *(p+fWindowSizeHiGain-fHiLoLast) - *p;
+        if (sum>sumtot)
+            sumtot = sum;
+    }
+
+    for (l=logain; l<logain+fHiLoLast; l++)
+    {
+        sum += *l - *p++;
+        if (sum>sumtot)
+            sumtot = sum;
+    }
+    max = (Float_t)sumtot;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// FindSignalLoGain:
+//
+// - Loop from ptr to (ptr+fWindowSizeLoGain)
+// - Sum up contents of *ptr
+// - If *ptr is greater than fSaturationLimit, raise sat by 1
+// - Loop from (ptr+fWindowSizeLoGain) to (ptr+fLoGainLast-fLoGainFirst)
+// - Sum the content of *(ptr+fWindowSizeLoGain) and subtract *ptr
+// - Check if the sum has become bigger and store it in case yes.
+// 
+void MExtractSlidingWindow::FindSignalLoGain(Byte_t *ptr, Float_t &max, Byte_t &sat) const
+{
+    const Byte_t *end = ptr + fLoGainLast - fLoGainFirst + 1;
+
+    Int_t sum=0;
+    Int_t sumtot=0;
+    //
+    // Calculate the sum of the first fWindowSize slices
+    //
+    sat = 0;
+    Byte_t *p = ptr;
+    while (p<ptr+fWindowSizeLoGain)
+    {
+        sum += *p;
+        if (*p++ >= fSaturationLimit)
+            sat++;
+    }
+
+    //
+    // Check for saturation in all other slices
+    //
+    while (p<end)
+        if (*p++ >= fSaturationLimit)
+            sat++;
+
+    //
+    // Calculate the i-th sum as
+    //    sum_i+1 = sum_i + slice[i+8] - slice[i]
+    // This is fast and accurate (because we are using int's)
+    //
+    sumtot=sum;
+    for (p=ptr; p+fWindowSizeLoGain<end; p++)
+    {
+        sum += *(p+fWindowSizeLoGain) - *p;
+        if (sum>sumtot)
+            sumtot = sum;
+    }
+    max = (Float_t)sumtot;
+}
+
+
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractSlidingWindow.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractSlidingWindow.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractSlidingWindow.h	(revision 9661)
@@ -0,0 +1,37 @@
+#ifndef MARS_MExtractSlidingWindow
+#define MARS_MExtractSlidingWindow
+
+#ifndef MARS_MExtractor
+#include "MExtractor.h"
+#endif
+
+class MExtractSlidingWindow : public MExtractor
+{
+private:
+  
+  static const Byte_t fgHiGainFirst;      // First FADC slice Hi-Gain (currently set to: 3) 
+  static const Byte_t fgHiGainLast;       // Last FADC slice Hi-Gain (currently set to: 14) 
+  static const Byte_t fgLoGainFirst;      // First FADC slice Lo-Gain (currently set to: 3) 
+  static const Byte_t fgLoGainLast;       // Last FADC slice Lo-Gain (currently set to: 14) 
+  static const Byte_t fgHiGainWindowSize; // The extraction window Hi-Gain
+  static const Byte_t fgLoGainWindowSize; // The extraction window Lo-Gain
+
+  Byte_t  fWindowSizeHiGain;             // Number of Hi Gain slices in window
+  Byte_t  fWindowSizeLoGain;             // Number of Lo Gain slices in window  
+  
+  void   FindSignalHiGain(Byte_t *ptr, Byte_t *logain, Float_t &max, Byte_t &sat) const;
+  void   FindSignalLoGain(Byte_t *ptr, Float_t &max, Byte_t &sat) const;  
+
+  Bool_t  ReInit(MParList *pList);
+  
+public:
+  MExtractSlidingWindow(const char *name=NULL, const char *title=NULL);
+
+  void SetRange(Byte_t hifirst=0, Byte_t hilast=0, Byte_t lofirst=0, Byte_t lolast=0);
+  void SetWindowSize(Byte_t windowh=fgHiGainWindowSize,
+                     Byte_t windowl=fgLoGainWindowSize);
+
+  ClassDef(MExtractSlidingWindow, 0) // Signal Extractor for sliding extraction window
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractTime.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractTime.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractTime.cc	(revision 9661)
@@ -0,0 +1,215 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug, 04/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//   MExtractTime
+//
+//   Base class for the signal extractors, used the functions 
+//   FindTimeHiGain() and FindTimeLoGain() to extract the signal and 
+//   substract the pedestal value    
+//
+//   The following variables have to be set by the derived class and 
+//   do not have defaults:
+//   - fNumHiGainSamples
+//   - fNumLoGainSamples
+//   - fSqrtHiGainSamples
+//   - fSqrtLoGainSamples
+//
+// Input Containers:
+//   MRawEvtData
+//   MRawRunHeader
+//   MPedestalCam
+//
+// Output Containers:
+//   MArrivalTimeCam
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MExtractTime.h"
+
+#include <fstream>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MRawEvtData.h"
+#include "MRawEvtPixelIter.h"
+#include "MRawRunHeader.h"
+
+#include "MPedestalCam.h"
+#include "MPedestalPix.h"
+
+#include "MArrivalTimeCam.h"
+#include "MArrivalTimePix.h"
+
+ClassImp(MExtractTime);
+
+using namespace std;
+const Float_t MExtractTime::fgOffsetLoGain = 1.51;   // 5 ns
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+// Set: 
+// - all pointers to NULL
+// - all variables to 0
+// - fSaturationLimit to fgSaturationLimit
+//
+// Call:
+// -  AddToBranchList("MRawEvtData.*")
+//
+MExtractTime::MExtractTime(const char *name, const char *title)
+    : fArrTime(NULL)
+{
+
+    fName  = name  ? name  : "MExtractTime";
+    fTitle = title ? title : "Base class for signal extractors";
+
+    SetOffsetLoGain();
+}
+
+
+
+// --------------------------------------------------------------------------
+//
+// The PreProcess searches for the following input containers:
+//  - MRawEvtData
+//  - MRawRunHeader
+//  - MPedestalCam
+//
+// The following output containers are also searched and created if
+// they were not found:
+//
+//  - MArrivalTimeCam
+//
+Int_t MExtractTime::PreProcess(MParList *pList)
+{
+
+  fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData"));
+  if (!fRawEvt)
+    {
+        *fLog << err << AddSerialNumber("MRawEvtData") << " not found... aborting." << endl;
+        return kFALSE;
+    }
+  
+  fRunHeader = (MRawRunHeader*)pList->FindObject(AddSerialNumber("MRawRunHeader"));
+  if (!fRunHeader)
+    {
+      *fLog << err << AddSerialNumber("MRawRunHeader") << " not found... aborting." << endl;
+      return kFALSE;
+    }
+  
+  
+  fArrTime = (MArrivalTimeCam*)pList->FindCreateObj(AddSerialNumber("MArrivalTimeCam"));
+  if (!fArrTime)
+    return kFALSE;
+  
+
+  fPedestals = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
+  if (!fPedestals)
+    {
+      *fLog << err << AddSerialNumber("MPedestalCam") << " not found... aborting" << endl;
+      return kFALSE;
+    }
+  
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// The ReInit calls:
+// -  MExtractor::ReInit()
+//
+// Call: 
+// - MArrivalTimeCam::SetUsedFADCSlices(fHiGainFirst, fHiGainLast, fNumHiGainSamples,
+//                                      fLoGainFirst, fLoGainLast, fNumLoGainSamples);
+//
+Bool_t MExtractTime::ReInit(MParList *pList)
+{
+  
+  MExtractor::ReInit(pList);
+
+  fArrTime->SetUsedFADCSlices(fHiGainFirst, fHiGainLast+fHiLoLast, fLoGainFirst, fLoGainLast);
+
+  return kTRUE;
+}
+
+
+
+void MExtractTime::FindTimeHiGain(Byte_t *firstused, Float_t &time, Float_t &dtime, 
+                                  Byte_t &sat, const MPedestalPix &ped) const
+{
+  return;
+}
+
+void MExtractTime::FindTimeLoGain(Byte_t *firstused, Float_t &time, Float_t &dtime, 
+                                  Byte_t &sat, const MPedestalPix &ped) const
+{
+  return;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculate the integral of the FADC time slices and store them as a new
+// pixel in the MArrivalTimeCam container.
+//
+Int_t MExtractTime::Process()
+{
+
+
+  MRawEvtPixelIter pixel(fRawEvt);
+  fArrTime->Clear();
+
+  while (pixel.Next())
+    {
+      //
+      // Find signal in hi- and lo-gain
+      //
+      Float_t timehi=0., deltatimehi=0.;
+      Byte_t sathi=0;
+
+      const Int_t pixid = pixel.GetPixelId();
+      const MPedestalPix  &ped = (*fPedestals)[pixid];
+      MArrivalTimePix &pix = (*fArrTime)[pixid];
+
+      FindTimeHiGain(pixel.GetHiGainSamples()+fHiGainFirst, timehi, deltatimehi, sathi, ped);
+
+      Float_t timelo=0., deltatimelo=0.;
+      Byte_t satlo=0;
+
+      if (sathi)
+	  FindTimeLoGain(pixel.GetLoGainSamples()+fLoGainFirst, timelo, deltatimelo, satlo, ped);
+
+      pix.SetArrivalTime(timehi, deltatimehi, timelo-fOffsetLoGain, deltatimelo);
+      pix.SetGainSaturation(sathi, sathi, satlo);
+ 
+    } /* while (pixel.Next()) */
+
+    fArrTime->SetReadyToSave();
+
+    return kTRUE;
+}
+
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractTime.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractTime.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractTime.h	(revision 9661)
@@ -0,0 +1,42 @@
+#ifndef MARS_MExtractTime
+#define MARS_MExtractTime
+
+#ifndef MARS_MExtractor
+#include "MExtractor.h"
+#endif
+
+class MPedestalPix;
+class MArrivalTimeCam;
+class MExtractTime : public MExtractor
+{
+  
+  static const Float_t fgOffsetLoGain;  // Default for fOffsetLoGain (now set to 1.51 (= 5ns)
+
+protected:
+
+  Float_t fOffsetLoGain;                // Offset of the low-gain signal w.r.t. the High-Gain slices 
+
+  MArrivalTimeCam *fArrTime;            // Container with the photons arrival times
+  
+  virtual Int_t PreProcess(MParList *pList);
+  virtual Bool_t ReInit(MParList *pList);
+  virtual Int_t Process();
+
+  virtual void FindTimeHiGain(Byte_t *firstused, Float_t &time, Float_t &dtime,
+                              Byte_t &sat, const MPedestalPix &ped) const;
+  virtual void FindTimeLoGain(Byte_t *firstused, Float_t &time, Float_t &dtime,
+                              Byte_t &sat, const MPedestalPix &ped) const;
+
+public:
+
+  MExtractTime(const char *name=NULL, const char *title=NULL);
+
+  void SetOffsetLoGain( const Float_t f=fgOffsetLoGain) { fOffsetLoGain = f; }
+ 
+  ClassDef(MExtractTime, 0)   // Arrival Time Extractor Base Class
+};
+
+#endif
+
+
+
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractTimeAndCharge.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractTimeAndCharge.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractTimeAndCharge.cc	(revision 9661)
@@ -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): Markus Gaug, 05/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//   MExtractTimeAndCharge
+//
+//   Base class for the signal extractors which extract the arrival time 
+//   and the signal at the same time. Uses the functions 
+//   FindTimeAndChargeHiGain() and FindTimeAndChargeLoGain() to extract the signal and 
+//   substract the pedestal value    
+//
+//   The following variables have to be set by the derived class and 
+//   do not have defaults:
+//   - fNumHiGainSamples
+//   - fNumLoGainSamples
+//   - fSqrtHiGainSamples
+//   - fSqrtLoGainSamples
+//
+// Input Containers:
+//   MRawEvtData
+//   MRawRunHeader
+//   MPedestalCam
+//
+// Output Containers:
+//   MArrivalTimeCam
+//   MExtractedSignalCam
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MExtractTimeAndCharge.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MRawEvtData.h"
+#include "MRawEvtPixelIter.h"
+#include "MRawRunHeader.h"
+
+#include "MPedestalCam.h"
+#include "MPedestalPix.h"
+
+#include "MArrivalTimeCam.h"
+#include "MArrivalTimePix.h"
+
+#include "MExtractedSignalCam.h"
+#include "MExtractedSignalPix.h"
+
+ClassImp(MExtractTimeAndCharge);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// The PreProcess searches for the following input containers:
+//  - MRawEvtData
+//  - MRawRunHeader
+//  - MPedestalCam
+//
+// The following output containers are also searched and created if
+// they were not found:
+//
+//  - MExtractedSignalCam
+//  - MArrivalTimeCam    
+//
+Int_t MExtractTimeAndCharge::PreProcess(MParList *pList)
+{
+
+  if (!MExtractTime::PreProcess(pList))
+    return kFALSE;
+  
+  fSignals = (MExtractedSignalCam*)pList->FindCreateObj(AddSerialNumber("MExtractedSignalCam"));
+  if (!fSignals)
+    {
+      *fLog << err << GetDescriptor()
+            << ": Could not find nor create MExtractedSignalCam,... aborting." << endl;
+      return kFALSE;
+    }
+  
+  
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// The ReInit calls:
+// -  MExtractor::ReInit()
+//
+// Call: 
+// - MArrivalTimeCam::SetUsedFADCSlices(fHiGainFirst, fHiGainLast, fNumHiGainSamples,
+//                                      fLoGainFirst, fLoGainLast, fNumLoGainSamples);
+//
+Bool_t MExtractTimeAndCharge::ReInit(MParList *pList)
+{
+  
+  MExtractTime::ReInit(pList);
+
+  fSignals->SetUsedFADCSlices(fHiGainFirst, fHiGainLast+fHiLoLast, fNumHiGainSamples,
+                              fLoGainFirst, fLoGainLast, fNumLoGainSamples);
+
+  return kTRUE;
+}
+
+void MExtractTimeAndCharge::FindTimeAndChargeHiGain(Byte_t *firstused, Byte_t *logain, Float_t &sum, Float_t &dsum, 
+                                                    Float_t &time, Float_t &dtime,
+                                                    Byte_t &sat, const MPedestalPix &ped)
+{
+  return;
+}
+
+void MExtractTimeAndCharge::FindTimeAndChargeLoGain(Byte_t *firstused, Float_t &sum, Float_t &dsum, 
+                                                    Float_t &time, Float_t &dtime,
+                                                    Byte_t &sat, const MPedestalPix &ped)
+{
+  return;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Calculate the integral of the FADC time slices and store them as a new
+// pixel in the MArrivalTimeCam container.
+// Calculate the integral of the FADC time slices and store them as a new
+// pixel in the MExtractedSignalCam container. 
+// The functions FindTimeAndChargeHiGain() and FindTimeAndChargeLoGain are 
+// supposed to extract the signal themselves.
+//
+Int_t MExtractTimeAndCharge::Process()
+{
+
+  MRawEvtPixelIter pixel(fRawEvt);
+  fArrTime->Clear();
+  fSignals->Clear();
+
+  while (pixel.Next())
+    {
+      //
+      // Find signal in hi- and lo-gain
+      //
+      Float_t sumhi =0., deltasumhi =0.;
+      Float_t timehi=0., deltatimehi=0.;
+      Byte_t sathi=0;
+
+      const Int_t pixid = pixel.GetPixelId();
+      const MPedestalPix  &ped = (*fPedestals)[pixid];
+
+      FindTimeAndChargeHiGain(pixel.GetHiGainSamples()+fHiGainFirst, pixel.GetLoGainSamples(), 
+                              sumhi, deltasumhi, 
+                              timehi, deltatimehi, 
+                              sathi, ped);
+      
+      Float_t sumlo =0., deltasumlo =0.;
+      Float_t timelo=0., deltatimelo=0.;
+      Byte_t satlo=0;
+
+      FindTimeAndChargeLoGain(pixel.GetLoGainSamples()+fLoGainFirst, 
+                              sumlo, deltasumlo, 
+                              timelo, deltatimelo, 
+                              satlo, ped);
+
+      MExtractedSignalPix &pix = (*fSignals)[pixid];
+      MArrivalTimePix     &tix = (*fArrTime)[pixid];      
+
+      pix.SetExtractedSignal(sumhi, deltasumhi,sumlo, deltasumlo);
+      pix.SetGainSaturation(sathi, sathi, satlo);
+      
+      pix.SetNumHiGainSlices(fNumHiGainSamples);
+      pix.SetNumLoGainSlices(fNumLoGainSamples);      
+      
+      tix.SetArrivalTime(timehi, deltatimehi, timelo-fOffsetLoGain, deltatimelo);
+      tix.SetGainSaturation(sathi, sathi, satlo);
+ 
+    } /* while (pixel.Next()) */
+
+  fArrTime->SetReadyToSave();
+  fSignals->SetReadyToSave();
+
+  return kTRUE;
+}
+
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractTimeAndCharge.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractTimeAndCharge.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractTimeAndCharge.h	(revision 9661)
@@ -0,0 +1,32 @@
+#ifndef MARS_MExtractTimeAndCharge
+#define MARS_MExtractTimeAndCharge
+
+#ifndef MARS_MExtractTime
+#include "MExtractTime.h"
+#endif
+
+class MPedestalPix;
+class MExtractTimeAndCharge : public MExtractTime
+{
+protected:
+
+  virtual Int_t PreProcess(MParList *pList);
+  virtual Bool_t ReInit(MParList *pList);
+  virtual Int_t Process();
+
+  virtual void FindTimeAndChargeHiGain(Byte_t *firstused, Byte_t *logain, Float_t &sum, Float_t &dsum,
+                                       Float_t &time, Float_t &dtime,
+                                       Byte_t &sat, const MPedestalPix &ped);
+  virtual void FindTimeAndChargeLoGain(Byte_t *firstused, Float_t &sum,  Float_t &dsum,
+                                       Float_t &time, Float_t &dtime,
+                                       Byte_t &sat, const MPedestalPix &ped);
+
+public:
+
+  ClassDef(MExtractTimeAndCharge, 0)   // Time And Charge Extractor Base Class
+};
+
+#endif
+
+
+
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractTimeFastSpline.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractTimeFastSpline.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractTimeFastSpline.cc	(revision 9661)
@@ -0,0 +1,674 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analyzing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!   Author(s): Markus Gaug       05/2004 <mailto:markus@ifae.es> 
+!
+!   Copyright: MAGIC Software Development, 2002-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//   MExtractTimeFastSpline
+//
+//   Fast arrival Time extractor using a cubic spline algorithm of Numerical Recipes. 
+//   It returns the position of the half maximum between absolute maximum 
+//   and pedestal of the spline that interpolates the FADC slices.
+//
+//   The precision of the half-maximum searches can be chosen by:
+//   SetPrecision().
+//
+//   The precision of the maximum-finder is fixed to 0.025 FADC units.
+// 
+//////////////////////////////////////////////////////////////////////////////
+#include "MExtractTimeFastSpline.h"
+
+#include "MPedestalPix.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+
+ClassImp(MExtractTimeFastSpline);
+
+using namespace std;
+
+const Byte_t  MExtractTimeFastSpline::fgHiGainFirst  = 2;
+const Byte_t  MExtractTimeFastSpline::fgHiGainLast   = 14;
+const Byte_t  MExtractTimeFastSpline::fgLoGainFirst  = 3;
+const Byte_t  MExtractTimeFastSpline::fgLoGainLast   = 14;
+const Float_t MExtractTimeFastSpline::fgResolution   = 0.003;
+const Float_t MExtractTimeFastSpline::fgRiseTime     = 1.5;
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+// Calls: 
+// - SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast)
+// 
+// Initializes:
+// - fResolution to fgResolution
+//
+MExtractTimeFastSpline::MExtractTimeFastSpline(const char *name, const char *title) 
+    : fHiGainFirstDeriv(NULL), fLoGainFirstDeriv(NULL),
+      fHiGainSecondDeriv(NULL), fLoGainSecondDeriv(NULL)
+{
+
+  fName  = name  ? name  : "MExtractTimeFastSpline";
+  fTitle = title ? title : "Calculate photons arrival time using a fast spline";
+
+  SetResolution();
+  SetRiseTime  ();
+  SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast);
+
+}
+
+MExtractTimeFastSpline::~MExtractTimeFastSpline()
+{
+  
+  if (fHiGainFirstDeriv)
+    delete fHiGainFirstDeriv;
+  if (fLoGainFirstDeriv)
+    delete fLoGainFirstDeriv;
+  if (fHiGainSecondDeriv)
+    delete fHiGainSecondDeriv;
+  if (fLoGainSecondDeriv)
+    delete fLoGainSecondDeriv;
+  
+}
+
+
+// --------------------------------------------------------------------------
+//
+// SetRange: 
+//
+// Calls:
+// - MExtractor::SetRange(hifirst,hilast,lofirst,lolast);
+// - Deletes x, if not NULL
+// - Creates x according to the range
+//
+void MExtractTimeFastSpline::SetRange(Byte_t hifirst, Byte_t hilast, Byte_t lofirst, Byte_t lolast)
+{
+
+  MExtractor::SetRange(hifirst,hilast,lofirst,lolast);
+
+  if (fHiGainFirstDeriv)
+    delete fHiGainFirstDeriv;
+  if (fLoGainFirstDeriv)
+    delete fLoGainFirstDeriv;
+  if (fHiGainSecondDeriv)
+    delete fHiGainSecondDeriv;
+  if (fLoGainSecondDeriv)
+    delete fLoGainSecondDeriv;
+  
+  Int_t range = fHiGainLast - fHiGainFirst + 1;
+
+  if (range < 2)
+    {
+      *fLog << warn << GetDescriptor()
+            << Form("%s%2i%s%2i%s",": Hi-Gain Extraction range [",(int)fHiGainFirst,","
+                    ,fHiGainLast,"] too small, ") << endl;
+      *fLog << warn << GetDescriptor()
+            << " will move higher limit to obtain 4 slices " << endl;
+      SetRange(fHiGainFirst, fHiGainLast+4-range,fLoGainFirst,fLoGainLast);
+      range = fHiGainLast - fHiGainFirst + 1;
+    }
+  
+
+  fHiGainFirstDeriv = new Float_t[range];
+  memset(fHiGainFirstDeriv,0,range*sizeof(Float_t));
+  fHiGainSecondDeriv = new Float_t[range];
+  memset(fHiGainSecondDeriv,0,range*sizeof(Float_t));
+
+  range = fLoGainLast - fLoGainFirst + 1;
+
+  if (range >= 2)
+    {
+      
+      fLoGainFirstDeriv = new Float_t[range];
+      memset(fLoGainFirstDeriv,0,range*sizeof(Float_t));
+      fLoGainSecondDeriv = new Float_t[range];
+      memset(fLoGainSecondDeriv,0,range*sizeof(Float_t));
+
+    }
+
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Calculates the arrival time for each pixel 
+//
+void MExtractTimeFastSpline::FindTimeHiGain(Byte_t *first, Float_t &time, Float_t &dtime, 
+                                        Byte_t &sat, const MPedestalPix &ped) const
+{
+
+  const Int_t range = fHiGainLast - fHiGainFirst + 1;
+  const Byte_t *end = first + range;
+  Byte_t *p = first;
+  Byte_t max    = 0;
+  Byte_t maxpos = 0;
+
+  //
+  // Check for saturation in all other slices
+  //
+  while (++p<end)
+    {
+      if (*p > max)
+        {
+          max    = *p;
+          maxpos =  p-first;
+        }
+
+      if (*p >= fSaturationLimit)
+        {
+          sat++;
+          break;
+        }
+    }
+  
+  if (sat)
+    return;
+
+  if (maxpos < 2)
+    return;
+  
+  Float_t pp;
+
+  p = first;
+  fHiGainSecondDeriv[0] = 0.;
+  fHiGainFirstDeriv[0]  = 0.;
+
+  for (Int_t i=1;i<range-1;i++)
+    {
+      p++;
+      pp = fHiGainSecondDeriv[i-1] + 4.;
+      fHiGainSecondDeriv[i] = -1.0/pp;
+      fHiGainFirstDeriv [i] = *(p+1) - 2.* *(p) + *(p-1);
+      fHiGainFirstDeriv [i] = (6.0*fHiGainFirstDeriv[i]-fHiGainFirstDeriv[i-1])/pp;
+    }
+
+  fHiGainSecondDeriv[range-1] = 0.;
+
+  for (Int_t k=range-2;k>0;k--)
+    fHiGainSecondDeriv[k] = fHiGainSecondDeriv[k]*fHiGainSecondDeriv[k+1] + fHiGainFirstDeriv[k];
+  for (Int_t k=range-2;k>0;k--)
+    fHiGainSecondDeriv[k] /= 6.;
+  
+  //
+  // Now find the maximum  
+  //
+  Float_t step  = 0.2; // start with step size of 1ns and loop again with the smaller one
+  Float_t lower = (Float_t)maxpos-1.;
+  Float_t upper = (Float_t)maxpos;
+  Float_t x     = lower;
+  Float_t y     = 0.;
+  Float_t a     = 1.;
+  Float_t b     = 0.;
+  Int_t   klo = maxpos-1;
+  Int_t   khi = maxpos;
+  Float_t klocont = (Float_t)*(first+klo);
+  Float_t khicont = (Float_t)*(first+khi);
+  time          = upper;
+  Float_t abmax = khicont;
+
+  //
+  // Search for the maximum, starting in interval maxpos-1. If no maximum is found, go to 
+  // interval maxpos+1.
+  //
+  while (x<upper-0.3)
+    {
+      
+      x += step;
+      a -= step;
+      b += step;
+      
+      y = a*klocont
+        + b*khicont
+        + (a*a*a-a)*fHiGainSecondDeriv[klo] 
+        + (b*b*b-b)*fHiGainSecondDeriv[khi];
+      
+      if (y > abmax)
+        {
+          abmax  = y;
+          time   = x;
+        }
+    }
+  
+
+ if (time > upper-0.1)
+    {
+
+      upper = (Float_t)maxpos+1.;
+      lower = (Float_t)maxpos;
+      x     = lower;
+      a     = 1.;
+      b     = 0.;
+      khi   = maxpos+1;
+      klo   = maxpos;
+      klocont = (Float_t)*(first+klo);
+      khicont = (Float_t)*(first+khi);
+
+      while (x<upper-0.3)
+        {
+
+          x += step;
+          a -= step;
+          b += step;
+          
+          y = a* klocont
+            + b* khicont
+            + (a*a*a-a)*fHiGainSecondDeriv[klo] 
+            + (b*b*b-b)*fHiGainSecondDeriv[khi];
+          
+          if (y > abmax)
+            {
+              abmax  = y;
+              time   = x;
+            }
+        }
+  }
+ 
+  const Float_t up = time+step-0.055;
+  const Float_t lo = time-step+0.055;
+  const Float_t maxpossave = time;
+
+  x     = time;
+  a     = upper - x;
+  b     = x - lower;
+
+  step  = 0.04; // step size of 83 ps 
+
+  while (x<up)
+    {
+
+      x += step;
+      a -= step;
+      b += step;
+      
+      y = a* klocont
+        + b* khicont
+        + (a*a*a-a)*fHiGainSecondDeriv[klo] 
+        + (b*b*b-b)*fHiGainSecondDeriv[khi];
+      
+      if (y > abmax)
+        {
+          abmax  = y;
+          time   = x;
+        }
+      
+    }
+
+  if (time < klo + 0.02)
+    {
+      klo--;
+      khi--;
+      klocont = (Float_t)*(first+klo);
+      khicont = (Float_t)*(first+khi);
+      upper--;
+      lower--;
+    }
+  
+  x     = maxpossave;
+  a     = upper - x;
+  b     = x - lower;
+
+  while (x>lo)
+    {
+
+      x -= step;
+      a += step;
+      b -= step;
+      
+      y = a* klocont
+        + b* khicont
+        + (a*a*a-a)*fHiGainSecondDeriv[klo] 
+        + (b*b*b-b)*fHiGainSecondDeriv[khi];
+      
+      if (y > abmax)
+        {
+          abmax  = y;
+          time   = x;
+        }
+    }
+
+  const Float_t pedes   = ped.GetPedestal();
+  const Float_t halfmax = pedes + (abmax - pedes)/2.;
+
+  //
+  // Now, loop from the maximum bin leftward down in order to find the position of the half maximum.
+  // First, find the right FADC slice:
+  // 
+  klo   = maxpos;
+  while (klo > maxpos-fStartBeforeMax)
+    {
+      if (*(first+klo) < (Byte_t)halfmax)
+        break;
+      klo--;
+    }
+
+  //
+  // Loop from the beginning of the slice upwards to reach the halfmax:
+  // With means of bisection:
+  // 
+  x     = (Float_t)klo;
+  a     = 1.;
+  b     = 0.;
+  klocont = (Float_t)*(first+klo);
+  khicont = (Float_t)*(first+klo+1);
+  time  = x;
+
+  step = 0.5;
+  Bool_t back = kFALSE;
+
+  while (step > fResolution)
+    {
+      
+      if (back)
+        {
+          x -= step;
+          a += step;
+          b -= step;
+        }
+      else
+        {
+          x += step;
+          a -= step;
+          b += step;
+        }
+      
+      y = a*klocont
+        + b*khicont
+        + (a*a*a-a)*fHiGainSecondDeriv[klo] 
+        + (b*b*b-b)*fHiGainSecondDeriv[khi];
+
+      if (y >= halfmax)
+        back = kTRUE;
+      else
+        back = kFALSE;
+
+      step /= 2.;
+      
+    }
+
+  time  = (Float_t)fHiGainFirst + x;
+  dtime = fResolution;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Calculates the arrival time for each pixel 
+//
+void MExtractTimeFastSpline::FindTimeLoGain(Byte_t *first, Float_t &time, Float_t &dtime, 
+                                        Byte_t &sat, const MPedestalPix &ped) const
+{
+  
+  const Int_t range = fLoGainLast - fLoGainFirst + 1;
+  const Byte_t *end = first + range;
+  Byte_t *p = first;
+  Byte_t max    = 0;
+  Byte_t maxpos = 0;
+
+  //
+  // Check for saturation in all other slices
+  //
+  while (++p<end)
+    {
+      if (*p > max)
+        {
+          max    = *p;
+          maxpos =  p-first;
+        }
+
+      if (*p >= fSaturationLimit)
+        {
+          sat++;
+          break;
+        }
+    }
+  
+  if (sat)
+    return;
+
+  if (maxpos < 2)
+    return;
+  
+  Float_t pp;
+
+  p = first;
+  fLoGainSecondDeriv[0] = 0.;
+  fLoGainFirstDeriv[0]  = 0.;
+
+  for (Int_t i=1;i<range-1;i++)
+    {
+      p++;
+      pp = fLoGainSecondDeriv[i-1] + 4.;
+      fLoGainSecondDeriv[i] = -1.0/pp;
+      fLoGainFirstDeriv [i] = *(p+1) - 2.* *(p) + *(p-1);
+      fLoGainFirstDeriv [i] = (6.0*fLoGainFirstDeriv[i]-fLoGainFirstDeriv[i-1])/pp;
+    }
+
+  fLoGainSecondDeriv[range-1] = 0.;
+
+  for (Int_t k=range-2;k>0;k--)
+    fLoGainSecondDeriv[k] = fLoGainSecondDeriv[k]*fLoGainSecondDeriv[k+1] + fLoGainFirstDeriv[k];
+  for (Int_t k=range-2;k>0;k--)
+    fLoGainSecondDeriv[k] /= 6.;
+  
+  //
+  // Now find the maximum  
+  //
+  Float_t step  = 0.2; // start with step size of 1ns and loop again with the smaller one
+  Float_t lower = (Float_t)maxpos-1.;
+  Float_t upper = (Float_t)maxpos;
+  Float_t x     = lower;
+  Float_t y     = 0.;
+  Float_t a     = 1.;
+  Float_t b     = 0.;
+  Int_t   klo = maxpos-1;
+  Int_t   khi = maxpos;
+  Float_t klocont = (Float_t)*(first+klo);
+  Float_t khicont = (Float_t)*(first+khi);
+  time          = upper;
+  Float_t abmax = khicont;
+
+  //
+  // Search for the maximum, starting in interval maxpos-1. If no maximum is found, go to 
+  // interval maxpos+1.
+  //
+  while (x<upper-0.3)
+    {
+
+      x += step;
+      a -= step;
+      b += step;
+
+      y = a*klocont
+        + b*khicont
+        + (a*a*a-a)*fLoGainSecondDeriv[klo] 
+        + (b*b*b-b)*fLoGainSecondDeriv[khi];
+
+      if (y > abmax)
+        {
+          abmax  = y;
+          time   = x;
+        }
+
+    }
+
+ if (time > upper-0.1)
+    {
+
+      upper = (Float_t)maxpos+1.;
+      lower = (Float_t)maxpos;
+      x     = lower;
+      a     = 1.;
+      b     = 0.;
+      khi   = maxpos+1;
+      klo   = maxpos;
+      klocont = (Float_t)*(first+klo);
+      khicont = (Float_t)*(first+khi);
+
+      while (x<upper-0.3)
+        {
+
+          x += step;
+          a -= step;
+          b += step;
+          
+          y = a* klocont
+            + b* khicont
+            + (a*a*a-a)*fLoGainSecondDeriv[klo] 
+            + (b*b*b-b)*fLoGainSecondDeriv[khi];
+          
+          if (y > abmax)
+            {
+              abmax  = y;
+              time   = x;
+            }
+        }
+  }
+ 
+  const Float_t up = time+step-0.055;
+  const Float_t lo = time-step+0.055;
+  const Float_t maxpossave = time;
+
+  x     = time;
+  a     = upper - x;
+  b     = x - lower;
+
+  step  = 0.025; // step size of 165 ps 
+
+  while (x<up)
+    {
+
+      x += step;
+      a -= step;
+      b += step;
+      
+      y = a* klocont
+        + b* khicont
+        + (a*a*a-a)*fLoGainSecondDeriv[klo] 
+        + (b*b*b-b)*fLoGainSecondDeriv[khi];
+      
+      if (y > abmax)
+        {
+          abmax  = y;
+          time   = x;
+        }
+      
+    }
+
+  if (time < klo + 0.01)
+    {
+      klo--;
+      khi--;
+      klocont = (Float_t)*(first+klo);
+      khicont = (Float_t)*(first+khi);
+      upper--;
+      lower--;
+    }
+  
+  x     = maxpossave;
+  a     = upper - x;
+  b     = x - lower;
+
+  while (x>lo)
+    {
+
+      x -= step;
+      a += step;
+      b -= step;
+      
+      y = a* klocont
+        + b* khicont
+        + (a*a*a-a)*fLoGainSecondDeriv[klo] 
+        + (b*b*b-b)*fLoGainSecondDeriv[khi];
+      
+      if (y > abmax)
+        {
+          abmax  = y;
+          time   = x;
+        }
+      
+    }
+
+  const Float_t pedes   = ped.GetPedestal();
+  const Float_t halfmax = pedes + (abmax - pedes)/2.;
+
+  //
+  // Now, loop from the maximum bin leftward down in order to find the position of the half maximum.
+  // First, find the right FADC slice:
+  // 
+  klo   = maxpos;
+  while (klo > maxpos-4)
+    {
+      if (*(first+klo) < (Byte_t)halfmax)
+        break;
+      klo--;
+    }
+
+  //
+  // Loop from the beginning of the slice upwards to reach the halfmax:
+  // With means of bisection:
+  // 
+  x     = (Float_t)klo;
+  a     = 1.;
+  b     = 0.;
+  klocont = (Float_t)*(first+klo);
+  khicont = (Float_t)*(first+klo+1);
+  time  = x;
+
+  step = 0.5;
+  Bool_t back = kFALSE;
+
+  while (step > fResolution)
+    {
+      
+      if (back)
+        {
+          x -= step;
+          a += step;
+          b -= step;
+        }
+      else
+        {
+          x += step;
+          a -= step;
+          b += step;
+        }
+      
+      y = a*klocont
+        + b*khicont
+        + (a*a*a-a)*fLoGainSecondDeriv[klo] 
+        + (b*b*b-b)*fLoGainSecondDeriv[khi];
+
+      if (y >= halfmax)
+        back = kTRUE;
+      else
+        back = kFALSE;
+
+      step /= 2.;
+
+    }
+
+  time  = (Float_t)fLoGainFirst + x;
+  dtime = fResolution;
+}
+
+
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractTimeFastSpline.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractTimeFastSpline.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractTimeFastSpline.h	(revision 9661)
@@ -0,0 +1,46 @@
+#ifndef MARS_MExtractTimeFastSpline
+#define MARS_MExtractTimeFastSpline
+
+#ifndef MARS_MExtractTime
+#include "MExtractTime.h"
+#endif
+
+class MPedestalPix;
+class MExtractTimeFastSpline : public MExtractTime
+{
+
+  static const Byte_t  fgHiGainFirst;    // Default for fHiGainFirst  (now set to: 2)
+  static const Byte_t  fgHiGainLast;     // Default for fHiGainLast   (now set to: 14)
+  static const Byte_t  fgLoGainFirst;    // Default for fLOGainFirst  (now set to: 3)
+  static const Byte_t  fgLoGainLast;     // Default for fLoGainLast   (now set to: 14)
+  static const Float_t fgResolution;     // Default for fResolution   (now set to: 0.003)
+  static const Float_t fgRiseTime  ;     // Default for fRiseTime     (now set to: 1.5  C  
+
+  Float_t *fHiGainFirstDeriv;
+  Float_t *fLoGainFirstDeriv;  
+  Float_t *fHiGainSecondDeriv;
+  Float_t *fLoGainSecondDeriv;  
+
+  Float_t fResolution;                        // The time resolution in FADC units
+  Float_t fRiseTime  ;                        // The rise time of the pulse 
+  Byte_t  fStartBeforeMax;                    // Slices to start searching for the halfmax before max
+  
+  void FindTimeHiGain(Byte_t *first, Float_t &time, Float_t &dtime, Byte_t &sat, const MPedestalPix &ped) const;
+  void FindTimeLoGain(Byte_t *first, Float_t &time, Float_t &dtime, Byte_t &sat, const MPedestalPix &ped) const;
+  
+public:
+
+  MExtractTimeFastSpline(const char *name=NULL, const char *title=NULL);
+  ~MExtractTimeFastSpline();
+    
+  void SetRange(Byte_t hifirst=0, Byte_t hilast=0, Byte_t lofirst=0, Byte_t lolast=0);      
+  void SetResolution(Float_t f=fgResolution)     { fResolution = f;  }
+  void SetRiseTime  (Float_t f=fgRiseTime  )     { fRiseTime   = f; fStartBeforeMax = (Int_t)(2*fRiseTime); }  
+  
+  ClassDef(MExtractTimeFastSpline, 0)   // Task to Extract the Arrival Times using a Fast Spline
+};
+
+#endif
+
+
+
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractTimeHighestIntegral.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractTimeHighestIntegral.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractTimeHighestIntegral.cc	(revision 9661)
@@ -0,0 +1,298 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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, 02/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!              Hendrik Bartko, 02/2004 <mailto:hbartko@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//   MExtractTimeHighestIntegral
+//
+//  Calculates the arrival time as the mean time of the fWindowSize time slices
+//  which have the highest integral content.
+//
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MExtractTimeHighestIntegral.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+#include "MPedestalPix.h"
+
+ClassImp(MExtractTimeHighestIntegral);
+
+using namespace std;
+
+const Byte_t MExtractTimeHighestIntegral::fgHiGainFirst  =  0;
+const Byte_t MExtractTimeHighestIntegral::fgHiGainLast   = 14;
+const Byte_t MExtractTimeHighestIntegral::fgLoGainFirst  =  3;
+const Byte_t MExtractTimeHighestIntegral::fgLoGainLast   = 14;
+const Byte_t MExtractTimeHighestIntegral::fgHiGainWindowSize = 6;
+const Byte_t MExtractTimeHighestIntegral::fgLoGainWindowSize = 6;
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+// Calls: 
+// - SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast)
+//
+MExtractTimeHighestIntegral::MExtractTimeHighestIntegral(const char *name, const char *title)
+    : fHiGainWindowSize(fgHiGainWindowSize), 
+      fLoGainWindowSize(fgLoGainWindowSize)
+{
+
+  fName  = name  ? name  : "MExtractTimeHighestIntegral";
+  fTitle = title ? title : "Task to extract the signal from the FADC slices";
+  
+  SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast);
+}
+
+// --------------------------------------------------------------------------
+//
+// SetRange: 
+//
+// Calls:
+// - MExtractor::SetRange(hifirst,hilast,lofirst,lolast);
+//
+void MExtractTimeHighestIntegral::SetRange(Byte_t hifirst, Byte_t hilast, Byte_t lofirst, Byte_t lolast)
+{
+  
+  MExtractor::SetRange(hifirst,hilast,lofirst,lolast);
+
+
+  Int_t range = fHiGainLast - fHiGainFirst + 1;
+  
+  if (range < 2)
+    {
+      *fLog << warn << GetDescriptor()
+            << Form("%s%2i%s%2i%s",": Hi-Gain Extraction range [",(int)fHiGainFirst,","
+                    ,fHiGainLast,"] too small, ") << endl;
+      *fLog << warn << GetDescriptor()
+            << " will move higher limit to obtain 4 slices " << endl;
+      SetRange(fHiGainFirst, fHiGainLast+4-range,fLoGainFirst,fLoGainLast);
+    }
+  
+  range = fLoGainLast - fLoGainFirst + 1;
+
+  if (range < 2)
+    {
+      *fLog << warn << GetDescriptor()
+            << Form("%s%2i%s%2i%s",": Lo-Gain Extraction range [",(int)fLoGainFirst,","
+                    ,fLoGainLast,"] too small, ") << endl;
+      *fLog << warn << GetDescriptor()
+            << " will move logher limit to obtain 4 slices " << endl;
+      SetRange(fHiGainFirst, fHiGainLast,fLoGainFirst,fLoGainLast+4-range);
+    }
+
+
+  SetWindowSize(fHiGainWindowSize,fLoGainWindowSize);
+
+  fNumHiGainSamples = fHiGainLast-fHiGainFirst+1;
+  fNumLoGainSamples = fLoGainLast-fLoGainFirst+1;
+  
+}
+
+// --------------------------------------------------------------------------
+//
+// Checks:
+// - if a window is odd, subtract one
+// - if a window is bigger than the one defined by the ranges, set it to the available range
+// - if a window is smaller than 2, set it to 2
+// 
+void MExtractTimeHighestIntegral::SetWindowSize(Byte_t windowh, Byte_t windowl)
+{
+
+  fHiGainWindowSize = windowh & ~1;
+  fLoGainWindowSize = windowl & ~1;
+
+  if (fHiGainWindowSize != windowh)
+    *fLog << warn << GetDescriptor() << ": Hi Gain window size has to be even, set to: " 
+          << int(fHiGainWindowSize) << " samples " << endl;
+  
+  if (fLoGainWindowSize != windowl)
+    *fLog << warn << GetDescriptor() << ": Lo Gain window size has to be even, set to: " 
+          << int(fLoGainWindowSize) << " samples " << endl;
+    
+  const Byte_t availhirange = (fHiGainLast-fHiGainFirst+1) & ~1;
+  const Byte_t availlorange = (fLoGainLast-fLoGainFirst+1) & ~1;
+
+  if (fHiGainWindowSize > availhirange)
+    {
+      *fLog << warn << GetDescriptor() 
+            << Form("%s%2i%s%2i%s%2i%s",": Hi Gain window size: ",(int)fHiGainWindowSize,
+                    " is bigger than available range: [",(int)fHiGainFirst,",",(int)fHiGainLast,"]") << endl;
+      *fLog << warn << GetDescriptor() 
+            << ": Will set window size to: " << (int)availhirange << endl;
+      fHiGainWindowSize = availhirange;
+    }
+  
+  if (fLoGainWindowSize > availlorange)
+    {
+      *fLog << warn << GetDescriptor() 
+            << Form("%s%2i%s%2i%s%2i%s",": Lo Gain window size: ",(int)fLoGainWindowSize,
+                    " is bigger than available range: [",(int)fLoGainFirst,",",(int)fLoGainLast,"]") << endl;
+      *fLog << warn << GetDescriptor() 
+            << ": Will set window size to: " << (int)availlorange << endl;
+      fLoGainWindowSize= availlorange;
+    }
+
+  fHiGainWindowSizeSqrt = TMath::Sqrt((Float_t)fHiGainWindowSize);
+  fLoGainWindowSizeSqrt = TMath::Sqrt((Float_t)fLoGainWindowSize);
+}
+
+
+void MExtractTimeHighestIntegral::FindTimeHiGain(Byte_t *ptr, Float_t &time, Float_t &deltatime, Byte_t &sat, const MPedestalPix &ped) const
+{
+
+  const Byte_t *end = ptr + fHiGainLast - fHiGainFirst +1 ;
+
+  Int_t sum=0;    // integral content of the actual window
+  Int_t max = 0;  // highest integral content of all windows
+  
+  //
+  // Calculate the sum of the first fWindowSize slices
+  //
+  sat = 0;
+  Byte_t *p = ptr;
+  
+  while (p<ptr+fHiGainWindowSize)
+    {
+      sum += *p;
+      if (*p++ >= fSaturationLimit)
+        sat++;
+    }
+  
+  //
+  // Check for saturation in all other slices
+  //
+  while (p<end)
+    if (*p++ >= fSaturationLimit)
+      sat++;
+  
+  //
+  // Calculate the i-th sum as
+  //    sum_i+1 = sum_i + slice[i+8] - slice[i]
+  // This is fast and accurate (because we are using int's)
+  //
+  max=sum;
+  Byte_t *ptrmax=ptr;  // pointer to the first slice of the maximum window
+  
+  for (p=ptr; p+fHiGainWindowSize<end; p++)
+    {
+      sum += *(p+fHiGainWindowSize) - *p;
+      
+      if (sum>max)
+	{
+	  max = sum;
+	  ptrmax = p+1;
+	}
+    }
+  
+  // now calculate the time for the maximum window
+  Int_t timesignalsum = 0;
+  Int_t timesquaredsum =0;
+  Int_t timesum =0;
+  
+  for (p=ptrmax; p < ptrmax + fHiGainWindowSize; p++)
+    {
+      timesignalsum += *p*(p-ptr);
+      timesum += p-ptr;
+      timesquaredsum  += (p-ptr)*(p-ptr);
+    }
+  
+  const Float_t pedes  = ped.GetPedestal();
+  const Float_t pedrms = ped.GetPedestalRms();
+  const Float_t pedsubsum = max - fHiGainWindowSize*pedes;
+  const Float_t pedsubtimesignalsum = timesignalsum - timesum*pedes;
+
+  time      = pedsubsum != 0 ? pedsubtimesignalsum / pedsubsum  + Float_t(fHiGainFirst): 1;
+  deltatime = pedsubsum != 0 ? pedrms / pedsubsum * sqrt(timesquaredsum - fHiGainWindowSize*time) : 1;
+}
+
+void MExtractTimeHighestIntegral::FindTimeLoGain(Byte_t *ptr, Float_t &time, Float_t &deltatime, Byte_t &sat, const MPedestalPix &ped) const
+{
+
+  const Byte_t *end = ptr + fLoGainLast - fLoGainFirst +1 ;
+
+  Int_t sum=0;    // integral content of the actual window
+  Int_t max = 0;  // highest integral content of all windows
+  
+  //
+  // Calculate the sum of the first fWindowSize slices
+  //
+  sat = 0;
+  Byte_t *p = ptr;
+  
+  while (p<ptr+fLoGainWindowSize)
+    {
+      sum += *p;
+      if (*p++ >= fSaturationLimit)
+        sat++;
+    }
+  
+  //
+  // Check for saturation in all other slices
+  //
+  while (p<end)
+    if (*p++ >= fSaturationLimit)
+      sat++;
+  
+  //
+  // Calculate the i-th sum as
+  //    sum_i+1 = sum_i + slice[i+8] - slice[i]
+  // This is fast and accurate (because we are using int's)
+  //
+  max=sum;
+  Byte_t *ptrmax=ptr;  // pointer to the first slice of the maximum window
+  
+  for (p=ptr; p+fLoGainWindowSize<end; p++)
+    {
+      sum += *(p+fLoGainWindowSize) - *p;
+      
+      if (sum>max)
+	{
+	  max = sum;
+	  ptrmax = p+1;
+	}
+    }
+  
+  // now calculate the time for the maximum window
+  Int_t timesignalsum = 0;
+  Int_t timesquaredsum =0;
+  Int_t timesum =0;
+  
+  for (p=ptrmax; p < ptrmax + fLoGainWindowSize; p++)
+    {
+      timesignalsum += *p*(p-ptr);
+      timesum += p-ptr;
+      timesquaredsum  += (p-ptr)*(p-ptr);
+    }
+  
+  const Float_t pedes  = ped.GetPedestal();
+  const Float_t pedrms = ped.GetPedestalRms();
+  const Float_t pedsubsum = max - fLoGainWindowSize*pedes;
+  const Float_t pedsubtimesignalsum = timesignalsum - timesum*pedes;
+
+  time      = pedsubsum != 0 ? pedsubtimesignalsum / pedsubsum  + Float_t(fLoGainFirst) : 1;
+  deltatime = pedsubsum != 0 ? pedrms / pedsubsum * sqrt(timesquaredsum - fLoGainWindowSize*time) : 1;
+}
+
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractTimeHighestIntegral.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractTimeHighestIntegral.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractTimeHighestIntegral.h	(revision 9661)
@@ -0,0 +1,39 @@
+#ifndef MARS_MExtractTimeHighestIntegral
+#define MARS_MExtractTimeHighestIntegral
+
+#ifndef MARS_MExtractTime
+#include "MExtractTime.h"
+#endif
+
+class MExtractTimeHighestIntegral : public MExtractTime
+{
+private:
+
+  static const Byte_t fgHiGainFirst;
+  static const Byte_t fgHiGainLast;
+  static const Byte_t fgLoGainFirst;
+  static const Byte_t fgLoGainLast;
+  static const Byte_t fgHiGainWindowSize;
+  static const Byte_t fgLoGainWindowSize;
+
+  Byte_t  fHiGainWindowSize;            // Number of gains in window
+  Float_t fHiGainWindowSizeSqrt;        // Sqaure root of number of gains in window
+  Byte_t  fLoGainWindowSize;            // Number of gains in window
+  Float_t fLoGainWindowSizeSqrt;        // Sqaure root of number of gains in window
+
+  void FindTimeHiGain(Byte_t *first, Float_t &time, Float_t &dtime, Byte_t &sat, const MPedestalPix &ped) const;
+  void FindTimeLoGain(Byte_t *first, Float_t &time, Float_t &dtime, Byte_t &sat, const MPedestalPix &ped) const;
+  
+public:
+  MExtractTimeHighestIntegral(const char *name=NULL, const char *title=NULL);
+
+  void SetRange(Byte_t hifirst=0, Byte_t hilast=0, Byte_t lofirst=0, Byte_t lolast=0);        
+  void SetWindowSize(Byte_t windowh=fgHiGainWindowSize,
+                     Byte_t windowl=fgLoGainWindowSize);
+
+  ClassDef(MExtractTimeHighestIntegral, 0) // Task to Extract the Arrival Times As the mean time of the fWindowSize time slices
+};
+
+#endif
+
+
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractTimeSpline.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractTimeSpline.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractTimeSpline.cc	(revision 9661)
@@ -0,0 +1,203 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analyzing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!   Author(s): Sebastian Raducci 12/2003 <mailto:raducci@fisica.uniud.it>
+!              Markus Gaug       04/2004 <mailto:markus@ifae.es> 
+!
+!   Copyright: MAGIC Software Development, 2002-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//   MExtractTimeSpline
+//
+//   This is a task that calculates the arrival times of photons. 
+//   It returns the absolute maximum of the spline that interpolates
+//   the FADC slices 
+//
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MExtractTimeSpline.h"
+#include "MCubicSpline.h"
+
+#include "MGeomCam.h"
+#include "MPedestalPix.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+
+ClassImp(MExtractTimeSpline);
+
+using namespace std;
+
+const Byte_t MExtractTimeSpline::fgHiGainFirst  = 0;
+const Byte_t MExtractTimeSpline::fgHiGainLast   = 14;
+const Byte_t MExtractTimeSpline::fgLoGainFirst  = 3;
+const Byte_t MExtractTimeSpline::fgLoGainLast   = 14;
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+// Calls: 
+// - SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast)
+//
+MExtractTimeSpline::MExtractTimeSpline(const char *name, const char *title) 
+    : fXHiGain(NULL), fXLoGain(NULL)
+{
+
+  fName  = name  ? name  : "MExtractTimeSpline";
+  fTitle = title ? title : "Calculate photons arrival time using a spline";
+    
+  SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast);
+
+}
+
+MExtractTimeSpline::~MExtractTimeSpline()
+{
+  
+  if (fXHiGain)
+    delete fXHiGain;
+  if (fXLoGain)
+    delete fXLoGain;
+  
+}
+
+
+// --------------------------------------------------------------------------
+//
+// SetRange: 
+//
+// Calls:
+// - MExtractor::SetRange(hifirst,hilast,lofirst,lolast);
+// - Deletes x, if not NULL
+// - Creates x according to the range
+//
+void MExtractTimeSpline::SetRange(Byte_t hifirst, Byte_t hilast, Byte_t lofirst, Byte_t lolast)
+{
+
+  MExtractor::SetRange(hifirst,hilast,lofirst,lolast);
+
+  if (fXHiGain)
+    delete fXHiGain;
+
+  if (fXLoGain)
+    delete fXLoGain;
+  
+  Int_t range = fHiGainLast - fHiGainFirst + 1;
+
+  if (range < 2)
+    {
+      *fLog << warn << GetDescriptor()
+            << Form("%s%2i%s%2i%s",": Hi-Gain Extraction range [",(int)fHiGainFirst,","
+                    ,fHiGainLast,"] too small, ") << endl;
+      *fLog << warn << GetDescriptor()
+            << " will move higher limit to obtain 4 slices " << endl;
+      SetRange(fHiGainFirst, fHiGainLast+4-range,fLoGainFirst,fLoGainLast);
+      range = fHiGainLast - fHiGainFirst + 1;
+    }
+  
+  fXHiGain = new Byte_t[range+1];
+  for (Int_t i=0; i<range+1; i++)
+    fXHiGain[i] = i;
+  
+  range = fLoGainLast - fLoGainFirst + 1;
+
+  if (range >= 2)
+    {
+      
+      fXLoGain = new Byte_t[range+1];
+      for (Int_t i=0; i<range+1; i++)
+        fXLoGain[i] = i;
+    }
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Calculates the arrival time for each pixel 
+//
+void MExtractTimeSpline::FindTimeHiGain(Byte_t *first, Float_t &time, Float_t &dtime, 
+                                        Byte_t &sat, const MPedestalPix &ped) const
+{
+  
+  const Int_t range = fHiGainLast - fHiGainFirst + 1;
+  const Byte_t *end = first + range;
+  Byte_t *p = first;
+
+  //
+  // Check for saturation in all other slices
+  //
+  while (p<end)
+    if (*p++ >= fSaturationLimit)
+      sat++;
+
+  //
+  // Initialize the spline
+  //
+  MCubicSpline spline(first,fXHiGain,kTRUE,range,0.0,0.0);  
+
+  //
+  // Now find the maximum  
+  //
+  Double_t abMaximum = spline.EvalAbMax();
+  Double_t maximum = spline.EvalMax();
+  const Double_t pedestal = ped.GetPedestal();
+  const Double_t halfMax = (maximum + pedestal)/2.;
+  time = (halfMax > pedestal) ? (Float_t ) spline.FindVal(halfMax,abMaximum,'l') + (Float_t)fHiGainFirst : 0.0;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculates the arrival time for each pixel 
+//
+void MExtractTimeSpline::FindTimeLoGain(Byte_t *first, Float_t &time, Float_t &dtime, 
+                                        Byte_t &sat, const MPedestalPix &ped) const
+{
+  
+  const Int_t range = fLoGainLast - fLoGainFirst + 1;
+
+  if (range < 2)
+    return;
+
+  const Byte_t *end = first + range;
+  Byte_t *p = first;
+
+  //
+  // Check for saturation in all other slices
+  //
+  while (p<end)
+    if (*p++ >= fSaturationLimit)
+      sat++;
+
+  //
+  // Initialize the spline
+  //
+  MCubicSpline spline(first,fXLoGain,kTRUE,range,0.0,0.0);  
+
+  //
+  // Now find the maximum  
+  //
+  Double_t abMaximum = spline.EvalAbMax();
+  Double_t maximum = spline.EvalMax();
+  const Double_t pedestal = ped.GetPedestal();
+  const Double_t halfMax = (maximum + pedestal)/2.;
+
+  time = (halfMax > pedestal) ? (Float_t )spline.FindVal(halfMax,abMaximum,'l') + (Float_t)fLoGainFirst : 0.0;
+}
+
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractTimeSpline.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractTimeSpline.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractTimeSpline.h	(revision 9661)
@@ -0,0 +1,36 @@
+#ifndef MARS_MExtractTimeSpline
+#define MARS_MExtractTimeSpline
+
+#ifndef MARS_MExtractTime
+#include "MExtractTime.h"
+#endif
+
+class MPedestalPix;
+class MExtractTimeSpline : public MExtractTime
+{
+
+  static const Byte_t fgHiGainFirst;
+  static const Byte_t fgHiGainLast;
+  static const Byte_t fgLoGainFirst;
+  static const Byte_t fgLoGainLast;
+
+  Byte_t *fXHiGain;
+  Byte_t *fXLoGain;  
+  
+  void FindTimeHiGain(Byte_t *first, Float_t &time, Float_t &dtime, Byte_t &sat, const MPedestalPix &ped) const;
+  void FindTimeLoGain(Byte_t *first, Float_t &time, Float_t &dtime, Byte_t &sat, const MPedestalPix &ped) const;
+  
+public:
+
+  MExtractTimeSpline(const char *name=NULL, const char *title=NULL);
+  ~MExtractTimeSpline();
+    
+  void SetRange(Byte_t hifirst=0, Byte_t hilast=0, Byte_t lofirst=0, Byte_t lolast=0);      
+  
+  ClassDef(MExtractTimeSpline, 0)   // Task to Extract the Arrival Times using a Spline
+};
+
+#endif
+
+
+
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractedSignalBlindPixel.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractedSignalBlindPixel.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractedSignalBlindPixel.cc	(revision 9661)
@@ -0,0 +1,143 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug  02/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MExtractedSignalBlindPixel
+//
+// The storage container of the extracted signal of the calibration Blind Pixel(s). 
+// Additionally, the number of saturated Slices are stored. 
+// There is place for various blind pixels set into the camera in  July. Default 
+// is one blind pixel.
+//
+// Default values for the extracted signals are: gkSignalInitializer
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MExtractedSignalBlindPixel.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MExtractedSignalBlindPixel);
+
+using namespace std;
+
+const Int_t MExtractedSignalBlindPixel::gkSignalInitializer = 99999;
+// ------------------------------------------------------------------------
+//
+//
+// Sets:
+// - the dimenstion of fBlindPixelIdx to 1
+// - the dimenstion of fExtractedSignal to 1
+// - the dimenstion of fNumSaturated to 1
+// - the dimenstion of fPed. to 1;      
+// - the dimenstion of fPedErr. to 1;
+// - the dimenstion of fPedRms. to 1;   
+// - the dimenstion of fPedRmsErr. to 1;
+//
+// Calls:
+// - Clear()
+//
+MExtractedSignalBlindPixel::MExtractedSignalBlindPixel(const char* name, const char* title)
+{
+
+  fName  = name  ? name  : "MExtractedSignalBlindPixel";
+  fTitle = title ? title : "Container of the Extracted Signals";
+
+  fBlindPixelIdx.Set(1);
+  fExtractedSignal.Set(1);
+  fNumSaturated.Set(1);
+
+  fPed.Set(1);      
+  fPedErr.Set(1);   
+  fPedRms.Set(1);   
+  fPedRmsErr.Set(1);
+
+  Clear();
+}
+
+// ------------------------------------------------------------------------
+//
+// Set values of:
+// - fNumSaturated   
+// - fExtractedSignal
+// to gkSignalInitializer
+//
+void MExtractedSignalBlindPixel::Clear(Option_t *o)
+{
+
+  for (Int_t i=0;i<fBlindPixelIdx.GetSize();i++)
+    {
+      fNumSaturated   .AddAt(gkSignalInitializer,i);
+      fExtractedSignal.AddAt(gkSignalInitializer,i);
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// Set number num of used FADC slices, starting from (including) first 
+//
+void MExtractedSignalBlindPixel::SetUsedFADCSlices(const Byte_t first, const Byte_t num)   
+{
+  fFirst          = first; 
+  fNumFADCSamples = num;
+}
+
+// --------------------------------------------------------------------------------------------
+//
+// Returns true, if fExtractedSignal is greater or equal 0 and smaller than gkSignalInitializer
+//
+Bool_t MExtractedSignalBlindPixel::IsValid( const Int_t i ) const
+{
+    return fExtractedSignal.At(i) >= 0 && fExtractedSignal.At(i) <  gkSignalInitializer;
+}
+
+// --------------------------------------------------------------------------------------------
+//
+// Prints for all stored blind pixels the ID, the signal and the number of saturated slices
+//
+void MExtractedSignalBlindPixel::Print(Option_t *o) const
+{
+
+  for (Int_t i=0;i<fBlindPixelIdx.GetSize();i++)
+    {
+      
+      *fLog << "Blind Pixel ID: " << fBlindPixelIdx.At(i)
+            << ": Signal: " << fExtractedSignal.At(i)
+            << " Saturated Slices: " <<  fNumSaturated.At(i)
+            << endl;
+    }
+}
+
+// ------------------------------------------------------------------------------------
+//
+// Returns true if the extraction type. Available are: kAmplitude, kIntegral and kFilter
+// The flags kIntegral and kFilter may be set both. 
+//
+Bool_t MExtractedSignalBlindPixel::IsExtractionType( const MExtractBlindPixel::ExtractionType_t typ )
+{
+  
+  return TESTBIT( fExtractionType, typ );
+
+}
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractedSignalBlindPixel.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractedSignalBlindPixel.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractedSignalBlindPixel.h	(revision 9661)
@@ -0,0 +1,106 @@
+#ifndef MARS_MExtractedSignalBlindPixel
+#define MARS_MExtractedSignalBlindPixel
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#ifndef ROOT_TArrayI
+#include <TArrayI.h>
+#endif
+
+#ifndef ROOT_TArrayF
+#include <TArrayF.h>
+#endif
+
+#ifndef MARS_MExtractBlindPixel
+#include <MExtractBlindPixel.h>
+#endif
+
+class MExtractedSignalBlindPixel : public MParContainer
+{
+private:
+
+  static const Int_t gkSignalInitializer; //! Initializer for variables
+
+  TArrayI fBlindPixelIdx;                 // Array Blind Pixel IDs
+  TArrayF fExtractedSignal;               // Array Extracted signals per Blind Pixel ID
+  TArrayI fNumSaturated;                  // Array Number of saturated slices per Blind Pixel ID 
+  					  
+  TArrayF fPed;                           // Array Pedestal per Blind Pixel IDs                               
+  TArrayF fPedErr;                        // Array Pedestal Error per Blind Pixel ID          
+  TArrayF fPedRms;                        // Array Pedestal RMS per Blind Pixel ID 
+  TArrayF fPedRmsErr;                     // Array Pedestal RMS Error per Blind Pixel ID 
+					  
+  Byte_t  fFirst;                         // First FADC extraction slice
+  Byte_t  fNumFADCSamples;                // Number of summed FADC slices
+  Byte_t  fExtractionType;                // What extraction type has been chosen?
+  
+public:
+
+  MExtractedSignalBlindPixel(const char* name=NULL, const char* title=NULL);
+
+  void Clear(Option_t *o="");
+  void Print(Option_t *o="") const;
+  
+  // Getters
+  Int_t   GetBlindPixelIdx   ( const Int_t i=0 )  const { return fBlindPixelIdx.At(i)    ; }  
+  Float_t GetExtractedSignal ( const Int_t i=0 )  const { return fExtractedSignal.At(i)  ; }
+  Int_t   GetNumBlindPixels  ()                   const { return fBlindPixelIdx.GetSize(); }
+  Int_t   GetNumSaturated    ( const Int_t i=0 )  const { return fNumSaturated.At(i)     ; }
+  Byte_t  GetNumFADCSamples  ()                   const { return fNumFADCSamples         ; }
+
+  Float_t GetPed             ( const Int_t i=0 )  const { return fPed.At(i)              ; }
+  Float_t GetPedErr          ( const Int_t i=0 )  const { return fPedErr.At(i)           ; }
+  Float_t GetPedRms          ( const Int_t i=0 )  const { return fPedRms.At(i)           ; }
+  Float_t GetPedRmsErr       ( const Int_t i=0 )  const { return fPedRmsErr.At(i)        ; }
+
+  Bool_t  IsExtractionType   ( const MExtractBlindPixel::ExtractionType_t typ );
+  Bool_t  IsValid            ( const Int_t i=0 )  const;   
+
+  // Setter
+  void SetExtractionType( const Byte_t b=0 )            { fExtractionType  = b           ; }
+  void SetNumFADCSamples( const Byte_t num )            { fNumFADCSamples  = num         ; }    
+  void SetUsedFADCSlices( const Byte_t first, const Byte_t num );
+
+  void SetBlindPixelIdx  ( const Int_t i,   const Int_t nr=0)      {
+    if (nr>fBlindPixelIdx.GetSize()-1)
+      fBlindPixelIdx.Set(nr+1);
+    fBlindPixelIdx.AddAt(i,nr); }
+  void SetExtractedSignal( const Float_t f, const Int_t nr=0 )     {
+    if (nr>fExtractedSignal.GetSize()-1)
+      fExtractedSignal.Set(nr+1);
+    fExtractedSignal.AddAt(f,nr); }
+  void SetNumSaturated   ( const Int_t i,   const Int_t nr=0 )     {
+    if (nr>fNumSaturated.GetSize()-1)
+      fNumSaturated.Set(nr+1);
+    fNumSaturated.AddAt(i,nr); }
+  void SetPed            ( const Float_t f, const Int_t nr=0 )     {
+    if (nr>fPed.GetSize()-1)
+      fPed.Set(nr+1);
+    fPed.AddAt(f,nr); }
+  void SetPedErr         ( const Float_t f, const Int_t nr=0 )     {
+    if (nr>fPedErr.GetSize()-1)
+      fPedErr.Set(nr+1);
+    fPedErr.AddAt(f,nr); }
+  void SetPedRms         ( const Float_t f, const Int_t nr=0 )     {
+    if (nr>fPedRms.GetSize()-1)
+      fPedRms.Set(nr+1);
+    fPedRms.AddAt(f,nr); }
+  void SetPedRmsErr      ( const Float_t f, const Int_t nr=0 )     {
+    if (nr>fPedRmsErr.GetSize()-1)
+      fPedRmsErr.Set(nr+1);
+    fPedRmsErr.AddAt(f,nr); }
+
+  ClassDef(MExtractedSignalBlindPixel, 3)	// Storage Container for extracted signal of Blind Pixel
+};
+
+#endif
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractedSignalCam.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractedSignalCam.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractedSignalCam.cc	(revision 9661)
@@ -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): Markus Gaug  12/2003 <mailto:markus@ifae.es>
+!   Author(s): Thomas Bretz 12/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MExtractedSignalCam
+//
+// Hold the Extracted Signal information for all pixels in the camera
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MExtractedSignalCam.h"
+
+#include <TClonesArray.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MExtractedSignalPix.h"
+
+ClassImp(MExtractedSignalCam);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. Creates a MExtractedSignalPix object for each pixel
+//
+MExtractedSignalCam::MExtractedSignalCam(const char *name, const char *title)
+    : fFirstUsedSliceHiGain(0), fFirstUsedSliceLoGain(0),
+      fLastUsedSliceHiGain(0), fLastUsedSliceLoGain(0), 
+      fUsedWindowHiGain(0.), fUsedWindowLoGain(0.)
+{
+    fName  = name  ? name  : "MExtractedSignalCam";
+    fTitle = title ? title : "Storage container for all Extracted Signal Information in the camera";
+
+    fArray = new TClonesArray("MExtractedSignalPix", 1);
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the array conatining the pixel pedest information
+//
+MExtractedSignalCam::~MExtractedSignalCam()
+{
+    delete fArray;
+}
+
+// --------------------------------------------------------------------------
+//
+// Distribute logging stream to all childs
+//
+void MExtractedSignalCam::SetLogStream(MLog *lg)
+{
+    fArray->ForEach(MParContainer, SetLogStream)(lg);
+    MParContainer::SetLogStream(lg);
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the size of the camera
+//
+void MExtractedSignalCam::InitSize(const UInt_t i)
+{
+    fArray->ExpandCreate(i);
+}
+
+// --------------------------------------------------------------------------
+//
+// Get the size of the MExtractedSignalCam
+//
+Int_t MExtractedSignalCam::GetSize() const
+{
+    return fArray->GetEntriesFast();
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th pixel (pixel index)
+//
+MExtractedSignalPix &MExtractedSignalCam::operator[](Int_t i)
+{
+    return *static_cast<MExtractedSignalPix*>(fArray->UncheckedAt(i));
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th pixel (pixel index)
+//
+const MExtractedSignalPix &MExtractedSignalCam::operator[](Int_t i) const
+{
+    return *static_cast<MExtractedSignalPix*>(fArray->UncheckedAt(i));
+}
+
+void MExtractedSignalCam::Clear(Option_t *o)
+{
+    fArray->ForEach(TObject, Clear)();
+}
+
+void MExtractedSignalCam::Print(Option_t *o) const
+{
+    *fLog << all << GetDescriptor() << ":" << endl;
+    int idx = -1;
+
+    TIter Next(fArray);
+    MExtractedSignalPix *pix;
+    while ((pix=(MExtractedSignalPix*)Next()))
+    {
+        idx++;
+
+        if (!pix->IsValid())
+            continue;
+
+        *fLog << idx << ": ";
+	pix->Print();
+    }
+}
+
+Bool_t MExtractedSignalCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
+{
+    switch (type)
+    {
+    case 0:
+        val = (*this)[idx].GetExtractedSignalHiGain();
+        break;
+    case 1:
+        val = (*this)[idx].GetExtractedSignalHiGainError();
+        break;
+    case 2:
+        val = (*this)[idx].GetExtractedSignalLoGain();
+        break;
+    case 3:
+        val = (*this)[idx].GetExtractedSignalLoGainError();
+        break;
+    default:
+	return kFALSE;
+    }
+    return val>=0;
+}
+
+void MExtractedSignalCam::DrawPixelContent(Int_t num) const
+{
+    *fLog << warn << "MExtractedSignaCam::DrawPixelContent - not available." << endl;
+}
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractedSignalCam.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractedSignalCam.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractedSignalCam.h	(revision 9661)
@@ -0,0 +1,71 @@
+#ifndef MARS_MExtractedSignalCam
+#define MARS_MExtractedSignalCam
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#ifndef MARS_MCamEvent
+#include "MCamEvent.h"
+#endif
+
+class TClonesArray;
+class MExtractedSignalPix;
+
+class MExtractedSignalCam : public MParContainer, public MCamEvent
+{
+private:
+    TClonesArray *fArray; //-> FIXME: Change TClonesArray away from a pointer?
+
+    Byte_t fFirstUsedSliceHiGain;
+    Byte_t fFirstUsedSliceLoGain;
+
+    Byte_t fLastUsedSliceHiGain;
+    Byte_t fLastUsedSliceLoGain;
+
+    Float_t fUsedWindowHiGain;
+    Float_t fUsedWindowLoGain;
+    
+public:
+
+    MExtractedSignalCam(const char *name=NULL, const char *title=NULL);
+    ~MExtractedSignalCam();
+
+    void Print(Option_t *o="") const;
+    void Clear(Option_t *o="");
+    void SetLogStream(MLog *lg);
+
+    void InitSize(const UInt_t i);
+    Int_t GetSize() const;
+
+    Float_t GetNumUsedHiGainFADCSlices() const { return fUsedWindowHiGain; }
+    Float_t GetNumUsedLoGainFADCSlices() const { return fUsedWindowLoGain; }
+
+    Byte_t GetFirstUsedSliceHiGain() const    { return fFirstUsedSliceHiGain; }
+    Byte_t GetFirstUsedSliceLoGain() const    { return fFirstUsedSliceLoGain; }
+
+    Byte_t GetLastUsedSliceHiGain()  const    { return fLastUsedSliceHiGain; }
+    Byte_t GetLastUsedSliceLoGain()  const    { return fLastUsedSliceLoGain; }
+
+    void   SetUsedFADCSlices(Byte_t firsth, Byte_t lasth, Float_t winh,
+                             Byte_t firstl, Byte_t lastl, Float_t winl)
+    {
+      fFirstUsedSliceHiGain    = firsth;
+      fLastUsedSliceHiGain     = lasth;
+      fUsedWindowHiGain        = winh;
+      fFirstUsedSliceLoGain    = firstl;
+      fLastUsedSliceLoGain     = lastl;
+      fUsedWindowLoGain        = winl;
+    }
+
+    MExtractedSignalPix &operator[](Int_t i);
+    const MExtractedSignalPix &operator[](Int_t i) const;
+
+    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const;
+    void DrawPixelContent(Int_t num) const;
+
+    ClassDef(MExtractedSignalCam, 1)	// Storage Container for extracted signals in the camera
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractedSignalPINDiode.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractedSignalPINDiode.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractedSignalPINDiode.cc	(revision 9661)
@@ -0,0 +1,120 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug  02/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MExtractedSignalPINDiode
+//
+// This is the storage container to hold informations about the extracted signal 
+// (offset) value of the calibration PIN Diode
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MExtractedSignalPINDiode.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MExtractedSignalPINDiode);
+
+using namespace std;
+
+static const Float_t gkSignalInitializer = 99999.9;
+
+// ------------------------------------------------------------------------
+//
+// MExtractedSignalPINDiode holds the extracted signal
+// of the FADC slices and its error. 
+//
+// Additionally, the number of saturated Slices are stored. 
+// 
+// Default values for the extracted signals are: 99999.9 
+//
+MExtractedSignalPINDiode::MExtractedSignalPINDiode(const char* name, const char* title)
+{
+
+  fName  = name  ? name  : "MExtractedSignalPINDiode";
+  fTitle = title ? title : "Container of the Extracted Signals";
+
+  Clear();
+}
+
+// ------------------------------------------------------------------------
+//
+// Invalidate values
+//
+void MExtractedSignalPINDiode::Clear(Option_t *o)
+{
+  fExtractedSignal          = gkSignalInitializer;
+  fExtractedSignalErr       = gkSignalInitializer;
+  fExtractedTime            = gkSignalInitializer;
+  fExtractedTimeErr         = gkSignalInitializer; 
+  fExtractedRms             = gkSignalInitializer; 
+  fExtractedRmsErr          = gkSignalInitializer; 
+
+  fNumSaturated       = 0;
+}
+
+void MExtractedSignalPINDiode::SetUsedFADCSlices(const Byte_t first, const Byte_t num)   
+{
+  fFirst          = first; 
+  fNumFADCSamples = num;
+}
+
+
+void MExtractedSignalPINDiode::SetExtractedSignal(const Float_t sig, const Float_t sigerr)   
+{
+  fExtractedSignal      = sig; 
+  fExtractedSignalErr = sigerr;
+}
+
+void MExtractedSignalPINDiode::SetExtractedRms(const Float_t sig, const Float_t sigerr)   
+{
+  fExtractedRms      = sig; 
+  fExtractedRmsErr = sigerr;
+}
+
+void MExtractedSignalPINDiode::SetExtractedTime(const Float_t sig, const Float_t sigerr)   
+{
+  fExtractedTime      = sig; 
+  fExtractedTimeErr = sigerr;
+}
+
+
+Bool_t MExtractedSignalPINDiode::IsValid() const
+{
+    return fExtractedSignal >= 0. || fExtractedSignalErr >= 0.;
+}
+
+void MExtractedSignalPINDiode::SetSaturation(const Byte_t numsat)
+{
+  fNumSaturated = numsat; 
+}
+
+void MExtractedSignalPINDiode::Print(Option_t *o) const
+{
+  *fLog << " Signal: " << fExtractedSignal
+        << " +- " << fExtractedSignalErr
+        << " Nr. Saturation: " <<  fNumSaturated
+        << endl;
+}
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractedSignalPINDiode.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractedSignalPINDiode.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractedSignalPINDiode.h	(revision 9661)
@@ -0,0 +1,52 @@
+#ifndef MARS_MExtractedSignalPINDiode
+#define MARS_MExtractedSignalPINDiode
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MExtractedSignalPINDiode : public MParContainer
+{
+private:
+
+  Float_t fExtractedSignal;    // mean value of the extracted signal
+  Float_t fExtractedSignalErr; // error of the mean value of the extracted signal
+  Float_t fExtractedTime; 
+  Float_t fExtractedTimeErr; 
+  Float_t fExtractedRms; 
+  Float_t fExtractedRmsErr; 
+
+  Byte_t fFirst;
+  Byte_t fNumFADCSamples;
+  Byte_t fNumSaturated;
+
+public:
+    MExtractedSignalPINDiode(const char* name=NULL, const char* title=NULL);
+
+    void Clear(Option_t *o="");
+    void Print(Option_t *o="") const;
+
+    // Setter
+    void SetExtractedSignal(const Float_t sig, const Float_t sigerr);
+    void SetExtractedRms(  const Float_t sig, const Float_t sigerr);
+    void SetExtractedTime(  const Float_t sig, const Float_t sigerr);
+    void SetSaturation(   const Byte_t numsat);
+    void SetUsedFADCSlices( const Byte_t first, const Byte_t num);
+    
+    // Getter
+    Float_t GetExtractedSignal()    const { return fExtractedSignal;       }
+    Float_t GetExtractedSignalErr() const { return fExtractedSignalErr;    }
+    Float_t GetExtractedTime()      const { return fExtractedTime;         }
+    Float_t GetExtractedTimeErr()   const { return fExtractedTimeErr;      }
+    Float_t GetExtractedRms()       const { return fExtractedRms;          }
+    Float_t GetExtractedRmsErr()    const { return fExtractedRmsErr;       }
+    Byte_t  GetNumFADCSamples()     const { return fNumFADCSamples;        }
+    Byte_t  GetFirstUsedSlice()     const { return fFirst;                 }
+    Byte_t  GetLastUsedSlice()      const { return fFirst+fNumFADCSamples; }    
+    
+    Bool_t IsValid() const;   
+
+    ClassDef(MExtractedSignalPINDiode, 1)	// Storage Container for Extracted Signal information of one pixel
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractedSignalPix.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractedSignalPix.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractedSignalPix.cc	(revision 9661)
@@ -0,0 +1,120 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug  12/2003 <mailto:markus@ifae.es>
+!   Author(s): Thomas Bretz 12/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MExtractedSignalPix
+//
+// This is the storage container to hold informations about the pedestal
+// (offset) value of one Pixel (PMT).
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MExtractedSignalPix.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MExtractedSignalPix);
+
+using namespace std;
+
+static const Float_t gkSignalInitializer = 99999.9;
+
+// ------------------------------------------------------------------------
+//
+// MExtractedSignalPix holds the extracted signal (HiGain and LoGain) 
+// of the FADC slices and its error. 
+//
+// Additionally, the number of saturated HiGain and LoGain Slices are stored. 
+// 
+// Default values for the extracted signals are: 99999.9 
+//
+MExtractedSignalPix::MExtractedSignalPix(const char* name, const char* title)
+  : fExtractedSignalHiGain(gkSignalInitializer),
+    fExtractedSignalHiGainError(gkSignalInitializer),
+    fExtractedSignalLoGain(gkSignalInitializer),
+    fExtractedSignalLoGainError(gkSignalInitializer),
+    fLoGainUsed(kFALSE),
+    fNumHiGainSaturated(0),
+    fNumLoGainSaturated(0)
+{
+  fName  = name  ? name  : "MExtractedSignalPix";
+  fTitle = title ? title : "Container of the Extracted Signals";
+}
+
+// ------------------------------------------------------------------------
+//
+// Invalidate values
+//
+void MExtractedSignalPix::Clear(Option_t *o)
+{
+  fExtractedSignalHiGain      = gkSignalInitializer;
+  fExtractedSignalHiGainError = gkSignalInitializer;
+  fExtractedSignalLoGain      = gkSignalInitializer;
+  fExtractedSignalLoGainError = gkSignalInitializer;
+  
+  fLoGainUsed = kFALSE;
+
+  fNumHiGainSaturated = 0;
+  fNumLoGainSaturated = 0;
+}
+
+void MExtractedSignalPix::SetExtractedSignal(Float_t sig, Float_t sigerr)   
+{
+  fExtractedSignalHiGain      = sig; 
+  fExtractedSignalHiGainError = sigerr;
+}
+
+void MExtractedSignalPix::SetExtractedSignal(Float_t sighi, Float_t sighierr,
+                                             Float_t siglo, Float_t sigloerr)   
+{
+  fExtractedSignalHiGain = sighi;
+  fExtractedSignalHiGainError = sighierr;
+  fExtractedSignalLoGain = siglo;
+  fExtractedSignalLoGainError = sigloerr;
+}
+
+Bool_t MExtractedSignalPix::IsValid() const
+{
+    return fExtractedSignalHiGain >= 0. || fExtractedSignalHiGainError >= 0.;
+}
+
+void MExtractedSignalPix::SetGainSaturation(Bool_t sat, Byte_t higain, Byte_t logain) 
+{
+
+  fLoGainUsed = sat; 
+  fNumHiGainSaturated = higain; 
+  fNumLoGainSaturated = logain;
+}
+
+void MExtractedSignalPix::Print(Option_t *o) const
+{
+    *fLog << " Signal: " << fExtractedSignalHiGain
+        << " +- " << fExtractedSignalHiGainError
+        << " LoGain? " << fLoGainUsed
+        << " Nr. Sat. Hi Gain: " <<  fNumHiGainSaturated
+        << " Nr. Sat. Lo Gain: " <<  fNumLoGainSaturated
+        << endl;
+}
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractedSignalPix.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractedSignalPix.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractedSignalPix.h	(revision 9661)
@@ -0,0 +1,47 @@
+#ifndef MARS_MExtractedSignalPix
+#define MARS_MExtractedSignalPix
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MExtractedSignalPix : public MParContainer
+{
+private:
+  Float_t fExtractedSignalHiGain;      // mean value of the extracted signal
+  Float_t fExtractedSignalHiGainError; // error of the mean value of the extracted signal
+  Float_t fExtractedSignalLoGain;      // mean value of the extracted signal
+  Float_t fExtractedSignalLoGainError; // error of the mean value of the extracted signal
+
+  Bool_t fLoGainUsed;
+  Byte_t fNumHiGainSaturated;
+  Byte_t fNumLoGainSaturated;
+
+public:
+    MExtractedSignalPix(const char* name=NULL, const char* title=NULL);
+
+    void Clear(Option_t *o="");
+    void Print(Option_t *o="") const;
+
+    // Setter
+    void SetExtractedSignal(Float_t sig, Float_t sigerr);
+    void SetExtractedSignal(Float_t sighi, Float_t sighierr,Float_t siglo, Float_t sigloerr);
+    void SetGainSaturation(Bool_t sat, Byte_t higain, Byte_t logain);
+
+    // Getter
+    Float_t GetExtractedSignalHiGain()      const { return fExtractedSignalHiGain; }
+    Float_t GetExtractedSignalHiGainError() const { return fExtractedSignalHiGainError; }
+
+    Float_t GetExtractedSignalLoGain()      const { return fExtractedSignalLoGain; }
+    Float_t GetExtractedSignalLoGainError() const { return fExtractedSignalLoGainError; }
+
+    Byte_t GetNumHiGainSaturated()          const { return fNumHiGainSaturated; }
+    Byte_t GetNumLoGainSaturated()          const { return fNumLoGainSaturated; }
+
+    Bool_t IsLoGainUsed() const { return fLoGainUsed; }
+    Bool_t IsValid() const;   
+
+    ClassDef(MExtractedSignalPix, 1)	// Storage Container for Extracted Signal information of one pixel
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractor.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractor.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractor.cc	(revision 9661)
@@ -0,0 +1,327 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug, 04/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// MExtractor
+// ==========
+//
+//   Base class for the signal extractors, used the functions 
+//   FindSignalHiGain() and FindSignalLoGain() to extract the signal and 
+//   substract the pedestal value    
+//
+//   The following variables have to be set by the derived class and 
+//   do not have defaults:
+//   - fNumHiGainSamples
+//   - fNumLoGainSamples
+//   - fSqrtHiGainSamples
+//   - fSqrtLoGainSamples
+//
+//   The signal extractor classes can be setup from an environmental
+//   setup file. For more information see ReadEnv and MEvtLoop::ReadEnv
+//
+// Input Containers:
+//   MRawEvtData
+//   MRawRunHeader
+//   MPedestalCam
+//
+// Output Containers:
+//   MExtractedSignalCam
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MExtractor.h"
+
+#include <fstream>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MRawEvtData.h"
+#include "MRawEvtPixelIter.h"
+#include "MRawRunHeader.h"
+
+#include "MPedestalCam.h"
+#include "MPedestalPix.h"
+
+#include "MExtractedSignalCam.h"
+#include "MExtractedSignalPix.h"
+
+ClassImp(MExtractor);
+
+using namespace std;
+
+const Byte_t MExtractor::fgSaturationLimit = 254;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+// Set: 
+// - all pointers to NULL
+// - all variables to 0
+// - fSaturationLimit to fgSaturationLimit
+//
+// Call:
+// -  AddToBranchList("MRawEvtData.*")
+//
+MExtractor::MExtractor(const char *name, const char *title)
+    : fPedestals(NULL), fSignals(NULL), fRawEvt(NULL), fRunHeader(NULL),
+      fHiLoLast(0), fNumHiGainSamples(0.), fNumLoGainSamples(0.), 
+      fSaturationLimit(fgSaturationLimit)
+{
+    fName  = name  ? name  : "MExtractor";
+    fTitle = title ? title : "Base class for signal extractors";
+
+    AddToBranchList("MRawEvtData.*");
+
+    SetRange();
+}
+
+void MExtractor::SetRange(Byte_t hifirst, Byte_t hilast, Byte_t lofirst, Byte_t lolast)
+{
+    fHiGainFirst = hifirst;
+    fHiGainLast  = hilast;
+
+    fLoGainFirst = lofirst;
+    fLoGainLast  = lolast;
+}
+
+// --------------------------------------------------------------------------
+//
+// The PreProcess searches for the following input containers:
+//  - MRawEvtData
+//  - MRawRunHeader
+//  - MPedestalCam
+//
+// The following output containers are also searched and created if
+// they were not found:
+//
+//  - MExtractedSignalCam
+//
+Int_t MExtractor::PreProcess(MParList *pList)
+{
+    fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData"));
+    if (!fRawEvt)
+      {
+        *fLog << err << AddSerialNumber("MRawEvtData") << " not found... aborting." << endl;
+        return kFALSE;
+      }
+    
+    fRunHeader = (MRawRunHeader*)pList->FindObject(AddSerialNumber("MRawRunHeader"));
+    if (!fRunHeader)
+      {
+        *fLog << err << AddSerialNumber("MRawRunHeader") << " not found... aborting." << endl;
+        return kFALSE;
+      }
+    
+
+    fSignals = (MExtractedSignalCam*)pList->FindCreateObj(AddSerialNumber("MExtractedSignalCam"));
+    if (!fSignals)
+        return kFALSE;
+
+    fPedestals = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
+    if (!fPedestals)
+    {
+        *fLog << err << AddSerialNumber("MPedestalCam") << " not found... aborting" << endl;
+        return kFALSE;
+    }
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// The ReInit searches for:
+// -  MRawRunHeader::GetNumSamplesHiGain()
+// -  MRawRunHeader::GetNumSamplesLoGain()
+//
+// In case that the variable fLoGainLast is smaller than 
+// the even part of the number of samples obtained from the run header, a
+// warning is given an the range is set back accordingly. A call to:  
+// - SetRange(fHiGainFirst, fHiGainLast, fLoGainFirst, fLoGainLast-diff) 
+// is performed in that case. The variable diff means here the difference 
+// between the requested range (fLoGainLast) and the available one. Note that 
+// the functions SetRange() are mostly overloaded and perform more checks, 
+// modifying the ranges again, if necessary.
+//
+// In case that the variable fHiGainLast is smaller than the available range 
+// obtained from the run header, a warning is given that a part of the low-gain 
+// samples are used for the extraction of the high-gain signal. 
+//
+// Call: 
+// - MExtractedSignalCam::SetUsedFADCSlices(fHiGainFirst, fHiGainLast, fNumHiGainSamples,
+//                                          fLoGainFirst, fLoGainLast, fNumLoGainSamples);
+//
+Bool_t MExtractor::ReInit(MParList *pList)
+{
+    Int_t lastdesired   = (Int_t)(fLoGainLast);
+    Int_t lastavailable = (Int_t)fRunHeader->GetNumSamplesLoGain()-1;
+
+    if (lastavailable < 0)
+        *fLog << warn << GetDescriptor() << " - WARNING: Number of available Low-Gain Slices is smaller than or equal zero!" << endl;
+
+    if (lastdesired > lastavailable)
+    {
+        const Int_t diff = lastdesired - lastavailable;
+
+        *fLog << endl;
+        *fLog << warn << GetDescriptor() << ": Selected Lo Gain FADC Window [";
+        *fLog << Form("%2i,%2i", (int)fLoGainFirst, lastdesired);
+        *fLog << "] ranges out of the available limits: [0," << Form("%2i", lastavailable) << "]" << endl;
+        *fLog << GetDescriptor() << ": Will reduce the upper edge to " << (int)(fLoGainLast - diff) << endl;
+        SetRange(fHiGainFirst, fHiGainLast, fLoGainFirst, fLoGainLast-diff);
+    }
+
+    lastdesired   = (Int_t)fHiGainLast;
+    lastavailable = (Int_t)fRunHeader->GetNumSamplesHiGain()-1;
+
+    if (lastavailable < 0)
+    {
+        *fLog << err << GetDescriptor();
+        *fLog << " - ERROR: Number of available High-Gain Slices is smaller than or equal zero!" << endl;
+        return kFALSE;
+    }
+
+  if (lastdesired > lastavailable)
+  {
+      const Int_t diff = lastdesired - lastavailable;
+
+      *fLog << endl;
+      *fLog << warn << GetDescriptor() << ": Selected Hi Gain FADC Window [";
+      *fLog << Form("%2i,%2i%s%2i%s", (int)fHiGainFirst,",",lastdesired);
+      *fLog << "] ranges out of the available limits: [0," << Form("%2i", lastavailable) << "]" << endl;
+      *fLog << warn << GetDescriptor() << ": Will use ";
+      *fLog << Form("%2i", diff) << " samples from the Low-Gain for the High-Gain extraction";
+      *fLog << endl;
+
+      fHiGainLast -= diff;
+      fHiLoLast    = diff;
+  }
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculate the integral of the FADC time slices and store them as a new
+// pixel in the MExtractedSignalCam container.
+//
+Int_t MExtractor::Process()
+{
+  MRawEvtPixelIter pixel(fRawEvt);
+  fSignals->Clear();
+
+  while (pixel.Next())
+    {
+      Float_t sumhi = 0.;
+      Byte_t sathi = 0;
+
+      FindSignalHiGain(pixel.GetHiGainSamples()+fHiGainFirst, pixel.GetLoGainSamples(), sumhi, sathi);
+
+      Float_t sumlo = 0.;
+      Byte_t satlo = 0;
+
+      if (pixel.HasLoGain())
+        FindSignalLoGain(pixel.GetLoGainSamples()+fLoGainFirst, sumlo, satlo);
+      
+      const Int_t pixid = pixel.GetPixelId();
+      
+      const MPedestalPix  &ped = (*fPedestals)[pixid]; 
+      MExtractedSignalPix &pix = (*fSignals)[pixid];
+      
+      const Float_t pedes  = ped.GetPedestal();
+      const Float_t pedrms = ped.GetPedestalRms();
+
+      pix.SetExtractedSignal(sumhi - pedes*fNumHiGainSamples, pedrms*fSqrtHiGainSamples,
+                             sumlo - pedes*fNumLoGainSamples, pedrms*fSqrtLoGainSamples);
+      
+      pix.SetGainSaturation(sathi, sathi, satlo);
+      
+    } /* while (pixel.Next()) */
+
+    fSignals->SetReadyToSave();
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Implementation of SavePrimitive. Used to write the call to a constructor
+// to a macro. In the original root implementation it is used to write
+// gui elements to a macro-file.
+//
+void MExtractor::StreamPrimitive(ofstream &out) const
+{
+  out << "   " << ClassName() << " " << GetUniqueName() << "(\"";
+  out << "\"" << fName << "\", \"" << fTitle << "\");" << endl;
+  
+  if (fSaturationLimit!=fgSaturationLimit)
+  {
+      out << "   " << GetUniqueName() << ".SetSaturationLimit(";
+      out << (int)fSaturationLimit << ");" << endl;
+  }
+  
+  out << "   " << GetUniqueName() << ".SetRange(";
+  out << (int)fHiGainFirst;
+  out << ", " << (int)fHiGainLast;
+  out << ", " << (int)fLoGainFirst;
+  out << ", " << (int)fLoGainLast;
+  out << ");" << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Read the setup from a TEnv, eg:
+//   MJPedestal.MExtractor.HiGainFirst: 5
+//   MJPedestal.MExtractor.LoGainFirst: 5
+//   MJPedestal.MExtractor.HiGainLast:  10
+//   MJPedestal.MExtractor.LoGainLast:  10
+//   MJPedestal.MExtractor.SaturationLimit: 88
+//
+Bool_t MExtractor::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
+{
+    Byte_t hf = fHiGainFirst;
+    Byte_t lf = fLoGainFirst;
+    Byte_t hl = fHiGainLast;
+    Byte_t ll = fLoGainLast;
+
+    if (IsEnvDefined(env, prefix, "HiGainFirst", print))
+        hf = GetEnvValue(env, prefix, "HiGainFirst", hf);
+    if (IsEnvDefined(env, prefix, "LoGainFirst", print))
+        lf = GetEnvValue(env, prefix, "LoGainFirst", lf);
+
+    if (IsEnvDefined(env, prefix, "HiGainLast", print))
+        hl = GetEnvValue(env, prefix, "HiGainLast", hl);
+    if (IsEnvDefined(env, prefix, "LoGainLast", print))
+        ll = GetEnvValue(env, prefix, "LoGainLast", ll);
+
+    SetRange(hf, hl, lf, ll);
+
+    if (IsEnvDefined(env, prefix, "SaturationLimit", print))
+        SetSaturationLimit(GetEnvValue(env, prefix, "SaturationLimit", fSaturationLimit));
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/msignal/MExtractor.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/MExtractor.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/MExtractor.h	(revision 9661)
@@ -0,0 +1,74 @@
+#ifndef MARS_MExtractor
+#define MARS_MExtractor
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MExtractor                                                              //
+//                                                                         //
+// Base class for the signal extractors                                    //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MRawEvtData;
+class MRawRunHeader;
+
+class MPedestalCam;
+class MExtractedSignalCam;
+
+class MExtractor : public MTask
+{
+protected:
+    static const Byte_t fgSaturationLimit;
+
+    MPedestalCam        *fPedestals;    // Pedestals of all pixels in the camera
+    MExtractedSignalCam *fSignals;      // Extracted signal of all pixels in the camera
+
+    MRawEvtData         *fRawEvt;       // raw event data (time slices)
+    MRawRunHeader       *fRunHeader;    // RunHeader information
+
+    Byte_t   fHiGainFirst;
+    Byte_t   fLoGainFirst;
+
+    Byte_t   fHiGainLast;
+    Byte_t   fLoGainLast;
+
+    Byte_t   fHiLoLast;
+    
+    Float_t  fNumHiGainSamples;
+    Float_t  fNumLoGainSamples;
+
+    Float_t  fSqrtHiGainSamples;
+    Float_t  fSqrtLoGainSamples;
+
+    Byte_t  fSaturationLimit;
+
+    virtual void FindSignalHiGain(Byte_t *firstused, Byte_t *lowgain, Float_t &sum, Byte_t &sat) const { }
+    virtual void FindSignalLoGain(Byte_t *firstused, Float_t &sum, Byte_t &sat) const { }
+
+    Int_t  PreProcess(MParList *pList);
+    Bool_t ReInit(MParList *pList);
+    Int_t  Process();
+    void   StreamPrimitive(ofstream &out) const;
+    Bool_t ReadEnv(const TEnv &env, TString prefix, Bool_t print);
+
+public:
+    MExtractor(const char *name=NULL, const char *title=NULL);
+
+    Byte_t  GetHiGainFirst()      const { return fHiGainFirst;      }
+    Byte_t  GetHiGainLast ()      const { return fHiGainLast ;      }
+    Byte_t  GetLoGainFirst()      const { return fLoGainFirst;      }
+    Byte_t  GetLoGainLast ()      const { return fLoGainLast ;      }
+    Float_t GetNumHiGainSamples() const { return fNumHiGainSamples; }
+    Float_t GetNumLoGainSamples() const { return fNumLoGainSamples; }
+    
+    virtual void SetRange  (Byte_t hifirst=0, Byte_t hilast=0, Byte_t lofirst=0, Byte_t lolast=0);
+    void SetSaturationLimit(Byte_t lim=fgSaturationLimit) { fSaturationLimit = lim; }
+
+    ClassDef(MExtractor, 0) // Signal Extractor Base Class
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/msignal/Makefile
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/Makefile	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/Makefile	(revision 9661)
@@ -0,0 +1,62 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#------------------------------------------------------------------------------
+
+#
+# Handling name of the Root Dictionary Files
+#
+CINT  = Signal
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES =  -I. -I../mbase -I../mgui -I../mraw -I../manalysis \
+            -I../mgeom -I../mtools -I../mpedestal
+
+# mgui (MCamEvent):         MExtractSignalCam
+# mgeom(MGeomCam):          MArrivalTime
+# mtools(MCubicSpline):     MArrivalTime
+# mraw (MRawEvtData):       MExtractSignal
+# manalysis (MPedestalCam): MExtractSignal
+
+SRCFILES = MExtractedSignalCam.cc \
+           MExtractedSignalPix.cc \
+	   MExtractedSignalPINDiode.cc \
+	   MExtractedSignalBlindPixel.cc \
+           MExtractor.cc \
+           MExtractFixedWindow.cc \
+           MExtractSlidingWindow.cc \
+           MExtractFixedWindowPeakSearch.cc \
+           MExtractFixedWindowSpline.cc \
+           MExtractAmplitudeSpline.cc \
+           MExtractSignal.cc \
+           MExtractSignal2.cc \
+           MExtractSignal3.cc \
+           MExtractSignalABcorr.cc \
+	   MExtractPINDiode.cc \
+	   MExtractBlindPixel.cc \
+           MExtractTime.cc \
+           MExtractTimeSpline.cc \
+           MExtractTimeFastSpline.cc \
+           MExtractTimeHighestIntegral.cc \
+           MArrivalTime.cc \
+           MArrivalTimeCalc.cc \
+           MArrivalTimeCalc2.cc \
+           MArrivalTimeCam.cc \
+	   MArrivalTimePix.cc
+
+############################################################
+
+all: $(OBJS)
+
+include ../Makefile.rules
+
+mrproper:	clean rmbak
Index: /tags/Mars_V0-8-5/Mars/msignal/SignalIncl.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/SignalIncl.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/SignalIncl.h	(revision 9661)
@@ -0,0 +1,7 @@
+#ifndef __CINT__
+
+#include <TArrayC.h>
+#include "MArrayB.h"
+#include "MArrayS.h"
+
+#endif // __CINT__
Index: /tags/Mars_V0-8-5/Mars/msignal/SignalLinkDef.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/msignal/SignalLinkDef.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msignal/SignalLinkDef.h	(revision 9661)
@@ -0,0 +1,37 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class MExtractedSignalCam+;
+#pragma link C++ class MExtractedSignalPix+;
+#pragma link C++ class MExtractedSignalPINDiode++;
+#pragma link C++ class MExtractedSignalBlindPixel++;
+
+#pragma link C++ class MExtractSignal+;
+#pragma link C++ class MExtractSignal2+;
+#pragma link C++ class MExtractSignal3+;
+#pragma link C++ class MExtractSignalABcorr+;
+
+#pragma link C++ class MExtractor+;
+#pragma link C++ class MExtractFixedWindow+;
+#pragma link C++ class MExtractSlidingWindow+;
+#pragma link C++ class MExtractFixedWindowPeakSearch+;
+#pragma link C++ class MExtractFixedWindowSpline+;
+#pragma link C++ class MExtractAmplitudeSpline+;
+#pragma link C++ class MExtractPINDiode++;
+#pragma link C++ class MExtractBlindPixel++;
+
+#pragma link C++ class MExtractTime+;
+#pragma link C++ class MExtractTimeSpline+;
+#pragma link C++ class MExtractTimeFastSpline+;
+#pragma link C++ class MExtractTimeHighestIntegral+;
+
+#pragma link C++ class MArrivalTimeCam+;
+#pragma link C++ class MArrivalTimePix+;
+#pragma link C++ class MArrivalTime+;
+#pragma link C++ class MArrivalTimeCalc+;
+#pragma link C++ class MArrivalTimeCalc2+;
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/msql/MSQLServer.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/msql/MSQLServer.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msql/MSQLServer.cc	(revision 9661)
@@ -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 2/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+////////////////////////////////////////////////////////////////////////
+//
+//  MSQLServer
+//
+//  Using this instead of a TSQLServer gives the possibility to
+//  browse a database server through the TBrowser and it will offer
+//  many features usefull working with relational tables.
+//
+//  Use it like TSQlServer:
+//    new MSQLServer("mysql://localhost:3306", "hercules", "stdmagicpassword");
+//    // now start your TBrowser
+//    new TBrowser;
+//
+////////////////////////////////////////////////////////////////////////
+#include "MSQLServer.h"
+
+#include <iostream>
+#include <iomanip>
+#include <stdlib.h>
+
+#include <TROOT.h>
+
+#include <TH1.h>
+
+#include <TSQLResult.h>
+#include <TSQLServer.h>
+#include <TSQLRow.h>
+
+#include <TBrowser.h>
+
+ClassImp(MSQLServer);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Used in virtual function TObject::Browse() to create the
+//
+void MSQLServer::BrowseColumn(TBrowser *b) /*FOLD00*/
+{
+    const TString query0(Form("EXPLAIN %s.%s %s", (const char*)fDataBase, (const char*)fTable, (const char*)fColumn));
+    const TString query1(Form("SELECT %s FROM %s.%s", (const char*)fColumn, (const char*)fDataBase, (const char*)fTable));
+
+    //cout << query0 << endl;
+    TSQLResult *res = fServ->Query(query0);
+    if (!res)
+    {
+        cout << "query - failed: " << query0 << endl;
+        return;
+    }
+
+    TSQLRow *row=res->Next();
+    const TString desc((*row)[1]);
+
+    delete res;
+
+    const Bool_t isnum =
+        !desc.Contains("char", TString::kIgnoreCase) &&
+        !desc.Contains("text", TString::kIgnoreCase);
+
+    cout << query1 << endl;
+    res = fServ->Query(query1);
+    if (!res)
+    {
+        cout << "query - failed: " << query1 << endl;
+        return;
+    }
+
+    TArrayD arr(2);
+    Int_t num=0;
+    Double_t max=0;
+    Double_t min=0;
+    Double_t sum=0;
+    Double_t sqr=0;
+
+    while ((row=res->Next()))
+    {
+        const TString row0((*row)[0]);
+
+        if (!isnum)
+        {
+            cout << row0 << endl;
+            continue;
+        }
+
+        if (num==arr.GetSize())
+            arr.Set(arr.GetSize()*2);
+
+        arr[num] = atof(row0.Data());
+
+        if (num==0)
+            min=max=arr[0];
+
+        if (arr[num]>max) max = arr[num];
+        if (arr[num]<min) min = arr[num];
+
+        sum += arr[num];
+        sqr += arr[num]*arr[num];
+
+        num++;
+    }
+
+    delete res;
+
+    if (!isnum)
+        return;
+
+    if (max==min) max += 1;
+
+    Int_t num0 = 1;
+
+    if (num>0)
+    {
+        /*
+         cout << "Num:   " << num << endl;
+         cout << "Mean:  " << sum/num << endl;
+         cout << "Range: " << max-min << endl;
+         cout << "RMS:   " << TMath::Sqrt(sqr/num-sum*sum/num/num) << endl;
+         */
+
+        num0 = (Int_t)((max-min)*40/TMath::Sqrt(sqr/num-sum*sum/num/num));
+    }
+
+    const TString title(Form("#splitline{%s}{<%s>}", (const char*)query1, (const char*)desc));
+
+    TH1F *hist=new TH1F(fColumn, title, num0, min, max);
+    for (int i=0; i<num; i++)
+        hist->Fill(arr[i]);
+
+    //cout << "Done." << endl;
+
+    hist->Draw();
+    hist->SetBit(kCanDelete);
+}
+
+void MSQLServer::BrowseTable(TBrowser *b) /*FOLD00*/
+{
+    TSQLResult *res = fServ->GetColumns(fDataBase, fTable);
+    if (!res)
+        return;
+
+    TSQLRow *row;
+    while ((row=res->Next()))
+    {
+        TString row0((*row)[0]);
+
+        MSQLServer *sql = (MSQLServer*)fList.FindObject(Form("%s/%s/%s", (const char*)fDataBase, (const char*)fTable, (const char*)row0));
+        if (!sql)
+        {
+            sql = new MSQLColumn(fServ, fDataBase, fTable, row0);
+            fList.Add(sql);
+        }
+        b->Add(sql, row0);
+    }
+}
+
+void MSQLServer::BrowseDataBase(TBrowser *b) /*FOLD00*/
+{
+    TSQLResult *res = fServ->GetTables(fDataBase);
+    if (!res)
+        return;
+
+    TSQLRow *row;
+    while ((row=res->Next()))
+    {
+        TString row0((*row)[0]);
+
+        MSQLServer *sql = (MSQLServer*)fList.FindObject(Form("%s/%s", (const char*)fDataBase, (const char*)row0));
+        if (!sql)
+        {
+            sql = new MSQLServer(fServ, fDataBase, row0);
+            fList.Add(sql);
+        }
+        b->Add(sql, row0);
+    }
+}
+
+void MSQLServer::BrowseServer(TBrowser *b) /*FOLD00*/
+{
+    TSQLResult *res = fServ->GetDataBases();
+    if (!res)
+        return;
+
+    TSQLRow *row;
+    while ((row=res->Next()))
+    {
+        const TString row0((*row)[0]);
+
+        MSQLServer *sql = (MSQLServer*)fList.FindObject(row0);
+        if (!sql)
+        {
+            sql = new MSQLServer(fServ, row0);
+            fList.Add(sql);
+        }
+        b->Add(sql, row0);
+    }
+}
+
+void MSQLServer::PrintLine(const TArrayI &max) const /*FOLD00*/
+{
+    cout << "+" << setfill('-');
+    for (int i=0; i<max.GetSize(); i++)
+        cout << setw(max[i]+1) << "-" << "-+";
+    cout << endl;
+}
+
+void MSQLServer::PrintTable(TSQLResult *res) const /*FOLD00*/
+{
+    Int_t n = res->GetFieldCount();
+
+    TArrayI max(n);
+
+    for (int i=0; i<n; i++)
+        max[i] = strlen(res->GetFieldName(i));
+
+    TSQLRow *row;
+
+    TList rows;
+    while ((row=res->Next()))
+    {
+        for (int i=0; i<n; i++)
+            max[i] = TMath::Max((ULong_t)max[i], row->GetFieldLength(i));
+        rows.Add(row);
+    }
+
+    cout << endl;
+
+    PrintLine(max);
+
+    cout << "|" << setfill(' ');
+    for (int i=0; i<n; i++)
+        cout << setw(max[i]+1) << res->GetFieldName(i) << " |";
+    cout << endl;
+
+    PrintLine(max);
+
+    cout << setfill(' ');
+    TIter Next(&rows);
+    while ((row=(TSQLRow*)Next()))
+    {
+        cout << "|";
+        for (int i=0; i<n; i++)
+        {
+            const char *c = (*row)[i];
+            cout << setw(max[i]+1) << (c?c:"") << " |";
+        }
+        cout << endl;
+    }
+
+    PrintLine(max);
+}
+
+TString MSQLServer::GetFields() const /*FOLD00*/
+{
+    TSQLResult *res = fServ->GetColumns(fDataBase, fTable);
+    if (!res)
+        return "";
+
+    TString fields;
+
+    TSQLRow *row;
+
+    TList rows;
+    while ((row=res->Next()))
+        rows.Add(row);
+
+    TIter Next(&rows);
+    while ((row=(TSQLRow*)Next()))
+    {
+        fields += (*row)[0];
+        if (row!=rows.Last())
+            fields += ", ";
+    }
+
+    return fields;
+}
+
+void MSQLServer::PrintQuery(const char *query) const /*FOLD00*/
+{
+    TSQLResult *res = fServ->Query(query);
+    if (res)
+    {
+        PrintTable(res);
+        delete res;
+    }
+    else
+        cout << "Query failed: " << query << endl;
+}
+
+void MSQLServer::Print(Option_t *o) const /*FOLD00*/
+{
+    switch (fType)
+    {
+    case kIsServer:
+        PrintQuery("SHOW DATABASES");
+        break;
+
+    case kIsDataBase:
+        PrintQuery(Form("SHOW TABLES FROM %s", (const char*)fDataBase));
+        break;
+
+    case kIsTable:
+        PrintQuery(Form("SELECT * FROM %s.%s", (const char*)fDataBase, (const char*)fTable));
+        break;
+
+    case kIsColumn:
+        PrintQuery(Form("SELECT %s FROM %s.%s", (const char*)fColumn, (const char*)fDataBase, (const char*)fTable));
+        break;
+
+    default:
+        break;
+    }
+}
+
+void MSQLServer::ShowColumns() const /*FOLD00*/
+{
+    switch (fType)
+    {
+    case kIsTable:
+        PrintQuery(Form("SHOW FULl COLUMNS FROM %s.%s", (const char*)fDataBase, (const char*)fTable));
+        break;
+
+    case kIsColumn:
+        PrintQuery(Form("SHOW FULl COLUMNS FROM %s.%s LIKE %s", (const char*)fDataBase, (const char*)fTable, (const char*)fColumn));
+        break;
+
+    default:
+        //Print();
+        break;
+    }
+}
+
+void MSQLServer::ShowStatus() const /*FOLD00*/
+{
+    switch (fType)
+    {
+    case kIsServer:
+        PrintQuery("SHOW STATUS");
+        break;
+
+    case kIsDataBase:
+        PrintQuery(Form("SHOW TABLE STATUS FROM %s", (const char*)fDataBase));
+        break;
+
+    case kIsTable:
+        PrintQuery(Form("SHOW TABLE STATUS FROM %s LIKE %s", (const char*)fDataBase, (const char*)fTable));
+        break;
+
+    default:
+        break;
+    }
+}
+
+void MSQLServer::ShowTableIndex() const /*FOLD00*/
+{
+    switch (fType)
+    {
+    case kIsTable:
+    case kIsColumn:
+        PrintQuery(Form("SHOW INDEX FROM %s.%s", (const char*)fDataBase, (const char*)fTable));
+        break;
+
+    default:
+        break;
+    }
+}
+
+void MSQLServer::ShowTableCreate() const /*FOLD00*/
+{
+    switch (fType)
+    {
+    case kIsTable:
+    case kIsColumn:
+        PrintQuery(Form("SHOW CREATE TABLE %s.%s", (const char*)fDataBase, (const char*)fTable));
+        break;
+
+    default:
+        break;
+    }
+}
+
+void MSQLServer::Close(Option_t *option) /*FOLD00*/
+{
+    if (fType==kIsServer)
+        fServ->Close(option);
+}
+
+TSQLResult *MSQLServer::Query(const char *sql) /*FOLD00*/
+{
+    return fType==kIsServer ? fServ->Query(sql) : NULL;
+}
+
+Int_t MSQLServer::SelectDataBase(const char *dbname) /*FOLD00*/
+{
+    return fType==kIsServer ? fServ->SelectDataBase(dbname) : 0;
+}
+
+TSQLResult *MSQLServer::GetDataBases(const char *wild) /*FOLD00*/
+{
+    return fType==kIsServer ? fServ->GetDataBases(wild) : NULL;
+}
+
+TSQLResult *MSQLServer::GetTables(const char *dbname, const char *wild) /*FOLD00*/
+{
+    return fType==kIsServer ? fServ->GetTables(dbname, wild) : NULL;
+}
+
+TSQLResult *MSQLServer::GetColumns(const char *dbname, const char *table, const char *wild) /*FOLD00*/
+{
+    return fType==kIsServer ? fServ->GetColumns(dbname, table, wild) : NULL;
+}
+
+Int_t MSQLServer::CreateDataBase(const char *dbname) /*FOLD00*/
+{
+    return fType==kIsServer ? fServ->CreateDataBase(dbname) : 0;
+}
+
+Int_t MSQLServer::DropDataBase(const char *dbname) /*FOLD00*/
+{
+    return fType==kIsServer ? fServ->DropDataBase(dbname) : 0;
+}
+
+Int_t MSQLServer::Reload() /*FOLD00*/
+{
+    return fType==kIsServer ? fServ->Reload() : 0;
+}
+
+Int_t MSQLServer::Shutdown() /*FOLD00*/
+{
+    return fType==kIsServer ? fServ->Shutdown() : 0;
+}
+
+const char *MSQLServer::ServerInfo() /*FOLD00*/
+{
+    return fType==kIsServer ? fServ->ServerInfo() : "";
+}
+
+Bool_t MSQLServer::IsConnected() const
+{
+    return fType==kIsServer ? fServ->IsConnected() : kFALSE;
+}
+
+const char *MSQLServer::GetName() const
+{
+    switch (fType)
+    {
+    case kIsServer:   return Form("%s://%s:%d", fServ->GetDBMS(), fServ->GetHost(), fServ->GetPort());
+    case kIsDataBase: return GetNameDataBase();
+    case kIsTable:    return GetNameTable();
+    case kIsColumn:   return GetNameColumn();
+    default:          return "n/a";
+    }
+}
+
+void MSQLServer::Init(const char *connection, const char *user, const char *password) /*FOLD00*/
+{
+    fType = kIsZombie;
+
+    fServ = TSQLServer::Connect(connection, user, password);
+    if (fServ)
+    {
+        gROOT->GetListOfBrowsables()->Add(this, connection);
+        fType = kIsServer;
+    }
+    else
+        SetBit(kZombie);
+
+    fList.SetOwner();
+}
+
+MSQLServer::MSQLServer(const char *connection, const char *user, const char *password) /*FOLD00*/
+{
+    Init(connection, user, password);
+}
+
+MSQLServer::MSQLServer(const char *u) : fType(kIsZombie) /*FOLD00*/
+{
+    TString url(u);
+
+    const Ssiz_t pos1 = url.First("://")+3;
+    const Ssiz_t pos2 = url.Last(':')   +1;
+    const Ssiz_t pos3 = url.First('@');
+
+    if (pos1<0 || pos2<0 || pos3<0 || pos1>pos2 || pos2>pos3)
+    {
+        SetBit(kZombie);
+        return;
+    }
+
+    const TString user = url(pos1, pos2-pos1-1);
+    const TString pasw = url(pos2, pos3-pos2);
+
+    url.Remove(pos1, pos3+1-pos1);
+
+    Init(url, user, pasw);
+}
+
+MSQLServer::~MSQLServer() /*FOLD00*/
+{
+    Close();
+    if (gDebug>0)
+        cout << "Delete: " << GetName() << endl;
+}
+
+Bool_t MSQLServer::PrintError(const char *txt, const char *q) const /*FOLD00*/
+{
+    cout << "Fatal error acessing database: " << txt << endl;
+    cout << "Query: " << q << endl;
+    return kFALSE;
+}
+
+TString MSQLServer::GetEntry(const char *where, const char *col, const char *table) const /*FOLD00*/
+{
+    if (!fServ)
+        return "";
+
+    if (table==0)
+        table = Form("%s.%s", (const char *)fDataBase, (const char*)fTable);
+    if (col==0)
+        col = (const char *)fColumn;
+
+    const TString query(Form("SELECT %s FROM %s WHERE %s", col, table, where));
+
+    TSQLResult *res = fServ->Query(query);
+    if (!res)
+        return (PrintError("GetEntry - TSQLResult==NULL", query), "");
+
+    if (res->GetFieldCount()!=1)
+    {
+        delete res;
+        return (PrintError("GetEntry - Number of columns != 1", query), "");
+    }
+
+    if (res->GetRowCount()>1)
+    {
+        delete res;
+        return (PrintError("GetEntry - Number of rows > 1", query), "");
+    }
+
+    if (res->GetRowCount()==0)
+    {
+        delete res;
+        return "";
+    }
+
+    const char *fld = res->Next()->GetField(0);
+    if (!fld)
+    {
+        delete res;
+        return (PrintError("GetEntry - Entry is empty", query), "");
+    }
+
+    const TString rc(fld);
+    delete res;
+    return rc;
+}
Index: /tags/Mars_V0-8-5/Mars/msql/MSQLServer.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/msql/MSQLServer.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msql/MSQLServer.h	(revision 9661)
@@ -0,0 +1,129 @@
+#ifndef MARS_MSQLServer
+#define MARS_MSQLServer
+
+#ifndef ROOT_TList
+#include <TList.h>
+#endif
+
+class TArrayI;
+class TSQLServer;
+class TSQLResult;
+
+class MSQLServer : public TObject
+{
+    TSQLServer *fServ;
+
+    TString fDataBase;
+    TString fTable;
+    TString fColumn;
+
+    TList   fList;
+
+    enum Type_t { kIsZombie, kIsServer, kIsDataBase, kIsTable, kIsColumn };
+
+    Type_t  fType;
+
+    Bool_t IsFolder() const { return kTRUE; }
+
+    Bool_t PrintError(const char *txt, const char *q) const;
+
+    void PrintLine(const TArrayI &max) const;
+    void PrintTable(TSQLResult *res) const;
+    TString GetFields() const;
+
+    void BrowseDataBase(TBrowser *b);
+    void BrowseTable(TBrowser *b);
+    void BrowseColumn(TBrowser *b);
+    void BrowseServer(TBrowser *b);
+
+    void Browse(TBrowser *b)
+    {
+        if (!b)
+            return;
+
+        switch (fType)
+        {
+        case kIsServer:   BrowseServer(b);   break;
+        case kIsDataBase: BrowseDataBase(b); break;
+        case kIsTable:    BrowseTable(b);    break;
+        case kIsColumn:   BrowseColumn(b);   break;
+        default:
+            break;
+        }
+    }
+
+    const char *GetNameDataBase() const { return fDataBase; }
+    const char *GetNameTable()    const { return Form("%s/%s",    (const char*)fDataBase, (const char*)fTable); }
+    const char *GetNameColumn()   const { return Form("%s/%s/%s", (const char*)fDataBase, (const char*)fTable, (const char*)fColumn); }
+
+    void Init(const char *connection, const char *user, const char *password);
+
+public:
+    MSQLServer(TSQLServer *serv, const char *dbname=0, const char *tname=0, const char *col=0)
+        : fServ(serv), fDataBase(dbname), fTable(tname), fColumn(col), fType(kIsZombie)
+    {
+        fList.SetOwner();
+
+        fType = kIsColumn;
+
+        if (fColumn.IsNull())
+            fType = kIsTable;
+
+        if (fTable.IsNull() && fColumn.IsNull())
+            fType = kIsDataBase;
+
+        if (fDataBase.IsNull() && fTable.IsNull() && fColumn.IsNull())
+            fType = kIsZombie;
+
+        if (!serv)
+            fType = kIsZombie;
+    }
+
+    MSQLServer(const char *connection, const char *user, const char *password);
+    MSQLServer(const char *link);
+    ~MSQLServer();
+
+    const char *GetName() const;
+
+    void Print(Option_t *o) const;
+    void Print() const { Print(""); } //*MENU*
+    void PrintQuery(const char *query) const; //*MENU*
+    void ShowColumns() const; //*MENU*
+    void ShowStatus() const; //*MENU*
+    void ShowTableIndex() const; //*MENU*
+    void ShowTableCreate() const; //*MENU*
+    void ShowVariables() const { PrintQuery("SHOW VARIABLES"); } //*MENU*
+    void ShowProcesses() const { PrintQuery("SHOW PROCESSLIST"); } //*MENU*
+
+    void Close(Option_t *option="");
+    TSQLResult *Query(const char *sql);
+    Int_t       SelectDataBase(const char *dbname);
+    TSQLResult *GetDataBases(const char *wild = 0);
+    TSQLResult *GetTables(const char *dbname, const char *wild = 0);
+    TSQLResult *GetColumns(const char *dbname, const char *table, const char *wild = 0);
+    Int_t       CreateDataBase(const char *dbname);
+    Int_t       DropDataBase(const char *dbname);
+    Int_t       Reload();
+    Int_t       Shutdown();
+    const char *ServerInfo();
+    Bool_t      IsConnected() const;
+
+    TString     GetEntry(const char *where, const char *col=0, const char *table=0) const;
+
+    ClassDef(MSQLServer, 0) // An enhancement of TSQLServer
+};
+
+class MSQLColumn : public MSQLServer
+{
+private:
+    Bool_t IsFolder() const { return kFALSE; }
+
+public:
+    MSQLColumn(TSQLServer *serv, const char *dbname=0, const char *tname=0, const char *col=0)
+        : MSQLServer(serv, dbname, tname, col)
+    {
+    }
+    ClassDef(MSQLColumn, 0) // A workarount to let MSQLServer return kFALSE for IsFolder
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/msql/MSqlInsertRun.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/msql/MSqlInsertRun.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msql/MSqlInsertRun.cc	(revision 9661)
@@ -0,0 +1,512 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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 2/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+////////////////////////////////////////////////////////////////////////
+//
+//  MSqlInsertRun
+//
+//  Input Containers:
+//   MRawRunHeader
+//
+//  Output Containers:
+//    -/-
+//
+////////////////////////////////////////////////////////////////////////
+#include "MSqlInsertRun.h"
+
+#include <TSystem.h>
+
+#include <TSQLResult.h>
+#include <TSQLRow.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MTaskList.h"
+
+#include "MRawFileRead.h"
+#include "MRawRunHeader.h"
+
+#include "MSQLServer.h"
+
+ClassImp(MSqlInsertRun);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+MSqlInsertRun::MSqlInsertRun(const char *db, const char *user, const char *pw)
+    : fIsUpdate(kFALSE)
+{
+    fName  = "MSqlInsertRun";
+    fTitle = "Write run into database";
+
+    *fLog << dbg << "Connecting to: " << db << " as " << user << " <" << pw << ">" << endl;
+
+    fSqlServer = new MSQLServer(db, user, pw);
+}
+
+// --------------------------------------------------------------------------
+//
+MSqlInsertRun::MSqlInsertRun(const char *u)
+    : fSqlServer(0), fIsUpdate(kFALSE)
+{
+    fName  = "MSqlInsertRun";
+    fTitle = "Write run into database";
+
+    fSqlServer = new MSQLServer(u); //::Connect(url, user, pasw);
+}
+
+MSqlInsertRun::~MSqlInsertRun()
+{
+    if (fSqlServer)
+        delete fSqlServer;
+}
+
+Bool_t MSqlInsertRun::PrintError(const char *txt, const char *q) const
+{
+    *fLog << err;
+    *fLog << "Fatal error acessing database: " << txt << endl;
+    fLog->Underline();
+    *fLog << "Query:" << flush << " " << q << endl;
+    return kFALSE;
+}
+
+TString MSqlInsertRun::GetEntry(const char *table, const char *col, const char *where)
+{
+    return fSqlServer->GetEntry(where, col, table);
+}
+
+Bool_t MSqlInsertRun::IsRunExisting(MRawRunHeader *h, Bool_t &exist)
+{
+    exist = kFALSE;
+
+    const TString str(GetEntry("RunData", "fRunNumber", Form("fRunNumber=%d", h->GetRunNumber())));
+    if (str.IsNull())
+        return kFALSE;
+
+    exist = kTRUE;
+    return kTRUE;
+}
+
+Int_t MSqlInsertRun::GetKey(const char *table, const char *where)
+{
+    const TString str(GetEntry(table, Form("f%sKEY", table), where));
+
+    Int_t key;
+    return sscanf(str.Data(), "%d", &key)==1 ? key : -1;
+}
+
+TString MSqlInsertRun::GetKeyStr(const char *table, const char *where, Bool_t &rc)
+{
+    const TString str(GetEntry(table, Form("f%sKEY", table), where));
+    if (str.IsNull())
+        rc = kFALSE;
+
+    return str;
+}
+
+TString MSqlInsertRun::MagicNumber(MRawRunHeader *h, Bool_t &ok)
+{
+    Int_t key = GetKey("MagicNumber", Form("fMagicNumber=%d", h->GetMagicNumber()));
+    if (key<0)
+        key = GetKey("MagicNumber", "fMagicNumber=0xffff");
+    if (key<0)
+    {
+        ok = kFALSE;
+        return TString("");
+    }
+    return TString(Form("%d", key));
+}
+
+TString MSqlInsertRun::RunType(MRawRunHeader *h, Bool_t &ok)
+{
+    Int_t key = GetKey("RunType", Form("fRunType=%d", h->GetRunType()));
+    if (key<0)
+        key = GetKey("RunType", "fRunTye=0xffff");
+    if (key<0)
+    {
+        ok = kFALSE;
+        return TString("");
+    }
+    return TString(Form("%d", key));
+}
+
+TString MSqlInsertRun::Source(MRawRunHeader *h, Bool_t &ok)
+{
+    Int_t key = GetKey("Source", Form("fSourceName='%s'", h->GetSourceName()));
+    if (key<0)
+    {
+        const char *q = Form("INSERT Source (fSourceName, fSourceTxt) VALUES ('%s', 'MSqlInsert: %s')",
+                             h->GetSourceName(), h->GetSourceName());
+
+        TSQLResult *res = fSqlServer->Query(q);
+        if (!res)
+        {
+            ok = kFALSE;
+            return TString("");
+        }
+        key = GetKey("Source", Form("fSourceName='%s'", h->GetSourceName()));
+        if (key>0)
+            *fLog << inf << "New Source '" << h->GetSourceName() << "' inserted into table Source of database." << endl;
+    }
+    else
+    {
+        // FIXME: check for consistency!
+    }
+    if (key<0)
+    {
+        ok = kFALSE;
+        return TString("");
+    }
+
+    return TString(Form("%d", key));
+}
+
+TString MSqlInsertRun::Project(MRawRunHeader *h, Bool_t &ok)
+{
+    Int_t key = GetKey("Project", Form("fProjectName='%s'", h->GetProjectName()));
+    if (key<0)
+    {
+        const char *q = Form("INSERT Project (fProjectName, fProjectTxt) VALUES ('%s', 'MSqlInsert: %s')",
+                             h->GetProjectName(), h->GetProjectName());
+
+        TSQLResult *res = fSqlServer->Query(q);
+        if (!res)
+        {
+            ok = kFALSE;
+            return TString("");
+        }
+        key = GetKey("Project", Form("fProjectName='%s'", h->GetProjectName()));
+        if (key>0)
+            *fLog << inf << "New Project '" << h->GetProjectName() << "' inserted into table Project of database." << endl;
+    }
+    if (key<0)
+    {
+        ok = kFALSE;
+        return TString("");
+    }
+
+    return TString(Form("%d", key));
+}
+
+TString MSqlInsertRun::RawFilePath(const char *path, Bool_t &ok)
+{
+    Int_t key = GetKey("FilePath", Form("fFilePathName='%s'", path));
+    if (key<0)
+    {
+        const char *q = Form("INSERT FilePath (fFilePathName, fFilePath) VALUES ('%s', 'MSqlInsert: %s')",
+                             path, path);
+
+        TSQLResult *res = fSqlServer->Query(q);
+        if (!res)
+        {
+            ok = kFALSE;
+            return TString("");
+        }
+        key = GetKey("FilePath", Form("fFilePathName='%s'", path));
+        if (key>0)
+            *fLog << inf << "New FilePath '" << path << "' inserted into table FilePath of database." << endl;
+
+    }
+    if (key<0)
+    {
+        ok = kFALSE;
+        return TString("");
+    }
+
+    return TString(Form("%d", key));
+}
+/*
+#include <TArrayI.h>
+
+void Line(const TArrayI &max)
+{
+    cout << "+" << setfill('-');
+    for (int i=0; i<max.GetSize(); i++)
+        cout << setw(max[i]+1) << "-" << "-+";
+    cout << endl;
+}
+
+void PrintResult(TSQLResult *res)
+{
+    Int_t n = res->GetFieldCount();
+
+    TArrayI max(n);
+
+    for (int i=0; i<n; i++)
+        max[i] = strlen(res->GetFieldName(i));
+
+    TSQLRow *row;
+
+    TList rows;
+    while ((row=res->Next()))
+    {
+        for (int i=0; i<n; i++)
+            max[i] = TMath::Max((ULong_t)max[i], row->GetFieldLength(i));
+        rows.Add(row);
+    }
+
+    Line(max);
+
+    cout << "|" << setfill(' ');
+    for (int i=0; i<n; i++)
+        cout << setw(max[i]+1) << res->GetFieldName(i) << " |";
+    cout << endl;
+
+    Line(max);
+
+    cout << setfill(' ');
+    TIter Next(&rows);
+    while ((row=(TSQLRow*)Next()))
+    {
+        cout << "|";
+        for (int i=0; i<n; i++)
+        {
+            const char *c = (*row)[i];
+            cout << setw(max[i]+1) << (c?c:"") << " |";
+        }
+        cout << endl;
+    }
+
+    Line(max);
+}
+*/
+Bool_t MSqlInsertRun::InsertRun(MRawRunHeader *h, Bool_t update)
+{
+    // FIXME: Insert input file (PreProcess), output file (PostProcess)
+
+    TString query(update ? "UPDATE" : "INSERT");
+
+    Bool_t ok=kTRUE;
+
+    query += " RunData SET fMagicNumberKEY='";
+    query += MagicNumber(h, ok);
+    query += "', fFormatVersion='";
+    query += h->GetFormatVersion();
+    query += "', fRunTypeKEY='";
+    query += RunType(h, ok);
+    query += "', fRunNumber='";
+    query += h->GetRunNumber();
+    query += "', fProjectKEY='";
+    query += Project(h, ok);
+    query += "', fSourceKEY='";
+    query += Source(h, ok);
+    query += "', fNumEvents='";
+    query += h->GetNumEvents();
+    query += "', fRunStart='";
+    query += h->GetRunStart().GetSqlDateTime();
+    query += "', fRunStop='";
+    query += h->GetRunEnd().GetSqlDateTime();
+    query += "'";
+
+    if (update)
+    {
+        query += " WHERE fRunNumber=";
+        query += h->GetRunNumber();
+    }
+
+    if (!ok)
+    {
+        *fLog << err << "ERROR - while concatenating query..." << endl;
+        *fLog << query << endl;
+        return kFALSE;
+    }
+
+    TSQLResult *res = fSqlServer->Query(query);
+    if (!res)
+        return PrintError("TSQLResult==NULL", query);
+
+    *fLog << inf << dec;
+    *fLog << "Run #" << h->GetRunNumber() << " ";
+    *fLog << (update ? "updated" : "inserted");
+    *fLog << " in database successfully." << endl;
+
+    return kTRUE;
+}
+
+Int_t MSqlInsertRun::GetIndex(MRawRunHeader *h)
+{
+    Bool_t ok=kTRUE;
+
+    TString query("SELECT fRunDataKEY from RunData WHERE fMagicNumberKEY='");
+
+    query += MagicNumber(h, ok);
+    query += "' AND fFormatVersion='";
+    query += h->GetFormatVersion();
+    query += "' AND fRunTypeKEY='";
+    query += RunType(h, ok);
+    query += "' AND fRunNumber='";
+    query += h->GetRunNumber();
+    query += "' AND fProjectKEY='";
+    query += Project(h, ok);
+    query += "' AND fSourceKEY='";
+    query += Source(h, ok);
+    query += "' AND fNumEvents='";
+    query += h->GetNumEvents();
+    query += "' AND fRunStart='";
+    query += h->GetRunStart().GetSqlDateTime();
+    query += "' AND fRunStop='";
+    query += h->GetRunEnd().GetSqlDateTime();
+    query += "'";
+
+    if (!ok)
+    {
+        *fLog << err << "ERROR - while concatenating query..." << endl;
+        *fLog << query << endl;
+        return -1;
+    }
+
+    TSQLResult *res = fSqlServer->Query(query);
+    if (!res)
+        return (PrintError("TSQLResult==NULL", query), -1);
+
+    if (res->GetFieldCount()!=1)
+        return (PrintError("Number of columns != 1", query), -1);
+
+    if (res->GetRowCount()>1)
+        return (PrintError("Number of rows > 1", query), -1);
+
+    if (res->GetRowCount()==0)
+        return 0;
+
+    const char *fld = res->Next()->GetField(0);
+    if (!fld)
+        return (PrintError("Entry is empty", query), -1);
+
+    return atoi(fld);
+}
+
+Bool_t MSqlInsertRun::InsertFile(MRawRunHeader *h, MParList *pList, Bool_t update)
+{
+    const Int_t key = GetIndex(h);
+    if (key<0)
+        return kFALSE;
+
+    if (key==0)
+        return kTRUE;
+
+    MTaskList *tasks = (MTaskList*)pList->FindObject("MTaskList");
+    if (!tasks)
+    {
+        *fLog << err << "MTaskList not found in parameter list... aborting." << endl;
+        return kFALSE;
+    }
+    MRawFileRead *read = (MRawFileRead*)tasks->FindObject("MRawFileRead");
+    if (!read)
+    {
+        *fLog << err << "MRawFileRead not found in task list... aborting." << endl;
+        return kFALSE;
+    }
+
+    const char *base = gSystem->BaseName(read->GetFileName());
+    const char *path = gSystem->DirName(read->GetFileName());
+
+    const TString str(GetEntry("RawFile", "fRawFileName", Form("fRawFileName='%s'", base)));
+    if (!update && !str.IsNull())
+    {
+        *fLog << err << "ERROR - fRawFileName=" << base << " already existing in RawFile... aborting." << endl;
+        return kFALSE;
+    }
+
+    Bool_t ok = kTRUE;
+
+    TString query(update ? "UPDATE" : "INSERT");
+    query += " RawFile SET fRawFileName='";
+    query += base;
+    query += "', fFilePathKEY=";
+    query += RawFilePath(path, ok);
+    query += ", fRawFileKEY=";
+    query += key;
+
+    if (!ok)
+    {
+        *fLog << err << "ERROR - while concatenating query..." << endl;
+        *fLog << query << endl;
+        return kFALSE;
+    }
+
+    TSQLResult *res = fSqlServer->Query(query);
+    if (!res)
+        return PrintError("TSQLResult==NULL", query);
+
+    *fLog << inf << dec;
+    *fLog << "File '" << base << "' ";
+    *fLog << (update ? "updated" : "inserted");
+    *fLog << " in database successfully." << endl;
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+Int_t MSqlInsertRun::PreProcess(MParList *pList)
+{
+    if (!fSqlServer)
+    {
+        *fLog << err << "Connection to SQL server failed... aborting." << endl;
+        return kFALSE;
+    }
+
+    MRawRunHeader *header = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
+    if (!header)
+    {
+        *fLog << err << "MRawRunHeader not found... aborting." << endl;
+        return kFALSE;
+    }
+/*
+    if (header->GetFormatVersion()<3)
+    {
+        *fLog << err << "MSqlInsertRun cannot be used for files with format <3... abort." << endl;
+        return kTRUE;
+    }
+ */
+    Bool_t update = kFALSE;
+
+    // Is run already in databae?
+    const TString str(GetEntry("MRawRunHeader", "fRunNumber", Form("fRunNumber=%d", header->GetRunNumber())));
+    if (!str.IsNull())
+    {
+        if (!fIsUpdate)
+        {
+            *fLog << err << "Run #" << dec << header->GetRunNumber() << " already in database... abort." << endl;
+            return kFALSE;
+        }
+        update=kTRUE;
+    }
+
+    if (!InsertRun(header, update))
+        return kFALSE;
+
+    if (!InsertFile(header, pList, update))
+        return kFALSE;
+
+    return kTRUE;
+}
+
+Int_t MSqlInsertRun::PostProcess()
+{
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/msql/MSqlInsertRun.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/msql/MSqlInsertRun.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msql/MSqlInsertRun.h	(revision 9661)
@@ -0,0 +1,51 @@
+#ifndef MARS_MRawRunInsertSql
+#define MARS_MRawRunInsertSql
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MSQLServer;
+
+class MRawRunHeader;
+
+class MSqlInsertRun : public MTask
+{
+private:
+    MSQLServer *fSqlServer;
+
+    Bool_t fIsUpdate;
+
+    Int_t   GetIndex(MRawRunHeader *h);
+    Int_t   GetKey(const char *table, const char *where);
+    TString GetKeyStr(const char *table, const char *where, Bool_t &rc);
+    TString GetEntry(const char *table, const char *col, const char *where);
+
+    Bool_t  IsRunExisting(MRawRunHeader *h, Bool_t &ok);
+    Bool_t  IsFileExisting(MRawRunHeader *h, Bool_t &ok);
+
+    TString MagicNumber(MRawRunHeader *h, Bool_t &ok);
+    TString RunType(MRawRunHeader *h, Bool_t &ok);
+    TString Source(MRawRunHeader *h, Bool_t &ok);
+    TString Project(MRawRunHeader *h, Bool_t &ok);
+    TString RawFilePath(const char *path, Bool_t &ok);
+
+    Bool_t InsertRun(MRawRunHeader *h, Bool_t update);
+    Bool_t InsertFile(MRawRunHeader *h, MParList *pList, Bool_t update);
+
+    Int_t  PreProcess(MParList *pList);
+    Int_t  PostProcess();
+
+    Bool_t PrintError(const char *txt, const char *q) const;
+
+public:
+    MSqlInsertRun(const char *db, const char *user, const char *pw);
+    MSqlInsertRun(const char *url);
+    ~MSqlInsertRun();
+
+    void SetUpdate(Bool_t u=kTRUE) { fIsUpdate=u; }
+
+    ClassDef(MSqlInsertRun, 0) // Task to insert run into database
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/msql/Makefile
===================================================================
--- /tags/Mars_V0-8-5/Mars/msql/Makefile	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msql/Makefile	(revision 9661)
@@ -0,0 +1,33 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+############################################################
+
+#
+# Handling name of the Root Dictionary Files
+#
+CINT  = Sql
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES = -I. -I../mbase -I../mraw -I../mfileio
+
+SRCFILES = \
+	MSQLServer.cc \
+	MSqlInsertRun.cc
+
+############################################################
+
+all: $(OBJS)
+
+include ../Makefile.rules
+
+mrproper:	clean rmbak
Index: /tags/Mars_V0-8-5/Mars/msql/SqlIncl.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/msql/SqlIncl.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msql/SqlIncl.h	(revision 9661)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-8-5/Mars/msql/SqlLinkDef.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/msql/SqlLinkDef.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/msql/SqlLinkDef.h	(revision 9661)
@@ -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 MSqlInsertRun+;
+
+#pragma link C++ class MSQLColumn+;
+#pragma link C++ class MSQLServer+;
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtemp/Changelog
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/Changelog	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/Changelog	(revision 9661)
@@ -0,0 +1,216 @@
+Please  do  not write behind the end of line tag so that it is  possible
+to   send  a   Changelog   file  to  a  line  printer  directly.  Thanks.
+
+For your entries please follow this style:
+
+_yyyy/mm/dd:_[Your Name]
+_
+___*_filename:
+_____-_description
+_
+___*_filename2, filename3:
+_____-_description
+_
+_
+_
+
+While an underscore is a placeholder for a white-space or an empty line.
+
+                                                 -*-*- END OF LINE -*-*-
+ 2004/08/05: Robert Wagner
+
+   * mtemp/mmpi/MSourceDirections.[h,cc]
+     - Converts objects given by their sky coordinates into 
+       camera coordinates by using MAstroCamera the same way
+       as MFindStars does.
+
+
+ 2004/08/02: Robert Wagner
+
+   * mtemp/mmpi/MFindStars.[h,cc]
+     - Functionality for finding stars by using stars from star catalog
+   
+   * mtemp/mmpi/MAstroCamera.[h,cc]
+     - Filling stars into a MStarLocalCam instead of painting them
+       (Functionality also in mastro/MAsstroCamera.[h,cc], but 
+       commented out there since MStarLocalCam not part of standard
+       MARS)
+
+   * mtemp/mmpi/macros/findstars.C
+     - sample macro for determining star positions (both with and 
+       without using a star catalog)
+
+   * mtemp/mmpi/macros/bsc5.dat
+     - Bright star catalog as used by findstars.C
+
+
+ 2004/07/30: Nicola Galante
+
+   * mtemp/mpisa/macros/AnalCurrents.C
+      - Added new macros AnalCurrents.C which reads DC files
+        and looks for DC clusters. Still preliminary! 
+        It currently just looks for starting pixels of clusters.
+
+ 2004/07/22: Sabrina Stark
+
+   * /mtemp/meth/MFindStars.[h,cc]
+      - new fit function, incl. constant background and rotation of 
+	2d gauss
+      - initialization of MAstroCamera
+      - new functions: 
+	     - CorrSourcePos -> calculates a corrected
+	       source position using the images of two stars
+	     - DistBetweenStars -> calculates the distances between
+	       two stars and the source
+	
+   * /mtemp/meth/MAstroCamera.[h,cc]
+      - TList *fCatList: list with star positions from catalog
+      - new functions: 
+	     - StarPosInCamera (similar to FillStarList, but
+               incl. aberration)
+      - GetCatList -> Access function to fCatList
+
+   * /mtemp/meth/MStarLocalPos.[h,cc]
+      - in function SetFitValue -> background included
+	
+
+   * /mtemp/meth/macros/CorrectSrcPos.C
+      - macro to calculate a corrected source position using
+	the images of two stars, these positions are written
+	to an output file
+
+	
+ 2004/07/20: David Paneque
+
+   * /mtemp/mmpi/SupercutsONOFFClasses directory containing the 
+   classes needed to optimize supercuts (and extract gamma signal) 
+   using the ON and OFF data. These classes are listed below:
+
+   MFRandomSplit.cc     
+   MSupercutsCalcONOFF.cc 
+   MTSupercutsApplied.cc
+   MHFindSignificanceONOFF.cc       
+   MFindSupercutsONOFFThetaLoop.cc 
+   MFindSupercutsONOFF.cc 
+
+   In order to add (to the compiled mars version) these classes you must add the 
+   following line to the SUBDIRS field of the general Makefile
+
+   mtemp/mmpi/SupercutsONOFFClasses
+
+
+   And that's it. It should compile without problems... there is no interference 
+   with the other classes.
+
+   I also add few macros (in the directory /mtemp/mmpi/macros/) which should help 
+   the user to use (correctly) the mentioned classes. 
+
+   SuperCutsONOFFMacro.C
+   SCDynamicalSupercutsApplied.C
+   SCNexSignificanceVSAlphaCut.C
+   
+   
+   The whole analysis is set and executed by running the macro  SuperCutsONOFFMacro.C.
+   I wrote quite some comments on it; it should be self-explanatory. 
+   The macro SCDynamicalSupercutsApplied.C can be used to make a quick 
+   inspection to the cuts applied to the events that survived the cuts, and the 
+   macro    SCNexSignificanceVSAlphaCut.C plots the significance and the excess events 
+   vs the cut in the ALPHA parameter.
+
+   I also included the directory mtemp/mmpi/asciifiles containing ascii files with 
+   some initial supercuts values and the optimized supercuts for Mkn421 Feb 15, 
+   that are used as input for the supercuts ON-OFF analysis.
+						 
+
+ 2004/06/29: Javier Rico
+
+   * MIslands.[h,cc], MIslandCalc.[h,cc]
+      - Remove obsolete versions of these classes whose up-to-date ver-
+	sions are available at mifae/library
+
+
+ 2004/06/26: Eva Domingo - Pepe Flix
+
+   * mifae/library/MDisp.[h,cc]
+   * mifae/library/MDispCalc.[h,cc]
+      - Added classes for evaluation of DISP method.
+
+ 2004/06/25: Sebastian Commichau
+
+   * meth/macros/analysis.C 
+      -Added macro to analyze data
+
+   * meth/macros/analysis_read.C 
+      -Added macro that reads the output of analysis.C	
+
+ 2004/06/24: Nicola Galante
+
+   * mpisa/macros/AlphaPlot.C
+     -Added a new macro to plot eccess in alpha
+
+ 2004/05/26: Nicola Galante
+
+   * mpisa/macros/timedist3.C
+     - Added a new macro to plot signal time distributions
+
+ 2004/05/26: Nicola Galante
+
+   * mpisa/macros/production3.C
+     - Added a new production macro. It is based on 
+       bootcampstandardanalisys.C
+
+ 2004/05/23: Thomas Hengstebeck
+   * mberlin/macros/ScaleHillas.C , SrcCorrect.C , Convert2Matrix.C , 
+     CutOptim.C , AlphaPlot.C , IOMkn421.h
+     - Added analysis macros
+
+
+ 2004/05/18: Daniel Mazin
+   * mmpi/macros/hillasread.C  
+     - Removed a small bug
+
+   * mmpi/macros/callalphaplot.C
+     - Added. macro to produce an alpha plot for a chosen position in the sky map
+     - Derotation is possible if theta and phi for each event are available 
+     - Using OFF data to estimate significance is optional 
+
+ 2004/05/18: Sebastian Commichau
+   * meth/MHillasSrc.cc/h
+     - Added. This is a modified version, containing now
+       the DCA parameter.
+
+   * meth/MDCACalc.cc/h, MDCA.cc/h
+     - Added. Based on MHillasCalc/MHillas, it calculates
+       the DCA parameter and provides a nice draw function
+
+ 2004/05/17: Daniel Mazin
+   * mmpi/macros 
+     - Added to put analysis macros there
+
+   * mmpi/macros/callcleaning.C , cleaninghillas.C
+     - Added. macros to make cleaning and calculate Hillas parameters
+	
+   * mmpi/macros/mtools.C
+     -Added. some simple mathematical functions 
+
+   * mmpi/macros/falsesourcemethod.C, skyplot.h, hillasread.C, gridloop.C
+     -Added. macros to produce 2D plots of False Source Method 
+
+ 2004/04/28: Javier Rico
+   * mifae/Changelog
+     - Added. Next changes in directory mifae will be reported 
+       exclusively in there
+
+	
+ 2004/04/27: Javier Rico
+   * mifae
+     - Add new directory for IFAE temporal stuff
+	
+   * mifae/Makefile,IFAEIncl.h,IFAELinkDef.h
+     - Add basic stuff to run the directory
+	
+   * mifae/MDCA.[h,cc]
+     - Add Commichau & Starks's MDCA (provisional)
+
+   * mifae/makeHillas.cc,makehillas.datacard
+     - Add program to generate hillas parameters' file
Index: /tags/Mars_V0-8-5/Mars/mtemp/MFindStars.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/MFindStars.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/MFindStars.cc	(revision 9661)
@@ -0,0 +1,900 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!   Author(s): Robert Wagner, 2/2004 <mailto:rwagner@mppmu.mpg.de>
+!   Author(s): Javier López , 4/2004 <mailto:jlopez@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MFindStars
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MFindStars.h"
+
+#include <TMinuit.h>
+#include <TStopwatch.h>
+#include <TTimer.h>
+#include <TString.h>
+#include <TFile.h>
+#include <TTree.h>
+#include <TCanvas.h>
+#include <TH1F.h>
+#include <TF1.h>
+
+#include "MObservatory.h"
+#include "MAstroCamera.h"
+#include "MMcConfigRunHeader.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MHCamera.h"
+
+#include "MGeomCam.h"
+#include "MGeomPix.h"
+#include "MCameraDC.h"
+#include "MTime.h"
+#include "MReportDrive.h"
+#include "MStarLocalCam.h"
+#include "MStarLocalPos.h"
+
+#include "MParList.h"
+#include "MTaskList.h"
+
+ClassImp(MFindStars);
+using namespace std;
+
+const Float_t sqrt2 = sqrt(2.);
+const Float_t sqrt3 = sqrt(3.);
+const UInt_t  lastInnerPixel = 396;
+    
+
+//______________________________________________________________________________
+//
+// The 2D gaussian fucntion used to fit the spot of the star
+//
+static Double_t func(float x,float y,Double_t *par)
+{
+    Double_t value=par[0]*exp(-(x-par[1])*(x-par[1])/(2*par[2]*par[2]))*exp(-(y-par[3])*(y-par[3])/(2*par[4]*par[4]));
+    return value;
+}
+
+//______________________________________________________________________________
+//
+// Function used by Minuit to do the fit
+//
+static void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)
+{
+
+  MParList*      plist = (MParList*)gMinuit->GetObjectFit();
+  MTaskList*     tlist = (MTaskList*)plist->FindObject("MTaskList");
+  MFindStars*    find = (MFindStars*)tlist->FindObject("MFindStars");
+  MStarLocalCam* stars = (MStarLocalCam*)plist->FindObject("MStarLocalCam");
+  MGeomCam*      geom = (MGeomCam*)plist->FindObject("MGeomCam");
+
+  MHCamera& display = (MHCamera&)find->GetDisplay();
+  
+  Float_t innerped = stars->GetInnerPedestalDC();
+  Float_t innerrms = stars->GetInnerPedestalRMSDC();
+  Float_t outerped = stars->GetOuterPedestalDC();
+  Float_t outerrms = stars->GetOuterPedestalRMSDC();
+
+  UInt_t numPixels = geom->GetNumPixels();
+  
+//calculate chisquare
+    Double_t chisq = 0;
+    Double_t delta;
+    Double_t x,y,z;
+    Double_t errorz=0;
+
+    UInt_t usedPx=0;
+    for (UInt_t pixid=1; pixid<numPixels; pixid++) 
+    {
+	if (display.IsUsed(pixid))
+	{
+	    x = (*geom)[pixid].GetX();
+	    y = (*geom)[pixid].GetY();
+            z = display.GetBinContent(pixid+1)-(pixid>lastInnerPixel?outerped:innerped);
+            errorz=(pixid>lastInnerPixel?outerrms:innerrms);
+
+	    if (errorz > 0.0)
+	    {
+              usedPx++;
+              delta  = (z-func(x,y,par))/errorz;
+              chisq += delta*delta;
+	    }
+	    else
+		cerr << " TMinuit::fcn errorz[" << pixid << "] " << errorz << endl;
+	}
+    }
+    f = chisq;
+
+    find->SetChisquare(chisq);
+    find->SetDegreesofFreedom(usedPx);
+}
+
+MFindStars::MFindStars(const char *name, const char *title): 
+  fGeomCam(NULL), fCurr(NULL), fTimeCurr(NULL), fDrive(NULL), fStars(NULL), fNumVar(5)
+{
+  fName  = name  ? name  : "MFindStars";
+  fTitle = title ? title : "Tool to find stars from DC Currents";
+
+  fNumIntegratedEvents=0;
+  fMaxNumIntegratedEvents = 10;
+  fRingInterest = 125.; //[mm] ~ 0.4 deg
+  fDCTailCut = 4;
+  
+  fPixelsUsed.Set(577);
+  fPixelsUsed.Reset((Char_t)kTRUE);
+  
+  //Fitting(Minuit) initialitation
+  const Float_t pixelSize = 31.5; //[mm]
+  fMinuitPrintOutLevel = -1;
+  
+  fVname = new TString[fNumVar];
+  fVinit.Set(fNumVar); 
+  fStep.Set(fNumVar); 
+  fLimlo.Set(fNumVar); 
+  fLimup.Set(fNumVar); 
+  fFix.Set(fNumVar);
+
+  fVname[0] = "max";
+  fVinit[0] = 10.*fMaxNumIntegratedEvents;
+  fStep[0]  = fVinit[0]/sqrt2;
+  fLimlo[0] = fMinDCForStars;
+  fLimup[0] = 30.*fMaxNumIntegratedEvents;
+  fFix[0]   = 0;
+
+  fVname[1] = "meanx";
+  fVinit[1] = 0.;
+  fStep[1]  = fVinit[1]/sqrt2;
+  fLimlo[1] = -600.;
+  fLimup[1] = 600.;
+  fFix[1]   = 0;
+
+  fVname[2] = "sigmaminor";
+  fVinit[2] = pixelSize;
+  fStep[2]  = fVinit[2]/sqrt2;
+  fLimlo[2] = pixelSize/(2*sqrt3);
+  fLimup[2] = 500.;
+  fFix[2]   = 0;
+
+  fVname[3] = "meany";
+  fVinit[3] = 0.;
+  fStep[3]  = fVinit[3]/sqrt2;
+  fLimlo[3] = -600.;
+  fLimup[3] = 600.;
+  fFix[3]   = 0;
+
+  fVname[4] = "sigmamajor";
+  fVinit[4] = pixelSize;
+  fStep[4]  = fVinit[4]/sqrt2;
+  fLimlo[4] = pixelSize/(2*sqrt3);
+  fLimup[4] = 500.;
+  fFix[4]   = 0;
+
+  fObjectFit  = NULL;
+  //  fMethod     = "SIMPLEX";
+  fMethod     = "MIGRAD";
+  //  fMethod     = "MINIMIZE";
+  fNulloutput = kFALSE;
+
+  // Set output level
+  //  fLog->SetOutputLevel(3); // No dbg messages
+}
+
+Int_t MFindStars::PreProcess(MParList *pList)
+{
+
+    fGeomCam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
+
+    if (!fGeomCam)
+    {
+      *fLog << err << AddSerialNumber("MGeomCam") << " not found ... aborting" << endl;
+      return kFALSE;
+    }
+
+    // Initialize camera display with the MGeomCam information
+    fDisplay.SetGeometry(*fGeomCam,"FindStarsDisplay","FindStarsDisplay");
+    fDisplay.SetUsed(fPixelsUsed);
+
+    fCurr = (MCameraDC*)pList->FindObject(AddSerialNumber("MCameraDC"));
+
+    if (!fCurr)
+    {
+      *fLog << err << AddSerialNumber("MCameraDC") << " not found ... aborting" << endl;
+      return kFALSE;
+    }
+
+    fTimeCurr = (MTime*)pList->FindObject(AddSerialNumber("MTimeCurrents"));
+
+    if (!fTimeCurr)
+    {
+      *fLog << err << AddSerialNumber("MTimeCurrents") << " not found ... aborting" << endl;
+      return kFALSE;
+    }
+
+    //    fDrive = (MReportDrive*)pList->FindObject(AddSerialNumber("MReportDrive"));
+
+    if (!fDrive)
+      {
+        *fLog << warn << AddSerialNumber("MReportDrive") << " not found ... ignored." << endl;
+      }
+    else
+      {
+//         //Initialitation MAstroCamera
+//         // Name of a MC file having MGeomCam and MMcConfigRunHeader
+//         TString fname = "../data/Gamma_zbin9_90_7_1480to1489_w0.root";
+
+//         // Time for which to get the picture
+//         //    MTime time;
+//         //    time.Set(2004, 2, 28, 01, 32, 15);
+        
+//         // Current observatory
+//         MObservatory magic1;
+        
+//         // Right Ascension [h] and declination [deg] of source
+//         // Currently 'perfect' pointing is assumed
+//         //    const Double_t ra  = MAstro::Hms2Rad(5, 34, 31.9);
+//         //    const Double_t dec = MAstro::Dms2Rad(22, 0, 52.0);
+
+//         // --------------------------------------------------------------------------
+//         // Create camera display from geometry
+//         MMcConfigRunHeader *config=0;
+//         MGeomCam           *geom=0;
+        
+//         TFile file(fname);
+//         TTree *tree = (TTree*)file.Get("RunHeaders");
+//         tree->SetBranchAddress("MMcConfigRunHeader", &config);
+//         if (tree->GetBranch("MGeomCam"))
+//           tree->SetBranchAddress("MGeomCam", &geom);
+//         tree->GetEntry(0);
+        
+//         fAstro.SetMirrors(*config->GetMirrors());
+//         fAstro.SetGeom(*geom);
+        
+        
+//         fAstro.SetLimMag(6);
+//         fAstro.SetRadiusFOV(3);
+//         fAstro.ReadBSC("../data/bsc5.dat");
+        
+//         fAstro.SetObservatory(magic1);
+//         // Time for which to get the picture
+//         //    MTime time;
+//         //    time.Set(2004, 2, 28, 01, 32, 15);
+//         //   fAstro.SetTime(time);
+//         fAstro.SetTime(*fTimeCurr);
+//         fAstro.SetGuiActive();
+        
+//         fAstro.SetStarList(fStars->GetList());
+        
+      }
+    
+
+    fStars = (MStarLocalCam*)pList->FindCreateObj(AddSerialNumber("MStarLocalCam"));
+    if (!fStars)
+    {
+      *fLog << err << AddSerialNumber("MStarLocalCam") << " cannot be created ... aborting" << endl;
+      return kFALSE;
+    }
+
+    fMinDCForStars = 1.*fMaxNumIntegratedEvents; //[uA]
+
+    // Initialize the TMinuit object
+
+    TMinuit *gMinuit = new TMinuit(fNumVar);  //initialize TMinuit with a maximum of params
+    gMinuit->SetFCN(fcn);
+
+    Double_t arglist[10];
+    Int_t ierflg = 0;
+
+    arglist[0] = 1;
+    gMinuit->mnexcm("SET ERR", arglist ,1,ierflg);
+    arglist[0] = fMinuitPrintOutLevel;
+    gMinuit->mnexcm("SET PRI", arglist ,1,ierflg);
+
+    // Set MParList object pointer to allow mimuit to access internally
+    gMinuit->SetObjectFit(pList);
+
+    return kTRUE;
+}
+
+Int_t MFindStars::Process()
+{
+
+  UInt_t numPixels = fGeomCam->GetNumPixels();
+  TArrayC origPixelsUsed;
+  origPixelsUsed.Set(numPixels);
+
+    if (fNumIntegratedEvents >= fMaxNumIntegratedEvents)
+    {
+
+      if (fDrive)
+        {
+//           Float_t ra  = fDrive->GetRa();
+//           Float_t dec = fDrive->GetDec();
+          
+//           fAstro.SetRaDec(ra, dec);
+//           fAstro.SetGuiActive();
+          
+//           fAstro.FillStarList();
+        }
+      else
+        {
+          //Fist delete the previus stars in the list
+          fStars->GetList()->Delete();
+          //
+
+          for (UInt_t pix=1; pix<numPixels; pix++)
+            {
+              if (fDisplay.IsUsed(pix))
+                origPixelsUsed[pix]=(Char_t)kTRUE;
+              else
+                  origPixelsUsed[pix]=(Char_t)kFALSE;
+            }
+          
+	  if (DCPedestalCalc())
+            {
+
+              Float_t innermin = fStars->GetInnerPedestalDC()+fDCTailCut*fStars->GetInnerPedestalRMSDC();
+              Float_t outermin = fStars->GetOuterPedestalDC()+fDCTailCut*fStars->GetOuterPedestalRMSDC();
+              fMinDCForStars = innermin>outermin?innermin:outermin;
+              if (fMinuitPrintOutLevel>=0) *fLog << dbg << "fMinDCForStars = " << fMinDCForStars << endl;
+              
+              // Find the star candidats searching the most brights pairs of pixels
+              Float_t maxPixelDC;
+              MGeomPix maxPixel;
+
+              while(FindPixelWithMaxDC(maxPixelDC, maxPixel))
+                {
+                  
+                  MStarLocalPos *starpos = new MStarLocalPos;
+                  starpos->SetExpValues(maxPixelDC,maxPixel.GetX(),maxPixel.GetY());
+                  starpos->SetCalcValues(maxPixelDC,maxPixelDC,maxPixel.GetX(),maxPixel.GetY(),fRingInterest/2,fRingInterest/2);
+                  starpos->SetFitValues(maxPixelDC,maxPixelDC,maxPixel.GetX(),maxPixel.GetY(),fRingInterest/2,fRingInterest/2,0.,1);
+                  fStars->GetList()->Add(starpos);
+                  
+                  ShadowStar(starpos);
+                  
+                }
+              
+              fDisplay.SetUsed(origPixelsUsed);
+            }
+          
+        }
+      
+      //loop to extract position of stars on the camera
+      if (fStars->GetList()->GetSize() == 0)
+        {
+          *fLog << err << GetName() << " No stars candidates in the camera." << endl;
+          return kCONTINUE;
+        }
+      else
+          *fLog << inf << GetName() << " Found " << fStars->GetList()->GetSize() << " stars candidates in the camera." << endl;
+          
+
+      for (UInt_t pix=1; pix<numPixels; pix++)
+        {
+          if (fDisplay.IsUsed(pix))
+            origPixelsUsed[pix]=(Char_t)kTRUE;
+          else
+            origPixelsUsed[pix]=(Char_t)kFALSE;
+        }
+
+      TIter Next(fStars->GetList());
+      MStarLocalPos* star;
+      while ((star=(MStarLocalPos*)Next()))
+        {
+          FindStar(star);
+          ShadowStar(star);
+        }
+      
+      //After finding stars reset all vairables
+      fDisplay.Reset();
+      fStars->GetDisplay().Reset(); //FIXME: Put this display just in the container
+      fDisplay.SetUsed(origPixelsUsed);
+      fNumIntegratedEvents=0;
+    }
+
+    for (UInt_t pix=1; pix<numPixels; pix++)
+      {
+        if (fDisplay.IsUsed(pix))
+          origPixelsUsed[pix]=(Char_t)kTRUE;
+        else
+          origPixelsUsed[pix]=(Char_t)kFALSE;
+        
+      }
+
+    fDisplay.AddCamContent(*fCurr);
+    fNumIntegratedEvents++;
+    fDisplay.SetUsed(origPixelsUsed);
+    
+
+  return kTRUE;
+}
+
+Int_t MFindStars::PostProcess()
+{
+  return kTRUE;
+}
+
+void MFindStars::SetBlindPixels(TArrayS blindpixels)
+{
+    Int_t npix = blindpixels.GetSize();
+
+    for (Int_t idx=0; idx<npix; idx++)
+      {
+	fPixelsUsed[blindpixels[idx]]=(Char_t)kFALSE;
+        if (fMinuitPrintOutLevel>=0) *fLog << dbg << "MFindStars::SetBlindPixels fDisplay.IsUsed(" <<blindpixels[idx]  << ") kFALSE" << endl;
+      }
+    
+    fDisplay.SetUsed(fPixelsUsed);
+}
+
+Bool_t MFindStars::DCPedestalCalc()
+{
+    //-------------------------------------------------------------
+    // save pointer to the MINUIT object for optimizing the supercuts
+    // because it will be overwritten 
+    // when fitting the alpha distribution in MHFindSignificance
+    TMinuit *savePointer = gMinuit;
+    //-------------------------------------------------------------
+
+   UInt_t numPixels = fGeomCam->GetNumPixels();
+   Float_t ped;
+   Float_t rms;
+
+   TH1F **dchist = new TH1F*[2];
+   for (UInt_t i=0; i<2; i++)
+      dchist[i] = new TH1F("","",26,0.4*fMaxNumIntegratedEvents,3.*fMaxNumIntegratedEvents);
+   
+   for (UInt_t pix=1; pix<=lastInnerPixel; pix++)
+       dchist[0]->Fill(fDisplay.GetBinContent(pix+1));
+   for (UInt_t pix=lastInnerPixel+1; pix<numPixels; pix++)
+       dchist[1]->Fill(fDisplay.GetBinContent(pix+1));
+
+   // inner/outer pixels
+   for (UInt_t i=0; i<2; i++)
+    {
+      Float_t nummaxprobdc = dchist[i]->GetBinContent(dchist[i]->GetMaximumBin());
+      Float_t maxprobdc = dchist[i]->GetBinCenter(dchist[i]->GetMaximumBin());
+      UInt_t bin = dchist[i]->GetMaximumBin();
+      do
+        {
+          bin++;
+        }
+      while(dchist[i]->GetBinContent(bin)/nummaxprobdc > 0.5);
+      Float_t halfmaxprobdc = dchist[i]->GetBinCenter(bin);
+      
+      if (fMinuitPrintOutLevel>=0) *fLog << dbg << " maxprobdc[high] " << maxprobdc << "[" << nummaxprobdc << "] ";
+      if (fMinuitPrintOutLevel>=0) *fLog << dbg << " halfmaxprobdc[high] " << halfmaxprobdc << "[" << dchist[i]->GetBinContent(bin) << "]" << endl;
+      
+      Float_t rmsguess = TMath::Abs(maxprobdc-halfmaxprobdc);
+      Float_t min = maxprobdc-3*rmsguess;
+      min = (min<0.?0.:min);
+      Float_t max = maxprobdc+3*rmsguess;
+      
+      if (fMinuitPrintOutLevel>=0) *fLog << dbg << " maxprobdc " << maxprobdc << " rmsguess " << rmsguess << endl;
+      
+      TF1 func("func","gaus",min,max);
+      func.SetParameters(nummaxprobdc, maxprobdc, rmsguess);
+      
+      dchist[i]->Fit("func","QR0");
+      
+      UInt_t aproxnumdegrees = 6*(bin-dchist[i]->GetMaximumBin());
+      Float_t chiq = func.GetChisquare();
+      ped = func.GetParameter(1);
+      rms = func.GetParameter(2);
+      
+      if (fMinuitPrintOutLevel>=0) *fLog << dbg << " ped " << ped << " rms " << rms << " chiq/ndof " << chiq << "/" << aproxnumdegrees << endl;
+      
+      Int_t numsigmas = 5;
+      Axis_t minbin = ped-numsigmas*rms/dchist[i]->GetBinWidth(1);
+      minbin=minbin<1?1:minbin;
+      Axis_t maxbin = ped+numsigmas*rms/dchist[i]->GetBinWidth(1);
+      if (fMinuitPrintOutLevel>=0) *fLog << dbg << " Number of pixels with dc under " << numsigmas << " sigmas = " << dchist[i]->Integral((int)minbin,(int)maxbin) << endl;
+      
+      //Check results from the fit are consistent
+      if (ped < 0. || rms < 0.)
+        {
+          *fLog << dbg << "dchist[i]->GetEntries()" << dchist[i]->GetEntries();
+        }
+      else if (TMath::Abs(ped-maxprobdc) > rmsguess || rms > rmsguess)
+        {
+          *fLog << warn << GetName() << " Pedestal DC fit give non consistent results for " << (i==0?"Inner":"Outer") << "pixels." << endl;
+          *fLog << warn << " maxprobdc " << maxprobdc << " rmsguess " << rmsguess << endl;
+          *fLog << warn << " ped " << ped << " rms " << rms << " chiq/ndof " << chiq << "/" << aproxnumdegrees << endl;
+          ped = maxprobdc;
+          rms = rmsguess/1.175; // FWHM=2.35*rms
+        }
+   
+//       TCanvas *c1 = new TCanvas("c2","c2",500,800);
+//       dchist[i]->Draw();
+//       c1->Print("dchist.ps");
+//       getchar();
+//       delete c1;
+//       exit(1);
+
+      if (i == 0)
+        {
+          fStars->SetInnerPedestalDC(ped);
+          fStars->SetInnerPedestalRMSDC(rms);
+        }
+      else
+        {
+          fStars->SetOuterPedestalDC(ped);
+          fStars->SetOuterPedestalRMSDC(rms);
+        }
+
+      
+
+    }
+   
+
+   for (UInt_t i=0; i<2; i++)
+      delete dchist[i];
+   delete [] dchist;
+
+   //=================================================================
+
+   // reset gMinuit to the MINUIT object for optimizing the supercuts 
+   gMinuit = savePointer;
+   //-------------------------------------------
+   
+   if (fStars->GetInnerPedestalDC() < 0. ||  fStars->GetInnerPedestalRMSDC() < 0. || fStars->GetOuterPedestalDC() < 0. ||  fStars->GetOuterPedestalRMSDC() < 0.)
+     return kFALSE;
+  
+   return kTRUE;
+}
+    
+Bool_t MFindStars::FindPixelWithMaxDC(Float_t &maxDC, MGeomPix &maxPix)
+{
+    UInt_t numPixels = fGeomCam->GetNumPixels();
+
+// Find the two close pixels with the maximun dc
+    UInt_t maxPixIdx[2];
+
+    maxDC = 0;
+
+    for (UInt_t pix=1; pix<numPixels; pix++)
+    {
+	if(fDisplay.IsUsed(pix))
+	{
+	    Float_t dc[2];
+	    dc[0] = fDisplay.GetBinContent(pix+1);
+	    if (dc[0] < fMinDCForStars)
+		continue;
+
+	    MGeomPix &g = (*fGeomCam)[pix];
+	    Int_t numNextNeighbors = g.GetNumNeighbors();
+	    
+	    Float_t dcsum;
+	    for(Int_t nextNeighbor=0; nextNeighbor<numNextNeighbors; nextNeighbor++)
+	    {
+              UInt_t swneighbor = g.GetNeighbor(nextNeighbor);
+              if(fDisplay.IsUsed(swneighbor))
+                {
+                  dc[1] = fDisplay.GetBinContent(swneighbor+1);
+                  if (dc[1] < fMinDCForStars)
+                    continue;
+                  
+                  dcsum = dc[0] + dc[1];
+                  
+                  if(dcsum > maxDC*2)
+                    {
+                      if(dc[0]>=dc[1])
+                        {
+                          maxPixIdx[0] = pix;
+                          maxPixIdx[1] = swneighbor;
+                          maxDC = dc[0];
+                        }
+                      else
+                        {
+                          maxPixIdx[1] = pix;
+                          maxPixIdx[0] = swneighbor;
+                          maxDC = dc[1];
+                        }
+                    }	
+                }
+            }
+        }
+    }
+
+    if (maxDC == 0)
+      {
+        *fLog << warn << " No found pixels with maximum dc" << endl;
+	return kFALSE;
+      }
+    
+    maxPix = (*fGeomCam)[maxPixIdx[0]];
+
+    if (fMinuitPrintOutLevel>=0) *fLog << dbg << "Star candidate maxDC(" << setw(3) << maxDC << " uA) x position(" << setw(3) << maxPix.GetX() <<  " mm) x position(" << setw(3) << maxPix.GetY() << " mm) swnumber(" << maxPixIdx[0] << ")" << endl;
+
+    return kTRUE;
+}
+
+Bool_t MFindStars::FindStar(MStarLocalPos* star)
+{    
+
+  UInt_t numPixels = fGeomCam->GetNumPixels();
+  Float_t innerped = fStars->GetInnerPedestalDC();
+  Float_t outerped = fStars->GetOuterPedestalDC();
+
+  TArrayC origPixelsUsed;
+  origPixelsUsed.Set(numPixels);
+  
+  for (UInt_t pix=1; pix<numPixels; pix++)
+    {
+      if (fDisplay.IsUsed(pix))
+        origPixelsUsed[pix]=(Char_t)kTRUE;
+      else
+        origPixelsUsed[pix]=(Char_t)kFALSE;
+    }
+  
+  Float_t expX = star->GetXExp();
+  Float_t expY = star->GetYExp();
+  
+  Float_t max=0;
+  UInt_t  pixmax=0;
+  Float_t meanX=0;
+  Float_t meanY=0;
+  Float_t meanSqX=0;
+  Float_t meanSqY=0;
+  Float_t sumCharge=0;
+  UInt_t usedInnerPx=0;	
+  UInt_t usedOuterPx=0;	
+
+  const Float_t meanPresition = 3.; //[mm]
+  const UInt_t maxNumIterations = 10;
+  UInt_t numIterations = 0;
+
+  do
+    {
+  // First define a area of interest around the expected position of the star
+  for (UInt_t pix=1; pix<numPixels; pix++)
+    {
+      
+      Float_t pixXpos=(*fGeomCam)[pix].GetX();
+      Float_t pixYpos=(*fGeomCam)[pix].GetY();
+      Float_t dist = sqrt((pixXpos-expX)*(pixXpos-expX)+
+                          (pixYpos-expY)*(pixYpos-expY));
+      
+      if ((dist < fRingInterest) && fDisplay.IsUsed(pix))
+        fPixelsUsed[pix]=(Char_t)kTRUE;
+      else
+        fPixelsUsed[pix]=(Char_t)kFALSE;
+    }
+  
+    fDisplay.SetUsed(fPixelsUsed);
+    
+// determine mean x and mean y
+    usedInnerPx=0;	
+    usedOuterPx=0;	
+    for(UInt_t pix=0; pix<numPixels; pix++)
+    {
+	if(fDisplay.IsUsed(pix))
+	{
+	    pix>lastInnerPixel?usedOuterPx++:usedInnerPx++;
+
+	    Float_t charge  = fDisplay.GetBinContent(pix+1);
+	    Float_t pixXpos = (*fGeomCam)[pix].GetX();
+	    Float_t pixYpos = (*fGeomCam)[pix].GetY();
+
+            if (charge>max)
+              {
+                max=charge;
+                pixmax=pix;
+              }
+            
+	    meanX     += charge*pixXpos;
+	    meanY     += charge*pixYpos;
+	    meanSqX   += charge*pixXpos*pixXpos;
+	    meanSqY   += charge*pixYpos*pixYpos;
+	    sumCharge += charge;
+	}
+    }
+
+    if (fMinuitPrintOutLevel>=0) *fLog << dbg << " usedInnerPx " << usedInnerPx << " usedOuterPx " << usedOuterPx << endl;
+
+    meanX   /= sumCharge;
+    meanY   /= sumCharge;
+    meanSqX /= sumCharge;
+    meanSqY /= sumCharge;
+
+    expX = meanX;
+    expY = meanY;
+
+    if (++numIterations >  maxNumIterations)
+      {
+        *fLog << warn << GetName() << "Mean calculation not converge after " << maxNumIterations << " iterations" << endl;
+        break;
+      }
+        
+    }while(TMath::Abs(meanX-expX) > meanPresition || TMath::Abs(meanY-expY) > meanPresition);
+  
+    Float_t rmsX = (meanSqX - meanX*meanX) - fRingInterest*fRingInterest/12;
+    Float_t rmsY = (meanSqY - meanY*meanY) - fRingInterest*fRingInterest/12;
+
+    if ( rmsX > 0)
+      rmsX =  TMath::Sqrt(rmsX);
+    else
+      {
+        *fLog << warn << " MFindStars::FindStar negative rmsX² " << rmsX << endl;
+        *fLog << warn << " meanSqX " << meanSqX << " meanX " << meanX << " fRingInterest " << fRingInterest << " sumCharge " << sumCharge << endl;
+        rmsX = 0.;
+      }
+
+    if ( rmsY > 0)
+      rmsY =  TMath::Sqrt(rmsY);
+    else
+      {
+        *fLog << warn << " MFindStars::FindStar negative rmsY² " << rmsY << endl;
+        *fLog << warn << " meanSqY " << meanSqY << " meanY " << meanY << " fRingInterest " << fRingInterest << " sumCharge " << sumCharge<< endl;
+        rmsY = 0.;
+      }
+    
+    // Substrack pedestal DC
+    sumCharge-= (usedInnerPx*innerped+usedOuterPx*outerped)/(usedInnerPx+usedOuterPx);
+    max-=pixmax>lastInnerPixel?outerped:innerped;
+    
+
+    star->SetCalcValues(sumCharge,max,meanX,meanY,rmsX,rmsY);
+
+    if (rmsX <= 0. || rmsY <= 0.)
+      return kFALSE;
+    
+    
+// fit the star spot using TMinuit
+
+    
+    for (UInt_t pix=1; pix<numPixels; pix++)
+      if (fDisplay.IsUsed(pix))
+        if (fMinuitPrintOutLevel>=0) *fLog << dbg << "[fit the star spot] fDisplay.IsUsed(" << pix << ") kTRUE" << endl;
+  
+    if (fMinuitPrintOutLevel>=0) *fLog << dbg << "fMinDCForStars " << fMinDCForStars << " pixmax>lastInnerPixel?outerped:innerped " << (pixmax>lastInnerPixel?outerped:innerped) << " fMaxNumIntegratedEvents " << fMaxNumIntegratedEvents << endl;
+
+  //Initialate variables for fit
+    fVinit[0] = max;
+    fLimlo[0] = fMinDCForStars-(pixmax>lastInnerPixel?outerped:innerped);
+    fLimup[0] = 30*fMaxNumIntegratedEvents-(pixmax>lastInnerPixel?outerped:innerped);
+    fVinit[1] = meanX;
+    fVinit[2] = rmsX;
+    fVinit[3] = meanY;
+    fVinit[4] = rmsY;
+    //Init steps
+    for(Int_t i=0; i<fNumVar; i++)
+      {
+	if (fVinit[i] != 0)
+	  fStep[i] = TMath::Abs(fVinit[i]/sqrt2);
+        if (fMinuitPrintOutLevel>=0) *fLog << dbg << " fVinit[" << i << "] " << fVinit[i];
+        if (fMinuitPrintOutLevel>=0) *fLog << dbg << " fStep[" << i << "] " << fStep[i];
+        if (fMinuitPrintOutLevel>=0) *fLog << dbg << " fLimlo[" << i << "] " << fLimlo[i];
+        if (fMinuitPrintOutLevel>=0) *fLog << dbg << " fLimup[" << i << "] " << fLimup[i] << endl;
+      }
+    //
+
+    // -------------------------------------------
+    // call MINUIT
+
+    Double_t arglist[10];
+    Int_t ierflg = 0;
+
+    for (Int_t i=0; i<fNumVar; i++)
+      gMinuit->mnparm(i, fVname[i], fVinit[i], fStep[i], fLimlo[i], fLimup[i], ierflg);
+
+    TStopwatch clock;
+    clock.Start();
+
+// Now ready for minimization step
+    arglist[0] = 500;
+    arglist[1] = 1.;
+    gMinuit->mnexcm(fMethod, arglist ,2,ierflg);
+
+    clock.Stop();
+
+    if(fMinuitPrintOutLevel>=0)
+      {
+	if (fMinuitPrintOutLevel>=0) *fLog << dbg << "Time spent for the minimization in MINUIT :   " << endl;;
+	clock.Print();
+      }
+
+    Double_t integratedCharge;
+    Double_t maxFit, maxFitError;
+    Double_t meanXFit, meanXFitError;
+    Double_t sigmaMinorAxis, sigmaMinorAxisError;
+    Double_t meanYFit, meanYFitError;
+    Double_t sigmaMajorAxis, sigmaMajorAxisError;
+    Float_t chisquare = GetChisquare();
+    Int_t   dregrees  = GetDegreesofFreedom()-fNumVar;
+
+    if (!ierflg)
+      {
+        gMinuit->GetParameter(0,maxFit, maxFitError);
+        gMinuit->GetParameter(1,meanXFit,meanXFitError);
+        gMinuit->GetParameter(2,sigmaMinorAxis,sigmaMinorAxisError);
+        gMinuit->GetParameter(3,meanYFit,meanYFitError);
+        gMinuit->GetParameter(4,sigmaMajorAxis,sigmaMajorAxisError);
+        
+        //FIXME: Do the integral properlly
+        integratedCharge = 0.;
+
+        
+      }
+    else
+      {
+        maxFit = 0.;
+        meanXFit = 0.;
+        sigmaMinorAxis = 0.;
+        meanYFit = 0.;
+        sigmaMajorAxis = 0.;
+        integratedCharge = 0.;
+
+	*fLog << err << "TMinuit::Call error " << ierflg << endl;
+      }
+    
+    star->SetFitValues(integratedCharge,maxFit,meanXFit,meanYFit,sigmaMinorAxis,sigmaMajorAxis,chisquare,dregrees);
+    
+    // reset the display to the starting values
+    fDisplay.SetUsed(origPixelsUsed);
+
+    if (ierflg)
+      return kCONTINUE;
+    return kTRUE;
+}
+
+Bool_t MFindStars::ShadowStar(MStarLocalPos* star)
+{
+    UInt_t numPixels = fGeomCam->GetNumPixels();
+
+// Define an area around the star which will be set unused.
+    UInt_t shadowPx=0;	
+    for (UInt_t pix=1; pix<numPixels; pix++)
+    {
+	Float_t pixXpos  = (*fGeomCam)[pix].GetX();
+	Float_t pixYpos  = (*fGeomCam)[pix].GetY();
+        Float_t starXpos = star->GetMeanX();
+        Float_t starYpos = star->GetMeanY();
+        
+	Float_t starSize = 3*star->GetSigmaMajorAxis();
+        
+	Float_t dist = sqrt((pixXpos-starXpos)*(pixXpos-starXpos)+
+			    (pixYpos-starYpos)*(pixYpos-starYpos));
+
+        if (dist > starSize && fDisplay.IsUsed(pix))
+	  fPixelsUsed[pix]=(Char_t)kTRUE;
+        else
+          {
+            fPixelsUsed[pix]=(Char_t)kFALSE;
+            shadowPx++;
+          }
+    }
+
+    if (fMinuitPrintOutLevel>=0) *fLog << dbg << " shadowPx " << shadowPx << endl;
+
+    fDisplay.SetUsed(fPixelsUsed);
+
+    return kTRUE;
+}
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/MFindStars.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/MFindStars.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/MFindStars.h	(revision 9661)
@@ -0,0 +1,105 @@
+#ifndef MARS_MFindStars
+#define MARS_MFindStars
+
+#ifndef ROOT_TArrayS
+#include <TArrayS.h>
+#endif
+
+#ifndef ROOT_TArrayC
+#include <TArrayC.h>
+#endif
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+#ifndef MARS_MHCamera
+#include "MHCamera.h"
+#endif
+
+#ifndef MARS_MAstroCamera
+#include "MAstroCamera.h"
+#endif
+
+class MGeomCam;
+class MGeomPix;
+class MCameraDC;
+class MTime;
+class MReportDrive;
+class MStarLocalCam;
+class MStarLocalPos;
+
+class MFindStars : public MTask
+{
+
+private:
+
+    MGeomCam      *fGeomCam;
+    MCameraDC     *fCurr;
+    MTime         *fTimeCurr;
+    MReportDrive  *fDrive;
+    MStarLocalCam *fStars;
+
+    //    MAstroCamera fAstro;
+    TArrayC      fPixelsUsed;
+    MHCamera     fDisplay;
+
+    UInt_t fMaxNumIntegratedEvents;
+    UInt_t fNumIntegratedEvents;
+
+    Float_t fRingInterest; //[mm]
+    Float_t fMinDCForStars; //[uA]
+
+    Float_t fDCTailCut;
+
+    //Fitting(Minuit) variables
+    const Int_t fNumVar;
+    Float_t fTempChisquare;
+    Int_t fTempDegreesofFreedom;
+    Int_t fMinuitPrintOutLevel;
+    
+    TString *fVname;
+    TArrayD fVinit; 
+    TArrayD fStep; 
+    TArrayD fLimlo; 
+    TArrayD fLimup; 
+    TArrayI fFix;
+    TObject *fObjectFit;
+    TString fMethod;
+    Bool_t fNulloutput;
+    
+    Bool_t DCPedestalCalc();
+    Bool_t FindPixelWithMaxDC(Float_t &maxDC, MGeomPix &maxPix);
+    Bool_t FindStar(MStarLocalPos* star);
+    Bool_t ShadowStar(MStarLocalPos* star);
+
+  public:
+    
+    MFindStars(const char *name=NULL, const char *title=NULL);
+    
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
+    // setters
+    void SetNumIntegratedEvents(UInt_t max) {fMaxNumIntegratedEvents=max;}
+    void SetRingInterest(Float_t ring) {fRingInterest=ring;}
+    void SetBlindPixels(TArrayS blindpixels);
+    void SetMinuitPrintOutLevel(Int_t level) {fMinuitPrintOutLevel=level;}
+    void SetDCTailCut(Float_t cut) {fDCTailCut=cut;}
+
+    void SetChisquare(Float_t chi) {fTempChisquare=chi;}
+    void SetDegreesofFreedom(Int_t free) {fTempDegreesofFreedom=free;}
+
+    //Getters
+    MHCamera& GetDisplay() { return fDisplay; }
+    
+    Float_t GetChisquare() {return fTempChisquare;}
+    Int_t GetDegreesofFreedom() {return fTempDegreesofFreedom;}
+    UInt_t GetNumIntegratedEvents() {return fMaxNumIntegratedEvents;}
+    Float_t GetRingInterest() {return fRingInterest;}
+    
+  ClassDef(MFindStars, 0) // Tool to find stars from DC Currents
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtemp/MStarLocalCam.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/MStarLocalCam.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/MStarLocalCam.cc	(revision 9661)
@@ -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): Javier Lopez 04/2004 <mailto:jlopez@ifae.es>
+!   Author(s): Jordi Albert 04/2004 <mailto:albert@astro.uni-wuerzburg.de>
+!                 
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MStarLocalCam
+//                                                                         //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MStarLocalCam.h"
+
+#include <TList.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MStarLocalPos.h"
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+// Default constructor. 
+//
+//
+MStarLocalCam::MStarLocalCam(const char *name, const char *title) 
+{
+  fName  = name  ? name  : "MStarLocalCam";
+  fTitle = title ? title : "";
+  
+  fStars = new TList;
+
+  fInnerPedestalDC = 0.;
+  fOuterPedestalDC = 0.;
+  fInnerPedestalRMSDC = 0.;
+  fOuterPedestalRMSDC = 0.;
+  
+}
+
+MStarLocalCam::~MStarLocalCam()
+{
+    fStars->SetOwner();
+    fStars->Delete();
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th
+//
+MStarLocalPos &MStarLocalCam::operator[] (Int_t i)
+{
+  MStarLocalPos& star = *static_cast<MStarLocalPos*>(fStars->At(i));
+  return star;
+}
+
+// --------------------------------------------------------------------------
+//
+// Get i-th
+//
+const MStarLocalPos &MStarLocalCam::operator[] (Int_t i) const
+{
+    return *static_cast<MStarLocalPos*>(fStars->At(i));
+}
+
+void MStarLocalCam::Paint(Option_t *o)
+{
+	TIter Next(fStars);
+	MStarLocalPos* star;
+	while ((star=(MStarLocalPos*)Next())) 
+	    star->Paint(o);
+}
+
+void MStarLocalCam::Print(Option_t *o) const
+{
+      *fLog << inf << "DCs baseline:" << endl;
+      *fLog << inf << " Inner Pixels Mean pedestal \t" << setw(4) << fInnerPedestalDC << " uA  and RMS " << setw(4) << fInnerPedestalRMSDC << " uA for DCs" << endl;
+      *fLog << inf << " Outer Pixels Mean pedestal \t" << setw(4) << fOuterPedestalDC << " uA  and RMS " << setw(4) << fOuterPedestalRMSDC << " uA for DCs" << endl;
+      
+      TIter Next(fStars);
+      MStarLocalPos* star;
+      UInt_t starnum = 0;
+      while ((star=(MStarLocalPos*)Next())) 
+        {
+          *fLog << inf << "Star[" << starnum << "] info:" << endl;
+          star->Print(o);
+          starnum++;
+        }
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/MStarLocalCam.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/MStarLocalCam.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/MStarLocalCam.h	(revision 9661)
@@ -0,0 +1,64 @@
+#ifndef MARS_MStarLocalCam
+#define MARS_MStarLocalCam
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#ifndef MARS_MHCamera
+#include "MHCamera.h"
+#endif
+
+class TList;
+
+class MGeomCam;
+class MStarLocalPos;
+
+class MStarLocalCam : public MParContainer
+{
+private:
+
+  TList  *fStars;  //-> FIXME: Change TClonesArray away from a pointer?
+
+  // BaseLine DCs info
+  Float_t fInnerPedestalDC;         //[ua]
+  Float_t fOuterPedestalDC;         //[ua]
+
+  Float_t fInnerPedestalRMSDC;      //[ua]
+  Float_t fOuterPedestalRMSDC;      //[ua]
+
+  MHCamera fDisplay;
+
+ public:
+
+  MStarLocalCam(const char *name=NULL, const char *title=NULL);
+  ~MStarLocalCam();
+
+  MStarLocalPos &operator[] (Int_t i);
+  const MStarLocalPos &operator[] (Int_t i) const;
+
+  TList *GetList() const { return fStars; }
+  UInt_t GetNumStars() const { return fStars->GetSize(); }
+
+  //Getters
+
+  Float_t GetInnerPedestalDC() {return fInnerPedestalDC;}
+  Float_t GetOuterPedestalDC() {return fOuterPedestalDC;}
+  Float_t GetInnerPedestalRMSDC() { return fInnerPedestalRMSDC;}
+  Float_t GetOuterPedestalRMSDC() { return fOuterPedestalRMSDC;}
+
+  MHCamera& GetDisplay() { return fDisplay; }
+
+    //Setters
+  void SetInnerPedestalDC(Float_t ped) {fInnerPedestalDC = ped;}
+  void SetOuterPedestalDC(Float_t ped) {fOuterPedestalDC = ped;}
+  void SetInnerPedestalRMSDC(Float_t rms){fInnerPedestalRMSDC = rms;}
+  void SetOuterPedestalRMSDC(Float_t rms){fOuterPedestalRMSDC = rms;}
+
+  void Paint(Option_t *o=NULL);
+  void Print(Option_t *o=NULL) const;
+
+  ClassDef(MStarLocalCam, 1)	// Storage Container for star positions in the camera
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtemp/MStarLocalPos.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/MStarLocalPos.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/MStarLocalPos.cc	(revision 9661)
@@ -0,0 +1,198 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without expressed
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Javier López , 4/2004 <mailto:jlopez@ifae.es>
+!   Author(s): Robert Wagner, 7/2004 <mailto:rwagner@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+#include "MStarLocalPos.h"
+
+#include <TEllipse.h>
+#include <TMarker.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MStarLocalPos);
+
+using namespace std;
+
+MStarLocalPos::MStarLocalPos(const char *name, const char *title)
+{
+
+    fName  = name  ? name  : "MStarLocalPos";
+    fTitle = title ? title : "";
+    
+    Reset();
+}
+
+void MStarLocalPos::Reset()
+{
+
+    //Expected position on camera
+     fMagExp = 0.;
+     fXExp = 0.;
+     fYExp = 0.;
+
+    //Info from calculation
+
+     fMagCalc = 0.;
+     fMaxCalc = 0.;
+     fMeanXCalc = 0.;
+     fMeanYCalc = 0.;
+     fSigmaMinorAxisCalc = 0.;
+     fSigmaMajorAxisCalc = 0.;
+
+    //Info from fit
+
+     fMagFit = 0.;
+     fMaxFit = 0.;
+     fMeanXFit = 0.;
+     fMeanYFit = 0.;
+     fSigmaMinorAxisFit = 0.;
+     fSigmaMajorAxisFit = 0.;
+     fChiSquare = 0.;
+     fNdof = 1;
+
+}
+
+void MStarLocalPos::SetExpValues(Float_t mag, Float_t x, Float_t y)
+{
+     fMagExp = mag;
+     fXExp = x;
+     fYExp = y;
+}
+
+void MStarLocalPos::SetCalcValues(Float_t mag, Float_t max, Float_t x, Float_t y, Float_t sigmaMinorAxis, Float_t sigmaMajorAxis)
+{
+     fMagCalc = mag;
+     fMaxCalc = max;
+     fMeanXCalc = x;
+     fMeanYCalc = y;
+     fSigmaMinorAxisCalc = sigmaMinorAxis;
+     fSigmaMajorAxisCalc = sigmaMajorAxis;
+}
+
+void MStarLocalPos::SetFitValues(Float_t mag, Float_t max, Float_t x, Float_t y, Float_t sigmaMinorAxis, Float_t sigmaMajorAxis, Float_t chiSquare, Int_t ndof)
+{
+     fMagFit = mag;
+     fMaxFit = max;
+     fMeanXFit = x;
+     fMeanYFit = y;
+     fSigmaMinorAxisFit = sigmaMinorAxis;
+     fSigmaMajorAxisFit = sigmaMajorAxis;
+     fChiSquare = chiSquare;
+     fNdof = ndof;
+}
+
+void MStarLocalPos::SetFitValues(Float_t mag, Float_t max, Float_t x, Float_t y, Float_t sigmaMinorAxis, Float_t sigmaMajorAxis, Float_t chiSquare, Int_t ndof, Float_t xx, Float_t xy, Float_t yy)
+{
+  SetFitValues(mag, max, x, y, sigmaMinorAxis, sigmaMajorAxis, chiSquare, ndof);
+  fXXErr = xx;
+  fYYErr = yy;
+  fXYErr = xy;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Paint the ellipse corresponding to the parameters
+//
+void MStarLocalPos::Paint(Option_t *opt)
+{
+  //Print a cross in the expected position
+  
+  TMarker mexp(fXExp, fYExp, 29);
+  mexp.SetMarkerSize(3);
+  mexp.SetMarkerColor(94);
+  mexp.Paint(); 
+
+  if (fSigmaMinorAxisCalc>0. && fSigmaMajorAxisCalc>0.)
+    {
+      TEllipse ecalc(fMeanXCalc, fMeanYCalc, fSigmaMinorAxisCalc, fSigmaMajorAxisCalc, 0, 360, 0);
+      ecalc.SetLineWidth(3);
+      ecalc.SetLineColor(kRed);
+      ecalc.Paint();
+    }
+
+  if (fSigmaMinorAxisFit>0. || fSigmaMajorAxisFit>0.)
+    {
+      TEllipse efit(fMeanXFit, fMeanYFit, fSigmaMinorAxisFit, fSigmaMajorAxisFit, 0, 360, 0);
+      efit.SetLineWidth(3);
+      efit.SetLineColor(kBlack);
+      efit.Paint();
+    }
+}
+  
+void MStarLocalPos::Print(Option_t *opt) const
+{
+  TString o = opt;
+
+  if (o.Contains("name", TString::kIgnoreCase) || opt == NULL)
+    {
+      *fLog << inf << "Star Name: \"" << this->GetName() << "\"" << endl;
+    }
+    
+  
+  if (o.Contains("mag", TString::kIgnoreCase) || opt == NULL)
+    {
+  
+      *fLog << inf << "Star maginitude:" << endl;
+      *fLog << inf << " Expected \t" << setw(4) << fMagExp << endl;
+      *fLog << inf << " Calcultated \t " << setw(4) << fMagCalc << endl;
+      *fLog << inf << " Fitted \t " << setw(4) << fMagFit << endl;
+    }
+  
+  if (o.Contains("max", TString::kIgnoreCase) || opt == NULL)
+    {
+      *fLog << inf << "Star Maximum:" << endl;
+      *fLog << inf << " Calcultated \t " << setw(4) << fMaxCalc << " uA" << endl;
+      *fLog << inf << " Fitted \t " << setw(4) << fMaxFit << " uA" << endl;
+    }
+  
+  if (o.Contains("pos", TString::kIgnoreCase) || opt == NULL)
+    {
+      *fLog << inf << "Star position:" << endl;
+      *fLog << inf << " Expected \t X " << setw(4) << fXExp << " mm \tY " << setw(4) << fYExp << " mm" << endl;
+      *fLog << inf << " Calcultated \t X " << setw(4) << fMeanXCalc << " mm \tY " << setw(4) << fMeanYCalc << " mm" << endl;
+      *fLog << inf << " Fitted \t X " << setw(4) << fMeanXFit << " mm \tY " << setw(4) << fMeanYFit << " mm" << endl;
+    }
+
+  if (o.Contains("siz", TString::kIgnoreCase) || opt == NULL)
+    {
+      *fLog << inf << "Star size:" << endl;
+      *fLog << inf << " Calcultated \t X " << setw(4) << fSigmaMinorAxisCalc << " mm \tY " << setw(4) << fSigmaMajorAxisCalc << " mm" << endl;
+      *fLog << inf << " Fitted \t X " << setw(4) << fSigmaMinorAxisFit << " mm \tY " << setw(4) << fSigmaMajorAxisFit << " mm" << endl;
+    }
+
+  if (o.Contains("chi", TString::kIgnoreCase) || opt == NULL)
+    {
+      *fLog << inf << "Star Fit Quality:" << endl;
+      *fLog << inf << " ChiSquare/Ndof \t " << setw(3) << fChiSquare << "/" << fNdof << endl;
+    }
+
+  if (o.Contains("err", TString::kIgnoreCase) || opt == NULL)
+    {
+      *fLog << inf << "Minuit Error Matrix:" << endl;
+      *fLog << inf << " xx,xy,yy \t " << setw(3) << fXXErr << ", " << fXYErr << ", " << fYYErr << endl;
+    }
+
+
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/MStarLocalPos.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/MStarLocalPos.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/MStarLocalPos.h	(revision 9661)
@@ -0,0 +1,89 @@
+#ifndef MARS_MStarLocalPos
+#define MARS_MStarLocalPos
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MStarLocalPos : public MParContainer
+{
+private:
+
+    //Expected position on camera
+    
+    Float_t fMagExp;
+    Float_t fXExp;    //[mm]
+    Float_t fYExp;    //[mm]
+
+    //Info from calculation
+
+    Float_t fMagCalc;
+    Float_t fMaxCalc;            //[uA]
+    Float_t fMeanXCalc;          //[mm]
+    Float_t fMeanYCalc;          //[mm]
+    Float_t fSigmaMinorAxisCalc; //[mm]
+    Float_t fSigmaMajorAxisCalc; //[mm]
+
+    //Info from fit
+
+    Float_t fMagFit;
+    Float_t fMaxFit;             //[uA]
+    Float_t fMeanXFit;           //[mm]
+    Float_t fMeanYFit;           //[mm]
+    Float_t fSigmaMinorAxisFit;  //[mm]
+    Float_t fSigmaMajorAxisFit;  //[mm]
+    Float_t fChiSquare;
+    Float_t fXXErr;              //minuit error matrix elements
+    Float_t fXYErr;
+    Float_t fYYErr;
+    Int_t   fNdof;
+
+public:
+
+    MStarLocalPos(const char *name=NULL, const char *title=NULL);
+    //~MStarLocalPos();
+
+    Float_t GetMagExp() {return fMagExp;}
+    Float_t GetXExp() {return fXExp;}
+    Float_t GetYExp() {return fYExp;}
+
+    Float_t GetMagCalc() {return fMagCalc;}
+    Float_t GetMaxCalc() {return fMaxCalc;}
+    Float_t GetMeanXCalc() {return fMeanXCalc;}
+    Float_t GetMeanYCalc() {return fMeanYCalc;}
+    Float_t GetSigmaMinorAxisCalc() {return fSigmaMinorAxisCalc;}
+    Float_t GetSigmaMajorAxisCalc() {return fSigmaMajorAxisCalc;}
+
+    Float_t GetMagFit() {return fMagFit;}
+    Float_t GetMaxFit() {return fMaxFit;}
+    Float_t GetMeanXFit() {return fMeanXFit;}
+    Float_t GetMeanYFit() {return fMeanYFit;}
+    Float_t GetSigmaMinorAxisFit() {return fSigmaMinorAxisFit;}
+    Float_t GetSigmaMajorAxisFit() {return fSigmaMajorAxisFit;}
+    Float_t GetChiSquare() {return fChiSquare;}
+    UInt_t GetNdof() {return fNdof;}
+    Float_t GetChiSquareNdof() {return fChiSquare/fNdof;}
+
+    Float_t GetMeanX() {return fMeanXFit!=0?fMeanXFit:fMeanXCalc;}
+    Float_t GetMeanY() {return fMeanXFit!=0?fMeanYFit:fMeanYCalc;}
+    Float_t GetSigmaMinorAxis() {return fSigmaMinorAxisFit!=0?fSigmaMinorAxisFit:fSigmaMinorAxisCalc;}
+    Float_t GetSigmaMajorAxis() {return fSigmaMajorAxisFit!=0?fSigmaMajorAxisFit:fSigmaMajorAxisCalc;}
+    
+    Float_t GetXXErr() {return fXXErr;}
+    Float_t GetXYErr() {return fXYErr;}
+    Float_t GetYYErr() {return fYYErr;}
+
+    void Reset();
+
+    void SetExpValues(Float_t mag, Float_t x, Float_t y);
+    void SetCalcValues(Float_t mag, Float_t max, Float_t x, Float_t y, Float_t sigmaMinorAxis, Float_t sigmaMajorAxis);
+    void SetFitValues(Float_t mag, Float_t max, Float_t x, Float_t y, Float_t sigmaMinorAxis, Float_t sigmaMajorAxis, Float_t chi, Int_t ndof);
+    void SetFitValues(Float_t mag, Float_t max, Float_t x, Float_t y, Float_t sigmaMinorAxis, Float_t sigmaMajorAxis, Float_t chi, Int_t ndof, Float_t xx, Float_t xy, Float_t yy);
+
+    void Paint(Option_t *opt=NULL);
+    void Print(Option_t *opt=NULL) const;
+
+    ClassDef(MStarLocalPos, 1) // Container that holds the star information in the PMT camera
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtemp/MVPObject.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/MVPObject.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/MVPObject.cc	(revision 9661)
@@ -0,0 +1,280 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Robert Wagner <mailto:magicsoft@rwagner.de> 10/2002
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//  MVPObject                                                              //
+//                                                                         //
+//  Class used by the visibility plotter to convert RA/Dec to Alt/Az       //
+//                                                                         //
+//  This class represents an object and is used with the Visibility        //
+//  macro. It must be provided with its RA/Dec coordinates and an          //
+//  object name (cf. MVPObject::SetRA, MVPObject::SetDec, and              //
+//  MVPObject::SetName). Alternatively, you can require the MVPObject      //
+//  to be a solar system object like the Sun, Mars or the Moon             //
+//  (cf. MVPObject::SetObject).                                            //
+//                                                                         //
+//  MVPObject is ready to be used in a Mars Eventloop. You must provide    //
+//  an Observatory Location as well as a time at which the position        //
+//  of the MVPObject is to be calculated. MVPObject::PreProcess            //
+//  checks the existence of the required containers and also makes sure    //
+//  all necessary setters have been called. MVPObject::Process             //
+//  then calculates the Alt/Az position of the object, as well as the      //
+//  Zenith angle and the object diameter (Solar system objects).           //
+//                                                                         //
+//  The astronomical algorithms used are taken from SLALIB 2.4-8.          //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MVPObject.h"
+
+#include <TMath.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+#include "MParList.h"
+
+#include "../../slalib/slalib.h"
+
+ClassImp(MVPObject);
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+MVPObject::MVPObject(const char *name, const char *title) : fDiameter(0), fCalcEc(kFALSE), fUT1(52000), fBody(10), fGotRA(kFALSE), fGotDec(kFALSE), fGotName(kFALSE)
+{
+  fName  = name  ? name  : "MVPObject";
+  fTitle = title ? title : "Task to calculate Alt, Az of a given object";
+  
+  fgDegToRad=2*TMath::Pi()/360;
+  fgHrsToRad=2*TMath::Pi()/24;  
+}
+
+MVPObject::~MVPObject()
+{
+  //Destructor: nothing special yet.
+}
+
+// --------------------------------------------------------------------------
+//
+//  Check if necessary containers exist in the parameter list already.
+//  We need an ObservatoryLocation and a MVPTime object.
+//
+Bool_t MVPObject::PreProcess(MParList *pList)
+{
+  fObservatory = (MObservatoryLocation*)pList->FindObject("MObservatoryLocation");
+  if (!fObservatory)
+    {
+      *fLog << dbginf << "MObservatoryLocation not found... aborting." << endl;
+      return kFALSE;
+    }
+  
+  fTime = (MVPTime*)pList->FindObject("MVPTime");
+  if (!fTime)
+    {
+      *fLog << dbginf << "MVPTime not found... aborting." << endl;
+      return kFALSE;
+    }
+
+  if (!fGotRA || !fGotDec || !fGotName)
+    {
+      *fLog << dbginf << "Object information is not complete." << endl;
+      return kFALSE;
+    }
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Sets coordinates from object name. Instead of providing RA, Dec and Name
+// of an object, you may also just provide the object name in the from
+// HHMMsDDT, where RA is given in hours and minutes and Declination is
+// given by degrees DD and tenths of degrees T. "s" may be "+" or
+// "-", eg. "1959+650"
+//
+void MVPObject::SetObjectByName(const char *object)
+{
+  fObjectName=object;
+  fGotName=kTRUE;
+  
+  Int_t ra, dec;
+  sscanf(object, "%d%d", &ra, &dec);
+
+  fRA  = fgHrsToRad * (0.01*ra + (r%100)/60.);
+  fDec = fgDegToRad * 0.1 * dec;
+
+  fGotRA=kTRUE;
+  fGotDec=kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Sets RA position of object. Position is to be provided in hours, minutes,
+// seconds, and microseconds (if needed)
+//
+void MVPObject::SetRA(Int_t rh, Int_t rm, Int_t rs, Int_t ru)
+{
+  // Rect is a timelike value...
+  fRA = fgHrsToRad*((Double_t)rh + (Double_t)rm/60 + (Double_t)rs/(60*60) + (Double_t)ru/(36000));
+  fBody = 10;
+  fGotRA = kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Sets Dec position of object. Position is to be provided in degrees, 
+// minutes, seconds, and microseconds (if needed)
+//
+void MVPObject::SetDec(Int_t dh, Int_t dm, Int_t ds, Int_t du)
+{
+  // Dec is an anglelike value
+  fDec = fgDegToRad*((Double_t)dh + (Double_t)dm/60 + (Double_t)ds/(60*60) + (Double_t)du/(36000));
+  fBody = 10;
+  fGotDec = kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Alternatively to providing RA, Dec and Name of an object, you may provide 
+// a solar system object (which has no fixed RA, Dec, by the way!) with
+// MVPObject::SetObject.
+// -
+// UInt_t body | Object      Sun and Moon will be objects needed at most,
+//           0 | Sun         presumably.
+//           1 | Mercury
+//           2 | Venus
+//           3 | Moon
+//           4 | Mars
+//           5 | Jupiter
+//           6 | Saturn
+//           7 | Uranus
+//           8 | Neptune
+//           9 | Pluto
+//
+Bool_t MVPObject::SetObject(UInt_t body)
+{
+  if (body > 9) 
+    {
+      *fLog << dbginf << "No solar system object associated with value " << body <<"! Ignoring request." << endl;
+      return kFALSE;
+    }
+  else  // We are working on a solar system body.
+    {                   
+      switch (body) 
+       	{
+	case 1: fObjectName="Mercury"; break;
+       	case 2: fObjectName="Venus"; break;
+       	case 3: fObjectName="Moon"; break;
+       	case 4: fObjectName="Mars"; break;
+       	case 5: fObjectName="Jupiter"; break;
+       	case 6: fObjectName="Saturn"; break;
+       	case 7: fObjectName="Uranus"; break;
+       	case 8: fObjectName="Neptune"; break;
+       	case 9: fObjectName="Pluto"; break;
+       	default: fObjectName="Sun"; 
+       	}            
+    }
+  
+  fBody = body; 
+  fGotRA = fGotDec = fGotName = kTRUE;
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Given RA, Dec or a solar system object as well as an observatory
+// location and a MVPTime, MVPObject::Process() calculates
+// Alt, Az, ZA and (in the case of solar system objects) the apparent
+// object diameter
+//
+Bool_t MVPObject::Process()
+{
+  Double_t diameter = 0.0;
+
+  if (fBody < 10) // We are working on a solar system body.
+    {      
+      slaRdplan(fTime->GetMJD(), fBody, fObservatory->GetLongitudeRad(), fObservatory->GetLatitudeRad(), &fRA, &fDec, &diameter);         
+    }
+  
+  if (fCalcEc) slaEqecl(fRA, fDec, fTime->GetMJD(), &fEcLong, &fEcLat);
+  
+  Float_t azimuth;
+  Float_t elevation;
+  
+  Float_t hourAngle = (Float_t)UT1ToGMST(fTime->GetMJD()) - fRA;
+
+  //  cout << "ha: " << hourAngle  << " ra: " << fRA << " dec " << fDec <<endl;
+
+  slaE2h (hourAngle, (Float_t)fDec, (Float_t)fObservatory->GetLatitudeRad(), &azimuth, &elevation);
+   
+  fZA  = slaZd(hourAngle, fDec, fObservatory->GetLatitudeRad());
+  fAlt = (Double_t)elevation;
+  fAz  = (Double_t)azimuth; 
+  fDiameter = diameter;
+
+  return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Returns distance of given object to this object in degrees
+//
+Double_t MVPObject::GetDistance(MVPObject* object)
+{
+  return slaSep(fRA, fDec, object->GetRARad(), object->GetDecRad())/fgDegToRad;
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns distance of given object to this object in radians
+//
+Double_t MVPObject::GetDistanceRad(MVPObject* object)
+{
+  return slaSep(fRA, fDec, object->GetRARad(), object->GetDecRad());
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Converts UT1 (given as MJD) to Greenwich mean star time in radians
+//
+Double_t MVPObject::UT1ToGMST(Double_t ut1)
+{
+  return slaGmst(ut1);
+}
+
+void MVPObject::Print(Option_t *) const
+{
+  *fLog << all;
+  *fLog << "Position of "<< fObjectName << 
+    ": Dec " << fDec/fgDegToRad << " deg, " << 
+    "RA  " << fRA/fgHrsToRad << " hrs" << endl;
+  if (fCalcEc) *fLog << "Ecliptic Long: " << fEcLong/fgDegToRad << " deg, " << 
+		  "Ecliptic Lat: " << fEcLat/fgDegToRad << " deg, " << endl; 
+}
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/MVPObject.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/MVPObject.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/MVPObject.h	(revision 9661)
@@ -0,0 +1,100 @@
+#ifndef MARS_MVPObject
+#define MARS_MVPObject
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+#ifndef MARS_MObservatoryLocation
+#include "MObservatoryLocation.h"
+#endif
+
+#ifndef MARS_MVPTime
+#include "MVPTime.h"
+#endif
+
+class MVPObject : public MTask
+{
+private:
+  MObservatoryLocation *fObservatory;  
+
+  Double_t fRA;
+  Double_t fDec;
+  Double_t fAlt;
+  Double_t fAz;
+  Double_t fZA;
+  Double_t fDiameter;
+  Double_t fEcLat;
+  Double_t fEcLong;
+  Bool_t fCalcEc;
+
+  Double_t fUT1;
+  MVPTime *fTime;
+ 
+  char* fObjectName;
+  UInt_t fBody;
+
+  Double_t UT1ToGMST(Double_t ut1);
+ 
+  Double_t fgDegToRad;
+  Double_t fgHrsToRad;
+
+  Bool_t fGotRA;
+  Bool_t fGotDec;
+  Bool_t fGotName;
+
+public:
+
+  MVPObject(const char *name=NULL, const char *title=NULL);
+  ~MVPObject();
+
+  Bool_t PreProcess(MParList *pList);
+  Bool_t Process();
+
+  void SetObservatory(MObservatoryLocation *observatory);
+
+  void SetRA(Double_t rad) { fRA = rad; fBody = 10; fGotRA = kTRUE; }
+  void SetDec(Double_t rad) { fDec = rad; fBody = 10; fGotDec = kTRUE; }
+
+  void SetRA(Int_t rh, Int_t rm, Int_t rs, Int_t ru = 0);
+  void SetDec(Int_t dh, Int_t dm, Int_t ds, Int_t du = 0);
+
+  void SetCalcEc(Bool_t calcEc) { fCalcEc = calcEc; }
+
+  void SetObjectName(char* name) { fObjectName = name; fGotName = kTRUE; } 
+  void SetObjectByName(char* object);
+
+  Bool_t SetObject(UInt_t body);
+
+  Double_t GetRA() { return fRA/fgHrsToRad; }
+  Double_t GetDec() { return fDec/fgDegToRad; }
+
+  Double_t GetRARad()  { return fRA; }
+  Double_t GetDecRad() { return fDec; }
+
+  Double_t GetZA() { return fZA; }
+  Double_t GetAltitude() { return fAlt; }
+  Double_t GetAzimut() { return fAz; }
+  Double_t GetDiameter() { return fDiameter; }
+
+  Double_t GetEcLat() { return fEcLat; }
+  Double_t GetEcLong() { return fEcLong; }
+
+  Double_t GetZADeg() { return fZA/fgDegToRad; }
+  Double_t GetAltitudeDeg() { return fAlt/fgDegToRad; }
+  Double_t GetAzimutDeg() { return fAz/fgDegToRad; }
+
+  Double_t GetDistance(MVPObject* object);
+  Double_t GetDistanceRad(MVPObject* object);
+
+  char* GetObjectName() { return fObjectName; }
+  
+  void Print(Option_t *) const;
+
+  Double_t MJDStartOfYear(UInt_t year);
+
+  ClassDef(MVPObject, 1)
+}; 
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/MVPPlotter.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/MVPPlotter.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/MVPPlotter.cc	(revision 9661)
@@ -0,0 +1,587 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Robert Wagner <magicdev@rwagner.de> 12/2002
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//  MVPPlotter                                                          //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MVPPlotter.h"
+
+#include <stream.h>
+
+#include "TCanvas.h"
+#include "TH1.h"
+#include "TH2.h"
+#include "TPaveText.h"
+#include "TPaveLabel.h"
+#include "TGraph.h"
+#include "TString.h"
+#include "TStyle.h"
+
+#include "MParList.h"
+#include "MVPTime.h"
+
+ClassImp(MVPPlotter);
+
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+MVPPlotter::MVPPlotter(const char *name, const char *title) : fUseSun(kTRUE), fUseMoon(kTRUE), fUsePlanets(kTRUE), fAstronomicalDarkness(-18.0)
+{
+  //  fName  = name  ? name  : "MVPPlotter";
+  //  fTitle = title ? title : "Generates visibility histograms and information";
+
+  fgSecPerDay = 86400;
+  fgMJD010170 = 40586; // 01-01-70 is JD 40586
+  fgDegToRad = 2*TMath::Pi()/360;
+
+}
+
+MVPPlotter::~MVPPlotter()
+// --------------------------------------------------------------------------
+//
+// Destructor. Deletes objects if allocated.
+//
+{
+  if (fUseSun) delete fSun;
+  if (fUseMoon) delete fMoon;
+  if (fUsePlanets) {
+    delete fVenus;
+    delete fMars;
+    delete fJupiter;
+    delete fSaturn;
+  }
+}
+   
+void MVPPlotter::SetupObjects()
+// --------------------------------------------------------------------------
+//
+// Create instances for Sun, Moon, Planets if requested.
+//
+{
+  
+  fTime = new MVPTime();
+  fPlist.AddToList(fTime);
+  fPlist.AddToList(fObs);
+
+  if (fObject==NULL) {
+    cout << "You didn't specify an object!" << endl;  
+  }
+
+  fObject->PreProcess(&fPlist);
+  cout << "Processing object " << fObject->GetObjectName() << endl;
+
+  if (fUseSun) {
+    fSun = new MVPObject();
+    fSun->SetObject(0); // Sun
+    fSun->PreProcess(&fPlist);
+    fSun->SetCalcEc(kTRUE);
+  }
+
+  if (fUseMoon) {
+    fMoon = new MVPObject();
+    fMoon->SetObject(3); // Moon
+    fMoon->PreProcess(&fPlist);
+    fMoon->SetCalcEc(kTRUE);
+  }
+
+  if (fUsePlanets) {
+    fVenus = new MVPObject();
+    fVenus->SetObject(2); 
+    fVenus->PreProcess(&fPlist);
+    fVenus->SetCalcEc(kTRUE);
+
+    fMars = new MVPObject();
+    fMars->SetObject(4); 
+    fMars->PreProcess(&fPlist);
+    fMars->SetCalcEc(kTRUE);
+
+    fJupiter = new MVPObject();
+    fJupiter->SetObject(5); 
+    fJupiter->PreProcess(&fPlist);
+    fJupiter->SetCalcEc(kTRUE);
+
+    fSaturn = new MVPObject();
+    fSaturn->SetObject(6); 
+    fSaturn->PreProcess(&fPlist);
+    fSaturn->SetCalcEc(kTRUE);
+  }
+}
+
+// --------------------------------------------------------------------------
+//
+// Plots for a single object and a whole year are generated.
+// 
+// Currently we do the following:
+// - Create a plot MJD vs UTC for one year
+// - Create a plot maxObjHeight vs Week for one year
+// - Create visibility tables for one year (ZA, hours)
+//
+Bool_t MVPPlotter::CalcYear(Int_t year, UInt_t daySlices=96)
+{
+  SetupObjects();
+  
+  UInt_t startday = (UInt_t)fTime->MJDStartOfYear(year);
+  UInt_t stopday  = (UInt_t)fTime->MJDStartOfYear(year+1)-1;
+
+  cout << "Processing period MJD "<< startday << " to MJD "<< stopday  << endl;
+
+  ULong_t startdayROOT = fgSecPerDay * (startday-fgMJD010170);
+  ULong_t stopdayROOT  = fgSecPerDay * (stopday-fgMJD010170);
+      
+  // 2D Plot ZA vs MJD and UTC
+  fMjdUtcYear = new TH2D("fMjdUtcYear", "Visibility of object",
+			  stopday-startday+1,startdayROOT,stopdayROOT, 
+			  daySlices+1,-450,fgSecPerDay+450);
+
+  // Observability hours per day MJD
+  fMjdObsHours = new TH1D("fMjdObsHours", "Observation hours per day",
+			  stopday-startday+1,startdayROOT,stopdayROOT);
+
+  if (fUseMoon) {
+    // 2D Plot ZA of moon vs MJD and UTC
+    fMjdUtcYearMoon =new TH2D("fMjdUtcYearMoon", "Moon ZA",
+     			 stopday-startday+1,startdayROOT,stopdayROOT,
+     			 daySlices+1,-450,fgSecPerDay+450);
+
+    // Moon phase vs MJD
+    fMjdMoonPhase =new TH1D("fMjdMoonPhase", "Moon phase",
+     			 stopday-startday+1,startdayROOT,stopdayROOT);
+    // Moon distance of object vs MJD
+    fMjdMoonDistance =new TH1D("fMjdMoonDistance", "Moon distance",
+     			 stopday-startday+1,startdayROOT,stopdayROOT);
+    // Moon intensity at object vs MJD
+    fMjdMoonIntensity =new TH1D("fMjdMoonIntensity", "Moon intensity at locus of object",
+     			 stopday-startday+1,startdayROOT,stopdayROOT);
+
+  }
+
+  if (fUsePlanets) {
+    // Distance of closest planet vs MJD
+    fMjdPlanetDistance =new TH1D("fMjdPlanetDistance", "PlanetDistance",
+     			 stopday-startday+1,startdayROOT,stopdayROOT);
+  }
+
+   
+  // Array which holds total visibility time for whole year [0] and
+  // each month [1]..[12]
+  Float_t visibility[13][18];
+  memset(visibility, 0, 13*18*sizeof(Float_t));
+  /*
+  for (int m=0;m<13;m++)
+    for (int z=0;z<18;z++)
+      visibility[m][z]=0;
+  */
+  int fday, ftime;
+  Double_t phase=0;	
+  Double_t obsHours;
+
+  for (UInt_t day=startday; day<stopday+1; day++) {     
+    Double_t todaysPhase=0;
+    Double_t moonIntensity;
+    obsHours=0;
+    for (UInt_t i=0; i<daySlices; i++)
+      {	 
+	// Rearrange filling of bins such that a "day" doesn't start at midnight,
+	// but rather at noon. This results in plots in which a "day" covers
+	// a whole night.
+	if (i>=(daySlices/2)) {
+	  fday=day;
+	  ftime=i-(daySlices/2);
+	} else {
+	  fday=day-1;
+	  ftime=i+(daySlices/2);
+	}
+
+	// Objects access fTime via parameter list...
+	fTime->SetMJD(day,(Double_t)i/daySlices);
+
+	if (fUseSun)  fSun->Process();
+	if (fUseMoon) fMoon->Process();
+
+	if (fUseSun && fUseMoon) {
+
+	  // Calculate moon phase...
+	  phase = fSun->GetEcLong() - fMoon->GetEcLong();	 
+	  phase = TMath::Pi()-(acos(cos(phase)*cos(fMoon->GetEcLat())));
+	  phase = phase*180/TMath::Pi();
+	  todaysPhase+=phase;
+      
+	}
+	
+	// If sun is not up (or we should not use sun information...)
+	if (fSun->GetAltitudeDeg() < fAstronomicalDarkness) {
+	  // Calculate Position of object:	  
+	  fObject->Process();		 	 	    
+
+	  // Calculate moon brightness at locus of object
+	  // now this is gonna be fun...
+
+	  /* Evaluates predicted LUNAR part of sky brightness, in
+	   * V magnitudes per square arcsecond,
+	   */
+
+	  moonIntensity = LunSkyBright(phase/180, fObject->GetDistance(fMoon),
+						fMoon->GetAltitudeDeg(), fObject->GetAltitudeDeg());
+	  fMjdMoonIntensity->Fill(fgSecPerDay*(fday-fgMJD010170),moonIntensity);
+
+	
+
+	  // If moon is not up (or we should not use moon information...)
+	  if (!fUseMoon || fMoon->GetAltitudeDeg()<=0 || moonIntensity<60) {
+	    // Fill MJD-UTC histogram
+	    fMjdUtcYear->Fill(fgSecPerDay*(fday-fgMJD010170),fgSecPerDay*ftime/daySlices,fObject->GetAltitudeDeg());
+	  }
+	  
+	  // Sum up visibility time (only if moon not visible or moon
+	  // info shouldn't be used at all)
+	  if ((!fUseMoon)||(fMoon->GetAltitudeDeg()<=0)||(moonIntensity<60)) {
+	    // Calculate 
+	    for (int z=0;z<18;z++) {
+	      if (fObject->GetAltitudeDeg()>(z*5)) {
+		visibility[0][z]+=(Double_t)(60*24/daySlices);
+		visibility[(Int_t)fTime->GetMonth()][z]+=(Double_t)(60*24/daySlices);
+	      }
+	    }	//for
+	  
+	    if ((fObject->GetAltitudeDeg())>40) {
+	      fMjdObsHours->Fill(fgSecPerDay*(fday-fgMJD010170),(Double_t)(24/(Double_t)daySlices));
+	    }
+
+	  }
+
+	 
+	} //fi sun 	 	  
+
+	// Optional: Fill histo with moon-up times...
+	// if (fMoon->GetAltitudeDeg() >0) 
+	// fMjdUtcYearMoon->Fill(fgSecPerDay*(day-fgMJD010170),fgSecPerDay*i/daySlices,phase);	
+	// fMoon->Process();
+	// Double_t phase;	
+	// phase = fSun->GetEcLong() - moon->GetEcLong();	 
+	// phase = TMath::Pi()-(acos(cos(phase)*cos(moon->GetEcLat())));
+	// cout << "Phase: " << phase*180/TMath::Pi() << endl;
+	
+      } //for daySlices
+
+    // Distance of Venus to object
+
+    if (fUsePlanets) {
+      fVenus->Process();
+      fMars->Process();
+      fJupiter->Process();
+      fSaturn->Process();
+
+      Double_t distance = fVenus->GetDistance(fObject);
+      distance = TMath::Min(distance, fMars->GetDistance(fObject));
+      distance = TMath::Min(distance, fJupiter->GetDistance(fObject));
+      distance = TMath::Min(distance, fSaturn->GetDistance(fObject));
+
+      fMjdPlanetDistance->Fill(fgSecPerDay*(fday-fgMJD010170),distance);      
+    }
+
+    fMjdMoonPhase->Fill(fgSecPerDay*(fday-fgMJD010170),todaysPhase/i);
+    fMjdMoonDistance->Fill(fgSecPerDay*(fday-fgMJD010170),fMoon->GetDistance(fObject));
+
+    
+  } //for days
+
+    
+  // Here we print the tables with visibilities...
+  cout << "Visibility time [hours]: " << endl;
+   
+  for (int z=1;z<17;z++) {
+    if (visibility[0][z]==0) break;
+    printf("Alt>%2d|%6d|",z*5,(Int_t)(visibility[0][z]/60));      
+    for (int m=1;m<13;m++) {
+      printf("%5d ",(Int_t)(visibility[m][z]/60));	
+    }
+    printf("\n");
+  }
+  
+  int vistimestart=0;
+  int vistimeend=0;  
+  for (int m=1; m<13; m++) {
+    int n = (m==1 ? 12 : m-1);
+    if (visibility[m][8]/60>20 && visibility[n][8]/60<=20) {
+      vistimestart=m; // we're on the rising slope
+    }
+  }
+  
+  for (int m=1; m<13; m++) {
+    int n = (m==1 ? 12 : m-1);
+    if (visibility[m][8]/60<20 && visibility[n][8]/60>=20) {
+      vistimeend=n; // we're on the falling slope
+    }
+  }
+  
+  cout << "Visibility (Alt>40) during months: " << vistimestart << "-" << vistimeend << " approx " << visibility[0][8]/60 << "hrs" <<endl;
+
+
+  /*!!!!!!!!!!!!!!!!!!!!!!!*/gROOT->Reset();
+
+  TCanvas *cMjdUtcYear = new TCanvas("cMjdUtcYear", "Object Visibility MjdUtcYear", 1100,500);
+  cMjdUtcYear->cd(0);
+
+  gStyle->SetPalette(1);
+  //  gStyle->SetOptStat(0);
+  gStyle->SetOptFit(0);
+  gStyle->SetFillStyle(0);
+  gStyle->SetFillColor(10);
+  gStyle->SetCanvasColor(10);
+  gStyle->SetDrawBorder(0);
+  gStyle->SetPadColor(10);
+  gStyle->SetPadBorderSize(0);
+  gStyle->SetPadLeftMargin(0.12);
+  gStyle->SetTitleYOffset(1.2);
+  gStyle->SetTitleXOffset(1.2);
+  
+  gStyle->SetPadLeftMargin(0.01);
+  gStyle->SetPadRightMargin(0.1);
+  gStyle->SetPadTopMargin(0.03);
+  gStyle->SetPadBottomMargin(0.12);
+  
+  fMjdUtcYear->SetTitle(fObject->GetObjectName());
+  fMjdUtcYear->GetXaxis()->SetTimeDisplay(1);
+  fMjdUtcYear->GetXaxis()->SetTimeFormat("%b %y");
+  fMjdUtcYear->GetYaxis()->SetTimeDisplay(1);
+  fMjdUtcYear->GetYaxis()->SetTimeFormat("%Hh");
+  gStyle->SetTimeOffset(43200);
+  fMjdUtcYear->GetYaxis()->SetLabelOffset(0.01);
+  fMjdUtcYear->SetMinimum(0);
+  fMjdUtcYear->SetMaximum(90);
+  
+  fMjdUtcYear->GetYaxis()->SetTitle("Hour");
+  fMjdUtcYear->GetXaxis()->SetTitle("Day of year");
+  fMjdUtcYear->GetZaxis()->SetTitle("Altitude");
+  fMjdUtcYear->Draw("SURF2BB9Z");
+  gPad->SetPhi(0);
+  gPad->SetTheta(90);
+  gPad->Modified();
+  
+  TPaveText *pt = new TPaveText(-0.74,-0.35,-0.58,0.52,"");  
+  char ptLine[80];
+  pt->AddText("Visibility time [hrs]:");
+  pt->SetTextAlign(13);
+  pt->SetFillStyle(0);
+  pt->SetBorderSize(0);
+  pt->SetTextFont(42);
+  for (int j=1;j<17;j++) {
+    sprintf (ptLine, "Alt>%i: %i", j*5, (Int_t)visibility[0][j]/60);
+    pt->AddText(ptLine);
+    if (visibility[0][j]==0) break;
+  }
+  pt->Draw();
+
+
+  if (fUseMoon) {
+    TCanvas *cMjdMoon = new TCanvas("cMjdMoon", "the Moon phase", 600,600);
+    gStyle->SetOptTitle(1);
+    cMjdMoon->Divide(1,3);
+    cMjdMoon->cd(1);
+    fMjdMoonPhase->Draw();
+    cMjdMoon->cd(2);
+    fMjdMoonDistance->Draw();
+    cMjdMoon->cd(3);
+    fMjdMoonIntensity->Draw();
+  }
+
+  TCanvas *cObsHours = new TCanvas("cObsHours", "ObsHours per day", 600,400);
+  fMjdObsHours->Draw();
+
+
+
+  if (fUsePlanets) {
+    TCanvas *cMjdPlanets = new TCanvas("cMjdPlanets", "the distance to planets", 600,200);
+    cMjdPlanets->cd(0);
+    fMjdPlanetDistance->Draw();
+  }
+
+    
+  // next histogram
+  Float_t objectHeight[55];
+  Float_t simpleCounter[55];
+  Int_t weekCounter=0;
+  
+  simpleCounter[weekCounter]=0;
+  objectHeight[weekCounter]=0;
+  weekCounter++;
+  
+  const Int_t startday2 = fTime->MJDStartOfYear(year);
+  const Int_t stopday2  = fTime->MJDStartOfYear(year+1)-1;
+  
+    for (int day=startday2; day<stopday2+1; day+=7)
+    {
+        simpleCounter[weekCounter]=weekCounter-1;
+        objectHeight[weekCounter]=0;
+        for (int i=0; i<daySlices; i++)
+        {
+            if (i>=48)
+            {
+                fday=day;
+                ftime=i-48;
+            }
+            else
+            {
+                fday=day-1;
+                ftime=i+48;
+            }
+
+            fTime->SetMJD(day,(Double_t)i/daySlices);
+            fObject->Process();
+            fSun->Process();
+
+            if (fSun->GetAltitudeDeg() < -25.0)
+            {
+                if (objectHeight[weekCounter]<(fObject->GetAltitudeDeg()))
+                    objectHeight[weekCounter]=fObject->GetAltitudeDeg();
+            }
+
+        } //i
+        weekCounter++;
+    } //day
+    simpleCounter[weekCounter]=weekCounter-2;
+    objectHeight[weekCounter]=0;
+    weekCounter++;
+
+    TString months[12] = {"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
+
+    TCanvas *c2 = new TCanvas("c2", "Object Visibility",600,100);
+ 
+    //  gStyle->SetOptTitle(0);
+    //   gStyle->SetPadLeftMargin(0.000001);
+    //   gStyle->SetPadRightMargin(0.000001);
+    //   gStyle->SetPadTopMargin(0.001);
+    //   gStyle->SetPadBottomMargin(0.000001);
+    gPad->SetGrid();
+
+    c2->SetGrid();
+    TGraph *tg=new TGraph(weekCounter,simpleCounter,objectHeight);
+
+    tg->SetMinimum(1);
+    tg->SetMaximum(90);
+
+    Double_t maxza = abs(fObject->GetDec()-fObs->GetLatitude());
+
+    if (maxza > 90) maxza=90;
+    if (maxza < 0) maxza=00;
+
+    cout << "MaxZA:    ";
+    cout << maxza << endl;
+
+    if (maxza < 30) { //colors=green to yellow
+        maxza *= 9/30;
+        maxza += 80;
+
+    } else { //colors=yellow to red
+        maxza -= 30;
+        maxza *= 11/60;
+        maxza += 89;
+    }
+
+  tg->SetFillColor((Int_t)maxza);
+  tg->SetLineColor((Int_t)maxza);
+  tg->SetLineWidth((Int_t)maxza);
+  tg->Draw("AF");
+  
+  tg->GetXaxis()->SetLimits(0,52);
+  tg->GetXaxis()->SetTickLength(0.1);
+  tg->GetXaxis()->SetNdivisions(0);
+  tg->GetYaxis()->SetNdivisions(202);
+  
+  TPaveLabel* l= new TPaveLabel(2,46,35,88, fObject->GetObjectName());
+  l->SetBorderSize(0);
+  l->SetFillStyle(0);
+  l->SetTextAlign(12);
+  l->Draw();
+  
+  if ((vistimestart<13)&&(vistimeend>0)) {
+    TString label=months[vistimestart-1]+"-"+months[vistimeend-1];
+    TPaveLabel* l2= new TPaveLabel(35,46,50,88, label);
+    l2->SetBorderSize(0);
+    l2->SetFillStyle(0);
+    l2->SetTextAlign(32);
+    l2->Draw();
+    
+  }
+  
+  c2->Modified();
+  c2->Update();
+  
+  return kTRUE;
+}
+
+Double_t MVPPlotter::LunSkyBright(Double_t moon_phase,Double_t rho,Double_t altmoon,Double_t alt)
+{
+/* Evaluates predicted LUNAR part of sky brightness, in
+ * V magnitudes per square arcsecond, following K. Krisciunas
+ * and B. E. Schaeffer (1991) PASP 103, 1033.
+ *
+ * moon_phase  = Phase of the Moon, between 0. (no moon) and 1. (full moon),
+ * rho (deg)   = separation of moon and object,
+ * altmoon (deg) = altitude of moon above horizon,
+ * alt (deg)   = altitude of object above horizon
+ */
+
+    double kzen=1.;
+
+    double rho_rad = rho*fgDegToRad;
+    double alpha = 180.*(1. - moon_phase);
+    double Zmoon = (90. - altmoon)*fgDegToRad;
+    double Z = (90. - alt)*fgDegToRad;
+
+    double istar = -0.4*(3.84 + 0.026*fabs(alpha) + 4.0e-9*pow(alpha,4.)); /*eqn 20*/
+    istar =  pow(10.,istar);
+    if(fabs(alpha) < 7.)   /* crude accounting for opposition effect */
+	istar *= 1.35 - 0.05 * fabs(istar);
+	/* 35 per cent brighter at full, effect tapering linearly to
+	   zero at 7 degrees away from full. mentioned peripherally in
+	   Krisciunas and Scheafer, p. 1035. */
+    double fofrho = 229087. * (1.06 + cos(rho_rad)*cos(rho_rad));
+    if(fabs(rho) > 10.)
+        fofrho+=pow(10.,(6.15 - rho/40.));            /* eqn 21 */
+    else if (fabs(rho) > 0.25)
+        fofrho+=6.2e7 / (rho*rho);   /* eqn 19 */
+    else fofrho = fofrho+9.9e8;  /*for 1/4 degree -- radius of moon! */
+
+    double Xzm = sqrt(1.0 - 0.96*sin(Zmoon)*sin(Zmoon));
+
+    if(Xzm != 0.) Xzm = 1./Xzm;
+    else Xzm = 10000.;
+
+    double Xo = sqrt(1.0 - 0.96*sin(Z)*sin(Z));
+    if(Xo != 0.) Xo = 1./Xo;
+    else Xo = 10000.;
+
+    double Bmoon = fofrho * istar * pow(10.,(-0.4*kzen*Xzm))
+        * (1. - pow(10.,(-0.4*kzen*Xo)));   /* nanoLamberts */
+    //    cout << " Bmoon=" << Bmoon;
+    if(Bmoon > 0.001)
+      return(Bmoon); 
+    else return(99999.);
+}
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/MVPPlotter.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/MVPPlotter.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/MVPPlotter.h	(revision 9661)
@@ -0,0 +1,77 @@
+#ifndef MARS_MVPPlotter
+#define MARS_MVPPlotter
+
+#ifndef MARS_MTaskList
+#include "MTaskList.h"
+#endif
+
+#ifndef MARS_MVPObject
+#include "MVPObject.h"
+#endif
+
+#ifndef MARS_MVPTime
+#include "MVPTime.h"
+#endif
+
+#ifndef MARS_MObservatoryLocation
+#include "MObservatoryLocation.h"
+#endif
+
+class TH1D;
+class TH2D;
+class TCanvas;
+
+class MVPPlotter
+{
+private:
+
+  MVPTime   *fTime;
+  MObservatoryLocation *fObs;
+
+  MParList fPlist;
+  MTaskList fTlist;
+
+  Bool_t fUseSun;
+  Bool_t fUseMoon;
+  Bool_t fUsePlanets;
+
+  Double_t fAstronomicalDarkness;
+
+  Int_t fgSecPerDay;
+  Int_t fgMJD010170; // 01-01-70 is JD 40586
+  Double_t fgDegToRad;
+
+  TH2D *fMjdUtcYear;
+  TH2D *fMjdUtcYearMoon;
+  TH1D *fMjdMoonPhase;
+  TH1D *fMjdMoonDistance;
+  TH1D *fMjdPlanetDistance;
+  TH1D *fMjdMoonIntensity;
+  TH1D *fMjdObsHours;
+
+  MVPObject *fObject;
+  MVPObject *fSun;
+  MVPObject *fMoon;
+  MVPObject *fVenus;
+  MVPObject *fMars;
+  MVPObject *fJupiter;
+  MVPObject *fSaturn;
+
+  void SetupObjects();
+
+public:
+    MVPPlotter(const char *name=NULL, const char *title=NULL);
+    ~MVPPlotter();
+
+    void SetObject(MVPObject *o) { fObject=o; }
+    void SetObservatory(MObservatoryLocation *l) { fObs=l; }
+    void SetAstronomicalDarkness(Double_t d) { fAstronomicalDarkness=d; }
+
+    Double_t LunSkyBright(Double_t moon_phase,Double_t rho,Double_t altmoon,Double_t alt);
+    Bool_t CalcYear(Int_t year, UInt_t daySlices);
+
+    ClassDef(MVPPlotter, 2) // Visibility Plotter: The Plotter Routine itself
+}; 
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/MVPTime.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/MVPTime.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/MVPTime.cc	(revision 9661)
@@ -0,0 +1,125 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Robert Wagner  11/2002 <mailto:magicsoft@rwagner.de>
+!
+!   Copyright: MAGIC Software Development, 2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MVPTime                                                                 //
+//                                                                         //
+// Time Container used by the visibility plotter storing times in MJD      //
+//                                                                         //
+// This is a simple time container for the Visibility Plotter. It takes    //
+// "normal" or MJD-formatted time, converts it to MJD and can return MJD.  //
+//                                                                         //
+// The astronomical algorithms used are taken from SLALIB 2.4-8.           //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MVPTime.h"
+
+#include <slalib.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MVPTime);
+
+MVPTime::MVPTime(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MVPTime";
+    fTitle = title ? title : "Storage container for time";      
+}
+
+MVPTime::~MVPTime()
+{
+  // do nothing special.
+}
+
+void MVPTime::SetTime(UInt_t yr, UInt_t mo, UInt_t dy, UInt_t hr, UInt_t mi, UInt_t se)
+{
+  fUT1 = CalendarToUT1(yr, mo, dy, hr, mi, se);  
+  fYear = yr;
+  fMonth = mo;
+  fDay = dy;
+}
+
+void MVPTime::SetMJD(Double_t mjd, Double_t fracMjd)
+{
+  fUT1 = mjd + fracMjd;
+  Double_t fd;
+  Int_t status;
+  slaDjcl (mjd, &fYear, &fMonth, &fDay, &fd, &status);  
+}
+
+// --------------------------------------------------------------------------
+//
+//
+Double_t MVPTime::CalendarToUT1(UInt_t yr, UInt_t mo, UInt_t dy, UInt_t hr, UInt_t mi, UInt_t se)
+{
+  int status;
+  Double_t mjd;
+  slaCldj(yr, mo, dy, &mjd, &status); 
+  switch (status)
+    {
+    case 1:
+      *fLog << "CalendarToMJD Warn: bad year" << endl;
+      break;
+    case 2:
+      *fLog << "CalendarToMJD Warn: bad month" << endl;
+      break;
+    case 3:
+      *fLog << "CalendarToMJD Warn: bad day" << endl;
+      break;
+    }
+  
+  mjd += ((Double_t)hr/24) + ((Double_t)mi/(24*60)) + ((Double_t)se/(24*60*60));
+  return mjd;
+}
+
+// --------------------------------------------------------------------------
+//
+//
+Double_t MVPTime::MJDStartOfYear(UInt_t year)
+{
+  int status;
+  Double_t mjd;
+  slaCldj(year, 1, 1, &mjd, &status); 
+  switch (status)
+    {
+    case 1:
+      *fLog << "CalendarToMJD Warn: bad year" << endl;
+      break;
+    case 2:
+      *fLog << "CalendarToMJD Warn: bad month" << endl;
+      break;
+    case 3:
+      *fLog << "CalendarToMJD Warn: bad day" << endl;
+      break;
+    }
+  return mjd;
+}
+
+void MVPTime::Print(Option_t *) const
+{
+  *fLog << all;
+  *fLog << "Time (MJD) is: " << fUT1 << endl;
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/MVPTime.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/MVPTime.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/MVPTime.h	(revision 9661)
@@ -0,0 +1,37 @@
+#ifndef MARS_MVPTime
+#define MARS_MVPTime
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MVPTime : public MParContainer
+{
+private:
+  Double_t fUT1;
+  Int_t fYear;
+  Int_t fMonth;
+  Int_t fDay;
+  Double_t MVPTime::CalendarToUT1(UInt_t yr, UInt_t mo, UInt_t dy, UInt_t hr, UInt_t mi, UInt_t se);
+ 
+public:
+  MVPTime(const char *name=NULL, const char *title=NULL);
+  ~MVPTime();
+
+  void SetTime(UInt_t yr, UInt_t mo, UInt_t dy, UInt_t hr, UInt_t mi, UInt_t se);
+  void SetMJD(Double_t mjd, Double_t fracMjd = 0);
+  inline Double_t GetMJD() { return fUT1; }
+
+  void Print(Option_t *) const;
+
+  Double_t MJDStartOfYear(UInt_t year);
+  Double_t GetYear() { return fYear; }
+  Double_t GetMonth() { return fMonth; }
+  Double_t GetDay() { return fDay; }
+  
+  ClassDef(MVPTime, 1)
+
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/Makefile
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/Makefile	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/Makefile	(revision 9661)
@@ -0,0 +1,51 @@
+##################################################################
+#
+#   subdirectory makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#------------------------------------------------------------------------------
+
+CINT     = Temp
+
+#------------------------------------------------------------------------------
+
+INCLUDES = -I. \
+	   -I../mbase \
+	   -I../mjobs \
+	   -I../mpedestal \
+	   -I../mbadpixels \
+	   -I../mfileio \
+           -I../mraw \
+           -I../manalysis \
+	   -I../mgui \
+	   -I../mgeom \
+	   -I../msignal \
+	   -I../mcalib \
+	   -I../mfilter \
+	   -I../mhbase \
+	   -I../mimage \
+	   -I../mpointing \
+	   -I../mcamera \
+	   -I../mhist \
+	   -I../mmc \
+	   -I../mreport \
+	   -I../mastro
+
+SRCFILES = \
+        MStarLocalPos.cc \
+        MStarLocalCam.cc \
+        MFindStars.cc
+
+############################################################
+
+all: $(OBJS)
+
+include ../Makefile.rules
+
+clean:	rmcint rmobjs rmcore rmlib
+mrproper:	clean rmbak
Index: /tags/Mars_V0-8-5/Mars/mtemp/TempIncl.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/TempIncl.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/TempIncl.h	(revision 9661)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-8-5/Mars/mtemp/TempLinkDef.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/TempLinkDef.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/TempLinkDef.h	(revision 9661)
@@ -0,0 +1,11 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class MStarLocalPos+;
+#pragma link C++ class MStarLocalCam+;
+#pragma link C++ class MFindStars+;
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtemp/mberlin/macros/AlphaPlot.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mberlin/macros/AlphaPlot.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mberlin/macros/AlphaPlot.C	(revision 9661)
@@ -0,0 +1,250 @@
+#include "TString.h"
+#include "TChain.h"
+#include "TCanvas.h"
+#include "TH1F.h"
+#include "TF1.h"
+#include "TLegend.h"
+#include "TArrayF.h"
+#include "TGraphErrors.h"
+#include "MRawRunHeader.h"
+#include "TPad.h"
+#include "TPaveText.h"
+#include "iostream.h"
+#include "TObjArray.h"
+#include "TFile.h"
+
+//--------------------------------------------------------------------------------------
+// MAIN INPUT/OUTPUT
+
+#include "IOMkn421.h"
+//--------------------------------------------------------------------------------------
+
+Double_t signal(Double_t *x, Double_t *par)
+{
+    return par[0]/(TMath::Sqrt(2.*TMath::Pi())*par[1])*TMath::Exp(-(x[0]-par[2])*(x[0]-par[2])/2./par[1]/par[1]);
+}
+
+Double_t background(Double_t *x, Double_t *par)
+{
+    return par[0]+par[1]*x[0]+par[2]*x[0]*x[0]+par[3]*x[0]*x[0]*x[0];
+}
+
+Double_t fitFunction(Double_t *x, Double_t *par)
+{
+    return signal(x,par) + background(x,&par[3]);
+}
+
+void AlphaPlot()
+{
+    DistLo*=deg2mm;
+    DistUp*=deg2mm;
+
+    Double_t acut = 10; // alpha region of excess
+    Int_t nbins   = 36;
+    Int_t nbin_flat= nbins/3;
+
+    // input file chain
+    TChain *fEvents=new TChain("Events");
+    fEvents->Add(fileOn1.Data());
+    fEvents->Add(fileOn2.Data());
+
+    TChain *fEventsOff=new TChain("Events");
+    fEventsOff->Add(fileOff1.Data());
+    fEventsOff->Add(fileOff2.Data());
+
+
+    cout<<"Non="<<fEvents->GetEntries()<<"  Noff="<<fEventsOff->GetEntries()<<endl;
+    //************************************************************************
+    // alpha plot + fit
+
+    // make alpha plot (after cuts)
+    TCanvas *c1 = new TCanvas("c1","Alpha distribution after g/h separation",200,10,800,500);
+    c1->SetFillColor(0);
+    c1->SetBorderMode(0);
+    c1->cd();
+
+    TH1F *halpha=new TH1F("halpha","",nbins,0.,90.);
+    halpha->GetXaxis()->SetTitle("Alpha [deg]");
+    halpha->GetYaxis()->SetTitle("Counts");
+
+    TH1F *halphaOff=new TH1F("halphaOff","",nbins,0.,90.);
+    halpha->SetStats(kFALSE);
+    halphaOff->SetStats(kFALSE);
+
+    TString strcut=Form("MHillas.fSize>%f",SizeLo);
+
+    strcut+=Form("&& MHillasSrc.fDist>%f",DistLo);
+    strcut+=Form("&& MHillasSrc.fDist<%f",DistUp);
+
+    strcut+=Form("&& MHillas.fWidth>%f",WidthLo);
+    strcut+=Form("&& MHillas.fWidth<%f",WidthUp);
+
+    strcut+=Form("&& MHillas.fLength>%f",LengthLo);
+    strcut+=Form("&& MHillas.fLength<%f",LengthUp);
+
+    // fill histograms
+    fEvents->Project("halpha","TMath::Abs(MHillasSrc.fAlpha)",strcut.Data());
+    halpha->SetLineWidth(2);
+    halpha->DrawCopy("e");
+
+    fEventsOff->Project("halphaOff","TMath::Abs(MHillasSrc.fAlpha)",strcut.Data());
+    halphaOff->SetLineColor(2);
+    halphaOff->SetLineWidth(2);
+
+
+    // scale Off histogram to On data using bins nbin_flat(first bin after peak) - nbins
+    Double_t nsample_on=0;
+    Double_t nsample_off=0;
+    for(Int_t i=nbin_flat;i<nbins;i++)
+        nsample_on+=halpha->GetBinContent(i);
+    for(Int_t i=nbin_flat;i<nbins;i++)
+        nsample_off+=halphaOff->GetBinContent(i);
+
+    Double_t scal=nsample_on/nsample_off;
+    halphaOff->Sumw2();
+    halphaOff->Scale(scal);
+    halphaOff->Draw("e same");
+
+    gPad->SetGridx();
+    gPad->SetGridy();
+
+    //--------------------------------------------------------------------------
+    // fit alpha hist
+    TF1 *backFcn = new TF1("backFcn",background,20.,89.5,4);
+    backFcn->SetLineWidth(2);
+    backFcn->SetLineColor(kRed);
+
+    TF1 *signalFcn = new TF1("signalFcn",signal,0.,89.5,3);
+    signalFcn->SetLineWidth(2);
+    signalFcn->SetLineColor(kBlue);
+    signalFcn->SetNpx(500);
+
+    TF1 *fitFcn = new TF1("fitFcn",fitFunction,0.,89.5,7);
+    fitFcn->SetNpx(500);
+    fitFcn->SetLineWidth(2);
+    fitFcn->SetLineColor(kMagenta);
+
+    // start-parameters
+    Double_t p3start=halpha->GetBinContent(halpha->GetNbinsX()-1);
+    Double_t p4start=0.;
+    Double_t p5start=0.;
+    Double_t p6start=0.;
+
+    Double_t p0start=(halpha->GetEntries()-p3start*nbins)*halpha->GetBinWidth(1);
+    Double_t p1start=5.;
+    Double_t p2start=0.;
+
+    cout<<"Start values for fit:"<<endl;
+
+    cout<<" Gaussian:"<<endl;
+    cout<<"  p0 = "<<p0start<<endl;
+    cout<<"  p1 = "<<p1start<<endl;
+    cout<<"  p2 = "<<p2start<<endl;
+
+    cout<<" Pol3:"<<endl;
+    cout<<"  p0 = "<<p3start<<endl;
+    cout<<"  p1 = "<<p4start<<endl;
+    cout<<"  p2 = "<<p5start<<endl;
+    cout<<"  p3 = "<<p6start<<endl<<endl<<endl;
+
+    // background fit
+    Double_t parb[4];
+    backFcn->SetParameters(p3start,p4start,p5start,p6start);
+    backFcn->FixParameter(1,0);   // deriv. at zero equal zero
+    //backFcn->FixParameter(2,0); // no 2nd order term
+    backFcn->FixParameter(3,0);   // no 3rd order term
+    halpha->Fit ("backFcn","RN");
+    backFcn->GetParameters(parb);
+
+    // total fit
+    Double_t par[7];
+    fitFcn->SetParameters(p0start,p1start,p2start,
+                          parb[0],parb[1],parb[2],parb[3]);
+
+    fitFcn->FixParameter(2,0.);
+    fitFcn->FixParameter(3,parb[0]);
+    fitFcn->FixParameter(4,parb[1]);
+    fitFcn->FixParameter(5,parb[2]);
+    fitFcn->FixParameter(6,parb[3]);
+    halpha->Fit ("fitFcn","RN");
+
+    // draw fit results + legend
+    TLegend *legend=new TLegend(0.4,0.5,0.93,0.65);
+    legend->SetTextFont(40);
+    legend->SetTextSize(0.04);
+    legend->SetFillColor(19);
+    legend->AddEntry(halpha,"Data","lp");
+    TString strpol("");
+    strpol=Form("Polynom");
+    legend->AddEntry(backFcn,strpol.Data(),"l");
+    legend->AddEntry(fitFcn,"Global Fit","l");
+    //legend->Draw();
+
+    fitFcn->GetParameters(par);
+    fitFcn->SetRange(-90.,90.);
+    fitFcn->SetLineWidth(2);
+    fitFcn->Draw("same");
+
+    signalFcn->SetParameters(par);
+    //signalFcn->SetLineWidth(2);
+    //signalFcn->Draw("same");
+
+    backFcn->SetParameters(&par[3]);
+    backFcn->SetRange(-90,90);
+    backFcn->SetLineWidth(2);
+    backFcn->Draw("same");
+
+    //-----------------------------------------------------------------------
+    // calculate significance
+
+    // analytical method
+    Double_t nSig=signalFcn->Integral(0.,acut)/halpha->GetBinWidth(1);
+    Double_t nOffScaled=backFcn->Integral(0.,acut)/halpha->GetBinWidth(1);
+
+    Double_t nOn=nSig+nOffScaled;
+
+    // significance after Li/Ma
+    Double_t theta=1.; // should be = Ton/Toff ???
+    Double_t nOff=nOffScaled/theta;
+    Double_t siglima = sqrt(2*(nOn*TMath::Log((1+theta)*nOn/(theta*(nOn+nOff)))
+                               +nOff*TMath::Log((1+theta)*(nOff/(nOn+nOff)))));
+
+    // "standard" significance
+    Double_t sigstd  = nSig/sqrt(nOn+nOffScaled);
+
+    TPaveText *pt = new TPaveText(0.25,0.75,0.56,0.98,"brNDC");
+    pt->SetTextFont(60);
+    pt->SetTextSize(0.03);
+    pt->SetTextAlign(12);
+
+    TString strcut1(Form("cuts:"));
+    TString strcut3(Form(" |alpha| <  %4.2f ",acut));
+    pt->AddText(strcut3.Data());
+    TString str("");
+    pt->AddText(str);
+
+    TString strsig(Form("NExcess = %d",Int_t(nSig)));
+    pt->AddText(strsig.Data());
+    TString strbak(Form("NOff    = %d",Int_t(nOffScaled)));
+    pt->AddText(strbak.Data());
+    pt->AddText(str);
+
+    TString strsg(Form("Significance (Li/Ma) = %4.2f",siglima));
+    pt->AddText(strsg.Data());
+    strsg=Form("Significance (std) = %4.2f",sigstd);
+    pt->AddText(strsg.Data());
+    pt->Draw();
+
+    cout<<endl<<"Results for events with |alpha| < "<<acut<<" degrees :"<<endl;
+    cout<<" noff         ="<<nOffScaled<<endl;
+    cout<<" nexcess      ="<<nSig<<endl;
+    cout<<" sig. (Li/Ma) ="<<siglima<<endl;
+    cout<<" sig.-std     ="<<sigstd<<endl<<endl<<endl;
+
+    gPad->SetGridx();
+    gPad->SetGridy();
+
+    c1->Update();
+
+    return;
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/mberlin/macros/Convert2Matrix.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mberlin/macros/Convert2Matrix.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mberlin/macros/Convert2Matrix.C	(revision 9661)
@@ -0,0 +1,93 @@
+#include "TString.h"
+#include "TChain.h"
+#include "TFile.h"
+#include "TH1F.h"
+#include "TMatrix.h"
+
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MReadTree.h"
+#include "MHMatrix.h"
+#include "MFillH.h"
+#include "MEvtLoop.h"
+
+//--------------------------------------------------------------------------------------
+// MAIN INPUT/OUTPUT
+
+#include "IOMkn421.h"
+//--------------------------------------------------------------------------------------
+
+void Convert2Matrix()
+{
+    //------------------------------------------------------
+    // ON + OFF data to be filled into matrix
+
+    MReadTree readOn("Events", fileOptOn);
+    MReadTree readOff("Events", fileOptOff);
+
+    const Int_t nent=readOn.GetEntries();
+
+    //------------------------------------------------------
+
+    // process On data
+    MParList plistOn;
+    MTaskList tlistOn;
+    plistOn.AddToList(&tlistOn);
+
+    readOn.DisableAutoScheme();
+
+    TString sdist  = Form("MHillasSrc.fDist*%f",mm2deg);
+  
+    MHMatrix matOn("Matrix");
+    matOn.AddColumn("MHillas.fSize");  // 0
+    matOn.AddColumn(sdist.Data());     // 1
+    matOn.AddColumn("MHillas.fWidth"); // 2
+    matOn.AddColumn("MHillas.fLength");// 3
+    matOn.AddColumn("MHillasSrc.fAlpha");
+    plistOn.AddToList(&matOn);
+    MFillH fillOn("Matrix");
+
+    tlistOn.AddToList(&readOn);
+    tlistOn.AddToList(&fillOn);
+
+    MEvtLoop evtloopOn;
+    evtloopOn.SetParList(&plistOn);
+
+    if (!evtloopOn.Eventloop(0.5*nent))
+        return;
+
+    tlistOn.PrintStatistics();
+
+    TFile fileOn2(fileMatOn.Data(),"recreate","");
+    matOn.Write();
+    fileOn2.Close();
+
+
+    // process Off data
+
+    MParList plistOff;
+    MTaskList tlistOff;
+    plistOff.AddToList(&tlistOff);
+
+    readOff.DisableAutoScheme();
+
+    MHMatrix matOff("Matrix");
+    matOff.AddColumns(matOn.GetColumns());
+    plistOff.AddToList(&matOff);
+    MFillH fillOff("Matrix");
+
+    tlistOff.AddToList(&readOff);
+    tlistOff.AddToList(&fillOff);
+
+    MEvtLoop evtloopOff;
+    evtloopOff.SetParList(&plistOff);
+
+    if (!evtloopOff.Eventloop())
+        return;
+
+    tlistOff.PrintStatistics();
+
+    TFile fileOff2(fileMatOff.Data(),"recreate","");
+    matOff.Write();
+    fileOff2.Close();
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/mberlin/macros/CutOptim.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mberlin/macros/CutOptim.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mberlin/macros/CutOptim.C	(revision 9661)
@@ -0,0 +1,468 @@
+#include "TMinuit.h"
+#include "TMatrix.h"
+#include "TString.h"
+#include "TCanvas.h"
+#include "TH1F.h"
+#include "TF1.h"
+#include "TLegend.h"
+#include "TFile.h"
+#include "TArrayF.h"
+#include "TGraphErrors.h"
+#include "MRawRunHeader.h"
+#include "TPad.h"
+#include "TPaveText.h"
+#include "iostream.h"
+#include "TObjArray.h"
+
+#include "MHMatrix.h"
+
+//--------------------------------------------------------------------------------------
+// MAIN INPUT/OUTPUT
+
+#include "IOMkn421.h"
+//--------------------------------------------------------------------------------------
+
+Double_t acut = 10; // alpha region of excess
+Bool_t aplot  = 1;  // make only alpha plot (1) , do sig. optimization and alpha plot (0)
+
+//--------------------------------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------------------------------
+
+const TMatrix *matOn;
+const TMatrix *matOff;
+
+Int_t isize   = 0;
+Int_t idist   = 1;
+Int_t iwidth  = 2;
+Int_t ilength = 3;
+Int_t ialpha  = 4;
+
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+
+Double_t signal(Double_t *x, Double_t *par){
+    return par[0]/(TMath::Sqrt(2.*TMath::Pi())*par[1])*TMath::Exp(-(x[0]-par[2])*(x[0]-par[2])/2./par[1]/par[1]);
+}
+
+Double_t background(Double_t *x, Double_t *par){
+    return par[0]+par[1]*x[0]+par[2]*pow(x[0],2.)+par[3]*x[0]*x[0]*x[0];
+    //return par[0]+par[1]*x[0]+par[2]*x[0]*x[0]+par[3]*x[0]*x[0]*x[0];
+}
+
+Double_t fitFunction(Double_t *x, Double_t *par){
+    return signal(x,par) + background(x,&par[3]);
+}
+
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)
+{
+    Double_t w1=par[0];
+    Double_t w2=par[1];
+    Double_t l1=par[2];
+    Double_t l2=par[3];
+    Double_t d1=par[4];
+    Double_t d2=par[5];
+
+    Double_t non=0;
+    Double_t noff=0;
+
+    TH1F hon("hon","",18,0.,90.);//5 deg bins
+    for(Int_t i=0;i<matOn->GetNrows();i++)
+    {
+        if( (*matOn)(i,isize)<SizeLo) continue;
+        if(((*matOn)(i,idist)>d1)  ||((*matOn)(i,idist)<d2  )) continue;
+
+        if(((*matOn)(i,iwidth)>w1) ||((*matOn)(i,iwidth)<w2))  continue;
+        if(((*matOn)(i,ilength)>l1)||((*matOn)(i,ilength)<l2)) continue;
+
+        Float_t alpha=(*matOn)(i,ialpha);
+        hon.Fill(TMath::Abs(alpha));
+    }
+
+    for(Int_t i=1;i<=4;i++)
+        non+=hon.GetBinContent(i);
+
+    //-----------------------------------------------------------------
+    /*TH1F hoff("hoff","",18,0.,90.);//5 deg bins
+    for(Int_t i=0;i<matOff->GetNrows();i++)
+    {
+        if( (*matOff)(i,isize)<SizeLo) continue;
+        if(((*matOff)(i,idist)>d1)  ||((*matOff)(i,idist)<d2  )) continue;
+
+        if(((*matOff)(i,iwidth)>w1) ||((*matOff)(i,iwidth)<w2))  continue;
+        if(((*matOff)(i,ilength)>l1)||((*matOff)(i,ilength)<l2)) continue;
+
+        Float_t alpha=(*matOff)(i,ialpha);
+        hoff.Fill(TMath::Abs(alpha));
+    }
+
+    for(Int_t i=1;i<=4;i++)
+        noff+=hoff.GetBinContent(i);*/
+    //-----------------------------------------------------------------
+
+    // flat background region
+    for(Int_t i=7;i<=15;i++)
+        noff+=hon.GetBinContent(i);
+
+    Float_t offscale=4./9.;
+    noff*=offscale;
+
+    if(non+noff<0.001)
+        f=0.;
+    else
+        f = -(non-noff)/(TMath::Sqrt(non+noff));
+
+    cout<<"Non="<<non<<" Noff="<<noff*offscale<<" Sig="<<-f<<endl;
+}
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+void CutOptim()
+{
+    //-----------------------------------------------------------------------
+    // read matrices
+
+    MHMatrix hmatOn;
+    TFile *fileOn=new TFile(fileMatOn.Data());
+    hmatOn.Read("Matrix");
+    delete fileOn;
+    const TMatrix &mOn=hmatOn.GetM();
+    matOn=(const TMatrix*)&mOn;
+
+    MHMatrix hmatOff;
+    TFile *fileOff=new TFile(fileMatOff.Data());
+    hmatOff.Read("Matrix");
+    delete fileOff;
+    const TMatrix &mOff=hmatOff.GetM();
+    matOff=(const TMatrix*)&mOff;
+
+    //-----------------------------------------------------------------------
+
+    Int_t nrowOn  = matOn->GetNrows();
+    Int_t nrowOff = matOff->GetNrows();
+
+    Int_t ncolOn  = matOn->GetNcols();
+    Int_t ncolOff = matOff->GetNcols();
+
+    cout<<"matrix On:  ncol="<<ncolOn<<" nrow="<<nrowOn<<endl;
+    cout<<"matrix Off: ncol="<<ncolOff<<" nrow="<<nrowOff<<endl;
+
+    TCanvas *c = new TCanvas("c1","Alpha distribution after g/h separation",200,10,800,500);
+    c->SetFillColor(0);
+
+    //-----------------------------------------------------------------------
+    // optimize cuts
+
+    Int_t iflag;
+    Double_t val;
+    Double_t vstart[6];
+
+    Double_t *gin=NULL;
+
+    Double_t arglist[10];
+    Int_t ierflg = 0;
+
+    TMinuit *gMinuit = new TMinuit(10);
+    TGraph* gr=NULL;
+
+    if(!aplot)
+        c->Divide(2,1);
+    else
+        goto APlot;
+
+    // start values
+    vstart[0]=WidthUp;
+    vstart[1]=WidthLo;
+    vstart[2]=LengthUp;
+    vstart[3]=LengthLo;
+    vstart[4]=DistUp;
+    vstart[5]=DistLo;
+
+    gMinuit->SetFCN(fcn);
+
+    arglist[0] = 1;
+    gMinuit->mnexcm("SET ERR", arglist ,1,ierflg);
+
+    // Set starting values and step sizes for parameters
+    static Double_t step[6];
+    const Double_t def_step=0.2;
+    step[0]=def_step;
+    step[1]=def_step;
+    step[2]=def_step;
+    step[3]=def_step;
+    step[4]=def_step;
+    step[5]=def_step;
+
+    gMinuit->mnparm(0,"w1", vstart[0], step[0], 0.,0.,ierflg);
+    gMinuit->mnparm(1,"w2", vstart[1], step[1], 0.,0.,ierflg);
+    gMinuit->mnparm(2,"l1", vstart[2], step[2], 0.,0.,ierflg);
+    gMinuit->mnparm(3,"l2", vstart[3], step[3], 0.,0.,ierflg);
+    gMinuit->mnparm(4,"d1", vstart[4], step[4], 0.2,1.,ierflg);
+    gMinuit->mnparm(5,"d2", vstart[5], step[5], 0.5,1.5,ierflg);
+
+    //gMinuit->FixParameter(0);  // WidthUp
+    gMinuit->FixParameter(1);   // WidthLo
+    //gMinuit->FixParameter(2);  // LengthUp
+    gMinuit->FixParameter(3);   // LengthLo
+    gMinuit->FixParameter(4);   // DistUp
+    gMinuit->FixParameter(5);   // DistLo
+
+    gMinuit->Eval(6,gin,val,vstart,iflag);
+
+    arglist[0] = 5000;
+    arglist[1] = 1.;
+
+    //gMinuit->mnexcm("MIGRAD", arglist ,2,ierflg);
+    gMinuit->mnexcm("SIM", arglist ,2,ierflg);
+
+    // Print results
+    Double_t amin,edm,errdef;
+    Int_t nvpar,nparx,icstat;
+    gMinuit->mnstat(amin,edm,errdef,nvpar,nparx,icstat);
+    gMinuit->mnprin(3,amin);
+
+    Double_t fpar[6];
+    Double_t fparerr[6];
+    for(Int_t i=0;i<6;i++)
+        gMinuit->GetParameter(i,fpar[i],fparerr[i]);
+
+    WidthUp  = fpar[0];
+    WidthLo  = fpar[1];
+    LengthUp = fpar[2];
+    LengthLo = fpar[3];
+    DistUp   = fpar[4];
+    DistLo   = fpar[5];
+
+
+    // parameter's sigma plots
+    c->cd(2);
+    // 2 sigma contour
+    /*
+    gMinuit->SetErrorDef(4);
+    gr = (TGraph*) gMinuit->Contour(100,0,2);
+    gr->DrawClone("AL");*/
+
+    // 1 sigma contour
+    gMinuit->SetErrorDef(1);
+    gr = (TGraph*) gMinuit->Contour(100,0,2);
+    gr->DrawClone("AL");
+    /*
+    // contour of min. function
+    c->cd(2);
+    arglist[0] = 1; // WidthUp
+    gMinuit->mnexcm("SCA", arglist ,1,ierflg);
+    TGraph* gr = (TGraph*)gMinuit->GetPlot();
+    gr->DrawClone("al");
+
+    c->cd(4);
+    arglist[0] = 4; // LengthLo
+    gMinuit->mnexcm("SCA", arglist ,1,ierflg);
+    gr = (TGraph*)gMinuit->GetPlot();
+    gr->DrawClone("al");//*/
+
+    c->cd(1);
+
+APlot:
+    //-----------------------------------------------------------------------
+    // plot alpha histogram with current cuts and calc significance
+
+    // alpha histogram
+    TH1F *halpha=new TH1F("halpha","",18,0.,90.);
+    TH1F *halphaOff=new TH1F("halphaOff","",18,0.,90.);
+
+    halpha->SetStats(kFALSE);
+    halphaOff->SetStats(kFALSE);
+
+    for(Int_t i=0;i<nrowOn;i++)
+    {
+        if (mOn(i,isize)<SizeLo) continue;
+        if((mOn(i,idist)<DistLo)||(mOn(i,idist)>DistUp)) continue;
+
+        if((mOn(i,iwidth) < WidthLo) ||(mOn(i,iwidth) > WidthUp))  continue;
+        if((mOn(i,ilength)< LengthLo)||(mOn(i,ilength)> LengthUp)) continue;
+
+        halpha->Fill(TMath::Abs(mOn(i,ialpha)));
+    }
+    halpha->SetLineWidth(2);
+    halpha->DrawClone();
+
+    for(Int_t i=0;i<nrowOff;i++)
+    {
+        if (mOff(i,isize)<SizeLo) continue;
+        if((mOff(i,idist)<DistLo)||(mOff(i,idist)>DistUp)) continue;
+
+        if((mOff(i,iwidth) < WidthLo) ||(mOff(i,iwidth) > WidthUp))  continue;
+        if((mOff(i,ilength)< LengthLo)||(mOff(i,ilength)> LengthUp)) continue;
+
+        halphaOff->Fill(TMath::Abs(mOff(i,ialpha)));
+
+    }
+
+    // scale Off histogram to On data using bins 6-18
+    Double_t nsample_on=0;
+    Double_t nsample_off=0;
+    for(Int_t i=6;i<18;i++)
+        nsample_on+=halpha->GetBinContent(i);
+    for(Int_t i=6;i<18;i++)
+        nsample_off+=halphaOff->GetBinContent(i);
+
+    Double_t scal=nsample_on/nsample_off;
+
+    halphaOff->SetLineColor(2);
+    halphaOff->Scale(scal);
+    halphaOff->Draw("same");
+
+    gPad->SetGridx();
+    gPad->SetGridy();
+
+    // define functions
+    TF1 *backFcn = new TF1("backFcn",background,20.,89.5,4);
+    backFcn->SetLineWidth(2);
+    backFcn->SetLineColor(kRed);
+
+    TF1 *signalFcn = new TF1("signalFcn",signal,0.,89.5,3);
+    signalFcn->SetLineWidth(2);
+    signalFcn->SetLineColor(kBlue);
+    signalFcn->SetNpx(500);
+
+    TF1 *fitFcn = new TF1("fitFcn",fitFunction,0.,89.5,7);
+    fitFcn->SetNpx(500);
+    fitFcn->SetLineWidth(2);
+    fitFcn->SetLineColor(kMagenta);
+
+    // start-parameters
+    Double_t p3start=halpha->GetBinContent(halpha->GetNbinsX()-1);
+    Double_t p4start=0.;
+    Double_t p5start=0.;
+    Double_t p6start=0.;
+
+    Double_t p0start=(halpha->GetEntries()*halpha->GetBinWidth(1)-p3start)*0.05;
+    Double_t p1start=5.;
+    Double_t p2start=0.;
+
+    cout<<"start values:"<<endl;
+
+    cout<<" gaussian:"<<endl;
+    cout<<"  p0 = "<<p0start<<endl;
+    cout<<"  p1 = "<<p1start<<endl;
+    cout<<"  p2 = "<<p2start<<endl;
+
+    cout<<" pol3:"<<endl;
+    cout<<"  p0 = "<<p3start<<endl;
+    cout<<"  p1 = "<<p4start<<endl;
+    cout<<"  p2 = "<<p5start<<endl;
+    cout<<"  p3 = "<<p6start<<endl<<endl;
+
+
+    // background fit
+    Double_t parb[4];
+    backFcn->SetParameters(p3start,p4start,p5start,p6start);
+    backFcn->FixParameter(1,0);    // deriv. at zero equal zero
+    //backFcn->FixParameter(2,0);  // no 2nd order term
+    backFcn->FixParameter(3,0);    // no 3rd order term
+    //halphaOff->Fit ("backFcn","RN");
+    halpha->Fit ("backFcn","RN");
+    backFcn->GetParameters(parb);
+
+    // total fit
+    Double_t par[7];
+    fitFcn->SetParameters(p0start,p1start,p2start,
+                          parb[0],parb[1],parb[2],parb[3]);
+
+    fitFcn->FixParameter(2,0.);
+    fitFcn->FixParameter(3,parb[0]);
+    fitFcn->FixParameter(4,parb[1]);
+    fitFcn->FixParameter(5,parb[2]);
+    fitFcn->FixParameter(6,parb[3]);
+    halpha->Fit ("fitFcn","RN");
+
+    // draw the legend
+    TLegend *legend=new TLegend(0.4,0.5,0.93,0.65);
+    legend->SetTextFont(40);
+    legend->SetTextSize(0.04);
+    legend->SetFillColor(19);
+    legend->AddEntry(halpha,"Data","lp");
+    TString strpol("");
+    strpol=Form("Polynom");
+    legend->AddEntry(backFcn,strpol.Data(),"l");
+    legend->AddEntry(fitFcn,"Global Fit","l");
+    //legend->Draw();
+
+    // drawing the functions
+    fitFcn->GetParameters(par);
+    fitFcn->SetRange(-90.,90.);
+    fitFcn->SetLineWidth(2);
+    fitFcn->Draw("same");
+
+    signalFcn->SetParameters(par);
+    signalFcn->SetLineWidth(2);
+    //signalFcn->Draw("same");
+
+    backFcn->SetParameters(&par[3]);
+    backFcn->SetRange(-90,90);
+    backFcn->SetLineWidth(2);
+    backFcn->Draw("same");
+
+
+    //-----------------------------------------------------------------------
+    // calculate significance
+
+    // analytical method
+    Double_t nSig=signalFcn->Integral(0.,acut)/halpha->GetBinWidth(1);
+    Double_t nOffScaled=backFcn->Integral(0.,acut)/halpha->GetBinWidth(1);
+
+    Double_t nOn=nSig+nOffScaled;
+
+    // significance after Li/Ma
+    Double_t theta=1.; // should be = Ton/Toff ???
+    nSig=nOn-nOffScaled;
+    Double_t nOff=nOffScaled/theta;
+
+    Double_t siglima = sqrt(2*(nOn*TMath::Log((1+theta)*nOn/(theta*(nOn+nOff)))
+                               +nOff*TMath::Log((1+theta)*(nOff/(nOn+nOff)))));
+
+    // "standard" significance
+    Double_t sigstd  = nSig/sqrt(nOn+nOffScaled);
+
+
+    TPaveText *pt = new TPaveText(0.25,0.75,0.56,0.98,"brNDC");
+ 
+    pt->SetTextFont(60);
+    pt->SetTextSize(0.03);
+    pt->SetTextAlign(12);
+
+    TString strcut1(Form("cuts:"));
+    TString strcut3(Form(" |alpha| <  %4.2f ",acut));
+    pt->AddText(strcut3.Data());
+    TString str("");
+    pt->AddText(str);
+
+    TString strsig(Form("NExcess = %d",Int_t(nSig)));
+    pt->AddText(strsig.Data());
+    TString strbak(Form("NOff    = %d",Int_t(nOffScaled)));
+    pt->AddText(strbak.Data());
+    pt->AddText(str);
+
+    TString strsg(Form("Significance (Li/Ma) = %4.2f",siglima));
+    pt->AddText(strsg.Data());
+
+    cout<<"results for events with alpha < "<<acut<<" degrees :"<<endl;
+    cout<<" nbackground  = "<<nOffScaled<<endl;
+    cout<<" theta        = "<<theta<<endl;
+    cout<<" nsignal      = "<<nSig<<endl;
+    cout<<" sig. (Li/Ma) = "<<siglima<<endl;
+    cout<<" sig.-std     = "<<sigstd<<endl;
+    pt->Draw();
+    gPad->SetGridx();
+    gPad->SetGridy();
+
+    c->Update();
+
+    cout<<endl<<"Optimized Cuts:"<<endl;
+    cout<<" "<<DistLo<<" < dist <"<<DistUp<<endl;
+    cout<<" "<<WidthLo<<" < width <"<<WidthUp<<endl;
+    cout<<" "<<LengthLo<<" < length <"<<LengthUp<<endl;
+
+    return;
+}
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mberlin/macros/IOMkn421.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mberlin/macros/IOMkn421.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mberlin/macros/IOMkn421.h	(revision 9661)
@@ -0,0 +1,152 @@
+//**************************************************************************************************************
+//
+// Sample A ON  = Runs 17206 - 17265
+// Sample A OFF = Runs 17269 - 17283
+//
+// Sample B ON  = Runs 17286 - 17456
+// Sample B OFF = Runs 17459 - 17543
+//
+//**************************************************************************************************************
+
+//**************************************************************************************************************
+// general INPUT
+//**************************************************************************************************************
+
+// pi
+const double  PI=3.14159265358979333;  //atan(1)*4.0
+
+// conversion from deg to mm and vice versa
+const Double_t mm2deg = 180./17000./PI;
+const Double_t deg2mm = 1./mm2deg;
+
+// conversion from rad to deg and vice versa
+const Double_t rad2deg = 180./PI;
+const Double_t deg2rad = 1./rad2deg;
+
+// conversion from millisec to min
+const Double_t msec2min=1./1000./60.;
+
+//--------------------------------------------------------------------------------------------------------------
+// main path
+
+// HUB
+TString inpath = "/users/eeh/hengsteb/MAGIC/Mkn421Feb2004/SlidingWindow/";
+TString path = "/users/eeh/hengsteb/MAGIC/Mkn421Feb2004/";
+
+// laptop
+//TString inpath = "/home/hengsteb/MAGIC/Mkn421Feb2004/";
+//TString path = "/home/hengsteb/MAGIC/Mkn421Feb2004/";
+
+//**************************************************************************************************************
+// INPUT/OUTPUT for MagicHillas.C, ScaleHillas.C, SrcCorrect.C, FSrcPlot.C
+//**************************************************************************************************************
+
+//--------------------------------------------------------------------------------------------------------------
+// Mkn421 ON A
+TString dataOnA="SLIDINGRun17206-17265CalibRun17193_D_Mkn421On_E";
+
+//--------------------------------------------------------------------------------------------------------------
+// Mkn421 OFF A
+TString dataOffA="SLIDINGRun17269-17283CalibRun17268_D_OffMkn421_E";
+
+//--------------------------------------------------------------------------------------------------------------
+// Mkn421 ON B
+TString dataOnB="SLIDINGRun17286-17456CalibRun17285_D_Mkn421On_E";
+
+//--------------------------------------------------------------------------------------------------------------
+// Mkn421 OFF B
+TString dataOffB="SLIDINGRun17459-17543CalibRun17458_D_OffMkn421_E";
+
+//--------------------------------------------------------------------------------------------------------------
+// select the sample!
+TString data=dataOnB;
+
+TString fileCalibData =  inpath + data + ".root";
+TString fileHillas    =  path + data + "_Hillas.root";
+TString fileHScaled   =  path + data + "_HScaled.root";
+TString fileHScalHist =  path + data + "_HScalHist.root";
+
+TString fileFSrcPlot  =  path + data + "_FSrcPlot.root";
+TString fileSrcPos    =  path + data + "_SrcPos.dat";
+
+TString fileFSrcPlotC =  path + data + "_FSrcPlotC.root"; //corrected with known src pos
+TString fileHScaledC  =  path + data + "_HScaledC.root";  //corrected with known src pos
+
+//--------------------------------------------------------------------------------------------------------------
+// dead pixels
+
+const Int_t NDEAD=54;
+const Short_t DEADPIX[NDEAD]=
+{  0,  25,  26,  34,  38,  46,  54, 124, 125, 155, 156, 157, 158, 162, 170, 172, 201, 202, 203, 204, 205,
+ 206, 207, 208, 224, 388, 395 ,397, 440, 441, 442, 443, 444, 445, 446, 483, 484, 485, 486, 487, 488, 489,
+ 490, 532, 533, 534, 535, 536, 537, 538, 539, 540, 543, 559 };
+// 1    2    3    4    5    6    7    8    9   10   11   12   13   14   15   16   17   18   19   20   21
+
+TArrayS blindpix(NDEAD,DEADPIX);
+
+//--------------------------------------------------------------------------------------------------------------
+// default cuts for false source plots
+/*
+//Double_t SizeLo   = 1000.; // #ph
+//Double_t SizeLo   = 1111.; // #ph
+Double_t SizeLo   = 2000.; // #ph
+Double_t DistLo   = 0.6;   // degree
+Double_t DistUp   = 1.4;   // degree
+
+// static cuts
+//Double_t LengthLo = 0.14*deg2mm;  // degree
+//Double_t LengthUp = 0.26*deg2mm;  // degree
+//Double_t WidthLo  = 0.05*deg2mm;  // degree
+//Double_t WidthUp  = 0.14*deg2mm;  // degree
+
+// scaled Hillas
+
+Double_t LengthLo = 0.2525;
+Double_t LengthUp = 0.9312;
+Double_t WidthLo  = 0.2875;
+Double_t WidthUp  = 0.738;
+//*/
+
+//**************************************************************************************************************
+// INPUT/OUTPUT for AlphaPlot.C, CutOptim.C
+//**************************************************************************************************************
+
+//--------------------------------------------------------------------------------------------------------------
+// Mkn421 A + B
+
+// AlphaPlot + LightCurve, CutOptim
+TString fileOn1      = path + dataOnA + "_HScaledC.root";
+TString fileOn2      = path + dataOnB + "_HScaledC.root";
+
+TString fileOff1     = path + dataOffA + "_HScaled.root";
+TString fileOff2     = path + dataOffB + "_HScaled.root";
+
+TString fileRateCFac = path + "Mkn421A+B_CFac.dat";
+TString fileLCurve   = path + "Mkn421A+B_LCurve.dat";
+TString fileAPlots   = path + "Mkn421A+B_APlot.root";
+
+// matrices needed for cut optimization, optimize on sample A
+TString fileOptOn    = path + dataOnA  + "_HScaledC.root";
+TString fileOptOff   = path + dataOffA + "_HScaled.root";
+
+TString fileMatOn    = path + dataOnA  + "_Matrix.root";
+TString fileMatOff   = path + dataOffA + "_Matrix.root";
+
+//--------------------------------------------------------------------------------------------------------------
+// optimized cuts for 1-dim aplot
+
+//Double_t SizeLo   = 1111.; // #ph
+Double_t SizeLo   = 2000.; // #ph
+Double_t DistLo   = 0.55;
+Double_t DistUp   = 1.27;
+//Double_t DistLo   = 1.;
+//Double_t DistUp   = 1.5;
+//Double_t DistLo   = 0.5;
+//Double_t DistUp   = 1.22;
+
+// optimized on half of sample A for scaled Hillas with dist-cut 0.6 - 1.25, size > 1300
+Double_t LengthLo = 0.318;
+Double_t LengthUp = 0.809;
+Double_t WidthLo  = 0.3;
+Double_t WidthUp  = 0.705;
+//*/
Index: /tags/Mars_V0-8-5/Mars/mtemp/mberlin/macros/ScaleHillas.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mberlin/macros/ScaleHillas.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mberlin/macros/ScaleHillas.C	(revision 9661)
@@ -0,0 +1,626 @@
+#include "TH1F.h"
+#include "TH2F.h"
+#include "TH3F.h"
+#include "TLine.h"
+#include "TTree.h"
+
+#include "TCanvas.h"
+#include "TStyle.h"
+#include "TString.h"
+#include "TFile.h"
+#include "TMath.h"
+
+#include "MReadTree.h"
+#include "MSrcPosCam.h"
+#include "MWriteRootFile.h"
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MEvtLoop.h"
+
+#include "MHillas.h"
+#include "MHillasExt.h"
+#include "MHillasExt.h"
+#include "MHillasSrc.h"
+#include "MNewImagePar.h"
+
+#include "MTaskInteractive.h"
+
+#include "iostream.h"
+#include "stdlib.h"
+#include "stdio.h"
+#include "string.h"
+
+//--------------------------------------------------------------------------------------
+// MAIN INPUT/OUTPUT
+
+#include "IOMkn421.h"
+//--------------------------------------------------------------------------------------
+
+Double_t estposx =  0.;
+Double_t estposy =  0.;
+
+//--------------------------------------------------------------------------------------
+// setting for hists
+const Int_t nBinSize=200;
+const Int_t nBinDist=1;
+const Int_t nBinLW=1000;
+
+// limits for size and dist for histograms
+Double_t hSizeLo=2.;
+Double_t hSizeUp=6.;
+Double_t hDistLo=0.5;
+Double_t hDistUp=1.15;
+
+// limits for length, width for histograms
+Double_t hLengthLo=0.;
+Double_t hLengthUp=0.8;
+Double_t hWidthLo =0.;
+Double_t hWidthUp =0.6;
+
+// limits for scaled Hillas for histograms
+Double_t hSLenLo =0.;
+Double_t hSLenUp =15.;
+Double_t hSWidLo =0.;
+Double_t hSWidUp =7.;
+
+// special limits for hLength, hWidth (see ReadHillas())
+const Int_t nBinLWFine=1000;
+Double_t hLenFineLo=0.;
+Double_t hLenFineUp=1.;
+Double_t hWidFineLo=0.;
+Double_t hWidFineUp=1.;
+
+// hists for mean of unscaled Hillas
+TH2F hLenMean("hLenMean","",nBinSize,hSizeLo,hSizeUp, nBinDist,hDistLo,hDistUp);
+TH2F hWidMean("hWidMean","",nBinSize,hSizeLo,hSizeUp, nBinDist,hDistLo,hDistUp);
+
+TH1F hLenMeanSize("hLenMeanSize","",nBinSize,hSizeLo,hSizeUp);
+TH1F hLenMeanDist("hLenMeanDist","",nBinDist,hDistLo,hDistUp);
+TH1F hWidMeanSize("hWidMeanSize","",nBinSize,hSizeLo,hSizeUp);
+TH1F hWidMeanDist("hWidMeanDist","",nBinDist,hDistLo,hDistUp);
+
+// hists for unscaled Hillas
+TH2F hLenSize("hLenSize","",nBinSize,hSizeLo,hSizeUp, nBinLW,hLengthLo,hLengthUp);
+TH2F hLenDist("hLenDist","",nBinDist,hDistLo,hDistUp, nBinLW,hLengthLo,hLengthUp);
+
+TH2F hWidSize("hWidSize","",nBinSize,hSizeLo,hSizeUp, nBinLW,hWidthLo,hWidthUp);
+TH2F hWidDist("hWidDist","",nBinDist,hDistLo,hDistUp, nBinLW,hWidthLo,hWidthUp);
+
+// hists for mean-scaled Hillas
+TH2F hSLenSize("hSLenSize","",nBinSize,hSizeLo,hSizeUp,nBinLW,hSLenLo,hSLenUp);
+TH2F hSLenDist("hSLenDist","",nBinDist,hDistLo,hDistUp,nBinLW,hSLenLo,hSLenUp);
+
+TH2F hSWidSize("hSWidSize","",nBinSize,hSizeLo,hSizeUp,nBinLW,hSWidLo,hSWidUp);
+TH2F hSWidDist("hSWidDist","",nBinDist,hDistLo,hDistUp,nBinLW,hSWidLo,hSWidUp);
+
+
+//****************************************************************************************
+// first part: prepare for scaling, read Hillas to calc mean
+//****************************************************************************************
+
+void ReadHillas()
+{
+    // fill hillas into histograms to calc mean
+    TFile *file=new TFile(fileHillas.Data());
+    TTree *fEvents=(TTree*)file->Get("Events");
+
+    // hists for Hillas
+    // in following 2  hists the binning in length/width should be
+    // very fine (like unbinned) and the limits should be generous
+    TH3F hLength("hLength","",nBinSize,hSizeLo,hSizeUp, nBinDist,hDistLo,hDistUp, nBinLWFine,hLenFineLo,hLenFineUp);
+    TH3F hWidth("hWidth",  "",nBinSize,hSizeLo,hSizeUp, nBinDist,hDistLo,hDistUp, nBinLWFine,hWidFineLo,hWidFineUp);
+
+    TString strlen = Form("MHillas.fLength*%f:MHillasSrc.fDist*%f:log10(MHillas.fSize)",mm2deg,mm2deg);
+    TString strwid = Form("MHillas.fWidth*%f :MHillasSrc.fDist*%f:log10(MHillas.fSize)",mm2deg,mm2deg);
+
+    TString strcut="MHillas.fSize>0";
+    fEvents->Project("hLength",strlen.Data(),strcut.Data());
+    fEvents->Project("hWidth", strwid.Data(),strcut.Data());
+
+    file->Close();
+
+    // fill hists hLenMean, hWidMean (2-dim (size,dist)-hists)
+    for(Int_t i=1;i<=nBinSize;i++)
+        for(Int_t j=1;j<=nBinDist;j++)
+        {
+            Double_t lsum=0.; Double_t lsum2=0.; Double_t lcnt=0.;
+            Double_t wsum=0.; Double_t wsum2=0.; Double_t wcnt=0.;
+
+            for(Int_t k=1;k<=nBinLWFine;k++)
+            {
+                Double_t nl = hLength.GetBinContent(i,j,k);
+                Double_t xl = hLength.GetZaxis()->GetBinCenter(k);
+                
+                lsum +=nl*xl;
+                lsum2+=nl*xl*xl;
+                lcnt +=nl;
+
+                Double_t nw = hWidth.GetBinContent(i,j,k);
+                Double_t xw = hWidth.GetZaxis()->GetBinCenter(k);
+
+                wsum +=nw*xw;
+                wsum2+=nw*xw*xw;
+                wcnt +=nw;
+            }
+
+            Double_t lmean=0.;
+            Double_t lmeanerr=0.;
+            if(lcnt>1)lmean=lsum/lcnt;
+            if(lcnt>2)lmeanerr=(lsum2/lcnt-lmean*lmean)/(lcnt-1.);
+            lmeanerr=TMath::Sqrt(lmeanerr);
+
+            hLenMean.SetBinContent(i,j,lmean);
+            hLenMean.SetBinError(i,j,lmeanerr);
+
+            Double_t wmean=0.;
+            Double_t wmeanerr=0.;
+            if(wcnt>1)wmean=wsum/wcnt;
+            if(wcnt>2)wmeanerr=(wsum2/wcnt-wmean*wmean)/(wcnt-1.);
+            wmeanerr=TMath::Sqrt(wmeanerr);
+
+            hWidMean.SetBinContent(i,j,wmean);
+            hWidMean.SetBinError(i,j,wmeanerr);
+        }
+
+    // fill hists hLenMeanSize, hWidMeanSize (1-dim hists, x-axis = size)
+    for(Int_t i=1;i<=nBinSize;i++)
+    {
+        Double_t lsum=0.; Double_t lsum2=0.; Double_t lcnt=0.;
+        Double_t wsum=0.; Double_t wsum2=0.; Double_t wcnt=0.;
+
+        for(Int_t j=1;j<=nBinDist;j++)
+            for(Int_t k=1;k<=nBinLWFine;k++)
+            {
+                Double_t nl = hLength.GetBinContent(i,j,k);
+                Double_t xl = hLength.GetZaxis()->GetBinCenter(k);
+                
+                lsum +=nl*xl;
+                lsum2+=nl*xl*xl;
+                lcnt +=nl;
+
+                Double_t nw = hWidth.GetBinContent(i,j,k);
+                Double_t xw = hWidth.GetZaxis()->GetBinCenter(k);
+
+                wsum +=nw*xw;
+                wsum2+=nw*xw*xw;
+                wcnt +=nw;
+            }
+
+        Double_t lmean=0.;
+        Double_t lmeanerr=0.;
+        if(lcnt>1)lmean=lsum/lcnt;
+        if(lcnt>2)lmeanerr=(lsum2/lcnt-lmean*lmean)/(lcnt-1.);
+        lmeanerr=TMath::Sqrt(lmeanerr);
+
+        hLenMeanSize.SetBinContent(i,lmean);
+        hLenMeanSize.SetBinError(i,lmeanerr);
+
+        Double_t wmean=0.;
+        Double_t wmeanerr=0.;
+        if(wcnt>1)wmean=wsum/wcnt;
+        if(wcnt>2)wmeanerr=(wsum2/wcnt-wmean*wmean)/(wcnt-1.);
+        wmeanerr=TMath::Sqrt(wmeanerr);
+
+        hWidMeanSize.SetBinContent(i,wmean);
+        hWidMeanSize.SetBinError(i,wmeanerr);
+    }
+
+    // fill hists hLenMeanDist, hWidMeanDist (1-dim hists, x-axis = dist)
+    for(Int_t j=1;j<=nBinDist;j++)
+    {
+        Double_t lsum=0.; Double_t lsum2=0.; Double_t lcnt=0.;
+        Double_t wsum=0.; Double_t wsum2=0.; Double_t wcnt=0.;
+
+        for(Int_t i=1;i<=nBinSize;i++)
+            for(Int_t k=1;k<=nBinLWFine;k++)
+            {
+                Double_t nl = hLength.GetBinContent(i,j,k);
+                Double_t xl = hLength.GetZaxis()->GetBinCenter(k);
+                
+                lsum +=nl*xl;
+                lsum2+=nl*xl*xl;
+                lcnt +=nl;
+
+                Double_t nw = hWidth.GetBinContent(i,j,k);
+                Double_t xw = hWidth.GetZaxis()->GetBinCenter(k);
+
+                wsum +=nw*xw;
+                wsum2+=nw*xw*xw;
+                wcnt +=nw;
+            }
+
+        Double_t lmean=0.;
+        Double_t lmeanerr=0.;
+        if(lcnt>1)lmean=lsum/lcnt;
+        if(lcnt>2)lmeanerr=(lsum2/lcnt-lmean*lmean)/(lcnt-1.);
+        lmeanerr=TMath::Sqrt(lmeanerr);
+
+        hLenMeanDist.SetBinContent(j,lmean);
+        hLenMeanDist.SetBinError(j,lmeanerr);
+
+        Double_t wmean=0.;
+        Double_t wmeanerr=0.;
+        if(wcnt>1)wmean=wsum/wcnt;
+        if(wcnt>2)wmeanerr=(wsum2/wcnt-wmean*wmean)/(wcnt-1.);
+        wmeanerr=TMath::Sqrt(wmeanerr);
+
+        hWidMeanDist.SetBinContent(j,wmean);
+        hWidMeanDist.SetBinError(j,wmeanerr);
+    }
+
+    return;
+}
+
+
+//****************************************************************************************
+// second part: do scaling
+//****************************************************************************************
+
+// pointer to Hillas ParContainer
+MHillas *fHillas=NULL;
+MHillasSrc *fHillasSrc=NULL;
+
+
+Int_t PreProcess(MParList *plist)
+{
+    fHillas = (MHillas*) plist->FindObject("MHillas");
+    fHillasSrc = (MHillasSrc*) plist->FindObject("MHillasSrc");
+
+    return (fHillas && fHillasSrc) ? kTRUE : kFALSE;
+}
+
+Int_t Process()
+{
+    // estimated source pos.
+    MSrcPosCam srcpos;
+    srcpos.SetXY(estposx*deg2mm,estposy*deg2mm);
+    fHillasSrc->SetSrcPos(&srcpos);
+    fHillasSrc->Calc(fHillas);
+
+    Float_t width   = fHillas->GetWidth();
+    Float_t length  = fHillas->GetLength();
+    Float_t size    = fHillas->GetSize();
+    Float_t meanx   = fHillas->GetMeanX();
+    Float_t meany   = fHillas->GetMeanY();
+    Float_t logsize = TMath::Log10(fHillas->GetSize());
+    Float_t delta   = fHillas->GetDelta();
+    Float_t dist    = fHillasSrc->GetDist();
+
+    width *=mm2deg;
+    length*=mm2deg;
+    dist  *=mm2deg;
+
+    hLenSize.Fill(logsize,length);
+    hLenDist.Fill(dist,length);
+    hWidSize.Fill(logsize,width);
+    hWidDist.Fill(dist,width);
+
+    // (log(size), dist) - bin
+    Int_t ix=hLenMean.GetXaxis()->FindBin(logsize);
+    Int_t iy=hLenMean.GetYaxis()->FindBin(dist);
+
+    // check for over-/underflow
+    /*if(ix*iy==0 || ix>nBinSize || iy>nBinDist)
+    {
+        cout<<"Warning, over-/underflow: Log(size)-bin="<<ix;
+        cout<<" Dist-bin="<<iy<<endl<<flush;
+    }*/
+    if(ix==0)ix=1;if(ix==nBinSize+1)ix=nBinSize;
+    if(iy==0)iy=1;if(iy==nBinDist+1)iy=nBinDist;
+
+    Float_t lq=hLenMean.GetBinContent(ix,iy);
+    Float_t wq=hWidMean.GetBinContent(ix,iy);
+
+    if(lq>0.)lq=1./lq;
+    if(wq>0.)wq=1./wq;
+
+    width *=wq;
+    length*=lq;
+
+    hSLenSize.Fill(logsize,length);
+    hSLenDist.Fill(dist,length);
+    hSWidSize.Fill(logsize,width);
+    hSWidDist.Fill(dist,width);
+
+    // --------------------------------------------------------------------------
+    //
+    // This function is ment for special usage, please never try to set
+    // values via this function
+    //
+    /* void MHillas::Set(const TArrayF &arr)
+    {
+        if (arr.GetSize() != 6)
+            return;
+    
+        fLength = arr.At(0);  // [mm]        major axis of ellipse
+        fWidth  = arr.At(1);  // [mm]        minor axis of ellipse
+        fDelta  = arr.At(2);  // [rad]       angle of major axis with x-axis
+        fSize   = arr.At(3);  // [#CerPhot]  sum of content of all pixels (number of Cherenkov photons)
+        fMeanX  = arr.At(4);  // [mm]        x-coordinate of center of ellipse
+        fMeanY  = arr.At(5);  // [mm]        y-coordinate of center of ellipse
+    }*/
+
+    TArrayF farr(6);
+    farr[0]=length;
+    farr[1]=width;
+    farr[2]=delta;
+    farr[3]=size;
+    farr[4]=meanx;
+    farr[5]=meany;
+
+    fHillas->Set(farr);
+
+    fHillas->SetReadyToSave();
+    fHillasSrc->SetReadyToSave();
+
+    return kTRUE;
+}
+
+Int_t PostProcess()
+{
+
+    return kTRUE;
+}
+
+void ScaleHillas(Int_t nent)
+{
+    //---------------------------------------------------------------
+    // scale Hillas (length, width) to mean
+
+    MParList plist;
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    MReadTree read("Events", fileHillas);
+    read.DisableAutoScheme();
+
+    MTaskInteractive scale;
+    scale.SetPreProcess(PreProcess);
+    scale.SetProcess(Process);
+    scale.SetPostProcess(PostProcess);
+
+    MWriteRootFile write(fileHScaled.Data());
+    write.AddContainer("MHillas",      "Events");
+    write.AddContainer("MHillasExt",   "Events");
+    write.AddContainer("MHillasSrc",   "Events");
+    write.AddContainer("MNewImagePar", "Events");
+    write.AddContainer("MRawRunHeader","Events");
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&scale);
+    tlist.AddToList(&write);
+
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    if (!evtloop.Eventloop(nent))
+        return;
+
+    tlist.PrintStatistics();
+
+    return;
+}
+
+
+//****************************************************************************************
+// third part: check scaling
+//****************************************************************************************
+
+void CheckScaling()
+{
+    //---------------------------------------------------------------
+    // check scaling
+    TFile fileHist(fileHScalHist,"recreate");
+
+    gStyle->SetPalette(1);
+
+
+    TCanvas *c1=new TCanvas("c1","",800,400);
+    if(nBinDist>1)
+        c1->Divide(2,2);
+    else
+        c1->Divide(2,1);
+
+    c1->cd(1);
+    gPad->SetGrid();
+    hSLenSize.SetStats(kFALSE);
+    hSLenSize.GetXaxis()->SetTitle("log(size [#phot])");
+    hSLenSize.GetYaxis()->SetTitle("scaled length");
+    hSLenSize.SetLineWidth(2);
+    hSLenSize.DrawCopy("colz");
+    hSLenSize.Write();
+
+    TLine lLen(2.7,1.,hSizeUp,1.);
+    TLine lLenUp(2.7,LengthUp,hSizeUp,LengthUp);
+    TLine lLenLo(2.7,LengthLo,hSizeUp,LengthLo);
+
+    lLen.SetLineColor(2);
+    lLen.SetLineWidth(2);
+    lLenUp.SetLineWidth(2);
+    lLenLo.SetLineWidth(2);
+    lLen.DrawClone();
+    lLenUp.DrawClone();
+    lLenLo.DrawClone();
+
+
+    c1->cd(2);
+    gPad->SetGrid();
+    hLenSize.SetStats(kFALSE);
+    hLenSize.SetTitle("");
+    hLenSize.GetXaxis()->SetTitle("log(size [#phot])");
+    hLenSize.GetYaxis()->SetTitle("length [deg]");
+    hLenSize.SetLineWidth(2);
+    hLenSize.DrawCopy("colz");
+    hLenSize.Write();
+    hLenMeanSize.SetLineColor(2);
+    hLenMeanSize.SetLineWidth(2);
+    hLenMeanSize.DrawCopy("e same");
+    hLenMeanSize.Write();
+
+    TH1F hLenCutLo("hLenCutLo","",nBinSize,hSizeLo,hSizeUp);
+    TH1F hLenCutUp("hLenCutUp","",nBinSize,hSizeLo,hSizeUp);
+    for(Int_t i=1;i<=nBinSize;i++)
+    {
+        Float_t meanval=hLenMeanSize.GetBinContent(i);
+        hLenCutLo.SetBinContent(i,meanval*LengthLo);
+        hLenCutUp.SetBinContent(i,meanval*LengthUp);
+    }
+    hLenCutLo.SetLineWidth(2);
+    hLenCutUp.SetLineWidth(2);
+    hLenCutLo.DrawCopy("][ same");
+    hLenCutUp.DrawCopy("][ same");
+
+
+    if(nBinDist>1)
+    {
+        c1->cd(3);
+        gPad->SetGrid();
+        hSLenDist.SetStats(kFALSE);
+        hSLenDist.GetXaxis()->SetTitle("dist [deg]");
+        hSLenDist.GetYaxis()->SetTitle("scaled length");
+        hSLenDist.SetLineWidth(2);
+        hSLenDist.DrawCopy("colz");
+        hSLenDist.Write();
+    
+        c1->cd(4);
+        gPad->SetGrid();
+        hLenDist.SetStats(kFALSE);
+        hLenDist.SetTitle("");
+        hLenDist.GetXaxis()->SetTitle("dist [deg]");
+        hLenDist.GetYaxis()->SetTitle("length");
+        hLenDist.SetLineWidth(2);
+        hLenDist.DrawCopy("colz");
+        hLenDist.Write();
+        hLenMeanDist.SetLineColor(2);
+        hLenMeanDist.SetLineWidth(2);
+        hLenMeanDist.DrawCopy("e same");
+        hLenMeanDist.Write();
+    }
+
+    TCanvas *c2=new TCanvas("c2","",800,400);
+    if(nBinDist>1)
+        c2->Divide(2,2);
+    else
+        c2->Divide(2,1);
+
+    c2->cd(1);
+    gPad->SetGrid();
+    hSWidSize.SetStats(kFALSE);
+    hSWidSize.GetXaxis()->SetTitle("log(size [#phot])");
+    hSWidSize.GetYaxis()->SetTitle("scaled width");
+    hSWidSize.SetLineWidth(2);
+    hSWidSize.DrawCopy("colz");
+    hSWidSize.Write();
+
+    TLine lWid(2.7,1.,hSizeUp,1.);
+    TLine lWidUp(2.7,WidthUp,hSizeUp,WidthUp);
+    TLine lWidLo(2.7,WidthLo,hSizeUp,WidthLo);
+
+    lWid.SetLineColor(2);
+    lWid.SetLineWidth(2);
+    lWidUp.SetLineWidth(2);
+    lWidLo.SetLineWidth(2);
+    lWid.DrawClone();
+    lWidUp.DrawClone();
+    lWidLo.DrawClone();
+
+    c2->cd(2);
+    gPad->SetGrid();
+    hWidSize.SetStats(kFALSE);
+    hWidSize.SetTitle("");
+    hWidSize.GetXaxis()->SetTitle("log(size [#phot])");
+    hWidSize.GetYaxis()->SetTitle("width [deg]");
+    hWidSize.SetLineWidth(2);
+    hWidSize.DrawCopy("colz");
+    hWidSize.Write();
+    hWidMeanSize.SetLineColor(2);
+    hWidMeanSize.SetLineWidth(2);
+    hWidMeanSize.DrawCopy("e same");
+    hWidMeanSize.Write();
+
+    TH1F hWidCutLo("hWidCutLo","",nBinSize,hSizeLo,hSizeUp);
+    TH1F hWidCutUp("hWidCutUp","",nBinSize,hSizeLo,hSizeUp);
+    for(Int_t i=1;i<=nBinSize;i++)
+    {
+        Float_t meanval=hWidMeanSize.GetBinContent(i);
+        hWidCutLo.SetBinContent(i,meanval*WidthLo);
+        hWidCutUp.SetBinContent(i,meanval*WidthUp);
+    }
+    hWidCutLo.SetLineWidth(2);
+    hWidCutUp.SetLineWidth(2);
+    hWidCutLo.DrawCopy("][ same");
+    hWidCutUp.DrawCopy("][ same");
+
+    if(nBinDist>1)
+    {
+        c2->cd(3);
+        gPad->SetGrid();
+        hSWidDist.SetStats(kFALSE);
+        hSWidDist.GetXaxis()->SetTitle("dist [deg]");
+        hSWidDist.GetYaxis()->SetTitle("scaled width");
+        hSWidDist.SetLineWidth(2);
+        hSWidDist.DrawCopy("colz");
+        hSWidDist.Write();
+    
+        c2->cd(4);
+        gPad->SetGrid();
+        hWidDist.SetStats(kFALSE);
+        hWidDist.SetTitle("");
+        hWidDist.GetXaxis()->SetTitle("dist [deg]");
+        hWidDist.GetYaxis()->SetTitle("width");
+        hWidDist.SetLineWidth(2);
+        hWidDist.DrawCopy("colz");
+        hWidDist.Write();
+        hWidMeanDist.SetLineColor(2);
+        hWidMeanDist.SetLineWidth(2);
+        hWidMeanDist.DrawCopy("e same");
+        hWidMeanDist.Write();
+    }
+
+    // mean values
+    if(nBinDist>1)
+    {
+        TCanvas *c4=new TCanvas("c4","",800,400);
+        c4->Divide(1,2);
+    
+        c4->cd(1);
+        gPad->SetGrid();
+        hLenMean.SetStats(kFALSE);
+        hLenMean.SetTitle("mean_length(log(size),dist)");
+        hLenMean.GetXaxis()->SetTitle("log(size [#phot])");
+        hLenMean.GetYaxis()->SetTitle("dist [deg])");
+        hLenMean.DrawCopy("colz");
+        hLenMean.Write();
+    
+        c4->cd(2);
+        gPad->SetGrid();
+        hWidMean.SetStats(kFALSE);
+        hWidMean.SetTitle("mean_width(log(size),dist)");
+        hWidMean.GetXaxis()->SetTitle("log(size [#phot])"); ;
+        hWidMean.GetYaxis()->SetTitle("dist [deg])");
+        hWidMean.DrawCopy("colz");
+        hWidMean.Write("colz");
+    }
+
+    fileHist.Close();
+
+    return;
+}
+
+//****************************************************************************************
+// main
+//****************************************************************************************
+
+void RunScaling(Int_t nent=-1)
+{
+    printf("Prepare for scaling...");
+    ReadHillas();
+    printf("done.\n");
+
+    ScaleHillas(nent);
+
+    CheckScaling();
+
+    return;
+}
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mberlin/macros/SrcCorrect.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mberlin/macros/SrcCorrect.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mberlin/macros/SrcCorrect.C	(revision 9661)
@@ -0,0 +1,768 @@
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MEvtLoop.h"
+
+#include "MReadTree.h"
+
+#include "MHillasSrc.h"
+#include "MSrcPosCam.h"
+
+#include "MHillasCalc.h"
+#include "MHillasSrcCalc.h"
+#include "MTaskInteractive.h"
+#include "MContinue.h"
+#include "MRawRunHeader.h"
+#include "MWriteRootFile.h"
+
+#include "TH2F.h"
+#include "TF2.h"
+#include "TArrayF.h"
+#include "TObjArray.h"
+#include "TStyle.h"
+#include "TFile.h"
+#include "TMath.h"
+#include "TString.h"
+#include "TCanvas.h"
+#include "TGraphErrors.h"
+#include "TMarker.h"
+
+#include "iostream.h"
+
+//----------------------------------------------------------------
+// MAIN INPUT/OUTPUT
+
+#include "IOMkn421.h"
+//----------------------------------------------------------------
+
+Double_t rmean=0.3;
+Double_t dtlimit=10;  // time slice width [min]
+//Double_t hlimit =0.85;
+Double_t hlimit =0.9;
+
+//----------------------------------------------------------------
+// false source hist ---------------------------------------------
+//----------------------------------------------------------------
+const Int_t nx = 100; // no. of points in x-grid
+const Int_t ny = 100; // no. of points in y-grid
+
+Double_t alimit = 8.; // signal region in alpha-plot [degree]
+
+Double_t xmin = -1.;  // units in degree !!
+Double_t xmax =  1.;
+Double_t ymin = -1.;
+Double_t ymax =  1.;
+
+Double_t dx=(xmax-xmin)/Double_t(nx);
+Double_t dy=(ymax-ymin)/Double_t(ny);
+
+TH2F FSrcHist("FSrcHist","",nx,xmin-dx,xmax+dx,ny,ymin-dy,ymax+dy);
+TObjArray FSrcArray(1);
+
+TH1F APlot("APlot","",36,0,90);
+TObjArray APlotArray(1);
+
+TArrayF xpeak(100);
+TArrayF ypeak(100);
+
+TArrayF xpeakerr(100);
+TArrayF ypeakerr(100);
+
+Int_t runno     = -1;
+Int_t runno_old = -1;
+Int_t runno_lo  = -1;
+Int_t runno_up  = -1;
+
+Double_t mjdend_old  = -1.;
+Double_t mjdstart_lo = -1.;
+Double_t mjdstart_up = -1.;
+
+Double_t mjd_lo  = -1.;
+Double_t mjd_up  = -1.;
+
+Double_t dt  = 0.;
+Int_t islice = 0;
+
+TF2  *fpeak   = NULL;
+FILE *fsrcpos = NULL;
+
+//****************************************************************************************
+// first part: track the source in time-intervalls of duration dtlimit
+//****************************************************************************************
+
+MHillas       *hil=NULL;
+MRawRunHeader *run=NULL;
+
+Double_t gaus2d(Double_t *x,Double_t *par)
+{
+    Double_t N=par[0];  //integral
+    Double_t mx=par[1]; //mean_x
+    Double_t my=par[2]; //mean_y
+    Double_t sx=par[3]; //sigma_x
+    Double_t sy=par[4]; //sigma_y
+    Double_t rho=par[5];//correlation factor
+    Double_t b=par[6];  //constant background
+
+    Double_t z=(x[0]-mx)*(x[0]-mx)/sx/sx;
+    z+=(x[1]-my)*(x[1]-my)/sy/sy;
+    z-=2.*rho*(x[0]-mx)*(x[1]-my)/sx/sy;
+
+    Double_t val=N/(2.*TMath::Pi()*sx*sy*sqrt(1-rho*rho));
+    val*=exp( -z/(2.*(1.-rho*rho)) );
+    val+=b;
+    return val;
+}
+
+Bool_t CalcPeakXY(Double_t *xmean, Double_t *ymean,
+                  Double_t *xmeanerr, Double_t *ymeanerr)
+{
+    Int_t mbin=FSrcHist.GetMaximumBin();
+    Int_t biny = mbin/(nx+2);
+    Int_t binx = mbin%(nx+2);
+  
+    if(mbin!=FSrcHist.GetBin(binx,biny))
+    {
+        cout<<"Error extracting binx, biny from global bin!"<<endl;
+        cout<<" mbin="<<mbin<<" binfound="<<FSrcHist.GetBin(binx,biny)<<endl;
+        cout<<" binx="<<binx<<" biny="<<biny<<endl;
+  
+        return kFALSE;
+    }
+  
+    Double_t ndelta = rmean/FSrcHist.GetBinWidth(mbin);
+
+    Double_t nmax=FSrcHist.GetBinContent(binx,biny);
+
+    Int_t ilo=Int_t(binx-ndelta);
+    Int_t iup=Int_t(binx+ndelta);
+
+    Int_t jlo=Int_t(biny-ndelta);
+    Int_t jup=Int_t(biny+ndelta);
+
+    Double_t xsum  = 0.; Double_t xsum2 = 0.;
+    Double_t ysum  = 0.; Double_t ysum2 = 0.;
+    Double_t cnt   = 0.;
+    //Double_t cov   = 0.;
+
+    for(Int_t i=ilo;i<=iup;i++)
+        for(Int_t j=jlo;j<=jup;j++)
+        {
+            Double_t n=(Double_t)FSrcHist.GetBinContent(i,j);
+            if(n<hlimit*nmax)continue;
+            Double_t x=(Double_t)FSrcHist.GetXaxis()->GetBinCenter(i);
+            Double_t y=(Double_t)FSrcHist.GetYaxis()->GetBinCenter(j);
+
+            cnt+=n;
+
+            xsum +=n*x;
+            xsum2+=n*x*x;
+            ysum +=n*y;
+            ysum2+=n*y*y;
+        }
+
+    Double_t xbar=0.; Double_t xbarerr=0.;
+    Double_t ybar=0.; Double_t ybarerr=0.;
+
+    if(cnt>1)
+    {
+        xbar=xsum/cnt;
+        ybar=ysum/cnt;
+    }
+    if(cnt>2)
+    {
+        xbarerr=cnt*(xsum2/cnt-xbar*xbar)/(cnt-1.);
+        xbarerr=TMath::Sqrt(xbarerr);
+
+        ybarerr=cnt*(ysum2/cnt-ybar*ybar)/(cnt-1.);
+        ybarerr=TMath::Sqrt(ybarerr);
+    }
+
+    /*
+    //fit not yet tested!!
+    Double_t b=FSrcHist.GetEntries()/nx/ny;
+    Double_t nn=b*ndelta*ndelta;
+
+    fpeak->SetParameter(0,nn);     // integral
+    fpeak->SetParameter(1,*xmean); // mean_x
+    fpeak->SetParameter(2,*ymean); // mean_y
+    fpeak->SetParameter(3,0.15);   // sigma_x
+    fpeak->SetParameter(4,0.15);   // sigma_y
+    fpeak->SetParameter(5,0.);     // correlation factor
+    fpeak->SetParameter(6,b);      // constant background
+
+    FSrcHist.Fit("fpeak");
+    xbar=fpeak->GetParameter(1);
+    ybar=fpeak->GetParameter(2);
+    xbarerr=fpeak->GetParameter(3);
+    ybarerr=fpeak->GetParameter(4);
+    */
+
+    *xmean=xbar;
+    *ymean=ybar;
+    *xmeanerr=xbarerr;
+    *ymeanerr=ybarerr;
+
+    return kTRUE;
+}
+
+void AddFSrcHist(Int_t i,Double_t delta)
+{
+    Int_t n=FSrcArray.GetSize();
+    if(i>=n) FSrcArray.Expand(n+1);
+
+    TH2F *htemp=(TH2F*)FSrcHist.Clone();
+    TString name=Form("%d",i);
+    TString title=Form("TimeIntervall = %f min",delta);
+
+    htemp->SetName(name.Data());
+    htemp->SetTitle(title.Data());
+    htemp->SetDrawOption("colz");
+
+    FSrcArray[i] = htemp;
+
+    return;
+}
+
+void AddAPlot(Int_t i,Double_t delta)
+{
+    Int_t n=APlotArray.GetSize();
+    if(i>=n) APlotArray.Expand(n+1);
+
+    TH1F *htemp=(TH1F*)APlot.Clone();
+    TString name=Form("%d",i);
+    TString title=Form("TimeIntervall = %f min",delta);
+
+    htemp->SetName(name.Data());
+    htemp->SetTitle(title.Data());
+    htemp->SetFillColor(16);
+
+    APlotArray[i] = htemp;
+
+    return;
+}
+
+//----------------------------------------------------------------
+// Source Position Grid ------------------------------------------
+//----------------------------------------------------------------
+
+Int_t STrackPreProc(MParList *plist)
+{
+    hil = (MHillas*) plist->FindObject("MHillas");
+    run = (MRawRunHeader*) plist->FindObject("MRawRunHeader");
+
+    return (hil && run) ? kTRUE : kFALSE;
+}
+
+Int_t STrackProc()
+{
+    runno  = run->GetRunNumber();
+    if(runno==0) return kTRUE;
+
+    Double_t mjdstart = (run->GetRunStart()).GetMjd();
+    Double_t mjdend   = (run->GetRunEnd()).GetMjd();
+    Double_t t = (mjdend-mjdstart)*24.*60.;
+
+    Double_t dtrun;
+    if(runno!=runno_old)
+    {
+        if(dt<0.001) {runno_lo=runno;mjd_lo=mjdstart;mjdend_old=mjdstart;} // very first run
+
+        dtrun=(mjdend_old-mjd_lo)*24.*60.;
+        //if(dt>dtlimit)
+        if(dtrun>dtlimit)
+        {
+            runno_up=runno_old;
+            mjd_up=mjdend_old;
+
+            Double_t x; Double_t xerr;
+            Double_t y; Double_t yerr;
+
+            if(!CalcPeakXY(&x,&y,&xerr,&yerr)) return kFALSE;
+            AddFSrcHist(islice,dt);
+
+            xpeak[islice]=x;
+            ypeak[islice]=y;
+            xpeakerr[islice]=xerr;
+            ypeakerr[islice]=yerr;
+
+            printf("\n TimeSlice %d   RunNo %d-%d  Mjd %f-%f  Dt=%f \n",islice,runno_lo,runno_up,mjd_lo,mjd_up,dt);
+            printf(" X=%f+-%f  Y=%f+-%f \n\n",x,xerr,y,yerr);
+            fprintf(fsrcpos,"%d %d %d %f %f %f %f %f %f %f\n",islice,runno_lo,runno_up,x,y,xerr,yerr,mjd_lo,mjd_up,dt);
+
+            FSrcHist.Reset();
+            dt=0.;
+
+            runno_lo=runno;
+            mjd_lo=mjdstart;
+
+            islice++;
+        }
+
+        dt+=t;
+        printf("Runno=%d  MjdStart=%f  MjdEnde=%f dt=%f \n",runno,mjdstart,mjdend,dt);
+        runno_old=runno;
+        mjdend_old=mjdend;
+    }
+
+
+    MHillasSrc hillas_src;
+    MSrcPosCam srcpos;
+
+    Double_t length=hil->GetLength();
+    Double_t width=hil->GetWidth();
+
+    // size cut
+    if(hil->GetSize()<SizeLo) return kTRUE;
+
+    // cuts in scaled length, width
+    if((length>LengthUp) || (length<LengthLo) || (width>WidthUp) || (width<WidthLo))
+        return kTRUE;
+
+    // cut in dist from camera center
+    srcpos.SetXY(0,0);
+    hillas_src.SetSrcPos(&srcpos);
+    hillas_src.Calc(hil);
+
+    Double_t dist=hillas_src.GetDist()*mm2deg;
+    if(dist>DistUp || dist<DistLo) return kTRUE;
+
+    // false source grid
+    for (Int_t i=0;i<nx;i++)
+        for (Int_t j=0;j<ny;j++)
+        {
+            Double_t x=(xmax-xmin)*Double_t(i)/Double_t(nx-1)+xmin;
+            Double_t y=(ymax-ymin)*Double_t(j)/Double_t(ny-1)+ymin;
+
+            srcpos.SetXY(x*deg2mm,y*deg2mm);
+            hillas_src.SetSrcPos(&srcpos);
+            hillas_src.Calc(hil);
+
+            if(TMath::Abs(hillas_src.GetAlpha())<alimit)
+                FSrcHist.Fill(x,y);
+
+        }
+
+    return kTRUE;
+}
+
+Int_t STrackPostProc()
+{
+    if(dt>0.001)
+    {
+        runno_up=runno_old;
+        mjd_up=mjdend_old;
+
+        Double_t x; Double_t xerr;
+        Double_t y; Double_t yerr;
+
+        if(!CalcPeakXY(&x,&y,&xerr,&yerr)) return kFALSE;
+        AddFSrcHist(islice,dt);
+
+        xpeak[islice]=x;
+        ypeak[islice]=y;
+        xpeakerr[islice]=xerr;
+        ypeakerr[islice]=yerr;
+
+        printf("\n TimeSlice %d   RunNo %d-%d  Mjd %f-%f  Dt=%f \n",islice,runno_lo,runno_up,mjd_lo,mjd_up,dt);
+        printf(" X=%f+-%f  Y=%f+-%f \n\n",x,xerr,y,yerr);
+        fprintf(fsrcpos,"%d %d %d %f %f %f %f %f %f %f\n",islice,runno_lo,runno_up,x,y,xerr,yerr,mjd_lo,mjd_up,dt);
+
+        islice++;
+    }
+
+    return kTRUE;
+}
+
+//----------------------------------------------------------------
+//----------------------------------------------------------------
+
+void SourceTrack(Int_t nent)
+{
+
+    MParList plist;
+
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    MReadTree read("Events",fileHScaled);
+    read.DisableAutoScheme();
+
+    //TString runcuts("(MRawRunHeader.fRunNumber<17427)");
+    //runcuts+="|| (MRawRunHeader.fRunNumber>17428)";
+    //MContinue runsel(runcuts.Data());
+
+    MTaskInteractive strack;
+    strack.SetPreProcess(STrackPreProc);
+    strack.SetProcess(STrackProc);
+    strack.SetPostProcess(STrackPostProc);
+
+    tlist.AddToList(&read);
+    //tlist.AddToList(&runsel);
+    tlist.AddToList(&strack);
+
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    //------------------------------------------
+    // initializations
+
+    FSrcHist.SetDrawOption("colz");
+    FSrcHist.SetStats(kFALSE);
+
+    fpeak=new TF2("fpeak",gaus2d,-1,1,-1,1,6);
+    fsrcpos=fopen(fileSrcPos.Data(),"w");
+
+    //------------------------------------------
+    // standard eventloop
+
+    if (!evtloop.Eventloop(nent))
+        return;
+
+    tlist.PrintStatistics();
+
+    fclose(fsrcpos);
+
+    TFile file(fileFSrcPlot.Data(),"recreate");
+    FSrcArray.Write();
+    FSrcHist.Write();
+    file.Close();
+
+    const Int_t dim=islice;
+    TGraphErrors g(dim,xpeak.GetArray(),ypeak.GetArray(),
+                   xpeakerr.GetArray(),ypeakerr.GetArray());
+
+    //------------------------------------------
+    // canvas with complete hist
+    TCanvas *c1=new TCanvas("c1","",400,800);
+    gStyle->SetPalette(1);
+
+    c1->Divide(2,1);
+    c1->cd(1);
+    gPad->Update();
+
+    FSrcHist.Reset();
+    for(Int_t i=0;i<dim;i++)
+    {
+        TH2F *hptr = (TH2F*) (FSrcArray[i]);
+        FSrcHist.Add(hptr);
+    }
+
+    TString label=Form("Size>%f  ",SizeLo);
+    label+=Form("%f<Dist<%f  ",  DistLo,DistUp);
+    label+=Form("%f<Width<%f  " ,WidthLo,WidthUp);
+    label+=Form("%f<Length<%f  ",LengthLo,LengthUp);
+    label+=Form("|Alpha|<%f"  ,alimit);
+
+    FSrcHist.SetTitle(label.Data());
+    FSrcHist.GetXaxis()->SetTitle("X");
+    FSrcHist.GetYaxis()->SetTitle("Y");
+
+    FSrcHist.DrawClone("colz");
+    g.DrawClone("pl");
+
+    c1->cd(2);
+    gPad->Update();
+    g.GetXaxis()->SetRangeUser(-1.,1.);
+    g.GetYaxis()->SetRangeUser(-1.,1.);
+    g.DrawClone("apl");
+
+    //------------------------------------------
+    // canvas with slides
+    TCanvas *c2=new TCanvas("c2","",800,800);
+    gStyle->SetPalette(1);
+
+    Int_t n=Int_t(TMath::Ceil(sqrt(double(dim))));
+
+    c2->Divide(n,n);
+    for(Int_t i=0;i<dim;i++)
+    {
+        Int_t col=i/n;
+        Int_t row=i%n;
+        c2->cd(row*n+col+1);
+
+        gPad->Update();
+        TH2F *hptr = (TH2F*) (FSrcArray[i]);
+
+        TMarker m;
+        m.SetMarkerStyle(2);
+        m.SetMarkerSize(4);
+        m.SetMarkerColor(1);
+        m.SetX(xpeak[i]);
+        m.SetY(ypeak[i]);
+
+        hptr->DrawClone("colz");
+        m.DrawClone();
+    }
+
+    return;
+}
+
+//****************************************************************************************
+// second part: correct for moving source position
+//****************************************************************************************
+
+// initilizations
+
+Double_t dtref=0.;
+Int_t islice_old;
+Double_t dtref_old=0;
+
+Double_t xref = 0.; Double_t xreferr = 0.;
+Double_t yref = 0.; Double_t yreferr = 0.;
+
+MSrcPosCam *src=NULL;
+
+//----------------------------------------------------------------
+// Source Position Grid ------------------------------------------
+//----------------------------------------------------------------
+Int_t SCorrectPreProc(MParList *plist)
+{
+    hil = (MHillas*) plist->FindObject("MHillas");
+    src = (MSrcPosCam*) plist->FindCreateObj("MSrcPosCam");
+    run = (MRawRunHeader*) plist->FindObject("MRawRunHeader");
+
+    return (hil && run && src) ? kTRUE : kFALSE;
+}
+
+Int_t SCorrectProc()
+{
+    if(hil->GetSize()<=0.) return kTRUE;
+
+    Int_t runno    = run->GetRunNumber();
+    if(runno==0) return kTRUE;
+
+    Double_t mjdstart = (run->GetRunStart()).GetMjd();
+    Double_t mjdend   = (run->GetRunEnd()).GetMjd();
+    Double_t t=(mjdend-mjdstart)*24.*60.;
+
+    if(runno!=runno_old)
+    {
+        if((runno<runno_lo)||(runno>runno_up))
+        {
+            dt=t;
+
+            fscanf(fsrcpos,"%d %d %d %lf %lf %lf %lf %lf %lf %lf\n",&islice,&runno_lo,&runno_up,&xref,&yref,&xreferr,&yreferr,&mjd_lo,&mjd_up,&dtref);
+            printf("\nApplying correction for runs %d - %d (MJD %f - %f), DtRef=%f :\n",runno_lo,runno_up,mjd_lo,mjd_up,dtref);
+            printf("Source pos set to X=%f  Y=%f \n\n",xref,yref);
+
+            if(islice>0)
+            {
+                AddAPlot(islice_old,dtref_old);
+                APlot.Reset();
+            }
+            islice_old=islice;
+            dtref_old=dtref;
+        }
+        else
+        {
+            dt+=t;
+        }
+        printf("Runno=%d  MjdStart=%f  MjdEnde=%f Dt=%f \n",runno,mjdstart,mjdend,dt);
+        runno_old=runno;
+
+    }
+
+    src->SetXY(xref*deg2mm,yref*deg2mm);
+    src->SetReadyToSave();
+    // false source grid
+
+    MHillasSrc hillas_src;
+    MSrcPosCam srcpos;
+
+    Double_t length=hil->GetLength();
+    Double_t width =hil->GetWidth();
+
+    // size cut
+    if(hil->GetSize()<SizeLo) return kTRUE;
+
+    // cuts in scaled length, width
+    if((length>LengthUp) || (length<LengthLo) || (width>WidthUp) || (width<WidthLo))
+        return kTRUE;
+
+    // cut in dist from camera center
+    srcpos.SetXY(0,0);
+    hillas_src.SetSrcPos(&srcpos);
+    hillas_src.Calc(hil);
+
+    Double_t dist=hillas_src.GetDist()*mm2deg;
+    if(dist>DistUp || dist<DistLo) return kTRUE;
+
+    // fill 1-dim APlot for extracted source position
+    srcpos.SetXY(xref*deg2mm,yref*deg2mm);
+    hillas_src.SetSrcPos(&srcpos);
+    hillas_src.Calc(hil);
+    APlot.Fill(TMath::Abs(hillas_src.GetAlpha()));
+
+    // false source plot for corrected source movement
+    for (Int_t i=0;i<nx;i++)
+        for (Int_t j=0;j<ny;j++)
+        {
+            Double_t x=(xmax-xmin)*Double_t(i)/Double_t(nx-1)+xmin;
+            Double_t y=(ymax-ymin)*Double_t(j)/Double_t(ny-1)+ymin;
+
+            //printf("xref=%f  yref=%f \n",xref,yref);
+            srcpos.SetXY((x+xref)*deg2mm,(y+yref)*deg2mm);
+            hillas_src.SetSrcPos(&srcpos);
+            hillas_src.Calc(hil);
+
+            if(TMath::Abs(hillas_src.GetAlpha())<alimit)
+                FSrcHist.Fill(x,y);
+        }
+
+    return kTRUE;
+}
+
+Int_t SCorrectPostProc()
+{
+    AddAPlot(islice_old,dtref_old);
+
+    return kTRUE;
+}
+
+//----------------------------------------------------------------
+//----------------------------------------------------------------
+
+void SourceCorrect(Int_t nent)
+{
+    MParList plist;
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    MReadTree read("Events", fileHScaled);
+    read.DisableAutoScheme();
+
+    MTaskInteractive scorrect;
+    scorrect.SetPreProcess(SCorrectPreProc);
+    scorrect.SetProcess(SCorrectProc);
+    scorrect.SetPostProcess(SCorrectPostProc);
+
+    MHillasSrcCalc scalc;
+
+    MWriteRootFile write(fileHScaledC.Data());
+    write.AddContainer("MSrcPosCam",   "Events");
+    write.AddContainer("MHillas",      "Events");
+    write.AddContainer("MHillasExt",   "Events");
+    write.AddContainer("MHillasSrc",   "Events");
+    write.AddContainer("MNewImagePar", "Events");
+    write.AddContainer("MRawRunHeader","Events");
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&scorrect);
+    tlist.AddToList(&scalc);
+    tlist.AddToList(&write);
+
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    //------------------------------------------
+    // standard eventloop
+
+    fsrcpos=fopen(fileSrcPos.Data(),"r");
+    if(!fsrcpos)
+    {
+        cout<<"fsrcpos does not exist!"<<endl;
+        return;
+    }
+
+    if (!evtloop.Eventloop(nent))
+        return;
+
+    tlist.PrintStatistics();
+
+    fclose(fsrcpos);
+
+
+    gStyle->SetPalette(1);
+    TFile file(fileFSrcPlotC.Data(),"recreate");
+    FSrcHist.Write();
+    APlotArray.Write();
+    file.Close();
+
+    //------------------------------------------
+    // canvas with complete hist
+    TCanvas *c=new TCanvas("c","",800,400);
+    c->cd();
+
+    TString label=Form("Size>%f  ",SizeLo);
+    label+=Form("%f<Dist<%f  ",  DistLo,DistUp);
+    label+=Form("%f<Width<%f  " ,WidthLo,WidthUp);
+    label+=Form("%f<Length<%f  ",LengthLo,LengthUp);
+    label+=Form("|Alpha|<%f"  ,alimit);
+
+    FSrcHist.SetTitle(label.Data());
+    FSrcHist.GetXaxis()->SetTitle("X");
+    FSrcHist.GetYaxis()->SetTitle("Y");
+
+    FSrcHist.DrawCopy("colz");
+
+    //------------------------------------------
+    // canvas with alpha hists
+    TCanvas *c2=new TCanvas("c2","",800,800);
+    gStyle->SetPalette(1);
+
+    const Int_t dim=islice+1;
+    Int_t n=Int_t(TMath::Ceil(sqrt(double(dim))));
+
+    c2->Divide(n,n);
+    for(Int_t i=0;i<dim;i++)
+    {
+        Int_t col=i/n;
+        Int_t row=i%n;
+        c2->cd(row*n+col+1);
+
+        gPad->Update();
+        TH1F *hptr = (TH1F*) (APlotArray[i]);
+
+        hptr->DrawClone();
+    }
+
+    return;
+}
+
+//****************************************************************************************
+// main
+//****************************************************************************************
+
+void SrcCorrect(Int_t icorrect,Int_t nent=-1)
+{
+
+    if(!icorrect)
+    {
+        // (re-) initilizations
+        islice=0;
+        runno_old=-1;
+        runno_lo=-1;
+        runno_up=-1;
+
+        dt=0;
+
+        mjd_lo=-1;
+        mjd_up=-1;
+
+        hil=NULL; run=NULL;
+
+        cout<<"Starting source track reconstruction."<<endl<<flush;
+        FSrcHist.Reset();
+        SourceTrack(nent);
+
+    }else{
+
+        // (re-) initilizations
+        islice=0;
+        runno_old=-1;
+        runno_lo=-1;
+        runno_up=-1;
+
+        dt=0;
+
+        mjd_lo=-1;
+        mjd_up=-1;
+
+        hil=NULL; run=NULL;
+
+        cout<<"Starting source correct."<<endl<<flush;
+        FSrcHist.Reset();
+        SourceCorrect(nent);
+    }
+
+    return;
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/meth/MAstroCamera.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/meth/MAstroCamera.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/meth/MAstroCamera.cc	(revision 9661)
@@ -0,0 +1,611 @@
+/*====================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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, 3/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Sabrina Stark, 7/2004 <mailto:stark@particle.phys.ethz.ch>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MAstroCamera
+// ============
+//
+// A tools displaying stars from a catalog in the camera display.
+// PRELIMINARY!!
+//
+//
+// Usage:
+// ------
+// For a usage example see macros/starfield.C
+//
+// To be able to reflect the star-light you need the geometry of the
+// mirror and the distance of the plain screen.
+//
+// You can get the mirror geometry from a MC file and the distance of
+// the screen from MGeomCam.
+//
+//
+// Algorithm:
+// ----------
+// The caluclation of the position of the reflection in the camera is
+// done by:
+//   - Rotation of the star-field such that the camera is looking into
+//     the pointing direction
+//   - Calculation of the reflected star-light vector by calling
+//     MGeomMirror::GetReflection (which returns the point at which
+//     the vector hits the camera plain)
+//   - Depending on the draw-option you get each reflected point, the
+//     reflection on a virtual ideal mirror or the reflection on each
+//     individual mirror
+//
+//
+// GUI:
+// ----
+//  * You can use the the cursor keys to change the pointing position
+//    and plus/minus to change the time by a quarter of an hour.
+//
+// ToDo:
+// -----
+//  * possibility to overwrite distance from mirror to screen
+//  * read the mirror geometry directly from the MC input file
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MAstroCamera.h"
+
+#include <errno.h>        // strerror
+#include <fstream>        // ifstream
+
+#include <KeySymbols.h>   // kKey_*
+
+#include <TH2.h>          // TH2D
+#include <TMarker.h>      // TMarker
+#include <TVirtualPad.h>  // gPad
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MGeomCam.h"
+#include "MGeomMirror.h"
+
+#include "MTime.h"
+#include "MAstroSky2Local.h"
+#include "MObservatory.h"
+
+#include "../mhist/MHCamera.h" // FIXME: This dependancy is very bad!
+                      // HOW TO GET RID OF IT? Move MHCamera to mgeom?
+
+//#include "MStarLocalPos.h"
+
+ClassImp(MAstroCamera);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Create a virtual MGeomMirror which is in the center of the coordinate
+// system and has a normal vector in z-direction.
+//
+MAstroCamera::MAstroCamera() : fGeom(0), fMirrors(0)
+{
+    fMirror0 = new MGeomMirror;
+    fMirror0->SetMirrorContent(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete fGeom, fMirrors and the virtual 0-Mirror fMirror0
+//
+MAstroCamera::~MAstroCamera()
+{    
+    if (fGeom)
+        delete fGeom;
+    if (fMirrors)
+        delete fMirrors;
+
+    delete fMirror0;
+
+}
+
+// --------------------------------------------------------------------------
+//
+// Set a list of mirrors. The Mirrors must be of type MGeomMirror and
+// stored in a TClonesArray
+//
+void MAstroCamera::SetMirrors(TClonesArray &arr)
+{
+    if (arr.GetClass()!=MGeomMirror::Class())
+    {
+        cout << "ERROR - TClonesArray doesn't contain objects of type MGeomMirror... ignored." << endl;
+        return;
+    }
+
+    const Int_t n = arr.GetSize();
+
+    if (!fMirrors)
+        fMirrors = new TClonesArray(MGeomMirror::Class(), n);
+
+    fMirrors->ExpandCreate(n);
+
+    for (int i=0; i<n; i++)
+        memcpy((*fMirrors)[i], arr[i], sizeof(MGeomMirror));
+
+}
+
+// --------------------------------------------------------------------------
+//
+// Read the mirror geometry from a MC .def file. The following
+// structure is expected:
+//
+// #*  TYPE=1  (MAGIC)
+// #*      i  f   sx   sy   x   y   z   thetan  phin 
+// #* 
+// #*       i : number of the mirror
+// #*       f : focal distance of that mirror
+// #*      sx : curvilinear coordinate of mirror's center in X[cm]
+// #*      sy : curvilinear coordinate of mirror's center in X[cm]
+// #*       x : x coordinate of the center of the mirror [cm]
+// #*       y : y coordinate of the center of the mirror [cm]
+// #*       z : z coordinate of the center of the mirror [cm]
+// #*  thetan : polar theta angle of the direction where the mirror points to
+// #*    phin : polar phi angle of the direction where the mirror points to
+// #*      xn : xn coordinate of the normal vector in the center (normalized)
+// #*      yn : yn coordinate of the normal vector in the center (normalized)
+// #*      zn : zn coordinate of the normal vector in the center (normalized)
+// #
+// define_mirrors
+//   1 1700.9200   25.0002   75.0061   25.0000   75.0000    0.9207 0.02328894 1.24904577 -0.00736394 -0.02209183 0.99972882
+//   2 ...
+//
+void MAstroCamera::SetMirrors(const char *fname)
+{
+    ifstream fin(fname);
+    if (!fin)
+    {
+        gLog << err << "Cannot open file " << fname << ": ";
+        gLog << strerror(errno) << endl;
+        return;
+    }
+
+    TString line;
+    while (1)
+    {
+        line.ReadLine(fin);
+        if (!fin)
+            return;
+
+        line = line.Strip(TString::kBoth);
+
+        if (line.BeginsWith("n_mirrors"))
+        {
+            Int_t n;
+            sscanf(line.Data(), "%*s %d", &n);
+
+            if (!fMirrors)
+                fMirrors = new TClonesArray(MGeomMirror::Class(), n);
+
+            fMirrors->ExpandCreate(n);
+            continue;
+        }
+
+
+        Int_t id;
+        Float_t f, sx, sy, x, y, z, thetan, phin, xn, yn, zn;
+
+        const Int_t n = sscanf(line.Data(), "%d %f %f %f %f %f %f %f %f %f %f %f",
+                               &id, &f, &sx, &sy, &x, &y, &z, &thetan,
+                               &phin, &xn, &yn, &zn);
+        if (n!=12)
+            continue;
+
+        new ((*fMirrors)[id-1]) MGeomMirror;
+        ((MGeomMirror*)(*fMirrors)[id-1])->SetMirrorContent(id, f, sx, sy, x, y, z, thetan, phin, xn, yn, zn);
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the camera geometry. The MGeomCam object is cloned.
+//
+void MAstroCamera::SetGeom(const MGeomCam &cam)
+{
+    if (fGeom)
+        delete fGeom;
+
+    fGeom = (MGeomCam*)cam.Clone();
+}
+
+// --------------------------------------------------------------------------
+//
+// Convert To Pad coordinates (see MAstroCatalog)
+//
+Int_t MAstroCamera::ConvertToPad(const TVector3 &w, TVector2 &v) const
+{
+    /*
+     --- Use this to plot the 'mean grid' instead of the grid of a
+         theoretical central mirror ---
+
+        TVector3 spot;
+        const Int_t num = fConfig->GetNumMirror();
+        for (int i=0; i<num; i++)
+        spot += fConfig->GetMirror(i).GetReflection(w, fGeom->GetCameraDist())*1000;
+        spot *= 1./num;
+        */
+
+    const TVector3 spot = fMirror0->GetReflection(w, fGeom->GetCameraDist())*1000;
+    v.Set(spot(0), spot(1));
+
+    const Float_t max = fGeom->GetMaxRadius()*0.70;
+    return v.X()>-max && v.Y()>-max && v.X()<max && v.Y()<max;
+}
+
+// --------------------------------------------------------------------------
+//
+// Find an object with a given name in the list of primitives of this pad.
+//
+TObject *FindObjectInPad(const char *name, TVirtualPad *pad)
+{
+    if (!pad)
+        pad = gPad;
+
+    if (!pad)
+        return NULL;
+
+    TObject *o;
+
+    TIter Next(pad->GetListOfPrimitives());
+    while ((o=Next()))
+    {
+        if (o->InheritsFrom(gROOT->GetClass(name)))
+            return o;
+
+        if (o->InheritsFrom("TPad"))
+            if ((o = FindObjectInPad(name, (TVirtualPad*)o)))
+                return o;
+    }
+    return NULL;
+}
+
+// --------------------------------------------------------------------------
+//
+// Options:
+//
+//  '*' Draw the mean of the reflections on all mirrors
+//  '.' Draw a dot for the reflection on each individual mirror
+//  'h' To create a TH2D of the star-light which is displayed
+//  'c' Use the underlaying MHCamera as histogram
+//  '0' Draw the reflection on a virtual perfect mirror
+//  '=' Draw '0' or '*' propotional to the star magnitude
+//
+// If the Pad contains an object MHCamera of type MHCamera it is used.
+// Otherwise a new object is created.
+//
+void MAstroCamera::AddPrimitives(TString o)
+{
+    if (!fMirrors)
+    {
+        cout << "Missing Mirror data..." << endl;
+    }
+    if (!fObservatory)
+    {
+        cout << "Missing data (Observatory)..." << endl;
+        return;
+    }
+    if (!fTime)
+    {
+        cout << "Missing data (Time)..." << endl;
+        return;
+    }
+
+    if (o.IsNull())
+        o = "*.";
+
+    const Bool_t hasnull = o.Contains("0", TString::kIgnoreCase);
+    const Bool_t hashist = o.Contains("h", TString::kIgnoreCase);
+    const Bool_t hasmean = o.Contains("*", TString::kIgnoreCase);
+    const Bool_t hasdot  = o.Contains(".", TString::kIgnoreCase);
+    const Bool_t usecam  = o.Contains("c", TString::kIgnoreCase);
+    const Bool_t resize  = o.Contains("=", TString::kIgnoreCase);
+
+    // Get camera
+    MHCamera *camera=(MHCamera*)FindObjectInPad("MHCamera", gPad);
+    if (camera)
+    {
+        if (!camera->GetGeometry() || camera->GetGeometry()->IsA()!=fGeom->IsA())
+            camera->SetGeometry(*fGeom);
+    }
+    else
+    {
+        camera = new MHCamera(*fGeom);
+        camera->SetName("MHCamera");
+        camera->SetStats(0);
+        camera->SetInvDeepBlueSeaPalette();
+        camera->SetBit(kCanDelete);
+        camera->Draw();
+    }
+
+    camera->SetTitle(GetPadTitle());
+
+    gPad->cd(1);
+
+    if (!usecam)
+    {
+        if (camera->GetEntries()==0)
+            camera->SetBit(MHCamera::kNoLegend);
+    }
+    else
+    {
+        camera->Reset();
+        camera->SetYTitle("arb.cur");
+    }
+
+    TH2 *h=0;
+    if (hashist)
+    {
+        TH2F hist("","", 90, -650, 650, 90, -650, 650);
+        hist.SetMinimum(0);
+        h = (TH2*)hist.DrawCopy("samecont1");
+    }
+
+    const TRotation rot(GetGrid(kTRUE));
+
+    MVector3 *radec;
+    TIter Next(&fList);
+
+    while ((radec=(MVector3*)Next()))
+    {
+        const Double_t mag = radec->Magnitude();
+        if (mag>GetLimMag())
+            continue;
+
+        TVector3 star(*radec);
+
+        // Rotate Star into telescope system
+        star *= rot;
+
+        TVector3 mean;
+
+        Int_t num = 0;
+
+        MGeomMirror *mirror = 0;
+        TIter NextM(fMirrors);
+        while ((mirror=(MGeomMirror*)NextM()))
+        {
+            const TVector3 spot = mirror->GetReflection(star, fGeom->GetCameraDist())*1000;
+
+            // calculate mean of all 'stars' hitting the camera plane
+            // by taking the sum of the intersection points between
+            // the light vector and the camera plane
+            mean += spot;
+
+            if (hasdot)
+            {
+                TMarker *m=new TMarker(spot(0), spot(1), 1);
+                m->SetMarkerColor(kMagenta);
+                m->SetMarkerStyle(kDot);
+                fMapG.Add(m);
+            }
+            if (h)
+                h->Fill(spot(0), spot(1), pow(10, -mag/2.5));
+
+            if (usecam)
+                camera->Fill(spot(0), spot(1), pow(10, -mag/2.5));
+
+            num++;
+        }
+
+        // transform meters into millimeters (camera display works with mm)
+        mean *= 1./num;
+	DrawStar(mean(0), mean(1), *radec, hasmean?kBlack:-1, Form("x=%.1fmm y=%.1fmm", mean(0), mean(1)), resize);
+
+        if (hasnull)
+        {
+            TVector3 star(*radec);
+            star *= rot;
+            const TVector3 spot = fMirror0->GetReflection(star, fGeom->GetCameraDist())*1000;
+            DrawStar(spot(0), spot(1), *radec, hasmean?kBlack:-1, Form("x=%.1fmm y=%.1fmm", mean(0), mean(1)), resize);
+            // This can be used to get the abberation...
+            //cout << TMath::Hypot(spot(0), spot(1)) << " " << TMath::Hypot(mean(0)-spot(0), mean(1)-spot(1)) << endl;
+        }
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Options:
+//
+//  '*' Draw the mean of the reflections on all mirrors
+//  '.' Draw a dot for the reflection on each individual mirror
+//  'h' To create a TH2D of the star-light which is displayed
+//  'c' Use the underlaying MHCamera as histogram
+//  '0' Draw the reflection on a virtual perfect mirror
+//
+// If the Pad contains an object MHCamera of type MHCamera it is used.
+// Otherwise a new object is created.
+//
+
+void MAstroCamera::StarPosInCamera()
+{
+  if (!fMirrors)
+    {
+      cout << "Missing Mirror data..." << endl;
+    }
+
+  const TRotation rot(GetGrid(kTRUE));
+
+  TIter Next(&fList);
+  MVector3 *v=0;
+  while ((v=(MVector3*)Next()))
+    {
+        const Double_t mag = v->Magnitude();
+        if (mag>GetLimMag())
+            continue;
+ 
+       TVector3 star(*v);
+
+        // Rotate Star into telescope system
+       star *= rot;
+
+       TVector3 *mean = new TVector3;
+
+       Int_t num = 0;
+
+       // Aberration:
+       MGeomMirror *mirror = 0;
+       TIter NextM(fMirrors);
+       while ((mirror=(MGeomMirror*)NextM()))
+	 {
+	   const TVector3 spot = mirror->GetReflection(star, fGeom->GetCameraDist())*1000;
+
+	   *mean += spot;
+	   num++;
+        }
+
+       *mean *= 1./num;
+       fCatList.Add(mean);
+    }
+}
+/*void MAstroCamera::FillStarList(TList *list)
+{
+    list->SetOwner();
+    list->Delete();
+
+    if (!fTime || !fObservatory || !fMirrors || !list)
+    {
+        cout << "Missing data..." << endl;
+        return;
+    }
+
+    const MAstroSky2Local s2l(*fTime, *fObservatory);
+    const TRotation trans(AlignCoordinates(rot*fRaDec));
+
+    // Return the correct rotation matrix
+    const TRotation rot = trans*s2l;
+
+    MVector3 *radec;
+    TIter Next(&fList);
+
+    while ((radec=(MVector3*)Next()))
+    {
+        const Double_t mag = radec->Magnitude();
+
+        TVector3 mean;
+	TVector3 star(*radec);
+	star *= rot;
+	const TVector3 spot = fMirror0->GetReflection(star, fGeom->GetCameraDist())*1000;
+
+	MStarLocalPos *starpos = new MStarLocalPos;
+	starpos->SetExpValues(mag,mean(0),mean(1));
+	list->Add(starpos);
+    }
+    // For MAGIC the distance of the mean of the light distribution
+    // to the Mirror0 reflection of the star (Abberation) can be
+    // expressed as:  dr = (0.0713 +/- 0.0002) * r = r/14.03
+    // with r = hypot(mean(0), mean(1))
+}
+*/
+
+// ------------------------------------------------------------------------
+//
+// Uses fRaDec as a reference point.
+//
+// Return dZd and dAz corresponding to the distance from x,y to fRaDec
+//
+// Before calling this function you should correct for abberation. In
+// case of MAGIC you can do this by:
+//    x /= 1.0713;
+//    y /= 1.0713;
+//
+// x [mm]: x coordinate in the camera plane (assuming a perfect mirror)
+// y [mm]: y coordinate in the camera plane (assuming a perfect mirror)
+//
+// We assume (0, 0) to be the center of the FOV
+//
+// dzd [deg]: Delta Zd
+// daz [deg]: Delta Az
+//
+void MAstroCamera::GetDiffZdAz(Double_t x, Double_t y, Double_t &dzd, Double_t &daz)
+{
+    // Reflect the corrected pixel on a perfect mirror
+    TVector3 v(x, y, fGeom->GetCameraDist()*1000);
+    TVector3 spot = fMirror0->GetReflection(v);
+    
+    // Derotate into the local coordinate system
+    const MAstroSky2Local rot(*fTime, *fObservatory);
+    const TRotation align(AlignCoordinates(rot*fRaDec).Inverse());
+    spot *= align;
+
+    cout << "Zd="<<spot.Theta()*TMath::RadToDeg() << " ";
+    cout << "Az="<<spot.Phi()  *TMath::RadToDeg()+360 << endl;
+
+    // Derotatet the center of the camera
+    TVector3 c(0, 0, 1);
+    c *= align;
+
+    dzd = (spot.Theta()-c.Theta())*TMath::RadToDeg();
+    daz = (spot.Phi()  -c.Phi())  *TMath::RadToDeg();
+
+    if (daz> 180) daz -= 360;
+    if (daz<-180) daz += 360;
+}
+
+// ------------------------------------------------------------------------
+//
+// Execute a gui event on the camera
+//
+void MAstroCamera::ExecuteEvent(Int_t event, Int_t mp1, Int_t mp2)
+{
+    // if (mp1>0 && mp2>0)
+    // {
+    //     // Calculate World coordinates from pixel
+    //     Double_t x = gPad->AbsPixeltoX(mp1);
+    //     Double_t y = gPad->AbsPixeltoY(mp2);
+    //
+    //     // Correct for abberation
+    //     x /= 1.0713;
+    //     y /= 1.0713;
+    //
+    //     Double_t dzd, daz;
+    //     GetDiffZdAz(x, y, dzd, daz);
+    //
+    //     cout << "dZd="<< dzd << " " << "dAz="<< daz << endl;
+    // }
+    //
+    // For MAGIC the distance of the mean of the light distribution
+    // to the Mirror0 reflection of the star (Abberation) can be
+    // expressed as:  dr = 0.0713*r = r/14.03
+    //                   +-0.0002
+
+    if (event==kKeyPress && fTime)
+        switch (mp2)
+        {
+        case kKey_Plus:
+            fTime->SetMjd(fTime->GetMjd()+0.25/24);
+            Update(kTRUE);
+            return;
+
+        case kKey_Minus:
+            fTime->SetMjd(fTime->GetMjd()-0.25/24);
+            Update(kTRUE);
+            return;
+        }
+
+    MAstroCatalog::ExecuteEvent(event, mp1, mp2);
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/meth/MAstroCamera.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/meth/MAstroCamera.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/meth/MAstroCamera.h	(revision 9661)
@@ -0,0 +1,46 @@
+#ifndef MARS_MAstroCamera
+#define MARS_MAstroCamera
+
+#ifndef MARS_MAstroCatalog
+#include "MAstroCatalog.h"
+#endif
+
+class TClonesArray;
+//class TList;
+
+class MTime;
+class MGeomCam;
+class MGeomMirror;
+class MObservatory;
+
+class MAstroCamera : public MAstroCatalog
+{
+private:
+    MGeomCam     *fGeom;
+    TClonesArray *fMirrors;
+
+    MGeomMirror  *fMirror0;     //!
+
+    Int_t   ConvertToPad(const TVector3 &w, TVector2 &v) const;
+    void   AddPrimitives(TString o);
+    void   SetRangePad(Option_t *o) { }
+    void   ExecuteEvent(Int_t event, Int_t mp1, Int_t mp2);
+
+    TList fCatList;
+
+public:
+    MAstroCamera();
+    ~MAstroCamera();
+
+    void SetMirrors(TClonesArray &arr);
+    void SetMirrors(const char *fname);
+    void SetGeom(const MGeomCam &cam);
+
+    void GetDiffZdAz(Double_t x, Double_t y, Double_t &dzd, Double_t &daz);
+    void StarPosInCamera();
+    TList *GetCatList() { return &fCatList; }
+
+    ClassDef(MAstroCamera, 1) // Display class to display stars on the camera
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtemp/meth/MDCA.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/meth/MDCA.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/meth/MDCA.cc	(revision 9661)
@@ -0,0 +1,281 @@
+
+
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Sebastian Commichau 05/2004 <mailto:commichau@particle.phys.ethz.ch>
+!   Author(s): Sabrina Stark       05/2004 <mailto:lstark@particle.phys.ethz.ch>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+// Container to store the DCA stuff - it offers a nice draw option...                   
+
+
+#include "MDCA.h"
+
+using namespace std;
+
+ClassImp(MDCA); 
+
+// Default constructor
+MDCA::MDCA(const char *name, const char *title) : fXRef(0.0), fYRef(0.0)
+{
+    fName = name ? name : "MDCA";
+    fTitle = title ? title : "Storage container for Hillas parameters and DCA of one event";
+ 
+    Reset();
+   
+    fEllipse = new TEllipse;
+    fRefCircle = new TEllipse;
+    
+    fLineL = new TLine;
+    fLineW = new TLine;
+    fLineX = new TLine;
+    fLineY = new TLine;
+    fLineDCA = new TLine;
+    fLineMean = new TLine;
+  
+}
+
+// Destructor: Deletes ellipse and lines if they do exist
+
+MDCA::~MDCA()
+{
+    Clear();
+}
+
+// Initialize parameters with default values
+
+void MDCA::Reset()
+{
+
+    fLength = -1;
+    fWidth  = -1;
+    fDelta0 =  0;
+    fMeanX  =  0;
+    fMeanY  =  0;
+    fDelta1 =  0;
+    fDCA    = -1;
+    fX1W    =  0;
+    fY1W    =  0;
+    fX2W    =  0;
+    fY2W    =  0;
+    fX1L    =  0;
+    fY1L    =  0;
+    fX2L    =  0;
+    fY2L    =  0;
+    fXDCA   =  0;
+    fYDCA   =  0;
+  
+}
+
+
+// Print parameters to *fLog
+
+void MDCA::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 << " - Delta0      [deg] = " << fDelta0*kRad2Deg << endl;
+    *fLog << " - Meanx       [mm]  = " << fMeanX  << endl;
+    *fLog << " - Meany       [mm]  = " << fMeanY  << endl;
+    *fLog << " - atg(y/x)    [deg] = " << atg     << endl;
+    *fLog << " - DCA         [mm]  = " << fDCA << endl;
+    *fLog << " - Delta1      [deg] = " << fDelta1*kRad2Deg << endl;
+
+    
+}
+
+void MDCA::Paint(Option_t *opt)
+{
+    Clear();
+
+    if (fLength<=0 || fWidth<=0) //fLength<0 || fWidth<0 doesn't look nice...
+        return;                  //We get a circle!
+
+    // Length line
+    fLineL = new TLine(fX1L, fY1L, fX2L, fY2L);
+    fLineL->SetLineWidth(2);
+    fLineL->SetLineColor(2);
+    fLineL->Draw();
+
+    // Width line
+    fLineW = new TLine(fX1W, fY1W, fX2W, fY2W);
+    fLineW->SetLineWidth(2);
+    fLineW->SetLineColor(2);
+    fLineW->Draw();
+
+    // Coordinate system
+    fLineX = new TLine(-600,fYRef,600,fYRef);
+    fLineY = new TLine(fXRef,-600,fXRef,600);
+    fLineX->SetLineWidth(2);
+    fLineX->SetLineColor(1);
+    fLineY->SetLineWidth(2);
+    fLineY->SetLineColor(1);
+    fLineX->Draw();
+    fLineY->Draw();
+    
+    // DCA line
+    fLineDCA = new TLine(fXRef,fYRef,fXDCA+fXRef,fYDCA+fYRef);
+    fLineDCA->SetLineWidth(2);
+    fLineDCA->SetLineColor(2);
+    fLineDCA->Draw();
+
+    // COG line
+    fLineMean = new TLine(fXRef,fYRef,fMeanX,fMeanY);
+    fLineMean->SetLineWidth(2);
+    fLineMean->SetLineColor(2);
+    fLineMean->Draw();
+
+    // Reference point marker
+    fRefCircle = new TEllipse(fXRef, fYRef, 5, 5, 0, 360, 0);
+    fRefCircle->SetLineColor(8);
+    fRefCircle->SetFillColor(8);
+    fRefCircle->Draw();
+
+    // Hillas ellipse
+    fEllipse = new TEllipse(fMeanX, fMeanY, fLength, fWidth, 0, 360, fDelta0*kRad2Deg+180);
+    fEllipse->SetLineWidth(2);
+    fEllipse->SetLineColor(2);
+    fEllipse->Draw();
+
+}
+
+
+// If an ellipse and lines exist they will be deleted 
+
+void MDCA::Clear(Option_t *)
+{
+    if (!fEllipse && !fRefCircle && !fLineL && !fLineW && !fLineX && !fLineY && !fLineDCA && !fLineMean) 
+        return;
+ 
+    delete fEllipse;
+    delete fRefCircle;
+    delete fLineL;
+    delete fLineW;
+    delete fLineX;
+    delete fLineY;
+    delete fLineDCA;
+    delete fLineMean;
+     
+    fLineL = NULL;
+    fLineX = NULL;
+    fLineY = NULL;
+    fLineW = NULL;
+    fLineDCA = NULL;
+    fLineMean = NULL;
+    fEllipse = NULL;
+    fRefCircle = NULL;
+}
+
+
+Int_t MDCA::Calc(const MGeomCam &geom, const MCerPhotEvt &evt, const MHillas &hil)
+{
+    // Get basic Hillas parameters from MHillas
+    fDelta0 = hil.GetDelta();
+    fMeanX  = hil.GetMeanX();
+    fMeanY  = hil.GetMeanY();
+    fLength = hil.GetLength();
+    fWidth  = hil.GetWidth();
+
+    // The Length Line - rotation and shift
+    fX1L = - (fLength+OffsetL)*cos(fDelta0) + fMeanX; // [mm]    
+    fY1L = - (fLength+OffsetL)*sin(fDelta0) + fMeanY; // [mm]    
+    fX2L =   (fLength+OffsetL)*cos(fDelta0) + fMeanX; // [mm]    
+    fY2L =   (fLength+OffsetL)*sin(fDelta0) + fMeanY; // [mm]
+
+    // The Width Line - rotation and shift
+    fX1W =   (fWidth+OffsetW)*sin(fDelta0) + fMeanX;  // [mm]   
+    fY1W = - (fWidth+OffsetW)*cos(fDelta0) + fMeanY;  // [mm]   
+    fX2W = - (fWidth+OffsetW)*sin(fDelta0) + fMeanX;  // [mm]   
+    fY2W =   (fWidth+OffsetW)*cos(fDelta0) + fMeanY;  // [mm]  
+
+    // Vector of orientation of the shower axis
+    fr1 = fX2L-fX1L;  
+    fr2 = fY2L-fY1L;  
+       
+    // Determine parameters to calculate coordinates of the DCA vector
+    flambda = (fr1*(fXRef-fMeanX) + fr2*(fYRef-fMeanY))/(fr1*fr1 + fr2*fr2);
+    fmu = (fMeanY-fYRef)/fr1 + flambda*fr2/fr1;
+
+    // Components of the DCA vector
+    fXDCA = -fmu*fr2;
+    fYDCA =  fmu*fr1;
+  
+    // Components of vector going from intersection point of the DCA vector
+    // with the shower axis to the COG
+    fd1 = fMeanX + fmu*fr2 - fXRef;
+    fd2 = fMeanY - fmu*fr1 - fYRef;
+
+    // Calculate DCA value 
+    fDCA = sqrt(fXDCA*fXDCA + fYDCA*fYDCA);
+
+    // Calculate angle of the shower axis with respect to the x-axis
+    fDelta1 = acos(fd1/sqrt(fd1*fd1 + fd2*fd2));
+
+    // Calculate angle of the shower axis with respect to the y-axis
+    //fDelta1 = acos(fd2/sqrt(fd1*fd1 + fd2*fd2)); 
+
+    // Determine the correct sign of the DCA (cross product of DCA vector and 
+    // vector going from the intersection point of the DCA vector with the shower axis
+    // to the COG)
+    if((fmu*(-fr2*(fMeanY-fYRef)-fr1*(fMeanX-fXRef)))<0)
+       fDCA = -fDCA;    
+
+    gRandom->Rannor(gx,gy);
+    gx = fabs(gx);
+  
+    // This is nice but does not remove the systematics in the profile plot...
+    //if(((1-0.6*gx)*(180-kRad2Deg*fDelta1)>120) || ((1-0.6*gx)*kRad2Deg*fDelta1>120))
+      // fDCA = -1;
+
+    // Enlarge the interval of Delta correctly...
+    if((fMeanY-fYRef-fmu*fr1)<0)
+       fDelta1 = TwoPi-fDelta1;
+
+    // Enlarge the interval of Delta correctly... (Delta with respect to the y-axis)
+    // if(-(fMeanX-fXRef+fmu*fr2)<0)
+     //  fDelta1 = TwoPi-fDelta1;
+
+    // This has to be improved...
+    if(fr1 == 0 || fr2 == 0 || (fr1*fr1+fr2*fr2) == 0 || sqrt(fd1*fd1+fd2*fd2) == 0)
+       fDCA = -fDCA;
+
+    SetReadyToSave();
+   
+    return 0;
+}
+
+void MDCA::SetRefPoint(const Float_t fXRef0, const Float_t fYRef0)
+{
+    fXRef = fXRef0;
+    fYRef = fYRef0;
+}
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/meth/MDCA.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/meth/MDCA.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/meth/MDCA.h	(revision 9661)
@@ -0,0 +1,109 @@
+#ifndef MARS_MDCA 
+#define MARS_MDCA
+
+
+#include <TArrayF.h>
+#include <TEllipse.h>
+#include <TLine.h>
+#include <TCanvas.h>
+#include <TROOT.h>
+#include <TStyle.h> 
+#include <TMath.h>
+#include <math.h>
+#include <TPad.h>
+#include <TRandom.h>
+#include <TRandom2.h>
+#include <fstream>
+#include <iostream>
+
+#include "MLog.h"
+#include "MLogManip.h"
+#include "MGeomCam.h"
+#include "MGeomPix.h"
+#include "MCerPhotPix.h"
+#include "MCerPhotEvt.h"
+#include "MHillas.h"
+
+// Add offsets to the Width and Length to draw nice lines
+#define OffsetW 20.0
+#define OffsetL 440.0
+
+#define kmm2Deg 0.00317460317
+#define TwoPi 6.28318530717958623 
+
+class TArrayF;
+class TEllipse;
+class MGeoCam;
+class MCerPhotEvt;
+class MHillas;
+
+class MDCA : public MParContainer
+{
+ private:
+    
+    Float_t fLength;  // [mm]   major axis of ellipse
+    Float_t fWidth;   // [mm]   minor axis of ellipse
+    Float_t fDelta0;  // [rad]  angle of major axis with x-axis (-Pi/2 .. Pi/2)
+    Float_t fDelta1;  // [rad]  my angle of major axis with x-axis (0 .. 2*Pi)
+    Float_t fMeanX;   // [mm]   x-coordinate of center of ellipse
+    Float_t fMeanY;   // [mm]   y-coordinate of center of ellipse
+    Float_t fX1W;     // [mm]   x-coordinate of 1st point of Lline
+    Float_t fY1W;     // [mm]   y-coordinate of 1st point of Lline
+    Float_t fX2W;     // [mm]   x-coordinate of 2nd point of Lline
+    Float_t fY2W;     // [mm]   y-coordinate of 2nd point of Lline
+    Float_t fX1L;     // [mm]   x-coordinate of 1st point of Wline
+    Float_t fY1L;     // [mm]   y-coordinate of 1st point of Wline
+    Float_t fX2L;     // [mm]   x-coordinate of 2nd point of Wline
+    Float_t fY2L;     // [mm]   y-coordinate of 2nd point of Wline
+    Double_t fDCA;    // [mm]   Distance of Cloasest Approach 
+    Float_t fXDCA;    // [mm]   x-coordinate of 2nd point of the DCA-line 
+    Float_t fYDCA;    // [mm]   y-coordinate of 2nd point of the DCA-line  
+    Float_t fXRef;    // [mm]   x-coordinate of reference point
+    Float_t fYRef;    // [mm]   y-coordinate of reference point
+    Float_t fmu;
+    Float_t flambda;  
+    Float_t fr1, fr2; // [mm] Coordinates of the orientation vector of the shower axis
+    Float_t fd1, fd2; // [mm] Coordinates of the DCA vector
+    Float_t gx, gy;
+   
+    TEllipse *fEllipse;   // Graphical object to draw the ellipse, ROOT!
+    TEllipse *fRefCircle; // To draw reference point
+
+    TLine *fLineL;        // Shower axis
+    TLine *fLineW;        // Line perpendicular to the shower axis
+    TLine *fLineX;        // x-axis of the coordinate system 
+    TLine *fLineY;        // y-axis of the coordinate system  
+    TLine *fLineDCA;      // DCA line
+    TLine *fLineMean;     // Line to COG of the shower 
+
+ public:
+    MDCA(const char *name=NULL, const char *title=NULL);
+
+    ~MDCA();
+
+    void Reset();
+
+    Int_t Calc(const MGeomCam &geom, const MCerPhotEvt &pix, const MHillas &hil);
+
+    void Print(Option_t *opt=NULL) const;
+
+    void Paint(Option_t *opt=NULL);
+
+    void Clear(Option_t *opt=NULL);
+
+    void SetRefPoint(const Float_t fXRef0, const Float_t fYRef0);
+    
+    Float_t GetDCA() const { return fDCA; }
+ 
+    Float_t GetDelta() const { return fDelta1; }
+
+    ClassDef(MDCA, 1) 
+
+};
+
+#endif
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/meth/MDCACalc.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/meth/MDCACalc.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/meth/MDCACalc.cc	(revision 9661)
@@ -0,0 +1,118 @@
+
+
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Sebastian Commichau 05/2004 <mailto:commichau@particle.phys.ethz.ch>
+!   Author(s): Sabrina Stark       05/2004 <mailto:lstark@particle.phys.ethz.ch>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+
+//Task to calculate the DCA parameter
+
+
+#include "MDCACalc.h"
+
+ClassImp(MDCACalc);
+
+using namespace std; 
+
+MDCACalc::MDCACalc(const char *name, const char *title)
+    : fDCAName("MDCA"), fFlags(0xff)
+{
+    fName  = name  ? name  : "MDCACalc";
+    fTitle = title ? title : "Calculate Hillas, DCA and other image parameters";
+    
+}
+
+Int_t MDCACalc::PreProcess(MParList *pList)
+{
+    fErrors = 0;
+
+    fCerPhotEvt = (MCerPhotEvt*)pList->FindObject(AddSerialNumber("MCerPhotEvt"));
+    if (!fCerPhotEvt)
+    {
+        *fLog << err << "MCerPhotEvt not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fGeomCam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
+    if (!fGeomCam)
+    {
+        *fLog << err << "MGeomCam (Camera Geometry) missing in Parameter List... aborting." << endl;
+        return kFALSE;
+    }
+
+    fHillas = (MHillas*)pList->FindObject(AddSerialNumber("MHillas"));
+    if (!fHillas)
+    {
+        *fLog << err << "MHillas missing in Parameter List... aborting." << endl;
+        return kFALSE;
+    }
+
+    if (TestFlag(kCalcDCA))
+        fMDCA = (MDCA*)pList->FindCreateObj("MDCA", AddSerialNumber(fDCAName));
+    else
+    {
+        fMDCA = (MDCA*)pList->FindObject(AddSerialNumber(fDCAName), "MDCA");
+        *fLog << err << fDCAName << " [MDCA] not found... aborting." << endl;
+    }
+    if (!fMDCA)
+        return kFALSE;
+
+    return kTRUE;
+}
+
+// If the calculation wasn't sucessfull skip this event
+
+Int_t MDCACalc::Process()
+{
+
+    if (TestFlag(kCalcDCA))
+    {
+        Int_t rc = fMDCA->Calc(*fGeomCam, *fCerPhotEvt, *fHillas);
+          
+
+	if (rc == -1)
+        {
+	    fErrors++;
+            *fLog << err << dbginf << "MDCA::Calc returned ... error!" << endl;
+            return kFALSE;
+        }
+   }
+   
+    return kTRUE;
+}
+
+Int_t MDCACalc::PostProcess()
+{
+
+    *fLog << fErrors << " errors occured..." << endl;
+    *fLog << endl;
+
+    return kTRUE;
+} 
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/meth/MDCACalc.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/meth/MDCACalc.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/meth/MDCACalc.h	(revision 9661)
@@ -0,0 +1,60 @@
+
+#ifndef MARS_MDCACalc
+#define MARS_MDCACalc
+
+#include "MTask.h"
+#include "MParList.h"
+#include "MDCA.h"
+#include "MCerPhotEvt.h"
+#include "MLog.h"
+#include "MLogManip.h"
+#include "MHillasCalc.h"
+
+class MGeomCam;
+class MCerPhotEvt;
+class MDCA;
+
+class MDCACalc : public MTask
+{
+    const MGeomCam    *fGeomCam;    // Camera Geometry used to calculate Hillas
+    const MCerPhotEvt *fCerPhotEvt; // Cerenkov Photon Event used for calculation
+    const MHillas     *fHillas;
+
+    MDCA        *fMDCA;  // Output container to store the result
+
+    TString      fDCAName;
+
+    Double_t par[6];
+    Double_t dca;
+
+    Int_t    fErrors;
+    Int_t    fFlags;
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
+public:
+     enum CalcCont_t {
+        kCalcDCA      = BIT(0),
+    };
+
+     MDCACalc(const char *name=NULL, const char *title=NULL);
+
+    void SetNameDCA(const char *name)    { fDCAName = name; }
+
+    void SetFlags(Int_t f) { fFlags  =  f; }
+    void Enable(Int_t f)   { fFlags |=  f; }
+    void Disable(Int_t f)  { fFlags &= ~f; }
+    Bool_t TestFlag(CalcCont_t i) const { return fFlags&i; }
+    
+    
+    ClassDef(MDCACalc, 0) // Task to calculate DCA 
+};
+
+#endif
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/meth/MFindStars.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/meth/MFindStars.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/meth/MFindStars.cc	(revision 9661)
@@ -0,0 +1,1030 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!   Author(s): Robert Wagner, 2/2004 <mailto:rwagner@mppmu.mpg.de>
+!   Author(s): Javier López , 4/2004 <mailto:jlopez@ifae.es>
+!   Author(s): Sabrina Stark , 7/2004 <mailto:stark@particle.phys.ethz.ch>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MFindStars
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MFindStars.h"
+
+#include <TMinuit.h>
+#include <TStopwatch.h>
+#include <TTimer.h>
+#include <TString.h>
+#include <TFile.h>
+#include <TTree.h>
+#include <TCanvas.h>
+#include <TH1F.h>
+#include <TF1.h>
+
+#include "MObservatory.h"
+#include "MAstroCamera.h"
+#include "MMcConfigRunHeader.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MHCamera.h"
+
+#include "MGeomCam.h"
+#include "MGeomPix.h"
+#include "MCameraDC.h"
+#include "MTime.h"
+#include "MReportDrive.h"
+#include "MStarLocalCam.h"
+#include "MStarLocalPos.h"
+
+#include "MParList.h"
+#include "MTaskList.h"
+
+ClassImp(MFindStars);
+using namespace std;
+
+const Float_t sqrt2 = sqrt(2.);
+const Float_t sqrt3 = sqrt(3.);
+const UInt_t  lastInnerPixel = 396;
+    
+
+//______________________________________________________________________________
+//
+// The 2D gaussian fucntion used to fit the spot of the star
+//
+static Double_t func(float x,float y,Double_t *par)
+{
+    Double_t value=par[0]+par[1]*exp(-(-(x-par[2])*sin(par[6]) - (y-par[4])*cos(par[6]))*(-(x-par[2])*sin(par[6]) - (y-par[4])*cos(par[6]))/(2*par[3]*par[3]))*exp(-((x-par[2])*cos(par[6]) - (y-par[4])*sin(par[6]))*((x-par[2])*cos(par[6]) - (y-par[4])*sin(par[6]))/(2*par[5]*par[5]));
+
+    return value;
+}
+
+//______________________________________________________________________________
+//
+// Function used by Minuit to do the fit
+//
+static void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)
+{
+
+  MParList*      plist = (MParList*)gMinuit->GetObjectFit();
+  MTaskList*     tlist = (MTaskList*)plist->FindObject("MTaskList");
+  MFindStars*    find = (MFindStars*)tlist->FindObject("MFindStars");
+  MStarLocalCam* stars = (MStarLocalCam*)plist->FindObject("MStarLocalCam");
+  MGeomCam*      geom = (MGeomCam*)plist->FindObject("MGeomCam");
+
+  MHCamera& display = (MHCamera&)find->GetDisplay();
+  
+  Float_t innerped = stars->GetInnerPedestalDC();
+  Float_t innerrms = stars->GetInnerPedestalRMSDC();
+  Float_t outerped = stars->GetOuterPedestalDC();
+  Float_t outerrms = stars->GetOuterPedestalRMSDC();
+
+  UInt_t numPixels = geom->GetNumPixels();
+  
+//calculate chisquare
+    Double_t chisq = 0;
+    Double_t delta;
+    Double_t x,y,z;
+    Double_t errorz=0;
+
+    UInt_t usedPx=0;
+    for (UInt_t pixid=1; pixid<numPixels; pixid++) 
+    {
+	if (display.IsUsed(pixid))
+	{
+	    x = (*geom)[pixid].GetX();
+	    y = (*geom)[pixid].GetY();
+            z = display.GetBinContent(pixid+1)-(pixid>lastInnerPixel?outerped:innerped);
+            errorz=(pixid>lastInnerPixel?outerrms:innerrms);
+	    if (errorz > 0.0)
+	    {
+              usedPx++;
+              delta  = (z-func(x,y,par))/errorz;
+              chisq += delta*delta;
+	    }
+	    else
+		cerr << " TMinuit::fcn errorz[" << pixid << "] " << errorz << endl;
+	}
+    }
+    f = chisq;
+
+    find->SetChisquare(chisq);
+    find->SetDegreesofFreedom(usedPx);
+}
+
+MFindStars::MFindStars(const char *name, const char *title): 
+  fGeomCam(NULL), fCurr(NULL), fTimeCurr(NULL), fDrive(NULL), fStars(NULL), fNumVar(7)
+{
+  fName  = name  ? name  : "MFindStars";
+  fTitle = title ? title : "Tool to find stars from DC Currents";
+
+  fNumIntegratedEvents=0;
+  fMaxNumIntegratedEvents = 10;
+  fRingInterest = 125.; //[mm] ~ 0.4 deg
+  fDCTailCut = 4;
+  
+  fPixelsUsed.Set(577);
+  fPixelsUsed.Reset((Char_t)kTRUE);
+  
+  //Fitting(Minuit) initialitation
+  const Float_t pixelSize = 31.5; //[mm]
+  fMinuitPrintOutLevel = -1; 
+  
+  fVname = new TString[fNumVar];
+  fVinit.Set(fNumVar); 
+  fStep.Set(fNumVar); 
+  fLimlo.Set(fNumVar); 
+  fLimup.Set(fNumVar); 
+  fFix.Set(fNumVar);
+
+  fVname[0] = "background";
+  fVinit[0] = fMaxNumIntegratedEvents;
+  fStep[0]  = fVinit[0]/sqrt2;
+  fLimlo[0] = 0;
+  fLimup[0] = 4.*fMaxNumIntegratedEvents;
+  fFix[0]   = 0;
+
+  fVname[1] = "max";
+  fVinit[1] = 10.*fMaxNumIntegratedEvents;
+  fStep[1]  = fVinit[0]/sqrt2;
+  fLimlo[1] = fMinDCForStars;
+  fLimup[1] = 30.*fMaxNumIntegratedEvents;
+  fFix[1]   = 0;
+
+  fVname[2] = "meanx";
+  fVinit[2] = 0.;
+  fStep[2]  = fVinit[1]/sqrt2;
+  fLimlo[2] = -600.;
+  fLimup[2] = 600.;
+  fFix[2]   = 0;
+
+  fVname[3] = "sigmaminor";
+  fVinit[3] = pixelSize;
+  fStep[3]  = fVinit[2]/sqrt2;
+  fLimlo[3] = pixelSize/(2*sqrt3);
+  fLimup[3] = 500.;
+  fFix[3]   = 0;
+
+  fVname[4] = "meany";
+  fVinit[4] = 0.;
+  fStep[4]  = fVinit[3]/sqrt2;
+  fLimlo[4] = -600.;
+  fLimup[4] = 600.;
+  fFix[4]   = 0;
+
+  fVname[5] = "sigmamajor";
+  fVinit[5] = pixelSize;
+  fStep[5]  = fVinit[4]/sqrt2;
+  fLimlo[5] = pixelSize/(2*sqrt3);
+  fLimup[5] = 500.;
+  fFix[5]   = 0;
+
+  fVname[6] = "phi";
+  fVinit[6] = 0.;
+  fStep[6]  = fVinit[0]/sqrt2;
+  fLimlo[6] = 0.;
+  fLimup[6] = TMath::TwoPi();
+  fFix[6]   = 0;
+
+
+  fObjectFit  = NULL;
+  //  fMethod     = "SIMPLEX";
+  fMethod     = "MIGRAD";
+  //  fMethod     = "MINIMIZE";
+  fNulloutput = kFALSE;
+
+  // Set output level
+  //  fLog->SetOutputLevel(3); // No dbg messages
+}
+
+Int_t MFindStars::PreProcess(MParList *pList)
+{
+
+    fGeomCam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
+
+    if (!fGeomCam)
+    {
+      *fLog << err << AddSerialNumber("MGeomCam") << " not found ... aborting" << endl;
+      return kFALSE;
+    }
+
+    // Initialize camera display with the MGeomCam information
+    fDisplay.SetGeometry(*fGeomCam,"FindStarsDisplay","FindStarsDisplay");
+    fDisplay.SetUsed(fPixelsUsed);
+
+    fCurr = (MCameraDC*)pList->FindObject(AddSerialNumber("MCameraDC"));
+
+    if (!fCurr)
+    {
+      *fLog << err << AddSerialNumber("MCameraDC") << " not found ... aborting" << endl;
+      return kFALSE;
+    }
+
+    fTimeCurr = (MTime*)pList->FindObject(AddSerialNumber("MTimeCurrents"));
+
+    if (!fTimeCurr)
+    {
+      *fLog << err << AddSerialNumber("MTimeCurrents") << " not found ... aborting" << endl;
+      return kFALSE;
+    }
+
+    //    fDrive = (MReportDrive*)pList->FindObject(AddSerialNumber("MReportDrive"));
+
+    if (!fDrive)
+      {
+        *fLog << warn << AddSerialNumber("MReportDrive") << " not found ... ignored." << endl;
+      }
+    
+
+    // Initalization of MAstroCamera
+
+    fAstroCamera = new MAstroCamera();
+
+    // Current observatory
+    MObservatory magic1;
+    MMcConfigRunHeader *config=0;
+    MGeomCam           *geom=0;
+    TString fname = "/dd/magLQE_3/gh/0/0/G_M0_00_0_550150_w0.root";
+    TFile file(fname);
+    TTree *tree = (TTree*)file.Get("RunHeaders");
+    tree->SetBranchAddress("MMcConfigRunHeader", &config);
+    if (tree->GetBranch("MGeomCam"))
+      tree->SetBranchAddress("MGeomCam", &geom);
+    tree->GetEntry(0);
+    
+    fAstroCamera->SetMirrors(*config->GetMirrors());
+    fAstroCamera->SetGeom(*geom);
+    // Right Ascension [h] and declination [deg] of source
+    // Currently 'perfect' pointing is assumed
+    const Double_t ra  = fAstro.Hms2Rad(fSrcRaHour,fSrcRaMin, fSrcRaSec); 
+    const Double_t dec = fAstro.Dms2Rad(fSrcDecDeg, fSrcDecMin, fSrcDecSec);
+    cout << "----------------------------FindStars,pos = "<<ra<<" , "<<dec<<" , "<<fSrcRaHour<<endl;
+    // Magnitude up to which the stars are loaded from the catalog
+    fAstroCamera->SetLimMag(6);
+    // Radius of FOV around the source position to load the stars
+    fAstroCamera->SetRadiusFOV(3);
+    // Source position
+    fAstroCamera->SetRaDec(ra, dec);
+    // Catalog to load (here: Bright Star Catalog V5)
+    fAstroCamera->ReadBSC("../catalogs/bsc5.dat");
+    // Obersavatory and time to also get local coordinate information
+    fAstroCamera->SetObservatory(magic1);
+    // fRes contains the corrected source position
+    fRes = new TVector3;
+    
+    fStars = (MStarLocalCam*)pList->FindCreateObj(AddSerialNumber("MStarLocalCam"));
+    if (!fStars)
+    {
+      *fLog << err << AddSerialNumber("MStarLocalCam") << " cannot be created ... aborting" << endl;
+      return kFALSE;
+    }
+
+    fMinDCForStars = 1.*fMaxNumIntegratedEvents; //[uA]
+
+    // Initialize the TMinuit object
+
+    TMinuit *gMinuit = new TMinuit(fNumVar);  //initialize TMinuit with a maximum of params
+    gMinuit->SetFCN(fcn);
+
+    Double_t arglist[2*fNumVar];//[10];
+    Int_t ierflg = 0;
+
+    arglist[0] = 1;
+    gMinuit->mnexcm("SET ERR", arglist ,1,ierflg);
+    arglist[0] = fMinuitPrintOutLevel;
+    gMinuit->mnexcm("SET PRI", arglist ,1,ierflg);
+
+    // Set MParList object pointer to allow mimuit to access internally
+    gMinuit->SetObjectFit(pList);
+
+    return kTRUE;
+}
+
+Int_t MFindStars::Process()
+{
+  UInt_t numPixels = fGeomCam->GetNumPixels();
+  TArrayC origPixelsUsed;
+  origPixelsUsed.Set(numPixels);
+    if (fNumIntegratedEvents >= fMaxNumIntegratedEvents)
+    {
+          //Fist delete the previus stars in the list
+	  fAstroCamera->GetCatList()->Delete();
+	  // Time for which to get the star position
+	  fAstroCamera->SetTime(*fTimeCurr);  // FIX ME: time should be averaged 
+	  //Clone the catalog due to the validity range of the instance
+	  TObject *o = fAstroCamera->Clone();
+	  o->SetBit(kCanDelete);
+	  o->Draw("mirror");  
+
+	  fAstroCamera->StarPosInCamera();
+
+      if (fDrive)
+        {
+//           Float_t ra  = fDrive->GetRa();
+//           Float_t dec = fDrive->GetDec();
+          
+//           fAstro.SetRaDec(ra, dec);
+//           fAstro.SetGuiActive();
+          
+//           fAstro.FillStarList();
+        }
+      else
+        {
+          //Fist delete the previus stars in the list
+          fStars->GetList()->Delete();
+
+          for (UInt_t pix=1; pix<numPixels; pix++)
+            {
+              if (fDisplay.IsUsed(pix))
+                origPixelsUsed[pix]=(Char_t)kTRUE;
+              else
+                  origPixelsUsed[pix]=(Char_t)kFALSE;
+            }
+          
+	  if (DCPedestalCalc())
+            {
+
+              Float_t innermin = fStars->GetInnerPedestalDC()+fDCTailCut*fStars->GetInnerPedestalRMSDC();
+              Float_t outermin = fStars->GetOuterPedestalDC()+fDCTailCut*fStars->GetOuterPedestalRMSDC();
+              fMinDCForStars = innermin>outermin?innermin:outermin;
+              if (fMinuitPrintOutLevel>=0) *fLog << dbg << "fMinDCForStars = " << fMinDCForStars << endl;
+              
+              // Find the star candidats searching the most brights pairs of pixels
+              Float_t maxPixelDC;
+              MGeomPix maxPixel;
+
+              while(FindPixelWithMaxDC(maxPixelDC, maxPixel))
+                {
+                  
+                  MStarLocalPos *starpos = new MStarLocalPos;
+                  starpos->SetExpValues(maxPixelDC,maxPixel.GetX(),maxPixel.GetY());
+                  starpos->SetCalcValues(maxPixelDC,maxPixelDC,maxPixel.GetX(),maxPixel.GetY(),fRingInterest/2,fRingInterest/2);
+                  starpos->SetFitValues(maxPixelDC,maxPixelDC,maxPixel.GetX(),maxPixel.GetY(),fRingInterest/2,fRingInterest/2,0.,1);
+                  fStars->GetList()->Add(starpos);
+                  
+                  ShadowStar(starpos);
+                  
+                }
+              
+              fDisplay.SetUsed(origPixelsUsed);
+            }
+          
+        }
+      
+      //loop to extract position of stars on the camera
+      if (fStars->GetList()->GetSize() == 0)
+        {
+          *fLog << err << GetName() << " No stars candidates in the camera." << endl;
+          return kCONTINUE;
+        }
+      else
+          *fLog << inf << GetName() << " Found " << fStars->GetList()->GetSize() << " stars candidates in the camera." << endl;
+          
+
+      for (UInt_t pix=1; pix<numPixels; pix++)
+        {
+          if (fDisplay.IsUsed(pix))
+            origPixelsUsed[pix]=(Char_t)kTRUE;
+          else
+            origPixelsUsed[pix]=(Char_t)kFALSE;
+        }
+
+      TIter Next(fStars->GetList());
+      MStarLocalPos* star;
+      while ((star=(MStarLocalPos*)Next()))
+        {
+          FindStar(star);
+          ShadowStar(star);
+        }
+
+      //Get the corrected source position
+      TVector3 *res = new TVector3;
+      if (CorrSourcePos(res))
+	  fRes = res;
+      else
+	  fRes->SetXYZ(-1000, -1000, -1000);
+      //After finding stars reset all vairables
+      fDisplay.Reset();
+      fStars->GetDisplay().Reset(); //FIXME: Put this display just in the container
+      fDisplay.SetUsed(origPixelsUsed);
+      fNumIntegratedEvents=0;
+    }
+
+    for (UInt_t pix=1; pix<numPixels; pix++)
+      {
+        if (fDisplay.IsUsed(pix))
+          origPixelsUsed[pix]=(Char_t)kTRUE;
+        else
+          origPixelsUsed[pix]=(Char_t)kFALSE;
+        
+      }
+    
+    fDisplay.AddCamContent(*fCurr);
+    fNumIntegratedEvents++;
+    fDisplay.SetUsed(origPixelsUsed);
+    
+
+  return kTRUE;
+}
+
+Int_t MFindStars::PostProcess()
+{
+  return kTRUE;
+}
+
+void MFindStars::SetBlindPixels(TArrayS blindpixels)
+{
+    Int_t npix = blindpixels.GetSize();
+
+    for (Int_t idx=0; idx<npix; idx++)
+      {
+	fPixelsUsed[blindpixels[idx]]=(Char_t)kFALSE;
+        if (fMinuitPrintOutLevel>=0) *fLog << dbg << "MFindStars::SetBlindPixels fDisplay.IsUsed(" <<blindpixels[idx]  << ") kFALSE" << endl;
+      }
+    
+    fDisplay.SetUsed(fPixelsUsed);
+}
+
+Bool_t MFindStars::DCPedestalCalc()
+{
+    //-------------------------------------------------------------
+    // save pointer to the MINUIT object for optimizing the supercuts
+    // because it will be overwritten 
+    // when fitting the alpha distribution in MHFindSignificance
+    TMinuit *savePointer = gMinuit;
+    //-------------------------------------------------------------
+
+   UInt_t numPixels = fGeomCam->GetNumPixels();
+   Float_t ped;
+   Float_t rms;
+
+   TH1F **dchist = new TH1F*[2];
+   for (UInt_t i=0; i<2; i++)
+      dchist[i] = new TH1F("","",26,0.4*fMaxNumIntegratedEvents,3.*fMaxNumIntegratedEvents);
+   
+   for (UInt_t pix=1; pix<=lastInnerPixel; pix++)
+       dchist[0]->Fill(fDisplay.GetBinContent(pix+1));
+   for (UInt_t pix=lastInnerPixel+1; pix<numPixels; pix++)
+       dchist[1]->Fill(fDisplay.GetBinContent(pix+1));
+
+   // inner/outer pixels
+   for (UInt_t i=0; i<2; i++)
+    {
+      Float_t nummaxprobdc = dchist[i]->GetBinContent(dchist[i]->GetMaximumBin());
+      Float_t maxprobdc = dchist[i]->GetBinCenter(dchist[i]->GetMaximumBin());
+      UInt_t bin = dchist[i]->GetMaximumBin();
+      do
+        {
+          bin++;
+        }
+      while(dchist[i]->GetBinContent(bin)/nummaxprobdc > 0.5);
+      Float_t halfmaxprobdc = dchist[i]->GetBinCenter(bin);
+      
+      if (fMinuitPrintOutLevel>=0) *fLog << dbg << " maxprobdc[high] " << maxprobdc << "[" << nummaxprobdc << "] ";
+      if (fMinuitPrintOutLevel>=0) *fLog << dbg << " halfmaxprobdc[high] " << halfmaxprobdc << "[" << dchist[i]->GetBinContent(bin) << "]" << endl;
+      
+      Float_t rmsguess = TMath::Abs(maxprobdc-halfmaxprobdc);
+      Float_t min = maxprobdc-3*rmsguess;
+      min = (min<0.?0.:min);
+      Float_t max = maxprobdc+3*rmsguess;
+      
+      if (fMinuitPrintOutLevel>=0) *fLog << dbg << " maxprobdc " << maxprobdc << " rmsguess " << rmsguess << endl;
+      
+      TF1 func("func","gaus",min,max);
+      func.SetParameters(nummaxprobdc, maxprobdc, rmsguess);
+      
+      dchist[i]->Fit("func","QR0");
+      
+      UInt_t aproxnumdegrees = 6*(bin-dchist[i]->GetMaximumBin());
+      Float_t chiq = func.GetChisquare();
+      ped = func.GetParameter(1);
+      rms = func.GetParameter(2);
+      
+      if (fMinuitPrintOutLevel>=0) *fLog << dbg << " ped " << ped << " rms " << rms << " chiq/ndof " << chiq << "/" << aproxnumdegrees << endl;
+      
+      Int_t numsigmas = 5;
+      Axis_t minbin = ped-numsigmas*rms/dchist[i]->GetBinWidth(1);
+      minbin=minbin<1?1:minbin;
+      Axis_t maxbin = ped+numsigmas*rms/dchist[i]->GetBinWidth(1);
+      if (fMinuitPrintOutLevel>=0) *fLog << dbg << " Number of pixels with dc under " << numsigmas << " sigmas = " << dchist[i]->Integral((int)minbin,(int)maxbin) << endl;
+      
+      //Check results from the fit are consistent
+      if (ped < 0. || rms < 0.)
+        {
+          *fLog << dbg << "dchist[i]->GetEntries()" << dchist[i]->GetEntries();
+//            TCanvas *c1 = new TCanvas("c2","c2",500,800);
+//            dchist[i]->Draw();
+//            c1->Print("dchist.ps");
+//            delete c1;
+//            exit(1);
+        }
+      else if (TMath::Abs(ped-maxprobdc) > rmsguess || rms > rmsguess)
+        {
+          *fLog << warn << GetName() << " Pedestal DC fit give non consistent results for " << (i==0?"Inner":"Outer") << "pixels." << endl;
+          *fLog << warn << " maxprobdc " << maxprobdc << " rmsguess " << rmsguess << endl;
+          *fLog << warn << " ped " << ped << " rms " << rms << " chiq/ndof " << chiq << "/" << aproxnumdegrees << endl;
+          ped = maxprobdc;
+          rms = rmsguess/1.175; // FWHM=2.35*rms
+        }
+   
+      if (i == 0)
+        {
+          fStars->SetInnerPedestalDC(ped);
+          fStars->SetInnerPedestalRMSDC(rms);
+        }
+      else
+        {
+          fStars->SetOuterPedestalDC(ped);
+          fStars->SetOuterPedestalRMSDC(rms);
+        }
+
+      
+
+    }
+   
+
+   for (UInt_t i=0; i<2; i++)
+      delete dchist[i];
+   delete [] dchist;
+
+   //=================================================================
+
+   // reset gMinuit to the MINUIT object for optimizing the supercuts 
+   gMinuit = savePointer;
+   //-------------------------------------------
+   
+   if (fStars->GetInnerPedestalDC() < 0. ||  fStars->GetInnerPedestalRMSDC() < 0. || fStars->GetOuterPedestalDC() < 0. ||  fStars->GetOuterPedestalRMSDC() < 0.)
+     return kFALSE;
+  
+   return kTRUE;
+}
+    
+Bool_t MFindStars::FindPixelWithMaxDC(Float_t &maxDC, MGeomPix &maxPix)
+{
+    UInt_t numPixels = fGeomCam->GetNumPixels();
+
+// Find the two close pixels with the maximun dc
+    UInt_t maxPixIdx[2];
+
+    maxDC = 0;
+
+    for (UInt_t pix=1; pix<numPixels; pix++)
+    {
+	if(fDisplay.IsUsed(pix))
+	{
+	    Float_t dc[2];
+	    dc[0] = fDisplay.GetBinContent(pix+1);
+	    if (dc[0] < fMinDCForStars)
+		continue;
+
+	    MGeomPix &g = (*fGeomCam)[pix];
+	    Int_t numNextNeighbors = g.GetNumNeighbors();
+	    
+	    Float_t dcsum;
+	    for(Int_t nextNeighbor=0; nextNeighbor<numNextNeighbors; nextNeighbor++)
+	    {
+              UInt_t swneighbor = g.GetNeighbor(nextNeighbor);
+              if(fDisplay.IsUsed(swneighbor))
+                {
+                  dc[1] = fDisplay.GetBinContent(swneighbor+1);
+                  if (dc[1] < fMinDCForStars)
+                    continue;
+                  
+                  dcsum = dc[0] + dc[1];
+                  
+                  if(dcsum > maxDC*2)
+                    {
+                      if(dc[0]>=dc[1])
+                        {
+                          maxPixIdx[0] = pix;
+                          maxPixIdx[1] = swneighbor;
+                          maxDC = dc[0];
+                        }
+                      else
+                        {
+                          maxPixIdx[1] = pix;
+                          maxPixIdx[0] = swneighbor;
+                          maxDC = dc[1];
+                        }
+                    }	
+                }
+            }
+        }
+    }
+
+    if (maxDC == 0)
+      {
+        *fLog << warn << " No found pixels with maximum dc" << endl;
+	return kFALSE;
+      }
+    
+    maxPix = (*fGeomCam)[maxPixIdx[0]];
+
+    if (fMinuitPrintOutLevel>=0) *fLog << dbg << "Star candidate maxDC(" << setw(3) << maxDC << " uA) x position(" << setw(3) << maxPix.GetX() <<  " mm) x position(" << setw(3) << maxPix.GetY() << " mm) swnumber(" << maxPixIdx[0] << ")" << endl;
+
+    return kTRUE;
+}
+
+Bool_t MFindStars::FindStar(MStarLocalPos* star)
+{    
+
+  UInt_t numPixels = fGeomCam->GetNumPixels();
+  Float_t innerped = fStars->GetInnerPedestalDC();
+  Float_t outerped = fStars->GetOuterPedestalDC();
+
+  TArrayC origPixelsUsed;
+  origPixelsUsed.Set(numPixels);
+  
+  for (UInt_t pix=1; pix<numPixels; pix++)
+    {
+      if (fDisplay.IsUsed(pix))
+        origPixelsUsed[pix]=(Char_t)kTRUE;
+      else
+        origPixelsUsed[pix]=(Char_t)kFALSE;
+    }
+  
+  Float_t expX = star->GetXExp();
+  Float_t expY = star->GetYExp();
+  
+  Float_t max=0;
+  UInt_t  pixmax=0;
+  Float_t meanX=0;
+  Float_t meanY=0;
+  Float_t meanSqX=0;
+  Float_t meanSqY=0;
+  Float_t sumCharge=0;
+  UInt_t usedInnerPx=0;	
+  UInt_t usedOuterPx=0;	
+
+  const Float_t meanPresition = 3.; //[mm]
+  const UInt_t maxNumIterations = 10;
+  UInt_t numIterations = 0;
+
+  do
+    {
+  // First define a area of interest around the expected position of the star
+  for (UInt_t pix=1; pix<numPixels; pix++)
+    {
+      
+      Float_t pixXpos=(*fGeomCam)[pix].GetX();
+      Float_t pixYpos=(*fGeomCam)[pix].GetY();
+      Float_t dist = sqrt((pixXpos-expX)*(pixXpos-expX)+
+                          (pixYpos-expY)*(pixYpos-expY));
+      
+      if ((dist < fRingInterest) && fDisplay.IsUsed(pix))
+        fPixelsUsed[pix]=(Char_t)kTRUE;
+      else
+        fPixelsUsed[pix]=(Char_t)kFALSE;
+    }
+  
+    fDisplay.SetUsed(fPixelsUsed);
+    
+// determine mean x and mean y
+    usedInnerPx=0;	
+    usedOuterPx=0;	
+    for(UInt_t pix=0; pix<numPixels; pix++)
+    {
+	if(fDisplay.IsUsed(pix))
+	{
+	    pix>lastInnerPixel?usedOuterPx++:usedInnerPx++;
+
+	    Float_t charge  = fDisplay.GetBinContent(pix+1);
+	    Float_t pixXpos = (*fGeomCam)[pix].GetX();
+	    Float_t pixYpos = (*fGeomCam)[pix].GetY();
+
+            if (charge>max)
+              {
+                max=charge;
+                pixmax=pix;
+              }
+            
+	    meanX     += charge*pixXpos;
+	    meanY     += charge*pixYpos;
+	    meanSqX   += charge*pixXpos*pixXpos;
+	    meanSqY   += charge*pixYpos*pixYpos;
+	    sumCharge += charge;
+	}
+    }
+
+    if (fMinuitPrintOutLevel>=0) *fLog << dbg << " usedInnerPx " << usedInnerPx << " usedOuterPx " << usedOuterPx << endl;
+
+    meanX   /= sumCharge;
+    meanY   /= sumCharge;
+    meanSqX /= sumCharge;
+    meanSqY /= sumCharge;
+
+    expX = meanX;
+    expY = meanY;
+
+    if (++numIterations >  maxNumIterations)
+      {
+        *fLog << warn << GetName() << "Mean calculation not converge after " << maxNumIterations << " iterations" << endl;
+        break;
+      }
+        
+    }while(TMath::Abs(meanX-expX) > meanPresition || TMath::Abs(meanY-expY) > meanPresition);
+  
+    Float_t rmsX = (meanSqX - meanX*meanX) - fRingInterest*fRingInterest/12;
+    Float_t rmsY = (meanSqY - meanY*meanY) - fRingInterest*fRingInterest/12;
+
+    if ( rmsX > 0)
+      rmsX =  TMath::Sqrt(rmsX);
+    else
+      {
+        *fLog << warn << " MFindStars::FindStar negative rmsX² " << rmsX << endl;
+        *fLog << warn << " meanSqX " << meanSqX << " meanX " << meanX << " fRingInterest " << fRingInterest << " sumCharge " << sumCharge << endl;
+        rmsX = 0.;
+      }
+
+    if ( rmsY > 0)
+      rmsY =  TMath::Sqrt(rmsY);
+    else
+      {
+        *fLog << warn << " MFindStars::FindStar negative rmsY² " << rmsY << endl;
+        *fLog << warn << " meanSqY " << meanSqY << " meanY " << meanY << " fRingInterest " << fRingInterest << " sumCharge " << sumCharge<< endl;
+        rmsY = 0.;
+      }
+    
+    // Substrack pedestal DC
+    sumCharge-= (usedInnerPx*innerped+usedOuterPx*outerped)/(usedInnerPx+usedOuterPx);
+    max-=pixmax>lastInnerPixel?outerped:innerped;
+    
+
+    star->SetCalcValues(sumCharge,max,meanX,meanY,rmsX,rmsY);
+
+    if (rmsX <= 0. || rmsY <= 0.)
+      return kFALSE;
+    
+    
+// fit the star spot using TMinuit
+
+    
+    for (UInt_t pix=1; pix<numPixels; pix++)
+      if (fDisplay.IsUsed(pix))
+        if (fMinuitPrintOutLevel>=0) *fLog << dbg << "[fit the star spot] fDisplay.IsUsed(" << pix << ") kTRUE" << endl;
+  
+    if (fMinuitPrintOutLevel>=0) *fLog << dbg << "fMinDCForStars " << fMinDCForStars << " pixmax>lastInnerPixel?outerped:innerped " << (pixmax>lastInnerPixel?outerped:innerped) << " fMaxNumIntegratedEvents " << fMaxNumIntegratedEvents << endl;
+
+  //Initialate variables for fit
+    fVinit[0] = 0;
+    fVinit[1] = max;
+    fLimlo[1] = fMinDCForStars-(pixmax>lastInnerPixel?outerped:innerped);
+    fLimup[1] = 30*fMaxNumIntegratedEvents-(pixmax>lastInnerPixel?outerped:innerped);
+    fVinit[2] = meanX;
+    fVinit[3] = rmsX;
+    fVinit[4] = meanY;
+    fVinit[5] = rmsY;
+    fVinit[6] = 0;
+    //Init steps
+    for(Int_t i=0; i<fNumVar; i++)
+      {
+	if (fVinit[i] != 0)
+	  fStep[i] = TMath::Abs(fVinit[i]/sqrt2);
+        if (fMinuitPrintOutLevel>=0) *fLog << dbg << " fVinit[" << i << "] " << fVinit[i];
+        if (fMinuitPrintOutLevel>=0) *fLog << dbg << " fStep[" << i << "] " << fStep[i];
+        if (fMinuitPrintOutLevel>=0) *fLog << dbg << " fLimlo[" << i << "] " << fLimlo[i];
+        if (fMinuitPrintOutLevel>=0) *fLog << dbg << " fLimup[" << i << "] " << fLimup[i] << endl;
+      }
+    //
+
+    // -------------------------------------------
+    // call MINUIT
+
+    Double_t arglist[10];
+    Int_t ierflg = 0;
+
+    for (Int_t i=0; i<fNumVar; i++)
+      gMinuit->mnparm(i, fVname[i], fVinit[i], fStep[i], fLimlo[i], fLimup[i], ierflg);
+
+    TStopwatch clock;
+    clock.Start();
+
+// Now ready for minimization step
+    arglist[0] = 500;
+    arglist[1] = 1.;
+    gMinuit->mnexcm(fMethod, arglist ,2,ierflg);
+
+    clock.Stop();
+
+    if(fMinuitPrintOutLevel>=0)
+      {
+	if (fMinuitPrintOutLevel>=0) *fLog << dbg << "Time spent for the minimization in MINUIT :   " << endl;;
+	clock.Print();
+      }
+
+    Double_t integratedCharge;
+    Double_t bkFit, bkFitError;
+    Double_t maxFit, maxFitError;
+    Double_t meanXFit, meanXFitError;
+    Double_t sigmaMinorAxis, sigmaMinorAxisError;
+    Double_t meanYFit, meanYFitError;
+    Double_t sigmaMajorAxis, sigmaMajorAxisError;
+    Double_t phiFit, phiFitError;
+    Float_t chisquare = GetChisquare();
+    Int_t   dregrees  = GetDegreesofFreedom()-fNumVar;
+
+    if (!ierflg)
+      {
+        gMinuit->GetParameter(0,bkFit, bkFitError);
+        gMinuit->GetParameter(1,maxFit, maxFitError);
+        gMinuit->GetParameter(2,meanXFit,meanXFitError);
+        gMinuit->GetParameter(3,sigmaMinorAxis,sigmaMinorAxisError);
+        gMinuit->GetParameter(4,meanYFit,meanYFitError);
+        gMinuit->GetParameter(5,sigmaMajorAxis,sigmaMajorAxisError);
+        gMinuit->GetParameter(6,phiFit,phiFitError);
+        
+        //FIXME: Do the integral properlly
+        integratedCharge = 0.;
+
+        
+      }
+    else
+      {
+        bkFit = 0.;
+        maxFit = 0.;
+        meanXFit = 0.;
+        sigmaMinorAxis = 0.;
+        meanYFit = 0.;
+        sigmaMajorAxis = 0.;
+        integratedCharge = 0.;
+        phiFit = 0.;
+
+	*fLog << err << "TMinuit::Call error " << ierflg << endl;
+      }
+    
+    star->SetFitValues(integratedCharge,bkFit,maxFit,meanXFit,meanYFit,sigmaMinorAxis,sigmaMajorAxis,phiFit,chisquare,dregrees);
+    
+    // reset the display to the starting values
+    fDisplay.SetUsed(origPixelsUsed);
+
+    if (ierflg)
+      return kCONTINUE;
+    return kTRUE;
+}
+
+Bool_t MFindStars::ShadowStar(MStarLocalPos* star)
+{
+    UInt_t numPixels = fGeomCam->GetNumPixels();
+
+// Define an area around the star which will be set unused.
+    UInt_t shadowPx=0;	
+    for (UInt_t pix=1; pix<numPixels; pix++)
+    {
+	Float_t pixXpos  = (*fGeomCam)[pix].GetX();
+	Float_t pixYpos  = (*fGeomCam)[pix].GetY();
+        Float_t starXpos = star->GetMeanX();
+        Float_t starYpos = star->GetMeanY();
+        
+	Float_t starSize = 3*star->GetSigmaMajorAxis();
+        
+	Float_t dist = sqrt((pixXpos-starXpos)*(pixXpos-starXpos)+
+			    (pixYpos-starYpos)*(pixYpos-starYpos));
+
+        if (dist > starSize && fDisplay.IsUsed(pix))
+	  fPixelsUsed[pix]=(Char_t)kTRUE;
+        else
+          {
+            fPixelsUsed[pix]=(Char_t)kFALSE;
+            shadowPx++;
+          }
+    }
+
+    if (fMinuitPrintOutLevel>=0) *fLog << dbg << " shadowPx " << shadowPx << endl;
+
+    fDisplay.SetUsed(fPixelsUsed);
+
+    return kTRUE;
+}
+
+Bool_t MFindStars::CorrSourcePos(TVector3* srcpos)
+{
+  const Int_t numstar = fStars->GetList()->GetSize();
+  if (numstar < 2)
+    {
+      cout <<" Less than 2 stars in list. Triangulation not possible."<<endl;
+      return kFALSE;
+    }
+  Float_t starmag[numstar];
+  Float_t starposx[numstar];
+  Float_t starposy[numstar];
+  Float_t starposcatx[numstar];
+  Float_t starposcaty[numstar];
+  Int_t i = 0;
+  Int_t matches = 0;
+  Int_t maxdist = 150;
+
+  TIter Next(fStars->GetList());
+  MStarLocalPos* star;
+  while ((star=(MStarLocalPos*)Next()))
+    {
+      starmag[i] = star->GetMagCalc();
+      starposx[i] = star->GetMeanX();
+      starposy[i] = star->GetMeanY();
+      i +=1;
+    }
+  for ( i = 0; i < numstar; i++)
+    {
+      starposcatx[i] = -1000;
+      starposcaty[i] = -1000;      
+      for( Int_t dist = 10; dist < maxdist; dist += 10)
+	{
+	  TIter Next1(fAstroCamera->GetCatList());
+	  TVector3 *starcat;
+	  while ((starcat=(TVector3*)Next1()) && dist < maxdist)
+	    {
+	      if ((starcat->X()-starposx[i])*(starcat->X()-starposx[i])+(starcat->Y()-starposy[i])*(starcat->Y()-starposy[i]) < dist*dist)
+		{
+		  starposcatx[i] = starcat->X();
+		  starposcaty[i] = starcat->Y();
+		  dist = maxdist;
+		  matches ++;
+		}
+	    }
+	}
+    }
+  // take the 2 'best' determined stars: Assumpion that the bright stars are better.
+  Float_t maxmag1 = 0, maxmag2 = 0;
+  Float_t minchi1 = 0, minchi2 = 0;
+  Int_t magi1 = -1, magi2 = -1;
+  Int_t chii1 = -1, chii2 = -1;
+  for ( i = 0; i < numstar; i++)
+    {
+      if (starposcatx[i] != -1000 && starposcaty[i] != -1000)
+	{
+	  if (starmag[i] > maxmag2)
+	    {
+	      maxmag2 = starmag[i];
+	      magi2 = i;
+	    }
+	  if (maxmag2 > maxmag1)
+	    {
+	      maxmag2 = maxmag1;
+	      maxmag1 = starmag[i];
+	      magi2 = magi1;
+	      magi1 = i;
+	    }
+	}
+    }  
+
+  if (matches < 2)
+    {
+      cout << " Could not find 2 stars in the camera matching with the stars in the catalog. Triangulation not possible."<<endl;
+      return kFALSE;
+    }
+
+  // Triangulation to get the correct source position:
+  TVector2 *source = new TVector2;      
+  TVector2 *star1 = new TVector2;      
+  TVector2 *star2 = new TVector2;      
+  TVector3 *dist = new TVector3;      
+  source->Set(0.,0.);    // Assume correct pointing.
+  star1->Set(starposcatx[magi1],starposcaty[magi1]);
+  star2->Set(starposcatx[magi2],starposcaty[magi2]);
+
+  DistBetweenStars(star1,star2,source,dist);
+
+  Float_t dx = starposx[magi1] - starposx[magi2];
+  Float_t delta = acos(dx/dist->Y()); 
+  Float_t alpha = acos((dist->Y()*dist->Y()+dist->Z()*dist->Z()-dist->X()*dist->X())/2/dist->Y()/dist->Y());
+  Float_t sigma = alpha - delta;
+
+  if (source->X()-starposx[magi1] > 0)
+    srcpos->SetX(starposx[magi1] + dist->Z()*abs(cos(sigma)));
+  else
+    srcpos->SetX(starposx[magi1] - dist->Z()*abs(cos(sigma)));
+  if (source->Y()-starposy[magi1] > 0)
+    srcpos->SetY(starposy[magi1] + dist->Z()*abs(sin(sigma)));
+  else
+    srcpos->SetY(starposy[magi1] - dist->Z()*abs(sin(sigma)));
+  return kTRUE;
+}
+
+
+Bool_t MFindStars::DistBetweenStars(TVector2 *star1, TVector2 *star2, TVector2 *source, TVector3 *dist)
+{
+  dist->SetX(sqrt(abs((source->X()-star2->X())*(source->X()-star2->X())+(source->Y()-star2->Y())*(source->Y()-star2->Y())))); 
+  dist->SetY(sqrt(abs((star1->X()-star2->X())*(star1->X()-star2->X())+(star1->Y()-star2->Y())*(star1->Y()-star2->Y())))); 
+  dist->SetZ(sqrt(abs((source->X()-star1->X())*(source->X()-star1->X())+(source->Y()-star1->Y())*(source->Y()-star1->Y())))); 
+  return kTRUE;
+
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/meth/MFindStars.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/meth/MFindStars.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/meth/MFindStars.h	(revision 9661)
@@ -0,0 +1,134 @@
+#ifndef MARS_MFindStars
+#define MARS_MFindStars
+
+#ifndef ROOT_TArrayS
+#include <TArrayS.h>
+#endif
+
+#ifndef ROOT_TArrayC
+#include <TArrayC.h>
+#endif
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+#ifndef MARS_MHCamera
+#include "MHCamera.h"
+#endif
+
+#ifndef MARS_MAstroCamera
+#include "MAstroCamera.h"
+#endif
+
+#ifndef MARS_MAstro
+#include "MAstro.h"
+#endif
+
+class MGeomCam;
+class MGeomPix;
+class MCameraDC;
+class MTime;
+class MReportDrive;
+class MStarLocalCam;
+class MStarLocalPos;
+
+class MFindStars : public MTask
+{
+
+private:
+
+    MGeomCam      *fGeomCam;
+    MCameraDC     *fCurr;
+    MTime         *fTimeCurr;
+    MReportDrive  *fDrive;
+    MStarLocalCam *fStars;
+
+    MAstroCamera  *fAstroCamera;
+    MAstro        fAstro;
+    TArrayC       fPixelsUsed;
+    MHCamera      fDisplay;
+
+    UInt_t fMaxNumIntegratedEvents;
+    UInt_t fNumIntegratedEvents;
+
+    Float_t fRingInterest; //[mm]
+    Float_t fMinDCForStars; //[uA]
+    Float_t fDCTailCut; //[uA]
+
+    // Source position:
+    Int_t fSrcRaHour;
+    Int_t fSrcRaMin;
+    Float_t fSrcRaSec;
+
+    Int_t fSrcDecDeg;
+    Int_t fSrcDecMin;
+    Float_t fSrcDecSec;
+
+    TVector3 *fRes;
+
+    //Fitting(Minuit) variables
+    const Int_t fNumVar;
+    Float_t fTempChisquare;
+    Int_t fTempDegreesofFreedom;
+    Int_t fMinuitPrintOutLevel;
+    
+    TString *fVname;
+    TArrayD fVinit; 
+    TArrayD fStep; 
+    TArrayD fLimlo; 
+    TArrayD fLimup; 
+    TArrayI fFix;
+    TObject *fObjectFit;
+    TString fMethod;
+    Bool_t fNulloutput;
+    
+    Bool_t DCPedestalCalc();
+    Bool_t FindPixelWithMaxDC(Float_t &maxDC, MGeomPix &maxPix);
+    Bool_t FindStar(MStarLocalPos* star);
+    Bool_t ShadowStar(MStarLocalPos* star);
+    Bool_t CorrSourcePos(TVector3* srcpos);
+    void DistBetweenStars(TVector2* star1, TVector2* star2, TVector2* source,TVector3* dist);
+
+  public:
+    
+    MFindStars(const char *name=NULL, const char *title=NULL);
+    
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
+    // setters
+    void SetNumIntegratedEvents(UInt_t max) {fMaxNumIntegratedEvents=max;}
+    void SetRingInterest(Float_t ring) {fRingInterest=ring;}
+    void SetBlindPixels(TArrayS blindpixels);
+    void SetMinuitPrintOutLevel(Int_t level) {fMinuitPrintOutLevel=level;}
+    void SetDCTailCut(Float_t cut) {fDCTailCut=cut;}
+
+    void SetChisquare(Float_t chi) {fTempChisquare=chi;}
+    void SetDegreesofFreedom(Int_t free) {fTempDegreesofFreedom=free;}
+
+    void SetSourceRaH(Int_t hour) {fSrcRaHour=hour;}
+    void SetSourceRaM(Int_t min) {fSrcRaMin=min;}
+    void SetSourceRaS(Float_t sec) {fSrcRaSec=sec;}
+
+    void SetSourceDecD(Int_t deg) {fSrcDecDeg=deg;}
+    void SetSourceDecM(Int_t min) {fSrcDecMin=min;}
+    void SetSourceDecS(Float_t sec) {fSrcDecSec=sec;}
+
+
+    //Getters
+    MHCamera& GetDisplay() { return fDisplay; }
+    
+    Float_t GetChisquare() {return fTempChisquare;}
+    Int_t GetDegreesofFreedom() {return fTempDegreesofFreedom;}
+    UInt_t GetNumIntegratedEvents() {return fMaxNumIntegratedEvents;}
+    Float_t GetRingInterest() {return fRingInterest;}
+    TList *GetCatalogList() { return fAstroCamera->GetCatList(); }
+    TVector3 *GetCorrSrcPos() {return fRes;}
+    
+    
+  ClassDef(MFindStars, 0) // Tool to find stars from DC Currents
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtemp/meth/MHillasSrc.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/meth/MHillasSrc.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/meth/MHillasSrc.cc	(revision 9661)
@@ -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    01/2001
+!   Author(s): Rudolf Bock         10/2001 <mailto:Rudolf.Bock@cern.ch>
+!   Author(s): Wolfgang Wittek     06/2002 <mailto:wittek@mppmu.mpg.de>
+!   Author(s): Sabrina Stark       05/2004 <mailto:stark@particle.phys.ethz.ch> 
+!   Author(s): Sebastian Commichau 05/2004 <mailto:commichau@particle.phys.ethz.ch>  
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHillasSrc
+//
+// Storage Container for image parameters
+//
+//    source-dependent image parameters
+//
+//
+// Version 1:
+// ----------
+//  fAlpha          angle between major axis and line source-to-center
+//  fDist           distance from source to center of ellipse
+//
+//
+// Version 2:
+// ----------
+//  fHeadTail       added
+//
+//
+// Version 3:
+// ----------
+//  fCosDeltaAlpha  cosine of angle between d and a, where
+//                   - d is the vector from the source position to the
+//                     center of the ellipse
+//                   - a is a vector along the main axis of the ellipse,
+//                     defined with positive x-component
+//
+//
+// Version 4:
+// ----------
+//
+// fHeadTail        removed
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MHillasSrc.h"
+
+#include <fstream>
+#include <TArrayF.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MGeomCam.h"
+#include "MSrcPosCam.h"
+
+ClassImp(MHillasSrc);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MHillasSrc::MHillasSrc(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MHillasSrc";
+    fTitle = title ? title : "Parameters depending in source position";
+}
+
+void MHillasSrc::Reset()
+{
+    fDist          = -1;
+    fAlpha         =  0;
+    fCosDeltaAlpha =  0;
+    fDCA           =  0;
+    fDDCA           = 0;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Calculation of source-dependent parameters
+//  In case you don't call Calc from within an eventloop make sure, that
+//  you call the Reset member function before.
+//
+Bool_t MHillasSrc::Calc(const MHillas *hillas)
+{
+    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]
+
+    //
+    // DCA: Distance of Closest Approach.
+    // Minimal distance from the shower axis to a reference point.
+
+    Double_t fDdca = hillas->GetDelta();
+    
+    // Distance between intersection point (DCA vector and the shower axis) and COG.
+    const Double_t fl = -(sx*TMath::Cos(fDdca) + sy*TMath::Sin(fDdca));
+
+    // Components of DCA vector
+    const Double_t fpd1 = TMath::Cos(fDdca)*fl+sx;
+    const Double_t fpd2 = TMath::Sin(fDdca)*fl+sy;
+
+    // Calculate DCA value 
+    Double_t fdca = sqrt(fpd1*fpd1 + fpd2*fpd2);
+
+    // Determine the correct sign of the DCA (cross product of DCA vector and the
+    // vector going from the intersection point of the DCA vector with the shower axis
+    // to the COG)
+    if ((sx-fpd1)*fpd2-(sy-fpd2)*fpd1<0.)
+      fdca = -fdca;
+
+    // Calculate angle of the shower axis with respect to the x-axis
+    fDdca = TMath::ACos((sx-fpd1)/TMath::Abs(fl));
+
+    // Enlarge the interval of fDdca to [0, 2pi]
+    if((sy-fpd2)<0)
+       fDdca = 360/kRad2Deg-fDdca;
+
+
+    //
+    // Distance from source position to center of ellipse.
+    // If the distance is 0 distance, Alpha is not specified.
+    // The calculation has failed and returnes kFALSE.
+    //
+    const Double_t dist = sqrt(sx*sx + sy*sy);  // [mm]
+    if (dist==0)
+        return kFALSE;
+
+    // Calculate Alpha and Cosda = cos(d,a)
+    // The sign of Cosda will be used for quantities containing 
+    // a head-tail information
+    //
+    // *OLD* const Double_t arg = (sy-tand*sx) / (dist*sqrt(tand*tand+1));
+    // *OLD* fAlpha = asin(arg)*kRad2Deg;
+    //
+    //    const Double_t arg1 = cd*sy-sd*sx;          // [mm]  ... equal abs(fdca)
+    //    const Double_t arg2 = cd*sx+sd*sy;          // [mm]  ... equal abs(fl)
+    const Double_t arg1 = TMath::Abs(fdca);          // [mm]  
+    const Double_t arg2 = TMath::Abs(fl);          // [mm] 
+
+    //
+    // Due to numerical uncertanties in the calculation of the
+    // square root (dist) and arg1 it can happen (in less than 1e-5 cases)
+    // that the absolute value of arg exceeds 1. Because this uncertainty
+    // results in an Delta Alpha which is still less than 1e-3 we don't care
+    // about this uncertainty in general and simply set values which exceed
+    // to 1 saving its sign.
+    //
+    const Double_t arg = arg1/dist;
+    fAlpha = TMath::Abs(arg)>1 ? TMath::Sign(90., arg) : asin(arg)*kRad2Deg;  // [deg]
+
+    fCosDeltaAlpha = arg2/dist;                 // [1]
+    fDist          = dist;                      // [mm]
+    fDCA = fdca;                                // [mm]
+    fDDCA = fDdca;                              // [rad]
+
+    SetReadyToSave();
+
+    return kTRUE;
+} 
+
+// --------------------------------------------------------------------------
+//
+// Print contents of MHillasSrc to *fLog
+//
+void MHillasSrc::Print(Option_t *) const
+{
+    *fLog << all;
+    *fLog << "Source dependant Image Parameters (" << GetName() << ")" << endl;
+    *fLog << " - Dist           [mm]  = " << fDist << endl;
+    *fLog << " - Alpha          [deg] = " << fAlpha << endl;
+    *fLog << " - CosDeltaAlpha        = " << fCosDeltaAlpha << endl;
+    *fLog << " - DCA            [mm]  = " << fDCA << endl;
+    *fLog << " - DeltaDCA       [mm]  = " << fDDCA << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Print contents of MHillasSrc to *fLog depending on the geometry in
+// units of deg.
+//
+void MHillasSrc::Print(const MGeomCam &geom) const
+{
+    *fLog << all;
+    *fLog << "Source dependant Image Parameters (" << GetName() << ")" << endl;
+    *fLog << " - Dist           [deg] = " << fDist*geom.GetConvMm2Deg() << endl;
+    *fLog << " - Alpha          [deg] = " << fAlpha << endl;
+    *fLog << " - CosDeltaAlpha        = " << fCosDeltaAlpha << endl;
+    *fLog << " - DCA            [deg] = " << fDCA*geom.GetConvMm2Deg() << endl;
+    *fLog << " - DeltaDCA       [mm]  = " << fDDCA << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// This function is ment for special usage, please never try to set
+// values via this function
+//
+void MHillasSrc::Set(const TArrayF &arr)
+{
+    if (arr.GetSize() != 5)
+        return;
+
+    fAlpha = arr.At(0);         // [deg]  angle of major axis with vector to src
+    fDist  = arr.At(1);         // [mm]   distance between src and center of ellipse
+    fCosDeltaAlpha = arr.At(2); // [1]    cosine of angle between d and a
+    fDCA   = arr.At(3);         // [mm]   distance between ref. point and shower axis
+    fDDCA   = arr.At(4);         // [rad] angle between shower axis and x-axis
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/meth/MHillasSrc.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/meth/MHillasSrc.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/meth/MHillasSrc.h	(revision 9661)
@@ -0,0 +1,45 @@
+#ifndef MARS_MHillasSrc
+#define MARS_MHillasSrc
+
+#ifndef MARS_MHillas
+#include "MHillas.h"
+#endif
+
+class MSrcPosCam;
+
+class MHillasSrc : public MParContainer
+{
+private:
+    const MSrcPosCam *fSrcPos; //! Source position in the camere
+
+    Float_t fAlpha;         // [deg]  angle of major axis with vector to src
+    Float_t fDist;          // [mm]   distance between src and center of ellipse
+    Float_t fDCA;          // [mm]   distance between ref. point and shower axis
+    Float_t fDDCA;          // [rad]  angle between major axis and x-axis [0, 2*pi]
+    Float_t fCosDeltaAlpha; // [1]    cosine of angle between d and a
+
+public:
+    MHillasSrc(const char *name=NULL, const char *title=NULL);
+
+    void SetSrcPos(const MSrcPosCam *pos) { fSrcPos = pos; }
+    const MSrcPosCam *GetSrcPos() const   { return fSrcPos; }
+
+    void Reset();
+
+    Float_t GetAlpha()         const { return fAlpha; }
+    Float_t GetDist()          const { return fDist; }
+    Float_t GetDCA()          const { return fDCA; }
+    Float_t GetDDCA()          const { return fDDCA; }
+    Float_t GetCosDeltaAlpha() const { return fCosDeltaAlpha; }
+
+    void Print(Option_t *opt=NULL) const;
+    void Print(const MGeomCam &geom) const;
+
+    virtual Bool_t Calc(const MHillas *hillas);
+
+    void Set(const TArrayF &arr);
+
+    ClassDef(MHillasSrc, 5) // Container to hold source position dependant parameters
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtemp/meth/MStarLocalPos.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/meth/MStarLocalPos.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/meth/MStarLocalPos.cc	(revision 9661)
@@ -0,0 +1,196 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Javier López , 4/2004 <mailto:jlopez@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+#include "MStarLocalPos.h"
+
+#include <TEllipse.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MStarLocalPos);
+
+using namespace std;
+
+MStarLocalPos::MStarLocalPos(const char *name, const char *title)
+{
+
+    fName  = name  ? name  : "MStarLocalPos";
+    fTitle = title ? title : "";
+    
+    Reset();
+}
+
+void MStarLocalPos::Reset()
+{
+
+    //Expected position on camera
+     fMagExp = 0.;
+     fXExp = 0.;
+     fYExp = 0.;
+
+    //Info from calculation
+
+     fMagCalc = 0.;
+     fMaxCalc = 0.;
+     fMeanXCalc = 0.;
+     fMeanYCalc = 0.;
+     fSigmaMinorAxisCalc = 0.;
+     fSigmaMajorAxisCalc = 0.;
+
+    //Info from fit
+
+     fMagFit = 0.;
+     fBkFit = 0.;
+     fMaxFit = 0.;
+     fMeanXFit = 0.;
+     fMeanYFit = 0.;
+     fSigmaMinorAxisFit = 0.;
+     fSigmaMajorAxisFit = 0.;
+     fPhiFit = 0.;
+     fChiSquare = 0.;
+     fNdof = 1;
+
+}
+
+void MStarLocalPos::SetExpValues(Float_t mag, Float_t x, Float_t y)
+{
+     fMagExp = mag;
+     fXExp = x;
+     fYExp = y;
+}
+
+void MStarLocalPos::SetCalcValues(Float_t mag, Float_t max, Float_t x, Float_t y, Float_t sigmaMinorAxis, Float_t sigmaMajorAxis)
+{
+     fMagCalc = mag;
+     fMaxCalc = max;
+     fMeanXCalc = x;
+     fMeanYCalc = y;
+     fSigmaMinorAxisCalc = sigmaMinorAxis;
+     fSigmaMajorAxisCalc = sigmaMajorAxis;
+}
+
+void MStarLocalPos::SetFitValues(Float_t mag, Float_t max, Float_t x, Float_t y, Float_t sigmaMinorAxis, Float_t sigmaMajorAxis, Float_t chiSquare, Int_t ndof)
+{
+     fMagFit = mag;
+     fMaxFit = max;
+     fMeanXFit = x;
+     fMeanYFit = y;
+     fSigmaMinorAxisFit = sigmaMinorAxis;
+     fSigmaMajorAxisFit = sigmaMajorAxis;
+     fChiSquare = chiSquare;
+     fNdof = ndof;
+}
+
+void MStarLocalPos::SetFitValues(Float_t mag, Float_t bk, Float_t max, Float_t x, Float_t y, Float_t sigmaMinorAxis, Float_t sigmaMajorAxis, Float_t phi, Float_t chiSquare, Int_t ndof)
+{
+     fMagFit = mag;
+     fBkFit = bk;
+     fMaxFit = max;
+     fMeanXFit = x;
+     fMeanYFit = y;
+     fSigmaMinorAxisFit = sigmaMinorAxis;
+     fSigmaMajorAxisFit = sigmaMajorAxis;
+     fPhiFit = phi;
+     fChiSquare = chiSquare;
+     fNdof = ndof;
+}
+
+// --------------------------------------------------------------------------
+//
+// Paint the ellipse corresponding to the parameters
+//
+void MStarLocalPos::Paint(Option_t *opt)
+{
+  //Print a cross in the expected position
+
+  if (fSigmaMinorAxisCalc>0. && fSigmaMajorAxisCalc>0.)
+    {
+      TEllipse ecalc(fMeanXCalc, fMeanYCalc, fSigmaMinorAxisCalc, fSigmaMajorAxisCalc, 0, 360, 0);
+      ecalc.SetLineWidth(2);
+      ecalc.SetLineColor(kRed);
+      ecalc.Paint();
+    }
+
+  if (fSigmaMinorAxisFit>0. || fSigmaMajorAxisFit>0.)
+    {
+      TEllipse efit(fMeanXFit, fMeanYFit, fSigmaMinorAxisFit, fSigmaMajorAxisFit, 0, 360, fPhiFit);
+      efit.SetLineWidth(2);
+      efit.SetLineColor(kBlack);
+      efit.Paint();
+    }
+}
+  
+void MStarLocalPos::Print(Option_t *opt) const
+{
+  TString o = opt;
+  
+  if (o.Contains("mag", TString::kIgnoreCase) || opt == NULL)
+    {
+      *fLog << inf << "Star maginitude:" << endl;
+      *fLog << inf << " Expected \t" << setw(4) << fMagExp << endl;
+      *fLog << inf << " Calcultated \t " << setw(4) << fMagCalc << endl;
+      *fLog << inf << " Fitted \t " << setw(4) << fMagFit << endl;
+    }
+  
+  if (o.Contains("bk", TString::kIgnoreCase) || opt == NULL)
+    {
+      *fLog << inf << "Background:" << endl;
+      *fLog << inf << " Fitted \t " << setw(4) << fBkFit << " uA" << endl;
+    }
+
+  if (o.Contains("max", TString::kIgnoreCase) || opt == NULL)
+    {
+      *fLog << inf << "Star Maximum:" << endl;
+      *fLog << inf << " Calcultated \t " << setw(4) << fMaxCalc << " uA" << endl;
+      *fLog << inf << " Fitted \t " << setw(4) << fMaxFit << " uA" << endl;
+    }
+  
+  if (o.Contains("pos", TString::kIgnoreCase) || opt == NULL)
+    {
+      *fLog << inf << "Star position:" << endl;
+      *fLog << inf << " Expected \t X " << setw(4) << fXExp << " mm \tY " << setw(4) << fYExp << " mm" << endl;
+      *fLog << inf << " Calcultated \t X " << setw(4) << fMeanXCalc << " mm \tY " << setw(4) << fMeanYCalc << " mm" << endl;
+      *fLog << inf << " Fitted \t X " << setw(4) << fMeanXFit << " mm \tY " << setw(4) << fMeanYFit << " mm" << endl;
+    }
+
+  if (o.Contains("rot", TString::kIgnoreCase) || opt == NULL)
+    {
+      *fLog << inf << "Rotation of ellipse:" << endl;
+      *fLog << inf << " Fitted \t  " << setw(4) << fPhiFit << " rad " << endl;
+    }
+
+  if (o.Contains("siz", TString::kIgnoreCase) || opt == NULL)
+    {
+      *fLog << inf << "Star size:" << endl;
+      *fLog << inf << " Calcultated \t X " << setw(4) << fSigmaMinorAxisCalc << " mm \tY " << setw(4) << fSigmaMajorAxisCalc << " mm" << endl;
+      *fLog << inf << " Fitted \t X " << setw(4) << fSigmaMinorAxisFit << " mm \tY " << setw(4) << fSigmaMajorAxisFit << " mm" << endl;
+    }
+
+  if (o.Contains("chi", TString::kIgnoreCase) || opt == NULL)
+    {
+      *fLog << inf << "Star Fit Quality:" << endl;
+      *fLog << inf << " ChiSquare/Ndof \t " << setw(3) << fChiSquare << "/" << fNdof << endl;
+    }
+}
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/meth/MStarLocalPos.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/meth/MStarLocalPos.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/meth/MStarLocalPos.h	(revision 9661)
@@ -0,0 +1,86 @@
+#ifndef MARS_MStarLocalPos
+#define MARS_MStarLocalPos
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MStarLocalPos : public MParContainer
+{
+private:
+
+    //Expected position on camera
+    
+    Float_t fMagExp;
+    Float_t fXExp;    //[mm]
+    Float_t fYExp;    //[mm]
+
+    //Info from calculation
+
+    Float_t fMagCalc;
+    Float_t fMaxCalc;            //[uA]
+    Float_t fMeanXCalc;          //[mm]
+    Float_t fMeanYCalc;          //[mm]
+    Float_t fSigmaMinorAxisCalc; //[mm]
+    Float_t fSigmaMajorAxisCalc; //[mm]
+
+    //Info from fit
+
+    Float_t fMagFit;
+    Float_t fBkFit;             //[uA]
+    Float_t fMaxFit;             //[uA]
+    Float_t fMeanXFit;           //[mm]
+    Float_t fMeanYFit;           //[mm]
+    Float_t fSigmaMinorAxisFit;  //[mm]
+    Float_t fSigmaMajorAxisFit;  //[mm]
+    Float_t fPhiFit;             //[rad]
+    Float_t fChiSquare;
+    Int_t   fNdof;
+
+public:
+
+    MStarLocalPos(const char *name=NULL, const char *title=NULL);
+    //~MStarLocalPos();
+
+    Float_t GetMagExp() {return fMagExp;}
+    Float_t GetXExp() {return fXExp;}
+    Float_t GetYExp() {return fYExp;}
+
+    Float_t GetMagCalc() {return fMagCalc;}
+    Float_t GetMaxCalc() {return fMaxCalc;}
+    Float_t GetMeanXCalc() {return fMeanXCalc;}
+    Float_t GetMeanYCalc() {return fMeanYCalc;}
+    Float_t GetSigmaMinorAxisCalc() {return fSigmaMinorAxisCalc;}
+    Float_t GetSigmaMajorAxisCalc() {return fSigmaMajorAxisCalc;}
+
+    Float_t GetMagFit() {return fMagFit;}
+    Float_t GetBkFit() {return fBkFit;}
+    Float_t GetMaxFit() {return fMaxFit;}
+    Float_t GetMeanXFit() {return fMeanXFit;}
+    Float_t GetMeanYFit() {return fMeanYFit;}
+    Float_t GetSigmaMinorAxisFit() {return fSigmaMinorAxisFit;}
+    Float_t GetSigmaMajorAxisFit() {return fSigmaMajorAxisFit;}
+    Float_t GetPhiFit() {return fPhiFit;}
+    Float_t GetChiSquare() {return fChiSquare;}
+    UInt_t GetNdof() {return fNdof;}
+    Float_t GetChiSquareNdof() {return fChiSquare/fNdof;}
+
+    Float_t GetMeanX() {return fMeanXFit!=0?fMeanXFit:fMeanXCalc;}
+    Float_t GetMeanY() {return fMeanXFit!=0?fMeanYFit:fMeanYCalc;}
+    Float_t GetSigmaMinorAxis() {return fSigmaMinorAxisFit!=0?fSigmaMinorAxisFit:fSigmaMinorAxisCalc;}
+    Float_t GetSigmaMajorAxis() {return fSigmaMajorAxisFit!=0?fSigmaMajorAxisFit:fSigmaMajorAxisCalc;}
+
+    void Reset();
+
+    void SetExpValues(Float_t mag, Float_t x, Float_t y);
+    void SetCalcValues(Float_t mag, Float_t max, Float_t x, Float_t y, Float_t sigmaMinorAxis, Float_t sigmaMajorAxis);
+    void SetFitValues(Float_t mag, Float_t max, Float_t x, Float_t y, Float_t sigmaMinorAxis, Float_t sigmaMajorAxis, Float_t chi, Int_t ndof);
+    void SetFitValues(Float_t mag, Float_t bk, Float_t max, Float_t x, Float_t y, Float_t sigmaMinorAxis, Float_t sigmaMajorAxis, Float_t phi, Float_t chi, Int_t ndof);
+
+    void Paint(Option_t *opt=NULL);
+    void Print(Option_t *opt=NULL) const;
+
+    ClassDef(MStarLocalPos, 1) // Container that holds the star information in the PMT camera
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtemp/meth/macros/CorrectSrcPos.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/meth/macros/CorrectSrcPos.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/meth/macros/CorrectSrcPos.C	(revision 9661)
@@ -0,0 +1,359 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Luisa Sabrina Stark Schneebeli, 07/2004 <stark@particle.phys.ethz.ch>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!   This macro is partially derived from findstars.C
+\* ======================================================================== */
+
+
+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 CorrectSrcPos(const TString filename="dc_2004_04_21_22_*_Mrk421.root", const TString directory="/scratch/Period016/cacodata/2004_04_22/", const UInt_t numEvents = 0)
+{
+
+  //
+  // 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);
+
+
+  MGeomCamMagic geomcam;
+  MCameraDC     dccam;
+  MStarLocalCam starcam;
+
+  plist.AddToList(&geomcam);
+  plist.AddToList(&dccam);
+  plist.AddToList(&starcam);
+
+  //
+  // Now setup the tasks and tasklist:
+  // ---------------------------------
+  //
+
+  // Reads the trees of the root file and the analysed branches
+  MReadReports read;
+  read.AddTree("Currents"); 
+  read.AddFile(directory+filename);     // after the reading of the trees!!!
+  read.AddToBranchList("MReportCurrents.*");
+
+  MGeomApply geomapl;
+  TString continuoslightfile = 
+    "/scratch/Period016/cacodata/2004_04_16/dc_2004_04_16_04_46_18_22368_Off3c279-2CL100.root";
+  MCalibrateDC dccal;
+  dccal.SetFileName(continuoslightfile);
+  
+
+  const Int_t numblind = 12;
+  const Short_t x[numblind] = {  8,  27,
+                               507, 508, 509, 510, 511,
+                               543, 559, 560, 561, 567};
+  const TArrayS blindpixels(numblind,(Short_t*)x);
+  Float_t ringinterest = 100; //[mm]
+  Float_t tailcut = 3.5;
+  UInt_t integratedevents = 5;
+
+  MFindStars findstars;
+  //  findstars.SetBlindPixels(blindpixels);
+  findstars.SetRingInterest(ringinterest);
+  findstars.SetDCTailCut(tailcut);
+  findstars.SetNumIntegratedEvents(integratedevents);
+  findstars.SetMinuitPrintOutLevel(0);
+
+  findstars.SetSourceRaH(11);   //  Mrk421
+  findstars.SetSourceRaM(4);
+  findstars.SetSourceRaS(26.0);
+  findstars.SetSourceDecD(38);
+  findstars.SetSourceDecM(12);
+  findstars.SetSourceDecS(36.0);
+
+
+  // prints
+  MPrint pdc("MCameraDC");
+  MPrint pstar("MStarLocalCam");
+  
+  tlist.AddToList(&geomapl);
+  tlist.AddToList(&read);
+  tlist.AddToList(&dccal);
+  //  tlist.AddToList(&pdc, "Currents");
+  tlist.AddToList(&findstars, "Currents");
+  //  tlist.AddToList(&pstar, "Currents");
+
+  //
+  // Create and setup the eventloop
+  //
+  MEvtLoop evtloop;
+  evtloop.SetParList(&plist);
+     
+  const Int_t numpar = 3;
+  Float_t starpos[10*numpar];       
+  Float_t starposcat[10*numpar];       
+  
+  if (numEvents > 0)
+  {
+      if (!evtloop.Eventloop(numEvents))
+	  return;
+  }
+  else
+  {
+      if (!evtloop.PreProcess())
+	  return;
+      
+       MHCamera display(geomcam);
+       display.SetPrettyPalette();
+       
+       TCanvas *c = new TCanvas("c", "FindStars", 100, 100,600,600); 
+       
+       TH2D *h0 = new TH2D("h0","",1,-2,2,1,-2,2);
+       h0->GetXaxis()->SetTitle("(deg)");
+       h0->GetYaxis()->SetTitle("(deg)");
+       h0->Draw();
+       
+       display.Draw();
+       gPad->cd(1);
+       //display.Draw("same");
+       starcam.Draw();
+
+       UShort_t year;
+       Byte_t month, day;
+
+       MTime *evttime = (MTime*)plist->FindObject("MTimeCurrents");
+
+       TList *starcatalog = new TList;
+       TList *stardc = new TList;
+       TVector3 *res = new TVector3;
+
+       Int_t maxdist = 100;
+       UInt_t numevents=0;
+       Int_t numEvt=0;
+       const Int_t maxnumEvt = 10000;
+       Int_t col = 2;
+       const Double_t kDeg2mm = 189/0.6;
+
+       Double_t resx[maxnumEvt];
+       Double_t resy[maxnumEvt];
+       Double_t time[maxnumEvt];
+
+       
+//
+// Find in the file name the date, run and project name 
+
+       Size_t pos = filename.Last('/');
+       TString iRun = TString(filename(pos+24,5));
+       TString iYear = TString(filename(pos+4,4));
+       TString iMonth = TString(filename(pos+9,2));
+       TString iDay = TString(filename(pos+12,2));
+       
+       TString iHour = TString(filename(pos+15,2));
+       TString iMin = TString(filename(pos+18,2));
+       TString iSec = TString(filename(pos+21,2));
+       
+       Size_t poslast = filename.Last('.');
+       Size_t posfirst = poslast-1;
+       while (filename[posfirst] != '_')
+	 posfirst--;
+       
+       TString iSource = TString(filename(posfirst+1,poslast-posfirst-1));
+       char str[100];
+       char str2[100];
+       sprintf(str,"Date %s %s %s  Run %s   Source %s",iYear.Data(),iMonth.Data(),iDay.Data(),iRun.Data(),iSource.Data());
+       sprintf(str2,"CorrectSrcPos_%s%s%s_%s_%s.txt",iYear.Data(),iMonth.Data(),iDay.Data(),iRun.Data(),iSource.Data());
+       
+       UInt_t evtyear, evtmonth, evtday, evthour, evtmin, evtsec;
+       UShort_t evtmsec;
+
+       ofstream fposout1;
+       //       fposout1.open (str2, ofstream::app);
+       fposout1.open (str2, ofstream::trunc);
+
+       while (tlist.Process())
+         {
+           if (numevents >= integratedevents)
+             {
+	       evttime->GetTime(evthour, evtmin, evtsec,evtmsec);
+	       evttime->Print();
+	       evthour = evttime->Hour();
+	       evtmin = evttime->Min();
+	       evtsec = evttime->Sec();
+
+               //               display.SetCamContent(dccam);
+               display.SetCamContent(findstars.GetDisplay());
+	       gPad->Modified();
+	       gPad->Update();
+	       Int_t numStars = starcam.GetNumStars();
+	       starcam.Print("bkmaxposrotsizechi");
+
+	       res = findstars.GetCorrSrcPos();
+	       cout<<"Corrected source position = "<<res->X()<<" , "<<res->Y()<<endl;
+	       resx[numEvt] = res->X();
+	       resy[numEvt] = res->Y();
+	       time[numEvt] = numEvt;
+	       numEvt ++;
+
+	       // write the corrected source position and the star positions to file
+	       if (!fposout1)
+		 cout << "Could not open output file to write the center of the fit." << endl;
+	       else{
+		 for ( Int_t i = 0; i < numStars; i++)
+		   {
+		     if (i == 0){
+		       fposout1 << str<<" "<<evthour<< " "<<evtmin<<" "<<evtsec<<" "<<evtmsec;
+		       fposout1 <<" "<< res->X()<< " " << res->Y();
+		     }
+		     fposout1 <<" "<< starcam[i].GetMeanX()<< " " << starcam[i].GetMeanY();
+		   }
+		 }
+	       fposout1 << endl;
+	       numevents = 0;
+
+               // Remove the comments if you want to go through the file
+               // event-by-event:
+	       //if (!HandleInput())
+	       // break;
+             }
+           numevents++;
+	 } 
+       fposout1.close();
+
+       // Print source position
+       gROOT->Reset();
+       gStyle->SetCanvasColor(0);
+       gStyle->SetCanvasBorderMode(0);
+       gStyle->SetPadBorderMode(0);
+       gStyle->SetFrameBorderMode(0);
+       gStyle->SetOptStat(00000000);
+
+       TCanvas *c1 = new TCanvas("c1", "SourcePosition", 200, 200,600,1200); 
+       c1->Divide(1,3);
+
+       TMath math;
+    
+       Double_t minresx, maxresx;
+       minresx = resx[math.LocMin(numEvt,resx)];
+       maxresx = resx[math.LocMax(numEvt,resx)];
+       
+       Double_t minresy, maxresy;
+       minresy = resy[math.LocMin(numEvt,resy)];
+       maxresy = resy[math.LocMax(numEvt,resy)];
+       
+       Double_t minres, maxres;
+       minres = math.Min(minresx,minresy);
+       maxres = math.Max(maxresx,maxresy);
+
+       Double_t diff;
+       diff = maxres - minres;
+       diff = 0.1*diff;
+       minres = minres - diff;
+       maxres = maxres + diff;
+
+       Double_t mintime, maxtime;
+       mintime = time[math.LocMin(numEvt,time)];
+       maxtime = time[math.LocMax(numEvt,time)];
+
+       c1->cd(1);
+       TH2D *h1 = new TH2D("h1","",1,mintime-1,maxtime+1,1,minres,maxres);
+       h1->GetXaxis()->SetTitle("(evt.nr)");
+       h1->GetYaxis()->SetTitle("(mm)");
+       h1->Draw();
+
+       TGraph *grtimeevolx = new TGraph(numEvt,time,resx);
+       grtimeevolx->SetMarkerColor(215);
+       grtimeevolx->SetMarkerStyle(20);
+       grtimeevolx->SetMarkerSize (0.4);
+       grtimeevolx->Draw("P");
+       
+       TGraph *grtimeevoly = new TGraph(numEvt,time,resy);
+       grtimeevoly->SetMarkerColor(6);
+       grtimeevoly->SetMarkerStyle(24);
+       grtimeevoly->SetMarkerSize (0.4);
+       grtimeevoly->Draw("P");
+       
+       legxy = new TLegend(0.8,0.85,0.95,0.95);
+       legxy.SetTextSize(0.03);
+       legxy.AddEntry(grtimeevolx,"src pos x","P");
+       legxy.AddEntry(grtimeevoly,"src pos y","P");
+       legxy.Draw();
+
+       c1->cd(2);
+       TH2D *h2 = new TH2D("h2","",1,mintime-1,maxtime+1,1,minresx,maxresx);
+       h2->GetXaxis()->SetTitle("(evt.nr)");
+       h2->GetYaxis()->SetTitle("(mm)");
+       h2->Draw();
+
+       TGraph *grtimeevolx = new TGraph(numEvt,time,resx);
+       grtimeevolx->SetMarkerColor(215);
+       grtimeevolx->SetMarkerStyle(20);
+       grtimeevolx->SetMarkerSize (0.4);
+       grtimeevolx->Draw("P");
+       
+       legxy = new TLegend(0.8,0.85,0.95,0.95);
+       legxy.SetTextSize(0.03);
+       legxy.AddEntry(grtimeevolx,"src pos x","P");
+       legxy.Draw();
+
+       c1->cd(3);
+       TH2D *h3 = new TH2D("h3","",1,mintime-1,maxtime+1,1,minresy,maxresy);
+       h3->GetXaxis()->SetTitle("(evt.nr)");
+       h3->GetYaxis()->SetTitle("(mm)");
+       h3->Draw();
+
+       TGraph *grtimeevoly = new TGraph(numEvt,time,resy);
+       grtimeevoly->SetMarkerColor(6);
+       grtimeevoly->SetMarkerStyle(24);
+       grtimeevoly->SetMarkerSize (0.4);
+       grtimeevoly->Draw("P");
+       
+       legxy = new TLegend(0.8,0.85,0.95,0.95);
+       legxy.SetTextSize(0.03);
+       legxy.AddEntry(grtimeevoly,"src pos y","P");
+       legxy.Draw();
+
+       evtloop.PostProcess();
+  }
+
+  tlist.PrintStatistics();
+
+}
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/meth/macros/analysis.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/meth/macros/analysis.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/meth/macros/analysis.C	(revision 9661)
@@ -0,0 +1,529 @@
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// analysis.C                                                              //
+//                                                                         //
+// Author(s): S.C. Commichau, 6/2004                                       //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+
+// This macro calculates source independent and dependent image parameter 
+// distributions from data and writes them into a file called hillas.root. 
+// To look at the distributions use the macro analysis_read.C
+// Up to now no derotation and mispointing correction is taken into account!
+
+const TString inpathcal = "/ihp/MAGIC/Period016/rootdata2/2004_04_22/";
+//const TString inpath = "/ihp/MAGIC/Period016/rootdata2/2004_04_23/";
+const TString inpath = "/ihp/MAGIC/Period016/rootdata2/2004_04_23/";
+
+
+const TString dname = "/ihp/MAGIC/Period016/rootdata2/2004_04_23/20040423_2375*_D_OffMrk421-6_E.root";
+
+//const TString dname = "/ihp/MAGIC/Period016/rootdata2/2004_04_23/20040423_2343*_D_Mrk421_E.root";
+
+
+const Int_t  pedrun  = 23745;//23427;  // Pedestal file
+const Int_t  calrun1 = 23205;  // Calibration files
+const Int_t  calrun2 = 0;
+const Int_t  datrun1 = 23429;  // Data files
+
+const Bool_t usedisplay = kFALSE;
+
+// Range of slices that are taken into account
+const Byte_t hifirst = 1;
+const Byte_t hilast  = 14;
+const Byte_t lofirst = 3;
+const Byte_t lolast  = 14;
+
+
+void analysis()                             
+{
+
+    /*******************************************
+     * Define some parameters for the analysis *
+     *******************************************/
+        
+    // Change the following line toggle pedestal display 
+    Bool_t DrawPedestals = kFALSE;//kTRUE; 
+    
+    // Set calibration mode
+    // kDefault, kNone, kDummy, kFfactor, kPinDiode,...
+    MCalibrate::CalibrationMode_t CalMode=MCalibrate::kDefault;
+
+    // Cleaning: Core and Tailcut
+    TArrayF clvl(2);
+    clvl[0] = 3.5;
+    clvl[1] = 3.0;	
+
+    // Set bad pixels
+    const Short_t x[16] = {330,395,329,396,389,
+			   323,388,322,384,385,
+			   386,387,321,320,319,
+			   394};
+
+    // Set output filename
+    TString oname = "hillas.root";
+   
+    
+    /***************************************
+     * Define general tasks and containers *
+     ***************************************/
+
+    MCalibrationQECam         qecam;
+    MBadPixelsCam             badcam;
+    MGeomCamMagic             geomcam;
+    MGeomApply                geomapl;
+    MExtractFixedWindow       extractor; 
+    extractor.SetRange(hifirst, hilast, lofirst, lolast);
+    //MExtractFixedWindowPeakSearch extractor;
+    //extractor.SetWindows(8,8);
+    //MExtractSlidingWindow         extractor;
+
+
+    // Iterate over runs
+    MRunIter pruns;
+    MRunIter cruns;
+    MRunIter druns;
+  
+    MReadMarsFile   dread("Events", dname);
+    dread.DisableAutoScheme();
+
+    // Pedestal runs
+    pruns.AddRun(pedrun,inpath);
+    
+    // Calibration runs
+    if (calrun2==0)
+        cruns.AddRun(calrun1,inpathcal);
+    else
+        cruns.AddRuns(calrun1,calrun2,inpath);
+
+    // Data 
+/*    if (1)//datrun2==0)
+	druns.AddRun(datrun1,inpath);
+    else
+	druns.AddRuns(datrun1,datrun2,inpath);//,datrun3,datrun4,datrun5,datrun6,inpath);
+*/
+
+    // Look for the pulser colors 
+    MCalibrationCam::PulserColor_t color;
+ 
+    if (calrun1 < 20000)
+	color = MCalibrationCam::kCT1;
+    else
+	color = FindColor((MDirIter*)&cruns);
+    
+    if (color==MCalibrationCam::kNONE)
+    {
+	TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
+	
+	while (1)
+	{
+	    timer.TurnOn();
+	    TString input = Getline("Couldn't find the pulser colour, type 'q' to exit, "
+				    "'green', 'blue', 'uv' or 'ct1' to go on: ");
+	    timer.TurnOff();
+	    
+	    if (input=="q\n")
+		return;
+	    
+	    if (input=="green\n")
+	    {
+		color = MCalibrationCam::kGREEN;
+		break;
+	    }
+	    if (input=="blue\n")
+	    {
+		color = MCalibrationCam::kBLUE;
+		break;
+	    }
+	    if (input=="uv\n" || input=="UV\n")
+	    {
+		color = MCalibrationCam::kUV;
+		break;
+	    }
+	    if (input=="ct1\n" || input=="CT1\n")
+	    {
+		color = MCalibrationCam::kCT1;
+		break;
+	    }
+	}
+    }
+    
+ 
+    /**********************************
+     * 1st Loop: Pedestal Computation *
+     **********************************/
+    
+    // If pixels have to be excluded from the beginning, read 
+    // an ASCII-file with the corresponding pixel numbers (MBadPixelsCam)
+    badcam.AsciiRead("badpixels.txt");
+    
+    MJPedestal                pedloop;
+    pedloop.SetInput(&pruns);   
+    pedloop.SetExtractor(&extractor);
+    pedloop.SetBadPixels(badcam);
+    
+    if (!pedloop.Process())
+	return;
+        
+    // Print the content of MPedestalCam
+    MPedestalCam *pedcam = (MPedestalCam*)pedloop.GetPedestalCam();
+    pedcam->Print(); 
+    
+    // Draw Pedestals and RMS into a camera - ADC counts
+    if (DrawPedestals)
+    {
+	MHCamera *disp0 = new MHCamera(geomcam, "Pedestals", "");
+	MHCamera *disp1 = new MHCamera(geomcam, "PedestalRMS", "");
+	
+	disp0->SetMinimum(0);
+	disp1->SetMinimum(0);
+	
+	TCanvas *c1 = new TCanvas("Pedestals", "Pedestals", 50, 50, 400, 400);
+	TCanvas *c2 = new TCanvas("RMS", "RMS", 460, 50, 400, 400);
+	
+	c1->SetBorderMode(0);
+	c1->SetFillColor(0);
+	
+	c2->SetBorderMode(0);
+	c2->SetFillColor(0);
+	
+	gStyle->SetOptStat(1101);
+	gStyle->SetStatColor(0);
+	gStyle->SetStatBorderSize(1);
+	
+	gPad->SetBorderMode(0);
+	
+	disp0.SetPrettyPalette();
+	disp1.SetPrettyPalette();
+	
+	c1->cd();
+	disp0.Draw();
+	
+	gPad->cd(1);
+	
+	disp0.SetCamContent(*pedcam,0);
+	disp0.SetCamError(*pedcam,1);
+	
+	c2->cd();
+	disp1.Draw();
+	
+	disp1.SetCamContent(*pedcam,2);
+	disp1.SetCamError(*pedcam,3);
+    }
+    
+   
+    /*************************
+     * 2nd Loop: Calibration *
+     *************************/
+
+    MJCalibration     calloop;
+    //calloop.SetColor(color);
+    calloop.SetInput(&cruns);
+    calloop.SetExtractor(&extractor);
+    //calloop.SetQECam(qecam);
+    calloop.SetBadPixels(pedloop.GetBadPixels());
+    
+    // Choose the arrival time Extractor:
+    //MExtractTimeHighestIntegral timeext;
+    //MExtractTimeSpline timeext;
+    // Set Ranges or Windows
+    //timeext.SetRange(0,14,6,14);
+    //calloop.SetTimeExtractor(&timeext);
+    
+    // To calibrate times enable the following line
+    //Bool_t UseTimes = kFALSE;
+    // Bool_t calibrateTimes = kFALSE;
+    //calloop.SetRelTimeCalibration(UseTimes);
+    
+    if (!calloop.Process(pedloop.GetPedestalCam()))
+    return;
+    
+    /**********************************
+     * 3rd Loop: Pedestal Calibration *
+     **********************************/
+
+    // Create a Parameter and a Task List
+    MParList                  plist3;
+    MTaskList                 tlist3;
+    plist3.AddToList(&tlist3);
+
+    // Parameter Containers
+    MCerPhotEvt               evtphot;
+    MPedPhotCam               pedphot;
+    MExtractedSignalCam       sigcam;
+    
+    // Add also some containers from previous loops
+    plist3.AddToList(&geomcam);
+    plist3.AddToList(&pedloop.GetPedestalCam());
+
+    plist3.AddToList(&calloop.GetCalibrationCam());
+    plist3.AddToList(&calloop.GetQECam());          // I have to check this! 
+    //plist3.AddToList(&calloop.GetRelTimeCam());
+    //plist3.AddToList(&calloop.GetBadPixels());
+    plist3.AddToList(&badcam);
+    plist3.AddToList(&sigcam);
+    plist3.AddToList(&evtphot);
+    plist3.AddToList(&pedphot);
+
+    
+    // Tasks
+    MReadMarsFile read3("Events");
+    static_cast<MRead&>(read3).AddFiles(pruns);  
+    read3.DisableAutoScheme();
+    
+    //MExtractSignal            extsig;
+    //extsig.SetRange(hifirst, hilast, lofirst, lolast);
+    MCalibrate                calphot;
+    calphot.SetCalibrationMode(CalMode);
+    MPedPhotCalc              pedphotcalc;  
+    
+    tlist3.AddToList(&read3);
+    tlist3.AddToList(&geomapl);
+    tlist3.AddToList(&extractor);
+    //tlist3.AddToList(&extsig);
+    tlist3.AddToList(&calphot);
+    tlist3.AddToList(&pedphotcalc);
+  
+    
+    // Create and setup the eventloop
+    MProgressBar              bar3;
+    bar3.SetWindowName("Calibrating Pedestals...");
+    
+    MEvtLoop                  evtloop3;
+    evtloop3.SetProgressBar(&bar3);
+    evtloop3.SetParList(&plist3);
+    
+    if (!evtloop3.Eventloop())
+	return;
+    
+    tlist3.PrintStatistics();
+
+
+    /****************************
+     * 4th Loop: Photonize Data *
+     ****************************/
+
+    // Create a Parameter and a Task List
+    MParList                  plist4;
+    MTaskList                 tlist4;
+    plist4.AddToList(&tlist4);
+
+    // Parameter Containers
+    MHillas                   hillas;
+    //MDCA                      dca;
+    MHillasSrc                hillassrc;
+    MSrcPosCam                source;
+    source.SetX(0.0*189/0.6);
+    source.SetY(0.0*189/0.6);
+    MRawRunHeader             runhead;
+    MArrivalTimeCam           timecam;
+    
+    // False Source stuff
+    MTime                     time;
+    MObservatory              obsv;
+    MPointingPos              poin;
+    
+    hillassrc.SetSrcPos(&source);
+    
+
+    // Add also some containers from previous loops
+    //plist4.AddToList(&timecam);
+    plist4.AddToList(&geomcam);
+    plist4.AddToList(&pedloop.GetPedestalCam());
+    plist4.AddToList(&calloop.GetCalibrationCam());
+    //plist4.AddToList(&badcam);
+    plist4.AddToList(&calloop.GetQECam());
+    //plist4.AddToList(&calloop.GetRelTimeCam());
+    //plist4.AddToList(&calloop.GetBadPixels());
+    plist4.AddToList(&source);
+    plist4.AddToList(&hillas);
+    plist4.AddToList(&hillassrc);
+    //plist4.AddToList(&dca);    
+    plist4.AddToList(&evtphot);
+    plist4.AddToList(&pedphot);
+
+    plist4.AddToList(&time);
+    plist4.AddToList(&obsv);
+    plist4.AddToList(&poin);
+    
+    
+    //MArrivalTime times;
+    //plist4.AddToList(&times);
+    
+    // Tasks
+/*  MReadMarsFile read4("Events");
+    static_cast<MRead&>(read4).AddFiles(druns);  
+    read4.DisableAutoScheme();
+*/
+    // Set bad pixels
+    MBlindPixelCalc           blind;
+
+    const TArrayS bp(16,(Short_t*)x);
+    blind.SetPixelIndices(bp);
+
+    MImgCleanStd              clean(clvl[0],clvl[1]);
+    MHillasCalc               hilcalc;
+    MHillasSrcCalc            hilsrc;
+    //MDCACalc                  dcacalc;
+    
+    
+    
+
+    MWriteRootFile write(oname,"RECREATE"); //Alternative options: NEW, UPDATE
+
+    //write.AddContainer("MDCA"         , "Parameters");
+    write.AddContainer("MHillas"        , "Parameters");
+    write.AddContainer("MHillasSrc"     , "Parameters");
+    write.AddContainer("MHillasExt"     , "Parameters");
+    write.AddContainer("MNewImagePar"   , "Parameters");
+    write.AddContainer("MRawEvtHeader"  , "Parameters");
+    write.AddContainer("MRawRunHeader"  , "Parameters");
+    write.AddContainer("MConcentration" , "Parameters");
+    write.AddContainer("MSrcPosCam"     , "Parameters");
+
+    
+    // False Source stuff
+    MHFalseSource             fshist;
+    fshist.SetAlphaCut(12.5);
+    //fshist.SetBgMean(35);
+    MFillH                   hfill(&fshist, "MHillas");
+    //MFillH                   hfill("MHFalseSource", "MHillas");
+
+    //MFalseSrcCalc     falsecalc;
+    //falsecalc.SetAlphaCut(12.5);
+    //falsecalc.SetDistCuts(.25,1.0);
+    //falsecalc.SetSizeCut(1000);
+    //falsecalc.SetWidthCuts(.04,.14);
+    //falsecalc.SetLengthCuts(.14,.26);
+    //falsecalc.SetOutput("ON.root");//outname);
+    //falsecalc.SetRefPoint(0,0);
+
+    //tlist4.AddToList(&read4);
+    tlist4.AddToList(&dread);
+    tlist4.AddToList(&geomapl);
+    tlist4.AddToList(&extractor);
+    //tlist4.AddToList(&blind);
+    //tlist4.AddToList(&timecalc);
+    tlist4.AddToList(&calphot);
+    //tlist4.AddToList(&timecal);
+    tlist4.AddToList(&clean);
+    tlist4.AddToList(&hilcalc);
+    //tlist4.AddToList(&dcacalc);
+    tlist4.AddToList(&hilsrc);
+//    tlist4.AddToList(&falsecalc);
+    //tlist4.AddToList(&hfill);
+    tlist4.AddToList(&write);  
+
+    // Create and setup the eventloop
+    MProgressBar              bar4;
+    bar4.SetWindowName("Analyzing Data...");
+
+    MEvtLoop                  evtloop4;
+    evtloop4.SetProgressBar(&bar4);
+    evtloop4.SetParList(&plist4);
+
+    if (!evtloop4.Eventloop())
+	return;
+
+    tlist4.PrintStatistics();
+
+    //fshist.Draw();
+
+
+}
+
+
+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;
+}
+
+
+// Find the correct pulser color, done by M. Gaug
+MCalibrationCam::PulserColor_t FindColor(MDirIter* run) 
+{
+  
+  MCalibrationCam::PulserColor_t col = MCalibrationCam::kNONE;
+
+  TString filenames;
+
+  while (!(filenames=run->Next()).IsNull())
+    {
+
+      filenames.ToLower();
+
+      if (filenames.Contains("green"))
+        if (col == MCalibrationCam::kNONE)
+          {
+            cout << "Found colour: Green  in " << filenames << endl;
+            col = MCalibrationCam::kGREEN;
+          }
+        else if (col != MCalibrationCam::kGREEN)
+          {
+            cout << "Different colour found in " << filenames << "... abort" << endl;
+            return MCalibrationCam::kNONE;
+          }
+
+      if (filenames.Contains("blue"))
+        if (col == MCalibrationCam::kNONE)
+          {
+            cout << "Found colour: Blue  in " << filenames << endl;
+            col = MCalibrationCam::kBLUE;
+          }
+        else if (col != MCalibrationCam::kBLUE)
+          {
+            cout << "Different colour found in " << filenames << "... abort" << endl;
+            return MCalibrationCam::kNONE;
+          }
+
+      if (filenames.Contains("uv"))
+        if (col == MCalibrationCam::kNONE)
+          {
+            cout << "Found colour: Uv  in " << filenames << endl;
+            col = MCalibrationCam::kUV;
+          }
+        else if (col != MCalibrationCam::kUV)
+          {
+            cout << "Different colour found in " << filenames << "... abort" << endl;
+            return MCalibrationCam::kNONE;
+          }
+
+      if (filenames.Contains("ct1"))
+        if (col == MCalibrationCam::kNONE)
+          {
+            cout << "Found colour: Ct1  in " << filenames << endl;
+            col = MCalibrationCam::kCT1;
+          }
+        else if (col != MCalibrationCam::kCT1)
+          {
+            cout << "Different colour found in " << filenames << "... abort" << endl;
+            return MCalibrationCam::kNONE;
+          }
+      
+    }
+  
+     
+  if (col == MCalibrationCam::kNONE)
+    cout <<  "No colour found in filenames of runs: " << ((MRunIter*)run)->GetRunsAsString() 
+         << "... abort" << endl;
+  
+  return col;      
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/meth/macros/analysis_read.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/meth/macros/analysis_read.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/meth/macros/analysis_read.C	(revision 9661)
@@ -0,0 +1,568 @@
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// analysis_read.C                                                         //
+//                                                                         //
+// Author(s): S.C. Commichau, 3/2004                                       //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+
+// This macro reads the output of analysis.C and plots some of the
+// image parameters. It also produces an ALPHA plot and calculates
+// the significance
+
+void analysis_read(){
+
+    gROOT->Reset();
+    
+    // Some parameters for the ALPHA-plot
+    const Int_t inibin = 9;
+    const Int_t nbins  = 18;
+
+    // ON data chain
+    TChain* CON  = new TChain("Parameters");
+
+    // OFF data chain
+    TChain* COFF = new TChain("Parameters");
+
+    // Add the root file(s) to the chain and treat it like a tree
+    CON->Add("~/Mars/on1.root");
+    COFF->Add("~/Mars/off1.root");
+
+    //CON->Add("~/no_back/hillas_on_all23.root");
+    //COFF->Add("~/no_back/hillas_off_all23.root");
+
+    TString title = "Mrk421 - 04/23/2004";
+
+    // Set some global style options
+    //gStyle->SetOptDate(10);
+    //gStyle->SetDateX(.1);
+    //gStyle->SetDateY(.905);
+    gStyle->SetOptFit(0);
+    gStyle->SetOptStat(110011);
+    gStyle->SetFrameBorderMode(0);
+    //gStyle->SetPalette(1);
+    gStyle->SetPalette(1,0);
+    gStyle->SetFrameBorderSize(0);
+    gStyle->SetCanvasColor(0);
+    gStyle->SetFrameFillColor(0);
+    gStyle->SetTitleFillColor(0);
+    gStyle->SetTitleBorderSize(0);
+    gStyle->SetStatColor(0);
+    gStyle->SetStatBorderSize(1);
+    // Put the statistics box into the right corner!
+    gStyle->SetStatX(.9);
+    gStyle->SetStatY(.9);
+    //gStyle->SetStatTextColor(2);
+
+    // Set alias for each quantity to simplify the handling
+    CON->SetAlias("length","MHillas.fLength*0.6/189.0");
+    CON->SetAlias("width","MHillas.fWidth*0.6/189.0");
+    CON->SetAlias("meanx","MHillas.fMeanX*0.6/189.0");
+    CON->SetAlias("meany","MHillas.fMeanY*0.6/189.0");
+    CON->SetAlias("size","MHillas.fSize");
+    CON->SetAlias("dist","MHillasSrc.fDist*0.6/189.0");
+    CON->SetAlias("alpha","MHillasSrc.fAlpha");
+    CON->SetAlias("delta","abs(MHillas.fDelta)*180/3.1415");
+    //CON->SetAlias("delta","MDCA.fDelta1*180/3.1415");
+    //CON->SetAlias("dca","MDCA.fDCA*0.6/189.0");
+
+    COFF->SetAlias("length","MHillas.fLength*0.6/189.0");
+    COFF->SetAlias("width","MHillas.fWidth*0.6/189.0");
+    COFF->SetAlias("meanx","MHillas.fMeanX*0.6/189.0");
+    COFF->SetAlias("meany","MHillas.fMeanY*0.6/189.0");
+    COFF->SetAlias("size","MHillas.fSize");
+    COFF->SetAlias("dist","MHillasSrc.fDist*0.6/189.0");
+    COFF->SetAlias("alpha","MHillasSrc.fAlpha");
+    COFF->SetAlias("delta","abs(MHillas.fDelta)*180/3.1415");
+
+
+    // Cuts...
+    // Cut for ALPHA
+    TString cut1 = "(dist>0.2) && (dist<.7) && (width>0.04) && (width<0.14) && (length>0.14) && (length<0.26) && (size>500)";
+        
+    TString cut2 = "";//size>1000 && size<2000";
+
+    TString cut3 = "";
+
+    TString cut4 = "";
+
+    TString cut5 = "";
+    
+
+    // And now the draw area
+    
+    //************ Width vs Length ************
+
+    TCanvas* CWL = new TCanvas("CWL","Canvas",0,0,300,300);
+    CWL->cd();
+    CWL->SetBorderMode(0); 
+    gPad->SetBorderMode(0);
+    gStyle->SetOptStat(0);
+            
+    TH2F* hWL = new TH2F("hWL","",200,0,0.7,200,0,1);
+    
+    // Leaf, Cuts, Draw option, use >>+ to append data to an ex. histogram
+    CON->Draw("length:width>>hWL",cut2);
+
+    hWL->SetTitle(title); 
+    hWL->GetXaxis()->SetTitle("WIDTH [#circ]");
+    hWL->GetYaxis()->SetTitle("LENGTH [#circ]");
+    hWL->GetYaxis()->SetTitleOffset(1.2);
+    hWL->SetMarkerColor(2);
+     
+    hWL->SetMaximum(150);
+    hWL->Draw("COLZ");//CONT
+
+
+    //************ Width and Length ************
+
+    // Create Canvas and set Canvas some options
+    TCanvas* Cwl = new TCanvas("Cwl","Canvas",325,0,300,300);
+    Cwl->cd();
+    Cwl->SetBorderMode(0);   
+    gPad->SetBorderMode(0);
+    gStyle->SetOptStat(110011);
+
+    TH1F* hLength = new TH1F("hLength","",100,0,1.1);
+        
+    CON->Draw("length>>hLength",cut5,"");
+
+    hLength->SetTitle(title); 
+    hLength->GetXaxis()->SetTitle("LENGTH and WIDTH [#circ]");
+    hLength->GetYaxis()->SetTitle("Entries");
+    hLength->GetYaxis()->SetTitleOffset(1.6);
+    hLength->SetFillColor(50);
+    hLength->SetLineColor(50);
+    hLength->SetLineWidth(2);
+    hLength->SetFillStyle(3005);
+    //hLength->SetMaximum(55000);
+    hLength->SetName("LENGTH");
+
+    TH1F* hWidth = new TH1F("hWidth","",100,0,1.1);
+
+    CON->Draw("width>>hWidth",cut5,"");
+ 
+    gStyle->SetStatTextColor(4);
+    hWidth->SetFillColor(4);
+    hWidth->SetLineColor(4);
+    hWidth->SetFillStyle(3004);
+    hWidth->SetLineWidth(2);
+    hWidth->SetName("WIDTH");
+
+    TLegend* leg = new TLegend(.59,.75,.8,.84);
+    leg->AddEntry(hLength,"LENGTH","F");
+    leg->AddEntry(hWidth,"WIDTH","F");
+    leg->SetFillColor(0);
+    leg->SetLineColor(1);
+    leg->SetBorderSize(0);
+
+    hLength->Draw();//DrawNormalized or DrawCopy are possible options
+    hWidth->Draw("sames");
+    //leg->Draw("same");
+
+    // Beautify the statistic boxes!
+    gPad->Update();
+    TPaveStats* pavstat = (TPaveStats*) hLength->GetListOfFunctions()->FindObject("stats");
+    if(pavstat)
+    {
+	Float_t shiftx = pavstat->GetX2NDC()-pavstat->GetX1NDC();
+	pavstat->SetX1NDC(pavstat->GetX1NDC()-shiftx);
+	pavstat->SetX2NDC(pavstat->GetX2NDC()-shiftx);
+	pavstat->SetTextColor(50);
+    }
+
+    gPad->Modified();
+    gPad->Update();
+
+
+    //************ Dist ************
+    
+    TCanvas* CDist = new TCanvas("CDist","Canvas",650,0,300,300);
+    CDist->cd();
+    CDist->SetBorderMode(0); 
+    gStyle->SetOptStat(110011);
+    //CDist->SetLogy();
+
+    TH1F* hDist = new TH1F("hDist","",90,0,1.8);
+
+    CON->Draw("dist>>hDist");
+
+    hDist->GetXaxis()->SetTitle("DIST [#circ]");
+    hDist->GetYaxis()->SetTitle("Entries");
+    hDist->GetYaxis()->SetTitleOffset(1.6);
+    //hDist->GetXaxis()->SetTitleOffset(1.3);
+    hDist->SetLineColor(4);
+    hDist->SetMarkerColor(4);
+    hDist->SetFillColor(4);
+    hDist->SetFillStyle(3004);
+    hDist->SetLineWidth(2);
+    hDist->SetTitle(title);
+    hDist->SetName("DIST");
+    
+    hDist->Draw();
+
+
+    //************ MeanY vs MeanX ************
+    
+    TCanvas* CXY = new TCanvas("CXY","Canvas",975,0,300,300);
+    CXY->cd();
+    CXY->SetBorderMode(0);  
+    gStyle->SetOptStat(0);
+    
+    TH2F* hXY = new TH2F("hXY","",500,-1.5,1.5,500,-1.5,1.5);
+
+    CON->Draw("meany:meanx>>hXY",cut3,"");
+
+    TString titlexy = TString(title);
+
+    hXY->SetTitle(titlexy); 
+    hXY->GetXaxis()->SetTitle("MeanX [#circ]");
+    hXY->GetYaxis()->SetTitle("MeanY [#circ]");
+    hXY->GetYaxis()->SetTitleOffset(1.2);
+    hXY->SetMaximum(15);
+     
+    hXY->Draw("COLZ");
+
+
+    //************ DCA ************
+    /*     
+    TCanvas* CDCA = new TCanvas("CDCA","Canvas",10,400,300,300);
+    CDCA->cd();
+    CDCA->SetBorderMode(0); 
+    gStyle->SetOptStat(110011);
+    
+    TH1F* hDCA = new TH1F("hDCA","",100,-1.5,1.5);
+
+    CON->Draw("dca>>hDCA");
+
+    hDCA->GetXaxis()->SetTitle("DCA [#circ]");
+    hDCA->GetYaxis()->SetTitle("Entries");
+    hDCA->GetYaxis()->SetTitleOffset(2);
+    hDCA->SetLineColor(4);
+    hDCA->SetFillColor(4);
+    hDCA->SetFillStyle(3004);
+    hDCA->SetTitle(title);
+    hDCA->SetName("DCA");
+
+    hDCA->Draw();
+    */    
+
+
+    //************ Delta ************
+     
+    TCanvas* CDelta = new TCanvas("CDelta","Canvas",0,335,300,300);
+    CDelta->cd();
+    CDelta->SetBorderMode(0); 
+    gStyle->SetOptStat(110011);
+
+    TH1F* hDelta = new TH1F("hDelta","",100,0,90);
+
+    CON->Draw("delta>>hDelta",cut3);
+    
+    hDelta->GetXaxis()->SetTitle("#delta [#circ]");
+    hDelta->GetYaxis()->SetTitle("Entries");
+    hDelta->GetYaxis()->SetTitleOffset(1.4);
+    hDelta->SetLineColor(4);
+    hDelta->SetFillColor(4);
+    hDelta->SetFillStyle(3004);
+    hDelta->SetLineWidth(2);
+    hDelta->SetTitle(title);
+    hDelta->SetName("Delta");
+
+    hDelta->Draw();
+
+
+    //************ Size ************
+     
+    TCanvas* CSize = new TCanvas("CSize","Canvas",325,335,300,300);
+    CSize->cd();
+    CSize->SetBorderMode(0); 
+    gStyle->SetOptStat(110011);
+
+    TH1F* hSize = new TH1F("hSize","",100,0.1,5000);
+
+    CON->Draw("size>>hSize");
+    
+    hSize->GetXaxis()->SetTitle("Size [Photons]");
+    hSize->GetYaxis()->SetTitle("Entries");
+    hSize->GetYaxis()->SetTitleOffset(1.6);
+    hSize->GetXaxis()->SetTitleOffset(1.2);
+    hSize->SetLineColor(4);
+    hSize->SetFillColor(4);
+    hSize->SetLineWidth(2);
+    hSize->SetFillStyle(3004);
+    hSize->SetTitle(title);
+    hSize->SetName("SIZE");
+    
+    hSize->Draw();
+
+
+    //************ Alpha ************
+       
+    TCanvas* CAlpha = new TCanvas("CAlpha","Canvas",650,335,300,300);
+    CAlpha->cd();
+    CAlpha->SetBorderMode(0); 
+    CAlpha->SetGridx();
+    CAlpha->SetGridy();
+    gStyle->SetOptStat(11);
+    
+    TH1F *hAlpha = (TH1F*)new TH1F("hAlpha","Alpha ON",nbins,0,90);
+    TH1F *hAlphaoff = (TH1F*)new TH1F("hAlphaoff","Alpha OFF",nbins,0,90);
+
+    CON->Draw("abs(alpha)>>hAlpha",cut1);
+
+    COFF->Draw("abs(alpha)>>hAlphaoff",cut1);
+
+
+    //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
+    // Normalize ON and OFF data
+    cout << "******************************************************" << endl;
+    cout << " Bin error before scaling: " << hAlphaoff->GetBinError(2) << endl;
+
+    // If TH1::Sumw2 has been called before filling, the sum of squares of
+    // weights is also stored - I do not understand this!!
+    hAlphaoff->Sumw2();
+    
+    Float_t level = 0, leveloff = 0;
+    
+    // Calculate the mean of entries beside the signal region
+    for(Int_t ibin = inibin; ibin<=nbins; ibin++)
+	level += hAlpha->GetBinContent(ibin);
+    level /= (nbins-inibin+1);
+    
+    cout << " Mean beside signal: " << level << endl;
+
+    for(Int_t ibin = inibin; ibin<=nbins; ibin++)
+	leveloff += hAlphaoff->GetBinContent(ibin);
+    leveloff /= (nbins-inibin+1);
+
+    // Compare the mean values of both histograms
+    if(leveloff>0)
+	const Float_t norm = level/leveloff;//*nbins/hAlphaoff->GetEntries();
+    cout << " Normalizing by factor " << norm <<endl;
+    hAlphaoff->Scale(norm);
+    
+    cout << " Bin error after scaling: " << hAlphaoff->GetBinError(2) << endl;
+
+    cout << " Cut on (ALPHA): " << cut1 << endl;
+    //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
+
+   //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
+    // Significance calculation
+    Float_t significance = 0;
+    const Int_t signbins = 3;
+    
+    Int_t Non  = 0;
+    Int_t Noff = 0;
+
+    cout << " Significance Bins: " << signbins << endl;
+
+    // Determine number of excess events and off events in the same region 
+    for(Int_t ibin = 1; ibin<=signbins;ibin++)
+    {
+	Non +=hAlpha->GetBinContent(ibin);
+	Noff+=hAlphaoff->GetBinContent(ibin);
+    }
+
+    cout << " Non = " << Non << " Noff = " << Noff << endl;
+
+    significance = Significance(Non, Noff, 1.0, 0); //norm
+
+    cout << " Significance: " << significance << endl;
+    cout << "******************************************************" << endl;
+    //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
+
+    // Set some draw options and draw the histograms
+    hAlphaoff->GetXaxis()->SetTitle("ALPHA [#circ]");
+    hAlphaoff->GetYaxis()->SetTitle("Entries");
+    hAlphaoff->GetYaxis()->SetTitleOffset(1.4);
+    hAlphaoff->GetXaxis()->SetTitleOffset(1.1);
+
+    char legentry[128];
+    sprintf(legentry,"  (Sign.: %2.3f #sigma,  Norm.: %2.3f,  |ALPHA| #leq %d#circ)", significance, norm, 90/nbins*signbins);
+
+    hAlphaoff->SetTitle(title+legentry);
+    hAlphaoff->SetName("OFF source");
+    hAlphaoff->SetLineColor(4);
+    hAlphaoff->SetLineWidth(2);
+    hAlphaoff->SetMarkerColor(8);
+    hAlphaoff->SetMarkerStyle(21);
+    hAlphaoff->SetMarkerSize(0);
+    hAlphaoff->SetFillColor(18);
+    hAlphaoff->SetMaximum(hAlpha->GetMaximum()+200);
+
+    hAlpha->SetLineColor(1);
+    hAlpha->SetLineWidth(2);
+    hAlpha->SetMarkerColor(50);
+    hAlpha->SetMarkerStyle(20);
+    hAlpha->SetMarkerSize(0.9);
+    hAlpha->SetName("ON source");
+    //hAlpha->SetMaximum(hAlpha->GetMaximum());
+
+    hAlphaoff->Draw("eH");
+    hAlpha->Draw("e1sames");
+
+    // Beautify the statistic boxes!
+    gPad->Update();
+    TPaveStats* pavstat = (TPaveStats*) hAlphaoff->GetListOfFunctions()->FindObject("stats");
+    if(pavstat)
+    {
+	Float_t shiftx = pavstat->GetX2NDC()-pavstat->GetX1NDC();
+	pavstat->SetX1NDC(pavstat->GetX1NDC()-shiftx);
+	pavstat->SetX2NDC(pavstat->GetX2NDC()-shiftx);
+	pavstat->SetTextColor(4);
+    }
+
+    TPaveStats* pavstaton = (TPaveStats*) hAlpha->GetListOfFunctions()->FindObject("stats");
+    if(pavstaton)
+    {
+	pavstaton->SetTextColor(50);
+    }
+
+    gPad->Modified();
+    gPad->Update();
+
+
+    //************ Length/Size ************
+    
+    TCanvas* CLSiz = new TCanvas("CLSiz","Canvas",975,335,300,300);
+    CLSiz->cd();
+    CLSiz->SetBorderMode(0); 
+    gStyle->SetOptStat(110011);
+
+    TH1F* hLenSiz = new TH1F("hLenSiz","",100,0,0.005);
+
+    CON->Draw("length/size>>hLenSiz",cut2,"");
+
+    hLenSiz->GetXaxis()->SetTitle("LENGTH/SIZE [#circ/Photons]");
+    hLenSiz->GetYaxis()->SetTitle("Entries");
+    hLenSiz->GetYaxis()->SetTitleOffset(1.5);
+    hLenSiz->GetXaxis()->SetTitleOffset(1.1);
+    hLenSiz->SetLineColor(4);
+    hLenSiz->SetFillColor(4);
+    hLenSiz->SetLineWidth(2);
+    hLenSiz->SetFillStyle(3004);
+    hLenSiz->SetNdivisions(505);
+
+    hLenSiz->SetTitle(title);
+    hLenSiz->SetName("LENGTH/SIZE");
+
+    hLenSiz->Draw();
+
+
+    // Uncomment the following lines for MC only!
+
+    //************ Energy ************
+    /*
+   
+    TH1F *hEnergy = (TH1F*)gDirectory->Get("hEnergy");
+    
+    TCanvas* CEnergy = new TCanvas("CEnergy","Canvas",0,670,300,300);
+    CEnergy->cd();
+    CEnergy->SetBorderMode(0); 
+    //CEnergy->SetLogy();
+    gStyle->SetOptStat(110011);
+
+    TH1F* hEnergy = new TH1F("hEnergy","",100,0,1000);
+
+    CON->Draw("energy>>hEnergy","","");
+     
+    hEnergy->GetXaxis()->SetTitle("Energy [GeV]");
+    hEnergy->GetYaxis()->SetTitle("Entries");
+    hEnergy->GetYaxis()->SetTitleOffset(1.2);
+    hEnergy->GetXaxis()->SetTitleOffset(1.1);
+    hEnergy->SetLineColor(4);
+    hEnergy->SetFillColor(4);
+    hEnergy->SetLineWidth(2);
+    hEnergy->SetFillStyle(3004);
+    hEnergy->SetNdivisions(505);
+
+    hEnergy->SetTitle(title);
+    hEnergy->SetName("Energy");
+
+    hEnergy->Draw();
+    */
+
+
+    //************ MeanX and MeanY ************
+
+    // Create Canvas and set Canvas some options
+    TCanvas* Cxy = new TCanvas("Cxy","Canvas",325,670,300,300);
+    Cxy->cd();    
+    Cxy->SetBorderMode(0);   
+    gPad->SetBorderMode(0);
+    gStyle->SetOptStat(111);
+
+    TH1F* hMeanX = new TH1F("hMeanX","",100,-1.5,1.5);
+    
+    CON->Draw("meanx>>hMeanX",cut3,"");
+
+    TH1F* hMeanY = new TH1F("hMeanY","",100,-1.5,1.5);
+
+    CON->Draw("meany>>hMeanY",cut3,"");
+    
+    hMeanX->SetTitle(title); 
+    hMeanX->GetXaxis()->SetTitle("MeanX and MeanY [#circ]");
+    hMeanX->GetYaxis()->SetTitle("Entries");
+    hMeanX->GetYaxis()->SetTitleOffset(1.6);
+    hMeanX->SetFillColor(50);
+    hMeanX->SetLineColor(50);
+    hMeanX->SetLineWidth(2);
+    hMeanX->SetFillStyle(3005);
+    //hMeanX->SetMaximum(16000);
+    //hMeanX->SetMaximum(6500);
+    hMeanX->SetName("MeanX");
+ 
+    gStyle->SetStatTextColor(4);
+    hMeanY->SetFillColor(4);
+    hMeanY->SetLineColor(4);
+    hMeanY->SetFillStyle(3004);
+    hMeanY->SetLineWidth(2);
+    hMeanY->SetName("MeanY");
+
+    hMeanX->Draw();//DrawNormalized or DrawCopy are possible options
+    hMeanY->Draw("sames");//esames
+
+    // Beautify the statistic boxes!
+    gPad->Update();
+    TPaveStats* pavstat = (TPaveStats*) hMeanX->GetListOfFunctions()->FindObject("stats");
+    if(pavstat)
+    {
+	Float_t shiftx = pavstat->GetX2NDC()-pavstat->GetX1NDC();
+	pavstat->SetX1NDC(pavstat->GetX1NDC()-shiftx);
+	pavstat->SetX2NDC(pavstat->GetX2NDC()-shiftx);
+	pavstat->SetTextColor(50);
+    }
+
+    gPad->Modified();
+    gPad->Update();
+
+    //delete hWL;
+    //delete hXY;
+}
+
+
+Double_t Significance(Float_t Non, Float_t Noff, Float_t alpha, Int_t type = 0)
+{
+    // Calculate significance after Li and Ma
+    
+    // Formula Nr. 17
+    if(type == 0)
+	return TMath::Sqrt(2*(Non*TMath::Log(((1+alpha)/alpha)*(Non/(Non+Noff))) + Noff*TMath::Log((1+alpha)*Noff/(Non+Noff))));
+
+    // Formula Nr. 9
+    if(type == 1)
+	return (Non-alpha*Noff)/TMath::Sqrt(alpha*(Non+Noff));
+
+}
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/.rootrc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/.rootrc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/.rootrc	(revision 9661)
@@ -0,0 +1,45 @@
+#############################################################################
+#                                                                           #
+# This is the path where root seraches for macros                           #
+# to execute (eg. .x merpp.C)                                               #
+#                                                                           #
+#############################################################################
+
+Unix.*.Root.MacroPath:       .:./macros:../../macros
+
+#############################################################################
+#                                                                           #
+# This is the path where the dynamic loader (eg. gSystem->Load("mars.so")   #
+# is searching for the shared objects                                       #
+#                                                                           #
+#############################################################################
+
+Unix.*.Root.DynamicPath:     .:./lib
+
+#############################################################################
+#                                                                           #
+# This is the name of the logon macro (executed at root startup) and the    #
+# logoff macro (executed when quiting root)                                 #
+#                                                                           #
+#############################################################################
+
+Rint.Logon:                  rootlogon.C
+Rint.Logoff:                 rootlogoff.C
+
+#############################################################################
+#                                                                           #
+# This is used if you want to use the root documentation facility to        #
+# create the documentation of the code out of the code                      #
+#                                                                           #
+#############################################################################
+
+Root.Html.DescriptionStyle:  Doc++
+
+Root.Html.Author:            !   Author(s):
+Root.Html.Copyright:         !   Copyright
+Root.Html.Modified:          !   Modified:
+Root.Html.Description        // ----
+
+Root.Html.Root:              http://root.cern.ch/root/htmldoc/
+Root.Html.HomePage:          http://magic.astro.uni-wuerzburg.de/mars/
+Root.Html.SearchEngine:      http://magic.astro.uni-wuerzburg.de/mars/search.html
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/Changelog
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/Changelog	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/Changelog	(revision 9661)
@@ -0,0 +1,471 @@
+Please  do  not write behind the end of line tag so that it is  possible
+to   send  a   Changelog   file  to  a  line  printer  directly.  Thanks.
+
+For your entries please follow this style:
+
+_yyyy/mm/dd:_[Your Name]
+_
+___*_filename:
+_____-_description
+_
+___*_filename2, filename3:
+_____-_description
+_
+_
+_
+
+While an underscore is a placeholder for a white-space or an empty line.
+
+                                                 -*-*- END OF LINE -*-*-
+
+ 2004/08/03 Ester Aliu Fusté
+    * library/MIslands.[h, cc], MIslandCalc.[h,cc]
+     - Add the delete for the pointers  
+
+  2004/08/02 Ester Aliu Fusté
+    * library/MIslands.[h, cc], MIslandCalc.[h,cc]
+     - Added the variables: distance (Dist) between the larger island and 
+       the other ones, width and lenght of the larger island. 
+     
+     - Written pointers instead of vectors 
+     
+  2004/07/28 Javi Lopez
+    * script/
+     - Created directory call scripts
+     - Added srcPosRun.sh script to create the *.pos file for the MSrcPosFromFile
+       task.
+     - Added makeHillas.sh script that run several makeHillas making groups of
+       data runs with preavius pedestal run.
+  
+  2004/07/28 Ester Aliu Fuste
+    * programa/makeHillas.cc
+     - Add a flag for the time calibration
+ 
+  2004/07/26 Ester Aliu Fuste
+    * library/MIslandCalc.cc
+     - Add the initialization of Dist(to -1) and MeanX/MeanY (to -10000) vectors
+
+  2004/07/22 Oscar Blanch Bigas
+    * programs/makeHillas.cc
+     - Solved backwards compatibility on the CLEANLEVEL
+       options.
+
+  2004/07/22 Ester Aliu 
+    * library/MIslands.[h,cc],MIslandCalc.cc
+     - Add meanX, meanY and dist of each of the islands
+     - Now the island with id 0 is the larger one
+
+  2004/07/21  Javier Rico
+    * programs/makeHillas.cc, srcPos.cc
+      - Add time information
+
+    * programs/makehillas.datacard
+      - Add comment
+
+  2004/07/20  Javier Lopez
+    * library/MLiveTime.[h,cc]
+      - Containers to hold the live time. It has the option to
+      have several time bins.
+    * library/MLiveTimeCalc.[h,cc]
+      - Task to compute the live time from the data. 
+    * macros/runlivetime.C
+      - Macro to use the MLiveTime+ stuff.
+
+  2004/07/15  Javier Lopez
+    * macros/ligthcurve.C
+      - Macro to compute a light curve from hillas files.
+
+  2004/07/04  Oscar Blanch Bigas
+    * library/MControlPlots.cc
+      - Off MHCamera normalised to On
+
+    * programs/makeHillas.cc
+      - Added clean flags to chose: number of rings and kDemocratic.
+      - Using different Pedestal run for the calibration.
+
+    * programs/optimizeCuts.cc
+      - Added alias for MNewImageParameters.fInnerLeakage
+
+    * calib.[cc,datacard]
+      - Added : produces ascci file with relevant factors of
+                Calibration
+
+    * controlPlot.cc, controlplot.datacard
+      - Added : It makes Number of hits plot.
+
+  2004/06/30: Javier Rico
+
+    * mifae/library/MDisp.cc
+      - Remove include of deprecated library
+      - Define namespace
+
+    * mifae/library/MControlPlots.cc
+      - Define style
+      - Add projection
+      - Plot 3rd plot correctly
+      - Search for "MIsland" instead of "MIsland1" container
+
+  2004/06/26: Eva Domingo - Pepe Flix
+
+    * mifae/library/MDisp.[h,cc]
+    * mifae/library/MDispCalc.[h,cc]
+      - Added classes for evaluation of DISP method.
+
+  2004/06/22  Javier Rico
+    * library/MControlPlots.[h,cc]
+      - Added
+
+    * library/Makefile, IFAELinkDef.h
+      - Add MControlPlots. So far, it produces plots with the number
+        of times each pixel survives the cleaning. It needs a MIsland
+        object to be included on the parameter list
+
+    * programs/makeHillas.cc
+      - Change pointer to MWriteRootFile object for MWriteRootFile 
+	object (otherwise the tree "Parameters" is not saved)
+      - Islands are always computed since are needed for some control
+        plots
+
+    * programs/srcPos.cc
+      - Add MControlPlots to the task list
+
+    * library/MSrcPosFromFile.cc
+      - Cope with case where first analyzed run is not in input file
+
+  2004/06/15  Javier Lopez
+    * library/MSrcPosFromStars.[h,cc]
+      - Task to compute the position of a source from
+        the positions of several stars.
+
+    * library/MHPSFFromStars.[h,cc]
+      - Histogram task that holds and fills the histograms of 
+        positioning and point spread function of an star.
+
+    * macros/distancebetweenstars.C
+      - Add macros that show in an histogram the distance between
+        the stars in a field of view. 
+
+    * macros/psffromstars.C
+      - Add task that show the point spread funtion and positon of
+        the most central star in the field of view. This information
+        is compute using the MFindStars tool.
+
+ 2004/06/11 Ester Aliu 
+   * programs/makeHillas.cc
+     - add the possibility of using more than one algorithm to 
+      calculate the islands and use different algorithms for counting
+      islands
+
+   * library/MIslands.[h,cc],MIslandCalc.[h,cc], MIslandCleaning.[h,cc]
+     - add a new island cleaning which consists in removing all the
+      islands except the larger one
+     - add a new algorithm of counting islands consisting in consider
+      as the same islands those islands separated by 2 or less pixels
+
+ 2004/06/02 Javier Rico
+   * srcpositions, srcpositions/Mrk421_220404_pos.txt
+     - add directory to store files with source positions and a first
+       sample file (with real data)
+
+ 2004/06/01 Javier Rico
+   * macros/observationTime.C
+     - add macro to compute observation time
+
+ 2004/05/28 Javier Rico
+   * programs/optimizeCuts.cc programs/optimizecuts.datacard
+     - Include loop on size
+
+ 2004/05/27 Ester Aliu 
+   * programs/makeHillas.cc
+     - Add the name of the MIslands container
+
+   * library/MHillasDisplay.[h,cc]
+     - Add a function which retuns the name of the MIslands container
+
+   * library/MIslands.[h,cc],MIslandCalc.cc
+     - Add MIslands::Print() function wich prints the island parameters
+     - Change some part of the code to take into account that some 
+     times there are bad pixels
+
+ 2004/05/27 Javier Rico
+   * programs/makeHillas.cc, programs/makehillas.datacard
+     - Remove unneeded MCalibrationQECam and MBadPixelsCam objects, 
+       trying to trace back a bug in the calibration
+     - Add possibility to interpolate bad pixels
+
+   * library/MHillasDisplay.cc
+     - Initialize MIslands object in constructor
+	
+ 2004/05/26 Javier Rico
+   * library/MHillasDisplay.[h,cc]
+     - Call for MIslands::Print() in the process if any MIslands is 
+       found
+	
+ 2004/05/24 Javier Rico
+   * library/MDisplay.[h,cc], programs/makeHillas.cc, 
+     programs/makehillas.datacard
+     - Add possibility to save a ps file
+     - Update documentation
+     - Cope with the case when no cut is provided
+	
+   * library/MHillasDisplay[h.cc]
+     - correct minor axis paint
+     - include MNewImagePar dumping
+     - update documentation
+	
+ 2004/05/21 Oscar Blanch
+   * makeHillas.cc
+     - Adde a couple of conditionals to allow makeHillas in 
+       NON calibration mode without giving a Cailbration file,
+	
+ 2004/05/21  Javier Rico
+   * library/MDCA.[cc.h]
+     - removed
+
+   * library/MDisplay.[h,cc], library/MHillasDisplay.[h,cc]
+     - added
+
+   * library/Makefile, library/IFAELinkDef.h
+     - remove MDCA
+     - add MDisplay and MHillasDisplay
+
+   * library/MSrcPlace.[h,cc], library/MSrcRotate.[h,cc],
+     library/MSrcTranslate.[h,cc], library/MSrcPosFromFile.cc
+     - remove MDCA dependences
+
+   * programs/makeHillas.cc, programs/makehillas.datacard
+     - include display and selection cuts options
+	
+   * programs/Makefile
+     - include mfbase in the list of includes directory
+
+ 2004/05/18  Javier Rico
+   * macros/plotOptimal.C
+     - dump value of maximal significance and cuts
+
+ 2004/05/18  Javier Rico
+   * library/MSrcPlace.[cc,h], library/MSrcRotate.[cc,h], 
+     library/MSrcTranslate.[cc,h], library/MSrcPosFromFile.[cc,h]
+     - Add the possibility of having different input and output 
+       MSrcPosCam containers (CONSTRUCTORS HAVE CHANGED!)
+     - Move the creation of internal histogram to PreProcess, so that
+       it can be configured before creation. Now configurable: whether
+       histo must be created or not (fCreateHisto), histo bin size 
+       (fHistoBinPrec), histogram name (fHistoName), with corresponding
+       getters and setters
+     - Update documentation
+
+   * library/MSrcPosFromFile.cc	
+     - If no position has been measured for the first analyzed run, use
+       the one of the first run in file instead.
+
+   * programs/falseSource.cc
+     - Change obsolete MSrcPosCam predefinitions for modern 
+       MSrcTranslate objects, which allow relative displacement of the
+       source position from a previously assigned one. 
+     - Add flag for relative translation
+     - Include control histograms (hOn[Off]SrcPos) for the source 
+       position
+
+   * programs/falsesource.datacard
+     - Add datacard SRCABS for relative/absolute source translation
+
+   * programs/srcPos.cc
+     - Avoid creation of internal histograms for the translation
+
+   * programs/optimizeCuts.cc
+     - Correct bug on width initial value
+
+   * programs/makeHillas.cc
+     - Pass MCalibrationQECam from the MJCalibration to the following
+       loops (to be able to perform calibration of data)
+	
+	
+ 2004/05/17  Javier Rico
+   * library/MSrcPlace.[cc,h], library/MSrcRotate.cc, 
+     library/MSrcTranslate.cc
+     - Assign the internal histogram a class-dependent name
+     - Add some log lines to trace the classes behaviour
+     - Remove function SearchForSrcPos
+
+   * library/MSrcPosFromFile.[cc,h]
+     - Correct behaviour for not found runs
+     - Keep latest good MSrcPosCam to fill for next events
+     - Initialize pointers to NULL
+     - Fill also MDCA
+
+	
+ 2004/05/14  Javier Rico
+   * library/MSrcPlace.[cc,h]
+     - added
+
+   * library/MSrcPosFromFile.[cc,h], library/MSrcRotate.[cc,h],
+     library/MSrcTranslate.[cc,h]
+     - inherit from MSrcPlace
+
+   * programs/srcPos.cc programs/srcpos.datacard
+     - adapt to new MSrcPlace class
+	
+   * library/Makefile, library/IFAELinkDef.h
+     - include MSrcPlace
+
+ 2004/05/13  Javier Rico
+   * macros/rotation.C
+     - added
+
+
+ 2004/05/13  Javier Lopez
+   * library/MCalibrateDC.[h,cc]
+     - Task to intercalibrate the dc response of the dc
+       current for all the pmts from a continuos light
+       run.
+
+ 2004/05/12: Javier Rico
+   * macros/alpha.C, macros/plotOptimal.C
+     - added
+
+   * library/MSrcRotate.[cc.h]
+     - correct bug in computation of run time for rotation
+	
+   * programs/srcPos.cc
+     - change mjdpos type to Double_t
+	
+	
+	
+ 2004/05/11: Javier Rico
+   * programs/optimizeCuts.cc, programs/optimizecuts.datacard
+     - added
+
+   * programs/Makefile
+     - include optimizeCuts
+
+   * programs/srcPos.cc, programs/srcpos.datacard
+     - add reference rotation angle
+
+	
+ 2004/05/11: Ester Aliu
+   *  macros/signal.cc 
+     - change some things
+   *  programs/falseSource.cc 
+     - change some mathematical functions to root equivalents 
+   *  programs/psffit.cc
+     - add <stdlib.h> library 
+
+ 2004/05/11: Ester Aliu 
+   * programs/makeHillas.cc, programs/makehillas.datacard
+     - add island calculations
+ 
+ 2004/05/11: Javier Rico
+   * programs/makeHillas.cc
+     - prevent it from bombing because of the mjobs
+
+
+ 2004/05/10: Javier Rico
+   * programs/Makefile
+     - specify libmars.so with absolute path
+
+	
+ 2004/05/07: Javier Rico
+   * programs/pedvsslices.cc
+     - added
+
+	
+ 2004/05/05: Ester Aliu
+   * library/MPSFFitCalc.cc library/MSrcRotate.cc
+     - change some mathematical functions to root equivalents 
+
+   * library/MIslands.[h,cc], library/MIslandCalc.[h,cc],
+    library/MIslandClean.[h,cc]
+     - added
+
+   * library/Makefile, library/IFAELinkDef.h
+     - add MIslands, MIslandCalc, MIslandClean
+ 
+ 2004/05/05: Javier Lopez
+   * library/MFHVNotNominal.[h,cc]
+     - filter to flag events(pixels) with non nominal hv
+ 
+   * macros/hvnotnominal.C
+     - macro to test MFHVNotNominal filter
+
+ 2004/05/05: Javier Rico
+   * library/MSrcTranslate.[h,cc]
+     - added
+
+   * library/Makefile, library/IFAELinkDef.h
+     - add MSrcTranslate
+
+   * library/MSrcRotate.[h.cc]
+     - adapted to changes in MObservatory and MAstro
+   
+   * programs/falseSource.cc programs/falsesource.datacard 
+     programs/srcPos.cc programs/srcpos.datacard
+     - added
+
+   * programs/Makefile
+     - add falseSource and srcPos
+
+   * macros/signal.C macros/signalPoint.C
+     - added
+	
+ 2004/05/03: Javier Rico
+   * makeHillas.cc
+     - put back Jobs for pedestal and calibration parts
+
+   * .rootrc
+     - added
+
+ 2004/05/03: Javier Rico
+   * library,programs,macros,*:
+     - new directories added
+     - directory macros contains macros (.C) and scripts (.sh)
+     - directory programs contains root compilables and associated
+       [input] files
+     - directory library contains routines to be linked with libmars.so
+	
+ 2004/04/30: Javier López
+   * alpha_plot.C
+     - macro to display hillas disttributions with corrected 
+       miss pointing
+
+   * srcPosRun.sh
+     - Script to produce the file with the positions of UMa51 using 
+       psffit executable
+
+   * MSrcPosFromFile.[h,cc]
+     - Tool to correct the position of the source for on and off data 
+       from a file
+ 
+   * psffit.C & psffit.cc
+     - Macro and executable to calculate the mean position of a star.
+
+   * MPSFFit.[h,cc] & MPSFFitCalc.[h,cc]
+     - Container and taks to do calculation of the psf and position of 
+       stars.
+
+ 2004/04/28: Javier Rico
+   * makeHillas.cc, makehillas.datacard
+     - Use MJPedestal and MJCalibration and simplified datacard
+
+   * Makefile
+     - include mjobs
+
+	
+ 2004/04/28: Javier Rico
+   * mifae/Changelog
+     - Added. Next changes in directory mifae will be reported 
+       exclusively in here
+
+	
+ 2004/04/27: Javier Rico
+   * mifae
+     - Add new directory for IFAE temporal stuff
+	
+   * mifae/Makefile,IFAEIncl.h,IFAELinkDef.h
+     - Add basic stuff to run the directory
+	
+   * mifae/MDCA.[h,cc]
+     - Add Commichau & Starks's MDCA (provisional)
+
+   * mifae/makeHillas.cc,makehillas.datacard
+     - Add program to generate hillas parameters' file
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/IFAEIncl.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/IFAEIncl.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/IFAEIncl.h	(revision 9661)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/IFAELinkDef.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/IFAELinkDef.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/IFAELinkDef.h	(revision 9661)
@@ -0,0 +1,28 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class MDisplay+;
+#pragma link C++ class MHillasDisplay+;
+#pragma link C++ class MPSFFit+;
+#pragma link C++ class MPSFFitCalc+;
+#pragma link C++ class MSrcPlace+;
+#pragma link C++ class MSrcPosFromFile+;
+#pragma link C++ class MSrcRotate+;
+#pragma link C++ class MSrcTranslate+;
+#pragma link C++ class MIslands+;
+#pragma link C++ class MIslandCalc+;
+#pragma link C++ class MIslandClean+;
+#pragma link C++ class MFHVNotNominal+;
+#pragma link C++ class MCalibrateDC+;
+#pragma link C++ class MHPSFFromStars+;
+#pragma link C++ class MControlPlots+;
+#pragma link C++ class MDisp+;
+#pragma link C++ class MDispCalc+;
+#pragma link C++ class MSrcPosFromStars+;
+#pragma link C++ class MLiveTime+;
+#pragma link C++ class MLiveTimeCalc+;
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MCalibrateDC.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MCalibrateDC.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MCalibrateDC.cc	(revision 9661)
@@ -0,0 +1,272 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!   Author(s): Javier López , 5/2004 <mailto:jlopez@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MCalibrateDC
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCalibrateDC.h"
+
+#include <TString.h>
+#include <TH1F.h>
+#include <TF1.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MGeomCam.h"
+#include "MGeomPix.h"
+#include "MCameraDC.h"
+#include "MTime.h"
+
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MEvtLoop.h"
+
+#include "MReadReports.h"
+#include "MGeomApply.h"
+
+ClassImp(MCalibrateDC);
+using namespace std;
+
+MCalibrateDC::MCalibrateDC(TString filename, const char *name, const char *title) 
+{
+  fName  = name  ? name  : "MCalibrateDC";
+  fTitle = title ? title : "Taks to intercalibrate the DC of all pmts from a continuos light run";
+
+  fFileName = filename;
+  
+  fStartingMissCalibration.Set(2004,3,8);
+  fEndingMissCalibration.Set(2004,4,15);
+  
+  Int_t   nbins = 120;
+  Float_t min = 0;
+  Float_t max = 30.;
+  fCalHist = new TH1F("calhist","",nbins,min,max);
+
+  fDCCalibration = 1.;
+  fDCCalibrationRMS = 0.;
+
+  fDCMissCalibrationFactor = 30./40.95;
+}
+MCalibrateDC::~MCalibrateDC()
+{
+  delete  fCalHist;
+}
+
+Int_t MCalibrateDC::PreProcess(MParList *pList)
+{
+
+    fGeomCam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
+
+    if (!fGeomCam)
+    {
+      *fLog << err << AddSerialNumber("MGeomCam") << " not found ... aborting" << endl;
+      return kFALSE;
+    }
+
+    // Initialization of objects that need the information from MGeomCam
+    fDisplay.SetGeometry(*fGeomCam);
+    fNumPixels = fGeomCam->GetNumPixels();
+
+    fCurr = (MCameraDC*)pList->FindObject(AddSerialNumber("MCameraDC"));
+
+    if (!fCurr)
+    {
+      *fLog << err << AddSerialNumber("MCameraDC") << " not found ... aborting" << endl;
+      return kFALSE;
+    }
+
+    fTimeCurr = (MTime*)pList->FindObject(AddSerialNumber("MTimeCurrents"));
+
+    if (!fTimeCurr)
+    {
+      *fLog << err << AddSerialNumber("MTimeCurrents") << " not found ... aborting" << endl;
+      return kFALSE;
+    }
+
+    // Run over the continuos light run to get the DC intercalibration factors
+    fDCCalibrationFactor.Set(fNumPixels);
+    fDCCalibrationFactor.Reset(1.);
+
+    if ( fFileName != "" )
+      {
+        ProcessFile();
+        DCCalibrationCalc();
+ 
+        UInt_t numPixelsSetUnsuedForDC = 0;
+        
+        for (UInt_t pix=1; pix<fNumPixels; pix++)
+          {
+            if (fDisplay.GetBinContent(pix+1) > fMinDCAllowed)
+              fDCCalibrationFactor[pix] = fDCCalibration/fDisplay.GetBinContent(pix+1);
+            else
+              {
+                numPixelsSetUnsuedForDC++;
+                fDCCalibrationFactor[pix] = 0.; //FIXME: Maybe to introduce a setunused in MCameraDC ?
+              }
+          }
+
+        *fLog << inf << GetName() << " set unused " << numPixelsSetUnsuedForDC << " because too low dc." << endl;
+        
+      }
+
+    return kTRUE;
+}
+
+Int_t MCalibrateDC::Process()
+{
+
+  if (*fTimeCurr >= fStartingMissCalibration && *fTimeCurr <= fEndingMissCalibration)
+    {
+      for (UInt_t pix=1; pix<fNumPixels; pix++)
+        {
+          MGeomPix& pixel = (*fGeomCam)[pix];
+          if (pixel.GetSector() >=3 && pixel.GetSector() <=5)
+            (*fCurr)[pix] *= fDCCalibrationFactor[pix]*fDCMissCalibrationFactor;
+          else
+            (*fCurr)[pix] *= fDCCalibrationFactor[pix];
+
+        }
+    }
+  else
+    for (UInt_t pix=1; pix<fNumPixels; pix++)
+      (*fCurr)[pix] *= fDCCalibrationFactor[pix];
+	  
+  return kTRUE;
+}
+
+Bool_t MCalibrateDC::ProcessFile()
+{
+
+    MParList plist;
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    MCameraDC     dccam;
+    plist.AddToList(&dccam);
+
+    // Reads the trees of the root file and the analysed branches
+    MReadReports read;
+    read.AddTree("Currents"); 
+    read.AddFile(fFileName);     // after the reading of the trees!!!
+    read.AddToBranchList("MReportCurrents.*");
+    
+    MGeomApply geomapl;
+
+    tlist.AddToList(&geomapl);
+    tlist.AddToList(&read);
+
+    // Enable logging to file
+    //*fLog.SetOutputFile(lname, kTRUE);
+
+    //
+    // Execute the eventloop
+    //
+    MEvtLoop evtloop(fName);
+    evtloop.SetParList(&plist);
+    evtloop.SetLogStream(fLog);
+
+    // Execute first analysis
+      if (!evtloop.PreProcess())
+        {
+          *fLog << err << GetDescriptor() << ": Failed." << endl;
+	  return kFALSE;
+        }
+        
+      while (tlist.Process())
+        fDisplay.AddCamContent(dccam);
+        
+      evtloop.PostProcess();
+
+    tlist.PrintStatistics();
+
+    UInt_t numexecutions = read.GetNumExecutions();
+    UInt_t numPixels = fDisplay.GetNumPixels();
+    for (UInt_t pix = 1; pix <= numPixels; pix++)
+      fDisplay[pix] /= numexecutions;
+    
+
+    *fLog << inf << GetDescriptor() << ": Done." << endl;
+
+    return kTRUE;
+}
+
+Bool_t MCalibrateDC::DCCalibrationCalc()
+{
+
+   for (UInt_t pix=1; pix<fNumPixels; pix++)
+       fCalHist->Fill(fDisplay.GetBinContent(pix+1));
+
+   Float_t nummaxprobdc = fCalHist->GetBinContent(fCalHist->GetMaximumBin());
+   Float_t maxprobdc = fCalHist->GetBinCenter(fCalHist->GetMaximumBin());
+   UInt_t bin = fCalHist->GetMaximumBin();
+   do
+   {
+       bin++;
+   }
+   while(fCalHist->GetBinContent(bin)/nummaxprobdc > 0.5);
+   Float_t halfmaxprobdc = fCalHist->GetBinCenter(bin);
+
+   *fLog << dbg << " maxprobdc[high] " << maxprobdc << "[" << nummaxprobdc << "] ";
+   *fLog << dbg << " halfmaxprobdc[high] " << halfmaxprobdc << "[" << fCalHist->GetBinContent(bin) << "]" << endl;
+
+   Float_t rmsguess = TMath::Abs(maxprobdc-halfmaxprobdc);
+   Float_t min = maxprobdc-3*rmsguess;
+   min = (min<0.?0.:min);
+   Float_t max = maxprobdc+3*rmsguess;
+
+   *fLog << dbg << " maxprobdc " << maxprobdc << " rmsguess " << rmsguess << endl;
+
+   TF1 func("func","gaus",min,max);
+   func.SetParameters(nummaxprobdc, maxprobdc, rmsguess);
+   
+   fCalHist->Fit("func","QR0");
+
+   UInt_t aproxnumdegrees = 6*(bin-fCalHist->GetMaximumBin());
+   Float_t chiq = func.GetChisquare();
+   fDCCalibration = func.GetParameter(1);
+   fDCCalibrationRMS = func.GetParameter(2);
+
+   *fLog << dbg << " fDCCalibration " << fDCCalibration << " fDCCalibrationRMS " << fDCCalibrationRMS << " chiq/ndof " << chiq << "/" << aproxnumdegrees << endl;
+
+   Int_t numsigmas = 5;
+   Axis_t minbin = fDCCalibration-numsigmas*fDCCalibrationRMS/fCalHist->GetBinWidth(1);
+   minbin=minbin<1?1:minbin;
+   Axis_t maxbin = fDCCalibration+numsigmas*fDCCalibrationRMS/fCalHist->GetBinWidth(1);
+   *fLog << dbg << " Number of pixels with dc under " << numsigmas << " sigmas = " << fCalHist->Integral((int)minbin,(int)maxbin) << endl;
+
+    //Check results from the fit are consistent
+    if (TMath::Abs(fDCCalibration-maxprobdc) > rmsguess || fDCCalibrationRMS > rmsguess)
+      {
+        *fLog << warn << GetName() << " Calibration DC fit give non consistent results." << endl;
+        *fLog << warn << " maxprobdc " << maxprobdc << " rmsguess " << rmsguess << endl;
+        *fLog << warn << " fDCCalibration " << fDCCalibration << " fDCCalibrationRMS " << fDCCalibrationRMS << " chiq/ndof " << chiq << "/" << aproxnumdegrees << endl;
+        fDCCalibration = maxprobdc;
+        fDCCalibrationRMS = rmsguess/1.175; // FWHM=2.35*rms
+      }
+
+   return kTRUE;
+}
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MCalibrateDC.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MCalibrateDC.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MCalibrateDC.h	(revision 9661)
@@ -0,0 +1,76 @@
+#ifndef MARS_MCalibrateDC
+#define MARS_MCalibrateDC
+
+#ifndef ROOT_TArrayD
+#include <TArrayD.h>
+#endif
+
+#ifndef ROOT_TString
+#include <TString.h>
+#endif
+
+#ifndef MARS_MHCamera
+#include "MHCamera.h"
+#endif
+
+#ifndef MARS_MTime
+#include "MTime.h"
+#endif
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class TH1F;
+class MGeomCam;
+class MCameraDC;
+
+class MCalibrateDC : public MTask
+{
+
+private:
+
+    MGeomCam      *fGeomCam;
+    MCameraDC     *fCurr;
+    MTime         *fTimeCurr;
+
+    MTime fStartingMissCalibration;
+    MTime fEndingMissCalibration;
+    
+    TString fFileName;
+    
+    TH1F *fCalHist;
+    MHCamera fDisplay;
+
+    Double_t fMinDCAllowed; //[uA]
+    
+    UInt_t fNumPixels ;
+    TArrayD  fDCCalibrationFactor;
+    Double_t fDCMissCalibrationFactor;
+    
+    Double_t fDCCalibration; //[uA]
+    Double_t fDCCalibrationRMS; //[uA]
+    
+    Bool_t ProcessFile();
+    Bool_t DCCalibrationCalc();
+    
+  public:
+    
+    MCalibrateDC(TString filename="", const char *name=NULL, const char *title=NULL);
+    ~MCalibrateDC();
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
+    //Setters
+    void SetFileName(TString filename="") {fFileName=filename;}
+    void SetMinDCAllowed(Double_t mindc=0.5) {fMinDCAllowed=mindc;}
+    
+    //Getters
+    MHCamera& GetDisplay() { return fDisplay; }
+    TArrayD&  GetDCCalibrationFactor() { return fDCCalibrationFactor; }
+
+    ClassDef(MCalibrateDC, 0) // Taks to intercalibrate the DC of all pmts from a continuos light run
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MControlPlots.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MControlPlots.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MControlPlots.cc	(revision 9661)
@@ -0,0 +1,212 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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 Rico     04/2004 <mailto:jrico@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// MControlPlots
+//
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <fstream>
+
+#include "TStyle.h"
+
+#include "MParList.h"
+#include "MControlPlots.h"
+#include "MIslands.h"
+#include "MHCamera.h"
+#include "MGeomCamMagic.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MControlPlots);
+
+using namespace std;
+
+static const TString gsDefName  = "MControlPlots";
+static const TString gsDefTitle = "Produce some control plots";
+
+// -------------------------------------------------------------------------
+//
+// Constructor
+//
+MControlPlots::MControlPlots(TString filename,const char* name, const char* title)
+  : fMode(kOn), fFileName(filename), fGeomCam(NULL), fIslands(NULL), fProduceFile(kTRUE)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+
+    fCameraHisto[kOn] = NULL;
+    fCameraHisto[kOff] = NULL;
+}
+// -------------------------------------------------------------------------
+//
+// Destructor
+//
+MControlPlots::~MControlPlots()
+{
+  if(fGeomCam)
+    delete fGeomCam;
+
+  if(fCameraHisto[kOn])
+    delete fCameraHisto[kOn];
+  if(fCameraHisto[kOff])
+    delete fCameraHisto[kOff];
+}
+
+
+// -------------------------------------------------------------------------
+//
+// Look for needed containers.
+//
+Int_t MControlPlots::PreProcess(MParList* pList)
+{ 
+  // FIXME! only valid for Magic geometry for the time being!
+  fGeomCam = new MGeomCamMagic;
+
+  // look for MIslands object
+  fIslands = (MIslands*)pList->FindObject("MIslands");
+  if (!fIslands)
+    *fLog << warn << AddSerialNumber("MIslands") << " [MIslands] not found... Some control plots will not be produced" << endl;
+  else
+    fCameraHisto[fMode] = new MHCamera(*fGeomCam,"Survive","Pixels surviving Image Cleaning");
+
+  return kTRUE;
+}
+
+// -------------------------------------------------------------------------
+//
+//
+Int_t MControlPlots::Process()
+{  
+  if(!fIslands) return kTRUE;
+
+  for (UInt_t i=0;i<fGeomCam->GetNumPixels();i++)
+    {
+      //      cout << fIslands->GetIslId(i) << " ";
+      if (fIslands->GetIslId(i)>=0)
+	{
+	  fCameraHisto[fMode]->Fill(i,1);
+	  fCameraHisto[fMode]->SetUsed(i);
+	}
+    }
+  //  cout << endl;
+  return kTRUE;
+}
+
+// -------------------------------------------------------------------------
+//
+//
+Int_t MControlPlots::PostProcess()
+{
+  fCameraHisto[fMode]->SetEntries(fGeomCam->GetNumPixels());
+
+  if(!fProduceFile) return kTRUE;
+  if(fProduceFile && !fFileName.Length())
+    {
+      *fLog << warn <<  "MControlPlots::PostProcess Warning: output file requested but no name for it" << endl;
+      return kTRUE;
+    }
+
+  // Canvas style
+  gStyle->SetCanvasColor(0);
+  gStyle->SetCanvasBorderMode(0);
+  gStyle->SetPadBorderMode(0);
+  gStyle->SetFrameBorderMode(0);
+  gStyle->SetStatColor(0);
+  gStyle->SetTitleFillColor(0);
+
+  TCanvas* c = new TCanvas("survivals","Pixels surviving Image Cleaning",800,800);
+  MHCamera* diff=NULL;
+
+  // in case both on and off histos are present, print both and the difference between them
+  if(fCameraHisto[kOn] && fCameraHisto[kOff])
+    {      
+      diff = new MHCamera(*fGeomCam,"Diff","Pixels surviving Image Cleaning");
+
+      // Normalize Off to On
+      Float_t NormOn=0;
+      Float_t NormOff=0;
+      for(Int_t i=1;i<diff->GetSize()-2;i++)
+	{
+	  NormOff+=fCameraHisto[kOff]->GetBinContent(i);
+	  NormOn+=fCameraHisto[kOn]->GetBinContent(i);
+	}      
+
+      fCameraHisto[kOff]->Scale(NormOn/NormOff);
+
+      for(Int_t i=1;i<diff->GetSize()-2;i++)
+	{
+	  diff->SetBinContent(i,(Double_t)fCameraHisto[kOn]->GetBinContent(i)-fCameraHisto[kOff]->GetBinContent(i));
+	  diff->SetUsed(i);
+	}      
+      fCameraHisto[kOn]->SetPrettyPalette();
+      fCameraHisto[kOff]->SetPrettyPalette();
+      diff->SetPrettyPalette();
+
+      c->Divide(2,2);
+
+      Float_t max = TMath::Max(fCameraHisto[kOn]->GetMaximum(),fCameraHisto[kOff]->GetMaximum());
+      Float_t min = TMath::Min(fCameraHisto[kOn]->GetMinimum(),fCameraHisto[kOff]->GetMinimum());
+      fCameraHisto[kOn]->SetMaximum(max);
+      fCameraHisto[kOn]->SetMinimum(min); 
+      fCameraHisto[kOff]->SetMaximum(max);
+      fCameraHisto[kOff]->SetMinimum(min); 
+      
+      c->cd(1);
+      fCameraHisto[kOn]->Draw();
+      gPad->Modified();
+      gPad->Update();
+
+      c->cd(2);
+      fCameraHisto[kOff]->Draw();
+      gPad->Modified();
+      gPad->Update();
+
+      c->cd(3);
+      diff->Draw();
+      gPad->Modified();
+      gPad->Update();      
+
+      c->cd(4);
+      diff->DrawProjection();
+      gPad->Modified();
+      gPad->Update();
+    }
+  // plot the existing histo
+  else
+    {
+      c->cd(1);
+      fCameraHisto[fMode]->Draw();
+      gPad->Modified();
+      gPad->Update();
+    }
+  
+  c->SaveAs(fFileName);
+  delete c;  
+  if(diff)
+    delete diff;
+  return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MControlPlots.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MControlPlots.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MControlPlots.h	(revision 9661)
@@ -0,0 +1,43 @@
+#ifndef MARS_MControlPlots
+#define MARS_MControlPlots
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class TString;
+class MIslands;
+class MGeomCam;
+class MHCamera;
+
+class MControlPlots : public MTask
+{
+ public:
+  enum OnOffMode_t {kOn=0,kOff};
+  
+ private:
+  OnOffMode_t  fMode;           // On/Off data mode 
+  TString      fFileName;       // name of the ps file
+  MGeomCam*    fGeomCam;        // pointer to camera geometry object
+  MIslands*    fIslands;        // pointer to the island object
+  MHCamera*    fCameraHisto[2]; // pointer to camera histos
+  Bool_t       fProduceFile;    // flag to produce the ouput (ps) file
+  
+  Int_t PreProcess(MParList *plist);
+  Int_t Process();
+  Int_t PostProcess();
+
+ public:
+  MControlPlots(TString filename="",const char* name=NULL, const char* title=NULL);
+
+  virtual ~MControlPlots();
+
+  void SetFilename(TString fname)           {fFileName=fname;}
+  void SetMode(OnOffMode_t mode)            {fMode=mode;}
+  void SetProduceFile(Bool_t mod=kTRUE)     {fProduceFile=mod;}  
+
+  ClassDef(MControlPlots, 0) // task to produce some control plots
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MDisp.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MDisp.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MDisp.cc	(revision 9661)
@@ -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): Eva Domingo  02/2004 <mailto:domingo@ifae.es>
+!   Author(s): Josep Flix   02/2004 <mailto:jflix@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MDisp
+//
+// Storage Container for image parameters
+//
+//    Disp method for extended sources analysis related image parameters
+//
+//
+// Version 1:
+// ----------
+//  fDisp          Distance along the major axis from the centroid to the suspected position of the source
+//  fPosDisp1      Position of Disp evaluated point 1 in the camera in [mm]
+//  fPosDisp2      Position of Disp evaluated point 2 in the camera in [mm]
+//
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MDisp.h"
+
+#include <iostream>
+//#include <TArrayF.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+using namespace std;
+ClassImp(MDisp);
+
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MDisp::MDisp(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MDisp";
+    fTitle = title ? title : "Parameter related to Disp method for extended sources analysis";
+
+}
+
+void MDisp::SetPosDisp(char *var, Float_t value)
+{
+
+    if ( !strcmp(var,"X1") )
+	fX1 = value;
+    else if ( !strcmp(var,"Y1") )
+	fY1 = value;
+    else if ( !strcmp(var,"X2") )
+	fX2 = value;
+    else if ( !strcmp(var,"Y2") )
+	fY2 = value;  
+    else
+	cout << "SetPosDisp:: Coordinate argument WRONG!" << endl;
+
+};
+
+
+Float_t MDisp::GetPosDisp(char *var)
+{
+
+    if ( !strcmp(var,"X1") )
+	return fX1;
+    else if ( !strcmp(var,"Y1") )
+	return fY1;
+    else if ( !strcmp(var,"X2") )
+	return fX2;
+    else if ( !strcmp(var,"Y2") )
+	return fY2;  
+    else
+    {
+	cout << "GetPosDisp:: Coordinate argument WRONG!" << endl;
+	return -9999.;
+    }
+};
+
+
+void MDisp::Print(Option_t *opt) const
+{
+      *fLog << all << GetDescriptor() << ":" << endl;
+      *fLog << "Disp [mm] = " << fDisp << ": ";
+      *fLog << "DX1 [mm] = " << fX1 << ": ";
+      *fLog << "DY1 [mm] = " << fY1 << ": ";
+      *fLog << "DX2 [mm] = " << fX2 << ": ";
+      *fLog << "DY2 [mm] = " << fY2 << ": ";
+      *fLog << "PsiEvent[mm] =" << fPsiEvent << ": " << endl;  
+};
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MDisp.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MDisp.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MDisp.h	(revision 9661)
@@ -0,0 +1,47 @@
+#ifndef MARS_MDisp
+#define MARS_MDisp
+
+#ifndef MARS_MSrcPosCam
+#include "MSrcPosCam.h"
+#endif
+
+class MSrcPosCam;
+
+class MDisp : public MParContainer
+{
+private:
+
+    Float_t fX1; // Position of Disp evaluated point 1 in the camera in [mm]
+    Float_t fY1;
+
+    Float_t fX2; // Position of Disp evaluated point 2 in the camera in [mm]
+    Float_t fY2;
+
+    Float_t fDisp;                // [mm]  distance along the major axis from the centroid
+                                  //       to the suspected position of the source 
+    Float_t fPsi;                 // [mm]  Psi Disp parameter (has to fixed before Disp calculations,
+                                  //                      used for fPosDisp1, fPosDisp2, fDisp determination)
+
+    Float_t fPsiEvent;            // [mm]  Psi Disp parameter evaluated for every event (uses fSrcPos as Disp)
+
+
+public:
+
+    MDisp(const char *name=NULL, const char *title=NULL);
+
+    Float_t GetPosDisp(char *var);
+    Float_t GetDisp()               { return fDisp; } 
+    Float_t GetPsi()                { return fPsi; } 
+    Float_t GetPsiEvent()           { return fPsiEvent; } 
+
+    void SetPosDisp(char *var, Float_t value);
+    void SetDisp(Float_t disp)                { fDisp=disp; } 
+    void SetPsi(Float_t psi)                  { fPsi=psi; } 
+    void SetPsiEvent(Float_t psievent)        { fPsiEvent=psievent; } 
+
+    void Print(Option_t *opt=NULL) const;
+
+    ClassDef(MDisp, 1) // Container to hold disp related parameters
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MDispCalc.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MDispCalc.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MDispCalc.cc	(revision 9661)
@@ -0,0 +1,129 @@
+#include "MDispCalc.h"
+
+#include "MParList.h"
+
+#include "MDisp.h"
+#include "MHillas.h"
+#include "MHillasSrc.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MDispCalc);
+
+using namespace std;
+
+static const TString gsDefName  = "MDispCalc";
+static const TString gsDefTitle = "Calculate Disp related parameters";
+
+// -------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MDispCalc::MDispCalc(const char *name, const char *title)
+    : fHillas(NULL), fHillasSrc(NULL), fSrcPos(NULL), fDisp(NULL)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+
+}
+
+// -------------------------------------------------------------------------
+//
+Int_t MDispCalc::PreProcess(MParList *pList)
+{
+
+    fHillas = (MHillas*)pList->FindObject("MHillas");
+    if (!fHillas)
+    {
+        *fLog << err << dbginf << "MHillas not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fHillasSrc = (MHillasSrc*)pList->FindObject("MHillasSrc");
+    if (!fHillasSrc)
+    {
+        *fLog << err << dbginf << "MHillasSrc not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fSrcPos = (MSrcPosCam*)pList->FindObject("MSrcPosCam");
+    if (!fSrcPos)
+    {
+        *fLog << err << dbginf << "SrcPosCam not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fDisp = (MDisp*)pList->FindCreateObj("MDisp");
+    if (!fDisp)
+        return kFALSE;
+ 
+    return kTRUE;
+}
+
+// -------------------------------------------------------------------------
+//
+Int_t MDispCalc::Process()
+{
+
+    fDisp->SetPsi(fPsi);
+
+    if ( fHillas->GetWidth()==-1 || fHillas->GetLength()==-1 )
+      {
+	fErrors++;
+	return kTRUE;
+      }
+
+    Float_t xshift = 0.;
+    Float_t yshift = 0.;
+
+    if ( fSrcPos )
+      {
+	xshift = fSrcPos->GetX();
+	yshift = fSrcPos->GetY();
+      }
+
+    fDisp->SetDisp(fPsi*(1-(fHillas->GetWidth()/fHillas->GetLength())));
+    fDisp->SetPosDisp("X1", fHillas->GetMeanX() - (fDisp->GetDisp()*fHillas->GetCosDelta()) - xshift);
+    fDisp->SetPosDisp("Y1", fHillas->GetMeanY() - (fDisp->GetDisp()*fHillas->GetSinDelta()) - yshift);
+    fDisp->SetPosDisp("X2", fHillas->GetMeanX() + (fDisp->GetDisp()*fHillas->GetCosDelta()) - xshift);
+    fDisp->SetPosDisp("Y2", fHillas->GetMeanY() + (fDisp->GetDisp()*fHillas->GetSinDelta()) - yshift);
+
+    if ( (1-fHillas->GetWidth()/fHillas->GetLength()) == 0. )
+      {
+	fErrors++;
+	return kTRUE;
+      }
+
+    fDisp->SetPsiEvent(fHillasSrc->GetDist()/(1-fHillas->GetWidth()/fHillas->GetLength()));
+
+    fDisp->SetReadyToSave();
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Prints some statistics about the disp calculation. The percentage
+//  is calculated with respect to the number of executions of this task.
+//
+Int_t MDispCalc::PostProcess()
+{
+    if (GetNumExecutions()==0)
+        return kTRUE;
+
+    *fLog << inf << endl;
+    *fLog << GetDescriptor() << " execution statistics:" << endl;
+    *fLog << dec << setfill(' ');
+    *fLog << " " << fErrors << " (" << (int)(fErrors*100/GetNumExecutions()) << "%) Evts skipped due to: (1-w/l)==0 or (Width or Length == -1)" << endl;
+    *fLog << endl;
+
+    /*
+    delete fHillas;
+    delete fHillasSrc;
+    delete fSrcPos;
+    delete fDisp;
+    */
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MDispCalc.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MDispCalc.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MDispCalc.h	(revision 9661)
@@ -0,0 +1,45 @@
+#ifndef MARS_MDispCalc
+#define MARS_MDispCalc
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+#ifndef MARS_MSrcPosCam
+#include "MSrcPosCam.h"
+#endif
+
+class MHillas;
+class MHillasSrc;
+class MDisp;
+class MSrcPosCam;
+
+class MDispCalc : public MTask
+{
+private:
+
+    MHillas    *fHillas;     //! Pointer to the source independent hillas parameters
+    MHillasSrc *fHillasSrc;  //! Pointer to the source dependent hillas parameters
+    MSrcPosCam *fSrcPos;     //! Pointer to the source position
+    MDisp *fDisp; 
+
+    Float_t fPsi;                 // [mm]  Psi Disp parameter (has to fixed before Disp calculations,
+                                  //                      used for fPosDisp1, fPosDisp2, fDisp determination)
+    
+    Int_t       fErrors;
+
+    Int_t PreProcess(MParList *plist);
+    Int_t Process();
+    Int_t PostProcess();
+
+public:
+
+    MDispCalc(const char *name=NULL, const char *title=NULL);
+    
+    void SetSrcPos(Float_t xpos, Float_t ypos) {fSrcPos->SetXY(xpos,ypos);}
+    void SetPsi(Float_t psi) {fPsi = psi;}
+
+    ClassDef(MDispCalc, 0) // task to calculate the Disp parameter and related positions
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MDisplay.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MDisplay.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MDisplay.cc	(revision 9661)
@@ -0,0 +1,151 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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 Rico     05/2004 <mailto:jrico@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// MDisplay
+//
+// Class to display camera events (MCamEvent)
+// You can set an event-by-event display with pause between two consecutive 
+// events. You can set an output PS file.
+//
+// Input containers (to be provided to the constructor):
+//
+//  MCamEvent
+//  MGeomCam
+//
+// Output containers:
+//
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <fstream>
+#include <math.h>
+
+#include "TCanvas.h"
+#include "TPostScript.h"
+
+#include "MParList.h"
+#include "MDisplay.h"
+#include "MCamEvent.h"
+#include "MGeomCam.h"
+#include "MHCamera.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MDisplay);
+
+using namespace std;
+
+static const TString gsDefName       = "MDisplay";
+static const TString gsDefTitle      = "Camera display task";
+static const TString gsDefPSFileName = "display.ps";
+
+// -------------------------------------------------------------------------
+//
+// Constructor. Need to provide the MCamEvent container to be displayed <event>
+// and camera geometry <geom>. Also the display type <type> can be specified
+// (see the MHCamera documentation for more details)
+//
+MDisplay::MDisplay(MCamEvent* event, MGeomCam* geom, Int_t type, const char* name, const char* title) 
+  :  fGeomCam(geom), fCamEvent(event),  fCanvas(NULL), fPSFile(NULL), fDisplayType(type), fCreatePSFile(kFALSE), fPause(kTRUE)
+{
+  fName  = name  ? name  : gsDefName.Data();
+  fTitle = title ? title : gsDefTitle.Data();
+
+  fDisplay = new MHCamera(*geom);
+  fDisplay->SetPrettyPalette();
+  
+  fPSFileName = gsDefPSFileName;
+}
+// -------------------------------------------------------------------------
+//
+// Destructor
+//
+MDisplay::~MDisplay()
+{
+  delete fDisplay;
+  if(fCanvas)
+    delete fCanvas;
+  if(fPSFile)
+    delete fPSFile;
+}
+
+// -------------------------------------------------------------------------
+//
+// Create the canvas, eventually set the batch mode and open ps file
+//
+Int_t MDisplay::PreProcess(MParList* pList)
+{ 
+  fCanvas = new TCanvas("myCanvas","Event Display",600,600);
+  if(fCreatePSFile) 
+    fPSFile = new TPostScript(fPSFileName,111);
+  if(!fPause)
+    fCanvas->SetBatch();
+  fCanvas->cd(1);
+  fDisplay->Draw();
+
+  return kTRUE;
+}
+
+// -------------------------------------------------------------------------
+//
+// Set the new containt of the camera event and update the display.
+// Set new page if ps file is requested
+// Pause execution if event-by-event display is chosen
+//
+Int_t MDisplay::Process()
+{  
+  // new page in ps file
+  if(fPSFile)
+    fPSFile->NewPage();
+
+  // update the display contents
+  fDisplay->SetCamContent(*fCamEvent);
+  fCanvas->GetPad(1)->Modified();
+  fCanvas->GetPad(1)->Update();
+
+  // pause execution
+  if(fPause)
+    {
+      cout << "Type 'q' to exit, <return> to go on: ";      
+      TString input;
+      input =cin.get(); 
+      
+      if (input=='q')
+	return kFALSE;
+    }
+
+  return kTRUE;
+}
+
+// -------------------------------------------------------------------------
+//
+// Close ps file if it was open
+//
+Int_t MDisplay::PostProcess()
+{
+  if(fPSFile) fPSFile->Close();
+  return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MDisplay.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MDisplay.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MDisplay.h	(revision 9661)
@@ -0,0 +1,53 @@
+#ifndef MARS_MDisplay
+#define MARS_MDisplay
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MHCamera;
+class MCamEvent;
+class MGeomCam;
+class TCanvas;
+class TPostScript;
+
+class MDisplay : public MTask
+{
+ private:
+  MHCamera*     fDisplay;      // pointer to the camera display
+  MGeomCam*     fGeomCam;      // pointer to the camera geometry
+  MCamEvent*    fCamEvent;     // pointer to camera event
+  TCanvas*      fCanvas;       // pointer to the canvas
+  TPostScript*  fPSFile;       // pointer to ps file
+  TString       fPSFileName;   // name for ps file
+  Int_t         fDisplayType;  // display type (see MHCamera)
+  Bool_t        fCreatePSFile; // flag to produce a ps file with events
+  Bool_t        fPause;        // flag to pause execution between events
+  
+
+  virtual Int_t PostProcess();
+
+ protected:
+  virtual Int_t PreProcess(MParList *plist);  
+  virtual Int_t Process();
+
+ public:
+  MDisplay(MCamEvent* event, MGeomCam* geom, Int_t type=0, const char* name=NULL, const char* title=NULL);
+  virtual ~MDisplay();
+
+  virtual void Paint(Option_t* option)     {};
+
+  MGeomCam*    GetGeomCam()                {return fGeomCam;}
+  Bool_t       GetPauseMode()              {return fPause;}
+  Bool_t       GetCreatePSFile()           {return fCreatePSFile;}
+
+  void         SetDisplayType(Int_t type)  {fDisplayType=type;}
+  void         SetPSFile(Bool_t set=kTRUE) {fCreatePSFile=set;}
+  void         SetPSFileName(TString name) {fPSFileName=name;}
+  void         SetPause(Bool_t set=kTRUE)  {fPause=set;}
+
+  ClassDef(MDisplay, 0) // Task to display camera containers
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MFHVNotNominal.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MFHVNotNominal.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MFHVNotNominal.cc	(revision 9661)
@@ -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): Javier Lopez 5/2004 <mailto:jlopez@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//   MFHVNotNominal
+//
+//   Filter to look if the HV monitored value is in agreement with the
+//   expected nominal value. If this is not true it sets a flag in MBadPixelsCam
+//   to not use this pixel in the analysis.
+//   Moreover if more than a certain number of pixels (set by defauld to 230) is
+//   deviated from the nominal value the event is rejected.
+//
+//  Input Containers:
+//   MCameraHV
+//
+//  Output Containers:
+//   MBadPixelsCam
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MFHVNotNominal.h"
+
+#include <fstream>
+#include <stdlib.h>
+
+#include <TMath.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+#include "MCameraHV.h"
+
+#include "MBadPixelsPix.h"
+#include "MBadPixelsCam.h"
+
+ClassImp(MFHVNotNominal);
+
+using namespace std;
+// --------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+MFHVNotNominal::MFHVNotNominal(const char *name, const char *title)
+  : fHV(NULL), fBadPixels(NULL), fHVConfFile("NULL"), fMaxHVDeviation(0.03), fMaxNumPixelsDeviated(230)
+{
+    fName  = name  ? name  : "MFHVNotNominal";
+    fTitle = title ? title : "Filter to reject events with too many pixels out of nominal HV";
+
+    fCut[0] = 0;
+    fCut[1] = 0;
+}
+
+// --------------------------------------------------------------------------
+//
+// The PreProcess searches for the following input containers:
+//  - MCameraHV
+//
+// The following containers are searched and created if they were not found:
+//  - MBadPixelsCam
+//
+Int_t MFHVNotNominal::PreProcess(MParList *pList)
+{
+  // 
+  // Containers that have to be there.
+  //
+    fHV = (MCameraHV*)pList->FindObject("MCameraHV");
+    if (!fHV)
+    {
+      *fLog << err << "MCameraHV not found... aborting." << endl;
+      return kFALSE;
+    }
+
+    // 
+    // Containers that are created in case that they are not there.
+    //
+    fBadPixels = (MBadPixelsCam*)pList->FindObject("MBadPixelsCam");
+    if (!fBadPixels)
+      {
+	*fLog << err << "Cannot find nor create MBadPixelsCam... aborting" << endl;
+	return kFALSE;
+      }
+
+    if (fHVConfFile != "NULL")
+      {
+        
+	const UInt_t npix = 577;
+	fHVNominal.Set(npix);
+
+	// Here we get the nominal HV values directitly from a CC 
+	// HV configuration file.
+	// Those files have the following structure:
+	//  [HV]
+	//  pixel_'hwnumber'='hvvalue'
+    
+	ifstream fin(fHVConfFile);
+    
+	TString str;
+	
+	if(!fin)
+	  {
+	    *fLog << err << "Imposible to open CC HV configuration file " << fHVConfFile << endl;
+	    return kFALSE;
+	  }
+	else
+	    *fLog << dbg << "Opened CC HV configuration file " << fHVConfFile << endl;
+
+	
+	fin >> str;
+	if(str != "[HV]")
+	  {
+	    *fLog << err << fHVConfFile << " file is not a CC HV configuration file" << endl;
+	    return kFALSE;
+	  }
+        else
+	    *fLog << dbg << fHVConfFile << " file is a good CC HV configuration file" << endl;
+
+	UInt_t npixinfile=0;
+	while(1)
+	  {
+	    fin >> str;
+	    if (fin.eof())
+	      break;
+
+	    UInt_t equalpos = str.Index("=");
+	    UInt_t underpos = str.Index("_");
+	    UInt_t length   = str.Length();
+
+	    TString tmp = str(underpos+1,equalpos-(underpos+1));
+	    UInt_t   hwpix = atoi((const char*)tmp);
+	    tmp = str(equalpos+1,length-(equalpos+1));
+	    Double_t value = atof((const char*)tmp);
+				  
+	    fHVNominal[hwpix-1]=value;
+	    npixinfile++;
+	  }
+	
+	fin.close();
+
+	if (npixinfile!=npix)
+	  {
+	    *fLog << err << fHVConfFile << " CC HV configuration file contain " << npixinfile << " pixels while the camera have " << npix << " pixels." << endl;
+	    return kFALSE;
+	  }	    
+      }
+
+    return kTRUE;
+}
+
+
+// ---------------------------------------------------------
+//
+// HVNotNominal rejection: 
+// 
+// Requiring less than fMaxHVDeviation deviation of HV monitored values
+// from nominal ones.
+// 
+// fMaxNumPixelsDeviated is set to 230 by default which is slightly higher 
+// than the number of outer pixels in MAGIC (for the case that 
+// the outer pixels have some defect).
+//
+Bool_t MFHVNotNominal::HVNotNominalRejection()
+{
+  UInt_t npix = fHVNominal.GetSize();
+
+  UInt_t notnominalpix = 0;
+
+  for (UInt_t idx=1; idx<npix; idx++)
+    {
+      Double_t hv = (*fHV)[idx];
+      Double_t nominal = fHVNominal[idx];
+      Double_t dev = 2.*TMath::Abs(nominal-hv)/(nominal+hv);
+      
+      if (dev > fMaxHVDeviation)
+	{
+	  MBadPixelsPix &bad = (*fBadPixels)[idx];
+	  bad.SetUnsuitable(MBadPixelsPix::kUnsuitableEvt);
+	  bad.SetHardware(MBadPixelsPix::kHVNotNominal);
+	  notnominalpix++;
+	}
+    }
+
+    if (notnominalpix!=0)
+      fCut[0]++;
+
+    //
+    // If the camera contains more than fMaxNumPixelsDeviated
+    // pixels with deviated HV, then the event is discarted.
+    //
+
+    return notnominalpix > fMaxNumPixelsDeviated;
+}
+
+// -----------------------------------------------------------
+//
+//  Compare the HV monitored valued with the HV nominal ones.
+//
+Int_t MFHVNotNominal::Process()
+{
+    fResult = HVNotNominalRejection();
+
+    if (fResult)
+      fCut[1]++;
+
+    return kTRUE;
+}
+
+Int_t MFHVNotNominal::PostProcess()
+{
+    if (GetNumExecutions()==0)
+        return kTRUE;
+
+    *fLog << inf << endl;
+    *fLog << GetDescriptor() << " execution statistics:" << endl;
+    *fLog << dec << setfill(' ');
+
+    *fLog << " " << setw(7) << fCut[0] << " (" << setw(3) ;
+    *fLog << (Int_t)(fCut[0]*100/GetNumExecutions()) ;
+    *fLog << "%) 'some not nominal pixel' events" << endl;
+
+    *fLog << " " << setw(7) << fCut[1] << " (" << setw(3) ;
+    *fLog << (Int_t)(fCut[1]*100/GetNumExecutions()) ;
+    *fLog << "%) rejected events" ;
+    *fLog << " (with fMaxNumPixelsDeviated = " << fMaxNumPixelsDeviated << ")" << endl;
+
+    return kTRUE;
+}
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MFHVNotNominal.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MFHVNotNominal.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MFHVNotNominal.h	(revision 9661)
@@ -0,0 +1,61 @@
+#ifndef MARS_MFHVNotNominal
+#define MARS_MFHVNotNominal
+
+#ifndef ROOT_TString
+#include <TString.h>
+#endif
+
+#ifndef ROOT_TArrayD
+#include <TArrayD.h>
+#endif
+
+#ifndef MARS_MFilter
+#include "MFilter.h"
+#endif
+
+class MCameraHV;
+class MBadPixelsCam;
+
+class MFHVNotNominal : public MFilter
+{
+private:
+    MCameraHV      *fHV;          // HV monitored values of all pixels in the camera
+    MBadPixelsCam  *fBadPixels;   // Bad Pixels storage container
+
+    TString fHVConfFile;
+    TArrayD fHVNominal;
+    Bool_t  fResult;
+
+    Float_t fMaxHVDeviation;         // Maximum HV deviation from nominal values in %.
+    Float_t fMaxNumPixelsDeviated;   // Maximum number of pixels with HV deviated from nominal values.
+
+    UInt_t fCut[2];
+
+    Int_t  PreProcess(MParList *pList);
+    Int_t  Process();
+    Int_t  PostProcess();
+
+    Bool_t HVNotNominalRejection();
+
+    Bool_t IsExpressionTrue() const { return fResult; }
+  
+public:
+    MFHVNotNominal(const char *name=NULL, const char *title=NULL);
+
+    void    SetHVNominalValues(const TString hvconf)    { fHVConfFile = hvconf; }
+    void    SetHVNominalValues(const TArrayD hvnominal) { fHVNominal  = hvnominal; }
+
+    void    SetMaxHVDeviation(const Float_t d)       { fMaxHVDeviation = d; }
+    void    SetMaxNumPixelsDeviated(const Float_t n) { fMaxNumPixelsDeviated = n; }
+
+    Float_t GetfMaxHVDeviation() const          { return fMaxHVDeviation; }
+    Float_t GetfMaxNumPixelsDeviated() const    { return fMaxNumPixelsDeviated; }
+    TArrayD GetHVNominal() const { return fHVNominal; }
+    
+    ClassDef(MFHVNotNominal, 0)   // Filter to filter the events with HV out of nominal values 
+};
+
+#endif
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MHPSFFromStars.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MHPSFFromStars.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MHPSFFromStars.cc	(revision 9661)
@@ -0,0 +1,476 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Javier López 05/2004 <mailto:jlopezs@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+/////////////////////////////////////////////////////////////////////////////
+//                                                               
+// MHPSFFromStars                                               
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MHPSFFromStars.h"
+
+#include <TVirtualPad.h>
+#include <TCanvas.h>
+#include <TPad.h>
+#include <TText.h>
+#include <TPaveText.h>
+#include <TF1.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MGeomCam.h"
+#include "MGeomPix.h"
+#include "MCameraDC.h"
+
+#include "MStarLocalCam.h"
+#include "MStarLocalPos.h"
+
+#include "MParList.h"
+
+ClassImp(MHPSFFromStars);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default Constructor. 
+//
+MHPSFFromStars::MHPSFFromStars(Int_t starpos, const char *name, const char *title)
+    : fGeom(NULL), fCurr(NULL), fSelectedStarPos(starpos)
+{
+    fName  = name  ? name  : "MHPSFFromStars";
+    fTitle = title ? title : "Class to fill the Point Spread Function histograms";
+
+    fNumEvents=0;
+
+    fHistMeanX.SetName("MeanX");
+    fHistMeanX.SetTitle("Mean X of the Fit");
+    fHistMeanX.SetDirectory(NULL);
+    fHistMeanX.UseCurrentStyle();
+    fHistMeanX.SetXTitle("Mean X [\\circ]");
+    fHistMeanX.SetYTitle("Counts [#]");
+    fHistMeanX.SetBins(800,-2.0,2.0);
+
+    fHistMeanY.SetName("MeanY");
+    fHistMeanY.SetTitle("Mean Y of the Fit");
+    fHistMeanY.SetDirectory(NULL);
+    fHistMeanY.UseCurrentStyle();
+    fHistMeanY.SetXTitle("Mean Y [\\circ]");
+    fHistMeanY.SetYTitle("Counts [#]");
+    fHistMeanY.SetBins(800,-2.0,2.0);
+
+    fHistSigmaMinor.SetName("SigmaMinor");
+    fHistSigmaMinor.SetTitle("Sigma X of the Fit");
+    fHistSigmaMinor.SetDirectory(NULL);
+    fHistSigmaMinor.UseCurrentStyle();
+    fHistSigmaMinor.SetXTitle("Sigma X [\\circ]");
+    fHistSigmaMinor.SetYTitle("Counts [#]");
+    fHistSigmaMinor.SetBins(160,0,0.8);
+    
+    fHistSigmaMajor.SetName("SigmaMajor");
+    fHistSigmaMajor.SetTitle("Sigma Y of the Fit");
+    fHistSigmaMajor.SetDirectory(NULL);
+    fHistSigmaMajor.UseCurrentStyle();
+    fHistSigmaMajor.SetXTitle("Sigma Y [\\circ]");
+    fHistSigmaMajor.SetYTitle("Counts [#]");
+    fHistSigmaMajor.SetBins(160,0,0.8);
+
+    fProjectionX.SetName("ProjetionX");
+    fProjectionX.SetTitle("Star projection in X axis");
+    fProjectionX.SetDirectory(NULL);
+    fProjectionX.UseCurrentStyle();
+    fProjectionX.SetXTitle("X [\\circ]");
+    fProjectionX.SetYTitle("DC [uA]");
+    fProjectionX.SetBins(16,-0.8,0.8);
+
+    fProjectionY.SetName("ProjetionY");
+    fProjectionY.SetTitle("Star projection in Y axis");
+    fProjectionY.SetDirectory(NULL);
+    fProjectionY.UseCurrentStyle();
+    fProjectionY.SetXTitle("Y [\\circ]");
+    fProjectionY.SetYTitle("DC [uA]");
+    fProjectionY.SetBins(16,-0.8,0.8);
+
+    fProfile.SetName("Profile");
+    fProfile.SetTitle("Star profile");
+    fProfile.SetDirectory(NULL);
+    fProfile.UseCurrentStyle();
+    fProfile.SetXTitle("X [\\circ]");
+    fProfile.SetYTitle("X [\\circ]");
+    fProfile.SetZTitle("DC [uA]");
+    fProfile.SetBins(16,-0.8,0.8,16,-0.8,0.8);
+
+    fvsTimeMeanX.Set(0);
+    fvsTimeMeanY.Set(0);
+    fvsTimeSigmaMinor.Set(0);
+    fvsTimeSigmaMajor.Set(0);
+
+    //  fTime.Set(0);
+    fEvent.Set(0);
+
+}
+
+MHPSFFromStars::~MHPSFFromStars()
+{
+  delete fGraphMeanX;
+  delete fGraphMeanY;
+  delete fGraphSigmaMinor;
+  delete fGraphSigmaMajor;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// TObject *MHPSFFromStars::lone(const char *) const
+// {
+//   MHPSFFromStars *hpsf = new MHPSFFromStars();
+  
+//   return hpsf;
+// }
+
+// --------------------------------------------------------------------------
+//
+// Gets the pointers to:
+//
+Bool_t MHPSFFromStars::SetupFill(const MParList *pList)
+{
+  
+  fGeom = (MGeomCam*)pList->FindObject("MGeomCam");
+  if (!fGeom)
+  {
+      *fLog << err << GetDescriptor() 
+            << ": MGeomCam not found... aborting." << endl;
+      return kFALSE;
+  }
+
+  TArrayC PixelsUsed;
+  PixelsUsed.Set(577);
+  PixelsUsed.Reset((Char_t)kTRUE);
+  fCamera.SetGeometry(*fGeom,"StarsDisplay","StarsDisplay");
+  fCamera.SetUsed(PixelsUsed);
+
+  fCurr = (MCameraDC*)pList->FindObject(AddSerialNumber("MCameraDC"));
+  
+  if (!fCurr)
+    {
+      *fLog << err << AddSerialNumber("MCameraDC") << " not found ... aborting" << endl;
+      return kFALSE;
+    }
+
+  return kTRUE;
+}
+
+//--------------------------------------------------------------------------------
+//
+//
+Bool_t MHPSFFromStars::Fill(const MParContainer *par, const Stat_t w)
+{
+  const UInt_t numPixels = fGeom->GetNumPixels();
+
+  MStarLocalCam* stars = (MStarLocalCam*)par;
+  if (!stars)
+    {
+      *fLog << err << "No argument in " << GetName() << "::Fill... abort." << endl;
+      return kFALSE;
+    }
+
+  //
+  MStarLocalPos* star = SelectStar(stars);
+  if (star == NULL)
+    return kCONTINUE;
+  
+
+  //Check good conditions of the fitting procedure
+  Float_t expectedStarXPos = star->GetMeanX();
+  Float_t expectedStarYPos = star->GetMeanY();
+
+  if ( star->GetChiSquareNdof() == 0 
+       || star->GetChiSquareNdof()>5.)
+//       || TMath::Sqrt(expectedStarXPos*expectedStarXPos+expectedStarYPos*expectedStarYPos)>150.)
+    {
+      *fLog << warn << "Star selected were bad reconstructed" << endl;
+      return kCONTINUE;
+    }
+  
+
+
+  //Fill Histograms
+  fHistMeanX.Fill(star->GetMeanX()*fGeom->GetConvMm2Deg());
+  fHistMeanY.Fill(star->GetMeanY()*fGeom->GetConvMm2Deg());
+  if (star->GetSigmaMinorAxis() < 0)
+    *fLog << err << GetName() << " Sigma of the fit " << star->GetSigmaMinorAxis() << " negative" << endl;
+  if (star->GetSigmaMajorAxis() < 0)
+    *fLog << err << GetName() << " Sigma of the fit " << star->GetSigmaMajorAxis() << " negative" << endl;
+  fHistSigmaMinor.Fill(star->GetSigmaMinorAxis()*fGeom->GetConvMm2Deg());
+  fHistSigmaMajor.Fill(star->GetSigmaMajorAxis()*fGeom->GetConvMm2Deg());
+  
+  fCamera.AddCamContent(*fCurr);
+  
+  //Selected star X(andY) projections
+  Float_t ringofinterest = 4*(star->GetSigmaMajorAxis()>star->GetSigmaMinorAxis()?star->GetSigmaMajorAxis():star->GetSigmaMinorAxis());
+
+  // First define a area of interest around the expected position of the star
+  for (UInt_t pix=1; pix<numPixels; pix++)
+    {
+      Float_t pixelXCenter = (*fGeom)[pix].GetX();
+      Float_t pixelYCenter = (*fGeom)[pix].GetY();
+      Float_t dist = TMath::Sqrt((pixelXCenter-expectedStarXPos)*(pixelXCenter-expectedStarXPos)+
+                          (pixelYCenter-expectedStarYPos)*(pixelYCenter-expectedStarYPos));
+      
+      if ((dist < ringofinterest))
+        {
+          fProjectionX.Fill((pixelXCenter-expectedStarXPos)*fGeom->GetConvMm2Deg(), (*fCurr)[pix]);
+          fProjectionY.Fill((pixelYCenter-expectedStarYPos)*fGeom->GetConvMm2Deg(), (*fCurr)[pix]);
+          //FIXME          fProfile.Fill((pixelXCenter-expectedStarXPos)*fGeom->GetConvMm2Deg(),(pixelYCenter-expectedStarYPos)*fGeom->GetConvMm2Deg(), (*fCurr)[pix]);
+        }
+    }
+  
+  
+  //
+  fvsTimeMeanX.Set(fNumEvents+1);
+  fvsTimeMeanY.Set(fNumEvents+1);
+  fvsTimeSigmaMinor.Set(fNumEvents+1);
+  fvsTimeSigmaMajor.Set(fNumEvents+1);
+  
+  //  fTime.Set(fNumEvents+1);
+  fEvent.Set(fNumEvents+1);
+
+  fvsTimeMeanX[fNumEvents] = star->GetMeanX()*fGeom->GetConvMm2Deg();
+  fvsTimeMeanY[fNumEvents] = star->GetMeanY()*fGeom->GetConvMm2Deg();
+  fvsTimeSigmaMinor[fNumEvents] = star->GetSigmaMinorAxis()*fGeom->GetConvMm2Deg();
+  fvsTimeSigmaMajor[fNumEvents] = star->GetSigmaMajorAxis()*fGeom->GetConvMm2Deg();
+
+  //  fTime[fNumEvents] = ?;
+  fEvent[fNumEvents] = fNumEvents;
+
+  fNumEvents++;
+  
+//   fGraphMeanX.SetPoint(fNumEvents,fNumEvents,star->GetMeanX()*fGeom->GetConvMm2Deg());
+//   fGraphMeanY.SetPoint(fNumEvents,fNumEvents,star->GetMeanY()*fGeom->GetConvMm2Deg());
+//   fGraphSigmaMinor.SetPoint(fNumEvents,fNumEvents,star->GetSigmaMinorAxis()*fGeom->GetConvMm2Deg());
+//   fGraphSigmaMajor.SetPoint(fNumEvents,fNumEvents,star->GetSigmaMajorAxis()*fGeom->GetConvMm2Deg());
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//
+Bool_t MHPSFFromStars::Finalize()
+{
+  *fLog << inf << GetName() << " Statistics: " << fNumEvents << " events" << endl;
+  //Fit  the profile plot with a gaussian(+baseline)
+
+  return kTRUE;
+}
+
+MStarLocalPos* MHPSFFromStars::SelectStar(MStarLocalCam* stars)
+{
+  TIter Next(stars->GetList());
+  MStarLocalPos* star = NULL;
+  MStarLocalPos* selectedStar = NULL;
+  
+  Float_t dist;
+  
+  if (fSelectedStarPos >= 0)
+    for (Int_t i=0; i<=fSelectedStarPos; i++)
+        star = (MStarLocalPos*)Next();
+  else //Look for the closer star to the center
+    {
+      Float_t mindist = 600; //mm
+      while ((star=(MStarLocalPos*)Next())) 
+        {
+          dist = TMath::Sqrt(star->GetMeanX()*star->GetMeanX() +
+                             star->GetMeanY()*star->GetMeanY());
+          if (dist < mindist)
+            {
+              selectedStar = star;
+              mindist = dist;
+            }
+        }
+      
+      star = selectedStar;
+      if (star == NULL)
+          *fLog << warn << "Not found star closer to center" << endl;
+      
+    }
+      
+  return star;
+}
+
+static Double_t fitfunc(Double_t *x, Double_t *par)
+{
+   Double_t fitval = 
+     par[0] + par[1]*TMath::Exp(-0.5*(x[0]-par[2])*(x[0]-par[2])/(par[3]*par[3]));
+
+   return fitval;
+}
+
+// -----------------------------------------------------------------------------
+// 
+// Default draw:
+//
+//
+void MHPSFFromStars::Draw(const Option_t *opt)
+{
+
+  TString option(opt);
+  option.ToLower();
+
+  TVirtualPad *pad = gPad ? gPad : MH::MakeDefCanvas(this);  
+  pad->SetBorderMode(0);
+
+  if (fNumEvents==0)
+    {
+      *fLog << err << GetName() << " no entries to be drawn" << endl;
+      return;
+    }
+  
+    
+
+  if (option.Contains("mean"))
+    {
+      fGraphMeanX = new TGraph((Int_t)fNumEvents,fEvent.GetArray(),fvsTimeMeanX.GetArray());
+      fGraphMeanX->SetName("GraphMeanX");
+      fGraphMeanX->SetTitle("Star X position v.s. event ");
+      fGraphMeanX->UseCurrentStyle();
+      fGraphMeanX->GetXaxis()->SetTitle("Event [#]");
+      fGraphMeanX->GetYaxis()->SetTitle("X [\\circ]");
+
+      fGraphMeanY = new TGraph((Int_t)fNumEvents,fEvent.GetArray(),fvsTimeMeanY.GetArray());
+      fGraphMeanY->SetName("GraphMeanY");
+      fGraphMeanY->SetTitle("Star Y position v.s. event ");
+      fGraphMeanY->UseCurrentStyle();
+      fGraphMeanY->GetXaxis()->SetTitle("Event [#]");
+      fGraphMeanY->GetYaxis()->SetTitle("Y [\\circ]");
+
+      pad->Divide(2,2);
+
+      pad->cd(1);
+      fHistMeanX.DrawClone();
+      pad->cd(2);
+      fHistMeanY.DrawClone();
+      pad->cd(3);
+      fGraphMeanX->SetMarkerStyle(20);
+      fGraphMeanX->SetMarkerSize(0.4);
+      fGraphMeanX->Draw("AP");
+      pad->cd(4);
+      fGraphMeanY->SetMarkerStyle(20);
+      fGraphMeanY->SetMarkerSize(0.4);
+      fGraphMeanY->Draw("AP");
+    }
+  else if (option.Contains("sig"))
+    {
+
+      fGraphSigmaMinor = new TGraph((Int_t)fNumEvents,fEvent.GetArray(),fvsTimeSigmaMinor.GetArray());
+      fGraphSigmaMinor->SetName("GraphSigmaMinor");
+      fGraphSigmaMinor->SetTitle("Star X sigma v.s. event ");
+      fGraphSigmaMinor->UseCurrentStyle();
+      fGraphSigmaMinor->GetXaxis()->SetTitle("Event [#]");
+      fGraphSigmaMinor->GetYaxis()->SetTitle("Sigma X [\\circ]");
+
+      fGraphSigmaMajor = new TGraph((Int_t)fNumEvents,fEvent.GetArray(),fvsTimeSigmaMajor.GetArray());
+      fGraphSigmaMajor->SetName("GraphSigmaMajor");
+      fGraphSigmaMajor->SetTitle("Star Y sigma v.s. event ");
+      fGraphSigmaMajor->UseCurrentStyle();
+      fGraphSigmaMajor->GetXaxis()->SetTitle("Event [#]");
+      fGraphSigmaMajor->GetYaxis()->SetTitle("Sigma Y [\\circ]");
+
+      pad->Divide(2,2);
+
+      pad->cd(1);
+      fHistSigmaMinor.DrawClone();
+      pad->cd(2);
+      fHistSigmaMajor.DrawClone();
+      pad->cd(3);
+      fGraphSigmaMinor->SetMarkerStyle(21);
+      fGraphSigmaMinor->SetMarkerSize(0.4);
+//       fGraphSigmaMinor->SetMarkerColor(kBlue);
+      fGraphSigmaMinor->Draw("AP");
+      fGraphSigmaMajor->SetMarkerStyle(21);
+      fGraphSigmaMajor->SetMarkerSize(0.4);
+      pad->cd(4);
+      fGraphSigmaMajor->Draw("AP");
+    }
+  else if (option.Contains("proj"))
+  {
+      pad->Divide(2,1);
+
+      pad->cd(1);
+// Creates a Root function based on function fitf above
+      TF1 *funcX = new TF1("fitfuncX",fitfunc,-0.4,0.4,4);
+
+      Float_t sigguess = fHistSigmaMinor.GetMean();
+      Float_t max = fProjectionX.GetMaximum();
+// Sets initial values and parameter names
+      funcX->SetParNames("base","Max","Mean","Sigma");
+      funcX->SetParameters(1.,max,0.,sigguess);
+
+// Fit histogram in range defined by function
+      fProjectionX.Fit("fitfuncX","QR");
+      //      fProjectionX.DrawClone();
+
+      pad->cd(2);
+      TF1 *funcY = new TF1("fitfuncY",fitfunc,-0.4,0.4,4);
+
+      sigguess = fHistSigmaMajor.GetMean();
+      max = fProjectionY.GetMaximum();
+// Sets initial values and parameter names
+      funcY->SetParNames("base","Max","Mean","Sigma");
+      funcY->SetParameters(1.,max,0.,sigguess);
+
+// Fit histogram in range defined by function
+      fProjectionY.Fit("fitfuncX","QR");
+      fProjectionY.DrawClone();
+  }
+//   else if (option.Contains("prof"))
+//   {
+//       fProfile.DrawClone();
+//   }
+  else if (option.Contains("cam"))
+    {
+      pad->cd(1);
+
+      TArrayF x(fNumEvents);
+      TArrayF y(fNumEvents);
+      for (UInt_t i=0; i<fNumEvents; i++)
+        {
+          x[i] = fvsTimeMeanX[i]/fGeom->GetConvMm2Deg();
+          y[i] = fvsTimeMeanY[i]/fGeom->GetConvMm2Deg();
+        }
+      
+      fGraphPath = new TGraph((Int_t)fNumEvents,x.GetArray(),y.GetArray());
+      fGraphPath->SetName("GraphPath");
+      fGraphPath->UseCurrentStyle();
+
+      fCamera.DrawClone();
+      fCamera.SetPrettyPalette();
+      fGraphPath->Draw("P");
+      fGraphPath->SetMarkerStyle(21);
+      fGraphPath->SetMarkerSize(0.4);
+    }
+  else
+    *fLog << err << GetName() << "::Draw Uknown option " << option << endl;
+  
+}
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MHPSFFromStars.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MHPSFFromStars.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MHPSFFromStars.h	(revision 9661)
@@ -0,0 +1,101 @@
+#ifndef MARS_MHPSFFromStars
+#define MARS_MHPSFFromStars
+
+#ifndef ROOT_TObjArray
+#include <TObjArray.h>
+#endif
+
+#ifndef ROOT_TH1F
+#include <TH1F.h>
+#endif
+
+#ifndef ROOT_TGraph
+#include <TGraph.h>
+#endif
+
+#ifndef ROOT_TArrayF
+#include <TArrayF.h>
+#endif
+
+#ifndef ROOT_TArrayI
+#include <TArrayI.h>
+#endif
+
+#ifndef ROOT_TProfile
+#include <TProfile.h>
+#endif
+
+#ifndef ROOT_TProfile2D
+#include <TProfile2D.h>
+#endif
+
+#ifndef MARS_MHCamera
+#include "MHCamera.h"
+#endif
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+class TObject;
+class MCameraDC;
+class MStarLocalPos;
+class MStarLocalCam;
+
+class MHPSFFromStars : public MH
+{
+ private:
+
+  MGeomCam* fGeom;
+  MCameraDC* fCurr;
+  
+  TH1F fHistMeanX;
+  TH1F fHistMeanY;
+  TH1F fHistSigmaMinor;
+  TH1F fHistSigmaMajor;
+
+  TGraph *fGraphMeanX;
+  TGraph *fGraphMeanY;
+  TGraph *fGraphPath;
+  TGraph *fGraphSigmaMinor;
+  TGraph *fGraphSigmaMajor;
+
+  TArrayF fvsTimeMeanX;
+  TArrayF fvsTimeMeanY;
+  TArrayF fvsTimeSigmaMinor;
+  TArrayF fvsTimeSigmaMajor;
+
+  TArrayF fTime;
+  TArrayF fEvent;
+
+  ULong_t fNumEvents;
+
+  MHCamera fCamera;
+  TProfile fProjectionX;
+  TProfile fProjectionY;
+  TProfile2D fProfile;
+
+  Int_t fSelectedStarPos;
+  MStarLocalPos* SelectStar(MStarLocalCam* stars);
+
+  public:
+
+  MHPSFFromStars(Int_t starpos=-1, const char *name=NULL, const char *title=NULL);
+  ~MHPSFFromStars();
+
+  Bool_t SetupFill(const MParList *pList);
+  Bool_t Fill(const MParContainer *par, const Stat_t w=1);
+  Bool_t Finalize();
+
+  void Draw(const Option_t*);
+/*   TObject* Clone(const char *) const; */
+
+  //Getter
+  TProfile& GetProjectionX() { return fProjectionX; }
+  TProfile& GetProjectionY() { return fProjectionY; }
+  
+  ClassDef(MHPSFFromStars, 1) // A list of histograms storing star information from PMT DCs
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MHillasDisplay.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MHillasDisplay.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MHillasDisplay.cc	(revision 9661)
@@ -0,0 +1,209 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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 Rico     05/2004 <mailto:jrico@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// MDisplayHillas
+//
+// Display the camera event of type MCerPhotEvt plus the computed hillas
+// parameters.
+//
+// Input containers (in constructor):
+//  MCerPhotEvt
+//  MGeomCam
+//
+// Input containers
+//  MHillas
+//  [MSrcPosCam]
+//  [MIslands]
+//
+// Output containers
+//  [...]
+//
+//////////////////////////////////////////////////////////////////////////////
+#include <fstream>
+#include <math.h>
+
+#include "TVirtualPad.h"
+#include "TLine.h"
+#include "TEllipse.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MHillasDisplay.h"
+#include "MCerPhotEvt.h"
+#include "MGeomCam.h"
+#include "MHillas.h"
+#include "MNewImagePar.h"
+#include "MSrcPosCam.h"
+#include "MIslands.h"
+
+ClassImp(MHillasDisplay);
+
+using namespace std;
+
+static const TString gsDefName  = "MHillasDisplay";
+static const TString gsDefTitle = "Hillas Camera display task";
+
+// -------------------------------------------------------------------------
+//
+// Constructor (see MDisplay documentation for more information)
+//
+MHillasDisplay::MHillasDisplay(MCerPhotEvt* event, MGeomCam* geom, Int_t type, const char* name, const char* title) 
+  :  MDisplay(event,geom,type), fHillas(NULL), fNewImage(NULL), fSrcPos(NULL), fIslands(NULL)
+{
+  fName  = name  ? name  : gsDefName.Data();
+  fTitle = title ? title : gsDefTitle.Data();
+}
+// -------------------------------------------------------------------------
+//
+// Call for MHillas::PreProcess and look for MHillas and look for the
+// needed containers
+//
+Int_t MHillasDisplay::PreProcess(MParList* pList)
+{  
+  if(!MDisplay::PreProcess(pList))
+    return kFALSE;
+
+  // Look for the MHillas container  
+  if(!fHillas)
+    fHillas = (MHillas*)pList->FindObject(AddSerialNumber("MHillas"), "MHillas");
+  if(!fHillas)
+    *fLog << warn << "MHillasDisplay::PreProcess Warning: MHillas object not found" << endl;
+  else
+    {
+      gPad->cd(1);
+      Draw();
+    }
+
+  // Look for the MNewImagePar container  
+  if(!fNewImage)
+    fNewImage = (MNewImagePar*)pList->FindObject(AddSerialNumber("MNewImagePar"), "MNewImagePar");
+  if(!fNewImage)
+    *fLog << warn << "MHillasDisplay::PreProcess Warning: MNewImagePar object not found" << endl;
+
+  // Look for the MSrcPosCam container  
+  if(!fSrcPos)
+    fSrcPos = (MSrcPosCam*)pList->FindObject(AddSerialNumber("MSrcPosCam"), "MSrcPosCam");
+  if(!fSrcPos)
+    *fLog << warn << "MHillasDisplay::PreProcess Warning: MSrcPosCam object not found" << endl;
+
+  // Look for the MIslands container
+  if (strlen(fIslName) > 0)
+    fIslands = (MIslands*)pList->FindObject(AddSerialNumber(fIslName));
+  else
+    fIslands = (MIslands*)pList->FindObject(AddSerialNumber("MIslands"));
+  if (!fIslands)
+    *fLog << warn << "MHillasDisplay::PreProcess Warning: MIslands object not found" << endl;
+    
+  return kTRUE;
+
+}
+// -------------------------------------------------------------------------
+//
+// Display event AND hillas parameters
+//
+Int_t MHillasDisplay::Process()
+{
+   // draw the hillas parameters
+  if(GetPauseMode())
+    {
+      if(fHillas)
+	fHillas->Print();
+      if(fNewImage)
+	fNewImage->Print();
+      if(fIslands)
+	fIslands->Print();
+    }      
+   
+  // draw the event
+  if(!MDisplay::Process())
+    return kFALSE;
+  return kTRUE;
+}
+// -------------------------------------------------------------------------
+//
+// Stuff to be painted when canvas will be updated
+//
+void MHillasDisplay::Paint(Option_t* option)
+{
+  const Float_t OffsetW=20.0;
+  const Float_t OffsetL=300.0;
+
+  Float_t meanX  = fHillas->GetMeanX();
+  Float_t meanY  = fHillas->GetMeanY();
+  Float_t length = fHillas->GetLength();
+  Float_t width  = fHillas->GetWidth();
+  Float_t delta  = fHillas->GetDelta();
+
+
+  if (length<=0 || width<=0)
+    return;
+  
+  // Length line
+  TLine lineL(-(length+OffsetL)*cos(delta) + meanX,
+              -(length+OffsetL)*sin(delta) + meanY,
+	      (length+OffsetL)*cos(delta)  + meanX,
+	      (length+OffsetL)*sin(delta)  + meanY);
+
+  lineL.SetLineWidth(1);
+  lineL.SetLineColor(2);
+  lineL.Paint();
+
+  // Width line
+  TLine lineW((width+OffsetW)*sin(delta)  + meanX,
+              -(width+OffsetW)*cos(delta) + meanY,
+	      -(width+OffsetW)*sin(delta) + meanX,
+	      (width+OffsetW)*cos(delta)  + meanY);
+
+  lineW.SetLineWidth(1);
+  lineW.SetLineColor(2);
+  lineW.Paint();
+
+  // Coordinate system
+  Float_t xSrc   = fSrcPos? fSrcPos->GetX() : 0.;
+  Float_t ySrc   = fSrcPos? fSrcPos->GetY() : 0.;
+  Float_t radius = GetGeomCam()->GetMaxRadius();
+  TLine lineX(-radius,ySrc,radius,ySrc);
+  TLine lineY(xSrc,-radius,xSrc,radius);
+  lineX.SetLineWidth(1);
+  lineX.SetLineColor(108);
+  lineY.SetLineWidth(1);
+  lineY.SetLineColor(108);
+  lineX.Paint();
+  lineY.Paint();
+  
+  // COG line
+  TLine lineMean(xSrc,ySrc,meanX,meanY);
+  lineMean.SetLineWidth(1);
+  lineMean.SetLineColor(2);
+  lineMean.Paint();
+  
+  // Hillas ellipse
+  TEllipse ellipse(meanX,meanY,length,width,0,360,delta*kRad2Deg+180);
+  ellipse.SetLineWidth(2);
+  ellipse.SetLineColor(2);
+  ellipse.Paint(); 
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MHillasDisplay.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MHillasDisplay.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MHillasDisplay.h	(revision 9661)
@@ -0,0 +1,47 @@
+#ifndef MARS_MHillasDisplay
+#define MARS_MHillasDisplay
+
+#ifndef MARS_MDisplay
+#include "MDisplay.h"
+#endif
+
+class MCerPhotEvt;
+class MSrcPosCam;
+class MGeomCam;
+class MHillas;
+class MIslands;
+class MNewImagePar;
+
+class MHillasDisplay : public MDisplay
+{
+ private:
+  MHillas*      fHillas;    // pointer to container with the hillas parameters
+  MNewImagePar* fNewImage;  // pointer to container with the new image parameters
+  MSrcPosCam*   fSrcPos;    // pointer to the source position in camera
+  MIslands*     fIslands;   // pointer to the islands
+
+  TString       fIslName;
+
+  virtual Int_t PreProcess(MParList *plist);
+  virtual Int_t Process();
+  
+
+ public:
+  MHillasDisplay(MCerPhotEvt* event, MGeomCam* geom, Int_t type=0,
+		 const char* name=NULL, const char* title=NULL);
+
+  virtual ~MHillasDisplay(){};
+
+  void SetHillas(MHillas* hillas)    {fHillas=hillas;}
+  void SetSrcPos(MSrcPosCam* srcpos) {fSrcPos=srcpos;}
+  void SetIslands(MIslands* islands) {fIslands=islands;}
+  
+  void SetIslandsName(TString inname)    {fIslName = inname;}
+  
+  virtual void Paint(Option_t* option);
+  
+  ClassDef(MHillasDisplay, 0) // task to display cleaned events with hillas parameters
+    };
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MIslandCalc.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MIslandCalc.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MIslandCalc.cc	(revision 9661)
@@ -0,0 +1,740 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Ester Aliu, 2/2004 <aliu@ifae.es>
+|
+!   Last Update: 7/2004
+!
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MIslandCalc
+//
+// The Island Calc task calculates the some islands parameters for each 
+// of the events such as:
+// 
+//   - fIslNum                 //  number of islands
+//   - fIslId[577]             //  island Id
+//   - fPixNum[numisl]         //  number of pixels in the island
+//   - fSigToNoise[numisl]     //  signal to noise of the island
+//   - ftime[numisl][577]      //  mean of the arrival time  
+//   - fTimeSpread[numisl]     //  mean arrival time spread of the island
+//   - fMeanX[numisl]          //  mean X position of the island
+//   - fMeanY[numisl]          //  mean Y position of the island
+//   - fDist[numisl]           //  dist between an island and the continent
+//   - fLength                 //  major axis of the larger island ellipse
+//   - fWidth                  //  minor axis of the larger island ellipse
+//   - fDistL[numisl]          //  dist divided by lenght of the larger island
+//   - fDistW[numisl]          //  dist divided by width of the larger island
+//
+// Input Containers:
+//   MGeomCam
+//   MCerPhotEvt
+//   MPedestalCam
+//   MArrivalTimeCam
+//
+// Output Containers:
+//   MIslands
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MIslandCalc.h"
+
+#include <stdlib.h>       // atof					  
+#include <fstream>        // ofstream, SavePrimitive
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MIslands.h"
+
+#include "MParList.h"
+
+#include "MGeomPix.h"
+#include "MGeomCam.h"
+
+#include "MCerPhotPix.h"
+#include "MCerPhotEvt.h"
+
+#include "MPedestalCam.h"
+#include "MPedestalPix.h"
+
+#include "MArrivalTimeCam.h"
+#include "MArrivalTimePix.h"
+
+ClassImp(MIslandCalc);
+
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MIslandCalc::MIslandCalc(const char* name, const char* title)    
+  : fIsl(NULL)
+{
+    fName  = name  ? name  : "MIslandCalc";
+    fTitle = title ? title : "Calculate island parameters";
+}
+
+
+// --------------------------------------------------------------------------
+Int_t MIslandCalc::PreProcess (MParList *pList)
+{
+    fCam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
+    if (!fCam)
+    {
+        *fLog << dbginf << "MGeomCam not found (no geometry information available)... aborting." << endl;
+        return kFALSE;
+    }
+
+    fEvt = (MCerPhotEvt*)pList->FindObject(AddSerialNumber("MCerPhotEvt"));
+    if (!fEvt)
+    {
+        *fLog << dbginf << "MCerPhotEvt not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fPed = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
+    if (!fPed)
+      {
+        *fLog << dbginf << "MPedestalCam not found... aborting." << endl;
+        return kFALSE;
+      }
+
+    fTime = (MArrivalTimeCam*)pList->FindObject(AddSerialNumber("MArrivalTimeCam"));
+    if (!fTime)
+      {
+        *fLog << dbginf << "MArrivalTimeCam not found... aborting." << endl;
+        return kFALSE;
+      }
+   
+    if (strlen(fIslName) > 0)
+      {
+	fIsl = (MIslands*)pList->FindCreateObj("MIslands", AddSerialNumber(fIslName));
+	//cout << "kk1" << endl;
+      }
+    else
+      {
+      fIsl = (MIslands*)pList->FindCreateObj(AddSerialNumber("MIslands"));
+      //cout << "kk2" << endl;
+      }
+    if (!fIsl)
+      return kFALSE;
+    
+    return kTRUE;
+}
+
+
+Int_t MIslandCalc::Process(){
+  
+  IslandPar();
+  
+  return kTRUE;  
+   
+}
+
+
+Int_t MIslandCalc::IslandPar(){
+
+  //calculates all the island parameters 
+
+  const Int_t nPix=577;
+  const Int_t nVect=20;
+  Int_t numisl;
+
+  Int_t** vect;
+  vect = new Int_t*[nVect];
+  for(Int_t i=0;i<nVect;i++)
+    vect[i]= new Int_t[nPix];
+  
+  Int_t num[nVect];
+  // num = new Int_t*[nVect];
+  
+  if (fIslandAlgorithm == 1)
+    Calc1(numisl,nVect,nPix,vect,num);
+  if (fIslandAlgorithm == 2)
+    Calc2(numisl,nVect,nPix,vect,num);
+  
+  //set the number of islands in one event
+  
+  fIsl->SetIslNum(numisl);
+
+ 
+  //examine each island...
+
+  Float_t  noise;
+  Float_t  signal;
+
+  /*
+  Float_t** ftime;
+  ftime = new Float_t*[numisl];
+
+  Int_t pixNumIsl = 0;
+
+  for(Int_t i=0;i<numisl;i++)
+    {
+      pixNumIsl = num[i+1];
+      ftime[i]= new Float_t[pixNumIsl];
+    }
+
+  Int_t** fIslId;
+  fIslId = new Int_t*[numisl];
+  for(Int_t i=0;i<numisl;i++)
+    {
+      pixNumIsl = num[i+1];
+      fIslId[i]= new Int_t[pixNumIsl];
+    }
+  */
+ 
+  Int_t fPixNum[numisl];
+  Float_t fSigToNoise[numisl];
+  Float_t time[nPix];
+  Float_t timeVariance[numisl];
+  Float_t meanX[numisl];
+  Float_t meanY[numisl];
+  Float_t dist[numisl];
+  Float_t distL[numisl];
+  Float_t distW[numisl];
+  Float_t size, sizeLargeIsl, length, width;
+
+
+  //reset the "sets" functions
+  if (numisl <1)
+    fIsl->SetIslNum(0);
+  
+  for(Int_t i = 0; i<10 ;i++){
+    for(Int_t idx = 0; idx<nPix; idx++)
+      {
+	if (i == 0)
+	  fIsl->SetIslId(idx, -1);
+	//fIsl->SetArrivalTime(i, idx, -1 );
+      }
+  }
+  
+  Float_t X = 0;
+  Float_t Y = 0;
+  sizeLargeIsl = 0;
+
+
+  for(Int_t i = 1; i<=numisl ; i++)
+    {
+      Int_t n = 0;
+      //Int_t ncore = 0;
+      
+      Float_t MIN = 10000.;
+      Float_t MAX = 0.;
+      
+      signal = 0;
+      noise = 0;
+
+      size = 0;
+      meanX[i-1] = 0;
+      meanY[i-1] = 0;
+      dist[i-1] = 0;
+
+      fPixNum[i-1] = 0;
+      timeVariance[i-1] = 0;
+      
+
+      for(Int_t idx=0 ; idx<nPix ; idx++)
+	{
+	  
+	  MCerPhotPix *pix = fEvt->GetPixById(idx);
+	  const MGeomPix &gpix2 = (*fCam)[pix->GetPixId()];
+	  const MPedestalPix &ped  = (*fPed)[idx];
+	  const MArrivalTimePix &timepix = (*fTime)[idx];
+	  const Float_t nphot = pix->GetNumPhotons();
+
+	  if (pix == NULL) break;
+	    
+	  if (vect[i][idx]==1){
+	    
+	    fPixNum[i-1]++;
+	    signal += nphot * (fCam->GetPixRatio(idx));
+	    noise += pow(ped.GetPedestalRms(),2);
+	    
+	    size += nphot;
+	    if (i == 1)
+	      sizeLargeIsl += nphot;
+
+	    meanX[i-1] += nphot * gpix2.GetX();
+	    meanY[i-1] += nphot * gpix2.GetY();
+	    
+	    time[i-1] = timepix.IsLoGainUsed() ? timepix.GetArrivalTimeLoGain() : timepix.GetArrivalTimeHiGain();
+	    	  	
+	    //	    ftime[i-1][n] = time[i-1];
+	    //  fIslId[i-1][n] = idx;
+
+	    //calculates the time spread only for core pixels  
+	    if (fEvt->IsPixelCore(idx)){ 
+	      
+	      if (time[i-1] > MAX)
+		MAX = time[i-1];
+	      if (time[i-1] < MIN)
+		MIN = time[i-1];
+	      //  ncore++;
+	    }
+	    
+	    fIsl->SetIslId(idx, i-1);
+	    //  fIsl->SetArrivalTime(i-1, idx, time[n]);
+
+	    n++;
+	  }
+	  
+	}
+
+      meanX[i-1] /= size;
+      meanY[i-1] /= size;
+  
+
+      if (i == 1){
+	X = meanX[i-1];
+	Y = meanY[i-1];
+      }
+  
+      dist[i-1] = TMath::Power(meanX[i-1]-X,2) + TMath::Power(meanY[i-1]-Y,2);
+      dist[i-1] = TMath::Sqrt(dist[i-1]);
+      
+      timeVariance[i-1] = MAX-MIN; 
+      
+      fSigToNoise[i-1]= (Float_t)signal/(Float_t)sqrt(noise);
+      
+    }
+
+  //fIsl->SetIslId(fIslId);
+  //fIsl->SetArrivalTime(ftime);
+  fIsl->SetPixNum(fPixNum);
+  fIsl->SetSigToNoise(fSigToNoise);
+  fIsl->SetTimeSpread(timeVariance);
+  fIsl->SetMeanX(meanX);
+  fIsl->SetMeanY(meanY);
+  fIsl->SetDist(dist);
+  
+
+  //Length and Width of the larger island according the definition of the hillas parameters
+  
+  // calculate 2nd moments
+  // ---------------------
+  Double_t corrxx=0;                               // [m^2]
+  Double_t corrxy=0;                               // [m^2]
+  Double_t corryy=0;                               // [m^2]
+  
+  for(Int_t idx=0 ; idx<nPix ; idx++)
+    {
+      MCerPhotPix *pix = fEvt->GetPixById(idx);
+      const MGeomPix &gpix3 = (*fCam)[pix->GetPixId()];
+      const Float_t nphot = pix->GetNumPhotons();
+      
+      if (pix == NULL) break;
+      
+      if (vect[1][idx]==1){
+	
+	const Float_t dx = gpix3.GetX() - X;     // [mm]
+	const Float_t dy = gpix3.GetY() - Y;     // [mm]
+	
+	
+	corrxx += nphot * dx*dx;                     // [mm^2]
+	corrxy += nphot * dx*dy;                     // [mm^2]
+	corryy += nphot * dy*dy;                     // [mm^2]
+	
+      }   
+    } 
+  
+  // calculate the hillas parameters Width and Length
+  
+  const Double_t d0    = corryy - corrxx;
+  const Double_t d1    = corrxy*2;
+  const Double_t d2    = d0 + TMath::Sqrt(d0*d0 + d1*d1);
+  const Double_t tand  = d2 / d1;
+  const Double_t tand2 = tand*tand;
+  
+  const Double_t s2 = tand2+1;
+  
+  const Double_t axis1 = (tand2*corryy + d2 + corrxx)/s2/sizeLargeIsl;
+  const Double_t axis2 = (tand2*corrxx - d2 + corryy)/s2/sizeLargeIsl;
+  
+  //
+  // fLength^2 is the second moment along the major axis of the ellipse
+  // fWidth^2  is the second moment along the minor axis of the ellipse
+  //
+  // From the algorithm we get: fWidth <= fLength is always true
+  //
+  // very small numbers can get negative by rounding
+  //
+  length = axis1<0 ? 0 : TMath::Sqrt(axis1);  // [mm]
+  width  = axis2<0 ? 0 : TMath::Sqrt(axis2);  // [mm]
+  
+  fIsl->SetLength(length);
+  fIsl->SetWidth(width); 
+   
+  // for(Int_t i = 1; i<=numisl ; i++){
+
+  // fIsl->SetDistL(fIsl->GetDist(i-1)/length, i-1);
+  // fIsl->SetDistW(fIsl->GetDist(i-1)/width, i-1);
+  // }
+
+  for(Int_t i = 1; i<=numisl ; i++){
+    
+    distL[i-1]=dist[i-1]/length;
+    distW[i-1]=dist[i-1]/width;
+    
+  }
+
+  fIsl->SetDistL(distL);
+  fIsl->SetDistW(distW);
+
+  fIsl->SetReadyToSave();
+
+    
+  for(Int_t i=0;i<nVect;i++)
+    delete [] vect[i];
+
+  delete vect;
+
+  return kTRUE;  
+}
+
+//------------------------------------------------------------------------------------------
+void MIslandCalc::Calc1(Int_t& numisl, const Int_t nv, const Int_t npix, Int_t** vect, Int_t* num){
+  
+  
+  /////////////////////////////
+  //
+  //        ALGORITHM # 1
+  // counts the number of islands as you can see in 
+  // the event display after doing the std image cleaning
+  //
+  /////////////////////////////
+  
+  Int_t    sflag;
+  Int_t    control;
+  
+  Int_t    nvect = 0;
+  
+  numisl = 0;
+
+  Int_t    zeros[nv];
+  
+  for(Int_t m = 0; m < nv ; m++)
+    for(Int_t n = 0; n < npix ; n++)
+	vect[m][n] = 0;
+    
+  for(Int_t n = 0; n < nv ; n++)
+    zeros[n] = 0;
+  
+
+  MCerPhotPix *pix;
+
+  //loop over all pixels
+  MCerPhotEvtIter Next(fEvt, kFALSE);
+  
+  while ((pix=static_cast<MCerPhotPix*>(Next())))
+    {
+      const Int_t idx = pix->GetPixId();
+
+      const MGeomPix &gpix  = (*fCam)[idx];
+      const Int_t    nnmax  = gpix.GetNumNeighbors();
+
+      if( fEvt->IsPixelUsed(idx)) 
+     	{
+	  sflag = 0;
+	  
+	  for(Int_t j=0; j < nnmax ; j++)
+	    {
+	      const Int_t idx2 = gpix.GetNeighbor(j);
+	      
+	      if (idx2 < idx)
+		{
+		  for(Int_t k = 1; k <= nvect; k++)
+		    {
+		      if (vect[k][idx2] == 1)
+			{
+			  sflag = 1;
+			  vect[k][idx] = 1;
+			}
+		    }
+		}
+	    }
+	  
+	  if (sflag == 0)
+	    {
+	      nvect++;
+	      vect[nvect][idx] = 1;	     
+	    }
+	  
+	}
+    }
+  
+  numisl = nvect;
+  
+  
+  // Repeated Chain Corrections
+
+  
+  for(Int_t i = 1; i <= nvect; i++)
+    {
+      for(Int_t j = i+1; j <= nvect; j++)
+	{
+	  control = 0;
+	  for(Int_t k = 0; k < npix; k++)
+	    {
+	      if (vect[i][k] == 1 && vect[j][k] == 1)
+		{
+		  control = 1; 
+		  break;
+		}
+	    }
+	  if (control == 1)
+	    {
+	      for(Int_t k = 0; k < npix; k++)
+		{
+		  if(vect[j][k] == 1)
+		    vect[i][k] = 1;
+		  vect[j][k] = 0;
+		  zeros[j] = 1;
+		}	
+	      numisl = numisl-1;	    
+	    }
+	  
+	}
+    }
+  
+  
+
+  Int_t l = 1;
+  Int_t numpixels;
+  Int_t pixMAX = 0;
+  Int_t idMAX = 1;
+
+  for(Int_t i = 1;  i<= nvect ; i++)
+    {
+      numpixels = 0;
+
+      if (zeros[i] == 0)
+	{
+	  for(Int_t k = 0; k<npix; k++)
+	    {
+	      vect[l][k] = vect[i][k];
+	      if (vect[l][k] == 1)
+		numpixels++;
+	      		
+	    }
+	  if (numpixels>pixMAX)
+	    {
+	      pixMAX = numpixels;
+	      idMAX = l;
+	    }
+	  l++;
+	}
+      num[i] = numpixels;
+
+    }
+  
+  //the larger island will correspond to the 1st component of the vector
+
+  num[nvect +1] = num[1];
+  num[1] = num[idMAX];
+  num[idMAX]=num[1];
+
+  for(Int_t k = 0; k<npix; k++) 
+    {
+      vect[nvect+1][k] = vect[1][k];
+      vect[1][k] = vect[idMAX][k];
+      vect[idMAX][k] = vect[nvect+1][k];
+    }
+}
+
+//------------------------------------------------------------------------------------------
+
+void MIslandCalc::Calc2(Int_t& numisl, const Int_t nv, const Int_t npix, Int_t** vect, Int_t* num){  
+
+  
+  /////////////////////////////
+  //
+  //        ALGORITHM # 2
+  // counts the number of islands considering as the same 
+  // islands the ones separated for 2 or less pixels
+  //
+  /////////////////////////////
+  
+  Int_t    sflag;
+  Int_t    control;
+  
+  Int_t    nvect = 0;
+  numisl = 0;
+ 
+  Int_t    zeros[nv];
+  
+  Int_t kk[npix];
+
+  for(Int_t m = 0; m < nv ; m++)
+    for(Int_t n = 0; n < npix ; n++)
+	vect[m][n] = 0;
+    
+  for(Int_t n = 0; n < nv ; n++)
+    zeros[n] = 0;
+  
+  for(Int_t n = 0; n < npix ; n++)
+    kk[n] = 0;
+  
+  MCerPhotPix *pix;
+
+  //1st loop over all pixels
+  MCerPhotEvtIter Next0(fEvt, kFALSE);
+ 
+  while ((pix=static_cast<MCerPhotPix*>(Next0())))
+    {
+      const Int_t idx = pix->GetPixId();
+      
+      const MGeomPix &gpix  = (*fCam)[idx]; 
+      const Int_t    nnmax  = gpix.GetNumNeighbors();
+
+      if( fEvt->IsPixelUsed(idx))
+	{
+	  kk[idx] = 1 ;
+	  for(Int_t j=0; j< nnmax; j++)
+	    {
+	      kk[gpix.GetNeighbor(j)] = 1;
+	    }
+	} 
+      
+    }
+      
+  //2nd loop over all pixels
+  MCerPhotEvtIter Next(fEvt, kFALSE);
+  
+  while ((pix=static_cast<MCerPhotPix*>(Next())))
+    {
+      const Int_t idx = pix->GetPixId();
+      
+      const MGeomPix &gpix  = (*fCam)[idx];
+      const Int_t    nnmax  = gpix.GetNumNeighbors();
+      
+      if ( kk[idx] > 0)
+     	{
+	  sflag = 0;
+	  
+	  for(Int_t j=0; j < nnmax ; j++)
+	    {
+	      const Int_t idx2 = gpix.GetNeighbor(j);
+	      
+	      if (idx2 < idx)
+		{
+		  for(Int_t k = 1; k <= nvect; k++)
+		    {
+		      if (vect[k][idx2] == 1)
+			{
+			  sflag = 1;
+			  vect[k][idx] = 1;
+			}
+		    }
+		}
+	    }
+	  
+	  if (sflag == 0)
+	    {
+	      nvect++;
+	      vect[nvect][idx] = 1;	     
+	    }
+	  
+	}
+    }
+  
+  numisl = nvect;
+  
+  
+  // Repeated Chain Corrections
+  
+  for(Int_t i = 1; i <= nvect; i++)
+    {
+      for(Int_t j = i+1; j <= nvect; j++)
+	{
+	  control = 0;
+	  for(Int_t k = 0; k < npix; k++)
+	    {
+	      
+	      if (vect[i][k] == 1 && vect[j][k] == 1)
+		{
+		  control = 1; 
+		  break;
+		}
+	    }
+	  if (control == 1)
+	    {
+	      for(Int_t k = 0; k < npix; k++)
+		{
+		  if(vect[j][k] == 1)
+		    vect[i][k] = 1;
+		  vect[j][k] = 0;
+		  zeros[j] = 1;
+		}	
+	      numisl = numisl-1;	    
+	    }
+	  
+	}
+    }
+  
+    
+  Int_t l = 1;
+  Int_t numpixels;
+  Int_t pixMAX = 0;
+  Int_t idMAX = 1;
+
+  for(Int_t i = 1;  i<= nvect ; i++)
+    {
+      numpixels = 0;
+
+      if (zeros[i] == 0)
+	{
+	  for(Int_t k = 0; k<npix; k++)
+	    {
+	      vect[l][k] = vect[i][k];
+	      if (vect[l][k] == 1)
+		numpixels++;
+	    }
+	  if (numpixels>pixMAX)
+	    {
+	      pixMAX = numpixels;
+	      idMAX = l;
+	    }
+	  l++;
+	}
+      num[i] = numpixels;
+    }
+  
+  
+  //the larger island will correspond to the 1st component of the vector
+
+  num[nvect +1] = num[1];
+  num[1] = num[idMAX];
+  num[idMAX]=num[1];
+
+  for(Int_t k = 0; k<npix; k++) 
+    {
+      vect[nvect+1][k] = vect[1][k];
+      vect[1][k] = vect[idMAX][k];
+      vect[idMAX][k] = vect[nvect+1][k];
+    }
+
+}
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MIslandCalc.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MIslandCalc.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MIslandCalc.h	(revision 9661)
@@ -0,0 +1,52 @@
+#ifndef MARS_MIslandCalc
+#define MARS_MIslandCalc
+
+#ifndef MARS_MGTask
+#include "MGTask.h"
+#endif
+
+#ifndef ROOT_TArrayF
+#include <TArrayF.h>
+#endif
+
+class MGeomCam;
+class MSigmabar;
+class MCerPhotPix;
+class MCerPhotEvt;
+class MPedestalCam;
+class MArrivalTimeCam;
+class MArrivalTimePix;
+class MIslands;
+
+class MIslandCalc : public MGTask
+{
+ private:
+    const MGeomCam    *fCam;        //!
+    MCerPhotEvt       *fEvt;        //!
+    MSigmabar         *fSgb;        //!
+    MPedestalCam      *fPed;        //!
+    MArrivalTimeCam   *fTime;       //!
+
+    MIslands          *fIsl;        //!   output container to store result
+  
+    TString           fIslName;     //    name of the 'MIslands' container
+  
+    Int_t  fIslandAlgorithm;
+
+    Int_t PreProcess(MParList *plist);
+    Int_t Process();
+    Int_t IslandPar();               //
+    void  Calc1(Int_t&,const Int_t,const Int_t,Int_t**,Int_t*);    // algorithm of counting islands #1
+    void  Calc2(Int_t&,const Int_t,const Int_t,Int_t**,Int_t*);    // algorithm of counting islands #2
+    
+           
+ public:
+    MIslandCalc(const char* name=NULL, const char* title=NULL);
+    void SetOutputName(TString outname)   { fIslName = outname; }
+    
+    void SetAlgorithm(Int_t m)   {fIslandAlgorithm = m;}
+    
+    ClassDef(MIslandCalc, 0)        // task doing the image cleaning
+}; 
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MIslandClean.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MIslandClean.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MIslandClean.cc	(revision 9661)
@@ -0,0 +1,232 @@
+/* ======================================================================== *\
+!
+!
+!   Author(s): Ester Aliu, 3/2004
+!  
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MIslandClean
+//
+// The Island Cleaning task selects the islands you use for the Hillas
+// parameters calculation, after the normal image cleaning.
+//
+// There are two methods to make the selection: 
+//
+//    - No time method, as used is Whipple. It calculates an island parameter 
+//   called "signal to noise" and adds a new threshold that eliminates some   
+//   of the islands. The way the island is eliminated is seeting the pixels 
+//   of the islands as UNUSED 
+//
+//    - Time method, taking profit of the time information in MAGIC.
+//   Calculates the maximum time difference (in time slices) for each island 
+//   and corrects for the island size. With an other new threshold "noise" 
+//   islands are supposed to be eliminated.     
+//
+// Other cleanings that are allowed in this code are:
+// 
+//    - Resting only with the continent, i.e. the larger island
+//    
+//  Example:
+//
+//  MIslands   isl;
+//  isl.SetName("MIslands1");
+
+//  MImgCleanStd clean;
+//  MIslandClean islclean(0.2);
+//  islclean.SetInputName("MIslands1");  
+//  islclean.SetMethod(0); // for timing method 
+//
+//  tlist.AddToList(&clean);
+//  tlist.AddToList(&islclean);
+//
+//
+//  Input Containers:
+//    MGeomCam
+//    MCerPhotEvt
+//    MPedestalCam
+//    MArrivalTime
+//    MIslands
+//
+//  Output Containers:
+//    MCerPhotEvt
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MIslandClean.h"
+
+#include <stdlib.h>       // atof					  
+#include <fstream>        // ofstream, SavePrimitive
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MIslands.h"
+
+#include "MParList.h"
+
+#include "MGeomPix.h"
+#include "MGeomCam.h"
+
+#include "MCerPhotPix.h"
+#include "MCerPhotEvt.h"
+
+#include "MPedestalCam.h"
+#include "MPedestalPix.h"
+
+#include "MArrivalTimeCam.h"
+#include "MArrivalTimePix.h"
+
+ClassImp(MIslandClean);
+
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MIslandClean::MIslandClean(const Float_t newThres, const char *name, const char *title)    
+  : fIsl(NULL), fIslandCleaningMethod(kNoTiming), fIslCleanThres(newThres)
+{
+    fName  = name  ? name  : "MIslandClean";
+    fTitle = title ? title : "Clean islands";
+}
+
+
+Int_t MIslandClean::PreProcess (MParList *pList)
+{
+    fCam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
+    if (!fCam)
+    {
+        *fLog << dbginf << "MGeomCam not found (no geometry information available)... aborting." << endl;
+        return kFALSE;
+    }
+
+    fEvt = (MCerPhotEvt*)pList->FindObject(AddSerialNumber("MCerPhotEvt"));
+    if (!fEvt)
+    {
+        *fLog << dbginf << "MCerPhotEvt not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fPed = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
+    if (!fPed)
+      {
+        *fLog << dbginf << "MPedestalCam not found... aborting." << endl;
+        return kFALSE;
+      }
+
+    fTime = (MArrivalTimeCam*)pList->FindObject(AddSerialNumber("MArrivalTimeCam"));
+    if (!fTime)
+      {
+        *fLog << dbginf << "MArrivalTimeCam not found... aborting." << endl;
+        return kFALSE;
+      }
+
+    if (strlen(fIslName) > 0)
+      fIsl = (MIslands*)pList->FindObject(AddSerialNumber(fIslName));
+    else
+      fIsl = (MIslands*)pList->FindObject(AddSerialNumber("MIslands"));
+    if (!fIsl)
+      {
+        *fLog << dbginf << "MIslands not found... aborting." << endl;
+        return kFALSE;
+      }
+    
+    return kTRUE;
+}
+
+
+
+Int_t MIslandClean::Process()
+{
+  //
+  //eliminates the island with a signal-to-noise 
+  //lower than a given limit 
+  //
+  //if ( fIslandCleaningMethod == kNoTiming ){
+  if ( fIslandCleaningMethod == 1 ){
+    Int_t nisl = fIsl->GetIslNum();
+    
+    for(Int_t isl = 0; isl<nisl ; isl++)
+      {
+	if(fIsl->GetSigToNoise(isl) < fIslCleanThres)
+	  {
+	    for(Int_t idx = 0; idx<577; idx++)
+	      {
+		MCerPhotPix &pix  = (*fEvt)[idx];
+		
+		if (fIsl->GetIslId(idx) == isl)
+		  pix.SetPixelUnused();
+	      }
+	  }
+      }	
+  }  
+    
+  //
+  //eliminates the island with a time spread  
+  //higher than a given limit 
+  //
+  //else if( fIslandCleaningMethod == kTiming ){
+  else if( fIslandCleaningMethod == 0 ){
+    Int_t nisl = fIsl->GetIslNum();
+    
+    for(Int_t isl = 0; isl<nisl ; isl++)
+      {
+	//fIslCleanThreshold has different values, FIXME, put two variables
+	
+	if(fIsl->GetTimeSpread(isl) > fIslCleanThres)
+	  {
+	    for(Int_t idx = 0;idx<577; idx++)
+	      {
+		MCerPhotPix &pix  = (*fEvt)[idx];
+		
+		if (fIsl->GetIslId(idx) == isl)
+		  pix.SetPixelUnused();
+	      }
+	  }
+	
+      }	    
+  }
+
+  //
+  //eliminates all the islands except the continent, 
+  //i.e. the larger island in the event
+  //
+  else if( fIslandCleaningMethod == 3 ){
+    Int_t nisl = fIsl->GetIslNum();
+
+    Int_t max = -1000;    
+    Int_t idMax;
+
+    for(Int_t isl = 0; isl<nisl ; isl++)
+      {
+	if (fIsl->GetPixNum(isl)>max)
+	 {
+	   max = fIsl->GetPixNum(isl);
+	   idMax = isl;
+	 } 
+      }	    
+
+    for(Int_t isl = 0; isl<nisl ; isl++)
+      {
+	if (isl != idMax)
+	  {
+	    for(Int_t idx = 0;idx<577; idx++)
+	      {
+		MCerPhotPix &pix  = (*fEvt)[idx];
+		
+		if (fIsl->GetIslId(idx) == isl)
+		  pix.SetPixelUnused();
+	      }
+	  }
+      }
+  }
+  
+  fEvt->SetReadyToSave();
+  
+  return kTRUE;
+  
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MIslandClean.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MIslandClean.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MIslandClean.h	(revision 9661)
@@ -0,0 +1,59 @@
+#ifndef MARS_MIslandClean
+#define MARS_MIslandClean
+
+#ifndef MARS_MGTask
+#include "MGTask.h"
+#endif
+
+#ifndef ROOT_TArrayF
+#include <TArrayF.h>
+#endif
+
+class MGeomCam;
+class MSigmabar;
+class MCerPhotPix;
+class MCerPhotEvt;
+class MPedestalCam;
+class MArrivalTimeCam;
+class MArrivalTimePix;
+class MIslands;
+
+class MIslandClean : public MGTask
+{
+ public: 
+
+  typedef enum {
+    kTiming,
+    kNoTiming
+  } IslandCleaningMethod_t;
+  
+ private:
+    const MGeomCam    *fCam;        //!
+    MCerPhotEvt       *fEvt;        //!
+    MSigmabar         *fSgb;        //!
+    MPedestalCam      *fPed;        //!
+    MArrivalTimeCam   *fTime;       //!
+    MIslands          *fIsl;        //!   
+   
+    TString           fIslName;
+
+    // IslandCleaningMethod_t fIslandCleaningMethod;
+    Int_t fIslandCleaningMethod;
+   
+    Float_t fIslCleanThres;
+
+    Int_t PreProcess(MParList *plist);
+    Int_t Process();
+           
+ public:
+    MIslandClean(const Float_t newThres=50, const char *name=NULL, const char *title=NULL);
+    
+    void SetInputName(TString inname)    {fIslName = inname;}
+    
+    //void SetMethod(IslandCleaningMethod_t m)   {fIslandCleaningMethod = m;}
+    void SetMethod(Int_t m)   {fIslandCleaningMethod = m;}
+    
+    ClassDef(MIslandClean, 0)        // task doing the island cleaning
+}; 
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MIslands.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MIslands.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MIslands.cc	(revision 9661)
@@ -0,0 +1,82 @@
+#include <fstream>
+
+#include "MIslands.h"
+
+#include "MCerPhotPix.h"
+#include "MCerPhotEvt.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MIslands);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MIslands::MIslands(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MIslands";
+    fTitle = title ? title : "Storage container for the island information of one event";
+    
+}
+
+// --------------------------------------------------------------------------
+//
+// Destructor.
+//
+MIslands::~MIslands()
+{
+  delete fPixNum;
+  delete fSigToNoise;
+  delete fTimeSpread;
+  delete fMeanX;
+  delete fMeanY;
+  delete fDist;
+  delete fDistL;
+  delete fDistW;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Getter functions
+//
+
+
+// --------------------------------------------------------------------------
+//
+// Setter functions
+//
+
+
+
+
+// --------------------------------------------------------------------------
+//
+// Print the island parameters to *fLog
+//
+void MIslands::Print(Option_t *opt=NULL) const
+{
+    *fLog << all;
+    *fLog << "Island Parameters (" << GetName() << ")"  << endl;
+    *fLog << " - Island Number   = " << fIslNum << endl;
+    for (Int_t i = 0; i< fIslNum ; i++)
+      {
+	*fLog << "   Island Id " << i  << endl;
+    	*fLog << "    + Pixel Number = " << fPixNum[i] << endl;
+    	*fLog << "    + SigToNoise = " << fSigToNoise[i] << endl;
+    	*fLog << "    + TimeSpread   [time slices]= " << fTimeSpread[i] << endl;
+    	*fLog << "    + MeanX   [mm]= " << fMeanX[i] << endl;
+    	*fLog << "    + MeanY   [mm]= " << fMeanY[i] << endl;
+    	*fLog << "    + Dist    [mm]= " << fDist[i] << endl;
+    	*fLog << "    + Length of the larger island  [mm]  = "  << fLength <<endl;
+	*fLog << "    + Width of the larger island  [mm]  = "  << fWidth <<endl;
+	*fLog << "    + DistL  = "  << fDistL[i] <<endl;
+    	*fLog << "    + DistW  = " << fDistW[i]  << endl;
+      }
+}
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MIslands.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MIslands.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MIslands.h	(revision 9661)
@@ -0,0 +1,92 @@
+#ifndef MARS_MIslands
+#define MARS_MIslands
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#ifndef ROOT_TArrayF
+#include <TArrayF.h>
+#endif
+
+#ifndef ROOT_TArrayI
+#include <TArrayI.h>
+#endif
+
+#ifndef ROOT_TObjArray
+#include <TObjArray.h>
+#endif
+
+class MIslands : public MParContainer
+{
+private:
+    // for description see MIslands.cc
+    Int_t fIslNum;             //  number of islands
+    //    Int_t** fIslId;      //[fIslNum]  island Id
+    // TObjArray fIslId;       //  island Id
+    Int_t fIslId[577];         //island Id
+    Int_t* fPixNum;            //[fIslNum]  number of pixels in the island
+    Float_t* fSigToNoise;      //[fIslNum]  signal to noise of the island
+    //  Float_t** fTime;       //[fIslNum]  mean of the arrival time
+    // Float_t fTime[10][577];        //  mean of the arrival time
+    Float_t* fTimeSpread;      //[fIslNum]  mean arrival time spread of the core pixels of the island  
+    Float_t* fMeanX;           //[fIslNum]  mean X position of the island
+    Float_t* fMeanY;           //[fIslNum]  mean Y position of the island
+    Float_t* fDist;            //[fIslNum]  dist between islands and continent(larger island)
+    Float_t fLength;           //  major axis of the larger island ellipse
+    Float_t fWidth;            //  minor axis of the larger island ellipse
+    Float_t* fDistL;           //[fIslNum] Dist of the island divided by Length of the larger island
+    Float_t* fDistW;           //[fIslNum] Dist of the island divided by Width of the larger island
+    
+public:
+    MIslands(const char *name=NULL, const char *title=NULL);
+    ~MIslands();
+
+    // void Clear();
+    void Print(Option_t *opt=NULL) const;
+    
+    //getter methods
+    Int_t    GetIslNum() const               { return fIslNum; }
+    Int_t    GetIslId(Int_t idx)  { return fIslId[idx]; }
+    //Int_t    GetIslId(Int_t isl, Int_t idx)  { return fIslId[isl][idx]; }
+    // TObjArray GetIslId()                    {return fIslId;}
+    //  Float_t  GetArrivalTime(Int_t isl, Int_t idx) { return fTime[isl][idx]; }     
+    //TObjArray GetArrivalTime()               { return fTime; }     
+    Int_t    GetPixNum(Int_t isl)            { return fPixNum[isl]; }
+    Float_t  GetSigToNoise(Int_t isl)        { return fSigToNoise[isl]; }      
+    Float_t  GetTimeSpread(Int_t isl)        { return fTimeSpread[isl];}          
+    Float_t  GetMeanX(Int_t isl)             { return fMeanX[isl];}
+    Float_t  GetMeanY(Int_t isl)             { return fMeanY[isl];}
+    Float_t  GetDist(Int_t isl)              { return fDist[isl]; }
+    Float_t  GetDistL(Int_t isl)             { return fDistL[isl]; }
+    Float_t  GetDistW(Int_t isl)             { return fDistW[isl]; }
+    
+    Float_t  GetLength() const               { return fLength; }
+    Float_t  GetWidth() const                { return fWidth; }
+
+    //setter functions    
+    void     SetIslNum(Int_t nisl)           { fIslNum = nisl; }
+    void     SetIslId(Int_t idx, Int_t isl)           { fIslId[idx] = isl; }
+    
+    // void     SetIslId(Int_t** vect)           { fIslId = vect; }
+    // void     SetArrivalTime(Int_t isl, Int_t idx, Float_t val)   { fTime[isl][idx] = val;}
+    //  void     SetArrivalTime(Float_t** vect)   { fTime = vect;}
+    void     SetPixNum(Int_t* npix)          { fPixNum = npix; }
+    void     SetSigToNoise(Float_t* val)     { fSigToNoise = val; }
+    void     SetTimeSpread(Float_t* val)     { fTimeSpread = val; }
+    void     SetMeanX( Float_t* val)         { fMeanX = val; }
+    void     SetMeanY(Float_t* val)          { fMeanY = val; }
+    void     SetDist(Float_t* val)           { fDist = val; }
+    void     SetDistL(Float_t* val)          { fDistL=val; }
+    void     SetDistW(Float_t* val)          { fDistW=val; }
+
+    void     SetLength(Float_t val)          { fLength=val; }
+    void     SetWidth(Float_t val)           { fWidth=val; }
+
+   
+    
+
+    ClassDef(MIslands, 2) // Storage Container for Island Parameters
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MLiveTime.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MLiveTime.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MLiveTime.cc	(revision 9661)
@@ -0,0 +1,75 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Javier López , 7/2004 <mailto:jlopez@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+#include "MLiveTime.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MLiveTime);
+
+using namespace std;
+
+MLiveTime::MLiveTime(UInt_t numberbins, const char *name, const char *title)
+{
+
+    fName  = name  ? name  : "MLiveTime";
+    fTitle = title ? title : "Container to hold the live time for a certain time bin";
+    
+    Set(numberbins);
+}
+
+void MLiveTime::Set(UInt_t numberbins)
+{
+  fNumberTimeBins = numberbins;
+  fLiveTimeBin.Set(numberbins);
+  fMeanRealTimeBin.Set(numberbins);
+  fWidthRealTimeBin.Set(numberbins);
+}
+
+void MLiveTime::Print(const Option_t* o) const
+{
+    TString opt = o;
+
+    Double_t totalLiveTime = 0;
+
+    if (opt.Contains("last", TString::kIgnoreCase))
+    {
+	*fLog << GetName() << ": Present real time bin " << setprecision(10) << fMeanRealTimeBin[fNumberTimeBins-1] << " +- " << setprecision(5) << fWidthRealTimeBin[fNumberTimeBins-1] << " [" <<  2*fWidthRealTimeBin[fNumberTimeBins-1]*24*60*60 << " sec] MJD" << endl;
+	*fLog << GetName() << ": Present live time " << fLiveTimeBin[fNumberTimeBins-1] << " sec" << endl;
+    }
+    else if (opt.Contains("all", TString::kIgnoreCase))
+    {
+	*fLog << GetName() << ": " << fNumberTimeBins << " time bins" << endl;
+	for (UInt_t bin = 0; bin<fNumberTimeBins; bin++)
+	{
+	    *fLog << GetName() << ": Present real time bin " << setprecision(10) << fMeanRealTimeBin[bin] << " +- " << setprecision(5) <<  fWidthRealTimeBin[bin] << " [" <<  2*fWidthRealTimeBin[bin]*24*60*60 << " sec] MJD" << endl;
+	    *fLog << GetName() << ": Present live time " << fLiveTimeBin[bin] << " sec" << endl;
+	    totalLiveTime += fLiveTimeBin[bin];
+	}		
+	*fLog << GetName() << ": Total live time " << totalLiveTime << " sec" << endl;
+    }
+    else
+	*fLog << GetName() << warn << "::Print() Bad argument " << opt << endl; 
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MLiveTime.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MLiveTime.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MLiveTime.h	(revision 9661)
@@ -0,0 +1,51 @@
+#ifndef MARS_MLiveTime
+#define MARS_MLiveTime
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#ifndef ROOT_TArrayD
+#include <TArrayD.h>
+#endif
+
+class MLiveTime : public MParContainer
+{
+ private:
+  
+  UInt_t fNumberTimeBins;
+  TArrayD fLiveTimeBin;
+  TArrayD fMeanRealTimeBin;
+  TArrayD fWidthRealTimeBin;
+  
+  void Set(UInt_t numberbins);
+
+ public:
+
+  MLiveTime(UInt_t numberbins = 1, const char *name=NULL, const char *title=NULL);
+  //~MLiveTime;
+
+  void AddBin() { Set(fNumberTimeBins+1); }
+  void AddTime(Double_t time) { fLiveTimeBin[fNumberTimeBins-1]+=time; }
+  void SetRealTime (Double_t mean, Double_t width)
+      {
+	  fMeanRealTimeBin[fNumberTimeBins-1]=mean;
+	  fWidthRealTimeBin[fNumberTimeBins-1]=width;
+      }
+
+  UInt_t GetNumberTimeBins() { return fNumberTimeBins;}
+  Double_t GetLiveTime() { return fLiveTimeBin[fNumberTimeBins-1]; }
+  Double_t GetMeanRealTime() { return fMeanRealTimeBin[fNumberTimeBins-1]; }
+  Double_t GetWidthRealTime() { return fWidthRealTimeBin[fNumberTimeBins-1]; }
+
+  TArrayD& GetLiveTimeTArray()      { return fLiveTimeBin; }
+  TArrayD& GetMeanRealTimeTArray()  { return fMeanRealTimeBin; }
+  TArrayD& GetWidthRealTimeTArray() { return fWidthRealTimeBin; }
+
+  void Print(const Option_t*) const;
+
+ ClassDef(MLiveTime, 1)    // Storage for the live time extracted from real data
+
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MLiveTimeCalc.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MLiveTimeCalc.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MLiveTimeCalc.cc	(revision 9661)
@@ -0,0 +1,360 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!   Author(s): Javier López , 7/2004 <mailto:jlopez@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MLiveTimeCalc
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MLiveTimeCalc.h"
+
+#include "MRawRunHeader.h"
+#include "MRawEvtHeader.h"
+#include "MLiveTime.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MTaskList.h"
+
+ClassImp(MLiveTimeCalc)
+using namespace std;
+
+Bool_t Debug = kFALSE;
+Bool_t PrintNewRun = kTRUE;
+
+MLiveTimeCalc::MLiveTimeCalc(const char *name, const char *title) : kSecTomSec(1e3), kDayToSec(24.*60.*60.), fRunHeader(NULL), fEvtHeader(NULL), fPresentEventTime(NULL), fLiveTime(NULL)
+{
+
+  fName  = name  ? name  : "MLiveTimeCalc";
+  fTitle = title ? title : "Task to compute the live time from real data.";
+
+  for (Int_t i=0; i<10; i++)
+    fNumberLostEvents[i] = 0;
+  
+  fFirstEventMjd = 0.;
+  fPresentEventMjd = 0.;
+  fLastEventMjd = 0.;
+
+  fPresentEventNumber = 0;
+  fLastEventNumber = 0;
+
+  fPresentEventRunNumber = 0;
+  fLastEventRunNumber = 0;
+
+  fRealTimeBinSize = 0.;
+
+  fPrintNextEvent = kFALSE;
+}
+
+Int_t MLiveTimeCalc::PreProcess(MParList *pList)
+{
+  
+  fEvtHeader = (MRawEvtHeader*)pList->FindObject(AddSerialNumber("MRawEvtHeader"));
+  if (!fEvtHeader)
+    {
+      *fLog << err << AddSerialNumber("MRawEvtHeader") << " not found ... aborting" << endl;
+      return kFALSE;
+    }
+  
+  fRunHeader = (MRawRunHeader*)pList->FindObject(AddSerialNumber("MRawRunHeader"));
+  if (!fRunHeader)
+    {
+      *fLog << err << AddSerialNumber("MRawRunHeader") << " not found ... aborting" << endl;
+      return kFALSE;
+    }
+  
+  fPresentEventTime = (MTime*)pList->FindObject(AddSerialNumber("MTime"));
+  if (!fPresentEventTime)
+    {
+      *fLog << err << AddSerialNumber("MTime") << " not found ... aborting" << endl;
+      return kFALSE;
+    }
+  
+  
+  fLiveTime = (MLiveTime*)pList->FindCreateObj(AddSerialNumber("MLiveTime"));
+  if (!fLiveTime)
+    {
+      *fLog << err << AddSerialNumber("MLiveTime") << " cannot be created ... aborting" << endl;
+      return kFALSE;
+    }
+  
+  return kTRUE;
+}
+
+Int_t MLiveTimeCalc::Process()
+{
+
+  fPresentEventMjd       = fPresentEventTime->GetMjd(); 
+  fLastEventMjd          = fLastEventTime.GetMjd();
+  fPreaviusLastEventMjd  = fPreaviusLastEventTime.GetMjd();
+
+  fPresentEventNumber    = fEvtHeader->GetDAQEvtNumber();
+  fPresentEventRunNumber = fRunHeader->GetRunNumber();;
+  
+  if (fPrintNextEvent && Debug)
+  {
+      *fLog << dbg << GetName() << ": Printing next event" << endl;
+      Print("all");
+      fLiveTime->Print("last");
+      *fLog << inf << endl; 
+      fPrintNextEvent = kFALSE;
+  }
+	  
+  if (fFirstEventMjd == 0)
+  {
+      fFirstEventMjd = fPresentEventMjd;
+
+      fPreaviusLastEventTime = fLastEventTime;
+      fLastEventTime = *fPresentEventTime;
+
+      fPreaviusLastEventRunNumber = fLastEventRunNumber;
+      fLastEventRunNumber = fPresentEventRunNumber;
+
+      fPreaviusLastEventNumber = fLastEventNumber;
+      fLastEventNumber = fPresentEventNumber;
+  }
+  else
+  {
+      if (isTimeStampOk())
+      {
+	  if (fRealTimeBinSize > 0 &&
+	      (fPresentEventMjd - fFirstEventMjd)*kDayToSec > fRealTimeBinSize)
+	  {
+
+	      Double_t width = (fLastEventMjd - fFirstEventMjd)/2;
+	      Double_t mean  = fFirstEventMjd + width;
+	      
+	      fLiveTime->SetRealTime(mean,width);
+	      
+	      if (Debug)
+		{
+		  *fLog << inf << GetName() << ": New time bin" << endl;
+		  Print("all");
+		  *fLog << GetName() << ": First event time " << setprecision(10) << fFirstEventMjd << setprecision(5) << endl;
+		  fLiveTime->Print("last");
+		}
+	      
+	      fLiveTime->AddBin();
+	      fFirstEventMjd = fPresentEventMjd;
+	  }      
+
+	  if (fPresentEventRunNumber!=fLastEventRunNumber)
+	  {
+	      if (fLastEventRunNumber != 0 && PrintNewRun)
+	      {
+		  *fLog << dbg << GetName() << ": New run" << endl;
+		  Print("all");
+		  fLiveTime->Print("last");
+		  *fLog << inf << endl;
+	      }
+	      fLastEventRunNumber = fPresentEventRunNumber;
+	  }
+	  else
+	      fLiveTime->AddTime((fPresentEventMjd-fLastEventMjd)*kDayToSec);
+	  
+
+      
+      fPreaviusLastEventTime = fLastEventTime;
+      fLastEventTime = *fPresentEventTime;
+
+      fPreaviusLastEventRunNumber = fLastEventRunNumber;
+      fLastEventRunNumber = fPresentEventRunNumber;
+
+      fPreaviusLastEventNumber = fLastEventNumber;      
+      fLastEventNumber = fPresentEventNumber;
+
+      }
+  }
+
+  return kTRUE;
+}
+  
+Int_t MLiveTimeCalc::PostProcess()
+{
+  Double_t width = (fLastEventMjd - fFirstEventMjd)/2;
+  Double_t mean  = fFirstEventMjd + width;
+ 
+  fLiveTime->SetRealTime(mean,width);
+
+  *fLog << dbg << endl;
+  *fLog << dbg << GetName() << ": PostProcess" << endl;
+  fLiveTime->Print("all");
+  *fLog << inf << endl;
+
+  *fLog << GetName() << " execution statistics:" << endl;
+  *fLog << dec << setfill(' ');
+
+  ULong_t fTotalNumberLostEvents = 0;
+  for (Int_t i=0; i<6; i++)
+    fTotalNumberLostEvents += fNumberLostEvents[i];
+
+  *fLog << " " << setw(7) << fTotalNumberLostEvents << " (" << setw(3) ;
+  *fLog << (Int_t)(fTotalNumberLostEvents*100/GetNumExecutions()) ;
+  *fLog << "%) bad time stamp events" << endl;
+
+  *fLog << "\t\t(" << setw(3) << (Int_t)(fNumberLostEvents[0]*100/fTotalNumberLostEvents) ;
+  *fLog << "%) time stamp == 0" << endl;
+
+  *fLog << "\t\t(" << setw(3) << (Int_t)(fNumberLostEvents[1]*100/fTotalNumberLostEvents) ;
+  *fLog << "%) last time stamp  == 0" << endl;
+
+  *fLog << "\t\t(" << setw(3) << (Int_t)(fNumberLostEvents[2]*100/fTotalNumberLostEvents) ;
+  *fLog << "%) time stamp in the past" << endl;
+
+  *fLog << "\t\t(" << setw(3) << (Int_t)(fNumberLostEvents[3]*100/fTotalNumberLostEvents) ;
+  *fLog << "%) time stamp == last one" << endl;
+
+  *fLog << "\t\t(" << setw(3) << (Int_t)(fNumberLostEvents[4]*100/fTotalNumberLostEvents) ;
+  *fLog << "%) time stamp just with integer part" << endl;
+
+  *fLog << "\t\t(" << setw(3) << (Int_t)(fNumberLostEvents[5]*100/fTotalNumberLostEvents) ;
+  *fLog << "%) run number < last one" << endl;
+
+  return kTRUE;
+}
+
+Bool_t MLiveTimeCalc::isTimeStampOk()
+{
+
+  Bool_t result = kTRUE;
+  
+
+  if (fPresentEventMjd == 0)
+    {
+	
+      if (Debug)
+	{
+	    *fLog << err << GetName() << ": Present event time stamp equal to 0" << endl;
+	    Print("all");
+	}
+
+      fNumberLostEvents[0]++;
+      result = kFALSE;
+      fPrintNextEvent = kTRUE;
+    }
+  else if (fLastEventMjd == 0)
+    {
+	
+      if (Debug)
+	{
+	    *fLog << err << GetName() << ": Last event time stamp equal to 0" << endl;
+	    Print("all");
+	}
+
+      fNumberLostEvents[1]++;
+      result = kFALSE;
+      fPrintNextEvent = kTRUE;
+    }
+  else if (fPresentEventMjd-fLastEventMjd < 0)
+    {
+      
+      if (Debug)
+	{
+	    *fLog << err << GetName() << ": Present event with time stamp in the past" << endl;
+	    Print("all");
+	}
+	  
+      fNumberLostEvents[2]++;
+      result = kFALSE;
+      fPrintNextEvent = kTRUE;
+    }
+  else if (fPresentEventMjd-fLastEventMjd == 0)
+    {
+      
+      if (Debug)
+	{
+	    *fLog << err << GetName() << ": Present event time stamp equal than last event" << endl;
+	    Print("all");
+	}
+      
+      fNumberLostEvents[3]++;
+      result = kFALSE;
+      fPrintNextEvent = kTRUE;
+    }
+  else if (fPresentEventNumber- fLastEventNumber<= 0 && fPresentEventRunNumber == fLastEventRunNumber)
+    {
+      
+      if (Debug)
+	{
+	    *fLog << warn << GetName() << ": Present event number equal or smaller than last event" << endl;
+	  Print("all");
+	}
+
+      result = kTRUE;
+      fPrintNextEvent = kTRUE;
+    }
+  else if ((Int_t)fPresentEventMjd == fPresentEventMjd)
+    {
+      
+      if (Debug)
+	{
+	    *fLog << err << GetName() << ": Present event time stamp idetical to midnight" << endl;
+	    Print("all");
+	}
+      
+      fNumberLostEvents[4]++;
+      result = kFALSE;
+      fPrintNextEvent = kTRUE;
+    }
+  else if  ((fPresentEventMjd-fLastEventMjd)*kDayToSec > 1.)
+  {
+      
+      if (Debug)
+      {
+	  *fLog << warn << GetName() << ": Time from last event bigger than 1 sec" << endl;
+	  Print("all");
+      }
+      
+      result = kTRUE;
+      fPrintNextEvent = kTRUE;
+  }
+  else if  (fPresentEventRunNumber-fLastEventRunNumber < 0)
+  {
+      
+      if (Debug)
+      {
+	  *fLog << warn << GetName() << ": Present run number previuos than last one" << endl;
+	  Print("all");
+      }
+      
+      fNumberLostEvents[5]++;
+      result = kTRUE;
+      fPrintNextEvent = kTRUE;
+  }
+
+  return result;
+}
+
+void MLiveTimeCalc::Print(const Option_t *o) const
+{
+
+  *fLog << "Present event run number       ["  << fPresentEventRunNumber << "] event number [" << fPresentEventNumber << ']' << endl;
+  *fLog << "Last event run number          ["  << fLastEventRunNumber << "] event number [" << fLastEventNumber << ']' << endl;
+  *fLog << "Preavius last event run number ["  << fPreaviusLastEventRunNumber << "] event number [" << fPreaviusLastEventNumber << ']' << endl;
+  *fLog << "Present, last and preavius to last event times:"  << endl;
+  fPresentEventTime->Print();
+  fLastEventTime.Print();
+  fPreaviusLastEventTime.Print();
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MLiveTimeCalc.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MLiveTimeCalc.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MLiveTimeCalc.h	(revision 9661)
@@ -0,0 +1,71 @@
+#ifndef MARS_MLiveTimeCalc
+#define MARS_MLiveTimeCalc
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+#ifndef MARS_MTime
+#include "MTime.h"
+#endif
+
+class MRawRunHeader;
+class MRawEvtHeader;
+class MLiveTime;
+
+class MLiveTimeCalc : public MTask
+{
+ public:
+  
+  const Double_t kSecTomSec;
+  const Double_t kDayToSec;
+  
+ private:
+  
+  MRawRunHeader* fRunHeader;
+  MRawEvtHeader* fEvtHeader;
+
+  MTime*         fPresentEventTime;
+  MTime          fLastEventTime;
+  MTime          fPreaviusLastEventTime;
+
+  MLiveTime*     fLiveTime;
+
+  
+  UInt_t   fNumberLostEvents[10];
+
+  Double_t fFirstEventMjd;
+  Double_t fPresentEventMjd;
+  Double_t fLastEventMjd;
+  Double_t fPreaviusLastEventMjd;
+
+  Int_t    fPresentEventNumber;
+  Int_t    fLastEventNumber;
+  Double_t fPreaviusLastEventNumber;
+
+  Int_t    fPresentEventRunNumber;
+  Int_t    fLastEventRunNumber;
+  Double_t fPreaviusLastEventRunNumber;
+
+  Double_t fRealTimeBinSize;
+  
+  Bool_t fPrintNextEvent;
+
+ public:
+
+  MLiveTimeCalc(const char *name=NULL, const char *title=NULL);
+  //~MLiveTimeCalc;
+
+  Int_t PreProcess(MParList *pList);
+  Int_t Process();
+  Int_t PostProcess();
+
+  void SetRealTimeBinSize(Double_t time) { fRealTimeBinSize=time; }
+
+  Bool_t isTimeStampOk();
+  void Print(const Option_t *o) const;
+
+ ClassDef(MLiveTimeCalc, 0)    // Task to compute the live time from real data
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MPSFFit.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MPSFFit.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MPSFFit.cc	(revision 9661)
@@ -0,0 +1,86 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Javier López , 4/2004 <mailto:jlopez@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+#include "MPSFFit.h"
+
+#include <TEllipse.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MPSFFit);
+
+using namespace std;
+
+MPSFFit::MPSFFit(const char *name, const char *title)
+{
+
+    fName  = name  ? name  : "MPSFFit";
+    fTitle = title ? title : "Container that holds the values of the PSF fit.";
+
+    fMaximun = -666.; 
+    fMeanMinorAxis = -666.; 
+    fMeanMajorAxis = -666.; 
+    fSigmaMinorAxis = -666.; 
+    fSigmaMajorAxis = -666.; 
+    fChisquare = -666.; 
+}
+
+void MPSFFit::Print(Option_t *opt) const
+{
+
+    *fLog << all << GetDescriptor() << " " << GetTitle() << endl;
+
+    *fLog << all << " Maximun \t " << fMaximun << " uA" << endl;
+    *fLog << all << " Mean Minor Axis \t " << fMeanMinorAxis << " mm \t";
+    *fLog << all << " Sigma Minor Axis \t " << fSigmaMinorAxis << " mm" << endl;
+    *fLog << all << " Mean Major Axis \t " << fMeanMajorAxis << " mm \t";
+    *fLog << all << " Sigma Major Axis \t " << fSigmaMajorAxis << " mm" << endl;
+    *fLog << all << " Chi Square \t " << fChisquare;
+    *fLog << all << endl;
+
+}
+
+// --------------------------------------------------------------------------
+//
+// Paint the ellipse corresponding to the parameters
+//
+void MPSFFit::Paint(Option_t *opt)
+{
+    if (fSigmaMinorAxis<0 || fSigmaMajorAxis<0)
+        return;
+
+    TEllipse e(fMeanMinorAxis, fMeanMajorAxis, fSigmaMinorAxis, fSigmaMajorAxis, 0, 360, 0);
+    e.SetLineWidth(2);
+    e.Paint();
+}
+
+void MPSFFit::Reset()
+{
+     SetMaximun(0.0);
+     SetMeanMinorAxis(0.0);
+     SetMeanMajorAxis(0.0);
+     SetSigmaMinorAxis(0.0);
+     SetSigmaMajorAxis(0.0);
+     SetChisquare(0.0);
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MPSFFit.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MPSFFit.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MPSFFit.h	(revision 9661)
@@ -0,0 +1,45 @@
+#ifndef MARS_MPSFFit
+#define MARS_MPSFFit
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+class MPSFFit : public MParContainer
+{
+private:
+
+    Float_t fMaximun;
+    Float_t fMeanMinorAxis;
+    Float_t fMeanMajorAxis;
+    Float_t fSigmaMinorAxis;
+    Float_t fSigmaMajorAxis;
+    Float_t fChisquare;
+
+public:
+    MPSFFit(const char *name=NULL, const char *title=NULL);
+    //~MPSFFit();
+
+    void SetMaximun(Float_t Maximun_) {fMaximun=Maximun_;}
+    void SetMeanMinorAxis(Float_t MeanMinorAxis_) {fMeanMinorAxis=MeanMinorAxis_;}
+    void SetMeanMajorAxis(Float_t MeanMajorAxis_) {fMeanMajorAxis=MeanMajorAxis_;}
+    void SetSigmaMinorAxis(Float_t SigmaMinorAxis_) {fSigmaMinorAxis=SigmaMinorAxis_;}
+    void SetSigmaMajorAxis(Float_t SigmaMajorAxis_) {fSigmaMajorAxis=SigmaMajorAxis_;}
+    void SetChisquare(Float_t Chisquare_) {fChisquare=Chisquare_;}
+
+    Float_t GetMaximun() {return fMaximun;}
+    Float_t GetMeanMinorAxis() {return fMeanMinorAxis;}
+    Float_t GetMeanMajorAxis() {return fMeanMajorAxis;}
+    Float_t GetSigmaMinorAxis() {return fSigmaMinorAxis;}
+    Float_t GetSigmaMajorAxis() {return fSigmaMajorAxis;}
+    Float_t GetChisquare() {return fChisquare;}
+
+    void Reset();
+
+    void Paint(Option_t *opt=NULL);
+    void Print(Option_t *opt=NULL) const;
+
+    ClassDef(MPSFFit, 1) // Container that holds the values of the PSF fit.
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MPSFFitCalc.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MPSFFitCalc.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MPSFFitCalc.cc	(revision 9661)
@@ -0,0 +1,569 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Javier López , 4/2004 <mailto:jlopez@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+#include "MPSFFitCalc.h"
+
+#include <iostream>
+
+
+#include <TH1D.h>
+#include <TString.h>
+#include <TArrayS.h>
+#include <TArrayI.h>
+#include <TArrayD.h>
+#include <TMinuit.h>
+#include <TStopwatch.h>
+
+#include "MGeomPix.h"
+#include "MGeomCam.h"
+#include "MMinuitInterface.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+ClassImp(MPSFFitCalc);
+
+using namespace std;
+
+
+const Int_t numVar = 5;
+const Float_t pixelSize = 31.5; //[mm]
+const Float_t sqrt2 = sqrt(2.);
+const Float_t sqrt3 = sqrt(3.);
+const Bool_t usePrintOut = kTRUE;
+const Int_t minuitPrintOut = 0;
+
+UInt_t  numPixels;
+Bool_t  isPixelUsed[577];
+UInt_t  numPixelsUsed;
+Float_t pixelPosX[577];
+Float_t pixelPosY[577];
+Float_t pixelValue[577];
+Float_t ChiSquare;
+
+MPSFFitCalc::MPSFFitCalc(ImgCleanMode_t imgmode, const char *name, const char *title)
+{
+    fName  = name  ? name  : "MPSFFitCalc";
+    fTitle = title ? title : "Task that fits the PSF using the dc readout of the camera.";
+
+    fImgCleanMode = imgmode;
+    fNumRings     = 6;
+    fPedLevel     = 3.0; 
+
+
+// Initialization of the camera dc mask 'fIsPixelused[]'
+    numPixels = 577;
+    for (UInt_t pixid=0; pixid<numPixels; pixid++)
+	isPixelUsed[pixid] = kTRUE;
+
+    fTotalMeanFit.Reset();
+    fNumTotalMeanFits = 0;
+
+    fMaxDC = 30.;
+
+    fPedestalDCHist = new TH1D("ped","",(Int_t)fMaxDC*10,0.,fMaxDC);
+
+    fVname = new TString[numVar];
+    fVinit.Set(numVar); 
+    fStep.Set(numVar); 
+    fLimlo.Set(numVar); 
+    fLimup.Set(numVar); 
+    fFix.Set(numVar);
+
+
+    fVname[0] = "max";
+    fVinit[0] = fMaxDC;
+    fStep[0]  = fVinit[0]/sqrt2;
+    fLimlo[0] = 1.;
+    fLimup[0] = 40.;
+    fFix[0]   = 0;
+
+    fVname[1] = "meanminor";
+    fVinit[1] = 0.;
+    fStep[1]  = fVinit[0]/sqrt2;
+    fLimlo[1] = -600.;
+    fLimup[1] = 600.;
+    fFix[1]   = 0;
+
+    fVname[2] = "sigmaminor";
+    fVinit[2] = pixelSize;
+    fStep[2]  = fVinit[0]/sqrt2;
+    fLimlo[2] = pixelSize/(2*sqrt3);
+    fLimup[2] = 500.;
+    fFix[2]   = 0;
+
+    fVname[3] = "meanmajor";
+    fVinit[3] = 0.;
+    fStep[3]  = fVinit[0]/sqrt2;
+    fLimlo[3] = -600.;
+    fLimup[3] = 600.;
+    fFix[3]   = 0;
+
+    fVname[4] = "sigmamajor";
+    fVinit[4] = pixelSize;
+    fStep[4]  = fVinit[0]/sqrt2;
+    fLimlo[4] = pixelSize/(2*sqrt3);
+    fLimup[4] = 500.;
+    fFix[4]   = 0;
+
+    fObjectFit  = NULL;
+    //    fMethod     = "SIMPLEX";
+    fMethod     = "MIGRAD";
+    fNulloutput = kFALSE;
+}
+
+MPSFFitCalc::~MPSFFitCalc()
+{
+  delete fPedestalDCHist;
+}
+
+//______________________________________________________________________________
+//
+// The 2D gaussian fucntion used to fit the spot of the star
+//
+static Double_t func(float x,float y,Double_t *par)
+{
+    Double_t value=par[0]*exp(-(x-par[1])*(x-par[1])/(2*par[2]*par[2]))*exp(-(y-par[3])*(y-par[3])/(2*par[4]*par[4]));
+    return value;
+}
+
+//______________________________________________________________________________
+//
+// Function used by Minuit to do the fit
+//
+static void fcnPSF(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)
+{
+
+//calculate chisquare
+    Double_t chisq = 0;
+    Double_t delta;
+    Double_t x,y,z;
+    Double_t errorz = 0.2; //[uA]
+
+
+    for (UInt_t pixid=1; pixid<numPixels; pixid++) 
+    {
+
+	if (isPixelUsed[pixid] && pixelValue[pixid]>0.)
+	{
+	    x = pixelPosX[pixid];
+	    y = pixelPosY[pixid];
+	    z = pixelValue[pixid];
+
+	    if (errorz > 0.0)
+	    {
+		delta  = (z-func(x,y,par))/errorz;
+		chisq += delta*delta;
+	    }
+	    else
+		cerr << "ERROR fcnPSF: This should never happen errorz[" << pixid << "] " << errorz << endl;
+	}
+    }
+    f = chisq;
+    ChiSquare = chisq;
+
+}
+
+
+void MPSFFitCalc::InitFitVariables()
+{
+
+  for (UInt_t pixid=1; pixid<577; pixid++) 
+    pixelValue[pixid]=(Float_t)((*fCamera)[pixid]);
+
+  numPixelsUsed = 0;
+  Float_t totalDC = 0.0;
+  
+    fVinit[0] = fMaxDC;
+
+    if(usePrintOut)
+      *fLog << dbg << "Pixels used in the fit \t";
+
+    for (UInt_t idx=0; idx<numPixels; idx++)
+    {
+	if (isPixelUsed[idx])
+	{
+	    fVinit[1] += pixelPosX[idx]*pixelValue[idx];
+	    fVinit[3] += pixelPosY[idx]*pixelValue[idx];
+	    totalDC += pixelValue[idx];
+	    numPixelsUsed++;
+
+	    if(usePrintOut)
+	      *fLog << dbg << ' ' << idx; 
+	}
+    }
+    if(usePrintOut)
+      *fLog << dbg << endl;
+
+     
+    fVinit[1] /= totalDC;
+    fVinit[3] /= totalDC;
+    
+
+    fVinit[2] = pixelSize*sqrt((Float_t)numPixelsUsed)/2;
+    fVinit[4] = pixelSize*sqrt((Float_t)numPixelsUsed)/3;
+
+    //Init steps
+
+    for(Int_t i=0; i<numVar; i++)
+	if (fVinit[i] != 0)
+	  fStep[i] = TMath::Abs(fVinit[i]/sqrt2);
+
+    
+    for (UInt_t pixidx=0; pixidx<numPixels; pixidx++)
+      if ( (*fGeomCam)[pixidx].GetSector() == 6)
+	fPedestalDCHist->Fill(pixelValue[pixidx]);
+    
+    fPedestalDC = fPedestalDCHist->GetBinCenter(fPedestalDCHist->GetMaximumBin());
+
+    for (UInt_t pixid=1; pixid<577; pixid++) 
+      pixelValue[pixid]-=fPedestalDC;
+
+    if(usePrintOut)
+      {
+	*fLog << dbg << "numPixelsUsed \t" << numPixelsUsed << endl;
+	*fLog << dbg << "fPedestalDC \t" << fPedestalDC << endl;
+	*fLog << dbg << "Maximun DC Init. value \t" << fVinit[0] << endl;
+	*fLog << dbg << "Mean Minor Axis Init. value \t" << fVinit[1] << " mm\t";
+	*fLog << dbg << "Sigma Minor Axis Init. value \t" << fVinit[2] << endl;
+	*fLog << dbg << "Mean Major Axis Init. value \t" << fVinit[3] << " mm\t";
+	*fLog << dbg << "Sigma Major Axis Init. value \t" << fVinit[4] << endl;
+      }
+}
+
+void MPSFFitCalc::RingImgClean()
+{
+
+  Bool_t  isPixelUsedTmp[577];
+
+  fMaxDC=0;
+  UInt_t maxDCpix[2];
+
+
+// Look for the two neighbor pixels with the maximun signal and set all pixels as unused
+    Float_t dc[2];
+    Float_t dcsum;
+
+// Find the two close pixels with the maximun dc
+    for(UInt_t pixidx=0; pixidx<numPixels; pixidx++)
+    {
+
+      if(isPixelUsed[pixidx])
+	{
+	  dc[0] = (Float_t)(*fCamera)[pixidx];
+	  isPixelUsedTmp[pixidx] = kFALSE;
+	  
+	  MGeomPix g = (*fGeomCam)[pixidx];
+	  Int_t numNextNeighbors = g.GetNumNeighbors();
+	  
+	  for(Int_t nextNeighbor=0; nextNeighbor<numNextNeighbors; nextNeighbor++)
+	    {
+	      if(isPixelUsed[pixidx])
+		{
+		  UInt_t swneighbor = g.GetNeighbor(nextNeighbor);
+		  dc[1] = (Float_t)(*fCamera)[swneighbor];
+		  
+		  dcsum = dc[0] + dc[1];
+		  
+		  if(dcsum > fMaxDC*2)
+		    {
+		      maxDCpix[0] = pixidx;
+		      maxDCpix[1] = swneighbor;
+		      fMaxDC = dcsum/2;
+		    }	
+		}
+	    }
+	}
+    }
+
+// Those variables are:
+// 1. an array of 2 dimensions
+//    1.1 the first dimension store the ring around the 'maxiun signal pixel'
+//    1.2 the sw numbers of the pixels in this ring
+// 2. an array with the number of pixels in each ring
+    UInt_t isPixelUesdInRing[fNumRings][577];
+    UInt_t numPixelsUsedInRing[fNumRings];
+
+// Store the 'maximun signal pixel in the [0] ring and set it as used 
+
+    for (Int_t core=0; core<2; core++)
+    {
+	isPixelUesdInRing[0][0] = maxDCpix[core];
+	numPixelsUsedInRing[0] = 1;
+	isPixelUsedTmp[isPixelUesdInRing[0][0]] = kTRUE;
+	
+	UInt_t count;
+	
+// Loop over the neighbors of the previus ring and store the sw numbers in the 2D array to be 
+// use in the next loop/ring 
+	for (UShort_t ring=0; ring<fNumRings-1; ring++)
+	{
+	    count = 0;  // In this variable we count the pixels we are in each ring
+	    for(UInt_t nextPixelUsed=0; nextPixelUsed<numPixelsUsedInRing[ring]; nextPixelUsed++)
+	    {
+		MGeomPix g = (*fGeomCam)[isPixelUesdInRing[ring][nextPixelUsed]];
+		Int_t numNextNeighbors = g.GetNumNeighbors();
+		for(Int_t nextNeighbor=0; nextNeighbor<numNextNeighbors; nextNeighbor++)
+		{
+		    UInt_t swneighbor = g.GetNeighbor(nextNeighbor);
+		    if (!isPixelUsedTmp[swneighbor])
+		    {
+			isPixelUsedTmp[swneighbor] = kTRUE;
+			isPixelUesdInRing[ring+1][count] = swneighbor;
+			count++;
+		    }
+		}
+		numPixelsUsedInRing[ring+1] = count;
+	    }
+	}
+
+
+    if(usePrintOut)
+      {
+	for (UInt_t row=0; row<fNumRings; row++)
+	  {
+	    
+	    *fLog << dbg  << "fIsPixeUsed[" << row << "][" << numPixelsUsedInRing[row] << "] ";
+	    for (UInt_t column=0; column<numPixelsUsedInRing[row]; column++)
+	      *fLog << dbg << isPixelUesdInRing[row][column] << ' ';
+	    *fLog << dbg << endl;
+	  }	
+      }
+    }
+
+
+    for(UInt_t pixidx=0; pixidx<numPixels; pixidx++)
+      {
+      if(isPixelUsed[pixidx] && isPixelUsedTmp[pixidx])
+	  isPixelUsed[pixidx] = kTRUE;
+      else
+	  isPixelUsed[pixidx] = kFALSE;
+      }
+
+}
+
+void MPSFFitCalc::RmsImgClean(Float_t pedestal)
+{}
+
+void MPSFFitCalc::MaskImgClean(TArrayS blindpixels)
+{
+    
+    Int_t npix = blindpixels.GetSize();
+
+    for (Int_t idx=0; idx<npix; idx++)
+	isPixelUsed[blindpixels[idx]] = kFALSE;
+
+}
+
+// --------------------------------------------------------------------------
+//
+// The PreProcess searches for the following input containers:
+//  - MCameraDC
+//
+// The following output containers are also searched and created if
+// they were not found:
+//
+//  - MPSFFit
+//
+Int_t MPSFFitCalc::PreProcess(MParList *pList)
+{
+
+    fGeomCam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
+
+    if (!fGeomCam)
+    {
+      *fLog << err << AddSerialNumber("MGeomCam") << " not found ... aborting" << endl;
+      return kFALSE;
+    }
+
+// Initialize positions of the pixels to be used in the minuit minimizations
+
+    for (UInt_t pixid=1; pixid<577; pixid++) 
+    {
+	MGeomPix &pix=(*fGeomCam)[pixid];
+	pixelPosX[pixid] = pix.GetX();
+	pixelPosY[pixid] = pix.GetY();
+    }
+   
+    fCamera = (MCameraDC*)pList->FindObject(AddSerialNumber("MCameraDC"));
+
+    if (!fCamera)
+    {
+      *fLog << err << AddSerialNumber("MCameraDC") << " not found ... aborting" << endl;
+      return kFALSE;
+    }
+
+    fFit = (MPSFFit*)pList->FindCreateObj(AddSerialNumber("MPSFFit"));
+    if (!fFit)
+    {
+      *fLog << err << AddSerialNumber("MPSFFit") << " cannot be created ... aborting" << endl;
+      return kFALSE;
+    }
+    
+    // Minuit initialization
+
+    TMinuit *gMinuit = new TMinuit(6);  //initialize TMinuit with a maximum of 5 params
+    gMinuit->SetFCN(fcnPSF);
+
+    Double_t arglist[10];
+    Int_t ierflg = 0;
+
+    arglist[0] = 1;
+    gMinuit->mnexcm("SET ERR", arglist ,1,ierflg);
+    arglist[0] = minuitPrintOut;
+    gMinuit->mnexcm("SET PRI", arglist ,1,ierflg);
+
+    return kTRUE;
+
+}
+
+Int_t MPSFFitCalc::Process()
+{
+
+    // ------------------------------------------
+    // image cleaning
+
+    switch(fImgCleanMode)
+    {
+	case kRing:
+	{
+	    RingImgClean();
+	    break;
+	}
+	case kRms:
+	{
+	    RmsImgClean(fPedLevel);
+	    break;
+	}
+	case kMask:
+	{
+	    MaskImgClean(fBlindPixels);
+	    break;
+	}
+	case kCombined:
+	{
+	    MaskImgClean(fBlindPixels);
+	    RingImgClean();
+	    MaskImgClean(fBlindPixels);
+	    break;
+	}
+	default:
+	{
+	    *fLog << err << "Image Cleaning mode " << fImgCleanMode << " not defined" << endl;
+	    return kFALSE;
+	}
+    }
+
+    InitFitVariables();
+
+    // -------------------------------------------
+    // call MINUIT
+
+    Double_t arglist[10];
+    Int_t ierflg = 0;
+
+    for (Int_t i=0; i<numVar; i++)
+      gMinuit->mnparm(i, fVname[i], fVinit[i], fStep[i], fLimlo[i], fLimup[i], ierflg);
+
+    TStopwatch clock;
+    clock.Start();
+
+// Now ready for minimization step
+    arglist[0] = 500;
+    arglist[1] = 1.;
+    gMinuit->mnexcm(fMethod, arglist ,2,ierflg);
+
+    clock.Stop();
+
+    if(usePrintOut)
+      {
+	*fLog << dbg << "Time spent for the minimization in MINUIT :   " << endl;;
+	clock.Print();
+      }
+
+    if (ierflg)
+    {
+	*fLog << err << "MMinuitInterface::CallMinuit error " << ierflg << endl;
+	return kCONTINUE;
+    }
+    
+    fNumTotalMeanFits++;
+
+    Double_t parm,parmerr;
+    
+    gMinuit->GetParameter(0,parm,parmerr);
+    fFit->SetMaximun(parm);
+    fTotalMeanFit.SetMaximun(fTotalMeanFit.GetMaximun()+parm);
+
+    gMinuit->GetParameter(1,parm,parmerr);
+    fFit->SetMeanMinorAxis(parm);
+    fTotalMeanFit.SetMeanMinorAxis(fTotalMeanFit.GetMeanMinorAxis()+parm);
+
+    gMinuit->GetParameter(2,parm,parmerr);
+    fFit->SetSigmaMinorAxis(parm);
+    fTotalMeanFit.SetSigmaMinorAxis(fTotalMeanFit.GetSigmaMinorAxis()+parm);
+
+    gMinuit->GetParameter(3,parm,parmerr);
+    fFit->SetMeanMajorAxis(parm);
+    fTotalMeanFit.SetMeanMajorAxis(fTotalMeanFit.GetMeanMajorAxis()+parm);
+
+    gMinuit->GetParameter(4,parm,parmerr);
+    fFit->SetSigmaMajorAxis(parm);
+    fTotalMeanFit.SetSigmaMajorAxis(fTotalMeanFit.GetSigmaMajorAxis()+parm);
+
+    fFit->SetChisquare(ChiSquare/(numPixelsUsed-numVar));
+    fTotalMeanFit.SetChisquare(fTotalMeanFit.GetChisquare()+ChiSquare/(numPixelsUsed-numVar));
+
+    if(usePrintOut)
+      {
+	fFit->Print();
+	fTotalMeanFit.Print();
+      }
+
+    return kTRUE;
+}
+
+Int_t MPSFFitCalc::PostProcess()
+{
+  
+  fTotalMeanFit.SetMaximun(fTotalMeanFit.GetMaximun()/fNumTotalMeanFits);
+  fTotalMeanFit.SetMeanMinorAxis(fTotalMeanFit.GetMeanMinorAxis()/fNumTotalMeanFits);
+  fTotalMeanFit.SetSigmaMinorAxis(fTotalMeanFit.GetSigmaMinorAxis()/fNumTotalMeanFits);
+  fTotalMeanFit.SetMeanMajorAxis(fTotalMeanFit.GetMeanMajorAxis()/fNumTotalMeanFits);
+  fTotalMeanFit.SetSigmaMajorAxis(fTotalMeanFit.GetSigmaMajorAxis()/fNumTotalMeanFits);
+  fTotalMeanFit.SetChisquare(fTotalMeanFit.GetChisquare()/fNumTotalMeanFits);
+
+  fFit->SetMaximun(fTotalMeanFit.GetMaximun());
+  fFit->SetMeanMinorAxis(fTotalMeanFit.GetMeanMinorAxis());
+  fFit->SetSigmaMinorAxis(fTotalMeanFit.GetSigmaMinorAxis());
+  fFit->SetMeanMajorAxis(fTotalMeanFit.GetMeanMajorAxis());
+  fFit->SetSigmaMajorAxis(fTotalMeanFit.GetSigmaMajorAxis());
+  fFit->SetChisquare(fTotalMeanFit.GetChisquare());
+
+    if(usePrintOut)
+      fTotalMeanFit.Print();
+    
+  return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MPSFFitCalc.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MPSFFitCalc.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MPSFFitCalc.h	(revision 9661)
@@ -0,0 +1,93 @@
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MPSFFitCalc                                                             //
+//                                                                         //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#ifndef MARS_MPSFFitCalc
+#define MARS_MPSFFitCalc
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+#ifndef ROOT_TArrayD
+#include <TArrayD.h>
+#endif
+#ifndef ROOT_TArrayI
+#include <TArrayI.h>
+#endif
+#ifndef ROOT_TArrayS
+#include <TArrayS.h>
+#endif
+
+class TSring;
+class TH1D;
+
+class MGeomCam;
+#ifndef MARS_MCameraDC
+#include "MCameraDC.h"
+#endif
+#ifndef MARS_MPSFFit
+#include "MPSFFit.h"
+#endif
+
+class MPSFFitCalc : public MTask
+{
+
+private:
+ 
+    MGeomCam  *fGeomCam;
+    MCameraDC *fCamera; 
+    MPSFFit   *fFit;
+
+    MPSFFit   fTotalMeanFit;
+    UInt_t    fNumTotalMeanFits;
+    
+    TH1D *fPedestalDCHist;
+    Float_t fPedestalDC;
+
+    TString *fVname;
+    TArrayD fVinit; 
+    TArrayD fStep; 
+    TArrayD fLimlo; 
+    TArrayD fLimup; 
+    TArrayI fFix;
+    TObject *fObjectFit;
+    TString fMethod;
+    Bool_t fNulloutput;
+
+    Float_t fMaxDC;
+    UShort_t fImgCleanMode;
+    UShort_t fNumRings;
+    Float_t fPedLevel;
+    TArrayS fBlindPixels;
+
+    void RingImgClean();
+    void RmsImgClean(Float_t pedestal);
+    void MaskImgClean(TArrayS blindpixels);
+
+    void InitFitVariables();
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
+public:
+
+    enum ImgCleanMode_t{kNone=0,kRing,kRms,kMask,kCombined};
+    static const ImgCleanMode_t kDefault = kRing;
+
+    MPSFFitCalc(ImgCleanMode_t imgmode=kDefault, const char *name=NULL, const char *title=NULL);
+    ~MPSFFitCalc();
+    
+    void SetImgCleanMode(ImgCleanMode_t imgmode=kDefault){ fImgCleanMode=imgmode;};
+    void SetNumRings(UShort_t numRings) {fNumRings=numRings;}
+    void SetPedLevel(Float_t pedestal) {fPedLevel=pedestal;}
+    void SetBlindPixels(TArrayS blindpixels) {fBlindPixels=blindpixels;}
+    
+
+    ClassDef(MPSFFitCalc, 0)   // Task that fits the PSF using the dc readout of the camera.
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MSrcPlace.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MSrcPlace.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MSrcPlace.cc	(revision 9661)
@@ -0,0 +1,213 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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    04/2004 <mailto:jlopez@ifae.es>
+!   Author(s): Javier Rico     04/2004 <mailto:jrico@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// MSrcPlace
+//
+// Abstract task to set the source position in any place in the camera
+// It keeps a 2D histogram with the assigned positions, so that the same
+// distribution can be applied later to any data set (tipically the OFF data)
+// Classes inheritating MSrcPlace should override the ComputeNewSrcPosition() 
+// method and probably include a call to MsrcPlace::PreProcess in their
+// PreProcess method (see, e.g., MSrcPosFromFile or MSrcRotate classes)
+//
+//  Input Containers:
+//    MSrcPosCam
+//
+//  Output Containers:
+//    MSrcPosCam
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <fstream>
+#include <math.h>
+
+#include "TH2F.h"
+
+#include "MParList.h"
+#include "MSrcPlace.h"
+#include "MSrcPosCam.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MSrcPlace);
+
+using namespace std;
+
+static const TString gsDefName  = "MSrcPlace";
+static const TString gsDefTitle = "Set the position of the source";
+
+// -------------------------------------------------------------------------
+//
+// Default constructor. The first argument is the name of the internal histo, 
+// the second (third) argument is the name of the input (output) container
+// containing the source position in the camera plain. 
+//
+MSrcPlace::MSrcPlace(const char* srcPosIn, const char* srcPosOut,  const char *name, const char *title)
+  : fSrcPosIn(NULL), fSrcPosOut(NULL), fHistoName("SrcPosHist"), 
+    fHistoBinPrec(1.), fHistPos(NULL)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+
+    fSrcPosInName   = srcPosIn;
+    fSrcPosOutName  = srcPosOut;
+
+    fMode=kOn;
+    fCreateHisto=kTRUE;
+}
+// -------------------------------------------------------------------------
+//
+// Destructor
+//
+MSrcPlace::~MSrcPlace()
+{
+  if(fHistPos)
+    delete fHistPos;
+}
+
+// -------------------------------------------------------------------------
+//
+// Save the position of the source in the histogram
+//
+void MSrcPlace::SavePosIntoHisto()
+{  
+  if(fHistPos)
+    fHistPos->Fill(fSrcPosOut->GetX(),fSrcPosOut->GetY());
+}
+// -------------------------------------------------------------------------
+//
+// Read the position of the source from the histogram
+//
+void MSrcPlace::ReadPosFromHisto()
+{  
+  if(fHistPos)
+    {
+      Axis_t x;
+      Axis_t y;
+      
+      fHistPos->GetRandom2(x,y);
+      fSrcPosOut->SetXY(x,y);
+    }
+}
+// -------------------------------------------------------------------------
+//
+// Look for needed containers.
+// Check processing mode and if histogram is filled in case kOff mode
+//
+Int_t MSrcPlace::PreProcess(MParList* pList)
+{ 
+  // create (if needed and requested) internal histogram
+  if(fCreateHisto && !fHistPos)
+    {
+      const Float_t cameraSize   = 600; //[mm]
+      const UInt_t nbins =  (UInt_t)(cameraSize*2/fHistoBinPrec);
+      fHistPos = new TH2F(fHistoName,"",nbins,-cameraSize,cameraSize,nbins,-cameraSize,cameraSize);
+      fHistPos->SetDirectory(0);
+      *fLog << inf << "MSrcPlace::PreProcess Message: internal histogram " << fHistoName << " created with " << nbins << "x" << nbins << " bins" << endl;
+    }
+
+  // look for/create input MSrcPosCam
+  fSrcPosIn = (MSrcPosCam*)pList->FindObject(AddSerialNumber(fSrcPosInName), "MSrcPosCam");
+  if (!fSrcPosIn)
+    {
+      *fLog << warn << AddSerialNumber(fSrcPosInName) << " [MSrcPosCam] not found... creating default container." << endl;
+      fSrcPosIn = (MSrcPosCam*)pList->FindCreateObj("MSrcPosCam", AddSerialNumber(fSrcPosInName));
+      if(!fSrcPosIn)
+	return kFALSE;
+    }
+
+  // look for/create output MSrcPosCam
+  fSrcPosOut = (MSrcPosCam*)pList->FindObject(AddSerialNumber(fSrcPosOutName), "MSrcPosCam");
+  if (!fSrcPosOut)
+    {
+      *fLog << warn << AddSerialNumber(fSrcPosOutName) << " [MSrcPosCam] not found... creating default container." << endl;
+      fSrcPosOut = (MSrcPosCam*)pList->FindCreateObj("MSrcPosCam", AddSerialNumber(fSrcPosOutName));
+      if(!fSrcPosOut)
+	return kFALSE;
+    }
+
+  // check mode, look for a filled histogram in case kOff
+  if(fHistPos)
+    {
+      if(fMode==kOn)
+	*fLog << inf << "MSrcPlace PreProcess Message: source postions will be stored in internal histo (" << fHistPos->GetName() << ")" << endl;
+      else
+	{
+	  if(fHistPos->GetEntries())
+	    *fLog << inf << "MSrcPlace PreProcess Message: source postions will be read from internal histo (" << fHistPos->GetName() << ")" << endl;
+	  else
+	    {
+	      *fLog << err << "MSrcPlace PreProcess Error: source postions attempted to be read from empty histo (" << fHistPos->GetName() << ")" << endl;
+	      return kFALSE;
+	    }
+	}
+    }
+  return kTRUE;
+}
+
+// -------------------------------------------------------------------------
+//
+// Call to compute a new position and then save it in the histogram (fMode==kOn) 
+// of to read the new position from the histogram (fMode==kOff)
+//
+Int_t MSrcPlace::Process()
+{  
+  switch(fMode)
+    {
+    case kOn:
+      if(!ComputeNewSrcPosition())
+	return kFALSE;
+      SavePosIntoHisto();
+      break;
+    case kOff:
+      ReadPosFromHisto();
+      break;
+    default:
+      *fLog << err << "MSrcPlace::Process Warning: Wrong mode " << fMode << endl;
+      return kFALSE;
+    }
+  return kTRUE;
+}
+
+// -------------------------------------------------------------------------
+//
+// Dump 2D histo statistics
+//
+Int_t MSrcPlace::PostProcess()
+{
+  if(fMode==kOn && fHistPos)
+    {
+      *fLog << inf << endl;
+      *fLog << inf << "MSrcPlace::PostProcess Message: Created internal histogram with: " << endl;
+      *fLog << inf << "Entries: " << fHistPos->GetEntries() << endl;
+      *fLog << inf << "X projection mean: " << fHistPos->ProjectionX()->GetMean() << endl;
+      *fLog << inf << "X projection rms:  " << fHistPos->ProjectionX()->GetRMS() << endl;
+      *fLog << inf << "Y projection mean: " << fHistPos->ProjectionY()->GetMean() << endl;
+      *fLog << inf << "Y projection rms:  " << fHistPos->ProjectionY()->GetRMS() << endl;
+    }
+  return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MSrcPlace.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MSrcPlace.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MSrcPlace.h	(revision 9661)
@@ -0,0 +1,65 @@
+#ifndef MARS_MSrcPlace
+#define MARS_MSrcPlace
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+class MSrcPosCam;
+class TH2F;
+
+class MSrcPlace : public MTask
+{
+ public:
+  enum OnOffMode_t {kOn=0,kOff};
+  
+ private:
+  MSrcPosCam*  fSrcPosIn;       //  Pointer to the input source position container
+  MSrcPosCam*  fSrcPosOut;      //  Pointer to the output source position container
+  
+  TString      fSrcPosInName;   //  Name of the input MSrcPosCam object
+  TString      fSrcPosOutName;  //  Name of the output MSrcPosCam object
+
+  TString      fHistoName;      //  Name of internal histogram
+  Float_t      fHistoBinPrec;   //  [mm] internal histo bin size 
+
+  TH2F*        fHistPos;     //  histogram of the used source positions
+  OnOffMode_t   fMode;        //  On/Off data mode (write/read to/from the histogram)
+  Bool_t       fCreateHisto; //  flag to decide whether internal histo is created or not
+
+  void  SavePosIntoHisto();
+  void  ReadPosFromHisto();
+
+  virtual Int_t Process();
+  virtual Int_t PostProcess();
+
+ protected:
+  virtual Int_t PreProcess(MParList *plist);
+
+ public:
+  MSrcPlace(const char* srcin="MSrcPosCam",const char* srcout="MSrcPosCam", 
+	    const char* name=NULL, const char* title=NULL);
+
+  virtual ~MSrcPlace();
+
+  void SetMode(OnOffMode_t mode)            {fMode=mode;}
+  void SetInputSrcPosName(TString name)     {fSrcPosInName=name;}
+  void SetOutputSrcPosName(TString name)    {fSrcPosOutName=name;}
+  void SetInternalHistoName(TString name)   {fHistoName=name;}
+  void SetInternalHistoBinSize(Float_t size){fHistoBinPrec=size;}
+  void SetPositionHisto(TH2F* histo)     {fHistPos=histo;}
+  void SetCreateHisto(Bool_t inp=kTRUE)     {fCreateHisto=inp;}
+
+  OnOffMode_t   GetMode()              {return fMode;}
+  TH2F*         GetPositionHisto()     {return fHistPos;}
+  MSrcPosCam*   GetInputSrcPosCam()    {return fSrcPosIn;}
+  MSrcPosCam*   GetOutputSrcPosCam()   {return fSrcPosOut;}
+  TString       GetInternalHistoName() {return fHistoName;}
+  
+  virtual Int_t ComputeNewSrcPosition() {return kTRUE;}
+
+  ClassDef(MSrcPlace, 0) // task to rotate the position of the source as a function of Azimuth and Zenith angles
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MSrcPosFromFile.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MSrcPosFromFile.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MSrcPosFromFile.cc	(revision 9661)
@@ -0,0 +1,227 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Javier López  04/2004 <mailto:jlopez@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// MSrcPosFromFile
+//
+// Task to set the position of the source as a function of run number according
+// to the positions read from an input file
+//
+//  Output Containers:
+//    MSrcPosCam
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <fstream>
+
+#include "MParList.h"
+#include "MSrcPosFromFile.h"
+
+#include "MRawRunHeader.h"
+#include "MSrcPosCam.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+
+ClassImp(MSrcPosFromFile);
+
+using namespace std;
+
+static const TString gsDefName  = "MSrcPosFromFile";
+static const TString gsDefTitle = "Set the position of the (off axis) source according to input file";
+
+// -------------------------------------------------------------------------
+//
+// Default constructor. cardpath is the name of the input file (.pos) where the
+// source positions are stored in the format Run# x y (in mm). mode indicates whether
+// to read or to save the positions of the source in/from the internal histogram
+//
+MSrcPosFromFile::MSrcPosFromFile(TString cardpath, OnOffMode_t mode, const char *name, const char *title)
+  : fRawRunHeader(NULL), fSourcePositionFilePath(cardpath)
+{
+  fName  = name  ? name  : gsDefName.Data();
+  fTitle = title ? title : gsDefTitle.Data();
+  SetMode(mode);
+
+  fRunList=0x0;
+  fRunSrcPos=0x0;
+  fRunMap=0x0;
+
+  fLastRun  = 0;
+  fFirstRun = 0;
+  fLastValidSrcPosCam=0x0;
+
+  SetInternalHistoName(TString(fName)+"Hist");
+}
+// -------------------------------------------------------------------------
+//
+// Destructor
+//
+MSrcPosFromFile::~MSrcPosFromFile()
+{
+  if(fRunList)
+    delete [] fRunList;
+  if(fRunSrcPos)
+    delete [] fRunSrcPos;
+  if(fRunMap)
+    delete fRunMap;
+}
+
+// -------------------------------------------------------------------------
+//
+// Open and read the input file.
+Int_t MSrcPosFromFile::PreProcess(MParList *pList)
+{
+  if(GetMode()==MSrcPlace::kOn)
+    {
+      // Count the number of runs in the card with the source poistions
+      ReadSourcePositionsFile(kCount);
+      
+      if(!fRunList)
+	fRunList = new Int_t[fNumRuns];
+      if(!fRunSrcPos)
+	fRunSrcPos = new MSrcPosCam[fNumRuns];
+      if(!fRunMap)
+	fRunMap = new TExMap(fNumRuns);
+      
+      // Read card with the source poistions
+      ReadSourcePositionsFile(kRead);
+    }
+
+  if(!MSrcPlace::PreProcess(pList))
+    return kFALSE;
+  
+  fRawRunHeader = (MRawRunHeader*)pList->FindObject(AddSerialNumber("MRawRunHeader"));
+  if (!fRawRunHeader)
+    {
+      *fLog << err << AddSerialNumber("MRawRunHeader") << " not found ... aborting" << endl;
+      return kFALSE;
+    }
+  
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// In case we enter a new run, look for the position in the read list
+// If there is no value for that run, take the previous one
+// 
+Int_t MSrcPosFromFile::ComputeNewSrcPosition()
+{
+  const UInt_t run = fRawRunHeader->GetRunNumber();
+  if(run!=fLastRun)
+    {      
+      fLastRun=run;
+      MSrcPosCam* srcpos = (MSrcPosCam*)fRunMap->GetValue(run);
+
+      *fLog << inf << "Source position for run " << run;
+
+      if(srcpos)
+	fLastValidSrcPosCam = srcpos;
+      else if(run>fFirstRun)
+	for(UInt_t irun=run-1; irun>=fFirstRun;irun--)
+	  if((srcpos=(MSrcPosCam*)fRunMap->GetValue(irun)))
+	    {
+	      *fLog << inf << " not found in file. Taking position for run "<< irun;
+	      fLastValidSrcPosCam = srcpos;
+	      break;
+	    }
+      else if(fLastValidSrcPosCam)
+	*fLog << inf << " not found in file. Taking previous position: ";
+	
+      if(!fLastValidSrcPosCam)
+	{
+	  *fLog << warn << "MSrcPosFromFile::ComputeNewSrcPosition warning: no value for the first run. Taking first found run in file, run number " << fFirstRun;
+	  fLastValidSrcPosCam = (MSrcPosCam*)fRunMap->GetValue(fFirstRun);
+	}
+
+      *fLog << inf << "\tX\t" << setprecision(3) << fLastValidSrcPosCam->GetX();
+      *fLog << inf << "\tY\t" << setprecision(3) << fLastValidSrcPosCam->GetY() << endl;      
+    }
+
+  GetOutputSrcPosCam()->SetXY(fLastValidSrcPosCam->GetX(),fLastValidSrcPosCam->GetY());
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Read file with table of source positions as function of run
+// 
+Int_t MSrcPosFromFile::ReadSourcePositionsFile(UShort_t readmode)
+{
+  
+  ifstream fin(fSourcePositionFilePath);
+  if(!fin)
+    {
+      *fLog << err << "MSrcPosFromFile::ReadSourcePositionsFile. Cannot open file " << fSourcePositionFilePath << endl;
+      return kFALSE;
+    }
+  
+  UInt_t run;
+  Float_t x,y;
+  
+  fNumRuns=0;
+  
+  *fLog << dbg << "MSrcPosFromFile::ReadSourcePositionsFile(" << readmode << ')' << endl;
+  while(1)
+    {
+      fin >> run >> x >> y;
+      if(!fFirstRun) fFirstRun=run;
+      if(fin.eof())
+	break;
+      
+      switch(readmode)
+	{
+	case kCount:
+	  {
+	    
+	    *fLog << dbg << "Source position for run " << run;
+	    *fLog << dbg << "\tX\t" << x << " mm";
+	    *fLog << dbg << "\tY\t" << y << " mm" << endl;
+	    
+	    fNumRuns++;
+	    break;
+	  }
+	case kRead:
+	  {
+	    fRunList[fNumRuns] = run;
+	    fRunSrcPos[fNumRuns].SetXY(x,y);
+	    fRunMap->Add(fRunList[fNumRuns],(Long_t)&(fRunSrcPos[fNumRuns]));
+	    fNumRuns++;
+	    break;
+	  }
+	default:
+	  *fLog << err << "Read mode " << readmode << " node defined" << endl;
+	  return kFALSE;
+	}
+    }
+  
+  fin.close();
+  
+  
+  return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MSrcPosFromFile.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MSrcPosFromFile.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MSrcPosFromFile.h	(revision 9661)
@@ -0,0 +1,48 @@
+#ifndef MARS_MSrcPosFromFile
+#define MARS_MSrcPosFromFile
+
+#ifndef MARS_MSrcPlace
+#include "MSrcPlace.h"
+#endif
+
+#ifndef ROOT_TMap
+#include <TExMap.h>
+#endif
+
+class MRawRunHeader;
+class MSrcPosCam;
+
+class MSrcPosFromFile : public MSrcPlace
+{
+ private:
+
+    MRawRunHeader *fRawRunHeader;
+
+    Int_t  fNumRuns;
+    UInt_t  fFirstRun;
+    UInt_t  fLastRun;
+
+    Int_t      *fRunList;
+    MSrcPosCam *fRunSrcPos;
+    MSrcPosCam *fLastValidSrcPosCam;
+    TExMap     *fRunMap;   // list of run numbers positions
+
+    TString fSourcePositionFilePath;
+
+    virtual Int_t ReadSourcePositionsFile(UShort_t readmode);
+    virtual Int_t ComputeNewSrcPosition();
+    
+    virtual Int_t PreProcess(MParList *plist);
+    
+public:    
+    enum ReadMode_t {kCount=0,kRead};
+
+    MSrcPosFromFile(TString cardpath=0, OnOffMode_t mode=kOn, const char *name=NULL, const char *title=NULL);
+    ~MSrcPosFromFile();
+
+    void SetInputFileName(TString fname) {fSourcePositionFilePath=fname;}
+
+    ClassDef(MSrcPosFromFile, 0) // task to calculate the position of the source as a function of the run number 
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MSrcPosFromStars.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MSrcPosFromStars.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MSrcPosFromStars.cc	(revision 9661)
@@ -0,0 +1,335 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Roger Firpo   04/2004 <mailto:jlopez@ifae.es>
+!   Author(s): Javier López  05/2004 <mailto:jlopez@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// MSrcPosFromStars
+//
+// Task to set the position of the source using the positions of the stars
+// in the field of view of the source
+//
+//  Output Containers:
+//    MSrcPosCam
+//
+//////////////////////////////////////////////////////////////////////////////
+
+
+#include "MSrcPosFromStars.h"
+
+#include <TList.h>
+#include <TH2F.h>
+#include <TF2.h>
+#include <TTimer.h>
+#include <TString.h>
+#include <TCanvas.h>
+
+#include "MSrcPosCam.h"
+#include "MStarLocalCam.h"
+#include "MStarLocalPos.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+
+ClassImp(MSrcPosFromStars);
+
+using namespace std;
+
+static const TString gsDefName  = "MSrcPosFromStars";
+static const TString gsDefTitle = "task to calculate the position of the source using the position of stars";
+
+// -------------------------------------------------------------------------
+//
+// Default constructor. 
+//
+MSrcPosFromStars::MSrcPosFromStars(const char *name, const char *title)
+    : fStars(NULL)
+{
+  fName  = name  ? name  : gsDefName.Data();
+  fTitle = title ? title : gsDefTitle.Data();
+  
+  fDistances.Set(0);
+
+}
+
+// -------------------------------------------------------------------------
+//
+Int_t MSrcPosFromStars::PreProcess(MParList *pList)
+{
+
+  if(!MSrcPlace::PreProcess(pList))
+    return kFALSE;
+  
+  fStars = (MStarLocalCam*)pList->FindObject(AddSerialNumber("MStarLocalCam"));
+  if (!fStars)
+    {
+      *fLog << err << AddSerialNumber("MStarLocalCam") << " not found ... aborting" << endl;
+      return kFALSE;
+    }
+  
+  fNumStars = fDistances.GetSize();
+  
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// 
+static Bool_t HandleInput()
+{
+    TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
+    while (1)
+    {
+        //
+        // While reading the input process gui events asynchronously
+        //
+        timer.TurnOn();
+        cout << "Type 'q' to exit, <return> to go on: " << endl;
+        TString input;
+        input = getchar();
+        timer.TurnOff();
+
+        if (input=="q\n")
+            return kFALSE;
+
+        if (input=="\n")
+            return kTRUE;
+    };
+
+    return kFALSE;
+}
+
+Int_t MSrcPosFromStars::ComputeNewSrcPosition()
+{
+
+  if (fNumStars == 0)
+    {
+      if (fStars->GetNumStars() > 0)
+        {
+
+          //Look for the star closer to the center of the camera
+          TIter Next(fStars->GetList());
+          MStarLocalPos* star;
+          Float_t mindist = 600; //mm
+          UInt_t starnum = 0;
+          Int_t select = -1;
+          while ((star=(MStarLocalPos*)Next())) 
+            {
+              Float_t dist = TMath::Sqrt(star->GetMeanX()*star->GetMeanX() +
+                                         star->GetMeanY()*star->GetMeanY());
+              if (dist < mindist)
+                {
+                  mindist = dist;
+                  select = starnum;
+                }
+              
+              starnum++;
+            }
+
+          if (select < 0)
+            {
+              *fLog << err << "Not found star closer to center" << endl;
+              return kFALSE;
+            }
+          
+          MStarLocalPos& selecStar = (*fStars)[select];
+
+          if (selecStar.GetChiSquareNdof() > 0. && selecStar.GetChiSquareNdof() < 10.)
+            {
+              
+              Float_t selecStarPosX = selecStar.GetMeanX();
+              Float_t selecStarPosY = selecStar.GetMeanY();
+        
+              GetOutputSrcPosCam()->SetXY(selecStarPosX,selecStarPosY);
+            }
+        }
+    }
+  else if (fStars->GetNumStars() >= fNumStars)
+    {
+      
+      Float_t diameterInnerPixel = 30; //[mm]
+      Float_t diameterOuterPixel = 60; //[mm]
+      
+      Double_t probability = 1.;
+
+      // Resolution and computing time are proportional to bins^2
+      const Int_t bins  = 200;
+      Double_t max_x_mm = 600;
+      Double_t min_x_mm = -max_x_mm;
+      Double_t max_y_mm = max_x_mm;
+      Double_t min_y_mm = -max_x_mm;
+      
+      // bins to mmrees
+      const Double_t bin2mm = 2 * max_x_mm / bins;
+      
+      // First run, to find the maximum peak and define the area
+      TH2F *hgrid = new TH2F("hgrid", "", bins, min_x_mm, max_x_mm, bins, min_y_mm, max_y_mm);
+      
+      for (Int_t ny = 1; ny <= bins; ny++)
+        for (Int_t nx = 1; nx <= bins; nx++)
+          hgrid->SetBinContent(nx, ny, 1.);
+
+      for (UInt_t numstar = 0; numstar < fNumStars; numstar++)
+        {
+          probability = 1;
+          
+          MStarLocalPos& star  = (*fStars)[numstar];
+          
+          if (star.GetChiSquareNdof() > 0. && star.GetChiSquareNdof() < 10.)
+            {
+              
+              Float_t starPosX  = star.GetMeanX();
+              Float_t starPosY  = star.GetMeanY();
+              Float_t starDist  = Dist(0.,0.,starPosX,starPosY);
+              Float_t starSigma = (starDist<350.?diameterInnerPixel:diameterOuterPixel);
+              
+//               *fLog << dbg << "Star[" << numstar << "] pos (" << starPosX << "," << starPosY << ") dist " << starDist << " size " << starSigma << endl;
+              
+              if (starSigma != 0)
+                {
+                  for (Int_t ny = 1; ny < bins + 1; ny++)
+                    {
+                      for (Int_t nx = 0; nx < bins + 1; nx++)
+                        {
+                          Float_t dist = Dist(min_x_mm + nx * bin2mm, starPosX, min_y_mm + ny * bin2mm, starPosY);
+                          Float_t prob = Prob(dist, fDistances[numstar], starSigma);
+                          
+//                           if ( prob > 0.8)
+//                             *fLog << dbg << " x " << min_x_mm + nx * bin2mm << " y " << min_y_mm + ny * bin2mm << " dist " << dist << " stardist " << fDistances[numstar] << " prob " << prob << endl;
+
+                          probability = hgrid->GetBinContent(nx, ny)*prob;
+                          hgrid->SetBinContent(nx, ny, probability);
+
+                        }
+                    }
+                }
+              else probability *= 1;
+              
+            }
+        }
+      
+      // Finding the peak
+      Double_t peak[2] = {0,0};
+      Double_t peak_value = 0;
+      
+      for (Int_t ny = 0; ny < bins + 1; ny++)
+        {
+          for (Int_t nx = 0; nx < bins + 1; nx++)
+            {
+              if (hgrid->GetBinContent(nx, ny) > peak_value)
+                {
+                  peak_value = hgrid->GetBinContent(nx, ny);
+                  peak[0] = min_x_mm + nx * bin2mm;
+                  peak[1] = min_y_mm + ny * bin2mm;
+                }
+            }
+        }
+      
+      *fLog << dbg << "The peak is at (x, y) = (" << peak[0] << ", " << peak[1] << ") mm" << endl;
+      
+      
+//       TCanvas c1;
+//       hgrid->Draw("lego");
+//       if(!HandleInput())
+//         exit(1);
+      
+      
+      // Here we define a small area surrounding the peak to avoid wasting time and resolution anywhere else
+      
+      min_x_mm = peak[0] - diameterInnerPixel;
+      max_x_mm = peak[0] + diameterInnerPixel;
+      min_y_mm = peak[1] - diameterInnerPixel;
+      max_y_mm = peak[1] + diameterInnerPixel;
+      
+      const Double_t xbin2mm = (max_x_mm - min_x_mm) / bins;
+      const Double_t ybin2mm = (max_y_mm - min_y_mm) / bins;
+      
+      // Other run centered in the peak for more precision
+      TH2F *hagrid = new TH2F("hagrid", "", bins, min_x_mm, max_x_mm, bins, min_y_mm, max_y_mm);
+
+      for (Int_t ny = 1; ny <= bins; ny++)
+        for (Int_t nx = 1; nx <= bins; nx++)
+          hagrid->SetBinContent(nx, ny, 1.);
+          
+      
+      for (UInt_t numstar = 0; numstar < fNumStars; numstar++)
+        {
+          probability = 1;
+          
+          MStarLocalPos& star  = (*fStars)[numstar];
+          
+          if (star.GetChiSquareNdof() > 0. && star.GetChiSquareNdof() < 10.)
+            {
+              
+              Float_t starPosX  = star.GetMeanX();
+              Float_t starPosY  = star.GetMeanY();
+              Float_t starDist  = Dist(0.,0.,starPosX,starPosY);
+              Float_t starSigma = (starDist<350.?diameterInnerPixel:diameterOuterPixel);
+              
+              if (starSigma != 0)
+                {
+                  for (Int_t ny = 0; ny < bins; ny++)
+                    {
+                      for (Int_t nx = 0; nx < bins; nx++)
+                        {
+                          Float_t prob = Prob(Dist(min_x_mm + nx * xbin2mm, starPosX, min_y_mm + ny * ybin2mm, starPosY), fDistances[numstar], starSigma);
+                          
+                          probability = hagrid->GetBinContent(nx, ny)*prob;
+                          hagrid->SetBinContent(nx, ny, probability);
+                        }
+                    }
+                }
+              else probability *= 1;                          
+              
+            }
+        }
+      
+      // This time we fit the histogram with a 2D gaussian
+      // Although we don't expect our function to be gaussian...
+      TF2 *gauss2d = new TF2("gauss2d","[0]*exp(-(x-[1])*(x-[1])/(2*[2]*[2]))*exp(-(y-[3])*(y-[3])/(2*[4]*[4]))", min_x_mm, max_x_mm, min_y_mm, max_y_mm);
+      
+      gauss2d->SetParName(0,"f0");
+      gauss2d->SetParName(1,"meanx");
+      gauss2d->SetParName(2,"sigmax");
+      gauss2d->SetParName(3,"meany");
+      gauss2d->SetParName(4,"sigmay");
+      
+      gauss2d->SetParameter(0,10);
+      gauss2d->SetParameter(1,peak[0]);
+      gauss2d->SetParameter(2,0.002);
+      gauss2d->SetParameter(3,peak[1]);
+      gauss2d->SetParameter(4,0.002);
+      
+      GetOutputSrcPosCam()->SetXY(gauss2d->GetParameter(1), gauss2d->GetParameter(3));
+      
+      delete hgrid;
+      delete hagrid;
+    }
+  
+
+  return kTRUE;
+}
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MSrcPosFromStars.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MSrcPosFromStars.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MSrcPosFromStars.h	(revision 9661)
@@ -0,0 +1,52 @@
+#ifndef MARS_MSrcPosFromStars
+#define MARS_MSrcPosFromStars
+
+#ifndef ROOT_TArrayF
+#include "TArrayF.h"
+#endif
+
+#ifndef ROOT_TMath
+#include "TMath.h"
+#endif
+
+#ifndef MARS_MSrcPlace
+#include "MSrcPlace.h"
+#endif
+
+class MStarLocalCam;
+class MSrcPosCam;
+
+class MSrcPosFromStars : public MSrcPlace
+{
+ private:
+
+  MStarLocalCam *fStars;
+
+  UInt_t fNumStars;
+  TArrayF fDistances;
+
+  virtual Int_t ComputeNewSrcPosition();
+  virtual Int_t PreProcess(MParList *plist);
+    
+public:    
+
+  MSrcPosFromStars(const char *name=NULL, const char *title=NULL);
+
+
+// This fuction is to compute the probability using a ring distribution
+  Double_t Prob(Double_t d, Double_t dist, Double_t sigma)
+    {
+      return TMath::Exp(-(d-dist)*(d-dist)/(2*sigma*sigma));///(sigma*TMath::Sqrt(2*3.141592654));
+    }
+ 
+  Double_t Dist(Double_t x1, Double_t x2, Double_t y1, Double_t y2)
+    {
+      return TMath::Sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
+    }
+  
+  void SetDistances(TArrayF dist) { fDistances = dist; }
+  
+  ClassDef(MSrcPosFromStars, 0) // task to calculate the position of the source using the position of stars
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MSrcRotate.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MSrcRotate.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MSrcRotate.cc	(revision 9661)
@@ -0,0 +1,196 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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 Rico     04/2004 <mailto:jrico@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// MSrcRotate
+//
+// Task to rotate the position of the source as a function of time
+//
+//  Input Containers:
+//    MSrcPosCam
+//
+//  Output Containers:
+//    MSrcPosCam
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <fstream>
+#include <math.h>
+
+#include "MParList.h"
+#include "MRawRunHeader.h"
+#include "MRawEvtHeader.h"
+#include "MSrcRotate.h"
+
+#include "MAstroSky2Local.h"
+#include "MObservatory.h"
+#include "MSrcPosCam.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MSrcRotate);
+
+using namespace std;
+
+static const TString gsDefName  = "MSrcRotate";
+static const TString gsDefTitle = "Rotate position of the source";
+
+// -------------------------------------------------------------------------
+//
+// Default constructor. The first (second) argument is the name of the
+// input (output) MSrcPosCam object containing the source position in the 
+// camera plain
+//
+MSrcRotate::MSrcRotate(const char* srcPosIn, const char* srcPosOut, const char *name, const char *title)
+  : fRA(0), fDEC(0), fRefMJD(0), fRunNumber(0)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+
+    SetInputSrcPosName(srcPosIn);
+    SetOutputSrcPosName(srcPosOut);
+
+    SetInternalHistoName(TString(fName)+"Hist");
+}
+
+// -------------------------------------------------------------------------
+//
+// Look for/create the needed containers
+// Check whether RA and DEC have been initialized
+//
+Int_t MSrcRotate::PreProcess(MParList *pList)
+{
+  if(!MSrcPlace::PreProcess(pList))
+    return kFALSE;
+  
+  // look for MRawRunHeader
+  fRunHeader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
+  if (!fRunHeader)
+    {
+      *fLog << err << "MSrcRotate::PreProcess Error: MRawRunHeader not found... aborting" << endl;
+      return kFALSE;
+    }
+  
+  // look for MRawEvtHeader
+  fEvtHeader = (MRawEvtHeader*)pList->FindObject("MRawEvtHeader");
+  if (!fEvtHeader)
+    {
+      *fLog << err << "MSrcRotate::PreProcess Error: MRawEvtHeader not found... aborting." << endl;
+      return kFALSE;
+    }
+  
+  // look for/create the MObservatory
+  fObservatory = (MObservatory*)pList->FindCreateObj("MObservatory");
+  if(!fObservatory)
+    {
+      *fLog << err << "MSrcRotate::PreProcess Error: MObservatory not found... aborting." << endl;
+      return kFALSE;
+    }
+
+  // check RA and DEC
+  if(fRA==0. || fDEC ==0)
+    *fLog << warn << "MSrcRotate::PreProcess Warning: RA=" << fRA << "or DEC=" << fDEC << " could be not initialized" << endl;    
+	
+  return kTRUE;
+}
+
+// -------------------------------------------------------------------------
+//
+// Perform the rotation of the source position 
+// 
+// FIXME: for the time being, this is computed by assuming constant event rate
+//
+Int_t MSrcRotate::ComputeNewSrcPosition()
+{  
+  if(fRunHeader->GetRunNumber()!=fRunNumber)
+    {
+      fRunNumber=fRunHeader->GetRunNumber();
+      
+      // save the number of events, initial and final times
+      fNEvts    = fRunHeader->GetNumEvents();
+      fIniTime  = fRunHeader->GetRunStart();
+      fFinTime  = fRunHeader->GetRunEnd();
+      fDeltaT   = (fFinTime.GetMjd()-fIniTime.GetMjd())/fNEvts;
+      
+      if((ULong_t)TMath::Nint(fIniTime.GetMjd())!=(ULong_t)TMath::Nint(fFinTime.GetMjd()))
+	{
+	  *fLog << err << "MSrcRotate::ComputeNewSrcPosition Error: Inial and final MJDs are different ("<<fIniTime.GetMjd()<<"!="<<fFinTime.GetMjd()<<")" << endl;
+	  return kFALSE;
+	}
+      
+#ifdef DEBUG
+      cout << endl << "********************"  << endl;
+      cout << "Run number: " << fRunHeader->GetRunNumber() << endl;
+      cout << "Number of events: " << fNEvts << endl;
+      cout << "Initial MJD date: " << fIniTime.GetMjd() << endl;
+      cout << "Final MJD   date: " << fFinTime.GetMjd() << endl;
+      cout << "Delta t: " << fDeltaT << endl;
+#endif
+    }
+  
+  
+  // Compute the event time
+  // FIXME: for the time being, this is computed by assuming constant event rate
+  MTime eventTime;
+  Double_t newMJD = fIniTime.GetMjd() + (fFinTime.GetMjd()-fIniTime.GetMjd())*fEvtHeader->GetDAQEvtNumber()/fNEvts;  
+  eventTime.SetMjd(newMJD);    
+  MTime refTime;
+  refTime.SetMjd(fRefMJD);
+  
+  // de-rotate the source position
+  const MAstroSky2Local Observation(eventTime, *fObservatory);
+  const MAstroSky2Local RefObservation(refTime, *fObservatory);
+  
+#ifdef DEBUG
+  printf("Run:%d, Event:%d, iniMJD=%15.5f, finMJD=%15.5f, fDeltaT=%15.5f, newMJD=%15.5f, fRefMJD=%15.5f, rotation=%15.5f, ref=%15.5f\n",
+	 fRunHeader->GetRunNumber(),fEvtHeader->GetDAQEvtNumber(),
+	 fIniTime.GetMjd(),fFinTime.GetMjd(),fDeltaT,
+	 newMJD,fRefMJD,Observation.RotationAngle(fRA,fDEC),
+	 RefObservation.RotationAngle(fRA,fDEC));
+  //  cout << "newMJD=" << newMJD << ", fRefMJD="<<fRefMJD<<", rotation="<<Observation.RotationAngle(fRA,fDEC)<<", ref="<<RefObservation.RotationAngle(fRA,fDEC)<< endl;
+#endif
+  
+  Double_t rotationAngle = fRefMJD ? 
+    Observation.RotationAngle(fRA,fDEC)-RefObservation.RotationAngle(fRA,fDEC) :
+    Observation.RotationAngle(fRA,fDEC) ;
+  MSrcPosCam* srcposIn  = GetInputSrcPosCam();
+  MSrcPosCam* srcposOut = GetOutputSrcPosCam();
+  
+  Float_t c = TMath::Cos(rotationAngle);
+  Float_t s = TMath::Sin(rotationAngle);
+  // perform a rotation of -rotationAngle to move the source back to the "initial" position
+  Float_t newX = c*srcposIn->GetX()-s*srcposIn->GetY();
+  Float_t newY = s*srcposIn->GetX()+c*srcposIn->GetY();
+  
+#ifdef DEBUG
+  Double_t rotationAngleComp = fObservatory->RotationAngle(0.1256,2.63);
+  cout << "Event " << fEvtHeader->GetDAQEvtNumber() << endl;
+  cout << "newMJD=" << newMJD <<", rotationAngle=" << rotationAngle <<", rotationAngleComp=" << rotationAngleComp << ", oldX="<<fIniSrcPosIn.GetX()<< ", oldY="<<fIniSrcPosIn.GetY()<< ", newX="<<newX<< ", newY="<<newY << endl;
+#endif
+  
+  srcposOut->SetXY(newX,newY);
+
+  return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MSrcRotate.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MSrcRotate.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MSrcRotate.h	(revision 9661)
@@ -0,0 +1,44 @@
+#ifndef MARS_MSrcRotate
+#define MARS_MSrcRotate
+
+#ifndef MARS_MSrcPlace
+#include "MSrcPlace.h"
+#endif
+
+#include "MTime.h"
+
+class MObservatory;
+class MRawEvtHeader;
+class MRawRunHeader;
+
+class MSrcRotate : public MSrcPlace
+{
+ private:
+  MRawEvtHeader* fEvtHeader;   //  Pointer to the event header
+  MRawRunHeader* fRunHeader;   //  Pointer to the run header
+  MObservatory*  fObservatory; //  Pointer to the MObservatory    
+  
+  Double_t   fRA;          //  [rad] Right ascenssion 
+  Double_t   fDEC;         //  [rad] Declination
+  Double_t   fRefMJD;      //  [MJ date] reference time for rotation
+  UInt_t     fNEvts;       //  Number of events in file
+  MTime      fIniTime;     //  Run initial time 
+  MTime      fFinTime;     //  Run final time 
+  Double_t   fDeltaT;      //  DeltaT between two events
+  UInt_t     fRunNumber;   //  Current run number
+  
+  virtual Int_t PreProcess(MParList *plist);
+  
+ public:
+  MSrcRotate(const char* srcIn="MSrcPosCam",const char* srcOut="MSrcPosCam",
+	     const char* name=NULL, const char* title=NULL);
+  
+  void SetRAandDECandRefMJD(Double_t ra, Double_t dec, Double_t ref=0) {fRA=ra;fDEC=dec;fRefMJD=ref;}
+  void SetRAandDEC(Double_t ra, Double_t dec){SetRAandDECandRefMJD(ra,dec);}
+  virtual Int_t ComputeNewSrcPosition();
+  
+  ClassDef(MSrcRotate, 0) // task to rotate the position of the source as a function of Azimuth and Zenith angles
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MSrcTranslate.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MSrcTranslate.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MSrcTranslate.cc	(revision 9661)
@@ -0,0 +1,118 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!   Author(s): Javier Rico     04/2004 <mailto:jrico@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// MSrcTranslate
+//
+// Task to translate the position of the source, starting from previous source
+// position (fTranslationIsRelative=kTRUE) or from camera center 
+// (fTranslationIsRelative=kFALSE). This task allows you to modify the position
+// of the source in an event-by-event basis
+//
+//  Input Containers:
+//    MSrcPosCam
+//
+//  Output Containers:
+//    MSrcPosCam
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <fstream>
+#include <math.h>
+
+#include "MParList.h"
+
+#include "MSrcTranslate.h"
+#include "MSrcPosCam.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MSrcTranslate);
+
+using namespace std;
+
+static const TString gsDefName  = "MSrcTranslate";
+static const TString gsDefTitle = "De-rotate position of the source";
+
+// -------------------------------------------------------------------------
+//
+// Default constructor. The first (second) argument is the name of the
+// input (output) MSrcPosCam object containing the source position in the 
+// camera plain
+//
+MSrcTranslate::MSrcTranslate(const char* srcPosIn, const char* srcPosOut, const char *name, const char *title)
+  : fShiftX(0.), fShiftY(0.), fTranslationIsRelative(kTRUE)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+
+    SetInputSrcPosName(srcPosIn);
+    SetOutputSrcPosName(srcPosOut);
+
+    SetInternalHistoName(TString(fName)+"Hist");
+}
+
+// -------------------------------------------------------------------------
+//
+// Look for/create the needed containers
+//
+Int_t MSrcTranslate::PreProcess(MParList *pList)
+{
+  // look for/create MSrcPosCam 
+  if(!MSrcPlace::PreProcess(pList))
+    return kFALSE;
+
+  if(fShiftX==0. && fShiftY==0.)
+    *fLog << warn << "MSrcTranslate::PreProcess Warning: Null translation" << endl;    
+
+  return kTRUE;
+}
+
+// -------------------------------------------------------------------------
+//
+// Perform the translation of the source position 
+// 
+Int_t MSrcTranslate::ComputeNewSrcPosition()
+{  
+  Double_t newX,newY;
+
+  MSrcPosCam* srcPosOut = GetOutputSrcPosCam();
+  
+  if(fTranslationIsRelative)
+    {
+      MSrcPosCam* srcPosIn  = GetInputSrcPosCam();
+      newX=srcPosIn->GetX()+fShiftX;
+      newY=srcPosIn->GetY()+fShiftY;
+    }
+  else
+    {
+      newX=fShiftX;
+      newY=fShiftY;
+    }
+
+  srcPosOut->SetXY(newX,newY);
+
+  return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MSrcTranslate.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MSrcTranslate.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/MSrcTranslate.h	(revision 9661)
@@ -0,0 +1,30 @@
+#ifndef MARS_MSrcTranslate
+#define MARS_MSrcTranslate
+
+#ifndef MARS_MSrcPlace
+#include "MSrcPlace.h"
+#endif
+
+class MSrcTranslate : public MSrcPlace
+{
+ private:
+  
+  Double_t fShiftX;
+  Double_t fShiftY;
+  Bool_t   fTranslationIsRelative;
+  
+  Int_t PreProcess(MParList *plist);
+
+ public:
+  MSrcTranslate(const char* srcIn="MSrcPosCam", const char* srcOut="MSrcPosCam", 
+		const char* name=NULL, const char* title=NULL);
+  
+  void SetTranslation(Double_t x=0.,Double_t y=0) {fShiftX=x,fShiftY=y;};
+  void SetRelativeTranslation(Bool_t inp=kTRUE) {fTranslationIsRelative=inp;};
+  virtual Int_t ComputeNewSrcPosition();
+
+  ClassDef(MSrcTranslate, 0) // task to set the position of the source within the camera in an event by event basis
+};
+
+#endif
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/Makefile
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/Makefile	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/library/Makefile	(revision 9661)
@@ -0,0 +1,82 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS IFAE library
+#
+##################################################################
+# @maintitle
+
+# @code
+
+#
+#  please change all system depend values in the 
+#  config.mk.${OSTYPE} file 
+#
+#
+include ../../../Makefile.conf.$(OSTYPE)
+include ../../../Makefile.conf.general
+
+#
+CINT     = IFAE
+#
+
+SOLIB    = ../../../libmars.so
+
+#------------------------------------------------------------------------------
+
+INCLUDES = -I. \
+	   -I../../../mbase \
+	   -I../../../mjobs \
+	   -I../../../mpedestal \
+	   -I../../../mbadpixels \
+	   -I../../../mfileio \
+           -I../../../mraw \
+           -I../../../manalysis \
+	   -I../../../mgui \
+	   -I../../../mgeom \
+	   -I../../../msignal \
+	   -I../../../mcalib \
+	   -I../../../mfilter \
+	   -I../../../mhbase \
+	   -I../../../mimage \
+	   -I../../../mpointing \
+	   -I../../../mcamera \
+	   -I../../../mastro \
+	   -I../../../mhist \
+	   -I../../
+
+
+SRCFILES = \
+	MDisplay.cc \
+	MHillasDisplay.cc \
+        MPSFFit.cc \
+        MPSFFitCalc.cc \
+	MSrcPlace.cc \
+        MSrcPosFromFile.cc \
+	MSrcRotate.cc \
+	MSrcTranslate.cc \
+        MIslands.cc \
+        MIslandCalc.cc \
+        MIslandClean.cc \
+        MFHVNotNominal.cc \
+        MCalibrateDC.cc \
+        MHPSFFromStars.cc \
+	MDisp.cc \
+	MDispCalc.cc \
+	MControlPlots.cc \
+        MSrcPosFromStars.cc \
+        MLiveTime.cc \
+        MLiveTimeCalc.cc
+        
+
+############################################################
+
+all: $(OBJS)
+
+include ../../../Makefile.rules
+
+clean:	rmcint rmobjs rmcore rmlib
+mrproper: clean rmbak
+
+# @endcode
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/alpha.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/alpha.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/alpha.C	(revision 9661)
@@ -0,0 +1,175 @@
+/* ======================================================================== *\!
+!   Author(s): Oscar Blanch & Javier Rico
+\* ======================================================================== */
+
+void alpha(
+    Float_t cutsize=2000,
+    Float_t upcutsize=9999999,
+    Float_t lengthlowcut=0.,
+    Float_t lengthcut=0.26,
+    Float_t widthlowcut=0.,
+    Float_t widthcut=0.12
+)
+{    
+    // constants
+    const Int_t nbins = 9;
+    TString psname("alphaMrk.gif");
+    // general settings
+    gROOT->Reset();
+    gStyle->SetCanvasColor(0);
+    gStyle->SetCanvasBorderMode(0);
+    gStyle->SetPadBorderMode(0);
+    gStyle->SetFrameBorderMode(0);
+    gStyle->SetOptTitle(0);
+    gStyle->SetTitleOffset(1.7,"y");
+    gStyle->SetPadLeftMargin(0.15);
+    gStyle->SetOptStat(111110);
+    gStyle->SetStatColor(0);
+    gStyle->SetStatBorderSize(1);
+    gStyle->SetStatW(0.2);
+    gStyle->SetStatH(0.1);
+    gStyle->SetStatX(0.9);
+    gStyle->SetStatY(0.9);
+    
+    // define files, chain, trees, canvas...
+    TChain* ton= new TChain("Parameters");
+    
+    // ON data
+    ton->Add("/mnt/users/jrico/magic/mars/mars/mtemp/mifae/hillas/crab20040215OnRotateCalA-D.root");
+
+    TChain* toff= new TChain("Parameters");
+
+    // OFF data
+    toff->Add("/mnt/users/jrico/magic/mars/mars/mtemp/mifae/hillas/crab20040215OffRotateCalA-H.root");
+    
+    TCanvas *c1 = new TCanvas("c1","c1",800,500);
+    c1->cd(1);
+
+    // define aliases
+    ton->SetAlias("length","MHillas.fLength*0.6/189");
+    ton->SetAlias("width","MHillas.fWidth*0.6/189");
+    ton->SetAlias("dist","MHillasSrc.fDist*0.6/189");
+    ton->SetAlias("conc","MNewImagePar.fConc");
+    ton->SetAlias("size","MHillas.fSize");
+    ton->SetAlias("event","MRawEvtHeader.fDAQEvtNumber");
+    ton->SetAlias("alpha","abs(MHillasSrc.fAlpha)");
+    ton->SetAlias("leakage","MNewImagePar.fInnerLeakage1");
+    
+    toff->SetAlias("length","MHillas.fLength*0.6/189");
+    toff->SetAlias("width","MHillas.fWidth*0.6/189");
+    toff->SetAlias("dist","MHillasSrc.fDist*0.6/189");
+    toff->SetAlias("conc","MNewImagePar.fConc");
+    toff->SetAlias("size","MHillas.fSize");
+    toff->SetAlias("event","MRawEvtHeader.fDAQEvtNumber");
+    toff->SetAlias("alpha","abs(MHillasSrc.fAlpha)");
+    toff->SetAlias("leakage","MNewImagePar.fInnerLeakage1");
+
+    // define  cut(s)
+//    const char* eventcut="event%4==0 &&";
+    const char* eventcut="";
+    const char varcut[512];
+    //    sprintf(varcut,"size>%f && size<%f && length>%f  &&length<%f && width>%f &&  width<%f",cutsize,upcutsize,lengthlowcut,lengthcut,widthlowcut,widthcut);
+    sprintf(varcut,"size>%f && size<%f  && dist>0.2 && dist<1.1 && leakage==0 && length>%f  &&length<%f && width>%f &&  width<%f",cutsize,upcutsize,lengthlowcut,lengthcut,widthlowcut,widthcut);
+//    sprintf(varcut,"size>%f && dist>0.2 && dist<0.8 && length<0.21 && width<0.125",cutsize,upcutsize,lengthcut,widthcut);
+//    sprintf(varcut,"size>%f && size<%f  && dist>0.2 && dist<0.8 && length<0.21 && width<0.125",cutsize,upcutsize);
+//    sprintf(varcut,"size>%f && size<%f  && dist>0.2 && dist<0.8 && length<0.21",cutsize,upcutsize);
+//    sprintf(varcut,"size>%f && size<%f  && dist>0.2 && dist<0.8",cutsize,upcutsize);
+//    sprintf(varcut,"size>%f && size<%f",cutsize,upcutsize)
+//    sprintf(varcut,"");
+    Char_t cut[256];
+    Char_t cutoff[256];
+    strcat(cut,eventcut);
+    strcat(cut,varcut);
+    strcat(cutoff,varcut);
+
+    // fill on/off histos
+    TH1F* onhisto       = new TH1F("OnHist" ,"Alpha Plot",nbins,0,90);
+    TH1F* offhisto      = new TH1F("OffHist","Alpha Plot",nbins,0,90);    
+    ton->Draw("alpha>>OnHist",cut);
+    toff->Draw("alpha>>OffHist",cutoff);
+    cout << "Applied cut: " << cut << endl;
+    
+    // line/normalization
+    const Int_t inibin = 20./90.*nbins+1;
+    Float_t level=0;
+    Float_t leveloff=0;
+    Float_t levelofferror=0;
+    for(Int_t ibin = inibin; ibin<=nbins;ibin++)
+    {
+	level+=onhisto->GetBinContent(ibin);
+	leveloff+=offhisto->GetBinContent(ibin);
+    }
+    level/=(nbins-inibin+1);
+    leveloff/=(nbins-inibin+1);
+    
+    // normalize on/off
+    offhisto->Sumw2(); // needed to compute correct errors after normalization
+    const Float_t norm = level/leveloff;
+    cout << "Normalizing by factor " << norm <<endl;
+    offhisto->Scale(norm);    
+
+    // significance:
+    Float_t sig=0,bg=0,esig=0,ebg=0;
+    Float_t significance=0;
+    const Int_t signbins = inibin-1;
+    for(Int_t ibin = 1; ibin<=signbins;ibin++)
+    {
+//	Float_t sigma = (onhisto->GetBinContent(ibin)-level)/onhisto->GetBinError(ibin);
+//	significance+=sigma*sigma;
+	sig  += onhisto->GetBinContent(ibin);
+	esig += onhisto->GetBinError(ibin)*onhisto->GetBinError(ibin);
+	bg   += offhisto->GetBinContent(ibin);
+	ebg  += offhisto->GetBinError(ibin)*offhisto->GetBinError(ibin);
+    }
+    Float_t error= TMath::Sqrt(esig+ebg);
+    significance = (sig-bg)/error;
+    
+    cout << "Excess: " << sig-bg << endl;
+    cout << "N bkg: "  << bg << endl; 
+    cout << "Significance: " << significance << endl;
+
+    // plot
+    onhisto->SetXTitle("alpha (deg)");
+    onhisto->SetYTitle("Entries");
+    onhisto->SetMarkerColor(4);
+    onhisto->SetMarkerStyle(20);
+    onhisto->SetMarkerSize(.7);
+    onhisto->SetLineColor(4);
+    onhisto->SetMaximum(onhisto->GetBinContent(nbins)*1.5);
+
+    offhisto->SetFillColor(2);
+    offhisto->SetMaximum(offhisto->GetBinContent(nbins)*1.5);
+    offhisto->SetXTitle("alpha (deg)");
+    offhisto->SetYTitle("Entries");
+
+    offhisto->Draw("HIST");
+    offhisto->Draw("ESAME");
+    onhisto->Draw("ESAMES");
+    //    onhisto->Draw("E");
+
+    // move stat box to make them all visible
+    gPad->Update();
+    TPaveStats* offpavstat = (TPaveStats*) offhisto->GetListOfFunctions()->FindObject("stats");
+    if(offpavstat)
+    {
+	Float_t shiftx = offpavstat->GetX2NDC()-offpavstat->GetX1NDC();
+	offpavstat->SetX1NDC(offpavstat->GetX1NDC()-shiftx);
+	offpavstat->SetX2NDC(offpavstat->GetX2NDC()-shiftx);
+    }
+
+    // draw line
+    TLine* line = new TLine(0.,level,90.,level);
+    line->SetLineColor(2);
+    line->SetLineStyle(2);
+//    line->Draw();
+
+    gPad->Modified();
+    gPad->Update();
+
+    // produce ps
+    //  char psname[50];
+    //  sprintf(psname,"%s.ps",var);
+    c1->Print(psname);
+}
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/alpha_plot.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/alpha_plot.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/alpha_plot.C	(revision 9661)
@@ -0,0 +1,835 @@
+Double_t ChiSquareNDof(TH1D *h1, TH1D *h2)
+{
+    Double_t chiq = 0.;
+    Double_t chi;
+    Double_t error;
+    Int_t nbinsnozero = 0;
+
+    Int_t nbins = h1->GetNbinsX();
+    if (nbins != h2->GetNbinsX() || nbins == 0)
+	return -1;
+
+    for (UInt_t bin=1; bin<=nbins; bin++)
+    {
+	error = sqrt(h1->GetBinError(bin)*h1->GetBinError(bin) +
+			   h2->GetBinError(bin)*h2->GetBinError(bin));
+	if (error != 0)
+	{
+	    chi = (h1->GetBinContent(bin)-h2->GetBinContent(bin))/error;
+	    chiq += chi*chi;
+	    nbinsnozero++;
+	}
+    }
+
+    return chiq/nbinsnozero;
+}
+
+void alpha_plot(TString f_on_name  = "../HillasFiles/Mrk421/*_H.root",
+		TString f_off_name = "../HillasFiles/OffMrk421/*_H.root",
+		TString f_src_name = "../HillasFiles/20040319_OffMrk421.fake.pos")	     
+{
+
+    const UInt_t numEntries = 100000000;
+    
+    //cuts
+    Float_t sizemin   = 2000.; //[ADC]
+    Float_t sizemax   = 10000000000.; //[ADC]
+    Float_t widthmin  = 0.06; 
+    Float_t widthmax  = 0.12;
+    Float_t lengthmin = 0.10; 
+    Float_t lengthmax = 0.26;
+    Float_t distmin   = 0.3; 
+    Float_t distmax   = 1.2;
+    Float_t alphamin   = 0.; 
+    Float_t alphamax   = 90.;
+
+    //integration
+    Float_t sigexccmin = 0.;
+    Float_t sigexccmax = 30.;
+    Float_t bkgnormmin = 30.;
+    Float_t bkgnormmax = 90.;
+    
+    gStyle->SetOptStat(111111);
+    gStyle->SetOptFit();
+    
+    //
+    // Make a loop only for the ON data:
+    //
+    
+    MParList plist_on;
+    MTaskList tlist_on;
+    plist_on.AddToList(&tlist_on);
+  
+    // ON containers
+    MGeomCamMagic geomcam;
+    MSrcPosCam source_on;
+    MHillas hillas;
+    MHillasSrc hillasscr;
+    
+    plist_on.AddToList(&geomcam);
+    plist_on.AddToList(&source_on);
+    plist_on.AddToList(&hillas);
+    plist_on.AddToList(&hillasscr);
+    
+    //create some 1-dim histo to test only for the ON distribution of dist, width , length, size...
+    MH3 hDist_on("MHillasSrc.fDist/315.");
+    hDist_on.SetName("Dist_on");
+    plist_on.AddToList(&hDist_on);
+    MBinning binsDist_on("BinningDist_on");
+    Int_t nbins_Dist = 20;
+    Float_t min_Dist = 0.;
+    Float_t max_Dist = distmax*1.2;
+    binsDist_on.SetEdges(nbins_Dist, min_Dist, max_Dist);
+    plist_on.AddToList(&binsDist_on);
+    
+    MH3 hWidth_on("MHillas.fWidth/315.");
+    hWidth_on.SetName("Width_on");
+    plist_on.AddToList(&hWidth_on);
+    MBinning binsWidth_on("BinningWidth_on");
+    Int_t nbins_Width = 20;
+    Float_t min_Width = 0.;
+    Float_t max_Width = widthmax*1.2;
+    binsWidth_on.SetEdges(nbins_Width, min_Width, max_Width);
+    plist_on.AddToList(&binsWidth_on);
+    
+    MH3 hLength_on("MHillas.fLength/315.");
+    hLength_on.SetName("Length_on");
+    plist_on.AddToList(&hLength_on);
+    MBinning binsLength_on("BinningLength_on");
+    Int_t nbins_Length = 20;
+    Float_t min_Length = 0.;
+    Float_t max_Length =  lengthmax*1.2;
+    binsLength_on.SetEdges(nbins_Length, min_Length, max_Length);
+    plist_on.AddToList(&binsLength_on);
+    
+    MH3 hSize_on("log10(MHillas.fSize)");
+    hSize_on.SetName("Size_on");
+    plist_on.AddToList(&hSize_on);
+    MBinning binsSize_on("BinningSize_on");
+    Int_t nbins_Size = 60;
+    Float_t min_Size = log10(sizemin)*0.8;
+    Float_t max_Size = log10(1000000)*1.2;
+    binsSize_on.SetEdges(nbins_Size, min_Size, max_Size);
+    plist_on.AddToList(&binsSize_on);
+    
+    //create a histo to fill the alpha values: one alpha plot form 0 to +90 deg in abs value
+    MH3 hAlpha_on_abs("abs(MHillasSrc.fAlpha)");
+    hAlpha_on_abs.SetName("Alpha_on_abs");
+    plist_on.AddToList(&hAlpha_on_abs);
+    MBinning binsAlpha_on_abs("BinningAlpha_on_abs");
+    Int_t nbins_abs = 9;
+    Float_t minalpha_abs = 0.;
+    Float_t maxalpha_abs =90.;
+    binsAlpha_on_abs.SetEdges(nbins_abs, minalpha_abs, maxalpha_abs);
+    plist_on.AddToList(&binsAlpha_on_abs);
+    
+    //create a histo to fill the alpha values: one alpha plot form -90 to +90 deg.
+    MH3 hAlpha_on("MHillasSrc.fAlpha");
+    hAlpha_on.SetName("Alpha_on");
+    plist_on.AddToList(&hAlpha_on);
+    MBinning binsAlpha_on("BinningAlpha_on");
+    Int_t nbins = nbins_abs*2;
+    Float_t minalpha = -90.;
+    Float_t maxalpha =  90.;
+    binsAlpha_on.SetEdges(nbins, minalpha, maxalpha);
+    plist_on.AddToList(&binsAlpha_on);
+    
+
+    MH3 hSrcPos_on("MSrcPosCam.fX","MSrcPosCam.fY");
+    hSrcPos_on.SetName("SrcPos_on");
+    plist_on.AddToList(&hSrcPos_on);
+    MBinning binsSrcPos_onX("BinningSrcPos_onX");
+    MBinning binsSrcPos_onY("BinningSrcPos_onY");
+    Int_t nbins_srcpos = 400;
+    Float_t minsrcpos = -600.;
+    Float_t maxsrcpos =  600.;
+    binsSrcPos_onX.SetEdges(nbins_srcpos, minsrcpos, maxsrcpos);
+    binsSrcPos_onY.SetEdges(nbins_srcpos, minsrcpos, maxsrcpos);
+    plist_on.AddToList(&binsSrcPos_onX);
+    plist_on.AddToList(&binsSrcPos_onY);
+
+    MH3 hDAQEvtNumber_on("MRawEvtHeader.fDAQEvtNumber");
+    hDAQEvtNumber_on.SetName("DAQEvtNumber_on");
+    plist_on.AddToList(&hDAQEvtNumber_on);
+    MBinning binsDAQEvtNumber_onX("BinningDAQEvtNumber_onX");
+    Int_t nbins_evtnum = 1000;
+    Float_t minevtnum =  0.;
+    Float_t maxevtnum =  1000.;
+    binsDAQEvtNumber_onX.SetEdges(nbins_evtnum,minevtnum,maxevtnum);
+    plist_on.AddToList(&binsDAQEvtNumber_onX);
+
+    //
+    //tasks
+    //
+    
+    MReadTree read_on("Parameters", f_on_name);
+    read_on.DisableAutoScheme();
+ 
+
+    //cuts
+    TString sizestr = "(MHillas.fSize < ";
+    sizestr += sizemin;
+    sizestr += ") || (";
+    sizestr += "MHillas.fSize > ";
+    sizestr += sizemax;
+    sizestr += ")";
+    MF sizefilter(sizestr);
+    
+    TString widthstr = "({MHillas.fWidth/315.} < ";
+    widthstr += widthmin;
+    widthstr += ") || (";
+    widthstr += "{MHillas.fWidth/315.} > ";
+    widthstr += widthmax;
+    widthstr += ")";
+    MF widthfilter(widthstr);
+    
+    TString lengthstr = "({MHillas.fLength/315.} < ";
+    lengthstr += lengthmin;
+    lengthstr += ") || (";
+    lengthstr += "{MHillas.fLength/315.} > ";
+    lengthstr += lengthmax;
+    lengthstr += ")";
+    MF lengthfilter(lengthstr);
+    
+    TString diststr = "({MHillasSrc.fDist/315.} < ";
+    diststr += distmin;
+    diststr += ") || (";
+    diststr += "{MHillasSrc.fDist/315.} > ";
+    diststr += distmax;
+    diststr += ")";
+    MF distfilter(diststr);
+    
+    TString alphastr = "({abs(MHillasSrc.fAlpha)} < ";
+    alphastr += alphamin;
+    alphastr += ") || (";
+    alphastr += "{abs(MHillasSrc.fAlpha)} > ";
+    alphastr += alphamax;
+    alphastr += ")";
+    MF alphafilter(alphastr);
+    
+    MF evenfilter("{MRawEvtHeader.fDAQEvtNumber%3}<0.5");
+    MF oddfilter("{MRawEvtHeader.fDAQEvtNumber%3}>0.5");
+
+    MContinue cont_size(&sizefilter);
+    MContinue cont_width(&widthfilter);
+    MContinue cont_length(&lengthfilter);
+    MContinue cont_dist(&distfilter);
+    MContinue cont_alpha(&alphafilter);
+    MContinue cont_even(&evenfilter);
+    MContinue cont_odd(&oddfilter);
+    
+    //    MSrcPosFromFile srccalc(f_src_name);
+    MSrcPlace srccalc;
+    
+    MHillasSrcCalc csrc_on;
+
+    // fill all histograms
+    MFillH falpha_on_abs(&hAlpha_on_abs);
+    MFillH falpha_on(&hAlpha_on);
+    MFillH fdist_on(&hDist_on);
+    MFillH fwidth_on(&hWidth_on);
+    MFillH flength_on(&hLength_on);
+    MFillH fsize_on(&hSize_on);
+    MFillH fsrcpos_on(&hSrcPos_on);
+    MFillH fevtnum_on(&hDAQEvtNumber_on);
+    
+
+    // prints
+    MPrint pevent("MRawEvtHeader");
+    MPrint phillas("MHillas");
+    MPrint phillassrc("MHillasSrc");
+    MPrint psrcpos("MSrcPosCam");
+
+    //tasklist
+    tlist_on.AddToList(&read_on);
+    tlist_on.AddToList(&srccalc);
+    tlist_on.AddToList(&csrc_on);
+    tlist_on.AddToList(&fsrcpos_on);
+//    tlist_on.AddToList(&cont_odd);
+    tlist_on.AddToList(&cont_size);
+    tlist_on.AddToList(&cont_width);
+    tlist_on.AddToList(&cont_length);
+    tlist_on.AddToList(&cont_dist);
+    tlist_on.AddToList(&cont_alpha);
+    tlist_on.AddToList(&falpha_on_abs);
+    tlist_on.AddToList(&falpha_on);
+    tlist_on.AddToList(&fdist_on);
+    tlist_on.AddToList(&fwidth_on);
+    tlist_on.AddToList(&flength_on);
+    tlist_on.AddToList(&fsize_on);
+    tlist_on.AddToList(&fevtnum_on);
+    
+    // Create and setup the eventloop
+    MEvtLoop loop_on;
+    loop_on.SetParList(&plist_on);
+  //loop_on.SetDisplay(display);
+    
+    MProgressBar bar;
+    loop_on.SetProgressBar(&bar);
+    
+    if (!loop_on.Eventloop(numEntries))
+	return;
+
+    tlist_on.PrintStatistics();
+    
+    // 
+    // Make a loop only for the OFF data:
+    //
+    
+    MParList plist_off;
+    MTaskList tlist_off;
+    plist_off.AddToList(&tlist_off);
+    
+    MSrcPosCam source_off;
+
+    plist_off.AddToList(&geomcam);
+    plist_off.AddToList(&source_off);
+    plist_off.AddToList(&hillas);
+    plist_off.AddToList(&hillasscr);
+
+    //create some 1-dim histo to test only for the OFF distribution of dist, width , length, size...
+    MH3 hDist_off("MHillasSrc.fDist/315.");
+    hDist_off.SetName("Dist_off");
+    plist_off.AddToList(&hDist_off);
+    MBinning binsDist_off("BinningDist_off");
+    binsDist_off.SetEdges(nbins_Dist, min_Dist, max_Dist);
+    plist_off.AddToList(&binsDist_off);
+    
+    MH3 hWidth_off("MHillas.fWidth/315.");
+    hWidth_off.SetName("Width_off");
+    plist_off.AddToList(&hWidth_off);
+    MBinning binsWidth_off("BinningWidth_off");
+    binsWidth_off.SetEdges(nbins_Width, min_Width, max_Width);
+    plist_off.AddToList(&binsWidth_off);
+
+    MH3 hLength_off("MHillas.fLength/315.");
+    hLength_off.SetName("Length_off");
+    plist_off.AddToList(&hLength_off);
+    MBinning binsLength_off("BinningLength_off");
+    binsLength_off.SetEdges(nbins_Length, min_Length, max_Length);
+    plist_off.AddToList(&binsLength_off);
+    
+    MH3 hSize_off("log10(MHillas.fSize)");
+    hSize_off.SetName("Size_off");
+    plist_off.AddToList(&hSize_off);
+    MBinning binsSize_off("BinningSize_off");
+    binsSize_off.SetEdges(nbins_Size, min_Size, max_Size);
+    plist_off.AddToList(&binsSize_off);
+    
+    //create a histo to fill the alpha values: from 0 to 90 deg -> abs value
+    MH3 hAlpha_off_abs("abs(MHillasSrc.fAlpha)");
+    hAlpha_off_abs.SetName("Alpha_off_abs");
+    plist_off.AddToList(&hAlpha_off_abs);
+    MBinning binsAlpha_off_abs("BinningAlpha_off_abs");
+    binsAlpha_off_abs.SetEdges(nbins_abs, minalpha_abs, maxalpha_abs);
+    plist_off.AddToList(&binsAlpha_off_abs);
+    
+    //create a histo to fill the alpha values: from -90 to 90 deg
+    MH3 hAlpha_off("MHillasSrc.fAlpha");
+    hAlpha_off.SetName("Alpha_off");
+    plist_off.AddToList(&hAlpha_off);
+    MBinning binsAlpha_off("BinningAlpha_off");
+    binsAlpha_off.SetEdges(nbins, minalpha, maxalpha);
+    plist_off.AddToList(&binsAlpha_off);
+    
+    
+    MH3 hSrcPos_off("MSrcPosCam.fX","MSrcPosCam.fY");
+    hSrcPos_off.SetName("SrcPos_off");
+    plist_off.AddToList(&hSrcPos_off);
+    MBinning binsSrcPos_offX("BinningSrcPos_offX");
+    MBinning binsSrcPos_offY("BinningSrcPos_offY");
+    binsSrcPos_offX.SetEdges(nbins_srcpos, minsrcpos, maxsrcpos);
+    binsSrcPos_offY.SetEdges(nbins_srcpos, minsrcpos, maxsrcpos);
+    plist_off.AddToList(&binsSrcPos_offX);
+    plist_off.AddToList(&binsSrcPos_offY);
+
+    MH3 hDAQEvtNumber_off("MRawEvtHeader.fDAQEvtNumber");
+    hDAQEvtNumber_off.SetName("DAQEvtNumber_off");
+    plist_off.AddToList(&hDAQEvtNumber_off);
+    MBinning binsDAQEvtNumber_offX("BinningDAQEvtNumber_offX");
+    Int_t nbins_evtnum = 100;
+    Float_t minevtnum =  0.;
+    Float_t maxevtnum =  100.;
+    binsDAQEvtNumber_offX.SetEdges(nbins_evtnum,minevtnum,maxevtnum);
+    plist_off.AddToList(&binsDAQEvtNumber_offX);
+
+   //tasks
+    MReadTree read_off("Parameters", f_off_name);
+    read_off.DisableAutoScheme();
+    
+    srccalc.SetMode(MSrcPlace::kOff);
+
+    MHillasSrcCalc csrc_off;
+
+    // fill all histograms
+    MFillH falpha_off_abs(&hAlpha_off_abs);
+    MFillH falpha_off(&hAlpha_off);
+    MFillH fdist_off(&hDist_off);
+    MFillH fwidth_off(&hWidth_off);
+    MFillH flength_off(&hLength_off);
+    MFillH fsize_off(&hSize_off);
+    MFillH fsrcpos_off(&hSrcPos_off);
+    MFillH fevtnum_off(&hDAQEvtNumber_off);
+   
+    //tasklist
+    tlist_off.AddToList(&read_off);
+    tlist_off.AddToList(&srccalc);
+    tlist_off.AddToList(&csrc_off);
+    tlist_off.AddToList(&fsrcpos_off);
+//    tlist_off.AddToList(&cont_even);
+    tlist_off.AddToList(&cont_size);
+    tlist_off.AddToList(&cont_width);
+    tlist_off.AddToList(&cont_length);
+    tlist_off.AddToList(&cont_dist);
+    tlist_off.AddToList(&cont_alpha);
+    tlist_off.AddToList(&falpha_off_abs);
+    tlist_off.AddToList(&falpha_off);
+    tlist_off.AddToList(&fdist_off);
+    tlist_off.AddToList(&fwidth_off);
+    tlist_off.AddToList(&flength_off);
+    tlist_off.AddToList(&fsize_off);
+    tlist_off.AddToList(&fevtnum_off);
+     
+    // Create and setup the eventloop
+    MEvtLoop loop_off;
+    loop_off.SetParList(&plist_off);
+    //loop_off.SetDisplay(display);
+    
+    MProgressBar bar_off;
+    loop_off.SetProgressBar(&bar_off);
+    
+    if (!loop_off.Eventloop(numEntries))
+	return;
+    
+    tlist_off.PrintStatistics();
+    
+  // ############################################################################
+  //  look for the histograms
+  // ############################################################################
+
+  TH1F *hist_size_on = (TH1F*)hSize_on.GetHist();
+  TH1F *hist_size_off = (TH1F*)hSize_off.GetHist();
+
+  TH1F *hist_dist_on = (TH1F*)hDist_on.GetHist();
+  TH1F *hist_dist_off = (TH1F*)hDist_off.GetHist();
+
+  TH1F *hist_width_on = (TH1F*)hWidth_on.GetHist();
+  TH1F *hist_width_off = (TH1F*)hWidth_off.GetHist();
+
+  TH1F *hist_length_on = (TH1F*)hLength_on.GetHist();
+  TH1F *hist_length_off = (TH1F*)hLength_off.GetHist();
+
+  TH1F *hist_on_abs = (TH1F*)hAlpha_on_abs.GetHist();
+  TH1F *hist_off_abs = (TH1F*)hAlpha_off_abs.GetHist();
+
+  TH1F *hist_on = (TH1F*)hAlpha_on.GetHist();
+  TH1F *hist_off = (TH1F*)hAlpha_off.GetHist();
+
+
+  // ############################################################################
+  // Calculate significance and excess: 
+  // ############################################################################
+
+  Double_t norm_on_abs  = (Double_t) hist_on_abs->Integral((Int_t)bkgnormmin*nbins_abs/90+1,(Int_t)bkgnormmax*nbins_abs/90+1);
+  Double_t exces_on_abs = (Double_t) hist_on_abs->Integral((Int_t)sigexccmin*nbins_abs/90+1,(Int_t)sigexccmax*nbins_abs/90+1);
+  Double_t norm_off_abs  = (Double_t) hist_off_abs->Integral((Int_t)bkgnormmin*nbins_abs/90+1,(Int_t)bkgnormmax*nbins_abs/90+1);
+  Double_t exces_off_abs = (Double_t) hist_off_abs->Integral((Int_t)sigexccmin*nbins_abs/90+1,(Int_t)sigexccmax*nbins_abs/90+1);
+  Double_t norm = norm_on_abs/norm_off_abs;
+
+  char text_tit_alpha[256];
+  sprintf(text_tit_alpha, " Alpha Plot On and Off ");
+  hist_off_abs->SetTitle(text_tit_alpha);
+  hist_on_abs->SetTitle(text_tit_alpha);
+
+  Double_t excess  = exces_on_abs - exces_off_abs*norm;
+  Double_t sign    = excess / sqrt( exces_on_abs + norm*norm*exces_off_abs );
+  Double_t int_off = (Double_t) hist_off_abs->Integral(1, 18);
+  int hist_on_entries  = (int) hist_on_abs->GetEntries();
+  int hist_off_entries = (int) hist_off_abs->GetEntries();
+    
+  cout << "---> Normalization F factor =\t" << norm <<endl;
+  cout << "---> Excess =\t\t\t" << excess <<endl;
+  cout << "---> Significancia =\t\t" << sign <<endl;    
+  cout << "---> entries on   =\t\t" << hist_on_entries  <<endl;
+  cout << "---> entries off  =\t\t" << hist_off_entries <<endl;
+  cout << "---> integral off =\t\t" << int_off <<endl;
+
+  Float_t shiftx;
+
+  //
+  //Create the display -> from now on, all histos are plotted
+  MStatusDisplay *display = new MStatusDisplay;
+  display->SetUpdateTime(3000);
+  display->Resize(850,700);
+  
+  // ############################################################################
+  // Draw SIZE
+  // ############################################################################
+  display->AddTab("SIZE");
+
+  gPad->cd();
+
+  gPad->SetLogy();
+  hist_size_on->Sumw2();
+  hist_size_off->Sumw2();
+  hist_size_off->Scale(norm); 
+  hist_size_on->SetLineColor(kBlack);
+  hist_size_on->SetMarkerStyle(21);
+  hist_size_on->SetMarkerSize(0.7);
+  hist_size_on->SetMarkerColor(kBlack);
+  hist_size_off->SetFillColor(46);
+  hist_size_off->SetLineColor(46);
+  hist_size_off->SetFillStyle(3004); //(1001)-> To set the pad NOT transparent and solid; (3004)-> pattern lines
+  hist_size_off->SetMinimum(0.1);
+  hist_size_on->SetMinimum(0.1);
+  hist_size_on->SetTitle("SIZE distribution");
+  hist_size_off->SetTitle("SIZE distribution");
+
+  hist_size_on->DrawCopy("E1P");
+
+  // move stat box to make them all visible
+  gPad->Update();
+  TPaveStats* pavs_on_size = (TPaveStats*) hist_size_on->GetListOfFunctions()->FindObject("stats");
+  if(pavs_on_size){
+    shiftx = pavs_on_size->GetX2NDC() - pavs_on_size->GetX1NDC();
+    pavs_on_size->SetX1NDC(pavs_on_size->GetX1NDC() - shiftx);
+    pavs_on_size->SetX2NDC(pavs_on_size->GetX2NDC() - shiftx);  
+  }
+  gPad->Modified();
+  gPad->Update();
+
+  hist_size_off->DrawCopy("HISTSAME");
+  hist_size_off->DrawCopy("ESAME");
+
+  gPad->Modified();
+  gPad->Update();
+
+  Double_t chisize = ChiSquareNDof((TH1D*)hist_size_on,(TH1D*)hist_size_off);
+
+  Double_t x_label_pos  = log10(1000000)*0.7;
+  Double_t y_label_pos  = log10((hist_size_on->GetBinContent(hist_size_on->GetMaximumBin()))/2.);
+  Double_t textsize = 0.03;
+
+  char text_size[256];
+  sprintf(text_size,"ChiSquare/NDof = %4.2f",chisize);
+
+  TLatex *tsize = new TLatex(x_label_pos, y_label_pos, text_size);
+  tsize->SetTextSize(textsize);
+//  tsize->Draw();
+
+  gPad->Modified();
+  gPad->Update();
+
+  // ############################################################################
+  // DrawCopy DIST
+  // ############################################################################
+  display->AddTab("DIST");
+
+  gPad->cd();
+
+  hist_dist_on->Sumw2();
+  hist_dist_off->Sumw2();
+  hist_dist_off->Scale(norm); 
+  hist_dist_on->SetLineColor(kBlack);
+  hist_dist_on->SetMarkerStyle(21);
+  hist_dist_on->SetMarkerSize(0.7);
+  hist_dist_on->SetMarkerColor(kBlack);
+  hist_dist_off->SetFillColor(46);
+  hist_dist_off->SetLineColor(46);
+  hist_dist_off->SetFillStyle(3004); //(1001)-> To set the pad NOT transparent and solid; (3004)-> pattern lines
+  hist_dist_off->SetMinimum(0.);
+  hist_dist_on->SetTitle("DIST distribution");
+  hist_dist_off->SetTitle("DIST distribution");
+
+  hist_dist_on->DrawCopy("E1P");
+
+  // move stat box to make them all visible
+  gPad->Update();
+  TPaveStats* pavs_on_dist = (TPaveStats*) hist_dist_on->GetListOfFunctions()->FindObject("stats");
+  if(pavs_on_dist){
+    shiftx = pavs_on_dist->GetX2NDC() - pavs_on_dist->GetX1NDC();
+    pavs_on_dist->SetX1NDC(pavs_on_dist->GetX1NDC() - shiftx);
+    pavs_on_dist->SetX2NDC(pavs_on_dist->GetX2NDC() - shiftx);  
+  }
+  gPad->Modified();
+  gPad->Update();
+
+  hist_dist_off->DrawCopy("HISTSAME");
+  hist_dist_off->DrawCopy("ESAME");
+  hist_dist_on->DrawCopy("E1PSAME");
+
+  Double_t chidist = ChiSquareNDof((TH1D*)hist_dist_on,(TH1D*)hist_dist_off);
+
+  x_label_pos  = distmax*0.7;
+  y_label_pos  = hist_dist_on->GetBinContent(hist_dist_on->GetMaximumBin())/2.;
+
+  char text_dist[256];
+  sprintf(text_size,"ChiSquare/NDof = %4.2f",chidist);
+
+  TLatex *tdist = new TLatex(x_label_pos, y_label_pos, text_dist);
+  tdist->SetTextSize(textsize);
+//  tdist->Draw();
+
+  gPad->Modified();
+  gPad->Update();
+
+   // ############################################################################
+  // DrawCopy WIDTH
+  // ############################################################################
+  display->AddTab("WIDTH");
+
+  gPad->cd();
+
+  hist_width_off->Sumw2();
+  hist_width_off->Scale(norm); 
+  hist_width_on->SetLineColor(kBlack);
+  hist_width_on->SetMarkerStyle(21);
+  hist_width_on->SetMarkerSize(0.7);
+  hist_width_on->SetMarkerColor(kBlack);
+  hist_width_off->SetFillColor(46);
+  hist_width_off->SetLineColor(46);
+  hist_width_off->SetFillStyle(3004); //(1001)-> To set the pad NOT transparent and solid; (3004)-> pattern lines
+  hist_width_off->SetMinimum(0.);
+  hist_width_on->SetTitle("WIDTH distribution");
+  hist_width_off->SetTitle("WIDTH distribution");
+
+  hist_width_on->DrawCopy("E1P");
+
+  // move stat box to make them all visible
+  gPad->Update();
+  TPaveStats* pavs_on_width = (TPaveStats*) hist_width_on->GetListOfFunctions()->FindObject("stats");
+  if(pavs_on_width){
+    shiftx = pavs_on_width->GetX2NDC() - pavs_on_width->GetX1NDC();
+    pavs_on_width->SetX1NDC(pavs_on_width->GetX1NDC() - shiftx);
+    pavs_on_width->SetX2NDC(pavs_on_width->GetX2NDC() - shiftx);  
+  }
+  gPad->Modified();
+  gPad->Update();
+
+  hist_width_off->DrawCopy("HISTSAME");
+  hist_width_off->DrawCopy("ESAME");
+  hist_width_on->DrawCopy("E1PSAME");
+
+  Double_t chiwidth = ChiSquareNDof((TH1D*)hist_width_on,(TH1D*)hist_width_off);
+
+  x_label_pos  = widthmax*0.7;
+  y_label_pos  = hist_width_on->GetBinContent(hist_width_on->GetMaximumBin())/2.;
+
+  char text_width[256];
+  sprintf(text_size,"ChiSquare/NDof = %4.2f",chiwidth);
+
+  TLatex *twidth = new TLatex(x_label_pos, y_label_pos, text_width);
+  twidth->SetTextSize(textsize);
+//  twidth->Draw();
+
+  gPad->Modified();
+  gPad->Update();
+ 
+  // ############################################################################
+  // DrawCopy LENGTH
+  // ############################################################################
+  display->AddTab("LENGTH");
+ 
+  gPad->cd();
+
+  hist_length_on->Sumw2();
+  hist_length_off->Sumw2();
+  hist_length_off->Scale(norm); 
+  hist_length_on->SetLineColor(kBlack);
+  hist_length_on->SetMarkerStyle(21);
+  hist_length_on->SetMarkerSize(0.7);
+  hist_length_on->SetMarkerColor(kBlack);
+  hist_length_off->SetFillColor(46);
+  hist_length_off->SetLineColor(46);
+  hist_length_off->SetFillStyle(3004); //(1001)-> To set the pad NOT transparent and solid; (3004)-> pattern lines
+  hist_length_off->SetMinimum(0.);
+  hist_length_on->SetTitle("LENGTH distribution");
+  hist_length_off->SetTitle("LENGTH distribution");
+
+  hist_length_on->DrawCopy("E1P");
+
+  // move stat box to make them all visible
+  gPad->Update();
+  TPaveStats* pavs_on_length = (TPaveStats*) hist_length_on->GetListOfFunctions()->FindObject("stats");
+  if(pavs_on_length){
+    shiftx = pavs_on_length->GetX2NDC() - pavs_on_length->GetX1NDC();
+    pavs_on_length->SetX1NDC(pavs_on_length->GetX1NDC() - shiftx);
+    pavs_on_length->SetX2NDC(pavs_on_length->GetX2NDC() - shiftx);  
+  }
+  gPad->Modified();
+  gPad->Update();
+
+  hist_length_off->DrawCopy("HISTSAME");
+  hist_length_off->DrawCopy("ESAME");
+  hist_length_on->DrawCopy("E1PSAME");
+
+  Double_t chilength = ChiSquareNDof((TH1D*)hist_length_on,(TH1D*)hist_length_off);
+
+  x_label_pos  = lengthmax*0.7;
+  y_label_pos  = hist_length_on->GetBinContent(hist_length_on->GetMaximumBin())/2.;
+
+  char text_length[256];
+  sprintf(text_size,"ChiSquare/NDof = %4.2f",chilength);
+
+  TLatex *tlength = new TLatex(x_label_pos, y_label_pos, text_length);
+  tlength->SetTextSize(textsize);
+//  tlength->Draw();
+
+  gPad->Modified();
+  gPad->Update();
+
+  // ############################################################################
+  // DrawCopy normalized ALPHA plot
+  // ############################################################################
+  display->AddTab("ALPHA");
+  
+  gPad->cd();
+
+  hist_on_abs->Sumw2();
+  hist_off_abs->SetStats(0);
+  hist_off_abs->Sumw2();
+  hist_off_abs->Scale(norm); 
+  hist_on_abs->SetStats(0); //-> Do NOT show the legend with statistics
+  hist_on_abs->SetLineColor(kBlack);
+  hist_on_abs->SetMarkerStyle(21);
+  //hist_on_abs->SetMarkerSize();
+  hist_on_abs->SetMarkerColor(kBlack);
+  hist_on_abs->SetMarkerSize(0.7);
+  hist_off_abs->SetFillColor(46);
+  hist_off_abs->SetLineColor(46);
+  hist_off_abs->SetFillStyle(3004); //(1001)-> To set the pad NOT transparent and solid; (3004)-> pattern lines
+  hist_off_abs->SetMinimum(0.);
+  hist_on_abs->SetTitle("Alpha plot");
+  hist_off_abs->SetTitle("Alpha plot");
+
+  
+  hist_on_abs->DrawCopy("E1P");
+  hist_off_abs->DrawCopy("HISTSAME");
+  hist_off_abs->DrawCopy("ESAME");
+  hist_on_abs->DrawCopy("E1PSAME");
+
+
+   //draw the LEGEND with excess and significance values in the alpha plot:
+  char text_Fnorm[256], text_excess[256], text_sign[256];
+  char text_entries_on[256], text_entries_off[256], text_integral_off[256];
+  int hist_on_entries  = (int) hist_on_abs->GetEntries();
+  int hist_off_entries = (int) hist_off_abs->GetEntries();
+  sprintf(text_Fnorm,       " F norm =       %.3f", norm);
+  sprintf(text_excess,      " Excess =       %.3f", excess);
+  sprintf(text_sign,        " Significance = %.3f", sign);
+  sprintf(text_entries_on,  " Entries ON   = %d",  hist_on_entries);
+  sprintf(text_entries_off, " Entries OFF  = %d",  hist_off_entries);
+  sprintf(text_integral_off," Integral OFF = %d",  int_off);
+  
+  x_label_pos  = alphamax*0.7;
+  y_label_pos  = (hist_on_abs->GetBinContent(hist_on_abs->GetMaximumBin()))/1.6; //2.;
+  Double_t y_label_step = y_label_pos / 8.;
+
+  TLatex *t0 = new TLatex(x_label_pos, y_label_pos - y_label_step*0, text_Fnorm);
+  t0->SetTextSize(textsize);
+  t0->Draw();
+  TLatex *t1 = new TLatex(x_label_pos, y_label_pos - y_label_step*1, text_excess);
+  t1->SetTextSize(textsize);
+  t1->Draw();
+  TLatex *t2 = new TLatex(x_label_pos, y_label_pos - y_label_step*2, text_sign);
+  t2->SetTextSize(textsize);
+  t2->Draw();
+  TLatex *t3 = new TLatex(x_label_pos, y_label_pos - y_label_step*3, text_entries_on);
+  t3->SetTextSize(textsize);
+  t3->Draw();
+  TLatex *t4 = new TLatex(x_label_pos, y_label_pos - y_label_step*4, text_entries_off);
+  t4->SetTextSize(textsize);
+  t4->Draw();
+  TLatex *t5 = new TLatex(x_label_pos, y_label_pos - y_label_step*5, text_integral_off);
+  t5->SetTextSize(textsize);
+  t5->Draw();
+  
+
+  Double_t chialpha = ChiSquareNDof((TH1D*)hist_on_abs,(TH1D*)hist_off_abs);
+
+  y_label_pos  = (hist_on_abs->GetBinContent(hist_on_abs->GetMaximumBin()))/2.;
+
+  char text_alpha[256];
+  sprintf(text_size,"ChiSquare/NDof = %4.2f",chialpha);
+
+  TLatex *talpha = new TLatex(x_label_pos, y_label_pos, text_alpha);
+  talpha->SetTextSize(textsize);
+//  talpha->Draw();
+
+  gPad->Modified();
+  gPad->Update();
+
+  // ############################################################################
+  // DrawCopy normalized alpha histos for alpha form -90 to 90 deg.
+  // ############################################################################
+  display->AddTab("ALPHA +-90");
+
+  gPad->cd();
+
+  hist_on->Sumw2();
+  hist_off->SetStats(0);
+  hist_off->Sumw2();
+  hist_off->Scale(norm); 
+  hist_off->SetFillColor(46);
+  hist_off->SetLineColor(46);
+  hist_off->SetFillStyle(3004); //(1001)-> To set the pad NOT transparent and solid; (3004)-> pattern lines
+  hist_off->SetMinimum(0.); 
+  hist_on->SetStats(0); //-> Do NOT show the legend with statistics
+  hist_on->SetLineColor(kBlack);
+  hist_on->SetMarkerStyle(21);
+  hist_on->SetMarkerSize(0.7);
+  hist_on->SetMarkerColor(kBlack);
+  hist_on->SetTitle("Alpha plot form -90 to 90 deg");
+  hist_off->SetTitle("Alpha plot form -90 to 90 deg");
+
+  hist_on->DrawCopy("E1P");
+  hist_off->DrawCopy("HISTSAME");
+  hist_off->DrawCopy("ESAME");
+  hist_on->DrawCopy("E1PSAME");
+
+  Double_t chialpha90 = ChiSquareNDof((TH1D*)hist_on,(TH1D*)hist_off);
+
+  x_label_pos  = alphamax*0.5;
+  y_label_pos  = hist_on->GetBinContent(hist_on->GetMaximumBin())/2.;
+
+  char text_alpha90[256];
+  sprintf(text_alpha90,"ChiSquare/NDof = %4.2f",chialpha90);
+
+  TLatex *talpha90 = new TLatex(x_label_pos, y_label_pos, text_alpha90);
+  talpha90->SetTextSize(textsize);
+//  talpha90->Draw();
+
+  gPad->Update();
+  gPad->Modified();
+
+
+  cout << "---> ChiSquare/NDof [Size] =\t\t" << chisize << endl;
+  cout << "---> ChiSquare/NDof [Dist] =\t\t" << chidist << endl;
+  cout << "---> ChiSquare/NDof [Width] =\t\t" << chiwidth << endl;
+  cout << "---> ChiSquare/NDof [Length] =\t\t" << chilength << endl;
+  cout << "---> ChiSquare/NDof [Abs(Alpha)] =\t" << chialpha << endl;
+  cout << "---> ChiSquare/NDof [Alpha] =\t\t" << chialpha90 << endl;
+
+
+  display->AddTab("SRCPOS ON");
+  TH2F *hist_srcpos_on = (TH2F*)hSrcPos_on.GetHist();
+  hist_srcpos_on->DrawCopy("BOX");
+
+  display->AddTab("SRCPOS OFF");
+  TH2F *hist_srcpos_off = (TH2F*)hSrcPos_off.GetHist();
+  hist_srcpos_off->DrawCopy("BOX");
+
+  display->AddTab("EVTNUM ON");
+  TH1F *hist_evtnum_on = (TH1F*)hDAQEvtNumber_on.GetHist();
+  hist_evtnum_on->DrawCopy();
+
+  display->AddTab("EVTNUM OFF");
+  TH1F *hist_evtnum_off = (TH1F*)hDAQEvtNumber_off.GetHist();
+  hist_evtnum_off->DrawCopy();
+
+  cout << "Done!!" <<endl;
+
+}
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/distancebetweenstars.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/distancebetweenstars.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/distancebetweenstars.C	(revision 9661)
@@ -0,0 +1,249 @@
+ /* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Javier López, 05/2004 <mailto:jlopez@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+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;
+}
+
+Double_t fitfunc(Double_t *x, Double_t *par);
+
+void distancebetweenstars(const TString filename="dc_2004_03_17_01_16_51_20440_Mrk421.root", const TString directory="/nfs/magic/CaCodata/rootdata/Mrk421/Period015/2004_03_17/", const UInt_t numEvents = 100000000)
+{
+
+    // general settings
+    gROOT->Reset();
+    gStyle->SetCanvasColor(0);
+    gStyle->SetCanvasBorderMode(0);
+    gStyle->SetPadBorderMode(0);
+    gStyle->SetFrameBorderMode(0);
+    gStyle->SetOptTitle(0);
+    gStyle->SetTitleOffset(1.7,"y");
+    gStyle->SetPadLeftMargin(0.15);
+    gStyle->SetOptStat(111110);
+    gStyle->SetOptFit(1);
+    gStyle->SetStatColor(0);
+    gStyle->SetStatBorderSize(1);
+    gStyle->SetStatW(0.2);
+    gStyle->SetStatH(0.1);
+    gStyle->SetStatX(0.9);
+    gStyle->SetStatY(0.9);
+
+  Int_t nbins  = 100;
+  Float_t mindist = 0.0;
+  Float_t maxdist = 400.0;
+  
+  TH1F* histStarsDintances = new TH1F("StarsDintances","Distance between stars",nbins,mindist,maxdist);
+  histStarsDintances->SetXTitle("Distance [mm]");
+  histStarsDintances->SetYTitle("Counts [#]");
+  TH1F* histStarsDintances1 = new TH1F("StarsDintances1","Distance between stars",nbins,mindist,maxdist);
+  TH1F* histStarsDintances2 = new TH1F("StarsDintances2","Distance between stars [1]-[3]",nbins,mindist,maxdist);
+  TH1F* histStarsDintances3 = new TH1F("StarsDintances3","Distance between stars [2]-[3]",nbins,mindist,maxdist);
+  //
+  // 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);
+
+  MGeomCamMagic geomcam;
+  MCameraDC     dccam;
+  MStarLocalCam starcam;
+
+  plist.AddToList(&geomcam);
+  plist.AddToList(&dccam);
+  plist.AddToList(&starcam);
+
+  //
+  // Now setup the tasks and tasklist:
+  // ---------------------------------
+  //
+
+  // Reads the trees of the root file and the analysed branches
+  MReadReports read;
+  read.AddTree("Currents"); 
+  read.AddFile(directory+filename);     // after the reading of the trees!!!
+  read.AddToBranchList("MReportCurrents.*");
+
+  MGeomApply geomapl;
+  TString continuoslightfile = 
+    //    "/home/Javi/mnt_magic_data/CaCo/rootdata/Miscellaneous/Period016/2004_04_16/dc_2004_04_16_04_46_18_22368_Off3c279-2CL100.root";
+        "/nfs/magic/CaCodata/rootdata/Miscellaneous/Period016/2004_04_16/dc_2004_04_16_04_46_18_22368_Off3c279-2CL100.root";
+
+  Float_t mindc = 0.7;
+  MCalibrateDC dccal;
+  dccal.SetFileName(continuoslightfile);
+  dccal.SetMinDCAllowed(mindc);
+
+  const Int_t numblind = 5;
+  const Short_t x[numblind] = { 47, 124, 470, 475, 571};
+  const TArrayS blindpixels(numblind,(Short_t*)x);
+  Float_t ringinterest = 100; //[mm]
+  Float_t tailcut = 4.0;
+  UInt_t integratedevents = 1;
+
+  MFindStars findstars;
+  findstars.SetBlindPixels(blindpixels);
+  findstars.SetRingInterest(ringinterest);
+  findstars.SetDCTailCut(tailcut);
+  findstars.SetNumIntegratedEvents(integratedevents);
+  findstars.SetMinuitPrintOutLevel(-1);
+
+  tlist.AddToList(&geomapl);
+  tlist.AddToList(&read);
+  tlist.AddToList(&dccal);
+  tlist.AddToList(&findstars, "Currents");
+
+  //
+  // Create and setup the eventloop
+  //
+  MEvtLoop evtloop;
+  evtloop.SetParList(&plist);
+  
+//   MProgressBar bar;
+//   evtloop.SetProgressBar(&bar);
+  
+  //
+  // Execute your analysis
+  //
+  
+//   if (!evtloop.Eventloop(numEvents))
+//     return;
+
+  if (!evtloop.PreProcess())
+    return;
+
+  Float_t maxchindof = 4.;
+  
+  while (tlist.Process())
+    {
+  
+      Int_t numStars = starcam.GetNumStars();
+      if ( numStars == 3)
+        {
+          
+          for (Int_t first=0; first<numStars; first++)
+            {
+              if (starcam[first].GetChiSquareNdof()>0. && starcam[first].GetChiSquareNdof()<maxchindof)
+                {
+                  for (Int_t second=first+1; second<numStars; second++)
+                    {
+                      if (starcam[second].GetChiSquareNdof()>0. && starcam[second].GetChiSquareNdof()<maxchindof)
+                        {
+                          Float_t dist = TMath::Sqrt((starcam[first].GetMeanX()-starcam[second].GetMeanX())*
+                                                     (starcam[first].GetMeanX()-starcam[second].GetMeanX()) +
+                                                     (starcam[first].GetMeanY()-starcam[second].GetMeanY())*
+                                                     (starcam[first].GetMeanY()-starcam[second].GetMeanY()));
+
+                            histStarsDintances->Fill(dist);
+                          if (first == 0 && second == 1)
+                            histStarsDintances1->Fill(dist);
+                          else if (first == 0 && second == 2)
+                            histStarsDintances2->Fill(dist);
+                          else if (first == 1 && second == 2)
+                            histStarsDintances3->Fill(dist);
+
+                        }
+                    }
+                }
+            }
+        }
+    }
+  
+  
+
+  evtloop.PostProcess();
+
+  tlist.PrintStatistics();
+
+  //Draw results
+
+  //   histStarsDintances->Draw();
+
+// Creates a Root function based on function fitf above
+   TF1 *func = new TF1("fitfunc",fitfunc,mindist,maxdist,7);
+
+// Sets initial values and parameter names
+   func->SetParNames("ConvF","Max0","Sig0","Max1","Sig1","Max2","Sig2");
+   func->SetParameters(300.,500.,5.,500.,5.,500.,5.);
+
+// Fit histogram in range defined by function
+   histStarsDintances->Fit("fitfunc","R");
+
+//   histStarsDintances1->Draw();
+//   histStarsDintances2->Fit("gaus","0");
+//   histStarsDintances2->Draw("same");
+//   histStarsDintances2->Fit("gaus","0");
+//   histStarsDintances3->Draw("same");
+//   histStarsDintances3->Fit("gaus","0");
+
+  if (!HandleInput())
+
+  delete histStarsDintances;
+  delete histStarsDintances1;
+  delete histStarsDintances2;
+  delete histStarsDintances3;
+  
+}
+
+Double_t fitfunc(Double_t *x, Double_t *par)
+{
+  Double_t dist[3] = 
+    {
+      0.64,0.750,1.203
+    };
+  
+  
+   Double_t fitval = 
+     par[1]*TMath::Exp(-0.5*(x[0]-par[0]*dist[0])*(x[0]-par[0]*dist[0])/(par[2]*par[2])) +
+     par[3]*TMath::Exp(-0.5*(x[0]-par[0]*dist[1])*(x[0]-par[0]*dist[1])/(par[4]*par[4])) +
+     par[5]*TMath::Exp(-0.5*(x[0]-par[0]*dist[2])*(x[0]-par[0]*dist[2])/(par[6]*par[6]));
+
+   //   cout << "x "  << x[0] << " fitval " << fitval << endl;
+   
+
+   return fitval;
+}
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/findstars.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/findstars.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/findstars.C	(revision 9661)
@@ -0,0 +1,175 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Javier López, 05/2004 <mailto:jlopez@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+
+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 findstars(const TString filename="20040422_*_D_Mrk421_E.root", const TString directory="/local_disk/Data/rootdata/Mrk421/Period016/2004_04_22/", const UInt_t numEvents = 0)
+{
+
+  //
+  // 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);
+
+
+  MGeomCamMagic geomcam;
+  MCameraDC     dccam;
+  MStarLocalCam starcam;
+
+  plist.AddToList(&geomcam);
+  plist.AddToList(&dccam);
+  plist.AddToList(&starcam);
+
+  //
+  // Now setup the tasks and tasklist:
+  // ---------------------------------
+  //
+
+  // Reads the trees of the root file and the analysed branches
+  MReadReports read;
+  read.AddTree("Currents"); 
+  read.AddFile(directory+filename);     // after the reading of the trees!!!
+  read.AddToBranchList("MReportCurrents.*");
+
+  MGeomApply geomapl;
+  TString continuoslightfile = 
+    "/local_disk/CaCoData/rootdata/Miscellaneous/Period016/2004_04_16/dc_2004_04_16_04_46_18_22368_Off3c279-2CL100.root";
+
+  Float_t mindc = 0.9; //[uA]
+  MCalibrateDC dccal;
+  dccal.SetFileName(continuoslightfile);
+  dccal.SetMinDCAllowed(mindc);
+
+  const Int_t numblind = 5;
+  const Short_t x[numblind] = { 47, 124, 470, 475, 571};
+  const TArrayS blindpixels(numblind,(Short_t*)x);
+  Float_t ringinterest = 100; //[mm]
+  Float_t tailcut = 3.5;
+  UInt_t integratedevents = 4;
+
+  MFindStars findstars;
+  findstars.SetBlindPixels(blindpixels);
+  findstars.SetRingInterest(ringinterest);
+  findstars.SetDCTailCut(tailcut);
+  findstars.SetNumIntegratedEvents(integratedevents);
+  findstars.SetMinuitPrintOutLevel(-1);
+
+  
+  tlist.AddToList(&geomapl);
+  tlist.AddToList(&read);
+  tlist.AddToList(&dccal);
+  tlist.AddToList(&findstars, "Currents");
+
+  //
+  // Create and setup the eventloop
+  //
+  MEvtLoop evtloop;
+  evtloop.SetParList(&plist);
+     
+  //
+  // Execute your analysis
+  //
+
+  if (numEvents > 0)
+  {
+      if (!evtloop.Eventloop(numEvents))
+	  return;
+  }
+  else
+  {
+      if (!evtloop.PreProcess())
+	  return;
+      
+//        MHCamera display0(geomcam);
+//        display0.SetPrettyPalette();
+//        display0.Draw();
+//        //       display0.SetCamContent(dccal.GetDisplay());
+//        display0.SetCamContent(dccal.GetDCCalibrationFactor());
+//        gPad->Modified();
+//        gPad->Update();
+
+//        // Remove the comments if you want to go through the file
+//        // event-by-event:
+//        if (!HandleInput())
+//          break;
+
+       MHCamera display(geomcam);
+       display.SetPrettyPalette();
+       display.Draw();
+       gPad->cd(1);
+       starcam.Draw();
+      
+       UInt_t numevents=0;
+       
+       while (tlist.Process())
+         {
+           numevents++;
+           if (numevents%integratedevents==0)
+             {
+               //               display.SetCamContent(dccam);
+               display.SetCamContent(findstars.GetDisplay());
+               gPad->Modified();
+               gPad->Update();
+               starcam.Print("maxpossizechi");
+               // Remove the comments if you want to go through the file
+               // event-by-event:
+               if (!HandleInput())
+                 break;
+             }
+      } 
+
+      evtloop.PostProcess();
+  }
+
+  tlist.PrintStatistics();
+
+}
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/hillasONOFF.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/hillasONOFF.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/hillasONOFF.C	(revision 9661)
@@ -0,0 +1,1337 @@
+/////////////////////////////////////////////////////////////////////////////
+//
+//           _____Macro for checking the hillas parameters_____
+//
+//                       Ester Aliu  <aliu@ifae.es>
+////////////////////////////////////////////////////////////////////////////
+void hillasONOFF(
+TString onname,
+TString offname,
+TString psname)
+{    
+    // general settings
+    gROOT->Reset();
+    gStyle->SetCanvasColor(0);
+    gStyle->SetCanvasBorderMode(0);
+    gStyle->SetPadBorderMode(0);
+    gStyle->SetFrameBorderMode(0);
+    gStyle->SetOptStat(kFALSE);
+    // gStyle->SetTitleSize(0);
+    gStyle->SetStatColor(0);
+    gStyle->SetStatBorderSize(1);
+    gStyle->SetStatW(0.2);
+    gStyle->SetStatH(0.1);
+    gStyle->SetStatX(0.9);
+    gStyle->SetStatY(0.9);
+ 
+       
+    // define file, tree, canvas
+    TChain *fdata = new TChain;
+    fdata->AddFile(onname);
+    TTree *t = Parameters;                                                     
+    
+    // define file, tree, canvas
+    TChain *fdata2 = new TChain;
+    fdata2->AddFile(offname);
+    TTree *t2 = Parameters;  
+   
+    TString title;
+
+    TH1F* hLength; 
+    TH1F* hWidth; 
+    TH1F* hDist;
+    TH1F* hConc;
+    TH1F* hConc1;
+    TH1F* hConc6;
+    TH1F* hAlpha; 
+    TH1F* hSize; 
+
+    TH2F *hXY;
+
+    // define aliases
+    t->SetAlias("length","MHillas.fLength*0.6/189");
+    t->SetAlias("width","MHillas.fWidth*0.6/189");
+    t->SetAlias("dist","MHillasSrc.fDist*0.6/189");
+    t->SetAlias("conc","MNewImagePar.fConc");
+    t->SetAlias("conc1","MNewImagePar.fConc1");
+    t->SetAlias("conc6","MConcentration.fConc[6]");
+    t->SetAlias("size","MHillas.fSize");
+    t->SetAlias("alpha","abs(MHillasSrc.fAlpha)");
+    t->SetAlias("meanx","MHillas.fMeanX");
+    t->SetAlias("meany","MHillas.fMeanY");
+
+    // define aliases
+    t2->SetAlias("length","MHillas.fLength*0.6/189");
+    t2->SetAlias("width","MHillas.fWidth*0.6/189");
+    t2->SetAlias("dist","MHillasSrc.fDist*0.6/189");
+    t2->SetAlias("conc","MNewImagePar.fConc");
+    t2->SetAlias("conc1","MNewImagePar.fConc1");
+    t2->SetAlias("conc6","MConcentration.fConc[6]");
+    t2->SetAlias("size","MHillas.fSize");
+    t2->SetAlias("alpha","abs(MHillasSrc.fAlpha)");
+    t2->SetAlias("meanx","MHillas.fMeanX");
+    t2->SetAlias("meany","MHillas.fMeanY");
+
+      
+    // define  cuts
+    const char* cut1 = "size>500";
+    const char* cut2 = "size>1000";
+    const char* cut3 = "size>2000";
+    const char* cut4 = "size>5000";
+    const char* cut5 = "size>10000";
+
+    const char* cutDist = "MHillasSrc.fDist*0.6/189.>0.2 && MHillasSrc.fDist*0.6/189.<0.8";
+
+
+    /*****************************************************************
+    ****                         PLOTS                            ****
+    *****************************************************************/
+    
+    Int_t nbin;
+    Float_t min;
+    Float_t max;
+
+
+    TString openpsname;
+    openpsname = psname + "(";
+
+    TString closepsname;
+    closepsname = psname  + ")";
+
+
+    //////////////////////////////////////////////////////////////
+    //                    Cuts in Size
+    //////////////////////////////////////////////////////////////
+    TCanvas *c1 = new TCanvas("c1","c1",500,800);
+    c1->Divide(2,3);
+    /////////////////////////////////////////////////////////////////
+
+    char* var="length>>hLength";    
+
+    nbin = 40; min = 0.; max = 1.;
+
+    c1->cd(1);
+    c1->GetPad(1)->SetGrid();    
+    title = "length " ;
+    hLength = new TH1F("hLength",title,nbin, min, max);
+    t->Draw(var, "","goff");  
+    hLength->SetXTitle("degrees");
+    hLength->SetNormFactor(1.);
+    hLength->Draw("Ehist");
+    c1->GetPad(1)->Update();    
+    
+    c1->cd(2);
+    c1->GetPad(2)->SetGrid();    
+    title = "length ";  
+    title = title + cut1;
+    hLength = new TH1F("hLength",title, nbin, min, max);
+    t->Draw(var,cut1,"goff");
+    hLength->SetXTitle("degrees");
+    hLength->SetNormFactor(1.);
+    hLength->Draw("Ehist");    
+    c1->GetPad(2)->Update();
+  
+    c1->cd(3);
+    c1->GetPad(3)->SetGrid();    
+    title = "length ";  
+    title = title + cut2;
+    hLength = new TH1F("hLength",title,nbin, min, max);
+    t->Draw(var,cut2,"goff");
+    hLength->SetXTitle("degrees");
+    hLength->SetNormFactor(1.);
+    hLength->Draw("Ehist");
+    c1->GetPad(3)->Update();
+  
+    c1->cd(4);
+    c1->GetPad(4)->SetGrid();    
+    title = "length ";  
+    title = title + cut3;
+    hLength = new TH1F("hLength",title,nbin, min, max);
+    t->Draw(var,cut3, "goff");
+    hLength->SetXTitle("degrees");
+    hLength->SetNormFactor(1.);
+    hLength->Draw("Ehist");
+    c1->GetPad(4)->Update();
+        
+    c1->cd(5);
+    c1->GetPad(5)->SetGrid();    
+    title = "length ";  
+    title = title + cut4;
+    hLength = new TH1F("hLength",title,nbin, min, max);
+    t->Draw(var,cut4, "goff");
+    hLength->SetXTitle("degrees");
+    hLength->SetNormFactor(1.);
+    hLength->Draw("Ehist");
+    c1->GetPad(5)->Update();
+        
+    c1->cd(6);
+    c1->GetPad(6)->SetGrid();    
+    title = "length ";  
+    title = title + cut5;
+    hLength = new TH1F("hLength",title,nbin, min, max);
+    t->Draw(var,cut5, "goff");
+    hLength->SetXTitle("degrees");
+    hLength->SetNormFactor(1.);
+    hLength->Draw("Ehist");
+    c1->GetPad(6)->Update();
+   
+    //off data
+
+    c1->cd(1);
+    title = "length " ;
+    hLength = new TH1F("hLength",title,nbin, min, max);
+    t2->Draw(var, "","goff");  
+    hLength->SetXTitle("degrees");
+    //hLength->SetLineStyle(2);
+    hLength->SetMarkerStyle(20);
+    hLength->SetMarkerSize(0.4);
+    hLength->SetNormFactor(1);
+    hLength->Draw("samePE");
+    c1->GetPad(1)->Modified();    
+    c1->GetPad(1)->Update();    
+    
+    c1->cd(2);
+    title = "length ";  
+    title = title + cut1;
+    hLength = new TH1F("hLength",title, nbin, min, max);
+    t2->Draw(var,cut1,"goff");
+    hLength->SetXTitle("degrees");
+    //hLength->SetLineStyle(2);
+    hLength->SetMarkerSize(0.4);
+    hLength->SetMarkerStyle(20);
+    hLength->SetNormFactor(1);
+    hLength->Draw("samePE");    
+    c1->GetPad(2)->Modified();    
+    c1->GetPad(2)->Update();
+  
+    c1->cd(3);
+    title = "length ";  
+    title = title + cut2;
+    hLength = new TH1F("hLength",title,nbin, min, max);
+    t2->Draw(var,cut2,"goff");
+    //hLength->SetXTitle("degrees");
+    hLength->SetMarkerSize(0.4);
+    hLength->SetMarkerStyle(20);
+    //hLength->SetLineStyle(2);
+    hLength->SetNormFactor(1);
+    hLength->Draw("samePE");
+    c1->GetPad(3)->Modified();    
+    c1->GetPad(3)->Update();
+  
+    c1->cd(4);
+    title = "length ";  
+    title = title + cut3;
+    hLength = new TH1F("hLength",title,nbin, min, max);
+    t2->Draw(var,cut3, "goff");
+    hLength->SetXTitle("degrees");
+    //    hLength->SetLineStyle(2);
+    hLength->SetMarkerStyle(20);
+    hLength->SetMarkerSize(0.4);
+    hLength->SetNormFactor(1);
+    hLength->Draw("samePE");
+    c1->GetPad(4)->Modified();    
+    c1->GetPad(4)->Update();
+        
+    c1->cd(5);
+    title = "length ";  
+    title = title + cut4;
+    hLength = new TH1F("hLength",title,nbin, min, max);
+    t2->Draw(var,cut4, "goff");
+    hLength->SetXTitle("degrees");
+    //hLength->SetLineStyle(2);
+    hLength->SetMarkerStyle(20);
+    hLength->SetMarkerSize(0.4);
+    hLength->SetNormFactor(1);
+    hLength->Draw("samePE");
+    c1->GetPad(5)->Modified();    
+    c1->GetPad(5)->Update();
+        
+    c1->cd(6);
+    title = "length ";  
+    title = title + cut5;
+    hLength = new TH1F("hLength",title,nbin, min, max);
+    t2->Draw(var,cut5, "goff");
+    hLength->SetXTitle("degrees");
+    // hLength->SetLineStyle(2);
+    hLength->SetMarkerStyle(20);
+    hLength->SetMarkerSize(0.4);
+    hLength->SetNormFactor(1);
+    hLength->Draw("samePE");
+    c1->GetPad(6)->Modified();    
+    c1->GetPad(6)->Update();
+    
+    c1->Print(openpsname); 
+
+    /////////////////////////////////////////////////////////////////
+    char* var="width>>hWidth";
+
+    nbin = 40; min = 0.; max = 0.8;
+
+    c1->cd(1);
+    title = "width ";  
+    hWidth = new TH1F("hWidth",title,nbin, min, max);
+    t->Draw(var, "", "goff");
+    hWidth->SetXTitle("degrees");
+    hWidth->SetNormFactor(1.);
+    hWidth->Draw("Ehist");
+    c1->GetPad(1)->Update();    
+
+    c1->cd(2);
+    title = "width ";  
+    title = title + cut1;
+    hWidth = new TH1F("hWidth",title,nbin, min, max);
+    t->Draw(var,cut1, "goff");
+    hWidth->SetXTitle("degrees");
+    hWidth->SetNormFactor(1.);
+    hWidth->Draw("Ehist");    
+    c1->GetPad(2)->Update();
+    
+    c1->cd(3);
+    title = "width ";  
+    title = title + cut2;
+    hWidth = new TH1F("hWidth",title,nbin, min, max);
+    t->Draw(var,cut2, "goff");
+    hWidth->SetXTitle("degrees");
+    hWidth->SetNormFactor(1.);
+    hWidth->Draw("Ehist");
+    c1->GetPad(3)->Update();
+    
+    c1->cd(4);
+    title = "width ";  
+    title = title + cut3;
+    hWidth = new TH1F("hWidth",title,nbin, min, max);
+    t->Draw(var,cut3, "goff");
+    hWidth->SetXTitle("degrees");
+    hWidth->SetNormFactor(1.);
+    hWidth->Draw("Ehist");
+    c1->GetPad(4)->Update();
+    
+    c1->cd(5);
+    title = "width ";  
+    title = title + cut4;
+    hWidth = new TH1F("hWidth",title,nbin, min, max);
+    t->Draw(var,cut4, "goff");
+    hWidth->SetXTitle("degrees");
+    hWidth->SetNormFactor(1.);
+    hWidth->Draw("Ehist");
+    c1->GetPad(5)->Update();
+    
+    c1->cd(6);
+    title = "width ";  
+    title = title + cut5;
+    hWidth = new TH1F("hWidth",title,nbin, min, max);
+    t->Draw(var,cut5, "goff");
+    hWidth->SetXTitle("degrees");
+    hWidth->SetNormFactor(1.);
+    hWidth->Draw("Ehist");
+    c1->GetPad(6)->Update();
+
+    // offdata
+   
+    c1->cd(1);
+    title = "width ";  
+    hWidth = new TH1F("hWidth",title,nbin, min, max);
+    t2->Draw(var, "", "goff");
+    hWidth->SetXTitle("degrees");
+    //hWidth->SetLineStyle(2);
+    hWidth->SetMarkerStyle(20);
+    hWidth->SetMarkerSize(0.4);
+    hWidth->SetNormFactor(1);
+    hWidth->Draw("samePE");
+    c1->GetPad(1)->Modified();    
+    c1->GetPad(1)->Update();    
+
+    c1->cd(2);
+    title = "width ";  
+    title = title + cut1;
+    hWidth = new TH1F("hWidth",title,nbin, min, max);
+    t2->Draw(var,cut1, "goff");
+    hWidth->SetXTitle("degrees");
+    //hWidth->SetLineStyle(2);
+    hWidth->SetMarkerStyle(20);
+    hWidth->SetMarkerSize(0.4);
+    hWidth->SetNormFactor(1);
+    hWidth->Draw("samePE");    
+    c1->GetPad(2)->Modified();    
+    c1->GetPad(2)->Update();
+    
+    c1->cd(3);
+    title = "width ";  
+    title = title + cut2;
+    hWidth = new TH1F("hWidth",title,nbin, min, max);
+    t2->Draw(var,cut2, "goff");
+    hWidth->SetXTitle("degrees");
+    //hWidth->SetLineStyle(2);
+    hWidth->SetMarkerStyle(20);
+    hWidth->SetMarkerSize(0.4);
+    hWidth->SetNormFactor(1);
+    hWidth->Draw("samePE");
+    c1->GetPad(3)->Modified();    
+    c1->GetPad(3)->Update();
+    
+    c1->cd(4);
+    title = "width ";  
+    title = title + cut3;
+    hWidth = new TH1F("hWidth",title,nbin, min, max);
+    t2->Draw(var,cut3, "goff");
+    hWidth->SetXTitle("degrees");
+    //hWidth->SetLineStyle(2);
+    hWidth->SetMarkerStyle(20);
+    hWidth->SetMarkerSize(0.4);
+    hWidth->SetNormFactor(1);
+    hWidth->Draw("samePE");
+    c1->GetPad(4)->Modified();    
+    c1->GetPad(4)->Update();
+    
+    c1->cd(5);
+    title = "width ";  
+    title = title + cut4;
+    hWidth = new TH1F("hWidth",title,nbin, min, max);
+    t2->Draw(var,cut4, "goff");
+    hWidth->SetXTitle("degrees");
+    // hWidth->SetLineStyle(2);
+    hWidth->SetMarkerStyle(20);
+    hWidth->SetMarkerSize(0.4);
+    hWidth->SetNormFactor(1);
+    hWidth->Draw("samePE");
+    c1->GetPad(5)->Modified();    
+    c1->GetPad(5)->Update();
+    
+    c1->cd(6);
+    title = "width ";  
+    title = title + cut5;
+    hWidth = new TH1F("hWidth",title,nbin, min, max);
+    t2->Draw(var,cut5, "goff");
+    hWidth->SetXTitle("degrees");
+    //hWidth->SetLineStyle(2);
+    hWidth->SetMarkerStyle(20);
+    hWidth->SetMarkerSize(0.4);
+    hWidth->SetNormFactor(1);
+    hWidth->Draw("samePE");
+    c1->GetPad(6)->Modified();    
+    c1->GetPad(6)->Update();
+
+   
+    c1->Print(psname); 
+ 
+    /////////////////////////////////////////////////////////////////
+
+    char* var="dist>>hDist";
+      
+    nbin = 40; min = 0.; max = 1.6;
+
+    c1->cd(1);
+    title = "dist ";  
+    hDist = new TH1F("hDist",title,nbin, min, max);   
+    t->Draw(var, "", "goff");
+    hDist->SetXTitle("degrees");
+    hDist->SetNormFactor(1.);
+    hDist->Draw("Ehist");
+    c1->GetPad(1)->Update();    
+
+    c1->cd(2);
+    title = "dist ";  
+    title = title + cut1;
+    hDist = new TH1F("hDist",title,nbin, min, max);
+    t->Draw(var,cut1, "goff");
+    hDist->SetXTitle("degrees");
+    hDist->SetNormFactor(1.);
+    hDist->Draw("Ehist");    
+    c1->GetPad(2)->Update();
+    
+    c1->cd(3);
+    title = "dist ";  
+    title = title + cut2;
+    hDist = new TH1F("hDist",title,nbin, min, max);
+    t->Draw(var,cut2, "goff");
+    hDist->SetXTitle("degrees");
+    hDist->SetNormFactor(1.);
+    hDist->Draw("Ehist");
+    c1->GetPad(3)->Update();
+    
+    c1->cd(4);
+    title = "dist ";  
+    title = title + cut3;
+    hDist = new TH1F("hDist",title,nbin, min, max);
+    t->Draw(var,cut3, "goff");
+    hDist->SetXTitle("degrees");
+    hDist->SetNormFactor(1.);
+    hDist->Draw("Ehist");
+    c1->GetPad(4)->Update();
+    
+    c1->cd(5);
+    title = "dist ";  
+    title = title + cut4;
+    hDist = new TH1F("hDist",title,nbin, min, max);
+    t->Draw(var,cut4, "goff");
+    hDist->SetXTitle("degrees");
+    hDist->SetNormFactor(1.);
+    hDist->Draw("Ehist");
+    c1->GetPad(5)->Update();
+    
+    c1->cd(6);
+    title = "dist ";  
+    title = title + cut5;
+    hDist = new TH1F("hDist",title,nbin, min, max);
+    t->Draw(var,cut5,"goff");
+    hDist->SetXTitle("degrees");
+    hDist->SetNormFactor(1.);
+    hDist->Draw("Ehist");
+    c1->GetPad(6)->Update();
+
+    //offdata
+
+    c1->cd(1);
+    title = "dist ";  
+    hDist = new TH1F("hDist",title,nbin, min, max);   
+    t2->Draw(var, "", "goff");
+    hDist->SetXTitle("degrees");
+    //hDist->SetLineStyle(2);
+    hDist->SetMarkerStyle(20);
+    hDist->SetMarkerSize(0.4);
+    hDist->SetNormFactor(1);
+    hDist->Draw("samePE");
+    c1->GetPad(1)->Modified();    
+    c1->GetPad(1)->Update();    
+
+    c1->cd(2);
+    title = "dist ";  
+    title = title + cut1;
+    hDist = new TH1F("hDist",title,nbin, min, max);
+    t2->Draw(var,cut1, "goff");
+    hDist->SetXTitle("degrees");
+    //hDist->SetLineStyle(2);
+    hDist->SetMarkerStyle(20);
+    hDist->SetMarkerSize(0.4);
+    hDist->SetNormFactor(1);
+    hDist->Draw("samePE");    
+    c1->GetPad(2)->Modified();    
+    c1->GetPad(2)->Update();
+    
+    c1->cd(3);
+    title = "dist ";  
+    title = title + cut2;
+    hDist = new TH1F("hDist",title,nbin, min, max);
+    t2->Draw(var,cut2, "goff");
+    hDist->SetXTitle("degrees");
+    //hDist->SetLineStyle(2);
+    hDist->SetMarkerStyle(20);
+    hDist->SetMarkerSize(0.4);   
+    hDist->SetNormFactor(1);
+    hDist->Draw("samePE");
+    c1->GetPad(3)->Modified();    
+    c1->GetPad(3)->Update();
+    
+    c1->cd(4);
+    title = "dist ";  
+    title = title + cut3;
+    hDist = new TH1F("hDist",title,nbin, min, max);
+    t2->Draw(var,cut3, "goff");
+    hDist->SetXTitle("degrees");
+    //hDist->SetLineStyle(2);
+    hDist->SetMarkerStyle(20);
+    hDist->SetMarkerSize(0.4);
+    hDist->SetNormFactor(1);
+    hDist->Draw("samePE");
+    c1->GetPad(4)->Modified();    
+    c1->GetPad(4)->Update();
+    
+    c1->cd(5);
+    title = "dist ";  
+    title = title + cut4;
+    hDist = new TH1F("hDist",title,nbin, min, max);
+    t2->Draw(var,cut4, "goff");
+    hDist->SetXTitle("degrees");
+    //hDist->SetLineStyle(2);
+    hDist->SetMarkerStyle(20);
+    hDist->SetMarkerSize(0.4);
+    hDist->SetNormFactor(1);
+    hDist->Draw("samePE");
+    c1->GetPad(5)->Modified();    
+    c1->GetPad(5)->Update();
+    
+    c1->cd(6);
+    title = "dist ";  
+    title = title + cut5;
+    hDist = new TH1F("hDist",title,nbin, min, max);
+    t2->Draw(var,cut5,"goff");
+    hDist->SetXTitle("degrees");
+    //hDist->SetLineStyle(2);
+    hDist->SetMarkerStyle(20);
+    hDist->SetMarkerSize(0.4);
+    hDist->SetNormFactor(1);
+    hDist->Draw("samePE");
+    c1->GetPad(6)->Modified();    
+    c1->GetPad(6)->Update();
+
+    c1->Print(psname); 
+
+    /////////////////////////////////////////////////////////////////
+    char* var="conc>>hConc";
+
+    nbin = 40; min = 0.; max = 1.;
+
+    c1->cd(1);
+    title = "conc ";  
+    hConc = new TH1F("hConc",title,nbin, min, max);
+    t->Draw(var,"","goff");
+    hConc->SetNormFactor(1.);
+    hConc->Draw("Ehist");
+    c1->GetPad(1)->Update();    
+
+    c1->cd(2);
+    title = "conc ";  
+    title = title + cut1;
+    hConc = new TH1F("hConc",title,nbin, min, max);
+    t->Draw(var,cut1,"goff");    
+    hConc->SetNormFactor(1.);
+    hConc->Draw("Ehist");
+    c1->GetPad(2)->Update();
+    
+    c1->cd(3);
+    title = "conc ";  
+    title = title + cut2;
+    hConc = new TH1F("hConc",title,nbin, min, max);
+    t->Draw(var,cut2,"goff");
+    hConc->SetNormFactor(1.);
+    hConc->Draw("Ehist");
+    c1->GetPad(3)->Update();
+    
+    c1->cd(4);
+    title = "conc ";  
+    title = title + cut3;
+    hConc = new TH1F("hConc",title,nbin, min, max);
+    t->Draw(var,cut3,"goff");
+    hConc->SetNormFactor(1.);
+    hConc->Draw("Ehist");
+    c1->GetPad(4)->Update();
+    
+    c1->cd(5);
+    title = "conc ";  
+    title = title + cut4;
+    hConc = new TH1F("hConc",title,nbin, min, max);
+    t->Draw(var,cut4,"goff");
+    hConc->SetNormFactor(1.);
+    hConc->Draw("Ehist");
+    c1->GetPad(5)->Update();
+    
+    c1->cd(6);
+    title = "conc ";  
+    title = title + cut5;
+    hConc = new TH1F("hConc",title,nbin, min, max);
+    t->Draw(var,cut5,"goff");
+    hConc->SetNormFactor(1.);
+    hConc->Draw("Ehist");
+    c1->GetPad(6)->Update();
+  
+    //offdata 
+
+    c1->cd(1);
+    title = "conc ";  
+    hConc = new TH1F("hConc",title,nbin, min, max);
+    t2->Draw(var, "","goff");
+    hConc->SetNormFactor(1.);
+    //hConc->SetLineStyle(2);
+    hConc->SetMarkerStyle(20);
+    hConc->SetMarkerSize(0.4);
+    hConc->Draw("samePE");
+    c1->GetPad(1)->Modified();    
+    c1->GetPad(1)->Update();    
+
+    c1->cd(2);
+    title = "conc ";  
+    title = title + cut1;
+    hConc = new TH1F("hConc",title,nbin, min, max);
+    t2->Draw(var,cut1,"goff");
+    hConc->SetNormFactor(1.);
+    hConc->SetMarkerStyle(20);
+    hConc->SetMarkerSize(0.4);
+    // hConc->SetLineStyle(2);
+    hConc->Draw("samePE");
+    c1->GetPad(2)->Modified();        
+    c1->GetPad(2)->Update();
+    
+    c1->cd(3);
+    title = "conc ";  
+    title = title + cut2;
+    hConc = new TH1F("hConc",title,nbin, min, max);
+    t2->Draw(var,cut2,"goff");
+    hConc->SetNormFactor(1.);
+    hConc->SetMarkerStyle(20);
+    hConc->SetMarkerSize(0.4);
+    //hConc->SetLineStyle(2);
+    hConc->Draw("samePE");
+    c1->GetPad(3)->Modified();    
+    c1->GetPad(3)->Update();
+    
+    c1->cd(4);
+    title = "conc ";  
+    title = title + cut3;
+    hConc = new TH1F("hConc",title,nbin, min, max);
+    t2->Draw(var,cut3,"goff");
+    hConc->SetNormFactor(1.);
+    hConc->SetMarkerStyle(20);
+    hConc->SetMarkerSize(0.4);
+    //hConc->SetLineStyle(2);
+    hConc->Draw("samePE");
+    c1->GetPad(4)->Modified();    
+    c1->GetPad(4)->Update();
+    
+    c1->cd(5);
+    title = "conc ";  
+    title = title + cut4;
+    hConc = new TH1F("hConc",title,nbin, min, max);
+    t2->Draw(var,cut4,"goff");
+    hConc->SetNormFactor(1.);
+    hConc->SetMarkerStyle(20);
+    hConc->SetMarkerSize(0.4);
+    //hConc->SetLineStyle(2);
+    hConc->Draw("samePE");
+    c1->GetPad(5)->Modified();    
+    c1->GetPad(5)->Update();
+    
+    c1->cd(6);
+    title = "conc ";  
+    title = title + cut5;
+    hConc = new TH1F("hConc",title,nbin, min, max);
+    t2->Draw(var,cut5,"goff");
+    hConc->SetNormFactor(1.);
+    hConc->SetMarkerStyle(20);
+    hConc->SetMarkerSize(0.4);
+    //hConc->SetLineStyle(2);
+    hConc->Draw("samePE");
+    c1->GetPad(6)->Modified();    
+    c1->GetPad(6)->Update();
+  
+    c1->Print(psname); 
+
+    /////////////////////////////////////////////////////////////////
+    char* var="conc6>>hConc6";
+
+    nbin = 40; min = 0.; max = 1.;
+
+    c1->cd(1);
+    title = "conc6 ";  
+    hConc6 = new TH1F("hConc6",title,nbin, min, max);
+    t->Draw(var,"","goff");
+    hConc6->SetNormFactor(1.);
+    hConc6->Draw("Ehist");
+    c1->GetPad(1)->Update();    
+
+    c1->cd(2);
+    title = "conc6 ";  
+    title = title + cut1;
+    hConc6 = new TH1F("hConc6",title,nbin, min, max);
+    t->Draw(var,cut1,"goff");  
+    hConc6->SetNormFactor(1.);
+    hConc6->Draw("Ehist");  
+    c1->GetPad(2)->Update();
+    
+    c1->cd(3);
+    title = "conc6 ";  
+    title = title + cut2;
+    hConc6 = new TH1F("hConc6",title,nbin, min, max);
+    t->Draw(var,cut2,"goff");
+    hConc6->SetNormFactor(1.);
+    hConc6->Draw("Ehist");
+    c1->GetPad(3)->Update();
+    
+    c1->cd(4);
+    title = "conc6 ";  
+    title = title + cut3;
+    hConc6 = new TH1F("hConc6",title,nbin, min, max);
+    t->Draw(var,cut3,"goff");
+    hConc6->SetNormFactor(1.);
+    hConc6->Draw("Ehist");
+    c1->GetPad(4)->Update();
+    
+    c1->cd(5);
+    title = "conc6 ";  
+    title = title + cut4;
+    hConc6 = new TH1F("hConc6",title,nbin, min, max);
+    t->Draw(var,cut4,"goff");
+    hConc6->SetNormFactor(1.);
+    hConc6->Draw("Ehist");
+    c1->GetPad(5)->Update();
+    
+    c1->cd(6);
+    title = "conc6 ";  
+    title = title + cut5;
+    hConc6 = new TH1F("hConc6",title,nbin, min, max);
+    t->Draw(var,cut5,"goff");
+    hConc6->SetNormFactor(1.);
+    hConc6->Draw("Ehist");
+    c1->GetPad(6)->Update();
+
+    //offdata
+
+    c1->cd(1);
+    title = "conc6 ";  
+    hConc6 = new TH1F("hConc6",title,nbin, min, max);
+    t2->Draw(var,"","goff");
+    hConc6->SetNormFactor(1.);
+    hConc6->SetMarkerStyle(20);
+    hConc6->SetMarkerSize(0.4);
+    //hConc6->SetLineStyle(2);
+    hConc6->Draw("samePE");
+    c1->GetPad(1)->Modified();    
+    c1->GetPad(1)->Update();    
+
+    c1->cd(2);
+    title = "conc6 ";  
+    title = title + cut1;
+    hConc6 = new TH1F("hConc6",title,nbin, min, max);
+    t2->Draw(var,cut1,"goff");
+    hConc6->SetNormFactor(1.);
+    hConc6->SetMarkerStyle(20);
+    hConc6->SetMarkerSize(0.4);
+    //hConc6->SetLineStyle(2);
+    hConc6->Draw("samePE");
+    c1->GetPad(2)->Modified();        
+    c1->GetPad(2)->Update();
+    
+    c1->cd(3);
+    title = "conc6 ";  
+    title = title + cut2;
+    hConc6 = new TH1F("hConc6",title,nbin, min, max);
+    t2->Draw(var,cut2,"goff");
+    hConc6->SetNormFactor(1.);
+    hConc6->SetMarkerStyle(20);
+    hConc6->SetMarkerSize(0.4);
+    //hConc6->SetLineStyle(2);
+    hConc6->Draw("samePE");
+    c1->GetPad(3)->Modified();    
+    c1->GetPad(3)->Update();
+    
+    c1->cd(4);
+    title = "conc6 ";  
+    title = title + cut3;
+    hConc6 = new TH1F("hConc6",title,nbin, min, max);
+    t2->Draw(var,cut3,"goff");
+    hConc6->SetNormFactor(1.);
+    hConc6->SetMarkerStyle(20);
+    hConc6->SetMarkerSize(0.4);
+    //hConc6->SetLineStyle(2);
+    hConc6->Draw("samePE");
+    c1->GetPad(4)->Modified();    
+    c1->GetPad(4)->Update();
+    
+    c1->cd(5);
+    title = "conc6 ";  
+    title = title + cut4;
+    hConc6 = new TH1F("hConc6",title,nbin, min, max);
+    t2->Draw(var,cut4,"goff");
+    hConc6->SetNormFactor(1.);
+    hConc6->SetMarkerStyle(20);
+    hConc6->SetMarkerSize(0.4);
+    // hConc6->SetLineStyle(2);
+    hConc6->Draw("samePE");
+    c1->GetPad(5)->Modified();    
+    c1->GetPad(5)->Update();
+    
+    c1->cd(6);
+    title = "conc6 ";  
+    title = title + cut5;
+    hConc6 = new TH1F("hConc6",title,nbin, min, max);
+    t2->Draw(var,cut5,"goff");
+    hConc6->SetNormFactor(1.);
+    hConc6->SetMarkerStyle(20);
+    hConc6->SetMarkerSize(0.4);
+    //hConc6->SetLineStyle(2);
+    hConc6->Draw("samePE");
+    c1->GetPad(6)->Modified();    
+    c1->GetPad(6)->Update();
+
+    c1->Print(psname); 
+
+    /////////////////////////////////////////////////////////////////
+    char* var="alpha>>hAlpha";
+
+    nbin = 18; min = 0.; max = 90.;
+    
+    c1->cd(1);
+    title = "alpha ";  
+    hAlpha = new TH1F("hAlpha",title,nbin, min, max);
+    t->Draw(var, "", "goff");
+    hAlpha->SetXTitle("degrees");
+    hAlpha->SetNormFactor(1);
+    hAlpha->Draw("Ehist");
+    c1->GetPad(1)->Update();    
+
+    c1->cd(2);
+    title = "alpha ";  
+    title = title + cut1;
+    hAlpha = new TH1F("hAlpha",title,nbin, min, max);
+    t->Draw(var,cut1, "goff");
+    hAlpha->SetXTitle("degrees");
+    hAlpha->SetNormFactor(1);
+    hAlpha->Draw("Ehist");    
+    c1->GetPad(2)->Update();
+    
+    c1->cd(3);
+    title = "alpha ";  
+    title = title + cut2;
+    hAlpha = new TH1F("hAlpha",title,nbin, min, max);
+    t->Draw(var,cut2, "goff");
+    hAlpha->SetXTitle("degrees");
+    hAlpha->SetNormFactor(1);
+    hAlpha->Draw("Ehist");
+    c1->GetPad(3)->Update();
+    
+    c1->cd(4);
+    title = "alpha ";  
+    title = title + cut3;
+    hAlpha = new TH1F("hAlpha",title,nbin, min, max);
+    t->Draw(var,cut3, "goff");
+    hAlpha->SetXTitle("degrees");
+    hAlpha->SetNormFactor(1);
+    hAlpha->Draw("Ehist");
+    c1->GetPad(4)->Update();
+    
+    c1->cd(5);
+    title = "alpha ";  
+    title = title + cut4;
+    hAlpha = new TH1F("hAlpha",title,nbin, min, max);
+    t->Draw(var,cut4, "goff");
+    hAlpha->SetXTitle("degrees");
+    hAlpha->SetNormFactor(1);
+    hAlpha->Draw("Ehist");
+    c1->GetPad(5)->Update();
+    
+    c1->cd(6);
+    title = "alpha ";  
+    title = title + cut5;
+    hAlpha = new TH1F("hAlpha",title,nbin, min, max);
+    t->Draw(var,cut5, "goff");
+    hAlpha->SetXTitle("degrees");
+    hAlpha->SetNormFactor(1);
+    hAlpha->Draw("Ehist");
+    c1->GetPad(6)->Update();
+
+    //offdata
+
+    c1->cd(1);
+    title = "alpha ";  
+    hAlpha = new TH1F("hAlpha",title,nbin, min, max);
+    t2->Draw(var, "", "goff");
+    hAlpha->SetXTitle("degrees");
+    //hAlpha->SetLineStyle(2);
+    hAlpha->SetNormFactor(1);
+    hAlpha->SetMarkerStyle(20);
+    hAlpha->SetMarkerSize(0.4);
+    hAlpha->Draw("samePE");
+    c1->GetPad(1)->Modified();    
+    c1->GetPad(1)->Update();    
+
+    c1->cd(2);
+    title = "alpha ";  
+    title = title + cut1;
+    hAlpha = new TH1F("hAlpha",title,nbin, min, max);
+    t2->Draw(var,cut1, "goff");
+    hAlpha->SetXTitle("degrees");
+    //hAlpha->SetLineStyle(2);
+    hAlpha->SetMarkerStyle(20);
+    hAlpha->SetMarkerSize(0.4);
+    hAlpha->SetNormFactor(1);
+    hAlpha->Draw("samePE");    
+    c1->GetPad(2)->Modified();    
+    c1->GetPad(2)->Update();
+    
+    c1->cd(3);
+    title = "alpha ";  
+    title = title + cut2;
+    hAlpha = new TH1F("hAlpha",title,nbin, min, max);
+    t2->Draw(var,cut2, "goff");
+    hAlpha->SetXTitle("degrees");
+    //hAlpha->SetLineStyle(2);
+    hAlpha->SetNormFactor(1);
+    hAlpha->SetMarkerStyle(20);
+    hAlpha->SetMarkerSize(0.4);
+    hAlpha->Draw("samePE");
+    c1->GetPad(3)->Modified();    
+    c1->GetPad(3)->Update();
+    
+    c1->cd(4);
+    title = "alpha ";  
+    title = title + cut3;
+    hAlpha = new TH1F("hAlpha",title,nbin, min, max);
+    t2->Draw(var,cut3, "goff");
+    hAlpha->SetXTitle("degrees");
+    //hAlpha->SetLineStyle(2);
+    hAlpha->SetMarkerStyle(20);
+    hAlpha->SetMarkerSize(0.4);
+    hAlpha->SetNormFactor(1);
+    hAlpha->Draw("samePE");
+    c1->GetPad(4)->Modified();    
+    c1->GetPad(4)->Update();
+    
+    c1->cd(5);
+    title = "alpha ";  
+    title = title + cut4;
+    hAlpha = new TH1F("hAlpha",title,nbin, min, max);
+    t2->Draw(var,cut4, "goff");
+    hAlpha->SetXTitle("degrees");
+    //hAlpha->SetLineStyle(2);
+    hAlpha->SetMarkerStyle(20);
+    hAlpha->SetMarkerSize(0.4);
+    hAlpha->SetNormFactor(1);
+    hAlpha->Draw("samePE");
+    c1->GetPad(5)->Modified();    
+    c1->GetPad(5)->Update();
+    
+    c1->cd(6);
+    title = "alpha ";  
+    title = title + cut5;
+    hAlpha = new TH1F("hAlpha",title,nbin, min, max);
+    t2->Draw(var,cut5, "goff");
+    hAlpha->SetXTitle("degrees");
+    //hAlpha->SetLineStyle(2);
+    hAlpha->SetMarkerStyle(20);
+    hAlpha->SetMarkerSize(0.4);
+    hAlpha->SetNormFactor(1);
+    hAlpha->Draw("samePE");
+    c1->GetPad(6)->Modified();    
+    c1->GetPad(6)->Update();
+
+    c1->Print(psname); 
+
+    /////////////////////////////////////////////////////////////////
+    //                     Cuts in Dist
+    /////////////////////////////////////////////////////////////////
+
+    TCanvas *c2 = new TCanvas("c2","Cuts in Dist",500,800);
+    c2->Divide(2,3);
+    /////////////////////////////////////////////////////////////////
+    char* var="length>>hLength";
+
+    nbin = 40; min = 0.; max = 1.;
+
+    c2->cd(1);
+    //    c2->GetPad(1)->SetGrid();    
+    title = "length "; 
+    hLength = new TH1F("hLength",title,nbin, min, max);
+    t->Draw(var, "", "goff");
+    hLength->SetXTitle("degrees");
+    hLength->SetNormFactor(1);
+    hLength->Draw("Ehist");
+    c2->GetPad(1)->Update();
+ 
+    c2->cd(2);
+    //c2->GetPad(2)->SetGrid();    
+    title = "length ";  
+    title = title + cutDist;
+    hLength = new TH1F("hLength",title,nbin, min, max);
+    t->Draw(var,cutDist, "goff");
+    hLength->SetXTitle("degrees");
+    hLength->SetNormFactor(1);
+    hLength->Draw("Ehist");
+    c2->GetPad(2)->Update();
+
+    //offdata
+        
+    c2->cd(1);
+    c2->GetPad(1)->SetGrid();    
+    title = "length "; 
+    hLength = new TH1F("hLength",title,nbin, min, max);
+    t2->Draw(var, "", "goff");
+    hLength->SetXTitle("degrees");
+    //   hLength->SetLineStyle(2);
+    hLength->SetMarkerStyle(20);
+    hLength->SetMarkerSize(0.4);
+    hLength->SetNormFactor(1);
+    hLength->Draw("samePE");
+    c2->GetPad(1)->Modified();    
+    c2->GetPad(1)->Update();
+ 
+    c2->cd(2);
+    c2->GetPad(2)->SetGrid();    
+    title = "length ";  
+    title = title + cutDist;
+    hLength = new TH1F("hLength",title,nbin, min, max);
+    t2->Draw(var,cutDist, "goff");
+    hLength->SetXTitle("degrees");
+    hLength->SetMarkerStyle(20);
+    hLength->SetMarkerSize(0.4);
+    //hLength->SetLineStyle(2);
+    hLength->SetNormFactor(1);
+    hLength->Draw("samePE");
+    c2->GetPad(1)->Modified();    
+    c2->GetPad(2)->Update();
+
+    /////////////////////////////////////////////////////////////////
+    char* var="width>>hWidth";
+
+    nbin = 40; min = 0.; max = 1.;
+
+    c2->cd(3);
+    c2->GetPad(3)->SetGrid();    
+    title = "width ";  
+    hWidth = new TH1F("hWidth",title,nbin, min, max);
+    t->Draw(var, "", "goff");
+    hWidth->SetXTitle("degrees");
+    hWidth->SetNormFactor(1);
+    hWidth->Draw("Ehist");
+    c2->GetPad(3)->Update();
+    
+    c2->cd(4);
+    c2->GetPad(4)->SetGrid();    
+    title = "width ";  
+    title = title + cutDist;
+    hWidth = new TH1F("hWidth",title,nbin, min, max);
+    t->Draw(var,cutDist, "goff");
+    hWidth->SetXTitle("degrees");
+    hWidth->SetNormFactor(1);
+    hWidth->Draw("Ehist");
+    c2->GetPad(4)->Update();
+    
+    //offdata
+
+    c2->cd(3);
+    c2->GetPad(3)->SetGrid();    
+    title = "width ";  
+    hWidth = new TH1F("hWidth",title,nbin, min, max);
+    t2->Draw(var, "", "goff");
+    hWidth->SetXTitle("degrees");
+    //hWidth->SetLineStyle(2);
+    hWidth->SetMarkerStyle(20);
+    hWidth->SetMarkerSize(0.4);
+    hWidth->SetNormFactor(1);
+    hWidth->Draw("samePE");
+    c2->GetPad(3)->Modified();    
+    c2->GetPad(3)->Update();
+    
+    c2->cd(4);
+    c2->GetPad(4)->SetGrid();    
+    title = "width ";  
+    title = title + cutDist;
+    hWidth = new TH1F("hWidth",title,nbin, min, max);
+    t2->Draw(var,cutDist, "goff");
+    hWidth->SetXTitle("degrees");
+    //hWidth->SetLineStyle(2);
+    hWidth->SetMarkerStyle(20);
+    hWidth->SetMarkerSize(0.4);
+    hWidth->SetNormFactor(1);
+    hWidth->Draw("samePE");
+    c2->GetPad(4)->Modified();    
+    c2->GetPad(4)->Update();
+
+    /////////////////////////////////////////////////////////////////
+    char* var="conc>>hConc";
+
+    nbin = 40; min = 0.; max = 1.;
+
+    c2->cd(5);
+    c2->GetPad(5)->SetGrid();    
+    title = "conc ";  
+    hConc = new TH1F("hConc",title,nbin, min, max);
+    t->Draw(var,"","goff");
+    hConc->SetNormFactor(1.);
+    hConc->Draw("Ehist");
+    c2->GetPad(5)->Update();
+    
+    c2->cd(6);
+    c2->GetPad(6)->SetGrid();    
+    title = "conc ";  
+    title = title + cutDist;
+    hConc = new TH1F("hConc",title,nbin, min, max);
+    t->Draw(var,cutDist,"goff");
+    hConc->SetNormFactor(1.);
+    hConc->Draw("Ehist");
+    c2->GetPad(6)->Update();
+    
+    //offdata
+
+    c2->cd(5);
+    c2->GetPad(5)->SetGrid();    
+    title = "conc ";  
+    hConc = new TH1F("hConc",title,nbin, min, max);
+    t2->Draw(var,"", "goff");
+    //  hConc->SetLineStyle(2);
+    hConc->SetMarkerStyle(20);
+    hConc->SetMarkerSize(0.4);
+    hConc->SetNormFactor(1.);
+    hConc->Draw("samePE");
+    c2->GetPad(5)->Modified();    
+    c2->GetPad(5)->Update();
+    
+    c2->cd(6);
+    c2->GetPad(6)->SetGrid();    
+    title = "conc ";  
+    title = title + cutDist;
+    hConc = new TH1F("hConc",title,nbin, min, max);
+    t2->Draw(var,cutDist,"goff");
+    //hConc->SetLineStyle(2);
+    hConc->SetMarkerStyle(20);
+    hConc->SetMarkerSize(0.4);
+    hConc->SetNormFactor(1.);
+    hConc->Draw("samePE");
+    c2->GetPad(6)->Modified();    
+    c2->GetPad(6)->Update();
+    
+    c2->Print(psname); 
+
+    /////////////////////////////////////////////////////////////////
+    char* var="conc6>>hConc6";
+
+    nbin = 40; min = 0.; max = 1.;
+
+    c2->cd(1);
+    title = "conc6 ";  
+    hConc6 = new TH1F("hConc6",title,nbin, min, max);
+    t->Draw(var,"","goff");
+    hConc6->SetNormFactor(1.);
+    hConc6->Draw("Ehist");
+    c2->GetPad(1)->Update();
+    
+    c2->cd(2);
+    title = "conc6 ";  
+    title = title + cutDist;
+    hConc6 = new TH1F("hConc6",title,nbin, min, max);
+    t->Draw(var,cutDist,"goff");
+    hConc6->SetNormFactor(1.);
+    hConc6->Draw("Ehist");
+    c2->GetPad(2)->Update();
+
+    //offdata
+
+    c2->cd(1);
+    title = "conc6 ";  
+    hConc6 = new TH1F("hConc6",title,nbin, min, max);
+    t2->Draw(var,"","goff");
+    //hConc6->SetLineStyle(2);
+    hConc6->SetMarkerStyle(20);
+    hConc6->SetMarkerSize(0.4);
+    hConc6->SetNormFactor(1.);
+    hConc6->Draw("samePE");
+    c2->GetPad(1)->Modified();    
+    c2->GetPad(1)->Update();
+    
+    c2->cd(2);
+    title = "conc6 ";  
+    title = title + cutDist;
+    hConc6 = new TH1F("hConc6",title,nbin, min, max);
+    t2->Draw(var,cutDist,"goff");
+    // hConc6->SetLineStyle(2);
+    hConc6->SetMarkerStyle(20);
+    hConc6->SetMarkerSize(0.4);
+    hConc6->SetNormFactor(1.);
+    hConc6->Draw("samePE");
+    c2->GetPad(2)->Modified();    
+    c2->GetPad(2)->Update(); 
+  
+    /////////////////////////////////////////////////////////////////
+    char* var="alpha>>hAlpha";
+
+    nbin = 18; min = 0.; max = 90.;
+
+    c2->cd(3);
+    title = "alpha ";  
+    hAlpha = new TH1F("hAlpha",title,nbin, min, max);
+    t->Draw(var, "", "goff");
+    hAlpha->SetXTitle("degrees");
+    hAlpha->SetNormFactor(1);
+    hAlpha->Draw("Ehist");
+    c2->GetPad(3)->Update();
+    
+    c2->cd(4);
+    title = "alpha ";  
+    title = title + cutDist;
+    hAlpha = new TH1F("hAlpha",title,nbin, min, max);
+    t->Draw(var,cutDist, "goff");
+    hAlpha->SetXTitle("degrees");
+    hAlpha->SetNormFactor(1);
+    hAlpha->Draw("Ehist");
+    c2->GetPad(4)->Update();
+   
+    //offdata
+
+    c2->cd(3);
+    title = "alpha ";  
+    hAlpha = new TH1F("hAlpha",title,nbin, min, max);
+    t2->Draw(var, "", "goff");
+    hAlpha->SetXTitle("degrees");
+    //hAlpha->SetLineStyle(2);
+    hAlpha->SetMarkerStyle(20);
+    hAlpha->SetMarkerSize(0.4);
+    hAlpha->SetNormFactor(1);
+    hAlpha->Draw("samePE");
+    c2->GetPad(3)->Modified();    
+    c2->GetPad(3)->Update();
+    
+    c2->cd(4);
+    title = "alpha ";  
+    title = title + cutDist;
+    hAlpha = new TH1F("hAlpha",title,nbin, min, max);
+    t2->Draw(var,cutDist, "goff");
+    hAlpha->SetXTitle("degrees");
+    //hAlpha->SetLineStyle(2);
+    hAlpha->SetMarkerStyle(20);
+    hAlpha->SetMarkerSize(0.4);
+    hAlpha->SetNormFactor(1);
+    hAlpha->Draw("samePE");
+    c2->GetPad(4)->Modified();    
+    c2->GetPad(4)->Update();
+
+
+    /////////////////////////////////////////////////////////////////
+    char* var="log10(size)>>hSize";
+
+    nbin = 40; min = 0.5; max = 4.5;
+
+    c2->cd(5);
+    c2->GetPad(5)->SetLogy(); 
+    title = "size ";  
+    hSize = new TH1F("hSize",title,nbin, min, max);
+    t->Draw(var, "1/MHillas.fSize", "goff");
+    hSize->SetNormFactor(1.);
+    hSize->SetXTitle("log10(ADC counts)");
+    hSize->Draw("Ehist");
+    c2->GetPad(5)->Update();
+    
+    c2->cd(6);
+    c2->GetPad(6)->SetLogy(); 
+    title = "size ";  
+    title = title + cutDist;
+    hSize = new TH1F("hSize",title,nbin, min, max);
+    t->Draw(var,"1/MHillas.fSize*(MHillasSrc.fDist*0.6/189.>0.2 && MHillasSrc.fDist*0.6/189<0.8)", "goff");
+    hSize->SetXTitle("log10(ADC counts)");
+    hSize->SetNormFactor(1.);
+    hSize->Draw("Ehist");
+    c2->GetPad(6)->Update(); 
+
+    //offdata
+    c2->cd(5);
+    c2->GetPad(5)->SetLogy(); 
+    title = "size ";  
+    hSize = new TH1F("hSize",title,nbin, min, max);
+    t2->Draw(var, "1/MHillas.fSize", "goff");
+    hSize->SetXTitle("log10(ADC counts)");
+    hSize->SetNormFactor(1.);
+    hSize->SetMarkerStyle(20);
+    hSize->SetMarkerSize(0.4);
+    //hSize->SetLineStyle(2);
+    hSize->Draw("samePE");
+    c2->GetPad(5)->Modified();    
+    c2->GetPad(5)->Update();
+    
+    c2->cd(6);
+    c2->GetPad(6)->SetLogy(); 
+    title = "size ";  
+    title = title + cutDist;
+    hSize = new TH1F("hSize",title,nbin, min, max);
+    t2->Draw(var,"1/MHillas.fSize*(MHillasSrc.fDist*0.6/189.>0.2 && MHillasSrc.fDist*0.6/189<0.8)", "goff");
+    hSize->SetXTitle("log10(ADC counts)");
+    //hSize->SetLineStyle(2);
+    hSize->SetNormFactor(1.);
+    hSize->SetMarkerStyle(20);
+    hSize->SetMarkerSize(0.4);
+    hSize->Draw("samePE");
+    c2->GetPad(6)->Modified();    
+    c2->GetPad(6)->Update(); 
+       
+    c2->Print(closepsname);                                                    
+  
+}
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/hvnotnominal.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/hvnotnominal.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/hvnotnominal.C	(revision 9661)
@@ -0,0 +1,167 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Javier López, 04/2004 <mailto:jlopez@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+
+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 hvnotnominal(const TString filename="20040319_20821_D_Mrk421_S.root", const TString directory="/nfs/magic/CaCodata/2004_03_19/", Float_t percent = 0.01)
+{
+
+  //
+  // 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);
+
+
+  MGeomCamMagic geomcam;
+  MBadPixelsCam badcam;
+  MCameraHV     hvcam;
+
+  // this line is needed because the CC rep rootified file don't have run header,
+  // then the MGeomApply can not initialitaze the containers with the number of 
+  // pixels because this is done in the reinit().
+  badcam.InitSize(geomcam.GetNumPixels());
+  
+  plist.AddToList(&geomcam);
+  plist.AddToList(&badcam);
+  plist.AddToList(&hvcam);
+
+  //
+  // Now setup the tasks and tasklist:
+  // ---------------------------------
+  //
+
+  // Reads the trees of the root file and the analysed branches
+  MReadReports read;
+  read.AddTree("Camera"); 
+  read.AddFile(directory+filename);     // after the reading of the trees!!!
+  read.AddToBranchList("MReportCamera.*");
+
+  MGeomApply geomapl;
+  MFHVNotNominal fHVNominal;
+  TString hvnominal = "/mnt/users/jlopez/Mars/Files4Mars/Config/HVSettings_FF35q.conf";
+  fHVNominal.SetHVNominalValues(hvnominal);
+  //  fHVNominal.SetMaxNumPixelsDeviated(10);
+  MContinue cont_hv(&fHVNominal);
+
+  tlist.AddToList(&read);
+  tlist.AddToList(&geomapl);
+  tlist.AddToList(&cont_hv);
+
+  //
+  // Create and setup the eventloop
+  //
+  MEvtLoop evtloop;
+  evtloop.SetParList(&plist);
+     
+  //
+  // Execute your analysis
+  //
+
+  MHCamera hvnotnominal(geomcam);
+  MHCamera lowhvnotnominal(geomcam);
+  MHCamera uphvnotnominal(geomcam);
+
+  if (!evtloop.PreProcess())
+    return;
+
+  TArrayD nominal = fHVNominal.GetHVNominal();
+  TArrayD lownominal = nominal;
+  TArrayD upnominal = nominal;
+  
+  for (UInt_t pix=0; pix<nominal.GetSize(); pix++)
+    {
+      lownominal[pix] *= (1-percent);
+      upnominal[pix]  *= (1+percent);
+    }
+  
+  
+  while(tlist.Process())
+    {
+      
+      hvnotnominal.CntCamContent(hvcam,lownominal,0,kFALSE);
+      hvnotnominal.CntCamContent(hvcam,upnominal,0,kTRUE);
+      
+      lowhvnotnominal.CntCamContent(hvcam,lownominal,0,kFALSE);
+      uphvnotnominal.CntCamContent(hvcam,upnominal,0,kTRUE);
+    }
+  
+
+  evtloop.PostProcess();
+  
+  tlist.PrintStatistics();
+  
+  TCanvas c1;
+  c1.Divide(2,1);
+  c1.cd(1);
+  lowhvnotnominal.SetPrettyPalette();
+  lowhvnotnominal.Draw();
+  gPad->cd(1);
+  gPad->Modified();
+  gPad->Update();
+  c1.cd(2);
+  uphvnotnominal.SetPrettyPalette();
+  uphvnotnominal.Draw();
+  gPad->cd(2);
+  gPad->Modified();
+  gPad->Update();
+
+  TCanvas c2;
+  hvnotnominal.SetPrettyPalette();
+  hvnotnominal.Draw();
+  gPad->cd(1);
+  gPad->Modified();
+  gPad->Update();
+
+  if (!HandleInput())
+    break;
+
+}
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/lightcurve.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/lightcurve.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/lightcurve.C	(revision 9661)
@@ -0,0 +1,1178 @@
+
+Double_t ChiSquareNDof(TH1D *h1, TH1D *h2);
+Int_t GetBin(Double_t size, Int_t numberSizeBins, Double_t sizeBins[]);
+
+void lightcurve(TString f_on_name = "../HillasFiles/Mrk421/*_H.root", 
+                TString f_off_name = "../HillasFiles/OffMrk421/*_H.root")
+{
+
+  gROOT->Reset();
+  gStyle->SetCanvasColor(0);
+  gStyle->SetCanvasBorderMode(0);
+  gStyle->SetPadBorderMode(0);
+  gStyle->SetFrameBorderMode(0);
+  gStyle->SetTimeOffset(-3600);
+
+  // Configuration
+  const Bool_t debug = kFALSE;
+  const Double_t timebin = 1380.; //[sec]
+  TString psname = "./20040421_Mrk421.1380s.ps";
+
+  //Constanst
+  const Double_t kConvDegToRad = TMath::Pi()/180.;
+  const Double_t kSec = 1e3;  //[sec/milisec]
+  const Double_t kDay = 24.*60.*60.;  //[Day/sec]
+
+  UInt_t numberTimeBins = 1;
+  TArrayI numberOnEvents(1);
+  TArrayD numberOnEventsAfterCleaning(1);
+  TArrayD numberBkgEventsToNormOn(1);
+  TArrayD timeOn(1);
+  
+  TArrayD meanTimeBinOn(1);
+  TArrayD widthTimeBinOn(1);
+
+  TArrayD zenithMinimumOn(1);
+  TArrayD zenithMaximumOn(1);
+
+  TArrayD deadFractionOn(1);
+  
+  TObjArray coszenithHistoOn;
+  TObjArray alphaHistoOn;
+  TObjArray srcposHistoOn;
+  TObjArray timediffHistoOn;
+  
+  const Int_t numberSizeBins = 3;
+  Double_t sizeBins[numberSizeBins] = {1897., 2785., 4087.}; //[Photons]
+
+  //cuts
+
+  Double_t widthmin[numberSizeBins]  = { 0.06, 0.06, 0.06 }; 
+  Double_t widthmax[numberSizeBins]  = { 0.10, 0.12, 0.12 };
+  Double_t lengthmin[numberSizeBins] = { 0.10, 0.10, 0.10 }; 
+  Double_t lengthmax[numberSizeBins] = { 0.25, 0.26, 0.36 };
+  Double_t distmin[numberSizeBins]   = { 0.30, 0.30, 0.30 }; 
+  Double_t distmax[numberSizeBins]   = { 1.20, 1.20, 1.20 };
+
+//   const Int_t numberSizeBins = 4;
+//   Double_t sizeBins[numberSizeBins] = {1292., 1897., 2785., 4087.}; //[Photons]
+
+//   //cuts
+
+//   Double_t widthmin[numberSizeBins]  = { 0.06, 0.06, 0.06, 0.06 }; 
+//   Double_t widthmax[numberSizeBins]  = { 0.10, 0.10, 0.12, 0.12 };
+//   Double_t lengthmin[numberSizeBins] = { 0.10, 0.10, 0.10, 0.10 }; 
+//   Double_t lengthmax[numberSizeBins] = { 0.20, 0.25, 0.26, 0.36 };
+//   Double_t distmin[numberSizeBins]   = { 0.30, 0.30, 0.30, 0.30 }; 
+//   Double_t distmax[numberSizeBins]   = { 1.20, 1.20, 1.20, 1.20 };
+
+  //alpha plot integration for gammas
+  Double_t sigexccmin = 0.;
+  Double_t sigexccmax = 15.;
+  Double_t bkgnormmin = 40.;
+  Double_t bkgnormmax = 80.;
+  
+  gStyle->SetOptStat(111111);
+  gStyle->SetOptFit();
+  
+  //
+  // Make a loop only for the ON data:
+  //
+  
+  MParList plist_on;
+  MTaskList tlist_on;
+  plist_on.AddToList(&tlist_on);
+  
+  // ON containers
+  MGeomCamMagic geomcam;
+  MRawRunHeader runheader_on;
+  MRawEvtHeader evtheader_on;
+  MTime              time_on;
+  MLiveTime      livetime_on;
+  MHillas          hillas_on;
+  MHillasSrc    hillassrc_on;
+  MSrcPosCam       srcpos_on;
+  MReportDrive      drive_on;
+
+  plist_on.AddToList(&geomcam);
+  plist_on.AddToList(&runheader_on);
+  plist_on.AddToList(&evtheader_on);
+  plist_on.AddToList(&time_on);
+  plist_on.AddToList(&livetime_on);
+  plist_on.AddToList(&hillas_on);
+  plist_on.AddToList(&hillassrc_on);
+  plist_on.AddToList(&srcpos_on);
+  plist_on.AddToList(&drive_on);
+
+  Int_t nbins_Size = 60;
+  Double_t min_Size = log10(sizeBins[0])*0.8;
+  Double_t max_Size = log10(1000000)*1.2;
+  TH1F *hSize_on = new TH1F ("hSizeOn","",nbins_Size,min_Size,max_Size);
+
+  Int_t nbins_Width = 20;
+  Double_t min_Width = 0.;
+  Double_t max_Width = widthmax[numberSizeBins-1]*1.2;
+  TH1F *hWidth_on = new TH1F ("hWidthOn","",nbins_Width,min_Width,max_Width);
+
+  Int_t nbins_Length = 20;
+  Double_t min_Length = 0.;
+  Double_t max_Length =  lengthmax[numberSizeBins-1]*1.2;
+  TH1F *hLength_on = new TH1F ("hLengthOn","",nbins_Length,min_Length,max_Length);
+
+  Int_t nbins_Dist = 20;
+  Double_t min_Dist = 0.;
+  Double_t max_Dist = distmax[numberSizeBins-1]*1.2;
+  TH1F *hDist_on = new TH1F ("hDistOn","",nbins_Dist,min_Dist,max_Dist);
+
+  Int_t nbins_abs = 18;
+  Double_t minalpha_abs = 0.;
+  Double_t maxalpha_abs =90.;
+  TH1F *hAlpha_on_abs = new TH1F ("hAbsAlphaOn","",nbins_abs,minalpha_abs,maxalpha_abs);
+
+  Int_t nbins = nbins_abs*2;
+  Double_t minalpha = -90.;
+  Double_t maxalpha =  90.;
+  TH1F *hAlpha_on = new TH1F ("hAlphaOn","",nbins,minalpha,maxalpha);
+
+  Int_t nbins_srcpos = 200;
+  Double_t minsrcpos = -200.;
+  Double_t maxsrcpos =  200.;  //[mm]  //!!! position precition 3mm ~ 0.01 deg
+  TH2F *hSrcPos_on = new TH2F ("hSrcPosOn","",nbins_srcpos,minsrcpos,maxsrcpos,nbins_srcpos,minsrcpos,maxsrcpos);
+
+  //
+  //tasks
+  //
+  
+  MReadTree read_on("Parameters", f_on_name);
+  read_on.DisableAutoScheme();
+ 
+  MSrcPlace srcplace;
+  MHillasSrcCalc csrc_on;
+
+  MLiveTimeCalc livetimecalc_on;
+  livetimecalc_on.SetRealTimeBinSize(timebin);
+
+//   // prints
+//   MPrint pevent("MRawEvtHeader");
+//   MPrint phillas("MHillas");
+//   MPrint phillassrc("MHillasSrc");
+//   MPrint psrcpos("MSrcPosCam");
+  
+  //tasklist
+  tlist_on.AddToList(&read_on);
+  tlist_on.AddToList(&livetimecalc_on);
+  tlist_on.AddToList(&srcplace);
+  tlist_on.AddToList(&csrc_on);
+  
+  // Create and setup the eventloop
+  MEvtLoop loop_on;
+  loop_on.SetParList(&plist_on);
+  //loop_on.SetDisplay(display);
+  
+//   MProgressBar bar;
+//   loop_on.SetProgressBar(&bar);
+  
+//   if (!loop_on.Eventloop())
+//     return;
+
+  if (!loop_on.PreProcess())
+    return;
+  
+  numberOnEventsAfterCleaning[numberTimeBins-1] = 0;
+  zenithMinimumOn[numberTimeBins-1] = 100.;
+  zenithMaximumOn[numberTimeBins-1] = 0.;
+  timeOn[numberTimeBins-1] = 0;
+
+  //create histos needed in the time bins
+
+  TString alphaTitle = Form("%s%02i","hAlphaOn",numberTimeBins-1);
+  TH1F *hAlpha_on_abs_timebin = new TH1F (alphaTitle,"",nbins_abs,minalpha_abs,maxalpha_abs);
+
+  TString srcposTitle =  Form("%s%02i","hSrcPosOn",numberTimeBins-1);
+  TH2F *hSrcPos_on_timebin = new TH2F (srcposTitle,"",nbins_srcpos,minsrcpos,maxsrcpos,nbins_srcpos,minsrcpos,maxsrcpos);
+
+  Int_t nbins_coszenith = 200;
+  Double_t mincoszenith = 0.;  
+  Double_t maxcoszenith = 1.;  
+  TString coszenithTitle =  Form("%s%02i","hCosZenithOn",numberTimeBins-1);
+  TH1F *hCosZenith_on_timebin = new TH1F (coszenithTitle,"",nbins_coszenith,mincoszenith,maxcoszenith);
+
+  Int_t nbins_timediff = 2000;
+  Double_t mintimediff = 0.;  
+  Double_t maxtimediff = 40.;  
+  TString timediffTitle =  Form("%s%02i","hTimeDiffOn",numberTimeBins-1);
+  TH1F *hTimeDiff_on_timebin = new TH1F (timediffTitle,"",nbins_timediff,mintimediff,maxtimediff);
+  TF1 *f1 = new TF1("exp","expo",mintimediff,maxtimediff);	      
+
+  Double_t lastSrcPosX = 0;
+  Double_t lastSrcPosY = 0;
+
+  while(tlist_on.Process())
+    {
+      numberOnEventsAfterCleaning[numberTimeBins-1]++;
+      
+      if (srcpos_on.GetX() == 0. && srcpos_on.GetY() == 0.)
+	srcpos_on.SetXY(lastSrcPosX,lastSrcPosY);
+      else
+	{
+	  lastSrcPosX = srcpos_on.GetX();
+	  lastSrcPosY = srcpos_on.GetY();
+	}
+      srcplace.CallProcess();
+      csrc_on.CallProcess();
+
+      
+      Double_t size = hillas_on.GetSize();
+      Double_t width = hillas_on.GetWidth()*geomcam.GetConvMm2Deg();
+      Double_t length = hillas_on.GetLength()*geomcam.GetConvMm2Deg();
+      Double_t meanx = hillas_on.GetMeanX()*geomcam.GetConvMm2Deg();
+      Double_t meany = hillas_on.GetMeanY()*geomcam.GetConvMm2Deg();
+      Double_t centerdist = TMath::Sqrt(meanx*meanx + meany*meany);
+      Double_t dist = hillassrc_on.GetDist()*geomcam.GetConvMm2Deg();
+      Double_t alpha = hillassrc_on.GetAlpha();
+      Double_t srcposx = srcpos_on.GetX();
+      Double_t srcposy = srcpos_on.GetY();
+      Double_t zenith = drive_on.GetNominalZd();
+	  
+
+      Int_t sizebin = GetBin(size,numberSizeBins,sizeBins);
+	  
+      if (sizebin >= 0)
+	{
+	  if (width > widthmin[sizebin] && width < widthmax[sizebin])
+	    {
+	      if (length > lengthmin[sizebin] && length < lengthmax[sizebin])
+		{
+		  if (dist > distmin[sizebin] && centerdist < distmax[sizebin])
+		    {      
+		      
+		      //General histos
+		      hSize_on->Fill(log10(size));
+		      hWidth_on->Fill(width);
+		      hLength_on->Fill(length);
+		      hDist_on->Fill(dist);
+		      hAlpha_on_abs->Fill(TMath::Abs(alpha));
+		      hAlpha_on->Fill(alpha);
+		      hSrcPos_on->Fill(srcposx,srcposy);
+		      
+		      // Time bin histos
+		      hAlpha_on_abs_timebin->Fill(TMath::Abs(alpha));
+		      hSrcPos_on_timebin->Fill(srcposx,srcposy);
+		      hCosZenith_on_timebin->Fill(TMath::Cos(zenith*kConvDegToRad));
+		      
+		      if (zenith != 0 && zenith < zenithMinimumOn[numberTimeBins-1])
+			zenithMinimumOn[numberTimeBins-1] = zenith;
+		      if (zenith>zenithMaximumOn[numberTimeBins-1])
+			zenithMaximumOn[numberTimeBins-1] = zenith;
+		      
+		    }
+		}
+	    }
+	}
+      
+      
+      // Check if you are overload the maxim time bin
+      if (numberTimeBins != livetime_on.GetNumberTimeBins())
+	{
+	  timeOn[numberTimeBins-1] = livetime_on.GetLiveTimeTArray().At(numberTimeBins-1);
+	  meanTimeBinOn[numberTimeBins-1] = livetime_on.GetMeanRealTimeTArray().At(numberTimeBins-1);
+	  widthTimeBinOn[numberTimeBins-1] = livetime_on.GetWidthRealTimeTArray().At(numberTimeBins-1);
+
+	  //Compute the number of on events
+	  numberOnEvents[numberTimeBins-1] = (Double_t) hAlpha_on_abs_timebin->Integral((Int_t)sigexccmin*nbins_abs/90+1,(Int_t)sigexccmax*nbins_abs/90);
+	  numberBkgEventsToNormOn[numberTimeBins-1] =  (Double_t)  hAlpha_on_abs_timebin->Integral((Int_t)bkgnormmin*nbins_abs/90+1,(Int_t)bkgnormmax*nbins_abs/90);	      
+	  
+// 	  hTimeDiff_on_timebin->Fit("exp","RQ0");
+// 	  deadFractionOn[numberTimeBins-1] = (nbins_timediff/(maxtimediff-mintimediff))*TMath::Exp(f1->GetParameter(0))/(TMath::Abs(f1->GetParameter(1))*hTimeDiff_on_timebin->GetEntries());
+// 	  cout << "1-> Exp(" << f1->GetParameter(0) << " + " << f1->GetParameter(1) << "*x) +- [" <<  f1->GetParError(0) << ' ' << f1->GetParError(1) << "]" << endl;
+// 	  cout << "Calc entries " << (nbins_timediff/(maxtimediff-mintimediff))*TMath::Exp(f1->GetParameter(0))/(TMath::Abs(f1->GetParameter(1))) << " +- Nt*(" << TMath::Sqrt( f1->GetParameter(0)*f1->GetParError(0)*f1->GetParameter(0)*f1->GetParError(0) + (f1->GetParError(1)*f1->GetParError(1))/(f1->GetParameter(1)*f1->GetParameter(1)))  << ") meas entries " << hTimeDiff_on_timebin->GetEntries() << " dead fraction " << deadFractionOn[numberTimeBins-1] << endl;
+	  deadFractionOn[numberTimeBins-1] = 1.;
+	  
+	  alphaHistoOn.AddLast(hAlpha_on_abs_timebin);
+	  srcposHistoOn.AddLast(hSrcPos_on_timebin);
+	  coszenithHistoOn.AddLast(hCosZenith_on_timebin);
+	  timediffHistoOn.AddLast(hTimeDiff_on_timebin);
+	  
+	  numberTimeBins = livetime_on.GetNumberTimeBins();
+	  
+	  timeOn.Set(numberTimeBins);
+	  numberOnEvents.Set(numberTimeBins);
+	  numberBkgEventsToNormOn.Set(numberTimeBins);
+	  widthTimeBinOn.Set(numberTimeBins);
+	  meanTimeBinOn.Set(numberTimeBins);
+	  zenithMinimumOn.Set(numberTimeBins);
+	  zenithMaximumOn.Set(numberTimeBins);
+	  deadFractionOn.Set(numberTimeBins);
+	  numberOnEventsAfterCleaning.Set(numberTimeBins);
+	  
+	  timeOn[numberTimeBins-1] = 0.;
+	  zenithMinimumOn[numberTimeBins-1] = 100.;
+	  zenithMaximumOn[numberTimeBins-1] = 0.;
+	  numberOnEventsAfterCleaning[numberTimeBins-1] = 0;
+	  
+	  alphaTitle =  Form("%s%02i","hAlphaOn",numberTimeBins-1);         
+	  hAlpha_on_abs_timebin = new TH1F (alphaTitle,"",nbins_abs,minalpha_abs,maxalpha_abs);
+	  
+	  srcposTitle =  Form("%s%02i","hSrcPosOn",numberTimeBins-1);
+	  hSrcPos_on_timebin = new TH2F (srcposTitle,"",nbins_srcpos,minsrcpos,maxsrcpos,nbins_srcpos,minsrcpos,maxsrcpos);
+	  
+	  coszenithTitle =  Form("%s%02i","hCosZenithOn",numberTimeBins-1);
+	  hCosZenith_on_timebin = new TH1F (coszenithTitle,"",nbins_coszenith,mincoszenith,maxcoszenith);
+	  
+	  timediffTitle =  Form("%s%02i","hTimeDiffOn",numberTimeBins-1);
+	  hTimeDiff_on_timebin = new TH1F (timediffTitle,"",nbins_timediff,mintimediff,maxtimediff);
+	  
+	}
+      
+    }
+	
+  loop_on.PostProcess();
+  
+  tlist_on.PrintStatistics();
+  
+  timeOn[numberTimeBins-1] = livetime_on.GetLiveTimeTArray().At(numberTimeBins-1);
+  meanTimeBinOn[numberTimeBins-1] = livetime_on.GetMeanRealTimeTArray().At(numberTimeBins-1);
+  widthTimeBinOn[numberTimeBins-1] = livetime_on.GetWidthRealTimeTArray().At(numberTimeBins-1);
+  
+  //Compute the number of on events for the last time bin
+  numberOnEvents[numberTimeBins-1] = (Double_t) hAlpha_on_abs_timebin->Integral((Int_t)sigexccmin*nbins_abs/90+1,(Int_t)sigexccmax*nbins_abs/90);
+  numberBkgEventsToNormOn[numberTimeBins-1] =  (Double_t)  hAlpha_on_abs_timebin->Integral((Int_t)bkgnormmin*nbins_abs/90+1,(Int_t)bkgnormmax*nbins_abs/90);	      
+
+//   hTimeDiff_on_timebin->Fit("exp","RQ0");
+//   deadFractionOn[numberTimeBins-1] = (nbins_timediff/(maxtimediff-mintimediff))*TMath::Exp(f1->GetParameter(0))/(TMath::Abs(f1->GetParameter(1))*hTimeDiff_on_timebin->GetEntries());
+
+//   cout.precision(5);
+//   cout << "2-> Exp(" << f1->GetParameter(0) << " + 
+//   cout << "Calc entries " << (nbins_timediff/(maxtimediff-mintimediff))*TMath::Exp(f1->GetParameter(0))/TMath::Abs(f1->GetParameter(1)) << " +- Nt*(" << TMath::Sqrt( f1->GetParameter(0)*f1->GetParError(0)*f1->GetParameter(0)*f1->GetParError(0) + (f1->GetParError(1)*f1->GetParError(1))/(f1->GetParameter(1)*f1->GetParameter(1)))  << ") meas entries " << hTimeDiff_on_timebin->GetEntries() << " dead fraction " << deadFractionOn[numberTimeBins-1] << endl;
+  deadFractionOn[numberTimeBins-1] = 1.;
+
+  alphaHistoOn.AddLast(hAlpha_on_abs_timebin);
+  srcposHistoOn.AddLast(hSrcPos_on_timebin);
+  coszenithHistoOn.AddLast(hCosZenith_on_timebin);
+  timediffHistoOn.AddLast(hTimeDiff_on_timebin);
+
+  //-----------------------OFF------------------------
+
+  TObjArray alphaHistoOff;
+  TObjArray srcposHistoOff;
+
+  TArrayD timeOff(numberTimeBins);
+
+  TArrayI numberOffEvents(numberTimeBins);
+
+  TArrayD numberBkgEventsToNormOff(numberTimeBins);
+  TArrayD onOffNormFactor(numberTimeBins);
+  TArrayD onOffNormFactorWithEvents(numberTimeBins);
+  TArrayD onOffNormFactorWithLiveTime(numberTimeBins);
+
+  TArrayD numberExcessEvents(numberTimeBins);
+  TArrayD errorNumberExcessEvents(numberTimeBins);
+
+  TArrayD numberExcessEventsPerSec(numberTimeBins);
+  TArrayD errorNumberExcessEventsPerSec(numberTimeBins);
+
+  TArrayD numberExcessEventsPerMin(numberTimeBins);
+  TArrayD errorNumberExcessEventsPerMin(numberTimeBins);
+
+  timeOff.Set(numberTimeBins);
+  
+  TH1F* hAlpha_off_abs_timebin;
+  TH2F* hSrcPos_off_timebin;
+  for (UInt_t bin=0; bin<numberTimeBins; bin++)
+    {
+      alphaTitle =  Form("%s%02i","hAlphaOff",bin);
+      hAlpha_off_abs_timebin = new TH1F (alphaTitle,"",nbins_abs,minalpha_abs,maxalpha_abs);;
+      alphaHistoOff.AddLast(hAlpha_off_abs_timebin);
+      //      cout << "hAlpha_off_abs_timebin " << hAlpha_off_abs_timebin <<  " alphaHistoOff [" << bin << "] " << alphaHistoOff[bin] << endl;
+
+      srcposTitle =  Form("%s%02i","hSrcPosOff",bin);
+      hSrcPos_off_timebin = new TH2F (srcposTitle,"",nbins_srcpos,minsrcpos,maxsrcpos,nbins_srcpos,minsrcpos,maxsrcpos);
+      srcposHistoOff.AddLast(hSrcPos_off_timebin);
+      //      cout << "hSrcPos_off_timebin " << hSrcPos_off_timebin <<  " srcposHistoOff [" << bin << "] " << srcposHistoOff[bin] << endl;
+    }
+
+  // 
+  // Make a loop only for the OFF data:
+  //
+  
+  MParList plist_off;
+  MTaskList tlist_off;
+  plist_off.AddToList(&tlist_off);
+  
+  MRawRunHeader runheader_off;
+  MRawEvtHeader evtheader_off;
+  MTime              time_off;
+  MLiveTime      livetime_off;
+  MHillas          hillas_off;
+  MHillasSrc    hillassrc_off;
+  MSrcPosCam       srcpos_off;
+  MReportDrive      drive_off;
+  
+  plist_off.AddToList(&geomcam);
+  plist_off.AddToList(&runheader_off);
+  plist_off.AddToList(&evtheader_off);
+  plist_off.AddToList(&time_off);
+  plist_off.AddToList(&livetime_off);
+  plist_off.AddToList(&hillas_off);
+  plist_off.AddToList(&hillassrc_off);
+  plist_off.AddToList(&srcpos_off);
+  plist_off.AddToList(&drive_off);
+
+  TH1F *hSize_off      = new TH1F ("hSizeOff","",nbins_Size,min_Size,max_Size);
+  TH1F *hWidth_off     = new TH1F ("hWidthOff","",nbins_Width,min_Width,max_Width);
+  TH1F *hLength_off    = new TH1F ("hLengthOff","",nbins_Length,min_Length,max_Length);
+  TH1F *hDist_off      = new TH1F ("hDistOff","",nbins_Dist,min_Dist,max_Dist);
+  TH1F *hAlpha_off_abs = new TH1F ("hAbsAlphaOff","",nbins_abs,minalpha_abs,maxalpha_abs);
+  TH1F *hAlpha_off     = new TH1F ("hAlphaOff","",nbins,minalpha,maxalpha);
+  TH2F *hSrcPos_off    = new TH2F ("hSrcPosOff","",nbins_srcpos,minsrcpos,maxsrcpos,nbins_srcpos,minsrcpos,maxsrcpos);
+
+  //tasks
+  MReadTree read_off("Parameters", f_off_name);
+  read_off.DisableAutoScheme();
+
+  // taks to set the src position in the off data for the time bins
+  // --------------------------------------------------------------
+  MSrcPlace srcplace_timebin;
+  srcplace_timebin.SetCreateHisto(kFALSE);
+  srcplace_timebin.SetMode(MSrcPlace::kOff);
+  // --------------------------------------------------------------
+
+  //  srcplace.SetMode(MSrcPlace::kOff);
+  
+  MHillasSrcCalc csrc_off;
+  
+  MLiveTimeCalc livetimecalc_off;
+
+ //tasklist
+  tlist_off.AddToList(&read_off);
+  tlist_off.AddToList(&livetimecalc_off);
+  tlist_off.AddToList(&srcplace_timebin); // This is just to run the preprocess correctely
+  tlist_off.AddToList(&csrc_off); // This is just to run the preprocess correctely
+  
+  // Create and setup the eventloop
+  MEvtLoop loop_off;
+  loop_off.SetParList(&plist_off);
+  //loop_off.SetDisplay(display);
+  
+//   MProgressBar bar_off;
+//   loop_off.SetProgressBar(&bar_off);
+  
+//   if (!loop_off.Eventloop(numEntries))
+//     return;
+  
+  if (!loop_off.PreProcess())
+    return;
+
+  while(tlist_off.Process())
+    {
+
+      //First read the variables source(i.e. time bin) independent
+      Double_t zenith = drive_off.GetNominalZd();
+
+      Double_t size = hillas_off.GetSize();
+      Double_t width = hillas_off.GetWidth()*geomcam.GetConvMm2Deg();
+      Double_t length = hillas_off.GetLength()*geomcam.GetConvMm2Deg();
+      Double_t meanx = hillas_off.GetMeanX()*geomcam.GetConvMm2Deg();
+      Double_t meany = hillas_off.GetMeanY()*geomcam.GetConvMm2Deg();
+      Double_t centerdist = TMath::Sqrt(meanx*meanx + meany*meany);
+      
+      Int_t sizebin = GetBin(size,numberSizeBins,sizeBins);
+      
+      if (sizebin >= 0)
+	{
+	  if (width > widthmin[sizebin] && width < widthmax[sizebin])
+	    {
+	      if (length > lengthmin[sizebin] && length < lengthmax[sizebin])
+		{
+		  if (centerdist < distmax[sizebin])
+		    {
+		      //General histos
+
+		      srcplace_timebin.SetPositionHisto(hSrcPos_on);
+		      srcplace_timebin.CallProcess();
+		      csrc_off.CallProcess();
+		      
+		      Double_t dist = hillassrc_off.GetDist()*geomcam.GetConvMm2Deg();
+		      Double_t alpha = hillassrc_off.GetAlpha();
+		      Double_t srcposx = srcpos_off.GetX();
+		      Double_t srcposy = srcpos_off.GetY();
+		      
+		      if (dist > distmin[sizebin] )
+			{
+			  hSize_off->Fill(log10(size));
+			  hWidth_off->Fill(width);
+			  hLength_off->Fill(length);
+			  
+			  hDist_off->Fill(dist);
+			  hAlpha_off_abs->Fill(TMath::Abs(alpha));
+			  hAlpha_off->Fill(alpha);
+			  hSrcPos_off->Fill(srcposx,srcposy);
+			}
+		      
+		      // Time bin histos
+		      for (UInt_t bin=0; bin<numberTimeBins; bin++)
+			{
+			  srcplace_timebin.SetPositionHisto((TH2F*)srcposHistoOn[bin]);
+			  srcplace_timebin.CallProcess();
+			  csrc_off.CallProcess();
+			  
+			  dist = hillassrc_off.GetDist()*geomcam.GetConvMm2Deg();
+			  alpha = hillassrc_off.GetAlpha();
+			  srcposx = srcpos_off.GetX();
+			  srcposy = srcpos_off.GetY();
+			  
+			  if (dist > distmin[sizebin])
+			    {
+			      ((TH1F*)alphaHistoOff[bin])->Fill(TMath::Abs(alpha));
+			      ((TH2F*)srcposHistoOff[bin])->Fill(srcposx,srcposy);
+			    }
+			}
+		    }
+		}
+	    }
+	}
+    }
+  
+  loop_off.PostProcess();
+
+  tlist_off.PrintStatistics();
+
+  TArrayD meanTimeBinOnInSec(numberTimeBins);
+  TArrayD widthTimeBinOnInSec(numberTimeBins);
+  
+  TArrayD meanTriggerRateOn(numberTimeBins);
+  TArrayD errorMeanTriggerRateOn(numberTimeBins);
+
+  for (UInt_t bin=0; bin<numberTimeBins; bin++)
+    {
+      cout.precision(5);
+      cout << bin << " timeOn " << timeOn[bin] << " mean-width time " << meanTimeBinOn[bin] << "-" << widthTimeBinOn[bin] << endl;
+    }
+  livetime_off.Print("last");
+  livetime_off.Print("all");
+  cout << "livetime_off.GetLiveTime() " << livetime_off.GetLiveTime() << endl;
+
+  for (UInt_t bin=0; bin<numberTimeBins; bin++)
+    {
+      timeOff[bin] = livetime_off.GetLiveTime();
+
+      //
+      meanTriggerRateOn[bin] = numberOnEventsAfterCleaning[bin]/timeOn[bin];
+      errorMeanTriggerRateOn[bin] = TMath::Sqrt(numberOnEventsAfterCleaning[bin])/timeOn[bin];
+
+      meanTimeBinOnInSec[bin]  = (meanTimeBinOn[bin]-(Int_t)meanTimeBinOn[bin]);
+      if (meanTimeBinOnInSec[bin] > 0.5)
+	meanTimeBinOnInSec[bin] = meanTimeBinOnInSec[bin] - 1 ;
+      meanTimeBinOnInSec[bin] *= kDay;
+
+      widthTimeBinOnInSec[bin] = widthTimeBinOn[bin]*kDay;
+
+      numberOffEvents[bin] = (Double_t) ((TH1F*)alphaHistoOff[bin])->Integral((Int_t)sigexccmin*nbins_abs/90+1,(Int_t)sigexccmax*nbins_abs/90);
+      numberBkgEventsToNormOff[bin] =  (Double_t) ((TH1F*)alphaHistoOff[bin])->Integral((Int_t)bkgnormmin*nbins_abs/90+1,(Int_t)bkgnormmax*nbins_abs/90);
+      if (numberOffEvents[bin] != 0 && numberBkgEventsToNormOff[bin] != 0)
+	{
+	  onOffNormFactorWithEvents[bin] = numberBkgEventsToNormOn[bin]/numberBkgEventsToNormOff[bin];
+	  onOffNormFactorWithLiveTime[bin] = timeOn[bin]/timeOff[bin];
+	  onOffNormFactor[bin] = onOffNormFactorWithEvents[bin];
+	  numberExcessEvents[bin] = numberOnEvents[bin] - onOffNormFactor[bin]*numberOffEvents[bin];
+	  errorNumberExcessEvents[bin] = TMath::Sqrt(numberOnEvents[bin] + onOffNormFactor[bin]*onOffNormFactor[bin]*numberOffEvents[bin]);
+	  numberExcessEventsPerSec[bin] = numberExcessEvents[bin]/timeOn[bin]*(deadFractionOn[bin]>1.?deadFractionOn[bin]:1.);
+	  errorNumberExcessEventsPerSec[bin] = errorNumberExcessEvents[bin]/timeOn[bin];
+	  numberExcessEventsPerMin[bin] = 60.*numberExcessEvents[bin]/timeOn[bin]*(deadFractionOn[bin]>1.?deadFractionOn[bin]:1.);
+	  errorNumberExcessEventsPerMin[bin] = 60.*errorNumberExcessEvents[bin]/timeOn[bin];
+
+	}
+    }
+  
+  for (UInt_t bin=0; bin<numberTimeBins; bin++)
+    {
+      cout.precision(5);
+      cout << bin << " timeOn " << timeOn[bin] << " mean-width time " << meanTimeBinOnInSec[bin] << "-" << widthTimeBinOnInSec[bin] << endl;
+      cout << " numberOnEvents\t " << numberOnEvents[bin] << endl;
+      cout << " numberOffEvents\t " << numberOffEvents[bin] << endl;
+      cout << " numberBkgEventsToNormOn\t " << numberBkgEventsToNormOn[bin] << endl;
+      cout << " numberBkgEventsToNormOff\t " << numberBkgEventsToNormOff[bin] << endl;
+      cout << " onOffNormFactorWithEvents\t " << onOffNormFactorWithEvents[bin] << endl;
+      cout << " onOffNormFactorWithLiveTime\t " << onOffNormFactorWithLiveTime[bin] << endl;
+      cout << " numberExcessEvents\t " <<  numberExcessEvents[bin] <<  " +- " << errorNumberExcessEvents[bin] << endl;
+      cout << " deadFraction\t" << deadFractionOn[bin] << endl;
+      cout << " Excess/Sec\t " << numberExcessEventsPerSec[bin] << " +- " << errorNumberExcessEventsPerSec[bin] << endl;
+      cout << " Trigger Rate\t " << meanTriggerRateOn[bin] << " +- " << errorMeanTriggerRateOn[bin] << endl;
+    }
+
+  
+
+  TString openpsname = psname + "(";
+  TString closepsname = psname + ")";
+
+  TCanvas *c0 = new TCanvas;
+  c0->cd(1);
+  TGraphErrors* lightcurvegraph = new TGraphErrors(numberTimeBins,meanTimeBinOnInSec.GetArray(),numberExcessEventsPerMin.GetArray(),widthTimeBinOnInSec.GetArray(),errorNumberExcessEventsPerMin.GetArray());
+  lightcurvegraph->SetTitle("LightCurve");
+  lightcurvegraph->SetMinimum(0.);
+  lightcurvegraph->SetMarkerStyle(21);
+  lightcurvegraph->SetMarkerSize(0.03);
+  lightcurvegraph->Draw("AP");
+  lightcurvegraph->GetYaxis()->SetTitle("Excess/min");
+  lightcurvegraph->GetXaxis()->SetTitle("UTC Time");
+  lightcurvegraph->GetXaxis()->SetTimeDisplay(1);
+  c0->Print(openpsname);
+      
+  TCanvas *c00 = new TCanvas;
+  c00->cd(1);
+  TGraphErrors* cosmicrategraph = new TGraphErrors(numberTimeBins,meanTimeBinOnInSec.GetArray(),meanTriggerRateOn.GetArray(),widthTimeBinOnInSec.GetArray(),errorMeanTriggerRateOn.GetArray());
+  cosmicrategraph->SetTitle("Cosmic Rate");
+  cosmicrategraph->SetMarkerStyle(21);
+  cosmicrategraph->SetMarkerSize(0.03);
+  cosmicrategraph->Draw("AP");
+  cosmicrategraph->GetYaxis()->SetTitle("[Hz]");
+  cosmicrategraph->GetXaxis()->SetTitle("UTC Time");
+  cosmicrategraph->GetXaxis()->SetTimeDisplay(1);
+  c00->Print(psname);
+
+  TCanvas** c = new TCanvas*[numberTimeBins];
+  
+  //Compute the maximum of all hAlphaOn histograms
+  Float_t maxAlphaHistoHeight = 0;
+  
+  for (UInt_t bin=0; bin<numberTimeBins; bin++)
+    {
+      for (UInt_t i=1; i<=nbins_abs; i++)
+	if (((TH1F*)alphaHistoOn[bin])->GetBinContent(i) > maxAlphaHistoHeight)
+	  maxAlphaHistoHeight = ((TH1F*)alphaHistoOn[bin])->GetBinContent(i);
+    }      
+  
+  cout << "maxAlphaHistoHeight " << maxAlphaHistoHeight << endl;
+
+  for (UInt_t bin=0; bin<numberTimeBins-1; bin++)
+    {
+      c[bin] = new TCanvas;
+      c[bin]->cd(1);
+      
+      ((TH1F*)alphaHistoOn[bin])->Sumw2();
+      ((TH1F*)alphaHistoOff[bin])->SetStats(0);
+      ((TH1F*)alphaHistoOff[bin])->Sumw2();
+      ((TH1F*)alphaHistoOff[bin])->Scale(onOffNormFactor[bin]); 
+      ((TH1F*)alphaHistoOn[bin])->SetStats(0); //-> Do NOT show the legend with statistics
+      ((TH1F*)alphaHistoOn[bin])->SetLineColor(kBlack);
+      ((TH1F*)alphaHistoOn[bin])->SetMarkerStyle(21);
+      ((TH1F*)alphaHistoOn[bin])->SetMarkerColor(kBlack);
+      ((TH1F*)alphaHistoOn[bin])->SetMarkerSize(0.7);
+      ((TH1F*)alphaHistoOff[bin])->SetFillColor(46);
+      ((TH1F*)alphaHistoOff[bin])->SetLineColor(46);
+      ((TH1F*)alphaHistoOff[bin])->SetFillStyle(3004); //(1001)-> To set the pad NOT transparent and solid; (3004)-> pattern lines
+      ((TH1F*)alphaHistoOn[bin])->SetMaximum(maxAlphaHistoHeight*1.2);
+      ((TH1F*)alphaHistoOff[bin])->SetMinimum(0.);
+      alphaTitle =  Form("%s%02i","hAlphaOnOff",bin);
+      ((TH1F*)alphaHistoOn[bin])->SetTitle(alphaTitle);
+      
+      
+      ((TH1F*)alphaHistoOn[bin])->DrawCopy("E1P");
+      ((TH1F*)alphaHistoOff[bin])->DrawCopy("HISTSAME");
+      ((TH1F*)alphaHistoOff[bin])->DrawCopy("ESAME");
+      ((TH1F*)alphaHistoOn[bin])->DrawCopy("E1PSAME");
+
+      c[bin]->Print(psname);
+    }
+
+  c[numberTimeBins-1] = new TCanvas;
+  c[numberTimeBins-1]->cd(1);
+  
+  ((TH1F*)alphaHistoOn[numberTimeBins-1])->Sumw2();
+  ((TH1F*)alphaHistoOff[numberTimeBins-1])->SetStats(0);
+  ((TH1F*)alphaHistoOff[numberTimeBins-1])->Sumw2();
+  ((TH1F*)alphaHistoOff[numberTimeBins-1])->Scale(onOffNormFactor[numberTimeBins-1]); 
+  ((TH1F*)alphaHistoOn[numberTimeBins-1])->SetStats(0); //-> Do NOT show the legend with statistics
+  ((TH1F*)alphaHistoOn[numberTimeBins-1])->SetLineColor(kBlack);
+  ((TH1F*)alphaHistoOn[numberTimeBins-1])->SetMarkerStyle(21);
+  ((TH1F*)alphaHistoOn[numberTimeBins-1])->SetMarkerColor(kBlack);
+  ((TH1F*)alphaHistoOn[numberTimeBins-1])->SetMarkerSize(0.7);
+  ((TH1F*)alphaHistoOff[numberTimeBins-1])->SetFillColor(46);
+  ((TH1F*)alphaHistoOff[numberTimeBins-1])->SetLineColor(46);
+  ((TH1F*)alphaHistoOff[numberTimeBins-1])->SetFillStyle(3004); //(1001)-> To set the pad NOT transparent and solid; (3004)-> pattern lines
+  ((TH1F*)alphaHistoOn[numberTimeBins-1])->SetMaximum(maxAlphaHistoHeight*1.2);
+  ((TH1F*)alphaHistoOff[numberTimeBins-1])->SetMinimum(0.);
+  alphaTitle =  Form("%s%02i","hAlphaOnOff",numberTimeBins-1);
+  ((TH1F*)alphaHistoOn[numberTimeBins-1])->SetTitle(alphaTitle);
+  
+  
+  ((TH1F*)alphaHistoOn[numberTimeBins-1])->DrawCopy("E1P");
+  ((TH1F*)alphaHistoOff[numberTimeBins-1])->DrawCopy("HISTSAME");
+  ((TH1F*)alphaHistoOff[numberTimeBins-1])->DrawCopy("ESAME");
+  ((TH1F*)alphaHistoOn[numberTimeBins-1])->DrawCopy("E1PSAME");
+  
+  c[numberTimeBins-1]->Print(psname);
+
+  //  TString rootname = psname.ReplaceAll(".ps",".root");
+  TString rootname = "./prueba.root";
+  TFile input(rootname, "RECREATE");
+
+   for (UInt_t bin=0; bin<numberTimeBins; bin++)
+     {
+       ((TH1F*)alphaHistoOn[bin])->Write();
+       ((TH2F*)srcposHistoOn[bin])->Write();
+       ((TH1F*)coszenithHistoOn[bin])->Write();
+       ((TH1F*)timediffHistoOn[bin])->Write();
+       ((TH1F*)alphaHistoOff[bin])->Write();
+       ((TH2F*)srcposHistoOff[bin])->Write();
+    }
+  
+  input.Close();
+
+  // ############################################################################
+  // Calculate significance and excess: 
+  // ############################################################################
+
+  Double_t norm_on_abs  = (Double_t) hAlpha_on_abs->Integral((Int_t)bkgnormmin*nbins_abs/90+1,(Int_t)bkgnormmax*nbins_abs/90);
+  Double_t exces_on_abs = (Double_t) hAlpha_on_abs->Integral((Int_t)sigexccmin*nbins_abs/90+1,(Int_t)sigexccmax*nbins_abs/90);
+  Double_t norm_off_abs  = (Double_t) hAlpha_off_abs->Integral((Int_t)bkgnormmin*nbins_abs/90+1,(Int_t)bkgnormmax*nbins_abs/90);
+  Double_t exces_off_abs = (Double_t) hAlpha_off_abs->Integral((Int_t)sigexccmin*nbins_abs/90+1,(Int_t)sigexccmax*nbins_abs/90);
+  Double_t norm = norm_on_abs/norm_off_abs;
+
+  char text_tit_alpha[256];
+  sprintf(text_tit_alpha, " Alpha Plot On and Off ");
+  hAlpha_off_abs->SetTitle(text_tit_alpha);
+  hAlpha_on_abs->SetTitle(text_tit_alpha);
+
+  Double_t excess  = exces_on_abs - exces_off_abs*norm;
+  Double_t sign    = excess / sqrt( exces_on_abs + norm*norm*exces_off_abs );
+  Double_t int_off = (Double_t) hAlpha_off_abs->Integral(1, 18);
+  int hAlpha_on_entries  = (int) hAlpha_on_abs->GetEntries();
+  int hAlpha_off_entries = (int) hAlpha_off_abs->GetEntries();
+    
+  cout << "---> Normalization F factor =\t" << norm <<endl;
+  cout << "---> Excess =\t\t\t" << excess <<endl;
+  cout << "---> Significancia =\t\t" << sign <<endl;    
+  cout << "---> entries on   =\t\t" << hAlpha_on_entries  <<endl;
+  cout << "---> entries off  =\t\t" << hAlpha_off_entries <<endl;
+  cout << "---> integral off =\t\t" << int_off <<endl;
+
+  Double_t shiftx;
+
+  // ############################################################################
+  // Draw SIZE
+  // ############################################################################
+  TCanvas *c1 = new TCanvas;
+
+  gPad->cd();
+
+  gPad->SetLogy();
+  hSize_on->Sumw2();
+  hSize_off->Sumw2();
+  hSize_off->Scale(norm); 
+  hSize_on->SetLineColor(kBlack);
+  hSize_on->SetMarkerStyle(21);
+  hSize_on->SetMarkerSize(0.7);
+  hSize_on->SetMarkerColor(kBlack);
+  hSize_off->SetFillColor(46);
+  hSize_off->SetLineColor(46);
+  hSize_off->SetFillStyle(3004); //(1001)-> To set the pad NOT transparent and solid; (3004)-> pattern lines
+  hSize_off->SetMinimum(0.1);
+  hSize_on->SetMinimum(0.1);
+  hSize_on->SetTitle("SIZE distribution");
+  hSize_off->SetTitle("SIZE distribution");
+
+  hSize_on->DrawCopy("E1P");
+
+  // move stat box to make them all visible
+  gPad->Update();
+  TPaveStats* pavs_on_size = (TPaveStats*) hSize_on->GetListOfFunctions()->FindObject("stats");
+  if(pavs_on_size){
+    shiftx = pavs_on_size->GetX2NDC() - pavs_on_size->GetX1NDC();
+    pavs_on_size->SetX1NDC(pavs_on_size->GetX1NDC() - shiftx);
+    pavs_on_size->SetX2NDC(pavs_on_size->GetX2NDC() - shiftx);  
+  }
+  gPad->Modified();
+  gPad->Update();
+
+  hSize_off->DrawCopy("HISTSAME");
+  hSize_off->DrawCopy("ESAME");
+
+  gPad->Modified();
+  gPad->Update();
+
+  Double_t chisize = ChiSquareNDof((TH1D*)hSize_on,(TH1D*)hSize_off);
+
+  Double_t x_label_pos  = log10(1000000)*0.7;
+  Double_t y_label_pos  = log10((hSize_on->GetBinContent(hSize_on->GetMaximumBin()))/2.);
+  Double_t textsize = 0.03;
+
+  char text_size[256];
+  sprintf(text_size,"ChiSquare/NDof = %4.2f",chisize);
+
+  TLatex *tsize = new TLatex(x_label_pos, y_label_pos, text_size);
+  tsize->SetTextSize(textsize);
+//  tsize->Draw();
+
+  gPad->Modified();
+  gPad->Update();
+
+  c1->Print(psname);
+
+  // ############################################################################
+  // DrawCopy DIST
+  // ############################################################################
+  TCanvas *c2 = new TCanvas;
+
+  gPad->cd();
+
+  hDist_on->Sumw2();
+  hDist_off->Sumw2();
+  hDist_off->Scale(norm); 
+  hDist_on->SetLineColor(kBlack);
+  hDist_on->SetMarkerStyle(21);
+  hDist_on->SetMarkerSize(0.7);
+  hDist_on->SetMarkerColor(kBlack);
+  hDist_off->SetFillColor(46);
+  hDist_off->SetLineColor(46);
+  hDist_off->SetFillStyle(3004); //(1001)-> To set the pad NOT transparent and solid; (3004)-> pattern lines
+  hDist_off->SetMinimum(0.);
+  hDist_on->SetTitle("DIST distribution");
+  hDist_off->SetTitle("DIST distribution");
+
+  hDist_on->DrawCopy("E1P");
+
+  // move stat box to make them all visible
+  gPad->Update();
+  TPaveStats* pavs_on_dist = (TPaveStats*) hDist_on->GetListOfFunctions()->FindObject("stats");
+  if(pavs_on_dist){
+    shiftx = pavs_on_dist->GetX2NDC() - pavs_on_dist->GetX1NDC();
+    pavs_on_dist->SetX1NDC(pavs_on_dist->GetX1NDC() - shiftx);
+    pavs_on_dist->SetX2NDC(pavs_on_dist->GetX2NDC() - shiftx);  
+  }
+  gPad->Modified();
+  gPad->Update();
+
+  hDist_off->DrawCopy("HISTSAME");
+  hDist_off->DrawCopy("ESAME");
+  hDist_on->DrawCopy("E1PSAME");
+
+  Double_t chidist = ChiSquareNDof((TH1D*)hDist_on,(TH1D*)hDist_off);
+
+  x_label_pos  = distmax[numberSizeBins-1]*0.7;
+  y_label_pos  = hDist_on->GetBinContent(hDist_on->GetMaximumBin())/2.;
+
+  char text_dist[256];
+  sprintf(text_size,"ChiSquare/NDof = %4.2f",chidist);
+
+  TLatex *tdist = new TLatex(x_label_pos, y_label_pos, text_dist);
+  tdist->SetTextSize(textsize);
+//  tdist->Draw();
+
+  gPad->Modified();
+  gPad->Update();
+
+  c2->Print(psname);
+
+   // ############################################################################
+  // DrawCopy WIDTH
+  // ############################################################################
+  TCanvas *c3 = new TCanvas;
+
+  gPad->cd();
+
+  hWidth_off->Sumw2();
+  hWidth_off->Scale(norm); 
+  hWidth_on->SetLineColor(kBlack);
+  hWidth_on->SetMarkerStyle(21);
+  hWidth_on->SetMarkerSize(0.7);
+  hWidth_on->SetMarkerColor(kBlack);
+  hWidth_off->SetFillColor(46);
+  hWidth_off->SetLineColor(46);
+  hWidth_off->SetFillStyle(3004); //(1001)-> To set the pad NOT transparent and solid; (3004)-> pattern lines
+  hWidth_off->SetMinimum(0.);
+  hWidth_on->SetTitle("WIDTH distribution");
+  hWidth_off->SetTitle("WIDTH distribution");
+
+  hWidth_on->DrawCopy("E1P");
+
+  // move stat box to make them all visible
+  gPad->Update();
+  TPaveStats* pavs_on_width = (TPaveStats*) hWidth_on->GetListOfFunctions()->FindObject("stats");
+  if(pavs_on_width){
+    shiftx = pavs_on_width->GetX2NDC() - pavs_on_width->GetX1NDC();
+    pavs_on_width->SetX1NDC(pavs_on_width->GetX1NDC() - shiftx);
+    pavs_on_width->SetX2NDC(pavs_on_width->GetX2NDC() - shiftx);  
+  }
+  gPad->Modified();
+  gPad->Update();
+
+  hWidth_off->DrawCopy("HISTSAME");
+  hWidth_off->DrawCopy("ESAME");
+  hWidth_on->DrawCopy("E1PSAME");
+
+  Double_t chiwidth = ChiSquareNDof((TH1D*)hWidth_on,(TH1D*)hWidth_off);
+
+  x_label_pos  = widthmax[numberSizeBins-1]*0.7;
+  y_label_pos  = hWidth_on->GetBinContent(hWidth_on->GetMaximumBin())/2.;
+
+  char text_width[256];
+  sprintf(text_size,"ChiSquare/NDof = %4.2f",chiwidth);
+
+  TLatex *twidth = new TLatex(x_label_pos, y_label_pos, text_width);
+  twidth->SetTextSize(textsize);
+//  twidth->Draw();
+
+  gPad->Modified();
+  gPad->Update();
+ 
+  c3->Print(psname);
+
+  // ############################################################################
+  // DrawCopy LENGTH
+  // ############################################################################
+  TCanvas *c4 = new TCanvas;
+ 
+  gPad->cd();
+
+  hLength_on->Sumw2();
+  hLength_off->Sumw2();
+  hLength_off->Scale(norm); 
+  hLength_on->SetLineColor(kBlack);
+  hLength_on->SetMarkerStyle(21);
+  hLength_on->SetMarkerSize(0.7);
+  hLength_on->SetMarkerColor(kBlack);
+  hLength_off->SetFillColor(46);
+  hLength_off->SetLineColor(46);
+  hLength_off->SetFillStyle(3004); //(1001)-> To set the pad NOT transparent and solid; (3004)-> pattern lines
+  hLength_off->SetMinimum(0.);
+  hLength_on->SetTitle("LENGTH distribution");
+  hLength_off->SetTitle("LENGTH distribution");
+
+  hLength_on->DrawCopy("E1P");
+
+  // move stat box to make them all visible
+  gPad->Update();
+  TPaveStats* pavs_on_length = (TPaveStats*) hLength_on->GetListOfFunctions()->FindObject("stats");
+  if(pavs_on_length){
+    shiftx = pavs_on_length->GetX2NDC() - pavs_on_length->GetX1NDC();
+    pavs_on_length->SetX1NDC(pavs_on_length->GetX1NDC() - shiftx);
+    pavs_on_length->SetX2NDC(pavs_on_length->GetX2NDC() - shiftx);  
+  }
+  gPad->Modified();
+  gPad->Update();
+
+  hLength_off->DrawCopy("HISTSAME");
+  hLength_off->DrawCopy("ESAME");
+  hLength_on->DrawCopy("E1PSAME");
+
+  Double_t chilength = ChiSquareNDof((TH1D*)hLength_on,(TH1D*)hLength_off);
+
+  x_label_pos  = lengthmax[numberSizeBins-1]*0.7;
+  y_label_pos  = hLength_on->GetBinContent(hLength_on->GetMaximumBin())/2.;
+
+  char text_length[256];
+  sprintf(text_size,"ChiSquare/NDof = %4.2f",chilength);
+
+  TLatex *tlength = new TLatex(x_label_pos, y_label_pos, text_length);
+  tlength->SetTextSize(textsize);
+//  tlength->Draw();
+
+  gPad->Modified();
+  gPad->Update();
+
+  c4->Print(psname);
+
+ // ############################################################################
+  // DrawCopy normalized ALPHA plot
+  // ############################################################################
+  TCanvas *c5 = new TCanvas;
+  
+  gPad->cd();
+
+  hAlpha_on_abs->Sumw2();
+  hAlpha_off_abs->SetStats(0);
+  hAlpha_off_abs->Sumw2();
+  hAlpha_off_abs->Scale(norm); 
+  hAlpha_on_abs->SetStats(0); //-> Do NOT show the legend with statistics
+  hAlpha_on_abs->SetLineColor(kBlack);
+  hAlpha_on_abs->SetMarkerStyle(21);
+  //hAlpha_on_abs->SetMarkerSize();
+  hAlpha_on_abs->SetMarkerColor(kBlack);
+  hAlpha_on_abs->SetMarkerSize(0.7);
+  hAlpha_off_abs->SetFillColor(46);
+  hAlpha_off_abs->SetLineColor(46);
+  hAlpha_off_abs->SetFillStyle(3004); //(1001)-> To set the pad NOT transparent and solid; (3004)-> pattern lines
+  hAlpha_off_abs->SetMinimum(0.);
+  hAlpha_on_abs->SetTitle("Alpha plot");
+  hAlpha_off_abs->SetTitle("Alpha plot");
+
+  
+  hAlpha_on_abs->DrawCopy("E1P");
+  hAlpha_off_abs->DrawCopy("HISTSAME");
+  hAlpha_off_abs->DrawCopy("ESAME");
+  hAlpha_on_abs->DrawCopy("E1PSAME");
+
+
+   //draw the LEGEND with excess and significance values in the alpha plot:
+  char text_Fnorm[256], text_excess[256], text_sign[256];
+  char text_entries_on[256], text_entries_off[256], text_integral_off[256];
+  int hAlpha_on_entries  = (int) hAlpha_on_abs->GetEntries();
+  int hAlpha_off_entries = (int) hAlpha_off_abs->GetEntries();
+  sprintf(text_Fnorm,       " F norm =       %.3f", norm);
+  sprintf(text_excess,      " Excess =       %.3f", excess);
+  sprintf(text_sign,        " Significance = %.3f", sign);
+  sprintf(text_entries_on,  " Entries ON   = %d",  hAlpha_on_entries);
+  sprintf(text_entries_off, " Entries OFF  = %d",  hAlpha_off_entries);
+  sprintf(text_integral_off," Integral OFF = %d",  int_off);
+  
+  x_label_pos  = 90.*0.7;
+  y_label_pos  = (hAlpha_on_abs->GetBinContent(hAlpha_on_abs->GetMaximumBin())); //2.;
+  Double_t y_label_step = y_label_pos / 8.;
+
+  TLatex *t0 = new TLatex(x_label_pos, y_label_pos - y_label_step*0, text_Fnorm);
+  t0->SetTextSize(textsize);
+  t0->Draw();
+  TLatex *t1 = new TLatex(x_label_pos, y_label_pos - y_label_step*1, text_excess);
+  t1->SetTextSize(textsize);
+  t1->Draw();
+  TLatex *t2 = new TLatex(x_label_pos, y_label_pos - y_label_step*2, text_sign);
+  t2->SetTextSize(textsize);
+  t2->Draw();
+  TLatex *t3 = new TLatex(x_label_pos, y_label_pos - y_label_step*3, text_entries_on);
+  t3->SetTextSize(textsize);
+  t3->Draw();
+  TLatex *t4 = new TLatex(x_label_pos, y_label_pos - y_label_step*4, text_entries_off);
+  t4->SetTextSize(textsize);
+  t4->Draw();
+  TLatex *t5 = new TLatex(x_label_pos, y_label_pos - y_label_step*5, text_integral_off);
+  t5->SetTextSize(textsize);
+  t5->Draw();
+  
+
+  Double_t chialpha = ChiSquareNDof((TH1D*)hAlpha_on_abs,(TH1D*)hAlpha_off_abs);
+
+  y_label_pos  = (hAlpha_on_abs->GetBinContent(hAlpha_on_abs->GetMaximumBin()))/2.;
+
+  char text_alpha[256];
+  sprintf(text_size,"ChiSquare/NDof = %4.2f",chialpha);
+
+  TLatex *talpha = new TLatex(x_label_pos, y_label_pos, text_alpha);
+  talpha->SetTextSize(textsize);
+//  talpha->Draw();
+
+  gPad->Modified();
+  gPad->Update();
+
+  c5->Print(psname);
+
+  // ############################################################################
+  // DrawCopy normalized alpha histos for alpha form -90 to 90 deg.
+  // ############################################################################
+  TCanvas *c6 = new TCanvas;
+
+  gPad->cd();
+
+  hAlpha_on->Sumw2();
+  hAlpha_off->SetStats(0);
+  hAlpha_off->Sumw2();
+  hAlpha_off->Scale(norm); 
+  hAlpha_off->SetFillColor(46);
+  hAlpha_off->SetLineColor(46);
+  hAlpha_off->SetFillStyle(3004); //(1001)-> To set the pad NOT transparent and solid; (3004)-> pattern lines
+  hAlpha_off->SetMinimum(0.); 
+  hAlpha_on->SetStats(0); //-> Do NOT show the legend with statistics
+  hAlpha_on->SetLineColor(kBlack);
+  hAlpha_on->SetMarkerStyle(21);
+  hAlpha_on->SetMarkerSize(0.7);
+  hAlpha_on->SetMarkerColor(kBlack);
+  hAlpha_on->SetTitle("Alpha plot form -90 to 90 deg");
+  hAlpha_off->SetTitle("Alpha plot form -90 to 90 deg");
+
+  hAlpha_on->DrawCopy("E1P");
+  hAlpha_off->DrawCopy("HISTSAME");
+  hAlpha_off->DrawCopy("ESAME");
+  hAlpha_on->DrawCopy("E1PSAME");
+
+  Double_t chialpha90 = ChiSquareNDof((TH1D*)hAlpha_on,(TH1D*)hAlpha_off);
+
+  x_label_pos  = 90.*0.5;
+  y_label_pos  = hAlpha_on->GetBinContent(hAlpha_on->GetMaximumBin())/2.;
+
+  char text_alpha90[256];
+  sprintf(text_alpha90,"ChiSquare/NDof = %4.2f",chialpha90);
+
+  TLatex *talpha90 = new TLatex(x_label_pos, y_label_pos, text_alpha90);
+  talpha90->SetTextSize(textsize);
+//  talpha90->Draw();
+
+  gPad->Update();
+  gPad->Modified();
+
+  c6->Print(psname);
+
+  cout << "---> ChiSquare/NDof [Size] =\t\t" << chisize << endl;
+  cout << "---> ChiSquare/NDof [Dist] =\t\t" << chidist << endl;
+  cout << "---> ChiSquare/NDof [Width] =\t\t" << chiwidth << endl;
+  cout << "---> ChiSquare/NDof [Length] =\t\t" << chilength << endl;
+  cout << "---> ChiSquare/NDof [Abs(Alpha)] =\t" << chialpha << endl;
+  cout << "---> ChiSquare/NDof [Alpha] =\t\t" << chialpha90 << endl;
+
+
+  TCanvas *c7 = new TCanvas;
+  hSrcPos_on->DrawCopy("BOX");
+  c7->Print(psname);
+
+  TCanvas *c8 = new TCanvas;
+  hSrcPos_off->DrawCopy("BOX");
+  c8->Print(closepsname);
+
+  cout << "Done!!" <<endl;
+  
+}
+
+
+Double_t ChiSquareNDof(TH1D *h1, TH1D *h2)
+{
+    Double_t chiq = 0.;
+    Double_t chi;
+    Double_t error;
+    Int_t nbinsnozero = 0;
+
+    Int_t nbins = h1->GetNbinsX();
+    if (nbins != h2->GetNbinsX() || nbins == 0)
+	return -1;
+
+    for (UInt_t bin=1; bin<=nbins; bin++)
+    {
+	error = sqrt(h1->GetBinError(bin)*h1->GetBinError(bin) +
+			   h2->GetBinError(bin)*h2->GetBinError(bin));
+	if (error != 0)
+	{
+	    chi = (h1->GetBinContent(bin)-h2->GetBinContent(bin))/error;
+	    chiq += chi*chi;
+	    nbinsnozero++;
+	}
+    }
+
+    return (nbinsnozero>0?chiq/nbinsnozero:0);
+}
+
+Int_t GetBin(Double_t size, Int_t numberSizeBins, Double_t sizeBins[])
+{
+
+  Int_t result = -1;
+
+  Int_t lowerbin = 0;
+  Int_t upperbin = numberSizeBins;
+  Int_t bin;
+
+  Int_t count = 0;
+
+  if (size >= sizeBins[0])
+    {
+      while (upperbin - lowerbin > 1 && count++<=numberSizeBins)
+	{
+	  bin = (upperbin+lowerbin)/2;
+	  if (size >= sizeBins[bin])
+	    lowerbin = bin;
+	  else
+	    upperbin = bin;
+	}
+      result = count<=numberSizeBins?lowerbin:-1;
+    }
+
+  return result;
+
+}
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/makeHillas.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/makeHillas.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/makeHillas.C	(revision 9661)
@@ -0,0 +1,558 @@
+/*********************************/
+/* Compute the hillas parameters */
+/*********************************/
+
+Bool_t readDatacards(TString& filename);
+
+// initial and final time slices to be used in signal extraction
+const Byte_t hifirst = 0;
+const Byte_t hilast  = 13;
+const Byte_t lofirst = 3;
+const Byte_t lolast  = 12;
+
+// declaration of variables read from datacards
+TString  outname;
+TString  idirname;
+MRunIter pedcaliter;
+MRunIter caliter;
+MRunIter pediter;
+MRunIter datiter;
+ULong_t  nmaxevents=999999999;
+Short_t  calflag=1;
+Float_t  lcore = 3.0;
+Float_t  ltail = 1.5;
+Int_t islflag = 0;
+Float_t  lnew  = 40;
+Int_t  kmethod = 1;
+Int_t    nfiles = 0;
+
+const TString defaultcard="input.datacard";
+
+//Slow control varialbles
+Short_t slowflag=0;
+Bool_t  isSlowControlAvailable = kFALSE;
+TString hvConfigFile="/mnt/users/jlopez/Mars/Files4Mars/Config/HVSettings_FF35q.conf";
+TString continuosLightFile="/local_disk/rootdata/Miscellaneous/Period016/2004_04_16/dc_2004_04_16_04_46_18_22368_Off3c279-2CL100.root";
+
+
+/*************************************************************/
+int makeHillas(TString datacard = defaultcard)
+{
+
+  if(!datacard.Length())
+    datacard = defaultcard;
+
+  if(!readDatacards(datacard))
+    {
+      cout << "Error reading datacards. Stoping" << endl;
+      return -1;
+    }
+
+  // Set the general tasks/containers
+  MExtractFixedWindow    extractor;
+  extractor.SetRange(hifirst,hilast,lofirst,lolast);
+
+  MCalibrationQECam   qecam;
+  MBadPixelsCam       badcam;
+  MGeomCamMagic       geomcam;
+  MGeomApply          geomapl;
+
+  cout << endl;
+  cout << "/****************************************************/" << endl;
+  cout << "/* FIRST LOOP: PEDESTAL FOR CALIBRATION COMPUTATION */" << endl;
+  cout << "/****************************************************/" << endl;
+  cout << endl;
+
+  // If you want to exclude pixels from the beginning, read 
+  // an ascii-file with the corr. pixel numbers (see MBadPixelsCam)  
+  ifstream fin("badpixels.dat");
+  badcam.AsciiRead(fin);
+  fin.close();
+
+  MJPedestal pedloop0;
+  pedloop0.SetOutputPath("./");
+  pedloop0.SetInput(&pedcaliter);
+  pedloop0.SetExtractor(&extractor);
+  pedloop0.SetBadPixels(badcam);
+
+  if (!pedloop0.Process())
+    return;
+
+  cout << endl;
+  cout << "/*****************************/" << endl;
+  cout << "/* SECOND LOOP: CALIBRATION  */" << endl;
+  cout << "/*****************************/" << endl;        
+  cout << endl;
+
+  MJCalibration calloop;
+
+  calloop.SetOutputPath("./");
+  calloop.SetExtractor(&extractor);
+  calloop.SetInput(&caliter);
+  calloop.SetQECam(qecam);
+  calloop.SetBadPixels(pedloop0.GetBadPixels());
+  if (!calloop.Process(pedloop0.GetPedestalCam()))
+    return;
+
+  cout << endl;
+  cout << "/*************************************************/" << endl;
+  cout << "/* THIRD LOOP: PEDESTAL CALIBRATION INTO PHOTONS */" << endl;
+  cout << "/*************************************************/" << endl;
+  cout << endl;
+
+  // First Compute the pedestals
+  MJPedestal pedloop;
+  pedloop.SetOutputPath("./");
+  pedloop.SetInput(&pediter);
+
+  if (!pedloop.Process())
+    return;
+
+  MPedestalCam pedcam = pedloop.GetPedestalCam();
+
+  // Now convert this pedestals in photons
+  MParList  plist3;
+  MTaskList tlist3;
+  plist3.AddToList(&tlist3);
+  
+  // containers
+  MCerPhotEvt         nphot;
+  MPedPhotCam         nphotrms;
+  MExtractedSignalCam sigcam;
+
+  plist3.AddToList(&geomcam);
+  plist3.AddToList(&pedcam);
+  plist3.AddToList(&calloop.GetCalibrationCam());
+  plist3.AddToList(&qecam);
+  plist3.AddToList(&badcam);
+  plist3.AddToList(&sigcam);
+  plist3.AddToList(&nphot);
+  plist3.AddToList(&nphotrms);
+
+  
+  MCalibrate::CalibrationMode_t calMode=MCalibrate::kDefault;  
+  if(calflag==0)
+    calMode=MCalibrate::kNone;
+  if(calflag==-1)
+    calMode=MCalibrate::kDummy;
+
+  //tasks
+  MReadMarsFile read3("Events");
+  static_cast<MRead&>(read3).AddFiles(pediter); 
+  read3.DisableAutoScheme();
+ 
+//   MReadReports read3;
+//   read3.AddTree("Events","MTime.",kFALSE);
+//   static_cast<MRead&>(read3).AddFiles(pediter); 
+
+   //  MExtractSignal  extsig;
+  //  extsig.SetRange(hifirst,hilast,lofirst,lolast);
+  MCalibrate      photcalc(calMode);
+  MPedPhotCalc    photrmscalc; 
+  
+  tlist3.AddToList(&read3);
+  tlist3.AddToList(&geomapl);
+  tlist3.AddToList(&extractor);
+  tlist3.AddToList(&photcalc);
+  tlist3.AddToList(&photrmscalc);
+
+  // Create and setup the eventloop
+  MEvtLoop evtloop3;
+  evtloop3.SetParList(&plist3);
+  if (!evtloop3.Eventloop())
+    return;
+  
+  tlist3.PrintStatistics();
+
+  cout << "/**********************************************/" << endl;
+  cout << "/* FOURTH LOOP: DATA CALIBRATION INTO PHOTONS */" << endl;
+  cout << "/**********************************************/" << endl;
+
+  MParList  plist4;
+  MTaskList tlist4;
+  plist4.AddToList(&tlist4);
+  
+  // containers 
+  MHillas       hillas;
+  MSrcPosCam    source;
+  MRawRunHeader runhead;
+
+  MArrivalTimeCam   timecam;
+     
+  MIslands      isl;
+  isl.SetName("MIslands1");
+  
+  MIslands      isl2;
+  isl2.SetName("MIslands2");
+
+  MReportDrive  drive;
+  MStarLocalCam starcam;
+
+  if (islflag == 1 || islflag == 2)
+    {
+      plist4.AddToList(&timecam);
+      plist4.AddToList(&isl);
+    }
+  
+  if (islflag == 2)
+    {
+      plist4.AddToList(&isl2);
+    }
+
+  if (isSlowControlAvailable)
+    {
+      plist4.AddToList(&starcam);
+    }
+  
+  
+  plist4.AddToList(&geomcam);
+  plist4.AddToList(&pedcam);
+  plist4.AddToList(&calloop.GetCalibrationCam());
+  plist4.AddToList(&qecam);
+  plist4.AddToList(&badcam);
+  plist4.AddToList(&nphot);
+  plist4.AddToList(&nphotrms);
+  plist4.AddToList(&source);
+  plist4.AddToList(&hillas);
+  plist4.AddToList(&runhead);
+  
+  //tasks
+//   MReadMarsFile read4("Events");
+//   static_cast<MRead&>(read4).AddFiles(datiter); 
+//   read4.DisableAutoScheme();
+
+  MReadReports read4;
+  read4.AddTree("Events","MTime.",kTRUE);
+  read4.AddTree("Currents");
+  read4.AddTree("Camera");
+  read4.AddTree("Drive");
+  static_cast<MRead&>(read4).AddFiles(datiter); 
+  read4.AddToBranchList("MReportCurrents.*");
+
+  // Task that use Slow control information 
+  MFHVNotNominal fhvnotnominal;
+  fhvnotnominal.SetHVNominalValues(hvConfigFile);
+  fhvnotnominal.SetMaxNumPixelsDeviated(40);
+ 
+  MContinue hvnotnominal(&fhvnotnominal);
+
+  MCalibrateDC dccalib;
+  dccalib.SetFileName(continuosLightFile);
+
+  const Int_t numblind = 5;
+  const Short_t w[numblind] = { 47, 124, 470, 475, 571};
+  const TArrayS blindpixels(numblind,(Short_t*)w);
+  Float_t ringinterest = 100; //[mm]
+  Float_t tailcut = 3.5;
+  UInt_t integratedevents = 4;
+
+  MFindStars findstars;
+  findstars.SetBlindPixels(blindpixels);
+  findstars.SetRingInterest(ringinterest);
+  findstars.SetDCTailCut(tailcut);
+  findstars.SetNumIntegratedEvents(integratedevents);
+  findstars.SetMinuitPrintOutLevel(-1);
+
+  MSrcPosFromStars srcposfromstar;
+    
+  MBadPixelsTreat   interpolatebadpixels;
+  interpolatebadpixels.SetUseInterpolation();
+  
+  MImgCleanStd      clean(lcore,ltail);
+
+  MArrivalTimeCalc2 timecalc;
+  
+  MIslandCalc       island;
+  island.SetOutputName("MIslands1");
+
+  MIslandClean      islclean(lnew);
+  islclean.SetInputName("MIslands1");
+  islclean.SetMethod(kmethod);
+      
+  MIslandCalc       island2;
+  island2.SetOutputName("MIslands2");  
+  
+  
+  MHillasCalc       hcalc;
+  MHillasSrcCalc    csrc1;
+  
+  MWriteRootFile write(outname,"RECREATE");
+  
+  write.AddContainer("MTime"          , "Parameters");
+  write.AddContainer("MHillas"        , "Parameters");
+  write.AddContainer("MHillasSrc"     , "Parameters");
+  write.AddContainer("MHillasExt"     , "Parameters");
+  write.AddContainer("MNewImagePar"   , "Parameters");
+  write.AddContainer("MRawEvtHeader"  , "Parameters");
+  write.AddContainer("MRawRunHeader"  , "Parameters");
+  write.AddContainer("MConcentration" , "Parameters");
+  write.AddContainer("MSrcPosCam"     , "Parameters");
+
+  if (islflag == 1 || islflag == 2)
+    write.AddContainer("MIslands1" , "Parameters");
+  if (islflag == 2) 
+    write.AddContainer("MIslands2" , "Parameters");
+  if (isSlowControlAvailable)
+    {
+      write.AddContainer("MStarLocalCam" , "Parameters");
+      write.AddContainer("MReportDrive" , "Parameters");
+    }
+  
+  tlist4.AddToList(&read4);
+  tlist4.AddToList(&geomapl);
+  if (isSlowControlAvailable)
+    {
+      tlist4.AddToList(&hvnotnominal,"Events");
+      tlist4.AddToList(&dccalib,"Currents");
+      tlist4.AddToList(&findstars,"Currents");
+      tlist4.AddToList(&srcposfromstar,"Events");
+    }
+                       
+  tlist4.AddToList(&extractor,"Events");
+  tlist4.AddToList(&photcalc,"Events");
+  if(calflag==11)
+    tlist4.AddToList(&interpolatebadpixels);
+  tlist4.AddToList(&clean,"Events");
+
+  if (islflag == 1 || islflag == 2)
+    {
+      tlist4.AddToList(&timecalc,"Events");
+      tlist4.AddToList(&island,"Events");
+    }
+
+  if (islflag == 2)
+    {
+      tlist4.AddToList(&islclean,"Events");
+      tlist4.AddToList(&island2,"Events");
+    }
+  
+  //tlist4.AddToList(&blind2,"Events");
+  tlist4.AddToList(&hcalc,"Events");
+  tlist4.AddToList(&csrc1,"Events");
+  tlist4.AddToList(&write,"Events");
+
+  // Create and setup the eventloop
+  MEvtLoop datloop;
+  datloop.SetParList(&plist4);
+
+  cout << endl;
+  cout << "******************************************************" << endl;
+  cout << "* COMPUTING DATA USING EXTRACTED SIGNAL (IN PHOTONS) *" << endl;
+  cout << "******************************************************" << endl;
+  cout << endl;
+
+  if (!datloop.Eventloop(nmaxevents))
+    return;
+
+  tlist4.PrintStatistics();    
+
+}
+//-------------------------------------------------------------------------------
+
+Bool_t readDatacards(TString& filename)
+{
+  ifstream ifun(filename.Data());
+  if(!ifun)
+    {
+      cout << "File " << filename << " not found" << endl;
+      return kFALSE;
+    }
+
+  TString word;
+  
+  while(ifun >> word)
+    {
+
+      // skip comments
+      if(word[0]=='/' && word[1]=='/')
+	{
+	  while(ifun.get()!='\n'); // skip line
+	  continue;
+	}
+
+      // number of events
+      if(strcmp(word.Data(),"NEVENTS")==0)
+	ifun >> nmaxevents;
+
+
+      // input file directory
+      if(strcmp(word.Data(),"IDIR")==0)
+	{
+	  if(idirname.Length())
+	    cout << "readDataCards Warning: overriding input directory file name" << endl;
+	  ifun >> idirname;
+	}
+
+       // pedestal runs for calibration
+      if(strcmp(word.Data(),"PCRUNS")==0)
+	{
+	  if(pedcaliter.GetNumRuns())
+	    cout << "readDataCards Warning: adding pedestal runs for calibration to the existing list" << endl;
+	  ifun >> word;
+	  pedcaliter.AddRuns(word.Data(),idirname.Data());
+	}
+
+      // calibration runs
+      if(strcmp(word.Data(),"CRUNS")==0)
+	{
+	  if(caliter.GetNumRuns())
+	    cout << "readDataCards Warning: adding calibration runs to the existing list" << endl;
+	  ifun >> word;
+	  caliter.AddRuns(word.Data(),idirname.Data());
+	}
+
+     // pedestal runs for data
+      if(strcmp(word.Data(),"PRUNS")==0)
+	{
+	  if(pediter.GetNumRuns())
+	    cout << "readDataCards Warning: adding pedestal runs for data to the existing list" << endl;
+	  ifun >> word;
+	  pediter.AddRuns(word.Data(),idirname.Data());
+	}
+
+      // data runs
+      if(strcmp(word.Data(),"DRUNS")==0)
+	{
+	  if(datiter.GetNumRuns())
+	    cout << "readDataCards Warning: adding data runs to the existing list" << endl;
+	  ifun >> word;
+	  datiter.AddRuns(word.Data(),idirname.Data());
+	}
+      
+      // output file name
+      if(strcmp(word.Data(),"OUTFILE")==0)
+	{
+	  if(outname.Length())
+	    cout << "readDataCards Warning: overriding output file name" << endl;
+	  ifun >> outname;
+	}
+
+      // calibration flag
+      if(strcmp(word.Data(),"CALFLAG")==0)
+	ifun >> calflag;
+
+      // cleaning level
+      if(strcmp(word.Data(),"CLEANLEVEL")==0)
+	{
+	  ifun >> lcore;
+	  ifun >> ltail;
+	}
+
+      if(strcmp(word.Data(),"ISLFLAG")==0)
+	{
+	  ifun >> islflag;
+	}
+
+      // island cleaning 
+      if (islflag == 2){
+	if(strcmp(word.Data(),"ISLANDCLEAN")==0)
+	  {
+	    ifun >> kmethod;
+	    ifun >> lnew;
+	  }
+      }
+
+      // slow control data available
+      if(strcmp(word.Data(),"SLOWCRT")==0)
+	{
+	  ifun >> slowflag;
+          if (slowflag == 1) isSlowControlAvailable = kTRUE;
+	}
+
+      // hv configuration file
+      if(strcmp(word.Data(),"HVCONFFILE")==0)
+	{
+	  ifun >> hvConfigFile;
+	}
+
+      // countinous light file to calibrate the dc data
+      if(strcmp(word.Data(),"CLFILE")==0)
+	{
+	  ifun >> continuosLightFile;
+	}
+    }
+
+  pedcaliter.Reset();
+  pediter.Reset();
+  caliter.Reset();
+  datiter.Reset();
+  TString pfile;
+
+  // Dump read values
+  cout << "************************************************" << endl;
+  cout << "* Datacards read from file " << filename << endl;
+  cout << "************************************************" << endl;
+  cout << "Pedestal file (s) for calibration: "  << endl;
+  while(kTRUE)
+  {
+      pfile=pedcaliter.Next();
+      if (pfile.IsNull())
+	  break;
+      cout << pfile << endl;
+  }
+  cout << "Calibration file (s): "  << endl;
+  while(kTRUE)
+  {
+      pfile=caliter.Next();
+      if (pfile.IsNull())
+	  break;
+      cout << pfile << endl;
+  }
+  cout << "Pedestal file (s) for data: "  << endl;
+  while(kTRUE)
+  {
+      pfile=pediter.Next();
+      if (pfile.IsNull())
+	  break;
+      cout << pfile << endl;
+  }
+  cout << "Data file (s): "  << endl;
+  while(kTRUE)
+  {
+      pfile=datiter.Next();
+      if (pfile.IsNull())
+	  break;
+      cout << pfile << endl;
+  }
+  cout << "Maximum number of events: " << nmaxevents << endl;
+  cout << "Output file name: " << outname << endl;
+  cout << "Calibration flag: " << calflag << endl;
+  cout << "Cleaning level: ("<<lcore<<","<<ltail<<")" << endl;
+  if (islflag == 1 || islflag == 2)
+    cout << "Island calcultation..." << endl;
+  if (islflag == 2)
+    {
+      cout << "Island Cleaning: "<< kmethod <<" method  "<< lnew << " new threshold" << endl;
+    }
+  cout << "***********" << endl << endl;
+  
+  if(!pediter.GetNumEntries())
+    {
+      cout << "No pedestal file name specified" << endl;
+      return kFALSE;
+    }
+  if(!caliter.GetNumEntries())
+    {
+      cout << "No calibration file name specified" << endl;
+      return kFALSE;
+    }
+  if(!datiter.GetNumEntries())
+    {
+      cout << "No data file name specified" << endl;
+      return kFALSE;
+    }
+  if(!outname.Length())
+    {
+      cout << "No output file name specified" << endl;
+      return kFALSE;
+    }
+
+  if (isSlowControlAvailable)
+    {
+      cout << "HV Configuratin file: " << hvConfigFile << endl;
+      cout << "Continous Light file: " << continuosLightFile << endl;
+    }
+  
+
+  return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/observationTime.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/observationTime.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/observationTime.C	(revision 9661)
@@ -0,0 +1,48 @@
+/* ======================================================================== *\!
+!   Author(s): Javier Rico
+\* ======================================================================== */
+
+void observationTime(
+		     Int_t iniRun=0,
+		     Int_t finRun=99999,
+		     TString filename="/mnt/users/jrico/magic/mars/mars/mtemp/mifae/hillas/AllCrabNebula_3015_kDefault_MispE.root"
+)
+{    
+    // define files, chains...
+    TChain* t= new TChain("Parameters");
+    t->Add(filename);
+
+    // define aliases
+    t->SetAlias("run",     "MRawRunHeader.fRunNumber");
+    t->SetAlias("runiniT", "MRawRunHeader.fRunStart.fTime.fMilliSec/1000");
+    t->SetAlias("runfinT", "MRawRunHeader.fRunStop.fTime.fMilliSec/1000");
+
+    TH1I* hrun = new TH1I("hrun","",finRun-iniRun+1,iniRun,finRun+1);
+    TH1I* hent = new TH1I("hent","",finRun-iniRun+1,iniRun,finRun+1);
+	
+    const char varcut[512];
+    const char runcut[512];
+    sprintf(runcut,"(run>=%d && run<=%d)",iniRun,finRun);
+    sprintf(varcut,"%s*(runfinT-runiniT)",runcut);
+
+    t->Draw("run>>hrun",runcut);
+    t->Draw("run>>hent",varcut);
+
+    Float_t seconds=0;
+    for(Int_t irun = 1; irun<=finRun-iniRun+1; irun++)
+      {
+	Int_t nev;
+	if(nev=hrun->GetBinContent(irun))
+	  {
+	    Float_t time = hent->GetBinContent(irun)/nev;
+	    seconds += time;	    
+	    cout << "run " << iniRun-1+irun << ", " << time <<  " seconds" << endl;
+	  }
+      }
+    
+    cout << "Total observation time = " << seconds << " seconds = " << seconds/60. << " minutes = " << seconds/3600. << " hours" << endl;
+    delete hrun;
+    delete hent;
+}
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/plotOptimal.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/plotOptimal.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/plotOptimal.C	(revision 9661)
@@ -0,0 +1,124 @@
+////////////////////////////////////////////////////////////////////////////////////
+//
+//             _____ Plot Optimized cuts _____
+//
+//  Take as input an output from programs/optimizeCuts and plot the results
+//  You only need to specify the input file name
+//
+//                 Jose Flix    <jflix@ifae.es>
+//                 Javier Rico  <jrico@ifae.es>
+////////////////////////////////////////////////////////////////////////////////////
+
+
+void plotOptimal(TString fname="optimize.out")
+{
+  gROOT->Reset();
+  gStyle->SetCanvasColor(0);
+  gStyle->SetCanvasBorderMode(0);
+  gStyle->SetPadBorderMode(0);
+  gStyle->SetFrameBorderMode(0);
+  gStyle->SetOptStat(000000);
+  gStyle->SetPalette(1);
+
+  ifstream ifun(fname.Data());
+  Float_t width,length,excess,significance;
+
+  Float_t wmin=9999999;
+  Float_t lmin=9999999;
+  Float_t wmax=-9999999;
+  Float_t lmax=-9999999;
+  Float_t emax=-9999999;
+  Float_t smax=-9999999;
+
+  Float_t dw=-1;
+  Float_t dl=-1;
+  Float_t prevw=-1;
+  Float_t prevl=-1;
+
+  // first loop to get parameters
+  Int_t i=0;
+  while(ifun >> width)
+    {
+      // read data
+      ifun >> length;
+      ifun >> excess;
+      ifun >> significance;
+      
+      // keep max/min
+      if(width<wmin)  wmin=width;
+      if(length<lmin) lmin=length;
+      if(width>wmax)  wmax=width;
+      if(length>lmax) lmax=length;
+      if(significance>smax) 
+	{
+	  smax=significance;
+	  emax=excess;
+	}
+
+      if(width!=prevw)   dw=width-prevw;
+      if(length!=prevl) dl=length-prevl;
+
+      prevw=width;
+      prevl=length;
+      i++;
+    }
+  ifun.close();
+
+  cout << "wmin: " << wmin << ", wmax: " << wmax+dw << ", lmin: " << lmin << ", lmax: " << lmax+dl << endl;
+
+  // define histos
+  Int_t nx = TMath::Nint((wmax-wmin)/dw)+1;
+  Int_t ny = TMath::Nint((lmax-lmin)/dl)+1;
+  TH2F *ex  = new TH2F("Excess","Excess",nx,wmin,wmax+dw,ny,lmin,lmax+dl);
+  TH2F *sig = new TH2F("Significance","Significance",nx,wmin,wmax+dw,ny,lmin,lmax+dl);
+
+  cout << "nx: " << nx << ", ny: " << ny << endl;
+  cout << "dw: " << dw << ", dl: " << dl << endl;
+
+  ifstream ifun2;
+  ifun2.open(fname.Data());
+  
+  // second loop to fill the histograms
+  Float_t wopt,lopt,eopt;
+  while(ifun2 >> width)
+    {
+      // read data
+      ifun2 >> length;
+      ifun2 >> excess;
+      ifun2 >> significance;
+
+      cout << "Width: " << width << '\t' << "Length: " << length << '\t' << "Excess: " << excess << '\t' << "Significance: " << significance;
+      if(significance==smax)
+	{
+	  cout << " *****";
+	  wopt=width;
+	  lopt=length;
+	  eopt=excess;
+	}
+	    
+      cout << endl;
+
+      Int_t binx = TMath::Nint(((width-wmin)/dw));
+      Int_t biny = TMath::Nint(((length-lmin)/dl));
+
+      //      cout << "binnx: " << binx+1 << ", biny: " << biny+1 << endl;
+
+      ex->SetBinContent(binx+1,biny+1,excess+.00001);
+      sig->SetBinContent(binx+1,biny+1,significance+.00001);    
+    }
+  cout << "Maximal significance: " << smax << " (excess=" << eopt << ") for width="<<wopt<<", length=" << lopt << endl;
+
+  // plot
+  TCanvas *c3 = new TCanvas("c3","c3",0,0,500,750);
+  c3->Divide(1,2);
+  
+  c3->cd(1);
+  ex->GetXaxis()->SetTitle("Width (degrees)");
+  ex->GetYaxis()->SetTitle("Length (degrees)");
+  ex->Draw("colz");
+  
+  c3->cd(2);
+  sig->GetXaxis()->SetTitle("Width (degrees)");
+  sig->GetYaxis()->SetTitle("Length (degrees)");
+  sig->Draw("colz");
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/psffit.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/psffit.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/psffit.C	(revision 9661)
@@ -0,0 +1,149 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Javier López, 04/2004 <mailto:jlopez@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+
+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 psffit(const TString filename="dc_2004_03_19_00_36_50_20781_Mrk421.root", const TString directory="/nfs/magic/CaCodata/rootdata/Mrk421/Period015/2004_03_19/", const UInt_t numEvents = 0)
+{
+
+  //
+  // 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);
+
+
+  MGeomCamMagic geomcam;
+  MCameraDC     dccam;
+  MPSFFit       psffit;
+
+  plist.AddToList(&geomcam);
+  plist.AddToList(&dccam);
+  plist.AddToList(&psffit);
+
+  //
+  // Now setup the tasks and tasklist:
+  // ---------------------------------
+  //
+
+  // Reads the trees of the root file and the analysed branches
+  MReadReports read;
+  read.AddTree("Currents"); 
+  read.AddFile(directory+filename);     // after the reading of the trees!!!
+  read.AddToBranchList("MReportCurrents.*");
+
+  MGeomApply geomapl;
+
+  const Int_t numrings = 3;
+  const Int_t numblind = 23;
+  const Short_t x[numblind] = {  8,  27, 224, 279, 339,
+			       507, 508, 509, 510, 511, 512, 513, 514,
+			       543,
+			       559, 560, 561, 562, 563, 564, 565, 566, 567};
+  const TArrayS blindpixels(numblind,(Short_t*)x);
+  MPSFFitCalc psfcalc;
+  //psfcalc.SetImgCleanMode(MPSFFitCalc::kRing);
+  psfcalc.SetImgCleanMode(MPSFFitCalc::kCombined);
+  psfcalc.SetNumRings(numrings);
+  psfcalc.SetBlindPixels(blindpixels);
+
+
+  tlist.AddToList(&geomapl);
+  tlist.AddToList(&read);
+  tlist.AddToList(&psfcalc, "Currents");
+
+  //
+  // Create and setup the eventloop
+  //
+  MEvtLoop evtloop;
+  evtloop.SetParList(&plist);
+     
+  //
+  // Execute your analysis
+  //
+
+  if (numEvents > 0)
+  {
+      if (!evtloop.Eventloop(numEvents))
+	  return;
+  }
+  else
+  {
+      if (!evtloop.PreProcess())
+	  return;
+      
+      MHCamera display(geomcam);
+      display.SetPrettyPalette();
+      display.Draw();
+      gPad->cd(1);
+      psffit.Draw();
+      
+      while (tlist.Process())
+      {
+	  display.SetCamContent(dccam);
+	  gPad->Modified();
+	  gPad->Update();
+          psffit.Print();
+	  // Remove the comments if you want to go through the file
+	  // event-by-event:
+	  if (!HandleInput())
+	      break;
+      } 
+
+      evtloop.PostProcess();
+  }
+
+  tlist.PrintStatistics();
+
+  psffit.Print();
+  cout << "RUN " << psffit.GetMeanMinorAxis() << ' ' << psffit.GetSigmaMinorAxis() << ' ' <<  psffit.GetMeanMajorAxis()  << ' ' <<  psffit.GetSigmaMajorAxis() << ' ' << psffit.GetChisquare() << endl;
+  
+}
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/psffromstars.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/psffromstars.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/psffromstars.C	(revision 9661)
@@ -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): Javier López, 05/2004 <mailto:jlopez@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+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;
+}
+
+Double_t fitfunc(Double_t *x, Double_t *par);
+
+
+void psffromstars(const TString filename="dc_*.root", const TString directory="/nfs/magic/CaCodata/online_data/Period015/cacadata/2004_03_21/", const UInt_t numEvents = 100000000)
+{
+
+  gStyle->SetOptFit(1);
+  
+  //
+  // 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);
+
+
+  MGeomCamMagic geomcam;
+  MCameraDC     dccam;
+  MStarLocalCam starcam;
+  MHPSFFromStars mhpsf;
+
+  plist.AddToList(&geomcam);
+  plist.AddToList(&dccam);
+  plist.AddToList(&starcam);
+  plist.AddToList(&mhpsf);
+
+  //
+  // Now setup the tasks and tasklist:
+  // ---------------------------------
+  //
+
+  // Reads the trees of the root file and the analysed branches
+  MReadReports read;
+  read.AddTree("Currents"); 
+  read.AddFile(directory+filename);     // after the reading of the trees!!!
+  read.AddToBranchList("MReportCurrents.*");
+
+  MGeomApply geomapl;
+  TString continuoslightfile = 
+    //    "/home/Javi/mnt_magic_data/CaCo/rootdata/Miscellaneous/Period016/2004_04_16/dc_2004_04_16_04_46_18_22368_Off3c279-2CL100.root";
+    "/nfs/magic/CaCodata/rootdata/Miscellaneous/Period016/2004_04_16/dc_2004_04_16_04_46_18_22368_Off3c279-2CL100.root";
+
+  Float_t mindc = 0.7; //[uA]
+  MCalibrateDC dccal;
+  dccal.SetFileName(continuoslightfile);
+  dccal.SetMinDCAllowed(mindc);
+
+  const Int_t numblind = 1;
+  const Short_t x[numblind] = { 124};
+  const TArrayS blindpixels(numblind,(Short_t*)x);
+  Float_t ringinterest = 100; //[mm]
+  Float_t tailcut = 3.5;
+  UInt_t integratedevents = 10;
+
+  MFindStars findstars;
+  findstars.SetBlindPixels(blindpixels);
+  findstars.SetRingInterest(ringinterest);
+  findstars.SetDCTailCut(tailcut);
+  findstars.SetNumIntegratedEvents(integratedevents);
+  findstars.SetMinuitPrintOutLevel(-1);
+
+  MFillH fpsf("MHPSFFromStars","MStarLocalCam");
+  
+  tlist.AddToList(&geomapl);
+  tlist.AddToList(&read);
+  tlist.AddToList(&dccal);
+  tlist.AddToList(&findstars, "Currents");
+  tlist.AddToList(&fpsf, "Currents");
+
+  //
+  // Create and setup the eventloop
+  //
+  MEvtLoop evtloop;
+  evtloop.SetParList(&plist);
+  
+//   MProgressBar bar;
+//   evtloop.SetProgressBar(&bar);
+  
+  //
+  // Execute your analysis
+  //
+  
+  if (!evtloop.Eventloop(numEvents))
+    return;
+
+  tlist.PrintStatistics();
+
+  //Draw results
+
+  MStatusDisplay *d = new MStatusDisplay;
+  d->SetTitle(Form("- %s -",filename));
+  d->SetLogStream(&gLog, kTRUE);            // Disables output to stdout
+
+  // Create a default canvas
+  TCanvas &c1 = d.AddTab("Star spot Position");
+  mhpsf.Draw("mean");
+  TCanvas &c2 = d.AddTab("Star's Path");
+  mhpsf.Draw("camera");
+  TCanvas &c3 = d.AddTab("Star spot Size");
+  mhpsf.Draw("sigma");
+  TCanvas &c4 = d.AddTab("Star XY Projection");
+  mhpsf.Draw("projection");
+  
+  d->Print("./psf.ps");
+  
+  //  if (!HandleInput()) {}
+
+}
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/rotation.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/rotation.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/rotation.C	(revision 9661)
@@ -0,0 +1,101 @@
+
+// Macro to compare the rotation obtained from simple FOV rotation, with 
+// measured values
+
+void rotation()
+{
+  const Int_t rmax=17427;
+  gStyle->SetMarkerStyle(20);
+  gStyle->SetMarkerSize(1);
+
+  const char* fname="/mnt/users/jrico/magic/mars/Mars_Standard02/mtemp/mifae/macros/20040215_Mrk421.B.pos";
+  TFile* file= new TFile("/mnt/users/jrico/magic/mars/Mars_Standard02/mtemp/mifae/hillas/mrk20040215OnRotateNoCalB.root");
+  TTree* chain = (TTree*)file->Get("Parameters");
+
+  // read position data from file
+  ifstream ifun(fname);
+
+  Int_t irun;
+  Float_t ix;
+  Float_t iy;
+
+  // first loop to evaluate number of entries
+  Int_t nentries=0;  
+  while(ifun >> irun)
+    {
+      ifun >> ix;
+      ifun >> iy;
+      nentries++;
+    }
+  ifun.close();
+  const Int_t size = nentries;
+  Float_t x[size];
+  Float_t y[size];
+  Int_t run[size];
+
+  // second loop to actually read values into arrays
+  Int_t i=0;
+  ifstream ifun2(fname);
+  while(ifun2 >> run[i])
+    {
+      ifun2 >> x[i];
+      ifun2 >> y[i];
+      x[i]/=315.;
+      y[i]/=315.;
+      i++;
+    }  
+  ifun2.close();
+  TGraph* tray = new TGraph(nentries,x,y);
+
+  // get data from tree
+  MSrcPosCam* srpos = new MSrcPosCam; 
+  MRawRunHeader* hrun = new MRawRunHeader;
+  chain->SetBranchAddress("MSrcPosCam.",&srpos);
+  chain->SetBranchAddress("MRawRunHeader.",&hrun);
+
+  Int_t ntot = chain->GetEntries();
+  const Int_t ctot =ntot;
+  Float_t xth[ctot];
+  Float_t yth[ctot];
+  Int_t rtot=0;
+  for(Int_t j=0;j<ctot;j++)
+    {
+      chain->GetEntry(j);
+      Int_t arun=hrun->GetRunNumber();
+      if(arun<=rmax)
+	{
+	  xth[j]=srpos->GetX()/315.;
+	  yth[j]=srpos->GetY()/315.;
+	  rtot++;
+	}
+    }     
+  TGraph* trayth = new TGraph(rtot,xth,yth);
+  
+
+  // Plot   
+  TPostScript myps("rotation.ps",111);
+  myps.Range(15,15);
+  TCanvas* myC = new TCanvas("myC","pedestal studies",500,500);
+  myC->cd(1);
+
+  // Null graph to adjust plot limits
+  Float_t nullx[2]={-0.4,0.4};
+  Float_t nully[2]={-0.4,0.4};
+
+  TGraph grnull(2,nullx,nully);
+  grnull.SetMarkerSize(0);
+  grnull.SetMarkerColor(0);
+  grnull.GetXaxis()->SetTitle("x (deg)");
+  grnull.GetYaxis()->SetTitle("y (deg)");
+  grnull.SetTitle("Source position in camera Mrk421 15th February");
+  grnull.DrawClone("AP");
+
+  tray->SetMarkerStyle(2);
+  tray->SetMarkerSize(2);
+  trayth->SetMarkerStyle(6);
+  trayth->SetMarkerColor(2);
+
+  tray->DrawClone("P");
+  trayth->DrawClone("P");
+  myps.Close();
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/runlivetime.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/runlivetime.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/runlivetime.C	(revision 9661)
@@ -0,0 +1,96 @@
+void runlivetime(TString filename)
+{
+
+  gROOT->Reset();
+  gStyle->SetCanvasColor(0);
+  gStyle->SetCanvasBorderMode(0);
+  gStyle->SetPadBorderMode(0);
+  gStyle->SetFrameBorderMode(0);
+
+  //
+  // Make a loop only for the ON data:
+  //
+  
+  MParList plist;
+  MTaskList tlist;
+  plist.AddToList(&tlist);
+
+  //Containers
+  
+  MLiveTime livetime;
+
+  plist.AddToList(&livetime);
+  
+  //
+  //tasks
+  //
+  
+  MReadTree read("Parameters");
+  read.DisableAutoScheme();
+
+  TString tmpfile = "./runlivetime.ls.tmp";
+  TString cmd = "ls " + filename + " > " + tmpfile;
+  gSystem->Exec(cmd);
+  TString tmpline;
+  ifstream in(tmpfile);
+  while(1)
+  {
+      in >> tmpline;
+      if(in.eof())
+	  break;
+      read.AddFile(tmpline);
+  }
+  TString cmd = "rm " + tmpfile;
+  gSystem->Exec(cmd);
+
+  Double_t timebin = 500.; //[sec]
+  MLiveTimeCalc livetimecalc;
+  livetimecalc.SetRealTimeBinSize(timebin);
+
+  tlist.AddToList(&read);
+  tlist.AddToList(&livetimecalc);
+
+  //
+  // Create and setup the eventloop
+  //
+  MEvtLoop loop;
+  loop.SetParList(&plist);
+     
+
+  if (!loop.Eventloop())
+      return;
+
+//   if (!loop.PreProcess())
+//     return;
+
+//   while(loop.Process())
+//     {}
+  
+//   loop.PostProcess();
+
+  tlist.PrintStatistics();
+
+  UInt_t numbertimebins = livetime.GetNumberTimeBins();
+  TArrayD y(numbertimebins);
+  TArrayD erry(numbertimebins);
+
+  for (UInt_t bin=0; bin<numbertimebins; bin++)
+    {
+      y[bin] = bin+1.;
+      erry[bin] = 0.;
+    }
+
+  TCanvas *c0 = new TCanvas;
+  c0->cd(1);
+  TGraphErrors *graph = new TGraphErrors(numbertimebins,livetime.GetMeanRealTimeArray(),y.GetArray(),livetime.GetWidthRealTimeArray(),erry.GetArray());
+  graph->SetTitle("");
+  graph->SetMinimum(0.);
+  graph->SetMarkerStyle(21);
+  graph->SetMarkerSize(0.03);
+  graph->Draw("AP");
+  graph->GetXaxis()->SetLabelSize(0.03);
+  graph->GetXaxis()->SetTitle("Time [MJD]");
+  //  lightcurvegraph->GetXaxis()->SetTimeDisplay(1);
+
+  
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/signal.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/signal.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/signal.C	(revision 9661)
@@ -0,0 +1,180 @@
+/////////////////////////////////////////////////////////////////////////////
+//
+//       This macro makes the two-dimension plot of the False Source Method:
+//        root > .x signal.C(TString name, TString psname)
+//
+//                 Ester Aliu   <aliu@ifae.es>
+//                 Oscar Blanch <blanch@ifae.es>
+//                 Javier Rico  <jrico@ifae.es>
+////////////////////////////////////////////////////////////////////////////
+void signal(
+TString fname ="hillasCrab/falseSourceCrab20040215.root",
+TString psname ="kk.ps")
+{
+  Float_t excess;
+  Float_t significance;
+  Float_t array[2];
+  
+  Int_t nbin2d = 5;
+  Int_t ntotal = 2*nbin2d+1;
+  
+  Int_t nx = 0;
+  Int_t ny = 0;
+  
+  Float_t max = -10000;
+  Int_t imax;
+  Int_t jmax;
+  Float_t A ;
+  Float_t B;
+  
+  TH2F *hsignif = new TH2F("hsignif","Significance", ntotal, -1.0, 1.0, ntotal, -1.0, 1.0);
+  TH2F *hexcess = new TH2F("hexcess","Excess", ntotal, -1.0, 1.0, ntotal, -1.0, 1.0);
+  
+  
+  // loop on the histos and compute excess and significance
+  for( Int_t i = -nbin2d; i <= nbin2d ; i++)  
+    {    
+      nx++;
+      ny = 0;
+      for( Int_t j = -nbin2d; j <= nbin2d ; j++)  
+	{	
+	  ny++;	  
+	  step_signal(i,j,&array[0], fname);
+	  
+	  excess = array[0];
+	  significance = array[1];
+
+	  hexcess->SetBinContent(nx, ny, excess);
+	  hsignif->SetBinContent(nx, ny, significance);
+
+	  if ( significance > max)
+	    {
+	      max = significance;
+	      imax = i;
+	      jmax = j;
+	      A = excess;
+	      B = significance;
+	    }
+	}
+    }
+  
+  cout << "The position of maximum significance is ( " << imax << " , " << jmax << " )" << endl;
+  cout << "Excess: " << A << endl;
+  cout << "Significance: " << B << endl;
+    
+  // Plot 
+  gROOT->Reset();
+  gStyle->SetCanvasColor(0);
+  gStyle->SetCanvasBorderMode(0);
+  gStyle->SetPadBorderMode(0);
+  gStyle->SetFrameBorderMode(0);
+  gStyle->SetOptTitle(0);
+  gStyle->SetTitleOffset(1.7,"y");
+  gStyle->SetPadLeftMargin(0.15);
+  gStyle->SetOptStat(kFALSE);
+  gStyle->SetStatColor(0);
+  gStyle->SetStatBorderSize(1);
+  gStyle->SetStatW(0.2);
+  gStyle->SetStatH(0.1);
+  gStyle->SetStatX(0.9);
+  gStyle->SetStatY(0.9);
+  
+
+  TPostScript myps(psname,111);
+  myps.Range(15,15);
+  TCanvas *c2d = new TCanvas("c2d", "Matrices", 0, 0, 800,800);  
+  c2d->Divide(2,2);
+  gStyle->SetPalette(1); 
+  
+  c2d->cd(1);
+  hexcess->Draw("colz");
+  hexcess->SetXTitle("X position (deg)");
+  hexcess->SetYTitle("Y position (deg)");
+  gPad->Update();    
+  
+  c2d->cd(2);
+  hsignif->Draw("colz");
+  hsignif->SetXTitle("X position (deg)");
+  hsignif->SetYTitle("Y position (deg)");
+  gPad->Update();
+
+  c2d->cd(3);
+  hexcess->Draw("lego2");
+  hexcess->SetXTitle("X position (deg)");
+  hexcess->SetYTitle("Y position (deg)");
+  gPad->Update();    
+  
+  c2d->cd(4);
+  hsignif->Draw("lego2");
+  hsignif->SetXTitle("X position (deg)");
+  hsignif->SetYTitle("Y position (deg)");
+  gPad->Update();    
+
+  myps.Close();
+}
+  
+  
+void step_signal(Int_t i, Int_t j, Float_t *array, TString fname) 
+{
+  cout << "Bin (" << i << "," << j << ")" << endl;
+  TH1F *onhisto;
+  TH1F *offhisto;
+
+  // open file and access to the histograms  
+  TFile *f = new TFile(fname);
+  Char_t name[20]; 
+  Char_t title[50]; 
+
+  // histo name
+  sprintf(name,"hOnAlpha[%d][%d]", i, j);
+  sprintf(title,"Alpha-Plot(On data) (%d ,%d)", i, j);
+  onhisto = (TH1F*)gDirectory->Get(name);   
+  
+  sprintf(name,"hOffAlpha[%d][%d]", i, j);
+  sprintf(title,"Alpha-Plot(Off data) (%d ,%d)", i, j);
+  offhisto = (TH1F*)gDirectory->Get(name);   
+  
+  // line/normalization
+  const Int_t nbins = 18;
+  const Int_t inibin = 20./90.*nbins+1;
+  Float_t level=0;
+  Float_t leveloff=0;
+  Float_t levelofferror=0;
+  for(Int_t ibin = inibin; ibin<=nbins;ibin++)
+    {
+      level+=onhisto->GetBinContent(ibin);
+      leveloff+=offhisto->GetBinContent(ibin);
+    }
+  level/=(nbins-inibin+1);
+  leveloff/=(nbins-inibin+1);
+  
+  // normalize on/off
+  offhisto->Sumw2(); // needed to compute correct errors after normalization
+  const Float_t norm = level/leveloff;
+  cout << "Normalizing by factor " << norm <<endl;
+  offhisto->Scale(norm);    
+  
+  // significance:
+  Float_t sig=0,bg=0,esig=0,ebg=0;
+  Float_t significance=0;
+  const Int_t signbins = inibin-1;
+  for(Int_t ibin = 1; ibin<=signbins;ibin++)
+    {
+      sig  += onhisto->GetBinContent(ibin);
+      esig += onhisto->GetBinError(ibin)*onhisto->GetBinError(ibin);
+      bg   += offhisto->GetBinContent(ibin);
+      ebg  += offhisto->GetBinError(ibin)*offhisto->GetBinError(ibin);
+    }
+  Float_t error= TMath::Sqrt(esig+ebg);
+  Float_t excess = sig-bg;
+  Float_t significance = excess/error;
+  
+  cout << "Excess:       " << excess << endl;
+  cout << "Significance: " << significance << endl;
+  
+  array[0] = excess;
+  array[1] = significance;
+}
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/signalPoint.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/signalPoint.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/macros/signalPoint.C	(revision 9661)
@@ -0,0 +1,131 @@
+/////////////////////////////////////////////////////////////////////////////
+//
+//       This macro makes the alpha-plot for one of the positions of the 
+//     False Source Method:
+//
+//                 Ester Aliu   <aliu@ifae.es>
+//                 Oscar Blanch <blanch@ifae.es>
+//                 Javier Rico  <jrico@ifae.es>
+////////////////////////////////////////////////////////////////////////////
+
+void signalPoint(Int_t i=0, Int_t j=0, TString fname="hillasCrab/falseSourceCrab20040215.root")
+{  
+  // constants
+  const Int_t nbins = 18;
+  
+  // general settings
+  gROOT->Reset();
+  gStyle->SetCanvasColor(0);
+  gStyle->SetCanvasBorderMode(0);
+  gStyle->SetPadBorderMode(0);
+  gStyle->SetFrameBorderMode(0);
+  gStyle->SetOptTitle(0);
+  gStyle->SetTitleOffset(1.7,"y");
+  gStyle->SetPadLeftMargin(0.15);
+  gStyle->SetOptStat(111110);
+  gStyle->SetStatColor(0);
+  gStyle->SetStatBorderSize(1);
+  gStyle->SetStatW(0.2);
+  gStyle->SetStatH(0.1);
+  gStyle->SetStatX(0.9);
+  gStyle->SetStatY(0.9);
+  
+  
+  //  open file and access to the histograms
+  TFile *f = new TFile(fname);
+  
+  Char_t name[20]; 
+  Char_t title[50]; 
+  
+  sprintf(name,"hOnAlpha[%d][%d]", i, j);
+  sprintf(title,"Alpha-Plot(On data) (%d ,%d)", i, j);
+  TH1F* onhisto = (TH1F*)gDirectory->Get(name);   
+  
+  sprintf(name,"hOffAlpha[%d][%d]", i, j);
+  sprintf(title,"Alpha-Plot(Off data) (%d ,%d)", i, j);
+  TH1F* offhisto = (TH1F*)gDirectory->Get(name);   
+
+  TPostScript myps("signalpoint.ps",111);
+  myps.Range(15,15);
+  TCanvas *c1 = new TCanvas("c1","c1",800,600);
+  c1->cd(1);
+
+  // line/normalization
+  const Int_t inibin = 20./90.*nbins+1;
+  Float_t level=0;
+  Float_t leveloff=0;
+  Float_t levelofferror=0;
+  for(Int_t ibin = inibin; ibin<=nbins;ibin++)
+    {
+      level+=onhisto->GetBinContent(ibin);
+      leveloff+=offhisto->GetBinContent(ibin);
+    }
+  level/=(nbins-inibin+1);
+  leveloff/=(nbins-inibin+1);
+  
+  // normalize on/off
+  offhisto->Sumw2(); // needed to compute correct errors after normalization
+  const Float_t norm = level/leveloff;
+  cout << "Normalizing by factor " << norm <<endl;
+  offhisto->Scale(norm);    
+  
+  // significance:
+  Float_t sig=0,bg=0,esig=0,ebg=0;
+  Float_t significance=0;
+  const Int_t signbins = inibin-1;
+  for(Int_t ibin = 1; ibin<=signbins;ibin++)
+    {
+      //	Float_t sigma = (onhisto->GetBinContent(ibin)-level)/onhisto->GetBinError(ibin);
+      //	significance+=sigma*sigma;
+      sig  += onhisto->GetBinContent(ibin);
+      esig += onhisto->GetBinError(ibin)*onhisto->GetBinError(ibin);
+      bg   += offhisto->GetBinContent(ibin);
+      ebg  += offhisto->GetBinError(ibin)*offhisto->GetBinError(ibin);
+    }
+  Float_t error= TMath::Sqrt(esig+ebg);
+  significance = (sig-bg)/error;
+  
+  cout << "Significance: " << significance << endl;
+  
+  // plot
+  onhisto->SetXTitle("alpha (deg)");
+  onhisto->SetYTitle("Entries");
+  onhisto->SetMarkerColor(4);
+  onhisto->SetMarkerStyle(20);
+  onhisto->SetMarkerSize(.7);
+  onhisto->SetLineColor(4);
+  onhisto->SetMaximum(onhisto->GetBinContent(nbins)*1.5);
+  
+  offhisto->SetFillColor(2);
+  offhisto->SetMaximum(offhisto->GetBinContent(nbins)*1.5);
+  offhisto->SetXTitle("alpha (deg)");
+  offhisto->SetYTitle("Entries");
+  
+  offhisto->Draw("HIST");
+  offhisto->Draw("ESAME");
+  onhisto->Draw("ESAMES");
+  //    onhisto->Draw("E");
+  
+  // move stat box to make them all visible
+  gPad->Update();
+  TPaveStats* offpavstat = (TPaveStats*) offhisto->GetListOfFunctions()->FindObject("stats");
+  if(offpavstat)
+    {
+      Float_t shiftx = offpavstat->GetX2NDC()-offpavstat->GetX1NDC();
+      offpavstat->SetX1NDC(offpavstat->GetX1NDC()-shiftx);
+      offpavstat->SetX2NDC(offpavstat->GetX2NDC()-shiftx);
+    }
+  
+  // draw line
+  TLine* line = new TLine(0.,level,90.,level);
+  line->SetLineColor(2);
+  line->SetLineStyle(2);
+  //    line->Draw();
+  
+  gPad->Modified();
+  gPad->Update();
+  
+  myps.Close();
+}
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/Makefile
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/Makefile	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/Makefile	(revision 9661)
@@ -0,0 +1,61 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS IFAE library
+#
+##################################################################
+# @maintitle
+
+# @code
+
+#
+#  please change all system depend values in the 
+#  config.mk.${OSTYPE} file 
+#
+#
+include ../../../Makefile.conf.$(OSTYPE)
+include ../../../Makefile.conf.general
+
+PROGRAMS = makeHillas psffit falseSource srcPos optimizeCuts calib controlPlot
+SOLIB    = $(MARSSYS)/libmars.so
+
+#------------------------------------------------------------------------------
+
+INCLUDES = -I. \
+	   -I../library \
+	   -I../../../mbase \
+	   -I../../../mfbase \
+	   -I../../../mjobs \
+	   -I../../../mpedestal	 \
+	   -I../../../mbadpixels \
+	   -I../../../mfileio \
+           -I../../../mraw \
+           -I../../../manalysis \
+	   -I../../../mgui \
+	   -I../../../mgeom \
+	   -I../../../msignal \
+	   -I../../../mcalib \
+	   -I../../../mfilter \
+	   -I../../../mhbase \
+	   -I../../../mimage \
+	   -I../../../mpointing \
+	   -I../../../mcamera \
+	   -I../../../mhist \
+	   -I../../../mastro \
+           -I../../../mtemp
+
+all: $(PROGRAMS)
+
+include ../../../Makefile.rules
+
+$(PROGRAMS): $(PROGRAMS:=.o)
+	@echo " Linking $@ ..." 
+	$(CXX) $(CXXFLAGS) $(ROOTGLIBS) $(SOLIB) $@.o $(MARS_LIB) -o $@
+
+clean: rmobjs rmcore 
+mrproper: clean rmbak
+	rm -f $(PROGRAMS)
+
+
+# @endcode
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/calib.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/calib.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/calib.cc	(revision 9661)
@@ -0,0 +1,312 @@
+/*********************************/
+/* Compute the hillas parameters */
+/*********************************/
+
+#include "TString.h"
+#include "TArrayS.h"
+
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MPedestalCam.h"
+#include "MBadPixelsCam.h"
+#include "MBadPixelsTreat.h"
+#include "MReadMarsFile.h"
+#include "MGeomApply.h"
+#include "MPedCalcPedRun.h"
+#include "MEvtLoop.h"
+#include "MGeomCamMagic.h"
+#include "MExtractedSignalCam.h"
+#include "MCalibrationChargeCam.h"
+#include "MCalibrationQECam.h"
+#include "MCalibrationQEPix.h"
+#include "MHCalibrationChargeCam.h"
+#include "MHCalibrationRelTimeCam.h"
+#include "MExtractor.h"
+#include "MExtractFixedWindow.h"
+#include "MExtractSlidingWindow.h"
+#include "MExtractSignal.h"
+#include "MCalibrationChargeCalc.h"
+#include "MFCosmics.h"
+#include "MContinue.h"
+#include "MLog.h"
+#include "MCerPhotEvt.h"
+#include "MPedPhotCam.h"
+#include "MCalibrate.h"
+#include "MPedPhotCalc.h"
+#include "MHillas.h"
+#include "MNewImagePar.h"
+#include "MRawRunHeader.h"
+#include "MSrcPosCam.h"
+#include "MBlindPixelCalc.h"
+#include "MImgCleanStd.h"
+#include "MHillasSrcCalc.h"
+#include "MHillasCalc.h"
+#include "MArrivalTimeCam.h"
+#include "MArrivalTimeCalc2.h"
+#include "MIslands.h"
+#include "MIslandCalc.h"
+#include "MIslandClean.h"
+#include "MWriteRootFile.h"
+#include "MArgs.h"
+#include "MRunIter.h"
+#include "MJPedestal.h"
+#include "MJCalibration.h"
+#include "MHillasDisplay.h"
+#include "MF.h"
+#include "MContinue.h"
+
+#include "TApplication.h"
+
+#include <iostream>
+#include <fstream>
+#include <stdlib.h>
+
+using namespace std;
+
+Bool_t readDatacards(TString& filename);
+void calib();
+
+// initial and final time slices to be used in signal extraction
+const Byte_t hifirst = 1;
+const Byte_t hilast  = 14;
+const Byte_t lofirst = 3;
+const Byte_t lolast  = 14;
+
+// declaration of variables read from datacards
+TString  outname;
+TString  idirname;
+TString  filter;
+TString  psfilename("makehillas.ps");
+MRunIter caliter;
+MRunIter pediter;
+MRunIter datiter;
+UInt_t   display   = 0;
+ULong_t  nmaxevents= 999999999;
+Short_t  calflag   = 1;
+Float_t  lcore     = 3.0;
+Float_t  ltail     = 1.5;
+Int_t    islflag   = 0;
+Float_t  lnew      = 40;
+Int_t    kmethod   = 1;
+Int_t    kalgorithm = 1;
+Int_t    nfiles    = 0;
+
+const TString defaultcard="makehillas.datacard";
+/*************************************************************/
+static void Usage()
+{
+  gLog <<endl;
+  gLog << "Usage is:" << endl;
+  gLog << "   calib [-h] [-?] <datacards>" << endl << endl;
+  gLog << "     <datacards>: datacards file name (dafault input.datacards)" << endl;
+  gLog << "     -?/-h: This help" << endl << endl;
+}
+/*************************************************************/
+int main(int argc, char **argv)
+{
+  // create a TApplication to be able to 
+  TApplication app("Application",0,0);
+
+  // evaluate arguments
+  MArgs arg(argc, argv);
+  if (arg.HasOnly("-?") || arg.HasOnly("-h") || arg.HasOnly("--help"))
+    {
+      Usage();
+      return -1;
+    }
+
+  TString datacard  = arg.GetArgumentStr(0);
+  if(!datacard.Length())
+    datacard = defaultcard;
+
+  if(!readDatacards(datacard))
+    {
+      cout << "Error reading datacards. Stoping" << endl;
+      return -1;
+    }
+
+  calib();
+}
+
+/*************************************************************/
+void calib()
+{
+  // Set the general tasks/containers
+  MExtractFixedWindow    extractor;
+  extractor.SetRange(hifirst,hilast,lofirst,lolast);
+ 
+  //  MExtractSlidingWindow    extractor;
+  // extractor.SetRange(hifirst,hilast,lofirst,lolast);
+  // extractor.SetWindowSize(2,2);
+  
+  MGeomCamMagic       geomcam;
+  MGeomApply          geomapl;
+
+  /************************************/
+  /* FIRST LOOP: PEDESTAL COMPUTATION */
+  /************************************/
+
+  // If you want to exclude pixels from the beginning, read 
+  // an ascii-file with the corr. pixel numbers (see MBadPixelsCam)  
+  //badcam.AsciiRead("badpixels.dat");
+
+  MJPedestal pedloop;
+  pedloop.SetInput(&pediter);
+  pedloop.SetExtractor(&extractor);
+  //  pedloop.SetBadPixels(badcam);
+
+  if (!pedloop.Process())
+    return;
+
+  /*****************************/
+  /* SECOND LOOP: CALIBRATION  */
+  /*****************************/        
+
+  MJCalibration calloop;
+
+  calloop.SetExtractor(&extractor);
+  calloop.SetInput(&caliter);
+  calloop.SetBadPixels(pedloop.GetBadPixels());
+  if(calflag==2)
+    calloop.SetUseBlindPixel();
+
+  if(calflag>0)
+    if (!calloop.Process(pedloop.GetPedestalCam()))
+      return;
+
+  Float_t meanCharge[577];
+  Float_t meanSigma[577];
+  Float_t meanFADC2Phe[577];
+  Float_t meanFADCtoPh[577];
+  Float_t prob[577];
+  ofstream fout;
+
+  fout.open(outname);
+
+  for (Int_t i=0; i<577; i++)
+    {
+      meanCharge[i] = 0;
+      MCalibrationChargePix calpix = (MCalibrationChargePix&)(calloop.GetCalibrationCam())[i];
+      MCalibrationQEPix qepix = ( MCalibrationQEPix&)(calloop.GetQECam())[i];
+      meanCharge[i] = calpix.GetMean();
+      meanSigma[i] = calpix.GetSigma();
+      meanFADC2Phe[i]=calpix.GetMeanConvFADC2Phe();
+      meanFADCtoPh[i]=calpix.GetMeanConvFADC2Phe()/qepix.GetQECascadesFFactor(0);
+      prob[i]=calpix.GetProb();
+      fout << i << '\t' << meanCharge[i] << '\t' << meanSigma[i]<< '\t' << meanFADC2Phe[i]<< '\t' <<meanFADCtoPh[i]<< '\t' <<prob[i]<< '\t' <<(Int_t)calpix.IsHiGainSaturation()<<endl;
+    }
+
+  fout.close();
+
+  return;
+
+}
+//-------------------------------------------------------------------------------
+
+Bool_t readDatacards(TString& filename)
+{
+  ifstream ifun(filename.Data());
+  if(!ifun)
+    {
+      cout << "File " << filename << " not found" << endl;
+      return kFALSE;
+    }
+
+  TString word;
+  
+  while(ifun >> word)
+    {
+      // skip comments
+      if(word[0]=='/' && word[1]=='/')
+	{
+	  while(ifun.get()!='\n'); // skip line
+	  continue;
+	}
+
+      // input file directory
+      if(strcmp(word.Data(),"IDIR")==0)
+	{
+	  if(idirname.Length())
+	    cout << "readDataCards Warning: overriding input directory file name" << endl;
+	  ifun >> idirname;
+	}
+
+      // pedestal runs
+      if(strcmp(word.Data(),"PRUNS")==0)
+	{
+	  if(pediter.GetNumRuns())
+	    cout << "readDataCards Warning: adding pedestal runs to the existing list" << endl;
+	  ifun >> word;
+	  pediter.AddRuns(word.Data(),idirname.Data());
+	}
+
+      // calibration runs
+      if(strcmp(word.Data(),"CRUNS")==0)
+	{
+	  if(caliter.GetNumRuns())
+	    cout << "readDataCards Warning: adding calibration runs to the existing list" << endl;
+	  ifun >> word;
+	  caliter.AddRuns(word.Data(),idirname.Data());
+	}
+
+      // output file name
+      if(strcmp(word.Data(),"OUTFILE")==0)
+	{
+	  if(outname.Length())
+	    cout << "readDataCards Warning: overriding output file name" << endl;
+	  ifun >> outname;
+	}
+
+      // calibration flag
+      if(strcmp(word.Data(),"CALFLAG")==0)
+	ifun >> calflag;
+
+
+    }
+
+  pediter.Reset();
+  caliter.Reset();
+  datiter.Reset();
+  TString pfile;
+
+  // Dump read values
+  cout << "************************************************" << endl;
+  cout << "* Datacards read from file " << filename << endl;
+  cout << "************************************************" << endl;
+  cout << "Pedestal file (s): "  << endl;
+  while(!(pfile=pediter.Next()).IsNull())
+    cout << pfile << endl;
+  cout << "Calibration file (s): "  << endl;
+  while(!(pfile=caliter.Next()).IsNull())
+    cout << pfile << endl;
+  cout << "Output file name: " << outname << endl;
+  cout << "Calibration: ";
+  if(calflag==0)    
+    cout << "Pixel area proportional intercalibration" << endl;
+  else if(calflag==-1)    
+    cout << "No calibration whatsoever" << endl;
+  else if(calflag==1)
+    cout << "Default calibration" << endl;
+  else if(calflag==11)
+    cout << "Default calibration + bad pixels interpolation" << endl;
+  
+  if(!pediter.GetNumEntries())
+    {
+      cout << "No pedestal file name specified" << endl;
+      return kFALSE;
+    }
+  if(!caliter.GetNumEntries() && calflag>0)
+    {
+      cout << "No calibration file name specified" << endl;
+      return kFALSE;
+    }
+  if(!outname.Length())
+    {
+      cout << "No output file name specified" << endl;
+      return kFALSE;
+    }
+
+
+  return kTRUE;
+}
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/calib.datacard
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/calib.datacard	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/calib.datacard	(revision 9661)
@@ -0,0 +1,32 @@
+/////////////////////////////////////////////////////////
+// Data card template for calib executable             //
+//                                                     //
+// *** Compulsory cards are:                           //
+// PRUNS, CRUNS, DRUNS, OUTFILE                        //
+//                                                     //
+// the rest are optional                               //
+// *** Do NEVER add a datacard with no value after it  //
+/////////////////////////////////////////////////////////
+
+
+// data file directory
+IDIR /nfs/magic/CCdata/rootdata/Mrk421/Period016/2004_04_22/
+
+// Pedestal (PRUNS), calibration (CRUNS)
+PRUNS 30150
+CRUNS 30148
+
+// output file name
+OUTFILE ./prueba.root
+
+// calibration flag:
+// -1: kDummy
+//  0: kNone
+//  1: kDefault (F factor)
+//  2: kDefault (Blind Pixels)
+// 11: kDefault + bad pixel interpolation
+CALFLAG 1
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/controlPlot.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/controlPlot.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/controlPlot.cc	(revision 9661)
@@ -0,0 +1,346 @@
+////////////////////////////////////////////////////////////////////////////////////
+//
+//             _____ Control Plot program_____
+//
+//  Take as input root files with hillas parameters and generates several
+//  control plots.
+//  Output is a file with :
+//       - Number of hits plot
+//
+//                 Ester Aliu   <aliu@ifae.es>
+//                 Oscar Blanch <blanch@ifae.es>
+//                 Javier Rico  <jrico@ifae.es>
+////////////////////////////////////////////////////////////////////////////////////
+
+#include <fstream>
+#include <iostream>
+
+#include "TString.h"
+
+#include "MHillasSrcCalc.h"
+#include "MHillasSrc.h"
+#include "MSrcRotate.h"
+#include "MSrcPosFromFile.h"
+#include "MSrcTranslate.h"
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MHillas.h"
+#include "MReadTree.h"
+#include "MEvtLoop.h"
+#include "MLog.h"
+#include "MArgs.h"
+#include "MWriteRootFile.h"
+#include "MTime.h"
+#include "MControlPlots.h"
+#include "MIslands.h"
+#include "MContinue.h"
+#include "MF.h"
+
+using namespace std;
+
+Bool_t readDatacards(TString& filename);
+void controlPlot();
+
+//-----------------------------------------------------------------------------
+// declaration of variables read from datacards
+//-----------------------------------------------------------------------------
+
+TString  inputFile;
+TString  offFile;
+TString  outputFile;
+TString  filter;
+TString  sizecut;
+TString  distcut;
+TString  widthcut;
+TString  lengthcut;
+TString  centercut;
+ULong_t  nmaxevents=999999999;
+Float_t  xsrcpos=0.;
+Float_t  ysrcpos=0.;
+Double_t mjdpos=0;
+
+//-----------------------------------------------------------------------------
+// constants
+//-----------------------------------------------------------------------------
+
+const TString defaultcard="srcpos.datacard";
+const Float_t conver   = 189./0.6; // conversion factor degrees to mm
+
+//-----------------------------------------------------------------------------
+
+static void Usage()
+{
+  gLog <<endl;
+  gLog << "Usage is:" << endl;
+  gLog << "   controlPlot [-h] [-?] <datacards>" << endl << endl;
+  gLog << "     <datacards>: datacards file name (dafault " << defaultcard <<")" << endl;
+  gLog << "     -?/-h: This help" << endl << endl;
+}
+
+//-----------------------------------------------------------------------------
+int main(int argc, char **argv)
+{
+  // evaluate arguments
+  MArgs arg(argc, argv);
+  if (arg.HasOnly("-?") || arg.HasOnly("-h") || arg.HasOnly("--help"))
+    {
+      Usage();
+      return -1;
+    }
+
+  TString datacard  = arg.GetArgumentStr(0);
+  if(!datacard.Length())
+    datacard = defaultcard;
+
+  if(!readDatacards(datacard))
+    {
+      cout << "Error reading datacards. Stoping" << endl;
+      return -1;
+    }
+
+  controlPlot();
+}
+
+//-----------------------------------------------------------------------------
+void  controlPlot()
+{
+  // containers
+  MParList  plist;  
+  MTaskList tlist;
+  MIslands  islands;
+
+  // include containers in parameter list
+  plist.AddToList(&tlist);
+  plist.AddToList(&islands);
+	  	  
+  MF cut(filter);
+  MF cutS(sizecut);
+  MF cutD(distcut);
+  MF cutL(lengthcut);
+  MF cutW(widthcut);
+  MF cutC(centercut);
+
+  // tasks
+  MReadTree read("Parameters", inputFile);
+  read.DisableAutoScheme();  
+
+  MControlPlots controlplots(outputFile);
+  controlplots.SetProduceFile(kFALSE);
+  
+  MContinue applycutS(&cutS);
+  applycutS.SetInverted(kTRUE);
+
+  MContinue applycutD(&cutD);
+  applycutD.SetInverted(kTRUE);
+
+  MContinue applycutL(&cutL);
+  applycutL.SetInverted(kTRUE);
+
+  MContinue applycutW(&cutW);
+  applycutW.SetInverted(kTRUE);
+
+  MContinue applycutC(&cutC);
+  applycutC.SetInverted(kTRUE);
+
+  MContinue applycut(&cut);
+  applycut.SetInverted(kTRUE);
+
+
+  // include tasks in task list
+  tlist.AddToList(&read);
+  if(sizecut.Length())
+    tlist.AddToList(&applycutS);
+  if(distcut.Length())
+    tlist.AddToList(&applycutD);
+  if(lengthcut.Length())
+    tlist.AddToList(&applycutL);
+  if(widthcut.Length())
+    tlist.AddToList(&applycutW);
+  if(centercut.Length())
+    tlist.AddToList(&applycutC);
+  if(filter.Length())
+    tlist.AddToList(&applycut);
+  tlist.AddToList(&controlplots);
+
+  // Eventloop
+  MEvtLoop evtloop;
+  evtloop.SetParList(&plist);
+  if (!evtloop.Eventloop(nmaxevents))
+    return;  
+ 
+  tlist.PrintStatistics();
+  
+  // do off-data if input file was specified
+  if(!offFile.Length())
+    return;
+
+  MReadTree read2("Parameters", offFile);
+  read2.DisableAutoScheme();  
+  tlist.AddToListBefore(&read2, &read, "All");
+  tlist.RemoveFromList(&read);
+
+  controlplots.SetMode(MControlPlots::kOff);
+  controlplots.SetProduceFile(kTRUE);
+
+  if (!evtloop.Eventloop(nmaxevents))
+    return;  
+
+  tlist.PrintStatistics();
+}
+//-----------------------------------------------------------------------
+  
+Bool_t readDatacards(TString& filename)
+{
+  ifstream ifun(filename.Data());
+  if(!ifun)
+    {
+      cout << "File " << filename << " not found" << endl;
+      return kFALSE;
+    }
+
+  TString word;
+  
+  while(ifun >> word)
+    {
+      // skip comments
+      if(word[0]=='/' && word[1]=='/')
+	{
+	  while(ifun.get()!='\n'); // skip line
+	  continue;
+	}
+      
+      // number of events
+      if(strcmp(word.Data(),"NEVENTS")==0)
+	ifun >> nmaxevents;
+
+      // input file name
+      if(strcmp(word.Data(),"ONFILES")==0)
+	{
+	  if(inputFile.Length())
+	    cout << "readDataCards Warning: overriding on-data file name" << endl;
+	  ifun >> inputFile;
+	}
+
+      // off-data file name
+      if(strcmp(word.Data(),"OFFFILES")==0)
+	{
+	  if(offFile.Length())
+	    cout << "readDataCards Warning: overriding off-data file name" << endl;
+	  ifun >> offFile;
+	}
+
+      // output file name
+      if(strcmp(word.Data(),"HITSFILE")==0)
+	{
+	  if(outputFile.Length())
+	    cout << "readDataCards Warning: overriding output file name" << endl;
+	  ifun >> outputFile;
+	}
+      // exclusion cut
+      if(strcmp(word.Data(),"FILTER")==0)
+	{
+	  if(filter.Length())
+	    cout << "readDataCards Warning: overriding existing cut" << endl;
+	  
+	  char ch;
+	  while((ch=ifun.get())!='\n')
+	    filter.Append(ch);	  
+	}
+      if(strcmp(word.Data(),"SIZECUT")==0)
+	{
+	  if(sizecut.Length())
+	    cout << "readDataCards Warning: overriding existing size cut" << endl;
+	  char ch[10];
+	  sizecut="(MHillas.fSize>";
+	  ifun >> ch;
+	  sizecut+=ch;
+	  sizecut+=") && (MHillas.fSize<";
+	  ifun >> ch;
+	  sizecut+=ch;
+	  sizecut+=")";
+	}
+      if(strcmp(word.Data(),"DISTCUT")==0)
+	{
+	  if(distcut.Length())
+	    cout << "readDataCards Warning: overriding existing DIST cut" << endl;
+	  char ch[10];
+	  distcut="(MHillasSrc.fDist>";
+	  ifun >> ch;
+	  distcut+=ch;
+	  distcut+=") && (MHillasSrc.fDist<";
+	  ifun >> ch;
+	  distcut+=ch;
+	  distcut+=")";
+	}
+      if(strcmp(word.Data(),"WIDTHCUT")==0)
+	{
+	  if(widthcut.Length())
+	    cout << "readDataCards Warning: overriding existing width cut" << endl;
+	  char ch[10];
+	  widthcut="(MHillas.fWidth>";
+	  ifun >> ch;
+	  widthcut+=ch;
+	  widthcut+=") && (MHillas.fWidth<";
+	  ifun >> ch;
+	  widthcut+=ch;
+	  widthcut+=")";
+	}
+      if(strcmp(word.Data(),"LENGTHCUT")==0)
+	{
+	  if(lengthcut.Length())
+	    cout << "readDataCards Warning: overriding existing length cut" << endl;
+	  char ch[10];
+	  lengthcut="(MHillas.fLength>";
+	  ifun >> ch;
+	  lengthcut+=ch;
+	  lengthcut+=") && (MHillas.fLength<";
+	  ifun >> ch;
+	  lengthcut+=ch;
+	  lengthcut+=")";
+	}
+      if(strcmp(word.Data(),"CENTERCUT")==0)
+	{
+	  if(centercut.Length())
+	    cout << "readDataCards Warning: overriding existing center cut" << endl;
+	  char ch[10];
+	  centercut="sqrt(MHillas.fMeanX*MHillas.fMeanX+MHillas.fMeanY*MHillas.fMeanY) < 0.00317*";
+	  ifun >> ch;
+	  centercut+=ch;
+	}
+    }
+  
+  // check compulsory values
+  if(!inputFile.Length())
+    {
+      cout << "No on-data file name specified" << endl;
+      return kFALSE;
+    }
+
+  if(!offFile.Length())
+    {
+      cout << "No off-data file name specified" << endl;
+      return kFALSE;
+    }
+
+  if(!outputFile.Length())
+    {
+      cout << "No output file name specified" << endl;
+      return kFALSE;
+    }
+
+  MTime thetime(mjdpos);
+
+  // Dump read values
+  cout << "************************************************" << endl;
+  cout << "* Datacards read from file " << filename << endl;
+  cout << "************************************************" << endl;
+  cout << "Maximum number of input events: " << nmaxevents << endl;
+  cout << "Input file name(s): " << inputFile << endl;
+  cout << "Input file name(s) for off data: " << offFile << endl;
+  cout << "Output file name for # hits plot : " << outputFile << endl;
+  if(filter.Length())
+    cout << "Applying rejection cut: " << filter << endl;
+  cout << "***********" << endl << endl;
+
+  return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/controlplot.datacard
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/controlplot.datacard	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/controlplot.datacard	(revision 9661)
@@ -0,0 +1,38 @@
+
+// Maximun number of on and off events to be processed)
+NEVENTS 99999999
+
+// On-data file name pattern
+ONFILES  ./srcPosPrueba.root
+
+// Off-data file name pattern
+OFFFILES ./srcPosOffPrueba.root
+
+// output file name
+HITSFILE  ./rotateprueba2.ps
+
+//////////
+// CUTS //
+//////////
+
+// Size cut (lower and upper) in # of photons
+SIZECUT   2000   9999999
+
+// Dist cut (lower and upper) in degrees
+DISTCUT   0.2   1.1
+
+// Width cut (lower and upper) in degrees
+WIDTHCUT  0  0.12
+
+// Length cut (lower and upper) in degrees
+LENGTHCUT  0  0.26
+
+// maxX and maxY upper cut in degrees
+CENTERCUT  1.1 
+
+// Other Additional cut
+// Selection cut. 
+// Condition "==" not supported.
+// Enclose all conditions between brakets, like: "(x<y) && (z<5)"
+// (see MF description class for more details)
+// FILTER (MHillas.fLength<100) && (MHillas.fLength>50)
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/falseSource.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/falseSource.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/falseSource.cc	(revision 9661)
@@ -0,0 +1,555 @@
+////////////////////////////////////////////////////////////////////////////////////
+//
+//             _____False Source Method macro_____
+//
+//  Take as input root files with hillas parameters, perform derotation (optional)
+//  and generates the alpha histograms for On and Off for different positions of the
+//  source. These histos can be ploted with signal.C and signalPoint.C
+//
+//                 Ester Aliu   <aliu@ifae.es>
+//                 Oscar Blanch <blanch@ifae.es>
+//                 Javier Rico  <jrico@ifae.es>
+////////////////////////////////////////////////////////////////////////////////////
+
+#include <fstream>
+#include <iostream>
+
+#include "TString.h"
+#include "TH2F.h"
+#include "TFile.h"
+
+#include "MHillasSrcCalc.h"
+#include "MSrcPosCam.h"
+#include "MSrcTranslate.h"
+#include "MHillasSrc.h"
+#include "MSrcRotate.h"
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MHillas.h"
+#include "MReadTree.h"
+#include "MEvtLoop.h"
+#include "MLog.h"
+#include "MArgs.h"
+
+using namespace std;
+
+Bool_t readDatacards(TString& filename);
+void falseSource();
+
+//-----------------------------------------------------------------------------
+// declaration of variables read from datacards
+//-----------------------------------------------------------------------------
+
+TString onFile;
+TString offFile;
+TString outputFile;
+Bool_t  kRotate=1;
+Bool_t  kSrcPolicy=kFALSE;
+Double_t fRA= -1.;
+Double_t fDEC= -1.;
+ULong_t nmaxevents=999999999;
+
+// cuts (default values to be overriden by datacards)
+Float_t minsize   = 0;        // minimum size (# of photons)
+Float_t maxsize   = 9999999;  // maximum size (# of photons)
+Float_t mindist   = 0;        // minimum distance cut (deg)
+Float_t maxdist   = 10;       // maximum distance cut (deg)
+Float_t minwidth  = 0.;       // minimum width cut (deg)
+Float_t maxwidth  = 10;       // maximum width cut (deg)
+Float_t minlength = 0;        // minimum length cut (deg)
+Float_t maxlength = 10;       // maximum length cut (deg)
+Float_t maxXY     = maxdist;  // maximum X and Y distance from the camera center
+
+// binning
+Int_t binning = 21;           // number of bins in false source search (one coordinate) 
+Int_t nbin    = 18;           // number of bins for alpha plots
+Float_t field = 2.;           // width of the examined field (degrees)
+
+//-----------------------------------------------------------------------------
+// constants
+//-----------------------------------------------------------------------------
+
+const TString defaultcard="falsesource.datacard";
+
+const Float_t alphamin = 0.;       // minimum value in alpha (degrees) 
+const Float_t alphamax = 90.;      // maximum value in alpha (degrees)
+const Float_t conver   = 189./0.6; // conversion factor degrees to mm
+const Float_t srclimit = field*conver;
+const Float_t srcstep  = 3.;
+const Int_t   nsrcbin  = (Int_t) (srclimit/srcstep);
+
+//-----------------------------------------------------------------------------
+
+static void Usage()
+{
+  gLog <<endl;
+  gLog << "Usage is:" << endl;
+  gLog << "   falseSource [-h] [-?] <datacards>" << endl << endl;
+  gLog << "     <datacards>: datacards file name (dafault falsesource.datacards)" << endl;
+  gLog << "     -?/-h: This help" << endl << endl;
+}
+
+//-----------------------------------------------------------------------------
+int main(int argc, char **argv)
+{
+  // evaluate arguments
+  MArgs arg(argc, argv);
+  if (arg.HasOnly("-?") || arg.HasOnly("-h") || arg.HasOnly("--help"))
+    {
+      Usage();
+      return -1;
+    }
+
+  TString datacard  = arg.GetArgumentStr(0);
+  if(!datacard.Length())
+    datacard = defaultcard;
+
+  if(!readDatacards(datacard))
+    {
+      cout << "Error reading datacards. Stoping" << endl;
+      return -1;
+    }
+  falseSource();
+}
+
+void falseSource()
+{
+  // CUTS
+
+  // variable declaration  
+  Float_t xpos;
+  Float_t ypos;  
+  Char_t name[20]; 
+  Char_t title[50];   
+  Float_t stepDegrees = field/(binning-1);    // degrees
+  Float_t step        = stepDegrees*conver;   // mm
+  Int_t   ival        =  (Int_t) ceil((Float_t)(binning-1)/2); // index bound
+  
+  // Hillas variables
+  Float_t alpha;
+  Float_t size;
+  Float_t dist;  
+  Float_t length;
+  Float_t width;
+  Float_t meanX;
+  Float_t meanY;
+  
+  // create the histograms (empty)
+  TH1F* hOnAlpha[binning][binning];
+  TH1F* hOffAlpha[binning][binning];
+  TH2F* hOnSrcPos[binning];
+  TH2F* hOffSrcPos[binning];
+
+  for(Int_t i = -ival; i <= ival ; i++){  
+    for(Int_t j = -ival; j <= ival ; j++){
+      
+      sprintf(name,"hOnAlpha[%d][%d]", i, j);
+      sprintf(title,"Alpha-Plot(On data) (%d ,%d)", i, j);
+      hOnAlpha[i+ival][j+ival] = new TH1F(name, title, nbin, alphamin, alphamax);
+      
+      sprintf(name,"hOffAlpha[%d][%d]", i, j);
+      sprintf(title,"Alpha-Plot(Off data) (%d ,%d)", i, j);
+      hOffAlpha[i+ival][j+ival] = new TH1F(name, title, nbin, alphamin, alphamax);
+
+      if(j==0)
+	{
+	  sprintf(name,"hOnSrcPos[%d]", i);
+	  sprintf(title,"Source position (On data) (%d)", i);
+	  hOnSrcPos[i+ival] = new TH2F(name, title, nsrcbin, -srclimit, srclimit, nsrcbin, -srclimit, srclimit);
+	  
+	  sprintf(name,"hOffSrcPos[%d]", i);
+	  sprintf(title,"Source position (Off data) (%d)", i);
+	  hOffSrcPos[i+ival] = new TH2F(name, title, nsrcbin, -srclimit, srclimit, nsrcbin, -srclimit, srclimit);
+	}
+    }
+  }
+  
+
+  
+  /******************************************************************
+                           FILL ON-DATA HISTOS
+  *******************************************************************/
+  
+  // source dependent hillas containers/tasks
+  MSrcPosCam*     source[binning][binning];
+  MHillasSrc*     hillasSrc[binning][binning];
+  MSrcTranslate*  srctranslate[binning][binning];
+  MSrcRotate*     srcrotate[binning][binning];
+  MHillasSrcCalc* csrc1[binning][binning];
+
+  // normal containers/classes
+  MParList  plist;  
+  MTaskList tlist;
+  MHillas   hillas;
+
+  plist.AddToList(&tlist);
+  plist.AddToList(&hillas);
+    
+  MReadTree read("Parameters", onFile);
+  read.DisableAutoScheme();  
+  tlist.AddToList(&read);
+    
+  char sourceName[100];  
+  char hillasSrcName[100];
+  char translateName[100];  
+  char rotateName[100];
+
+  // create the tasks/containers for the different source positions
+  for(Int_t i=-ival;i<=ival;i++)
+    {    
+      xpos = step*i;      
+      for(Int_t j=-ival;j<=ival;j++)
+	{
+	  ypos = step*j;
+	  
+	  // name the different containers
+	  if (i<0 && j<0)
+	    {
+	      Int_t k = -i;
+	      Int_t l = -j;
+	      sprintf(sourceName,    "MSrcPosCam_Min%dMin%d", k, l);
+	      sprintf(hillasSrcName, "MHillasSrc_Min%dMin%d", k, l);
+	      sprintf(translateName, "MSrcTranslate_Min%dMin%d", k, l);
+	      sprintf(rotateName,    "MSrcRotate_Min%dMin%d", k, l);
+	    }
+	  
+	  if (i<0 && j>=0)
+	    {
+	      Int_t k = -i;
+	      sprintf(sourceName,    "MSrcPosCam_Min%d%d", k, j);
+	      sprintf(hillasSrcName, "MHillasSrc_Min%d%d", k, j);
+	      sprintf(translateName, "MSrcTranslate_Min%d%d", k, j);
+	      sprintf(rotateName,    "MSrcRotate_Min%d%d", k, j);
+	    }
+	  
+	  if (i>=0 && j<0)
+	    {
+	      Int_t l = -j;
+	      sprintf(sourceName,    "MSrcPosCam_%dMin%d", i, l);
+	      sprintf(hillasSrcName, "MHillasSrc_%dMin%d", i, l);
+	      sprintf(translateName, "MSrcTranslate_%dMin%d", i, l);
+	      sprintf(rotateName,    "MSrcRotate_%dMin%d", i, l);
+	    }
+	  
+	  if (i>=0 && j>= 0)
+	    {
+	      sprintf(sourceName,    "MSrcPosCam_%d%d", i, j);
+	      sprintf(hillasSrcName, "MHillasSrc_%d%d", i, j);
+	      sprintf(translateName, "MSrcTranslate_%d%d", i, j);
+	      sprintf(rotateName,    "MSrcRotate_%d%d", i, j);
+	    }
+
+	  // include containers in parameter list
+	  source[i+ival][j+ival] = new MSrcPosCam(sourceName);
+	  plist.AddToList(source[i+ival][j+ival]);
+	  	  
+	  hillasSrc[i+ival][j+ival] = new MHillasSrc(hillasSrcName);	  
+	  plist.AddToList(hillasSrc[i+ival][j+ival]);      
+	  
+	  // define the different tasks and include them in the task list
+	  srctranslate[i+ival][j+ival] = new MSrcTranslate("MSrcPosCam",sourceName,"MDCA",translateName);	  
+	  srctranslate[i+ival][j+ival]->SetTranslation(xpos,ypos);	  
+	  srctranslate[i+ival][j+ival]->SetRelativeTranslation(kSrcPolicy);
+	  srctranslate[i+ival][j+ival]->SetInternalHistoBinSize(5.);
+	  srctranslate[i+ival][j+ival]->SetMode(MSrcPlace::kOn);
+      
+	  tlist.AddToList(srctranslate[i+ival][j+ival]);  
+
+	  if(kRotate && !kSrcPolicy)
+	    {
+	      srcrotate[i+ival][j+ival] = new MSrcRotate(sourceName,sourceName,"MDCA",rotateName);
+	      srcrotate[i+ival][j+ival]->SetRAandDEC(fRA,fDEC);	  
+
+	      srctranslate[i+ival][j+ival]->SetCreateHisto(kFALSE);
+	      srcrotate[i+ival][j+ival]->SetMode(MSrcPlace::kOn);	      
+	      srcrotate[i+ival][j+ival]->SetInternalHistoBinSize(5.);
+
+	      tlist.AddToList(srcrotate[i+ival][j+ival]);  
+	    }
+	  else
+	    srcrotate[i+ival][j+ival] = NULL;
+
+
+	  TString HilName = "MHillas";	  
+	  csrc1[i+ival][j+ival] = new MHillasSrcCalc(sourceName, hillasSrcName);
+	  csrc1[i+ival][j+ival]->SetInput(HilName);  
+	  
+	  tlist.AddToList(csrc1[i+ival][j+ival]);  
+	  
+	} // loop on j (y coordinate)
+    } // loop on i (x coordinate)
+  
+  
+  // Eventloop
+  MEvtLoop evtloop;  
+  evtloop.SetParList(&plist);
+  //  MProgressBar bar;
+  //  evtloop.SetProgressBar(&bar);  
+  if (!evtloop.PreProcess())
+    return;
+  
+  // select the events passing the cuts
+  UInt_t nread=0;
+  while (tlist.Process())
+    {
+      for(Int_t i = -ival; i <= ival ; i++)	
+	for(Int_t j = -ival; j <= ival ; j++)
+	  {
+	    width  = hillas.GetWidth()/conver;
+	    length = hillas.GetLength()/conver;
+	    size   = hillas.GetSize();
+	    dist   = hillasSrc[i+ival][j+ival]->GetDist()/conver;
+	    meanX  = hillas.GetMeanX()/conver;
+	    meanY  = hillas.GetMeanY()/conver;
+	    
+	    if (width<maxwidth && length<maxlength && dist>mindist && dist<maxdist && size>minsize && meanX<maxXY && meanY<maxXY)
+	      {
+		alpha = hillasSrc[i+ival][j+ival]->GetAlpha();
+		hOnAlpha[i+ival][j+ival]->Fill(TMath::Abs(alpha));
+	      }	
+
+	    // fill source position histo
+	    if(j==0)
+	      hOnSrcPos[i+ival]->Fill(source[i+ival][j+ival]->GetX(),source[i+ival][j+ival]->GetY());
+	  }
+      if(++nread>nmaxevents) break;
+    }
+      
+  // end 
+  evtloop.PostProcess();    
+  tlist.PrintStatistics();
+
+
+  /******************************************************************
+                        FILL OFF-DATA HISTOS
+  *******************************************************************/
+ for(Int_t i=-ival;i<=ival;i++)
+   for(Int_t j=-ival;j<=ival;j++)
+     {
+       if(srcrotate[i+ival][j+ival])
+	 srcrotate[i+ival][j+ival]->SetMode(MSrcPlace::kOff);
+       srctranslate[i+ival][j+ival]->SetMode(MSrcPlace::kOff);
+     }
+
+  
+  MReadTree read2("Parameters", offFile);
+  read2.DisableAutoScheme();
+  
+  tlist.AddToListBefore(&read2, &read, "All");
+  tlist.RemoveFromList(&read);
+  
+  if (!evtloop.PreProcess())
+    return;
+
+  nread=0;
+  while (tlist.Process())
+    {
+      for(Int_t i = -ival; i <= ival ; i++)
+	for(Int_t j = -ival; j <= ival ; j++)
+	  {	    
+	    width  = hillas.GetWidth()/conver;
+	    length = hillas.GetLength()/conver;
+	    size   = hillas.GetSize();   
+	    dist   = hillasSrc[i+ival][j+ival]->GetDist()/conver;
+	    meanX  = hillas.GetMeanX()/conver;
+	    meanY  = hillas.GetMeanY()/conver;
+	    
+	    if (width<maxwidth && length<maxlength && dist>mindist && dist<maxdist && size>minsize && meanX<maxXY && meanY<maxXY)
+	      {
+		alpha = hillasSrc[i+ival][j+ival]->GetAlpha();
+		hOffAlpha[i+ival][j+ival]->Fill(TMath::Abs(alpha));	      
+	      } 	
+
+	    // fill source position histo
+	    if(j==0)
+	      hOffSrcPos[i+ival]->Fill(source[i+ival][j+ival]->GetX(),source[i+ival][j+ival]->GetY());
+	  }
+      if(++nread>nmaxevents) break;
+    }
+        
+  evtloop.PostProcess();    
+
+  // Save results
+  TFile *f = new TFile(outputFile, "RECREATE");
+  
+  for(Int_t i = -ival; i <= ival ; i++){  
+    for(Int_t j = -ival; j <= ival ; j++){
+      hOnAlpha[i+ival][j+ival]->Write();
+      hOffAlpha[i+ival][j+ival]->Write();
+      if(j==0)
+	{
+	  hOnSrcPos[i+ival]->Write();
+	  hOffSrcPos[i+ival]->Write();
+	}
+    }
+  }
+
+  f->Close();
+
+ for(Int_t i=-ival;i<=ival;i++)
+   for(Int_t j=-ival;j<=ival;j++)
+     {
+       if(srcrotate[i+ival][j+ival])
+	 delete srcrotate[i+ival][j+ival];
+       delete srctranslate[i+ival][j+ival];
+       delete source[i+ival][j+ival];
+       delete hillasSrc[i+ival][j+ival];
+       delete csrc1[i+ival][j+ival];
+     }
+}
+//-----------------------------------------------------------------------
+  
+Bool_t readDatacards(TString& filename)
+{
+  ifstream ifun(filename.Data());
+  if(!ifun)
+    {
+      cout << "File " << filename << " not found" << endl;
+      return kFALSE;
+    }
+
+  TString word;
+  
+  while(ifun >> word)
+    {
+      // skip comments
+      if(word[0]=='/' && word[1]=='/')
+	{
+	  while(ifun.get()!='\n'); // skip line
+	  continue;
+	}
+
+      // number of events
+      if(strcmp(word.Data(),"NEVENTS")==0)
+	ifun >> nmaxevents;
+
+      // on-data file name
+      if(strcmp(word.Data(),"ONFILES")==0)
+	{
+	  if(onFile.Length())
+	    cout << "readDataCards Warning: overriding on-data file name" << endl;
+	  ifun >> onFile;
+	}
+
+      // off-data file name
+      if(strcmp(word.Data(),"OFFFILES")==0)
+	{
+	  if(offFile.Length())
+	    cout << "readDataCards Warning: overriding off-data file name" << endl;
+	  ifun >> offFile;
+	}
+
+      // output file name
+      if(strcmp(word.Data(),"OUTFILE")==0)
+	{
+	  if(outputFile.Length())
+	    cout << "readDataCards Warning: overriding output file name" << endl;
+	  ifun >> outputFile;
+	}
+
+      // rotation flag
+      if(strcmp(word.Data(),"ROTFLAG")==0)
+	ifun >> kRotate;
+
+      // source movement policy flag
+      if(strcmp(word.Data(),"SRCABS")==0)
+	ifun >> kSrcPolicy;	  
+
+
+      // source celestial coordinates 
+      if(strcmp(word.Data(),"SRCCOORDS")==0)
+	{
+	  ifun >> fRA;
+	  ifun >> fDEC;	  
+	}
+
+      // field width
+      if(strcmp(word.Data(),"FIELD")==0)
+	ifun >> field;
+
+      // binning
+      if(strcmp(word.Data(),"BINNING")==0)
+	ifun >> binning;
+
+      // Number of bins in alpha plots
+      if(strcmp(word.Data(),"NBIN")==0)
+	ifun >> nbin;
+
+      // size cut
+      if(strcmp(word.Data(),"SIZECUT")==0)
+	{
+	  ifun >> minsize;
+	  ifun >> maxsize;	  
+	}
+
+      // dist cut
+      if(strcmp(word.Data(),"DISTCUT")==0)
+	{
+	  ifun >> mindist;
+	  ifun >> maxdist;	  
+	}
+
+      // width cut
+      if(strcmp(word.Data(),"WIDTHCUT")==0)
+	{
+	  ifun >> minwidth;
+	  ifun >> maxwidth;	  
+	}
+      
+      // length cut
+      if(strcmp(word.Data(),"LENGTHCUT")==0)
+	{
+	  ifun >> minlength;
+	  ifun >> maxlength;	  
+	}
+
+      // maxX and maxY upper cut
+      if(strcmp(word.Data(),"CENTERCUT")==0)
+	ifun >> maxXY;	  
+    }
+
+  // check compulsory values
+  if(!onFile.Length())
+    {
+      cout << "No on-data file name specified" << endl;
+      return kFALSE;
+    }
+  if(!offFile.Length())
+    {
+      cout << "No off-data file name specified" << endl;
+      return kFALSE;
+    }
+  if(!outputFile.Length())
+    {
+      cout << "No output file name specified" << endl;
+      return kFALSE;
+    }
+
+
+  // Dump read values
+  cout << "************************************************" << endl;
+  cout << "* Datacards read from file " << filename << endl;
+  cout << "************************************************" << endl;
+  cout << "Maximum number of input events: " << nmaxevents << endl;
+  cout << "On-data file name(s): " << onFile << endl;
+  cout << "Off-data file name(s): " << offFile << endl;
+  cout << "Output file name: " << outputFile << endl;
+  if(kSrcPolicy)
+    cout << "Source position displaced with respect to the original existing one (no rotation applied)" << endl;
+  else
+    {
+      cout << "De-rotation flag " << kRotate << endl;
+      cout << "Source celestial coordiantes (rad): RA = " << fRA << ", DEC = " << fDEC << endl;
+    }
+  cout << "Field width (degrees): " << field << endl;
+  cout << "Field binning: " << binning << endl;
+  cout << "Number of alpha plot bins: " << nbin << endl;
+  cout << "Size cuts (# of photons): ("<<minsize<<","<<maxsize<<")" << endl;
+  cout << "Dist cuts (degrees): ("<<mindist<<","<<maxdist<<")" << endl;
+  cout << "Length cuts (degrees): ("<<minlength<<","<<maxlength<<")" << endl;
+  cout << "Width cuts (degrees): ("<<minwidth<<","<<maxwidth<<")" << endl;
+  cout << "maxX and maxY upper cut (degrees): " << maxXY << endl;
+  cout << "***********" << endl << endl;
+
+  return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/falsesource.datacard
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/falsesource.datacard	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/falsesource.datacard	(revision 9661)
@@ -0,0 +1,53 @@
+
+// Maximun number of on and off events to be processed)
+NEVENTS 99999999
+
+// On-data file name pattern
+ONFILES  ./srcPosPrueba.root
+
+// Off-data file name pattern
+OFFFILES ./srcPosOffPrueba.root
+
+// output file name
+OUTFILE  ./rotateprueba2.root
+
+// rotation flag:
+//  0: Do not rotate
+//  1: Do rotate
+ROTFLAG 1
+
+// source coordinates (RA DEC in rads)
+SRCCOORDS 1.46 0.384
+
+// Flag to determine whether source position is absolute (0) or relative to previous position (1)
+// In case SRCABS=1, no rotation is carried out
+SRCABS 1 
+
+// Width of examined field (degrees)
+FIELD 2
+
+// Number of source positions in one direction (total grid positions BINNING*BINNING)
+BINNING 11
+
+// Number of bins in alpha plots
+NBIN 18
+
+
+//////////
+// CUTS //
+//////////
+
+// Size cut (lower and upper) in # of photons
+SIZECUT   2000   9999999
+
+// Dist cut (lower and upper) in degrees
+DISTCUT   0.2   1.1
+
+// Width cut (lower and upper) in degrees
+WIDTHCUT  0  0.12
+
+// Length cut (lower and upper) in degrees
+LENGTHCUT  0  0.26
+
+// maxX and maxY upper cut in degrees
+CENTERCUT  1.1 
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/makeHillas.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/makeHillas.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/makeHillas.cc	(revision 9661)
@@ -0,0 +1,615 @@
+/*********************************/
+/* Compute the hillas parameters */
+/*********************************/
+
+#include "TString.h"
+#include "TArrayS.h"
+
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MPedestalCam.h"
+#include "MBadPixelsCam.h"
+#include "MBadPixelsTreat.h"
+#include "MReadMarsFile.h"
+#include "MGeomApply.h"
+#include "MPedCalcPedRun.h"
+#include "MEvtLoop.h"
+#include "MGeomCamMagic.h"
+#include "MExtractedSignalCam.h"
+#include "MCalibrationChargeCam.h"
+#include "MHCalibrationChargeCam.h"
+#include "MHCalibrationRelTimeCam.h"
+#include "MExtractor.h"
+#include "MExtractFixedWindow.h"
+#include "MExtractSlidingWindow.h"
+#include "MExtractSignal.h"
+#include "MCalibrationChargeCalc.h"
+#include "MFCosmics.h"
+#include "MContinue.h"
+#include "MLog.h"
+#include "MCerPhotEvt.h"
+#include "MPedPhotCam.h"
+#include "MCalibrate.h"
+#include "MPedPhotCalc.h"
+#include "MHillas.h"
+#include "MNewImagePar.h"
+#include "MRawRunHeader.h"
+#include "MSrcPosCam.h"
+#include "MBlindPixelCalc.h"
+#include "MImgCleanStd.h"
+#include "MHillasSrcCalc.h"
+#include "MHillasCalc.h"
+#include "MArrivalTimeCam.h"
+#include "MArrivalTimeCalc2.h"
+#include "MIslands.h"
+#include "MIslandCalc.h"
+#include "MIslandClean.h"
+#include "MWriteRootFile.h"
+#include "MArgs.h"
+#include "MRunIter.h"
+#include "MJPedestal.h"
+#include "MJCalibration.h"
+#include "MHillasDisplay.h"
+#include "MF.h"
+#include "MContinue.h"
+
+#include "TApplication.h"
+
+#include <iostream>
+#include <fstream>
+#include <stdlib.h>
+
+using namespace std;
+
+Bool_t readDatacards(TString& filename);
+void makeHillas();
+
+// initial and final time slices to be used in signal extraction
+const Byte_t hifirst = 1;
+const Byte_t hilast  = 14;
+const Byte_t lofirst = 3;
+const Byte_t lolast  = 14;
+
+// declaration of variables read from datacards
+TString  outname;
+const TString outpath = "./";
+TString  idirname;
+TString  filter;
+TString  psfilename("makehillas.ps");
+MRunIter pedcaliter;
+MRunIter caliter;
+MRunIter pediter;
+MRunIter datiter;
+UInt_t   display   = 0;
+ULong_t  nmaxevents= 999999999;
+Short_t  calflag   = 1;
+Bool_t  caltimeflag   = kFALSE;
+Short_t  cleanflag   = 1;
+UShort_t  lrings     = 1;
+Float_t  lcore     = 3.0;
+Float_t  ltail     = 1.5;
+Int_t    islflag   = 0;
+Float_t  lnew      = 40;
+Int_t    kmethod   = 1;
+Int_t    kalgorithm = 1;
+Int_t    nfiles    = 0;
+
+const TString defaultcard="makehillas.datacard";
+/*************************************************************/
+static void Usage()
+{
+  gLog <<endl;
+  gLog << "Usage is:" << endl;
+  gLog << "   makeHillas [-h] [-?] <datacards>" << endl << endl;
+  gLog << "     <datacards>: datacards file name (dafault input.datacards)" << endl;
+  gLog << "     -?/-h: This help" << endl << endl;
+}
+/*************************************************************/
+int main(int argc, char **argv)
+{
+  // create a TApplication to be able to 
+  TApplication app("Application",0,0);
+
+  // evaluate arguments
+  MArgs arg(argc, argv);
+  if (arg.HasOnly("-?") || arg.HasOnly("-h") || arg.HasOnly("--help"))
+    {
+      Usage();
+      return -1;
+    }
+
+  TString datacard  = arg.GetArgumentStr(0);
+  if(!datacard.Length())
+    datacard = defaultcard;
+
+  if(!readDatacards(datacard))
+    {
+      cout << "Error reading datacards. Stoping" << endl;
+      return -1;
+    }
+
+  makeHillas();
+}
+
+/*************************************************************/
+void makeHillas()
+{
+  // Set the general tasks/containers
+  //MExtractFixedWindow    extractor;
+  //extractor.SetRange(hifirst,hilast,lofirst,lolast);
+ 
+  MExtractSlidingWindow    extractor;
+  extractor.SetRange(hifirst,hilast,lofirst,lolast);
+  extractor.SetWindowSize(4,4);
+  
+  MGeomCamMagic       geomcam;
+  MGeomApply          geomapl;
+
+  /************************************/
+  /* FIRST LOOP: PEDESTAL COMPUTATION */
+  /************************************/
+
+  // If you want to exclude pixels from the beginning, read 
+  // an ascii-file with the corr. pixel numbers (see MBadPixelsCam)  
+  //badcam.AsciiRead("badpixels.dat");
+
+  MJPedestal pedcalloop;
+  pedcalloop.SetInput(&pediter);
+  pedcalloop.SetExtractor(&extractor);
+  //  pedloop.SetBadPixels(badcam);
+  //pedcalloop.SetOutputPath(outpath.Data());
+
+
+  if (!pedcalloop.Process())
+    return;
+
+  /*****************************/
+  /* SECOND LOOP: CALIBRATION  */
+  /*****************************/        
+
+  MJCalibration calloop;
+
+  calloop.SetRelTimeCalibration(caltimeflag);
+  calloop.SetExtractor(&extractor);
+  calloop.SetInput(&caliter);
+  calloop.SetBadPixels(pedcalloop.GetBadPixels());
+  if(calflag==2)
+    calloop.SetUseBlindPixel();
+  if(calflag>0)
+    if (!calloop.Process(pedcalloop.GetPedestalCam()))
+      return;
+
+
+  /************************************************************************/
+  /*                THIRD LOOP: PEDESTAL CALIBRATION INTO PHOTONS         */
+  /************************************************************************/
+  // First Compute the pedestals
+  MJPedestal pedloop;
+  pedloop.SetInput(&pediter);
+
+  if (!pedloop.Process())
+    return;
+
+  MParList  plist3;
+  MTaskList tlist3;
+  plist3.AddToList(&tlist3);
+  
+  // containers
+  MCerPhotEvt         nphot;
+  MPedPhotCam         nphotrms;
+  MExtractedSignalCam sigcam;
+
+  plist3.AddToList(&geomcam);
+  plist3.AddToList(&pedloop.GetPedestalCam());
+  plist3.AddToList(&calloop.GetCalibrationCam());
+  plist3.AddToList(&calloop.GetQECam());
+  plist3.AddToList(&calloop.GetRelTimeCam());
+  plist3.AddToList(&calloop.GetBadPixels());
+  plist3.AddToList(&sigcam);
+  plist3.AddToList(&nphot);
+  plist3.AddToList(&nphotrms);
+
+  
+  MCalibrate::CalibrationMode_t calMode=MCalibrate::kDefault;  
+  if(calflag==0)
+    calMode=MCalibrate::kNone;
+  if(calflag==-1)
+    calMode=MCalibrate::kDummy;
+
+  //tasks
+  MReadMarsFile read3("Events");
+  static_cast<MRead&>(read3).AddFiles(pediter); 
+  read3.DisableAutoScheme();
+ 
+  MCalibrate      photcalc(calMode);
+  MPedPhotCalc    photrmscalc; 
+  
+  tlist3.AddToList(&read3);
+  tlist3.AddToList(&geomapl);
+  tlist3.AddToList(&extractor);
+  tlist3.AddToList(&photcalc);
+  tlist3.AddToList(&photrmscalc);
+
+  // Create and setup the eventloop
+  MEvtLoop evtloop3;
+  evtloop3.SetParList(&plist3);
+  if (!evtloop3.Eventloop())
+    return;
+  
+  tlist3.PrintStatistics();
+
+  /************************************************************************/
+  /*                FOURTH LOOP: DATA CALIBRATION INTO PHOTONS            */
+  /************************************************************************/
+
+  MParList  plist4;
+  MTaskList tlist4;
+  plist4.AddToList(&tlist4);
+  
+  // containers 
+  MHillas       hillas;
+  MNewImagePar  newimagepar;
+  MSrcPosCam    source;
+  MRawRunHeader runhead;
+
+  MArrivalTimeCam   timecam;
+
+
+  // islands
+  MIslands      isl;
+  MIslands      isl2;
+  MIslands      isl3;
+
+  isl.SetName("MIslands");  
+  isl2.SetName("MIslands2");
+  isl3.SetName("MIslands3");
+
+  plist4.AddToList(&timecam);
+  plist4.AddToList(&isl);
+  
+  if (islflag == 2)
+    plist4.AddToList(&isl2);
+  if (islflag == 3)
+    plist4.AddToList(&isl3);
+  
+  plist4.AddToList(&geomcam);
+  plist4.AddToList(&pedloop.GetPedestalCam());
+  plist4.AddToList(&calloop.GetCalibrationCam());
+  plist4.AddToList(&calloop.GetQECam());
+  plist4.AddToList(&calloop.GetRelTimeCam());
+  plist4.AddToList(&calloop.GetBadPixels());
+  plist4.AddToList(&nphot);
+  plist4.AddToList(&nphotrms);
+  plist4.AddToList(&source);
+  plist4.AddToList(&hillas);
+  plist4.AddToList(&newimagepar);
+  plist4.AddToList(&runhead);
+
+  // cuts
+  MF cut(filter);
+  
+  //tasks
+  MReadMarsFile read4("Events");
+  static_cast<MRead&>(read4).AddFiles(datiter); 
+  read4.DisableAutoScheme();
+  
+  MImgCleanStd      clean(lcore,ltail);
+  clean.SetCleanRings(lrings);
+  MImgCleanStd::CleaningMethod_t cleanMeth= MImgCleanStd::kStandard;  
+  if(cleanflag==2)
+    cleanMeth=MImgCleanStd::kDemocratic;
+  clean.SetMethod(cleanMeth);
+
+  MArrivalTimeCalc2 timecalc;
+  MIslandCalc       island;
+  island.SetOutputName("MIslands");
+  island.SetAlgorithm(kalgorithm);
+
+  MBadPixelsTreat   interpolatebadpixels;
+  interpolatebadpixels.SetUseInterpolation();
+
+  MIslandClean      islclean(lnew);
+  islclean.SetInputName("MIslands");
+  islclean.SetMethod(kmethod);
+      
+  MIslandCalc       island2;
+  island2.SetOutputName("MIslands2");  
+  island2.SetAlgorithm(kalgorithm);
+
+  MIslandCalc       island3;
+  island3.SetOutputName("MIslands3");  
+  
+  
+  MHillasCalc       hcalc;
+  MHillasSrcCalc    csrc1;
+  
+  MContinue applycut(&cut);
+  applycut.SetInverted(kTRUE);
+  MWriteRootFile write(outname,"RECREATE");
+  
+  MHillasDisplay*  disphillas=NULL;
+
+  write.AddContainer("MHillas"        , "Parameters");
+  write.AddContainer("MHillasSrc"     , "Parameters");
+  write.AddContainer("MHillasExt"     , "Parameters");
+  write.AddContainer("MNewImagePar"   , "Parameters");
+  write.AddContainer("MRawEvtHeader"  , "Parameters");
+  write.AddContainer("MRawRunHeader"  , "Parameters");
+  write.AddContainer("MTime"          , "Parameters");
+  write.AddContainer("MConcentration" , "Parameters");
+  write.AddContainer("MSrcPosCam"     , "Parameters");
+  write.AddContainer("MIslands"       , "Parameters");
+
+  if (islflag == 2) 
+    write.AddContainer("MIslands2" , "Parameters");
+  if (islflag == 3) 
+    write.AddContainer("MIslands3" , "Parameters");
+
+
+  if(display)
+    {
+      disphillas = new MHillasDisplay(&nphot,&geomcam);
+      disphillas->SetIslandsName("MIslands");
+      if (islflag == 2)
+	disphillas->SetIslandsName("MIslands2");
+      if (islflag == 3)
+	disphillas->SetIslandsName("MIslands3");
+    }      
+
+  tlist4.AddToList(&read4);
+  tlist4.AddToList(&geomapl);
+  tlist4.AddToList(&extractor);
+  tlist4.AddToList(&photcalc);
+  if(calflag==11 || calflag==21)
+    tlist4.AddToList(&interpolatebadpixels);
+  tlist4.AddToList(&clean);
+  tlist4.AddToList(&timecalc);
+  tlist4.AddToList(&island);
+
+  if (islflag == 2)
+    {
+      tlist4.AddToList(&islclean);
+      tlist4.AddToList(&island2);
+    }
+
+  if (islflag == 3)
+    {
+      tlist4.AddToList(&islclean);
+      tlist4.AddToList(&island3);
+    }
+  
+  tlist4.AddToList(&hcalc);
+  tlist4.AddToList(&csrc1);
+  if(filter.Length())
+    tlist4.AddToList(&applycut);
+  tlist4.AddToList(&write);
+  if(display)
+    {
+      disphillas->SetPSFile();
+      disphillas->SetPSFileName(psfilename);
+      if(display==2) 
+	disphillas->SetPause(kFALSE);	
+      tlist4.AddToList(disphillas);
+    }
+
+  // Create and setup the eventloop
+  MEvtLoop datloop;
+  datloop.SetParList(&plist4);
+
+  cout << "*************************************************************" << endl;
+  cout << "***   COMPUTING DATA USING EXTRACTED SIGNAL (IN PHOTONS)  ***" << endl;
+  cout << "*************************************************************" << endl;
+  
+  if (!datloop.Eventloop(nmaxevents))
+    return;
+
+  tlist4.PrintStatistics();    
+
+}
+//-------------------------------------------------------------------------------
+
+Bool_t readDatacards(TString& filename)
+{
+  ifstream ifun(filename.Data());
+  if(!ifun)
+    {
+      cout << "File " << filename << " not found" << endl;
+      return kFALSE;
+    }
+
+  TString word;
+  
+  while(ifun >> word)
+    {
+      // skip comments
+      if(word[0]=='/' && word[1]=='/')
+	{
+	  while(ifun.get()!='\n'); // skip line
+	  continue;
+	}
+
+      // number of events
+      if(strcmp(word.Data(),"NEVENTS")==0)
+	ifun >> nmaxevents;
+
+
+      // input file directory
+      if(strcmp(word.Data(),"IDIR")==0)
+	{
+	  if(idirname.Length())
+	    cout << "readDataCards Warning: overriding input directory file name" << endl;
+	  ifun >> idirname;
+	}
+
+      // pedestal runs
+      if(strcmp(word.Data(),"PRUNS")==0)
+	{
+	  if(pediter.GetNumRuns())
+	    cout << "readDataCards Warning: adding pedestal runs to the existing list" << endl;
+	  ifun >> word;
+	  pediter.AddRuns(word.Data(),idirname.Data());
+	}
+
+      // pedestal runs for calibration
+      if(strcmp(word.Data(),"PCRUNS")==0)
+	{
+	  if(pedcaliter.GetNumRuns())
+	    cout << "readDataCards Warning: adding pedestal runs for calibration to the existing list" << endl;
+	  ifun >> word;
+	  pedcaliter.AddRuns(word.Data(),idirname.Data());
+	}
+
+      // calibration runs
+      if(strcmp(word.Data(),"CRUNS")==0)
+	{
+	  if(caliter.GetNumRuns())
+	    cout << "readDataCards Warning: adding calibration runs to the existing list" << endl;
+	  ifun >> word;
+	  caliter.AddRuns(word.Data(),idirname.Data());
+	}
+
+      // data runs
+      if(strcmp(word.Data(),"DRUNS")==0)
+	{
+	  if(datiter.GetNumRuns())
+	    cout << "readDataCards Warning: adding data runs to the existing list" << endl;
+	  ifun >> word;
+	  datiter.AddRuns(word.Data(),idirname.Data());
+	}
+      
+      // output file name
+      if(strcmp(word.Data(),"OUTFILE")==0)
+	{
+	  if(outname.Length())
+	    cout << "readDataCards Warning: overriding output file name" << endl;
+	  ifun >> outname;
+	}
+
+      // exclusion cut
+      if(strcmp(word.Data(),"FILTER")==0)
+	{
+	  if(filter.Length())
+	    cout << "readDataCards Warning: overriding existing cut" << endl;
+	  
+	  char ch;
+	  while((ch=ifun.get())!='\n')
+	    filter.Append(ch);	  
+	}
+
+      // display flag
+      if(strcmp(word.Data(),"DISPLAY")==0)
+	ifun >> display;
+
+      // ps file name
+      if(strcmp(word.Data(),"PSFILENAME")==0)
+	ifun >> psfilename;
+
+      // calibration flag
+      if(strcmp(word.Data(),"CALFLAG")==0)
+	ifun >> calflag;
+
+      // calibration flag
+      if(strcmp(word.Data(),"CALTIME")==0)
+	ifun >> caltimeflag;
+
+      // cleaning level
+      if(strcmp(word.Data(),"CLEANLEVEL")==0)
+	{
+	  ifun >> lcore;
+	  ifun >> ltail;
+	  if(ifun.get()!='\n'){
+	    ifun.unget();
+	    ifun >> lrings;
+	    if(ifun.get()!='\n'){
+	      ifun.unget();
+	      ifun >> cleanflag;
+	    }
+	  }
+	}
+      
+      if(strcmp(word.Data(),"ISLFLAG")==0)
+	{
+	  ifun >> islflag;
+
+	  // if (islflag == 1 || islflag == 2)
+	    ifun >> kalgorithm;
+	}
+
+      // island cleaning 
+      if (islflag == 2){
+	if(strcmp(word.Data(),"ISLANDCLEAN")==0)
+	  {
+	    ifun >> kmethod;
+	    ifun >> lnew;
+	  }
+      }
+    }
+
+  pediter.Reset();
+  caliter.Reset();
+  datiter.Reset();
+  TString pfile;
+
+  // Dump read values
+  cout << "************************************************" << endl;
+  cout << "* Datacards read from file " << filename << endl;
+  cout << "************************************************" << endl;
+  cout << "Pedestal file (s): "  << endl;
+  while(!(pfile=pediter.Next()).IsNull())
+    cout << pfile << endl;
+  cout << "Calibration file (s): "  << endl;
+  while(!(pfile=caliter.Next()).IsNull())
+    cout << pfile << endl;
+  cout << "Data file (s): "  << endl;
+  while(!(pfile=datiter.Next()).IsNull())
+    cout << pfile << endl;
+  cout << "Maximum number of events: " << nmaxevents << endl;
+  if(filter.Length())
+    cout << "Applying rejection cut: " << filter << endl;
+  cout << "Output file name: " << outname << endl;
+  if(display)
+    cout << "Generating PS file: " << psfilename << endl;
+  cout << "Calibration: ";
+  if(calflag==0)    
+    cout << "Pixel area proportional intercalibration" << endl;
+  else if(calflag==-1)    
+    cout << "No calibration whatsoever" << endl;
+  else if(calflag==1)
+    cout << "Default calibration" << endl;
+  else if(calflag==11)
+    cout << "Default calibration + bad pixels interpolation" << endl;
+  cout << "Cleaning level: ("<<lcore<<","<<ltail<<") - " << lrings << "ring" << endl;
+  cout << "Cleaning methode: "<< cleanflag << endl;
+  if (islflag == 1 || islflag == 2)
+    cout << "Island calcultation..." << "using algorithm #" << kalgorithm <<endl;
+  if (islflag == 2)
+    {
+      cout << "Island Cleaning: "<< kmethod <<" method  "<< lnew << " new threshold" << endl;
+    }
+  cout << "***********" << endl << endl;
+  
+  if(!pediter.GetNumEntries())
+    {
+      cout << "No pedestal file name specified" << endl;
+      return kFALSE;
+    }
+  if(!caliter.GetNumEntries() && calflag>0)
+    {
+      cout << "No calibration file name specified" << endl;
+      return kFALSE;
+    }
+  if(!datiter.GetNumEntries())
+    {
+      cout << "No data file name specified" << endl;
+      return kFALSE;
+    }
+  if(!outname.Length())
+    {
+      cout << "No output file name specified" << endl;
+      return kFALSE;
+    }
+
+
+  return kTRUE;
+}
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/makehillas.datacard
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/makehillas.datacard	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/makehillas.datacard	(revision 9661)
@@ -0,0 +1,70 @@
+/////////////////////////////////////////////////////////
+// Data card template for makeHillas executable        //
+//                                                     //
+// *** Compulsory cards are:                           //
+// PRUNS, CRUNS, DRUNS, OUTFILE                        //
+//                                                     //
+// the rest are optional                               //
+// *** Do NEVER add a datacard with no value after it  //
+/////////////////////////////////////////////////////////
+
+
+// Maximun number of (data) events to be processed)
+NEVENTS 9999999
+
+// data file directory
+IDIR /local_disk/jrico/rootdata/Crab20040215/
+
+// Pedestal (PRUNS), calibration (CRUNS) and data runs (DRUNS), e.g 1500-23444,25444,25455-26544
+PRUNS 16743
+CRUNS 16744
+DRUNS 16745
+
+// output file name
+// OUTFILE ~/magic/mars/mars/hillasCrab/crab20040215OnA.root
+OUTFILE ./prueba.root
+
+// Selection cut. 
+// Condition "==" not supported.
+// Enclose all conditions between brakets, like: "(x<y) && (z<5)"
+// (see MF description class for more details)
+// FILTER (MHillas.fLength<100) && (MHillas.fLength>50)
+
+// Display flag 
+// DISPLAY 0 will simply produce the hillas parameters files
+// DISPLAY 1 will show event display and produce ps file
+// DISPLAY 2 will produce the ps files, no display
+DISPLAY 0
+
+// PS file name
+PSFILENAME makehillas.ps
+
+// calibration flag:
+// -1: kDummy
+//  0: kNone
+//  1: kDefault(F factor)
+//  2: kDemocratic
+// 11: kDefault(F factor) + bad pixel interpolation
+// 21: kDemocratic + bad pixel interpolation
+CALFLAG 0
+
+// calibration time:
+//   0: kFALSE (no time calibration)
+//   1: kTRUE  (time calibration)
+//CALTIME 1
+
+
+// Cleaning level (tail cut, boundary cut, number of rings, cleaning method - 1=standard, 2=democratic)
+CLEANLEVEL 3.0 1.5 1 1
+
+//Island calculations
+// 0  nothing about islands    1:normal algorithm 
+// 1  islands w/o cleaning     2:alternative algorithm
+// 2  islands  w  cleaning
+ISLFLAG 0 1
+
+// island cleaning:
+// 0: timing method     val:0.2, 0.3, 0.5... 
+// 1: no timing method  val: 40, 50, 60...
+ISLANDCLEAN 1 40
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/optimizeCuts.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/optimizeCuts.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/optimizeCuts.cc	(revision 9661)
@@ -0,0 +1,357 @@
+////////////////////////////////////////////////////////////////////////////////////
+//
+//             _____ Optimize cuts _____
+//
+//  Take as input root files with hillas parameters and compute the optimal cuts by
+//  mapping the width/length plane (only upper cuts so far)
+//
+//                 Jose Flix    <jflix@ifae.es>
+//                 Javier Rico  <jrico@ifae.es>
+////////////////////////////////////////////////////////////////////////////////////
+
+#include <fstream>
+#include <iostream>
+
+#include "TString.h"
+#include "TChain.h"
+#include "TH1F.h"
+
+#include "MArgs.h"
+#include "MLog.h"
+
+using namespace std;
+
+Bool_t readDatacards(TString& filename);
+void optimizeCuts();
+
+
+//-----------------------------------------------------------------------------
+// declaration of variables read from datacards
+//-----------------------------------------------------------------------------
+
+TString  onFile;
+TString  offFile;
+TString  outputFile;
+ULong_t  nmaxevents=999999999;
+Float_t  lowdistcut=0;
+Float_t  uppdistcut=10;
+Float_t  lowsizecut=1800;
+Float_t  uppsizecut=1800;
+Int_t    nsizebins=1;
+UInt_t   onRate=1;
+Float_t  lowlgcut=0.01;
+Float_t  upplgcut=0.3;
+Float_t  lgstep=0.005;
+Float_t  lowwdcut=0.01;
+Float_t  uppwdcut=0.3;
+Float_t  wdstep=0.005;
+
+//-----------------------------------------------------------------------------
+// constants
+//-----------------------------------------------------------------------------
+
+const TString defaultcard="optimizecuts.datacard";
+const Float_t conver   = 189./0.6; // conversion factor degrees to mm
+const Int_t nbins=18; //number of bins in alpha plots
+const Float_t frontiere=20.; // [deg] value below (above) wich signal (background is computed (normalized)
+
+//-----------------------------------------------------------------------------
+
+static void Usage()
+{
+  gLog <<endl;
+  gLog << "Usage is:" << endl;
+  gLog << "   optimizeCuts [-h] [-?] <datacards>" << endl << endl;
+  gLog << "     <datacards>: datacards file name (default " << defaultcard <<")" << endl;
+  gLog << "     -?/-h: This help" << endl << endl;
+}
+
+//-----------------------------------------------------------------------------
+int main(int argc, char **argv)
+{
+  // evaluate arguments
+  MArgs arg(argc, argv);
+  if (arg.HasOnly("-?") || arg.HasOnly("-h") || arg.HasOnly("--help"))
+    {
+      Usage();
+      return -1;
+    }
+
+  TString datacard  = arg.GetArgumentStr(0);
+  if(!datacard.Length())
+    datacard = defaultcard;
+
+  if(!readDatacards(datacard))
+    {
+      cout << "Error reading datacards. Stoping" << endl;
+      return -1;
+    }
+  optimizeCuts();
+}
+
+//-----------------------------------------------------------------------------
+void optimizeCuts()
+{
+  // create the TChains for ON and OFF data
+  TChain* ton= new TChain("Parameters");
+  TChain* toff= new TChain("Parameters");
+  if(!ton->Add(onFile))
+    {
+      cout << "On-data file not found or not valid format" << endl;
+      return;
+    }
+  if(!toff->Add(offFile))
+    {
+      cout << "Off-data file not found or not valid format" << endl;
+      return;
+    }
+
+  ofstream fout;
+  fout.open(outputFile.Data());
+
+  // define aliases
+  ton->SetAlias("length","MHillas.fLength*0.6/189");
+  ton->SetAlias("width","MHillas.fWidth*0.6/189");
+  //ton->SetAlias("length","MHillas.fLength");
+  //ton->SetAlias("width","MHillas.fWidth");
+  ton->SetAlias("dist","MHillasSrc.fDist*0.6/189");
+  ton->SetAlias("conc","MNewImagePar.fConc");
+  ton->SetAlias("size","MHillas.fSize");
+  ton->SetAlias("event","MRawEvtHeader.fDAQEvtNumber");
+  ton->SetAlias("alpha","abs(MHillasSrc.fAlpha)");
+  ton->SetAlias("leak","MNewImagePar.fInnerLeakage1");
+  
+  toff->SetAlias("length","MHillas.fLength*0.6/189");
+  toff->SetAlias("width","MHillas.fWidth*0.6/189");
+  //toff->SetAlias("length","MHillas.fLength");
+  //toff->SetAlias("width","MHillas.fWidth");
+  toff->SetAlias("dist","MHillasSrc.fDist*0.6/189");
+  toff->SetAlias("conc","MNewImagePar.fConc");
+  toff->SetAlias("size","MHillas.fSize");
+  toff->SetAlias("event","MRawEvtHeader.fDAQEvtNumber");
+  toff->SetAlias("alpha","abs(MHillasSrc.fAlpha)");
+  toff->SetAlias("leak","MNewImagePar.fInnerLeakage1");
+
+
+  // general cut
+  char gencut[256];
+  char evecut[256];
+  sprintf(evecut,"event%%%d==0",onRate);
+  sprintf(gencut,"dist>%f && dist<%f",lowdistcut,uppdistcut);
+  cout << "General cut " << gencut << " (" << evecut << " for on-data)" << endl;
+
+  Bool_t isDiff = kFALSE;
+  if(nsizebins<0)
+    {
+      nsizebins*=-1;
+      isDiff=kTRUE;
+    }
+  else
+    nsizebins+=1;
+
+  // loop on size, width and length cuts
+  for(Int_t isb=0;isb<nsizebins;isb++) // loop on size
+    {      
+      cout << isb << endl;      
+      Float_t minsize = isDiff ? 
+	TMath::Power(10,TMath::Log10(lowsizecut)+isb*(TMath::Log10(uppsizecut)-TMath::Log10(lowsizecut))/nsizebins) :
+	TMath::Power(10,TMath::Log10(lowsizecut)+isb*(TMath::Log10(uppsizecut)-TMath::Log10(lowsizecut))/(nsizebins-1));
+      Float_t maxsize = isDiff ? TMath::Power(10,TMath::Log10(lowsizecut)+(isb+1)*(TMath::Log10(uppsizecut)-TMath::Log10(lowsizecut))/nsizebins) : 9999999999.;
+      
+      Float_t length=lowlgcut;
+      while(length<=upplgcut) // loop on length
+	{
+	  Float_t width=lowwdcut;
+	  while(width<=uppwdcut) // loop on width
+	    {
+	      TH1F* onhisto  = new TH1F("OnHist" ,"Alpha Plot",nbins,0,90);
+	      TH1F* offhisto = new TH1F("OffHist","Alpha Plot",nbins,0,90);    
+	      
+	      // define the width/length cut
+	      char varcut[256];
+	      sprintf(varcut,"size>%f && size<%f && length<%f && width<%f",minsize,maxsize,length,width);
+	      cout << "Cutting " << varcut << endl;
+	      
+	      // define the on/off data cut
+	      char offcut[1024];
+	      sprintf(offcut,"%s && %s",gencut,varcut);
+	      char oncut[1024];
+	      sprintf(oncut,"%s && %s",evecut,offcut);
+	      
+	      // Fill the histos
+	      ton->Draw("alpha>>OnHist",oncut);
+	      toff->Draw("alpha>>OffHist",offcut);
+	      
+	      // Normalize histos
+	      const Int_t inibin = (Int_t)(frontiere/90.*nbins+1);
+	      Float_t level=0;
+	      Float_t leveloff=0;
+	      for(Int_t ibin = inibin; ibin<=nbins;ibin++)
+		{
+		  level+=onhisto->GetBinContent(ibin);
+		  leveloff+=offhisto->GetBinContent(ibin);
+		}
+	      offhisto->Sumw2(); // needed to compute correct errors after normalization
+	      const Float_t norm = leveloff ? level/leveloff: 1;
+	      cout << "Normalizing by factor " << norm <<endl;
+	      offhisto->Scale(norm);    
+	      
+	      // compute significance/excess
+	      Float_t sig=0,bg=0,esig=0,ebg=0;
+	      Float_t significance=0;
+	      const Int_t signbins = inibin-1;
+	      for(Int_t ibin = 1; ibin<=signbins;ibin++)
+		{
+		  sig  += onhisto->GetBinContent(ibin);
+		  esig += onhisto->GetBinError(ibin)*onhisto->GetBinError(ibin);
+		  bg   += offhisto->GetBinContent(ibin);
+		  ebg  += offhisto->GetBinError(ibin)*offhisto->GetBinError(ibin);
+		}
+	      Float_t error= TMath::Sqrt(esig+ebg);
+	      significance = error ? (sig-bg)/error : 0; 
+	      
+	      cout << "Excess: " << sig-bg << endl;
+	      cout << "N bkg: "  << bg << endl; 
+	      cout << "Significance: " << significance << endl;	  
+	      
+	      // save the result in file
+	      fout << minsize << '\t' 
+		   << maxsize << '\t' 
+		   << width << '\t' 
+		   << length << '\t'
+		   << sig-bg << '\t'
+		   << significance << '\t' << endl;
+	      
+	      delete onhisto;
+	      delete offhisto;
+	      
+	      width+=wdstep;
+	    }
+	  length+=lgstep;
+	}
+    }
+  fout.close();
+}
+//-----------------------------------------------------------------------
+  
+Bool_t readDatacards(TString& filename)
+{
+  ifstream ifun(filename.Data());
+  if(!ifun)
+    {
+      cout << "File " << filename << " not found" << endl;
+      return kFALSE;
+    }
+
+  TString word;
+  
+  while(ifun >> word)
+    {
+      // skip comments
+      if(word[0]=='/' && word[1]=='/')
+	{
+	  while(ifun.get()!='\n'); // skip line
+	  continue;
+	}
+      
+      // number of events
+      if(strcmp(word.Data(),"NEVENTS")==0)
+	ifun >> nmaxevents;
+      
+      // number of events
+      if(strcmp(word.Data(),"ONRATE")==0)
+	ifun >> onRate;
+      
+      // input file name (on data)
+      if(strcmp(word.Data(),"ONFILES")==0)
+	{
+	  if(onFile.Length())
+	    cout << "readDataCards Warning: overriding on-data file name" << endl;
+	  ifun >> onFile;
+	}
+
+      // input file name (off data)
+      if(strcmp(word.Data(),"OFFFILES")==0)
+	{
+	  if(offFile.Length())
+	    cout << "readDataCards Warning: overriding off-data file name" << endl;
+	  ifun >> offFile;
+	}
+
+      // output file name
+      if(strcmp(word.Data(),"OUTFILE")==0)
+	{
+	  if(outputFile.Length())
+	    cout << "readDataCards Warning: overriding output file name" << endl;
+	  ifun >> outputFile;
+	}
+
+      // size cuts
+      if(strcmp(word.Data(),"SIZECUTS")==0)
+	{
+	  ifun >> lowsizecut;
+	  ifun >> uppsizecut;
+	  ifun >> nsizebins;
+	}
+
+      // dist cuts
+      if(strcmp(word.Data(),"DISTCUTS")==0)
+	{
+	  ifun >> lowdistcut ; 
+	  ifun >> uppdistcut ; 
+	}
+
+      // length cuts
+      if(strcmp(word.Data(),"LENGTHCUTS")==0)
+	{
+	  ifun >> lowlgcut;
+	  ifun >> upplgcut;
+	  ifun >> lgstep;
+	}
+
+      // width cuts
+      if(strcmp(word.Data(),"WIDTHCUTS")==0)
+	{
+	  ifun >> lowwdcut;
+	  ifun >> uppwdcut;
+	  ifun >> wdstep;
+	}
+
+    }
+  
+  // check compulsory values
+  if(!onFile.Length())
+    {
+      cout << "No on-data file name specified" << endl;
+      return kFALSE;
+    }
+  
+  if(!offFile.Length())
+    {
+      cout << "No off-data file name specified" << endl;
+      return kFALSE;
+    }
+    
+  if(!outputFile.Length())
+    {
+      cout << "No output file name specified" << endl;
+      return kFALSE;
+    }
+
+  // Dump read values
+  cout << "************************************************" << endl;
+  cout << "* Datacards read from file " << filename << endl;
+  cout << "************************************************" << endl;
+  cout << "Maximum number of input events: " << nmaxevents << endl;
+  cout << "On-data acceptance rate: 1/" << onRate << endl;
+  cout << "On-data input file name(s): " << onFile << endl;
+  cout << "Off-data input file name(s): " << offFile << endl;
+  cout << "Output file name: " << outputFile << endl;
+  cout << "Dist cuts (deg): [" << lowdistcut<< ","<<uppdistcut<< "]" << endl;
+  cout << "Scanning size range: [" << lowsizecut << "," << uppsizecut << "]"<< " in " << nsizebins << " steps" << endl;
+  cout << "Scanning length range (deg): [" << lowlgcut<< ","<<upplgcut<< "], with step (deg): "<< lgstep << endl;
+  cout << "Scanning width range (deg): [" << lowwdcut<< ","<<uppwdcut<< "], with step (deg): "<< wdstep << endl;
+  cout << "***********" << endl << endl;
+
+  return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/optimizecuts.datacard
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/optimizecuts.datacard	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/optimizecuts.datacard	(revision 9661)
@@ -0,0 +1,43 @@
+/////////////////////////////////////////////////////////
+// Data card template for optimizeCuts executable      //
+//                                                     //
+// *** Compulsory cards are:                           //
+// ONFILES, OFFFILES, OUTFILE                          //
+//                                                     //
+// the rest are optional                               //
+// *** Do NEVER add a datacard with no value after it  //
+/////////////////////////////////////////////////////////
+
+// Maximun number of on and off events to be processed)
+NEVENTS 9999999
+
+// On data acceptance rate (e.g 4 for taking 1/4 of whole data sample)
+ONRATE 3
+
+// Input file name pattern (On data)
+ONFILES  /mnt/users/jrico/magic/mars/Mars_Standard02/mtemp/mifae/hillas/mrk20040215OnRotateNoCalB.root
+
+// Input file name pattern (Off data)
+OFFFILES  /mnt/users/jrico/magic/mars/Mars_Standard02/mtemp/mifae/hillas/mrk20040215OffRotateA-C.root
+
+// output file name
+OUTFILE  ./prueba.out
+
+
+// Preliminary distance lower and upper cuts (in deg)
+DISTCUTS 0.3 1.2
+
+// Size initial, final and number of steps 
+// it will take logarithmic constant intervals
+// positive number of steps means lower cut (integral)
+// negative number of steps means lower and upper cuts (diferential)
+SIZECUTS  500 10000 3
+
+// Length initial, final and step values (in deg)
+LENGTHCUTS 0.15 0.35 0.1 
+
+// Width initial, final and step values (in deg)
+WIDTHCUTS 0.05 0.15 0.1 
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/pedvsslices.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/pedvsslices.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/pedvsslices.cc	(revision 9661)
@@ -0,0 +1,253 @@
+#include "TString.h"
+#include "TMultiGraph.h"
+#include "TGraphErrors.h"
+#include "TStyle.h"
+#include "TCanvas.h"
+#include "TLegend.h"
+
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MReadMarsFile.h"
+#include "MGeomApply.h"
+#include "MEvtLoop.h"
+#include "MPedCalcPedRun.h"
+#include "MPedestalCam.h"
+#include "MPedestalPix.h"
+
+#include <iostream>
+#include <fstream>
+#include <stdlib.h>
+
+using namespace std;
+
+
+const UInt_t nmaxslice = 30;
+const UInt_t step = 2;
+
+void pedvsslices2(TString pedname);
+
+int main()
+//void pedvsslices()
+{
+  pedvsslices2("~markus/Magic/Soft/Mars/20040303_20123_P_NewCalBoxTestLidOpen_E.root");
+}
+
+void pedvsslices2(TString pedname)
+{
+  const Int_t nbad = 22;
+  Int_t bad[nbad]={0,10,47,54,124,125,159,162,222,300,388,395,464,558,559,543,89,510,576,459,550,561};
+
+  static const UInt_t rnmax   = (nmaxslice/step)*step;
+  static const UInt_t nslices = rnmax/step;
+  static const UInt_t nloops  = rnmax*(rnmax-step+2)/(2*step);
+
+  cout << "nslices = " << nslices << endl;
+
+  // general settings
+  gStyle->SetCanvasColor(0);
+  gStyle->SetStatColor(0);
+  gStyle->SetStatBorderSize(1);
+  gStyle->SetMarkerSize(0.6);
+  gStyle->SetPadBorderMode(0);
+
+  // Define the graphs and their atributes
+  TGraphErrors grmeanIn[nslices];
+  TGraphErrors grrmsIn[nslices];
+  TGraphErrors grmeanOut[nslices];
+  TGraphErrors grrmsOut[nslices];
+
+  // Null graph to adjust plot limits
+  Float_t nullx[rnmax+1];
+  Float_t nullyM[rnmax+1];
+  Float_t nullyR[rnmax+1];
+  for(UInt_t i=0;i<=rnmax;i++)
+    {
+      nullx[i]=(Float_t)i;
+      nullyM[i]=9+2./rnmax*i;
+      nullyR[i]=3.5+5./rnmax*i;
+    }
+  TGraph grnullM(rnmax+1,nullx,nullyM);
+  TGraph grnullR(rnmax+1,nullx,nullyR);
+  grnullM.SetMarkerSize(0);
+  grnullR.SetMarkerSize(0);
+  grnullM.SetMarkerColor(0);
+  grnullR.SetMarkerColor(0);
+  grnullM.GetXaxis()->SetTitle("First used time slice");
+  grnullR.GetXaxis()->SetTitle("First used time slice");
+  grnullM.GetYaxis()->SetTitle("Average Pedestal mean (ADC cnts)");
+  grnullR.GetYaxis()->SetTitle("Average Pedestal rms (ADC cnts)");
+
+  for(UInt_t i=0;i<nslices;i++)
+    {
+      grmeanIn[i].SetMarkerColor(i%9+1);
+      grrmsIn[i].SetMarkerColor(i%9+1);
+      grmeanOut[i].SetMarkerColor(i%9+1);
+      grrmsOut[i].SetMarkerColor(i%9+1);
+
+      grmeanIn[i].SetMarkerStyle(20+i%19+1);
+      grrmsIn[i].SetMarkerStyle(20+i%19+1);
+      grmeanOut[i].SetMarkerStyle(20+i%19+1);
+      grrmsOut[i].SetMarkerStyle(20+i%19+1);
+    }
+
+
+  // Fill the graphs
+  UInt_t islice=0;
+  UInt_t fslice=step-1;    
+  for(UInt_t i=0;i<nloops;i++)
+    {
+      MParList plist;
+      MTaskList tlist;
+      MPedestalCam pedcam;
+  
+      plist.AddToList(&tlist);
+      plist.AddToList(&pedcam);
+      
+      MReadMarsFile read("Events", pedname);
+      read.DisableAutoScheme();
+      MGeomApply     geomapl;
+      MPedCalcPedRun pedcalc;
+      cout << "Checking slices from " << islice << " to " << fslice << endl;
+      pedcalc.SetRange(islice,fslice,0,0);
+      pedcalc.SetWindowSize(fslice-islice+1);
+
+      tlist.AddToList(&read);
+      tlist.AddToList(&geomapl);
+      tlist.AddToList(&pedcalc);
+      
+      MEvtLoop evtloop;
+      evtloop.SetParList(&plist);
+      if (!evtloop.Eventloop())
+	return;
+
+      // compute the pedestal mean and rms averaged in the camera
+      Float_t meansumIn =0;
+      Float_t meansum2In=0;
+      Float_t rmssumIn  =0;
+      Float_t rmssum2In =0;
+      Float_t meansumOut =0;
+      Float_t meansum2Out=0;
+      Float_t rmssumOut  =0;
+      Float_t rmssum2Out =0;
+
+      const Int_t ninn = 397;
+      Int_t rninn=0;
+      Int_t rnout=0;
+      for(Int_t j=0;j<pedcam.GetSize();j++)
+	{
+	  // skip bad pixels from list above
+	  Bool_t isBad=kFALSE;
+	  for(Int_t k=0;k<nbad;k++)
+	    if(bad[k]==j)
+	      {
+		isBad=kTRUE;
+		break;
+	      }
+	  if(isBad)
+	    continue;
+
+	  // keep the sum of values and of squares
+	  Float_t ped = pedcam[j].GetPedestal();
+	  Float_t rms = pedcam[j].GetPedestalRms();
+	  if(j<ninn)
+	    {
+	      meansumIn+= ped;
+	      meansum2In+=ped*ped;
+	      rmssumIn+=rms;
+	      rmssum2In+=rms*rms;
+	      rninn++;
+	    }
+	  else
+	    {
+	      meansumOut+= ped;
+	      meansum2Out+=ped*ped;
+	      rmssumOut+=rms;
+	      rmssum2Out+=rms*rms;
+	      rnout++;
+	    }	    
+	}
+      
+      Float_t avmeanIn  = meansumIn/rninn;
+      Float_t sigmeanIn = (meansum2In-meansumIn*meansumIn/rninn)/(rninn-1);
+      Float_t avrmsIn   = rmssumIn/rninn;
+      Float_t sigrmsIn  = (rmssum2In-rmssumIn*rmssumIn/rninn)/(rninn-1);
+       
+      Float_t avmeanOut  = meansumOut/rnout;
+      Float_t sigmeanOut = (meansum2Out-meansumOut*meansumOut/rnout)/(rnout-1);
+      Float_t avrmsOut   = rmssumOut/rnout;
+      Float_t sigrmsOut  = (rmssum2Out-rmssumOut*rmssumOut/rnout)/(rnout-1);
+      
+      // save the values into the graphs
+      grmeanIn[(fslice-islice+1)/step-1].SetPoint(islice,islice,avmeanIn);
+      grmeanIn[(fslice-islice+1)/step-1].SetPointError(islice,0,sigmeanIn/rninn);
+      grmeanOut[(fslice-islice+1)/step-1].SetPoint(islice,islice,avmeanOut);
+      grmeanOut[(fslice-islice+1)/step-1].SetPointError(islice,0,sigmeanOut/rnout);
+
+      grrmsIn[(fslice-islice+1)/step-1].SetPoint(islice,islice,avrmsIn);
+      grrmsIn[(fslice-islice+1)/step-1].SetPointError(islice,0,sigrmsIn/rninn);
+      grrmsOut[(fslice-islice+1)/step-1].SetPoint(islice,islice,avrmsOut);
+      grrmsOut[(fslice-islice+1)/step-1].SetPointError(islice,0,sigrmsOut/rnout);
+
+      // compute next initial and final slice values
+      islice++;
+      fslice++;
+      if(fslice>=nmaxslice)
+	{
+	  fslice=fslice-islice+step;
+	  islice=0;
+	}
+    }
+
+  TCanvas* myC = new TCanvas("myC","pedestal studies",900,1250);
+  myC->Divide(2,2);
+
+  TLegend* leg1 = new TLegend(.2,.2,.4,.5);
+  TLegend* leg2 = new TLegend(.44,.2,.88,.5);
+  leg1->SetEntrySeparation(0.1);
+  leg1->SetHeader("");
+  leg2->SetEntrySeparation(0.1);
+  leg2->SetHeader("");
+
+  myC->cd(1);
+  grnullM.SetTitle("Average pedestal mean for inner pixels");
+  grnullM.DrawClone("AP");
+  for(UInt_t i=0;i<nslices;i++)
+    {      
+      grmeanIn[i].DrawClone("P");
+      char leglab[100];
+      sprintf(leglab,"%d slices",(i+1)*step);
+      if(i<nslices/2)
+	leg1->AddEntry(&grmeanIn[i],leglab,"p");
+      else
+	leg2->AddEntry(&grmeanIn[i],leglab,"p");
+    }
+  leg1->SetFillColor(0);
+  leg1->SetLineColor(0);
+  leg1->SetBorderSize(0);
+  leg1->Draw();
+  leg2->SetFillColor(0);
+  leg2->SetLineColor(0);
+  leg2->SetBorderSize(0);
+  leg2->Draw();
+
+  myC->cd(2);
+  grnullR.SetTitle("Average pedestal rms for inner pixels");
+  grnullR.DrawClone("AP");
+  for(UInt_t i=0;i<nslices;i++)
+    grrmsIn[i].DrawClone("P");
+  
+  myC->cd(3);
+  grnullM.SetTitle("Average pedestal mean for outer pixels");
+  grnullM.DrawClone("AP");
+  for(UInt_t i=0;i<nslices;i++)
+    grmeanOut[i].DrawClone("P");
+  
+  myC->cd(4);
+  grnullR.SetTitle("Average pedestal rms for outer pixels");
+  grnullR.DrawClone("AP");
+  for(UInt_t i=0;i<nslices;i++)
+    grrmsOut[i].DrawClone("P");
+
+  myC->Print("pedestaSliceDependence.ps");
+
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/psffit.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/psffit.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/psffit.cc	(revision 9661)
@@ -0,0 +1,175 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Javier López, 04/2004 <mailto:jlopez@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+#include <iostream>
+#include <stdlib.h>
+
+#include <TString.h>
+#include <TArrayS.h>
+
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MGeomCamMagic.h"
+#include "MCameraDC.h"
+#include "MPSFFit.h"
+
+#include "MReadReports.h"
+#include "MGeomApply.h"
+#include "MPSFFitCalc.h"
+#include "MEvtLoop.h"
+#include "MCalibrateDC.h"
+
+using namespace std;
+
+int main(int argc, char *argv[])
+{
+    if(argc!=2 && argc!=3) 
+      {
+        printf("\n usage: %s filename numberEnvents \n\n",argv[0]);
+        return 1;
+      }
+    
+    UInt_t len=strlen(argv[1]);
+    
+    if(argv[1][len] == '/')
+      {
+	argv[1][len]='\0';
+      }
+    
+    TString filename;
+    filename=argv[1];
+
+    UInt_t numEvents = 1000000;
+    if(argc == 3)
+      {
+	len=strlen(argv[2]);
+    
+	if(argv[2][len] == '/')
+	  {
+	    argv[2][len]='\0';
+	  }
+	
+	numEvents=atoi(argv[2]);
+      }
+
+  //
+  // 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);
+
+
+  MGeomCamMagic geomcam;
+  MCameraDC     dccam;
+  MPSFFit       psffit;
+
+  plist.AddToList(&geomcam);
+  plist.AddToList(&dccam);
+  plist.AddToList(&psffit);
+
+  //
+  // Now setup the tasks and tasklist:
+  // ---------------------------------
+  //
+
+  // Reads the trees of the root file and the analysed branches
+  MReadReports read;
+  read.AddTree("Currents"); 
+  read.AddFile(filename);     // after the reading of the trees!!!
+  read.AddToBranchList("MReportCurrents.*");
+
+  MGeomApply geomapl;
+
+  TString continuoslightfile = 
+    "/nfs/magic/CaCodata/rootdata/Miscellaneous/Period016/2004_04_16/dc_2004_04_16_04_46_18_22368_Off3c279-2CL100.root";
+  MCalibrateDC dccal;
+  dccal.SetFileName(continuoslightfile);
+ 
+  const Int_t numrings = 3;
+  //  const Int_t numblind = 187;
+
+
+  // 2004_02_15
+  /*  const Int_t numblind = 28;
+  const Short_t x[numblind] = {  8, 224, 279, 339,
+			       433, 434, 435, 436, 437, 438, 439, 
+			       475, 476, 477, 478, 479, 480, 481, 482,
+			       523, 524, 525, 526, 527, 528, 529, 530, 531};
+  */
+  const Int_t numblind = 260;
+  Short_t x[numblind];
+
+  for (int i=0;i<246;i++)
+    x[i+14]=i+331;
+  x[0]=124;
+  x[1]=123;
+  x[2]=125;
+  x[3]=166;
+  x[4]=165;
+  x[5]=88;
+  x[6]=89;
+  x[7]=282;
+  x[8]=283;
+  x[9]=226;
+  x[10]=227;
+  x[11]=228;
+  x[12]=177;
+  x[13]=178;
+
+  const TArrayS blindpixels(numblind,(Short_t*)x);
+  MPSFFitCalc psfcalc;
+  //psfcalc.SetImgCleanMode(MPSFFitCalc::kRing);
+  psfcalc.SetImgCleanMode(MPSFFitCalc::kCombined);
+  psfcalc.SetNumRings(numrings);
+  psfcalc.SetBlindPixels(blindpixels);
+
+
+  tlist.AddToList(&geomapl);
+  tlist.AddToList(&read);
+  tlist.AddToList(&dccal, "Currents");
+  tlist.AddToList(&psfcalc, "Currents");
+
+  //
+  // Create and setup the eventloop
+  //
+  MEvtLoop evtloop;
+  evtloop.SetParList(&plist);
+     
+  //
+  // Execute your analysis
+  //
+
+  if (!evtloop.Eventloop(numEvents))
+    return kFALSE;
+
+  //  tlist.PrintStatistics();
+
+  cout << "RUN " << psffit.GetMeanMinorAxis() << ' ' << psffit.GetSigmaMinorAxis() << ' ' <<  psffit.GetMeanMajorAxis()  << ' ' <<  psffit.GetSigmaMajorAxis() << ' ' << psffit.GetChisquare() << endl;
+  
+}
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/srcPos.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/srcPos.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/srcPos.cc	(revision 9661)
@@ -0,0 +1,361 @@
+////////////////////////////////////////////////////////////////////////////////////
+//
+//             _____ Source Position macro_____
+//
+//  Take as input root files with hillas parameters and recompute the ones depending
+//  on the source position for a new (input) position, optionally rotating it in an
+//  event by event basis. Output is a file with recomputed hillas parameters
+//
+//                 Ester Aliu   <aliu@ifae.es>
+//                 Oscar Blanch <blanch@ifae.es>
+//                 Javier Rico  <jrico@ifae.es>
+////////////////////////////////////////////////////////////////////////////////////
+
+#include <fstream>
+#include <iostream>
+
+#include "TString.h"
+
+#include "MHillasSrcCalc.h"
+#include "MHillasSrc.h"
+#include "MSrcRotate.h"
+#include "MSrcPosFromFile.h"
+#include "MSrcTranslate.h"
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MHillas.h"
+#include "MReadTree.h"
+#include "MEvtLoop.h"
+#include "MLog.h"
+#include "MArgs.h"
+#include "MWriteRootFile.h"
+#include "MTime.h"
+#include "MControlPlots.h"
+#include "MIslands.h"
+
+using namespace std;
+
+Bool_t readDatacards(TString& filename);
+void srcPos();
+
+//-----------------------------------------------------------------------------
+// declaration of variables read from datacards
+//-----------------------------------------------------------------------------
+
+TString  inputFile;
+TString  offFile;
+TString  outputFile;
+TString  offOutputFile;
+ULong_t  nmaxevents=999999999;
+Float_t  xsrcpos=0.;
+Float_t  ysrcpos=0.;
+Double_t mjdpos=0;
+Bool_t   kRotate=0;
+Bool_t   kSrcPolicy=kFALSE;
+Double_t fRA= -1.;
+Double_t fDEC= -1.;
+TString  srcFile;
+TString  controlplotsfilename="controlplots.ps";
+
+//-----------------------------------------------------------------------------
+// constants
+//-----------------------------------------------------------------------------
+
+const TString defaultcard="srcpos.datacard";
+const Float_t conver   = 189./0.6; // conversion factor degrees to mm
+
+//-----------------------------------------------------------------------------
+
+static void Usage()
+{
+  gLog <<endl;
+  gLog << "Usage is:" << endl;
+  gLog << "   srcPos [-h] [-?] <datacards>" << endl << endl;
+  gLog << "     <datacards>: datacards file name (dafault " << defaultcard <<")" << endl;
+  gLog << "     -?/-h: This help" << endl << endl;
+}
+
+//-----------------------------------------------------------------------------
+int main(int argc, char **argv)
+{
+  // evaluate arguments
+  MArgs arg(argc, argv);
+  if (arg.HasOnly("-?") || arg.HasOnly("-h") || arg.HasOnly("--help"))
+    {
+      Usage();
+      return -1;
+    }
+
+  TString datacard  = arg.GetArgumentStr(0);
+  if(!datacard.Length())
+    datacard = defaultcard;
+
+  if(!readDatacards(datacard))
+    {
+      cout << "Error reading datacards. Stoping" << endl;
+      return -1;
+    }
+
+  srcPos();
+}
+
+//-----------------------------------------------------------------------------
+void srcPos()
+{
+  // variable declaration  
+  Float_t xpos=xsrcpos*conver; // [mm]
+  Float_t ypos=ysrcpos*conver; // [mm] 
+  
+  // containers
+  MParList  plist;  
+  MTaskList tlist;
+  MIslands  islands;
+
+  // include containers in parameter list
+  plist.AddToList(&tlist);
+  plist.AddToList(&islands);
+	  	  
+  // tasks
+  MReadTree read("Parameters", inputFile);
+  read.DisableAutoScheme();  
+
+  MSrcTranslate   srctranslate;
+  MSrcRotate      srcrotate;
+  MSrcPosFromFile srcfromfile;
+
+  if(srcFile.Length())
+    {
+      srcfromfile.SetInputFileName(srcFile);
+      srcfromfile.SetMode(MSrcPlace::kOn);
+    }
+  else
+    {
+      srctranslate.SetTranslation(xpos,ypos);
+      srctranslate.SetRelativeTranslation(kSrcPolicy);
+      srctranslate.SetCreateHisto(kFALSE);
+      srcrotate.SetRAandDECandRefMJD(fRA,fDEC,mjdpos); 
+      srcrotate.SetMode(MSrcPlace::kOn);
+    }
+
+  MHillasSrcCalc csrc1;	  
+
+  MWriteRootFile write(outputFile,"RECREATE");
+  write.AddContainer("MHillas"       , "Parameters");
+  write.AddContainer("MHillasSrc"    , "Parameters");
+  write.AddContainer("MHillasExt"    , "Parameters");
+  write.AddContainer("MNewImagePar"  , "Parameters");
+  write.AddContainer("MRawEvtHeader" , "Parameters");
+  write.AddContainer("MRawRunHeader" , "Parameters");
+  write.AddContainer("MTime"          , "Parameters");
+  write.AddContainer("MConcentration" , "Parameters");
+  write.AddContainer("MSrcPosCam"     , "Parameters");
+  write.AddContainer("MIslands"       , "Parameters");
+  //write.AddContainer("MIslands2"     ,  "Parameters");
+
+  MControlPlots controlplots(controlplotsfilename);
+  controlplots.SetProduceFile(kFALSE);
+  
+  // include tasks in task list
+  tlist.AddToList(&read);
+  if(srcFile.Length())
+    tlist.AddToList(&srcfromfile);
+  else
+    {
+      tlist.AddToList(&srctranslate);
+      if(kRotate) 
+	tlist.AddToList(&srcrotate);  
+    }
+  tlist.AddToList(&csrc1);  
+  tlist.AddToList(&controlplots);
+  tlist.AddToList(&write);
+
+  // Eventloop
+  MEvtLoop evtloop;
+  evtloop.SetParList(&plist);
+  if (!evtloop.Eventloop(nmaxevents))
+    return;  
+ 
+  tlist.PrintStatistics();
+  
+  // do off-data if input file was specified
+  if(!offFile.Length())
+    return;
+
+  MReadTree read2("Parameters", offFile);
+  read2.DisableAutoScheme();  
+  tlist.AddToListBefore(&read2, &read, "All");
+  tlist.RemoveFromList(&read);
+
+  MWriteRootFile write2(offOutputFile,"RECREATE");
+  write2.AddContainer("MHillas"       , "Parameters");
+  write2.AddContainer("MHillasSrc"    , "Parameters");
+  write2.AddContainer("MHillasExt"    , "Parameters");
+  write2.AddContainer("MNewImagePar"  , "Parameters");
+  write2.AddContainer("MRawEvtHeader" , "Parameters");
+  write2.AddContainer("MRawRunHeader" , "Parameters");
+  write2.AddContainer("MTime"          , "Parameters");
+  write2.AddContainer("MConcentration" , "Parameters");
+  write2.AddContainer("MSrcPosCam"     , "Parameters");
+  write2.AddContainer("MIslands"       , "Parameters");
+  // write2.AddContainer("MIslands2"     ,  "Parameters");
+  tlist.AddToListBefore(&write2,&write,"All");
+  tlist.RemoveFromList(&write);
+
+  if(srcFile.Length())
+    srcfromfile.SetMode(MSrcPlace::kOff);
+  else
+    srcrotate.SetMode(MSrcPlace::kOff);
+
+  controlplots.SetMode(MControlPlots::kOff);
+  controlplots.SetProduceFile(kTRUE);
+
+  if (!evtloop.Eventloop(nmaxevents))
+    return;  
+
+  tlist.PrintStatistics();
+}
+//-----------------------------------------------------------------------
+  
+Bool_t readDatacards(TString& filename)
+{
+  ifstream ifun(filename.Data());
+  if(!ifun)
+    {
+      cout << "File " << filename << " not found" << endl;
+      return kFALSE;
+    }
+
+  TString word;
+  
+  while(ifun >> word)
+    {
+      // skip comments
+      if(word[0]=='/' && word[1]=='/')
+	{
+	  while(ifun.get()!='\n'); // skip line
+	  continue;
+	}
+      
+      // number of events
+      if(strcmp(word.Data(),"NEVENTS")==0)
+	ifun >> nmaxevents;
+
+      // input file name
+      if(strcmp(word.Data(),"INPUTFILES")==0)
+	{
+	  if(inputFile.Length())
+	    cout << "readDataCards Warning: overriding on-data file name" << endl;
+	  ifun >> inputFile;
+	}
+
+      // off-data file name
+      if(strcmp(word.Data(),"OFFFILES")==0)
+	{
+	  if(offFile.Length())
+	    cout << "readDataCards Warning: overriding off-data file name" << endl;
+	  ifun >> offFile;
+	}
+
+      // output file name
+      if(strcmp(word.Data(),"OUTFILE")==0)
+	{
+	  if(outputFile.Length())
+	    cout << "readDataCards Warning: overriding output file name" << endl;
+	  ifun >> outputFile;
+	}
+
+      // output file name (off data)
+      if(strcmp(word.Data(),"OFFOUTFILE")==0)
+	{
+	  if(offOutputFile.Length())
+	    cout << "readDataCards Warning: overriding output file name for off data" << endl;
+	  ifun >> offOutputFile;
+	}
+
+      // source position input file
+      if(strcmp(word.Data(),"SRCFILE")==0)
+	{
+	  if(srcFile.Length())
+	    cout << "readDataCards Warning: overriding source-position file name" << endl;
+	  ifun >> srcFile;
+	}
+
+      // source position
+      if(strcmp(word.Data(),"SRCPOS")==0)
+	{
+	  ifun >> xsrcpos;
+	  ifun >> ysrcpos;	  
+	  ifun >> mjdpos;
+	}
+
+      // source celestial coordinates 
+      if(strcmp(word.Data(),"SRCCOORDS")==0)
+	{
+	  ifun >> fRA;
+	  ifun >> fDEC;	  
+	}
+
+      // source movement policy flag
+      if(strcmp(word.Data(),"SRCABS")==0)
+	ifun >> kSrcPolicy;	  
+
+      // rotation flag
+      if(strcmp(word.Data(),"ROTFLAG")==0)
+	ifun >> kRotate;
+    }
+  
+  // check compulsory values
+  if(!inputFile.Length())
+    {
+      cout << "No on-data file name specified" << endl;
+      return kFALSE;
+    }
+
+  if(!outputFile.Length())
+    {
+      cout << "No output file name specified" << endl;
+      return kFALSE;
+    }
+
+  if(offFile.Length() && !offOutputFile.Length())
+    {
+      cout << "No output file name specified for off data" << endl;
+      return kFALSE;
+    }
+
+  if(xsrcpos==0 && ysrcpos==0)
+    {
+      cout << "Source position is center of the camera (as in input file)" << endl;
+      return kFALSE;
+    }
+
+  MTime thetime(mjdpos);
+
+  // Dump read values
+  cout << "************************************************" << endl;
+  cout << "* Datacards read from file " << filename << endl;
+  cout << "************************************************" << endl;
+  cout << "Maximum number of input events: " << nmaxevents << endl;
+  cout << "Input file name(s): " << inputFile << endl;
+  if(offFile.Length())
+    cout << "Input file name(s) for off data: " << offFile << endl;
+  cout << "Output file name: " << outputFile << endl;
+  if(offFile.Length())
+    cout << "Output file name for off data: " << offOutputFile << endl;
+  if(srcFile.Length())
+    cout << "Reading source position from file " << srcFile << endl;
+  else
+    {
+      cout << "Source position (degrees) X=" << xsrcpos << ", Y="<<ysrcpos;
+      if(kSrcPolicy)
+	cout << " (RELATIVE TO INITIAL SOURCE POSITION)";
+      else
+	cout << " (ABSOLUTE POSITION IN THE CAMERA)";
+      cout << ", at " << thetime.GetSqlDateTime() << endl;
+      cout << "De-rotation flag " << kRotate << endl;
+      cout << "Source celestial coordiantes (rad): RA = " << fRA << ", DEC = " << fDEC << endl;
+    }
+  cout << "***********" << endl << endl;
+
+  return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/srcpos.datacard
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/srcpos.datacard	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/programs/srcpos.datacard	(revision 9661)
@@ -0,0 +1,37 @@
+
+// Maximun number of on and off events to be processed)
+NEVENTS 9999999
+
+// Input file name pattern (wildcards allowed)
+INPUTFILES /mnt/users/jrico/magic/mars/Mars_Standard02/mtemp/mifae/hillas/crab20040215OnCal*.root
+
+// Specify optionally the name of OFF-data files you want to apply the same source position distribution to
+OFFFILES  /mnt/users/jrico/magic/mars/Mars_Standard02/mtemp/mifae/hillas/crab20040215OffCal*.root
+
+// output file name (on data)
+OUTFILE  /mnt/users/jrico/magic/mars/Mars_Standard02/mtemp/mifae/hillas/crab20040215OnRotateCalA-D.root
+
+// output file name (off data)
+OFFOUTFILE /mnt/users/jrico/magic/mars/Mars_Standard02/mtemp/mifae/hillas/crab20040215OffRotateCalA-H.root
+
+// X and Y position of the source (degrees) for a MJ date (days) -important only in case of rotation
+SRCPOS  0.3  0.1   53049.89
+
+// Flag to determine whether source position is absolute (0) or relative to previous position (1)
+SRCABS 0
+
+// rotation flag:
+//  0: Do not rotate
+//  1: Do rotate 
+ROTFLAG 1
+
+// source coordinates (RA DEC in rads)
+SRCCOORDS 1.46 0.384 // (Crab)
+// SRCCOORDS 2.899 0.667   // (Mrk 421)
+
+
+// File containing source position as a function of run number (invalidates SRCPOS, SRCABS, ROTFLAG and SRCCOORDS values)
+// SRCFILE /mnt/users/jrico/magic/mars/Mars_Standard02/mtemp/mifae/programs/20040215_Mrk421.B.pos
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/scripts/makeHillas.sh
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/scripts/makeHillas.sh	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/scripts/makeHillas.sh	(revision 9661)
@@ -0,0 +1,142 @@
+#!/bin/bash
+# Author: Javi Lopez <jlopez@ifae.es>
+# Update: 2004/05/23
+# Description: Run the makeHillas program grouping
+#              the data files with the preavious
+#              pedestal run.
+
+
+STARTDATE=$(date)
+
+#--DATACARD INFO--
+NEVENTS=999999999
+CALFLAG=1
+CLEANLEVEL1=3.0
+CLEANLEVEL2=1.5
+ISLFLAG=0
+ISLANDCLEAN1=1
+ISLANDCLEAN2=40
+SLOWCRT=1
+HVCONFFILE=/mnt/users/jlopez/Mars/Files4Mars/Config/HVSettings_FF35q.conf
+CLFILE=/local_disk/CaCoData/rootdata/Miscellaneous/Period016/2004_04_16/dc_2004_04_16_04_46_18_22368_Off3c279-2CL100.root
+#------------------
+
+MARSPATH=/mnt/users/jlopez/Mars/Mars
+MACRO=makeHillas.C
+#BIN=makeHillas
+CARD=input.datacard
+
+LOCALDIR=$(pwd)
+cd ${MARSPATH}
+
+DATAPATH=/local_disk/Data/rootdata/Mrk421/Period016/2004_04_21
+RUNS=$(ls ${DATAPATH} | gawk -F_ '{print $2}')
+#RUNS='22999 23000'
+echo RUNS ${RUNS}
+PRUNS=$(ls ${DATAPATH} | grep _P_ | gawk -F_ '{print $2}')
+#PRUNS='23209 22990'
+
+#CRUN=$(ls ${DATAPATH} | grep _C_ | gawk -F_ '{print $2}')
+CRUN=23207
+echo CRUN ${CRUN}
+
+#Look for the closer pedestal run for the calibration
+MINDIST=99999
+for PRUN in ${PRUNS}
+do
+  DIST=$[${PRUN}-${CRUN}]
+  if [ ${DIST} -lt "0" ]; then
+   DIST=$[-${DIST}]
+  fi
+#  echo PRUN ${PRUN}
+#  echo DIST ${DIST}
+  if [ ${DIST} -lt ${MINDIST} ]; then
+    PRUNFORCAL=${PRUN}
+    MINDIST=${DIST}
+  fi
+done
+echo PRUNFORCAL ${PRUNFORCAL}
+ 
+FIRSTPRUN=$(echo ${PRUNS} | gawk '{print $1}')
+for RUN in ${RUNS}
+do
+  RUNTYPE=$(ls ${DATAPATH} | grep ${RUN} | gawk -F_ '{print $3}')
+  if [ ${RUNTYPE} == "P" ]; then
+     if [  ${RUN} != ${FIRSTPRUN} ]; then
+        if [ ! -z $(echo ${DRUNS} | gawk '{print $1}')  ]; then
+#          echo PRUN ${PRUN}
+#          echo DRUNS ${DRUNS} [${FIRSTDRUN}-${LASTDRUN}]
+          DATE=$(ls ${DATAPATH} | grep ${PRUN} | gawk -F_ '{print $1}')
+          SOURCE=$(ls ${DATAPATH} | grep ${PRUN} | gawk -F_ '{print $4}')
+          #produce the datacard and run makeHillas
+          echo "NEVENTS ${NEVENTS}" > ./${CARD}
+          echo "IDIR ${DATAPATH}" >> ./${CARD}
+          echo "PCRUNS ${PRUNFORCAL}" >> ./${CARD}
+          echo "CRUNS ${CRUN}" >> ./${CARD}
+          echo "PRUNS ${PRUN}" >> ./${CARD}
+          echo "DRUNS ${FIRSTDRUN}-${LASTDRUN}" >> ./${CARD}
+          echo "OUTFILE ${DATE}_C_${CRUN}_P_${PRUN}_D_${FIRSTDRUN}-${LASTDRUN}_${SOURCE}_H.root" >>  ./${CARD}
+          echo "CALFLAG ${CALFLAG}" >> ./${CARD}
+          echo "CLEANLEVEL ${CLEANLEVEL1} ${CLEANLEVEL2}" >> ./${CARD}
+          echo "ISLFLAG ${ISLFLAG}"  >> ./${CARD}
+          echo "ISLANDCLEAN ${ISLANDCLEAN1} ${ISLANDCLEAN2}" >> ./${CARD}
+          echo "SLOWCRT ${SLOWCRT}"  >> ./${CARD}
+          echo "HVCONFFILE ${HVCONFFILE}"  >> ./${CARD}
+          echo "CLFILE ${CLFILE}" >> ./${CARD} 
+	  echo "Produced datacard for makeHillas"
+          cat ./${CARD}
+          root -b -q ${MARSSYS}/mtemp/mifae/macros/${MACRO}
+          rm ./${CARD}
+
+	  mv *_H.root ${LOCALDIR}
+        fi
+     fi
+     PRUN=${RUN}
+     DRUNS=""
+     FIRSTDRUN=""
+  else
+   if [ ${RUNTYPE} == "D" ]; then
+     if [ -z ${FIRSTDRUN} ]; then
+        FIRSTDRUN=${RUN}
+     fi
+     LASTDRUN=${RUN}
+     DRUNS="${DRUNS} ${RUN}"
+   fi
+  fi
+done
+
+if [ ! -z $(echo ${DRUNS} | gawk '{print $1}') ]; then
+#   echo PRUN ${PRUN}
+#   echo DRUNS ${DRUNS}  [${FIRSTDRUN}-${LASTDRUN}]
+
+  DATE=$(ls ${DATAPATH} | grep ${RUN} | gawk -F_ '{print $1}')
+  SOURCE=$(ls ${DATAPATH} | grep ${RUN} | gawk -F_ '{print $4}')
+  #produce the datacard and run makeHillas
+  echo "NEVENTS 99999999" > ./${CARD}
+  echo "IDIR ${DATAPATH}" >> ./${CARD}
+  echo "PCRUNS ${PRUNFORCAL}" >> ./${CARD}
+  echo "CRUNS ${CRUN}" >> ./${CARD}
+  echo "PRUNS ${PRUN}" >> ./${CARD}
+  echo "DRUNS ${FIRSTDRUN}-${LASTDRUN}" >> ./${CARD}
+  echo "OUTFILE ${DATE}_C_${CRUN}_P_${PRUN}_D_${FIRSTDRUN}-${LASTDRUN}_${SOURCE}_H.root" >>  ./${CARD}
+  echo "CALFLAG ${CALFLAG}" >> ./${CARD}
+  echo "CLEANLEVEL ${CLEANLEVEL1} ${CLEANLEVEL2}" >> ./${CARD}
+  echo "ISLFLAG ${ISLFLAG}"  >> ./${CARD}
+  echo "ISLANDCLEAN ${ISLANDCLEAN1} ${ISLANDCLEAN1}" >> ./${CARD}
+  echo "SLOWCRT ${SLOWCRT}"  >> ./${CARD}
+  echo "HVCONFFILE ${HVCONFFILE}"  >> ./${CARD}
+  echo "CLFILE ${CLFILE}" >> ./${CARD} 
+  echo "Last produced datacard for makeHillas"
+  cat ./${CARD}
+  root -b -q ${MARSSYS}/mtemp/mifae/macros/${MACRO}
+  rm ./${CARD}
+
+  mv *_H.root ${LOCALDIR}
+fi
+
+cd  ${LOCALDIR}
+
+STOPDATE=$(date)
+
+echo "STARTING DATE ${STARTDATE}"
+echo "STOPING  DATE ${STOPDATE}"
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/scripts/srcPosRun.sh
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/scripts/srcPosRun.sh	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/scripts/srcPosRun.sh	(revision 9661)
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+DCFILESPATH=/nfs/magic/CaCodata/2004_03_19
+SOURCE=Mrk421
+BIN=./psffit
+
+DCFILES=$(ls ${DCFILESPATH}/*${SOURCE}*.root)
+#echo DCFILES ${DCFILES}
+
+echo RUN SRCX SRCY
+for DCFILE in ${DCFILES}
+do
+  DCFILE=${DCFILE//${DCFILESPATH}/.}
+  #echo DCFILE ${DCFILE}
+  RUN=${DCFILE:25:5}
+  #echo RUN ${RUN}
+  if [ RUN != '00000' ]; then
+      SRCPOS=$(./${BIN} ${DCFILESPATH}/${DCFILE} | tail -1)
+      #echo SRCPOS ${SRCPOS}
+      SRCX=$(echo ${SRCPOS} | gawk '{print $2}') 
+      SIGX=$(echo ${SRCPOS} | gawk '{print $3}') 
+      SRCY=$(echo ${SRCPOS} | gawk '{print $4}')
+      SIGY=$(echo ${SRCPOS} | gawk '{print $5}')
+      CHI2=$(echo ${SRCPOS} | gawk '{print $6}')
+      #echo ${RUN}  ${SRCX} ${SIGX} ${SRCY} ${SIGY} ${CHI2}
+      echo ${RUN} ${SRCX} ${SRCY}
+  fi
+done
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/srcpositions/20040510_Mrk421.pos
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/srcpositions/20040510_Mrk421.pos	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/srcpositions/20040510_Mrk421.pos	(revision 9661)
@@ -0,0 +1,40 @@
+25791 -31.8904 -22.2868
+25793 -31.204 -25.1259
+25794 -30.8582 -26.1056
+25796 -30.8433 -27.315
+25800 -30.9893 -26.5873
+25801 -30.129 -28.5482
+25802 -30.0869 -29.0446
+25803 -29.6106 -29.6053
+25806 -29.5739 -30.2493
+25807 -29.1453 -30.803
+25811 -29.2426 -30.7231
+25812 -29.1423 -31.5773
+25813 -29.4705 -31.4197
+25814 -29.1459 -32.4534
+25816 -28.9612 -33.5763
+25817 -28.9655 -33.0914
+25819 -29.2206 -33.2739
+25820 -29.013 -33.6073
+25837 -23.6607 -37.5356
+25839 -23.2204 -38.3438
+25840 -23.2022 -38.145
+25842 -23.2352 -38.8685
+25843 -22.9597 -38.2165
+25845 -22.7618 -39.4373
+25846 -22.4334 -38.3265
+25848 -22.1283 -38.5474
+25850 -22.0476 -39.362
+25851 -21.3159 -38.6381
+25852 -20.51 -39.3704
+25854 -20.0418 -39.6989
+25855 -20.0536 -39.2094
+25858 -20.3918 -42.9825
+25860 -20.5511 -43.2302
+25861 -22.9288 -40.9434
+25862 -21.534 -43.0463
+25863 -23.9955 -41.2485
+25864 -23.6695 -42.2856
+25874 -23.8745 -43.3409
+25876 -20.2687 -43.5657
+25883 -24.6953 -42.6541
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/srcpositions/Mrk421_220404_pos.txt
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/srcpositions/Mrk421_220404_pos.txt	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/srcpositions/Mrk421_220404_pos.txt	(revision 9661)
@@ -0,0 +1,65 @@
+23203 49.2726 61.8901
+23204 41.693 83.1926
+23209 33.6331 88.5239
+23210 28.2513 92.6265
+23212 21.4295 96.1593
+23213 16.432 97.7467
+23216 0.550093 102.076
+23217 -8.98307 101.311
+23219 -19.9699 101.232
+23220 -48.3997 97.7073
+23222 -35.553 94.5315
+23223 -42.1249 90.7072
+23225 -49.72 87.585
+23226 -48.378 70.4774
+23229 -55.2906 60.7539
+23230 -56.1453 60.0578
+23232 -57.1738 52.706
+23233 -57.0943 47.5582
+23235 -63.7419 43.9618
+23236 -62.0881 37.9026
+23238 -73.589 36.2268
+23239 -70.8132 31.9569
+23241 -70.478 28.262
+23242 -69.6348 24.0415
+23244 -68.4586 20.6795
+23245 -67.2766 19.0235
+23250 -55.8484 0.194891
+23253 -53.7881 -3.28016
+23255 -52.8007 -4.84312
+23256 -51.2311 -6.88246
+23259 -48.3625 -9.56292
+23262 -45.6057 -11.7548
+23265 -43.3533 -13.5378
+23268 -44.4973 -14.4726
+23271 -43.343 -15.6643
+23273 -42.2395 -16.4098
+23275 -41.4118 -16.7661
+23278 -40.2932 -17.6661
+23279 -39.9929 -17.671
+23280 -39.711 -17.442
+23281 -39.0344 -18.3018
+23282 -38.4745 -18.2764
+23283 -35.0204 -18.1458
+23289 -34.7234 -20.9747
+23291 -34.1059 -22.5775
+23292 -34.7917 -21.5298
+23293 -33.2113 -22.229
+23294 -33.4358 -21.962
+23297 -32.7803 -21.0645
+23299 -31.8816 -21.61
+23300 -30.4907 -23.1672
+23301 -31.7465 -21.3046
+23302 -30.2575 -21.4706
+23303 -29.7285 -21.6212
+23304 -29.5768 -21.3276
+23305 -29.2646 -23.2172
+23306 -29.0006 -21.7169
+23307 -28.9752 -21.71
+23308 -29.1528 -21.6656
+23309 -28.5402 -21.0133
+23310 -28.6243 -21.7256
+23311 -29.0955 -21.5047
+23312 -29.5512 -22.1346
+23314 -29.679 -22.068
+23317 -30.901 -21.6827
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/srcpositions/Mrk421_april.pos
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/srcpositions/Mrk421_april.pos	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/srcpositions/Mrk421_april.pos	(revision 9661)
@@ -0,0 +1,326 @@
+20780 -61.6944 67.059
+20781 -64.6926 47.4227
+20783 -65.8374 43.1406
+20784 -66.6132 39.1829
+20786 -67.4031 35.7154
+20787 -66.244 32.1211
+20790 -65.9027 29.6755
+20791 -62.6377 59.1079
+20794 -65.6662 25.6452
+20795 -64.9428 22.9849
+20797 -64.1151 20.8169
+20798 -63.723 18.4919
+20800 -63.3643 16.6103
+20801 -63.1704 14.2815
+20804 -62.7876 13.6825
+20805 -62.4634 11.3297
+20806 -62.1662 9.6296
+20807 -60.0303 8.64362
+20808 -60.2703 0.509429
+20809 -59.386 -0.938021
+20811 -58.1121 -4.42333
+20812 -56.5063 -5.16089
+20813 -54.9194 -6.98546
+20814 -53.7668 -8.03962
+20818 -46.0907 -16.6877
+20819 -45.8623 -14.8199
+20820 -45.7539 -14.3919
+20821 -44.929 -16.358
+22245 10.2468 23.1621
+22249 25.85 25.9106
+22250 25.6546 29.1566
+22251 29.1613 25.4159
+22254 58.316 33.7302
+22255 37.5861 29.4664
+22257 57.9896 34.7069
+22258 61.9726 25.5081
+22260 81.5392 37.5373
+22261 70.6807 16.5722
+22264 58.1712 25.6161
+22266 66.3476 40.3227 
+22384 33.7108 44.2858
+22388 31.4939 45.9244
+22394 36.3619 47.3819
+22395 38.3426 48.5743
+22400 39.6094 48.8239
+22401 41.1102 50.745
+22406 42.1073 51.6704
+22407 43.8524 54.075
+22411 45.2629 54.7259
+22412 45.3289 58.2773
+22413 45.9415 58.2507
+22414 69.3919 87.317
+22429 52.0164 66.3798
+22439 45.8513 71.0317
+22440 45.5684 71.4425
+22450 43.789 74.1573
+22451 41.3883 76.8225
+22461 410.064 168.151
+22462 407.911 169.206
+22466 394.568 183.316
+22467 393.798 194.727
+22477 380.467 220.11
+22478 373.801 240.848
+22483 20.3671 101.709
+22484 14.4039 101.842
+22489 8.03032 103.608
+22490 0.0405639 104.229
+22495 289.384 348.55
+22496 255.487 359.161
+22503 -15.7097 106.418
+22504 -22.6365 102.47
+22511 -30.7607 100.265
+22512 -33.8572 100.537
+22516 -41.9986 100.456
+22517 -48.2052 90.4964
+22522 -65.668 42.6643
+22526 -65.0008 41.6949
+22527 -65.629 38.2615
+22531 -66.3627 35.6813
+22532 -67.0988 32.6288
+22534 -67.5101 30.7526
+22535 -66.7941 28.2758
+22538 -66.0013 26.5091
+22539 -65.0212 23.9648
+22541 -64.507 22.077
+22544 -63.4069 19.9872
+22558 276.466 -110.216
+22559 -263.554 -391.457
+22560 -284.903 -390.722
+22711 244.229 32.1922
+22717 587.4 109.335
+22718 53.802 53.875
+22719 44.9718 46.5444
+22720 48.771 45.2452
+22722 46.5953 51.4958
+22723 47.1241 57.9021
+22725 46.6285 59.6458
+22726 48.0192 62.5682
+22728 46.6808 63.3769
+22729 81.7319 131.281
+22731 41.5407 73.4151
+22732 38.9125 74.97
+22735 394.369 184.289
+22736 391.167 187.667
+22738 375.638 224.6
+22739 368.822 243.244
+22743 16.1032 94.8722
+22744 11.2596 95.7668
+22746 4.11151 98.6553
+22747 -5.51529 98.7573
+22749 258.705 353.641
+22750 228.989 359.292
+22752 -22.5239 97.8863
+22754 -25.7971 97.6711
+22755 -31.3562 96.3472
+22756 -35.3656 94.8347
+22757 -43.9467 89.2152
+22758 -54.7801 64.0827
+22763 -63.5534 45.2586
+22765 -64.7755 40.1216
+22766 -65.8142 38.821
+22768 -66.4905 35.2643
+22769 -67.0298 32.6377
+22810 -117.508 -441.851
+22811 -200.855 -401.565
+22962 40.604 36.4264
+22964 599.401 46.4693
+22965 63.519 44.8682
+22967 365.741 -0.122339
+22969 369.93 20.0097
+00000 300.355 -52.2264
+22970 280.213 -149.609
+22971 234.378 -216.905
+22973 254.659 189.151
+22974 101.128 -67.7792
+22976 47.8854 59.8481
+22977 47.2984 63.6432
+22979 46.9635 66.0826
+22980 44.1839 70.2999
+22982 43.3303 73.4819
+22983 37.8974 77.0181
+22985 395.191 176.371
+22986 393.522 190.227
+22988 390.085 162.713
+22989 375.7 224.23
+22995 259.366 357.751
+22996 223.73 362.435
+22998 -21.9336 102.655
+22999 -28.3336 97.6638
+23001 -44.8834 89.8799
+23002 -50.7141 85.5837
+23005 -60.7778 56.2697
+23008 -65.9688 42.2415
+23010 -66.5424 40.1167
+23011 -67.0799 36.9962
+23013 -67.3001 33.4055
+23014 -67.4957 32.6484
+23016 -67.5712 30.9981
+23017 -67.2629 28.5432
+23019 -66.3983 26.7778
+23020 -65.4753 24.7367
+23022 -64.1789 22.3838
+23023 -63.4728 20.7786
+23025 -60.7328 12.414
+23030 -57.9515 10.0549
+23031 -57.1479 7.4803
+23033 -53.4069 3.53683
+23035 -53.9728 -4.72199
+23036 -52.1748 -5.9891
+23037 -50.7731 -6.82306
+23038 -48.9648 -8.49934
+23041 -47.7019 -9.17361
+23042 -46.4665 -10.6739
+23044 -45.0935 -10.5075
+23045 -44.107 -12.1032
+23047 -43.4158 -11.1391
+23048 -43.0353 -13.1539
+23051 -42.7699 -12.5803
+23052 -42.1787 -13.5728
+23054 -41.6294 -13.8375
+23055 -41.2568 -14.0938
+23057 -290.439 250.263
+23062 -297.09 263.923
+23063 -298.562 260.606
+23065 -299.633 250.574
+23066 -300.793 248.678
+23069 -301.577 248.353
+23070 -305.353 240.577
+23072 -305.971 240.208
+23073 -308.467 237.252
+23076 -309.522 235.973
+23077 -308.17 235.072
+23081 -309.601 234.154
+23082 -307.69 232.974
+23084 -310.036 231.466
+23085 -310.173 229.806
+23086 -311.19 228.58
+23087 -311.67 226.48
+23088 -312.337 224.47
+23089 -313.102 222.753
+23091 -314.491 219.638
+23092 -315.423 219.455
+23093 -316.648 211.099
+23094 -317.449 216.1
+23096 -318.305 213.36
+23097 -319.057 212.771
+23098 -319.745 212.283
+00000 -319.947 211.413
+23099 -320.291 209.397
+23100 -320.67 210.915
+23101 -321.542 211.145
+23102 -322.189 209.441
+23104 -322.937 209.212
+23105 -323.247 207.812
+23107 -323.708 206.321
+23108 -323.338 200.837
+23203 45.1872 61.2712
+23204 394.129 182.738
+23209 376.848 222.488
+23210 91.4164 230.426
+23212 15.2987 98.4375
+23213 9.83596 100.328
+23216 -2.32038 104.881
+23217 -9.40899 104.143
+23219 245.469 359.594
+23220 219.868 376.786
+23223 143.542 397
+23225 130.714 401.776
+23226 125.609 404.129
+23229 -62.92 55.0264
+23230 -66.0427 47.7518
+23232 -67.3102 44.9688
+23233 -67.9107 41.3038
+23235 -68.3111 38.6037
+23236 -68.415 35.9021
+23238 -68.563 33.0559
+23239 -68.2589 29.757
+23241 -67.9479 28.7807
+23242 -67.3735 26.8282
+23244 -66.6344 25.2004
+23245 -66.0266 24.3683
+23278 -38.4621 -15.8849
+23279 -38.1683 -15.9046
+23280 -291.557 248.291
+23281 -295.06 263.191
+23282 -296.571 269.995
+23283 -297.366 266.598
+23286 -310.404 237.349
+23288 -311.872 235.932
+23289 -311.352 235.505
+23291 -305.265 238.91
+23292 -308.408 234.851
+23293 -310.426 224.93
+23294 -311.411 232.103
+23296 -312.035 231.051
+23297 -312.038 229.156
+23298 -312.824 228.12
+23299 -313.127 225.547
+23300 -313.222 222.556
+23301 -314.431 222.262
+23302 -315.148 220.916
+23303 -315.74 219.728
+23304 -316.556 218.823
+00000 -316.638 217.144
+23305 -316.76 217.022
+23306 -317.965 221.19
+23307 -318.97 214.2
+23308 -319.403 208.621
+23309 -320.184 206.064
+23310 -320.648 208.893
+23311 -322.682 215.685
+23312 -318.403 206.408
+23313 -599.997 13.1938
+23314 -59.0671 -27.9948
+23316 -234.741 196.301
+23317 -240.554 192.296
+23425 -66.5951 18.1945
+23426 -63.939 8.33197
+23427 -56.5394 -0.631792
+23428 -54.9475 -2.29846
+23442 -53.4959 -4.3676
+23443 -53.2873 -2.89022
+23449 -50.1898 -6.25351
+23450 -49.0202 -6.93665
+23464 -48.5527 -6.68196
+23465 -47.1345 -8.4623
+23479 -46.0659 -9.21844
+23480 -44.326 -9.73134
+23495 -43.4018 -9.54128
+23496 -41.9692 -10.3322
+23511 -286.402 284.23
+23512 -286.98 278.243
+23527 -290.011 278.777
+23528 -291.986 277.958
+23544 -293.79 277.126
+23545 -295.22 275.579
+23561 -307.265 242.111
+23562 -308.875 240.952
+23573 -309.08 237.911
+23574 -311.794 238.41
+23586 -311.922 233.851
+23588 -313.525 236.201
+23599 -313.652 233.38
+23600 -314.257 233.529
+23611 -310.519 233.267
+23612 -313.229 230.611
+23622 -315.964 226.994
+23623 -315.815 226.584
+23634 -317.842 222.603
+23636 -318.592 222.275
+23647 -319.315 221.166
+23648 -320.237 219.248
+23663 -320.955 218.693
+23664 -321.558 216.198
+23675 -322.119 214.459
+23676 -322.734 212.887
+23686 -323.392 211.242
+23687 -324.446 207.76
+23698 -325.499 205.158
+23699 -331.149 201.771
+23709 -333.366 199.833
+23710 -332.384 197
+23720 -315.361 196.689
+23721 92.2192 241.811
+23732 -332.349 193.469
+23733 90.7276 242.28
Index: /tags/Mars_V0-8-5/Mars/mtemp/mifae/srcpositions/Mrk421_may.pos
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mifae/srcpositions/Mrk421_may.pos	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mifae/srcpositions/Mrk421_may.pos	(revision 9661)
@@ -0,0 +1,41 @@
+25791 -84.8946 47.6763
+25794 -122.125 48.4988
+25796 -122.461 49.1271
+25797 -158.079 50.8216
+25801 -84.0898 46.3166
+25802 -84.5659 47.6243
+25803 -83.9559 46.2252
+25806 -85.946 51.5223
+25807 -94.0789 51.5786
+25811 -84.4276 47.8788
+25812 -84.3594 47.8559
+25813 -84.5057 48.0659
+25814 -84.3513 47.8463
+25817 -94.3231 52.0249
+25820 -93.7396 50.8518
+25837 -100.304 51.9021
+25839 -100.155 51.9117
+25840 -133.041 50.619
+25842 -153.155 51.9754
+25843 -164.676 50.8785
+25845 -167.419 52.1466
+25846 -152.706 51.8807
+25847 -156.14 52.1006
+25848 -155.703 52.0932
+25850 -153.024 52.1258
+00000 -150.056 51.9723
+25851 -157.841 51.8809
+25852 -155.837 51.886
+25854 -158.421 51.9508
+25855 -156.322 51.9079
+25858 -103.452 52.2983
+25861 -103.909 52.3202
+25862 -98.145 52.5624
+25863 -99.9381 52.4628
+25865 -101.62 52.8831
+25874 -104.375 52.2092
+25875 -109.995 51.9257
+25876 -83.6544 48.1068
+25877 -108.161 52.0623
+25883 -83.6796 48.0056
+25884 -119.101 66.3904
Index: /tags/Mars_V0-8-5/Mars/mtemp/mmpi/MAstroCamera.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mmpi/MAstroCamera.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mmpi/MAstroCamera.cc	(revision 9661)
@@ -0,0 +1,561 @@
+/*====================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without expressed
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz, 3/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MAstroCamera
+// ============
+//
+// A tools displaying stars from a catalog in the camera display.
+// PRELIMINARY!!
+//
+//
+// Usage:
+// ------
+// For a usage example see macros/starfield.C
+//
+// To be able to reflect the star-light you need the geometry of the
+// mirror and the distance of the plain screen.
+//
+// You can get the mirror geometry from a MC file and the distance of
+// the screen from MGeomCam.
+//
+//
+// Algorithm:
+// ----------
+// The calculation of the position of the reflection in the camera is
+// done by:
+//   - Rotation of the star-field such that the camera is looking into
+//     the pointing direction
+//   - Calculation of the reflected star-light vector by calling
+//     MGeomMirror::GetReflection (which returns the point at which
+//     the vector hits the camera plain)
+//   - Depending on the draw-option you get each reflected point, the
+//     reflection on a virtual ideal mirror or the reflection on each
+//     individual mirror
+//
+//
+// GUI:
+// ----
+//  * You can use the the cursor keys to change the pointing position
+//    and plus/minus to change the time by a quarter of an hour.
+//
+// ToDo:
+// -----
+//  * possibility to overwrite distance from mirror to screen
+//  * read the mirror geometry directly from the MC input file
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MAstroCamera.h"
+
+#include <errno.h>        // strerror
+#include <fstream>        // ifstream
+
+#include <KeySymbols.h>   // kKey_*
+
+#include <TH2.h>          // TH2D
+#include <TMarker.h>      // TMarker
+#include <TVirtualPad.h>  // gPad
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MGeomCam.h"
+#include "MGeomMirror.h"
+
+#include "MTime.h"
+#include "MAstroSky2Local.h"
+#include "MObservatory.h"
+
+#include "../mhist/MHCamera.h" // FIXME: This dependancy is very bad!
+                      // HOW TO GET RID OF IT? Move MHCamera to mgeom?
+
+#include "MStarLocalPos.h"
+
+ClassImp(MAstroCamera);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Create a virtual MGeomMirror which is in the center of the coordinate
+// system and has a normal vector in z-direction.
+//
+MAstroCamera::MAstroCamera() : fGeom(0), fMirrors(0)
+{
+    fMirror0 = new MGeomMirror;
+    fMirror0->SetMirrorContent(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete fGeom, fMirrors and the virtual 0-Mirror fMirror0
+//
+MAstroCamera::~MAstroCamera()
+{
+    if (fGeom)
+        delete fGeom;
+    if (fMirrors)
+        delete fMirrors;
+
+    delete fMirror0;
+
+}
+
+// --------------------------------------------------------------------------
+//
+// Set a list of mirrors. The Mirrors must be of type MGeomMirror and
+// stored in a TClonesArray
+//
+void MAstroCamera::SetMirrors(TClonesArray &arr)
+{
+    if (arr.GetClass()!=MGeomMirror::Class())
+    {
+      cout << "ERROR - TClonesArray doesn't contain objects of type MGeomMirror... ignored." << endl;
+      return;
+    }
+
+    const Int_t n = arr.GetSize();
+
+    if (!fMirrors)
+        fMirrors = new TClonesArray(MGeomMirror::Class(), n);
+
+    fMirrors->ExpandCreate(n);
+
+    for (int i=0; i<n; i++)
+        memcpy((*fMirrors)[i], arr[i], sizeof(MGeomMirror));
+
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Read the mirror geometry from a MC .def file. The following
+// structure is expected:
+//
+// #*  TYPE=1  (MAGIC)
+// #*      i  f   sx   sy   x   y   z   thetan  phin 
+// #* 
+// #*       i : number of the mirror
+// #*       f : focal distance of that mirror
+// #*      sx : curvilinear coordinate of mirror's center in X[cm]
+// #*      sy : curvilinear coordinate of mirror's center in X[cm]
+// #*       x : x coordinate of the center of the mirror [cm]
+// #*       y : y coordinate of the center of the mirror [cm]
+// #*       z : z coordinate of the center of the mirror [cm]
+// #*  thetan : polar theta angle of the direction where the mirror points to
+// #*    phin : polar phi angle of the direction where the mirror points to
+// #*      xn : xn coordinate of the normal vector in the center (normalized)
+// #*      yn : yn coordinate of the normal vector in the center (normalized)
+// #*      zn : zn coordinate of the normal vector in the center (normalized)
+// #
+// define_mirrors
+//   1 1700.9200   25.0002   75.0061   25.0000   75.0000    0.9207 0.02328894 1.24904577 -0.00736394 -0.02209183 0.99972882
+//   2 ...
+//
+void MAstroCamera::SetMirrors(const char *fname)
+{
+    ifstream fin(fname);
+    if (!fin)
+    {
+        gLog << err << "Cannot open file " << fname << ": ";
+        gLog << strerror(errno) << endl;
+        return;
+    }
+
+    TString line;
+    while (1)
+    {
+        line.ReadLine(fin);
+        if (!fin)
+            return;
+
+        line = line.Strip(TString::kBoth);
+
+        if (line.BeginsWith("n_mirrors"))
+        {
+            Int_t n;
+            sscanf(line.Data(), "%*s %d", &n);
+
+            if (!fMirrors)
+                fMirrors = new TClonesArray(MGeomMirror::Class(), n);
+
+            fMirrors->ExpandCreate(n);
+            continue;
+        }
+
+
+        Int_t id;
+        Float_t f, sx, sy, x, y, z, thetan, phin, xn, yn, zn;
+
+        const Int_t n = sscanf(line.Data(), "%d %f %f %f %f %f %f %f %f %f %f %f",
+                               &id, &f, &sx, &sy, &x, &y, &z, &thetan,
+                               &phin, &xn, &yn, &zn);
+        if (n!=12)
+            continue;
+
+        new ((*fMirrors)[id-1]) MGeomMirror;
+        ((MGeomMirror*)(*fMirrors)[id-1])->SetMirrorContent(id, f, sx, sy, x, y, z, thetan, phin, xn, yn, zn);
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+// Set the camera geometry. The MGeomCam object is cloned.
+//
+void MAstroCamera::SetGeom(const MGeomCam &cam)
+{
+    if (fGeom)
+        delete fGeom;
+
+    fGeom = (MGeomCam*)cam.Clone();
+}
+
+// --------------------------------------------------------------------------
+//
+// Convert To Pad coordinates (see MAstroCatalog)
+//
+Int_t MAstroCamera::ConvertToPad(const TVector3 &w, TVector2 &v) const
+{
+    /*
+     --- Use this to plot the 'mean grid' instead of the grid of a
+         theoretical central mirror ---
+
+        TVector3 spot;
+        const Int_t num = fConfig->GetNumMirror();
+        for (int i=0; i<num; i++)
+        spot += fConfig->GetMirror(i).GetReflection(w, fGeom->GetCameraDist())*1000;
+        spot *= 1./num;
+        */
+
+    const TVector3 spot = fMirror0->GetReflection(w, fGeom->GetCameraDist())*1000;
+    v.Set(spot(0), spot(1));
+
+    const Float_t max = fGeom->GetMaxRadius()*0.70;
+    return v.X()>-max && v.Y()>-max && v.X()<max && v.Y()<max;
+}
+
+// --------------------------------------------------------------------------
+//
+// Find an object with a given name in the list of primitives of this pad.
+//
+TObject *FindObjectInPad(const char *name, TVirtualPad *pad)
+{
+    if (!pad)
+        pad = gPad;
+
+    if (!pad)
+        return NULL;
+
+    TObject *o;
+
+    TIter Next(pad->GetListOfPrimitives());
+    while ((o=Next()))
+    {
+        if (o->InheritsFrom(gROOT->GetClass(name)))
+            return o;
+
+        if (o->InheritsFrom("TPad"))
+            if ((o = FindObjectInPad(name, (TVirtualPad*)o)))
+                return o;
+    }
+    return NULL;
+}
+
+// --------------------------------------------------------------------------
+//
+// Options:
+//
+//  '*' Draw the mean of the reflections on all mirrors
+//  '.' Draw a dot for the reflection on each individual mirror
+//  'h' To create a TH2D of the star-light which is displayed
+//  'c' Use the underlaying MHCamera as histogram
+//  '0' Draw the reflection on a virtual perfect mirror
+//  '=' Draw '0' or '*' propotional to the star magnitude
+//
+// If the Pad contains an object MHCamera of type MHCamera it is used.
+// Otherwise a new object is created.
+//
+void MAstroCamera::AddPrimitives(TString o)
+{
+    if (!fTime || !fObservatory || !fMirrors)
+    {
+      cout << "Missing data..." << endl;
+        return;
+    }
+
+    if (o.IsNull())
+        o = "*.";
+
+    const Bool_t hasnull = o.Contains("0", TString::kIgnoreCase);
+    const Bool_t hashist = o.Contains("h", TString::kIgnoreCase);
+    const Bool_t hasmean = o.Contains("*", TString::kIgnoreCase);
+    const Bool_t hasdot  = o.Contains(".", TString::kIgnoreCase);
+    const Bool_t usecam  = o.Contains("c", TString::kIgnoreCase);
+    const Bool_t resize  = o.Contains("=", TString::kIgnoreCase);
+
+    // Get camera
+    MHCamera *camera=(MHCamera*)FindObjectInPad("MHCamera", gPad);
+    if (camera)
+    {
+        if (!camera->GetGeometry() || camera->GetGeometry()->IsA()!=fGeom->IsA())
+            camera->SetGeometry(*fGeom);
+    }
+    else
+    {
+        camera = new MHCamera(*fGeom);
+        camera->SetName("MHCamera");
+        camera->SetStats(0);
+        camera->SetInvDeepBlueSeaPalette();
+        camera->SetBit(kCanDelete);
+        camera->Draw();
+    }
+
+    camera->SetTitle(GetPadTitle());
+
+    gPad->cd(1);
+
+    if (!usecam)
+    {
+        if (camera->GetEntries()==0)
+            camera->SetBit(MHCamera::kNoLegend);
+    }
+    else
+    {
+        camera->Reset();
+        camera->SetYTitle("arb.cur");
+    }
+
+    TH2 *h=0;
+    if (hashist)
+    {
+        TH2F hist("","", 90, -650, 650, 90, -650, 650);
+        hist.SetMinimum(0);
+        h = (TH2*)hist.DrawCopy("samecont1");
+    }
+
+    const TRotation rot(GetGrid(kTRUE));
+
+    MVector3 *radec;
+    TIter Next(&fList);
+
+    while ((radec=(MVector3*)Next()))
+    {
+        const Double_t mag = radec->Magnitude();
+        if (mag>GetLimMag())
+            continue;
+
+        TVector3 star(*radec);
+
+        // Rotate Star into telescope system
+        star *= rot;
+
+        TVector3 mean;
+
+        Int_t num = 0;
+
+        MGeomMirror *mirror = 0;
+        TIter NextM(fMirrors);
+        while ((mirror=(MGeomMirror*)NextM()))
+        {
+  	    const TVector3 spot = mirror->GetReflection(star, fGeom->GetCameraDist())*1000;
+            
+            // calculate mean of all 'stars' hitting the camera plane
+            // by taking the sum of the intersection points between
+            // the light vector and the camera plane
+            mean += spot;
+
+            if (hasdot)
+            {
+                TMarker *m=new TMarker(spot(0), spot(1), 1);
+                m->SetMarkerColor(kMagenta);
+                m->SetMarkerStyle(kDot);
+                fMapG.Add(m);
+            }
+            if (h)
+                h->Fill(spot(0), spot(1), pow(10, -mag/2.5));
+
+            if (usecam)
+                camera->Fill(spot(0), spot(1), pow(10, -mag/2.5));
+
+            num++;
+        }
+
+        // transform meters into millimeters (camera display works with mm)
+        mean *= 1./num;
+        DrawStar(mean(0), mean(1), *radec, hasmean?kBlack:-1, Form("x=%.1fmm y=%.1fmm", mean(0), mean(1)), resize);
+        if (hasnull)
+        {
+            TVector3 star(*radec);
+            star *= rot;
+            const TVector3 spot = fMirror0->GetReflection(star, fGeom->GetCameraDist())*1000;
+            DrawStar(spot(0), spot(1), *radec, hasmean?kBlack:-1, Form("x=%.1fmm y=%.1fmm", mean(0), mean(1)), resize);
+            // This can be used to get the abberation...
+            //cout << TMath::Hypot(spot(0), spot(1)) << " " << TMath::Hypot(mean(0)-spot(0), mean(1)-spot(1)) << endl;
+        }
+    }
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Fills a TList with all stars found under current presets
+// (Coordinates, Time, FOV). The list is emptied before the filling is done.
+// Currently, the mean spot when averaging over all mirrors is used.
+//
+void MAstroCamera::FillStarList(TList* list)
+{
+    if (!fTime || !fObservatory || !fMirrors) {
+      cout << "Missing data..." << endl;
+      return;
+    }
+
+    if (!list) {
+      cout << "Missing storage list for stars found..." << endl;
+      return;
+    }
+
+    list->Delete(); // dump old list... (otherwise the same stars would pile up)
+   
+    const TRotation rot(GetGrid(kTRUE));
+    MVector3 *radec;
+    TIter Next(&fList);
+
+    while ((radec=(MVector3*)Next())) {
+      const Double_t mag = radec->Magnitude();
+      if (mag>GetLimMag())
+	continue;
+      TVector3 star(*radec);
+      // Rotate Star into telescope system
+      star *= rot;
+      TVector3 mean;
+      Int_t num = 0;
+      MGeomMirror *mirror = 0;
+      TIter NextM(fMirrors);
+      while ((mirror=(MGeomMirror*)NextM())) {
+	const TVector3 spot = mirror->GetReflection(star, fGeom->GetCameraDist())*1000;
+	mean += spot;
+	num++;
+      }
+      mean *= 1./num;
+      MStarLocalPos *starpos = new MStarLocalPos;
+      starpos->SetExpValues(mag,mean(0),mean(1));
+      
+      TString name = radec->GetName();
+      if (name.Length()==0) {
+	starpos->SetName("unknown"); 
+      } else {
+	starpos->SetName(radec->GetName());
+      }	 
+      list->Add(starpos);   
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// Uses fRaDec as a reference point.
+//
+// Return dZd and dAz corresponding to the distance from x,y to fRaDec
+//
+// Before calling this function you should correct for abberation. In
+// case of MAGIC you can do this by:
+//    x /= 1.0713;
+//    y /= 1.0713;
+//
+// x [mm]: x coordinate in the camera plane (assuming a perfect mirror)
+// y [mm]: y coordinate in the camera plane (assuming a perfect mirror)
+//
+// We assume (0, 0) to be the center of the FOV
+//
+// dzd [deg]: Delta Zd
+// daz [deg]: Delta Az
+//
+void MAstroCamera::GetDiffZdAz(Double_t x, Double_t y, Double_t &dzd, Double_t &daz)
+{
+    // Reflect the corrected pixel on a perfect mirror
+    TVector3 v(x, y, fGeom->GetCameraDist()*1000);
+    TVector3 spot = fMirror0->GetReflection(v);
+    
+    // Derotate into the local coordinate system
+    const MAstroSky2Local rot(*fTime, *fObservatory);
+    const TRotation align(AlignCoordinates(rot*fRaDec).Inverse());
+    spot *= align;
+
+    cout << "Zd="<<spot.Theta()*TMath::RadToDeg() << " ";
+    cout << "Az="<<spot.Phi()  *TMath::RadToDeg()+360 << endl;
+
+    // Derotatet the center of the camera
+    TVector3 c(0, 0, 1);
+    c *= align;
+
+    dzd = (spot.Theta()-c.Theta())*TMath::RadToDeg();
+    daz = (spot.Phi()  -c.Phi())  *TMath::RadToDeg();
+
+    if (daz> 180) daz -= 360;
+    if (daz<-180) daz += 360;
+}
+
+// ------------------------------------------------------------------------
+//
+// Execute a gui event on the camera
+//
+void MAstroCamera::ExecuteEvent(Int_t event, Int_t mp1, Int_t mp2)
+{
+    // if (mp1>0 && mp2>0)
+    // {
+    //     // Calculate World coordinates from pixel
+    //     Double_t x = gPad->AbsPixeltoX(mp1);
+    //     Double_t y = gPad->AbsPixeltoY(mp2);
+    //
+    //     // Correct for abberation
+    //     x /= 1.0713;
+    //     y /= 1.0713;
+    //
+    //     Double_t dzd, daz;
+    //     GetDiffZdAz(x, y, dzd, daz);
+    //
+    //     cout << "dZd="<< dzd << " " << "dAz="<< daz << endl;
+    // }
+    //
+    // For MAGIC the distance of the mean of the light distribution
+    // to the Mirror0 reflection of the star (Abberation) can be
+    // expressed as:  dr = 0.0713*r = r/14.03
+    //                   +-0.0002
+
+    if (event==kKeyPress && fTime)
+        switch (mp2)
+        {
+        case kKey_Plus:
+            fTime->SetMjd(fTime->GetMjd()+0.25/24);
+            Update(kTRUE);
+            return;
+
+        case kKey_Minus:
+            fTime->SetMjd(fTime->GetMjd()-0.25/24);
+            Update(kTRUE);
+            return;
+        }
+
+    MAstroCatalog::ExecuteEvent(event, mp1, mp2);
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/mmpi/MAstroCamera.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mmpi/MAstroCamera.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mmpi/MAstroCamera.h	(revision 9661)
@@ -0,0 +1,44 @@
+#ifndef MARS_MAstroCamera
+#define MARS_MAstroCamera
+
+#ifndef MARS_MAstroCatalog
+#include "MAstroCatalog.h"
+#endif
+
+class TClonesArray;
+class TList;
+
+class MTime;
+class MGeomCam;
+class MGeomMirror;
+class MObservatory;
+
+class MAstroCamera : public MAstroCatalog
+{
+private:
+    MGeomCam     *fGeom;
+    TClonesArray *fMirrors;
+
+    MGeomMirror  *fMirror0;     //!
+
+    Int_t  ConvertToPad(const TVector3 &w, TVector2 &v) const;
+    void   AddPrimitives(TString o);
+    void   SetRangePad(Option_t *o) { }
+    void   ExecuteEvent(Int_t event, Int_t mp1, Int_t mp2);
+
+public:
+    MAstroCamera();
+    ~MAstroCamera();
+
+    void SetMirrors(TClonesArray &arr);
+    void SetMirrors(const char *fname);
+    void SetGeom(const MGeomCam &cam);
+
+    void FillStarList(TList *list);
+
+    void GetDiffZdAz(Double_t x, Double_t y, Double_t &dzd, Double_t &daz);
+
+    ClassDef(MAstroCamera, 1) // Display class to display stars on the camera
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtemp/mmpi/MFindStars.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mmpi/MFindStars.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mmpi/MFindStars.cc	(revision 9661)
@@ -0,0 +1,946 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!   Author(s): Robert Wagner, 2/2004 <mailto:rwagner@mppmu.mpg.de>
+!   Author(s): Javier López , 4/2004 <mailto:jlopez@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MFindStars
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MFindStars.h"
+
+#include <TMinuit.h>
+#include <TStopwatch.h>
+#include <TTimer.h>
+#include <TString.h>
+#include <TFile.h>
+#include <TTree.h>
+#include <TCanvas.h>
+#include <TH1F.h>
+#include <TF1.h>
+#include <TEllipse.h>
+
+
+#include "MObservatory.h"
+#include "MAstroCamera.h"
+#include "MMcConfigRunHeader.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MHCamera.h"
+
+#include "MGeomCam.h"
+#include "MGeomPix.h"
+#include "MCameraDC.h"
+#include "MTime.h"
+#include "MReportDrive.h"
+#include "MStarLocalCam.h"
+#include "MStarLocalPos.h"
+
+#include "MParList.h"
+#include "MTaskList.h"
+
+ClassImp(MFindStars);
+using namespace std;
+
+const Float_t sqrt2 = sqrt(2.);
+const Float_t sqrt3 = sqrt(3.);
+const UInt_t  lastInnerPixel = 396;
+    
+
+//______________________________________________________________________________
+//
+// The 2D gaussian fucntion used to fit the spot of the star
+//
+static Double_t func(float x,float y,Double_t *par)
+{
+    Double_t value=par[0]*exp(-(x-par[1])*(x-par[1])/(2*par[2]*par[2]))*exp(-(y-par[3])*(y-par[3])/(2*par[4]*par[4]));
+    return value;
+}
+
+//______________________________________________________________________________
+//
+// Function used by Minuit to do the fit
+//
+static void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)
+{
+
+  MParList*      plist = (MParList*)gMinuit->GetObjectFit();
+  MTaskList*     tlist = (MTaskList*)plist->FindObject("MTaskList");
+  MFindStars*    find = (MFindStars*)tlist->FindObject("MFindStars");
+  MStarLocalCam* stars = (MStarLocalCam*)plist->FindObject("MStarLocalCam");
+  MGeomCam*      geom = (MGeomCam*)plist->FindObject("MGeomCam");
+
+  MHCamera& display = (MHCamera&)find->GetDisplay();
+  
+  Float_t innerped = stars->GetInnerPedestalDC();
+  Float_t innerrms = stars->GetInnerPedestalRMSDC();
+  Float_t outerped = stars->GetOuterPedestalDC();
+  Float_t outerrms = stars->GetOuterPedestalRMSDC();
+
+  UInt_t numPixels = geom->GetNumPixels();
+  
+//calculate chisquare
+    Double_t chisq = 0;
+    Double_t delta;
+    Double_t x,y,z;
+    Double_t errorz=0;
+
+    UInt_t usedPx=0;
+    for (UInt_t pixid=1; pixid<numPixels; pixid++) 
+    {
+	if (display.IsUsed(pixid))
+	{
+	    x = (*geom)[pixid].GetX();
+	    y = (*geom)[pixid].GetY();
+            z = display.GetBinContent(pixid+1)-(pixid>lastInnerPixel?outerped:innerped);
+            errorz=(pixid>lastInnerPixel?outerrms:innerrms);
+
+	    if (errorz > 0.0)
+	    {
+              usedPx++;
+              delta  = (z-func(x,y,par))/errorz;
+              chisq += delta*delta;
+	    }
+	    else
+		cerr << " TMinuit::fcn errorz[" << pixid << "] " << errorz << endl;
+	}
+    }
+    f = chisq;
+
+    find->SetChisquare(chisq);
+    find->SetDegreesofFreedom(usedPx);
+}
+
+MFindStars::MFindStars(const char *name, const char *title): 
+  fGeomCam(NULL), fCurr(NULL), fTimeCurr(NULL), fDrive(NULL), fStars(NULL), fNumVar(5)
+{
+  fName  = name  ? name  : "MFindStars";
+  fTitle = title ? title : "Tool to find stars from DC Currents";
+
+  fNumIntegratedEvents=0;
+  fMaxNumIntegratedEvents = 10;
+  fRingInterest = 125.; //[mm] ~ 0.4 deg
+  fDCTailCut = 4;
+  
+  fPixelsUsed.Set(577);
+  fPixelsUsed.Reset((Char_t)kTRUE);
+  
+  //Fitting(Minuit) initialitation
+  const Float_t pixelSize = 31.5; //[mm]
+  fMinuitPrintOutLevel = -1;
+  
+  fVname = new TString[fNumVar];
+  fVinit.Set(fNumVar); 
+  fStep.Set(fNumVar); 
+  fLimlo.Set(fNumVar); 
+  fLimup.Set(fNumVar); 
+  fFix.Set(fNumVar);
+
+  fVname[0] = "max";
+  fVinit[0] = 10.*fMaxNumIntegratedEvents;
+  fStep[0]  = fVinit[0]/sqrt2;
+  fLimlo[0] = fMinDCForStars;
+  fLimup[0] = 30.*fMaxNumIntegratedEvents;
+  fFix[0]   = 0;
+
+  fVname[1] = "meanx";
+  fVinit[1] = 0.;
+  fStep[1]  = fVinit[1]/sqrt2;
+  fLimlo[1] = -600.;
+  fLimup[1] = 600.;
+  fFix[1]   = 0;
+
+  fVname[2] = "sigmaminor";
+  fVinit[2] = pixelSize;
+  fStep[2]  = fVinit[2]/sqrt2;
+  fLimlo[2] = pixelSize/(2*sqrt3);
+  fLimup[2] = 500.;
+  fFix[2]   = 0;
+
+  fVname[3] = "meany";
+  fVinit[3] = 0.;
+  fStep[3]  = fVinit[3]/sqrt2;
+  fLimlo[3] = -600.;
+  fLimup[3] = 600.;
+  fFix[3]   = 0;
+
+  fVname[4] = "sigmamajor";
+  fVinit[4] = pixelSize;
+  fStep[4]  = fVinit[4]/sqrt2;
+  fLimlo[4] = pixelSize/(2*sqrt3);
+  fLimup[4] = 500.;
+  fFix[4]   = 0;
+
+  fObjectFit  = NULL;
+  //  fMethod     = "SIMPLEX";
+  fMethod     = "MIGRAD";
+  //  fMethod     = "MINIMIZE";
+  fNulloutput = kFALSE;
+
+  // Set output level
+  //  fLog->SetOutputLevel(3); // No dbg messages
+
+  fGeometryFile="";
+  fBSCFile="";
+}
+
+Int_t MFindStars::PreProcess(MParList *pList)
+{
+
+    fGeomCam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
+
+    if (!fGeomCam)
+    {
+      *fLog << err << AddSerialNumber("MGeomCam") << " not found ... aborting" << endl;
+      return kFALSE;
+    }
+
+    // Initialize camera display with the MGeomCam information
+    fDisplay.SetGeometry(*fGeomCam,"FindStarsDisplay","FindStarsDisplay");
+    fDisplay.SetUsed(fPixelsUsed);
+
+    fCurr = (MCameraDC*)pList->FindObject(AddSerialNumber("MCameraDC"));
+
+    if (!fCurr)
+    {
+      *fLog << err << AddSerialNumber("MCameraDC") << " not found ... aborting" << endl;
+      return kFALSE;
+    }
+
+    fTimeCurr = (MTime*)pList->FindObject(AddSerialNumber("MTimeCurrents"));
+
+    if (!fTimeCurr)
+    {
+      *fLog << err << AddSerialNumber("MTimeCurrents") << " not found ... aborting" << endl;
+      return kFALSE;
+    }
+
+    fDrive = (MReportDrive*)pList->FindObject(AddSerialNumber("MReportDrive"));
+
+    if (!fDrive)
+      {
+
+        *fLog << warn << AddSerialNumber("MReportDrive") << " not found ... ignored." << endl;
+
+      }
+    else
+      {
+	
+	MObservatory magic1;
+
+	MMcConfigRunHeader *config=0;
+	MGeomCam           *geom=0;
+
+	TFile file(fGeometryFile);
+	TTree *tree = (TTree*)file.Get("RunHeaders");
+	tree->SetBranchAddress("MMcConfigRunHeader", &config);
+	if (tree->GetBranch("MGeomCam")) tree->SetBranchAddress("MGeomCam", &geom);
+	tree->GetEntry(0);
+	
+	fAstro.SetMirrors(*config->GetMirrors());
+	fAstro.SetGeom(*geom);	
+	fAstro.ReadBSC(fBSCFile);
+	
+	fAstro.SetObservatory(magic1);
+	
+      }
+    
+
+    fStars = (MStarLocalCam*)pList->FindCreateObj(AddSerialNumber("MStarLocalCam"));
+    if (!fStars)
+    {
+      *fLog << err << AddSerialNumber("MStarLocalCam") << " cannot be created ... aborting" << endl;
+      return kFALSE;
+    }
+
+    fMinDCForStars = 1.*fMaxNumIntegratedEvents; //[uA]
+
+    // Initialize the TMinuit object
+
+    TMinuit *gMinuit = new TMinuit(fNumVar);  //initialize TMinuit with a maximum of params
+    gMinuit->SetFCN(fcn);
+
+    Double_t arglist[10];
+    Int_t ierflg = 0;
+
+    arglist[0] = 1;
+    gMinuit->mnexcm("SET ERR", arglist ,1,ierflg);
+    arglist[0] = fMinuitPrintOutLevel;
+    gMinuit->mnexcm("SET PRI", arglist ,1,ierflg);
+
+    // Set MParList object pointer to allow mimuit to access internally
+    gMinuit->SetObjectFit(pList);
+
+    return kTRUE;
+}
+
+Int_t MFindStars::Process()
+{
+
+  UInt_t numPixels = fGeomCam->GetNumPixels();
+  TArrayC origPixelsUsed;
+  origPixelsUsed.Set(numPixels);
+
+  if (fNumIntegratedEvents >= fMaxNumIntegratedEvents) {
+
+    //Fist delete the previous stars in the list
+    fStars->GetList()->Delete();
+
+    if (fDrive) {
+
+      //If drive information is provided we take RaDec info
+      //from the drive and let the star list fill by the astrocamera.
+
+      //FIXME: rwagner: Doesn't work as expected
+      //FIXME: rwagner: For the time being set manually.
+      //fAstro.SetRaDec(fDrive->GetRa(), fDrive->GetDec());              
+
+      fAstro.SetTime(*fTimeCurr);
+      fAstro.SetGuiActive();
+      fAstro.FillStarList(fStars->GetList());      
+
+      cout << "Number of Stars added by astrocamera is " <<fStars->GetList()->GetSize() << endl;
+      
+      MStarLocalPos* starpos;
+      TIter Next(fStars->GetList());
+      while ((starpos=(MStarLocalPos*)Next())) {
+	starpos->SetCalcValues(40,40,starpos->GetXExp(),starpos->GetYExp(),fRingInterest/2,fRingInterest/2);
+	starpos->SetFitValues (40,40,starpos->GetXExp(),starpos->GetYExp(),fRingInterest/2,fRingInterest/2,0.,1);
+      }
+
+      for (UInt_t pix=1; pix<numPixels; pix++) {
+	if (fDisplay.IsUsed(pix))
+	  origPixelsUsed[pix]=(Char_t)kTRUE;
+	else
+	  origPixelsUsed[pix]=(Char_t)kFALSE;
+      }
+          
+      DCPedestalCalc();
+
+    } 
+    else 
+    {
+      
+      cout << "No drive information available: Will not use a star catalog to identify stars."<< endl;
+      
+      for (UInt_t pix=1; pix<numPixels; pix++) {
+	if (fDisplay.IsUsed(pix))
+	  origPixelsUsed[pix]=(Char_t)kTRUE;
+	else
+	  origPixelsUsed[pix]=(Char_t)kFALSE;
+      }
+          
+      if (DCPedestalCalc()) {
+
+	Float_t innermin = fStars->GetInnerPedestalDC()+fDCTailCut*fStars->GetInnerPedestalRMSDC();
+	Float_t outermin = fStars->GetOuterPedestalDC()+fDCTailCut*fStars->GetOuterPedestalRMSDC();
+	fMinDCForStars = innermin>outermin?innermin:outermin;
+	if (fMinuitPrintOutLevel>=0) *fLog << dbg << "fMinDCForStars = " << fMinDCForStars << endl;
+              
+	// Find the star candidates searching the most brights pairs of pixels
+	Float_t maxPixelDC;
+	MGeomPix maxPixel;
+	
+	while(FindPixelWithMaxDC(maxPixelDC, maxPixel)) {
+	  
+	  MStarLocalPos *starpos = new MStarLocalPos;
+	  starpos->SetExpValues(maxPixelDC,maxPixel.GetX(),maxPixel.GetY());
+	  starpos->SetCalcValues(maxPixelDC,maxPixelDC,maxPixel.GetX(),maxPixel.GetY(),fRingInterest/2,fRingInterest/2);
+	  starpos->SetFitValues(maxPixelDC,maxPixelDC,maxPixel.GetX(),maxPixel.GetY(),fRingInterest/2,fRingInterest/2,0.,1);
+	  fStars->GetList()->Add(starpos);
+	  
+	  ShadowStar(starpos);
+	}	
+	fDisplay.SetUsed(origPixelsUsed);
+      }      
+    }
+
+    //Show the stars found
+    //fStars->Print("namepos");
+   
+    //loop to extract position of stars on the camera
+    if (fStars->GetList()->GetSize() == 0) {
+      *fLog << err << GetName() << "No stars candidates in the camera." << endl;
+      return kCONTINUE;
+    } else
+      *fLog << inf << GetName() << " found " << fStars->GetList()->GetSize() 
+	    << " stars candidates in the camera." << endl;
+    
+    for (UInt_t pix=1; pix<numPixels; pix++) {
+      if (fDisplay.IsUsed(pix))
+	origPixelsUsed[pix]=(Char_t)kTRUE;
+      else
+	origPixelsUsed[pix]=(Char_t)kFALSE;
+    }
+
+    TIter Next(fStars->GetList());
+    MStarLocalPos* star;
+    while ((star=(MStarLocalPos*)Next())) {
+       FindStar(star);
+       ShadowStar(star);
+    }
+
+    //Show the stars found: Here it is interesting to see what FindStars
+    //made out of the positions we gave to it.
+    fStars->Print("namepos");
+
+    
+    //After finding stars reset all variables
+    fDisplay.Reset();
+    fStars->GetDisplay().Reset(); //FIXME: Put this display just in the container
+    fDisplay.SetUsed(origPixelsUsed);
+    fNumIntegratedEvents=0;
+  }
+
+  for (UInt_t pix=1; pix<numPixels; pix++) {
+    if (fDisplay.IsUsed(pix))
+      origPixelsUsed[pix]=(Char_t)kTRUE;
+    else
+      origPixelsUsed[pix]=(Char_t)kFALSE;
+    
+  }
+  
+  fDisplay.AddCamContent(*fCurr);
+  fNumIntegratedEvents++;
+  fDisplay.SetUsed(origPixelsUsed);
+  
+  return kTRUE;
+}
+
+Int_t MFindStars::PostProcess()
+{
+  return kTRUE;
+}
+
+void MFindStars::SetBlindPixels(TArrayS blindpixels)
+{
+    Int_t npix = blindpixels.GetSize();
+
+    for (Int_t idx=0; idx<npix; idx++)
+      {
+	fPixelsUsed[blindpixels[idx]]=(Char_t)kFALSE;
+        if (fMinuitPrintOutLevel>=0) *fLog << dbg << "MFindStars::SetBlindPixels fDisplay.IsUsed(" <<blindpixels[idx]  << ") kFALSE" << endl;
+      }
+    
+    fDisplay.SetUsed(fPixelsUsed);
+}
+
+Bool_t MFindStars::DCPedestalCalc()
+{
+    //-------------------------------------------------------------
+    // save pointer to the MINUIT object for optimizing the supercuts
+    // because it will be overwritten 
+    // when fitting the alpha distribution in MHFindSignificance
+    TMinuit *savePointer = gMinuit;
+    //-------------------------------------------------------------
+
+   UInt_t numPixels = fGeomCam->GetNumPixels();
+   Float_t ped;
+   Float_t rms;
+
+   TH1F **dchist = new TH1F*[2];
+   for (UInt_t i=0; i<2; i++)
+      dchist[i] = new TH1F("","",26,0.4*fMaxNumIntegratedEvents,3.*fMaxNumIntegratedEvents);
+   
+   for (UInt_t pix=1; pix<=lastInnerPixel; pix++)
+       dchist[0]->Fill(fDisplay.GetBinContent(pix+1));
+   for (UInt_t pix=lastInnerPixel+1; pix<numPixels; pix++)
+       dchist[1]->Fill(fDisplay.GetBinContent(pix+1));
+
+   // inner/outer pixels
+   for (UInt_t i=0; i<2; i++)
+    {
+      Float_t nummaxprobdc = dchist[i]->GetBinContent(dchist[i]->GetMaximumBin());
+      Float_t maxprobdc = dchist[i]->GetBinCenter(dchist[i]->GetMaximumBin());
+      UInt_t bin = dchist[i]->GetMaximumBin();
+      do
+        {
+          bin++;
+        }
+      while(dchist[i]->GetBinContent(bin)/nummaxprobdc > 0.5);
+      Float_t halfmaxprobdc = dchist[i]->GetBinCenter(bin);
+      
+      if (fMinuitPrintOutLevel>=0) *fLog << dbg << " maxprobdc[high] " << maxprobdc << "[" << nummaxprobdc << "] ";
+      if (fMinuitPrintOutLevel>=0) *fLog << dbg << " halfmaxprobdc[high] " << halfmaxprobdc << "[" << dchist[i]->GetBinContent(bin) << "]" << endl;
+      
+      Float_t rmsguess = TMath::Abs(maxprobdc-halfmaxprobdc);
+      Float_t min = maxprobdc-3*rmsguess;
+      min = (min<0.?0.:min);
+      Float_t max = maxprobdc+3*rmsguess;
+      
+      if (fMinuitPrintOutLevel>=0) *fLog << dbg << " maxprobdc " << maxprobdc << " rmsguess " << rmsguess << endl;
+      
+      TF1 func("func","gaus",min,max);
+      func.SetParameters(nummaxprobdc, maxprobdc, rmsguess);
+      
+      dchist[i]->Fit("func","QR0");
+      
+      UInt_t aproxnumdegrees = 6*(bin-dchist[i]->GetMaximumBin());
+      Float_t chiq = func.GetChisquare();
+      ped = func.GetParameter(1);
+      rms = func.GetParameter(2);
+      
+      if (fMinuitPrintOutLevel>=0) *fLog << dbg << " ped " << ped << " rms " << rms << " chiq/ndof " << chiq << "/" << aproxnumdegrees << endl;
+      
+      Int_t numsigmas = 5;
+      Axis_t minbin = ped-numsigmas*rms/dchist[i]->GetBinWidth(1);
+      minbin=minbin<1?1:minbin;
+      Axis_t maxbin = ped+numsigmas*rms/dchist[i]->GetBinWidth(1);
+      if (fMinuitPrintOutLevel>=0) *fLog << dbg << " Number of pixels with dc under " << numsigmas << " sigmas = " << dchist[i]->Integral((int)minbin,(int)maxbin) << endl;
+      
+      //Check results from the fit are consistent
+      if (ped < 0. || rms < 0.)
+        {
+          *fLog << dbg << "dchist[i]->GetEntries()" << dchist[i]->GetEntries();
+//            TCanvas *c1 = new TCanvas("c2","c2",500,800);
+//            dchist[i]->Draw();
+//            c1->Print("dchist.ps");
+//            delete c1;
+//            exit(1);
+        }
+      else if (TMath::Abs(ped-maxprobdc) > rmsguess || rms > rmsguess)
+        {
+          *fLog << warn << GetName() << " Pedestal DC fit give non consistent results for " << (i==0?"Inner":"Outer") << "pixels." << endl;
+          *fLog << warn << " maxprobdc " << maxprobdc << " rmsguess " << rmsguess << endl;
+          *fLog << warn << " ped " << ped << " rms " << rms << " chiq/ndof " << chiq << "/" << aproxnumdegrees << endl;
+          ped = maxprobdc;
+          rms = rmsguess/1.175; // FWHM=2.35*rms
+        }
+   
+      if (i == 0)
+        {
+          fStars->SetInnerPedestalDC(ped);
+          fStars->SetInnerPedestalRMSDC(rms);
+        }
+      else
+        {
+          fStars->SetOuterPedestalDC(ped);
+          fStars->SetOuterPedestalRMSDC(rms);
+        }
+
+      
+
+    }
+   
+
+   for (UInt_t i=0; i<2; i++)
+      delete dchist[i];
+   delete [] dchist;
+
+   //=================================================================
+
+   // reset gMinuit to the MINUIT object for optimizing the supercuts 
+   gMinuit = savePointer;
+   //-------------------------------------------
+   
+   if (fStars->GetInnerPedestalDC() < 0. ||  fStars->GetInnerPedestalRMSDC() < 0. || fStars->GetOuterPedestalDC() < 0. ||  fStars->GetOuterPedestalRMSDC() < 0.)
+     return kFALSE;
+  
+   return kTRUE;
+}
+    
+Bool_t MFindStars::FindPixelWithMaxDC(Float_t &maxDC, MGeomPix &maxPix)
+{
+    UInt_t numPixels = fGeomCam->GetNumPixels();
+
+// Find the two close pixels with the maximun dc
+    UInt_t maxPixIdx[2];
+
+    maxDC = 0;
+
+    for (UInt_t pix=1; pix<numPixels; pix++)
+    {
+	if(fDisplay.IsUsed(pix))
+	{
+	    Float_t dc[2];
+	    dc[0] = fDisplay.GetBinContent(pix+1);
+	    if (dc[0] < fMinDCForStars)
+		continue;
+
+	    MGeomPix &g = (*fGeomCam)[pix];
+	    Int_t numNextNeighbors = g.GetNumNeighbors();
+	    
+	    Float_t dcsum;
+	    for(Int_t nextNeighbor=0; nextNeighbor<numNextNeighbors; nextNeighbor++)
+	    {
+              UInt_t swneighbor = g.GetNeighbor(nextNeighbor);
+              if(fDisplay.IsUsed(swneighbor))
+                {
+                  dc[1] = fDisplay.GetBinContent(swneighbor+1);
+                  if (dc[1] < fMinDCForStars)
+                    continue;
+                  
+                  dcsum = dc[0] + dc[1];
+                  
+                  if(dcsum > maxDC*2)
+                    {
+                      if(dc[0]>=dc[1])
+                        {
+                          maxPixIdx[0] = pix;
+                          maxPixIdx[1] = swneighbor;
+                          maxDC = dc[0];
+                        }
+                      else
+                        {
+                          maxPixIdx[1] = pix;
+                          maxPixIdx[0] = swneighbor;
+                          maxDC = dc[1];
+                        }
+                    }	
+                }
+            }
+        }
+    }
+
+    if (maxDC == 0)
+      {
+        *fLog << warn << " No found pixels with maximum dc" << endl;
+	return kFALSE;
+      }
+    
+    maxPix = (*fGeomCam)[maxPixIdx[0]];
+
+    if (fMinuitPrintOutLevel>=0) *fLog << dbg << "Star candidate maxDC(" << setw(3) << maxDC << " uA) x position(" << setw(3) << maxPix.GetX() <<  " mm) x position(" << setw(3) << maxPix.GetY() << " mm) swnumber(" << maxPixIdx[0] << ")" << endl;
+
+    return kTRUE;
+}
+
+Bool_t MFindStars::FindStar(MStarLocalPos* star)
+{    
+ 
+  UInt_t numPixels = fGeomCam->GetNumPixels();
+  Float_t innerped = fStars->GetInnerPedestalDC();
+  Float_t outerped = fStars->GetOuterPedestalDC();
+
+  TArrayC origPixelsUsed;
+  origPixelsUsed.Set(numPixels);
+  
+  for (UInt_t pix=1; pix<numPixels; pix++)
+    {
+      if (fDisplay.IsUsed(pix))
+        origPixelsUsed[pix]=(Char_t)kTRUE;
+      else
+        origPixelsUsed[pix]=(Char_t)kFALSE;
+    }
+  
+  Float_t expX = star->GetXExp();
+  Float_t expY = star->GetYExp();
+  
+  Float_t max=0;
+  UInt_t  pixmax=0;
+  Float_t meanX=0;
+  Float_t meanY=0;
+  Float_t meanSqX=0;
+  Float_t meanSqY=0;
+  Float_t sumCharge=0;
+  UInt_t usedInnerPx=0;	
+  UInt_t usedOuterPx=0;	
+
+  const Float_t meanPresition = 3.; //[mm]
+  const UInt_t maxNumIterations = 10;
+  UInt_t numIterations = 0;
+
+  do
+    {
+
+      //rwagner: Need to find px with highest dc and need to assume it is
+      // somewhere near the center of the star
+      //after that we need to REDEFINE our roi! because expected pos could be
+      // quite off that px!
+      
+      // 1.) Initial roi around expected position
+
+      for (UInt_t pix=1; pix<numPixels; pix++)
+	{
+	  
+	  Float_t pixXpos=(*fGeomCam)[pix].GetX();
+	  Float_t pixYpos=(*fGeomCam)[pix].GetY();
+	  Float_t dist = sqrt((pixXpos-expX)*(pixXpos-expX)+
+			      (pixYpos-expY)*(pixYpos-expY));
+	  
+	  if ((dist < fRingInterest) && fDisplay.IsUsed(pix))
+	    fPixelsUsed[pix]=(Char_t)kTRUE;
+	  else
+	    fPixelsUsed[pix]=(Char_t)kFALSE;
+	}
+      fDisplay.SetUsed(fPixelsUsed);
+
+      // 2.) Find px with highest dc in that region
+
+      for(UInt_t pix=0; pix<numPixels; pix++)	
+	if(fDisplay.IsUsed(pix))
+	  {
+	    Float_t charge  = fDisplay.GetBinContent(pix+1);	      
+	    if (charge>max)
+	      {
+		max=charge;
+		pixmax=pix;
+	      }
+	    
+	  }         
+
+      // 3.) make it new center
+
+      expX = (*fGeomCam)[pixmax].GetX();
+      expY = (*fGeomCam)[pixmax].GetY();
+      for (UInt_t pix=1; pix<numPixels; pix++)
+	fPixelsUsed[pix]=(Char_t)kTRUE;       
+      fDisplay.SetUsed(fPixelsUsed);
+
+      // First define a area of interest around the expected position of the star
+      for (UInt_t pix=1; pix<numPixels; pix++)
+	{
+	  
+	  Float_t pixXpos=(*fGeomCam)[pix].GetX();
+	  Float_t pixYpos=(*fGeomCam)[pix].GetY();
+	  Float_t dist = sqrt((pixXpos-expX)*(pixXpos-expX)+
+			      (pixYpos-expY)*(pixYpos-expY));
+	  
+	  if ((dist < fRingInterest) && fDisplay.IsUsed(pix))
+	    fPixelsUsed[pix]=(Char_t)kTRUE;
+	  else
+	    fPixelsUsed[pix]=(Char_t)kFALSE;
+	}
+  
+      fDisplay.SetUsed(fPixelsUsed);
+    
+      // determine mean x and mean y
+      usedInnerPx=0;	
+      usedOuterPx=0;	
+      for(UInt_t pix=0; pix<numPixels; pix++)
+	{
+	  if(fDisplay.IsUsed(pix))
+	    {
+	      pix>lastInnerPixel?usedOuterPx++:usedInnerPx++;
+	      
+	      Float_t charge  = fDisplay.GetBinContent(pix+1);
+	      Float_t pixXpos = (*fGeomCam)[pix].GetX();
+	      Float_t pixYpos = (*fGeomCam)[pix].GetY();
+	      
+	      if (charge>max)
+		{
+		  max=charge;
+		  pixmax=pix;
+		}
+	      
+	      meanX     += charge*pixXpos;
+	      meanY     += charge*pixYpos;
+	      meanSqX   += charge*pixXpos*pixXpos;
+	      meanSqY   += charge*pixYpos*pixYpos;
+	      sumCharge += charge;
+	    }
+	} 
+      
+      if (fMinuitPrintOutLevel>=0) *fLog << dbg << " usedInnerPx " << usedInnerPx << " usedOuterPx " << usedOuterPx << endl;
+      
+      meanX   /= sumCharge;
+      meanY   /= sumCharge;
+      meanSqX /= sumCharge;
+      meanSqY /= sumCharge;
+      
+      expX = meanX;
+      expY = meanY;
+      
+      if (++numIterations >  maxNumIterations)
+	{
+	  *fLog << warn << GetName() << "Mean calculation not converge after " << maxNumIterations << " iterations" << endl;
+	  break;
+	}
+        
+    } while(TMath::Abs(meanX-expX) > meanPresition || TMath::Abs(meanY-expY) > meanPresition);
+  
+  Float_t rmsX = (meanSqX - meanX*meanX) - fRingInterest*fRingInterest/12;
+  Float_t rmsY = (meanSqY - meanY*meanY) - fRingInterest*fRingInterest/12;
+  
+  if ( rmsX > 0)
+    rmsX =  TMath::Sqrt(rmsX);
+  else
+    {
+      *fLog << warn << " MFindStars::FindStar negative rmsX² " << rmsX << endl;
+      *fLog << warn << " meanSqX " << meanSqX << " meanX " << meanX << " fRingInterest " << fRingInterest << " sumCharge " << sumCharge << endl;
+      rmsX = 0.;
+    }
+  
+  if ( rmsY > 0)
+    rmsY =  TMath::Sqrt(rmsY);
+  else
+    {
+      *fLog << warn << " MFindStars::FindStar negative rmsY² " << rmsY << endl;
+      *fLog << warn << " meanSqY " << meanSqY << " meanY " << meanY << " fRingInterest " << fRingInterest << " sumCharge " << sumCharge<< endl;
+      rmsY = 0.;
+    }
+  
+  // Substrack pedestal DC
+  sumCharge-= (usedInnerPx*innerped+usedOuterPx*outerped)/(usedInnerPx+usedOuterPx);
+  max-=pixmax>lastInnerPixel?outerped:innerped;
+  
+  
+  star->SetCalcValues(sumCharge,max,meanX,meanY,rmsX,rmsY);
+  
+  if (rmsX <= 0. || rmsY <= 0.)
+    return kFALSE;
+    
+    
+// fit the star spot using TMinuit
+
+    
+    for (UInt_t pix=1; pix<numPixels; pix++)
+      if (fDisplay.IsUsed(pix))
+        if (fMinuitPrintOutLevel>=0) *fLog << dbg << "[fit the star spot] fDisplay.IsUsed(" << pix << ") kTRUE" << endl;
+  
+    if (fMinuitPrintOutLevel>=0) *fLog << dbg << "fMinDCForStars " << fMinDCForStars << " pixmax>lastInnerPixel?outerped:innerped " << (pixmax>lastInnerPixel?outerped:innerped) << " fMaxNumIntegratedEvents " << fMaxNumIntegratedEvents << endl;
+
+  //Initialate variables for fit
+    fVinit[0] = max;
+    fLimlo[0] = fMinDCForStars-(pixmax>lastInnerPixel?outerped:innerped);
+    fLimup[0] = 30*fMaxNumIntegratedEvents-(pixmax>lastInnerPixel?outerped:innerped);
+    fVinit[1] = meanX;
+    fVinit[2] = rmsX;
+    fVinit[3] = meanY;
+    fVinit[4] = rmsY;
+    //Init steps
+    for(Int_t i=0; i<fNumVar; i++)
+      {
+	if (fVinit[i] != 0)
+	  fStep[i] = TMath::Abs(fVinit[i]/sqrt2);
+        if (fMinuitPrintOutLevel>=0) *fLog << dbg << " fVinit[" << i << "] " << fVinit[i];
+        if (fMinuitPrintOutLevel>=0) *fLog << dbg << " fStep[" << i << "] " << fStep[i];
+        if (fMinuitPrintOutLevel>=0) *fLog << dbg << " fLimlo[" << i << "] " << fLimlo[i];
+        if (fMinuitPrintOutLevel>=0) *fLog << dbg << " fLimup[" << i << "] " << fLimup[i] << endl;
+      }
+    //
+
+    // -------------------------------------------
+    // call MINUIT
+
+    Double_t arglist[10];
+    Int_t ierflg = 0;
+
+    for (Int_t i=0; i<fNumVar; i++)
+      gMinuit->mnparm(i, fVname[i], fVinit[i], fStep[i], fLimlo[i], fLimup[i], ierflg);
+
+    TStopwatch clock;
+    clock.Start();
+
+// Now ready for minimization step
+    arglist[0] = 500;
+    arglist[1] = 1.;
+    gMinuit->mnexcm(fMethod, arglist ,2,ierflg);
+
+    clock.Stop();
+
+    if(fMinuitPrintOutLevel>=0)
+      {
+	if (fMinuitPrintOutLevel>=0) *fLog << dbg << "Time spent for the minimization in MINUIT :   " << endl;;
+	clock.Print();
+      }
+
+    Double_t integratedCharge;
+    Double_t maxFit, maxFitError;
+    Double_t meanXFit, meanXFitError;
+    Double_t sigmaMinorAxis, sigmaMinorAxisError;
+    Double_t meanYFit, meanYFitError;
+    Double_t sigmaMajorAxis, sigmaMajorAxisError;
+    Float_t chisquare = GetChisquare();
+    Int_t   dregrees  = GetDegreesofFreedom()-fNumVar;
+
+    if (!ierflg)
+      {
+        gMinuit->GetParameter(0,maxFit, maxFitError);
+        gMinuit->GetParameter(1,meanXFit,meanXFitError);
+        gMinuit->GetParameter(2,sigmaMinorAxis,sigmaMinorAxisError);
+        gMinuit->GetParameter(3,meanYFit,meanYFitError);
+        gMinuit->GetParameter(4,sigmaMajorAxis,sigmaMajorAxisError);
+        
+        //FIXME: Do the integral properlly
+        integratedCharge = 0.;
+
+        
+      }
+    else
+      {
+        maxFit = 0.;
+        meanXFit = 0.;
+        sigmaMinorAxis = 0.;
+        meanYFit = 0.;
+        sigmaMajorAxis = 0.;
+        integratedCharge = 0.;
+
+	*fLog << err << "TMinuit::Call error " << ierflg << endl;
+      }
+
+    //rwagner: get error matrix
+    Double_t matrix[2][2];
+    gMinuit->mnemat(&matrix[0][0],2);
+
+    star->SetFitValues(integratedCharge,maxFit,meanXFit,meanYFit,sigmaMinorAxis,sigmaMajorAxis,chisquare,dregrees,
+  		       matrix[0][0],matrix[1][0],matrix[1][1]);
+    
+    // reset the display to the starting values
+    fDisplay.SetUsed(origPixelsUsed);
+
+    if (ierflg)
+      return kCONTINUE;
+    return kTRUE;
+}
+
+Bool_t MFindStars::ShadowStar(MStarLocalPos* star)
+{
+    UInt_t numPixels = fGeomCam->GetNumPixels();
+
+// Define an area around the star which will be set unused.
+    UInt_t shadowPx=0;	
+    for (UInt_t pix=1; pix<numPixels; pix++)
+    {
+	Float_t pixXpos  = (*fGeomCam)[pix].GetX();
+	Float_t pixYpos  = (*fGeomCam)[pix].GetY();
+        Float_t starXpos = star->GetMeanX();
+        Float_t starYpos = star->GetMeanY();
+        
+	Float_t starSize = 3*star->GetSigmaMajorAxis();
+        
+	Float_t dist = sqrt((pixXpos-starXpos)*(pixXpos-starXpos)+
+			    (pixYpos-starYpos)*(pixYpos-starYpos));
+
+        if (dist > starSize && fDisplay.IsUsed(pix))
+	  fPixelsUsed[pix]=(Char_t)kTRUE;
+        else
+          {
+            fPixelsUsed[pix]=(Char_t)kFALSE;
+            shadowPx++;
+          }
+    }
+
+    if (fMinuitPrintOutLevel>=0) *fLog << dbg << " shadowPx " << shadowPx << endl;
+
+    fDisplay.SetUsed(fPixelsUsed);
+
+    return kTRUE;
+}
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mmpi/MFindStars.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mmpi/MFindStars.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mmpi/MFindStars.h	(revision 9661)
@@ -0,0 +1,116 @@
+#ifndef MARS_MFindStars
+#define MARS_MFindStars
+
+#ifndef ROOT_TArrayS
+#include <TArrayS.h>
+#endif
+
+#ifndef ROOT_TArrayC
+#include <TArrayC.h>
+#endif
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+#ifndef MARS_MHCamera
+#include "MHCamera.h"
+#endif
+
+#ifndef MARS_MAstroCamera
+#include "MAstroCamera.h"
+#endif
+
+class MGeomCam;
+class MGeomPix;
+class MCameraDC;
+class MTime;
+class MReportDrive;
+class MStarLocalCam;
+class MStarLocalPos;
+
+class MFindStars : public MTask
+{
+
+private:
+
+    MGeomCam      *fGeomCam;
+    MCameraDC     *fCurr;
+    MTime         *fTimeCurr;
+    MReportDrive  *fDrive;
+    MStarLocalCam *fStars;
+
+    MAstroCamera fAstro;
+    TArrayC      fPixelsUsed;
+    MHCamera     fDisplay;
+
+    UInt_t fMaxNumIntegratedEvents;
+    UInt_t fNumIntegratedEvents;
+
+    Float_t fRingInterest; //[mm]
+    Float_t fMinDCForStars; //[uA]
+
+    Float_t fDCTailCut;
+
+    //Fitting(Minuit) variables
+    const Int_t fNumVar;
+    Float_t fTempChisquare;
+    Int_t fTempDegreesofFreedom;
+    Int_t fMinuitPrintOutLevel;
+    
+    TString *fVname;
+    TArrayD fVinit; 
+    TArrayD fStep; 
+    TArrayD fLimlo; 
+    TArrayD fLimup; 
+    TArrayI fFix;
+    TObject *fObjectFit;
+    TString fMethod;
+    Bool_t fNulloutput;
+    
+    Bool_t DCPedestalCalc();
+    Bool_t FindPixelWithMaxDC(Float_t &maxDC, MGeomPix &maxPix);
+    Bool_t FindStar(MStarLocalPos* star);
+    Bool_t ShadowStar(MStarLocalPos* star);
+
+    TString fGeometryFile;
+    TString fBSCFile;
+
+  public:
+    
+    MFindStars(const char *name=NULL, const char *title=NULL);
+    
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
+    // setters
+    void SetNumIntegratedEvents(UInt_t max) {fMaxNumIntegratedEvents=max;}
+    void SetRingInterest(Float_t ring) {fRingInterest=ring;}
+    void SetBlindPixels(TArrayS blindpixels);
+    void SetMinuitPrintOutLevel(Int_t level) {fMinuitPrintOutLevel=level;}
+    void SetDCTailCut(Float_t cut) {fDCTailCut=cut;}
+
+    void SetChisquare(Float_t chi) {fTempChisquare=chi;}
+    void SetDegreesofFreedom(Int_t free) {fTempDegreesofFreedom=free;}
+
+    void SetGeometryFile(TString f) {fGeometryFile=f;}
+    void SetBSCFile(TString f) {fBSCFile=f;}
+    void SetRaDec(Double_t ra, Double_t dec) {fAstro.SetRaDec(ra,dec);}
+    void SetRaDec(TVector3 &v) { fAstro.SetRaDec(v); }
+    void SetLimMag(Double_t mag) { fAstro.SetLimMag(mag); } 
+    void SetRadiusFOV(Double_t deg) { fAstro.SetRadiusFOV(deg); }
+
+
+    //Getters
+    MHCamera& GetDisplay() { return fDisplay; }
+    
+    Float_t GetChisquare() {return fTempChisquare;}
+    Int_t GetDegreesofFreedom() {return fTempDegreesofFreedom;}
+    UInt_t GetNumIntegratedEvents() {return fMaxNumIntegratedEvents;}
+    Float_t GetRingInterest() {return fRingInterest;}
+    
+  ClassDef(MFindStars, 0) // Tool to find stars from DC Currents
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtemp/mmpi/MSourceDirections.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mmpi/MSourceDirections.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mmpi/MSourceDirections.cc	(revision 9661)
@@ -0,0 +1,149 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without expressed
+! * or implied warranty.
+! *
+!
+!   Author(s): Robert Wagner, 8/2004 <mailto:rwagner@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MSourceDirections
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MSourceDirections.h"
+
+#include <TTimer.h>
+#include <TString.h>
+#include <TFile.h>
+#include <TTree.h>
+#include <TCanvas.h>
+#include <TH1F.h>
+#include <TF1.h>
+#include <TEllipse.h>
+
+
+#include "MObservatory.h"
+#include "MAstroCamera.h"
+#include "MMcConfigRunHeader.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MHCamera.h"
+
+#include "MGeomCam.h"
+#include "MGeomPix.h"
+#include "MCameraDC.h"
+#include "MTime.h"
+#include "MReportDrive.h"
+#include "MStarLocalCam.h"
+#include "MStarLocalPos.h"
+
+#include "MParList.h"
+#include "MTaskList.h"
+
+ClassImp(MSourceDirections);
+using namespace std;
+
+MSourceDirections::MSourceDirections(const char *name, const char *title): 
+  fGeomCam(NULL), fTimeCurr(NULL), fDrive(NULL), fStars(NULL)
+{
+  fName  = name  ? name  : "MSourceDirections";
+  fTitle = title ? title : "Convert Ra-Dec source positions into camera coordinates";
+  fGeometryFile="";
+}
+
+Int_t MSourceDirections::PreProcess(MParList *pList)
+{
+  fGeomCam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
+  if (!fGeomCam) {
+    *fLog << err << AddSerialNumber("MGeomCam") << " not found ... aborting" << endl;
+    return kFALSE;
+  }
+  
+  fTimeCurr = (MTime*)pList->FindObject(AddSerialNumber("MTimeCurrents"));
+  if (!fTimeCurr) {
+    *fLog << err << AddSerialNumber("MTimeCurrents") << " not found ... aborting" << endl;
+    return kFALSE;
+  }
+
+  fDrive = (MReportDrive*)pList->FindObject(AddSerialNumber("MReportDrive"));
+  if (!fDrive) {
+    *fLog << warn << AddSerialNumber("MReportDrive") << " not found ... aborting" << endl;
+    return kFALSE;
+  } 
+
+  fStars = (MStarLocalCam*)pList->FindCreateObj(AddSerialNumber("MStarLocalCam"),"MSourceLocalCam");
+  if (!fStars) {
+    *fLog << err << AddSerialNumber("MStarLocalCam") << " cannot be created ... aborting" << endl;
+    return kFALSE;
+  }
+  
+  MObservatory magic1;
+  
+  MMcConfigRunHeader *config=0;
+  MGeomCam           *geom=0;
+  
+  TFile file(fGeometryFile);
+  TTree *tree = (TTree*)file.Get("RunHeaders");
+  tree->SetBranchAddress("MMcConfigRunHeader", &config);
+  if (tree->GetBranch("MGeomCam")) tree->SetBranchAddress("MGeomCam", &geom);
+  tree->GetEntry(0);
+  
+  fAstro.SetMirrors(*config->GetMirrors());
+  fAstro.SetGeom(*geom);	
+  fAstro.SetObservatory(magic1);  
+    
+  return kTRUE;
+}
+
+Int_t MSourceDirections::AddDirection(Float_t ra, Float_t dec, Float_t mag, TString name) 
+{
+  return fAstro.AddObject(ra,dec,1,name);
+}
+
+Int_t MSourceDirections::Process()
+{
+  //Fist delete the previous directions in the list
+  fStars->GetList()->Delete();
+
+  fAstro.SetTime(*fTimeCurr);
+  fAstro.SetGuiActive();
+  fAstro.FillStarList(fStars->GetList());      
+      
+  MStarLocalPos* starpos;
+  TIter Next(fStars->GetList());
+  while ((starpos=(MStarLocalPos*)Next())) {
+    starpos->SetCalcValues(40,40,starpos->GetXExp(),starpos->GetYExp(),0.,0.);
+    starpos->SetFitValues (40,40,starpos->GetXExp(),starpos->GetYExp(),0.,0.,0.,1);
+  }
+    
+  if (fStars->GetList()->GetSize() == 0) {
+    *fLog << err << GetName() << "No directions inside the chosen FOV." << endl;
+  } else {
+    *fLog << inf << GetName() << " found " << fStars->GetList()->GetSize() 
+	  << " directions inside the chosen FOV." << endl;          
+  }
+  return kTRUE;
+}
+
+Int_t MSourceDirections::PostProcess()
+{
+  return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/mmpi/MSourceDirections.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mmpi/MSourceDirections.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mmpi/MSourceDirections.h	(revision 9661)
@@ -0,0 +1,49 @@
+#ifndef MARS_MSourceDirections
+#define MARS_MSourceDirections
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+#ifndef MARS_MAstroCamera
+#include "MAstroCamera.h"
+#endif
+
+class MTime;
+class MReportDrive;
+class MStarLocalCam;
+class MStarLocalPos;
+
+class MSourceDirections : public MTask
+{
+
+private:
+
+    MGeomCam      *fGeomCam;
+    MTime         *fTimeCurr;
+    MReportDrive  *fDrive;
+    MStarLocalCam *fStars;
+
+    MAstroCamera fAstro;
+  
+    TString fGeometryFile;
+
+  public:
+    
+    MSourceDirections(const char *name=NULL, const char *title=NULL);
+    
+    Int_t AddDirection(Float_t ra, Float_t dec, Float_t mag, TString name="");
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
+    // setters
+    void SetGeometryFile(TString f) {fGeometryFile=f;}
+    void SetRaDec(Double_t ra, Double_t dec) {fAstro.SetRaDec(ra,dec);}
+    void SetRaDec(TVector3 &v) { fAstro.SetRaDec(v); }
+    void SetRadiusFOV(Double_t deg) { fAstro.SetRadiusFOV(deg); }
+    
+  ClassDef(MSourceDirections, 0) // Tool to translate RaDec Source Directions into camera coordinates
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/MFRandomSplit.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/MFRandomSplit.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/MFRandomSplit.cc	(revision 9661)
@@ -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): Wolfgang Wittek, 11/2003 <mailto:wittek@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  MFRandomSplit
+//
+//  A filter which gives fResult = kTRUE with the probability fProb
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MFRandomSplit.h"
+
+#include <fstream>
+#include <TRandom.h>
+
+#include "MParList.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MFRandomSplit);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+//     Constructor
+//
+MFRandomSplit::MFRandomSplit(Double_t f, const char *name, const char *title)
+    : fProb(f)
+{
+    fName  = name  ? name  : "MFRandomSplit";
+    fTitle = title ? title : "Filter for random splitting";
+
+    if (fProb < 0)
+    {
+        *fLog << warn << "WARNING - MFRandomSplit::MFRandomSplit: Probability less than 0... set to 0." << endl;
+        fProb = 0;
+    }
+
+    if (fProb > 1)
+    {
+        *fLog << warn << "WARNING - MFRandomSplit::MFRandomSplit: Probability greater than 1... set to 1." << endl;
+        fProb = 1;
+    }
+}
+
+// --------------------------------------------------------------------------
+//
+//  PreProcess. Set fNumSelectedEvts=0
+//
+Int_t MFRandomSplit::PreProcess(MParList *pList)
+{
+    fNumSelectedEvts = 0;
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//  
+//  Select events randomly according to the probability fProb. Count all
+//  selected events
+//
+Int_t MFRandomSplit::Process()
+{
+    fResult = gRandom->Uniform() < fProb;
+
+    if (fResult)
+        fNumSelectedEvts++;
+
+    return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//  
+//  PostProcess. Prints execution statistics
+//
+Int_t MFRandomSplit::PostProcess()
+{
+    if (GetNumExecutions()==0)
+        return kTRUE;
+
+    *fLog << inf << endl;
+    *fLog << GetDescriptor() << " execution statistics:" << endl;
+    *fLog << dec << setfill(' ');
+    *fLog << " " << setw(7) << fNumSelectedEvts << " (";
+    *fLog << setw(3) << (int)(100.*fNumSelectedEvts/GetNumExecutions());
+    *fLog << "%) selected - out of " << GetNumExecutions() << endl;
+    *fLog << endl;
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/MFRandomSplit.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/MFRandomSplit.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/MFRandomSplit.h	(revision 9661)
@@ -0,0 +1,41 @@
+#ifndef MARS_MFRandomSplit
+#define MARS_MFRandomSplit
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MFRandomSplit                                                           //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef MARS_MFilter
+#include "MFilter.h"
+#endif
+
+class MParList;
+
+class MFRandomSplit : public MFilter
+{
+private:
+    Int_t    fNumSelectedEvts;
+    Double_t fProb;    // probability with which the result should be kTRUE
+
+    Bool_t   fResult;  // Result returned by IsExpressionTrue
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+    Int_t PostProcess();
+
+public:
+    MFRandomSplit(Double_t f, const char *name=NULL, const char *title=NULL);
+
+    Bool_t IsExpressionTrue() const { return fResult; }
+
+    ClassDef(MFRandomSplit, 0) // A Filter giving kTRUE with a certain probability
+};
+
+#endif
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/MFindSupercutsONOFF.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/MFindSupercutsONOFF.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/MFindSupercutsONOFF.cc	(revision 9661)
@@ -0,0 +1,4299 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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 9/2003 <mailto:wittek@mppmu.mpg.de>
+!              David Paneque   11/2003 <mailto:dpaneque@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MFindSupercutsONOFF                                                       //
+//                                                                         //
+// Class for optimizing the parameters of the supercuts                     //
+// Using ON and OFF data                                                   //
+//                                                                         //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MFindSupercutsONOFF.h"
+
+#include <math.h>            // fabs 
+
+#include <TFile.h>
+#include <TArrayD.h>
+#include <TMinuit.h>
+#include <TCanvas.h>
+#include <TStopwatch.h>
+#include <TVirtualFitter.h>
+
+#include "MBinning.h"
+#include "MContinue.h"
+#include "MSupercuts.h"
+#include "MSupercutsCalcONOFF.h"
+#include "MDataElement.h"
+#include "MDataMember.h"
+
+
+#include <TPostScript.h>
+
+#include "MEvtLoop.h"
+#include "MFCT1SelFinal.h"
+#include "MF.h"
+#include "MFEventSelector.h"
+#include "MFEventSelector2.h"
+#include "MFillH.h"
+//#include "MGeomCamCT1Daniel.h"
+//#include "MGeomCamCT1.h"
+#include "MGeomCamMagic.h"
+#include "MFRandomSplit.h"
+#include "MH3.h"
+#include "MHCT1Supercuts.h"
+#include "MHFindSignificance.h" // To be removed at some point...
+#include "MHFindSignificanceONOFF.h"
+#include "MTSupercutsApplied.h"
+#include "MHMatrix.h"
+#include "MHOnSubtraction.h"
+#include "MDataValue.h"
+// #include "MDataString.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+#include "MMatrixLoop.h"
+#include "MMinuitInterface.h"
+#include "MParList.h"
+#include "MProgressBar.h"
+#include "MReadMarsFile.h"
+#include "MReadTree.h"
+#include "MTaskList.h"
+
+
+ClassImp(MFindSupercutsONOFF);
+
+using namespace std;
+
+
+
+// Function that computes the normalization factor using COUNTED events in alpha histogram 
+// for ON data  and alpha histogram for OFF data;
+// in alpha region defined by AlphaBkgMin and AlphaBkgMax
+
+// It is defined outside the class MFindSupercutsONOFF so that it can be used 
+// in function fcnSupercuts
+
+
+static Double_t ComputeNormFactorFromAlphaBkg(TH1 *histON, TH1 *histOFF, 
+					      Double_t AlphaBkgMin, 
+					      Double_t AlphaBkgMax)
+{                                                      
+
+    Double_t NormFactor = 0.0;
+    Double_t ONEvents = 0.0; 
+    Double_t OFFEvents = 0.0;
+
+    const Double_t SmallQuantity = 0.01;
+    
+    Double_t xlo = 0.0;
+    Double_t xup = 0.0;
+    Double_t width = 0.0;
+
+    Int_t BinCounterOFF = 0;
+    Int_t BinCounterON = 0;
+    
+
+    // I make a copy of the histograms so that nothing happens to the 
+    // histograms used in argument
+
+    TH1* HistON = (TH1*) histON->Clone();
+    TH1* HistOFF = (TH1*) histOFF->Clone();
+
+    if ( !HistON )
+    {
+	gLog << "ComputeNormFactorFromAlphaBkg; " << endl
+	      << "Clone of ON histogram could not be generated" 
+	      << endl;
+	return 0.0;
+    }
+
+
+    
+    if ( !HistOFF )
+    {
+	gLog << "ComputeNormFactorFromAlphaBkg; " << endl
+	      << " Clone of OFF histogram could not be generated" 
+	      << endl;
+	return 0.0;
+    }
+
+  // Calculate the number of OFF events in the Bkg region 
+  // defined by AlphaBkgMin and AlphaBkgMax 
+  // ___________________________________________________
+  
+
+    Int_t nbinsOFF = HistOFF -> GetNbinsX();  
+    Double_t binwidthOFF = HistOFF -> GetBinWidth(1);
+
+    for (Int_t i=1; i<=nbinsOFF; i++)
+    {
+	xlo = HistOFF->GetBinLowEdge(i);
+	xup = HistOFF->GetBinLowEdge(i+1);
+ 
+	// bin must be completely contained in the bkg region
+	if ( xlo >= (AlphaBkgMin-SmallQuantity)  &&  xup <= (AlphaBkgMax+SmallQuantity)    )
+	{
+	    width = fabs(xup-xlo);
+	    if (fabs(width-binwidthOFF) > SmallQuantity)
+	    {
+		gLog << "ComputeNormFactorFromAlphaBkg; " 
+		      << endl << " HistOFF has variable binning, which is not allowed" 
+		      << endl;
+		return 0.0;
+	    }
+
+	    BinCounterOFF++;
+
+	    OFFEvents  += HistOFF->GetBinContent(i);
+	    
+	}
+    }
+
+
+    // Calculate the number of ON events in the Bkg region 
+  // defined by AlphaBkgMin and AlphaBkgMax 
+  // ___________________________________________________
+  
+
+    Int_t nbinsON = HistON -> GetNbinsX();  
+    Double_t binwidthON = HistON -> GetBinWidth(1);
+
+    for (Int_t i=1; i<=nbinsON; i++)
+    {
+	xlo = HistON->GetBinLowEdge(i);
+	xup = HistON->GetBinLowEdge(i+1);
+ 
+	// bin must be completely contained in the bkg region
+	if ( xlo >= (AlphaBkgMin-SmallQuantity)  &&  xup <= (AlphaBkgMax+SmallQuantity)    )
+	{
+	    width = fabs(xup-xlo);
+	    if (fabs(width-binwidthON) > SmallQuantity)
+	    {
+		gLog << "ComputeNormFactorFromAlphaBkg; " 
+		      << endl << " HistON has variable binning, which is not allowed" 
+		      << endl;
+		return 0.0;
+	    }
+
+	    BinCounterON++;
+	    ONEvents  += HistON->GetBinContent(i);
+	    
+	}
+    }
+
+
+  
+
+    // NormFactor is computed
+
+      if (ONEvents < SmallQuantity || OFFEvents < SmallQuantity)
+      {
+	  gLog << "ComputeNormFactorFromAlphaBkg; " 
+		<< endl 
+		<< "ONEvents or OFFEvents computed in bkg region are < " 
+		<< SmallQuantity << endl;
+	  return 0.0;
+	  
+      }
+
+     
+	  
+    
+    NormFactor = ONEvents/OFFEvents;
+
+    Double_t error = 1/ONEvents + 1/OFFEvents;
+    error = TMath::Sqrt(error);
+    error = error * NormFactor;
+
+     // tmp info
+      gLog << "ComputeNormFactorFromAlphaBkg;" << endl
+	   << "ON Events in bkg region = " << ONEvents 
+	   << " (" << BinCounterON << " bins)"
+	   << " , OFF Events in bkg region = " << OFFEvents 
+	   << " (" << BinCounterOFF << " bins)" << endl
+	   <<"NormFactor computed from bkg region = " << NormFactor 
+	   << " +/- " << error << endl;
+      // end temp
+
+    return NormFactor;
+
+}
+
+
+
+
+
+
+
+
+//------------------------------------------------------------------------
+//
+// fcnSupercuts 
+//
+// - calculates the quantity to be minimized (using TMinuit)
+//
+// - the quantity to be minimized is (-1)*significance of the gamma signal
+//   in the alpha distribution (after cuts)
+//
+// - the parameters to be varied in the minimization are the cut parameters
+//   (par)
+//
+static void fcnSupercuts(Int_t &npar, Double_t *gin, Double_t &f, 
+                         Double_t *par, Int_t iflag)
+{
+    //cout <<  "entry fcnSupercuts" << endl;
+
+    //-------------------------------------------------------------
+    // save pointer to the MINUIT object for optimizing the supercuts
+    // because it will be overwritten 
+    // when fitting the alpha distribution in MHFindSignificance
+    TMinuit *savePointer = gMinuit;
+    //-------------------------------------------------------------
+
+
+    MEvtLoop* evtloopfcn = (MEvtLoop*)gMinuit->GetObjectFit();
+
+    // Event loops for ON and OFF data are recovered. 
+
+    MEvtLoop* ONDataevtloopfcn = &evtloopfcn[0];
+    MEvtLoop* OFFDataevtloopfcn = &evtloopfcn[1];
+
+
+    // Parameter list from event loops for ON and OFF data are recovered
+
+    MParList *ONDataplistfcn   = (MParList*) ONDataevtloopfcn->GetParList();
+    MParList *OFFDataplistfcn   = (MParList*) OFFDataevtloopfcn->GetParList();
+    
+    // MTaskList *ONDataTasklistfcn   = (MTaskList*) ONDataevtloopfcn->GetTaskList();
+    // MTaskList *OFFDataTasklistfcn   = (MTaskList*) OFFDataevtloopfcn->GetTaskList();
+
+
+
+    // Container for supercuts is retrieved from ONDataplistfcn. 
+    // NOTE: The same supercuts parameter container is used in  OFFDataplistfcn
+
+    MSupercuts *super = (MSupercuts*) ONDataplistfcn->FindObject("MSupercuts");
+    if (!super)
+    {
+        gLog << "fcnSupercuts : MSupercuts object '" << "MSupercuts"
+            << "' not found... aborting" << endl;
+        return;
+    }
+
+
+    // Normalization factor for train sample (Train ON before cuts/ train OFF before cuts) 
+    // is retrieved from the ONDataplistfcn
+
+    Double_t NormalizationFactorTrain = 0.0;
+    
+    MDataValue* NormFactorContainer = (MDataValue*) ONDataplistfcn->FindObject("NormFactorTrain");
+    NormalizationFactorTrain = NormFactorContainer -> GetValue();
+
+    
+    gLog << "fcnSupercuts : Normalization factor retrieved from ONDataplistfcn: " << endl
+	 << "NormalizationFactorTrain = " << NormalizationFactorTrain << endl;
+    
+
+    Double_t AlphaSig = 0.0;
+    MDataValue* AlphaSigContainer = (MDataValue*) ONDataplistfcn->FindObject("AlphaSigValue");
+    AlphaSig = AlphaSigContainer -> GetValue();
+
+    Double_t AlphaBkgMin = 0.0;
+    MDataValue* AlphaBkgMinContainer = 
+	(MDataValue*) ONDataplistfcn->FindObject("AlphaBkgMinValue");
+    AlphaBkgMin = AlphaBkgMinContainer -> GetValue();
+
+    Double_t AlphaBkgMax = 0.0;
+    MDataValue* AlphaBkgMaxContainer = 
+	(MDataValue*) ONDataplistfcn->FindObject("AlphaBkgMaxValue");
+    AlphaBkgMax = AlphaBkgMaxContainer -> GetValue();
+
+    
+    gLog << "fcnSupercuts : AlphaSig and AlphaBkgMin-AlphaBkgMax retrieved from ONDataplistfcn: "
+	 << endl
+	 << "AlphaSig = " << AlphaSig << "; AlphaBkgMin-AlphaBkgMax = " 
+	 << AlphaBkgMin << "-" << AlphaBkgMax << endl;
+
+
+
+    // Variable fUseFittedQuantities is retrieved from ONDataplistfcn
+
+    Bool_t UseFittedQuantities;
+    MDataValue* UseFittedQuantitiesContainer = 
+	(MDataValue*) ONDataplistfcn->FindObject("UseFittedQuantitiesValue");
+    UseFittedQuantities = bool(UseFittedQuantitiesContainer -> GetValue());
+    
+    if (UseFittedQuantities)
+    {
+	gLog << "fcnSupercuts :  UseFittedQuantities variable set to kTRUE" << endl;
+    }
+    else
+    {
+	gLog << "fcnSupercuts :  UseFittedQuantities variable set to kFALSE" << endl;
+    }
+    
+
+    Bool_t UseNormFactorFromAlphaBkg;
+    MDataValue* UseNormFactorFromAlphaBkgContainer = 
+      (MDataValue*) ONDataplistfcn -> FindObject("UseNormFactorFromAlphaBkgValue");
+    UseNormFactorFromAlphaBkg = bool(UseNormFactorFromAlphaBkgContainer -> GetValue());
+
+
+    if (UseNormFactorFromAlphaBkg)
+    {
+	gLog << "fcnSupercuts :  UseNormFactorFromAlphaBkg variable set to kTRUE" << endl;
+    }
+    else
+    {
+	gLog << "fcnSupercuts :  UseNormFactorFromAlphaBkg variable set to kFALSE" << endl;
+    }
+
+
+
+
+    //
+    // transfer current parameter values to MSupercuts
+    //
+    // Attention : npar is the number of variable parameters
+    //                  not the total number of parameters
+    //
+    Double_t fMin, fEdm, fErrdef;
+    Int_t     fNpari, fNparx, fIstat;
+    gMinuit->mnstat(fMin, fEdm, fErrdef, fNpari, fNparx, fIstat);
+
+    super->SetParameters(TArrayD(fNparx, par));
+
+    //$$$$$$$$$$$$$$$$$$$$$
+    // for testing
+    //  TArrayD checkparameters = super->GetParameters();
+    //gLog << "fcnsupercuts : fNpari, fNparx =" << fNpari << ",  " 
+    //     << fNparx  << endl;
+    //gLog << "fcnsupercuts : i, par, checkparameters =" << endl;
+    //for (Int_t i=0; i<fNparx; i++)
+    //{
+    //gLog << i << ",  " << par[i] << ",  " << checkparameters[i] << endl;
+    //  }
+    //$$$$$$$$$$$$$$$$$$$$$
+
+    //
+    // plot alpha for ON data with the current cuts
+    //
+    if (!ONDataevtloopfcn->Eventloop())
+    {
+	gLog << "fcnsupercuts  : ONDataevtloopfcn->Eventloop() failed" << endl;
+    }
+    
+    // Somehow (??) I can not use the function MTaskList::PrintStatistics...
+    // it produces a segmentation fault...
+
+    //ONDataTasklistfcn->PrintStatistics(0, kFALSE);
+    
+    MH3* alpha = (MH3*)ONDataplistfcn->FindObject("AlphaFcn", "MH3");
+    if (!alpha)
+        return;
+
+    TH1 &alphaHist = alpha->GetHist();
+    alphaHist.SetName("alpha-fcnSupercuts");
+
+
+    //
+    // plot alpha for OFF data with the current cuts
+    //
+    if(!OFFDataevtloopfcn->Eventloop())
+    {
+	gLog << "fcnsupercuts  : OFFDataevtloopfcn->Eventloop() failed" << endl;
+    }
+
+    // Somehow (??) I can not use the function MTaskList::PrintStatistics...
+    // it produces a segmentation fault...
+
+    //OFFDataTasklistfcn->PrintStatistics(0, kFALSE);
+
+    MH3* alphaOFF = (MH3*) OFFDataplistfcn->FindObject("AlphaOFFFcn", "MH3");
+    if (!alphaOFF)
+        return;
+
+    TH1 &alphaHistOFF = alphaOFF->GetHist();
+    alphaHistOFF.SetName("alphaOFF-fcnSupercuts");
+
+
+
+
+
+    if (UseNormFactorFromAlphaBkg)
+      {
+	// Normalization factor computed using alpha bkg region
+	Double_t NewNormFactor = 
+	    ComputeNormFactorFromAlphaBkg(&alphaHist, &alphaHistOFF, 
+					  AlphaBkgMin, AlphaBkgMax);
+	
+	gLog << "Normalization factor computed from alpha plot (after cuts) " << endl
+	      << "using counted number of ON and OFF events in alpha region " << endl
+	      << "defined by range " << AlphaBkgMin << "-" << AlphaBkgMax << endl
+	      << "Normalization factor = " << NewNormFactor << endl;
+
+	gLog << "Normalization factor used is the one computed in bkg region; " << endl
+	      << "i.e. " << NewNormFactor << " instead of " << NormalizationFactorTrain << endl;
+
+	NormalizationFactorTrain = NewNormFactor;
+
+
+    }
+
+
+
+
+
+
+
+    //-------------------------------------------
+    // set Minuit pointer to zero in order not to destroy the TMinuit
+    // object for optimizing the supercuts
+    gMinuit = NULL;
+
+    //=================================================================
+    // fit alpha distribution to get the number of excess events and
+    // calculate significance of gamma signal in the alpha plot
+  
+    const Double_t alphasig = AlphaSig;
+    const Double_t alphamin = AlphaBkgMin; 
+   // alpha min for bkg region in ON data
+    const Double_t alphamax = AlphaBkgMax; // alpha max for bkg region in ON data
+    const Int_t    degreeON   =    2; 
+    // degree of polynomial used to fit ON data in Bkg  region
+    const Int_t    degreeOFF   =    2; 
+    // degree of polynomial used to fit OFF data in ALL region
+
+    Bool_t drawpoly;
+    Bool_t fitgauss;
+    Bool_t saveplots;
+    
+
+    if (iflag == 3)
+    {// Even though minimization finished successfully, I will NOT produce 
+	// final plots now... i'll do it later via the function 
+	// "MFindSupercutsONOFF::OutputOptimizationOnTrainSample()"
+
+        drawpoly  = kFALSE;
+        fitgauss  = kFALSE;
+	saveplots = kFALSE;
+    }
+    else
+    {
+        drawpoly  = kFALSE;
+        fitgauss  = kFALSE;
+	saveplots = kFALSE;
+	
+	
+    }
+
+
+    const Bool_t print = kTRUE;
+
+    MHFindSignificanceONOFF findsig;
+    findsig.SetRebin(kTRUE);
+    findsig.SetReduceDegree(kFALSE);
+    findsig.SetUseFittedQuantities(UseFittedQuantities);
+    
+    // TPostScript* DummyPs  = new TPostScript("dummy.ps");
+    
+    TString DummyPs = ("Dummy");
+
+    const Bool_t rc = findsig.FindSigmaONOFF(&alphaHist,&alphaHistOFF, 
+					     NormalizationFactorTrain, 
+					     alphamin, alphamax, 
+					     degreeON, degreeOFF,
+					     alphasig, drawpoly, fitgauss, 
+					     print, saveplots, 
+					     DummyPs);
+    //DummyPs -> Close();
+    //delete DummyPs;
+
+    
+    //=================================================================
+
+    // reset gMinuit to the MINUIT object for optimizing the supercuts 
+    gMinuit = savePointer;
+    //-------------------------------------------
+
+    if (!rc)
+    {
+        gLog << "fcnSupercuts : FindSigmaONOFF() failed" << endl;
+        f = 1.e10;
+        return;
+    }
+
+    /*
+
+    // plot some quantities during the optimization
+    MHCT1Supercuts *plotsuper = (MHCT1Supercuts*)ONDataplistfcn->FindObject("MHCT1Supercuts");
+    if (plotsuper)
+        plotsuper->Fill(&findsig);
+
+
+
+    */
+
+    //------------------------
+    // get significance
+    const Double_t significance = findsig.GetSignificance();
+    f = significance>0 ? -significance : 0;
+
+
+    gLog << " ///****************************************** ///" << endl;
+    gLog << "Significance (Li&Ma)is now: " << f << endl;
+    gLog << " ///****************************************** ///" << endl;
+
+    //------------------------
+    // optimize signal/background ratio
+    //Double_t ratio = findsig.GetNbg()>0.0 ? 
+    //                 findsig.GetNex()/findsig.GetNbg() : 0.0; 
+    //f = -ratio;
+
+    //-------------------------------------------
+    // final calculations
+    //if (iflag == 3)
+    //{
+    //
+    //}    
+
+    //-------------------------------------------------------------
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MFindSupercutsONOFF::MFindSupercutsONOFF(const char *name, const char *title)
+    : fHowManyTrain(10000), fHowManyTest(10000), fMatrixFilter(NULL)
+{
+    fName  = name  ? name  : "MFindSupercutsONOFF";
+    fTitle = title ? title : "Optimizer of the supercuts";
+
+    //---------------------------
+    // camera geometry is needed for conversion mm ==> degree
+    //fCam = new MGeomCamCT1Daniel; 
+    // fCam = new MGeomCamCT1; 
+    fCam = new MGeomCamMagic; 
+
+    // matrices to contain the training/test samples
+    fMatrixTrain = new MHMatrix("MatrixTrain");
+    fMatrixTest  = new MHMatrix("MatrixTest");
+    fMatrixTrainOFF = new MHMatrix("MatrixTrainOFF");
+    fMatrixTestOFF  = new MHMatrix("MatrixTestOFF");
+    
+
+    // objects of MSupercutsCalcONOFF to which these matrices are attached
+    fCalcHadTrain = new MSupercutsCalcONOFF("SupercutsCalcTrain");
+    fCalcHadTest  = new MSupercutsCalcONOFF("SupercutsCalcTest");
+    fCalcHadTrainOFF = new MSupercutsCalcONOFF("SupercutsCalcTrainOFF");
+    fCalcHadTestOFF  = new MSupercutsCalcONOFF("SupercutsCalcTestOFF");
+
+    // Define columns of matrices
+    fCalcHadTrain->InitMapping(fMatrixTrain);
+    fCalcHadTest->InitMapping(fMatrixTest);
+    fCalcHadTrainOFF->InitMapping(fMatrixTrainOFF);
+    fCalcHadTestOFF->InitMapping(fMatrixTestOFF);
+
+    // For the time being weights method is not implemented
+    //UseWeights = kFALSE; 
+
+    // Normalization factors are initialized to -1
+    // Functions determining Number of excess events will not work 
+    // with negative norm factors;  
+    // This will ensure that Norm factors are computed before running
+    // DetExcessONOFF() function.
+
+    fNormFactorTrain = -1.0;
+    fNormFactorTest = -1.0;
+
+    // SigmaLiMa and Nex member variables are initialized to 0
+
+    fSigmaLiMaTrain = 0.0;
+    fSigmaLiMaTest = 0.0;
+    fNexTrain = 0.0; 
+    fNexTest = 0.0; 
+
+    
+    // Cuts (low and up) in variable MPointingPos.fZd
+    // (at some point real theta)
+    // The default is not cut, i.e. all values (0-1) are taken
+    
+    fThetaMin = 0; // in miliradians  // FIXME: change name
+    fThetaMax = 90; // new: in deg; old: (1570) in miliradians // FIXME: change name
+    
+
+    fAlphaSig = 20; // By default, signal is expected in alpha<20 for CT1
+
+    // By default, bkg region is set to alpha range 30-90 for CT1
+    fAlphaBkgMin = 30; 
+    fAlphaBkgMax = 90;
+
+
+    // By default, bining for alpha plots is set to 
+    
+    fNAlphaBins = 54;
+    fAlphaBinLow = -12;
+    fAlphaBinUp = 96;
+
+
+
+    fNormFactorFromAlphaBkg = kTRUE; // By default normalization factor is 
+    // computed using bkg region in alpha histograms (after cuts)
+
+//    fActualCosThetaBinCenter = 0;
+
+    fTuneNormFactor = kTRUE; // Norm factors will be corrected using 
+    //the total amount of OFF events before cuts and the estimated excess events
+    // fNormFactorTrain = fNormFactorTrain - Ngammas/EventsInTrainMatrixOFF
+
+
+    // use quantities computed from the fits
+    // The variable allows the user to NOT use these quantities when there is not 
+    // enough statistics and fit not always is possible.
+    // Default value is kTRUE
+    fUseFittedQuantities = kTRUE;
+
+
+
+
+    // Boolean variable that allows the user to set some limits to the 
+    // some of the Minuit parameters. For the time being, only the limits
+    // for the parameters which do NOT depend in size, dist and theta are set, 
+    // i.e. static limits. The value of this boolean variable is set in the 
+    // constructor of the class.
+    
+    fSetLimitsToSomeMinuitParams = kTRUE;
+    
+    // Limits for the Minuit parameters. For the time being the values are set in the constructor 
+    // of the class. One MUST be very careful to set limits such that the expected final values 
+    // (optimized values) are far away from the limits.
+    
+    // Values in degrees
+    
+
+    fMinuitDistUPUpperLimit = 2.0;
+    fMinuitDistUPLowerLimit = 0.5;
+    fMinuitLengthUPUpperLimit = 0.8;
+    fMinuitLengthUPLowerLimit = 0.0;
+    fMinuitWidthUPUpperLimit = 0.5;
+    fMinuitWidthUPLowerLimit = 0.0;
+    fMinuitLeakage1UPUpperLimit = 1.5;
+    fMinuitLeakage1UPLowerLimit = -0.5;
+    
+    fMinuitDistLOWUpperLimit = 1.0;
+    fMinuitDistLOWLowerLimit = 0.0;
+    fMinuitLengthLOWUpperLimit = 0.5;
+    fMinuitLengthLOWLowerLimit = -0.3;
+    fMinuitWidthLOWUpperLimit = 0.4;
+    fMinuitWidthLOWLowerLimit = -0.3;
+
+
+
+    // Boolean variable that controls wether the optimization of the 
+    // parameters (MMinuitInterface::CallMinuit(..) in function FindParams(..))
+    // takes place or not. kTRUE will skip such optimization.
+    // This variable is useful to test the optmized parameters (previously found 
+    // and stored in root file) on the TRAIN sample.
+    
+    fSkipOptimization = kFALSE;
+
+    // Boolean variable that allows the user to write the initial parameters 
+    // into the root file that will be used to store the optimum cuts.
+    // If fUseInitialSCParams = kTRUE , parameters are written.
+    // In this way, the initial SC parameters can be applied on the data (train/test) 
+    
+    // The initial parameters are ONLY written to the root file if 
+    // there is NO SC params optimization, i.e., if variable 
+    // fSkipOptimization = kTRUE;
+
+    // The default value is obviously kFALSE.
+
+    fUseInitialSCParams = kTRUE;
+    
+
+    // Set wether to use or not hillas dist
+    fUseDist = kTRUE;
+
+
+
+
+    fGammaEfficiency = 0.5; // Fraction of gammas that remain after cuts
+    // Quantity that will have to be determined with MC, yet for the 
+    // time being I set it to 0.5 (standard value)
+
+    fPsFilename = NULL;
+    fPsFilename2 = NULL;
+
+
+    ////////////////////////////////////////////////////
+    // TMP
+
+    // There are quite some problems during the data preprocessing. 
+    // For the time being, I will add some cuts to the functions 
+    // DefineTrainTestMatrixThetaRange and for OFF, so that I can 
+    // make a kind of preprocess on my own. This allows me 
+    // to make a very silly preprocess with wolfgangs macro, which 
+    // might be free of corrupted data, and then I can do on my own.
+
+    fSizeCutLow = 0.1; // To prevent empty events
+    fSizeCutUp = 10000000;
+
+    // Angular cuts are converted to mm, which 
+    // are the units of the preprocessed data....
+
+
+    // Angular cuts not yet implemented ...
+    Double_t ConvMMToDeg = 0.00337034;
+    
+    fDistCutLow = 0.4/ConvMMToDeg;
+    fDistCutUp = 1.5/ConvMMToDeg;
+    
+    fLengthCutLow = 0.1/ConvMMToDeg;
+    fLengthCutUp = 1/ConvMMToDeg;
+
+    fWidthCutLow = 0.07/ConvMMToDeg;
+    fWidthCutUp = 1/ConvMMToDeg;
+
+    // ENDTMP
+    ////////////////////////////////////////////////////
+    
+
+
+
+
+}
+
+// --------------------------------------------------------------------------
+//
+// Default destructor.
+//
+MFindSupercutsONOFF::~MFindSupercutsONOFF()
+{
+
+    *fLog << "destructor of MFindSupercutsONOFF is called" << endl;
+
+    fPsFilename = NULL;
+    fPsFilename2 = NULL;
+
+
+    delete fCam;
+    delete fMatrixTrain;
+    delete fMatrixTest;
+    delete fCalcHadTrain;
+    delete fCalcHadTest;
+    delete fMatrixTrainOFF;
+    delete fMatrixTestOFF;
+    delete fCalcHadTrainOFF;
+    delete fCalcHadTestOFF;
+    
+    *fLog << "destructor of MFindSupercutsONOFF finished successfully" << endl;
+
+}
+
+// --------------------------------------------------------------------------
+//
+// Function that sets the name of the PostScript file where alpha distributions 
+// for the different Theta bins will be stored.
+// It also initializes 
+
+
+
+void MFindSupercutsONOFF::SetPostScriptFile (TPostScript* PsFile)
+{
+    fPsFilename = PsFile;
+
+    *fLog << "MFindSupercutsONOFF : Results (alpha distributions with excess and significances) will be stored in PostScript file " 
+	  << fPsFilename -> GetName() << endl;
+
+}
+
+void MFindSupercutsONOFF::SetPostScriptFile2 (TPostScript &PsFile)
+{
+    fPsFilename2 = new TPostScript (PsFile);
+
+    *fLog << "MFindSupercutsONOFF : Results (alpha distributions with excess and significances) will be stored in PostScript file " 
+	  << fPsFilename2 -> GetName() << endl;
+
+}
+
+void MFindSupercutsONOFF::SetPsFilenameString (const TString filename)
+{
+    fPsFilenameString = filename;
+}
+
+void MFindSupercutsONOFF::SetSkipOptimization(Bool_t b)
+{
+    fSkipOptimization = b;
+    if (fSkipOptimization)
+    {
+	*fLog << "MFindSupercutsONOFF :: SetSkipOptimization " << endl
+	      << "Variable fSkipOptimization is kTRUE, and therefore "
+	      << "the optimization of supercuts is skipped. Hope that's "
+	      << "what you want... " << endl;
+    }
+
+}
+
+
+void MFindSupercutsONOFF::SetUseInitialSCParams(Bool_t b)
+{
+    fUseInitialSCParams = b;
+    if (fUseInitialSCParams)
+    {
+	*fLog << "MFindSupercutsONOFF :: SetUseInitialSCParams " << endl
+	      << "Variable fUseInitialSCParams is kTRUE. " << endl;
+
+	if (fSkipOptimization)
+	{
+	    *fLog << "The Initial SC Parameters will be applied on the selected data."
+		  << endl;
+	}
+
+	else
+	{
+	    *fLog << "However, fSkipOptimization = kFALSE, and therefore, the " 
+		  << "the supercuts will be optimized. The final cuts that " 
+		  << "will be applied to the data will NOT be the initial SC parameters."
+		  << endl;
+
+	}
+
+
+
+    }
+    
+}
+
+
+
+Bool_t MFindSupercutsONOFF::SetAlphaSig(Double_t alphasig)
+{
+    // check that alpha is within the limits 0-90
+    if (alphasig <= 0 || alphasig > 90)
+    {
+	*fLog << "MFindSupercutsONOFF ::SetAlphaSig; " 
+	      << "value " << alphasig << " is not within the the "
+	      << "logical limits of alpha; 0-90" << endl;
+	return kFALSE;
+    }
+    
+
+    fAlphaSig = alphasig;
+
+    return kTRUE;
+}
+
+Bool_t MFindSupercutsONOFF::SetAlphaBkgMin(Double_t alpha)
+{
+    // check that alpha is within the limits 0-90
+    if (alpha <= 0 || alpha >= 90)
+    {
+	*fLog << "MFindSupercutsONOFF ::SetAlphaBkgMin; " 
+	      << "value " << alpha << " is not within the the "
+	      << "logical limits of alpha; 0-90" << endl;
+	return kFALSE;
+    }
+    
+
+    fAlphaBkgMin = alpha;
+
+    return kTRUE;
+}
+
+
+Bool_t MFindSupercutsONOFF::SetAlphaBkgMax(Double_t alpha)
+{
+    // check that alpha is within the limits 0-90
+    if (alpha <= 0 || alpha > 90.001)
+    {
+	*fLog << "MFindSupercutsONOFF ::SetAlphaBkgMax; " 
+	      << "value " << alpha << " is not within the the "
+	      << "logical limits of alpha; 0-90" << endl;
+	return kFALSE;
+    }
+    
+
+    fAlphaBkgMax = alpha;
+
+    return kTRUE;
+}
+
+
+// Function that checks that the values of the member data 
+// fAlphaSig, fAlphaBkgMin and fAlphaBkgMax make sense
+// (ie, fAlphaSig < fAlphaBkgMin < fAlphaBkgMax)
+
+Bool_t MFindSupercutsONOFF::CheckAlphaSigBkg()
+{
+
+    if (fAlphaSig > fAlphaBkgMin)
+    {
+	*fLog << "MFindSupercutsONOFF ::CheckAlphaSigBkg(); " << endl
+	      << "fAlphaSig > fAlphaBkgMin, which should not occur..." << endl
+	      << "fAlphaSig = " << fAlphaSig << ", fAlphaBkgMin = " << fAlphaBkgMin
+	      << endl;
+
+	return kFALSE;
+    }
+    
+    if (fAlphaBkgMax < fAlphaBkgMin)
+    {
+	*fLog << "MFindSupercutsONOFF ::CheckAlphaSigBkg(); " << endl
+	      << "fAlphaBkgMin > fAlphaBkgMax, which should not occur..." << endl
+	      << "fAlphaBkgMin = " << fAlphaBkgMin << ", fAlphaBkgMax = " << fAlphaBkgMax
+	      << endl;
+
+	return kFALSE;
+    }
+
+    return kTRUE;
+
+}
+
+
+/*
+// Function that computes the normalization factor using COUNTED events ON and OFF
+// in alpha region defined by fAlphaBkgMin and fAlphaBkgMax
+
+
+Double_t MFindSupercutsONOFF::ComputeNormFactorFromAlphaBkg(TH1 *histON, TH1 *histOFF)
+{
+
+    Double_t NormFactor = 0.0;
+    Double_t ONEvents = 0.0; 
+    Double_t OFFEvents = 0.0;
+
+    const Double_t SmallQuantity = 0.01;
+    
+    Double_t xlo = 0.0;
+    Double_t xup = 0.0;
+    Double_t width = 0.0;
+
+    Int_t BinCounterOFF = 0;
+    Int_t BinCounterON = 0;
+    
+
+    // I make a copy of the histograms so that nothing happens to the 
+    // histograms used in argument
+
+    TH1* HistON = (TH1*) histON->Clone();
+    TH1* HistOFF = (TH1*) histOFF->Clone();
+
+    if ( !HistON )
+    {
+	*fLog << "MFindSupercutsONOFF::ComputeNormFactorFromAlphaBkg; " << endl
+	      << "Clone of ON histogram could not be generated" 
+	      << endl;
+	return 0.0;
+    }
+
+
+    
+    if ( !HistOFF )
+    {
+	*fLog << "MFindSupercutsONOFF::ComputeNormFactorFromAlphaBkg; " << endl
+	      << " Clone of OFF histogram could not be generated" 
+	      << endl;
+	return 0.0;
+    }
+
+  // Calculate the number of OFF events in the Bkg region 
+  // defined by fAlphaBkgMin and fAlphaBkgMax 
+  // ___________________________________________________
+  
+
+    Int_t nbinsOFF = HistOFF -> GetNbinsX();  
+    Double_t binwidthOFF = HistOFF -> GetBinWidth(1);
+
+    for (Int_t i=1; i<=nbinsOFF; i++)
+    {
+	xlo = HistOFF->GetBinLowEdge(i);
+	xup = HistOFF->GetBinLowEdge(i+1);
+ 
+	// bin must be completely contained in the bkg region
+	if ( xlo >= (fAlphaBkgMin-SmallQuantity)  &&  xup <= (fAlphaBkgMax+SmallQuantity)    )
+	{
+	    width = fabs(xup-xlo);
+	    if (fabs(width-binwidthOFF) > SmallQuantity)
+	    {
+		*fLog << "MFindSupercutsONOFF::ComputeNormFactorFromAlphaBkg; " 
+		      << endl << " HistOFF has variable binning, which is not allowed" 
+		      << endl;
+		return 0.0;
+	    }
+
+	    BinCounterOFF++;
+
+	    OFFEvents  += HistOFF->GetBinContent(i);
+	    
+	}
+    }
+
+
+    // Calculate the number of ON events in the Bkg region 
+  // defined by fAlphaBkgMin and fAlphaBkgMax 
+  // ___________________________________________________
+  
+
+    Int_t nbinsON = HistON -> GetNbinsX();  
+    Double_t binwidthON = HistON -> GetBinWidth(1);
+
+    for (Int_t i=1; i<=nbinsON; i++)
+    {
+	xlo = HistON->GetBinLowEdge(i);
+	xup = HistON->GetBinLowEdge(i+1);
+ 
+	// bin must be completely contained in the bkg region
+	if ( xlo >= (fAlphaBkgMin-SmallQuantity)  &&  xup <= (fAlphaBkgMax+SmallQuantity)    )
+	{
+	    width = fabs(xup-xlo);
+	    if (fabs(width-binwidthON) > SmallQuantity)
+	    {
+		*fLog << "MFindSupercutsONOFF::ComputeNormFactorFromAlphaBkg; " 
+		      << endl << " HistON has variable binning, which is not allowed" 
+		      << endl;
+		return 0.0;
+	    }
+
+	    BinCounterON++;
+	    ONEvents  += HistON->GetBinContent(i);
+	    
+	}
+    }
+
+
+  
+
+    // NormFactor is computed
+
+      if (ONEvents < SmallQuantity || OFFEvents < SmallQuantity)
+      {
+	  *fLog << "MFindSupercutsONOFF::ComputeNormFactorFromAlphaBkg; " 
+		<< endl 
+		<< "ONEvents or OFFEvents computed in bkg region are < " 
+		<< SmallQuantity << endl;
+	  return 0.0;
+	  
+      }
+
+     
+	  
+    
+    NormFactor = ONEvents/OFFEvents;
+
+    Double_t error = 1/ONEvents + 1/OFFEvents;
+    error = TMath::Sqrt(error);
+    error = error * NormFactor;
+
+     // tmp info
+      cout << "MFindSupercutsONOFF::ComputeNormFactorFromAlphaBkg;" << endl
+	   << "ON Events in bkg region = " << ONEvents 
+	   << " (" << BinCounterON << " bins)"
+	   << " , OFF Events in bkg region = " << OFFEvents 
+	   << " (" << BinCounterOFF << " bins)" << endl
+	   <<"NormFactor computed from bkg region = " << NormFactor 
+	   << " +/- " << error << endl;
+      // end temp
+
+    return NormFactor;
+
+}
+
+
+*/
+
+
+// Function that set the values of fThetaMin and fThetaMax and also 
+// fThetaRangeString (with value in miliradians); 
+// data members that are used basically to print/plot
+// information. 
+
+Bool_t MFindSupercutsONOFF::SetThetaRange(Double_t ThetaMin, Double_t ThetaMax)
+{
+
+// Check  that values are reasonable... well ... i guess this was done 
+// in previous functions...
+
+    fThetaMin = int(ThetaMin*1000.0);
+    fThetaMax = int(ThetaMax*1000.0);
+
+    fThetaRangeString = ("ThetaRange");
+    fThetaRangeString += (fThetaMin);
+    fThetaRangeString += ("_");
+    fThetaRangeString += (fThetaMax);
+    fThetaRangeString += ("mRad");
+
+    return kTRUE;
+
+}
+
+// Function that sets Size range
+Bool_t MFindSupercutsONOFF::SetSizeRange(Double_t SizeMin, Double_t SizeMax)
+{
+
+
+    fSizeCutLow = SizeMin;
+    fSizeCutUp = SizeMax;
+
+    *fLog << "MFindSupercutsONOFF::SetSizeRange" << endl
+	  << "Data matrices will be filled with events whose MHillas.fSize " << endl
+	  << "is in the range " 
+	  << fSizeCutLow <<"-"<<fSizeCutUp << endl;
+
+
+
+    return kTRUE;
+}
+
+
+
+// Function that sets the names of all parameter containers 
+// used to store the supercuts applied to ON/OFF Train/Test samples
+
+void MFindSupercutsONOFF::SetSupercutsAppliedTreeNames()
+{
+
+    char* sc = {"SupercutsApplied"};
+
+    fTrainONSupercutsAppliedName = (sc);  
+    fTrainONSupercutsAppliedName += ("TrainON");
+
+    fTrainOFFSupercutsAppliedName = (sc);       
+    fTrainOFFSupercutsAppliedName += ("TrainOFF");
+
+    fTestONSupercutsAppliedName = (sc);
+    fTestONSupercutsAppliedName += ("TestON");
+
+    fTestOFFSupercutsAppliedName = (sc); 
+    fTestOFFSupercutsAppliedName += ("TestOFF");
+    
+
+    if (fThetaRangeString.IsNull())
+    {
+	*fLog << "MFindSupercutsONOFF::SetSupercutsAppliedTreeNames; "
+	      << " fThetaRangeString is NOT defined..." << endl;
+
+	fTrainONSupercutsAppliedName += ("ThetaRangeStringUndefined");
+	fTrainOFFSupercutsAppliedName += ("ThetaRangeStringUndefined");
+	fTestONSupercutsAppliedName += ("ThetaRangeStringUndefined");
+	fTestOFFSupercutsAppliedName += ("ThetaRangeStringUndefined");
+    }
+    else
+    {
+	fTrainONSupercutsAppliedName += (fThetaRangeString);
+	fTrainOFFSupercutsAppliedName += (fThetaRangeString);
+	fTestONSupercutsAppliedName += (fThetaRangeString);
+	fTestOFFSupercutsAppliedName += (fThetaRangeString);
+    }
+     
+    // Info about names
+
+    *fLog << "MFindSupercutsONOFF::SetSupercutsAppliedTreeNames; " << endl
+	  << "Names of the MTSupercutsApplied Trees for Train (ON/OFF) " 
+	  << " and Test (ON/OFF) samples are the following ones: " << endl
+	  << fTrainONSupercutsAppliedName << ", " 
+	  << fTrainOFFSupercutsAppliedName << ", "
+	  << fTestONSupercutsAppliedName << ", "
+	  << fTestOFFSupercutsAppliedName << endl;
+  
+}
+
+
+void MFindSupercutsONOFF::SetUseOrigDistribution(Bool_t b)
+{
+  fUseOrigDistribution = b;
+
+  if (fUseOrigDistribution == kTRUE)
+  {
+ 
+      *fLog << "MFindSupercutsONOFF : when defining training and test matrices use the original distribution" 
+	    << endl;
+  }
+
+  else 
+  {
+      *fLog << "MFindSupercutsONOFF : when defining training and test matrices, events will be selected according to distribution given by a MH3 object" 
+	    << endl;
+  }
+}
+
+
+
+// --------------------------------------------------------------------------
+//
+// Define the matrix 'fMatrixTrain' for the training sample
+//
+// alltogether 'howmanytrain' events are read from file 'nametrain';
+// the events are selected according to a target distribution 'hreftrain'
+//
+//
+Bool_t MFindSupercutsONOFF::DefineTrainMatrix(const TString &nametrain, MH3 &hreftrain,
+						 const Int_t howmanytrain, 
+						 const TString &filetrain)
+{
+    if (nametrain.IsNull() || howmanytrain <= 0)
+        return kFALSE;
+
+    *fLog << "=============================================" << endl;
+    *fLog << "fill training matrix from file '" << nametrain 
+          << "',   select " << howmanytrain 
+          << " events " << endl;
+
+    if (!fUseOrigDistribution)
+    {
+      *fLog << "     according to a distribution given by the MH3 object '"
+            << hreftrain.GetName() << "'" << endl;
+    }
+    else
+    {
+      *fLog << "     randomly" << endl;
+    }
+    
+
+
+    MParList  plist;
+    MTaskList tlist;
+
+    MReadMarsFile read("Events", nametrain);
+    read.DisableAutoScheme();
+
+
+    MFEventSelector2 seltrain(hreftrain);
+    seltrain.SetNumMax(howmanytrain);
+    seltrain.SetName("selectTrain");
+    if (fUseOrigDistribution)
+    {
+	*fLog << "MFindSupercutsONFF; MFEventSelector2::SetUseOrigDistribution(Bool)"
+	      << " DOES NOT EXIST NOW..." << endl;
+	// seltrain.SetUseOrigDistribution(kTRUE);
+    }
+
+
+    MFillH filltrain(fMatrixTrain);
+    filltrain.SetFilter(&seltrain);
+    filltrain.SetName("fillMatrixTrain");
+
+    //******************************
+    // entries in MParList 
+    
+    plist.AddToList(&tlist);
+    plist.AddToList(fCam);
+    plist.AddToList(fMatrixTrain);
+
+    //******************************
+    // entries in MTaskList 
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&seltrain);
+    tlist.AddToList(&filltrain);
+
+    //******************************
+
+    MProgressBar bar;
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+    evtloop.SetName("EvtLoopMatrixTrain");
+    evtloop.SetProgressBar(&bar);
+
+    if (!evtloop.Eventloop())
+      return kFALSE;
+
+    tlist.PrintStatistics(0, kTRUE);
+
+    fMatrixTrain->Print("SizeCols");
+    Int_t howmanygenerated = fMatrixTrain->GetM().GetNrows();
+    if (TMath::Abs(howmanygenerated-howmanytrain) > TMath::Sqrt(9.*howmanytrain))
+    {
+      *fLog << "MFindSupercutsONOFF::DefineTrainMatrix; no.of generated events ("
+	    << howmanygenerated 
+            << ") is incompatible with the no.of requested events ("
+            << howmanytrain << ")" << endl;
+    }
+
+    *fLog << "training matrix was filled" << endl;
+    *fLog << "=============================================" << endl;
+
+    //--------------------------
+    // write out training matrix
+
+    if (filetrain != "")
+    {
+      TFile filetr(filetrain, "RECREATE");
+      fMatrixTrain->Write();
+      filetr.Close();
+
+      *fLog << "MFindSupercuts::DefineTrainMatrix; Training matrix was written onto file '"
+            << filetrain << "'" << endl;
+    }
+
+
+    return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+
+ 
+
+// --------------------------------------------------------------------------
+//
+// Define the matrix for the test sample
+//
+// alltogether 'howmanytest' events are read from file 'nametest'
+//
+// the events are selected according to a target distribution 'hreftest'
+//
+//
+Bool_t MFindSupercutsONOFF::DefineTestMatrix(const TString &nametest, MH3 &hreftest,
+						const Int_t howmanytest, const TString &filetest)
+{
+    if (nametest.IsNull() || howmanytest<=0)
+        return kFALSE;
+
+    *fLog << "=============================================" << endl;
+    *fLog << "fill test matrix from file '" << nametest 
+          << "',   select " << howmanytest << " events " << endl;
+
+
+    if (!fUseOrigDistribution)
+    {
+      *fLog << "     according to a distribution given by the MH3 object '"
+            << hreftest.GetName() << "'" << endl;
+    }
+    else
+    {
+      *fLog << "     randomly" << endl;
+    }
+
+
+    MParList  plist;
+    MTaskList tlist;
+
+    MReadMarsFile read("Events", nametest);
+    read.DisableAutoScheme();
+
+    MFEventSelector2 seltest(hreftest);
+    seltest.SetNumMax(howmanytest);
+    seltest.SetName("selectTest");
+    if (fUseOrigDistribution)
+    {
+	*fLog << "MFindSupercutsONFF; MFEventSelector2::SetUseOrigDistribution(Bool)"
+	      << " DOES NOT EXIST NOW..." << endl;
+	// seltest.SetUseOrigDistribution(kTRUE);
+    }
+      
+
+    MFillH filltest(fMatrixTest);
+    filltest.SetFilter(&seltest);
+    filltest.SetName("fillMatrixTest");
+
+
+
+    //******************************
+    // entries in MParList 
+    
+    plist.AddToList(&tlist);
+    plist.AddToList(fCam);
+    plist.AddToList(fMatrixTest);
+
+    //******************************
+    // entries in MTaskList 
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&seltest);
+    tlist.AddToList(&filltest);
+
+    //******************************
+
+    MProgressBar bar;
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+    evtloop.SetName("EvtLoopMatrixTest");
+    evtloop.SetProgressBar(&bar);
+
+    if (!evtloop.Eventloop())
+      return kFALSE;
+
+    tlist.PrintStatistics(0, kTRUE);
+
+    fMatrixTest->Print("SizeCols");
+    const Int_t howmanygenerated = fMatrixTest->GetM().GetNrows();
+    if (TMath::Abs(howmanygenerated-howmanytest) > TMath::Sqrt(9.*howmanytest))
+    {
+      *fLog << "MFindSupercutsONOFF::DefineTestMatrix; no.of generated events ("
+	    << howmanygenerated 
+            << ") is incompatible with the no.of requested events ("
+            << howmanytest << ")" << endl;
+    }
+
+    *fLog << "test matrix was filled" << endl;
+    *fLog << "=============================================" << endl;
+
+    //--------------------------
+    // write out test matrix
+
+    if (filetest != "")
+    {
+      TFile filete(filetest, "RECREATE", "");
+      fMatrixTest->Write();
+      filete.Close();
+
+      *fLog << "MFindSupercutsONOFF::DefineTestMatrix; Test matrix was written onto file '"
+            << filetest << "'" << endl;
+    }
+
+
+    
+    return kTRUE;
+}
+
+
+
+// --------------------------------------------------------------------------
+//
+// Define the matrices for the training and test sample respectively
+//
+//
+//
+Bool_t MFindSupercutsONOFF::DefineTrainTestMatrix(
+    const TString &name, MH3 &href,
+    const Int_t howmanytrain, const Int_t howmanytest,
+    const TString &filetrain, const TString &filetest)
+{
+    *fLog << "=============================================" << endl;
+    *fLog << "fill training and test matrix from file '" << name 
+          << "',   select "   << howmanytrain 
+          << " training and " << howmanytest << " test events " << endl;
+    if (!fUseOrigDistribution)
+    {
+      *fLog << "     according to a distribution given by the MH3 object '"
+            << href.GetName() << "'" << endl;
+    }
+    else
+    {
+      *fLog << "     randomly" << endl;
+    }
+
+
+    MParList  plist;
+    MTaskList tlist;
+
+    MReadMarsFile read("Events", name);
+    read.DisableAutoScheme();
+
+     MFEventSelector2 selector(href);
+    selector.SetNumMax(howmanytrain+howmanytest);
+    selector.SetName("selectTrainTest");
+    selector.SetInverted();
+    if (fUseOrigDistribution)
+    {
+	*fLog << "MFindSupercutsONFF; MFEventSelector2::SetUseOrigDistribution(Bool)"
+	      << " DOES NOT EXIST NOW..." << endl;
+	// selector.SetUseOrigDistribution(kTRUE);
+    }
+
+    MContinue cont(&selector);
+    cont.SetName("ContTrainTest");
+
+    Double_t prob =  ( (Double_t) howmanytrain )
+                   / ( (Double_t)(howmanytrain+howmanytest) );
+    MFRandomSplit split(prob);
+
+    MFillH filltrain(fMatrixTrain);
+    filltrain.SetFilter(&split);
+    filltrain.SetName("fillMatrixTrain");
+
+
+    // consider this event as candidate for a test event 
+    // only if event was not accepted as a training event
+
+    MContinue conttrain(&split);
+    conttrain.SetName("ContTrain");
+
+    MFillH filltest(fMatrixTest);
+    filltest.SetName("fillMatrixTest");
+
+
+    //******************************
+    // entries in MParList 
+    
+    plist.AddToList(&tlist);
+    plist.AddToList(fCam);
+    plist.AddToList(fMatrixTrain);
+    plist.AddToList(fMatrixTest);
+
+    //******************************
+
+
+    //******************************
+    // entries in MTaskList 
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&cont);
+
+    tlist.AddToList(&split);
+    tlist.AddToList(&filltrain);
+    tlist.AddToList(&conttrain);
+
+    tlist.AddToList(&filltest);
+
+    //******************************
+
+    MProgressBar bar;
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+    evtloop.SetName("EvtLoopMatrixTrainTest");
+    evtloop.SetProgressBar(&bar);
+
+    Int_t maxev = -1;
+    if (!evtloop.Eventloop(maxev))
+      return kFALSE;
+
+    tlist.PrintStatistics(0, kTRUE);
+
+    fMatrixTrain->Print("SizeCols");
+
+    const Int_t generatedtrain = fMatrixTrain->GetM().GetNrows();
+    if (TMath::Abs(generatedtrain-howmanytrain) > TMath::Sqrt(9.*howmanytrain))
+    {
+      *fLog << "MFindSupercuts::DefineTrainTestMatrix; no.of generated events ("
+	    << generatedtrain 
+            << ") is incompatible with the no.of requested events ("
+            << howmanytrain << ")" << endl;
+    }
+
+    fMatrixTest->Print("SizeCols");
+    const Int_t generatedtest = fMatrixTest->GetM().GetNrows();
+    if (TMath::Abs(generatedtest-howmanytest) > TMath::Sqrt(9.*howmanytest))
+    {
+      *fLog << "MFindSupercuts::DefineTrainTestMatrix; no.of generated events ("
+	    << generatedtest 
+            << ") is incompatible with the no.of requested events ("
+            << howmanytest << ")" << endl;
+    }
+
+
+    *fLog << "training and test matrix were filled" << endl;
+    *fLog << "=============================================" << endl;
+
+
+    //--------------------------
+    // write out training matrix
+
+    if (filetrain != "")
+    {
+      TFile filetr(filetrain, "RECREATE");
+      fMatrixTrain->Write();
+      filetr.Close();
+
+      *fLog << "MFindSupercuts::DefineTrainTestMatrix; Training matrix was written onto file '"
+            << filetrain << "'" << endl;
+    }
+
+    //--------------------------
+    // write out test matrix
+
+    if (filetest != "")
+    {
+      TFile filete(filetest, "RECREATE", "");
+      fMatrixTest->Write();
+      filete.Close();
+
+      *fLog << "MFindSupercuts::DefineTrainTestMatrix; Test matrix was written onto file '"
+            << filetest << "'" << endl;
+    }
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Define the matrices for the training and test OFF sample respectively
+//
+//
+//
+
+Bool_t MFindSupercutsONOFF::DefineTrainTestMatrixOFFThetaRange(
+    const TString &name, 
+    const Double_t whichfractiontrain, 
+    const Double_t whichfractiontest,  
+    Double_t ThetaMin, Double_t ThetaMax, 
+    const TString &filetrain, const TString &filetest)
+    
+
+
+{
+    *fLog << "=============================================" << endl;
+    *fLog << "Fill training and testing OFF matrices from file '" << name 
+          << "',   select a fraction of " << whichfractiontrain 
+          << " events for the training and a fraction of " << endl
+	  << whichfractiontest << " for the testing" << endl;
+
+
+    MParList  plist;
+    MTaskList tlist;
+
+    MReadMarsFile read("Events", name);
+    read.DisableAutoScheme();
+
+
+    
+
+    
+    // Cuts in Theta
+
+    // TString ThetaCutMinString ("ThetaOrig.fVal>");
+    TString ThetaCutMinString ("MPointingPos.fZd>"); // new! // for magic
+    ThetaCutMinString += ThetaMin;
+    MContinue ThetaCutMin(ThetaCutMinString);
+    ThetaCutMin.SetInverted();
+
+    //TString ThetaCutMaxString ("ThetaOrig.fVal<");
+    TString ThetaCutMaxString ("MPointingPos.fZd<"); // new! // for magic
+    ThetaCutMaxString += ThetaMax;
+    MContinue ThetaCutMax(ThetaCutMaxString);
+    ThetaCutMax.SetInverted();
+
+
+    // TMP
+    // Cuts in Size,
+
+    TString SizeCutMinString ("MHillas.fSize>"); 
+    SizeCutMinString += fSizeCutLow;
+    MContinue SizeCutMin(SizeCutMinString);
+    SizeCutMin.SetInverted();
+
+    
+    TString SizeCutMaxString ("MHillas.fSize<"); 
+    SizeCutMaxString += fSizeCutUp;
+    MContinue SizeCutMax(SizeCutMaxString);
+    SizeCutMax.SetInverted();
+    
+
+
+
+    // ENDTMP
+
+
+
+
+    Double_t prob = whichfractiontrain /(whichfractiontrain+whichfractiontest);
+                   
+    MFRandomSplit split(prob);
+
+    MFillH filltrain(fMatrixTrainOFF);
+    filltrain.SetName("fillMatrixTrainOFF");
+    filltrain.SetFilter(&split);
+    
+    
+    // consider this event as candidate for a test event 
+    // only if event was not accepted as a training event
+
+    MContinue conttrain(&split);
+    conttrain.SetName("ContTrain");
+
+    MFillH filltest(fMatrixTestOFF);
+    filltest.SetName("fillMatrixTestOFF");
+    
+
+    //******************************
+    // entries in MParList 
+    
+    plist.AddToList(&tlist);
+    plist.AddToList(fCam);
+    plist.AddToList(fMatrixTrainOFF);
+    plist.AddToList(fMatrixTestOFF);
+
+    //******************************
+    // entries in MTaskList 
+
+    tlist.AddToList(&read);
+//    tlist.AddToList(&ThetaCutMin);
+//    tlist.AddToList(&ThetaCutMax);
+    
+    //TMP
+    tlist.AddToList(&SizeCutMin);
+    tlist.AddToList(&SizeCutMax);
+
+    //ENDTMP
+    tlist.AddToList(&split);
+    tlist.AddToList(&filltrain);
+
+    tlist.AddToList(&conttrain);
+    tlist.AddToList(&filltest);
+
+    //******************************
+
+    MProgressBar bar;
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+    evtloop.SetName("EvtLoopMatrixTrainTestOFF");
+    evtloop.SetProgressBar(&bar);
+    
+    Int_t maxev = -1;
+    if (!evtloop.Eventloop(maxev))
+      return kFALSE;
+
+    tlist.PrintStatistics(0, kTRUE);
+
+    fMatrixTrainOFF->Print("SizeCols");
+
+    
+    fMatrixTestOFF->Print("SizeCols");
+    
+
+    *fLog << "train and test matrix OFF were filled" << endl;
+    *fLog << "=============================================" << endl;
+    
+    
+    //--------------------------
+    // write out training matrix
+    
+    if (filetrain != "")
+    {
+	TFile filetr(filetrain, "RECREATE");
+	fMatrixTrainOFF->Write();
+	filetr.Close();
+	
+	*fLog << "MFindSupercutsONOFF::DefineTrainTestMatrixOFFThetaRange; Training matrix was written onto file '"
+	      << filetrain << "'" << endl;
+    }
+    
+    //--------------------------
+    // write out test matrix
+
+    if (filetest != "")
+    {
+	TFile filete(filetest, "RECREATE", "");
+	fMatrixTestOFF->Write();
+	filete.Close();
+	
+	*fLog << "MFindSupercutsONOFF::DefineTrainTestMatrixOFFThetaRange; Test matrix was written onto file '"
+	      << filetest << "'" << endl;
+    }
+    
+    return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Define the matrices for the training and test sample respectively
+//
+//
+//
+Bool_t MFindSupercutsONOFF::DefineTrainTestMatrixThetaRange(
+    const TString &name, 
+    const Double_t whichfractiontrain, 
+    const Double_t whichfractiontest,  
+    Double_t ThetaMin, Double_t ThetaMax, 
+    const TString &filetrain, const TString &filetest)
+
+   
+{
+    *fLog << "=============================================" << endl;
+    *fLog << "Fill training and testing ON matrices from file '" << name 
+          << "',   select a fraction of " << whichfractiontrain 
+          << " events for the training and a fraction of " << endl
+	  << whichfractiontest << " for the testing" << endl;
+
+
+    MParList  plist;
+    MTaskList tlist;
+
+    
+    MReadMarsFile read("Events", name);
+    read.DisableAutoScheme();
+
+
+     // Cuts in Theta
+
+    //TString ThetaCutMinString ("ThetaOrig.fVal>");
+    TString ThetaCutMinString ("MPointingPos.fZd>"); // for magic
+    ThetaCutMinString += ThetaMin;
+    MContinue ThetaCutMin(ThetaCutMinString);
+    ThetaCutMin.SetInverted();
+
+    //TString ThetaCutMaxString ("ThetaOrig.fVal<");
+    TString ThetaCutMaxString ("MPointingPos.fZd<"); // for magic
+    ThetaCutMaxString += ThetaMax;
+    MContinue ThetaCutMax(ThetaCutMaxString);
+    ThetaCutMax.SetInverted();
+
+
+    // TMP
+    // Cuts in Size,
+
+    TString SizeCutMinString ("MHillas.fSize>"); 
+    SizeCutMinString += fSizeCutLow;
+    MContinue SizeCutMin(SizeCutMinString);
+    SizeCutMin.SetInverted();
+
+    
+    TString SizeCutMaxString ("MHillas.fSize<"); 
+    SizeCutMaxString += fSizeCutUp;
+    MContinue SizeCutMax(SizeCutMaxString);
+    SizeCutMax.SetInverted();
+    
+
+
+
+    // ENDTMP
+
+
+
+    
+    Double_t prob = whichfractiontrain/(whichfractiontrain + whichfractiontest);
+                   
+    MFRandomSplit split(prob);
+
+    MFillH filltrain(fMatrixTrain);
+    filltrain.SetName("fillMatrixTrain");
+    filltrain.SetFilter(&split);
+    
+    
+    // consider this event as candidate for a test event 
+    // only if event was not accepted as a training event
+
+    MContinue conttrain(&split);
+    conttrain.SetName("ContTrain");
+
+    MFillH filltest(fMatrixTest);
+    filltest.SetName("fillMatrixTest");
+
+
+  
+
+    //******************************
+    // entries in MParList 
+    
+    plist.AddToList(&tlist);
+    plist.AddToList(fCam);
+    plist.AddToList(fMatrixTrain);
+    plist.AddToList(fMatrixTest);
+
+    //******************************
+    // entries in MTaskList 
+
+    tlist.AddToList(&read);
+//    tlist.AddToList(&ThetaCutMin);
+//    tlist.AddToList(&ThetaCutMax);
+    
+       
+    //TMP
+    tlist.AddToList(&SizeCutMin);
+    tlist.AddToList(&SizeCutMax);
+
+    //ENDTMP
+
+    tlist.AddToList(&split);
+    tlist.AddToList(&filltrain);
+
+    tlist.AddToList(&conttrain);
+    tlist.AddToList(&filltest);
+
+    //******************************
+
+    MProgressBar bar;
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+    evtloop.SetName("EvtLoopMatrixTrainTest");
+    evtloop.SetProgressBar(&bar);
+
+    Int_t maxev = -1;
+    if (!evtloop.Eventloop(maxev))
+      return kFALSE;
+
+    tlist.PrintStatistics(0, kTRUE);
+
+    fMatrixTrain->Print("SizeCols");
+    
+    fMatrixTest->Print("SizeCols");
+    
+
+    *fLog << "training and test matrix were filled" << endl;
+    *fLog << "=============================================" << endl;
+
+
+    //--------------------------
+    // write out training matrix
+
+    if (filetrain != "")
+    {
+      TFile filetr(filetrain, "RECREATE");
+      fMatrixTrain->Write();
+      filetr.Close();
+
+      *fLog << "MFindSupercutsONOFF::DefineTrainTestMatrixThetaRange; Train matrix was written onto file '"
+            << filetrain << "'" << endl;
+    }
+
+
+     //--------------------------
+    // write out test matrix
+
+    if (filetest != "")
+    {
+      TFile filete(filetest, "RECREATE", "");
+      fMatrixTest->Write();
+      filete.Close();
+
+      *fLog << "MFindSupercutsONOFF::DefineTrainTestMatrixThetaRange; Test matrix was written onto file '"
+            << filetest << "'" << endl;
+    }
+
+  return kTRUE;
+}
+
+
+
+
+/// **********///
+
+// --------------------------------------------------------------------------
+//
+// Read training and test matrices from files
+//
+//
+
+Bool_t MFindSupercutsONOFF::ReadMatrix(const TString &filetrain, const TString &filetest)
+{
+  //--------------------------
+  // read in training matrix
+
+  TFile filetr(filetrain);
+  fMatrixTrain->Read("MatrixTrain");
+  fMatrixTrain->Print("SizeCols");
+
+  *fLog << "MFindSupercuts::ReadMatrix; Training matrix was read in from file '"
+        << filetrain << "'" << endl;
+  filetr.Close();
+
+
+  //--------------------------
+  // read in test matrix
+
+  TFile filete(filetest);
+  fMatrixTest->Read("MatrixTest");
+  fMatrixTest->Print("SizeCols");
+
+  *fLog << "MFindSupercuts::ReadMatrix; Test matrix was read in from file '"
+        << filetest << "'" << endl;
+  filete.Close();
+
+  return kTRUE;  
+}
+
+
+// Read training and test matrices OFF from files
+//
+//
+
+Bool_t MFindSupercutsONOFF::ReadMatrixOFF(const TString &filetrain, const TString &filetest)
+{
+  //--------------------------
+  // read in training matrix
+
+  TFile filetr(filetrain);
+  fMatrixTrainOFF->Read("MatrixTrainOFF");
+  fMatrixTrainOFF->Print("SizeCols");
+
+  *fLog << "MFindSupercutsONOFF::ReadMatrixOFF; Training matrix OFF was read in from file '"
+        << filetrain << "'" << endl;
+  filetr.Close();
+
+
+  //--------------------------
+  // read in test matrix
+
+  TFile filete(filetest);
+  fMatrixTestOFF->Read("MatrixTestOFF");
+  fMatrixTestOFF->Print("SizeCols");
+
+  *fLog << "MFindSupercutsONOFF::ReadMatrixONOFF; Test matrix OFF was read in from file '"
+        << filetest << "'" << endl;
+  filete.Close();
+
+  return kTRUE;  
+}
+
+
+
+// Function to compute the normalization factor for Train sample.
+// The normalization factor is defined as the ratio of OFF/ON events.
+
+Bool_t  MFindSupercutsONOFF::ComputeNormFactorTrain()
+{
+   Int_t EventsInTrainMatrixON = fMatrixTrain->GetM().GetNrows(); 
+   Int_t EventsInTrainMatrixOFF = fMatrixTrainOFF->GetM().GetNrows();
+
+   // Info...
+   *fLog << "MFindSupercutsONOFF::ComputeNormFactorTrain; " << endl
+	 << "EventsInTrainMatrixON = " << EventsInTrainMatrixON 
+	 << " , EventsInTrainMatrixOFF = " << EventsInTrainMatrixOFF << endl;
+
+
+   fNormFactorTrain = double(EventsInTrainMatrixON)/double(EventsInTrainMatrixOFF);
+
+   
+   *fLog << "MFindSupercutsONOFF::ComputeNormFactorTrain; fNormFactorTrain is : " 
+	 << fNormFactorTrain << endl;
+   
+   return kTRUE;
+}
+
+
+
+
+// Function to compute the normalization factor for Test sample.
+// The normalization factor is defined as the ratio of OFF/ON events.
+
+Bool_t  MFindSupercutsONOFF::ComputeNormFactorTest()
+{
+   Int_t EventsInTestMatrixON = fMatrixTest->GetM().GetNrows(); 
+   Int_t EventsInTestMatrixOFF = fMatrixTestOFF->GetM().GetNrows();
+
+   // Info...
+   *fLog << "MFindSupercutsONOFF::ComputeNormFactorTest; " << endl
+	 << "EventsInTestMatrixON = " << EventsInTestMatrixON 
+	 << " , EventsInTestMatrixOFF = " << EventsInTestMatrixOFF << endl;
+
+   fNormFactorTest = double(EventsInTestMatrixON)/double(EventsInTestMatrixOFF);
+   
+   *fLog << "MFindSupercutsONOFF::ComputeNormFactorTest; fNormFactorTest is : " 
+	 << fNormFactorTest << endl;
+
+   return kTRUE;
+}
+
+
+Bool_t  MFindSupercutsONOFF::SetGammaEfficiency(Double_t gammaeff)
+{
+
+    if (gammaeff < 0.0 || gammaeff >1.0)
+    {
+	*fLog << "MFindSupercutsONOFF::SetGammaEfficiency; " << endl
+	      << "The argument of SetGammaEfficiency ("
+	      << gammaeff << ") is outside the range 0-1" << endl
+	      << "This is not allowed..." << endl;
+	return kFALSE;
+	    
+    }
+
+    fGammaEfficiency = gammaeff;
+    
+    // TEMP INFO
+    cout << "fGammaEfficiency has been set to : " << fGammaEfficiency << endl;
+    // END TEMP
+    return kTRUE;
+	
+
+}
+
+//------------------------------------------------------------------------
+//
+// Steering program for optimizing the supercuts
+// ---------------------------------------------
+//
+//      the criterion for the 'optimum' is 
+//
+//          - a maximum significance of the gamma signal in the alpha plot, 
+//            in which the supercuts have been applied
+//
+// The various steps are :
+//
+// - setup the 2 event loops (ON and OFF) to be executed for each call to fcnSupercuts 
+// - call TMinuit to do the minimization of (-significance) :
+//        the fcnSupercuts function calculates the significance 
+//                                             for the current cut values
+//        for this - the 2 alpha plots (ON and OFF) are produced in the 2 event loops, 
+//                   in which the SAME cuts have been applied
+//                 - the significance of the gamma signal is extracted from the 
+//                   the 2 alpha plots (ON OFF) using MHFindSignificanceONOFF::FindSigmaONOFF.
+//                   
+//
+// Needed as input : (to be set by the Set functions)
+//
+// - fFilenameParam      name of file to which optimum values of the 
+//                       parameters are written
+//
+// - fHadronnessName     name of container where MSupercutsCalcONOFF will
+//                       put the supercuts hadronness for ON data
+
+// - fHadronnessNameOFF  name of container where MSupercutsCalcONOFF will
+//                       put the supercuts hadronness for OFF data
+//
+// - fAlphaSig, fAlphaBkgMin, fAlphaBkgMax ; Signal and Bkg region in alpha histo. 
+
+// - for the minimization, the starting values of the parameters are taken  
+//     - from file parSCinit (if it is != "")
+//     - or from the arrays params and/or steps 
+//
+//----------------------------------------------------------------------
+Bool_t MFindSupercutsONOFF::FindParams(TString parSCinit,
+					  TArrayD &params, TArrayD &steps)
+{
+    // Setup the event loops which will be executed in the 
+    //                 fcnSupercuts function  of MINUIT
+    //
+    // parSCinit is the name of the file containing the initial values 
+    // of the parameters; 
+    // if parSCinit = ""   'params' and 'steps' are taken as initial values
+
+    *fLog << "=============================================" << endl;
+    *fLog << "Setup event loop for fcnSupercuts" << endl;
+
+    if (fHadronnessName.IsNull())
+    {
+      *fLog << "MFindSupercutsONOFF::FindParams; hadronness name for ON data is not defined... aborting"
+            << endl;
+      return kFALSE;
+    }
+
+
+    if (fHadronnessNameOFF.IsNull())
+    {
+      *fLog << "MFindSupercutsONOFF::FindParams; hadronness name for OFF data is not defined... aborting"
+            << endl;
+      return kFALSE;
+    }
+
+
+    if (fMatrixTrain == NULL)
+    {
+      *fLog << "MFindSupercuts::FindParams; training matrix is not defined... aborting"
+            << endl;
+      return kFALSE;
+    }
+
+    if (fMatrixTrain->GetM().GetNrows() <= 0)
+    {
+      *fLog << "MFindSupercuts::FindParams; training matrix has no entries"
+            << endl;
+      return kFALSE;
+    }
+
+    
+
+    if (fMatrixTrainOFF == NULL)
+    {
+      *fLog << "MFindSupercutsONOFF::FindParams; training matrix OFF is not defined... aborting"
+            << endl;
+      return kFALSE;
+    }
+
+    if (fMatrixTrainOFF->GetM().GetNrows() <= 0)
+    {
+      *fLog << "MFindSupercutsONOFF::FindParams; training matrix OFF has no entries"
+            << endl;
+      return kFALSE;
+    }
+
+    if (fAlphaDistributionsRootFilename.IsNull())
+    {
+	*fLog << "MFindSupercutsONOFF::FindParams; fAlphaDistributionsRootFilename is not defined... program aborting..." << endl;
+
+	return kFALSE;
+    }
+
+   
+
+    //--------------------------------
+    // create container for the supercut parameters
+    // and set them to their initial values
+    MSupercuts super;
+
+    // take initial values from file parSCinit
+    if (parSCinit != "")
+    {
+      TFile inparam(parSCinit);
+      super.Read("MSupercuts");
+      inparam.Close();
+      *fLog << "MFindSupercutsONOFF::FindParams; initial values of parameters are taken from file "
+            << parSCinit << endl;
+    }
+
+    // take initial values from 'params' and/or 'steps'
+    else if (params.GetSize() != 0  || steps.GetSize()  != 0 )
+    {
+	if (params.GetSize()  != 0)
+	{
+	    *fLog << "MFindSupercutsONOFF::FindParams; initial values of parameters are taken from 'params'"
+		  << endl;
+	    super.SetParameters(params);
+	}
+	if (steps.GetSize()  != 0)
+	{
+	    *fLog << "MFindSupercutsONOFF::FindParams; initial step sizes are taken from 'steps'"
+		  << endl;
+	    super.SetStepsizes(steps);
+	}
+	
+	/*
+	// TMP
+	// Print parameters
+	if (params.GetSize() == steps.GetSize())
+	{
+	    *fLog << "MFindSupercutsONOFF; SC parameters and Setps are: " << endl;
+	    for (Int_t z = 0; z < params.GetSize(); z++)
+	    {
+		cout << params[z] << setw(20) << steps[z] << endl;
+	    }
+	}
+
+	// ENDTMP
+
+	*/
+
+	/*
+	// TMP2
+
+	TArrayD paramsBis = super.GetParameters();
+	TArrayD stepsBis = super.GetStepsizes();
+	if (paramsBis.GetSize() == stepsBis.GetSize())
+	{
+	    *fLog << "MFindSupercutsONOFF; SC parametersBis and SetpsBis are: " << endl;
+	    for (Int_t z = 0; z < paramsBis.GetSize(); z++)
+	    {
+		cout << paramsBis[z] << setw(20) << stepsBis[z] << endl;
+	    }
+	}
+	
+	// ENDTMP2
+	*/
+
+	else
+	{
+	    *fLog << "MFindSupercutsONOFF; ERROR: params.GetSize() != steps.GetSize() " 
+		  << endl;
+	    
+	}
+
+
+
+    }
+    else
+    {
+        *fLog << "MFindSupercutsONOFF::FindParams; initial values and step sizes are taken from the MSupercuts constructor"
+              << endl;
+    }
+
+
+    // Computation of fNormFactorTrain and creation of a container for 
+    // storing this value and include it  in the MParList for being 
+    // used by function fcnSupercuts
+
+    if (!ComputeNormFactorTrain())
+    {
+	*fLog << "Normalization factor for train sample (ON-OFF) could not be computed. Aborting..." << endl;
+	return kFALSE;
+    }
+
+    
+    *fLog << "MFindSupercutsONOFF::FindParams; fNormFactorTrain = " << fNormFactorTrain << endl;
+
+    
+
+    MDataValue NormFactorCont(fNormFactorTrain);
+    NormFactorCont.SetName("NormFactorTrain");
+                                 
+
+    // Value of fAlphaSig, fAlphaBkgMin and fAlphaBkgMax 
+    // are stored in MDataValue containers,
+    // then they will be passed to the MParList and will be 
+    // accessible to fcnsupercuts
+
+    MDataValue AlphaSigCont(fAlphaSig);
+    AlphaSigCont.SetName("AlphaSigValue");
+
+    MDataValue AlphaBkgMinCont(fAlphaBkgMin);
+    AlphaBkgMinCont.SetName("AlphaBkgMinValue");
+
+    MDataValue AlphaBkgMaxCont(fAlphaBkgMax);
+    AlphaBkgMaxCont.SetName("AlphaBkgMaxValue");
+    
+    
+    // Value of fUseFittedQuantities is stored in container 
+    // and passed to the MParList and will be 
+    // accessible to fcnsupercuts
+
+    
+
+    MDataValue UseFittedQuantitiesCont(fUseFittedQuantities);
+    UseFittedQuantitiesCont.SetName("UseFittedQuantitiesValue");
+
+
+     // Value of fNormFactorFromAlphaBkg is stored in container 
+    // and passed to the MParList and will be 
+    // accessible to fcnsupercuts
+
+    MDataValue UseNormFactorFromAlphaBkgCont(fNormFactorFromAlphaBkg);
+    UseNormFactorFromAlphaBkgCont.SetName("UseNormFactorFromAlphaBkgValue");
+
+
+
+    // A vector of pointers to objects of the class MEvtLoop is defined.
+    // One of the pointed loops will be used to compute ON data alpha plot
+    // and the other for computing OFF data alpha plot.
+
+    MEvtLoop evtloopfcn[2] = {MEvtLoop("ONDataEvtLoopFCN"), 
+			      MEvtLoop("OFFDataEvtLoopFCN")};
+
+
+
+
+    // ******************************************************************
+    // EVENT LOOP FOR COMPUTING ALPHA HISTOGRAM FOR ON DATA IS SET
+    // ******************************************************************
+
+    // -----------------------------------------------------------------
+
+    MParList  parlistfcn;
+    MTaskList tasklistfcn;
+
+    // loop over rows of matrix
+    MMatrixLoop loop(fMatrixTrain);
+
+
+    //--------------------------------
+    // calculate supercuts hadronness
+    fCalcHadTrain->SetHadronnessName(fHadronnessName);
+
+    // Boolean variable that controls in class MSupercutsCalcONOFF
+    // wether the supercuts are stored or not
+    // is set to the default value, kFALSE. (no storage of supercuts)
+
+    fCalcHadTrain -> SetStoreAppliedSupercuts(kFALSE);
+
+
+    
+    // Set boolean variable that controls wether cuts are 
+    // dynamic or static
+
+    fCalcHadTrain -> SetVariableUseStaticCuts(fUseStaticCuts);
+
+    if (!fUseStaticCuts)
+    {
+	// Set boolean variable that controls wether the theta variable 
+	// is used or not in the computation of the dynamical cuts
+	
+	fCalcHadTrain -> SetVariableNotUseTheta(fNotUseTheta);
+    }
+
+    // apply the supercuts
+    MF scfilter(fHadronnessName+".fHadronness>0.5");
+    MContinue supercuts(&scfilter);
+
+    // plot |alpha|
+    const TString  mh3Name = "AlphaFcn";
+    MBinning binsalpha("Binning"+mh3Name);
+    //binsalpha.SetEdges(54, -12.0, 96.0);
+    binsalpha.SetEdges(fNAlphaBins, fAlphaBinLow, fAlphaBinUp);
+     
+     
+    *fLog << warn << "WARNING------------>ALPHA IS ASSUMED TO BE IN COLUMN 7!!!!!!!!" << endl;
+
+    // |alpha| is assumed to be in column 7 of the matrix
+    MH3 alpha("MatrixTrain[7]");
+    alpha.SetName(mh3Name);
+
+    MFillH fillalpha(&alpha);
+
+    // book histograms to be filled during the optimization
+    //                              ! not in the event loop !
+    MHCT1Supercuts plotsuper;
+    plotsuper.SetupFill(&parlistfcn);
+
+    //******************************
+    // entries in MParList (extension of old MParList)
+    
+    parlistfcn.AddToList(&tasklistfcn);
+    parlistfcn.AddToList(&super);
+    parlistfcn.AddToList(&NormFactorCont);
+    parlistfcn.AddToList(&AlphaSigCont);
+    parlistfcn.AddToList(&AlphaBkgMinCont);
+    parlistfcn.AddToList(&AlphaBkgMaxCont);
+    parlistfcn.AddToList(&UseFittedQuantitiesCont);
+    parlistfcn.AddToList(&UseNormFactorFromAlphaBkgCont);
+
+    parlistfcn.AddToList(fCam);
+    parlistfcn.AddToList(fMatrixTrain);
+
+    parlistfcn.AddToList(&binsalpha);
+    parlistfcn.AddToList(&alpha);
+
+    parlistfcn.AddToList(&plotsuper);
+
+    //******************************
+    // entries in MTaskList
+
+    tasklistfcn.AddToList(&loop);
+    tasklistfcn.AddToList(fCalcHadTrain);
+    tasklistfcn.AddToList(&supercuts);
+    tasklistfcn.AddToList(&fillalpha);
+
+    //******************************
+
+
+    // &evtloopfcn[0] = new MEvtLoop("ONDataEvtLoopFCN");
+    evtloopfcn[0].SetParList(&parlistfcn);
+    // MEvtLoop evtloopfcn("EvtLoopFCN");
+    // evtloopfcn.SetParList(&parlistfcn);
+    *fLog << "Event loop for computing ON data alpha histo in fcnSupercuts has been setup" << endl;
+
+
+//---- End of setting of loop for compuing ON data alpha plot ---------------
+
+    
+
+     // ******************************************************************
+    // EVENT LOOP FOR COMPUTING ALPHA HISTOGRAM FOR OFF DATA IS SET
+    // ******************************************************************
+
+    // -----------------------------------------------------------------
+
+    MParList  parlistfcnOFF;
+    MTaskList tasklistfcnOFF;
+
+    // loop over rows of matrix
+    MMatrixLoop loopOFF(fMatrixTrainOFF);
+
+
+    //--------------------------------
+    // calculate supercuts hadronness
+    fCalcHadTrainOFF->SetHadronnessName(fHadronnessNameOFF);
+
+
+    // Boolean variable that controls in class MSupercutsCalcONOFF
+    // wether the supercuts are stored or not
+    // is set to the default value, kFALSE. (no storage of supercuts)
+
+    fCalcHadTrainOFF -> SetStoreAppliedSupercuts(kFALSE);
+
+
+    
+    // Set boolean variable that controls wether cuts are 
+    // dynamic or static
+
+    fCalcHadTrainOFF -> SetVariableUseStaticCuts(fUseStaticCuts);
+
+
+    if (!fUseStaticCuts)
+    {
+	// Set boolean variable that controls wether the theta variable 
+	// is used or not in the computation of the dynamica cuts
+	
+	fCalcHadTrainOFF -> SetVariableNotUseTheta(fNotUseTheta);
+    }
+
+    // apply the supercuts
+    MF scfilterOFF(fHadronnessNameOFF+".fHadronness>0.5");
+    MContinue supercutsOFF(&scfilterOFF);
+
+    // plot |alpha|
+    const TString  mh3NameOFF = "AlphaOFFFcn";
+    MBinning binsalphaOFF("Binning"+mh3NameOFF);
+    //binsalphaOFF.SetEdges(54, -12.0, 96.0);
+    binsalphaOFF.SetEdges(fNAlphaBins, fAlphaBinLow, fAlphaBinUp);
+
+
+    *fLog << warn << "WARNING------------>ALPHA IS ASSUMED TO BE IN COLUMN 7!!!!!!!!" << endl;
+
+    // |alpha| is assumed to be in column 7 of the matrix
+    MH3 alphaOFF("MatrixTrainOFF[7]");
+    alphaOFF.SetName(mh3NameOFF);
+
+    MFillH fillalphaOFF(&alphaOFF);
+
+    
+
+    //******************************
+    // entries in MParList (extension of old MParList)
+    
+    parlistfcnOFF.AddToList(&tasklistfcnOFF);
+    parlistfcnOFF.AddToList(&super);
+    parlistfcnOFF.AddToList(fCam);
+    parlistfcnOFF.AddToList(fMatrixTrainOFF);
+
+    parlistfcnOFF.AddToList(&binsalphaOFF);
+    parlistfcnOFF.AddToList(&alphaOFF);
+
+    
+
+    //******************************
+    // entries in MTaskList
+
+    tasklistfcnOFF.AddToList(&loopOFF);
+    tasklistfcnOFF.AddToList(fCalcHadTrainOFF);
+    tasklistfcnOFF.AddToList(&supercutsOFF);
+    tasklistfcnOFF.AddToList(&fillalphaOFF);
+
+    //******************************
+
+
+    // &evtloopfcn[1] = new MEvtLoop("OFFDataEvtLoopFCN");
+    evtloopfcn[1].SetParList(&parlistfcnOFF);
+    // MEvtLoop evtloopfcn("EvtLoopFCN");
+    // evtloopfcn.SetParList(&parlistfcn);
+    *fLog << "Event loop for computing OFF data alpha histo in fcnSupercuts has been setup" << endl;
+
+
+//---- End of setting of loop for compuing OFF data alpha plot ---------------
+
+
+    // address of evtloopfcn is used in CallMinuit()
+
+
+    //-----------------------------------------------------------------------
+    //
+    //----------   Start of minimization part   --------------------
+    //
+    // Do the minimization with MINUIT
+    //
+    // Be careful: This is not thread safe
+    //
+    *fLog << "========================================================" << endl;
+    *fLog << "Start minimization for supercuts" << endl;
+
+
+    // -------------------------------------------
+    // prepare call to MINUIT
+    //
+
+    // get initial values of parameters 
+    fVinit = super.GetParameters();
+    fStep  = super.GetStepsizes();
+
+    TString name[fVinit.GetSize()];
+    fStep.Set(fVinit.GetSize());
+    fLimlo.Set(fVinit.GetSize());
+    fLimup.Set(fVinit.GetSize());
+    fFix.Set(fVinit.GetSize());
+
+    fNpar = fVinit.GetSize();
+
+    for (UInt_t i=0; i<fNpar; i++)
+    {
+        name[i]   = "p";
+        name[i]  += i+1;
+        //fStep[i]  = TMath::Abs(fVinit[i]/10.0);
+        fLimlo[i] = -100.0;
+        fLimup[i] =  100.0;
+        fFix[i]   =     0;
+    }
+
+
+    
+
+
+    if(fSetLimitsToSomeMinuitParams)
+      {
+
+	// Limits for some Minuit parameters are set. For the time being the values are set in the constructor 
+	// of the class. One MUST be very careful to set limits such that the expected final values 
+	// (optimized values) are far away from the limits.
+	// Limits are set to those Minuit parameters not depending in Size,dist and theta (static values). 
+	// Limits are set only to Dist, Length and Width.
+
+	
+	*fLog << endl 
+	      <<"Limits set to hillas parameters Length, Width, Dist and Leakage1 for the optimization with Minuit." 
+	      << endl;
+	
+
+	
+	fLimup[0] = fMinuitLengthUPUpperLimit;
+	fLimlo[0] = fMinuitLengthUPLowerLimit;
+	fLimup[8] = fMinuitLengthLOWUpperLimit;
+	fLimlo[8] = fMinuitLengthLOWLowerLimit;
+	fLimup[16] = fMinuitWidthUPUpperLimit;
+	fLimlo[16] = fMinuitWidthUPLowerLimit;
+	fLimup[24] = fMinuitWidthLOWUpperLimit;
+	fLimlo[24] = fMinuitWidthLOWLowerLimit;
+	fLimup[32] = fMinuitDistUPUpperLimit;
+	fLimlo[32] = fMinuitDistUPLowerLimit;
+	fLimup[40] = fMinuitDistLOWUpperLimit;
+	fLimlo[40] = fMinuitDistLOWLowerLimit;
+
+	fLimup[80] = fMinuitLeakage1UPUpperLimit;
+	fLimlo[80] = fMinuitLeakage1UPLowerLimit;
+
+	
+
+      }
+    
+   
+
+    // Wolfgang sets manyally some parameters.
+    // That might give an error if parameters are changed...
+    // To be changed in future...
+
+    // these parameters make no sense, fix them at 0.0
+    fVinit[33] = 0.0;
+    fStep[33]  = 0.0;
+    fFix[33]   = 1;
+
+    fVinit[36] = 0.0;
+    fStep[36]  = 0.0;
+    fFix[36]   = 1;
+
+    fVinit[39] = 0.0;
+    fStep[39]  = 0.0;
+    fFix[39]   = 1;
+
+    fVinit[41] = 0.0;
+    fStep[41]  = 0.0;
+    fFix[41]   = 1;
+
+    fVinit[44] = 0.0;
+    fStep[44]  = 0.0;
+    fFix[44]   = 1;
+
+    fVinit[47] = 0.0;
+    fStep[47]  = 0.0;
+    fFix[47]   = 1;
+
+
+   
+    // ADDITIONAL PARAMETERS ARE FIXED ACCORDING TO THE 
+    // VALUES OF THE BOOLEAN VARIABLES fUseStaticCuts, AND
+    // fNotUseTheta
+
+
+    if (fUseStaticCuts)
+    {    
+        // Static cuts will be used; all parameters with index 
+	// 1-7 are fixed for ALL variables (width, length, ...)
+	
+       for (UInt_t i=0; i<fNpar; i = i+8)
+       {
+	   // At some point, the number of paraemters in the 
+	   // dynamical cuts parameterezattion (currently 7) 
+           // will become a variable that can be set from 
+	   // outside the class
+
+	   for (UInt_t j=i+1; j<=i+7; j++)
+	   {
+	       fVinit[j] = 0.0;
+	       fStep[j]  = 0.0;
+	       fFix[j]   = 1;
+	   }
+       }
+    }
+    else
+    {
+	if(fNotUseTheta)
+	{
+	    // Theta is not used in the parameterization of the dynamical cut
+	    // Parameters with index 2 and 5 are fixed for all variables 
+	    // (width, length, ...)
+
+	    for (UInt_t i=0; i<fNpar; i = i+8)
+	    {
+		// At some point, the number of paraemters in the 
+		// dynamical cuts parameterezattion (currently 7) 
+		// will become a variable that can be set from 
+		// outside the class
+		
+		for (UInt_t j=i+2; j<=i+7; j = j+3)
+		{
+		    fVinit[j] = 0.0;
+		    fStep[j]  = 0.0;
+		    fFix[j]   = 1;
+		}
+	    }
+
+
+	}
+
+	if(!fUseDist)
+	  {
+	    // parameterization using dist is removed
+	    // Parameters with index 1 and 4 and 7 are fixed for all variables 
+	    // (width, length, ...)
+	     for (UInt_t i=0; i<fNpar; i = i+8)
+	    {
+		// At some point, the number of paraemters in the 
+		// dynamical cuts parameterezattion (currently 7) 
+		// will become a variable that can be set from 
+		// outside the class
+		
+		for (UInt_t j=i+1; j<=i+7; j = j+3)
+		{
+		    fVinit[j] = 0.0;
+		    fStep[j]  = 0.0;
+		    fFix[j]   = 1;
+		}
+	    }
+
+
+
+	  }
+
+
+
+
+    }
+
+
+
+
+
+
+    // vary only first 48 parameters
+    //for (UInt_t i=0; i<fNpar; i++)
+    //{
+    //    if (i >= 48)
+    //	{
+    //      fStep[i] = 0.0;
+    //      fFix[i]  =   1;
+    //	}
+    //}
+ 
+    // -------------------------------------------
+    // call MINUIT
+    
+    Bool_t rc;
+
+    if(fSkipOptimization)
+    {
+	*fLog << "Parameter optimization is skipped. Using previously optimized parameters."
+	      << endl;
+	
+
+	rc = kTRUE;
+	
+
+	if(fUseInitialSCParams)
+	{
+
+	    // write Initial parameter values onto root file filenameParam
+	    // so that later they can be applied on the data
+
+	     *fLog << "Initial SC parameter values are written onto file '"
+		  << fFilenameParam << "' :" << endl;
+
+	    
+	    TFile outparam(fFilenameParam, "RECREATE"); 
+	    super.Write();
+	    outparam.Close();
+	    
+
+	    
+	     const TArrayD &check = super.GetParameters();
+	    for (Int_t i=0; i<check.GetSize(); i++)
+		*fLog << check[i] << ",  ";
+	    *fLog << endl;
+
+	
+	}
+
+
+    }
+    else
+    {
+	TStopwatch clock;
+	clock.Start();
+	
+	*fLog << "before calling CallMinuit" << endl;
+    
+	MMinuitInterface inter;               
+	rc = inter.CallMinuit(fcnSupercuts, name,
+			      fVinit, fStep, fLimlo, fLimup, fFix,
+			      evtloopfcn, "SIMPLEX", kFALSE);
+	
+	*fLog << "after calling CallMinuit" << endl;
+	
+	*fLog << "Time spent for the minimization in MINUIT :   " << endl;;
+	clock.Stop();
+	clock.Print();
+
+	// plotsuper.DrawClone();
+
+	if (!rc)
+	{
+	    *fLog << "*************  ERROR !!! *********************" << endl
+		  << "Minimization could not finish properly..." << endl
+		  << "MMinuitInterface.CallMinuit() returned kFALSE" << endl;
+	    return kFALSE;
+	}
+	
+	
+	
+	
+	*fLog << "Minimization for supercuts finished" << endl;
+	*fLog << "========================================================" << endl;
+	
+	
+	// -----------------------------------------------------------------
+	// in 'fcnSupercuts' (IFLAG=3) the optimum parameter values were put 
+	//                    into MSupercuts
+	
+	// write optimum parameter values onto file filenameParam
+	
+	TFile outparam(fFilenameParam, "RECREATE"); 
+	super.Write();
+	outparam.Close();
+	
+	*fLog << "Optimum parameter values for supercuts were written onto file '"
+	      << fFilenameParam << "' :" << endl;
+    
+	const TArrayD &check = super.GetParameters();
+	for (Int_t i=0; i<check.GetSize(); i++)
+	    *fLog << check[i] << ",  ";
+	*fLog << endl;
+	
+	
+	
+	
+    }
+    
+	
+    
+    
+    
+    *fLog << "End of  supercuts optimization part" << endl;
+    *fLog << "======================================================" << endl;
+    
+    
+    *fLog << "Applying the optimized supercuts on the TRAIN sample and " 
+	  << "producing plots related to the output results" << endl;
+
+    *fLog << "======================================================" << endl;
+    
+    if (!TestParamsOnTrainSample())
+    {
+	*fLog << "MFindSupercutsONOFF::FindParams;" 
+	      << "TestParamsOnTrainSample failed"
+	      << endl;
+	
+	return kFALSE;
+    }
+    
+    
+    
+    return kTRUE;
+}
+
+
+
+
+
+
+
+// -----------------------------------------------------------------------
+//
+// Test the supercuts on the test sample using ON and OFF data
+// 2 loops are used to fill the 2 alpha distributions
+// Supercuts applied (LengthUp, LengthLow...) 
+// to all the individual events, as well as 
+// the features of the shower images (Length,Width...) are 
+// stored in 2 TTree objects (for ON and OFF data) in the 
+// root file specified by variable "fAlphaDistributionsRootFilename"
+
+
+
+Bool_t MFindSupercutsONOFF::TestParamsOnTestSample()
+{
+    if (fMatrixTest->GetM().GetNrows() <= 0)
+    {
+        *fLog << "MFindSupercutsONOFF::TestParamsOnTestSample; test matrix ON has no entries" 
+              << endl;
+        return kFALSE;
+    }
+
+
+    if (fMatrixTestOFF->GetM().GetNrows() <= 0)
+    {
+        *fLog << "MFindSupercutsONOFF::TestParamsOnTestSample; test matrix OFF has no entries" 
+              << endl;
+        return kFALSE;
+    }
+
+    // -------------   TEST the supercuts    ------------------------------
+    //
+    *fLog << "Test the supercuts on the test sample ON and OFF" << endl;
+
+    // -----------------------------------------------------------------
+    // read optimum parameter values from file filenameParam
+    // into array 'supercutsPar'
+
+    TFile inparam(fFilenameParam);
+    MSupercuts scin; 
+    scin.Read("MSupercuts");
+    inparam.Close();
+
+    *fLog << "Optimum parameter values for supercuts were read from file '";
+    *fLog << fFilenameParam << "' :" << endl;
+
+    const TArrayD &supercutsPar = scin.GetParameters();
+    for (Int_t i=0; i<supercutsPar.GetSize(); i++)
+        *fLog << supercutsPar[i] << ",  ";
+    *fLog << endl;
+    //---------------------------
+
+
+    // -----------------------------------------------------------------
+    if (fHadronnessName.IsNull())
+    {
+        *fLog << "MFindSupercutsONOFF::TestParamsONOFF; hadronness name for ON data is not defined... aborting";
+        *fLog << endl;
+        return kFALSE;
+    }
+
+    if (fHadronnessNameOFF.IsNull())
+    {
+        *fLog << "MFindSupercutsONOFF::TestParamsONOFF; hadronness name for OFF data is not defined... aborting";
+        *fLog << endl;
+        return kFALSE;
+    }
+
+    if(fTestONSupercutsAppliedName.IsNull())
+    {
+        *fLog << "MFindSupercutsONOFF::TestParamsONOFF; " 
+	      << " MTSupercutsApplied tree name for ON Test data is not defined... aborting"
+	      << endl;
+        return kFALSE;
+    }
+
+    if(fTestOFFSupercutsAppliedName.IsNull())
+    {
+        *fLog << "MFindSupercutsONOFF::TestParamsONOFF; " 
+	      << " MTSupercutsApplied container name for OFF Test data is not defined... aborting"
+	      << endl;
+        return kFALSE;
+    }
+    
+
+    MSupercuts supercuts;
+    supercuts.SetParameters(supercutsPar);
+
+    // Objects containing the trees used to store supercuts applied
+    // TTree Branches are also created
+    MTSupercutsApplied supapptestON(fTestONSupercutsAppliedName.Data(), "");
+    supapptestON.CreateTreeBranches();
+
+    MTSupercutsApplied supapptestOFF(fTestOFFSupercutsAppliedName.Data(), "");
+    supapptestOFF.CreateTreeBranches();
+
+    
+
+    
+    fCalcHadTestOFF -> SetHadronnessName(fHadronnessNameOFF);
+    fCalcHadTest -> SetHadronnessName(fHadronnessName);
+
+
+    // Settings related to the storage of teh supercuts applied 
+    fCalcHadTest -> SetSupercutsAppliedName(fTestONSupercutsAppliedName);
+    fCalcHadTest -> SetStoreAppliedSupercuts(kTRUE);
+
+    fCalcHadTestOFF -> SetSupercutsAppliedName(fTestOFFSupercutsAppliedName);
+    fCalcHadTestOFF -> SetStoreAppliedSupercuts(kTRUE);
+    
+
+
+    // Set boolean variable that controls wether cuts are 
+    // dynamic or static
+
+    fCalcHadTest -> SetVariableUseStaticCuts(fUseStaticCuts);
+    fCalcHadTestOFF -> SetVariableUseStaticCuts(fUseStaticCuts);
+
+    if (!fUseStaticCuts)
+    {
+	// Set boolean variable that controls wether the theta variable 
+	// is used or not in the computation of the dynamical cuts
+	
+	fCalcHadTest -> SetVariableNotUseTheta(fNotUseTheta);
+	fCalcHadTestOFF -> SetVariableNotUseTheta(fNotUseTheta);
+    }
+
+
+     // apply the supercuts to OFF data
+
+    MF scfilterOFF(fHadronnessNameOFF+".fHadronness>0.5");
+    MContinue applysupercutsOFF(&scfilterOFF);
+
+
+     // apply the supercuts to ON data
+    MF scfilter(fHadronnessName+".fHadronness>0.5");
+    MContinue applysupercuts(&scfilter);
+
+   
+
+    // ****************************************************
+    // Filling OFF alpha distribution 
+
+    MParList parlistOFF;
+    MTaskList tasklistOFF;
+
+    MMatrixLoop loopOFF(fMatrixTestOFF);
+
+    // plot alpha before applying the supercuts
+    const TString  mh3NameOFFB = "AlphaOFFBefore";
+    MBinning binsalphaOFFbef("Binning"+mh3NameOFFB);
+    // binsalphaOFFbef.SetEdges(54, -12.0, 96.0);
+    binsalphaOFFbef.SetEdges(fNAlphaBins, fAlphaBinLow, fAlphaBinUp);
+
+    // |alpha| is assumed to be in column 7 of the matrix
+    MH3 alphaOFFbefore("MatrixTestOFF[7]");
+    alphaOFFbefore.SetName(mh3NameOFFB);
+
+
+    MFillH fillalphaOFFbefore(&alphaOFFbefore);
+    fillalphaOFFbefore.SetName("FillAlphaOFFBefore");
+
+   
+
+    // plot alpha OFF after applying the supercuts
+    const TString  mh3NameOFFA = "AlphaOFFAfter";
+    MBinning binsalphaOFFaft("Binning"+mh3NameOFFA);
+    // binsalphaOFFaft.SetEdges(54, -12.0, 96.0);
+    binsalphaOFFaft.SetEdges(fNAlphaBins, fAlphaBinLow, fAlphaBinUp);
+    
+    MH3 alphaOFFafter("MatrixTestOFF[7]");
+    alphaOFFafter.SetName(mh3NameOFFA);
+
+
+    MFillH fillalphaOFFafter(&alphaOFFafter);
+    fillalphaOFFafter.SetName("FillAlphaOFFAfter");
+
+    //******************************
+    // entries in MParList
+
+    parlistOFF.AddToList(&tasklistOFF);
+
+    parlistOFF.AddToList(&supercuts);
+
+    parlistOFF.AddToList(&supapptestOFF);
+
+    parlistOFF.AddToList(fCam);
+    parlistOFF.AddToList(fMatrixTestOFF);
+
+    parlistOFF.AddToList(&binsalphaOFFbef);
+    parlistOFF.AddToList(&alphaOFFbefore);
+
+    parlistOFF.AddToList(&binsalphaOFFaft);
+    parlistOFF.AddToList(&alphaOFFafter);
+
+
+    //******************************
+    // Entries in MtaskList
+    tasklistOFF.AddToList(&loopOFF);
+    tasklistOFF.AddToList(&fillalphaOFFbefore);
+
+    tasklistOFF.AddToList(fCalcHadTestOFF);
+    tasklistOFF.AddToList(&applysupercutsOFF);
+
+    tasklistOFF.AddToList(&fillalphaOFFafter);
+
+    //******************************
+
+    MProgressBar barOFF;
+    MEvtLoop evtloopOFF;
+    evtloopOFF.SetParList(&parlistOFF);
+    evtloopOFF.SetName("EvtLoopTestParamsOFF");
+    evtloopOFF.SetProgressBar(&barOFF);
+    Int_t maxeventsOFF = -1;
+    if (!evtloopOFF.Eventloop(maxeventsOFF))
+        return kFALSE;
+
+    tasklistOFF.PrintStatistics(0, kTRUE);
+
+
+    //-------------------------------------------
+    // draw the alpha plots
+
+    MH3* alphaOFFBefore = (MH3*)parlistOFF.FindObject(mh3NameOFFB, "MH3");
+    TH1  &alphaOFFHistb = alphaOFFBefore->GetHist();
+    TString alphaOFFHistbName ("TestAlphaOFFBeforeCuts");
+    
+    if (fThetaRangeString.IsNull())
+    {
+	*fLog << "MFindSupercutsONOFF::TestParamsOnTestSample; "
+	      << " fThetaRangeString is NOT defined..." << endl;
+	alphaOFFHistbName += ("ThetaRangeStringUndefined");
+    }
+    else
+    {
+	alphaOFFHistbName += (fThetaRangeString);
+    }
+
+
+    alphaOFFHistb.SetXTitle("|\\alpha|  [\\circ]");
+    alphaOFFHistb.SetName(alphaOFFHistbName);
+
+
+    MH3* alphaOFFAfter = (MH3*)parlistOFF.FindObject(mh3NameOFFA, "MH3");
+    TH1  &alphaOFFHista = alphaOFFAfter->GetHist();
+    TString alphaOFFHistaName ("TestAlphaOFFAfterCuts");
+
+    if (fThetaRangeString.IsNull())
+    {
+	*fLog << "MFindSupercutsONOFF::TestParamsOnTestSample; "
+	      << " fThetaRangeString is NOT defined..." << endl;
+	alphaOFFHistaName += ("ThetaRangeStringUndefined");
+    }
+    else
+    {
+	alphaOFFHistaName += (fThetaRangeString);
+    }
+
+
+    alphaOFFHista.SetXTitle("|\\alpha|  [\\circ]");
+    alphaOFFHista.SetName(alphaOFFHistaName);
+
+    
+
+
+
+    // *****************************************************
+
+
+
+    //-------------------------------------------
+
+
+    MParList  parlist2;
+    MTaskList tasklist2;
+
+    MMatrixLoop loop(fMatrixTest);
+
+    // plot alpha before applying the supercuts
+    const TString  mh3NameB = "AlphaBefore";
+    MBinning binsalphabef("Binning"+mh3NameB);
+    //binsalphabef.SetEdges(54, -12.0, 96.0);
+    binsalphabef.SetEdges(fNAlphaBins, fAlphaBinLow, fAlphaBinUp);
+    
+    // |alpha| is assumed to be in column 7 of the matrix
+    MH3 alphabefore("MatrixTest[7]");
+    alphabefore.SetName(mh3NameB);
+
+
+    MFillH fillalphabefore(&alphabefore);
+    fillalphabefore.SetName("FillAlphaBefore");
+
+
+    // plot alpha after applying the supercuts
+    const TString  mh3NameA = "AlphaAfter";
+    MBinning binsalphaaft("Binning"+mh3NameA);
+    // binsalphaaft.SetEdges(54, -12.0, 96.0);
+    binsalphaaft.SetEdges(fNAlphaBins, fAlphaBinLow, fAlphaBinUp);
+
+    MH3 alphaafter("MatrixTest[7]");
+    alphaafter.SetName(mh3NameA);
+
+
+    MFillH fillalphaafter(&alphaafter);
+    fillalphaafter.SetName("FillAlphaAfter");
+
+    //******************************
+    // entries in MParList
+
+    parlist2.AddToList(&tasklist2);
+
+    parlist2.AddToList(&supercuts);
+
+    parlist2.AddToList(&supapptestON);
+
+    parlist2.AddToList(fCam);
+    parlist2.AddToList(fMatrixTest);
+
+    parlist2.AddToList(&binsalphabef);
+    parlist2.AddToList(&alphabefore);
+
+    parlist2.AddToList(&binsalphaaft);
+    parlist2.AddToList(&alphaafter);
+
+    //******************************
+    // entries in MTaskList
+
+    tasklist2.AddToList(&loop);
+    tasklist2.AddToList(&fillalphabefore);
+
+    tasklist2.AddToList(fCalcHadTest);
+    tasklist2.AddToList(&applysupercuts);
+
+    tasklist2.AddToList(&fillalphaafter);
+
+    //******************************
+
+    MProgressBar bar2;
+    MEvtLoop evtloop2;
+    evtloop2.SetParList(&parlist2);
+    evtloop2.SetName("EvtLoopTestParams");
+    evtloop2.SetProgressBar(&bar2);
+    Int_t maxevents2 = -1;
+    if (!evtloop2.Eventloop(maxevents2))
+        return kFALSE;
+
+    tasklist2.PrintStatistics(0, kTRUE);
+
+
+    //-------------------------------------------
+    // draw the alpha plots
+
+    MH3* alphaBefore = (MH3*)parlist2.FindObject(mh3NameB, "MH3");
+    TH1  &alphaHist1 = alphaBefore->GetHist();
+    TString alphaHist1Name ("TestAlphaBeforeCuts");
+    
+    if (fThetaRangeString.IsNull())
+    {
+	*fLog << "MFindSupercutsONOFF::TestParamsOnTestSample; "
+	      << " fThetaRangeString is NOT defined..." << endl;
+	alphaHist1Name += ("ThetaRangeStringUndefined");
+    }
+    else
+    {
+	alphaHist1Name += (fThetaRangeString);
+    }
+
+
+
+
+    alphaHist1.SetName(alphaHist1Name);
+    alphaHist1.SetXTitle("|\\alpha|  [\\circ]");
+    
+
+
+    MH3* alphaAfter = (MH3*)parlist2.FindObject(mh3NameA, "MH3");
+    TH1  &alphaHist2 = alphaAfter->GetHist();
+    TString alphaHist2Name ("TestAlphaAfterCuts");
+    
+    
+    if (fThetaRangeString.IsNull())
+    {
+	*fLog << "MFindSupercutsONOFF::TestParamsOnTestSample; "
+	      << " fThetaRangeString is NOT defined..." << endl;
+	alphaHist2Name += ("ThetaRangeStringUndefined");
+    }
+    else
+    {
+	alphaHist2Name += (fThetaRangeString);
+    }
+
+    alphaHist2.SetXTitle("|\\alpha|  [\\circ]");
+    alphaHist2.SetName(alphaHist2Name);
+
+
+       
+    //fPsFilename  -> NewPage();
+
+
+    // Canvas is deleted after saving the plot in ps file
+    // This is to allow for GRID analysis
+
+    TCanvas *c = new TCanvas("TestAlphaBeforeAfterSC", 
+			     "TestAlphaBeforeAfterSC", 
+			     600, 600);
+    c->Divide(2,2);
+    
+    
+
+    c->cd(1);
+    alphaOFFHistb.DrawCopy();
+
+    c->cd(2);
+    alphaOFFHista.DrawCopy();
+    
+  
+
+    c->cd(3);
+    alphaHist1.DrawCopy();
+
+    c->cd(4);
+    alphaHist2.DrawCopy();
+
+    c->Modified();
+    c-> Update();
+
+
+    // ********************************************
+    // TMP solutions while the TPostScript thing is not working 
+    // PsFileName for storing these plots is derived 
+    // from PsFilenameString. 
+    
+
+    cout << "Alpha distributions will be saved in PostScript file  " ;
+
+
+    if (!fPsFilenameString.IsNull())
+    {
+	TString filename = (fPsFilenameString);
+	filename += ("AlphaTESTSampleONOFFBeforeAfterCuts.ps");
+	cout << filename << endl;	
+	c -> SaveAs(filename);
+    }
+
+    // END OF TEMPORAL SOLUTION
+    // ********************************************
+    
+    
+    // Canvas is deleted after saving the plot in ps file
+    // This is to allow for GRID analysis
+    delete c;
+
+    //-------------------------------------------
+    // fit alpha distribution to get the number of excess events and
+    // calculate significance of gamma signal in the alpha plot
+  
+    const Double_t alphasig = fAlphaSig;
+    const Double_t alphamin = fAlphaBkgMin; 
+   // alpha min for bkg region in ON data
+    
+    const Double_t alphamax = fAlphaBkgMax;
+    const Int_t    degree   =    2;
+    const Int_t    degreeOFF   =    2;
+    const Bool_t   drawpoly  = kTRUE;
+    const Bool_t   fitgauss  = kTRUE;
+    const Bool_t   print     = kTRUE;
+    
+    const Bool_t saveplots   = kTRUE; // Save plots in Psfile
+   
+     
+
+    if (!ComputeNormFactorTest())
+    {
+	*fLog << "Normalization factor for test sample (ON-OFF) couold not be computed. Aborting..." << endl;
+	return kFALSE;
+    }
+
+
+
+     // Normalization factor factor is corrected using the estimated 
+    // number of excess events and the total number of ON events
+
+
+ 
+    if (fTuneNormFactor)
+    {
+
+
+	// Run MHFindSignificanceONOFF::FindSigmaONOFF
+	// to get estimation of number of excess gamma events. 
+	// This number will be used in the correction of the 
+	// normalization factor 
+	
+	// No plots will be produced this time...
+
+	const Bool_t   drawpolyTest  = kFALSE;
+	const Bool_t   fitgaussTest  = kFALSE;
+	const Bool_t   printTest     = kFALSE;
+	
+	const Bool_t saveplotsTest   = kFALSE; // Save plots in Psfile
+	
+	// TPostScript* DummyPs  = new TPostScript("dummy.ps");
+
+	TString DummyPs = ("Dummy");
+
+	MHFindSignificanceONOFF findsigTest;
+	findsigTest.SetRebin(kTRUE);
+	findsigTest.SetReduceDegree(kFALSE);
+	findsigTest.SetUseFittedQuantities(fUseFittedQuantities);
+	
+
+	if (findsigTest.FindSigmaONOFF(&alphaHist2, &alphaOFFHista, 
+				       fNormFactorTest, 
+        			       alphamin, alphamax, 
+				       degree, degreeOFF,
+				       alphasig, drawpolyTest, 
+				       fitgaussTest, printTest, 
+				       saveplotsTest, DummyPs))
+	{
+	    
+	    // Update values of Nex and SigmaLiMa for Test sammple
+	
+	    fSigmaLiMaTest = double(findsigTest.GetSignificance());
+
+	    if(fUseFittedQuantities)
+	    {
+		fNexTest = double(findsigTest.GetNexONOFFFitted());
+	    }
+	    else
+	    {
+		fNexTest = double(findsigTest.GetNexONOFF());
+	    }
+
+
+	}
+	else
+	{
+
+	    *fLog << "Normalization Factor tuning for Train sample is not possible"
+		  << endl;
+	    fSigmaLiMaTest = 0.0;
+	    fNexTest = 0.0;
+	}
+    
+
+//	DummyPs -> Close();
+	//DummyPs = NULL;
+	//      delete DummyPs;
+
+	
+   
+	
+	
+	Int_t EventsInTestMatrixOFF = fMatrixTestOFF->GetM().GetNrows();
+	Double_t Ngammas = fNexTest/fGammaEfficiency;
+	Double_t GammaFraction = Ngammas/EventsInTestMatrixOFF;
+	
+	
+	*fLog << "MFindSupercutsONOFF::TestParamsOnTestSample; "
+	      << "fNormFactorTest is corrected with fraction of gammas in ON "
+	      << "Data Test sample and the number of OFF events before cuts." 
+	      << endl
+	      << "EventsInTestMatrixOFF = " << EventsInTestMatrixOFF
+	      << " Excess events in Test ON sample = " << fNexTest
+	      << " fGammaEfficiency = " << fGammaEfficiency << endl
+	      << "fNormFactorTest Value before correction is " 
+	      << fNormFactorTest << endl;
+	
+	fNormFactorTest = fNormFactorTest - GammaFraction;
+
+	*fLog << "fNormFactorTest Value after correction is "
+	      << fNormFactorTest << endl;
+	    
+
+    }
+    
+
+    
+   
+    if (fNormFactorFromAlphaBkg)
+    {
+	// Normalization factor computed using alpha bkg region
+	Double_t NewNormFactor = 
+	    ComputeNormFactorFromAlphaBkg(&alphaHist2, &alphaOFFHista, 
+					  fAlphaBkgMin, fAlphaBkgMax);
+	
+	*fLog << "Normalization factor computed from alpha plot (after cuts) " << endl
+	      << "using counted number of ON and OFF events in alpha region " << endl
+	      << "defined by range " << fAlphaBkgMin << "-" << fAlphaBkgMax << endl
+	      << "Normalization factor = " << NewNormFactor << endl;
+
+	*fLog << "Normalization factor used is the one computed in bkg region; " << endl
+	      << "i.e. " << NewNormFactor << " instead of " << fNormFactorTest << endl;
+
+	fNormFactorTest = NewNormFactor;
+
+
+    }
+
+
+
+    // Significance is found using MHFindSignificanceONOFF::FindSigmaONOFF
+
+
+    MHFindSignificanceONOFF findsig;
+    findsig.SetRebin(kTRUE);
+    findsig.SetReduceDegree(kFALSE);
+    findsig.SetUseFittedQuantities(fUseFittedQuantities);
+
+    TString psfilename; // Name of psfile where Alpha plot will be stored
+    if (!fPsFilenameString.IsNull())
+    {
+	psfilename += (fPsFilenameString);
+	psfilename += ("TESTSample"); 
+    }
+    else
+    {
+	psfilename += ("TESTSample");
+    }
+
+
+    findsig.FindSigmaONOFF(&alphaHist2, &alphaOFFHista, 
+			   fNormFactorTest, 
+			   alphamin, alphamax, 
+			   degree, degreeOFF,
+			   alphasig, drawpoly, fitgauss, print, 
+			   saveplots, psfilename);
+    
+    const Double_t significance = findsig.GetSignificance();
+    const Double_t alphasi = findsig.GetAlphasi();
+
+
+    // Update values of Nex and SigmaLiMa for Test sammple
+
+    fSigmaLiMaTest = double(findsig.GetSignificance());
+
+    if(fUseFittedQuantities)
+    {
+	fNexTest = double(findsig.GetNexONOFFFitted());
+    }
+    else
+    {
+	fNexTest = double(findsig.GetNexONOFF());
+    }
+
+
+    // Alpha distributions and containers with teh supercuts applied 
+    // are written into root file 
+
+    TFile rootfile(fAlphaDistributionsRootFilename, "UPDATE",
+		   "Alpha Distributions for several Theta bins");
+
+    alphaHist2.Write();
+    alphaOFFHista.Write();
+    
+    (supapptestON.GetTreePointer())->Write();
+    (supapptestOFF.GetTreePointer())->Write();
+
+    *fLog  << "TTree objects containing supercuts applied to TEST sample are "
+	   << "written into root file " << fAlphaDistributionsRootFilename << endl; 
+ 
+    (supapptestON.GetTreePointer())->Print();
+    (supapptestOFF.GetTreePointer())->Print();
+
+    //rootfile.Close();
+    
+
+    // Boolean variable that controls in class MSupercutsCalcONOFF
+    // wether the supercuts are stored or not
+    // is set to the default value, kFALSE.
+
+    fCalcHadTest -> SetStoreAppliedSupercuts(kFALSE);
+    fCalcHadTestOFF -> SetStoreAppliedSupercuts(kFALSE);
+
+
+
+    *fLog << "Significance of gamma signal after supercuts in Test sample : "
+         << significance << " (for |alpha| < " << alphasi << " degrees)" 
+         << endl;
+    //-------------------------------------------
+
+
+    *fLog << "Test of supercuts on TEST sample finished" << endl;
+    *fLog << "======================================================" << endl;
+
+    return kTRUE;
+}
+
+
+
+
+
+// Function that applies the optimized supercuts on the TEST sample.
+
+// Supercuts applied (LengthUp, LengthLow...) 
+// to all the individual events, as well as 
+// the features of the shower images (Length,Width...) are 
+// stored in 2 TTree objects (for ON and OFF data) in the 
+// root file specified by variable "fAlphaDistributionsRootFilename"
+
+
+Bool_t MFindSupercutsONOFF::TestParamsOnTrainSample()
+{
+    if (fMatrixTrain->GetM().GetNrows() <= 0)
+    {
+        *fLog << "MFindSupercutsONOFF::TestParamsOnTrainSample; train matrix ON has no entries" 
+              << endl;
+        return kFALSE;
+    }
+
+
+    if (fMatrixTrainOFF->GetM().GetNrows() <= 0)
+    {
+        *fLog << "MFindSupercutsONOFF::TestParamsOnTrainSample; train matrix OFF has no entries" 
+              << endl;
+        return kFALSE;
+    }
+
+    // -------------   TEST the supercuts on TRAIN sample  --------------------------
+    //
+    *fLog << "Producing output of the SUPERCUTS ON-OFF optimization " << endl;
+
+    // -----------------------------------------------------------------
+    // read optimum parameter values from file filenameParam
+    // into array 'supercutsPar'
+
+    TFile inparam(fFilenameParam);
+    MSupercuts scin; 
+    scin.Read("MSupercuts");
+    inparam.Close();
+
+    *fLog << "Optimum parameter values for supercuts were read from file '";
+    *fLog << fFilenameParam << "' :" << endl;
+
+    const TArrayD &supercutsPar = scin.GetParameters();
+    for (Int_t i=0; i<supercutsPar.GetSize(); i++)
+        *fLog << supercutsPar[i] << ",  ";
+    *fLog << endl;
+    //---------------------------
+
+
+    // -----------------------------------------------------------------
+    if (fHadronnessName.IsNull())
+    {
+        *fLog << "MFindSupercutsONOFF::TestParamsOnTrainSample; hadronness name for ON data is not defined... aborting";
+        *fLog << endl;
+        return kFALSE;
+    }
+
+    if (fHadronnessNameOFF.IsNull())
+    {
+        *fLog << "MFindSupercutsONOFF::TestParamsOnTrainSample; hadronness name for OFF data is not defined... aborting";
+        *fLog << endl;
+        return kFALSE;
+    }
+
+
+    if(fTrainONSupercutsAppliedName.IsNull())
+    {
+        *fLog << "MFindSupercutsONOFF::TestParamsOnTrainSample; " 
+	      << " MTSupercutsApplied Tree name for ON Train data is not defined... aborting"
+	      << endl;
+        return kFALSE;
+    }
+
+    if(fTrainOFFSupercutsAppliedName.IsNull())
+    {
+        *fLog << "MFindSupercutsONOFF::TestParamsOnTrainSample; " 
+	      << " MTSupercutsApplied Tree name for OFF Train data is not defined... aborting"
+	      << endl;
+        return kFALSE;
+    }
+    
+   
+    MSupercuts supercuts;
+    supercuts.SetParameters(supercutsPar);
+
+    // Objects containing the trees used to store supercuts applied
+    // TTree Branches are also created
+    MTSupercutsApplied supapptrainON(fTrainONSupercutsAppliedName,"");
+    supapptrainON.CreateTreeBranches();
+
+    MTSupercutsApplied supapptrainOFF(fTrainOFFSupercutsAppliedName,"");
+    supapptrainOFF.CreateTreeBranches();
+
+    fCalcHadTrainOFF -> SetHadronnessName(fHadronnessNameOFF);
+    fCalcHadTrain -> SetHadronnessName(fHadronnessName);
+
+
+    // Settings related to the storage of teh supercuts applied 
+    fCalcHadTrain -> SetSupercutsAppliedName(fTrainONSupercutsAppliedName);
+    fCalcHadTrain -> SetStoreAppliedSupercuts(kTRUE);
+
+    fCalcHadTrainOFF -> SetSupercutsAppliedName(fTrainOFFSupercutsAppliedName);
+    fCalcHadTrainOFF -> SetStoreAppliedSupercuts(kTRUE);
+    
+
+    // Set boolean variable that controls wether cuts are 
+    // dynamic or static
+
+    fCalcHadTrain -> SetVariableUseStaticCuts(fUseStaticCuts);
+    fCalcHadTrainOFF -> SetVariableUseStaticCuts(fUseStaticCuts);
+
+
+    if (!fUseStaticCuts)
+    {
+	// Set boolean variable that controls wether the theta variable 
+	// is used or not in the computation of the dynamical cuts
+	
+	fCalcHadTrain -> SetVariableNotUseTheta(fNotUseTheta);
+	fCalcHadTrainOFF -> SetVariableNotUseTheta(fNotUseTheta);
+    }
+
+
+    // apply the supercuts to OFF data
+
+    MF scfilterOFF(fHadronnessNameOFF+".fHadronness>0.5");
+    MContinue applysupercutsOFF(&scfilterOFF);
+
+     // apply the supercuts to ON data
+    MF scfilter(fHadronnessName+".fHadronness>0.5");
+    MContinue applysupercuts(&scfilter);
+
+    
+
+
+    // ****************************************************
+    // Filling OFF alpha distribution 
+
+    MParList parlistOFF;
+    MTaskList tasklistOFF;
+
+    MMatrixLoop loopOFF(fMatrixTrainOFF);
+
+    // plot alpha before applying the supercuts
+    const TString  mh3NameOFFB = "AlphaOFFBefore";
+    MBinning binsalphaOFFbef("Binning"+mh3NameOFFB);
+    //binsalphaOFFbef.SetEdges(54, -12.0, 96.0);
+    binsalphaOFFbef.SetEdges(fNAlphaBins, fAlphaBinLow, fAlphaBinUp);
+
+
+    // |alpha| is assumed to be in column 7 of the matrix
+    MH3 alphaOFFbefore("MatrixTrainOFF[7]");
+    alphaOFFbefore.SetName(mh3NameOFFB);
+
+    
+    MFillH fillalphaOFFbefore(&alphaOFFbefore);
+    fillalphaOFFbefore.SetName("FillAlphaOFFBefore");
+
+   
+
+    // fill OFF alpha after applying the supercuts
+    const TString  mh3NameOFFA = "AlphaOFFAfter";
+    MBinning binsalphaOFFaft("Binning"+mh3NameOFFA);
+    //binsalphaOFFaft.SetEdges(54, -12.0, 96.0);
+    binsalphaOFFaft.SetEdges(fNAlphaBins, fAlphaBinLow, fAlphaBinUp);
+
+    MH3 alphaOFFafter("MatrixTrainOFF[7]");
+    alphaOFFafter.SetName(mh3NameOFFA);
+
+    //TH1 &alphaOFFhista = alphaOFFafter.GetHist();
+    //alphaOFFhista.SetName("alphaOFFAfter-OptimizationParamOutput");
+
+    MFillH fillalphaOFFafter(&alphaOFFafter);
+    fillalphaOFFafter.SetName("FillAlphaOFFAfter");
+
+    //******************************
+    // entries in MParList
+
+    parlistOFF.AddToList(&tasklistOFF);
+
+    parlistOFF.AddToList(&supercuts);
+
+    parlistOFF.AddToList(&supapptrainOFF);
+
+    parlistOFF.AddToList(fCam);
+    parlistOFF.AddToList(fMatrixTrainOFF);
+
+    parlistOFF.AddToList(&binsalphaOFFbef);
+    parlistOFF.AddToList(&alphaOFFbefore);
+
+    parlistOFF.AddToList(&binsalphaOFFaft);
+    parlistOFF.AddToList(&alphaOFFafter);
+
+
+    //******************************
+    // Entries in MtaskList
+    tasklistOFF.AddToList(&loopOFF);
+    tasklistOFF.AddToList(&fillalphaOFFbefore);
+
+    tasklistOFF.AddToList(fCalcHadTrainOFF);
+    tasklistOFF.AddToList(&applysupercutsOFF);
+
+    tasklistOFF.AddToList(&fillalphaOFFafter);
+
+    //******************************
+
+    MProgressBar barOFF;
+    MEvtLoop evtloopOFF;
+    evtloopOFF.SetParList(&parlistOFF);
+    evtloopOFF.SetName("EvtLoopOptimizationParamOutputOFF");
+    evtloopOFF.SetProgressBar(&barOFF);
+    Int_t maxeventsOFF = -1;
+    if (!evtloopOFF.Eventloop(maxeventsOFF))
+        return kFALSE;
+
+    tasklistOFF.PrintStatistics(0, kTRUE);
+
+
+    //-------------------------------------------
+    // draw the alpha plots
+
+    MH3* alphaOFFBefore = (MH3*)parlistOFF.FindObject(mh3NameOFFB, "MH3");
+    TH1  &alphaOFFHistb = alphaOFFBefore->GetHist();
+    alphaOFFHistb.SetXTitle("|\\alpha|  [\\circ]");
+
+    TString alphaOFFHistbName ("TrainAlphaOFFBeforeCuts");
+    if (fThetaRangeString.IsNull())
+    {
+	*fLog << "MFindSupercutsONOFF::TestParamsOnTrainSample; "
+	      << " fThetaRangeString is NOT defined..." << endl;
+	alphaOFFHistbName += ("ThetaRangeStringUndefined");
+    }
+    else
+    {
+	alphaOFFHistbName += (fThetaRangeString);
+    }
+
+    alphaOFFHistb.SetName(alphaOFFHistbName);
+
+    MH3* alphaOFFAfter = (MH3*)parlistOFF.FindObject(mh3NameOFFA, "MH3");
+    TH1  &alphaOFFHista = alphaOFFAfter->GetHist();
+    TString alphaOFFHistaName ("TrainAlphaOFFAfterCuts");
+    if (fThetaRangeString.IsNull())
+    {
+	*fLog << "MFindSupercutsONOFF::TestParamsOnTrainSample; "
+	      << " fThetaRangeString is NOT defined..." << endl;
+	alphaOFFHistaName += ("ThetaRangeStringUndefined");
+    }
+    else
+    {
+	alphaOFFHistaName += (fThetaRangeString);
+    }
+
+
+    alphaOFFHista.SetXTitle("|\\alpha|  [\\circ]");
+    alphaOFFHista.SetName(alphaOFFHistaName);
+
+
+    // *****************************************************
+
+
+
+    //-------------------------------------------
+
+
+    MParList  parlist2;
+    MTaskList tasklist2;
+
+    MMatrixLoop loop(fMatrixTrain);
+
+    // plot alpha before applying the supercuts
+    const TString  mh3NameB = "AlphaBefore";
+    MBinning binsalphabef("Binning"+mh3NameB);
+    //binsalphabef.SetEdges(54, -12.0, 96.0);
+    binsalphabef.SetEdges(fNAlphaBins, fAlphaBinLow, fAlphaBinUp);
+    
+    // |alpha| is assumed to be in column 7 of the matrix
+    MH3 alphabefore("MatrixTrain[7]");
+    alphabefore.SetName(mh3NameB);
+
+    MFillH fillalphabefore(&alphabefore);
+    fillalphabefore.SetName("FillAlphaBefore");
+
+
+    // plot alpha after applying the supercuts
+    const TString  mh3NameA = "AlphaAfter";
+    MBinning binsalphaaft("Binning"+mh3NameA);
+    //binsalphaaft.SetEdges(54, -12.0, 96.0);
+    binsalphaaft.SetEdges(fNAlphaBins, fAlphaBinLow, fAlphaBinUp);
+
+    MH3 alphaafter("MatrixTrain[7]");
+    alphaafter.SetName(mh3NameA);
+
+    
+    MFillH fillalphaafter(&alphaafter);
+    fillalphaafter.SetName("FillAlphaAfter");
+
+    //******************************
+    // entries in MParList
+
+    parlist2.AddToList(&tasklist2);
+
+    parlist2.AddToList(&supercuts);
+
+    parlist2.AddToList(&supapptrainON);
+
+    parlist2.AddToList(fCam);
+    parlist2.AddToList(fMatrixTrain);
+
+    parlist2.AddToList(&binsalphabef);
+    parlist2.AddToList(&alphabefore);
+
+    parlist2.AddToList(&binsalphaaft);
+    parlist2.AddToList(&alphaafter);
+
+    //******************************
+    // entries in MTaskList
+
+    tasklist2.AddToList(&loop);
+    tasklist2.AddToList(&fillalphabefore);
+
+    tasklist2.AddToList(fCalcHadTrain);
+    tasklist2.AddToList(&applysupercuts);
+
+    tasklist2.AddToList(&fillalphaafter);
+
+    //******************************
+
+    MProgressBar bar2;
+    MEvtLoop evtloop2;
+    evtloop2.SetParList(&parlist2);
+    evtloop2.SetName("EvtLoopOptimizationParamOutput");
+    evtloop2.SetProgressBar(&bar2);
+    Int_t maxevents2 = -1;
+    if (!evtloop2.Eventloop(maxevents2))
+        return kFALSE;
+
+    tasklist2.PrintStatistics(0, kTRUE);
+
+
+    //-------------------------------------------
+    // draw the alpha plots
+
+    MH3* alphaBefore = (MH3*)parlist2.FindObject(mh3NameB, "MH3");
+    TH1  &alphaHist1 = alphaBefore->GetHist();
+    TString alphaHist1Name ("TrainAlphaBeforeCuts");
+    if (fThetaRangeString.IsNull())
+    {
+	*fLog << "MFindSupercutsONOFF::TestParamsOnTrainSample; "
+	      << " fThetaRangeString is NOT defined..." << endl;
+	alphaHist1Name += ("ThetaRangeStringUndefined");
+    }
+    else
+    {
+	alphaHist1Name += (fThetaRangeString);
+    }
+
+
+    alphaHist1.SetXTitle("|\\alpha|  [\\circ]");
+    alphaHist1.SetName(alphaHist1Name);
+
+    MH3* alphaAfter = (MH3*)parlist2.FindObject(mh3NameA, "MH3");
+    TH1  &alphaHist2 = alphaAfter->GetHist();
+    TString alphaHist2Name ("TrainAlphaAfterCuts");
+    if (fThetaRangeString.IsNull())
+    {
+	*fLog << "MFindSupercutsONOFF::TestParamsOnTrainSample; "
+	      << " fThetaRangeString is NOT defined..." << endl;
+	alphaHist2Name += ("ThetaRangeStringUndefined");
+    }
+    else
+    {
+	alphaHist2Name += (fThetaRangeString);
+    }
+
+    alphaHist2.SetXTitle("|\\alpha|  [\\circ]");
+    alphaHist2.SetName(alphaHist2Name);
+
+
+    // fPsFilename -> NewPage();
+
+    
+    // Canvas is deleted after saving the plot in ps file
+    // This is to allow for GRID analysis
+
+    TCanvas *c = new TCanvas("TrainAlphaBeforeAfterSC", 
+			     "TrainAlphaBeforeAfterSC", 
+			     600, 600);
+
+    c->Divide(2,2);
+
+
+
+    c->cd(1);
+    alphaOFFHistb.DrawCopy();
+
+    c->cd(2);
+    alphaOFFHista.DrawCopy();
+
+
+    //c->Modified();
+    //c-> Update();
+    
+
+    // fPsFilename -> NewPage();
+
+    c->cd(3);
+    alphaHist1.DrawCopy();
+
+    c->cd(4);
+    alphaHist2.DrawCopy();
+
+
+    c -> Modified();
+    c -> Update();
+    
+     // ********************************************
+    // TMP solutions while the TPostScript thing is not working 
+    // PsFileName for storing these plots is derived 
+    // from PsFilenameString. 
+
+    cout << "Alpha distributions will be saved in PostScript file  " ;
+
+    if (!fPsFilenameString.IsNull())
+    {
+	TString filename = (fPsFilenameString);
+	filename += ("AlphaTRAINSampleONOFFBeforeAfterCuts.ps");
+	cout << filename << endl;
+	c -> SaveAs(filename);
+    }
+
+    // END OF TEMPORAL SOLUTION
+    // ********************************************
+	    
+
+
+
+    // fPsFilename -> NewPage();
+
+
+    // Canvas is deleted after saving the plot in ps file
+    // This is to allow for GRID analysis
+
+    delete c;
+
+
+
+
+    //-------------------------------------------
+    // fit alpha distribution to get the number of excess events and
+    // calculate significance of gamma signal in the alpha plot
+  
+    const Double_t alphasig = fAlphaSig;
+    const Double_t alphamin = fAlphaBkgMin; 
+   // alpha min for bkg region in ON data
+    
+    const Double_t alphamax = fAlphaBkgMax;
+    const Int_t    degree   =    2;
+    const Int_t    degreeOFF   =    2;
+    const Bool_t   drawpoly  = kTRUE;
+    const Bool_t   fitgauss  = kTRUE;
+    const Bool_t   print     = kTRUE;
+    
+    Bool_t saveplots   = kTRUE; // Save plots in Psfile
+  
+    
+
+    
+    
+
+    if (!ComputeNormFactorTrain())
+    {
+	*fLog << "Normalization factor for train sample (ON-OFF) could not be computed. Aborting..." << endl;
+	return kFALSE;
+    }
+	    
+
+    // Normalization factor factor is corrected using the estimated 
+    // number of excess events and the total number of OFF events
+    // fNormFactor = fNormFactor - Ngammas/EventsInMatrixOFF
+
+ 
+    if (fTuneNormFactor)
+    {
+
+
+	// Run MHFindSignificanceONOFF::FindSigmaONOFF
+	// to get estimation of number of excess gamma events. 
+	// This number will be used in the correction of the 
+	// normalization factor 
+	
+	// No plots will be produced this time...
+
+	const Bool_t   drawpolyTest  = kFALSE;
+	const Bool_t   fitgaussTest  = kFALSE;
+	const Bool_t   printTest     = kFALSE;
+	
+	const Bool_t saveplotsTest   = kFALSE; // Save plots in Psfile
+	
+	//TPostScript* DummyPs  = new TPostScript("dummy.ps");
+
+	TString DummyPs = ("Dummy");
+
+	MHFindSignificanceONOFF findsigTest;
+	findsigTest.SetRebin(kTRUE);
+	findsigTest.SetReduceDegree(kFALSE);
+	findsigTest.SetUseFittedQuantities(fUseFittedQuantities);
+
+	if(findsigTest.FindSigmaONOFF(&alphaHist2, &alphaOFFHista, 
+				      fNormFactorTrain, 
+				      alphamin, alphamax, 
+				      degree, degreeOFF,
+				      alphasig, drawpolyTest, 
+				      fitgaussTest, printTest, 
+				      saveplotsTest, DummyPs))
+
+	{
+
+	    // Update values of Nex and SigmaLiMa for Test sammple
+	
+	    fSigmaLiMaTrain = double(findsigTest.GetSignificance());
+
+	    if(fUseFittedQuantities)
+	    {
+		fNexTrain = double(findsigTest.GetNexONOFFFitted());
+	    }
+	    else
+	    {
+		fNexTrain = double(findsigTest.GetNexONOFF());
+	    }
+	    
+	}
+
+	else
+	{
+	    *fLog << "Normalization Factor tuning for Train sample is not possible"
+		  << endl;
+
+	    fSigmaLiMaTrain = 0.0;
+	    fNexTrain = 0.0;
+
+	}
+
+	//DummyPs -> Close();
+	//DummyPs = NULL;
+	//delete DummyPs;
+
+	
+
+
+	Int_t EventsInTrainMatrixOFF = fMatrixTrainOFF->GetM().GetNrows();
+	Double_t Ngammas = fNexTrain/fGammaEfficiency;
+	Double_t GammaFraction = Ngammas/EventsInTrainMatrixOFF;
+	
+
+	*fLog << "MFindSupercutsONOFF::TestParamsOnTrainSample; "
+	      << "fNormFactorTrain is corrected with fraction of gammas in ON "
+	      << "Data Train sample and the number of OFF events before cuts." 
+	      << endl
+	      << "EventsInTrainMatrixOFF = " << EventsInTrainMatrixOFF
+	      << " Excess events in Train ON sample = " << fNexTrain
+	      << " fGammaEfficiency = " << fGammaEfficiency << endl
+	      << "fNormFactorTrain Value before correction is " 
+	      << fNormFactorTrain << endl;
+
+	fNormFactorTrain = fNormFactorTrain - GammaFraction;
+
+	*fLog << "fNormFactorTrain Value after correction is "
+	      << fNormFactorTrain << endl;
+       
+	    
+
+    }
+
+    if (fNormFactorFromAlphaBkg)
+    {
+	Double_t NewNormFactor = 
+	    ComputeNormFactorFromAlphaBkg(&alphaHist2, &alphaOFFHista, 
+					  fAlphaBkgMin, fAlphaBkgMax);
+	
+	*fLog << "Normalization factor computed from alpha plot (after cuts) " << endl
+	      << "using counted number of ON and OFF events in alpha region " << endl
+	      << "defined by range " << fAlphaBkgMin << "-" << fAlphaBkgMax << endl
+	      << "Normalization factor = " << NewNormFactor << endl;
+
+	*fLog << "Normalization factor used is the one computed in bkg region; " << endl
+	      << "i.e. " << NewNormFactor << " instead of " << fNormFactorTrain << endl;
+
+	fNormFactorTrain = NewNormFactor;
+
+
+    }
+
+
+    MHFindSignificanceONOFF findsig;
+    findsig.SetRebin(kTRUE);
+    findsig.SetReduceDegree(kFALSE);
+    findsig.SetUseFittedQuantities(fUseFittedQuantities);
+
+    TString psfilename; // Name of psfile where Alpha plot will be stored
+    if (!fPsFilenameString.IsNull())
+    {
+	psfilename += (fPsFilenameString);
+	psfilename += ("TRAINSample"); 
+    }
+    else
+    {
+	psfilename += ("TRAINSample");
+    }
+
+
+    findsig.FindSigmaONOFF(&alphaHist2, &alphaOFFHista, 
+			   fNormFactorTrain, 
+			   alphamin, alphamax, 
+			   degree, degreeOFF,
+			   alphasig, drawpoly, fitgauss, print, 
+			   saveplots, psfilename);
+    
+    const Double_t significance = findsig.GetSignificance();
+    const Double_t alphasi = findsig.GetAlphasi();
+
+    // Update Train values Nex, SigmaLiMa
+
+  fSigmaLiMaTrain = double(findsig.GetSignificance());
+
+  if(fUseFittedQuantities)
+  {
+      fNexTrain = double(findsig.GetNexONOFFFitted()); 
+  }
+  else
+  {
+      fNexTrain = double(findsig.GetNexONOFF()); 
+  }
+  
+
+    // Alpha distributions and containers with the supercuts applied 
+    // are written into root file 
+
+    TFile rootfile(fAlphaDistributionsRootFilename, "UPDATE",
+		   "Alpha Distributions for several Theta bins");
+
+    alphaHist2.Write();
+    alphaOFFHista.Write();
+    
+    (supapptrainON.GetTreePointer())->Write();
+    (supapptrainOFF.GetTreePointer())->Write();
+
+    *fLog  << "TTree objects containing supercuts applied to TEST sample are "
+	   << "written into root file " << fAlphaDistributionsRootFilename << endl; 
+ 
+    (supapptrainON.GetTreePointer())->Print();
+    (supapptrainOFF.GetTreePointer())->Print();
+
+
+    //rootfile.Close();
+    
+
+    // Boolean variable that controls in class MSupercutsCalcONOFF
+    // wether the supercuts are stored or not
+    // is set to the default value, kFALSE.
+
+    fCalcHadTrain -> SetStoreAppliedSupercuts(kFALSE);
+    fCalcHadTrainOFF -> SetStoreAppliedSupercuts(kFALSE);
+    
+
+
+
+
+    *fLog << "Significance of gamma signal after supercuts in train sample : "
+         << significance << " (for |alpha| < " << alphasi << " degrees)" 
+         << endl;
+    //-------------------------------------------
+
+
+    *fLog << "Test of supercuts on TRAIN sample finished" << endl;
+    *fLog << "======================================================" << endl;
+
+    return kTRUE;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/MFindSupercutsONOFF.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/MFindSupercutsONOFF.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/MFindSupercutsONOFF.h	(revision 9661)
@@ -0,0 +1,466 @@
+#ifndef MARS_MFindSupercutsONOFF
+#define MARS_MFindSupercutsONOFF
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#ifndef ROOT_TArrayD
+#include <TArrayD.h>
+#endif
+#ifndef ROOT_TArrayI
+#include <TArrayI.h>
+#endif
+
+#ifndef ROOT_TH1F
+#include <TH1F.h>
+#endif
+
+#ifndef ROOT_TPostScript
+#include <TPostScript.h>
+#endif
+
+
+class MFilter;
+class MEvtLoop;
+class MH3;
+class MSupercutsCalcONOFF;
+
+class MGeomCam;
+class MHMatrix;
+
+
+class MFindSupercutsONOFF : public MParContainer
+{
+ private:
+
+
+     // TMP
+    // There are quite some problems during the data preprocessing. 
+    // For the time being, I will add some cuts to the functions 
+    // DefineTrainTestMatrixThetaRange and for OFF, so that I can 
+    // make a kind of preprocess on my own. This allows me 
+    // to make a very silly preprocess with wolfgangs macro, which 
+    // might be free of corrupted data, and then I can do on my own.
+
+
+    // VARIABLES INITIALIZED IN CONSTRUCTOR
+
+    Double_t fSizeCutLow;
+    Double_t fSizeCutUp;
+
+    Double_t fDistCutLow;
+    Double_t fDistCutUp;
+    
+    Double_t fLengthCutLow;
+    Double_t fLengthCutUp;
+    
+    Double_t  fWidthCutLow;
+    Double_t  fWidthCutUp;
+
+
+    // ENDTMP
+
+
+
+
+
+
+  TString fFilenameTrain;
+  TString fFilenameTest;
+
+  Int_t   fHowManyTrain;
+  Int_t   fHowManyTest;
+
+  Int_t   fHowManyTrainOFF;
+  Int_t   fHowManyTestOFF;
+
+
+  
+  Double_t fAlphaSig; // Max alpha value were signal is expected
+
+  // Background range (in alpha) is defined by the member variables 
+  // fAlphaBkgMin and fAlphaBkgMax
+  Double_t fAlphaBkgMin; 
+  Double_t fAlphaBkgMax; 
+  
+  Int_t fThetaMin; // Cuts in ThetaOrig.fVal (in mili radians!!!)
+  Int_t fThetaMax; // Cuts in ThetaOrig.fVal (in mili radians !!!)
+  TString fThetaRangeString;
+
+ 
+
+  // Variables for binning of alpha plots
+  
+  Int_t fNAlphaBins;
+  Double_t fAlphaBinLow;
+  Double_t fAlphaBinUp;
+
+
+  Bool_t  fUseOrigDistribution;
+
+
+  Double_t fNormFactorTrain;
+  Double_t fNormFactorTest;
+  Double_t fSigmaLiMaTrain;
+  Double_t fSigmaLiMaTest;
+  Double_t fNexTrain; 
+  Double_t fNexTest; 
+  Double_t fGammaEfficiency; // Fraction of gammas that remain after cuts
+  // Quantity that will have to be determined with MC
+
+  Bool_t fTuneNormFactor; // If true, normalization factors are corrected using the estimated number of gammas and the gamma efficiency
+  // fNormFactorTrain = fNormFactorTrain - Ngammas/EventsInTrainMatrixOFF
+
+
+  // Boolean variable used to determine wether the normalization factor is 
+  // computed from method 1) or 2)
+  // 1) Using total number of ON and OFF events before cuts, and tuning the factor 
+  //    correcting for "contamination" of gamma events in ON sample
+  // 2) Using number of ON and OFF events after cuts in the background 
+  //    region determined by variables fAlphaBkgMin-fAlphaBkgMax
+ 
+  Bool_t fNormFactorFromAlphaBkg; // if kTRUE, method 2) is used
+
+
+
+  // Boolean variable used to disable the usage ("serious" usage) of the 
+  // quantities computed from fits. This will be useful in those cases 
+  // where there is too few events to perform a decent fit to the 
+  // alpha histograms. Default value will be kTRUE.
+  
+  Bool_t fUseFittedQuantities;
+
+  // Boolean variable that controls wether the optimization of the 
+  // parameters (MMinuitInterface::CallMinuit(..) in function FindParams(..))
+  // takes place or not. kTRUE will skip such optimization.
+  // This variable is useful to test the optmized parameters (previously found 
+  // and stored in root file) on the TRAIN sample.
+
+  Bool_t fSkipOptimization;
+
+
+
+  // Boolean variable that allows the user to set some limits to the 
+  // some of the Minuit parameters. For the time being, only the limits
+  // for the parameters which do NOT depend in size, dist and theta are set, 
+  // i.e. static limits. The value of this boolean variable is set in the 
+  // constructor of the class.
+
+  Bool_t fSetLimitsToSomeMinuitParams;
+
+  // Limits for the Minuit parameters. For the time being the values are set in the constructor 
+  // of the class. One MUST be very careful to set limits such that the expected final values 
+  // (optimized values) are far away from the limits.
+
+ 
+  
+  Double_t fMinuitDistUPUpperLimit;
+  Double_t fMinuitDistUPLowerLimit;
+  Double_t fMinuitLengthUPUpperLimit;
+  Double_t fMinuitLengthUPLowerLimit;
+  Double_t fMinuitWidthUPUpperLimit;
+  Double_t fMinuitWidthUPLowerLimit;
+  
+  Double_t fMinuitLeakage1UPUpperLimit;
+  Double_t fMinuitLeakage1UPLowerLimit;
+
+
+
+  Double_t fMinuitDistLOWUpperLimit;
+  Double_t fMinuitDistLOWLowerLimit;
+  Double_t fMinuitLengthLOWUpperLimit;
+  Double_t fMinuitLengthLOWLowerLimit;
+  Double_t fMinuitWidthLOWUpperLimit;
+  Double_t fMinuitWidthLOWLowerLimit;
+  
+
+
+  // Boolean variable used to control decide wether to use theta information 
+  // in the computation of teh dynamical cuts.
+  Bool_t fNotUseTheta;
+
+
+  // Boolean variable that allows to use/not use the dist info in the cuts parameterization
+  // kTRUE for use it.
+  // For the time being this variable is set in the constructor
+
+  Bool_t fUseDist;
+
+
+
+ // Boolean variable used to decide wether to use dynamical cuts or static cuts
+  // kTRUE means that static cuts are used. 
+  Bool_t fUseStaticCuts;
+
+  
+  // Boolean variable that allows the user to write the initial parameters 
+  // into the root file that will be used to store the optimum cuts.
+  // If fUseInitialSCParams = kTRUE , parameters are written.
+  // In this way, the initial SC parameters can be applied on the data (train/test) 
+  
+  // The initial parameters are ONLY written to the root file if 
+  // there is NO SC params optimization, i.e., if variable 
+  // fSkipOptimization = kTRUE;
+  
+  // The default value is obviously kFALSE.
+
+  Bool_t fUseInitialSCParams;
+
+  
+  TString  fFilenameParam;
+
+  TString  fHadronnessName;
+  TString  fHadronnessNameOFF;
+
+  // name for the containers to store the 
+  // supercuts applied to Train (ON/OFF) and Test(ON/OFF) samples
+
+  TString  fTrainONSupercutsAppliedName;        
+  TString  fTrainOFFSupercutsAppliedName;       
+
+  TString  fTestONSupercutsAppliedName;        
+  TString  fTestOFFSupercutsAppliedName;       
+
+  
+
+  // Name of Postscript file where, for each theta bin,  alpha ON and OFF distributions 
+  //  after cuts (and hence, Nex and SigmaLiMa computations) will be stored
+  // If fAlphaDistributionsPostScriptFilename is not defined, postscript file is not 
+  // produced. It is an optional variable...
+
+  // NOT WORKING YET !!!!
+  TPostScript* fPsFilename; 
+  TPostScript* fPsFilename2; 
+
+  TString fPsFilenameString; // Name of the file where plots will be stored while the 
+  // TPostScript option is not working 
+
+  TString fAlphaDistributionsRootFilename;
+  // Root file where histograms containing the ON alpha distribution and the 
+  // OFF alpha distribution (non normalized) , AFTER CUTS, are stored.
+  // Histograms containing the normalization factors, Nex and SigmaLiMa for 
+  // each theta bin will be also stored there.
+  // This name MUST be defined, since the histograms stored there will be used by 
+  // function XXX to compute an overall Nex and sigmaLiMa combining all those histograms
+
+
+  MSupercutsCalcONOFF *fCalcHadTrain;
+  MSupercutsCalcONOFF *fCalcHadTest;
+  MSupercutsCalcONOFF *fCalcHadTrainOFF;
+  MSupercutsCalcONOFF *fCalcHadTestOFF;
+  
+
+  MHMatrix          *fMatrixTrain;
+  MHMatrix          *fMatrixTest;
+  MHMatrix          *fMatrixTrainOFF;
+  MHMatrix          *fMatrixTestOFF;
+
+  MGeomCam          *fCam;
+
+  MEvtLoop *fObjectFit;
+
+  MFilter  *fMatrixFilter; 
+
+  // to comunicate with MINUIT -----------------
+  // attention : dimensions must agree with those in 
+  //             MMinuitInterface::CallMinuit()
+  //char    fParName [80][100];
+  TArrayD fVinit;
+  TArrayD fStep;
+  TArrayD fLimlo;
+  TArrayD fLimup;
+  TArrayI fFix;
+
+  UInt_t     fNpar;
+
+  TString    fMethod;
+
+  Double_t fMin,   fEdm,   fErrdef;
+  Int_t    fNpari, fNparx, fIstat;
+  Int_t    fErrMinimize;
+  //--------------------------------------------
+
+
+public:
+  MFindSupercutsONOFF(const char *name=NULL, const char *title=NULL);
+  ~MFindSupercutsONOFF();
+
+  void SetFilenameTraining(const TString &name, const Int_t howmany) 
+      {fFilenameTrain = name;  fHowManyTrain = howmany; }
+
+  void SetFilenameTest(const TString &name, const Int_t howmany)     
+      {fFilenameTest     = name;  fHowManyTest  = howmany; }
+
+  void SetFilenameParam(const TString &name)    {fFilenameParam  = name;}
+  void SetHadronnessName(const TString &name)   {fHadronnessName = name;}
+  void SetHadronnessNameOFF(const TString &name)   {fHadronnessNameOFF = name;}
+
+  
+  void SetSupercutsAppliedTreeNames();
+
+
+  void SetAlphaDistributionsRootFilename(const TString &name) 
+      {fAlphaDistributionsRootFilename = name;}
+
+  Bool_t SetAlphaSig (Double_t alphasig);
+  Bool_t SetAlphaBkgMin (Double_t alphabkgmin);
+  Bool_t SetAlphaBkgMax (Double_t alphabkgmax);
+
+  // Function that checks that the values of the member data 
+  // fAlphaSig, fAlphaBkgMin and fAlphaBkgMax make sense
+  // (ie, fAlphaSig < fAlphaBkgMin < fAlphaBkgMax)
+
+  Bool_t CheckAlphaSigBkg();
+
+  void SetUseFittedQuantities (Bool_t b)
+      {fUseFittedQuantities = b;}
+
+
+  void SetPostScriptFile(TPostScript* PsFile);
+  void SetPostScriptFile2(TPostScript &PsFile);
+
+  void SetPsFilenameString (const TString filename);
+
+
+  void SetMatrixFilter(MFilter *filter)          {fMatrixFilter = filter;}
+
+  
+
+
+  Bool_t DefineTrainMatrix(const TString &name, MH3 &href,
+                           const Int_t howmany, const TString &filetrain);
+  Bool_t DefineTestMatrix(const TString &name, MH3 &href,
+                          const Int_t howmany, const TString &filetest);
+
+
+
+  Bool_t DefineTrainTestMatrix(const TString &name, MH3 &href,
+			 const Int_t howmanytrain, const Int_t howmanytest, 
+                         const TString &filetrain, const TString &filetest);
+
+
+
+  Bool_t DefineTrainTestMatrixThetaRange(const TString &name, 
+					 const Double_t whichfractiontrain, 
+					 const Double_t whichfractiontest,  
+					 Double_t ThetaMin, Double_t ThetaMax, 
+					 const TString &filetrain, const TString &filetest);
+
+
+
+  
+  Bool_t DefineTrainTestMatrixOFFThetaRange(const TString &name, 
+					    const Double_t whichfractiontrain, 
+					    const Double_t whichfractiontest,  
+					    Double_t ThetaMin, Double_t ThetaMax, 
+					    const TString &filetrain, const TString &filetest);
+
+
+  MHMatrix *GetMatrixTrain() { return fMatrixTrain; }
+  MHMatrix *GetMatrixTest()  { return fMatrixTest;  }
+  MHMatrix *GetMatrixTrainOFF() { return fMatrixTrainOFF; }
+  MHMatrix *GetMatrixTestOFF()  { return fMatrixTestOFF;  }
+
+
+  void SetUseOrigDistribution(Bool_t b);
+
+
+  Bool_t ReadMatrix( const TString &filetrain, const TString &filetest);
+  
+  Bool_t ReadMatrixOFF( const TString &filetrainOFF, const TString &filetestOFF);
+
+  Bool_t ComputeNormFactorTrain ();
+  Bool_t ComputeNormFactorTest ();
+
+  Bool_t FindParams(TString parSCinit, TArrayD &params, TArrayD &steps);
+  // Bool_t TestParams();
+
+  // Function used to apply the supercuts on the TEST sample.
+  // Two event loops (one after the other) 
+  // are used to fill the 2 alpha distributions (ON and OFF) 
+  // applying supercuts to the Test sample
+  Bool_t TestParamsOnTestSample(); 
+  
+
+  // Function used to apply the supercuts on the TRAIN sample.
+  // Two event loops (one after the other) 
+  // are used to fill the 2 alpha distributions (ON and OFF) 
+  // applying supercuts to the TRAIN sample
+  Bool_t TestParamsOnTrainSample();
+  
+
+
+  Bool_t SetThetaRange(Double_t ThetaMin, Double_t ThetaMax);
+
+  Bool_t SetSizeRange(Double_t SizeMin, Double_t SizeMax);
+
+
+  void SetAlphaPlotBinining(Int_t nbins, Double_t binlow, Double_t binup)
+    { fNAlphaBins = nbins; fAlphaBinLow = binlow; fAlphaBinUp = binup;}
+
+  Double_t GetNormFactorTrain() {return fNormFactorTrain;}
+  Double_t GetNormFactorTest() {return fNormFactorTest;}
+  Double_t GetSigmaLiMaTrain() {return fSigmaLiMaTrain;}
+  Double_t GetSigmaLiMaTest() {return fSigmaLiMaTest;}
+  Double_t GetNexTrain() {return fNexTrain;}
+  Double_t GetNexTest() {return fNexTest;}
+
+
+  Double_t GetAlphaSig() {return fAlphaSig;}
+  Double_t GetAlphaBkgMin () {return fAlphaBkgMin;}
+  Double_t GetAlphaBkgMax () {return fAlphaBkgMax;}
+  
+  Bool_t GetUseFittedQuantities() {return fUseFittedQuantities;}
+  Bool_t GetSkipOptimization() {return fSkipOptimization;}
+  Bool_t GetUseInitialSCParams() {return fUseInitialSCParams;}
+
+  Bool_t SetGammaEfficiency (Double_t gammaeff);
+  Double_t GetGammaEfficiency() {return fGammaEfficiency;}
+  
+  
+
+  // Double_t ComputeNormFactorFromAlphaBkg(TH1 *histON, TH1 *histOFF);
+           
+  void SetTuneNormFactor(Bool_t b) {fTuneNormFactor = b;}
+
+  void SetNormFactorFromAlphaBkg (Bool_t b) {fNormFactorFromAlphaBkg = b;}
+
+  void SetSkipOptimization(Bool_t b);
+
+  void SetUseInitialSCParams(Bool_t b);
+
+  void SetVariableNotUseTheta(Bool_t b) {fNotUseTheta = b;}
+  Bool_t GetVariableNotUseTheta() { return fNotUseTheta;}
+
+  void SetVariableUseStaticCuts(Bool_t b) {fUseStaticCuts = b;}
+  Bool_t GetVariableUseStaticCuts() { return fUseStaticCuts;}
+
+  
+
+  
+
+
+  ClassDef(MFindSupercutsONOFF, 1) // Class for optimization of the Supercuts
+};
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/MFindSupercutsONOFFThetaLoop.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/MFindSupercutsONOFFThetaLoop.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/MFindSupercutsONOFFThetaLoop.cc	(revision 9661)
@@ -0,0 +1,4090 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): David Paneque   12/2003 <mailto:dpaneque@mppmu.mpg.de>
+!              
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+// MFindSupercutsONOFFThetaLoop                                             //
+//                                                                         //
+// Class for optimizing the parameters of the supercuts                     //
+// Using ON and OFF data runing over data which are subdivided in 
+// several Theta ranges.                                                  //
+//                                                                         //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+
+
+#include "MFindSupercutsONOFFThetaLoop.h"
+
+
+#include <math.h>            // fabs 
+
+#include <TFile.h>
+#include <TArrayD.h>
+#include <TMinuit.h>
+#include <TCanvas.h>
+#include <TStopwatch.h>
+#include <TVirtualFitter.h>
+
+#include <iostream.h>
+#include <fstream.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "MFindSupercutsONOFF.h"
+#include "MBinning.h"
+#include "MContinue.h"
+#include "MSupercuts.h"
+#include "MSupercutsCalcONOFF.h"
+#include "MDataElement.h"
+#include "MDataMember.h"
+
+
+#include <TPostScript.h>
+
+#include "MEvtLoop.h"
+#include "MFCT1SelFinal.h"
+#include "MF.h"
+#include "MFEventSelector.h"
+#include "MFEventSelector2.h"
+#include "MFillH.h"
+//#include "MGeomCamCT1Daniel.h"
+//#include "MGeomCamCT1.h"
+#include "MGeomCamMagic.h" // only for magic
+#include "MFRandomSplit.h"
+#include "MH3.h"
+#include "MHCT1Supercuts.h"
+#include "MHFindSignificance.h" // To be removed at some point...
+#include "MHFindSignificanceONOFF.h"
+#include "MHMatrix.h"
+#include "MHOnSubtraction.h"
+#include "MDataValue.h"
+// #include "MDataString.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+#include "MMatrixLoop.h"
+#include "MMinuitInterface.h"
+#include "MParList.h"
+#include "MProgressBar.h"
+#include "MReadMarsFile.h"
+#include "MReadTree.h"
+#include "MTaskList.h"
+
+
+ClassImp(MFindSupercutsONOFF);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MFindSupercutsONOFFThetaLoop::MFindSupercutsONOFFThetaLoop(const char *name, const char *title)
+{
+    fName  = name  ? name  : "MFindSupercutsONOFF";
+    fTitle = title ? title : "Optimizer of the supercuts";
+    
+    //---------------------------
+
+
+    // Cuts (low and up) in variable ThetaOrig.fVal
+    // The default is not cut, i.e. all values (0-1) are taken
+    // fThetaOrig.fVal is measured in Radians; thus 1 = 57 degrees.
+
+    fThetaMin = 0.0;
+    fThetaMax = 1.0;
+
+    fAlphaSig = 20; // By default, signal is expected in alpha<20 for CT1
+
+    // By default, bkg region is set to alpha range 30-90 for CT1
+    fAlphaBkgMin = 30; 
+    fAlphaBkgMax = 90;
+
+    fActualCosThetaBinCenter = 0;
+    
+    fNormFactorTrainHist = NULL;
+    //fNormFactorTrainHist -> SetDirectory(0);
+    fNormFactorTestHist = NULL;
+    //fNormFactorTestHist -> SetDirectory(0);
+    fSigmaLiMaTrainHist = NULL;
+    //fSigmaLiMaTrainHist -> SetDirectory(0);
+    fSigmaLiMaTestHist = NULL;
+    //fSigmaLiMaTestHist -> SetDirectory(0);
+    fNexTrainHist = NULL;
+    //fSigmaLiMaTestHist -> SetDirectory(0);
+    fNexTestHist = NULL;
+    //fNexTestHist -> SetDirectory(0);
+
+
+    fSuccessfulThetaBinsHist = NULL;
+
+    /*
+    fNexVSAlphaSigTrain = NULL;
+    fNexVSAlphaSigTest = NULL;
+    
+    fSignificanceVSAlphaSigTrain = NULL;
+    fSignificanceVSAlphaSigTest = NULL;
+    */
+
+
+    fNEvtsInTrainMatrixONHist = NULL; 
+    fNEvtsInTestMatrixONHist = NULL; 
+    fNEvtsInTrainMatrixOFFHist = NULL; 
+    fNEvtsInTestMatrixOFFHist = NULL; 
+
+
+    fTrainMatrixONFilenameVector = NULL;
+    fTestMatrixONFilenameVector= NULL;
+    fTrainMatrixOFFFilenameVector= NULL;
+    fTestMatrixOFFFilenameVector= NULL;
+
+    
+    fOptSCParamFilenameVector = NULL;
+
+    fThetaRangeStringVector = NULL;
+
+    fPsFilename = NULL;
+
+
+
+    fTuneNormFactor = kTRUE; // Norm factors will be corrected using the total amount of OFF events before cuts and the estimated excess events
+    
+    // fNormFactorTrain = fNormFactorTrain - Ngammas/EventsInTrainMatrixOFF
+    
+    fGammaEfficiency = 0.5; // Fraction of gammas that remain after cuts
+    // Quantity that will have to be determined with MC, yet for the 
+    // time being I set it to 0.5
+
+    // boolean variables are set to kFALSE as default 
+
+    fReadMatricesFromFile = kFALSE;
+    fOptimizeParameters = kFALSE;
+    fTestParameters = kFALSE;
+
+    // Fraction of Train/Test ON/OFF samples is set to 0.5 as default
+
+   fWhichFractionTrain = 0.5;  // number <= 1; specifying fraction of ON Train events
+   fWhichFractionTest = 0.5;  // number <= 1; specifying fraction of ON Test events
+
+   fWhichFractionTrainOFF = 0.5;  // number <= 1; specifying fraction of OFF  Train events
+   fWhichFractionTestOFF = 0.5;  // number <= 1; specifying fraction of OFF Test events
+
+
+
+    // use quantities computed from the fits
+    // The variable allows the user to NOT use these quantities when there is not 
+    // enough statistics and fit not always is possible
+    fUseFittedQuantities = kTRUE;
+
+
+
+    // Boolean variable that controls wether the optimization of the 
+    // parameters (MMinuitInterface::CallMinuit(..) in function FindParams(..))
+    // takes place or not. kTRUE will skip such optimization.
+    // This variable is useful to test the optmized parameters (previously found 
+    // and stored in root file) on the TRAIN sample.
+    
+    fSkipOptimization = kFALSE;
+
+    // Boolean variable that allows the user to write the initial parameters 
+    // into the root file that will be used to store the optimum cuts.
+    // If fUseInitialSCParams = kTRUE , parameters are written.
+    // In this way, the initial SC parameters can be applied on the data (train/test) 
+    
+    // The initial parameters are ONLY written to the root file if 
+    // there is NO SC params optimization, i.e., if variable 
+    // fSkipOptimization = kTRUE;
+
+    // The default value is obviously kFALSE.
+
+    fUseInitialSCParams = kTRUE;
+
+
+
+    // fInitSCPar  and fInitSCParSteps initialized to zero
+    
+    fInitSCPar.Set(0);
+
+    fInitSCParSteps.Set(0);
+        
+}
+
+// --------------------------------------------------------------------------
+//
+// Default destructor.
+//
+MFindSupercutsONOFFThetaLoop::~MFindSupercutsONOFFThetaLoop()
+{
+
+    *fLog << "Destructor of MFindSupercutsONOFFThetaLoop is called" 
+	  << endl;
+
+    fPsFilename = NULL;
+
+    delete fNormFactorTrainHist;
+    delete fNormFactorTestHist;
+    delete fSigmaLiMaTrainHist;
+    delete fSigmaLiMaTestHist;
+    delete fNexTrainHist;
+    delete fNexTestHist;
+
+
+    
+    delete fSuccessfulThetaBinsHist;
+    
+
+    delete fNEvtsInTrainMatrixONHist; 
+    delete fNEvtsInTestMatrixONHist; 
+    delete fNEvtsInTrainMatrixOFFHist; 
+    delete fNEvtsInTestMatrixOFFHist; 
+
+    delete [] fTrainMatrixONFilenameVector;
+    delete [] fTestMatrixONFilenameVector;
+    delete [] fTrainMatrixOFFFilenameVector;
+    delete [] fTestMatrixOFFFilenameVector;
+    
+    delete [] fOptSCParamFilenameVector;
+    
+    delete [] fThetaRangeStringVector;
+
+
+    *fLog << "Destructor of MFindSupercutsONOFFThetaLoop finished " 
+	  << "successfully."  
+	  << endl;
+
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Function that sets the name of the PostScript file where alpha distributions 
+// for the different Theta bins will be stored.
+// It also initializes 
+
+
+
+void MFindSupercutsONOFFThetaLoop::SetPostScriptFile (TPostScript* PsFile)
+{
+    fPsFilename = PsFile;
+
+    *fLog << "MFindSupercutsONOFF : Results (alpha distributions with excess and significances) will be stored in PostScript file " 
+	  << fPsFilename -> GetName() << endl;
+
+}
+
+
+Bool_t MFindSupercutsONOFFThetaLoop::SetGammaEfficiency (Double_t gammaeff)
+{
+    if (gammaeff <= 0.0 || gammaeff > 1)
+    {
+	*fLog << " ******   ERROR  *********"  << endl
+ 	      << "MFindSupercutsONOFFThetaLoop :: SetGammaEfficiency; " << endl
+	      << "The requested Gamma efficiency " << gammaeff << " can not occur" << endl
+	      << "Member data fGammaEfficiency can not be set properly." << endl
+	      << "Default value for fGammaEfficiency, which is " 
+	      << fGammaEfficiency << " will remain." << endl;
+
+
+	return kFALSE;
+    }
+
+    fGammaEfficiency = gammaeff;
+
+    return kTRUE;
+
+}
+
+
+Bool_t MFindSupercutsONOFFThetaLoop::ReadSCParamsFromAsciiFile(const char* filename,
+								  Int_t Nparams)
+{
+    const Int_t NColumns = 2; 
+    
+    Double_t tmp_vector[NColumns];
+    Int_t counter = 0;
+    Double_t tmpdouble = 0.0;
+
+    
+    // File is read and data stored in data_vector
+    
+    ifstream infile (filename, ios::in);
+    
+    if ( !infile )
+    {
+	cout << "Input file could not be opened" << endl; 	
+	return kFALSE;
+      //	exit (1);
+    }
+    
+    counter = 0;
+    while (infile >> tmp_vector [0])
+    {
+	for (Int_t i = 1; i < NColumns; i++)
+	{
+	    infile >> tmp_vector[i];
+	}
+	counter++;
+    }
+    
+    infile.close();
+    
+    
+    // Length of TArray vectors is set to the length of the 
+    // vectors defined in ascii file.
+    // If such length does not match with the specified 
+    // by variable Nparams, the function complains and 
+    // aborts.
+    
+    if (counter != Nparams)
+    {
+	*fLog << "MFindSupercutsONOFFThetaLoop::ReadSCParamsFromAsciiFile" << endl
+	      << "Length of vectors in ascii file " << filename << "  is  " << counter 
+	      << " , which does not match with the expected length " << Nparams << endl  
+	      << " fInitSCPar and fInitSCParSteps are NOT retrieved from ascii file" << endl;
+
+	return kFALSE;
+    }
+    
+    fInitSCPar.Set(counter);
+    fInitSCParSteps.Set(counter);
+    
+    
+  // Vectors are filled
+
+  ifstream infile2 (filename, ios::in);
+  
+  if ( !infile2 )
+    {
+      cout << "Input file could not be opened" << endl; 
+      return kFALSE;
+      // exit (1);
+    }
+  
+  for (Int_t i = 0; i < fInitSCPar.GetSize(); i++)
+    {
+
+	infile2 >> tmpdouble;
+	fInitSCPar[i] = tmpdouble;
+	
+	infile2 >> tmpdouble;
+	fInitSCParSteps[i] = tmpdouble;
+	
+    }
+
+
+  // Print the vectors read 
+
+  *fLog << "*****  INITIAL SC PARAMETERS AND STEPS TAKEN FROM ASCII FILE ********* " << endl;
+  for (Int_t i = 0; i < fInitSCPar.GetSize(); i++)
+    {
+	cout << fInitSCPar[i] << setw(20) <<  fInitSCParSteps[i] << endl;
+    }
+
+  // 
+  
+ // File close 
+  infile2.close();
+  
+  return kTRUE;
+}
+
+
+Bool_t MFindSupercutsONOFFThetaLoop::SetInitSCPar (TArrayD &d)
+{
+    *fLog << "MFindSupercutsONOFFThetaLoop; Initial SC parameters are "
+	  << "set using function SetInitSCPar (TArrayD &d)" << endl;
+
+    fInitSCPar = d;
+
+    return kTRUE;
+}
+
+
+Bool_t MFindSupercutsONOFFThetaLoop::SetInitSCParSteps (TArrayD &d)
+{
+
+    *fLog << "MFindSupercutsONOFFThetaLoop; Initial SC parameters STEPS are "
+	  << "set using function SetInitSCParSteps (TArrayD &d)" << endl;
+
+    fInitSCParSteps = d;
+
+    return kTRUE;
+}
+
+
+
+Bool_t MFindSupercutsONOFFThetaLoop::SetAlphaSig(Double_t alphasig)
+{
+    // check that alpha is within the limits 0-90
+    if (alphasig <= 0 || alphasig > 90)
+    {
+	*fLog << "MFindSupercutsONOFFThetaLoop ::SetAlphaSig; " 
+	      << "value " << alphasig << " is not within the the "
+	      << "logical limits of alpha; 0-90" << endl;
+	return kFALSE;
+    }
+    
+
+    fAlphaSig = alphasig;
+
+    return kTRUE;
+}
+
+Bool_t MFindSupercutsONOFFThetaLoop::SetAlphaBkgMin(Double_t alpha)
+{
+    // check that alpha is within the limits 0-90
+    if (alpha <= 0 || alpha >= 90)
+    {
+	*fLog << "MFindSupercutsONOFFThetaLoop::SetAlphaBkgMin; " 
+	      << "value " << alpha << " is not within the the "
+	      << "logical limits of alpha; 0-90" << endl;
+	return kFALSE;
+    }
+    
+
+    fAlphaBkgMin = alpha;
+
+    return kTRUE;
+}
+
+
+Bool_t MFindSupercutsONOFFThetaLoop::SetAlphaBkgMax(Double_t alpha)
+{
+    // check that alpha is within the limits 0-90
+    if (alpha <= 0 || alpha > 90.001)
+    {
+	*fLog << "MFindSupercutsONOFFThetaLoop ::SetAlphaBkgMax; " 
+	      << "value " << alpha << " is not within the the "
+	      << "logical limits of alpha; 0-90" << endl;
+	return kFALSE;
+    }
+    
+
+    fAlphaBkgMax = alpha;
+
+    return kTRUE;
+}
+
+
+// Function that checks that the values of the member data 
+// fAlphaSig, fAlphaBkgMin and fAlphaBkgMax make sense
+// (ie, fAlphaSig < fAlphaBkgMin < fAlphaBkgMax)
+
+Bool_t MFindSupercutsONOFFThetaLoop::CheckAlphaSigBkg()
+{
+
+    if (fAlphaSig > fAlphaBkgMin)
+    {
+	*fLog << "MFindSupercutsONOFFThetaLoop ::CheckAlphaSigBkg(); " << endl
+	      << "fAlphaSig > fAlphaBkgMin, which should not occur..." << endl
+	      << "fAlphaSig = " << fAlphaSig << ", fAlphaBkgMin = " << fAlphaBkgMin
+	      << endl;
+
+	return kFALSE;
+    }
+    
+    if (fAlphaBkgMax < fAlphaBkgMin)
+    {
+	*fLog << "MFindSupercutsONOFFThetaLoop::CheckAlphaSigBkg(); " << endl
+	      << "fAlphaBkgMin > fAlphaBkgMax, which should not occur..." << endl
+	      << "fAlphaBkgMin = " << fAlphaBkgMin << ", fAlphaBkgMax = " << fAlphaBkgMax
+	      << endl;
+
+	return kFALSE;
+    }
+
+    return kTRUE;
+
+}
+
+
+
+
+// Function that sets the value of fCosThetaRangeVector and 
+// fCosThetaBinCenterVector
+
+Bool_t MFindSupercutsONOFFThetaLoop::SetCosThetaRangeVector(
+    const TArrayD &d)
+{
+    if (d.GetSize() < 2)
+    {
+        *fLog << err 
+	      << "MFindSupercutsONOFFThetaLoop::SetCosThetaRangeVector: " 
+	      << endl
+	      << "Size of d is smaller than 2... "
+	      << "fCosThetaRangeVector can not be defined properly"
+	      << endl;
+        return kFALSE;
+    }
+
+    fCosThetaRangeVector.Set(d.GetSize());
+    fCosThetaRangeVector = d;
+
+
+    // Give a "soft warning" if Vector has increasing values 
+    // of CosThetas; which means decreasing values of Thetas
+    /*
+    if (fCosThetaRangeVector[0] <= fCosThetaRangeVector[1])
+    {
+	*fLog << "MFindSupercutsONOFFThetaLoop::SetCosThetaRangeVector; " 
+	      << endl
+	      << "Values in vector fCosThetaRangeVector are in increasing "
+	      << "order, i.e., values in theta will be in decreasing order"
+	      << endl
+	      << "DO NOT forget it !!" << endl;
+    }
+
+    */
+
+    // fCosThetaBinCenterVector is defined
+
+    Int_t dim = fCosThetaRangeVector.GetSize() - 1;
+    fCosThetaBinCenterVector.Set(dim);
+
+    for (Int_t i = 0; i < dim; i++)
+    {
+	fCosThetaBinCenterVector[i] = 
+	    (fCosThetaRangeVector[i+1]+fCosThetaRangeVector[i])/2;
+    }
+
+    return kTRUE;
+}
+
+// Function that sets the range of Theta (fThetaMin, fThetaMax) 
+// where data will be used in the iteration 
+// thetabin. This theta range is used when geting data from 
+// file and filling matrices. If matrices are already built 
+// and just read from root files, this theta range is useless. 
+
+
+// **** IMPORTANT *********
+// thetabin is an integer  value that goes from 1 to 
+// fCosThetaBinCenterVector.GetSize()
+// ************************
+
+Bool_t MFindSupercutsONOFFThetaLoop::SetThetaRange (Int_t thetabin)
+{
+    // Check that iteration thetabin is smaller than 
+    // components of fCosThetaBinCenterVector
+   
+    if (fCosThetaRangeVector.GetSize() < 2 ||
+	fCosThetaBinCenterVector.GetSize() < 1)
+	
+    {
+	*fLog << "MFindSupercutsONOFFThetaLoop::SetThetaRange; " << endl
+	      << "Dimension of vectors fCosThetaRangeVector or/and " 
+	      << "fCosThetaBinCenterVector are smaller than 2 and 1 " 
+	      << "respectively. Range for theta can not be defined." << endl;
+	
+	return kFALSE;
+    }
+    
+    if (thetabin < 1 || 
+	thetabin > fCosThetaBinCenterVector.GetSize())
+    {
+	*fLog << "MFindSupercutsONOFFThetaLoop::SetThetaRange; " << endl
+	      << "thetabin value is " << thetabin 
+	      << " Is is outside the possible values given by " 
+	      << "vector fCosThetaRangeVector. "
+	      << "Range for theta can not be defined." << endl;
+	
+	return kFALSE;
+    }
+    
+    
+    fThetaMin = fCosThetaRangeVector[thetabin-1];
+    fThetaMax = fCosThetaRangeVector[thetabin];
+    
+
+    // Now costheta values have to be converted to Radians
+    // Function TMath::ACos(x) gives angle in Radians
+
+    
+    fThetaMin = TMath::ACos(fThetaMin);
+    fThetaMax = TMath::ACos(fThetaMax);
+
+    // If fThetaMin > fThetaMax means that fCosThetaRangeVector
+    // is defined with increasing values of CosTheta, which 
+    // means decreasing values of Theta
+
+    // In such case, values of fThetaMin and fThetaMax are swapped
+
+    if (fThetaMin > fThetaMax)
+    {
+	Double_t tmp = fThetaMin;
+	fThetaMin = fThetaMax;
+	fThetaMax = tmp;
+    }
+
+    // Info for user
+    *fLog << "-------------------------------------------------"<< endl
+	  << "MFindSupercutsONOFFThetaLoop::SetThetaRange; " << endl
+	  << "Theta range for this iteration is set to "
+	  << fThetaMin << "-" << fThetaMax << " Radians." << endl 
+	  << "-------------------------------------------------"<< endl;
+    
+    return kTRUE;
+
+
+}
+
+
+Bool_t MFindSupercutsONOFFThetaLoop::SetNormFactorTrainHist()
+{
+    if (fCosThetaRangeVector.GetSize() <= 1)
+    {
+        *fLog << err << "MFindSupercutsONOFFThetaLoop::SetNormFactorTrainHist: " 
+	      << endl
+	      << "Size of fCosThetaRangeVector is <=1 ... fCosThetaRangeVector must exist and have, at least, 2 components defining a single bin"
+	      << endl;
+        return kFALSE;
+    }
+
+    
+    Int_t HistoNbins = fCosThetaRangeVector.GetSize() - 1;
+    Double_t* BinsVector = fCosThetaRangeVector.GetArray();
+
+    fNormFactorTrainHist = new TH1F ("NormFactorTrainHist",
+				     "NormFactorTrainHist",
+				     HistoNbins,BinsVector );
+
+    return kTRUE;
+
+}
+
+
+Bool_t MFindSupercutsONOFFThetaLoop::SetNormFactorTestHist()
+{
+    if (fCosThetaRangeVector.GetSize() <= 1)
+    {
+        *fLog << err << "MFindSupercutsONOFFThetaLoop::SetNormFactorTestHist: " 
+	      << endl
+	      << "Size of fCosThetaRangeVector is <=1 ... fCosThetaRangeVector must exist and have, at least, 2 components defining a single bin"
+	      << endl;
+        return kFALSE;
+    }
+
+
+    Int_t HistoNbins = fCosThetaRangeVector.GetSize() - 1;
+    Double_t* BinsVector = fCosThetaRangeVector.GetArray();
+
+    fNormFactorTestHist = new TH1F ("NormFactorTestHist",
+				     "NormFactorTestHist",
+				     HistoNbins, BinsVector);
+
+    return kTRUE;
+}
+
+
+Bool_t MFindSupercutsONOFFThetaLoop::SetSigmaLiMaTrainHist()
+{
+    if (fCosThetaRangeVector.GetSize() <= 1)
+    {
+        *fLog << err << "MFindSupercutsONOFFThetaLoop::SetSigmaLiMaTrainHist: " 
+	      << endl
+	      << "Size of fCosThetaRangeVector is <=1 ... fCosThetaRangeVector must exist and have, at least, 2 components defining a single bin"
+	      << endl;
+        return kFALSE;
+    }
+
+
+    // At some point, definition of bins should be able to 
+    // contain variable bins...
+
+    Int_t HistoNbins = fCosThetaRangeVector.GetSize() - 1;
+    
+    Double_t* BinsVector = fCosThetaRangeVector.GetArray();
+
+    fSigmaLiMaTrainHist = new TH1F ("SigmaLiMaTrainHist",
+				     "SigmaLiMaTrainHist",
+				     HistoNbins, BinsVector);
+
+    return kTRUE;
+}
+
+
+
+Bool_t MFindSupercutsONOFFThetaLoop::SetSigmaLiMaTestHist()
+{
+    if (fCosThetaRangeVector.GetSize() <= 1)
+    {
+        *fLog << err << "MFindSupercutsONOFFThetaLoop::SetSigmaLiMaTestHist: " 
+	      << endl
+	      << "Size of fCosThetaRangeVector is <=1 ... fCosThetaRangeVector must exist and have, at least, 2 components defining a single bin"
+	      << endl;
+        return kFALSE;
+    }
+
+
+   
+    Int_t HistoNbins = fCosThetaRangeVector.GetSize() - 1;
+    
+    Double_t* BinsVector = fCosThetaRangeVector.GetArray();
+    fSigmaLiMaTestHist = new TH1F ("SigmaLiMaTestHist",
+				     "SigmaLiMaTestHist",
+				     HistoNbins, BinsVector);
+
+    return kTRUE;
+
+}
+
+
+Bool_t MFindSupercutsONOFFThetaLoop::SetNexTrainHist()
+{
+    if (fCosThetaRangeVector.GetSize() <= 1)
+    {
+        *fLog << err << "MFindSupercutsONOFFThetaLoop::SetNexTrainHist: " 
+	      << endl
+	      << "Size of fCosThetaRangeVector is <=1 ... fCosThetaRangeVector must exist and have, at least, 2 components defining a single bin"
+	      << endl;
+        return kFALSE;
+    }
+
+
+    Int_t HistoNbins = fCosThetaRangeVector.GetSize() - 1;
+    
+    Double_t* BinsVector = fCosThetaRangeVector.GetArray();
+
+    fNexTrainHist = new TH1F ("NexTrainHist",
+			      "NexTrainHist",
+			      HistoNbins, BinsVector);
+
+    return kTRUE;
+
+}
+
+
+Bool_t MFindSupercutsONOFFThetaLoop::SetNexTestHist()
+{
+    if (fCosThetaRangeVector.GetSize() <= 1)
+    {
+        *fLog << err << "MFindSupercutsONOFFThetaLoop::SetNexTestHist: " 
+	      << endl
+	      << "Size of fCosThetaRangeVector is <=1 ... fCosThetaRangeVector must exist and have, at least, 2 components defining a single bin"
+	      << endl;
+        return kFALSE;
+    }
+
+
+    Int_t HistoNbins = fCosThetaRangeVector.GetSize() - 1;
+    Double_t* BinsVector = fCosThetaRangeVector.GetArray();
+
+    fNexTestHist = new TH1F ("NexTestHist",
+			     "NexTestHist",
+			     HistoNbins, BinsVector);
+
+    return kTRUE;
+
+}
+
+Bool_t MFindSupercutsONOFFThetaLoop::SetSuccessfulThetaBinsHist()
+{
+    if (fCosThetaRangeVector.GetSize() <= 1)
+    {
+        *fLog << err << "MFindSupercutsONOFFThetaLoop::SetSuccessfulThetaBinsHist(): " 
+	      << endl
+	      << "Size of fCosThetaRangeVector is <=1 ... "
+	      << "fCosThetaRangeVector must exist and have >= 2 components (defining a single bin)"
+	      << endl;
+        return kFALSE;
+    }
+
+
+    Int_t HistoNbins = fCosThetaRangeVector.GetSize() - 1;
+    Double_t* BinsVector = fCosThetaRangeVector.GetArray();
+
+    fSuccessfulThetaBinsHist = new TH1F ("SuccessfulThetaBinsHist",
+					 "SuccessfulThetaBinsHist",
+					 HistoNbins, BinsVector);
+
+    return kTRUE;
+
+}
+
+
+
+
+Bool_t MFindSupercutsONOFFThetaLoop::SetNexSigmaLiMaNormFactorNEvtsTrainTestHist()
+{
+    if (fCosThetaRangeVector.GetSize() <= 1)
+    {
+        *fLog << err 
+	      << "MFindSupercutsONOFFThetaLoop::SetNexSigmaLiMaNormFactorTrainTestHist: " 
+	      << endl
+	      << "Size of fCosThetaRangeVector is <=1 ... " 
+	      << "fCosThetaRangeVector must exist and have, at least, "
+	      << "2 components defining a single bin"
+	      << endl;
+        return kFALSE;
+    }
+
+
+    Int_t HistoNbins = fCosThetaRangeVector.GetSize() - 1;
+    
+    Double_t* BinsVector = fCosThetaRangeVector.GetArray();
+
+    char* x_axis_title = {"Cos(Theta)"};
+
+    fNormFactorTrainHist = new TH1F ("NormFactorTrainHist",
+				     "NormFactorTrainHist",
+				     HistoNbins, BinsVector);
+
+    
+    fNormFactorTrainHist -> SetXTitle(x_axis_title);
+    fNormFactorTrainHist -> SetYTitle("Normalization Factor (Non/Noff)");
+    
+
+    fNormFactorTestHist = new TH1F ("NormFactorTestHist",
+				     "NormFactorTestHist",
+				     HistoNbins, BinsVector);
+
+    fNormFactorTestHist -> SetXTitle(x_axis_title);
+    fNormFactorTestHist -> SetYTitle("Normalization Factor (Non/Noff)");
+
+    fSigmaLiMaTrainHist = new TH1F ("SigmaLiMaTrainHist",
+				     "SigmaLiMaTrainHist",
+				     HistoNbins, BinsVector);
+
+    fSigmaLiMaTrainHist -> SetXTitle(x_axis_title);
+    fSigmaLiMaTrainHist -> SetYTitle("Significance");
+
+
+    fSigmaLiMaTestHist = new TH1F ("SigmaLiMaTestHist",
+				   "SigmaLiMaTestHist",
+				   HistoNbins, BinsVector);
+
+    fSigmaLiMaTestHist -> SetXTitle(x_axis_title);
+    fSigmaLiMaTestHist -> SetYTitle("Significance");
+
+
+
+    fNexTrainHist = new TH1F ("NexTrainHist",
+			      "NexTrainHist",
+			      HistoNbins, BinsVector);
+
+    fNexTrainHist -> SetXTitle(x_axis_title);
+    fNexTrainHist -> SetYTitle("Excess Events");
+
+
+    fNexTestHist = new TH1F ("NexTestHist",
+			     "NexTestHist",
+			     HistoNbins, BinsVector);
+
+    fNexTestHist -> SetXTitle(x_axis_title);
+    fNexTestHist -> SetYTitle("Excess Events");
+
+
+
+    fNEvtsInTrainMatrixONHist = new TH1F("NEvtsInTrainMatrixONHist",
+					 "NEvtsInTrainMatrixONHist", 
+					 HistoNbins, BinsVector);
+
+
+    fNEvtsInTrainMatrixONHist -> SetXTitle(x_axis_title);
+    fNEvtsInTrainMatrixONHist -> SetYTitle("Number of ON Events");
+    
+
+    fNEvtsInTestMatrixONHist = new TH1F("NEvtsInTestMatrixONHist",
+					 "NEvtsInTestMatrixONHist", 
+					 HistoNbins, BinsVector);
+
+    fNEvtsInTestMatrixONHist -> SetXTitle(x_axis_title);
+    fNEvtsInTestMatrixONHist -> SetYTitle("Number of ON Events");
+    
+
+    fNEvtsInTrainMatrixOFFHist = new TH1F("NEvtsInTrainMatrixOFFHist",
+					  "NEvtsInTrainMatrixOFFHist", 
+					  HistoNbins, BinsVector);
+
+    fNEvtsInTrainMatrixOFFHist -> SetXTitle(x_axis_title);
+    fNEvtsInTrainMatrixOFFHist -> SetYTitle("Number of OFF Events");
+
+
+    fNEvtsInTestMatrixOFFHist = new TH1F("NEvtsInTestMatrixOFFHist",
+					 "NEvtsInTestMatrixOFFHist", 
+					 HistoNbins, BinsVector);
+
+    fNEvtsInTestMatrixOFFHist -> SetXTitle(x_axis_title);
+    fNEvtsInTestMatrixOFFHist -> SetYTitle("Number of OFF Events");
+    
+
+    // Histograms references are removed from the current directory
+
+    /* IT DOES NOT WORK !!! THESE STATEMENTS PRODUCE SEGMENTATION FAULT.
+    fNormFactorTrainHist -> SetDirectory(NULL);
+    
+    fNormFactorTestHist -> SetDirectory(NULL);
+    
+    fSigmaLiMaTrainHist -> SetDirectory(NULL);
+    
+    fSigmaLiMaTestHist -> SetDirectory(NULL);
+    
+    fSigmaLiMaTestHist -> SetDirectory(NULL);
+    
+    fNexTestHist -> SetDirectory(NULL);
+    */
+
+
+    return kTRUE;
+
+}
+
+void MFindSupercutsONOFFThetaLoop::WriteSuccessfulThetaBinsHistToFile()
+{
+    *fLog << "MFindSupercutsONOFFThetaLoop : Writing histogram "
+	  << " 'SuccessfulThetaBinsHist'"
+	  << " (if contents != 0) into root file " 
+	  << fAlphaDistributionsRootFilename << endl;
+
+    TFile rootfile(fAlphaDistributionsRootFilename, "UPDATE",
+		   "Alpha Distributions for several Theta bins");
+
+
+    if (fSuccessfulThetaBinsHist)
+    {
+	if (fSuccessfulThetaBinsHist->GetEntries() > 0.5)
+	    fSuccessfulThetaBinsHist -> Write();
+    }
+
+
+    rootfile.Close();
+
+}
+
+void MFindSupercutsONOFFThetaLoop::WriteNexSigmaLiMaNormFactorNEvtsTrainTestHistToFile()
+{
+
+    *fLog << "MFindSupercutsONOFFThetaLoop : Writing histograms 'NexSigmaLiMaNormFactorNEvtsTrainTest'"
+	  << " (if they have contents != 0) into root file " 
+	  << fAlphaDistributionsRootFilename << endl;
+
+    TFile rootfile(fAlphaDistributionsRootFilename, "UPDATE",
+		   "Alpha Distributions for several Theta bins");
+
+
+    if (fNormFactorTrainHist)
+    {
+	if (fNormFactorTrainHist->GetEntries() > 0.5)
+	    fNormFactorTrainHist -> Write();
+    }
+
+    if (fNormFactorTestHist)
+    {
+	if (fNormFactorTestHist->GetEntries() > 0.5)
+	    fNormFactorTestHist -> Write();
+    }
+
+    if (fSigmaLiMaTrainHist)
+    {
+	if (fSigmaLiMaTrainHist->GetEntries() > 0.5)
+	    fSigmaLiMaTrainHist -> Write();
+    }
+
+    if (fSigmaLiMaTestHist)
+    {
+	if (fSigmaLiMaTestHist->GetEntries() > 0.5)
+	    fSigmaLiMaTestHist -> Write();
+    }
+
+    if (fNexTrainHist)
+    {
+	if (fNexTrainHist->GetEntries() > 0.5)
+	    fNexTrainHist -> Write();
+    }
+
+    if (fNexTestHist)
+    {
+	if (fNexTestHist->GetEntries() > 0.5)
+	    fNexTestHist -> Write();
+    }
+   
+
+    if (fNEvtsInTrainMatrixONHist)
+    {
+	if (fNEvtsInTrainMatrixONHist->GetEntries() > 0.5)
+	    fNEvtsInTrainMatrixONHist -> Write();
+    }
+
+    if (fNEvtsInTestMatrixONHist)
+    {
+	if (fNEvtsInTestMatrixONHist->GetEntries() > 0.5)
+	    fNEvtsInTestMatrixONHist -> Write();
+    }
+    
+    if (fNEvtsInTrainMatrixOFFHist)
+    {
+	if (fNEvtsInTrainMatrixOFFHist->GetEntries() > 0.5)
+	    fNEvtsInTrainMatrixOFFHist -> Write();
+    }
+
+
+    if (fNEvtsInTestMatrixOFFHist)
+    {
+	if (fNEvtsInTestMatrixOFFHist->GetEntries() > 0.5)
+	    fNEvtsInTestMatrixOFFHist -> Write();
+    }
+
+
+    rootfile.Close();
+
+}
+
+void  MFindSupercutsONOFFThetaLoop::SetFractionTrainTestOnOffEvents(
+    Double_t fontrain, 
+    Double_t fontest, 
+    Double_t fofftrain,
+    Double_t fofftest)
+{
+
+    fWhichFractionTrain = fontrain;
+    fWhichFractionTest = fontest;
+    fWhichFractionTrainOFF = fofftrain;
+    fWhichFractionTestOFF = fofftest;
+
+
+}
+
+void MFindSupercutsONOFFThetaLoop::SetReadMatricesFromFile (Bool_t b)
+{
+
+    *fLog << "---------------------------------------------------" << endl
+	  << "MFindSupercutsONOFFThetaLoop: " << endl;
+
+    if (b)
+    {	*fLog  << "Matrices are read from root files." << endl;}
+    else
+    {   *fLog  << "Matrices are produced and stored into root files." 
+	       << endl;
+    }
+
+
+    fReadMatricesFromFile = b;
+}
+
+Bool_t MFindSupercutsONOFFThetaLoop::SetAlphaDistributionsRootFilename(
+    const TString &name)
+{
+
+    if (fPathForFiles.IsNull())
+    {
+	*fLog << err 
+	      << "MFindSupercutsONOFFThetaLoop::SetAlphaDistributionsRootFilename; " 
+	      << endl
+	      << "fPathForFiles is not defined yet, hence "
+	      << "name for rootfile containing alpha distributions " 
+	      << "can not be defined properly" << endl;
+
+	return kFALSE;
+    }
+
+    
+    fAlphaDistributionsRootFilename = (fPathForFiles);
+    fAlphaDistributionsRootFilename += (name);
+
+
+    *fLog << "MFindSupercutsONOFFThetaLoop: fAlphaDistributionsRootFilename = "
+	  << fAlphaDistributionsRootFilename << endl;
+
+
+    return kTRUE;
+
+
+}
+
+// Function to set Names of root files containing matrices and  
+// optimizedparameters and also fThetaRangeStringVector vector
+
+Bool_t MFindSupercutsONOFFThetaLoop::SetALLNames()
+{
+    // Names for files only possible if CosThetaRangeVector 
+    // is defined properly
+    if (fCosThetaRangeVector.GetSize() < 2)
+    {
+        *fLog << err 
+	      << "MFindSupercutsONOFFThetaLoop::SetALLNames; " 
+	      << endl
+	      << "Size of fCosThetaRangeVector is smaller than 2... "
+	      << "fCosThetaRangeVector is not defined properly, "
+	      << "and thus, names for rootfiles containing data matrices "
+	      << "and optimized parameters for the different theta "
+	      << "ranges can not defined properly." << endl;
+ 
+        return kFALSE;
+    }
+
+    if (fPathForFiles.IsNull())
+    {
+	*fLog << err 
+	      << "MFindSupercutsONOFFThetaLoop::Setnames; " 
+	      << endl
+	      << "fPathForFiles is not defined yet, hence "
+	      << "names for rootfiles containing data matrices "
+	      << "and optimized parameters for the different theta "
+	      << "ranges can not defined properly." << endl;
+
+	return kFALSE;
+    }
+
+
+     // Name of rootfiles for Supercuts parameters follow the 
+    // follwing structure
+
+    // Path + "OptSCParametersONOFF" + "ThetaRange" 
+    // + int {(fThetaMin_fThetaMax)*1000} + ".root"
+
+
+    // Name of rootfiles for Matrices follow the follwing structure
+
+    // Path + "ON(OFF)Data" + "Train(Test)" + "Matrix" + Fraction 
+    // + "ThetaRange" + int {(fThetaMin_fThetaMax)*1000} + ".root"
+
+
+    Int_t tmpdim = fCosThetaRangeVector.GetSize() - 1;
+    const Int_t VectorDimension = tmpdim;
+
+    fThetaRangeStringVector = new TString[VectorDimension];
+
+    fOptSCParamFilenameVector = new TString[VectorDimension];
+
+    fTrainMatrixONFilenameVector = new TString[VectorDimension];
+    fTestMatrixONFilenameVector = new TString[VectorDimension];
+    fTrainMatrixOFFFilenameVector = new TString[VectorDimension];
+    fTestMatrixOFFFilenameVector = new TString[VectorDimension];
+
+
+    Int_t ThetaMinTimes1000 = 0;
+    Int_t ThetaMaxTimes1000 = 0;
+    Int_t FractionONTrainTimes100 = 0;
+    Int_t FractionONTestTimes100 = 0;
+    Int_t FractionOFFTrainTimes100 = 0;
+    Int_t FractionOFFTestTimes100 = 0;
+
+    char ThetaRangeString[100];
+
+    for (Int_t i = 0; i < VectorDimension; i++)
+    {
+	if (!SetThetaRange(i+1))
+	{
+	    *fLog << "MFindSupercutsONOFFThetaLoop::SetALLNames; " 
+		  << endl
+		  << "Values for fThetaMin and fThetaMax could NOT "
+		  << "be computed for theta bin " 
+		  << (i+1) << "; SetNames can not go on successfully."
+		  << endl;
+
+	    return kFALSE;
+	}
+	
+	
+	ThetaMinTimes1000 = int(fThetaMin*1000);
+	ThetaMaxTimes1000 = int(fThetaMax*1000);
+	sprintf(ThetaRangeString, "ThetaRange%d_%dmRad", 
+		ThetaMinTimes1000, ThetaMaxTimes1000);
+
+	fThetaRangeStringVector[i] = (ThetaRangeString);
+	
+	// tmp
+	*fLog << "ThetaRangeString = " << fThetaRangeStringVector[i] << endl;
+	// endtmp
+
+	Double_t tmpdouble = 0.0;
+	tmpdouble = fWhichFractionTrain*100 - int(fWhichFractionTrain*100); 
+	
+	FractionONTrainTimes100 = tmpdouble < 0.5 ? int(fWhichFractionTrain*100):
+	    int(fWhichFractionTrain*100) + 1;
+	
+
+	tmpdouble = fWhichFractionTest*100 - int(fWhichFractionTest*100);
+
+	FractionONTestTimes100 = tmpdouble < 0.5 ? int(fWhichFractionTest*100):
+	    int(fWhichFractionTest*100) + 1;
+	
+	tmpdouble = fWhichFractionTrainOFF*100 - int(fWhichFractionTrainOFF*100);
+
+	FractionOFFTrainTimes100 = tmpdouble < 0.5 ? int(fWhichFractionTrainOFF*100):
+	    int(fWhichFractionTrainOFF*100) + 1;
+
+	tmpdouble = fWhichFractionTestOFF*100 - int(fWhichFractionTestOFF*100);
+	FractionOFFTestTimes100 = tmpdouble < 0.5 ? int(fWhichFractionTestOFF*100):
+	    int(fWhichFractionTestOFF*100) + 1;
+	
+	
+
+	// File for SC parameters 
+	fOptSCParamFilenameVector[i] = (fPathForFiles);
+	fOptSCParamFilenameVector[i] += ("OptSCParametersONOFF");
+	fOptSCParamFilenameVector[i] += (fThetaRangeStringVector[i]);
+	fOptSCParamFilenameVector[i] += (".root");
+	
+	
+	
+	// File for Data Matrices
+
+	fTrainMatrixONFilenameVector[i] = (fPathForFiles);
+	fTrainMatrixONFilenameVector[i] += ("ONDataTrainMatrixFraction");
+	fTrainMatrixONFilenameVector[i] += (FractionONTrainTimes100);
+	fTrainMatrixONFilenameVector[i] += (fThetaRangeStringVector[i]);
+	fTrainMatrixONFilenameVector[i] += (".root");
+
+	fTestMatrixONFilenameVector[i] = (fPathForFiles);
+	fTestMatrixONFilenameVector[i] += ("ONDataTestMatrixFraction");
+	fTestMatrixONFilenameVector[i] += (FractionONTestTimes100);
+	fTestMatrixONFilenameVector[i] += (fThetaRangeStringVector[i]);
+	fTestMatrixONFilenameVector[i] += (".root");
+
+
+	fTrainMatrixOFFFilenameVector[i] = (fPathForFiles);
+	fTrainMatrixOFFFilenameVector[i] += ("OFFDataTrainMatrixFraction");
+	fTrainMatrixOFFFilenameVector[i] += (FractionOFFTrainTimes100);
+	fTrainMatrixOFFFilenameVector[i] += (fThetaRangeStringVector[i]);
+	fTrainMatrixOFFFilenameVector[i] += (".root");
+
+	fTestMatrixOFFFilenameVector[i] = (fPathForFiles);
+	fTestMatrixOFFFilenameVector[i] += ("OFFDataTestMatrixFraction");
+	fTestMatrixOFFFilenameVector[i] += (FractionOFFTestTimes100);
+	fTestMatrixOFFFilenameVector[i] += (fThetaRangeStringVector[i]);
+	fTestMatrixOFFFilenameVector[i] += (".root");
+
+    }
+    // Info concerning names is printed
+    
+    *fLog << "--------------------------------------------------" << endl
+	  << "MFindSupercutsONOFFThetaLoop::Setnames; " 
+	  << endl
+	  << "Names for root files containing Opt SC Param. and Data "
+	  << "matrices for the different theta bins are the "
+	  << "following ones: " << endl
+	  << "MeanCosTheta, OptSCParm, ONDataTrainMatrix, ..." << endl;
+    
+    for (Int_t i = 0; i < VectorDimension; i++)
+    {
+	*fLog << fCosThetaBinCenterVector[i] << ",  " << endl
+	      << fOptSCParamFilenameVector[i] << ",  "<< endl
+	      << fTrainMatrixONFilenameVector[i] << ",  " << endl
+	      << fTestMatrixONFilenameVector[i] << ",  " << endl
+	      << fTrainMatrixOFFFilenameVector[i] << ",  " << endl
+	      << fTestMatrixOFFFilenameVector[i] << ",  " << endl
+	      << endl << endl;
+    }
+    
+    *fLog << "--------------------------------------------------" << endl;
+    
+    return kTRUE;
+    
+}
+
+
+
+Bool_t MFindSupercutsONOFFThetaLoop::LoopOverThetaRanges()
+{
+
+
+    *fLog << "--------------------------------------------------------------" << endl
+	  << "MFindSupercutsONOFFThetaLoop::LoopOverThetaRanges function starts " 
+	  << endl;
+	  
+
+
+    if (fDataONRootFilename.IsNull())
+    {
+      *fLog << "MFindSupercutsONOFF::LoopOverThetaRanges; root file for ON data is not defined... " 
+	    << "aborting..."
+            << endl;
+      return kFALSE;
+    }
+
+
+    if (fDataOFFRootFilename.IsNull())
+    {
+      *fLog << "MFindSupercutsONOFF:: LoopOverThetaRanges; root file for OFF data is not defined... aborting"
+            << endl;
+      return kFALSE;
+    }
+
+    
+    if (fHadronnessName.IsNull())
+    {
+      *fLog << "MFindSupercutsONOFF::LoopOverThetaRanges; hadronness name for ON data is not defined... aborting"
+            << endl;
+      return kFALSE;
+    }
+
+
+    if (fHadronnessNameOFF.IsNull())
+    {
+      *fLog << "MFindSupercutsONOFF::LoopOverThetaRanges; hadronness name for OFF data is not defined... aborting"
+            << endl;
+      return kFALSE;
+    }
+
+
+    if (fCosThetaRangeVector.GetSize() < 2)
+	
+    {
+	*fLog << "MFindSupercutsONOFFThetaLoop::LoopOverThetaRanges; " << endl
+	      << "Dimension of vector fCosThetaRangeVector " 
+	      << "is smaller than 2" 
+	      << "Theta ranges are not well defined... aborting ..." << endl;
+	
+	return kFALSE;
+    }
+
+
+    // Check if pointers to root file names (opt SC parameters and matrices) 
+    // are empty
+
+
+    if (!fTrainMatrixONFilenameVector || 
+	!fTestMatrixONFilenameVector ||
+	!fTrainMatrixOFFFilenameVector ||
+	!fTestMatrixOFFFilenameVector ||
+	!fOptSCParamFilenameVector)
+    {
+	*fLog << "MFindSupercutsONOFFThetaLoop::LoopOverThetaRanges; " << endl
+	      << "Pointers to root files names for Opt SC parameters and data "
+	      << "matrices are not well defined. Aborting... " << endl;
+
+	return kFALSE;
+    }
+
+
+    if (fAlphaDistributionsRootFilename.IsNull())
+    {
+	*fLog << "MFindSupercutsONOFFThetaLoop::LoopOverThetaRanges; " << endl
+	      << "Root filename where to store alpha distributions "
+	      << "(fAlphaDistributionsRootFilename) is not defined." << endl
+	      << "Loop over theta angles can not go on..." << endl;
+
+	return kTRUE;
+    }
+
+
+    
+	
+    if (!fPsFilename)
+    {
+	*fLog << "MFindSupercutsONOFFThetaLoop::LoopOverThetaRanges; " << endl
+	      << "Object from Class TPostScript is not defined. "
+	      << "Plots will be stored in a a file named 'PsFilesTmp.ps' located "
+	      << "in current directory" << endl;
+
+	// fPsFilename = new TPostScript("PsFilesTmp.ps" ,111);
+
+
+    }
+
+
+    
+
+
+
+    // All drinks are in house... the party starts !!
+
+    Int_t ThetaLoopIterations = fCosThetaRangeVector.GetSize() - 1;
+                                
+    *fLog << "looping over the following Cos Theta Angle Ranges : "<< endl;
+    for (Int_t i = 0; i < ThetaLoopIterations; i++)
+    {
+	*fLog << i+1 << " -> " 
+	      << fCosThetaRangeVector[i] << "-" << fCosThetaRangeVector[i+1] 
+	      << endl;
+    }
+	  
+    *fLog << "--------------------------------------------------------------------" 
+	  << endl;
+
+
+
+    // Let's create histograms where SigmaLiMa, Nex and Normfactors will be stored
+
+    if (!SetNexSigmaLiMaNormFactorNEvtsTrainTestHist())
+    {
+	*fLog << "MFindSupercutsONOFFThetaLoop::LoopOverThetaRanges; " << endl
+	      << "Histograms where to store Significances, Nex and Normalization "
+	      << "factors, NEvts for all theta bins could not be created... Aborting."
+	      << endl;
+
+	return kFALSE;
+    }
+
+
+    // Let's create histogram where successfully optimized theta bins will be stored
+
+    if (!SetSuccessfulThetaBinsHist())
+    {
+	*fLog << "MFindSupercutsONOFFThetaLoop::LoopOverThetaRanges; " << endl
+	      << "Histogram where to store successfully optimized theta bins "
+	      << " could not be created... Aborting."
+	      << endl;
+
+	return kFALSE;
+    }
+
+
+    
+
+
+    Double_t NormFactor = 0.0;
+    Double_t Nex = 0.0;
+    Double_t SigmaLiMa = 0.0;
+    Int_t NEvtsON = 0;
+    Int_t NEvtsOFF = 0;
+    
+    Bool_t MinimizationSuccessful = kTRUE;
+    Double_t MinimizationValue = 1.0; // Value quantifying the minimization, and stored in 
+    // histogram fSuccessfulThetaBinsHist. For the time being it is 0.0 (minimization failed). 
+    // and 1.0 (minimization succeeded). Yet in future it may take other values quantifying 
+    // other aspects...
+
+
+    for (Int_t i = 0; i < ThetaLoopIterations; i++)
+    {
+
+	// Get the Theta range that will be used in this iteration
+	// Remember that argument of the function is iteration number, 
+	// and it starts at 1...
+
+	if (!SetThetaRange(i+1))
+	{
+	    *fLog << "MFindSupercutsONOFFThetaLoop::LoopOverThetaRanges; " 
+		  << endl
+		  << "Values for fThetaMin and fThetaMax could NOT "
+		  << "be computed for theta bin " 
+		  << (i+1) << ";  LoopOverThetaRanges is aborting."
+		  << endl;
+
+	    return kFALSE;
+	}
+	
+
+
+	// Object of class MFindSupercutsONOFF will be created and used 
+
+
+	MFindSupercutsONOFF FindSupercuts("MFindSupercutsONOFF", 
+					     "Optimizer for the supercuts");
+
+	
+	// Set Theta range that will be used
+	FindSupercuts.SetThetaRange(fThetaMin, fThetaMax);
+
+
+	// Alphamax where signal is expected is set
+	FindSupercuts.SetAlphaSig(fAlphaSig);
+
+	// Bkg alpha region is set 
+	FindSupercuts.SetAlphaBkgMin(fAlphaBkgMin);
+	FindSupercuts.SetAlphaBkgMax(fAlphaBkgMax);
+
+	// alpha bkg and signal region set in object FindSupercuts
+	// are re-checked in order to be sure that make sense
+	
+	FindSupercuts.CheckAlphaSigBkg();
+
+
+	// bining for alpha plots is set 
+	
+	FindSupercuts.SetAlphaPlotBinining(fNAlphaBins, fAlphaBinLow, fAlphaBinUp);
+
+
+
+	
+	// Bool variable NormFactorFromAlphaBkg is set in FindSupercuts
+	// in order to decide the way in which mormalization factors
+	// for TRAIN and TEST samples are computed
+
+
+	FindSupercuts.SetNormFactorFromAlphaBkg(fNormFactorFromAlphaBkg);
+
+
+	// Define size range of events used to fill the data matrices
+
+	FindSupercuts.SetSizeRange(fSizeCutLow, fSizeCutUp);
+
+
+
+	
+	// Boolean variable that controls wether the optimization of the 
+	// parameters (MMinuitInterface::CallMinuit(..) in function FindParams(..))
+	// takes place or not. kTRUE will skip such optimization.
+	// This variable is useful to test the optmized parameters (previously found 
+	// and stored in root file) on the TRAIN sample.
+
+	FindSupercuts.SetSkipOptimization(fSkipOptimization);
+
+	// Boolean variable that allows the user to write the initial parameters 
+	// into the root file that will be used to store the optimum cuts.
+	// If fUseInitialSCParams = kTRUE , parameters are written.
+	// In this way, the initial SC parameters can be applied on the data (train/test)
+
+	FindSupercuts.SetUseInitialSCParams(fUseInitialSCParams);
+
+
+        // Set boolean variable that controls wether the theta variable 
+	// is used or not in the computation of the dynamica cuts
+
+	FindSupercuts.SetVariableNotUseTheta(fNotUseTheta);
+
+	// Set boolean variable that controls wether cuts are dynamical 
+	// or static.
+
+	FindSupercuts.SetVariableUseStaticCuts(fUseStaticCuts);
+
+	
+	FindSupercuts.SetUseFittedQuantities(fUseFittedQuantities);
+
+	                                        
+	// fGammaEfficiency is set in object FindSupercuts
+
+	FindSupercuts.SetGammaEfficiency (fGammaEfficiency);
+
+
+	// Filename with SuperCuts parameters is set
+
+	FindSupercuts.SetFilenameParam(fOptSCParamFilenameVector[i]);
+
+	// Hadroness containers are set
+	
+	FindSupercuts.SetHadronnessName(fHadronnessName);
+	FindSupercuts.SetHadronnessNameOFF(fHadronnessNameOFF);
+    
+	// Rootfilename where to store alpha distribution histograms is set
+
+	FindSupercuts.SetAlphaDistributionsRootFilename(fAlphaDistributionsRootFilename);
+
+
+	// Set the names of all trees 
+        // used to store the supercuts applied to ON/OFF Train/Test samples
+
+	// In future, names might be controlled by user, but for the time 
+	// being I'll make things simple, and names are set to some defaults 
+	// taking into account the theta range used
+	
+	// Containers will be stored in rootfile specified by variable 
+	// fAlphaDistributionsRootFilename
+
+	FindSupercuts.SetSupercutsAppliedTreeNames();
+
+
+
+
+
+	// Object of the class TPostScritp is set...
+	// BUT THAT'S NOT WORKING PROPERLY !!!!!
+
+	// FindSupercuts.SetPostScriptFile (fPsFilename);
+
+	// ********************************************************
+	// Due to the failure of the use of object TPostScript
+	// to make a Ps document with all plots, I decided to use the 
+	// standard way (SaveAs(filename.ps)) to store plots related 
+	// to alpha distributions 
+	// for ON and OFF and BEFORE and AFTER cuts (VERY IMPORTANT
+	// TO COMPUTE EFFICIENCIES IN CUTS) 
+
+	// Psfilename is set inside function LoopOverThetaRanges()
+	// and given to the object MFindSupercutsONOFF created 
+	// within this loop.
+
+	// This will have to be removed as soon as the TPostScript
+	// solutions works...
+	// ********************************************************
+
+	TString PsFilenameString = (fPathForFiles);
+	PsFilenameString += ("SC");
+	PsFilenameString += (fThetaRangeStringVector[i]);
+	// Name to be completed inside object MFindSupercutsONOFF
+
+	FindSupercuts.SetPsFilenameString(PsFilenameString);
+
+
+	if (fReadMatricesFromFile)
+	{
+	    *fLog << "MFindSupercutsONOFFThetaLoop::LoopOverThetaRanges; " << endl
+		  << "Reading Data matrices from root files... " << endl;
+
+	    FindSupercuts.ReadMatrix(fTrainMatrixONFilenameVector[i], 
+				     fTestMatrixONFilenameVector[i]);
+	    FindSupercuts.ReadMatrixOFF(fTrainMatrixOFFFilenameVector[i], 
+					fTestMatrixOFFFilenameVector[i]);
+
+	}
+
+	else
+	{
+	    *fLog << "MFindSupercutsONOFFThetaLoop::LoopOverThetaRanges; " << endl
+		  << "Reading Data from files " << fDataONRootFilename 
+		  << " and " << fDataOFFRootFilename << "(for ON and OFF data "
+		  << "respectively " 
+		  << " and producing data matrices that will be stored "
+		  << "in root files. " << endl;
+
+	    // ON data 
+	    
+	    FindSupercuts.DefineTrainTestMatrixThetaRange(
+		fDataONRootFilename,
+		fWhichFractionTrain,
+		fWhichFractionTest, 
+		fThetaMin, fThetaMax, 
+		fTrainMatrixONFilenameVector[i], 
+		fTestMatrixONFilenameVector[i]);
+
+	    // OFF data
+	    
+	    FindSupercuts.DefineTrainTestMatrixOFFThetaRange(
+		fDataOFFRootFilename,
+		fWhichFractionTrainOFF,
+		fWhichFractionTestOFF, 
+		fThetaMin, fThetaMax, 
+		fTrainMatrixOFFFilenameVector[i], 
+		fTestMatrixOFFFilenameVector[i]);
+	    
+	}
+
+
+	MinimizationSuccessful = kTRUE;
+	
+	if (fOptimizeParameters)
+	{
+	    MinimizationSuccessful = 
+		FindSupercuts.FindParams("",fInitSCPar, fInitSCParSteps); 
+	    
+	    if (MinimizationSuccessful)
+	    {
+		// Minimization was successful	
+		// NormFactor, Nex, SigmaLiMa and NEvts Train histograms are updated 
+
+		*fLog << "MFindSupercutsONOFFThetaLoop::LoopOverThetaRanges; " 
+		      << endl
+		      << "Minimization was successful" << endl
+		      << "Updating values for NormFactor, Nex, SigmaLiMa and NEvts " 
+		      << "Train histograms for " <<  fThetaRangeStringVector[i] << endl;
+		
+		
+		NormFactor = FindSupercuts.GetNormFactorTrain();
+		SigmaLiMa = FindSupercuts.GetSigmaLiMaTrain();
+		Nex = FindSupercuts.GetNexTrain();
+		
+		NEvtsON = FindSupercuts.GetMatrixTrain()->GetM().GetNrows();
+		NEvtsOFF = FindSupercuts.GetMatrixTrainOFF()->GetM().GetNrows();
+
+		// MinimizationValue is updated...
+
+		MinimizationValue = 1.0;		
+
+	    }
+	    else
+	    {
+		// Minimization was NOT successful	
+		// NormFactor, Nex, SigmaLiMa and NEvts Train histograms are updated 
+
+		*fLog << "MFindSupercutsONOFFThetaLoop::LoopOverThetaRanges; " 
+		      << endl
+		      << "Minimization was NOT successful" << endl
+		      << "Updating values for NormFactor, and NEvts " 
+		      << "Train histograms for " <<  fThetaRangeStringVector[i] << endl
+		      << "Nex and SigmaLiMa are set to ZERO" << endl;
+		
+		
+		NormFactor = FindSupercuts.GetNormFactorTrain();
+		
+		NEvtsON = FindSupercuts.GetMatrixTrain()->GetM().GetNrows();
+		NEvtsOFF = FindSupercuts.GetMatrixTrainOFF()->GetM().GetNrows();
+
+		SigmaLiMa = 0.0;
+		Nex = 0.0;
+		
+		// MinimizationValue is updated...
+
+		MinimizationValue = 0.0;
+
+	    }
+
+
+	    
+	    cout << "---- Train Histograms will be updated with the following numbers: ------ " 
+		 << endl
+		 << "Mean CosTheta for this Thetabin = " 
+		 << fCosThetaBinCenterVector[i] << endl
+		 << "Minimization status (1.0 is successful, 0.0 is UNsuccessful) = "
+		 << MinimizationValue << endl
+		 << "Number of ON Events in Train sample used = "
+		 << NEvtsON << endl
+		 << "Number of OFF Events in Train sample used = "
+		 << NEvtsOFF << endl
+		 << "Normalization factor (Non/Noff) for Train sample = "
+		 << NormFactor << endl 
+		 << "Excess events and SigmaLiMa: "
+		 << Nex << "; " << SigmaLiMa << endl << endl;
+		 
+	    
+
+	    fNormFactorTrainHist -> Fill(fCosThetaBinCenterVector[i], 
+					  NormFactor);
+	    
+	    fNexTrainHist -> Fill(fCosThetaBinCenterVector[i], 
+				   Nex);
+
+	    fSigmaLiMaTrainHist -> Fill(fCosThetaBinCenterVector[i], 
+					 SigmaLiMa);
+
+
+	    fNEvtsInTrainMatrixONHist -> Fill(fCosThetaBinCenterVector[i], 
+					 NEvtsON);
+
+	    fNEvtsInTrainMatrixOFFHist -> Fill(fCosThetaBinCenterVector[i], 
+						NEvtsOFF);
+
+	    
+	    fSuccessfulThetaBinsHist -> Fill(fCosThetaBinCenterVector[i],
+					     MinimizationValue);
+	    
+	    cout << "Histograms (TRAIN) updated successfully " << endl;
+	    
+
+	    
+	    
+	}
+	
+	
+	if (fTestParameters && MinimizationSuccessful)
+	{
+	    
+	    // Cuts are applied to test sample
+	    
+	    FindSupercuts.TestParamsOnTestSample();
+
+	    // NormFactor, Nex and SigmaLiMa Test histograms are updated 
+
+	    *fLog << "MFindSupercutsONOFFThetaLoop::LoopOverThetaRanges; " << endl
+		  << "Updating values for NormFactor, Nex, SigmaLiMa and NEvts " 		  
+		  << "Test histograms for " <<  fThetaRangeStringVector[i] << endl;
+
+
+	    NormFactor = FindSupercuts.GetNormFactorTest();
+	    SigmaLiMa = FindSupercuts.GetSigmaLiMaTest();
+	    Nex = FindSupercuts.GetNexTest();
+
+	    NEvtsON = FindSupercuts.GetMatrixTest()->GetM().GetNrows();
+	    NEvtsOFF = FindSupercuts.GetMatrixTestOFF()->GetM().GetNrows();
+
+
+       cout << "---- Test Histograms will be updated with the following numbers: ------ " 
+	    << endl
+		 << "Mean CosTheta for this Thetabin = " 
+		 << fCosThetaBinCenterVector[i] << endl
+		 << "Number of ON Events in Test sample used = "
+		 << NEvtsON << endl
+		 << "Number of OFF Events in Test sample used = "
+		 << NEvtsOFF << endl
+		 << "Normalization factor (Non/Noff) for Test sample = "
+		 << NormFactor << endl 
+		 << "Excess events and SigmaLiMa: "
+		 << Nex << "; " << SigmaLiMa << endl << endl;
+		 
+
+
+
+	    fNormFactorTestHist -> Fill(fCosThetaBinCenterVector[i], 
+					 NormFactor);
+	    
+	    fNexTestHist -> Fill(fCosThetaBinCenterVector[i], 
+				  Nex);
+
+	    fSigmaLiMaTestHist -> Fill(fCosThetaBinCenterVector[i], 
+				       SigmaLiMa);
+
+
+	    fNEvtsInTestMatrixONHist -> Fill(fCosThetaBinCenterVector[i], 
+					    NEvtsON);
+
+	    fNEvtsInTestMatrixOFFHist -> Fill(fCosThetaBinCenterVector[i], 
+					      NEvtsOFF);
+
+	    
+	    cout << "Histograms (TEST) updated successfully " << endl;
+	    
+
+
+
+	}
+
+    }
+
+
+    // PsFile is closed
+
+
+    //*fLog << "Closing PsFile ";
+    //*fLog << fPsFilename -> GetName() << endl;
+    
+    //fPsFilename -> Close();
+
+    
+
+    if (fOptimizeParameters || fTestParameters)
+    {
+	// Histograms cotanining SigmaLiMa, Nex and NormFactors and NEvts are written 
+	// in the same root file where alpha distributions where stored
+	// i.e. fAlphaDistributionsRootFilename
+	
+	*fLog << "MFindSupercutsONOFFThetaLoop::LoopOverThetaRanges; " << endl
+	      << "Executing WriteNexSigmaLiMaNormFactorNEvtsTrainTestHistToFile()"
+	      << endl;
+
+	WriteNexSigmaLiMaNormFactorNEvtsTrainTestHistToFile();
+
+
+	if (fOptimizeParameters)
+	{   // Histogram containing minimization status for all theta bins defined 
+	    // in vector fCosThetaVector is stored in file fAlphaDistributionsRootFilename
+
+	    *fLog << "MFindSupercutsONOFFThetaLoop::LoopOverThetaRanges; " << endl
+	      << "Executing WriteSuccessfulThetaBinsHistToFile()"
+	      << endl;
+
+	    WriteSuccessfulThetaBinsHistToFile();
+	    
+	}
+
+    }
+
+
+    return kTRUE;
+}
+
+
+
+
+
+ // Function that loops over the alpha distributions (ON-OFF)
+   // stored in root file defined by fAlphaDistributionsRootFilename
+   // and computes the significance and Nex (using MHFindSignificanceONOFF::FindSigma)
+   // for several cuts in alpha (0-fAlphaSig; in bins defined for alpha distributions 
+   // by user).
+
+   // It initializes the histograms (memeber data), fills them and store them 
+   // in root file defined by fAlphaDistributionsRootFilename. A single histogram 
+   // for each theta bin.
+
+
+
+Bool_t MFindSupercutsONOFFThetaLoop::ComputeNexSignificanceVSAlphaSig()
+{
+
+
+  *fLog << endl << endl 
+	<< "****************************************************************************" << endl
+	<< "Computing number of excess events and significance vs " << endl
+	<< " the cut in alpha parameter (fAlphaSig) using function " << endl
+	<< " MFindSupercutsONOFFThetaLoop::ComputeNexSignificanceVSAlphaSig() " << endl
+	<< "****************************************************************************" << endl
+	<< endl;
+  
+
+  // Check that all elements needed by the function are available
+ 
+
+  if (fAlphaDistributionsRootFilename.IsNull())
+    {
+	*fLog << err 
+	      << "MFindSupercutsONOFFThetaLoop::ComputeNexSignificanceVSAlphaSig; " 
+	      << endl
+	      << "fAlphaDistributionsRootFilename is not defined yet, hence "
+	      << "histograms  containing alpha distributions for the different theta "
+	      << "ranges can not be retrieved. " << endl;
+
+	return kFALSE;
+    }
+
+
+
+    if (fCosThetaRangeVector.GetSize() < 2)
+    {
+        *fLog << err 
+	      << "MFindSupercutsONOFFThetaLoop::ComputeNexSignificanceVSAlphaSig; " 
+	      << endl
+	      << "Size of fCosThetaRangeVector is smaller than 2... "
+	      << "fCosThetaRangeVector is not defined properly, "
+	      << "and thus, number of theta loops and names "
+	      << " of the histograms  containing alpha distributions "
+	      << "for the different theta "
+	      << "ranges can not defined properly." << endl;
+ 
+        return kFALSE;
+    }
+
+   
+
+    // It seems that i have all I need for the time being. Let's start the party...
+
+
+    Int_t tmpint =  0; // variable that will be used to store temporally integers 
+    Double_t tmpdouble = 0.0; // variable that will be used to store temporally doubles
+
+    tmpint = fCosThetaRangeVector.GetSize() - 1;
+    const Int_t NThetaBins = tmpint;
+ 
+
+    // Definition of the bins for Nex and Significance vs Alpha histograms
+    // The bins in Alpha will start with ZERO  and will end 
+    // with 5 bins further after fAlphaSig.
+
+    Double_t AlphaBinWidth = double((fAlphaBinUp-fAlphaBinLow)/fNAlphaBins);
+    Double_t FirstBinLow = 0.0;
+    tmpint = int((fAlphaSig/AlphaBinWidth) + 5.0);
+
+    while ((FirstBinLow + AlphaBinWidth*tmpint) > fAlphaBkgMin)
+      {
+	tmpint--;
+      }
+	
+    *fLog << "Information about the binning of the histograms Nex and Significance vs alphasig " 
+	  << endl
+	  << "FirstBinLow, AlphaBinWidth, NBins : " 
+	  << FirstBinLow << ", " << AlphaBinWidth << ", " << tmpint-1 << endl;
+
+
+
+    const Int_t NexSignVSAlphaXBinsVectorDimension = tmpint;
+                
+ 
+    Double_t* XBinsVector = new Double_t [NexSignVSAlphaXBinsVectorDimension];
+    
+    for (Int_t i = 0; i < NexSignVSAlphaXBinsVectorDimension; i++)
+      {
+	XBinsVector[i] = FirstBinLow + i*AlphaBinWidth;
+	// cout << XBinsVector[i] << endl;
+      }
+
+
+   
+    // Axis labels for Nex and Significance vs Alpha histograms
+
+    TString x_axis_label = ("Cut in alpha [\\circ]");
+    TString y_axis_label_nex = ("Excess Events");
+    TString y_axis_label_significance = ("Significance (LiMa formula 17)");
+
+
+    // Arguments for function MHFindSignificanceONOFF::FindSigmaONOFF()
+    // are defined in here. The same arguments (obviously) will be used 
+    // in all theta bins and TRAIN and TEST samples.
+
+    // variable alphasig will be defined and varied withing the theta loop
+
+    Double_t alphasig = 0.0;
+
+    // Minimum value of alpha for bkg region in ON data
+    const Double_t alphabkgmin = fAlphaBkgMin;
+    
+    // Maximum value of alpha for bkg region in ON data
+    const Double_t alphabkgmax = fAlphaBkgMax;
+    
+    // degree of polynomial function used to fit ON data in background region
+    const Int_t    degree   =    2;
+    
+    // degree of polynomial function used to fit OFF data in all alpha region (0-90)
+    const Int_t    degreeOFF   =    2;
+    
+    const Bool_t   drawpoly  = kFALSE;
+    const Bool_t   fitgauss  = kFALSE;
+    const Bool_t   print     = kFALSE;
+    
+    const Bool_t saveplots   = kFALSE; // No plots are saved
+   
+    const Bool_t RebinHistograms = kTRUE;
+    const Bool_t ReduceDegree = kFALSE;
+
+
+
+    Double_t Nex = 0.0;
+    Double_t Significance = 0.0;
+
+
+    // Names of histograms containing Nex and Significance vs alphasig
+
+    TString NexVSAlphaName = ("NexVSAlpha"); // Names to be completed in theta loop
+    TString SignificanceVSAlphaName = ("SignificanceVSAlpha");// Names to be completed in theta loop
+    
+
+
+    // Names of histograms to be retrieved from root file 
+    // fAlphaDistributionsRootFilename
+
+    TString NormFactorTrainHistoName = ("NormFactorTrainHist");
+    TString NormFactorTestHistoName = ("NormFactorTestHist");
+    
+    TString SuccessfulThetaBinsHistoName = ("SuccessfulThetaBinsHist");
+
+ 
+
+    // Histogram containing information about the success of the optimization
+    // for the several theta bins. The content of those bins where optimization was not 
+    // successful, are set to ZERO.
+
+    
+    TH1F* SuccessfulThetaBinsHisto;
+ 
+
+
+    // Histograms to store the normalization factors
+
+    TH1F* NormFactorTrainHisto;
+    TH1F* NormFactorTestHisto;
+
+
+
+    // Histograms that will be used to store the alpha distributions 
+    // retrieved from   fAlphaDistributionsRootFilename, and that will be use as arguments in 
+    // function MHFindSignificanceONOFF::FindSigma
+
+    // The same histograms (pointer to histograms actually) will be used for TRAIN and TEST 
+    // and for the different ThetaNBinsUsed.
+
+    TH1F* AlphaONAfterCuts;
+    TH1F* AlphaOFFAfterCuts;
+
+
+
+   
+      // Vector containing the histogram index of the successfully 
+    // optimized theta bins. 
+    // It is filled with the contents of the histogram 
+    // fSuccessfulThetaBinsHist retrieved from the root 
+    // file fAlphaDistributionsRootFilename
+    // Remember that histogram index START AT 1 !!!
+    TArrayI SuccessfulThetaBinsVector; 
+   
+
+
+    
+
+
+
+     // Open root file for retrieving information
+ 
+    *fLog << "MFindSupercutsONOFFThetaLoop::ComputeNexSignificanceVSAlphaSig()" << endl
+	  << "Opening root file " << fAlphaDistributionsRootFilename << endl;
+
+    TFile rootfile (fAlphaDistributionsRootFilename, "READ");
+
+    // Retrieving SuccessfulThetaBinsHisto from root file. 
+    
+    *fLog << "MFindSupercutsONOFFThetaLoop::ComputeNexSignificanceVSAlphaSig()" << endl
+	  << "Retrieving SuccessfulThetaBinsHisto from root file and filling vector "
+	  << " SuccessfulThetaBinsVector" << endl;
+
+                                    
+    cout << "Getting histogram with name " << SuccessfulThetaBinsHistoName << endl;
+
+    SuccessfulThetaBinsHisto = (TH1F*) rootfile.Get(SuccessfulThetaBinsHistoName);
+    
+
+
+    // Check that bins in this histo correspond with the 
+    // CosTheta intervals defined by vector fCosThetaRangeVector
+
+	
+    if (SuccessfulThetaBinsHisto -> GetNbinsX() != NThetaBins)
+    {
+	*fLog << "MFindSupercutsONOFFThetaLoop::ComputeNexSignificanceVSAlphaSig()" 
+	      << endl
+	      << "Number of theta bins defined by vector fCosThetaRangeVector (" 
+	      << NThetaBins << ") does not match with the bins in histogram "
+	      << SuccessfulThetaBinsHistoName << "(" 
+	      << SuccessfulThetaBinsHisto -> GetNbinsX() << ")" << endl
+	      << "Function execution will be ABORTED." << endl;
+	return kFALSE;
+    }
+
+
+    // Filling vector SuccessfulThetaBinsVector
+
+    tmpint = 0;
+    for (Int_t i = 0; i < NThetaBins; i++)
+    {
+	if ((SuccessfulThetaBinsHisto -> GetBinContent(i+1)) > 0.5)
+	{
+	    tmpint++;
+	}
+    }
+
+    SuccessfulThetaBinsVector.Set(tmpint);
+    
+    tmpint = 0;
+    for (Int_t i = 0; i < NThetaBins; i++)
+    {
+	if ((SuccessfulThetaBinsHisto -> GetBinContent(i+1)) > 0.5)
+	{
+	    if(tmpint < SuccessfulThetaBinsVector.GetSize())
+	    {
+		SuccessfulThetaBinsVector[tmpint] = i+1;
+		tmpint++;
+	    }
+	    else
+	    {
+		*fLog << "MFindSupercutsONOFFThetaLoop::ComputeNexSignificanceVSAlphaSig()" 
+		      << endl
+		      << "Problem when filling vector 'SuccessfulThetaBinsVector'" 
+		      << endl
+		      << "Function execution will be ABORTED." << endl;
+		return kFALSE;
+	    }
+	    
+
+	}
+    }
+
+    // variable defining the theta bins where optimization was successful, and 
+    // hence, alpha distributions stored in root file are meaningful (up to some extent)
+   
+    tmpint = SuccessfulThetaBinsVector.GetSize();
+    const Int_t SuccessfulNThetaBins = tmpint;
+    
+    // TEMP
+    //  cout << "const Int_t SuccessfulNThetaBins = " << SuccessfulNThetaBins << endl;
+    // ENDTEMP
+
+    // Vectors of pointers to histograms are defined to store the histograms 
+    // containing Nex and significance for TRAIN and TEST sample for all the 
+    // successful theta bins
+
+    // Histograms will be initialized in the loop over theta bins
+          
+    TH1F* NexVSAlphaSigTrainVector[SuccessfulNThetaBins];
+    TH1F* NexVSAlphaSigTestVector[SuccessfulNThetaBins];
+
+    
+    TH1F* SignificanceVSAlphaSigTrainVector[SuccessfulNThetaBins];
+    TH1F* SignificanceVSAlphaSigTestVector[SuccessfulNThetaBins];
+    
+    
+    // ***************************************************
+    // HISTOGRAMS FOR TRAIN SAMPLE ARE COMPUTED
+    // ***************************************************
+
+    
+
+    if (fOptimizeParameters)
+      { // Computation for TRAIN sample
+
+
+	*fLog << endl << endl
+	      << "****************************************************************************" << endl
+	      << "Computing Nex and significance vs cut in alpha (alphasig)  for TRAIN sample" << endl
+	      << "****************************************************************************" << endl
+	      << endl << endl;
+
+
+	// Retrieving NormFactorTrainHisto from root file. 
+
+	 cout << "Getting histogram with name " << NormFactorTrainHistoName << endl;
+
+	NormFactorTrainHisto = (TH1F*) rootfile.Get(NormFactorTrainHistoName);
+	
+
+	// Check that bins in this histo correspond with the 
+	// CosTheta intervals defined by vector fCosThetaRangeVector
+
+	////////////////// START CHECK  //////////////////////////////////////
+	
+	if (NormFactorTrainHisto -> GetNbinsX() != NThetaBins)
+	{
+	    *fLog << "MFindSupercutsONOFFThetaLoop::ComputeNexSignificanceVSAlphaSig()" 
+		  << endl
+		  << "Number of theta bins defined by vector fCosThetaRangeVector (" 
+		  << NThetaBins << ") does not match with the bins in histogram "
+		  << NormFactorTrainHistoName << "(" 
+		  << NormFactorTrainHisto -> GetNbinsX() << ")" << endl
+		  << "Function execution will be ABORTED." << endl;
+	    return kFALSE;
+	}
+
+	// histo test 
+	/*
+	cout << "NORMFACTORTRAINHIST  Test: BinCenter and Value" << endl;
+	for (Int_t k = 0; k < NThetaBins; k++)
+	{
+	    
+	    cout << NormFactorTrainHisto -> GetBinCenter(k+1) 
+		 << ";  " << NormFactorTrainHisto -> GetBinContent(k+1)<< endl;
+	}
+	*/
+
+	for (Int_t i = 0; i < SuccessfulThetaBinsVector.GetSize(); i++)
+	{
+	    tmpdouble = NormFactorTrainHisto -> GetBinCenter(SuccessfulThetaBinsVector[i]);
+	    if (fCosThetaRangeVector[SuccessfulThetaBinsVector[i]-1] > tmpdouble || 
+		fCosThetaRangeVector[SuccessfulThetaBinsVector[i]] < tmpdouble)
+	    {
+		*fLog << "MFindSupercutsONOFFThetaLoop::ComputeNexSignificanceVSAlphaSig()" 
+		      << endl
+		      << "Bins defined by vector fCosThetaRangeVector " 
+		      << "do not match with the bins of histogram "
+		      << NormFactorTrainHistoName << endl
+		      << "CosTheta: " << fCosThetaRangeVector[SuccessfulThetaBinsVector[i]-1]
+		      << "-" << fCosThetaRangeVector[SuccessfulThetaBinsVector[i]] << endl
+		      << "NormFactorHist Bin: " <<  tmpdouble << endl
+		      << "Function execution will be ABORTED." << endl;
+
+		return kFALSE;
+	    }
+	    
+	}
+
+	////////////////// END CHECK  //////////////////////////////////////
+
+
+
+	
+	// Check that the theta range string (needed to compute names for alpha histograms)
+	// is well defined
+	
+	for (Int_t i = 0; i < SuccessfulThetaBinsVector.GetSize(); i++)
+	  {
+	    if (fThetaRangeStringVector[SuccessfulThetaBinsVector[i]-1].IsNull())
+	      {
+		*fLog << "MFindSupercutsONOFFThetaLoop::ComputeNexSignificanceVSAlphaSig()" 
+		      << endl
+		      << "Component " << SuccessfulThetaBinsVector[i]-1 
+		      << " of fThetaRangeStringVector is EMPTY"
+		      << endl
+		      << "Function execution will be ABORTED." << endl;
+
+		return kFALSE;
+
+		
+	    }
+	  }
+
+
+	// *************************************************************
+	// *************************************************************
+	
+	// Normfactors and successfultheta bins are ok. 
+	// I can now compute the Nex and Sigma for train sample (ON-OFF) 
+	
+	// *************************************************************
+	// *************************************************************
+
+
+	
+
+	// Loop over the several successful theta bins doing the following 
+
+	// 0) Initializing histograms Nex and Significance (with names!!)
+	// 1) Retrieving alpha histograms (ON-OFF), and normalization factor
+	// 2) Computing Nex and Signficance vs alpha and filling histograms
+
+
+	*fLog << endl
+	      << "Starting loop over the successfully optimized theta ranges " << endl
+	      << endl;
+
+	Double_t NormalizationFactor = 0.0;
+	
+	for (Int_t i = 0; i < SuccessfulThetaBinsVector.GetSize(); i++)
+	  {
+
+	    *fLog << fThetaRangeStringVector[SuccessfulThetaBinsVector[i]-1] << endl << endl;
+	
+	    // 0) Initializing histograms Nex and Significance (with names!!)
+
+	    TString NexVSAlphaNameTmp = (NexVSAlphaName);
+	    TString SignificanceVSAlphaNameTmp = (SignificanceVSAlphaName);
+
+	    NexVSAlphaNameTmp += "Train";
+	    NexVSAlphaNameTmp += fThetaRangeStringVector[SuccessfulThetaBinsVector[i]-1];
+
+	    SignificanceVSAlphaNameTmp += "Train";
+	    SignificanceVSAlphaNameTmp += fThetaRangeStringVector[SuccessfulThetaBinsVector[i]-1];
+
+	
+	    // TEMP    
+	    // cout << NexVSAlphaNameTmp << endl;
+	    // cout << SignificanceVSAlphaNameTmp << endl;
+	    // ENDTEMP
+	      
+
+
+    
+	    NexVSAlphaSigTrainVector[i] = new TH1F (NexVSAlphaNameTmp.Data(), 
+						    NexVSAlphaNameTmp.Data(), 
+						    NexSignVSAlphaXBinsVectorDimension - 1,
+						    XBinsVector);
+	    
+	    // It is important to unlink the the created histograms from 
+	    // the current directory (defined now by "rootfile"), 
+	    // so that we can do whatever we want to 
+	    // with them regardless of such directory is opened or closed 
+	    // The reference of the histogram is removed from the current 
+	    // directory by means of the member function  "SetDirectory(0)"
+
+
+	    NexVSAlphaSigTrainVector[i] -> SetDirectory(0);
+
+
+	    SignificanceVSAlphaSigTrainVector[i] = new TH1F (SignificanceVSAlphaNameTmp.Data(), 
+							     SignificanceVSAlphaNameTmp.Data(),
+							     NexSignVSAlphaXBinsVectorDimension - 1,
+							     XBinsVector);
+	    
+	    SignificanceVSAlphaSigTrainVector[i] -> SetDirectory(0);
+	    
+	    
+
+	    // axis are defined
+
+	    NexVSAlphaSigTrainVector[i] -> SetXTitle(x_axis_label.Data());
+	    NexVSAlphaSigTrainVector[i] -> SetYTitle(y_axis_label_nex.Data());
+	    
+	    SignificanceVSAlphaSigTrainVector[i] ->SetXTitle(x_axis_label.Data());
+	    SignificanceVSAlphaSigTrainVector[i] ->SetYTitle(y_axis_label_significance.Data());
+
+	
+	    // 1) Retrieving alpha histograms (ON-OFF) and normalization factor
+
+	    NormalizationFactor = 
+	      NormFactorTrainHisto -> GetBinContent(SuccessfulThetaBinsVector[i]);
+
+
+	    TString TmpAlphaHistoName = ("TrainAlphaAfterCuts");
+	    TmpAlphaHistoName += fThetaRangeStringVector[SuccessfulThetaBinsVector[i]-1];
+
+	    *fLog << "Getting Histogram with name " << endl
+		  << TmpAlphaHistoName << endl;
+
+	    AlphaONAfterCuts = (TH1F*) rootfile.Get(TmpAlphaHistoName);
+
+	    
+	    TString TmpAlphaOFFHistoName = ("TrainAlphaOFFAfterCuts");
+	    TmpAlphaOFFHistoName += fThetaRangeStringVector[SuccessfulThetaBinsVector[i]-1];
+
+	    *fLog << "Getting Histogram with name " << endl
+		  << TmpAlphaOFFHistoName << endl;
+
+	    AlphaOFFAfterCuts = (TH1F*) rootfile.Get(TmpAlphaOFFHistoName);
+	    
+
+	 // 2) Computing Nex and Signficance vs alpha and filling histograms
+	    // Significance is found using MHFindSignificanceONOFF::FindSigmaONOFF  
+
+
+	    *fLog  << endl << endl
+		   << "Starting loop to compute Nex and Significance vs alphasig " << endl
+		   << "for TRAIN sample and " 
+		   << fThetaRangeStringVector[SuccessfulThetaBinsVector[i]-1] 
+		   << " :" << endl;
+	    
+	   	    
+	    for (Int_t j = 1; j < NexSignVSAlphaXBinsVectorDimension; j++)
+	      {
+		
+
+		alphasig = XBinsVector[j];
+		
+		MHFindSignificanceONOFF findsig;
+		findsig.SetRebin(RebinHistograms);
+		findsig.SetReduceDegree(ReduceDegree);	
+		findsig.SetUseFittedQuantities(fUseFittedQuantities);
+
+		// Dummy name for psfile 
+		TString psfilename = ("DummyPs"); 
+	    
+		findsig.FindSigmaONOFF(AlphaONAfterCuts, AlphaOFFAfterCuts, 
+				       NormalizationFactor, 
+				       alphabkgmin, alphabkgmax, 
+				       degree, degreeOFF,
+				       alphasig, 
+				       drawpoly, fitgauss, print, 
+				       saveplots, psfilename);
+
+		
+		Significance = double(findsig.GetSignificance());
+
+		// so far there is not a variable that contains 
+		// NexONOFF or NexONOFFFitted (in class MHFindSignificanceONOFF) 
+		// according to the value of the variable fUseFittedQuantities.
+		// As soon as I have some time I will implement it (with the 
+		// corresponging GET member function) and will change 
+		// MFindSignificanceONOFF accordingly to make use of it.
+		
+		// For the time being, I will survive with an "if statement".
+
+		
+		if(fUseFittedQuantities)
+		  {
+		    Nex = double(findsig.GetNexONOFFFitted()); 
+		  }
+		else
+		  {
+		    Nex = double(findsig.GetNexONOFF()); 
+		  }
+
+
+				
+		*fLog << endl << "Cut in alpha, Nex and significance : " 
+		      << alphasig << ", " << Nex << ", " << Significance << endl << endl;
+		
+	      
+		// updating histograms
+
+		tmpdouble = alphasig - AlphaBinWidth/2.0;
+
+		NexVSAlphaSigTrainVector[i] -> Fill(tmpdouble, Nex);
+		SignificanceVSAlphaSigTrainVector[i] -> Fill(tmpdouble, Significance);
+		
+	  
+
+		
+
+
+
+	      }	  
+	
+
+	    // Dynamic memory allocated in this loop is released
+	    
+    
+	    *fLog  << "Memory allocated by temporal alpha histograms "
+		   << "will be released" << endl;
+	    
+	    delete AlphaONAfterCuts;
+	    delete AlphaOFFAfterCuts;
+	    
+	  }
+
+
+      }
+
+    
+    
+     // ***************************************************
+    // HISTOGRAMS FOR TEST SAMPLE ARE COMPUTED
+    // ***************************************************
+
+
+ 
+
+    if(fTestParameters)
+      {// computation for TEST sample
+	
+	*fLog << endl << endl
+	      << "**************************************************************************" << endl
+	      << "Computing Nex and significance vs cut in alpha (alphasig) for TEST sample" << endl
+	      << "**************************************************************************" << endl
+	      << endl << endl;
+
+	// Retrieving NormFactorTestHisto from root file. 
+
+	 *fLog << "Getting histogram with name " << NormFactorTestHistoName << endl;
+
+	NormFactorTestHisto = (TH1F*) rootfile.Get(NormFactorTestHistoName);
+	
+
+	// Check that bins in this histo correspond with the 
+	// CosTheta intervals defined by vector fCosThetaRangeVector
+
+	////////////////// START CHECK  //////////////////////////////////////
+	
+	if (NormFactorTestHisto -> GetNbinsX() != NThetaBins)
+	{
+	    *fLog << "MFindSupercutsONOFFThetaLoop::ComputeNexSignificanceVSAlphaSig()" 
+		  << endl
+		  << "Number of theta bins defined by vector fCosThetaRangeVector (" 
+		  << NThetaBins << ") does not match with the bins in histogram "
+		  << NormFactorTestHistoName << "(" 
+		  << NormFactorTestHisto -> GetNbinsX() << ")" << endl
+		  << "Function execution will be ABORTED." << endl;
+	    return kFALSE;
+	}
+
+	// histo test 
+	/*
+	cout << "NORMFACTORTRAINHIST  Test: BinCenter and Value" << endl;
+	for (Int_t k = 0; k < NThetaBins; k++)
+	{
+	    
+	    cout << NormFactorTestHisto -> GetBinCenter(k+1) 
+		 << ";  " << NormFactorTestHisto -> GetBinContent(k+1)<< endl;
+	}
+	*/
+
+	for (Int_t i = 0; i < SuccessfulThetaBinsVector.GetSize(); i++)
+	{
+	    tmpdouble = NormFactorTestHisto -> GetBinCenter(SuccessfulThetaBinsVector[i]);
+	    if (fCosThetaRangeVector[SuccessfulThetaBinsVector[i]-1] > tmpdouble || 
+		fCosThetaRangeVector[SuccessfulThetaBinsVector[i]] < tmpdouble)
+	    {
+		*fLog << "MFindSupercutsONOFFThetaLoop::ComputeNexSignificanceVSAlphaSig()" 
+		      << endl
+		      << "Bins defined by vector fCosThetaRangeVector " 
+		      << "do not match with the bins of histogram "
+		      << NormFactorTestHistoName << endl
+		      << "CosTheta: " << fCosThetaRangeVector[SuccessfulThetaBinsVector[i]-1]
+		      << "-" << fCosThetaRangeVector[SuccessfulThetaBinsVector[i]] << endl
+		      << "NormFactorHist Bin: " <<  tmpdouble << endl
+		      << "Function execution will be ABORTED." << endl;
+
+		return kFALSE;
+	    }
+	    
+	}
+
+	////////////////// END CHECK  //////////////////////////////////////
+
+
+
+	
+	// Check that the theta range string (needed to compute names for alpha histograms)
+	// is well defined
+	
+	for (Int_t i = 0; i < SuccessfulThetaBinsVector.GetSize(); i++)
+	  {
+	    if (fThetaRangeStringVector[SuccessfulThetaBinsVector[i]-1].IsNull())
+	      {
+		*fLog << "MFindSupercutsONOFFThetaLoop::ComputeNexSignificanceVSAlphaSig()" 
+		      << endl
+		      << "Component " << SuccessfulThetaBinsVector[i]-1 
+		      << " of fThetaRangeStringVector is EMPTY"
+		      << endl
+		      << "Function execution will be ABORTED." << endl;
+
+		return kFALSE;
+
+		
+	    }
+	  }
+
+
+	// *************************************************************
+	// *************************************************************
+	
+	// Normfactors and successfultheta bins are ok. 
+	// I can now compute the Nex and Sigma for test sample (ON-OFF) 
+	
+	// *************************************************************
+	// *************************************************************
+
+	// Loop over the several successful theta bins doing the following 
+
+	// 0) Initializing histograms Nex and Significance (with names!!)
+	// 1) Retrieving alpha histograms (ON-OFF), and normalization factor
+	// 2) Computing Nex and Signficance vs alpha and filling histograms
+
+
+	*fLog << endl
+	      << "Starting loop over the successfully optimized theta ranges " << endl
+	      << endl;
+
+	
+	Double_t NormalizationFactor = 0.0;
+	
+	for (Int_t i = 0; i < SuccessfulThetaBinsVector.GetSize(); i++)
+	  {
+
+	    *fLog << fThetaRangeStringVector[SuccessfulThetaBinsVector[i]-1] << endl << endl;
+
+	    // 0) Initializing histograms Nex and Significance (with names!!)
+
+	    TString NexVSAlphaNameTmp = (NexVSAlphaName);
+	    TString SignificanceVSAlphaNameTmp = (SignificanceVSAlphaName);
+
+	    NexVSAlphaNameTmp += "Test";
+	    NexVSAlphaNameTmp += fThetaRangeStringVector[SuccessfulThetaBinsVector[i]-1];
+
+	    SignificanceVSAlphaNameTmp += "Test";
+	    SignificanceVSAlphaNameTmp += fThetaRangeStringVector[SuccessfulThetaBinsVector[i]-1];
+
+	
+	    // TEMP    
+	    // cout << NexVSAlphaNameTmp << endl;
+	    // cout << SignificanceVSAlphaNameTmp << endl;
+	    // ENDTEMP
+	      
+
+
+    
+	    NexVSAlphaSigTestVector[i] = new TH1F (NexVSAlphaNameTmp.Data(), 
+						    NexVSAlphaNameTmp.Data(), 
+						    NexSignVSAlphaXBinsVectorDimension - 1,
+						    XBinsVector);
+	    
+	    // It is important to unlink the the created histograms from 
+	    // the current directory (defined now by "rootfile"), 
+	    // so that we can do whatever we want to 
+	    // with them regardless of such directory is opened or closed 
+	    // The reference of the histogram is removed from the current 
+	    // directory by means of the member function  "SetDirectory(0)"
+
+
+	    NexVSAlphaSigTestVector[i] -> SetDirectory(0);
+
+
+	    SignificanceVSAlphaSigTestVector[i] = new TH1F (SignificanceVSAlphaNameTmp.Data(), 
+							     SignificanceVSAlphaNameTmp.Data(),
+							     NexSignVSAlphaXBinsVectorDimension - 1,
+							     XBinsVector);
+	    
+	    SignificanceVSAlphaSigTestVector[i] -> SetDirectory(0);
+	    
+	    
+
+	    // axis are defined
+
+	    NexVSAlphaSigTestVector[i] -> SetXTitle(x_axis_label.Data());
+	    NexVSAlphaSigTestVector[i] -> SetYTitle(y_axis_label_nex.Data());
+	    
+	    SignificanceVSAlphaSigTestVector[i] ->SetXTitle(x_axis_label.Data());
+	    SignificanceVSAlphaSigTestVector[i] ->SetYTitle(y_axis_label_significance.Data());
+
+	
+	    // 1) Retrieving alpha histograms (ON-OFF) and normalization factor
+
+	    NormalizationFactor = 
+	      NormFactorTestHisto -> GetBinContent(SuccessfulThetaBinsVector[i]);
+
+
+	    TString TmpAlphaHistoName = ("TestAlphaAfterCuts");
+	    TmpAlphaHistoName += fThetaRangeStringVector[SuccessfulThetaBinsVector[i]-1];
+
+	    *fLog << "Getting Histogram with name " << endl
+		  << TmpAlphaHistoName << endl;
+
+	    AlphaONAfterCuts = (TH1F*) rootfile.Get(TmpAlphaHistoName);
+
+	    
+	    TString TmpAlphaOFFHistoName = ("TestAlphaOFFAfterCuts");
+	    TmpAlphaOFFHistoName += fThetaRangeStringVector[SuccessfulThetaBinsVector[i]-1];
+
+	    *fLog << "Getting Histogram with name " << endl
+		  << TmpAlphaOFFHistoName << endl;
+
+	    AlphaOFFAfterCuts = (TH1F*) rootfile.Get(TmpAlphaOFFHistoName);
+	    
+
+	 // 2) Computing Nex and Signficance vs alpha and filling histograms
+	    // Significance is found using MHFindSignificanceONOFF::FindSigmaONOFF  
+
+
+	    *fLog  << endl << endl
+		   << "Starting loop to compute Nex and Significance vs alphasig " << endl
+		   << "for TRAIN sample and " 
+		   << fThetaRangeStringVector[SuccessfulThetaBinsVector[i]-1] 
+		   << " :" << endl;
+	    
+	   	    
+	    for (Int_t j = 1; j < NexSignVSAlphaXBinsVectorDimension; j++)
+	      {
+		
+
+		alphasig = XBinsVector[j];
+		
+		MHFindSignificanceONOFF findsig;
+		findsig.SetRebin(RebinHistograms);
+		findsig.SetReduceDegree(ReduceDegree);	
+		findsig.SetUseFittedQuantities(fUseFittedQuantities);
+
+		// Dummy name for psfile 
+		TString psfilename = ("DummyPs"); 
+	    
+		findsig.FindSigmaONOFF(AlphaONAfterCuts, AlphaOFFAfterCuts, 
+				       NormalizationFactor, 
+				       alphabkgmin, alphabkgmax, 
+				       degree, degreeOFF,
+				       alphasig, 
+				       drawpoly, fitgauss, print, 
+				       saveplots, psfilename);
+
+
+
+		Significance = double(findsig.GetSignificance());
+
+		// so far there is not a variable that contains 
+		// NexONOFF or NexONOFFFitted (in class MHFindSignificanceONOFF) 
+		// according to the value of the variable fUseFittedQuantities.
+		// As soon as I have some time I will implement it (with the 
+		// corresponging GET member function) and will change 
+		// MFindSignificanceONOFF accordingly to make use of it.
+		
+		// For the time being, I will survive with an "if statement".
+
+		
+		if(fUseFittedQuantities)
+		  {
+		    Nex = double(findsig.GetNexONOFFFitted()); 
+		  }
+		else
+		  {
+		    Nex = double(findsig.GetNexONOFF()); 
+		  }
+
+
+		*fLog << endl << "Cut in alpha, Nex and significance : " 
+		      << alphasig << ", " << Nex << ", " << Significance << endl << endl;
+		
+	      
+		// updating histograms
+
+		tmpdouble = alphasig - AlphaBinWidth/2.0;
+
+		NexVSAlphaSigTestVector[i] -> Fill(tmpdouble, Nex);
+		SignificanceVSAlphaSigTestVector[i] -> Fill(tmpdouble, Significance);
+		
+	  
+
+		
+
+
+
+	      }	  
+	
+
+	    // Dynamic memory allocated in this loop is released
+	    
+    
+	    *fLog  << "Memory allocated by temporal alpha histograms "
+		   << "will be released" << endl;
+	    
+	    delete AlphaONAfterCuts;
+	    delete AlphaOFFAfterCuts;
+	    
+	  }
+
+
+
+
+
+
+
+
+      }
+    
+    rootfile.Close();
+
+
+   
+     // *************************************************************
+    // Histograms Nex and Significance vs alpha are written into 
+    // root file fAlphaDistributionsRootFilename
+
+    
+
+
+     *fLog <<"Histograms containing Nex and significance vs alphasig " 
+	  << " are saved into root file " << endl 
+	  << fAlphaDistributionsRootFilename << endl;
+    
+
+    TFile rootfiletowrite (fAlphaDistributionsRootFilename, "UPDATE", 
+			   "Alpha Distributions for several Theta bins");
+
+ 
+   for (Int_t i = 0; i < SuccessfulThetaBinsVector.GetSize(); i++)
+    {
+
+      if (fOptimizeParameters)
+	{// Histograms for train sample are written to root file
+
+	  if(NexVSAlphaSigTrainVector[i])
+	    {
+	      if(NexVSAlphaSigTrainVector[i]-> GetEntries() > 0.5)
+		NexVSAlphaSigTrainVector[i]-> Write();
+
+	    }
+
+	   if(SignificanceVSAlphaSigTrainVector[i])
+	    {
+	      if(SignificanceVSAlphaSigTrainVector[i]-> GetEntries() > 0.5)
+		SignificanceVSAlphaSigTrainVector[i]-> Write();
+	      
+	    }
+	}
+
+
+
+      if (fTestParameters)
+	{// Histograms for test sample are written to root file
+
+	  if(NexVSAlphaSigTestVector[i])
+	    {
+	      if(NexVSAlphaSigTestVector[i]-> GetEntries() > 0.5)
+		NexVSAlphaSigTestVector[i]-> Write();
+
+	    }
+
+	   if(SignificanceVSAlphaSigTestVector[i])
+	    {
+	      if(SignificanceVSAlphaSigTestVector[i]-> GetEntries() > 0.5)
+		SignificanceVSAlphaSigTestVector[i]-> Write();
+	      
+	    }
+	}
+	  
+
+
+    }
+    
+
+    rootfiletowrite.Close();
+
+ 
+
+
+    // Dynamic memory allocated is released 
+    
+    delete  XBinsVector; 
+
+    // function finished successfully... hopefully...
+    return kTRUE;
+
+}
+
+
+
+// Function that gets the histograms with the alpha distributions
+// (for all the theta bins specified by fCosThetaRangeVector)
+// stored in fAlphaDistributionsRootFilename, and combine them
+// (correcting OFF histograms with the normalization factors stored 
+// in NormFactorTrain or NormFactorTest) to get one single 
+// Alpha distribution for ON and another one for OFF. 
+// Then these histograms are given as arguments to 
+// the function MHFindSignificanceONOFF::FindSigmaONOFF, 
+// (Object of this class is created) to compute the 
+// Overall Excess events and  significance, that will be 
+// stored in variables fOverallNexTrain/Test and fOverallSigmaLiMaTrain/Test
+
+
+
+
+Bool_t MFindSupercutsONOFFThetaLoop::ComputeOverallSignificance(Bool_t CombineTrainData,
+								   Bool_t CombineTestData)
+{
+
+    // First of all let's check that we have the proper the "drinks" for the party
+
+    if (fAlphaDistributionsRootFilename.IsNull())
+    {
+	*fLog << "MFindSupercutsONOFFThetaLoop::ComputeOverallSignificance()" << endl
+	      << "Root file containing all alpha distributions "
+	      <<" (fAlphaDistributionsRootFilename) is not well defined." << endl
+	      << "Execution of the function is ABORTED" << endl;
+	return kFALSE;
+    }
+
+
+    if (fCosThetaRangeVector.GetSize() < 2)
+	
+    {
+	*fLog << "MFindSupercutsONOFFThetaLoop::ComputeOverallSignificance()" << endl
+	      << "Dimension of vector fCosThetaRangeVector is smaller than 2." 
+	      << "So, vector fCosThetaRangeVector is NOT properly defined" << endl
+	      << "Function execution will be ABORTED" << endl;
+
+	return kFALSE;
+    }
+
+    
+    TArrayI SuccessfulThetaBinsVector; 
+    // Vector containing the histogram index of the successfully 
+    // optimized theta bins. 
+    // It is filled with the contents of the histogram 
+    // fSuccessfulThetaBinsHist retrieved from the root 
+    // file fAlphaDistributionsRootFilename
+    // Remember that histogram index START AT 1 !!!
+
+    TH1F* CombinedAlphaTrainON = NULL;
+    TString CombinedAlphaTrainONName = ("CombinedAlphaTrainON");
+    TH1F* CombinedAlphaTrainOFF = NULL;
+    TString CombinedAlphaTrainOFFName = ("CombinedAlphaTrainOFF");
+   
+    TH1F* CombinedAlphaTestON = NULL;
+    TString CombinedAlphaTestONName = ("CombinedAlphaTestON");
+   
+    TH1F* CombinedAlphaTestOFF = NULL;
+    TString CombinedAlphaTestOFFName = ("CombinedAlphaTestOFF");
+   
+
+    
+
+    
+    Int_t NAlphaBins = 0; // Amount of bins of alpha histograms is expected to 
+    // be equal for all alpha histograms
+
+    // Vectors storing the computed error for each of the NAlphaBins 
+    // Only 2 vectors are needed for OFF Train and OFF Test sample, whose 
+    // alpha distributions are corrected with normalization factors. 
+
+    // The ON sample is just added (no normalization factors are applied) 
+    // and therefore, the error of the bin is the assumed by default 
+    // (i.e Sqrt(BinContent)
+
+    TArrayD ErrorInCombinedAlphaTrainOFF;
+    TArrayD ErrorInCombinedAlphaTestOFF;
+
+    TArrayD CombinedAlphaTrainOFFWithoutNormalization;
+    TArrayD CombinedAlphaTestOFFWithoutNormalization;
+    
+
+
+    const Double_t SmallQuantity = 0.01; // This quantity will be used as the 
+    // maximum difference between quantities (double) that are expected to be equal, 
+    // as the center of the bins in the several alpha distributions 
+
+    TH1F* NormFactorTrainHisto;
+    TString NormFactorTrainHistoName = ("NormFactorTrainHist");
+    TH1F* NormFactorTestHisto;
+    TString NormFactorTestHistoName = ("NormFactorTestHist");
+    TString SuccessfulThetaBinsHistoName = ("SuccessfulThetaBinsHist");
+    
+
+    TH1F* SuccessfulThetaBinsHisto;
+
+    TH1F* TmpTH1FHisto;
+
+    
+    // Retrieve number of theta bins that have to be combined
+    // from TArrayD fCosThetaRangeVector
+
+    Int_t tmpdim = fCosThetaRangeVector.GetSize() - 1;
+    const Int_t NThetaBins = tmpdim;
+
+    // Variables to store the mean normalization factor of the 
+    // combined OFF sample. 
+    // MeanNormFactor = Sum (NormFactor_i*Noff_i)/Sum (Noff_i)
+    
+
+    Double_t MeanNormFactorTrain = 0.0;
+    Double_t MeanNormFactorTest = 0.0;
+    
+    Double_t TotalNumberOFFTrain = 0.0;
+    Double_t TotalNumberOFFTest = 0.0;
+    
+
+
+    Double_t EventCounter = 0.0;// variable used to count events used to fill histograms
+    // it is double (and not Int) because the contents of an histogram bin might not 
+    // be an integer value... due to normalization factors !!
+    Int_t tmpint = 0;
+    Double_t tmpdouble = 0.0; // tmp variable double
+    Double_t tmpdouble2 = 0.0; // tmp variable double
+    Double_t tmperror = 0.0; // quantity used to store 
+    // temporaly the bin error in OFF histogram
+    Double_t tmpnormfactor = 0.0; // variable used to store normalization factor 
+    // of the theta bin i (used for TRAIN and TEST sample)
+             
+
+
+
+    // Open root file
+
+    
+
+    
+    *fLog << "MFindSupercutsONOFFThetaLoop::ComputeOverallSignificance()" << endl
+	  << "Opening root file " << fAlphaDistributionsRootFilename << endl;
+
+
+
+    TFile rootfile (fAlphaDistributionsRootFilename, "READ");
+
+    // Retrieving SuccessfulThetaBinsHisto from root file. 
+    
+
+    *fLog << "MFindSupercutsONOFFThetaLoop::ComputeOverallSignificance()" << endl
+	  << "Retrieving SuccessfulThetaBinsHisto from root file and filling vector "
+	  << " SuccessfulThetaBinsVector" << endl;
+
+
+    cout << "Getting histogram " << SuccessfulThetaBinsHistoName << endl;
+
+    SuccessfulThetaBinsHisto = (TH1F*) rootfile.Get(SuccessfulThetaBinsHistoName);
+    
+
+
+    // Check that bins in this histo correspond with the 
+    // CosTheta intervals defined by vector fCosThetaRangeVector
+
+	
+    if (SuccessfulThetaBinsHisto -> GetNbinsX() != NThetaBins)
+    {
+	*fLog << "MFindSupercutsONOFFThetaLoop::ComputeOverallSignificance()" 
+	      << endl
+	      << "Number of theta bins defined by vector fCosThetaRangeVector (" 
+	      << NThetaBins << ") does not match with the bins in histogram "
+	      << SuccessfulThetaBinsHistoName << "(" 
+	      << SuccessfulThetaBinsHisto -> GetNbinsX() << ")" << endl
+	      << "Function execution will be ABORTED." << endl;
+	return kFALSE;
+    }
+
+
+    // Filling vector SuccessfulThetaBinsVector
+
+    tmpint = 0;
+    for (Int_t i = 0; i < NThetaBins; i++)
+    {
+	if ((SuccessfulThetaBinsHisto -> GetBinContent(i+1)) > 0.5)
+	{
+	    tmpint++;
+	}
+    }
+
+    SuccessfulThetaBinsVector.Set(tmpint);
+    
+    tmpint = 0;
+    for (Int_t i = 0; i < NThetaBins; i++)
+    {
+	if ((SuccessfulThetaBinsHisto -> GetBinContent(i+1)) > 0.5)
+	{
+	    if(tmpint < SuccessfulThetaBinsVector.GetSize())
+	    {
+		SuccessfulThetaBinsVector[tmpint] = i+1;
+		tmpint++;
+	    }
+	    else
+	    {
+		*fLog << "MFindSupercutsONOFFThetaLoop::ComputeOverallSignificance()" 
+		      << endl
+		      << "Problem when filling vector 'SuccessfulThetaBinsVector'" 
+		      << endl
+		      << "Function execution will be ABORTED." << endl;
+		return kFALSE;
+	    }
+	    
+
+	}
+    }
+
+
+   
+
+
+    // *********  HISTOGRAMS FOR TRAIN SAMPLE WILL BE FILLED *********///
+
+    if (CombineTrainData)
+    {
+
+	// Retrieving NormFactorTrainHisto from root file. 
+	
+	NormFactorTrainHisto = (TH1F*) rootfile.Get(NormFactorTrainHistoName);
+	// NormFactorTrainHisto-> DrawCopy();
+
+	// Check that bins in this histo correspond with the 
+	// CosTheta intervals defined by vector fCosThetaRangeVector
+
+	
+	if (NormFactorTrainHisto -> GetNbinsX() != NThetaBins)
+	{
+	    *fLog << "MFindSupercutsONOFFThetaLoop::ComputeOverallSignificance()" 
+		  << endl
+		  << "Number of theta bins defined by vector fCosThetaRangeVector (" 
+		  << NThetaBins << ") does not match with the bins in histogram "
+		  << NormFactorTrainHistoName << "(" 
+		  << NormFactorTrainHisto -> GetNbinsX() << ")" << endl
+		  << "Function execution will be ABORTED." << endl;
+	    return kFALSE;
+	}
+
+	// histo test 
+	/*
+	cout << "NORMFACTORTRAINHIST  TEST: BinCenter and Value" << endl;
+	for (Int_t k = 0; k < NThetaBins; k++)
+	{
+	    
+	    cout << NormFactorTrainHisto -> GetBinCenter(k+1) 
+		 << ";  " << NormFactorTrainHisto -> GetBinContent(k+1)<< endl;
+	}
+	*/
+
+	for (Int_t i = 0; i < SuccessfulThetaBinsVector.GetSize(); i++)
+	{
+	    tmpdouble = NormFactorTrainHisto -> GetBinCenter(SuccessfulThetaBinsVector[i]);
+	    if (fCosThetaRangeVector[SuccessfulThetaBinsVector[i]-1] > tmpdouble || 
+		fCosThetaRangeVector[SuccessfulThetaBinsVector[i]] < tmpdouble)
+	    {
+		*fLog << "MFindSupercutsONOFFThetaLoop::ComputeOverallSignificance()" 
+		      << endl
+		      << "Bins defined by vector fCosThetaRangeVector " 
+		      << "do not match with the bins of histogram "
+		      << NormFactorTrainHistoName << endl
+		      << "CosTheta: " << fCosThetaRangeVector[SuccessfulThetaBinsVector[i]-1]
+		      << "-" << fCosThetaRangeVector[SuccessfulThetaBinsVector[i]] << endl
+		      << "NormFactorHist Bin: " <<  tmpdouble << endl
+		      << "Function execution will be ABORTED." << endl;
+
+		return kFALSE;
+	    }
+	    
+	}
+
+
+	// Let's summ up all ON alpha distributions
+	
+	EventCounter = 0;
+
+	for (Int_t i = 0; i < SuccessfulThetaBinsVector.GetSize(); i++)
+	{
+	    if (fThetaRangeStringVector[SuccessfulThetaBinsVector[i]-1].IsNull())
+	    {
+		*fLog << "MFindSupercutsONOFFThetaLoop::ComputeOverallSignificance()" 
+		      << endl
+		      << "Component " << SuccessfulThetaBinsVector[i]-1 
+		      << " of fThetaRangeStringVector is EMPTY"
+		      << endl
+		      << "Function execution will be ABORTED." << endl;
+		return kFALSE;
+
+		
+	    }
+
+	
+
+	    TString TmpHistoName = ("TrainAlphaAfterCuts");
+	    TmpHistoName += fThetaRangeStringVector[SuccessfulThetaBinsVector[i]-1];
+
+	    *fLog << "Getting Histogram with name " << endl
+		  << TmpHistoName << endl;
+
+	    if (i == 0)
+	    {      
+		CombinedAlphaTrainON = (TH1F*) rootfile.Get(TmpHistoName);
+		NAlphaBins = CombinedAlphaTrainON -> GetNbinsX();
+
+		// Name of histogram is set
+		CombinedAlphaTrainON -> SetName(CombinedAlphaTrainONName);
+
+		// update EventCounter
+		EventCounter += CombinedAlphaTrainON -> GetEntries();
+
+		// tmp
+		cout << "NAlphaBins in histo CombinedAlphaTrainON: "
+		     << NAlphaBins << endl;
+		// endtmp
+	    }
+	    else
+	    {
+		TmpTH1FHisto = (TH1F*) rootfile.Get(TmpHistoName);
+		
+		// update EventCounter
+		EventCounter += TmpTH1FHisto -> GetEntries();
+		
+		for (Int_t j = 1; j <= NAlphaBins; j++)
+		{
+		    // At some time alpha bins might not be the same for 
+		    // the different alpha distributions. That's why
+		    // I will check it before summing the alpha histo contents
+		    tmpdouble =  CombinedAlphaTrainON->GetBinCenter(j) -
+			TmpTH1FHisto->GetBinCenter(j);
+		    tmpdouble = TMath::Abs(tmpdouble);
+		    
+
+		    if (tmpdouble > SmallQuantity)
+		    {
+			*fLog << "MFindSupercutsONOFFThetaLoop::ComputeOverallSignificance()" 
+			      << endl
+			      << "Bins among the several alpha ON histograms "
+			      << "for TRAIN sample do not match"
+			      << endl
+			      << "Function execution will be ABORTED." << endl;
+			return kFALSE;
+		    }
+		    
+		    tmpdouble = CombinedAlphaTrainON->GetBinContent(j) + 
+			TmpTH1FHisto->GetBinContent(j);
+
+		    
+		    CombinedAlphaTrainON-> SetBinContent(j,tmpdouble);
+
+		}
+		
+		// Dynamic memory allocated for TmpTH1FHisto is released
+
+
+		//tmp
+		cout << "Memory allocated by temporal histogram TmpTH1FHisto "
+		     << "will be released" << endl;
+		//endtmp
+		delete TmpTH1FHisto;
+	    
+	    }
+
+
+	}
+
+	// Entries of histogram CombinedAlphaTrainON is set to 
+	// the events counted in EventCounter
+
+	tmpint = int (EventCounter);
+	CombinedAlphaTrainON->SetEntries(tmpint);
+
+	// Let's summ up all OFF alpha distributions
+	
+	EventCounter = 0;
+
+	for (Int_t i = 0; i < SuccessfulThetaBinsVector.GetSize(); i++)
+	{
+	    if (fThetaRangeStringVector[SuccessfulThetaBinsVector[i]-1].IsNull())
+	    {
+		*fLog << "MFindSupercutsONOFFThetaLoop::ComputeOverallSignificance()" 
+		      << endl
+		      << "Component " << SuccessfulThetaBinsVector[i]-1 
+		      << " of fThetaRangeStringVector is EMPTY"
+		      << endl
+		      << "Function execution will be ABORTED." << endl;
+		return kFALSE;
+
+		
+	    }
+
+	    TString TmpHistoName = ("TrainAlphaOFFAfterCuts");
+	    TmpHistoName += fThetaRangeStringVector[SuccessfulThetaBinsVector[i]-1];
+
+	    // Normalization constant for this theta bin is stored now in tmpnormfactor
+	    tmpnormfactor = NormFactorTrainHisto -> GetBinContent(SuccessfulThetaBinsVector[i]);
+
+	    // temp 
+	    cout << "Normalization factor for bin "
+		 << SuccessfulThetaBinsVector[i] << " is "
+		 << tmpnormfactor << endl;
+
+	    // endtemp
+
+	    if (i == 0)
+	    {
+		CombinedAlphaTrainOFF = (TH1F*) rootfile.Get(TmpHistoName);
+		NAlphaBins = CombinedAlphaTrainOFF -> GetNbinsX();
+		
+
+		// Name of histogram is set
+		CombinedAlphaTrainOFF -> SetName(CombinedAlphaTrainOFFName);
+
+		// Event counter is updated taking into account the 
+		// normalization factor
+
+		EventCounter += tmpnormfactor * CombinedAlphaTrainOFF -> GetEntries();
+
+		// Contribution to total number of OFF events and mean normfactor
+		// of this theta bin is computed
+
+		TotalNumberOFFTrain = CombinedAlphaTrainOFF -> GetEntries();
+		MeanNormFactorTrain = tmpnormfactor *
+		    CombinedAlphaTrainOFF -> GetEntries();
+		    
+		
+		
+		// ****
+		// Dimension of ErrorInCombinedAlphaTrainOFF is set
+		ErrorInCombinedAlphaTrainOFF.Set(NAlphaBins);
+		
+		CombinedAlphaTrainOFFWithoutNormalization.Set(NAlphaBins);
+
+		// Histogram now is normalized (to the respective ON data)
+		// by using the normalization constants stored in 
+		// histogram NormFactorTrainHisto
+
+		// Error of the normalized bins is computed and stored in 
+		// vector ErrorInCombinedAlphaTrainOFF
+		
+		for (Int_t j = 1; j <= NAlphaBins; j++)
+		{
+
+		    // Number of events (without normalization) are 
+		    // stored in vector CombinedAlphaTrainOFFWithoutNormalization
+
+			CombinedAlphaTrainOFFWithoutNormalization[j-1] = 
+			    CombinedAlphaTrainOFF -> GetBinContent(j);
+		   
+		    // Bin content is set
+		    tmpdouble2 = tmpnormfactor * 
+			CombinedAlphaTrainOFF -> GetBinContent(j);
+
+		    CombinedAlphaTrainOFF -> SetBinContent(j,tmpdouble2);
+
+		    // (Bin Error)^2 is computed and stored in 
+		    // ErrorInCombinedAlphaTrainOFF
+		    // Bin error = Sqrt(BinContent) X Normalization Factor
+
+		    tmperror = tmpdouble2*tmpnormfactor;
+		    ErrorInCombinedAlphaTrainOFF[j-1] = tmperror;
+
+		}
+
+	    }
+	    else
+	    {
+		TmpTH1FHisto = (TH1F*) rootfile.Get(TmpHistoName);
+
+
+		// Event counter is updated taking into account the 
+		// normalization factor
+
+		EventCounter += tmpnormfactor * TmpTH1FHisto -> GetEntries();
+
+		// Contribution to total number of OFF events and mean normfactor
+		// of this theta bin is computed
+
+		TotalNumberOFFTrain += TmpTH1FHisto -> GetEntries();
+		MeanNormFactorTrain += tmpnormfactor *
+		    TmpTH1FHisto -> GetEntries();
+
+		
+
+		for (Int_t j = 1; j <= NAlphaBins; j++)
+		{
+		    // At some time alpha bins might not be the same for 
+		    // the different alpha distributions. That's why
+		    // I will check it before summing the alpha histo contents
+		    tmpdouble2 =  CombinedAlphaTrainOFF->GetBinCenter(j) -
+			TmpTH1FHisto->GetBinCenter(j);
+		    tmpdouble2 = TMath::Abs(tmpdouble2);
+
+		    if (tmpdouble2 > SmallQuantity)
+		    {
+			*fLog << "MFindSupercutsONOFFThetaLoop::ComputeOverallSignificance()" 
+			      << endl
+			      << "Bins among the several alpha OFF histograms "
+			      << "for TRAIN sample do not match"
+			      << endl
+			      << "Function execution will be ABORTED." << endl;
+			return kFALSE;
+		    }
+		    
+
+		     // Number of events (without normalization) are 
+		    // added in vector CombinedAlphaTrainOFFWithoutNormalization
+		    
+		    CombinedAlphaTrainOFFWithoutNormalization[j-1] += 
+			TmpTH1FHisto -> GetBinContent(j);
+
+		    // Histogram bin contents must be normalized (to the respective ON data)
+		    // by using the normalization constants stored in 
+		    // histogram NormFactorTrainHisto before being added 
+		    // to CombinedAlphaTrainOFF
+
+		   
+		    tmpdouble2 = CombinedAlphaTrainOFF->GetBinContent(j) + 
+			(TmpTH1FHisto->GetBinContent(j) * tmpnormfactor);
+
+		    
+		    CombinedAlphaTrainOFF-> SetBinContent(j,tmpdouble2);
+
+
+		    // (Bin Error)^2 is computed and added to  
+		    // ErrorInCombinedAlphaTrainOFF 
+		    // Bin error = Sqrt(BinContent) X Normalization Factor
+
+		    tmperror = TmpTH1FHisto->GetBinContent(j) * tmpnormfactor;
+		    ErrorInCombinedAlphaTrainOFF[j-1] += tmperror;
+
+		}
+		
+		// Dynamic memory allocated for TmpTH1FHisto is released
+
+		delete TmpTH1FHisto;
+	    
+	    }
+
+	    
+
+
+
+	}
+
+	
+
+
+	// Mean Normalization factor is computed for the combined OFF histogram. 
+	// This factor will be used when computing the significance via 
+	// MHFindSignificance::FindSigmaONOFF().
+
+	// The bin contents (and errors) of teh combined OFF TRAIN histo will be 
+	// normalized (divided) by teh mean norm constant, so that 
+	// the histogram for OFF data given as argument in FindSigmaONOFF
+	// is equivalent to a non-normalized histogram. 
+	
+	MeanNormFactorTrain = MeanNormFactorTrain/TotalNumberOFFTrain;
+
+
+
+	// Sqrt(Contents) is performed in ErrorInCombinedAlphaTrainOFF, 
+	// in order to compute the real error in the bin content of histogram 
+	// CombinedAlphaTrainOFF.
+
+	// Then error and contents (normalized with mean normfctor) are
+	// set to histogram bin 	
+
+	for (Int_t j = 1; j <= NAlphaBins; j++)
+	{	    
+	    tmpdouble2 = 
+		(CombinedAlphaTrainOFF -> GetBinContent(j))/MeanNormFactorTrain;
+
+	    CombinedAlphaTrainOFF -> SetBinContent(j,tmpdouble2);
+
+	    ErrorInCombinedAlphaTrainOFF[j-1] = 
+		TMath::Sqrt(ErrorInCombinedAlphaTrainOFF[j-1])/MeanNormFactorTrain;
+	    // Proper error treatment when adding quantities to histogram bin 
+
+	    CombinedAlphaTrainOFF -> SetBinError(j,ErrorInCombinedAlphaTrainOFF[j-1]);
+
+	    // ******  TMP **************
+	    /*
+	    // Error computation assuming a given (no normalized) bin content
+
+	    tmpdouble = CombinedAlphaTrainOFF -> GetBinContent(j);
+
+	    if (CombinedAlphaTrainOFFWithoutNormalization[j-1] < SmallQuantity)
+	    {tmpnormfactor = 0;}
+	    else
+	    {tmpnormfactor = tmpdouble/CombinedAlphaTrainOFFWithoutNormalization[j-1];}
+
+	    tmperror = TMath::Sqrt(CombinedAlphaTrainOFFWithoutNormalization[j-1]) *
+		tmpnormfactor;
+
+	    CombinedAlphaTrainOFF -> SetBinError(j,tmperror);
+	    
+	    */
+	    // ******  END TMP **************			 
+
+	    // tmp
+	    /*
+	    cout << CombinedAlphaTrainOFF -> GetBinContent(j) << " +/-  " 
+		 << CombinedAlphaTrainOFF -> GetBinError(j)
+		 << "  Number Events without normalization: " 
+		 << CombinedAlphaTrainOFFWithoutNormalization[j-1] << endl;
+	    */
+	    // endtmp
+	    
+	}
+
+
+	// Entries of histogram CombinedAlphaTrainON is set to 
+	// the events counted during histogram filling
+
+	EventCounter = EventCounter/MeanNormFactorTrain;
+	tmpint = int (EventCounter);
+	CombinedAlphaTrainOFF->SetEntries(tmpint);
+
+
+	cout << "SILLY INFO FOR TRAIN SAMPLE: Total number of events Before nomralization and " 
+	     << " re-re normalized" << endl
+	     << TotalNumberOFFTrain << " - " << EventCounter << endl;
+
+    }
+
+    // *********  COMBINED  HISTOGRAMS FOR TRAIN SAMPLE ALREADY FILLED ********* ///
+
+
+
+
+    // *********  HISTOGRAMS FOR TEST SAMPLE WILL BE FILLED *********  ///
+
+
+    if (CombineTestData)
+    {
+
+	// Retrieving NormFactorTestHisto from root file. 
+	
+	NormFactorTestHisto = (TH1F*) rootfile.Get(NormFactorTestHistoName);
+	// NormFactorTestHisto-> DrawCopy();
+
+	// Check that bins in this histo correspond with the 
+	// CosTheta intervals defined by vector fCosThetaRangeVector
+
+	
+	if (NormFactorTestHisto -> GetNbinsX() != NThetaBins)
+	{
+	    *fLog << "MFindSupercutsONOFFThetaLoop::ComputeOverallSignificance()" 
+		  << endl
+		  << "Number of theta bins defined by vector fCosThetaRangeVector (" 
+		  << NThetaBins << ") does not match with the bins in histogram "
+		  << NormFactorTestHistoName << "(" 
+		  << NormFactorTestHisto -> GetNbinsX() << ")" << endl
+		  << "Function execution will be ABORTED." << endl;
+	    return kFALSE;
+	}
+
+	// histo test 
+	/*
+	cout << "NORMFACTORTRAINHIST  TEST: BinCenter and Value" << endl;
+	for (Int_t k = 0; k < NThetaBins; k++)
+	{
+	    
+	    cout << NormFactorTestHisto -> GetBinCenter(k+1) 
+		 << ";  " << NormFactorTestHisto -> GetBinContent(k+1)<< endl;
+	}
+	*/
+
+	
+
+	for (Int_t i = 0; i < SuccessfulThetaBinsVector.GetSize(); i++)
+	{
+	    tmpdouble = NormFactorTestHisto -> GetBinCenter(SuccessfulThetaBinsVector[i]);
+	    if (fCosThetaRangeVector[SuccessfulThetaBinsVector[i]-1] > tmpdouble || 
+		fCosThetaRangeVector[SuccessfulThetaBinsVector[i]] < tmpdouble)
+	    {
+		*fLog << "MFindSupercutsONOFFThetaLoop::ComputeOverallSignificance()" 
+		      << endl
+		      << "Bins defined by vector fCosThetaRangeVector " 
+		      << "do not match with the bins of histogram "
+		      << NormFactorTestHistoName << endl
+		      << "CosTheta: " << fCosThetaRangeVector[SuccessfulThetaBinsVector[i]-1]
+		      << "-" << fCosThetaRangeVector[SuccessfulThetaBinsVector[i]] << endl
+		      << "NormFactorHist Bin: " <<  tmpdouble << endl
+		      << "Function execution will be ABORTED." << endl;
+
+		return kFALSE;
+	    }
+	    
+	}
+
+
+	// Let's summ up all ON alpha distributions
+
+	// Event counter (counts events used in the histogram filling) is 
+	// initialized to zero
+
+	EventCounter = 0;
+
+	for (Int_t i = 0; i < SuccessfulThetaBinsVector.GetSize(); i++)
+	{
+	    if (fThetaRangeStringVector[SuccessfulThetaBinsVector[i]-1].IsNull())
+	    {
+		*fLog << "MFindSupercutsONOFFThetaLoop::ComputeOverallSignificance()" 
+		      << endl
+		      << "Component " << SuccessfulThetaBinsVector[i]-1 
+		      << " of fThetaRangeStringVector is EMPTY"
+		      << endl
+		      << "Function execution will be ABORTED." << endl;
+		return kFALSE;
+
+		
+	    }
+
+	
+
+	    TString TmpHistoName = ("TestAlphaAfterCuts");
+	    TmpHistoName += fThetaRangeStringVector[SuccessfulThetaBinsVector[i]-1];
+
+	    *fLog << "Getting Histogram with name " << endl
+		  << TmpHistoName << endl;
+
+	    if (i == 0)
+	    {      
+		CombinedAlphaTestON = (TH1F*) rootfile.Get(TmpHistoName);
+		NAlphaBins = CombinedAlphaTestON -> GetNbinsX();
+
+		// Name of histogram is set
+		CombinedAlphaTestON -> SetName(CombinedAlphaTestONName);
+
+		// EventCounter is updated
+		
+		EventCounter += CombinedAlphaTestON -> GetEntries();
+
+		// tmp
+		cout << "NAlphaBins in histo CombinedAlphaTestON: "
+		     << NAlphaBins << endl;
+		// endtmp
+	    }
+	    else
+	    {
+		TmpTH1FHisto = (TH1F*) rootfile.Get(TmpHistoName);
+
+		// EventCounter is updated
+		
+		EventCounter += TmpTH1FHisto -> GetEntries();
+
+		for (Int_t j = 1; j <= NAlphaBins; j++)
+		{
+		    // At some time alpha bins might not be the same for 
+		    // the different alpha distributions. That's why
+		    // I will check it before summing the alpha histo contents
+		    tmpdouble =  CombinedAlphaTestON->GetBinCenter(j) -
+			TmpTH1FHisto->GetBinCenter(j);
+		    tmpdouble = TMath::Abs(tmpdouble);
+		    
+
+		    if (tmpdouble > SmallQuantity)
+		    {
+			*fLog << "MFindSupercutsONOFFThetaLoop::ComputeOverallSignificance()" 
+			      << endl
+			      << "Bins among the several alpha ON histograms "
+			      << "for TEST sample do not match"
+			      << endl
+			      << "Function execution will be ABORTED." << endl;
+			return kFALSE;
+		    }
+		    
+		    tmpdouble = CombinedAlphaTestON->GetBinContent(j) + 
+			TmpTH1FHisto->GetBinContent(j);
+
+		    
+		    CombinedAlphaTestON-> SetBinContent(j,tmpdouble);
+
+		}
+		
+		// Dynamic memory allocated for TmpTH1FHisto is released
+
+
+		//tmp
+		cout << "Memory allocated by temporal histogram TmpTH1FHisto "
+		     << "will be released" << endl;
+		//endtmp
+		delete TmpTH1FHisto;
+	    
+	    }
+
+
+
+
+	}
+
+	// Entries of histogram CombinedAlphaTestON is set to 
+	// the events counted during histogram filling
+	tmpint = int (EventCounter);
+	CombinedAlphaTestON->SetEntries(tmpint);
+
+
+	// Let's summ up all OFF alpha distributions
+
+	EventCounter = 0;
+
+	for (Int_t i = 0; i < SuccessfulThetaBinsVector.GetSize(); i++)
+	{
+	    if (fThetaRangeStringVector[SuccessfulThetaBinsVector[i]-1].IsNull())
+	    {
+		*fLog << "MFindSupercutsONOFFThetaLoop::ComputeOverallSignificance()" 
+		      << endl
+		      << "Component " << SuccessfulThetaBinsVector[i]-1 
+		      << " of fThetaRangeStringVector is EMPTY"
+		      << endl
+		      << "Function execution will be ABORTED." << endl;
+		return kFALSE;
+
+		
+	    }
+
+	    TString TmpHistoName = ("TestAlphaOFFAfterCuts");
+	    TmpHistoName += fThetaRangeStringVector[SuccessfulThetaBinsVector[i]-1];
+
+	    // Normalization constant for this theta bin is stored now in tmpnormfactor
+	    tmpnormfactor = NormFactorTestHisto -> GetBinContent(SuccessfulThetaBinsVector[i]);
+
+	    // temp 
+	    cout << "Normalization factor for bin "
+		 << SuccessfulThetaBinsVector[i] << " is "
+		 << tmpnormfactor << endl;
+
+	    // endtemp
+
+	    if (i == 0)
+	    {
+		CombinedAlphaTestOFF = (TH1F*) rootfile.Get(TmpHistoName);
+		NAlphaBins = CombinedAlphaTestOFF -> GetNbinsX();
+	       
+
+		// Name of histogram is set
+		CombinedAlphaTestOFF -> SetName(CombinedAlphaTestOFFName);
+
+		// EventCounter is updated taking into account 
+		// normalization factor
+		
+		EventCounter += tmpnormfactor*CombinedAlphaTestOFF -> GetEntries();
+
+		
+		// Contribution to total number of OFF events and mean normfactor
+		// of this theta bin is computed
+
+		TotalNumberOFFTest = CombinedAlphaTestOFF -> GetEntries();
+		MeanNormFactorTest = tmpnormfactor *
+		    CombinedAlphaTestOFF -> GetEntries();
+
+
+		// Dimension of ErrorInCombinedAlphaTrainOFF is set
+		ErrorInCombinedAlphaTestOFF.Set(NAlphaBins);
+
+		CombinedAlphaTestOFFWithoutNormalization.Set(NAlphaBins);
+
+
+		// Histogram now is normalized (to the respective ON data)
+		// by using the normalization constants stored in 
+		// histogram NormFactorTestHisto
+
+		
+		for (Int_t j = 1; j <= NAlphaBins; j++)
+		{
+
+		    // Vector containing number of events without 
+		    // normalization is filled
+		   
+			CombinedAlphaTestOFFWithoutNormalization[j-1] = 
+			    CombinedAlphaTestOFF -> GetBinContent(j);
+		   
+
+
+		    tmpdouble2 = tmpnormfactor * 
+			CombinedAlphaTestOFF -> GetBinContent(j);
+
+		    CombinedAlphaTestOFF -> SetBinContent(j,tmpdouble2);
+
+		    // (Bin Error)^2 is computed and stored in 
+		    // ErrorInCombinedAlphaTestOFF
+		    // Bin error = Sqrt(BinContent) X Normalization Factor
+
+		    tmperror = tmpdouble2*tmpnormfactor;
+		    ErrorInCombinedAlphaTestOFF[j-1] = tmperror;
+
+
+		}
+
+	    }
+	    else
+	    {
+		TmpTH1FHisto = (TH1F*) rootfile.Get(TmpHistoName);
+
+
+		// EventCounter is updated taking into account 
+		// normalization factor
+		
+		EventCounter += tmpnormfactor* TmpTH1FHisto-> GetEntries();
+
+		// Contribution to total number of OFF events and mean normfactor
+		// of this theta bin is computed
+
+
+		TotalNumberOFFTest += TmpTH1FHisto -> GetEntries();
+		MeanNormFactorTest += tmpnormfactor *
+		    TmpTH1FHisto -> GetEntries();
+
+
+
+		for (Int_t j = 1; j <= NAlphaBins; j++)
+		{
+		    // At some time alpha bins might not be the same for 
+		    // the different alpha distributions. That's why
+		    // I will check it before summing the alpha histo contents
+		    tmpdouble2 =  CombinedAlphaTestOFF->GetBinCenter(j) -
+			TmpTH1FHisto->GetBinCenter(j);
+		    tmpdouble2 = TMath::Abs(tmpdouble2);
+
+		    if (tmpdouble2 > SmallQuantity)
+		    {
+			*fLog << "MFindSupercutsONOFFThetaLoop::ComputeOverallSignificance()" 
+			      << endl
+			      << "Bins among the several alpha OFF histograms "
+			      << "for TRAIN sample do not match"
+			      << endl
+			      << "Function execution will be ABORTED." << endl;
+			return kFALSE;
+		    }
+		    
+
+		    // Vector containing number of events without 
+		    // normalization is updated
+
+		    // Vector containing number of events without 
+		    // normalization is filled
+		   
+			CombinedAlphaTestOFFWithoutNormalization[j-1] += 
+			    TmpTH1FHisto -> GetBinContent(j);
+		   
+
+
+
+		    
+		    
+		    // Histogram bin contents must be normalized (to the respective ON data)
+		    // by using the normalization constants stored in 
+		    // histogram NormFactorTestHisto before being added 
+		    // to CombinedAlphaTestOFF
+
+		   
+		    tmpdouble2 = CombinedAlphaTestOFF->GetBinContent(j) + 
+			(TmpTH1FHisto->GetBinContent(j) * tmpnormfactor);
+
+		    
+		    CombinedAlphaTestOFF-> SetBinContent(j,tmpdouble2);
+
+
+		     // (Bin Error)^2 is computed and added to  
+		    // ErrorInCombinedAlphaTestOFF 
+		    // Bin error = Sqrt(BinContent) X Normalization Factor
+
+		    tmperror = TmpTH1FHisto->GetBinContent(j) * tmpnormfactor;
+		    ErrorInCombinedAlphaTestOFF[j-1] += tmperror;
+
+
+		}
+		
+		// Dynamic memory allocated for TmpTH1FHisto is released
+
+		delete TmpTH1FHisto;
+	    
+	    }
+
+	    
+
+
+
+	}
+
+
+
+	// Mean Normalization factor is computed for the combined OFF histogram. 
+	// This factor will be used when computing the significance via 
+	// MHFindSignificance::FindSigmaONOFF().
+
+	// The bin contents (and errors) of teh combined OFF TEST histo will be 
+	// normalized (divided) by teh mean norm constant, so that 
+	// the histogram for OFF data given as argument in FindSigmaONOFF
+	// is equivalent to a non-normalized histogram. 
+	
+	MeanNormFactorTest = MeanNormFactorTest/TotalNumberOFFTest;
+
+
+
+	// Sqrt(Contents) is performed in ErrorInCombinedAlphaTestOFF, 
+	// in order to compute the real error in the bin content of histogram 
+	// CombinedAlphaTestOFF.
+
+	// Then error and contents (normalized with mean normfctor) are
+	// set to histogram bin 	
+
+
+
+
+	
+	for (Int_t j = 1; j <= NAlphaBins; j++)
+	{
+
+	    tmpdouble2 = 
+		(CombinedAlphaTestOFF -> GetBinContent(j))/MeanNormFactorTest;
+
+	    CombinedAlphaTestOFF -> SetBinContent(j,tmpdouble2);
+
+	    ErrorInCombinedAlphaTestOFF[j-1] = 
+		TMath::Sqrt(ErrorInCombinedAlphaTestOFF[j-1])/MeanNormFactorTest;
+
+	    // Proper error treatment for the bin contents 
+	    CombinedAlphaTestOFF -> SetBinError(j,ErrorInCombinedAlphaTestOFF[j-1]);
+	    
+	    
+	    // ******  TMP **************
+	    /*
+	    // Error computation assuming a given (no normalized) bin content
+	    
+	    tmpdouble = CombinedAlphaTestOFF -> GetBinContent(j);
+
+	    if (CombinedAlphaTestOFFWithoutNormalization[j-1] < SmallQuantity)
+	    {tmpnormfactor = 0;}
+	    else
+	    {tmpnormfactor = tmpdouble/CombinedAlphaTestOFFWithoutNormalization[j-1];}
+	   
+	    tmperror = (TMath::Sqrt(CombinedAlphaTestOFFWithoutNormalization[j-1])) * tmpnormfactor;
+	    
+	    CombinedAlphaTestOFF -> SetBinError(j,tmperror);
+	    
+	    */
+	    
+	    // ******  ENDTMP **************
+	    
+	    // tmp
+	    // cout << CombinedAlphaTestOFF -> GetBinContent(j) << " +/-  " 
+	    //	 << CombinedAlphaTestOFF -> GetBinError(j) << endl;
+	    
+	    // endtmp
+
+	}
+
+
+	
+	// Entries of histogram CombinedAlphaTestOFF is set to 
+	// the events counted during histogram filling
+	
+	EventCounter = EventCounter/MeanNormFactorTest;
+	tmpint = int(EventCounter);
+	CombinedAlphaTestOFF->SetEntries(tmpint);
+
+
+	cout << "SILLY INFO FOR TEST SAMPLE: Total number of events Before nomralization and " 
+	     << " re-re normalized" << endl
+	     << TotalNumberOFFTest << " - " << EventCounter << endl;
+
+	/*
+	// Sumw2() test
+
+	cout << "********   TEST   ********* " << endl;
+	cout << "Sumw2() is executed: " << endl;
+	CombinedAlphaTestOFF -> Sumw2();
+	for (Int_t j = 1; j <= NAlphaBins; j++)
+	{
+	     // tmp
+	    cout << CombinedAlphaTestOFF -> GetBinContent(j) << " +/-  " 
+		 << CombinedAlphaTestOFF -> GetBinError(j) << endl;
+	    
+	    // endtmp
+
+	}
+	  
+	*/
+	
+	
+
+    }
+
+
+
+     // *********  COMBINED  HISTOGRAMS FOR TEST SAMPLE ALREADY FILLED ********* ///
+
+
+    /*
+    CombinedAlphaTrainON-> DrawCopy();
+    gPad -> SaveAs("tmpONTrain.ps");
+
+    CombinedAlphaTrainOFF-> DrawCopy();
+    gPad -> SaveAs("tmpOFFTrain.ps");
+
+
+    CombinedAlphaTestON-> DrawCopy();
+    gPad -> SaveAs("tmpONTest.ps");
+
+    CombinedAlphaTestOFF-> DrawCopy();
+    gPad -> SaveAs("tmpOFFTest.ps");
+
+    */
+    
+
+    // ****  COMPUTATION OF SIGNIFICANCES FOR COMBINED ALPHA HISTOGRAMS  ****** ///
+    
+    if (SuccessfulThetaBinsVector.GetSize() >= 1)
+    {
+	// There is, at least, ONE theta bin for which optimization of 
+	// supercuts was SUCCESSFUL, and thus, it is worth to 
+	// compute significance of signal
+
+		
+	// Significance is found using MHFindSignificanceONOFF::FindSigmaONOFF
+	
+
+	
+	// Maximum value of alpha below which signal is expected
+	const Double_t alphasig = fAlphaSig; 
+
+	// Minimum value of alpha for bkg region in ON data
+	const Double_t alphabkgmin = fAlphaBkgMin;
+	
+	// Maximum value of alpha for bkg region in ON data
+	const Double_t alphabkgmax = fAlphaBkgMax;
+	
+	// degree of polynomial function used to fit ON data in background region
+	const Int_t    degree   =    2;
+
+	// degree of polynomial function used to fit OFF data in all alpha region (0-90)
+	const Int_t    degreeOFF   =    2;
+
+	const Bool_t   drawpoly  = kTRUE;
+	const Bool_t   fitgauss  = kTRUE;
+	const Bool_t   print     = kTRUE;
+    
+	const Bool_t saveplots   = kTRUE; // Save final alpha plot for ON and OFF 
+	// (with Nex and significance) in Psfile
+   
+
+
+
+	MHFindSignificanceONOFF findsig;
+	findsig.SetRebin(kTRUE);
+	findsig.SetReduceDegree(kFALSE);
+
+	
+
+	if (CombineTrainData)
+	{
+
+	    // Name of psfile where Alpha plot will be stored
+	    TString psfilename = ("TRAINSampleCombined"); 
+	    
+	    findsig.FindSigmaONOFF(CombinedAlphaTrainON, CombinedAlphaTrainOFF, 
+				   MeanNormFactorTrain, 
+				   alphabkgmin, alphabkgmax, 
+				   degree, degreeOFF,
+				   alphasig, 
+				   drawpoly, fitgauss, print, 
+				   saveplots, psfilename);
+
+
+	  fOverallSigmaLiMaTrain = double(findsig.GetSignificance());
+	  fOverallNexTrain = double(findsig.GetNexONOFF());
+
+	  *fLog << "MFindSupercutsONOFFThetaLoop::ComputeOverallSignificance" << endl
+		<< "After performing the combined analysis for TRAIN sample it was found " 
+		<< "the following Nex and Significance: " <<  fOverallNexTrain 
+		<< ", " << fOverallSigmaLiMaTrain << endl;
+	      
+
+	}
+
+
+	if (CombineTestData)
+	{
+
+	    // Name of psfile where Alpha plot will be stored
+	    TString psfilename = ("TESTSampleCombined"); 
+	    
+	    findsig.FindSigmaONOFF(CombinedAlphaTestON, CombinedAlphaTestOFF, 
+				   MeanNormFactorTest, 
+				   alphabkgmin, alphabkgmax, 
+				   degree, degreeOFF,
+				   alphasig, 
+				   drawpoly, fitgauss, print, 
+				   saveplots, psfilename);
+
+	    fOverallSigmaLiMaTest = double(findsig.GetSignificance());
+	    fOverallNexTest = double(findsig.GetNexONOFF());
+	    
+	    *fLog << "MFindSupercutsONOFFThetaLoop::ComputeOverallSignificance" << endl
+		  << "After performing the combined analysis for TEST sample it was found " 
+		  << "the following Nex and Significance: " <<  fOverallNexTest 
+		  << ", " << fOverallSigmaLiMaTest << endl;
+	    
+	}
+	
+	
+
+	
+    }
+
+
+    return kTRUE;
+}
+
+    
+    
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/MFindSupercutsONOFFThetaLoop.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/MFindSupercutsONOFFThetaLoop.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/MFindSupercutsONOFFThetaLoop.h	(revision 9661)
@@ -0,0 +1,443 @@
+#ifndef MARS_MFindSupercutsONOFFThetaLoop
+#define MARS_MFindSupercutsONOFFThetaLoop
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#ifndef ROOT_TArrayD
+#include <TArrayD.h>
+#endif
+#ifndef ROOT_TArrayI
+#include <TArrayI.h>
+#endif
+
+#ifndef ROOT_TH1F
+#include <TH1F.h>
+#endif
+
+#ifndef ROOT_TPostScript
+#include <TPostScript.h>
+#endif
+
+
+class MFilter;
+class MEvtLoop;
+class MH3;
+class MSupercutsCalcONOFF;
+class MFindSupercutsONOFF;
+class MGeomCam;
+class MHMatrix;
+
+
+class MFindSupercutsONOFFThetaLoop : public MParContainer
+{
+private:
+
+  TString fDataONRootFilename;
+  TString fDataOFFRootFilename;
+
+
+  TString fPathForFiles; // Path to directory where files (PsFiles, rootfiles) will be stored
+
+  
+  TString*  fOptSCParamFilenameVector; // Pointer to vector of TStrings containing name of the root files where optimized supercuts will be stored. To be created and filled once Vector of Costheta ranges is defined
+
+  
+
+
+  // Vectors containing the names of the root files where matrices 
+  // will be stored for Train/Test ON/OFF samples.
+  // To be defined and filled once vector fCosThetaRangeVector is 
+  // defined
+
+  TString* fTrainMatrixONFilenameVector;
+  TString* fTestMatrixONFilenameVector;
+  TString* fTrainMatrixOFFFilenameVector;
+  TString* fTestMatrixOFFFilenameVector;
+  
+
+  Double_t fAlphaSig; // Max alpha value were signal is expected
+
+
+  // Background range (in alpha) is defined by the member variables 
+  // fAlphaBkgMin and fAlphaBkgMax
+  Double_t fAlphaBkgMin; 
+  Double_t fAlphaBkgMax; 
+
+
+  // Size range of events used to fill the data matrices  
+  // is defined by the following variables
+
+  Double_t fSizeCutLow;
+  Double_t fSizeCutUp;
+
+  
+ // Variables for binning of alpha plots
+  
+  Int_t fNAlphaBins;
+  Double_t fAlphaBinLow;
+  Double_t fAlphaBinUp;
+
+
+
+  // Boolean variable used to disable the usage ("serious" usage) of the 
+  // quantities computed from fits. This will be useful in those cases 
+  // where there is too few events to perform a decent fit to the 
+  // alpha histograms. In general this variable will be always kTRUE
+  
+  Bool_t fUseFittedQuantities;
+
+
+  Double_t fPolyGaussFitAlphaSigma;
+
+
+  Double_t fWhichFractionTrain;  // number <= 1; specifying fraction of ON Train events
+  Double_t fWhichFractionTest;  // number <= 1; specifying fraction of ON Test events
+
+   Double_t fWhichFractionTrainOFF;  // number <= 1; specifying fraction of OFF  Train events
+  Double_t fWhichFractionTestOFF;  // number <= 1; specifying fraction of OFF Test events
+
+  Double_t fThetaMin; // Cuts in ThetaOrig.fVal (in rad!!!)
+  Double_t fThetaMax; // Cuts in ThetaOrig.fVal (in rad !!!)
+  TArrayD fCosThetaRangeVector; // vector containing the 
+  // theta ranges that will be used in the 
+  // optimization
+
+  TString* fThetaRangeStringVector; // Pointer to vector of TStrings that contain Cos theta ranges specified in fCosThetaRangeVector. It will be used to identify alpha distributions stored in fAlphaDistributionsRootFilename
+
+  TArrayD fCosThetaBinCenterVector; // vector containing the 
+  // theta bin centers of the theta ranges/bins contained in 
+  // fCosThetaRangeVector
+
+  Double_t fActualCosThetaBinCenter; // Theta value used to fill 
+  // the histograms fNormFactorTrainHist, fNormFactorTestHist, 
+  // fSigmaLiMaTrainHist ...
+
+  
+
+  Double_t fOverallNexTrain;
+  Double_t fOverallNexTest;
+
+  Double_t fOverallSigmaLiMaTrain;
+  Double_t fOverallSigmaLiMaTest;
+  
+
+  TH1F* fSuccessfulThetaBinsHist; // Hist containing theta bins were optimization was successful
+
+  TH1F* fNormFactorTrainHist; // Hist containing norm factors train for all Cos theta ranges
+  TH1F* fNormFactorTestHist; // Hist containing norm factors test for all Cos theta ranges
+  TH1F* fSigmaLiMaTrainHist; // Hist containing SigmaLiMa for Train samples for all Cos theta ranges
+  TH1F* fSigmaLiMaTestHist; // Hist containing SigmaLiMa for Test samples for all Cos theta ranges
+  TH1F* fNexTrainHist; // Hist containing Number os excess events for Train sample for all Cos thetas
+  TH1F* fNexTestHist; // Hist containing Number os excess events for Test sample for all Cos theta
+
+  TH1F* fNEvtsInTrainMatrixONHist; // Hist containing total number of events in Train Matrices of ON data for all Cos theta ranges
+  TH1F* fNEvtsInTestMatrixONHist; // Hist containing total number of events in Test Matrices of ON data for all Cos theta ranges
+  TH1F* fNEvtsInTrainMatrixOFFHist; // Hist containing total number of events in Train Matrices of OFF data for all Cos theta ranges
+  TH1F* fNEvtsInTestMatrixOFFHist; // Hist containing total number of events in Test Matrices of OFF data for all Cos theta ranges
+  
+
+
+ 
+  // Boolean variable that controls wether the optimization of the 
+  // parameters (MMinuitInterface::CallMinuit(..) in function FindParams(..))
+  // takes place or not. kTRUE will skip such optimization.
+  // This variable is useful to test the optmized parameters (previously found 
+  // and stored in root file) on the TRAIN sample.
+
+  Bool_t fSkipOptimization;
+
+
+
+
+  // Boolean variable that allows the user to write the initial parameters 
+  // into the root file that will be used to store the optimum cuts.
+  // If fUseInitialSCParams = kTRUE , parameters are written.
+  // In this way, the initial SC parameters can be applied on the data (train/test) 
+  
+  // The initial parameters are ONLY written to the root file if 
+  // there is NO SC params optimization, i.e., if variable 
+  // fSkipOptimization = kTRUE;
+  
+  // The default value is obviously kFALSE.
+
+  Bool_t fUseInitialSCParams;
+
+
+  Double_t fGammaEfficiency; // Fraction of gammas that remain after cuts
+  // Quantity that will have to be determined with MC
+
+  Bool_t fTuneNormFactor; // If true, normalization factors are corrected 
+  // using the estimated number of gammas and the gamma efficiency
+  // fNormFactor = fNormFactor - Ngammas/EventsInMatrixOFF
+
+
+  // Boolean variable used to determine wether the normalization factor is 
+  // computed from method 1) or 2)
+  // 1) Using total number of ON and OFF events before cuts, and tuning the factor 
+  //    correcting for "contamination" of gamma events in ON sample
+  // 2) Using number of ON and OFF events after cuts in the background 
+  //    region determined by variables fAlphaBkgMin-fAlphaBkgMax
+ 
+  Bool_t fNormFactorFromAlphaBkg; // if kTRUE, method 2) is used
+
+
+  // Boolean variable used to control decide wether to use theta information 
+  // in the computation of teh dynamical cuts.
+  Bool_t fNotUseTheta;
+  
+  // Boolean variable used to decide wether to use dynamical cuts or static cuts
+  // kTRUE means that static cuts are used. 
+  Bool_t fUseStaticCuts;
+
+
+  // Names for the Hadronness containers for ON and OFF data
+
+  TString  fHadronnessName;
+  TString  fHadronnessNameOFF;
+
+  // Vectors where initial SC parameters and steps are stored. 
+  // If these vectors are empty, initial SC parameters and steps 
+  // are taken from Supercuts container. 
+  // They will be intialized to empty vectors in constructor
+
+  TArrayD fInitSCPar;
+  TArrayD fInitSCParSteps;
+
+  
+
+  // Name of Postscript file where, for each theta bin,  alpha ON and OFF distributions 
+  //  after cuts (and hence, Nex and SigmaLiMa computations) will be stored
+  // If fAlphaDistributionsPostScriptFilename is not defined, postscript file is not 
+  // produced. It is an optional variable...
+
+  // Still not working...
+ 
+  TPostScript* fPsFilename; 
+
+
+  // ********************************************************
+  // Due to the failure of the use of object TPostScript
+  // to make a Ps document with all plots, I decided to use the 
+  // standard way (SaveAs(filename.ps)) to store plots related 
+  // to alpha distributions 
+  // for ON and OFF and BEFORE and AFTER cuts (VERY IMPORTANT
+  // TO COMPUTE EFFICIENCIES IN CUTS) 
+  
+  // Psfilename is set inside function LoopOverThetaRanges()
+  // and given to the object MFindSupercutsONOFF created 
+  // within this loop.
+
+  // This will have to be removed as soon as the TPostScript
+  // solutions works...
+  // ********************************************************
+  
+
+  TString fAlphaDistributionsRootFilename;
+  // Root file where histograms containing the ON alpha distribution and the 
+  // OFF alpha distribution (non normalized) , AFTER CUTS, are stored.
+  // Histograms containing the normalization factors, Nex and SigmaLiMa for 
+  // each theta bin will be also stored there.
+  // This name MUST be defined, since the histograms 
+  // stored there will be used by 
+  // function XXX to compute an overall Nex and sigmaLiMa 
+  // combining all those histograms
+
+  // Boolean variables seting flags for loop over theta ranges
+
+  Bool_t fReadMatricesFromFile;
+  Bool_t fOptimizeParameters;
+  Bool_t fTestParameters;
+  
+   //--------------------------------------------
+
+
+public:
+  MFindSupercutsONOFFThetaLoop(const char *name=NULL, 
+				  const char *title=NULL);
+  ~MFindSupercutsONOFFThetaLoop();
+
+  void SetHadronnessName(const TString &name)   
+      {fHadronnessName = name;}
+  void SetHadronnessNameOFF(const TString &name)   
+      {fHadronnessNameOFF = name;}
+
+  void SetPathForFiles(const TString &path)
+      {fPathForFiles = path;}
+
+  void SetDataONOFFRootFilenames(const TString &name1, const TString &name2 ) 
+      {fDataONRootFilename = name1;  fDataOFFRootFilename = name2; }
+
+
+
+  // Names of root files containing matrices and  optimizedparameters 
+   Bool_t SetALLNames(); 
+
+  // Function to set names manually... in case matrices are 
+  // already defined...
+
+  Bool_t SetNamesManually(TString* OptSCParamFilenameVector, 
+			  TString* ThetaRangeStringVector,
+			  TString* TrainMatrixONFilenameVector,
+			  TString* TestMatrixONFilenameVector,
+			  TString* TrainMatrixOFFFilenameVector,
+			  TString* TestMatrixOFFFilenameVector) 
+
+      {   
+	  fOptSCParamFilenameVector = OptSCParamFilenameVector;
+	  fThetaRangeStringVector = ThetaRangeStringVector;
+	  fTrainMatrixONFilenameVector = TrainMatrixONFilenameVector;
+	  fTestMatrixONFilenameVector = TestMatrixONFilenameVector;
+	  fTrainMatrixOFFFilenameVector = TrainMatrixOFFFilenameVector;
+	  fTestMatrixOFFFilenameVector = TestMatrixOFFFilenameVector; 
+
+	  return kTRUE;
+      }
+  
+  Bool_t SetAlphaDistributionsRootFilename(const TString &name); 
+
+
+  Bool_t SetAlphaSig (Double_t alphasig);
+
+  Bool_t SetAlphaBkgMin (Double_t alphabkgmin);
+  Bool_t SetAlphaBkgMax (Double_t alphabkgmax);
+
+  Bool_t CheckAlphaSigBkg();
+
+  void SetPostScriptFile(TPostScript* PsFile);
+
+
+  Bool_t SetCosThetaRangeVector (const TArrayD &d);
+  
+  Bool_t SetThetaRange (Int_t thetabin);
+
+
+  void SetAlphaPlotBinining(Int_t nbins, Double_t binlow, Double_t binup)
+    { fNAlphaBins = nbins; fAlphaBinLow = binlow; fAlphaBinUp = binup;}
+
+  Bool_t SetNormFactorTrainHist();
+  Bool_t SetNormFactorTestHist();
+  Bool_t SetSigmaLiMaTrainHist();
+  Bool_t SetSigmaLiMaTestHist();
+  Bool_t SetNexTrainHist();
+  Bool_t SetNexTestHist();
+  Bool_t SetNexSigmaLiMaNormFactorNEvtsTrainTestHist();
+  Bool_t SetSuccessfulThetaBinsHist();
+  void WriteNexSigmaLiMaNormFactorNEvtsTrainTestHistToFile();
+
+  void WriteSuccessfulThetaBinsHistToFile();
+  
+  
+  Bool_t SetInitSCPar (TArrayD &d);
+  Bool_t SetInitSCParSteps (TArrayD &d);
+
+  
+
+  Bool_t ReadSCParamsFromAsciiFile(const char* filename, Int_t Nparams);
+
+
+  void SetFractionTrainTestOnOffEvents(Double_t fontrain, 
+				       Double_t fontest, 
+				       Double_t fofftrain,
+				       Double_t fofftest);
+
+   void SetTuneNormFactor(Bool_t b) {fTuneNormFactor = b;}
+   Bool_t SetGammaEfficiency (Double_t gammaeff);
+   
+
+
+   void SetNormFactorFromAlphaBkg (Bool_t b) {fNormFactorFromAlphaBkg = b;}
+
+   void SetUseFittedQuantities (Bool_t b)
+      {fUseFittedQuantities = b;}
+
+   void SetReadMatricesFromFile(Bool_t b);
+   void SetTrainParameters(Bool_t b) {fOptimizeParameters = b;}
+   void SetTestParameters(Bool_t b) {fTestParameters = b;}
+
+
+   void SetSkipOptimization(Bool_t b) {fSkipOptimization = b;}
+
+   void SetUseInitialSCParams(Bool_t b) {fUseInitialSCParams = b;}
+
+
+   void SetVariableNotUseTheta(Bool_t b) {fNotUseTheta = b;}
+   Bool_t GetVariableNotUseTheta() { return fNotUseTheta;}
+
+
+   void SetVariableUseStaticCuts(Bool_t b) {fUseStaticCuts = b;}
+   Bool_t GetVariableUseStaticCuts() { return fUseStaticCuts;}
+
+
+   void SetSizeRange(Double_t SizeMin, Double_t SizeMax)
+	{fSizeCutLow = SizeMin; fSizeCutUp = SizeMax; }
+
+   // Function that loops over the theta ranges defined by 
+   // fCosThetaRangeVector optimizing parameter and/or testing
+   // parameters
+
+   Bool_t LoopOverThetaRanges();
+
+
+   // Function that loops over the alpha distributions (ON-OFF)
+   // stored in root file defined by fAlphaDistributionsRootFilename
+   // and computes the significance and Nex (using MHFindSignificanceONOFF::FindSigma)
+   // for several cuts in alpha (0-fAlphaSig; in bins defined for alpha distributions 
+   // by user).
+
+   // It creates the histograms, fills them and store them 
+   // in root file defined by fAlphaDistributionsRootFilename. A single histogram 
+   // for each theta bin.
+
+   // The function returns kFALSE if it could not accomplish its duty
+
+   Bool_t ComputeNexSignificanceVSAlphaSig();
+
+   
+
+
+   // Function that gets the histograms with the alpha distributions
+   // (for all the theta bins specified by fCosThetaRangeVector)
+   // stored in fAlphaDistributionsRootFilename, and combine them
+   // (correcting OFF histograms with the normalization factors stored 
+   // in NormFactorTrain or NormFactorTest) to get one single 
+   // Alpha distribution for ON and another one for OFF. 
+   // Then these histograms are given as arguments to 
+   // the function MHFindSignificanceONOFF::FindSigmaONOFF, 
+   // (Object of this class is created) to compute the 
+   // Overall Excess events and  significance, that will be 
+   // stored in variables fOverallNexTrain and fOverallSigmaLiMaTrain
+   // and Test.
+
+ 
+
+   Bool_t ComputeOverallSignificance(Bool_t CombineTrainData,
+				     Bool_t CombineTestData);
+
+
+   Double_t GetOverallNexTrain() {return fOverallNexTrain;}
+   Double_t GetOverallNexTest() {return fOverallNexTest;}
+   
+   Double_t GetOverallSigmaLiMaTrain() {return fOverallSigmaLiMaTrain;}
+   Double_t GetOverallSigmaLiMaTest() {return fOverallSigmaLiMaTest;}
+
+   Double_t GetGammaEfficiency() {return fGammaEfficiency;}
+
+   Double_t GetAlphaSig() {return fAlphaSig;}
+  Double_t GetAlphaBkgMin () {return fAlphaBkgMin;}
+  Double_t GetAlphaBkgMax () {return fAlphaBkgMax;}
+   
+  Bool_t GetSkipOptimization() {return fSkipOptimization;}
+
+  Bool_t GetUseFittedQuantities() {return fUseFittedQuantities;}
+ 
+   ClassDef(MFindSupercutsONOFFThetaLoop, 1) 
+  // Class for optimization of the Supercuts
+};
+
+#endif
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/MHFindSignificanceONOFF.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/MHFindSignificanceONOFF.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/MHFindSignificanceONOFF.cc	(revision 9661)
@@ -0,0 +1,3720 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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,  July 2003      <mailto:wittek@mppmu.mpg.de>
+!              David Paneque,    Nov 2003       <mailto:dpaneque@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MHFindSignificanceONOFF
+//
+// determines the significance of a gamma signal in an |alpha| plot
+// it uses real OFF events in the computation of excess events
+//
+// Input :  2 TH1 histogram (ON and OFF) of |alpha| : with 0 < |alpha| < 90 degrees
+//  
+//************TEMP ************************************************
+
+
+//         alphamin, alphamax :     defining the background region
+//         alphasig           :     defining the signal region for which
+//                                  the significance is calculated
+//         degree : the degree of the polynomial to be fitted to the background
+//                  ( a0 + a1*x + a2*x**2 + a3*x**3 + ...) 
+//
+// Output : 
+//
+//
+//   - the number of events in the signal region (Non)
+//     the number of background events in the signal region (Nbg)
+//     (counted number of events 'NoffSig' and fitted number of events 'NoffSigFitted 
+//   - the number of excess events in the signal region (Nex = Non - Nbg)
+//     (again, counted 'NexONOFF' and fitted 'NexONOFFFitted'
+//   - thew effective number of background events (Noff), and gamma :
+//     Nbg = gamma * Noff
+//   - 
+//   - the significance of the gamma signal according to Li & Ma               
+//     3 significances are computed 
+//        a) LiMa formula (17) using fitted quantities; fSigLiMa
+//        b) LiMa formula (17) using counted quantities; fSigLiMa2
+//        c) LiMa formula (5) using counted quantities.
+//
+// call member function 'FindSigmaONOFF' 
+//      to fit the background and to determine the significance  
+//
+//
+//
+/////////////////////////////////////////////////////////////////////////////
+
+////////// ***********  ENDTEMPORAL  *************************
+
+
+#include "MHFindSignificanceONOFF.h"
+
+#include <fstream>
+#include <math.h>
+
+#include <TArrayD.h>
+#include <TArrayI.h>
+#include <TH1.h>
+#include <TF1.h>
+#include <TCanvas.h>
+#include <TFitter.h>
+#include <TMinuit.h>
+#include <TPaveText.h>
+#include <TStyle.h>
+#include <TPostScript.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+#include "MMinuitInterface.h"
+
+
+ClassImp(MHFindSignificanceONOFF);
+
+using namespace std;
+
+const TString MHFindSignificanceONOFF::gsDefName  = "MHFindSignificanceONOFF";
+const TString MHFindSignificanceONOFF::gsDefTitle = "Find Significance in alpha plot";
+
+
+
+// --------------------------------------------------------------------------
+//
+// fcnpoly
+//
+// calculates the chi2 for the fit of the polynomial function 'poly' 
+// to the histogram 'fhist'
+//
+// it is called by CallMinuit() (which is called in FitPolynomial()) 
+//
+// bins of fhist with huge errors are ignored in the calculation of the chi2
+// (the huge errors were set in 'FitPolynomial()')
+//
+
+static void fcnpoly(Int_t &npar, Double_t *gin, Double_t &f, 
+                    Double_t *par, Int_t iflag)
+{
+    TH1 *fhist = (TH1*)gMinuit->GetObjectFit();
+    TF1 *fpoly = fhist->GetFunction("Poly");    
+
+
+    //-------------------------------------------
+
+    Double_t chi2 = 0.0;
+
+    Int_t nbins = fhist->GetNbinsX();
+    Int_t mbins = 0;
+    for (Int_t i=1; i<=nbins; i++)
+    {
+      Double_t content = fhist->GetBinContent(i);
+      Double_t error   = fhist->GetBinError(i);
+      Double_t center  = fhist->GetBinCenter(i);
+
+      //-----------------------------
+      // ignore unwanted points
+      if (error > 1.e19)
+        continue;
+
+      if (content <= 0.0)
+      {
+        gLog << "fcnpoly : bin with zero content; i, content, error = "
+             << i << ",  " << content << ",  " << error << endl;
+        continue;
+      }        
+
+      if (error <= 0.0)
+      {
+        gLog << "fcnpoly : bin with zero error; i, content, error = "
+             << i << ",  " << content << ",  " << error << endl;
+        continue;
+      }        
+
+      //-----------------------------
+      mbins++;
+
+      Double_t fu;
+      fu = fpoly->EvalPar(&center, par);
+
+      // the fitted function must not be negative
+      if (fu <= 0.0)
+      {
+        chi2 = 1.e10;
+        break;
+      }
+
+      Double_t temp = (content - fu) / error;
+      chi2 += temp*temp;
+    }
+
+    //-------------------------------------------
+
+    f = chi2;
+
+    //-------------------------------------------
+    // final calculations
+    //if (iflag == 3)
+    //{
+    //}    
+
+    //-------------------------------------------------------------
+}
+
+
+// --------------------------------------------------------------------------
+//
+// fcnpolyOFF
+//
+// calculates the chi2 for the fit of the polynomial function 'poly' 
+// to the histogram 'fhist'
+//
+// it is called by CallMinuit() (which is called in FitPolynomial()) 
+//
+// bins of fhist with huge errors are ignored in the calculation of the chi2
+// (the huge errors were set in 'FitPolynomial()')
+//
+
+static void fcnpolyOFF(Int_t &npar, Double_t *gin, Double_t &f, 
+		       Double_t *par, Int_t iflag)
+{
+    TH1 *fhist = (TH1*)gMinuit->GetObjectFit();
+    TF1 *fpoly = fhist->GetFunction("PolyOFF");    
+
+
+    //-------------------------------------------
+
+    Double_t chi2 = 0.0;
+
+    Int_t nbins = fhist->GetNbinsX();
+    Int_t mbins = 0;
+    for (Int_t i=1; i<=nbins; i++)
+    {
+      Double_t content = fhist->GetBinContent(i);
+      Double_t error   = fhist->GetBinError(i);
+      Double_t center  = fhist->GetBinCenter(i);
+
+      //-----------------------------
+      // ignore unwanted points
+      if (error > 1.e19)
+        continue;
+
+      if (content <= 0.0)
+      {
+        gLog << "fcnpoly : bin with zero content; i, content, error = "
+             << i << ",  " << content << ",  " << error << endl;
+        continue;
+      }        
+
+      if (error <= 0.0)
+      {
+        gLog << "fcnpoly : bin with zero error; i, content, error = "
+             << i << ",  " << content << ",  " << error << endl;
+        continue;
+      }        
+
+      //-----------------------------
+      mbins++;
+
+      Double_t fu;
+      fu = fpoly->EvalPar(&center, par);
+
+      // the fitted function must not be negative
+      if (fu <= 0.0)
+      {
+        chi2 = 1.e10;
+        break;
+      }
+
+      Double_t temp = (content - fu) / error;
+      chi2 += temp*temp;
+    }
+
+    //-------------------------------------------
+
+    f = chi2;
+
+    //-------------------------------------------
+    // final calculations
+    //if (iflag == 3)
+    //{
+    //}    
+
+    //-------------------------------------------------------------
+}
+
+
+
+
+// --------------------------------------------------------------------------
+//
+// fcnpolygauss
+//
+// calculates the chi2 for the fit of the (polynomial+Gauss) function 
+// 'PolyGauss' to the histogram 'fhist'
+//
+// it is called by CallMinuit() (which is called in FitGaussPoly()) 
+//
+// bins of fhist with huge errors are ignored in the calculation of the chi2
+// (the huge errors were set in 'FitGaussPoly()')
+//
+
+static void fcnpolygauss(Int_t &npar, Double_t *gin, Double_t &f, 
+                         Double_t *par, Int_t iflag)
+{
+    TH1 *fhist = (TH1*)gMinuit->GetObjectFit();
+    TF1 *fpolygauss = fhist->GetFunction("PolyGauss");    
+
+
+    //-------------------------------------------
+
+    Double_t chi2 = 0.0;
+
+    Int_t nbins = fhist->GetNbinsX();
+    Int_t mbins = 0;
+    for (Int_t i=1; i<=nbins; i++)
+    {
+      Double_t content = fhist->GetBinContent(i);
+      Double_t error   = fhist->GetBinError(i);
+      Double_t center  = fhist->GetBinCenter(i);
+
+      //-----------------------------
+      // ignore unwanted points
+      if (error > 1.e19)
+        continue;
+
+      if (content <= 0.0)
+      {
+        gLog << "fcnpolygauss : bin with zero content; i, content, error = "
+             << i << ",  " << content << ",  " << error << endl;
+        continue;
+      }        
+
+      if (error <= 0.0)
+      {
+        gLog << "fcnpolygauss : bin with zero error; i, content, error = "
+             << i << ",  " << content << ",  " << error << endl;
+        continue;
+      }        
+
+      //-----------------------------
+      mbins++;
+
+      Double_t fu;
+      fu = fpolygauss->EvalPar(&center, par);
+
+      // the fitted function must not be negative
+      if (fu <= 0.0)
+      {
+        chi2 = 1.e10;
+        break;
+      }
+
+      Double_t temp = (content - fu) / error;
+      chi2 += temp*temp;
+    }
+
+    //-------------------------------------------
+
+    f = chi2;
+
+    //-------------------------------------------
+    // final calculations
+    //if (iflag == 3)
+    //{
+    //}    
+
+    //-------------------------------------------------------------
+}
+
+
+
+// --------------------------------------------------------------------------
+//
+//  Constructor
+//
+MHFindSignificanceONOFF::MHFindSignificanceONOFF(const char *name, const char *title)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+
+//    fSigVsAlpha = NULL;
+
+    fPoly   = NULL;
+    fPolyOFF   = NULL;
+    fPolyOFFNormalized   = NULL;
+    fGPoly  = NULL;
+    fGBackg = NULL;
+
+    fHist     = NULL;
+    fHistOrig = NULL;
+
+    fHistOFF     = NULL;
+    fHistOrigOFF = NULL;
+    fHistOFFNormalized = NULL;
+
+    // allow rebinning of the alpha plot
+    fRebin = kTRUE;
+
+    // allow reducing the degree of the polynomial
+    fReduceDegree = kTRUE;
+
+    // Low and Upper limits for the OFF alpha distribution fit
+    // are set to 0 and 90 degrees respectively
+
+    fAlphaminOFF = 0.0;
+    fAlphamaxOFF = 90.0;
+    
+    // use quantities computed from the fits
+    // The variable allows the user to NOT use these quantities when there is not 
+    // enough statistics and fit not always is possible.
+    // Default value is kTRUE.
+    fUseFittedQuantities = kTRUE;
+
+    // Bool variable used to decide wether to print or not the results 
+    // of the fit, significance, Nex... onto the final alpha plot. 
+    // for the time being, this variable is set in the constructor. 
+    // At some point, I might make it such it can be set externally...
+
+    fPrintResultsOntoAlphaPlot = kTRUE;
+
+
+
+    fCanvas = NULL;
+    
+    fSavePlots = kFALSE; // By default plots are not saved in Postscriptfiles
+
+    fPsFilename = NULL;
+
+   
+
+}
+
+// --------------------------------------------------------------------------
+//
+//  Destructor. 
+//
+// =====>  it is not clear why one obtains sometimes a segmentation violation
+//         when the destructor is active     <=======================
+//
+// therefore the 'return'statement
+//
+
+MHFindSignificanceONOFF::~MHFindSignificanceONOFF()
+{
+
+
+    
+     return;
+    
+    *fLog << "destructor of MHFindSignificanceONOFF is called" << endl;
+    
+
+    fPsFilename = NULL;
+  
+    cout << "PS set to null... " << endl;
+
+    delete fHist;
+    delete fHistOFF;
+
+    delete fHistOFFNormalized;
+
+    cout << "Histos removed..." << endl;
+
+    delete fPoly;
+    delete fPolyOFF;
+    delete fPolyOFFNormalized;
+    delete fGPoly;
+    delete fGBackg;
+  
+    cout << "Functions are also removed..." << endl;
+    
+    // delete fCanvas; if I removed fCanvas pointed memory address the 
+    // program crashes  ???
+
+    *fLog << "destructor of MHFindSignificanceONOFF finished successfully" << endl;
+
+   
+}
+
+// --------------------------------------------------------------------------
+//
+//  Set flag fRebin 
+//
+//  if flag is kTRUE rebinning of the alpha plot is allowed
+//
+//
+void MHFindSignificanceONOFF::SetRebin(Bool_t b)
+{
+  fRebin = b;
+
+  *fLog << "MHFindSignificanceONOFF::SetRebin; flag fRebin set to " 
+        << (b? "kTRUE" : "kFALSE") << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Set flag fReduceDegree 
+//
+//  if flag is kTRUE reducing of the degree of the polynomial is allowed
+//
+//
+void MHFindSignificanceONOFF::SetReduceDegree(Bool_t b)
+{
+  fReduceDegree = b;
+
+  *fLog << "MHFindSignificanceONOFF::SetReduceDegree; flag fReduceDegree set to " 
+        << (b? "kTRUE" : "kFALSE") << endl;
+}
+
+// Function that returns one of the 3 LiMa sigmas. 
+// The returned value is the one used in the optimization 
+// and final alpha plots. 
+
+// For the time being, if fUseFittedQuantities = kTRUE (default)
+// fSigLiMa is used, otherwise, fSigLiMa2 is used. 
+
+Double_t MHFindSignificanceONOFF::GetSignificance()
+{
+
+    if(fUseFittedQuantities)
+    {   
+	return fSigLiMa;
+    }
+
+    return fSigLiMa2;
+
+
+    
+}
+
+
+// --------------------------------------------------------------------------
+//
+//  FindSigmaONOFF
+//
+//  calls FitPolynomialOFF  it gets bkg events in "signal" region 
+//                          from histogram histOFF which is the alpha 
+//                          distribution of OFF data NON normalized. 
+//                          Normalization factor is also one of the 
+//                          arguments.
+//  calls DetExcess         to determine the number of excess events
+//                          using the previously computed bkg events
+
+//  calls SigmaLiMa         to determine the significance of the gamma signal
+//                          in the range |alpha| < alphasig
+//  calls FitGaussPoly      to fit a (polynomial+Gauss) function in the
+//                          whole |alpha| region of ON - OFF diagram 
+//
+//
+
+Bool_t MHFindSignificanceONOFF::FindSigmaONOFF(TH1 *fhistON,  
+					       TH1 *fhistOFF,
+					       Double_t NormFactor,
+					       Double_t alphamin,
+					       Double_t alphamax,
+					       Int_t degreeON, 
+					       Int_t degreeOFF,
+					       Double_t alphasig, 
+					       Bool_t drawpoly,   
+					       Bool_t fitgauss, 
+					       Bool_t print, 
+					       Bool_t saveplots, 
+					       //TPostScript* PsFile
+					       const TString psfilename)
+{
+    
+    //*fLog << "MHFindSignificanceONOFF::FindSigma;" << endl;
+ 
+
+    // Pointer to object TPostScript where plots will be stored 
+    // is copied into member varialbe 
+    // NOT WORKING !!!
+    // fPsFilename = PsFile;
+
+    // Temporally (while TPostSctipt option is not working) psfiles 
+    // will be produced by the standard way (Canvas.SaveAs())
+
+    fPsFilenameString = psfilename;
+
+
+
+    // "3 Li and Ma significances" are initialized to 0.0
+
+    fSigLiMa = 0.0;
+    fSigLiMa2 = 0.0;
+    fSigLiMa3 = 0.0;
+   
+    
+    // fNormFactor is set 
+    
+    fNormFactor = NormFactor;
+
+    // Report when this histograms given in the 
+    // arguments are empty
+    
+    Double_t tmpdouble= -1.0;
+    
+    tmpdouble = double(fhistON->GetEntries());
+    if (tmpdouble < 0.5)
+    {
+	cout << "MHFindSignificanceONOFF::FindSigmaONOFF; ERROR " << endl
+	     << "fhistON has ZERO entries" << endl;
+   } 
+
+    tmpdouble = double(fhistOFF->GetEntries());
+    if (tmpdouble < 0.5)
+    {
+	cout << "MHFindSignificanceONOFF::FindSigmaONOFF; ERROR " << endl
+	     << "fhistOFF has ZERO entries" << endl;
+    } 
+
+
+
+   
+    // Variables set for alpha from ON events
+    fHistOrig = fhistON;
+    fHist = (TH1*)fHistOrig->Clone();
+    fHist->SetName(fhistON->GetName());
+    fDegree   = degreeON;
+
+
+     // Variables set for alpha from OFF events
+
+    fHistOrigOFF = fhistOFF;    
+    fHistOFF = (TH1*)fHistOrigOFF->Clone();
+    fHistOFF->SetName(fhistOFF->GetName());
+    fDegreeOFF   = degreeOFF;
+
+    if ( !fHist )
+    {
+	*fLog << "MHFindSignificanceONOFF::FindSigmaONOFF; Clone of histogram could not be generated" 
+	      << endl;
+	return kFALSE;
+    }
+
+
+    
+    if ( !fHistOFF )
+    {
+	*fLog << "MHFindSignificanceONOFF::FindSigmaONOFF; Clone of OFF histogram could not be generated" 
+	      << endl;
+	return kFALSE;
+    }
+
+
+
+  
+  fHist->Sumw2();
+  fHist->SetXTitle("|alpha|  [\\circ]");
+  fHist->SetYTitle("Counts");
+  fHist->UseCurrentStyle();
+  
+
+  fHistOFF->Sumw2(); // if error has been set (via function SetBinError(j))
+   // the errors set remain, i.e. are not overwritten with the sum of the square of weights.
+  // Which means that this function will not have any effect.
+
+  fHistOFF->SetXTitle("|alpha|  [\\circ]");
+  fHistOFF->SetYTitle("Counts");
+  fHistOFF->UseCurrentStyle();
+  
+
+  
+
+
+/////////////////////////////////////
+
+  fAlphamin = alphamin;
+  fAlphamax = alphamax;
+  fAlphammm = (alphamin+alphamax)/2.0;
+  fAlphasig = alphasig;
+
+
+
+
+  // UYpper limits for fit to OFF data set are taken also from alphamax
+  // fAlphaminOFF is set in constructor. Inn principle, it WILL ALWAYS BE ZERO.
+
+  fAlphamaxOFF = alphamax;
+
+  
+  fDraw     = drawpoly;
+  fSavePlots = saveplots;
+  fFitGauss = fitgauss;
+  
+
+  //--------------------------------------------
+  // fit a polynomial in the backgr  region
+  
+  //*fLog << "MHFindSignificanceONOFF::FindSigma;  calling FitPolynomial()" << endl;
+  if ( !FitPolynomialOFF())
+  {
+      *fLog << "MHFindSignificanceONOFF::FindSigmaONOFF; PolynomialOFF failed"
+	    << endl;  
+      return kFALSE;
+  }
+      
+      
+  //--------------------------------------------
+  // calculate the number of excess events in the signal region
+  
+  //*fLog << "MHFindSignificanceONOFF::FindSigma;  calling DetExcess()" << endl;
+  if ( !DetExcessONOFF())
+  {
+      *fLog << "MHFindSignificanceONOFF::FindSigmaONOFF; DetExcessONOFF failed"
+	    << endl;  
+      return kFALSE;
+  }
+
+  
+
+
+
+  //--------------------------------------------
+  // calculate the significance of the excess
+
+  //*fLog << "MHFindSignificanceONOFF::FindSigma;  calling SigmaLiMa()" << endl;
+
+  // For testing purposes "3 Li&Ma significances" will be computed
+  // At some point, only one will remain
+
+
+  Double_t siglima = 0.0;
+  
+
+  // Significance computed using effective number of OFF events  in signal 
+  // region (fNoff) and gamma factor (fGama).
+  // This is Wolfgang approach to the calulation of significance 
+  // using Li&Ma formula and estimated OFF events from polynomial fit.
+  
+  if(fUseFittedQuantities) 
+  {
+      if ( !SigmaLiMa(fNon, fNoff, fGamma, &siglima) )
+      {
+	  *fLog << "MHFindSignificanceONOFF::FindSigmaONOFF; SigmaLiMa failed"
+		<< endl;  
+	  return kFALSE;
+      }
+
+      fSigLiMa = siglima;
+  }
+  else
+  {
+      fSigLiMa = 0.0;
+  }
+
+
+
+  // Significance computed using counted number of OFF events in signal 
+  // region (fNoffSig) and normalization factor (fNormFactor).
+  // This is the strictly speaking the significance in Li&Ma paper...
+  
+  
+  if ( !SigmaLiMa(fNon, fNoffSig, fNormFactor, &siglima) )
+  {
+      *fLog << "MHFindSignificanceONOFF::FindSigmaONOFF; SigmaLiMa2 failed"
+	    << endl;  
+      return kFALSE;
+  }
+  fSigLiMa2 = siglima;
+  
+  
+  // Significance computed using counted number of OFF events in signal 
+  // region (fNoffSig) and normalization factor (fNormFactor). 
+  // significance of gamma signal according to Li & Ma using  
+  // formula (5)
+
+
+
+  if ( !SigmaLiMaForm5(fNon, fNoffSig, fNormFactor, &siglima) )
+      {
+	  *fLog << "MHFindSignificanceONOFF::FindSigmaONOFF; SigmaLiMa failed"
+		<< endl;  
+	  return kFALSE;
+      }
+
+  fSigLiMa3 = siglima;
+  
+    
+  
+ 
+ 
+//--------------------------------------------
+// calculate the error of the number of excess events
+// using fitted quantities and counted quantities
+ 
+ 
+// from fit to OFF histogram
+
+ if (fSigLiMa > 0.0) 
+ {fdNexONOFFFitted = fNexONOFFFitted / fSigLiMa;}
+ else
+ {fdNexONOFFFitted = 0.0;}
+
+
+ // from counted OFF events
+ if (fSigLiMa2 > 0.0) 
+ {
+     fdNexONOFF = fNexONOFF / fSigLiMa2;
+ }
+ else
+ {
+     fdNexONOFF = 0.0;
+ }
+
+  if (fDraw || fFitGauss)
+  {
+      
+      // ------------------------------------------------
+      // Polynomial fit to bkg region from ON data is performed, 
+      // Because some of the quantities will be used as 
+      // initial values in the PolyGAuss fit.
+      
+      // Besides, this function will modify the binning of fHist 
+      // so that the number of events in each bin is big enough
+      
+      // This might change in future...
+      
+      if ( !FitPolynomial())
+      {
+	  *fLog << "MHFindSignificanceONOFF::FindSigmaONOFF; Polynomial fit failed"
+		<< endl;  
+	  return kFALSE;
+      }
+  }
+
+
+  if (fDraw)
+  {
+
+      // Compute fHistOFFNormalized
+
+      if (!ComputeHistOFFNormalized())
+      {
+	  *fLog << "MHFindSignificanceONOFF::ComputeHistOFFNormalized; Normalization of fHistOFF was not possible"
+		<< endl;  
+	  return kFALSE;
+	  
+      }
+  }
+
+
+ 
+
+
+  //--------------------------------------------
+
+  //*fLog << "MHFindSignificanceONOFF::FindSigma;  calling PrintPoly()" << endl;
+  if (print)
+    PrintPolyOFF();
+
+
+
+  
+  
+
+
+
+
+  //--------------------------------------------
+  // fit a (polynomial + Gauss) function to the ON-OFF alpha distribution 
+
+  if (fFitGauss)
+  {
+
+    //--------------------------------------------------
+    // delete objects from this fit
+    // in order to have independent starting conditions for the next fit
+
+      delete gMinuit;
+      gMinuit = NULL;
+    //--------------------------------------------------
+
+       //*fLog << "MHFindSignificanceONOFF::FindSigma;  calling FitGaussPoly()" 
+      //      << endl;
+    if ( !FitGaussPoly() )
+    {
+      *fLog << "MHFindSignificanceONOFF::FindSigmaONOFF; FitGaussPoly failed"  
+      	    << endl;  
+      return kFALSE;
+    }
+
+    if (print)
+    {
+      //*fLog << "MHFindSignificanceONOFF::FindSigma;  calling PrintPolyGauss()" 
+      //      << endl;
+      PrintPolyGauss();
+    }
+  }
+
+  //--------------------------------------------------
+  // draw the histogram if requested
+
+  if (fDraw)
+  {
+
+
+       // TEMPORALLY I will plot fHistOFF and fHistOFFNormalized (with the fits)
+
+      
+      if (!DrawHistOFF())
+      {
+	  *fLog << "MHFindSignificanceONOFF::DrawHistOFF; Drawing  of fHistOFF was not possible"
+		<< endl;  
+	  // return kFALSE;
+	  
+      }
+      
+     
+      if (!DrawHistOFFNormalized())
+      {
+	  *fLog << "MHFindSignificanceONOFF::DrawHistOFFNormalized; Drawing  of fHistOFFNormalized was not possible"
+		<< endl;  
+	  // return kFALSE;
+	  
+      }
+
+
+
+
+    //*fLog << "MHFindSignificanceONOFF::FindSigma;  calling DrawFit()" << endl;
+      if ( !DrawFit() )
+      {
+	  *fLog << "MHFindSignificanceONOFF::FindSigmaONOFF; DrawFit failed"  
+		<< endl;  
+	  return kFALSE;
+      }
+  }
+  
+
+  //--------------------------------------------------
+  // delete objects from this fit
+  // in order to have independent starting conditions for the next fit
+
+  delete gMinuit;
+  gMinuit = NULL;
+  //--------------------------------------------------
+  
+  return kTRUE;
+
+}
+
+ 
+//// ********************* end sigmaonoff ************************
+
+
+
+
+
+
+
+// UNDER CONSTRUCTION
+
+Bool_t MHFindSignificanceONOFF::SigmaVsAlphaONOFF(TH1 *fhistON, TH1 *fhistOFF,  
+					   Double_t alphamin, Double_t alphamax, 
+					   Int_t degree, Bool_t print)
+{
+    *fLog << "   MHFindSignificanceONOFF::SigmaVsAlphaONOFF still under construction !!!" << endl;
+
+    return kFALSE;
+
+}
+
+
+
+
+// --------------------------------------------------------------------------
+//
+//  FitPolynomialOFF
+//  - create a clone 'fHistOFF' of the |alpha| distribution 'fHistOrigOFF'
+//  - fit a polynomial of degree 'fDegreeOFF' to the alpha distribution 
+//    'fHistOFF' in the region alphaminOFF < |alpha| < alphamaxOFF
+
+
+
+Bool_t MHFindSignificanceONOFF::FitPolynomialOFF()
+
+{
+  //--------------------------------------------------
+  // check the histogram :
+  //       - calculate initial values of the parameters
+  //       - check for bins with zero entries
+  //       - set minimum errors
+  //       - save the original errors
+  //       - set errors huge outside the fit range
+  //         (in 'fcnpolyOFF' points with huge errors will be ignored)
+
+
+  Double_t dummy = 1.e20;
+
+  Double_t mean;
+  Double_t rms;
+  Double_t nclose;
+  Double_t nfar;
+  Double_t a2init = 0.0;
+  TArrayD  saveError;
+
+  Int_t nbins;
+  Int_t nrebin = 1;
+
+
+ //----------------   start while loop for rebinning   -----------------
+  while(1)
+  {
+
+  fNzeroOFF   = 0;
+  fMbinsOFF   = 0;
+  fMlowOFF   = 0;
+  fNoffTot = 0.0;
+
+  // same variables (as in fitpoly to ON data) are used
+  // here for naming the actual values for low/up limit for fit
+  fAlphami =  10000.0;
+  fAlphamm =  10000.0;
+  fAlphama = -10000.0;
+
+  mean   = 0.0;
+  rms    = 0.0;
+  nclose = 0.0;
+  nfar   = 0.0;
+
+  nbins = fHistOFF->GetNbinsX();
+  saveError.Set(nbins);
+
+  for (Int_t i=1; i<=nbins; i++)
+  {
+    saveError[i-1] = fHistOFF->GetBinError(i);
+
+    // bin should be completely contained in the fit range
+    // (fAlphaminOFF, fAlphamaxOFF)
+    Double_t  xlo = fHistOFF->GetBinLowEdge(i);
+    Double_t  xup = fHistOFF->GetBinLowEdge(i+1);
+
+    if ( xlo >= fAlphaminOFF-fEps  &&  xlo <= fAlphamaxOFF+fEps  &&
+	 xup >= fAlphaminOFF-fEps  &&  xup <= fAlphamaxOFF+fEps     )
+    {
+      fMbinsOFF++;
+
+      if ( xlo < fAlphami )
+        fAlphami = xlo;
+
+      if ( xup > fAlphama )
+        fAlphama = xup;
+
+      Double_t content = fHistOFF->GetBinContent(i);
+      // fNoffTot += content;
+
+      mean += content;
+      rms  += content*content;
+
+// count events in low-alpha and high-alpha region
+      if ( xlo >= fAlphammm-fEps  &&  xup >= fAlphammm-fEps)
+      {
+        nfar   += content;
+        if ( xlo < fAlphamm )
+          fAlphamm = xlo;
+        if ( xup < fAlphamm )
+          fAlphamm = xup; 
+      }
+      else
+      {
+        nclose += content;
+        if ( xlo > fAlphamm )
+          fAlphamm = xlo;
+        if ( xup > fAlphamm )
+          fAlphamm = xup; 
+      }
+
+      // count bins with zero entry
+      if (content <= 0.0)
+        fNzeroOFF++;
+     
+      // set minimum error
+      if (content < 9.0)
+      {
+        fMlowOFF += 1;
+        fHistOFF->SetBinError(i, 3.0);
+      }
+
+      //*fLog << "Take : i, content, error = " << i << ",  " 
+      //      << fHist->GetBinContent(i) << ",  "
+      //      << fHist->GetBinError(i)   << endl;
+
+      continue;
+    }    
+    // bin is not completely contained in the fit range : set error huge
+
+    fHistOFF->SetBinError(i, dummy);
+
+    //*fLog << "Omit : i, content, error = " << i << ",  " 
+    //      << fHist->GetBinContent(i) << ",  " << fHist->GetBinError(i) 
+    //      << endl;
+
+  }
+
+  // mean of entries/bin in the fit range
+  if (fMbinsOFF > 0)
+  {
+    mean /= ((Double_t) fMbinsOFF);
+    rms  /= ((Double_t) fMbinsOFF);
+  }
+
+  rms = sqrt( rms - mean*mean );
+
+  // if there are no events in the background region
+  //    there is no reason for rebinning
+  //    and this is the condition for assuming a constant background (= 0)
+  if (mean <= 0.0)
+    break;
+
+  Double_t helpmi = fAlphami*fAlphami*fAlphami;
+  Double_t helpmm = fAlphamm*fAlphamm*fAlphamm;
+  Double_t helpma = fAlphama*fAlphama*fAlphama;
+  Double_t help   =   (helpma-helpmm) * (fAlphamm-fAlphami)    
+	            - (helpmm-helpmi) * (fAlphama-fAlphamm);
+  if (help != 0.0)
+    a2init =  ( (fAlphamm-fAlphami)*nfar - (fAlphama-fAlphamm)*nclose )
+                * 1.5 * fHistOFF->GetBinWidth(1) / help;
+  else
+    a2init = 0.0;
+
+
+  //--------------------------------------------
+  // rebin the histogram
+  //   - if a bin has no entries 
+  //   - or if there are too many bins with too few entries
+  //   - or if the new bin width would exceed half the size of the 
+  //     signal region
+
+  if ( !fRebin  ||
+       ( fNzeroOFF <= 0 && (Double_t)fMlowOFF<0.05*(Double_t)fMbinsOFF )  || 
+       (Double_t)(nrebin+1)/(Double_t)nrebin * fHistOFF->GetBinWidth(1) 
+                                                           > fAlphasig/2.0 )
+  {
+    //*fLog << "before break" << endl;
+    break;
+  }
+
+  nrebin += 1;
+  TString histname = fHistOFF->GetName();
+  delete fHistOFF;
+  fHistOFF = NULL;
+
+  *fLog << "MHFindSignificanceONOFF::FitPolynomialOFF; rebin the |alpha|OFF plot, grouping "
+        << nrebin << " bins together" << endl;
+
+  // TH1::Rebin doesn't work properly
+  //fHist = fHistOrig->Rebin(nrebin, "Rebinned");
+  // use private routine RebinHistogram()
+  fHistOFF = new TH1F;
+  fHistOFF->Sumw2();
+  fHistOFF->SetNameTitle(histname, histname);
+  fHistOFF->UseCurrentStyle();
+
+  // do rebinning such that x0 remains a lower bin edge
+  Double_t x0 = 0.0;
+  if ( !RebinHistogramOFF(x0, nrebin) )
+  {
+    *fLog << "MHFindSignificanceONOFF::FitPolynomialOFF; RebinHistgramOFF() failed" 
+          << endl;
+    return kFALSE;
+  }
+
+  fHistOFF->SetXTitle("|alpha|  [\\circ]");
+  fHistOFF->SetYTitle("Counts");
+  
+  }
+  //----------------   end of while loop for rebinning   -----------------
+
+
+  // if there are still too many bins with too few entries don't fit
+  // and assume a constant background
+
+  fConstantBackg = kFALSE;
+  if ( fNzeroOFF > 0  ||  (Double_t)fMlowOFF>0.05*(Double_t)fMbinsOFF ) 
+  {
+    *fLog << "MHFindSignificanceONOFF::FitPolynomialOFF; polynomial fit not possible,  fNzeroOFF, fMlowOFF, fMbinsOFF = "
+          << fNzeroOFF << ",  " << fMlowOFF << ",  " << fMbinsOFF << endl;
+    *fLog << "                    assume a constant background" << endl;
+
+    fConstantBackg = kTRUE;
+    fDegreeOFF        = 0;
+
+    TString funcname = "PolyOFF";
+    Double_t xmin =   0.0;
+    Double_t xmax =  90.0;
+
+    TString formula = "[0]";
+
+    fPolyOFF = new TF1(funcname, formula, xmin, xmax);
+    TList *funclist = fHistOFF->GetListOfFunctions();
+    funclist->Add(fPolyOFF);
+
+    //--------------------
+    Int_t nparfree = 1;
+    fChisqOFF         = 0.0; 
+    fNdfOFF           = fMbinsOFF - nparfree;
+    fProbOFF          = 0.0;
+    fIstatOFF         = 0;
+
+    fValuesOFF.Set(1);
+    fErrorsOFF.Set(1);
+
+    Double_t val, err;
+    val = mean;
+    err = sqrt( mean / (Double_t)fMbinsOFF );
+
+    fPolyOFF->SetParameter(0, val);
+    fPolyOFF->SetParError (0, err);
+
+    fValuesOFF[0] = val;
+    fErrorsOFF[0] = err; 
+
+    fEmaOFF[0][0]  = err*err;
+    fCorrOFF[0][0] = 1.0;
+    //--------------------
+    //--------------------------------------------------
+    // reset the errors of the points in the histogram
+    for (Int_t i=1; i<=nbins; i++)
+    {
+      fHistOFF->SetBinError(i, saveError[i-1]);
+    }
+
+
+    return kTRUE;
+  }
+
+
+  //===========   start loop for reducing the degree   ==================
+  //              of the polynomial
+  while (1)
+  {
+      //--------------------------------------------------
+      // prepare fit of a polynomial :   (a0 + a1*x + a2*x**2 + a3*x**3 + ...)
+
+      TString funcname = "PolyOFF";
+      Double_t xmin =   0.0;
+      Double_t xmax =  90.0;
+
+      TString formula = "[0]";
+      TString bra1     = "+[";
+      TString bra2     =    "]";
+      TString xpower   = "*x";
+      TString newpower = "*x";
+      for (Int_t i=1; i<=fDegreeOFF; i++)
+      {
+          formula += bra1;
+          formula += i;
+          formula += bra2;
+          formula += xpower;
+
+          xpower += newpower;
+      }
+
+      //*fLog << "FitPolynomial : formula = " << formula << endl;
+
+      fPolyOFF = new TF1(funcname, formula, xmin, xmax);
+      TList *funclist = fHistOFF->GetListOfFunctions();
+      funclist->Add(fPolyOFF);
+
+      //------------------------
+      // attention : the dimensions must agree with those in CallMinuit()
+      const UInt_t npar = fDegreeOFF+1;
+
+      TString parname[npar];
+      TArrayD vinit(npar);
+      TArrayD  step(npar);
+      TArrayD limlo(npar);
+      TArrayD limup(npar);
+      TArrayI   fix(npar);
+
+      vinit[0] =   mean;
+      vinit[2] = a2init;
+
+      for (UInt_t j=0; j<npar; j++)
+      {
+          parname[j]  = "p";
+          parname[j] += j+1;
+
+          step[j] = vinit[j] != 0.0 ? TMath::Abs(vinit[j]) / 10.0 : 0.000001;
+      }
+
+      // limit the first coefficient of the polynomial to positive values
+      // because the background must not be negative
+      limup[0] = fHistOFF->GetEntries();
+
+      // use the subsequernt loop if you want to apply the
+      // constraint : uneven derivatives (at alpha=0) = zero
+      for (UInt_t j=1; j<npar; j+=2)
+      {
+          vinit[j] = 0;
+          step[j]  = 0;
+          fix[j]   = 1;
+      }
+
+      //*fLog << "FitPolynomial : before CallMinuit()" << endl;
+
+      MMinuitInterface inter;
+      const Bool_t rc = inter.CallMinuit(fcnpolyOFF, parname, vinit, step,
+                                         limlo, limup, fix, fHistOFF, "Migrad",
+                                         kFALSE);
+
+      //*fLog << "FitPolynomial : after CallMinuit()" << endl;
+
+      if (rc != 0)
+      {
+          //  *fLog << "MHFindSignificanceONOFF::FitPolynomial; polynomial fit failed"
+          //        << endl;
+          //  return kFALSE;
+      }
+
+      //-------------------
+      // get status of minimization
+      Double_t fmin   = 0;
+      Double_t fedm   = 0;
+      Double_t errdef = 0;
+      Int_t    npari  = 0;
+      Int_t    nparx  = 0;
+
+      if (gMinuit)
+          gMinuit->mnstat(fmin, fedm, errdef, npari, nparx, fIstatOFF);
+
+      *fLog << "MHFindSignificanceONOFF::FitPolynomialOFF; fmin, fedm, errdef, npari, nparx, fIstat = "
+            << fmin << ",  " << fedm << ",  " << errdef << ",  " << npari
+            << ",  " << nparx << ",  " << fIstatOFF << endl;
+
+
+      //-------------------
+      // store the results
+
+      Int_t nparfree = gMinuit!=NULL ? gMinuit->GetNumFreePars() : 0;
+      fChisqOFF         = fmin;
+      fNdfOFF          = fMbinsOFF - nparfree;
+      fProbOFF          = TMath::Prob(fChisqOFF, fNdfOFF);
+
+
+      // get fitted parameter values and errors
+      fValuesOFF.Set(npar);
+      fErrorsOFF.Set(npar);
+
+      for (Int_t j=0; j<=fDegreeOFF; j++)
+      {
+          Double_t val, err;
+          if (gMinuit)
+              gMinuit->GetParameter(j, val, err);
+
+          fPolyOFF->SetParameter(j, val);
+          fPolyOFF->SetParError(j, err);
+
+          fValuesOFF[j] = val;
+          fErrorsOFF[j] = err;
+      }
+
+      // if the highest coefficient (j0) of the polynomial
+      // is consistent with zero reduce the degree of the polynomial
+
+      Int_t j0 = 0;
+      for (Int_t j=fDegreeOFF; j>1; j--)
+      {
+          // ignore fixed parameters
+          if (fErrorsOFF[j] == 0)
+              continue;
+
+          // this is the highest coefficient
+          j0 = j;
+          break;
+      }
+
+      if (!fReduceDegree || j0==0 || TMath::Abs(fValuesOFF[j0]) > fErrorsOFF[j0])
+          break;
+
+      // reduce the degree of the polynomial
+      *fLog << "MHFindSignificanceONOFF::FitPolynomialOFF; reduce the degree of the polynomial from "
+          << fDegreeOFF << " to " << (j0-2) << endl;
+      fDegreeOFF = j0 - 2;
+
+      funclist->Remove(fPolyOFF);
+      //if (fPoly)
+      delete fPolyOFF;
+      fPolyOFF = NULL;
+
+      // delete the Minuit object in order to have independent starting
+      // conditions for the next minimization
+      //if (gMinuit)
+      delete gMinuit;
+      gMinuit = NULL;
+  }
+  //===========   end of loop for reducing the degree   ==================
+  //              of the polynomial
+
+
+  //--------------------------------------------------
+  // get the error matrix of the fitted parameters
+
+  if (fIstatOFF >= 1)
+  {
+      // error matrix was calculated
+      if (gMinuit)
+          gMinuit->mnemat(&fEmatOFF[0][0], fNdimOFF);
+
+      // copy covariance matrix into a matrix which includes also the fixed
+      // parameters
+      TString  name;
+      Double_t bnd1, bnd2, val, err;
+      Int_t    jvarbl;
+      Int_t    kvarbl;
+      for (Int_t j=0; j<=fDegreeOFF; j++)
+      {
+          if (gMinuit)
+              gMinuit->mnpout(j, name, val, err, bnd1, bnd2, jvarbl);
+
+          for (Int_t k=0; k<=fDegreeOFF; k++)
+          {
+              if (gMinuit)
+                  gMinuit->mnpout(k, name, val, err, bnd1, bnd2, kvarbl);
+
+              fEmaOFF[j][k] = jvarbl==0 || kvarbl==0 ? 0 : fEmatOFF[jvarbl-1][kvarbl-1];
+          }
+      }
+  }
+  else
+  {
+      // error matrix was not calculated, construct it
+      *fLog << "MHFindSignificanceONOFF::FitPolynomialOFF; error matrix not defined"
+          << endl;
+      for (Int_t j=0; j<=fDegreeOFF; j++)
+      {
+          for (Int_t k=0; k<=fDegreeOFF; k++)
+              fEmaOFF[j][k] = 0;
+
+          fEmaOFF[j][j] = fErrorsOFF[j]*fErrorsOFF[j];
+      }
+  }
+
+
+
+  
+  //--------------------------------------------------
+  // calculate correlation matrix
+  for (Int_t j=0; j<=fDegreeOFF; j++)
+  {
+      for (Int_t k=0; k<=fDegreeOFF; k++)
+      {
+          const Double_t sq = fEmaOFF[j][j]*fEmaOFF[k][k];
+          fCorrOFF[j][k] = 
+	      sq == 0 ? 0 : (fEmaOFF[j][k] / TMath::Sqrt(fEmaOFF[j][j]*fEmaOFF[k][k]));
+      }
+  }
+  
+  //--------------------------------------------------
+  // reset the errors of the points in the histogram
+  for (Int_t i=1; i<=nbins; i++)
+  {
+      fHistOFF->SetBinError(i, saveError[i-1]);
+  }
+  
+  return kTRUE;
+
+
+}
+
+
+
+
+
+
+
+
+// --------------------------------------------------------------------------
+//
+//  FitPolynomial
+//
+//  - create a clone 'fHist' of the |alpha| distribution 'fHistOrig'
+//  - fit a polynomial of degree 'fDegree' to the alpha distribution 
+//    'fHist' in the region alphamin < |alpha| < alphamax
+//
+//  in pathological cases the histogram is rebinned before fitting
+//     (this is done only if fRebin is kTRUE)
+//
+//  if the highest coefficient of the polynomial is compatible with zero
+//     the fit is repeated with a polynomial of lower degree
+//     (this is done only if fReduceDegree is kTRUE)
+//
+//
+
+Bool_t MHFindSignificanceONOFF::FitPolynomial()
+{
+  //--------------------------------------------------
+  // check the histogram :
+  //       - calculate initial values of the parameters
+  //       - check for bins with zero entries
+  //       - set minimum errors
+  //       - save the original errors
+  //       - set errors huge outside the fit range
+  //         (in 'fcnpoly' points with huge errors will be ignored)
+
+
+  Double_t dummy = 1.e20;
+
+  Double_t mean;
+  Double_t rms;
+  Double_t nclose;
+  Double_t nfar;
+  Double_t a2init = 0.0;
+  TArrayD  saveError;
+
+  Int_t nbins;
+  Int_t nrebin = 1;
+
+  //----------------   start while loop for rebinning   -----------------
+  while(1)
+  {
+
+  fNzero   = 0;
+  fMbins   = 0;
+  fMlow    = 0;
+  fNbgtot  = 0.0;
+
+  fAlphami =  10000.0;
+  fAlphamm =  10000.0;
+  fAlphama = -10000.0;
+
+  mean   = 0.0;
+  rms    = 0.0;
+  nclose = 0.0;
+  nfar   = 0.0;
+
+  nbins = fHist->GetNbinsX();
+  saveError.Set(nbins);
+
+  for (Int_t i=1; i<=nbins; i++)
+  {
+    saveError[i-1] = fHist->GetBinError(i);
+
+    // bin should be completely contained in the fit range
+    // (fAlphamin, fAlphamax)
+    Double_t  xlo = fHist->GetBinLowEdge(i);
+    Double_t  xup = fHist->GetBinLowEdge(i+1);
+
+    if ( xlo >= fAlphamin-fEps  &&  xlo <= fAlphamax+fEps  &&
+	 xup >= fAlphamin-fEps  &&  xup <= fAlphamax+fEps     )
+    {
+      fMbins++;
+
+      if ( xlo < fAlphami )
+        fAlphami = xlo;
+
+      if ( xup > fAlphama )
+        fAlphama = xup;
+
+      Double_t content = fHist->GetBinContent(i);
+      fNbgtot += content;
+
+      mean += content;
+      rms  += content*content;
+
+      // count events in low-alpha and high-alpha region
+      if ( xlo >= fAlphammm-fEps  &&  xup >= fAlphammm-fEps)
+      {
+        nfar   += content;
+        if ( xlo < fAlphamm )
+          fAlphamm = xlo;
+        if ( xup < fAlphamm )
+          fAlphamm = xup; 
+      }
+      else
+      {
+        nclose += content;
+        if ( xlo > fAlphamm )
+          fAlphamm = xlo;
+        if ( xup > fAlphamm )
+          fAlphamm = xup; 
+      }
+
+      // count bins with zero entry
+      if (content <= 0.0)
+        fNzero++;
+     
+      // set minimum error
+      if (content < 9.0)
+      {
+        fMlow += 1;
+        fHist->SetBinError(i, 3.0);
+      }
+
+      //*fLog << "Take : i, content, error = " << i << ",  " 
+      //      << fHist->GetBinContent(i) << ",  "
+      //      << fHist->GetBinError(i)   << endl;
+
+      continue;
+    }    
+    // bin is not completely contained in the fit range : set error huge
+
+    fHist->SetBinError(i, dummy);
+
+    //*fLog << "Omit : i, content, error = " << i << ",  " 
+    //      << fHist->GetBinContent(i) << ",  " << fHist->GetBinError(i) 
+    //      << endl;
+
+  }
+
+  // mean of entries/bin in the fit range
+  if (fMbins > 0)
+  {
+    mean /= ((Double_t) fMbins);
+    rms  /= ((Double_t) fMbins);
+  }
+
+  rms = sqrt( rms - mean*mean );
+
+  // if there are no events in the background region
+  //    there is no reason for rebinning
+  //    and this is the condition for assuming a constant background (= 0)
+  if (mean <= 0.0)
+    break;
+
+  Double_t helpmi = fAlphami*fAlphami*fAlphami;
+  Double_t helpmm = fAlphamm*fAlphamm*fAlphamm;
+  Double_t helpma = fAlphama*fAlphama*fAlphama;
+  Double_t help   =   (helpma-helpmm) * (fAlphamm-fAlphami)    
+	            - (helpmm-helpmi) * (fAlphama-fAlphamm);
+  if (help != 0.0)
+    a2init =  ( (fAlphamm-fAlphami)*nfar - (fAlphama-fAlphamm)*nclose )
+                * 1.5 * fHist->GetBinWidth(1) / help;
+  else
+    a2init = 0.0;
+
+
+  //--------------------------------------------
+  // rebin the histogram
+  //   - if a bin has no entries 
+  //   - or if there are too many bins with too few entries
+  //   - or if the new bin width would exceed half the size of the 
+  //     signal region
+
+  if ( !fRebin  ||
+       ( fNzero <= 0 && (Double_t)fMlow<0.05*(Double_t)fMbins )  || 
+       (Double_t)(nrebin+1)/(Double_t)nrebin * fHist->GetBinWidth(1) 
+                                                           > fAlphasig/2.0 )
+  {
+    //*fLog << "before break" << endl;
+    break;
+  }
+
+  nrebin += 1;
+  TString histname = fHist->GetName();
+  delete fHist;
+  fHist = NULL;
+
+  *fLog << "MHFindSignificanceONOFF::FitPolynomial; rebin the |alpha| plot, grouping "
+        << nrebin << " bins together" << endl;
+
+  // TH1::Rebin doesn't work properly
+  //fHist = fHistOrig->Rebin(nrebin, "Rebinned");
+  // use private routine RebinHistogram()
+  fHist = new TH1F;
+  fHist->Sumw2();
+  fHist->SetNameTitle(histname, histname);
+  fHist->UseCurrentStyle();
+
+  // do rebinning such that x0 remains a lower bin edge
+  Double_t x0 = 0.0;
+  if ( !RebinHistogram(x0, nrebin) )
+  {
+    *fLog << "MHFindSignificanceONOFF::FitPolynomial; RebinHistgram() failed" 
+          << endl;
+    return kFALSE;
+  }
+
+  fHist->SetXTitle("|alpha|  [\\circ]");
+  fHist->SetYTitle("Counts");
+
+  }
+  //----------------   end of while loop for rebinning   -----------------
+
+
+  // if there are still too many bins with too few entries don't fit
+  // and assume a constant background
+
+  fConstantBackg = kFALSE;
+  if ( fNzero > 0  ||  (Double_t)fMlow>0.05*(Double_t)fMbins ) 
+  {
+    *fLog << "MHFindSignificanceONOFF::FitPolynomial; polynomial fit not possible,  fNzero, fMlow, fMbins = "
+          << fNzero << ",  " << fMlow << ",  " << fMbins << endl;
+    *fLog << "                    assume a constant background" << endl;
+
+    fConstantBackg = kTRUE;
+    fDegree        = 0;
+
+    TString funcname = "Poly";
+    Double_t xmin =   0.0;
+    Double_t xmax =  90.0;
+
+    TString formula = "[0]";
+
+    fPoly = new TF1(funcname, formula, xmin, xmax);
+    TList *funclist = fHist->GetListOfFunctions();
+    funclist->Add(fPoly);
+
+    //--------------------
+    Int_t nparfree = 1;
+    fChisq         = 0.0; 
+    fNdf           = fMbins - nparfree;
+    fProb          = 0.0;
+    fIstat         = 0;
+
+    fValues.Set(1);
+    fErrors.Set(1);
+
+    Double_t val, err;
+    val = mean;
+    err = sqrt( mean / (Double_t)fMbins );
+
+    fPoly->SetParameter(0, val);
+    fPoly->SetParError (0, err);
+
+    fValues[0] = val;
+    fErrors[0] = err; 
+
+    fEma[0][0]  = err*err;
+    fCorr[0][0] = 1.0;
+    //--------------------
+
+    //--------------------------------------------------
+    // reset the errors of the points in the histogram
+    for (Int_t i=1; i<=nbins; i++)
+    {
+      fHist->SetBinError(i, saveError[i-1]);
+    }
+
+
+    return kTRUE;
+  }
+
+
+  //===========   start loop for reducing the degree   ==================
+  //              of the polynomial
+  while (1)
+  {
+      //--------------------------------------------------
+      // prepare fit of a polynomial :   (a0 + a1*x + a2*x**2 + a3*x**3 + ...)
+
+      TString funcname = "Poly";
+      Double_t xmin =   0.0;
+      Double_t xmax =  90.0;
+
+      TString formula = "[0]";
+      TString bra1     = "+[";
+      TString bra2     =    "]";
+      TString xpower   = "*x";
+      TString newpower = "*x";
+      for (Int_t i=1; i<=fDegree; i++)
+      {
+          formula += bra1;
+          formula += i;
+          formula += bra2;
+          formula += xpower;
+
+          xpower += newpower;
+      }
+
+      //*fLog << "FitPolynomial : formula = " << formula << endl;
+
+      fPoly = new TF1(funcname, formula, xmin, xmax);
+      TList *funclist = fHist->GetListOfFunctions();
+      funclist->Add(fPoly);
+
+      //------------------------
+      // attention : the dimensions must agree with those in CallMinuit()
+      const UInt_t npar = fDegree+1;
+
+      TString parname[npar];
+      TArrayD vinit(npar);
+      TArrayD  step(npar);
+      TArrayD limlo(npar);
+      TArrayD limup(npar);
+      TArrayI   fix(npar);
+
+      vinit[0] =   mean;
+      vinit[2] = a2init;
+
+      for (UInt_t j=0; j<npar; j++)
+      {
+          parname[j]  = "p";
+          parname[j] += j+1;
+
+          step[j] = vinit[j] != 0.0 ? TMath::Abs(vinit[j]) / 10.0 : 0.000001;
+      }
+
+      // limit the first coefficient of the polynomial to positive values
+      // because the background must not be negative
+      limup[0] = fHist->GetEntries();
+
+      // use the subsequernt loop if you want to apply the
+      // constraint : uneven derivatives (at alpha=0) = zero
+      for (UInt_t j=1; j<npar; j+=2)
+      {
+          vinit[j] = 0;
+          step[j]  = 0;
+          fix[j]   = 1;
+      }
+
+      //*fLog << "FitPolynomial : before CallMinuit()" << endl;
+
+      MMinuitInterface inter;
+      const Bool_t rc = inter.CallMinuit(fcnpoly, parname, vinit, step,
+                                         limlo, limup, fix, fHist, "Migrad",
+                                         kFALSE);
+
+      //*fLog << "FitPolynomial : after CallMinuit()" << endl;
+
+      if (rc != 0)
+      {
+          //  *fLog << "MHFindSignificanceONOFF::FitPolynomial; polynomial fit failed"
+          //        << endl;
+          //  return kFALSE;
+      }
+
+
+      //-------------------
+      // get status of minimization
+      Double_t fmin   = 0;
+      Double_t fedm   = 0;
+      Double_t errdef = 0;
+      Int_t    npari  = 0;
+      Int_t    nparx  = 0;
+
+      if (gMinuit)
+          gMinuit->mnstat(fmin, fedm, errdef, npari, nparx, fIstat);
+
+      *fLog << "MHFindSignificanceONOFF::FitPolynomial; fmin, fedm, errdef, npari, nparx, fIstat = "
+            << fmin << ",  " << fedm << ",  " << errdef << ",  " << npari
+            << ",  " << nparx << ",  " << fIstat << endl;
+
+
+      //-------------------
+      // store the results
+
+      Int_t nparfree = gMinuit!=NULL ? gMinuit->GetNumFreePars() : 0;
+      fChisq         = fmin;
+      fNdf           = fMbins - nparfree;
+      fProb          = TMath::Prob(fChisq, fNdf);
+
+
+      // get fitted parameter values and errors
+      fValues.Set(npar);
+      fErrors.Set(npar);
+
+      for (Int_t j=0; j<=fDegree; j++)
+      {
+          Double_t val, err;
+          if (gMinuit)
+              gMinuit->GetParameter(j, val, err);
+
+          fPoly->SetParameter(j, val);
+          fPoly->SetParError(j, err);
+
+          fValues[j] = val;
+          fErrors[j] = err;
+      }
+
+
+      //--------------------------------------------------
+      // if the highest coefficient (j0) of the polynomial
+      // is consistent with zero reduce the degree of the polynomial
+
+      Int_t j0 = 0;
+      for (Int_t j=fDegree; j>1; j--)
+      {
+          // ignore fixed parameters
+          if (fErrors[j] == 0)
+              continue;
+
+          // this is the highest coefficient
+          j0 = j;
+          break;
+      }
+
+      if (!fReduceDegree || j0==0 || TMath::Abs(fValues[j0]) > fErrors[j0])
+          break;
+
+      // reduce the degree of the polynomial
+      *fLog << "MHFindSignificanceONOFF::FitPolynomial; reduce the degree of the polynomial from "
+          << fDegree << " to " << (j0-2) << endl;
+      fDegree = j0 - 2;
+
+      funclist->Remove(fPoly);
+      //if (fPoly)
+      delete fPoly;
+      fPoly = NULL;
+
+      // delete the Minuit object in order to have independent starting
+      // conditions for the next minimization
+      //if (gMinuit)
+      delete gMinuit;
+      gMinuit = NULL;
+  }
+  //===========   end of loop for reducing the degree   ==================
+  //              of the polynomial
+
+
+  //--------------------------------------------------
+  // get the error matrix of the fitted parameters
+
+
+  if (fIstat >= 1)
+  {
+      // error matrix was calculated
+      if (gMinuit)
+          gMinuit->mnemat(&fEmat[0][0], fNdim);
+
+      // copy covariance matrix into a matrix which includes also the fixed
+      // parameters
+      TString  name;
+      Double_t bnd1, bnd2, val, err;
+      Int_t    jvarbl;
+      Int_t    kvarbl;
+      for (Int_t j=0; j<=fDegree; j++)
+      {
+          if (gMinuit)
+              gMinuit->mnpout(j, name, val, err, bnd1, bnd2, jvarbl);
+
+          for (Int_t k=0; k<=fDegree; k++)
+          {
+              if (gMinuit)
+                  gMinuit->mnpout(k, name, val, err, bnd1, bnd2, kvarbl);
+
+              fEma[j][k] = jvarbl==0 || kvarbl==0 ? 0 : fEmat[jvarbl-1][kvarbl-1];
+          }
+      }
+  }
+  else
+  {
+      // error matrix was not calculated, construct it
+      *fLog << "MHFindSignificanceONOFF::FitPolynomial; error matrix not defined"
+          << endl;
+      for (Int_t j=0; j<=fDegree; j++)
+      {
+          for (Int_t k=0; k<=fDegree; k++)
+              fEma[j][k] = 0;
+
+          fEma[j][j] = fErrors[j]*fErrors[j];
+      }
+  }
+
+
+  //--------------------------------------------------
+  // calculate correlation matrix
+  for (Int_t j=0; j<=fDegree; j++)
+      for (Int_t k=0; k<=fDegree; k++)
+      {
+          const Double_t sq = fEma[j][j]*fEma[k][k];
+          fCorr[j][k] = sq==0 ? 0 : fEma[j][k] / TMath::Sqrt(fEma[j][j]*fEma[k][k]);
+      }
+
+
+  //--------------------------------------------------
+  // reset the errors of the points in the histogram
+  for (Int_t i=1; i<=nbins; i++)
+      fHist->SetBinError(i, saveError[i-1]);
+
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// ReBinHistogramOFF
+//
+// rebin the histogram 'fHistOrig' by grouping 'nrebin' bins together 
+// put the result into the histogram 'fHist'
+// the rebinning is made such that 'x0' remains a lower bound of a bin
+//
+
+Bool_t MHFindSignificanceONOFF::RebinHistogramOFF(Double_t x0, Int_t nrebin)
+{
+  //-----------------------------------------
+  // search bin i0 which has x0 as lower edge
+
+  Int_t i0 = -1;
+  Int_t nbold = fHistOrigOFF->GetNbinsX();
+  for (Int_t i=1; i<=nbold; i++)
+  {
+      if (TMath::Abs(fHistOrigOFF->GetBinLowEdge(i) - x0) < 1.e-4 )
+      {
+          i0 = i;
+          break;
+      }
+  }
+
+  if (i0 == -1)
+  {
+    i0 = 1;
+    *fLog << "MHFindsignificanceOFF::RebinOFF; no bin found with " << x0
+          << " as lower edge,  start rebinning with bin 1" << endl;
+  }
+
+  Int_t istart = i0 - nrebin * ( (i0-1)/nrebin );
+
+  //-----------------------------------------
+  // get new bin edges
+
+  const Int_t    nbnew = (nbold-istart+1) / nrebin;
+  const Double_t xmin  = fHistOrigOFF->GetBinLowEdge(istart);
+  const Double_t xmax  = xmin + (Double_t)nbnew * nrebin * fHistOrigOFF->GetBinWidth(1);
+  fHistOFF->SetBins(nbnew, xmin, xmax);
+
+  *fLog << "MHFindSignificanceONOFF::ReBinOFF; x0, i0, nbold, nbnew, xmin, xmax = "
+        << x0 << ",  " << i0 << ",  " << nbold << ",  " << nbnew << ",  "
+        << xmin << ",  " << xmax << endl;
+
+  //-----------------------------------------
+  // get new bin entries
+
+  for (Int_t i=1; i<=nbnew; i++)
+  {
+      Int_t j = nrebin*(i-1) + istart;
+
+      Double_t content = 0;
+      Double_t error2  = 0;
+      for (Int_t k=0; k<nrebin; k++)
+      {
+          content += fHistOrigOFF->GetBinContent(j+k);
+          error2  += fHistOrigOFF->GetBinError(j+k) * fHistOrigOFF->GetBinError(j+k);
+      }
+      fHistOFF->SetBinContent(i, content);
+      fHistOFF->SetBinError  (i, sqrt(error2));
+  }
+  fHistOFF->SetEntries( fHistOrigOFF->GetEntries() );
+
+  return kTRUE;
+}
+
+
+
+
+// --------------------------------------------------------------------------
+
+
+
+//
+// ReBinHistogram
+//
+// rebin the histogram 'fHistOrig' by grouping 'nrebin' bins together 
+// put the result into the histogram 'fHist'
+// the rebinning is made such that 'x0' remains a lower bound of a bin
+//
+
+Bool_t MHFindSignificanceONOFF::RebinHistogram(Double_t x0, Int_t nrebin)
+{
+  //-----------------------------------------
+  // search bin i0 which has x0 as lower edge
+
+  Int_t i0 = -1;
+  Int_t nbold = fHistOrig->GetNbinsX();
+  for (Int_t i=1; i<=nbold; i++)
+  {
+      if (TMath::Abs(fHistOrig->GetBinLowEdge(i) - x0) < 1.e-4 )
+      {
+          i0 = i;
+          break;
+      }
+  }
+
+  if (i0 == -1)
+  {
+    i0 = 1;
+    *fLog << "MHFindsignificance::Rebin; no bin found with " << x0
+          << " as lower edge,  start rebinning with bin 1" << endl;
+  }
+
+  Int_t istart = i0 - nrebin * ( (i0-1)/nrebin );
+
+  //-----------------------------------------
+  // get new bin edges
+
+  const Int_t    nbnew = (nbold-istart+1) / nrebin;
+  const Double_t xmin  = fHistOrig->GetBinLowEdge(istart);
+  const Double_t xmax  = xmin + (Double_t)nbnew * nrebin * fHistOrig->GetBinWidth(1);
+  fHist->SetBins(nbnew, xmin, xmax);
+
+  *fLog << "MHFindSignificanceONOFF::ReBin; x0, i0, nbold, nbnew, xmin, xmax = "
+        << x0 << ",  " << i0 << ",  " << nbold << ",  " << nbnew << ",  "
+        << xmin << ",  " << xmax << endl;
+
+  //-----------------------------------------
+  // get new bin entries
+
+  for (Int_t i=1; i<=nbnew; i++)
+  {
+      Int_t j = nrebin*(i-1) + istart;
+
+      Double_t content = 0;
+      Double_t error2  = 0;
+      for (Int_t k=0; k<nrebin; k++)
+      {
+          content += fHistOrig->GetBinContent(j+k);
+          error2  += fHistOrig->GetBinError(j+k) * fHistOrig->GetBinError(j+k);
+      }
+      fHist->SetBinContent(i, content);
+      fHist->SetBinError  (i, sqrt(error2));
+  }
+  fHist->SetEntries( fHistOrig->GetEntries() );
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+//  FitGaussPoly
+//
+//  fits a (Gauss + polynomial function) to the alpha distribution 'fhist' 
+//
+//
+Bool_t MHFindSignificanceONOFF::FitGaussPoly()
+{
+  *fLog << "Entry FitGaussPoly" << endl;
+
+  //--------------------------------------------------
+  // check the histogram :
+  //       - calculate initial values of the parameters
+  //       - check for bins with zero entries
+  //       - set minimum errors
+  //       - save the original errors
+  //       - set errors huge outside the fit range
+  //         (in 'fcnpoly' points with huge errors will be ignored)
+
+
+  Double_t dummy = 1.e20;
+
+  fGNzero   = 0;
+  fGMbins   = 0;
+
+  //------------------------------------------
+  // if a constant background has been assumed (due to low statistics)
+  // fit only in the signal region
+  if ( !fConstantBackg )
+  {
+    fAlphalow = 0.0;
+    fAlphahig = fAlphamax;
+  }
+  else
+  {
+    fAlphalow = 0.0;
+    fAlphahig = 2.0*fAlphasig>25.0 ? 25.0 : 2.0*fAlphasig;
+  }
+  //------------------------------------------
+
+
+  fAlphalo =  10000.0;
+  fAlphahi = -10000.0;
+
+
+  Int_t nbins = fHist->GetNbinsX();
+  TArrayD saveError(nbins);
+
+  for (Int_t i=1; i<=nbins; i++)
+  {
+    saveError[i-1] = fHist->GetBinError(i);
+
+    // bin should be completely contained in the fit range
+    // (fAlphalow, fAlphahig)
+    Double_t  xlo = fHist->GetBinLowEdge(i);
+    Double_t  xup = fHist->GetBinLowEdge(i+1);
+
+    if ( xlo >= fAlphalow-fEps  &&  xlo <= fAlphahig+fEps  &&
+	 xup >= fAlphalow-fEps  &&  xup <= fAlphahig+fEps     )
+    {
+      fGMbins++;
+
+      if ( xlo < fAlphalo )
+        fAlphalo = xlo;
+
+      if ( xup > fAlphahi )
+        fAlphahi = xup;
+
+      Double_t content = fHist->GetBinContent(i);
+
+
+      // count bins with zero entry
+      if (content <= 0.0)
+        fGNzero++;
+     
+      // set minimum error
+      if (content < 9.0)
+        fHist->SetBinError(i, 3.0);
+
+      //*fLog << "Take : i, content, error = " << i << ",  " 
+      //      << fHist->GetBinContent(i) << ",  "
+      //      << fHist->GetBinError(i)   << endl;
+
+      continue;
+    }    
+    // bin is not completely contained in the fit range : set error huge
+
+    fHist->SetBinError(i, dummy);
+
+    //*fLog << "Omit : i, content, error = " << i << ",  " 
+    //      << fHist->GetBinContent(i) << ",  " << fHist->GetBinError(i) 
+    //      << endl;
+
+  }
+
+
+  // if a bin has no entries don't fit
+  if (fGNzero > 0)
+  {
+    *fLog << "MHFindSignificanceONOFF::FitGaussPoly; out of " << fGMbins 
+          << " bins there are " << fGNzero
+          << " bins with zero entry" << endl;
+
+    fGPoly = NULL;
+    return kFALSE;
+  }
+
+
+  //--------------------------------------------------
+  // prepare fit of a (polynomial+Gauss) :   
+  // (a0 + a1*x + a2*x**2 + a3*x**3 + ...) + A*exp( -0.5*((x-x0)/sigma)**2 )
+
+  TString funcname = "PolyGauss";
+  Double_t xmin =   0.0;
+  Double_t xmax =  90.0;
+
+  TString xpower   = "*x";
+  TString newpower = "*x";
+
+  TString formulaBackg = "[0]";
+  for (Int_t i=1; i<=fDegree; i++)
+      formulaBackg += Form("+[%d]*x^%d", i, i);
+
+  const TString formulaGauss = 
+        Form("[%d]/[%d]*exp(-0.5*((x-[%d])/[%d])^2)",
+             fDegree+1, fDegree+3, fDegree+2, fDegree+3);
+
+  TString formula = formulaBackg;
+  formula += "+";
+  formula += formulaGauss;
+
+  *fLog << "FitGaussPoly : formulaBackg = " << formulaBackg << endl;
+  *fLog << "FitGaussPoly : formulaGauss = " << formulaGauss << endl;
+  *fLog << "FitGaussPoly : formula = " << formula << endl;
+
+  fGPoly = new TF1(funcname, formula, xmin, xmax);
+  TList *funclist = fHist->GetListOfFunctions();
+  funclist->Add(fGPoly);
+
+  fGBackg = new TF1("Backg", formulaBackg, xmin, xmax);
+  //funclist->Add(fGBackg); 
+
+  //------------------------
+  // attention : the dimensions must agree with those in CallMinuit()
+  Int_t npar = fDegree+1 + 3;
+
+  TString parname[npar];
+  TArrayD vinit(npar);
+  TArrayD  step(npar); 
+  TArrayD limlo(npar); 
+  TArrayD limup(npar); 
+  TArrayI   fix(npar);
+
+
+  // take as initial values for the polynomial 
+  // the result from the polynomial fit
+  for (Int_t j=0; j<=fDegree; j++)
+    vinit[j] = fPoly->GetParameter(j);
+
+  Double_t sigma = 8;
+  vinit[fDegree+1] = 2.0 * fNexONOFF * fHist->GetBinWidth(1) / TMath::Sqrt(TMath::Pi()*2);
+  vinit[fDegree+2] = 0;
+  vinit[fDegree+3] = sigma;
+
+  *fLog << "FitGaussPoly : starting value for Gauss-amplitude = " 
+        << vinit[fDegree+1] << endl;
+
+  for (Int_t j=0; j<npar; j++)
+  {
+      parname[j]  = "p";
+      parname[j] += j+1;
+
+      step[j] = vinit[j]!=0 ? TMath::Abs(vinit[j]) / 10.0 : 0.000001;
+  }
+
+  // limit the first coefficient of the polynomial to positive values
+  // because the background must not be negative
+  limup[0] = fHist->GetEntries()*10;
+
+  // limit the sigma of the Gauss function
+  limup[fDegree+3] = 20;
+
+
+  // use the subsequernt loop if you want to apply the
+  // constraint : uneven derivatives (at alpha=0) = zero
+  for (Int_t j=1; j<=fDegree; j+=2)
+  {
+      vinit[j] = 0;
+      step[j]  = 0;
+      fix[j]   = 1;
+  }
+
+  // fix position of Gauss function
+  vinit[fDegree+2] = 0;
+  step[fDegree+2]  = 0;
+  fix[fDegree+2]   = 1;
+   
+  // if a constant background has been assumed (due to low statistics)
+  // fix the background
+  if (fConstantBackg)
+  {
+      step[0] = 0;
+      fix[0]  = 1;
+  }
+
+  MMinuitInterface inter;
+  const Bool_t rc = inter.CallMinuit(fcnpolygauss, parname, vinit, step,
+                                     limlo, limup, fix, fHist, "Migrad",
+                                     kFALSE);
+
+  if (rc != 0)
+  {
+  //  *fLog << "MHFindSignificanceONOFF::FitGaussPoly; (polynomial+Gauss) fit failed"
+  //        << endl;
+  //  return kFALSE;
+  }
+
+
+  //-------------------
+  // get status of the minimization
+  Double_t fmin;
+  Double_t fedm;
+  Double_t errdef;
+  Int_t    npari;
+  Int_t    nparx;
+
+  if (gMinuit)
+    gMinuit->mnstat(fmin, fedm, errdef, npari, nparx, fGIstat);
+
+  *fLog << "MHFindSignificanceONOFF::FitGaussPoly; fmin, fedm, errdef, npari, nparx, fGIstat = "
+        << fmin << ",  " << fedm << ",  " << errdef << ",  " << npari
+        << ",  " << nparx << ",  " << fGIstat << endl;
+
+
+  //-------------------
+  // store the results
+
+  Int_t nparfree  = gMinuit!=NULL ? gMinuit->GetNumFreePars() : 0;
+  fGChisq         = fmin; 
+  fGNdf           = fGMbins - nparfree;
+  fGProb          = TMath::Prob(fGChisq, fGNdf);
+
+
+  // get fitted parameter values and errors
+  fGValues.Set(npar);
+  fGErrors.Set(npar);
+
+  for (Int_t j=0; j<npar; j++)
+  {
+    Double_t val, err;
+    if (gMinuit)
+      gMinuit->GetParameter(j, val, err);
+
+    fGPoly->SetParameter(j, val);
+    fGPoly->SetParError(j, err);
+
+    fGValues[j] = val;
+    fGErrors[j] = err; 
+
+    if (j <=fDegree)
+    {
+      fGBackg->SetParameter(j, val);
+      fGBackg->SetParError(j, err);
+    }
+  }
+
+  fSigmaGauss  = fGValues[fDegree+3];
+  fdSigmaGauss = fGErrors[fDegree+3];
+  // fitted total number of excess events 
+  fNexGauss = fGValues[fDegree+1] * TMath::Sqrt(TMath::Pi()*2) /
+                                         (fHist->GetBinWidth(1)*2 );
+  fdNexGauss = fNexGauss * fGErrors[fDegree+1]/fGValues[fDegree+1];
+
+  //--------------------------------------------------
+  // get the error matrix of the fitted parameters
+
+
+  if (fGIstat >= 1)
+  {
+    // error matrix was calculated
+    if (gMinuit)
+      gMinuit->mnemat(&fGEmat[0][0], fGNdim);
+
+    // copy covariance matrix into a matrix which includes also the fixed
+    // parameters
+    TString  name;
+    Double_t bnd1, bnd2, val, err;
+    Int_t    jvarbl;
+    Int_t    kvarbl;
+    for (Int_t j=0; j<npar; j++)
+    {
+        if (gMinuit)
+            gMinuit->mnpout(j, name, val, err, bnd1, bnd2, jvarbl);
+
+        for (Int_t k=0; k<npar; k++)
+        {
+            if (gMinuit)
+                gMinuit->mnpout(k, name, val, err, bnd1, bnd2, kvarbl);
+
+            fGEma[j][k] = jvarbl==0 || kvarbl==0 ? 0 : fGEmat[jvarbl-1][kvarbl-1];
+        }
+    }
+  }
+  else
+  {
+    // error matrix was not calculated, construct it
+    *fLog << "MHFindSignificanceONOFF::FitPolynomial; error matrix not defined" 
+          << endl;
+    for (Int_t j=0; j<npar; j++)
+    {
+        for (Int_t k=0; k<npar; k++)
+            fGEma[j][k] = 0;
+
+        fGEma[j][j] = fGErrors[j]*fGErrors[j];
+    }
+  }
+
+
+  //--------------------------------------------------
+  // calculate correlation matrix
+  for (Int_t j=0; j<npar; j++)
+  {
+    for (Int_t k=0; k<npar; k++)
+    {
+        const Double_t sq = fGEma[j][j]*fGEma[k][k];
+        fGCorr[j][k] = sq==0 ? 0 : fGEma[j][k] / sqrt( fGEma[j][j]*fGEma[k][k] );
+    }
+  }
+
+
+  //--------------------------------------------------
+  // reset the errors of the points in the histogram
+  for (Int_t i=1; i<=nbins; i++)
+    fHist->SetBinError(i, saveError[i-1]);
+
+  return kTRUE;
+
+}
+
+
+
+// --------------------------------------------------------------------------
+//
+//  DetExcessONOFF
+//
+//  using the result of the polynomial fit (fValuesOFF), DetExcessONOFF determines
+//
+//  - the total number of events in the signal region (fNon)
+//  - the number of backgound events (fitted) in the signal region (fNoffSigFitted)
+//  - the number of OFF (normalized evetns) in the alpha OFF distribution (fNoffSig)
+//  - the number of excess events (fNexONOFF)
+//  - the number of excess events using the fitted OFF (fNexONOFFFitted)
+//  - the effective number of background events (fNoff), and fGamma :
+//    fNoffSigFitted = fGamma * fNoff;  fdNoffSigFitted = fGamma * sqrt(fNoff);
+//
+//  It assumed that the polynomial is defined as
+//               a0 + a1*x + a2*x**2 + a3*x**3 + ..
+//
+//  and that the alpha distribution has the range 0 < alpha < 90 degrees
+//
+
+Bool_t MHFindSignificanceONOFF::DetExcessONOFF()
+{
+  //*fLog << "MHFindSignificanceONOFF::DetExcessONOFF;" << endl;
+
+//--------------------------------------------
+  // calculate the total number of events (fNon) in the signal region
+
+  fNon  = 0.0;
+  fdNon = 0.0;
+
+  Double_t alphaup = -1000.0; 
+  Double_t binwidth = fHist->GetBinWidth(1);
+
+  Int_t nbins = fHist->GetNbinsX();
+  for (Int_t i=1; i<=nbins; i++)
+  {
+    Double_t  xlo = fHist->GetBinLowEdge(i);
+    Double_t  xup = fHist->GetBinLowEdge(i+1);
+ 
+    // bin must be completely contained in the signal region
+    if ( xlo <= (fAlphasig+fEps)  &&  xup <= (fAlphasig+fEps)    )
+    {
+      Double_t width = fabs(xup-xlo);
+      if (fabs(width-binwidth) > fEps)
+      {
+        *fLog << "MHFindSignificanceONOFF::DetExcessONOFF; alpha plot has variable binning, which is not allowed" 
+          << endl;
+        return kFALSE;
+      }
+
+      if (xup > alphaup)
+        alphaup = xup;
+
+      fNon  += fHist->GetBinContent(i);
+      fdNon += fHist->GetBinError(i) * fHist->GetBinError(i);
+    }
+  }
+  fdNon = sqrt(fdNon);
+
+  *fLog << "MHFindSignificamceONOFF::DetExcessONOFF:" << endl
+	<< "fNon = " << fNon << " ; fdNon = " << fdNon << endl;
+
+
+  // tmp
+  //if (fNon == 0)
+  //{
+  //    cout << "ERROR... WITH COUNTED OF ON EVETNS: fAlphasig, fEps = "
+//	   << fAlphasig << ", " << fEps << endl;
+  //    fHist-> DrawCopy();
+  //   gPad -> SaveAs("HistON.ps");
+  //}
+  // endtmp
+
+
+  // the actual signal range is :
+  if (alphaup == -1000.0)
+    return kFALSE;
+
+  fAlphasi = alphaup;
+
+
+  //*fLog << "fAlphasi, fNon, fdNon, binwidth, fDegree = " << fAlphasi << ",  "
+  //      << fNon << ",  " << fdNon << ",  " << binwidth << ",  "
+  //      << fDegree << endl;
+
+
+  // Calculate the number of OFF events in the signal region
+  // ___________________________________________________
+  
+
+  fNoffSig = 0.0;
+  fdNoffSig = 0.0;
+
+  Double_t alphaupOFF = -1000.0; 
+  Double_t binwidthOFF = fHistOFF->GetBinWidth(1);
+
+  Int_t nbinsOFF = fHistOFF->GetNbinsX();
+
+  for (Int_t i=1; i<=nbinsOFF; i++)
+  {
+    Double_t xlo = fHistOFF->GetBinLowEdge(i);
+    Double_t xup = fHistOFF->GetBinLowEdge(i+1);
+ 
+    // bin must be completely contained in the signal region
+    if ( xlo <= (fAlphasig+fEps)  &&  xup <= (fAlphasig+fEps)    )
+    {
+      Double_t width = fabs(xup-xlo);
+      if (fabs(width-binwidthOFF) > fEps)
+      {
+        *fLog << "MHFindSignificanceONOFF::DetExcessONOFF; alphaOFF plot has variable binning, which is not allowed" 
+          << endl;
+        return kFALSE;
+      }
+
+      if (xup > alphaupOFF)
+        alphaup = xup;
+
+      fNoffSig  += fHistOFF->GetBinContent(i);
+      fdNoffSig += fHistOFF->GetBinError(i) * fHistOFF->GetBinError(i);
+    }
+  }
+  fdNoffSig = sqrt(fdNoffSig);
+
+  // tmp
+  //if (fNoffSig == 0)
+  //{
+  //   cout << "ERROR... WITH COUNTED OF OFF EVETNS: fAlphasig, fEps = "
+//	   << fAlphasig << ", " << fEps << endl;
+  //     fHistOFF-> DrawCopy();
+  //   gPad -> SaveAs("HistOFF.ps");
+  //}
+  //endtmp
+
+  // the actual signal range is :
+  if (alphaup == -1000.0)
+    return kFALSE;
+
+  fAlphasiOFF = alphaup;
+
+  if (fabs(fAlphasiOFF - fAlphasi) > fEps)
+  {
+      *fLog << "MHFindSignificanceONOFF::DetExcessONOFF; fAlphasiOFF ("
+	    << fAlphasiOFF << ") is not equal to fAlphasi (" 
+	    << fAlphasi << "), this is something that should not happen" 
+	    << endl;
+
+    //return kFALSE; It might happen in pathological cases (very few OFF)
+      // and I want to see the results, anyhow
+  }
+
+
+
+   // Calculate the number of OFF events in the total OFF region 
+  // defined by fAlphaminOFF and fAlphamaxOFF 
+  // ___________________________________________________
+  
+  fNoffTot = 0.0;
+  fdNoffTot = 0.0;
+
+  
+ 
+  for (Int_t i=1; i<=nbinsOFF; i++)
+  {
+    Double_t xlo = fHistOFF->GetBinLowEdge(i);
+    Double_t xup = fHistOFF->GetBinLowEdge(i+1);
+ 
+    // bin must be completely contained in the signal region
+    if ( xlo >= (fAlphaminOFF-fEps)  &&  xup <= (fAlphamaxOFF+fEps)    )
+    {
+      Double_t width = fabs(xup-xlo);
+      if (fabs(width-binwidthOFF) > fEps)
+      {
+        *fLog << "MHFindSignificanceONOFF::DetExcessONOFF; alphaOFF plot has variable binning, which is not allowed" 
+          << endl;
+        return kFALSE;
+      }
+
+      fNoffTot  += fHistOFF->GetBinContent(i);
+      fdNoffTot += fHistOFF->GetBinError(i) * fHistOFF->GetBinError(i);
+    }
+  }
+  fdNoffTot = sqrt(fdNoffTot);
+
+
+
+
+
+
+
+
+
+  //--------------------------------------------
+  // calculate the number of OFF fitted events (fNoffSigFitted) in the signal region
+  // and its error (fdNoffSigFitted) 
+
+ 
+
+ if (fUseFittedQuantities) 
+ {
+     //--------------------------------------------
+     // calculate the number of OFF fitted events (fNoffSigFitted) in the signal region
+     // and its error (fdNoffSigFitted) 
+     
+     Double_t fac = 1.0/binwidthOFF;
+     
+     fNoffSigFitted        = 0.0;
+     Double_t altothejplus1 = fAlphasi; // Limit for signal found for ON data is used. 
+     for (Int_t j=0; j<=fDegreeOFF; j++)
+     {
+	 fNoffSigFitted += fValuesOFF[j] * altothejplus1 / ((Double_t)(j+1));
+	 altothejplus1 *= fAlphasi;
+     }
+     fNoffSigFitted *= fac;
+     
+     // derivative of fNoffSigFitted 
+     Double_t facj;
+     Double_t fack;
+     
+     Double_t sum = 0.0;
+     altothejplus1 = fAlphasi;
+     for (Int_t j=0; j<=fDegreeOFF; j++)
+     {
+	 facj = altothejplus1 / ((Double_t)(j+1));
+	 
+	 Double_t altothekplus1 = fAlphasi;    
+	 for (Int_t k=0; k<=fDegreeOFF; k++)
+	 {
+	     fack = altothekplus1 / ((Double_t)(k+1));
+	     sum   += facj * fack * fEmaOFF[j][k];
+	     altothekplus1 *= fAlphasi;
+	 }
+	 altothejplus1 *= fAlphasi;
+     }
+     sum  *= fac*fac;
+     
+     if (sum < 0.0)
+     {
+	 *fLog << "MHFindsignificanceONOFF::DetExcessONOFF; error squared is negative" 
+	       << endl;
+	 return kFALSE;
+     }
+     
+     fdNoffSigFitted = sqrt(sum);
+     
+     
+     // We can now compare fNoffSig with fNoffSigFitted (and their errors)
+     // NUmbers should agree within 10 % (errors within 20%)
+     
+     if (fabs(fNoffSig - fNoffSigFitted) > 0.1 * fNoffSigFitted)
+     {
+	 *fLog << "MHFindsignificanceONOFF::DetExcessONOFF; number of OFF events and Fitted number of OFF events in signal region do not agree (within 10 %)" << endl;
+	 
+	 *fLog << "fNoffSig = " << fNoffSig << " ; fNoffSigFitted = " << fNoffSigFitted << endl;
+	 
+	 
+	 // return kFALSE; NOt yet...
+     }
+     
+     /*
+       if (fabs(fdNoffSig - fdNoffSigFitted) > 0.2 * fdNoffSigFitted)
+       {
+       *fLog << "MHFindsignificanceONOFF::DetExcessONOFF; error in number of OFF events and error in Fitted number of OFF events in signal region do not agree (within 20 %)" 
+       << endl;
+       
+       
+       *fLog << "fdNoffSig = " << fdNoffSig << " ; fdNoffSigFitted = " << fdNoffSigFitted << endl;
+       
+       
+       //return kFALSE; NOt yet...
+       }
+       
+     */
+     
+    
+     
+     // Calculate the number of OFF events in the whole fit region (fAlphaminOFF-fAlphamaxOFF)
+     // ___________________________________________________
+     
+     
+     
+     fNoffTotFitted = 0.0;
+     
+     altothejplus1 = fAlphamaxOFF; // Limit for OFF data fit 
+     for (Int_t j=0; j<=fDegreeOFF; j++)
+     {
+	 fNoffTotFitted += fValuesOFF[j] * altothejplus1 / ((Double_t)(j+1));
+	 altothejplus1 *= fAlphamaxOFF;
+     }
+     fNoffTotFitted *= fac;
+     
+     // derivative of fdNoffTotFitted 
+     
+     
+     sum = 0.0;
+     altothejplus1 = fAlphamaxOFF;
+     for (Int_t j=0; j<=fDegreeOFF; j++)
+     {
+	 facj = altothejplus1 / ((Double_t)(j+1));
+	 
+	 Double_t altothekplus1 = fAlphamaxOFF;    
+	 for (Int_t k=0; k<=fDegreeOFF; k++)
+	 {
+	     fack = altothekplus1 / ((Double_t)(k+1));
+	     
+	     sum   += facj * fack * fEmaOFF[j][k];
+	     altothekplus1 *= fAlphamaxOFF;
+	 }
+	 altothejplus1 *= fAlphamaxOFF;
+     }
+     sum  *= fac*fac;
+     
+     if (sum < 0.0)
+     {
+	 *fLog << "MHFindsignificanceONOFF::DetExcessONOFF; error squared is negative" 
+	       << endl;
+	 return kFALSE;
+     }
+     
+     fdNoffTotFitted = sqrt(sum);
+     
+
+
+ }
+
+else
+ {
+     fNoffSigFitted = 0.0;
+     fdNoffSigFitted = 0.0;
+     fNoffTotFitted = 0.0;
+     fdNoffTotFitted = 0.0;
+ }
+
+
+
+ *fLog << "MHFindSignificamceONOFF::DetExcessONOFF; INFO ABOOUT COMPUTED OFF EVENTS..." << endl
+       << "fNoffSig = " << fNoffSig << "; fdNoffSig =  " << fdNoffSig << endl
+       << "fNoffSigFitted = " << fNoffSigFitted 
+       << "; fdNoffSigFitted =  " << fdNoffSigFitted << endl;
+ 
+
+
+
+
+  //--------------------------------------------
+  // calculate the number of excess events in the signal region
+
+  fNexONOFF = fNon - fNoffSig*fNormFactor;
+  fNexONOFFFitted = fNon - fNoffSigFitted*fNormFactor;
+  
+  
+  *fLog << "MHFindSignificamceONOFF::DetExcessONOFF;" << endl
+	<< "fNexONOFF (= fNon - fNoffSig*fNormFactor)  = " << fNexONOFF << endl
+	<< "fNexONOFFFitted (= fNon - fNoffSigFitted*fNormFactor)  = " << fNexONOFFFitted << endl;
+
+
+  //--------------------------------------------
+  // calculate the effective number of background events (fNoff) , and fGamma :
+  // fNbg = fGamma * fNoff = fNormFactor* fNoffSigFitted;   
+  // dfNbg = fGamma * sqrt(fNoff) = fNormFactor * fdNoffSigFitted;
+  
+  if (fNoffSigFitted < 0.0)
+  {
+      *fLog << "MHFindSignificamceONOFF::DetExcessONOFF; number of fitted OFF events in signal region is negative,  fNoffSigFitted, fdNoffSigFitted = "
+	    << fNoffSigFitted   << ",  " << fdNoffSigFitted << endl;
+      
+      fGamma = 1.0;
+      fNoff  = 0.0;
+      return kFALSE;
+  }
+  
+  if (fNoffSigFitted > 0.0)
+  {
+      fGamma = fNormFactor * fdNoffSigFitted*fdNoffSigFitted/fNoffSigFitted;
+      fNoff  = fNormFactor * fNoffSigFitted/fGamma; 
+  }
+  else
+  {
+      fGamma = 1.0;
+      fNoff  = 0.0;
+  }
+  
+   *fLog << "MHFindSignificamceONOFF::DetExcessONOFF: " << endl
+	 << "fGamma = " << fGamma << " ; fNoff = " << fNoff << endl;
+
+  
+  return kTRUE;
+}
+
+
+
+
+
+// --------------------------------------------------------------------------
+//
+//  SigmaLiMa
+//
+//  calculates the significance according to Li & Ma
+//  ApJ 272 (1983) 317; formula 17
+//
+Bool_t MHFindSignificanceONOFF::SigmaLiMa(Double_t non,   Double_t noff, 
+                                     Double_t gamma, Double_t *siglima)
+{
+  if (gamma <= 0.0  ||  non <= 0.0  ||  noff <= 0.0)
+  {
+    *siglima = 0.0;
+    return kFALSE;
+  }
+
+  Double_t help1 = non  * log( (1.0+gamma)*non  / (gamma*(non+noff)) );
+  Double_t help2 = noff * log( (1.0+gamma)*noff / (       non+noff ) );
+  *siglima = sqrt( 2.0 * (help1+help2) );
+
+  Double_t nex = non - gamma*noff;
+  if (nex < 0.0)
+    *siglima = - *siglima;
+
+  //*fLog << "MHFindSignificanceONOFF::SigmaLiMa; non, noff, gamma, *siglima = "
+  //      << non << ",  " << noff << ",  " << gamma << ",  " << *siglima << endl;
+
+  return kTRUE;
+}
+
+
+
+//  calculates the significance according to Li & Ma
+//  ApJ 272 (1983) 317; formula 5
+//
+Bool_t MHFindSignificanceONOFF::SigmaLiMaForm5(Double_t non,   Double_t noff, 
+					       Double_t gamma, Double_t *siglima)
+{
+  if (gamma <= 0.0  ||  non <= 0.0  ||  noff <= 0.0)
+  {
+    *siglima = 0.0;
+    return kFALSE;
+  }
+
+  Double_t nex = non - (gamma*noff);
+  Double_t tmp = non + (gamma*gamma)*noff;
+  tmp = TMath::Sqrt(tmp);
+
+  *siglima = nex/tmp;
+
+  if (nex < 0.0)
+    *siglima = - *siglima;
+
+  //*fLog << "MHFindSignificanceONOFF::SigmaLiMa; non, noff, gamma, *siglima = "
+  //      << non << ",  " << noff << ",  " << gamma << ",  " << *siglima << endl;
+
+  return kTRUE;
+}
+
+
+
+
+// --------------------------------------------------------------------------
+//
+
+// Following function computes a clone of fHistOFF and normalizes 
+// contents, errors and fPolyOFF (if exists) with the fNormFactor. 
+// This normalized OFF hist will be used when plotting OFF data 
+// together with ON data.
+
+Bool_t MHFindSignificanceONOFF::ComputeHistOFFNormalized()
+{
+
+    
+    if (!fHist)
+    {
+	*fLog << "MHFindsignificanceONOFF::ComputeHistOFFNormalized; fHist does not exist, normalization of HistOFF can not be performed properly..."
+	      << endl;
+	return kFALSE;
+	
+    }
+
+    
+
+    if (!fHistOFF)
+    {
+	*fLog << "MHFindsignificanceONOFF::ComputeHistOFFNormalized; fHistOFF does not exist, hence can not be normalized" 
+          << endl;
+    return kFALSE;
+	
+    }
+
+
+    if (fNormFactor <= 0)
+    {
+	*fLog << "MHFindsignificanceONOFF::ComputeHistOFFNormalized; fNormFactor is ZERO or NEGATIVE, it might have not been defined yet..."
+          << endl;
+    return kFALSE;
+
+    }
+
+
+    Double_t BinWidthAlphaON = fHist -> GetBinWidth(1);
+    Double_t BinWidthAlphaOFF = fHistOFF -> GetBinWidth(1);
+    Double_t BinWidthRatioONOFF = BinWidthAlphaON/BinWidthAlphaOFF;
+
+
+    *fLog << "MHFindsignificanceONOFF::ComputeHistOFFNormalized; INFO about alpha ON, OFF histo bins"
+	  << endl
+	//  << "fHist bin width = " << BinWidthAlphaON 
+	  << " fHistOFF bin width = " << BinWidthAlphaOFF << endl;
+
+
+
+    TString fHistOFFNormalizedName = fHistOFF -> GetName();
+    fHistOFFNormalizedName += (" (Normalized)");
+    // fHistOFFNormalized = (TH1*) fHistOFF -> Clone();
+    // fHistOFFNormalized -> SetNameTitle(fHistOFFNormalizedName, fHistOFFNormalizedName);
+
+
+    Int_t nbinsOFFNormalized = 0;
+    Int_t nbinsOFF = 0;
+    Double_t xlow = 0.0;
+    Double_t xup = 0.0;
+    Double_t content = 0.0;
+    Double_t error = 0.0;
+    Double_t BinCenter = 0.0;
+    
+
+    // Bins for normalized OFF histo will be the ones of ON histo
+
+    
+    nbinsOFF = fHistOFF -> GetNbinsX();
+    nbinsOFFNormalized = nbinsOFF;
+    xlow = fHistOFF -> GetBinLowEdge(1);
+    xup = fHistOFF -> GetBinLowEdge(nbinsOFFNormalized);
+    xup = xup + BinWidthAlphaON;
+
+    *fLog << "MHFindsignificanceONOFF::ComputeHistOFFNormalized; Limits for fHistOFFNormalized: " 
+	  << "nbins, xlow, xup: " << nbinsOFFNormalized << ", " 
+	  <<  xlow << ", " << xup << endl;
+    
+    fHistOFFNormalized = new TH1F (fHistOFFNormalizedName, fHistOFFNormalizedName, 
+				  nbinsOFFNormalized, xlow, xup);
+    
+
+    // fHistOFFNormalized is filled with data from fHistOFF, 
+    // taken into account the possible bin difference
+
+    
+    for (Int_t i = 1; i <= nbinsOFF; i++)
+    {
+	BinCenter = fHistOFF -> GetBinCenter(i);
+	fHistOFFNormalized -> Fill (BinCenter, fHistOFF -> GetBinContent(i));
+	fHistOFFNormalized -> SetBinError(i, fHistOFF -> GetBinError(i));
+    }
+	    
+
+    
+
+    for (Int_t i = 1; i <= nbinsOFFNormalized; i++)
+    {
+	content = fNormFactor * fHistOFFNormalized -> GetBinContent(i);
+	error = fNormFactor * fHistOFFNormalized -> GetBinError(i);
+	
+	fHistOFFNormalized -> SetBinContent (i, content);
+	fHistOFFNormalized -> SetBinError (i, error);
+    }
+	
+
+    // Number of entries is obtained from histOFF.
+    // and set to histOFFNoramlized; otherwise, the number 
+    // of entries in  histOFFNoramlized would be "nbins"
+
+    Double_t entries = fNormFactor * (fHistOFF -> GetEntries());
+    fHistOFFNormalized -> SetEntries(entries);
+
+
+
+
+    // If polynomial fit has been performed for fHistOFF, 
+    // it is defined a new polyfunction for fHistOFFNormalized, 
+    // which will be the polyfunction of fHistOFF normalized.
+    // Function will be added to the function list of fHistOFFNormalized
+
+
+    
+    if (fPolyOFF == NULL)
+    {
+	*fLog << "MHFindsignificanceONOFF::ComputeHistOFFNormalized; fPolyOFF does not exist..."
+	      << endl;
+    }
+
+    if (fPolyOFF)
+    {
+	*fLog << "MHFindsignificanceONOFF::ComputeHistOFFNormalized; fPolyOFF exists... will be also normalized and included in the list of functions of fHistOFFNormalized"
+	      << endl;
+	
+	
+
+	
+	// Normalization of the function using fNormFactor and 
+	// BinWidthON/BinWidthOFF relation of alpha ON/OFF histograms
+	// This makes possible to plot it together with ON alpha histo
+
+	TString FunctionName("PolyOFFNormalized");
+
+	Double_t xmin = fAlphaminOFF;
+	Double_t xmax = fAlphamaxOFF;
+
+	TString formula = "[0]";
+	TString bra1     = "+[";
+	TString bra2     =    "]";
+	TString xpower   = "*x";
+	TString newpower = "*x";
+	for (Int_t i=1; i<=fDegreeOFF; i++)
+	{
+	    formula += bra1;
+	    formula += i;
+	    formula += bra2;
+	    formula += xpower;
+	    
+	    xpower += newpower;
+	}
+
+      *fLog << "MHFindsignificanceONOFF::ComputeHistOFFNormalized; formula = " << formula << endl;
+
+
+	
+	fPolyOFFNormalized = new TF1 (FunctionName, formula, xmin, xmax);
+	
+	
+	Double_t Parameter = 0.0;
+	Double_t ParameterError = 0.0;
+
+	*fLog << " MHFindsignificanceONOFF::ComputeHistOFFNormalized; Fit parameters info: " << endl;
+	for (Int_t i = 0; i <= fDegreeOFF; i++)
+	{
+	    Parameter = fNormFactor * BinWidthRatioONOFF * fValuesOFF[i];
+	    ParameterError = fNormFactor * BinWidthRatioONOFF * fErrorsOFF[i];
+
+	    fPolyOFFNormalized -> SetParameter(i, Parameter);
+	    fPolyOFFNormalized -> SetParError(i,ParameterError);
+
+	   
+
+	    // Parameters are shown :
+	    
+	    *fLog  << " fValuesOFF[" << i<< "] = " << fValuesOFF[i] 
+		   << " ; Parameter for  fPolyOFFNormalized = " << Parameter  << endl;
+
+	}
+	    
+
+	TList *funclist = fHistOFFNormalized->GetListOfFunctions();
+	
+	// temporal...
+	//*fLog << "INFO concerning list of functions of fHistOFFNormalized :" << endl
+	//       << "List before adding OFF Normal., after adding it and after removing fPolyOFF..." 
+	//       << endl;
+	
+	//funclist-> Print();
+	funclist-> Add(fPolyOFFNormalized);
+	
+	//funclist-> Print();
+	
+		
+
+    }
+
+    return kTRUE;
+
+}
+
+// --------------------------------------------------------------------------
+//
+
+Bool_t MHFindSignificanceONOFF::DrawHistOFF()
+{
+    if (fHistOFF == NULL )
+    {
+	*fLog << "MHFindSignificanceONOFF::DrawHistOFF; fHistOFF = NULL" << endl;
+	return kFALSE;
+    }
+
+//    fPsFilename -> NewPage();
+
+    // PLOT DISABLE
+    /*
+    TCanvas* CanvasHistOFF = new TCanvas(fHistOFF->GetName(), fHistOFF->GetName(), 600, 600);
+
+    //gStyle->SetOptFit(1011);
+
+    gROOT->SetSelectedPad(NULL);    
+    gStyle->SetPadLeftMargin(0.1);
+    gStyle -> SetOptStat(1);
+
+    CanvasHistOFF->cd();
+
+
+    if (fHistOFF)
+    {
+      fHistOFF->DrawCopy();
+    }
+
+    // TF1 *fpolyOFF = fHistOFF->GetFunction("PolyOFF");    
+    if (fPolyOFF == NULL)
+	*fLog << "MHFindSignificanceONOFF::DrawHistOFF; fpolyOFF = NULL" << endl;
+
+    if (fPolyOFF)
+    {
+      // 2, 1 is red and solid
+      fPolyOFF->SetLineColor(2);
+      fPolyOFF->SetLineStyle(1);
+      fPolyOFF->SetLineWidth(2);
+      fPolyOFF->DrawCopy("same");
+    }
+
+    CanvasHistOFF -> Update();
+
+    
+    */
+
+    return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
+
+Bool_t MHFindSignificanceONOFF::DrawHistOFFNormalized()
+{
+    if (fHistOFFNormalized == NULL )
+    {
+	*fLog << "MHFindSignificanceONOFF::DrawHistOFF; fHistOFFNormalized = NULL" << endl;
+	return kFALSE;
+    }
+
+    //   fPsFilename -> NewPage();
+
+    // PLOT DISABLE TO PERFORM GRID ANALYSIS
+    /*
+    TCanvas* CanvasHistOFFNormalized = new TCanvas(fHistOFFNormalized->GetName(), 
+						   fHistOFFNormalized->GetName(), 600, 600);
+
+    //gStyle->SetOptFit(1011);
+
+    // gROOT->SetSelectedPad(NULL);    
+    gStyle->SetPadLeftMargin(0.1);
+    gStyle -> SetOptStat(1);
+
+    CanvasHistOFFNormalized->cd();
+    
+
+    if (fHistOFFNormalized)
+    {
+      fHistOFFNormalized->DrawCopy();
+    }       
+
+    // TF1 *fpolyOFFNormalized = fHistOFFNormalized->GetFunction("PolyOFFNormalized");    
+    if (fPolyOFFNormalized == NULL)
+	*fLog << "MHFindSignificanceONOFF::DrawHistOFF; fPolyOFFNormalized = NULL" << endl;
+
+    if (fPolyOFFNormalized)
+    {
+      // 2, 1 is red and solid
+      fPolyOFFNormalized->SetLineColor(2);
+      fPolyOFFNormalized->SetLineStyle(1);
+      fPolyOFFNormalized->SetLineWidth(2);
+      fPolyOFFNormalized->DrawCopy("same");
+    }
+
+    CanvasHistOFFNormalized -> Update();
+
+
+    */
+
+    return kTRUE;
+    
+}
+
+
+// --------------------------------------------------------------------------
+//
+
+Bool_t MHFindSignificanceONOFF::DrawFit(const Option_t *opt)
+{
+    if (fHistOFFNormalized == NULL ||  fHist == NULL)
+      *fLog << "MHFindSignificanceONOFF::DrawFit; fHistOFFNormalized = NULL or fHist == NULL" << endl;
+
+    //fPsFilename -> NewPage();
+
+
+    // PLOT DISABLE TO PERFORM GRID ANALYSIS
+    // I DO SAVE PS FILE, BUT CANVAS IS DELETED AFTERWARDS
+
+    fCanvas = new TCanvas("Alpha", "Alpha plot", 600, 600);
+    fCanvas -> SetFillColor(10);
+    
+
+
+
+    //gStyle->SetOptFit(1011);
+
+    gROOT->SetSelectedPad(NULL);    
+    gStyle -> SetFrameFillColor(10);
+    gStyle->SetPadLeftMargin(0.15);
+    gStyle -> SetOptStat(1);
+    
+    fCanvas->cd();
+    
+    if (fHist)
+      {
+	fHist -> SetTitle("Alpha Plot");
+	fHist-> SetTitleOffset(1.5, "Y");
+	fHist-> DrawCopy();
+	
+      }
+
+
+    if (fHistOFFNormalized)
+    {
+	TF1 *fpoly = fHistOFFNormalized->GetFunction("PolyOFFNormalized");    
+	if (fpoly == NULL)
+	    *fLog << "MHFindSignificanceONOFF::DrawFit; fPolyOFFNormalized = NULL" << endl;
+
+	if (fpoly)
+	{
+	    // 2, 1 is red and solid
+	    fpoly->SetLineColor(2);
+	    fpoly->SetLineStyle(1);
+	    fpoly->SetLineWidth(2);
+	    fpoly->DrawCopy("same");
+	}
+    }
+
+    if (fFitGauss)
+    {
+      TF1 *fpolygauss = fHist->GetFunction("PolyGauss");    
+      if (fpolygauss == NULL)
+        *fLog << "MHFindSignificanceONOFF::DrawFit; fpolygauss = NULL" << endl;
+
+      if (fpolygauss)
+      {
+        // 4, 1 is blue and solid
+        fpolygauss->SetLineColor(4);
+        fpolygauss->SetLineStyle(1);
+        fpolygauss->SetLineWidth(4);
+        fpolygauss->DrawCopy("same");
+      }
+ 
+      TF1 *fbackg = fHist->GetFunction("Backg");    
+      if (fbackg == NULL)
+        *fLog << "MHFindSignificanceONOFF::DrawFit; fbackg = NULL" << endl;
+
+      if (fbackg)
+      {
+        // 10, 1 is white and solid
+        fbackg->SetLineColor(10);
+        fbackg->SetLineStyle(1);
+        fbackg->SetLineWidth(4);
+        // fbackg->DrawCopy("same"); I do not want to draw it... already too many things.
+      }
+    }
+
+
+    //-------------------------------
+    // print results onto the figure
+    
+    
+    
+    TPaveText *pt = new TPaveText(0.30, 0.35, 0.70, 0.90, "NDC");
+    char tx[100];
+    
+    sprintf(tx, "Results of polynomial fit to OFF (order %2d) :", fDegreeOFF);
+    TText *t1 = pt->AddText(tx);
+    t1->SetTextSize(0.03);
+    t1->SetTextColor(2);
+    
+    sprintf(tx, "   (%6.2f< |alpha| <%6.2f [\\circ])", fAlphaminOFF, fAlphamaxOFF);
+    pt->AddText(tx);
+    
+    sprintf(tx, "   chi2 = %8.2f,  Ndof = %4d,  Prob = %6.2f", 
+	    fChisqOFF, fNdfOFF, fProbOFF);
+    pt->AddText(tx);
+    
+    sprintf(tx, "   OFF events (fit)= %8.1f #pm %8.1f", 
+	    fNoffTotFitted, fdNoffTotFitted);
+    pt->AddText(tx);
+    
+    sprintf(tx, "   OFF events (meas) = %8.1f #pm %8.1f", fNoffTot, fdNoffTot);
+    pt->AddText(tx);
+    
+    sprintf(tx, "   OFF Normalization Factor (= Non/Noff) = %4.4f", fNormFactor);
+    pt->AddText(tx);
+    
+    
+    
+    
+    //sprintf(tx, "     ");
+    //pt->AddText(tx);
+    
+    //--------------
+    sprintf(tx, "Results for |alpha|< %6.2f [\\circ] :", fAlphasi);
+    TText *t6 = pt->AddText(tx);
+    t6->SetTextSize(0.03);
+    t6->SetTextColor(8);
+    
+    sprintf(tx, "   Non = %8.1f #pm %8.1f", fNon, fdNon);
+    pt->AddText(tx);
+    
+    
+    if(fUseFittedQuantities)
+      {
+	//// **************************************************
+	///// PRINT INFORMATION ABOUT FITTED QUANTITIES  /////////
+	
+	
+	
+	Double_t NoffFitNormalized = fNoffSigFitted * fNormFactor;
+	Double_t ErrorNoffFitNormalized = fdNoffSigFitted * fNormFactor;
+	Double_t SignificanceUsed = GetSignificance();
+	
+	sprintf(tx, "   Noff Fitted (Normalized)  = %8.1f #pm %8.1f", 
+		NoffFitNormalized, ErrorNoffFitNormalized);
+	pt->AddText(tx);
+	
+	
+	sprintf(tx, "   Nex (ON - OFF Fitted) = %8.1f #pm %8.1f", 
+		fNexONOFFFitted, fdNexONOFFFitted);
+	pt->AddText(tx);
+	
+	
+	sprintf(tx, "   Gamma = %4.4f,   Effective Noff (i.e. fNoff) = %6.1f", 
+		fGamma, fNoff);
+	pt->AddText(tx);
+	
+	
+	Double_t ratio = fNoffSigFitted>0.0 ? fNexONOFFFitted/(fNoffSigFitted*fNormFactor) : 0.0;
+	sprintf(tx, "   Significance = %6.2f,    Nex/(Nbg*NormFactor) = %6.2f", 
+		SignificanceUsed, ratio);
+	pt->AddText(tx);
+	
+	
+      }
+    
+    else
+      {
+	//// **************************************************
+	///// PRINT INFORMATION ABOUT MEASURED QUANTITIES  /////////
+	
+	
+	Double_t NoffNormalized = fNoffSig * fNormFactor;
+	Double_t ErrorNoffNormalized = fdNoffSig * fNormFactor;
+	Double_t SignificanceUsed = GetSignificance();
+	
+	sprintf(tx, "   Noff measured (Normalized)  = %8.1f #pm %8.1f", 
+		NoffNormalized, ErrorNoffNormalized);
+	pt->AddText(tx);
+	
+	sprintf(tx, "   Nex (ON - OFF measured) = %8.1f #pm %8.1f", 
+		fNexONOFF, fdNexONOFF);
+	pt->AddText(tx);
+	
+	Double_t ratio = fNoffSig>0.0 ? fNexONOFF/(fNoffSig*fNormFactor) : 0.0;
+	sprintf(tx, "   Significance = %6.2f,    Nex/(Nbg*NormFactor) = %6.2f", 
+		SignificanceUsed, ratio);
+	pt->AddText(tx);
+	
+      }
+    
+    /*
+      // Temporally I will also show ALL SIGMALIMA COMPUTED.
+      
+      sprintf(tx, 
+      "  fSigLiMa1 =  %6.2f, fSigLiMa2 =  %6.2f, fSigLiMa3 =  %6.2f", 
+      fSigLiMa,fSigLiMa2, fSigLiMa3);
+      pt->AddText(tx);
+    */
+    
+    
+    //--------------
+    if (fFitGauss)
+      {
+	sprintf(tx, "Results of (polynomial+Gauss) fit  :");
+	TText *t7 = pt->AddText(tx);
+	t7->SetTextSize(0.03);
+	t7->SetTextColor(4);
+	
+	sprintf(tx, "   chi2 = %8.2f,  Ndof = %4d,  Prob = %6.2f", 
+		fGChisq, fGNdf, fGProb);
+	pt->AddText(tx);
+	
+	sprintf(tx, "   Sigma of Gauss = %8.1f #pm %8.1f  [\\circ]", 
+		fSigmaGauss, fdSigmaGauss);
+	pt->AddText(tx);
+	
+	sprintf(tx, "   total no.of excess events = %8.1f #pm %8.1f", 
+		fNexGauss, fdNexGauss);
+	pt->AddText(tx);
+      }
+    //--------------
+    
+    pt->SetFillStyle(0);
+    pt->SetBorderSize(0);
+    pt->SetTextAlign(12);
+    
+    
+    if(fPrintResultsOntoAlphaPlot)
+      {
+	pt->Draw();
+      }
+    fCanvas->Modified();
+    fCanvas->Update();
+    
+    //    fPsFilename -> NewPage();
+
+
+
+    if (fSavePlots)
+    {
+	// ********************************************
+	// TMP solution while the TPostScript thing is not working. 
+	// PsFileName for storing these histograms is derived 
+	// from fPsFilenameString. 
+	
+	
+	cout << "Alpha plot with ON-OFF data will be saved in PostScript file  " ;
+	
+	
+	if (!fPsFilenameString.IsNull())
+	{
+	    TString filename = (fPsFilenameString);
+	    // Train or Test Sample is specified outside 
+	    // class MHFindSignificanceONOFF, and included in 
+	    // fPsFilenameString
+	    
+	    filename += ("AlphaPlotAfterSupercuts.ps");
+	    cout << filename << endl;	
+	    fCanvas -> SaveAs(filename);
+	}
+	
+	// END OF TEMPORAL SOLUTION
+	// ********************************************
+	
+    }
+    
+    // Canvvas deleted to allow for GRID analysis
+
+    delete fCanvas;
+	
+
+    return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Print the results of the polynomial fit to the alpha OFF distribution
+// 
+//
+void MHFindSignificanceONOFF::PrintPolyOFF(Option_t *o) 
+{
+  *fLog << "---------------------------" << endl;
+  *fLog << "MHFindSignificanceONOFF::PrintPolyOFF :" << endl; 
+
+  *fLog << "fAlphaminOFF, fAlphamaxOFF, fDegreeOFF "
+        << fAlphaminOFF << ",  " << fAlphamaxOFF << ",  " << fDegreeOFF <<  endl;
+
+  *fLog << "fMbinsOFF, fNzeroOFF, fIstatOFF = " << fMbinsOFF << ",  "
+        << fNzeroOFF << ",  " << fIstatOFF << endl;
+
+  *fLog << "fChisqOFF, fNdfOFF, fProbOFF = " << fChisqOFF << ",  " 
+        << fNdfOFF << ",  " << fProbOFF << endl; 
+
+  *fLog << "fNon; fNoffSigFitted, fdNoffSigFitted; fNoffSig, fdNoffSig = "
+        << fNon << ";  " << fNoffSigFitted << ",  " << fdNoffSigFitted 
+	<< ";  " << fNoffSig << ",  " << fdNoffSig <<  endl;
+
+  Double_t sigtoback = fNoffSigFitted >0.0 ? fNexONOFFFitted/(fNoffSigFitted*fNormFactor) : 0.0;
+
+  
+  *fLog << "fNexONOFFFitted, fdNexONOFFFitted, fGamma, fNoff, fSigLiMa, sigtoback = "
+        << fNexONOFFFitted << ",  " << fdNexONOFFFitted << ",  " 
+	<< fGamma << ",  " << fNoff 
+        << ",  " << fSigLiMa << ",  "
+	<< sigtoback << endl;
+
+
+  Double_t sigtoback2 = fNoffSig >0.0 ? fNexONOFF/(fNoffSig*fNormFactor) : 0.0;
+  
+  *fLog << "fNexONOFF, fdNexONOFF, fNormFactor, fNoffSig, fSigLiMa2, sigtoback2 = "
+        << fNexONOFF << ",  " << fdNexONOFF << ",  " 
+	<< fNormFactor << ",  " << fNoffSig 
+        << ",  " << fSigLiMa2 << ",  "
+	<< sigtoback2 << endl;
+
+ *fLog << "---------------------------" << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Print the results of the polynomial fit to the alpha distribution
+// 
+//
+void MHFindSignificanceONOFF::PrintPoly(Option_t *o) 
+{
+  *fLog << "---------------------------" << endl;
+  *fLog << "MHFindSignificanceONOFF::PrintPoly :" << endl; 
+
+  *fLog << "fAlphami, fAlphama, fDegree, fAlphasi = "
+        << fAlphami << ",  " << fAlphama << ",  " << fDegree << ",  " 
+        << fAlphasi << endl;
+
+  *fLog << "fMbins, fNzero, fIstat = " << fMbins << ",  "
+        << fNzero << ",  " << fIstat << endl;
+
+  *fLog << "fChisq, fNdf, fProb = " << fChisq << ",  " 
+        << fNdf << ",  " << fProb << endl; 
+
+  *fLog << "fNon, fNbg, fdNbg, fNbgtot, fNbgtotFitted, fdNbgtotFitted = "
+        << fNon << ",  " << fNbg << ",  " << fdNbg << ",  " << fNbgtot 
+        << ",  " << fNbgtotFitted << ",  " << fdNbgtotFitted << endl;
+
+  Double_t sigtoback = fNbg>0.0 ? fNex/fNbg : 0.0;
+  *fLog << "fNex, fdNex, fGamma, fNoff, fSigLiMa, sigtoback = "
+        << fNex << ",  " << fdNex << ",  " << fGamma << ",  " << fNoff 
+        << ",  " << fSigLiMa << ",  " << sigtoback << endl;
+
+  //------------------------------------
+  // get errors
+
+  /*
+  Double_t eplus; 
+  Double_t eminus; 
+  Double_t eparab; 
+  Double_t gcc;
+  Double_t errdiag;
+
+
+  if ( !fConstantBackg )
+  {
+    *fLog << "parameter value     error     eplus     eminus    eparab   errdiag   gcc"
+          << endl; 
+
+    for (Int_t j=0; j<=fDegree; j++)
+    {
+      if (gMinuit)
+        gMinuit->mnerrs(j, eplus, eminus, eparab, gcc);
+      errdiag = sqrt(fEma[j][j]);
+      *fLog << j << "  " << fValues[j] << "  "   << fErrors[j] << "  "
+            << eplus     << "  "       << eminus << "  " << eparab     << "  " 
+            <<  errdiag  << "  "       << gcc    << endl;
+    }
+  }  
+  else
+  {
+    *fLog << "parameter value     error     errdiag "
+          << endl; 
+
+    for (Int_t j=0; j<=fDegree; j++)
+    {
+      errdiag = sqrt(fEma[j][j]);
+      *fLog << j << "  " << fValues[j] << "  "   << fErrors[j] << "  "
+            <<  errdiag  << endl;
+    }
+  }  
+  */
+
+  //----------------------------------------
+  /*
+  *fLog << "Covariance matrix :" << endl;
+  for (Int_t j=0; j<=fDegree; j++)
+  {
+    *fLog << "j = " << j << " :   ";
+    for (Int_t k=0; k<=fDegree; k++)
+    {
+      *fLog << fEma[j][k] << "   ";
+    }
+    *fLog << endl;
+  }
+
+  *fLog << "Correlation matrix :" << endl;
+  for (Int_t j=0; j<=fDegree; j++)
+  {
+    *fLog << "j = " << j << " :   ";
+    for (Int_t k=0; k<=fDegree; k++)
+    {
+      *fLog << fCorr[j][k] << "   ";
+    }
+    *fLog << endl;
+  }
+  */
+
+  *fLog << "---------------------------" << endl;
+}
+
+// --------------------------------------------------------------------------
+//
+// Print the results of the (polynomial+Gauss) fit to the alpha distribution
+// 
+//
+void MHFindSignificanceONOFF::PrintPolyGauss(Option_t *o) 
+{
+  *fLog << "---------------------------" << endl;
+  *fLog << "MHFindSignificanceONOFF::PrintPolyGauss :" << endl; 
+
+  *fLog << "fAlphalo, fAlphahi = "
+        << fAlphalo << ",  " << fAlphahi << endl;
+
+  *fLog << "fGMbins, fGNzero, fGIstat = " << fGMbins << ",  "
+        << fGNzero << ",  " << fGIstat << endl;
+
+  *fLog << "fGChisq, fGNdf, fGProb = " << fGChisq << ",  " 
+        << fGNdf << ",  " << fGProb << endl; 
+
+
+  //------------------------------------
+  // get errors
+
+  Double_t eplus; 
+  Double_t eminus; 
+  Double_t eparab; 
+  Double_t gcc;
+  Double_t errdiag;
+
+  *fLog << "parameter value     error     eplus     eminus    eparab   errdiag   gcc"
+        << endl; 
+  for (Int_t j=0; j<=(fDegree+3); j++)
+  {
+    if (gMinuit)
+      gMinuit->mnerrs(j, eplus, eminus, eparab, gcc);
+    errdiag = sqrt(fGEma[j][j]);
+    *fLog << j << "  " << fGValues[j] << "  "   << fGErrors[j] << "  "
+          << eplus     << "  "       << eminus << "  " << eparab     << "  " 
+          <<  errdiag  << "  "       << gcc    << endl;
+  }
+
+  
+  *fLog << "Covariance matrix :" << endl;
+  for (Int_t j=0; j<=(fDegree+3); j++)
+  {
+    *fLog << "j = " << j << " :   ";
+    for (Int_t k=0; k<=(fDegree+3); k++)
+    {
+      *fLog << fGEma[j][k] << "   ";
+    }
+    *fLog << endl;
+  }
+
+  *fLog << "Correlation matrix :" << endl;
+  for (Int_t j=0; j<=(fDegree+3); j++)
+  {
+    *fLog << "j = " << j << " :   ";
+    for (Int_t k=0; k<=(fDegree+3); k++)
+    {
+      *fLog << fGCorr[j][k] << "   ";
+    }
+    *fLog << endl;
+  }
+
+  *fLog << "---------------------------" << endl;
+}
+
+//============================================================================
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/MHFindSignificanceONOFF.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/MHFindSignificanceONOFF.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/MHFindSignificanceONOFF.h	(revision 9661)
@@ -0,0 +1,400 @@
+#ifndef MARS_MHFindSignificanceONOFF
+#define MARS_MHFindSignificanceONOFF
+
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+#ifndef ROOT_TArrayD
+#include <TArrayD.h>
+#endif
+
+#ifndef ROOT_TPostScript
+#include <TPostScript.h>
+#endif
+
+
+class TF1;
+class TH1;
+class TCanvas;
+
+class MHFindSignificanceONOFF : public MH
+{
+private:
+
+    TH1  *fHistOrig;  // original plot of |alpha| (0.0 to 90.0 degrees)
+    TH1  *fHist;      // copy of fHistOrig or rebinned histogram
+
+
+    
+   TH1  *fHistOrigOFF;  // original plot of |alpha| (0.0 to 90.0 degrees)
+   TH1  *fHistOFF;      // copy of fHistOrig or rebinned histogram
+   TH1  *fHistOFFNormalized;   //  fHistOFF normalized (contents and errors) with 
+                               //   with fNormFactor; useful when plotting OFF 
+                               //  Data together with ON data
+
+ 
+  // Postscript file where, for each theta bin,  
+   // alpha ON and OFF distributions 
+  //  after cuts (and hence, Nex and SigmaLiMa computations) will be stored
+   // This TPostScript object has to be initialized and closed finally 
+   // outside this class.
+ 
+   // NOT WORKING WELL !!!
+   
+   TPostScript* fPsFilename;
+   
+
+   TString fPsFilenameString; // Name of the file where plots will be stored while the 
+  // TPostScript option is not working 
+
+
+
+    Double_t fAlphamin;  // requested lower limit of fit range
+    Double_t fAlphammm;  // center of fit range
+    Double_t fAlphamax;  // requested lower limit of fit range
+
+    Double_t fAlphaminOFF; // requested lower limit of fit range for OFF data
+    Double_t fAlphamaxOFF;  // requested lower limit of fit range for OFF data
+
+
+    Double_t fAlphami;  // actual lower limit of fit range 
+    Double_t fAlphamm;  // actual center of fit range 
+    Double_t fAlphama;  // actual upper limit of fit range
+
+    Double_t fAlphasig; // requested signal range
+    Double_t fAlphasi;  // actual signal range
+    Double_t fAlphasiOFF;  // actual signal range for OFF data
+
+
+    Double_t fAlphalow; // requested lower edge of signal range
+    Double_t fAlphalo;  // actual lower edge of signal range
+
+    Double_t fAlphahig; // requested upper edge of background range
+    Double_t fAlphahi;  // actual upper edge of background range
+ 
+    // number of events in signal region
+    Double_t fNon;     // total number of events in signal region
+    Double_t fNbg;     // number of background events in signal region
+    Double_t fNex;     // number of excess events in signal region
+
+    Double_t fdNon;
+    Double_t fdNbg;
+    Double_t fdNex;
+
+    // number of events in background region
+    Double_t fNbgtot;  // total number of events in background region
+    Double_t fNbgtotFitted;  // fitted total no. of events in background region
+    Double_t fdNbgtotFitted; // fitted error of this number
+
+    // Variables related to OFF data. 
+    // Many variables are defined for similarity with 
+    // existing program. Many of them might be removed in future...
+
+
+    Double_t fNexONOFF;     // number of excess events (ON-OFF) 
+                            // in signal region
+    Double_t fNexONOFFFitted;     // number of excess events (ON-OFF fitted) 
+                                  // in signal region
+
+    Double_t fdNexONOFF;     // error in number of excess events (ON-OFF) 
+                            // in signal region
+    Double_t fdNexONOFFFitted;     // error in number of excess events (ON-OFF fitted) 
+                                  // in signal region
+
+
+    
+    Double_t fNoffTot;       // Total number of OFF events
+    Double_t fNoffSig;    // Number of OFF events in "signal" region 
+    Double_t fNoffBg;     // Number of OFF events in "background" region
+    
+    // errors for previous quantities
+
+    Double_t fdNoffTot;       
+    Double_t fdNoffSig;    
+    Double_t fdNoffBg;     
+
+    // Fitted quantities for OFF alpha distribution
+
+    Double_t fNoffTotFitted;       // Total number of OFF events
+    Double_t fNoffSigFitted;    // Number of OFF events in "signal" region 
+    Double_t fNoffBgFitted;     // Number of OFF events in "background" region
+    
+    // errors for previous quantities
+
+    Double_t fdNoffTotFitted;       
+    Double_t fdNoffSigFitted;    
+    Double_t fdNoffBgFitted;     
+
+    
+    // Boolean variable used to disable the usage ("serious" usage) of the 
+    // quantities computed from fits. This will be useful in those cases 
+    // where there is too few events to perform a decent fit to the 
+    // alpha histograms.
+    
+    Bool_t fUseFittedQuantities;
+
+
+
+    // Bool variable used to decide wether to print or not the results 
+    // of the fit, significance, Nex... onto the final alpha plot. 
+    // for the time being, this variable is set in the constructor. 
+    // At some point, I might make it such it can be set externally...
+
+    Bool_t fPrintResultsOntoAlphaPlot;
+
+
+    // effective number of background events
+    Double_t fNoff; // fNoff = fNoffSig * fNormFactor
+    Double_t fGamma;   // 
+    Double_t fNormFactor; // = TotalNon/TotalNoff)
+
+    Double_t fSigLiMa; // significance of gamma signal according to Li & Ma
+                       // Computed using quantities fGama and Noff
+                       // and formula (17) 
+
+
+    Double_t fSigLiMa2; // significance of gamma signal according to Li & Ma
+                        // Computed using quantities  fNormFactor and fNoffSig
+                        // and formula (17)
+
+    Double_t fSigLiMa3; // significance of gamma signal according to Li & Ma
+                        // Computed using quantities  fNormFactor and fNoffSig
+                        // and formula (5)
+
+                       
+
+
+    const static Double_t fEps = 1.e-4;  // tolerance for floating point comparisons
+
+    Bool_t fDraw;          // if true : draw plots
+    Bool_t fSavePlots;     // if true : Save plots in Psfile
+    Bool_t fFitGauss;      // if true : do the (polynomial+Gauss fit)
+    Bool_t fRebin;         // if true : allow rebinning of the alpha plot    
+    Bool_t fReduceDegree;  // if true : allow reducing of the order of the polynomial
+
+    Bool_t fConstantBackg; // if set true if background fit is not possible
+                           // due to low statistics
+
+    TCanvas  *fCanvas;
+
+    Double_t fNexGauss;    // total number of excess events 
+                           // (from fitted Gauss function)
+    Double_t fdNexGauss;   // error of the total number of excess events
+ 
+    Double_t fSigmaGauss;  // sigma of fitted Gauss function
+    Double_t fdSigmaGauss; // error of this sigma
+
+    //--------------------
+    TF1      *fPoly;   // polynomial function
+    Int_t    fFitBad;  // if != 0 fit failed
+    Int_t    fDegree;  // degree of polynomial to be fitted to the background
+    Int_t    fNdf;     // number of degrees of freedom of polynomial fit
+    Double_t fChisq;   // chi squared of polynomial fit
+    Double_t fProb;    // chi squared probability ofg polynomial fit 
+
+    TArrayD fValues;
+    TArrayD fErrors;
+
+    const static Int_t    fNdim = 6;
+    Double_t fEmat[fNdim][fNdim];
+    Double_t fEma [fNdim][fNdim];
+    Double_t fCorr[fNdim][fNdim];
+
+    Int_t  fMbins;     // number of bins in the fit range
+    Int_t  fMlow;      // number of bins in the fit range with too few entries
+    Int_t  fNzero;     // number of bins in the fit range with zero entry
+    Int_t  fIstat;
+
+    //--------------------
+
+    // Fit to OFF data
+
+    
+    TF1      *fPolyOFF;   // polynomial function for OFF data
+    
+    TF1      *fPolyOFFNormalized;  //  polynomial function for OFF data normalized with fNormFactor*(BinWidthON/BinWidthOFF)
+
+    Int_t    fFitBadOFF;  // if != 0 fit failed
+    Int_t    fDegreeOFF;  // degree of polynomial to be fitted to the background
+    Int_t    fNdfOFF;     // number of degrees of freedom of polynomial fit
+    Double_t fChisqOFF;   // chi squared of polynomial fit
+    Double_t fProbOFF;    // chi squared probability ofg polynomial fit 
+
+    TArrayD fValuesOFF;
+    TArrayD fErrorsOFF;
+    TArrayD fValuesOFFNormalized;
+    TArrayD fErrorsOFFNormalized;
+
+    const static Int_t    fNdimOFF = 6;
+    Double_t fEmatOFF[fNdim][fNdim];
+    Double_t fEmaOFF [fNdim][fNdim];
+    Double_t fCorrOFF[fNdim][fNdim];
+
+    Int_t  fMbinsOFF;     // number of bins in the fit range
+    Int_t  fMlowOFF;      // number of bins in the fit range with too few entries
+    Int_t  fNzeroOFF;     // number of bins in the fit range with zero entry
+    Int_t  fIstatOFF;
+
+
+    //--------------------
+    TF1      *fGPoly;   // (Gauss+polynomial) function
+    TF1      *fGBackg;  // polynomial part of (Gauss+polynomial) function
+    Int_t    fGFitBad;  // if != 0 fit failed
+    Int_t    fGDegree;  // degree of polynomial to be fitted to the background
+    Int_t    fGNdf;     // number of degrees of freedom of polynomial fit
+    Double_t fGChisq;   // chi squared of polynomial fit
+    Double_t fGProb;    // chi squared probability ofg polynomial fit 
+
+    TArrayD fGValues;
+    TArrayD fGErrors;
+
+    const static Int_t    fGNdim = 9;
+    Double_t fGEmat[fGNdim][fGNdim];
+    Double_t fGEma[fGNdim][fGNdim];
+    Double_t fGCorr[fGNdim][fGNdim];
+
+    Int_t  fGMbins;     // number of bins in the fit range
+    Int_t  fGNzero;     // numnber of bins in the fit range with zero entry
+    Int_t  fGIstat;
+
+    //--------------------
+
+    static const TString gsDefName;  //! Default Name
+    static const TString gsDefTitle; //! Default Title
+
+    Bool_t DetExcess(); 
+    Bool_t DetExcessONOFF(); 
+    Bool_t FitPolynomial();
+    Bool_t FitPolynomialOFF();
+    Bool_t FitGaussPoly();
+    //Bool_t FitGaussPolyONOFF();
+    Bool_t RebinHistogram(Double_t x0, Int_t nrebin);
+    Bool_t RebinHistogramOFF(Double_t x0, Int_t nrebin);
+
+ public:
+    MHFindSignificanceONOFF(const char *name=NULL, const char *title=NULL);
+    ~MHFindSignificanceONOFF();
+
+    
+    // fhistOFF is the alpha distribution of OFF data (after cuts), 
+    // BUT NOT normalized. Normalization factor is also one of the 
+    // arguments. Off alpha distribution will be normalized 
+    // at the beginning of the function FindSigmaONOFF. 
+
+    Bool_t FindSigmaONOFF(TH1 *fhistON, TH1 *fhistOFF, 
+			  Double_t NormFactor,
+			  Double_t alphamin, Double_t alphamax,
+			  Int_t degreeON,  Int_t degreeOFF, 
+			  Double_t alphasig, 
+			  Bool_t drawpoly, 
+			  Bool_t fitgauss, 
+			  Bool_t print, Bool_t saveplots, 
+			  //TPostScript* PsFile
+			  const TString psfilename);
+
+    // Set limits for the polynomial fit of the OFF data
+    // It will give the user the possibility of using, 
+    // for the OFF data substraction, a fit in the region 
+    // of interest. Might be useful in case of "pathological"  
+    // alpha distribution for the OFF data.
+
+    void SetLimitsForOFFDataFit(Double_t Low, Double_t Up)
+	{ fAlphaminOFF = Low; fAlphamaxOFF = Up;  }
+
+    void SetAlphaSig (Double_t alphasig)
+	{ fAlphasig = alphasig; }
+
+
+    void SetUseFittedQuantities (Bool_t b)
+	{fUseFittedQuantities = b;}
+	    
+
+    Bool_t SigmaLiMa(Double_t non, Double_t noff, Double_t gamma,
+                     Double_t *siglima);
+
+    Bool_t SigmaLiMaForm5(Double_t non, Double_t noff, Double_t gamma,
+			  Double_t *siglima);
+
+   
+    Bool_t SigmaVsAlphaONOFF(TH1 *fhistON, TH1 *fhistOFF,  
+			     Double_t alphamin, Double_t alphamax, 
+			     Int_t degree, Bool_t print);
+    
+
+
+    // Function that returns one of the 3 LiMa sigmas. 
+    // The returned value is the one used in the optimization 
+    // and final alpha plots. 
+    
+
+    Double_t GetSignificance();//   { return fSigLiMa; }
+
+    Bool_t GetUseFittedQuantities() {return fUseFittedQuantities;}
+
+
+
+    // Following function computes a clone of fHistOFF and normalizes 
+    // contents, errors and fPolyOFF (if exists) with the fNormFactor. 
+    // This normalized OFF hist will be used when plotting OFF data 
+    // together with ON data.
+ 
+    Bool_t ComputeHistOFFNormalized(); 
+
+
+    Bool_t DrawFit(Option_t *opt=NULL);
+
+    Bool_t DrawHistOFF();
+    Bool_t DrawHistOFFNormalized();
+
+    Float_t GetDegree()     const { return fDegree;  }
+    Float_t GetProb()       const { return fProb;    }
+    Float_t GetNdf()        const { return fNdf;     }
+    Float_t GetGamma()      const { return fGamma;   }
+    Float_t GetNon()        const { return fNon;     }
+    Float_t GetNex()        const { return fNex;     }
+    Float_t GetNbg()        const { return fNbg;     }
+    Float_t GetSigLiMa1()    const { return fSigLiMa; }
+    Float_t GetSigLiMa2()    const { return fSigLiMa2; }
+    Float_t GetSigLiMa3()    const { return fSigLiMa3; }
+       
+    Float_t GetMbins()      const { return fMbins;   }
+    Float_t GetAlphasi()    const { return fAlphasi; }
+    Float_t GetNexONOFF() const {return fNexONOFF;}
+    Float_t GetNexONOFFFitted() const {return fNexONOFFFitted;}
+    
+    
+
+    void SetRebin(Bool_t b=kTRUE);
+    void SetReduceDegree(Bool_t b=kTRUE);
+
+    void SetPsFilename (TPostScript* PsFile) {fPsFilename = PsFile;}
+
+    void PrintPoly(Option_t *opt=NULL);
+    void PrintPolyOFF(Option_t *opt=NULL);
+    void PrintPolyGauss(Option_t *opt=NULL);
+
+    ClassDef(MHFindSignificanceONOFF, 1) // Determine significance from alpha plot
+};
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/MSupercutsCalcONOFF.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/MSupercutsCalcONOFF.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/MSupercutsCalcONOFF.cc	(revision 9661)
@@ -0,0 +1,797 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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, 04/2003 <mailto:wittek@mppmu.mpg.de>
+!               David Paneque,   02/2004 <mailto:dpaneque@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//                                                                         //
+//   MSupercutsCalcONOFF                                                     //
+//                                                                         //
+//   this class calculates the hadronness for the supercuts                //
+//   the parameters of the supercuts are taken                             //
+//                  from the container MSupercuts                       //
+//                                                                         //
+//                                                                         //
+/////////////////////////////////////////////////////////////////////////////
+#include "MSupercutsCalcONOFF.h"
+
+#include <math.h>
+#include <fstream>
+
+#include "TFile.h"
+#include "TArrayD.h"
+
+#include "MParList.h"
+#include "MHillasExt.h"
+#include "MHillasSrc.h"
+#include "MNewImagePar.h"
+#include "MPointingPos.h"
+#include "MCerPhotEvt.h"
+#include "MGeomCam.h"
+#include "MHadronness.h"
+#include "MTSupercutsApplied.h"
+#include "MHMatrix.h"
+#include "MSupercuts.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MSupercutsCalcONOFF);
+
+using namespace std;
+
+
+// --------------------------------------------------------------------------
+//
+// constructor
+//
+
+MSupercutsCalcONOFF::MSupercutsCalcONOFF(const char *hilname, 
+                                     const char *hilsrcname, 
+                                     const char *name, const char *title)
+  : fHadronnessName("MHadronness"), fSupercutsAppliedName("MSupercutsApplied"), 
+    fHilName(hilname), fHilSrcName(hilsrcname),
+    fHilExtName("MHillasExt"), fNewParName("MNewImagePar"), 
+    fSuperName("MSupercuts") 
+{
+    fName  = name  ? name  : "MSupercutsCalcONOFF";
+    fTitle = title ? title : "Class to evaluate the Supercuts";
+
+    fMatrix = NULL;
+
+    fStoreAppliedSupercuts = kFALSE; // by default, applied SC parameters are not stored
+
+    fNotUseTheta = kFALSE; // by default, theta info is used in the computation of the cuts
+
+    fUseStaticCuts = kFALSE; // by default, dynamical cuts are used
+
+
+    // Usage of DIST parameter in the parameterization of the cuts.
+    // For the time being is in the constructor. If finally it comes out 
+    // that it is important to disable the DIST parameter from the 
+    // cut parameterization I will make a function that access this 
+    // data variable from outside the class.
+    fUseDist = kTRUE;
+
+
+
+    // OFFSETS FOR THE DYNAMICAL CUTS
+    // Values of Size (photons), Dist (degrees) and Theta (degrees) 
+    // for which the value of the dynamical cut is equal to the 
+    // non dependent parameter; i.e. to the static cut. 
+    // By adjusting these offsets the user can set the value in size, 
+    // dist and theta for which the dynamical cuts will be given by 
+    // the term that DOES not depend on size, dist and theta.
+
+    // For the time being, these quantities are set in the constructor. 
+    // In future, if they show to be useful, I will make them available 
+    // as external variables.
+
+    fSizeOffset = 3000; // photons
+    fDistOffset = 0.9; // degrees  
+    fThetaOffset = 20; // degrees   NOT USED FOR THE TIME BEING
+
+    
+
+
+
+
+    // Variables defining upper limits for some of the hillas params.
+    // The default values are set to conservative 
+    // values so that no gamma showers are removed
+
+    // If a cut value computed by function MSupercutsCalcONOFF::CtsMCut, 
+    // (i.e. widthlow) exceeds (larger or smaller 
+    // depending on wether is cutUP or cutLOW) one of these values
+    // (i.e. fWidthLowerLimit), such cut value is replaced by the 
+    // the corresponding Limit (i.e. widthlow = fWidthLowerLimit)
+
+
+
+    fDistUpperLimit = 1.4; // in deg
+    fLengthUpperLimit = 0.6;
+    fWidthUpperLimit = 0.4;
+
+    fLeakage1UpperLimit = 0.25; 
+
+    fLengthOverWidthUpperLimit = 1.0;
+
+    fDistLowerLimit = 0.1;
+    fLengthLowerLimit = 0.09;
+    fWidthLowerLimit = 0.05;
+
+    
+
+
+
+
+}
+
+// --------------------------------------------------------------------------
+//
+
+
+void MSupercutsCalcONOFF::SetStoreAppliedSupercuts(Bool_t b)
+{
+    fStoreAppliedSupercuts = b;
+    if (fStoreAppliedSupercuts)
+    {
+	*fLog << "Supercuts applied to all the individual events will be stored " 
+	      << "in a container of the class MSupercutsApplied." << endl;
+    }
+
+}
+
+
+void MSupercutsCalcONOFF::SetVariableNotUseTheta(Bool_t b)
+{
+    fNotUseTheta = b;
+    if (fNotUseTheta)
+    {
+	*fLog << "Theta variable is NOT used in the computation of the the  " 
+	      << "dynamical cuts" << endl;
+    }
+    else
+    {
+	*fLog << "Theta variable is used in the computation of the the  " 
+	      << "dynamical cuts" << endl;
+    }
+
+}
+
+
+void MSupercutsCalcONOFF::SetVariableUseStaticCuts(Bool_t b)
+{
+    fUseStaticCuts = b;
+    if (fUseStaticCuts)
+    {
+	*fLog << "Supercuts DO NOT take into account Theta, Size and Dist dependence; "
+	      << "i.e, they are STATIC CUTS." << endl;
+    }
+    else
+    {
+	*fLog << "Supercuts are computed taking into account Theta, size and Dist dependence."
+	      << "i.e., they are DYNAMICAL CUTS" << endl;
+
+    }
+
+
+
+}
+
+
+void MSupercutsCalcONOFF::SetHillasDistLengthWidthUpperLowerLimits(Double_t distup, 
+							      Double_t lengthup, 
+							      Double_t widthup, 
+							      Double_t distlow, 
+							      Double_t lengthlow, 
+							      Double_t widthlow)
+{
+  
+  fDistUpperLimit = distup;
+  fLengthUpperLimit = lengthup;
+  fWidthUpperLimit = widthup;
+
+
+  fDistLowerLimit = distlow;
+  fLengthLowerLimit = lengthlow;
+  fWidthLowerLimit = widthlow;
+
+
+  *fLog << "MSupercutsCalcONOFF::SetHillasDistLengthWidthUpperLowerLimits" << endl
+	<< "Upper limits to Hillas parameters Dist, Length and Width " 
+	<< "are set respectively to : " 
+	<<  fDistUpperLimit << ", " 
+	<< fLengthUpperLimit << ", "
+	<< fWidthUpperLimit << " (in degrees!!)" << endl
+
+	<< "Lower limits to Hillas parameters Dist, Length and Width " 
+	<< "are set respectively to : " 
+	<<  fDistLowerLimit << ", " 
+	<< fLengthLowerLimit << ", "
+	<< fWidthLowerLimit << " (in degrees!!)" << endl
+
+	<< "The Hadronnes of those images exceeding one of these limits will " 
+	<< "be set to 0.75." << endl << endl;
+
+
+} 
+
+
+
+Int_t MSupercutsCalcONOFF::PreProcess(MParList *pList)
+{
+    MGeomCam *cam = (MGeomCam*)pList->FindObject("MGeomCam");
+    if (!cam)
+    {
+        *fLog << err << "MGeomCam (Camera Geometry) not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fMm2Deg = cam->GetConvMm2Deg();
+
+    fHadronness = (MHadronness*)pList->FindCreateObj("MHadronness", fHadronnessName);
+    if (!fHadronness)
+    {
+        *fLog << err << fHadronnessName << " [MHadronness] not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fSuper = (MSupercuts*)pList->FindObject(fSuperName, "MSupercuts");
+    if (!fSuper)
+    {
+        *fLog << err << fSuperName << " [MSupercuts] not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    if (fStoreAppliedSupercuts)
+    {
+	
+	fSupercutsApplied = (MTSupercutsApplied*)pList->FindObject(fSupercutsAppliedName,
+								  "MTSupercutsApplied");
+	if(!fSupercutsApplied)
+	{
+	    *fLog << err << fSupercutsAppliedName 
+		  << " [MTSupercutsApplied] not found... aborting." << endl;
+	    return kFALSE;
+	}
+	
+
+    }
+
+    if (fMatrix)
+        return kTRUE;
+
+    //-----------------------------------------------------------
+    fHil = (MHillas*)pList->FindObject(fHilName, "MHillas");
+    if (!fHil)
+    {
+        *fLog << err << fHilName << " [MHillas] not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fHilExt = (MHillasExt*)pList->FindObject(fHilExtName, "MHillasExt");
+    if (!fHilExt)
+    {
+        *fLog << err << fHilExtName << " [MHillasExt] not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fHilSrc = (MHillasSrc*)pList->FindObject(fHilSrcName, "MHillasSrc");
+    if (!fHilSrc)
+    {
+        *fLog << err << fHilSrcName << " [MHillasSrc] not found... aborting." << endl;
+        return kFALSE;
+    }
+
+    fNewPar = (MNewImagePar*)pList->FindObject(fNewParName, "MNewImagePar");
+    if (!fNewPar)
+    {
+        *fLog << err << fNewParName << " [MNewImagePar] not found... aborting." << endl;
+        return kFALSE;
+    }
+
+   fPointPos = (MPointingPos*)pList->FindCreateObj("MPointingPos");
+   if (!fPointPos)
+   {
+       *fLog << err << "MSupercutsCalcONOFF::PreProcess; MPointingPos not found... aborting." << endl;
+       return kFALSE;
+   }
+
+
+
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Calculation of upper and lower limits
+//
+Double_t MSupercutsCalcONOFF::CtsMCut(const Double_t* a,  Double_t ls, Double_t ct,
+                                    Double_t ls2, Double_t dd2) const
+{
+    // define cut-function
+    //
+    //   
+    //    dNOMCOSZA   = 1.0
+    //
+    //      a: array of cut parameters
+    //     ls: log(SIZE) - log(fSizeOffset)
+    //    ls2: ls^2
+    //     ct: Cos(ZA.) - Cos(fThetaOffset)
+    //    dd2: (DIST- fDistOffset)^2
+
+    Double_t limit;
+
+    if(fUseStaticCuts)
+    { // static cuts are used
+	limit = a[0];
+    }
+    else
+    {
+	if (fNotUseTheta)
+	{ // Theta info is NOT used in the computation of the dynamical cuts
+	  // For the time being dist info will not be used
+
+	  if(fUseDist)
+	    {
+
+	     
+	      limit = a[0] + a[1] * dd2 + 
+		      ls  * (a[3] + a[4] * dd2) + 
+		      ls2 * (a[6] + a[7] * dd2);
+	      
+
+	    }
+	  else
+	    {
+	      limit =  a[0] + ls  * (a[3])+   ls2 * (a[6]);
+	    }
+
+
+	}
+	else
+	{// Theta info IS used in the computation of the dynamical cuts
+	    
+	    limit =
+		a[0] + a[1] * dd2 + a[2] * ct  +
+		ls  * (a[3] + a[4] * dd2 + a[5] * ct) +
+		ls2 * (a[6] + a[7] * dd2);
+	}
+
+    }
+
+
+
+    //*fLog << "MSupercutsCalcONOFF::CtsMCut; *a = "
+    //      << *a     << ",  " << *(a+1) << ",  " << *(a+2) << ",  "
+    //      << *(a+3) << ",  " << *(a+4) << ",  " << *(a+5) << ",  "
+    //      << *(a+6) << ",  " << *(a+7) << endl;
+
+    //*fLog << "MSupercutsCalcONOFF::CtsMCut; ls, ls2, ct, dd2, limit = " << ls
+    //      << ",  " << ls2 << ",  " << ct << ",  " << dd2 << ",  "
+    //      << limit << endl;
+
+    return limit;
+}
+
+// --------------------------------------------------------------------------
+//
+// Returns the mapped value from the Matrix
+//
+Double_t MSupercutsCalcONOFF::GetVal(Int_t i) const
+{
+
+    Double_t val = (*fMatrix)[fMap[i]];
+
+
+    //*fLog << "MSupercutsCalcONOFF::GetVal; i, fMatrix, fMap, val = "
+    //    << i << ",  " << fMatrix << ",  " << fMap[i] << ",  " << val << endl;
+
+
+    return val;
+}
+
+// --------------------------------------------------------------------------
+//
+// You can use this function if you want to use a MHMatrix instead of the
+// given containers. This function adds all necessary columns to the
+// given matrix. Afterward you should fill the matrix with the corresponding
+// data (eg from a file by using MHMatrix::Fill). If you now loop
+// through the matrix (eg using MMatrixLoop) MEnergyEstParam::Process
+// will take the values from the matrix instead of the containers.
+//
+
+
+void MSupercutsCalcONOFF::InitMapping(MHMatrix *mat)
+{
+    if (fMatrix)
+      return;
+
+    fMatrix = mat;
+
+    fMap[0] = fMatrix->AddColumn("MPointingPos.fZd");  //deg
+    fMap[1] = fMatrix->AddColumn("MHillas.fWidth");
+    fMap[2] = fMatrix->AddColumn("MHillas.fLength");
+    fMap[3] = fMatrix->AddColumn("MHillas.fSize");
+    fMap[4] = fMatrix->AddColumn("MHillas.fMeanX");
+    fMap[5] = fMatrix->AddColumn("MHillas.fMeanY");
+    fMap[6] = fMatrix->AddColumn("MHillasSrc.fDist");
+    fMap[7] = fMatrix->AddColumn("fabs(MHillasSrc.fAlpha)");
+    fMap[8] = fMatrix->AddColumn("sgn(MHillasSrc.fCosDeltaAlpha)*(MHillasExt.fM3Long)");
+    fMap[9] = fMatrix->AddColumn("MNewImagePar.fConc");
+    fMap[10]= fMatrix->AddColumn("MNewImagePar.fLeakage1");
+}
+
+
+// ---------------------------------------------------------------------------
+//
+// Evaluate dynamical supercuts 
+// 
+//          set hadronness to 0.25 if cuts are fullfilled
+//                            0.75 otherwise
+//
+Int_t MSupercutsCalcONOFF::Process()
+{
+  //    const Double_t kNomLogSize = 4.1;
+    const Double_t kNomCosZA   = 1.0;
+
+    //const Double_t theta   = fMatrix ? GetVal(0) : fMcEvt->GetTelescopeTheta();
+    // For the time being I do it in a way that theta must be 
+    // the value used in the row 0 of fMatrix. That means that if there is 
+    // no matrix, the program will complain (and crash). And tehn I will know 
+    // that value 0 (supposed to be fThetaOrig.Val) could not be taken.
+    const Double_t theta   = GetVal(0);
+    const Double_t width0  = fMatrix ? GetVal(1) : fHil->GetWidth();
+    const Double_t length0 = fMatrix ? GetVal(2) : fHil->GetLength();
+    const Double_t size    = fMatrix ? GetVal(3) : fHil->GetSize();
+    const Double_t meanx   = fMatrix ? GetVal(4) : fHil->GetMeanX();
+    const Double_t meany   = fMatrix ? GetVal(5) : fHil->GetMeanY();
+    const Double_t dist0   = fMatrix ? GetVal(6) : fHilSrc->GetDist();
+
+    const Double_t alpha   = fMatrix ? GetVal(7) : fHilSrc->GetAlpha();
+
+    Double_t help;
+    if (!fMatrix)
+      help = TMath::Sign(fHilExt->GetM3Long(), 
+	      		 fHilSrc->GetCosDeltaAlpha());
+    const Double_t asym0   = fMatrix ? GetVal(8) : help;
+    const Double_t conc    = fMatrix ? GetVal(9) : fNewPar->GetConc();
+    const Double_t leakage = fMatrix ? GetVal(10): fNewPar->GetLeakage1();
+
+    const Double_t newdist = dist0 * fMm2Deg;
+
+    const Double_t dist2   = meanx*meanx + meany*meany;
+    const Double_t dist    = sqrt(dist2) * fMm2Deg;
+    
+    // const Double_t dd2     = dist*dist;
+
+
+    // in the parameterization of the cuts 
+    // the dist parameter used is the one computed from the source position, 
+    // and not the one computed from the camera center.
+
+    // Actually the value used in the parameterization is newdist^2, 
+    // minus the offset_in_dist^2
+    
+    const Double_t dd2     = newdist*newdist - fDistOffset*fDistOffset;
+
+
+    
+    const Double_t dmls    = log(size) - log(fSizeOffset);
+    const Double_t dmls2   = dmls * dmls;
+
+    const Double_t dmcza   = cos(theta) - kNomCosZA;
+
+    const Double_t length  = length0 * fMm2Deg;
+    const Double_t width   = width0  * fMm2Deg;
+    const Double_t asym    = asym0   * fMm2Deg;
+
+
+    
+    // computation of the cut limits
+
+    Double_t lengthup  = CtsMCut (fSuper->GetLengthUp(), dmls, dmcza, dmls2, dd2);    
+    Double_t lengthlow = CtsMCut (fSuper->GetLengthLo(), dmls, dmcza, dmls2, dd2);
+
+    Double_t widthup   = CtsMCut (fSuper->GetWidthUp(),  dmls, dmcza, dmls2, dd2);     
+    Double_t widthlow  =  CtsMCut (fSuper->GetWidthLo(),  dmls, dmcza, dmls2, dd2);
+
+    Double_t distup   =  CtsMCut (fSuper->GetDistUp(),   dmls, dmcza, dmls2, dd2);
+    Double_t distlow  =  CtsMCut (fSuper->GetDistLo(),   dmls, dmcza, dmls2, dd2);
+
+    Double_t asymup   = CtsMCut (fSuper->GetAsymUp(),   dmls, dmcza, dmls2, dd2);
+    Double_t asymlow  = CtsMCut (fSuper->GetAsymLo(),   dmls, dmcza, dmls2, dd2);
+
+    Double_t concup   = CtsMCut (fSuper->GetConcUp(),   dmls, dmcza, dmls2, dd2);
+    Double_t conclow  = CtsMCut (fSuper->GetConcLo(),   dmls, dmcza, dmls2, dd2);
+
+    Double_t  leakageup = CtsMCut (fSuper->GetLeakage1Up(),dmls, dmcza, dmls2, dd2);
+    Double_t  leakagelow = CtsMCut (fSuper->GetLeakage1Lo(),dmls, dmcza, dmls2, dd2); 
+
+    
+    Double_t lengthoverwidth = length/width;
+
+    Double_t hadronness = 0.0;
+
+
+    // If the cut values computed before for Dist, Length and Width exceed the upper limits set 
+    // by the user through function MSupercutsCalcONOFF::SetHillasDistLengthWidthUpperLowerLimits,
+    // (or the default values defined in constructor); such cut values are replaced by the 
+    // the limit values
+
+    
+
+    if (distup > fDistUpperLimit)
+      {
+	distup = fDistUpperLimit;
+      }
+
+   
+    if (lengthup > fLengthUpperLimit)
+      {
+	lengthup = fLengthUpperLimit;
+      }
+
+    if (widthup > fWidthUpperLimit)
+      {
+	widthup = fWidthUpperLimit;
+      }
+
+    
+
+    if (distlow < fDistLowerLimit)
+      {
+	distlow = fDistLowerLimit;
+      }
+                   
+    if (lengthlow < fLengthLowerLimit)
+      {
+	lengthlow = fLengthLowerLimit;
+      }
+
+    if (widthlow < fWidthLowerLimit)
+      {            
+	widthlow = fWidthLowerLimit;
+      }
+
+    
+    if (leakageup > fLeakage1UpperLimit)
+      {
+	leakageup = fLeakage1UpperLimit;
+      }
+    
+
+   
+
+
+    // Upper cut in leakage 1 also implemented
+
+    
+    
+   
+    if (// 
+	newdist > distup ||
+	newdist < distlow ||	    
+	length  > lengthup ||
+	length  < lengthlow ||	    
+	width   > widthup ||
+	width   < widthlow ||	    
+	leakage > leakageup ||
+	leakage < leakagelow ||
+	lengthoverwidth < fLengthOverWidthUpperLimit
+	//
+	//asym    < asymup &&
+	//asym    > asymlow &&
+	
+	//dist    < distup &&
+	//dist    > distlow &&
+	
+	//conc    < concup &&
+	//conc    > conclow &&	
+	//
+	) 
+	  
+      {hadronness = 0.75;}
+    else
+      {
+	hadronness = 0.25;
+      }
+      
+    
+    fHadronness->SetHadronness(hadronness);
+    fHadronness->SetReadyToSave();
+    
+    
+    if(fStoreAppliedSupercuts)
+    {
+
+	// TArrayD vector with the shower parameters (matching the ones 
+	// specified in function MTSupercutsApplied::CreateTreeBranches)
+	// is created and filled with this event features
+
+	// Eventually this definition might be done from outside this 
+	// class, allowing for adding removing parameters without 
+	// recompiling mars. yet for the time being, let's keep it simple.
+	
+	TArrayD ShowerParams(10);
+	ShowerParams[0] = length;
+	ShowerParams[1] = width;
+	ShowerParams[2] = dist;
+	ShowerParams[3] = newdist;
+	ShowerParams[4] = asym;
+	ShowerParams[5] = conc;
+	ShowerParams[6] = leakage;
+	ShowerParams[7] = theta;
+	ShowerParams[8] = size;
+	ShowerParams[9] = alpha;
+	
+	
+	// TArrayD vector with the cut parameters (matching the ones 
+	// specified in function MTSupercutsApplied::CreateTreeBranches)
+	// is created and filled with this event features
+
+	// Eventually this definition might be done from outside this 
+	// class, allowing for adding removing parameters without 
+	// recompiling mars. yet for the time being, let's keep it simple.
+	
+	
+	TArrayD SuperCutParams(13);
+	SuperCutParams[0] = lengthup;
+	SuperCutParams[1] = lengthlow;
+	SuperCutParams[2] = widthup;
+	SuperCutParams[3] = widthlow;
+	SuperCutParams[4] = distup;
+	SuperCutParams[5] = distlow;
+	SuperCutParams[6] = asymup;
+	SuperCutParams[7] = asymlow;
+	SuperCutParams[8] = concup;
+	SuperCutParams[9] = conclow;
+	SuperCutParams[10] = leakageup;
+	SuperCutParams[11] = leakagelow;
+	SuperCutParams[12] = hadronness;
+
+	// SC parameters applied to this event, as well as the 
+	// shower parameters, are stored in the branches of the
+	// TTree object of a MTSupercutsApplied object
+
+   
+	if (!fSupercutsApplied ->FillTreeBranches(SuperCutParams, ShowerParams))
+	{
+	    *fLog << "MSupercutsCalcONOFF::Process()" << endl
+		  << "Supercuts applied could not be stored in tree..."
+		  << endl;
+	    
+	    return kFALSE;
+	}
+	
+
+    }
+     
+
+
+    return kTRUE;
+
+
+    // OLD STUFF
+
+    /*
+    *fLog << "newdist, length, width, asym, dist, conc, leakage = " 
+          << newdist << ",  " << length << ",  " << width << ",  "
+          << asym    << ",  " << dist   << ",  " << conc  << ",  " << leakage
+          << endl;
+  
+    *fLog << "upper cuts in newdist, length, width, asym, dist, conc, leakage = " 
+          << CtsMCut (fSuper->GetDistUp(),   dmls, dmcza, dmls2, dd2) << ",  "
+          << CtsMCut (fSuper->GetDistLo(),   dmls, dmcza, dmls2, dd2) << ",  "
+
+          << CtsMCut (fSuper->GetLengthUp(),   dmls, dmcza, dmls2, dd2) << ",  "
+          << CtsMCut (fSuper->GetLengthLo(),   dmls, dmcza, dmls2, dd2) << ",  "
+
+          << CtsMCut (fSuper->GetWidthUp(),   dmls, dmcza, dmls2, dd2) << ",  "
+          << CtsMCut (fSuper->GetWidthLo(),   dmls, dmcza, dmls2, dd2) << ",  "
+
+          << CtsMCut (fSuper->GetAsymUp(),   dmls, dmcza, dmls2, dd2) << ",  "
+          << CtsMCut (fSuper->GetAsymLo(),   dmls, dmcza, dmls2, dd2) << ",  "
+
+          << CtsMCut (fSuper->GetDistUp(),   dmls, dmcza, dmls2, dd2) << ",  "
+          << CtsMCut (fSuper->GetDistLo(),   dmls, dmcza, dmls2, dd2) << ",  "
+
+          << CtsMCut (fSuper->GetConcUp(),   dmls, dmcza, dmls2, dd2) << ",  "
+          << CtsMCut (fSuper->GetConcLo(),   dmls, dmcza, dmls2, dd2) << ",  "
+
+          << CtsMCut (fSuper->GetLeakage1Up(),   dmls, dmcza, dmls2, dd2) << ",  "
+          << CtsMCut (fSuper->GetLeakage1Lo(),   dmls, dmcza, dmls2, dd2) << ",  "
+          << endl;
+    */
+
+    /*
+    if (
+        //dist    < 1.05                                                     &&
+        //newdist < 1.05                                                     &&
+
+        newdist < CtsMCut (fSuper->GetDistUp(),   dmls, dmcza, dmls2, dd2) &&
+        newdist > CtsMCut (fSuper->GetDistLo(),   dmls, dmcza, dmls2, dd2) &&
+
+        length  < CtsMCut (fSuper->GetLengthUp(), dmls, dmcza, dmls2, dd2) &&
+        length  > CtsMCut (fSuper->GetLengthLo(), dmls, dmcza, dmls2, dd2) &&
+
+        width   < CtsMCut (fSuper->GetWidthUp(),  dmls, dmcza, dmls2, dd2) &&
+        width   > CtsMCut (fSuper->GetWidthLo(),  dmls, dmcza, dmls2, dd2) &&
+
+        asym    < CtsMCut (fSuper->GetAsymUp(),   dmls, dmcza, dmls2, dd2) &&
+        asym    > CtsMCut (fSuper->GetAsymLo(),   dmls, dmcza, dmls2, dd2) &&
+
+        dist    < CtsMCut (fSuper->GetDistUp(),   dmls, dmcza, dmls2, dd2) &&
+        dist    > CtsMCut (fSuper->GetDistLo(),   dmls, dmcza, dmls2, dd2) &&
+
+        conc    < CtsMCut (fSuper->GetConcUp(),   dmls, dmcza, dmls2, dd2) &&
+        conc    > CtsMCut (fSuper->GetConcLo(),   dmls, dmcza, dmls2, dd2) &&
+
+        leakage < CtsMCut (fSuper->GetLeakage1Up(),dmls, dmcza, dmls2, dd2) &&
+        leakage > CtsMCut (fSuper->GetLeakage1Lo(),dmls, dmcza, dmls2, dd2)  ) 
+
+      fHadronness->SetHadronness(0.25);
+    else
+      fHadronness->SetHadronness(0.75);
+
+   
+
+    // *fLog << "SChadroness = " << fHadronness->GetHadronness() << endl;
+
+    fHadronness->SetReadyToSave();
+    */
+
+    // END OF OLD STUFF
+}
+
+/*
+Bool_t MSupercutsCalcONOFF::StoreSupercutsAppliedToThisEvent(TArrayD CutParams, 
+							   TArrayD ShowerParams)
+{
+    // SC parameters applied to this event are stored in 
+    // TTree object of MTSupercutsApplied object
+
+   
+    if (!fSupercutsApplied ->FillTreeBranches(CutParams, ShowerParams))
+    {
+	*fLog << "MSupercutsCalcONOFF::StoreSupercutsAppliedToThisEvent" << endl
+	      << "Supercuts applied could not be stored in tree..."
+	      << endl;
+
+	return kFALSE;
+    }
+
+    
+    return kTRUE;
+}
+
+*/
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/MSupercutsCalcONOFF.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/MSupercutsCalcONOFF.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/MSupercutsCalcONOFF.h	(revision 9661)
@@ -0,0 +1,173 @@
+#ifndef MARS_MSupercutsCalcONOFF
+#define MARS_MSupercutsCalcONOFF
+
+#ifndef MARS_MTask
+#include "MTask.h"
+#endif
+
+#ifndef ROOT_TArrayD
+#include <TArrayD.h>
+#endif
+
+class MParList;
+class MHillas;
+class MHillasSrc;
+class MHillasExt;
+class MNewImagePar;
+class MPointingPos;
+class MCerPhotEvt;
+class MGeomCam;
+class MHadronness;
+class MHMatrix;
+class MSupercuts;
+class MTSupercutsApplied;
+
+class MSupercutsCalcONOFF : public MTask
+{
+private:
+    MHillas       *fHil;
+    MHillasSrc    *fHilSrc;
+    MHillasExt    *fHilExt;
+    MNewImagePar  *fNewPar;
+    MPointingPos  *fPointPos;
+    MHadronness   *fHadronness; //! output container for hadronness
+    MTSupercutsApplied *fSupercutsApplied; // output container for applied supercuts
+    MSupercuts *fSuper;      // container for supercut parameters
+
+    TString  fHadronnessName;   // name of container to store hadronness
+    TString  fSupercutsAppliedName;        // name of the container to store applied supercuts
+    TString  fHilName;
+    TString  fHilSrcName;
+    TString  fHilExtName;
+    TString  fNewParName;
+    TString  fSuperName;        // name of container for supercut parameters
+
+    Double_t fMm2Deg;           //!
+
+    Int_t     fMap[11];         //!
+    MHMatrix *fMatrix;          //!
+
+    Bool_t fStoreAppliedSupercuts; // Boolean variable used to decided wether to store (kTRUE) or not (kFALSE) the supercuts applied
+
+
+    // Boolean variable used to control decide wether to use theta information 
+    // in the computation of teh dynamical cuts.
+    Bool_t fNotUseTheta;
+
+    // Boolean variable used to decide wether to use dynamical cuts or static cuts
+    // kTRUE means that static cuts are used
+    Bool_t fUseStaticCuts;
+
+
+    // Boolean variable that allows to use/not use the dist info in the cuts parameterization
+    // kTRUE for use it.
+    // For the time being this variable is set in the constructor
+
+    Bool_t fUseDist;
+
+
+
+     // OFFSETS FOR THE DYNAMICAL CUTS
+    // Values of Size (photons), Dist (degrees) and Theta (degrees) 
+    // for which the value of the dynamical cut is equal to the 
+    // non dependent parameter; i.e. to the static cut. 
+    // By adjusting these offsets the user can set the value in size, 
+    // dist and theta for which the dynamical cuts will be given by 
+    // the term that DOES not depend on size, dist and theta.
+
+    // For the time being, these quantities are set in the constructor. 
+    // In future, if they show to be useful, I will make them available 
+    // as external variables.
+
+    Double_t fSizeOffset; // photons
+    Double_t fDistOffset; // degrees   NOT USED FOR THE TIME BEING
+    Double_t fThetaOffset; // degrees   NOT USED FOR THE TIME BEING
+
+
+
+
+    // Variables defining upper/lower limits for some of the hillas params
+    // Variables in degrees !!
+
+    Double_t fDistUpperLimit;
+    Double_t fLengthUpperLimit;
+    Double_t fWidthUpperLimit;
+
+     Double_t fDistLowerLimit;
+    Double_t fLengthLowerLimit;
+    Double_t fWidthLowerLimit;
+
+    // tmp
+
+    Double_t fLeakage1UpperLimit;
+
+    Double_t fLengthOverWidthUpperLimit;
+    
+    //endtemp
+
+    Int_t PreProcess(MParList *pList);
+    Int_t Process();
+
+    Double_t GetVal(Int_t i) const;
+
+    Double_t CtsMCut(const Double_t* a, Double_t ls, Double_t ct,
+                     Double_t ls2, Double_t dd2) const;
+    /*
+    Bool_t StoreSupercutsAppliedToThisEvent(Double_t lengthup, Double_t lengthlow, 
+					    Double_t widthup, Double_t widthlow, 
+					    Double_t distup, Double_t distlow);
+    */     
+public:
+    MSupercutsCalcONOFF(const char *hilname="MHillas",
+                      const char *hilsrcname="MHillasSrc",
+                      const char *name=NULL, const char *title=NULL);
+
+    void SetHadronnessName(const TString name) { fHadronnessName = name; }
+    TString GetHadronnessName() const { return fHadronnessName; }
+
+    void SetSupercutsAppliedName(const TString name) { fSupercutsAppliedName = name; }
+    TString GetSupercutsAppliedName() const { return fSupercutsAppliedName; }
+
+
+    void SetStoreAppliedSupercuts(Bool_t b);
+    Bool_t GetStoreAppliedSupercuts() {return fStoreAppliedSupercuts;}
+
+
+    void SetVariableNotUseTheta(Bool_t b);
+    Bool_t GetVariableNotUseTheta() { return fNotUseTheta;}
+
+    void SetVariableUseStaticCuts(Bool_t b);
+    Bool_t GetVariableUseStaticCuts() { return fUseStaticCuts;}
+
+
+    
+    void SetHillasDistLengthWidthUpperLowerLimits(Double_t distup, 
+						  Double_t lengthup, 
+						  Double_t widthup, 
+						  Double_t distlow, 
+						  Double_t lengthlow, 
+						  Double_t widthlow);
+
+    void InitMapping(MHMatrix *mat); // use quantity ThetaOrig.fVal at theta
+    
+    void StopMapping() { InitMapping(NULL); }
+
+    
+
+
+    ClassDef(MSupercutsCalcONOFF, 0) // A class to evaluate the Supercuts
+};
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/MTSupercutsApplied.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/MTSupercutsApplied.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/MTSupercutsApplied.cc	(revision 9661)
@@ -0,0 +1,281 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): David Paneque 02/2004 <mailto:dpaneque@mppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MTSupercutsApplied
+//
+// Class derived from TObject and containing a TTree object 
+// used to store the values of the Supercuts applied 
+// to each single event. The supercuts are dynamic, which means that 
+// the cuts depend on the characterics (size, theta, distance) of the 
+// individual events. 
+// For the time being, only Length, Width and Dist are used, yet in 
+// the future more parameters will be added (conc, asym...)
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MTSupercutsApplied.h"
+
+#include <TObject.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MTSupercutsApplied);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MTSupercutsApplied::MTSupercutsApplied(const char* name, const char* title)
+{
+    fName  = name  ? name  : "MTSupercutsApplied";
+    fTitle = title ? title : "Storage container for the dynamical supercuts";
+
+
+    // TTree object is initialized with same name and titles as parent object
+    
+    fRootTree = new TTree (name, title);
+
+    fBranchesCreated = kFALSE;
+
+}
+
+// --------------------------------------------------------------------------
+//   DESTRUCTOR deletes dynamic memory allocated for TTree and vectors
+
+MTSupercutsApplied::~MTSupercutsApplied()
+{
+
+    // If I release the dynamic memory ocupied by this guys a segmentation 
+    // fault is produced. I guess this is due to the fact that tryis to 
+    // remove something which has been writtenn into a root file... 
+    // not sure...
+
+    // Anyhow, this occupies very little memory... it will not load 
+    // too much the system.
+
+    //delete fCutParameters;
+    //delete fShowerParamBranchName;
+    //delete fRootTree;
+    
+
+}
+
+
+
+
+// Function that creates the branches of the TTree object
+
+Bool_t MTSupercutsApplied::CreateTreeBranches()
+{
+
+    // Names of the branches is fixed for the time being
+    
+    fCutParamBranchName = ("SupercutsApplied");
+    fShowerParamBranchName = ("ShowerParameters");
+
+   
+    // Number of parameters for the 2 branches is set in cosntructor. 
+    // In later versions I might do it in such a way that can be set 
+    // by user
+
+    fNCutParameters = 13;
+    fNShowerParameters = 10;
+
+    
+    const Int_t dimscparam = fNCutParameters;
+    const Int_t dimshowerparam = fNShowerParameters;
+
+    fCutParameters = new Double_t [dimscparam];
+    fShowerParameters = new Double_t [dimshowerparam];
+    
+
+
+    // Cut parameters names and types for branch CutParameters
+    // will be stored in a member data TString fCutParametersNamesTypes
+    // Eventually might be set from outside the class
+
+    TString StringVector[dimscparam];
+    StringVector[0] = ("LengthUp/D");
+    StringVector[1] = ("LengthLow/D");
+    StringVector[2] = ("WidthUp/D");
+    StringVector[3] = ("WidthLow/D");
+    StringVector[4] = ("DistUp/D");
+    StringVector[5] = ("DistLow/D");
+    StringVector[6] = ("AsymUp/D");
+    StringVector[7] = ("AsymLow/D");
+    StringVector[8] = ("ConcUp/D");
+    StringVector[9] = ("ConcLow/D");
+    StringVector[10] = ("LeakageUp/D");
+    StringVector[11] = ("LeakageLow/D");
+    StringVector[12] = ("Hadronness/D");
+
+    fCutParametersNamesTypes = StringVector[0];
+    for (Int_t i = 1; i < dimscparam; i++)
+    {
+	fCutParametersNamesTypes += (":");
+	fCutParametersNamesTypes += StringVector[i];
+    }
+	
+
+    // Cut parameters names and types for branch CutParameters
+    // will be stored in a member data TString fShowerParametersNamesTypes
+    // Eventually might be set from outside the class
+	
+    TString StringVector2[dimshowerparam];
+
+    StringVector2[0] = ("Length/D");
+    StringVector2[1] = ("Width/D");
+    StringVector2[2] = ("Dist/D");
+    StringVector2[3] = ("NewDist/D");
+    StringVector2[4] = ("Asym/D");
+    StringVector2[5] = ("Conc/D");
+    StringVector2[6] = ("Leakage/D");
+    StringVector2[7] = ("Theta/D");
+    StringVector2[8] = ("Size/D");
+    StringVector2[9] = ("Alpha/D");
+
+
+ 
+    fShowerParametersNamesTypes = StringVector2[0];
+    for (Int_t i = 1; i < dimshowerparam; i++)
+    {
+	fShowerParametersNamesTypes += (":");
+	fShowerParametersNamesTypes += StringVector2[i];
+    }
+
+
+    *fLog << "MTSupercutsApplied::CreateTreeBranches()" << endl
+	  << "Branches created are the following ones (BranchName; Parameters)" << endl
+	  << fCutParamBranchName << " ; " << fCutParametersNamesTypes << endl
+	  << fShowerParamBranchName << " ; " << fShowerParametersNamesTypes << endl;
+
+    
+    // Branches are finally created
+
+    fRootTree -> Branch(fCutParamBranchName.Data(),
+			fCutParameters, fCutParametersNamesTypes.Data());
+
+    fRootTree -> Branch(fShowerParamBranchName.Data(),
+			fShowerParameters, fShowerParametersNamesTypes.Data());
+
+    fBranchesCreated = kTRUE;
+
+
+    /*
+
+    fRootTree -> Branch("LengthUp", &fLengthUp, "LengthUp/D");
+    fRootTree -> Branch("LengthLow", &fLengthLow, "LengthLow/D");
+    fRootTree -> Branch("WidthUp", &fWidthUp, "WidthUp/D");
+    fRootTree -> Branch("Widthlow", &fWidthLow, "WidthLow/D");
+    fRootTree -> Branch("DistUp", &fDistUp, "DistUp/D");
+    fRootTree -> Branch("DistLow", &fDistLow, "DistLow/D");
+
+    */
+
+
+    *fLog << "MTSupercutsApplied::CreateTreeBranches();" << endl
+	  << "Branches created successfully in TTree object" << endl;
+
+    return kTRUE;
+    
+}
+
+Bool_t MTSupercutsApplied::FillTreeBranches(const TArrayD cutparameters, 
+					    const TArrayD showerparameters)
+{
+
+    // Check that branches have been created 
+    if(!fBranchesCreated)
+    {
+	*fLog << "MTSupercutsApplied::FillTreeBranches" << endl
+	      << "Branches for the Tree object have not been created yet..." 
+	      << "Therefore Tree can not be filled" << endl;
+	
+	return kFALSE;
+
+    }
+
+    // Check that dimensions of the argument vectors match with the
+    // dimension of the vectors whose addresses are given to the branches
+
+    if (fNCutParameters != cutparameters.GetSize()
+	|| fNShowerParameters != showerparameters.GetSize())
+    {
+	*fLog << "MTSupercutsApplied::FillTreeBranches" << endl
+	      << "Dimension of arrays used in the argument of this function " 
+	      << "do not match with the dimension of the arrays used in the branches"
+	      << endl;
+
+	return kFALSE;
+    }
+
+    // Parameters are transferred to the member data vectors 
+
+    for (Int_t i = 0; i < fNCutParameters; i++)
+    {
+	fCutParameters[i] = double (cutparameters[i]);
+    }
+
+    for (Int_t i = 0; i < fNShowerParameters; i++)
+    {
+	fShowerParameters[i] = double (showerparameters[i]);
+    }
+
+
+    // Branches are finally filled
+
+    fRootTree -> Fill();
+    
+    return kTRUE;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/MTSupercutsApplied.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/MTSupercutsApplied.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/MTSupercutsApplied.h	(revision 9661)
@@ -0,0 +1,98 @@
+#ifndef MARS_MTSupercutsApplied
+#define MARS_MTSupercutsApplied
+//////////////////////////////////////////////////////////////////////////
+//                                                                      //
+// MTSupercutsApplied                                                      //
+//                                                                      //
+// Class containing TTree object used to store 
+// supercuts applied to all individual events                               //
+//                                                                      //
+//////////////////////////////////////////////////////////////////////////
+#ifndef MARS_MAGIC
+#include "MAGIC.h"
+#endif
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+
+#ifndef ROOT_TObject
+#include <TObject.h>
+#endif
+#ifndef ROOT_TString
+#include <TString.h>
+#endif
+#ifndef ROOT_TArrayD
+#include <TArrayD.h>
+#endif
+#ifndef ROOT_TTree
+#include <TTree.h>
+#endif
+
+class MTSupercutsApplied : public MParContainer
+{
+private:
+    
+    Int_t fNCutParameters;
+    Int_t fNShowerParameters;
+
+    Double_t* fCutParameters;
+    Double_t* fShowerParameters;
+/*
+    Double_t fLengthUp;
+    Double_t fLengthLow;
+    Double_t fWidthUp;
+    Double_t fWidthLow;
+    Double_t fDistUp;
+    Double_t fDistLow;    
+*/
+    TTree* fRootTree;
+
+    Bool_t fBranchesCreated;
+
+    TString fCutParamBranchName;
+    TString fShowerParamBranchName;
+
+    TString fCutParametersNamesTypes;
+    TString fShowerParametersNamesTypes;
+
+public:
+    MTSupercutsApplied(const char* name=NULL, const char* title=NULL);
+    ~MTSupercutsApplied();
+
+    /*
+    Double_t GetLengthUp() const { return fLengthUp; }
+    Double_t GetLengthLow() const { return fLengthLow; }
+    Double_t GetWidthUp() const { return fWidthUp; }
+    Double_t GetWidthLow() const { return fWidthLow; }
+    Double_t GetDistUp() const { return fDistUp; }
+    Double_t GetDistLow() const { return fDistLow; }
+
+
+    void     SetLengthUp(Double_t x) { fLengthUp = x; }
+    void     SetLengthLow(Double_t x) { fLengthLow = x; }
+    void     SetWidthUp(Double_t x) { fWidthUp = x; }
+    void     SetWidthLow(Double_t x) { fWidthLow = x; }
+    void     SetDistUp(Double_t x) { fDistUp = x; }
+    void     SetDistLow(Double_t x) { fDistLow = x; }
+    */
+     
+    Bool_t CreateTreeBranches();
+
+    Bool_t FillTreeBranches(TArrayD CutParamVector, 
+			    TArrayD ShowerParamVector);
+    	
+    TTree* GetTreePointer() {return fRootTree;}
+    
+
+    ClassDef(MTSupercutsApplied, 1) // Storage Container for the supercuts applied
+};
+
+#endif
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/Makefile
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/Makefile	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/Makefile	(revision 9661)
@@ -0,0 +1,57 @@
+##################################################################
+#
+#   subdirectory makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../../../Makefile.conf.$(OSTYPE)
+include ../../../Makefile.conf.general
+
+#------------------------------------------------------------------------------
+
+CINT     = SuperCutsONOFF
+LIB      = SuperCutsONOFF.a
+
+#------------------------------------------------------------------------------
+
+INCLUDES = -I. \
+	   -I../../../mbase \
+	   -I../../../mfbase \
+	   -I../../../mjobs \
+	   -I../../../mpedestal \
+	   -I../../../mbadpixels \
+	   -I../../../mfileio \
+           -I../../../mraw \
+           -I../../../manalysis \
+	   -I../../../mgui \
+	   -I../../../mgeom \
+	   -I../../../msignal \
+	   -I../../../mcalib \
+	   -I../../../mfilter \
+	   -I../../../mhbase \
+	   -I../../../mimage \
+	   -I../../../mpointing \
+	   -I../../../mcamera \
+	   -I../../../mhist \
+	   -I../../../mmc \
+	   -I../../../mreport \
+	   -I../../../mastro \
+	   -I../../../mdata 
+
+SRCFILES = \
+	MFRandomSplit.cc \
+	MSupercutsCalcONOFF.cc \
+	MHFindSignificanceONOFF.cc \
+	MTSupercutsApplied.cc \
+	MFindSupercutsONOFF.cc \
+        MFindSupercutsONOFFThetaLoop.cc 
+
+############################################################
+
+all: $(OBJS)
+
+include ../../../Makefile.rules
+
+clean:	rmcint rmobjs rmcore rmlib
+mrproper:	clean rmbak
Index: /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/SuperCutsONOFFCint.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/SuperCutsONOFFCint.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/SuperCutsONOFFCint.cc	(revision 9661)
@@ -0,0 +1,4707 @@
+//
+// File generated by /cernroot/3_05_07/root/bin/rootcint at Tue Jul 20 11:55:55 2004.
+// Do NOT change. Changes will be lost next time file is generated
+//
+
+#include "RConfig.h"
+#if !defined(R__ACCESS_IN_SYMBOL)
+//Break the privacy of classes -- Disabled for the moment
+#define private public
+#define protected public
+#endif
+
+#include "SuperCutsONOFFCint.h"
+#include "TClass.h"
+#include "TBuffer.h"
+#include "TMemberInspector.h"
+#include "TError.h"
+
+#ifndef G__ROOT
+#define G__ROOT
+#endif
+
+// Since CINT ignores the std namespace, we need to do so in this file.
+namespace std {} using namespace std;
+
+#include "RtypesImp.h"
+
+namespace ROOT {
+   namespace Shadow {
+   } // Of namespace ROOT::Shadow
+} // Of namespace ROOT
+
+namespace ROOT {
+   void MFRandomSplit_ShowMembers(void *obj, TMemberInspector &R__insp, char *R__parent);
+   TClass *MFRandomSplit_IsA(const void*);
+   void delete_MFRandomSplit(void *p);
+   void deleteArray_MFRandomSplit(void *p);
+   void destruct_MFRandomSplit(void *p);
+
+   // Function generating the singleton type initializer
+   TGenericClassInfo *GenerateInitInstance(const MFRandomSplit*)
+   {
+      MFRandomSplit *ptr = 0;
+      static ROOT::TGenericClassInfo 
+         instance("MFRandomSplit", MFRandomSplit::Class_Version(), "MFRandomSplit.h", 16,
+                  typeid(MFRandomSplit), DefineBehavior(ptr, ptr),
+                  &::MFRandomSplit::Dictionary, &MFRandomSplit_IsA, 4);
+      instance.SetDelete(&delete_MFRandomSplit);
+      instance.SetDeleteArray(&deleteArray_MFRandomSplit);
+      instance.SetDestructor(&destruct_MFRandomSplit);
+      return &instance;
+   }
+   // Static variable to force the class initialization
+   static ROOT::TGenericClassInfo *_R__UNIQUE_(Init) = GenerateInitInstance((const MFRandomSplit*)0x0); R__UseDummy(_R__UNIQUE_(Init));
+}
+
+namespace ROOT {
+   void MTSupercutsApplied_ShowMembers(void *obj, TMemberInspector &R__insp, char *R__parent);
+   TClass *MTSupercutsApplied_IsA(const void*);
+   void *new_MTSupercutsApplied(void *p = 0);
+   void *newArray_MTSupercutsApplied(Long_t size);
+   void delete_MTSupercutsApplied(void *p);
+   void deleteArray_MTSupercutsApplied(void *p);
+   void destruct_MTSupercutsApplied(void *p);
+
+   // Function generating the singleton type initializer
+   TGenericClassInfo *GenerateInitInstance(const MTSupercutsApplied*)
+   {
+      MTSupercutsApplied *ptr = 0;
+      static ROOT::TGenericClassInfo 
+         instance("MTSupercutsApplied", MTSupercutsApplied::Class_Version(), "MTSupercutsApplied.h", 34,
+                  typeid(MTSupercutsApplied), DefineBehavior(ptr, ptr),
+                  &::MTSupercutsApplied::Dictionary, &MTSupercutsApplied_IsA, 4);
+      instance.SetNew(&new_MTSupercutsApplied);
+      instance.SetNewArray(&newArray_MTSupercutsApplied);
+      instance.SetDelete(&delete_MTSupercutsApplied);
+      instance.SetDeleteArray(&deleteArray_MTSupercutsApplied);
+      instance.SetDestructor(&destruct_MTSupercutsApplied);
+      return &instance;
+   }
+   // Static variable to force the class initialization
+   static ROOT::TGenericClassInfo *_R__UNIQUE_(Init) = GenerateInitInstance((const MTSupercutsApplied*)0x0); R__UseDummy(_R__UNIQUE_(Init));
+}
+
+namespace ROOT {
+   void MSupercutsCalcONOFF_ShowMembers(void *obj, TMemberInspector &R__insp, char *R__parent);
+   TClass *MSupercutsCalcONOFF_IsA(const void*);
+   void *new_MSupercutsCalcONOFF(void *p = 0);
+   void *newArray_MSupercutsCalcONOFF(Long_t size);
+   void delete_MSupercutsCalcONOFF(void *p);
+   void deleteArray_MSupercutsCalcONOFF(void *p);
+   void destruct_MSupercutsCalcONOFF(void *p);
+
+   // Function generating the singleton type initializer
+   TGenericClassInfo *GenerateInitInstance(const MSupercutsCalcONOFF*)
+   {
+      MSupercutsCalcONOFF *ptr = 0;
+      static ROOT::TGenericClassInfo 
+         instance("MSupercutsCalcONOFF", MSupercutsCalcONOFF::Class_Version(), "MSupercutsCalcONOFF.h", 26,
+                  typeid(MSupercutsCalcONOFF), DefineBehavior(ptr, ptr),
+                  &::MSupercutsCalcONOFF::Dictionary, &MSupercutsCalcONOFF_IsA, 4);
+      instance.SetNew(&new_MSupercutsCalcONOFF);
+      instance.SetNewArray(&newArray_MSupercutsCalcONOFF);
+      instance.SetDelete(&delete_MSupercutsCalcONOFF);
+      instance.SetDeleteArray(&deleteArray_MSupercutsCalcONOFF);
+      instance.SetDestructor(&destruct_MSupercutsCalcONOFF);
+      return &instance;
+   }
+   // Static variable to force the class initialization
+   static ROOT::TGenericClassInfo *_R__UNIQUE_(Init) = GenerateInitInstance((const MSupercutsCalcONOFF*)0x0); R__UseDummy(_R__UNIQUE_(Init));
+}
+
+namespace ROOT {
+   void MHFindSignificanceONOFF_ShowMembers(void *obj, TMemberInspector &R__insp, char *R__parent);
+   TClass *MHFindSignificanceONOFF_IsA(const void*);
+   void *new_MHFindSignificanceONOFF(void *p = 0);
+   void *newArray_MHFindSignificanceONOFF(Long_t size);
+   void delete_MHFindSignificanceONOFF(void *p);
+   void deleteArray_MHFindSignificanceONOFF(void *p);
+   void destruct_MHFindSignificanceONOFF(void *p);
+
+   // Function generating the singleton type initializer
+   TGenericClassInfo *GenerateInitInstance(const MHFindSignificanceONOFF*)
+   {
+      MHFindSignificanceONOFF *ptr = 0;
+      static ROOT::TGenericClassInfo 
+         instance("MHFindSignificanceONOFF", MHFindSignificanceONOFF::Class_Version(), "MHFindSignificanceONOFF.h", 22,
+                  typeid(MHFindSignificanceONOFF), DefineBehavior(ptr, ptr),
+                  &::MHFindSignificanceONOFF::Dictionary, &MHFindSignificanceONOFF_IsA, 4);
+      instance.SetNew(&new_MHFindSignificanceONOFF);
+      instance.SetNewArray(&newArray_MHFindSignificanceONOFF);
+      instance.SetDelete(&delete_MHFindSignificanceONOFF);
+      instance.SetDeleteArray(&deleteArray_MHFindSignificanceONOFF);
+      instance.SetDestructor(&destruct_MHFindSignificanceONOFF);
+      return &instance;
+   }
+   // Static variable to force the class initialization
+   static ROOT::TGenericClassInfo *_R__UNIQUE_(Init) = GenerateInitInstance((const MHFindSignificanceONOFF*)0x0); R__UseDummy(_R__UNIQUE_(Init));
+}
+
+namespace ROOT {
+   void MFindSupercutsONOFF_ShowMembers(void *obj, TMemberInspector &R__insp, char *R__parent);
+   TClass *MFindSupercutsONOFF_IsA(const void*);
+   void *new_MFindSupercutsONOFF(void *p = 0);
+   void *newArray_MFindSupercutsONOFF(Long_t size);
+   void delete_MFindSupercutsONOFF(void *p);
+   void deleteArray_MFindSupercutsONOFF(void *p);
+   void destruct_MFindSupercutsONOFF(void *p);
+
+   // Function generating the singleton type initializer
+   TGenericClassInfo *GenerateInitInstance(const MFindSupercutsONOFF*)
+   {
+      MFindSupercutsONOFF *ptr = 0;
+      static ROOT::TGenericClassInfo 
+         instance("MFindSupercutsONOFF", MFindSupercutsONOFF::Class_Version(), "MFindSupercutsONOFF.h", 34,
+                  typeid(MFindSupercutsONOFF), DefineBehavior(ptr, ptr),
+                  &::MFindSupercutsONOFF::Dictionary, &MFindSupercutsONOFF_IsA, 4);
+      instance.SetNew(&new_MFindSupercutsONOFF);
+      instance.SetNewArray(&newArray_MFindSupercutsONOFF);
+      instance.SetDelete(&delete_MFindSupercutsONOFF);
+      instance.SetDeleteArray(&deleteArray_MFindSupercutsONOFF);
+      instance.SetDestructor(&destruct_MFindSupercutsONOFF);
+      return &instance;
+   }
+   // Static variable to force the class initialization
+   static ROOT::TGenericClassInfo *_R__UNIQUE_(Init) = GenerateInitInstance((const MFindSupercutsONOFF*)0x0); R__UseDummy(_R__UNIQUE_(Init));
+}
+
+namespace ROOT {
+   void MFindSupercutsONOFFThetaLoop_ShowMembers(void *obj, TMemberInspector &R__insp, char *R__parent);
+   TClass *MFindSupercutsONOFFThetaLoop_IsA(const void*);
+   void *new_MFindSupercutsONOFFThetaLoop(void *p = 0);
+   void *newArray_MFindSupercutsONOFFThetaLoop(Long_t size);
+   void delete_MFindSupercutsONOFFThetaLoop(void *p);
+   void deleteArray_MFindSupercutsONOFFThetaLoop(void *p);
+   void destruct_MFindSupercutsONOFFThetaLoop(void *p);
+
+   // Function generating the singleton type initializer
+   TGenericClassInfo *GenerateInitInstance(const MFindSupercutsONOFFThetaLoop*)
+   {
+      MFindSupercutsONOFFThetaLoop *ptr = 0;
+      static ROOT::TGenericClassInfo 
+         instance("MFindSupercutsONOFFThetaLoop", MFindSupercutsONOFFThetaLoop::Class_Version(), "MFindSupercutsONOFFThetaLoop.h", 34,
+                  typeid(MFindSupercutsONOFFThetaLoop), DefineBehavior(ptr, ptr),
+                  &::MFindSupercutsONOFFThetaLoop::Dictionary, &MFindSupercutsONOFFThetaLoop_IsA, 4);
+      instance.SetNew(&new_MFindSupercutsONOFFThetaLoop);
+      instance.SetNewArray(&newArray_MFindSupercutsONOFFThetaLoop);
+      instance.SetDelete(&delete_MFindSupercutsONOFFThetaLoop);
+      instance.SetDeleteArray(&deleteArray_MFindSupercutsONOFFThetaLoop);
+      instance.SetDestructor(&destruct_MFindSupercutsONOFFThetaLoop);
+      return &instance;
+   }
+   // Static variable to force the class initialization
+   static ROOT::TGenericClassInfo *_R__UNIQUE_(Init) = GenerateInitInstance((const MFindSupercutsONOFFThetaLoop*)0x0); R__UseDummy(_R__UNIQUE_(Init));
+}
+
+//______________________________________________________________________________
+TClass *MFRandomSplit::fgIsA = 0;  // static to hold class pointer
+
+//______________________________________________________________________________
+const char *MFRandomSplit::Class_Name()
+{
+   return "MFRandomSplit";
+}
+
+//______________________________________________________________________________
+const char *MFRandomSplit::ImplFileName()
+{
+   return ROOT::GenerateInitInstance((const MFRandomSplit*)0x0)->GetImplFileName();
+}
+
+//______________________________________________________________________________
+int MFRandomSplit::ImplFileLine()
+{
+   return ROOT::GenerateInitInstance((const MFRandomSplit*)0x0)->GetImplFileLine();
+}
+
+//______________________________________________________________________________
+void MFRandomSplit::Dictionary()
+{
+   fgIsA = ROOT::GenerateInitInstance((const MFRandomSplit*)0x0)->GetClass();
+}
+
+//______________________________________________________________________________
+TClass *MFRandomSplit::Class()
+{
+   if (!fgIsA) fgIsA = ROOT::GenerateInitInstance((const MFRandomSplit*)0x0)->GetClass();
+   return fgIsA;
+}
+
+//______________________________________________________________________________
+TClass *MTSupercutsApplied::fgIsA = 0;  // static to hold class pointer
+
+//______________________________________________________________________________
+const char *MTSupercutsApplied::Class_Name()
+{
+   return "MTSupercutsApplied";
+}
+
+//______________________________________________________________________________
+const char *MTSupercutsApplied::ImplFileName()
+{
+   return ROOT::GenerateInitInstance((const MTSupercutsApplied*)0x0)->GetImplFileName();
+}
+
+//______________________________________________________________________________
+int MTSupercutsApplied::ImplFileLine()
+{
+   return ROOT::GenerateInitInstance((const MTSupercutsApplied*)0x0)->GetImplFileLine();
+}
+
+//______________________________________________________________________________
+void MTSupercutsApplied::Dictionary()
+{
+   fgIsA = ROOT::GenerateInitInstance((const MTSupercutsApplied*)0x0)->GetClass();
+}
+
+//______________________________________________________________________________
+TClass *MTSupercutsApplied::Class()
+{
+   if (!fgIsA) fgIsA = ROOT::GenerateInitInstance((const MTSupercutsApplied*)0x0)->GetClass();
+   return fgIsA;
+}
+
+//______________________________________________________________________________
+TClass *MSupercutsCalcONOFF::fgIsA = 0;  // static to hold class pointer
+
+//______________________________________________________________________________
+const char *MSupercutsCalcONOFF::Class_Name()
+{
+   return "MSupercutsCalcONOFF";
+}
+
+//______________________________________________________________________________
+const char *MSupercutsCalcONOFF::ImplFileName()
+{
+   return ROOT::GenerateInitInstance((const MSupercutsCalcONOFF*)0x0)->GetImplFileName();
+}
+
+//______________________________________________________________________________
+int MSupercutsCalcONOFF::ImplFileLine()
+{
+   return ROOT::GenerateInitInstance((const MSupercutsCalcONOFF*)0x0)->GetImplFileLine();
+}
+
+//______________________________________________________________________________
+void MSupercutsCalcONOFF::Dictionary()
+{
+   fgIsA = ROOT::GenerateInitInstance((const MSupercutsCalcONOFF*)0x0)->GetClass();
+}
+
+//______________________________________________________________________________
+TClass *MSupercutsCalcONOFF::Class()
+{
+   if (!fgIsA) fgIsA = ROOT::GenerateInitInstance((const MSupercutsCalcONOFF*)0x0)->GetClass();
+   return fgIsA;
+}
+
+//______________________________________________________________________________
+TClass *MHFindSignificanceONOFF::fgIsA = 0;  // static to hold class pointer
+
+//______________________________________________________________________________
+const char *MHFindSignificanceONOFF::Class_Name()
+{
+   return "MHFindSignificanceONOFF";
+}
+
+//______________________________________________________________________________
+const char *MHFindSignificanceONOFF::ImplFileName()
+{
+   return ROOT::GenerateInitInstance((const MHFindSignificanceONOFF*)0x0)->GetImplFileName();
+}
+
+//______________________________________________________________________________
+int MHFindSignificanceONOFF::ImplFileLine()
+{
+   return ROOT::GenerateInitInstance((const MHFindSignificanceONOFF*)0x0)->GetImplFileLine();
+}
+
+//______________________________________________________________________________
+void MHFindSignificanceONOFF::Dictionary()
+{
+   fgIsA = ROOT::GenerateInitInstance((const MHFindSignificanceONOFF*)0x0)->GetClass();
+}
+
+//______________________________________________________________________________
+TClass *MHFindSignificanceONOFF::Class()
+{
+   if (!fgIsA) fgIsA = ROOT::GenerateInitInstance((const MHFindSignificanceONOFF*)0x0)->GetClass();
+   return fgIsA;
+}
+
+//______________________________________________________________________________
+TClass *MFindSupercutsONOFF::fgIsA = 0;  // static to hold class pointer
+
+//______________________________________________________________________________
+const char *MFindSupercutsONOFF::Class_Name()
+{
+   return "MFindSupercutsONOFF";
+}
+
+//______________________________________________________________________________
+const char *MFindSupercutsONOFF::ImplFileName()
+{
+   return ROOT::GenerateInitInstance((const MFindSupercutsONOFF*)0x0)->GetImplFileName();
+}
+
+//______________________________________________________________________________
+int MFindSupercutsONOFF::ImplFileLine()
+{
+   return ROOT::GenerateInitInstance((const MFindSupercutsONOFF*)0x0)->GetImplFileLine();
+}
+
+//______________________________________________________________________________
+void MFindSupercutsONOFF::Dictionary()
+{
+   fgIsA = ROOT::GenerateInitInstance((const MFindSupercutsONOFF*)0x0)->GetClass();
+}
+
+//______________________________________________________________________________
+TClass *MFindSupercutsONOFF::Class()
+{
+   if (!fgIsA) fgIsA = ROOT::GenerateInitInstance((const MFindSupercutsONOFF*)0x0)->GetClass();
+   return fgIsA;
+}
+
+//______________________________________________________________________________
+TClass *MFindSupercutsONOFFThetaLoop::fgIsA = 0;  // static to hold class pointer
+
+//______________________________________________________________________________
+const char *MFindSupercutsONOFFThetaLoop::Class_Name()
+{
+   return "MFindSupercutsONOFFThetaLoop";
+}
+
+//______________________________________________________________________________
+const char *MFindSupercutsONOFFThetaLoop::ImplFileName()
+{
+   return ROOT::GenerateInitInstance((const MFindSupercutsONOFFThetaLoop*)0x0)->GetImplFileName();
+}
+
+//______________________________________________________________________________
+int MFindSupercutsONOFFThetaLoop::ImplFileLine()
+{
+   return ROOT::GenerateInitInstance((const MFindSupercutsONOFFThetaLoop*)0x0)->GetImplFileLine();
+}
+
+//______________________________________________________________________________
+void MFindSupercutsONOFFThetaLoop::Dictionary()
+{
+   fgIsA = ROOT::GenerateInitInstance((const MFindSupercutsONOFFThetaLoop*)0x0)->GetClass();
+}
+
+//______________________________________________________________________________
+TClass *MFindSupercutsONOFFThetaLoop::Class()
+{
+   if (!fgIsA) fgIsA = ROOT::GenerateInitInstance((const MFindSupercutsONOFFThetaLoop*)0x0)->GetClass();
+   return fgIsA;
+}
+
+//______________________________________________________________________________
+void MFRandomSplit::Streamer(TBuffer &R__b)
+{
+   // Stream an object of class MFRandomSplit.
+
+   if (R__b.IsReading()) {
+      MFRandomSplit::Class()->ReadBuffer(R__b, this);
+   } else {
+      MFRandomSplit::Class()->WriteBuffer(R__b, this);
+   }
+}
+
+//______________________________________________________________________________
+void MFRandomSplit::ShowMembers(TMemberInspector &R__insp, char *R__parent)
+{
+      // Inspect the data members of an object of class MFRandomSplit.
+
+      TClass *R__cl = MFRandomSplit::IsA();
+      Int_t R__ncp = strlen(R__parent);
+      if (R__ncp || R__cl || R__insp.IsA()) { }
+      R__insp.Inspect(R__cl, R__parent, "fNumSelectedEvts", &fNumSelectedEvts);
+      R__insp.Inspect(R__cl, R__parent, "fProb", &fProb);
+      R__insp.Inspect(R__cl, R__parent, "fResult", &fResult);
+      MFilter::ShowMembers(R__insp, R__parent);
+}
+
+namespace ROOT {
+   // Return the actual TClass for the object argument
+   TClass *MFRandomSplit_IsA(const void *obj) {
+      return ((::MFRandomSplit*)obj)->IsA();
+   }
+   // Wrapper around operator delete
+   void delete_MFRandomSplit(void *p) {
+      delete ((::MFRandomSplit*)p);
+   }
+   void deleteArray_MFRandomSplit(void *p) {
+      delete [] ((::MFRandomSplit*)p);
+   }
+   void destruct_MFRandomSplit(void *p) {
+      typedef ::MFRandomSplit current_t;
+      ((current_t*)p)->~current_t();
+   }
+} // end of namespace ROOT for class MFRandomSplit
+
+//______________________________________________________________________________
+void MSupercutsCalcONOFF::Streamer(TBuffer &R__b)
+{
+   // Stream an object of class MSupercutsCalcONOFF.
+
+   if (R__b.IsReading()) {
+      MSupercutsCalcONOFF::Class()->ReadBuffer(R__b, this);
+   } else {
+      MSupercutsCalcONOFF::Class()->WriteBuffer(R__b, this);
+   }
+}
+
+//______________________________________________________________________________
+void MSupercutsCalcONOFF::ShowMembers(TMemberInspector &R__insp, char *R__parent)
+{
+      // Inspect the data members of an object of class MSupercutsCalcONOFF.
+
+      TClass *R__cl = MSupercutsCalcONOFF::IsA();
+      Int_t R__ncp = strlen(R__parent);
+      if (R__ncp || R__cl || R__insp.IsA()) { }
+      R__insp.Inspect(R__cl, R__parent, "*fHil", &fHil);
+      R__insp.Inspect(R__cl, R__parent, "*fHilSrc", &fHilSrc);
+      R__insp.Inspect(R__cl, R__parent, "*fHilExt", &fHilExt);
+      R__insp.Inspect(R__cl, R__parent, "*fNewPar", &fNewPar);
+      R__insp.Inspect(R__cl, R__parent, "*fPointPos", &fPointPos);
+      R__insp.Inspect(R__cl, R__parent, "*fHadronness", &fHadronness);
+      R__insp.Inspect(R__cl, R__parent, "*fSupercutsApplied", &fSupercutsApplied);
+      R__insp.Inspect(R__cl, R__parent, "*fSuper", &fSuper);
+      R__insp.Inspect(R__cl, R__parent, "fHadronnessName", &fHadronnessName);
+      fHadronnessName.ShowMembers(R__insp, strcat(R__parent,"fHadronnessName.")); R__parent[R__ncp] = 0;
+      R__insp.Inspect(R__cl, R__parent, "fSupercutsAppliedName", &fSupercutsAppliedName);
+      fSupercutsAppliedName.ShowMembers(R__insp, strcat(R__parent,"fSupercutsAppliedName.")); R__parent[R__ncp] = 0;
+      R__insp.Inspect(R__cl, R__parent, "fHilName", &fHilName);
+      fHilName.ShowMembers(R__insp, strcat(R__parent,"fHilName.")); R__parent[R__ncp] = 0;
+      R__insp.Inspect(R__cl, R__parent, "fHilSrcName", &fHilSrcName);
+      fHilSrcName.ShowMembers(R__insp, strcat(R__parent,"fHilSrcName.")); R__parent[R__ncp] = 0;
+      R__insp.Inspect(R__cl, R__parent, "fHilExtName", &fHilExtName);
+      fHilExtName.ShowMembers(R__insp, strcat(R__parent,"fHilExtName.")); R__parent[R__ncp] = 0;
+      R__insp.Inspect(R__cl, R__parent, "fNewParName", &fNewParName);
+      fNewParName.ShowMembers(R__insp, strcat(R__parent,"fNewParName.")); R__parent[R__ncp] = 0;
+      R__insp.Inspect(R__cl, R__parent, "fSuperName", &fSuperName);
+      fSuperName.ShowMembers(R__insp, strcat(R__parent,"fSuperName.")); R__parent[R__ncp] = 0;
+      R__insp.Inspect(R__cl, R__parent, "fMm2Deg", &fMm2Deg);
+      R__insp.Inspect(R__cl, R__parent, "fMap[11]", fMap);
+      R__insp.Inspect(R__cl, R__parent, "*fMatrix", &fMatrix);
+      R__insp.Inspect(R__cl, R__parent, "fStoreAppliedSupercuts", &fStoreAppliedSupercuts);
+      R__insp.Inspect(R__cl, R__parent, "fNotUseTheta", &fNotUseTheta);
+      R__insp.Inspect(R__cl, R__parent, "fUseStaticCuts", &fUseStaticCuts);
+      R__insp.Inspect(R__cl, R__parent, "fUseDist", &fUseDist);
+      R__insp.Inspect(R__cl, R__parent, "fSizeOffset", &fSizeOffset);
+      R__insp.Inspect(R__cl, R__parent, "fDistOffset", &fDistOffset);
+      R__insp.Inspect(R__cl, R__parent, "fThetaOffset", &fThetaOffset);
+      R__insp.Inspect(R__cl, R__parent, "fDistUpperLimit", &fDistUpperLimit);
+      R__insp.Inspect(R__cl, R__parent, "fLengthUpperLimit", &fLengthUpperLimit);
+      R__insp.Inspect(R__cl, R__parent, "fWidthUpperLimit", &fWidthUpperLimit);
+      R__insp.Inspect(R__cl, R__parent, "fDistLowerLimit", &fDistLowerLimit);
+      R__insp.Inspect(R__cl, R__parent, "fLengthLowerLimit", &fLengthLowerLimit);
+      R__insp.Inspect(R__cl, R__parent, "fWidthLowerLimit", &fWidthLowerLimit);
+      R__insp.Inspect(R__cl, R__parent, "fLeakage1UpperLimit", &fLeakage1UpperLimit);
+      R__insp.Inspect(R__cl, R__parent, "fLengthOverWidthUpperLimit", &fLengthOverWidthUpperLimit);
+      MTask::ShowMembers(R__insp, R__parent);
+}
+
+namespace ROOT {
+   // Return the actual TClass for the object argument
+   TClass *MSupercutsCalcONOFF_IsA(const void *obj) {
+      return ((::MSupercutsCalcONOFF*)obj)->IsA();
+   }
+   // Wrappers around operator new
+   void *new_MSupercutsCalcONOFF(void *p) {
+      return  p ? new(p) ::MSupercutsCalcONOFF : new ::MSupercutsCalcONOFF;
+   }
+   void *newArray_MSupercutsCalcONOFF(Long_t size) {
+      return new ::MSupercutsCalcONOFF[size];
+   }
+   // Wrapper around operator delete
+   void delete_MSupercutsCalcONOFF(void *p) {
+      delete ((::MSupercutsCalcONOFF*)p);
+   }
+   void deleteArray_MSupercutsCalcONOFF(void *p) {
+      delete [] ((::MSupercutsCalcONOFF*)p);
+   }
+   void destruct_MSupercutsCalcONOFF(void *p) {
+      typedef ::MSupercutsCalcONOFF current_t;
+      ((current_t*)p)->~current_t();
+   }
+} // end of namespace ROOT for class MSupercutsCalcONOFF
+
+//______________________________________________________________________________
+void R__MHFindSignificanceONOFF_fHistOrig(TBuffer &R__b, void *R__p, int)
+{
+   TH1** fHistOrig = (TH1**)R__p;
+   if (R__b.IsReading()) {
+      R__b >> *fHistOrig;
+   } else {
+      R__b << (TObject*)*fHistOrig;
+   }
+}
+
+//______________________________________________________________________________
+void R__MHFindSignificanceONOFF_fHist(TBuffer &R__b, void *R__p, int)
+{
+   TH1** fHist = (TH1**)R__p;
+   if (R__b.IsReading()) {
+      R__b >> *fHist;
+   } else {
+      R__b << (TObject*)*fHist;
+   }
+}
+
+//______________________________________________________________________________
+void R__MHFindSignificanceONOFF_fHistOrigOFF(TBuffer &R__b, void *R__p, int)
+{
+   TH1** fHistOrigOFF = (TH1**)R__p;
+   if (R__b.IsReading()) {
+      R__b >> *fHistOrigOFF;
+   } else {
+      R__b << (TObject*)*fHistOrigOFF;
+   }
+}
+
+//______________________________________________________________________________
+void R__MHFindSignificanceONOFF_fHistOFF(TBuffer &R__b, void *R__p, int)
+{
+   TH1** fHistOFF = (TH1**)R__p;
+   if (R__b.IsReading()) {
+      R__b >> *fHistOFF;
+   } else {
+      R__b << (TObject*)*fHistOFF;
+   }
+}
+
+//______________________________________________________________________________
+void R__MHFindSignificanceONOFF_fHistOFFNormalized(TBuffer &R__b, void *R__p, int)
+{
+   TH1** fHistOFFNormalized = (TH1**)R__p;
+   if (R__b.IsReading()) {
+      R__b >> *fHistOFFNormalized;
+   } else {
+      R__b << (TObject*)*fHistOFFNormalized;
+   }
+}
+
+//______________________________________________________________________________
+void R__MHFindSignificanceONOFF_fPsFilenameString(TBuffer &R__b, void *R__p, int)
+{
+   TString &fPsFilenameString = *(TString *)R__p;
+   if (R__b.IsReading()) {
+      fPsFilenameString.Streamer(R__b);
+   } else {
+      fPsFilenameString.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void R__MHFindSignificanceONOFF_fValues(TBuffer &R__b, void *R__p, int)
+{
+   TArrayD &fValues = *(TArrayD *)R__p;
+   if (R__b.IsReading()) {
+      fValues.Streamer(R__b);
+   } else {
+      fValues.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void R__MHFindSignificanceONOFF_fErrors(TBuffer &R__b, void *R__p, int)
+{
+   TArrayD &fErrors = *(TArrayD *)R__p;
+   if (R__b.IsReading()) {
+      fErrors.Streamer(R__b);
+   } else {
+      fErrors.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void R__MHFindSignificanceONOFF_fValuesOFF(TBuffer &R__b, void *R__p, int)
+{
+   TArrayD &fValuesOFF = *(TArrayD *)R__p;
+   if (R__b.IsReading()) {
+      fValuesOFF.Streamer(R__b);
+   } else {
+      fValuesOFF.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void R__MHFindSignificanceONOFF_fErrorsOFF(TBuffer &R__b, void *R__p, int)
+{
+   TArrayD &fErrorsOFF = *(TArrayD *)R__p;
+   if (R__b.IsReading()) {
+      fErrorsOFF.Streamer(R__b);
+   } else {
+      fErrorsOFF.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void R__MHFindSignificanceONOFF_fValuesOFFNormalized(TBuffer &R__b, void *R__p, int)
+{
+   TArrayD &fValuesOFFNormalized = *(TArrayD *)R__p;
+   if (R__b.IsReading()) {
+      fValuesOFFNormalized.Streamer(R__b);
+   } else {
+      fValuesOFFNormalized.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void R__MHFindSignificanceONOFF_fErrorsOFFNormalized(TBuffer &R__b, void *R__p, int)
+{
+   TArrayD &fErrorsOFFNormalized = *(TArrayD *)R__p;
+   if (R__b.IsReading()) {
+      fErrorsOFFNormalized.Streamer(R__b);
+   } else {
+      fErrorsOFFNormalized.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void R__MHFindSignificanceONOFF_fGValues(TBuffer &R__b, void *R__p, int)
+{
+   TArrayD &fGValues = *(TArrayD *)R__p;
+   if (R__b.IsReading()) {
+      fGValues.Streamer(R__b);
+   } else {
+      fGValues.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void R__MHFindSignificanceONOFF_fGErrors(TBuffer &R__b, void *R__p, int)
+{
+   TArrayD &fGErrors = *(TArrayD *)R__p;
+   if (R__b.IsReading()) {
+      fGErrors.Streamer(R__b);
+   } else {
+      fGErrors.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void MHFindSignificanceONOFF::Streamer(TBuffer &R__b)
+{
+   // Stream an object of class MHFindSignificanceONOFF.
+
+   if (R__b.IsReading()) {
+      MHFindSignificanceONOFF::Class()->ReadBuffer(R__b, this);
+   } else {
+      MHFindSignificanceONOFF::Class()->WriteBuffer(R__b, this);
+   }
+}
+
+//______________________________________________________________________________
+void MHFindSignificanceONOFF::ShowMembers(TMemberInspector &R__insp, char *R__parent)
+{
+      // Inspect the data members of an object of class MHFindSignificanceONOFF.
+
+      TClass *R__cl = MHFindSignificanceONOFF::IsA();
+      Int_t R__ncp = strlen(R__parent);
+      if (R__ncp || R__cl || R__insp.IsA()) { }
+      R__insp.Inspect(R__cl, R__parent, "*fHistOrig", &fHistOrig);
+      R__cl->SetStreamer("*fHistOrig",R__MHFindSignificanceONOFF_fHistOrig);
+      R__insp.Inspect(R__cl, R__parent, "*fHist", &fHist);
+      R__cl->SetStreamer("*fHist",R__MHFindSignificanceONOFF_fHist);
+      R__insp.Inspect(R__cl, R__parent, "*fHistOrigOFF", &fHistOrigOFF);
+      R__cl->SetStreamer("*fHistOrigOFF",R__MHFindSignificanceONOFF_fHistOrigOFF);
+      R__insp.Inspect(R__cl, R__parent, "*fHistOFF", &fHistOFF);
+      R__cl->SetStreamer("*fHistOFF",R__MHFindSignificanceONOFF_fHistOFF);
+      R__insp.Inspect(R__cl, R__parent, "*fHistOFFNormalized", &fHistOFFNormalized);
+      R__cl->SetStreamer("*fHistOFFNormalized",R__MHFindSignificanceONOFF_fHistOFFNormalized);
+      R__insp.Inspect(R__cl, R__parent, "*fPsFilename", &fPsFilename);
+      R__insp.Inspect(R__cl, R__parent, "fPsFilenameString", &fPsFilenameString);
+      fPsFilenameString.ShowMembers(R__insp, strcat(R__parent,"fPsFilenameString.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fPsFilenameString",R__MHFindSignificanceONOFF_fPsFilenameString);
+      R__insp.Inspect(R__cl, R__parent, "fAlphamin", &fAlphamin);
+      R__insp.Inspect(R__cl, R__parent, "fAlphammm", &fAlphammm);
+      R__insp.Inspect(R__cl, R__parent, "fAlphamax", &fAlphamax);
+      R__insp.Inspect(R__cl, R__parent, "fAlphaminOFF", &fAlphaminOFF);
+      R__insp.Inspect(R__cl, R__parent, "fAlphamaxOFF", &fAlphamaxOFF);
+      R__insp.Inspect(R__cl, R__parent, "fAlphami", &fAlphami);
+      R__insp.Inspect(R__cl, R__parent, "fAlphamm", &fAlphamm);
+      R__insp.Inspect(R__cl, R__parent, "fAlphama", &fAlphama);
+      R__insp.Inspect(R__cl, R__parent, "fAlphasig", &fAlphasig);
+      R__insp.Inspect(R__cl, R__parent, "fAlphasi", &fAlphasi);
+      R__insp.Inspect(R__cl, R__parent, "fAlphasiOFF", &fAlphasiOFF);
+      R__insp.Inspect(R__cl, R__parent, "fAlphalow", &fAlphalow);
+      R__insp.Inspect(R__cl, R__parent, "fAlphalo", &fAlphalo);
+      R__insp.Inspect(R__cl, R__parent, "fAlphahig", &fAlphahig);
+      R__insp.Inspect(R__cl, R__parent, "fAlphahi", &fAlphahi);
+      R__insp.Inspect(R__cl, R__parent, "fNon", &fNon);
+      R__insp.Inspect(R__cl, R__parent, "fNbg", &fNbg);
+      R__insp.Inspect(R__cl, R__parent, "fNex", &fNex);
+      R__insp.Inspect(R__cl, R__parent, "fdNon", &fdNon);
+      R__insp.Inspect(R__cl, R__parent, "fdNbg", &fdNbg);
+      R__insp.Inspect(R__cl, R__parent, "fdNex", &fdNex);
+      R__insp.Inspect(R__cl, R__parent, "fNbgtot", &fNbgtot);
+      R__insp.Inspect(R__cl, R__parent, "fNbgtotFitted", &fNbgtotFitted);
+      R__insp.Inspect(R__cl, R__parent, "fdNbgtotFitted", &fdNbgtotFitted);
+      R__insp.Inspect(R__cl, R__parent, "fNexONOFF", &fNexONOFF);
+      R__insp.Inspect(R__cl, R__parent, "fNexONOFFFitted", &fNexONOFFFitted);
+      R__insp.Inspect(R__cl, R__parent, "fdNexONOFF", &fdNexONOFF);
+      R__insp.Inspect(R__cl, R__parent, "fdNexONOFFFitted", &fdNexONOFFFitted);
+      R__insp.Inspect(R__cl, R__parent, "fNoffTot", &fNoffTot);
+      R__insp.Inspect(R__cl, R__parent, "fNoffSig", &fNoffSig);
+      R__insp.Inspect(R__cl, R__parent, "fNoffBg", &fNoffBg);
+      R__insp.Inspect(R__cl, R__parent, "fdNoffTot", &fdNoffTot);
+      R__insp.Inspect(R__cl, R__parent, "fdNoffSig", &fdNoffSig);
+      R__insp.Inspect(R__cl, R__parent, "fdNoffBg", &fdNoffBg);
+      R__insp.Inspect(R__cl, R__parent, "fNoffTotFitted", &fNoffTotFitted);
+      R__insp.Inspect(R__cl, R__parent, "fNoffSigFitted", &fNoffSigFitted);
+      R__insp.Inspect(R__cl, R__parent, "fNoffBgFitted", &fNoffBgFitted);
+      R__insp.Inspect(R__cl, R__parent, "fdNoffTotFitted", &fdNoffTotFitted);
+      R__insp.Inspect(R__cl, R__parent, "fdNoffSigFitted", &fdNoffSigFitted);
+      R__insp.Inspect(R__cl, R__parent, "fdNoffBgFitted", &fdNoffBgFitted);
+      R__insp.Inspect(R__cl, R__parent, "fUseFittedQuantities", &fUseFittedQuantities);
+      R__insp.Inspect(R__cl, R__parent, "fPrintResultsOntoAlphaPlot", &fPrintResultsOntoAlphaPlot);
+      R__insp.Inspect(R__cl, R__parent, "fNoff", &fNoff);
+      R__insp.Inspect(R__cl, R__parent, "fGamma", &fGamma);
+      R__insp.Inspect(R__cl, R__parent, "fNormFactor", &fNormFactor);
+      R__insp.Inspect(R__cl, R__parent, "fSigLiMa", &fSigLiMa);
+      R__insp.Inspect(R__cl, R__parent, "fSigLiMa2", &fSigLiMa2);
+      R__insp.Inspect(R__cl, R__parent, "fSigLiMa3", &fSigLiMa3);
+      R__insp.Inspect(R__cl, R__parent, "fDraw", &fDraw);
+      R__insp.Inspect(R__cl, R__parent, "fSavePlots", &fSavePlots);
+      R__insp.Inspect(R__cl, R__parent, "fFitGauss", &fFitGauss);
+      R__insp.Inspect(R__cl, R__parent, "fRebin", &fRebin);
+      R__insp.Inspect(R__cl, R__parent, "fReduceDegree", &fReduceDegree);
+      R__insp.Inspect(R__cl, R__parent, "fConstantBackg", &fConstantBackg);
+      R__insp.Inspect(R__cl, R__parent, "*fCanvas", &fCanvas);
+      R__insp.Inspect(R__cl, R__parent, "fNexGauss", &fNexGauss);
+      R__insp.Inspect(R__cl, R__parent, "fdNexGauss", &fdNexGauss);
+      R__insp.Inspect(R__cl, R__parent, "fSigmaGauss", &fSigmaGauss);
+      R__insp.Inspect(R__cl, R__parent, "fdSigmaGauss", &fdSigmaGauss);
+      R__insp.Inspect(R__cl, R__parent, "*fPoly", &fPoly);
+      R__insp.Inspect(R__cl, R__parent, "fFitBad", &fFitBad);
+      R__insp.Inspect(R__cl, R__parent, "fDegree", &fDegree);
+      R__insp.Inspect(R__cl, R__parent, "fNdf", &fNdf);
+      R__insp.Inspect(R__cl, R__parent, "fChisq", &fChisq);
+      R__insp.Inspect(R__cl, R__parent, "fProb", &fProb);
+      R__insp.Inspect(R__cl, R__parent, "fValues", &fValues);
+      fValues.ShowMembers(R__insp, strcat(R__parent,"fValues.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fValues",R__MHFindSignificanceONOFF_fValues);
+      R__insp.Inspect(R__cl, R__parent, "fErrors", &fErrors);
+      fErrors.ShowMembers(R__insp, strcat(R__parent,"fErrors.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fErrors",R__MHFindSignificanceONOFF_fErrors);
+      R__insp.Inspect(R__cl, R__parent, "fEmat[6][6]", fEmat);
+      R__insp.Inspect(R__cl, R__parent, "fEma[6][6]", fEma);
+      R__insp.Inspect(R__cl, R__parent, "fCorr[6][6]", fCorr);
+      R__insp.Inspect(R__cl, R__parent, "fMbins", &fMbins);
+      R__insp.Inspect(R__cl, R__parent, "fMlow", &fMlow);
+      R__insp.Inspect(R__cl, R__parent, "fNzero", &fNzero);
+      R__insp.Inspect(R__cl, R__parent, "fIstat", &fIstat);
+      R__insp.Inspect(R__cl, R__parent, "*fPolyOFF", &fPolyOFF);
+      R__insp.Inspect(R__cl, R__parent, "*fPolyOFFNormalized", &fPolyOFFNormalized);
+      R__insp.Inspect(R__cl, R__parent, "fFitBadOFF", &fFitBadOFF);
+      R__insp.Inspect(R__cl, R__parent, "fDegreeOFF", &fDegreeOFF);
+      R__insp.Inspect(R__cl, R__parent, "fNdfOFF", &fNdfOFF);
+      R__insp.Inspect(R__cl, R__parent, "fChisqOFF", &fChisqOFF);
+      R__insp.Inspect(R__cl, R__parent, "fProbOFF", &fProbOFF);
+      R__insp.Inspect(R__cl, R__parent, "fValuesOFF", &fValuesOFF);
+      fValuesOFF.ShowMembers(R__insp, strcat(R__parent,"fValuesOFF.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fValuesOFF",R__MHFindSignificanceONOFF_fValuesOFF);
+      R__insp.Inspect(R__cl, R__parent, "fErrorsOFF", &fErrorsOFF);
+      fErrorsOFF.ShowMembers(R__insp, strcat(R__parent,"fErrorsOFF.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fErrorsOFF",R__MHFindSignificanceONOFF_fErrorsOFF);
+      R__insp.Inspect(R__cl, R__parent, "fValuesOFFNormalized", &fValuesOFFNormalized);
+      fValuesOFFNormalized.ShowMembers(R__insp, strcat(R__parent,"fValuesOFFNormalized.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fValuesOFFNormalized",R__MHFindSignificanceONOFF_fValuesOFFNormalized);
+      R__insp.Inspect(R__cl, R__parent, "fErrorsOFFNormalized", &fErrorsOFFNormalized);
+      fErrorsOFFNormalized.ShowMembers(R__insp, strcat(R__parent,"fErrorsOFFNormalized.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fErrorsOFFNormalized",R__MHFindSignificanceONOFF_fErrorsOFFNormalized);
+      R__insp.Inspect(R__cl, R__parent, "fEmatOFF[6][6]", fEmatOFF);
+      R__insp.Inspect(R__cl, R__parent, "fEmaOFF[6][6]", fEmaOFF);
+      R__insp.Inspect(R__cl, R__parent, "fCorrOFF[6][6]", fCorrOFF);
+      R__insp.Inspect(R__cl, R__parent, "fMbinsOFF", &fMbinsOFF);
+      R__insp.Inspect(R__cl, R__parent, "fMlowOFF", &fMlowOFF);
+      R__insp.Inspect(R__cl, R__parent, "fNzeroOFF", &fNzeroOFF);
+      R__insp.Inspect(R__cl, R__parent, "fIstatOFF", &fIstatOFF);
+      R__insp.Inspect(R__cl, R__parent, "*fGPoly", &fGPoly);
+      R__insp.Inspect(R__cl, R__parent, "*fGBackg", &fGBackg);
+      R__insp.Inspect(R__cl, R__parent, "fGFitBad", &fGFitBad);
+      R__insp.Inspect(R__cl, R__parent, "fGDegree", &fGDegree);
+      R__insp.Inspect(R__cl, R__parent, "fGNdf", &fGNdf);
+      R__insp.Inspect(R__cl, R__parent, "fGChisq", &fGChisq);
+      R__insp.Inspect(R__cl, R__parent, "fGProb", &fGProb);
+      R__insp.Inspect(R__cl, R__parent, "fGValues", &fGValues);
+      fGValues.ShowMembers(R__insp, strcat(R__parent,"fGValues.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fGValues",R__MHFindSignificanceONOFF_fGValues);
+      R__insp.Inspect(R__cl, R__parent, "fGErrors", &fGErrors);
+      fGErrors.ShowMembers(R__insp, strcat(R__parent,"fGErrors.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fGErrors",R__MHFindSignificanceONOFF_fGErrors);
+      R__insp.Inspect(R__cl, R__parent, "fGEmat[9][9]", fGEmat);
+      R__insp.Inspect(R__cl, R__parent, "fGEma[9][9]", fGEma);
+      R__insp.Inspect(R__cl, R__parent, "fGCorr[9][9]", fGCorr);
+      R__insp.Inspect(R__cl, R__parent, "fGMbins", &fGMbins);
+      R__insp.Inspect(R__cl, R__parent, "fGNzero", &fGNzero);
+      R__insp.Inspect(R__cl, R__parent, "fGIstat", &fGIstat);
+      MH::ShowMembers(R__insp, R__parent);
+}
+
+namespace ROOT {
+   // Return the actual TClass for the object argument
+   TClass *MHFindSignificanceONOFF_IsA(const void *obj) {
+      return ((::MHFindSignificanceONOFF*)obj)->IsA();
+   }
+   // Wrappers around operator new
+   void *new_MHFindSignificanceONOFF(void *p) {
+      return  p ? new(p) ::MHFindSignificanceONOFF : new ::MHFindSignificanceONOFF;
+   }
+   void *newArray_MHFindSignificanceONOFF(Long_t size) {
+      return new ::MHFindSignificanceONOFF[size];
+   }
+   // Wrapper around operator delete
+   void delete_MHFindSignificanceONOFF(void *p) {
+      delete ((::MHFindSignificanceONOFF*)p);
+   }
+   void deleteArray_MHFindSignificanceONOFF(void *p) {
+      delete [] ((::MHFindSignificanceONOFF*)p);
+   }
+   void destruct_MHFindSignificanceONOFF(void *p) {
+      typedef ::MHFindSignificanceONOFF current_t;
+      ((current_t*)p)->~current_t();
+   }
+} // end of namespace ROOT for class MHFindSignificanceONOFF
+
+//______________________________________________________________________________
+void R__MTSupercutsApplied_fRootTree(TBuffer &R__b, void *R__p, int)
+{
+   TTree** fRootTree = (TTree**)R__p;
+   if (R__b.IsReading()) {
+      R__b >> *fRootTree;
+   } else {
+      R__b << (TObject*)*fRootTree;
+   }
+}
+
+//______________________________________________________________________________
+void R__MTSupercutsApplied_fCutParamBranchName(TBuffer &R__b, void *R__p, int)
+{
+   TString &fCutParamBranchName = *(TString *)R__p;
+   if (R__b.IsReading()) {
+      fCutParamBranchName.Streamer(R__b);
+   } else {
+      fCutParamBranchName.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void R__MTSupercutsApplied_fShowerParamBranchName(TBuffer &R__b, void *R__p, int)
+{
+   TString &fShowerParamBranchName = *(TString *)R__p;
+   if (R__b.IsReading()) {
+      fShowerParamBranchName.Streamer(R__b);
+   } else {
+      fShowerParamBranchName.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void R__MTSupercutsApplied_fCutParametersNamesTypes(TBuffer &R__b, void *R__p, int)
+{
+   TString &fCutParametersNamesTypes = *(TString *)R__p;
+   if (R__b.IsReading()) {
+      fCutParametersNamesTypes.Streamer(R__b);
+   } else {
+      fCutParametersNamesTypes.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void R__MTSupercutsApplied_fShowerParametersNamesTypes(TBuffer &R__b, void *R__p, int)
+{
+   TString &fShowerParametersNamesTypes = *(TString *)R__p;
+   if (R__b.IsReading()) {
+      fShowerParametersNamesTypes.Streamer(R__b);
+   } else {
+      fShowerParametersNamesTypes.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void MTSupercutsApplied::Streamer(TBuffer &R__b)
+{
+   // Stream an object of class MTSupercutsApplied.
+
+   if (R__b.IsReading()) {
+      MTSupercutsApplied::Class()->ReadBuffer(R__b, this);
+   } else {
+      MTSupercutsApplied::Class()->WriteBuffer(R__b, this);
+   }
+}
+
+//______________________________________________________________________________
+void MTSupercutsApplied::ShowMembers(TMemberInspector &R__insp, char *R__parent)
+{
+      // Inspect the data members of an object of class MTSupercutsApplied.
+
+      TClass *R__cl = MTSupercutsApplied::IsA();
+      Int_t R__ncp = strlen(R__parent);
+      if (R__ncp || R__cl || R__insp.IsA()) { }
+      R__insp.Inspect(R__cl, R__parent, "fNCutParameters", &fNCutParameters);
+      R__insp.Inspect(R__cl, R__parent, "fNShowerParameters", &fNShowerParameters);
+      R__insp.Inspect(R__cl, R__parent, "*fCutParameters", &fCutParameters);
+      R__insp.Inspect(R__cl, R__parent, "*fShowerParameters", &fShowerParameters);
+      R__insp.Inspect(R__cl, R__parent, "*fRootTree", &fRootTree);
+      R__cl->SetStreamer("*fRootTree",R__MTSupercutsApplied_fRootTree);
+      R__insp.Inspect(R__cl, R__parent, "fBranchesCreated", &fBranchesCreated);
+      R__insp.Inspect(R__cl, R__parent, "fCutParamBranchName", &fCutParamBranchName);
+      fCutParamBranchName.ShowMembers(R__insp, strcat(R__parent,"fCutParamBranchName.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fCutParamBranchName",R__MTSupercutsApplied_fCutParamBranchName);
+      R__insp.Inspect(R__cl, R__parent, "fShowerParamBranchName", &fShowerParamBranchName);
+      fShowerParamBranchName.ShowMembers(R__insp, strcat(R__parent,"fShowerParamBranchName.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fShowerParamBranchName",R__MTSupercutsApplied_fShowerParamBranchName);
+      R__insp.Inspect(R__cl, R__parent, "fCutParametersNamesTypes", &fCutParametersNamesTypes);
+      fCutParametersNamesTypes.ShowMembers(R__insp, strcat(R__parent,"fCutParametersNamesTypes.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fCutParametersNamesTypes",R__MTSupercutsApplied_fCutParametersNamesTypes);
+      R__insp.Inspect(R__cl, R__parent, "fShowerParametersNamesTypes", &fShowerParametersNamesTypes);
+      fShowerParametersNamesTypes.ShowMembers(R__insp, strcat(R__parent,"fShowerParametersNamesTypes.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fShowerParametersNamesTypes",R__MTSupercutsApplied_fShowerParametersNamesTypes);
+      MParContainer::ShowMembers(R__insp, R__parent);
+}
+
+namespace ROOT {
+   // Return the actual TClass for the object argument
+   TClass *MTSupercutsApplied_IsA(const void *obj) {
+      return ((::MTSupercutsApplied*)obj)->IsA();
+   }
+   // Wrappers around operator new
+   void *new_MTSupercutsApplied(void *p) {
+      return  p ? new(p) ::MTSupercutsApplied : new ::MTSupercutsApplied;
+   }
+   void *newArray_MTSupercutsApplied(Long_t size) {
+      return new ::MTSupercutsApplied[size];
+   }
+   // Wrapper around operator delete
+   void delete_MTSupercutsApplied(void *p) {
+      delete ((::MTSupercutsApplied*)p);
+   }
+   void deleteArray_MTSupercutsApplied(void *p) {
+      delete [] ((::MTSupercutsApplied*)p);
+   }
+   void destruct_MTSupercutsApplied(void *p) {
+      typedef ::MTSupercutsApplied current_t;
+      ((current_t*)p)->~current_t();
+   }
+} // end of namespace ROOT for class MTSupercutsApplied
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFF_fFilenameTrain(TBuffer &R__b, void *R__p, int)
+{
+   TString &fFilenameTrain = *(TString *)R__p;
+   if (R__b.IsReading()) {
+      fFilenameTrain.Streamer(R__b);
+   } else {
+      fFilenameTrain.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFF_fFilenameTest(TBuffer &R__b, void *R__p, int)
+{
+   TString &fFilenameTest = *(TString *)R__p;
+   if (R__b.IsReading()) {
+      fFilenameTest.Streamer(R__b);
+   } else {
+      fFilenameTest.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFF_fThetaRangeString(TBuffer &R__b, void *R__p, int)
+{
+   TString &fThetaRangeString = *(TString *)R__p;
+   if (R__b.IsReading()) {
+      fThetaRangeString.Streamer(R__b);
+   } else {
+      fThetaRangeString.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFF_fFilenameParam(TBuffer &R__b, void *R__p, int)
+{
+   TString &fFilenameParam = *(TString *)R__p;
+   if (R__b.IsReading()) {
+      fFilenameParam.Streamer(R__b);
+   } else {
+      fFilenameParam.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFF_fHadronnessName(TBuffer &R__b, void *R__p, int)
+{
+   TString &fHadronnessName = *(TString *)R__p;
+   if (R__b.IsReading()) {
+      fHadronnessName.Streamer(R__b);
+   } else {
+      fHadronnessName.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFF_fHadronnessNameOFF(TBuffer &R__b, void *R__p, int)
+{
+   TString &fHadronnessNameOFF = *(TString *)R__p;
+   if (R__b.IsReading()) {
+      fHadronnessNameOFF.Streamer(R__b);
+   } else {
+      fHadronnessNameOFF.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFF_fTrainONSupercutsAppliedName(TBuffer &R__b, void *R__p, int)
+{
+   TString &fTrainONSupercutsAppliedName = *(TString *)R__p;
+   if (R__b.IsReading()) {
+      fTrainONSupercutsAppliedName.Streamer(R__b);
+   } else {
+      fTrainONSupercutsAppliedName.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFF_fTrainOFFSupercutsAppliedName(TBuffer &R__b, void *R__p, int)
+{
+   TString &fTrainOFFSupercutsAppliedName = *(TString *)R__p;
+   if (R__b.IsReading()) {
+      fTrainOFFSupercutsAppliedName.Streamer(R__b);
+   } else {
+      fTrainOFFSupercutsAppliedName.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFF_fTestONSupercutsAppliedName(TBuffer &R__b, void *R__p, int)
+{
+   TString &fTestONSupercutsAppliedName = *(TString *)R__p;
+   if (R__b.IsReading()) {
+      fTestONSupercutsAppliedName.Streamer(R__b);
+   } else {
+      fTestONSupercutsAppliedName.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFF_fTestOFFSupercutsAppliedName(TBuffer &R__b, void *R__p, int)
+{
+   TString &fTestOFFSupercutsAppliedName = *(TString *)R__p;
+   if (R__b.IsReading()) {
+      fTestOFFSupercutsAppliedName.Streamer(R__b);
+   } else {
+      fTestOFFSupercutsAppliedName.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFF_fPsFilenameString(TBuffer &R__b, void *R__p, int)
+{
+   TString &fPsFilenameString = *(TString *)R__p;
+   if (R__b.IsReading()) {
+      fPsFilenameString.Streamer(R__b);
+   } else {
+      fPsFilenameString.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFF_fAlphaDistributionsRootFilename(TBuffer &R__b, void *R__p, int)
+{
+   TString &fAlphaDistributionsRootFilename = *(TString *)R__p;
+   if (R__b.IsReading()) {
+      fAlphaDistributionsRootFilename.Streamer(R__b);
+   } else {
+      fAlphaDistributionsRootFilename.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFF_fMatrixFilter(TBuffer &R__b, void *R__p, int)
+{
+   MFilter** fMatrixFilter = (MFilter**)R__p;
+   if (R__b.IsReading()) {
+      R__b >> *fMatrixFilter;
+   } else {
+      R__b << (TObject*)*fMatrixFilter;
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFF_fVinit(TBuffer &R__b, void *R__p, int)
+{
+   TArrayD &fVinit = *(TArrayD *)R__p;
+   if (R__b.IsReading()) {
+      fVinit.Streamer(R__b);
+   } else {
+      fVinit.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFF_fStep(TBuffer &R__b, void *R__p, int)
+{
+   TArrayD &fStep = *(TArrayD *)R__p;
+   if (R__b.IsReading()) {
+      fStep.Streamer(R__b);
+   } else {
+      fStep.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFF_fLimlo(TBuffer &R__b, void *R__p, int)
+{
+   TArrayD &fLimlo = *(TArrayD *)R__p;
+   if (R__b.IsReading()) {
+      fLimlo.Streamer(R__b);
+   } else {
+      fLimlo.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFF_fLimup(TBuffer &R__b, void *R__p, int)
+{
+   TArrayD &fLimup = *(TArrayD *)R__p;
+   if (R__b.IsReading()) {
+      fLimup.Streamer(R__b);
+   } else {
+      fLimup.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFF_fFix(TBuffer &R__b, void *R__p, int)
+{
+   TArrayI &fFix = *(TArrayI *)R__p;
+   if (R__b.IsReading()) {
+      fFix.Streamer(R__b);
+   } else {
+      fFix.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFF_fMethod(TBuffer &R__b, void *R__p, int)
+{
+   TString &fMethod = *(TString *)R__p;
+   if (R__b.IsReading()) {
+      fMethod.Streamer(R__b);
+   } else {
+      fMethod.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void MFindSupercutsONOFF::Streamer(TBuffer &R__b)
+{
+   // Stream an object of class MFindSupercutsONOFF.
+
+   if (R__b.IsReading()) {
+      MFindSupercutsONOFF::Class()->ReadBuffer(R__b, this);
+   } else {
+      MFindSupercutsONOFF::Class()->WriteBuffer(R__b, this);
+   }
+}
+
+//______________________________________________________________________________
+void MFindSupercutsONOFF::ShowMembers(TMemberInspector &R__insp, char *R__parent)
+{
+      // Inspect the data members of an object of class MFindSupercutsONOFF.
+
+      TClass *R__cl = MFindSupercutsONOFF::IsA();
+      Int_t R__ncp = strlen(R__parent);
+      if (R__ncp || R__cl || R__insp.IsA()) { }
+      R__insp.Inspect(R__cl, R__parent, "fSizeCutLow", &fSizeCutLow);
+      R__insp.Inspect(R__cl, R__parent, "fSizeCutUp", &fSizeCutUp);
+      R__insp.Inspect(R__cl, R__parent, "fDistCutLow", &fDistCutLow);
+      R__insp.Inspect(R__cl, R__parent, "fDistCutUp", &fDistCutUp);
+      R__insp.Inspect(R__cl, R__parent, "fLengthCutLow", &fLengthCutLow);
+      R__insp.Inspect(R__cl, R__parent, "fLengthCutUp", &fLengthCutUp);
+      R__insp.Inspect(R__cl, R__parent, "fWidthCutLow", &fWidthCutLow);
+      R__insp.Inspect(R__cl, R__parent, "fWidthCutUp", &fWidthCutUp);
+      R__insp.Inspect(R__cl, R__parent, "fFilenameTrain", &fFilenameTrain);
+      fFilenameTrain.ShowMembers(R__insp, strcat(R__parent,"fFilenameTrain.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fFilenameTrain",R__MFindSupercutsONOFF_fFilenameTrain);
+      R__insp.Inspect(R__cl, R__parent, "fFilenameTest", &fFilenameTest);
+      fFilenameTest.ShowMembers(R__insp, strcat(R__parent,"fFilenameTest.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fFilenameTest",R__MFindSupercutsONOFF_fFilenameTest);
+      R__insp.Inspect(R__cl, R__parent, "fHowManyTrain", &fHowManyTrain);
+      R__insp.Inspect(R__cl, R__parent, "fHowManyTest", &fHowManyTest);
+      R__insp.Inspect(R__cl, R__parent, "fHowManyTrainOFF", &fHowManyTrainOFF);
+      R__insp.Inspect(R__cl, R__parent, "fHowManyTestOFF", &fHowManyTestOFF);
+      R__insp.Inspect(R__cl, R__parent, "fAlphaSig", &fAlphaSig);
+      R__insp.Inspect(R__cl, R__parent, "fAlphaBkgMin", &fAlphaBkgMin);
+      R__insp.Inspect(R__cl, R__parent, "fAlphaBkgMax", &fAlphaBkgMax);
+      R__insp.Inspect(R__cl, R__parent, "fThetaMin", &fThetaMin);
+      R__insp.Inspect(R__cl, R__parent, "fThetaMax", &fThetaMax);
+      R__insp.Inspect(R__cl, R__parent, "fThetaRangeString", &fThetaRangeString);
+      fThetaRangeString.ShowMembers(R__insp, strcat(R__parent,"fThetaRangeString.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fThetaRangeString",R__MFindSupercutsONOFF_fThetaRangeString);
+      R__insp.Inspect(R__cl, R__parent, "fNAlphaBins", &fNAlphaBins);
+      R__insp.Inspect(R__cl, R__parent, "fAlphaBinLow", &fAlphaBinLow);
+      R__insp.Inspect(R__cl, R__parent, "fAlphaBinUp", &fAlphaBinUp);
+      R__insp.Inspect(R__cl, R__parent, "fUseOrigDistribution", &fUseOrigDistribution);
+      R__insp.Inspect(R__cl, R__parent, "fNormFactorTrain", &fNormFactorTrain);
+      R__insp.Inspect(R__cl, R__parent, "fNormFactorTest", &fNormFactorTest);
+      R__insp.Inspect(R__cl, R__parent, "fSigmaLiMaTrain", &fSigmaLiMaTrain);
+      R__insp.Inspect(R__cl, R__parent, "fSigmaLiMaTest", &fSigmaLiMaTest);
+      R__insp.Inspect(R__cl, R__parent, "fNexTrain", &fNexTrain);
+      R__insp.Inspect(R__cl, R__parent, "fNexTest", &fNexTest);
+      R__insp.Inspect(R__cl, R__parent, "fGammaEfficiency", &fGammaEfficiency);
+      R__insp.Inspect(R__cl, R__parent, "fTuneNormFactor", &fTuneNormFactor);
+      R__insp.Inspect(R__cl, R__parent, "fNormFactorFromAlphaBkg", &fNormFactorFromAlphaBkg);
+      R__insp.Inspect(R__cl, R__parent, "fUseFittedQuantities", &fUseFittedQuantities);
+      R__insp.Inspect(R__cl, R__parent, "fSkipOptimization", &fSkipOptimization);
+      R__insp.Inspect(R__cl, R__parent, "fSetLimitsToSomeMinuitParams", &fSetLimitsToSomeMinuitParams);
+      R__insp.Inspect(R__cl, R__parent, "fMinuitDistUPUpperLimit", &fMinuitDistUPUpperLimit);
+      R__insp.Inspect(R__cl, R__parent, "fMinuitDistUPLowerLimit", &fMinuitDistUPLowerLimit);
+      R__insp.Inspect(R__cl, R__parent, "fMinuitLengthUPUpperLimit", &fMinuitLengthUPUpperLimit);
+      R__insp.Inspect(R__cl, R__parent, "fMinuitLengthUPLowerLimit", &fMinuitLengthUPLowerLimit);
+      R__insp.Inspect(R__cl, R__parent, "fMinuitWidthUPUpperLimit", &fMinuitWidthUPUpperLimit);
+      R__insp.Inspect(R__cl, R__parent, "fMinuitWidthUPLowerLimit", &fMinuitWidthUPLowerLimit);
+      R__insp.Inspect(R__cl, R__parent, "fMinuitLeakage1UPUpperLimit", &fMinuitLeakage1UPUpperLimit);
+      R__insp.Inspect(R__cl, R__parent, "fMinuitLeakage1UPLowerLimit", &fMinuitLeakage1UPLowerLimit);
+      R__insp.Inspect(R__cl, R__parent, "fMinuitDistLOWUpperLimit", &fMinuitDistLOWUpperLimit);
+      R__insp.Inspect(R__cl, R__parent, "fMinuitDistLOWLowerLimit", &fMinuitDistLOWLowerLimit);
+      R__insp.Inspect(R__cl, R__parent, "fMinuitLengthLOWUpperLimit", &fMinuitLengthLOWUpperLimit);
+      R__insp.Inspect(R__cl, R__parent, "fMinuitLengthLOWLowerLimit", &fMinuitLengthLOWLowerLimit);
+      R__insp.Inspect(R__cl, R__parent, "fMinuitWidthLOWUpperLimit", &fMinuitWidthLOWUpperLimit);
+      R__insp.Inspect(R__cl, R__parent, "fMinuitWidthLOWLowerLimit", &fMinuitWidthLOWLowerLimit);
+      R__insp.Inspect(R__cl, R__parent, "fNotUseTheta", &fNotUseTheta);
+      R__insp.Inspect(R__cl, R__parent, "fUseDist", &fUseDist);
+      R__insp.Inspect(R__cl, R__parent, "fUseStaticCuts", &fUseStaticCuts);
+      R__insp.Inspect(R__cl, R__parent, "fUseInitialSCParams", &fUseInitialSCParams);
+      R__insp.Inspect(R__cl, R__parent, "fFilenameParam", &fFilenameParam);
+      fFilenameParam.ShowMembers(R__insp, strcat(R__parent,"fFilenameParam.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fFilenameParam",R__MFindSupercutsONOFF_fFilenameParam);
+      R__insp.Inspect(R__cl, R__parent, "fHadronnessName", &fHadronnessName);
+      fHadronnessName.ShowMembers(R__insp, strcat(R__parent,"fHadronnessName.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fHadronnessName",R__MFindSupercutsONOFF_fHadronnessName);
+      R__insp.Inspect(R__cl, R__parent, "fHadronnessNameOFF", &fHadronnessNameOFF);
+      fHadronnessNameOFF.ShowMembers(R__insp, strcat(R__parent,"fHadronnessNameOFF.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fHadronnessNameOFF",R__MFindSupercutsONOFF_fHadronnessNameOFF);
+      R__insp.Inspect(R__cl, R__parent, "fTrainONSupercutsAppliedName", &fTrainONSupercutsAppliedName);
+      fTrainONSupercutsAppliedName.ShowMembers(R__insp, strcat(R__parent,"fTrainONSupercutsAppliedName.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fTrainONSupercutsAppliedName",R__MFindSupercutsONOFF_fTrainONSupercutsAppliedName);
+      R__insp.Inspect(R__cl, R__parent, "fTrainOFFSupercutsAppliedName", &fTrainOFFSupercutsAppliedName);
+      fTrainOFFSupercutsAppliedName.ShowMembers(R__insp, strcat(R__parent,"fTrainOFFSupercutsAppliedName.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fTrainOFFSupercutsAppliedName",R__MFindSupercutsONOFF_fTrainOFFSupercutsAppliedName);
+      R__insp.Inspect(R__cl, R__parent, "fTestONSupercutsAppliedName", &fTestONSupercutsAppliedName);
+      fTestONSupercutsAppliedName.ShowMembers(R__insp, strcat(R__parent,"fTestONSupercutsAppliedName.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fTestONSupercutsAppliedName",R__MFindSupercutsONOFF_fTestONSupercutsAppliedName);
+      R__insp.Inspect(R__cl, R__parent, "fTestOFFSupercutsAppliedName", &fTestOFFSupercutsAppliedName);
+      fTestOFFSupercutsAppliedName.ShowMembers(R__insp, strcat(R__parent,"fTestOFFSupercutsAppliedName.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fTestOFFSupercutsAppliedName",R__MFindSupercutsONOFF_fTestOFFSupercutsAppliedName);
+      R__insp.Inspect(R__cl, R__parent, "*fPsFilename", &fPsFilename);
+      R__insp.Inspect(R__cl, R__parent, "*fPsFilename2", &fPsFilename2);
+      R__insp.Inspect(R__cl, R__parent, "fPsFilenameString", &fPsFilenameString);
+      fPsFilenameString.ShowMembers(R__insp, strcat(R__parent,"fPsFilenameString.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fPsFilenameString",R__MFindSupercutsONOFF_fPsFilenameString);
+      R__insp.Inspect(R__cl, R__parent, "fAlphaDistributionsRootFilename", &fAlphaDistributionsRootFilename);
+      fAlphaDistributionsRootFilename.ShowMembers(R__insp, strcat(R__parent,"fAlphaDistributionsRootFilename.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fAlphaDistributionsRootFilename",R__MFindSupercutsONOFF_fAlphaDistributionsRootFilename);
+      R__insp.Inspect(R__cl, R__parent, "*fCalcHadTrain", &fCalcHadTrain);
+      R__insp.Inspect(R__cl, R__parent, "*fCalcHadTest", &fCalcHadTest);
+      R__insp.Inspect(R__cl, R__parent, "*fCalcHadTrainOFF", &fCalcHadTrainOFF);
+      R__insp.Inspect(R__cl, R__parent, "*fCalcHadTestOFF", &fCalcHadTestOFF);
+      R__insp.Inspect(R__cl, R__parent, "*fMatrixTrain", &fMatrixTrain);
+      R__insp.Inspect(R__cl, R__parent, "*fMatrixTest", &fMatrixTest);
+      R__insp.Inspect(R__cl, R__parent, "*fMatrixTrainOFF", &fMatrixTrainOFF);
+      R__insp.Inspect(R__cl, R__parent, "*fMatrixTestOFF", &fMatrixTestOFF);
+      R__insp.Inspect(R__cl, R__parent, "*fCam", &fCam);
+      R__insp.Inspect(R__cl, R__parent, "*fObjectFit", &fObjectFit);
+      R__insp.Inspect(R__cl, R__parent, "*fMatrixFilter", &fMatrixFilter);
+      R__cl->SetStreamer("*fMatrixFilter",R__MFindSupercutsONOFF_fMatrixFilter);
+      R__insp.Inspect(R__cl, R__parent, "fVinit", &fVinit);
+      fVinit.ShowMembers(R__insp, strcat(R__parent,"fVinit.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fVinit",R__MFindSupercutsONOFF_fVinit);
+      R__insp.Inspect(R__cl, R__parent, "fStep", &fStep);
+      fStep.ShowMembers(R__insp, strcat(R__parent,"fStep.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fStep",R__MFindSupercutsONOFF_fStep);
+      R__insp.Inspect(R__cl, R__parent, "fLimlo", &fLimlo);
+      fLimlo.ShowMembers(R__insp, strcat(R__parent,"fLimlo.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fLimlo",R__MFindSupercutsONOFF_fLimlo);
+      R__insp.Inspect(R__cl, R__parent, "fLimup", &fLimup);
+      fLimup.ShowMembers(R__insp, strcat(R__parent,"fLimup.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fLimup",R__MFindSupercutsONOFF_fLimup);
+      R__insp.Inspect(R__cl, R__parent, "fFix", &fFix);
+      fFix.ShowMembers(R__insp, strcat(R__parent,"fFix.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fFix",R__MFindSupercutsONOFF_fFix);
+      R__insp.Inspect(R__cl, R__parent, "fNpar", &fNpar);
+      R__insp.Inspect(R__cl, R__parent, "fMethod", &fMethod);
+      fMethod.ShowMembers(R__insp, strcat(R__parent,"fMethod.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fMethod",R__MFindSupercutsONOFF_fMethod);
+      R__insp.Inspect(R__cl, R__parent, "fMin", &fMin);
+      R__insp.Inspect(R__cl, R__parent, "fEdm", &fEdm);
+      R__insp.Inspect(R__cl, R__parent, "fErrdef", &fErrdef);
+      R__insp.Inspect(R__cl, R__parent, "fNpari", &fNpari);
+      R__insp.Inspect(R__cl, R__parent, "fNparx", &fNparx);
+      R__insp.Inspect(R__cl, R__parent, "fIstat", &fIstat);
+      R__insp.Inspect(R__cl, R__parent, "fErrMinimize", &fErrMinimize);
+      MParContainer::ShowMembers(R__insp, R__parent);
+}
+
+namespace ROOT {
+   // Return the actual TClass for the object argument
+   TClass *MFindSupercutsONOFF_IsA(const void *obj) {
+      return ((::MFindSupercutsONOFF*)obj)->IsA();
+   }
+   // Wrappers around operator new
+   void *new_MFindSupercutsONOFF(void *p) {
+      return  p ? new(p) ::MFindSupercutsONOFF : new ::MFindSupercutsONOFF;
+   }
+   void *newArray_MFindSupercutsONOFF(Long_t size) {
+      return new ::MFindSupercutsONOFF[size];
+   }
+   // Wrapper around operator delete
+   void delete_MFindSupercutsONOFF(void *p) {
+      delete ((::MFindSupercutsONOFF*)p);
+   }
+   void deleteArray_MFindSupercutsONOFF(void *p) {
+      delete [] ((::MFindSupercutsONOFF*)p);
+   }
+   void destruct_MFindSupercutsONOFF(void *p) {
+      typedef ::MFindSupercutsONOFF current_t;
+      ((current_t*)p)->~current_t();
+   }
+} // end of namespace ROOT for class MFindSupercutsONOFF
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFFThetaLoop_fDataONRootFilename(TBuffer &R__b, void *R__p, int)
+{
+   TString &fDataONRootFilename = *(TString *)R__p;
+   if (R__b.IsReading()) {
+      fDataONRootFilename.Streamer(R__b);
+   } else {
+      fDataONRootFilename.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFFThetaLoop_fDataOFFRootFilename(TBuffer &R__b, void *R__p, int)
+{
+   TString &fDataOFFRootFilename = *(TString *)R__p;
+   if (R__b.IsReading()) {
+      fDataOFFRootFilename.Streamer(R__b);
+   } else {
+      fDataOFFRootFilename.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFFThetaLoop_fPathForFiles(TBuffer &R__b, void *R__p, int)
+{
+   TString &fPathForFiles = *(TString *)R__p;
+   if (R__b.IsReading()) {
+      fPathForFiles.Streamer(R__b);
+   } else {
+      fPathForFiles.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFFThetaLoop_fOptSCParamFilenameVector(TBuffer &R__b, void *R__p, int)
+{
+   TString** fOptSCParamFilenameVector = (TString**)R__p;
+   if (R__b.IsReading()) {
+      R__b >> *fOptSCParamFilenameVector;
+   } else {
+      R__b << *fOptSCParamFilenameVector;
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFFThetaLoop_fTrainMatrixONFilenameVector(TBuffer &R__b, void *R__p, int)
+{
+   TString** fTrainMatrixONFilenameVector = (TString**)R__p;
+   if (R__b.IsReading()) {
+      R__b >> *fTrainMatrixONFilenameVector;
+   } else {
+      R__b << *fTrainMatrixONFilenameVector;
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFFThetaLoop_fTestMatrixONFilenameVector(TBuffer &R__b, void *R__p, int)
+{
+   TString** fTestMatrixONFilenameVector = (TString**)R__p;
+   if (R__b.IsReading()) {
+      R__b >> *fTestMatrixONFilenameVector;
+   } else {
+      R__b << *fTestMatrixONFilenameVector;
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFFThetaLoop_fTrainMatrixOFFFilenameVector(TBuffer &R__b, void *R__p, int)
+{
+   TString** fTrainMatrixOFFFilenameVector = (TString**)R__p;
+   if (R__b.IsReading()) {
+      R__b >> *fTrainMatrixOFFFilenameVector;
+   } else {
+      R__b << *fTrainMatrixOFFFilenameVector;
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFFThetaLoop_fTestMatrixOFFFilenameVector(TBuffer &R__b, void *R__p, int)
+{
+   TString** fTestMatrixOFFFilenameVector = (TString**)R__p;
+   if (R__b.IsReading()) {
+      R__b >> *fTestMatrixOFFFilenameVector;
+   } else {
+      R__b << *fTestMatrixOFFFilenameVector;
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFFThetaLoop_fCosThetaRangeVector(TBuffer &R__b, void *R__p, int)
+{
+   TArrayD &fCosThetaRangeVector = *(TArrayD *)R__p;
+   if (R__b.IsReading()) {
+      fCosThetaRangeVector.Streamer(R__b);
+   } else {
+      fCosThetaRangeVector.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFFThetaLoop_fThetaRangeStringVector(TBuffer &R__b, void *R__p, int)
+{
+   TString** fThetaRangeStringVector = (TString**)R__p;
+   if (R__b.IsReading()) {
+      R__b >> *fThetaRangeStringVector;
+   } else {
+      R__b << *fThetaRangeStringVector;
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFFThetaLoop_fCosThetaBinCenterVector(TBuffer &R__b, void *R__p, int)
+{
+   TArrayD &fCosThetaBinCenterVector = *(TArrayD *)R__p;
+   if (R__b.IsReading()) {
+      fCosThetaBinCenterVector.Streamer(R__b);
+   } else {
+      fCosThetaBinCenterVector.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFFThetaLoop_fSuccessfulThetaBinsHist(TBuffer &R__b, void *R__p, int)
+{
+   TH1F** fSuccessfulThetaBinsHist = (TH1F**)R__p;
+   if (R__b.IsReading()) {
+      R__b >> *fSuccessfulThetaBinsHist;
+   } else {
+      R__b << (TObject*)*fSuccessfulThetaBinsHist;
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFFThetaLoop_fNormFactorTrainHist(TBuffer &R__b, void *R__p, int)
+{
+   TH1F** fNormFactorTrainHist = (TH1F**)R__p;
+   if (R__b.IsReading()) {
+      R__b >> *fNormFactorTrainHist;
+   } else {
+      R__b << (TObject*)*fNormFactorTrainHist;
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFFThetaLoop_fNormFactorTestHist(TBuffer &R__b, void *R__p, int)
+{
+   TH1F** fNormFactorTestHist = (TH1F**)R__p;
+   if (R__b.IsReading()) {
+      R__b >> *fNormFactorTestHist;
+   } else {
+      R__b << (TObject*)*fNormFactorTestHist;
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFFThetaLoop_fSigmaLiMaTrainHist(TBuffer &R__b, void *R__p, int)
+{
+   TH1F** fSigmaLiMaTrainHist = (TH1F**)R__p;
+   if (R__b.IsReading()) {
+      R__b >> *fSigmaLiMaTrainHist;
+   } else {
+      R__b << (TObject*)*fSigmaLiMaTrainHist;
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFFThetaLoop_fSigmaLiMaTestHist(TBuffer &R__b, void *R__p, int)
+{
+   TH1F** fSigmaLiMaTestHist = (TH1F**)R__p;
+   if (R__b.IsReading()) {
+      R__b >> *fSigmaLiMaTestHist;
+   } else {
+      R__b << (TObject*)*fSigmaLiMaTestHist;
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFFThetaLoop_fNexTrainHist(TBuffer &R__b, void *R__p, int)
+{
+   TH1F** fNexTrainHist = (TH1F**)R__p;
+   if (R__b.IsReading()) {
+      R__b >> *fNexTrainHist;
+   } else {
+      R__b << (TObject*)*fNexTrainHist;
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFFThetaLoop_fNexTestHist(TBuffer &R__b, void *R__p, int)
+{
+   TH1F** fNexTestHist = (TH1F**)R__p;
+   if (R__b.IsReading()) {
+      R__b >> *fNexTestHist;
+   } else {
+      R__b << (TObject*)*fNexTestHist;
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFFThetaLoop_fNEvtsInTrainMatrixONHist(TBuffer &R__b, void *R__p, int)
+{
+   TH1F** fNEvtsInTrainMatrixONHist = (TH1F**)R__p;
+   if (R__b.IsReading()) {
+      R__b >> *fNEvtsInTrainMatrixONHist;
+   } else {
+      R__b << (TObject*)*fNEvtsInTrainMatrixONHist;
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFFThetaLoop_fNEvtsInTestMatrixONHist(TBuffer &R__b, void *R__p, int)
+{
+   TH1F** fNEvtsInTestMatrixONHist = (TH1F**)R__p;
+   if (R__b.IsReading()) {
+      R__b >> *fNEvtsInTestMatrixONHist;
+   } else {
+      R__b << (TObject*)*fNEvtsInTestMatrixONHist;
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFFThetaLoop_fNEvtsInTrainMatrixOFFHist(TBuffer &R__b, void *R__p, int)
+{
+   TH1F** fNEvtsInTrainMatrixOFFHist = (TH1F**)R__p;
+   if (R__b.IsReading()) {
+      R__b >> *fNEvtsInTrainMatrixOFFHist;
+   } else {
+      R__b << (TObject*)*fNEvtsInTrainMatrixOFFHist;
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFFThetaLoop_fNEvtsInTestMatrixOFFHist(TBuffer &R__b, void *R__p, int)
+{
+   TH1F** fNEvtsInTestMatrixOFFHist = (TH1F**)R__p;
+   if (R__b.IsReading()) {
+      R__b >> *fNEvtsInTestMatrixOFFHist;
+   } else {
+      R__b << (TObject*)*fNEvtsInTestMatrixOFFHist;
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFFThetaLoop_fHadronnessName(TBuffer &R__b, void *R__p, int)
+{
+   TString &fHadronnessName = *(TString *)R__p;
+   if (R__b.IsReading()) {
+      fHadronnessName.Streamer(R__b);
+   } else {
+      fHadronnessName.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFFThetaLoop_fHadronnessNameOFF(TBuffer &R__b, void *R__p, int)
+{
+   TString &fHadronnessNameOFF = *(TString *)R__p;
+   if (R__b.IsReading()) {
+      fHadronnessNameOFF.Streamer(R__b);
+   } else {
+      fHadronnessNameOFF.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFFThetaLoop_fInitSCPar(TBuffer &R__b, void *R__p, int)
+{
+   TArrayD &fInitSCPar = *(TArrayD *)R__p;
+   if (R__b.IsReading()) {
+      fInitSCPar.Streamer(R__b);
+   } else {
+      fInitSCPar.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFFThetaLoop_fInitSCParSteps(TBuffer &R__b, void *R__p, int)
+{
+   TArrayD &fInitSCParSteps = *(TArrayD *)R__p;
+   if (R__b.IsReading()) {
+      fInitSCParSteps.Streamer(R__b);
+   } else {
+      fInitSCParSteps.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void R__MFindSupercutsONOFFThetaLoop_fAlphaDistributionsRootFilename(TBuffer &R__b, void *R__p, int)
+{
+   TString &fAlphaDistributionsRootFilename = *(TString *)R__p;
+   if (R__b.IsReading()) {
+      fAlphaDistributionsRootFilename.Streamer(R__b);
+   } else {
+      fAlphaDistributionsRootFilename.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void MFindSupercutsONOFFThetaLoop::Streamer(TBuffer &R__b)
+{
+   // Stream an object of class MFindSupercutsONOFFThetaLoop.
+
+   if (R__b.IsReading()) {
+      MFindSupercutsONOFFThetaLoop::Class()->ReadBuffer(R__b, this);
+   } else {
+      MFindSupercutsONOFFThetaLoop::Class()->WriteBuffer(R__b, this);
+   }
+}
+
+//______________________________________________________________________________
+void MFindSupercutsONOFFThetaLoop::ShowMembers(TMemberInspector &R__insp, char *R__parent)
+{
+      // Inspect the data members of an object of class MFindSupercutsONOFFThetaLoop.
+
+      TClass *R__cl = MFindSupercutsONOFFThetaLoop::IsA();
+      Int_t R__ncp = strlen(R__parent);
+      if (R__ncp || R__cl || R__insp.IsA()) { }
+      R__insp.Inspect(R__cl, R__parent, "fDataONRootFilename", &fDataONRootFilename);
+      fDataONRootFilename.ShowMembers(R__insp, strcat(R__parent,"fDataONRootFilename.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fDataONRootFilename",R__MFindSupercutsONOFFThetaLoop_fDataONRootFilename);
+      R__insp.Inspect(R__cl, R__parent, "fDataOFFRootFilename", &fDataOFFRootFilename);
+      fDataOFFRootFilename.ShowMembers(R__insp, strcat(R__parent,"fDataOFFRootFilename.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fDataOFFRootFilename",R__MFindSupercutsONOFFThetaLoop_fDataOFFRootFilename);
+      R__insp.Inspect(R__cl, R__parent, "fPathForFiles", &fPathForFiles);
+      fPathForFiles.ShowMembers(R__insp, strcat(R__parent,"fPathForFiles.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fPathForFiles",R__MFindSupercutsONOFFThetaLoop_fPathForFiles);
+      R__insp.Inspect(R__cl, R__parent, "*fOptSCParamFilenameVector", &fOptSCParamFilenameVector);
+      R__cl->SetStreamer("*fOptSCParamFilenameVector",R__MFindSupercutsONOFFThetaLoop_fOptSCParamFilenameVector);
+      R__insp.Inspect(R__cl, R__parent, "*fTrainMatrixONFilenameVector", &fTrainMatrixONFilenameVector);
+      R__cl->SetStreamer("*fTrainMatrixONFilenameVector",R__MFindSupercutsONOFFThetaLoop_fTrainMatrixONFilenameVector);
+      R__insp.Inspect(R__cl, R__parent, "*fTestMatrixONFilenameVector", &fTestMatrixONFilenameVector);
+      R__cl->SetStreamer("*fTestMatrixONFilenameVector",R__MFindSupercutsONOFFThetaLoop_fTestMatrixONFilenameVector);
+      R__insp.Inspect(R__cl, R__parent, "*fTrainMatrixOFFFilenameVector", &fTrainMatrixOFFFilenameVector);
+      R__cl->SetStreamer("*fTrainMatrixOFFFilenameVector",R__MFindSupercutsONOFFThetaLoop_fTrainMatrixOFFFilenameVector);
+      R__insp.Inspect(R__cl, R__parent, "*fTestMatrixOFFFilenameVector", &fTestMatrixOFFFilenameVector);
+      R__cl->SetStreamer("*fTestMatrixOFFFilenameVector",R__MFindSupercutsONOFFThetaLoop_fTestMatrixOFFFilenameVector);
+      R__insp.Inspect(R__cl, R__parent, "fAlphaSig", &fAlphaSig);
+      R__insp.Inspect(R__cl, R__parent, "fAlphaBkgMin", &fAlphaBkgMin);
+      R__insp.Inspect(R__cl, R__parent, "fAlphaBkgMax", &fAlphaBkgMax);
+      R__insp.Inspect(R__cl, R__parent, "fSizeCutLow", &fSizeCutLow);
+      R__insp.Inspect(R__cl, R__parent, "fSizeCutUp", &fSizeCutUp);
+      R__insp.Inspect(R__cl, R__parent, "fNAlphaBins", &fNAlphaBins);
+      R__insp.Inspect(R__cl, R__parent, "fAlphaBinLow", &fAlphaBinLow);
+      R__insp.Inspect(R__cl, R__parent, "fAlphaBinUp", &fAlphaBinUp);
+      R__insp.Inspect(R__cl, R__parent, "fUseFittedQuantities", &fUseFittedQuantities);
+      R__insp.Inspect(R__cl, R__parent, "fPolyGaussFitAlphaSigma", &fPolyGaussFitAlphaSigma);
+      R__insp.Inspect(R__cl, R__parent, "fWhichFractionTrain", &fWhichFractionTrain);
+      R__insp.Inspect(R__cl, R__parent, "fWhichFractionTest", &fWhichFractionTest);
+      R__insp.Inspect(R__cl, R__parent, "fWhichFractionTrainOFF", &fWhichFractionTrainOFF);
+      R__insp.Inspect(R__cl, R__parent, "fWhichFractionTestOFF", &fWhichFractionTestOFF);
+      R__insp.Inspect(R__cl, R__parent, "fThetaMin", &fThetaMin);
+      R__insp.Inspect(R__cl, R__parent, "fThetaMax", &fThetaMax);
+      R__insp.Inspect(R__cl, R__parent, "fCosThetaRangeVector", &fCosThetaRangeVector);
+      fCosThetaRangeVector.ShowMembers(R__insp, strcat(R__parent,"fCosThetaRangeVector.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fCosThetaRangeVector",R__MFindSupercutsONOFFThetaLoop_fCosThetaRangeVector);
+      R__insp.Inspect(R__cl, R__parent, "*fThetaRangeStringVector", &fThetaRangeStringVector);
+      R__cl->SetStreamer("*fThetaRangeStringVector",R__MFindSupercutsONOFFThetaLoop_fThetaRangeStringVector);
+      R__insp.Inspect(R__cl, R__parent, "fCosThetaBinCenterVector", &fCosThetaBinCenterVector);
+      fCosThetaBinCenterVector.ShowMembers(R__insp, strcat(R__parent,"fCosThetaBinCenterVector.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fCosThetaBinCenterVector",R__MFindSupercutsONOFFThetaLoop_fCosThetaBinCenterVector);
+      R__insp.Inspect(R__cl, R__parent, "fActualCosThetaBinCenter", &fActualCosThetaBinCenter);
+      R__insp.Inspect(R__cl, R__parent, "fOverallNexTrain", &fOverallNexTrain);
+      R__insp.Inspect(R__cl, R__parent, "fOverallNexTest", &fOverallNexTest);
+      R__insp.Inspect(R__cl, R__parent, "fOverallSigmaLiMaTrain", &fOverallSigmaLiMaTrain);
+      R__insp.Inspect(R__cl, R__parent, "fOverallSigmaLiMaTest", &fOverallSigmaLiMaTest);
+      R__insp.Inspect(R__cl, R__parent, "*fSuccessfulThetaBinsHist", &fSuccessfulThetaBinsHist);
+      R__cl->SetStreamer("*fSuccessfulThetaBinsHist",R__MFindSupercutsONOFFThetaLoop_fSuccessfulThetaBinsHist);
+      R__insp.Inspect(R__cl, R__parent, "*fNormFactorTrainHist", &fNormFactorTrainHist);
+      R__cl->SetStreamer("*fNormFactorTrainHist",R__MFindSupercutsONOFFThetaLoop_fNormFactorTrainHist);
+      R__insp.Inspect(R__cl, R__parent, "*fNormFactorTestHist", &fNormFactorTestHist);
+      R__cl->SetStreamer("*fNormFactorTestHist",R__MFindSupercutsONOFFThetaLoop_fNormFactorTestHist);
+      R__insp.Inspect(R__cl, R__parent, "*fSigmaLiMaTrainHist", &fSigmaLiMaTrainHist);
+      R__cl->SetStreamer("*fSigmaLiMaTrainHist",R__MFindSupercutsONOFFThetaLoop_fSigmaLiMaTrainHist);
+      R__insp.Inspect(R__cl, R__parent, "*fSigmaLiMaTestHist", &fSigmaLiMaTestHist);
+      R__cl->SetStreamer("*fSigmaLiMaTestHist",R__MFindSupercutsONOFFThetaLoop_fSigmaLiMaTestHist);
+      R__insp.Inspect(R__cl, R__parent, "*fNexTrainHist", &fNexTrainHist);
+      R__cl->SetStreamer("*fNexTrainHist",R__MFindSupercutsONOFFThetaLoop_fNexTrainHist);
+      R__insp.Inspect(R__cl, R__parent, "*fNexTestHist", &fNexTestHist);
+      R__cl->SetStreamer("*fNexTestHist",R__MFindSupercutsONOFFThetaLoop_fNexTestHist);
+      R__insp.Inspect(R__cl, R__parent, "*fNEvtsInTrainMatrixONHist", &fNEvtsInTrainMatrixONHist);
+      R__cl->SetStreamer("*fNEvtsInTrainMatrixONHist",R__MFindSupercutsONOFFThetaLoop_fNEvtsInTrainMatrixONHist);
+      R__insp.Inspect(R__cl, R__parent, "*fNEvtsInTestMatrixONHist", &fNEvtsInTestMatrixONHist);
+      R__cl->SetStreamer("*fNEvtsInTestMatrixONHist",R__MFindSupercutsONOFFThetaLoop_fNEvtsInTestMatrixONHist);
+      R__insp.Inspect(R__cl, R__parent, "*fNEvtsInTrainMatrixOFFHist", &fNEvtsInTrainMatrixOFFHist);
+      R__cl->SetStreamer("*fNEvtsInTrainMatrixOFFHist",R__MFindSupercutsONOFFThetaLoop_fNEvtsInTrainMatrixOFFHist);
+      R__insp.Inspect(R__cl, R__parent, "*fNEvtsInTestMatrixOFFHist", &fNEvtsInTestMatrixOFFHist);
+      R__cl->SetStreamer("*fNEvtsInTestMatrixOFFHist",R__MFindSupercutsONOFFThetaLoop_fNEvtsInTestMatrixOFFHist);
+      R__insp.Inspect(R__cl, R__parent, "fSkipOptimization", &fSkipOptimization);
+      R__insp.Inspect(R__cl, R__parent, "fUseInitialSCParams", &fUseInitialSCParams);
+      R__insp.Inspect(R__cl, R__parent, "fGammaEfficiency", &fGammaEfficiency);
+      R__insp.Inspect(R__cl, R__parent, "fTuneNormFactor", &fTuneNormFactor);
+      R__insp.Inspect(R__cl, R__parent, "fNormFactorFromAlphaBkg", &fNormFactorFromAlphaBkg);
+      R__insp.Inspect(R__cl, R__parent, "fNotUseTheta", &fNotUseTheta);
+      R__insp.Inspect(R__cl, R__parent, "fUseStaticCuts", &fUseStaticCuts);
+      R__insp.Inspect(R__cl, R__parent, "fHadronnessName", &fHadronnessName);
+      fHadronnessName.ShowMembers(R__insp, strcat(R__parent,"fHadronnessName.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fHadronnessName",R__MFindSupercutsONOFFThetaLoop_fHadronnessName);
+      R__insp.Inspect(R__cl, R__parent, "fHadronnessNameOFF", &fHadronnessNameOFF);
+      fHadronnessNameOFF.ShowMembers(R__insp, strcat(R__parent,"fHadronnessNameOFF.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fHadronnessNameOFF",R__MFindSupercutsONOFFThetaLoop_fHadronnessNameOFF);
+      R__insp.Inspect(R__cl, R__parent, "fInitSCPar", &fInitSCPar);
+      fInitSCPar.ShowMembers(R__insp, strcat(R__parent,"fInitSCPar.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fInitSCPar",R__MFindSupercutsONOFFThetaLoop_fInitSCPar);
+      R__insp.Inspect(R__cl, R__parent, "fInitSCParSteps", &fInitSCParSteps);
+      fInitSCParSteps.ShowMembers(R__insp, strcat(R__parent,"fInitSCParSteps.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fInitSCParSteps",R__MFindSupercutsONOFFThetaLoop_fInitSCParSteps);
+      R__insp.Inspect(R__cl, R__parent, "*fPsFilename", &fPsFilename);
+      R__insp.Inspect(R__cl, R__parent, "fAlphaDistributionsRootFilename", &fAlphaDistributionsRootFilename);
+      fAlphaDistributionsRootFilename.ShowMembers(R__insp, strcat(R__parent,"fAlphaDistributionsRootFilename.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fAlphaDistributionsRootFilename",R__MFindSupercutsONOFFThetaLoop_fAlphaDistributionsRootFilename);
+      R__insp.Inspect(R__cl, R__parent, "fReadMatricesFromFile", &fReadMatricesFromFile);
+      R__insp.Inspect(R__cl, R__parent, "fOptimizeParameters", &fOptimizeParameters);
+      R__insp.Inspect(R__cl, R__parent, "fTestParameters", &fTestParameters);
+      MParContainer::ShowMembers(R__insp, R__parent);
+}
+
+namespace ROOT {
+   // Return the actual TClass for the object argument
+   TClass *MFindSupercutsONOFFThetaLoop_IsA(const void *obj) {
+      return ((::MFindSupercutsONOFFThetaLoop*)obj)->IsA();
+   }
+   // Wrappers around operator new
+   void *new_MFindSupercutsONOFFThetaLoop(void *p) {
+      return  p ? new(p) ::MFindSupercutsONOFFThetaLoop : new ::MFindSupercutsONOFFThetaLoop;
+   }
+   void *newArray_MFindSupercutsONOFFThetaLoop(Long_t size) {
+      return new ::MFindSupercutsONOFFThetaLoop[size];
+   }
+   // Wrapper around operator delete
+   void delete_MFindSupercutsONOFFThetaLoop(void *p) {
+      delete ((::MFindSupercutsONOFFThetaLoop*)p);
+   }
+   void deleteArray_MFindSupercutsONOFFThetaLoop(void *p) {
+      delete [] ((::MFindSupercutsONOFFThetaLoop*)p);
+   }
+   void destruct_MFindSupercutsONOFFThetaLoop(void *p) {
+      typedef ::MFindSupercutsONOFFThetaLoop current_t;
+      ((current_t*)p)->~current_t();
+   }
+} // end of namespace ROOT for class MFindSupercutsONOFFThetaLoop
+
+/********************************************************
+* SuperCutsONOFFCint.cc
+********************************************************/
+
+#ifdef G__MEMTEST
+#undef malloc
+#undef free
+#endif
+
+extern "C" void G__cpp_reset_tagtableSuperCutsONOFFCint();
+
+extern "C" void G__set_cpp_environmentSuperCutsONOFFCint() {
+  G__add_compiledheader("TROOT.h");
+  G__add_compiledheader("TMemberInspector.h");
+  G__add_compiledheader("MFRandomSplit.h");
+  G__add_compiledheader("MSupercutsCalcONOFF.h");
+  G__add_compiledheader("MHFindSignificanceONOFF.h");
+  G__add_compiledheader("MTSupercutsApplied.h");
+  G__add_compiledheader("MFindSupercutsONOFF.h");
+  G__add_compiledheader("MFindSupercutsONOFFThetaLoop.h");
+  G__add_compiledheader("SuperCutsONOFFIncl.h");
+  G__cpp_reset_tagtableSuperCutsONOFFCint();
+}
+class G__SuperCutsONOFFCintdOcc_tag {};
+
+void* operator new(size_t size,G__SuperCutsONOFFCintdOcc_tag* p) {
+  if(p && G__PVOID!=G__getgvp()) return((void*)p);
+#ifndef G__ROOT
+  return(malloc(size));
+#else
+  return(::operator new(size));
+#endif
+}
+
+/* dummy, for exception */
+#ifdef G__EH_DUMMY_DELETE
+void operator delete(void *p,G__SuperCutsONOFFCintdOcc_tag* x) {
+  if((long)p==G__getgvp() && G__PVOID!=G__getgvp()) return;
+#ifndef G__ROOT
+  free(p);
+#else
+  ::operator delete(p);
+#endif
+}
+#endif
+
+static void G__operator_delete(void *p) {
+  if((long)p==G__getgvp() && G__PVOID!=G__getgvp()) return;
+#ifndef G__ROOT
+  free(p);
+#else
+  ::operator delete(p);
+#endif
+}
+
+void G__DELDMY_SuperCutsONOFFCintdOcc() { G__operator_delete(0); }
+
+extern "C" int G__cpp_dllrevSuperCutsONOFFCint() { return(30051515); }
+
+/*********************************************************
+* Member function Interface Method
+*********************************************************/
+
+/* MFRandomSplit */
+static int G__SuperCutsONOFFCint_124_3_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   MFRandomSplit *p=NULL;
+   switch(libp->paran) {
+   case 3:
+      p = new MFRandomSplit(
+(Double_t)G__double(libp->para[0]),(const char*)G__int(libp->para[1])
+,(const char*)G__int(libp->para[2]));
+      break;
+   case 2:
+      p = new MFRandomSplit((Double_t)G__double(libp->para[0]),(const char*)G__int(libp->para[1]));
+      break;
+   case 1:
+      p = new MFRandomSplit((Double_t)G__double(libp->para[0]));
+      break;
+   }
+      result7->obj.i = (long)p;
+      result7->ref = (long)p;
+      result7->type = 'u';
+      result7->tagnum = G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MFRandomSplit);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_124_4_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((const MFRandomSplit*)(G__getstructoffset()))->IsExpressionTrue());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_124_5_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,85,(long)MFRandomSplit::Class());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_124_6_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,67,(long)MFRandomSplit::Class_Name());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_124_7_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,115,(long)MFRandomSplit::Class_Version());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_124_8_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      MFRandomSplit::Dictionary();
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_124_9_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,85,(long)((const MFRandomSplit*)(G__getstructoffset()))->IsA());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_124_0_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFRandomSplit*)(G__getstructoffset()))->ShowMembers(*(TMemberInspector*)libp->para[0].ref,(char*)G__int(libp->para[1]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_124_1_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFRandomSplit*)(G__getstructoffset()))->Streamer(*(TBuffer*)libp->para[0].ref);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_124_2_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFRandomSplit*)(G__getstructoffset()))->StreamerNVirtual(*(TBuffer*)libp->para[0].ref);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_124_3_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,67,(long)MFRandomSplit::DeclFileName());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_124_4_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,105,(long)MFRandomSplit::ImplFileLine());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_124_5_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,67,(long)MFRandomSplit::ImplFileName());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_124_6_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,105,(long)MFRandomSplit::DeclFileLine());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+// automatic copy constructor
+static int G__SuperCutsONOFFCint_124_7_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash)
+{
+   MFRandomSplit *p;
+   p=new MFRandomSplit(*(MFRandomSplit*)G__int(libp->para[0]));
+   result7->obj.i = (long)p;
+   result7->ref = (long)p;
+   result7->type = 'u';
+   result7->tagnum = G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MFRandomSplit);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+// automatic destructor
+typedef MFRandomSplit G__TMFRandomSplit;
+static int G__SuperCutsONOFFCint_124_8_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   if(0==G__getstructoffset()) return(1);
+   if(G__getaryconstruct())
+     if(G__PVOID==G__getgvp())
+       delete[] (MFRandomSplit *)(G__getstructoffset());
+     else
+       for(int i=G__getaryconstruct()-1;i>=0;i--)
+         delete (MFRandomSplit *)((G__getstructoffset())+sizeof(MFRandomSplit)*i);
+   else  delete (MFRandomSplit *)(G__getstructoffset());
+      G__setnull(result7);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+
+/* MTSupercutsApplied */
+static int G__SuperCutsONOFFCint_136_0_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   MTSupercutsApplied *p=NULL;
+   switch(libp->paran) {
+   case 2:
+      p = new MTSupercutsApplied((const char*)G__int(libp->para[0]),(const char*)G__int(libp->para[1]));
+      break;
+   case 1:
+      p = new MTSupercutsApplied((const char*)G__int(libp->para[0]));
+      break;
+   case 0:
+   if(G__getaryconstruct()) p=new MTSupercutsApplied[G__getaryconstruct()];
+   else                    p=new MTSupercutsApplied;
+      break;
+   }
+      result7->obj.i = (long)p;
+      result7->ref = (long)p;
+      result7->type = 'u';
+      result7->tagnum = G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MTSupercutsApplied);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_136_2_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MTSupercutsApplied*)(G__getstructoffset()))->CreateTreeBranches());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_136_3_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MTSupercutsApplied*)(G__getstructoffset()))->FillTreeBranches(*((TArrayD*)G__int(libp->para[0])),*((TArrayD*)G__int(libp->para[1]))));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_136_4_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,85,(long)((MTSupercutsApplied*)(G__getstructoffset()))->GetTreePointer());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_136_5_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,85,(long)MTSupercutsApplied::Class());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_136_6_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,67,(long)MTSupercutsApplied::Class_Name());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_136_7_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,115,(long)MTSupercutsApplied::Class_Version());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_136_8_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      MTSupercutsApplied::Dictionary();
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_136_9_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,85,(long)((const MTSupercutsApplied*)(G__getstructoffset()))->IsA());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_136_0_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MTSupercutsApplied*)(G__getstructoffset()))->ShowMembers(*(TMemberInspector*)libp->para[0].ref,(char*)G__int(libp->para[1]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_136_1_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MTSupercutsApplied*)(G__getstructoffset()))->Streamer(*(TBuffer*)libp->para[0].ref);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_136_2_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MTSupercutsApplied*)(G__getstructoffset()))->StreamerNVirtual(*(TBuffer*)libp->para[0].ref);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_136_3_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,67,(long)MTSupercutsApplied::DeclFileName());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_136_4_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,105,(long)MTSupercutsApplied::ImplFileLine());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_136_5_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,67,(long)MTSupercutsApplied::ImplFileName());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_136_6_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,105,(long)MTSupercutsApplied::DeclFileLine());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+// automatic copy constructor
+static int G__SuperCutsONOFFCint_136_7_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash)
+{
+   MTSupercutsApplied *p;
+   p=new MTSupercutsApplied(*(MTSupercutsApplied*)G__int(libp->para[0]));
+   result7->obj.i = (long)p;
+   result7->ref = (long)p;
+   result7->type = 'u';
+   result7->tagnum = G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MTSupercutsApplied);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+// automatic destructor
+typedef MTSupercutsApplied G__TMTSupercutsApplied;
+static int G__SuperCutsONOFFCint_136_8_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   if(0==G__getstructoffset()) return(1);
+   if(G__getaryconstruct())
+     if(G__PVOID==G__getgvp())
+       delete[] (MTSupercutsApplied *)(G__getstructoffset());
+     else
+       for(int i=G__getaryconstruct()-1;i>=0;i--)
+         delete (MTSupercutsApplied *)((G__getstructoffset())+sizeof(MTSupercutsApplied)*i);
+   else  delete (MTSupercutsApplied *)(G__getstructoffset());
+      G__setnull(result7);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+
+/* MSupercutsCalcONOFF */
+static int G__SuperCutsONOFFCint_137_4_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   MSupercutsCalcONOFF *p=NULL;
+   switch(libp->paran) {
+   case 4:
+      p = new MSupercutsCalcONOFF(
+(const char*)G__int(libp->para[0]),(const char*)G__int(libp->para[1])
+,(const char*)G__int(libp->para[2]),(const char*)G__int(libp->para[3]));
+      break;
+   case 3:
+      p = new MSupercutsCalcONOFF(
+(const char*)G__int(libp->para[0]),(const char*)G__int(libp->para[1])
+,(const char*)G__int(libp->para[2]));
+      break;
+   case 2:
+      p = new MSupercutsCalcONOFF((const char*)G__int(libp->para[0]),(const char*)G__int(libp->para[1]));
+      break;
+   case 1:
+      p = new MSupercutsCalcONOFF((const char*)G__int(libp->para[0]));
+      break;
+   case 0:
+   if(G__getaryconstruct()) p=new MSupercutsCalcONOFF[G__getaryconstruct()];
+   else                    p=new MSupercutsCalcONOFF;
+      break;
+   }
+      result7->obj.i = (long)p;
+      result7->ref = (long)p;
+      result7->type = 'u';
+      result7->tagnum = G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MSupercutsCalcONOFF);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_137_5_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MSupercutsCalcONOFF*)(G__getstructoffset()))->SetHadronnessName(*((const TString*)G__int(libp->para[0])));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_137_6_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      {
+const         TString *pobj,xobj=((const MSupercutsCalcONOFF*)(G__getstructoffset()))->GetHadronnessName();
+        pobj=new TString(xobj);
+        result7->obj.i=(long)((void*)pobj); result7->ref=result7->obj.i;
+        G__store_tempobject(*result7);
+      }
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_137_7_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MSupercutsCalcONOFF*)(G__getstructoffset()))->SetSupercutsAppliedName(*((const TString*)G__int(libp->para[0])));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_137_8_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      {
+const         TString *pobj,xobj=((const MSupercutsCalcONOFF*)(G__getstructoffset()))->GetSupercutsAppliedName();
+        pobj=new TString(xobj);
+        result7->obj.i=(long)((void*)pobj); result7->ref=result7->obj.i;
+        G__store_tempobject(*result7);
+      }
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_137_9_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MSupercutsCalcONOFF*)(G__getstructoffset()))->SetStoreAppliedSupercuts((Bool_t)G__int(libp->para[0]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_137_0_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MSupercutsCalcONOFF*)(G__getstructoffset()))->GetStoreAppliedSupercuts());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_137_1_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MSupercutsCalcONOFF*)(G__getstructoffset()))->SetVariableNotUseTheta((Bool_t)G__int(libp->para[0]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_137_2_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MSupercutsCalcONOFF*)(G__getstructoffset()))->GetVariableNotUseTheta());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_137_3_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MSupercutsCalcONOFF*)(G__getstructoffset()))->SetVariableUseStaticCuts((Bool_t)G__int(libp->para[0]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_137_4_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MSupercutsCalcONOFF*)(G__getstructoffset()))->GetVariableUseStaticCuts());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_137_5_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MSupercutsCalcONOFF*)(G__getstructoffset()))->SetHillasDistLengthWidthUpperLowerLimits((Double_t)G__double(libp->para[0]),(Double_t)G__double(libp->para[1])
+,(Double_t)G__double(libp->para[2]),(Double_t)G__double(libp->para[3])
+,(Double_t)G__double(libp->para[4]),(Double_t)G__double(libp->para[5]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_137_6_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MSupercutsCalcONOFF*)(G__getstructoffset()))->InitMapping((MHMatrix*)G__int(libp->para[0]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_137_7_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MSupercutsCalcONOFF*)(G__getstructoffset()))->StopMapping();
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_137_8_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,85,(long)MSupercutsCalcONOFF::Class());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_137_9_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,67,(long)MSupercutsCalcONOFF::Class_Name());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_137_0_2(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,115,(long)MSupercutsCalcONOFF::Class_Version());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_137_1_2(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      MSupercutsCalcONOFF::Dictionary();
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_137_2_2(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,85,(long)((const MSupercutsCalcONOFF*)(G__getstructoffset()))->IsA());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_137_3_2(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MSupercutsCalcONOFF*)(G__getstructoffset()))->ShowMembers(*(TMemberInspector*)libp->para[0].ref,(char*)G__int(libp->para[1]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_137_4_2(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MSupercutsCalcONOFF*)(G__getstructoffset()))->Streamer(*(TBuffer*)libp->para[0].ref);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_137_5_2(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MSupercutsCalcONOFF*)(G__getstructoffset()))->StreamerNVirtual(*(TBuffer*)libp->para[0].ref);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_137_6_2(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,67,(long)MSupercutsCalcONOFF::DeclFileName());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_137_7_2(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,105,(long)MSupercutsCalcONOFF::ImplFileLine());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_137_8_2(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,67,(long)MSupercutsCalcONOFF::ImplFileName());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_137_9_2(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,105,(long)MSupercutsCalcONOFF::DeclFileLine());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+// automatic copy constructor
+static int G__SuperCutsONOFFCint_137_0_3(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash)
+{
+   MSupercutsCalcONOFF *p;
+   p=new MSupercutsCalcONOFF(*(MSupercutsCalcONOFF*)G__int(libp->para[0]));
+   result7->obj.i = (long)p;
+   result7->ref = (long)p;
+   result7->type = 'u';
+   result7->tagnum = G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MSupercutsCalcONOFF);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+// automatic destructor
+typedef MSupercutsCalcONOFF G__TMSupercutsCalcONOFF;
+static int G__SuperCutsONOFFCint_137_1_3(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   if(0==G__getstructoffset()) return(1);
+   if(G__getaryconstruct())
+     if(G__PVOID==G__getgvp())
+       delete[] (MSupercutsCalcONOFF *)(G__getstructoffset());
+     else
+       for(int i=G__getaryconstruct()-1;i>=0;i--)
+         delete (MSupercutsCalcONOFF *)((G__getstructoffset())+sizeof(MSupercutsCalcONOFF)*i);
+   else  delete (MSupercutsCalcONOFF *)(G__getstructoffset());
+      G__setnull(result7);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+
+/* MHFindSignificanceONOFF */
+static int G__SuperCutsONOFFCint_159_7_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   MHFindSignificanceONOFF *p=NULL;
+   switch(libp->paran) {
+   case 2:
+      p = new MHFindSignificanceONOFF((const char*)G__int(libp->para[0]),(const char*)G__int(libp->para[1]));
+      break;
+   case 1:
+      p = new MHFindSignificanceONOFF((const char*)G__int(libp->para[0]));
+      break;
+   case 0:
+   if(G__getaryconstruct()) p=new MHFindSignificanceONOFF[G__getaryconstruct()];
+   else                    p=new MHFindSignificanceONOFF;
+      break;
+   }
+      result7->obj.i = (long)p;
+      result7->ref = (long)p;
+      result7->type = 'u';
+      result7->tagnum = G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MHFindSignificanceONOFF);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_9_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MHFindSignificanceONOFF*)(G__getstructoffset()))->FindSigmaONOFF(
+(TH1*)G__int(libp->para[0]),(TH1*)G__int(libp->para[1])
+,(Double_t)G__double(libp->para[2]),(Double_t)G__double(libp->para[3])
+,(Double_t)G__double(libp->para[4]),(Int_t)G__int(libp->para[5])
+,(Int_t)G__int(libp->para[6]),(Double_t)G__double(libp->para[7])
+,(Bool_t)G__int(libp->para[8]),(Bool_t)G__int(libp->para[9])
+,(Bool_t)G__int(libp->para[10]),(Bool_t)G__int(libp->para[11])
+,*((const TString*)G__int(libp->para[12]))));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_0_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MHFindSignificanceONOFF*)(G__getstructoffset()))->SetLimitsForOFFDataFit((Double_t)G__double(libp->para[0]),(Double_t)G__double(libp->para[1]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_1_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MHFindSignificanceONOFF*)(G__getstructoffset()))->SetAlphaSig((Double_t)G__double(libp->para[0]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_2_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MHFindSignificanceONOFF*)(G__getstructoffset()))->SetUseFittedQuantities((Bool_t)G__int(libp->para[0]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_3_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MHFindSignificanceONOFF*)(G__getstructoffset()))->SigmaLiMa((Double_t)G__double(libp->para[0]),(Double_t)G__double(libp->para[1])
+,(Double_t)G__double(libp->para[2]),(Double_t*)G__int(libp->para[3])));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_4_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MHFindSignificanceONOFF*)(G__getstructoffset()))->SigmaLiMaForm5((Double_t)G__double(libp->para[0]),(Double_t)G__double(libp->para[1])
+,(Double_t)G__double(libp->para[2]),(Double_t*)G__int(libp->para[3])));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_5_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MHFindSignificanceONOFF*)(G__getstructoffset()))->SigmaVsAlphaONOFF((TH1*)G__int(libp->para[0]),(TH1*)G__int(libp->para[1])
+,(Double_t)G__double(libp->para[2]),(Double_t)G__double(libp->para[3])
+,(Int_t)G__int(libp->para[4]),(Bool_t)G__int(libp->para[5])));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_6_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letdouble(result7,100,(double)((MHFindSignificanceONOFF*)(G__getstructoffset()))->GetSignificance());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_7_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MHFindSignificanceONOFF*)(G__getstructoffset()))->GetUseFittedQuantities());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_8_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MHFindSignificanceONOFF*)(G__getstructoffset()))->ComputeHistOFFNormalized());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_9_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   switch(libp->paran) {
+   case 1:
+      G__letint(result7,103,(long)((MHFindSignificanceONOFF*)(G__getstructoffset()))->DrawFit((const Option_t*)G__int(libp->para[0])));
+      break;
+   case 0:
+      G__letint(result7,103,(long)((MHFindSignificanceONOFF*)(G__getstructoffset()))->DrawFit());
+      break;
+   }
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_0_2(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MHFindSignificanceONOFF*)(G__getstructoffset()))->DrawHistOFF());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_1_2(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MHFindSignificanceONOFF*)(G__getstructoffset()))->DrawHistOFFNormalized());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_2_2(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letdouble(result7,102,(double)((const MHFindSignificanceONOFF*)(G__getstructoffset()))->GetDegree());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_3_2(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letdouble(result7,102,(double)((const MHFindSignificanceONOFF*)(G__getstructoffset()))->GetProb());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_4_2(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letdouble(result7,102,(double)((const MHFindSignificanceONOFF*)(G__getstructoffset()))->GetNdf());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_5_2(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letdouble(result7,102,(double)((const MHFindSignificanceONOFF*)(G__getstructoffset()))->GetGamma());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_6_2(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letdouble(result7,102,(double)((const MHFindSignificanceONOFF*)(G__getstructoffset()))->GetNon());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_7_2(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letdouble(result7,102,(double)((const MHFindSignificanceONOFF*)(G__getstructoffset()))->GetNex());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_8_2(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letdouble(result7,102,(double)((const MHFindSignificanceONOFF*)(G__getstructoffset()))->GetNbg());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_9_2(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letdouble(result7,102,(double)((const MHFindSignificanceONOFF*)(G__getstructoffset()))->GetSigLiMa1());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_0_3(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letdouble(result7,102,(double)((const MHFindSignificanceONOFF*)(G__getstructoffset()))->GetSigLiMa2());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_1_3(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letdouble(result7,102,(double)((const MHFindSignificanceONOFF*)(G__getstructoffset()))->GetSigLiMa3());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_2_3(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letdouble(result7,102,(double)((const MHFindSignificanceONOFF*)(G__getstructoffset()))->GetMbins());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_3_3(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letdouble(result7,102,(double)((const MHFindSignificanceONOFF*)(G__getstructoffset()))->GetAlphasi());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_4_3(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letdouble(result7,102,(double)((const MHFindSignificanceONOFF*)(G__getstructoffset()))->GetNexONOFF());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_5_3(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letdouble(result7,102,(double)((const MHFindSignificanceONOFF*)(G__getstructoffset()))->GetNexONOFFFitted());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_6_3(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   switch(libp->paran) {
+   case 1:
+      G__setnull(result7);
+      ((MHFindSignificanceONOFF*)(G__getstructoffset()))->SetRebin((Bool_t)G__int(libp->para[0]));
+      break;
+   case 0:
+      G__setnull(result7);
+      ((MHFindSignificanceONOFF*)(G__getstructoffset()))->SetRebin();
+      break;
+   }
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_7_3(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   switch(libp->paran) {
+   case 1:
+      G__setnull(result7);
+      ((MHFindSignificanceONOFF*)(G__getstructoffset()))->SetReduceDegree((Bool_t)G__int(libp->para[0]));
+      break;
+   case 0:
+      G__setnull(result7);
+      ((MHFindSignificanceONOFF*)(G__getstructoffset()))->SetReduceDegree();
+      break;
+   }
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_8_3(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MHFindSignificanceONOFF*)(G__getstructoffset()))->SetPsFilename((TPostScript*)G__int(libp->para[0]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_9_3(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   switch(libp->paran) {
+   case 1:
+      G__setnull(result7);
+      ((MHFindSignificanceONOFF*)(G__getstructoffset()))->PrintPoly((const Option_t*)G__int(libp->para[0]));
+      break;
+   case 0:
+      G__setnull(result7);
+      ((MHFindSignificanceONOFF*)(G__getstructoffset()))->PrintPoly();
+      break;
+   }
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_0_4(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   switch(libp->paran) {
+   case 1:
+      G__setnull(result7);
+      ((MHFindSignificanceONOFF*)(G__getstructoffset()))->PrintPolyOFF((const Option_t*)G__int(libp->para[0]));
+      break;
+   case 0:
+      G__setnull(result7);
+      ((MHFindSignificanceONOFF*)(G__getstructoffset()))->PrintPolyOFF();
+      break;
+   }
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_1_4(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   switch(libp->paran) {
+   case 1:
+      G__setnull(result7);
+      ((MHFindSignificanceONOFF*)(G__getstructoffset()))->PrintPolyGauss((const Option_t*)G__int(libp->para[0]));
+      break;
+   case 0:
+      G__setnull(result7);
+      ((MHFindSignificanceONOFF*)(G__getstructoffset()))->PrintPolyGauss();
+      break;
+   }
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_2_4(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,85,(long)MHFindSignificanceONOFF::Class());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_3_4(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,67,(long)MHFindSignificanceONOFF::Class_Name());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_4_4(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,115,(long)MHFindSignificanceONOFF::Class_Version());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_5_4(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      MHFindSignificanceONOFF::Dictionary();
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_6_4(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,85,(long)((const MHFindSignificanceONOFF*)(G__getstructoffset()))->IsA());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_7_4(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MHFindSignificanceONOFF*)(G__getstructoffset()))->ShowMembers(*(TMemberInspector*)libp->para[0].ref,(char*)G__int(libp->para[1]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_8_4(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MHFindSignificanceONOFF*)(G__getstructoffset()))->Streamer(*(TBuffer*)libp->para[0].ref);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_9_4(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MHFindSignificanceONOFF*)(G__getstructoffset()))->StreamerNVirtual(*(TBuffer*)libp->para[0].ref);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_0_5(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,67,(long)MHFindSignificanceONOFF::DeclFileName());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_1_5(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,105,(long)MHFindSignificanceONOFF::ImplFileLine());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_2_5(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,67,(long)MHFindSignificanceONOFF::ImplFileName());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_159_3_5(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,105,(long)MHFindSignificanceONOFF::DeclFileLine());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+// automatic copy constructor
+static int G__SuperCutsONOFFCint_159_4_5(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash)
+{
+   MHFindSignificanceONOFF *p;
+   p=new MHFindSignificanceONOFF(*(MHFindSignificanceONOFF*)G__int(libp->para[0]));
+   result7->obj.i = (long)p;
+   result7->ref = (long)p;
+   result7->type = 'u';
+   result7->tagnum = G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MHFindSignificanceONOFF);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+// automatic destructor
+typedef MHFindSignificanceONOFF G__TMHFindSignificanceONOFF;
+static int G__SuperCutsONOFFCint_159_5_5(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   if(0==G__getstructoffset()) return(1);
+   if(G__getaryconstruct())
+     if(G__PVOID==G__getgvp())
+       delete[] (MHFindSignificanceONOFF *)(G__getstructoffset());
+     else
+       for(int i=G__getaryconstruct()-1;i>=0;i--)
+         delete (MHFindSignificanceONOFF *)((G__getstructoffset())+sizeof(MHFindSignificanceONOFF)*i);
+   else  delete (MHFindSignificanceONOFF *)(G__getstructoffset());
+      G__setnull(result7);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+
+/* MFindSupercutsONOFF */
+static int G__SuperCutsONOFFCint_205_0_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   MFindSupercutsONOFF *p=NULL;
+   switch(libp->paran) {
+   case 2:
+      p = new MFindSupercutsONOFF((const char*)G__int(libp->para[0]),(const char*)G__int(libp->para[1]));
+      break;
+   case 1:
+      p = new MFindSupercutsONOFF((const char*)G__int(libp->para[0]));
+      break;
+   case 0:
+   if(G__getaryconstruct()) p=new MFindSupercutsONOFF[G__getaryconstruct()];
+   else                    p=new MFindSupercutsONOFF;
+      break;
+   }
+      result7->obj.i = (long)p;
+      result7->ref = (long)p;
+      result7->type = 'u';
+      result7->tagnum = G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MFindSupercutsONOFF);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_2_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFF*)(G__getstructoffset()))->SetFilenameTraining(*(TString*)libp->para[0].ref,(const Int_t)G__int(libp->para[1]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_3_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFF*)(G__getstructoffset()))->SetFilenameTest(*(TString*)libp->para[0].ref,(const Int_t)G__int(libp->para[1]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_4_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFF*)(G__getstructoffset()))->SetFilenameParam(*(TString*)libp->para[0].ref);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_5_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFF*)(G__getstructoffset()))->SetHadronnessName(*(TString*)libp->para[0].ref);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_6_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFF*)(G__getstructoffset()))->SetHadronnessNameOFF(*(TString*)libp->para[0].ref);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_7_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFF*)(G__getstructoffset()))->SetSupercutsAppliedTreeNames();
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_8_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFF*)(G__getstructoffset()))->SetAlphaDistributionsRootFilename(*(TString*)libp->para[0].ref);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_9_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFF*)(G__getstructoffset()))->SetAlphaSig((Double_t)G__double(libp->para[0])));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_0_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFF*)(G__getstructoffset()))->SetAlphaBkgMin((Double_t)G__double(libp->para[0])));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_1_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFF*)(G__getstructoffset()))->SetAlphaBkgMax((Double_t)G__double(libp->para[0])));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_2_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFF*)(G__getstructoffset()))->CheckAlphaSigBkg());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_3_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFF*)(G__getstructoffset()))->SetUseFittedQuantities((Bool_t)G__int(libp->para[0]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_4_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFF*)(G__getstructoffset()))->SetPostScriptFile((TPostScript*)G__int(libp->para[0]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_5_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFF*)(G__getstructoffset()))->SetPostScriptFile2(*(TPostScript*)libp->para[0].ref);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_6_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFF*)(G__getstructoffset()))->SetPsFilenameString(*((const TString*)G__int(libp->para[0])));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_7_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFF*)(G__getstructoffset()))->SetMatrixFilter((MFilter*)G__int(libp->para[0]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_8_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFF*)(G__getstructoffset()))->DefineTrainMatrix(*(TString*)libp->para[0].ref,*(MH3*)libp->para[1].ref
+,(const Int_t)G__int(libp->para[2]),*(TString*)libp->para[3].ref));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_9_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFF*)(G__getstructoffset()))->DefineTestMatrix(*(TString*)libp->para[0].ref,*(MH3*)libp->para[1].ref
+,(const Int_t)G__int(libp->para[2]),*(TString*)libp->para[3].ref));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_0_2(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFF*)(G__getstructoffset()))->DefineTrainTestMatrix(*(TString*)libp->para[0].ref,*(MH3*)libp->para[1].ref
+,(const Int_t)G__int(libp->para[2]),(const Int_t)G__int(libp->para[3])
+,*(TString*)libp->para[4].ref,*(TString*)libp->para[5].ref));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_1_2(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFF*)(G__getstructoffset()))->DefineTrainTestMatrixThetaRange(
+*(TString*)libp->para[0].ref,(const Double_t)G__double(libp->para[1])
+,(const Double_t)G__double(libp->para[2]),(Double_t)G__double(libp->para[3])
+,(Double_t)G__double(libp->para[4]),*(TString*)libp->para[5].ref
+,*(TString*)libp->para[6].ref));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_2_2(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFF*)(G__getstructoffset()))->DefineTrainTestMatrixOFFThetaRange(
+*(TString*)libp->para[0].ref,(const Double_t)G__double(libp->para[1])
+,(const Double_t)G__double(libp->para[2]),(Double_t)G__double(libp->para[3])
+,(Double_t)G__double(libp->para[4]),*(TString*)libp->para[5].ref
+,*(TString*)libp->para[6].ref));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_3_2(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,85,(long)((MFindSupercutsONOFF*)(G__getstructoffset()))->GetMatrixTrain());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_4_2(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,85,(long)((MFindSupercutsONOFF*)(G__getstructoffset()))->GetMatrixTest());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_5_2(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,85,(long)((MFindSupercutsONOFF*)(G__getstructoffset()))->GetMatrixTrainOFF());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_6_2(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,85,(long)((MFindSupercutsONOFF*)(G__getstructoffset()))->GetMatrixTestOFF());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_7_2(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFF*)(G__getstructoffset()))->SetUseOrigDistribution((Bool_t)G__int(libp->para[0]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_8_2(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFF*)(G__getstructoffset()))->ReadMatrix(*(TString*)libp->para[0].ref,*(TString*)libp->para[1].ref));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_9_2(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFF*)(G__getstructoffset()))->ReadMatrixOFF(*(TString*)libp->para[0].ref,*(TString*)libp->para[1].ref));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_0_3(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFF*)(G__getstructoffset()))->ComputeNormFactorTrain());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_1_3(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFF*)(G__getstructoffset()))->ComputeNormFactorTest());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_2_3(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFF*)(G__getstructoffset()))->FindParams(*((TString*)G__int(libp->para[0])),*(TArrayD*)libp->para[1].ref
+,*(TArrayD*)libp->para[2].ref));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_3_3(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFF*)(G__getstructoffset()))->TestParamsOnTestSample());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_4_3(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFF*)(G__getstructoffset()))->TestParamsOnTrainSample());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_5_3(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFF*)(G__getstructoffset()))->SetThetaRange((Double_t)G__double(libp->para[0]),(Double_t)G__double(libp->para[1])));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_6_3(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFF*)(G__getstructoffset()))->SetSizeRange((Double_t)G__double(libp->para[0]),(Double_t)G__double(libp->para[1])));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_7_3(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFF*)(G__getstructoffset()))->SetAlphaPlotBinining((Int_t)G__int(libp->para[0]),(Double_t)G__double(libp->para[1])
+,(Double_t)G__double(libp->para[2]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_8_3(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letdouble(result7,100,(double)((MFindSupercutsONOFF*)(G__getstructoffset()))->GetNormFactorTrain());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_9_3(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letdouble(result7,100,(double)((MFindSupercutsONOFF*)(G__getstructoffset()))->GetNormFactorTest());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_0_4(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letdouble(result7,100,(double)((MFindSupercutsONOFF*)(G__getstructoffset()))->GetSigmaLiMaTrain());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_1_4(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letdouble(result7,100,(double)((MFindSupercutsONOFF*)(G__getstructoffset()))->GetSigmaLiMaTest());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_2_4(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letdouble(result7,100,(double)((MFindSupercutsONOFF*)(G__getstructoffset()))->GetNexTrain());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_3_4(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letdouble(result7,100,(double)((MFindSupercutsONOFF*)(G__getstructoffset()))->GetNexTest());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_4_4(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letdouble(result7,100,(double)((MFindSupercutsONOFF*)(G__getstructoffset()))->GetAlphaSig());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_5_4(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letdouble(result7,100,(double)((MFindSupercutsONOFF*)(G__getstructoffset()))->GetAlphaBkgMin());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_6_4(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letdouble(result7,100,(double)((MFindSupercutsONOFF*)(G__getstructoffset()))->GetAlphaBkgMax());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_7_4(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFF*)(G__getstructoffset()))->GetUseFittedQuantities());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_8_4(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFF*)(G__getstructoffset()))->GetSkipOptimization());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_9_4(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFF*)(G__getstructoffset()))->GetUseInitialSCParams());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_0_5(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFF*)(G__getstructoffset()))->SetGammaEfficiency((Double_t)G__double(libp->para[0])));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_1_5(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letdouble(result7,100,(double)((MFindSupercutsONOFF*)(G__getstructoffset()))->GetGammaEfficiency());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_2_5(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFF*)(G__getstructoffset()))->SetTuneNormFactor((Bool_t)G__int(libp->para[0]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_3_5(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFF*)(G__getstructoffset()))->SetNormFactorFromAlphaBkg((Bool_t)G__int(libp->para[0]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_4_5(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFF*)(G__getstructoffset()))->SetSkipOptimization((Bool_t)G__int(libp->para[0]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_5_5(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFF*)(G__getstructoffset()))->SetUseInitialSCParams((Bool_t)G__int(libp->para[0]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_6_5(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFF*)(G__getstructoffset()))->SetVariableNotUseTheta((Bool_t)G__int(libp->para[0]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_7_5(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFF*)(G__getstructoffset()))->GetVariableNotUseTheta());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_8_5(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFF*)(G__getstructoffset()))->SetVariableUseStaticCuts((Bool_t)G__int(libp->para[0]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_9_5(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFF*)(G__getstructoffset()))->GetVariableUseStaticCuts());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_0_6(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,85,(long)MFindSupercutsONOFF::Class());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_1_6(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,67,(long)MFindSupercutsONOFF::Class_Name());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_2_6(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,115,(long)MFindSupercutsONOFF::Class_Version());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_3_6(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      MFindSupercutsONOFF::Dictionary();
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_4_6(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,85,(long)((const MFindSupercutsONOFF*)(G__getstructoffset()))->IsA());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_5_6(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFF*)(G__getstructoffset()))->ShowMembers(*(TMemberInspector*)libp->para[0].ref,(char*)G__int(libp->para[1]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_6_6(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFF*)(G__getstructoffset()))->Streamer(*(TBuffer*)libp->para[0].ref);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_7_6(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFF*)(G__getstructoffset()))->StreamerNVirtual(*(TBuffer*)libp->para[0].ref);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_8_6(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,67,(long)MFindSupercutsONOFF::DeclFileName());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_9_6(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,105,(long)MFindSupercutsONOFF::ImplFileLine());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_0_7(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,67,(long)MFindSupercutsONOFF::ImplFileName());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_205_1_7(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,105,(long)MFindSupercutsONOFF::DeclFileLine());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+// automatic copy constructor
+static int G__SuperCutsONOFFCint_205_2_7(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash)
+{
+   MFindSupercutsONOFF *p;
+   p=new MFindSupercutsONOFF(*(MFindSupercutsONOFF*)G__int(libp->para[0]));
+   result7->obj.i = (long)p;
+   result7->ref = (long)p;
+   result7->type = 'u';
+   result7->tagnum = G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MFindSupercutsONOFF);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+// automatic destructor
+typedef MFindSupercutsONOFF G__TMFindSupercutsONOFF;
+static int G__SuperCutsONOFFCint_205_3_7(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   if(0==G__getstructoffset()) return(1);
+   if(G__getaryconstruct())
+     if(G__PVOID==G__getgvp())
+       delete[] (MFindSupercutsONOFF *)(G__getstructoffset());
+     else
+       for(int i=G__getaryconstruct()-1;i>=0;i--)
+         delete (MFindSupercutsONOFF *)((G__getstructoffset())+sizeof(MFindSupercutsONOFF)*i);
+   else  delete (MFindSupercutsONOFF *)(G__getstructoffset());
+      G__setnull(result7);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+
+/* MFindSupercutsONOFFThetaLoop */
+static int G__SuperCutsONOFFCint_206_0_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   MFindSupercutsONOFFThetaLoop *p=NULL;
+   switch(libp->paran) {
+   case 2:
+      p = new MFindSupercutsONOFFThetaLoop((const char*)G__int(libp->para[0]),(const char*)G__int(libp->para[1]));
+      break;
+   case 1:
+      p = new MFindSupercutsONOFFThetaLoop((const char*)G__int(libp->para[0]));
+      break;
+   case 0:
+   if(G__getaryconstruct()) p=new MFindSupercutsONOFFThetaLoop[G__getaryconstruct()];
+   else                    p=new MFindSupercutsONOFFThetaLoop;
+      break;
+   }
+      result7->obj.i = (long)p;
+      result7->ref = (long)p;
+      result7->type = 'u';
+      result7->tagnum = G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MFindSupercutsONOFFThetaLoop);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_2_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->SetHadronnessName(*(TString*)libp->para[0].ref);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_3_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->SetHadronnessNameOFF(*(TString*)libp->para[0].ref);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_4_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->SetPathForFiles(*(TString*)libp->para[0].ref);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_5_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->SetDataONOFFRootFilenames(*(TString*)libp->para[0].ref,*(TString*)libp->para[1].ref);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_6_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->SetALLNames());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_7_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->SetNamesManually((TString*)G__int(libp->para[0]),(TString*)G__int(libp->para[1])
+,(TString*)G__int(libp->para[2]),(TString*)G__int(libp->para[3])
+,(TString*)G__int(libp->para[4]),(TString*)G__int(libp->para[5])));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_8_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->SetAlphaDistributionsRootFilename(*(TString*)libp->para[0].ref));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_9_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->SetAlphaSig((Double_t)G__double(libp->para[0])));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_0_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->SetAlphaBkgMin((Double_t)G__double(libp->para[0])));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_1_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->SetAlphaBkgMax((Double_t)G__double(libp->para[0])));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_2_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->CheckAlphaSigBkg());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_3_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->SetPostScriptFile((TPostScript*)G__int(libp->para[0]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_4_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->SetCosThetaRangeVector(*(TArrayD*)libp->para[0].ref));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_5_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->SetThetaRange((Int_t)G__int(libp->para[0])));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_6_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->SetAlphaPlotBinining((Int_t)G__int(libp->para[0]),(Double_t)G__double(libp->para[1])
+,(Double_t)G__double(libp->para[2]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_7_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->SetNormFactorTrainHist());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_8_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->SetNormFactorTestHist());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_9_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->SetSigmaLiMaTrainHist());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_0_2(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->SetSigmaLiMaTestHist());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_1_2(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->SetNexTrainHist());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_2_2(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->SetNexTestHist());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_3_2(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->SetNexSigmaLiMaNormFactorNEvtsTrainTestHist());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_4_2(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->SetSuccessfulThetaBinsHist());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_5_2(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->WriteNexSigmaLiMaNormFactorNEvtsTrainTestHistToFile();
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_6_2(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->WriteSuccessfulThetaBinsHistToFile();
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_7_2(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->SetInitSCPar(*(TArrayD*)libp->para[0].ref));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_8_2(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->SetInitSCParSteps(*(TArrayD*)libp->para[0].ref));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_9_2(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->ReadSCParamsFromAsciiFile((const char*)G__int(libp->para[0]),(Int_t)G__int(libp->para[1])));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_0_3(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->SetFractionTrainTestOnOffEvents((Double_t)G__double(libp->para[0]),(Double_t)G__double(libp->para[1])
+,(Double_t)G__double(libp->para[2]),(Double_t)G__double(libp->para[3]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_1_3(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->SetTuneNormFactor((Bool_t)G__int(libp->para[0]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_2_3(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->SetGammaEfficiency((Double_t)G__double(libp->para[0])));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_3_3(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->SetNormFactorFromAlphaBkg((Bool_t)G__int(libp->para[0]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_4_3(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->SetUseFittedQuantities((Bool_t)G__int(libp->para[0]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_5_3(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->SetReadMatricesFromFile((Bool_t)G__int(libp->para[0]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_6_3(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->SetTrainParameters((Bool_t)G__int(libp->para[0]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_7_3(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->SetTestParameters((Bool_t)G__int(libp->para[0]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_8_3(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->SetSkipOptimization((Bool_t)G__int(libp->para[0]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_9_3(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->SetUseInitialSCParams((Bool_t)G__int(libp->para[0]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_0_4(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->SetVariableNotUseTheta((Bool_t)G__int(libp->para[0]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_1_4(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->GetVariableNotUseTheta());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_2_4(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->SetVariableUseStaticCuts((Bool_t)G__int(libp->para[0]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_3_4(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->GetVariableUseStaticCuts());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_4_4(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->SetSizeRange((Double_t)G__double(libp->para[0]),(Double_t)G__double(libp->para[1]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_5_4(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->LoopOverThetaRanges());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_6_4(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->ComputeNexSignificanceVSAlphaSig());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_7_4(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->ComputeOverallSignificance((Bool_t)G__int(libp->para[0]),(Bool_t)G__int(libp->para[1])));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_8_4(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letdouble(result7,100,(double)((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->GetOverallNexTrain());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_9_4(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letdouble(result7,100,(double)((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->GetOverallNexTest());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_0_5(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letdouble(result7,100,(double)((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->GetOverallSigmaLiMaTrain());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_1_5(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letdouble(result7,100,(double)((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->GetOverallSigmaLiMaTest());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_2_5(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letdouble(result7,100,(double)((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->GetGammaEfficiency());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_3_5(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letdouble(result7,100,(double)((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->GetAlphaSig());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_4_5(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letdouble(result7,100,(double)((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->GetAlphaBkgMin());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_5_5(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letdouble(result7,100,(double)((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->GetAlphaBkgMax());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_6_5(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->GetSkipOptimization());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_7_5(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,103,(long)((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->GetUseFittedQuantities());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_8_5(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,85,(long)MFindSupercutsONOFFThetaLoop::Class());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_9_5(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,67,(long)MFindSupercutsONOFFThetaLoop::Class_Name());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_0_6(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,115,(long)MFindSupercutsONOFFThetaLoop::Class_Version());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_1_6(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      MFindSupercutsONOFFThetaLoop::Dictionary();
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_2_6(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,85,(long)((const MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->IsA());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_3_6(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->ShowMembers(*(TMemberInspector*)libp->para[0].ref,(char*)G__int(libp->para[1]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_4_6(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->Streamer(*(TBuffer*)libp->para[0].ref);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_5_6(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MFindSupercutsONOFFThetaLoop*)(G__getstructoffset()))->StreamerNVirtual(*(TBuffer*)libp->para[0].ref);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_6_6(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,67,(long)MFindSupercutsONOFFThetaLoop::DeclFileName());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_7_6(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,105,(long)MFindSupercutsONOFFThetaLoop::ImplFileLine());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_8_6(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,67,(long)MFindSupercutsONOFFThetaLoop::ImplFileName());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__SuperCutsONOFFCint_206_9_6(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,105,(long)MFindSupercutsONOFFThetaLoop::DeclFileLine());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+// automatic copy constructor
+static int G__SuperCutsONOFFCint_206_0_7(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash)
+{
+   MFindSupercutsONOFFThetaLoop *p;
+   p=new MFindSupercutsONOFFThetaLoop(*(MFindSupercutsONOFFThetaLoop*)G__int(libp->para[0]));
+   result7->obj.i = (long)p;
+   result7->ref = (long)p;
+   result7->type = 'u';
+   result7->tagnum = G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MFindSupercutsONOFFThetaLoop);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+// automatic destructor
+typedef MFindSupercutsONOFFThetaLoop G__TMFindSupercutsONOFFThetaLoop;
+static int G__SuperCutsONOFFCint_206_1_7(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   if(0==G__getstructoffset()) return(1);
+   if(G__getaryconstruct())
+     if(G__PVOID==G__getgvp())
+       delete[] (MFindSupercutsONOFFThetaLoop *)(G__getstructoffset());
+     else
+       for(int i=G__getaryconstruct()-1;i>=0;i--)
+         delete (MFindSupercutsONOFFThetaLoop *)((G__getstructoffset())+sizeof(MFindSupercutsONOFFThetaLoop)*i);
+   else  delete (MFindSupercutsONOFFThetaLoop *)(G__getstructoffset());
+      G__setnull(result7);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+
+/* Setting up global function */
+
+/*********************************************************
+* Member function Stub
+*********************************************************/
+
+/* MFRandomSplit */
+
+/* MTSupercutsApplied */
+
+/* MSupercutsCalcONOFF */
+
+/* MHFindSignificanceONOFF */
+
+/* MFindSupercutsONOFF */
+
+/* MFindSupercutsONOFFThetaLoop */
+
+/*********************************************************
+* Global function Stub
+*********************************************************/
+
+/*********************************************************
+* Get size of pointer to member function
+*********************************************************/
+class G__Sizep2memfuncSuperCutsONOFFCint {
+ public:
+  G__Sizep2memfuncSuperCutsONOFFCint() {p=&G__Sizep2memfuncSuperCutsONOFFCint::sizep2memfunc;}
+    size_t sizep2memfunc() { return(sizeof(p)); }
+  private:
+    size_t (G__Sizep2memfuncSuperCutsONOFFCint::*p)();
+};
+
+size_t G__get_sizep2memfuncSuperCutsONOFFCint()
+{
+  G__Sizep2memfuncSuperCutsONOFFCint a;
+  G__setsizep2memfunc((int)a.sizep2memfunc());
+  return((size_t)a.sizep2memfunc());
+}
+
+
+/*********************************************************
+* virtual base class offset calculation interface
+*********************************************************/
+
+   /* Setting up class inheritance */
+
+/*********************************************************
+* Inheritance information setup/
+*********************************************************/
+extern "C" void G__cpp_setup_inheritanceSuperCutsONOFFCint() {
+
+   /* Setting up class inheritance */
+   if(0==G__getnumbaseclass(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MFRandomSplit))) {
+     MFRandomSplit *G__Lderived;
+     G__Lderived=(MFRandomSplit*)0x1000;
+     {
+       MFilter *G__Lpbase=(MFilter*)G__Lderived;
+       G__inheritance_setup(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MFRandomSplit),G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MFilter),(long)G__Lpbase-(long)G__Lderived,1,1);
+     }
+     {
+       MTask *G__Lpbase=(MTask*)G__Lderived;
+       G__inheritance_setup(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MFRandomSplit),G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MTask),(long)G__Lpbase-(long)G__Lderived,1,0);
+     }
+     {
+       MInputStreamID *G__Lpbase=(MInputStreamID*)G__Lderived;
+       G__inheritance_setup(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MFRandomSplit),G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MInputStreamID),(long)G__Lpbase-(long)G__Lderived,1,0);
+     }
+     {
+       MParContainer *G__Lpbase=(MParContainer*)G__Lderived;
+       G__inheritance_setup(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MFRandomSplit),G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MParContainer),(long)G__Lpbase-(long)G__Lderived,1,0);
+     }
+     {
+       TObject *G__Lpbase=(TObject*)G__Lderived;
+       G__inheritance_setup(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MFRandomSplit),G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TObject),(long)G__Lpbase-(long)G__Lderived,1,0);
+     }
+   }
+   if(0==G__getnumbaseclass(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MTSupercutsApplied))) {
+     MTSupercutsApplied *G__Lderived;
+     G__Lderived=(MTSupercutsApplied*)0x1000;
+     {
+       MParContainer *G__Lpbase=(MParContainer*)G__Lderived;
+       G__inheritance_setup(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MTSupercutsApplied),G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MParContainer),(long)G__Lpbase-(long)G__Lderived,1,1);
+     }
+     {
+       TObject *G__Lpbase=(TObject*)G__Lderived;
+       G__inheritance_setup(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MTSupercutsApplied),G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TObject),(long)G__Lpbase-(long)G__Lderived,1,0);
+     }
+   }
+   if(0==G__getnumbaseclass(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MSupercutsCalcONOFF))) {
+     MSupercutsCalcONOFF *G__Lderived;
+     G__Lderived=(MSupercutsCalcONOFF*)0x1000;
+     {
+       MTask *G__Lpbase=(MTask*)G__Lderived;
+       G__inheritance_setup(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MSupercutsCalcONOFF),G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MTask),(long)G__Lpbase-(long)G__Lderived,1,1);
+     }
+     {
+       MInputStreamID *G__Lpbase=(MInputStreamID*)G__Lderived;
+       G__inheritance_setup(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MSupercutsCalcONOFF),G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MInputStreamID),(long)G__Lpbase-(long)G__Lderived,1,0);
+     }
+     {
+       MParContainer *G__Lpbase=(MParContainer*)G__Lderived;
+       G__inheritance_setup(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MSupercutsCalcONOFF),G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MParContainer),(long)G__Lpbase-(long)G__Lderived,1,0);
+     }
+     {
+       TObject *G__Lpbase=(TObject*)G__Lderived;
+       G__inheritance_setup(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MSupercutsCalcONOFF),G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TObject),(long)G__Lpbase-(long)G__Lderived,1,0);
+     }
+   }
+   if(0==G__getnumbaseclass(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MHFindSignificanceONOFF))) {
+     MHFindSignificanceONOFF *G__Lderived;
+     G__Lderived=(MHFindSignificanceONOFF*)0x1000;
+     {
+       MH *G__Lpbase=(MH*)G__Lderived;
+       G__inheritance_setup(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MHFindSignificanceONOFF),G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MH),(long)G__Lpbase-(long)G__Lderived,1,1);
+     }
+     {
+       MParContainer *G__Lpbase=(MParContainer*)G__Lderived;
+       G__inheritance_setup(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MHFindSignificanceONOFF),G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MParContainer),(long)G__Lpbase-(long)G__Lderived,1,0);
+     }
+     {
+       TObject *G__Lpbase=(TObject*)G__Lderived;
+       G__inheritance_setup(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MHFindSignificanceONOFF),G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TObject),(long)G__Lpbase-(long)G__Lderived,1,0);
+     }
+   }
+   if(0==G__getnumbaseclass(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MFindSupercutsONOFF))) {
+     MFindSupercutsONOFF *G__Lderived;
+     G__Lderived=(MFindSupercutsONOFF*)0x1000;
+     {
+       MParContainer *G__Lpbase=(MParContainer*)G__Lderived;
+       G__inheritance_setup(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MFindSupercutsONOFF),G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MParContainer),(long)G__Lpbase-(long)G__Lderived,1,1);
+     }
+     {
+       TObject *G__Lpbase=(TObject*)G__Lderived;
+       G__inheritance_setup(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MFindSupercutsONOFF),G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TObject),(long)G__Lpbase-(long)G__Lderived,1,0);
+     }
+   }
+   if(0==G__getnumbaseclass(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MFindSupercutsONOFFThetaLoop))) {
+     MFindSupercutsONOFFThetaLoop *G__Lderived;
+     G__Lderived=(MFindSupercutsONOFFThetaLoop*)0x1000;
+     {
+       MParContainer *G__Lpbase=(MParContainer*)G__Lderived;
+       G__inheritance_setup(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MFindSupercutsONOFFThetaLoop),G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MParContainer),(long)G__Lpbase-(long)G__Lderived,1,1);
+     }
+     {
+       TObject *G__Lpbase=(TObject*)G__Lderived;
+       G__inheritance_setup(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MFindSupercutsONOFFThetaLoop),G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TObject),(long)G__Lpbase-(long)G__Lderived,1,0);
+     }
+   }
+}
+
+/*********************************************************
+* typedef information setup/
+*********************************************************/
+extern "C" void G__cpp_setup_typetableSuperCutsONOFFCint() {
+
+   /* Setting up typedef entry */
+   G__search_typename2("Int_t",105,-1,0,
+-1);
+   G__setnewtype(-1,"Signed integer 4 bytes (int)",0);
+   G__search_typename2("Float_t",102,-1,0,
+-1);
+   G__setnewtype(-1,"Float 4 bytes (float)",0);
+   G__search_typename2("Double_t",100,-1,0,
+-1);
+   G__setnewtype(-1,"Float 8 bytes (double)",0);
+   G__search_typename2("Bool_t",103,-1,0,
+-1);
+   G__setnewtype(-1,"Boolean (0=false, 1=true) (bool)",0);
+   G__search_typename2("Version_t",115,-1,0,
+-1);
+   G__setnewtype(-1,"Class version identifier (short)",0);
+   G__search_typename2("Option_t",99,-1,256,
+-1);
+   G__setnewtype(-1,"Option string (const char)",0);
+}
+
+/*********************************************************
+* Data Member information setup/
+*********************************************************/
+
+   /* Setting up class,struct,union tag member variable */
+
+   /* MFRandomSplit */
+static void G__setup_memvarMFRandomSplit(void) {
+   G__tag_memvar_setup(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MFRandomSplit));
+   { MFRandomSplit *p; p=(MFRandomSplit*)0x1000; if (p) { }
+   G__memvar_setup((void*)NULL,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"fNumSelectedEvts=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fProb=",0,"probability with which the result should be kTRUE");
+   G__memvar_setup((void*)NULL,103,0,0,-1,G__defined_typename("Bool_t"),-1,4,"fResult=",0,"Result returned by IsExpressionTrue");
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TClass),-1,-2,4,"fgIsA=",0,(char*)NULL);
+   }
+   G__tag_memvar_reset();
+}
+
+
+   /* MTSupercutsApplied */
+static void G__setup_memvarMTSupercutsApplied(void) {
+   G__tag_memvar_setup(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MTSupercutsApplied));
+   { MTSupercutsApplied *p; p=(MTSupercutsApplied*)0x1000; if (p) { }
+   G__memvar_setup((void*)NULL,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"fNCutParameters=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"fNShowerParameters=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,68,0,0,-1,G__defined_typename("Double_t"),-1,4,"fCutParameters=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,68,0,0,-1,G__defined_typename("Double_t"),-1,4,"fShowerParameters=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TTree),-1,-1,4,"fRootTree=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,103,0,0,-1,G__defined_typename("Bool_t"),-1,4,"fBranchesCreated=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,-1,4,"fCutParamBranchName=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,-1,4,"fShowerParamBranchName=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,-1,4,"fCutParametersNamesTypes=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,-1,4,"fShowerParametersNamesTypes=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TClass),-1,-2,4,"fgIsA=",0,(char*)NULL);
+   }
+   G__tag_memvar_reset();
+}
+
+
+   /* MSupercutsCalcONOFF */
+static void G__setup_memvarMSupercutsCalcONOFF(void) {
+   G__tag_memvar_setup(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MSupercutsCalcONOFF));
+   { MSupercutsCalcONOFF *p; p=(MSupercutsCalcONOFF*)0x1000; if (p) { }
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MHillas),-1,-1,4,"fHil=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MHillasSrc),-1,-1,4,"fHilSrc=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MHillasExt),-1,-1,4,"fHilExt=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MNewImagePar),-1,-1,4,"fNewPar=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MPointingPos),-1,-1,4,"fPointPos=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MHadronness),-1,-1,4,"fHadronness=",0,"! output container for hadronness");
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MTSupercutsApplied),-1,-1,4,"fSupercutsApplied=",0,"output container for applied supercuts");
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MSupercuts),-1,-1,4,"fSuper=",0,"container for supercut parameters");
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,-1,4,"fHadronnessName=",0,"name of container to store hadronness");
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,-1,4,"fSupercutsAppliedName=",0,"name of the container to store applied supercuts");
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,-1,4,"fHilName=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,-1,4,"fHilSrcName=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,-1,4,"fHilExtName=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,-1,4,"fNewParName=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,-1,4,"fSuperName=",0,"name of container for supercut parameters");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fMm2Deg=",0,"!");
+   G__memvar_setup((void*)NULL,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"fMap[11]=",0,"!");
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MHMatrix),-1,-1,4,"fMatrix=",0,"!");
+   G__memvar_setup((void*)NULL,103,0,0,-1,G__defined_typename("Bool_t"),-1,4,"fStoreAppliedSupercuts=",0,"Boolean variable used to decided wether to store (kTRUE) or not (kFALSE) the supercuts applied");
+   G__memvar_setup((void*)NULL,103,0,0,-1,G__defined_typename("Bool_t"),-1,4,"fNotUseTheta=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,103,0,0,-1,G__defined_typename("Bool_t"),-1,4,"fUseStaticCuts=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,103,0,0,-1,G__defined_typename("Bool_t"),-1,4,"fUseDist=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fSizeOffset=",0,"photons");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fDistOffset=",0,"degrees   NOT USED FOR THE TIME BEING");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fThetaOffset=",0,"degrees   NOT USED FOR THE TIME BEING");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fDistUpperLimit=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fLengthUpperLimit=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fWidthUpperLimit=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fDistLowerLimit=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fLengthLowerLimit=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fWidthLowerLimit=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fLeakage1UpperLimit=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fLengthOverWidthUpperLimit=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TClass),-1,-2,4,"fgIsA=",0,(char*)NULL);
+   }
+   G__tag_memvar_reset();
+}
+
+
+   /* MHFindSignificanceONOFF */
+static void G__setup_memvarMHFindSignificanceONOFF(void) {
+   G__tag_memvar_setup(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MHFindSignificanceONOFF));
+   { MHFindSignificanceONOFF *p; p=(MHFindSignificanceONOFF*)0x1000; if (p) { }
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TH1),-1,-1,4,"fHistOrig=",0,"original plot of |alpha| (0.0 to 90.0 degrees)");
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TH1),-1,-1,4,"fHist=",0,"copy of fHistOrig or rebinned histogram");
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TH1),-1,-1,4,"fHistOrigOFF=",0,"original plot of |alpha| (0.0 to 90.0 degrees)");
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TH1),-1,-1,4,"fHistOFF=",0,"copy of fHistOrig or rebinned histogram");
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TH1),-1,-1,4,"fHistOFFNormalized=",0,"fHistOFF normalized (contents and errors) with ");
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TPostScript),-1,-1,4,"fPsFilename=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,-1,4,"fPsFilenameString=",0,"Name of the file where plots will be stored while the ");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fAlphamin=",0,"requested lower limit of fit range");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fAlphammm=",0,"center of fit range");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fAlphamax=",0,"requested lower limit of fit range");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fAlphaminOFF=",0,"requested lower limit of fit range for OFF data");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fAlphamaxOFF=",0,"requested lower limit of fit range for OFF data");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fAlphami=",0,"actual lower limit of fit range ");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fAlphamm=",0,"actual center of fit range ");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fAlphama=",0,"actual upper limit of fit range");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fAlphasig=",0,"requested signal range");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fAlphasi=",0,"actual signal range");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fAlphasiOFF=",0,"actual signal range for OFF data");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fAlphalow=",0,"requested lower edge of signal range");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fAlphalo=",0,"actual lower edge of signal range");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fAlphahig=",0,"requested upper edge of background range");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fAlphahi=",0,"actual upper edge of background range");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fNon=",0,"total number of events in signal region");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fNbg=",0,"number of background events in signal region");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fNex=",0,"number of excess events in signal region");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fdNon=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fdNbg=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fdNex=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fNbgtot=",0,"total number of events in background region");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fNbgtotFitted=",0,"fitted total no. of events in background region");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fdNbgtotFitted=",0,"fitted error of this number");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fNexONOFF=",0,"number of excess events (ON-OFF) ");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fNexONOFFFitted=",0,"number of excess events (ON-OFF fitted) ");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fdNexONOFF=",0,"error in number of excess events (ON-OFF) ");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fdNexONOFFFitted=",0,"error in number of excess events (ON-OFF fitted) ");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fNoffTot=",0,"Total number of OFF events");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fNoffSig=",0,"Number of OFF events in \"signal\" region ");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fNoffBg=",0,"Number of OFF events in \"background\" region");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fdNoffTot=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fdNoffSig=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fdNoffBg=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fNoffTotFitted=",0,"Total number of OFF events");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fNoffSigFitted=",0,"Number of OFF events in \"signal\" region ");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fNoffBgFitted=",0,"Number of OFF events in \"background\" region");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fdNoffTotFitted=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fdNoffSigFitted=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fdNoffBgFitted=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,103,0,0,-1,G__defined_typename("Bool_t"),-1,4,"fUseFittedQuantities=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,103,0,0,-1,G__defined_typename("Bool_t"),-1,4,"fPrintResultsOntoAlphaPlot=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fNoff=",0,"fNoff = fNoffSig * fNormFactor");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fGamma=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fNormFactor=",0,"= TotalNon/TotalNoff)");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fSigLiMa=",0,"significance of gamma signal according to Li & Ma");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fSigLiMa2=",0,"significance of gamma signal according to Li & Ma");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fSigLiMa3=",0,"significance of gamma signal according to Li & Ma");
+   G__memvar_setup((void*)NULL,100,0,1,-1,G__defined_typename("Double_t"),-2,4,"fEps=",0,"tolerance for floating point comparisons");
+   G__memvar_setup((void*)NULL,103,0,0,-1,G__defined_typename("Bool_t"),-1,4,"fDraw=",0,"if true : draw plots");
+   G__memvar_setup((void*)NULL,103,0,0,-1,G__defined_typename("Bool_t"),-1,4,"fSavePlots=",0,"if true : Save plots in Psfile");
+   G__memvar_setup((void*)NULL,103,0,0,-1,G__defined_typename("Bool_t"),-1,4,"fFitGauss=",0,"if true : do the (polynomial+Gauss fit)");
+   G__memvar_setup((void*)NULL,103,0,0,-1,G__defined_typename("Bool_t"),-1,4,"fRebin=",0,"if true : allow rebinning of the alpha plot    ");
+   G__memvar_setup((void*)NULL,103,0,0,-1,G__defined_typename("Bool_t"),-1,4,"fReduceDegree=",0,"if true : allow reducing of the order of the polynomial");
+   G__memvar_setup((void*)NULL,103,0,0,-1,G__defined_typename("Bool_t"),-1,4,"fConstantBackg=",0,"if set true if background fit is not possible");
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TCanvas),-1,-1,4,"fCanvas=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fNexGauss=",0,"total number of excess events ");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fdNexGauss=",0,"error of the total number of excess events");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fSigmaGauss=",0,"sigma of fitted Gauss function");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fdSigmaGauss=",0,"error of this sigma");
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TF1),-1,-1,4,"fPoly=",0,"polynomial function");
+   G__memvar_setup((void*)NULL,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"fFitBad=",0,"if != 0 fit failed");
+   G__memvar_setup((void*)NULL,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"fDegree=",0,"degree of polynomial to be fitted to the background");
+   G__memvar_setup((void*)NULL,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"fNdf=",0,"number of degrees of freedom of polynomial fit");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fChisq=",0,"chi squared of polynomial fit");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fProb=",0,"chi squared probability ofg polynomial fit ");
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TArrayD),-1,-1,4,"fValues=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TArrayD),-1,-1,4,"fErrors=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,105,0,1,-1,G__defined_typename("Int_t"),-2,4,"fNdim=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fEmat[6][6]=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fEma[6][6]=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fCorr[6][6]=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"fMbins=",0,"number of bins in the fit range");
+   G__memvar_setup((void*)NULL,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"fMlow=",0,"number of bins in the fit range with too few entries");
+   G__memvar_setup((void*)NULL,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"fNzero=",0,"number of bins in the fit range with zero entry");
+   G__memvar_setup((void*)NULL,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"fIstat=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TF1),-1,-1,4,"fPolyOFF=",0,"polynomial function for OFF data");
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TF1),-1,-1,4,"fPolyOFFNormalized=",0,"polynomial function for OFF data normalized with fNormFactor*(BinWidthON/BinWidthOFF)");
+   G__memvar_setup((void*)NULL,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"fFitBadOFF=",0,"if != 0 fit failed");
+   G__memvar_setup((void*)NULL,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"fDegreeOFF=",0,"degree of polynomial to be fitted to the background");
+   G__memvar_setup((void*)NULL,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"fNdfOFF=",0,"number of degrees of freedom of polynomial fit");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fChisqOFF=",0,"chi squared of polynomial fit");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fProbOFF=",0,"chi squared probability ofg polynomial fit ");
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TArrayD),-1,-1,4,"fValuesOFF=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TArrayD),-1,-1,4,"fErrorsOFF=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TArrayD),-1,-1,4,"fValuesOFFNormalized=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TArrayD),-1,-1,4,"fErrorsOFFNormalized=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,105,0,1,-1,G__defined_typename("Int_t"),-2,4,"fNdimOFF=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fEmatOFF[6][6]=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fEmaOFF[6][6]=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fCorrOFF[6][6]=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"fMbinsOFF=",0,"number of bins in the fit range");
+   G__memvar_setup((void*)NULL,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"fMlowOFF=",0,"number of bins in the fit range with too few entries");
+   G__memvar_setup((void*)NULL,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"fNzeroOFF=",0,"number of bins in the fit range with zero entry");
+   G__memvar_setup((void*)NULL,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"fIstatOFF=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TF1),-1,-1,4,"fGPoly=",0,"(Gauss+polynomial) function");
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TF1),-1,-1,4,"fGBackg=",0,"polynomial part of (Gauss+polynomial) function");
+   G__memvar_setup((void*)NULL,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"fGFitBad=",0,"if != 0 fit failed");
+   G__memvar_setup((void*)NULL,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"fGDegree=",0,"degree of polynomial to be fitted to the background");
+   G__memvar_setup((void*)NULL,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"fGNdf=",0,"number of degrees of freedom of polynomial fit");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fGChisq=",0,"chi squared of polynomial fit");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fGProb=",0,"chi squared probability ofg polynomial fit ");
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TArrayD),-1,-1,4,"fGValues=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TArrayD),-1,-1,4,"fGErrors=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,105,0,1,-1,G__defined_typename("Int_t"),-2,4,"fGNdim=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fGEmat[9][9]=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fGEma[9][9]=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fGCorr[9][9]=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"fGMbins=",0,"number of bins in the fit range");
+   G__memvar_setup((void*)NULL,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"fGNzero=",0,"numnber of bins in the fit range with zero entry");
+   G__memvar_setup((void*)NULL,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"fGIstat=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,117,0,1,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,-2,4,"gsDefName=",0,"! Default Name");
+   G__memvar_setup((void*)NULL,117,0,1,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,-2,4,"gsDefTitle=",0,"! Default Title");
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TClass),-1,-2,4,"fgIsA=",0,(char*)NULL);
+   }
+   G__tag_memvar_reset();
+}
+
+
+   /* MFindSupercutsONOFF */
+static void G__setup_memvarMFindSupercutsONOFF(void) {
+   G__tag_memvar_setup(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MFindSupercutsONOFF));
+   { MFindSupercutsONOFF *p; p=(MFindSupercutsONOFF*)0x1000; if (p) { }
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fSizeCutLow=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fSizeCutUp=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fDistCutLow=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fDistCutUp=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fLengthCutLow=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fLengthCutUp=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fWidthCutLow=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fWidthCutUp=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,-1,4,"fFilenameTrain=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,-1,4,"fFilenameTest=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"fHowManyTrain=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"fHowManyTest=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"fHowManyTrainOFF=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"fHowManyTestOFF=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fAlphaSig=",0,"Max alpha value were signal is expected");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fAlphaBkgMin=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fAlphaBkgMax=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"fThetaMin=",0,"Cuts in ThetaOrig.fVal (in mili radians!!!)");
+   G__memvar_setup((void*)NULL,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"fThetaMax=",0,"Cuts in ThetaOrig.fVal (in mili radians !!!)");
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,-1,4,"fThetaRangeString=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"fNAlphaBins=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fAlphaBinLow=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fAlphaBinUp=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,103,0,0,-1,G__defined_typename("Bool_t"),-1,4,"fUseOrigDistribution=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fNormFactorTrain=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fNormFactorTest=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fSigmaLiMaTrain=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fSigmaLiMaTest=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fNexTrain=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fNexTest=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fGammaEfficiency=",0,"Fraction of gammas that remain after cuts");
+   G__memvar_setup((void*)NULL,103,0,0,-1,G__defined_typename("Bool_t"),-1,4,"fTuneNormFactor=",0,"If true, normalization factors are corrected using the estimated number of gammas and the gamma efficiency");
+   G__memvar_setup((void*)NULL,103,0,0,-1,G__defined_typename("Bool_t"),-1,4,"fNormFactorFromAlphaBkg=",0,"if kTRUE, method 2) is used");
+   G__memvar_setup((void*)NULL,103,0,0,-1,G__defined_typename("Bool_t"),-1,4,"fUseFittedQuantities=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,103,0,0,-1,G__defined_typename("Bool_t"),-1,4,"fSkipOptimization=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,103,0,0,-1,G__defined_typename("Bool_t"),-1,4,"fSetLimitsToSomeMinuitParams=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fMinuitDistUPUpperLimit=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fMinuitDistUPLowerLimit=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fMinuitLengthUPUpperLimit=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fMinuitLengthUPLowerLimit=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fMinuitWidthUPUpperLimit=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fMinuitWidthUPLowerLimit=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fMinuitLeakage1UPUpperLimit=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fMinuitLeakage1UPLowerLimit=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fMinuitDistLOWUpperLimit=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fMinuitDistLOWLowerLimit=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fMinuitLengthLOWUpperLimit=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fMinuitLengthLOWLowerLimit=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fMinuitWidthLOWUpperLimit=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fMinuitWidthLOWLowerLimit=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,103,0,0,-1,G__defined_typename("Bool_t"),-1,4,"fNotUseTheta=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,103,0,0,-1,G__defined_typename("Bool_t"),-1,4,"fUseDist=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,103,0,0,-1,G__defined_typename("Bool_t"),-1,4,"fUseStaticCuts=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,103,0,0,-1,G__defined_typename("Bool_t"),-1,4,"fUseInitialSCParams=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,-1,4,"fFilenameParam=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,-1,4,"fHadronnessName=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,-1,4,"fHadronnessNameOFF=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,-1,4,"fTrainONSupercutsAppliedName=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,-1,4,"fTrainOFFSupercutsAppliedName=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,-1,4,"fTestONSupercutsAppliedName=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,-1,4,"fTestOFFSupercutsAppliedName=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TPostScript),-1,-1,4,"fPsFilename=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TPostScript),-1,-1,4,"fPsFilename2=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,-1,4,"fPsFilenameString=",0,"Name of the file where plots will be stored while the ");
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,-1,4,"fAlphaDistributionsRootFilename=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MSupercutsCalcONOFF),-1,-1,4,"fCalcHadTrain=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MSupercutsCalcONOFF),-1,-1,4,"fCalcHadTest=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MSupercutsCalcONOFF),-1,-1,4,"fCalcHadTrainOFF=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MSupercutsCalcONOFF),-1,-1,4,"fCalcHadTestOFF=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MHMatrix),-1,-1,4,"fMatrixTrain=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MHMatrix),-1,-1,4,"fMatrixTest=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MHMatrix),-1,-1,4,"fMatrixTrainOFF=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MHMatrix),-1,-1,4,"fMatrixTestOFF=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MGeomCam),-1,-1,4,"fCam=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MEvtLoop),-1,-1,4,"fObjectFit=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MFilter),-1,-1,4,"fMatrixFilter=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TArrayD),-1,-1,4,"fVinit=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TArrayD),-1,-1,4,"fStep=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TArrayD),-1,-1,4,"fLimlo=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TArrayD),-1,-1,4,"fLimup=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TArrayI),-1,-1,4,"fFix=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,104,0,0,-1,G__defined_typename("UInt_t"),-1,4,"fNpar=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,-1,4,"fMethod=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fMin=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fEdm=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fErrdef=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"fNpari=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"fNparx=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"fIstat=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"fErrMinimize=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TClass),-1,-2,4,"fgIsA=",0,(char*)NULL);
+   }
+   G__tag_memvar_reset();
+}
+
+
+   /* MFindSupercutsONOFFThetaLoop */
+static void G__setup_memvarMFindSupercutsONOFFThetaLoop(void) {
+   G__tag_memvar_setup(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MFindSupercutsONOFFThetaLoop));
+   { MFindSupercutsONOFFThetaLoop *p; p=(MFindSupercutsONOFFThetaLoop*)0x1000; if (p) { }
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,-1,4,"fDataONRootFilename=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,-1,4,"fDataOFFRootFilename=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,-1,4,"fPathForFiles=",0,"Path to directory where files (PsFiles, rootfiles) will be stored");
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,-1,4,"fOptSCParamFilenameVector=",0,"Pointer to vector of TStrings containing name of the root files where optimized supercuts will be stored. To be created and filled once Vector of Costheta ranges is defined");
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,-1,4,"fTrainMatrixONFilenameVector=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,-1,4,"fTestMatrixONFilenameVector=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,-1,4,"fTrainMatrixOFFFilenameVector=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,-1,4,"fTestMatrixOFFFilenameVector=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fAlphaSig=",0,"Max alpha value were signal is expected");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fAlphaBkgMin=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fAlphaBkgMax=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fSizeCutLow=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fSizeCutUp=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"fNAlphaBins=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fAlphaBinLow=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fAlphaBinUp=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,103,0,0,-1,G__defined_typename("Bool_t"),-1,4,"fUseFittedQuantities=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fPolyGaussFitAlphaSigma=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fWhichFractionTrain=",0,"number <= 1; specifying fraction of ON Train events");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fWhichFractionTest=",0,"number <= 1; specifying fraction of ON Test events");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fWhichFractionTrainOFF=",0,"number <= 1; specifying fraction of OFF  Train events");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fWhichFractionTestOFF=",0,"number <= 1; specifying fraction of OFF Test events");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fThetaMin=",0,"Cuts in ThetaOrig.fVal (in rad!!!)");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fThetaMax=",0,"Cuts in ThetaOrig.fVal (in rad !!!)");
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TArrayD),-1,-1,4,"fCosThetaRangeVector=",0,"vector containing the ");
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,-1,4,"fThetaRangeStringVector=",0,"Pointer to vector of TStrings that contain Cos theta ranges specified in fCosThetaRangeVector. It will be used to identify alpha distributions stored in fAlphaDistributionsRootFilename");
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TArrayD),-1,-1,4,"fCosThetaBinCenterVector=",0,"vector containing the ");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fActualCosThetaBinCenter=",0,"Theta value used to fill ");
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fOverallNexTrain=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fOverallNexTest=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fOverallSigmaLiMaTrain=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fOverallSigmaLiMaTest=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TH1F),-1,-1,4,"fSuccessfulThetaBinsHist=",0,"Hist containing theta bins were optimization was successful");
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TH1F),-1,-1,4,"fNormFactorTrainHist=",0,"Hist containing norm factors train for all Cos theta ranges");
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TH1F),-1,-1,4,"fNormFactorTestHist=",0,"Hist containing norm factors test for all Cos theta ranges");
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TH1F),-1,-1,4,"fSigmaLiMaTrainHist=",0,"Hist containing SigmaLiMa for Train samples for all Cos theta ranges");
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TH1F),-1,-1,4,"fSigmaLiMaTestHist=",0,"Hist containing SigmaLiMa for Test samples for all Cos theta ranges");
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TH1F),-1,-1,4,"fNexTrainHist=",0,"Hist containing Number os excess events for Train sample for all Cos thetas");
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TH1F),-1,-1,4,"fNexTestHist=",0,"Hist containing Number os excess events for Test sample for all Cos theta");
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TH1F),-1,-1,4,"fNEvtsInTrainMatrixONHist=",0,"Hist containing total number of events in Train Matrices of ON data for all Cos theta ranges");
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TH1F),-1,-1,4,"fNEvtsInTestMatrixONHist=",0,"Hist containing total number of events in Test Matrices of ON data for all Cos theta ranges");
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TH1F),-1,-1,4,"fNEvtsInTrainMatrixOFFHist=",0,"Hist containing total number of events in Train Matrices of OFF data for all Cos theta ranges");
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TH1F),-1,-1,4,"fNEvtsInTestMatrixOFFHist=",0,"Hist containing total number of events in Test Matrices of OFF data for all Cos theta ranges");
+   G__memvar_setup((void*)NULL,103,0,0,-1,G__defined_typename("Bool_t"),-1,4,"fSkipOptimization=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,103,0,0,-1,G__defined_typename("Bool_t"),-1,4,"fUseInitialSCParams=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,100,0,0,-1,G__defined_typename("Double_t"),-1,4,"fGammaEfficiency=",0,"Fraction of gammas that remain after cuts");
+   G__memvar_setup((void*)NULL,103,0,0,-1,G__defined_typename("Bool_t"),-1,4,"fTuneNormFactor=",0,"If true, normalization factors are corrected ");
+   G__memvar_setup((void*)NULL,103,0,0,-1,G__defined_typename("Bool_t"),-1,4,"fNormFactorFromAlphaBkg=",0,"if kTRUE, method 2) is used");
+   G__memvar_setup((void*)NULL,103,0,0,-1,G__defined_typename("Bool_t"),-1,4,"fNotUseTheta=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,103,0,0,-1,G__defined_typename("Bool_t"),-1,4,"fUseStaticCuts=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,-1,4,"fHadronnessName=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,-1,4,"fHadronnessNameOFF=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TArrayD),-1,-1,4,"fInitSCPar=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TArrayD),-1,-1,4,"fInitSCParSteps=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TPostScript),-1,-1,4,"fPsFilename=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,-1,4,"fAlphaDistributionsRootFilename=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,103,0,0,-1,G__defined_typename("Bool_t"),-1,4,"fReadMatricesFromFile=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,103,0,0,-1,G__defined_typename("Bool_t"),-1,4,"fOptimizeParameters=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,103,0,0,-1,G__defined_typename("Bool_t"),-1,4,"fTestParameters=",0,(char*)NULL);
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TClass),-1,-2,4,"fgIsA=",0,(char*)NULL);
+   }
+   G__tag_memvar_reset();
+}
+
+extern "C" void G__cpp_setup_memvarSuperCutsONOFFCint() {
+}
+/***********************************************************
+************************************************************
+************************************************************
+************************************************************
+************************************************************
+************************************************************
+************************************************************
+***********************************************************/
+
+/*********************************************************
+* Member function information setup for each class
+*********************************************************/
+static void G__setup_memfuncMFRandomSplit(void) {
+   /* MFRandomSplit */
+   G__tag_memfunc_setup(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MFRandomSplit));
+   G__memfunc_setup("PreProcess",1030,(G__InterfaceMethod)NULL,105,-1,G__defined_typename("Int_t"),0,1,1,4,0,"U 'MParList' - 0 - pList",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("Process",735,(G__InterfaceMethod)NULL,105,-1,G__defined_typename("Int_t"),0,0,1,4,0,"",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("PostProcess",1157,(G__InterfaceMethod)NULL,105,-1,G__defined_typename("Int_t"),0,0,1,4,0,"",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("MFRandomSplit",1280,G__SuperCutsONOFFCint_124_3_0,105,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MFRandomSplit),-1,0,3,1,1,0,
+"d - 'Double_t' 0 - f C - - 10 NULL name "
+"C - - 10 NULL title",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("IsExpressionTrue",1676,G__SuperCutsONOFFCint_124_4_0,103,-1,G__defined_typename("Bool_t"),0,0,1,1,8,"",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("Class",502,G__SuperCutsONOFFCint_124_5_0,85,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TClass),-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("Class_Name",982,G__SuperCutsONOFFCint_124_6_0,67,-1,-1,0,0,3,1,1,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("Class_Version",1339,G__SuperCutsONOFFCint_124_7_0,115,-1,G__defined_typename("Version_t"),0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("Dictionary",1046,G__SuperCutsONOFFCint_124_8_0,121,-1,-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("IsA",253,G__SuperCutsONOFFCint_124_9_0,85,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TClass),-1,0,0,1,1,8,"",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("ShowMembers",1132,G__SuperCutsONOFFCint_124_0_1,121,-1,-1,0,2,1,1,0,
+"u 'TMemberInspector' - 1 - insp C - - 0 - parent",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("Streamer",835,G__SuperCutsONOFFCint_124_1_1,121,-1,-1,0,1,1,1,0,"u 'TBuffer' - 1 - b",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("StreamerNVirtual",1656,G__SuperCutsONOFFCint_124_2_1,121,-1,-1,0,1,1,1,0,"u 'TBuffer' - 1 - b",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("DeclFileName",1145,G__SuperCutsONOFFCint_124_3_1,67,-1,-1,0,0,3,1,1,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("ImplFileLine",1178,G__SuperCutsONOFFCint_124_4_1,105,-1,-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("ImplFileName",1171,G__SuperCutsONOFFCint_124_5_1,67,-1,-1,0,0,3,1,1,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("DeclFileLine",1152,G__SuperCutsONOFFCint_124_6_1,105,-1,-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   // automatic copy constructor
+   G__memfunc_setup("MFRandomSplit",1280,G__SuperCutsONOFFCint_124_7_1,(int)('i'),G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MFRandomSplit),-1,0,1,1,1,0,"u 'MFRandomSplit' - 11 - -",(char*)NULL,(void*)NULL,0);
+   // automatic destructor
+   G__memfunc_setup("~MFRandomSplit",1406,G__SuperCutsONOFFCint_124_8_1,(int)('y'),-1,-1,0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__tag_memfunc_reset();
+}
+
+static void G__setup_memfuncMTSupercutsApplied(void) {
+   /* MTSupercutsApplied */
+   G__tag_memfunc_setup(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MTSupercutsApplied));
+   G__memfunc_setup("MTSupercutsApplied",1838,G__SuperCutsONOFFCint_136_0_0,105,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MTSupercutsApplied),-1,0,2,1,1,0,
+"C - - 10 NULL name C - - 10 NULL title",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("CreateTreeBranches",1802,G__SuperCutsONOFFCint_136_2_0,103,-1,G__defined_typename("Bool_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("FillTreeBranches",1597,G__SuperCutsONOFFCint_136_3_0,103,-1,G__defined_typename("Bool_t"),0,2,1,1,0,
+"u 'TArrayD' - 0 - CutParamVector u 'TArrayD' - 0 - ShowerParamVector",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetTreePointer",1425,G__SuperCutsONOFFCint_136_4_0,85,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TTree),-1,0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("Class",502,G__SuperCutsONOFFCint_136_5_0,85,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TClass),-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("Class_Name",982,G__SuperCutsONOFFCint_136_6_0,67,-1,-1,0,0,3,1,1,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("Class_Version",1339,G__SuperCutsONOFFCint_136_7_0,115,-1,G__defined_typename("Version_t"),0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("Dictionary",1046,G__SuperCutsONOFFCint_136_8_0,121,-1,-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("IsA",253,G__SuperCutsONOFFCint_136_9_0,85,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TClass),-1,0,0,1,1,8,"",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("ShowMembers",1132,G__SuperCutsONOFFCint_136_0_1,121,-1,-1,0,2,1,1,0,
+"u 'TMemberInspector' - 1 - insp C - - 0 - parent",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("Streamer",835,G__SuperCutsONOFFCint_136_1_1,121,-1,-1,0,1,1,1,0,"u 'TBuffer' - 1 - b",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("StreamerNVirtual",1656,G__SuperCutsONOFFCint_136_2_1,121,-1,-1,0,1,1,1,0,"u 'TBuffer' - 1 - b",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("DeclFileName",1145,G__SuperCutsONOFFCint_136_3_1,67,-1,-1,0,0,3,1,1,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("ImplFileLine",1178,G__SuperCutsONOFFCint_136_4_1,105,-1,-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("ImplFileName",1171,G__SuperCutsONOFFCint_136_5_1,67,-1,-1,0,0,3,1,1,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("DeclFileLine",1152,G__SuperCutsONOFFCint_136_6_1,105,-1,-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   // automatic copy constructor
+   G__memfunc_setup("MTSupercutsApplied",1838,G__SuperCutsONOFFCint_136_7_1,(int)('i'),G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MTSupercutsApplied),-1,0,1,1,1,0,"u 'MTSupercutsApplied' - 11 - -",(char*)NULL,(void*)NULL,0);
+   // automatic destructor
+   G__memfunc_setup("~MTSupercutsApplied",1964,G__SuperCutsONOFFCint_136_8_1,(int)('y'),-1,-1,0,0,1,1,0,"",(char*)NULL,(void*)NULL,1);
+   G__tag_memfunc_reset();
+}
+
+static void G__setup_memfuncMSupercutsCalcONOFF(void) {
+   /* MSupercutsCalcONOFF */
+   G__tag_memfunc_setup(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MSupercutsCalcONOFF));
+   G__memfunc_setup("PreProcess",1030,(G__InterfaceMethod)NULL,105,-1,G__defined_typename("Int_t"),0,1,1,4,0,"U 'MParList' - 0 - pList",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("Process",735,(G__InterfaceMethod)NULL,105,-1,G__defined_typename("Int_t"),0,0,1,4,0,"",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("GetVal",579,(G__InterfaceMethod)NULL,100,-1,G__defined_typename("Double_t"),0,1,1,4,8,"i - 'Int_t' 0 - i",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("CtsMCut",675,(G__InterfaceMethod)NULL,100,-1,G__defined_typename("Double_t"),0,5,1,4,8,
+"D - 'Double_t' 10 - a d - 'Double_t' 0 - ls "
+"d - 'Double_t' 0 - ct d - 'Double_t' 0 - ls2 "
+"d - 'Double_t' 0 - dd2",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("MSupercutsCalcONOFF",1798,G__SuperCutsONOFFCint_137_4_0,105,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MSupercutsCalcONOFF),-1,0,4,1,1,0,
+"C - - 10 \"MHillas\" hilname C - - 10 \"MHillasSrc\" hilsrcname "
+"C - - 10 NULL name C - - 10 NULL title",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetHadronnessName",1730,G__SuperCutsONOFFCint_137_5_0,121,-1,-1,0,1,1,1,0,"u 'TString' - 10 - name",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetHadronnessName",1718,G__SuperCutsONOFFCint_137_6_0,117,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,0,0,1,1,8,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetSupercutsAppliedName",2362,G__SuperCutsONOFFCint_137_7_0,121,-1,-1,0,1,1,1,0,"u 'TString' - 10 - name",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetSupercutsAppliedName",2350,G__SuperCutsONOFFCint_137_8_0,117,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString),-1,0,0,1,1,8,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetStoreAppliedSupercuts",2502,G__SuperCutsONOFFCint_137_9_0,121,-1,-1,0,1,1,1,0,"g - 'Bool_t' 0 - b",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetStoreAppliedSupercuts",2490,G__SuperCutsONOFFCint_137_0_1,103,-1,G__defined_typename("Bool_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetVariableNotUseTheta",2214,G__SuperCutsONOFFCint_137_1_1,121,-1,-1,0,1,1,1,0,"g - 'Bool_t' 0 - b",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetVariableNotUseTheta",2202,G__SuperCutsONOFFCint_137_2_1,103,-1,G__defined_typename("Bool_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetVariableUseStaticCuts",2438,G__SuperCutsONOFFCint_137_3_1,121,-1,-1,0,1,1,1,0,"g - 'Bool_t' 0 - b",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetVariableUseStaticCuts",2426,G__SuperCutsONOFFCint_137_4_1,103,-1,G__defined_typename("Bool_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetHillasDistLengthWidthUpperLowerLimits",4102,G__SuperCutsONOFFCint_137_5_1,121,-1,-1,0,6,1,1,0,
+"d - 'Double_t' 0 - distup d - 'Double_t' 0 - lengthup "
+"d - 'Double_t' 0 - widthup d - 'Double_t' 0 - distlow "
+"d - 'Double_t' 0 - lengthlow d - 'Double_t' 0 - widthlow",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("InitMapping",1120,G__SuperCutsONOFFCint_137_6_1,121,-1,-1,0,1,1,1,0,"U 'MHMatrix' - 0 - mat","use quantity ThetaOrig.fVal at theta",(void*)NULL,0);
+   G__memfunc_setup("StopMapping",1138,G__SuperCutsONOFFCint_137_7_1,121,-1,-1,0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("Class",502,G__SuperCutsONOFFCint_137_8_1,85,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TClass),-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("Class_Name",982,G__SuperCutsONOFFCint_137_9_1,67,-1,-1,0,0,3,1,1,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("Class_Version",1339,G__SuperCutsONOFFCint_137_0_2,115,-1,G__defined_typename("Version_t"),0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("Dictionary",1046,G__SuperCutsONOFFCint_137_1_2,121,-1,-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("IsA",253,G__SuperCutsONOFFCint_137_2_2,85,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TClass),-1,0,0,1,1,8,"",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("ShowMembers",1132,G__SuperCutsONOFFCint_137_3_2,121,-1,-1,0,2,1,1,0,
+"u 'TMemberInspector' - 1 - insp C - - 0 - parent",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("Streamer",835,G__SuperCutsONOFFCint_137_4_2,121,-1,-1,0,1,1,1,0,"u 'TBuffer' - 1 - b",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("StreamerNVirtual",1656,G__SuperCutsONOFFCint_137_5_2,121,-1,-1,0,1,1,1,0,"u 'TBuffer' - 1 - b",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("DeclFileName",1145,G__SuperCutsONOFFCint_137_6_2,67,-1,-1,0,0,3,1,1,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("ImplFileLine",1178,G__SuperCutsONOFFCint_137_7_2,105,-1,-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("ImplFileName",1171,G__SuperCutsONOFFCint_137_8_2,67,-1,-1,0,0,3,1,1,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("DeclFileLine",1152,G__SuperCutsONOFFCint_137_9_2,105,-1,-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   // automatic copy constructor
+   G__memfunc_setup("MSupercutsCalcONOFF",1798,G__SuperCutsONOFFCint_137_0_3,(int)('i'),G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MSupercutsCalcONOFF),-1,0,1,1,1,0,"u 'MSupercutsCalcONOFF' - 11 - -",(char*)NULL,(void*)NULL,0);
+   // automatic destructor
+   G__memfunc_setup("~MSupercutsCalcONOFF",1924,G__SuperCutsONOFFCint_137_1_3,(int)('y'),-1,-1,0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__tag_memfunc_reset();
+}
+
+static void G__setup_memfuncMHFindSignificanceONOFF(void) {
+   /* MHFindSignificanceONOFF */
+   G__tag_memfunc_setup(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MHFindSignificanceONOFF));
+   G__memfunc_setup("DetExcess",904,(G__InterfaceMethod)NULL,103,-1,G__defined_typename("Bool_t"),0,0,1,4,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("DetExcessONOFF",1280,(G__InterfaceMethod)NULL,103,-1,G__defined_typename("Bool_t"),0,0,1,4,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("FitPolynomial",1351,(G__InterfaceMethod)NULL,103,-1,G__defined_typename("Bool_t"),0,0,1,4,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("FitPolynomialOFF",1570,(G__InterfaceMethod)NULL,103,-1,G__defined_typename("Bool_t"),0,0,1,4,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("FitGaussPoly",1226,(G__InterfaceMethod)NULL,103,-1,G__defined_typename("Bool_t"),0,0,1,4,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("RebinHistogram",1438,(G__InterfaceMethod)NULL,103,-1,G__defined_typename("Bool_t"),0,2,1,4,0,
+"d - 'Double_t' 0 - x0 i - 'Int_t' 0 - nrebin",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("RebinHistogramOFF",1657,(G__InterfaceMethod)NULL,103,-1,G__defined_typename("Bool_t"),0,2,1,4,0,
+"d - 'Double_t' 0 - x0 i - 'Int_t' 0 - nrebin",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("MHFindSignificanceONOFF",2129,G__SuperCutsONOFFCint_159_7_0,105,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MHFindSignificanceONOFF),-1,0,2,1,1,0,
+"C - - 10 NULL name C - - 10 NULL title",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("FindSigmaONOFF",1258,G__SuperCutsONOFFCint_159_9_0,103,-1,G__defined_typename("Bool_t"),0,13,1,1,0,
+"U 'TH1' - 0 - fhistON U 'TH1' - 0 - fhistOFF "
+"d - 'Double_t' 0 - NormFactor d - 'Double_t' 0 - alphamin "
+"d - 'Double_t' 0 - alphamax i - 'Int_t' 0 - degreeON "
+"i - 'Int_t' 0 - degreeOFF d - 'Double_t' 0 - alphasig "
+"g - 'Bool_t' 0 - drawpoly g - 'Bool_t' 0 - fitgauss "
+"g - 'Bool_t' 0 - print g - 'Bool_t' 0 - saveplots "
+"u 'TString' - 10 - psfilename",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetLimitsForOFFDataFit",2109,G__SuperCutsONOFFCint_159_0_1,121,-1,-1,0,2,1,1,0,
+"d - 'Double_t' 0 - Low d - 'Double_t' 0 - Up",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetAlphaSig",1077,G__SuperCutsONOFFCint_159_1_1,121,-1,-1,0,1,1,1,0,"d - 'Double_t' 0 - alphasig",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetUseFittedQuantities",2272,G__SuperCutsONOFFCint_159_2_1,121,-1,-1,0,1,1,1,0,"g - 'Bool_t' 0 - b",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SigmaLiMa",852,G__SuperCutsONOFFCint_159_3_1,103,-1,G__defined_typename("Bool_t"),0,4,1,1,0,
+"d - 'Double_t' 0 - non d - 'Double_t' 0 - noff "
+"d - 'Double_t' 0 - gamma D - 'Double_t' 0 - siglima",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SigmaLiMaForm5",1309,G__SuperCutsONOFFCint_159_4_1,103,-1,G__defined_typename("Bool_t"),0,4,1,1,0,
+"d - 'Double_t' 0 - non d - 'Double_t' 0 - noff "
+"d - 'Double_t' 0 - gamma D - 'Double_t' 0 - siglima",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SigmaVsAlphaONOFF",1560,G__SuperCutsONOFFCint_159_5_1,103,-1,G__defined_typename("Bool_t"),0,6,1,1,0,
+"U 'TH1' - 0 - fhistON U 'TH1' - 0 - fhistOFF "
+"d - 'Double_t' 0 - alphamin d - 'Double_t' 0 - alphamax "
+"i - 'Int_t' 0 - degree g - 'Bool_t' 0 - print",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetSignificance",1507,G__SuperCutsONOFFCint_159_6_1,100,-1,G__defined_typename("Double_t"),0,0,1,1,0,"","{ return fSigLiMa; }",(void*)NULL,0);
+   G__memfunc_setup("GetUseFittedQuantities",2260,G__SuperCutsONOFFCint_159_7_1,103,-1,G__defined_typename("Bool_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("ComputeHistOFFNormalized",2405,G__SuperCutsONOFFCint_159_8_1,103,-1,G__defined_typename("Bool_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("DrawFit",689,G__SuperCutsONOFFCint_159_9_1,103,-1,G__defined_typename("Bool_t"),0,1,1,1,0,"C - 'Option_t' 10 NULL opt",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("DrawHistOFF",1025,G__SuperCutsONOFFCint_159_0_2,103,-1,G__defined_typename("Bool_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("DrawHistOFFNormalized",2070,G__SuperCutsONOFFCint_159_1_2,103,-1,G__defined_typename("Bool_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetDegree",876,G__SuperCutsONOFFCint_159_2_2,102,-1,G__defined_typename("Float_t"),0,0,1,1,8,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetProb",691,G__SuperCutsONOFFCint_159_3_2,102,-1,G__defined_typename("Float_t"),0,0,1,1,8,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetNdf",568,G__SuperCutsONOFFCint_159_4_2,102,-1,G__defined_typename("Float_t"),0,0,1,1,8,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetGamma",771,G__SuperCutsONOFFCint_159_5_2,102,-1,G__defined_typename("Float_t"),0,0,1,1,8,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetNon",587,G__SuperCutsONOFFCint_159_6_2,102,-1,G__defined_typename("Float_t"),0,0,1,1,8,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetNex",587,G__SuperCutsONOFFCint_159_7_2,102,-1,G__defined_typename("Float_t"),0,0,1,1,8,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetNbg",567,G__SuperCutsONOFFCint_159_8_2,102,-1,G__defined_typename("Float_t"),0,0,1,1,8,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetSigLiMa1",983,G__SuperCutsONOFFCint_159_9_2,102,-1,G__defined_typename("Float_t"),0,0,1,1,8,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetSigLiMa2",984,G__SuperCutsONOFFCint_159_0_3,102,-1,G__defined_typename("Float_t"),0,0,1,1,8,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetSigLiMa3",985,G__SuperCutsONOFFCint_159_1_3,102,-1,G__defined_typename("Float_t"),0,0,1,1,8,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetMbins",793,G__SuperCutsONOFFCint_159_2_3,102,-1,G__defined_typename("Float_t"),0,0,1,1,8,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetAlphasi",994,G__SuperCutsONOFFCint_159_3_3,102,-1,G__defined_typename("Float_t"),0,0,1,1,8,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetNexONOFF",963,G__SuperCutsONOFFCint_159_4_3,102,-1,G__defined_typename("Float_t"),0,0,1,1,8,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetNexONOFFFitted",1571,G__SuperCutsONOFFCint_159_5_3,102,-1,G__defined_typename("Float_t"),0,0,1,1,8,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetRebin",796,G__SuperCutsONOFFCint_159_6_3,121,-1,-1,0,1,1,1,0,"g - 'Bool_t' 0 kTRUE b",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetReduceDegree",1488,G__SuperCutsONOFFCint_159_7_3,121,-1,-1,0,1,1,1,0,"g - 'Bool_t' 0 kTRUE b",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetPsFilename",1296,G__SuperCutsONOFFCint_159_8_3,121,-1,-1,0,1,1,1,0,"U 'TPostScript' - 0 - PsFile",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("PrintPoly",945,G__SuperCutsONOFFCint_159_9_3,121,-1,-1,0,1,1,1,0,"C - 'Option_t' 10 NULL opt",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("PrintPolyOFF",1164,G__SuperCutsONOFFCint_159_0_4,121,-1,-1,0,1,1,1,0,"C - 'Option_t' 10 NULL opt",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("PrintPolyGauss",1460,G__SuperCutsONOFFCint_159_1_4,121,-1,-1,0,1,1,1,0,"C - 'Option_t' 10 NULL opt",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("Class",502,G__SuperCutsONOFFCint_159_2_4,85,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TClass),-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("Class_Name",982,G__SuperCutsONOFFCint_159_3_4,67,-1,-1,0,0,3,1,1,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("Class_Version",1339,G__SuperCutsONOFFCint_159_4_4,115,-1,G__defined_typename("Version_t"),0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("Dictionary",1046,G__SuperCutsONOFFCint_159_5_4,121,-1,-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("IsA",253,G__SuperCutsONOFFCint_159_6_4,85,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TClass),-1,0,0,1,1,8,"",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("ShowMembers",1132,G__SuperCutsONOFFCint_159_7_4,121,-1,-1,0,2,1,1,0,
+"u 'TMemberInspector' - 1 - insp C - - 0 - parent",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("Streamer",835,G__SuperCutsONOFFCint_159_8_4,121,-1,-1,0,1,1,1,0,"u 'TBuffer' - 1 - b",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("StreamerNVirtual",1656,G__SuperCutsONOFFCint_159_9_4,121,-1,-1,0,1,1,1,0,"u 'TBuffer' - 1 - b",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("DeclFileName",1145,G__SuperCutsONOFFCint_159_0_5,67,-1,-1,0,0,3,1,1,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("ImplFileLine",1178,G__SuperCutsONOFFCint_159_1_5,105,-1,-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("ImplFileName",1171,G__SuperCutsONOFFCint_159_2_5,67,-1,-1,0,0,3,1,1,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("DeclFileLine",1152,G__SuperCutsONOFFCint_159_3_5,105,-1,-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   // automatic copy constructor
+   G__memfunc_setup("MHFindSignificanceONOFF",2129,G__SuperCutsONOFFCint_159_4_5,(int)('i'),
+G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MHFindSignificanceONOFF),-1,0,1,1,1,0,"u 'MHFindSignificanceONOFF' - 11 - -",(char*)NULL,(void*)NULL,0);
+   // automatic destructor
+   G__memfunc_setup("~MHFindSignificanceONOFF",2255,G__SuperCutsONOFFCint_159_5_5,(int)('y'),-1,-1,0,0,1,1,0,"",(char*)NULL,(void*)NULL,1);
+   G__tag_memfunc_reset();
+}
+
+static void G__setup_memfuncMFindSupercutsONOFF(void) {
+   /* MFindSupercutsONOFF */
+   G__tag_memfunc_setup(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MFindSupercutsONOFF));
+   G__memfunc_setup("MFindSupercutsONOFF",1812,G__SuperCutsONOFFCint_205_0_0,105,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MFindSupercutsONOFF),-1,0,2,1,1,0,
+"C - - 10 NULL name C - - 10 NULL title",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetFilenameTraining",1929,G__SuperCutsONOFFCint_205_2_0,121,-1,-1,0,2,1,1,0,
+"u 'TString' - 11 - name i - 'Int_t' 10 - howmany",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetFilenameTest",1517,G__SuperCutsONOFFCint_205_3_0,121,-1,-1,0,2,1,1,0,
+"u 'TString' - 11 - name i - 'Int_t' 10 - howmany",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetFilenameParam",1598,G__SuperCutsONOFFCint_205_4_0,121,-1,-1,0,1,1,1,0,"u 'TString' - 11 - name",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetHadronnessName",1730,G__SuperCutsONOFFCint_205_5_0,121,-1,-1,0,1,1,1,0,"u 'TString' - 11 - name",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetHadronnessNameOFF",1949,G__SuperCutsONOFFCint_205_6_0,121,-1,-1,0,1,1,1,0,"u 'TString' - 11 - name",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetSupercutsAppliedTreeNames",2877,G__SuperCutsONOFFCint_205_7_0,121,-1,-1,0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetAlphaDistributionsRootFilename",3402,G__SuperCutsONOFFCint_205_8_0,121,-1,-1,0,1,1,1,0,"u 'TString' - 11 - name",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetAlphaSig",1077,G__SuperCutsONOFFCint_205_9_0,103,-1,G__defined_typename("Bool_t"),0,1,1,1,0,"d - 'Double_t' 0 - alphasig",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetAlphaBkgMin",1354,G__SuperCutsONOFFCint_205_0_1,103,-1,G__defined_typename("Bool_t"),0,1,1,1,0,"d - 'Double_t' 0 - alphabkgmin",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetAlphaBkgMax",1356,G__SuperCutsONOFFCint_205_1_1,103,-1,G__defined_typename("Bool_t"),0,1,1,1,0,"d - 'Double_t' 0 - alphabkgmax",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("CheckAlphaSigBkg",1531,G__SuperCutsONOFFCint_205_2_1,103,-1,G__defined_typename("Bool_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetUseFittedQuantities",2272,G__SuperCutsONOFFCint_205_3_1,121,-1,-1,0,1,1,1,0,"g - 'Bool_t' 0 - b",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetPostScriptFile",1735,G__SuperCutsONOFFCint_205_4_1,121,-1,-1,0,1,1,1,0,"U 'TPostScript' - 0 - PsFile",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetPostScriptFile2",1785,G__SuperCutsONOFFCint_205_5_1,121,-1,-1,0,1,1,1,0,"u 'TPostScript' - 1 - PsFile",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetPsFilenameString",1927,G__SuperCutsONOFFCint_205_6_1,121,-1,-1,0,1,1,1,0,"u 'TString' - 10 - filename",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetMatrixFilter",1543,G__SuperCutsONOFFCint_205_7_1,121,-1,-1,0,1,1,1,0,"U 'MFilter' - 0 - filter",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("DefineTrainMatrix",1726,G__SuperCutsONOFFCint_205_8_1,103,-1,G__defined_typename("Bool_t"),0,4,1,1,0,
+"u 'TString' - 11 - name u 'MH3' - 1 - href "
+"i - 'Int_t' 10 - howmany u 'TString' - 11 - filetrain",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("DefineTestMatrix",1632,G__SuperCutsONOFFCint_205_9_1,103,-1,G__defined_typename("Bool_t"),0,4,1,1,0,
+"u 'TString' - 11 - name u 'MH3' - 1 - href "
+"i - 'Int_t' 10 - howmany u 'TString' - 11 - filetest",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("DefineTrainTestMatrix",2142,G__SuperCutsONOFFCint_205_0_2,103,-1,G__defined_typename("Bool_t"),0,6,1,1,0,
+"u 'TString' - 11 - name u 'MH3' - 1 - href "
+"i - 'Int_t' 10 - howmanytrain i - 'Int_t' 10 - howmanytest "
+"u 'TString' - 11 - filetrain u 'TString' - 11 - filetest",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("DefineTrainTestMatrixThetaRange",3137,G__SuperCutsONOFFCint_205_1_2,103,-1,G__defined_typename("Bool_t"),0,7,1,1,0,
+"u 'TString' - 11 - name d - 'Double_t' 10 - whichfractiontrain "
+"d - 'Double_t' 10 - whichfractiontest d - 'Double_t' 0 - ThetaMin "
+"d - 'Double_t' 0 - ThetaMax u 'TString' - 11 - filetrain "
+"u 'TString' - 11 - filetest",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("DefineTrainTestMatrixOFFThetaRange",3356,G__SuperCutsONOFFCint_205_2_2,103,-1,G__defined_typename("Bool_t"),0,7,1,1,0,
+"u 'TString' - 11 - name d - 'Double_t' 10 - whichfractiontrain "
+"d - 'Double_t' 10 - whichfractiontest d - 'Double_t' 0 - ThetaMin "
+"d - 'Double_t' 0 - ThetaMax u 'TString' - 11 - filetrain "
+"u 'TString' - 11 - filetest",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetMatrixTrain",1427,G__SuperCutsONOFFCint_205_3_2,85,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MHMatrix),-1,0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetMatrixTest",1333,G__SuperCutsONOFFCint_205_4_2,85,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MHMatrix),-1,0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetMatrixTrainOFF",1646,G__SuperCutsONOFFCint_205_5_2,85,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MHMatrix),-1,0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetMatrixTestOFF",1552,G__SuperCutsONOFFCint_205_6_2,85,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MHMatrix),-1,0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetUseOrigDistribution",2282,G__SuperCutsONOFFCint_205_7_2,121,-1,-1,0,1,1,1,0,"g - 'Bool_t' 0 - b",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("ReadMatrix",1009,G__SuperCutsONOFFCint_205_8_2,103,-1,G__defined_typename("Bool_t"),0,2,1,1,0,
+"u 'TString' - 11 - filetrain u 'TString' - 11 - filetest",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("ReadMatrixOFF",1228,G__SuperCutsONOFFCint_205_9_2,103,-1,G__defined_typename("Bool_t"),0,2,1,1,0,
+"u 'TString' - 11 - filetrainOFF u 'TString' - 11 - filetestOFF",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("ComputeNormFactorTrain",2262,G__SuperCutsONOFFCint_205_0_3,103,-1,G__defined_typename("Bool_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("ComputeNormFactorTest",2168,G__SuperCutsONOFFCint_205_1_3,103,-1,G__defined_typename("Bool_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("FindParams",997,G__SuperCutsONOFFCint_205_2_3,103,-1,G__defined_typename("Bool_t"),0,3,1,1,0,
+"u 'TString' - 0 - parSCinit u 'TArrayD' - 1 - params "
+"u 'TArrayD' - 1 - steps",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("TestParamsOnTestSample",2243,G__SuperCutsONOFFCint_205_3_3,103,-1,G__defined_typename("Bool_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("TestParamsOnTrainSample",2337,G__SuperCutsONOFFCint_205_4_3,103,-1,G__defined_typename("Bool_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetThetaRange",1295,G__SuperCutsONOFFCint_205_5_3,103,-1,G__defined_typename("Bool_t"),0,2,1,1,0,
+"d - 'Double_t' 0 - ThetaMin d - 'Double_t' 0 - ThetaMax",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetSizeRange",1204,G__SuperCutsONOFFCint_205_6_3,103,-1,G__defined_typename("Bool_t"),0,2,1,1,0,
+"d - 'Double_t' 0 - SizeMin d - 'Double_t' 0 - SizeMax",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetAlphaPlotBinining",2015,G__SuperCutsONOFFCint_205_7_3,121,-1,-1,0,3,1,1,0,
+"i - 'Int_t' 0 - nbins d - 'Double_t' 0 - binlow "
+"d - 'Double_t' 0 - binup",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetNormFactorTrain",1817,G__SuperCutsONOFFCint_205_8_3,100,-1,G__defined_typename("Double_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetNormFactorTest",1723,G__SuperCutsONOFFCint_205_9_3,100,-1,G__defined_typename("Double_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetSigmaLiMaTrain",1650,G__SuperCutsONOFFCint_205_0_4,100,-1,G__defined_typename("Double_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetSigmaLiMaTest",1556,G__SuperCutsONOFFCint_205_1_4,100,-1,G__defined_typename("Double_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetNexTrain",1097,G__SuperCutsONOFFCint_205_2_4,100,-1,G__defined_typename("Double_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetNexTest",1003,G__SuperCutsONOFFCint_205_3_4,100,-1,G__defined_typename("Double_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetAlphaSig",1065,G__SuperCutsONOFFCint_205_4_4,100,-1,G__defined_typename("Double_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetAlphaBkgMin",1342,G__SuperCutsONOFFCint_205_5_4,100,-1,G__defined_typename("Double_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetAlphaBkgMax",1344,G__SuperCutsONOFFCint_205_6_4,100,-1,G__defined_typename("Double_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetUseFittedQuantities",2260,G__SuperCutsONOFFCint_205_7_4,103,-1,G__defined_typename("Bool_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetSkipOptimization",1982,G__SuperCutsONOFFCint_205_8_4,103,-1,G__defined_typename("Bool_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetUseInitialSCParams",2065,G__SuperCutsONOFFCint_205_9_4,103,-1,G__defined_typename("Bool_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetGammaEfficiency",1796,G__SuperCutsONOFFCint_205_0_5,103,-1,G__defined_typename("Bool_t"),0,1,1,1,0,"d - 'Double_t' 0 - gammaeff",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetGammaEfficiency",1784,G__SuperCutsONOFFCint_205_1_5,100,-1,G__defined_typename("Double_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetTuneNormFactor",1731,G__SuperCutsONOFFCint_205_2_5,121,-1,-1,0,1,1,1,0,"g - 'Bool_t' 0 - b",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetNormFactorFromAlphaBkg",2485,G__SuperCutsONOFFCint_205_3_5,121,-1,-1,0,1,1,1,0,"g - 'Bool_t' 0 - b",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetSkipOptimization",1994,G__SuperCutsONOFFCint_205_4_5,121,-1,-1,0,1,1,1,0,"g - 'Bool_t' 0 - b",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetUseInitialSCParams",2077,G__SuperCutsONOFFCint_205_5_5,121,-1,-1,0,1,1,1,0,"g - 'Bool_t' 0 - b",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetVariableNotUseTheta",2214,G__SuperCutsONOFFCint_205_6_5,121,-1,-1,0,1,1,1,0,"g - 'Bool_t' 0 - b",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetVariableNotUseTheta",2202,G__SuperCutsONOFFCint_205_7_5,103,-1,G__defined_typename("Bool_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetVariableUseStaticCuts",2438,G__SuperCutsONOFFCint_205_8_5,121,-1,-1,0,1,1,1,0,"g - 'Bool_t' 0 - b",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetVariableUseStaticCuts",2426,G__SuperCutsONOFFCint_205_9_5,103,-1,G__defined_typename("Bool_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("Class",502,G__SuperCutsONOFFCint_205_0_6,85,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TClass),-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("Class_Name",982,G__SuperCutsONOFFCint_205_1_6,67,-1,-1,0,0,3,1,1,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("Class_Version",1339,G__SuperCutsONOFFCint_205_2_6,115,-1,G__defined_typename("Version_t"),0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("Dictionary",1046,G__SuperCutsONOFFCint_205_3_6,121,-1,-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("IsA",253,G__SuperCutsONOFFCint_205_4_6,85,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TClass),-1,0,0,1,1,8,"",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("ShowMembers",1132,G__SuperCutsONOFFCint_205_5_6,121,-1,-1,0,2,1,1,0,
+"u 'TMemberInspector' - 1 - insp C - - 0 - parent",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("Streamer",835,G__SuperCutsONOFFCint_205_6_6,121,-1,-1,0,1,1,1,0,"u 'TBuffer' - 1 - b",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("StreamerNVirtual",1656,G__SuperCutsONOFFCint_205_7_6,121,-1,-1,0,1,1,1,0,"u 'TBuffer' - 1 - b",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("DeclFileName",1145,G__SuperCutsONOFFCint_205_8_6,67,-1,-1,0,0,3,1,1,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("ImplFileLine",1178,G__SuperCutsONOFFCint_205_9_6,105,-1,-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("ImplFileName",1171,G__SuperCutsONOFFCint_205_0_7,67,-1,-1,0,0,3,1,1,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("DeclFileLine",1152,G__SuperCutsONOFFCint_205_1_7,105,-1,-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   // automatic copy constructor
+   G__memfunc_setup("MFindSupercutsONOFF",1812,G__SuperCutsONOFFCint_205_2_7,(int)('i'),G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MFindSupercutsONOFF),-1,0,1,1,1,0,"u 'MFindSupercutsONOFF' - 11 - -",(char*)NULL,(void*)NULL,0);
+   // automatic destructor
+   G__memfunc_setup("~MFindSupercutsONOFF",1938,G__SuperCutsONOFFCint_205_3_7,(int)('y'),-1,-1,0,0,1,1,0,"",(char*)NULL,(void*)NULL,1);
+   G__tag_memfunc_reset();
+}
+
+static void G__setup_memfuncMFindSupercutsONOFFThetaLoop(void) {
+   /* MFindSupercutsONOFFThetaLoop */
+   G__tag_memfunc_setup(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MFindSupercutsONOFFThetaLoop));
+   G__memfunc_setup("MFindSupercutsONOFFThetaLoop",2724,G__SuperCutsONOFFCint_206_0_0,105,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MFindSupercutsONOFFThetaLoop),-1,0,2,1,1,0,
+"C - - 10 NULL name C - - 10 NULL title",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetHadronnessName",1730,G__SuperCutsONOFFCint_206_2_0,121,-1,-1,0,1,1,1,0,"u 'TString' - 11 - name",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetHadronnessNameOFF",1949,G__SuperCutsONOFFCint_206_3_0,121,-1,-1,0,1,1,1,0,"u 'TString' - 11 - name",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetPathForFiles",1491,G__SuperCutsONOFFCint_206_4_0,121,-1,-1,0,1,1,1,0,"u 'TString' - 11 - path",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetDataONOFFRootFilenames",2390,G__SuperCutsONOFFCint_206_5_0,121,-1,-1,0,2,1,1,0,
+"u 'TString' - 11 - name1 u 'TString' - 11 - name2",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetALLNames",1017,G__SuperCutsONOFFCint_206_6_0,103,-1,G__defined_typename("Bool_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetNamesManually",1635,G__SuperCutsONOFFCint_206_7_0,103,-1,G__defined_typename("Bool_t"),0,6,1,1,0,
+"U 'TString' - 0 - OptSCParamFilenameVector U 'TString' - 0 - ThetaRangeStringVector "
+"U 'TString' - 0 - TrainMatrixONFilenameVector U 'TString' - 0 - TestMatrixONFilenameVector "
+"U 'TString' - 0 - TrainMatrixOFFFilenameVector U 'TString' - 0 - TestMatrixOFFFilenameVector",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetAlphaDistributionsRootFilename",3402,G__SuperCutsONOFFCint_206_8_0,103,-1,G__defined_typename("Bool_t"),0,1,1,1,0,"u 'TString' - 11 - name",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetAlphaSig",1077,G__SuperCutsONOFFCint_206_9_0,103,-1,G__defined_typename("Bool_t"),0,1,1,1,0,"d - 'Double_t' 0 - alphasig",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetAlphaBkgMin",1354,G__SuperCutsONOFFCint_206_0_1,103,-1,G__defined_typename("Bool_t"),0,1,1,1,0,"d - 'Double_t' 0 - alphabkgmin",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetAlphaBkgMax",1356,G__SuperCutsONOFFCint_206_1_1,103,-1,G__defined_typename("Bool_t"),0,1,1,1,0,"d - 'Double_t' 0 - alphabkgmax",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("CheckAlphaSigBkg",1531,G__SuperCutsONOFFCint_206_2_1,103,-1,G__defined_typename("Bool_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetPostScriptFile",1735,G__SuperCutsONOFFCint_206_3_1,121,-1,-1,0,1,1,1,0,"U 'TPostScript' - 0 - PsFile",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetCosThetaRangeVector",2215,G__SuperCutsONOFFCint_206_4_1,103,-1,G__defined_typename("Bool_t"),0,1,1,1,0,"u 'TArrayD' - 11 - d",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetThetaRange",1295,G__SuperCutsONOFFCint_206_5_1,103,-1,G__defined_typename("Bool_t"),0,1,1,1,0,"i - 'Int_t' 0 - thetabin",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetAlphaPlotBinining",2015,G__SuperCutsONOFFCint_206_6_1,121,-1,-1,0,3,1,1,0,
+"i - 'Int_t' 0 - nbins d - 'Double_t' 0 - binlow "
+"d - 'Double_t' 0 - binup",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetNormFactorTrainHist",2237,G__SuperCutsONOFFCint_206_7_1,103,-1,G__defined_typename("Bool_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetNormFactorTestHist",2143,G__SuperCutsONOFFCint_206_8_1,103,-1,G__defined_typename("Bool_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetSigmaLiMaTrainHist",2070,G__SuperCutsONOFFCint_206_9_1,103,-1,G__defined_typename("Bool_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetSigmaLiMaTestHist",1976,G__SuperCutsONOFFCint_206_0_2,103,-1,G__defined_typename("Bool_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetNexTrainHist",1517,G__SuperCutsONOFFCint_206_1_2,103,-1,G__defined_typename("Bool_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetNexTestHist",1423,G__SuperCutsONOFFCint_206_2_2,103,-1,G__defined_typename("Bool_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetNexSigmaLiMaNormFactorNEvtsTrainTestHist",4300,G__SuperCutsONOFFCint_206_3_2,103,-1,G__defined_typename("Bool_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetSuccessfulThetaBinsHist",2662,G__SuperCutsONOFFCint_206_4_2,103,-1,G__defined_typename("Bool_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("WriteNexSigmaLiMaNormFactorNEvtsTrainTestHistToFile",5102,G__SuperCutsONOFFCint_206_5_2,121,-1,-1,0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("WriteSuccessfulThetaBinsHistToFile",3464,G__SuperCutsONOFFCint_206_6_2,121,-1,-1,0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetInitSCPar",1145,G__SuperCutsONOFFCint_206_7_2,103,-1,G__defined_typename("Bool_t"),0,1,1,1,0,"u 'TArrayD' - 1 - d",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetInitSCParSteps",1672,G__SuperCutsONOFFCint_206_8_2,103,-1,G__defined_typename("Bool_t"),0,1,1,1,0,"u 'TArrayD' - 1 - d",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("ReadSCParamsFromAsciiFile",2419,G__SuperCutsONOFFCint_206_9_2,103,-1,G__defined_typename("Bool_t"),0,2,1,1,0,
+"C - - 10 - filename i - 'Int_t' 0 - Nparams",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetFractionTrainTestOnOffEvents",3149,G__SuperCutsONOFFCint_206_0_3,121,-1,-1,0,4,1,1,0,
+"d - 'Double_t' 0 - fontrain d - 'Double_t' 0 - fontest "
+"d - 'Double_t' 0 - fofftrain d - 'Double_t' 0 - fofftest",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetTuneNormFactor",1731,G__SuperCutsONOFFCint_206_1_3,121,-1,-1,0,1,1,1,0,"g - 'Bool_t' 0 - b",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetGammaEfficiency",1796,G__SuperCutsONOFFCint_206_2_3,103,-1,G__defined_typename("Bool_t"),0,1,1,1,0,"d - 'Double_t' 0 - gammaeff",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetNormFactorFromAlphaBkg",2485,G__SuperCutsONOFFCint_206_3_3,121,-1,-1,0,1,1,1,0,"g - 'Bool_t' 0 - b",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetUseFittedQuantities",2272,G__SuperCutsONOFFCint_206_4_3,121,-1,-1,0,1,1,1,0,"g - 'Bool_t' 0 - b",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetReadMatricesFromFile",2292,G__SuperCutsONOFFCint_206_5_3,121,-1,-1,0,1,1,1,0,"g - 'Bool_t' 0 - b",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetTrainParameters",1854,G__SuperCutsONOFFCint_206_6_3,121,-1,-1,0,1,1,1,0,"g - 'Bool_t' 0 - b",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetTestParameters",1760,G__SuperCutsONOFFCint_206_7_3,121,-1,-1,0,1,1,1,0,"g - 'Bool_t' 0 - b",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetSkipOptimization",1994,G__SuperCutsONOFFCint_206_8_3,121,-1,-1,0,1,1,1,0,"g - 'Bool_t' 0 - b",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetUseInitialSCParams",2077,G__SuperCutsONOFFCint_206_9_3,121,-1,-1,0,1,1,1,0,"g - 'Bool_t' 0 - b",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetVariableNotUseTheta",2214,G__SuperCutsONOFFCint_206_0_4,121,-1,-1,0,1,1,1,0,"g - 'Bool_t' 0 - b",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetVariableNotUseTheta",2202,G__SuperCutsONOFFCint_206_1_4,103,-1,G__defined_typename("Bool_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetVariableUseStaticCuts",2438,G__SuperCutsONOFFCint_206_2_4,121,-1,-1,0,1,1,1,0,"g - 'Bool_t' 0 - b",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetVariableUseStaticCuts",2426,G__SuperCutsONOFFCint_206_3_4,103,-1,G__defined_typename("Bool_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("SetSizeRange",1204,G__SuperCutsONOFFCint_206_4_4,121,-1,-1,0,2,1,1,0,
+"d - 'Double_t' 0 - SizeMin d - 'Double_t' 0 - SizeMax",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("LoopOverThetaRanges",1932,G__SuperCutsONOFFCint_206_5_4,103,-1,G__defined_typename("Bool_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("ComputeNexSignificanceVSAlphaSig",3197,G__SuperCutsONOFFCint_206_6_4,103,-1,G__defined_typename("Bool_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("ComputeOverallSignificance",2677,G__SuperCutsONOFFCint_206_7_4,103,-1,G__defined_typename("Bool_t"),0,2,1,1,0,
+"g - 'Bool_t' 0 - CombineTrainData g - 'Bool_t' 0 - CombineTestData",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetOverallNexTrain",1822,G__SuperCutsONOFFCint_206_8_4,100,-1,G__defined_typename("Double_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetOverallNexTest",1728,G__SuperCutsONOFFCint_206_9_4,100,-1,G__defined_typename("Double_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetOverallSigmaLiMaTrain",2375,G__SuperCutsONOFFCint_206_0_5,100,-1,G__defined_typename("Double_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetOverallSigmaLiMaTest",2281,G__SuperCutsONOFFCint_206_1_5,100,-1,G__defined_typename("Double_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetGammaEfficiency",1784,G__SuperCutsONOFFCint_206_2_5,100,-1,G__defined_typename("Double_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetAlphaSig",1065,G__SuperCutsONOFFCint_206_3_5,100,-1,G__defined_typename("Double_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetAlphaBkgMin",1342,G__SuperCutsONOFFCint_206_4_5,100,-1,G__defined_typename("Double_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetAlphaBkgMax",1344,G__SuperCutsONOFFCint_206_5_5,100,-1,G__defined_typename("Double_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetSkipOptimization",1982,G__SuperCutsONOFFCint_206_6_5,103,-1,G__defined_typename("Bool_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetUseFittedQuantities",2260,G__SuperCutsONOFFCint_206_7_5,103,-1,G__defined_typename("Bool_t"),0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("Class",502,G__SuperCutsONOFFCint_206_8_5,85,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TClass),-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("Class_Name",982,G__SuperCutsONOFFCint_206_9_5,67,-1,-1,0,0,3,1,1,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("Class_Version",1339,G__SuperCutsONOFFCint_206_0_6,115,-1,G__defined_typename("Version_t"),0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("Dictionary",1046,G__SuperCutsONOFFCint_206_1_6,121,-1,-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("IsA",253,G__SuperCutsONOFFCint_206_2_6,85,G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TClass),-1,0,0,1,1,8,"",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("ShowMembers",1132,G__SuperCutsONOFFCint_206_3_6,121,-1,-1,0,2,1,1,0,
+"u 'TMemberInspector' - 1 - insp C - - 0 - parent",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("Streamer",835,G__SuperCutsONOFFCint_206_4_6,121,-1,-1,0,1,1,1,0,"u 'TBuffer' - 1 - b",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("StreamerNVirtual",1656,G__SuperCutsONOFFCint_206_5_6,121,-1,-1,0,1,1,1,0,"u 'TBuffer' - 1 - b",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("DeclFileName",1145,G__SuperCutsONOFFCint_206_6_6,67,-1,-1,0,0,3,1,1,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("ImplFileLine",1178,G__SuperCutsONOFFCint_206_7_6,105,-1,-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("ImplFileName",1171,G__SuperCutsONOFFCint_206_8_6,67,-1,-1,0,0,3,1,1,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("DeclFileLine",1152,G__SuperCutsONOFFCint_206_9_6,105,-1,-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   // automatic copy constructor
+   G__memfunc_setup("MFindSupercutsONOFFThetaLoop",2724,G__SuperCutsONOFFCint_206_0_7,(int)('i'),
+G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MFindSupercutsONOFFThetaLoop),-1,0,1,1,1,0,"u 'MFindSupercutsONOFFThetaLoop' - 11 - -",(char*)NULL,(void*)NULL,0);
+   // automatic destructor
+   G__memfunc_setup("~MFindSupercutsONOFFThetaLoop",2850,G__SuperCutsONOFFCint_206_1_7,(int)('y'),-1,-1,0,0,1,1,0,"",(char*)NULL,(void*)NULL,1);
+   G__tag_memfunc_reset();
+}
+
+
+/*********************************************************
+* Member function information setup
+*********************************************************/
+extern "C" void G__cpp_setup_memfuncSuperCutsONOFFCint() {
+}
+
+/*********************************************************
+* Global variable information setup for each class
+*********************************************************/
+static void G__cpp_setup_global0() {
+
+   /* Setting up global variables */
+   G__resetplocal();
+
+}
+
+static void G__cpp_setup_global1() {
+}
+
+static void G__cpp_setup_global2() {
+
+   G__resetglobalenv();
+}
+extern "C" void G__cpp_setup_globalSuperCutsONOFFCint() {
+  G__cpp_setup_global0();
+  G__cpp_setup_global1();
+  G__cpp_setup_global2();
+}
+
+/*********************************************************
+* Global function information setup for each class
+*********************************************************/
+static void G__cpp_setup_func0() {
+   G__lastifuncposition();
+
+}
+
+static void G__cpp_setup_func1() {
+}
+
+static void G__cpp_setup_func2() {
+}
+
+static void G__cpp_setup_func3() {
+
+   G__resetifuncposition();
+}
+
+extern "C" void G__cpp_setup_funcSuperCutsONOFFCint() {
+  G__cpp_setup_func0();
+  G__cpp_setup_func1();
+  G__cpp_setup_func2();
+  G__cpp_setup_func3();
+}
+
+/*********************************************************
+* Class,struct,union,enum tag information setup
+*********************************************************/
+/* Setup class/struct taginfo */
+G__linked_taginfo G__SuperCutsONOFFCintLN_TClass = { "TClass" , 99 , -1 };
+G__linked_taginfo G__SuperCutsONOFFCintLN_TBuffer = { "TBuffer" , 99 , -1 };
+G__linked_taginfo G__SuperCutsONOFFCintLN_TMemberInspector = { "TMemberInspector" , 99 , -1 };
+G__linked_taginfo G__SuperCutsONOFFCintLN_TObject = { "TObject" , 99 , -1 };
+G__linked_taginfo G__SuperCutsONOFFCintLN_TString = { "TString" , 99 , -1 };
+G__linked_taginfo G__SuperCutsONOFFCintLN_TArrayD = { "TArrayD" , 99 , -1 };
+G__linked_taginfo G__SuperCutsONOFFCintLN_MParContainer = { "MParContainer" , 99 , -1 };
+G__linked_taginfo G__SuperCutsONOFFCintLN_MInputStreamID = { "MInputStreamID" , 99 , -1 };
+G__linked_taginfo G__SuperCutsONOFFCintLN_MFilter = { "MFilter" , 99 , -1 };
+G__linked_taginfo G__SuperCutsONOFFCintLN_MParList = { "MParList" , 99 , -1 };
+G__linked_taginfo G__SuperCutsONOFFCintLN_MTask = { "MTask" , 99 , -1 };
+G__linked_taginfo G__SuperCutsONOFFCintLN_MFRandomSplit = { "MFRandomSplit" , 99 , -1 };
+G__linked_taginfo G__SuperCutsONOFFCintLN_MHillas = { "MHillas" , 99 , -1 };
+G__linked_taginfo G__SuperCutsONOFFCintLN_MHillasSrc = { "MHillasSrc" , 99 , -1 };
+G__linked_taginfo G__SuperCutsONOFFCintLN_MHillasExt = { "MHillasExt" , 99 , -1 };
+G__linked_taginfo G__SuperCutsONOFFCintLN_MNewImagePar = { "MNewImagePar" , 99 , -1 };
+G__linked_taginfo G__SuperCutsONOFFCintLN_MPointingPos = { "MPointingPos" , 99 , -1 };
+G__linked_taginfo G__SuperCutsONOFFCintLN_MGeomCam = { "MGeomCam" , 99 , -1 };
+G__linked_taginfo G__SuperCutsONOFFCintLN_MHadronness = { "MHadronness" , 99 , -1 };
+G__linked_taginfo G__SuperCutsONOFFCintLN_MHMatrix = { "MHMatrix" , 99 , -1 };
+G__linked_taginfo G__SuperCutsONOFFCintLN_MSupercuts = { "MSupercuts" , 99 , -1 };
+G__linked_taginfo G__SuperCutsONOFFCintLN_MTSupercutsApplied = { "MTSupercutsApplied" , 99 , -1 };
+G__linked_taginfo G__SuperCutsONOFFCintLN_MSupercutsCalcONOFF = { "MSupercutsCalcONOFF" , 99 , -1 };
+G__linked_taginfo G__SuperCutsONOFFCintLN_TH1 = { "TH1" , 99 , -1 };
+G__linked_taginfo G__SuperCutsONOFFCintLN_TCanvas = { "TCanvas" , 99 , -1 };
+G__linked_taginfo G__SuperCutsONOFFCintLN_MH = { "MH" , 99 , -1 };
+G__linked_taginfo G__SuperCutsONOFFCintLN_TPostScript = { "TPostScript" , 99 , -1 };
+G__linked_taginfo G__SuperCutsONOFFCintLN_TF1 = { "TF1" , 99 , -1 };
+G__linked_taginfo G__SuperCutsONOFFCintLN_MHFindSignificanceONOFF = { "MHFindSignificanceONOFF" , 99 , -1 };
+G__linked_taginfo G__SuperCutsONOFFCintLN_TTree = { "TTree" , 99 , -1 };
+G__linked_taginfo G__SuperCutsONOFFCintLN_TArrayI = { "TArrayI" , 99 , -1 };
+G__linked_taginfo G__SuperCutsONOFFCintLN_TH1F = { "TH1F" , 99 , -1 };
+G__linked_taginfo G__SuperCutsONOFFCintLN_MEvtLoop = { "MEvtLoop" , 99 , -1 };
+G__linked_taginfo G__SuperCutsONOFFCintLN_MH3 = { "MH3" , 99 , -1 };
+G__linked_taginfo G__SuperCutsONOFFCintLN_MFindSupercutsONOFF = { "MFindSupercutsONOFF" , 99 , -1 };
+G__linked_taginfo G__SuperCutsONOFFCintLN_MFindSupercutsONOFFThetaLoop = { "MFindSupercutsONOFFThetaLoop" , 99 , -1 };
+
+/* Reset class/struct taginfo */
+extern "C" void G__cpp_reset_tagtableSuperCutsONOFFCint() {
+  G__SuperCutsONOFFCintLN_TClass.tagnum = -1 ;
+  G__SuperCutsONOFFCintLN_TBuffer.tagnum = -1 ;
+  G__SuperCutsONOFFCintLN_TMemberInspector.tagnum = -1 ;
+  G__SuperCutsONOFFCintLN_TObject.tagnum = -1 ;
+  G__SuperCutsONOFFCintLN_TString.tagnum = -1 ;
+  G__SuperCutsONOFFCintLN_TArrayD.tagnum = -1 ;
+  G__SuperCutsONOFFCintLN_MParContainer.tagnum = -1 ;
+  G__SuperCutsONOFFCintLN_MInputStreamID.tagnum = -1 ;
+  G__SuperCutsONOFFCintLN_MFilter.tagnum = -1 ;
+  G__SuperCutsONOFFCintLN_MParList.tagnum = -1 ;
+  G__SuperCutsONOFFCintLN_MTask.tagnum = -1 ;
+  G__SuperCutsONOFFCintLN_MFRandomSplit.tagnum = -1 ;
+  G__SuperCutsONOFFCintLN_MHillas.tagnum = -1 ;
+  G__SuperCutsONOFFCintLN_MHillasSrc.tagnum = -1 ;
+  G__SuperCutsONOFFCintLN_MHillasExt.tagnum = -1 ;
+  G__SuperCutsONOFFCintLN_MNewImagePar.tagnum = -1 ;
+  G__SuperCutsONOFFCintLN_MPointingPos.tagnum = -1 ;
+  G__SuperCutsONOFFCintLN_MGeomCam.tagnum = -1 ;
+  G__SuperCutsONOFFCintLN_MHadronness.tagnum = -1 ;
+  G__SuperCutsONOFFCintLN_MHMatrix.tagnum = -1 ;
+  G__SuperCutsONOFFCintLN_MSupercuts.tagnum = -1 ;
+  G__SuperCutsONOFFCintLN_MTSupercutsApplied.tagnum = -1 ;
+  G__SuperCutsONOFFCintLN_MSupercutsCalcONOFF.tagnum = -1 ;
+  G__SuperCutsONOFFCintLN_TH1.tagnum = -1 ;
+  G__SuperCutsONOFFCintLN_TCanvas.tagnum = -1 ;
+  G__SuperCutsONOFFCintLN_MH.tagnum = -1 ;
+  G__SuperCutsONOFFCintLN_TPostScript.tagnum = -1 ;
+  G__SuperCutsONOFFCintLN_TF1.tagnum = -1 ;
+  G__SuperCutsONOFFCintLN_MHFindSignificanceONOFF.tagnum = -1 ;
+  G__SuperCutsONOFFCintLN_TTree.tagnum = -1 ;
+  G__SuperCutsONOFFCintLN_TArrayI.tagnum = -1 ;
+  G__SuperCutsONOFFCintLN_TH1F.tagnum = -1 ;
+  G__SuperCutsONOFFCintLN_MEvtLoop.tagnum = -1 ;
+  G__SuperCutsONOFFCintLN_MH3.tagnum = -1 ;
+  G__SuperCutsONOFFCintLN_MFindSupercutsONOFF.tagnum = -1 ;
+  G__SuperCutsONOFFCintLN_MFindSupercutsONOFFThetaLoop.tagnum = -1 ;
+}
+
+
+extern "C" void G__cpp_setup_tagtableSuperCutsONOFFCint() {
+
+   /* Setting up class,struct,union tag entry */
+   G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TClass);
+   G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TBuffer);
+   G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TMemberInspector);
+   G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TObject);
+   G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TString);
+   G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TArrayD);
+   G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MParContainer);
+   G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MInputStreamID);
+   G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MFilter);
+   G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MParList);
+   G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MTask);
+   G__tagtable_setup(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MFRandomSplit),sizeof(MFRandomSplit),-1,323584,"A Filter giving kTRUE with a certain probability",G__setup_memvarMFRandomSplit,G__setup_memfuncMFRandomSplit);
+   G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MHillas);
+   G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MHillasSrc);
+   G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MHillasExt);
+   G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MNewImagePar);
+   G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MPointingPos);
+   G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MGeomCam);
+   G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MHadronness);
+   G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MHMatrix);
+   G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MSupercuts);
+   G__tagtable_setup(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MTSupercutsApplied),sizeof(MTSupercutsApplied),-1,324864,"Storage Container for the supercuts applied",G__setup_memvarMTSupercutsApplied,G__setup_memfuncMTSupercutsApplied);
+   G__tagtable_setup(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MSupercutsCalcONOFF),sizeof(MSupercutsCalcONOFF),-1,323840,"A class to evaluate the Supercuts",G__setup_memvarMSupercutsCalcONOFF,G__setup_memfuncMSupercutsCalcONOFF);
+   G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TH1);
+   G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TCanvas);
+   G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MH);
+   G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TPostScript);
+   G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TF1);
+   G__tagtable_setup(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MHFindSignificanceONOFF),sizeof(MHFindSignificanceONOFF),-1,324864,"Determine significance from alpha plot",G__setup_memvarMHFindSignificanceONOFF,G__setup_memfuncMHFindSignificanceONOFF);
+   G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TTree);
+   G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TArrayI);
+   G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_TH1F);
+   G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MEvtLoop);
+   G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MH3);
+   G__tagtable_setup(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MFindSupercutsONOFF),sizeof(MFindSupercutsONOFF),-1,324864,"Class for optimization of the Supercuts",G__setup_memvarMFindSupercutsONOFF,G__setup_memfuncMFindSupercutsONOFF);
+   G__tagtable_setup(G__get_linked_tagnum(&G__SuperCutsONOFFCintLN_MFindSupercutsONOFFThetaLoop),sizeof(MFindSupercutsONOFFThetaLoop),-1,324864,(char*)NULL,G__setup_memvarMFindSupercutsONOFFThetaLoop,G__setup_memfuncMFindSupercutsONOFFThetaLoop);
+}
+extern "C" void G__cpp_setupSuperCutsONOFFCint(void) {
+  G__check_setup_version(30051515,"G__cpp_setupSuperCutsONOFFCint()");
+  G__set_cpp_environmentSuperCutsONOFFCint();
+  G__cpp_setup_tagtableSuperCutsONOFFCint();
+
+  G__cpp_setup_inheritanceSuperCutsONOFFCint();
+
+  G__cpp_setup_typetableSuperCutsONOFFCint();
+
+  G__cpp_setup_memvarSuperCutsONOFFCint();
+
+  G__cpp_setup_memfuncSuperCutsONOFFCint();
+  G__cpp_setup_globalSuperCutsONOFFCint();
+  G__cpp_setup_funcSuperCutsONOFFCint();
+
+   if(0==G__getsizep2memfunc()) G__get_sizep2memfuncSuperCutsONOFFCint();
+  return;
+}
+class G__cpp_setup_initSuperCutsONOFFCint {
+  public:
+    G__cpp_setup_initSuperCutsONOFFCint() { G__add_setup_func("SuperCutsONOFFCint",(G__incsetup)(&G__cpp_setupSuperCutsONOFFCint)); G__call_setup_funcs(); }
+   ~G__cpp_setup_initSuperCutsONOFFCint() { G__remove_setup_func("SuperCutsONOFFCint"); }
+};
+G__cpp_setup_initSuperCutsONOFFCint G__cpp_setup_initializerSuperCutsONOFFCint;
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/SuperCutsONOFFCint.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/SuperCutsONOFFCint.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/SuperCutsONOFFCint.h	(revision 9661)
@@ -0,0 +1,77 @@
+/********************************************************************
+* SuperCutsONOFFCint.h
+********************************************************************/
+#ifdef __CINT__
+#error SuperCutsONOFFCint.h/C is only for compilation. Abort cint.
+#endif
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <string.h>
+#define G__ANSIHEADER
+#define G__DICTIONARY
+#include "G__ci.h"
+extern "C" {
+extern void G__cpp_setup_tagtableSuperCutsONOFFCint();
+extern void G__cpp_setup_inheritanceSuperCutsONOFFCint();
+extern void G__cpp_setup_typetableSuperCutsONOFFCint();
+extern void G__cpp_setup_memvarSuperCutsONOFFCint();
+extern void G__cpp_setup_globalSuperCutsONOFFCint();
+extern void G__cpp_setup_memfuncSuperCutsONOFFCint();
+extern void G__cpp_setup_funcSuperCutsONOFFCint();
+extern void G__set_cpp_environmentSuperCutsONOFFCint();
+}
+
+
+#include "TROOT.h"
+#include "TMemberInspector.h"
+#include "MFRandomSplit.h"
+#include "MSupercutsCalcONOFF.h"
+#include "MHFindSignificanceONOFF.h"
+#include "MTSupercutsApplied.h"
+#include "MFindSupercutsONOFF.h"
+#include "MFindSupercutsONOFFThetaLoop.h"
+#include "SuperCutsONOFFIncl.h"
+
+#ifndef G__MEMFUNCBODY
+#endif
+
+extern G__linked_taginfo G__SuperCutsONOFFCintLN_TClass;
+extern G__linked_taginfo G__SuperCutsONOFFCintLN_TBuffer;
+extern G__linked_taginfo G__SuperCutsONOFFCintLN_TMemberInspector;
+extern G__linked_taginfo G__SuperCutsONOFFCintLN_TObject;
+extern G__linked_taginfo G__SuperCutsONOFFCintLN_TString;
+extern G__linked_taginfo G__SuperCutsONOFFCintLN_TArrayD;
+extern G__linked_taginfo G__SuperCutsONOFFCintLN_MParContainer;
+extern G__linked_taginfo G__SuperCutsONOFFCintLN_MInputStreamID;
+extern G__linked_taginfo G__SuperCutsONOFFCintLN_MFilter;
+extern G__linked_taginfo G__SuperCutsONOFFCintLN_MParList;
+extern G__linked_taginfo G__SuperCutsONOFFCintLN_MTask;
+extern G__linked_taginfo G__SuperCutsONOFFCintLN_MFRandomSplit;
+extern G__linked_taginfo G__SuperCutsONOFFCintLN_MHillas;
+extern G__linked_taginfo G__SuperCutsONOFFCintLN_MHillasSrc;
+extern G__linked_taginfo G__SuperCutsONOFFCintLN_MHillasExt;
+extern G__linked_taginfo G__SuperCutsONOFFCintLN_MNewImagePar;
+extern G__linked_taginfo G__SuperCutsONOFFCintLN_MPointingPos;
+extern G__linked_taginfo G__SuperCutsONOFFCintLN_MGeomCam;
+extern G__linked_taginfo G__SuperCutsONOFFCintLN_MHadronness;
+extern G__linked_taginfo G__SuperCutsONOFFCintLN_MHMatrix;
+extern G__linked_taginfo G__SuperCutsONOFFCintLN_MSupercuts;
+extern G__linked_taginfo G__SuperCutsONOFFCintLN_MTSupercutsApplied;
+extern G__linked_taginfo G__SuperCutsONOFFCintLN_MSupercutsCalcONOFF;
+extern G__linked_taginfo G__SuperCutsONOFFCintLN_TH1;
+extern G__linked_taginfo G__SuperCutsONOFFCintLN_TCanvas;
+extern G__linked_taginfo G__SuperCutsONOFFCintLN_MH;
+extern G__linked_taginfo G__SuperCutsONOFFCintLN_TPostScript;
+extern G__linked_taginfo G__SuperCutsONOFFCintLN_TF1;
+extern G__linked_taginfo G__SuperCutsONOFFCintLN_MHFindSignificanceONOFF;
+extern G__linked_taginfo G__SuperCutsONOFFCintLN_TTree;
+extern G__linked_taginfo G__SuperCutsONOFFCintLN_TArrayI;
+extern G__linked_taginfo G__SuperCutsONOFFCintLN_TH1F;
+extern G__linked_taginfo G__SuperCutsONOFFCintLN_MEvtLoop;
+extern G__linked_taginfo G__SuperCutsONOFFCintLN_MH3;
+extern G__linked_taginfo G__SuperCutsONOFFCintLN_MFindSupercutsONOFF;
+extern G__linked_taginfo G__SuperCutsONOFFCintLN_MFindSupercutsONOFFThetaLoop;
+
+/* STUB derived class for protected member access */
Index: /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/SuperCutsONOFFDep.d
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/SuperCutsONOFFDep.d	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/SuperCutsONOFFDep.d	(revision 9661)
@@ -0,0 +1,9 @@
+# DO NOT DELETE
+
+SuperCutsONOFFDep.d MFRandomSplit.o: MFRandomSplit.h ../../../mbase/MFilter.h ../../../mbase/MTask.h ../../../mbase/MInputStreamID.h ../../../mbase/MParContainer.h ../../../mbase/MAGIC.h ../../../mbase/MParList.h ../../../mbase/MLog.h ../../../mbase/MLogManip.h
+SuperCutsONOFFDep.d MSupercutsCalcONOFF.o: MSupercutsCalcONOFF.h ../../../mbase/MTask.h ../../../mbase/MInputStreamID.h ../../../mbase/MParContainer.h ../../../mbase/MAGIC.h ../../../mbase/MParList.h ../../../mimage/MHillasExt.h ../../../mimage/MHillasSrc.h ../../../mimage/MHillas.h ../../../mimage/MNewImagePar.h ../../../mpointing/MPointingPos.h ../../../manalysis/MCerPhotEvt.h ../../../mgui/MCamEvent.h ../../../manalysis/MCerPhotPix.h ../../../mgeom/MGeomCam.h ../../../manalysis/MHadronness.h MTSupercutsApplied.h ../../../mhbase/MHMatrix.h ../../../mhbase/MH.h ../../../manalysis/MSupercuts.h ../../../mbase/MLog.h ../../../mbase/MLogManip.h
+SuperCutsONOFFDep.d MHFindSignificanceONOFF.o: MHFindSignificanceONOFF.h ../../../mhbase/MH.h ../../../mbase/MParContainer.h ../../../mbase/MAGIC.h ../../../mbase/MLog.h ../../../mbase/MLogManip.h ../../../manalysis/MMinuitInterface.h
+SuperCutsONOFFDep.d MTSupercutsApplied.o: MTSupercutsApplied.h ../../../mbase/MAGIC.h ../../../mbase/MParContainer.h ../../../mbase/MLog.h ../../../mbase/MLogManip.h
+SuperCutsONOFFDep.d MFindSupercutsONOFF.o: MFindSupercutsONOFF.h ../../../mbase/MParContainer.h ../../../mbase/MAGIC.h ../../../mhbase/MBinning.h ../../../mbase/MContinue.h ../../../mbase/MTask.h ../../../mbase/MInputStreamID.h ../../../manalysis/MSupercuts.h MSupercutsCalcONOFF.h ../../../mdata/MDataElement.h ../../../mdata/MData.h ../../../mdata/MDataMember.h ../../../mbase/MEvtLoop.h ../../../mfilter/MFCT1SelFinal.h ../../../mbase/MFilter.h ../../../mfbase/MF.h ../../../mfbase/MFEventSelector.h ../../../mfbase/MFEventSelector2.h ../../../mdata/MDataChain.h ../../../mhbase/MFillH.h ../../../mgeom/MGeomCamMagic.h ../../../mgeom/MGeomCam.h MFRandomSplit.h ../../../mhbase/MH3.h ../../../mhbase/MH.h ../../../mhist/MHCT1Supercuts.h ../../../mhist/MHFindSignificance.h MHFindSignificanceONOFF.h MTSupercutsApplied.h ../../../mhbase/MHMatrix.h ../../../mhist/MHOnSubtraction.h ../../../mdata/MDataValue.h ../../../mbase/MLog.h ../../../mbase/MLogManip.h ../../../manalysis/MMatrixLoop.h ../../../manalysis/MMinuitInterface.h ../../../mbase/MParList.h ../../../mbase/MProgressBar.h ../../../mfileio/MReadMarsFile.h ../../../mfileio/MReadTree.h ../../../mfileio/MRead.h ../../../mbase/MTaskList.h
+SuperCutsONOFFDep.d MFindSupercutsONOFFThetaLoop.o: MFindSupercutsONOFFThetaLoop.h ../../../mbase/MParContainer.h ../../../mbase/MAGIC.h MFindSupercutsONOFF.h ../../../mhbase/MBinning.h ../../../mbase/MContinue.h ../../../mbase/MTask.h ../../../mbase/MInputStreamID.h ../../../manalysis/MSupercuts.h MSupercutsCalcONOFF.h ../../../mdata/MDataElement.h ../../../mdata/MData.h ../../../mdata/MDataMember.h ../../../mbase/MEvtLoop.h ../../../mfilter/MFCT1SelFinal.h ../../../mbase/MFilter.h ../../../mfbase/MF.h ../../../mfbase/MFEventSelector.h ../../../mfbase/MFEventSelector2.h ../../../mdata/MDataChain.h ../../../mhbase/MFillH.h ../../../mgeom/MGeomCamMagic.h ../../../mgeom/MGeomCam.h MFRandomSplit.h ../../../mhbase/MH3.h ../../../mhbase/MH.h ../../../mhist/MHCT1Supercuts.h ../../../mhist/MHFindSignificance.h MHFindSignificanceONOFF.h ../../../mhbase/MHMatrix.h ../../../mhist/MHOnSubtraction.h ../../../mdata/MDataValue.h ../../../mbase/MLog.h ../../../mbase/MLogManip.h ../../../manalysis/MMatrixLoop.h ../../../manalysis/MMinuitInterface.h ../../../mbase/MParList.h ../../../mbase/MProgressBar.h ../../../mfileio/MReadMarsFile.h ../../../mfileio/MReadTree.h ../../../mfileio/MRead.h ../../../mbase/MTaskList.h
+SuperCutsONOFFDep.d: Makefile
Index: /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/SuperCutsONOFFIncl.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/SuperCutsONOFFIncl.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/SuperCutsONOFFIncl.h	(revision 9661)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/SuperCutsONOFFLinkDef.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/SuperCutsONOFFLinkDef.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mmpi/SupercutsONOFFClasses/SuperCutsONOFFLinkDef.h	(revision 9661)
@@ -0,0 +1,15 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+
+#pragma link C++ class MFRandomSplit+;
+#pragma link C++ class MSupercutsCalcONOFF+;
+#pragma link C++ class MHFindSignificanceONOFF+;
+#pragma link C++ class MTSupercutsApplied+;
+#pragma link C++ class MFindSupercutsONOFF+;
+#pragma link C++ class MFindSupercutsONOFFThetaLoop+;
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtemp/mmpi/asciifiles/OptimizedMkn421DynCutsGridWithSelected22pointsMay19.txt
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mmpi/asciifiles/OptimizedMkn421DynCutsGridWithSelected22pointsMay19.txt	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mmpi/asciifiles/OptimizedMkn421DynCutsGridWithSelected22pointsMay19.txt	(revision 9661)
@@ -0,0 +1,107 @@
+0.291162		0.03
+0.0767981		0.01
+0.0			0.0
+0.0319514		0.003
+0.0			0.00
+0.0			0.0
+0.00197097		0.001
+0.0			0.00
+0.136532		0.01
+0.0672596		0.01
+0.0			0.0
+-0.00328891		0.003
+0.0			0.000
+0.0			0.0
+0.00346991		0.001
+0.0			0.0
+0.121355		0.01
+0.00941745		0.002
+0.0			0.0
+0.0130449		0.001
+0.0			0.0
+0.0			0.0
+-7.67104e-05		0.001
+0.0			0.0
+0.0553008		0.005
+0.00677071		0.002
+0.0			0.0
+0.012681		0.001
+0.0			0.000
+0.0			0.0
+0.00110842		0.001
+0.0			0.0
+1.21178			0.1
+0.0			0.0
+0.0			0.0
+0.105799		0.005
+0.0			0.0
+0.0			0.0
+0.00212262		0.001
+0.0			0.0
+0.607549		0.06
+0.0			0.0
+0.0			0.0
+0.0390365		0.006
+0.0			0.0
+0.0			0.0
+0.000148364		0.001
+0.0			0.0
+1.e10			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+-1.e10			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+1.e10			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+-1.e10			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+.25			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+-1.e10			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+13.123440		0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mmpi/asciifiles/StartingValuesForOptimizationMkn421DynCutsOnSizeAndDist.txt
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mmpi/asciifiles/StartingValuesForOptimizationMkn421DynCutsOnSizeAndDist.txt	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mmpi/asciifiles/StartingValuesForOptimizationMkn421DynCutsOnSizeAndDist.txt	(revision 9661)
@@ -0,0 +1,107 @@
+0.32			0.03
+0.05			0.01
+0.0			0.0
+0.034			0.003
+0.0			0.01
+0.0			0.0
+0.0			0.001
+0.0			0.01
+0.12			0.01
+0.05			0.01
+0.0			0.0
+0.034			0.003
+0.0			0.001
+0.0			0.0
+0.0			0.001
+0.0			0.001
+0.12			0.01
+0.007			0.002
+0.0			0.0
+0.013			0.001
+0.0			0.001
+0.0			0.0
+0.0			0.001
+0.0			0.001
+0.055			0.005
+0.007			0.002
+0.0			0.0
+0.013			0.001
+0.0			0.001
+0.0			0.0
+0.0			0.001
+0.0			0.001
+1.25			0.1
+0.0			0.0
+0.0			0.0
+0.059			0.005
+0.0			0.0
+0.0			0.0
+0.0			0.001
+0.0			0.0
+0.60			0.06
+0.0			0.0
+0.0			0.0
+0.059			0.006
+0.0			0.0
+0.0			0.0
+0.0			0.001
+0.0			0.0
+1.e10			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+-1.e10			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+1.e10			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+-1.e10			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+.25			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+-1.e10			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+13.123440		0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mmpi/asciifiles/StartingValuesForSmallSizes1.txt
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mmpi/asciifiles/StartingValuesForSmallSizes1.txt	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mmpi/asciifiles/StartingValuesForSmallSizes1.txt	(revision 9661)
@@ -0,0 +1,107 @@
+0.32			0.03
+0.05			0.01
+0.0			0.0
+0.034			0.003
+0.0			0.01
+0.0			0.0
+0.0			0.001
+0.0			0.01
+0.12			0.01
+0.05			0.01
+0.0			0.0
+0.034			0.003
+0.0			0.001
+0.0			0.0
+0.0			0.001
+0.0			0.001
+0.12			0.01
+0.007			0.002
+0.0			0.0
+0.013			0.001
+0.0			0.001
+0.0			0.0
+0.0			0.001
+0.0			0.001
+0.055			0.005
+0.007			0.002
+0.0			0.0
+0.013			0.001
+0.0			0.001
+0.0			0.0
+0.0			0.001
+0.0			0.001
+1.25			0.1
+0.0			0.0
+0.0			0.0
+0.059			0.005
+0.0			0.0
+0.0			0.0
+0.0			0.001
+0.0			0.0
+0.60			0.06
+0.0			0.0
+0.0			0.0
+0.059			0.006
+0.0			0.0
+0.0			0.0
+0.0			0.001
+0.0			0.0
+1.e10			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+-1.e10			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+1.e10			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+-1.e10			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+.25			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+-1.e10			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+13.123440		0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+0.0			0.0
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mmpi/macros/SCDynamicalSupercutsApplied.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mmpi/macros/SCDynamicalSupercutsApplied.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mmpi/macros/SCDynamicalSupercutsApplied.C	(revision 9661)
@@ -0,0 +1,273 @@
+// The aim of this macro is to show the cuts applied to the 
+// events that survive the g/h separation cuts + the alpha cut.
+// The macro can be modified easily to show other things...
+
+// This program reads a TTree (specified by the user) and 
+// stores the array containing the variables specified by 
+// the user into pointer to arrays. This is done through 
+// the member function TTree::Draw()
+
+// Selection rules (cuts) are allowed. In such case, only 
+// the variables of the events that pass the cuts specified are 
+// stored into the arrays. 
+
+
+// It  works with arrays of pointers 
+// and plot N quantities in the N pads of the same Canvas.
+// single strings that contain
+// the quantities to be plotted are used.
+
+// This program is an alternative to another (faster?) more 
+// professional way of getting info from a Tree.
+
+
+// As input, this macro needs a root file that is 
+// generated by the SupercutsONOFF programs, which is 
+// the root file containing the TTrees with the needed info.
+
+// The user must write
+
+// 1) Name of the root file with the info (Path included!!)
+
+// 2) Name of the output ps file produced by the macro (with path included!!)
+
+
+gROOT -> Reset();
+
+void SCDynamicalSupercutsApplied()
+{
+
+
+
+
+  char* RootFile = {"/.magic/magicserv01/scratch/Daniel/SuperCuts/Mrk421/2004_04_22/4slices_3520_nc/E800_1200_Opt_MC/RootFileDynCuts.root"};
+
+  char* OutputPsFilename = {"/.magic/magicserv01/scratch/Daniel/SuperCuts/Mrk421/2004_04_22/4slices_3520_nc/E800_1200_Opt_MC/DynamicalCutsLengthWidthDistApplied.eps"};
+  
+  
+  char* Xaxis = "log(SIZE/[photons])";
+  
+  char* YaxisVector[6] = {"LENGTH UP [\\circ]", "LENGTH LOW [\\circ]", 
+		       "WIDTH UP [\\circ]", "WIDTH LOW [\\circ]", 
+		       "DIST UP [\\circ]", "DIST LOW [\\circ]"}; 
+
+  
+  
+
+
+  
+  
+ 
+
+
+// Name of the root file that contains the Tree
+    char* TreeName = {"SupercutsAppliedTrainONThetaRange0_1570mRad"}; // Name of the Tree that contains the variables that have to plotted
+   
+
+    
+    const Int_t NQuantitiesToBePlot = 6;
+
+    // Write here the quantities to be plot
+    
+    TString QuantitiesToBePlot[NQuantitiesToBePlot] = 
+    {"SupercutsApplied.LengthUp:log10(ShowerParameters.Size)", 
+     "SupercutsApplied.LengthLow:log10(ShowerParameters.Size)", 
+     "SupercutsApplied.WidthUp:log10(ShowerParameters.Size)", 
+     "SupercutsApplied.WidthLow:log10(ShowerParameters.Size)",
+     "SupercutsApplied.DistUp:log10(ShowerParameters.Size)", 
+     "SupercutsApplied.DistLow:log10(ShowerParameters.Size)"};
+
+
+    // Write here the number of rows and columns in the ps file
+
+    const Int_t Nrows = 2;
+    const Int_t Ncolumns = 3;
+
+    // Title of Canvas.. not really important...
+
+    TString CanvasTitle = ("Dynamical cuts in Length, Width and Dist");
+
+    // 0 for not using and 1 for using Selection cut
+    Int_t UseSelectionCut = 1; 
+    // Section rule to be applied in the data to be plotted
+    char* SelectionCut = {"(SupercutsApplied.Hadronness < 0.5) && ShowerParameters.Alpha < 12"}; 
+    
+    
+
+    // Vectors where variables will be stored
+    Int_t ArrayDimension[NQuantitiesToBePlot];
+    Double_t* VarYArray[NQuantitiesToBePlot];
+    Double_t* VarXArray[NQuantitiesToBePlot];
+
+
+    
+
+    // Vector  of pointers to TFile objects and TTree objects that will be used to retrieve 
+    // requested info from root file. 
+
+    TFile* FileVector[NQuantitiesToBePlot];
+    TTree* TreeVector[NQuantitiesToBePlot];
+
+    // Vector of pointers to graph objects where quantities will be plot
+
+    TGraph* GraphVector[NQuantitiesToBePlot];
+
+
+    // Options available for plotting the histo are the following ones:
+    // "prof" -->> Profile
+    // "goff" -->> No draw variables in TTree::Draw()
+    // ""     -->> No special option is set
+
+    char* DrawingOption = {"goff"};
+
+
+    TString selection = UseSelectionCut ? SelectionCut : NULL;
+
+
+
+    // Tree is read and stored in dynamic memory pointed by pointer tree.
+    
+    //  TFile file (RootFile);
+    // TTree* tree = (TTree*) file.Get(TreeName);
+
+
+  
+
+    // Loop in which arrays are retrieved from root file and 
+    // array dimensions (with events surviving the selection)
+    // are retrieved too.
+
+    for (Int_t i = 0; i < NQuantitiesToBePlot; i++)
+      {
+
+
+	FileVector[i] = new TFile(RootFile, "READ");
+
+	TreeVector[i] = (TTree*) FileVector[i] -> Get(TreeName);
+	
+	 // Array dimension of temporal vectors where the variables 
+	// that will be plotted are stored can be modify accordingly 
+	// with the nnumber of events of the Tree
+	
+	TreeVector[i] -> SetEstimate(TreeVector[i] -> GetEntries());
+
+	// Requested info is "plotted"
+
+	TreeVector[i]  -> Draw(QuantitiesToBePlot[i].Data(), selection, DrawingOption);
+
+	
+	// Let's find out the REAL length of the vectors we want 
+	// to get from the tree (Selection rules may have removed some events)
+	
+	ArrayDimension[i] = TreeVector[i] -> GetSelectedRows();
+	
+	// Vectors are retrieved
+
+	VarYArray[i] = TreeVector[i] -> GetV1();
+	VarXArray[i] = TreeVector[i] -> GetV2();
+
+      }
+
+  
+   
+    // Silly info is displayed for testing...
+
+
+   
+    for (Int_t i = 0; i < NQuantitiesToBePlot; i++)
+      {
+	cout << "Events that passed the selection for quantity " 
+	     << QuantitiesToBePlot[i] << " : " << ArrayDimension[i] << endl;
+      }
+
+   
+    // Initialization of the graphs with the info contained in the vectors
+    // Kind of default features are set for all graphs
+
+
+     TAxis* axispointer;
+      
+     
+
+    for (Int_t i = 0; i < NQuantitiesToBePlot; i++)
+      {	
+	GraphVector[i] = new TGraph (ArrayDimension[i], VarXArray[i], VarYArray[i]);
+	
+	GraphVector[i] -> SetTitle(QuantitiesToBePlot[i].Data());
+
+	
+	GraphVector[i]->SetFillColor(19);
+	GraphVector[i]->SetMarkerColor(2);
+	GraphVector[i]->SetMarkerStyle(21);
+	GraphVector[i]->SetMarkerSize(0.5);
+
+	axispointer = GraphVector[i] -> GetXaxis();
+	axispointer -> SetTitle(Xaxis);
+	axispointer -> SetTitleOffset(1.3);
+	axispointer -> SetTitleSize(0.05);
+
+
+	axispointer =  GraphVector[i] -> GetYaxis();
+	axispointer -> SetTitle(YaxisVector[i]);
+	axispointer -> SetTitleOffset(1.5);
+	axispointer -> SetTitleSize(0.05);
+	
+
+      }
+
+
+
+   
+    /*
+    // Let's output some of their components:
+    
+    for ( Int_t i = 0; i < ArrayDimension[]0; i++)
+    {
+	cout << VarXArray[0][i] << "  " <<  VarYArray[0][i] << endl;
+
+    }
+    */
+
+    
+    // TCanvas is defined with the NQuantitiesToBePlot Pads where the graphs 
+    // will be plotted
+
+    TCanvas* Canvas = new TCanvas(CanvasTitle, CanvasTitle, 600, 800);
+    Canvas -> SetBorderMode(0);
+    Canvas -> Divide(Nrows, Ncolumns);
+    
+    
+    // gStyle -> SetFrameFillColor(10);
+    gStyle -> SetPadLeftMargin (0.15);
+    gStyle -> SetPadRightMargin (0.05);
+    gStyle -> SetPadTopMargin (0.00);
+    gStyle -> SetPadBottomMargin (0.20);
+    
+    gStyle -> SetOptTitle(0);
+
+    // Graphs are plot in canvas
+    
+    for (Int_t i = 0; i < NQuantitiesToBePlot; i++)
+      {	
+	Canvas -> cd(i+1);
+	gPad -> SetBorderMode(0);
+	gPad->SetGridx();
+	gPad->SetGridy(); 
+	//gPad -> SetPadTopMargin (0.05);
+	//gPad -> SetPadBottomMargin (0.15);
+	
+	GraphVector[i] -> Draw("AP");
+      }
+    
+    
+
+    Canvas -> SaveAs(OutputPsFilename);
+
+
+}
+    
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mmpi/macros/SCNexSignificanceVSAlphaCut.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mmpi/macros/SCNexSignificanceVSAlphaCut.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mmpi/macros/SCNexSignificanceVSAlphaCut.C	(revision 9661)
@@ -0,0 +1,466 @@
+// This program produces a ps file with 
+// two graphs in the same TPad, but 
+// with different axis. 
+
+// The aim is to plot Nex and significance vs 
+// cut in alpha parameter.
+
+// As input, this macro needs a root file that is 
+// generated by the SupercutsONOFF programs.
+
+// It will read the histograms where Nex and significance 
+// vs alpha are stored and will plot this info in a single 
+// ps file. 
+
+// The user must write
+
+// 1) Name of the root file with the info (Path included!!)
+
+// 2) Name of the output ps file (with path included!!)
+
+// Depending on the values to be plotted the axis scale
+// as well as the axis offsets for labels might have to be 
+// modified. If I have time I will modify the program to 
+// make it automatic...
+
+
+
+
+#include <string.h>
+#include <iostream.h>
+#include <fstream.h>
+#include <iomanip.h>
+#include <stdlib.h>
+#include <math.h>
+
+
+gROOT -> Reset();
+
+void SCNexSignificanceVSAlphaCut() 
+{
+
+  
+  
+  char* SCRootFile = {"/.magic/magicserv01/scratch/Daniel/SuperCuts/Mrk421/2004_04_22/4slices_3520_nc/E800_1200_Opt/RootFileDynCuts.root"};
+
+  char* output_ps_file = {"/.magic/magicserv01/scratch/Daniel/SuperCuts/Mrk421/2004_04_22/4slices_3520_nc/E800_1200_Opt/NexSignificanceVSCutinAlpha.ps"};
+
+  
+ 
+  char* ps_title = 
+    {"Excess events (green) and significance (red) vs cut in alpha"};
+
+
+
+
+  // Name of the histograms (contained in root file) that contain the number of 
+  // excess events and significance vs alpha cut
+
+  TString ExcessEventsHistoName = ("NexVSAlphaTrainThetaRange0_1570mRad");
+  TString SignificanceHistoName = ("SignificanceVSAlphaTrainThetaRange0_1570mRad");
+
+
+  // Axis titles
+
+  char* xaxis_title = "Cut in alpha (degrees)";
+  char* yaxis_title = "Excess events";
+  char* yaxis_2_title = "Significance";
+
+  // Axis for plot
+
+  const Double_t pad_xlow = 0;
+  const Double_t pad_ylow = 0;
+  const Double_t pad_xup = 30;
+  const Double_t pad_yup = 1000;
+
+  
+  
+  
+  // Axis labels offsets for plot
+ 
+  const Double_t xaxis_label_xoffset_pad = 8;
+  const Double_t xaxis_label_yoffset_pad = -300;
+  const Double_t yaxis_label_xoffset_pad = -5;
+  const Double_t yaxis_label_yoffset_pad = 1200;
+  const Double_t yaxis_2_label_xoffset_pad = 35;
+  const Double_t yaxis_2_label_yoffset_pad = 1200;
+
+ 
+
+  // Vector of pointer to histograms that will be plotted
+  // Colors and marker types are also defined 
+
+
+  const Int_t n_graphs = 2; 
+  TGraph* graph_vector [n_graphs];
+  Int_t graph_colors_vector[n_graphs] = {3,2};
+  Int_t polimarker_style_vector[n_graphs] = {21,25};
+  char* additional_info_vector[n_graphs] = 
+    {"Excess events", "Significance"};
+
+
+
+  // TMP VARIABLES
+
+  Int_t tmp_int = 0;
+
+  TH1F* histo1;
+  TH1F* histo2;
+
+
+ 
+  Double_t y_axis_2_min_value = 0.0;
+  Double_t y_axis_2_max_value = 0.0;
+  
+  Double_t graph_y_minmax_vector [n_graphs][2];
+  // It contains y values min and max for graphs that 
+  // are plotted.
+  
+  Double_t graph_2_scale_factor = 0.0;
+
+  // ******************************************************************
+  // Data is read from the histograms contained in the input root file 
+  // and stored in vectors 
+  // ******************************************************************
+  
+  TFile rootfile (SCRootFile, "READ");
+
+  histo1 = (TH1F*) rootfile.Get(ExcessEventsHistoName);
+  histo2 = (TH1F*) rootfile.Get(SignificanceHistoName);
+
+  
+
+  // check that dimension is the same 
+
+  if (histo1 -> GetNbinsX() != histo2 -> GetNbinsX())
+    {
+      cout << "Dimension of histogram " << ExcessEventsHistoName 
+	   << " is not equal to dimension of histogram "<< SignificanceHistoName << endl
+	   << "Aborting ..." << endl;
+      
+      Exit(1);
+    }
+
+  
+  tmp_int = histo1 -> GetNbinsX();
+  
+  const Int_t vectors_dimension = tmp_int;
+
+
+  // Vectors that will be used to plot graphs are defined and filled
+
+  Double_t alpha_cut_vector[vectors_dimension] = {0.0};
+  Double_t excess_events_vector[vectors_dimension] = {0.0};
+  Double_t significance_vector[vectors_dimension] = {0.0};
+
+
+  for (Int_t i = 0 ; i < vectors_dimension; i++)
+    {
+      alpha_cut_vector[i] =  histo1-> GetBinCenter(i+1) + ((histo1->GetBinWidth(i+1))/2);
+      excess_events_vector[i] = histo1-> GetBinContent(i+1);
+      significance_vector[i] = histo2-> GetBinContent(i+1);
+    }
+
+  
+  
+
+   // Dynamic memory from is released and root file closed 
+
+  delete histo1;
+  delete histo2;
+
+  rootfile.Close();
+
+
+    // Information retrieved from histos is displayed in terminal
+  
+  cout << endl
+       << "Cut in alpha, excess events and significance values retrieved from root file: "
+       << endl;
+
+  for (Int_t i = 0 ; i < vectors_dimension; i++)
+    {
+      cout << alpha_cut_vector[i] << "        " 
+	   << excess_events_vector[i] << "        " 
+	   << significance_vector[i] << endl;
+    }
+  
+
+
+
+
+
+  //******************************************************
+  // Graph 2 is scaled so that it can be plotted in the 
+  // same TPad... kind of a trick in root.
+
+  // First, values min and max are needed for the 
+  // graphs to be plotted.
+
+  graph_y_minmax_vector [0][0] = pad_ylow;
+  graph_y_minmax_vector [0][1] = find_max (excess_events_vector, 
+					   vectors_dimension);
+    
+cout << " min set to : " <<  graph_y_minmax_vector [0][0] << endl;
+cout << " max set to : " <<  graph_y_minmax_vector [0][1] << endl;
+
+  graph_y_minmax_vector [1][0] = 0;
+					
+  graph_y_minmax_vector [1][1] = find_max (significance_vector, 
+					   vectors_dimension);
+  //TEST
+  /*
+  cout << graph_y_minmax_vector [0][1] << "  "  
+       << graph_y_minmax_vector [0][0] << endl;
+
+   cout << graph_y_minmax_vector [1][1] << "  "  
+       << graph_y_minmax_vector [1][0] << endl;
+   */
+
+
+   
+  graph_2_scale_factor = 
+    (graph_y_minmax_vector [0][1] - 
+     graph_y_minmax_vector [0][0])/(graph_y_minmax_vector [1][1] 
+				    - graph_y_minmax_vector [1][0]);
+
+  //  cout << "scale factor :  " << graph_2_scale_factor << endl;
+
+  for (Int_t i = 0 ; i < vectors_dimension; i++)
+    { 
+      
+      significance_vector[i] = ((graph_2_scale_factor * significance_vector[i])
+			   + graph_y_minmax_vector [0][0]);
+    }
+  
+  // ***********  END OF SCALING   ********************************
+
+  // Graphs are initialized and filled with vectors
+
+   
+  // Graph i initialized and filled 
+  graph_vector[0] = new TGraph(vectors_dimension,
+			       alpha_cut_vector, 
+			       excess_events_vector);
+      
+
+  graph_vector[1] = new TGraph(vectors_dimension,
+			       alpha_cut_vector, 
+			       significance_vector);
+  
+  // Some properties of graphs are set
+
+  for (Int_t i = 0; i < n_graphs; i++)
+    {
+      graph_vector[i]->SetTitle();
+      graph_vector[i]->SetFillColor(19);
+      graph_vector[i]->SetLineColor(graph_colors_vector[i]);
+      graph_vector[i]->SetLineWidth(1);
+      graph_vector[i]->SetMarkerColor(graph_colors_vector[i]);
+      graph_vector[i]->SetMarkerStyle(polimarker_style_vector[i]);
+      graph_vector[i]->SetMarkerSize(1);
+    }
+
+
+// Graphgrams are plotted
+
+
+ TCanvas *Window = new TCanvas("Plot","Plot",600,600); 
+  
+ gStyle->SetOptStat(0);   
+ // So that statistic information is not printed
+
+  Window -> SetFillColor(10);
+  gStyle -> SetFrameFillColor(10);
+  gStyle -> SetPadLeftMargin (0.15);
+  gStyle -> SetPadRightMargin (0.15);
+  gStyle -> SetPadTopMargin (0.05);
+  gStyle -> SetPadBottomMargin (0.15);
+
+  TPaveText *title = new TPaveText (.05,.95,.95,.99);
+  title -> SetFillColor (38);  
+  title -> AddText (ps_title);
+  title -> Draw();
+
+ 
+  
+  
+  /* TPad(const char *name, const char *title, 
+     Double_t xlow, Double_t ylow, 
+     Double_t xup, Double_t yup, Color_t color, 
+     Short_t bordersize,Short_t bordermode) 
+     : TVirtualPad(name,title,xlow,ylow,xup,yup,color,
+     bordersize,bordermode) 
+  */
+
+  TPad *pad = new TPad ("plot", "plot",0.0, 0.0, 1.0, 0.92, 
+			10, 0, 0); 
+  // I do not want any border effect.
+  pad -> Draw();
+   
+   
+  // Axis and axis labels for pad1 are created and drawn.
+
+  pad -> cd();
+  pad -> SetGrid(1,1); // Grid for x axis and for y axis.
+  pad -> DrawFrame(pad_xlow,pad_ylow,pad_xup,pad_yup); 
+  // dimensions of the pad are set.
+  
+  
+   
+  // Labels of the graph are set
+
+  TText *t = new TText();
+  t->SetTextFont(62);
+  t->SetTextColor(1);
+  t->SetTextSize(0.05);
+  t->SetTextAlign(11);
+
+  // X axis
+  t->SetTextAngle(0);
+  t->DrawText(xaxis_label_xoffset_pad,
+	      xaxis_label_yoffset_pad,
+	      xaxis_title);
+  // Y axis
+  t->SetTextAngle(90); 
+  t->DrawText(yaxis_2_label_xoffset_pad,
+	      yaxis_2_label_yoffset_pad, 
+	      yaxis_2_title);
+
+ 
+  
+
+  // Graphs are plotted in pad
+
+
+  for (Int_t j = 0; j < n_graphs; j++)
+    {  
+      
+      pad -> cd();
+      graph_vector[j]-> Draw("LP");
+      // "A" option is removed in order to 
+      //control de dimensionsn of the pad, 
+      // by means of the " DrawFrame()" function.
+      
+    }
+  
+  // **************************************************
+  // Second Axis is drawn with its label
+  
+  // First of all we must look for units at
+  // bottom and top of axis. This is found 
+
+  
+  y_axis_2_min_value = ((pad_ylow - graph_y_minmax_vector [0][0])/
+			graph_2_scale_factor);
+
+  y_axis_2_max_value = ((pad_yup - graph_y_minmax_vector [0][0])/
+			graph_2_scale_factor);
+
+  
+
+  TGaxis *axis = new TGaxis(gPad->GetUxmax(),gPad->GetUymin(),
+			    gPad->GetUxmax(), gPad->GetUymax(),
+			    y_axis_2_min_value,
+			    y_axis_2_max_value,510,"+L");
+
+   axis->SetLineColor(1);
+   axis->SetTextColor(1);
+   axis->Draw();
+
+    // Y axis 2
+  t->SetTextAngle(90); 
+  t->DrawText(yaxis_label_xoffset_pad,
+	      yaxis_label_yoffset_pad, 
+	      yaxis_title);
+
+  // Graph information is produced and drawn.
+
+  // Spectrum names
+  /*
+  char info_string[150] = 0;
+  char info_string_tmp [20] = 0;
+  Double_t xpos = 0;
+  Double_t ypos = 0;
+  TText *tt = new TText();
+  tt->SetTextFont(62);
+  tt->SetTextSize(0.04);
+  tt->SetTextAlign(12);
+  tt->SetTextAngle(0);
+  
+  for (Int_t i = 0; i < n_graphs; i++)
+    {
+      if (i < 1)
+	{xpos = 0.15; ypos =  0.91;} 
+      else 
+	{xpos = 0.15; ypos = 0.85;}
+      
+      //xpos = 0.02 + i*0.12 + i*(i-1)*0.15; //for three curves
+      //xpos = 0.1 + i*0.4; // for two curves
+      strcpy(info_string, additional_info_vector[i]);
+      tt->SetTextColor(graph_colors_vector[i]);
+      Window -> cd();
+      tt->DrawText(xpos,ypos,info_string);
+    }
+  */
+
+
+  Window -> SaveAs(output_ps_file);
+
+}
+
+
+
+
+// FUNCTION DEFINITIONS
+
+
+
+
+
+Double_t find_value (Double_t vector[], Int_t dimension, Int_t min_max)
+{
+  Double_t value = vector[0];
+  if (min_max < 0.5) // we look for min
+    {
+      for (Int_t i = 1; i < dimension; i++)
+	{
+	  if (value > vector[i])
+	    {
+	      value = vector[i];
+	    }
+	}
+    }
+
+  else // we look for max
+    {
+      for (Int_t i = 1; i < dimension; i++)
+	{
+	  if (value < vector[i])
+	    {
+	      value = vector[i];
+	    }
+	}
+    }
+
+  return value;
+}
+  
+
+
+Double_t find_min (Double_t vector[], Int_t dimension)
+{
+  Double_t min = 0.0;
+  min = find_value (vector, dimension, 0);
+  return min;
+}
+
+
+
+Double_t find_max (Double_t vector[], Int_t dimension)
+{
+  Double_t max = 0.0;
+  max = find_value (vector, dimension, 1);
+  return max;
+}
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mmpi/macros/SuperCutsONOFFMacro.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mmpi/macros/SuperCutsONOFFMacro.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mmpi/macros/SuperCutsONOFFMacro.C	(revision 9661)
@@ -0,0 +1,426 @@
+// Silly macro to run the classes that optimize supercuts 
+// using ON and OFF data.
+
+// The user only needs to fill/change the variables that control 
+// the optimization procedure.
+
+
+gROOT -> Reset();
+
+void SuperCutsONOFFMacro()
+{
+  gLog.SetNoColors();
+
+    // File containing the data (ON/OFF DATA and path for files (root/ps))
+
+    // From magicserv01
+    TString  ONDataFilename("/.magic/data16a/mazin/data/Mrk421/2004_04_22/4slices/Hillas_20040422_4sl_time_clean/Mrk421_*_HillasON.root");
+                                       
+    TString  OFFDataFilename("/.magic/data16a/mazin/data/Mrk421/2004_04_22/4slices/Hillas_20040422_4sl_time_clean/Mrk421_*_HillasOFF.root");
+
+    
+    TString PathForFiles ("/mnt/magicserv01/scratch/David/SillyTestForCommiting_July20_2004/");
+
+    
+    // **********************************************
+    // Boolean variables defining the job of the 
+    // macro
+    // **********************************************
+
+    
+
+    // Boolean variable that decides wether data is read from files specified above
+    // (ON/OFF) or read from already existing Matrices (which are obviously stored
+    // in a root file). The names of the files storing those matrices are produced 
+    // automatically using information provided by some of the next variables whose 
+    // values must be specified by user.
+
+    // kTRUE reads alredy existing matrices, and kFALSE read data and produce matrices.
+
+    Bool_t ReadMatrixFromRootFiles = kTRUE; 
+  
+
+    // Boolean variable that controls wether to use the 
+    // TRAIN sample or not.
+    
+
+    Bool_t TrainParams   = kTRUE;  
+
+
+
+    // Variable that allows the user to skip the optimization on the 
+    // train sample. If optimization is skipped (value kTRUE), the
+    // previously optimized supercuts (stored in root file
+    // which is called OptSCParametersONOFFThetaRangeXXXXXmRad.root, and located 
+    // in the directory specified by variable PathForFiles) are used 
+    // on the train and/or the test sample.
+
+    // If value kFALSE, the cuts are optimized.
+    // The optimized cuts will be  written in root file
+    // located in directory specified before. Name of 
+    // the root files is created automatically.
+    
+    Bool_t SkipOptimization = kTRUE;
+  
+
+
+
+
+    // Boolean variable that allows the user to write the initial parameters 
+    // into the root file that will be used to store the optimum cuts.
+    // If ApplyInitialParams = kTRUE , the initial 
+    // parameters are written into this root file, and they 
+    // will be applied to the data (TRAIN/TEST ) 
+    // IF NO OPTIMIZATION PROCEDURE IS PERFORMED.
+    
+    // If cuts are optimized (ie, variable SkipOptimization = kFALSE), 
+    // the cuts applied to the data are the optimized cuts.
+  
+    // NOTE: be aware that, if ApplyInitialSCParams = kTRUE and 
+    // there was a root file with the optimized cuts 
+    // (previously computed), it will be overwritten with the initial 
+    // SC parameters. 
+
+    Bool_t ApplyInitialSCParams = kTRUE;
+    
+
+
+    // Boolean variable that controls wether to use the 
+    // TEST sample or not.
+    
+
+    Bool_t TestParams = kFALSE;  
+
+
+    // Boolean variable that controls wether to combine, OR not, the 
+    // alpha distributions computed (after cuts) for the several theta bins
+    // in which the TRAIN sample was divided.
+
+    Bool_t CombineCosThetaBinsForTrainSample = kFALSE; 
+    
+    // Boolean variable that controls wether to combine, OR not, the 
+    // alpha distribution computed (after cuts) for the several theta bins
+    // in which the TEST sample was divided.
+
+    Bool_t CombineCosThetaBinsForTestSample = kFALSE; 
+    
+
+    // Fraction of ON events used for the training/testing
+    Double_t whichfractiontrain = 0.999;
+    Double_t whichfractiontest = 0.001;
+
+    // Fraction of OFF events used for the training/testing 
+    Double_t whichfractiontrainOFF = 0.999;
+    Double_t whichfractiontestOFF = 0.001;
+
+
+    // Efficiency for gammas when using this set of dynamical cuts
+    // (i.e., fraction of initial gammas that remain after cuts)
+
+    // Current value is the first estimation of the efficiency of cuts
+    // on Mkn421 at a SIZE > 2000 photons
+
+    Double_t gammaeff = 0.6;  
+                         
+
+    // Alpha value (degrees) below which signal is expected
+    
+    Double_t alphasig = 12; 
+
+    // Definition of alpha bkg region (where no signal is expected)
+
+    Double_t alphabkgmin = 30;
+    Double_t alphabkgmax = 90;
+    
+    // Definition of the Size range
+
+    Double_t SizeLow = 800;
+    Double_t SizeUp = 1200;
+//    Double_t SizeUp = 1000000;
+    
+
+     // Definition of binning of alpha plots
+    Int_t NAlphaBins = 35;
+    Double_t AlphaBinLow = -9;
+    Double_t AlphaBinUp = 96;
+
+ 
+    // Boolean variable used to determine wether the normalization factor is 
+    // computed from method 1) or 2)
+    // 1) Using total number of ON and OFF events before cuts, and tuning the factor 
+    //    correcting for "contamination" of gamma events in ON sample 
+    // 2) Using number of ON and OFF events after cuts in the background 
+    //    region determined by variables fAlphaBkgMin-fAlphaBkgMax
+    
+    Bool_t NormFactorFromAlphaBkg = kTRUE; // if kTRUE, method 2) is used
+
+
+    // Boolean variable used to disable the usage ("serious" usage) of the 
+    // quantities computed from fits. This will be useful in those cases 
+    // where there is too few events to perform a decent fit to the 
+    // alpha histograms.
+    
+    Bool_t UseFittedQuantities = kTRUE;
+
+
+    // Boolean variable used to control wether to use theta information 
+    // in the computation of teh dynamical cuts that take place within
+    // class MCT1SupercutsCalc
+    Bool_t NotUseTheta = kTRUE; // kTRUE renoves theta from the parameterization of cuts
+
+    // Boolean variable used to decide wether to use dynamical cuts or static cuts
+    // kTRUE means that static cuts are used.
+    Bool_t UseStaticCuts = kFALSE;
+
+
+
+
+
+    // Name of the Postscript document where all plots
+    // will be saved.
+    // STORAGE OF PSFILE IS NOT WORKING PROPERLY
+    // For the time being, several ps files are produced 
+    // and saved in the directory specified by PathForFiles
+
+    /*
+    TString PsFileName = ("PsTest23.ps");
+    TString CompletePsFileName = (PathForFiles);
+    CompletePsFileName += PsFileName;
+    TPostScript* PsFile = new TPostScript(CompletePsFileName, 111);
+    */
+
+    // Boolean variable used to decide wether initial parameters are 
+    // read from ascii file or not. If kTRUE, parameters are retrieved 
+    // from ascii file. Otherwise, default parameters from MSupercuts 
+    // class are used.
+
+    Bool_t ReadInitParamsFromAsciiFile = kTRUE;
+
+    // Number of SC parameters. The aim of this variable is to cross check 
+    // that the number of parameters read from an ascii file 
+    // is teh one the user wants. 
+
+    Int_t NInitSCPar = 104;
+
+    // Name of  the ascii file containing the 2 columns, the first one 
+    // for initial parameters and the second one for the steps
+    // Name must contain also the path.
+ 
+    const char* InitSCParamAsciiFile = 
+      // {"../InitialSCParametersSteps/InitSCParamsAndStepsDanielModified1.txt"};
+      // {"../InitialSCParametersSteps/FixedStaticCutsInLengthWidthDist.txt"};
+      // {"../InitialSCParametersSteps/FixedStaticCutsInLengthWidthDist11.txt"};
+      // {"../InitialSCParametersSteps/InitSCParamsAndStepsDanielModified1.txt"};
+      // {"../InitialSCParametersSteps/StartingValuesForOptimizationMkn421.txt"};
+      // {"../InitialSCParametersSteps/StartingValuesForOptimizationMkn421DynStaticCutsFixedPol2SizeCut3000.txt"};
+      // {"../InitialSCParametersSteps/StartingValuesForOptimizationMkn421DynWithDistParametersFixed.txt"};
+      // {"../InitialSCParametersSteps/StartingValuesForOptimizationMkn421DynStaticCutsVariablePol2.txt"};
+      // {"../InitialSCParametersSteps/StartingValuesForOptimizationMkn421DynStaticCutsVariablePol2WidthCutLowFixed.txt"};
+      // {"../InitialSCParametersSteps/StartingValuesForOptimizationMkn421DynCutsOnSize.txt"};
+      // {"../InitialSCParametersSteps/StartingValuesForOptimizationMkn421DynCutsOnSizeAndDist.txt"};
+      {"mtemp/mmpi/asciifiles/OptimizedMkn421DynCutsGridWithSelected22pointsMay19.txt"};
+
+
+    // Name of the root file where alpha distributions, TTree objects
+    // with info about the events and cuts applied and  info support histograms 
+    // will be stored. 
+    // Write only the name of the file. The Path 
+    // is the one defined previously
+
+    TString RootFilename = ("RootFileDynCuts.root");
+
+    
+
+    
+    
+
+    // Vector containing the theta bins in which data (ON/OFF train/test)
+    // will be divided. Actually this vector contains the cosinus of 
+    // these theta bins. The dimension of the vector is N+1, where 
+    // N is the number of theta bins intended. The first component of the 
+    // vector is the low bin edge of the first bin, and the last 
+    // vector component the upper bin edge of the last bin.
+
+
+    TArrayD CosThetaRangeVector(2);
+    CosThetaRangeVector[0] = 0.0;
+    //CosThetaRangeVector[1] = 0.825;
+    //CosThetaRangeVector[2] = 0.921; 
+    //CosThetaRangeVector[3] = 0.961; 
+    CosThetaRangeVector[1] = 1.0;
+
+
+    /*
+    TArrayD CosThetaRangeVector(2);
+    CosThetaRangeVector[0] = 0.622;
+    // CosThetaRangeVector[1] = 0.825;
+    //CosThetaRangeVector[2] = 0.921; 
+    //CosThetaRangeVector[0] = 0.961; 
+    CosThetaRangeVector[1] = 0.984;
+    
+    */
+    // Object of MCT1FindSupercutsONOFFThetaLoop created, data that was specified 
+    // above is introduced and ... and the party starts.
+     
+    MFindSupercutsONOFFThetaLoop FindSupercuts("MFindSupercutsONOFFThetaLoop", 
+					       "Optimizer for the supercuts");
+
+    
+    FindSupercuts.SetPathForFiles(PathForFiles);
+
+    FindSupercuts.SetDataONOFFRootFilenames(ONDataFilename, OFFDataFilename);
+
+    FindSupercuts.SetFractionTrainTestOnOffEvents(whichfractiontrain, 
+						  whichfractiontest, 
+						  whichfractiontrainOFF, 
+						  whichfractiontestOFF);
+
+
+    FindSupercuts.SetGammaEfficiency(gammaeff);
+
+
+    FindSupercuts.SetAlphaSig(alphasig);
+
+    // Bkg alpha region is set 
+    FindSupercuts.SetAlphaBkgMin(alphabkgmin);
+    FindSupercuts.SetAlphaBkgMax(alphabkgmax);
+
+    // alpha bkg and signal region set in object FindSupercuts
+    // are re-checked in order to be sure that make sense
+	
+    FindSupercuts.CheckAlphaSigBkg();
+
+
+    // binning for alpha plots is defined
+
+    FindSupercuts.SetAlphaPlotBinining(NAlphaBins, AlphaBinLow, 
+				       AlphaBinUp);
+
+
+
+
+    // Size range is defined
+
+    FindSupercuts.SetSizeRange(SizeLow, SizeUp);
+
+
+
+    FindSupercuts.SetNormFactorFromAlphaBkg(NormFactorFromAlphaBkg);
+
+    FindSupercuts.SetUseFittedQuantities(UseFittedQuantities);
+
+    FindSupercuts.SetVariableUseStaticCuts(UseStaticCuts);
+
+    FindSupercuts.SetVariableNotUseTheta(NotUseTheta);
+
+    FindSupercuts.SetReadMatricesFromFile(ReadMatrixFromRootFiles);
+
+    FindSupercuts.SetTrainParameters(TrainParams);
+    FindSupercuts.SetSkipOptimization(SkipOptimization);
+    FindSupercuts.SetUseInitialSCParams(ApplyInitialSCParams);
+
+    FindSupercuts.SetTestParameters(TestParams);
+
+   
+    
+    FindSupercuts.SetHadronnessName("MHadSC");
+    FindSupercuts.SetHadronnessNameOFF("MHadOFFSC");
+    
+    FindSupercuts.SetAlphaDistributionsRootFilename (RootFilename);
+    
+    // FindSupercuts.SetPostScriptFile (PsFile);
+
+    FindSupercuts.SetCosThetaRangeVector (CosThetaRangeVector);
+    
+
+    // Names for all root files (matrices, alpha distributions...)
+    // are created 
+    FindSupercuts.SetALLNames();
+
+    if(ReadInitParamsFromAsciiFile)
+    {
+	// Initial SC Parameters and steps are retrieved from 
+	// Ascii file
+	if(!FindSupercuts.ReadSCParamsFromAsciiFile(InitSCParamAsciiFile,
+						    NInitSCPar))
+	{
+	    cout << "Initial SC Parameters could not be read from Ascii file "
+		 << InitSCParamAsciiFile << endl
+		 << "Aborting execution of macro... " << endl;
+	    return;
+
+	}
+    }
+ 
+   
+
+
+    // Finally loop over all theta bins defined is executed
+    
+    if (!FindSupercuts.LoopOverThetaRanges())
+      {
+	cout << "Function MFindSupercutsONOFFThetaLoop::LoopOverThetaRanges()" << endl
+	     << "could not be performed" << endl;
+
+      }
+
+    
+
+    // Nex and Significance are computed vs alphasig
+    
+    if (!FindSupercuts.ComputeNexSignificanceVSAlphaSig())
+      {
+	cout << "Function MFindSupercutsONOFFThetaLoop::ComputeNexSignificanceVSAlphaSig()" << endl
+	     << "could not be performed" << endl;
+	
+
+      }
+    
+
+
+
+    // Option to store ps files in a single ps document is still not working
+    /*
+    PsFile -> Close();
+    PsFile = NULL;
+    */
+
+    // Several theta bins are combined to produced a single alpha plot (for train and test)
+    // with single Nex and significances
+
+    if (CombineCosThetaBinsForTrainSample || CombineCosThetaBinsForTestSample)
+    {
+	if(!FindSupercuts.ComputeOverallSignificance(CombineCosThetaBinsForTrainSample, 
+						     CombineCosThetaBinsForTestSample))
+	  {
+	    cout << "Function MFindSupercutsONOFFThetaLoop::ComputeOverallSignificance" << endl
+		 << "could not be performed" << endl;
+	  }
+       
+
+    }
+
+
+   
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mmpi/macros/bsc5.dat
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mmpi/macros/bsc5.dat	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mmpi/macros/bsc5.dat	(revision 9661)
@@ -0,0 +1,9110 @@
+   1          BD+44 4550      3 36042          46           000001.1+444022000509.9+451345114.44-16.88 6.70  +0.07 +0.08         A1Vn               -0.012-0.018      -018      195  4.2  21.6AC   3 
+   2          BD-01 4525      6128569                       235956.2-010330000503.8-003011 98.33-61.14 6.29  +1.10 +1.02        gG9                 +0.045-0.060      +014V                          
+   3 33    PscBD-06 6357     281285721002I         Var?     000013.0-061601000520.1-054227 93.75-65.93 4.61  +1.04 +0.89 +0.54   K0IIIbCN-0.5       -0.009+0.089 +.014-006SB1O < 17  2.5   0.0     3*
+   4 86    PegBD+12 5063     87 917012004                   000033.8+125023000542.0+132346106.19-47.98 5.51  +0.90               G5III              +0.045-0.012      -002V?                         
+   5          BD+57 2865    123 21085          61  V640 Cas 000101.8+575245000616.0+582612117.03-03.92 5.96  +0.67 +0.20         G5V                +0.263+0.030 +.047-012V          0.8   1.4      *
+   6          CD-4914337    142214963      W                000108.4-493751000619.0-490430321.61-66.38 5.70  +0.52 +0.05         G1IV               +0.565-0.038 +.050+003SB         5.7   5.4      *
+   7 10    CasBD+63 2107    144 109782005                   000114.4+633822000626.5+641146118.06  1.75 5.59  -0.03 -0.19         B9III             e+0.008 0.000      -000V     153                 *
+   8          BD+28 4704    166 73743          69     33    000125.2+282811000636.8+290117111.26-32.83 6.13  +0.75 +0.33         K0V                +0.380-0.182 +.067-008V          2.6 158.6AB   4*
+   9          CD-23    4    2031660531003                   000143.0-233947000650.1-230627 52.21-79.14 6.18  +0.38 +0.05         A7V                +0.100-0.045      +003V                          
+  10          BD-18 6428    256147090                       000211.8-175639000718.2-172311 74.36-75.90 6.19  +0.14 +0.10         A6Vn               -0.018+0.036      -009V?    195                 *
+  11          BD-03    2    315128595              Var?     000236.7-030620000744.1-023256 98.02-63.29 6.43  -0.14 -0.47         B8IIIpSi           +0.027-0.002      +013                          *
+  12          CD-23   13    319166066          89     46    000240.3-230352000746.8-223032 55.56-79.07 5.94  +0.14 +0.06         A2Vp:              +0.052-0.044      -013V          5.1   1.9      *
+  13          CD-34   17    344192367                       000258.6-340510000803.5-333146355.91-78.67 5.68  +1.12               K1III              -0.037 0.000      +007                           
+  14          BD-03    3    3521286022006I         AP Psc   000304.8-030015000812.1-022652 98.34-63.24 6.07  +1.38 +1.14         K2III+F            +0.009-0.003      +001SB1O   22  2.0   0.0      *
+  15 21Alp AndBD+28    4    358 73765   1I     94  Alp And  000313.0+283218000823.3+290526111.73-32.84 2.06  -0.11 -0.46 -0.10   B8IVpMnHg         v+0.136-0.163 +.032-012SBO    56  8.5  81.5      *
+  16          BD-09    5    360128604                       000310.9-092247000817.4-084926 91.79-69.04 5.99  +1.04 +0.83        gG8                 -0.052-0.033      +020                           
+  17          BD+35    8    400 53677                       000331.9+360426000841.0+363736113.45-25.45 6.19  +0.48 -0.09         F8IV               -0.100-0.145 +.044-014    =<  6                  
+  18          BD-18    3    402147103    I            51    000327.1-180801000833.4-173439 74.69-76.25 6.06  +1.67 +1.97         M0III               0.000-0.025      -017V?                        *
+  19          BD+24    3    417 73769                       000342.2+245419000852.2+252746110.97-36.42 6.23  +0.97 +0.73         K0III              +0.114+0.031      +015                           
+  20          BD+78    1    431  4048         102           000348.5+790933000920.2+794253120.98 17.00 6.01  +0.19 +0.10         A7IV               +0.102-0.027 +.002+001       90  0.2   0.6      *
+  21 11Bet CasBD+58    3    432 21133   2I    107  Bet Cas  000350.2+583554000910.7+590859117.52-03.27 2.27  +0.34 +0.11 +0.20   F2III-IV           +0.525-0.181 +.072+012SB     70 11.3  31.3      *
+  22 87    PegBD+17    7    448 91734                       000352.8+173922000902.4+181243108.99-43.51 5.53  +1.04               G9III              +0.137-0.024      -023V?                         
+  23          CP-54   19    469231943      W                000359.7-543333000902.4-540007316.25-62.02 6.33  +0.74 +0.39         G4IV               +0.051+0.016D+.009+001SB         1.3   0.2      *
+  24   Kap1SclCD-28   16    493166083         111           000415.2-283240000921.0-275916 25.24-80.63 5.42  +0.42 +0.08         F2V                +0.072-0.004 +.023+009      131  0.2   1.4AB   3*
+  25   Eps PheCD-46   18    496214983   3                   000420.2-461757000924.7-454451324.34-69.60 3.88  +1.03 +0.84 +0.52   K0III              +0.124-0.181 +.066-009                           
+  26 34    PscBD+10    8    560 91750         122           000453.8+103521001002.3+110844106.87-50.43 5.51  -0.07 -0.24         B9Vn              e+0.041-0.003D+.017+014V     275  4.4   7.7      *
+  27 22    AndBD+45   17    571 36123   4                   000507.2+453057001019.3+460420115.52-16.21 5.03  +0.40 +0.25 +0.29   F2II               +0.008 0.000 -.002-005       47                 *
+  28          BD+56   11    584 21162                       000515.0+563632001029.7+570956117.38-05.26 6.74  -0.08 -0.41         B7IV               +0.023+0.006      +002                           
+  29          BD-06   11    587128621      D                000511.6-054815001018.8-051455 96.99-66.03 5.84  +0.98 +0.74         K1III              +0.036-0.033      +024                          *
+  30   Gam3OctCP-82    4    6362582153971                   000530.4-824648001002.1-821326304.63-34.77 5.28  +1.05 +0.92         G8III              -0.029-0.020      +015                           
+  31          BD-13   13    6451471272008                   000535.5-130807001042.8-123448 87.69-72.60 5.85  +1.01 +0.80         K0IV               +0.150-0.038      +006V?                         
+  32          CP-73    4    661255642      W                000544.4-734653001038.6-731328306.98-43.58 6.64  +0.37 +0.06         F2V+F6V            +0.123+0.016      -014           1.1   0.5AB   3*
+  33  6    CetBD-16   17    693147133                       000610.5-160101001115.9-152805 82.24-75.06 4.89  +0.49 -0.03         F7V                -0.077-0.268 +.067+014V?      0                  
+  34   Kap2SclCD-28   26    720166103   5I W                000629.8-282124001134.4-274759 26.30-81.13 5.41  +1.34 +1.46         K5III              +0.010+0.016      -006          13.8  46.0       
+  35   The SclCD-35   42    739192388   6                   000639.0-354134001144.0-350759347.16-78.34 5.25  +0.44               F4V                +0.173+0.119 +.034-002        0                  
+  36          BD+47   21    743 36148    I                  000645.1+473545001159.1+480909116.16-14.20 6.16  +1.45              gK4                 +0.058+0.017      +016                           
+  37          BD-18   14    787147144    I                  000704.0-182938001210.0-175618 76.32-77.10 5.25  +1.48 +1.63         K5III              +0.056-0.031 -.015-008V    < 19:                 
+  38          BD+36   12    829 53725                       000738.2+370815001250.4+374136114.55-24.55 6.73  -0.13 -0.70         B2V                +0.028-0.012      -010                          *
+  39 88Gam PegBD+14   14    886 91781   7I'W       Gam Peg  000805.1+143740001314.2+151101109.43-46.68 2.83  -0.23 -0.87 -0.19   B2IV               +0.003-0.012 -.002+004SBO     3  8.9 163.4AB   3*
+  40          BD+26   13    895 73823         161           000813.4+262556001324.0+265914112.56-35.12 6.30  +0.65 +0.33         G0III              -0.008-0.047D+.006-013           1.1   0.1AB   3*
+  41 23    AndBD+40   29    905 361732010                   000819.0+402900001330.8+410207115.27-21.27 5.72  +0.31 -0.02         F0IV               -0.123-0.148 +.024-029       25                  
+  42          CD-26   56    942166130    I            96    000837.8-263435001342.1-260119 38.28-81.49 5.94  +1.55               K5III              +0.026-0.069      -030V                          
+  43          CD-26   57    943166131    I                  000840.2-265029001344.2-261705 36.52-81.54 6.31  +1.48 +1.65         K5III              -0.020+0.012      +018V                          
+  44          BD+32   21    952 537442012                   000850.6+323901001402.3+331222113.99-29.02 6.25  -0.01 -0.05         A1V                -0.006-0.018      +001       56                  
+  45 89Chi PegBD+19   27   1013 917921004I            99    000925.6+193902001436.2+201224111.30-41.83 4.80  +1.57 +1.93 +1.13   M2+III            e+0.093 0.000 +.015-046V                         *
+  46          BD-08   26   1014128655    I    180  AD Cet   000920.8-082013001427.6-074650 96.87-68.76 5.12  +1.62 +1.81 +1.03E  M3+III             +0.059+0.004 +.003-002V?         6.0   3.0      *
+  47          CP-85    2   10322582173972                   000932.1-853302001319.4-845939303.91-32.06 5.77  +1.72 +2.10         M0-1III            +0.004+0.008      +004                           
+  48  7    CetBD-19   21   1038147169    I         AE Cet   000933.7-192913001438.4-185558 75.11-78.23 4.44  +1.66 +1.99 +1.14   M3III             e-0.024-0.067 +.029-023                          *
+  49          BD+21   13   1048 73838                       000945.3+214343001456.1+221703111.92-39.81 6.24  -0.01 +0.12         A1pSi              +0.065-0.011      -015                          *
+  50 35    PscBD+08   19   1061109087         191  UU Psc   000949.7+081556001458.8+084915107.86-52.98 5.79  +0.31 +0.04         F0IV               +0.097-0.028D+.017+001SB2O   86  0.0   0.0 A   3*
+  51          BD-10   30   1064128660                       000948.2-100731001454.5-093411 95.06-70.44 5.75  -0.08               B9V                +0.028-0.011      +017V?                         
+  52          BD+30   26   1075 53755    I                  000954.9+305848001507.0+313209113.93-30.70 6.45R                     K5                 +0.035-0.005      +002                           
+  53          BD+26   23   1083 73842      W                000959.3+264340001510.6+271659113.10-34.90 6.35  -0.02 +0.02         A1Vn               +0.021-0.031      -004SB    230  6.8  29.2      *
+  54          CD-35   65   1089192418                       000955.3-352736001458.2-345416345.80-78.99 6.17  +1.34               K3III              +0.073-0.023      -052                           
+  55          BD+76    5   1141  4071         207           001033.1+762342001614.0+765703120.89 14.22 6.35  -0.07 -0.26         B8Vnn              +0.018-0.002D+.013-007V          0.3   0.8      *
+  56          BD+42   41   1185 36221         215           001106.2+430224001621.6+433541116.23-18.82 6.15  +0.05 +0.03         A2VpSi             +0.043-0.030      +002      100  3.9   9.2      *
+  57          CD-32   72   11871924302014I W                001105.4-320006001608.9-312647  1.53-81.18 5.67  +1.35 +1.50         K5III              +0.122-0.030      +026           9.9  64.0      *
+  58          CP-76   19   1221255650                       001120.4-762803001555.2-755441305.79-41.02 6.49  +1.00 +0.72         G8-K0III           -0.013+0.006      +016                           
+  59 36    PscBD+07   27   12271091002015                   001125.7+074105001634.1+081424108.28-53.64 6.11  +0.92 +0.66         G8II-III           -0.020-0.019      +001                           
+  60          BD+60   21   1239 11084         222           001134.6+605839001657.1+613200118.83-01.06 5.74  +0.88 +0.59         G8III              -0.001-0.001      -004           6.4  19.4      *
+  61          BD-21   24   1256166167                113    001138.1-204557001642.5-201238 72.13-79.47 6.47  -0.09 -0.48         B8III              +0.012-0.014      +019V                         *
+  62          BD+47   50   1279 362362016                   001152.3+472331001709.1+475651117.01-14.53 5.89  -0.09 -0.44         B7III              +0.008 0.000      -009V?      0                  
+  63 24The AndBD+37   34   1280 53777                116    001151.9+380735001705.5+384054115.62-23.70 4.61  +0.06 +0.04 +0.01   A2V                -0.050-0.019 +.022+001V     107                 *
+  64          CP-79    7   1324255652                       001222.8-792007001649.0-784650305.07-38.20 6.77  +0.46 +0.08         F3III              +0.077-0.043      -013                           
+  65          BD+50   46   1337 21273    I         AO Cas   001224.8+505239001743.0+512559117.59-11.09 6.14  -0.13 -0.97         O9IIInn            -0.005-0.004      -035SB2O  135                 *
+  66          BD-19   30   1343147205                       001228.2-193624001732.6-190304 77.21-78.78 6.45  +0.37               F4IV-V             +0.015+0.003      -005                           
+  67          BD+00   28   13671091192017                   001239.5+010758001747.7+014120105.89-60.07 6.17  +0.94 +0.73         K0II               +0.095+0.012      -009                           
+  68 25Sig AndBD+35   44   1404 537981005            118    001306.0+361351001819.7+364707115.59-25.61 4.52  +0.05 +0.07  0.00   A2V                -0.063-0.041 +.023-008SB    103                 *
+  69          BD+10   25   1419 91832                       001308.3+103905001817.2+111221110.00-50.83 6.05  +1.03               K0III              -0.036-0.038      +009                           
+  70 26    AndBD+42   48   1438 36256         254    119    001325.7+431409001842.1+434728116.70-18.68 6.11  -0.08 -0.35         B8V                +0.020-0.003      +007           4.1   6.2      *
+  71          BD+30   35   1439 538031006                   001324.7+305743001838.3+313102114.79-30.84 5.87  -0.01  0.00         A0IV               +0.058-0.006      -005       53                  
+  72          BD-08   38   1461128690                       001333.0-083616001841.8-080310 99.29-69.40 6.46  +0.68 +0.29         G0V                +0.413-0.139 +.053-010V?                        *
+  73          CD-43   64   1483215047                       001343.7-434728001842.6-431407323.20-72.58 6.33  +1.21               K2III              +0.056+0.012      +012                           
+  74  8Iot CetBD-09   48   1522128694   9I W         123    001419.9-092242001925.7-084926 98.98-70.19 3.56  +1.22 +1.25 +0.59   K1.5III            -0.014-0.036 +.013+019     < 17  4.8 108.8AC   3*
+  75          BD+39   56   1527 36269                       001425.9+401029001941.6+404347116.46-21.74 6.33  +1.18               K1III              -0.026-0.010      -038                           
+  76          BD+48   79   1561 36272                       001446.3+481838002005.2+485155117.63-13.68 6.52                      A0V s              +0.005-0.017      -003V      57                  
+  77   Zet TucCP-65   13   1581248163  10I'                 001451.7-652745002004.3-645229308.35-51.90 4.23  +0.58 +0.02 +0.33   F9V                +1.705+1.164 +.134+009        0                  
+  78          BD+30   42   1606 53820                128    001510.7+302250002024.4+305609115.13-31.47 5.90  -0.10 -0.46         B7V                +0.021+0.004      +004      125                  
+  79          BD+32   45   1632 53825    I                  001531.6+322124002045.5+325441115.53-29.52 5.79  +1.59       +1.00   K5III              -0.026-0.014      -036                           
+  80 41    PscBD+07   36   16351091521008I           132    001527.0+073806002035.9+081125109.91-53.90 5.37  +1.34 +1.55        gK3                 -0.002+0.008      +016                           
+  81          BD+10   32   1663 91858         287           001545.4+102522002054.5+105837110.93-51.18 6.56                      A0V                -0.046-0.028D+.005-018V      56  0.2   0.6      *
+  82 27Rho AndBD+37   45   1671 538281009                   001551.1+372453002107.3+375807116.37-24.52 5.18  +0.42 +0.05         F5III              +0.060-0.040 +.017+009       41                  
+  83   Pi  TucCP-70   12   16852481672018                   001600.9-701048002039.0-693730306.87-47.27 5.51  -0.05 -0.14         B9V                -0.007 0.000 +.011+012                           
+  84   Iot SclCD-29   86   1737166207                       001629.7-293204002131.2-285854 15.52-83.15 5.18  +1.00 +0.82         G5III              +0.040-0.074 +.027+021                           
+  85          BD-20   50   1760166210    I         T Cet    001642.6-203645002146.3-200328 77.51-80.20 5.12  +1.82 +1.78         M5IIe              +0.071-0.005      +029V                         *
+  86 42    PscBD+12   25   1796 918662020     303           001714.9+125538002225.5+132857112.19-48.78 6.23  +1.22               K3III              +0.062+0.021      +003V          4.6  28.9      *
+  87          CP-78    9   1801255663                       001712.7-775854002128.6-772537305.04-39.58 5.97  +1.40 +1.40         K3III              +0.002-0.010      +021V                          
+  88  9    CetBD-13   60   1835147237    I'W       BE Cet   001744.3-124557002251.8-121234 97.34-73.64 6.39  +0.66 +0.24         G2V                +0.394+0.061 +.049-007V       6  5.4 202.1      *
+  89          CD-31  138   1909192495                       001812.3-313526002312.6-310210358.89-82.70 6.55   0.00 -0.31         B9IVMn             +0.029-0.003      +001SB1    25                 *
+  90          BD+37   58   1967 53860    I:W       R And    001844.8+380125002402.0+383438117.07-23.98 7.39  +1.97 +1.25 +2.21   S6.5IIIeZr6Ti2     -0.007-0.023      -011V          4.9  84.6      *
+  91          BD+51   62   1976 21366         328    155    001852.2+512757002415.6+520112118.68-10.63 5.57  -0.12 -0.60         B5IV               +0.013-0.004D+.004-007SBO   230  2.5   0.2      *
+  92 NOVA 1572                                     B Cas    0 0 0      0 0 0 0 0      0 0                                                                                                           *
+  93 12    CasBD+61   69   2011 11172                       001916.2+611637002447.5+614952119.79-00.88 5.40   0.00 -0.16         B9III              +0.012-0.001 +.015-004V     154                  
+  94          BD-03   49   20231287432021                   001923.0-024620002429.7-021309107.27-64.27 6.07  +1.22 +1.23         K1III              -0.033-0.044      +015                           
+  95 47    Tuc                                              0 0 0      0 0 0 0 0      0 0                                                                                                           *
+  96          BD+52   61   2054 213812022            159    001941.6+522934002506.4+530249118.92-09.62 5.74  -0.06 -0.31         B9IV               +0.023-0.002      +010V     210                 *
+  97 44    PscBD+01   57   21141091921010  W                002016.5+012310002524.2+015623109.73-60.26 5.77  +0.86 +0.57         G5III              -0.013-0.015      -004     < 20                 *
+  98   Bet HyiCP-77   16   2151255670  11I'          161    002030.0-774903002545.1-771515304.81-39.77 2.80  +0.62 +0.11 +0.34   G2IV               +2.215+0.324 +.153+023                          *
+  99   Alp PheCD-42  116   2261215093  12I A                002120.5-425056002617.0-421822320.02-73.98 2.39  +1.09 +0.88 +0.60   K0III              +0.203-0.396 +.035+075SB1O             0.1      *
+ 100   Kap PheCD-44  101   2262215092                       002117.1-441405002612.2-434048318.42-72.68 3.94  +0.17 +0.11 +0.08   A7V                +0.109+0.029 +.072+011      219                  
+ 101 10    CetBD-00   63   2273128760              Var?     002129.6-003612002637.4-000259109.50-62.27 6.19  +0.90 +0.55         G8III              +0.073-0.001      -023V                         *
+ 102          CD-26  138   23631662822025                   002214.0-260601002714.7-253250 47.84-84.35 5.98  +1.03 +0.88         G8III              +0.036-0.019      -003                           
+ 103 47    PscBD+17   55   2411 91910    I         TV Psc   002250.0+172021002802.9+175335115.10-44.62 5.06  +1.65 +1.82 +1.54   M3III             v+0.117+0.021 +.016+006V                         *
+ 104          BD+43   92   2421 363902027                   002251.1+435029002813.7+442340118.57-18.28 5.17  +0.03 -0.01         A2V s              +0.089-0.016 +.013+002SB1O   36                 *
+ 105   Eta SclCD-33  152   24291925452026          Eta Scl  002258.2-333333002755.7-330026342.36-82.23 4.81  +1.64 +1.81 +1.38   M4III              -0.019-0.052 -.014+011                          *
+ 106 48    PscBD+15   63   2436 919121012I                  002300.9+155332002812.7+162642114.89-46.06 6.06  +1.58 +2.00         K5III              +0.019-0.015      -007SB                         
+ 107          BD+09   47   24541092242028                   002309.8+093832002820.1+101123113.62-52.26 6.04  +0.43 -0.06         F6Va vw            +0.046-0.207 +.033-010V       8                 *
+ 108          BD-21   57   24751662962029  W                002320.2-205307002821.1-202006 83.87-81.40 6.43  +0.59 -0.03         G0V                -0.116-0.114D+.034+006V          0.1   0.2      *
+ 109          CD-40   93   2490215103    I                  002330.7-402802002826.4-395454321.94-76.35 5.43  +1.56 +1.90         M0III              +0.130-0.036 +.015+032                          *
+ 110          BD+36   66   2507 53928                       002337.9+362048002856.6+365400117.94-25.75 6.26  +0.92               G5III              -0.011+0.003      +010                           
+ 111          CD-51  113   2529232055                       002352.8-510509002843.1-503158311.91-66.20 6.26  +1.09               K0III              +0.150-0.002      +006                           
+ 112          BD+76   10   2589  41302031                   002429.4+762804003055.0+770110121.74 14.20 6.21  +0.84 +0.54         K0IV               +0.337-0.038 +.023+019                          *
+ 113          BD+59   68   2626 21457         412           002444.9+592530003019.9+595838120.29-02.79 5.94  +0.01 -0.36         B9IIIn             +0.017-0.012D+.002-017V     225: 2.2   0.5AB   3*
+ 114 28    AndBD+28   75   2628 74041         409  GN And   002450.6+291201003007.3+294506117.42-32.89 5.23  +0.24 +0.09         A7III              +0.041-0.054 +.001-010       21  7.1 139.3AC   3*
+ 115          BD-15   84   26301473072030                   002447.8-152458002951.9-145151 99.58-76.75 6.14  +0.37               F2III              +0.144-0.032      +003       42                 *
+ 116          CD-32  154   2632192567                       002451.6-324005002948.9-320700344.92-83.15 6.57  +1.34               K4III              -0.004-0.054      +001                           
+ 117 12    CetBD-04   54   2637128791  13I    410           002456.1-043035003002.4-035726109.57-66.27 5.72  +1.56 +1.91         M0III              +0.011-0.012      +005V?         5.6  10.6      *
+ 118          CD-24  179   2696166318  14                   002522.7-242027003022.7-234716 66.87-84.19 5.19  +0.12               A5Vn               -0.024+0.013 +.018-000SB                        *
+ 119          CD-41  116   2724215120              BB Phe   002534.7-412934003027.8-405622318.97-75.53 6.19  +0.33 +0.14         F2III              -0.001+0.021      -005                          *
+ 120          CD-48  102   2726215119                       002535.8-484555003026.1-481254312.52-68.52 5.69  +0.35 +0.05         F2V                +0.129-0.088      +002                           
+ 121 13    CasBD+65   67   2729 11243                       002539.8+655802003125.3+663110120.94  3.73 6.18  -0.10 -0.47         B6V                +0.023-0.006      -010                          *
+ 122          BD+32   80   2767 53956      W                002606.8+330147003125.6+333454118.16-29.10 5.87  +1.14               K1III              +0.047-0.019      +009SB         2.4  56.4       
+ 123 14Lam CasBD+53   82   2772 21489         434           002615.1+535813003146.4+543120120.05-08.24 4.73  -0.10 -0.35 -0.12   B8Vn               +0.045-0.010 +.030-012V          0.2   0.5      *
+ 124          BD+52   92   2774 21486    I                  002612.4+521715003141.2+525022119.91-09.92 5.60  +1.15 +1.13         K2III              -0.053-0.019 +.008-052SB                         
+ 125   Lam1PheCD-49  115   2834215131  15  W                002635.6-492123003125.0-484813311.75-67.98 4.77  +0.02 +0.04         A0V                +0.143+0.017 +.027-002SB    109  8.8  30.3      *
+ 126   Bet1TucCP-63   50   2884248201      W     A          002657.7-633033003132.7-625729306.78-54.02 4.37  -0.07 -0.17 -0.07   B9V                +0.090-0.054 +.030+014SB    173  0.2  27.0AC   6*
+ 127   Bet2TucCP-63   50   2885248202      W     C          002658.4-633100003133.6-625757306.78-54.01 4.54  +0.15 +0.03 +0.08   A2V+A7V            +0.101-0.056 +.030+010       50  0.2  27.0AC   6*
+ 128          BD+42   99   2888 36453                       002703.0+425635003226.8+432941119.29-19.24 6.70  -0.01 -0.20         A1Vn               +0.018-0.010      -015SB    265                 *
+ 129          BD+70   24   2904  41422034                   002720.9+702548003319.3+705854121.44  8.16 6.42  -0.01 -0.06         A0Vn               +0.028-0.004      -010      154                  
+ 130 15Kap CasBD+62  102   2905 11256  16          Kap Cas  002718.6+622248003300.0+625554120.84  0.14 4.16  +0.14 -0.80 +0.06   B1Ia              e+0.003-0.003      -002SB     62                 *
+ 131 52    PscBD+19   79   2910 740842033     452           002720.8+194437003235.5+201740116.94-42.36 5.38  +1.08 +0.96         K0III              +0.135-0.047 +.032-013V          6.8  49.6       
+ 132 51    PscBD+06   64   29131092622032     449  Var?     002714.1+062412003223.8+065720114.55-55.61 5.67   0.00 -0.17         B9.5V              +0.035+0.002      +017      125  0.7   0.0 O   4*
+ 133          BD+26   76   2924 74083                       002718.2+270144003234.5+273450117.82-35.10 6.67                      A2IV               -0.017-0.015      +002                           
+ 134          BD+27   84   2942 74090         455           002732.4+274341003249.1+281649117.96-34.41 6.30  +1.00 +0.73         K0III              -0.006+0.007 +.006-012SB         4.9   8.5AB   3*
+ 135          BD+54  101   2952 21512                       002737.3+542039003310.4+545342120.28-07.88 5.93  +1.04 +0.84         K0III              +0.071-0.042      -035                           
+ 136   Bet3TucCP-63   52   3003248208      W                002810.4-633456003243.8-630152306.54-53.97 5.09  +0.04 +0.02         A0V                +0.081-0.038 +.049+005V      84  0.2   0.1      *
+ 137 16    CasBD+65   70   3038 11265                       002835.1+661156003424.9+664501121.25  3.93 6.48  -0.08 -0.32         B9III              +0.021 0.000      -016SB                         
+ 138          CD-30  156   30591663671013I                  002844.3-300633003341.1-293330  0.01-85.40 5.55  +1.27 +1.23         K2III              -0.026-0.030      -009SB                        *
+ 139   The TucCP-71   20   31122556792035          The Tuc  002908.9-714904003323.3-711558305.01-45.79 6.13  +0.23 +0.20         A7IV               +0.067-0.012      +002       52                 *
+ 140          CP-53  117   31582320911014                   002942.3-525532003427.8-522223308.97-64.55 5.57  +0.47  0.00         F3IV-V             +0.230+0.032 +.038+035                           
+ 141          BD+12   57   3166 91980                       002944.1+124917003455.3+132216116.77-49.30 6.40                      K0                 -0.090-0.057      -019V                          
+ 142 13    CetBD-04   62   3196128839         490    212    003006.0-040836003514.9-033534112.89-66.15 5.20  +0.56 +0.08         F8V                +0.413-0.026 +.060+009SBO    18  0.7   0.3AB   3*
+ 143 14    CetBD-01   68   32291288432036                   003024.7-010318003532.8-003020114.12-63.10 5.93  +0.44 -0.02         F5IV               +0.146-0.066      +006V   =< 10                  
+ 144          BD+53  102   3240 21551                       003034.1+533703003608.3+541007120.67-08.64 5.08  -0.11 -0.36         B7III              +0.022 0.000      +001V      58                  
+ 145          BD+12   59   3268 91990                       003043.9+123940003554.7+131224117.11-49.49 6.41  +0.52 -0.05         F7V                -0.143-0.189 +.020-025    =< 15                  
+ 146          BD+59   84   3283 11291                       003046.0+594632003627.3+601934121.08-02.49 5.79  +0.29 +0.29         A4III              -0.001-0.003      -009V?                        *
+ 147   Lam2PheCD-48  121   3302215157                       003055.0-483257003541.1-480003310.27-68.90 5.51  +0.44 -0.01         F6V                +0.045-0.104      +008        0                  
+ 148          CP-55  117   3303232099                219    003053.4-552217003533.4-544919307.83-62.16 6.06  +1.01               K0IV               +0.027-0.054      -010                           
+ 149          BD+26   91   3322 74136                221    003102.6+264215003620.0+271517118.81-35.50 6.50  -0.09 -0.39         B8IIIpHgMn:        +0.011-0.016      +001SB?    28                 *
+ 150          BD-15  109   3325147360                       003101.5-153120003603.0-145825105.75-77.33 6.45  +1.06 +0.91         G9III              -0.083-0.079      +012V?                         
+ 151          CD-23  220   33261664002037          BG Cet   003108.3-232331003606.9-225033 83.10-84.48 6.06  +0.29               A6pSr              -0.072-0.052      +013                          *
+ 152          BD+43  113   3346 36509    I                  003120.1+435613003646.6+442919120.18-18.31 5.13  +1.60 +1.97         K5-M0III           -0.023+0.033 +.007-033V    < 17                  
+ 153 17Zet CasBD+53  105   3360 21566  17            225    003123.7+532048003658.3+535349120.78-08.91 3.66  -0.20 -0.87 -0.21   B2IV               +0.019-0.009 +.004+002SB?    18                 *
+ 154 29Pi  AndBD+32  101   3369 54033  18     513    227    003132.2+331008003652.9+334310119.47-29.05 4.36  -0.14 -0.55 -0.12   B5V                +0.015-0.004 -.003+009SB1O   34  4.2  35.2AB   3*
+ 155 53    PscBD+14   76   3379 919952039          AG Psc   003134.6+144053003647.3+151354117.70-47.49 5.89  -0.15 -0.66         B2.5IV            v+0.002-0.015      -009SB                        *
+ 156          BD+23   84   3411 74148                       003151.1+232754003707.2+240051118.74-38.74 6.47R                     K2III              -0.014-0.044      -001                           
+ 157          BD+34   86   3421 54038                       003159.7+345057003721.1+352358119.70-27.38 5.48  +0.88 +0.48         G2.5IIa            -0.016-0.005      -000                           
+ 158          BD+81   13   3440   1063941            235    003212.4+815630003947.3+822938122.53 19.63 6.40  +0.55 -0.01        dF6                 -0.111+0.078 +.028-033V                          
+ 159          CD-25  225   3443166418         520           003212.5-251903003720.7-244602 68.68-86.03 5.57  +0.72 +0.24 +0.27E  G8V                +1.390-0.012 +.076+017SB2     2: 0.2   0.5      *
+ 160          CP-65   58   3444248225                       003213.2-654029003637.4-650729305.46-51.93 6.42  +1.26 +1.38         K2-3III            +0.029-0.020      +020                           
+ 161          BD+02   80   34571093152040                   003221.5+023512003730.5+030807116.06-59.55 6.39  +1.33 +1.52 +0.54E  K4III              +0.095-0.061      +004V                         *
+ 162          CP-55  130   3488232114                       003238.7-545639003718.1-542339307.41-62.61 6.41  +1.00               K0II-IIICNIV       +0.056-0.021      -006                           
+ 163 30Eps AndBD+28  103   3546 74164  19I                  003316.1+284608003833.3+291842119.57-33.47 4.37  +0.87 +0.47 +0.51   G6IIIFe-3CH1       -0.227-0.254 +.031-084V       9                  
+ 164          BD+48  192   3574 36550    I    546           003338.0+484818003909.9+492116120.88-13.47 5.43  +1.64               K7III              +0.008-0.011      -008V          5.3  13.3      *
+ 165 31Del AndBD+30   91   3627 54058  20I:   548           003358.7+301850003919.7+305139119.87-31.94 3.27  +1.28 +1.48 +0.66   K3III              +0.136-0.091 +.028-007SB1O < 17  8.2  28.7AB   3*
+ 166 54    PscBD+20   85   3651 74175      W         245    003409.5+204240003921.8+211502119.18-41.53 5.87  +0.85 +0.57 +0.39   K0+V               -0.464-0.370 +.099-034V          4.9 122.0      *
+ 167 55    PscBD+20   87   3690 74182    I    558           003439.6+205323003955.6+212618119.36-41.35 5.36  +1.16 +1.05         K0III+F3V          +0.028-0.035 +.009-017V          3.2   6.6      *
+ 168 18Alp CasBD+55  139   3712 21609  21I    561  Alp Cas  003449.7+555920004030.5+563214121.42-06.30 2.23  +1.17 +1.13 +0.60   K0IIIa             +0.053-0.032 +.016-004V?     21  6.7  64.4AD   4*
+ 169          CP-73   42   3719255690                       003445.3-734115003840.8-730814304.22-43.96 6.85  +0.11 +0.12 +0.06C  A1m                -0.017+0.020      +021V?                         
+ 170          CD-34  224   3735192663              Z Scl    003502.6-343028003957.9-335742322.13-82.73 6.69  +0.51 -0.03         F8V               v+0.333-0.116 +.020-011                          *
+ 171          CD-45  201   3750215185                       003505.9-452046003952.0-444748309.65-72.18 6.01  +1.14 +1.09         K1IIICNII          +0.045 0.000      +008                           
+ 172          BD-17  109   3794147395      W                003527.6-170354004028.6-163101108.92-79.09 6.49  +0.92 +0.53         G5                 +0.037-0.040      +048V          2.5 105.0AB   3 
+ 173          CD-24  263   3795166475                       003530.7-242040004032.9-234816 85.79-85.86 6.14  +0.70 +0.21         G3V                +0.644-0.333 +.043-053V                          
+ 174          BD-05  101   38071288912042  W                003536.9-045402004042.4-042107116.05-67.08 5.91  +1.10 +0.89         K0III              -0.013-0.013      +035V          2.5  64.3       
+ 175 32    AndBD+38   90   3817 540792043                   003541.7+385435004107.2+392731120.76-23.37 5.33  +0.89 +0.60 +0.46   G8III              -0.010-0.007 +.010-005V    < 17                 *
+ 176          CP-60   46   3823232143                       003545.2-600058004026.4-592716305.56-57.61 5.89  +0.55 +0.01         G1V                +0.889+0.448 +.058+002                           
+ 177          BD+65   83   3856 113362045                   003605.6+653557004203.4+660851121.98  3.29 5.83  +1.04 +0.87         G9III-IV           -0.013-0.009      -003                           
+ 178          BD+23   94   3883 742002044  W         258    003617.6+240451004136.0+243745120.09-38.19 6.04  +0.26 +0.22 +0.11   A7m                +0.107-0.016      -015       25                 *
+ 179 19Xi  CasBD+49  164   3901 216372046            260    003629.0+495751004203.9+503045121.41-12.33 4.80  -0.11 -0.63 -0.12   B2V                +0.015-0.005      -010SB1   211                 *
+ 180   Mu  PheCD-46  180   39192151941015                   003636.0-463802004119.6-460506308.31-70.94 4.59  +0.97 +0.72 +0.52   G8III              -0.014-0.002 +.004+019V?                        *
+ 181          BD+57  132   3924 21642                       003645.8+581219004231.1+584512121.77-04.10 6.17  -0.01 -0.11         B9.5III            +0.036-0.007      -003      100                  
+ 182 M 31  And                                     S And    0 0 0      0 0 0 0 0      0 0                                                                                                           *
+ 183   Xi  PheCP-57  143   3980232152      W       Xi  Phe  003712.9-570305004146.4-563006305.65-60.57 5.70  +0.20               ApSrEuCr           +0.085+0.044      +010           4.4  13.2      *
+ 184 20Pi  CasBD+46  146   4058 36602                268    003755.8+462839004328.1+470129121.52-15.82 4.94  +0.18 +0.09         A5V                -0.020-0.034 +.023+013SB2O   58                 *
+ 185   Lam1SclCD-39  175   4065192690      W                003754.2-390041004242.9-382748311.54-78.52 6.06  -0.03 -0.13         A0V                +0.003-0.005      +010V          0.3   0.6      *
+ 186          CP-60   48   4088248238                       003812.5-604835004241.8-601545304.92-56.83 5.98  +1.32 +1.45         K5III              +0.255-0.045      +026                          *
+ 187   Rho TucCP-66   47   40892482372047                   003812.0-660103004228.4-652805304.43-51.63 5.39  +0.50 +0.02         F6V                +0.053+0.042 +.038+014SBO     0                 *
+ 188 16Bet CetBD-18  115   4128147420  22I           272    003834.2-183208004335.4-175912111.31-80.68 2.04  +1.02 +0.87 +0.51   G9.5IIICH-1        +0.234+0.033 +.061+013V?     18                 *
+ 189          BD+47  181   4142 36617                       003852.8+471858004426.4+475151121.72-14.99 5.67  -0.12 -0.56         B5V                -0.026+0.015      -060SB    177                 *
+ 190          BD-12  126   4145147422                       003847.9-123314004350.2-120042115.84-74.78 6.02  +1.10 +1.09         K2III-IV           +0.007-0.204      -009V?                         
+ 191   Eta PheCP-58   42   4150232162  23  W                003851.7-580041004321.2-572747305.08-59.63 4.36   0.00 -0.02  0.00   A0IV               -0.006+0.011 +.046+002V      96  7.0  19.8       
+ 192 21    CasBD+74   27   4161  4216  24     624  YZ Cas   003902.2+742629004539.0+745917122.55 12.12 5.66  +0.05 +0.07         A2IV               -0.018-0.026      +009SBO    27  5.5  36.0      *
+ 193 22Omi CasBD+47  183   4180 36620  25     622  Omi Cas  003908.9+474414004443.5+481704121.78-14.57 4.54  -0.07 -0.51 -0.05   B5IIIe             +0.019-0.008      -017SB1O  260  7.2  33.6      *
+ 194 17Phi1CetBD-11  128   41881474232048I           278    003908.7-110915004411.4-103634116.69-73.39 4.76  +1.01 +0.84 +0.51   K0III             v-0.009-0.113 +.022+001     < 17                 *
+ 195   Lam2SclCD-39  181   4211192703  26                   003922.0-385821004412.1-382518310.14-78.60 5.90  +1.16 +1.18         K1III              +0.244+0.113 +.010+027                           
+ 196          BD+54  143   4222 21677         625           003935.0+544027004517.2+551318122.05-07.64 5.42  +0.04 +0.04         A2V s              -0.025+0.002 +.012-009V      59  5.4  89.0AC   3*
+ 197          BD-22  127   4247166528                       003947.5-223321004444.4-220022106.02-84.66 5.24  +0.33               F1III-IV           -0.066+0.083 +.048+012       32                  
+ 198          CD-43  207   42932152211017                   004013.4-431316004457.1-424036307.36-74.40 5.94  +0.28               F0V                -0.086-0.102      +010SB                         
+ 199          CP-63   72   4294248243      W                004010.5-630243004432.3-622952304.31-54.61 6.07  +0.44 +0.13         F5III-IV           +0.143-0.005      -004V?         1.8   2.5      *
+ 200          BD+68   49   4295 11380                       004022.1+684642004639.0+691930122.50  6.46 6.33R                     F3V                +0.196+0.001      -014       15                  
+ 201          BD-05  120   4301128935    I                  004018.6-051038004524.1-043745119.00-67.46 6.15  +1.62 +2.01         M0III              +0.028+0.033      +007V                          
+ 202          CP-54  166   43042321682049                   004024.0-541544004500.0-534254305.07-63.39 6.15  +0.53 -0.08         F7III              +0.230 0.000      +014                          *
+ 203 18    CetBD-13  128   4307147432      W                004027.3-132520004528.7-125251117.05-75.68 6.15  +0.61 +0.10         G0V                -0.034-0.201      -013           6.3  69.5      *
+ 204          BD+54  148   4321 21689                       004031.6+544531004615.1+551819122.19-07.56 6.52                      A2III              +0.015-0.012      -008                           
+ 205          BD+44  160   4335 36640                       004038.4+441853004610.9+445141121.95-18.00 6.05  -0.07 -0.27         B9.5IIIpHgMnCr     +0.028-0.009      +000SB     25                 *
+ 206          BD-17  132   4338147436         636           004041.7-165816004541.7-162527115.55-79.21 6.47  +0.31               F1IVn              +0.014-0.005      -000           3.0   3.0       
+ 207          BD+58  101   4362 21693                       004052.4+590140004642.4+593428122.33-03.29 6.39  +1.09 +0.77         G0Ib               -0.008-0.001      -015V                          
+ 208 23    CasBD+74   29   4382  4226                       004105.0+741805004746.1+745051122.69 11.98 5.41  -0.08 -0.39         B8III              +0.015-0.009      -003SB2O    4                 *
+ 209          CD-48  176   4391215232      W                004104.1-480604004545.6-473306305.68-69.54 5.80  +0.64               G1V                +0.184+0.086 +.049-011           7.7  14.3       
+ 210          CD-23  293   4398166555                       004113.6-230407004611.8-223119108.14-85.24 5.50  +0.98               G3V                +0.201-0.006 +.021-015V                         *
+ 211 57    PscBD+14  111   4408 92072    I           293    004118.9+145549004633.0+152832121.19-47.38 5.38  +1.65 +1.76         M4IIIa             -0.027-0.044 +.015-027V                         *
+ 212          BD+71   37   4440  4229                       004136.8+720741004809.1+724030122.68  9.80 5.87  +1.01 +0.82         K0IV               +0.130+0.024      +001V                          
+ 213 58    PscBD+11   96   4482 920802050                   004148.4+112542004701.5+115826121.22-50.88 5.50  +0.97               G8II               +0.058-0.036      -001                           
+ 214 59    PscBD+18  101   4490 920822051          XX Psc   004156.4+190156004713.6+193444121.57-43.28 6.13  +0.27 +0.18         F0Vn               +0.104+0.011      +000V?    163                 *
+ 215 34Zet AndBD+23  106   4502 74267  27I W       Zet And  004202.1+234324004720.3+241602121.74-38.59 4.06  +1.12 +0.90 +0.59   K1IIe              -0.100-0.083 +.037-024SB1O   40  5.6 162.7AD   4*
+ 216 60    PscBD+05  104   4526109461                       004213.2+061142004723.6+064427121.13-56.12 5.99  +0.94 +0.70         G8III              +0.014-0.015      +014V                          
+ 217 61    PscBD+20  105   4568 74280                       004236.4+202244004754.8+205531121.82-41.94 6.54  +0.50 +0.03         F8V                +0.157+0.006 +.022+001V                         *
+ 218          BD-18  127   4585147451    I                  004244.3-183630004743.3-180341117.34-80.89 5.70  +1.30 +1.46         K3III              +0.043+0.031      +002V                          
+ 219 24Eta CasBD+57  150   4614 21732    I:   671           004303.0+571706004906.0+574857122.60-05.05 3.44  +0.57 +0.01 +0.36   F9V+dM0            +1.100-0.529 +.176+009SB1O=<  6  4.0  11.6AB   8*
+ 220          BD-22  134   46221665851018                   004304.1-221605004801.1-214321114.55-84.54 5.57  -0.06 -0.12         B9V                +0.028-0.011      +021V      53                  
+ 221 62    PscBD+06  105   4627109470                       004306.0+064514004817.4+071800121.55-55.56 5.93  +1.10 +1.00         G8III              +0.111+0.004      -000V?                         
+ 222          BD+04  123   46281094711019  W                004308.2+044600004823.0+051650121.49-57.57 5.75  +0.88 +0.59 +0.47   K2V                +0.758-1.146 +.145-013V          4.6 181.2       
+ 223 25Nu  CasBD+50  147   4636 21729                302    004309.8+502522004850.1+505806122.51-11.90 4.89  -0.11 -0.42         B9III              +0.035-0.006      +009V     210                  
+ 224 63Del PscBD+06  107   4656109474  28I W                004329.6+070227004841.0+073506121.73-55.28 4.43  +1.50 +1.86 +0.87   K4IIIb             +0.085-0.052 +.019+032V?   < 19  8.6 113.3      *
+ 225 64    PscBD+16   76   4676 920991020  W                004343.3+162403004858.7+165626122.09-45.92 5.07  +0.51  0.00         F8V                -0.003-0.204 +.047+002SB2O < 17  7.4  76.7AB   3*
+ 226 35Nu  AndBD+40  171   4727 366991021                   004417.7+403204004948.8+410444122.60-21.79 4.53  -0.15 -0.58 -0.15   B5V+F8V            +0.023-0.019      -024SB2O   80                 *
+ 227          BD-14  145   47301474642054I    680           004424.2-140613004925.6-133341120.84-76.42 5.59  +1.30 +1.54         K5III              +0.105-0.104      +004V          6.2   1.3      *
+ 228          CD-24  345   4732166602         679           004418.2-244050004913.9-240811113.36-86.97 5.90  +0.95 +0.72         K2III              +0.078-0.051      +023V          7.7   8.8       
+ 229          CD-47  229   47372152452053                   004418.4-471437004856.7-464152304.21-70.42 6.27  +0.90               G8III              -0.008+0.017      +012                           
+ 230 65    PscBD+26  131   4757 74295         683B          004430.6+270958004952.8+274239122.51-35.16 7.0   +0.36 +0.06         F4III              +0.084-0.010 +.011+005V      82  0.0   4.5      *
+ 231 65    PscBD+26  131   4758 74296         683A          004430.9+270955004953.2+274237122.51-35.16 7.1                       F5III              +0.091-0.009 +.011+007       82  0.0   4.5      *
+ 232          CD-24  347   4772166608                       004438.0-235425004933.4-232142116.39-86.21 6.28  +0.13 +0.13         A3V                -0.008 0.000      +012V                          
+ 233          BD+63   99   4775 11424  29  S         317    004439.2+634211005043.6+641451122.85  1.38 5.39  +0.49 +0.14         G0III-IV+B9.5V     +0.030-0.012      +003SBO     0                 *
+ 234          BD+44  176   4778 367022055          GO And   004443.0+442726005018.3+450008122.72-17.87 6.15  +0.01 -0.03         A0pCr             v+0.065+0.006      +002                          *
+ 235 19Phi2CetBD-11  153   4813147470  30            316    004507.1-111058005007.6-103840121.81-73.51 5.19  +0.50 -0.02 +0.28   F7IV-V             -0.226-0.229 +.065+008V       0                 *
+ 236   Lam HyiCP-75   64   4815255710  31                   004507.2-752804004835.4-745524303.18-42.20 5.07  +1.37 +1.68 +0.52E  K5III              +0.130-0.033 +.025-009V                          
+ 237          BD+61  178   4817 11430    I           319    004517.5+611540005116.4+614821122.91-01.07 6.07  +1.88 +1.84         K2Ib-IICN-2        -0.002+0.006      -006V?                        *
+ 238          BD+50  161   4818 21767              V526 Cas 004513.9+505748005057.4+513029122.85-11.36 6.39  +0.28 +0.12         F2IV               +0.135-0.003      +002V?                        *
+ 239          CD-44  216   4849215254              AZ Phe   004522.6-435624005003.7-432341303.82-73.73 6.48  +0.29 +0.12         A9-F0III           +0.011+0.016      +015                          *
+ 240          BD+82   20   4853   1433942                   004529.8+830952005453.1+834226123.03 20.84 5.62  +0.09 +0.10         A4V                +0.062-0.022      +012       65                  
+ 241          BD+50  164   4881 21775                       004551.3+510138005133.7+513416122.95-11.30 6.21                      B9.5V              -0.010-0.019      -014       68                  
+ 242   Rho PheCD-51  209   49192322032056          Rho Phe  004608.0-513157005041.2-505913303.23-66.14 5.22  +0.36 +0.16         F2III              +0.067+0.039 +.005+022                          *
+ 243          BD+02  118   4928109507                       004609.3+025033005118.3+032306122.87-59.49 6.37  +1.07 +0.89         K0III              +0.016-0.067      +006V?                        *
+ 244          BD+60  124   5015 11444         721           004705.8+603433005304.1+610727123.13-01.75 4.82  +0.53 +0.12 +0.30   F8V                -0.071+0.172 +.066+021SB1O    6  5.5 129.7AB   5*
+ 245          CD-44  226   5042215270      W                004712.1-441510005152.1-434233302.66-73.42 6.90  +0.35               F2V+F5V            +0.025-0.013D+.007+013V?         0.4   0.9      *
+ 246          BD+37  159   5066 54225                       004722.9+380020005253.4+383255123.24-24.32 6.69  +0.02 +0.10         A2V                +0.029-0.021      +016SB                         
+ 247          CD-24  376   5098166647    I    726           004746.0-243301005240.6-240021128.10-86.87 5.46  +1.24 +1.21         K2III              +0.035+0.035D+.007+034SB         4.4  11.0      *
+ 248 20    CetBD-01  114   51121290091022I                  004753.8-014114005300.5-010839123.83-64.01 4.77  +1.57 +1.93 +0.91   M0III              +0.008-0.017 -.003+016                           
+ 249          BD+36  148   5118 54237                       004758.5+365234005328.2+372505123.38-25.45 6.06  +1.14              gK3                 +0.013-0.046      -006V?                         
+ 250          BD+51  179   5128 21814    I    735           004801.1+520849005347.6+524121123.29-10.18 6.27  +0.19 +0.15 +0.08   A5m                +0.076-0.026D+.013-001       30  3.4   8.2AB   4*
+ 251          CD-25  338   5156166651         733A          004818.0-251917005312.4-244637132.59-87.62 6.46  +0.44 +0.03         F6IV-V             +0.098+0.037D+.006-004V          2.5   5.4      *
+ 252   Lam1TucCP-70   37   5190248269      W         334    004836.3-700244005224.3-693016302.81-47.62 6.22  +0.56 +0.08         F7IV-V             -0.007-0.086      +030           0.7  20.6       
+ 253 26Ups1CasBD+58  134   5234 21832    I    748           004903.7+582553005500.1+585822123.39-03.90 4.83  +1.21 +1.26 +0.61   K2III              -0.032-0.043 +.006-023V?   < 17  7.6  94.1AC   3*
+ 254 66    PscBD+18  122   5267 92145         746           004917.4+183846005435.2+191118123.96-43.68 5.74R -0.01 -0.14         A1VN               +0.018-0.014 +.014+010SB    175  0.8   0.5AB   3*
+ 255 21    CetBD-09  181   5268129019                       004914.8-091655005417.6-084427125.17-71.60 6.16  +0.92 +0.54         G5IV               +0.018-0.052      +045V                          
+ 256          BD+47  242   5273 36763    I                  004924.0+480811005505.2+484043123.55-14.19 6.27  +1.68 +2.00         M2.5IIIa           -0.022-0.006      -052                           
+ 257          CP-63   83   52762482762057          BQ Tuc   004928.3-632452005337.9-625217302.51-54.25 5.70  +1.56 +1.77         M4III              +0.073+0.004      -010                          *
+ 258 36    AndBD+22  146   5286 74359         755    343    004936.6+230513005458.0+233742123.97-39.24 5.47  +1.00 +0.90 +0.50   K1IV               +0.131-0.031D+.022+002           0.4   0.6AB   3*
+ 259          BD+23  126   5316 74365    I           346    004953.4+240055005514.7+243325124.03-38.31 6.20  +1.62 +1.75         M4IIIab            +0.020-0.015      -010                           
+ 260          BD+57  172   5343 21846    I                  005016.3+572719005612.9+575948123.57-04.87 6.21  +1.37               K3III              +0.037-0.014      -030                           
+ 261          BD+67   81   5357 11481                       005027.0+681406005655.6+684634123.43  5.91 6.37  +0.38 -0.02         F4III              +0.137-0.021      -008       34                  
+ 262 67    PscBD+26  151   5382 743732059                   005035.6+264002005558.5+271234124.17-35.65 6.09  +0.14 +0.09         A5IV               -0.020+0.013      -008      130                  
+ 263          BD-08  167   53841290322058I                  005039.2-075317005542.4-072050126.06-70.19 5.85  +1.52 +1.93 +0.64E  K5III              -0.007-0.046      +002V                         *
+ 264 27Gam CasBD+59  144   5394 11482  32I    782  Gam Cas  005040.1+601031005642.5+604300123.58-02.15 2.47  -0.15 -1.08 -0.08   B0IVe             v+0.026-0.005 +.016-007SB    300: 6.3   2.3AB   3*
+ 265 28Ups2CasBD+58  138   5395 21855                       005042.2+583827005639.8+591052123.60-03.68 4.63  +0.96 +0.69 +0.50   G8IIIbFe-0.5       -0.092-0.046 +.051-047V    < 17                 *
+ 266          BD+59  146   5408 11484         784           005045.2+594917005647.1+602146123.59-02.50 5.55  -0.07 -0.32         B9IVn              +0.032-0.008D+.007-005SB2O  178  0.5   0.2AB   3*
+ 267 22Phi3CetBD-12  162   5437147519    I                  005100.6-114829005601.5-111600127.04-74.10 5.31  +1.52 +1.78         K4III              -0.020-0.008 +.009-026V?                         
+ 268          CD-28  288   5445166686    I                  005104.5-281903005555.5-274632246.23-88.81 6.10  +1.67 +1.97         M0III               0.000+0.002      +022V                          
+ 269 37Mu  AndBD+37  175   5448 54281  33     788           005112.0+375725005645.2+382958124.07-24.36 3.87  +0.13 +0.15 +0.08   A5V                +0.152+0.033 +.039+008       72  6.8 266.7AD   4*
+ 270   Lam2TucCP-70   40   5457248281  34                   005116.2-700404005500.3-693137302.47-47.60 5.45  +1.09 +1.00         K2III              +0.006-0.045 +.035+005                           
+ 271 38Eta AndBD+22  153   5516 743882060I W                005151.8+225240005712.4+232503124.65-39.43 4.42  +0.94 +0.69 +0.48   G8IIIb             -0.044-0.048 +.009-010SB2O < 17  6.9 131.7      *
+ 272          BD+45  237   5526 36795                       005159.9+451755005739.7+455023124.07-17.02 6.12  +1.02 +0.89         K2III              +0.013+0.005      +005                           
+ 273          BD+65  115   5550 11502                       005210.9+654842005831.1+662108123.64  3.49 5.97  -0.02 -0.13         A0III              +0.043-0.006      -010                           
+ 274 68    PscBD+28  157   5575 743951023I                  005225.3+282706005750.2+285932124.62-33.86 5.42  +1.08              gG6                 +0.008-0.008      -001                           
+ 275          BD+33  140   5608 543062061                   005245.2+332445005814.2+335703124.54-28.90 5.98  +1.00               K0                 +0.035-0.072      -017                           
+ 276          BD+12  119   5612 92183                       005239.5+130919005754.5+134145125.34-49.15 6.32  +0.89 +0.57 +0.46   G8III              -0.011-0.013      +015V                         *
+ 277          BD+20  131   5641 74402         805           005259.2+205151005818.9+212416125.07-41.44 6.37R +0.09 +0.11         A2V                -0.006-0.003D+.009-006V?         1.4   0.4      *
+ 278          BD+70   65   5715  42882063                   005347.8+702637010031.0+705859123.68  8.12 6.39  +0.13 +0.11         A4IV               +0.082 0.000      +006V     101                 *
+ 279 23Phi4CetBD-12  173   5722147546                       005343.4-115511005843.9-112248129.49-74.16 5.61  +0.97 +0.66         G7III              -0.034-0.019      -019V?                         
+ 280   Alp SclCD-30  297   5737166716  35            359    005347.3-295352005836.4-292127268.05-87.27 4.31  -0.16 -0.56 -0.13   B7IIIp             +0.022+0.004      +010SBO     7                 *
+ 281          CP-61   50   5771248293                       005412.8-611413005822.4-604147301.40-56.41 6.23  +0.10 +0.13         Am                 +0.050+0.018      +007                           
+ 282          BD+43  193   5788 36832         824B          005423.5+441020010003.4+444240124.54-18.13 6.84H                     A2Vn               +0.011-0.024D+.005+017SB    250  0.8   7.8      *
+ 283          BD+43  193   5789 36833         824A          005423.7+441028010003.6+444248124.54-18.13 6.04H -0.01 -0.04         B9.5Vn             +0.016-0.023D+.005+001SB    298  0.8   7.8      *
+ 284          BD+05  131   5820109581    I W       WW Psc   005438.6+055638005949.7+062859126.69-56.33 6.11  +1.67 +1.92 +1.02E  M2III              +0.023-0.008 +.001-015V?         7.1  31.0      *
+ 285          BD+85   19   5848   181 906                   005501.5+854314010844.7+861525123.24 23.40 4.25  +1.21 +1.33 +0.60   K2II-III           +0.076-0.012      +009                           
+ 286          BD+88    4   5914   209                       005536.8+882915013350.4+890056123.13 26.16 6.46  +0.11 +0.07         A3V                +0.062-0.036      -010                           
+ 287          BD+50  202   6028 21938                       005629.2+502950010218.4+510206124.68-11.80 6.47                      A3V                -0.004-0.013      +006                           
+ 288   Xi  SclCD-39  260   60551928702064                   005638.0-392723010118.3-385500293.64-78.03 5.59  +1.18               K0III              +0.069+0.045 +.034-031                           
+ 289          BD+46  243   6114 36875         862           005715.9+465020010301.5+472234124.97-15.45 6.45  +0.25 +0.09         A9IV               +0.088-0.015 +.012+003SB         1.0   0.9      *
+ 290 39    AndBD+40  209   6116 36874         863           005716.9+404827010254.3+412042125.24-21.47 5.98  +0.16 +0.10 +0.05   A5m                -0.020-0.010      +004V?     39  6.2  20.9      *
+ 291 69Sig PscBD+31  168   6118 54374                       005720.3+311603010249.1+314816125.75-31.00 5.50  -0.05 -0.18         B9.5V              +0.015-0.028      +010SB2O   46                 *
+ 292          BD+60  157   6130 11551         868           005727.2+603215010337.0+610430124.40-01.76 5.92  +0.49               F0II               -0.006+0.004      -001V      20  3.1   1.2       
+ 293   Sig SclCD-32  410   61781928841026                   005739.9-320525010226.4-313307275.15-84.97 5.50  +0.08 +0.13         A2V                +0.082+0.012      -008V                          
+ 294 71Eps PscBD+07  153   6186109627  36I D                005745.1+072106010256.6+075324127.89-54.87 4.28  +0.96 +0.70 +0.52   K0III              -0.078+0.023 +.027+007V?   < 17  0.0   0.2      *
+ 295   Ome PheCP-57  220   61922322681027                   005748.1-573227010201.8-570009300.04-60.07 6.11  +0.94               G8III              +0.006+0.015      +013                           
+ 296 25    CetBD-05  177   6203129094    I W                005759.0-052217010302.6-045012130.52-67.54 5.43  +1.11 +1.04         K0III-IV           -0.108-0.106      +015           6.4  99.9       
+ 297          BD+60  158   6210 11557                       005808.7+610238010419.6+613449124.47-01.25 5.84  +0.54 +0.11         F6V                -0.070-0.022      -016       30                  
+ 298          BD+51  220   6211 219672066I                  005809.5+515800010402.4+523008124.88-10.32 5.99  +1.47               K2                 +0.001-0.059      -007                           
+ 299          CD-47  313   62452153432065                   005818.8-465607010249.2-462351297.02-70.60 5.36  +0.90               G8III               0.000+0.002 +.025-001                           
+ 300          CD-30  325   6269166774                       005831.2-300345010317.6-293133256.19-86.46 6.29  +0.93 +0.59         G5IV               -0.114-0.030      +057                           
+ 301 26    CetBD+00  174   6288109643  37     875           005840.1+004951010349.0+012200129.39-61.35 6.04  +0.27 +0.13         F1V                +0.122-0.042D+.024+006           3.4  16.0AB   3*
+ 302          BD+50  212   6300 21988                       005855.7+502824010446.8+510036125.08-11.81 6.54  -0.08 -0.57         B3V                +0.019-0.002      -003                          *
+ 303          BD+28  174   6301 74471                       005859.5+290731010427.6+293931126.31-33.13 6.19  +0.43 -0.05         F7IV-V             +0.084-0.116      +000       12                  
+ 304          CP-66   80   6311248308              CC Tuc   005853.1-655936010242.9-652722301.05-51.63 6.21  +1.64 +1.91 +1.33   M2III              +0.004 0.000      +035V                         *
+ 305          BD+39  249   6314 54398                       005858.8+392718010436.4+395928125.67-22.81 6.72  +0.31 +0.04         F0Vn               +0.077-0.022      +011                           
+ 306          BD+86   17   6319   193                       005906.3+863648011613.5+870843123.27 24.29 6.25  +1.12 +0.99        gK2                 +0.051-0.027 +.011-005                           
+ 307 73    PscBD+04  172   6386109656    I                  005941.7+050713010452.6+053923129.09-57.05 6.00  +1.51 +1.86        gK5                 +0.028-0.014      -015V                          
+ 308 72    PscBD+14  163   6397 922301028     889           005948.5+142430010505.4+145646127.84-47.80 5.68  +0.41 -0.06         F4II-III           +0.006+0.054      +004SB2 =< 10  7.4  55.2      *
+ 309          BD+61  206   6416 11571                       010004.0+621336010622.8+624542124.64-00.06 6.54  +0.19 +0.06         A5Vn               +0.102-0.024      +011SB    125                 *
+ 310 74Psi1PscBD+20  156   6456 74482         899A   397    010019.1+205616010540.9+212824127.34-41.28 5.34  -0.03 -0.06         A1Vn               +0.050-0.016D+.016-003V     246  0.3  29.9AB   3*
+ 311 74Psi1PscBD+20  157   6457 74483         899B          010019.9+205548010541.7+212755127.35-41.28 5.56  -0.07 -0.16         A0Vn               +0.047-0.018D+.016-004V     267  0.3  29.9AB   3*
+ 312          BD+79   29   6473  4331                       010039.5+792841010912.3+800042123.74 17.17 6.29R                   sgG6                 -0.030-0.038      -027V                          
+ 313 77    PscBD+04  175   6479109666         903A          010038.7+042233010549.2+045430129.66-57.77 6.35  +0.38 -0.05         F3V                +0.022-0.121      -007           1.0  33.0AB   5*
+ 314 77    PscBD+04  176   6480109667         903B          010040.9+042237010551.4+045434129.68-57.77 7.25  +0.49 -0.04         F6V                +0.029-0.119      -010V          1.0  33.0AB   5*
+ 315 27    CetBD-10  229   6482147601                       010036.2-103051010536.8-095845134.63-72.53 6.12  +1.01 +0.86 +0.53   K0III              -0.034-0.033      +012V?                        *
+ 316          BD+56  196   6497 220152069                   010055.6+562410010700.2+565606125.06-05.87 6.43  +1.18 +1.26 +0.42E  K2III              +0.100-0.110      -096                          *
+ 317 28    CetBD-10  230   6530147606                       010104.1-102230010605.1-095022134.92-72.37 5.58  +0.01               A1V                +0.030+0.004      +011SB2    65                 *
+ 318          BD+52  262   6540 22021    I    915           010112.4+525748010709.5+532954125.30-09.30 6.38R                     K2III              +0.023-0.001      +007           4.0  21.7AB   3*
+ 319 75    PscBD+12  135   6557 922502068                   010117.8+122512010633.6+125722128.64-49.75 6.12  +0.96               G8III              +0.019+0.023      +008V                          
+ 320          CD-24  484   65591667991029                   010117.1-243137010607.7-235933170.31-85.44 6.14  +1.09 +1.00         G8-K0III           -0.031-0.041      +033V                          
+ 321 30Mu  CasBD+54  223   6582 220241030  W         405    010136.8+542547010816.4+545513125.32-07.85 5.17  +0.69 +0.09 +0.42   G5Vb               +3.424-1.596 +.136-097SBO     1  5.8 190.5AB   6*
+ 322   Bet PheCD-47  324   6595215365      W         400    010137.3-471515010605.0-464307295.51-70.20 3.31  +0.89 +0.57 +0.50   G8III             v-0.027-0.001 +.021-001           0.2   1.0AB   3*
+ 323          CD-36  417   6619192925                       010145.3-361143010626.5-353939283.32-80.89 6.61  +0.14 +0.16 +0.07   A1V                +0.069-0.023      +018SBO                       *
+ 324 41    AndBD+43  234   6658 369502071                   010216.2+432434010800.9+435631126.08-18.83 5.03  +0.11 +0.14 +0.04   A3m                +0.165-0.070 +.031+009       91                 *
+ 325          CD-24  496   6668166814                       010221.8-243149010713.1-235947172.43-85.26 6.37  +0.23 +0.09         A7V                +0.098-0.036      +015V                          
+ 326          BD+57  200   6676 22032                       010225.6+574347010833.3+581549125.19-04.53 5.79  -0.01 -0.27         B8V                +0.007-0.005      -004                           
+ 327 78    PscBD+31  185   6680 544452072                   010229.1+312843010801.3+320044127.02-30.73 6.25  +0.40 -0.01         F5IV               +0.204-0.030      +014V     101                 *
+ 328 79Psi2PscBD+19  185   6695 74506                       010235.2+201227010757.2+204421128.13-41.96 5.55  +0.13 +0.13         A3V                +0.087-0.094      -002V     125                  
+ 329 30    CetBD-10  238   6706147622                       010244.5-101914010746.2-094708136.22-72.24 5.82  +0.43 +0.02         F7IV               +0.152+0.017      +022V?                         
+ 330 80    PscBD+04  190   67631096972073  W         410    010313.0+050715010822.2+053859130.68-56.96 5.52  +0.34  0.00 +0.18   F0III-IV           -0.264-0.185 +.036+007           3.8 159.3AC   3*
+ 331   Ups PheCD-42  391   67672153741031  W                010313.8-420118010747.9-412913290.82-75.25 5.21  +0.16 +0.09 +0.09   A3IV               +0.038+0.010 +.014+014V          0.4   0.2      *
+ 332   Iot TucCP-62   89   6793248324  39                   010321.0-621834010718.7-614631299.64-55.25 5.37  +0.88               G5III              +0.073-0.012 +.033-008                           
+ 333          BD+78   34   6798  4341  41                   010337.2+790830011216.7+794026123.91 16.84 5.64  +0.01 +0.03         A3V                +0.091-0.005      +018      175                  
+ 334 31Eta CetBD-10  240   6805147632  40I W                010333.5-104244010835.4-101056137.15-72.58 3.45  +1.16 +1.19 +0.58   K1.5IIICN1Fe0.5    +0.218-0.138 +.041+012V    < 17  6.7 233.5      *
+ 335 42Phi AndBD+46  275   6811 36972         940  Var?     010341.7+464231010930.2+471431126.11-15.52 4.25  -0.07 -0.34 -0.05   B7Ve               +0.010-0.009 +.003-000V      71  1.2   0.4      *
+ 336 31    CasBD+68   77   6829 116122074  W                010353.1+681447011039.3+684643124.68  5.97 5.29  -0.02 -0.06         A0Vnn              +0.036-0.031 +.017+001V     215                 *
+ 337 43Bet AndBD+34  198   6860 54471  42I    949    414    010407.8+350526010943.9+353714127.10-27.10 2.06  +1.58 +1.96 +1.00   M0+IIIa           e+0.178-0.114 +.049+003V         10.1  80.4AD   5*
+ 338   Zet PheCP-55  241   6882232306      W       Zet Phe  010410.9-554649010823.1-551445297.83-61.71 3.92  -0.08 -0.41 -0.12   B6V+B9V            +0.019+0.025D+.013+015SB2O  127  4.0   6.6ABxC 3*
+ 339 81Psi3PscBD+18  153   6903 92283              Var?     010428.3+190730010949.2+193931128.85-43.00 5.55  +0.69               G0III              -0.006+0.009      -008V?     91                  
+ 340 44    AndBD+41  219   6920 369842075                   010437.8+413259011018.8+420453126.67-20.65 5.65  +0.60               F8V                -0.133-0.043      -011V   =< 10                  
+ 341          BD+24  186   6953 74530    I                  010453.8+245541011019.4+252728128.29-37.22 5.80  +1.47 +1.82         K7III               0.000-0.114      +005V?                         
+ 342          BD+63  149   6960 11615                424    010457.5+634015011125.6+641210125.10  1.42 5.55  -0.07 -0.13         B9.5V              +0.040-0.013      -010V      47                  
+ 343 33The CasBD+54  236   6961 22070      W         423    010500.5+543705011106.2+550859125.76-07.61 4.33  +0.17 +0.12 +0.07   A7V                +0.229-0.022 +.014+009SB    102  5.9 145.6      *
+ 344          BD+14  175   6966 92288    I                  010453.2+150831011011.5+154027129.55-46.96 6.06  +1.49               M0III              +0.031-0.021      -003V                          
+ 345 32    CasBD+64  127   6972 116172078          RU Cas   010510.3+642914011141.4+650108125.07  2.23 5.57  -0.09 -0.28         B9IV               +0.023-0.016      -002V      70                 *
+ 346 32    CetBD-09  227   6976129154                       010511.0-092616011012.0-085422137.48-71.25 6.40  +1.04 +0.87         K0III              -0.013-0.036      -020V?                         
+ 347 33    CetBD+01  221   7014109715    I           422    010524.7+015449011033.6+022644132.54-60.07 5.95  +1.51 +1.87         K4III               0.000-0.015      -003V?                        *
+ 348 45    AndBD+36  201   7019 54494      W                010532.9+371131011110.3+374327127.24-24.98 5.81  -0.10 -0.40         B7III-IV           -0.012-0.007 +.003-001       70  0.0   0.4      *
+ 349 82    PscBD+30  181   7034 54493                       010535.7+305334011106.8+312529127.84-31.26 5.16  +0.23               F0V                -0.011-0.014      +002V      84                  
+ 350          CP-58   81   70822323242077                   010602.5-581325011007.4-574140298.05-59.26 6.41  +0.89               G6II-III           -0.006-0.121      +088                           
+ 351 84Chi PscBD+20  172   7087 745441032I                  010604.6+203011011127.2+210205129.18-41.59 4.66  +1.03 +0.82 +0.54   G8.5III-IIIa       +0.038-0.011 +.015+016     < 19:                 
+ 352 83Tau PscBD+29  190   7106 74546  43I                  010609.0+293332011139.6+300523128.12-32.58 4.51  +1.09 +1.01 +0.58   K0.5IIIb           +0.072-0.035 +.023+030SB   < 17                  
+ 353 34    CetBD-03  161   7147129169    I                  010638.3-024656011143.5-021504134.84-64.65 5.94  +1.40 +1.68         K4III              -0.062-0.026      -009                          *
+ 354          BD+60  186   7157 11637         987           010648.3+611031011309.9+614221125.50-01.06 6.41  +0.01 -0.27         B9V                +0.033-0.021      -002V?    160  2.8   1.2AB   3 
+ 355          BD+44  261   7158 37023    I                  010646.3+444821011234.0+452016126.82-17.37 6.11  +1.64 +2.03         M1III              +0.021+0.026      +022V                          
+ 356          BD+29  195   7229 74561         990           010728.8+293203011259.5+300351128.47-32.58 6.19  +1.00 +0.75         G9III+G1V          +0.020-0.034      +036SB         4.1  10.8AB   4*
+ 357          BD+79   36   7238  4354                       010739.1+792244011630.7+795436124.08 17.09 6.26  +0.42 -0.07         F5V s              -0.055+0.059      -043V?     45                  
+ 358          CD-31  484   7259192977                       010739.8-311953011223.4-304808252.89-84.13 6.52  +0.48 +0.03         F7IV               +0.061-0.077      +014                           
+ 359          CD-38  420   7312192980  44          AI Scl   010809.0-382311011245.4-375123281.60-78.37 5.92  +0.28 +0.12         F0III              +0.090-0.034      +010SB                        *
+ 360 85Phi PscBD+23  158   7318 745712082I    995           010819.0+240315011344.9+243501129.37-38.01 4.65  +1.04 +0.85 +0.53   K0III              +0.017-0.023 +.007+006SB   < 17  5.2   7.9AB   3*
+ 361 86Zet PscBD+06  174   73441097391033     996A          010830.3+070248011343.9+073431132.56-54.88 5.24  +0.32 +0.09         A7IV               +0.144-0.056 +.026+009SB    262  0.1   0.1 O   5*
+ 362 86Zet PscBD+06  175   7345109740         996B   442    010831.7+070258011345.3+073442132.57-54.87 6.30  +0.49 +0.01         F7V                +0.147-0.052 +.026+011SBO =< 25  0.1   0.1 O   5*
+ 363          BD+27  196   7351 74576    I           444    010835.0+280004011405.0+283147128.94-34.08 6.43  +1.70 +1.87 +0.98E  S3+/2-             +0.079-0.049      +002SB                        *
+ 364 87    PscBD+15  177   7374 923262083            445    010848.8+153615011407.6+160801130.84-46.39 5.98  -0.08 -0.41         B8III              -0.027-0.026      -016V      28                 *
+ 365          BD+70   90   7389  4358                       010900.3+711253011612.1+714438124.89  8.97 7.83  +0.78 +0.35         K1V                +0.006+0.004      -017                          *
+ 366 37    CetBD-08  216   7439129193        1003A   446    010921.7-082737011424.0-075523139.80-70.04 5.13  +0.46 -0.05         F5V                +0.127+0.273 +.056+022V      12  2.7  49.8      *
+ 367 88    PscBD+06  181   7446109753                       010930.2+062759011442.4+065943133.14-55.41 6.03  +1.08 +1.02        gG6                 -0.011-0.024      -009V                          
+ 368 38    CetBD-01  162   74761291962084  W                010942.8-013032011449.2-005826136.01-63.25 5.70  +0.42 -0.02         F5V                -0.012+0.201 +.028+026V   =< 10  6.3 114.1AB   3*
+ 369          BD+47  357   7546 370672085                   011030.5+473314011624.5+480456127.24-14.58 6.61  -0.05 -0.34         B9IIIpSi           +0.010+0.001      -014V?                         
+ 370   Nu  PheCD-46  346   7570215428                       011040.4-460356011511.1-453153290.10-71.00 4.96  +0.58 +0.11 +0.36   F8V                +0.669+0.183 +.069+012                          *
+ 371          BD+32  223   7578 54567    I:                 011044.1+323514011618.8+330653128.91-29.47 6.02  +1.15               K1III              +0.016-0.033      +006                          *
+ 372          BD+44  271   7647 37077    I                  011115.6+442231011705.1+445407127.70-17.73 6.34R                     K5                 +0.014-0.045      -052                           
+ 373 39    CetBD-03  172   7672129204      W       AY Cet   011131.6-030136011636.3-023001137.75-64.64 5.41  +0.90 +0.44         G5IIIe+dA          -0.104-0.063 +.015-020V          5.7 177.6      *
+ 374          BD+30  196   7724 54580                       011150.9+311301011724.1+314441129.36-30.80 6.73R                     K0                 -0.052+0.003      -034                           
+ 375          BD+76   40   7732  4376                       011159.1+770231012019.5+773414124.54 14.79 6.31  +0.92               G5III              -0.018+0.086      -074                           
+ 376          BD+46  319   7758 37096                       011216.2+465334011810.2+472511127.61-15.21 6.25  +1.35               K0                 +0.018-0.002      -001                           
+ 377   Kap TucCP-69   45   7788248346      W     A   454    011222.7-692426011546.1-685234299.66-48.10 4.86  +0.47 +0.03 +0.22   F6IV               +0.399+0.107 +.061+009      111  2.2   5.2AB   4*
+ 378 89    PscBD+02  185   78041097931034                   011238.4+030517011748.0+033652135.63-58.61 5.16  +0.07 +0.08 +0.03   A3V                -0.046-0.025 +.013+005SB    121                 *
+ 379          BD+36  220   7853 54592        1055           011306.8+365136011847.0+372310128.93-25.17 6.46  +0.23 +0.14 +0.11   A5m                -0.011-0.014D+.008+005SB     35  3.1   6.2       
+ 380          CP-67   81   7916248350      W                011335.5-665531011703.6-662353298.90-50.53 6.24  +0.05 -0.02         A0V                +0.044+0.002D+.010+013           2.4   2.4       
+ 381          BD+75   59   7925  43872087                   011351.5+754253012159.1+761420124.79 13.48 6.38  +0.28 +0.07         F0IVn              +0.063-0.032      -016                           
+ 382 34Phi CasBD+57  260   7927 22191    I   1073           011347.2+574221012004.9+581354126.71-04.43 4.98  +0.68 +0.49 +0.56   F0Ia                0.000-0.002 -.003-024SB     27  1.9 133.8AC   5*
+ 383 90Ups PscBD+26  220   7964 74637  45                   011358.0+264419011928.0+271551130.56-35.19 4.76  +0.03 +0.10 +0.05   A3V                +0.025-0.013 +.019+008SB     93                  
+ 384 35    CasBD+63  176   8003 11712        1088    474    011424.1+640802012105.2+643930126.10  1.97 6.34  +0.09               A2Vnn              +0.057-0.019      -015V     240  2.1  55.5       
+ 385 42    CetBD-01  171   8036129235        1081           011441.5-010202011948.3-003032138.45-62.52 5.87  +0.64 +0.32         G8III+A7V          +0.012-0.014D+.009+014SB         0.7   1.6AxBC 3*
+ 386          BD+77   49   8065  4391                       011457.4+781208012346.8+784333124.57 15.96 6.07  +0.39 -0.08         A0Iab              -0.009-0.003      -075                           
+ 387          BD-04  185   8120129239                       011529.9-034619012034.5-031449140.45-65.12 6.23  +1.02 +0.84         K1III              -0.013+0.006      -003                           
+ 388          BD-11  248   81211477462088                   011529.8-114543012027.8-111420147.57-72.71 6.15  +1.11 +1.03         K1III              -0.047-0.074      -011V?                         
+ 389 91    PscBD+27  215   8126 746472089I                  011535.4+281257012107.4+284417130.75-33.68 5.23  +1.39              gK5                 +0.027-0.078      -036V?                         
+ 390 46Xi  AndBD+44  287   8207 371551035I                  011626.9+450017012220.4+453144128.58-17.00 4.88  +1.08 +0.99 +0.53   K0-IIIb            +0.032+0.009 +.026-013SB   < 17                 *
+ 391          BD+57  274   8272 22230        1105           011659.5+573721012321.6+580835127.14-04.47 6.45                      F4V                +0.139-0.094D+.005+007           0.2   0.5AB   4*
+ 392          BD+00  223   83341098342091I                  011728.0+011216012237.0+014335138.75-60.18 6.20  +1.52 +1.86 +0.63E  K5IIIab            +0.066-0.048      -016V                          
+ 393 43    CetBD-01  179   8335129262                487    011727.8-005821012234.8-002659139.87-62.29 6.49  +1.08 +1.01        gK0                 +0.023-0.014      +014                           
+ 394          BD-19  229   8350147767        1106           011739.5-193609012230.5-190453166.13-79.24 6.35  +0.48               F6IV               -0.056-0.071D+.008-005V?     19  2.2   5.0      *
+ 395 47    AndBD+36  237   8374 546552093                   011757.2+371135012340.6+374254129.94-24.72 5.58  +0.26 +0.13 +0.12   A2Vm               +0.083-0.022      +013SB2O   15                 *
+ 396          BD+33  220   8375 54654                       011757.1+334312012337.5+341445130.47-28.16 6.29  +0.83 +0.48         G8IV               +0.229+0.116      +003V                          
+ 397          BD+19  226   8388 74682    I                  011800.6+195648012324.9+202808132.99-41.78 5.97  +1.71               K5                 -0.009-0.007      -011                           
+ 398          BD+70  102   8424  4401                       011824.9+702732012546.5+705848125.75  8.30 6.49R                     A0Vnn              +0.016-0.013      +011      195                  
+ 399 36Psi CasBD+67  123   8491 11751  46I   1129           011851.7+673629012556.0+680748126.15  5.47 4.74  +1.05 +0.94 +0.52   K0III              +0.074+0.026 +.013-012V    < 17  5.2  23.2AC   4*
+ 400          CD-31  562   84981930901036I                  011851.7-312800012331.0-305644243.40-82.02 5.84  +1.61 +2.05 +0.80E  K5III              -0.012-0.046      -016                          *
+ 401 44    CetBD-08  243   8511129275      W       AV Cet   011900.7-083139012402.5-080027146.42-69.38 6.21  +0.23 +0.09         F0V                +0.174-0.070      +006      157  4.7  84.6      *
+ 402 45The CetBD-08  244   8512129274  47I   1118           011901.5-084158012401.4-081100146.59-69.54 3.60  +1.06 +0.93 +0.56   K0III-IIIb         -0.079-0.218 +.041+017V?   < 17 11.0  65.4      *
+ 403 37Del CasBD+59  248   8538 22268  48I W       Del Cas  011916.1+594256012549.0+601407127.19-02.35 2.68  +0.13 +0.12 +0.09   A5III-IV          v+0.297-0.051 +.037+007SB    113  8.7 131.7      *
+ 404          BD-07  223   8556129277        1123           011918.8-072611012420.6-065453145.55-68.33 5.91  +0.41 -0.05         F3V                +0.042+0.003D+.023+032SBO        0.2   0.2      *
+ 405          BD-16  237   8589147793                       011945.7-161053012439.8-153937158.54-76.18 6.14  +0.91 +0.54         G5                 +0.012-0.005      +013V                         *
+ 406          BD-03  195   85991292801037                   011943.8-032209012448.7-025055142.56-64.44 6.15  +0.96 +0.71         G8III              +0.013-0.030      -027                           
+ 407          BD+22  226   8634 747072096                   012007.7+225928012535.7+233042132.98-38.69 6.18  +0.43  0.00         F5III              +0.032-0.021      -016SBO    34                 *
+ 408          CD-42  493   86512154922095                   012015.2-420046012440.8-412933279.66-74.10 5.42  +1.04 +0.86 +0.49   K0III              +0.022-0.038 -.012+074                           
+ 409          BD+42  302   8671 37204                       012025.6+425620012618.6+432728129.61-18.96 5.96  +0.49 +0.01         F7V                +0.103-0.060      +031    =<  6                  
+ 410          BD+33  228   8673 54695                       012027.1+340342012608.7+343447131.00-27.75 6.31  +0.47 +0.01         F7V                +0.230-0.087      +017       32                 *
+ 411          CD-45  463   8681215494                       012021.3-450257012441.9-443142284.11-71.36 6.26  +1.14 +1.08 +0.52   K1II               -0.009-0.018      -010V                          
+ 412 46    CetBD-15  266   8705147803    I                  012042.1-150708012537.2-143556157.07-75.16 4.90  +1.23 +1.26         K2.5IIIb           +0.039-0.018 +.007-023V    < 17                  
+ 413 93Rho PscBD+18  187   8723 92436                506    012051.7+183907012615.3+191020134.19-42.94 5.38  +0.39 -0.10         F2V:              v-0.024+0.010 +.038-009V      61                  
+ 414 94    PscBD+18  189   8763 924441039                   012117.4+184320012641.7+191425134.31-42.85 5.50  +1.11 +1.05         K1III              +0.050-0.061 +.013-042V                         *
+ 415          BD+33  234   8774 54705                       012125.1+335129012706.2+342239131.25-27.92 6.27  +0.46 +0.02         F7IVb vs           +0.154-0.011      +015       23                 *
+ 416          BD-01  189   8779129300                       012120.2-005507012627.3-002355141.83-61.98 6.41  +1.24 +1.27         K0IV               +0.044-0.001 +.023-006V                          
+ 417 48Ome AndBD+44  307   8799 372281040    1152           012140.1+445326012739.4+452424129.56-17.00 4.83  +0.42  0.00 +0.23   F5IV               +0.351-0.107 +.030+011       69  6.6 119.0AC   4*
+ 418          BD+40  289   8801 37227        1151           012137.5+403452012726.6+410602130.20-21.26 6.46  +0.27 +0.03 +0.16   A7m                +0.003-0.001      +001       70  5.9  15.3      *
+ 419          BD+02  211   8803109895        1148           012143.4+030059012653.5+033207139.88-58.16 6.58  -0.04 -0.19         B9V+A8V            +0.004-0.035 -.016+015V     210  2.5   6.0      *
+ 420          CP-65  130   88102483811038                   012137.8-645322012505.3-642210296.98-52.37 5.93  +1.56 +1.92         K5III              +0.023-0.019      +023                           
+ 421 47    CetBD-13  262   88291478121041            512    012155.5-133435012651.6-130324155.16-73.67 5.66  +0.35 +0.02         F0IIIDel Del       +0.016+0.009      +010                           
+ 422          BD+39  334   8837 37234                       012158.8+394901012747.0+402008130.39-22.01 6.60  -0.04 -0.17         A0III              +0.015-0.019      -001V?    135                 *
+ 423          CD-33  525   8879193122    I W       R Scl    012221.9-330342012658.1-323235250.18-80.59 5.79  +3.86 +7.4  +1.38   C6II               -0.011-0.031      -008          11.9  10.0      *
+ 424  1Alp UMiBD+88    8   8890   308 907    1477  Alp UMi  012233.7+884626023148.7+891551123.28 26.46 2.02  +0.60 +0.38 +0.31   F7:Ib-II          v+0.038-0.015 +.007-017SBO    17  6.8  18.4AB   5*
+ 425          BD-11  272   8921147819        1162           012247.5-112515012746.6-105406152.44-71.66 6.13  +1.32 +1.36         K4III-IV           +0.180+0.019      +004           3.7   1.5       
+ 426          BD+07  213   8949109907      W         519    012308.2+072636012822.9+075741138.54-53.79 6.20  +1.12 +1.08         K1III              +0.112-0.003      +002           2.1  69.0      *
+ 427 38    CasBD+69  102   9021  44221042                   012346.8+694500013113.8+701553126.30  7.65 5.81  +0.47 -0.11         F6V                +0.137-0.077 +.039+005SBO                       *
+ 428          BD+65  175   9030 11788                       012352.7+653454013052.3+660553126.92  3.53 6.14  +0.08 +0.05         A2V s              +0.084-0.010 -.001+009SB     75                 *
+ 429   Gam PheCD-43  449   9053215516  49I:        Gam Phe  012401.4-434950012821.9-431906280.52-72.17 3.41  +1.57 +1.85 +0.98   M0-IIIa            -0.014-0.209 +.000+026SB1O                      *
+ 430 49    AndBD+46  370   9057 37275    I                  012406.0+462929013006.2+470026129.75-15.35 5.27  +1.00 +0.82         K0III              +0.008-0.044 +.015-011     < 19:                 
+ 431          CD-34  576   9065193136              WZ Scl   012409.6-341651012843.3-334549254.77-79.59 6.58  +0.30 +0.07         F0IV               -0.055-0.025      -005                          *
+ 432 97    PscBD+17  210   9100 92463              VX Psc   012428.8+175019012952.9+182120135.56-43.57 6.02  +0.14 +0.14         A4IV               +0.063-0.003      +004      108                 *
+ 433 48    CetBD-22  254   91321670861043    1184           012448.3-220848012936.1-213746182.65-79.72 5.12  +0.02 +0.04         A1V                +0.056+0.006 +.028+001V          7.5  22.0       
+ 434 98Mu  PscBD+05  194   91381099262099I W                012456.6+053742013011.1+060838140.07-55.43 4.84  +1.37 +1.54 +0.74   K4III              +0.294-0.048 +.018+034V    < 17  5.6 182.5AB   3*
+ 435          CD-47  440   9184215525              AW Phe   012516.5-471625012930.4-464523284.52-68.99 6.31  +1.66 +1.87 +1.39   M2III              -0.012+0.013      +018                          *
+ 436          CD-26  502   9228167093    I   1193           012540.1-264327013022.9-261228209.10-81.25 5.93  +1.34 +1.41         K4III              +0.045+0.002      -001           5.0   2.9      *
+ 437 99Eta PscBD+14  231   9270 92484  50I   1199    532    012607.8+144949013129.0+152045137.01-46.43 3.62  +0.97 +0.75 +0.50   G7IIIa             +0.028-0.006 +.015+015V    < 19: 3.6   0.8      *
+ 438          BD+34  265   9298 547622100                   012625.3+341706013207.6+344800132.33-27.33 6.39  -0.12 -0.42         B7IIIpHgMn         -0.008-0.002      -001       60                  
+ 439          BD+57  320   9352 22389    I S                012656.0+574848013325.8+581939128.44-04.09 5.70  +1.52 +1.15         K0Ib+B9V           +0.011+0.002      -001    =< 50                 *
+ 440   Del PheCD-49  425   93622155361044                   012705.3-493532013115.1-490422286.27-66.75 3.95  +0.99 +0.70 +0.51   K0III              +0.142+0.151 +.031-007                           
+ 441          CD-30  506   9377193163                       012705.8-304747013143.3-301700234.96-80.63 5.82  +1.08               K0III              +0.009-0.067      +003V?                         
+ 442 39Chi CasBD+58  260   9408 22397    I                  012723.4+584308013355.9+591355128.35-03.19 4.71  +1.00 +0.76 +0.53   G9IIIb             -0.037-0.021 +.021+006     < 19:                 
+ 443          CD-46  420   9414215539      I                012724.1-460526013139.1-453432282.11-69.89 6.17  +0.06 +0.09 +0.03   A2V                 0.000+0.006      +008           4.2   1.4      *
+ 444          BD-09  298   9484129363              Var      012804.3-093144013303.5-090053153.38-69.39 6.59  -0.04 -0.10         A0III              +0.029+0.003      +010V?                        *
+ 445          CD-37  589   95251931732101                   012827.6-372243013256.0-365155263.48-76.89 5.51  +1.02               K0III              +0.002-0.023 +.007+013V?                         
+ 446          BD+36  277   9531 54788              KK And   012830.0+364328013416.6+371414132.32-24.85 5.88  -0.07 -0.30         B9IV               +0.009-0.015 +.018-004V     175                 *
+ 447          CD-50  411   9544215547                       012830.5-501422013236.3-494340286.40-66.06 6.28  +0.46               F4V                -0.030-0.077      +002                           
+ 448          BD-07  256   9562129371                       012840.9-073211013342.9-070131151.37-67.53 5.76  +0.64 +0.21         G2IV               +0.180-0.081      -015V?  =< 10                  
+ 449          BD+73   81   9612  4448                       012909.4+734723013722.5+741803126.09 11.71 6.58  +0.03 -0.16         B9Ve               +0.027-0.009      -008V?                         
+ 450          BD+17  224   9640 92520    I                  012924.3+175700013449.1+182738137.11-43.21 5.89  +1.52 +1.80         M2IIIab            +0.033-0.069      -026                           
+ 451 49    CetBD-16  265   9672147886                       012944.6-161119013437.8-154034166.32-74.78 5.63  +0.07 +0.05         A3V                +0.096+0.003      +009V?                         
+ 452          BD+40  328   9712 37344                       012958.4+403353013552.5+410435131.88-21.02 6.38  +1.11 +1.00         K1III              +0.139-0.002      +065                           
+ 453          CD-32  613   9742193188                       013016.9-322412013450.7-315332242.30-79.43 6.12  +1.11               K0-1III            -0.077-0.036      -011                           
+ 454          BD+47  460   9746 37351              OP And   013020.2+481243013627.2+484322130.54-13.48 5.92  +1.21              gK1                 -0.012-0.017      -043V                         *
+ 455101    PscBD+13  240   9766 92530                559    013025.5+140901013546.4+143941138.71-46.85 6.22  -0.04 -0.21         B9.5III            +0.004-0.011      -016V     220                  
+ 456 40    CasBD+72   86   9774  4453  51    1268    567    013030.9+723149013830.9+730224126.40 10.49 5.28  +0.96 +0.72         G8III              -0.013-0.015 +.017-005V    < 19: 6.4  53.3       
+ 457          BD+16  176   9780 92531                       013030.0+165519013554.8+172601137.79-44.15 5.80R                     F0IV               +0.152+0.010      +003SB     97                  
+ 458 50Ups AndBD+40  332   9826 373621045I W                013055.5+405419013647.8+412420132.00-20.66 4.09  +0.54 +0.06 +0.29   F8V                -0.171-0.382 +.062-028SBO     8  8.4 114.0AB   3*
+ 459 50    CetBD-16  270   98561479012104I                  013106.3-155442013559.0-152401166.61-74.36 5.42  +1.21 +1.20         K2IIIaBa0.2CN1     +0.023+0.011      +024V    < 19:                 
+ 460          CP-58  123   9896232470                561    013130.3-583900013515.2-580822292.01-58.05 6.01  +0.38               F2V                +0.277-0.035 +.011+001?                         *
+ 461          BD+57  349   9900 224562108I                  013135.0+572805013807.6+575839129.11-04.33 5.56  +1.38 +1.43 +0.71   G5II               +0.007-0.006      -008V?                        *
+ 462   Tau SclCD-30  540   9906193201      W                013131.2-302510013608.4-295427231.37-79.80 5.69  +0.33               F2V                +0.100+0.040D+.025+005       63  1.1   0.9      *
+ 463102Pi  PscBD+11  205   9919 925361046                   013147.7+113749013705.9+120830140.16-49.20 5.57  +0.35 -0.02 +0.21   F0V                -0.066+0.043      -001V      96                  
+ 464 51    AndBD+47  467   9927 37375  52I                  013151.0+480718013759.6+483742130.81-13.53 3.57  +1.28 +1.45 +0.65   K3-III             +0.065-0.113 +.021+016V    < 17                 *
+ 465          BD+44  341   9996 37393              GY And   013230.2+445326013831.7+452400131.53-16.68 6.36  +0.04 -0.10         B9pCrEu           v-0.034+0.014      +003SB1O   19                 *
+ 466          BD-10  343  100091294122109  W                013237.7-095458013737.7-092414156.70-69.19 6.24  +0.53  0.00         F7V                +0.259+0.093 +.024+048V?         0.4   0.2      *
+ 467          CP-79   40  10042255794  53  W                013259.1-790045013339.2-783017300.26-38.41 6.11  +0.97 +0.70         K0III              -0.034-0.136      -001           7.4  50.1      *
+ 468          CP-58  126  10052232477                       013304.9-584651013644.8-581615291.74-57.86 6.18  +1.61 +1.89         M3III              +0.022+0.003      -002                           
+ 469 52Chi AndBD+43  343  10072 374062112I                  013320.9+435239013921.0+442310131.89-17.65 4.98  +0.89 +0.55         G8III              -0.022+0.012 +.009+007SB   < 17                  
+ 470          BD+53  363  10110 22493    I                  013351.4+532139014013.1+535206130.16-08.32 6.39  +1.61 +1.98         K5III              -0.011-0.002      -062                           
+ 471          CD-37  620  10142193224                       013400.9-370200013827.4-363142259.18-76.31 5.94  +1.05 +0.90 +0.37E  K0IV               -0.018-0.128      +030                          *
+ 472   Alp EriCP-57  334  10144232481  54          Var      013359.4-574441013742.9-571412290.84-58.79 0.46  -0.16 -0.66 -0.11   B3Vpe             v+0.095-0.035 +.026+016V     251                 *
+ 473          BD-22  272  101481671982113                   013405.0-214705013851.8-211631187.04-77.72 5.58  +0.34               A4n                +0.131+0.036      +014V                          
+ 474          CD-25  670  10161167199        1298           013408.4-253150013850.0-250119204.39-79.16 6.70  -0.08 -0.17         B9Vn               +0.001+0.011      +015V          6.2  20.3       
+ 475105    PscBD+15  245  10164 92558                       013416.9+155355013940.8+162421139.37-44.92 5.97  +1.12               K2III              +0.077-0.015      +017V                          
+ 476          BD+42  345  10204 37419                       013439.7+424730014039.8+431752132.35-18.67 5.61  +0.21 +0.14       sgA9                 +0.127-0.037      +017V      82                 *
+ 477 53Tau AndBD+39  378  10205 37418        1311    584    013440.4+400414014034.8+403437132.92-21.34 4.94  -0.09 -0.41 -0.07   B8III              +0.013-0.025      -014SB     91  5.9  52.3      *
+ 478 43    CasBD+67  149  10221 11919  55          V557 Cas 013455.6+673214014220.5+680235127.68  5.64 5.59  -0.07 -0.23         A0pSiSr            +0.052-0.009      +005       28                 *
+ 479          CP-54  358  10241232483      W                013455.7-535644013848.2-532620287.70-62.27 6.84  +0.44 +0.11         F5IV-V             -0.027-0.046      -003           1.3  10.4      *
+ 480 42    CasBD+69  114  10250  4470                590    013510.0+700702014255.9+703721127.21  8.18 5.18  -0.04               B9V                +0.077-0.013 +.004+006SB    117                 *
+ 481          BD+60  308  10260 11920                       013515.7+603157014203.0+610218129.02-01.23 6.71  -0.03 -0.41         B8IIIpSi           +0.015-0.007      -013V                         *
+ 482          BD+57  370  10293 22520        1334           013539.3+580720014217.8+583740129.52-03.59 6.37  -0.02 -0.45         B8III              +0.019-0.010      -004V?     35  2.4  20.1AB   3*
+ 483          BD+41  328  10307 37434      A                013541.6+420642014147.2+423649132.70-19.30 4.95  +0.62 +0.12 +0.33   G1.5V              +0.809-0.154 +.081+004V?      2        0.1      *
+ 484          BD+25  276  10308 748702115    1326           013543.5+251427014118.4+254445136.80-35.78 6.17  +0.44  0.00         F2III              +0.118-0.040 +.023+005SB2O   12  4.4  10.6AB   3*
+ 485          BD+29  286  10348 74872                       013559.9+293230014139.2+300250135.69-31.58 5.99  +1.01 +0.84 +0.46   K0III              -0.015-0.006      +005                          *
+ 486          CP-56  329  10360232492      W     B          013559.9-564215013947.4-561153289.60-59.66 5.87  +0.90 +0.59         K0V                +0.310-0.020 +.152+023SB         0.1  10.8      *
+ 487          CP-56  329  10361232490      W     A          013600.5-564208013947.8-561141289.60-59.66 5.76  +0.87 +0.53 +0.48   K5V                +0.279+0.020 +.152+020           0.1  10.8      *
+ 488          BD+60  312  10362 11931                       013608.7+605459014258.4+612518129.06-00.84 6.34  +0.01 -0.45         B7II               +0.004+0.011      -005                          *
+ 489106Nu  PscBD+04  293  10380110065  56I                  013613.5+045854014125.9+052915145.12-55.22 4.44  +1.36 +1.57 +0.71   K3IIIbBa0.1        -0.021+0.002 +.041+000     < 19:                 
+ 490          BD+34  297  10390 549121047                   013616.5+344427014203.5+351444134.46-26.49 5.64  -0.07 -0.20         B9IV-V             +0.049-0.028      -002V      70                  
+ 491 44    CasBD+59  307  10425 11941        1344           013633.2+600249014319.7+603304129.27-01.68 5.78  -0.02 -0.32         B8IIIn             +0.008-0.020      -033SB    130: 5.1  66.0AC   4*
+ 492          BD-12  315  10453147962        1339           013648.6-114907014144.7-111929162.14-70.26 5.75  +0.44 -0.01         F5V+F7V            +0.043-0.412 +.035-010V          1.1   1.8      *
+ 493107    PscBD+19  279  10476 74883      W         600    013703.9+194657014229.8+201607138.88-41.01 5.24  +0.84 +0.49 +0.43   K1V                -0.296-0.672 +.119-034V?   < 19: 6.4  19.0AB   3 
+ 494          CD-38  584  10481193255                       013703.9-383824014127.3-380759262.44-74.80 6.17  +0.42 +0.04         F2V                +0.050+0.052      +011                           
+ 495          BD+44  354  10486 37460                       013711.0+444905014316.5+451920132.40-16.59 6.34  +1.01 +0.92 +0.48   K2IV               +0.146-0.017      +012                          *
+ 496   Phi PerBD+49  444  10516 22554  57I         Phi Per  013723.3+501106014339.6+504119131.32-11.33 4.07  -0.04 -0.93 +0.02   B2Vep              +0.026-0.014 +.025+001SB2O  450                 *
+ 497   Pi  SclCD-32  666  105371932631048I                  013737.8-324952014208.6-321937241.27-77.84 5.25  +1.05 +0.79 +0.54   K0III              -0.065-0.025 -.005+010V?                        *
+ 498          CD-37  650  10538193261  58                   013738.5-372012014203.0-364957258.27-75.56 5.72  -0.01       -0.01   A1V                -0.028-0.021      +017V                          
+ 499          BD+56  330  10543 22566        1359           013741.3+570202014417.9+573211130.00-04.61 6.21  +0.10 +0.03         A3V                +0.039-0.040 -.003+005       70  1.4   1.2      *
+ 500          BD-04  260  105501294651049I                  013740.1-041138014243.5-034125152.75-63.55 4.99  +1.38 +1.58         K3II-III           -0.007-0.032 +.009-034     < 19:                 
+ 501          CD-50  461  10553232497                       013741.8-503236014141.1-500220283.51-65.15 6.64  +0.12 +0.12 +0.07C  A3V                -0.023-0.020      -007V?                         
+ 502          BD+56  334  10587 22578                       013810.9+563510014446.1+570521130.16-05.03 6.25  +0.04 +0.06         A2V                +0.014-0.004      +005      170                  
+ 503          BD+31  301  10588 54939              Var?     013807.2+314118014350.0+321130135.65-29.38 6.34R                     G8III-IV           -0.022-0.007      -005SBO                       *
+ 504          BD+45  432  10597 37475    I                  013820.2+453815014426.5+460823132.43-15.75 6.35R                     K5III              -0.009-0.028      -019                           
+ 505          CP-61  130  106152484212116                   013822.5-611734014148.0-604722292.17-55.27 5.71  +1.27               K2-3III            +0.015-0.041      +002                           
+ 506          CP-54  365  10647232501                       013838.1-541432014229.3-534426286.90-61.77 5.52  +0.53  0.00         F9V                +0.171-0.093      +013                           
+ 507          BD-05  309  10658129477    I                  013852.6-051604014354.8-044556154.47-64.37 6.19  +1.54 +1.90         K0                 -0.020-0.032      +020                           
+ 508109    PscBD+19  282  10697 92611    I                  013928.0+193501014455.8+200459139.67-41.04 6.27  +0.75 +0.23         G3Va               -0.041-0.109 +.027-044V?                         
+ 509 52Tau CetBD-16  295  10700147986  59I W                013925.3-162751014404.1-155615173.19-73.43 3.50  +0.72 +0.21 +0.47   G8V                -1.718+0.856 +.275-016V       2  9.5  89.8       
+ 510110Omi PscBD+08  273  10761110110  60I           615    014006.7+083916014523.6+090928144.61-51.43 4.26  +0.96 +0.71 +0.48   G8III              +0.073+0.048 +.023+014     < 17                 *
+ 511          BD+63  238  10780 11983      W                014030.5+632132014744.8+635108129.08  1.66 5.63  +0.81 +0.40 +0.39   K0V                +0.582-0.255 +.107+003V?         3.1  91.1      *
+ 512          CP-83   27  10800258271    I'                 014033.8-832902013755.6-825830301.23-34.00 5.87  +0.61 +0.10         G2V                +0.119+0.120      -005V                          
+ 513          BD-06  336  108241294902117I                  014058.0-061401014559.3-054400156.61-64.97 5.34  +1.52 +1.88         K4III              -0.007-0.033      +011V?                         
+ 514   Eps SclCD-25  704  10830167275  61    1394           014057.7-253308014538.8-250309206.28-77.66 5.31  +0.39 +0.02         F1V                +0.162-0.057 +.037+015V      86  3.2   4.9AB   4*
+ 515          BD+16  196  10845 92622              VY Psc   014109.5+165443014635.3+172447141.20-43.49 6.55  +0.25 +0.17         A9III              +0.053+0.011      -001SB     67                 *
+ 516   Tau1HyiCP-79   44  10859255806      W                014117.5-793908014121.3-790854299.99-37.69 6.33  +0.94 +0.69         G6-8III            +0.052+0.009      +002           6.0  16.0      *
+ 517          CD-27  595  10863167279                       014123.5-275054014601.0-272057217.10-77.87 6.39  +0.36               F2Vn               +0.095-0.052      +006V                          
+ 518          BD+45  447  10874 375132119                   014139.5+454354014748.0+461347133.00-15.54 6.32  +0.43  0.00         F6V                +0.014-0.056      -003       27                  
+ 519          CD-51  419  10934232519    I'                 014210.7-511858014605.8-504859282.92-64.14 5.49  +1.60 +1.95 +1.27   M3III              +0.034-0.024 -.023-002                           
+ 520          CP-54  377  109392325202118                   014217.5-540126014606.3-533119285.68-61.74 5.04  +0.04 +0.05         A1V                +0.127+0.056 +.023+010       56                  
+ 521          BD+37  372  10975 54991                       014244.6+372718014838.9+375710135.20-23.55 5.94  +0.97 +0.71         K0III              +0.112-0.029      +037V?                         
+ 522  4    AriBD+16  203  10982 926371050                   014245.3+162727014810.9+165720141.89-43.82 5.84  -0.03 -0.12         B9.5V              +0.053-0.036      +010SB     22                  
+ 523          BD+31  316  11007 549942120                   014257.7+321101014841.6+324125136.65-28.66 5.79  +0.55 -0.01         F8V                -0.167+0.298 +.038-027V   =<  6                  
+ 524          CD-42  633  11022215650                       014302.5-421538014716.8-414536268.52-71.43 6.18  +1.54 +1.91         K5-M0III           +0.024+0.042      -013                           
+ 525          CP-85   17  11025258273 916                   014308.3-851629013728.0-844611301.70-32.25 5.69  +0.94 +0.66         G8III              +0.034+0.021      +018                           
+ 526          BD+47  508  11031 37536        1438           014302.9+472356014915.7+475349132.86-13.86 5.82  +0.29 +0.07         A3V                -0.010-0.002D+.008-002SB2        0.7   1.9AB   4*
+ 527          BD+02  270  110371101382121                   014315.1+031111014826.0+034108149.17-56.25 5.91  +0.97 +0.74         G9III              -0.006+0.017      +003V?                         
+ 528          CD-37  687  11050193303                       014325.8-373932014747.8-370935256.59-74.45 6.32  +1.02               K0III              +0.008+0.011      +015                           
+ 529          BD+51  416  11151 22678                       014432.7+512625015057.1+515600132.18-09.87 5.90  +0.43 +0.02         F5IV               +0.041-0.120      -017       40                  
+ 530  1    AriBD+21  243  11154 74966        1457           014436.9+214644015008.5+221631140.39-38.60 5.86  +0.74 +0.50 +0.49   K1III+A6V          -0.017-0.008 +.017+003SB         1.1   2.8      *
+ 531 53Chi CetBD-11  352  111711480361051  W                014440.3-111052014935.1-104111165.48-68.61 4.67  +0.33 +0.03 +0.16   F3III              -0.146-0.093 +.046-001       61  2.1 184.0      *
+ 532          CD-31  753  11183193320                       014448.0-313410014919.5-310422233.70-76.77 6.34  +1.22               K2-3III            +0.101-0.026      +020                           
+ 533  1    PerBD+54  396  11241 226902122          V436 Per 014525.0+543908015159.3+550851131.57-06.70 5.52  -0.18 -0.83         B1.5V              +0.014-0.008      -003SBO   198                 *
+ 534          BD+10  252  11257 92659      D         635    014533.5+103254015052.0+110236145.58-49.20 5.94  +0.30 -0.03 +0.17   F2V w              -0.070-0.027      +011V          0.0   0.1      *
+ 535          CD-39  553  11262193326      W                014529.9-385425014948.8-382414259.30-73.37 6.37  +0.52               F8V                -0.003+0.233 +.022+022V?         7.0  28.0       
+ 536  2    PerBD+50  379  11291 226961052                   014547.5+501755015209.4+504734132.64-10.93 5.79  -0.07 -0.30         B9IIIpHgMn         +0.017-0.026      +010SB1O   22                 *
+ 537          CD-48  487  11332215673                       014619.4-481849015020.2-474859277.77-66.33 6.14  +1.01 +0.88 +0.34E  K1IV               +0.124+0.051      +012                          *
+ 538          BD+50  381  11335 22705                       014626.9+505851015250.8+512829132.58-10.24 6.26                      A3V                -0.011-0.009      +006V     135                  
+ 539 55Zet CetBD-11  359  11353148059  62I W         638    014631.4-104945015127.6-102006165.88-68.05 3.73  +1.14 +1.07 +0.55   K0IIIBa0.1         +0.041-0.039 +.031+009SB1O < 19: 6.2 187.0      *
+ 540          BD+54  408  11408 22716                       014710.9+550617015348.5+553553131.72-06.21 6.45  +0.18 +0.11 +0.07   A5m                +0.049+0.001      +008       57                  
+ 541          CD-50  514  114132325422123          BD Phe   014701.6-504204015054.5-501222280.70-64.28 5.94  +0.14               A1Vp               -0.042-0.003      +007                          *
+ 542 45Eps CasBD+62  320  11415 12031  63            652    014711.7+631040015423.7+634012129.84  1.65 3.38  -0.15 -0.60 -0.12   B3III              +0.032-0.021 +.010-008V      19                 *
+ 543 55    AndBD+40  394  11428 375872124I W                014717.3+401411015317.3+404347135.40-20.64 5.40  +1.32 +1.41        gK1                 -0.010-0.006 +.006-007V?         5.3  59.8       
+ 544  2Alp TriBD+28  312  11443 74996  64I W                014722.7+290530015304.9+293444138.64-31.40 3.41  +0.49 +0.06 +0.28   F6IV               +0.011-0.235 +.057-013SB1O   93  8.6 222.3AC   3*
+ 545  5Gam1AriBD+18  243  11503 92680        1507B Var?     014802.4+184821015331.8+191745142.55-41.20 4.83H                     B9V               v+0.078-0.112 +.026+004V     152  0.1   7.8AB   3*
+ 546  5Gam2AriBD+18  243  11502 92681        1507A Gam Ari  014802.4+184813015331.8+191737142.55-41.20 4.75H -0.04 -0.13 -0.05   A1pSi              +0.079-0.104 +.026-001V      63  0.1   7.8AB   3*
+ 547          BD-17  336  115221480782125          BK Cet   014803.6-172517015252.1-165545180.42-72.52 5.80  +0.27 +0.09         F0IIIn             +0.042-0.053      -004                          *
+ 548 46Ome CasBD+67  169  11529 120382129            659    014813.5+681139015600.0+684107128.77  6.55 4.99  -0.10 -0.40         B8III              +0.013-0.011      -024SBO    34                 *
+ 549111Xi  PscBD+02  290  11559110206  65I           654    014822.6+024138015333.3+031115151.64-56.18 4.62  +0.94 +0.72 +0.47   K0III              +0.022+0.023 +.005+030SBO  < 17                 *
+ 550   Tau2HyiCP-80   35  11604258280      W                014842.4-804015014746.5-801036299.96-36.63 6.06  +0.34 +0.04         F0IV               -0.074-0.071      +030           7.4  39.7       
+ 551          BD+39  434  11613 37607                       014852.5+401244015453.8+404207135.72-20.59 6.24  +1.25               K2                 +0.047-0.066      +032SBO                       *
+ 552          BD+36  346  11624 55082    I:                 014902.9+363813015457.5+370742136.75-24.03 6.26  +1.17               K0                 +0.021-0.010      -002                           
+ 553  6Bet AriBD+20  306  11636 75012  66I           658    014906.8+201909015438.4+204829142.24-39.68 2.64  +0.13 +0.10 +0.08   A5V                +0.096-0.111 +.074-002SBO    79                 *
+ 554          CD-39  573  116431933682127                   014904.9-390517015323.2-383541258.35-72.71 6.10  +1.12               K1II               +0.131+0.027      +022                           
+ 555   Psi PheCD-46  552  11695215696  67I         Psi Phe  014938.2-464732015338.8-461809274.35-67.22 4.41  +1.59 +1.70 +1.52   M4III              -0.086-0.087 +.011+002SB                        *
+ 556          BD+36  354  11727 55102    I   1534B          014959.3+364715015554.4+371640136.91-23.84 5.89  +1.63              gM0                 +0.004-0.003      +007V   =< 25  0.2 190.4AB   4*
+ 557 56    AndBD+36  355  11749 55107        1534A          015012.7+364540015609.3+371506136.96-23.85 5.67  +1.06 +0.91         K0III              +0.182+0.006      +059    =< 25  0.2 190.4AB   4*
+ 558   Phi PheCD-43  583  117532156971053                   015013.0-425915015422.0-422949267.17-69.99 5.11  -0.06 -0.15 -0.06   A3V                -0.028-0.032      +012SB     13                 *
+ 559  7    AriBD+22  284  11763 750302130I         RR Ari   015016.3+230514015551.0+233438141.48-36.96 5.74  +1.19 +1.04         K1III              +0.009-0.013      +014                          *
+ 560          BD+01  347  11803110235        1538    667    015043.6+012116015553.8+015059153.67-57.13 6.01  +0.56 +0.04         F7V+G0V            +0.158+0.184 +.025+030SB         0.1   1.5      *
+ 561          BD+60  398  11857 12065                678    015127.5+611236015833.3+614153130.80-00.14 6.02  -0.04 -0.40         B5III              +0.014-0.008      +007V                         *
+ 562          BD+40  407  11905 37653                       015152.2+411223015756.4+414140136.03-19.48 6.78  -0.06 -0.39         B8III              +0.012-0.014      +003V       8                 *
+ 563  8Iot AriBD+17  289  11909 927212132I                  015153.1+171946015721.1+174903144.34-42.30 5.10  +0.92 +0.70         K1p                +0.037-0.018      -005SBO  < 17: 1.0   0.0      *
+ 564          BD+27  310  11928 75048    I                  015202.7+271904015743.8+274816140.40-32.81 5.82  +1.60 +1.89         M2III              +0.026-0.058      -003V                          
+ 565 56    CetCD-23  721  119301674162131I                  015159.2-230054015640.2-223137199.22-74.52 4.85  +1.42 +1.67 +0.56E  K4III              +0.062-0.029 -.012+027                           
+ 566   Chi EriCP-52  241  11937232573  68  W         671    015204.0-520623015557.5-513632280.88-62.67 3.70  +0.85 +0.46 +0.45   G8IIIbCNIV         +0.681+0.292 +.058-006           6.5   4.8      *
+ 567          BD+63  265  11946 12076        1571           015215.1+640806015938.0+643717130.16  2.71 5.26  +0.01 -0.05         A0Vn               +0.033-0.020      +005V     360  5.6  41.5      *
+ 568  3    PerBD+48  576  11949 37665                       015212.0+484256015833.6+491215134.06-12.21 5.69  +1.01               K0IV               +0.010+0.038      -000                           
+ 569  9Lam AriBD+22  288  11973 75051        1563A   680    015221.2+230630015755.7+233546142.04-36.80 4.79  +0.28 +0.09 +0.16   F0V                -0.090-0.013 +.028-001SB     99  2.5  37.4AB   4*
+ 570   Eta2HyiCP-68  101  11977248460  69                   015224.0-680821015456.1-673850293.93-48.35 4.69  +0.95 +0.64 +0.49   G8.5III            +0.074+0.074      -016                          *
+ 571          CP-61  157  11995248464                       015234.6-612107015546.4-605141289.48-54.55 6.06  +0.37 +0.01         F0IV-V             +0.004+0.056      +015                           
+ 572          BD+77   73  12005  4555                       015249.0+772554020257.2+775459126.76 15.58 6.04  +1.14               K0                 -0.004-0.002      -003                           
+ 573          CP-52  242  12042232581                       015311.2-521541015700.1-514558280.76-62.45 6.10  +0.48 -0.04         F6-7V              +0.359+0.248 +.056+004                           
+ 574          CD-47  597  12055215715                       015312.2-475225015710.0-472306274.84-66.00 4.83  +0.88 +0.52 +0.45   G8III              +0.103+0.016 +.021+012                           
+ 575 48    CasBD+70  153  12111  4554        1598    694    015344.0+702520020157.4+705425128.69  8.83 4.54  +0.16 +0.06 +0.08   A3IV               -0.067+0.004 +.035-005SBO    67  1.7   0.5AB   4*
+ 576          CD-33  682  121351934222135  W                015401.9-333311015826.7-330400239.29-74.36 6.35  +1.02               K0III              +0.008-0.020      +001V          6.9   6.1       
+ 577          BD+20  322  12139 75077        1582D          015402.5+203422015935.7+210330143.55-39.07 5.87  +1.03               K0III-IV           +0.139-0.022      -002           3.3 188.1AD   4*
+ 578          BD+11  261  12140 927392136                   015404.5+114835015925.9+121741147.82-47.26 6.09  +0.19 +0.10         A6V                +0.008-0.042      -012V?    129                  
+ 579          BD+73  108  12173  4559        1606           015418.7+732201020310.5+735102127.95 11.68 6.23R                     A5III              -0.029-0.005D+.004-005           3.1   5.5       
+ 580 50    CasBD+71  117  12216  4560  70                   015453.1+715615020326.1+722517128.38 10.31 3.98  -0.01 +0.03  0.00   A2V                -0.045+0.022      -014SB2    84                  
+ 581 47    CasBD+76   63  12230  45622139  W                015505.6+764803020507.4+771653127.06 15.00 5.38  +0.31 +0.05         F0Vn               +0.125-0.056 +.028-026V      95  6.0  95.6       
+ 582112    PscBD+02  311  12235110266                691    015457.0+023708020009.2+030550154.33-55.53 5.88  +0.62 +0.19         G2IV               +0.231-0.251 +.034-017V?  =< 10                  
+ 583 57    CetBD-21  356  12255167466    I                  015503.9-211837015946.1-204928194.60-73.19 5.41  +1.65 +1.98         M1III              +0.008+0.019      -015V                          
+ 584          CP-66  123  12270248472                       015510.2-655439015753.6-652529292.20-50.30 6.37  +0.90 +0.62         G8II-III           -0.010-0.013      +012                           
+ 585 59Ups CetBD-21  358  12274167471  71I                  015517.6-213344020000.3-210440195.47-73.25 4.00  +1.57 +1.91 +1.04   M0III             e+0.135-0.024 +.007+018                          *
+ 586 52    CasBD+64  282  12279 12095                       015525.1+642507020252.7+645405130.42  3.07 6.00  +0.03 +0.02         A1Vn               -0.002-0.015      -025SB    305                  
+ 587          BD-09  380  12292129624    I W       AR Cet   015529.0-090029020026.9-083125167.40-65.25 5.51  +1.52 +1.34         M3III              +0.096-0.010      +006V          4.1  62.2      *
+ 588          CD-42  684  12296215726                       015531.5-423047015938.8-420150264.25-69.60 5.57  +1.06               K1III              -0.054-0.103 +.018+027                           
+ 589 53    CasBD+63  274  12301 12097                       015535.7+635425020300.3+642324130.57  2.59 5.58  +0.38 -0.27 +0.31   B8Ib               +0.005-0.005      -020                           
+ 590  4    PerBD+53  439  12303 228591054                   015538.2+540015020218.1+542915133.19-06.97 5.04  -0.08 -0.32 -0.05   B8III              +0.035-0.002      -002SB     93                  
+ 591   Alp HyiCP-62  162  12311248474  72                   015537.1-620323015846.2-613411289.45-53.76 2.86  +0.28 +0.14 +0.14   F0V                +0.264+0.027 +.048+001V     153                 *
+ 592 49    CasBD+75   86  12339  4565        1625           015557.4+753804020531.2+760654127.44 13.90 5.22  +0.95 +0.75         G8III              -0.022-0.021 +.022+000V    < 17  7.0   5.4AB   3*
+ 593   Sig HyiCP-78   42  123632558352134                   015600.7-785014015550.5-782054298.84-38.26 6.16  +0.44 +0.01         F5-6IV-V           +0.096+0.060      +006                           
+ 594   Pi  ForCD-30  703  12438193455                       015646.8-302856020114.7-300006227.66-74.42 5.35  +0.88 +0.46         G5III              -0.104-0.109 +.017+024                           
+ 595113Alp PscBD+02  317  12446              1615B          015652.3+021651020202.8+024549155.35-55.60 5.23H                     A3m                +0.033-0.005 +.005+009SB?    24  1.0   2.0      *
+ 596113Alp PscBD+02  317  12447110291        1615A   705    015652.3+021651020202.8+024549155.35-55.60 4.33H +0.03 -0.05  0.00   A0pSiSr            +0.033-0.005 +.005+009SB     42  1.0   4.0      *
+ 597          BD+80   64  12467   3443943                   015704.5+804903020925.3+811745125.99 18.89 6.05  +0.11 +0.06         A1V                -0.036+0.006      -013V     130                  
+ 598          BD+64  285  12468 12105                       015708.5+643724020440.1+650612130.54  3.32 6.52   0.00 -0.05         A0V                +0.051-0.032      -004V     130                  
+ 599  3Eps TriBD+32  369  12471 55218        1621    707    015707.2+324808020258.0+331702139.71-27.25 5.50  +0.03 +0.06 +0.03   A2V                -0.016-0.013 +.010+003SB?    92  6.0   4.2      *
+ 600          CP-66  125  124772484762137                   015703.6-663304015941.1-660359292.34-49.64 6.10  +1.17 +1.21         K1III              +0.032+0.006      +005                           
+ 601          BD+12  271  12479 92763    I                  015712.0+125940020235.2+132836148.19-45.88 5.94  +1.59 +1.83         M2III              +0.016-0.010      -007                          *
+ 602   Chi PheCD-45  659  125242157392138                   015741.8-451142020142.4-444249268.87-67.48 5.14  +1.49 +1.82 +0.89   K5III              -0.028-0.053 -.019-031                           
+ 603 57Gam1AndBD+41  395  12533 37734  73I   1630A          015745.4+415100020354.0+421947136.96-18.56 2.26  +1.37 +1.58 +0.68   K3-IIb             +0.045-0.052 +.013-012SB   < 17  2.8   9.6AxBC 4*
+ 604 57Gam2AndBD+41  395  12534 37735        1630BC         015746.3+415104020354.7+421951136.97-18.56 4.84  +0.03 -0.12         B8V+A0V            +0.037-0.055 +.013-014SB2O   70  2.8   9.6AxBC 4*
+ 605 10    AriBD+25  341  12558 75114        1631           015758.6+252714020339.3+255608142.61-34.16 5.63  +0.54 +0.02         F8IV               +0.134+0.022 +.025+016V          1.5   0.8AB   3*
+ 606          CD-30  714  12563167511                       015759.5-300852020228.1-293954226.33-74.19 6.42  +0.14 +0.19 +0.04   A3III              -0.033+0.027      +012        0                  
+ 607 60    CetBD-00  307  125731296552142                   015803.9-002113020311.7+000742158.18-57.75 5.43  +0.15 +0.13 +0.08   A5III              +0.079+0.017      +013                           
+ 608          BD-16  356  125831481702141                   015809.7-154716020258.6-151821181.14-69.60 5.86  +0.98 +0.74         G3IV               +0.028+0.011      +006V                          
+ 609          BD+17  307  12594 92774    I D                015813.4+174622020342.6+181512146.03-41.35 6.21  +1.42              gK4                 -0.007-0.018      +010V                         *
+ 610 61    CetBD-01  285  12641129667        1634    711    015840.9-004911020348.2-002025158.88-58.07 5.93  +0.88 +0.50         G5II-III+G5V       +0.079-0.046      +024           3.8  42.9AB   3*
+ 611          BD-04  324  126421296652143I                  015838.2-043457020340.5-040613162.91-61.23 5.62  +1.59 +1.97         K5I:               +0.006-0.068      +025V?                         
+ 612   Nu  ForCD-29  706  127671675321055          Nu  For  020000.5-294636020429.4-291749224.89-73.78 4.69  -0.17 -0.51 -0.14   B9.5pSi            +0.012+0.008      +019       87                 *
+ 613 12Kap AriBD+21  279  12869 75146                       020058.0+221018020633.9+223854144.78-37.02 5.03  +0.11 +0.13 +0.03   A2m                +0.018-0.035      +012SB2O   29                 *
+ 614          BD+07  324  12872110337    I         WZ Psc   020055.3+074614020612.3+081451152.67-50.26 6.31  +1.65 +1.82 +1.00E  M2III:             -0.005-0.036      -026                          *
+ 615 11    AriBD+25  349  12885 75149        1658           020108.9+251340020649.2+254217143.52-34.14 6.15  -0.03 -0.26         B9IV-Vn            +0.017-0.011      -009      300  5.5   1.6       
+ 616          BD-00  318  12923129695                       020121.8-002632020629.3+000206159.58-57.40 6.28  +0.90 +0.63         K0                 +0.064-0.010      +021V                          
+ 617 13Alp AriBD+22  306  12929 75151  74I           725    020132.0+225923020710.4+232745144.57-36.20 2.00  +1.15 +1.12 +0.62   K2-IIICa-1         +0.190-0.148 +.049-014SB   < 17                 *
+ 618          BD+57  494  12953 22959              V472 Per 020141.3+575652020840.5+582525132.92-02.94 5.67  +0.61 -0.02 +0.50   A1Ia              t-0.011+0.003      -036V      18                 *
+ 619          BD+43  431  13013 37794                       020218.3+435907020833.6+442734137.14-16.27 6.42R                     G8III-IV           +0.016-0.051      +024                           
+ 620 58    AndBD+37  486  13041 552892145                   020226.9+372305020829.3+375133139.31-22.55 4.82  +0.12 +0.14 +0.07   A5IV-V             +0.157-0.044 +.006+008SB    133                  
+ 621          BD+53  460  13137 229932146                   020324.8+532214021007.8+535035134.48-07.25 6.31  +0.95               G8III              +0.027-0.043      +010                           
+ 622  4Bet TriBD+34  381  13161 55306  75I                  020335.4+343052020932.6+345914140.55-25.20 3.00  +0.14 +0.10 +0.08   A5III              +0.150-0.040 +.022+010SB2O   76                 *
+ 623 14    AriBD+25  355  13174 75171      W                020343.6+252801020925.3+255623144.08-33.71 4.98  +0.33 +0.15         F2III              +0.075-0.039      +001V     154  2.5 105.9AC   3 
+ 624          BD+16  247  13201 92810                       020353.3+164519020923.1+171328148.23-41.79 6.43                      F5V                +0.142-0.181      +011    =< 10                  
+ 625          BD-18  374  13215148237    I           732    020401.1-181511020845.7-174646189.29-69.87 6.10  +1.61 +2.02 +0.95E  M2III              -0.002-0.032      +014                          *
+ 626          BD+73  121  13222  45992149                   020407.8+733327021321.2+740140128.58 12.06 6.29  +0.91               G8III              +0.048-0.037      -037V                          
+ 627  5    PerBD+56  438  13267 23011        1685  Var?     020431.0+571024021129.0+573845133.51-03.57 6.36  +0.33 -0.43 +0.26   B5Ia               -0.013+0.005      -034V      53  6.9  60.0AC   3*
+ 628 59    AndBD+38  425  13294 55330        1683A          020448.6+383403021052.8+390222139.38-21.28 5.63  -0.02 -0.09         B9V                -0.015-0.018D+.010+001V     192  0.8  16.2      *
+ 629 59    AndBD+38  425  13295 55331        1683B          020449.5+383417021053.7+390235139.38-21.28 6.10  -0.07 -0.17         A1Vn               -0.009-0.026D+.010+015V?    305  0.8  16.2      *
+ 630          CD-24  921  133051675992147                   020459.9-244904020934.8-242045208.31-72.20 6.48  +0.29               F4III              -0.027-0.044      +020                           
+ 631 15    AriBD+18  277  13325 928221056I           738    020504.9+190143021037.6+193001147.40-39.58 5.70  +1.65 +1.91         M3IIIab            +0.088-0.028      +060V                          
+ 632          CD-44  632  13336215785                       020509.7-435919020909.3-433100264.22-67.31 5.85  +1.19 +1.08         K1III              -0.048-0.053      -026                           
+ 633 16    AriBD+25  362  13363 75188    I                  020530.5+252755021112.0+255613144.53-33.57 6.02  +1.36              gK4                 -0.007-0.010      -019                           
+ 634  5    TriBD+30  347  13372 553382148            740    020534.2+310319021125.0+313135142.27-28.32 6.23  +0.11 +0.14         A1m                +0.035-0.013      +011SB2    30                 *
+ 635 64    CetBD+07  347  13421110390                       020604.2+080606021121.1+083411154.20-49.39 5.63  +0.56 +0.14         G0IV               -0.139-0.112 +.034-018V?  =< 10                  
+ 636          CD-44  638  13423215794                       020605.5-441715021004.9-434856264.54-66.99 6.32  +0.90               G8III              +0.059-0.009      +041V?                         
+ 637          CD-51  532  13445232658                       020623.7-511852021025.6-504928275.99-61.97 6.12  +0.82 +0.45 +0.32E  K1V                +2.119+0.641 +.090+053                           
+ 638          BD-10  447  134561482622150                   020628.0-103106021122.2-100308174.54-64.57 6.01  +0.39 -0.03         F5V                -0.022-0.166      +011    =< 10:                 
+ 639 63    CetBD-02  375  134681297392151                   020631.1-021744021135.8-014931163.52-58.23 5.93  +0.97 +0.70        gG9                 -0.008-0.031      +032                           
+ 640 55    CasBD+65  239  13474 12180  76  S         753    020637.7+660321021429.1+663128131.08  4.98 6.07  +0.63 +0.33         G0II-III+B9V       -0.006-0.006      -012V      70                 *
+ 641          BD+57  519  13476 23044                       020637.7+580529021341.5+583340133.50-02.61 6.44  +0.60 +0.23 +0.51   A3Iab              -0.012+0.020      -041V?  =< 45                 *
+ 642  6    TriBD+29  371  13480 55347    I   1697  TZ Tri   020634.0+295004021222.3+301811142.98-29.40 4.94  +0.78 +0.31         G5III+F5V          -0.064-0.063 +.004-018SBO    36  1.6   3.8      *
+ 643 60    AndBD+43  447  13520 378672153I S         746    020656.8+434545021313.3+441354138.04-16.23 4.83  +1.48 +1.74 +0.60E  K3.5IIIBa0.5:      -0.020-0.016      -046SB1O < 17                 *
+ 644          BD+23  297  13522 75203    I                  020658.0+234153021237.5+241004145.69-35.09 5.96  +1.37               K0                 +0.041-0.006      -001                           
+ 645          BD+50  481  13530 23047  77  W         747    020657.0+503605021336.3+510357135.85-09.73 5.31  +0.93 +0.62 +0.34E  G8III:            v+0.346-0.171 +.009+027SBO        4.4  27.3      *
+ 646 17Eta AriBD+20  348  13555 75204                       020712.0+204428021248.1+211239147.14-37.81 5.27  +0.43 -0.05         F5V                +0.161+0.003      +006V?      9                 *
+ 647          BD+46  536  13594 37878        1709           020737.7+470102021402.6+472903137.10-13.10 6.06  +0.40 -0.07 +0.25   F4V                -0.063-0.059 +.036-008V    < 26  0.6   1.0      *
+ 648 19    AriBD+14  357  13596 928411057I           748    020735.9+144841021303.3+151647150.40-43.20 5.71  +1.55 +1.94 +0.97   M0III              +0.097-0.023      +023SB                        *
+ 649 65Xi 1CetBD+08  345  136111104081058I D         749    020741.9+082240021300.0+085048154.55-48.95 4.37  +0.89 +0.60 +0.49   G6II-IIICN-2       -0.022-0.009 +.022-004SBO  < 17  2.0   0.0      *
+ 650 66    CetBD-03  336  13612129752        1703           020740.9-025140021247.5-022337164.60-58.52 5.54  +0.57 +0.09         F8V                +0.370-0.069 +.045-003V?         2.1  16.4AB   3*
+ 651          BD-21  396  13692167637                       020821.2-212812021300.9-210001199.11-70.43 5.86  +1.01 +0.78         G9III              +0.050+0.035      +038                           
+ 652   Mu  ForCD-31  882  13709193573  78                   020830.2-311134021254.5-304326229.19-71.84 5.28  -0.02 -0.06         B9V                +0.018+0.006 +.064+010V                          
+ 653          BD+47  590  13818 37905                       020929.9+472051021557.9+474841137.30-12.69 6.33R                     G9III-IV           +0.062-0.071      +016                          *
+ 654          BD+56  471  13854 23115      W       Var?     020952.0+563525021651.7+570319134.38-03.91 6.48  +0.28 -0.66 +0.19   B1Iab             e+0.001-0.002      -042V      57  0.9 103.0      *
+ 655  7    TriBD+32  409  13869 55397                       021001.2+325339021556.2+332132142.55-26.27 5.28  -0.01 -0.03         A0V                -0.017-0.038      -001V     122                  
+ 656 20    AriBD+25  373  13871 75239                       021002.3+251908021546.0+254659145.74-33.33 5.79  +0.44 +0.04 +0.21   F6IV-V             +0.176-0.063      +026V?     12                 *
+ 657 21    AriBD+24  329  13872 752381059  W                021002.2+243447021542.8+250235146.07-34.01 5.58  +0.49 +0.01         F6V                -0.088-0.087D+.015-044           0.3   0.2      *
+ 658          BD-10  460  13936129781                       021033.5-095555021528.3-092756175.21-63.45 6.55  -0.02 -0.07         A0V                -0.003+0.031      -001      118                  
+ 659          CD-41  621  139402158311060                   021029.1-413757021432.0-411000257.70-67.91 5.91  +0.97               G8III              -0.013-0.028      +014SB                         
+ 660  8Del TriBD+33  395  13974 55420        1739           021056.8+334600021703.2+341327142.43-25.39 4.87  +0.61 +0.02 +0.24E  G0.5V              +1.154-0.245 +.093-006SB2O=< 10  8.5  65.4      *
+ 661  8    PerBD+57  535  13982 231432157                   021054.8+572610021759.9+575359134.25-03.06 5.75  +1.17               K3III              +0.063+0.005      +003                           
+ 662  7    PerBD+56  486  13994 23149        1753           021102.1+570310021804.5+573100134.39-03.42 5.98  +1.05 +0.79         G7III              -0.019+0.006      -011V          2.6 121.9AD   4*
+ 663          BD+43  461a 14028                    W And    021112.9+435035021733.4+441825138.78-15.90 6.7                       M7-8Se            v+0.041+0.083      -045V                         *
+ 664  9Gam TriBD+33  397  14055 55427  79                   021122.0+332305021718.9+335050142.65-25.71 4.01  +0.02 +0.02  0.00   A1Vnn              +0.047-0.051 +.039+014V     208                  
+ 665          BD+23  307  14067 752622156                   021131.1+231818021710.4+234604147.05-35.06 6.55  +1.02 +0.85         G9III              -0.033-0.039      -013                           
+ 666 67    CetBD-07  393  14129129798  80                   021159.7-065258021659.0-062520171.27-60.99 5.51  +0.96 +0.76         G8.5III            +0.093-0.108      +007V?                         
+ 667   Pi 1HyiCP-68  126  14141248518                767    021209.0-681830021414.7-675030291.57-47.42 5.55  +1.55 +1.85         M1III              +0.037+0.037 +.013+026                          *
+ 668          BD+63  320  14171 12226                       021231.5+635233022012.9+642014132.36  3.10 6.60  -0.03 -0.09         B9.5V              -0.019+0.018      -026    =< 41                  
+ 669 22The AriBD+19  340  14191 92877  81                   021233.6+192619021807.5+195404149.27-38.50 5.62  +0.01 +0.03         A1Vn               -0.013-0.002      +006SB    175                  
+ 670 62    AndBD+46  552  14212 379481063                   021249.4+465507021916.8+472248137.99-12.91 5.30  -0.01  0.00         A1V                -0.059-0.008 +.015-030V      74                  
+ 671          BD+45  589  14213 37947                       021245.6+460040021910.9+462821138.29-13.77 6.21                      A4V                -0.014-0.009      -015                           
+ 672          BD+01  410  142141104561061                   021249.6+011706021801.4+014528162.20-54.38 5.58  +0.60 +0.10         G0.5IVb            +0.368+0.369 +.038+027SBO                       *
+ 673          BD+48  648  14221 37949                       021251.1+482931021922.7+485719137.46-11.42 6.37R                     F4V                -0.093+0.068      -019       15                  
+ 674   Phi EriCP-52  285  14228232696  82  W                021256.2-515830021630.6-513044275.35-60.82 3.56  -0.12 -0.39 -0.11   B8V-IV             +0.096-0.027      +010      247  5.0  87.6      *
+ 675 10    TriBD+27  360  14252 75276        1770           021309.1+281052021857.0+283833145.22-30.41 5.03  +0.04 +0.05         A2V                +0.011-0.006      +003V      29  7.5  57.1       
+ 676          BD+22  329  14262 75277                       021319.0+224224021858.0+231004147.80-35.44 6.46  +0.34 +0.08         A1V+F3III           0.000-0.005      -013SBO   116                 *
+ 677          BD+39  521  14272 55453                       021327.6+392228021937.3+395006140.79-19.96 6.63  -0.09 -0.37         B8V                +0.033-0.010      -008V?     15                  
+ 678   Pi 2HyiCP-68  128  14287248521                       021323.4-681235021528.5-674447291.35-47.45 5.69  +1.30 +1.48         K2III              +0.035-0.016      +017                           
+ 679          BD+46  557  14372 37955                       021412.9+465105022041.4+471839138.24-12.89 6.11  -0.08 -0.47         B5V                +0.007-0.007      +002V                          
+ 680          BD+29  392  14373 75287                       021413.5+294344022004.4+301118144.79-28.89 6.47R                     K0                 +0.016-0.023      -001                           
+ 681 68Omi CetBD-03  353  14386129825    I   1778  Omi Cet  021417.6-032554021920.7-025839167.75-57.98 3.04  +1.42 +1.09 +1.90   M7IIIe+Bep        v-0.008-0.237 +.024+064V          7.3 118.7AC   4*
+ 682 63    AndBD+49  640  14392 37960                790    021420.7+494134022058.2+500905137.29-10.21 5.59  -0.13 -0.38         B9pSi              +0.034-0.027      -002V     105                 *
+ 683          CD-26  828  14412167697                       021429.6-262508021858.5-255644214.47-70.41 6.34  +0.73 +0.18         G5V                -0.214+0.448 +.089+007V?                         
+ 684          BD-05  438  14417129830                       021439.2-044820021940.8-042044169.55-58.98 6.50  +0.08 +0.09         A3V                +0.041+0.005      +018                           
+ 685  9    PerBD+55  598  14489 232562159    1802  V474 Per 021522.8+552317022221.4+555044135.51-04.79 5.17  +0.37 -0.11 +0.32   A2Ia              v-0.002-0.002      -015V      25  7.8  11.6      *
+ 686          CD-42  785  14509215860    I                  021525.4-421832021924.7-415054257.92-66.77 6.37  +1.16               K2III              +0.009+0.023      +023                           
+ 687          BD+40  500  14622 379862161  W                021636.7+405633022250.3+412347140.80-18.28 5.82  +0.27 +0.05         F0III-IV           -0.077-0.096      -035V?         1.8 295.5AC   3 
+ 688          CP-56  413  146412327172158  W                021639.8-562414021954.3-555641280.10-57.09 5.81  +1.55 +1.95         K5III              +0.026+0.020      +049           5.1  33.8       
+ 689 69    CetBD-00  355  14652110495    I           805    021649.1-000340022156.6+002345164.95-54.92 5.28  +1.65 +1.87         M2III              -0.013-0.007      +023                           
+ 690          BD+54  535  14662 23283        1820  V440 Per 021654.0+545434022351.8+552152135.87-05.17 6.28  +0.86 +0.64         F7Ib               +0.006-0.024      -026V      12  8.1  10.0      *
+ 691 70    CetBD-01  322  146901298582160                   021706.6-012025022212.4-005306166.40-55.90 5.42  +0.31 +0.10         F0Vn               -0.019-0.048      +020SB                         
+ 692          BD-11  448  14691148354                       021708.0-111355022201.4-104640179.78-63.15 5.46  +0.35 +0.02         F0V                +0.140-0.085      +012V     101                  
+ 693          BD-18  409  147281483561064                   021722.2-180702022205.0-173944193.30-67.06 5.87  +1.23 +1.35 +0.44E  K0III              +0.011-0.060      -003                          *
+ 694 64    AndBD+49  649  14770 38005    I                  021746.0+493311022424.9+500024137.86-10.15 5.19  +0.98 +0.76         G8III              +0.024-0.039 -.001-013V?   < 17                  
+ 695   Kap ForCD-24 1038  14802167736  83                   021758.0-241614022232.6-234859208.85-69.21 5.20  +0.60 +0.12 +0.36   G0Va               +0.200-0.062 +.077+018        4                  
+ 696 10    PerBD+55  612  14818 23304              Var      021812.1+560922022516.0+563636135.62-03.93 6.25  +0.31 -0.62 +0.20   B2Ia              e-0.002+0.008      -046V   =< 45                 *
+ 697          BD-19  444  14830148366                       021815.2-184824022257.8-182116195.13-67.20 6.22  +0.94               G5                 +0.149-0.109      +020V?                         
+ 698          CD-43  724  148322158782162                   021816.5-433925022211.8-431200260.03-65.60 6.31  +1.00               K0III              +0.064+0.035      -007                           
+ 699 65    AndBD+49  656  14872 233192165I W                021857.0+494934022537.4+501643137.95-09.83 4.71  +1.53 +1.89 +0.87   K4+III             +0.027-0.010 +.011-005V?   < 17  5.7 191.7AC   3 
+ 700          CD-38  797  14890193679                       021859.1-380148022306.5-373435247.15-68.09 6.53  +1.61 +1.94         K2III              -0.014-0.037      +011                           
+ 701          CD-51  571  14943232736                       021923.5-513255022254.6-510532273.28-60.44 5.92  +0.22               A5V                +0.022+0.061      +005                           
+ 702 24Xi  AriBD+09  316  14951 929322164                   021927.3+100928022449.0+103638157.03-45.99 5.47  -0.10 -0.48         B7IV               +0.020-0.017      +004SB    175                  
+ 703          CD-26  857  149881677572163                   021950.5-261804022420.1-255051214.69-69.20 6.44  +1.32               K3III              +0.036+0.013      +034                           
+ 704 71    CetBD-03  374  15004129888                       021955.1-031357022458.4-024648169.53-56.93 6.33   0.00 -0.14         A0III              -0.001-0.007      +012V                         *
+ 705   Del HyiCP-69  113  150082485451065                   021958.1-690652022144.9-683934291.25-46.37 4.09  +0.03 +0.05 +0.01   A3V                -0.050+0.002 +.050+006V?    163                  
+ 706          CD-41  681  15064215892                       022032.3-411746022433.8-405026254.50-66.45 6.18  +0.66               G2V                +0.222+0.111      +001SB1O                      *
+ 707   Iot CasBD+66  213  15089 12298        1860  Iot Cas  022049.2+665711022904.0+672409132.12  6.29 4.52  +0.12 +0.06 +0.06   A5pSr             v-0.017+0.011 +.023+001V?     46  2.2   2.3AB   4*
+ 708 72Rho CetBD-12  451  151301483851066                   022107.1-124429022557.0-121726183.75-63.35 4.89  -0.03 -0.07 -0.03   B9.5Vn             -0.010-0.009 +.029+010V     191                  
+ 709 66    AndBD+49  666  15138 23353                       022109.0+500722022751.8+503411138.18-09.42 6.12  +0.41               F4V                +0.036-0.093      -004SBO                       *
+ 710          BD-15  426  15144148386        1849  AB Cet   022115.1-154727022600.3-152028189.53-65.08 5.83  +0.15 +0.10 +0.04   A6VpSrCr           -0.058-0.047 +.015-008SBO    14  3.   12. AB   3*
+ 711          BD+26  409  15152 75370    I                  022120.3+263354022707.0+270048147.91-31.18 6.18  +1.43 +1.82         K5III              -0.055-0.065      -048                           
+ 712 11    TriBD+31  427  15176 55570                       022132.1+312108022727.7+314805145.72-26.79 5.54  +1.12              gK1                 -0.027-0.028      -039V                          
+ 713          BD-20  455  152201677952167                   022156.3-202944022635.2-200234200.01-67.12 5.88  +1.26 +1.33         K2III              +0.088+0.099      +042V                          
+ 714   Lam HorCP-60  199  15233248555  84                   022206.1-604535022453.9-601843283.79-53.20 5.35  +0.39 +0.06         F2III              -0.068-0.133 +.023+006V     106                  
+ 715   Kap HyiCP-74  194  152482558801067                   022216.2-740555022252.3-733845294.47-41.95 5.01  +1.09 +1.04         K1III              -0.083+0.010      +022                           
+ 716          BD+54  557  15253 23369        1878           022222.4+550520022925.0+553211136.55-04.72 6.51  +0.09  0.00         A2pShell          v+0.033-0.010      +002           1.3   2.8      *
+ 717 12    TriBD+29  417  15257 753821068                   022218.0+291323022810.0+294010146.86-28.67 5.29        +0.10         F0III              -0.015-0.087      -025V      78                  
+ 718 73Xi 2CetBD+07  388  15318110543  85I'                 022250.4+080043022809.5+082736159.69-47.39 4.28  -0.06 -0.12 -0.05   B9III              +0.040-0.009 +.030+011SB?    63                  
+ 719          BD+01  431  15328110542      W                022250.2+013046022800.0+015739165.42-52.76 6.45  +0.97 +0.79         K0III              -0.002-0.012      +018           0.4   0.5       
+ 720 13    TriBD+29  423  15335 75391                       022256.3+292855022848.5+295555146.89-28.37 5.89  +0.58 +0.01?        G0V                -0.069+0.074      +040V   =<  6                  
+ 721   Kap EriCD-48  637  15371215906  86I'                 022319.2-480909022659.1-474214267.12-62.24 4.25  -0.14 -0.50 -0.13   B5IV               +0.023-0.010      +028SB?    24                 *
+ 722          CP-67  154  15379248556              TZ Hor   022322.4-665639022526.3-662941289.17-48.04 6.41  +1.54 +1.46 +1.74   M5III              -0.029-0.019      +002                          *
+ 723          BD+22  354  15385 75398                       022331.4+230121022913.6+232808150.24-34.16 6.19  +0.15 +0.14 +0.02   A5m                +0.081-0.028      +021V      21                  
+ 724   Phi ForCD-34  905  154271937232168                   022347.8-341532022801.7-334840236.68-68.20 5.14  +0.10               A2V                +0.020+0.007 +.015+019V     127                  
+ 725          BD+08  385  15453110565        1896           022414.8+090709022935.3+093357159.26-46.27 6.07  +1.02 +0.85         K2III              -0.012+0.012      -011           4.5   1.6      *
+ 726          BD+33  445  15464 55611                       022415.4+332323023016.6+335002145.40-24.69 6.25  +1.07               K1III              +0.070-0.057      +007                           
+ 727          CD-31  990  15471193727                       022416.8-313256022835.4-310609229.36-68.46 6.11  +1.11 +1.07         K2IIICNII          -0.034-0.019      -002                           
+ 728          BD+24  358  15524 754072171    1904           022447.0+244731023032.4+251406149.62-32.45 5.92  +0.41 +0.06         F6IV               +0.066-0.078D+.022-011V      50  4.5 113.1AC   3*
+ 729 26    AriBD+19  365  15550 929792172  D       UU Ari   022501.8+192441023038.4+195119152.63-37.23 6.15  +0.25 +0.10         A9V                +0.078-0.033      +019V     152                 *
+ 730          CD-23  942  15588167832        1906           022521.3-230742022955.4-224058207.10-67.27 6.77  +0.19 +0.15 +0.05   A9V                +0.077+0.006      +013           5.7  28.4       
+ 731 27    AriBD+17  380  15596 929831069                   022521.4+171542023054.4+174214154.01-39.09 6.23  +0.90 +0.55         G5III-IV           +0.031-0.084      -118V?                         
+ 732          BD-00  378  15633110583                846    022538.1-001114023045.2+001519168.08-53.68 6.00  +0.17 +0.17         A7III-IV s         -0.053-0.071      -002V?     42                 *
+ 733          CD-25  979  15634167837              TY For   022544.0-253756023013.8-251111213.52-67.78 6.51  +0.29              dA9n                +0.090+0.031      +025V?                        *
+ 734          CP-64  174  156462485672170                   022544.2-644447022804.4-641759287.00-49.73 6.37  -0.04 -0.05         A0V                +0.037+0.001      +010                           
+ 735          CD-23  947  15652167839    I                  022559.2-225920023032.8-223244206.86-67.09 6.10  +1.61 +2.00 +0.84E  M1III              +0.008-0.033      -019                          *
+ 736 14    TriBD+35  497  15656 556351070I                  022559.8+354214023206.2+360850144.74-22.43 5.15  +1.47 +1.78         K5III              +0.046+0.012      -036     < 19:                *
+ 737          BD+01  438  156941105892173I                  022619.7+014927023130.1+021602166.25-51.98 5.25  +1.27 +1.41         K3III              +0.027-0.004 +.041+026V    < 19:                 
+ 738          BD+33  454  15755 55650                       022650.1+340603023252.5+343233145.62-23.82 5.83  +1.07               K0III              -0.066-0.012      -002V                          
+ 739 75    CetBD-01  353  15779129959                       022704.0-012835023209.4-010206169.94-54.44 5.35  +1.02 +0.84        gG3                 -0.026-0.037      -005V?                         
+ 740 76Sig CetBD-15  449  157981484451071                   022720.8-154101023205.2-151441191.12-63.78 4.75  +0.45 -0.02 +0.27   F4IV               -0.070-0.120 +.035-029       12                  
+ 741 29    AriBD+14  419  15814 929982176                   022725.4+143531023254.1+150205156.28-41.18 6.04  +0.54 +0.04         F8V                -0.028+0.037      +006SB  =< 10                  
+ 742          CD-36  957  15889193759                       022807.5-365209023214.8-362539242.77-66.74 6.30  +1.02 +0.74 +0.37E  G8III              +0.065+0.009      +013                          *
+ 743          BD+72  140  15920  4694  87                   022830.9+722252023802.0+724906130.71 11.58 5.16  +0.88 +0.58         G8III              -0.030+0.016 +.011-002V?   < 19:                 
+ 744   Lam1ForCD-35  877  15975193763  88                   022856.8-350523023307.0-343900238.27-67.00 5.90  +1.06               K0III              -0.015-0.020      +013                           
+ 745          BD-20  480  15996167878                       022903.3-202622023340.2-200007201.48-65.57 6.21  +1.10               K0                 -0.041-0.079      -006V                          
+ 746          BD+39  573  16004 55680        1961           022912.5+391337023527.9+393952143.84-18.95 6.36  -0.10 -0.34         B9pHgMn            +0.026-0.026      -008V?     30  5.6  16.3AB   3*
+ 747          BD+65  280  16024 123612178I                  022925.7+651833023736.1+654444133.55  5.09 5.78  +1.56 +1.85         K5III              +0.042-0.005      +041                           
+ 748          BD+36  519  16028 55684    I   1964           022928.9+365229023538.8+371844144.92-21.07 5.71  +1.39               K3III              +0.004-0.009      -006           5.2  18.3AB   3 
+ 749   Ome ForCD-28  819  16046167882        1954A          022927.9-284018023350.7-281357221.70-67.34 4.90  -0.05 -0.13 -0.07   B9.5V              -0.019-0.013      +010V      72  2.8  10.8      *
+ 750 15    TriBD+34  469  16058 55687    I W         866    022942.5+341505023546.8+344115146.14-23.44 5.35  +1.66 +1.93 +1.00E  M3IIIa             +0.030-0.049 +.016-010V          1.2 141.3      *
+ 751          BD+06  392  16060110625                       022946.3+070210023504.1+072817162.60-47.26 6.18  +1.06 +0.89        gG6                 -0.006-0.108      -025                          *
+ 752 77    CetBD-08  484  16074129984    I W                022946.5-081746023442.7-075134179.49-58.87 5.75  +1.40 +1.65        gK4                 +0.063-0.065      +025           6.7  94.7      *
+ 753          BD+06  398  161601106361073  W                023035.7+062435023604.9+065313163.39-47.62 5.82  +0.98 +0.81 +0.53   K3V                +1.811+1.451 +.147+023SB         5.0   2.5AP   3*
+ 754 78Nu  CetBD+04  418  161611106351072I   1971           023037.5+050925023552.5+053536164.48-48.67 4.86  +0.87 +0.53 +0.49   G8III              -0.026-0.025 +.002+005SB   < 17  4.8   8.1      *
+ 755          CD-51  611  161702328182177                   023030.2-513153023354.6-510537270.92-59.19 6.24  +0.52 +0.07         F6V                -0.004-0.030      -008                           
+ 756          BD+38  515  16176 55705                       023042.4+381808023657.2+384358144.53-19.67 5.90  +0.48               F5V                +0.145-0.194      +001       27                  
+ 757          BD+30  418  16187 55703                       023045.2+311018023642.9+313627147.80-26.13 6.10  +1.05 +0.79         K0                 -0.042-0.004      +003V                          
+ 758          BD+33  470  16210                    R Tri    023057.7+334953023702.5+341550146.59-23.71 5.3   +1.55 +0.84         M4IIIe             +0.058-0.029 +.008+067V                         *
+ 759 80    CetBD-08  489  162121300041074I W                023104.6-081559023600.0-074954179.86-58.61 5.53  +1.59 +1.93 +0.87E  M0III              -0.033-0.059      +014           3.6 146.7AC   3 
+ 760          BD+39  582  16219 55715                       023104.3+392740023720.8+395345144.09-18.59 6.54  -0.12 -0.48         B5V                +0.006-0.019      +016SBO    35                 *
+ 761          BD+32  473  16220 55711                       023105.2+322717023706.4+325331147.26-24.94 6.25  +0.48 +0.01         F8V                +0.065+0.063      +000                           
+ 762          CP-63  169  16226248595                       023106.3-630132023333.6-623513284.65-50.76 6.77  -0.06               B9V                +0.026+0.010      +001V                          
+ 763 31    AriBD+11  360  16234 930222179  D                023110.6+120051023637.9+122651159.13-42.91 5.68  +0.49 -0.08         F7V                +0.286-0.089 +.035+007V   =< 10  0.1   0.0      *
+ 764 30    AriBD+24  375  16232 75470        1982B          023111.5+241246023657.7+243854151.47-32.31 7.09  +0.50 +0.02         F4V                +0.143 0.000 +.018+017       30  0.6  38.3      *
+ 765 30    AriBD+24  376  16246 75471        1982A          023114.3+241244023700.5+243851151.49-32.31 6.50  +0.41 -0.02         F6III              +0.136-0.006 +.018+015SBO    60  0.6  38.3      *
+ 766          BD+07  402  16247110640                872    023117.1+071741023635.1+074347162.83-46.83 5.81  +1.04 +0.86        gK0                 -0.049-0.031      -025                           
+ 767   Iot1ForCD-30  958  16307193795                       023150.5-302850023609.3-300241226.39-66.88 5.75  +1.02               G8-K0III           -0.013+0.001      +002V?                         
+ 768          BD+37  588  16327 55729        1996           023206.5+371739023817.8+374336145.24-20.47 6.18  +0.47 +0.08         F6III              -0.040-0.044      +009       43  5.0  20.8AC   4*
+ 769          BD+37  591  16350 55735                       023215.3+373920023827.8+380522145.10-20.13 6.30  -0.03 -0.03         B9.5V              -0.009+0.001      +002    =< 41                 *
+ 770          BD+07  405  16399110653                       023241.8+071545023800.8+074143163.28-46.66 6.39  +0.44  0.00         F6IV               +0.086-0.044      +013       12                  
+ 771 81    CetBD-04  436  164001300262180                   023239.4-034944023741.8-032346174.49-55.25 5.65  +1.02 +0.85        gG5                 +0.041-0.045      +008                           
+ 772   Lam2ForCD-35  903  16417193811                       023249.4-350019023658.6-343442237.68-66.24 5.79  +0.66 +0.22         G5IV               -0.015-0.270 +.056+010V?                         
+ 773 32Nu  AriBD+21  362  16432 75495  89                   023308.1+213145023849.0+215741153.46-34.47 5.43  +0.16 +0.13         A7V                -0.008-0.017 +.013+008SB?   110                  
+ 774          BD+80   86  16458   4333945                   023320.8+810129024747.6+812654127.33 19.59 5.78  +1.30               G8pBa3             +0.010-0.076 +.013+018V?                        *
+ 775          BD+02  406  16467110655      W                023324.5+030037023836.9+032635167.32-49.96 6.21  +1.00 +0.76         G9III              +0.043+0.002      +002           3.2   0.8       
+ 776   Mu  HyiCP-79   66  16522255898  90                   023347.1-793245023140.5-790634297.19-36.88 5.28  +0.98 +0.73         G8III              +0.121-0.056 +.001-015                           
+ 777   Iot2ForCD-30  973  165381938292183                   023359.9-303729023818.7-301139226.75-66.41 5.83  +0.48 -0.01         F4V                +0.100-0.077      +029                           
+ 778   Eta HorCP-53  457  165552328352182                   023406.4-525833023724.4-523235272.31-57.82 5.31  +0.27               A6V                +0.100-0.019 +.025-003      239                  
+ 779 82Del CetBD-00  406  16582110665  91          Del Cet  023421.3-000610023929.0+001943170.76-52.21 4.07  -0.22 -0.87 -0.21   B2IV               +0.014-0.004 +.001+013SB     13                 *
+ 780          CD-38  875  165891938342184                   023422.8-382516023824.8-375926245.54-65.10 6.49  +0.52               G0IV               +0.111-0.063      +043SBO                       *
+ 781 83Eps CetBD-12  501  16620148528      W                023443.6-121748023933.8-115220187.19-60.41 4.84  +0.45 -0.01         F5V+F6V            +0.146-0.236 +.072+015SBO    13  0.2   0.1      *
+ 782 33    AriBD+26  443  16628 75510        2033           023450.2+263754024041.1+270339151.02-29.79 5.30  +0.09 +0.13         A3V                +0.067-0.031 +.002+017SB    104  4.2  28.6      *
+ 783          BD+05  374  16647110673                       023459.2+054054024015.7+060643165.32-47.60 6.25  +0.40 -0.03         F3V:               +0.052-0.003      +018V      18                  
+ 784          BD-10  525  16673130047                       023520.4-095251024012.3-092711183.54-58.84 5.78  +0.52  0.00         F6V                -0.151-0.086      -004V   =<  6                  
+ 785 11    PerBD+54  598  16727 235552188                   023553.2+544045024302.8+550621138.51-04.35 5.77  -0.13 -0.48         B7IIIpHg           +0.034-0.027      -002                          *
+ 786          CD-31 1081  16733193846                       023545.9-310343024002.5-303802227.82-66.03 6.52  +1.04               K0III              -0.004-0.068      -004V?                         
+ 787          BD+52  616  16735 23556        2059           023556.5+530559024259.7+533134139.16-05.79 5.84  +1.12               K0II-III           +0.068-0.030      -012V          9.0  12.4      *
+ 788 12    PerBD+39  610  16739 557932187  S         896    023556.0+394616024214.9+401138144.84-17.91 4.91  +0.59 +0.14 +0.30   F9V                -0.019-0.186 +.043-023SB2O < 25  0.3   0.1      *
+ 789          CD-43  814  167542159962185  W                023559.2-431915023948.0-425330255.67-62.98 4.75  +0.06 +0.06 +0.01   A2V                +0.106-0.027 +.028+018V     190:10.0  23.8       
+ 790 84    CetBD-01  377  16765130055        2046    893    023606.5-010715024113.9-004145172.42-52.68 5.71  +0.52 -0.02         F7IV               +0.214-0.136 +.036+008           3.6   4.0      *
+ 791          BD+67  224  16769 12421  92                   023612.9+672359024449.7+674929133.34  7.27 5.95  +0.10 +0.17         A5III              +0.015-0.033      +005SBO    35                 *
+ 792          BD+47  683  16780 38274        2064           023619.0+475018024301.9+481556141.40-10.56 6.48R                     G5II               +0.007+0.002      -005           5.0  72.8AC   3*
+ 793 34Mu  AriBD+19  403  16811 93062        2062           023643.5+193508024222.0+200042155.53-35.74 5.69R -0.02 -0.03         A0Vnp:             +0.029-0.043      -007V     195  0.8   0.1 O   4*
+ 794   Iot EriCD-40  689  168152159991075I                  023643.2-401700024040.0-395120249.30-64.07 4.11  +1.02 +0.74 +0.56   K0III              +0.138-0.032 +.038-009                           
+ 795          BD-03  421  16824130061                       023646.1-033828024148.3-031248175.53-54.40 6.05  +1.17 +1.13        gG9                 -0.019+0.002      +004V?                         
+ 796          BD-15  478  16825148550                       023649.4-145843024134.0-143258192.38-61.45 5.98  +0.43 -0.02         F5III:             -0.032+0.042      +002V?                         
+ 797          BD+10  360  16861 93067                899    023705.8+101856024228.9+104430162.07-43.53 6.30  +0.06 +0.06 +0.02   A2V                -0.025-0.022      +006V      33                 *
+ 798          CP-64  192  16891248616                       023722.6-644241023931.7-641655285.44-49.01 6.55  -0.08 -0.24         B8V                +0.025+0.013      -001V?                        *
+ 799 13The PerBD+48  746  16895 38288  93I   2081    902    023721.9+484820024412.0+491342141.16-09.61 4.12  +0.49  0.00 +0.30   F8V                +0.336-0.089 +.077+025V?      6  5.6  19.6AB   3*
+ 800 14    PerBD+43  566  16901 382891077                   023734.2+435219024405.2+441749143.31-14.07 5.43  +0.90 +0.65         G0Ib-IICa1CH-1     +0.004-0.007      -003SB?                        
+ 801 35    AriBD+27  424  16908 75532  94                   023734.8+271654024327.1+274226151.29-28.93 4.66  -0.13 -0.62 -0.13   B3V                +0.008-0.012      +013SB1O  132                 *
+ 802   Zet HorCP-55  446  169202328571076                   023732.9-545841024039.6-543300274.43-56.11 5.21  +0.40 -0.01         F4IV               +0.036-0.001 +.031-001SB2O                      *
+ 803          BD+25  441  16955 75539        2082           023802.9+251247024351.2+253817152.53-30.69 6.35  +0.08 +0.11         A2Vp:              -0.011-0.005 -.000-011           4.1   2.9AB   3*
+ 804 86Gam CetBD+02  422  16970110707        2080           023807.1+024852024318.0+031409168.92-49.38 3.47  +0.09 +0.07 +0.04   A3V                -0.142-0.152 +.052-005V     183  2.7   2.8AB   3*
+ 805          CD-38  894  16975193873                       023807.6-384837024206.6-382302245.90-64.29 6.01  +0.92               G8III              +0.018+0.001      +017                           
+ 806   Eps HyiCP-68  161  16978248621  95                   023802.9-684143023935.4-681601288.96-45.82 4.11  -0.06 -0.14 -0.07   B9V                +0.086-0.002      +006      110                 *
+ 807          CD-47  832  170062160132189                   023832.4-465652024208.5-463128261.96-60.83 6.10  +0.88               K1III              +0.015-0.100      +013                           
+ 808 36    AriBD+17  426  17017 930812190                   023844.1+172027024419.1+174550157.47-37.42 6.46  +1.07 +1.07 +0.39E  K2III              +0.039-0.038      -032V                         *
+ 809 37Omi AriBD+14  457  17036 93082                       023902.2+145319024432.9+151842159.22-39.46 5.77  -0.01 -0.19         B9Vn               -0.002-0.019      -007      350                  
+ 810   Iot HorCD-51  641  17051232864                       023909.2-511354024233.5-504801268.82-58.33 5.41  +0.56 +0.10         G0V                +0.334+0.222 +.069+016                           
+ 811 89Pi  CetBD-14  519  17081148575  97                   023921.7-141656024407.4-135131191.81-60.57 4.25  -0.14 -0.45 -0.14   B7V                -0.008-0.015      +015SB     18                  
+ 812 38    AriBD+11  377  17093 93083              UV Ari   023930.5+120130024457.6+122645161.43-41.79 5.18  +0.24 +0.10         A7III-IV           +0.122-0.084 +.027-002V      83                 *
+ 813 87Mu  CetBD+09  359  17094110723  98  D         909    023932.1+094131024456.5+100651163.25-43.70 4.27  +0.31 +0.08 +0.19   F0IV               +0.284-0.036 +.046+030SBO    54  1.4   0.1      *
+ 814          CD-41  769  17098216019      W                023927.3-405710024320.3-403139250.30-63.35 6.36  -0.02               B9V                +0.019+0.024D+.009+016           0.3   1.9      *
+ 815          BD+69  179  17138 12445              RZ Cas   023954.1+691249024855.5+693803132.89  9.07 6.18  +0.18 +0.10         A3V                 0.000+0.032      -039SBO    82                 *
+ 816          BD+04  437  17163110730                       024006.2+041726024520.9+044242168.09-47.92 6.03  +0.31 +0.08        gF0                 +0.068-0.043      +020SB     75                  
+ 817          CD-33  943  17168193888                       024008.8-325650024420.5-323130232.25-65.00 6.22  +0.04               A1V                +0.020-0.031      +021SB     48                  
+ 818  1Tau1EriBD-19  518  17206148584                       024026.1-185945024506.2-183421200.83-62.53 4.47  +0.48  0.00 +0.27   F6V                +0.330+0.038 +.072+026SB1O   22                 *
+ 819          BD+35  553  17228 55868                       024047.4+353348024658.3+355901147.73-21.26 6.25  +0.93 +0.62         G8III              +0.050-0.005      +021                          *
+ 820          BD+34  513  17240 55872        2117           024054.3+350809024703.5+353318147.96-21.64 6.30R                     A9V                -0.043-0.047D+.013-004       45  2.1   1.5AB   3*
+ 821          CP-53  475  17254232871                       024058.1-525934024410.7-523414271.10-57.02 6.15  +0.09               A2V                -0.012-0.015      +010                           
+ 822          CD-46  797  17325216036                       024141.3-464229024516.5-461714260.97-60.49 6.85  +1.36               K2III              -0.003-0.014      +032V                          
+ 823          CP-67  181  17326248632      W         911    024141.7-670806024326.6-664252287.19-46.84 6.26  +0.53 +0.01         F5V                +0.108-0.070 +.010-020           0.0   0.4      *
+ 824 39    AriBD+28  462  17361 75578    I                  024157.1+284955024754.5+291450151.42-27.10 4.51  +1.11 +1.05 +0.58   K1.5III            +0.149-0.123 +.027-015V    < 17                  
+ 825          BD+56  718  17378 23637      S       V480 Per 024207.7+564001024930.8+570503138.47-02.18 6.25  +0.89 +0.50 +0.76   A5Ia               +0.004-0.010      -038V      37                 *
+ 826          BD-22  479  17390168045                       024212.4-220334024645.2-213823207.44-63.24 6.49  +0.38               F3IV               +0.091+0.009      +007       67                  
+ 827          CD-23 1061  17438168051                       024240.8-225412024711.2-222908209.30-63.39 6.47  +0.39               F2                 -0.021-0.038      +003V?                         
+ 828 40    AriBD+17  442  17459 93118    I D         937    024255.5+175202024832.1+181701158.18-36.45 5.82  +1.20 +1.13 +0.44E  K1III              +0.044-0.036      +047V          0.0   0.2      *
+ 829          BD+68  200  17463 124722195          SU Cas   024302.8+682827025158.7+685319133.47  8.52 5.80  +0.64 +0.48         F5:Ib-II           -0.006-0.004 +.010-007SB                        *
+ 830          BD+24  396  17471 75588              VZ Ari   024256.9+244615024845.9+251117153.91-30.53 5.86R -0.07 -0.08         A0V                +0.059-0.004      +014       60                 *
+ 831          BD+36  566  17484 55910                       024312.5+365436024927.1+371934147.54-19.84 6.45  +0.43 +0.14         F6III-IV           +0.009-0.016      +012SB     17                  
+ 832          BD-13  530  17491148612    I         Z Eri    024308.4-125238024756.0-122738190.42-59.04 6.90  +1.56 +1.37 +1.39E  M4III             v+0.007-0.038      -014                          *
+ 833   Gam HorCP-64  196  17504248642      W                024319.2-640726024527.5-634216284.11-49.05 5.74  +0.93 +0.63         G8III-IV           +0.022-0.009      -011SB         7.3  20.0       
+ 834 15Eta PerBD+55  714  17506 23655  99I   2157           024323.8+552850025041.8+555344139.14-03.18 3.76  +1.68 +1.89 +0.89   K3-Ib-IIa         e+0.017-0.014 +.006-001SB  =< 54  4.7  28.3AB   6*
+ 835   Eta1ForCD-36 1050  17528193916                       024330.3-355803024733.7-353303238.99-63.93 6.51  +0.96               K0-1III            -0.041-0.039      +003                           
+ 836 42Pi  AriBD+16  355  17543 93127        2151    944    024342.6+170254024917.5+172751158.93-37.04 5.22  -0.06 -0.47         B6V                -0.001-0.015      +009SBO    79  3.0   0.0 A   4*
+ 837   Zet HyiCP-68  169  175662486442191                   024400.0-680213024532.6-673700287.76-46.00 4.84  +0.06 +0.09 +0.07   A2IV-V             +0.069+0.046 +.009+004V?    100                  
+ 838 41    AriBD+26  471  17573 75596 100    2159    951    024405.7+265054024959.0+271538152.98-28.61 3.63  -0.10 -0.37 -0.11   B8Vn               +0.067-0.118 +.034+004SB    180  4.8 124.9AD   4*
+ 839          BD+57  651  17581 23662      W                024415.2+575402025145.5+581853138.20-00.94 6.45  +0.10 +0.08 +0.03   A1m                -0.066+0.015      -005SBO    33  2.8 192.7      *
+ 840 16    PerBD+37  646  17584 559282194  W         956    024416.0+375425025035.1+381907147.25-18.86 4.23  +0.34 +0.08 +0.23   F2III              +0.197-0.105 +.024+014      149  4.7 249.3AC   3*
+ 841   Bet ForCD-32 1025  17652193931 101I W                024454.3-324933024905.4-322421231.79-64.02 4.46  +0.99 +0.69 +0.54   K0-IIIFe-0.5       +0.090+0.155 +.026+017           9.5   4.7       
+ 842          BD+46  648  17656 383972197                   024459.8+462546025141.7+465031143.38-11.20 5.88  +0.89 +0.58         G8III              -0.025-0.028      -012V?                         
+ 843 17    PerBD+34  527  17709 559462198I A         963    024521.0+343854025130.8+350335149.07-21.64 4.53  +1.56 +1.92 +0.95   K5+III             +0.009-0.061 +.004+014V    < 17                  
+ 844   Gam1ForCD-25 1120  17713168081        2167           024525.1-245817024951.0-243337214.12-63.29 6.14  +1.07               K1III              -0.043-0.127      -006           4.4  40.9AC   3*
+ 845   Gam2ForCD-28  903  17729168082                       024534.2-282125024954.2-275630221.64-63.79 5.39  +0.02               A0V                +0.047+0.028 +.025+024      261                  
+ 846          BD+52  640  17743 23674        2185    971    024546.1+523511025252.0+525952140.73-05.63 6.36  +0.07 -0.27         B8III              +0.002-0.011 -.004+001V?         0.2   1.6ABxC 3*
+ 847 43Sig AriBD+14  480  17769 931441079                   024558.2+144013025129.6+150455161.17-38.72 5.49  -0.09 -0.43         B7V                +0.031-0.026      +017V     195                  
+ 848   Eta2ForCD-36 1067  17793193940      W                024612.1-361528025014.8-355037239.41-63.34 5.92  +0.90 +0.62         K0III              +0.058+0.021      +022V          4.3   5.0      *
+ 849          BD+47  723  17818 38418        2192           024632.1+480935025321.2+483410142.83-09.54 6.26  +1.18 +0.94         G5I                +0.015-0.027      -001           5.7   6.7       
+ 850  2Tau2EriBD-21  509  17824168094 102I   2179           024630.1-212458025102.3-210015206.80-62.09 4.75  +0.91 +0.63 +0.47   K0III              -0.046-0.019 +.031-009          10.2  46.7      *
+ 851   Eta3ForCD-36 1070  17829193944                       024637.9-360514025040.4-354034239.01-63.28 5.47  +1.25 +1.31 +0.49E  K5III              +0.006-0.061 +.017+012                          *
+ 852   Nu  HorCP-63  188  178482486562196                   024648.3-631317024901.5-624824282.75-49.46 5.26  +0.10 +0.06         A2V                +0.091+0.021 +.001+031      167                  
+ 853          CD-40  736  17864216065                       024655.8-402040025047.9-395554248.01-62.21 6.36  +0.05               A0V                +0.055+0.007      +019V?                         
+ 854 18Tau PerBD+52  641  17878 23685 103I   2202  Tau Per  024709.8+522112025415.5+524545141.02-05.74 3.95  +0.74 +0.46 +0.44   G4III+A4V           0.000-0.005 +.019+002SB1O < 25  8.6  51.7AxBC 4*
+ 855 20    PerBD+37  655  17904 55975        2200    977    024723.7+375548025342.6+382015147.81-18.55 5.33  +0.41 +0.04         F4IV               +0.047-0.077 +.011+006SBO    63  0.6   0.2AB   4*
+ 856          BD+15  400  17918 93164                       024737.5+160431025311.7+162900160.59-37.33 6.31                      F5III              +0.055-0.062      +009      120                  
+ 857          BD-13  544  17925148647                975    024742.9-131030025232.1-124610192.06-58.26 6.04  +0.87 +0.56 +0.45   K2V                +0.394-0.175 +.121+019V                          
+ 858          CD-31 1148  17926193951                       024743.1-311342025155.3-304852228.14-63.47 6.40  +0.48               F8IV-V             -0.116+0.106      +008                           
+ 859          BD-10  569  17943130160                       024758.0-095108025250.5-092628187.02-56.35 6.32  +0.19 +0.12         A7IV               +0.074+0.050      +035      120                 *
+ 860          BD+60  591  17948 125172201  W                024801.0+610647025556.9+613116137.21  2.15 5.59  +0.45 -0.10         F4V                +0.142+0.032      +029           5.5  89.6AC   3 
+ 861          BD+63  369  17958 12519    I W         985    024809.2+635533025624.8+641957135.96  4.67 6.24  +2.03 +2.41         K3Ib              v+0.006-0.002      -022           3.4 115.6      *
+ 862          BD-22  503  18071168121                       024905.1-224657025335.3-222235209.96-61.94 5.95  +1.04               K0III              +0.090-0.080      +049                          *
+ 863   Psi ForCD-38  948  181491939652200                   024939.2-385045025334.4-382613244.62-62.12 5.92  +0.44 +0.07         F6IV               +0.063+0.031      +021V                          
+ 864          BD+50  665  18153 23721                       024949.8+505125025650.6+511539142.08-06.89 6.22  +1.57 +1.90         K5III              -0.011-0.039      +005                           
+ 865          BD+46  658  18155 38455      W                024947.8+464531025633.4+470950143.97-10.53 6.02  +1.34              gK3                 +0.004 0.000      -013           5.5  24.9AC   3*
+ 866          CP-63  197  18185248673                982    025009.9-631906025219.2-625435282.43-49.13 6.03  +1.25               K1III              +0.072+0.001      +017                           
+ 867 45Rho2AriBD+17  457  18191 93189              RZ Ari   025011.2+175535025548.5+181954159.93-35.45 5.91  +1.47 +1.12 +2.17   M6-III:            -0.008-0.017 +.014+046V?                        *
+ 868          CD-50  860  18242                    R Hor    025033.2-501752025352.9-495325265.46-57.38 4.0 H +2.11 +0.43 +3.09   M7IIIe             +0.135+0.014 +.013+060V                         *
+ 869 46Rho3AriBD+17  458  18256 931952204                   025047.3+173728025626.1+180123160.29-35.62 5.63  +0.43 -0.02         F6V                +0.276-0.213 +.038+015SB1O   15                 *
+ 870          BD+07  450  18262110851                       025052.7+075846025613.8+082254167.75-43.37 5.97  +0.48 +0.06         F7IV               +0.068-0.087      +029V   =< 10                  
+ 871          CD-51  683  182652329332202                   025052.2-511641025406.5-505217266.92-56.80 6.21  +1.58 +1.88         K4III              +0.010+0.006      -013                           
+ 872   Nu  HyiCP-75  204  182932559292199                   025106.7-752832025028.5-750401293.35-39.77 4.75  +1.33 +1.56 +0.66   K3III              -0.037-0.027 +.011+005                          *
+ 873 21    PerBD+31  509  18296 560312205          LT Per   025112.9+313154025717.3+315603151.88-23.77 5.11  -0.01 -0.23         B9pSi             v+0.003-0.031 +.003+008SB     19                 *
+ 874  3Eta EriBD-09  553  18322130197 104I           988    025132.5-091746025625.7-085353187.15-55.31 3.89  +1.11 +1.00 +0.58   K1-IIIbBa0.2:      +0.079-0.220 +.033-020     < 17                 *
+ 875          BD-04  502  183311301991080                   025136.6-040653025637.4-034244180.36-52.04 5.17  +0.08 +0.05 +0.05   A1Vn               -0.035-0.044 +.026-015SB    231                 *
+ 876          BD+38  599  18339 56036    I                  025141.8+381247025802.3+383654148.45-17.90 6.04  +1.41              gK3                 -0.007-0.016      -041V?                         
+ 877          BD+03  410  183451108652206I           990    025150.2+040550025704.6+043004171.55-46.17 6.11  +1.69 +1.81         M4IIIab            +0.017+0.023      +052                           
+ 878 47    AriBD+20  480  18404 756621081                   025221.6+201604025805.2+204007158.88-33.22 5.80  +0.41 +0.01 +0.20   F5IV               +0.233-0.031 +.030+028       20                 *
+ 879 22Pi  PerBD+39  681  18411 560472207                   025221.8+391545025845.7+393946148.04-16.92 4.70  +0.06 +0.12 +0.04   A2Vn               +0.024-0.043 +.009+014SB    168                 *
+ 880          CP-64  206  18423248681                       025226.9-645026025420.9-642608283.75-47.86 6.56  +1.39 +1.59         K2-3III            +0.009-0.004      +006                           
+ 881          BD+78  103  18438  4810 105I   2294           025246.6+790125030607.8+792507129.08 18.19 5.49  +1.57               M1III+F7IV         -0.039+0.009D+.008-038SB         4.4   4.7      *
+ 882 24    PerBD+34  550  18449 560521082I                  025251.7+344657025903.7+351059150.45-20.78 4.93  +1.23 +1.29 +0.64   K2III              -0.046+0.006      -036V?   < 17                  
+ 883  4    EriCD-24 1336  18454168183                       025256.9-241547025723.7-235143213.46-61.47 5.45  +0.23               A5V                +0.098-0.030 +.029+029V      81                  
+ 884          CD-30 1122  18466194002                       025259.1-301526025713.1-295119226.08-62.31 6.29  +0.47               A2-3V:+G:          +0.012-0.005      +027SB2                       *
+ 885          BD+46  669  18474 38493                       025302.5+464913025949.9+471315144.44-10.22 5.47  +0.89 +0.61         G5:III*            +0.021+0.024 -.007+007V?                        *
+ 886          BD+40  639  18482 38492    I          1004    025312.0+403804025939.9+410159147.50-15.64 5.89  +1.44               K2                 +0.019-0.039      +032                           
+ 887 48Eps AriBD+20  484  18519 75673        2257B  1001    025329.5+205626025912.7+212025158.69-32.51 4.63  +0.04 +0.08 +0.02   A2V s              -0.017-0.005 +.005-006V      66  0.3   1.5AB   3*
+ 888 48Eps AriBD+20  484  18520 75673        2257A  1001    025329.5+205626025912.7+212025158.69-32.51 4.63  +0.04 +0.08 +0.02   A2V s              -0.017-0.005 +.005-008SB?        0.3   1.5AB   3*
+ 889  6    EriCD-24 1343  18535168191    I                  025338.8-240030025805.7-233622213.02-61.25 5.84  +1.33               K2III              +0.060+0.050      +007V                          
+ 890          BD+51  665  18537 23763        2270A          025344.3+515715030052.2+522106142.11-05.63 5.28  -0.05 -0.45         B7V                +0.028-0.026      -005SB    210  1.4  11.9      *
+ 891          BD+51  665  18538 23765        2270B          025345.7+515716030053.4+522108142.11-05.63 6.74   0.00 -0.15         B9V                +0.014-0.021      -002SB    200  1.4  11.9      *
+ 892          BD-03  470  18543130215      W                025339.7-031053025842.0-024657179.79-51.03 5.23   0.00 +0.04         A2IV               -0.030-0.056 +.016-007V?     63  7.3   2.7       
+ 893          CD-38  976  18546194007                       025338.6-383533025732.7-381128243.71-61.42 6.41  -0.03               A0Vn               +0.007+0.005      +020                           
+ 894          BD+37  675  18552 56067                       025351.7+374401030011.8+380754149.09-18.11 6.11  -0.06 -0.38         B8Vne              +0.006-0.028      -016SB    305                 *
+ 895          BD-10  585  18557130216                       025356.3-101034025847.4-094635189.01-55.34 6.14  +0.22 +0.13 +0.14   A2m                +0.010-0.011      -018V      28                  
+ 896 91Lam CetBD+08  455  186041108891083                   025421.2+083032025942.9+085427168.21-42.41 4.70  -0.12 -0.45 -0.11   B6III              +0.004-0.014      +010      150                 *
+ 897   The1EriCD-40  771  18622216113 106  W     A  1002    025428.1-404219025815.7-401817247.86-60.74 3.24  +0.14 +0.14 +0.08   A4III              -0.045+0.019 +.035+012SB2    74  1.1   8.3      *
+ 898   The2EriCD-40  771  18623216114      W     B  1002    025428.9-404218025816.3-401816247.85-60.73 4.35  +0.08 +0.12         A1V                -0.064+0.018 +.035+019      100  1.1   8.3      *
+ 899  5    EriBD-03  475  186331302282209           1008    025438.2-025147025941.2-022754179.67-50.64 5.56  -0.08 -0.18         B9.5V              -0.002-0.022      +018SB    182:                 
+ 900          CD-29 1106  18650168202                       025451.0-291817025906.6-285425224.10-61.85 6.14  +1.04               K1III              +0.018-0.044      +014V                          
+ 901   Zet ForCD-25 1191  18692168209                       025511.9-254029025936.1-251627216.57-61.27 5.71  +0.40               F2V                +0.180+0.087 +.029+021       90                 *
+ 902          BD+10  401  18700 932322213I                  025518.6+102827030044.1+105213166.80-40.74 5.95  +1.59 +1.95         K6                 +0.080-0.039      +018                           
+ 903          CD-33 1042  187351940232211                   025530.9-325420025938.3-323026231.73-61.79 6.31   0.00               A0V                +0.010+0.011      +016V?                         
+ 904  7    EriBD-03  478  18760130242    I         CV Eri   025548.5-031632030051.0-025243180.47-50.70 6.11  +1.77 +2.07 +0.91E  M1III              +0.020+0.006      +080V                         *
+ 905 49    AriBD+25  477  18769 756932214           1021    025600.4+260400030154.1+262744156.02-27.90 5.90  +0.14 +0.15 +0.05   A3m                -0.012 0.000      -004V      43                  
+ 906          BD+80   97  18778   5003946    2348   1042    025610.9+810502031142.8+812814128.14 20.05 5.95  +0.15 +0.09 +0.07   A7III-IV           -0.040-0.009 +.018-003SB1O   41  5.0  24.2      *
+ 907  8Rho1EriBD-08  562  18784130243                       025614.9-080325030110.0-073946186.62-53.64 5.75  +1.05 +0.87         K0II               +0.098-0.070      +014V                         *
+ 908          BD+04  485  18832110915                       025636.2+045626030152.3+052010172.01-44.75 6.25  +1.05 +0.82         K0                 +0.036+0.015      -059                           
+ 909   Bet HorCP-64  215  188662487012212                   025654.3-642808025847.8-640417282.85-47.79 4.99  +0.13 +0.15 +0.05   A3-5IIIm:          +0.022+0.001      +024V?     84                  
+ 910 93    CetBD+03  420  18883110921                       025708.2+035731030222.5+042110173.08-45.39 5.61  -0.10 -0.41         B7V                +0.014+0.005      +012       80                  
+ 911 92Alp CetBD+03  419  18884110920 107I         Alp Cet  025703.0+034151030216.8+040523173.32-45.59 2.53  +1.64 +1.94 +1.16   M1.5IIIa          v-0.009-0.078 +.009-026V                         *
+ 912          BD-10  594  188851487212216                   025705.3-102121030156.1-095741190.03-54.80 5.83  +1.11              gG6                 +0.046 0.000      +012V?                         
+ 913          BD-07  537  18894130251                       025712.4-065306030209.3-062941185.31-52.74 6.19  +0.60 +0.15         G0IV-V             +0.087-0.148      +016SB2O   27                 *
+ 914   Eps ForCD-28  987  189071682382215                   025718.9-282827030137.7-280530222.48-61.23 5.89  +0.79               G5IV               +0.279-0.437 +.039+038V                          
+ 915 23Gam PerBD+52  654  18925 23789 108I   2324           025732.9+530654030447.8+533023142.07-04.34 2.93  +0.70 +0.45 +0.45   G8III+A2V           0.000-0.005 +.016+003SB2O=< 50  8.6  57.0AB   3*
+ 916          BD+27  468  18928 75709                       025731.7+275239030330.3+281611155.26-26.19 6.36                      F0V                +0.083-0.020      +011      157                  
+ 917  9Rho2EriBD-08  568  18953130254    I   2312   1024    025747.7-080443030242.3-074107187.04-53.34 5.32  +0.94 +0.73         K0II-III           +0.047-0.001      +025           4.2   1.9      *
+ 918          BD+56  767  18970 237912217I                  025801.3+561848030532.4+564221140.59-01.50 4.76  +1.02 +0.86         G9.5III            -0.014+0.067 +.005-045V    < 19:                 
+ 919 11Tau3EriCD-24 1387  189781682491085                   025758.9-240059030223.5-233728213.54-60.29 4.09  +0.16 +0.08 +0.09   A4IV               -0.145-0.054 +.059-010V?    144                 *
+ 920          BD+55  738  18991 23793                       025812.0+554045030539.9+560407140.92-02.04 6.11  +1.02               G9III              -0.003-0.039      -011                           
+ 921 25Rho PerBD+38  630  19058 56138 109I         Rho Per  025845.9+382710030510.6+385025149.60-17.01 3.39  +1.65 +1.79 +1.62   M4II               +0.130-0.106 +.011+028                          *
+ 922          BD+63  390  19065 126082219                   025856.6+634009030719.0+640328137.14  5.00 5.89  -0.03 -0.10         B9V                -0.015+0.006      -002V       0                  
+ 923          BD+40  664  19066 38559                       025852.7+401132030520.8+403457148.70-15.49 6.05  +1.01               K0III              -0.053+0.001      -034                           
+ 924          BD+15  430  19080 93260                       025906.6+152805030440.7+155122163.84-36.22 6.49R                     K3III              -0.001-0.093      -032                           
+ 925 10Rho3EriBD-08  572  19107130269                       025921.7-075931030416.4-073603187.30-52.98 5.26  +0.20 +0.09         A8V                +0.056+0.013 +.026+015V?    152                  
+ 926          BD+01  534  191211109452218                   025927.7+012824030438.1+015149176.17-46.77 6.05  +1.04 +0.86         K0III              +0.028-0.003      +001V?                         
+ 927 52    AriBD+24  431  19134 75723        2336A          025934.6+245158030526.7+251519157.53-28.47 6.8   -0.02 -0.38         B7V                +0.002-0.008D+.004+009           0.0   0.2AB   5*
+ 928 52    AriBD+24  431  19135 75723        2336B          025934.6+245158030526.7+251519157.53-28.47 7.0                       B7V                +0.003-0.008D+.004+009?          0.0   0.2AB   5*
+ 929          CD-47  932  191412161501086                   025930.7-472201030255.9-465830259.36-57.50 5.82  +1.30               K2-3III            +0.029+0.003      +016V                          
+ 930          BD+51  681  19268 23825                       030052.8+514941030803.9+521248143.14-05.21 6.31  -0.01 -0.43         B5V                +0.032-0.026      +006                           
+ 931          BD+12  436  19270 932762220                   030054.2+124806030623.7+131114166.31-38.06 5.62  +1.08               K3III               0.000-0.063      -015SB                         
+ 932          BD+73  168  19275  48402222                   030105.2+740049031156.3+742337132.11 14.08 4.87  +0.02 +0.05 -0.01   A2Vnn              +0.012-0.090 +.032+010V     247                  
+ 933          BD+46  692  19279 38587                       030056.3+465521030747.4+471830145.59-09.47 6.41  +0.12 +0.11         A3Vnn              +0.005-0.008      -010                           
+ 934   Mu  HorCP-60  236  19319232981 110                   030115.4-600732030336.8-594416277.43-50.34 5.11  +0.34 -0.03         F0IV               -0.073-0.067 +.025+017       97                  
+ 935          BD-06  606  193491302842221I W                030136.6-062830030633.5-060519185.87-51.62 5.27  +1.60 +1.78         M3III              +0.006-0.008      +017           7.2  15.9       
+ 936 26Bet PerBD+40  673  19356 38592 111I   2362  Bet Per  030139.5+403414030810.1+405720148.98-14.90 2.12  -0.05 -0.37 -0.03   B8V                +0.004-0.001 +.045+004SBO    65  8.3  81.9AD   6*
+ 937   Iot PerBD+49  857  19373 38597 112I W                030150.8+491353030904.0+493648144.58-07.39 4.05  +0.59 +0.12 +0.29   G0V                +1.263-0.091 +.084+050V?  =< 10  8.2 146.2      *
+ 938 53    AriBD+17  493  19374 93284      D       UW Ari   030147.7+172939030725.7+175248162.98-34.21 6.11  -0.12 -0.79         B1.5V              -0.025+0.008      +021SB     18  0.0   0.0      *
+ 939   The HyiCP-72  219  19400255945 113  W                030202.8-721735030215.4-715409289.93-41.76 5.53  -0.14 -0.51         B3V+A0IV           +0.025+0.014D+.103+012       44  0.0   0.1      *
+ 940 54    AriBD+18  414  19460 93293    I                  030240.9+182441030821.2+184742162.53-33.35 6.27  +1.58 +1.97 +0.70E  M0III              +0.047-0.016 +.032+043V?                        *
+ 941 27Kap PerBD+44  631  19476 38609    I   2368   1055    030244.8+442843030929.8+445126147.12-11.43 3.80  +0.98 +0.83 +0.50   K0III              +0.177-0.157 +.033+029SB   < 17  8.4  27.7      *
+ 942          BD+07  478  19525111002                       030317.3+080508030838.7+082815170.83-41.30 6.28  +1.06 +0.88         G9III              -0.015+0.069      +038                           
+ 943          CD-28 1028  19545168321                       030334.5-281252030750.9-274952222.28-59.84 6.19  +0.16               A5V                +0.075-0.020      +012                           
+ 944 55    AriBD+28  499  19548 757571088                   030335.6+284143030936.7+290437156.01-24.78 5.72  +0.12 -0.15         B8III              +0.019-0.014      -002V                         *
+ 945          BD+27  480  19600 75762                       030410.3+272624031008.8+274912156.90-25.75 6.42  +0.01 -0.01         A0V               v+0.005-0.048      -005       62                 *
+ 946          BD+26  516  19637 75771                       030430.6+263049031027.0+265347157.54-26.48 6.02  +1.28 +1.28         K3III              +0.004+0.070      -016                           
+ 947 28Ome PerBD+39  724  19656 56224    I W                030449.8+391355031117.4+393642150.23-15.73 4.63  +1.11 +1.03 +0.57   K1III              -0.023+0.005 +.023+007V    < 19: 6.1 177.4      *
+ 948          BD+11  445  19698 93320      D                030511.0+112936031038.9+115221168.40-38.41 5.98  -0.06 -0.27         B8V                +0.041-0.026      +001      350                 *
+ 949          BD+47  779  19735 386382225I W                030531.1+472101031226.4+474333146.06-08.71 6.33  +1.43 +1.64         K5III              +0.074-0.083      -036           3.9 202.1AD   5*
+ 950          BD+41  631  19736 38635                       030533.1+415954031209.6+422234148.87-13.30 6.15  -0.09 -0.56         B4V                +0.028-0.013      +006V                         *
+ 951 57Del AriBD+19  477  19787 93328 114I          1066    030554.5+192055031137.8+194336162.60-32.14 4.35  +1.03 +0.87 +0.51   K2III             v+0.152-0.011 +.027+025V?   < 17                 *
+ 952          BD+12  452  19789 93327      D                030552.3+124007031121.9+130252167.61-37.40 6.12  +1.02 +0.84         K0IIIp             -0.013+0.015      +011                          *
+ 953          CD-24 1480  19826168354                       030611.0-240706031035.4-234418214.63-58.50 6.38  +0.93               K0IV               +0.058+0.033      +009V                          
+ 954 56    AriBD+26  523  19832 75788              SX Ari   030616.6+265248031214.2+271525157.68-25.95 5.79  -0.12 -0.42         B9pSi             v+0.010-0.017      +011V     200                 *
+ 955          BD-04  540  198361303282224I   2389           030618.3-041122031118.8-034842184.19-49.29 6.05  +1.66 +1.94         M1III              -0.006-0.014      +024           5.9  24.4      *
+ 956          BD+47  782  19845 38652                       030627.0+474804031324.0+481037145.96-08.25 5.90  +0.97 +0.81         G9III              +0.030-0.022      -010                          *
+ 957          BD-16  587  19887148821                       030638.0-162410031116.8-160131201.29-55.78 6.26  +1.20 +1.27         K0                 -0.014-0.020      -015V?                         
+ 958          BD+06  496  199261110442226I                  030707.9+061704031226.4+063939173.40-41.99 5.56  +1.08 +0.66         K1IIIep+A6V        -0.009-0.004      +005SB  =< 50                 *
+ 959          CP-69  174  19940248742                       030702.4-693846030749.2-691556287.07-43.42 6.15  +1.02 +0.83         K1III              -0.025-0.016      +011V?                         
+ 960          CD-49  884  19948216197                       030712.2-490642031027.4-484403261.22-55.59 6.12  +1.12 +1.03         K1III              +0.034-0.027      +014                           
+ 961          BD+77  115  19978  4875 115    2450   1094    030737.2+772203032019.7+774405130.66 17.16 5.45  +0.19 +0.11         A6V                +0.059-0.061 +.014+004V      37  6.8   1.2AB   3*
+ 962 94    CetBD-01  457  19994130355 116    2406           030740.1-013412031246.4-011146181.50-47.34 5.06  +0.57 +0.12         F8V                +0.196-0.067 +.057+018        7  6.4   3.2      *
+ 963   Alp ForCD-29 1177  20010168373    I   2402   1074    030749.3-292252031204.3-285913224.75-59.04 3.87  +0.52 +0.02 +0.31   F8V                +0.339+0.640 +.075-021        0  2.7   3.6      *
+ 964          BD+56  798  20041 23903        2424           030808.0+564605031548.0+570827141.57-00.41 5.79  +0.73 +0.09         A0Ia               -0.004+0.003      -012           8.2  10.8      *
+ 965          BD+84   59  20084   5501636                   030834.9+843327033220.1+845440126.50 23.20 5.61  +0.92 +0.49         G3IIp:+F0:V        +0.063-0.136 +.026+033SB     80                 *
+ 966          BD+41  638  20063 38674                       030818.4+420749031456.7+423014149.24-12.92 6.07R +1.07      ?        K2III              +0.070+0.012      +022                          *
+ 967          BD+65  338  20104 12686        2436           030845.7+651716031731.6+653931137.24  6.93 6.36  +0.09 +0.07         A3V                -0.010+0.010D+.005-006           0.4   0.5AB   3*
+ 968          CD-44 1025  201212162092228  W                030855.0-444740031225.8-442511253.82-56.96 5.93  +0.44               F7III+A0V          +0.093-0.017D+.025+017SB    151  0.4   0.2AB   3*
+ 969          BD+50  729  20123 23914    I                  030903.0+503400031612.2+505616144.89-05.66 5.03  +1.15 +0.83         G6Ib-IIa           -0.007-0.016 +.010+002SB   < 17                 *
+ 970          CD-36 1208  20144194163                       030906.4-361905031301.5-355638238.21-58.76 6.27  -0.08               B8V                +0.003-0.001      +022V                          
+ 971          BD+30  512  20149 56285                       030914.9+301104031520.5+303324156.23-22.85 5.52R +0.01 +0.09         A1V s              -0.006+0.007      -003SB?    24                  
+ 972 58Zet AriBD+20  527  20150 758101089                   030909.1+204026031454.1+210240162.38-30.62 4.89  -0.01 -0.01 -0.03   A1V                -0.028-0.073 +.020+007V     128                  
+ 973          BD+44  648  20162 38685    I                  030916.7+445833031604.7+452045147.87-10.41 6.16  +1.67 +2.00 +1.02E  M2III              +0.054-0.045      -003                           
+ 974          CD-30 1238  20176168397               1082    030927.6-301039031338.0-294815226.36-58.76 6.16  +1.05               K1IICNIII          +0.027-0.002      +023V?                        *
+ 975          BD+32  591  20193 56293        2431           030936.0+322906031547.0+325123154.91-20.90 6.31  +0.37 -0.02         F4V vw             -0.035+0.009      +014       19  6.5  44.1AC   3 
+ 976          BD+34  610  20210 56296        2433  V423 Per 030945.6+341907031601.9+344119153.87-19.35 6.25  +0.28 +0.12         A1m                +0.043-0.034      +025SBO        7.2  29.3      *
+ 977          CP-57  513  20234233037 118          TW Hor   031001.1-574145031233.2-571918273.30-50.90 5.74  +2.28 +2.83 +1.38   C5II               +0.019+0.009      +014                          *
+ 978          BD+31  576  20277 56308                       031025.4+314900031635.1+321101155.47-21.36 6.06  +0.99 +0.68         G8IV               -0.018-0.108      +019V                          
+ 979          BD+39  743  20283 38700        2443           031039.1+400653031711.4+402900150.73-14.39 6.45                      B9VpSi             +0.015-0.023D+.004-008           0.9   3.8      *
+ 980          CD-26 1210  20293168406                       031042.2-262815031500.2-260601219.41-58.00 6.25  +0.04               A5V                -0.019-0.015      -002      270                  
+ 981          CP-79   91  20313255962      W       BN Hyi   031056.1-792208030732.0-785922295.34-36.05 5.57  +0.30 +0.09         F2II-III           +0.071+0.066      +011SB     47  2.4  15.2      *
+ 982 30    PerBD+43  674  20315 38704                       031103.4+433927031747.4+440130148.85-11.36 5.47  -0.06 -0.35         B8V                +0.032-0.029      -001SB    269                 *
+ 983          BD-06  636  20319130388        2440   1090    031104.1-061718031600.9-055507187.86-49.63 6.17  -0.02 -0.24         B9V                +0.007-0.004 +.039+007V          0.2   0.9      *
+ 984 13Zet EriBD-09  624  203201303871091           1088    031058.5-091128031550.0-084911191.58-51.31 4.80  +0.23 +0.09 +0.13   A5m                -0.002+0.046 +.025-004SBO    66                 *
+ 985          BD+65  340  20336 12704      W       BK Cam   031111.1+651712031959.4+653908137.46  7.06 4.84  -0.15 -0.77 -0.13   B2.5Ven           v+0.015-0.013 +.009-003SB    351  7.7 120.9      *
+ 986          BD+38  690  20346 563222230                   031116.7+385457031745.8+391700151.51-15.34 5.96  +0.07 +0.11         A2IV               +0.022-0.020      +027SB?    35                  
+ 987 29    PerBD+49  899  20365 23944                       031130.2+495121031837.8+501320145.60-06.06 5.15  -0.06 -0.56         B3V                +0.029-0.026      -004SB    156                 *
+ 988 14    EriBD-09  627  20395130395                       031144.9-093128031635.7-090916192.19-51.33 6.14  +0.40 -0.04         F1V                -0.005+0.048      -005    =< 10:                 
+ 989 31    PerBD+49  902  20418 38714                       031200.4+494347031907.6+500542145.74-06.12 5.03  -0.06 -0.54         B5V                +0.023-0.025      +003V     298                 *
+ 990          CD-31 1303  20423194197                       031203.9-311148031611.3-304939228.37-58.26 6.65  -0.07               A0V                +0.030+0.004      +020V?                         
+ 991          BD+33  619  20468 563402232I                  031228.4+335125031843.8+341322154.63-19.43 4.82  +1.49 +1.57 +0.76   K2IICN1            +0.003-0.006 +.012+002     < 17                  
+ 992 95    CetBD-01  469  20559130408    I   2459   1097    031315.3-011740031822.4-005549182.52-46.10 5.38  +1.04 +0.81         G9IV               +0.252-0.052 +.017+020V          2.4   1.2      *
+ 993          CD-29 1216  20606168449                       031349.9-290943031802.8-284749224.61-57.71 5.91  +0.33               F3V+A8-9           +0.185-0.015      +042                           
+ 994 15    EriBD-22 1146  20610168452    I   2463           031356.8-225236031822.1-223041213.26-56.46 4.88  +0.90               G6III              +0.018+0.012 +.028+024V          1.3   0.2      *
+ 995 59    AriBD+26  540  20618 75863                       031357.3+264235031955.8+270416159.34-25.11 5.90  +0.86 +0.51         G6IV               -0.026-0.075      -000V                          
+ 996 96Kap1CetBD+02  518  206301111201093  W        1100    031406.9+030013031921.7+032213178.22-43.08 4.83  +0.68 +0.19 +0.36   G5V               v+0.271+0.092 +.108+020V?   < 17  4.5 268.7AB   3*
+ 997          BD-19  651  20631148897        2465           031407.1-185522031841.2-183335206.62-55.15 5.71  +0.37               F0IV               +0.136-0.053 +.029+018SB         2.3   7.2      *
+ 998          CD-48  900  206402162462233                   031411.0-480705031726.6-474506258.81-54.94 5.85  +1.24               K2III              -0.005+0.021      -009                           
+ 999          BD+28  516  20644 758712234I                  031417.1+284110032020.4+290254158.14-23.46 4.47  +1.55 +1.79 +0.88   K2II-III           -0.008-0.016 -.008-002V?   < 17                  
+1000 60    AriBD+25  536  20663 75875                       031429.7+251809032025.6+253946160.37-26.17 6.12  +1.24 +1.27        gK3                 +0.017-0.087      +026V?                         
+1001          BD+48  893  20675 38753      W                031446.7+484242032152.6+490415146.67-06.74 5.93  +0.43 -0.02         F6V                +0.191-0.070 +.015+024V?         3.5 205.8      *
+1002 32    PerBD+42  750  20677 387502236           1107    031444.4+425806032126.5+431946149.81-11.58 4.95  +0.04 +0.07  0.00   A3V                -0.063-0.006 +.026-007SB?   228                  
+1003 16Tau4EriBD-22  584  20720168460    I   2472  Tau4 Eri 031504.1-220718031931.0-214528212.09-56.00 3.69  +1.62 +1.81 +1.46   M3.5IIIaCa-1      e+0.052+0.033 -.013+042           6.2   5.5AB   6*
+1004          CD-24 1578  20729168462    I          1104    031513.2-242906031934.8-240723216.21-56.59 5.61  +1.66 +2.00 +0.96E  M2III              +0.001-0.025      +015V                         *
+1005 61Tau1AriBD+20  543  20756 758861094  W                031527.1+204712032113.6+210849163.66-29.64 5.28  -0.07 -0.52         B5IV               +0.025-0.024      +014V      20  2.5   0.2 O   3*
+1006   Zet1RetCP-63  217  20766248770    I'W                031535.8-625728031746.2-623431279.12-47.22 5.54  +0.64 +0.06 +0.34   G2.5VFe1Hdel 1     +1.339+0.648 +.097+012           0.3 309.6      *
+1007 97Kap2CetBD+03  461  20791111142                       031552.8+031856032106.8+034032178.32-42.54 5.69  +0.97 +0.76         G8.5III            +0.051-0.026      +011V                          
+1008          CD-43 1028  20794216263 119I'                 031556.0-432708031955.7-430411250.78-56.11 4.27  +0.71 +0.22 +0.40   G8V                +3.043+0.725 +.156+087                          *
+1009          BD+64  391  20797 127431096I          1121    031559.3+641343032440.5+643510138.46  6.44 5.23  +2.08 +2.06 +1.23   M0II               -0.005+0.001 +.009-021                           
+1010   Zet2RetCP-62  265  20807248774      W                031602.3-625317031812.9-623023279.00-47.23 5.24  +0.60  0.00 +0.34   G1V                +1.336+0.645 +.091+012           0.3 309.6      *
+1011          BD+48  899  20809 38768                       031607.8+485120032313.2+491248146.78-06.50 5.29  -0.07 -0.54         B5V                +0.022-0.020      +004SB?   244                 *
+1012 62    AriBD+27  500  20825 75892                       031611.5+271454032211.9+273627159.43-24.38 5.52  +1.10 +0.91         G5III              +0.009-0.014      +006                           
+1013          CD-27 1183  20853168475                       031628.9-265804032045.2-263623220.75-56.82 6.39  +0.54               F7V                +0.043+0.024      +025V?                         
+1014          CP-67  217  208882487762235                   031650.9-671724031759.0-665537283.83-44.38 6.05  +0.13 +0.10         A3V                +0.055+0.007      +024                           
+1015 63Tau2AriBD+20  551  20893 75899    I                  031659.8+202304032245.2+204431164.27-29.73 5.09  +1.24 +1.27         K3III              -0.044-0.022 +.008+002V?   < 19:                 
+1016          CD-24 1600  20894168482                       031701.9-235938032124.0-233807215.54-56.07 5.52  +0.88 +0.59 +0.47   G6.5IIbCN-1Hdel -1 -0.021-0.029      +008V                         *
+1017 33Alp PerBD+49  917  20902 38787 120I W        1125    031710.8+493019032419.4+495140146.57-05.86 1.79  +0.48 +0.37 +0.33   F5Ib               +0.024-0.025 +.016-002V      18 10.0 167.0      *
+1018          CD-26 1257  209801684932237                   031758.3-255644032216.3-253516219.04-56.30 6.35  +0.01               A0V                +0.009-0.002      +025V                          
+1019          BD+33  636  20995 56419        2514           031814.3+331053032429.7+333209156.09-19.30 5.61R -0.03 -0.16         A0V                +0.038-0.028      +002      145  3.5   4.3AB   3*
+1020          BD+53  657  21004 24024                       031819.4+533407032548.4+535518144.50-02.36 6.51  +0.29 +0.07         A9III-IV           +0.088-0.030      -004       97                  
+1021          CD-48  930  21011216278                       031819.5-480804032133.3-474637258.40-54.29 6.39  +1.00               K0III              -0.002-0.023      -002                           
+1022 64    AriBD+24  481  21017 759122240I                  031824.0+242212032418.5+244327161.78-26.39 5.50  +1.19              gK4                 +0.015-0.050      +013V?                         
+1023          BD+04  532  21018111161        2509  Var?     031823.2+043134032339.1+045255177.72-41.26 6.38  +0.86 +0.51         G5III              +0.006-0.008      +003SB         3.2   0.9      *
+1024          BD-08  643  21019130457        2507           031824.7-080840032317.8-074739191.80-49.20 6.20  +0.70 +0.16         G2V                +0.010-0.222 +.034+043V?  =< 10  6.4   3.9      *
+1025   Iot HyiCP-77  134  210242559731095                   031826.6-774512031557.6-772318293.66-37.01 5.52  +0.44  0.00 +0.24C  F4III              +0.109+0.061      +019V       0                  
+1026          BD+40  736  21038 38809                       031832.2+405410032509.4+411526151.58-12.91 6.51                      A0V                -0.005+0.001      -019SB     91                  
+1027 65    AriBD+20  556  21050 75915                       031840.0+202655032426.1+204813164.58-29.43 6.08  -0.04 -0.08         A1V                -0.002-0.006      -009V      44                  
+1028          BD+12  473  21051 934162241                   031839.9+121630032410.1+123746170.87-35.66 6.04  +1.23 +1.09         K0III-IV           +0.028-0.021      +021                           
+1029          BD+48  913  21071 38817                       031851.2+484605032557.4+490715147.20-06.33 6.09  -0.07 -0.49         B7V                +0.026-0.022      -001V?     43                 *
+1030  1Omi TauBD+08  511  21120111172 121I          1134    031925.8+084037032448.8+090144174.12-38.16 3.60  +0.89 +0.61 +0.45   G6IIIFe-1          -0.066-0.078 +.016-021SB1O < 17                 *
+1031          CD-33 1202  21149194268                       031943.7-330343032344.6-324226231.95-56.71 6.50  +1.37               K3III              +0.023-0.005      +018                           
+1032          BD+71  201  21179  4917    I                  031956.8+713056033019.5+715150134.70 12.72 6.32  +1.80 +1.88         M2III              +0.010+0.005      -023                           
+1033          BD+59  657  21203 12770        2538           032015.3+595423032823.6+601520141.25  3.09 6.49  +0.02 -0.23         B9V+A1             +0.018-0.021D+.006+005           1.0   0.2AB   3*
+1034          BD+48  920  21278 38849                       032056.3+484251032803.1+490346147.52-06.19 4.98  -0.09 -0.56 -0.10   B5V                +0.024-0.028      +002SB1O   53                 *
+1035          BD+59  660  21291 24054 122    2544   1152    032058.0+593531032904.1+595625141.50  2.88 4.21  +0.41 -0.24 +0.38   B9Ia               -0.003-0.004      -007       29  4.3   2.4      *
+1036          BD+18  484  21335 934362242  D                032120.6+182424032703.2+184523166.64-30.61 6.57  +0.15 +0.10         A3Vnp              +0.043-0.006      +031      214  0.0   0.1      *
+1037          BD+49  944  21362 38862                       032141.8+493004032852.4+495054147.19-05.46 5.58  -0.04 -0.45         B6Vn               +0.028-0.026      -002SB    355                 *
+1038  2Xi  TauBD+09  439  21364111195 123                   032144.9+092303032710.2+094358174.01-37.25 3.74  -0.09 -0.33 -0.09   B9Vn               +0.060-0.039 -.017-002SB2    33                 *
+1039          BD+12  477  21379 93439                       032148.1+122310032718.7+124406171.47-35.06 6.28  -0.02 -0.07         A0V s              +0.007-0.019      +015SB     59                  
+1040          BD+58  607  21389 24061    I                  032155.4+583155032954.9+585243142.19  2.06 4.54  +0.56 -0.11 +0.50   A0Ia              e+0.006-0.002      -006SB      6                 *
+1041          BD+33  656  21402 56475                       032203.7+332740032820.8+334827156.60-18.61 5.61R +0.02 +0.14         A2V                +0.037-0.057      +006SB                         
+1042   Chi1ForCD-36 1290  21423194289               1142    032203.9-361616032555.8-355515237.74-56.16 6.39  +0.08               A1IV               +0.029-0.007      +025V                          
+1043          BD+58  608  21427 24062        2563   1158    032207.9+590116033011.3+592158141.94  2.49 6.13  +0.08               A2V                +0.036-0.047D+.004+011V          1.4   2.5       
+1044 34    PerBD+49  945  21428 38872        2558           032212.8+490946032922.1+493032147.45-05.70 4.67  -0.09 -0.57 -0.11   B3V                +0.026-0.027 +.018-002V     202  2.1   0.8      *
+1045          CD-27 1228  21430168544                       032209.2-274008032622.5-271903222.37-55.70 5.93  +0.94               G5III              +0.008+0.049      +013V                          
+1046          BD+54  684  21447 24064        2565   1159    032222.4+550621033000.2+552707144.14-00.75 5.09  +0.05 +0.04 -0.01   A1V                -0.046-0.009 +.025+000V     179  4.8  14.8AB   3*
+1047          BD+46  760  21455 38874        2560           032227.5+463531032926.2+465616148.93-07.80 6.24  +0.13 -0.25         B7V                +0.018-0.035      +002      150  5.1  27.9AB   6*
+1048 66    AriBD+22  495  21467 75945        2552           032235.7+222734032826.6+224815163.95-27.29 6.03  +0.95               K0IV               -0.001-0.104      +049SB         1.4   0.0 A   4*
+1049          CD-42 1115  21473216316                       032237.3-415914032611.7-413813247.78-55.30 6.32  +0.06 +0.05         A0V                +0.015+0.027      +012                           
+1050          BD-11  667  21530148972                       032314.8-113758032801.0-111712197.35-50.01 5.73  +1.10 +1.04         K2III              +0.002-0.049      -002V                          
+1051          BD+47  844  21551 38893                       032333.0+474535033037.0+480613148.42-06.73 5.82  -0.04 -0.32         B8V                +0.032-0.029      +005SB    334                 *
+1052 35Sig PerBD+47  843  21552 38890 124I          1167    032331.2+473900033034.5+475943148.48-06.83 4.36  +1.35 +1.54 +0.74   K3III              +0.004+0.020 +.004+016     < 17                 *
+1053          CP-70  230  21563248797                       032336.7-695834032402.5-693729286.07-42.15 6.15  +0.48 +0.25         G0-5+A3-5V         +0.029+0.015      +020                           
+1054   Chi2ForCD-36 1306  215741943122244                   032340.9-360144032733.4-354053237.27-55.85 5.71  +1.29               K2III              +0.081+0.002      +030                           
+1055          BD+72  178  21610  49362251                   032414.4+730029033512.4+732049134.10 14.14 6.57  +0.03 +0.02         A0Vn               +0.013-0.026      -009      145                  
+1056          BD+48  938  21620 38906               1173    032420.8+485201033129.4+491235147.90-05.74 6.29  +0.09 +0.12         A0Vn               -0.005+0.001      -023      230                 *
+1057 NOVA 1901                                     GK Per   0 0 0      0 0 0 0 0      0 0                                                                             +029SBO                       *
+1058   Chi3ForCD-36 1310  21635194318      W                032420.0-361158032811.5-355112237.56-55.71 6.50  +0.13 +0.08         A1V                +0.030-0.003      +015           4.0   6.3       
+1059          BD+48  942  21661 38912                       032439.4+490332033149.1+492403147.84-05.56 6.39  +0.09 -0.14         B9III              +0.012-0.005      -006       25                 *
+1060          BD-07  606  21665130520                       032445.2-070847032939.1-064818191.86-47.34 5.99  +1.02 +0.87         G5                 -0.096-0.104      +026                           
+1061  4    TauBD+10  452  21686 93463                       032456.4+105937033024.5+112011173.32-35.55 5.14  -0.03 -0.07         A0Vn               -0.008-0.018 +.002+000V     236                  
+1062          BD-13  662  216881489852246                   032452.5-130109032936.0-124029199.55-50.32 5.59  +0.17 +0.11         A5IV               +0.005+0.004      +015      181                  
+1063          BD+47  847  21699 38917              V396 Per 032504.4+474057033208.6+480125148.68-06.65 5.47  -0.10 -0.57         B8IIIpMn           +0.020-0.025      +001V      59                 *
+1064          CP-69  192  217222488042243                   032508.2-694110032536.2-692011285.65-42.24 5.96  +0.42 +0.01         F3-5IV             -0.002+0.063      +014V                          
+1065          BD+27  515  21743 75970        2582A          032518.4+271350033120.8+273419161.21-23.17 5.96R                     A2V                +0.041-0.029D+.009+006      100  0.4  11.4      *
+1066  5    TauBD+12  486  21754 93469 125I                  032521.0+123539033052.4+125612172.07-34.32 4.11  +1.12 +1.02 +0.54   K0II-IIIFe-0.5     +0.020-0.002 -.012+015SB1O < 19: 2.0   0.0      *
+1067          BD+05  502  217551112302247                   032526.6+055048033045.4+061119178.04-39.07 5.94  +0.96 +0.64         G8III              +0.045-0.016      +011                           
+1068          BD+58  619  21769 24093        2592A          032531.3+582536033332.1+584554142.64  2.24 6.40  +0.14 +0.15         A4III              +0.008-0.057 +.009+007           1.7  20.4AB   3*
+1069 36    PerBD+45  778  21770 389242249           1182    032530.4+454305033226.3+460325149.87-08.22 5.31  +0.40 -0.02 +0.22   F4III              -0.054-0.079 +.031-049       29                  
+1070 17    EriBD-05  674  217901305281097                   032539.3-052505033037.1-050431189.96-46.18 4.73  -0.09 -0.27 -0.08   B9V s              +0.014+0.007      +015V?     96                  
+1071          BD+57  730  21794 240982252                   032546.3+573142033341.2+575208143.17  1.52 6.37  +0.51 +0.03         F7V                +0.007+0.040      -072    =< 10                  
+1072          BD+44  734  21803 38927              KP Per   032547.0+443056033239.1+445120150.61-09.18 6.41  +0.03 -0.72         B2IV               +0.011-0.013      +002V                         *
+1073          BD+54  693  21819 24099                       032601.9+543808033339.0+545829144.84-00.84 5.98  +0.11               A3V                -0.048-0.005      +014SB2   185                  
+1074          BD+34  674  21856 565311098          Var?     032617.8+350718033240.0+352742156.32-16.75 5.90  -0.06 -0.85         B1V                -0.010+0.001      +025V     150                 *
+1075          CD-43 1085  21882216347                       032625.9-425837032955.0-423803249.21-54.41 5.78  +0.22               A5V                -0.075-0.001      +012      198                  
+1076          CD-41 1029  218992163502248           1179    032639.7-414226033013.6-412212247.06-54.61 6.12  +0.48               F7V                -0.009-0.175      +016                           
+1077          BD+59  675  21903 24111        2612           032650.6+594213033500.8+600228142.05  3.39 6.46  +0.39 -0.07         F3V                -0.035+0.013D+.021+021           0.9   1.1AB   3*
+1078          BD+39  811  21912 565382254          IW Per   032659.3+393344033335.1+395358153.72-13.09 5.81  +0.11 +0.12         A5m                +0.019-0.046      +004SB1O  101                 *
+1079  6    TauBD+08  528  21933111246                       032711.2+090208033236.0+092225175.51-36.55 5.77  -0.08 -0.30         B9IV               +0.033-0.044      +007V      90                  
+1080          BD+75  143  21970  4953                       032721.1+752426033924.8+754423132.81 16.20 6.27  +0.97 +0.65         G9III-IV           -0.015+0.006      +028                           
+1081          CD-47 1071  219812163572250          TU Hor   032724.4-474300033037.0-472231256.87-53.00 5.99  +0.11               A1V                +0.069+0.011      -012V                         *
+1082          CD-26 1333  21997168612                       032737.1-255712033153.9-253651219.83-54.18 6.38  +0.12               A3V                +0.082-0.019      +018V?                         
+1083   Kap RetCP-63  234  22001248819 126  W                032737.7-631724032922.7-625615278.36-45.94 4.72  +0.40 -0.04 +0.18   F5IV-V             +0.383+0.372 +.060+012        0  6.0  60.0      *
+1084 18Eps EriBD-09  697  22049130564 127I A                032813.1-094748033255.8-092730195.86-48.04 3.73  +0.88 +0.59 +0.47   K2V                -0.974+0.021 +.303+015V?   < 17  3.0   2.0      *
+1085          BD+17  575  22072 93494                       032826.4+173018033408.3+174958168.80-30.19 6.17  +0.89 +0.54         K1IVFe-1           +0.089-0.315 +.022+011V?                         
+1086  7    TauBD+23  473  22091 75999        2616   1192    032831.1+240745033426.6+242752163.95-25.14 5.92  +0.13 +0.17         A3V+A3V            +0.008-0.024 +.006+026       31  0.2   0.7AB   3*
+1087 37Psi PerBD+47  857  22192 38980    I         Psi Per  032922.8+475136033629.4+481134149.17-06.09 4.23  -0.06 -0.57 -0.01   B5Ve              v+0.024-0.026      -001V     369                 *
+1088 19Tau5EriBD-22  628  222031686341099                   032922.2-215805033347.3-213758213.52-52.78 4.27  -0.11 -0.35 -0.12   B8V+B8V            +0.048-0.027      +014SB2O   48                 *
+1089          BD+05  511  22211111273                       032930.2+060500033449.2+062504178.70-38.17 6.49  +0.63 +0.16         G0                 -0.007-0.017      -011    =< 10                  
+1090          CD-50 1071  22231233152 128                   032935.8-504304033234.8-502243261.29-51.65 5.68  +1.10 +1.16         K2III              +0.097+0.079      +037V                         *
+1091          BD-10  704  22243149047                       032948.9-101211033437.4-095207196.69-47.90 6.25  +0.02               A2V                +0.018-0.004      +011V?                         
+1092          CP-66  195  22252248825                       032950.0-664941033051.6-662923282.23-43.68 5.83  -0.06 -0.33         B8V                +0.010-0.002      +029                           
+1093          CD-31 1450  22262194375      W                032954.4-312502033356.8-310449229.23-54.48 6.20  +0.48               F5V                -0.021+0.062D+.024-033           0.4   0.1      *
+1094          BD+56  826  22316 24133                       033027.9+563612033819.7+565558144.23  1.13 6.30  -0.13 -0.35         B9p               v+0.022-0.032      -000V?      0:                *
+1095          CD-32 1358  22322194379      W                033033.0-321232033433.5-315229230.61-54.40 6.40  +1.40               K3III              +0.014+0.001      +014           3.8   1.4       
+1096          CP-61  267  223822488342256                   033057.1-612113033251.6-610101275.72-46.68 6.41  +1.04 +0.91         K0III              +0.080+0.036      +031                           
+1097          BD+42  795  22402 38999                       033114.3+421513033800.2+423459152.76-10.44 6.42  -0.06 -0.37         B8Vn               +0.024-0.021      -001                           
+1098          BD-11  696  22409149057                       033111.7-113141033557.7-111137198.66-48.26 5.57  +0.91              gG7                 +0.030+0.084      +037V                          
+1099          BD+00  616  22468111291        2644  V711 Tau 033139.3+001541033647.3+003516184.91-41.57 5.71  +0.92 +0.46 +0.39E  G9V                -0.026-0.164 +.032-023SB2O       2.7   6.6      *
+1100 20    EriBD-17  699  224701490631100          EG Eri   033144.0-174753033617.4-172801207.47-50.85 5.23  -0.13 -0.49         B9.5p              +0.029-0.010 +.014+014       98                 *
+1101 10    TauBD-00  572  224841112921101I                  033146.1+000504033652.4+002406185.12-41.66 4.28  +0.58 +0.07 +0.32   F9IV-V             -0.233-0.483 +.054+028V?      0 10.0 396.0      *
+1102          BD+14  586  22522 93524      D                033210.9+150607033747.8+152551171.46-31.35 6.39  +0.17 -0.06:        A5IV               +0.015-0.020      +033       67  0.0   0.1       
+1103          BD+20  602  22615 76045               1213    033311.7+203523033900.1+205457167.43-27.13 6.50  +0.15 +0.19 +0.07   Am,A5-F0           +0.005-0.026      -009       30                 *
+1104          CP-66  199  22634248842                       033317.0-660546033424.7-654552281.13-43.84 6.75  +0.17 +0.15         A3V                +0.044+0.006      +011V                          
+1105          BD+62  597  22649 12874 129I         BD Cam   033328.3+625333034209.3+631300140.84  6.44 5.10  +1.63 +1.82 +1.39   S3.5/2             -0.020+0.017 +.002-022SB                        *
+1106          CD-40 1008  22663216405 130                   033330.3-403609033705.7-401629244.85-53.51 4.58  +1.04 +0.77 +0.57   K1III              -0.005-0.030 +.011+012                           
+1107          BD+86   51  22701   6233947                   033355.0+861957041001.5+863734125.76 24.91 5.86  +0.37  0.00         F5IV               +0.139-0.084 +.022-004V                          
+1108          BD-07  647  22675130628                       033336.2-074302033829.2-072330194.29-45.81 5.85  +0.98 +0.76        gG5                 -0.009-0.055      -030                           
+1109          CP-78  101  22676255998                       033337.2-784112032958.8-782107293.79-35.80 5.70  +0.93 +0.65         G8III              -0.017-0.028      +010SB                         
+1110          BD+16  484  22695 935362257    2661           033346.3+161241033925.7+163212170.90-30.28 6.16  +1.00 +0.69         K0III              +0.041-0.034      +014           0.0   0.3 O   3*
+1111 21    EriBD-06  713  22713130634                       033404.8-055648033901.1-053734192.27-44.75 5.96  +0.92 +0.66         K1V                -0.015-0.205 +.028+040V?                         
+1112          BD+59  699  22764 24169    I   2691           033428.0+593850034242.7+595810142.87  3.90 5.76  +1.71 +1.82 +1.02   K3IIb              -0.005+0.002      -010           2.4  54.7AD   5*
+1113          BD+37  811  22780 56628               1225    033437.1+371526034107.9+373448156.37-14.04 5.57  -0.07 -0.41         B7Vne              +0.023-0.030      -001      360                 *
+1114   Tau ForCD-28 1225  227891687011102                   033438.0-281611033847.7-275635224.16-53.08 6.01  -0.02               A0V                +0.025+0.023      +039                           
+1115 12    TauBD+02  581  227961113342258                   033438.5+024354033951.1+030325183.01-39.42 5.57  +0.94 +0.67        gG6                 -0.041+0.008      +021V                          
+1116          BD-03  591  22798130639                       033437.8-034258033938.3-032335189.82-43.37 6.23  +1.04 +0.89         G5                 -0.022-0.073      -018                           
+1117          BD-10  717  22799149082                       033438.5-104535033925.4-102614198.28-47.14 6.19  +1.03               G5                 -0.021-0.104      +023                           
+1118 11    TauBD+24  529  22805 760731103  D                033447.8+250022034046.3+251946164.54-23.55 6.11  +0.06 +0.16         A2IV               +0.008-0.015      -005SBO    70  2.0   0.0      *
+1119          BD-01  519  22819130645                       033454.4-012644033959.5-010714187.38-41.97 6.12  +1.00 +0.77         K1III-IV           +0.024+0.016      +026                           
+1120          BD-15  634  229051490942259                   033534.0-153300034011.4-151336204.83-49.12 6.33  +0.88               G5                 -0.005-0.014      -019V                          
+1121 22    EriBD-05  715  229201306522260                   033541.2-053201034038.3-051238192.10-44.18 5.53  -0.15 -0.57         B9IIIpSi4200       -0.003-0.001      +016      121                 *
+1122 39Del PerBD+47  876  22928 39053 131  W       Del Per  033548.1+472804034255.5+474715150.28-05.77 3.01  -0.13 -0.51 -0.11   B5IIIe            t+0.028-0.034 +.016+004SB    259  7.3  99.1      *
+1123 40    PerBD+33  698  22951 56646        2699           033602.1+333839034222.5+335754158.92-16.70 4.97  -0.01 -0.84         B0.5V              -0.005-0.009      +020SB     51  5.0  20.0      *
+1124          BD+66  284  23005 128902267                   033632.7+665317034600.9+671206138.68  9.84 5.80  +0.35 +0.07         F0IV               +0.081-0.113 +.004+006                           
+1125          BD-12  689  23010149107      W                033629.0-120730034113.8-114811200.36-47.40 6.49  +0.36 +0.02?        F5II               +0.073+0.013      +029       82  7.7  14.7      *
+1126 13    TauBD+19  578  23016 935572263                   033632.8+192248034218.9+194201169.00-27.51 5.69  -0.01 -0.27         B9Vne              +0.001-0.014      -010SB    350                 *
+1127          BD+48  984  23049 39063    I   2712           033655.7+481220034406.4+483125149.99-05.06 6.06  +1.55 +1.83         K4III              -0.005-0.010      -012           7.1  18.6AC   3*
+1128          BD-20  687  23055149114                       033654.2-195420034122.4-193505211.27-50.46 6.59  +0.09               A3V                -0.002-0.007      -008V?                         
+1129          BD+62  604  23089 12891    I S                033717.3+630146034602.3+632042141.10  6.81 4.80  +0.80 +0.25 +0.53   G0III+A3V          -0.004-0.013 -.000-002SBO    50  1.0   0.1      *
+1130          BD+45  804  23139 390712266                   033740.0+454700034440.9+460559151.56-06.92 6.11  +0.28 +0.21         A7IV               -0.004-0.024      +009V      81                  
+1131 38Omi PerBD+31  642  23180 56673        2726  Omi Per  033802.7+315818034419.1+321718160.36-17.74 3.83  +0.05 -0.75  0.00   B1III              +0.007-0.011 +.023+019SB2O   85  2.8   1.0      *
+1132 14    TauBD+19  582  23183 93568                       033800.1+192056034347.2+193954169.31-27.30 6.14  +1.01 +0.74         G8III              +0.116-0.054      +078SB                        *
+1133          BD+36  742  23193 566752268                   033802.9+360840034431.4+362736157.64-14.49 5.59  +0.06 +0.15 +0.01   A2m                +0.048-0.040      +022       45                  
+1134   Del ForCD-32 1430  23227194467 133                   033816.2-321528034214.9-315618230.88-52.77 5.00  -0.16 -0.60 -0.15   B5IV               +0.009+0.014      +026SB    217                  
+1135 41Nu  PerBD+42  815  23230 39078 134I   2738   1261    033823.8+421546034511.6+423443153.83-09.63 3.77  +0.42 +0.31 +0.26   F5II               -0.014-0.002 +.020-013       44  8.1  31.4       
+1136 23Del EriBD-10  728  23249130686 135I         Del Eri  033827.4-100606034314.9-094548198.10-46.00 3.54  +0.92 +0.69 +0.50   K0+IV             e-0.092+0.745 +.109-006     < 17                 *
+1137          BD+20  621  23258 76121                       033838.9+203646034428.1+205543168.47-26.26 6.10  +0.01 +0.06         A0V                +0.014-0.020      +015SB     87                  
+1138          BD+70  257  23277  5000                       033849.3+703342034913.8+705216136.55 12.86 5.44  +0.09 +0.12 +0.03   A2m                +0.024-0.065 +.017+017SB2O   25                 *
+1139          BD-10  729  23281149132                       033847.2-104808034333.8-102908199.05-46.28 5.60  +0.22 +0.10 +0.12   A5m                -0.014-0.017      +016       70                  
+1140 16    TauBD+23  505  23288 76126      D        1262    033851.4+235830034448.2+241722166.04-23.73 5.46  -0.04 -0.33 -0.05   B7IV               +0.011-0.046 +.012+003V?    246  2.0   0.0      *
+1141          BD+45  811  23300 39085        2746           033859.3+452205034559.3+454055152.00-07.11 5.66  -0.07 -0.45         B6V                +0.023-0.018      +002           8.4   6.5      *
+1142 17    TauBD+23  507  23302 76131 136  D                033856.1+234757034452.5+240648166.18-23.85 3.70  -0.11 -0.40 -0.10   B6III             e+0.019-0.046 +.020+012SB1O  215  2.0   0.0      *
+1143          CD-37 1415  233191944752265  W                033907.6-373744034250.1-371849239.76-52.69 4.59  +1.20 +1.31 +0.42E  K2.5III            -0.088-0.077 +.028+010           7.6   5.4       
+1144 18    TauBD+24  546  23324 76137      D                033911.6+243132034509.7+245021165.70-23.26 5.64  -0.07 -0.36 -0.07   B8V                +0.020-0.047      -002SB2   246  0.0   0.1      *
+1145 19    TauBD+24  547  23338 76140      W        1264    033915.2+240913034512.5+242802165.98-23.53 4.30  -0.11 -0.46 -0.09   B6IV               +0.018-0.045      +006SB1   133  1.5   0.0 A   3*
+1146 24    EriBD-01  526  23363130698 137                   033925.7-012842034430.5-010947188.32-41.08 5.25  -0.10 -0.39         B7V                +0.002-0.007      +027SB    207                  
+1147          BD+55  824  23383 24215                       033941.8+553639034732.2+555521145.85  1.10 6.10  -0.03 -0.15         B9Vnn              +0.031-0.015      -016V     415                  
+1148   Gam CamBD+70  259  23401  5006 138  W                033947.7+710127035021.5+711956136.31 13.27 4.63  +0.03 +0.07 +0.04   A2IVn              +0.017-0.042 +.012-001V     189  3.9 106.3AC   3 
+1149 20    TauBD+23  516  23408 76155      D        1279    033952.4+240319034549.6+242204166.17-23.51 3.87  -0.07 -0.40 -0.06   B8III             v+0.020-0.046      +008SB     39  0.0   0.0      *
+1150 25    EriBD-00  593  23413130704    I                  033949.6-003641034456.5-001748187.48-40.49 5.55  +1.42 +1.72         K4III              +0.057-0.001      +071V                         *
+1151 21    TauBD+24  553  23432 76159               1283    033956.8+241432034554.4+243317166.05-23.36 5.76  -0.04 -0.23 -0.04   B8V                +0.011-0.042      +009SB    194                 *
+1152 22    TauBD+24  556  23441 76164      D                034005.3+241257034602.9+243141166.09-23.36 6.43  -0.02 -0.15 -0.02   A0Vn               +0.014-0.044      +000V     236  0.0   0.1      *
+1153 29    TauBD+05  539  234661114001104    2750           034021.5+054413034540.4+060300181.28-36.39 5.35  -0.12 -0.61         B3V                +0.019-0.013      +017SB2O  142  7.3  66.2      *
+1154          CP-78  105  234742560052261                   034018.1-783845033630.0-781923293.48-35.59 6.29  +1.15 +1.03         K2III              -0.021+0.001      +003                           
+1155          BD+65  369  23475 12916    I         BE Cam   034021.6+651301034931.2+653134140.02  8.75 4.47  +1.88 +2.13 +1.42   M2+IIab           e-0.007-0.013 +.014-003V                         *
+1156 23    TauBD+23  522  23480 76172      W       V971 Tau 034023.3+233813034619.6+235654166.57-23.75 4.18  -0.06 -0.42 -0.04   B6IVe             v+0.021-0.045      +006V     282                 *
+1157          CD-41 1119  23508216459      W                034034.0-405822034406.2-403937245.19-52.14 6.45  +1.06 +1.01 +0.38E  K1III              +0.008-0.086      +019           3.0   5.1      *
+1158          BD+62  612  23523 12917                       034050.0+625923034936.7+631750141.45  7.03 5.85  +0.18               A5Vn               -0.018-0.051      -014SB    222                  
+1159          BD+06  583  23526111407      W                034049.1+062933034609.5+064811180.67-35.81 5.91  +0.99 +0.76         G9III              +0.019-0.071      -026V?                         
+1160          BD+50  825  23552 24231        2769           034055.8+502536034818.3+504412149.16-02.90 6.14  +0.06 -0.32         B8Vne              +0.014-0.006      -024V     250  6.2   7.0      *
+1161          BD+56  846  23594 24244      W                034121.0+564837034919.6+570705145.30  2.19 6.46  +0.06 +0.02         A0Vn               +0.018-0.027      -002      157  0.8  58.3       
+1162 26Pi  EriBD-12  707  23614149158    I         Pi  Eri  034124.8-122455034608.5-120606201.55-46.47 4.42  +1.63 +2.01 +1.05   M2III              +0.048+0.058 -.000+046                          *
+1163          BD+33  717  23625 56709        2772   1305    034131.9+331724034752.6+333600160.08-16.25 6.57  +0.08 -0.61         B2.5V              -0.006-0.002D+.005+020SB2O  170  4.0   3.2      *
+1164          BD+31  650  23626 56707                       034132.3+315311034748.9+321142161.02-17.33 6.25  +0.47               G0                 -0.032-0.047      -004SB                         
+1165 25Eta TauBD+23  541  23630 76199 139I W                034132.3+234746034729.1+240618166.67-23.45 2.87  -0.09 -0.34 -0.04   B7IIIe             +0.019-0.046 +.008+010V?    215  1.6   0.0 O   5*
+1166          BD+68  286  23662 12929                       034152.7+681208035141.8+683027138.26 11.18 6.32  -0.08 -0.23         B9IVp              +0.017-0.016      -004V?                         
+1167          CD-48 1069  23670216469                       034146.7-482219034450.6-480341256.76-50.51 6.49  +1.02               G8-K0III           +0.028-0.081      +004                           
+1168          CP-54  589  23697233252      W                034200.8-543519034433.8-541626265.80-48.46 6.30  +1.04 +0.89         K1III              +0.023+0.065      +033           3.0   5.0       
+1169          CD-47 1147  23719216470                       034209.4-474016034515.8-472135255.67-50.63 5.73  +0.96               K1III              -0.011-0.020      -003                           
+1170          BD+43  818  23728 39128              V376 Per 034214.0+433916034908.2+435747153.52-08.10 6.02  +0.29 +0.09         A9IV               +0.001+0.021      -015       94                 *
+1171   Sig ForCD-29 1413  23738168820      I                034222.7-293856034627.4-292017226.81-51.61 5.90  +0.12               A3V                +0.004+0.012      -013           5.2   5.0      *
+1172          BD+22  563  23753 76215      D        1321    034225.5+230650034820.9+232516167.33-23.83 5.45  -0.07 -0.32 -0.06   B8V                +0.023-0.050      +004SB?   272  2.0   0.1      *
+1173 27Tau6EriCD-23 1565  23754168827 140                   034232.7-233242034650.9-231459217.34-50.32 4.23  +0.42  0.00 +0.22   F3III              -0.158-0.529 +.059+007        6                  
+1174 30    TauBD+10  486  23793 93611        2778   1327    034247.1+105009034816.3+110836177.17-32.53 5.07  -0.13 -0.60         B3V+F5V            +0.028-0.022D+.011+016V?     52  4.4   9.2      *
+1175   Bet RetCP-65  263  23817248877 141  W                034256.6-650717034412.0-644825279.24-43.54 3.85  +1.13 +1.10 +0.56   K2+III             +0.313+0.076 +.042+051SBO        4.21480.       *
+1176          BD+44  801  23838 39134              Var?     034306.5+443945035004.5+445804153.02-07.22 5.66  +0.76       +0.29E  G2III+F2:V         -0.028-0.028      +014SB  =< 50                 *
+1177 42    PerBD+32  667  23848 56727              V467 Per 034313.2+324705034932.6+330529160.70-16.42 5.11  +0.07 +0.11         A3V                -0.029-0.001 -.003-014SBO    82                 *
+1178 27    TauBD+23  557  23850 76228 142    2786   1345    034312.8+234452034909.7+240312167.01-23.23 3.63  -0.09 -0.36 -0.05   B8III              +0.018-0.047 -.026+009SB1O  212  1.5   0.0 A   3*
+1179          CD-30 1494  23856194531                       034315.7-301232034720.1-295407227.75-51.50 6.55  +0.49 -0.03         F8V                +0.182-0.069      +004V?                         
+1180 28    TauBD+23  558  23862 76229              BU Tau   034314.1+234952034911.2+240812166.96-23.17 5.09  -0.08 -0.28 -0.07   B8Vpe             v+0.013-0.050 -.012+004SB    329                 *
+1181 28Tau7EriCD-24 1877  23878168836              Var      034321.5-241104034739.6-235229218.37-50.30 5.24  +0.07 +0.15         A2                 +0.043+0.048 +.014+029V?      0                  
+1182          BD-00  602  238871114332273                   034331.0-000445034838.9+001340187.65-39.43 5.91  +1.23 +1.31         K3III              +0.063-0.006      +066                           
+1183          BD+23  563  23923 76244                       034347.3+232426034943.5+234242167.37-23.40 6.17  -0.05 -0.19 -0.05   B8V                +0.014-0.049      +009      273                 *
+1184   Rho ForCD-30 1497  239401945352272           1337    034353.6-302808034756.0-301004228.19-51.40 5.54  +0.98 +0.66         G6III              +0.028-0.230 +.008+053                           
+1185          BD+21  535  23950 76250                       034402.2+215624034955.0+221440168.50-24.44 6.07  -0.01 -0.32 -0.01   B8III              +0.015-0.037      -003SB?   165                 *
+1186          CD-36 1453  23958194537                       034403.8-362449034749.6-360621237.74-51.73 6.21  -0.10               B8V                +0.021+0.008      +011V                          
+1187          BD-21  703  23978168851    I                  034411.5-211233034835.8-205411214.04-49.27 5.81  +1.64               K5III              -0.015-0.025      +003V                          
+1188          BD+25  624  23985 76256        2799   1366    034418.1+251640035018.9+253446166.10-21.93 5.26  +0.21 +0.08         A2V+A5V            +0.038-0.109D+.018+004V      69  0.4   0.7      *
+1189          CD-38 1297  24071194550      W     B          034454.1-375540034835.4-373720240.17-51.53 5.40  +0.01 +0.01         A1V                +0.059-0.013 +.024+016        0  0.6   8.0      *
+1190          CD-38 1297  24072194551      W     A  1359    034454.4-375533034835.9-373714240.17-51.53 4.73  -0.03 -0.07 -0.04   B9V                +0.079-0.025 +.024+016      218  0.6   8.0      *
+1191          BD+33  728  24131 56761      W                034530.0+340327035153.7+342133160.23-15.14 5.77   0.00 -0.80         B1V                +0.002-0.007      +018V     140  7.5  15.1      *
+1192          BD+57  752  24141 242761105                   034535.9+574041035343.3+575830145.22  3.22 5.80  +0.18 +0.11 +0.04   A5m                +0.081-0.096      -005       55                  
+1193          BD+21  539  24154 76275      D                034544.0+214349035136.6+220154168.97-24.32 6.83R                     K0III              +0.013-0.019      +063                          *
+1194          BD+12  516  24155 93637              V766 Tau 034542.6+124440035115.8+130245176.12-30.70 6.30  -0.07 -0.48         B9pSi              +0.022-0.030      +016       52                 *
+1195          CD-36 1467  24160194559 143I'                 034542.7-363011034927.3-361201237.88-51.40 4.17  +0.95 +0.69 +0.50   G9II-III           -0.046-0.051 +.025+002                          *
+1196          BD+71  222  24164  50402277                   034542.6+713130035630.2+714918136.36 13.96 6.34  +0.30  0.00         A5m                -0.057-0.008      -002       49                  
+1197          BD+30  582  24167 56762                       034549.6+305206035204.3+311006162.44-17.52 6.25  +0.20 +0.14         A5V                -0.026-0.045      -038      151                 *
+1198          BD+48 1015  24240 39175                       034623.6+482108035338.7+483902151.15-03.98 5.76  +1.05 +0.95         K0III              +0.036-0.029 +.020+008V                          
+1199 31    TauBD+06  594  242631114692275  W                034640.2+061404035200.2+063205182.07-34.88 5.67  +0.06 -0.43         B5V                +0.009-0.008      +016           0.1   0.6       
+1200          CD-36 1476  24305194570                       034653.5-364339035037.6-362531238.24-51.16 6.86  -0.04               B9.5V              +0.004+0.020      +006                           
+1201          BD+16  523  24357 936501106                   034726.8+170146035310.0+171937172.94-27.41 5.97  +0.34  0.00 +0.17   F4V                +0.142-0.030 +.030+035V?     59                 *
+1202 30    EriBD-05  769  24388130789        2832           034745.2-053935035241.6-052141194.49-41.74 5.48  -0.10 -0.41         B8V                -0.011-0.011D+.018+015V     191  6.7   8.3      *
+1203 44Zet PerBD+31  666  24398 56799 144I   2843   1397    034750.6+313512035407.9+315301162.29-16.69 2.85  +0.12 -0.77 +0.09   B1Ib               +0.006-0.010 +.010+020SB     59  6.5  12.9AB   5*
+1204          BD+62  628  24479 129692281                   034835.6+624645035725.5+630420142.28  7.42 5.03  -0.09 -0.16 -0.08   B9.5V             e+0.010+0.005      +005V     113                  
+1205          BD+60  768  24480 12968    I   2867           034836.3+604858035708.3+610632143.53  5.90 5.00  +1.45 +1.26         K3I-II+A3V:        -0.004-0.015 +.015-002V          3.2   1.7      *
+1206          BD-18  691  244971492292276                   034843.5-184354035313.0-182604211.06-47.44 6.22  +0.88              gK+F                +0.011 0.000      +020SB2    15                 *
+1207          BD+47  912  24504 391952279                   034845.8+473440035558.2+475217151.94-04.33 5.37  -0.08 -0.47         B6V                +0.019-0.018      +005SB    286                 *
+1208   Gam HyiCP-74  276  24512256029 146                   034847.0-743244034714.3-741420289.13-37.80 3.24  +1.62 +1.99 +1.09   M2III              +0.047+0.114 +.005+016                          *
+1209          BD+30  591  24534 56815    I   2859  X Per    034907.9+304505035523.0+310245163.08-17.14 6.10  +0.29 -0.82         O9.5ep            v-0.013-0.007 -.002+015SBO   150  5.8  22.5      *
+1210 43    PerBD+50  860  24546 24314    I W                034910.1+502421035636.5+504143150.20-02.10 5.28  +0.41  0.00         F5IV               +0.091-0.130 +.036+027SB2O < 17  4.8  75.3AB   4*
+1211 32    EriBD-03  631  24554130805        2850B          034916.0-031454035417.4-025710192.09-40.10 6.14  +0.09 +0.07         A2V                +0.029+0.008 +.004+018V     180  1.5   6.8AB   3*
+1212 32    EriBD-03  631  24555130806    I   2850A          034916.1-031501035417.5-025717192.10-40.10 4.79  +0.94 +0.69 +0.40   G8III              +0.029+0.002 +.004+027SB   < 17  1.5   6.8AB   3*
+1213 33Tau8EriCD-24 1945  24587168925              Tau8 Eri 034927.3-245429035342.6-243645220.00-49.14 4.65  -0.13 -0.48 -0.14   B6V                +0.023-0.016      +023SB     48                  
+1214          CD-35 1455  246261946082278                   034950.2-350140035338.9-344356235.57-50.53 5.11  -0.13               B6V                +0.031-0.004      +021V?     35                  
+1215          BD+34  768  24640 56824               1418    035001.8+344719035628.7+350452160.47-13.97 5.49  -0.03 -0.75         B1.5V              +0.005-0.001      +017SB    137                 *
+1216          CD-47 1187  247062165401108                   035027.4-471116035333.3-465337254.43-49.37 5.93  +1.24 +1.35 +0.56C  K2III              +0.034-0.043      -001V                         *
+1217          BD-12  752  24712149251              DO Eri   035033.9-122329035516.3-120557202.97-44.47 6.00  +0.32 +0.03?        A5pSrCrEu         v-0.055-0.040      +022    =<  6                 *
+1218 32    TauBD+22  605  24740 763392283                   035057.4+221124035652.1+222841169.59-23.16 5.63  +0.30 -0.02         F2IV               +0.069-0.116 +.030+032V                          
+1219          CD-40 1128  247442165462280  W        1414    035052.9-403904035423.2-402126244.38-50.23 5.71  +0.60               K0III+A3V          -0.012-0.003      +002SB         0.0   0.1AB   3*
+1220 45Eps PerBD+39  895  24760 56840 147    2888  Eps Per  035108.4+394316035751.2+400037157.35-10.09 2.89  -0.18 -0.99 -0.18   B0.5V+A2V          +0.018-0.026 +.009+001SB2   153  5.1   8.8AB   3*
+1221 33    TauBD+22  607  24769 76343      D       V817 Tau 035107.9+225307035703.8+231032169.10-22.63 6.06  +0.02 -0.01         B9.5IV             +0.009-0.018      +025SBO    70  2.0   0.0      *
+1222          BD+24  599  24802 76350                       035127.5+241020035726.4+242743168.19-21.64 6.16  +1.37               K0                 +0.001-0.012      -013                           
+1223          BD+34  773  24809 56847              V386 Per 035136.6+343132035803.1+344852160.90-13.96 6.53  +0.23?              A8V                +0.013-0.018      -002SB2    80                 *
+1224          BD+05  564  24817111516                       035142.3+054506035701.7+060224183.49-34.22 6.09  +0.06 +0.05         A2Vn               +0.036-0.067      +008V?    190                  
+1225          BD-10  793  248321308332284          DL Eri   035150.1-100229035637.9-094503200.29-43.10 6.19  +0.28 +0.14         F1V                +0.042+0.006      +014      120                 *
+1226          BD+38  827  24843 56849                       035149.9+383310035829.1+385025158.23-10.89 6.30  +1.08 +0.98        gK1                 +0.038-0.041      +022                           
+1227          CP-53  628  248632333212282  W        1419    035156.3-525855035434.0-524126262.79-47.64 6.46  +0.16 +0.13         A4V                +0.031-0.041      +021           6.1  22.8      *
+1228 46Xi  PerBD+35  775  24912 56856 148I         Xi  Per  035228.4+353013035857.9+354728160.37-13.11 4.04  +0.01 -0.92 -0.01   O7.5III(n)((f))   e+0.002 0.000 -.004+070SB    216                 *
+1229          BD+38  829  24982 56866        2910           035300.9+383204035940.0+384914158.42-10.75 6.38R +0.10 +0.13         A1Vp:              -0.006 0.000D+.005-002       68  2.7   1.5       
+1230          BD+80  125  25007   650        2963           035317.0+802525041002.8+804155130.51 20.91 5.10  +0.56 +0.30         G8III+A6V          -0.017-0.002 +.005+004       12  0.8   0.8      *
+1231 34Gam EriBD-13  781  25025149283 149I   2904  Gam Eri  035321.8-134734035801.8-133031205.16-44.47 2.95  +1.59 +1.96 +1.00   M0.5IIICa-1Cr-1   e+0.061-0.111 +.010+062           9.5  52.8      *
+1232          BD-05  789  25069130860                       035356.6-054504035852.3-052812195.68-40.48 5.83  +1.00 +0.85         G9V                -0.055-0.180      +036V?                         
+1233          BD+09  524  25102 93710                       035411.5+100245035940.7+101951180.07-30.98 6.37  +0.42  0.00 +0.22   F5V                +0.170+0.004      +040V      54                 *
+1234          BD+36  805  25152 56899                       035441.2+364224040114.7+365924159.90-11.91 6.41  -0.01 -0.07         A0V                -0.022+0.015      -020V      68                 *
+1235          BD-12  766  25165149299    I                  035448.7-125128035930.1-123427204.20-43.75 5.60  +1.48 +1.76         K5III              -0.011-0.032      -005                           
+1236          CP-63  275  25170248912                       035446.0-634511035604.0-632749276.74-43.11 6.14  +1.10 +1.02         K1-2III            +0.072+0.047      -000V                          
+1237          BD+16  544  25175 93716                       035454.0+170052040036.9+171748174.34-26.15 6.32  +0.06 +0.01         A0V                 0.000-0.033      +029V      20                  
+1238          BD+17  666  25202 937212288  W                035502.9+175443040048.8+181138173.65-25.50 5.89  +0.32 +0.04 +0.17   F4V                +0.132-0.028      +025SB2   146  3.3 164.2      *
+1239 35Lam TauBD+12  539  25204 93719 150I'        Lam Tau  035508.3+121228040040.8+122925178.37-29.38 3.47  -0.12 -0.62 -0.09   B3V+A4IV           -0.006-0.012 +.002+018SB2O   87                 *
+1240 36Tau9EriCD-24 2022  252671690172287          Tau9 Eri 035539.6-241759035955.5-240059219.65-47.62 4.66  -0.13 -0.42 -0.13   B6V+B9.5V          +0.015+0.015 +.015+024SBO    25                 *
+1241          BD+68  303  25274 130062291I                  035600.5+682413040603.1+684048139.15 12.18 5.87  +1.54               K2III              +0.002-0.001      -047V                          
+1242          BD+58  690  25291 243842290                   035606.9+585240040427.2+590920145.51  5.03 5.06  +0.50 +0.49 +0.39   F0II               -0.002+0.001      -020        9                  
+1243          BD+09  528  25330111566        2938           035618.7+094303040146.1+095952180.76-30.80 5.67  +0.02 -0.41         B5V                +0.005-0.005      +003           5.2  12.0AB   3*
+1244 35    EriBD-01  572  253401308781111                   035627.9-014947040132.0-013259191.88-37.81 5.28  -0.15 -0.55         B5V                +0.025-0.016      +017V     179                 *
+1245          CP-57  606  253462333471109                   035634.0-572310035842.9-570609268.50-45.53 6.05  +0.44 -0.01         F2IV               +0.029+0.006      +012                           
+1246          CD-30 1597  253711946892289                   035641.2-304620040040.7-302927229.23-48.71 5.93  +0.04               A2V                +0.052+0.004      +021      110                  
+1247   Del RetCP-61  290  254222489181110                   035709.7-614057035844.7-612401274.02-43.78 4.56  +1.62 +1.96 +1.03   M2IIIab            +0.011-0.018 -.001-001                           
+1248          BD+65  391  25425 13015                       035717.3+651450040639.0+653115141.38  9.91 6.17  +0.14 +0.17 +0.06   A3m                +0.030-0.021      -003V?     23                  
+1249          BD-00  632  25457130893                       035729.2-003225040236.7-001608190.74-36.87 5.38  +0.50  0.00         F5V                +0.149-0.251 +.057+018V      23                  
+1250          CD-51  975  25470233354              XY Dor   035734.3-515046040015.7-513353260.82-47.14 6.51  +1.64 +1.95 +0.96E  M1III              +0.027+0.014      +007                          *
+1251 38Nu  TauBD+05  581  25490111579 151                   035750.1+054243040309.4+055921184.68-33.06 3.91  +0.03 +0.07  0.00   A1V                +0.005-0.003 +.030-006       69                  
+1252 36    TauBD+23  609  25555 76425    I   2965           035822.7+234951040421.7+240621169.67-20.79 5.47  +0.86               G0III+A4V          -0.004-0.014 +.014+018V      50  0.0   0.0 O   3*
+1253 40    TauBD+05  584  25558111585                       035826.4+050935040344.6+052608185.31-33.28 5.33  -0.08 -0.57         B3V                +0.003-0.010      +011       51                 *
+1254          BD+07  592  25570111586                       035831.7+075515040356.6+081150182.78-31.53 5.46  +0.37  0.00 +0.21   F2V                +0.169+0.023 +.030+036V?     40                 *
+1255          BD+53  732  25602 24411                       035849.0+534419040636.6+540031149.18  1.40 6.31  +0.99 +0.75         K0III-IV           +0.055-0.099      -008                           
+1256 37    TauBD+21  585  25604 764301112I W                035846.8+214832040441.7+220455171.28-22.15 4.36  +1.07 +0.95 +0.53   K0+III-IIIaFe-0.2  +0.090-0.059 +.013+009     < 17  5.0 137.2      *
+1257          BD+02  645  256211115902292                   035856.0+023319040409.9+024937187.90-34.77 5.36  +0.50 +0.04         F6IV               +0.147-0.125 +.020-018       15                 *
+1258          BD-20  769  25631169071              Var?     035900.3-202511040324.7-200839214.57-45.74 6.46  -0.18 -0.80         B2.5V              +0.003-0.014      +020                          *
+1259          BD-20  770  25661169078                       035912.3-202602040336.8-200930214.62-45.70 7.01  +1.22               K2II               +0.020+0.006      +024                           
+1260          BD+61  676  25638 13031        2984A SZ Cam   035902.7+620333040751.1+621948143.68  7.66 6.99  +0.42 -0.50         B0III              -0.023-0.010      -009SBO   258  0.3  17.9AB  12*
+1261 47Lam PerBD+49 1101  25642 244121113                   035907.8+500448040635.0+502105151.63-01.32 4.29  +0.02 -0.04 +0.02   A0IVn              -0.015-0.036      +006V?    196                  
+1262 39    TauBD+21  587  25680 76438      W        1452    035924.9+214421040520.2+220032171.44-22.10 5.90  +0.62 +0.12         G5V                +0.169-0.136 +.063+026V?      3  2.7 170.1AB   3*
+1263          BD-16  770  257001493452293                   035935.6-165141040408.7-163520209.94-44.34 6.39  +1.26               K2                 +0.093-0.063      +032V?                         
+1264   Gam RetCP-62  312  25705248925    I'        Gam Ret  035926.9-622618040053.8-620934274.81-43.21 4.51  +1.65 +1.81 +1.45   M4III              +0.002+0.026      -007SB                        *
+1265          BD-13  806  25723149351                       035941.9-130401040422.7-124733205.17-42.77 5.61  +1.08 +0.97        gK0                 +0.010+0.013      +032V                          
+1266   Iot RetCP-61  293  25728248927                       035940.8-612132040118.2-610444273.44-43.64 4.97  +1.42 +1.70 +0.73   K4III              +0.067+0.092 +.014+061                          *
+1267          BD-20  774  25803169095                       040017.0-203917040441.0-202254215.03-45.53 6.13  +1.16               K0                 +0.028-0.009      -004V?                         
+1268 41    TauBD+27  633  25823 76455              GS Tau   040028.2+271950040636.4+273600167.43-17.96 5.20  -0.13 -0.47         B9pSi             v+0.019-0.053      -002SB1O   20                 *
+1269 42Psi TauBD+28  619  25867 764612295                   040049.3+284352040700.5+290005166.46-16.90 5.23  +0.34 -0.04         F1V                -0.092+0.007      +009V      68                  
+1270          BD+59  759  25877 24436                       040059.1+593827040927.6+595429145.48  6.01 6.28  +1.14 +0.92         G8IIa               0.000-0.005      -014                           
+1271          CP-85   44  25887258356      W                040055.2-853332034232.1-851544299.20-30.56 6.41  -0.01 -0.10         B9.5IV             +0.013+0.010D+.008+021V          1.5   2.2       
+1272          BD-09  811  259101309482294                   040107.4-090736040556.5-085122200.70-40.65 6.26  +0.06 +0.09         A3V                +0.024-0.008      +028                           
+1273 48    PerBD+47  939  25940 39336 152I         MX Per   040123.9+472644040839.7+474245153.65-03.04 4.04  -0.03 -0.55 -0.02   B3Ve               +0.021-0.030 +.020+001V?    217                 *
+1274          BD-20  780  25944169111                       040123.5-204700040546.7-203044215.32-45.33 6.34  +0.92               G5                 -0.020+0.012      +014                           
+1275          CD-27 1540  25945169110 153                   040130.1-275531040537.4-273906225.31-47.18 5.59  +0.31 +0.05         F1IV               +0.205+0.094 +.045+063V      98                  
+1276          BD+54  740  25948 24440                       040128.4+543352040922.4+544944148.92  2.27 6.18R                     F5V                +0.081-0.093      -005       15                  
+1277 49    PerBD+37  881  25975 57000                       040138.6+372754040815.3+374340160.43-10.42 6.09  +0.95 +0.75         K1III              -0.112-0.191 +.020-040                           
+1278 50    PerBD+37  882  25998 570062297                   040156.5+374641040836.6+380223160.27-10.15 5.51  +0.46 -0.03         F7V                +0.167-0.202 +.049+025       19                 *
+1279          BD+14  657  26015 93775        2999   1466    040202.3+145343040742.0+150946177.38-26.33 6.01  +0.40 +0.02 +0.21   F3V                +0.132-0.024D+.007+036SB1?   25  3.2   3.8      *
+1280          BD+16  560  26038 93777    I   3006           040215.7+170421040759.4+172023175.63-24.83 5.89  +1.50               K5IIIb             +0.007-0.015D+.006-031           0.0   0.1 O   3*
+1281          BD+71  239  26076  5125                       040234.1+715158041344.9+720735137.15 15.10 6.03  +1.01               K1III              +0.013-0.027      -004                           
+1282          BD+68  310  26101 13061                       040247.6+681421041251.6+683006139.73 12.48 6.32  +1.18               K0                 -0.045+0.026      -024                           
+1283 43Ome1TauBD+19  672  26162 937851115                   040320.3+192042040910.0+193633174.00-23.09 5.50  +1.07               K2III              +0.104-0.033 +.023+025V                          
+1284          BD+13  648  26171 937842298                   040326.4+130800040901.6+132354179.11-27.24 5.95  +0.05 -0.06         B9.5V              +0.016-0.014      -025V      27                  
+1285          CD-43 1304  26262216655                       040407.5-431100040725.1-425501247.93-47.57 6.59  +0.93 +0.61 +0.44C  K0III              -0.005+0.004      -007                           
+1286          BD+33  807  26311 570472300I                  040433.7+331931041059.0+333512163.77-13.03 5.72  +1.44 +1.47 +0.79   K1II-III           -0.004-0.009      +020V                          
+1287 44    TauBD+26  686  26322 764851116          IM Tau   040444.3+261312041049.9+262851168.96-18.08 5.41  +0.34 +0.06         F2IV-V             -0.033-0.036      +019        0                 *
+1288          BD-16  796  26326149412                       040445.4-163858040917.8-162309210.32-43.12 5.37  -0.15 -0.53         B4V                +0.002+0.005      +014V      31                  
+1289          BD+83  104  26356   685                       040459.3+833352042813.0+834828128.40 23.40 5.57  -0.13 -0.51         B5V                -0.014+0.010 +.003-007V     320:                *
+1290 37    EriBD-07  758  26409131001                       040529.7-071106041022.5-065526199.19-38.76 5.44  +0.94 +0.67         G8III              -0.003-0.013      -010V?                         
+1291          CD-46 1314  264132166672299  W                040527.7-460744040833.9-455153252.21-47.02 6.59  +0.38  0.00 +0.22C  F2V                +0.075+0.021      +008           4.0   1.2AB   3 
+1292 45    TauBD+05  601  264621116482301  W                040600.8+051546041120.3+053123186.58-31.73 5.72  +0.36 +0.01 +0.19   F4V                +0.149+0.005 +.032+037V?      6  4.1 124.1      *
+1293          BD-09  837  26464131005                       040558.7-090450041047.7-084911201.40-39.58 5.70  +1.06 +0.93        gG9                 +0.038+0.009      +030                           
+1294          CP-64  305  26491248945                       040616.1-642944040721.6-641321276.89-41.65 6.38  +0.64 +0.11         G3V                +0.213+0.324 +.038+028                           
+1295          BD+16  569  26546 93810                       040647.1+170113041231.4+171639176.47-24.06 6.09  +1.08 +0.96         K0III              +0.052-0.018      +027V                          
+1296          BD+57  785  26553 244952304          Var?     040649.2+571219041501.8+572737147.69  4.73 6.08  +0.61 +0.50         A4III              -0.002+0.003      -023       50                 *
+1297          BD+22  649  26571 76505                       040655.3+220923041251.2+222449172.42-20.55 6.12  +0.19 -0.27         B9IIIp:Si:        v-0.005-0.010      +013SB                        *
+1298 38Omi1EriBD-07  764  26574131019 154          Omi1 Eri 040659.0-070554041151.9-065015199.32-38.39 4.04  +0.33 +0.13 +0.16   F2II-III           +0.010+0.082 +.033+011V      96                 *
+1299          CD-35 1588  26575194810                       040702.7-353157041045.8-351626236.63-47.05 6.44  +1.07 +0.96 +0.56   K1+IIIaCH-1.5      -0.019-0.035      +028                          *
+1300          BD-20  801  265911692062302                   040712.7-203658041136.2-202122215.72-43.99 5.79  +0.18 +0.09 +0.05   A2m                +0.050+0.052      -013SB2O   30                 *
+1301          BD+37  897  26605 57081                       040720.5+374241041359.6+375801161.10-09.47 6.45R                     G9III              -0.058 0.000      +029                           
+1302   Del HorCD-42 1400  26612216682                       040728.5-421516041050.6-415937246.50-47.02 4.93  +0.33 +0.07 +0.21   A9V                +0.196+0.063 +.012+037      193                 *
+1303 51Mu  PerBD+48 1063  26630 394041117I   3071   1518    040733.1+480919041453.9+482434153.94-01.82 4.14  +0.95 +0.64 +0.54   G0Ib               +0.005-0.018 +.017+008SB1O   14  6.0  83.8AC   5*
+1304          BD+82  113  26659   693                       040759.1+830600043000.1+832026128.84 23.15 5.46  +0.87 +0.46         G8III              -0.055+0.105 +.015-038                           
+1305          BD+61  687  26670 13075                       040804.5+613556041653.6+615101144.78  8.04 5.70  -0.14 -0.51         B5Vn               +0.011-0.010      -002V?                         
+1306 52    PerBD+40  912  26673 394092306I                  040804.8+401350041453.3+402901159.45-07.54 4.71  +1.01 +0.65 +0.57   G5Ib+A2V           +0.008-0.026 +.004-002SBO =< 50                 *
+1307          BD+09  549  26676 93821                       040805.9+095728041334.8+101244182.69-28.42 6.23  +0.05 -0.33         B8Vn               +0.045-0.026      +003V?    300                 *
+1308          BD+08  651  26677111671        3063           040805.6+083809041331.3+085326183.86-29.25 6.51  +0.16 +0.13         A2m                +0.016-0.027      +008           6.3  54.3AC   3*
+1309 46    TauBD+07  617  26690111672        3064           040809.9+072738041333.1+074258184.93-29.96 5.29  +0.36 +0.01 +0.19   F2V+F5V            -0.002+0.006 +.030+004SB2?   58  0.2   0.1      *
+1310          BD+12  564  26703 93823                       040815.8+122957041349.9+124512180.51-26.76 6.25  +1.16 +1.12 +0.39E  K0                 +0.019-0.028      +048                          *
+1311 47    TauBD+08  652  26722111674    I   3072           040830.0+090037041356.4+091549183.60-28.94 4.84  +0.80 +0.50 +0.45   G5III+A7V?         -0.010-0.038 +.029-007           2.2   1.2AB   3*
+1312          BD-01  600  267391310412305                   040833.4-012416041338.2-010859193.54-35.07 6.44  -0.13 -0.56         B5IV               +0.007-0.004      +018                           
+1313          BD+57  787  26755 24514                       040851.4+573639041708.2+575138147.62  5.21 5.71  +1.09               K1III              +0.030-0.034      -038                           
+1314          BD+53  750  26764 245122310                   040854.8+532139041643.1+533643150.54  2.13 5.19  +0.05               A2Vn               -0.017+0.002 +.011-003SB    191                  
+1315          BD+09  550  26793111680                       040908.2+094532041436.3+100040183.04-28.34 5.22  -0.10 -0.34         B9Vn               +0.002-0.026      +007      350                  
+1316          CD-44 1450  26820216694                       040920.6-443725041231.6-442206249.91-46.51 6.71  +1.48 +1.81 +0.71C  K3-4III            +0.045+0.003      +041                           
+1317          BD+80  133  26836   6912321I                  040937.5+803508042702.8+804927130.89 21.50 5.43  +1.17              gG6                 +0.003-0.019 +.014-009V                          
+1318 39    EriBD-10  867  26846149478    I   3079           040938.2-103016041423.7-101523203.58-39.45 4.87  +1.17 +1.15 +0.57   K3III              -0.009-0.162 +.015+007     < 19: 3.7   6.4AB   3*
+1319 48    TauBD+15  603  26911 93836      W        1537    041005.5+150902041546.3+152402178.59-24.70 6.32  +0.40 +0.02 +0.21   F5V                +0.116-0.029      +036V      53  4.7 151.4AC   3*
+1320 49Mu  TauBD+08  657  269121116961118                   041006.1+083831041532.1+085332184.21-28.85 4.29  -0.06 -0.53 -0.06   B3IV               +0.021-0.024      +017SB?    89                 *
+1321          BD+05  613  26913111695        3085B V891 Tau 041006.4+055706041525.8+061159186.66-30.50 6.93  +0.70 +0.22         G5IV               -0.106-0.107      -008V   =<  6  0.6  64.7AB   4*
+1322          BD+05  614  26923111698        3085A V774 Tau 041009.5+055620041529.2+061112186.68-30.50 6.31  +0.59 +0.05         G0IV               -0.060-0.116      -008        4  0.6  64.7AB   4*
+1323          CD-40 1286  269272167052307                   041009.9-403642041335.7-402128244.07-46.58 6.37  +1.46               K3III              +0.016+0.028      +059                           
+1324          BD+49 1150  26961 24531              b Per    041043.2+500259041814.6+501744153.02-00.09 4.61  +0.04 +0.03 +0.05   A2V                +0.047-0.054      +020SB2O   98                 *
+1325 40Omi2EriBD-07  780  26965131063    I   3093  DY Eri   041040.2-074830041516.3-073910200.72-38.00 4.43  +0.82 +0.45 +0.45   K1-V               -2.242-3.414 +.209-042V          5.0  83.4AB   5*
+1326   Alp HorCD-42 1425  26967216710 155I:                 041041.2-423227041400.1-421740246.88-46.41 3.86  +1.10 +1.00 +0.59   K1III              +0.046-0.209 +.026+022                          *
+1327          BD+64  433  27022 130982315                   041115.6+645347042040.3+650826142.72 10.66 5.27  +0.81 +0.47 +0.43   G5IIb              -0.036-0.003      -019       10                 *
+1328          BD+41  844  27026 39447                       041112.6+415343041808.2+420828158.72-05.93 6.22  -0.08 -0.29         B9V                +0.029-0.034      +007V                          
+1329 50Ome2TauBD+20  724  27045 76532      D       Var?     041123.9+201957041715.6+203443174.61-21.03 4.94  +0.26 +0.11 +0.12   A3m                -0.044-0.058      +016SB     64  2.0   0.1      *
+1330          BD+49 1155  27084 39457                       041142.7+494818041913.3+500256153.30-00.16 5.45  +0.22 +0.12         A7V                +0.061-0.052      -017      120                 *
+1331 51    TauBD+21  618  27176 765412313  W                041228.0+212006041823.2+213445173.99-20.17 5.65  +0.28 +0.08 +0.16   F0V                +0.094-0.037      +035SBO    97  2.0   0.1     3*
+1332          BD-06  862  27179131092                       041225.8-064307041719.2-062819199.76-37.03 5.94  +1.08 +0.94        gG8                 -0.019+0.002      -002                           
+1333          BD+50  973  27192 245442316           1550    041236.7+504041042011.5+505515152.80  0.57 5.55  -0.01 -0.75         B1.5IV              0.000-0.006      -016SB      0                 *
+1334          BD+09  558  27236111729                       041257.5+091434041824.5+092912184.17-27.93 6.54  +0.16 +0.17         A4III              -0.023-0.034      +028                           
+1335          BD+60  800  27245 131132317I          1558    041305.5+602952042147.6+604408146.00  7.67 5.39  +1.49 +1.81         M0III              +0.054-0.117      +029V?                         
+1336   Alp RetCP-62  332  27256248969 156  W                041308.1-624327041425.5-622826274.32-41.65 3.35  +0.91 +0.63 +0.44   G8II-III           +0.045+0.045 +.013+036SB?        8.6  48.5       
+1337          BD+41  852  27278 39468                       041319.8+413359042014.4+414829159.24-05.89 5.92  +0.94               K0III              +0.011-0.026      +024V                          
+1338   Gam DorCD-51 1066  27290233457 157          Gam Dor  041324.3-514419041601.6-512912259.84-44.79 4.25  +0.30 +0.03 +0.16   F4III              +0.106+0.182 +.061+025V?     69                 *
+1339 53    TauBD+20  733  27295 76548                       041332.3+205402041926.1+210832174.52-20.28 5.35  -0.08 -0.25         B9IV               +0.030-0.042      +012SBO     2                 *
+1340          CP-62  334  27304248973      W                041329.3-622634041448.7-621131273.94-41.72 5.45  +1.10 +1.03 +0.39E  K0III              +0.010+0.088 +.006+036           5.6  11.0      *
+1341 56    TauBD+21  623  27309 76551              V724 Tau 041341.4+213155041936.7+214625174.04-19.83 5.38  -0.14 -0.39         A0pSi              +0.030-0.040      +012       53                 *
+1342          BD+56  905  27322 24563                       041343.2+561558042151.8+563024149.03  4.70 5.88R                     A3V                -0.014+0.015      -018V     145                  
+1343 54    PerBD+34  860  27348 57171 158I W                041354.9+341931042024.6+343400164.47-10.95 4.93  +0.94 +0.69         G8III              -0.025-0.005      -027     < 19: 7.9 110.0       
+1344          BD+31  757  27349 57166    I                  041347.9+314242042010.0+315712166.35-12.81 6.16  +1.71               K5                 +0.002-0.008      -018                           
+1345          BD-21  831  27362169317    I          1548    041354.4-205736041815.9-204256216.87-42.62 6.00  +1.67 +1.82         G8III              -0.013+0.012      +025V                         *
+1346 54Gam TauBD+15  612  27371 93868 159I S        1553    041406.0+152311041947.6+153739179.08-23.82 3.65  +0.99 +0.82 +0.47   K0-IIIabCN1        +0.115-0.025 +.028+039SB1 =<  8                 *
+1347 41Ups4EriCD-34 1614  27376194902      W       Var      041406.5-340232041753.7-334754234.67-45.47 3.56  -0.12 -0.37 -0.11   B9V                +0.067-0.008      +018SB2O   31  1.0   0.2AB   3*
+1348 52Phi TauBD+27  655  27382 76558    I   3137           041412.1+270642042021.3+272103169.83-15.94 4.95  +1.15 +1.08         K1III              -0.025-0.080      +003     < 19: 3.7  50.0      *
+1349          BD+09  562  27386 93866    I A                041408.9+095249041937.5+100717183.81-27.30 6.31  +1.43 +1.60         K0                 +0.002-0.040      -027                          *
+1350 53    PerBD+46  872  27396 394832319          V469 Per 041419.0+461536042133.2+462956156.08-02.40 4.85  -0.03 -0.52 -0.05   B4IV               +0.025-0.035      +001       19                 *
+1351 57    TauBD+13  663  27397 93872      W       V483 Tau 041419.7+134739041957.7+140207180.46-24.80 5.59  +0.28 +0.08 +0.16   F0IV               +0.116-0.021      +042SB1?  109  7.9  34.9      *
+1352          BD+59  793  27402 24577        3146   1566    041425.1+592245042257.9+593659146.91  6.99 6.19                      A4V                +0.030-0.038      +012V     150  3.1  32.3ABxC 3*
+1353          CD-23 1856  27411169325                       041421.0-231251041837.4-225813219.84-43.21 6.07  +0.30 +0.20 +0.14   Am                 +0.047+0.029      +039V      56                 *
+1354          BD+18  624  27429 93874                       041436.3+183010042025.1+184433176.61-21.69 6.12  +0.37 +0.02 +0.20   F3:V               +0.108-0.043      +042SB    132                 *
+1355   Eps RetCP-59  324  27442233463      W                041445.4-593233041628.9-591807270.20-42.56 4.44  +1.08 +1.07 +0.53   K2IVa              -0.051-0.164 +.067+029           8.1  13.8       
+1356 58    TauBD+14  682  27459 93876              V696 Tau 041455.9+145121042036.3+150543179.67-24.01 5.26  +0.22 +0.10 +0.12   F0V                +0.108-0.024      +036SB1    65                 *
+1357          CP-61  317  27463248977      W       TT Ret   041450.3-611139041621.1-605655272.30-42.01 6.37  +0.07 +0.01         ApEuCrSr:          +0.041+0.019D+.015+022           0.5   0.4      *
+1358          BD+13  665  27483 93878                       041515.1+133731042052.8+135151180.76-24.74 6.17  +0.46 +0.01 +0.25   F6V                +0.113-0.025      +037SB2O   12                 *
+1359          CD-34 1626  27490194923      W     A          041516.8-340847041903.0-335418234.86-45.24 6.37  +0.13 +0.11         A3V                +0.017-0.006D+.007+016      165  2.1   6.0      *
+1360          BD+05  631  274971117562320                   041521.3+055333042041.2+060751187.61-29.49 5.77  +0.92 +0.68         G8III-IV           -0.012-0.051      +007V                          
+1361          BD+08  672  27505111759                       041522.0+085906042049.0+091332184.81-27.62 6.53  +0.15 +0.11         A4V                +0.054+0.039      +039                           
+1362          BD-06  875  27536131129              EK Eri   041544.1-062902042038.7-061444200.02-36.20 6.27  +0.91 +0.56         G8IV:              +0.103-0.044      +008                          *
+1363          BD-07  798  275631311322322          EM Eri   041551.8-074953042042.8-073533201.50-36.83 5.85  -0.13 -0.49         B5III              +0.002-0.001      +011V?                        *
+1364          CD-44 1503  27588216749      W                041606.7-443026041916.6-441605249.61-45.32 5.34  +1.08 +0.95 +0.51C  K2III              +0.063-0.046 +.005+024           2.4  70.4      *
+1365          CP-53  679  276042334762318  W                041611.9-530611041840.0-525136261.59-44.09 6.09  +0.49               F7IV-V             +0.051+0.073      +021           3.0   0.6       
+1366          BD-00  687  27611131140    I   3152           041620.3-001957042127.1-000553193.75-32.85 5.86  +1.32 +1.52         K3III              -0.016-0.123 +.008-027           5.0 197.8AC   3*
+1367          BD-20  831  27616169354 161                   041617.2-205241042039.0-203823217.01-42.07 5.38  -0.02               A2V                +0.025-0.011 +.007+032V     164                  
+1368 60    TauBD+13  668  27628 93892      W        V775 Tau041625.3+135027042203.5+140438180.78-24.38 5.72  +0.32 +0.10 +0.17   A3m                +0.113-0.026      +041SB1O   25  7.1 109.2AC   3*
+1369 59Chi TauBD+25  707  27638 76573        3161           041629.7+252337042234.9+253745171.51-16.74 5.37  -0.05 -0.08         B9V                +0.017-0.023      +017V     350  3.0  19.4     3*
+1370          BD+20  744  27639 76571    I   3158           041629.6+203506042222.8+204917175.26-19.97 5.91  +1.66               M0IIIab+A,F        +0.001+0.001 +.015-009           3.0   2.0      *
+1371          BD+42  946  27650 39501        3172           041638.0+421138042335.9+422541159.24-05.01 6.23   0.00 -0.15         A1pSi              +0.024-0.032D+.002-012V      40  0.5   0.4       
+1372   The RetCP-63  316  27657248986      W        1556    041633.0-632953041740.2-631520275.09-41.01 5.87  -0.07 -0.26         B9III-IV           +0.002+0.027      +003V          1.8   3.9       
+1373 61Del1TauBD+17  712  27697 93897 162I W        1582    041709.9+171829042256.1+173233178.01-22.01 3.76  +0.98 +0.82 +0.47   K0-IIICN0.5        +0.107-0.030 +.021+039SBO =<  8  8.7 109.6AB   3*
+1374          CD-26 1642  27710169368        3159AB 1574    041722.2-255749042131.3-254342223.73-43.30 6.01  +0.35  0.00         F0IV-V             +0.048-0.050 +.057+018V      46  0.3   0.6AB   4*
+1375          BD+20  751  27742 76585      D                041738.7+204456042332.4+205856175.32-19.66 5.99  +0.03 -0.26         B8IV-V             +0.016-0.028      +018V     175  0.0   0.2       
+1376 63    TauBD+16  586  27749 93900              Var?     041740.7+163238042325.0+164638178.73-22.41 5.64  +0.30 +0.13 +0.16   A1m                +0.104-0.028      +035SB1O   10  2.0   0.0      *
+1377 55    PerBD+33  853  27777 57212                       041759.7+335357042429.2+340750165.38-10.65 5.73  -0.06 -0.34         B8V                +0.019-0.044      +005      250                  
+1378 62    TauBD+23  684  27778 76591        3179A          041757.8+240405042359.8+241804172.76-17.39 6.36  +0.17 -0.35         B3V                +0.006-0.010      +016V          1.9  29.1AB   4*
+1379 56    PerBD+33  854  27786 57216        3188   1592    041808.3+334346042437.4+335735165.53-10.75 5.76  +0.40 -0.12         F4V                +0.043-0.072 +.005-032           3.6   4.9      *
+1380 64Del2TauBD+17  714  27819 93907      W                041819.7+171245042405.8+172638178.29-21.86 4.80  +0.15 +0.12 +0.07   A7V                +0.110-0.038 +.017+039SB     59  8.5 143.0      *
+1381 66    TauBD+09  570  27820111791        3182           041824.6+091342042351.9+092739185.11-26.88 5.12  +0.07 +0.11 +0.05   A3V                -0.015-0.008 +.001-004V      83  0.1   0.3      *
+1382          BD+57  800  27855 246152324    3203           041842.4+572124042700.9+573507148.74  5.96 6.32  +0.04 +0.02         A0III              +0.009-0.012      -001           5.9  20.6      *
+1383 42Xi  EriBD-04  818  278611311761120           1590    041842.0-035836042340.8-034444197.82-34.30 5.17  +0.08 +0.08 +0.03   A2V                -0.050-0.057 +.013-011SB?   173                 *
+1384          CD-25 1862  278811693912323I          1588    041854.8-250730042305.7-245332222.75-42.75 5.83  +1.51               K5                 +0.018-0.015      +029V                         *
+1385          BD+18  633  27901 93918                       041907.3+184844042457.1+190230177.12-20.68 5.98  +0.37 +0.04 +0.22   F4V                +0.105-0.044      +037SB?   125                 *
+1386          CD-35 1687  27941194971      W                041927.5-354639042307.7-353242237.28-44.56 6.39  +1.24               K1III              -0.006 0.000      +017           7.0  18.7       
+1387 65Kap1TauBD+21  642  27934 76601        3201   1593    041924.4+220354042522.1+221738174.56-18.48 4.22  +0.13 +0.13 +0.05   A7IV-V             +0.096-0.048 +.025+040SB?    81  0.0   0.1 O   6*
+1388 67Kap2TauBD+21  643  27946 76602        3201   1594    041927.4+215817042525.0+221159174.65-18.54 5.28  +0.25 +0.10 +0.14   A7V                +0.109-0.054      +032V     153  0.0   0.1 O   6*
+1389 68Del3TauBD+17  719  27962 93923        3206  V776 Tau 041942.1+174158042529.4+175541178.12-21.30 4.29  +0.05 +0.08 +0.01   A2IV               +0.108-0.028D+.019+035SB     18  3.7   1.5AB   3*
+1390          BD+31  776  27971 572292325                   041944.2+311248042606.3+312620167.62-12.24 5.28  +0.97 +0.80         K1III              +0.076-0.110      +028V    < 19:                 
+1391 70    TauBD+15  621  27991 93925      W                041954.7+154245042537.3+155627179.79-22.54 6.46  +0.49 +0.02 +0.25   F7V                +0.107-0.028 +.038+038SB?    15  0.0   0.1AP   3*
+1392 69Ups TauBD+22  696  28024 766082326  W       Ups Tau  042019.3+223513042618.5+224849174.30-17.98 4.28  +0.26 +0.14 +0.14   A8Vn               +0.107-0.046 +.036+035SB1   196  1.9   0.0     3*
+1393 43    EriCD-34 1664  280281949841121                   042016.8-341456042402.2-340101235.17-44.23 3.96  +1.49 +1.80 +0.83   K4III              +0.069+0.051 -.008+024                          *
+1394 71    TauBD+15  625  28052 93932      W       V777 Tau 042038.8+152329042620.8+153706180.18-22.60 4.49  +0.25 +0.14 +0.15   F0V                +0.112-0.023 +.007+038SBO   192  2.0   0.1     3*
+1395   Eta RetCP-63  324  28093249009 163                   042048.3-633725042153.3-632311275.01-40.52 5.24  +0.96 +0.69         G8III              +0.089+0.173 +.016+045                          *
+1396 73Pi  TauBD+14  697  28100 93935    I                  042057.3+142916042636.4+144249180.99-23.12 4.69  +0.98 +0.72 +0.51   G7IIIaFe-1         -0.002-0.033 +.014+032     < 17                  
+1397          BD+08  687  281141118172327                   042055.5+082147042621.1+083525186.30-26.90 6.06  +0.02 -0.42         B6IV               -0.001-0.006      +014       25                  
+1398          CD-35 1704  28143194996      W                042114.1-345859042456.4-344528236.23-44.12 6.55  +0.44               F2III              -0.013-0.110      +007V          3.4  39.5AB   3*
+1399 72    TauBD+22  699  28149 76613      D                042118.5+224615042717.5+225947174.31-17.69 5.53  -0.10 -0.48         B7V                +0.006-0.017      +005V     230                 *
+1400          BD+01  753  28191111827                       042148.6+015119042700.7+020446192.50-30.50 6.23  +1.09 +1.03         K1III              +0.065-0.047      +021                           
+1401          BD+72  227  28204  52382333    3267           042154.6+721847043330.7+723143137.89 16.48 5.94  +0.30 +0.18         A8m                +0.027-0.089      +010SB1O   31  6.6  26.0      *
+1402          BD+10  577  28217 93943        3228           042157.4+105916042728.8+111245184.16-25.11 5.88  +0.05 -0.33         B8IV               -0.003-0.003D+.003+004V      70  1.8   0.4      *
+1403          BD+21  647  28226 76618      W                042204.5+212349042800.8+213712175.52-18.46 5.72  +0.27 +0.10 +0.14   Am                 +0.095-0.038      +036SB2    88  0.8   0.0 A   3*
+1404          CD-44 1546  28246216790                       042210.4-442323042519.1-440939249.35-44.24 6.39  +0.44               F6V                +0.035+0.067      +013                           
+1405          CP-57  659  28255233506      W     A          042215.1-571751042412.2-570417266.91-42.27 6.29  +0.66 +0.19         G4V                -0.098-0.077 +.042-004           0.4   5.8      *
+1406          BD+30  665  28271 57249        3243A          042233.0+300822042851.9+302141168.85-12.53 6.40  +0.52 +0.08         F7V                +0.010-0.023D+.016-037SB     40  1.8  14.7AB   4*
+1407 75    TauBD+16  605  28292 93950    I D        1609    042243.3+160810042826.4+162135179.90-21.75 4.97  +1.13 +1.10         K2III             v+0.006+0.028      +018V    < 19: 2.5   0.0      *
+1408 76    TauBD+14  702  28294 93948                       042243.3+143107042823.4+144427181.26-22.77 5.90  +0.32 +0.06 +0.19   F0IV               +0.108-0.024      +044V     102                 *
+1409 74Eps TauBD+18  640  28305 93954 164I W                042246.5+185731042837.0+191049177.60-19.92 3.53  +1.01 +0.88 +0.50   G9.5IIICN0.5       +0.107-0.038 +.020+039V?  =<  8  7.0 181.6      *
+1410          CD-24 2343  28312169455        3230           042244.6-241820042657.0-240453222.00-41.69 6.11  +0.14               A2                 -0.003-0.015D+.019-004           0.2   0.4      *
+1411 77The1TauBD+15  631  28307 93955    I W                042251.6+154425042834.5+155744180.26-21.97 3.84  +0.95 +0.73 +0.47   K0IIIbFe-0.5       +0.103-0.027 +.038+040SB1 =<  8  0.4 337.4AB   4*
+1412 78The2TauBD+15  632  28319 93957      W       The2 Tau 042257.0+153857042839.7+155215180.35-22.01 3.40  +0.18 +0.13 +0.09   A7III              +0.103-0.025 +.029+040SB1O   78  0.4 337.4AB   4*
+1413          BD+01  755  28322111840                       042252.3+013807042803.6+015131192.88-30.40 6.15  +1.02 +0.81         G9III              +0.027+0.004      +030                           
+1414 79    TauBD+12  598  28355 939602330                   042313.9+124934042850.2+130251182.78-23.73 5.03  +0.23 +0.12 +0.08   A7V                +0.105-0.016      +033V?    104                 *
+1415          BD+01  757  283751118451123                   042321.9+010933042832.1+012251193.42-30.57 5.55  -0.10 -0.55         B3V                +0.019-0.021      +018SB     26                 *
+1416          CP-61  335  28413249016                       042341.9-612752042505.3-611418272.18-40.92 5.94  +1.54 +1.85         K4-5III            -0.024+0.014      -019                           
+1417  1    CamBD+53  779  28446 24672 165    3274A Var?     042406.4+534137043201.8+535439151.91  3.95 5.77  +0.18 -0.73         B0III               0.000-0.003D+.006-007SB    275  1.1  10.3AB   3*
+1418          CD-47 1383  284542168092329                   042409.6-470946042706.0-465651253.17-43.71 6.10  +0.46               F5-6V              +0.068-0.275 +.032+016                          *
+1419          BD+32  806  28459 57269      W                042413.1+321422043038.3+322729167.52-10.85 6.21  -0.04 -0.13         B9.5Vn             -0.004-0.011      +023V     350                 *
+1420          BD+10  583  28475 93968                       042412.9+101807042942.9+103118185.13-25.09 6.79  +0.09 -0.37         B5V                +0.004+0.001      +015V                          
+1421          BD-19  931  28479149668                       042415.0-194036042839.0-192730216.34-39.91 5.96  +1.22               K1III              +0.028-0.090      +026SB                         
+1422 80    TauBD+15  636  28485 93970        3264           042426.4+152511043008.6+153817180.78-21.88 5.58  +0.32 +0.10 +0.19   F0V                +0.102-0.024 +.031+030SB1   134  2.2   1.7      *
+1423          BD-13  893  284971496742332          DU Eri   042428.2-131607042906.9-130254208.78-37.40 5.60  -0.23 -0.89 -0.10   B1Vne             v+0.002 0.000      +022      340                 *
+1424          BD+39 1013  28503 57278        3273A          042433.9+394735043124.0+400037162.01-05.62 6.26  +0.04 -0.36         B8V                -0.006-0.014      -012V          0.5   9.3      *
+1425          BD+09  590  28505 93971                       042433.1+100243043002.4+101545185.41-25.18 6.48  +1.03 +0.82         G8III              -0.007-0.067      -063                           
+1426   Del MenCP-80  116  28525258372 166           1591    042444.0-802654041759.1-801250293.80-32.90 5.69  +0.84 +0.53         K2-3III+A          +0.018+0.061      -020SB                         
+1427          BD+15  637  28527 93975      W        1627    042450.1+155835043033.7+161138180.38-21.45 4.78  +0.17 +0.13 +0.07   A6IV               +0.107-0.027 +.053+038SB     71  0.0   0.0 O   3*
+1428 81    TauBD+15  639  28546 93978      W                042456.5+152828043038.9+154131180.82-21.75 5.48  +0.26 +0.10 +0.12   A5m                +0.103-0.023      +039V?     21  3.9 162.0      *
+1429          CD-42 1510  28552216821               1615    042452.9-421051042809.4-415736246.27-43.80 6.44  +1.64 +1.95         M1III              -0.011-0.006      +097                           
+1430 83    TauBD+13  690  28556 93979      W                042459.5+133025043037.3+134328182.49-22.97 5.40  +0.26 +0.10 +0.14   F0V                +0.106-0.023      +039V      95  5.8 111.9      *
+1431          BD-13  896  28625149682                       042532.5-134837043009.7-133532209.54-37.39 6.24  +1.00 +0.73         G5                 -0.025+0.009      +014V?                         
+1432 85    TauBD+15  645  28677 93993               1640    042608.9+153813043151.8+155106180.88-21.42 6.02  +0.34 +0.04 +0.20   F4V                +0.101-0.027      +036SB1   109                 *
+1433          CD-46 1427  28700216832                       042622.4-464403042920.0-463055252.54-43.37 6.16  +1.06               K1III              +0.046+0.030      +011                           
+1434 57    PerBD+42  990  28704 396041124  W                042622.6+425102043324.9+430350160.02-03.27 6.09  +0.38 +0.01         F0V                +0.004+0.004      -023V          0.7 116.2AB   4 
+1435          CP-62  357  28732249029      W                042636.1-624427042745.9-623115273.64-40.20 5.75  +1.01 +0.82         K0III              -0.019+0.014      +001           6.7  10.2       
+1436          BD+05  674  28736111879                       042645.2+051144043204.8+052436190.14-27.59 6.39  +0.42  0.00 +0.25   F5V                +0.114+0.009      +040V      35                 *
+1437 45    EriBD-00  713  28749131270    I                  042645.6-001530043152.7-000238195.34-30.63 4.91  +1.32 +1.44 +0.67   K3II-III           +0.003-0.009 -.009+017     < 17                  
+1438          BD-13  904  28763149702        3284           042648.8-135129043125.9-133842209.75-37.13 6.21  +0.12 +0.09         A3V                -0.011-0.063      -015           3.2  29.1       
+1439          CD-35 1768  287761950852334  W                042701.7-355213043040.3-353913237.62-43.04 5.96  +1.00               K0II                0.000+0.031      -008           8.3  36.6       
+1440          BD+63  515  28780 131962336                   042701.5+640309043624.2+641542144.54 11.30 5.94  -0.03 -0.02         A1V                -0.026-0.009      -016V   =< 41                  
+1441          BD-03  809  28843131279      W       DZ Eri   042737.2-032519043237.4-031233198.62-32.10 5.81  -0.14 -0.54         B9III             v-0.005-0.006      +018V?         3.4 124.5      *
+1442          BD+17  750  28867 94002        3297           042745.5+174820043332.9+180100179.34-19.76 6.25  +0.07 -0.10         B9IVn              +0.011-0.024D+.002+015V          0.1   3.1      *
+1443   Del CaeCD-45 1567  28873216850 167          Var?     042746.3-451006043050.1-445714250.37-43.22 5.07  -0.19 -0.78         B2IV-V             +0.007-0.008      +014       36                  
+1444 86Rho TauBD+14  720  28910 940071125          Rho Tau  042810.3+143803043350.9+145040182.05-21.67 4.65  +0.25 +0.08 +0.12   A8V                +0.103-0.027 +.026+040SB2O  117                 *
+1445          BD+28  666  28929 76654        3304           042822.4+284507043438.0+285740170.77-12.53 5.88  -0.06 -0.36         B9pHg              +0.002-0.025      +013V      76  4.9  25.3AB   3*
+1446          BD+09  600  28930111890                       042820.6+091213043348.1+092447186.77-24.93 6.01  +1.06 +0.82         G8III              -0.016-0.043      -026                           
+1447          BD-11  900  28970149725    I                  042838.5-105949043322.0-104709206.78-35.50 6.06  +1.38 +1.45         K0                 -0.005+0.015      -003V?                         
+1448          BD+05  679  289781118962335                   042849.1+052132043408.3+053407190.32-27.08 5.68  +0.05 +0.11 +0.04   A2V s              -0.010-0.005      -008       36                 *
+1449 46    EriBD-07  838  29009131309        3305  EH Eri   042902.2-065655043354.8-064420202.47-33.55 5.72  -0.13 -0.46         B9pSi               0.000-0.007      +002V          4.8   1.2      *
+1450          BD-07  841  29063131317    I                  042922.1-070245043414.2-065016202.62-33.52 6.09  +1.38 +1.64         K2III              -0.018-0.037      -004                           
+1451 47    EriBD-08  887  290641313152337I         DV Eri   042922.6-082626043411.6-081353204.10-34.18 5.11  +1.70 +2.02 +0.97E  M3III              -0.018-0.001 +.006-012V                         *
+1452          BD-09  930  29065131316    I                  042924.4-091034043411.7-085813204.90-34.51 5.26  +1.47 +1.73         K4III              -0.037-0.111 +.010-027V    < 19:                 
+1453 50Ups1EriCD-30 1883  29085169570    I          1650    042935.1-295807043330.6-294600229.85-41.59 4.51  +0.98 +0.72 +0.54   K0IIICN-1          -0.102-0.275 +.028+021                           
+1454 58    PerBD+40 1000  29094 396392338I A                042945.5+410334043641.4+411553161.76-04.03 4.25  +1.22 +0.82 +0.69   K4III+A3V          -0.005-0.016 +.016+005SBO =< 50        0.1      *
+1455          BD+19  742  29104 94022        3316           042950.7+194031043542.7+195254178.14-18.19 6.36                      G5II-III+A-F       -0.001-0.017      -002SB         0.5   0.3      *
+1456   Nu  MenCP-81  115  29116258378                       042949.1-814825042057.9-813448295.07-32.05 5.79  +0.35 +0.05         F0-2III            +0.003+0.127      +014                          *
+1457 87Alp TauBD+16  629  29139 94027 168I   3321  Alp Tau  043010.9+161830043555.2+163033180.97-20.25 0.85  +1.54 +1.90 +0.94   K5+III            v+0.063-0.190 +.048+054SB   < 17  9.8 121.7AC   6*
+1458 88    TauBD+09  607  29140 94026        3317   1658    043009.5+095720043539.3+100939186.40-24.13 4.25  +0.18 +0.11 +0.10   A5m                +0.055-0.046 +.036+029SB2O   35  3.6  69.7      *
+1459          BD+23  715  29169 76670               1663    043027.6+230813043629.2+232027175.47-15.85 6.02  +0.38 +0.02 +0.21   F5IV               +0.112-0.055      +043V      80                 *
+1460          BD-10  959  29173131335        3318A          043028.1-095633043514.0-094412205.87-34.63 6.37  +0.11 +0.10         A1m                +0.021-0.023      +026V      15  1.0  12.8      *
+1461          BD-20  880  29184169584                       043037.8-200747043500.5-195514217.55-38.65 6.13  +1.17               K3III              +0.081+0.081      +074V?                         
+1462          BD-03  830  29227131344        3328           043102.4-034900043601.6-033643199.53-31.57 6.33  -0.10 -0.43         B7III              -0.007-0.013      +020           4.7  17.9AB   4*
+1463 48Nu  EriBD-03  834  29248131346 169  W       Nu  Eri  043119.3-033325043619.1-032109199.31-31.38 3.93  -0.21 -0.89 -0.19   B2III              +0.002-0.005      +015SB     25  9.2  50.9      *
+1464 52Ups2EriCD-30 1901  29291195148 170I                  043139.7-304601043533.0-303344231.01-41.31 3.82  +0.98 +0.72 +0.49   G8IIIa             -0.045-0.012 -.014-004                          *
+1465   Alp DorCP-55  663  29305233564 171  W       Alp Dor  043150.0-551506043359.8-550242263.83-41.42 3.27  -0.10 -0.35 -0.09   A0IIISi            +0.051-0.003 +.018+026       82  0.5   0.2     3*
+1466  2    CamBD+53  794  29316 24744        3358           043202.4+531634043958.1+532823153.03  4.53 5.35  +0.32 +0.07         A8V                +0.046-0.092 +.019+020V     112  1.6   0.3AB   4*
+1467  3    CamBD+52  865  29317 24743    I   3359   1681    043201.9+525249043954.7+530447153.32  4.26 5.05  +1.07 +0.89         K0III              -0.002-0.013 -.008-041SB1O < 17  7.0   3.8      *
+1468          BD+76  174  29329  5289                       043208.1+762520044600.3+763640135.05 19.65 6.49  +0.51               F7V                +0.064-0.136 +.015-006       64                  
+1469          BD+00  798  293351119282339           1671    043204.4+004745043713.7+005954195.13-28.94 5.31  -0.12 -0.45         B7V                -0.004-0.004      +024V     136                 *
+1470          BD+26  731  29364 76682        3353   1676    043218.8+264427043829.6+265624172.92-13.20 6.47R                     F2V:               +0.047-0.058D+.021+004SB         0.1   4.0      *
+1471          BD+20  785  29365 766802341          HU Tau   043221.7+202902043815.8+204105177.88-17.22 5.92  -0.05 -0.35         B8V                -0.015-0.007      -002SBO    70  1.5   0.0      *
+1472 89    TauBD+15  661  29375 94043      W                043225.8+154958043809.4+160200181.72-20.12 5.79  +0.31 +0.06 +0.16   F0V                +0.093-0.023      +038V     115  5.9 140.5      *
+1473 90    TauBD+12  618  29388 940442342  W                043234.0+121837043809.5+123039184.74-22.24 4.27  +0.12 +0.13 +0.05   A6V                +0.103-0.013 +.024+045SB1    79  5.7 119.8AC   3*
+1474 51    EriBD-02  963  29391131358        3350           043234.1-024024043736.1-022824198.61-30.66 5.23  +0.28 +0.04         F0V                +0.042-0.061 +.034+021       95  5.9  80.0AC   3*
+1475          CP-63  342  29399249054      W        1659    043231.2-630146043334.0-624925273.74-39.47 5.79  +1.04 +0.90         K1III              -0.115-0.023      +031           3.6  31.9       
+1476          CD-30 1911  29435195163                       043257.9-305508043650.9-304300231.28-41.06 6.30  -0.10               B9IV-V             -0.011+0.013      +015                           
+1477          BD+24  674  29459 766892343                   043317.1+250111043923.1+251306174.41-14.15 6.22  +0.16 +0.11         A5Vn               +0.017-0.015      +021V     160                  
+1478 91Sig1TauBD+15  665  29479 94051      W                043326.5+153611043909.2+154759182.07-20.07 5.07  +0.15 +0.20         A4m                +0.039-0.072 +.021+019SBO    60  0.4 431.2AB   3*
+1479 92Sig2TauBD+15  666  29488 940542345  W                043333.2+154312043916.5+155505181.99-19.97 4.69  +0.15 +0.13 +0.07   A5Vn               +0.083-0.018 +.020+036SB2   117  0.4 431.2AB   3*
+1480          BD+07  681  294991119542344  W                043341.1+074020043906.2+075215188.99-24.76 5.39  +0.26 +0.13 +0.12   A5m                +0.094-0.003      +036V      55  3.5 297.8AC   3*
+1481 53    EriBD-14  933  29503149781 172I W                043336.0-142958043810.8-141814211.32-35.89 3.87  +1.09 +1.01 +0.56   K2IIIb             -0.075-0.156 +.044+042SB1  < 17  3.4   0.8      *
+1482          BD+48 1128  29526 396882347                   043356.4+480623044124.1+481803157.06  1.28 5.67  -0.02 -0.02         A0V                +0.042-0.042      +023V      65                  
+1483          BD-12  955  29573149789                       043413.7-121916043853.6-120723208.96-34.85 5.01  +0.07 +0.09 +0.05   A2IV               -0.053-0.011 +.028+007V      43                  
+1484 93    TauBD+11  639  29589 94063                       043429.2+120005044003.4+121152185.31-22.05 5.46  -0.12 -0.49         B8IV               -0.001-0.008      +023V      73                 *
+1485          CP-83   91  295982583791658  W                043429.0-830656042250.9-825357296.31-31.26 6.76  +0.20 +0.10         A7IV-V             -0.018+0.003      -005           5.7  47.7      *
+1486          BD+59  826  29606 24777        3391           043438.1+591946044318.1+593115148.73  8.83 6.50R                     A7IV               +0.033-0.049D+.005+010           0.0   0.1      *
+1487          BD-14  936  29613149797                       043443.7-143311043919.7-142133211.52-35.66 5.45  +1.06               K1IVa              +0.122-0.127 +.007+056V                          
+1488          BD-01  689  29610131392                       043442.2-011456043947.2-010310197.52-29.46 6.10  +0.94 +0.70         K0                 +0.025-0.018      +034                           
+1489          BD+37  954  29645 573772348                   043502.3+380520044150.3+381649164.66-05.27 5.99  +0.57 +0.06         G0V                +0.241-0.093 +.022+047V?  =< 10                  
+1490          BD+28  680  29646 767071126    3379           043504.1+282517044119.8+283654172.02-11.64 5.78  -0.03 -0.01         A2V                +0.034-0.030      +025V          5.2  43.5AB   3*
+1491          BD+75  189  29678  5309 173  W                043522.2+754533044850.3+755628135.73 19.40 6.06  +0.28 -0.02         A9IV               +0.035-0.135 +.021-006SB     97  6.0  96.9       
+1492          CP-62  372  29712249066    I W       R Dor    043535.6-621627043645.6-620439272.67-39.34 5.40  +1.58 +0.86 +3.16   M8eIII:            -0.064-0.084      +026           6.5  36.5AC   3*
+1493          BD+49 1230  29721 397021128  W                043545.4+494658044321.6+495826156.02  2.62 5.87  +0.02 -0.25         B9III              -0.004-0.016      +003           7.3  20.8       
+1494 59    PerBD+43 1043  29722 396992349                   043548.5+431029044254.3+432154160.95-01.78 5.29   0.00 +0.02         A1Vn               +0.039-0.052 +.018+009V     197                  
+1495          CD-24 2488  297371696501127                   043557.2-244040044006.8-242857223.58-38.91 5.58  +0.92               G6III              -0.067+0.018      -018SB                         
+1496 54    EriBD-19  988  29755149818    I   3380  DM Eri   043604.0-195148044026.5-194018217.79-37.36 4.32  +1.61 +1.81 +1.38   M4III              +0.021-0.096 +.008-033           0.3   0.1      *
+1497 94Tau TauBD+22  739  29763 76721 174  W                043614.5+224555044214.7+225725176.64-15.07 4.28  -0.13 -0.57 -0.14   B3V                -0.002-0.016 +.017+015SB2O  187  0.7   0.1     5*
+1498          CD-51 1207  29805233605                       043635.6-515207043904.3-514022259.24-41.23 6.44  +1.32               K2III              +0.017+0.017      +037                           
+1499 95    TauBD+23  733  29859 76727                       043710.4+235358044313.8+240520175.88-14.19 6.13  +0.54 +0.07         F7IV-V             +0.017-0.022      +008V   =< 10                  
+1500          BD+40 1032  29866 39715                       043717.4+403554044412.9+404713163.06-03.28 6.08  +0.06 -0.28         B8IVne             +0.003-0.007      +041      300                 *
+1501          BD+32  827  29867 57393                       043720.3+324039044348.3+325155169.06-08.49 6.45R                     A8V                -0.035-0.042      +000       73                  
+1502   Alp CaeCD-42 1587  298752169261129  W       Var?     043720.3-420316044033.7-415150246.15-41.49 4.45  +0.34 +0.01 +0.21   F2V                -0.141-0.077 +.045-001V      52  8.0   6.6      *
+1503   Bet CaeCD-37 1867  299921952391130                   043831.2-372022044203.5-370840239.92-40.91 5.05  +0.37 +0.04         F1V                +0.049+0.193 +.058+027V?    140                  
+1504          CP-59  370  30003233622      W                043839.2-590825044018.3-585637268.60-39.73 6.53  +0.68 +0.24         G5V                +0.070+0.186 +.064+010           0.2   2.7      *
+1505 55    EriBD-09  969  30020131442        3409B DW Eri   043846.8-085852044334.6-084737205.96-32.37 6.82  +0.39 +0.14         F4IIIpSr           +0.021-0.012D+.008+040SB     60  0.1   9.3      *
+1506 55    EriBD-09  970  30021131443        3409A          043847.2-085859044335.1-084746205.96-32.37 6.70  +0.92 +0.59         G8III              +0.032-0.024D+.008+048SB  =< 25  0.1   9.3      *
+1507          BD+10  621  30034 94095      W        1705    043853.2+105735044425.8+110846186.90-21.80 5.40  +0.25 +0.08 +0.13   F0V                +0.100-0.015      +040       86  5.8  74.7AB   3*
+1508 56    EriBD-08  929  300761314511131          DX Eri   043917.0-084125044405.3-083013205.72-32.12 5.90  -0.11 -0.81 -0.03   B2Ve               +0.003-0.002      +015      240                 *
+1509          CD-30 1968  30080195250    I                  043917.3-305705044309.3-304556231.68-39.74 5.68  +1.41 +1.60         K2III              -0.030-0.067      -004V?                         
+1510          BD+70  322  30085  53262358                   043924.5+704547045036.4+705630140.05 16.55 6.37  -0.08 -0.24         A0IV               +0.001-0.020      +007V?  =< 41                  
+1511  4    CamBD+56  973  30121 24829 175    3432           043940.2+563447044800.3+564526151.27  7.54 5.30  +0.25 +0.15 +0.08   A3m                +0.050-0.148 +.013+019       63  7.5  99.0AC   3*
+1512          BD+23  739  30122 76737                       043940.1+232639044542.5+233741176.62-14.03 6.35  +0.06 -0.44         B5III              +0.007-0.015      +019V?                        *
+1513          BD-18  906  301271498562352                   043943.0-185108044408.0-184000216.98-36.20 5.53  +0.02 +0.04         A3V                +0.051-0.018      +005                           
+1514          BD+40 1045  30138 39746                       043950.3+400751044644.4+401846163.73-03.23 5.97  +0.93               G9III              -0.001-0.029      +034                           
+1515          BD+55  928  30144 24834                       043954.8+552527044807.0+553609152.18  6.81 6.26R                     F0                 +0.075-0.102      +022       53                 *
+1516   Lam PicCD-50 1471  301852336382351                   044012.5-504010044246.4-502853257.58-40.79 5.31  +0.98 +0.74         K0-1III            -0.031+0.030 -.000+005                           
+1517          BD+18  719  30197 94112                       044026.3+183314044616.8+184406180.71-16.93 6.01  +1.21 +1.32 +0.63   K4III              +0.072-0.065      +038                          *
+1518          CD-41 1549  30202216961                       044026.9-411503044344.2-410353245.12-40.87 6.25  +1.46 +1.78         K3-4III            +0.003+0.010      -004                           
+1519          BD+11  646  30210 941112353  W                044027.9+113122044601.7+114220186.65-21.16 5.37  +0.19 +0.14 +0.08   A2m                +0.068-0.006 +.005+041SB1?   47  7.5  93.8AC   3*
+1520 57Mu  EriBD-03  876  30211131468 176                   044030.0-032616044530.1-031517200.53-29.34 4.02  -0.15 -0.60 -0.14   B5IV               +0.016-0.013      +009SB1O  140                 *
+1521          BD-21  966  30238169727    I                  044046.0-212800044504.2-211701220.15-36.87 5.72  +1.47              gK2                 +0.018-0.025      +022V                          
+1522          BD-03  884  30321131481                       044123.4-030805044624.1-025716200.36-28.99 6.33  +0.04 +0.06         A2V                +0.012-0.047      +019                           
+1523          BD+80  155  30338   7833948                   044137.3+810141050020.7+811138131.38 22.78 5.07  +1.28 +1.47         K3III              -0.001+0.024 +.020-008V?   < 17                  
+1524          CD-34 1859  30397195275                       044207.5-341113044549.6-340018235.96-39.75 6.86   0.00               A0V                +0.040+0.018      +028                           
+1525          CD-28 1735  304221697521132                   044226.1-281606044625.8-280515228.51-38.47 6.19  +0.19               A3IV               +0.001+0.016      +019      157                  
+1526          CD-39 1624  304321952782355                   044232.6-393213044555.4-392124242.91-40.35 6.05  +1.07               K1III              -0.059-0.020      -006                           
+1527          BD+63  543  30442 132912362I W                044243.4+632005045205.2+633019146.25 12.16 5.44  +1.57 +1.76         M3IIIab            +0.037-0.096 +.001-036V          4.5 115.4      *
+1528          BD+32  840  30453 57444      S                044250.8+322446044919.0+323518170.03-07.78 5.86  +0.24 +0.14 +0.11   A8m                +0.018-0.031      +021SB1O   15                 *
+1529          BD+31  816  30454 574412359I                  044248.1+311549044912.8+312614170.91-08.52 5.58  +1.12 +1.03         K2III              +0.017-0.108      +023V                          
+1530   Kap DorCP-59  376  304782336642354          Var      044250.5-595458044421.1-594358269.44-39.05 5.27  +0.20               A8-9III-IV         +0.033+0.039 +.024+000V     177                  
+1531          CP-77  181  304792561162350                   044253.7-775041043821.7-773922290.58-33.35 6.05  +1.10 +0.95 +0.52C  K2III              -0.010-0.018      +009                           
+1532 58    EriBD-17  954  30495149888                       044306.8-170703044736.3-165604215.37-34.81 5.51  +0.63 +0.12 +0.34   G2.5V              +0.133+0.170 +.079+023V                         *
+1533          BD+37  969  30504 574471133I                  044310.6+371842044954.6+372918166.30-04.57 4.88  +1.44 +1.70 +0.58E  K3.5IIIBa0.2:      -0.038+0.040 +.025-023V?   < 19:                *
+1534          BD+03  681  30545112098                       044329.5+032445044844.6+033518194.39-25.12 6.03  +1.19 +1.15         K1III              -0.001-0.017      -019                           
+1535          BD+48 1162  30557 397992361                   044338.0+483405045109.3+484427157.78  2.79 5.66  +0.99 +0.80         G9III              -0.040-0.031      +029                           
+1536          BD-05 1044  30562131504                       044339.7-055037044836.3-054026203.39-29.83 5.78  +0.62 +0.20         F8V                +0.305-0.243 +.038+079V                         *
+1537 96    TauBD+15  687  30605 94151    I   3464           044400.7+154347044944.1+155415183.60-17.97 6.08  +1.60 +1.72        gK3                 +0.005-0.010      +013V?         5.5  29.3AB   3 
+1538 59    EriBD-16  956  30606149901                       044402.5-163024044832.5-161946214.78-34.37 5.77  +0.55 +0.09         F6V                +0.004+0.036      +035                           
+1539   Zet CaeCD-30 2011  30608195300                       044355.4-301200044749.6-300113231.01-38.60 6.37  +1.07               K1IV               +0.039+0.094      +006V                          
+1540          CP-63  365  306102490952356           1718    044402.3-632435044457.9-631347273.75-38.12 6.46  +1.08 +1.00         K0-1III            -0.013-0.005      +016                           
+1541   Mu  MenCP-71  282  30612256122 177                   044403.6-710652044303.9-705552282.97-35.83 5.54  -0.12 -0.46         B8II-IIISi:        +0.008+0.033      -001V?                         
+1542  9Alp CamBD+66  358  30614 13298 178                   044406.3+661023045403.0+662034144.07 14.04 4.29  +0.03 -0.88  0.00   O9.5Ia            e 0.000+0.006 -.002+006V?     95                 *
+1543  1Pi 3OriBD+06  762  306521121061134I W        1731    044424.6+064712044950.4+065741191.45-23.07 3.19  +0.45 -0.01 +0.26   F6V                +0.466+0.012 +.125+024SB2    17  5.5  94.6      *
+1544  2Pi 2OriBD+08  777  30739112124    I                  044509.6+084343045036.7+085401189.82-21.83 4.36  +0.01  0.00  0.00   A1Vn               +0.004-0.032 +.036+024SB    212                 *
+1545          BD-14  970  307431499162363                   044507.0-135618044942.2-134611212.07-33.12 6.26  +0.44 -0.05         F5V                -0.122-0.172      -003    =< 15                  
+1546          BD+52  891  30752 24894                       044515.1+524020045309.8+525027154.80  5.63 6.41                      A2V                -0.008-0.021      -013                           
+1547 97    TauBD+18  743  30780 941641135  W       V480 Tau 044531.3+184011045122.5+185023181.38-15.91 5.10  +0.21 +0.12 +0.12   A7IV-V             +0.080-0.035 +.022+037V     141  5.3 177.0      *
+1548          CD-44 1720  307882170042360                   044529.1-440918044833.8-435848248.99-40.07 6.72  +0.95 +0.66         G8III              +0.018+0.022      +019                           
+1549 60    EriBD-16  964  30814149924    I          1740    044541.1-162327045011.6-161302214.84-33.96 5.03  +0.98 +0.77         K0III             v+0.041+0.054 +.023+037                           
+1550          BD+42 1081  30823 39826                       044543.8+422503045247.8+423512162.71-00.90 5.71  +0.11 +0.14         A3III              -0.006-0.001      -001V                          
+1551  2    AurBD+36  952  30834 57475    I                  044556.2+363203045238.0+364211167.26-04.65 4.78  +1.41 +1.58 +0.78   K2.5IIIbBa0.4      -0.027-0.007      -017     < 17                 *
+1552  3Pi 4OriBD+05  745  30836112142 179           1742    044552.7+052603045112.4+053618192.89-23.52 3.69  -0.17 -0.81 -0.16   B2III+B2IV         -0.001+0.001 +.001+023SBO    40                 *
+1553          BD+09  668  30870112150                       044613.8+094820045143.4+095830189.03-21.00 6.11  +0.08 -0.44         B5V                +0.001-0.008      +011                           
+1554          BD+27  701  30912 768022365                   044632.2+274349045247.1+275351174.20-10.13 5.97  +0.37 +0.16         F2IV               +0.041-0.032      +038      135                 *
+1555  5    CamBD+55  941  30958 249042367    3508           044652.4+550539045503.1+551533153.07  7.36 5.52  +0.04  0.00         B9.5V              -0.012-0.010      +002V?     71  6.4  12.9      *
+1556  4Omi1OriBD+14  777  30959 941761136I         Omi1 Ori 044652.4+140503045232.0+141502185.43-18.39 4.74  +1.84 +2.03 +1.17E  S3.5/1-             0.000-0.057 +.004-008V                         *
+1557          CD-41 1593  30985217032      W                044701.0-412936045016.2-411915245.54-39.66 6.07  +0.37               F2-3V              +0.006+0.065      +025           4.6  13.4      *
+1558          BD+43 1116  31069 39851                       044740.4+435352045451.3+440339161.81  0.32 6.08  -0.02 -0.09         A0V                +0.027-0.053      +003V     121                  
+1559          CD-35 1962  310931953572364  W                044749.8-350426045128.2-345423237.34-38.74 5.86  +0.08 +0.09         A1Vn               +0.026-0.022      +023SB         0.4   0.1       
+1560 61Ome EriBD-05 1068  311091315682366                   044758.8-053711045253.7-052710203.75-28.78 4.39  +0.25 +0.16 +0.17   F4III+A6III        -0.023+0.021 +.013-006SBO   153                 *
+1561          BD+52  898  31134 24919                       044811.4+524225045607.1+525210155.05  6.00 5.75  +0.11 +0.10         A2V s              -0.003+0.008      -022SB     40                  
+1562  5    OriBD+02  800  31139112179    I          1755    044809.8+022035045322.8+023029196.08-24.71 5.33  +1.64 +1.95 +0.91E  M1III              +0.034-0.019 +.010+013                           
+1563   Iot PicCP-53  760  31203233709      W                044841.3-533754045055.2-532741261.28-39.22 5.61  +0.33               F0IV               -0.091+0.083      +016V      57  0.8  12.3      *
+1564   Iot PicCP-53  760  31204233710      W                044842.5-533747045056.3-532735261.27-39.22 6.42                      F4V:               -0.092+0.081      +010V          0.8  12.3      *
+1565          BD+01  847  31209112191                       044845.1+012419045355.8+013410197.04-25.08 6.61  +0.04 +0.01         A1Vn               +0.009-0.003      +021      139                  
+1566          BD+19  811  31236 94199                       044905.5+191925045458.3+192907181.36-14.84 6.37  +0.29 +0.06 +0.16   F3IV               +0.060-0.038      +035V?    102                 *
+1567  8Pi 5OriBD+02  810  31237112197 180          Pi5 Ori  044902.5+021637045415.1+022626196.27-24.56 3.72  -0.18 -0.83 -0.20   B3III+B0V           0.000 0.000 +.003+023SBO    93                 *
+1568  7    CamBD+53  829  31278 24929        3536           044916.0+533532045717.2+534508154.47  6.68 4.47  -0.02 -0.01 -0.01   A1V                -0.024+0.007 +.000-008SB1O   45  3.4   0.4AB   3*
+1569  6    OriBD+11  675  31283 941972368  S                044914.0+111546045446.9+112534188.21-19.56 5.19  +0.12 +0.11         A3V                -0.009+0.032      +009V     127                  
+1570  7Pi 1OriBD+09  683  31295 94201      W                044923.4+095931045453.8+100903189.34-20.25 4.65  +0.09 +0.09 +0.03   A0Vp               +0.046-0.132      +013V     104  4.2 171.6AB   3*
+1571          BD+07  755  312961122032369I          1763    044923.3+073702045447.8+074645191.44-21.59 5.33  +1.22 +1.18        gK1                 -0.021-0.027      -005                           
+1572          BD+74  229  31312  5385    I                  044938.5+740653050220.1+741609137.71 19.17 6.06  +1.57 +1.83         K5III              +0.021+0.034      -052V?                         
+1573          BD+35  930  31327 57511                       044939.4+360029045619.9+361008168.14-04.40 6.07  +0.41 -0.43         B2Ib               -0.017+0.013      -005V?  =< 32                 *
+1574          BD+00  893  31331112206                       044942.5+001819045450.7+002803198.22-25.45 5.99  -0.12 -0.56         B5V                 0.000+0.003      +017SB    200                  
+1575          BD+24  709  31362 76848                       045010.0+242557045615.6+243532177.35-11.54 6.37  +0.33 -0.08         F0                 -0.026-0.017      -009V?     60                  
+1576          BD+14  787  31373 94212                       045008.6+145249045550.3+150224185.24-17.28 5.81  -0.08 -0.45         B9V                +0.018-0.021      +007V      90                  
+1577  3Iot AurBD+32  855  31398 57522 181I          1778    045028.7+330028045659.6+330958170.59-06.16 2.69  +1.53 +1.78 +0.82   K3II               +0.003-0.018 +.021+018V    < 17                 *
+1578          BD+05  769  31411112220                       045039.2+051423045558.4+052357193.77-22.63 6.50  +0.02 -0.01         A0V                -0.004-0.009      +022      118                  
+1579          BD-16  991  31414149985                       045038.1-165405045506.8-164426215.95-33.06 5.70  +0.96              gG9                 +0.008+0.001      +010                           
+1580  9Omi2OriBD+13  740  31421 94218    I   3540           045044.8+132124045622.3+133052186.63-18.05 4.07  +1.15 +1.11 +0.63   K2-IIIFe-1         -0.074-0.047 +.019+001     < 17  7.5 100.4AC   3*
+1581          BD-16  992  314441499882370          R Eri    045049.1-163446045518.6-162504215.61-32.90 5.72  +0.88              gG4                 +0.010+0.045      +032V                         *
+1582 62    EriBD-05 1091  31512131614      W                045128.6-051946045624.2-051017203.93-27.88 5.51  -0.13 -0.56         B6V                -0.008-0.007      +024      104  3.6  67.3       
+1583          CD-25 2115  31517169889                       045124.6-255316045530.2-254340226.30-35.91 6.72  +0.27               F0-2III            +0.018+0.028      +025                           
+1584          CD-39 1691  315291954002371                   045133.8-394721045454.8-393743243.46-38.65 6.10  +1.42               K3III              -0.003+0.022      +029                           
+1585          BD+16  672  31539 94227    I D                045135.7+165949045722.3+170913183.67-15.75 5.48  +1.31              gK1                 -0.013-0.007      +025V          0.0   0.1      *
+1586 99    TauBD+23  777  31553 76858        3557           045144.5+234733045748.7+235655178.09-11.64 5.79  +1.11              gG8                 +0.008-0.007      +004           6.4 103.5AC   3 
+1587          BD+73  264  31563  5403    I                  045145.0+733656050413.0+734550138.24 19.00 6.66R                     K0                 +0.021-0.016      +022                           
+1588  8    CamBD+52  906  31579 24943    I                  045148.2+530006045946.3+530920155.17  6.61 6.08  +1.46               K4III              -0.014-0.009      -002                           
+1589          BD+73  265  31590  5407      W                045203.1+735510050439.8+740401137.98 19.19 5.96R                     A1V                +0.013-0.016D+.010-009V      93  1.0   0.6      *
+1590 98    TauBD+24  717  31592 768622374    3547           045202.1+245346045809.4+250301177.24-10.92 5.81   0.00 -0.02         A0V                +0.022-0.048      +026SB     50  5.8  94.6AC   4*
+1591          BD-01  762  316231316252373                   045212.6-011323045717.2-010402200.03-25.70 6.23  +0.42 +0.06         F2                 -0.037-0.028      +009       67                  
+1592  4Ome AurBD+37 1005  31647 57548        3572           045228.0+374421045915.4+375325167.15-02.88 4.94  +0.04 +0.02 +0.03   A1V                +0.040-0.101 +.005+005V      83  2.8   5.1      *
+1593          BD+60  853  31662 13341        3590           045236.3+605555050135.9+610441148.91 11.58 6.03  +0.41               F4V                +0.008-0.175      +011       34  5.5   5.4      *
+1594          BD+66  370  31675 13344                       045242.2+664059050250.4+664922144.19 15.03 6.19  +0.48 -0.04        dF6                 +0.066-0.345 +.034+017V?                        *
+1595          BD-14 1003  31726150029                       045310.1-142311045744.8-141353213.50-31.51 6.15  -0.21               B1V                +0.010+0.011      +011                           
+1596          BD-02 1080  31739131640        3570           045308.6-022202045810.8-021245201.26-26.07 6.35  +0.10 +0.11         A2V                -0.003+0.025      +037           5.5  21.0       
+1597          CP-58  437  31746233733                       045314.5-584227045453.0-583250267.62-37.96 6.12  +0.44 -0.06         F3V                +0.101+0.077      +022                           
+1598          CP-66  338  317542491382372           1777    045321.2-665007045330.5-664032277.61-36.31 6.41  +1.63 +1.96         M0-1III             0.000+0.010      -024V                         *
+1599  5    AurBD+39 1133  31761 57559        3589           045325.7+391436050018.3+392341166.09-01.79 5.95  +0.41 -0.03         F5V                -0.017+0.004 +.021+006           3.4   3.7      *
+1600          BD+14  796  31764 94240        3579A  1788    045318.8+142325045859.4+143234186.12-16.94 6.09  +0.04 -0.27 +0.01   B7V                +0.006-0.017      +004      125  1.5  39.3AB   4*
+1601 10Pi 6OriBD+01  872  31767112281    I          1786    045321.8+013338045832.9+014251197.56-24.02 4.47  +1.40 +1.55 +0.70   K2-II              -0.002-0.003 +.018+014V?   < 17                  
+1602  6    AurBD+39 1134  31780 57560    I                  045329.5+393013050023.2+393918165.90-01.61 6.58R                     K4I                +0.002+0.006      -024V                          
+1603 10Bet CamBD+60  856  31910 13351 182I   3615A          045431.1+601746050325.1+602632149.57 11.38 4.03  +0.92 +0.63 +0.45   G1Ib-IIa           -0.006-0.016 +.009-002       19  3.4  80.8AB   3*
+1604          BD-16 1013  31925150052        3588   1793    045432.9-163153045901.3-162233215.97-32.06 5.66  +0.43 -0.08         F3V+F9V            -0.141+0.148 +.028+030V?         1.5   0.2AB   3*
+1605  7Eps AurBD+43 1166  31964 39955 183I   3605  Eps Aur  045447.4+434032050158.1+434924162.79  1.18 2.99  +0.54 +0.33 +0.45   F0Iae+B           v-0.001-0.004 +.007-003SB1O   29  6.2 207.6AE   6*
+1606          CP-72  332  31975256139                       045445.5-723425045305.5-722427284.32-34.57 6.28  +0.52 +0.01         F6V                -0.052+0.276      +025                           
+1607          BD-15  915  31996150058    I         R Lep    045503.2-145724045936.5-144821214.32-31.33 7.71  +5.74       +1.47   C6IIe              +0.021+0.020      +032V                         *
+1608 63    EriBD-10 1066  320081500602375                   045506.4-102435045950.4-101548209.55-29.41 5.38  +0.80 +0.35         G4V                +0.020-0.135      -012V                          
+1609          BD+03  736  32039112304        3597B  1800    045517.1+032759050032.6+033655196.07-22.61 7.03                      B9Vn               +0.025+0.001      +031      340  0.4  21.3      *
+1610          BD+03  737  32040112305        3597A  1800    045518.5+032803050033.9+033658196.07-22.60 6.66  -0.07 -0.28         B9Vn               +0.007-0.012      +042      352  0.4  21.3      *
+1611 64    EriBD-12 1047  32045150064              S Eri    045516.9-124105045955.8-123215211.94-30.34 4.79  +0.26 +0.16 +0.14   F0IV               +0.045-0.091 +.022-009V?    173                 *
+1612  8Zet AurBD+40 1142  32068 399661137I         Zet Aur  045529.1+405548050228.7+410433165.02-00.43 3.75  +1.22 +0.38 +0.87   K4II+B8V           +0.009-0.022 +.005+013SBO    19:                *
+1613          BD-02 1095  32115131684                       045537.3-021252050039.8-020356201.45-25.45 6.32  +0.28 +0.04         A8IV               -0.019+0.008      +021V                          
+1614          BD-05 1123  32147131688                       045551.1-055216050049.0-054512205.07-27.18 6.22  +1.06 +1.02 +0.49   K3V                +0.551-1.094 +.110+027SB                         
+1615          BD+41 1044  32188 39979               1810    045617.6+411750050318.6+412630164.82-00.08 6.14  +0.16               A2IIIShell?        +0.002-0.004      -001V?                        *
+1616          BD+85   74  32196   8431637                   045617.8+854946053148.0+855619127.17 25.68 6.51  +0.32 +0.10         A5m                +0.013-0.079      -006SB                        *
+1617 65Psi EriBD-07  948  32249131700                       045635.4-071914050126.3-071026206.59-27.69 4.81  -0.19 -0.74 -0.19   B3V                +0.003+0.008      +025V?     74                  
+1618          BD+00  923  322631123342376           1806    045641.5+003437050150.3+004320198.95-23.81 5.92  +1.27 +1.39         K0                 +0.001-0.012      +021                           
+1619          BD+01  886  32273112340        3623A          045649.2+012747050200.0+013632198.14-23.33 6.24  -0.04 -0.41         B8V                -0.009+0.012D+.013+025V      53  1.3  14.2AxBC 4*
+1620102Iot TauBD+21  751  32301 76920 184  D                045707.0+212650050305.7+213524180.77-12.06 4.64  +0.16 +0.15 +0.09   A7V                +0.066-0.042 +.019+041      126  0.0   0.1      *
+1621          BD-20  990  32309169981                       045705.2-201151050125.6-200307220.27-32.85 4.91  -0.05 -0.14 -0.05   B9.5Vn             +0.034-0.015      +024      237:                *
+1622 11    CamBD+58  804  32343 25001      W       BV Cam   045726.7+584958050608.5+585821150.99 10.80 5.08  -0.08 -0.69         B2.5Ve             -0.005-0.008      -011V?    131  1.0 180.5AB   4*
+1623 12    CamBD+58  805  32357 25003      W       BM Cam   045729.9+585256050612.2+590116150.95 10.83 6.08  +1.12 +0.85?        K0III              -0.001-0.031      -008SBO =< 25  1.0 180.5AB   4*
+1624          BD+60  857  32356 13369    I                  045727.4+610157050629.7+611012149.19 12.11 6.04  +1.37               K5II               +0.036-0.075      -040                           
+1625          BD-04 1019  32393131715                       045747.4-042113050245.5-041235203.82-26.03 5.85  +1.21 +1.36         K3                 +0.055+0.016      +038V?                        *
+1626          BD+30  772  32406 57610                       045751.2+302112050414.5+302941173.66-06.57 6.14  +1.21               K0II-III           +0.001-0.005      +018                           
+1627          BD+32  879  32428 57614                       045808.0+321053050436.9+321913172.25-05.41 6.62  +0.27 +0.13 +0.13   A4m                -0.011-0.070      -008                          *
+1628          CD-26 1975  324361699972377I                  045805.7-262500050209.8-261630227.45-34.62 5.02  +1.07 +0.97         K1III              +0.089-0.073 +.007+027                           
+1629   Eta MenCP-75  290  324402561451138                   045803.5-750526045511.2-745613287.12-33.55 5.47  +1.52 +1.83         K4III              +0.024+0.059 +.026+026                           
+1630          BD+54  859  32445 25007        3667           045814.4+541559050622.0+542421154.75  8.14 7.24R                     G5                 -0.014+0.028                     3.7   6.7AB   3*
+1631          CD-39 1744  32453195501                       045814.7-395148050134.5-394305243.74-37.38 6.03  +0.88               G5III              -0.001+0.030      +006                           
+1632          BD+27  723  32480 76941                       045822.7+273324050437.9+274146175.98-08.17 6.60  +0.24 +0.12         F0III              +0.019-0.031      +022      105                  
+1633          BD+21  755  32482 76939                       045823.9+210816050421.6+211641181.21-12.01 6.19  +1.32 +1.47 +0.48E  K0                 +0.020-0.015      +048                           
+1634  1    LepBD-22 1960  32503170010    I                  045831.6-225617050244.9-224742223.49-33.46 5.75  +1.20 +1.14         K1IV               +0.059+0.023      +033                          *
+1635          CD-31 2163  325151955091139                   045835.7-315500050222.8-314617234.00-35.92 5.94  +1.17               G8III              -0.002+0.082      +029                           
+1636          BD+69  302  32518 133822382                   045840.0+693024050936.7+693822142.12 17.12 6.41  +1.11 +1.03         K1III              +0.056-0.063 +.007-008                           
+1637  9    AurBD+51 1024  32537 25019        3675           045850.6+512754050640.6+513552157.06  6.51 5.00  +0.33 -0.01 +0.20   F0V                -0.030-0.173 +.052-005SBO    14  4.4  90.1AC   5*
+1638 11    OriBD+15  732  32549 942901140          V1032 Ori045851.2+151554050434.1+152415186.18-15.35 4.68  -0.06 -0.09 -0.02   A0pSi              +0.016-0.034 +.018+017V      36                 *
+1639          BD+35  973  32608 576292379                   045920.0+354756050600.9+355611169.53-03.00 6.52  +0.16 +0.09         A5V                -0.011-0.010      +014       80                  
+1640          BD-14 1027  32612150109                       045918.0-143038050352.0-142210214.33-30.21 6.41  -0.18 -0.77         B2.5IV             -0.009+0.033      +016                           
+1641 10Eta AurBD+41 1058  32630 40026 185           1822    045930.0+410558050630.9+411404165.35  0.27 3.17  -0.18 -0.67 -0.17   B3V                +0.029-0.068 +.022+007V?    132                 *
+1642          BD+19  847  32642 94306        3672           045938.3+194009050532.1+194823182.60-12.64 6.44  +0.21 +0.24 +0.14   A5m                -0.009-0.022D+.008-017       53  0.6   1.1       
+1643          BD+73  274  32650  54552387          BN Cam   045945.3+734904051222.4+735648138.39 19.58 5.43  -0.12?-0.36?        B9pSi               0.000-0.025 +.024+009V      37                 *
+1644          BD+42 1170  32655 40029                       045941.0+430218050649.6+431029163.84  1.49 6.20  +0.43 +0.30         F2IIp:             +0.005 0.000      -014    =< 23                  
+1645          CD-24 2795  32667170029                       045944.6-243137050353.3-242316225.40-33.70 5.61  +0.10 +0.07  0.00   A3m                +0.024-0.028      +007SB    216                  
+1646          BD-03  998  326861317422378                   045954.2-031041050454.5-030223202.96-25.00 6.05  -0.11 -0.53         B5IV               +0.001-0.001      +027                          *
+1647          BD+64  500  32715 133882384                   050000.8+644731050944.5+645510146.23 14.54 6.41  +0.40 -0.02         F6V                -0.015-0.182 +.024+000V                          
+1648          BD+00  939  32736112406    I         W Ori    050013.8+010225050523.7+011039199.01-22.82 6.17  +3.45 +6.5  +1.48   C6II               +0.012-0.007      +017V?                        *
+1649   Eta1PicCD-49 1541  32743217140      W                050011.7-491734050248.6-490905255.64-37.63 5.38  +0.42 +0.01         F2V                -0.044+0.024 +.055+021        0  7.6  10.4       
+1650          BD+76  190  32781  5464        3738   1854    050030.1+762048051435.6+762822136.14 20.98 6.37  -0.02 -0.08         A0V                -0.007-0.008      +007       34  4.5   1.5      *
+1651          CD-41 1690  32820217153                       050042.2-415317050354.0-414442246.33-37.15 6.31  +0.53 +0.04         F8V                +0.027+0.152      +029                           
+1652   Gam1CaeCD-35 2089  32831195532      W       Var?     050048.5-353711050424.4-352900238.60-36.23 4.55  +1.20 +1.20 +0.65   K3III              +0.129-0.051 +.013-003V          4.1   3.0       
+1653   Gam2CaeCD-35 2090  32846195534              X Cae    050051.8-355039050426.1-354219238.87-36.26 6.34  +0.30 +0.08         F1III              +0.028+0.038      +006                          *
+1654  2Eps LepBD-22 1000  32887170051 186I          1826    050113.6-223019050527.7-222216223.25-32.73 3.19  +1.46 +1.78 +0.81   K5III             v+0.025-0.074 +.011+001                           
+1655          CD-26 2005  32890170050                       050112.5-261714050516.2-260909227.54-33.91 5.73  +1.17               K2III              +0.007-0.065      -003V?                         
+1656104    TauBD+18  779  32923 94332        3701           050132.3+183039050727.0+183842183.83-12.94 5.00  +0.65 +0.14         G4V                +0.537+0.016 +.061+020V?      2  0.1   0.1      *
+1657 66    EriBD-04 1044  32964131777        3698   1831    050148.9-044721050645.7-043918204.78-25.35 5.12  -0.06 -0.17 -0.10   B9V+A1V            +0.016+0.008 +.024+031SB2O=< 41  5.4  52.8      *
+1658106    TauBD+20  885  32977 769712383                   050153.2+201712050748.4+202506182.40-11.85 5.30  +0.09 +0.10         A5V                -0.047-0.034 +.007-002V      95                 *
+1659103    TauBD+24  755  32990 76974        3709           050200.9+240759050806.6+241555179.25-09.56 5.50  +0.06 -0.57         B2V               e 0.000-0.004      +016SBO    98  5.7  35.3AC   4*
+1660105    TauBD+21  766  32991 76972      W                050156.6+213421050755.5+214217181.34-11.09 5.89  +0.19 -0.57         B2Ve               +0.005-0.006      +017V     220  0.0   0.3 O   3*
+1661          BD-13 1063  32996150149                       050159.6-131525050636.7-130719213.32-29.10 6.05  -0.06               A0V                +0.019+0.035      +040V?  =< 41                  
+1662 13    OriBD+09  736  33021112436      W                050209.4+092059050738.3+092819191.77-18.00 6.17  +0.62 +0.10         G1IV               -0.003-0.378 +.033-024V?  =<  6  3.8 124.0AB   3*
+1663   Eta2PicCD-49 1562  33042217164 187           1827    050222.5-494248050458.0-493440256.17-37.28 5.03  +1.49 +1.88 +0.91   K5III              +0.071-0.003 +.009+036                          *
+1664 14    OriBD+08  866  33054112440        3711           050226.1+082205050752.9+082954192.67-18.48 5.34  +0.33 +0.10 +0.18   Am                 +0.024-0.065 +.004+006V      52  0.8   0.7      *
+1665          BD-12 1076  33093150159                       050245.6-123714050725.0-122926212.75-28.66 5.97  +0.60               F7V                +0.140-0.080      +050V?  =< 15                  
+1666 67Bet EriBD-05 1162  33111131794 188I W        1841    050255.9-051256050751.0-050511205.34-25.31 2.79  +0.13 +0.10 +0.08   A3III              -0.095-0.081 +.050-009      179  8.0 116.7      *
+1667          CP-54  768  331162338142381                   050254.8-543233050500.6-542427262.23-37.07 6.27  +1.54 +1.90         M2III              +0.002 0.000      +105                           
+1668          BD+46  970  33167 40077                       050316.0+465019051042.9+465744161.20  4.29 5.68  +0.42 +0.02         F5V                +0.055-0.147 +.027+033V                         *
+1669          BD+37 1067  33203 57704    I   3734           050332.6+371028051018.9+371807168.95-01.49 6.02  +0.72               K3:+B2II:          +0.004-0.006D+.002+009SB         0.1   1.5AB   3*
+1670          BD+27  732  33204 769901141    3730A          050328.2+275413050945.1+280150176.38-07.06 6.01  +0.27 +0.04 +0.14   A5m                +0.054-0.060D+.008+041       27  2.5  11.6AxBC 3*
+1671          BD-08 1037  33224131806        3722A          050332.7-084742050820.2-083954208.95-26.83 5.78  -0.06 -0.37         B8V                +0.005-0.012      +027V          3.2  21.6AB   3*
+1672 16    OriBD+09  743  332541124671142  W        1849    050349.5+094204050919.6+094946191.69-17.46 5.43  +0.24 +0.16 +0.12   A2m                +0.064-0.007 +.011+037SBO    15  4.5 168.0AC   3*
+1673 68    EriBD-04 1056  33256131813                       050346.2-043510050843.6-042722204.83-24.83 5.12  +0.44 -0.05         F2V                +0.044+0.017 +.050+009        0                  
+1674   Zet DorCP-57  735  33262233822 189                   050347.7-573633050530.6-572822266.04-36.72 4.72  +0.52 -0.04 +0.29   F7V                -0.030+0.115 +.085-002        0                  
+1675          BD+61  766  33266 13409                       050352.8+614333051303.2+615100149.07 13.14 6.17  +0.02 +0.08         A2III              +0.011+0.006      -004                           
+1676 15    OriBD+15  752  33276 94359      W                050358.4+152811050942.0+153550186.74-14.21 4.82  +0.32 +0.19 +0.19   F2IV               +0.002-0.013 +.004+030       53                 *
+1677   Bet MenCP-71  309  332852561542380                   050400.4-712703050243.0-711852282.77-34.21 5.31  +1.00 +0.77         G8III              -0.005+0.004 +.013-011                           
+1678 14    CamBD+62  734  33296 13413                       050412.7+623405051331.3+624129148.38 13.65 6.50  +0.21 +0.12         A7Vn               -0.036+0.006      -004SB                         
+1679 69Lam EriBD-08 1040  33328131824 190          Lam Eri  050421.6-085256050908.8-084515209.14-26.69 4.27  -0.19 -0.90 -0.20   B2IVne            v+0.002-0.004 -.003+003V     336                 *
+1680          CD-35 2126  33377195581                       050441.1-355050050814.8-354306239.05-35.50 6.52  +1.08 +0.94         K1III              +0.009+0.001      -005                           
+1681          BD-00  867  33419131834                       050457.3-004125051003.2-003355201.28-22.67 6.10  +1.10 +1.07         K0III              +0.001-0.053      +026                           
+1682          CP-78  165  33519256153      W                050535.9-782614050013.2-781801290.71-32.05 6.29  +1.51 +1.88         K5-M0III           -0.023-0.012      +000           4.0  46.4       
+1683          BD+73  280  33541  5483                       050552.8+730912051813.3+731605139.23 19.59 5.74R                     A0V                -0.005-0.033      +000SB2    65                  
+1684          BD+15  759  33554 943772391I                  050556.8+155520051141.6+160244186.63-13.57 5.18  +1.49 +1.86         K5III              +0.005+0.007      -006V?   < 19:                 
+1685          BD-02 1161  33555131847                       050555.4-022227051058.0-021514203.00-23.29 6.25  +0.98 +0.81         K1-IVa             +0.075-0.145      +064                           
+1686          BD+79  169  33564  5496 191    3864A          050604.1+790659052233.5+791352133.74 22.65 5.05  +0.47 -0.13         F6V                -0.082+0.161 +.054-010        0  3.7  10.4AB   3*
+1687          BD-02 1165  336081318522390                   050617.1-023651051119.2-022927203.27-23.33 5.90  +0.46 +0.04         F5V                +0.079+0.001      +031    =< 10                  
+1688          BD+59  857  33618 25088                       050623.5+591715051511.3+592420151.30 11.99 6.15  +1.18 +1.23         K2III-IV           +0.012-0.014      +003                           
+1689 11Mu  AurBD+38 1063  33641 57755 192                   050635.0+382158051325.7+382904168.35-00.30 4.86  +0.18 +0.09 +0.10   A4Vm               -0.018-0.075 +.023+021V      86                  
+1690          BD+00  974  33647112505        3767  V1085 Ori050632.9+002331051141.4+003053200.48-21.79 6.67  -0.07 -0.32 -0.12   B9Vn               +0.015+0.003      +020V      39  0.4   0.1      *
+1691          BD+00  975  33646112509        3764           050635.8+005453051145.3+010213200.00-21.51 5.89  +0.66 +0.29         G5III              -0.012-0.015D+.002-019       23  1.4   1.6      *
+1692          BD+53  872  33654 250872393                   050642.7+530543051444.3+531250156.46  8.45 6.20  +0.07 +0.05         A0V                 0.000+0.001      +001V?     54                  
+1693          BD-12 1092  33664150206    I         RX Lep   050642.8-115825051122.8-115057212.55-27.51 5.68  +1.46 +1.23         M6III              +0.028+0.056      +046                          *
+1694          CD-26 2045  33667170151                       050640.7-260205051044.5-255434227.69-32.67 6.41  +1.25               K1III              -0.015+0.059      +042V                          
+1695          CP-63  420  336842491982389          WZ Dor   050647.0-633132050734.0-632359273.25-35.61 5.2   +1.65 +1.85 +1.42   M3III              +0.015-0.047 +.018+019                          *
+1696  3Iot LepBD-12 1095  33802150223        3778           050737.9-115921051217.9-115209212.67-27.32 4.45  -0.10 -0.40 -0.09   B8V                +0.027-0.015      +025V     193  6.3  12.7      *
+1697          BD-06 1109  33833131873                       050754.6-061034051248.2-060326206.91-24.67 5.91  +0.96 +0.72         G7III              +0.027-0.032      +023                           
+1698 17Rho OriBD+02  888  33856112528    I   3797   1872    050803.7+024432051317.5+025140198.52-20.27 4.46  +1.19 +1.16 +0.59   K0.5III            +0.001-0.006 -.010+041SB1O < 17  3.9   6.9AB   3*
+1699          CD-37 2071  33872195639                       050808.5-373058051135.9-372343241.22-35.12 6.57  +1.62 +1.95         K5III              +0.007+0.004      +001                           
+1700          CP-73  286  338752561602388                   050809.9-731000050609.3-730216284.67-33.45 6.27  -0.01 +0.01         A1V                +0.016+0.064      +008V                          
+1701          BD+01  938  33883112535        3799           050819.8+015057051331.6+015805199.37-20.66 6.09  +0.42 +0.28         A5V                +0.010+0.012D+.004+005      100  0.2   0.5AB   3*
+1702  5Mu  LepBD-16 1072  339041502371144          Mu  Lep  050826.3-161925051255.9-161220217.25-28.91 3.31  -0.11 -0.39 -0.12   B9IIIpHgMn         +0.043-0.026 +.023+028       12                 *
+1703          BD+00  988  33946112543    I W        1874    050838.7+002636051347.2+003337200.71-21.31 6.32  +1.46 +1.35         M0V                +0.003-0.025      -011                           
+1704          BD-08 1059  33948131887                       050844.8-081556051333.3-080852209.07-25.44 6.37  -0.13 -0.54         B5V                +0.002 0.000      +025                           
+1705  4Kap LepBD-13 1092  33949150239        3800           050836.8-130335051313.9-125629213.88-27.55 4.36  -0.10 -0.37 -0.09   B9V                -0.014-0.009 +.034+018V     124  2.7   2.6      *
+1706 14    AurBD+32  922  33959 57799        3824A KW Aur   050853.5+323419051524.4+324116173.30-03.35 5.02  +0.23 +0.19         A9IVDel Del        -0.024+0.014D+.007-010SBO    24  2.9  14.3AC   4*
+1707          BD+53  882  34019 25112    I   3845  R Aur    050913.2+532826051717.8+533510156.37  8.97 6.5   +1.66 +0.27         M7IIIe             +0.016-0.021      +008V          2.1  46.4      *
+1708 13Alp AurBD+45 1077  34029 40186 193I   3841   1897    050918.0+455347051641.4+455953162.58  4.57 0.08  +0.80 +0.44 +0.44   G5IIIe+G0III      v+0.076-0.425 +.073+030SB2O       0.5   0.0AP  10*
+1709          BD+04  877  340431125562394I          1880    050925.0+050225051444.1+050922196.62-18.79 5.50  +1.37 +1.55        gK4                 -0.001+0.004      -008                           
+1710          BD-14 1074  34045150255                       050926.7-144324051359.9-143624215.69-28.05 6.21  +0.37               F2III              -0.003+0.009      +031       67                  
+1711108    TauBD+22  864  34053 77057      W                050926.9+221013051527.7+221705181.88-09.32 6.27  +0.08 +0.14         A2V                -0.008-0.011      -011SB     90  6.2   1.9       
+1712          BD+34  980  34078 57816        3843  AE Aur   050941.7+341152051618.2+341843172.08-02.26 5.96  +0.22 -0.70         O9.5V             e+0.008+0.030 -.004+059V       5  3.3   8.4AB   3*
+1713 19Bet OriBD-08 1063  34085131907 194I   3823   1882    050943.9-081901051432.3-081206209.24-25.25 0.12  -0.03 -0.66 -0.02   B8Ia:             e 0.000-0.001 +.013+021SB     33  6.5   9.5AB   4*
+1714          BD+85   78  34109   873                       050952.0+853516054348.7+854005127.54 25.79 6.60R                     A2V                -0.016+0.002      -014                           
+1715          CD-35 2176  34167195669               1877    051013.4-355624051346.5-354932239.43-34.41 6.98  +1.47               K4III              +0.036-0.051      -007                           
+1716   Xi  MenCP-82  106  34172258395 917                   051014.9-823615045850.9-822814295.23-30.47 5.85  +0.93 +0.64         G8-K0III           -0.011+0.004      -005                           
+1717          BD-01  837  34180131917                       051014.7-013127051518.4-012433202.76-21.93 6.15  +0.39 -0.03         F0IV               -0.043+0.037      +014V      50:                 
+1718 18    OriBD+11  756  34203 944262395                   051030.7+111344051604.1+112029191.30-15.25 5.56  -0.04 -0.05         A0V                -0.009-0.005      -008       67                  
+1719 15    CamBD+57  874  34233 25125                       051050.1+580035051927.8+580702152.71 11.75 6.13  -0.03 -0.47         B5V                +0.004-0.021      +007SB?                       *
+1720          BD+62  742  34255 134602397I                  051102.3+623249052022.6+623913148.85 14.29 5.61  +1.75 +2.00         K4I:               -0.003-0.002      -006V                          
+1721          CD-36 2127  34266195683                       051056.5-360529051428.8-355838239.65-34.30 5.76  +1.01               G8III              +0.016+0.004      +013V                          
+1722          BD+42 1239  34269 40214    I         PU Aur   051107.1+424101051815.9+424732165.38  2.95 5.48  +1.65 +1.62         M4III              +0.038-0.023 +.007-038                          *
+1723          CD-27 2161  34310170238                       051123.6-270319051524.3-265636229.22-31.97 5.07  -0.10               B9V                +0.010-0.018      +029      111                  
+1724          BD+01  957  34317112588                       051129.4+015012051641.1+015650199.81-19.99 6.42  -0.02 +0.01 -0.03   A0V               e-0.011-0.009      -008V?     65                 *
+1725          BD+40 1240  34332 40224                       051141.3+402126051840.4+402754167.33  1.68 6.18  +1.37               K0                 +0.017-0.015      -017                           
+1726 16    AurBD+33 1000  34334 57853    I   3872   1909    051136.8+331602051810.7+332218173.07-02.48 4.54  +1.27 +1.27 +0.71   K2.5IIIbFe-1       +0.045-0.160 +.014-028SB1O < 17  5.8   4.2      *
+1727          CP-52  677  34347233886                       051133.9-520840051353.3-520152259.20-35.84 6.05  +1.39 +1.60         K3III              -0.004-0.024      +034                           
+1728 17    AurBD+33 1002  34364 57858              AR Aur   051143.9+333934051818.9+334602172.77-02.23 6.14  -0.06 -0.18         B9.5V              +0.012-0.030      +025SBO    58                 *
+1729 15Lam AurBD+39 1248  34411 402331145    3886           051206.3+400037051908.5+400557167.67  1.54 4.71  +0.63 +0.12 +0.32   G1.5IV-VFe-1       +0.519-0.664 +.066+066        2  4.9 146.6AD   6*
+1730          CD-35 2199  34435195694                       051211.5-350219051547.0-345536238.46-33.84 6.66  +0.15 +0.16 +0.08   A2III-IV           -0.018+0.026      +020                           
+1731          BD-17 1069  34447150295                       051221.4-171507051648.1-170830218.64-28.40 6.56  -0.16               B3IV               -0.012+0.022      +012                           
+1732          BD+33 1008  34452 57884              IQ Aur   051225.1+333832051900.0+334454172.86-02.13 5.41  -0.19 -0.55         A0pSi             v+0.011-0.025      +029SB?    53                 *
+1733          BD+44 1170  34498 40242                       051246.5+441914052002.3+442532164.22  4.15 6.62R                     K0                 +0.004-0.010      +013                           
+1734 18    AurBD+33 1010  34499 57893        3893           051247.8+335248051923.6+335908172.72-01.92 6.49  +0.24 +0.10         A7V                +0.009-0.010      +007      120  5.3   3.8       
+1735 20Tau OriBD-07 1028  34503131952 195    3877           051245.0-065709051736.4-065040208.28-23.96 3.60  -0.11 -0.47 -0.11   B5III              -0.015-0.008 +.006+020SB     46  7.2  36.0AD   4 
+1736          BD+46  998  34533 40251        3903           051311.5+465136052039.3+465750162.18  5.68 6.54  +0.60 +0.36         GIII+A2V           +0.002-0.002      +017           2.9  23.2      *
+1737          BD-13 1116  34538150304               1913    051304.6-133735051740.2-133111214.97-26.80 5.50  +0.93 +0.62       sgG9                 -0.012-0.046      +075                           
+1738          BD+40 1253  34557 40248                       051313.2+405900052014.8+410510166.99  2.28 5.52  +0.11 +0.05         A3V                -0.002-0.058 +.011+022V?    200                  
+1739109    TauBD+21  816  34559 770972398I                  051316.0+215935051916.6+220547182.54-08.70 4.94  +0.93 +0.69         G8III              +0.012-0.083 +.010+019     < 17                  
+1740 19    AurBD+33 1013  34578 579062399           1925    051325.3+335113052000.9+335729172.81-01.83 5.03  +0.27 +0.42         A5II               +0.001+0.002      -005       16                  
+1741          BD+19  893  34579 77098        3894           051319.6+200147051914.7+200805184.18-09.80 6.08  +1.01 +0.82         G8II-III+G1IV-V    -0.039-0.027 +.015-047           3.5   9.0      *
+1742          CP-52  683  34587233895                       051320.4-521733051538.9-521055259.39-35.57 6.49  +1.21               K2III              +0.022+0.027      +013                           
+1743   Omi ColCD-35 2214  34642195721 197                   051352.6-345935051729.1-345343238.51-33.49 4.83  +1.00 +0.80 +0.55   K0IV               +0.090-0.337 +.018+021V?                         
+1744   The DorCP-67  401  34649249225 196                   051349.9-671752051345.4-671107277.64-34.26 4.83  +1.28 +1.39 +0.63   K2.5IIIa           +0.019+0.036 -.006+011V                          
+1745          BD+77  195  34653  55352404                   051401.7+775307052925.7+775839135.11 22.40 6.56  +0.14 +0.16         A7III              +0.011-0.017      -016V      67                  
+1746 21    OriBD+02  916  34658112624               1922    051358.2+022932051911.2+023545199.54-19.12 5.34  +0.41 +0.09         F5II              v-0.017-0.047 +.022+011V      72                 *
+1747          BD-18 1051  34721150326        3899           051423.5-181412051850.4-180748219.88-28.33 5.96  +0.58 +0.08         G0V                +0.381+0.058 +.065+040SB         7.8  46.0AB   3*
+1748          BD-01  859  34748131983                       051431.3-013057051935.2-012444203.32-21.00 6.34  -0.11 -0.75 -0.14   B1.5Vn             -0.007-0.006      +019SB    280                 *
+1749 20Rho AurBD+41 1162  34759 402692400                   051443.6+414217052148.4+414816166.56  2.93 5.23  -0.15 -0.57         B3V                +0.018-0.037      +013SBO   102                 *
+1750          BD+27  758  34762 77121                       051442.5+275121052059.3+275726177.88-05.08 6.33  +0.04 -0.26         B9IV               -0.013-0.016      +007SBO   125  2.0   0.0      *
+1751 16    CamBD+57  879  34787 251612402  W                051454.2+572650052327.8+573240153.49 11.88 5.28  -0.03 -0.07         A0Vn               +0.013-0.055 +.023+012SB    268  7.7 106.2       
+1752          BD+29  869  34790 77124                       051450.9+292806052112.7+293412176.57-04.12 5.76R +0.06 +0.13         A1V s              +0.004+0.004      -019SB2O   53  0.4   0.0      *
+1753          BD-18 1055  34798150335        3910A          051454.2-183726051917.5-183112220.34-28.36 6.36  -0.16 -0.59         B3V                +0.012+0.010      +010       16  0.2  39.3      *
+1754          BD-18 1056  34797150336        3910B TX Lep   051455.0-183648051918.3-183035220.33-28.36 6.54  -0.11 -0.44         B8/9III/IV         +0.005-0.002      +015       72  0.2  39.3      *
+1755          BD+19  902  34810 94478                       051502.1+194247052056.6+194851184.68-09.64 6.18  +1.23               K0III              -0.006-0.015      +000                           
+1756  6Lam LepBD-13 1127  348161503401146                   051458.0-131648051934.5-131036214.83-26.24 4.29  -0.26 -1.03 -0.28   B0.5IV             -0.001-0.003 +.000+020       67                 *
+1757  7Nu  LepBD-12 1132  34863150345                       051520.5-122505051959.1-121856214.00-25.79 5.30  -0.12 -0.40         B7IVnn             -0.006+0.009      +016      370                  
+1758          CD-27 2204  34868170311 198                   051524.5-272818051923.7-272208229.99-31.24 5.99  -0.04               A0V                 0.000-0.010      +018       69                  
+1759          BD-05 1225  34880132004        3926           051531.5-052808052026.4-052200207.19-22.66 6.39  -0.03 -0.36         B8III              -0.011+0.029      +020       50  4.7   4.4      *
+1760          BD+40 1268  34904 40290                       051548.8+405551052250.3+410146167.31  2.65 5.54  +0.12 +0.13         A3V                -0.013+0.005      -009V     150                  
+1761          BD+03  857  34959112660                       051602.9+035445052119.3+040043198.53-17.95 6.57  -0.09 -0.49 -0.04   B5Vp              e-0.003-0.009      +005      300                 *
+1762          BD-21 1135  34968170327        3930   1940    051610.7-212025052026.9-211422223.35-29.07 4.71  -0.05 -0.11 -0.05   A0V               v+0.005 0.000 +.002+030V      51  3.8   4.2       
+1763          BD+08  933  349891126672401                   051616.8+081946052143.6+082543194.62-15.61 5.80  -0.13 -0.88 -0.13   B1V                +0.003-0.006      +026SB     57                 *
+1764          BD-00  929  35007132024        3941           051625.6-003057052131.8-002459202.64-20.09 5.68  -0.12 -0.65 -0.15   B3V                -0.003+0.002      +007V      40  5.9  37.6AC   3*
+1765 22    OriBD-00  930  350391320281147                   051639.4-002852052145.7-002257202.63-20.03 4.73  -0.17 -0.79 -0.18   B2IV-V              0.000-0.001      +029SB1O   14                 *
+1766          CD-34 2198  35046195763                       051644.5-344757052020.6-344156238.43-32.88 6.34  +0.33 +0.14         F2IV-V             -0.007-0.004      -010                           
+1767   Zet PicCD-50 1723  35072233926 199                   051654.8-504248051922.1-503622257.47-34.98 5.45  +0.51 +0.01         F7III-IV           +0.028+0.224 +.023+045                           
+1768 22    AurBD+28  788  35076 77139                       051702.8+285029052322.9+285612177.36-04.09 6.46  -0.04 -0.19         B9V s              +0.019-0.030      +009V      70                  
+1769          BD-13 1135  35104150375                       051716.0-135113052151.0-134522215.67-25.96 6.56  -0.09 -0.48         B8V                +0.008-0.007      +014V                          
+1770 23    OriBD+03  871  35149112697        3962A          051734.6+032654052250.0+033240199.16-17.86 5.00  -0.15 -0.86 -0.18   B1V                -0.004-0.002      +018      295  2.2  31.9      *
+1771          CD-24 3023  35162170351    I   3954A          051739.9-245212052146.2-244623227.30-29.95 5.06  +0.67 +0.16         G7II-III+A7IV-V    -0.024-0.013 +.004+005           1.5   3.1AB   3*
+1772          CD-34 2207  35165195770      W       Var?     051739.5-342636052116.9-342043238.07-32.61 6.09  -0.19 -0.70 -0.14   B5IVnpe            +0.009+0.001      +020V?         4.8   2.2      *
+1773 21Sig AurBD+37 1175  35186 57981    I   3984           051751.3+371731052439.2+372308170.52  0.88 4.99  +1.42 +1.76 +0.53E  K4III              +0.001-0.008 +.003-019V    < 19: 7.0   8.7AB   4*
+1774110    TauBD+16  765  35189 94514                       051751.1+163618052337.7+164158187.68-10.82 6.08  +0.14 +0.19         A2IV               -0.029-0.017      +021SB                         
+1775          BD+31  954  35238 57987                       051811.6+310751052438.3+311326175.62-02.58 6.28  +1.24               K1III              -0.043-0.009      +040SB                         
+1776          BD+31  955  35239 57988                       051811.8+310300052438.5+310835175.69-02.63 5.94  +0.04 -0.13         B9III              -0.011-0.007      +005V     285                  
+1777          BD+05  905  35242112708                       051811.7+051341052331.1+051921197.64-16.82 6.35  +0.12 +0.09         A2V                -0.024-0.003      +009                          *
+1778          BD-08 1107  35281132053        3978           051830.7-083036052318.5-082457210.50-23.39 5.9   -0.03 -0.36         B8III              +0.003-0.016D+.013+015V     119  1.7   6.0      *
+1779          BD+34 1031  35295 57999        4000A          051834.0+344551052513.0+345119172.68-00.44 6.55  +1.11 +1.16         K1pIII-IV+F6V      -0.007-0.039      -015           1.8  31.2      *
+1780111    TauBD+17  920  35296 94526      W                051835.2+171726052425.4+172300187.20-10.29 4.99  +0.53 -0.07         F8V                +0.246-0.009 +.067+037SB     16  2.9  85.7      *
+1781          BD-00  936  35299132057                       051835.4-001514052342.3-000935202.68-19.49 5.70  -0.21 -0.87 -0.19   B1.5V              -0.009+0.003      +022V?     36                 *
+1782          BD-01  882  35317132060        3991           051846.1-005738052351.4-005202203.35-19.80 6.11  +0.50 +0.01         F7V                -0.004-0.009D+.021+045SB2        0.0   2.7AxBC 3*
+1783  8    LepBD-14 1119  35337150396                       051855.6-140116052330.2-135538216.02-25.67 5.25  -0.21 -0.87?        B2IV               +0.002+0.004      +018V      23                  
+1784 29    OriBD-07 1064  35369132067    I                  051907.7-075359052356.8-074829209.98-22.98 4.14  +0.96 +0.69 +0.50   G8IIIFe-0.5        -0.015-0.043 +.011-018V?   < 17                  
+1785          CD-26 2185  35386170375                       051910.8-264800052312.0-264221229.54-30.23 6.49  +0.50               F6V                +0.029+0.009      +051V                          
+1786          BD+02  947  35407112729                       051923.4+021540052436.2+022110200.48-18.07 6.32  -0.15 -0.62 -0.16   B4IVn              +0.011-0.007      -008SB    398                 *
+1787 27    OriBD-01  886  35410132070    I                  051923.8-005914052428.9-005329203.46-19.68 5.08  +0.96 +0.69         G9III-IVFe-1       -0.005+0.132 +.021+020V?   < 19:                 
+1788 28Eta OriBD-02 1235  35411132071        4002  Eta Ori  051926.9-022921052428.6-022349204.87-20.39 3.36  -0.17 -0.92 -0.23   B1V+B2e            +0.002 0.000 +.007+020SB2O   46  1.4   1.5AB   5*
+1789 25Psi1OriBD+01 1005  354391127342406          V1086 Ori051933.3+014517052444.8+015047200.96-18.29 4.95  -0.20 -0.92 -0.22   B1Vpe              +0.001+0.001      +019V     316                 *
+1790 24Gam OriBD+06  919  35468112740 201I W        1972    051946.0+061533052507.9+062059196.93-15.95 1.64  -0.22 -0.87 -0.22   B2III              -0.009-0.014 +.029+018SB?    59 10.5 179.0      *
+1791112Bet TauBD+28  795  35497 77168 202I W                051958.1+283123052617.5+283627177.99-03.74 1.65  -0.13 -0.49 -0.10   B7III              +0.022-0.175 +.028+009V      71       33.4      *
+1792          BD-17 1117  35505150416                       052001.3-170400052428.4-165834219.25-26.64 5.65   0.00               A1V                +0.015-0.027      +022       89                  
+1793          CD-39 1940  355151958072405          SW Col   052005.9-394616052324.0-394043244.40-33.22 5.71  +1.62               M1III              +0.028+0.003      +061                          *
+1794          BD+35 1102  35519 580292408I                  052013.2+352210052654.3+352726172.38  0.18 6.15  +1.45 +1.68         K2                 -0.018-0.011      -021                          *
+1795          BD+34 1040  35520 58028                       052011.3+341814052648.9+342330173.25-00.43 5.94  +0.14 +0.21         A0III              +0.007-0.011      +008       95                 *
+1796          BD+33 1045  35521 58030                       052017.4+331028052651.3+331546174.19-01.05 6.15  +1.15               K0                 +0.013 0.000      -009                           
+1797          CD-37 2176  35528195809                       052012.1-372544052339.0-372012241.66-32.75 6.82  +1.04               K1III              +0.034+0.008      +030                           
+1798113    TauBD+16  775  35532 94543                       052018.9+163641052605.7+164201188.00-10.32 6.25  -0.08 -0.63         B2Vn               -0.009-0.003      +031                           
+1799          BD-10 1178  35536150420    I                  052018.5-102508052501.6-101945212.58-23.84 5.61  +1.56 +1.79         K5III              -0.017-0.022      +057                           
+1800          BD-00  945  35548132086        4020           052025.1-003800052531.2-003239203.26-19.28 6.57  -0.05 -0.18         B9pHgSi            +0.012-0.007D+.002-009V?      5  0.6   0.2      *
+1801   Kap PicCP-56  840  355802339522403                   052031.5-561342052222.1-560804264.19-34.51 6.11  -0.10               B8-9V              -0.005+0.020      -005V?                         
+1802 17    CamBD+62  759  35583 13518 203I          2003    052043.3+625901053010.2+630402149.08 15.46 5.42  +1.71 +2.00 +0.94E  M1IIIa             -0.006-0.005      -019V?                         
+1803          BD+00 1056  35588112752               1975    052038.5+002552052547.0+003115202.31-18.71 6.16  -0.18 -0.75 -0.20   B2.5V              -0.005+0.019      -024SBO   150                 *
+1804          BD+30  898  35600 58040                       052044.2+300718052708.3+301231176.76-02.70 5.74  +0.16 -0.18         B9Ib               +0.008-0.010      +017                          *
+1805 24Phi AurBD+34 1048  35620 58051    I W                052101.0+342327052738.9+342833173.28-00.24 5.07  +1.40 +1.67 +0.47E  K3IIICN+2          -0.003-0.047 +.009+031V    < 17  3.2 206.8AD   4*
+1806          BD-05 1247  35640132100                       052107.8-053624052602.4-053106208.02-21.49 6.23  -0.06 -0.23 -0.05   B9.5Vn             +0.013+0.008      +018V     280                 *
+1807          BD+06  923  35656112767                       052115.6+064656052638.8+065209196.66-15.36 6.42  -0.02 -0.04         A0Vn               +0.003-0.012      +013V?    118                  
+1808115    TauBD+17  928  35671 945541148    4038           052120.0+175235052710.1+175744187.07-09.42 5.42  -0.10 -0.53         B5V                +0.005-0.022      +018V?    155  1.2   0.1 O   4*
+1809          BD+15  822  35693 94556                       052130.7+151018052713.8+151528189.39-10.86 6.16  +0.08 +0.14         A1IV               -0.014-0.002      +025       68                  
+1810114    TauBD+21  847  35708 77184        4048           052137.6+215106052738.1+215613183.75-07.17 4.88  -0.15 -0.76 -0.15   B2.5IV             +0.002-0.007      +013V?     24  0.0   0.1 O   5*
+1811 30Psi2OriBD+02  962  35715112775        4039  Psi Ori  052135.8+030033052650.2+030544200.09-17.22 4.59  -0.21 -0.93 -0.22   B2IV               +0.002-0.004 -.016+012SB2O  141  5.6   2.7AB   3*
+1812          BD-19 1173  35736150442        4034A          052139.8-194657052559.8-194144222.23-27.31 5.89  +0.40 -0.05         F2V                +0.004-0.022      +006V          2.8  27.0      *
+1813          CD-44 2036  357652173252407                   052156.8-441852052455.6-441333249.84-33.58 6.08  +1.20               K1III              +0.003+0.005      +015                           
+1814116    TauBD+15  826  35770 94566                       052200.8+154723052745.6+155227188.93-10.42 5.50  +0.01 -0.05         B9.5Vn             +0.006-0.022      +016V     260                  
+1815          CP-81  134  357982584053976                   052206.7-813847051225.7-813230294.02-30.39 6.51  +1.11 +1.01         K1III              +0.011+0.050      +019SB2                        
+1816117    TauBD+17  931  35802 94573    I                  052213.2+170921052801.6+171420187.79-09.64 5.77  +1.63 +2.01         M1III              +0.020-0.049      -023V?                         
+1817          BD-12 1169  358501504612409                   052225.2-115906052704.8-115403214.37-24.04 6.35  +0.51 +0.01        dF7                 +0.019-0.049      +019V?                         
+1818   The PicCP-52  718  35860233965      W                052230.1-522413052446.2-521859259.56-34.18 6.27  +0.07 +0.07         A0V                -0.012-0.031D+.004-003SB2        0.5  38.2AC   3*
+1819          BD+13  903  35909 94580                       052255.3+133547052834.8+134044190.93-11.42 6.35  +0.15 +0.14         A4V                +0.014-0.018      +025V?    153                  
+1820          BD+01 1021  35912112794                       052251.2+011252052801.6+011754201.88-17.84 6.41  -0.18 -0.74 -0.18   B2V                +0.018+0.003      +034       32                 *
+1821118    TauBD+25  839  35943 77201        4068A  2009    052307.1+250410052916.5+250902181.25-05.10 5.47  -0.04 -0.14         B8.5V              +0.010-0.032D+.014+015V?    133  0.8   4.8AB   3*
+1822          BD+29  909  35984 77205                       052319.3+290624052940.6+291111177.92-02.81 6.24  +0.45 +0.01         F6III              +0.022-0.054      +013V      39                  
+1823          BD-21 1174  35991170445                       052320.8-212737052736.5-212232224.15-27.56 6.07  +1.04 +0.86 +0.35E gG7                 +0.013+0.036      +034                          *
+1824          BD+41 1206  36040 403872412                   052344.6+412302053048.6+412743167.79  4.13 6.00  +1.11 +1.12         K0IIIp             +0.002-0.035      +014                          *
+1825          BD+39 1322  36041 58129      W                052347.4+394452053045.1+394933169.15  3.23 6.37  +0.97 +0.76         G9III              +0.021-0.041      +012           1.3  75.4      *
+1826          BD-03 1115  36058132157        4078           052357.3-032318052856.7-031827206.28-19.83 6.39  -0.01 -0.06         A0Vn               -0.035-0.015D+.003+005      142  0.3   0.8      *
+1827          CD-41 1884  360602173401149  W                052352.7-410148052705.3-405637246.03-32.73 5.87  +0.23 +0.18 +0.12   A7m                +0.011+0.096      +036           8.7  20.3       
+1828 18    CamBD+57  889  36066 252411150           2058    052359.8+570902053233.8+571316154.43 12.76 6.48  +0.57 +0.12         F8V                +0.113-0.222 +.012+037V?  =< 10                  
+1829  9Bet LepBD-20 1096  36079170457 204I   4066   2008    052357.6-205021052814.7-204534223.56-27.20 2.84  +0.82 +0.46 +0.44   G5II               -0.004-0.089 +.020-014V?     11  4.5   2.6AB   5*
+1830          BD-03 1116  36134132170               2022    052424.5-033134052923.6-032647206.46-19.80 5.79  +1.15 +1.02 +0.57   K1-III             -0.044-0.008      +023V                          
+1831          BD+22  925  36160 77220                       052441.1+222305053043.4+222745183.70-06.29 6.29  +1.18 +1.15         K0                 +0.043-0.016      +002                           
+1832          BD+15  837  36162 94596                       052442.7+151659053026.1+152137189.72-10.15 5.94  +0.14 +0.14         A3Vn               -0.027-0.050      -016V?    230                  
+1833          BD+01 1032  36166112830                       052443.3+014237052954.8+014721201.67-17.19 5.78  -0.20 -0.84 -0.20   B2V                +0.008-0.004      +012V     175                 *
+1834 31    OriBD-01  913  36167132176    I   4097  CI Ori   052439.2-011015052944.0-010532204.31-18.62 4.71  +1.57 +1.85 +0.69E  K5III              +0.004-0.023 +.006+008SB   < 19: 5.4  12.5      *
+1835          CD-37 2220  36187195887                       052448.5-371850052815.3-371350241.75-31.83 5.57  +0.02 +0.03         A1V                +0.009+0.074      +050                           
+1836   Lam DorCP-59  472  361892339812410                   052451.5-585948052619.3-585445267.52-33.87 5.14  +1.00       +0.48   G6III              -0.008+0.028 +.012+010                           
+1837          BD+04  949  36217112837              CK Ori   052502.8+040738053019.8+041215199.53-15.91 6.21  +1.27 +1.38 +0.47E  K2IIIe            v+0.002-0.048      +015                          *
+1838          CD-30 2421  36255195898                       052516.2-301147052906.7-300700233.75-29.96 6.75  +1.06               G8/K0III           -0.003+0.014      +059V                          
+1839 32    OriBD+05  939  36267112849        4115           052525.9+055219053047.1+055653198.02-14.94 4.20  -0.14 -0.55 -0.14   B5V                +0.012-0.034 +.005+019V?    176  1.3   0.9      *
+1840          BD-07 1099  36285132192                       052530.7-073045053020.7-072605210.38-21.39 6.33  -0.19 -0.83 -0.17   B2IV-V             -0.013+0.001      +011       10                 *
+1841 NOVA 1891                                     T Aur    0 0 0      0 0 0 0 0      0 0                                                                                                           *
+1842 33    OriBD+03  948  36351112861        4123           052559.6+031258053114.5+031732200.48-16.17 5.46  -0.18 -0.83 -0.20   B1IV+B1.5V         +0.001+0.003D+.001+020V?     38  1.0   1.9AB   3*
+1843 25Chi AurBD+32 1024  36371 581641151                   052613.0+320705053243.7+321131175.77-00.61 4.76  +0.34 -0.46 +0.27   B5Iab              -0.002-0.003      -000SBO    41                 *
+1844          BD+74  252  36384  5593 205I          2337    052620.9+745840053943.7+750238138.26 21.71 6.17  +1.57 +1.95         M0III              -0.008+0.025      -003V?                         
+1845119    TauBD+18  875  36389 94628    I         CE Tau   052620.9+183112053212.8+183540187.18-08.07 4.38  +2.07 +2.21 +1.44   M2Iab-Ib          e+0.002-0.001 +.002+023V?                        *
+1846          BD+41 1218  36404 40426                       052621.7+420210053328.7+420632167.51  4.90 6.55  -0.02 -0.27         B9IIIp:Hg:         -0.001-0.001      +001                           
+1847          BD+16  794  36408 94630        4131A          052626.3+165903053214.2+170329188.50-08.88 5.46R -0.04 -0.23         B7IIIe             -0.002-0.009D+.009+015SB     55  0.4   9.6      *
+1848          BD-06 1207  36430132210                       052629.2-064701053120.9-064230209.80-20.85 6.22  -0.17 -0.74 -0.17   B2V                +0.010 0.000      +023       25                 *
+1849 10    LepBD-20 1105  36473170506                       052650.8-205615053107.6-205149223.94-26.61 5.55   0.00 +0.03         A0V                +0.005-0.044 +.016-011       60                  
+1850          BD+32 1028  36484 58179                       052654.8+324350053327.5+324804175.34-00.15 6.48  +0.09 +0.17  0.00   A2m                +0.008-0.063      +034SB                         
+1851 34Del OriBD-00  982  36485132221        4134C          052653.8-002130053200.5-001704203.84-17.73 6.85  -0.16 -0.71         B2V                +0.009-0.004 +.014+021V      77  4.6  51.7AC   3*
+1852 34Del OriBD-00  983  36486132220 206I   4134A Del Ori  052653.8-002223053200.4-001757203.86-17.74 2.23  -0.22 -1.05 -0.22   O9.5II             +0.001-0.002 +.014+016SBO   152  4.6  51.7AC   3*
+1853          BD+66  401  36496 13548      W                052701.6+663746053716.2+664146146.14 17.87 6.26                      A8Vn               -0.010-0.031      -015V?    209  0.8   0.3       
+1854          BD+34 1083  36499 58182                       052659.2+343915053338.0+344333173.74  0.93 6.27  +0.15 +0.17         A3IV               -0.038-0.008      -006SB    100                  
+1855 36Ups OriBD-07 1106  36512132222                       052705.5-072231053155.8-071805210.44-20.98 4.62  -0.26 -1.07 -0.26   B0V                -0.001-0.005      +017V      20                 *
+1856          CD-47 1884  365532173681152  W                052724.5-470858053009.5-470440253.35-32.98 5.46  +0.62 +0.21         G3IV               +0.025-0.137      +016           1.0 197.1AD   4 
+1857 19    CamBD+64  536  36570 13550        4177           052734.2+640523053715.1+640917148.49 16.68 6.15  +0.01 -0.07         A0V                +0.003-0.070 +.007-012       55  4.0   1.6      *
+1858120    TauBD+18  877  36576 94649              V960 Tau 052739.9+182808053331.6+183225187.39-07.84 5.69  +0.01 -0.76         B2IV-Ve            -0.002 0.000      +041V     271                 *
+1859          CP-68  375  36584249281      W                052731.3-684206052700.0-683722279.07-32.78 6.03  +0.34 +0.03 +0.21C  F0IV-V             +0.001-0.019D+.012-002           0.2   1.1       
+1860          BD+20  989  36589 77255               2132    052742.1+202412053338.8+202827185.76-06.78 6.18  -0.07 -0.39         B6V                -0.004-0.012      +027V      90                  
+1861          BD-01  935  36591132234        4141   2107    052737.7-013951053241.3-013531205.14-18.20 5.35  -0.19 -0.94 -0.19   B1IV               -0.001-0.009      +034       29  4.5   2.0      *
+1862   Eps ColCD-35 2348  365971959242413I                  052739.7-353237053112.7-352814239.89-30.88 3.87  +1.14 +1.08 +0.60   K1IIIa             +0.022-0.035 +.008-005V                          
+1863          BD-01  939  36646132247        4150   2131    052804.0-014719053307.2-014306205.31-18.17 6.46  -0.09 -0.60 -0.12   B4Vn               -0.025-0.040D+.002+037      196  1.8   1.5AB   4*
+1864 35    OriBD+14  947  36653 946522414                   052813.2+141408053354.3+141820191.08-09.99 5.64  -0.14 -0.62         B3V                -0.001-0.009      +019V     224                  
+1865 11Alp LepBD-17 1166  36673150547 207I   4146   2128    052819.1-175338053243.8-174920220.95-25.14 2.58  +0.21 +0.23 +0.21   F0Ib               +0.001+0.002 +.007+024       13  8.5  35.8AB   3*
+1866          BD+54  914  36678 252762416I                  052822.6+542144053635.2+542544157.19 11.82 5.73  +1.63 +1.98         M0III              -0.013-0.002      +001                           
+1867          CP-62  479  36689249288                       052822.6-622321052917.4-621852271.57-33.29 6.59  +1.53 +1.85         K4-5III            +0.010-0.023      +014V                          
+1868          BD-01  943  36695132255              VV Ori   052826.8-011335053331.4-010922204.84-17.81 5.34  -0.18 -0.90 -0.20   B1V                -0.004 0.000      +022SB1O  168                 *
+1869          BD+47 1178  36719 404662417                   052842.7+473857053615.9+474255163.00  8.30 6.11  +0.26 +0.15        dF0                 +0.012-0.018      +014V      67                  
+1870          CD-46 1892  36734217382                       052845.5-455955053136.1-455531252.02-32.61 5.86  +1.35 +1.54         K3III              +0.028+0.038      +007                           
+1871          BD+01 1058  36741112901                       052847.0+012018053357.6+012428202.53-16.49 6.59  -0.17 -0.79 -0.21   B2V                +0.009+0.004      +014      198                 *
+1872 38    OriBD+03  964  36777112904      W                052900.9+034155053416.7+034601200.43-15.27 5.36  +0.05 +0.07 +0.04   A2V                -0.031-0.018 +.014-004V     145        0.4      *
+1873          BD-01  949  36779132269        4159           052858.9-010617053403.9-010208204.79-17.64 6.22  -0.17 -0.81 -0.18   B2.5V              +0.007+0.001      +004      227  4.8  27.5      *
+1874          BD-01  950  36780132270    I                  052900.2-013219053404.0-012814205.20-17.84 5.93  +1.55 +1.88         K5III              -0.012-0.033      +091                           
+1875121    TauBD+23  954  36819 772852415          Var?     052920.6+235824053527.1+240222182.95-04.52 5.38  -0.09 -0.62         B2.5IV             +0.010-0.024      +023SB    117                 *
+1876 37Phi1OriBD+09  877  36822112914 208  S                052919.8+092519053449.2+092922195.40-12.29 4.41  -0.16 -0.97 -0.17   B0III              +0.002-0.004 +.000+033SBO    39                 *
+1877          CD-38 2085  36848195948                       052929.3-383459053251.3-383047243.44-31.20 5.48  +1.22 +1.34         K2III              +0.040-0.002 -.008-001                           
+1878          BD+27  806  36859 77295    I                  052938.8+273550053555.5+273944179.95-02.48 6.27  +1.54 +1.65         K0                 -0.025-0.039      -009SB                         
+1879 39Lam OriBD+09  879  36861112921    I   4179A  2240    052937.7+095202053508.3+095603195.05-12.00 3.54  -0.18 -1.03 -0.17   O8III((f))          0.000-0.006 +.007+034       66  2.0   4.4AB   4*
+1880 39Lam OriBD+09  879  36862              4179B  2240    052937.9+095205053508.5+095606195.05-12.00 5.61  +0.04 -0.77         B0.5V              +0.001-0.006 +.007+036V?    125  2.0   4.4AB   4*
+1881          CD-35 2367  36874195952               2158    052932.7-351229053307.4-350823239.62-30.42 5.78  +1.07 +1.00         K0III              +0.097-0.041      +015V?                         
+1882          CP-64  452  36876249297      W                052939.7-640008053015.9-635540273.48-33.04 6.19  +0.22 +0.16         F0IV               +0.009+0.054      +011           5.1   9.2       
+1883          BD+10  818  36881 94671        4181   2251    052942.0+101025053513.4+101424194.79-11.82 5.60  +0.12 -0.07         B9IIIpHg:Mn:       +0.022-0.008      +035V      15  4.2   2.9      *
+1884          BD+40 1346  36891 40481                       052953.1+400704053652.4+401056169.49  4.41 6.09  +1.03 +0.69         G3Ib+F             -0.002-0.010      -018SB?                        
+1885          BD+85   80  36905   9141638                   052954.5+850850060120.2+851056128.17 25.99 6.11  +1.57 +1.90         M0III              +0.011 0.000      -046V                          
+1886          BD-06 1233  36959132298        4182B  2261    053007.7-060433053500.9-060033209.57-19.72 5.67  -0.23 -0.91 -0.21   B1V               v-0.011 0.000 +.005+030V?     26  0.9  36.2      *
+1887          BD-06 1234  36960132301        4182A          053009.3-060407053502.7-060007209.56-19.71 4.78  -0.25 -1.02 -0.25   B0.5V              +0.004+0.002 +.005+028V?     38  0.9  36.2      *
+1888          CD-29 2348  36965170561                       053000.8-295502053352.1-295056233.78-28.90 6.53  -0.02               A0V                +0.014+0.021      +015                           
+1889          BD+25  879  36994 77310                       053018.2+255230053630.2+255622181.47-03.30 6.49  +0.43               F5III              +0.014+0.003      +003       76                  
+1890          BD-04 1183  37017132317              V1046 Ori053025.0-043336053521.8-042936208.18-18.96 6.56  -0.13 -0.77 -0.13   B1.5V              -0.011+0.030      +029SB1O   85                 *
+1891          BD-04 1184  37016132319      W                053025.3-042924053522.5-042531208.11-18.92 6.24  -0.15 -0.70 -0.17   B2.5V              +0.022-0.027      +031           0.7   0.2      *
+1892 42    OriBD-04 1185  37018132320    I   4187   2318    053027.1-045414053523.2-045018208.50-19.11 4.59  -0.19 -0.94 -0.18   B1V                +0.004 0.000 +.006+030SB     71  3.2   1.5      *
+1893 41The1OriBD-05 1315  37020              4186A V1016 Ori053021.0-052712053515.9-052314209.01-19.38 6.73  +0.02 -0.88 +0.21   B0.5V              +0.005+0.002 +.001+032SBO   112  0.1 117.0 *  12*
+1894 41The1OriBD-05 1315  37021              4186B BM Ori   053021.3-052704053516.1-052307209.01-19.38 7.96  +0.24 -0.49         B0V                +0.005+0.002 +.001+024SBO   222  0.1 117.0 *  12*
+1895 41The1OriBD-05 1315  37022132314    I   4186C  2294    053021.7-052720053516.5-052323209.01-19.38 5.13  +0.02 -0.95 +0.18   O6p               v+0.004+0.002 +.001+033SB?   127  0.1 117.0 *  12*
+1896 41The1OriBD-05 1315  37023              4186D  2295    053022.5-052714053517.3-052316209.01-19.38 6.70  +0.09 -0.71 +0.20   B0.5Vp             +0.005+0.002 +.001+031SB    109  0.1 117.0 *  12*
+1897 43The2OriBD-05 1319  37041132321    I:  4188A  2320    053028.2-052854053522.9-052458209.05-19.37 5.08  -0.09 -0.94         O9.5Vp            e+0.001+0.005 -.001+036SBO   170  0.1 117.0 *  12*
+1898          BD-04 1186  37040132325        4192           053033.9-042546053531.1-042153208.07-18.86 6.38  -0.14 -0.74 -0.16   B2.5IV             +0.002-0.021      +030      140  2.0   4.2      *
+1899 44Iot OriBD-06 1241  37043132323 209I   4193   2334    053032.4-055832053526.0-055436209.52-19.58 2.77  -0.24 -1.08 -0.20   O9III             e 0.000+0.001 +.025+022SB2O  130  4.5  11.4AB   3*
+1900          BD-03 1146  37055132332      W        2350    053036.1-031905053535.8-031510207.04-18.33 6.40  -0.12 -0.63 -0.13   B3IV               -0.008 0.000      +024           6.2   1.1      *
+1901 45    OriBD-04 1188  37077132336        4196           053043.5-045517053539.5-045121208.55-19.06 5.26  +0.24 +0.15 +0.14   F0III              +0.009+0.011 +.026-009V      66  9.0  19.1AC   3*
+1902          BD+26  870  37098 77322        4208   2426    053054.0+265143053708.8+265527180.72-02.65 5.83  -0.07 -0.39         B9IV-V             +0.011-0.025D+.007+010V          0.1   1.1AB   4*
+1903 46Eps OriBD-01  969  37128132346 210I W       Eps Ori  053108.3-011557053612.8-011207205.21-17.24 1.70  -0.19 -1.04 -0.17   B0Ia              e+0.001-0.002 -.002+026SB     87  8.7 179.9      *
+1904          BD+33 1102  37138 58263                       053110.3+332950053745.7+333333175.19  1.02 6.33  +1.31               K0                 +0.003 0.000      +029                           
+1905122    TauBD+16  822  37147 94700                       053115.4+165843053703.8+170225189.12-07.91 5.54  +0.22 +0.10 +0.12   F0V                +0.045-0.031 +.029+041      114                 *
+1906          BD-05 1334  37150132351               2416    053120.9-054241053615.0-053853209.37-19.28 6.54  -0.18 -0.81         B3V               v 0.000-0.004      +011                          *
+1907 40Phi2OriBD+09  898  37160112958    I                  053124.7+091411053654.3+091726195.84-11.95 4.09  +0.95 +0.64 +0.55   K0IIIbFe-2         +0.091-0.305 +.030+099                          *
+1908          BD+10  828  37171 947022420I                  053130.8+105823053704.4+110206194.33-11.02 5.94  +1.58 +1.91 +0.94   K4III              +0.051-0.018      -111SB                         
+1909          CD-33 2414  37192195986                       053134.4-330851053515.4-330448237.44-29.49 5.78  +1.12               K2IIIa             +0.020+0.109      +044                           
+1910123Zet TauBD+21  908  37202 77336 211I D       Zet Tau  053140.0+210454053738.7+210833185.69-05.64 3.00  -0.19 -0.67 -0.10   B4IIIpe           v 0.000-0.021 +.008+020SB1O  310  2.0   0.0      *
+1911          BD-06 1255  37209132359        4212   2433    053142.5-060739053635.7-060354209.81-19.39 5.72  -0.22 -0.91 -0.25   B1V                -0.005-0.012      +028SB     50  3.2   5.2      *
+1912          CP-54  854  372262340262419  W                053145.3-545807053344.4-545408262.70-32.91 6.43  +0.55               F8V                +0.072+0.011      +038           3.6  54.7AB   3*
+1913          BD+08 1016  37232112966                       053151.1+085325053719.3+085707196.20-12.03 6.12  -0.17 -0.83         B2IV-V             +0.001-0.001      +042      120                 *
+1914 26    AurBD+30  963  37269 58280        4229   2485    053212.7+302559053838.1+302933177.88-00.47 5.40  +0.45 +0.25         F9III+B9.5V        -0.019-0.009D+.005+002SB         0.3   0.2AB   4*
+1915          CD-28 2298  37286170587                       053215.6-284614053610.3-284228232.71-28.09 6.26  +0.13 +0.05 +0.05   A2/3III/V:         +0.023 0.000      +022                           
+1916          BD+65  485  37289 135702426I                  053225.0+653837054226.4+654152147.32 17.88 5.60  +1.24              gK5                 -0.006-0.018      -019V                          
+1917          CP-64  456  372972493092418                   053226.8-641737053259.6-641339273.80-32.72 5.34  +1.04 +0.85         G8-K0III           +0.041-0.010 +.010+010SBO                       *
+1918          BD-06 1262  37303132375               2467    053233.8-055956053727.4-055618209.79-19.15 6.05  -0.22 -0.93 -0.25   B1V               v+0.015+0.002      +029      260                 *
+1919          BD-11 1238  373061506172421                   053229.0-115010053708.8-114632215.37-21.75 6.11  +0.05               A2V                +0.020-0.020      +024V?                         
+1920          BD+07  953  37320112979                       053236.2+072855053801.1+073229197.53-12.59 5.88  -0.07 -0.37         B8III              +0.007-0.017      +019V?     35                  
+1921          BD+26  884  37329 77350      D                053243.3+263335053857.4+263704181.19-02.47 6.37R                     G9III              +0.024-0.018      +015                          *
+1922   Bet DorCP-62  487  37350249311 212          Bet Dor  053245.4-623319053337.5-622923271.73-32.77 3.76  +0.82 +0.55 +0.43   F6Ia              v+0.002+0.009 +.012+007V       0                 *
+1923          BD-04 1196  37356132387               2483    053257.3-045225053753.4-044849208.78-18.54 6.19  -0.04 -0.72 -0.05   B2IV-V             +0.004+0.021      +029       10                 *
+1924          BD+29  947  37367 77354                       053256.7+290927053918.4+291255179.04-01.03 5.96  +0.16 -0.50         B2IV-V             +0.012-0.004      +020SB         2.0   0.0      *
+1925          BD+53  934  37394 25319      W                053313.4+532626054120.3+532852158.38 11.95 6.23  +0.84 +0.51 +0.43   K1V                +0.002-0.518 +.081+002V          2.8 688.0AD   5*
+1926   Nu 1ColCD-27 2389  37430170601                       053319.4-275547053716.5-275217231.89-27.60 6.16  +0.34               F0IV               +0.014-0.061      +027                           
+1927          CD-47 1940  37434217422              TX Pic   053319.7-472230053602.7-471850253.76-32.01 6.11  +1.16               K2III+F            -0.014-0.017      +016SB2                        
+1928125    TauBD+25  902  37438 773602424  D                053332.3+255028053944.2+255349181.90-02.71 5.18  -0.15 -0.68         B3IV               +0.012-0.024      +015SBO    65  2.0   0.0     3*
+1929          BD+21  918  37439 77358                       053326.7+214224053927.0+214546185.38-04.95 6.34R +0.06 +0.10         A1Vn               -0.004-0.036      +015SB2   180                  
+1930          CP-58  526  37462234037                       053335.6-585603053502.4-585216267.43-32.74 6.75  +1.45 +1.80         K4III              -0.035+0.017      +032                           
+1931 48Sig OriBD-02 1326  37468132406        4241AB         053343.5-023928053844.8-023600206.82-17.34 3.81  -0.24 -1.01 -0.24   O9.5V              +0.002+0.001 +.007+029SB     94  0.8   0.2AB   5*
+1932          BD-02 1327  37479132408        4241E V1030 Ori053345.9-023907053847.1-023539206.82-17.32 6.65  -0.19 -0.86         B2Vp              v-0.018+0.012 +.007+029           0.8   0.2AB   5*
+1933          BD-06 1275  37481132405                       053346.0-063754053837.8-063426210.53-19.17 5.96  -0.23 -0.92         B1.5IV             -0.015+0.003      +015V     105                 *
+1934 47Ome OriBD+04 1002  374901130012423          Ome Ori  053354.3+040352053911.1+040717200.73-14.03 4.57  -0.11 -0.76 -0.10   B3IIIe            v+0.001-0.003      +022      194                 *
+1935   Nu 2ColCD-28 2321  37495170613                       053350.3-284458053744.6-284122232.81-27.75 5.31  +0.46 +0.10         F4V                -0.034+0.052 +.047+036V      31                  
+1936          CP-61  488  37501249314                       053351.8-611415053457.6-611033270.16-32.69 6.32  +0.85               G5IV               +0.006-0.022      +008                           
+1937 49    OriBD-07 1142  37507132411                       053402.7-071607053853.1-071247211.16-19.40 4.80  +0.13 +0.11 +0.06   A4V                -0.012-0.053 +.042-001SBO   170                 *
+1938          BD+31 1048  37519 583192425           2537    053407.6+311813054035.9+312129177.37  0.35 6.04  +0.04 -0.21 +0.05   B9.5III-IVp:       -0.007-0.020      -007      250                  
+1939          BD+31 1049  37536 58322    I         NO Aur   053411.9+315157054042.1+315515176.90  0.67 6.11  +2.12 +2.22 +1.42   M2IIIS             +0.010+0.006      +005                          *
+1940          BD-03 1166  37594132424                       053432.2-033714053931.2-033353207.81-17.61 6.00  +0.27 +0.01         A8V s              -0.002-0.003      +022                           
+1941 24    CamBD+56 1050  37601 25333                       053432.7+563145054301.6+563454155.74 13.68 6.05  +0.95 +0.73         K0III              +0.014+0.031      -029V?                         
+1942          BD-09 1197  37635132425                       053446.2-094543053930.8-094224213.62-20.35 6.50  -0.10 -0.48         B7V                +0.008-0.014      +021                          *
+1943 23    CamBD+61  816  37638 13590                       053456.6+612537054408.6+612836151.34 16.12 6.15  +0.90              gG5                 -0.005+0.001      -004V?                         
+1944          BD-17 1199  37643150652        4254           053451.8-175419053916.3-175058221.62-23.71 6.38  -0.12 -0.40         B7V                +0.001+0.003      +021V          1.5   0.6AB   9*
+1945          BD+29  953  37646 77393        4262A          053458.4+292607054121.0+292915179.04-00.50 6.43  -0.11 -0.39         B8IV               +0.019-0.029      +018SB    200  0.4  26.1      *
+1946126    TauBD+16  841  37711 94759        4265   2560    053530.9+162856054117.7+163202190.09-07.31 4.86  -0.13 -0.63 -0.12   B3IV               +0.008-0.018 +.014+021SB?    97  0.4   0.4      *
+1947          CD-40 1999  37717217450                       053530.8-404548053843.6-404227246.21-30.52 5.82  -0.09               B8V                -0.005+0.009      +004                           
+1948 50Zet OriBD-02 1338  37742132444    I   4263A  2553    053542.7-015943054045.5-015634206.45-16.59 2.05H -0.21 -1.07 -0.20   O9.7Ib            e+0.003-0.002 +.024+018SB    140  2.2   2.4AB   3*
+1949 50Zet OriBD-02 1338  37743          I   4263B  2553    053542.7-015943054045.6-015634206.45-16.59 4.21H                     B0III              +0.004-0.002 +.024+013SB         2.2   2.4AB   3*
+1950          BD-02 1337  37744132441                       053536.5-025242054037.3-024930207.25-17.03 6.22  -0.20 -0.88         B1.5V              +0.008+0.010      +029       35                 *
+1951          BD+23 1007  37752 77413                       053550.0+231631054154.6+231935184.35-03.65 6.59  -0.06 -0.53         B8p                -0.016-0.014      +026                          *
+1952          BD-01 1004  37756132445               2556    053546.0-011053054050.6-010744205.71-16.19 4.95  -0.21 -0.84         B2IV-V             -0.012-0.006      +026SBO    77                 *
+1953   Gam MenCP-76  333  37763256201 214  W                053550.3-762445053152.9-762028287.93-30.97 5.19  +1.13 +1.19 +0.55   K2III              +0.111+0.283 +.020+057V          6.0  38.2      *
+1954          BD+22  996  37784 77420                       053601.1+223636054203.9+223937184.93-03.96 6.36R                     K2                 -0.011-0.021      -021                           
+1955          BD+00 1152  37788113033                       053557.4+001705054105.6+002016204.40-15.44 5.93  +0.30 +0.04         F0IV               +0.015+0.028      -013V      52                 *
+1956   Alp ColCD-34 2375  37795196059 215  W        2549    053601.6-340738053938.9-340427238.81-28.86 2.64  -0.12 -0.46 -0.09   B7IVe             v+0.007-0.026 +.001+035V?    176  9.7  13.5      *
+1957          BD-10 1258  37808150680              V1051 Ori053603.3-102740054046.0-102434214.44-20.37 6.52  -0.16 -0.48         B9.5IIIpSi4200     -0.030-0.030      +020                          *
+1958          CD-32 2479  37811196061                       053607.8-324054053949.8-323745237.23-28.44 5.45  +0.92       +0.47   G6-8III            -0.022-0.029      -008                           
+1959          BD-02 1346  37904132465        4279           053639.4-025651054140.3-025346207.44-16.83 6.42  +0.30 +0.07         A9IV-V             +0.041+0.030      +030SB2        0.9   0.1      *
+1960          CP-66  439  37935249322                       053654.8-663700053654.7-663337276.51-32.10 6.31  -0.07 -0.15         B9.5V             e-0.022+0.010      +020                          *
+1961          BD+23 1015  37967 77450              V731 Tau 053715.1+230925054319.5+231215184.62-03.43 6.21  -0.06 -0.64         B2.5Ve             -0.001-0.022      +016                          *
+1962          BD-16 1208  37971150703                       053714.2-164633054141.5-164332220.74-22.74 6.21  -0.13               B3IVp              -0.005+0.009      +016                          *
+1963 51    OriBD+01 1105  379841130562427I                  053718.3+012534054228.6+012829203.54-14.59 4.91  +1.17 +1.06 +0.61   K1III              -0.058-0.015 +.015+088V?   < 17                 *
+1964          CP-73  316  379932562082422          WX Men   053714.1-734802053444.7-734429284.90-31.30 5.78  +1.71 +1.83 +1.53   M3III              -0.003+0.033      -011                          *
+1965          BD-17 1214  38054150716                       053749.3-173444054214.3-173149221.60-22.94 6.15  +1.38               K0                 -0.036+0.007      +062V                          
+1966          CD-33 2483  38056196088                       053747.3-332700054127.0-332402238.18-28.32 6.34  -0.04               A0V                +0.014-0.002      +029                           
+1967          BD-06 1293  38089132477        4299           053802.4-065043054253.8-064746211.24-18.32 6.02  +0.40 -0.05         F3V                -0.003+0.068D+.019-007SB         0.4   0.2AB   4*
+1968 12    LepBD-22 1194  38090170715                       053801.5-222520054213.9-222225226.52-24.73 5.87  +0.11               A2                 -0.004+0.018      +028                          *
+1969 26    CamBD+56 1058  38091 25362               2615    053804.6+560427054630.4+560656156.39 13.88 5.94  +0.17 +0.12         A4Vn               +0.019-0.056      +021SB    260                  
+1970          BD-01 1012  38099132480    I         V1197 Ori053805.7-013934054309.3-013647206.44-15.90 6.31  +1.47 +1.77         K4III              +0.003-0.026      +030SBO                       *
+1971 27Omi AurBD+49 1398  38104 40583 216                   053809.1+494658054554.0+494935161.98 10.75 5.47  +0.03 +0.07 +0.01   A2VpCr             -0.010+0.001 +.019-006V      30                 *
+1972          CD-30 2571  381381960962428                   053822.8-303501054211.6-303208235.12-27.37 6.19  +0.01               A0V                +0.002+0.007      +027                           
+1973          CD-34 2401  38170196098                       053840.0-344300054215.1-344004239.62-28.49 5.29  -0.05               B9.5V              -0.008+0.051      +035       41                  
+1974          BD+40 1403  38189 40584                       053848.6+402752054549.5+403026170.11  6.03 6.58  +0.25 +0.02 +0.15   A3Del Del          -0.031-0.005      -004       67                  
+1975          BD-18 1172  38206150739                       053858.9-183610054321.6-183327222.74-23.08 5.73  -0.01 -0.11         A0V s              +0.016-0.015      +025    =< 41                  
+1976          BD+62  784  38284 13618        4376           053938.3+624614054904.9+624829150.37 17.24 6.13R                     A4V                -0.007-0.010D+.010-004V     125  0.9   0.9       
+1977          BD+20 1083  38307 77516    I         Y Tau    053941.7+203911054539.4+204142187.05-04.28 6.95  +3.03 +5.81 +1.52   C5II               -0.001 0.000      +017                          *
+1978          BD+03 1025  38309113099        4333           053945.1+035757054501.9+040029201.57-12.81 6.09  +0.31 +0.09        gF0n                +0.020-0.019      +008       82  4.2  15.7AB   3*
+1979          BD+42 1396  38358 406092431                   054005.1+422922054714.7+423136168.49  7.29 6.29  +1.35 +1.59         K0                 +0.009-0.088      -016                           
+1980          BD-20 1171  38382170756                       054010.0-201014054428.4-200735224.43-23.43 6.34  +0.58               G0                 -0.016+0.046      +038V?                         
+1981          CD-39 2140  383851961162430                   054011.9-392704054330.2-392425244.95-29.36 6.25  +0.37               F3V                +0.051-0.002      +013                           
+1982          BD-22 1210  38392170757        4334B          054016.4-222717054426.5-222518226.76-24.26 6.15  +0.94 +0.74 +0.35   K2V                -0.309-0.353 +.128-010           2.5  96.5AB   3*
+1983 13Gam LepBD-22 1211  38393170759 217I   4334A          054017.6-222851054427.8-222654226.79-24.27 3.60  +0.47  0.00 +0.26   F6V                -0.293-0.370 +.128-010       11  2.5  96.5AB   3*
+1984          CD-45 2131  38458217497               2613    054050.8-455243054341.1-454959252.25-30.51 6.39  +0.29 +0.13         A9V                +0.029+0.091      +011                          *
+1985129    TauBD+15  926  38478 94848                       054100.4+154700054645.5+154921191.39-06.55 6.00  -0.06 -0.44         B8IIIpHgMn:        +0.004-0.004      +019       80                  
+1986          BD-04 1235  38495132515        4361           054105.4-041823054602.8-041606209.24-16.48 6.34  +1.05 +0.99         K1III+G0IV          0.000-0.068      -046           2.7   6.9      *
+1987          BD+09  954  385271131242432    4369           054122.7+092908054652.1+093120196.90-09.71 5.79  +0.88 +0.58         G8III              -0.034-0.065      -026           5.9  17.2      *
+1988          BD+01 1126  38529113119                       054125.4+010800054635.0+011005204.32-13.83 5.95  +0.78 +0.42         G4V                -0.073-0.148 +.027+029V                         *
+1989131    TauBD+14 1025  38545 94855                       054131.3+142706054713.2+142918192.60-07.14 5.72  +0.04 +0.16         A3Vn               +0.010-0.039 +.021+021V                          
+1990130    TauBD+17 1004  38558 94858 218                   054136.3+174130054726.2+174345189.82-05.44 5.49  +0.30 +0.27         F0III              -0.005-0.006      +009       51:                 
+1991   Iot MenCP-78  195  38602256214              Iot Men  054143.6-785223053536.3-784915290.68-30.22 6.05  -0.02 -0.33         B8III              +0.008+0.017      +013V?                        *
+1992 29    CamBD+56 1065  38618 25403        4412           054202.1+565309055034.0+565508155.93 14.75 6.54                      A4IV-V             -0.009-0.008      +004V?         4.2  25.1AB   3*
+1993133    TauBD+13  979  38622 948642433    4381           054202.6+135148054742.9+135359193.17-07.33 5.29  -0.17 -0.66         B2IV-V             +0.002-0.012 -.002+029       70  6.1  24.9AC   3*
+1994          BD+68  412  38645 136352438                   054210.0+682633055255.5+682817145.13 19.98 6.20  +0.95               G9III              +0.005-0.051 +.004-001                           
+1995 29Tau AurBD+39 1418  38656 58465    I   4398           054214.7+390850054910.5+391052171.58  5.91 4.52  +0.94 +0.70 +0.49   G8IIIFe-1          -0.025-0.022 +.007-020     < 17  6.1  49.6AC   3*
+1996   Mu  ColCD-32 2538  38666196149               2630    054216.9-322040054559.9-321823237.29-27.10 5.17  -0.28 -1.06 -0.27   O9.5V              +0.009-0.025      +109      153                 *
+1997          BD+20 1105  38670 77578        4392           054224.1+205004054822.4+205210187.23-03.64 6.07  -0.08 -0.38         B9Vn               +0.014-0.016D+.001+007SB    175  1.4   0.5AB   3*
+1998 14Zet LepBD-14 1232  38678150801 219                   054225.4-145133054657.3-144919219.40-20.83 3.55  +0.10 +0.07 +0.03   A3Vn               -0.016-0.001 +.049+020SB?   202                  
+1999 52    OriBD+06 1027  38710113150        4390           054237.8+062508054800.2+062715199.75-10.98 5.27  +0.23 +0.17         A5V                +0.007-0.019 +.023+043SB2   110  0.1   1.4      *
+2000          BD-16 1244  38713150806                       054239.4-161628054707.6-161416220.81-21.35 6.17  +0.89               G2Ib-II            -0.034+0.003      +007V                          
+2001          BD-10 1281  38735150814      S       V1031 Ori054244.4-103407054726.7-103159215.30-18.94 6.03  +0.16               A4V                -0.029-0.024      -001SB3                       *
+2002132    TauBD+24  970  38751 775922435I D        2650    054252.7+243202054901.0+243403184.13-01.61 4.86  +1.01 +0.81 +0.38E  G8III             v-0.004-0.023 +.005+016V?   < 19  0.0   0.1       
+2003          BD+51 1117  38765 254112437                   054259.5+512902055056.4+513053160.87 12.26 6.29  +1.05               K1III              +0.167-0.030      +026                           
+2004 53Kap OriBD-09 1235  38771132542 220I          2641    054300.8-094218054745.4-094011214.51-18.50 2.06  -0.17 -1.03 -0.18   B0.5Ia            v+0.002-0.002 +.015+021V?     82                 *
+2005          CD-28 2449  38804170836                       054310.1-284031054704.7-283821233.45-25.79 6.22  -0.15               B5V                +0.006+0.006      +018                           
+2006 30    CamBD+58  863  38831 25419                       054328.3+585607055217.4+585751154.15 15.88 6.14  -0.04 -0.13         A0V s              +0.007-0.023      +012      400:                 
+2007          BD-04 1244  388581325541155                   054336.7-040720054834.9-040541209.37-15.84 5.97  +0.64 +0.10         G4V                +0.062-0.225      +029V                          
+2008          CD-46 1999  388712175212434  W                054341.0-463802054627.4-463550253.21-30.16 5.31  +1.04               K0-1II             +0.012+0.004 +.018+011           7.4  37.0       
+2009          CD-35 2509  38885196171                       054347.1-354240054718.6-354029241.02-27.75 6.32  +1.18               K1III              -0.008+0.041      +057                           
+2010134    TauBD+12  912  38899 94888      W                054355.8+123711054932.9+123904194.49-07.57 4.91  -0.07 -0.17 -0.08   B9IV               -0.020-0.024      +018V      22  5.4  18.9       
+2011 31Ups AurBD+37 1336  38944 584962440I          2661    054413.1+371636055102.4+371820173.39  5.28 4.74  +1.62 +1.93 +1.07   M0+III-IIIbFe-0.5  +0.035-0.047 -.002+038                          *
+2012 32Nu  AurBD+39 1429  39003 58502 221I   4440           054433.5+390709055129.4+390855171.84  6.28 3.97  +1.13 +1.09 +0.56   G9.5III*           -0.005+0.007 +.017+010V?   < 17  7.3  54.6      *
+2013          BD+27  888  39004 77625        4474           054439.9+275617055058.1+275804181.44  0.51 5.56  +0.97              gG7                 -0.009+0.012      +008V          1.3   0.0 O   3*
+2014          BD+09  978  39007113179                       054432.0+095026055002.6+095216196.98-08.85 5.80  +0.87 +0.62 +0.30E  G8III              +0.005-0.010      +044V?                        *
+2015   Del DorCP-65  496  390142493461154                   054435.6-654623054446.4-654408275.47-31.37 4.35  +0.21 +0.12 +0.17   A7V                -0.031+0.008 +.027-003      206                  
+2016135    TauBD+14 1041  39019 94904                       054447.5+141636055028.9+141820193.16-06.55 5.52  +1.01              gG9                 +0.006-0.035      +046V?                         
+2017          CD-40 2085  39040217543                       054445.3-404111054758.1-403909246.55-28.79 6.61  +1.12               K1III              +0.007+0.032      +013SB2                        
+2018          BD+32 1109  39045 58504    I   4443  Var      054454.6+320546055125.7+320730177.91  2.72 6.25  +1.75 +2.00 +1.40   M3III             v+0.001+0.007      +103           5.9  15.2      *
+2019          BD+04 1052  390511131862439I                  054455.4+042339055013.1+042524201.83-11.48 5.97  +1.36 +1.57        gK2                 +0.005-0.039      +027V?                         
+2020   Bet PicCD-51 1620  39060234134                       054454.9-510609054717.1-510359258.37-30.61 3.85  +0.17 +0.10 +0.16   A5V                +0.011+0.085 +.061+020V?    139                 *
+2021          BD-14 1251  39070150845        4432           054503.8-143047054936.5-142901219.35-20.10 5.49  +0.88              gG6                 -0.025-0.044D+.009-002V          3.0   2.6      *
+2022   Pi  MenCP-80  161  39091258421                       054506.8-803240053709.8-802809292.53-29.78 5.65  +0.60 +0.11 +0.19E  G1V                +0.305+1.054 +.044+009V?                        *
+2023          CP-54  892  39110234137                       054512.0-542339054713.0-542139262.18-30.93 6.18  +1.40               K3III              -0.016-0.009      -003                           
+2024          BD+01 1148  39118113198              Var      054518.0+015944055030.0+020128204.02-12.57 5.98  +0.91 +0.30         G8III+A0IV         +0.001-0.015      +007SBO =< 50                 *
+2025          BD+39 1435  39182 58524                       054542.0+393255055239.5+393428171.58  6.69 6.45R +0.09 +0.17         A2V                -0.026-0.016      -019                           
+2026          CD-23 3135  39190170892                       054542.9-230007054953.5-225818227.82-23.29 5.87  +0.06               A2                 -0.014+0.025      +044                           
+2027 31    CamBD+59  920  39220 254472446          TU Cam   054600.3+595157055457.8+595318153.44 16.59 5.20  +0.02 +0.03         A2V                +0.001-0.019 +.009-003SB2O   76                 *
+2028          BD+33 1179  39225 585282443I          2681    054602.8+335329055240.1+335503176.50  3.85 5.98  +1.60 +1.97         M1.5II-III         +0.020+0.008      +100                          *
+2029 30Xi  AurBD+55 1027  39283 254501157                   054627.9+554101055450.8+554225157.33 14.72 4.99  +0.05 +0.12 +0.02   A2V                -0.013+0.020 +.012-012V?     72                 *
+2030          BD+19 1110  39286 94942                       054627.9+195032055223.4+195205188.57-03.34 6.06  +0.54 -0.01         G2IIIe+B8III       -0.002+0.003      -003V?    230                 *
+2031 55    OriBD-07 1187  392911325912442           2677    054632.3-073241055122.0-073105212.89-16.76 5.35  -0.20 -0.83         B2IV-V             -0.001+0.003      +020V     164                 *
+2032          CD-44 2274  39312217559                       054639.7-445416054934.1-445231251.36-29.34 6.38  +1.27               K1III              -0.004+0.011      +029                           
+2033137    TauBD+14 1060  39317 94945              V809 Tau 054641.4+140847055222.3+141018193.51-06.22 5.59  -0.05 -0.06         B9pSiCrEu          -0.020-0.005      -004V      35                 *
+2034136    TauBD+27  899  39357 776751158  D        2696    054702.4+273519055319.6+273644182.01  0.77 4.58  -0.02 +0.03  0.00   A0V                +0.003-0.012 +.021-016SB2O   41  1.5   0.0      *
+2035 15Del LepBD-20 1211  39364170926 222I                  054701.2-205315055119.3-205245225.82-22.22 3.81  +0.99 +0.68 +0.56   K0IIIFe-1.5CH0.5   +0.227-0.649 +.022+099        0                 *
+2036          BD-22 1246  39385170931                       054717.8-225705055128.6-225534227.91-22.93 6.17  +1.02               K0                 -0.001-0.018      +026                           
+2037 56    OriBD+01 1151  394001132202444I   4467   2690    054714.8+014951055226.4+015118204.41-12.22 4.78  +1.38 +1.47         K1.5IIb            -0.007-0.012 +.005+010     < 19: 8.4  43.4       
+2038          BD+20 1156  39417 77680                       054722.3+201633055319.1+201757188.31-02.94 6.71  -0.07 -0.33         B9V                +0.005-0.010      -006      175                  
+2039          BD-09 1255  39421132603                       054721.7-090404055207.6-090229214.41-17.25 5.97  +0.10 +0.08         A2Vnp              -0.027+0.052      +039                          *
+2040   Bet ColCD-35 2546  39425196240 223I:                 054726.0-354821055057.6-354606241.35-27.06 3.12  +1.16 +1.21 +0.58   K2III              +0.059+0.401 +.023+089V                         *
+2041          BD+66  413  39429 136622448                   054725.7+660442055735.0+660546147.63 19.44 6.25  +1.36 +1.64         K0                 +0.048-0.016      -022                           
+2042   Gam PicCP-56  946  395232341541156                   054800.6-561130054949.7-561000264.31-30.69 4.51  +1.10 +0.98 +0.54   K1III              +0.083-0.076 +.018+016                          *
+2043          CD-29 2556  39543170945                       054807.6-292824055159.5-292655234.68-25.02 6.45  +1.48 +1.72         K3III              -0.004+0.020      +002                           
+2044          CP-52  791  39547234162      W                054817.3-524738055028.6-524604260.39-30.30 6.35  +0.76               K0-1III+A4V+A      -0.025+0.015      +001           0.8   0.2       
+2045          BD+51 1128  39551 25467                       054817.5+514707055614.4+514814161.00 13.13 6.49R                     A5V                -0.009-0.008      -012                           
+2046          BD+31 1139  39586 58569                       054829.5+314111055459.0+314206178.66  3.15 5.90  +0.14?+0.13?        A5IV               -0.043-0.176 +.023-021      105                  
+2047 54Chi1OriBD+20 1162  39587 77705    I D                054827.6+201528055422.9+201634188.46-02.73 4.41  +0.59 +0.07 +0.31   G0V                -0.189-0.084 +.104-014SB?     6        0.6     3*
+2048          BD+10  927  39632 94977    I                  054841.0+103357055413.4+103513196.87-07.61 6.12  +1.47 +1.43         G9II               +0.006+0.008      +013                           
+2049          CP-52  794  396402341691159                   054837.4-520754055053.2-520632259.64-30.17 5.17  +0.99 +0.72 +0.42   G8III              +0.006-0.078 +.023+001                           
+2050          BD+11  964  39662 94979      W                054857.0+114440055432.2+114545195.88-06.96 6.59  +0.03 +0.02         A2V                +0.008-0.068      +028           5.5  22.7      *
+2051          BD+03 1071  39685113253                       054900.5+031224055415.7+031331203.40-11.17 6.31  +1.29 +1.47         K0                 +0.053-0.061      -004                           
+2052 57    OriBD+19 1126  39698 949862447           2722    054901.4+194349055456.7+194459188.98-02.88 5.92  -0.17 -0.74         B2V                -0.003-0.004      +007SBO   121  2.2   0.0      *
+2053          CD-37 2457  39720196266      W                054908.5-373909055233.2-373752243.46-27.23 5.63  +1.04 +0.87         K1III              +0.033-0.031      +032           6.1  16.5AB   3*
+2054          BD+49 1423  39743 40720                       054923.5+490049055704.9+490146163.58 11.96 6.47  +0.99               G8III              +0.019-0.016      -002                           
+2055          CD-38 2270  39752196274      W                054926.7-383250055247.7-383133244.45-27.40 6.70  +1.08               K1III              +0.004-0.004D+.003+004           3.5   1.2       
+2056   Lam ColCD-33 2599  39764196276              Lam Col  054929.0-334924055306.9-334805239.36-26.09 4.87  -0.15 -0.57 -0.15   B5V                -0.004+0.033 +.035+030V      88                 *
+2057          BD+00 1208  39775113265    I                  054934.4+005658055444.1+005806205.49-12.14 6.00  +1.34 +1.45         K0III              +0.003-0.003      +022                           
+2058          BD-04 1281  39777132635                       054936.8-040502055434.7-040350210.05-14.50 6.57  -0.18 -0.81         B1.5V              -0.001+0.020      +025       20                 *
+2059          CP-84   75  397802584181659          TZ Men   054933.7-845007053013.9-844706297.35-28.83 6.20  -0.02 -0.11         B9.5IV-V           -0.008+0.046      -004SBO                       *
+2060          BD-19 1293  39789150925                       054937.9-193930055357.4-193818224.85-21.18 6.69  +0.10               A4V                -0.025+0.004      +002                           
+2061 58Alp OriBD+07 1055  39801113271 224I   4506  Alp Ori  054945.4+072319055510.3+072425199.79-08.96 0.50  +1.85 +2.06 +1.28   M1-2Ia-Iab        e+0.026+0.009 +.005+021SB         9.9 174.4AE   6*
+2062   Lam MenCP-72  418  398102562392441                   054950.0-724349054748.1-724208283.55-30.52 6.53  +1.08 +0.97         K0III              -0.011+0.022      +015                           
+2063          BD+20 1171a 39816 77730    I         U Ori    054952.8+200929055549.3+201030188.72-02.49 5.4   +0.99 +0.43         M6.5IIIe            0.000-0.014      -021V?                        *
+2064   Eps DorCP-66  463  39844249368               2693    054959.8-665534054953.6-665404276.80-30.80 5.11  -0.14 -0.49         B6V                -0.016+0.016 +.012+016                           
+2065          BD-11 1321  39853150932    I                  055003.6-114737055443.6-114626217.29-17.85 5.66  +1.53 +1.84         K5III              +0.066+0.039      +086V?                        *
+2066          BD+28  952  39866 77744                       055012.6+285535055633.8+285632181.22  2.06 6.32  +0.30 +0.26         A2II               +0.003-0.001      +019                           
+2067          BD+13 1036  39881 95004        4519           055020.4+135518055603.5+135531194.16-05.57 6.60  +0.65 +0.13         G5IV               +0.384-0.467 +.047-002V          1.9  47.5AB   4*
+2068          CD-29 2595  39891170993      W                055021.4-290954055414.1-290852234.53-24.46 6.36  +0.37               F3V                -0.020-0.051      +018           0.0   0.1       
+2069          CD-42 2205  39901217599                       055019.7-425629055322.9-425517249.32-28.29 6.55  +1.37               K3III              +0.012+0.009      -010                           
+2070          BD-04 1289  39910132652                       055033.4-043759055530.3-043659210.67-14.54 5.87  +1.18 +1.21        gK2                 +0.040-0.017      +026V?                         
+2071          BD-04 1291  39927132653                       055039.3-044816055535.4-044718210.84-14.60 6.28  +0.06 +0.07         A2III              -0.011-0.019      -014                           
+2072          CP-57  901  39937234181               2714    055039.6-571029055220.3-570922265.48-30.41 5.94  +0.66               F7IV               +0.024-0.078      +008V                          
+2073          CP-64  486  39963249376                       055050.2-640320055123.0-640201273.46-30.72 6.36  +0.86 +0.57         G8III              -0.011+0.016      +013                          *
+2074          BD+24 1033  39970 77750                       055048.6+241406055656.1+241459185.32-00.22 6.02  +0.39 -0.19         A0Ia               +0.002 0.000      +001V      60                 *
+2075          BD+09 1016  39985113284                       055058.3+092940055628.0+093035198.09-07.65 5.99  -0.07 -0.15         A0IV                0.000-0.001      +013       83                  
+2076          BD+11  975  40020 950272453                   055114.1+113029055649.5+113116196.37-06.59 5.87  +1.10               K2III              +0.106-0.058      +021                           
+2077 33Del AurBD+54  970  40035 25502 225I W                055117.5+541637055931.6+541705158.95 14.69 3.72  +1.00 +0.87 +0.50   K0-III             +0.081-0.125 +.022+008     < 17  5.8 115.4AB   4 
+2078          BD+75  247  40055  57302459                   055121.8+753455060509.3+753509138.34 23.40 6.40R                     K5                 +0.009-0.010      +004                           
+2079          BD+55 1036  40062 25504                       055125.4+551846055945.7+551915158.00 15.18 6.44  +0.31 +0.12 +0.13   A5m                -0.015-0.088      +045                           
+2080          BD+54  971  40083 25505                       055133.0+543216055948.1+543250158.73 14.84 6.14  +1.20 +1.33         K2III              +0.011-0.035      -006                           
+2081          BD+49 1428  40084 40743                       055135.7+495449055921.8+495528162.95 12.70 5.89  +1.23               G5III              -0.002-0.009      -004SBO                       *
+2082          CD-39 2260  400911963092449                   055137.2-395829055452.5-395729246.12-27.36 5.57  +1.51 +1.85         M0III              -0.014+0.016      +114V                          
+2083          CD-50 1977  40105234191                       055143.8-502342055410.7-502143257.72-29.44 6.52  +0.90 +0.63 +0.30E  G8IV               +0.086+0.569 +.034+002                           
+2084139    TauBD+25 1052  40111 77775                       055147.3+255630055759.7+255714183.97  0.84 4.82  -0.06 -0.93 -0.11   B0.5II              0.000-0.002      +008SB    131                 *
+2085 16Eta LepBD-14 1286  40136150957 226I                  055151.0-141109055624.3-141004219.76-18.47 3.71  +0.33 +0.01 +0.16   F1III              -0.042+0.139 +.066-002        0                  
+2086          BD-22 1269  40151171034                       055202.3-225118055614.3-225025228.25-21.88 5.96  +1.11 +0.99?        K0V                +0.119+0.021      +034V                          
+2087   Xi  ColCD-37 2487  40176196316                       055203.4-370807055529.9-370715243.07-26.53 4.97  +1.11               K1III              +0.032-0.026 -.011+060V                          
+2088 34Bet AurBD+44 1328  40183 40750 227I   4556  Bet Aur  055211.5+445615055931.7+445651167.46 10.41 1.90  +0.03 +0.05 -0.01   A2IV               -0.057 0.000 +.041-018SB2O   37  8.9 184.6AB   3*
+2089          CD-49 1945  402002176122450                   055211.0-493836055441.1-493737256.89-29.25 6.10  -0.13               B3V                -0.009+0.016      +012                           
+2090          CD-23 3263  40235171045                       055224.3-231346055634.5-231256228.66-21.94 6.36  +1.07               K0                 +0.014+0.026      -005V                          
+2091 35Pi  AurBD+45 1217  40239 40756    I         Pi  Aur  055230.7+455540055956.1+455613166.60 10.94 4.26  +1.72 +1.83 +1.48   M3II              e 0.000-0.005 +.003+001V                         *
+2092   Sig ColCD-31 2848  402481963302454                   055235.1-312346055620.9-312257237.03-24.73 5.50                      F2III              -0.002+0.006      +019       79                  
+2093          BD+01 1168  40282113306    I                  055244.4+011246055754.2+011328205.64-11.31 6.22  +1.48 +1.84         M0III              -0.069+0.008      +037                           
+2094          CP-52  805  40292234199                       055237.9-523927055450.2-523807260.32-29.63 5.29  +0.31  0.00?        F0VDel Del         -0.005+0.248 +.034+027        0                 *
+2095 37The AurBD+37 1380  40312 58636    I   4566  The Aur  055254.1+371221055943.3+371245174.34  6.73 2.62  -0.08 -0.18 -0.06   A0pSi              +0.048-0.081 +.022+030SB     49  4.5   3.5AB   4*
+2096          BD+44 1332  40325 40769        4576           055300.1+443506060019.0+443531167.84 10.37 6.22                      K2III+K0III        -0.026-0.041      +002           4.0  34.2AC   3*
+2097          BD-01 1078  40347132700                       055306.6-010014055811.7-005939207.67-12.29 6.22  +1.14 +1.20         K0                 +0.007-0.025      +061                           
+2098          CD-31 2854  40359196335                       055305.0-315920055649.0-315834237.68-24.82 6.44  +1.07               G8III              +0.002+0.019      +029                           
+2099          BD+12  968  40369 95075        4562           055315.6+124755055853.2+124831195.49-05.52 5.70  +0.89 +0.63?        K2III+A5V          -0.014+0.021D+.006+012V          1.0   0.4      *
+2100 59    OriBD+01 1171  40372113315        4555  V1004 Ori055312.7+014938055824.4+015013205.14-10.92 5.90  +0.21 +0.17         A5mDel Del         +0.005-0.008      +045SBO    60  4.7  36.7      *
+2101 36    AurBD+47 1227  40394 40778                       055323.3+475344060058.6+475407164.91 12.01 5.73  -0.01 -0.12         B9.5pSiFe          +0.006-0.018      +016                           
+2102          CP-63  498  404092493902452                   055320.0-630712055406.1-630524272.38-30.42 4.65  +1.05 +0.96 +0.50   K1III-IV           +0.138+0.537 +.048+025                          *
+2103 60    OriBD+00 1239  404461133211161  W                055341.0+003238055849.6+003311206.35-11.43 5.22  +0.01 +0.01         A1V s              -0.013+0.002 +.004+035SB     47  6.6  19.1       
+2104          CP-64  495  40455249391                       055344.6-642955055411.9-642856273.98-30.42 6.63  +0.38 +0.10         F0III              -0.003+0.064      +013                           
+2105          BD+48 1333  40486 407892458I                  055402.2+485716060143.1+485734164.01 12.60 5.96  +1.45               K0                 +0.005-0.015      +011                           
+2106   Gam ColCD-35 2612  404941963521160  W                055359.4-351738055732.2-351700241.23-25.64 4.36  -0.18 -0.66 -0.17   B2.5IV              0.000+0.009      +024       96  8.3  33.8       
+2107  1    MonBD-09 1284  40535132714              V474 Mon 055415.7-092327055901.0-092256215.50-15.87 6.12  +0.29 +0.10         F2IV               +0.014+0.012      +012SB     25                 *
+2108  2    MonBD-09 1285  405361327152455                   055419.4-093354055904.3-093330215.67-15.93 5.03  +0.19 +0.16 +0.09   A6IIIm vs          +0.009-0.050 +.010+022SBO    23                 *
+2109          BD-01 1083  40574132723                       055433.7-012704055937.7-012640208.25-12.18 6.63  -0.07 -0.39         B8IIIn             -0.009-0.020      -004                           
+2110          BD+31 1164  40588 58657                       055442.4+310146060110.2+310205179.90  3.97 5.98R +0.08 +0.14         A2V                -0.001+0.009      -009      100                  
+2111          BD+27  945  40589 77837        4589           055443.3+273402060100.4+273420182.90  2.23 6.05  +0.25 -0.26         B9Iab              -0.001-0.004      +017       57  6.0   9.5      *
+2112          BD+49 1441  40626 40801                       055502.4+495415060248.7+495420163.22 13.19 6.05  -0.06 -0.10         B9.5IV             +0.024-0.046      +025       20                  
+2113          BD-03 1256  406571327322457I          2770    055503.1-030441060003.4-030427209.79-12.83 4.53  +1.22 +1.21 +0.67   K1.5IIIFe-1.5      +0.012-0.076 +.022+026     < 17                  
+2114          CP-53  978  40665234224      W        2753    055507.0-532606055714.4-532534261.27-29.37 6.45  +1.48               K5-M0III           +0.016-0.014      +073           1.0  55.9AB   3*
+2115          BD+43 1421  40722 40808                       055539.8+432239060253.6+432243169.15 10.21 6.42R                     K0                 +0.020-0.024      -019                           
+2116          BD+22 1140  40724 77858      D                055539.2+222353060141.6+222403187.47-00.20 6.37  -0.07 -0.28         B8V                -0.011-0.020      +024       40                 *
+2117          CD-44 2363  40733217648                       055539.5-440230055837.6-440204250.77-27.59 5.81  +1.07 +0.87         G8II               -0.001+0.014      +012V                          
+2118          BD-12 1337  40745151011                       055540.9-125413060017.7-125359218.96-17.08 6.22  +0.36               F0                 -0.007-0.039      +033       45                  
+2119 38    AurBD+42 1473  40801 408182461                   055605.3+425453060318.0+425442169.60 10.05 6.10  +0.97 +0.78         K0II               +0.112-0.141 +.014+038V?                        *
+2120   Eta ColCD-42 2266  40808217650 229                   055605.1-424914055908.8-424855249.46-27.23 3.96  +1.14 +1.08 +0.58   K0III              +0.022-0.014 +.019+017                           
+2121          BD+59  937  40827 25551                       055614.9+592347060508.3+592335154.47 17.55 6.34  +1.10 +1.10         K1III-IV           +0.005-0.051      +031                          *
+2122          BD+32 1166  40832 58688                       055621.5+323827060255.1+323809178.68  5.07 6.24  +0.42 -0.01         F4V                +0.076-0.209 +.028+034       12                  
+2123          BD+51 1146  40873 255482463    4633   2804    055633.3+513433060429.1+513424161.80 14.17 6.45  +0.18 +0.16         A7III              +0.005-0.042      +020V      99  2.8  39.0AB   3*
+2124 61Mu  OriBD+09 1064  40932113389        4617   2792    055652.8+093850060223.0+093851198.68-06.31 4.12  +0.16 +0.11 +0.10   A2V                +0.015-0.028 +.028+045SB1O   24  1.8   0.3AB   3*
+2125   Kap MenCP-79  202  409532562482451                   055701.7-792243055016.7-792141291.13-29.44 5.47  -0.08 -0.24         B9V                -0.009+0.066      +010                           
+2126          BD+63  630  40956 13715                       055704.8+632729060639.2+632713150.61 19.31 6.39R                     K0                 -0.030+0.006      -015                           
+2127          BD+01 1195  40964113392                       055705.8+014136060217.1+014140205.74-10.13 6.59  -0.05 -0.27         B8V                +0.004+0.007      +003                           
+2128  3    MonBD-10 1349  40967151037        4615           055708.1-103557060150.4-103553216.95-15.77 4.95  -0.12 -0.60 -0.09   B5III              -0.007 0.000D+.003+039SB     65  3.5   1.9      *
+2129          CD-25 2865  409721711382460                   055709.3-252509060113.1-252504231.28-21.74 6.05  +0.02               A1V                -0.008-0.018      +012                           
+2130 64    OriBD+19 1186  41040 95166      D        2803    055732.1+194132060327.3+194126190.03-01.18 5.14  -0.11 -0.43         B8III              -0.001-0.017      +012SB2    17  0.0   0.0     3*
+2131          CD-33 2681  41047196413    I:                 055738.7-335445060116.4-335442240.02-24.51 5.55  +1.58 +1.94         K5III              +0.015-0.020      +019                           
+2132 39    AurBD+42 1477  41074 40840               2812    055751.8+425921060503.4+425854169.69 10.37 5.87  +0.30 +0.06         F3V                -0.039-0.143      +034V?     82                 *
+2133          BD+11 1009  41076 95170                       055749.8+114058060324.7+114051197.02-05.10 6.08  -0.04 -0.03         A0V s              -0.016-0.015      -013V      19                  
+2134  1    GemBD+23 1170  41116 779151163I W       Var?     055802.4+231608060407.2+231548186.99  0.72 4.16  +0.82 +0.52 +0.45   G7III              -0.008-0.100 +.031+020SBO        0.4   0.2AB   4*
+2135 62Chi2OriBD+20 1233  41117 77911      D        2809    055758.8+200827060355.2+200818189.69-00.86 4.63  +0.28 -0.68 +0.22   B2Ia              t+0.002-0.006 +.025+017V      36  0.0   0.0      *
+2136          BD-14 1315  41125151052                       055801.0-142948060233.8-142950220.72-17.25 6.20  +0.96               G5                 +0.011+0.012      +045                           
+2137          BD+37 1405  41162 58716        4649           055810.9+375806060502.6+375751174.18  8.02 6.34                      K0III+A2           +0.003-0.007      +005    =< 23  5.6  17.9AB   3*
+2138          CD-51 1713  41214234251                       055828.4-511311060049.2-511259258.86-28.53 5.67  +0.20               Am                 -0.021+0.094      +005        0                  
+2139          BD+33 1236  41269 58727                       055857.8+333618060534.0+333557178.10  6.02 6.23  -0.08 -0.26         B9pSi              +0.008-0.013      +025       75                  
+2140          CD-26 2675  41312171180    I   4645           055913.7-261702060315.5-261704232.33-21.62 5.04  +1.34 +1.44 +0.55E  K3III              +0.056+0.092      +182V?         7.3   2.2AB   3*
+2141          BD+35 1334  41330 58739      W                055927.2+352410060608.5+352315176.57  6.99 6.12  +0.60 +0.06         G0V                -0.131-0.302 +.046-012V   =< 10  3.4 122.0       
+2142          BD-06 1391  41335132793               2817    055921.9-064217060413.5-064233213.60-13.54 5.21  -0.06 -0.85 +0.04   B2Ven             v-0.005-0.003      +025SB    419                 *
+2143 40    AurBD+38 1377  41357 587492465          Var?     055941.4+382930060635.1+382858173.87  8.53 5.36  +0.25 +0.15 +0.09   A4m                +0.007-0.049 +.004+018SB2O   26                 *
+2144 63    OriBD+05 1085  41361113429                       055938.2+052532060458.2+052512202.73-07.78 5.67  +1.04 +0.83        gG7                  0.000+0.003      +020V?                         
+2145 66    OriBD+04 1116  41380113430 230                   055941.3+040952060458.4+040931203.85-08.38 5.63  +1.04 +0.75         G4III              -0.001-0.005      +033V?                         
+2146          BD+29 1112  41429 77958    I   4673           055959.3+293113060622.5+293045181.78  4.20 6.08  +1.73 +1.94         M3II+F7V           +0.015-0.006      -036           5.0  10.0      *
+2147          BD+41 1357  41467 40868                       060019.7+415151060726.9+415115170.92 10.24 6.12  +1.22               K0III              +0.007-0.021      +006                           
+2148 17    LepBD-16 1349  41511151093    I         SS Lep   060031.3-162839060459.1-162904222.87-17.53 4.93  +0.24 +0.12 +0.52   A2eShell          v-0.006-0.001 +.032+020SB2O   98                 *
+2149          CD-32 2743  415341964592464  W                060037.1-321011060420.3-321021238.43-23.36 5.65  -0.19 -0.82         B2.5V              -0.015+0.119      +093V     128  0.0   0.1      *
+2150          BD-10 1368  41547151098                       060043.7-101409060527.0-101434217.01-14.81 5.87  +0.37 +0.04        dF4                 +0.014+0.024      +033SB2                        
+2151          CP-60  537  41586249424              SW Pic   060054.1-600536060209.2-600549268.97-29.34 6.45  +1.58 +1.81         M4III              +0.010+0.004      -051V?                        *
+2152 37    CamBD+58  897  41597 25597    I                  060109.6+585655060959.1+585609155.18 17.94 5.36  +1.09 +0.92         G8III              +0.024+0.023 +.011+031     < 19:                 
+2153          BD+41 1365  41636 40881                       060119.4+410408060823.0+410320171.72 10.03 6.36  +1.05 +0.83         G9III              -0.016-0.053      -087                           
+2154          BD-04 1362  416921328412467    4698           060141.2-041101060638.7-041138211.57-11.87 5.38  -0.13 -0.54         B5IV               -0.007-0.004      +020       20  6.2  28.5       
+2155 18The LepBD-14 1331  416951511102466                   060137.7-145534060609.3-145607221.51-16.64 4.67  +0.05 +0.02  0.00   A1Vn               -0.018+0.014 +.012+032SB    211                 *
+2156          CD-24 3679  41698171222    I         S Lep    060138.2-241110060545.7-241144230.46-20.34 6.95  +1.63 +1.30 +2.37   M6III              +0.024-0.018      +012                          *
+2157          CD-45 2300  41700217702 231  W     C          060135.7-450210060428.4-450212252.13-26.78 6.35  +0.52  0.00         G0IV-V             -0.080+0.244 +.042+026           0.3 196.7AC   3*
+2158          CD-45 2302  41742217706      W     AB         060147.5-450442060440.2-450444252.18-26.76 5.93  +0.49 -0.01         F4V                -0.070+0.255 +.033+027           0.3 196.7AC   3*
+2159 67Nu  OriBD+14 1152  41753 95259 232                   060151.7+144650060734.3+144606194.81-02.72 4.42  -0.17 -0.66 -0.16   B3V                +0.006-0.021 -.032+024SB1O   41                 *
+2160          CD-35 2684  41759196483                       060155.0-353018060527.1-353049241.98-24.16 5.80  +0.02               A1V                +0.007+0.018      +024                           
+2161          BD-11 1386  41814151126                       060210.9-110945060651.9-111025218.04-14.90 6.66  -0.15               B3V                -0.002+0.001      +013                           
+2162          CD-48 2124  41824217708      W        2827    060211.3-482657060446.9-482731255.90-27.43 6.58  +0.72 +0.27         G6V                -0.092-0.038 +.019+023V       8  0.3   2.5      *
+2163          CD-23 3431  41841171236        4704           060221.8-230557060632.0-230638229.46-19.78 5.47  +0.08 +0.09 +0.03   Am                 -0.023-0.023 +.014-015       64  5.1  44.3       
+2164          CD-29 2769  418431712311164                   060214.5-294451060605.5-294531236.08-22.22 5.81  +0.05               A1V                +0.013-0.041      +007V                          
+2165 36    CamBD+65  517  41927 13756 233I                  060247.4+654418061251.1+654306148.62 20.75 5.32  +1.34 +1.44         K1.5IIIbCN-0.5     +0.006-0.033 +.004+007SB   < 17                  
+2166          BD-21 1353  41933171251    I          2833    060243.6-214802060657.6-214846228.22-19.19 5.78  +1.64 +1.79         M4III              +0.004-0.016      +008V                         *
+2167          BD+08 1202  42035113503                       060319.2+084104060847.2+084012200.31-05.40 6.55  -0.07 -0.17         B9V                +0.032+0.005      +035V                          
+2168 19    LepBD-19 1361  42042151142    I                  060320.6-190914060741.6-190957225.72-18.01 5.31  +1.68 +1.96         M2III              +0.013+0.054      +029V                          
+2169          BD+22 1198  42049 78045    I                  060330.6+221223060932.4+221124188.54  1.28 5.93  +1.63               K4I                -0.018-0.013      +008V                          
+2170          CD-34 2655  42054196503               2836    060327.4-341757060703.7-341843240.83-23.48 5.83  -0.13 -0.55 -0.09   B4IVe              +0.003+0.003      +018                           
+2171   Pi 1ColCD-42 2343  42078217720                       060335.5-421710060641.0-421755249.26-25.76 6.12  +0.25 +0.12 +0.14   Am                 -0.033+0.003      +002V      69                  
+2172          BD+52 1041  42083 25613                       060343.5+524004061146.0+523850161.29 15.63 6.30  +0.14 +0.08 +0.02   A5IIIm             +0.011-0.070      +011SB2O   30                 *
+2173  3    GemBD+23 1226  42087 78050        4751   2846    060339.6+230747060944.0+230648187.75  1.77 5.75  +0.21 -0.63         B2.5Ib            e+0.007-0.001      +016V      37  2.5   0.7AB   3*
+2174          BD+02 1139  42111113507        4749           060344.7+023056060857.9+022958205.81-08.28 5.73  +0.07 +0.06         A3Vn              v+0.004-0.020      +034      250  1.2  29.3AB   3*
+2175 41    AurBD+48 1352  42126 40924        4773B          060356.8+484401061136.5+484247164.97 13.95 6.82H                     A8V                +0.012-0.066D+.010+029      120  0.8   7.7      *
+2176 41    AurBD+48 1352  42127 40925        4773A          060356.9+484353061136.6+484240164.97 13.95 6.09H +0.10 +0.08         A3V                +0.019-0.050D+.010+031      115  0.8   7.7      *
+2177   The ColCD-37 2609  421671965142468                   060405.8-371420060731.6-371511243.94-24.26 5.02  -0.11               B9IV               +0.002-0.005      +045                          *
+2178          CD-45 2317  42168217724                       060407.8-450445060701.9-450529252.30-26.36 6.51  +1.16 +1.13         K1III              +0.085+0.044      +082                           
+2179          BD-05 1523  42278132900                       060441.8-054139060936.2-054240213.29-11.90 6.17  +0.34 +0.01         F3IV w             +0.058+0.014      -001       27                  
+2180          BD-22 1327  423011712931165                   060445.6-222434060857.9-222539229.01-19.00 5.50  -0.01               A0IV               +0.002-0.039 +.012+044                           
+2181   Pi 2ColCD-42 2351  42303217730      W                060446.5-420817060752.9-420914249.16-25.51 5.50   0.00               A0V                +0.001-0.014 +.016+031      248  0.1   0.1      *
+2182          BD-18 1316  42327151173      W                060456.5-180630060920.3-180734224.88-17.24 6.35  -0.03               B9Vn               +0.013-0.015      +033           5.0  23.0       
+2183          BD-14 1348  42341151178    I                  060502.0-143404060934.3-143503221.53-15.74 5.56  +1.16 +1.20         K2III              -0.047+0.045      +031                           
+2184          BD+18 1112  42351 95337                       060510.6+180901061101.8+180746192.26-00.37 6.33  +1.35 +1.44?        K1II               -0.002-0.047      -003V                          
+2185  5    GemBD+24 1151  42398 78079                       060524.3+242632061132.3+242513186.80  2.76 5.80  +1.11               K0III              -0.004-0.054      +022SB                        *
+2186          BD-22 1330  42443171317      W                060536.0-224526060947.9-224627229.43-18.95 5.71  +0.44 -0.05         F6V                +0.080+0.067D+.019+022V          0.1   0.2      *
+2187          CD-44 2452  42448217735      W                060537.9-442021060834.6-442122251.57-25.92 6.27  -0.15               B8II               -0.013+0.010      +017V?         6.8  33.1       
+2188          BD+51 1163  42466 25630                       060552.0+511153061345.3+511021162.82 15.30 6.04  +1.06               K1III              -0.007-0.065      +011                           
+2189          BD+32 1217  42471 588522470I                  060547.1+324256061220.1+324136179.58  6.84 5.78  +1.66               M2IIIa             -0.008-0.001      -051V?                         
+2190          BD+21 1146  42475 78092    I         TV Gem   060550.4+215323061151.4+215207189.08  1.60 6.56  +2.25 +1.77 +1.48   M0-1Iab            +0.002+0.015      +017                          *
+2191          BD+13 1151  42477 95352                       060548.1+133936061127.9+133819196.25-02.44 6.04   0.00 +0.04         A0Vnn              -0.005-0.017      +013      160                  
+2192          CD-26 2761  42486171318                       060547.0-264057060947.2-264203233.30-20.40 6.27  +1.01 +0.78         G8-K0III           -0.007+0.021      -014V                          
+2193 68    OriBD+19 1253  42509 953592471  W                060605.9+194846061201.3+194726190.92  0.63 5.75  -0.07 -0.11         B9.5V              -0.001-0.012      +031       83  3.5  86.3       
+2194   Eta1DorCP-66  493  42525249448                       060602.3-660132060609.4-660223275.80-29.19 5.71  -0.03 -0.07         A0V                +0.017+0.027      +018                           
+2195          BD-06 1439  42536132924              V653 Mon 060609.7-064359061101.3-064515214.41-12.05 6.15  +0.01 +0.03         A0pSrCr            +0.004-0.003      +005V                         *
+2196          CP-62  582  425402494512469           2845    060608.6-620812060703.4-620917271.36-28.89 5.05  +1.25 +1.35 +0.64   K2-3III            +0.018-0.072 +.013+022                           
+2197  6    GemBD+22 1220  42543 78098    I         BU Gem   060615.3+225552061219.1+225430188.22  2.19 6.39  +2.24 +2.48 +1.48   M1-2Ia-Iab         +0.002-0.004 +.003+022SB                        *
+2198 69    OriBD+16 1035  42545 95365                       060617.2+160911061203.3+160750194.13-01.12 4.95  -0.14 -0.58 -0.14   B5Vn               +0.009-0.014      +022SB    303                 *
+2199 70Xi  OriBD+14 1187  42560 95362      W                060615.2+141353061156.4+141232195.81-02.06 4.48  -0.18 -0.65 -0.16   B3IV               +0.003-0.020 -.001+024SB1O  223  7.9  40.0AB   3*
+2200          CD-27 2780  42621171339               2866    060635.8-270755061034.6-270915233.82-20.40 5.72  +1.07 +0.98         K1III              -0.016-0.046      +001                           
+2201 40    CamBD+60  938  42633 13772    I W                060641.5+600137061540.6+595957154.43 19.01 5.35  +1.34               K3III              +0.033-0.021      +012V?         5.1 102.7       
+2202          BD-04 1393  42657132941        4799  V638 Mon 060647.3-043834061143.7-043956212.58-10.95 6.18  -0.08 -0.37         B9pHgMn            -0.011-0.009      +023       74  1.7   0.8      *
+2203          CD-40 2291  42682217753               2864    060656.6-402006061010.3-402113247.37-24.63 5.58  +1.68 +2.00         M2II-III           -0.026+0.076      -019                           
+2204          CD-49 2084  42683217747                       060652.8-493243060923.3-493346257.28-26.90 6.49  +0.52               F7V                -0.024+0.080      +060                           
+2205          BD-06 1446  42690132944                       060659.8-063139061151.8-063301214.32-11.77 5.05  -0.20 -0.78         B2V                -0.005-0.005      +029       25                  
+2206          CD-26 2784  42729171356                       060712.8-262736061113.5-262856233.21-20.02 6.09  -0.04               A0V                -0.017+0.003      +024V                          
+2207          BD+18 1129  42784 95397                       060740.7+184224061333.4+184049192.07  0.42 6.58  -0.08 -0.43         B8Vnn              +0.023-0.017      +020V?    350                 *
+2208          BD+10 1050  42807 95394                       060739.5+103938061312.6+103739199.10-03.50 6.45  +0.67 +0.15         G2V                +0.092-0.285 +.055+003                           
+2209          BD+69  371  42818 13788 234                   060749.6+692119061850.8+691911145.16 22.46 4.80  +0.03  0.00 -0.01   A0Vn               +0.002-0.107 +.008-007SB    320                  
+2210          BD-02 1512  42824132965                       060743.2-022848061244.4-023016210.74-09.75 6.62  +0.05 +0.08         A2V                -0.045+0.012      -004                           
+2211          CD-45 2349  428342177582472                   060747.4-451535061039.9-451655252.67-25.77 6.31  -0.03 -0.04         A0V                +0.005+0.005      +020                           
+2212   Del PicCP-54  980  42933234359 235          Del Pic  060821.0-545646061017.9-545807263.30-27.68 4.81  -0.23 -1.03 -0.26   B3III+O9V          -0.003+0.005      +031SB2O  221                 *
+2213          BD-17 1398  42927151227                       060821.7-174416061246.3-174547224.88-16.35 6.52  -0.17               B3III              -0.008+0.017      +008                           
+2214          BD+17 1182  42954 95419      W                060838.1+175605061428.6+175423192.85  0.24 5.88  +0.22 +0.15 +0.11   A5Vm               -0.009-0.012      +029SB     47  0.0   0.5      *
+2215  1    LynBD+61  869  42973 137872479I         UW Lyn   060841.6+613252061754.8+613055153.03 19.81 4.98  +1.83 +2.06         M3IIIab            -0.014-0.006 +.006+011                          *
+2216  7Eta GemBD+22 1241  42995 78135    I   4841  Eta Gem  060850.4+223209061452.6+223024188.85  2.52 3.28  +1.60 +1.66 +1.31   M3III              -0.068-0.012 +.014+019SBO        2.0   0.0 O   3*
+2217          BD+36 1388  43017 589051167    4849A          060854.6+361042061539.0+360855176.81  9.05 6.92  +0.45 -0.02         F4IV               -0.065+0.003      +007           0.6  11.3AB   4*
+2218          BD-03 1345  43023132994                       060855.7-034251061354.3-034429211.99-10.05 5.83  +0.94 +0.64 +0.32E  G8III              -0.011+0.025      +050V                         *
+2219 44Kap AurBD+29 1154  43039 781431168I          2877    060900.3+293206061522.7+292953182.72  5.92 4.35  +1.02 +0.80 +0.54   G8.5IIIb           -0.073-0.262 +.018+020V?   < 19:                 
+2220 71    OriBD+19 1270  43042 95432        4842           060857.8+191126061450.9+190923191.80  0.92 5.20  +0.44  0.00         F6V                -0.098-0.188 +.041+036       13  5.6  25.4AB   4*
+2221   Nu  DorCP-68  474  431072494611166                   060922.7-684919060844.2-685036279.01-29.00 5.06  -0.08 -0.21         B8V                -0.052+0.018      +018V?    121                  
+2222          BD+13 1173  43112 954442474I:W        2878    060928.0+135251061508.5+135104196.49-01.55 5.91  -0.23 -0.95         B1V                +0.023+0.006      +036V?         6.6  21.3      *
+2223 72    OriBD+16 1060  43153 95447                       060939.1+161026061525.1+160835194.51-00.40 5.30  -0.14 -0.46         B7V                +0.003-0.012      +022V      91                  
+2224          BD-04 1421  43157133003        4846           060940.0-043220061436.7-043406212.83-10.27 5.83  -0.17 -0.65         B5V                -0.008+0.006      +020           6.0   1.7       
+2225          CD-23 3577  43162171428                       060937.3-235012061345.1-235143230.86-18.52 6.39  +0.72               G5                 -0.069+0.118      +022V?                         
+2226          CD-29 2883  43179171425                       060941.3-292203061333.3-292346236.31-20.57 6.54  -0.10               B7V                -0.025-0.013      +018V                          
+2227  5Gam MonBD-06 1469  432321330122475I   4853           060958.6-061439061451.3-061629214.40-10.98 3.98  +1.32 +1.41 +0.64   K1.5IIIBa0.3       -0.008-0.019 +.013-005V?         9.0  51.4      *
+2228 42    AurBD+46 1122  43244 40999                       061007.4+462726061734.7+462527167.55 13.89 6.52  +0.27 +0.09 +0.14   F0V                -0.043+0.019      -008V     195                 *
+2229 73    OriBD+12 1081  43247 95457                       061007.9+123457061545.0+123304197.71-02.04 5.33  -0.02 -0.13         B9II-III           -0.001+0.001      +013V      59                  
+2230  8    GemBD+24 1182  43261 78168      D                061012.4+240009061619.0+235812187.72  3.50 6.08  +0.90 +0.62 +0.49   G8III              -0.015-0.009      -021           0.0   0.1      *
+2231          BD+06 1172  43285113650                       061018.6+060553061540.1+060358203.42-05.13 6.07  -0.13 -0.52         B6Ve               -0.008-0.024      +026      290                  
+2232          BD+04 1181  433171136532478                   061029.6+041856061547.0+041701205.02-05.94 6.64  -0.17 -0.65         B3IV               -0.001-0.004      +013SB                         
+2233          BD-00 1234  433181330282477                   061029.1-002828061534.3-003044209.27-08.21 5.65  +0.50  0.00         F6V                -0.158-0.219 +.036-037V   =<  6                  
+2234          BD-04 1431  43319133027        4865           061033.6-045256061529.7-045455213.24-10.23 5.99  +0.09 +0.10         A5IV s             +0.025-0.045      +031V?     95  4.2   4.1       
+2235          BD+17 1191  43335 95473    I                  061035.1+171253061623.8+171053193.71  0.30 6.39  +1.58 +1.79         K5II               -0.002-0.014      +039V?                         
+2236          BD+01 1275  43358113656      W                061043.9+011202061554.0+011009207.81-07.36 6.37  +0.46 -0.01         F5IV:              -0.005+0.034      +003SB2    22  0.0   0.2      *
+2237          BD-08 1368  43362133029        4866           061040.1-090015061526.0-090207217.00-12.07 6.10  -0.08 -0.31         B9III              -0.035+0.015 -.003+019V          0.0   0.2      *
+2238  2    LynBD+59  959  43378 25665 237          UZ Lyn   061048.0+590250061937.4+590039155.59 19.12 4.48  +0.01 +0.03 -0.01   A2V s             v-0.008+0.026 +.035-004V?     20                 *
+2239 43    AurBD+46 1124  43380 41010                       061049.4+462358061816.9+462138167.66 13.97 6.38  +1.11 +1.12         K2III              +0.012-0.126      +000                          *
+2240  9    GemBD+23 1275  43384 78176                       061052.6+234629061658.7+234427187.99  3.53 6.25  +0.45 -0.38 +0.40   B3Ib                0.000-0.001      +013V      51                 *
+2241 74    OriBD+12 1084  43386 954761169  W                061049.6+121800061626.6+121620198.04-02.03 5.04  +0.42 -0.02         F5IV-V             +0.082+0.186 +.041+009V?     17  4.2 204.0AC   3 
+2242          BD-20 1336  43396171458    I                  061050.3-201429061508.4-201620227.51-16.84 5.91  +1.32 +2.43         K0                 +0.005+0.030      +052V                          
+2243          BD-18 1352  43429151274                       061054.6-182637061517.5-182836225.81-16.09 5.99  +1.06 +0.96         K0                 +0.016-0.048      +065V                          
+2244          BD-13 1411  43445151283                       061109.9-134108061544.9-134306221.37-14.02 5.01  -0.08 -0.23 -0.05   B9Vn               +0.011-0.009      +038V     235                  
+2245   Eta2DorCP-65  561  434552494692473           2873    061102.0-653356061115.0-653522275.31-28.65 5.01  +1.62 +1.86 +1.24   M2.5III            -0.026+0.112 +.009+035                           
+2246          BD+01 1278  43461113668                       061111.1+010650061621.2+010449207.94-07.30 6.63  -0.05 -0.44         B6V                +0.016-0.008      +022                           
+2247 75    OriBD+09 1173  435251136752480    4890           061135.8+095844061706.6+095633200.16-02.99 5.39  +0.10 +0.09         A2V                +0.007-0.061 +.013+012      192  0.2   0.1AP   5*
+2248          BD+07 1216  43526113673                       061134.6+070515061658.4+070311202.70-04.38 6.57  -0.12 -0.51         B7III              -0.011+0.009      +041                           
+2249          BD-16 1415  43544151294               2891    061140.1-163504061607.7-163704224.13-15.15 5.92  -0.17 -0.75 -0.14   B2.5Vn            e-0.002+0.008      +014                          *
+2250          BD+14 1233  43583 95494                       061152.5+140540061733.3+140330196.59-00.94 6.59  -0.03 -0.10         A0V                 0.000-0.012      +003       74                  
+2251          BD+05 1168  43587113683      W        2896    061158.2+050753061716.1+050601204.47-05.23 5.71  +0.61 +0.10         F9V                -0.216+0.159 +.050+013V?  =<  6  3.9 189.7AB   4 
+2252          CD-29 2936  43636171482                       061206.1-294516061557.2-294718236.90-20.22 6.67  +1.55               K4III              +0.004+0.008      +036V?                         
+2253          BD+14 1235  43683 955022481    4901           061224.0+142511061805.6+142258196.37-00.67 6.16  +0.01 +0.03         A3V                -0.007+0.004      +008V?    120  6.9  25.4AC   3*
+2254          BD-22 1364  43745171502      W                061251.1-224018061703.5-224254230.04-17.38 6.07  +0.56 +0.07         G0V                +0.119-0.251 +.018-004V          4.4  47.6      *
+2255  6    MonBD-10 1455  43760151318                       061253.0-104117061735.2-104331218.79-12.33 6.75  +0.35 +0.20 +0.18   F0Del Del          -0.002-0.007      +027V?  =< 15                  
+2256   Kap ColCD-35 2800  43785196643 238           2897    061259.6-350626061633.1-350826242.35-21.89 4.37  +1.00 +0.83 +0.51   K0.5IIIa            0.000+0.086 +.025+024                          *
+2257  4    LynBD+59  964  43812 25678        4950           061311.1+592454062203.6+592220155.35 19.54 5.94R                     A3V                -0.001+0.004D+.005-024V?    155  1.1   0.7AB   5*
+2258          BD+17 1203  43819 95519              V1155 Ori061312.9+172152061901.8+171930193.88  0.92 6.32  -0.07 -0.30         B9IIIpSiCr:        -0.009-0.009      +000V      35                 *
+2259          BD+09 1184  43821113710                       061311.7+090513061840.5+090250201.14-03.07 6.24  +0.87 +0.52         K0                 +0.030-0.044      -014SB1O                      *
+2260          BD-16 1426  43827151322    I          2903    061314.7-164642061741.7-164857224.48-14.89 5.14  +1.30 +1.23         K3III              -0.011+0.008 +.017-008                          *
+2261   Alp MenCP-74  374  43834256274 239                   061313.2-744307061014.4-744511285.75-28.80 5.09  +0.72 +0.33 +0.32   G6V                +0.118-0.213 +.115+035                           
+2262          CD-39 2491  43847196646                       061317.3-391339061635.6-391552246.60-23.14 6.00  +0.16               A2Vm:              -0.013-0.022      -004                           
+2263          CD-37 2707  43899196653                       061337.0-374209061701.2-374415245.05-22.61 5.53  +1.14 +1.11         K1III              +0.002+0.081      +067                          *
+2264 45    AurBD+53 1008  43905 256812484                   061338.6+532952062146.1+532708161.14 17.33 5.36  +0.43 +0.12         F5III              +0.020-0.084 +.022-001SB1O   14                 *
+2265          CD-37 2708  43940196659                       061343.6-371255061709.5-371511244.56-22.43 5.87  +0.14               A3V                -0.011-0.010      +021V?                         
+2266          BD-19 1407  439551513342483                   061354.8-195541061813.7-195801227.52-16.05 5.52  -0.18               B2V                -0.005+0.007      +023SB     88                  
+2267          BD-09 1411  43993133091    I                  061405.2-092058061850.6-092325217.70-11.47 5.36  +1.24 +1.32         K1.5III            +0.003-0.033      +007                           
+2268          BD-14 1400  44021151346    I          2912    061417.1-145907061848.8-150129222.91-13.90 6.06  +1.66 +1.87 +0.86E  M0III              -0.003+0.022      +051                          *
+2269          BD+14 1247  44033 95543    I          2917    061422.0+144136062004.2+143904196.36-00.12 5.69  +1.61 +1.87         K3Ib               -0.003-0.014      +036                           
+2270          BD-08 1386  44037133098                       061420.8-083244061907.9-083511216.99-11.05 6.22  -0.04 -0.14         B9V                -0.022-0.010      +004                           
+2271          BD-20 1355  44081171549               2915    061442.6-205305061859.0-205534228.51-16.27 5.81  -0.15               B4IV               -0.009-0.009      +031                           
+2272          BD+29 1190  44092 78259                       061448.9+293509062112.1+293228183.28  7.06 6.43  +0.06 +0.01         A1V s              +0.035-0.039      +021V      54                  
+2273  7    MonBD-07 1373  441121331141170  S                061453.7-074651061942.8-074923216.36-10.59 5.27  -0.19 -0.75         B2.5V              -0.004 0.000      +029SB    152                  
+2274          CP-59  619  44120234418      W                061455.5-591000061618.5-591249268.17-27.47 6.43  +0.59 +0.14         G0V                -0.057-0.325 +.043-003           1.0  38.3AB   3*
+2275          BD-02 1564  44131133118    I          2918    061459.1-025407061959.6-025640211.97-08.34 4.90  +1.60 +1.96         M1III              -0.013+0.004 -.001+047V?                         
+2276          BD+11 1128  44173 95563                       061517.0+114801062052.3+114523199.00-01.32 6.54  -0.10 -0.56         B5III              +0.023+0.003      +019                           
+2277          BD+17 1214  44234 95572                       061535.7+174835062125.9+174549193.76  1.63 6.35R                   g:G9                 +0.019-0.039      +010                           
+2278          CP-52  902  44267234430                       061539.3-524133061751.7-524359261.05-26.20 6.41  +1.46               K2-3III            +0.003-0.006      -005                           
+2279          CD-34 2795  44323196686                       061604.7-342112061941.0-342348241.81-21.04 5.78  -0.08 -0.26         B9V                +0.014+0.001      +026                           
+2280          BD+02 1197  44333113758        4971   2932    061613.2+021854062125.8+021607207.47-05.63 6.31  +0.24 +0.09         A4.5V              -0.016-0.026D+.012-028V     160  0.6   0.3      *
+2281          CD-50 2169  44362234442                       061620.1-501900061846.8-502133258.49-25.58 7.04  +0.83               G2Ib               +0.006+0.003      +017                           
+2282  1Zet CMaCD-30 3038  44402196698 240  W        2927    061628.4-300108062018.8-300348237.52-19.43 3.02  -0.19 -0.72 -0.18   B2.5V              +0.009+0.003 +.004+032SBO    63  4.6 175.5      *
+2283          CP-71  426  44447256285                       061641.8-713957061505.9-714210282.28-28.49 6.64  +0.56 +0.01         F8V                -0.025+0.061      +014                           
+2284          BD-11 1460  44458151401        4978  FR CMa   061645.1-114337062124.7-114624220.17-11.94 5.64  -0.02 -0.85 +0.06   B1Vpe             v-0.009-0.005      +016SB    265  4.2   4.2AB   3*
+2285          BD+70  401  44472  5861        5039           061650.3+703523062814.6+703208144.14 23.58 5.97R                     A4V                +0.002+0.023      -030V      80  5.9   5.7      *
+2286 13Mu  GemBD+22 1304  44478 78297 241I   4990  Mu  Gem  061654.6+223354062257.6+223049189.72  4.17 2.88  +1.64 +1.85 +1.38   M3IIIab           e+0.054-0.111 +.020+055V?         8.1 121.7AxBC 3*
+2287          BD+12 1123  44497 95599                       061659.6+123709062236.5+123412198.48-00.56 6.00                      F0III              -0.033-0.037      +021V      75                  
+2288          CD-34 2806  44506196707               2931    061659.1-340557062036.3-340838241.63-20.78 5.53  -0.19 -0.88         B1.5Ve             +0.005+0.028      +054V     211                 *
+2289 46Psi1AurBD+49 1488  44537 41076 242I         Psi1 Aur 061711.8+492020062453.9+491717165.35 16.17 4.91  +1.97 +2.29 +1.07   K5-M0Iab-Ib        -0.002-0.001 +.007+005SB                        *
+2290          CD-48 2259  445942178612486I'                 061728.1-484117062006.1-484428256.80-25.01 6.60  +0.66 +0.20         G3V                +0.231-0.271 +.041+060                           
+2291          BD+56 1125  44691 257312491          RR Lyn   061759.3+562018062625.8+561706158.63 19.00 5.64  +0.24 +0.12 +0.10   A3Vm               -0.026+0.022 +.023-010SB1O   37                 *
+2292          BD+03 1221  44700113801                       061802.3+034854062318.5+034552206.36-04.52 6.40  -0.15 -0.63         B3V                +0.006-0.013      +030SB                        *
+2293  5    LynBD+58  927  44708 25733    I   5036           061805.0+582819062648.9+582502156.53 19.78 5.21  +1.53 +1.88         K4III              -0.005-0.009 +.005-003SB   < 19: 2.6  95.4AC   3*
+2294  2Bet CMaBD-17 1467  44743151428 243I W       Bet CMa  061817.7-175422062242.0-175721226.06-14.27 1.98  -0.23 -0.98 -0.24   B1II-III           -0.006 0.000 +.019+034SB     36  7.8 185.9      *
+2295          BD-04 1484  44756133199                       061826.3-043811062322.7-044114213.93-08.37 6.67  +0.06 +0.01         A2V                -0.013-0.007      +017                           
+2296   Del ColCD-33 2927  44762196735                       061827.5-332309062206.8-332611241.03-20.24 3.85  +0.88 +0.52 +0.47   G7II               -0.024-0.055 +.019-003SBO                       *
+2297          BD+29 1213  44766 78333                       061829.4+294536062452.6+294226183.50  7.85 6.71  -0.06 -0.39         B8IIIn             -0.032-0.009      +029      250                  
+2298  8Eps MonBD+04 1236  44769113810 244    5012A          061828.1+043838062346.1+043534205.68-04.03 4.44  +0.18 +0.13 +0.10   A5IV               -0.018+0.011 +.025+015SB    124  2.2  12.9AB   3*
+2299          BD+04 1237  44770113811        5012B          061828.5+043850062346.5+043544205.67-04.03 6.72  +0.45 -0.05         F5V                -0.021-0.010 +.025+016    =< 25  2.2  12.9AB   3*
+2300          BD+08 1316  44783113817                       061834.1+085613062402.3+085305201.90-01.97 6.26  -0.08 -0.31         B8Vn               -0.005-0.018      +003V      65                 *
+2301          BD-09 1444  44816133203    I                  061851.7-094924062336.0-095228218.67-10.63 6.19  +1.84 +2.05         K5                 +0.008+0.018      +029V                          
+2302          BD+16 1135  44867 95641                       061906.9+160642062452.9+160325195.66  1.56 6.33  +1.08 +0.91         G9III              +0.040-0.046      +077SB                         
+2303          BD-14 1428  44891151450    I                  061914.5-150109062346.0-150418223.47-12.83 6.24  +1.53               K2                 -0.015-0.007      +037V?                         
+2304          BD+23 1347  44927 78349      D                061928.2+232256062532.9+231937189.28  5.07 6.06R -0.03 +0.07         A2Vn               -0.010-0.023      -027V?    220  0.4   0.1      *
+2305          BD-11 1478  449511514581171I                  061930.4-112834062410.3-113149220.25-11.22 5.22  +1.24 +1.20         K3III              -0.054-0.035 +.016-026     < 19:                 
+2306          BD-19 1435  44953151453        5023   2944    061928.1-194400062347.6-194707227.89-14.78 6.60  -0.15 -0.64         B8IIIHe wk         -0.017+0.014D+.003+024           0.3   0.8      *
+2307          CD-31 3245  44956196759                       061929.8-314419062314.4-314724239.47-19.45 6.34  +0.89               G8III              -0.056+0.013      +015                           
+2308          BD+14 1283  44984 95659    I         BL Ori   061945.8+144637062528.1+144319196.91  1.06 6.24  +2.34 +3.40 +1.28   C5II               -0.014-0.002      +013                          *
+2309          BD-12 1470  44996151461        5030           061943.8-125431062420.5-125745221.58-11.80 6.12  -0.08 -0.63         B5Ve               -0.012-0.012      +008V     120  4.4  23.2      *
+2310          BD+07 1273  44990113845              T Mon    061949.0+070825062513.1+070509203.63-02.55 5.98  +1.22 +1.04 +0.65   F7Iab-K1Iab        +0.017+0.004 +.005+032SB     21                 *
+2311          CD-25 3189  450181716882490I                  061952.1-253124062355.9-253440233.44-17.04 5.63  +1.56 +1.90         K5III              +0.008-0.042      +034V?                         
+2312          BD+01 1332  45050113855      W                062007.6+013324062518.4+013004208.60-05.12 6.66  -0.04 -0.22         B9V                -0.017-0.011      +007      150  0.0   0.1       
+2313          BD-00 1287  45067133229                       062009.7-005305062516.4-005646210.78-06.25 5.87  +0.56 +0.08 +0.20E  F8V                +0.224-0.225 +.027+044    =< 10                  
+2314          BD+47 1299  45105 41109                       062019.1+472747062751.1+472419167.36 15.89 6.56  -0.04 -0.12         A0V                -0.004+0.020      -012       31                  
+2315          BD+02 1227  45137113868                       062033.8+021942062546.6+021620207.97-04.66 6.51  -0.03 -0.07         A0V                +0.005-0.002      +024      120                  
+2316          CD-36 2873  45145196774      W                062032.8-363919062401.0-364228244.46-20.96 5.62  +1.04 +0.87         G6III              -0.015+0.055      +053           1.2  64.8AC   3 
+2317          BD-03 1425  45168133238                       062048.8-034957062547.1-035321213.48-07.48 6.35  +1.02 +0.77         G9III              -0.020-0.005      +012SBO                       *
+2318          CD-28 2981  45184171711    I'                 062050.7-284317062443.9-284648236.62-18.07 6.39  +0.62               G2IV               -0.159-0.115      -005V?                        *
+2319          BD+32 1300  45192 59096                       062103.1+323726062735.5+323347181.17  9.64 6.43  +1.26               K0                 -0.002-0.058      +057                           
+2320   Nu  PicCP-56 1072  45229234473                       062108.7-561857062255.8-562212265.18-26.16 5.61  +0.24 +0.13 +0.14   Am                 -0.034-0.024      +007V?      0                  
+2321          BD-07 1422  45239133246                       062109.8-075016062558.8-075339217.13-09.23 6.40  +0.14 +0.12         A4V                -0.004+0.019      +031                           
+2322          CP-52  913  45291234475                       062121.8-520734062337.7-521052260.64-25.23 5.98  +1.04               G8III              -0.025-0.023      +011                           
+2323          CD-40 2440  453062179102492                   062129.7-401340062444.5-401703248.16-21.95 6.31  -0.05               B9V                -0.003-0.009      +023V                          
+2324          BD-01 1242  453201332602493                   062135.7-012653062639.6-013026211.45-06.20 5.87  +0.08 +0.09         A3Vn               -0.007-0.026      +010V     270                  
+2325          BD-04 1510  45321133257                       062137.7-043220062634.5-043550214.21-07.62 6.15  -0.14 -0.62         B2.5V              +0.007-0.002      +010      185                 *
+2326   Alp CarCP-52  914  45348234480 245I                  062143.9-523827062357.1-524145261.21-25.29-0.72  +0.15 +0.10 +0.18   F0II               +0.022+0.021 +.028+021        0                 *
+2327          BD+00 1421  45357113896                       062149.5+005401062658.7+005027209.38-05.05 6.71  +0.04  0.00         A1Vn               -0.020-0.004      +010      143                  
+2328          BD-07 1429  45380133263        5070           062154.9-072708062644.9-073041216.86-08.89 6.27  -0.04 -0.10         A0Vn               +0.006-0.001      +020      146  2.3  21.1      *
+2329          CD-34 2864  45383196805      W                062155.8-350020062529.9-350350242.91-20.13 6.25  +1.36 +1.59         K3III              -0.005-0.035      +019           1.1 132.2AB   3 
+2330 16    GemBD+20 1428  45394 78402                       062159.8+203323062756.6+202946192.06  4.26 6.22  +0.01 +0.18         A2V s              -0.035+0.007      +039                           
+2331  6    LynBD+58  932  45410 25771      W                062206.0+581410063047.2+580946156.97 20.19 5.88  +0.94 +0.66         K0III-IV           -0.026-0.335 +.025+036           3.0 179.6       
+2332 48    AurBD+30 1238  45412 59128              RT Aur   062208.4+303318062834.1+302935183.15  8.92 5.55  +0.68 +0.50         F8Ib              v+0.002-0.013 +.005+022V       0                 *
+2333          BD+02 1237  45415113906                       062206.6+025804062720.4+025429207.59-04.02 5.55  +1.04 +0.86 +0.36E  G9III              -0.046+0.008      +053                           
+2334          BD+00 1426  45416113905    I                  062205.6+002133062713.8+001757209.90-05.25 5.20  +1.18 +1.13         K1II               +0.007-0.008 +.005+033                          *
+2335          BD-00 1299  45433133269    I                  062208.8-001257062715.6-001634210.41-05.50 5.55  +1.38 +1.61         K5III               0.000-0.008      +039V?                        *
+2336          CP-58  692  45450234482                       062216.5-582919062346.9-583238267.59-26.42 6.48  +0.12               A3V                +0.010+0.021      +023SB2                       *
+2337          CP-63  561  45461249531                       062222.9-633743062301.3-634059273.28-27.23 6.27  +1.60 +2.01 +0.90E  M1III              -0.024+0.013      -014                           
+2338 47    AurBD+46 1149  45466 411302496I                  062234.7+464457063003.0+464108168.20 15.95 5.90  +1.44              gK4                 -0.006+0.003 +.017-047                           
+2339          BD+27 1122  45504 78417      D                062240.7+270156062856.6+265804186.37  7.41 6.47R                     F5                 +0.116-0.067      -070    =< 10  0.9   0.0      *
+2340          BD+16 1159  45506 957192494                   062242.6+161806062828.0+161418195.90  2.41 6.23  +0.90 +0.60         G5                 -0.095-0.047      +041                           
+2341          CP-52  919  45509234488                       062235.9-524457062448.2-524823261.36-25.19 6.51  +1.70               K5-M0III           -0.007+0.002      +036                           
+2342          BD+10 1149  45512 95718                       062247.0+102201062818.8+101814201.14-00.38 6.15  +1.15 +1.18         K2III-IV           +0.026-0.039      -020                           
+2343 18Nu  GemBD+20 1441  45542 784231173    5103           062301.5+201632062857.8+201244192.42  4.35 4.15  -0.13 -0.48 -0.11   B6IIIe             -0.007-0.014 +.009+039SB    219  1.7   0.2AA'  8*
+2344 10    MonBD-04 1526  45546133290 246  W                062301.2-044201062757.6-044544214.52-07.39 5.06  -0.17 -0.76 -0.17   B2V                -0.005-0.001      +025V?     79  4.2  77.2AB   3*
+2345          CP-60  608  45557249535                       062259.5-601330062413.7-601652269.52-26.63 5.80   0.00 -0.01         A0V                -0.041+0.036      +010                           
+2346          BD+79  208  45560  5911                       062305.5+794033064016.8+793558134.52 26.15 6.54R                     A1V                +0.001+0.017      -007       92                  
+2347          BD+02 1244  45563113929                       062304.9+015831062816.8+015444208.58-04.27 6.48  -0.07 -0.16         B9V                -0.002-0.027      +042       80                  
+2348          CD-48 2308  45572217922      W                062304.7-480702062543.6-481038256.45-23.97 5.76  -0.06 -0.16 -0.03C  B9V                -0.005-0.032D+.003+006           2.5   1.2       
+2349          CD-25 3237  45588171774      W                062309.5-254722062711.2-255124234.00-16.46 6.07  +0.53 +0.05         F9V                -0.186-0.218 +.045+036V?         6.5  43.        
+2350          BD+82  177  45618  10433950                   062322.6+821157064430.2+820655131.75 26.61 6.65  +0.17 +0.06         A5V                +0.010-0.052      +006       55                  
+2351          BD+11 1193  45638 95732                       062326.9+110500062900.0+110110200.58  0.10 6.59                      A9IV               -0.027-0.010      +041       42                  
+2352   Pi 1DorCP-69  607  45669249532                       062334.9-695544062238.2-695903280.35-27.82 5.56  +1.51 +1.83         K5III              +0.020+0.029      +016V?                         
+2353          CD-37 2837  45680196842      W                062343.5-375006062707.5-375344245.88-20.76 6.48  +0.39               F3V                -0.011+0.042      +030           7.0  32.8       
+2354          CP-63  568  45701249539    I'                 062344.5-632203062426.3-632544273.01-27.04 6.46  +0.66               G3III-IV           -0.007-0.103      +023                           
+2355          BD+02 1253  45724113940    I W                062401.2+024242062914.9+023846208.04-03.72 6.16  +1.54 +1.86        gM1                 +0.009-0.040      +009           4.0  19.3       
+2356 11Bet MonBD-06 1574  45725133316        5107A  2977    062358.0-065808062849.0-070158216.66-08.21 4.60  -0.10 -0.63 -0.16   B3Ve              v-0.017 0.000 +.021+020SBO   346  0.5   7.1AB   4*
+2357 11Bet MonBD-06 1575  45726133317        5107B  2977    062358.5-065814062849.5-070204216.66-08.21 5.40  -0.07 -0.52         B3ne               -0.017+0.005 +.021+018      123  0.5   7.1AB   4*
+2358 11Bet MonBD-06 1575  45727              5107C  2977    062358.5-065814062849.5-070204216.66-08.21 5.60H                     B3e                -0.016+0.005 +.021+023      331  0.5   7.1AB   4*
+2359          BD-17 1506  45765151546                       062411.7-172408062837.3-172758226.20-12.78 5.77  +1.12               G5                 -0.007+0.004      +018V                          
+2360          CP-63  572  45796249542                       062418.5-634608062455.6-634940273.47-27.04 6.27  -0.13 -0.45         B6V                -0.014+0.026      -001                           
+2361   Lam CMaCD-32 3066  45813196857                       062427.7-323101062810.1-323448240.64-18.76 4.48  -0.17 -0.61 -0.16   B4V                -0.018+0.024 +.013+041      135                  
+2362          BD+09 1259  45827113957                       062437.1+090546063005.5+090145202.47-00.58 6.57  +0.14 -0.06         A0III              -0.017-0.026      +014SB?                       *
+2363          BD+78  227  45866  59192507I                  062456.8+780431064028.8+775945136.29 25.92 5.73  +1.47              gK5                 +0.009-0.012 +.018-014                           
+2364          CD-32 3072  45871196861      W       Var      062455.9-321824062839.2-322216240.47-18.59 5.74  -0.17 -0.65         B4Vnpe             -0.003+0.017D+.006+023           2.0   1.2      *
+2365          BD+73  340  45947  59092503                   062517.4+734622063754.9+734144140.95 25.02 6.24  +0.38 +0.01         F2                 -0.155-0.018 +.039+006       30                  
+2366          BD+17 1275  45951 95765        5146           062522.2+170030063110.1+165619195.57  3.31 6.20  +1.16 +1.06         K2III              +0.001-0.049      +027SB         4.0   8.0AB   3*
+2367          BD-09 1493  459761515732497I                  062527.5-100050063011.3-100453219.58-09.26 5.93  +1.38               K0                 -0.011+0.002      +020V?                         
+2368          CD-40 2482  45983217951                       062530.2-410034062842.3-410428249.22-21.47 6.32  +0.40               F2-3V              +0.030+0.028      +017                           
+2369          CP-57 1001  45984234519                       062529.1-575618062704.0-580008267.08-25.90 5.82  +1.28               K3III              -0.015-0.014      +013                           
+2370          BD+11 1204  45995 95766        5153A          062535.7+111913063109.5+111503200.62  0.68 6.14  -0.08 -0.86         B2V:nne            -0.005-0.016D+.009+020      293  2.8  16.1      *
+2371 19    GemBD+16 1178  46031 95778                       062552.2+155825063137.4+155412196.55  2.93 6.40R                     A8V                -0.016-0.015      +021       97                  
+2372          BD+32 1324  46052 591942500          WW Aur   062555.6+323134063227.2+322717181.72 10.52 5.87  +0.14 +0.15 +0.02   A3m+A3m:           -0.031-0.022      -009SB2O   35                 *
+2373          BD-13 1519  46064151585        5148           062558.4-130447063034.7-130853222.42-10.51 6.16  -0.15               B1.5V              -0.024+0.002      +002           5.0  33.2      *
+2374          BD+11 1207  46075 95783                       062604.3+115145063139.2+114732200.20  1.04 6.65  -0.12 -0.42         B6III              -0.030-0.012      +010       70                 *
+2375          BD+11 1209  46089 95788                       062613.6+113650063148.3+113240200.44  0.95 5.23  +0.15 +0.13         A3V                +0.013+0.032 +.010-003V     124                 *
+2376  7    LynBD+55 1093  46101 25814    I                  062613.5+552535063432.8+552111159.97 19.75 6.45R                     K0III:             +0.002+0.004      -020                           
+2377   Pi 2DorCP-69  614  461162495502495                   062619.8-693759062528.6-694125280.04-27.55 5.38  +0.97 +0.67 +0.36E  G8III              -0.016+0.195 +.007+009                          *
+2378          BD+11 1213  46178 95803        5170           062648.4+114446063223.3+114025200.39  1.14 6.03  +1.07               K0III              +0.010-0.031      -021           4.2  31.1      *
+2379          BD-12 1518  46184151602    I W                062644.4-121915063123.0-122330221.81-10.01 5.15  +1.27 +1.38         K3III              +0.040-0.016 +.022+017V?   < 19: 8.3  14.8       
+2380          CD-27 3051  461891718662499                   062648.7-274200063046.3-274610236.17-16.46 5.93  -0.15 -0.67         B2.5V              -0.007+0.011      +020V                          
+2381          BD-08 1462  46229133369    I                  062701.7-080511063150.1-080929218.02-08.05 5.43  +1.38 +1.52        gK2                 -0.012-0.008      +003V                          
+2382 12    MonBD+04 1304  46241114023               3017    062700.7+045540063219.2+045121206.43-02.02 5.84  +0.99 +0.79 +0.53   K0V                -0.037-0.006      +021V                         *
+2383          BD+33 1356  46251 59222                       062709.0+330552063342.7+330127181.32 11.00 6.42R +0.03 +0.13         A3V                +0.011+0.010      -009                           
+2384          CD-50 2241  46273234539      W                062721.5-501006062949.1-501421258.81-23.84 5.27  +0.41               F2V                -0.054-0.058 +.027+002SB    133  0.1   0.5AB   4*
+2385 13    MonBD+07 1337  463001140341174                   062729.7+072423063254.2+071959204.30-00.75 4.50   0.00 -0.18 +0.04   A0Ib               -0.001-0.006 +.007+012       17                 *
+2386          BD-05 1678  46304133382      W                062729.3-054743063223.1-055208216.01-06.90 5.60  +0.25 +0.07         F0Vnn              -0.001-0.042      -021           7.7   4.2       
+2387  4Xi 1CMaCD-23 3991  46328171895        5176  Xi1 CMa  062741.3-232047063151.3-232506232.11-14.53 4.33  -0.24 -0.99 -0.27   B0.5IV             -0.006+0.012      +027SB     27  9.6  24.6AB   3*
+2388          CD-35 2947  46349196897                       062739.3-351116063113.0-351533243.53-19.10 5.84  +0.81 +0.53         G8III              -0.011 0.000      +014V                         *
+2389          CP-56 1095  463552345412498           3000    062744.4-564703062928.5-565110265.89-25.36 5.22  +1.09               K0III              -0.040+0.031 +.010+013                           
+2390          CD-40 2512  46365217986                       062747.3-405043063059.8-405459249.20-21.01 6.20  +1.40               K3III              -0.017 0.000      +051V?                         
+2391          BD+14 1339  46374 95830                       062755.4+141356063336.1+140919198.32  2.55 5.53  +1.11              gK2                 -0.019-0.085      -012V?                         
+2392          BD-11 1520  46407151625               3024    062805.7-110534063246.9-110959220.85-09.17 6.24  +1.11 +0.78 +0.48   G9.5III:Ba3        -0.007+0.001      -011V                         *
+2393          CD-36 2962  464311969062501I:        SX Col   062807.1-365211063135.0-365624245.23-19.61 6.34  +1.63 +1.91         M1III              +0.005+0.072      +054                          *
+2394  8    LynBD+61  893  46480 13897 247  W                062833.1+613409063741.4+612852153.87 22.04 5.94  +0.89 +0.52         G8IV-V             -0.209-0.274 +.027-046           3.0 157.0AB   4 
+2395          BD-01 1274  464871334041175                   062833.3-010840063337.9-011313211.99-04.52 5.10  -0.14 -0.56         B5Vn               -0.003-0.021      +025V     300                  
+2396          BD+71  359  46509  59252511                   062843.2+714956064032.2+714456143.09 24.82 5.92  +1.19               K0III              -0.002+0.015      -023                           
+2397          CD-31 3407  46547196919      W       Var      062854.4-315722063239.0-320150240.46-17.68 5.69  -0.17 -0.79         B2IVe              -0.001-0.002      +020V     120  3.0  24.7      *
+2398 49    AurBD+28 1168  46553 785242504           3032    062854.1+280601063512.1+280120186.04  9.13 5.27  -0.03 -0.08         A0Vnn              -0.002-0.015 +.000+017      149                  
+2399          CD-37 2889  46568196917                       062855.7-373713063221.3-374148246.04-19.72 5.24  +1.00               G8III              +0.065-0.077 +.016+039                           
+2400          CD-51 1946  46569234551                       062858.1-514521063118.3-514934260.56-24.00 5.60  +0.54 +0.04         F8V                +0.105+0.094      +016                           
+2401          BD+79  212  46588  5946 248                   062910.2+794022064614.1+793353134.59 26.41 5.45  +0.50 -0.02         F8V                -0.102-0.604 +.049+013SB1O                      *
+2402 11    LynBD+56 1136  46590 25842                       062908.3+565617063738.5+565127158.61 20.64 5.85                      A2V                 0.000+0.012      +000V?                         
+2403          BD-20 1437  46602171940                       062910.0-205050063326.6-205526229.92-13.18 6.40  +0.83               G5                 -0.030-0.026      -002V                          
+2404 14    MonBD+07 1357  46642114085        5211   3031    062921.4+073901063446.4+073421204.30-00.23 6.45  -0.02 -0.03         A0V s              -0.010-0.004      +038       56  4.0  10.5      *
+2405          BD+38 1539  46687 59280    I W       UU Aur   062940.3+383134063632.9+382643176.52 13.78 5.29  +2.61       +1.43   C5II               +0.005-0.026 +.005+012           5.6  17.9      *
+2406          BD+10 1186  46709 958702505I                  062946.8+100402063517.6+095918202.21  1.00 5.88  +1.51 +1.85         K4III              -0.001-0.010      +039V                          
+2407          CD-38 2730  46727196930                       062948.5-383254063310.3-383731247.03-19.88 6.44  +1.00               G8III              +0.006-0.022      +029                           
+2408          CP-65  610  467302495682502                   062946.8-652951063003.0-653406275.48-26.71 6.29  +0.33 +0.06         F0III              +0.002+0.058      +006SB2                       *
+2409          BD+00 1491  46769114097                       063006.3+005810063515.8+005324210.29-03.19 5.80   0.00 -0.45         B8Ib               -0.001-0.006      +010                           
+2410          CP-61  669  46792249572                       063010.9-614820063110.6-615247271.43-26.05 6.15  -0.15               B3V                -0.013+0.008      +034SBO                       *
+2411          CD-36 2990  46815196945    I                  063019.1-360926063349.5-361356244.69-18.94 5.42  +1.44 +1.72         K3III              -0.014+0.094 +.030+032                           
+2412   Mu  PicCP-58  722  46860234564      W                063028.9-584042063158.4-584515268.03-25.40 5.70  -0.06 -0.18         B9Ve              t+0.004-0.011      +002           3.2   2.4      *
+2413          BD+04 1335  46885114115                       063042.2+043442063600.0+042951207.17-01.37 6.55  -0.06 -0.28         B9III              -0.021-0.005      +013V      35                 *
+2414  5Xi 2CMaBD-22 1458  46933171982 249                   063051.9-225308063503.4-225753231.99-13.68 4.54  -0.05 -0.03 -0.02   A0V                +0.011+0.016 +.025+026V     138                  
+2415          CD-32 3168  469361969552506                   063052.8-323814063435.3-324259241.29-17.54 5.62  -0.08 -0.23         B8V                +0.005-0.001      +028V                          
+2416          CP-52  947  47001234574                       063110.4-521507063326.1-521944261.18-23.80 6.19  +1.09               G8III              -0.044+0.040      +006                           
+2417          BD+24 1328  47020 78557                       063119.4+244026063727.2+243527189.38  8.07 6.44R +0.10 +0.05         A3V                -0.016+0.008      -002                           
+2418          BD-05 1710  470541334692509                   063139.9-050741063635.3-051240215.89-05.67 5.52  -0.08 -0.39         B8V               e 0.000-0.017      +027      245                 *
+2419 51    AurBD+39 1690  47070 59316 250I                  063143.7+392845063839.5+392327175.79 14.54 5.69  +1.35 +1.56         K5III              -0.023-0.109      +033                          *
+2420 52Psi3AurBD+40 1665  47100 59319                       063151.3+395918063849.2+395409175.32 14.77 5.20  -0.07 -0.40         B8III              -0.009-0.012      +009V?    169                  
+2421 24Gam GemBD+16 1223  47105 95912 251I W                063156.1+162905063742.7+162357196.77  4.45 1.93   0.00 +0.04 -0.01   A0IV               +0.042-0.042 +.033-013SB     32  9.0 143.5AC   3*
+2422          BD+06 1309  47129114146              V640 Mon 063202.4+061310063724.1+060807205.87-00.31 6.06  +0.05 -0.88         O8p                +0.006-0.001      +025SB2O   80                 *
+2423  6Nu 1CMaBD-18 1480  47138151694        5253A          063200.1-183439063622.8-183936228.11-11.61 5.70  +0.85 +0.49         G8III+F3IV-V       -0.011+0.017      +025SB         1.9  17.4      *
+2424          CD-36 3009  47144196978      W                063155.6-364157063524.1-364648245.35-18.84 5.59  -0.14 -0.48         A0V                -0.011+0.018D+.011+023V          0.8   1.5AB   3*
+2425 53    AurBD+29 1293  47152 78571      D                063202.5+290412063823.0+285903185.47 10.17 5.79   0.00 -0.07         B9npEu             -0.021-0.021      +018V?     29  0.0   0.1      *
+2426          BD+10 1201  47156 95914                       063204.4+105619063736.9+105111201.71  1.90 6.38                      K0                 -0.039-0.039      +002                           
+2427 50Psi2AurBD+42 1585  47174 41239    I W                063211.4+423437063919.9+422920172.89 15.86 4.79  +1.23 +1.29 +0.60   K3III              +0.006-0.058 +.004+017V    < 17  5.5  52.1AB   3 
+2428          BD-13 1570  47182151700    I                  063210.4-131412063646.7-131915223.24-09.23 5.97  +1.56               K5                 +0.011-0.023      -012                           
+2429  7Nu 2CMaBD-19 1502  472051517022510I          3047    063219.3-191014063641.0-191521228.69-11.80 3.95  +1.06 +1.01 +0.51   K1III              +0.059-0.062 +.058+003     < 17                  
+2430          BD+02 1315  472201141542512                   063226.9+024725063740.3+024215208.95-01.82 6.17  +1.08 +0.96         K1III              -0.038-0.049      -008                           
+2431          CD-35 3005  47230196987      W                063223.3-360012063554.0-360520244.70-18.50 6.35  +0.48               G0V                -0.058-0.095D+.028+028SB         0.4   0.2      *
+2432          BD+05 1334  47240114162                       063233.8+050231063752.7+045726206.98-00.75 6.15  +0.14 -0.74         B1Ib               -0.004+0.020      +033V     126:                *
+2433          BD-22 1472  47247172021        5260           063228.7-223152063640.9-223654231.82-13.19 6.35  -0.11 -0.54         B5V                -0.031-0.006D+.012+034V          3.6   9.1      *
+2434          BD+44 1506  47270 41245                       063242.6+440607063958.0+440050171.46 16.55 6.41R                     K1III              +0.033-0.003      -030SB                         
+2435          CP-52  953  473062345892508                   063246.3-525338063458.6-525832261.93-23.73 4.39  -0.02 -0.15 +0.14   A0II               -0.003+0.007      +023       45                  
+2436          BD+22 1416  47358 785862513                   063304.3+220708063905.3+220151191.86  7.27 6.04  +1.03               G9III              +0.011-0.025      -009                           
+2437          BD-12 1566  47366151725                       063303.7-125345063740.9-125906223.03-08.89 6.12  +1.00               K0                 +0.030-0.124      +009V?                         
+2438 54    AurBD+28 1196  47395 78593        5289   3065    063314.7+282105063933.1+281547186.24 10.10 6.03  -0.08 -0.48         B7III              -0.006-0.014D+.002+019SB     70  1.6   0.8       
+2439          BD+24 1343  47415 78596                       063323.4+244109063931.4+243600189.58  8.50 6.38  +0.53               F8IV               +0.006+0.084      +018SB                         
+2440          BD-02 1691  47420133511    I                  063319.0-022726063820.5-023237213.71-04.07 6.14  +1.48 +1.77         K2                 -0.018+0.015      +027                           
+2441          BD+04 1365  47431114194                       063331.1+044718063849.5+044202207.31-00.65 6.57  -0.07 -0.33         B8IIIn             +0.012-0.008      +033                          *
+2442          BD+01 1443  47432114191               3060    063327.0+014203063838.1+013649210.03-02.11 6.21  +0.15 -0.82         O9.5II             -0.007-0.005      +058V?    100                 *
+2443  8Nu 3CMaBD-18 1492  47442151730    I                  063329.5-180903063753.4-181415227.87-11.11 4.43  +1.15 +1.04 +0.60   K1-II-III          -0.010-0.007 +.013-002     < 17                 *
+2444          CD-38 2782  47463197011      W                063338.1-380344063701.9-380848246.82-19.00 6.04  +1.03 +0.84         K0III              +0.006+0.040      +029           4.0  25.0AC   4 
+2445          CD-41 2488  47475218060                       063340.8-412819063651.3-413325250.22-20.17 6.34  +1.15               K0II               +0.008+0.008      +014                           
+2446          CD-36 3031  47500197014      W                063345.8-365418063713.8-365926245.69-18.57 5.71  -0.12 -0.51         B7IV               -0.014+0.017      +021V          0.8   0.6       
+2447          CD-32 3216  47536197019    I                  063402.8-321517063747.6-322023241.18-16.78 5.27  +1.18 +1.12         K2III              +0.105+0.068 +.017+079                          *
+2448          BD-16 1554  47561151737                       063408.0-164706063835.4-165225226.69-10.37 6.03  +0.03 +0.10         A1V s              -0.008-0.023      +010       44                  
+2449          BD+13 1356  47575 95963        5302           063409.9+130422063947.6+125859200.05  3.35 5.97  +0.06 +0.11         A2V                -0.034-0.001      -020       60  6.0   2.9       
+2450          BD-14 1525  476671517512515I                  063442.4-140322063916.7-140845224.26-09.04 4.82  +1.50 +1.68 +0.73   K2II               +0.004-0.004 -.003+029     < 17                 *
+2451   Nu  PupCD-43 2576  47670218071 252           3062    063442.0-430629063745.7-431146251.94-20.54 3.17  -0.11 -0.41 -0.07   B8III              +0.002-0.006      +028SB    228                 *
+2452          BD+36 1482  47703 593652516                   063454.8+360131064137.7+355555179.30 13.69 6.46  +0.49               F8III              -0.017-0.022      +086    =< 10                  
+2453 25    GemBD+28 1207  47731 78636      W                063502.7+281721064121.0+281147186.47 10.42 6.42  +1.09 +0.85         G5Ib               +0.008-0.009      -006           3.9  55.9AC   3 
+2454          BD+06 1338  47756114244                       063509.8+062746064031.8+062218206.02  0.49 6.51  -0.14 -0.47         B8IIISi            -0.029+0.012      +035       35                  
+2455          CD-23 4172  47827172102      W                063526.6-233617063936.3-234144233.11-13.02 6.05  -0.03 -0.06         A0                 +0.013-0.002      +026           0.4   0.1       
+2456 15    MonBD+10 1220  47839114258    I   5322  S Mon    063528.2+095918064058.7+095344202.94  2.20 4.66  -0.25 -1.07 -0.22   O7V((f))           +0.003-0.006 -.004+033SB     63  3.5   2.9AB  13*
+2457          BD+16 1242  47863 95996                       063535.7+162927064121.8+162351197.17  5.23 6.28  -0.01 -0.07         A1V                -0.022-0.008      +022       38                  
+2458          BD+11 1273  47886 95997    I                  063544.1+110546064117.2+110012201.98  2.77 6.11  +1.68               M1III              -0.002+0.009      +016                           
+2459 55Psi4AurBD+44 1518  47914 412882517I                  063548.3+443714064305.0+443128171.18 17.26 5.02  +1.48 +1.83         K5III              -0.042-0.028 +.019-073V    < 17                  
+2460          CD-30 3386  47946197057                       063552.8-302226063942.7-302813239.54-15.69 5.71  +1.14 +1.10         K0III              -0.006-0.182 +.019-024                           
+2461          BD+00 1546  47964114269                       063556.9+003519064105.4+002943211.31-02.08 5.79  -0.10 -0.37         B8III              -0.016-0.003      +023       95                  
+2462          CD-48 2417  47973218093      W        3072    063557.6-480750063837.6-481313257.12-21.91 4.93  +0.87 +0.60 +0.43C  G8III              +0.008+0.012 +.012+028           2.3  13.0      *
+2463          BD+53 1056  47979 25916                       063606.9+532354064411.6+531747162.53 20.41 6.27  +1.08               K0                 +0.050-0.177      +019                           
+2464          BD+37 1567  48073 59406                       063626.3+371439064313.8+370849178.29 14.47 6.19  +1.03               K0                 +0.036-0.041      -041                           
+2465          CD-38 2817  48087197064                       063632.4-380356063956.9-380932247.04-18.47 6.58  +1.18               K1IIICNIb          +0.056-0.027      +018                           
+2466 26    GemBD+17 1357  48097 96015                       063634.9+174435064224.3+173843196.16  6.02 5.21  +0.06 +0.01         A2V                +0.005-0.087      +015SB     99                  
+2467          BD+06 1351  48099114293    I                  063637.1+062625064159.3+062042206.21  0.80 6.37  -0.05 -0.94 -0.05   O6.5V             e+0.010-0.006      +031V      70:                *
+2468          CP-61  688  48189249604      W                063656.2-612641063800.6-613159271.21-25.19 6.18  +0.62 +0.12         G1-2V              -0.011+0.084      +032           2.0   2.1      *
+2469          BD-09 1601  48217133585    I                  063709.9-090414064156.4-091002220.05-06.26 5.19  +1.53 +1.89 +0.68E  M0III              +0.043-0.040 +.031+001V?                        *
+2470 12    LynBD+59 1015  48250 25939        5400AB         063724.0+593234064614.1+592630156.31 22.48 4.87  +0.08 +0.08 +0.03   A3V                -0.023-0.002D+.011-003V      90  0.6   1.7AB   4*
+2471          BD+36 1494  48272 59425                       063729.0+361229064412.6+360635179.35 14.24 6.31R +0.06 +0.11         A2V                +0.014+0.014      -015V?     90                  
+2472 NOVA 1903                                     DM Gem   0 0 0      0 0 0 0 0      0 0                                                                                                           *
+2473 27Eps GemBD+25 1406  48329 78682 254I   5381   3183    063746.7+251349064355.9+250752189.54  9.63 2.98  +1.40 +1.46 +0.61   G8Ib              e-0.006-0.013 +.017+010SB   < 17  6.0 110.3      *
+2474          BD+03 1371  48348114312    I                  063752.1+030755064306.5+030200209.28-00.47 6.19  +1.37 +1.60         K0                 -0.001-0.021      +031                           
+2475          CD-40 2625  48383218126      W                063758.5-401516064114.1-402059249.30-18.99 6.12  -0.14 -0.59         B4V                -0.014+0.015      +017      217  3.4  15.4      *
+2476          CD-47 2521  48403218124                       063806.4-473444064049.3-474029256.68-21.40 6.65  +1.58 +1.92 +0.98E  M2III              -0.008-0.009      +021                           
+2477 13    LynBD+57 1004  48432 259472520                   063818.0+571623064649.5+571009158.69 21.93 5.35  +0.96 +0.73         K0III              +0.012-0.038      +019     < 19:                 
+2478 30    GemBD+13 1390  48433 96051    I   5387           063820.9+131944064359.3+131340200.30  4.37 4.49  +1.16 +1.16 +0.60   K0IIICN1Ca1        -0.003-0.058 +.007+014     < 19: 8.4  27.2      *
+2479          BD+04 1414  48434114324                       063822.1+040154064338.7+035556208.54  0.06 5.90  -0.02 -0.89         B0III              +0.006-0.006      +035       70                 *
+2480 28    GemBD+29 1327  48450 786922518I          3188    063825.2+290420064445.5+285815186.08 11.43 5.44  +1.45 +1.64         K4III              -0.004-0.026      +016V?                         
+2481          BD-22 1505  48501172204        5377A  3181    063833.3-222111064245.8-222657232.26-11.84 6.13  +0.34 -0.02         F0                 -0.085+0.078      +044           2.1  18.2      *
+2482          CD-38 2844  48543197108      W                063853.2-381803064216.4-382355247.45-18.13 6.29  +0.34 +0.13         A3V+F/G            -0.015+0.005D+.003+063V          1.5   7.9      *
+2483 56Psi5AurBD+43 1595  48682 41330 255    5425           063931.9+434037064644.3+433439172.36 17.52 5.25  +0.56 +0.05         G0V                -0.002+0.165 +.068-024    =<  6  3.4  36.2      *
+2484 31Xi  GemBD+13 1396  48737 96074 256I:         3193    063940.6+130013064517.4+125344200.74  4.50 3.36  +0.43 +0.06 +0.23   F5III              -0.116-0.191 +.055+025V?     70                 *
+2485          BD+55 1122  48767 25963        5436B  3202    063952.1+554849064812.9+554216160.26 21.69 6.33H                    dF6                 +0.057-0.101 +.032+012SB         0.1   4.7AB   3*
+2486          BD+55 1122  48766 25962        5436A  3202    063951.5+554848064812.3+554216160.26 21.69 6.28H +0.47              dF5                 +0.058-0.101 +.032+009V          0.1   4.7AB   3*
+2487 57Psi6AurBD+48 1436  48781 413461176I                  064002.1+485343064739.6+484722167.26 19.47 5.22  +1.12 +1.04         K0III              -0.001+0.006      -008V    < 19:                 
+2488          CD-39 2798  487971971342519                   064003.0-390531064323.3-391136248.31-18.20 6.30  +0.26               A8:mDel Del        -0.001-0.019      +010V                         *
+2489 32    GemBD+12 1275  48843 96084               3197    064017.1+124752064554.2+124137200.99  4.54 6.46                      A9III              +0.001+0.002      +009    =< 15                  
+2490 42    CamBD+67  454  48879 139732523                   064031.5+674056065057.1+673419147.80 24.88 5.14  -0.17 -0.63         B4IV               +0.002+0.002 +.010+005SB    126                  
+2491  9Alp CMaBD-16 1591  48915151881 257I   5423           064044.6-163444064508.9-164258227.22-08.88-1.46   0.00 -0.05 -0.03   A1Vm               -0.553-1.205 +.375-008SBO    13 10.3  11.2AB   4*
+2492 10    CMaCD-30 3484  48917197149      W       FT CMa   064040.1-305804064428.4-310414240.53-14.98 5.20  -0.12 -0.93 -0.15   B2IIIe            v-0.015+0.008      +034      200  5.4  36.3      *
+2493          CD-27 3248  48938172264                       064052.4-271447064451.9-272029237.03-13.42 6.45  +0.54 -0.02         G2V                -0.011+0.308 +.062-012V?                         
+2494 16    MonBD+08 1486  489771143881177                   064105.1+084135064632.4+083514204.73  2.82 5.93  -0.17 -0.69         B2.5V              -0.006-0.007      +010V                         *
+2495          CD-23 4325  49001172273                       064113.0-232131064523.3-232743233.46-11.72 6.05  +1.20 +1.29         K0                 -0.038+0.042      +034V?                         
+2496  NGC 2281                                              0 0 0      0 0 0 0 0      0 0                                                                                                           *
+2497          CD-30 3495  49028197163      W                064112.7-302856064502.4-303510240.11-14.68 6.54  -0.11 -0.49         B8IV               -0.026+0.017      +018       60  3.9   4.4      *
+2498          BD-14 1573  49048151895                       064126.6-144124064559.3-144746225.57-07.87 5.32  +0.07 +0.12         A2V                -0.025-0.017 +.024-019      205                  
+2499          BD+18 1349  49059 96111        5447           064132.8+181807064723.5+181136196.20  7.32 6.20R +0.07 +0.01         A2V                +0.003-0.043 +.016+021V      77  0.2   0.5      *
+2500          CD-31 3640  49095197171                       064138.4-314047064522.8-314737241.29-15.08 5.92  +0.48 -0.03         F6V                -0.220-0.320 +.051+032V                          
+2501          CD-30 3505  49131197177      W       HP CMa   064142.4-305038064531.3-305656240.50-14.73 5.80  -0.19 -0.88         B2III             e+0.010+0.002D+.005+007SB         2.3   4.9      *
+2502          BD-09 1644  491471519112521                   064155.0-100002064639.0-100626221.42-05.64 5.66  -0.05 -0.11         B9.5V              -0.017+0.003      +017V     149                  
+2503 17    MonBD+08 1496  49161114410    I                  064154.0+080843064719.8+080214205.31  2.75 4.77  +1.40 +1.65 +0.70   K4III              -0.026-0.013 +.013+047     < 19:                 
+2504 11    CMaBD-14 1584  49229151919                       064217.3-141907064651.1-142533225.33-07.52 5.29  -0.04 -0.25         B9III              -0.002+0.012      +015V     245                  
+2505          CP-71  476  49268256326      W                064227.8-714024064057.8-714632282.50-26.48 6.51  +1.11 +1.07         K1IIICNII          +0.031-0.051      +021           3.5  10.7       
+2506 18    MonBD+02 1397  49293114428 258I                  064238.7+023118064751.6+022444210.38  0.30 4.47  +1.11 +1.04 +0.55   K0+IIIaBa0.2       -0.018-0.012 +.017+011SB   < 17                 *
+2507          CD-39 2831  49319197192                       064244.0-392600064603.3-393224248.84-17.84 6.62  -0.13 -0.50         B6Vnne             +0.003+0.014      +016                          *
+2508          BD-08 1558  49331133679    I          3213    064250.5-085322064737.1-085954220.53-04.93 5.07  +1.80 +1.88         M1+Ib-IIa          -0.016+0.005 +.002+024V                         *
+2509 12    CMaBD-20 1576  49333172318              HK CMa   064244.4-205426064701.5-210056231.36-10.34 6.08  -0.19 -0.62         B7IIIn             -0.014+0.005      +015                          *
+2510          CD-37 3065  49336197195              V339 Pup 064246.3-374005064612.1-374632247.13-17.18 6.21  -0.13 -0.64         B4Vne              -0.008+0.002      +015                          *
+2511 43    CamBD+69  394  49340 13986 259                   064255.3+690017065342.2+685318146.42 25.38 5.12  -0.13 -0.43         B7III              +0.003+0.008 +.002-021V?    188                  
+2512          BD+32 1414  49380 595212525I         IS Gem   064310.3+324313064941.3+323624183.13 13.89 5.71  +1.29               K3II               -0.036-0.047      -016                          *
+2513          CP-52  996  49396234693                       064307.4-520539064526.1-521204261.57-22.00 6.57  +1.08               G6Iab              +0.007-0.007      +017                           
+2514          BD-01 1386  49434133687                       064314.8-011227064819.0-011909213.75-01.29 5.75  +0.28 +0.05         F1V                -0.041-0.042      -014       82                  
+2515          CP-52  998  49517234699                       064336.4-521807064553.7-522436261.81-21.99 5.80  +1.53 +1.82         K3III              -0.004-0.003      +023                           
+2516 58Psi7AurBD+41 1536  49520 413802527I W                064341.7+415356065045.9+414653174.39 17.57 5.02  +1.27 +1.35 +0.46E  K3III              -0.024-0.136 -.003+061V?   < 19: 5.0  40.9AB   3*
+2517          BD+01 1531  49567114465                       064353.9+010651064903.7+010007211.77-00.07 6.15  -0.13 -0.68         B3II-III           +0.007-0.004      +023       87                  
+2518          CD-37 3080  495911972151178  W                064356.0-374909064721.4-375547247.37-17.02 5.26  -0.08 -0.25         B9IV               -0.007-0.015      +047      173  5.8  65.4       
+2519 33    GemBD+16 1298  49606 961612526  W       OV Gem   064404.4+161859064949.8+161210198.26  6.96 5.85  -0.13 -0.52         B7III              -0.017-0.012      +013       35  7.3  27.5      *
+2520 14    LynBD+59 1028  49618 26012        5514           064415.9+593402065305.1+592655156.54 23.32 5.33  +0.65               G4III+A2V          -0.006-0.039 +.005+013V?     26: 1.0   0.9AB   4*
+2521          BD-02 1776  496431337181179  W                064414.2-020933064916.4-021619214.71-01.52 5.74  -0.10 +0.46         B8IIIn             -0.009-0.004      +010V          0.0   0.1       
+2522          BD-14 1599  49662151962        5487           064425.7-150155064857.8-150841226.21-07.38 5.39  -0.10 -0.51         B6V                +0.002-0.004D+.004+023SB    157  2.7   0.7       
+2523          CD-51 2078  49689234705                       064428.5-510910064652.8-511557260.67-21.52 5.40  +1.34 +1.24         K1II-III+G:p       -0.003-0.097 +.018-005                           
+2524          CP-54 1115  49705234704      W                064439.4-543507064641.5-544141264.22-22.50 6.46  +0.86               G6III              -0.050+0.024D+.004+003           3.4   1.8       
+2525 35    GemBD+13 1434  49738 96179    I                  064446.8+133141065025.5+132448200.84  5.85 5.65  +1.34              gK3                 -0.002-0.002      +026V?                         
+2526          CP-55 1063  498772347102524           3220    064521.7-552544064718.7-553224265.13-22.65 5.61  +1.52               K5III              +0.003+0.023      +035V                         *
+2527          BD+77  266  49878  6022 260I                  064529.1+770618070004.0+765839137.55 26.86 4.55  +1.36 +1.66 +0.71   K4III              +0.071-0.013 +.023-026SB   < 17                 *
+2528          CD-23 4438  49891172389        5498           064534.9-235739064944.0-240433234.45-11.07 6.33  +0.04 +0.08         A1                 +0.002-0.003D+.002-002           1.3   1.6AB   4*
+2529 36    GemBD+21 1405  49908 788052530    5511           064533.4+215245065133.0+214540193.38  9.76 5.27  -0.02 +0.01         A2V                -0.008-0.038 +.010+034V     135  8.8  11.3      *
+2530          BD-00 1462  49933133760        5505           064543.4-002510065049.9-003227213.34-00.38 5.77  +0.39 -0.07         F2V                +0.030-0.185 +.036-015V   =< 10: 5.5   5.9      *
+2531          CP-72  522  499472563302522                   064539.7-730028064336.8-730705284.02-26.43 6.37  +0.96 +0.66         G8III              +0.012-0.093      +016                           
+2532          BD+45 1359  49949 41406                       064550.1+445739065307.6+445022171.53 19.04 6.26  +0.21 +0.12         A8Vn               +0.008-0.081      +006SB?   260                  
+2533          BD+23 1518  49968 78816    I                  064555.7+234312065200.0+233606191.74 10.64 5.65  +1.45 +1.96         K5III              -0.040-0.009      +040V?                        *
+2534          BD-07 1592  49976133761              V592 Mon 064553.3-075529065042.3-080228220.02-03.82 6.29   0.00 +0.02         A2pSrCrEu         v-0.006 0.000      +022                          *
+2535          BD-16 1624  49980151992    I                  064554.5-165806065021.9-170502228.12-07.93 5.79  +1.44               K0                 +0.013+0.015      +023V                          
+2536          CP-70  560  50002256331                       064556.1-701927064456.1-702602281.07-25.98 6.11  +1.33 +1.50         K3III              +0.007+0.007      +005                           
+2537          CD-27 3310  500121724032528           3234    064606.0-271305065006.0-272002237.51-12.36 7.04  -0.18 -0.82         B2IV               -0.004+0.002      +033V?                        *
+2538 13Kap CMaCD-32 3404  500131972581180          Kap CMa  064606.3-322335064950.5-323031242.36-14.49 3.96  -0.23 -0.92 -0.16   B1.5IVne          v-0.007+0.004      +014      199                 *
+2539 59    AurBD+39 1771  50018 59571        5534  OX Aur   064608.6+385919065301.5+385209177.40 16.91 6.12  +0.37 +0.12         F2VDel Del        v+0.005+0.008      +001V     105  3.9  22.3AB   3*
+2540 34The GemBD+34 1481  50019 59570 261    5532           064611.9+340455065247.3+335740182.10 15.02 3.60  +0.10 +0.14 +0.08   A3III              -0.002-0.048 +.021+021SB    128  7.9  78.7AB   3 
+2541 60    AurBD+38 1636  50037 59576      S                064621.9+383346065313.4+382617177.83 16.79 6.30  +0.49              dF5                 +0.034-0.176 +.005+032                          *
+2542          BD+35 1511  50056 59574    I          3250    064621.9+355429065303.4+354719180.38 15.77 6.01  +1.45               K3III:             -0.020+0.015      +006                           
+2543          BD+03 1437  50062114525                       064624.9+030940065139.3+030230210.25  1.44 6.38  +0.04 +0.09         A2V s              -0.010-0.042      +024V      70                  
+2544          CD-25 3691  50093172420                       064632.5-253941065036.9-254641236.11-11.61 6.33  -0.18 -0.77         B2V                -0.006+0.014      +021                           
+2545          CD-31 3717  50123197263      W                064636.5-313522065023.3-314222241.64-14.07 5.70  +0.14 -0.52         B6Vnpe            v-0.002+0.012      +020V     270  2.1  42.9AB   3*
+2546          CD-45 2773  50196218236      W        3236    064702.7-451954064957.8-452700254.96-19.21 6.55  +1.51 +1.83 +0.82C  K5-M0III           +0.019-0.044      +015           4.6   6.6      *
+2547 61Psi8AurBD+38 1638  50204 59589                       064705.7+383739065357.0+383018177.82 16.95 6.48  -0.05 -0.19         B9.5pSi            -0.010-0.026      +027                          *
+2548          CD-46 2703  502232182352529                   064705.2-463029064954.6-463653256.12-19.60 5.14  +0.45 -0.02 +0.26C  F5V                +0.004+0.370 +.049+020        0                 *
+2549          CD-34 3140  50235197277                       064714.1-341457065052.4-342202244.21-15.02 4.99  +1.38 +1.56         K5III              +0.007+0.006 -.013+030                           
+2550   Alp PicCP-61  720  50241249647 262                   064709.8-615002064811.4-615629271.92-24.10 3.27  +0.21 +0.13 +0.13   A7IV               -0.069+0.269 +.052+021      205                  
+2551          BD+08 1543  50277114556    I:                 064723.0+083007065249.4+082249205.62  4.12 5.77  +0.26 +0.10         F0Vn               -0.050-0.032      +027      195                  
+2552          BD-05 1845  50282133807                       064727.6-051144065222.9-051858217.77-02.21 6.30  +0.99 +0.76         K0                 -0.020-0.008      +031                           
+2553   Tau PupCD-50 2415  50310234735 263                   064727.2-502943064956.2-503653260.16-20.86 2.93  +1.20 +1.21 +0.60   K1III              +0.036-0.070      +036SB1O                      *
+2554          CP-53 1168  50337234737              V415 Car 064740.9-533019064951.3-533720263.24-21.76 4.40  +0.92 +0.61 +0.45   G6II                0.000+0.030 +.025+026SBO                       *
+2555          BD+11 1344  50371 96241                       064749.5+110720065322.5+105947203.33  5.42 6.24  +0.97               K0III              +0.011-0.136      -034                           
+2556          BD+46 1202  50384 41426                       064753.8+455709065515.2+454935170.67 19.72 6.34  +0.94 +0.65         K0III-IV           -0.037-0.067      +031                          *
+2557          BD+44 1551  50420 41429              V352 Aur 064801.6+440205065514.7+435436172.59 19.08 6.13  +0.32 +0.19 +0.19   A9III              +0.010-0.009      -007V      30                 *
+2558          CD-36 3189  50445197291                       064810.8-360629065142.3-361349246.06-15.58 5.96  +0.18               A3V                -0.048-0.064      +004                           
+2559   Zet MenCP-80  196  50506258451 264                   064822.5-804230064002.7-804849292.60-27.21 5.64  +0.20 +0.15         A5III              -0.016+0.055      +007V     157                  
+2560 15    LynBD+58  982  50522 26051    I   5586           064837.0+583314065716.5+582521157.77 23.60 4.35  +0.85 +0.52 +0.44   G5III-IV           -0.005-0.135 +.014+009V    < 25  1.2   0.9AB   4*
+2561          BD+57 1017  50551 26050               3280    064840.4+574125065713.2+573348158.68 23.38 6.05  +1.49 +1.75         K3III              +0.018+0.022      -054V                          
+2562          CP-60  712  50571249654                       064841.5-600759065001.1-601457270.18-23.49 6.11  +0.46               F7III-IV           +0.009+0.109      +023                           
+2563          CD-48 2556  50621218261                       064851.1-481017065132.8-481733257.90-19.89 6.42  +1.21 +1.23         K2-3III            +0.039-0.009      -009                           
+2564 38    GemBD+13 1462  50635 96265        5559   3266    064900.1+131818065438.7+131040201.51  6.67 4.65  +0.30 +0.07 +0.20   F0Vp               +0.078-0.083 +.043+024SB    126  2.9   7.0AB   3*
+2565          BD-18 1591  50644152055                       064856.6-185435065318.8-190158230.20-08.15 5.64  +0.28 +0.14         F1V                -0.049+0.003      +030                           
+2566          BD-18 1594  50643152056                       064859.1-184838065321.7-185600230.11-08.10 6.14  +0.15 +0.13 +0.05   A5m                -0.028+0.023      +041                           
+2567          CD-26 3529  50648172504    I   5548   3259    064859.1-264959065300.1-265727237.43-11.61 6.40  +1.53 +2.29         M4III              -0.031-0.061      -013V?         7.5  11.9AB   3*
+2568   Psi9AurBD+46 1203  50658 41446              Var?     064908.4+462404065632.3+461627170.30 20.07 5.87  -0.06 -0.45         B8IIIe             +0.018+0.013      -041      270                 *
+2569 37    GemBD+25 1496  50692 78866                       064909.7+253003065518.6+252232190.42 12.06 5.73  +0.57  0.00         G0V                -0.042+0.022 +.055-011V   =<  3                  
+2570          BD-05 1863  50700133855        5557           064914.5-054340065408.5-055109218.45-02.07 6.41  +0.17 +0.16         A6Vn               -0.020-0.001D+.003+017           0.1   1.2       
+2571 15    CMaBD-20 1616  507071725202532          EY CMa   064913.4-200602065332.9-201327231.30-08.62 4.83  -0.21 -0.96 -0.22   B1IV               -0.009+0.004      +028V      49                 *
+2572          BD-00 1487  507471338702533                   064919.7-010006065424.6-010737214.27  0.15 5.45  +0.18 +0.16         A4IV               +0.003-0.012 +.009-009       70                 *
+2573          BD+46 1205  50763 41450                       064931.3+465009065656.0+464218169.89 20.28 5.86  +1.08              gK0                 -0.102-0.090      +039                           
+2574 14The CMaBD-11 1681  50778152071 266I                  064932.6-115448065411.4-120219223.98-04.85 4.07  +1.43 +1.70 +0.78   K4III              -0.137-0.013 +.022+097V?   < 19:                *
+2575          CD-42 2793  50785218272                       064931.6-422252065239.7-423016252.22-17.73 6.52  +0.42 +0.12 +0.22C  F5II-III           -0.002-0.008      +041                           
+2576          CD-28 3554  50806172524                       064935.1-282412065333.9-283223238.95-12.16 6.04  +0.71 +0.27 +0.24E  G5IV               +0.274-0.438 +.042+072V                         *
+2577          BD-01 1446  50820133881               3271    064938.5-013751065442.1-014523214.87-00.08 6.21  +0.56 -0.35 +0.66   B3IVe+K2II         +0.006+0.006      +009SB    130                 *
+2578          CD-24 4565  50853172531                       064947.4-242450065355.3-243221235.29-10.40 6.21  +0.01 +0.10         A1                 -0.027-0.012      +027V?                        *
+2579          CD-43 2756  50860218278      W                064945.2-435108065247.1-435833253.67-18.23 6.46  -0.10 -0.38 -0.05C  B8V                -0.005+0.001      +026           6.0  10.0       
+2580 16Omi1CMaCD-24 4567  50877172542    I         Omi1 CMa 064958.9-240332065407.9-241102234.98-10.21 3.87  +1.73 +1.99 +0.82   K2+Iab             -0.008+0.013 +.002+036     < 19:                *
+2581          BD+70  430  50885  6041    I W                064959.8+705634070121.5+704829144.42 26.31 5.68  +1.33              gK4                 +0.017-0.019      -017           5.3 117.0       
+2582          BD-02 1827  50890133890                       064957.8-024038065458.8-024813215.83-00.49 6.04  +1.10 +0.85        gG6                 -0.016+0.002      +020                           
+2583          CD-23 4553  50896172546              EZ CMa   065003.3-234810065413.0-235542234.76-10.08 6.91  -0.28 -0.89 +0.06   WN5-B             v-0.009+0.003      +130SBO                       *
+2584          BD+08 1562  50931114626                       065008.2+082706065534.6+081929205.98  4.70 6.29  +0.04 +0.06         A0V                -0.019+0.017      +020V?     70                  
+2585 16    LynBD+45 1367  50973 414632537           3293    065019.3+451327065737.1+450539171.55 19.87 4.90  +0.03 +0.05 +0.01   A2Vn               -0.021-0.004 +.006-008V     201                 *
+2586          BD+33 1433  51000 59631               3289    065026.5+334837065700.5+334052182.72 15.72 5.89  +0.88               G5III              -0.019 0.000      -010V                          
+2587          CP-53 1177  51043234762                       065039.2-535757065246.9-540524263.86-21.48 6.57  +1.08               G5Ib-II            -0.019+0.016      +014                           
+2588 17    CMaBD-20 1624  51055172569        5585           065043.6-201638065502.7-202417231.62-08.39 5.74  +0.08               A3IV               -0.003-0.004      -015           3.2  50.5AC   4*
+2589          BD+10 1335  51104 962942535                   065055.6+100510065625.8+095723204.61  5.62 5.92  -0.08 -0.35         B8Vn               -0.015-0.014      +033V?    175                  
+2590 19Pi  CMaBD-19 1610  51199172579        5602   3285    065117.2-200032065537.4-200811231.44-08.15 4.68  +0.37 +0.05 +0.19  gF2                 +0.047+0.043 +.034+008      120  5.0  11.6      *
+2591          CD-42 2818  512082182962534          NP Pup   065117.7-421419065426.7-422156252.21-17.38 6.32  +2.24 +2.79 +1.30   C3II               +0.002+0.014      +032                          *
+2592          CP-59  716  51210234764                       065117.3-591301065245.4-592028269.31-22.93 6.41  +0.18               A3m                -0.012+0.039      -002SB2                       *
+2593 18Mu  CMaBD-13 1741  51250152123    I   5605           065131.6-135451065606.6-140237225.99-05.34 5.00  +1.18               G5III+A2           -0.001+0.005 -.002+019V          2.5   2.8AB   4*
+2594          CD-50 2458  51266234774                       065133.6-502926065402.3-503642260.38-20.24 6.26  +0.99               K0-1III            -0.049+0.218 -.003+044                           
+2595          BD-22 1602  51283172588                       065134.4-224844065546.8-225629234.01-09.33 5.30  -0.18 -0.80         B3II-III           -0.017+0.003      +038      248                 *
+2596 20Iot CMaBD-16 1661  513091521262536          Iot CMa  065140.6-165528065608.2-170315228.70-06.68 4.37  -0.07 -0.70 -0.07   B3II               -0.003+0.002 +.005+041       29                 *
+2597          BD+12 1361  51330 96314                       065150.7+120221065725.7+115427202.96  6.71 6.27  +0.34?+0.27?        F2Ib-II            +0.019 0.000      +009                           
+2598          CD-31 3808  51411197371      W                065207.8-313937065554.8-314724242.21-13.03 6.36                      B3V                -0.006+0.013      +021SB2        7.6  18.8      *
+2599          BD-07 1642  51424133937                       065211.3-080251065700.1-081044220.85-02.49 6.34  +0.64 +0.26         K0II-III+A2V       -0.007+0.002      -005                           
+2600 62    AurBD+38 1656  51440 596582538I                  065214.0+381122065902.8+380308178.64 17.72 6.00  +1.23 +1.17         K2III              -0.043-0.122      +025V                          
+2601 39    GemBD+26 1405  51530 78929      W                065237.6+261245065847.4+260452190.09 13.07 6.10  +0.46 +0.02         F7V                -0.168+0.093 +.025+006    =< 10  6.0  28.8       
+2602   Iot VolCP-70  572  51557256344 267                   065235.7-705020065127.0-705748281.74-25.53 5.40  -0.11 -0.38         B7IV               +0.001+0.023      +019      145                 *
+2603          BD-22 1616  51630172631              HH CMa   065300.2-220413065714.8-221212233.48-08.71 6.61  -0.19 -0.80         B1-2III:           -0.006-0.015      +032V                         *
+2604          CD-35 3225  51682197388                       065310.2-351233065645.7-352030245.63-14.29 6.29  +1.29               K2III              -0.001-0.003      +018                           
+2605 40    GemBD+26 1411  51688 78947      D                065317.4+260300065927.9+255451190.31 13.14 6.40  -0.11 -0.47         B8III              -0.011-0.008      +012V      67  0.0   0.0      *
+2606          BD+07 1539  51693114713                       065314.2+074527065839.0+073719206.95  5.06 6.27  +0.11 +0.10         A3V                -0.016-0.030      -012V?    115                  
+2607          CD-24 4648  51733172644        5629           065326.3-243000065733.9-243750235.73-09.70 5.46  +0.36 +0.03        dF0                 -0.058+0.106 +.016+020V?     92  1.3   1.1       
+2608          CD-48 2601  51799218324                       065336.2-483521065616.0-484316258.60-19.29 4.95  +1.69 +1.92 +1.18   M1III              +0.006+0.010 -.003+022                           
+2609          BD+87   51  51802  1168 909          OV Cep   065344.3+871220074030.5+870112126.22 27.72 5.07  +1.63 +1.97 +0.88E  M2IIIab            -0.045-0.028 +.003-025V                         *
+2610          BD+03 1488  518141147222540    5648           065341.4+034417065857.0+033608210.58  3.31 5.97  +1.06 +0.88         G8III              -0.002-0.004      +017           6.7   3.6       
+2611          CD-27 3460  51823172650                       065342.7-272413065742.4-273215238.42-10.91 6.23  -0.14 -0.66         B2.5V              -0.034+0.005      +024SB     80                 *
+2612          CD-35 3233  51825197402      W                065342.9-352227065717.6-353027245.83-14.26 6.23  +0.46 -0.04         F8IV-V             -0.037+0.008 +.069+010V?         0.2   0.2      *
+2613          BD+07 1544  51892114731                       065356.1+072712065920.1+071901207.30  5.08 6.35  -0.11 -0.47         B7III              -0.019-0.011      +005V      70                  
+2614          CD-26 3646  51925172656      W        3316    065406.6-270146065807.6-270953238.12-10.67 6.37  -0.19 -0.82         B2.5III            +0.006-0.008      +018V     205  0.4   0.2      *
+2615 41    GemBD+16 1354  52005 96363    I                  065431.0+161302070015.8+160444199.48  9.16 5.68  +1.66 +1.82 +0.85   K3Ib               -0.007-0.005      +022                           
+2616          CD-25 3864  52018172669        5651           065430.0-251642065835.9-252450236.55-09.82 5.59  -0.16 -0.70         B3V                -0.010+0.015      +028SB    125  7.0  10.2      *
+2617          BD+70  432  52030  6074    I                  065433.0+705236070551.8+704355144.56 26.67 6.50R                     K0III              +0.037-0.008      +020                           
+2618 21Eps CMaCD-28 3666  52089172676 268I   5654           065441.7-285009065837.5-285820239.83-11.33 1.50  -0.21 -0.93 -0.21   B2II               +0.004+0.003D+.001+027       44  6.4   7.5      *
+2619          CD-33 3389  520921974272541                   065445.4-335833065825.1-340642244.61-13.49 5.06  -0.16 -0.65         B3V                -0.006+0.005      +019V      36                  
+2620          BD+32 1460  52100 59697        5680           065447.4+323316070117.2+322452184.30 16.06 6.59  +0.27 +0.14         A9IV               +0.011-0.020      -028       90  5.8  16.1AB   5*
+2621          CD-30 3757  52140197432      W                065454.0-305142065843.8-305952241.72-12.16 6.42  -0.14 -0.61         B3V                +0.004+0.021      +014           2.6  35.0AB   3*
+2622          BD-05 1910  52265134031                       065523.4-051349070018.0-052201218.72-00.48 6.30  +0.57 +0.09         G0III-IV           -0.118+0.088      +054V?                         
+2623          BD-21 1689  52273172700                       065523.0-212753065939.3-213612233.19-07.94 6.26  -0.15 -0.78         B2-3IV-V:          -0.002-0.010      +033                           
+2624          BD-08 1662  523121340361181  W                065535.4-081603070023.7-082425221.43-01.85 5.96  -0.08 -0.34         B9III              -0.009+0.001      +010V          6.7   1.5       
+2625          BD-19 1644  52348172718                       065548.3-200109070008.1-200932231.93-07.21 6.31  -0.15 -0.62         B4III              -0.028-0.008      +032V                          
+2626          CD-45 2850  52362218360                       065547.2-453747065841.8-454605255.83-17.88 6.22   0.00 -0.06 -0.01C  A0V                -0.005-0.021      +034SB2                       *
+2627          BD-08 1667  52382134041                       065552.8-090347070039.3-091211222.17-02.15 6.49  +0.21 -0.75         B1Ib               -0.007-0.006      +051       87                 *
+2628          BD-21 1695  52437172725        5687  FU CMa   065604.4-215845070019.3-220710233.72-08.03 6.53  -0.17 -0.82 -0.18   B2IV-Vne           -0.006-0.018      +009           0.0   0.1AP   5*
+2629          BD+05 1513  52479114798                       065623.0+045736070141.4+044905209.80  4.47 6.63  +0.06 +0.10         A3V s              -0.006-0.001      -011                           
+2630 42Ome GemBD+24 1502  52497 789991182          Ome Gem  065619.2+242129070224.8+241255192.18 13.06 5.18  +0.94 +0.68         G5IIa-Ib           -0.009-0.001 +.012-009     < 19:                *
+2631          BD+17 1479  52554 964072543I D       NP Gem   065636.5+175352070225.5+174520198.17 10.35 5.94  +1.63               M1                 +0.016+0.031      +023V          0.0   0.0      *
+2632          BD+15 1431  52556 96403                       065634.5+152846070217.4+152010200.37  9.28 5.74R                    gK1                  0.000-0.016      -014                           
+2633          BD+05 1514  52559114801                       065635.2+054159070155.0+053327209.17  4.86 6.59  -0.02 -0.64         B2IV-V             -0.041+0.010      +034                          *
+2634          CP-55 1116  52603234826                       065642.6-553517065839.6-554346265.81-21.16 6.27  +1.16 +1.16         K2III              -0.073-0.090      -001                           
+2635          BD+16 1363  52609 96409    I                  065647.1+164905070233.5+164027199.18  9.91 5.82  +1.68 +1.92         M2III              +0.017-0.015      +035V?                         
+2636          BD-01 1509  52611134073      W                065648.3-011208070152.9-012044215.32  1.71 6.17  +1.28 +1.36         G5II               +0.010-0.027      -045           4.7  24.5       
+2637          CD-28 3711  52619172749                       065645.3-282050070042.6-282922239.58-10.71 6.27  +0.45               F5V                -0.006-0.034      +010                           
+2638          CP-56 1211  52622234825                       065643.5-561519065836.2-562341266.49-21.37 6.45  +0.39               F2II               -0.030-0.028      -003                           
+2639          BD-05 1926  52666134076    I          3341    065701.9-053446070156.4-054320219.22-00.28 5.20  +1.68 +2.05         M2III              -0.016+0.001 -.003+003V                          
+2640          CD-25 3911  52670172763                       065659.3-250426070105.9-251255236.62-09.23 5.63  -0.17               B2V                -0.008+0.021      +006SB     67                  
+2641          CD-33 3415  52703197475                       065707.5-331934070049.8-332755244.21-12.77 6.40  +1.05               G8II-III           +0.019+0.091      +028V                          
+2642          BD+60 1026  52708 26141                       065711.5+595659070601.3+594807156.56 25.00 6.44R                     G8III:             +0.026+0.001      +022                           
+2643          BD+29 1441  52711 79009                       065709.1+293018070330.4+292014187.43 15.32 5.93  +0.60 +0.04         G4V                +0.153-0.826 +.059+022V   =<  6                 *
+2644          BD+52 1165  52859 26144        5746           065742.8+525430070539.8+524529164.07 23.36 6.12  +0.11 +0.88         A3V s              -0.024-0.072D+.011+027           0.2   4.2AB   3*
+2645          BD+47 1391  52860 41538                       065739.2+475521070509.0+474630169.25 21.93 6.38  -0.04 -0.23         B9IIIn             -0.001-0.004      -017V?                         
+2646 22Sig CMaCD-27 3544  528771727971183I   5719  Sig CMa  065744.1-274729070143.1-275605239.17-10.27 3.47  +1.73 +1.88 +1.00   K7Ib              e-0.005+0.005 +.024+022          10.5  10.0      *
+2647          BD+09 1496  52913114835                       065749.8+091701070317.9+090818206.10  6.77 5.97  +0.12 +0.11         A3V s              -0.023+0.006      -012SB     85                  
+2648 19    MonBD-04 1788  529181341062547          V637 Mon 065756.8-040539070254.8-041421218.01  0.61 4.99  -0.20 -0.93 -0.19   B1V               e-0.003+0.003      +025V?    336                 *
+2649          BD+11 1428  52960 96429    I                  065805.6+110554070338.0+105706204.50  7.65 5.13  +1.39 +1.62         K3III              -0.008-0.019 +.011+021V    < 19:                 
+2650 43Zet GemBD+20 1687  52973 79031 269I   5742  Zet Gem  065810.6+204302070406.5+203413195.75 11.90 3.79  +0.79 +0.62 +0.41   F7-G3Ib           v-0.009 0.000 -.006+007SB  =< 54  0.0   0.1 O   6*
+2651          BD+12 1406  52976 96432    I                  065815.3+124428070351.6+123540203.04  8.42 5.98  +1.58               K5                 +0.002+0.001      -016                           
+2652          CD-51 2224  530472348542544          Var?     065825.7-511535070051.5-512409261.54-19.48 5.14  +1.61 +1.92 +1.15   M1III              -0.015+0.016 -.014+005V?                        *
+2653 24Omi2CMaCD-23 4797  53138172839 270                   065850.9-234113070301.5-235000235.55-08.23 3.02  -0.08 -0.80 -0.09   B3Iab             v-0.004+0.003      +048SB     44                 *
+2654          BD+01 1665  53205114867      W                065909.3+013813070420.2+012918213.08  3.55 6.57  +0.01 -0.07         A0V                +0.002-0.012      +007       62  0.9  90.4       
+2655          BD-05 1943  53208134133    I                  065909.7-051034070405.2-051925219.11  0.38 5.62  +1.29 +1.24         K3III              -0.007+0.009      +040V                          
+2656          BD-09 1818  53240152308                       065912.9-095834070357.3-100727223.36-01.85 6.45  -0.08 -0.31         B9IIIn            e-0.025-0.011      +024                          *
+2657 23Gam CMaBD-15 1625  53244152303 271                   065914.0-152908070345.5-153800228.25-04.41 4.12  -0.12 -0.48 -0.10   B8II               -0.002-0.008      +032V      27                 *
+2658          CD-43 2882  53253218396                       065909.8-431529070215.6-432415253.77-16.43 6.43  -0.04 -0.09         A0V                +0.015-0.012      +031                           
+2659 44    GemBD+22 1566  53257 79042                       065917.1+224714070518.4+223814193.94 13.01 6.02  -0.03 -0.08         B8Vn               -0.006-0.013      -011      345                  
+2660          BD+34 1524  53329 59773               3373    065936.1+343734070611.6+342826182.69 17.78 5.55  +0.91 +0.55         G8IV               -0.055-0.048 +.036+005                           
+2661          CP-58  820  533492348632546           3349    065932.1-584757070105.1-585624269.21-21.79 6.02  +0.30               A8III              -0.058+0.144      +010                          *
+2662          CP-67  686  53501249704                       070000.8-674644065950.5-675458278.61-24.22 5.17  +1.40 +1.65 +0.70   K3III              -0.033+0.241 +.037+039                          *
+2663          BD+09 1510  53510114899    I                  070010.4+092014070539.1+091109206.32  7.31 5.78  +1.52 +1.87         M0III              +0.048-0.020      +046V?                         
+2664          BD-21 1732  53629172906                       070031.5-215249070447.1-220156234.11-07.07 6.09  +1.22 +1.35         K0                 +0.020-0.058      +077                           
+2665          BD+34 1530  53686 59794    I                  070048.2+340950070722.3+340034183.24 17.84 5.91  +1.51              gK4                 -0.028-0.025      +014SB                         
+2666          CD-42 2929  537042184241184          Var?     070052.5-421122070402.8-422014252.87-15.72 5.20  +0.20 +0.15 +0.12   Am                 -0.008+0.072 +.025+028SB2    62                 *
+2667          CD-43 2906  53705218421    I'W     A          070053.2-432809070357.3-433629254.09-16.22 5.54  +0.64 +0.04 +0.34   G3V                -0.105+0.386 +.052+086SB         1.2  21.0AB   3*
+2668          CD-43 2907  53706218423    I'W     B          070054.8-432820070358.8-433642254.09-16.22 6.79  +0.80 +0.36 +0.28E  K0V                -0.109+0.371 +.052+090           1.2  21.0AB   3*
+2669          BD+28 1314  53744 79066                       070108.5+281951070725.0+281038188.89 15.66 6.48  -0.09 -0.25         B9V                +0.006+0.020      -016V?    160                 *
+2670          BD-10 1862  53755152363        5782  V569 Mon 070106.3-103029070549.7-103940224.05-01.69 6.49  -0.05 -0.89         B0.5V+F5III         0.000-0.029      +016SB    412  3.6  38.3AC   4*
+2671          BD+22 1577  53791 79070    I W       R Gem    070120.1+225128070721.4+224213194.08 13.47 7.68  +2.21 +1.85 +3.36   S3.9e             v+0.003-0.002      -041V          4.9 172.5      *
+2672          CD-49 2587  53811218427                       070117.6-492616070353.7-493502259.91-18.41 4.93  +0.13 +0.12         A4IV               -0.045+0.146 +.020+027       59                 *
+2673          BD+34 1533  53899 598062549                   070139.7+335920070813.3+334956183.48 17.94 6.28  +1.34 +1.54         K1                 -0.010-0.030      -003                           
+2674          CP-58  826  53921234890      W                070143.0-590142070315.6-591041269.54-21.60 5.50  -0.11 -0.47         B9IV               +0.022+0.009D+.014+007V          0.8   1.6       
+2675          BD+37 1660  53925 59812                       070150.4+373606070836.3+372642179.94 19.28 6.16  +1.21               K1III              -0.008-0.013      +010                           
+2676          BD+05 1543  53929114935                       070148.0+050355070706.4+045437210.33  5.72 6.11  -0.13 -0.47         B9.5III            -0.033-0.020      +006V?     25                  
+2677          CD-34 3327  53952197557      W                070154.0-343734070532.0-344640245.85-12.42 6.14  +0.37 +0.03         F2V                -0.043+0.041D+.034+019           1.3   3.1AB   5*
+2678          BD-11 1790  53974152394        5795  FN CMa   070158.9-110823070640.7-111739224.71-01.79 5.39  +0.05 -0.85         B0.5IV             -0.011-0.005      +031V?    153  1.3   0.5AB   3*
+2679          BD-12 1788  53975152393                       070156.7-121424070635.9-122338225.68-02.32 6.48  -0.10 -0.99         O7.5V              -0.018+0.007      +033      162                 *
+2680          CD-30 3907  54031197566                       070209.1-303008070600.6-303920242.08-10.59 6.34  -0.16 -0.63         B3V                 0.000+0.009      +005SB                         
+2681          BD+72  352  54070  61152552                   070219.3+715845071358.1+714900143.41 27.42 6.35  +1.12               K0                 +0.025+0.020      -068                           
+2682          BD+07 1607  540791149471185                   070225.1+073742070749.5+072816208.11  7.03 5.75  +1.18 +1.08        gK0                 +0.007-0.036      +024V?                         
+2683          CP-56 1232  54118234902 272          V386 Car 070226.4-563552070418.3-564459267.11-20.73 5.17  -0.04               A0pSi              +0.005-0.001 -.015+030        0                 *
+2684 45    GemBD+16 1397  54131 96535        5812           070237.9+160526070822.0+155551200.47 10.86 5.44  +1.03 +0.80 +0.36E  G8III              -0.008-0.099 +.007-017V?         5.4  10.4AB   3*
+2685          CD-38 3163  54153197572                       070236.2-381344070602.3-382258249.27-13.81 6.11  +0.70               G0IIaCH1           +0.014+0.017      +022V                          
+2686          CD-24 4868  54173172986                       070244.7-244819070652.3-245738236.97-07.94 6.08  +1.34 +1.51         K2                 -0.031+0.007      +019V                          
+2687          CD-50 2561  54179234907                       070243.9-501228070516.5-502137260.76-18.47 6.46                      K3III              -0.011+0.032      +013                           
+2688          CD-26 3880  54224172989                       070256.8-263004070700.1-263928238.52-08.66 6.62  -0.17 -0.77         B2IV-V             +0.016-0.032      +004V                         *
+2689   The MenCP-79  238  542392563552545                   070254.0-791636065634.4-792513291.11-26.40 5.45  +0.05 -0.07         B9.5V              -0.007 0.000      +006                           
+2690          CD-23 4908  54309173002              FV CMa   070311.7-234104070722.6-235025236.01-07.34 5.71  -0.10 -0.89 -0.12   B2IVe             v-0.005+0.023      +029V?    290                 *
+2691          CD-40 2930  54475218465              Var      070350.5-404411070707.1-405336251.72-14.63 5.79  -0.17 -0.67         B3V               t-0.007+0.004      +006                          *
+2692          BD+21 1528  54563 79131                       070410.6+212516071006.7+211449195.71 13.46 6.43  +0.89 +0.50         G9V                -0.167-0.478 +.029-015V                         *
+2693 25Del CMaCD-26 3916  54605173047 273I          3424    070419.5-261404070823.5-262336238.42-08.27 1.84  +0.68 +0.54 +0.33   F8Ia               -0.003+0.004 -.011+034SB     28                 *
+2694          BD-10 1892  54662152470                       070436.1-101111070920.3-102050224.17-00.78 6.21  +0.03 -0.89         O6.5V              +0.005-0.020      +058       91                 *
+2695          CD-23 4949  54669173064              Var?     070439.0-235302070849.3-240239236.34-07.13 6.65  -0.19 -0.81         B2V                -0.013-0.009      +057V                         *
+2696 63    AurBD+39 1882  54716 59866 274I                  070446.6+392901071139.3+391914178.27 20.46 4.90  +1.45 +1.74 +0.56E  K4III-IIIa         +0.044+0.003 +.023-027SB?  < 17                  
+2697 46Tau GemBD+30 1439  54719 59858    I   5846   3437    070446.5+302433071108.4+301443187.22 17.20 4.41  +1.26 +1.41 +0.63   K2-III             -0.030-0.045 +.007+022     < 17  6.5   1.9AB   3*
+2698          CD-51 2306  54732234940                       070449.4-514841070713.3-515804262.46-18.75 5.96  +1.00 +0.82         K0III              -0.008+0.057      +029V                          
+2699          BD-16 1802  54764152477        5837           070503.1-160424070933.2-161405229.42-03.44 6.03  +0.06 -0.79         B1II               -0.022-0.009      +006           5.3  32.5      *
+2700 47    GemBD+27 1327  54801 791412553                   070510.9+270116071123.1+265124190.51 15.96 5.78  +0.10 +0.13         A4IV               -0.023-0.036      +039       80                 *
+2701 20    MonBD-04 1840  548101342821186I W                070515.6-040451071013.7-041414218.85  2.23 4.92  +1.03 +0.78 +0.52   K0III               0.000+0.215 +.030+079     < 19: 4.9 186.2AC   4 
+2702          CD-39 3105  548931976322551           3431    070529.5-392942070851.1-393921250.69-13.83 4.83  -0.18 -0.69 -0.15   B2IV-V             -0.009+0.002      +020V       0                 *
+2703          BD+51 1295  54895 262232555I         UY Lyn   070535.6+513541071323.4+512544165.80 24.18 5.47  +1.67 +1.90         M3-III             +0.006+0.014 +.003-051V                         *
+2704          CD-25 4120  54912173101      W       Var?     070535.7-250409070942.9-251352237.50-07.48 5.69  -0.16 -0.77         B2.5IV             -0.012+0.006      +027SB         6.9   9.2      *
+2705          BD-18 1711  54958152497      W                070545.0-183123071009.3-184107231.68-04.43 6.23  +0.40               F0                 -0.010+0.016      +033V   =< 15  5.0   0.8AB   3 
+2706 48    GemBD+24 1558  55052 79162                       070621.8+241745071226.4+240742193.21 15.11 5.85  +0.36 +0.09         F5III-IV           -0.022-0.048      +013V      74                  
+2707 21    MonBD-00 1634  55057134316              V571 Mon 070616.9-000813071123.6-001807215.48  4.30 5.45  +0.29 +0.14         A8Vn-F3Vn         v-0.031-0.011 +.021+030V     121                 *
+2708          CD-27 3710  55070173122                       070618.3-271941071019.4-272929239.61-08.37 5.46  +1.00               G8III              -0.003+0.009      +015                           
+2709          BD+81  242  55075  1164                       070624.1+812622072521.9+811527132.74 28.08 6.31  -0.04 -0.09         A0III              -0.005-0.026      -008                           
+2710          BD+05 1577  55111115062                       070631.3+054914071151.3+053917210.20  7.11 6.09  -0.02 -0.05         A1V                -0.017-0.008      +042SB     69                  
+2711          BD+27 1337  55130 79170        5871   3453    070635.7+272340071249.0+271329190.28 16.40 6.43  +0.49 -0.02         F8V                +0.010-0.104 +.027-013V?  =< 10  0.1   1.1AB   3*
+2712          CP-68  591  55151249740                       070636.3-684042070614.1-685014279.73-23.86 6.47  +1.04 +0.87         K0III              -0.004+0.008      -014                           
+2713          BD+05 1580  55184115065                       070647.9+053827071207.4+052829210.39  7.09 6.16  +1.14 +0.97         K0III              -0.036+0.005      +020                           
+2714 22Del MonBD-00 1636  551851343301187    5864           070645.4-001937071151.9-002934215.70  4.32 4.15  -0.01 +0.02 +0.01   A2V                -0.001+0.005 +.016+015V     142  9.2  32.0       
+2715 18    LynBD+59 1065  55280 262482558I                  070710.9+594857071554.9+593815156.99 26.20 5.20  +1.07 +1.01         K2III              -0.101-0.259 +.042+024V?   < 19:                 
+2716          BD-20 1767  553441731682556                   070722.8-204302071141.6-205259233.80-05.11 5.84  -0.04 -0.05         A0V                -0.003+0.022      +018V      71                  
+2717 51    GemBD+16 1417  55383 966381188I W       BQ Gem   070737.7+161943071322.3+160932200.78 12.04 5.00  +1.66 +1.82 +1.25E  M4IIIab            +0.013-0.042 +.011-009V          5.2 149.2AB   3*
+2718 26    CMaCD-25 4191  55522173193               3458    070806.6-254630071212.2-255633238.40-07.30 5.92  -0.17 -0.71         B2V                -0.009+0.011      +022                          *
+2719          CD-48 2765  555262185142554                   070806.3-484617071047.5-485556259.70-17.13 5.14  +1.24 +1.29 +0.47E  K2III              -0.012+0.192 +.031+064                          *
+2720          CD-30 4081  55568197686                       070812.8-303916071204.1-304918242.80-09.49 6.10  +0.27 +0.06 +0.14   A8V                -0.039+0.015      +006                          *
+2721          BD+47 1419  55575 416441190                   070824.6+472503071550.1+471424170.34 23.52 5.58  +0.58 +0.03         G0V                +0.030-0.183 +.037+085V   =<  6                  
+2722          BD+24 1576  55579 79191      W                070820.4+245256071426.6+244239192.84 15.76 6.89  -0.03 -0.07         A1pSrCr            +0.003-0.016      +003           3.5  27.5AB   4 
+2723          BD-11 1849  555891525702557I                  070825.0-110456071307.2-111505225.40-00.37 5.78  +1.51 +1.76         K0                 -0.003+0.008      +009                           
+2724          CD-27 3761  55595173200              HN CMa   070822.9-271822071224.1-272827239.80-07.95 6.59  +0.19               A5IV-V             -0.025+0.008      -008                          *
+2725 52    GemBD+25 1618  55621 79199    I   5909   3469    070835.0+250331071441.9+245306192.70 15.88 5.82  +1.56 +1.83         M1III             v+0.047-0.092      +047V?         6.3  23.9      *
+2726          CD-36 3421  55718197694      W        3464    070852.6-362232071225.7-363240248.09-11.89 5.96  -0.14 -0.62         B3V                -0.022+0.004D+.004+017           2.5   2.5      *
+2727          CD-40 2987  55719218525              Var?     070857.0-401947071215.8-402956251.76-13.57 5.31  +0.06 +0.09         A3pSrEuCr          -0.018-0.015 +.009+017SBO    66                 *
+2728          BD+12 1469  55730 966722559                   070858.1+121716071432.6+120657204.63 10.56 5.62  +1.01 +0.77         G6III              -0.050-0.020      +030                           
+2729          BD+03 1609  55751115119    I                  070905.6+031658071420.0+030641212.76  6.51 5.35  +1.19 +1.18         K2II               -0.006-0.002      +037                           
+2730          BD-22 1756  55762173230    I          3467    070909.4-223009071323.9-224024235.58-05.58 6.01  +1.48 +1.69         K2III              +0.006-0.008      -005                           
+2731          BD-03 1804  55775134391    I   5911           070912.2-034349071411.0-035405219.01  3.27 5.75  +1.58 +1.89         K5III              -0.015+0.007      +022V          5.0   2.7       
+2732          BD-09 1921  55832134395    I                  070930.3-094633071415.5-095651224.38  0.48 5.90  +1.52 +1.72         K3III              -0.004+0.004      +043V?                         
+2733          BD-22 1761  55856173247        5912           070934.6-224404071348.3-225423235.84-05.60 6.36  -0.21 -0.83         B2IV+G5IV          -0.012-0.017      +017           1.8  19.7      *
+2734          CD-27 3789  55857173244              GY CMa   070934.7-271107071336.3-272123239.81-07.65 6.12  -0.23 -1.01         B0.5V              -0.025+0.006      +043V                         *
+2735   Gam1VolCP-70  600  55864256373      W     B          070933.4-702004070842.2-702950281.55-24.05 5.69  +0.40 +0.04         F2V                +0.007+0.101 +.016-003SB         1.9  13.6      *
+2736   Gam2VolCP-70  600  558652563741189  W     A  3448    070935.8-702011070844.9-702956281.56-24.04 3.78  +1.04 +0.88         K0III              +0.023+0.106 +.016+003V?         1.9  13.6      *
+2737          BD+52 1188  55866 26260                       070942.8+521827071733.7+520751165.21 24.97 5.92  +1.26              gK1                 -0.001-0.025      -007                           
+2738 53    GemBD+28 1350  55870 79221    I          3485    070942.4+280417071557.1+275351189.91 17.30 5.71  +1.63 +2.00         M1IIIa             -0.016+0.001 +.008+024V?                         
+2739          BD-10 1933  55879152598                       070943.8-100838071428.2-101900224.73  0.35 6.03  -0.18 -0.97         B0III              -0.004-0.011      +033       50                 *
+2740          CD-46 2977  55892218537 275          QW Pup   070942.5-463532071233.6-464534257.72-16.02 4.49  +0.32 -0.01 +0.22   F0IV               -0.132+0.103 +.048-001       54                 *
+2741          CD-30 4143  55958197719              GG CMa   070956.3-305443071347.1-310502243.20-09.28 6.60  -0.17 -0.76         B2IV               -0.014-0.002      +028SB?                       *
+2742          BD+82  201  55966  11793951I         VZ Cam   071003.1+823616073104.4+822441131.42 28.18 4.96  +1.66 +1.80 +1.25E  M4IIIa             -0.006-0.042 +.001+014V                         *
+2743          CD-30 4146  55985197722                       071004.1-301004071357.2-302024242.54-08.92 6.33  -0.20 -0.83         B2IV-V             -0.015-0.006      +024SB                        *
+2744 24    MonBD+00 1871  56003134414        5933           071012.3+000044071519.3-000941215.81  5.24 6.41  +0.90 +0.57         G5III              -0.020-0.002D+.011-010V?         5.8   3.8       
+2745 27    CMaCD-26 4057  56014173264      W       EW CMa   071010.6-261048071415.2-262109238.97-07.07 4.66  -0.19 -0.71 -0.12   B3IIIe             -0.009+0.007      +000SB2   139  0.0   0.1      *
+2746          CD-44 3223  56022218546              OU Pup   071013.8-450032071313.4-451059256.26-15.30 4.89  -0.02 -0.07         A0pSi              -0.019-0.099 +.010+004V?     28                 *
+2747          BD+08 1712  56031115159    I          3486    071013.9+080907071539.4+075840208.53  8.99 5.82  +1.60 +1.71         M4-IIIab           +0.029+0.007      -009                          *
+2748          CD-44 3227  56096218549      W       L2 Pup   071029.1-442836071332.4-443823255.77-15.04 5.10  +1.56       +2.42   M5IIIe             +0.114+0.330 +.022+053V?         6.4  62.0      *
+2749 28Ome CMaCD-26 4073  56139173282              Ome CMa  071045.2-263556071448.7-264622239.41-07.15 3.85  -0.17 -0.73 -0.12   B2IV-Ve           v-0.008+0.006      +026SB?   120                 *
+2750          CD-26 4074  56160173283    I                  071048.6-265148071451.1-270217239.65-07.26 5.58  +1.22 +1.29         K4III              -0.049-0.030      +015V                          
+2751          BD+49 1612  56169 41681                       071056.1+493835071831.9+492754168.11 24.51 5.05  +0.08 +0.09 +0.06   A4IIIn             -0.004+0.014 +.008-012V     222                  
+2752          BD-10 1945  56207152621                       071059.2-102430071543.1-103502225.11  0.50 5.95  +1.18 +1.18         K0                 +0.011-0.007      -013                           
+2753 64    AurBD+41 1630  56221 41679 276                   071105.0+410340071802.2+405300177.08 22.11 5.78  +0.17 +0.12         A5Vn               -0.015+0.013      -010V     185                 *
+2754          CP-62  789  56239249774      W                071105.4-630108071202.0-631124274.00-21.77 6.02  -0.02               A0IV-V             -0.003 0.000D+.005-000           0.4   0.4       
+2755          CD-23 5173  56341173319                       071135.6-233353071547.5-234426236.79-05.58 6.32R                     A0                 +0.017+0.007      +034                           
+2756          CD-30 4184  56342197756                       071128.8-303041071521.0-304111242.99-08.80 5.36  -0.17 -0.65         B3V                -0.018+0.013      +033        0                 *
+2757          BD+31 1529  56386 599642563                   071140.6+310807071804.1+305721187.09 18.85 6.24  -0.03 -0.10         A0Vn               -0.004-0.028      +027V     325                  
+2758          BD-15 1734  564051526412561                   071142.7-152431071614.5-153509229.59-01.71 5.46  +0.08 +0.06         A2Vnp              -0.050-0.015 +.041+010V?    152                 *
+2759          CD-41 2906  56410218568                       071141.3-411505071457.1-412533252.84-13.49 5.94  -0.16               B4III-IV           +0.009+0.022      +021V?                         
+2760          BD+06 1594  56446115204                       071155.4+065133071717.8+064050209.88  8.78 6.65  -0.11 -0.41         B8III              +0.001-0.015      +009V?    200                  
+2761          CD-46 3000  56455218570              PR Pup   071153.6-464028071445.9-465059257.96-15.71 5.72  -0.11 -0.46         A0pSi              -0.018-0.008      +040                          *
+2762          CD-48 2807  56456218567      W                071152.6-480549071438.2-481618259.31-16.29 4.76  -0.10 -0.29 -0.08   B8-9V              +0.004+0.004      +039V          8.6  18.5      *
+2763 54Lam GemBD+16 1443  56537 96746 277    5961   3512    071220.7+164315071805.6+163225200.92 13.23 3.58  +0.11 +0.10 +0.05   A3V                -0.048-0.037 +.047-009SB    154  1.0   0.0 O   3*
+2764          CD-23 5189  56577173349    I   5951   3503    071223.8-230816071636.8-231856236.50-05.21 4.79  +1.71 +1.87 +0.96   K3Ib-II            -0.010+0.002 +.019+028V?         1.2  26.8      *
+2765          BD-06 2032  56614134474    I                  071239.1-063004071731.7-064048221.86  2.72 6.29  +1.62 +1.96         K2                 -0.014+0.011      +009                           
+2766          CD-27 3852  566181733602562I                  071234.4-274216071635.0-275252240.58-07.30 4.64  +1.60 +1.88 +1.25   M3III              -0.010+0.043 +.012+042                          *
+2767          CP-52 1123  56705235040                       071258.9-521932071521.0-522959263.45-17.78 5.97  +1.10               K1III              -0.058+0.103      +039                           
+2768          CD-30 4234  56731197789      W                071305.3-304302071657.2-305348243.34-08.59 6.32  +0.20 +0.19 +0.15   A9II               +0.005-0.021      -005V          1.7  37.9      *
+2769          CD-38 3288  56733197785                       071304.3-380826071631.8-381908250.08-11.91 5.80  -0.13 -0.59         B4V                -0.015+0.005      +045V                         *
+2770          CD-36 3485  56779197790              Var?     071315.8-362449071649.5-363534248.52-11.12 5.03  -0.17 -0.69         B2IV-V             +0.001-0.002      +009SB    132                 *
+2771          CD-46 3023  56813218589                       071322.3-463549071615.5-464628257.99-15.45 5.66  +1.44 +1.67         K4III              +0.009+0.035      +020                           
+2772 47    CamBD+60 1048  56820 26298        5995           071331.7+600514072217.2+595407156.84 27.03 6.35                      A8m                +0.003+0.014D+.015+007V          4.5   2.2       
+2773   Pi  PupCD-36 3489  56855197795 278  W        3515    071336.6-365504071708.6-370551249.01-11.28 2.70  +1.62 +1.24 +0.91   K3Ib               -0.009+0.004 +.032+016           5.3  69.2      *
+2774          CD-26 4140  56876173411                       071344.2-263700071747.9-264751239.73-06.57 6.46  -0.15 -0.61         B2IV-V             -0.010+0.001      +015V                         *
+2775          BD+42 1699  56941 41705                       071359.4+425030072103.1+423920175.42 23.16 6.35  +1.46 +1.58         K0                 -0.019-0.046      +046                           
+2776          BD+45 1422  56963 417082567                   071403.1+452447072117.5+451341172.73 23.90 5.77  +0.32  0.00         A7 s               -0.048+0.004      +025                           
+2777 55Del GemBD+22 1645  56986 79294 279I   5983           071409.0+221000072007.4+215856195.98 15.89 3.53  +0.34 +0.04 +0.19   F2IV               -0.026-0.012 +.061+004SBO   111  2.0   0.2 O   3*
+2778          BD+02 1640  569891152632564                   071408.8+025527071922.4+024426213.67  7.46 5.89  +1.07 +0.82         G9III               0.000-0.013      +024                           
+2779          BD+07 1684  570061152692565                   071423.9+071942071947.6+070834209.74  9.54 5.91  +0.53 +0.07         F8V                +0.060-0.063      +022    =< 10                  
+2780          BD+15 1541  57049 96783                       071425.1+151939072006.9+150834202.43 13.08 6.45  -0.02 +0.07         A2Vn               +0.011-0.017      +013SB                         
+2781 29    CMaCD-24 5173  57060173444    I         UW CMa   071430.5-242234071840.3-243332237.82-05.37 4.98  -0.15 -1.01 -0.13   O7Ia:fp           v-0.006 0.000      -011SB2O  136                 *
+2782 30Tau CMaCD-24 5176  57061173446    I   5977   3528    071433.6-244618071842.4-245715238.18-05.54 4.40  -0.15 -0.99 -0.18   O9Ib               -0.009+0.010      +040SBO   112  0.0   0.2AP   5*
+2783 19    LynBD+55 1192  57102 26311        6012B          071441.2+552822072250.9+551704161.96 26.36 6.53H                     B9V                +0.004-0.024 +.011+010SB    250  1.0  15.1AB   4*
+2784 19    LynBD+55 1192  57103 26312 280    6012A          071442.5+552812072252.1+551653161.96 26.37 5.45                      B8V                -0.003-0.029 +.011+005SB2O   80  1.0  15.1AB   4*
+2785          BD-19 1813  57118152710                       071438.5-190550071902.0-191649233.17-02.85 6.09  +0.62 +0.35         F0Iab-Ib           +0.008+0.002      +062SB?    23                  
+2786          CD-26 4164  57146173453    I                  071446.9-262411071851.2-263509239.65-06.26 5.28  +0.96 +0.65         G2Ib               -0.017+0.008 +.017+032V                         *
+2787          CD-36 3512  57150197824      W       NV Pup   071445.0-363306071818.4-364403248.78-10.91 4.66  -0.10 -0.80 -0.05   B2V+B3IVne         -0.003+0.001      +019      277  0.4 239.9AB   4*
+2788          BD-16 1898  57167152724              R CMa    071456.6-161227071928.1-162342230.67-01.41 5.70  +0.35 +0.04         F1V                +0.157-0.132 +.040-039SBO    98                 *
+2789          CD-43 3093  57197218618                       071458.4-434815071804.2-435912255.49-14.03 5.85  -0.12 -0.48         B8II-III           -0.015+0.001      +013V                          
+2790          CD-36 3519  57219197837              NW Pup   071504.8-363335071838.2-364434248.82-10.86 5.11  -0.16 -0.66 -0.21   B2IVne             -0.002+0.003      +018V     124                 *
+2791          CD-38 3309  57240197836                       071508.8-390138071833.6-391237251.08-11.94 5.25  +0.01 +0.07         A1V                +0.010+0.007 +.014+032       29                  
+2792          BD+39 1927  57263 60012                       071523.8+391105072213.4+385946179.29 22.31 6.40  +1.22 +1.23         K0                 -0.003-0.038      +003                           
+2793 65    AurBD+37 1707  57264 600102568I   6009           071521.7+365655072202.6+364538181.57 21.58 5.13  +1.08 +0.94         K0III              -0.098-0.023 +.022+023     < 17  5.5  11.4AB   3*
+2794          CD-33 3696  572991978422566                   071530.3-333233071913.7-334338246.12-09.42 6.30  +1.31               K2-3III            -0.013-0.013      -002                           
+2795 56    GemBD+20 1775  57423 79328    I   6016   3550    071602.8+203757072156.8+202637197.63 15.66 5.10  +1.52 +1.87         M0IIIab            -0.066-0.027 +.002+004           7.4  16.5AB   3*
+2796          BD-14 1846  57478152749                       071623.0-141023072058.2-142136229.04-00.13 5.45  +0.98 +0.63        gG5                 -0.018+0.016      +013                           
+2797          BD+81  252  57508  1194                       071627.2+810559073439.7+805348133.11 28.47 6.41R                    gG7                 -0.010+0.003      -002                           
+2798          BD-08 1862  57517134563                       071628.7-084110072116.9-085242224.24  2.51 6.55  +0.54 +0.04         F5                 +0.036-0.156      -007V?  =< 10                  
+2799          BD-22 1823  57573173517              Var      071638.6-223946072053.2-225106236.54-04.13 6.61  -0.15               B2.5V              +0.006-0.042      +010                          *
+2800          CD-26 4223  57593173522        6015  HQ CMa   071651.3-264634072055.0-265749240.20-06.03 6.01  -0.17 -0.70         B2.5V              +0.010+0.019      +018V          7.2   8.2      *
+2801          BD+00 1915  57608115335                       071655.5+002159072203.5+001038216.28  6.89 5.99  -0.07 -0.29         B8III              +0.001+0.004      -010V       5                  
+2802          CD-25 4400  57615173529    I                  071657.8-254214072104.3-255329239.26-05.50 5.87  +1.64 +1.90         M4III              -0.012+0.025      +023                           
+2803   Del VolCP-67  730  57623249809 281                   071652.8-674627071649.8-675726279.09-22.69 3.98  +0.79 +0.45 +0.38   F6II               -0.007+0.005 +.004+023        0                  
+2804          BD+52 1205  57646 26333    I                  071709.3+520452072457.2+515314165.74 26.03 5.80  +1.61 +1.96 +0.92   K5III              +0.014-0.035      +018V                          
+2805 66    AurBD+40 1852  57669 417381191I                  071713.0+405154072408.5+404020177.67 23.15 5.19  +1.23 +1.24         K1+IIIaCN1         -0.006-0.023 +.007+021SB?  < 19:                 
+2806          BD-08 1872  57682134580                       071714.3-084725072202.0-085845224.41  2.63 6.43  -0.19 -1.04         O9V                +0.006+0.021      +023       35                 *
+2807          BD-02 2079  57708134585                       071717.6-024721072218.5-025844219.13  5.49 6.23  +0.68 +0.35         F5                 -0.016+0.003      -015V   =< 10                  
+2808 57    GemBD+25 1660  57727 79352      D                071722.7+251434072328.5+250302193.34 17.78 5.03  +0.90 +0.57         G8III              -0.069-0.023 +.022+006     < 19:                *
+2809          BD+66  502  57742 141952571                   071731.9+663143072725.8+661954149.69 28.26 6.47  -0.09 -0.19         B9III              -0.012-0.032      +007V?      0                  
+2810 58    GemBD+23 1698  57744 79354                       071727.6+230816072328.2+225643195.38 16.97 6.02R -0.01 -0.01         A1V                -0.022-0.036      +015      125                  
+2811          BD-05 2089  57749134588               3560    071731.1-054732072225.4-055858221.81  4.12 5.82  +0.35 +0.19         F3IV               -0.011-0.004      +011V      42                 *
+2812          BD-18 1806  578211527762570                   071749.2-184933072213.5-190100233.29-02.06 4.96  -0.04 -0.39 -0.04   B7IV               -0.006-0.008      +027      117                  
+2813          CP-52 1153  57852235110      W     A          071756.7-520737072021.4-521842263.57-17.00 6.05  +0.42 -0.02         F0-2IV-V           -0.036+0.134 +.038+022           0.6   9.3      *
+2814          CP-52 1153  57853235111      W     B          071757.0-520728072021.7-521835263.57-17.00 6.60  +0.59 +0.05         G0V:e              -0.040+0.124 +.038+035V          0.6   9.3      *
+2815          CD-51 2445  57917235116                       071812.4-515348072038.7-520510263.37-16.87 5.39  -0.07               B9II-III           -0.019-0.007      +018SB     29:                 
+2816 59    GemBD+27 1374  57927 79366                       071820.1+274952072433.4+273817190.91 18.97 5.76  +0.34 +0.08       g:F0                 +0.012+0.017      -005V      67                  
+2817          BD+15 1564  58050 96866              OT Gem   071845.3+154241072427.7+153102202.53 14.19 6.41  -0.18 -0.84         B2Ve              v+0.011+0.004      +037      140                 *
+2818 21    LynBD+49 1623  58142 417642572           3585    071910.2+492436072642.8+491241168.71 25.75 4.64  -0.02 -0.01 -0.05   A1V                -0.013-0.050 +.012+027V      16                 *
+2819          CD-31 4437  58155197925                       071911.2-314351072300.6-315526244.86-07.90 5.43  -0.15 -0.68 -0.13   B5IIIn            e-0.014+0.004      +024SB                        *
+2820  1    CMiBD+11 1578  58187 96871                       071924.8+115156072458.2+114011206.17 12.67 5.30  +0.10 +0.13         A5IV               -0.017-0.014 +.015-001V?    165                  
+2821 60Iot GemBD+28 1385  58207 79374 282I                  071930.9+275949072543.6+274753190.85 19.27 3.79  +1.03 +0.85 +0.50   G9IIIbHdel -1      -0.123-0.086 +.032+008V       9                 *
+2822          CD-27 4020  58215173622    I                  071927.3-273825072329.1-275003241.24-05.92 5.38  +1.53 +1.83         K2III              +0.045+0.005 +.013+048SB                         
+2823          CD-31 4454  58286197938                       071943.2-320029072331.9-321208245.16-07.93 5.39  -0.18 -0.69         B3III-IV           -0.009+0.004      +021SB     29                 *
+2824          CD-29 4322  58325197944                       071959.7-300120072354.3-301301243.41-06.94 6.60  -0.20 -0.79         B2IV-V             -0.019+0.009      +007                          *
+2825          BD-15 1810  58343152834              FW CMa   072008.9-160018072440.1-161204231.09-00.21 5.33  -0.05 -0.60 -0.02   B2.5IVe           v-0.014-0.010      +002V      33                 *
+2826          BD-22 1855  58346173656                       072002.5-224303072417.2-225446236.96-03.46 6.19  -0.09 -0.36         B8                 -0.016 0.000      +032V?                        *
+2827 31Eta CMaCD-29 4328  58350173651 283I W                072008.3-290629072405.7-291811242.62-06.49 2.45  -0.08 -0.72 -0.06   B5Ia               -0.004+0.005      +041V      45  4.5 178.7      *
+2828  2Eps CMiBD+09 1643  58367115425    I                  072010.9+092824072538.9+091634208.45 11.78 4.99  +1.01 +0.78 +0.50   G6.5IIb            -0.006-0.011 +.008-008V?   < 17                 *
+2829          CD-35 3569  58420197951      W                072021.1-353834072358.3-355016248.48-09.49 6.31  -0.15 -0.55         B7III              -0.018+0.018      +028           6.2  25.0      *
+2830          BD+68  480  58425 14211 284I                  072028.6+684012073052.7+682756147.28 28.69 5.64  +1.11 +0.89        gK2                 -0.010-0.038 +.011+056                           
+2831          BD-18 1825  58439152837      W                072026.4-184857072450.7-190044233.58-01.51 6.24  +0.29  0.00?        A2Ib               -0.021+0.005      +070           4.9   2.7       
+2832          BD-13 2001  584611528401192  W                072032.7-133318072508.3-134507228.99  1.05 5.78  +0.42               F0V                -0.204-0.004 +.037+007V?                         
+2833          BD-05 2112  58526134654                       072056.3-053436072551.0-054630222.02  4.97 5.97  +0.92 +0.62         G3Ib               -0.029-0.004      +014V                          
+2834          CD-31 4482  58535197964    I W        3584    072053.9-313644072443.8-314832244.92-07.52 5.35  +1.07 +0.91         G8II               -0.020+0.010 -.021+020           2.1  99.2AC   4*
+2835          BD+21 1596  58551 79386                       072055.6+214408072650.2+213209197.05 17.15 6.54  +0.46               F6V                -0.315-0.020 +.038+047SB  =< 10:                 
+2836          BD+10 1532  58552 96899                       072057.1+104825072627.9+103630207.31 12.54 6.37  +0.09 +0.06 +0.02   A2IV               -0.021+0.005      -010V      20                  
+2837 61    GemBD+20 1805  58579 79391      D        3592    072102.6+202727072656.3+201526198.29 16.66 5.93  +0.30 +0.10         F2Vn               -0.005-0.019      +009SB                         
+2838          BD-04 1943  58580134658                       072105.7-042018072603.5-043215220.95  5.59 6.76  -0.01 -0.11         A0IV               +0.009-0.018      -002SB2    71                 *
+2839          BD-21 1925  58585173691      W                072102.8-214706072519.9-215858236.26-02.81 6.05  +0.23               A8I-II:            -0.010+0.003      +041V          7.4   2.4       
+2840          BD+11 1588  58599 96901      W                072109.4+111231072641.3+110033206.97 12.76 6.41  -0.13 -0.46         B6IV               +0.009-0.002      +029       50                 *
+2841          CD-24 5366  586121736972574                   072116.5-250111072525.3-251304239.12-04.32 5.78  -0.10 -0.39         B7III              -0.005-0.002      +024V                         *
+2842          CD-37 3549  58634197974      W     B          072114.5-370535072447.2-371724249.87-10.00 6.97  +0.22 +0.15         F0V:               +0.016+0.009D+.003+026           0.1   7.0      *
+2843          CD-37 3549  58635197975      W     A          072114.9-370541072447.3-371727249.87-10.00 6.84  +0.27 +0.15         F0V:               -0.020+0.044D+.003+018           0.1   7.0      *
+2844          BD+48 1538  58661 41797        6095           072124.5+482314072851.6+481102169.91 25.87 5.72  -0.10 -0.41         B9pHgMn            +0.007-0.049      +021V      32  4.6  16.5ABxC 3*
+2845  3Bet CMiBD+08 1774  58715115456 285  W       Bet CMi  072143.6+082927072709.0+081722209.52 11.68 2.90  -0.09 -0.28 -0.06   B8Ve               -0.052-0.038 +.019+022SB    276  7.8 138.7AE   5*
+2846 63    GemBD+21 1602  58728 79403        6089           072148.2+213859072744.4+212642197.23 17.30 5.22  +0.39 -0.04         F5V+F5V            -0.058-0.121 +.041+025SB2O   38  0.5   0.0 O   5*
+2847          CD-31 4506  58766197986              Var?     072152.6-313223072543.0-314419244.96-07.30 6.31  -0.17 -0.70         B2V                 0.000+0.007      +010                          *
+2848          CP-86  105  588052584601661                   072201.5-865211064658.7-870130299.59-27.15 6.47  +0.42 -0.07         F3V                +0.006+0.004      +004                           
+2849 22    LynBD+49 1630  58855 41808      W                072220.5+495245072956.0+494021168.33 26.35 5.36  +0.45 -0.06         F6V                +0.114-0.080 +.042-027V      12  4.8 169.3AB   3*
+2850          CD-23 5477  58907173743                       072227.9-233043072640.7-234244237.93-03.36 6.56  +0.01               A1                 -0.006+0.023      +027                           
+2851  5Eta CMiBD+07 1729  58923115477        6101           072239.3+070845072802.1+065631210.85 11.28 5.25  +0.22 +0.17         F0III              -0.004-0.044 +.010+018       67  5.2   4.0      *
+2852 62Rho GemBD+32 1562  58946 60118 286    6109           072240.8+315900072906.7+314704187.14 21.34 4.18  +0.32 -0.03 +0.19   F0V                +0.155+0.175 +.062-004SB     68  3.4 220.4AC   4*
+2853          BD-17 1980  58954152894        6093           072240.6-173948072708.0-175152232.83-00.49 5.63  +0.32               A5n                +0.002+0.015      -029      157  5.3   1.6       
+2854  4Gam CMiBD+09 1660  58972115478    I   6100           072243.1+090741072809.8+085532209.05 12.18 4.32  +1.43 +1.54 +0.79   K3-IIIFe-0.5       -0.062+0.017 +.019+047SB1O < 17  5.9 130. AD   4*
+2855          BD-22 1874  58978173752              FY CMa   072245.0-225305072659.4-230510237.41-03.00 5.61  -0.13 -0.98 -0.03   B0IV:pe            -0.012+0.004      +025V?    244                 *
+2856          CD-33 3813  59026198000                       072259.3-335622072642.3-340827247.20-08.22 5.90  -0.17 -0.68         B2IV-V             -0.027 0.000      +007                           
+2857 64    GemBD+28 1396  59037 79427                       072306.6+281928072920.4+280705190.83 20.13 5.05  +0.11 +0.12         A4V                -0.041-0.056 +.008+035V     202                 *
+2858          BD+15 1579  59059 96930                       072306.1+151851072847.3+150634203.36 14.97 6.22  -0.05 -0.11         B9IV               +0.004-0.025      +034                           
+2859          BD-11 1951  59067152909        6104AB 3600    072309.6-112114072751.7-113325227.36  2.67 5.79  +0.58 -0.21         G8Ib-II+B2+B8V     -0.004-0.001      +015V?         2.0   0.9AB   5*
+2860          BD-22 1878  59136173778                       072327.8-223922072742.9-225135237.29-02.74 5.95  -0.09 -0.41         B5V:               -0.005-0.017      +026V?                         
+2861 65    GemBD+28 1400  59148 79434    I   6119           072335.5+280721072948.7+275458191.07 20.15 5.01  +1.11 +1.03 +0.37E  K2III              -0.034-0.024 +.018+036SB2  < 17  8.5  12.8      *
+2862          CD-50 2761  592192351922575                   072347.8-504900072621.9-510106262.72-15.63 5.10  +1.06               K0III              +0.001+0.008 +.007+008                           
+2863          CD-28 4383  59256173799              Var?     072400.9-285707072759.2-290921242.88-05.67 5.54  -0.08 -0.15         B9VpSi:            -0.006+0.008      +004                           
+2864  6    CMiBD+12 1567  59294 969521193I          3609    072413.8+121248072947.8+120024206.38 13.88 4.54  +1.28 +1.37 +0.64   K1+IIIBa0.4         0.000-0.019 +.029-015     < 19:                 
+2865          BD-01 1738  593111347402578I                  072415.3-014157072918.7-015419218.99  7.54 5.59  +1.50 +1.76         K5III              -0.015-0.005      -005V                          
+2866          BD-07 1996  59380134742                       072434.1-072054072925.7-073304224.02  4.91 5.86  +0.48 -0.02         F8V                +0.064+0.131      +009V?  =< 10                  
+2867          BD-10 2067  593811529412579I                  072437.1-100713072922.1-101936226.46  3.58 5.75  +1.62 +1.99         K5III              -0.001+0.001      -007                           
+2868          BD-14 1925  59438152943        6126           072448.8-144708072921.9-145957230.57  1.36 6.05  +0.47 -0.07         F7V                -0.185-0.254 +.027-006V          1.4   2.2AB   5*
+2869          CD-37 3601  59466198031                       072451.7-373612072822.8-374837250.66-09.59 6.58  +0.06 +0.04         A1IV               -0.020-0.050      -001V?                         
+2870          CD-31 4590  59499198038      W     A          072500.6-313833072851.3-315054245.36-06.76 6.38  -0.17 -0.70         B3V                +0.008+0.003      +002           0.7   8.9      *
+2871          CD-31 4590  59500198039      W     B          072501.2-313827072851.5-315049245.36-06.76 7.13  -0.15 -0.60         B4V                -0.036+0.003      +004           0.7   8.9       
+2872          BD+39 1958  59507 60148                       072508.4+390623073155.7+385347179.99 24.08 6.54  +0.07 +0.04         A2V                -0.035-0.014      +007                           
+2873          CD-31 4593  59550198042                       072513.2-311459072904.9-312723245.04-06.54 5.77  -0.19 -0.75         B2V                -0.014+0.002      +008SB                         
+2874          BD-22 1897  59612173864      W                072536.5-224859072951.4-230128237.67-02.39 4.85  +0.23 +0.14 +0.27   A5Ib               -0.004-0.006 -.003+037       26  5.9   3.0       
+2875          CD-38 3400  596351980452580                   072537.9-383619072905.7-384844251.64-09.93 5.43  -0.16               B5Vp               -0.016+0.011      +024V      38                  
+2876          BD-04 1979  596691347742582                   072554.9-050101073051.1-051335222.12  6.32 6.24  +1.18 +1.06         K0                 -0.006-0.002      +017                           
+2877          BD+17 1596  59686 969852585I                  072602.4+171756073148.4+170510201.80 16.44 5.42  +1.13              gK2                 +0.043-0.078 +.001-040V?                         
+2878   Sig PupCD-43 3260  597172187551194  W                072603.4-430556072913.8-431805255.74-11.91 3.25  +1.51 +1.78 +0.92   K5III              -0.055+0.187 +.020+088SB1O       5.3  22.3      *
+2879          BD+23 1744  59878 79489        6160           072651.0+230603073250.6+225316196.30 18.95 6.54  +1.01 +0.77         K0II-III+F8V       -0.025-0.012      +030SB         2.2  11.5      *
+2880  7Del1CMiBD+02 1691  598811155812587                   072654.2+020735073205.9+015452215.88  9.92 5.25  +0.22 +0.20         F0III              -0.003-0.003 +.016+029V?     75                  
+2881          CD-30 4620  59890198064    I                  072649.3-304507073042.5-305744244.76-06.00 4.65  +0.93 +0.64 +0.47   G3Ib               -0.021 0.000 +.023+014                           
+2882          CD-37 3637  59967198069    I'                 072709.9-370748073042.4-372023250.46-08.97 6.65  +0.63               G4V                -0.098+0.042      +009                           
+2883          BD-08 1964  59984134806        6158           072718.1-083951073205.8-085251225.50  4.87 5.90  +0.54 -0.08         F5V                -0.090-0.157      +055V   =< 10  2.7  23.4      *
+2884          CP-52 1198  60060235239                       072734.1-522632072959.6-523904264.50-15.79 5.87  +1.01 +0.83         K0III              -0.031+0.058      +026                           
+2885          CD-35 3650  60098198086               3629    072748.4-355628073125.8-360910249.46-08.29 6.68  -0.12 -0.57         B4V                -0.004+0.022      +021       83                  
+2886 68    GemBD+16 1510  60107 97016      D        3642    072754.0+160230073336.5+154936203.19 16.32 5.25  +0.05 +0.06         A1Vn               -0.019-0.012 +.011+012V?    163  1.6   0.2      *
+2887  8Del2CMiBD+03 1715  60111115610                       072757.1+033013073311.6+031725214.76 10.79 5.59  +0.31 +0.10         F2V                -0.018+0.038      +001      101                  
+2888          CP-64  721  601502498642584                   072802.5-641800072851.3-643036275.98-20.45 6.39  +1.56 +1.85         K5III              -0.011-0.016      +014                           
+2889          CD-35 3652  60168198093      W       PS Pup   072804.4-354030073142.8-355316249.25-08.12 6.61  -0.08 -0.36         A0V                +0.011+0.007      -002SB2        4.4  91.5AB   3*
+2890 66Alp GemBD+32 1581  60178 60198 287I   6175B          072813.0+320627073436.0+315319187.44 22.48 2.88  +0.04 +0.02         A2Vm               -0.172-0.099 +.067-001SB1O   30  0.9   2.0AB   6*
+2891 66Alp GemBD+32 1581  60179          I   6175A YY Gem   072813.0+320627073436.0+315318187.44 22.48 1.98  +0.03 +0.01 -0.01   A1V                -0.171-0.098 +.067+006SB1O   14  0.9   2.0AB   6*
+2892          CP-54 1294  602282352522586                   072815.4-541118073030.9-542358266.20-16.43 5.96  +1.56 +1.96         M1III              +0.018+0.021      +049                           
+2893          BD+10 1563  60275 97021                       072834.6+104704073405.1+103406208.18 14.21 6.28  -0.01 -0.06         A1V                -0.005-0.009      -003      135                  
+2894          BD+56 1227  60294 26423                       072838.6+555831073647.0+554519161.77 28.38 5.92  +1.12               K2III              -0.015-0.035      +001V                          
+2895          CD-35 3659  60312198104      W                072844.1-354449073222.3-355741249.38-08.04 6.3   -0.10 -0.36         B9V                -0.012+0.005      +023V          1.2   0.3       
+2896          BD+31 1620  60318 60204        6185           072847.5+311042073508.7+305740188.43 22.29 5.33  +1.01 +0.85         K0III              -0.033+0.013D+.003-006     < 19: 0.4   0.4AB   3*
+2897          BD-14 1966  60325153061                       072846.1-140722073322.1-142018230.45  2.52 6.21  -0.04 -0.71         B1V                -0.010-0.004      +022                          *
+2898          BD+43 1711  60335 41877        6191           072853.7+431503073556.0+430152175.80 25.89 6.30R                     F0                 -0.024-0.050D+.005+021    =< 15  1.1   2.2       
+2899          BD-19 1944  60341153062                       072855.2-191142073319.5-192445234.89  0.06 5.66  +1.12 +1.08 +0.38E  K3III              +0.022-0.067      +016V                         *
+2900          CD-24 5566  60345173987                       072858.9-242945073309.7-244239239.51-02.54 5.85  +0.17 +0.11         A7V:               -0.010+0.013      +015                           
+2901  9Del3CMiBD+03 1719  60357115644      W                072901.0+033519073415.8+032217214.81 11.06 5.81  -0.02 -0.09         A0Vnn              -0.012-0.014      +034V     195  5.2  90.0AB   3 
+2902          BD-14 1971  60414153072    I         KQ Pup   072912.3-141827073347.9-143126230.67  2.52 4.97  +1.41 +0.29 +1.33   M2Iabpe+B2V       v-0.012+0.004 -.003+022SBO                       *
+2903          BD+46 1286  60437 418791195I                  072916.1+462403073631.6+461049172.41 26.71 5.65  +1.56 +1.90 +0.78E  M0III              -0.028-0.032      +029                           
+2904          BD+03 1723  60489115653               3648    072932.9+025637073446.0+024330215.46 10.88 6.55  +0.22 +0.15         A7III              -0.043-0.027      +046                          *
+2905 69Ups GemBD+27 1424  60522 795331196I W        3652    072945.6+270705073555.3+265345192.60 21.06 4.06  +1.54 +1.94 +0.91   M0III-IIIb        e-0.034-0.106 +.014-021    =< 19: 9.0  46.1      *
+2906          BD-21 2007  60532174009 288                   072946.3-220448073403.2-221746237.50-01.19 4.45  +0.51 +0.06 +0.27   F6IV               -0.040+0.046 +.054+061        0                 *
+2907          CD-39 3398  60559198120                       072949.1-395032073313.5-400332253.13-09.78 6.26  -0.12 -0.48         B8IVpSi            +0.020-0.010      +014V                          
+2908          CD-42 3325  60574218792                       073000.7-425208073313.3-430511255.87-11.16 6.52  +0.92               G8III              +0.005-0.035      -048                           
+2909          CD-23 5709  60584174019        6190A          073005.0-231520073418.6-232825238.56-01.71 5.83  +0.44 +0.03        dF4                 -0.095+0.002 +.023-005SB         0.0   9.6      *
+2910          CD-23 5709  60585174020        6190B          073005.7-231523073419.1-232829238.56-01.71 5.87                     dF6                 -0.111-0.010 +.023-006V          0.0   9.6      *
+2911          CD-36 3715  60606198130              OW Pup   073013.9-360715073351.0-362018249.85-07.95 5.54  -0.06 -0.72 -0.01   B3Vne              -0.012+0.001      -009SB    297                 *
+2912          CD-25 4719  60629174028                       073021.6-255351073428.8-260700240.89-02.95 6.65  -0.01 -0.05         A0V                -0.019-0.025      +028                           
+2913          CD-33 3926  60646198138                       073026.8-331449073412.8-332748247.33-06.53 6.11  +0.29               A9IV               -0.056+0.070      +025                           
+2914          BD+49 1653  60652 41893                       073026.4+485949073753.9+484625169.61 27.45 5.92  +0.22 +0.16 +0.05   A5m                -0.026-0.032      +010       60                  
+2915          BD+40 1903  60654 418872589I                  073027.2+401455073717.8+400131179.10 25.39 6.38R                     M1                 -0.011-0.050      +010                           
+2916          CD-26 4574  60666174033                       073030.1-264744073434.9-270043241.69-03.37 5.77  +1.06               K1III              -0.039+0.079      -006V?                         
+2917          CD-39 3407  60686198137                       073033.7-394120073358.5-395421253.06-09.59 6.76  +1.13               K2III              -0.017+0.045      +030V                          
+2918          BD+06 1729  60803115693                       073115.2+060500073634.7+055142212.81 12.70 5.91  +0.60 +0.10         G0V                -0.111+0.011      +004SB2?=< 10                  
+2919   Eps MenCP-78  265  608162564152583                   073108.4-785305072538.0-790539291.02-25.01 5.53  +1.28 +1.42         K2-3III            -0.033+0.003 -.002+011                           
+2920          BD-07 2065  60853134883    I                  073126.7-080523073616.6-081841225.50  6.04 6.27  +1.54 +1.89         K2                 +0.035+0.002      +005                           
+2921          BD-14 1999  60855153118        6208  Var      073128.0-141616073603.9-142934230.91  3.02 5.70  -0.12 -0.71 -0.10   B2Ve               -0.010+0.003      +021      284  3.8  19.6ABxC 3*
+2922          CD-28 4566  60863174058        6205           073122.0-280854073522.8-282210242.96-03.87 4.64  -0.11 -0.40 -0.11   B8V                -0.074-0.019      +003V?    222  4.5  38.4AB   3*
+2923          BD-21 2030  60951174092                       073149.8-215617073607.8-220938237.61-00.70 6.34  +0.99 +0.76         G5                 +0.044-0.018      +028SB2                        
+2924 70    GemBD+35 1662  60986 60243        6229           073159.1+351621073832.8+350255184.45 24.24 5.56  +0.93               K0III              +0.037+0.030      -036V          4.6 159.9AC   5 
+2925          CD-51 2571  61031235310                       073205.8-511515073439.5-512829263.71-14.64 6.28  +0.08               A1III-IV           -0.006-0.001      +028                           
+2926          BD+24 1727  61035 79562                       073211.3+243505073814.5+242137195.34 20.64 6.27R                     F0                 +0.025+0.013      +007      112                  
+2927 25    MonBD-03 1979  61064134899 289  W        3665    073218.3-035316073716.7-040640221.89  8.26 5.13  +0.44 +0.12         F6III              -0.068+0.017 +.028+046       20  5.3 121.7AC   3*
+2928          BD-19 1967  610681531491197          PT Pup   073217.3-192846073641.0-194208235.53  0.61 5.74  -0.19 -0.89         B2III              -0.007+0.005      +022V?     38                 *
+2929 23    LynBD+57 1093  61106 264592593                   073233.2+571840074049.5+570458160.34 29.09 6.06  +1.46 +1.65         K5III              -0.018-0.005      -013V                          
+2930 71Omi GemBD+34 1649  61110 602472592                   073238.3+344850073909.9+343503184.97 24.23 4.90  +0.40 +0.11 +0.22   F3III              -0.037-0.117 +.021+007V      89                  
+2931          BD+24 1730  61219 79580                       073309.5+242658073911.9+241321195.56 20.79 6.17  +0.01 +0.04         A2V                -0.012+0.002      -011V     110                  
+2932          BD-14 2053  61224153172      W                073302.7-141257073738.9-142628231.05  3.38 6.53  -0.01 -0.30         B9IIIe             +0.014-0.004      +016      275  2.8  65.0      *
+2933          CD-23 5791  61227174141                       073303.2-233303073716.8-234630239.15-01.26 6.37  +0.54 +0.44         F0II               -0.015+0.022      +018V                          
+2934          CP-52 1231  612482353361198           3661    073311.3-521838073539.7-523202264.77-14.96 4.94  +1.40 +1.63 +0.73   K3III              +0.024-0.016 +.012+062SB                        *
+2935          BD+38 1803  61294 60257    I                  073330.9+383424074014.6+382040181.06 25.49 5.73  +1.63 +1.95         M0III              -0.050-0.009      +046V?                         
+2936          BD+32 1599  61295 60254                       073330.3+321420073954.1+320035187.71 23.58 6.17  +0.35 +0.13         F6II               -0.019-0.045      +025SB  =< 23                  
+2937          CD-34 3755  61330198195 290  W                073340.0-344437073722.1-345807248.98-06.67 4.53  -0.09 -0.31 -0.07   B8IV               -0.022+0.014      +024       80  0.5   0.1AB   3*
+2938 74    GemBD+18 1701  61338 97120    I D        3671    073342.1+175408073928.6+174029202.01 18.35 5.05  +1.56 +1.92         K5IIIFe-0.5        +0.005+0.004 +.009+028V?         0.0   0.0      *
+2939          BD+48 1561  61363 419342594                   073349.2+482154074112.4+480754170.43 27.88 5.56  +1.01       +0.52:  K0III              -0.054-0.128 +.009+040                           
+2940          CD-48 3069  613912188412591                   073355.8-483619073643.9-484949261.40-13.19 5.72  -0.06               B9.5V              -0.001-0.003      -001                           
+2941          CP-55 1282  61394235343                       073354.2-553949073601.7-555315267.95-16.32 6.39  +1.18               K1-2IIICNII        -0.002+0.010      +022                           
+2942          CD-34 3760  61409198205                       073403.7-350305073744.8-351638249.29-06.75 6.60  +1.14               K1III              -0.027+0.012      +031                           
+2943 10Alp CMiBD+05 1739  61421115756 291I   6251   3672    073404.0+052853073918.1+051330213.69 13.03 0.38  +0.42 +0.02 +0.23   F5IV-V             -0.710-1.023 +.288-003SBO     6 10.4   4.6AC   5*
+2944          CD-25 4828  61429174175        6246  PU Pup   073408.2-250816073818.0-252153240.65-01.84 4.70  -0.11 -0.35 -0.09   B8IV               -0.007-0.007      +041V     293: 0.4   0.2      *
+2945          CD-37 3736  61453198210                       073412.8-374708073745.2-380038251.71-08.05 6.38  +1.48               K4III              +0.007+0.058      +052                          *
+2946 24    LynBD+59 1103  61497 26474 292    6285           073432.8+585640074300.4+584237158.51 29.53 4.99  +0.08 +0.08 +0.04   A3IVn              -0.037-0.051 +.018+009V     183  5.8  54.7       
+2947          BD-18 1946  61554153195                       073440.8-182700073907.1-184045234.92  1.61 6.72  -0.10 -0.50         B6Vn               -0.021-0.026      +036                           
+2948          CD-26 4707  61555174198        6255A  3673    073443.4-263427073849.3-264806241.96-02.44 4.50H -0.17 -0.57 -0.16   B6V                -0.017+0.019D+.010+024       65  0.2   9.9AB   3*
+2949          CD-26 4707  61556174199        6255B  3673    073443.9-263434073849.8-264813241.97-02.44 4.62H                     B5IVn              -0.029+0.028D+.010+033      193  0.2   9.9AB   3*
+2950          BD+05 1742  61563115773        6263           073448.3+052741074007.0+051351213.79 13.20 6.02  -0.04 -0.18         A0III              -0.008-0.023 +.014+017SB    100  0.3   1.1AB   3*
+2951          BD+23 1780  61603 796072595I                  073459.2+231459074058.5+230107196.92 20.73 5.89  +1.58 +1.86 +0.62E  K5                 -0.010-0.011      +039                          *
+2952          CD-39 3463  61623198226                       073458.6-394550073824.2-395929253.54-08.88 6.59  -0.05 -0.17         A0                 +0.013+0.018      +015V                          
+2953          BD+14 1721  61630 97136                       073509.7+140008074047.3+134615205.89 17.05 6.24                      K0                 +0.010-0.016      +005                           
+2954          CD-36 3773  61641198237                       073506.4-361606073843.9-362949250.46-07.16 5.80  -0.16 -0.70         B2IV-V             -0.007+0.001      +019V?                        *
+2955          CD-38 3521  61642198229                       073502.5-383308073832.6-384652252.47-08.28 6.19  +1.02 +0.77         G8III              +0.030-0.028      +026                          *
+2956          CD-26 4722  61672174219                       073521.0-263800073926.9-265147242.09-02.35 6.50  -0.10 -0.48         B7V                -0.013+0.001      +033                           
+2957          CD-48 3091  61715218852              MY Pup   073528.5-482223073818.2-483604261.31-12.86 5.68  +0.65 +0.45         F4Iab              +0.002+0.008      +011       19                 *
+2958          BD-07 2118  61749134969                       073545.3-075713074035.5-081109225.90  7.04 6.01  +0.15 +0.11         A3IV               +0.016-0.037      -007V                          
+2959          BD-14 2082  61772153227    I                  073548.8-150155074023.2-151549232.09  3.55 4.94  +1.56 +1.80         K3II               -0.010-0.022 +.005+000V                          
+2960          BD-19 2003  61774153225        6273           073549.4-192549074013.6-193939235.90  1.36 5.93  +1.16 +1.07         K0                 +0.007+0.011      -003           5.2   8.3      *
+2961          CD-38 3531  61831198253                       073555.9-380441073927.4-381830252.14-07.90 4.84  -0.19 -0.66 -0.16   B2.5V              -0.014+0.004      +026      138                 *
+2962          BD+34 1657  61859 60291                       073614.7+341404074243.5+340001185.83 24.76 6.02R                     F7V                -0.080-0.003      -011SB2O                      *
+2963          CD-37 3767  61878198265      W                073611.7-375432073943.8-380822252.01-07.77 5.73  -0.12 -0.49         B5Vn               -0.019+0.011D+.006+030           2.7   1.1      *
+2964          CD-37 3768  61899198268                       073616.1-380148073947.8-381539252.13-07.82 5.76  -0.07 -0.54         B2.5V              -0.011+0.004      +023                          *
+2965          BD+13 1737  61885 97154    I                  073615.4+134252074151.8+132850206.28 17.17 5.77  +1.67 +1.99         M2IIIab            -0.039-0.020      +007                           
+2966          BD+03 1758  61887115813               3689    073619.8+035130074135.2+033729215.43 12.81 5.94  -0.04 -0.08         A0V                +0.015-0.025      -024V     165                  
+2967          BD+14 1729  61913 971572597I         NZ Gem   073624.9+142633074203.2+141230205.61 17.51 5.56  +1.64 +1.91 +1.42   M3II-III           -0.004-0.012 +.006-016V?                        *
+2968          CD-37 3770  61925198273                       073623.8-372053073958.0-373446251.54-07.46 6.00  -0.04 -0.46 +0.01   B6IVe              +0.001-0.010      +007SB                        *
+2969          BD+50 1460  61931 264882599                   073629.8+504014074404.2+502602167.94 28.72 5.27   0.00  0.00         A0IIIn             -0.005-0.026 +.015+000SB    183                  
+2970 26Alp MonBD-09 2172  61935134986 293I                  073628.1-091904074114.8-093304227.19  6.52 3.93  +1.02 +0.88 +0.52   K0III              -0.073-0.019 +.024+011     < 17                 *
+2971          CP-52 1242  61966235391      W       V390 Car 073635.5-530235073900.4-531624265.68-14.82 6.06  -0.11 -0.41         B9IV-Vp:Si:        -0.009+0.008      +012           7.8  15.       *
+2972          CD-27 4393  61987174273                       073640.1-274246074043.4-275645243.17-02.63 6.76  -0.16 -0.64         B3-5IV-V:          +0.007-0.017      +036                           
+2973 75Sig GemBD+29 1590  62044 79638    I W       Sig Gem  073703.7+290732074318.7+285301191.19 23.27 4.28  +1.12 +0.97 +0.58   K1III             e+0.065-0.232 +.018+046SB1O   22  6.5 182.2      *
+2974          CD-31 4910  62058198286              R Pup    073659.8-312541074052.7-313939246.43-04.43 6.56  +1.18 +0.85 +0.67   G20-Ia             +0.014+0.012      +068                          *
+2975 51    CamBD+65  593  62066 143212602                   073706.6+654141074640.1+652721150.76 30.20 5.92  +1.18              gK2                 +0.027+0.018      -029                           
+2976          BD-21 2077  62082174298    I                  073705.7-220612074123.6-222014238.36  0.27 6.18  +1.62 +1.95 +0.94E  M1III              +0.022-0.004      +032V                          
+2977 49    CamBD+63  733  62140 14322              BC Cam   073724.3+630418074627.4+624950153.79 30.15 6.49  +0.26 +0.13         F0pSrEu            -0.036-0.057      +002                          *
+2978          BD+22 1756  62141 79641      W     A          073724.8+223807074322.2+222358197.75 21.02 6.21  +0.93               K0III              -0.026+0.013      -003                           
+2979          CP-73  457  62153256428      W     A          073724.6-740254073521.7-741632286.11-23.14 7.16H -0.02 -0.24         B9IV               -0.007+0.009D+.010+013SB2        0.1   1.8      *
+2980          CP-73  457  62154            W     B          073724.6-740254073521.8-741632286.11-23.14 7.26H                     B9IV               -0.007+0.009D+.010+010           0.1   1.8      *
+2981          CD-38 3556  62226198298                       073744.7-381759074115.8-383201252.51-07.69 5.42  -0.15 -0.56         B5V                -0.017+0.013      +040SB2   100                 *
+2982          BD+00 2054  62264115839        6313           073757.4+002534074305.4+001122218.73 11.56 6.19  +1.02 +0.74         K0III              +0.008-0.012      +008           0.2   0.1AB   3 
+2983 76    GemBD+26 1633  62285 79650    I          3703    073800.9+260121074406.9+254703194.42 22.39 5.31  +1.54 +1.89         K4-5III            -0.020-0.016 +.007+003V    < 19:                 
+2984          CD-44 3655  62318218905                       073813.5-442350074121.8-443756257.96-10.57 6.41   0.00 -0.18         B7IV-V             +0.010 0.000      +027V?                         
+2985 77Kap GemBD+24 1759  62345 79653 294I   6321           073824.6+243816074426.8+242353195.85 21.97 3.57  +0.93 +0.69 +0.45   G8IIIa             -0.033-0.052 +.026+021        8  5.8   7.1      *
+2986          CD-38 3564  62376198315                       073826.8-381735074158.0-383144252.57-07.57 6.54  -0.09 -0.40?        B7V                -0.017+0.002      +008                           
+2987          BD+13 1750  62407 97199                       073838.9+130557074414.0+125134207.12 17.43 6.43                      K0                 -0.024-0.042      +027                           
+2988          CD-26 4824  62412174356                       073840.4-260649074248.1-262104242.01-01.44 5.64  +0.99 +0.80         K1III              -0.005-0.027      -018                           
+2989          BD+02 1761  62437115864              AZ CMi   073855.0+023839074407.4+022418216.84 12.81 6.47  +0.20 +0.14         F0III:             -0.048-0.022      +015                          *
+2990 78Bet GemBD+28 1463  62509 79666 295I   6335   3712    073911.8+281604074518.9+280134192.23 23.41 1.14  +1.00 +0.85 +0.50   K0IIIb            e-0.628-0.046 +.094+003V    < 17 10.2 201.1AC   7*
+2991 79    GemBD+20 1893  62510 79665                       073917.1+203322074509.3+201859199.99 20.62 6.33R  0.00  0.00         A1V                -0.014+0.008      -011       79                  
+2992          CD-25 4966  62555174395      W                073929.0-251554074339.1-253014241.37-00.85 6.55  +0.06               A3                 +0.001-0.005      +023V?         7.5   5.3       
+2993  1    PupCD-28 4767  62576174391    I   6324   3708    073930.1-281023074332.4-282440243.88-02.32 4.59  +1.63 +1.96 +0.97   K3Ib               -0.014+0.025 +.018+033           8.9  26.2       
+2994          CD-35 3809  62578198343                       073932.3-354844074312.0-360301250.51-06.15 5.60  -0.13 -0.54         B5V                -0.019+0.008      -001                           
+2995          CD-38 3583  62595198342                       073936.4-383731074307.0-385151252.98-07.54 6.89  +1.02 +0.77         G6/8III            +0.009-0.018      +000                           
+2996  3    PupCD-28 4774  626231744002601I                  073947.6-284256074348.5-285717244.38-02.54 3.96  +0.18 -0.09 +0.22   A2Iabe             +0.002+0.005      +025SBO    73                 *
+2997          BD+80  238  62613  1254                       073945.7+803059075617.3+801556133.68 29.44 6.56  +0.73 +0.28         G8V                -0.476+0.090      -008V                          
+2998          CD-44 3675  62644218923                       073951.4-445509074257.2-451024258.57-10.57 5.06  +0.78 +0.32         G6IV               -0.066-0.558      +028SB                         
+2999          BD+37 1769  62647 603281199I          3721    073958.9+374535074639.3+373103182.32 26.50 5.18  +1.58 +1.94 +0.90E  M2IIIb             +0.027+0.014      -035V                          
+3000          CP-77  321  626892564312596                   074006.1-772412073604.2-773803289.62-24.11 6.18  +1.73 +2.03         M0III              +0.006+0.009      +007V?                         
+3001          CD-37 3820  62712198352                       074010.2-375745074342.9-381207252.45-07.11 6.40  -0.16 -0.48         B9VpSi             -0.025+0.006      -006                          *
+3002          CD-40 3377  627132189322603                   074017.6-404121074341.9-405602254.86-08.44 5.17  +1.10 +1.06         K1III              +0.133-0.175 +.026+053                          *
+3003 81    GemBD+18 1733  62721 972211200I D                074020.0+184515074607.4+183036201.86 20.14 4.88  +1.45 +1.75 +0.83   K4III-IIIb         -0.076-0.058 +.014+081SB   < 17  0.0   0.1      *
+3004          CD-24 5885  62747174433              Var?     074021.9-242601074434.0-244026240.75-00.26 5.62  -0.19               B1.5III            -0.030+0.016      +015                          *
+3005          CD-49 3014  62756218928                       074022.8-494512074306.9-495934262.95-12.79 6.57  +0.07               A2V                -0.005-0.006      +003                           
+3006          CP-58  967  627582354302600                   074020.2-582335074210.2-583751270.91-16.72 6.43  -0.10               B2.5V              -0.001+0.003      +011SB                         
+3007          CD-35 3825  62781198366                       074030.3-354927074409.6-360346250.62-05.99 5.80  +0.31 +0.01         F2V                -0.083+0.076      +029                           
+3008 11    CMiBD+11 1670  62832 972241201           3724    074045.9+110043074616.2+104606209.33 17.00 5.30  +0.01 -0.02         A1Vnn              -0.029-0.024 +.022+028SB    249                  
+3009  2    PupBD-14 2193  62863153362        6348B PV Pup   074052.7-142636074528.7-144110232.19  4.91 6.89                      A8V                -0.016-0.018      +030SB2        0.8  16.8AB   3*
+3010  2    PupBD-14 2194  62864153363        6348A          074053.1-142651074529.1-144127232.20  4.91 6.07  +0.11               A2V                -0.014-0.026      +024           0.8  16.8AB   3*
+3011          CD-37 3841  62893198379                       074100.5-374207074434.2-375635252.31-06.84 5.88  -0.11 -0.36         B7V                -0.018+0.004      +037                          *
+3012          CP-57 1305  62897235440                       074100.2-575929074253.3-581348270.57-16.46 6.21  +1.05 +0.84         K0III              -0.030+0.033      -022V                          
+3013 80Pi  GemBD+33 1585  62898 60340 296I   6364   3729    074103.5+333940074730.3+332456186.76 25.53 5.14  +1.60 +1.95         M1IIIa             -0.018-0.029 +.012-012V?         5.2  21.0AB   3*
+3014          BD-06 2281  62902135079    I                  074108.5-063136074602.2-064621225.31  8.90 5.49  +1.38 +1.68         K5III              +0.056-0.094      -033V                          
+3015  4    PupBD-14 2199  629521533721202                   074120.5-141914074556.9-143350232.14  5.07 5.04  +0.33 +0.09         F0V                -0.012+0.006 +.031-002V     101                  
+3016          CD-37 3861  62991198390                       074130.7-373843074504.6-375316252.31-06.73 6.54  -0.10 -0.63         B3IV               -0.023+0.007      +024                          *
+3017          CD-37 3863  630321983982605           3723    074141.4-374333074515.3-375807252.39-06.74 3.61  +1.73 +1.72 +1.00   K2.5Ib-II          -0.010+0.002 +.006+017                          *
+3018          CD-33 4113  63077198404                       074151.1-335832074535.0-341023249.13-04.81 5.37  +0.60 -0.06 +0.23E  G0V                -0.279+1.665 +.064+103V                         *
+3019          BD-12 2135  63112153389                       074204.2-122549074644.9-124031230.59  6.17 6.39  -0.02 -0.08         A0V                +0.018 0.000      +008V?  =< 41                  
+3020          CD-43 3534  63118218955                       074205.3-433032074518.1-434508257.51-09.53 6.03  -0.07 -0.41         B6IV               -0.004+0.002      +035      118                  
+3021 82    GemBD+23 1812  63208 79704        6378           074234.9+232319074833.6+230828197.48 22.40 6.18R                     G2III+A4V          -0.011+0.008      -005V?         0.1   0.3AB   4 
+3022          CD-37 3886  63215198416                       074236.4-374121074610.4-375602252.45-06.56 5.88  -0.11 -0.47         B7V               t-0.035+0.004      +028                          *
+3023          BD-22 2027  63271174533              Var?     074254.6-221624074712.5-223111239.19  1.34 5.90  -0.19 -0.81         B2IV-V             -0.013+0.007      +007       73                 *
+3024   Zet VolCP-72  627  63295256438 297  W                074303.1-722157074149.2-723622284.57-22.16 3.95  +1.04 +0.83 +0.53   K0III              +0.030+0.018 +.017+048           5.8  16.7       
+3025          CD-39 3587  63308198424                       074306.5-394850074633.4-400335254.36-07.54 6.57  -0.13 -0.67         B2V                -0.006-0.001      +034                          *
+3026          BD-15 2049  63302153404              QY Pup   074305.2-154437074738.5-155927233.59  4.71 6.34  +1.78 +1.92         K1Ia-Iab           -0.004+0.001      +031V?                        *
+3027          BD-15 2052  63323153409    I W        3741    074312.0-154602074745.2-160052233.62  4.72 6.43  +1.70 +1.97         M2II-III            0.000-0.001      +014V?         0.1 130.5AB   3*
+3028          BD+54 1177  63332 26535                       074313.1+542243075105.7+540745163.89 30.25 6.02  +0.46 +0.02         F6V                -0.041+0.051      -002V   =<  6                  
+3029  5    PupBD-11 2106  63336153414        6381           074315.7-115650074756.7-121135230.32  6.66 5.48  +0.48 -0.02        dF5                 -0.111+0.059D+.013+027V      55  1.8   2.0      *
+3030          BD+13 1772  63352 97273    I                  074325.5+133715074902.0+132215207.14 18.71 6.04  +1.38               K0                 +0.051-0.043      -057                          *
+3031          CP-56 1420  63382235490      W                074330.1-562839074535.6-564321269.32-15.48 6.12  +0.39               F0II               +0.005+0.016      +019V?         5.0  36.2       
+3032          CD-39 3595  63401198435              OX Pup   074336.3-390503074705.8-391953253.77-07.09 6.31  -0.17 -0.55         B8III              -0.010-0.005      +022                          *
+3033          BD+04 1826  63435115966                       074342.4+043459074858.9+041958215.64 14.77 6.53  +0.78 +0.38         G2III              -0.036-0.031      -006                           
+3034   Omi PupCD-25 5081  63462174558        6384   3745    074355.7-254120074805.2-255614242.25-00.21 4.50  -0.05 -1.02 -0.01   B0V:pe:           v-0.009+0.006      +015V     368  8.0  27.0      *
+3035          CD-38 3650  63465198442      W                074352.5-381549074725.0-383040253.08-06.63 5.08  -0.10 -0.65         B2.5III            -0.006 0.000 -.004+012       53  5.8  10.9      *
+3036          CP-65  806  63513249944                       074405.7-654941074443.9-660419278.18-19.49 6.38  +0.95 +0.66         G6-8III            -0.015+0.043      +002                           
+3037          CD-46 3435  635782190001203                   074430.1-462137074731.5-463631260.25-10.56 5.23  -0.14 -0.85         B1.5IV             -0.002+0.004      +034SB    154                  
+3038          CP-69  770  63584249943                       074431.1-693437074413.0-694917281.85-20.97 6.18  -0.06 -0.09         A0IV-V             -0.050+0.011      +010                           
+3039          BD+55 1228  63586 26543                       074437.3+552753075236.6+551234162.66 30.56 6.38                      A0Vn               -0.004-0.039      +008V     325                  
+3040          BD+33 1601  63589 60379      W        3758    074436.7+332909075102.3+331401187.19 26.19 6.03  +0.15 +0.15 +0.02   A2Vm               -0.017+0.001      -010V      40  4.2  77.8       
+3041          CD-40 3490  63640219006              T Pup    074443.4-402408074808.5-403908255.03-07.57 6.14  +1.58 +1.90 +1.01E  M2III              -0.003-0.029      +023                          *
+3042          BD-12 2164  63655153449                       074449.5-130606074928.6-132112231.52  6.41 6.23  -0.09 -0.47         B8III              -0.035-0.018      -007V                          
+3043          CD-24 6022  63660174592                       074449.6-243944074901.7-245444241.47  0.49 5.33  +0.76               G0III              -0.030+0.019 +.036+002SB                         
+3044  6    PupBD-16 2146  636971534542607I                  074510.1-165825074941.2-171342234.91  4.51 5.18  +1.28 +1.49         K3III              +0.052-0.117      +044V                          
+3045  7Xi  PupCD-24 6030  637001746011204I   6393           074505.3-243631074917.7-245135241.46  0.57 3.34  +1.24 +1.16 +0.55   G6Iab-Ib           -0.003-0.002 +.003+003SB         9.5   5.1      *
+3046          CD-46 3451  63744219018                       074521.6-464931074820.3-470440260.73-10.66 4.71  +1.06 +0.92 +0.57   K0III              -0.088-0.078 +.006-001SB                         
+3047          BD-08 2096  63752135158    I                  074522.2-085552075010.6-091100227.95  8.62 5.61  +1.44 +1.56         K3III              -0.001+0.004      -007V                          
+3048          BD-19 2085  63754174617        6398           074521.7-195708074945.2-201225237.49  3.02 6.56  +0.58 +0.12         G3V                -0.053-0.106      +045V          7.0   6.0       
+3049          CD-34 3970  63786198480               3756    074531.1-345931074914.7-351436250.42-04.69 5.93  -0.05 -0.19         B9V                +0.001+0.009      +034SB2                       *
+3050          BD+03 1818  63799116014        6405           074532.5+033153075047.4+031638216.83 14.69 6.18  +1.12 +1.01         K1III              +0.054-0.031D+.003-048           0.2   0.2      *
+3051          BD-19 2089  63822153468                       074540.3-191616075005.7-193125236.95  3.44 6.12  +1.26               K0                 -0.007-0.002      +032V                          
+3052          CD-32 4451  638521984872608                   074546.2-330213074935.4-331720248.76-03.64 5.60  +1.61 +1.95         K5III              -0.034 0.000      +033                           
+3053          BD+19 1854  63889 97318                       074607.8+193452075156.7+191931201.62 21.72 5.99  +1.13              gK1                 -0.055-0.032      +039                           
+3054          BD-10 2253  638941534792609                   074611.0-105225075055.2-110743229.75  7.82 6.16  +1.13               K0                 -0.001-0.031      +044V                          
+3055          CD-46 3458  63922219035      W                074611.4-460716074914.3-462224260.18-10.19 4.11  -0.18 -1.01 -0.17   B0III               0.000+0.006      +024       49  4.9  59.2      *
+3056          CP-56 1437  63926235532      W                074611.3-561312074819.2-562816269.26-15.03 6.33  +1.01 +0.38         K0III+A1V          -0.026+0.003      +009           2.2   1.1       
+3057          CD-44 3762  63948219040                       074618.9-442958074928.2-444507258.76-09.36 6.32  +0.96 +0.72         K0III              -0.048+0.003      +032                           
+3058          CD-46 3460  63949219034              QS Pup   074612.1-463621074912.9-465128260.61-10.42 5.84  -0.14 -0.85         B1.5IV              0.000+0.011      +025                          *
+3059 13Zet CMiBD+02 1808  639751160431205                   074630.8+020120075142.0+014601218.32 14.20 5.14  -0.12 -0.49         B8II               -0.016-0.003 +.012+032V?     35                 *
+3060          CD-24 6060  64042174658        6414           074646.6-241623075100.0-243142241.37  1.08 6.45  -0.01 -0.06         A0                 -0.012-0.023      -007           3.5   0.9       
+3061          BD+03 1824  64052116054    I         BC CMi   074652.4+033208075207.2+031638216.98 14.99 6.31  +1.59 +1.62 +1.26E  M4III              +0.047-0.084      -062                          *
+3062          CP-56 1442  64067235539      W                074657.8-560928074906.7-562438269.26-14.91 5.59  +1.13 +0.84         G5II               -0.003+0.007      +022SB         8.0   6.9       
+3063  8    PupBD-12 2179  64077153499                       074700.2-123349075140.9-124910231.32  7.14 6.36  +0.39               F2                 -0.001-0.011      +021V     101                  
+3064  9    PupBD-13 2267  64096153500        6420           074708.4-133757075146.3-135353232.27  6.62 5.17  +0.60 +0.06 +0.36   G0V:               -0.062-0.340 +.062-018SBO  < 17  0.7   0.4      *
+3065 25    LynBD+47 1498  64106 42055                       074712.9+473841075429.3+472310171.70 29.95 6.25  +1.15 +1.07        gK2                 -0.017+0.006      -063V                          
+3066 26    LynBD+47 1499  64144 42058 299I                  074725.9+474926075442.7+473353171.50 30.02 5.45  +1.46              gK4                 -0.047+0.002      +017                           
+3067 83Phi GemBD+27 1499  64145 797741207                   074722.6+270129075329.8+264557194.19 24.70 4.97  +0.09 +0.10 +0.05   A3V                -0.035-0.031      +008SB    152                  
+3068          BD-20 2235  64152174679                       074721.7-205506075142.9-211026238.56  2.93 5.63  +0.96 +0.70 +0.33E  G8III              -0.062+0.025      +032V?                        *
+3069          CD-44 3780  64181219059                       074731.8-441930075042.4-443447258.72-09.09 6.45  +0.90               G6III              -0.022+0.021      +033V                          
+3070          CP-59  908  641852499751206  W                074733.7-600203074912.9-601701272.87-16.62 5.78  +0.42 -0.01         F1V                -0.055+0.151      +020           6.9  23.3      *
+3071          CD-50 3004  64225235552                       074740.6-501512075023.9-503035263.97-12.00 5.91  +1.09 +1.02         K2III              -0.060-0.049      -023                           
+3072          BD-05 2280  642351352052611  W        3777    074751.6-051011075247.9-052541224.94 11.03 5.76  +0.41  0.00         F5IV               -0.017-0.023      -002       20: 0.3   0.2      *
+3073 10    PupBD-14 2250  64238153520                       074742.7-143521075218.9-145047233.16  6.26 5.69  +0.37 +0.21?        F1Ia               -0.011-0.002      +017V                          
+3074          CD-42 3601  64287219069                       074803.5-425020075120.5-430544257.47-08.26 6.32  -0.17 -0.76         B2IV-V             +0.011-0.010      +014                           
+3075          BD+74  338  64307  6378 300I                  074813.8+741106080011.7+735505140.86 30.73 5.41  +1.42 +1.64         K3III              -0.009-0.037 +.022+035V?                         
+3076          CP-59  910  64320235553                       074812.6-594747074954.8-600304272.69-16.44 6.72  +1.24               K0II                0.000+0.020      +022                           
+3077          BD+56 1253  64347 26579                       074820.4+564603075626.8+563016161.19 31.18 6.72                      A2IV                0.000-0.024      +028SB                         
+3078          CD-42 3610  64365219076              QU Pup   074822.7-423752075140.3-425318257.32-08.10 6.04  -0.18 -0.84         B2IV               -0.016+0.004      +032V                         *
+3079          CD-34 4036  64379198540      W                074831.5-342714075215.7-344219250.27-03.88 5.01  +0.44 -0.06         F5V                -0.194+0.243 +.074+027V       0  3.6   3.0      *
+3080          CD-40 3579  64440219082 301                   074846.7-401904075213.0-403433255.35-06.86 3.73  +1.04 +0.78 +0.56   K1-2II+A0          -0.010+0.003 +.031+024SB1O                      *
+3081          CP-65  827  644842499782610                   074901.1-655625074941.0-661145278.52-19.08 5.79  -0.04 -0.16         B9V                +0.003-0.001      +011                           
+3082          BD+79  265  64486  63922617  W                074904.4+794511080447.1+792847134.47 29.96 5.42  -0.06 -0.14         A0pSi              -0.027-0.049 +.021+003       35  8.3   6.7      *
+3083          BD+35 1705  64491 604532613                   074909.7+354032075540.8+352446185.13 27.70 6.23  +0.28 -0.02         A3IVp:             -0.062-0.023      +022V      70                  
+3084          CD-38 3769  64503198545              QZ Pup   074906.2-383614075238.7-385147253.90-05.93 4.49  -0.19 -0.69 -0.16   B2.5V              -0.002-0.006 +.012-031SB    187                 *
+3085          CD-36 3989  64572198553                       074922.8-360614075303.5-362150251.78-04.59 5.43  +1.16               K0III              -0.005-0.005 +.035+012                           
+3086 85    GemBD+20 1946  64648 797992614                   074949.7+200853075539.9+195302201.42 22.74 5.35  -0.04 -0.06         A0V s              -0.018-0.043 +.009+011SB     65                  
+3087          BD+09 1815  64685116120                       075005.5+090743075531.4+085146212.16 18.24 5.86  +0.35 +0.02         F2IV               -0.013-0.087      +022                           
+3088          CP-54 1420  64722235579              V372 Car 075006.5-540627075229.7-542202267.62-13.54 5.70  -0.15 -0.89         B1.5IV             -0.003+0.004      +018V     147                 *
+3089          CD-49 3137  64740219106                       075014.5-492110075303.7-493647263.38-11.19 4.63  -0.23 -0.93 -0.21   B1.5Vp            v+0.002+0.016      +008      160                 *
+3090          CD-47 3396  64760219111                       075021.8-475031075318.2-480611262.06-10.42 4.24  -0.14 -1.00 -0.12   B0.5Ib             +0.004+0.001      +041      238                 *
+3091          CD-35 4002  64802198575                       075028.5-353655075411.0-355239251.48-04.14 5.49  -0.19 -0.73         B2V                -0.001-0.010      +028       81:                *
+3092          CD-34 4091  64876198579    I:                 075054.2-343500075439.9-345049250.64-03.53 6.15  +1.53 +1.86         K4III              -0.012-0.020      +047                           
+3093          BD+04 1860  64938116145                       075107.1+044503075623.9+042909216.37 16.49 6.17  +0.98 +0.74         G8III              -0.005 0.000      +017V?                         
+3094          BD+44 1693  64958 420971209                   075115.2+441440075816.6+435839175.71 30.05 6.34   1.06 +0.91         K0                 +0.038+0.006      -049                          *
+3095  1    CncBD+16 1590  64960 973991208I                  075118.8+160327075659.4+154725205.62 21.45 5.78  +1.28               K3+III             -0.028-0.042      +010V?                         
+3096          CD-30 5275  64974198591                       075116.8-303916075513.7-305503247.33-01.40 6.44                      K4III              -0.047+0.043      +054V                          
+3097          BD+09 1824  65066116162                       075150.4+085431075715.9+083829212.57 18.53 6.05  +1.00 +0.86         K0III              +0.006-0.017      -036V?                         
+3098          BD+01 1959  65123116165        6483           075207.4+012339075716.2+010737219.58 15.14 6.35  +0.50  0.00         F7V                -0.172-0.002 +.005-000           0.2   0.3      *
+3099          CD-29 5189  65183198609    I         PX Pup   075223.5-300104075622.8-301707246.92-00.86 6.33  +1.66 +1.50         M6III              +0.004-0.032      +021V                         *
+3100          CP-52 1333  65189235612                       075226.1-521906075500.5-523459266.19-12.36 6.38  -0.01 -0.20         B8III              -0.008+0.017      +007V                          
+3101          CD-43 3737  65211219157      W                075231.5-433445075546.5-435042258.53-07.93 6.02  -0.11 -0.49         B6V                -0.012+0.002      +014           0.2   0.7       
+3102 11    PupBD-22 2087  652281748522615I:                 075233.5-223647075651.5-225248240.64  3.07 4.20  +0.72 +0.42 +0.37   F7II               -0.026+0.009 +.023+014       21                 *
+3103          BD+07 1879  65241116179               3829    075243.5+072857075805.8+071249214.02 18.09 6.41  -0.04 -0.07         A0V                -0.020-0.007      +035SB2    59                 *
+3104          BD+16 1598  65257 97429    I D                075249.2+164717075831.5+163107205.06 22.08 5.99  +1.47               K0                 -0.006-0.001      -001           0.0   0.2      *
+3105          CP-56 1468  65273235615                       075248.9-570218075453.2-571811270.45-14.61 5.63  +1.30 +1.44 +0.48E  K3-4III            -0.077+0.023 +.009+026                          *
+3106          BD+59 1130  65301 26618                       075257.8+591908080120.7+590251158.24 31.91 5.77  +0.39 -0.04       d:F2                 +0.017+0.032      -040V?                         
+3107          CD-40 3655  65315219169                       075257.3-402809075624.3-404411255.89-06.26 6.78  -0.18 -0.74         B2V                +0.020-0.002      +014                           
+3108          BD+84  169  65299  13001639                   075301.7+842050081653.8+840328129.27 29.15 6.49  +0.03 +0.03         A3IV               -0.013-0.018      -003SB                         
+3109 53    CamBD+60 1105  65339 14402 302  S       AX Cam   075310.0+603552080142.4+601928156.73 31.95 6.01  +0.14 +0.06         A2pSrCrEu         v-0.037-0.020      -005SBO    14:                *
+3110 14    CMiBD+02 1833  65345116182      W                075309.5+022929075820.6+021329218.70 15.88 5.29  +0.92 +0.71         K0III              -0.158+0.099 +.027+046     < 19: 3.0  88.6AB   4 
+3111          CD-42 3717  65442219186                       075336.7-420818075657.9-422422257.39-07.02 6.09  +1.36 +1.61         K3III              +0.029+0.023      +058                           
+3112          BD+63  749  65448 144072619  W                075333.1+632154080230.8+630525153.47 31.97 6.40  +0.59 +0.35         G1III              -0.012-0.017      +020V          2.4  48.6       
+3113          CD-29 5236  654561986361210           3830    075340.9-300356075740.1-302005247.10-00.65 4.79  +0.15 +0.18 +0.15   A2V               v-0.006+0.007 +.025+028        0                 *
+3114          CD-43 3758  65460219189                       075341.1-431356075657.9-433001258.34-07.57 5.35  -0.18 -0.74         B2.5V              +0.001+0.013      +020SB    146:                 
+3115          BD+13 1811  65522 97445    I                  075400.1+133051075935.1+131432208.40 20.99 6.02  +1.32               K2                 -0.019-0.011      +027                           
+3116          CD-43 3766  655512191972616  W       Var      075404.0-435027075718.4-440635258.90-07.83 5.09  -0.17               B2.5IV             -0.008+0.009      +016        0  8.9  10.0AB   3*
+3117   Chi CarCP-52 1343  65575235635 303          Chi Car  075414.1-524250075646.7-525856266.68-12.32 3.47  -0.18 -0.67 -0.18   B3IVp              -0.029+0.021 +.004+019V      95                 *
+3118          CD-47 3457  65598219200      W                075421.6-473716075720.0-475325262.21-09.73 6.22  -0.10 -0.50         B5V                -0.020+0.014D+.007+012           0.6   0.5       
+3119          BD+57 1118  65626 26634              AE Lyn   075427.1+573302080235.8+571625160.33 32.05 6.49  +0.62 +0.16         F8V                -0.027-0.063 +.038+026SB2O   12                 *
+3120          CP-60  935  65662250019                       075437.3-601528075618.6-603135273.50-15.94 5.74  +1.55 +1.80 +0.82   K3III              -0.011+0.014      +023                          *
+3121          CD-45 3611  65685219218                       075443.1-451828075751.8-453440260.23-08.49 5.17  +1.27 +1.36         K2III              -0.006+0.020 +.009+051SB                         
+3122 27    MonBD-03 2157  65695135345 304I                  075444.4-032425075944.1-034047224.24 13.39 4.93  +1.21 +1.21 +0.46E  K2III              -0.054-0.003 +.008-029     < 19:                 
+3123 12    PupBD-22 2104  65699174932    I                  075448.3-230219075905.7-231838241.28  3.29 5.11  +1.12 +0.92        cK2                 -0.012+0.001 -.003+011                          *
+3124  2Ome1CncBD+25 1812  65714 798611211                   075452.8+254000080055.9+252334196.23 25.82 5.83  +1.02 +0.88        gG8                 +0.014+0.006      +002V                          
+3125          BD+20 1976  65735 97471                       075458.4+200525080048.0+194858201.98 23.84 6.25  +1.11               K1III              -0.001-0.013      +028                           
+3126          CP-58 1028  65750235638              V341 Car 075458.2-585122075650.7-590735272.25-15.24 6.25  +2.08 +2.29 +1.04E  M0III             e-0.024-0.019      +024                          *
+3127          BD+23 1866  65757 79864        6513           075502.4+235129080100.7+233459198.13 25.23 6.34R                     K1III-IV           -0.026-0.024D+.010+025           4.5   2.3       
+3128  3    CncBD+17 1731  65759 974722618I                  075503.4+173458080047.3+171831204.50 22.88 5.55  +1.32              gK3                 -0.012-0.002      +041                          *
+3129          CD-48 3349  65818219226      W       V Pup    075521.9-485825075814.4-491442263.48-10.28 4.41  -0.17 -0.96         B1Vp+B3IV:         -0.011+0.008      +019SB2O       5.9  39.2AD   5*
+3130          BD+35 1731  65801 60523    I                  075525.1+354120080155.1+352447185.50 28.93 6.34  +1.56               K0                 -0.043-0.007      -016                           
+3131          BD-18 2118  658101536871212                   075523.1-180729075952.0-182357237.16  6.00 4.61  +0.08 +0.08 +0.06   A2Vn               -0.002-0.039 +.021-012      198                 *
+3132  4Ome2CncBD+25 1816  65856 79869      W                075541.9+252153080143.8+250523196.62 25.89 6.31  +0.01 +0.03         A1V                -0.021+0.020      -009V     115  3.8 109.3AC   3 
+3133          CD-51 2784  65867235646               3841    075540.1-511039075821.4-512655265.43-11.36 6.44  +0.25               A8-9IV             -0.046+0.034      +010                           
+3134  5    CncBD+16 1612  65873 97485                       075548.3+164352080130.3+162719205.43 22.71 5.99  -0.02 -0.02         B9.5Vn             +0.004-0.005      -012SB    185                  
+3135          BD-02 2379  65875135368               3857    075542.4-023626080044.1-025254223.64 13.99 6.51  -0.07 -0.81 -0.05   B2.5Ve            v-0.014+0.013      +046V     148                 *
+3136          BD+05 1857  65900116244      W                075556.5+050918080113.8+045247216.58 17.74 5.65   0.00 +0.01         A1V                -0.038+0.009      +046    =< 41  6.7  30.1       
+3137          CD-44 3920  65904219240                       075551.3-445635075901.8-451258260.02-08.13 5.99  -0.14               B4V                -0.011-0.004      -003                           
+3138          CP-59  944  65907250035    I'W                075556.0-600205075746.9-601812273.38-15.69 5.60  +0.57  0.00         G0V                +0.517+0.114 +.062+014SB         4.3  60. AB   3*
+3139          CP-62  925  65908250030                       075556.1-630134075712.5-631749276.13-17.11 6.14  -0.10               B8V                -0.018+0.015      +023                          *
+3140          CD-38 3908  65925198668                       075556.5-390120075928.4-391750254.96-05.01 5.24  +0.39 +0.02         F5III              -0.082-0.043 +.038-008      125                  
+3141 28    MonBD-00 1882  659531353802620I         V645 Mon 075608.0-010654080113.3-012333222.35 14.81 4.68  +1.49 +1.78 +0.83   K4III              +0.068-0.073 +.009+027     < 19:                *
+3142          CD-49 3243  66005219249      W     A          075622.9-494212075912.3-495836264.20-10.51 6.32                      B2IV-V              0.000+0.015      +013V?         0.0  16.4      *
+3143          CD-49 3244  66006219250      W     B          075624.0-494201075913.4-495825264.20-10.51 6.34                      B2IV-V             -0.008+0.013      +023V?         0.0  16.4      *
+3144          BD+09 1843  660111162512621          Var      075624.9+091124080150.7+085450212.83 19.67 6.22  +0.57 +0.13         G0IV               -0.002+0.022      +004       12                 *
+3145          BD+02 1854  661411162602623I W                075703.7+023634080215.9+022004219.07 16.80 4.39  +1.25 +1.28 +0.67   K2III              -0.031+0.105 +.024+071V    < 19: 4.7 241.4       
+3146          CD-45 3662  66190219280                       075709.6-451053080019.6-452725260.35-08.06 6.61  +1.27               K1Ib-II            +0.008+0.001      +027                           
+3147          CP-60 1006  66194250055              V374 Car 075710.4-603302075850.5-604928273.93-15.80 5.81  -0.09 -0.80 -0.06   B2IVpne           v-0.008+0.015      +011V     250                 *
+3148          CD-48 3384  66210219283                       075720.5-484224080014.9-485853263.41-09.86 6.02  +0.04 +0.08         A2V                -0.015+0.047      +012                           
+3149   Chi GemBD+28 1532  66216 79896 305I W                075722.6+280429080331.1+274739193.90 27.14 4.94  +1.12 +1.09         K1.5III            -0.026-0.042 +.016-011SB   < 19: 6.0  78.6AC   3*
+3150          BD-05 2339  662421354061213                   075731.1-060330080226.0-062014226.95 12.67 6.33  +0.62 +0.13         G0III              +0.006-0.014 +.007-017V                          
+3151          CD-48 3388  66255219292              PY Pup   075733.9-483544080028.9-485217263.34-09.77 6.12  -0.11               A0pSi              -0.014+0.012      +028                          *
+3152          CP-59  954  66341250064                       075754.4-595554075940.2-601227273.41-15.43 6.33  -0.06 -0.40         B5III              +0.004+0.003      +023                          *
+3153          CP-60 1018  66342250063                       075755.0-601841075937.6-603513273.76-15.61 5.17  +1.74 +1.91 +1.13   M1.5IIa            +0.003+0.011 -.001+023                          *
+3154          CD-36 4116  66358198714                       075757.9-370021080137.4-371701253.46-03.60 5.95  +0.14 +0.14         A3IV               -0.017+0.008      -000                           
+3155          CD-36 4120  66435198725               3872    075825.6-364617080206.2-370302253.31-03.39 6.34  +1.62 +1.88         M1III              +0.016-0.003      +059V?                        *
+3156          CP-53 1505  664412356802622                   075822.4-535226080049.9-540905268.02-12.37 5.87  -0.14 -0.52         B5Vn               -0.023+0.008      +000V?                         
+3157          CP-54 1470  66546235686      W        3871    075857.2-541412080122.9-543054268.39-12.48 6.10  -0.04 -0.65         B2IV-V             -0.018+0.021      +034SB    164  2.0  40.2      *
+3158          BD+19 1911  66552 97537                       075858.5+190730080445.2+185032203.35 24.34 6.15R -0.05 -0.12         B9V                -0.035-0.016      +028       70                  
+3159          CP-63  866  665912500692624                   075904.2-631725080020.0-633403276.55-16.92 4.82  -0.17 -0.62 -0.20   B3V                +0.001+0.017      +022        0                 *
+3160          CD-32 4766  66598198743    I W                075909.9-321059080304.1-322750249.52-00.79 5.82  +1.22 +1.28         K2-3III            -0.017 0.000      +049           3.1  35.1       
+3161          CP-55 1419  66607235690                       075911.4-551032080131.5-552718269.24-12.92 6.28  -0.15 -0.62         B4V                -0.017-0.008      +006                           
+3162          CD-40 3776  66624219339      W       V336 Pup 075918.4-410147080244.8-411836257.01-05.53 5.52  -0.15 -0.47         B9pSi              -0.002+0.010      +026V?    104  3.2  26.1      *
+3163  8    CncBD+13 1831  66664 975422625                   075930.2+132412080504.5+130705209.11 22.16 5.12  +0.01 -0.01         A1V                -0.036-0.067 +.023+021SB    150                  
+3164          BD+27 1536  66684 79928        6569   3892    075929.3+274849080537.0+273147194.34 27.50 6.21  +0.01 -0.09         A0V                 0.000-0.009D+.007-017V?    103  0.7   3.7      *
+3165   Zet PupCD-39 3939  66811198752 306                   080004.1-394317080335.1-400012255.98-04.71 2.25  -0.26 -1.11 -0.22   O5f               e-0.027+0.012      -024V?    211                 *
+3166          CD-42 3832  66812219355                       080009.1-423958080329.5-425655258.48-06.27 6.29  +1.01 +0.76         G8II               -0.026-0.013      +014                          *
+3167 28    LynBD+43 1770  66824 421742627                   080014.3+433251080709.9+431537176.84 31.52 6.26R -0.02 -0.13         A1V                -0.010-0.034      +009SB2O   50                 *
+3168 14    PupBD-19 2228  66834153796                       080015.0-192640080441.5-194341238.90  6.28 6.13  -0.16 -0.72         B3III              +0.002+0.003      +014                           
+3169  9Mu 1CncBD+23 1887  66875 79940    I         BL Cnc   080022.9+225516080618.4+223808199.58 26.05 5.99  +1.66 +1.91 +1.01E  M3III              -0.008-0.005      +026V                         *
+3170          CD-32 4796  66888198764    I         MZ Pup   080022.3-322330080416.2-324030249.83-00.69 5.31  +1.91 +1.95         M1Ib               -0.003+0.004 +.024+036                          *
+3171          CP-72  654  66920256463                       080029.9-725756075916.1-731441285.73-21.21 6.34  +0.14 +0.13         A3III              +0.002-0.036      +024                           
+3172          BD-00 1903  66950135488                       080043.2-001717080549.6-003425222.18 16.22 6.41  +1.05 +1.01         K0                 -0.022-0.013      +034                           
+3173 27    LynBD+51 1391  67006 26687 307    6600           080056.2+514742080827.4+513024167.19 32.65 4.84  +0.05  0.00  0.00   A2V                -0.059-0.004 -.009+011V     168  7.1  45.6AB   3 
+3174          BD-08 2222  67159135505        6588           080138.4-085728080627.5-091442230.04 12.07 6.23  -0.07 -0.12         B9V                +0.001-0.012      +028V?         1.7  30.8AB   4*
+3175          BD+58 1102  67224 26701    I                  080151.5+583228081003.8+581453159.17 33.04 5.93  +1.39 +1.50        gK4                 -0.023-0.075      +034                           
+3176 10Mu 2CncBD+22 1862  67228 799592630I'                 080152.8+215220080745.8+213454200.81 25.99 5.30  +0.63 +0.21         G1IVb              +0.022-0.069 +.034-036    =< 10                  
+3177          CD-33 4525  67243198791      W                080153.2-331659080544.9-333409250.76-00.91 6.14  +1.11 +0.88         G1Ib               -0.006+0.010      +033           2.4  22.1AB   3*
+3178          CD-50 3138  672492357302626                   080154.1-501818080442.4-503526265.19-10.06 5.95  +1.21 +1.03         G5II               -0.001+0.001      +027                           
+3179          CD-46 3764  67341219400                       080215.2-464132080520.4-465844262.12-08.10 6.19  -0.15 -0.67         B3Vnp              +0.005-0.009      +024SB                         
+3180          CP-52 1376  67364235735                       080228.2-524917080504.0-530629267.42-11.30 5.53  +1.34 +1.60         K3-4III            +0.034-0.006 +.020+018                           
+3181          BD+42 1819  67370 42199                       080231.1+424325080923.1+422550177.88 31.79 6.27  +1.27              gK3                 -0.008-0.072      +038V?                         
+3182          BD+68  524  67447 144561215                   080251.8+684607081248.8+682827147.01 32.53 5.32  +1.04 +0.81 +0.48   G7+II               0.000+0.008 +.021-009V    < 19:                *
+3183          BD-20 2395  67456175206      W                080253.2-201555080718.0-203317239.93  6.36 5.38  +0.10 +0.16 +0.09   A5II               -0.016-0.006 +.001+012        0  9.2  13.8      *
+3184 12    CncBD+14 1831  67483 97594                       080307.1+135555080842.4+133827208.98 23.18 6.27  +0.43 +0.01         F3V                -0.001-0.017      -010V      40                  
+3185 15Rho PupCD-23 6828  67523175217 308I W       Rho Pup  080317.1-240057080732.6-241815243.15  4.40 2.81  +0.43 +0.19 +0.21   F6IIpDel Del      e-0.083+0.049 +.035+046SB     14 10.9  29.6      *
+3186          CP-62  953  67536250101      W       V375 Car 080317.5-623259080442.9-625010276.11-16.14 6.30  -0.10               B2.5Vn            e-0.009+0.017      +000V?    292  1.3  87.1      *
+3187          CD-44 4051  67582219422               3905    080327.7-445838080640.4-451559260.77-07.01 5.05  +1.50 +1.73         K3III               0.000 0.000 -.011+025                          *
+3188 29Zet MonBD-02 2450  67594135551    I   6617           080334.0-024133080835.6-025902224.72 15.66 4.34  +0.97 +0.69 +0.46   G2Ib               -0.017-0.005 +.003+030     < 17: 4.9  66.0AC   4*
+3189          BD-10 2400  67725153887                       080412.1-110250080856.9-112023232.20 11.53 6.32  +0.01 -0.09         A0Vn               -0.004-0.012      +020V?    160                  
+3190          BD-19 2262  67751175250      W                080418.2-200416080843.5-202147239.95  6.74 6.36  +0.16               A7IV               -0.012 0.000      +028           6.6  20.2       
+3191 14Psi CncBD+25 1865  67767 799952633  W                080425.8+254839081027.2+253026196.89 27.90 5.73  +0.81 +0.43 +0.28E  G7V                -0.075-0.348 +.029-043V          4.9 112.1AC   3*
+3192 16    PupBD-18 2190  677971538902632                   080433.7-185708080901.6-191442239.04  7.40 4.40  -0.15 -0.60 -0.14   B5IV               -0.014-0.002      +019SB?   188                  
+3193          BD+39 2065  67827 606252635                   080443.8+390143081121.6+384353182.23 31.50 6.58  +0.59 +0.09         G0                 -0.111-0.075      +026    =< 10                  
+3194          BD-15 2280  67880153898        6632           080454.0-155719080928.5-161456236.53  9.08 5.68  -0.17 -0.74         B2.5V              -0.017-0.007      +033V?         6.7   5.3      *
+3195          CD-37 4288  678881988482631          PQ Pup   080457.7-372320080837.6-374053254.54-02.63 6.37  -0.04 -0.56 +0.01   B4V               e-0.002+0.003      +030V?                        *
+3196          CD-29 5620  67921198854      W                080505.2-300145080906.7-301921248.41  1.44 6.65  +1.40 +1.60         K5III              +0.024-0.001      -025           4.2   1.1       
+3197          BD+82  235  67934  13193952                   080512.4+824427082432.9+822551130.95 29.89 6.32  +0.01 +0.01         A2Vn               -0.022-0.025      -021V?    200                  
+3198          BD+15 1775  67959 97628                       080521.8+145531081058.8+143746208.24 24.08 6.23  +0.02 +0.04         A1V                -0.028-0.014      +024    =< 41                  
+3199          CD-35 4256  67977198859                       080523.2-350942080910.2-352718252.72-01.34 6.20  +0.89               G8III              +0.003+0.014      -014                           
+3200          BD+56 1278  68077 267322640                   080552.0+564507081350.2+562708161.31 33.58 5.85  +1.01 +0.79         G9III              -0.022-0.033      +007V?                         
+3201          BD+10 1746  68099116444                       080549.4+100704081116.6+094916213.03 22.16 6.07  -0.10 -0.42         B6III              -0.009-0.021      +030V      70                 *
+3202 18    PupBD-13 2420  681461539242637  W                080601.7-133018081039.8-134757234.57 10.61 5.54  +0.49  0.00         F6V                -0.251+0.061 +.047+038           6.7  93.       *
+3203          CD-48 3516  68161219493                       080610.6-482324080909.6-484104263.92-08.45 5.70  -0.12 -0.42         B8Ib-II             0.000-0.004      +027V?                         
+3204          CD-43 3998  682172195022634          Var?     080618.0-434940080935.9-440722260.07-05.96 5.21  -0.19               B2IV-V             -0.007 0.000      +008      194                  
+3205          CD-42 3944  68242219507      W                080624.2-422044080947.7-423826258.84-05.13 6.26  -0.04 -0.32         B7V                -0.004+0.010D+.017+012V?         1.1   5.6      *
+3206   Gam1VelCD-46 3846  68243219501      W     B  3930    080624.4-470302080929.3-472045262.81-07.70 4.27  -0.23 -0.92 -0.18   B1IV               -0.004-0.005      +020SBO   119  2.3  41.2AB   5*
+3207   Gam2VelCD-46 3847  68273219504 309  W     A Gam2 Vel 080627.0-470230080932.0-472012262.80-07.69 1.78  -0.22 -0.99 -0.13   WC8+O9I           v-0.004+0.006 +.017+035SB2O       2.3  41.2AB   5*
+3208 16Zet1CncBD+18 1867  68257 97645        6650A          080628.6+175658081212.7+173852205.30 25.53 5.63  +0.54 +0.06         F8V                +0.066-0.135 +.039-006        0  0.4   0.9AB   5*
+3209 16Zet1CncBD+18 1867  68256 97645        6650B          080628.6+175658081212.7+173852205.30 25.53 6.02  +0.54 +0.06         F9V                +0.066-0.135 +.039-006           0.4   0.9AB   5*
+3210 16Zet2CncBD+18 1867  68255 97646        6650C          080629.0+175655081213.3+173852205.30 25.53 6.20  +0.60 +0.13         G5V                +0.097-0.109 +.039-011V          1.2   5.9ABxC 5*
+3211 19    PupBD-12 2385  68290153942    I   6647           080634.7-123749081116.3-125537233.89 11.19 4.72  +0.95 +0.74 +0.48   G9III-IIIb         -0.025+0.012 +.031+036V    < 17  3.0  71.0AE   5 
+3212          BD-07 2378  68312135611                       080641.0-072828081133.0-074621229.40 13.91 5.36  +0.89 +0.60 +0.45   G6III              -0.041-0.021 +.012-011V    < 19:                 
+3213          CD-47 3653  68324219515              IS Vel   080640.7-473831080943.2-475615263.33-07.98 5.23  -0.21 -0.89         B1IVe              +0.003+0.001      +005SB    188                 *
+3214          BD+14 1850  68332 97647                       080646.5+141809081222.1+140014209.01 24.14 6.54                      A7III              -0.026-0.008      -009       71                  
+3215 15    CncBD+30 1664  68351 800162641          BM Cnc   080657.0+295723081308.9+293924192.58 29.71 5.64  -0.07 -0.12         B9pSiCr            -0.009-0.018      +020SBO    27                 *
+3216          BD+76  310  68375  6487 310                   080659.2+760344081932.2+754525138.47 31.61 5.54  +0.90               G8III              +0.030+0.016      +007V                          
+3217          CP-63  896  68423250127                       080706.4-633023080824.5-634804277.20-16.24 6.28  -0.06               B6Ve               -0.017+0.002      +030V?                        *
+3218          CP-55 1467  684342357842638                   080713.8-554726080933.6-560508270.38-12.26 5.66  +0.21               A3m                -0.007+0.034      +025                           
+3219          CD-36 4291  68450198898      W                080719.9-365942081101.6-371732254.47-02.02 6.44  -0.01 -0.87         O9.5II             -0.012+0.003      +039       97  7.0  18.0AC   3*
+3220          CP-60 1074  684562501312636                   080721.1-605955080900.7-611809274.97-14.95 4.76  +0.43 -0.03 +0.25   F5V                -0.158-0.297 +.055+025        0                  
+3221          BD+60 1119  68457 14479        6680           080724.8+604058081550.5+602250156.59 33.69 6.45  +0.20 +0.11         A7Vm               -0.013+0.007      -016           4.1  48.6AC   4*
+3222          BD+16 1662  68461 97653      D                080718.7+164851081259.8+163051206.54 25.27 6.01  +0.89               G8III              -0.009-0.019      -020SB                        *
+3223   Eps VolCP-68  736  68520250128      W                080736.4-681924080755.8-683702281.62-18.56 4.35  -0.11 -0.46 -0.09   B6IV               -0.026+0.025      +010SBO    38  3.6   6.0      *
+3224          BD+23 1913  68543 80024                       080746.2+232619081341.7+230816199.70 27.82 6.56  +0.11 +0.12         A4IVn              -0.036-0.010      -002                           
+3225          CD-39 4084  68553198908              NS Pup   080747.1-391913081121.5-393707256.45-03.24 4.45  +1.62 +1.86 +0.90   K3Ib                0.000-0.004 -.006+016SB                        *
+3226          CD-42 3979  68601219569      W                080803.1-424119081125.9-425914259.29-05.06 4.75  +0.18 +0.08 +0.22   A5Ib               +0.004+0.004 +.004+019        0  4.8  25.7       
+3227          CD-48 3576  68657219565                       080810.3-480948081111.1-482743263.91-08.05 5.82  -0.15 -0.63         B3V                +0.015-0.004      +015                           
+3228          BD+18 1882  68703 97669        6673           080827.7+175839081411.1+174033205.47 25.98 6.47  +0.30 +0.14 +0.13   A0VnDel Del        -0.005+0.011      -003       67  3.0  63.0AC   3 
+3229 20    PupBD-15 2324  68752153993 311I                  080844.1-152912081320.0-154718236.63 10.11 4.99  +1.07 +0.78 +0.38E  G5II               -0.013-0.004 +.030+017V?                         
+3230          CD-29 5738  68758175390                       080843.1-293639081246.0-295439248.50  2.33 6.52  +0.06 +0.07         A1V                -0.024+0.031      +028V?                         
+3231          BD+13 1868  68776 97671      W                080847.4+132104081421.0+130254210.19 24.19 6.38                      G8III              -0.021-0.018      +025SB         5.6  22.8       
+3232          CD-46 3902  68808219587              AH Vel   080851.2-462040081200.0-463839262.44-06.96 5.76  +0.59 +0.39         F7Ib-II            -0.001+0.008      +026SB?                       *
+3233          CD-37 4394  68862198942                       080911.3-373723081251.5-375528255.20-02.07 6.43  +0.10 +0.08         A3V                -0.011-0.002      +027                          *
+3234          CD-45 3892  68895219602      W                080920.4-455748081230.9-461551262.17-06.68 6.03  -0.11 -0.57         B5V                +0.008+0.012      +013           0.8   0.4       
+3235 29    LynBD+60 1124  68930 267562645                   080932.0+595240081750.4+593416157.54 33.99 5.64  +0.16 +0.13         A7IV               -0.006+0.003      -015V      96                  
+3236          BD+72  409  68951  6504    I   6724           080939.3+724303082040.3+722426142.29 32.46 5.98  +1.54 +1.46         M0III              +0.004-0.025      +012           3.7  42.9AB   3*
+3237          CD-35 4349  68980198957              MX Pup   080942.9-353550081329.6-355359253.58-00.84 4.78  -0.11 -0.98 -0.08   B1.5IIIe          v+0.002-0.002      +035SB2   156                 *
+3238          CD-33 4705  69002198960      W                080947.4-331601081341.1-333409251.66  0.48 6.37  +1.14               K2III              +0.033+0.019      +026           6.7   6.3       
+3239          CD-31 5742  690801989722644  W                081013.7-315014081411.0-320827250.52  1.35 6.06  -0.16 -0.74         B1.5V              -0.002+0.006      -049SB2   208  7.0  29.6       
+3240          CD-35 4358  69081198969      W       OS Pup   081012.9-360109081358.4-361921253.98-01.00 5.08  -0.19 -0.86         B1.5IV             +0.010-0.002      +018      213  0.9  66.9      *
+3241          CD-35 4360  69082198970                       081013.3-360215081358.8-362028254.00-01.01 6.11  -0.18 -0.71         B2IV-V             +0.010-0.008      +014SB2                       *
+3242          CD-35 4365  69123198979                       081025.7-351112081413.2-352926253.32-00.49 5.78  +1.02 +0.87         K1III              -0.055+0.008      +027                           
+3243          CD-39 4128  69142219635      W                081029.8-400232081402.9-402053257.35-03.21 4.44  +1.17 +1.09 +0.64   K1II-III           +0.047-0.068 +.010+014SB1O       5.1  51.1      *
+3244          CD-46 3929  69144219629      W       Var      081028.4-464118081336.2-465931262.88-06.92 5.13  -0.14 -0.63         B2.5IV             +0.003-0.004      +025SB     57  3.9  35.       *
+3245          BD+62  991  69148 14500              Var      081035.1+624858081917.3+623026154.00 33.93 5.71  +0.89               G8III              -0.013+0.007      -002SB                        *
+3246          BD+54 1215  69149 26760    I                  081033.8+542710081815.8+540837164.09 34.22 6.27  +1.54 +1.90         K5                 -0.024-0.038      +025                           
+3247          CD-49 3430  69194235819               3957    081040.4-495333081334.1-501146265.60-08.65 5.51  +1.61 +2.00 +0.47   M1III              +0.009-0.004 +.007-007                          *
+3248          BD+12 1803  69243 97694    I         R Cnc    081103.0+120201081633.9+114335211.75 24.14 7.13  +1.56 +0.40 +2.98   M7IIIe             +0.012-0.010 +.021+032V?                        *
+3249 17Bet CncBD+09 1917  69267116569 312I   6704   3973    081105.5+092938081630.9+091108214.25 23.05 3.52  +1.48 +1.77 +0.78   K4IIIBa0.5         -0.044-0.049 +.012+022V?   < 17  9.4  29.2      *
+3250          CD-45 3914  69302219657      W                081111.1-453147081423.9-455004261.98-06.17 5.83  -0.20 -0.79         B2IV-V             -0.004+0.008      +020           1.5   0.4AB   3 
+3251          CD-30 5946  69445199010      W                081151.9-303706081552.5-305533249.71  2.33 6.21  +0.78 +0.35         G5-8III+G:         -0.047-0.005D+.009+006V          1.9   2.2AB   3 
+3252          BD+09 1921  69478116585                       081206.7+091032081731.7+085158214.68 23.13 6.29  +0.98 +0.75         G8III              -0.012-0.013      +029                           
+3253          CD-35 4401  69511199015                       081211.7-353545081558.9-355410253.86-00.43 6.16  +1.55 +1.70         K2III              +0.005+0.015      +030                           
+3254 30    LynBD+58 1112  69548 26784                       081221.6+580318082026.1+574436159.73 34.43 5.89  +0.39 -0.10         F4V                +0.061+0.014      -015V                          
+3255          BD-20 2467  69589175497                       081230.0-210044081654.2-211913241.80  7.83 6.60  +0.02               A0                 -0.016+0.026      +010                           
+3256          CD-50 3227  69596235838                       081230.3-500830081523.3-502658265.98-08.55 6.44  +1.49 +1.87         K3-4III            -0.012-0.020      +010                           
+3257 21    PupBD-15 2362  69665154076               3986    081248.0-155831081723.1-161706237.58 10.66 6.16  +0.01 +0.08         A2V                -0.020-0.008      +000                           
+3258          BD+54 1217  69682 26788                       081251.8+535323082029.1+533428164.78 34.55 6.49  +0.28?              F0IV               -0.065-0.092      +011       34                  
+3259          BD-12 2449  69830154093                       081339.1-121736081823.9-123755234.55 12.83 5.98  +0.76 +0.33 +0.38   G7.5V              +0.267-0.979 +.082+030V                          
+3260          CP-62  985  69863250164      W                081345.0-623625081515.9-625457276.80-15.13 5.16  +0.09 +0.10         A2V                -0.023-0.022 +.031+004      199: 2.6   3.9      *
+3261          CD-29 5897  69879175543                       081354.2-294133081758.3-300012249.20  3.22 6.45  +1.04               K0III              +0.041+0.014      -012                           
+3262 18Chi CncBD+27 1589  69897 801041217                   081359.4+273230082003.9+271304195.78 30.47 5.14  +0.47 -0.06         F6V                -0.018-0.378 +.061+033        0                  
+3263          BD+61 1043  69976 14522                       081419.9+605652082244.1+603752156.20 34.52 6.41R +0.97?              K0III              +0.008-0.002 +.015-006                           
+3264          BD+21 1817  69994 801122646                   081431.0+210348082021.0+204452202.85 28.45 5.83  +1.13 +1.06         K1III              +0.060-0.047      -017V                          
+3265          BD-09 2471  699971541051218          HQ Hya   081427.5-095113081915.1-100957232.52 14.30 6.32  +0.33 +0.17         F3IIIpDel Del      -0.041+0.038      +032                          *
+3266          CD-35 4452  70002199061                       081428.3-350822081817.4-352706253.75  0.21 5.58  +1.24               K2III              +0.018+0.002      -009                           
+3267          CD-36 4443  70003199059      W                081429.5-370346081812.6-372227255.33-00.88 6.70  +0.23 -0.03         A0IV+G:            -0.022+0.019D+.009+017SB2        0.8   1.9      *
+3268 19Lam CncBD+24 1909  70011 80113                       081435.4+242014082032.1+240120199.33 29.59 5.98R -0.03 -0.12         B9.5V              -0.023-0.021      +023SB     82                  
+3269          BD+04 1954  70013116630      W                081434.4+041545081949.9+035652219.71 21.43 6.05  +0.97 +0.64         G8III              +0.034-0.030      -047           0.0   0.2       
+3270          CD-36 4449  70060199070 313                   081448.7-362057081833.3-363934254.78-00.42 4.45  +0.22 +0.11 +0.13   A7III              -0.106+0.097 +.057+005      129                  
+3271          BD-00 1966  70110135783                       081506.8-003532082013.1-005434224.31 19.20 6.18  +0.60 +0.15         F9V                +0.056-0.094      +010V?  =< 10                  
+3272          BD-04 2303  70148135787                       081519.5-050048082017.1-051945228.35 17.02 6.13  +1.33 +1.52         K2III              +0.024-0.027      -037                           
+3273          CD-34 4627  70235199084                       081537.8-341633081929.4-343525253.18  0.90 6.43  -0.08 -0.37         B9pHgMn            -0.018 0.000      +012                          *
+3274          CP-58 1095  70267235872      W                081552.9-585110081755.8-591001273.67-12.91 6.42  +0.39  0.00         F5V                -0.044-0.032      -002           3.3  43.8AB   3 
+3275 31    LynBD+43 1815  70272 42319 314I          4030    081559.4+433032082250.1+431117177.39 34.34 4.25  +1.55 +1.90 +0.88   K4.5III-IIIb      e-0.021-0.096 +.023+024     < 19:                *
+3276          BD-22 2233  70302175634      W                081606.3-223632082027.4-225529243.61  7.63 6.13  +1.04               K0                 -0.011+0.001      +026V          7.0   6.7       
+3277          BD+53 1246  70313 268192649                   081614.2+533231082348.5+531311165.21 35.05 5.51  +0.11 +0.08         A3V                -0.026-0.095 +.030+021                           
+3278          BD-01 2017  70340135804        6762           081615.7-011703082120.2-013608225.10 19.11 6.50  +0.02 -0.02         A2Vpn:EuSrCr:Si    -0.017-0.041D+.009+029           0.7   0.5      *
+3279          BD-19 2369  704421541502647                   081653.6-194539082121.2-200445241.33  9.38 5.58  +0.77 +0.50 +0.45   G2III+A3           -0.001-0.013      -008SB  =< 50                 *
+3280          CP-65  907  70514250186                       081712.5-651756081818.9-653648279.39-16.22 5.07  +1.15 +1.19 +0.58   K1III              +0.027+0.020 +.013+000                           
+3281          BD-17 2464  70523154159                       081722.3-171602082154.6-173511239.29 10.87 5.75  +1.05 +0.98         K1III              -0.096-0.014      +069                          *
+3282          CD-32 5185  705551991181219I                  081726.7-324410082123.0-330316252.13  2.10 4.83  +1.45 +1.60 +0.75   K2.5II-III         -0.008+0.004 +.030+033                           
+3283          CD-36 4513  70556199119      W                081734.3-360958082121.0-362904254.95  0.14 5.20  -0.19 -0.82         B2IV-V             -0.005-0.003      +016SB     71  6.8   6.8      *
+3284 20    CncBD+18 1930  70569 977811220                   081738.3+183912082321.8+181956205.70 28.25 5.95  +0.17 +0.13         A9V                -0.054-0.028 +.011+036                           
+3285          BD-05 2512  705741358322650                   081734.7-055135082230.2-061045229.41 17.06 6.15  +0.22 +0.13         A8IV               -0.062+0.003      +018      125                  
+3286          CD-39 4245  706121991232648                   081747.0-391808082124.2-393715257.54-01.64 6.16  +0.17               A3V                +0.011+0.002      -012V?                         
+3287          BD+42 1859  70647 42342    I W                081756.6+421937082442.8+420018178.86 34.54 6.02  +1.59 +1.94         K5III              +0.015+0.007      +027           2.5  79.2       
+3288          BD-07 2452  70652135840    I                  081800.9-071323082254.0-073236230.69 16.44 5.96  +1.67 +1.85         M1III              -0.023+0.002      +050                           
+3289 22    PupBD-12 2490  70673154177               4046    081804.8-124400082246.8-130317235.52 13.50 6.11  +1.00 +0.89        gG7                 -0.051-0.043      -017                           
+3290 21    CncBD+11 1830  70734 97788    I   6787           081827.0+105716082355.2+103755213.68 25.32 6.08  +1.49 +1.54         M2III              +0.004-0.023      +003           3.3   1.0       
+3291          CD-25 5988  70761175709        6782           081836.3-260139082249.9-262053246.77  6.16 5.90  +0.37 +0.27?        F3Ib               -0.007+0.008 -.009+065           0.1   0.1AB   3*
+3292          BD+35 1819  70771 607942652                   081840.9+352005082504.9+350041187.20 33.45 6.06  +1.27               K0                 -0.012-0.012      +033                           
+3293          CP-57 1490  70839235917              Var?     081858.6-573914082112.0-575823272.87-11.91 5.97  -0.09 -0.80         B1.5III            -0.007+0.009      +020V     178                 *
+3294          CD-48 3734  70930219848      W       Var?     081927.0-481009082231.6-482925264.98-06.50 4.82  -0.15 -0.84 -0.13   B1V                -0.013+0.008      +027V     169  1.0   0.8       
+3295          BD-04 2328  70937135882                       081937.6-042331082436.4-044301228.37 18.25 6.01  +0.46 +0.04         F2V                +0.022-0.051      -035SB                         
+3296          CD-37 4638  70946199166               4056    081935.1-375749082317.2-381709256.65-00.57 6.32  +1.63 +1.86         M1III              +0.028-0.003      -009                          *
+3297  1    HyaBD-03 2333  70958135877                       081935.9-032537082435.0-034504227.50 18.74 5.61  +0.46 -0.06         F3V                -0.210-0.024 +.057+072SBO    35                 *
+3298          CP-63  940  70982250202                       081944.0-634706082107.7-640622278.20-15.19 6.12  +0.93               G6-8III            -0.004-0.025      -003                           
+3299 25    CncBD+17 1842  71030 97806                       082010.2+172233082549.9+170246207.30 28.32 6.14  +0.41 -0.03         F6V                -0.192-0.151 +.035+038                           
+3300          CD-51 2980  71043235933                       082007.3-514807082255.2-520726268.05-08.49 5.85  +0.01               A0V                -0.010+0.008      +003                           
+3301   Kap1VolCP-71  677  71046256497      W     A          082006.5-711147081949.0-713054284.83-19.05 5.37  -0.06 -0.31         B9III-IV           -0.013+0.030      +036SB2    50  0.3  65.0AB   3*
+3302   Kap2VolCP-71  678  71066256499      W     B Var?     082017.7-711112082000.7-713019284.82-19.03 5.65  -0.10 -0.31         A0IVMn             -0.008+0.044      -006           0.3  65.0AB   3*
+3303          BD+67  545  71088 145682662                   082020.3+673735082946.2+671751148.07 34.30 5.88  +0.97               G8III              -0.066+0.010      -003                           
+3304 22Phi1CncBD+28 1602  71093 801812656I W                082022.8+281323082627.7+275337195.50 32.02 5.57  +1.40 +1.68         K5III              -0.033-0.114      +024V          4.3 130.6       
+3305          BD+02 1965  710951167472654I                  082024.0+022540082535.5+020608222.19 21.83 5.73  +1.53 +1.86         K5III              -0.020-0.006      +012V?                         
+3306          BD+08 2053  711151167522655    6805           082032.9+075326082554.8+073352216.96 24.43 5.13  +0.94 +0.64 -0.06   G7II-IIIFe-1       -0.034-0.012 +.016+015V    < 19: 5.2  30.4       
+3307   Eps CarCP-59 1032  71129235932 315           4058    082027.7-591115082230.8-593035274.29-12.60 1.86  +1.28 +0.19 +0.89   K3III+B2:V         -0.026+0.014      +002                          *
+3308          BD-22 2262  71141175777                       082034.1-224947082455.1-230913244.38  8.36 5.68  +0.06               A2                 -0.041+0.042      +026V?                         
+3309          BD+46 1398  71148 423692660                   082038.4+455925082736.8+453911174.49 35.42 6.32  +0.62 +0.12         G5V                -0.017-0.350 +.046-034V   =< 10                 *
+3310 23Phi2CncBD+27 1612  71150 80187        6815B  4078    082044.1+271540082646.8+265604196.61 31.82 6.32H +0.18 +0.09         A6V                -0.014+0.002D+.010-025V?    126  0.1   5.2      *
+3311 23Phi2CncBD+27 1612  71151 80188        6815A  4078    082044.4+271544082647.0+265607196.61 31.82 6.30H +0.18 +0.09         A3V                -0.016-0.003D+.010-029V?    135  0.1   5.2      *
+3312 24    CncBD+25 1920  71152 80184        6811A  4076    082042.9+245147082639.8+243203199.28 31.08 7.02  +0.32 +0.07         F0III              -0.041-0.080D+.021+015           0.6   5.7AB   3*
+3313 24    CncBD+25 1920  71153 80185        6811B  4076    082043.2+245151082640.1+243207199.28 31.08 7.81  +0.52 -0.04         F7V                -0.045-0.085D+.021+019           0.6   5.7AB   3*
+3314          BD-03 2339  71155135896 316                   082039.8-033448082539.6-035423227.78 18.89 3.90  -0.02 -0.02 -0.05   A0V                -0.066-0.023 +.026+010V     125                  
+3315          CD-23 7277  711761757831221I   6800A          082044.6-234318082503.7-240246245.15  7.88 5.28  +1.48 +1.83         K5III+K1III        -0.028+0.026 +.031+026SB         3.5  41.0      *
+3316          BD-20 2522  71196175792                       082053.3-204319082519.1-210245242.67  9.62 6.01  +0.40               F3V                -0.019+0.061      -002                           
+3317          BD-16 2442  71231154240                       082105.7-170648082539.4-172622239.67 11.69 6.44                      K0                 -0.007-0.005      -013V                          
+3318   Alp ChaCP-76  507  71243256496                       082106.7-763613081831.6-765511289.86-21.68 4.07  +0.39 -0.02 +0.23   F5III              +0.110+0.108 +.053-014       36                  
+3319 27    CncBD+13 1912  71250 978192658I         BP Cnc   082112.1+125905082643.9+123916211.95 26.79 5.50  +1.60 +1.92 +1.41   M3III              -0.020-0.104 +.030-007V                         *
+3320          BD-14 2517  712671542442657                   082116.8-143615082555.6-145547237.56 13.13 5.98  +0.17 +0.13 +0.06   A5m                -0.010+0.040      +009       30                  
+3321  2    HyaBD-03 2345  71297135916      W       LM Hya   082127.4-033931082627.2-035915227.96 19.02 5.59  +0.22 +0.09         A5III-IV           -0.053-0.061 +.028+027       22  3.8  72.8      *
+3322          CD-42 4219  71302219890      W                082129.6-422639082457.2-424610260.50-02.89 5.98  -0.17 -0.69         B3V                -0.011+0.019      +023           0.4   0.4       
+3323  1Omi UMaBD+61 1054  71369 14573 317I   6830   4093    082157.5+610309083015.9+604305155.97 35.43 3.36  +0.84 +0.52 +0.42   G5III              -0.133-0.107 +.009+020       17  7.1 143.0AC   4*
+3324          BD-12 2524  71377154257    I          4085    082158.9-121221082641.9-123204235.59 14.59 5.54  +1.19 +1.14         K2III             v-0.091-0.018      +061V                         *
+3325          BD-05 2530  71433135931                       082221.9-060447082717.2-062435230.26 17.96 6.59  +0.51 +0.06         F4III              -0.040-0.030      +007V      12                 *
+3326          CD-41 4119  71459219910                       082221.9-414933082551.9-420912260.10-02.40 5.47  -0.15 -0.63         B3V                -0.009+0.003      +028       24                 *
+3327          CD-38 4462  71487199222      W     A NO Pup   082237.5-384351082617.6-390334257.62-00.54 6.53  -0.09 -0.36         B9V                -0.017-0.008D+.005+028           0.6   8.0AxBC 3*
+3328          CD-38 4462  71488199224      W     B          082238.0-384356082618.2-390337257.62-00.54 7.25  +0.08 +0.06         A2V:               -0.011+0.006D+.005+019V?         0.6   8.0AxBC 3*
+3329 28    CncBD+24 1931  71496 80204              CX Cnc   082241.0+242837082836.8+240841199.88 31.38 6.10  +0.24 +0.15         F0Vn               -0.031-0.058      +009SB    130                 *
+3330          CD-51 3004  71510235962      W                082238.4-512401082531.0-514341267.94-07.93 5.17  -0.16               B2Ve               -0.041-0.012      +018      158  4.2  25.7      *
+3331          CD-28 6048  71523175851                       082243.4-285313082650.8-291255249.65  5.25 6.73  -0.05               B9.5V              -0.005+0.017      +037V                          
+3332          BD+69  472  71553 14582                       082300.2+693920083253.4+691912145.61 34.14 6.31  +1.35               K0                 +0.030-0.027      -030                           
+3333 29    CncBD+14 1899  71555 978431222  D                082302.5+143231082837.3+141239210.56 27.83 5.95  +0.19 +0.14         A5V                -0.014-0.011      +002SB    120  0.5   0.2 O   3*
+3334   Eta VolCP-72  694  715762565052653  W                082258.5-730435082204.4-732400286.66-19.82 5.29  +0.01 -0.01         A0-1IV-V           -0.034+0.031 +.010+020           6.3  42.4AC   3 
+3335          BD-20 2538  71581175870      W       VV Pyx   082306.5-203049082733.3-205038242.80 10.16 6.56  +0.04               A2V                +0.010-0.008      +001SB2        1.1   0.3      *
+3336          CD-31 6079  71622199246                       082315.2-312034082716.4-314023251.71  3.91 6.33  +0.90               G8III              -0.016-0.011      -001SB2                       *
+3337          BD-02 2581  71663135958        6828  LO Hya   082326.3-021108082829.2-023102226.88 20.20 6.39  +0.33 +0.08         A5m                -0.005-0.016D+.015-014SBO        0.1   0.4AB   5*
+3338          BD-08 2374  71665135956                       082328.7-082903082819.7-084858232.55 16.91 6.43  +1.20 +1.23         K0                 -0.001-0.040      +011V                          
+3339          CD-25 6109  71688175883                       082338.9-254806082753.5-260757247.24  7.22 6.62  +0.11               A2IV-V             -0.055-0.002      +026V?                         
+3340   The ChaCP-77  383  71701256503 318  W                082338.7-770943082038.5-772904290.46-21.84 4.35  +1.16 +1.20 +0.57   K2IIICN0.5         -0.134+0.042 +.036+022           7.7  31.        
+3341          CP-52 1474  717222359762661                   082339.4-522841082625.2-524827268.92-08.43 6.05  +0.06               A0V                -0.037-0.003      +030                           
+3342          BD-09 2532  71766135965                       082401.8-092459082850.9-094454233.45 16.53 6.00  +0.42 +0.20         F2III              -0.012+0.008      +003                           
+3343          CD-34 4842  71801199260      W        4092    082407.2-344657082759.3-350650254.60  2.03 5.75  -0.15 -0.70         B3V                -0.023+0.002      +025SB    158  0.0   0.1AP   3*
+3344          BD-22 2286  71815175902                       082414.2-224420082835.9-230418244.80  9.10 6.51  +0.05 +0.08         A2                 -0.043-0.022      +054                           
+3345          BD-20 2549  71833175912      W                082426.8-203703082853.3-205701243.07 10.36 6.67  -0.06 -0.41         B8III              -0.012-0.008      +007           5.8  18.9      *
+3346          CP-64  878  71863250226                       082429.6-641617082551.6-643603278.92-15.01 5.97  +0.96 +0.73         G8-K0III           -0.012+0.007      +019V                          
+3347   Bet VolCP-65  933  71878250228 319           4088    082439.0-654810082544.2-660813280.26-15.84 3.77  +1.13 +1.14 +0.56   K1III              -0.036-0.155 +.042+027                           
+3348          BD+37 1870  71906 60866                       082451.0+373604083119.9+371557184.80 35.11 6.18  -0.03 -0.15         A0V                -0.016+0.001      +016V      56                  
+3349          CP-54 1647  71919236001      W                082452.7-544048082727.4-550042270.85-09.55 6.53  -0.02               A0V                -0.018-0.010      +020           0.0   0.2       
+3350          CP-52 1484  71935236002              GU Vel   082452.0-524527082736.5-530519269.26-08.44 5.09  +0.25 +0.14         A9-F0III-IV        -0.068+0.013 +.021+025      122                 *
+3351          BD+53 1259  71952 26896                       082503.3+532713083233.5+530653165.30 36.36 6.24  +1.01 +0.83 +0.51   K0IV               +0.013-0.077      +044V                         *
+3352          BD+75  342  71973  6592        6872   4133    082510.4+750354083648.7+744325139.27 32.95 6.31                      A2m                -0.017-0.023      -006SBO    20  3.5   1.8      *
+3353          CD-26 6103  71997175939               4104    082515.1-265954082927.6-271957248.44  6.81 6.70  -0.13 -0.55         B4V                 0.000-0.008      +006V                          
+3354  2    UMaBD+65  638  72037 14590                       082539.1+652910083436.2+650842150.52 35.21 5.47  +0.18 +0.10 +0.04   A2m                -0.049-0.063 +.017-016       17                  
+3355 30Ups1CncBD+24 1940  72041 802292666                   082535.7+242507083130.5+240452200.19 31.98 5.75  +0.28 +0.05         F0IIIn             -0.082-0.044      +019V      97                  
+3356          CD-43 4337  720672199822665  W        4106    082543.5-434936082907.6-440938262.08-03.08 5.79  -0.16 -0.75 -0.15   B2Vn              t-0.003+0.004      +003V?         0.1   0.2      *
+3357 31The CncBD+18 1963  72094 978812667I W        4117    082553.6+182557083135.7+180540206.77 29.98 5.35  +1.56 +1.93         K5III              -0.061-0.058      +045V?         0.0   0.3 O   3*
+3358          CD-47 4004  72108219985      W                082555.2-473542082904.7-475545265.14-05.28 5.33  -0.14 -0.79         B2IV               -0.011-0.001      +029SB     66  0.0   0.2AP   4*
+3359          CD-44 4462  72127219996      W                082605.3-442325082927.6-444330262.57-03.36 4.99  -0.16 -0.79 -0.17   B2IV               +0.004-0.003D+.000+022SB    163  1.7   4.6      *
+3360          BD+38 1920  72184 60890 320                   082625.0+382134083255.0+380059183.95 35.54 5.90  +1.11 +1.17         K2III              -0.103-0.169 +.011+015V                         *
+3361          BD+10 1816  72208116863                       082628.5+100907083154.6+094852215.44 26.74 6.83  -0.07 -0.17         B9p:Hg:            +0.003-0.007      +008SB                         
+3362          CD-31 6165  72227199308    I R        4113    082627.9-314924083028.6-320934252.51  4.18 5.65  +1.49 +1.78         K2III              -0.016-0.005      +019           0.0   0.1      *
+3363          CD-45 4183  72232220007                       082629.6-455948082945.6-461955263.91-04.26 5.99  -0.15               B5III              -0.029+0.002      +012                           
+3364          CD-36 4715  72268199310               4115    082641.4-362306083029.6-364316256.21  1.50 6.69  +1.95 +2.09         M2Iab              -0.019+0.012      +025V                         *
+3365 32    LynBD+36 1836  72291 60896                       082656.9+364632083321.8+362611185.89 35.37 6.24  +0.36 -0.08         F5Vb vw            -0.143+0.001 +.032+000V      20:                 
+3366 33Eta CncBD+20 2109  72292 80243 321I                  082655.5+204652083242.5+202628204.33 31.06 5.33  +1.25 +1.39 +0.61   K3III              -0.047-0.043 +.013+024                           
+3367          BD-19 2438  72310154359        6862           082701.3-191422083130.9-193439242.27 11.65 5.42  -0.06               A0V                -0.033-0.007 +.003+012V?     61  0.6   0.2      *
+3368          CP-54 1667  72322236032      W                082701.5-545117082936.3-551128271.17-09.40 6.36  +0.80               G0V                -0.015-0.015      -012V          5.9   2.4       
+3369 32Ups2CncBD+24 1946  72324 80245                       082705.4+242530083300.1+240505200.31 32.31 6.36  +1.02 +0.88 +0.50   G9III              -0.068-0.047 +.027+075                          *
+3370          CP-69  919  72337250235                       082702.6-694540082716.9-700536283.86-17.80 5.53  -0.03 -0.04         A0V                -0.008+0.048      +013V?                         
+3371          CD-44 4477  72350220025      W                082716.7-442401083039.2-444414262.71-03.19 6.30  -0.02 -0.49 -0.06   B4IV               -0.013+0.011      +024V?         4.5   3.2      *
+3372 34    CncBD+10 1818  72359 97902                       082713.3+102418083239.9+100358215.27 27.02 6.46  -0.02 -0.04         A1V                +0.003-0.005      -011SB     20                  
+3373          CD-38 4566  72436199329      W                082743.0-384334083124.6-390351258.20  0.26 6.31  -0.15 -0.56         B4V                -0.017+0.004      +011SB         1.8   3.8AB   3 
+3374          BD-14 2564  72462154373      W                082754.4-144129083233.3-150146238.56 14.41 6.38  +0.27 +0.09         F0Vn               -0.050+0.052      +023V          2.1   0.3       
+3375          CD-47 4048  72485220039                       082800.1-473143083110.8-475200265.30-04.96 6.39  -0.15 -0.65         B2.5V              +0.001+0.002      +011                           
+3376          BD+13 1940  72505 97913      D                082812.6+133558083345.1+131526212.12 28.59 6.28  +1.17 +1.23         K0III              -0.029-0.045      +028           0.0   0.1       
+3377 33    LynBD+36 1840  72524 60907                       082818.4+364546083443.8+362510185.96 35.64 5.78  +0.04 +0.02         A2Vnn              -0.031-0.044      +025                           
+3378          BD+05 1997  72561116890                       082827.1+050554083343.5+044524220.68 24.88 5.87  +1.07 +0.87         G5III              -0.005-0.013      +001V?                         
+3379          BD+74  370  72582  6605 322                   082835.7+735846083942.6+733747140.44 33.48 6.15  +1.02               G7III              -0.015-0.099 +.015+016V                          
+3380          BD+08 2077  72617116894      W                082850.0+084741083413.3+082707217.09 26.66 6.03  +0.33 +0.04         F3IV               -0.003-0.031      +011       67  7.6  31.2       
+3381          CD-24 7089  72626176061        6871           082845.5-241555083304.8-243623246.67  9.05 6.19  +0.27               A8IV               -0.007-0.016 +.016-008V?         0.2   0.5AB   3*
+3382          CP-53 1729  72650236055                       082849.0-540312083129.6-542339270.67-08.72 6.34  +1.31 +1.40         K3III              +0.020-0.047      -007                           
+3383          BD-01 2074  726601360442669                   082858.1-014837083401.6-020906227.29 21.58 5.81   0.00  0.00         A1V                -0.032+0.020      +004    =< 41                  
+3384          CD-31 6229  72673199352                       082857.2-311052083251.5-313003252.29  4.98 6.38  +0.79 +0.34 +0.28E  K0V                -1.110+0.765 +.086+016V                          
+3385          CD-34 4959  72688199353              VX Pyx   082903.8-341735083258.6-343802254.82  3.14 6.36  +0.95               K0V                -0.010+0.004      +006V                         *
+3386          CP-52 1517  72737236062      W                082918.3-525219083204.8-531244269.75-07.97 5.69  +0.58               K0III+A3           -0.021+0.007      +019           1.0   0.8      *
+3387 35    CncBD+20 2118  72779 97928                       082934.5+195603083519.4+193524205.51 31.34 6.58  +0.68 +0.25 +0.37   G0III              -0.036-0.010      +036V      91                 *
+3388          CD-37 4850  72787199363              Var?     082935.6-380145083319.9-382216257.87  0.98 6.49  -0.18 -0.65         B2.5V               0.000-0.007      +010                          *
+3389          CD-38 4610  72832199370               4137    082955.6-383024083338.3-385056258.29  0.74 5.96  -0.14               B5III              -0.034+0.006      +028                          *
+3390          CD-46 4300  72900220103                       083015.1-463741083330.4-465816264.81-04.11 6.24  +1.56               K3III              +0.011-0.009      +023                           
+3391  3Pi 1UMaBD+65  643  72905 14609                       083019.1+652200083911.7+650115150.55 35.70 5.64  +0.62 +0.07 +0.33   G1.5Vb             -0.024+0.088 +.073-012V?      4                 *
+3392          BD+03 2014  72908116920                       083012.3+030516083524.9+024437222.85 24.30 6.33  +1.02 +0.87         G9III              -0.006+0.007      -004                           
+3393          CP-80  258  729222584962664                   083015.6-803511082419.8-805451293.85-23.26 5.69  +1.02 +0.74         G8III              -0.149+0.216      +027V?                         
+3394          BD+15 1851  72943 97950                       083031.2+153935083607.7+151849210.22 29.94 6.32                      F0IV               +0.008-0.024      +004       65                  
+3395          BD+07 1997  72945116929        6886A          083032.0+065808083551.0+063712219.12 26.20 5.99  +0.52 +0.04         F8V                -0.128-0.143 +.052+025SBO        1.2  10.3AB   5*
+3396          BD+07 1997  72946116931        6886B          083032.3+065818083551.3+063721219.12 26.21 7.25  +0.71 +0.27         G5V                -0.128-0.143 +.052+027V          1.2  10.3AB   5*
+3397          CD-32 5465  72954199388      W                083031.5-321504083431.7-323555253.37  4.61 6.43  +0.75 +0.23?        G5IV-V             -0.044-0.133      +008           0.0   0.2      *
+3398  3    HyaBD-07 2540  729681360762672          HV Hya   083035.4-073817083528.2-075856232.80 18.85 5.72  -0.03 -0.01         A1pSrCrEu         v-0.020+0.013      +024SB?    16                 *
+3399          CD-37 4873  72993199389      W        4143    083042.4-371603083429.3-373641257.39  1.61 6.30  +1.56 +1.74         K5III              -0.007+0.001      +023           2.3   1.9      *
+3400          BD+53 1268  73017 26935                       083054.3+534459083822.2+532405164.89 37.21 5.66  +0.96               G8IV               -0.078-0.017      -043V                          
+3401          BD+60 1148  73029 14612                       083101.8+601721083910.2+595622156.74 36.63 6.48                      A2Vn               -0.019-0.033      -014                           
+3402          CD-26 6225  73072176131                       083114.2-262955083528.8-265037248.82  8.18 5.96  +0.37               A1V+G-KIII         -0.022+0.014      +009SB2                        
+3403  4Pi 2UMaBD+64  698  73108 146162677I                  083128.5+644038084012.8+641940151.36 35.96 4.60  +1.17 +1.16 +0.63   K1+IIIb            -0.060+0.023 +.016+015     < 17                 *
+3404          CD-39 4519  73121199402                       083131.9-393734083512.6-395812259.37  0.31 6.47  +0.58               G1V                +0.087+0.053      +034                           
+3405          BD+53 1269  73131 26940                       083134.2+531630083900.0+525530165.48 37.34 6.42R                     K0                 -0.022-0.032      +039                           
+3406 36    CncBD+10 1837  731431169532675                   083140.5+100011083705.8+093920216.22 27.83 5.88  +0.09 +0.10         A3V                -0.029-0.003      +017                           
+3407          CD-49 3646  731552201382674                   083140.3-493559083443.6-495639267.33-05.71 5.01  +1.33 +1.38 +0.68   K1-2II             -0.012+0.016 +.009+004                           
+3408          BD+53 1272  73171 26946 323                   083153.1+530343083917.6+524242165.75 37.39 5.91  +1.17 +1.05        gK1                 -0.029-0.028      +027V?                        *
+3409          BD+33 1728  73192 60939                       083204.2+330904083819.0+324807190.51 35.69 5.94  +1.12              gK2                 -0.024-0.010      +004                           
+3410  4Del HyaBD+06 2001  732621169651223  W                083221.7+060309083739.4+054213220.26 26.18 4.16   0.00 +0.01 +0.01   A1Vnn              -0.066-0.007 +.033+011SB    249  6.2 243.7       
+3411          BD-04 2401  73281136103                       083228.5-043508083727.1-045601230.32 20.88 6.19  +1.05 +0.89         K0                 -0.006+0.021      +018                           
+3412 37    CncBD+10 1840  73316116975                       083240.2+095527083805.2+093429216.42 28.01 6.53  -0.02 -0.04         A1V                -0.039-0.007      +028       50                  
+3413          CD-50 3417  73340236110              HV Vel   083252.8-503721083552.1-505812268.27-06.18 5.80  -0.13 -0.54         B8Si              v-0.004-0.004      +023V?                        *
+3414          CP-57 1591  73389236106                       083257.9-573947083519.6-580033273.97-10.38 4.86  +1.00 +0.81 +0.49   K0III              +0.042+0.022 +.017+024                           
+3415          CP-57 1590  73390236105                       083256.1-575241083515.4-581330274.14-10.52 5.26  -0.14 -0.61 -0.16   B3V+B3Vn           -0.032+0.006      +021V     140                 *
+3416          BD-06 2669  73451136117                       083324.8-061844083820.3-063945232.02 20.16 6.51  +0.44 +0.17         A1V+G               0.000-0.005      +030V                          
+3417          CP-72  713  73468256524                       083323.0-730050083242.2-732124287.03-19.14 6.12  +0.95 +0.66         G8III              -0.038+0.082      -027                           
+3418  5Sig HyaBD+03 2026  734711169881224I                  083331.8+034133083845.4+032029222.71 25.31 4.44  +1.21 +1.28 +0.56   K1+III             -0.018-0.018 +.035+025V    < 17                 *
+3419          CD-33 5257  73476199436      W                083331.5-332342083729.7-334445254.66  4.42 6.48  +0.33               F0IV-V             -0.021-0.046      +012V?         5.3  22.4AB   4 
+3420   Eta PyxCD-25 6356  734951761892676  W                083335.8-255417083752.2-261518248.66  8.96 5.27  -0.04               A0V                -0.020-0.006 +.038+031      203  7.8  16.0       
+3421          CD-39 4574  73524199438                       083342.5-394756083719.9-400851259.76  0.53 6.55  +0.60 +0.14         G4IV-V             -0.308+0.033 +.059-002                           
+3422 34    LynBD+46 1422  73593 424901225I                  083406.5+461105084101.1+455002174.42 37.76 5.37  +0.99 +0.75         G8IV               +0.025+0.092 +.015-037                           
+3423          BD+32 1776  73596 60970                       083406.3+321744084018.3+315631191.65 35.92 6.10R                     F5III              -0.035-0.028      +013SB                         
+3424          BD+08 2099  73599116997                       083402.5+082213083924.6+080102218.16 27.62 6.45  +1.08 +0.99         K1III              -0.025-0.037      +017                           
+3425          BD-19 2489  736031544922678I   6903           083409.7-192308083840.3-194413243.40 12.93 6.33  +1.59 +1.83         K5III              +0.014+0.006D+.005+000           3.0   4.3       
+3426          CD-42 4451  73634220204 324                   083407.6-423821083738.7-425921262.05-01.14 4.14  +0.11 +0.16 +0.16   A6II               -0.006+0.008 +.018+019        0                  
+3427 39    CncBD+20 2158  73665 80333      W        4179    083421.3+202139084006.4+200028205.51 32.54 6.39  +0.98 +0.83 +0.47   G8III              -0.036-0.015      +035V       0  0.0 149.8AB   5*
+3428          BD+20 2166  73710 98021        6921           083437.7+200125084022.1+194012205.89 32.48 6.44  +1.02 +0.90 +0.49   G9III              -0.035-0.017      +036SB   < 45  1.3  63.2AC   4*
+3429 41Eps CncBD+20 2171  73731 98024      W                083442.9+195355084027.0+193242206.06 32.45 6.30  +0.17 +0.16 +0.06   A8Vn               -0.039-0.006      +030SB2    82  1.1 134.9      *
+3430          BD-22 2345  73752176226        6914           083445.2-221918083908.0-223943245.90 11.31 5.05  +0.73 +0.36         G6IV               -0.235+0.436 +.063+043SB         1.3   0.8AB   3*
+3431  6    HyaBD-11 2420  73840154515 325I                  083517.2-120718084001.5-122831237.40 17.34 4.98  +1.42 +1.62 +0.75   K4III              -0.081-0.002 +.023-011V?   < 19:                *
+3432          CP-62 1058  738872502882679  W                083532.3-623006083718.8-625113278.15-12.99 5.47  +1.02 +0.83         K0III              -0.008-0.025 +.020+021V?         5.6   7.6       
+3433   Zet PyxCD-29 6544  738981762532680I   6923   4186    083533.4-291218083942.5-293340251.59  7.31 4.89  +0.90               G4III              -0.020-0.089 +.021-032           4.2  52.4       
+3434          CD-36 4872  73900199473      W                083532.4-361518083922.1-363625257.18  3.00 6.13  +0.42               F1IV               -0.171+0.040D+.024+009SB         1.5   0.9      *
+3435          CP-52 1565  73952236142      W                083554.4-524417083844.9-530526270.25-07.09 6.47  -0.10 -0.35         B8Vn               -0.009+0.013      +011V     184  7.5  22.2      *
+3436          BD+47 1606  73971 42508                       083602.9+471534084300.2+465404173.08 38.13 6.22  +0.96               G8III              -0.039-0.045      -007                           
+3437          BD-08 2452  739971361762682                   083610.5-084148084101.6-090307234.54 19.43 6.63  -0.02 +0.02         A1Vn               -0.033+0.002      +010      112                  
+3438   Bet PyxCD-34 5128  740061994902681  W                083611.2-345712084006.2-351830256.24  3.90 3.97  +0.94 +0.65 +0.48   G7Ib-II            +0.012-0.022 +.018-013SB         8.5  12.6       
+3439          CD-39 4653  74067220252      W        4193    083638.9-395432084019.3-401551260.19  0.91 5.20  -0.01 -0.14         B9V                -0.044-0.004      +021        0  3.7   4.4      *
+3440          CP-53 1796  74071236151              HW Vel   083634.9-530510083923.8-532623270.59-07.22 5.48  -0.16 -0.55         B5V                -0.029+0.019      +015V?    128                 *
+3441  9    HyaBD-15 2554  741371545522684I   6937           083704.9-153502084143.3-155636240.63 15.71 4.88  +1.06 +0.92 +0.53   G9.5III            +0.001-0.098 +.032-002V    < 19: 6.8  31.0      *
+3442          CP-52 1579  74146236157      W        4194    083705.5-524200083957.6-530318270.33-06.92 5.19  -0.14 -0.57         B4IV               -0.022+0.012      +014SB     56  4.4  16.6      *
+3443          CP-59 1075  74148250291      W                083705.8-595748083913.2-601902276.18-11.33 6.36   0.00               A0V                -0.032+0.026D+.013+009           0.6   1.2       
+3444          CD-44 4679  74167220261               4198    083710.7-445007084035.3-451129264.12-02.06 5.71  +1.65 +2.00         M0III              +0.013-0.003      +013                           
+3445          CD-46 4438  741802202651226  W        4199    083718.4-461734084037.6-463856265.28-02.95 3.84  +0.71 +0.30 +0.60   F3Ia                0.000+0.003 +.031+025V      38  6.9  37.5      *
+3446          BD-11 2432  74190154558                       083724.0-113629084209.8-115758237.26 18.06 6.45  +0.16 +0.13         A5m                -0.031-0.022      +002                           
+3447          CP-52 1583  741952361641227          o Vel    083725.6-523400084017.6-525519270.25-06.80 3.62  -0.18 -0.64 -0.18   B3IV               -0.022+0.019      +016SB     40                 *
+3448          CP-52 1584  74196236165               4197    083726.0-523937084017.4-530055270.33-06.86 5.61  -0.14 -0.50         B7Vn               -0.029+0.030      +015SB    130                 *
+3449 43Gam CncBD+21 1895  74198 803781228  W                083729.9+214942084317.1+212807204.17 33.73 4.66  +0.02 +0.01  0.00   A1IV               -0.106-0.039 +.016+029SB     79  4.0 106.3AB   5*
+3450 45    CncBD+13 1972  74228 980692686                   083741.7+130223084312.3+124051213.80 30.46 5.64  +0.39 +0.25         A3V+G0III          -0.012+0.002      -013SBO    30  0.0   0.1      *
+3451          BD+37 1899  74243 61018                       083745.8+371649084410.1+365505185.71 37.59 6.33R                     F7V                -0.034-0.094      +004       20                  
+3452          CD-46 4448  74272220284                       083756.3-465736084113.1-471901265.87-03.27 4.77  +0.12 +0.12 +0.19   A5II               -0.012+0.007 -.000+017SB      0                  
+3453          CD-48 4020  74273220282                       083754.9-483357084105.3-485521267.13-04.27 5.90  -0.21 -0.90         B1.5V              -0.005+0.007      +018      181                 *
+3454  7Eta HyaBD+03 2039  742801170502687          Eta Hya  083759.8+034528084313.5+032355223.25 26.32 4.30  -0.20 -0.74 -0.19   B3V                -0.019-0.001      +017SB?   128                 *
+3455          CP-57 1644  74341236179      W                083816.6-571120084043.6-573243274.02-09.53 6.34  +0.20 +0.14         A3V                -0.015+0.025D+.022+014           1.9   3.8       
+3456          CD-44 4704  74371220300                       083832.7-450308084156.9-452439264.44-02.01 5.23  +0.21 -0.53         B6Iae              -0.003-0.002      +024       53                 *
+3457          CP-59 1080  743752361812685  W       V343 Car 083824.4-592415084037.0-594540275.82-10.86 4.33  -0.11 -0.80 -0.13   B1.5III            -0.001 0.000      +013SB     48  8.9  15.7      *
+3458          BD+04 2029  74393117069                       083844.5+044143084359.7+042005222.43 26.94 6.37  -0.06 -0.13         B9.5III-IV         -0.032-0.005      +034V                          
+3459          BD-06 2708  74395136221    I W                083845.7-065225084340.4-071401233.29 20.97 4.62  +0.84 +0.49 +0.44   G1Ib               -0.002+0.003 +.007+031     < 17  4.1  78.9AB   3*
+3460   The VolCP-69  946  744052565352683  W                083843.1-700147083905.2-702313284.68-17.12 5.20  +0.01 -0.03         A0V                +0.018-0.040 +.006+013       82  5.0  45.0AC   3 
+3461 47Del CncBD+18 2027  74442 98087 326I   6967           083900.1+183119084441.1+180915208.02 32.90 3.94  +1.08 +0.99 +0.54   K0III-IIIb         -0.018-0.228 +.025+017     < 17  7.5  38.4      *
+3462          CD-47 4251  74455220313      W       HX Vel   083902.0-474424084216.0-480557266.60-03.61 5.51  -0.18 -0.88         B1.5Vn             -0.024-0.008      +042V     285  1.3   0.3      *
+3463          CD-35 4976  74475199535                       083903.1-353502084257.0-355636257.10  3.97 6.42  +0.02 +0.01         A0V                 0.000+0.018      +008                           
+3464 46    CncBD+31 1876  74485 610292690                   083913.4+310336084521.4+304152193.45 36.71 6.13  +0.94 +0.63 +0.49   G5III              -0.002-0.006 +.008-012V?                        *
+3465 49    CncBD+10 1864  74521 980892688          BI Cnc   083919.4+102638084445.0+100454216.71 29.71 5.66  -0.11 -0.25         A1pEuCr            -0.016-0.019      +024SB     20                 *
+3466          CP-52 1605  74535236202      W     BCKT Vel   083926.9-524428084218.9-530600270.58-06.67 5.52  -0.15 -0.54         B8Si               -0.029+0.023      +017           0.8  76.6AB   4*
+3467          CP-52 1607  74560236205      W     A HY Vel   083933.3-524517084225.5-530650270.60-06.66 4.86  -0.17 -0.66 -0.19   B3IV               -0.015+0.022      +022SB     22  0.8  76.6AB   4*
+3468   Alp PyxCD-32 5651  74575199546 327           4220    083934.4-324933084335.5-331111254.99  5.77 3.68  -0.18 -0.88 -0.16   B1.5III            -0.011+0.011      +015V?     19                 *
+3469 10    HyaBD+06 2030  74591117088                       083943.5+060235084501.3+054050221.23 27.79 6.13  +0.20 +0.10         A6V                -0.001-0.005      -009SB    132                  
+3470          BD+67  560  74604 14667                       083946.1+670430084849.4+664229148.23 36.25 6.20  -0.11 -0.40         B8V                -0.011-0.039      +005V?                         
+3471          CP-55 1688  74622236206                       083943.3-552457084220.9-554627272.73-08.29 6.29  +1.18 +1.20         K2III              -0.072+0.053      +075                           
+3472          BD-02 2676  74688136243        6977A          084017.7-021415084520.8-023603229.28 23.78 6.41  +0.52 +0.06         F2IV               +0.005-0.006D+.005-018V          0.7   4.7      *
+3473          BD-20 2667  747061764041229                   084026.8-204818084455.2-211004245.47 13.28 6.11  +0.22               A5V                -0.020+0.001      -015      170                  
+3474 48Iot CncBD+29 1823  74738 80415    I:  6988B  4238    084036.9+290751084640.0+284555195.87 36.54 6.57  +0.04 +0.04         A3V                -0.018-0.041 +.017+015      200  2.5  30.4      *
+3475 48Iot CncBD+29 1824  74739 80416 328I   6988A  4238    084038.8+290733084641.8+284536195.88 36.54 4.02  +1.01 +0.78 +0.49   G7.5IIIaBa0.1      -0.025-0.042 +.017+016     < 19: 2.5  30.4      *
+3476          CD-49 3761  747532203612689                   084032.4-492740084340.3-494922268.11-04.49 5.16  -0.20 -1.03         B0IIIn             +0.002+0.004      +028      288                  
+3477          CD-42 4569  74772220371      W                084049.6-421713084424.0-423857262.54  0.05 4.07  +0.87 +0.52 +0.50   G5III              -0.012+0.018 +.051-002           7.1  45.3      *
+3478          BD-01 2125  74794136254                       084058.1-014108084602.5-020256228.86 24.21 5.70  +1.10 +1.04        gK0                 +0.043+0.042      +010V?                         
+3479          CD-36 4980  74824199573               4232    084100.8-364702084451.9-370850258.28  3.53 5.76  -0.15               B2III              -0.008+0.001      +012V     148                 *
+3480          BD-10 2634  74860154615    I W                084119.0-103833084606.9-110023237.00 19.39 6.25  +1.61 +1.90         K5III              -0.018+0.027      +034V          3.5   2.3       
+3481 50    CncBD+12 1904  74873 98117                       084127.1+122837084656.0+120636214.84 31.06 5.87  +0.11 +0.05         A1V                -0.068-0.052      +023V      74                  
+3482 11Eps HyaBD+06 2036  74874117112    I   6993  Eps Hya  084128.8+064709084646.6+062508220.72 28.53 3.38  +0.68 +0.36 +0.39   G5III              -0.189-0.051 +.027+036SBO    19  0.9   0.2AB   6*
+3483          CD-24 7377  74879176439                       084129.7-250125084549.3-252315249.05 10.91 6.10  +0.08               A2V:               -0.029+0.032      +009V?                         
+3484 12    HyaBD-13 2673  74918154622    I W                084139.0-131055084622.5-133252239.25 18.01 4.32  +0.90 +0.62 +0.46   G8-IIIFe-1         +0.016-0.011 +.013-008SB1  < 17  9.3  19.9      *
+3485   Del VelCP-54 1788  74956236232      W                084156.5-542031084442.2-544230272.08-07.37 1.96  +0.04 +0.07 +0.02   A1V                +0.023-0.078 +.051+002V?     40  3.0   2.2AB   4*
+3486          BD-01 2130  749881362762693                   084210.8-013150084715.0-015350228.89 24.55 5.29  +0.04 +0.08         A3V                -0.033+0.004 +.020+002SB    170                  
+3487          CD-45 4517  75063220422                       084238.2-454032084601.7-460230265.38-01.84 3.91   0.00 -0.05 +0.13   A1III              -0.001 0.000 +.003+024       25                  
+3488          CD-40 4602  75081220432                       084243.9-404533084623.8-410732261.58  1.29 6.21  -0.05 -0.19         B9Ve              t-0.018-0.001      +023                          *
+3489          CP-58 1202  75086236241      W     A          084243.3-582133084505.3-584330275.33-09.78 6.21  -0.09 -0.47         B7III              -0.031-0.020D+.006+028           0.1   4.1AB   4*
+3490          CD-34 5243  75112199607               4251    084250.9-341522084649.2-343722256.54  5.41 6.37  -0.13 -0.58         B4V                -0.021+0.007      +015V                         *
+3491          CP-67  990  75116250315                       084257.5-675053084354.3-681242283.07-15.53 6.32  +1.50 +1.78         K3III:             +0.001+0.027      -017                           
+3492 13Rho HyaBD+06 2040  75137117146        7006           084308.1+061226084826.0+055016221.52 28.62 4.36  -0.04 -0.04 -0.07   A0Vn               -0.017-0.034 +.014+033SB    126  8.7  12.4      *
+3493          BD-06 2727  75140136287                       084308.6-061123084804.9-063331233.32 22.26 6.09  +1.28 +1.42         K0                 +0.012-0.021      -005                           
+3494          CD-45 4526  75149220442                       084306.3-453244084630.6-455446265.33-01.69 5.46  +0.27 -0.53         B3Ia               +0.006-0.012      +026       73                 *
+3495          CP-65 1013  751712503172691                   084306.6-652748084430.0-654932281.10-14.09 6.05  +0.20 +0.08         A4V                -0.062+0.101      +009                           
+3496          CD-45 4541  75276220464                       084355.2-454714084718.9-460920265.61-01.73 5.75  +0.56 +0.38         F2Iab              +0.003-0.008      +032                          *
+3497          CD-41 4507  75289220481                       084401.9-412142084740.5-414414262.21  1.09 6.36  +0.58 +0.10         G0Ia-0:             0.000-0.242 +.029+014V                          
+3498          CP-56 1865  753112362682695          V344 Car 084407.3-562407084642.5-564611273.90-08.41 4.49  -0.17 -0.73 -0.18   B3Vne             v-0.010+0.008      +027      332                 *
+3499          BD+33 1765  75332 61074                       084419.5+333932085032.2+331707190.53 38.30 6.25  +0.49 +0.01         F7Vn               -0.067-0.081      +005       11                  
+3500 14    HyaBD-02 2699  753331363081230          KX Hya   084420.2-030419084921.7-032635230.64 24.19 5.31  -0.09 -0.35         B9pHgMn            -0.020-0.023      +033V?     35                 *
+3501          CD-41 4516  75387220495                       084432.4-420538084808.8-422750262.83  0.70 6.43  -0.20 -0.77         B2IV-V             -0.003-0.009      +030                          *
+3502   Eta ChaCP-78  372  75416256543 331                   084443.7-783601084119.5-785748292.40-21.65 5.47  -0.10 -0.35         B8V                -0.031+0.026      +014V     301                  
+3503          CP-52 1675  75466236284                       084504.1-522851084800.2-525102270.91-05.84 6.30  -0.10 -0.32         B8V                -0.026+0.007      +012      204                 *
+3504          BD+19 2110  75469 98162                       084503.6+191219085045.1+184956207.88 34.48 6.16R -0.01  0.00         A2V s              -0.015-0.020      +019                           
+3505  5    UMaBD+62 1027  75486 146912701                   084508.3+622011085322.6+615744153.83 37.93 5.73  +0.28 +0.11         F2III              -0.010+0.020      -031V?    101                  
+3506          BD+59 1198  75487 27026                       084512.2+592551085305.9+590322157.46 38.52 6.25R                     F5IV-V             +0.014+0.003      +009       30                  
+3507          BD-20 2693  75495176535                       084515.4-204030084944.9-210255246.06 14.25 6.47  +0.23               A7Vn               +0.006-0.064      -017                           
+3508 35    LynBD+44 1794  75506 425762700I                  084514.2+440556085156.8+434336177.19 39.64 5.15  +0.98 +0.68 +0.50   K0III              -0.015+0.048 +.018+015     < 17                  
+3509          BD+45 1649  75523 42580                       084523.8+454115085211.6+451845175.13 39.71 5.99  +1.26 +1.33         K0III              -0.026-0.037      +012                           
+3510 54    CncBD+15 1917  75528 981682699  D                084527.3+154318085101.5+152102211.81 33.26 6.38  +0.64               G1V                -0.112+0.075      +045    =< 10  1.4   0.1      *
+3511          BD+42 1935  75556 42581                       084533.2+422243085210.0+420009179.43 39.62 5.99  +1.25               K0III              -0.039-0.071      +057                           
+3512          CD-32 5770  756051996782696           4268    084547.7-322425084951.5-324650255.49  7.05 5.21  +0.87               G5III              +0.002-0.049 +.028-008V                         *
+3513          CD-28 6600  75629176546                       084550.7-290526085002.2-292747252.90  9.15 5.87  +0.95               G8III              -0.014+0.007      -010                           
+3514          CD-39 4838  75630220531                       084555.7-395652084939.2-401914261.34  2.27 5.48  +0.06 +0.13         A2/3IV             -0.008-0.014 +.036+017                           
+3515 M 67                                                   0 0 0      0 0 0 0 0      0 0                                                                                                           *
+3516          CD-28 6610  75649176554                       084608.1-281440085021.6-283705252.27  9.73 6.17  -0.08 -0.19         B9V                -0.021-0.022      +025                           
+3517          CD-38 4925  756541996822697          HZ Vel   084605.8-384612084952.4-390830260.46  3.05 6.39  +0.23               A5III              -0.058+0.038      +009                          *
+3518   Gam PyxCD-27 5986  75691176559 332I                  084617.2-272020085031.9-274236251.57 10.33 4.01  +1.27 +1.40 +0.67   K3-III             -0.130+0.087 +.033+025                           
+3519 51Sig1CncBD+33 1770  75698 61102        7057           084624.0+325056085234.6+322827191.64 38.57 5.66  +0.22 +0.07 +0.08   A8Vma s            -0.003+0.016      -014SB     65  4.4  79.0AC   4*
+3520          CD-44 4861  757102205402698                   084620.1-445608084947.7-451829265.22-00.86 4.93  +0.05 +0.15         A2III              -0.010+0.010 +.012+005SB     77                  
+3521 53    CncBD+28 1659  75716 80476    I W       BO Cnc   084627.8+283805085228.6+281533196.87 37.66 6.23  +1.62               M3III              -0.017-0.004 +.001+011V          3.5  43.1      *
+3522 55Rho1CncBD+28 1660  75732 80478                       084638.5+284246085235.8+281951196.79 37.71 5.95  +0.87 +0.63 +0.40   G8V                -0.484-0.234 +.074+027V          7.0  85.0      *
+3523 15    HyaBD-06 2743  75737136345        7050   4282    084639.5-064809085134.5-071038234.39 22.64 5.54  +0.15 +0.14         A4m                -0.044+0.001D+.011+037SB2    25  1.8   0.9AB   4*
+3524          CP-78  378  75747256549              RS Cha   084637.7-784214084312.4-790411292.55-21.63 6.05  +0.23 +0.08         A5V+A7V            -0.029+0.040      +026SBO                       *
+3525          CD-41 4560  75759220552                       084642.6-414259085021.0-420524262.80  1.25 6.00  -0.10 -0.95         B1-2III            -0.011-0.007      +023SB2O   39                 *
+3526          BD+05 2074  75811117214        7061           084707.3+054259085224.2+052024222.55 29.26 6.33  +0.12 +0.14         A5V                -0.004-0.015      -010V      43  3.2   0.8       
+3527          CD-46 4661  75821220561      W                084709.8-460918085033.5-463145266.25-01.54 5.10  -0.21 -0.99 -0.16   B0III              -0.001-0.002      +007SB     74  4.1   3.2      *
+3528          BD+36 1883  75896 611172704                   084737.9+355459085355.7+353218187.81 39.34 6.14  +0.04 +0.11         A4III              -0.024-0.017      +025SB?    50                  
+3529          BD-12 2716  75916154704        7062           084746.0-125124085230.7-131401239.88 19.41 6.13  +1.14 +1.14         K0                 +0.025-0.019      +014V?         5.3  33.6       
+3530          CD-42 4723  75926220581                       084750.5-420746085127.9-423016263.25  1.15 6.55  +0.04 +0.08         A1Vn               -0.022+0.027      +024V                          
+3531  6    UMaBD+65  673  75958 14703                       084803.2+645912085637.5+643614150.48 37.60 5.58  +0.86 +0.57         G7IIIFe-0.5        -0.026-0.081      +003SB                         
+3532 57    CncBD+31 1907  75959 61125    I   7071           084808.6+305730085414.7+303446194.11 38.55 5.39  +1.05               G7III              +0.038-0.019D+.005-060           0.2   1.5AB   3*
+3533          CD-32 5814  76001199728                       084821.1-320756085226.1-323033255.62  7.64 6.50  +1.46               K2/3III            -0.008-0.006      +001                           
+3534          CD-36 5125  76072199731      W        4288    084843.7-361004085238.6-363244258.79  5.12 6.42  +0.56               G8III+A3-5V        -0.015-0.017      +018           0.0   0.1       
+3535          CD-38 4980  76110199737                       084858.8-382048085248.0-384327260.50  3.75 5.82  +1.50 +1.89         M0III              -0.001+0.013      +021                           
+3536          CP-57 1759  76113236339                       084903.5-571526085136.6-573801275.00-08.43 5.59  -0.11 -0.41         B8III              -0.011+0.014      +008       19                  
+3537          CP-66  927  76143250347      W                084913.8-662511085034.8-664735282.28-14.18 5.35  +0.42 +0.07         F5IV               +0.089+0.097 +.031+042      106  6.6  20.        
+3538          BD-04 2490  76151136389                       084922.3-050321085417.9-052604233.21 24.17 6.00  +0.67 +0.22 +0.21E  G2V                -0.416+0.031 +.085+028V   =<  6                  
+3539          CD-47 4460  76161220609                       084921.0-475852085238.6-482133267.89-02.43 5.91  -0.15 -0.59 -0.16   B3Vn               -0.009-0.006      +003V?                        *
+3540 58Rho2CncBD+28 1666  76219 805112705I                  084940.3+281833085539.7+275539197.50 38.26 5.22  +1.00 +0.75 +0.49   G8II-III           -0.010-0.030 -.005+017V?   < 19:                *
+3541          BD+17 1973  76221 98230    I         X Cnc    084944.9+173643085522.9+171353210.18 34.94 6.64  +3.36       +1.37   C6II               +0.001+0.009 +.007-001                          *
+3542          CD-51 3303  76230236362      W                084938.9-514503085240.8-520745270.80-04.83 6.39   0.00 -0.13         A0V                -0.019+0.005      +018           1.6   2.8      *
+3543          CP-79  352  76236256552                       084936.0-790804084555.2-793016293.02-21.76 5.79  +1.60 +1.97         K5III              -0.029+0.085      +007                           
+3544          CP-72  747  76270256556                       084953.0-721032084950.3-723303287.05-17.65 6.11  +0.20 +0.17         Am                 -0.001+0.025      -003                           
+3545          BD+46 1459  76291 42612                       085003.8+460055085650.0+453755174.71 40.52 5.74  +1.09 +1.06 +0.56   K1IV               -0.126-0.034      +059V?                         
+3546          BD+40 2125  76292 426112706                   085001.1+403504085630.5+401206181.84 40.33 5.89  +0.35 +0.06         F3III              -0.083-0.033      +025       53                 *
+3547 16Zet HyaBD+06 2060  76294117264 334I                  085006.4+061934085523.6+055644222.34 30.20 3.11  +1.00 +0.80 +0.49   G9II-III           -0.099+0.014 +.035+023     < 17                  
+3548          CD-39 4924  76304220628                       085006.2-400404085350.7-402651261.95  2.81 6.47  +0.96               K0II-III+A5        -0.006+0.007      -001V                          
+3549          CP-56 1918  76346236368                       085024.3-561616085303.8-563858274.35-07.66 6.03  -0.02 -0.08         A0V                -0.017+0.033      +024                           
+3550 60    CncBD+12 1941  76351 98235    I D        4308    085027.9+120030085555.6+113734216.45 32.85 5.41  +1.46              gK5                 -0.010-0.010      +024V?                        *
+3551          CD-47 4480  76360220636      W                085029.2-470824085350.7-473115267.37-01.74 5.33  +0.26               A9IV-V             +0.006-0.028 +.019-001SB2    99  0.0   0.1      *
+3552 17    HyaBD-07 2661  76369136408        7093B          085035.5-073515085529.5-075813235.69 23.01 6.91H                     A7m                -0.001-0.038D+.004-020       50  0.3   4.1      *
+3553 17    HyaBD-07 2661  76370136409        7093A          085035.5-073520085529.6-075816235.69 23.01 6.67H +0.22 +0.13         A2m                +0.002-0.024D+.004-010    =< 25  0.3   4.1      *
+3554          BD-17 2691  763761547451231I W                085036.7-175136085512.4-181429244.54 16.97 5.75  +1.32               K2-3III            +0.020+0.004      +037V?         1.2  66.7       
+3555 59Sig2CncBD+33 1785  76398 61146                       085046.4+331743085656.6+325437191.30 39.55 5.45  +0.12 +0.12         A7IV               -0.048-0.068 +.011+005      145                 *
+3556   Del PyxCD-27 6072  76483176697        7095           085114.1-271749085531.5-274055252.25 11.21 4.89  +0.11 +0.14 +0.05   A3IV               +0.079-0.102 +.037+005       73  9.1  23.8      *
+3557          BD+04 2081  76494117287                       085122.2+043712085636.9+041412224.24 29.65 6.14  +1.00 +0.75         G8II-III           -0.020+0.005      -012                           
+3558          BD+17 1979  76508 98245                       085130.9+173143085708.2+170838210.46 35.30 6.17  +1.00               K1III              -0.044-0.025      +019                           
+3559          CD-23 7902  765121767112707                   085131.3-232612085555.9-234906249.22 13.69 6.39  +0.16 +0.12         A7V:n              -0.040+0.038      +021                           
+3560          CP-59 1174  76538250369                       085131.4-595824085348.7-602115277.32-09.92 5.78  -0.08 -0.55         B5III              -0.007+0.002      +002                           
+3561 62Omi1CncBD+15 1945  76543 98247                       085140.3+154223085714.9+151922212.53 34.64 5.20  +0.15               A5III              +0.056+0.017      -005SB     89                  
+3562          CD-44 4951  76566220664      W       IY Vel   085148.5-443933085519.3-450230265.64  0.05 6.26  -0.16 -0.63         B3IV               +0.002+0.008      +022        5  6.5  35.0      *
+3563 61    CncBD+30 1795  76572 61157        7107           085154.2+303705085758.7+301401194.76 39.26 6.29  +0.43 -0.02         F6V                +0.055+0.024      +008    =< 10  0.0   0.1      *
+3564          BD-16 2639  76579154773    I          4321    085155.5-161928085634.1-164234243.46 18.15 5.96  +1.54               K0                 -0.010-0.047      +038                          *
+3565 63Omi2CncBD+16 1864  76582 98250                       085200.1+155755085735.2+153453212.28 34.81 5.67  +0.20               F0IV               +0.058+0.029      -004V?    113                  
+3566          BD+36 1889  76595 61161                       085210.0+361118085827.5+354809187.63 40.29 6.51R -0.01 +0.01         A2V                +0.008-0.011      -015                           
+3567          BD+09 2093  766291173012710                   085218.4+094623085742.0+092316219.06 32.28 6.19  +0.98 +0.76         G8III              -0.002-0.007      -014                           
+3568          CP-57 1790  76640236402                       085222.5-575126085454.0-581424275.75-08.47 6.38  -0.11 -0.49         B5V                -0.022+0.002      +013      119                  
+3569  9Iot UMaBD+48 1707  76644 42630 335I   7114   4329    085221.8+482604085912.4+480230171.51 40.84 3.14  +0.19 +0.07 +0.07   A7IV               -0.444-0.226 +.075+009SB1O  151  7.2   3.9AB   4*
+3570          CP-54 1925  76653236405                       085221.5-543449085511.9-545756273.23-06.35 5.71  +0.48  0.00         F6V                +0.037-0.082      -002                           
+3571          CP-60 1243  76728250374 336  W                085246.8-601545085502.8-603841277.65-09.98 3.84  -0.10 -0.45 -0.11   B8-9II             -0.021+0.038      +025V      36  8.8  21.1      *
+3572 65Alp CncBD+12 1948  76756 98267 337    7115   4327    085301.1+121442085829.2+115128216.51 33.52 4.25  +0.14 +0.15 +0.04   A5m                +0.034-0.031 +.024-014SB     68  0.0   0.1     3*
+3573          BD+02 2112  767571173112712  W                085258.1+015540085808.2+013230227.14 28.65 6.59  +0.06 +0.09         A2V                -0.040-0.005      +026           5.5   2.5       
+3574          CP-52 1788  76805236417      W                085318.1-522020085619.4-524325271.62-04.79 4.69  -0.12 -0.47 -0.14   B5V                 0.000+0.007D+.020+022SB1O   48  3.0   2.8      *
+3575 64Sig3CncBD+32 1821  76813 611771232I W                085324.2+324826085932.6+322507192.05 40.01 5.20  +0.93               G8III              -0.045-0.035      +023           3.8  89.3      *
+3576  8Rho UMaBD+68  551  76827 14742 338I          4344    085331.9+680110090232.7+673747146.63 37.23 4.76  +1.53 +1.88 +1.26   M3III-IIIbCa1      -0.021+0.019 +.014+005V                          
+3577          BD+18 2093  76830 98276    I          4332    085331.9+183127085910.8+180805209.54 36.11 6.38  +1.55 +1.69         M4III             v-0.044-0.068 -.002+021V?                         
+3578          BD-15 2656  769321548042713                   085402.3-154504085843.9-160758243.30 18.91 5.86  +0.53 +0.08 +0.23E  F6V                +0.246+0.212 +.028+121V       0                  
+3579          BD+42 1956  76943 42642 339I W                085409.0+421044090038.4+414658179.80 41.19 3.97  +0.44 +0.05 +0.22   F5V                -0.440-0.246 +.070+026SBO    26  2.0   0.3AB   5*
+3580          BD+38 1986  76944 61191    I                  085409.4+375936090030.8+373616185.33 40.90 6.44R                     K5                 -0.007 0.000      -017                           
+3581          BD+84  196  76990  14611640                   085432.3+843459091521.2+841052128.39 30.44 6.33  +0.30 +0.10         F2III              +0.027+0.015      -006SB2                        
+3582          CP-58 1301  770022364361233  W     A V376 Car 085431.6-585035085658.4-591346276.70-08.90 4.92  -0.19 -0.77 -0.24   B2IV-V             -0.009+0.007      +027        0  1.9  40.2      *
+3583          CD-48 4282  77020220703                       085436.5-481109085755.8-483424268.62-01.90 5.87  +1.07 +0.88         G8-K0II            +0.004-0.004      +018                           
+3584          BD-18 2536  77084154815                       085505.8-184858085939.9-191229246.01 17.22 6.18  +0.46               F6V                -0.051-0.098      +020V                          
+3585          CD-28 6793  77087176789                       085501.0-282504085915.7-284822253.67 11.13 6.25  +1.00               G8III              -0.061+0.015      +025                           
+3586          BD+40 2138  77093 61203                       085514.1+400624090140.6+394248182.56 41.29 6.36  +0.30 +0.04         A9Vn               -0.053-0.079      -008      150                  
+3587 66    CncBD+32 1829  77104 61202        7137           085516.2+323835090124.1+321509192.36 40.36 5.82R  0.00 +0.09         A2V                -0.004+0.003      -013V          2.3   4.6AB   3*
+3588          CD-46 4810  77140220717      W       FZ Vel   085528.5-465050085852.3-471405267.71-00.90 5.18  +0.25 +0.19         Am                 -0.086+0.054 +.013+018       57  6.0  24.2      *
+3589 67    CncBD+28 1674  77190 80585      W                085551.2+281748090148.9+275410197.94 39.58 6.07                      A8Vn               -0.056-0.076      +012SB    166  2.8 103.5      *
+3590          BD+06 2087  77250117351                       085614.5+060158090131.4+053827223.50 31.40 6.07  +1.11 +1.02         K1II-III+F3IV      -0.028-0.007      +033           1.6 269.0      *
+3591          CD-40 4810  772582207301234           4346    085621.4-405151090005.4-411514263.33  3.18 4.45  +0.65 +0.38 +0.41   G8-K1III+A         -0.039+0.045 +.030-007SB1O    0                 *
+3592          BD+54 1272  77309 27105 340                   085640.9+544041090400.4+541702163.20 40.86 5.75  +0.02 +0.05         A2V                -0.003+0.004      -004V     110                  
+3593          CD-42 4875  77320220738              IU Vel   085643.6-424658090022.2-431024264.82  1.96 6.07  -0.16 -0.82 -0.12   B2.5Vn            t-0.015+0.019      +027V     230                 *
+3594 12Kap UMaBD+47 1633  77327 42661 341    7158   4357    085648.0+473308090337.5+470924172.63 41.63 3.60   0.00 +0.01 +0.01   A1Vn               -0.033-0.054 +.016+004V?    219  0.2   0.3      *
+3595 69Nu  CncBD+25 2029  77350 805952714           4356    085653.5+245047090244.3+242710202.31 38.90 5.45  -0.04 -0.10 -0.04   A0pSi             v-0.005-0.006 +.003-015SBO    23                 *
+3596          BD+00 2449  773531365111235                   085651.4-000531090158.0-002858229.68 28.43 5.67  +1.15 +1.04         K0III              -0.048+0.069      +073V                          
+3597          CD-26 6647  77361176833                       085651.1-261613090111.4-263950252.26 12.83 6.20  +1.13               K1IIICNII          +0.026-0.056      -024V?                         
+3598          CP-58 1327  77370236475      W                085656.8-584203085924.1-590501276.79-08.57 5.16  +0.42               F3V                -0.174+0.280 +.054+011       66  6.8  26.2      *
+3599          BD+07 2066  77445117369                       085725.1+074132090244.8+071753221.94 32.44 5.85  +1.11 +0.98        gK3                 -0.016-0.005      +027                           
+3600          CD-41 4720  77475220760              IZ Vel   085737.9-412818090120.8-415152263.95  2.96 5.55  -0.14 -0.58         B5V                -0.023+0.005      +021SB      0                 *
+3601 70    CncBD+28 1683  77557 80609                       085812.3+281739090409.9+275354198.10 40.08 6.38R  0.00 +0.05         A1V                +0.001-0.002      -021V     180                  
+3602          CD-38 5154  77580199902                       085816.4-390032090206.4-392409262.19  4.69 6.27  +1.00               K1III-IV           -0.037+0.023      +018                           
+3603          BD+49 1801  77601 42682                       085830.1+485540090524.1+483149170.76 41.83 5.95  +0.45 +0.17         F6II-III           -0.012-0.016      -006SB    139                 *
+3604          CP-60 1283  77615250417                       085827.6-603415090045.7-605750278.35-09.65 5.79  +1.21               G8II               -0.006 0.000      +018                           
+3605          CD-51 3430  77653236518      W                085838.2-514742090144.6-521118271.75-03.81 5.23  -0.12 -0.45         B9Si               -0.007+0.018D+.008+032        0  1.2   0.9       
+3606          BD+32 1837  77660 61242                       085848.3+324632090455.2+322237192.36 41.12 6.46  +0.24 +0.10         A8V                -0.043-0.058      +016      131                  
+3607          CD-25 6829  77665176881                       085846.0-250631090308.8-253016251.63 13.90 6.74  -0.03               B8                 -0.014-0.006      +027                           
+3608          BD+59 1217  77692 271212716                   085857.2+594436090643.1+592040156.59 40.15 6.45  +0.04 +0.13         A2V                -0.014-0.010      +002SB     55                  
+3609 11Sig1UMaBD+67  573  77800 14769    I                  085937.0+671630090823.6+665224147.27 38.03 5.14  +1.51 +1.83 +0.83   K5III              -0.018-0.038 +.011+015SB   < 19:                 
+3610          CP-68  879  77887250421                       090000.0-681721090108.5-684102284.45-14.56 5.88  +1.63 +1.97         M1III              +0.012+0.005      +013                           
+3611          CP-53 2072  77907236542                       090004.3-530914090305.2-533259272.91-04.56 6.40  -0.09 -0.35         B6V                -0.024+0.030      -007                           
+3612          BD+39 2200  77912 612541237I                  090010.2+385107090631.8+382708184.33 42.15 4.56  +1.04 +0.82 +0.49   G7Ib-II            -0.028-0.014 +.021+017V?   < 19:                *
+3613 18Ome HyaBD+05 2116  779961174202717I                  090042.5+052931090558.4+050532224.69 32.11 4.97  +1.22 +1.21 +0.57   K2II-III           -0.018-0.010 +.011+025V    < 19:                 
+3614          CD-46 4883  78004220803 342                   090042.3-464158090409.3-470552268.20-00.14 3.75  +1.20 +1.22 +0.60   K2III              -0.044-0.013 +.020+024                           
+3615   Alp VolCP-65 1065  78045250422 343                   090052.1-655948090226.8-662346282.71-13.00 4.00  +0.14 +0.13 +0.06   A2-3IVm            -0.002-0.096 +.051+005SB2    45                 *
+3616 13Sig2UMaBD+67  577  78154 14788        7203   4392    090135.8+673226091023.2+670805146.87 38.11 4.80  +0.49 +0.02 +0.28   F6IV               -0.020-0.074 +.056-002        0  3.5   2.8AB   3*
+3617          BD+23 2048  78175 80643        7187A          090141.1+232256090726.9+225852204.53 39.51 6.40                      F4V                -0.168+0.009 +.004+029           0.4   7.6AB   3*
+3618          BD+02 2145  781961174322718I                  090149.9+015152090659.9+012746228.52 30.51 6.17  +1.65 +1.96 +0.97E  M1III              -0.011-0.015      +003                           
+3619 15    UMaBD+52 1365  78209 271362721                   090149.1+520030090852.3+513617166.57 42.02 4.48  +0.27 +0.12 +0.11   F0IVm vs           -0.137-0.030      -000       37                 *
+3620          BD+33 1810  78234 61276                       090158.0+325636090804.1+323226192.28 41.80 6.50  +0.36  0.00         F2V                -0.084-0.017      +041                           
+3621 72Tau CncBD+30 1817  78235 806502719                   090159.9+300323090800.1+293915196.07 41.28 5.43  +0.89 +0.57 +0.45   G8III              -0.032+0.002      -013V?   < 19:                 
+3622          CP-57 1859  78293236578      W                090207.9-572712090448.0-575109276.31-07.23 6.44  +0.25 +0.19         A8III              -0.026+0.025      +015           3.6   3.3      *
+3623 76Kap CncBD+11 1984  78316 983781238  D       Kap Cnc  090219.8+110415090744.8+104005218.99 35.06 5.24  -0.11 -0.43         B8IIIpMn           -0.020-0.010      +024SB1O    9  0.2   0.3     3*
+3624 14Tau UMaBD+64  723  78362 147962727    7211           090240.6+635514091055.1+633049151.21 39.42 4.67  +0.35 +0.15 +0.13   F3-4IIIm vs        +0.098-0.056      -009SBO    18  6.2  57.2AB   3*
+3625          BD+34 1949  78366 612882723                   090242.9+341720090851.1+335256190.53 42.16 5.93  +0.60 +0.04         F9V                -0.187-0.114      +027V       5                 *
+3626 75    CncBD+27 1715  78418 806592724  W                090254.4+270235090847.3+263745200.03 40.78 5.98  +0.66 +0.20         G5IV-V             -0.136-0.368 +.040+013SB2O       3.1 112.0AB   3*
+3627 77Xi  CncBD+22 2061  78515 806661239  W                090336.6+222700090921.5+220244205.86 39.65 5.14  +0.97 +0.80 +0.48   G9IIIFe-1CH-0.5    +0.001+0.005      -007SB1O < 17  0.5   0.1      *
+3628   Kap PyxCD-25 6895  78541177002    I   7202   4389    090339.4-252718090802.9-255130252.64 14.52 4.58  +1.59 +1.89 +0.90   K4III              +0.041+0.008 +.013-045           5.2   2.1       
+3629          CP-55 1957  78548236611                       090341.7-552401090634.0-554812274.93-05.68 6.11  -0.15 -0.67         B2IV-V             -0.012-0.023      +029      202                  
+3630 19    HyaBD-08 2588  785561366042725  W                090348.5-081106090842.2-083522238.29 25.34 5.60  -0.06 -0.19         B9.5III            -0.019-0.002      +023SB    172  5.0   1.0       
+3631          CD-50 3849  785992366182722                   090401.2-504831090714.7-511243271.59-02.52 6.73  +1.62 +1.87         K4III              -0.004 0.000      +007V                          
+3632          CP-63 1093  78632250441                       090411.8-640553090607.6-642959281.49-11.49 6.37  +1.35 +1.58         K3III              +0.020+0.029      +001                           
+3633          BD+72  444  78633  67842729                   090419.8+720358091403.2+713921141.50 36.59 6.55  +0.96 +0.75         G8III-IV           -0.028-0.038      +006                           
+3634   Lam VelCD-42 4990  78647220878 345I'W       Lam Vel  090419.0-430144090759.8-432557265.94  2.82 2.21  +1.66 +1.81 +0.94   K4.5Ib-II         e-0.019+0.013 +.022+018          12.6  18.2      *
+3635          BD+12 1979  78661 98400                       090420.3+115818090946.4+113352218.25 35.90 6.48  +0.34 -0.10         F2Vp               -0.045-0.062      -016       53                  
+3636          BD-11 2565  786681549531240                   090423.8-115709090911.5-122128241.70 23.21 5.77  +0.94               G6III              +0.019+0.003      -009SB                         
+3637          CD-26 6766  786761770222726                   090422.4-262147090843.5-264604253.46 14.05 6.15  +0.17               A4IV               -0.045+0.009      +008V?                         
+3638          BD-17 2765  78702154950                       090427.3-175526090904.3-181943246.74 19.51 5.73   0.00 +0.01         A2Vn               -0.052+0.009      +017V?                         
+3639          BD+31 1946  78712 61306    I         RS Cnc   090436.2+312214091038.7+305747194.50 42.08 5.95  +1.67 +1.03 +2.33   M6IIIase           -0.021-0.034      +014V                         *
+3640 79    CncBD+22 2063  78715 80674      W                090436.2+222409091020.9+215947206.01 39.86 6.01  +0.90               G5III              +0.005+0.006      -007V          0.0   0.1      *
+3641 20    HyaBD-08 2593  78732136622                       090442.1-082254090935.5-084716238.61 25.40 5.46  +1.01 +0.78         G8II               -0.019-0.010      +026V?                         
+3642          CP-70  861  78764256583              V345 Car 090449.5-700810090538.3-703220286.19-15.43 4.71  -0.15 -0.81 -0.14   B2IVe              -0.008-0.005      +019V     140                 *
+3643          CP-72  779  787912565822720                   090453.0-721201090508.8-723610287.83-16.77 4.48  +0.61 +0.22 +0.31   F9II               -0.013-0.005 +.024+022       53                  
+3644   Eps PyxCD-29 7194  789222000471241  W                090542.1-295726090956.4-302155256.42 11.88 5.59  +0.19 +0.16 +0.07   A4IV-V             +0.002-0.048      -008SB    129  4.3  17.6AxBC 4*
+3645          BD+73  452  78935  6792                       090550.3+732136091552.6+725646139.99 36.14 5.96  +0.18 +0.13         F0III              -0.085-0.063 +.023+000V?     90                  
+3646          BD-22 2512  789551770662728                   090554.5-224610091023.0-231036250.88 16.66 6.53   0.00               A1-2V:             -0.029+0.010      +014V                          
+3647          CD-48 4471  79025220910                       090623.2-490058090945.1-492529270.54-01.02 6.48  +0.17               A9Vn               +0.014-0.041      -001                          *
+3648 16    UMaBD+62 1058  79028 148192730  W                090626.4+615007091420.6+612524153.62 40.47 5.13  +0.58 +0.10         F9V                -0.006-0.030 +.047-014SBO     0                 *
+3649          BD+06 2120  79066117487                       090639.9+055242091155.6+052806225.15 33.59 6.35  +0.32 +0.01         A9IVDel Del        -0.101-0.025      +003                           
+3650 81Pi 1CncBD+15 2003  79096 98427      W                090649.2+152357091217.6+145946214.66 37.86 6.51  +0.73 +0.25 +0.38   G9V                -0.522+0.248 +.064+045V          0.0   0.1AP   4*
+3651          BD+04 2139  79108117492                       090659.4+041637091212.9+035202226.86 32.86 6.14  -0.01 +0.01         A0Vp               -0.044-0.001      +020V     150                 *
+3652 36    LynBD+43 1893  79158 42759 346                   090715.9+433748091348.2+431304177.86 43.61 5.32  -0.14 -0.48         B8IIIpMn           -0.028-0.032      +021V      29                 *
+3653          BD-19 2644  791811549891242                   090723.9-192020091158.7-194452248.37 19.15 5.73  +0.98               G9III              -0.057+0.046      -001V?                         
+3654          CD-44 5206  79186220928              GX Vel   090726.6-442731091104.4-445205267.36  2.25 5.00  +0.23 -0.57 +0.22   B5Ia               -0.001+0.002      +034V?     61                 *
+3655 21    HyaBD-06 2845  79193136662              KW Hya   090729.7-064159091226.0-070635237.55 26.95 6.11  +0.22 +0.12 +0.12   A3III:m+A0V:       -0.016+0.019      -004SBO  < 12                 *
+3656          CD-38 5358  79241200084                       090747.1-385057091141.0-391532263.33  6.16 6.00  -0.11               B6V                -0.010+0.006      +019V                          
+3657          BD+21 1991  79248 80702                       090754.6+214143091337.3+211700207.20 40.36 6.48  +0.02 +0.06         A2V                -0.016-0.008      +009                           
+3658          CD-46 4987  79275220937                       090800.9-461026091133.2-463502268.68  1.14 5.79  -0.21 -0.84 -0.12C  B2III/IV           -0.018+0.010      +007                           
+3659          CP-58 1419  79351236693              V357 Car 090820.0-583326091058.0-585801277.69-07.37 3.44  -0.19 -0.70 -0.19   B2IV-V            e-0.026+0.008      +023SB2O   30                 *
+3660 17    UMaBD+57 1211  79354 27185    I          4427    090825.4+570922091549.9+564429159.52 41.98 5.27  +1.56 +1.87 +0.88   K5III              -0.016-0.031      -030V?   < 19:                 
+3661          CD-43 5041  79416220952      W       KL Vel   090848.5-431207091230.6-433649266.63  3.30 5.57  -0.11 -0.47 -0.06C  B8Vp:Si:           -0.012+0.002D+.005+015V?    384  0.7   2.8ABxC 3*
+3662 18    UMaBD+54 1285  79439 271912734          DD UMa   090859.6+542606091611.3+540119163.08 42.66 4.83  +0.19 +0.08 +0.09   A5V                +0.049+0.061 +.042-019SB    157                 *
+3663          CP-61 1201  79447250471                       090900.4-615424091116.6-621902280.22-09.61 3.97  -0.18 -0.67 -0.18   B3III             v-0.043+0.009      +018       21                 *
+3664          BD+35 1966  79452 61361      W                090906.0+350246091514.3+343801189.73 43.56 5.97  +0.86 +0.37 +0.47   G6III              -0.148+0.053      +056           3.5 150.6       
+3665 22The HyaBD+02 2167  79469117527 347    7253   4425    090909.7+024411091421.9+021851228.77 32.53 3.88  -0.06 -0.12 -0.05   B9.5V              +0.129-0.310 +.027-010SB     81  7.7  27.1AB   4*
+3666          BD+74  393  79517  6816                       090937.0+742612091955.8+740059138.66 35.89 6.50R                     G8III              -0.037-0.067      +056                           
+3667          CD-38 5376  79523200119               4423    090929.5-381211091325.9-383659263.09  6.85 6.31   0.00 +0.01         A0V                +0.008-0.012      +004                           
+3668          CD-41 4904  79524220962                       090932.3-415144091318.6-421625265.75  4.32 6.29  +1.25               K2III              -0.017+0.054      +029                           
+3669 82Pi 2CncBD+15 2009  79554 984562733I                  090942.6+152123091513.8+145629215.07 38.49 5.34  +1.32 +1.33         K1III              -0.044-0.012      +026                          *
+3670          CD-46 5010  79621220965                       091003.7-465531091334.5-472019269.46  0.87 5.92  -0.05 -0.10 -0.01C  B9Ve              v-0.016+0.003      +019                          *
+3671 NGC 2808                                               0 0 0      0 0 0 0 0      0 0                                                                                                           *
+3672          CD-43 5068  796942209722731           4428    091027.1-434355091408.2-440845267.21  3.14 5.85  -0.12 -0.50 -0.06C  B5/6IV/V           -0.019+0.014      +022V     260                 *
+3673          CP-58 1432  79698236723                       091018.5-590004091255.6-592452278.19-07.49 5.54  +0.85               G6II                0.000 0.000      +016                           
+3674          CD-42 5086  79735220978      W                091040.5-424847091424.5-431339266.58  3.81 5.25  -0.14 -0.56 -0.07C  B4V                -0.021+0.010 +.011+015V?    201  4.1   5.8      *
+3675          BD-14 2793  79752155032               4431    091041.2-143632091524.9-150129245.00 22.77 6.35  +0.02  0.00         A0V                -0.026-0.014      +032V?    148                  
+3676          BD+47 1658  79763 427902738                   091048.7+471403091731.2+464902172.82 44.02 5.97  +0.04 +0.05         A1V                +0.017+0.014      -012SBO    53                 *
+3677          CD-37 5578  79807200152                       091057.8-371112091457.2-373609262.55  7.76 5.86  +0.83               G0V                +0.011-0.013      -002                           
+3678   Zet OctCP-85  183  79837258515 918                   091114.3-851547085641.1-853947298.85-24.81 5.42  +0.31 +0.07         A8-9IV             -0.117+0.037      -004       81                  
+3679          CP-55 2035  798462367492736           4429    091120.0-550919091418.0-553411275.50-04.72 5.27  +0.99               G8II-III           -0.035+0.027 +.015+009                          *
+3680          CD-45 4982  79900220998      W                091137.2-450821091514.6-453320268.37  2.31 6.25  -0.08 -0.26 -0.02C  B8V                -0.003-0.010D+.006+033           0.9   0.8      *
+3681 23    HyaBD-05 2762  799101367252739I W                091143.7-055609091641.7-062111237.54 28.25 5.24  +1.17 +1.22         K2III              +0.024+0.006 +.008-008SB1O < 19: 5.6   1.6      *
+3682          CD-38 5408  799172001592737                   091140.2-380911091536.7-383412263.35  7.19 4.94  +1.11 +1.06 +0.57   K0III              -0.068-0.013 +.027+002                           
+3683 24    HyaBD-08 2623  79931136728                       091147.4-081938091641.3-084441239.73 26.85 5.47  -0.09 -0.30         B9III              -0.020+0.004      +010V?    121                  
+3684          CD-36 5505  79940200163      W                091144.9-365946091545.1-372448262.52  8.00 4.62  +0.45 +0.10 +0.28   F5III              +0.026-0.010 +.064+006SB    100  9.8  11.3       
+3685   Bet CarCP-69 1023  80007250495 348                   091206.2-691819091312.0-694302285.98-14.41 1.68   0.00 +0.03 +0.02   A2IV              v-0.162+0.108 +.021-005V?    133                 *
+3686          BD+35 1971  80024 61387        7286           091216.0+354702091826.0+352151188.81 44.28 5.75R                     A8V                -0.041-0.024D+.005+022V     126  0.2   1.8       
+3687          BD-13 2808  80050155060                       091223.0-140920091707.5-143425244.90 23.37 5.84  +1.06 +0.90        gK0                 -0.048+0.012      -037                           
+3688          CD-44 5305  80057221010      W        4436    091224.2-442853091604.2-445355268.00  2.87 6.04  +0.28 -0.13 +0.22C  A1Ib               +0.017+0.009      +026           8.0   6.8      *
+3689          BD+12 2009  80064 98476        7285           091225.8+115512091751.4+113004219.39 37.66 6.41  +0.07 +0.11         A2IV               -0.012-0.003      -007SB     60  5.9  21.8      *
+3690 38    LynBD+37 1965  80081 61391        7292           091237.3+371333091850.7+364809186.81 44.47 3.82  +0.06 +0.06 +0.03   A3V                -0.030-0.122 +.042+004SB    165  2.1   2.7AB   4*
+3691          CP-57 1949  80094236772              Var?     091233.2-575817091517.5-582319277.65-06.57 6.02  -0.10 -0.43 -0.11   B7IV               -0.022-0.006      +016V                         *
+3692          CD-43 5103  80108221014               4437    091241.2-435052091623.1-441557267.58  3.35 5.12  +1.67 +1.94 +0.79C  K3Ib               +0.002-0.001 +.017-003                          *
+3693          CP-57 1951  80126236777                       091245.7-570938091535.0-573441277.09-05.98 6.32  +1.04               G8II               +0.003-0.003      +015                           
+3694          CD-38 5430  80170200185                       091301.8-385855091657.2-392405264.14  6.80 5.33  +1.17               K5III-IV           -0.009-0.031 +.027-000V                         *
+3695          CP-76  574  801942565942735                   091313.9-761448091212.3-763947291.43-18.99 6.14  +1.09 +0.99         K1III              +0.031-0.044      +001                           
+3696          CP-57 1961  80230236787               4440    091322.6-570722091612.2-573229277.12-05.89 4.34  +1.63 +1.98 +1.03   M1III              -0.014-0.007 +.025-005                           
+3697          BD+51 1495  80290 27215        7303           091347.4+514103092043.8+511558166.60 43.90 6.13  +0.42 -0.11         F3V                -0.035+0.150 +.036-008           4.0 142.1AC   3*
+3698          BD+57 1214  80390 272192743I         CG UMa   091422.9+570723092143.3+564157159.29 42.77 5.47  +1.61               M4IIIa             -0.010-0.008      +021V                         *
+3699   Iot CarCP-58 1465  80404236808 351           4444    091424.8-585120091705.4-591631278.46-07.01 2.25  +0.18 +0.16 +0.20   A8Ib               -0.020+0.008 +.017+013        0                 *
+3700          CP-53 2281  80435236819                       091437.0-540428091742.3-542943275.07-03.63 6.33  +1.41               K3III              -0.018-0.004      -009                           
+3701          BD+38 2025  80441 61411        7307           091443.5+383643092059.3+381118184.89 44.96 6.12  +0.38 -0.06         F2V+F4V            -0.044-0.013D+.018+001V?  =< 10: 0.3   1.2AB   3*
+3702          BD-10 2804  80447155090                       091444.0-105335091933.7-111851242.49 25.86 6.62  +0.08               A2V s              -0.084+0.036      +029                           
+3703          CD-50 4001  80456236824                       091446.1-503749091805.8-510304272.64-01.18 5.26  -0.07 -0.38         B7-8III            -0.023+0.008      +057SB                         
+3704          BD-15 2763  80479155091    I   7302           091449.9-152440091933.2-155004246.36 23.03 5.78  +1.29 +1.39         K4III              +0.052-0.046      -030V?         5.0   4.1      *
+3705 40Alp LynBD+35 1979  80493 61414 352I          4456    091457.8+344856092103.3+342333190.24 44.73 3.13  +1.55 +1.94 +0.90   K7IIIab           e-0.221+0.019 +.025+038                          *
+3706 26    HyaBD-11 2609  804991550962741I W                091457.3-113310091946.4-115830243.10 25.49 4.79  +0.93 +0.64 +0.47   G8III              -0.030+0.015 +.023-002V    < 19: 7.5   3.4       
+3707          BD+33 1848  80546 61424                       091523.3+331937092127.2+325407192.33 44.64 6.16  +1.09 +1.04         K3III              +0.011-0.035      +028                           
+3708          CD-51 3693  80558236837               4454    091524.1-510819091842.2-513338273.07-01.47 5.87  +0.54 -0.38         B6Iae              -0.014 0.000      +022       73                 *
+3709 27    HyaBD-08 2643  80586136768    I   7311A          091536.0-090753092029.0-093321241.08 27.11 4.80  +0.93 +0.67 +0.44   G8III-IV+F5V       -0.014-0.029 +.022+025SB   < 19: 1.9 231.8AB   3*
+3710          CD-33 5973  805902002412742                   091539.0-334048091947.9-340612260.66 10.88 6.39  -0.10               B8V                -0.010-0.007      +026                           
+3711          BD+15 2027  80613 98517                       091544.1+154745092115.4+152216215.29 40.00 6.53  -0.01 +0.03         A1V                -0.036-0.015      +018      130                  
+3712          CP-68  918  80671250526      W                091553.5-681603091717.2-684122285.44-13.45 5.39  +0.42 -0.03         F4V                -0.109-0.020 +.058+032        0  0.0   0.1AB   3*
+3713          CP-66 1002  80710250529                       091608.3-663746091751.7-670303284.25-12.30 6.11  +1.26 +1.10         K2III              -0.003+0.014      +001V                          
+3714          BD-14 2828  807191551142744                   091611.5-151126092055.5-153704246.41 23.42 6.33  +0.46 +0.02        dF6                 +0.065-0.107      -001SB                         
+3715          CD-31 7162  80773200258      W                091630.2-312009092044.2-314538259.07 12.64 6.82   0.00 -0.04         B9.5V              -0.034-0.011      +018V?         0.8   2.9      *
+3716          CD-37 5668  80774200257                       091628.5-370924092029.6-373453263.30  8.57 6.05  +1.39               K3/4III            -0.017-0.018      +007                           
+3717          CP-54 2186  80781236851                       091629.1-544547091932.6-551112275.75-03.92 6.28  -0.10 -0.57 -0.06   B5V                -0.004 0.000      +013       53                 *
+3718   The PyxCD-25 7114  808741773221243I                  091703.9-253223092129.6-255756254.81 16.72 4.72  +1.63 +2.02 +1.08   M1III              -0.011-0.008 +.010+020                           
+3719          BD+75  377  80930  68582749                   091721.3+753143092751.6+750554137.18 35.80 6.29  +0.07 +0.11         A5V s              -0.014+0.015      +001       55                  
+3720          CP-74  579  80951256599      W                091736.1-742821091725.4-745340290.24-17.59 5.29  +0.02 +0.04         A1V                -0.015+0.030      +011        0  0.5   0.2AB   4*
+3721          CP-74  580  80950256600                       091735.3-741846091727.4-744405290.11-17.49 5.86  -0.02 -0.04         A0V                -0.041+0.033                                     
+3722          BD+64  733  80953 14875    I                  091741.2+642216092544.2+635627149.91 40.80 6.28  +1.46 +1.74         K2III              -0.008-0.041      +007                           
+3723          BD+25 2088  80956 80797                       091744.6+253637092331.8+251059203.02 43.64 6.41  +0.82 +0.52:        G5IV               -0.121+0.005      -001V                          
+3724          BD-09 2816  81009136799        7334  KU Hya   091758.2-092440092250.9-095020241.74 27.40 6.53  +0.22 +0.11         A5pSrCrEu          -0.027-0.021      +023     < 10  0.1   0.1AB   3*
+3725          BD+52 1389  81025 27246        7348           091759.6+520010092455.7+513426166.00 44.47 6.31  +0.75               G2III              +0.041-0.005      -016SB         2.2   1.4      *
+3726          CD-41 5023  81034221103                       091800.4-414601092150.9-421142266.80  5.51 5.58  +1.63 +1.94         M1III              +0.053-0.060      +049                           
+3727          BD+37 1978  81039 614562748                   091811.8+370059092422.5+363513187.21 45.57 6.67  +0.21 +0.10         F0V                -0.068-0.024      +015                           
+3728          CP-61 1242  811012505442745                   091832.7-615842092056.8-622417281.06-08.85 4.81  +0.94 +0.62 +0.54   G6III              -0.013+0.002 +.017+051                           
+3729          CD-39 5446  81134200299                       091840.6-392058092236.7-394629265.17  7.32 6.54  +1.13               K1III              -0.063+0.074      +023                           
+3730          CD-45 5099  811362211092746           4473    091844.8-453714092224.0-460251269.60  2.86 5.75  +0.92 +0.65 +0.43C  G6-8III            +0.004+0.027      -007                          *
+3731  1Kap LeoBD+26 1939  81146 808071244I   7351   4478    091849.9+263646092439.3+261056201.76 44.13 4.46  +1.23 +1.31 +0.63   K2III              -0.033-0.048 -.003+028     < 19: 5.1   2.5AB   3*
+3732          CP-54 2213  81157236887                       091847.3-550523092150.0-553054276.21-03.92 5.63  +0.19 +0.11         A3IV s:            -0.065+0.060      +059       34                  
+3733   Lam PyxCD-28 7196  811691773742747I                  091852.4-282422092312.3-285002257.26 15.04 4.69  +0.92 +0.63 +0.47   G8.5IIICN-1.5*     -0.123+0.019 +.038+010                          *
+3734   Kap VelCP-54 2219  81188236891 353                   091901.0-543501092206.8-550039275.88-03.54 2.50  -0.18 -0.75 -0.19   B2IV-V             -0.008+0.009 +.013+022SBO    49                 *
+3735          CD-37 5721  81309200320                       091943.6-371942092344.8-374526263.89  8.90 6.48  +0.18               A1mA5-F0           -0.083+0.017      +020                           
+3736          BD+17 2078  81361 985612750                   092000.1+170102092532.5+163508214.32 41.41 6.29  +0.97              gG9                 -0.084-0.025 +.016+012V                          
+3737          CD-38 5541  81411200330      W                092018.0-385941092416.3-392533265.15  7.80 6.06  +0.20 +0.10 +0.12   A7V:               +0.012-0.036      +008V          0.0   0.1      *
+3738 28    HyaBD-04 2616  814201368321245I                  092024.0-044110092524.0-050703237.84 30.73 5.59  +1.52 +1.82         K5III              -0.012-0.008      +005V                         *
+3739          CD-51 3767  81471236930                       092038.8-511825092359.5-514414273.78-01.01 6.08  +0.57 +0.37         A7Iab              +0.013-0.002      +018       62                 *
+3740          CP-59 1374  81502250561                       092047.7-595221092327.4-601809279.76-07.16 6.30  +1.48 +1.68         K1-2II-III         -0.005-0.004      +022V?                         
+3741          BD-00 2195  81567136844                       092116.8-010153092622.3-012750234.48 33.03 6.01  +1.32 +1.44         K2IIIb             -0.001-0.003      -015                           
+3742          CP-61 1265  81613250563                       092133.5-611300092405.7-613856280.78-08.06 5.99  +1.06               K0III              +0.016-0.051      -008                           
+3743          BD+46 1509  81688 428762751  W                092206.8+460223092840.0+453605174.22 46.07 5.41  +0.98 +0.74         K0III-IV           -0.007-0.128      +039           2.5  77.3AB   3*
+3744 29    HyaBD-08 2678  81728136861        7382           092220.7-084723092714.6-091325241.94 28.63 6.54  +0.05 +0.02         A2V                -0.029+0.001      +030           0.0   0.3AB   3*
+3745          CD-28 7271  81753177461        7379   4492    092223.3-282114092644.8-284715257.78 15.63 6.10  -0.10 -0.55         B6Ve              v-0.027-0.001D+.005+004V          0.7   0.5      *
+3746          CD-39 5507  81780221167                       092232.0-400406092628.5-403007266.22  7.33 6.20  +0.25               A7III              +0.025+0.002      -003V                          
+3747          BD+56 1388  81790 27271                       092238.8+561057092947.6+554444160.10 44.12 6.45R                     F3V s              -0.132-0.033      +010                           
+3748 30Alp HyaBD-08 2680  81797136871 354I W        4496    092240.4-081330092735.2-083931241.49 29.05 1.98  +1.44 +1.72 +0.77   K3II-III           -0.014+0.033 +.022-004V?   < 17  7.5 283.1AB   3*
+3749          BD-21 2802  81799177469    I                  092243.7-215418092718.4-222038252.94 20.14 4.69  +1.14 +1.15 +0.56   K2.5III            +0.180-0.161 +.030+029                           
+3750          BD-05 2802  81809136872      W                092249.5-053803092746.8-060416239.15 30.65 5.38  +0.64 +0.13         G2V                -0.224-0.074 +.038+054SB2O=< 10  0.8   0.2      *
+3751          BD+81  302  81817  1551 910                   092251.2+814607093705.2+811935130.65 32.65 4.29  +1.48 +1.72 +0.74   K3IIIa             -0.019-0.014 +.017-005V    < 19:                 
+3752          CP-61 1271  81830250575      W                092257.8-613108092527.1-615701281.11-08.16 5.77  +0.15 +0.13         A4V                -0.129+0.061      +012           4.5   8.7      *
+3753          CP-52 2360  81848236972                       092302.7-525643092618.1-532245275.18-01.94 5.11  -0.11 -0.50         B6V                -0.008 0.000      +024SB    201                 *
+3754  2Ome LeoBD+09 2188  81858117717        7390           092306.1+092932092827.5+090324223.66 38.90 5.41  +0.60 +0.14         F9V                +0.055-0.004 +.034-006SBO        0.7   0.5      *
+3755  3    LeoBD+08 2226  818731177182752    7391           092309.7+083729092829.2+081118224.64 38.50 5.71  +1.04 +0.90         K0III              -0.027-0.030      +022V          5.3  25.2      *
+3756          CD-34 5895  81919200392      W                092329.2-343418092738.4-350028262.47 11.40 6.65  +0.20               A3                 -0.028-0.031      -028V          0.1   0.1       
+3757 23    UMaBD+63  845  81937 14908 355I   7402   4506    092338.9+632957093131.7+630343150.64 41.74 3.67  +0.33 +0.10 +0.18   F0IV               +0.109+0.028 +.041-010V     140  5.6  22.8AB   3*
+3758          BD-00 2201  81980136894        7396           092356.9-004913092902.2-011525234.73 33.70 6.27  +0.27 +0.11         F0Vn               -0.073+0.001D+.012+000      176  5.0   1.3       
+3759 31Tau1HyaBD-02 2901  81997136895      W                092404.3-021955092908.9-024608236.23 32.86 4.60  +0.46  0.00 +0.22   F6V                +0.130-0.015 +.072+010V?     28  3.0  65.7      *
+3760          BD-01 2268  82043136899                       092420.3-014605092924.5-021219235.72 33.23 6.14  +0.22 +0.16         F0III              -0.046-0.003      +016V                          
+3761          CP-64 1037  82068250583                       092434.1-642946092644.2-645547283.34-10.17 6.05  +0.15 +0.10         A3Vn               -0.056+0.063      +008                           
+3762          BD-03 2693  82074136900                       092431.1-034828092932.4-041450237.72 32.08 6.26  +0.84 +0.40         G6IV               -0.029-0.080      -012                           
+3763          BD-20 2915  82077177521    I                  092436.4-201844092912.6-204455252.00 21.54 5.66  +1.60 +1.85         M1III              -0.017+0.022      -008SB                         
+3764  7    LMiBD+34 1999  82087 615292755  W                092440.7+340543093043.2+333920191.56 46.65 5.85  +1.05              gG8                 -0.020-0.049      +002V          3.3  62.8AB   3 
+3765   Eps AntCD-35 5724  82150200416 356                   092507.0-353050092914.7-355705263.39 10.96 4.51  +1.44 +1.68 +0.76   K3IIIa             -0.022+0.001 +.005+022SB                         
+3766          CD-37 5817  82165200419                       092514.6-375757092916.3-382414265.13  9.21 6.19  +0.22               A7Vn               -0.085-0.013      +001                           
+3767          BD-22 2623  82180177541    I                  092517.8-225426092949.9-232043254.14 19.89 6.24  +1.57 +1.83         K0                 -0.002-0.003      -000V                          
+3768 22    UMaBD+72  462  82189  6898              Var      092527.9+723859093453.6+721220139.93 37.74 5.72  +0.48 -0.01         F7V                +0.075-0.077      -038                          *
+3769  8    LMiBD+35 2015  82198 61540    I          4510    092527.3+353244093132.4+350611189.47 46.93 5.37  +1.53 +1.81         M1IIIab            -0.056-0.102      +038                           
+3770          CD-26 7117  82205177546    I   7405           092528.1-260905092954.5-263523256.64 17.66 5.48  +1.36 +1.52         K3III              -0.022+0.002      +012V          8.6  11.6      *
+3771 24    UMaBD+70  565  82210  6897 357I         DK UMa   092538.7+701612093428.9+694949142.55 38.93 4.56  +0.77 +0.34 +0.41   G4III-IV           -0.063+0.077 +.042-027     < 19:                *
+3772          BD-14 2867  82232155246                       092538.3-150812093022.6-153438247.99 25.19 5.85  +1.20 +1.22        gK3                 -0.066-0.063      +024V?                         
+3773  4Lam LeoBD+23 2107  82308 808852756I          4514    092600.9+232433093143.2+225805206.69 44.86 4.31  +1.54 +1.89 +0.89   K5III             v-0.021-0.033 +.020+027V    < 17                 *
+3774          BD+74  402  82327  6900                       092607.6+744547093606.8+741904137.63 36.68 6.46  -0.10 -0.33         B9V                -0.016-0.070      -011V?                         
+3775 25The UMaBD+52 1401  82328 27289 358I   7420   4519    092610.3+520800093251.4+514038165.45 45.66 3.17  +0.46 +0.02 +0.27   F6IV               -0.954-0.531 +.052+015SB1O   12 10.7   4.1      *
+3776          CP-61 1277  82347250590                       092616.2-615009092847.0-621623281.62-08.11 5.92  +1.10 +0.97         K1III              -0.076+0.031      +000                           
+3777          CP-71  833  82350256623                       092607.3-711003092706.4-713608288.22-14.85 5.47  +1.08 +0.98 +0.38E  K2III              -0.102+0.075 +.036+003SB                        *
+3778          BD+50 1657  82380 42914                       092624.2+495247093307.2+492619168.59 46.19 6.76                      A4V                -0.024+0.009      -010V?                         
+3779  6    LeoBD+10 2014  82381117751    I   7416           092635.9+100924093157.6+094257223.42 39.97 5.07  +1.37 +1.53         K2.5IIIbFe-0.5     -0.003-0.013      +019SB   < 17  4.4  37.3      *
+3780   Zet1AntCD-31 7355  82383200444      W     B          092628.7-312703093045.4-315329260.70 14.07 7.00  +0.09 +0.09         A2V                -0.013-0.026D+.001-003           0.7   8.0      *
+3781   Zet1AntCD-31 7355  82384200445      W     A          092629.1-312656093046.1-315322260.70 14.07 6.18  +0.03 +0.03         A0V                +0.028-0.028D+.001-003V?         0.7   8.0      *
+3782  5Xi  LeoBD+11 2053  82395 986271246I D        4518    092633.3+114434093156.7+111759221.56 40.68 4.97  +1.05 +0.86 +0.52   K0-III-IIIb        -0.094-0.082 +.028+029V    < 19: 1.9   0.0      *
+3783          CP-66 1018  824062505912754                   092633.3-661554092830.6-664207284.74-11.30 5.91  +0.01 -0.02         A0V                -0.033+0.047      +029V                          
+3784          CD-50 4204  82419237042                       092640.4-510441093005.2-513102274.31-00.20 5.45  -0.10 -0.42         B8V                -0.004+0.009      +010                           
+3785          BD-09 2856  82428155257                       092646.4-100640093138.9-103308243.89 28.65 6.14  +0.24 +0.10         F0Vn               +0.014-0.020      -018SB    184                  
+3786   Psi VelCD-39 5580  82434221234      W        4513    092645.6-400144093042.0-402800266.78  7.91 3.60  +0.36 -0.03 +0.22   F3IV+F0IV          -0.182+0.073 +.065+009V     201: 0.5   0.7      *
+3787 32Tau2HyaBD-00 2211  82446136932                       092653.0-004437093158.9-011106235.15 34.34 4.57  +0.10 +0.09 +0.06   A3V                -0.012-0.011 +.027+006SB     70                  
+3788          BD-09 2858  82477155262                       092703.6-095547093155.8-102214243.78 28.82 6.13  +1.19 +1.17         K0                 -0.086+0.010      +064V?                         
+3789   Zet2AntCD-31 7369  82513200459                       092715.5-312551093132.2-315219260.80 14.20 5.93  +0.26 +0.16 +0.14   A9IV               -0.039+0.001      +022                           
+3790          CD-35 5751  82514200462      W                092722.5-351608093132.9-354254263.56 11.45 5.87  +1.29 +1.47         K4III              +0.143-0.177 -.004+014           8.2  23.6AB   3 
+3791  9    LMiBD+37 1998  82522 61561                       092722.1+365549093330.3+362913187.47 47.39 6.18  +1.27              gK4                 +0.031-0.035      -017V                          
+3792          BD+29 1913  82523 809002760    7426           092727.0+284840093318.3+282205199.29 46.46 6.53  +0.12 +0.10         A3Vnn              -0.044-0.034      +026V          5.2  30.5      *
+3793          CP-57 2090  82536237056      W        4516    092728.2-575520093023.4-582142279.04-05.15 5.88  +1.70 +1.68         M2III              -0.031+0.028      +003V          7.7   2.3      *
+3794          BD+02 2217  825431177572758  W                092731.2+021825093241.4+015151232.17 36.18 6.11  +0.62 +0.27         F7IV-V             -0.020-0.038      +028    =< 10  0.0   0.1       
+3795   Iot ChaCP-80  350  825542585302753                   092729.2-802118092409.1-804713295.18-21.22 5.36  +0.45 +0.06         F3-5IV            v-0.146+0.140      +007      123                 *
+3796          BD-18 2708  825731552732757                   092741.5-185731093220.4-192401251.46 23.00 5.74  +0.14 +0.12 +0.04   A5V                -0.036+0.010      +027       74                  
+3797          BD+47 1683  82582 42924                       092745.7+472045093419.6+465408172.15 46.86 6.52  +0.22 +0.09         F0V                -0.062-0.008      +011      142                  
+3798          CD-28 7373  82610177619              S Ant    092755.7-281114093218.5-283741258.55 16.62 6.46  +0.33               A9V                -0.072+0.039      +015SBO   113                 *
+3799 26    UMaBD+52 1402  82621 27298                       092758.5+522946093449.5+520305164.83 45.85 4.50  +0.01 +0.04 +0.01   A2V                -0.065-0.035 +.025+023V     180                  
+3800 10    LMiBD+37 2004  82635 61570 360I         SU LMi   092805.9+365030093413.4+362351187.61 47.53 4.55  +0.92 +0.62 +0.46   G8.5III            +0.006-0.022      -012V    < 19:                *
+3801          BD-07 2836  82638136945                       092806.7-080342093302.1-083019242.30 30.20 6.12  +0.98 +0.71         K0                 -0.020-0.034      +036                           
+3802          BD-12 2926  826601552812761I                  092807.6-130427093255.8-133101246.70 27.00 5.94  +1.50 +1.74         K5III              -0.008+0.003      +028                           
+3803          CP-56 2270  82668237067 361          N Vel    092810.9-563535093113.3-570204278.21-04.11 3.13  +1.55 +1.89 +0.89   K5III              -0.032+0.004 +.022-014                          *
+3804          BD+24 2104  82670 80909    I                  092816.6+235359093359.1+232714206.23 45.50 6.25  +1.46              gK7                 -0.052-0.087      -006V?                         
+3805          BD-06 2939  82674136951                       092822.8-064447093320.1-071124241.15 31.07 6.24  +1.17 +1.25         K0                 -0.033-0.012      +029SBO                       *
+3806          BD+73  470  82685  6915        7446           092823.5+733139093756.2+730450138.84 37.47 6.42R                     F2V+F1V            -0.041-0.026D+.017+000           0.1   4.7      *
+3807          CD-40 5284  826942212622759  W                092821.0-401225093219.3-403858267.13  7.99 5.35  +0.90               G8III              +0.011-0.012 +.024-001           3.6   1.1       
+3808          BD-20 2936  827341776421247I                  092836.1-204023093312.5-210657252.97 21.98 5.01  +1.02 +0.87         K0IV               -0.020+0.015 +.052+013                           
+3809          BD+40 2224  82741 615782762I                  092849.6+400356093503.8+393717182.83 47.71 4.81  +0.99 +0.76 +0.53   G9.5IIIFe-1        -0.030+0.022      -012     < 19:                 
+3810          BD-22 2645  82747177649                       092852.9-222519093326.2-225150254.38 20.82 5.91  +0.02               A0Vn               -0.049+0.060      +015                           
+3811          BD+40 2226  82780 42931        7438A          092907.3+402428093522.4+395748182.32 47.76 6.76  +0.35  0.00         F2V                -0.016+0.012      -035SBO    45  1.4  24.9AB   3*
+3812          CD-38 5676  82785200492      W                092905.9-384112093307.8-390744266.19  9.20 6.43  +0.33               F0IV               -0.029+0.049      +025           3.5  55.2       
+3813          CP-66 1025  82858250611                       092932.5-661636093132.9-664310284.97-11.11 6.27  +1.35 +1.38         K1III              -0.027-0.006      +004                           
+3814 33    HyaBD-05 2840  828701369642763I                  092933.2-052807093432.7-055454240.18 32.09 5.56  +1.16 +1.13 +0.41E  K1III              +0.011-0.059      +013V                         *
+3815 11    LMiBD+36 1979  82885 61586        7441  SV LMi   092939.7+361545093539.6+354837188.49 47.81 5.41  +0.77 +0.44 +0.37   G8V                -0.706-0.241 +.109+013V?   < 17  8.5   3.3      *
+3816          CP-62 1253  82901250614    I:W       R Car    092943.6-622046093214.6-624720282.27-08.21 6.10  +1.43 +0.23 +2.51   M6-7IIIep         v-0.036+0.020      +028V          7.3   2.1      *
+3817          CD-48 4802  82984221288      W                093009.1-483338093344.5-490018273.03  2.04 5.12  -0.12 -0.58         B4IV               -0.016+0.010D+.015+017V     117  0.8   2.1      *
+3818  7    LeoBD+15 2077  83023 98662        7448A          093025.0+144934093552.9+142247218.36 42.85 6.36  +0.01 +0.03         A1V                -0.038 0.000 +.006+020       92  3.2  41.2     3*
+3819          CD-50 4270  830582371072764                   093040.7-504836093408.8-511519274.60  0.42 5.01  -0.18 -0.94         B1.5IV             -0.003+0.004      +035SB    207                  
+3820          BD+31 2011  83069 615942765I          4545    093046.9+313636093642.9+310942195.41 47.63 5.56  +1.59 +1.86         M2IIIa             +0.003-0.039      -020V?                         
+3821          CP-72  835  83095256634 362                   093051.4-723814093136.3-730451289.55-15.64 5.47  +1.56 +1.75         K4III              -0.027+0.001      +014                           
+3822          BD-18 2728  83104155323      W                093054.7-190809093533.7-193501252.17 23.43 6.31  +0.06 +0.03         A2V                -0.038-0.046      +016V?         3.2  51.5       
+3823          CD-35 5803  83108200531                       093102.2-352238093511.8-354926264.18 11.89 6.49  +0.42               F7III-IV           -0.072-0.002      +013                           
+3824          BD+67  602  83126 149492769I                  093110.6+674322093927.9+671620145.15 40.59 5.94  +1.52               K5                 -0.026-0.040      +019                           
+3825          CP-58 1576  83183237117                       093132.6-584701093426.7-591346280.02-05.43 4.08  +0.01 -0.56 +0.01   B5II               -0.012+0.014      +022V?      0                 *
+3826  8    LeoBD+17 2109  83189 986732766I D                093131.5+165310093702.6+162616215.91 43.91 5.69  +1.25              gK1                 -0.014-0.006      +006                          *
+3827 10    LeoBD+07 2160  832401178072767I          4551    093155.9+071703093712.7+065009227.52 39.73 5.00  +1.05 +0.87         K1III             v-0.060+0.001 +.019+020SB   < 17                  
+3828          CD-24 8263  83261177738      W                093203.3-241523093633.7-244210256.32 20.05 6.53  +0.38               F2                 -0.119+0.060      +024           0.0   0.1       
+3829 42    LynBD+40 2232  83287 42958                       093207.2+404120093821.7+401423181.86 48.31 5.25  +0.22 +0.12         F0V                -0.017+0.006      -003V      96                  
+3830          CD-24 8272  83332177748                       093230.3-245057093700.2-251748256.84 19.71 5.70  +1.12              gK1                 -0.062+0.043      +030                           
+3831          CD-48 4831  83368221339      W       IM Vel   093247.7-481808093625.3-484505273.18  2.52 6.17  +0.27 +0.15         ApSrEuCr           -0.011-0.024D+.021-004       33  2.4   3.1      *
+3832 34    HyaBD-08 2725  83373137011                       093257.3-085830093751.5-092528244.00 30.55 6.40  -0.04 -0.09         A1V                -0.062+0.002      +025    =< 41                  
+3833          CD-31 7458  833802005611248                   093251.6-314345093709.9-321043261.91 14.81 5.63  +1.02               K0III              +0.034-0.020      -003                           
+3834          BD+05 2207  834251178211249I                  093314.3+050604093827.3+043857230.16 38.88 4.68  +1.32 +1.46 +0.71   K3III              -0.163-0.051 +.011+045V    < 19:                *
+3835          CD-35 5833  83441200573                       093318.2-353847093728.3-360545264.72 12.00 5.98  +1.12               K2III              -0.035-0.001      +020                           
+3836          CD-48 4836  834462213442768  W                093314.8-485424093649.6-492119273.64  2.12 4.35  +0.17 +0.13 +0.10   A5IV-V             -0.125+0.025 +.019+021      144  8.7  25.7       
+3837          CP-52 2612  83465237144                       093324.1-522950093646.3-525639276.03-00.56 6.19  +1.05 +0.89         K0III              -0.120+0.081      +034                           
+3838          BD+69  531  83489 14966 363                   093341.5+694134094214.8+691415142.76 39.82 5.69  +1.14              gG9                 -0.067-0.070      -009V?                         
+3839 27    UMaBD+72  466  83506  69362772I                  093345.1+724226094257.2+721509139.45 38.23 5.17  +1.04 +0.90         K0III              -0.026-0.030      -017V?   < 19:                 
+3840          CP-53 2646  83520237149      W                093351.8-531306093712.3-534007276.56-01.05 5.45  +0.15 +0.08         A2-3V              -0.054-0.017      -013           0.0   0.5      *
+3841          CP-64 1049  83523250636                       093345.8-643009093605.1-645702284.08-09.50 6.56  +0.10 +0.11         A2V                -0.040+0.036      +016                           
+3842          CD-42 5462  835482213552771                   093407.0-424422093801.5-431128269.65  6.84 5.50  +1.00 +0.68 +0.43C  G8II               +0.032-0.037 +.020+002                          *
+3843          BD+78  317  83550  6948                       093410.8+783526094530.8+780805133.41 34.91 6.23  +1.35               K2III              +0.004+0.003      -027                           
+3844          CD-39 5697  83610200590      W                093438.0-390939093840.7-393651267.32  9.58 6.70  +0.49               F5                 -0.044-0.062      +002V?         2.0   0.5      *
+3845 35Iot HyaBD-00 2231  836181370351250I          4568    093444.9-004120093951.4-010834236.49 35.98 3.91  +1.32 +1.46 +0.67   K2.5III-IIIbBa0.3  +0.049-0.064 +.026+023V?   < 17                 *
+3846 37    HyaBD-09 2898  83650155377                       093454.4-100705093947.4-103413245.37 30.18 6.31  -0.03 -0.14         A0Vn               -0.024+0.005      +014V     127                  
+3847          BD+79  319  83727  69562780                   093527.0+793543094718.0+790812132.39 34.35 6.17  +0.25 +0.12         F0V:               -0.031-0.021      -007                           
+3848          BD-10 2888  83731155387                       093527.2-101857094020.1-104609245.65 30.16 6.37  +0.08               A2V                -0.004-0.001      -011V                          
+3849 38Kap HyaBD-13 2917  83754155388 364           4576    093530.7-135243094018.4-141956248.71 27.81 5.06  -0.15 -0.57 -0.15   B5V                -0.027-0.020      +018V?    185                 *
+3850          BD+31 2026  83787 61633    I W       DR Leo   093540.2+314356094135.2+311641195.43 48.68 5.89  +1.60 +1.77 +0.97   K6III              +0.030-0.001      -013           7.5  28.4      *
+3851 43    LynBD+40 2241  83805 616362773                   093548.7+401249094200.3+394528182.53 49.03 5.62  +0.95 +0.68 +0.46   G8III              -0.050-0.045 +.018+030V?   < 19:                 
+3852 14Omi LeoBD+10 2044  83808 98709 365I   7480           093548.8+102050094109.0+095332224.60 42.06 3.52  +0.49 +0.21 +0.23   F6II+A1-5V         -0.142-0.037 +.034+027SBO =< 50  0.2   0.0     3*
+3853 13    LeoBD+26 1991  83821 80970                       093553.3+262205094138.5+255446203.37 47.78 6.24  +1.25       +0.66  gK2                 -0.014-0.033 +.013-026V?                         
+3854          BD+49 1868  83869 429902774                   093608.6+485312094243.1+482552169.53 47.95 6.39  -0.01  0.00         A1V                -0.030-0.017      -008SB2    86                  
+3855          BD+55 1345  83886 273592775                   093612.0+544913094307.0+542149161.12 46.36 6.47  +0.13 +0.09 +0.02   A5m                -0.035-0.034      +021      100                  
+3856          CP-60 1477  83944250653               4577    093634.8-605231093921.0-611941281.89-06.57 4.52  -0.07 -0.21 -0.08   B9IV-V             -0.041+0.021      +020V      68                 *
+3857 13    LMiBD+35 2042  83951 616482776                   093641.1+353302094242.7+350536189.66 49.21 6.14  +0.36  0.00         F3V                -0.021-0.052      -008V      12                  
+3858          BD-22 2684  83953177840      W                093643.2-230812094117.0-233530256.29 21.60 4.77  -0.12 -0.58 -0.09   B6Ve              v-0.028-0.004      +026      332  5.2  54.7      *
+3859          BD+65  731  83962 14976                       093644.8+652626094436.7+645902147.47 42.17 6.17R                     F3Vn               -0.049+0.012      -028      116                  
+3860   Zet ChaCP-80  365  83979258538              Zet Cha  093650.1-802931093353.2-805629295.57-21.04 5.11  -0.14 -0.57 -0.18   B5V                -0.043+0.007      -042SB     88                 *
+3861 15    LeoBD+30 1901  84107 616561251                   093741.6+302603094333.3+295828197.47 48.93 5.64  +0.12 +0.08 +0.03   A2IV               -0.018-0.100      +016                           
+3862          CD-23 8646  84117177866                       093743.6-232800094214.4-235456256.70 21.53 4.94  +0.53  0.00 +0.28   F9IV               -0.395+0.260 +.080+034V?                         
+3863          CP-57 2228  84121237221      W                093737.7-573143094042.5-575901279.79-03.95 5.32  +0.20 +0.10         A3IV               -0.034+0.006 +.031+007SB     39  0.2   0.2      *
+3864          CP-56 2435  84152237224                       093752.4-564811094102.2-571535279.35-03.38 5.80  +1.09 +0.98         K0-1III            +0.081-0.043      +039                           
+3865 28    UMaBD+64  752  84179 14980      W                093813.9+640648094555.4+633912148.96 42.93 6.34  +0.31 -0.02         F2V                -0.012-0.043      -027SB    101  5.2   6.4      *
+3866 16Psi LeoBD+14 2136  84194 987331252I W        4594    093817.2+142846094343.9+140118219.89 44.44 5.35  +1.63 +1.95         M2IIIab            +0.004-0.003      +008           5.3 281.8       
+3867          CD-34 6097  842242006522777                   093828.1-350242094241.4-353006265.10 13.16 6.41  -0.06 -0.37         ApSi               -0.014+0.007      +017                           
+3868          CP-54 2594  84228237237                       093830.0-544527094147.8-551251278.08-01.77 6.00  -0.13 -0.58         B4V                -0.018-0.004      +014                           
+3869          BD+19 2251  84252 98742      W                093856.4+191925094430.0+185149213.60 46.44 6.50R                     K0                 -0.007-0.054      -001           6.0  31.2       
+3870          BD+57 1231  84335 27377    I         CS UMa   093926.9+573514094631.7+570741157.15 45.82 5.2   +1.62 +1.80         M3IIIab            +0.004+0.034      +008V                         *
+3871   The AntCD-27 6881  84367177908 366  W                093944.6-271842094412.1-274610259.89 19.06 4.79  +0.51 +0.35 +0.32   A8V+F7II-III       -0.047+0.035 +.053+024V?         0.2   0.1      *
+3872          CD-50 4420  84400237260      W       IP Vel   093954.0-504611094327.5-511342275.67  1.41 6.15  -0.10 -0.46         B6V                -0.024-0.004      -023V          4.7   2.1      *
+3873 17Eps LeoBD+24 2129  84441 81004 367I          4613    094010.5+241405094551.1+234627206.82 48.21 2.98  +0.80 +0.47 +0.44   G1II               -0.046-0.011 +.010+004V?   < 17                 *
+3874          CD-38 5850  84447200681                       094010.6-390643094415.8-393416268.11 10.32 6.82  +0.30               F2-3V              -0.029+0.008      +005                           
+3875          CP-53 2788  84461237268                       094018.5-532600094342.2-535330277.43-00.59 5.56  -0.04 -0.08 -0.07   A0IV               -0.068+0.022      +010V      16                 *
+3876          BD+07 2181  845421178982781I                  094053.5+071013094610.0+064231229.14 41.59 5.79  +1.64 +1.96 +0.81E  M1.5IIIab          +0.004-0.022      +003V                         *
+3877 18    LeoBD+12 2090  84561 98755    I                  094100.1+121615094623.3+114836223.07 44.08 5.63  +1.49              gK4                 -0.017+0.015      +030V                          
+3878          CD-29 7758  84567177939                       094058.0-294433094521.8-301210261.83 17.45 6.45  -0.13 -0.94         B0.5IIIn           -0.032+0.001      +033                          *
+3879          BD+02 2246  846071179012782                   094114.0+021453094623.6+014708234.63 38.99 5.65  +0.34 +0.12         F4IV               -0.056-0.041      +015SB                         
+3880 19    LeoBD+12 2095  84722 98767      S                094203.4+120151094725.9+113406223.53 44.20 6.45  +0.43 +0.09         A7Vn               -0.053+0.005      -004           0.2   0.0      *
+3881          BD+46 1551  84737 430461255                   094208.5+462913094835.4+460116172.78 49.43 5.09  +0.62 +0.10 +0.34   G0.5Va             +0.224-0.092 +.073+005V       3                  
+3882          BD+12 2096  84748 98769    I         R Leo    094210.8+115334094733.5+112544223.72 44.16 6.02  +1.30 -0.20 +3.24   M8IIIe            v+0.002-0.042 +.020+013V?                        *
+3883          CP-56 2499  84809237314               4623    094228.3-564328094540.5-571108279.78-02.92 6.46  -0.11 -0.58         B8III-IV           -0.031+0.017      +011V?                        *
+3884          CP-61 1333  848102506831254          l Car    094230.0-620248094514.8-623028283.20-07.00 3.69  +1.22 +0.85 +0.68   G5Iab-Ib          v-0.014+0.007 +.027+003V                         *
+3885          BD+66  637  84812 15000                       094233.3+660332095023.7+653536146.34 42.38 6.31  +0.28 +0.12         A9Vn               -0.052-0.029      -007      176                  
+3886          CD-44 5846  84816221484              Var?     094236.3-441733094630.4-444518271.85  6.67 5.55  -0.18 -0.72 -0.15   B2.5IV             -0.008+0.002      -004SB    114                 *
+3887          CP-58 1640  84850237321                       094251.5-582001094555.4-584739280.84-04.12 6.22  +0.46               F5IV               -0.123+0.059      +006                           
+3888 29Ups UMaBD+59 1268  84999 27401 368I   7534  Ups UMa  094352.9+593033095059.4+590219154.31 45.58 3.80  +0.29 +0.10 +0.16   F2IV               -0.293-0.151 +.041+027V?    110  8.6  11.3      *
+3889 20    LeoBD+21 2113  85040 810352785  W       DG Leo   094414.3+213844094950.1+211046210.95 48.37 6.09  +0.25 +0.18         A7IVn              -0.043-0.012      +026SB2O  139  0.3   0.3      *
+3890   Ups CarCP-64 1084  85123250695      W     A          094436.1-643629094706.1-650419285.04-08.82 3.01  +0.28 +0.18         A6Ib               -0.012+0.011 +.027+014        0  3.0   5.0      *
+3891   Ups CarCP-64 1084  85124250696      W     B          094436.7-643632094706.7-650421285.04-08.82 6.26  +0.08 -0.54         B7III              -0.011+0.023 +.027+014           3.0   5.0      *
+3892          CD-36 5955  85206200777                       094516.4-364315094928.1-371111267.30 12.79 5.97  +1.24               K1III              -0.084+0.023      +012                           
+3893  4    SexBD+05 2240  85217117937                       094517.8+044843095030.1+042037232.58 41.26 6.24  +0.48 -0.02         F7Vn               -0.147-0.055      +017SBO                       *
+3894 30Phi UMaBD+54 1331  85235 27408        7545           094518.2+543154095206.4+540352160.87 47.70 4.59  +0.03 +0.08  0.00   A3IV               -0.004+0.021 +.032-012       30  0.2   0.3      *
+3895          CP-55 2548  85250237370                       094522.7-555647094840.0-562443279.60-02.06 6.06  +0.94 +0.67         K0III              -0.056+0.014      +007                          *
+3896 23    LeoBD+13 2164  85268 98809    I                  094537.3+133202095102.0+130358222.18 45.65 6.46  +1.58 +1.92         M0III              +0.028-0.008      -009V?                         
+3897          CD-35 5961  85296200784                       094537.2-354807094951.3-361607266.74 13.54 6.37  +1.01               K0III              -0.022+0.002      +021V                          
+3898          CD-45 5470  85355221523      W                094604.1-451557094957.1-454358272.95  6.31 5.08  -0.10               B7III              -0.026+0.004      +012      130: 4.5  66.6      *
+3899  6    SexBD-03 2794  85364137183 370                   094611.6-034629095114.0-041436241.68 36.39 6.01  +0.17 +0.11         A8III              +0.013-0.028      -010V     101                  
+3900 22    LeoBD+25 2169  85376 81054                       094612.5+245207095153.0+242343206.42 49.69 5.32  +0.23 +0.08         A5IV               +0.006-0.179 +.040-002V?    126                 *
+3901          BD-05 2923  85380137185                       094622.6-054255095121.6-061054243.56 35.19 6.42  +0.58 +0.11         F8V                -0.125+0.060      +036V   =< 10                  
+3902   Nu  ChaCP-76  598  853962566582784                   094618.5-761835094620.6-764634292.94-17.65 5.45  +0.89 +0.57         G8III              +0.079-0.056 +.019+011                           
+3903 39Ups1HyaBD-14 2963  854441555422786I                  094640.0-142239095128.7-145048251.23 29.44 4.12  +0.92 +0.65 +0.47   G7-III             +0.017-0.026 +.021-015     < 19:                *
+3904          CD-46 5558  85483221538                       094651.8-462800095042.0-465604273.82  5.46 5.73  +1.08 +1.02         K0IIICNIb          -0.034+0.016      +017V                          
+3905 24Mu  LeoBD+26 2019  85503 81064 371I                  094704.6+262841095245.8+260025204.05 50.25 3.88  +1.22 +1.39 +0.58   K2IIICN1Ca1        -0.216-0.056 +.025+014V?   < 17                 *
+3906  7    SexBD+03 2280  85504117959               4656    094702.6+025514095212.2+022715234.98 40.57 6.02  -0.04 -0.08         A0V s              -0.181+0.092 +.011+097V   =< 41                  
+3907          BD+00 2573  855051179602788                   094704.4+003244095212.0+000432237.51 39.20 6.35  +0.94 +0.69         G9III              -0.022-0.032      +019                           
+3908          BD-15 2920  85519155553                       094713.1-160350095159.6-163205252.72 28.36 6.08  +1.04 +2.12         K0                 +0.026-0.067      +005V                          
+3909  8Gam SexBD-07 2909  85558137199        7555           094733.4-073803095230.4-080618245.57 34.17 5.05  +0.04 +0.06         A1V                -0.055-0.040 +.013+012V     114  0.5   0.4AB   3*
+3910          CD-45 5499  855632215471256                   094727.4-454333095119.8-461138273.43  6.10 5.62  +1.17 +1.16         K2III              -0.043+0.033      +018                           
+3911          BD+61 1151  85583 150232790  W                094745.7+613515095503.4+610658151.35 45.07 6.27  +1.05               K0                 +0.009-0.002      -011           6.8  12.2       
+3912          CD-45 5508  85622221553               4658    094748.8-460443095140.8-463252273.70  5.87 4.58  +1.20 +0.99 +0.63   G5Ib               -0.008-0.001 +.007+011SB1O                      *
+3913          CP-58 1673  856552374182789                   094805.0-585719095112.1-592533281.77-04.18 5.79  +1.36 +1.28         K2IVCNIV-Vp        +0.035-0.045      +024V                          
+3914          CP-62 1335  85656250721                       094806.8-621635095055.7-624443283.86-06.77 5.57  +1.32 +1.31         K1IIICNII          -0.007+0.007      +012                           
+3915          BD+06 2224  85709117975    I                  094827.8+062546095342.9+055730231.32 42.80 5.95  +1.66 +1.94 +0.93E  M2III              -0.008-0.006      -001V?                         
+3916          CD-26 7505  85725178130      W                094829.3-265151095258.0-271956261.10 20.70 6.30  +0.62               G1V                -0.284+0.093 +.015+023           4.0   1.3      *
+3917 31    UMaBD+50 1698  85795 274302793          SY UMa   094911.4+501731095543.0+494912166.65 49.63 5.27  +0.07 +0.12         A3III              -0.003+0.022 +.025-006      147                 *
+3918          BD+73  478  85841  7009 372                   094927.0+732118095822.8+725246137.93 38.80 5.83  +1.14              gK3                 -0.076-0.035      +004V?                         
+3919          CD-25 7585  858591781582792I                  094940.4-252743095412.3-255557260.31 21.92 4.88  +1.23 +1.30 +0.45E  K2+III-IIIb        -0.180+0.054 +.031+051V?                        *
+3920          CP-54 2816  85871237448               4668    094935.0-545407095300.0-552224279.41-00.87 6.48  -0.14 -0.86         B1IV               -0.018+0.001      -018SB    274                 *
+3921          BD-21 2935  85905178164                       094953.5-220054095431.7-222918257.84 24.51 6.24  +0.04               A2                 -0.038-0.031      +009                          *
+3922          BD+58 1224  85945 27438                       095015.4+575339095713.6+572506155.90 47.02 5.93  +0.89               G5III              +0.032-0.059 +.007-044V                         *
+3923          BD-18 2810  85951155588 373I                  095009.2-183208095452.2-190034255.24 27.09 4.94  +1.57 +1.93 +0.74E  M1III              -0.047-0.037 +.011+050SB                         
+3924          CD-50 4622  85953237464              Var?     095010.0-504028095350.2-510849276.87  2.51 5.93  -0.15 -0.73         B2III              -0.005-0.010      +010                          *
+3925          CD-44 5987  85980221592      W                095021.2-444840095417.6-451702273.25  7.14 5.71  -0.11 -0.56 -0.11   B3V                -0.020-0.008      +013V     156  2.4   5.3      *
+3926          BD+09 2262  860801180012794                   095107.9+092425095626.0+085559228.26 44.90 5.85  +1.13 +1.00        gK2                 -0.085+0.018 +.011+009                           
+3927          CD-49 4801  86087237483                       095108.1-494614095451.3-501438276.43  3.32 5.72  -0.01 -0.01         A0V                -0.029+0.012      +014SB2                       *
+3928 19    LMiBD+41 2033  86146 43115 374                   095133.7+413155095741.1+410320180.07 51.89 5.14  +0.46  0.00         F6V s              -0.117-0.025 +.040-010SB1O    0                 *
+3929          BD+46 1566  86166 431172798                   095138.4+455327095756.9+452452173.16 51.16 6.30  +1.11 +0.95         K0III              +0.011-0.030      +005                           
+3930          CD-40 5626  862112216172795                   095158.0-402057095605.4-404929270.68 10.82 6.41  +1.61 +1.99         M1III              -0.018-0.022      +058                           
+3931          CD-25 7622  86266178214        7591           095214.4-260430095646.5-263301261.22 21.85 6.28  +0.22 +0.11         A4V                -0.114+0.006      +011           4.4   3.4       
+3932          CD-32 6895  862672008892796                   095213.4-325637095635.5-332507265.93 16.61 5.84  +1.20               K1III              +0.038+0.016      +004                           
+3933          CD-26 7551  86301178216                       095223.0-270001095654.0-272830261.90 21.17 6.32  +0.17               A4V                -0.081+0.029      +014                           
+3934          BD+84  225  86321  16373955          Var      095236.9+842404100834.3+835506127.59 31.66 6.37  +1.52 +1.64         K0                 -0.004+0.007      -012                          *
+3935          CD-50 4662  863522375142797                   095240.8-505138095621.9-512010277.30  2.61 6.37  -0.17 -0.75         B2IV-V             -0.004-0.007      +009                           
+3936          BD+28 1824  86358 81120                       095242.8+281412095826.1+274532201.68 51.82 6.30R                     F3V                -0.117-0.034      +036SB2    75                 *
+3937 27Nu  LeoBD+13 2183  86360 988762800                   095250.6+125519095813.4+122641224.10 46.95 5.26  -0.04 -0.13         B9IV               -0.025-0.015 +.018+014SB     96                  
+3938          BD+09 2269  86369118023    I                  095249.7+084729095807.6+081851229.31 44.95 6.04  +1.36 +1.55        gK3                 +0.011-0.024      -019V                          
+3939          BD+57 1242  86378 274642802I                  095258.8+571725095951.7+564843156.48 47.60 5.48  +1.46 +1.82         K5III              -0.029-0.026      -013V                          
+3940   Phi VelCP-53 3075  86440237522 375  W                095321.0-540530095651.8-543404279.35  0.11 3.54  -0.08 -0.62 -0.08   B5Ib               -0.010+0.003      +014       45  8.3  37.2      *
+3941          CP-52 2980  86466237526              IV Vel   095333.4-520945095710.9-523820278.20  1.66 6.12  -0.13 -0.61         B3IV               -0.010-0.002      +019V?     30                 *
+3942          BD+30 1946  86513 811292803                   095350.2+300728095936.2+293843198.70 52.34 5.73  +1.06              gG9                 -0.095-0.039      -001V?                         
+3943          CD-47 5399  86523221644      W                095352.3-475613095742.5-482452275.67  5.04 6.05  -0.14               B3V                -0.016-0.015      +009SB         4.6  14.1      *
+3944          CP-70  953  866062566722799                   095425.4-705446095609.7-712322289.82-13.13 6.35  -0.08 -0.93         B9Ib               -0.020-0.002      -030                           
+3945 12    SexBD+04 2276  86611118041 376           4694    095431.8+035146095943.1+032305235.37 42.64 6.70  +0.27 +0.09         F0V                -0.066+0.022      -004SB    187                  
+3946          CD-23 8898  86612178271              Var?     095429.1-232821095906.1-235701259.77 24.14 6.21  -0.10 -0.68 -0.06   B4Ve              v-0.049+0.023      +015      220                 *
+3947   Eta AntCD-35 6050  86629200926 377  W                095434.8-352444095852.3-355328267.94 15.00 5.23  +0.31 +0.08         F1III-IV           -0.087-0.020 +.029+030           6.0  31.1      *
+3948          CP-63 1233  866342507602801                   095432.7-640052095715.2-642922285.51-07.68 6.58  +1.13 +1.08         K0-1III            -0.130+0.084      +045                           
+3949          CP-68 1011  86659250761                       095450.9-683729095659.7-690607288.40-11.31 6.20  -0.10 -0.62         B3V                -0.027 0.000      +016V?    135                 *
+3950 29Pi  LeoBD+08 2301  86663118044 378I          4699    095455.7+083127100012.8+080239230.01 45.26 4.70  +1.60 +1.93 +1.08   M2-IIIab          e-0.030-0.023 +.017+023V                         *
+3951 20    LMiBD+32 1964  86728 618081258  W                095514.8+322456100100.7+315525195.01 52.86 5.36  +0.66 +0.27         G3VaHdel 1         -0.528-0.428 +.053+056        3  3.2 407.       *
+3952          BD+22 2164  87015 811542807                   095714.4+222554100248.9+215657211.17 51.48 5.66  -0.19 -0.73         B2.5IV             -0.017-0.006      +003                           
+3953          CP-56 2746  87030237586      W                095710.4-562757100034.4-565648281.21-01.46 6.52  +0.98               K0III              -0.064+0.008      +010           6.5   7.6       
+3954          BD+54 1348  87141 275031259                   095757.7+542232100436.3+535330160.03 49.46 5.74  +0.48 +0.04         F5V                -0.022-0.002      -016       10                  
+3955          CP-52 3087  87152237612              Var?     095802.7-525255100140.5-532152279.18  1.49 6.20  -0.13 -0.69         B2.5V              -0.036-0.017      +006V     218                 *
+3956          CD-29 8034  871992009942808                   095821.0-300543100249.3-303439265.09 19.64 6.54  +1.19               K1III              -0.014+0.030      +014V?                         
+3957          CP-56 2770  87238237621                       095834.2-565204100158.0-572059281.60-01.67 6.20  +1.12               K1II               -0.041+0.027      +007                           
+3958          BD+53 1384  87243 27512                       095837.0+525121100510.5+522215162.14 50.15 6.14R                     A5IV               -0.004-0.020      -026SB    167                  
+3959          BD-08 2836  87262137326    I                  095844.5-090523100341.0-093426249.14 35.24 6.12  +1.66 +2.01         K0                 +0.005-0.011      +009V?                         
+3960          CP-59 1695  87283250782                       095849.1-595618100200.0-602515283.45-04.12 5.94  +0.26 +0.10         A9IV               -0.019+0.006      -002                          *
+3961 13    SexBD+03 2311  87301118086                       095857.6+034116100408.4+031204236.44 43.45 6.45  +0.40 -0.02         F4V                -0.075-0.097      +000SB                         
+3962          CD-24 8711  87318178357        7625           095905.3-244958100341.4-251900261.61 23.80 6.70   0.00  0.00         A0III-IV           -0.039+0.009      +012           5.5  16.1       
+3963          BD-17 3047  87344155704        7627AB         095916.9-173702100402.9-180606256.32 29.24 5.86  -0.06               A0V                -0.010-0.002      +019V      17  1.0  21.2AC   3*
+3964          CD-46 5759  87363221728                       095922.9-460907100320.5-463810275.34  7.03 6.12  +0.02               A0V                -0.029-0.010      +003                           
+3965          CD-23 8973  874271783671260                   095943.8-234805100421.0-241708261.00 24.68 5.70  +0.30               A8V                -0.114+0.023      +004V                          
+3966          CP-59 1752  87436237640                       095946.9-594141100259.9-601043283.41-03.86 6.19  +0.17               A6II-III           -0.013+0.005      -004                          *
+3967          CP-61 1431  87438250789               4720    095946.2-614023100249.4-620923284.58-05.45 6.42  +1.72 +1.90         K3Ib               -0.010+0.010      -008                           
+3968          CD-39 6100  874772010202809                   100010.9-392927100423.4-395833271.42 12.46 6.43  +1.30               K1III              -0.034-0.003      +047                           
+3969          BD+16 2077  87500 98944                       100015.4+161438100540.9+154527220.74 49.99 6.37  +0.37 +0.15         F2Vn               -0.078-0.017      +012      139                  
+3970 40Ups2HyaBD-12 3073  875041557131261           4725    100015.2-123447100507.5-130353252.46 33.06 4.60  -0.09 -0.27 -0.09   B9III-IV           -0.037+0.018      +028SB2    76                  
+3971          CP-61 1441  87543250795      W                100028.9-612358100334.3-615302284.49-05.18 6.14  -0.04 -0.43         B7IVne             -0.005+0.005D+.008+005           1.5   1.2      *
+3972          CD-35 6130  87606201037                       100055.6-355353100515.2-362302269.30 15.41 6.27  +1.11 +1.07         K1III              -0.010+0.003      +028                           
+3973 14    SexBD+06 2259  876821181112811  D                100133.6+060557100647.4+053641234.17 45.35 6.21  +0.94 +0.72         K1III              -0.034-0.013      +017V                         *
+3974 21    LMiBD+35 2110  87696 618742812           4736    100131.9+354356100725.8+351441189.47 54.26 4.48  +0.18 +0.08 +0.07   A7V                +0.053+0.004 +.050-018V     148                 *
+3975 30Eta LeoBD+17 2171  87737 98955 379  W        4738    100152.9+171501100720.0+164546219.53 50.75 3.52  -0.03 -0.21 +0.02   A0Ib               -0.002 0.000 +.003+003V      20  0.5   0.1      *
+3976          CD-46 5806  87783221773      W                100213.6-465252100611.3-472212276.17  6.73 5.08  +0.88 +0.55         K1IV+G5V           +0.011-0.057 +.017+021           1.7   0.7      *
+3977          BD-16 2974  878081557392813I                  100221.6-163908100709.5-170830256.19 30.45 5.60  +1.50 +1.68         K7III              +0.016-0.063      +011                           
+3978          CD-51 4471  87816237690              R Vel    100223.0-514204100607.1-521117279.02  2.84 6.52  +0.98 +0.82         K1III              -0.068+0.015      +005                          *
+3979          BD+32 1982  87822 61882        7651           100229.3+320542100815.9+313615195.72 54.37 6.24  +0.45 +0.01         F4V                -0.083-0.080      -008        8  0.3   0.2AB   4*
+3980 31    LeoBD+10 2112  87837 98964    I   7649           100235.8+102916100754.3+095951228.95 47.89 4.37  +1.45 +1.75 +0.76   K3.5IIIbFe-1       -0.080-0.061      +041V?   < 19: 7.7   7.9      *
+3981 15Alp SexBD+00 2615  878871373662814                   100249.1+000701100756.3-002218241.11 42.07 4.49  -0.04 -0.07 -0.05   A0III              -0.016-0.013 +.015+007V?      9                  
+3982 32Alp LeoBD+12 2149  87901 98967 380I   7654A  4750    100302.8+122722100822.3+115802226.43 48.94 1.35  -0.11 -0.36 -0.10   B7V               e-0.248+0.006 +.045+006SB    329  6.8 177.6AB   4*
+3983   Mu 1ChaCP-81  399  879712585543980                   100324.3-814351100043.7-821253297.28-21.29 5.52  +0.03 +0.05         A0IV               -0.031+0.032      +016SB2    76                  
+3984          CD-36 6156  88013201081                       100342.7-365040100801.7-372001270.36 14.99 6.36  +0.98               K0III              -0.011+0.003      +001V                          
+3985          BD-10 3000  88024155765                       100350.3-102342100845.7-105305251.36 35.23 6.53  +0.02 +0.02         A2V                +0.004-0.003      -009                           
+3986          BD-14 3036  88025155763                       100345.8-150721100835.5-153642255.27 31.80 6.27  -0.01 -0.04         A0V                -0.027+0.014      +009V      68                  
+3987          BD+41 2063  88161 43220                       100457.3+410911101058.9+403941180.10 54.43 6.32  +1.25              gK3                 -0.014-0.002      +014V?                         
+3988          BD-11 2818  88182155777                       100502.3-113613100956.5-120545252.65 34.57 6.24  +0.18 +0.15 +0.09   A5m                -0.005-0.036      -014                           
+3989 17    SexBD-07 2972  88195137385                       100509.4-075501101007.5-082430249.45 37.19 5.91  +0.02 -0.05         A1V                -0.026-0.001      +016V?    100                 *
+3990          CD-51 4507  88206237736                       100508.7-511914100856.3-514840279.15  3.40 4.86  -0.12 -0.69 -0.09   B3IV               -0.010+0.001      +014V     229                 *
+3991          BD-12 3101  88215155780                       100513.4-121917101005.9-124858253.29 34.08 5.31  +0.36  0.00         F5V                -0.125-0.113 +.028+023SB1O  148                 *
+3992          CD-35 6194  882182011092816  W                100513.1-352158100931.8-355124269.69 16.36 6.13  +0.60 +0.16         F8V                -0.437+0.014 +.048+041           4.7   2.3      *
+3993          BD+38 2110  88231 619142817I          4764    100517.3+375341101112.8+372407185.68 54.90 5.85  +1.29              gK3                 -0.021-0.031      +009                           
+3994 41Lam HyaBD-11 2820  88284155785 381I   7671           100542.7-115135101035.3-122115253.01 34.50 3.61  +1.01 +0.92 +0.48   K0IIICN1           -0.202-0.089 +.027+019SB1O < 19: 7.7 112.2AC   3*
+3995          CP-65 1248  88323250836      W                100555.3-651932100842.6-654855287.29-08.02 5.28  +0.98 +0.75         K0III              -0.072+0.042 -.014+000           4.2  63.3       
+3996 18    SexBD-07 2977  88333137395    I          4767    100557.5-075530101055.8-082506249.63 37.33 5.65  +1.30 +1.42         K2III              -0.006-0.044      +000V                          
+3997   Mu 2ChaCP-80  423  88351258561               4744    100603.1-810443100407.6-813357296.93-20.72 6.60  +0.92 +0.53         G6-8III            -0.046+0.047      -000V                          
+3998 34    LeoBD+14 2217  88355 98991        7674           100615.5+135056101138.2+132118225.08 50.28 6.44  +0.46 +0.02 +0.27   F7V                +0.040-0.036      -016           0.8   0.2      *
+3999          CP-60 1701  88366250840              S Car    100610.6-610335100921.9-613257284.85-04.51 5.60  +1.60 +1.75 +1.54   M2-3IIIe           -0.094+0.073      +289V?                        *
+4000          BD-06 3096  883721374002818                   100618.0-064925101117.8-071900248.70 38.16 6.25  +0.01 +0.01         A2Vn               +0.012-0.014      +013SB                         
+4001          CD-41 5658  88399221832                       100625.3-411310101037.9-414254273.45 11.77 5.98  +1.24 +1.40         K2-3III            +0.050-0.120      +033                           
+4002          CP-68 1034  88473250844      W                100701.7-681129100930.5-684100289.05-10.29 5.81  +0.02 -0.02         A0IV               -0.008+0.010D+.007+010           0.1   0.8AB   3 
+4003          CD-27 7266  88522178526        7681           100729.1-280644101202.9-283623265.45 22.43 6.28  +0.01 -0.01         A1V                -0.026-0.014      +018V?         0.1   0.1       
+4004 19    SexBD+05 2301  88547118164                       100736.1+050632101248.3+043653236.56 46.03 5.77  +1.18 +1.11        gK0                 -0.051-0.005      +032V?                         
+4005          BD-18 2870  88595155820                       100753.2-183922101237.8-190913258.87 29.82 6.44  +0.50               F6V                -0.236-0.116      +034                           
+4006          BD+27 1862  88639 81243                       100810.8+273751101349.8+270809203.65 55.08 6.04  +0.85               G3IIIFe-1          -0.018+0.002      +010SB                        *
+4007          CP-58 1979  88647237773              V368 Car 100809.6-582005101135.2-584941283.50-02.12 6.40  +1.66 +1.75 +1.52   M3III              -0.051+0.020      -010                          *
+4008          BD+60 1246  88651 151292821I         U UMa    100813.7+602852101507.7+595908150.91 47.77 6.25  +1.60               M0III             v+0.015+0.009      -021                          *
+4009          CP-57 2781  886612377762819          QY Car   100817.3-573400101146.5-580338283.08-01.48 5.72  -0.08 -0.91 -0.04   B2IVpne           v-0.010+0.012      +031      360                 *
+4010          CD-51 4560  88693237784                       100834.5-514012101223.0-520948279.79  3.41 6.16  +1.17               K2IIICNII          -0.041+0.046      +011                           
+4011          CD-26 7752  88699178544                       100843.3-263205101319.4-270144264.63 23.84 6.25  +0.31               A9mA8-F3           -0.056+0.038      +018V                         *
+4012          BD+21 2165  88737 81250                       100859.5+213957101429.7+211004213.71 53.85 6.02  +0.56 +0.12         F9V                -0.142-0.082      +017V?     11                  
+4013          CD-32 7158  88742201186                       100859.6-323218101324.8-330155268.58 19.10 6.38  +0.59 +0.09         G1V                -0.360+0.061 +.055+042                           
+4014 22    LMiBD+32 2005  88786 61953                       100921.8+315752101506.3+312805196.10 55.82 6.46R                     G8III              -0.037-0.001      +015V?                         
+4015          CD-39 6222  88809221877      W                100930.5-395102101345.9-402045273.12 13.23 5.90  +1.21 +1.25         K1III              -0.078+0.017      +018V          7.0   4.7       
+4016          BD+73  489  88815  7098                       100935.7+733425101801.1+730424136.52 39.75 6.40  +0.23 -0.02         F2V                -0.056-0.079      +016SB     42                  
+4017          CD-50 4924  88824237804                       100931.1-504413101322.8-511400279.38  4.27 5.28  +0.25               A7V                -0.041-0.026      +048      181                  
+4018          CP-59 1974  88825237799                       100938.3-592522101301.3-595505284.27-02.92 6.10  -0.08 -0.48 -0.02   B4Ve               -0.006 0.000      -002V?                        *
+4019          CD-39 6225  88836221883      W                100940.6-394852101356.6-401838273.13 13.28 6.35  +0.94               G8III              -0.026-0.002      +000           7.0  12.7       
+4020          CD-51 4578  88842237807      W        4788    100937.7-511538101328.0-514522279.69  3.84 5.78  +0.14               A3IV-V             -0.046+0.004      +018V?         1.5   0.3       
+4021          BD+71  534  88849  7099        7705A  4802    100947.4+713336101750.6+710338138.45 41.12 6.66  +0.32 +0.20         A7m                -0.031-0.048 +.026+011    =< 25  0.7  16.6AB   3*
+4022          CP-61 1517  889072508752822                   101005.6-610947101321.2-613932285.30-04.33 6.41  -0.11 -0.66         B2V                -0.019-0.002      +013SB     55                 *
+4023          CD-41 5713  88955221895 382I'                 101032.2-413735101444.2-420719274.33 11.88 3.85  +0.05 +0.06 +0.02   A2V                -0.145+0.045 +.034+007SB     91                 *
+4024 23    LMiBD+30 1981  88960 812582823                   101033.6+294832101614.4+291838199.96 55.90 5.35  +0.01 +0.01         A0Vn               -0.075-0.023      +016V     139                 *
+4025          CP-65 1273  88981250880                       101040.8-655236101330.6-662223288.01-08.19 5.16  +0.21 +0.18 +0.13   Am                 -0.039+0.004 +.012-015       24                 *
+4026 32    UMaBD+65  767  88983 151351262                   101046.5+653626101802.0+650630144.61 45.02 5.82  +0.12 +0.10         A8III              -0.087-0.009      -007V     100                  
+4027 24    LMiBD+29 2021  88986 81259                       101048.1+291058101628.1+284057201.09 55.88 6.49  +0.60 +0.16         G0V                -0.055-0.089      +030    =< 10                  
+4028          BD+18 2338  88987 99032        7704           101049.3+181417101616.1+174425219.37 53.09 6.55R                     A9IV               -0.006+0.001D+.014-008V          0.3   1.1      *
+4029          CD-35 6260  89015201211                       101057.8-360114101520.9-363105271.08 16.52 6.19  +1.06 +0.93         K0III              -0.033-0.005      +027                           
+4030 35    LeoBD+24 2207  89010 81260    I'                 101100.1+240001101632.3+233011210.07 54.94 5.97  +0.67               G1.5IV-V           -0.205+0.036 +.034-033SB  =<  6                  
+4031 36Zet LeoBD+24 2209  89025 81265 384I W        4804    101107.7+235457101641.4+232502210.23 54.95 3.44  +0.31 +0.20 +0.19   F0III              +0.018-0.007 +.017-016SB     84  2.3 325.9      *
+4032          BD+26 2064  89024 81264                       101106.7+255207101641.9+252217206.90 55.40 5.84  +1.20 +1.22        gK2                 -0.107+0.029      +034V                          
+4033 33Lam UMaBD+43 2005  89021 43268 383                   101104.0+432450101705.8+425452175.87 55.09 3.45  +0.03 +0.06 -0.01   A2IV               -0.164-0.038 +.030+018V      48                 *
+4034          BD-10 3029  89033155855                       101113.4-104219101609.1-111212253.23 36.27 6.08  +1.10               K0                 -0.013+0.008      +032V                          
+4035 37    LeoBD+14 2228  89056 990342824I                  101118.7+141337101640.7+134342225.42 51.54 5.41  +1.61 +1.95         M1.5IIIab          -0.023-0.016      +003                           
+4036          CD-42 6074  89062221910                       101119.6-423647101531.5-430645275.02 11.15 5.60  +1.52               K4III              +0.009-0.064      +018                           
+4037   Ome CarCP-69 1178  89080250885 385                   101121.6-693229101344.2-700217290.16-11.18 3.32  -0.08 -0.33 -0.03   B8III             t-0.039+0.007      +007V     225                 *
+4038          CP-54 3356  89104237834              Var?     101134.2-542836101516.6-545827281.73  1.34 6.16  -0.17 -0.76         B2IV-V             -0.015 0.000      +008V     104                 *
+4039 39    LeoBD+23 2207  89125 81270        7712           101144.5+233628101714.6+230622210.81 55.01 5.82  +0.50 -0.05 +0.27   F8Vb w             -0.408-0.100 +.062+038    =<  6  6.0   7.6      *
+4040          BD-19 2964  89169178610        7711           101201.2-201014101645.6-204014260.84 29.29 6.57  +0.48               F3V                -0.127-0.038      -001V          3.5   1.3       
+4041          BD+28 1867  89239 81278                       101232.4+275454101810.3+272455203.42 56.08 6.52  -0.02 -0.10         A0V                -0.057+0.006      +007       83                  
+4042 22Eps SexBD-07 3001  892541374691263                   101239.6-073410101737.8-080408250.79 38.76 5.24  +0.31 +0.13         F2III              -0.158+0.004 +.028+015V      76                 *
+4043          CP-59 2008  89263237853      W                101237.9-592418101603.1-595412284.58-02.69 6.22  +0.20               A5V                -0.047+0.016D+.012+018           0.1   0.4      *
+4044          BD+47 1761  89268 43281      W                101248.9+471543101859.0+464539169.34 54.28 6.43                      K1III              -0.021-0.030      -021           5.7  27.8       
+4045          CD-50 4990  89273237858              GY Vel   101246.2-504221101640.2-511218279.80  4.58 6.30  +1.54       +1.75   M4-5III            -0.028 0.000      +043                          *
+4046          BD+49 1940  89319 432852827                   101314.1+485402101926.8+482349166.68 53.77 6.00  +1.02               K0                 -0.097-0.107      -006                           
+4047          BD+69  568  89343 151472828                   101326.1+691501102103.4+684451140.50 42.89 5.96  +0.20 +0.12         A7Vn               -0.053-0.038      +004V     131                  
+4048          BD+25 2231  89344 81285                       101326.5+251246101900.7+244242208.23 55.77 6.40R                     K0                 -0.047-0.008      +000                           
+4049          CD-28 8070  893531786441265          AG Ant   101332.5-282931101807.6-285931266.85 22.93 5.34  +0.24               A0Ib-IIp           -0.010+0.012      -033                          *
+4050          CP-60 1817  893882509051264  W       V337 Car 101344.5-604957101705.0-611956285.48-03.80 3.40  +1.54 +1.72 +0.77   K3IIa              -0.024+0.005 +.027+008           9.2  16.4AB   3*
+4051          BD+54 1366  89389 27606                       101348.4+541646102014.8+534645158.57 51.58 6.45  +0.54 +0.08         F9V                -0.084+0.046      -021    =<  6                  
+4052          BD+54 1367  89414 276092829                   101403.1+544308102031.2+541301157.93 51.40 6.00  +1.13              gK3                 -0.032-0.002      +009V?                         
+4053          CD-36 6281  89442201266                       101414.0-361814101837.8-364817271.81 16.67 6.30  +1.28               K2-3III            -0.043+0.008      +002V                          
+4054 40    LeoBD+20 2466  89449 99065               4822    101417.6+195842101944.1+192815217.12 54.48 4.79  +0.45 +0.01 +0.23   F6IV               -0.234-0.214 +.052+007V?     16                 *
+4055          BD-11 2851  89455155894      W                101422.2-120134101916.8-123141255.04 35.83 6.00  +0.26               A9V                -0.014-0.019      -016      112  1.3   0.6       
+4056          CD-41 5765  89461221948                       101412.6-411004101828.2-414006274.65 12.65 5.96  -0.06               B9V                -0.027+0.006      +023                           
+4057 41Gam1LeoBD+20 2467  89484 81298    I   7724A  4823    101427.6+202051101958.3+195030216.55 54.65 2.61  +1.15 +1.00 +0.62   K1-IIIbFe-0.5      +0.306-0.147 +.022-037SB   < 17  1.2   4.5AB   4*
+4058 41Gam2LeoBD+20 2467  89485 81299    I   7724B  4823    101427.8+202049101958.6+195026216.55 54.65 3.80H                     G7IIIFe-1          +0.312-0.169 +.022-036V          1.2   4.5AB   4*
+4059          BD-04 2840  89490137490                       101430.1-043609101932.2-050621248.44 41.16 6.37  +0.90 +0.60         K0                 -0.053-0.061      +016                           
+4060          BD-08 2897  89565137495                       101501.5-083318101959.4-090332252.21 38.47 6.32  +0.33 +0.03         F1IV               -0.067-0.068      +015V      90                  
+4061          CP-55 3220  89569237902                       101459.0-553644101837.6-560636282.76  0.66 5.81  +0.48               F6V                -0.253+0.127      +011                           
+4062          BD+84  234  89571  1701                       101509.2+844537102941.5+841508126.85 31.76 5.50                      F0IV               -0.129-0.032 +.034+004V     105                 *
+4063          CP-54 3474  896822379162830          GZ Vel   101551.2-543137101936.8-550146282.28  1.64 4.57  +1.62 +1.82 +0.87   K3II               -0.014+0.003 -.008+013                          *
+4064 23    SexBD+03 2352  896881182481266          RS Sex   101552.1+024734102102.0+021723241.02 46.28 6.66  -0.08 -0.67         B2.5IV             -0.007-0.003      +005V                         *
+4065          CP-64 1248  89715250917      W                101558.8-641028101904.8-644035287.53-06.46 5.67  +0.05 +0.05         A1V                -0.043+0.007      +010           0.1   2.4      *
+4066          CD-47 5790  897362219702831                   101612.0-471147102016.7-474157278.33  7.82 5.65  +1.67               K5-M0III           -0.002+0.001      +016                           
+4067          BD+41 2076  89744 43309                       101613.9+414414102210.5+411346178.39 56.39 5.76  +0.54 +0.08         F7V                -0.124-0.136 +.041-007V       8                  
+4068          BD-17 3129  89747155920                       101619.0-172851102107.8-175906259.77 32.01 6.51  +0.40               F3III-IV           -0.051-0.028      +023V?     34                  
+4069 34Mu  UMaBD+42 2115  89758 43310 386I          4829    101622.4+420009102219.7+412958177.90 56.36 3.05  +1.59 +1.89 +0.96   M0III             e-0.082+0.035 +.035-021SBO                       *
+4070 42    LeoBD+15 2192  89774 99080               4828    101627.6+152847102150.3+145832224.49 53.21 6.12  +0.02 -0.02         A1V                -0.035-0.015      +009V      65                 *
+4071          BD-22 2904  898161787212832                   101646.3-231227102128.7-234239263.97 27.59 6.50  +0.20 +0.15         A3                 -0.049+0.019      +013                           
+4072          BD+66  664  89822 15163 387           4839    101655.5+660420102407.9+653359143.54 45.22 4.97  -0.06 -0.13 -0.06   A0pSiSr:Hg:        -0.008-0.022 +.043-000SB2O   15                 *
+4073          BD-21 3045  89828178723        7739           101652.1-220129102136.0-223142263.18 28.54 6.51  +0.07               A0                 -0.030+0.006D+.006+012           1.5   1.8       
+4074          CP-55 3286  89890237959      W     A          101711.5-553222102054.8-560235282.99  0.89 4.50  -0.12 -0.58 -0.09   B3IIIe            v-0.016+0.003D+.008+010       81  3.7   7.1AB   3*
+4075 27    LMiBD+34 2120  89904 620101267                   101720.8+342447102306.3+335429191.68 57.53 5.90  +0.14 +0.10         A6V                -0.013-0.005      -015V     150                  
+4076          BD-19 2987  89911155935                       101725.9-192144102212.9-195201261.40 30.72 6.13  +0.03               A1V                -0.031-0.001      +011SB2    50                 *
+4077 43    LeoBD+07 2289  89962118269                       101746.5+070302102300.4+063233236.37 49.21 6.07  +1.12 +1.14 +0.37E  K3III              -0.018-0.100      -024V                         *
+4078          BD+30 2005  89993 81328                       101802.3+300718102341.8+293657199.69 57.54 6.39  +1.09 +0.94         G8III              -0.006-0.010      -013                           
+4079          BD+06 2301  899951182712833  W                101803.0+061205102314.6+054139237.48 48.77 6.54  +0.46 -0.04         F6V                -0.241-0.073 +.007+030       23  2.5  58.6       
+4080          CD-41 5809  899982219981268           4837    101802.1-410848102219.6-413900275.25 13.07 4.83  +1.12 +1.08 +0.58   K1III              -0.022+0.056 +.024+021                           
+4081 28    LMiBD+34 2123  90040 62019    I                  101823.7+341328102408.6+334307192.02 57.75 5.50  +1.18              gK1                 -0.019-0.003      -022V?                         
+4082 25    SexBD-03 2911  90044137533 388          SS Sex   101823.2-033407102326.5-040427248.33 42.58 5.97  -0.10 -0.17         B9pSiCr:Sr:       v-0.050+0.005      +023                          *
+4083          CD-29 8306  90071178759                       101837.9-293923102313.1-300944268.56 22.64 6.27  +0.31 +0.05         F0III              +0.006-0.011      -013V                          
+4084          BD+83  297  90089  1714 911           4864    101854.9+830403103104.6+823331128.03 33.13 5.26  +0.37 -0.05         F2V                -0.083+0.031 +.047+007V     107                  
+4085          BD+03 2358  90125118278        7755           101902.9+025230102413.1+022205241.65 46.96 6.32  +1.00 +0.74         G9V                +0.037-0.023      -014           0.3 212.2AC   3*
+4086          CD-37 6509  901322013461269                   101906.5-373008102329.3-380036273.35 16.22 5.33  +0.25               A8V                -0.158-0.057 +.015+017      208                  
+4087          CD-41 5833  90170222016                       101923.8-412650102340.4-415712275.64 12.96 6.27  +0.88 +0.60         G8IV               -0.130+0.011      +022                          *
+4088 44    LeoBD+09 2351  902541182862835I         DE Leo   101959.0+091736102515.2+084705233.95 50.92 5.61  +1.62 +1.97         M3IIIabs           +0.014-0.042      -020V                         *
+4089          CP-66 1243  902642509402834                   102000.2-662344102258.1-665406289.10-08.11 4.99  -0.13 -0.51         B8V               v-0.024+0.008      +012SB2    79:                *
+4090 30    LMiBD+34 2128  90277 62038                       102011.0+341820102554.9+334746191.85 58.11 4.74  +0.25 +0.17 +0.14   F0V                -0.070-0.061      +014V      31                  
+4091          CP-57 3127  90289238021               4846    102011.2-572649102350.9-575714284.35-00.51 6.35  +1.52 +1.78         K4III              -0.001-0.006      -013                           
+4092          BD-06 3146  903621375572836I                  102044.3-063320102544.3-070335251.72 40.89 5.57  +1.52 +1.86 +0.95   K5:IIIbFe-0.5      -0.135+0.136      +032                           
+4093          CD-41 5850  90393222041                       102059.6-415733102517.2-422805276.18 12.69 6.18  +1.00               G8III              -0.002-0.034      -005                           
+4094 42Mu  HyaBD-16 3052  90432155980 389I                  102115.2-161933102605.4-165011259.99 33.65 3.81  +1.48 +1.82 +0.83   K4.5III            -0.128-0.080 +.018+040V    < 19:                 
+4095          CP-57 3164  90454238046                       102121.8-580407102459.4-583435284.81-00.95 5.95  +0.32               F2III              -0.077+0.009      +005                           
+4096          BD+42 2123  90470 43344                       102132.7+420644102728.0+413603177.30 57.27 6.02  +0.17 +0.08         A2V                -0.055-0.076      +007                           
+4097          BD+20 2487  90472 991282837                   102134.2+195225102700.5+192152218.32 56.05 6.15  +1.14               K0                 -0.064-0.012      +032                           
+4098          BD+49 1961  90508 43351      W                102153.6+491908102803.8+484705165.08 54.91 6.44  +0.60 +0.05 +0.24E  F9V                +0.079-0.884 +.053-007V       3  6.0   4.7      *
+4099          CD-42 6222  90518222047                       102153.1-421343102609.5-424420276.47 12.55 6.13  +1.13 +1.08         K1III              -0.127-0.052      +023                           
+4100 31Bet LMiBD+37 2080  90537 62053 390I   7780           102206.1+371311102753.0+364226186.28 58.28 4.21  +0.90 +0.64 +0.46   G9IIIab            -0.118-0.101 +.022+006SBO  < 19: 1.7   0.5      *
+4101 45    LeoBD+10 2152  90569 99136        7781  CX Leo   102222.0+101620102739.0+094545233.13 51.94 6.04  -0.06 -0.09         A0pSiCr:           +0.007+0.002      -008SBO    26  6.3  37.2     3*
+4102          CP-73  733  90589256710 391           4856    102224.7-733122102423.7-740154293.16-14.02 4.00  +0.35 -0.01 +0.19   F2IV               -0.021-0.026 +.086-004SB     55                  
+4103          BD+45 1832  90602 433562838                   102235.0+454323102836.5+451244170.89 56.38 6.35  +1.32 +1.40         K0                 -0.021-0.019      -004                           
+4104   Alp AntCD-30 8465  90610201405 392I          4862    102234.5-303331102709.1-310404269.88 22.39 4.25  +1.45 +1.63 +0.79   K4III              -0.075+0.011 +.024+012SB                        *
+4105          CP-73  735  90630256711                       102244.3-732749102444.3-735818293.15-13.96 6.19  +0.07 +0.11         A2-3V              -0.032+0.017      -003V?                         
+4106 35    UMaBD+66  671  90633 15196                       102248.4+660817102954.3+653734142.91 45.63 6.32  +1.14              gK2                  0.000-0.032      -025V?                         
+4107          CP-54 3651  90677238067                       102257.6-542204102649.0-545239283.07  2.32 5.58  +1.56               K3II-III           -0.007-0.008      +006                           
+4108          BD+64  789  90745 152002839                   102329.3+644615103026.6+641527144.32 46.59 6.12  +0.16 +0.12         A7III              -0.047-0.059      -013V     105                  
+4109          BD-03 2929  90763137591              Var?     102339.8-031351102844.0-034433249.25 43.76 6.05  +0.05 +0.04         A1pSr:             +0.004-0.027      -026                          *
+4110          CP-57 3256  90772238077              V399 Car 102340.9-570743102724.4-573820284.59  0.01 4.66  +0.51 +0.02 +0.48   A9Ia               -0.013 0.000 -.012-001       42                 *
+4111          CD-48 5655  90798222081               4868    102356.2-485338102801.9-492420280.35  7.07 6.10  +1.51 +1.76         K4III              +0.006-0.036      +090                          *
+4112 36    UMaBD+56 1459  90839 27670 394                   102413.8+562936103037.6+555850154.29 51.70 4.84  +0.52 -0.01 +0.28   F8V                -0.176-0.030 +.077+009        0  3.4 139. AC   3*
+4113 32    LMiBD+39 2357  90840 62076                       102416.3+392613103006.4+385531181.98 58.36 5.77  +0.08 +0.14         A4V                -0.017-0.002      +002SB?    70                  
+4114          CP-58 2227  90853238085 393           4869    102412.4-581343102752.7-584422285.22-00.90 3.82  +0.31 +0.24 +0.24   F2II               -0.013 0.000 +.010+009       22                 *
+4115          CP-65 1354  90874250966                       102416.1-651141102725.3-654217288.83-06.86 6.01  +0.09 +0.11         A2V                -0.082+0.023      +006                           
+4116 29Del SexBD-02 3155  908821376001270                   102423.9-021338102928.7-024421248.42 44.59 5.21  -0.06 -0.12         B9.5V              -0.048-0.014      +019V     191                  
+4117          CD-29 8381  90957178888    I                  102451.7-290908102929.0-293949269.46 23.83 5.58  +1.42 +1.72         K5III              -0.059+0.015      -005V                          
+4118   Del AntCD-29 8383  90972201442      W        4876    102459.1-300543102935.4-303626270.06 23.06 5.56  -0.04 -0.18         B9.5V              -0.033 0.000D+.002+014SB2     0  3.9  10.9      *
+4119 30Bet SexBD+00 2663  909941376082841          Bet Sex  102510.7-000727103017.5-003813246.42 46.17 5.09  -0.14 -0.52 -0.14   B6V                -0.040-0.023      +012      114                 *
+4120          CP-63 1440  91056250979                       102533.0-633938102852.6-641020288.16-05.47 5.29  +1.86 +2.10         M0III              -0.013+0.006 +.010-003                          *
+4121          BD+81  343  91075  17352845                   102544.3+810036103601.7+802940129.37 34.87 6.52  +0.95 +0.74        gG4                 -0.027-0.006      -011                           
+4122          BD-06 3173  91106137614    I   7808           102558.3-070728103058.7-073815253.49 41.37 6.20  +1.38 +1.18         K5III+F6V          -0.039+0.005      +007SB         2.3   2.8AB   3*
+4123          BD-12 3181  91120156029              Var?     102605.0-130431103059.8-133518258.57 36.91 5.58  -0.04 -0.16 -0.04   B9Vn              e-0.045+0.009      +013SB    310                 *
+4124 33    LMiBD+33 1999  91130 62101        7813           102610.8+325334103151.4+322246194.53 59.39 5.90  +0.11 +0.05         A0IV               +0.015+0.006      -015V     125  6.6  43.3      *
+4125          CD-25 8084  91135178917                       102610.1-255816103051.4-262902267.74 26.62 6.51  +0.54               F7III              -0.065+0.015      +016                           
+4126          BD+76  393  91190  7164 395I                  102636.2+761342103505.5+754247133.12 38.59 4.84  +0.96 +0.72         G8.5III            -0.030-0.003 +.027+017     < 19:                 
+4127 46    LeoBD+14 2255  91232 991721272I          4883    102651.5+143902103211.8+140814227.68 55.08 5.46  +1.68 +2.04         M1.5IIIbCa-1       -0.042+0.024 -.008+034V?                        *
+4128          CP-60 1945  91270250992      W                102705.6-605036103039.2-612122286.87-02.95 6.43  +1.76 +1.84         M2IIIe             -0.003+0.022      -004V          1.2  82.6      *
+4129          CP-66 1291  91272250989               4881    102702.4-662817103008.7-665906289.74-07.80 6.19  +0.01 -0.53         B4IV               -0.025-0.008      -008V                          
+4130          CD-27 7503  91280178938                       102709.2-274323103148.6-281415269.04 25.30 6.05  +0.51               F7V                -0.086-0.016      -021V                          
+4131          BD+54 1381  91311 27682                       102727.4+540047103343.6+532951157.30 53.44 6.45R                     A1V                -0.047-0.025      +002      127                 *
+4132          BD+41 2101  91312 433792844    7826           102723.9+405625103313.9+402532178.93 58.62 4.75  +0.23 +0.08 +0.09   A7IV               -0.140+0.006 +.031+009SBO   132  7.0  19.3      *
+4133 47Rho LeoBD+10 2166  91316118355 396  W       Rho Leo  102732.7+094917103248.7+091824234.89 52.77 3.85  -0.14 -0.96 -0.16   B1Ib               -0.007-0.003 +.011+042SB     61  0.4   0.0      *
+4134          CP-53 3909  91324238146      W                102728.6-531226103121.8-534256283.04  3.66 4.89  +0.50       +0.29   F6V                -0.418+0.205 +.050+020           3.5  46.4      *
+4135          CD-44 6583  91355222126      W     A          102741.1-443309103157.5-450400278.63 11.12 5.74  -0.15 -0.71         B6II                0.000-0.002      -000           0.4  13.7      *
+4136          CD-44 6582  91356222125      W     B          102740.2-443319103156.6-450410278.63 11.12 6.09  -0.11 -0.47         B8II               -0.013+0.006      -009V          0.4  13.7      *
+4137 34    LMiBD+35 2154  91365 62121                       102747.9+353014103330.9+345919189.36 59.60 5.58R +0.02 +0.04         A2Vn               -0.029-0.006      +007V     153                  
+4138          CP-71 1034  913752567222842                   102748.7-712842103020.1-715935292.41-12.07 4.74  +0.04 +0.07 +0.02   A1V                +0.025-0.037 +.014+008       20                 *
+4139          CD-43 6347  91437222129                       102816.1-440611103233.6-443708278.49 11.56 5.91  +0.92               G6-8III            -0.011-0.032      -010                           
+4140          CP-61 1704  91465251006 397          PP Car   102828.0-611015103201.4-614107287.18-03.15 3.32  -0.09 -0.72 -0.07   B4Vne             v-0.019+0.009      +026      303                 *
+4141 37    UMaBD+57 1277  91480 27695 398                   102843.4+573552103509.7+570458152.26 51.57 5.16  +0.34 -0.02 +0.17   F1V                +0.067+0.039 +.036-010V      87                 *
+4142          CP-72  981  91496256723      W        4886    102842.1-724226103102.0-731318293.12-13.08 4.93  +1.68 +1.83 +0.93   K4-5III            -0.017-0.001      +011           7.6  32.0      *
+4143          CD-46 6205  915042221361273  W                102843.6-462918103256.9-470012279.80  9.55 5.02  +1.04 +0.59         K4III              -0.019+0.003 +.010+004           4.0  40.2      *
+4144          CP-58 2285  91533238168                       102902.9-580905103247.6-584001285.73-00.50 6.00  +0.32 -0.07         A2Iab              -0.024 0.000      +010                          *
+4145 44    HyaBD-22 2946  91550178979 399I   7834           102915.4-231347103400.9-234443266.62 29.27 5.08  +1.60 +1.82         K4III              -0.008+0.021 +.017-004V?         8.7  19.1       
+4146 48    LeoBD+07 2330  916121183762846I                  102935.0+072807103448.0+065713238.51 51.84 5.08  +0.94 +0.64 +0.48   G8.5IIIFe-1Ca-1    -0.102+0.056 +.034+005V?   < 19:                *
+4147          CP-57 3431  91619238182              V369 Car 102938.5-574028103325.3-581125285.56-00.05 6.14  +0.35 -0.44         B7Iae             v-0.017-0.003      +007       52                 *
+4148 49    LeoBD+09 2374  91636118380        7837  TX Leo   102947.3+091002103502.2+083901236.30 52.86 5.67  +0.05 +0.05         A2V                -0.055-0.006D+.005+017SB1O=< 39  2.0   0.0     3*
+4149          BD-22 2952  91706178993                       103012.1-223937103457.7-231034266.45 29.86 6.10  +0.50 +0.01         F7V                -0.098+0.036      +012V                          
+4150 35    LMiBD+37 2100  91752 62147                       103037.2+365044103621.4+361937186.58 60.01 6.28  +0.39 -0.03         F3V                +0.036-0.037      -024V       8                  
+4151          CP-60 1983  91767251014               4898    103034.4-602815103412.9-605916287.05-02.42 6.23  +1.40 +1.55         K2-3III            +0.004-0.003      -001                          *
+4152          BD-17 3187  91790156087                       103047.8-180307103538.9-183409263.42 33.69 6.49  +0.20               A7V                +0.009+0.008      -007                           
+4153          CD-38 6579  91793201533              U Ant    103046.3-390244103512.9-393346276.22 16.14 5.38  +2.88 +7.1  +1.37   N0:               v-0.027-0.001      +037                          *
+4154          CD-43 6395  91805222170      W                103050.3-430854103510.5-433953278.40 12.62 6.08  +0.94 +0.71  0.00   G8II-IIICNVp       -0.030+0.023      +008           8.4  14.7      *
+4155          BD-09 3108  91858156092                       103118.8-100352103617.4-103500257.37 40.04 6.57  +0.29               F0V                +0.018-0.033      -022      112                  
+4156   Phi2HyaBD-15 3087  91880156093    I   7847           103123.6-154935103616.7-162040261.94 35.55 6.03  +1.65 +1.86         M1III              -0.026-0.001      +016V          7.0   3.4      *
+4157          CD-26 8022  91881179014        7846   4907    103121.5-260919103604.6-264030268.94 27.12 6.29  +0.48               F5V                +0.009-0.062D+.020-023SB         1.0   1.0      *
+4158          BD-11 2918  918891560951274  W                103133.6-114136103632.4-121349258.78 38.82 5.70  +0.52  0.00         F7V                +0.268-0.673 +.048-006           5.1  14.4      *
+4159          CP-56 3544  91942238222               4904    103144.7-570223103535.3-573328285.49  0.64 4.45  +1.62 +1.79 +0.84   K3-4II             -0.023 0.000 +.026+010SB                         
+4160          BD-10 3094  91992156105                       103214.4-111344103711.6-114455258.56 39.29 6.52  +0.29               F0V                -0.051-0.032      +009      176                  
+4161          CP-81  449  92029258581      W                103226.2-812417103151.0-815516298.01-20.42 7.07  -0.08 -0.51         B5III-IV           -0.033+0.008      +007           2.5  41.9      *
+4162          CD-26 8033  920361790412848I                  103232.0-265340103713.7-272445269.64 26.65 4.89  +1.62 +1.95 +0.82E  M2III              -0.109+0.024 +.010+017                           
+4163          BD-12 3218  92055156110    I         U Hya    103236.9-125152103733.2-132304259.97 38.07 4.82  +2.68 +5.78 +1.27   C5II               +0.034-0.032      -025V?                        *
+4164          CP-58 2371  92063238242               4909    103235.8-590241103620.3-593353286.57-01.05 5.08  +1.18 +1.20         K1III              -0.059-0.053 +.038-013                           
+4165          BD+54 1387  92095 277242849I                  103253.6+541125103905.7+534006156.32 54.01 5.52  +1.27 +1.34         K3III              -0.087-0.074      +045V?                         
+4166 37    LMiBD+32 2061  92125 621731275I                  103305.6+322945103843.2+315834195.30 60.85 4.71  +0.81 +0.54 +0.38   G2.5IIa             0.000+0.008 +.021-007V    < 19:                 
+4167          CD-47 6042  92139222199    I'W                103305.8-474222103718.1-481333281.06  8.87 3.84  +0.30 +0.07 +0.16   F4IV+F3            -0.155-0.017 +.040+019SB2O    0  0.9   0.3      *
+4168 38    LMiBD+38 2166  92168 621782852                   103324.6+382553103907.6+375436183.25 60.29 5.85  +0.57 +0.17         F9V                -0.222-0.044 +.038+007SBO                       *
+4169          CP-58 2411  92207238271              V370 Car 103338.3-581250103726.8-584400286.29-00.26 5.45  +0.50 -0.24         A0Iae             v-0.033+0.002      -009SB     56                 *
+4170          CP-75  678  922092567302847                   103334.0-754726103524.8-761833295.03-15.57 6.30  +1.20 +1.27         K2III              -0.018+0.004      +018V                          
+4171   Phi3HyaBD-16 3100  922141561222850I                  103342.5-162126103835.0-165236262.88 35.46 4.91  +0.92 +0.68         G8IIIFe-0.5        -0.097+0.027 +.014+018SB1O < 17                 *
+4172          BD-11 2925  92245156124                       103353.7-115525103850.4-122637259.53 39.00 6.04   0.00               A0Vn               -0.057+0.002      +012      210                  
+4173          CP-56 3588  92287238278                       103409.1-564411103802.5-571523285.63  1.07 5.91  -0.14 -0.63         B3IV               -0.028+0.002      -009SB                        *
+4174   Gam ChaCP-77  622  92305256731 401I'         4913    103417.3-780521103528.1-783628296.28-17.53 4.11  +1.58 +1.95 +0.97   M0III              -0.042+0.014 +.009-022                           
+4175          CD-42 6390  923282222222853  W                103426.7-421358103850.3-424513278.52 13.74 6.11  +0.66 +0.43         Am+Am:             -0.016-0.016      +016           0.1   0.2       
+4176          BD+69  583  92354 15260    I                  103441.7+685757104148.3+682636138.94 44.44 5.75  +1.30              gK3                 -0.026-0.026 -.000+005V?                         
+4177          CP-58 2460  92397238295      W        4922    103456.5-583945103845.1-591059286.65-00.57 4.66  +1.48 +0.97 +0.90   K4-5III:           -0.012+0.001 +.016+011           3.4  14.6      *
+4178 38    UMaBD+66  678  92424 152612855I          4936    103507.5+661425104156.6+654259141.57 46.45 5.12  +1.20 +1.28 +0.57   K2III             v-0.162-0.069 +.026-011SB   < 19:                 
+4179          CP-58 2474  92436238304      W                103510.5-581747103859.4-584901286.50-00.24 5.92  +1.65 +1.96 +1.22   M1III              -0.086+0.012      +081           2.7  23.5      *
+4180          CP-54 3915  92449238309 402  W                103519.5-550456103918.4-553612284.98  2.59 4.28  +1.04 +0.75 +0.47   G2-3Ib             -0.019+0.005 +.023+020           2.2  51.8AB   3*
+4181          BD+69  586  92523 15269 403I                  103554.7+693558104304.1+690434138.24 44.04 5.00  +1.38 +1.54 +0.73   K3III-IIIb         +0.002-0.012 +.005-000     < 19:                 
+4182 33    SexBD-00 2364  92588137728 404                   103618.9-011257104124.2-014430250.38 47.42 6.26  +0.88 +0.59 +0.45   K1IV               -0.137-0.121 +.026+043V?                         
+4183          CD-35 6646  925892016312856  W                103617.5-351311104051.6-354430275.16 19.99 6.37  +0.92               G8-K0III+F-G       -0.021+0.001      +011V          2.5   0.6       
+4184          BD+32 2066  92620 62206    I W       RX LMi   103635.2+321313104211.3+314149195.85 61.59 6.02  +1.62 +1.83 +1.13E  M4III              +0.008-0.021      +016V          4.0 112.5      *
+4185          CP-64 1403  92664251059              V364 Car 103643.5-643442104011.3-650602289.68-05.66 5.52  -0.16 -0.57         B9pSi              -0.027+0.003      +030       66                 *
+4186          CP-73  758  92682256742                       103654.8-735818103916.6-742937294.30-13.88 6.07  +1.71 +1.91         K3II                0.000-0.006      -004                           
+4187 39    UMaBD+57 1286  92728 27748                       103724.6+574328104343.3+571157150.95 52.42 5.80  -0.02 -0.09         A0V s              +0.017-0.053      -015V?     27                  
+4188          CP-59 2450  92740238353               4939    103728.2-590915104117.6-594037287.17-00.85 6.42  +0.08 -0.82         WN7-A              -0.006-0.001      +033SBO                       *
+4189 40    LMiBD+27 1927  92769 81485        7899           103732.4+265103104301.8+261932207.12 61.40 5.51  +0.17 +0.09         A4Vn               -0.105-0.063      +010      162  6.3  18.4AB   4*
+4190          BD-13 3197  92770156170    I                  103735.2-132705104231.3-135830261.64 38.35 6.24  +1.54               K2                 -0.020-0.002      -009V                          
+4191          BD+46 1657  92787 434441276  W                103740.4+464346104332.9+461214167.29 58.39 5.18  +0.33 +0.01         F5III              -0.269-0.066 +.021+004SB     52  2.8 286.9AB   5*
+4192 41    LMiBD+23 2253  92825 81490 405                   103758.7+234243104325.0+231118213.52 60.84 5.08  +0.04 +0.05         A3Vn               -0.116+0.009 +.016+019V     154                  
+4193 35    SexBD+05 2384  92841118449        7902A          103809.4+051621104320.9+044452243.46 52.16 5.79  +1.17 +1.09         K3III+K0III        +0.022-0.030D+.003-006SB         1.1   6.7AB   3*
+4194          CD-32 7572  928452016651277  W                103805.0-321132104243.2-324257273.85 22.79 5.64   0.00  0.00         A0V                -0.029+0.002      +004      131  8.2  17.4       
+4195          BD+68  617  92839 15274    I         VY UMa   103807.4+675609104504.0+672441139.59 45.41 6.00  +2.39 +4.62 +1.27   C5II               +0.005-0.001      -005                          *
+4196          CP-63 1589  92938251078                       103841.1-635635104214.0-642759289.56-05.00 4.82  -0.14 -0.58         B4V                -0.026+0.018      +024      138                 *
+4197          BD+20 2514  92941 81496                       103851.6+201702104414.5+194531220.27 60.00 6.27  +0.17               A5V                -0.116-0.026      +005SB    168                  
+4198          CP-58 2581  92964238379               4948    103848.6-584131104240.6-591257287.11-00.36 5.38  +0.26 -0.65 +0.36   B2.5Iae           v-0.009 0.000      -002       68                 *
+4199   The CarCP-63 1599  93030251083 406I                  103923.3-635214104257.4-642340289.60-04.90 2.76  -0.22 -1.01 -0.23   B0Vp              v-0.023+0.010      +024SB    151                 *
+4200          CP-59 2532  93070251090               4951    103943.8-600232104332.1-603400287.84-01.50 4.57  +1.71 +1.87 +0.99   K4III              -0.032+0.006 +.020+009SB                        *
+4201 36    SexBD+03 2408  93102118473      D                104000.3+030050104509.4+022917246.68 51.02 6.28  +1.21 +1.28         K4III              -0.051-0.023      +011V          0.0   0.0      *
+4202 41    UMaBD+58 1281  93132 27760    I                  104006.4+575336104622.5+572157150.36 52.58 6.34  +1.56 +1.90         M1III              -0.050-0.064      -002                          *
+4203 42    LMiBD+31 2180  93152 62236 407  W                104018.3+311233104551.9+304056198.01 62.38 5.24  -0.06 -0.14         A1Vn               -0.023-0.037      +012SB    125  2.8 198.1       
+4204          CP-63 1619  93163251095              Var?     104015.4-634327104351.2-641456289.61-04.73 5.77   0.00 -0.57 -0.03   B2.5V              -0.014+0.006      +011       12                 *
+4205          CP-63 1623  93194251096                       104029.7-632610104406.9-635740289.50-04.46 4.82  -0.13 -0.62 -0.13   B5Vn               -0.019+0.013      +026      260                 *
+4206          CP-79  548  93237256745                       104048.2-791533104151.3-794700297.18-18.39 5.97  -0.07 -0.51         B4IVe              -0.031+0.010      +018V                         *
+4207          BD+07 2356  932441184831278                   104053.3+065401104605.7+062223242.08 53.72 6.37  +1.12 +1.12        gK1                 -0.008-0.036      -009V                         *
+4208 51    LeoBD+19 2371  93257 992811279I                  104101.3+192508104624.5+185329222.26 60.16 5.49  +1.12              gK3                 +0.097-0.038      -006                           
+4209 52    LeoBD+14 2294  93291 992822860                   104107.5+144322104625.3+141141230.54 58.15 5.48  +0.91 +0.59        gG4                 -0.123-0.066      +035V                          
+4210   Eta CarCP-59 2620  93308238429    I W       Eta Car  104110.8-590931104503.6-594103287.60-00.63 6.21  +0.61 -0.45 +0.49   pec                -0.004+0.009      -025           0.1   0.2AP  15*
+4211          CP-70 1183  93344256750      W     A          104118.8-702002104419.4-705136292.82-10.53 6.26  +0.20 +0.17         A5IV-V             -0.075-0.007      +010           0.2  63.0AB   3*
+4212          CP-70 1185  93359256751      W     B          104130.9-701946104432.1-705118292.83-10.51 6.46  +0.23 +0.14         A6IV               -0.060+0.007      +015           0.2  63.0AB   3*
+4213          CP-71 1118  93372256752                       104139.9-715509104426.5-722638293.60-11.91 6.27  +0.49 +0.01         F6V                -0.175+0.040      +019                           
+4214          BD-16 3124  93397156221                       104158.0-164610104652.0-171748265.16 36.28 5.42  +0.11 +0.14 +0.04   A3V                -0.020-0.013      -014V?                         
+4215          BD+65  803  93427 15298                       104209.2+653936104850.0+650756141.38 47.36 6.39  -0.02 -0.04         A1V                +0.010 0.000      -005V     170                  
+4216   Mu  VelCD-48 5913  93497222321    I'W                104228.0-485330104646.2-492512283.03  8.57 2.69  +0.90 +0.57 +0.49   G5III+G2V          +0.074-0.048D+.022+006SB         3.7   1.7      *
+4217          CP-59 2671  93502251113      W                104226.3-600435104616.8-603612288.16-01.37 6.25  +0.04 +0.03         A0IV               -0.062-0.008      +008SB2        7.8   4.2      *
+4218          BD-14 3186  93526156235        7930           104242.1-144403104738.0-151543263.88 38.05 6.67  -0.01               A0III              +0.002-0.014D+.012+022SB         1.2  74.7AC   3 
+4219          CP-63 1646  93540251115                       104239.1-635916104616.5-643054289.97-04.84 5.34  -0.10 -0.45         B6V               e-0.025-0.005      +032      228                 *
+4220          CP-63 1649  93549251117      W                104250.9-634411104629.7-641548289.88-04.61 5.23  -0.07 -0.47         B7IV               -0.008+0.012      +012V     201  0.1   0.1      *
+4221          CP-56 3800  93563238468              Var?     104255.3-561348104657.5-564526286.46  2.08 5.23  -0.08 -0.33         B8-9IIIe          v-0.016-0.002      +031      218                 *
+4222          CP-63 1655  93607251120                       104312.6-635123104651.2-642300289.97-04.69 4.85  -0.15 -0.65 -0.18   B3IV               -0.023+0.012      +016      202                 *
+4223 43    LMiBD+30 2072  93636 81533                       104326.3+295643104857.2+292457200.81 63.01 6.15  +1.15 +1.06       sgK1                 -0.086-0.041 +.038+010                           
+4224          BD-01 2446  93655137800    I                  104334.5-012551104840.6-015732252.55 48.53 5.93  +1.60 +1.94         M2III              -0.012+0.008      +003                           
+4225          CD-31 8536  93657201766                       104332.9-310935104814.2-314118274.38 24.27 5.88  +0.03 +0.04         A1V                -0.020-0.013      +021V                          
+4226          CP-56 3821  93662238480               4975    104337.4-565623104738.7-572804286.87  1.49 6.36  +1.62 +1.86         M1II               +0.010-0.004      +002                          *
+4227 53    LeoBD+11 2283  93702 99305 409                   104400.0+110428104915.4+103243237.00 56.82 5.34  +0.03 +0.02         A2V                -0.003-0.025 +.007-007SB    191                  
+4228          CP-59 2720  937372384932862                   104410.4-592328104805.4-595509288.04-00.66 6.00  +0.27 -0.30         A0Ia-Iab           -0.001+0.006      -024                          *
+4229 40    SexBD-03 2999  93742137808        7936           104413.0-032943104917.3-040127254.80 47.11 6.61  +0.22 +0.08         A2IV               -0.049-0.012D+.011+014           0.7   2.2       
+4230 44    LMiBD+28 1931  93765 815422863                   104424.0+283007104953.7+275826204.02 63.12 6.04  +0.37 -0.01         F3V                -0.011+0.031      +003V?     22                  
+4231   Del1ChaCP-79  554  93779258592      W                104419.3-795630104515.7-802811297.68-18.91 5.47  +0.95 +0.75         K0III              -0.038-0.033D+.003+011           0.3   0.6       
+4232   Nu  HyaBD-15 3138  93813156256 410I                  104441.4-154013104937.5-161137265.05 37.56 3.11  +1.25 +1.30 +0.64   K2III              +0.094+0.200 +.028-001     < 17                  
+4233          BD-09 3147  93833137815                       104443.1-091922104943.5-095110260.17 42.69 5.86  +1.07 +0.91        gG8                 +0.009-0.037      +040V?                         
+4234   Del2ChaCP-79  556  93845258593 411                   104451.0-800046104546.8-803225297.74-18.96 4.45  -0.19 -0.70 -0.20   B2.5IV             -0.049+0.008      +023       55                 *
+4235 43    UMaBD+57 1294  93859 27791                       104501.3+570642105111.1+563456150.63 53.59 5.67  +1.12               K2III              -0.058+0.003      +015                           
+4236 42    UMaBD+60 1296  93875 277932865I                  104506.6+595104105123.7+591912147.28 51.76 5.58  +1.14 +1.15         K2III              -0.036-0.047      -017SB                         
+4237 41    SexBD-08 3018  939031378231281    7942           104517.0-082205105018.1-085352259.52 43.53 5.79  +0.16 +0.13 +0.07   A3m                -0.004-0.015      -004SB1O   20  5.8  27.3AB   3*
+4238          CD-33 7288  93905201805                       104517.7-333145104957.0-340329276.00 22.38 5.61  +0.04 +0.05         A1V                -0.044+0.015      -012V?                         
+4239          CP-58 2755  93943238514      W                104526.7-584740104924.1-591925287.92-00.06 5.91   0.00 -0.09         B9.5IV-V           -0.043+0.001D+.010+004           1.2   1.1       
+4240          BD-02 3236  94014137834    I                  104600.4-023344105105.4-030533254.38 48.10 5.95  +1.48 +1.83         K2                 -0.046-0.006      +037                           
+4241          BD+53 1439  94083 27809                       104630.3+530548105230.8+523355155.83 56.29 6.65R                    gG8                 -0.020-0.023      -008V                          
+4242          BD+53 1440  94084 27810                       104632.1+530208105231.9+523013155.91 56.33 6.44  +1.11 +1.01 +0.53   K2III              -0.071-0.052      -003SB                         
+4243          BD+70  634  94132  72292866  W                104640.1+702313105330.7+695114136.56 44.02 5.93  +0.99 +0.86         G9IV               -0.398-0.067 +.029+015V          3.0  75.1AB   4 
+4244          BD+01 2495  94180118550      W                104705.4+013321105213.7+010131250.31 51.29 6.38  +0.08 +0.13         A3V                -0.002+0.003      -013V?     75  5.8  39.2       
+4245          BD+00 2710  94237118555    I                  104728.7+001948105236.1-001205251.78 50.48 6.31  +1.50 +1.82 +0.62E  K5III              -0.009-0.018      +009                          *
+4246 44    UMaBD+55 1418  94247 278152869I                  104731.2+550700105334.5+543506152.85 55.15 5.10  +1.36 +1.52 +0.47E  K3III              -0.064-0.011 +.016+001     < 19:                *
+4247 46    LMiBD+34 2172  94264 62297 412I          4999    104743.2+344514105318.7+341254190.00 63.73 3.83  +1.04 +0.91 +0.54   K0+III-IV          +0.087-0.278 +.024+016V    < 19:                *
+4248 45Ome UMaBD+43 2058  94334 435122870                   104813.4+434321105358.7+431124171.16 61.35 4.71  -0.05 -0.05 -0.04   A1V s              +0.045-0.021 +.014-017SBO    35                 *
+4249          BD-01 2459  94363137863        7967           104819.8-014316105324.9-021519254.18 49.12 6.12  +0.90 +0.61         K0III+G0V          -0.138-0.083      +026SB         2.6  35.2      *
+4250          CP-56 3947  943672385572868                   104825.0-564233105230.9-571426287.36  1.99 5.25  +0.16 -0.54         B9Ia              e-0.004+0.002      -024       41                 *
+4251          BD-19 3125  94388156301      W        5006    104835.9-193601105329.5-200820268.69 34.78 5.24  +0.47 +0.06         F6V               v+0.078-0.239 +.054-005V      14  4.0 124.5AB   4*
+4252          BD-14 3213  94386156302                       104835.8-145445105332.9-152644265.50 38.71 6.38  +1.16               K3IV               +0.067-0.043      +000V                          
+4253          BD-01 2460  94402137871      W                104838.2-013552105343.7-020745254.14 49.26 5.45  +0.96 +0.77 +0.33E  G8III              -0.084+0.013      +015V?                        *
+4254 48    LMiBD+26 2147  94480 81576                       104916.3+260123105442.2+252927209.85 63.85 6.20  +0.28 +0.12 +0.16   A8V                -0.054+0.003      +008V     140                 *
+4255          BD-12 3293  944811563102871                   104919.8-131333105417.8-134529264.46 40.21 5.66  +0.83               G4III              -0.005+0.009      +005                           
+4256          BD+34 2178  94497 62310                       104924.7+343407105458.2+340205190.31 64.10 5.72  +1.01              gG7                 -0.060-0.049      -028V?                        *
+4257          CP-58 2834  94510238574      W        5011    104925.8-581919105329.6-585112288.18  0.60 3.78  +0.95 +0.65 +0.49   K1III              +0.067+0.030 +.059+008SB         2.7 153.9AB   3*
+4258 46    UMaBD+34 2181  94600 62314    I                  105012.1+340227105544.4+333025191.47 64.32 5.03  +1.10 +1.00 +0.55   K1III              -0.109-0.027      -022V?   < 19:                 
+4259 54    LeoBD+25 2314  94601 81583        7979A          105012.0+251659105536.8+244459211.59 63.91 4.50  +0.01 +0.02 -0.01   A1V                -0.072-0.012D+.015+005V     182  1.9   6.5      *
+4260 54    LeoBD+25 2314  94602 81584        7979B          105012.4+251657105537.3+244456211.60 63.91 6.30H                     A2Vn               -0.074-0.026D+.015-001SB    233  1.9   6.5      *
+4261          BD-19 3134  946191793342872                   105018.7-200755105511.6-203954269.45 34.54 6.44  +1.10               K0                 -0.010+0.004      -012V?                         
+4262          CP-70 1246  94650256770      W                105025.2-701115105342.0-704313293.45-10.05 5.99  -0.02 -0.46         B6V               e-0.034-0.006D+.004+006           0.6   1.5      *
+4263          CD-41 6220  94660222422              KQ Vel   105028.8-414305105501.0-421504280.98 15.60 6.11  -0.08 -0.25         A0pSiCr            -0.037-0.001      +022V                         *
+4264          BD+42 2162  94669 43535                       105032.2+423239105614.5+420030173.09 62.21 6.03  +1.13 +1.08 +0.42E  K2III              +0.014-0.091 +.027-054                          *
+4265 55    LeoBD+01 2501  94672118574        7982           105033.7+011613105542.4+004413251.63 51.69 5.91  +0.42 -0.02         F2/3III/V          +0.106 0.000 +.014-002SB         2.0   0.0     3*
+4266          CP-61 1960  94683251173      W                105033.8-611737105429.6-614936289.59-02.02 5.93  +1.75 +1.97         K4III              +0.003-0.004      -003           5.0   7.1       
+4267 56    LeoBD+06 2369  94705118576    I         VY Leo   105049.9+064309105601.5+061107245.05 55.50 5.81  +1.45 +1.00 +2.09   M5.5III           v-0.022-0.008 -.003-013V?                        *
+4268          CP-78  589  94717256768                       105049.3-790138105227.5-793334297.51-17.96 6.33  +1.46 +1.57         K2II-III           -0.040+0.002      +003                           
+4269          BD+23 2279  94720 815892873I                  105053.8+225306105616.9+222106216.93 63.48 6.14  +1.55 +1.94         K2                 -0.037+0.017      +025                           
+4270 50    LMiBD+26 2152  94747 81591                       105108.9+260203105634.4+253000210.00 64.26 6.35  +1.03 +0.89         K0                 -0.025-0.015      +030                           
+4271          CP-59 2840  94776251178              T Car    105117.4-595909105517.2-603101289.11-00.80 5.92  +1.08 +0.88         K0III              -0.036+0.084      -026                          *
+4272          BD+78  367  94860  7255 413                   105157.7+781821105956.8+774612130.13 37.76 6.20  +0.97               G9III              -0.072-0.023      -050V?                         
+4273   Iot AntCD-36 6808  94890201927 414                   105203.3-363600105643.1-370816278.85 20.31 4.60  +1.03 +0.84 +0.53   K1III              +0.077-0.128 +.025-000                           
+4274          CD-50 5534  949852386222874          IW Vel   105246.2-501351105707.9-504554285.14  8.11 5.91  +0.18               A4V                -0.031+0.013      +016                          *
+4275          BD+52 1528  95057 278582876           5038    105323.5+522504105917.9+515256155.64 57.53 6.17  +1.38 +1.59         K0                 -0.012-0.003      -007                          *
+4276          CP-59 2888  95109238635              U Car    105343.5-591150105748.4-594355289.06  0.04 6.11  +1.10 +1.10         G3Ia               +0.007+0.016      +000                          *
+4277 47    UMaBD+41 2147  95128 435571282                   105352.0+405752105928.0+402549175.78 63.37 5.05  +0.61 +0.13 +0.31   G1-VFe-0.5         -0.317+0.057 +.072+013V?  =<  3                  
+4278          BD+36 2139  95129 62345    I                  105358.0+363749105932.8+360535185.24 64.66 6.00  +1.59 +1.92 +1.29   M2III              +0.071-0.049 +.018-026V                          
+4279          CP-74  755  952082567752875                   105424.9-743353105715.7-750559295.66-13.86 6.13  +1.53 +1.64         K1II               -0.017+0.003      +008                           
+4280          BD+46 1680  95212 435622878I                  105430.2+460344110014.7+453134165.76 61.27 5.47  +1.47               K5III              +0.011+0.003      +009                           
+4281          BD+12 2284  95216 993922877                   105427.6+121426105941.1+114221237.93 59.59 6.55  +0.43 -0.02         F5V                -0.228+0.044      +020        8                  
+4282          CD-33 7401  95221201976      W        5041    105430.4-331201105913.9-334414277.67 23.57 5.71  +0.37               F2V                +0.016-0.043      -010           3.0   1.8       
+4283          BD+52 1529  95233 27868                       105432.8+520219110025.6+513007155.99 57.90 6.43                      G9III              -0.029-0.015      +000                           
+4284          BD-15 3174  95234156372    I                  105434.3-154903105930.9-162114267.68 38.74 5.89  +1.63 +1.91         M2III              -0.046-0.016      -033V?                         
+4285          BD+43 2068  95241 43564      W                105440.5+432705110020.6+425441170.63 62.52 6.02  +0.57 +0.02         F9V                -0.109-0.132 +.019-006V       6  5.6  37.1       
+4286          BD+64  824  95256 15360                       105446.8+635732110105.8+632516141.55 49.53 6.39  +0.16 +0.14 +0.04   A2Vm               -0.040-0.048      +007       50                  
+4287  7Alp CrtBD-17 3273  952721563751283I                  105454.1-174558105946.5-181756269.06 37.12 4.08  +1.09 +1.00 +0.55   K0+III             -0.460+0.130 +.031+047V    < 19:                *
+4288 49    UMaBD+39 2400  95310 62354                       105514.2+394457110050.4+391244178.15 64.04 5.08  +0.24 +0.17 +0.11   F0V s              -0.072-0.019      +003       72                 *
+4289          BD-13 3271  95314156382    I                  105513.2-133246110011.6-140500266.26 40.74 5.88  +1.50 +1.82         K5III              -0.018-0.022      -006                           
+4290          CP-60 2433  95324251205      W                105512.4-604704105914.0-611913289.89-01.32 6.16  -0.06 -0.29         B8IV               -0.031+0.019      +016           3.5   4.1       
+4291 58    LeoBD+04 2407  953451186101284I D                105523.7+040916110033.6+033703249.69 54.59 4.84  +1.16 +1.12 +0.56   K1IIICN-0.5        +0.014-0.016 +.007+006V?   < 19: 0.0   0.1      *
+4292          CD-43 6692  95347222485                       105526.7-431615105959.4-434826282.54 14.61 5.81  -0.08               B8-9V              -0.058+0.011      -005                           
+4293          CD-41 6276  95370222487 415                   105533.8-414122110009.3-421333281.86 16.05 4.39  +0.11 +0.12 +0.07   A3IV               +0.028+0.003 +.003-005      111                  
+4294 59    LeoBD+06 2384  95382118615        8019           105533.8+063819110044.8+060605246.54 56.32 4.99  +0.16 +0.11         A5III              -0.048-0.025 +.035-012       71  7.5  44.8      *
+4295 48Bet UMaBD+57 1302  95418 27876 416I          5053    105548.6+565507110150.5+562257149.17 54.80 2.37  -0.02 +0.01 -0.04   A1V                +0.082+0.034 +.053-012SB     39                 *
+4296          CD-51 5220  95429238674      W                105546.6-511652110008.6-514904286.02  7.36 6.15  +0.18               A3III-IV           -0.038+0.004      +014           7.1  10.3       
+4297          BD-15 3178  95441156396                       105559.3-151517110057.2-154734267.67 39.40 6.34  +1.18               K0                 +0.055-0.040      -005V?                         
+4298          CD-31 8696  95456201998                       105555.9-311820110040.8-315022277.02 25.40 6.07  +0.52 +0.09         F8V                -0.080+0.105      -002                           
+4299 61    LeoBD-01 2471  955781379472879I          5059    105643.6-015646110149.7-022905256.87 50.32 4.74  +1.62 +1.95 +0.96   M0IIIBa0.2         +0.012-0.038 +.032-014V    < 19:                 
+4300 60    LeoBD+20 2547  95608 816372880                   105659.5+204259110219.8+201047222.61 64.13 4.42  +0.05 +0.05 -0.02   A1m                -0.006+0.042 +.017-010       24                  
+4301 50Alp UMaBD+62 1161  95689 15384 417I   8035   5070    105733.6+621727110343.7+614503142.85 51.01 1.79  +1.07 +0.92 +0.58   K0IIIa            e-0.119-0.067 +.038-009SBO  < 17  3.0   0.5      *
+4302          CD-26 8302  95698179456        8028           105733.9-261725110224.4-264953274.77 30.01 6.23  +0.31 +0.09         F1V                +0.065-0.120      +001           0.1   0.2      *
+4303          BD+00 2728  95771137963      D                105807.6-001240110314.6-004509255.51 51.87 6.14  +0.26 +0.06         F0V                -0.013-0.111      +004                          *
+4304          CP-80  509  95788258599      W                105803.3-810116105912.9-813322298.73-19.62 6.71  +0.55 +0.04         F7IV               -0.160+0.073D+.010+011           0.1   0.4       
+4305          BD-10 3184  95808156421        8037           105814.7-104544110314.9-111813265.03 43.47 5.50  +0.94               G7-III             -0.070-0.108      -008V          5.9   3.7      *
+4306 62    LeoBD+00 2729  95849118634                       105829.5+003215110336.6-000003254.81 52.49 5.95  +1.22 +1.32         K3III              -0.057+0.001      -008V                          
+4307          CD-31 8726  958572020392881I                  105830.0-312518110316.1-315739277.62 25.54 6.46  +1.62 +1.98         M1III              -0.039-0.031      +080                           
+4308          BD-12 3333  95870156427                       105837.1-125346110336.5-132604266.72 41.73 6.34  +0.88 +0.60         G5                 +0.003+0.010      -010V                          
+4309 51    UMaBD+39 2414  95934 623872882    8046           105857.7+384649110431.2+381429179.75 65.03 6.00  +0.16 +0.10         A3III-IV           -0.064-0.003      +007V?         7.1   8.4AB   3*
+4310 63Chi LeoBD+08 2455  96097118648 418  W        5079    105951.5+075236110501.0+072010246.14 57.94 4.63  +0.33 +0.08 +0.17   F2III-IV          v-0.341-0.047 +.029+005V      25  4.3 276.4AC   4 
+4311          CD-47 6466  961132225382884                   110001.2-470826110431.2-474045284.94 11.42 5.67  +0.24               A8III-IV           -0.110+0.027      -016      202                  
+4312   Eta OctCP-83  386  961242586001664                   110001.3-840321105913.8-843538300.19-22.33 6.19  +0.11 +0.12         A1V                -0.068-0.005      -003                           
+4313          CD-35 6954  961462020672885                   110010.7-351555110454.2-354817279.80 22.24 5.43  +0.03               A2V                -0.017+0.004      +011                           
+4314   Chi1HyaCD-26 8338  96202179514 419  W                110030.7-264514110519.9-271737275.69 29.91 4.94  +0.36 +0.04         F3IV               -0.188-0.004 +.043+017V?    186  0.1   0.2      *
+4315          BD-10 3190  962201564481286                   110032.8-103249110534.0-110520265.52 43.96 6.09  +0.30               F0Vn               +0.013-0.079      -020                           
+4316          CD-48 6157  96224222548                       110035.2-485111110504.2-492333285.73  9.89 6.13  -0.02 -0.06         B9.5V              -0.023+0.004      +004                           
+4317   Chi2HyaCD-26 8342  96314179522              Chi2 Hya 110106.5-264451110557.6-271716275.82 29.97 5.71  -0.06 -0.26         A0IV               +0.034-0.014      +030SBO   193                 *
+4318          CD-50 5686  96407238763                       110138.3-504014110605.8-511245286.62  8.29 6.30  +0.95 +0.59         G8III              +0.005-0.065      +053                           
+4319 65    LeoBD+02 2387  964361186681287    8060   5090    110148.1+022954110654.2+015720253.65 54.50 5.52  +0.97 +0.66         G9IIICN-1          -0.383-0.086 +.035+055           3.8   2.2      *
+4320          CD-28 8657  96441179542                       110149.2-281111110638.7-284340276.73 28.76 6.77  +0.04               A1V                -0.057-0.032      +018                           
+4321          CD-50 5693  96484238775                       110200.0-502459110627.4-505724286.57  8.55 6.32  +1.16 +1.22?        K2III              -0.067+0.006      +009                           
+4322 64    LeoBD+24 2318  96528 81681                       110218.5+235152110739.7+231925216.37 66.27 6.46  +0.16 +0.12 +0.09   A5m                -0.014+0.008      -002SBO                       *
+4323          CP-58 3112  96544238779      W        5091    110214.3-580804110629.3-584031289.64  1.46 6.02  +1.24               K2II-III           -0.015 0.000      +003           5.9  12. AB   3*
+4324          CD-31 8776  96557202100                       110221.8-320242110708.4-323514278.74 25.34 6.59  +0.34 +0.03         F1III              -0.081-0.052      -002                           
+4325          CP-61 2067  96566251269                       110226.3-615301110632.4-622527291.12-01.98 4.61  +1.03 +0.81 +0.45   G8III              -0.043+0.013 +.055-002                           
+4326          CP-64 1630  96568251267                       110225.1-641757110624.2-645023292.06-04.21 6.41  +0.12 +0.13         A3V                -0.050+0.008      -006V?                         
+4327          CD-41 6343  96616222581      W       V815 Cen 110239.0-420556110716.6-423819283.28 16.22 5.15  +0.03               ApSrCrEu           -0.096+0.043 -.001+002       56  2.5   1.4      *
+4328          CD-29 8875  96700179558                       110309.0-293747110754.4-301029277.74 27.59 6.54  +0.60 +0.08         G2V                -0.513-0.138 +.049+013                           
+4329          CP-70 1305  967062568001288  W       Var      110313.2-702013110649.9-705241294.51-09.74 5.57  -0.05 -0.63         B2V                -0.027 0.000      +007       62  8.2  15.       *
+4330          BD+68  632  96707 15414              Var?     110319.4+674509110939.9+671237137.06 47.03 6.06  +0.22 +0.13         F0pSr             v-0.083-0.025      +005       45                 *
+4331          CD-29 8877  96723179568                       110326.2-292551110815.8-295822277.71 27.80 6.49  +0.03 +0.05         A1V                +0.008-0.020      -013V?                         
+4332 67    LeoBD+25 2344  96738 816922889    8071           110327.2+251159110849.1+243930213.26 66.83 5.68  +0.06 +0.12         A3IV               +0.003+0.004      -006V          6.6   4.8       
+4333          BD+37 2162  96813 624272892I         CO UMa   110349.1+365106110919.1+361834183.56 66.52 5.74  +1.51 +1.50 +1.32E  M3.5IIIab          -0.046-0.024      +022                          *
+4334          CD-27 7886  96819179577               5101    110353.5-273218110843.9-280450276.87 29.54 5.44  +0.07 +0.06         A1V                -0.080-0.016 +.011+016V?    227                  
+4335 52Psi UMaBD+45 1897  96833 43629 420I                  110402.6+450228110939.8+442955165.80 63.23 3.01  +1.14 +1.11 +0.57   K1III              -0.065-0.028      -004V?   < 19:                 
+4336          BD+43 2083  96834 43627    I          5107    110402.6+434459110938.5+431227168.30 63.89 5.89  +1.57 +1.90 +0.97E  M2III              -0.064-0.011      +018                          *
+4337          CP-58 3189  969182388131289I         V382 Car 110419.0-582600110835.4-585830290.01  1.29 3.91  +1.23 +0.94 +0.58   G40-Ia            v-0.007 0.000 -.001+007SB     23                 *
+4338          CP-61 2075  969192512862891          V371 Car 110424.1-612420110834.0-615650291.15-01.45 5.13  +0.22 -0.44         B9Ia              t-0.006+0.002 +.009-022        0                 *
+4339          CD-31 8816  97023202149               5111    110504.9-314928110953.4-322203279.22 25.79 5.81  +0.04               A2V                +0.023-0.029      -000                           
+4340          BD+69  602  97138 15431               5119    110548.0+684853111211.0+681619135.92 46.27 6.40                      A3V                +0.032+0.010      -018                           
+4341          BD+15 2301  97244 99492                       110629.1+145637111143.7+142401236.63 63.53 6.30  +0.21 +0.08         A5V                -0.066-0.009      +006       82                  
+4342          CP-57 4387  97271238839                       110635.5-575445111054.7-582719290.09  1.89 6.88  -0.08 -0.44         B7III              -0.036+0.003      +017                           
+4343 11Bet CrtBD-22 3095  97277179624 421                   110644.3-221647111139.5-224933274.78 34.53 4.48  +0.03 +0.06 +0.02   A2III              +0.003-0.100 +.051+006SB     58                  
+4344          BD+55 1446  97302 27952                       110655.4+552616111244.5+545339149.04 56.94 6.63                      A4V                +0.001-0.002      -006V                          
+4345          BD+36 2162  97334 62451      W                110705.8+362143111232.2+354849184.33 67.28 6.41  +0.61 +0.10         G0V                -0.271-0.170      -003V   =<  6  1.6 138.7AB   4 
+4346          CD-31 8847  973932021971290I          5129    110725.5-315326111214.8-322602279.75 25.93 6.38  +1.70 +1.85 +0.98E  M1III              +0.019+0.011      +027                           
+4347   Psi CrtBD-17 3321  97411156528        8086           110732.7-175720111230.4-183000272.49 38.45 6.13  -0.01 -0.01         A0V                -0.019-0.030      +014       51  0.4   0.2      *
+4348          BD-20 3374  97428179638                       110738.7-211221111234.6-214457274.41 35.59 6.40  +1.38               K0                 -0.011+0.012      -024V?                         
+4349          CP-70 1336  97472256808                       110747.9-705334111129.5-712611295.08-10.10 6.35  +1.37 +1.54         K2-3III            -0.020+0.003      +026                           
+4350          CD-48 6263  974952226391291                   110759.6-483329111233.1-490604286.76 10.64 5.36  +0.18               A3IV-V             -0.096+0.033      -010SB    128                  
+4351          BD+41 2170  97501 43649        8093           110807.8+413757111340.2+410519171.83 65.55 6.33  +1.15 +1.12         K2III              -0.004+0.013      +012V          4.8   3.1      *
+4352          CP-59 3190  97534251316      W        5137    110818.5-594625111236.0-601903290.99  0.24 4.60  +0.55 +0.05 +0.38   A6Iae              -0.007+0.004 +.005-008       34  6.8  21.7      *
+4353          CD-49 5937  97550222643                       110823.0-491132111256.9-494411287.06 10.08 6.11  +1.06               G8II-III           -0.008-0.009      +007                           
+4354          CD-43 6872  975762226472894                   110834.8-434941111314.7-442220285.02 15.06 5.80  +1.66 +2.08         K5-M0III           -0.001 0.000      +001V?                         
+4355          CP-63 1860  975832513202893  W                110836.8-633733111245.2-641011292.44-03.33 5.23  -0.06 -0.25         B8V                -0.050+0.007      +021      206  6.7  19.1      *
+4356 69    LeoBD+00 2761  97585118731                       110838.4+002829111345.6-000411258.13 54.08 5.42  -0.03 -0.05         A0V                -0.043-0.002 +.018+005V?    177                  
+4357 68Del LeoBD+21 2298  97603 81727 422I W        5143    110847.4+210418111406.5+203125224.22 66.83 2.56  +0.12 +0.12 +0.03   A4V                +0.142-0.130 +.048-020V     181  6.0 191.4AB   3*
+4358          BD+08 2476  976051187352895  W                110850.0+083629111401.8+080338247.99 60.08 5.79  +1.12 +1.13 +0.38E  K3III              +0.048-0.110      +017V?         6.0  21.5      *
+4359 70The LeoBD+16 2234  97633 99512 423           5144    110859.6+155834111414.4+152546235.37 64.59 3.34  -0.01 +0.06 -0.03   A2V                -0.061-0.079 +.026+008V      20                 *
+4360          CP-52 4350  97651238878                       110909.5-524118111339.3-531354288.48  6.87 5.76  +1.32 +1.42         K2III              -0.025+0.038      +047                           
+4361          CP-58 3315  97670238877              Var      110911.0-590430111330.8-593710290.83  0.93 5.74  -0.10 -0.71         B1.5V              -0.009-0.006      +018       62                 *
+4362 72    LeoBD+23 2322  97778 817362897I          5147    110953.1+233826111512.2+230544218.10 67.88 4.63  +1.66 +1.85 +1.31   M3IIb             e-0.024-0.006 +.010+016                          *
+4363          BD+53 1480  97855 27970        8108A          111018.8+531900111604.0+524623151.12 58.82 6.50  +0.43 -0.12         F6V+F9V            +0.162+0.057 +.052-041V?  =<  6  1.7  12.7      *
+4364          CD-43 6899  97866222671                       111012.9-431120111454.0-434403285.05 15.76 6.21  +1.61 +1.93         K4III              -0.025-0.016      +009                           
+4365 73    LeoBD+14 2367  97907 99525    I S                111038.0+135111111551.9+131827239.93 63.74 5.32  +1.20 +1.09         K3III              -0.007-0.008      +018SB     19:                *
+4366          BD+13 2379  97937 99527                       111044.3+132330111557.8+125041240.81 63.49 6.67  +0.27 +0.07         A9Vp               -0.034-0.055      -020SB    109                 *
+4367          BD+50 1807  97989 43675 424                   111103.8+500120111641.9+492835155.72 61.19 5.88  +1.08              gK0                 -0.083-0.009      +000V?                         
+4368 74Phi LeoBD-02 3315  980581381021292  W                111134.6-030618111639.7-033906262.66 51.65 4.47  +0.21 +0.14 +0.11   A7IVn              -0.108-0.036 +.019-003V?    225  4.7  96.9      *
+4369          BD-06 3344  980881381062900    8115  SV Crt   111154.0-063521111658.2-070805265.81 48.81 6.14  +0.20 +0.15         A8IVpeSrCrSi       -0.006+0.009D+.004-008SB2O   25  3.8  57.2AC   3*
+4370          CD-45 6837  98096222687      W                111148.8-452010111627.7-455248286.15 13.87 6.31  +0.40 -0.03         F3V                -0.136+0.066D+.016-002           0.3   2.4      *
+4371 75    LeoBD+02 2409  981181187642902I                  111208.6+023338111717.4+020038257.02 56.25 5.18  +1.52 +1.84 +0.94   M0III-IIIb         +0.056-0.140 +.010-059V?                         
+4372          CD-37 7146  98161202283                       111225.5-372807111711.8-380052283.19 21.22 6.27  +0.10               A3Vn               -0.088+0.010      -003                           
+4373          CD-34 7345  98221202289                       111249.6-341128111739.2-344414281.91 24.28 6.45  +0.40 -0.03         F4V                -0.006+0.002      -009                           
+4374 53Xi  UMaBD+32 2132  98230 62484    I:  8119B  5165    111250.9+320531111810.9+313145195.08 69.25 4.87H                     G0V                -0.432-0.586 +.137-016SB1O    3  0.5   3.1AB   4*
+4375 53Xi  UMaBD+32 2132  98231 62484    I   8119A  5165    111250.9+320531111811.0+313145195.08 69.25 4.41H +0.59 +0.04 +0.34   G0V                -0.430-0.586 +.137-016SB1O    1  0.5   3.1AB   4*
+4376          CD-35 7111  98233202291                       111255.3-355920111743.0-363204282.68 22.62 6.68  +0.98               G8-K0III           -0.077+0.026      +003V                          
+4377 54Nu  UMaBD+33 2098  98262 62486 425I   8123           111304.7+333824111828.7+330539190.73 69.08 3.48  +1.40 +1.55 +0.70   K3-IIIBa0.3        -0.026+0.028 +.020-009SB   < 19: 6.0   7.2      *
+4378          BD+12 2319  98280 99544                       111308.0+123156111821.0+115905243.13 63.44 6.66  +0.07 +0.05         A2V                +0.004-0.036      -035                           
+4379          CP-67 1703  982922513412903  W        5163    111314.2-671637111719.0-674925294.21-06.56 6.06  +1.76 +1.93         M2III              +0.013-0.007      +026V          7.5  34.7      *
+4380 55    UMaBD+38 2225  98353 624911293                   111340.9+384403111907.9+381108177.34 67.74 4.78  +0.12 +0.03 +0.03   A1Vp:              -0.057-0.068 +.025-003SB2O   47                 *
+4381 76    LeoBD+02 2411  98366118778                       111347.0+021155111855.0+013902257.99 56.23 5.91  +1.04 +0.87        gK0                 -0.038-0.055      +005V?                         
+4382 12Del CrtBD-13 3345  98430156605 426I                  111420.4-141414111920.5-144643272.07 42.51 3.56  +1.12 +0.97 +0.60   G8III-IV           -0.122+0.208 +.024-005SB   < 19:                 
+4383          BD+67  692  98499 154782905                   111446.9+673858112053.8+670602135.79 47.70 6.21  +1.01               G8                 +0.049-0.052      -056                           
+4384          CP-63 1881  98560251357                       111505.4-640211111916.5-643457293.25-03.46 5.99  +0.46  0.00         F6IV               -0.302+0.044      +006                           
+4385          CP-78  638  986172568232904                   111538.5-790715111834.3-794007298.68-17.57 6.35  +0.26 +0.08         A8IIIm:            +0.031-0.026      -004                           
+4386 77Sig LeoBD+06 2437  98664118804 427                   111558.8+063439112108.2+060146253.36 59.90 4.05  -0.06 -0.12 -0.07   B9.5V s            -0.092-0.012 +.001-005SB     65                  
+4387          CP-74  801  98672256826                       111600.3-743542111936.3-750833297.03-13.33 6.27  -0.03 -0.12         B9.5-A0V           -0.038+0.004      +023V?                         
+4388          BD+57 1316  98673 279992907                   111605.5+573721112149.3+570430144.73 56.10 6.43  +0.15 +0.09         A7Vn               -0.058+0.009      -010SB    230                  
+4389          CP-71 1238  98695256828                       111610.8-712648112003.9-715940295.93-10.38 6.41  +0.05 -0.48         B4V                -0.039-0.005      -000                           
+4390   Pi  CenCP-53 4498  98718238986 428  W                111626.7-535635112100.4-542928289.96  6.09 3.89  -0.15 -0.59 -0.17   B5Vn               -0.036-0.006D+.011+009V     326  0.7   0.2      *
+4391          BD+65  828  98772 15486 429                   111654.9+645240112251.3+641950137.71 50.18 6.02  +0.09 +0.09         A1Vnp              -0.005+0.034      +001      160                 *
+4392 56    UMaBD+44 2083  98839 437192908I                  111720.4+440153112249.6+432858164.73 65.77 4.99  +0.99 +0.80 +0.46   G7.5IIIa:Ba0.3     -0.038-0.013 -.002+003     < 19:                 
+4393          CD-43 7006  98892222751                       111738.9-440548112223.1-443845286.70 15.40 6.12  +0.92 +0.68         G8III              -0.048-0.034      +001                           
+4394          BD+00 2782  98960118825    I                  111810.7+004051112318.0+000754261.20 55.69 6.05  +1.46 +1.78         K3                 -0.037-0.018      +022                           
+4395 13Lam CrtBD-17 3367  98991156646                       111824.3-181349112321.9-184648275.60 39.37 5.09  +0.42 -0.06         F5III              -0.312-0.034 +.023+011SB1O   14                 *
+4396          CD-35 7163  989932023912909  W                111822.0-353658112312.7-360953283.65 23.38 5.00  +1.46 +1.63         K6III              -0.020 0.000 +.025-005SB         9.5  31.3       
+4397          CP-76  662  99015256832                       111834.8-770335112157.1-773630298.07-15.59 6.43  +0.20 +0.11         A5III-IV           -0.081-0.005      -006V?                         
+4398          CP-56 4449  990222390172910                   111835.5-561350112308.1-564646291.02  4.04 5.79  +0.01               A4:pe              -0.030+0.006      +003                          *
+4399 78Iot LeoBD+11 2348  99028 99587    I   8148   5184    111842.7+110449112355.5+103145247.60 63.55 3.94  +0.41 +0.07 +0.21   F4IV               +0.168-0.075 +.052-010SB1O   20  2.8   1.1      *
+4400 79    LeoBD+02 2418  99055118831      D                111854.4+015724112402.3+012428260.09 56.83 5.39  +0.94 +0.66         G8IIICN-0.5        -0.020+0.005      -010V?         0.7   0.0      *
+4401          CP-64 1657  99104251383      W                111902.0-642421112321.8-645718293.78-03.66 5.11  -0.08 -0.42         B5V                -0.001-0.005D+.010+019V?     78  1.2   2.6       
+4402 14Eps CrtBD-10 3260  99167156658    I                  111933.5-101839112436.6-105134271.04 46.57 4.83  +1.56 +1.96 +0.94   K5III              -0.028+0.027      +003V    < 19:                 
+4403          CD-41 6529  991712227731294                   111934.9-420712112422.1-424009286.33 17.38 6.12  -0.18 -0.81         B2IV-V             -0.005+0.001      +010                           
+4404          BD+12 2335  99196 995982912I                  111947.7+115847112458.9+112549246.45 64.34 5.80  +1.38 +1.58 +0.54E  K4III              -0.102-0.005      +038V?                        *
+4405 15Gam CrtBD-16 3244  99211156661 431    8153           111953.1-170805112452.9-174102275.41 40.52 4.08  +0.21 +0.11 +0.11   A5V                -0.098+0.004 +.028+001V?    131  4.8   5.3      *
+4406          CP-71 1248  992642568342911                   112011.8-714226112411.1-721524296.32-10.51 5.59  +0.06 -0.57  0.00   B2IV-V             -0.030-0.003      +002V                         *
+4407          BD+56 1518  99283 28017                       112018.7+562355112557.1+555102145.26 57.42 5.75                      K0III              -0.066+0.048      -006V?                         
+4408 81    LeoBD+17 2356  99285 996012913  W                112023.5+170023112536.4+162723236.75 67.45 5.57  +0.36 +0.02         F2V                -0.143-0.005      +018V      30  3.6  55.7       
+4409          CD-35 7189  99322202428      I                112038.4-353050112529.4-360347284.08 23.64 5.22  +0.99 +0.77 +0.31E  K0III              -0.113+0.020 +.032+004           4.6   1.3      *
+4410 80    LeoBD+04 2463  99329118851                       112041.6+042439112550.0+035136257.90 59.03 6.37  +0.33 +0.05         F3IV               -0.080-0.041      -003SB    112                  
+4411          CD-37 7235  99333202430      W                112042.5-371151112533.1-374452284.73 22.07 5.89  +1.54 +1.72         M3III              -0.042-0.014      +007           5.5   4.7       
+4412          BD+34 2222  99373 62551                       112104.4+335959112625.5+332702188.72 70.63 6.32  +0.43  0.00?        F7V                -0.040+0.016      -025        5                  
+4413          CP-63 1893  99453251402                       112123.3-632515112543.2-635822293.70-02.65 5.17  +0.50 +0.04         F7V                -0.313-0.078 +.040-005SB2    84                  
+4414 83    LeoBD+03 2502  994911188641296    8162A          112141.6+033329112645.3+030047259.28 58.52 6.50  +0.79 +0.49 +0.36   K0IV               -0.724+0.180 +.054-003V?         1.1  28.5AB   3*
+4415          CP-60 2941  99556251406      W                112205.4-603354112635.3-610655292.87  0.09 5.30  -0.08 -0.54 -0.06   B3IV               -0.026+0.002      +009      205  8.5  13.0      *
+4416 16Kap CrtBD-11 3098  995641566852914  W                112207.2-114826112709.5-122124272.85 45.53 5.94  +0.49 +0.03         F4III-IV           -0.097+0.026      +006           7.0  27.9       
+4417          CP-52 4567  99574239074      W                112207.6-523637112647.3-530936290.32  7.63 5.81  +0.52               K0III+A2-3V        -0.041+0.014      -008           0.4   0.1       
+4418 84Tau LeoBD+03 2504  996481188751297I W                112247.6+032425112756.2+025122259.90 58.57 4.95  +1.00 +0.79 +0.50   G7.5IIIa           +0.018-0.012 +.034-009     < 19: 2.6  91.1AB   4*
+4419          BD-00 2442  99651138216      W                112247.0-010858112753.7-014200264.70 54.85 6.25  +1.04 +0.73        gK2                 -0.034-0.003      -010           1.4   0.3       
+4420          CD-34 7471  99712202478                       112305.3-344642112758.5-351943284.31 24.51 6.45                      K5III:             -0.006+0.012      -018V                          
+4421          BD+62 1183  99747 155202915                   112321.8+621921112904.6+614642138.87 52.73 5.83  +0.36 -0.05         F5Va vw            -0.112+0.237      -008V                          
+4422 57    UMaBD+40 2433  99787 62572        8175           112341.0+395314112904.2+392013172.23 68.97 5.31  +0.01 +0.01         A2V                -0.050+0.016 +.025-011SB    176  2.5 346.3AD   6*
+4423          CD-41 6565  99803222813      W                112346.0-420725112835.1-424027287.10 17.64 5.08  -0.03               B9V                -0.040+0.008D+.007+003SB      0  2.7  13.2      *
+4424          BD+57 1324  99859 28035                       112407.6+571722112943.5+564415143.51 57.01 6.28  +0.15 +0.11 +0.04   A4m                -0.089-0.034      +009       90                 *
+4425          CP-71 1253  99872256843      W                112412.7-715523112818.2-722828296.69-10.62 6.09  +0.16 -0.42         B3V                -0.043-0.020      +012           0.1   0.3       
+4426 85    LeoBD+16 2266  99902 99629    I                  112429.3+155756112941.9+152448240.45 67.70 5.74  +1.32              gK4                 -0.028-0.045      -029                           
+4427          BD+55 1468  99913 28038                       112438.7+545452113012.9+542142146.03 58.97 6.41R                     K0III              +0.010-0.057      -022                           
+4428          CD-2310009  99922179935        8183           112440.1-235448112938.6-242748280.16 34.77 5.76  +0.07               A0V                -0.048+0.043D+.021-002           3.0   8.3AB   3 
+4429          BD+81  373  99945  18843956           5230    112447.9+814040113150.4+810738126.62 35.42 6.15  +0.24 +0.12         A2m                -0.149+0.032 +.020+003                           
+4430          BD+47 1880  99967 43784              EE UMa   112457.4+471229113025.0+463927156.83 64.78 6.35  +1.27 +1.19         K2IIICN-1          +0.011+0.032      +027SBO                       *
+4431 58    UMaBD+43 2122  99984 43787 432                   112506.5+434320113031.1+431024163.28 67.08 5.94  +0.49 -0.01         F4V                -0.050+0.083      -030    =<  6                 *
+4432 87    LeoBD-02 3360  999981382382917I                  112512.3-022706113018.9-030013266.78 54.07 4.77  +1.54 +1.83 +0.84   K3.5IIIFe-1        +0.022-0.014 +.015+019V?   < 19:                *
+4433 86    LeoBD+19 2459 100006 996372918I                  112515.9+185738113029.0+182435233.76 69.44 5.52  +1.05 +0.82 +0.37E  K0III              -0.088+0.020 +.026+027V                         *
+4434  1Lam DraBD+70  665 100029 15532 433I          5231    112528.3+695259113124.2+691952132.98 46.20 3.84  +1.62 +1.97 +0.99   M0IIICa-1          -0.039-0.017 +.026+007                          *
+4435          BD+48 1952 100030 43790                       112527.1+482857113052.9+475545154.61 63.94 6.42  +0.88 +0.54         G9IV               -0.229-0.070      +038                           
+4436          BD+49 2062 100055 43793                       112542.0+492030113110.2+484721153.20 63.35 6.56  +0.93 +0.72         G9III              -0.030-0.040      +006                           
+4437 88    LeoBD+15 2345 100180 99648        8196A          112635.1+145518113144.9+142152243.43 67.48 6.20  +0.57 +0.07         G0V                -0.330-0.189 +.035-004    =< 10  2.8  15.5      *
+4438          CP-60 3011 100198251437              V809 Cen 112640.3-604336113115.0-611642293.45  0.11 6.38  +0.52 -0.11         A3Iae              -0.007+0.003      -004V                         *
+4439          BD+61 1246 100203 15542        8197           112641.0+613811113220.8+610457138.90 53.52 5.48  +0.50 -0.01         F8V                +0.002-0.069 +.045-046SB      0  1.4   0.5      *
+4440          BD-19 3285 1002191799642919                   112647.8-201332113147.6-204636278.98 38.36 6.24  +0.54               F7IV               -0.131+0.032      +010V?  =< 15                  
+4441   Omi1CenCP-58 3692 100261239145    I W       Omi1 Cen 112708.6-585325113146.1-592632292.95  1.88 5.13  +1.08 +0.78 +0.66   G30-Ia             -0.005-0.005 +.024-020V          6.4  13.3      *
+4442   Omi2CenCP-58 3693 1002622391462920          Omi2 Cen 112711.3-585749113148.8-593057292.98  1.81 5.15  +0.49 -0.11 +0.46   A2Ia               -0.008+0.001 +.014-017       43                 *
+4443          CD-28 8928 100286179967        8202B          112718.5-284255113216.1-291548282.88 30.51 5.81  +0.53 +0.02         F8V                -0.014+0.138D+.013+010V?         0.1   9.3      *
+4444          CD-28 8928 100287179968        8202A          112718.9-284247113216.3-291540282.88 30.51 5.64  +0.53 +0.04         F8V                -0.028+0.145D+.013+004V?         0.1   9.3      *
+4445          CD-26 8620 100307179969    I                  112725.2-261143113223.3-264448281.86 32.87 6.16  +1.66 +1.99 +0.98E  M1III              -0.079+0.033      +035V?                         
+4446          BD-07 3250 1003431382652921I                  112742.5-071631113247.5-074939271.56 50.19 5.95  +1.38 +1.64         K4III              -0.007+0.004      -001V?                         
+4447          CD-39 7168 1003782228562922                   112755.9-395308113248.1-402611287.12 20.01 5.64  +1.58 +1.81         K6III              -0.069+0.052      +003                           
+4448          CP-66 1605 100382251451                       112753.0-662435113219.9-665744295.29-05.27 5.90  +1.13 +1.12         K1IIICNIb-II       -0.004-0.001      -011                           
+4449          CD-30 9303 100393202554    I          5246    112757.2-303207113254.1-310514283.75 28.84 5.04  +1.58 +1.95 +1.01   M2IIIb             -0.030+0.006 +.019+019                           
+4450   Xi  HyaCD-31 9083 100407202558 434I W                112804.9-311815113300.1-315128284.08 28.13 3.54  +0.94 +0.71 +0.48   G7III              -0.206-0.040 +.027-005V          7.0  68.2      *
+4451          BD-15 3295 100418156750                       112812.2-154337113314.6-161650277.05 42.63 6.05  +0.60               F9III              -0.002-0.043      -004                           
+4452          BD+37 2195 100470 626042923                   112837.3+372210113356.3+364856177.50 70.98 6.40  +1.05 +0.93 +0.53   K0III              -0.129-0.046 -.014+018SB                        *
+4453          CD-39 7175 100493222863      W                112844.7-400206113337.3-403513287.33 19.92 5.39  +0.12               A2IV-V             -0.071+0.024 +.028+009      137  0.0   1.0      *
+4454          BD+11 2372 100518 99668                       112859.0+113437113410.0+110125250.77 65.72 6.55  +0.18 +0.10 +0.12   A2m                +0.045-0.031      -005V                          
+4455 89    LeoBD+03 2521 1005631189292924                   112914.8+033656113422.0+030336262.18 59.69 5.77  +0.46 +0.01         F5V                -0.182-0.104 +.045+003V?     14                  
+4456 90    LeoBD+17 2374 100600 99673        8220           112930.2+172059113442.5+164749239.18 69.47 5.95  -0.16 -0.64 -0.14   B4V                -0.011+0.003D+.003+019SB    117  1.1   3.6AB   3*
+4457          BD+55 1473 100615 280642925                   112934.4+552016113504.9+544707144.44 59.04 5.63  +1.02               K0III              +0.008+0.008      +018V?                         
+4458          CD-32 8179 100623202583                       112937.8-321805113429.5-324953284.79 27.31 5.98  +0.81 +0.39 +0.46   K0V                -0.674+0.826 +.106-023V                          
+4459          BD+21 2331 100655 81886                       112950.7+205940113503.8+202629229.80 71.32 6.45  +1.01               G9III              -0.059-0.005      -007                           
+4460          CP-53 4637 1006732391892926                   113001.0-534242113445.7-541551291.79  6.94 4.62  -0.08 -0.21 -0.53   B9Ve               -0.056+0.017      +003V     159                 *
+4461  2    DraBD+70  670 100696 15567    I                  113011.3+695246113602.8+691922132.45 46.38 5.20  +1.01 +0.68 +0.50   K0III              +0.111-0.127 +.025-002     < 19:                 
+4462          CD-48 6630 100708222883               5253    113009.5-483518113456.8-490812290.29 11.85 5.50  +1.04 +0.92         K1III-IV           -0.170+0.168 +.034-001                           
+4463          CD-46 7199 100733222887      W       V763 Cen 113023.8-464910113513.2-472221289.79 13.55 5.71  +1.66 +1.93 +1.00E  M3III              -0.089-0.004 +.008+018           7.6   6.7      *
+4464          BD+11 2377 100740 996832927                   113032.7+112753113543.4+105440251.62 65.92 6.56  +0.13 +0.10         A4Vn               +0.035-0.023      -005SB    232                  
+4465          BD+28 2022 100808 81893        8231           113102.2+282003113617.9+274652206.35 73.33 5.80  +0.23 +0.07         F0V                +0.023+0.003D+.012+008SB         0.2   0.5AB   3*
+4466          CD-46 7205 100825222895 435                   113104.6-470514113555.6-473830289.99 13.32 5.25  +0.25 +0.12         A7m                +0.036-0.049 +.022+005       43                  
+4467   Lam CenCP-62 2127 100841251472 436  W                113110.0-622759113546.8-630111294.47-01.40 3.13  -0.04 -0.17 -0.01   B9III              -0.041-0.005      -001V       0  8.2  16.3      *
+4468 21The CrtBD-08 3202 1008891382961299                   113136.5-091457113640.9-094808274.25 48.86 4.70  -0.08 -0.18 -0.07   B9.5Vn             -0.061+0.008      +001SB    192                 *
+4469          CD-32 8199 100893202622      W                113137.2-330057113635.0-333412285.51 26.76 5.74  +1.02 +0.83         K0III              +0.040-0.037      +042           2.1   3.3AB   3 
+4470          CD-36 7291 100911202627                       113144.8-364102113640.8-371416286.81 23.28 6.31  +0.06 +0.06         A1V                -0.013-0.019      -002V                          
+4471 91Ups LeoBD-00 2458 100920138298 437I D                113149.7-001618113656.9-004926267.26 56.80 4.30  +1.00 +0.75 +0.52   G8.5IIICN-0.5      +0.004+0.043 +.019+001     < 19: 4.5   0.1      *
+4472          CP-60 3140 100929251479                       113142.2-602957113622.3-610308293.97  0.51 5.83  -0.09 -0.63         B2.5IV             -0.021+0.008      +011        0                 *
+4473          CD-32 8202 100953202634                       113203.4-322557113701.2-325917285.40 27.34 6.29  +0.46 +0.06         F6III-IV           -0.011-0.079      +010                           
+4474          BD+51 1679 101013 280812929                   113228.4+511021113753.0+503706148.77 62.66 6.14  +1.07 +0.76 +0.48   G9III:Ba2.5        -0.047-0.021      -004                           
+4475          CP-60 3182 101021251486                       113222.8-604348113700.6-611700294.12  0.31 5.15  +1.12 +1.15         K0III              -0.224+0.006 +.002+003                          *
+4476          CD-47 6997 101067222917                       113243.0-471139113733.9-474450290.29 13.30 5.44  +1.24 +1.30 +0.44E  K2III              -0.072+0.027 +.001-001                          *
+4477 59    UMaBD+44 2110 101107 43837                       113300.9+441048113820.6+433732159.98 67.87 5.59  +0.33 +0.01         F2II-III           -0.145-0.033      +002V      51                  
+4478          BD+09 2523 101112118961                       113300.5+092614113809.8+085303256.00 64.85 6.17  +1.08 +0.95 +0.36E  K1III              -0.059+0.019      +011                          *
+4479   Pi  ChaCP-75  744 101132256857 438                   113308.1-752034113715.6-755348298.36-13.69 5.65  +0.35  0.00 +0.21C  F1III              -0.134+0.001      -010                           
+4480 60    UMaBD+47 1894 101133 438392931                   113311.4+472320113833.5+465003154.16 65.63 6.10  +0.38 +0.14         F5III s            -0.037-0.033      -024                           
+4481          BD+65  843 101150 15580        8249           113312.1+645402113849.2+642049135.31 51.00 6.46R                     A5IV               +0.016+0.006D+.004-022           1.3   1.8       
+4482          BD+34 2242 101151 62635                       113315.6+341047113832.2+333732186.02 73.02 6.27  +1.32 +1.48         K2III              -0.028-0.019      -006                           
+4483  1Ome VirBD+08 2532 1011531189652932I         Ome Vir  113318.2+084116113827.6+080803257.26 64.32 5.36  +1.57 +1.53         M4III              -0.006+0.005 -.005+004V?                        *
+4484          BD-01 2546 101154138314        8247           113317.5-015257113824.1-022610269.29 55.59 6.22  +1.12 +1.08         G9III              -0.031+0.009      -015V?         4.7   5.2      *
+4485          CP-66 1629 1011622515012930                   113316.5-670359113748.4-673713295.99-05.75 5.96  +1.02 +0.83         K0III              -0.083-0.007      +034                           
+4486          BD+45 1947 101177 43841        8250A          113329.1+453942113844.9+450631157.05 66.91 6.44  +0.56 +0.05         G0V                -0.594+0.026 +.049-018SBO        1.9   9.4AB   5*
+4487          CP-61 2463 101189251505                       113326.9-611623113807.3-614935294.39-00.18 5.15  -0.02 -0.16         ApHgMn             -0.071+0.017 +.024+004        0                 *
+4488 24Iot CrtBD-12 3466 101198156802      W                113335.2-123905113840.1-131207277.00 45.97 5.48  +0.52               F7V                +0.092+0.120      -024           5.4   1.4       
+4489          CD-24 9867 1012591800652933                   113359.0-240938113900.4-244316282.69 35.29 6.42  +0.82 +0.32         G5                 +0.033-0.241      +097V?                         
+4490          BD-13 3420 1013691568202934    8259           113447.3-135451113951.1-142807278.08 44.92 6.21   0.00               A1V                -0.038-0.011      +005       68  6.0   7.8      *
+4491          BD-15 3323 101370156819    I          5284    113446.9-160357113950.4-163713279.21 42.93 6.19  +1.62 +1.75         M3.5IIIBa0.2Ca1    -0.010-0.009      +026V?                        *
+4492          CP-64 1685 101379251522      W       GT Mus   113451.4-645036113929.4-652352295.53-03.56 5.17  +0.80 +0.36 +0.63   G2III+A0V          -0.042-0.006 +.006+014SB         0.8   0.2AB   4*
+4493          BD+58 1331 101391 28093                       113459.2+583127114027.4+575814140.07 56.73 6.37  -0.12 -0.34         B9pHgMn:           -0.012+0.021      +004                           
+4494   Omi HyaCD-34 7610 101431202695 439                   113514.7-341125114012.8-344441286.72 25.87 4.70  -0.07 -0.22 -0.05   B9V                -0.042 0.000      +006      188:                 
+4495 92    LeoBD+22 2391 101484 819412936I                  113535.1+215430114047.1+212110228.85 72.91 5.26  +0.98 +0.44?+0.48   K1III              -0.064-0.049      +009     < 17                  
+4496 61    UMaBD+35 2270 101501 626551300  W        5291    113547.1+344600114103.0+341206183.53 73.32 5.33  +0.72 +0.25 +0.36   G8V                -0.012-0.381 +.119-005V    < 17  4.9 159.3       
+4497          CP-53 4691 101541239284               5289    113552.4-532449114042.6-535807292.55  7.47 5.96  +1.66 +2.02         M1III              +0.004-0.019      -012V?                        *
+4498          CD-28 9027 101563180098                       113610.3-283852114108.4-291147284.99 31.21 6.44  +0.66 +0.19         G0V                -0.324+0.215 +.032-019SB                         
+4499          CP-61 2514 101570251535                       113609.8-613208114053.6-620524294.78-00.34 4.94  +1.15 +0.81 +0.57   G3Ib               -0.020+0.008 +.025+014SB                         
+4500          BD+55 1481 101604 28101    I                  113618.6+554334114143.6+551021142.47 59.23 6.27  +1.49               K5                 -0.015+0.023      -007                           
+4501 62    UMaBD+32 2179 101606 626582938  W                113622.0+321759114134.3+314446191.85 74.13 5.73  +0.43 -0.07         F4V                -0.351+0.032 +.026+032V   =< 10  4.3  84.3      *
+4502          CD-42 7155 1016152229602937                   113624.6-423229114119.8-430545289.57 17.95 5.55                      A0V                -0.082+0.003      +008SB      0                  
+4503          CD-31 9181 101666202717    I W                113644.2-315638114144.0-322959286.29 28.11 5.22  +1.48 +1.78         K5III+F7V          +0.004-0.042 +.015+034           3.1  67.0AC   4*
+4504  3    DraBD+67  714 101673 15606 440I                  113653.8+671754114228.4+664442133.20 48.99 5.30  +1.28 +1.24         K3III              -0.043+0.038      +003V?   < 17                  
+4505          BD+23 2375 101688 81949                       113653.6+224602114205.2+221239226.49 73.51 6.59R                     F2IV-V             -0.092-0.063      -023       60                  
+4506          BD-19 3326 101695180117                       113700.6-194417114203.5-201738281.62 39.69 6.22  +0.95               K0                 -0.015-0.048      -014V                          
+4507          CP-82  469 1017822586213982  W                113733.2-823244114101.2-830600300.71-20.53 6.33  +1.08 +0.88         K0III              -0.071+0.015      +012           5.2  22.2       
+4508          CD-36 7371 1018832027442939                   113828.3-363804114327.2-371125288.20 23.73 5.98  +1.46 +1.71         K3III              -0.015-0.024      +036                           
+4509          CP-78  677 101917256865                       113841.0-784504114255.4-791823299.66-16.87 6.39  +0.90 +0.59         K0III-IV           +0.132-0.008      +033                           
+4510          BD-05 3340 101933138375                       113848.6-060715114355.1-064038274.69 52.45 6.07  +0.96 +0.71        gG8                 +0.059-0.040      -003V?                         
+4511          CP-61 2559 101947251555    I         V810 Cen 113844.8-615604114331.2-622922295.18-00.64 5.03  +0.80 +0.35 +0.36   G00-IaFe1         v-0.008+0.003 +.037+010V                         *
+4512          BD+26 2250 101980 819602940I   8285           113900.8+254623114413.2+251306216.37 74.81 6.02  +1.53 +1.85         K5III              -0.014+0.012      -003V?         4.7  36.7      *
+4513          CP-62 2250 101995251559                       113906.1-621922114352.9-625242295.32-01.01 6.10  +0.06 +0.13         A2III-IV           +0.017-0.015      +002V?                         
+4514 27Zet CrtBD-17 3460 1020701568691301I                  113941.6-174741114445.8-182103281.53 41.73 4.73  +0.97 +0.74 +0.48   G8IIIa             +0.031-0.030 +.030-005     < 19:                *
+4515  2Xi  VirBD+09 2545 102124119029                       114007.7+084851114517.1+081530260.18 65.48 4.85  +0.18 +0.10         A4V                +0.061-0.018 +.039-001V     158                  
+4516          CD-48 6777 102150222997                       114017.0-483054114512.6-490411291.91 12.38 6.26  +1.17               K1III              -0.031+0.014      +004                           
+4517  3Nu  VirBD+07 2479 1022121190351302I          5318    114043.1+070523114551.6+063146262.86 64.18 4.03  +1.51 +1.79 +1.01   M1IIIab           e-0.018-0.184 +.014+051V?                        *
+4518 63Chi UMaBD+48 1966 102224 43886 441I          5319    114046.3+482002114603.0+474646150.32 65.72 3.71  +1.18 +1.16 +0.60   K0.5IIIb           -0.137+0.030 +.019-009V    < 19:                *
+4519          CD-44 7564 102232223009               5317    114046.9-450806114543.9-454124291.09 15.67 5.29  -0.12 -0.55 -0.04C  B6III              -0.047+0.009      -010V?     56                  
+4520   Lam MusCP-66 1640 102249251575 442  W                114053.1-661027114536.4-664343296.49-04.68 3.64  +0.16 +0.15 +0.08   A7III              -0.103+0.037      +016       71  9.0  40.6      *
+4521          BD+56 1544 102328 281422941I                  114134.5+561104114655.6+553742140.77 59.21 5.27  +1.27 +1.48 +0.60   K2.5IIIbCN1Ca1     +0.014-0.030      +002     < 19:                 
+4522          CP-60 3325 102350251579 443  W        5325    114140.4-603721114630.8-611042295.19  0.71 4.11  +0.90 +0.58 +0.43   G5Ib-II            -0.027-0.015 +.011-003           8.8  25.        
+4523          CD-39 7301 102365223020    I'                 114144.9-395722114631.1-403002289.82 20.71 4.91  +0.66 +0.10 +0.38   G3V                -1.531+0.401 +.099+015                          *
+4524          CD-35 7438 102397202805                       114205.7-352102114707.0-355425288.58 25.17 6.17  +0.96               G8III              +0.034-0.037      +009V                          
+4525          CD-29 9337 102438202811                       114215.6-294328114715.7-301713286.84 30.58 6.48  +0.68 +0.24         G5V                -0.276-0.240 +.064+012                           
+4526          CP-57 4989 1024612393732942           5334    114225.9-570829114719.1-574147294.42  4.11 5.41  +1.67 +1.99         K5III              -0.025+0.017 +.004-052                          *
+4527 93    LeoBD+21 2358 102509 819981304I W       DQ Leo   114249.6+204629114759.1+201308235.01 73.93 4.53  +0.55 +0.28 +0.36   G5III-IVe+A7V      -0.149-0.003 +.022+000SBO =< 50  4.4  74.3      *
+4528  4    VirBD+09 2549 102510119058      W                114246.6+084805114754.9+081445261.46 65.86 5.32  +0.02 +0.04         A1                 -0.057+0.012 +.017-001V      68  6.8 150.2AB   3 
+4529          BD-09 3366 102574156896      W                114318.3-094515114823.5-101848278.60 49.56 6.26  +0.58 +0.13         F7V                -0.099-0.115      +015V?  =< 10  3.3  88.4AB   3*
+4530   Mu  MusCP-66 1649 102584251597              Mu  Mus  114325.7-661531114814.3-664853296.76-04.70 4.72  +1.54 +1.91 +0.88   K4III              +0.013-0.015 +.013+037                          *
+4531          BD+15 2381 102590 99800        8311   5344    114329.9+145023114838.7+141703251.07 70.53 5.88  +0.29 +0.07         F0V                -0.107+0.007 +.053+006V          2.4   1.1      *
+4532          CD-26 8789 1026201802081305I         II Hya   114341.9-261137114845.1-264459286.01 34.05 5.11  +1.60 +1.67         M4+III             -0.032-0.010 +.019+007                          *
+4533          BD+00 2843 102634138420                       114355.3+001414114901.2-001907271.74 58.72 6.15  +0.52 +0.08         F7V                -0.217+0.009      +004V?      6                  
+4534 94Bet LeoBD+15 2383 102647 99809 444I   8314  Bet Leo  114357.5+150752114903.6+143419250.65 70.81 2.14  +0.09 +0.07 +0.02   A3V                -0.497-0.114 +.082-000V     121  6.5 264.0AD   4*
+4535          BD+17 2402 102660 99812                       114404.8+164801114914.9+161434246.81 71.94 6.04  +0.27 +0.14         A3m                +0.054-0.061      -023SB1O   22                 *
+4536          BD+35 2284 102713 62718                       114430.0+352915114941.7+345554178.56 74.67 5.70  +0.46 +0.02         F5IV               -0.115+0.006      -007SBO                       *
+4537          CP-63 1988 1027762516022944           5357    114448.9-631357114941.1-634718296.18-01.73 4.32  -0.15 -0.59 -0.14   B3Vne              -0.021+0.006      +029V     268                 *
+4538          CP-69 1595 1028392516042945                   114509.3-694011114956.6-701333297.74-07.98 4.97  +1.40 +1.22 +0.75   G6Ib               -0.009+0.001 +.009+018                           
+4539          BD-15 3363 102845156926                       114514.2-151829115019.5-155150282.11 44.52 6.13  +0.95               K0                 -0.013+0.009      -004V                          
+4540  5Bet VirBD+02 2489 102870119076 445I W                114529.1+021942115041.7+014553270.50 60.75 3.61  +0.55 +0.11 +0.28   F9V                +0.743-0.271 +.104+005V       3  5.0 512.3AC   3*
+4541          CP-61 2677 102878251605                       114533.3-620536115027.2-623858295.99-00.60 5.70  +0.26 -0.04         A2Iab              -0.012-0.002      -010                          *
+4542          CD-26 8807 102888180232                       114533.9-264319115037.1-271640286.67 33.67 6.48  +0.98               G8III              -0.087+0.010      -003                           
+4543          BD+13 2465 102910 998272946    8320           114547.4+125003115055.3+121644256.30 69.47 6.35  +0.27 +0.08         F0IVm s            -0.137+0.023      +007       60  4.9  14.9      *
+4544          BD-04 3152 1029281384451306  D                114555.4-044638115102.2-052000276.47 54.41 5.64  +1.06 +0.88         K0III              +0.003 0.000      +012SB                        *
+4545          BD+34 2264 102942 62731      W                114557.7+335550115109.4+332230183.62 75.58 6.27  +0.32 +0.11 +0.09   Am                 -0.021+0.019      +002V          2.5  46.6       
+4546          CD-44 7614 102964223062 446                   114608.6-443701115108.7-451025291.92 16.40 4.46  +1.30 +1.46 +0.67   K3III              -0.070-0.010 +.022+002                           
+4547          BD-11 3190 1029901569402947  W        5365    114617.5-113758115121.9-121116280.66 48.07 6.35  +0.40               F1III-IV           -0.238+0.048      +009       28  7.2  30.7       
+4548          CD-30 9506 1030262028832948                   114638.0-301614115141.6-305006288.08 30.31 5.85  +0.56 +0.05         F7V                -0.010-0.295 +.019+033                           
+4549          CP-64 1724 103079251617      W                114657.6-643858115151.2-651222296.73-03.05 4.90  -0.11 -0.54 -0.13   B4V                -0.039-0.010      +021V?     57  2.2   1.8      *
+4550          BD+38 2285 103095 627381307          CF UMa   114713.0+382610115258.8+374307168.42 73.69 6.45  +0.75 +0.17 +0.45   G8Vp               +4.003-5.813 +.116-098V          5.5   1.7      *
+4551          CP-56 4836 103101239443      W                114713.3-562556115210.1-565916294.89  4.96 5.57  +0.07               A2V                -0.119+0.033      +023V?         5.3  54.6AB   3 
+4552   Bet HyaCD-33 8018 103192202901      W       Bet Hya  114751.3-332106115254.6-335429289.27 27.41 4.28  -0.10 -0.33 -0.08   B9IIIpSi           -0.050+0.005D+.010-001       72  0.9   0.8      *
+4553          CD-34 7760 1032662029102949                   114823.7-343034115326.8-350400289.72 26.31 6.17  +0.08 +0.09         A2V                -0.079-0.028      -009                           
+4554 64Gam UMaBD+54 1475 103287 28179 447I          5379    114834.3+541503115349.8+534141140.84 61.38 2.44   0.00 +0.02 -0.03   A0Ve               +0.095+0.012 +.028-013SB    168                 *
+4555          BD+01 2624 103313119100                       114843.1+010630115350.3+003307273.07 60.04 6.30  +0.20 +0.16         F0V                -0.039-0.007      +010       75                  
+4556          CP-56 4861 103400239475                       114911.8-565113115411.5-572436295.26  4.61 6.06  +0.05               A0-1:III           -0.014+0.005      -014                           
+4557          CD-37 7536 103437202926      W                114924.7-371138115425.8-374456290.66 23.76 6.46  +0.52 -0.03         F7V                -0.309+0.060 +.052-012           1.3   1.1      *
+4558          CD-25 8930 1034621802882950                   114937.0-250934115442.5-254250287.21 35.42 5.30  +0.88 +0.53         G4III              +0.048+0.081 +.032-011V                          
+4559  6    VirBD+09 2560 1034841191112951                   114955.3+090000115503.1+082638264.79 67.04 5.58  +0.94 +0.67 +0.46  gK0                 -0.031+0.016      -010                           
+4560 65    UMaBD+47 1913 103483 43945        8347A DN UMa   114953.6+470159115505.7+462837149.12 67.68 6.54  +0.10 +0.08         A3Vn               +0.001+0.008D+.003-008SB    150  0.4  63.0ABxD 4*
+4561 65    UMaBD+47 1914 103498 43946        8347D          114959.3+470134115511.2+462811149.10 67.70 7.03  +0.01 +0.02         A1pCrEuSr:         -0.009+0.006D+.003-007    =< 25  0.4  63.0ABxD 4*
+4562          BD+37 2230 103500 62754    I                  115003.9+371851115514.1+364523170.44 74.71 6.49  +1.58 +1.83 +0.98E  M3III              -0.054-0.050      +019                           
+4563          CP-62 2408 103516251640                       115001.4-624321115459.8-631644296.64-01.10 5.91  +0.19 +0.01         A3Ib               -0.026+0.011      -028                           
+4564 95    LeoBD+16 2319 103578 998691308  W                115031.9+161212115540.5+153848251.67 72.70 5.53  +0.11 +0.12         A3V                +0.009+0.002 -.003-021SBO    54       90.       *
+4565          CD-27 8384 103596180307    I                  115034.9-275511115540.1-282837288.34 32.81 5.93  +1.50 +1.86         K5III              +0.004-0.026      +011V                          
+4566 66    UMaBD+57 1343 103605 281912953                   115045.0+570918115558.4+563555137.73 58.91 5.84  +1.10               K1III              +0.010 0.000      +013V                          
+4567 30Eta CrtBD-16 3358 1036321569881309           5392    115055.1-163538115600.9-170903284.47 43.73 5.18  -0.02  0.00         A0V                -0.051-0.006 +.023+015V?     74                  
+4568          CD-38 7410 103637202950                       115050.1-390756115554.7-394121291.45 21.94 6.13  +1.02               K0III              +0.048-0.008      -000                           
+4569          BD+62 1204 103736 15666                       115140.1+620625115653.2+613257134.05 54.39 6.22  +0.96               G8III              -0.031-0.040      +017                           
+4570          CD-46 7521 103746223127                       115141.3-463059115643.9-470421293.35 14.78 6.26  +0.40 +0.04 +0.22C  F5V                -0.126+0.016      +008                           
+4571          CD-32 8413 103789202971              LV Hya   115158.8-324531115703.7-331855290.06 28.19 6.21  -0.04               A0V                -0.055+0.003      -010                           
+4572          BD+41 2253 103799 439632954                   115205.9+405407115714.6+402037159.77 72.68 6.62  +0.46 -0.02         F6V                -0.160-0.062      +026        7                  
+4573          CP-61 2829 103884251659               5397    115238.3-615330115740.1-622656296.76-00.22 5.57  -0.15 -0.66 -0.23   B3V                -0.022-0.006      +020V     185                 *
+4574          BD+33 2174 103928 627741310    8368           115259.0+324956115807.2+321626185.75 77.34 6.42  +0.29               A9V                -0.109-0.060      +002V?     67  5.0 122.5AC   4*
+4575          BD+62 1206 103953 15673                       115308.0+620117115820.6+612753133.83 54.53 6.76                      K0III              +0.042 0.000      -026                           
+4576          CP-55 4751 1039612395332956           5402    115311.8-554538115815.2-561902295.57  5.79 5.44  -0.08               B8III              -0.021+0.006      -005                           
+4577          CD-40 7041 103974223139      W                115315.5-402328115820.3-405650292.24 20.82 6.79  +0.97 +0.70         K1III              -0.057+0.021      +007           2.6   3.1       
+4578          CP-63 2073 104035251664                       115344.8-634658115847.7-642021297.27-02.05 5.61  +0.18 -0.11         A3Ib               -0.001+0.012      +002V                          
+4579          CD-25 8963 104039180349        8371           115348.2-252105115854.4-255432288.40 35.48 6.43  +0.03 +0.04         A0-1V              -0.027-0.019      +013           0.2   0.2      *
+4580          BD+01 2636 104055119147        8372           115356.4+010512115903.4+003150275.47 60.58 6.17  +1.26 +1.41         K2IV               -0.061+0.027      +012V?         7.7  14.2      *
+4581          BD+33 2176 104075 62784        8374           115408.9+334327115917.6+331003181.58 77.23 5.96  +1.15 +1.11 +0.58   K1III              +0.004+0.003      -001V?         6.0   4.5      *
+4582          CD-51 6236 1040812395482959                   115406.1-510823115910.9-514148294.74 10.34 6.05  +1.28               K1-2III            -0.012-0.003      +010                           
+4583   Eps ChaCP-77  772 104174256894      W                115439.4-773954115937.3-781319300.21-15.62 4.91  -0.06 -0.16 -0.05   B9Vn               -0.057-0.002D+.012+013V     205  0.6   0.9      *
+4584          BD+34 2279 104179 62786                       115449.3+343526115957.2+340206177.83 76.96 6.50  +0.22 +0.15         A9III              -0.064+0.042      -008      101                  
+4585  7    VirBD+04 2556 1041811191562960                   115449.5+041244115956.9+033919273.05 63.50 5.37   0.00  0.00         A1V                -0.017-0.006 +.016-003V?     65                  
+4586          BD+81  389 104216  19673957I          5415    115505.5+812440120018.6+805111125.42 36.03 6.17  +1.61 +1.90 +1.04E  M2III              -0.068-0.038      +032V?                        *
+4587          BD-09 3413 104304157041                       115536.5-095234120044.5-102646283.11 50.47 5.55  +0.77 +0.44 +0.36   G8-K0IV            +0.126-0.476 +.080+000V?                         
+4588          BD-21 3443 104307180374        8389           115535.3-211650120042.5-215014287.61 39.52 6.28  +1.22               K0IV               +0.028+0.006      +004V          7.1  11.7       
+4589  8Pi  VirBD+07 2502 1043211191641311  S                115544.9+071019120052.4+063651270.30 66.23 4.66  +0.13 +0.11 +0.04   A5V                +0.001-0.030 +.021-010SBO    74  2.0   0.0      *
+4590          BD-18 3295 1043371570422961                   115544.2-190608120051.2-193932286.92 41.63 5.26  -0.20               B1.5V              -0.021+0.013      +002SBO   119                 *
+4591          BD-00 2520 104356138533                       115554.5-011233120101.8-014605278.14 58.66 6.31  +1.21 +1.06        gG8                 -0.015-0.070      +036V?                         
+4592          CP-56 4954 104430239589                       115623.4-565647120129.0-573013296.24  4.72 6.16   0.00 -0.03         A0V                -0.073-0.015      -004                           
+4593          BD+36 2230 104438 628022963                   115632.4+363604120139.5+360231169.73 76.17 5.59  +1.01 +0.80 +0.51   K0III              -0.091-0.081 +.028+030V?                         
+4594 67    UMaBD+43 2179 104513 440022965  W       DP UMa   115702.2+433602120206.8+430244151.89 71.20 5.21  +0.26 +0.07 +0.11   F0Vam              -0.326+0.070 +.019+006V?     76  1.7 310.5AB   4*
+4595          CP-84  371 1045552586323983  W                115719.1-850430120220.1-853754301.93-22.86 6.05  +1.29 +1.54         K3III              -0.065+0.001      +017           4.3  25.0       
+4596          CP-70 1454 104570256897                       115722.6-705556120228.6-712920299.03-08.99 6.42  +1.17 +1.14         K1III              -0.064+0.018      -009                           
+4597          CP-68 1604 1046002516992966                   115731.0-683806120237.7-691132298.60-06.73 5.89  -0.08 -0.28         B9V                -0.039-0.007      +008                           
+4598          BD-06 3499 104625138551    I                  115744.5-070738120251.6-074101282.54 53.25 6.22  +1.49 +1.83         K5                 -0.036+0.020      -008                           
+4599   The1CruCP-62 2543 104671251705      W                115755.8-624522120301.5-631846297.53-00.95 4.33  +0.27 +0.04 +0.18   Am                 -0.150+0.008 +.021-002SB2O   33  9.3   4.5      *
+4600          CD-41 6938 104731223193 449                   115828.7-415226120339.6-422603293.60 19.57 5.15  +0.41 -0.03 +0.25C  F6V                +0.331-0.114 +.039+036        0                  
+4601          CP-73  924 104752256898                       115835.2-733926120344.3-741250299.64-11.65 6.44  +1.23 +0.97 +0.60C  G6III              -0.027+0.007      +009                           
+4602  2    ComBD+22 2437 104827 82123        8406           115909.3+220058120416.6+212733238.22 77.86 5.87  +0.22 +0.11 +0.11   F0IV-V             +0.036-0.004D+.005+006SB  =< 54  1.4   3.6      *
+4603   The2CruCP-62 2561 104841251717              The2 Cru 115910.1-623632120419.2-630956297.64-00.78 4.72  -0.08 -0.61 -0.10   B2IV               -0.020+0.008      +016SBO    56                 *
+4604          CP-67 1896 104878251720                       115929.2-674619120438.7-681945298.62-05.85 5.35  -0.01 -0.17         A0IV               -0.054-0.012 +.016+025SB    187                 *
+4605   Kap ChaCP-75  777 104902256899                       115936.1-755749120446.5-763109300.15-13.90 5.04  +1.49 +1.78 +0.76   K4III              -0.082+0.048 +.003-002                           
+4606          BD+86  176 104904  19751642                   115942.8+860829120428.1+853514123.98 31.45 6.27  +0.59               F6V                -0.056+0.092      +008V?                         
+4607          CP-60 3697 104933251723                       115947.7-602441120457.1-605809297.32  1.40 5.96  +1.67 +2.04 +0.92E  M2III              -0.038-0.032      -000                           
+4608  9Omi VirBD+09 2583 104979119213 450I                  120006.9+091718120512.5+084359270.07 68.60 4.12  +0.98 +0.63 +0.49   G8IIIaCN-1Ba1CH1   -0.220+0.046 +.039-030V?   < 19:                *
+4609          BD+77  461 104985  7500 451                   120010.3+772754120515.1+765421126.32 39.92 5.80  +1.01 +0.85         G9III              +0.147-0.091 +.014-020V                          
+4610          BD+63  999 105043 15710        8417   5452    120036.7+632930120539.7+625559131.64 53.41 6.13  +1.17 +1.15         K2III              -0.050-0.075      -026V?         5.4   2.3      *
+4611          CP-64 1791 105071251734                       120042.2-645924120553.2-653250298.24-03.09 6.33  +0.22 -0.47         B6Iab-Ib           -0.031-0.012      -013V                          
+4612          CD-35 7694 1050782031191312  W        5456    120048.1-350814120556.7-354138292.64 26.27 6.23  -0.08               B8V                -0.031-0.002      -018V          7.7  25.4       
+4613          BD-02 3460 1050891385852967                   120052.5-023427120559.8-030754281.26 57.82 6.37  +1.00 +0.79        gG8                 -0.028-0.019      +017V?                         
+4614          CP-67 1903 105138251737                       120107.2-680540120619.8-683903298.83-06.14 6.23  +1.24 +1.04         G3Ib               -0.014+0.020      +006                           
+4615          CP-65 1788 105151251738      W                120111.7-650908120623.1-654233298.32-03.24 6.06  +0.65 +0.40         G8-K0III+A3-5V     -0.049+0.002      -004           0.0   0.1AB   3*
+4616   Eta CruCP-63 2145 1052112517422969  W                120139.8-640321120652.9-643649298.18-02.15 4.15  +0.34 +0.03 +0.16   F2III              +0.033-0.037 +.053+009SB     65  7.5  44.0       
+4617          CP-74  880 1053402569052971                   120233.6-744839120749.8-752201300.13-12.73 5.18  +1.30 +1.37 +0.60C  K2II-III           -0.098+0.019 +.020-045                           
+4618          CD-49 6813 105382239687      W     B          120254.3-500615120805.2-503941295.94 11.62 4.47  -0.15 -0.67 -0.18   B6IIIe            v-0.035-0.010      +017      127  1.9 268.6AB   3*
+4619          CD-50 6688 105383239686      W     C          120253.9-501223120804.8-504548295.96 11.52 6.37  -0.05               B9V                -0.037+0.002      +016V?         1.9 268.6AB   3*
+4620          CD-47 7396 105416223235                       120303.8-480808120814.7-484134295.62 13.57 5.34  -0.01 -0.04  0.00C  B9V                -0.025-0.017      +003V                         *
+4621   Del CenCD-50 6697 105435239689 452  W     A Del Cen  120310.4-500956120821.5-504321296.00 11.57 2.60  -0.12 -0.90 -0.12   B2IVne            v-0.034-0.008 +.026+011V     181  1.9 268.6AB   3*
+4622          CP-60 3777 105437251757                       120311.4-601726120824.6-605050297.71  1.59 6.22  +1.74 +1.88         K3-4II             -0.013+0.003      +010                           
+4623  1Alp CrvCD-2410174 105452180505                       120315.2-241016120824.8-244344290.66 37.12 4.02  +0.32 -0.02 +0.18   F2III-IV           +0.086-0.040 +.070+004V      16                 *
+4624          CD-43 7502 105509223241              V788 Cen 120343.3-434605120853.8-441934294.96 17.89 5.75  +0.24 +0.16 +0.11C  A2mA5-F2          v-0.046-0.049      -009SB2                       *
+4625          CD-40 7128 105521223242              V817 Cen 120344.1-404029120854.5-411353294.39 20.93 5.48  -0.07 -0.62 -0.08   B3IV              e-0.024-0.006      +000V?    204                 *
+4626 10    VirBD+02 2517 1056391192452972  W                120433.8+022734120941.3+015352279.54 62.86 5.95  +1.12 +1.14         K3III              +0.043-0.178 +.009+003           7.3  39.5      *
+4627          BD+75  469 105678  7512                       120455.9+751304120947.3+743941126.63 42.17 6.35  +0.50               F6IV               +0.001+0.006      -019       34                  
+4628          CD-34 7956 105686203183      W                120452.5-340853121002.5-344218293.36 27.40 6.17  +0.03 -0.02         A0V                -0.052-0.018D+.006-010           1.8   3.4       
+4629 11    VirBD+06 2559 1057021192492973                   120457.6+062147121003.4+054825276.30 66.52 5.72  +0.35 +0.17 +0.15   F2-6IIIm vs        -0.158+0.016 +.019-009V?                        *
+4630  2Eps CrvBD-21 3487 105707180531 453I          5483    120458.8-220349121007.5-223711290.59 39.26 3.00  +1.33 +1.47 +0.64   K2.5IIIaBa0.2:     -0.071+0.014 +.027+005                          *
+4631          CD-37 7714 1057762031952974                   120522.4-371846121033.8-375213294.09 24.30 6.06  +0.20               A5V                +0.047-0.035      -007                           
+4632  3    ComBD+17 2446 105778 999731313                   120525.8+172157121031.6+164833258.30 76.00 6.39  +0.06 +0.10         A4V                -0.017+0.001      -012V                          
+4633          BD+28 2084 105805 82166               5485    120541.3+275017121046.1+271653209.63 80.96 6.01  +0.11 +0.09         A4Vn               -0.009-0.014      -009SB2   172                 *
+4634          CP-60 3812 105841251778                       120550.4-604314121104.9-611639298.10  1.22 6.08  +0.39 +0.09         F2-3IV             -0.134-0.018      -003                           
+4635  3    CrvBD-22 3305 105850180546                       120554.8-230244121103.9-233609291.12 38.34 5.46  +0.06               A2V                -0.063-0.016 +.023+011      124                  
+4636          CD-44 7845 105852223266      W                120550.8-445159121102.9-452522295.54 16.87 6.61  +1.08 +0.79 +0.51C  K0III              -0.018+0.009      +006V          3.8   2.3       
+4637          CD-50 6752 105920239735                       120619.7-504804121131.4-512134296.61 11.02 6.23  +0.82 +0.49         G6III+G:           -0.208-0.067      +026                           
+4638   Rho CenCD-51 6455 105937239737                       120625.4-514842121139.1-522207296.78 10.03 3.96  -0.15 -0.62 -0.17   B3V                -0.035-0.016 +.032+015V     140                 *
+4639          BD+82  356 105943  1991      W                120630.2+821558121100.0+814236124.71 35.28 6.00  +1.62              gK5                 -0.029+0.007      -027V?         2.0  66.7       
+4640  4    ComBD+26 2316 105981 821782976I                  120646.7+262539121151.2+255213218.78 81.06 5.66  +1.41 +1.61         K4III              -0.038-0.031      +022SBO                       *
+4641 68    UMaBD+57 1359 106002 28291    I                  120645.8+573640121144.9+570316133.49 59.25 6.43R                    gK5                 +0.007-0.013      +035                           
+4642          BD+29 2265 106022 82181                       120656.1+290540121201.2+283210201.47 81.17 6.49  +0.36 +0.01         F5V                +0.097-0.071      -015V?                        *
+4643  5    ComBD+21 2398 106057 821822977                   120704.1+210556121209.3+203231247.11 78.87 5.57  +0.95               K0II-III           -0.020-0.019      -025V                          
+4644          CP-62 2624 106068251790                       120703.7-622340121222.0-625703298.51-00.42 5.92  +0.29 -0.33         B8Ia-Iab           -0.007+0.002      -002                          *
+4645          CP-69 1646 106111251791              S Mus    120723.8-693543121246.8-700907299.64-07.53 6.17  +0.84 +0.57         F6Ib              v-0.022-0.009      +011SB                        *
+4646          BD+78  412 106112  7522 454                   120731.0+781019121211.9+773659125.64 39.31 5.14  +0.33 +0.10         A5m                +0.010+0.022 +.031-000SB1O   79                 *
+4647          CD-33 8252 106198203245               5503    120801.7-333409121313.0-340732293.97 28.08 6.5   +1.66 +1.46         M4III              -0.030-0.006      +003V                         *
+4648          CD-38 7581 106231203250                       120812.9-382222121325.3-385545294.89 23.35 5.76  -0.13               B4IV               -0.003-0.006      -043V?                        *
+4649          CP-77  804 106248256915                       120818.1-780102121355.7-783425301.01-15.84 6.35  +1.24 +1.41         K2-3IIICNII        -0.033-0.003      +035                           
+4650 12    VirBD+11 2440 106251 999972978                   120820.3+104908121325.9+101544273.17 70.90 5.85  +0.27 +0.11 +0.11   A2m                -0.091-0.010      +002       35                  
+4651          CD-33 8257 106257203252      W                120825.1-331411121336.7-334734294.00 28.42 6.33  +0.08               A0V                -0.006-0.011      -011V?         1.8   1.6      *
+4652          CD-45 7630 106321223297      W                120848.9-451004121402.6-454326296.13 16.65 5.31  +1.43 +1.59 +0.70C  K3III              -0.042+0.007 +.007+007SB         1.3   2.8      *
+4653          CP-63 2203 106343251803                       120855.7-635108121416.8-642431298.93-01.83 6.22  +0.12 -0.82         B1.5Ia             -0.013+0.004      -007      100                  
+4654          BD+54 1504 106478 283091314                   120946.0+535928121443.4+532605134.94 62.83 6.16  +1.04              gK0                 -0.019-0.015      +000                          *
+4655          BD-20 3606 106485180602                       120949.5-201718121459.6-205039291.58 41.22 5.83  +1.05              gG7                 +0.001+0.004      +016V                          
+4656   Del CruCP-58 4189 106490239791 455          Del Cru  120949.9-581133121508.7-584456298.23  3.79 2.80  -0.23 -0.91 -0.24   B2IV               -0.041-0.009 +.003+022V?    194                 *
+4657          BD-09 3468 106516157168      W                121001.7-094342121510.6-101845288.49 51.55 6.11  +0.46 -0.13 +0.16E  F5V                +0.034-1.017 +.034+008V       8  6.8  73.3      *
+4658          CD-41 7056 106572223309                       121019.4-412108121530.5-415447295.81 20.46 6.26  +1.01 +0.76         K0III              -0.331-0.175 +.025+025                           
+4659          BD+71  610 106574  75322980I                  121022.6+704524121508.5+701200127.39 46.61 5.71  +1.19              gK2                 -0.023-0.026 +.013-014V?                         
+4660 69Del UMaBD+57 1363 106591 28315 456  W        5513    121028.7+573518121525.6+570157132.57 59.42 3.31  +0.08 +0.07  0.00   A3V                +0.104+0.009 +.061-013V     177  6.6 189.6AB   3*
+4661          BD-22 3322 106612180619        8481           121036.0-224749121547.0-232113292.42 38.79 6.54  +0.45               F3V                +0.039-0.030D+.016+018V          1.2   1.6      *
+4662  4Gam CrvBD-16 3424 106625157176 457I          5515    121039.7-165912121548.4-173231290.99 44.50 2.59  -0.11 -0.34 -0.09   B8IIIpHgMn         -0.161+0.023      -004SB     41                 *
+4663  6    ComBD+15 2436 1066611000122981                   121055.5+152721121600.2+145356267.16 75.25 5.10  +0.06 +0.08         A3V                -0.080-0.034 +.026+010SB    170                  
+4664          CP-71 1323 106676256919                       121052.3-720329121623.5-723653300.28-09.92 6.22  -0.01 -0.06         A0V                -0.053-0.026      +028                           
+4665          BD+73  549 106677  7533              DK Dra   121059.5+730628121541.4+723303126.66 44.32 6.29  +1.14               K0IIIe+K0IIIe      -0.014-0.035      -048SB2O                      *
+4666  2    CVnBD+41 2284 106690 44097 458I   8489           121106.9+411301121607.6+403937148.99 74.63 5.66  +1.55 +1.96         M1III+F7V          +0.017-0.032D+.004-016SB         3.1  11.4      *
+4667  7    ComBD+24 2443 106714 822112982I                  121117.0+243005121620.5+235643232.90 81.47 4.95  +0.97 +0.68 +0.48   G8IIIFe-0.5        -0.027-0.007 +.006-028     < 17                 *
+4668          BD+33 2213 106760 629282983I S       Var?     121128.5+333713121630.1+330341172.65 80.40 5.00  +1.14 +1.07 +0.58   K0.5IIIb           -0.053-0.111 +.022-042SB1O < 17                 *
+4669          CP-64 1844 106797251826                       121141.2-650812121706.0-654134299.41-03.06 6.06  +0.03 -0.05         A0V                -0.057-0.001      +021V                          
+4670          BD-15 3442 106819157184               5527    121153.8-160817121703.3-164137291.17 45.39 6.05  +0.10 +0.12         A2IV               -0.048+0.003      -012                           
+4671   Eps MusCP-67 1931 106849251830    I:        Eps Mus  121209.9-672415121734.1-675739299.75-05.30 4.11  +1.58 +1.55 +1.69   M5III              -0.244-0.025 +.046+007SB                        *
+4672          BD+54 1510 106884 28327    I                  121233.6+534453121729.5+531128134.24 63.19 5.81  +1.30 +1.52         K6III              +0.034-0.046      -041                           
+4673          BD+29 2275 106887 82219        8501           121228.3+292930121730.5+285614197.38 82.30 5.70  +0.16 +0.12 +0.05   A4m:               -0.042+0.037      -007V      75  4.9   8.6      *
+4674   Bet ChaCP-78  741 106911256924 459           5532    121228.6-784525121820.7-791844301.34-16.54 4.26  -0.12 -0.51 -0.10   B5Vn               -0.048+0.017      +023      255                 *
+4675          CD-35 7842 106922203319      W                121233.8-353217121747.3-360538295.36 26.28 6.15  +0.01               A0V                -0.037-0.006D+.004-014           0.3   0.5       
+4676          BD+15 2442 106926100023                       121239.1+154205121744.3+150839268.05 75.68 6.34  +1.37               K4III              +0.044-0.063      -042SB                         
+4677          BD-03 3262 106975138703        8505B          121301.3-032357121809.1-035716287.17 57.89 6.99  +0.36 +0.03         F3V                -0.017+0.016D+.016+001           0.4  20.1      *
+4678          BD-03 3263 106976138704        8505A          121301.7-032338121809.6-035655287.17 57.90 6.54  +0.33 +0.01         F2V                -0.013+0.024D+.016-001           0.4  20.1      *
+4679   Zet CruCP-63 2235 106983251841      W                121300.9-632650121826.1-640011299.33-01.36 4.04  -0.17 -0.69 -0.19   B2.5V              -0.050-0.010      +016      113  9.0  33.8      *
+4680          BD+31 2350 107054 629432984                   121329.1+304828121831.6+301457187.60 82.14 6.23  +0.30 +0.02         A9.5III            +0.077-0.116      -018V     140                  
+4681 13    VirBD+00 2920 107070138710                       121332.6-001353121840.3-004714285.85 60.99 5.90  +0.17 +0.13         A5Vn               +0.029-0.016      -014V     195                  
+4682          CP-54 5113 1070792398382985  W        5544    121339.7-543514121859.7-550835298.27  7.43 5.00  +1.59 +1.95 +1.06   M1III              -0.076-0.014 +.010-007SB         7.0  35.7      *
+4683          BD+87  107 107113  2012                       121355.8+865930121651.4+862610123.56 30.65 6.33  +0.43 -0.08         F4V                +0.210-0.003 +.037-006                           
+4684          BD+26 2326 107131 82237              FM Com   121359.5+263350121902.1+260028219.89 82.67 6.48  +0.18 +0.09 +0.07   A5-7mIV-V          -0.004-0.022      +001SB    175                 *
+4685  8    ComBD+23 2448 107168 82239                       121416.1+233525121919.1+230205240.56 81.66 6.27  +0.17 +0.15 +0.02   A5III vs           -0.022-0.012      +001V?  =< 12                 *
+4686          BD+88   71 107192  20103958                   121423.5+881515121520.3+874200123.35 29.40 6.28  +0.35 -0.01         F2V                -0.028+0.054      -004V      67                  
+4687          BD+75  470 107193  75402986                   121420.8+754256121849.9+750938125.72 41.79 5.38  -0.02 -0.05         A1V                -0.040+0.002 +.018-003V     217                  
+4688  9    ComBD+28 2106 107213 82244                       121429.0+284256121929.6+280925202.80 82.85 6.33  +0.50 +0.08         F8V s              -0.197-0.129 +.025-008V       8                 *
+4689 15Eta VirBD+00 2926 107259138721 460  D        5555    121447.3-000640121954.4-004001286.40 61.19 3.89  +0.02 +0.06  0.00   A2IV               -0.063-0.018 +.016+002SB2O   34  0.5   0.0     3*
+4690  3    CVnBD+49 2130 107274 441271316I                  121453.2+493221121948.7+485903136.46 67.31 5.29  +1.66 +1.97 +1.06   M0III              -0.012+0.007      +008V                          
+4691          BD-21 3511 107295180695        8515           121500.0-213711122010.7-221032293.46 40.12 5.97  +0.82               G3IV               -0.109-0.025D+.008-001V?         1.8   0.3       
+4692          CP-65 1842 107301251854                       121458.8-651714122028.0-655034299.77-03.16 6.21  -0.04 -0.15         B9V                -0.056-0.015      -008                           
+4693          BD+27 2114 107325 82250               5559    121518.0+271040122019.7+263710215.35 83.05 5.54  +1.09 +1.07 +0.54   K2III-IV           -0.065-0.107      -013SBO                       *
+4694          BD+26 2329 107326 82249               5557    121516.5+263323122017.7+260007220.37 82.95 6.15  +0.30 +0.08 +0.14   F0IV               -0.145+0.019 +.060+008V     109                 *
+4695 16    VirBD+04 2604 1073281193411317I W                121516.2+035210122021.0+031845284.27 65.05 4.96  +1.16 +1.15 +0.61   K0-IIIbFe-1        -0.292-0.065 -.002+036V?   < 19: 0.0   0.6     3*
+4696  5Zet CrvBD-21 3514 107348180700        8517           121522.8-213936122033.7-221257293.58 40.09 5.21  -0.10 -0.38 -0.13   B8Vne              -0.095-0.028      -006SB         8.4  11.2      *
+4697 11    ComBD+18 2592 1073831000532987I   8521           121539.9+182044122043.0+174734264.15 78.28 4.74  +1.01 +0.79 +0.52   G8+III             -0.111+0.092      +042V    < 19: 8.0   9.1      *
+4698          BD+27 2115 107398 82254        8519A          121539.4+273646122041.3+270317211.78 83.16 7.13  +0.36 -0.01         F3V+F3V            -0.001-0.114D+.008-015           0.1   8.5      *
+4699          BD-12 3614 1074181572262988I W        5564    121545.8-130039122055.7-133356291.67 48.64 5.14  +1.05 +0.89 +0.52   K1III              -0.006+0.014 +.020+013V?   < 19: 8.1  48.6       
+4700   Eps CruCP-59 4188 1074462518622989           5568    121557.6-595055122121.6-602404299.23  2.25 3.59  +1.42 +1.63 +0.74   K3-4III            -0.175+0.087 +.026-005                          *
+4701 70    UMaBD+58 1371 107465 28346    I                  121600.2+582516122050.8+575150130.79 58.79 5.55  +1.43 +1.71         K5III              +0.041-0.073      -043V                          
+4702          CP-55 5019 107543239880                       121633.5-554910122157.5-562229298.83  6.26 5.92  +1.57 +1.64         K4III+F:           -0.008-0.012      -001                           
+4703   Zet2MusCP-66 1747 1075662518662990  W                121633.6-665801122207.3-673119300.13-04.81 5.15  +0.19 +0.17         A5V                -0.031-0.003 +.007-017V?     86  5.4  32.4       
+4704   Zet1MusCP-67 1939 107567251868                       121636.7-674504122211.9-681827300.22-05.59 5.74  +1.04 +0.82         K0III              -0.016-0.057      +020V                          
+4705          BD+25 2498 107655 82271                       121709.2+251943122210.8+244626231.00 83.02 6.19  -0.01 -0.04 -0.02   A0V                -0.062-0.008      -004       53                 *
+4706          CP-56 5202 107696239901              Var?     121724.2-570716122249.3-574034299.10  4.98 5.39  -0.10 -0.41         B9V                -0.046-0.013      -005V                         *
+4707 12    ComBD+26 2337 107700 822731318    8530   5581    121728.7+262404122230.3+255046222.50 83.40 4.81  +0.49 +0.26 +0.33   G0III-IV+A3V       -0.011-0.009 +.014+001SB2O   35  3.7  65.3AC   3*
+4708 17    VirBD+06 2599 107705119360        8531   5579    121726.9+055142122232.0+051820284.15 67.12 6.40  +0.60 +0.08 +0.28   F8V                -0.166-0.053 +.027+005    =< 10  3.0  20.6      *
+4709          CP-85  343 107739258644                       121737.1-853546122537.5-860902302.46-23.30 6.33  +1.08 +0.89         K0III              -0.017-0.001      +025                           
+4710          CP-66 1752 107773251877                       121750.9-670503122313.8-673754300.26-04.91 6.36  +0.89 +0.53         G8-K0IV            -0.759+0.254 +.013+031                           
+4711  6    CrvCD-2410314 107815180747                       121808.8-241708122321.6-245026294.89 37.59 5.68  +1.16              gK1                 -0.019-0.010      -002                           
+4712          CD-34 8117 1078322034202992                   121819.7-345129122335.4-352446296.56 27.11 5.32  -0.08               B9III              -0.036-0.003      -010       45                 *
+4713          CD-38 7700 107833203421                       121819.6-384453122336.9-391811297.08 23.25 6.40  +0.29               F2V                -0.009-0.016      -013                           
+4714          CD-38 7701 107860203424                       121828.0-382123122344.9-385440297.06 23.64 5.79  -0.08               B9V                -0.036 0.000      -008                           
+4715  4    CVnBD+43 2218 107904 441552993          AI CVn   121851.9+430548122347.0+423234141.22 73.59 6.06  +0.33 +0.18         F3III-IV           -0.078+0.015      -000SB     73                 *
+4716  5    CVnBD+52 1626 107950 283662994I         Var      121910.0+520658122401.5+513344133.05 65.02 4.80  +0.87 +0.62 +0.44   G6IIIBa0.2         +0.014+0.013 +.038-012SB   < 17                 *
+4717 13    ComBD+26 2344 107966 82291              GN Com   121917.5+263911122418.5+260555221.04 83.85 5.18  +0.08 +0.11 +0.02   A3V                -0.016-0.011 +.009+001V      54                 *
+4718          CD-40 7281 107998223417      W                121926.7-404941122444.7-412303297.57 21.21 6.25  +1.18 +1.06         K2-3III            -0.064-0.071      +001           2.4  10.0      *
+4719          BD+26 2345 108007 82293        8539           121925.6+260813122426.7+253458225.75 83.76 6.42  +0.27 +0.08 +0.10   A7V+F4V            -0.014-0.004D+.011-006V     148  1.0   1.4AB   3*
+4720          CP-65 1862 108054251893                       121942.5-651246122517.3-654614300.25-03.03 6.30  +0.96 +0.74         G8-K0IV            -0.080-0.121      +025                           
+4721          CD-41 7163 1080632234262995                   121950.4-415734122508.5-423052297.78 20.09 6.11  +0.65               G5III+F-G          -0.130-0.022      +034                           
+4722          BD-10 3467 108107157272                       122002.1-110320122511.7-113637292.75 50.74 5.95  +0.03               A1V                -0.065-0.023      -003V?    160                  
+4723          CD-27 8670 1081101807861319                   122004.1-271142122518.4-274457295.89 34.77 6.09  +1.27               K1III              +0.005-0.001      +010V?                         
+4724          CD-34 8146 108114203450               5610    122005.4-343756122521.8-351111296.93 27.38 5.73  -0.06               B9III             v-0.034-0.006      -011                          *
+4725          BD+24 2455 108123 82297                       122013.3+242853122515.1+235534239.94 83.28 6.03  +1.10 +1.00 +0.56   K0III              +0.058-0.038 +.007-005V?                        *
+4726 71    UMaBD+57 1373 108135 28375    I                  122016.4+571956122503.2+564639130.16 59.98 5.81  +1.62 +1.83 +1.00E  M3IIIb             -0.014-0.018      -017V?                         
+4727          BD+64  896 108150 158012996  W                122026.5+642124122506.4+634810127.76 53.08 6.32  +0.91               G8III              -0.015+0.002      -004           3.7  52.3       
+4728  6    CVnBD+39 2521 108225 63000 461I                  122055.4+393424122550.9+390107145.50 76.97 5.02  +0.96 +0.73 +0.46   G9III              -0.078-0.032 +.030-004V?   < 19:                 
+4729          CP-62 2742 108250251903      W     C          122057.1-623404122630.9-630721300.12-00.39 4.86  -0.12 -0.59         B4IV               -0.040-0.025      +027SBO   137  0.4   4.4AB   3*
+4730   Alp1CruCP-62 2745 108248251904 462  W     A          122102.0-623241122635.9-630557300.13-00.36 1.33  -0.24 -1.03         B0.5IV             -0.036-0.012D+.008-011SBO   117  0.4   4.4AB   3*
+4731   Alp2CruCP-62 2745 108249            W     B          122102.5-623243122636.5-630558300.13-00.36 1.73  -0.26 -0.95         B1V                -0.034-0.007D+.008-001      197  0.4   4.4AB   3*
+4732          CD-50 6975 108257239948      W                122107.5-505347122631.6-512703298.98 11.23 4.82  -0.14 -0.64 -0.16   B3Vn               -0.044-0.017      +005V     312  8.8  21.7      *
+4733 14    ComBD+28 2115 108283 823102997I                  122124.0+274920122624.1+271606210.06 84.43 4.95  +0.27 +0.18 +0.15   F0p                -0.013-0.008 +.014-004SB    227                 *
+4734          CD-48 7426 108309223443                       122131.2-482126122648.2-485448298.78 13.76 6.26  +0.68 +0.22         G3-5V              -0.633-0.082 +.040+030                          *
+4735          CD-32 8713 108323203477 463                   122135.3-321632122651.7-324948296.99 29.76 5.55  +0.01               B9V                -0.005-0.027      -015                           
+4736          CP-63 2283 108355251911                       122148.9-631406122724.6-634721300.28-01.04 6.00  +0.07               B8IV               -0.035-0.018      +042                           
+4737 15Gam ComBD+29 2288 108381 823132999I                  122157.2+284928122656.3+281606199.63 84.46 4.36  +1.13 +1.15 +0.51   K1IIIFe0.5         -0.083-0.080 +.003+004V?   < 17                 *
+4738 16    ComBD+27 2134 108382 82314                       122159.3+272246122659.3+264932214.72 84.55 5.00  +0.08 +0.13 +0.02   A4V                -0.006-0.011 +.024+002V?     89                 *
+4739          CP-58 4289 108396239960              BL Cru   122158.0-582618122728.7-585931299.84  3.74 5.50  +1.45 +1.58 +1.88   M4-5III            -0.031+0.005 +.007+072                          *
+4740          BD+72  565 108399  75632998                   122203.6+722903122624.2+715547125.67 45.06 6.24  +1.06 +0.85        gG8                 -0.153-0.023 +.005+006V                          
+4741          BD+09 2628 108471119413                       122236.8+090951122742.1+083637284.96 70.65 6.37  +0.93 +0.68         G8III              +0.018-0.010      -006                           
+4742          BD-15 3471 108477157299                       122237.8-160443122749.4-163755294.80 45.87 6.35  +0.84 +0.50         G3III              -0.018+0.003      -008                           
+4743   Sig CenCD-49 7115 108483223454 464                   122237.8-494036122802.4-501350299.10 12.47 3.91  -0.19 -0.78 -0.20   B2V                -0.030-0.015      +008V     245                 *
+4744          CP-63 2297 108501251920                       122242.0-634714122818.9-642029300.43-01.58 6.04  +0.02 -0.03         A0Vn               -0.068-0.027      +009                           
+4745 73    UMaBD+56 1598 108502 283943000I                  122249.7+561559122735.1+554246129.89 61.09 5.70  +1.55               M2IIIb             -0.021-0.012      +017V?                         
+4746          BD-03 3298 1085061387983001          FT Vir   122243.6-040343122751.6-043655291.87 57.75 6.22  +0.44 +0.08         A8n                -0.086+0.006      -012SB    139                 *
+4747          CP-61 3209 108530251924                       122251.1-611429122825.5-614743300.22  0.96 6.22  +1.26 +1.32         K2III              -0.034-0.014      -014                           
+4748          CD-38 7753 1085412035081320                   122303.3-382915122822.5-390229298.05 23.61 5.44  -0.08               B8V                -0.023-0.017      +005      174                  
+4749          CP-55 5084 108570239977      W                122306.4-555053122833.4-562428299.75  6.33 6.15  +0.92 +0.64         K0-1III            -0.240-0.220 +.021+008           5.8  49.0AC   3*
+4750          BD+27 2138 108642 82326                       122338.5+264649122838.1+261336221.68 84.83 6.54  +0.17 +0.12 +0.09   A2m                -0.020-0.014      +002SB1O=< 12                 *
+4751          BD+26 2353 108651 82328        8568BC         122344.8+262711122844.6+255357225.26 84.78 6.65  +0.22 +0.08 +0.08   Am(A2/A9V/F0)      -0.018-0.021      -002SBO =< 12  1.4 145.4AB   3*
+4752 17    ComBD+26 2354 108662 82330        8568A AI Com   122355.0+262759122854.7+255446225.22 84.82 5.29  -0.05 -0.12 -0.08   A1IVp              -0.025-0.020 +.021-003V      18  1.4 145.4AB   3*
+4753 18    ComBD+24 2464 108722 82333                       122426.9+243943122926.9+240632243.07 84.20 5.48  +0.43 +0.09         F5III              -0.031-0.001      +025SB1O   93                 *
+4754          CP-55 5097 108732239999                       122423.2-555820122953.9-563129299.95  6.22 5.80  +1.56 +1.82         M1III              -0.022+0.019      +042V                          
+4755          CD-41 7219 108759223471               5655    122436.4-411057122957.9-414410298.64 20.96 6.02  +1.52 +1.54         M2II-III           +0.008-0.025      +003                           
+4756 20    ComBD+21 2424 108765 82336 466                   122441.8+212700122943.2+205346263.27 82.04 5.69  +0.07 +0.09         A3V                +0.024-0.032      -005SB2                        
+4757  7Del CrvBD-15 3482 108767157323 465I   8572A  5656    122441.3-155731122951.9-163056295.48 46.05 2.95  -0.05 -0.09 -0.04   B9.5V              -0.210-0.138 +.024+009V     148  5.3  24.4      *
+4758          BD-12 3647 108799157326        8573           122455.4-125021123004.8-132335294.98 49.15 6.35  +0.56 +0.05         G0V                -0.248-0.041 +.049+000V?         2.7   1.5AB   4*
+4759          BD-22 3383 108821180850    I          5662    122503.3-230837123017.5-234148296.71 38.92 5.63  +1.67 +2.03         M0III              -0.020-0.003      -011V                          
+4760 74    UMaBD+59 1444 108844 28405 467                   122517.1+585721122957.3+582421128.32 58.50 5.35  +0.20 +0.14 +0.06   A5Del Del          -0.062+0.091 +.039+007V      87                  
+4761  7    CVnBD+52 1631 108845 28407      W                122519.1+520515123002.9+513208130.89 65.26 6.21  +0.51 +0.03         F6-8V              -0.289+0.024 +.035+019V?  =< 10  2.8 229.0AC   3 
+4762 75    UMaBD+59 1446 108861 28408                       122523.4+591915123004.3+584603128.18 58.14 6.08  +0.98               G8III-IV           +0.031-0.024      -017                           
+4763   Gam CruCP-56 5272 108903240019 468I W     A  5672    122537.0-563312123109.9-570648300.17  5.65 1.63  +1.59 +1.78 +1.41   M3.5III            +0.023-0.262      +021           5.1 110.6AB   3*
+4764   Gam CruCP-56 5274 108925240022      W     B          122543.9-563142123116.7-570452300.18  5.68 6.42  +0.16               A3V                +0.002 0.000      +002           5.1 110.6AB   3 
+4765  4    DraBD+70  700 108907 15816    I         CQ Dra   122543.8+694519123006.7+691204125.75 47.81 4.95  +1.62 +1.81 +1.05E  M3IIIa             -0.059-0.052 +.016-013SB                        *
+4766 21    ComBD+25 2517 108945 82346              UU Com   122600.9+250712123100.6+243402240.93 84.74 5.46  +0.05 +0.10 -0.03   A2p               v-0.012-0.009      +000V      63                 *
+4767          BD+53 1554 108954 28413                       122604.8+533726123050.1+530436129.94 63.77 6.21  +0.54 +0.07         F8-G0V             +0.015+0.181      -021V?  =<  6                  
+4768          CP-58 4344 108968240027              BG Cru   122605.0-585217123140.3-592526300.42  3.35 5.48  +0.63 +0.38         F7Ib-II           v-0.018-0.004 +.010-020SB                        *
+4769          CP-72 1261 108970256954                       122607.2-722654123210.0-730006301.50-10.18 5.88  +1.11 +1.05 +0.49C  K1III              +0.038-0.024      +005                           
+4770          BD+08 2609 1089851194533002I                  122616.5+080923123121.4+073615288.31 69.90 6.05  +1.52 +1.89         K5                 -0.018+0.010      -017                           
+4771          CP-62 2805 109000251946                       122615.8-625714123155.8-633022300.76-00.72 5.95  +0.27               A8III              -0.063+0.008      +004                           
+4772          BD-04 3296 109014138832                       122630.1-043004123138.7-050309293.74 57.47 6.19  +1.04 +0.86        gG9                 -0.038+0.031      +002V?                         
+4773   Gam MusCP-71 1336 109026256955 469                   122629.4-713450123228.0-720759301.46-09.32 3.87  -0.15 -0.62 -0.17   B5V                -0.058-0.002      +003V?    188                 *
+4774          CD-31 9746 109074203567                       122646.4-315852123204.5-323201298.21 30.16 6.46  +0.20 +0.18         A3V                -0.015-0.008      -009                           
+4775  8Eta CrvBD-15 3489 109085157345               5690    122654.9-153832123204.2-161146296.19 46.42 4.31  +0.38 +0.01 +0.18   F2III-IV           -0.426-0.061 +.052-004SB2    59                 *
+4776          BD-13 3552 109141157350                       122725.4-131820123236.0-135133295.99 48.76 5.74  +0.40 -0.02         F2V                -0.144-0.051      -001V                          
+4777 20    VirBD+11 2473 1092171001463004                   122759.1+105051123302.9+101744287.63 72.62 6.26  +0.95 +0.70 +0.34E  G8III              -0.051+0.005      +001                          *
+4778          BD-18 3416 109238157359               5715    122808.7-191424123322.4-194731297.13 42.88 6.26  +0.29               F2V                -0.013-0.002      +005       90                  
+4779          BD-12 3659 1092721573611321                   122823.0-121648123334.3-124949296.18 49.81 5.58  +0.86 +0.45         G8III              -0.016+0.052      -016V?                         
+4780 22    ComBD+25 2523 109307 82378                       122835.2+245006123334.2+241659247.20 85.07 6.29  +0.11 +0.10 +0.03   A4Vm               -0.018-0.004      +002V       8                 *
+4781 21    VirBD-08 3372 109309138845                       122837.0-085401123346.8-092707295.66 53.17 5.48  -0.03 -0.10         A0V                -0.080+0.007 +.019-011V     110                  
+4782          CD-49 7195 109312223516      W                122832.1-492124123359.2-495434300.05 12.87 6.38  +0.46               F3III-IV           -0.163-0.040      +018           6.5   7.8       
+4783          BD+34 2332 109317 630701322I                  122843.4+334800123338.9+331451153.97 82.78 5.42  +1.00 +0.83 +0.50   K0IIICN-1          +0.020-0.033 +.033-020V    < 19:                 
+4784          BD+34 2333 109345 63072                       122852.1+335612123347.4+332305153.19 82.68 6.24  +1.05 +0.90 +0.52   K0III              +0.002-0.008 +.056-043V                          
+4785  8Bet CVnBD+42 2321 109358 44230 470I S        5725    122859.6+415403123344.5+412127136.10 75.32 4.26  +0.59 +0.05 +0.31   G0V                -0.705+0.292 +.117+007SB1O=<  3                 *
+4786  9Bet CrvBD-22 3401 109379180915 471I          5729    122907.9-225037123423.2-232348297.87 39.31 2.65  +0.89 +0.60 +0.44   G5II               +0.002-0.054 +.034-008V    < 17                 *
+4787  5Kap DraBD+70  703 109387  7593 472I         Kap Dra  122912.9+702022123329.0+694718125.21 47.26 3.87  -0.13 -0.57 -0.08   B6IIIpe           v-0.059+0.012 +.013-011SBO   249                 *
+4788          CD-43 7755 109409223527      W                122917.5-440657123442.3-444024299.80 18.10 5.77  +0.70 +0.28         G1V                -0.083-0.215 +.021+018           4.0   1.0       
+4789 23    ComBD+23 2475 109485 823901323  W                122952.1+231048123451.1+223745262.15 84.14 4.81   0.00 -0.01 -0.02   A0IV               -0.065+0.021 +.004-016SB2    66  2.4   0.4       
+4790          CP-61 3298 109492251962    I                  122950.8-611717123529.0-615031301.05  0.97 6.22  +0.73 +0.30         G3III              -0.304-0.084      +006                           
+4791 24    ComBD+19 2584 109510100159        8600B  5745    123005.3+185540123506.3+182238278.83 80.48 6.56  +0.25 +0.11 +0.16   A9Vm               -0.003+0.024 +.002+005SB2O=< 25  1.5  20.2      *
+4792 24    ComBD+19 2584 109511100160 473I   8600A  5748    123006.8+185539123507.8+182237278.86 80.48 5.02  +1.15 +1.11         K2III              -0.006+0.023 +.002+004    =< 25  1.5  20.2      *
+4793          BD+22 2490 109519 82394    I                  123008.3+222559123508.1+215253266.81 83.58 5.85  +1.22               K1III              +0.014-0.019      -014V                          
+4794          CD-40 7376 1095362235423005          Var?     123022.5-402815123545.5-410119299.75 21.75 5.13  +0.22  0.00 +0.11   A7III              -0.107-0.001 +.024-011       94                 *
+4795  6    DraBD+70  705 109551  7600    I                  123030.2+703423123444.0+700119125.02 47.04 4.94  +1.31 +1.15         K3III*             -0.032 0.000      +005V                         *
+4796          CD-39 7717 109573203621      W                123038.1-391904123601.2-395212299.72 22.91 5.80  +0.01               A0V                -0.034-0.037      +006           6.1  40.0AC   3 
+4797          BD-19 3521 109585180937              TU Crv   123044.0-195830123558.6-203138298.04 42.20 6.20  +0.33 +0.08         F0III              +0.014-0.037      -002V      67                 *
+4798   Alp MusCP-68 1702 109668251974 474  W       Alp Mus  123113.0-683504123711.0-690808301.66-06.30 2.69  -0.20 -0.83 -0.24   B2IV-V             -0.048-0.013      +013V     147 10.1  29.6      *
+4799 25    VirBD-05 3535 1097041388731324                   123138.2-051651123647.4-054955296.26 56.85 5.87  +0.07 +0.09         A3V                -0.028-0.018      -006V                          
+4800          BD+60 1406 109729 28444    I         T UMa    123150.3+600216123623.3+592913126.49 57.54 5.5 H                     M4IIIe             -0.025-0.011      -091V                         *
+4801 25    ComBD+17 2504 1097421001763007I                  123157.4+173826123658.3+170522283.77 79.42 5.68  +1.41 +1.75         K5III              -0.037-0.016      -008                           
+4802   Tau CenCD-47 7745 109787223560                       123213.8-475926123742.2-483228300.59 14.27 3.86  +0.05 +0.03 +0.04   A2V                -0.184-0.005 +.024+005      281                  
+4803          CD-26 9233 109799180965        8612           123224.0-263510123742.2-270820299.17 35.63 5.45  +0.32 +0.03 +0.19   F1IV               +0.076-0.091 +.037-001        0  5.9   1.4      *
+4804          CP-74  955 109857256967      W                123249.3-744913123914.5-752210302.14-12.52 6.49  +0.08 -0.24 +0.08C  B8Vne              -0.032+0.031      -020           2.0   2.0      *
+4805          BD+04 2631 109860119503                       123258.5+034958123804.4+031657294.73 65.94 6.33  +0.01 +0.01         A1V                -0.029-0.009      -008V?     24                  
+4806          CP-66 1861 109867251980      W                123256.2-663834123852.5-671135301.71-04.35 6.25  +0.06 -0.85         B1Ia              t-0.006-0.002      -016       88  5.7  17.0      *
+4807          BD+02 2560 1098961195083009I         FW Vir   123316.3+022419123822.4+015117295.32 64.53 5.71  +1.60 +1.83 +1.42   M3+IIIbCa0.5       -0.080-0.018 +.029-016V?                        *
+4808          BD+07 2561 109914119509    I         R Vir    123325.4+073218123830.0+065918293.68 69.63 7.08  +1.44 +1.28 +1.74   M4.5IIIe           -0.026-0.004 +.014-026V                         *
+4809          BD-17 3668 1099311574153010                   123331.2-174203123844.6-181501298.71 44.52 6.00  +0.29              dA6                 -0.119+0.025      -013V                          
+4810          CD-29 9845 1099602036663011           5822    123344.1-295220123903.5-302520299.77 32.37 5.89  +1.21               K2-3III            -0.034-0.006      -013V                          
+4811  9    CVnBD+41 2312 109980 44265                       123357.6+412529123846.3+405228132.88 76.01 6.37  +0.18 +0.07         A7Vn               -0.026-0.016      -015      220                  
+4812          BD+23 2479 109996 82420      W                123404.1+231235123902.1+223934270.09 84.72 6.38  +1.10               K1III              -0.050-0.016      -027V          6.0  32.8       
+4813 26Chi VirBD-07 3452 110014138892 475I W                123405.0-072643123914.8-075944297.70 54.75 4.66  +1.23 +1.39 +0.61   K2III-IIIbCN1      -0.076-0.025 +.020-020     < 17  4.3 173.1AB   4*
+4814          CP-65 1941 110020251987              FH Mus   123400.4-655740123955.6-663042301.78-03.67 6.26  -0.05 -0.20         B8V                -0.059-0.021      -003V                         *
+4815 26    ComBD+21 2439 110024 824213012                   123408.8+213645123907.3+210345277.43 83.32 5.46  +0.96               G9III              -0.081-0.013      -021SBO                       *
+4816          BD+36 2295 110066 631183013          AX CVn   123425.0+363006123916.9+355707138.51 80.81 6.45  +0.06 +0.03         A0pSrCrEu          +0.022-0.006      -015V?     13                 *
+4817          CD-39 7748 110073203681               5835    123427.6-392613123952.5-395915300.53 22.83 4.64  -0.08 -0.42 -0.09   B8II/III           -0.047-0.030      +015SB1    57                 *
+4818          CD-45 7944 1102872236011325                   123553.2-453553124123.0-460844301.12 16.69 5.84  +1.52 +1.72         K4III              -0.069+0.057      +007                           
+4819   Gam CenCD-48 7597 110304223603      W                123559.9-482438124131.0-485735301.26 13.88 2.17  -0.01 -0.01  0.00   A1IV               -0.189-0.005 +.016-006SB     81  0.1   1.5AB   3*
+4820          CP-68 1731 110311251996              R Mus    123558.4-685131124205.1-692427302.10-06.55 6.33  +0.78 +0.54         F7Ib-G2           v-0.004-0.002      +004                          *
+4821          BD-12 3676 110317157447        8627B  5855    123604.3-122754124116.0-130049299.10 49.78 6.08H                     F3Vn               -0.113+0.019D+.014-014SBO        0.1   5.4AB   3*
+4822          BD-12 3676 110318157448        8627A  5855    123604.6-122758124116.2-130054299.10 49.78 5.98H +0.42 +0.10         F5V                -0.127+0.008D+.014-011SB2O       0.1   5.4AB   3*
+4823          CP-59 4393 110335240161               5858    123611.2-590813124156.6-594109301.73  3.16 4.93  -0.04 -0.39 -0.01   B6IVe              -0.025-0.002      +013SB    185:                *
+4824 27    VirBD+11 2484 110377100207      W       GG Vir   123632.0+105830124134.4+102535294.55 73.14 6.19  +0.19 +0.10         A7Vn               -0.109+0.004      +009SB    153  3.8  85.5      *
+4825 29Gam VirBD-00 2601 110379138917    I   8630A  5859    123635.5-005403124139.6-012658297.85 61.33 3.65H +0.36 -0.03 +0.19   F0V                -0.565+0.012 +.099-020SB     28  0.1   4.1AB   4*
+4826 29Gam VirBD-00 2601 110380138917    I   8630B  5859    123635.5-005403124139.6-012658297.85 61.33 3.68H                     F0V                -0.565+0.012 +.099-020V      30  0.1   4.1AB   4*
+4827          BD-18 3442 110385157451                       123635.2-191238124149.2-194531299.84 43.06 6.03  +0.39 +0.09         F3-5III            -0.212+0.027      -003       82                 *
+4828 30Rho VirBD+11 2485 1104111002111326          Rho Vir  123649.3+104712124153.1+101408294.88 72.96 4.88  +0.09 +0.03 +0.02   A0V                +0.084-0.091      +002SB    173                 *
+4829 31    VirBD+07 2568 110423119538        8633   5867    123653.0+072120124157.1+064824296.18 69.55 5.59   0.00 -0.02         A2V                -0.068-0.012 +.012+004V     136  5.8   4.0       
+4830          CP-62 2898 1104322520023015          BZ Cru   123658.1-623036124250.3-630331301.96-00.20 5.31  +0.27 -0.79 +0.21   B1IIIe            v-0.015 0.000      +035SB    275                 *
+4831          CD-48 7608 110458223614                       123703.1-481549124235.4-484847301.43 14.03 4.66  +1.09 +1.01 +0.57   K0III              -0.127-0.032 +.025-012                          *
+4832          CP-55 5194 110461240176                       123708.8-552353124249.6-555650301.72  6.90 6.08  -0.03 -0.19         B9V                -0.047-0.019      +015V?                         
+4833 76    UMaBD+63 1026 110462 15871 478                   123711.8+631543124133.9+624247124.87 54.38 6.07  +0.01 +0.07         A2III              -0.032-0.017      -004                           
+4834          CP-55 5197 110506240179                       123727.6-553739124309.1-561034301.77  6.68 6.00  -0.08 -0.30         B7-8V              -0.041-0.010      +010                           
+4835          CP-58 4453 110532240183      W                123743.2-582117124328.2-585411301.90  3.95 6.40  +1.09 +1.00         K0-1III            -0.085-0.011      +017           3.3  29.8AC   3 
+4836          CD-39 7785 110575203746                       123758.9-393746124326.3-401040301.28 22.67 6.44  +0.25 +0.04 +0.14   A8V:               +0.027-0.014      -005                          *
+4837          BD-00 2603 110646138933                       123829.8-010137124338.1-013437298.88 61.23 5.93  +0.86 +0.46 +0.49   G8IIIp             +0.050-0.076      +001                          *
+4838          CD-35 8155 1106532037563016                   123833.8-354804124358.7-362057301.25 26.50 6.39  -0.06               A0V                +0.013-0.007      -001                           
+4839          CD-27 8832 110666181063 479I                  123840.6-274630124400.5-281926300.95 34.52 5.48  +1.34 +1.50         K4III              -0.027-0.038      +007V                          
+4840          BD+61 1312 110678 15877              Var      123841.0+614210124304.2+610920124.73 55.94 6.38  +1.26 +1.39         K0                 -0.047+0.026      -006                          *
+4841          CP-68 1745 110716252012                       123852.9-681659124501.7-684952302.35-05.97 6.16  +0.69 +0.38         F6Ia               -0.032-0.015      -003V                          
+4842   Iot CruCP-60 4273 110829252016      W                123945.0-602556124537.9-605852302.23  1.88 4.69  +1.05 +0.94 +0.52   K0III              +0.098-0.063 +.036+007           4.8  27.5      *
+4843          BD+44 2221 110834 44307                       123943.9+443901124427.1+440611127.22 72.97 6.33  +0.43               F6IV               -0.027+0.005      -016      127                  
+4844   Bet MusCP-67 2064 110879252019      W                124008.7-673338124616.9-680629302.45-05.24 3.05  -0.18 -0.74 -0.21   B2.5V              -0.039-0.017D+.015+042V     184  0.2   1.3      *
+4845 10    CVnBD+40 2570 110897 63177                       124015.5+394920124459.5+391644128.81 77.78 5.95  +0.55 -0.03 +0.29   G0V                -0.355+0.139 +.063+081V?      1                  
+4846          BD+46 1817 110914 443171327I         Y CVn    124025.9+455913124507.8+452625126.45 71.65 4.99  +2.54 +6.33 +1.39   C7I                -0.001+0.015 +.002+012                          *
+4847 32    VirBD+08 2639 1109511195741328          FM Vir   124033.9+081313124537.1+074024298.61 70.50 5.22  +0.33 +0.15 +0.16   F0IIIm             -0.107+0.004 +.014-009SBO    66                 *
+4848          CP-55 5215 1109562402353018  W                124038.0-555629124622.7-562920302.23  6.38 4.65  -0.16 -0.64 -0.18   B3V               v-0.036-0.013      +017V?     66  4.3  52.6      *
+4849 33    VirBD+10 2468 111028119580      W                124117.6+100556124622.5+093224298.79 72.38 5.67  +0.99 +0.76         K1III-IV           +0.277-0.446 +.021+052V          3.1 171.5       
+4850          CD-32 8912 111032203797      W                124122.1-324605124646.0-331856301.81 29.55 5.86  +1.34 +1.60         K3III              -0.007-0.030      +031           6.0  65.        
+4851 27    ComBD+17 2533 111067100252    I                  124139.0+170726124638.7+163439296.68 79.39 5.12  +1.35 +1.54 +0.68   K3III              +0.009+0.007      +053V    < 17                  
+4852          BD+81  402 111112  20803017                   124153.5+811009124426.0+803716123.29 36.50 6.40  +0.12 +0.13         A5m                +0.030-0.042      -028SB     30                 *
+4853   Bet CruCP-59 4451 111123240259 481  W       Bet Cru  124152.5-590831124743.2-594119302.46  3.18 1.25  -0.23 -1.00 -0.26   B0.5III            -0.048-0.014      +016SB     38  6.0 371.6AC   3*
+4854          BD+06 2660 111133119585              EP Vir   124157.5+062954124702.3+055703299.90 68.80 6.34  -0.05 -0.06         A0pSrEuCr         v+0.035-0.043      +016V      10                 *
+4855 34    VirBD+12 2512 111164100260      W                124211.6+123017124713.6+115729299.00 74.80 6.07  +0.12 +0.13         A3V                +0.042-0.018      -002V?    120  3.2 139.4      *
+4856          BD-05 3569 111199138967      W                124223.2-054516124733.4-061807301.18 56.56 6.26  +0.55 +0.07         F7V                +0.001-0.044      +013V?     12  6.1  16.3       
+4857          CD-2410540 1112261811051329                   124234.6-241824124753.7-245106301.91 38.01 6.44  -0.06 -0.45         B8III              -0.041+0.040      +049V                          
+4858 35    VirBD+04 2653 1112391195961330I          5947    124245.8+040708124751.4+033422300.70 66.43 6.41  +1.60 +1.83 +0.96E  M3IIIb             -0.006-0.003      +008V?                        *
+4859          BD+63 1034 111270 15901                       124302.8+631937124718.9+624651123.74 54.34 5.89R                     A9V                +0.016-0.001      -011SB    106                  
+4860          CD-26 9340 111295181114                       124306.3-270259124826.4-273551302.12 35.27 5.66  +0.95 +0.61         G5III-IV           -0.139-0.063      -010V?                         
+4861 28    ComBD+14 2546 111308100269                       124313.8+140559124814.3+133311299.63 76.40 6.56  +0.01 +0.01         A1V                -0.047-0.028      -000      130                  
+4862          CP-71 1391 111315256983                       124315.9-712626124944.9-715911302.80-09.11 5.55  +1.17 +0.95         G8Ib-II            +0.001-0.005      -007V                         *
+4863  7    DraBD+67  764 111335 159023020I                  124329.2+672011124734.4+664725123.53 50.33 5.43  +1.56              gK5                 +0.010-0.005 +.023+008                           
+4864          BD+25 2568 111395 825113021                   124354.7+252319124847.0+245025288.28 87.64 6.31  +0.70 +0.25         G7V                -0.339-0.108 +.043-008V                          
+4865 29    ComBD+14 2549 1113971002833022                   124353.5+144007124854.2+140721300.20 76.98 5.70  +0.02 +0.07 -0.01   A1V                +0.026-0.019      -008V?    145                 *
+4866 11    CVnBD+49 2163 111421 44332                       124405.7+490043124841.8+482801124.18 68.66 6.27  +0.18 +0.17         A6m                -0.065+0.016      -002V?     37                  
+4867          BD+61 1320 111456 15907                       124418.3+605155124839.4+601912123.56 56.81 5.85  +0.46 -0.04 +0.28   F5V                +0.105+0.001 +.041-012V      36                 *
+4868          CP-59 4483 111463252047                       124417.0-595119125012.0-602403302.78  2.47 6.75  +0.35 +0.21         A3II               -0.007-0.017      -009V                          
+4869 30    ComBD+28 2153 111469 82515        8674           124425.1+280549124917.4+273308171.10 89.36 5.78  +0.03 +0.06         A2V                -0.096+0.021      +000SB2        7.0  42.5      *
+4870   Iot OctCP-84  407 111482258654 919  W                124427.3-843449125458.6-850724303.01-22.25 5.46  +1.02 +0.79         K0III              +0.062+0.028      +053           0.5   0.6      *
+4871          CD-47 7893 111519223698                       124441.8-475453125019.6-482735302.74 14.41 6.24  +0.05               A0V                -0.037+0.002      -017                           
+4872          CP-52 5947 1115882403143023                   124514.5-521433125057.9-524715302.86 10.08 5.73  +0.13               A5V                -0.026-0.012      -007                           
+4873          BD+23 2502 111591 82523                       124521.0+232436125017.4+225148299.36 85.73 6.43  +1.00 +0.80         K0III              +0.109-0.069      +006                          *
+4874          CD-33 8653 1115972038631331  W                124515.5-332715125041.2-335958302.75 28.87 4.91  -0.04 -0.11         A0IV               -0.028-0.020 +.020+004V     178:10.0  27.6      *
+4875          BD+38 2373 111604 63217               5983    124525.5+380340125010.7+373101124.31 79.61 5.89  +0.15 +0.08         A3V                -0.097+0.027 -.000-014V     183                 *
+4876          CP-59 4494 111613252054               5991    124522.1-594707125117.8-601947302.91  2.54 5.72  +0.38 -0.10         A2Iabe             -0.025+0.007      -021       18                 *
+4877          BD-09 3569 111720157550        8684A  5994    124610.6-094738125122.9-102018302.91 52.53 6.41  +1.02 +0.79         G8III              -0.008-0.006      -017V          3.3  30.2AB   3*
+4878 37    VirBD+03 2703 111765119633                       124631.4+033601125136.9+030324303.04 65.93 6.02  +1.29 +1.44        gK4                 -0.035+0.020      +003                           
+4879          CD-39 7879 111774203881               5999    124626.4-390809125156.8-394051303.04 23.19 5.98  -0.10               B8V                -0.035-0.028      +005                           
+4880          CD-47 7917 111775223720                       124627.0-473301125205.3-480539303.05 14.78 6.33  +0.03 +0.02         A0IV               -0.060+0.013      -002    =< 49                  
+4881          CD-26 9369 111786181169                       124637.1-261143125157.9-264417303.08 36.13 6.15  +0.23               A0III              -0.111+0.040      -018                          *
+4882          CP-53 5359 111790240338      W                124638.6-531709125224.6-534946303.08  9.04 6.24  +1.13               G8Ib-II            -0.020+0.012      -023           6.0   6.4       
+4883 31    ComBD+28 2156 111812 825371332I'        Var?     124649.7+280506125141.9+273226114.93 89.58 4.94  +0.67 +0.20 +0.35   G0III              -0.012-0.008 +.011-001V?     77                 *
+4884 32    ComBD+17 2551 1118621003091333I W                124713.8+173704125212.3+170426303.98 79.94 6.32  +1.59 +1.99         M0III              +0.001-0.007      -001V?         0.6 196.5AB   3 
+4885          CP-54 5360 111884240347                       124716.9-542433125303.9-545709303.17  7.92 5.93  +1.31 +1.40 +0.50E  K2III              -0.119+0.011      -009                          *
+4886          BD+16 2430 111893100312                       124729.0+164000125227.6+160721304.22 78.99 6.30  +0.16 +0.10         A7V                -0.043-0.019      -027      214                  
+4887          CP-59 4529 111904252069               6008    124724.0-594706125321.8-601943303.17  2.54 5.76  +0.33 -0.42         B9Ia               -0.013 0.000      -019V?     81                 *
+4888          CD-48 7753 1119152237313024                   124727.2-482357125306.9-485636303.22 13.93 4.33  +1.37 +1.58 +0.75   K3-4III            -0.076-0.030 +.020-002SB                         
+4889          CD-39 7893 111968203907 482                   124753.7-393806125326.2-401044303.34 22.69 4.27  +0.21 +0.12 +0.14   A7III              +0.063-0.022 +.056-003       81                  
+4890   Kap CruCP-59 4555 111973252077                       124750.5-594959125349.1-602237303.23  2.49 5.90  +0.20 -0.65         B5Ia              t+0.004-0.021      -004V?      0                 *
+4891 38    VirBD-02 3593 1119981390223025  D                124803.8-030035125311.2-033311303.79 59.32 6.11  +0.50 +0.04         F5V                -0.262-0.003 +.042-007V                         *
+4892          BD+84  289 112014  2101        8682B          124815.6+835742124906.6+832505123.01 33.71 5.85  -0.06 -0.12         A0V+A2V            -0.026+0.022 +.001+001SB2O   17  0.5  21.6AB   3*
+4893          BD+84  290 112028  2102        8682A          124823.1+835724124913.6+832446123.01 33.72 5.28  -0.03 -0.06         A1IIIShell         -0.029+0.020 +.001+002V     275  0.5  21.6AB   3*
+4894 35    ComBD+22 2519 112033 82550    I   8695           124822.3+214719125317.8+211442307.21 84.10 4.90  +0.90 +0.64 +0.45   G8III+F6V          -0.047-0.022 +.021-007SBO  < 17  2.1   1.0AB   4*
+4895          CP-57 5776 112044240362              S Cru    124826.9-575315125422.0-582550303.32  4.44 6.58  +0.76 +0.60         F7Ib-II           v-0.014-0.001      -007                          *
+4896          BD-03 3373 112048139027                       124828.6-034047125338.1-041326303.98 58.64 6.44  +1.10 +1.02         K0                 +0.001-0.041      +037V                          
+4897   Lam CruCP-58 4584 112078240368              Lam Cru  124842.7-583612125439.2-590848303.35  3.72 4.62  -0.15 -0.61 -0.16   B4Vne              -0.036-0.010      +012      317                 *
+4898   Mu 1CruCP-56 5487 112092240366      W     A          124842.8-563805125435.6-571040303.36  5.69 4.03  -0.17 -0.76 -0.24   B2IV-V             -0.033-0.006      +014       48  1.0  34.9      *
+4899   Mu 2CruCP-56 5487 112091240367      W     B Mu2 Cru  124844.0-563731125436.8-571006303.37  5.70 5.17  -0.12 -0.51 -0.06   B5Vne              -0.035-0.001      +019V     201  1.0  34.9      *
+4900 41    VirBD+13 2602 112097100322                       124848.6+125744125349.7+122507305.23 75.28 6.25  +0.27 +0.05 +0.15   A7III              +0.051-0.024      -010SB     67                 *
+4901          BD-10 3570 112131157584      D        6019    124906.2-110622125418.7-113855304.06 51.22 6.00  +0.08               A2V                -0.141+0.013      -024           0.1   0.1      *
+4902 40Psi VirBD-08 3449 1121421390331335I D       Psi Vir  124909.1-085945125421.2-093220304.14 53.33 4.79  +1.60 +1.53 +1.28   M3-IIICa-1        e-0.024-0.015 +.021+018V?         3.3   0.0      *
+4903          CD-43 7953 112164223753                       124924.2-433612125458.5-440907303.61 18.72 5.89  +0.64 +0.25         G1V                -0.223-0.225 +.044+032                           
+4904          BD+34 2369 112171 632443027                   124926.5+340434125413.1+333204117.74 83.57 6.26  +0.20 +0.09         A7IV               -0.090+0.032      +005      127                  
+4905 77Eps UMaBD+56 1627 112185 28553 483I         Eps UMa  124937.8+563009125401.7+555735122.18 61.16 1.77  -0.02 +0.02 -0.03   A0pCr              +0.112-0.006 +.009-009SB?    38                 *
+4906          CD-42 7975 1122132237603029                   124944.4-422223125519.4-425457303.69 19.95 5.47  +1.68 +2.05         M0III              -0.038-0.012      -007                           
+4907          CP-71 1404 112219256992                       124950.5-713834125631.5-721107303.33-09.32 5.93  +1.13 +0.90         G8III              -0.027-0.011      +010                           
+4908          CP-56 5498 112244240385      W        6024    125003.5-561737125557.0-565010303.55  6.03 5.32  +0.01 -0.84         O9Ib               -0.024-0.010      +018V     145  5.0  29.1      *
+4909          BD+47 2003 112264 443833030I         TU CVn   125022.5+474421125456.5+471148121.20 69.92 5.84  +1.55 +1.57         M5III              -0.016-0.006      -017                          *
+4910 43Del VirBD+04 2669 112300119674 484I W        6026    125033.9+035627125536.2+032351305.53 66.25 3.38  +1.58 +1.78 +1.33   M3+III            e-0.469-0.054 +.022-018V?         7.0 164.5      *
+4911          BD-14 3605 1123041575993033                   125037.7-144707125553.3-151937304.52 47.53 6.17   0.00               A0Vn               -0.017+0.003      -003      148                  
+4912          CD-25 9508 112374181244              LN Hya   125107.3-255505125630.1-262737304.34 36.40 6.62  +0.68               F3Ia               +0.013-0.015      -024V                         *
+4913          CD-50 7394 112409240407                       125118.7-503925125704.4-511155303.83 11.66 5.16  -0.06 -0.32         B8-9V              -0.026-0.015      +025      255                  
+4914 12Alp1CVnBD+39 2580 112412 63256        8706B          125119.7+385117125600.4+381853118.31 78.77 5.60  +0.34 -0.03 +0.23   F0V                -0.236+0.062 +.027-003V       8  2.7  19.4      *
+4915 12Alp2CVnBD+39 2580 112413 63257 485I   8706A Alp2 CVn 125121.0+385130125601.7+381906118.29 78.77 2.90  -0.12 -0.32 -0.06   A0pSiEuHg          -0.234+0.056 +.027-003V      29  2.7  19.4      *
+4916  8    DraBD+66  778 112429 15941 486                   125129.7+655851125528.5+652619122.26 51.68 5.24  +0.28 +0.02         F0V                -0.005-0.029 +.032+009      132                 *
+4917          BD+54 1556 112486 28572        8710           125154.7+543827125617.6+540558121.36 63.01 5.82  +0.19 +0.08 +0.08   A5m                -0.077+0.001D+.012-005SB2O   20  1.8   3.5AB   3*
+4918          BD-21 3635 112519181265                       125213.0-221244125733.2-224514304.78 40.10 6.31  +1.07               G5                 -0.052-0.029      +003V                          
+4919          BD+46 1833 112570 44398                       125233.8+464309125707.7+461037119.92 70.92 6.12  +1.01 +0.80         K0III-IV           -0.022-0.047      +007V                          
+4920 36    ComBD+18 2682 1127691003573036I          6046    125358.7+175654125855.4+172434313.41 80.13 4.78  +1.56 +1.96 +0.95   M1-IIIb            -0.039+0.034      -002                           
+4921 44    VirBD-03 3384 1128461390861336    8727           125430.3-031621125939.5-034843306.92 59.00 5.79  +0.18 +0.08         A3V                -0.037+0.008      -018           4.9  20.9     3*
+4922          CD-32 9083 1129352040293038                   125504.0-325750130032.6-333019305.11 29.33 6.02  +0.38               F0V                -0.078-0.079      -023V?                         
+4923   Del MusCP-70 1548 112985257000 487                   125523.3-710034130216.2-713256303.80-08.69 3.62  +1.18 +1.26 +0.59   K2III              +0.256-0.021 +.030+037SBO                       *
+4924 37    ComBD+31 2434 112989 632883039I   8731  Var?     125529.3+311928130016.5+304706 95.60 85.86 4.90  +1.17 +1.05 +0.58   G9IIICH-2Fe1Ca1    -0.018-0.013 +.016-013V?   < 19: 7.8   5.5      *
+4925 46    VirBD-02 3609 112992139096        8732   6053    125526.9-024951130035.9-032207307.43 59.42 5.99  +1.12 +1.10         K2III              -0.025+0.050      +023V?         3.9   1.1AB   3*
+4926          BD+19 2622 113022100366        8735           125544.3+185437130038.8+182223317.04 80.99 6.20  +0.42 +0.02         F6V s              -0.226+0.060 +.020+001V?     20  2.8 149.2AxBC 3*
+4927          BD+76  473 113049  77143037                   125549.8+760042125847.3+752821122.32 41.65 6.01  +0.99 +0.75         K0III              +0.008+0.010      -015                           
+4928  9    DraBD+67  773 113092 15960    I                  125608.4+670812125955.1+663550121.60 50.51 5.32  +1.29 +1.29         K2III              -0.139-0.013 +.005-030V?   < 17                  
+4929 38    ComBD+17 2573 113095100374                       125612.9+173945130109.6+170723316.09 79.75 5.96  +0.96               K0III              -0.005-0.025      -006                           
+4930          CP-70 1553 113120257003               6063    125617.1-705615130305.2-712834303.87-08.63 6.03  +0.05 -0.87         B1.5IIIne         v-0.023-0.014      -005V     300                 *
+4931 78    UMaBD+57 1408 113139 28601        8739   6058    125626.4+565419130043.8+562159120.30 60.71 4.93  +0.36 +0.01 +0.21   F2V                +0.114-0.009 +.034-010V?     92  2.5   1.3      *
+4932 47Eps VirBD+11 2529 113226100384 488I W        6064    125711.9+112948130210.6+105733312.34 73.63 2.83  +0.94 +0.73 +0.45   G8IIIab            -0.273+0.020 +.043-014V?   < 17  8.9 248.7      *
+4933   Xi 1CenCD-48 7887 113314223870                       125745.8-485922130333.2-493138304.95 13.30 4.85  +0.02 +0.03         A0V                -0.059-0.014 +.012+000V     185                 *
+4934          BD+64  927 113337 15962      W                125752.5+640851130146.8+633637121.00 53.48 6.00  +0.41 +0.02         F6V                -0.180+0.029 +.033-011V?  =<  6  9.4 119.        
+4935          BD-19 3629 113415181357        8757           125824.6-200247130346.1-203459306.83 42.20 5.58  +0.56 +0.07         F7V                +0.142+0.018D+.003+034V?         0.1   0.4      *
+4936          BD+60 1439 113436 286133041                   125833.9+601514130240.4+594258120.31 57.35 6.53  +0.05 +0.06 +0.03   A3Vn               -0.029-0.016      -023SB?   200                  
+4937 48    VirBD-02 3622 113459139131        8759           125845.2-030731130354.4-033948308.99 59.06 6.59  +0.29 +0.11         F0V                -0.035-0.036D+.005+003V     109  0.3   0.6       
+4938          CD-40 7662 113523223881              V789 Cen 125910.0-403933130448.1-411148305.64 21.61 6.26  +1.68 +1.83         M3-4III            -0.028-0.034      -033                          *
+4939          CD-51 7248 113602240535               6084    125938.0-513446130530.8-520654305.13 10.70 6.43  +1.70 +1.99         M1III              -0.048+0.032      -031V?                        *
+4940          CD-47 8088 113703223900      W                130028.8-475538130616.7-482749305.47 14.34 4.71  -0.14 -0.58 -0.14   B5V                -0.030-0.023      +006      189  6.5  11.4      *
+4941          CD-40 7682 1137782239053044           6092    130055.0-410309130635.1-413519305.97 21.19 5.59  +1.05               K0II-III           +0.046-0.017      +002                           
+4942   Xi 2CenCD-49 7644 113791223909 489  W                130104.2-492214130654.6-495422305.49 12.89 4.27  -0.19 -0.79 -0.20   B1.5V              -0.026-0.012      +014SB1O   51  5.1  25.1      *
+4943 14    CVnBD+36 2337 113797 633381337           6089    130103.9+362002130544.5+354756104.46 80.81 5.25  -0.08 -0.20         B9V                -0.030+0.021 +.011-013V     175                 *
+4944          CP-59 4740 113823240566      W                130114.0-591930130724.2-595138304.94  2.95 5.99  +0.48 +0.12         F8-G2+B9IV         -0.027-0.012      +004           0.2   0.9       
+4945          BD+46 1847 113847 444651338I   8775           130122.3+454812130552.3+451607114.85 71.63 5.63  +1.13               K1III              -0.012+0.028D+.012-020V          5.4   2.9       
+4946 39    ComBD+21 2487 113848 826501339  W                130128.8+214124130621.2+210912333.39 83.13 5.99  +0.39  0.00         F4V                -0.069-0.046 +.030+001       30  3.0   1.2      *
+4947          CD-35 8441 113852204132                       130120.1-351928130654.3-355143306.44 26.91 6.54  -0.02 -0.02         A0IV-III           +0.041-0.078      +016    =< 49                  
+4948          BD+29 2365 113865 82648        8777           130123.9+293354130610.2+290146 64.11 86.23 6.54  +0.05 +0.09         A3IV               -0.069+0.001      +005V          6.4   6.3AxBC 4*
+4949 40    ComBD+23 2538 113866 82651    I         FS Com   130130.5+230910130622.6+223658340.64 84.36 5.60  +1.59 +1.63 +1.81   M5III              +0.025-0.049 +.045-005V?                        *
+4950          BD+73  583 113889  7741        8772           130144.2+733337130449.7+730131121.57 44.07 6.31R                     F0V                -0.019+0.020D+.007-016       90  2.0   1.3AB   3 
+4951          CP-52 6194 1139022405731340                   130141.6-525527130738.3-532735305.37  9.34 5.71  -0.07 -0.27         B8V                -0.039-0.024      +022                           
+4952   The MusCP-64 2183 113904252162      W       The Mus  130139.6-644617130807.0-651823304.67-02.49 5.51  -0.02 -0.87         B0Ia+WC5:         v-0.016-0.009      -028SBO   106: 1.7   5.3      *
+4953          BD+62 1275 113994 15985                       130225.9+623441130622.7+620231119.88 55.00 6.14  +0.99 +0.65         G7III              +0.005-0.037      +015V                          
+4954 41    ComBD+28 2185 113996 826593045I                  130222.8+280941130710.7+273729 41.94 86.47 4.80  +1.48 +1.85 +0.81   K5III              +0.031-0.070 +.008-016V?   < 17                  
+4955 49    VirBD-09 3628 114038157739    I                  130239.4-101221130753.8-104425309.50 51.92 5.19  +1.14 +1.12 +0.58   K2III              +0.017-0.006 +.025-009     < 19:                *
+4956          BD+28 2187 114092 82665                       130306.4+280531130753.6+273321 40.56 86.32 6.19  +1.36 +1.64 +0.48E  K4III              -0.041-0.064      -009                           
+4957          BD-08 3491 1141131391753046I D                130319.5-082655130832.5-085904310.07 53.65 5.55  +1.18 +1.18         K3III              -0.032-0.062      +016V?         0.0   0.1       
+4958 45Psi HyaBD-22 3515 1141491814103048I                  130340.0-223500130903.3-230705308.19 39.57 4.95  +1.05 +0.93         K1III              -0.024-0.036 +.012-019V                          
+4959          BD-08 3495 114203139183                       130400.9-090016130914.4-093218310.25 53.08 6.32  +1.02 +0.79         K0                 -0.033-0.009      +000V?                         
+4960          BD+10 2516 114256100436                       130411.9+103321130912.4+100120317.53 72.39 5.78  +1.00               K0III              +0.017-0.003      -000                           
+4961 50    VirBD-09 3636 114287157760    I          6114    130431.1-094745130945.3-101946310.31 52.28 5.94  +1.49 +1.69         K5III              -0.008-0.012      -007V?                         
+4962          BD+17 2595 1143261004393049I                  130452.8+172255130947.8+165055326.33 78.88 5.91  +1.45 +1.65         K5III              -0.069-0.012      -017                           
+4963 51The VirBD-04 3430 114330139189 490    8801           130446.2-050018130957.0-053220311.42 57.03 4.38  -0.01 -0.01  0.00   A1IV s+Am          -0.032-0.033 +.026-003SB     15  1.0   0.5     4*
+4964          BD+38 2407 114357 63372                       130502.0+375721130938.7+372523103.61 79.01 6.02  +1.15               K3III              -0.103+0.005      -019                           
+4965          CD-51 7329 114365240627              V824 Cen 130500.9-520202131058.4-523401305.95 10.19 6.06  -0.09 -0.38         ApSi               -0.041-0.017      +026V      76                 *
+4966          CP-69 1772 114371252185      W                130457.3-692435131151.6-695631304.69-07.14 5.91  +0.42 -0.03         F3IV-V             +0.036+0.006      +007SB2        5.9  30.7      *
+4967 15    CVnBD+39 2611 114376 63374        8805BC         130505.9+390400130942.0+383202105.55 77.97 6.28  -0.12 -0.48         B7III              -0.016+0.003      -006V     125  0.3 284.4AC   3*
+4968 42Alp ComBD+18 2697 114378100443        8804A  6116    130507.4+180330130959.3+173146327.96 79.49 5.22H +0.45 -0.06         F5V                -0.431+0.136 +.054-018V?     28  0.1   0.2AB   3*
+4969 42Alp ComBD+18 2697 114379100443        8804B  6116    130507.4+180330130959.3+173146327.96 79.49 5.22H                     F5V                -0.430+0.136 +.054-018V?         0.1   0.2AB   3*
+4970          CD-41 7648 114435223960                       130526.9-414200131108.8-421359306.83 20.49 5.79  +0.52               F7IV               -0.080-0.024      -011                           
+4971 17    CVnBD+39 2614 114447 63380 491    8805A          130527.7+390149131003.2+382956105.17 77.98 5.91  +0.29               A9III-IV           -0.070+0.044      +000SB2?   77: 0.3 284.4AC   3*
+4972          CP-62 3046 114461252187                       130528.2-624615131153.1-631810305.23-00.52 6.33  +0.44 +0.35         A8II-III           -0.006+0.003      -003V                          
+4973          CD-42 8175 114474223966                       130540.0-425009131123.2-432208306.77 19.35 5.25  +1.05 +0.92 +0.36E  K1-2III            -0.117-0.027 +.011-009                          *
+4974          BD+63 1056 114504 159993050  W                130558.2+624543130950.2+621345119.22 54.77 6.54  -0.02 -0.02         A1V                -0.030-0.008      -017       68  3.2 107.8       
+4975          CP-59 4815 114529240645      W       V831 Cen 130602.8-592318131217.4-595515305.55  2.85 4.60  -0.08 -0.38 -0.09   B8V                -0.049-0.024D+.014+012SB    216: 0.4   0.1AB   4*
+4976          CP-77  890 1145332570193054                   130557.9-775459131417.2-782650304.12-15.63 5.85  +1.07 +0.72         F8Ib               -0.018+0.004      -018                           
+4977          CP-65 2201 114570252196                       130611.6-654144131248.9-661337305.09-03.44 5.90  +0.06 +0.04         A0Vm:              +0.024+0.006      +009                           
+4978          CD-25 9653 1145761814461341  W                130612.8-260112131139.2-263306308.53 36.10 6.50  +0.19               A5Vn               -0.068+0.004      -021      177  0.1   0.2      *
+4979          CD-37 8437 1146132042273051                   130628.4-371622131203.2-374811307.43 24.89 4.85  +0.70 +0.31 +0.36   G3V                -0.385+0.047 +.053-015V?                         
+4980          CP-59 4827 114630240653      W                130640.2-591657131256.0-594900305.63  2.94 6.16  +0.60 +0.08         G0V                +0.014-0.107      +016SB2        3.2  25.3      *
+4981 53    VirBD-15 3613 114642157788      W        6136    130644.1-153933131203.5-161155310.12 46.39 5.04  +0.46 +0.02         F5III-IV           +0.098-0.286 +.040-014       15  5.0 235.0AD   4*
+4982          CD-42 8196 114707223980                       130706.9-421007131250.9-424159307.12 20.00 6.22  +1.06               K0III              -0.020+0.003      -001                           
+4983 43Bet ComBD+28 2193 114710 82706 492I W                130712.4+282306131152.4+275241 43.33 85.40 4.26  +0.57 +0.07 +0.30   F9.5V              -0.801+0.882 +.120+006SB?     6  5.8  90.8      *
+4984          BD+25 2610 114724 827083052                   130719.4+244725131208.4+241529  2.47 84.52 6.33  +0.98               K1III              -0.008-0.041      -024                           
+4985          CD-50 7589 114772240655      W                130727.3-501007131323.5-504200306.48 12.02 5.89  -0.02               B9V                -0.019-0.027      -001           0.3   0.3       
+4986          BD+12 2565 1147801004603053I                  130734.3+120517131232.9+113322321.61 73.66 5.77  +1.51               M0III              -0.050-0.033      +025                           
+4987          BD+19 2648 114793100461                       130742.9+191657131235.9+184506334.19 80.31 6.53  +0.88               G8III              -0.065-0.003      -020                           
+4988          CP-58 4738 1148352406633055                   130759.0-580912131412.1-584102305.89  4.06 5.89  +1.08               K0-1III            -0.051-0.012      -002                           
+4989          CP-58 4740 114837240666      W                130803.3-583407131414.8-590612305.87  3.64 4.92  +0.48       +0.27   F7IV               -0.265-0.157 +.053-065        0  5.3   2.7       
+4990 54    VirBD-18 3562 114846157798        8824A          130805.9-181744131326.8-184936310.15 43.74 6.28  +0.09 +0.01         B9III              -0.020-0.017D+.011-041SB         0.4   5.4      *
+4991          CD-42 8213 114873223989                       130813.8-423634131357.5-430820307.29 19.54 6.16  +1.38 +1.62         K4III              -0.170+0.028      +030                           
+4992          BD+19 2649 114889100467                       130820.5+191532131312.4+184337334.87 80.22 6.11  +1.20               G8III              -0.215-0.049      -024                          *
+4993   Eta MusCP-67 2224 114911252224 493  W       Eta Mus  130828.0-672152131514.9-675340305.18-05.13 4.80  -0.08 -0.35 -0.08   B8V                -0.041-0.008      -008SBO   268  3.2  60.       *
+4994          CP-69 1784 114912252225                       130830.3-690855131525.7-694047305.03-06.90 6.37  +1.21 +1.33         K2-3III            -0.101-0.048      -011                           
+4995 55    VirBD-19 3651 114946157806                       130849.7-192420131410.9-195551310.21 42.62 5.33  +0.87 +0.44         G6V                -0.122+0.167 +.010-045V?                         
+4996          CD-48 8050 114971224000                       130850.2-482529131443.1-485724306.86 13.74 5.89  +1.06 +0.93         K1III              -0.129-0.081      +056                          *
+4997          BD+40 2633 115004 44519    I                  130910.9+404057131343.0+400910104.83 76.18 4.92  +1.06 +0.93 +0.49   G8IIIaCN0.5        -0.048+0.015 +.004-021V?   < 19:                 
+4998          BD+12 2572 115046100473    I   8832           130931.9+115146131431.3+111954322.99 73.30 5.67  +1.50 +1.86 +0.90   M0III              +0.074-0.052      +012V          6.7  49.1      *
+4999          CD-35 8547 115050204282                       130932.2-355029131509.7-362216308.26 26.26 6.19  +0.97               K1III              -0.012-0.015      -004                           
+5000          CP-64 2316 115149252236                       131009.3-643629131644.8-650818305.59-02.40 6.07  +0.44 -0.02         F5V                -0.103-0.052      +018V                          
+5001 57    VirBD-19 3653 115202157823    I                  131034.2-192441131558.8-195635310.77 42.56 5.22  +1.03 +0.87         K1III-IV           +0.306-0.116 +.048+034V                         *
+5002          CP-66 2142 115211252240               6164    131028.5-661518131713.0-664701305.47-04.04 4.87  +1.50 +1.58 +0.75   K2Ib-II            -0.020-0.014 +.007-010                          *
+5003          BD+73  587 115227  77823057                   131040.0+731944131332.0+724756120.66 44.23 6.59  +0.08 +0.07         A2V                +0.017-0.016      +002SB                         
+5004 19    CVnBD+41 2374 115271 44531                       131102.2+412300131532.0+405119104.57 75.40 5.79  +0.19 +0.12         A7V                -0.108+0.015      -018       97                  
+5005          BD-00 2674 1153081392543058          DK Vir   131117.5-005142131625.5-012326315.84 60.85 6.68  +0.31 +0.08         F1IV               -0.035-0.028      -012       51                 *
+5006          CD-3010457 1153102043121342I                  131119.7-305837131653.1-313022309.26 31.05 5.10  +0.96 +0.61:        K1III              +0.034-0.048 +.016+013V?                         
+5007          BD+19 2655 115319100484                       131122.4+193447131614.3+190306339.43 80.12 6.45  +0.98 +0.75         G8III              -0.102+0.002      -045                           
+5008          CD-43 8165 1153312240321343                   131125.8-432705131713.9-435846307.82 18.65 5.84  +0.20 +0.15 +0.09   Am                  0.000-0.008      -012V                         *
+5009          BD+81  416 115337  21643056  W        6153    131131.4+810002131225.4+802817121.85 36.61 6.25  +0.94               K0Ib               -0.009+0.012      -011V?         4.0   1.1      *
+5010          BD+20 2814 115365 827513059  W                131141.1+201845131632.3+194707342.33 80.67 6.45  +0.25 +0.08         F0V                -0.110+0.023      -035      161  1.9 203.       *
+5011 59    VirBD+10 2531 115383119847      W                131148.7+095648131646.5+092527322.80 71.31 5.22  +0.59 +0.10 +0.20E  G0V s              -0.334+0.190 +.079-026V?      7  9.1  34.3       
+5012          CP-71 1458 1154392570283061                   131200.2-713026131918.9-720208305.11-09.28 6.04  +1.35 +1.46         K3III              -0.013-0.056      -031                           
+5013          BD+14 2591 115478100497    I                  131218.8+141207131715.6+134032328.35 75.26 5.33  +1.31 +1.51 +0.66   K3III              +0.007+0.039      -025V?   < 19:                 
+5014          BD+00 3040 115488139264      W        6171    131222.6-000855131729.9-004036316.69 61.50 6.37  +0.26 +0.04         F0V                -0.058-0.025      -020      120  0.0   0.1       
+5015 60Sig VirBD+06 2722 1155211198551344I          6173    131233.2+055948131736.3+052811320.14 67.46 4.80  +1.67 +1.95 +0.84E  M1III              -0.005+0.013 +.011-027V?                        *
+5016          CD-50 7660 115529240721                       131234.2-504531131834.6-511710307.25 11.36 6.19  +0.01               A0V                -0.048-0.023      -004                           
+5017 20    CVnBD+41 2380 115604 44549 494          AO CVn   131303.5+410557131732.5+403421102.73 75.52 4.73  +0.30 +0.21 +0.15   F3III              -0.125+0.021 +.019+008V?     17                 *
+5018          BD+69  694 115612 160333060                   131311.3+685606131628.6+682429119.46 48.55 6.20  -0.06 -0.16         B9.5V              -0.013+0.016      -007V     120:                 
+5019 61    VirBD-17 3813 1156171578441345  W                131310.3-174518131824.3-181841311.88 44.10 4.74  +0.71 +0.26 +0.36   G6V                -1.070-1.065 +.115-009V?   < 17  5.5 231.5       
+5020 46Gam HyaBD-22 3554 115659181543 495I W        6180    131329.0-223838131855.3-231018311.10 39.26 3.00  +0.92 +0.66 +0.47   G8-IIIa            +0.064-0.045 +.027-005V?   < 17  6.7 138.4      *
+5021          BD+04 2721 115709119867                       131347.1+041251131851.1+034116319.73 65.66 6.62  +0.06 +0.03         A1IV               -0.050-0.011      -001SB     47                  
+5022          BD+34 2410 115723 63462    I                  131349.9+343728131827.8+340553 84.77 80.93 5.82  +1.35               K4.5III            +0.033+0.003      -020                           
+5023 21    CVnBD+50 1994 115735 445563063          BK CVn   131359.3+501229131814.5+494055111.85 66.87 5.15  -0.07 -0.20         A0V                -0.033+0.015 +.020-003      106                 *
+5024          CP-59 4912 115778240756      W                131412.8-591449132034.9-594624306.60  2.89 6.18  +0.43               F3-F5II            -0.042-0.024      -010           6.4  13.1       
+5025          BD+35 2435 115810 634683064    8861D          131428.3+353912131904.2+350741 88.19 80.06 6.02  +0.24               F0IV               -0.030+0.019      -002       82  3.6 319.0AD   4 
+5026          CP-52 6405 115823240762               6190    131432.9-521320132037.8-524453307.41  9.87 5.48  -0.13 -0.52 -0.15   B6V                -0.030-0.019      +010SB     73                 *
+5027          CP-55 5504 1158422407653065           6193    131436.3-551632132048.3-554802307.08  6.83 6.02  +0.29 -0.69 +0.22   B0.5Ia            e-0.009+0.004      -003       90                 *
+5028   Iot CenCD-36 8497 115892204371 496                   131458.4-361105132035.8-364244309.42 25.79 2.75  +0.04 +0.03 -0.01   A2V                -0.341-0.085 +.062+000       85                  
+5029          CD-46 8580 115912224080                       131503.8-462121132057.7-465250308.17 15.69 5.77  +1.12 +1.01         K1III              -0.075+0.004      -003                           
+5030          CP-71 1467 115967257033      W                131527.3-713720132252.6-720848305.37-09.42 6.05  +0.09 -0.34         B6V                -0.023-0.013      +033SB         1.4   0.3      *
+5031          BD+03 2758 115995119889        8864           131537.1+032802132041.6+025630320.32 64.82 6.26  +0.10 +0.10         A3V                -0.059-0.029D+.005-004V      80  0.4   1.1       
+5032 23    CVnBD+40 2647 116010 445701346I                  131550.1+404031132019.0+400902100.09 75.67 5.60  +1.20               K1III              -0.058-0.002      -021                           
+5033          BD-18 3587 116061157879               6206    131607.2-185754132129.9-192920312.61 42.82 6.21  +0.09 +0.08         A2V                -0.066+0.008      -008V?                         
+5034          CP-60 4627 116072252283      W     B V790 Cen 131607.7-602652132235.7-605820306.70  1.67 6.18  +0.01 -0.58         B2.5Vn             -0.020-0.013      +003V     233  0.0   0.1AB   3*
+5035          CP-60 4627 1160872522841347  W     A          131610.1-602751132237.9-605918306.71  1.65 4.53  -0.13 -0.60 -0.15   B3V                -0.039-0.014      +006V     241  0.0   0.1AB   3*
+5036          CD-51 7465 116084240782                       131611.1-513932132216.2-521059307.73 10.40 5.83  +0.12 -0.72         B2.5Ib             -0.010+0.001      -015                          *
+5037          BD+02 2664 1161601198993067                   131636.5+023646132141.6+020514320.35 63.93 5.69  +0.06 +0.03         A2V                -0.061-0.053      -007V     200                  
+5038          CD-47 8260 116197224095      W                131654.8-472511132252.7-475635308.36 14.60 6.16  +0.18               A4V                +0.036+0.005      -000V?         0.3   0.6       
+5039          CD-47 8261 1162262240963068                   131703.9-480222132302.6-483346308.31 13.98 6.38  -0.07 -0.44         B6IV               -0.006-0.001      -041                          *
+5040 64    VirBD+05 2737 116235119905                       131707.1+054045132209.7+050917322.72 66.84 5.87  +0.12 +0.10 +0.04   A2m                -0.065-0.036      -010V      20                  
+5041          CP-63 2732 116243252293                       131717.0-640044132400.5-643209306.42-01.88 4.53  +0.85 +0.47 +0.43   G6II               +0.029-0.026 +.002+012                           
+5042   Iot1MusCP-74 1057 1162442570413070                   131714.0-742142132507.1-745316305.17-12.16 5.05  +1.11 +1.01 +0.54   K0III              -0.115-0.130 +.016+028                           
+5043          CD-32 9322 116278204420               6212    131731.6-324001132308.7-331124310.53 29.21 6.22  +1.65 +1.96 +0.94E  M1III              -0.005-0.005      -013                          *
+5044 63    VirBD-16 3650 116292157899               6213    131739.6-171241132301.1-174407313.50 44.49 5.37  +0.99 +0.75 +0.49   KIII               -0.047-0.029 +.004-027                           
+5045          BD+44 2269 116303 44582               6210    131741.4+442534132203.8+435411104.70 72.12 6.35  +0.24 +0.06 +0.14   A7m                -0.071+0.010      -001       36                  
+5046          CD-49 7884 116338224104                       131751.4-491758132352.3-494923308.29 12.71 6.48  +0.96               G8III              -0.067-0.044      -032V                          
+5047 65    VirBD-04 3469 1163651393083069I                  131807.9-042405132318.9-045528317.64 57.03 5.89  +1.43 +1.66         K3III              -0.019-0.015      +010                           
+5048          CP-63 2743 1164572523043071  W                131832.1-635746132513.9-642907306.56-01.85 5.31  +0.40 -0.01         F2III              -0.157-0.022 +.008-002        0  5.7  25.7      *
+5049          CP-69 1838 116458257042                       131832.5-700621132550.1-703739305.80-07.95 5.67  -0.03 -0.18         ApHgMn:            -0.067-0.009      +008V   =< 49                 *
+5050 66    VirBD-04 3472 116568139324                       131920.8-043829132433.2-050950318.08 56.73 5.75  +0.42 -0.04         F3-4V s            +0.159-0.030      +014SB     40                  
+5051   Iot2MusCP-74 1059 116579257047                       131921.4-741015132718.3-744131305.34-11.99 6.63  -0.06 -0.24         B9V                -0.049-0.017      -003                           
+5052          BD+37 2404 116581 63514    I          6220    131921.9+373322132354.0+370202 90.25 77.95 6.07  +1.68               M3III              +0.022-0.006      +000                           
+5053          BD+13 2663 116594100553                       131933.8+125709132430.5+122555332.35 73.39 6.44  +1.06 +0.91         K0III              -0.016+0.041      -006SB                         
+5054 79Zet UMaBD+55 1598 116656 28737 497I   8891A  6224    131954.0+552651132355.5+545531113.11 61.58 2.27  +0.02 +0.03 -0.02   A1VpSrSi           +0.122-0.020 +.047-006SB2O   32  1.7   0.0AP   4*
+5055 79Zet UMaBD+55 1598 116657 28738    I:  8891B  6225    131954.9+552639132356.4+545518113.11 61.58 3.95  +0.13 +0.09         A1m                +0.119-0.028 +.047-009SB1O   57  1.7   0.0AP   4*
+5056 67Alp VirBD-10 3672 116658157923 498I W       Alp Vir  131955.4-103822132511.6-110941316.11 50.84 0.98  -0.23 -0.93 -0.24   B1III-IV+B2V       -0.041-0.028 +.023+001SB2O  159  1.5   0.0 O   5*
+5057          BD+24 2578 116706 828253072                   132020.5+242232132506.7+235116 11.48 81.73 5.78  +0.06 +0.08         A3IV               -0.013-0.009      -003SB?    60                  
+5058          CD-39 8246 1167132044653073                   132019.7-391359132607.8-394519310.14 22.63 5.09  +1.20 +1.02         K0.5III:Ba3        +0.184-0.052 +.012+067V                         *
+5059          BD-00 2686 1168311393373074           6242    132104.0-004021132611.4-011133320.78 60.47 5.97  +0.19 +0.13         A7III              -0.111+0.004      -020      112                3*
+5060          CD-40 7894 116835224148                       132106.8-405840132656.1-412953310.04 20.88 5.69  +1.47               K3III              -0.004-0.019      -024                           
+5061          CD-48 8202 116836224149      W                132104.2-483726132706.3-490838308.91 13.31 6.31                      A0III-IV           -0.021-0.006      -018           0.0   0.1       
+5062 80    UMaBD+55 1603 116842 28751               6238    132113.1+553032132513.5+545917112.77 61.47 4.01  +0.16 +0.08 +0.07   A5V                +0.118-0.016 +.045-009SB    218                 *
+5063          CD-48 8206 116862224151                       132117.8-485142132720.8-492251308.92 13.07 6.28  -0.12 -0.69         B3IV               +0.011+0.010      -006V?                         
+5064 68    VirBD-11 3516 1168701579381348I          6244    132126.1-121114132643.2-124228316.18 49.25 5.25  +1.52 +1.75 +0.87   M0III             v-0.130-0.020      -029V?                        *
+5065          CD-39 8260 116873204483      W                132127.2-393836132714.7-400947310.31 22.20 6.40  +0.98               G8/K0III           -0.007-0.002      +014V          5.7  45.4       
+5066          CP-68 1929 116890252321              EZ Mus   132130.9-690628132846.4-693741306.19-06.99 6.20  +0.02 -0.42         ApSi               -0.047-0.045      +016V                         *
+5067          BD+46 1868 116957 44611                       132159.1+463254132616.6+460141105.14 69.88 5.88  +0.97              gK0                 +0.024-0.021      +004                           
+5068 69    VirBD-15 3668 116976157946    I          6253    132207.0-152718132727.2-155825315.45 46.02 4.76  +1.09 +1.06 +0.53   K0-III-IVCN2Fe0.5 v-0.119+0.024 +.059-014V                         *
+5069          CP-64 2418 117025252329                       132219.5-640926132907.6-644033306.95-02.10 6.11  +0.11 +0.05 +0.05   ApSrEuCr           -0.083-0.005      +015                          *
+5070          BD+64  949 117043 16071                       132234.8+634629132559.9+631540116.41 53.43 6.50  +0.74 +0.30         G6V                -0.392+0.216 +.028-031V                         *
+5071          CD-50 7812 117150240883                       132317.3-503849132925.2-510955308.99 11.26 5.06  +0.07 +0.07         A1V                -0.002-0.017 +.011-002V     243:                 
+5072 70    VirBD+14 2621 1171761005821349  W                132332.3+141846132825.8+134644337.69 74.11 4.98  +0.71 +0.26 +0.39   G4V                -0.236-0.577 +.043+005V       1  3.6 286.4      *
+5073          BD+73  592 117187  7814 499I W        6254    132335.0+725439132608.1+722329119.27 44.49 5.79  +1.63 +1.90         M1IIIab            +0.022-0.009      -048V          7.4  25.7       
+5074          BD+65  935 117200 16078      W     A          132342.6+651512132704.6+644408116.77 51.96 6.66  +0.37  0.00         F0                 -0.068+0.028      -013       21  0.4  47.0AB   3*
+5075          BD+65  936 117201 16079      W     B          132348.6+651413132710.7+644310116.75 51.98 7.04  +0.39 -0.01         F0                 -0.063+0.032      -015    =< 30  0.4  47.0AB   3*
+5076          BD+53 1622 117242 28763                       132358.4+531551132759.5+524445110.49 63.49 6.34  +0.23 +0.14         F0                 -0.114-0.008      -007      101                  
+5077          BD+41 2400 117261 44621                       132401.4+411457132826.2+404347 95.99 74.40 6.47  +0.92               G8III              +0.009-0.056      -058                           
+5078          BD-00 2694 117267139359                       132406.9-005043132914.9-012152322.16 60.09 6.43  +1.11 +1.11 +0.36E  K0III              -0.043-0.062      +039V?                        *
+5079          BD+51 1846 117281 28766                       132405.8+510615132811.7+503514108.77 65.52 6.80R                     F1IV               -0.113+0.041      -016                           
+5080          BD-22 3601 117287181695    I   8920  R Hya    132414.8-224552132942.8-231653314.22 38.75 4.97  +1.60 +0.68 +2.42   M7IIIe            v-0.056+0.016      -010V          8.5  21.2      *
+5081 71    VirBD+11 2575 1173041005923076                   132415.7+112012132913.0+104906333.33 71.42 5.65  +1.05               K0III              -0.061-0.035      -001SB                         
+5082          CP-76  767 117360257060      W       S Cha    132433.3-770259133314.8-773406305.25-14.88 6.48  +0.48 -0.06         F6V                -0.344-0.112 +.034-036V?      0  2.8  22.4      *
+5083          BD+51 1847 117361 28771                       132438.9+511417132845.7+504306108.68 65.36 6.43  +0.37 +0.05         F0IV               +0.029-0.083      -007                          *
+5084   Kap OctCP-85  384 1173742586741665                   132442.1-851625134055.5-854710303.91-23.01 5.58  +0.18 +0.16         Am                 -0.090-0.018      -009SB                        *
+5085          BD+60 1461 117376 16080 500  W                132446.9+602744132827.1+595645114.52 56.57 5.40  -0.01 -0.02         A1Vn               -0.080+0.037 +.025-003V     144  3.3 182.3AC   3*
+5086          BD+07 2655 1174041199623077I                  132459.1+074144133000.1+071044329.33 68.05 6.17  +1.47 +1.80         K5                 +0.004+0.003      -003                           
+5087          BD+06 2750 117405119961                       132455.8+063143132957.6+060048328.11 66.98 6.51  +0.96 +0.59         K0                 -0.017+0.050      -019                           
+5088 72    VirBD-05 3706 117436139370        8924   6281    132512.6-055715133025.7-062813320.03 55.10 6.09  +0.33 +0.07         F2V                +0.042+0.017      -009SB    131  4.9  29.8      *
+5089          CD-38 8592 117440204545      W        6283    132514.6-385327133102.7-392427311.22 22.83 3.88  +1.17 +1.03 +0.59   G9Ib*              -0.012-0.015 +.012-002SB         0.1   0.2      *
+5090          CD-27 9278 117558181723                       132559.7-273550133133.3-280646313.60 33.93 6.47  +0.10               A1V                -0.062+0.002      -004                           
+5091          BD+79  422 117566  78213075                   132605.5+790938132656.7+783838120.71 38.33 5.77  +0.77 +0.35         G2.5IIIbCH1        -0.146+0.029      +015                           
+5092          CD-37 8695 117597204561                       132617.8-375258133205.3-382357311.62 23.79 6.16  +1.04               K1III              +0.035-0.043      +004V                          
+5093          CP-64 2465 117651252361                       132637.4-650704133335.7-653757307.27-03.12 6.37  -0.02 -0.08         A0V                -0.048-0.012      +012                           
+5094 73    VirBD-17 3877 1176611579873078  W       HX Vir   132639.1-181248133202.8-184344316.15 43.10 6.01  +0.18 +0.16 +0.07   F0IV-V             -0.099-0.014      -018       60  0.2   0.1      *
+5095 74    VirBD-05 3714 1176751393903079I          6297    132645.9-054422133157.9-061521320.78 55.21 4.69  +1.62 +1.95 +1.16   M2III              -0.104-0.045 +.020+018V                          
+5096          BD+42 2405 117710 44637                       132655.4+423714133115.8+420622 96.97 72.96 6.08  +1.05               K2III              -0.093+0.026 +.012-020                           
+5097          CD-2810128 1177161817373080                   132701.6-281039133235.9-284134313.74 33.31 5.69  +0.04               A1Vn               -0.095-0.022      -022                           
+5098          CD-2810127 117718181735                       132659.0-290303133234.5-293355313.54 32.46 6.45  +0.44  0.00?        F3IV               -0.072+0.004      -020                           
+5099 75    VirBD-14 3739 117789157998    I W                132730.9-145055133251.7-152147317.47 46.34 5.55  +1.23 +1.22         K1.5IIIb           -0.073-0.002      -040V          5.6  79.6AB   3 
+5100 76    VirBD-09 3711 1178181394013081I                  132741.9-093859133258.1-100954319.44 51.37 5.21  +0.96 +0.60 +0.50   K0III              -0.029-0.036 +.021-001     < 19:                 
+5101          BD-06 3837 117833139403    I         S Vir    132746.7-064051133300.7-071142320.76 54.23 6.68  +1.28 +0.91 +1.86   M7IIIe             +0.050-0.005      +010                          *
+5102          BD+25 2643 117876 82875        8937           132803.9+245158133248.1+242047 18.61 80.28 6.11  +0.96 +0.70 +0.53   G8III              +0.049-0.206      +006V?         6.7   1.5       
+5103          CD-47 8417 117919224254      W                132824.1-474532133428.9-481620310.29 13.98 6.33  -0.05               B8III              -0.029-0.012      -004           2.0   0.5       
+5104          CD-32 9459 1180102046123082           6315    132902.7-324752133443.6-331839313.24 28.69 6.44  +1.26               K2III              -0.049-0.012      -009                           
+5105 78    VirBD+04 2764 1180221200041351          CW Vir   132903.8+041021133407.9+033932328.27 64.41 4.94  +0.03  0.00 -0.03   A1pSrCrEu          +0.044-0.024 +.021-012SB     15                 *
+5106          BD-12 3843 118054158021        8954   6316    132921.3-124205133440.5-131252318.87 48.32 5.91  +0.02 -0.09         A2pSrEu:Cr:        -0.044-0.010D+.007-020V?         0.4   0.3AB   3*
+5107 79Zet VirBD+00 3076 118098139420 501                   132935.8-000505133441.6-003545325.25 60.39 3.37  +0.11 +0.10 +0.06   A3V                -0.285+0.042 +.044-013      173                 *
+5108          BD+39 2658 118156 63616        8956           132956.7+391804133421.8+384721 88.07 75.29 6.37  +0.21 +0.11         F0IV               +0.013+0.024      -012       97  4.3  30.6      *
+5109 81    UMaBD+56 1667 118214 28803               6319    133016.6+555139133407.3+552055110.49 60.74 5.60  -0.03 -0.09         A0V                -0.022-0.002 +.013-007V     156                  
+5110          BD+37 2426 118216 63623 502          BH CVn   133019.9+374141133447.8+371057 83.33 76.41 4.98  +0.40 +0.06 +0.30   F2IV               +0.086-0.009 +.022+007SBO     0                 *
+5111 80    VirBD-04 3515 1182191394281352                   133019.0-045313133531.3-052346322.71 55.77 5.73  +0.95 +0.66         G6III              +0.017+0.085      -008                           
+5112 24    CVnBD+49 2227 118232 446683083           6322    133022.1+493138133427.3+490058104.99 66.59 4.70  +0.12 +0.11 +0.02   A5V                -0.127+0.030 +.034-018V     178                 *
+5113          CP-61 3841 118261252387      W                133025.2-611040133712.2-614131308.33  0.70 5.63  +0.50               F6V                +0.135-0.113D+.032+040SB    111  0.2   0.3AB   3*
+5114          BD+10 2565 118266100630      W                133035.2+104305133533.3+101217336.59 70.14 6.49  +1.03 +0.90 +0.52   K1III+F6V          +0.077-0.061      +033V?         2.0  70.2      *
+5115          CP-75  882 118285257069 503                   133038.2-751025133911.9-754102305.94-13.09 6.34  +0.01 -0.26         B8IV               -0.027-0.006      +018SB2                       *
+5116          BD+44 2285 118295 446751353                   133058.7+444229133514.1+441149 98.48 70.79 6.84  +0.20 +0.25         A7-F0III           -0.016+0.015      -026      101                  
+5117          CD-33 9189 118319204653                       133107.0-335722133650.5-342804313.47 27.47 6.50  +1.03 +0.85         K0III              -0.011-0.028      +022V?                         
+5118          CD-43 8418 1183382242753084                   133107.7-433756133706.0-440836311.52 17.97 5.98  +0.94               G8-K0III           -0.050-0.020      +006                           
+5119          CP-69 1898 1183442570703086                   133110.2-695603133845.7-702642306.91-07.94 6.10  +1.42 +1.73         K3III              -0.068-0.032      +002                           
+5120          CD-25 9900 118349181790        8966A          133115.4-255906133648.4-262942315.38 35.28 5.78  +0.22 +0.19         A7III              -0.091+0.021 +.021-010           1.0  10.1AB   4*
+5121          CD-45 8578 118354224283                       133120.6-455501133723.7-462542311.13 15.71 5.90  -0.12               B8V                -0.009-0.033      +003V?                         
+5122          CP-57 6169 118384241013      W                133133.8-575414133807.6-582454309.03  3.90 6.42  +1.12 +0.93         K1III              -0.008-0.036      +001           4.6   2.5       
+5123          BD+25 2652 118508 829053085I          6342    133216.7+250724133659.1+243648 21.68 79.45 5.74  +1.55 +1.85         M2III              -0.024-0.005      -031V                          
+5124          CP-56 5856 118520241026      W                133217.2-570649133849.1-573723309.26  4.67 6.01  +1.14               G5Ib               -0.006-0.014      -010           0.0   0.1       
+5125          CP-70 1653 118522257074                       133219.6-701644134000.6-704718306.94-08.30 6.59  +1.30 +1.09         K0III              -0.026-0.028      -003                           
+5126          BD+50 2014 118536 44682                       133235.8+495949133639.8+492912104.68 66.01 6.49R                     K1III              -0.004-0.012      -010                           
+5127 25    CVnBD+37 2433 118623 63648        8974           133301.0+364813133727.6+361742 78.96 76.61 4.82  +0.23 +0.09 +0.13   A7III              -0.099+0.027 +.030-006V     204  2.0   1.7AB   3*
+5128          CD-2810181 118646181825                       133304.8-290300133842.0-293339315.08 32.19 5.83  +0.40               F5V                -0.078-0.069      +004                           
+5129          BD+15 2602 118660100644                       133314.3+144841133807.9+141806345.58 73.18 6.52  +0.25 +0.11         A9V s              +0.036-0.019      -002       90                 *
+5130          CP-63 2896 118666252400                       133310.5-640407134010.9-643437308.14-02.20 5.79  +0.39 +0.02         F3III-IV           -0.059-0.012      +004                           
+5131          BD+77  516 118686  7848    I                  133323.5+770326133442.8+763248119.65 40.30 6.57R                     K5III:             -0.026-0.003      -014                           
+5132   Eps CenCP-52 6655 118716241047 504  W       Eps Cen  133332.9-525728133953.2-532759310.19  8.72 2.30  -0.22 -0.92 -0.24   B1III              -0.028-0.016      +003      159  8.4  36.9      *
+5133          BD+51 1856 118741 28819    I   8979           133342.6+511325133743.0+504253105.56 64.82 6.48  +1.55 +1.66 +1.05   M2II-III+K3III:    -0.012+0.001D+.003-048V          1.3   1.8      *
+5134          CD-49 8095 118767224317    I         V744 Cen 133348.8-492633133959.7-495701310.89 12.17 6.00  +1.50 +1.15 +1.75E  M5III              -0.113+0.011      -011                          *
+5135          CD-39 8390 118781204708              V765 Cen 133348.4-391422133940.8-394453312.92 22.19 6.27  +1.66 +1.78         M4III              -0.020-0.025      -048V                         *
+5136          CD-39 8392 118799204712                       133355.9-393232133948.6-400307312.88 21.88 5.60  +1.30               K2/3III            -0.044-0.061      +001                           
+5137          BD+19 2697 118839100650                       133413.5+184626133902.3+181555356.46 75.91 6.48  +1.20 +1.27         K3III              -0.045-0.018      -011                           
+5138          BD+11 2589 118889100654        8987   6363    133438.7+111515133934.6+104446339.90 70.08 5.57  +0.33 +0.05         F0V                -0.112-0.013 +.011-018V     111: 0.2   0.1AB   3*
+5139          BD+71  659 118904  7854 505I                  133446.8+714504133711.0+711432117.72 45.42 5.50  +1.20              gK2                 -0.038-0.006      +015                           
+5140          CP-58 5059 118978241080                       133522.9-581651134201.1-584714309.46  3.44 5.38  -0.03 -0.23         B9III              -0.035-0.010      -008V     228:                *
+5141          CP-53 5725 118991241076      W                133520.3-540309134144.7-543336310.25  7.60 5.01  -0.05 -0.23         B8Vn               -0.048-0.047D+.003+010V     281: 1.4   5.4      *
+5142 82    UMaBD+53 1640 119024 28832                       133538.3+532536133930.4+525517107.04 62.70 5.46  +0.10 +0.04         A3Vn               -0.142+0.060 +.011-015V     181                  
+5143          BD+31 2526 119035 63676                       133542.4+313058134015.6+310043 55.83 78.65 6.21  +0.96               G5II:              -0.078+0.087      -018SB                         
+5144  1    BooBD+20 2858 119055 82942        8991           133553.8+202741134040.5+195720  3.08 76.64 5.75  +0.01  0.00         A1V                -0.049+0.023D+.018-026V      45  3.5   4.8AB   3*
+5145          BD+28 2248 119081 82944      W                133602.2+283416134039.1+280355 40.68 79.06 6.23  +1.28 +1.50         K3III              -0.066+0.014      -063           3.3  91.2       
+5146          BD-22 3645 1190861818631354    8994           133559.6-225638134130.9-232659317.55 38.00 6.59  +0.06 +0.05         A0                 -0.009+0.003      -013           0.0   0.1AB   3*
+5147          CD-32 9549 119090204739    I:        T Cen    133601.6-330530134145.7-333549314.80 28.11 6.05  +1.44 +1.10 +1.09   K0e-M4IIe         v-0.014+0.026      +028V                         *
+5148          BD+51 1859 119124 28836        8992           133625.3+510126134023.2+503110104.46 64.82 6.32  +0.54 -0.03         F7-9V              -0.132+0.060 +.049-015V      12  4.3  17.6      *
+5149  2    BooBD+23 2600 119126 82946                       133618.4+230009134102.3+222945 13.26 77.84 5.62  +1.01               G9III              -0.020-0.025      +005                           
+5150 82    VirBD-07 3674 1191491394901355I          6390    133621.7-081154134136.8-084211323.42 52.16 5.01  +1.63 +1.95 +1.16   M1.5III            -0.094+0.040 +.013-037                           
+5151          CP-56 5891 1191592410961356                   133623.7-561546134256.1-564605309.98  5.40 6.00  -0.08               B0.5III            -0.011-0.004      -023V                          
+5152          CD-50 7983 119193241098                       133638.8-501706134254.6-504726311.19 11.25 6.41  +1.67               M0III              -0.007-0.027      -010                           
+5153          BD+57 1456 119213 28838              CQ UMa   133641.9+574247134021.3+571227110.18 58.69 6.29  +0.10 +0.02         A2VpSrCrEu        v-0.057+0.024      -000                          *
+5154 83    UMaBD+55 1625 119228 288433087I          6389    133656.7+551116134044.3+544054108.18 61.01 4.66  +1.64 +1.96 +1.12   M2IIIabBa0.5       -0.022-0.009 +.014-017                           
+5155          CD-40 8096 119250224359                       133658.8-405342134255.0-412404313.20 20.44 5.98  +1.02               K0III              -0.059-0.049      +028                           
+5156          BD+09 2798 119288120075              Var      133716.5+085344134212.7+082318337.96 67.74 6.16  +0.42 -0.04         F3Vp               -0.382-0.090 +.035-011V      12                 *
+5157          CD-41 8089 119361224365      W                133741.9-413348134340.0-420403313.20 19.76 5.98  -0.08               B8III              -0.026-0.006      -021           0.0   0.1AB   3*
+5158          CD-50 7998 119419241120              V827 Cen 133759.0-503030134415.9-510047311.35 10.99 6.47  -0.13               A0pSiCr            -0.036-0.041      +009                          *
+5159 84    VirBD+04 2775 119425120082    I   9000   6401    133802.0+040238134303.7+033217332.78 63.38 5.36  +1.11 +1.04 +0.54   K2III              -0.291-0.071 +.006-041SB         2.8   3.0      *
+5160          BD+42 2431 119445 44720                       133813.1+421041134228.8+414027 90.49 72.09 6.30  +0.86               G6III              -0.090+0.007      -033                           
+5161          BD+35 2474 119458 637013089                   133816.0+352934134243.4+345920 71.71 76.51 5.98  +0.85               G5III              +0.013+0.012      -015SBO                       *
+5162          BD+65  953 119476 161423088                   133823.1+651939134129.9+644921114.42 51.47 5.85  +0.07 +0.08         A2V                +0.054-0.012      -006SB    105                  
+5163          BD-04 3540 119537139516                       133841.9-045943134354.3-052956326.12 54.99 6.51  +0.05 +0.01         A1V                -0.050-0.018      -022SB  =< 38                  
+5164          BD+23 2606 119584 82969    I                  133901.6+231217134345.2+224201 15.32 77.35 6.13  +1.42 +1.70 +0.75   K4III              +0.049-0.036      +009                          *
+5165 83    VirBD-15 3731 1196051581311357                   133906.0-154034134429.8-161045321.03 44.82 5.60  +0.81 +0.41 +0.40   G0Ib-IIa           +0.013-0.004      +001V                         *
+5166          CD-2411057 119623181921                       133911.6-245952134445.7-253003317.81 35.83 6.21  +1.38               K0                 -0.053-0.016      +006V                          
+5167          CD-25 9972 119752181931                       134001.9-253651134536.9-260658317.84 35.18 5.81  +0.02               A1Vn               -0.071-0.010      -010V                          
+5168  1    CenCD-32 9603 119756204812 506          Var?     134000.2-323217134541.2-330238315.86 28.46 4.23  +0.38  0.00 +0.21   F3IV               -0.462-0.146 +.051-022SBO    86                 *
+5169          BD+52 1733 119765 28866                       134002.1+523402134354.7+520352104.91 63.19 6.02   0.00 -0.01         A1V                -0.026-0.003      -007V?     77                  
+5170 85    VirBD-15 3735 119786158147      W                134011.9-151554134535.1-154603321.56 45.14 6.19  +0.05               A2Vn               -0.044-0.024      -041SB         1.7   0.0 O   4*
+5171          CP-61 4003 119796252448    I W       V766 Cen 134012.1-620520134710.7-623524309.30-00.41 6.51  +1.98 +1.19 +1.20   K00-Iae            -0.023-0.011      -036V          4.0   9.4      *
+5172          CD-50 8017 119834241157      W        6434    134019.4-505551134639.3-512558311.63 10.50 4.65  +0.96 +0.72         G8-K0III           +0.006-0.033 +.018-006SB1O       6.3  40.       *
+5173 86    VirBD-11 3591 119853158152        9018           134036.5-115532134556.3-122536323.16 48.29 5.51  +0.90               G8III              -0.017+0.008      -011V?         5.0   1.2AB   4*
+5174          CD-35 8995 1199212048353091  W                134106.5-354504134656.4-361507315.28 25.29 5.15  -0.02               A0V                -0.011-0.009 +.019-010      437  7.3  26.3       
+5175          CD-49 8194 1199382411733092                   134109.6-494458134727.6-501458312.02 11.63 5.91  +0.29               A3mA5F0            +0.058+0.013      +016                           
+5176          CD-49 8198 119971241177                       134122.3-494914134738.4-501916312.04 11.55 5.45  +1.36 +1.36         K2III              -0.151-0.023 +.013+028                           
+5177          BD+56 1683 119992 28878                       134131.4+562326134513.2+555246107.97 59.66 6.50  +0.47 -0.06         F7IV-V             +0.102-0.360 +.024-004        9                  
+5178          BD-08 3639 120033139544    I W                134156.2-091230134713.5-094233324.99 50.76 6.05  +1.42 +1.66         K5III              +0.008-0.037      +007V          1.6   0.4      *
+5179          BD+41 2424 120047 44742                       134158.7+413525134613.5+410519 87.52 72.06 5.87  +0.21 +0.06         A5V                -0.114-0.043 +.012-013V?    199                  
+5180          BD+39 2678 120048 63735                       134159.2+390015134619.0+383014 81.11 73.84 5.94  +0.94               G9III              -0.051-0.002      -014                           
+5181 87    VirBD-17 3932 120052158165    I          6442    134158.9-172133134725.4-175136321.28 43.01 5.43  +1.62 +1.94 +0.89E  M2IIIab            +0.059-0.034      +064                          *
+5182  3    BooBD+26 2494 120064 829931358                   134204.7+261214134643.3+254208 29.48 77.55 5.95  +0.49 +0.10         G5III+A7V:         -0.020-0.061      +008SB2O                      *
+5183          BD+07 2690 120066120108                       134159.9+065112134657.1+062102337.86 65.38 6.33  +0.63 +0.16         G0-1IV-V           -0.510-0.108 +.026-031V?  =< 10  3.5 486.       *
+5184          BD+78  466 120084  78763090                   134213.2+783354134239.3+780352119.56 38.73 5.91  +1.01              gG7                 -0.062+0.049 +.034-007V?                        *
+5185  4Tau BooBD+18 2782 120136100706 507    9025   6444    134230.6+175719134715.7+172724358.95 73.88 4.50  +0.48 +0.04 +0.24   F6IV               -0.482+0.041 +.059-016V      14  7.5   5.0      *
+5186          BD+39 2680 120164 637393094  W                134241.0+390234134659.8+383234 80.90 73.71 5.50  +1.03 +0.84 +0.52   K0III+F8V          -0.131-0.016      -010SB         3.2  71.3       
+5187 84    UMaBD+55 1634 120198 28885              CR UMa   134251.7+545557134635.7+542558106.38 60.89 5.70  -0.08 -0.08         B9pEuCr           v-0.019+0.001      -002V?     37                 *
+5188          CP-82  585 1202132586833986                   134252.1-821014135538.7-823958305.09-20.06 5.95  +1.46 +1.57  0.00   K2.5IIIaCH-3Ba0.5  -0.036-0.023      -035V?                        *
+5189          CD-35 9019 120237204867      W                134309.5-351203134855.1-354214315.87 25.72 6.53  +0.57 +0.05         G3IV-V             -0.516-0.174 +.039+004           3.0  11.5      *
+5190   Nu  CenCD-41 8171 120307224469              Nu  Cen  134330.2-411122134930.3-414116314.41 19.89 3.41  -0.22 -0.84 -0.23   B2IV               -0.022-0.021      +009SB1O   91                 *
+5191 85Eta UMaBD+50 2027 120315 44752 509I          6450    134336.0+494845134732.4+491848100.69 65.32 1.86  -0.19 -0.67 -0.18   B3V                -0.122-0.011 +.035-011SB?   205                 *
+5192  2    CenCD-33 9358 120323204875    I         V806 Cen 134338.9-335705134926.7-342703316.32 26.91 4.19  +1.50 +1.45 +1.81   M4.5III            -0.042-0.057 +.031+041                          *
+5193   Mu  CenCD-41 8172 120324224471 508  W       Mu  Cen  134335.4-415832134937.0-422826314.24 19.12 3.04  -0.17 -0.72 -0.11   B2IV-Ve           v-0.023-0.020      +009SB    175 10.7  48.       *
+5194          CP-68 2014 1204042524813099                   134400.8-685417135147.4-692405308.23-07.15 5.75  +1.73 +2.02         K5-M0III           +0.004-0.003      +010V?                         
+5195          BD+31 2547 120420 637603096                   134408.0+314113134838.7+311125 54.35 76.88 5.62  +1.01               K0III              -0.007+0.037      +011                           
+5196 89    VirBD-17 3937 120452158186 510I                  134426.1-173810134952.3-180803321.93 42.57 4.97  +1.06 +0.92 +0.50   K0.5III-IIIb       -0.100-0.038 +.046-040     < 19:                *
+5197          CD-2810277 1204551819993097           6460    134426.3-283501135006.5-290453318.07 32.06 6.18  -0.03 -0.12         A0V                -0.048-0.032      +000                           
+5198          CD-39 8501 120457204888                       134421.9-392413135019.4-395404315.03 21.58 6.44  +0.99               K1III              +0.007-0.012      -004                           
+5199          BD+40 2694 120499 63763    I         R CVn    134439.7+400224134857.2+393234 82.66 72.77 7.4                       M6IIIe            v+0.023-0.002 -.006-006V                         *
+5200  5Ups BooBD+16 2564 120477100725    I          6458    134439.2+161738134928.6+154752355.81 72.40 4.07  +1.52 +1.87 +0.87   K5.5III           e-0.095+0.042 +.011-006V    < 17                 *
+5201  6    BooBD+21 2578 120539 830153098I                  134459.0+214538134942.8+211551 12.25 75.49 4.91  +1.43 +1.65 +0.74   K4III              +0.024+0.017      -003     < 19:                 
+5202          BD-19 3754 120544158192                       134505.8-192406135034.5-195350321.42 40.84 6.53  +0.51               G5III-IV:+A5:      -0.046+0.034      -030V      30                  
+5203          BD+83  397 120565  22661643                   134510.2+831515134223.1+824509121.01 34.18 5.98  +1.01               G9III              +0.035-0.041      -050SB                         
+5204          BD+37 2457 120600 63772                       134523.5+370743134945.0+363758 74.14 74.42 6.38R                     A7IV-V             -0.074+0.022      -012       82                  
+5205          BD+06 2800 1206021201323100                   134523.3+055937135024.7+052950338.54 64.21 6.01  +0.90 +0.59         K0                 +0.009-0.003      -024                           
+5206          CD-46 8909 120640224489                       134535.3-462410135147.2-465357313.53 14.73 5.77  -0.16 -0.75         B2Vp               -0.018-0.030      -005V?    100                 *
+5207          CP-52 6787 120642241239      W                134538.1-521856135204.8-524842312.14  8.97 5.25  -0.09 -0.32         B9V                -0.045-0.035 -.001+027      186  2.3  18.1      *
+5208          CD-35 9054 120672204911                       134545.4-355605135136.6-362600316.24 24.88 6.35  +0.48 +0.01         F6IV-V             -0.100-0.117      +000SB2                       *
+5209          CD-2311329 120690182026                       134549.8-235313135120.4-242327319.96 36.49 6.45  +0.69 +0.27         G5V                -0.572-0.302 +.062+002                          *
+5210  3    CenCD-32 9676 120709204916      W     A          134603.1-322953135149.6-325940317.28 28.19 4.56  -0.13 -0.60 -0.13   B5IIIp             -0.033-0.038D+.017+010       12  1.5   7.9      *
+5211  3    CenCD-32 9676 120710204917      W     B          134603.8-322956135150.1-325941317.28 28.19 6.06  -0.04 -0.15         B8V                -0.056-0.027D+.017+000      180  1.5   7.9      *
+5212          CD-3110706 120759204922      W                134616.5-310723135200.9-313710317.74 29.50 6.12  +0.48               F7V                -0.053-0.052D+.016+009           1.0   0.6       
+5213          BD+62 1318 120787 161863101                   134630.2+615917134945.5+612921111.06 54.27 5.96  +0.96 +0.64         G3V                +0.065-0.099      -011V                          
+5214          BD+35 2492 120818 63779                       134639.7+351604135104.5+344621 67.50 75.13 6.65  +0.12 +0.07 +0.01   A5IV               +0.031-0.010      -012V     108                 *
+5215          BD+35 2493 120819 63781    I          6468    134644.4+350939135109.2+343952 67.10 75.16 5.87  +1.62 +1.96         M2III              +0.005-0.054 +.014-040                           
+5216          BD+59 1533 120874 28901                       134701.4+590204135027.7+583222108.83 56.94 6.46  +0.09 +0.08         A3V                -0.029+0.011      -040SB                         
+5217          CP-52 6805 120908241262                       134713.3-525246135343.1-532225312.25  8.37 5.89  +0.01 -0.41  0.00   B5III              -0.024-0.029      +007       23                 *
+5218          CP-67 2426 120913252511                       134712.5-670932135448.9-673909308.92-05.52 5.71  +1.49 +1.67         K2III              -0.034-0.027      -008                           
+5219          BD+35 2496 120933 637933102I         AW CVn   134722.8+345622135147.5+342639 66.10 75.14 4.74  +1.66 +1.96 +1.28   K5III              -0.019-0.032 +.026-044                          *
+5220          BD+12 2635 1209341007453104                   134724.4+123934135218.4+120955349.54 69.32 6.04  +0.04 +0.01         A1V                +0.028-0.005      -016       74                  
+5221  4    CenCD-3110729 120955204944      W                134727.0-312601135312.5-315540317.93 29.14 4.73  -0.14 -0.54 -0.08   B4IV               -0.015-0.012      +005SBO    27  3.7  14.9      *
+5222          CD-35 9090 120987204955      W                134741.9-351014135332.8-353951316.88 25.52 5.54  +0.44 -0.01         F4V                -0.078-0.019D+.009-008SB      0  0.2   0.9AB   5*
+5223          CD-46 8931 120991224514      W       V767 Cen 134743.5-463806135356.9-470741313.84 14.42 6.10  -0.07 -0.92 -0.10   B2IIIe            v-0.037-0.001      -021       70  4.9  21.4      *
+5224          CD-34 9223 121056204963                       134803.4-344910135352.2-351852317.06 25.84 6.19  +1.02 +0.86         K1IV-V             -0.270-0.075      +005V?                         
+5225  7    BooBD+18 2795 121107100751                       134826.2+182532135312.9+175558  3.30 73.05 5.70  +0.84               G5III              -0.039+0.004      -010V?                         
+5226 10    DraBD+65  963 121130 16199 511I   9039  CU Dra   134830.6+651302135125.9+644324112.77 51.21 4.65  +1.58 +1.89 +1.36   M3.5III            +0.001-0.002 +.014-011V?         7.7  90.2AC   3*
+5227          BD+69  724 121146 161973103  W                134831.8+684839135059.2+681855114.79 47.86 6.40  +1.17       +0.60   K2IV               -0.172-0.055 +.025-045           1.8  79.1AB   3*
+5228          CD-27 9478 121156182065                       134836.8-280432135416.6-283411319.27 32.30 6.04  +1.13               K2III              -0.170-0.069      -017V                          
+5229          BD+29 2464 121164 830553106                   134838.1+290825135310.3+283853 42.88 76.28 5.90  +0.20 +0.14         A7V                -0.125+0.027      -012       57                  
+5230          CD-51 7832 121190241294                       134845.0-514007135512.2-520940312.77  9.49 5.71  -0.08 -0.30         B9V                -0.027-0.024      +023V                         *
+5231   Zet CenCD-46 8949 121263224538 512                   134917.9-464745135532.4-471718314.07 14.19 2.55  -0.22 -0.92 -0.20   B2.5IV             -0.057-0.042      +007SB2O  219                 *
+5232 90    VirBD-00 2758 1212991396133107I                  134933.9-010040135442.1-013011333.47 57.57 5.15  +1.08 +1.08 +0.52   K2III              -0.088-0.018 +.027-007V?   < 17                  
+5233          BD-07 3728 121325139618        9053           134943.3-073400135458.2-080332328.80 51.59 6.19  +0.53 +0.01         F8V+G0             -0.172-0.030 +.020-019V          0.9   3.4AB   4*
+5234          CP-53 5805 121336241309      W                134946.1-533828135619.8-540755312.44  7.54 6.14  +0.07 +0.03         A1V                -0.038-0.014D+.012+013           1.0   1.8AB   3 
+5235  8Eta BooBD+19 2725 121370100766 513I W                134955.3+185356135441.1+182352  5.30 73.03 2.68  +0.58 +0.20 +0.29   G0IV               -0.063-0.358 +.108-000SB1O   13  6.0 112.6      *
+5236          CP-54 5806 121384241315      W                134957.2-541230135633.0-544216312.32  6.98 6.00  +0.78               G6IV-V             -0.038-0.216      +005           6.9  33.        
+5237          CD-3011015 121397204994                       134959.4-304740135544.5-311706318.73 29.61 6.51  +0.90               G8III              -0.047+0.009      -018                           
+5238 86    UMaBD+54 1630 121409 28928                       135010.2+541313135351.0+534343103.76 61.01 5.70  -0.05 -0.07         A0V                -0.030-0.003 +.012-016V?    225                  
+5239          CD-45 8815 121416224555                       135007.3-460600135619.5-463533314.39 14.83 5.83  +1.14 +1.11         K1III              -0.164-0.076 +.025-001                          *
+5240          CP-77  922 1214392571073111                   135013.4-780607140032.8-783524306.44-16.19 6.09  +0.03 -0.17         B9III              -0.021-0.005      +006V                          
+5241          CP-63 3070 121474252531 514                   135024.5-631147135738.9-634112310.19-01.75 4.71  +1.11 +1.04 +0.40E  K1.5III            -0.044-0.030 +.033+022                           
+5242          CP-65 2553 1215572525343110  W                135103.2-651840135831.2-654802309.74-03.82 6.20  +1.05 +0.81         K0III              -0.033-0.036      -029           4.0   6.4       
+5243          BD+14 2680 1215601007763109                   135100.8+143247135550.0+140323355.12 70.09 6.16  +0.50 -0.08         F6V                -0.292+0.007      -013    =<  6                  
+5244 92    VirBD+01 2865 121607120185                       135122.1+013223135627.9+010302336.53 59.61 5.91  +0.20 +0.14         A8V                -0.026+0.014      -023      181                  
+5245          BD+32 2411 121682 638371360                   135144.2+323114135610.5+320157 56.03 75.11 6.32  +0.37 +0.06         F4IV-V             -0.118+0.048 +.014-022        8                  
+5246          BD-22 3687 121699182123    I                  135153.6-223204135727.7-230122322.14 37.37 6.14  +1.43               K0                 -0.041+0.006      +001V?                         
+5247  9    BooBD+28 2278 121710 83084    I          6502    135200.2+275857135634.2+272931 38.12 75.54 5.01  +1.42 +1.72 +0.75   K3III             v+0.028-0.048 +.008-040     < 19:                *
+5248   Phi CenCD-41 8329 121743224577               6509    135211.4-413644135816.3-420603315.98 19.07 3.83  -0.21 -0.83 -0.22   B2IV               -0.024-0.021      +006V     126                 *
+5249   Ups1CenCD-44 9010 1217902245853112                   135230.0-441856135840.8-444813315.29 16.45 3.87  -0.20 -0.80 -0.21   B2IV-V             -0.025-0.024      +005V     122                 *
+5250 47    HyaCD-2411202 121847182134 515                   135254.3-242903135831.1-245820321.66 35.45 5.15  -0.10 -0.40         B8VpShell          -0.049-0.029      +005SB                        *
+5251          CD-49 8356 121853241352                       135252.1-495256135917.3-502212313.86 11.06 5.91  +0.96               G8-K0III           +0.011-0.034      -005                           
+5252          CP-60 5135 121901252552                       135312.2-605938140017.3-612853311.06  0.30 6.49  +0.33 -0.04         F1III-IV           -0.072-0.040      +006                           
+5253          CP-65 2573 121932252554      W                135320.0-654657140052.2-661607309.85-04.33 5.97  +0.35 +0.07         F2III              -0.136-0.016      -017           5.9  46.2       
+5254          BD+15 2651 121980100801    I                  135350.2+150815135839.9+143858357.75 69.98 6.00  +1.44 +1.71         K5III              -0.061-0.056      -041                           
+5255 10    BooBD+22 2650 121996 831033113                   135357.7+221103135838.9+214146 17.02 73.78 5.76  -0.03 +0.02         A0V s              -0.009-0.045 +.013+006       60                  
+5256          BD+62 1325 122064 16230                       135425.6+615826135732.1+612934109.61 53.90 6.37R                     K3V                -0.034+0.210      -025                           
+5257 48    HyaCD-2411215 1220661821521361                   135424.0-243120140000.1-250037322.04 35.31 5.77  +0.48               F7V                -0.196-0.091 +.029-017V?                         
+5258          BD-02 3768 1221061396661362                   135438.3-030345135949.3-033259333.84 55.17 6.40  +0.49 +0.06         F8V                -0.025-0.058      -008V?     12                  
+5259          CD-39 8628 122210205096      W                135516.6-394416140119.0-401320317.12 20.72 6.13  +1.25 +1.29         K1III              -0.037-0.006      -045           6.2  10.        
+5260   Ups2CenCD-44 9040 122223224621                       135529.1-450708140143.4-453613315.60 15.53 4.34  +0.60 +0.27 +0.33   F6II               +0.002-0.019 +.013-001SB1O    0                 *
+5261   The ApsCP-76  799 1222502571121363I:        The Aps  135534.5-761851140519.8-764748307.22-14.54 5.5   +1.55 +1.05 +1.77   M6.5III:           -0.094-0.032      +010                          *
+5262          BD+09 2835 1223651202283114                   135623.4+092243140120.4+085341348.38 65.40 5.99  +0.09 +0.10         A2V                +0.036-0.007      -017      100                  
+5263 11    BooBD+28 2287 122405 83130 517                   135638.4+275211140110.5+272312 37.90 74.51 6.23  +0.17               A7III              -0.080+0.017      -024V     102                  
+5264 93Tau VirBD+02 2761 122408120238 516    9085A          135633.3+020142140138.8+013240339.22 59.38 4.26  +0.10 +0.12 +0.06   A3V                +0.018-0.021 +.024-002SB    150  5.2 129.0AB   3*
+5265          CD-2610060 122430182182    I                  135641.4-265649140222.8-272548321.70 32.84 5.48  +1.34 +1.44         K3III              -0.033-0.008      +000                           
+5266          CP-55 5846 122438241403                       135640.8-554350140326.2-561249312.87  5.26 5.92  +1.22 +1.18         K2III              -0.083-0.031      +017                           
+5267   Bet CenCP-59 5365 122451252582 518  W       Bet Cen  135645.8-595326140349.4-602223311.77  1.25 0.61  -0.23 -0.98         B1III             v-0.032-0.019 +.009+006SB    139  3.2   1.3      *
+5268          CD-3110859 122510205123      W                135713.2-311214140301.7-314102320.29 28.76 6.18  +0.48               F8V                +0.022+0.083 +.018+005           1.1   2.1      *
+5269          CD-40 8373 1225322246411364          V828 Cen 135721.7-405628140327.5-412524317.16 19.45 6.11  -0.11 -0.39 -0.11   ApSi               -0.034-0.017      +004V                         *
+5270          BD+10 2617 122563120251               6526    135737.4+101013140231.8+094111350.17 65.80 6.20  +0.90 +0.38 +0.58   F8IV               -0.196-0.063      -023                          *
+5271          BD+46 1922 122675 448583115                   135813.8+461415140212.2+454513 90.56 66.67 6.27  +1.32 +1.45         K2III              +0.033-0.076      -049                           
+5272          BD-21 3824 1227031822043117                   135818.3-215627140353.1-222518324.15 37.45 6.30  +0.45               F5III              -0.012+0.013      -019                           
+5273          BD+11 2625 122742100832                       135837.5+111634140332.3+104712352.46 66.45 6.30  +0.74 +0.29 +0.40   G8V                +0.083-0.307 +.059-017SB                        *
+5274          BD+08 2810 122744120261                       135838.8+080139140336.8+073247347.39 64.00 6.26  +0.94 +0.70         G9III              -0.038-0.012      -020                           
+5275          BD+05 2836 1227971202653118                   135854.5+052254140355.8+045403343.99 61.85 6.24  +0.39 -0.02         F4V                -0.011-0.003      -023       50                  
+5276          BD-04 3614 122815139711                       135901.2-045403140414.6-052253334.07 53.03 6.39  +1.32 +1.58         K0                 -0.009-0.011      -009                           
+5277          BD-14 3863 1228371583251365                   135902.0-142928140427.0-145818327.95 44.32 6.28  +1.08 +0.95         G6III              -0.036-0.019      -015V                          
+5278          CP-54 5887 1228442414303119                   135904.6-541122140546.5-544010313.63  6.65 6.17  +0.23               A5III-IV           -0.050-0.019      -036V                          
+5279          CP-74 1142 1228622571163120                   135916.0-742240140827.1-745101308.00-12.75 6.02  +0.58 +0.06         G2-3IV             -0.252+0.179 +.041-022                           
+5280          BD+51 1889 122866 28989                       135916.4+512710140259.7+505819 98.11 62.57 6.15  +0.01               A2V                -0.021 0.000      -010       60                  
+5281          CP-59 5395 122879241439               6544    135922.0-591414140625.1-594256312.26  1.79 6.42  +0.12 -0.80         B0Ia               -0.011+0.019      +002                          *
+5282          BD+69  733 122909 16254    I                  135938.2+690936140150.6+684043113.63 47.16 6.34  +1.40               K5                 -0.035-0.001      -022                           
+5283          BD+02 2768 122910120269                       135933.3+024638140437.5+021751341.25 59.61 6.28  +1.02 +0.87         K0                 -0.030-0.003      -029                           
+5284          BD-15 3805 122958158331                       135947.0-155125140514.0-162009327.46 42.99 6.56  +0.10               A4V                +0.002+0.006      -013                           
+5285   Chi CenCD-40 8405 122980224673              Chi Cen  135956.3-404202140602.8-411047317.73 19.54 4.36  -0.19 -0.77 -0.22   B2V                -0.017-0.020      +012V?     33                 *
+5286          CD-42 9027 123004224676                       140000.1-423644140610.9-430531317.15 17.71 6.20  +0.98               G8III              -0.006-0.037      +022                           
+5287 49Pi  HyaCD-2610095 123123182244 519I                  140040.5-261202140622.3-264057323.00 33.25 3.27  +1.12 +1.04 +0.55   K2-III-IIIbFe-0.5  +0.044-0.139 +.049+027V                          
+5288  5The CenCD-35 9260 123139205188 520I'W                140047.7-355241140641.0-362212319.46 24.08 2.06  +1.01 +0.87 +0.53   K0-IIIb            -0.519-0.519 +.065+001          12.0  69.9      *
+5289          CP-62 3941 1231512526163121                   140051.1-624356140814.3-631229311.46-01.62 6.40  +1.02               G8-K0III           +0.025+0.038      +039                           
+5290 95    VirBD-08 3697 123255139736                       140125.4-085011140642.8-091848332.12 49.24 5.46  +0.34 +0.08         F2IV               -0.139+0.011      -036V     120                  
+5291 11Alp DraBD+65  978 123299 16273 521           6546    140140.8+645114140423.3+642233110.52 50.96 3.65  -0.05 -0.08 -0.07   A0III              -0.055+0.018 +.018-013SBO    18                 *
+5292          CP-58 5383 123335241478                       140153.1-584803140856.3-591636312.70  2.12 6.34  +0.05 -0.51         B5IV               -0.010-0.011      -002V      89                 *
+5293          CP-69 2012 1233772571193123  W                140210.6-694951141030.9-701820309.55-08.46 6.05  +1.74 +1.84         K4II               -0.006-0.010      -001           8.5   5.2AB   3 
+5294          CD-42 9065 123445224721      W                140239.1-425943140851.9-432816317.52 17.20 6.17  -0.06               B9V                -0.019-0.028      -002V          6.6  28.6      *
+5295          CP-69 2014 123492252636                       140247.3-691443141101.9-694311309.77-07.91 6.06  +0.18 +0.15         A6IV               -0.035-0.026      -003                           
+5296          CD-50 8294 1235152414913122  W        6565    140300.7-510148140935.0-513017315.12  9.51 6.00  -0.06 -0.27         B9IV               -0.030-0.007      +005SB1O < 39  3.0  64.1      *
+5297          CP-52 7028 123569241496      W                140315.3-525745140954.8-532621314.58  7.65 4.75  +0.94 +0.72 +0.32E  G9-III             -0.146-0.096 +.017-016           9.2  27.4      *
+5298 96    VirBD-09 3865 123630158385      D                140340.8-095139140900.6-102004332.20 48.08 6.47  +1.00 +0.73         G8III              -0.005+0.025      -020V?                        *
+5299          BD+44 2325 123657 449011368I         BY Boo   140355.9+441948140755.8+435116 85.26 67.26 5.27  +1.59 +1.66 +1.66   M4.5:III           +0.011-0.028 +.024-036                          *
+5300 13    BooBD+50 2047 123782 449053124I W       CF Boo   140433.1+495550140817.3+492729 94.58 63.23 5.25  +1.65 +1.92 +1.12   M1.5III            -0.061+0.059 +.020-013V          4.5  79.7      *
+5301          BD-15 3817 123934158401    I         ET Vir   140522.6-154947141050.5-161807329.16 42.49 4.91  +1.72 +2.13 +0.85E  M2IIIa             +0.006-0.006 +.012+018V?                        *
+5302          BD+60 1516 123977 290193126                   140540.1+594841140846.0+592016105.75 55.14 6.46  +1.02 +0.82 +0.52   K0III              -0.123-0.017      +011V?                         
+5303   Eta ApsCP-80  706 1239982586933129                   140539.5-803220141813.8-810028306.43-18.73 4.91  +0.25 +0.11         A2m                -0.031-0.063      -009SB2    43                 *
+5304 12    BooBD+25 2737 123999 83203 522                   140550.2+253355141023.9+250530 30.82 72.18 4.83  +0.54 +0.07 +0.29   F9IV w             -0.022-0.061 +.042+011SB2O   26                 *
+5305  3    UMiBD+75  529 124063  79533125                   140608.9+750403140656.4+743537116.34 41.55 6.45  +0.14 +0.12         A7V                -0.052+0.012      -004                           
+5306          CP-77  940 124099257131                       140622.2-771148141654.9-773950307.57-15.57 6.47  +1.42 +1.42         K2IIp              -0.017+0.009      -010                          *
+5307          BD+02 2783 124115120334                       140626.6+014957141131.2+012144342.99 57.87 6.43  +0.48 +0.04         F7V                -0.125+0.028      -018       30                  
+5308          CP-53 5912 124147241543                       140632.4-531144141316.4-533957314.98  7.28 5.56  +1.44               K5III+B-A          -0.012-0.018 +.009-003                           
+5309          CD-2311551 124162182343                       140644.9-235335141224.5-242151325.54 34.93 6.34  +1.35               K0                 +0.011-0.028      +011V                          
+5310          BD+32 2443 124186 63979                       140653.4+324556141115.1+321744 54.36 71.95 6.11  +1.26 +1.43         K4III              -0.025+0.022      -022                           
+5311          CP-54 5933 124195241552              V716 Cen 140652.2-540922141339.9-543733314.73  6.35 6.11  +0.05 -0.38         B5Ve               -0.019-0.015      +066V                         *
+5312 50    HyaCD-2610158 124206182349    I                  140702.1-264726141246.0-271540324.34 32.21 5.08  +1.16 +1.13         K3III              -0.012-0.034 +.048+027                           
+5313          BD+03 2867 1242241203393127    9152  CU Vir   140712.0+025248141215.8+022434344.43 58.61 5.01  -0.12 -0.42 -0.13   A0VpSi            v-0.042-0.026 +.009-002SB    123  6.5  59.9      *
+5314          CD-2610163 124281182354                       140730.0-260833141313.2-263644324.74 32.77 6.24  +1.08               K0III              +0.009-0.014      -010V                          
+5315 98Kap VirBD-09 3878 124294158427 523I                  140733.6-094830141253.8-101625333.51 47.70 4.19  +1.33 +1.47 +0.75   K2.5IIIFe-0.5      +0.008+0.140 +.022-004     < 19:                *
+5316          CP-56 6206 124367241563      W       V795 Cen 140759.0-563704141457.0-570509314.13  3.96 5.07  -0.08 -0.63 +0.04   B4Vne             v-0.039-0.009      +007V     242  5.8  33.9AB   3*
+5317          BD-00 2796 124425139798              Var      140831.2-002224141340.8-005044341.52 55.74 5.91  +0.47 +0.03         F7V w              +0.207-0.141 +.027+018SBO    30                 *
+5318          CD-41 8589 124433224791                       140831.9-412210141442.6-415015319.14 18.40 5.61  +0.93 +0.58         G8III              -0.133-0.021      -038                           
+5319          CP-52 7087 124454241569                       140836.5-530234141521.2-533035315.33  7.33 6.39  +1.57               K3III              -0.030+0.002      -021                           
+5320          CP-66 2490 124471252678      W                140844.4-660718141638.6-663516311.26-05.10 5.75  -0.06 -0.87         B1.5III            -0.015-0.005      -009V      57  7.1  23.8      *
+5321  4    UMiBD+78  478 124547  7958 524I S                140913.9+780103140850.9+773251117.67 38.78 4.82  +1.36 +1.39 +0.52E  K3III              -0.032+0.034 +.010+006SB1O < 17                 *
+5322          BD-05 3837 124553139806                       140908.7-052858141421.3-055651337.22 51.32 6.36  +0.60 +0.16         F9V                -0.306+0.088 +.023-032                           
+5323 14    BooBD+13 2764 124570100925      S        6597    140916.5+132542141405.2+125734  0.78 66.03 5.54  +0.54 +0.09         F6IV               -0.256-0.052 +.022-039SBO     0                 *
+5324          CD-2810528 124576182374                       140913.7-284853141501.3-291655324.02 30.14 6.08                      A1V                -0.030-0.015      -013                           
+5325          CD-44 9181 124580224798                       140917.6-443150141538.8-450003318.20 15.36 6.31  +0.60               F9V                +0.137-0.142      +003                           
+5326          CP-59 5476 124601241580    I W       R Cen    140921.8-592652141634.2-595450313.42  1.21 6.39  +2.04 +1.24 +1.73   M5IIe             v-0.019-0.018      -020V          6.9  28.0      *
+5327          CP-82  601 124639258697                       140935.1-822316142423.3-825055305.94-20.53 6.42  +0.02 -0.33         B8Ve               +0.001-0.019      +027                           
+5328 17Kap1BooBD+52 1782 124674 29045        9173B          140952.8+521520141327.7+514716 96.46 60.92 6.69  +0.39 -0.04         F1V                +0.054-0.019 +.010-020SB     40  2.2  13.4      *
+5329 17Kap2BooBD+52 1782 124675 29046        9173A Kap2 Boo 140954.0+521527141329.0+514725 96.46 60.91 4.54  +0.20 +0.14 +0.12   A8IV               +0.063-0.002 +.010-017SB    127  2.2  13.4      *
+5330 15    BooBD+10 2654 1246791009343131I W                140956.9+103418141450.8+100602356.00 64.00 5.29  +1.00 +0.77 +0.50   K1III              -0.028-0.167      +017V?   < 19: 2.6   1.1      *
+5331          BD+04 2841 124681120364    I         FS Vir   140950.5+034811141453.0+032010346.51 58.96 6.45  +1.60 +1.72 +1.05E  M4IIIab            -0.045-0.014      -048                          *
+5332          BD-17 4046 124683158448                       140953.3-174403141524.1-181203329.44 40.31 5.43  -0.03 -0.08         A1V                -0.039-0.012      -019V      74                 *
+5333          BD+22 2678 124713 832423130                   141002.9+222024141441.0+215224 21.95 70.38 6.39  +0.18 +0.09         A7V                +0.039-0.006      -004       67                  
+5334          BD+70  778 124730 163053128I          6593    141012.4+695407141204.0+692557112.88 46.09 5.24  +1.58 +1.84         M2IIIab            -0.027-0.047 +.016-023V?                         
+5335          BD+42 2472 124755 44952                       141021.5+415917141423.5+413108 78.52 67.73 6.24  +1.04              gK3                 -0.024-0.105 +.030-010SB                         
+5336   Eps ApsCP-79  755 124771257142                       141016.6-793850142222.7-800632306.93-17.95 5.06  -0.10 -0.57         B4V                -0.025-0.009      +005V     216                 *
+5337          CD-32 9982 1247802053713132                   141023.0-324634141618.3-331429322.67 26.36 6.55  +0.30               F0V                +0.022+0.004      +003                           
+5338 99Iot VirBD-05 3843 124850139824 525I          6604    141046.1-053124141600.9-060002337.75 51.07 4.08  +0.52 +0.04 +0.27   F6III              -0.004-0.432 +.043+012       15                 *
+5339   Del OctCP-83  557 124882258698               6636    141051.6-831235142654.9-834004305.68-21.31 4.32  +1.31 +1.45 +0.49E  K2III              -0.105-0.007      +005                           
+5340 16Alp BooBD+19 2777 124897100944 526I          6603    141106.0+194211141539.7+191057 15.14 69.11-0.04  +1.23 +1.27 +0.65   K1.5IIIFe-0.5     v-1.093-1.998 +.090-005V    < 17                 *
+5341          BD-05 3845 124915139828                       141106.0-060924141621.5-063719337.36 50.49 6.44  +0.28 +0.09         A9III              -0.032-0.016      -034                           
+5342          BD-02 3812 124931139830               6608    141119.1-024351141630.1-031147340.32 53.39 6.15  -0.01 -0.01         A1V                -0.025-0.038      +002       56                  
+5343          BD+19 2779 124953100949              CN Boo   141122.0+192239141604.2+185443 14.49 68.90 5.98  +0.26 +0.05 +0.12   A8III              +0.043-0.028      +004SB?                       *
+5344          BD-17 4053 124990158462                       141131.9-180717141703.8-183507329.69 39.80 6.22  +0.98               G5                 +0.001+0.005      -012V?                         
+5345          BD+53 1699 125019 29059                       141146.6+530003141516.9+523209 97.00 60.16 6.58  +0.10 +0.09         A4V                -0.032-0.004      -015                           
+5346          BD+20 2954 125040 83259        9192           141153.8+203518141632.8+200717 17.70 69.32 6.25  +0.49               F8V                -0.148-0.103D+.031-008V          2.0   4.4       
+5347          BD+40 2760 125111 64040                       141220.1+401230141624.2+394441 73.94 68.33 6.38  +0.36 -0.07         F2IV               -0.147+0.008      -024    =<  6                  
+5348          CD-3210005 125150205412                       141228.6-324525141823.8-331314323.14 26.22 6.54  +0.27               F0V                -0.070-0.042      -029                           
+5349          CP-60 5294 125158252703                       141231.2-604833141951.5-611623313.35-00.20 5.23  +0.29 +0.16 +0.11   Am                 -0.171-0.093 +.034+021       74                 *
+5350 21Iot BooBD+52 1784 125161 29071 528    9198A Iot Boo  141237.4+514942141609.9+512202 95.23 60.96 4.75  +0.20 +0.06 +0.09   A9V                -0.150+0.092 +.048-019SB    137  3.5  38.7AB   3*
+5351 19Lam BooBD+46 1949 125162 44965 527           6611    141234.9+463251141623.0+460518 86.97 64.67 4.18  +0.08 +0.05 +0.03   A0p                -0.187+0.161 +.045-008      110                 *
+5352          BD+15 2690 125180100956    I          6613    141241.5+154334141728.4+151548  6.61 66.76 5.80  +1.71 +2.07 +0.87E  M3IIIa             +0.012+0.011      -010V?                         
+5353          BD-06 3964 125184139856      W                141242.0-070424141800.6-073233337.18 49.49 6.47  +0.73 +0.35         G5IV               +0.254-0.240      -014V?         4.5  57.1      *
+5354   Iot LupCD-45 9084 125238224833               6620    141259.9-453547141924.2-460328318.48 14.14 3.55  -0.18 -0.72 -0.14   B2.5IV             -0.013+0.002      +022      370                 *
+5355          BD-18 3789 1252481584811369          CS Vir   141306.3-181511141838.3-184258330.06 39.52 5.90   0.00 -0.04         A0pCrEu           v-0.059-0.042      -009SBO     9                 *
+5356          CD-2510271 125276182433        9212           141320.3-252150141900.8-254856326.53 33.01 5.87  +0.50 -0.09         F5V                -0.372+0.350 +.051-021V?         5.1  64.0AC   3*
+5357          CD-36 9268 125283205430                       141320.9-363226141923.9-370013321.83 22.62 5.94  +0.08 +0.04         A2Vn               -0.047-0.059      +000                           
+5358          CP-55 5984 125288241641 529                   141320.2-555532142019.5-562312315.05  4.38 4.33  +0.12 -0.43         B6Ib               -0.014-0.009      +004V?     10                 *
+5359100Lam VirBD-12 4018 1253371584891371I:D        6621    141341.8-125439141906.6-132216333.40 44.25 4.52  +0.13 +0.12 +0.06   A2m                -0.015+0.030 +.017-011SB2O   16  0.1   0.0      *
+5360          BD+51 1908 125349 29086                       141347.8+514611141721.1+511826 94.87 60.88 6.20  +0.04               A2IV               -0.025-0.005      -009V      85                  
+5361          BD+36 2468 125351 640531370I                  141346.1+355815141759.8+353034 62.73 69.76 4.81  +1.06 +0.92 +0.53   K0III              +0.004+0.016      -026SB1O < 17                 *
+5362          CD-42 9235 125383224838      W                141352.7-423556142009.7-430332319.69 16.91 5.56  +0.92 +0.60         G8III              -0.010+0.010      -019           2.6   3.5       
+5363          BD+48 2188 125406 44982                       141405.6+482753141749.2+480006 89.83 63.20 6.32  +0.44               F5                 -0.010-0.045      -017       30                  
+5364          CD-44 9236 125442224843                       141419.5-444331142042.5-451114319.01 14.88 4.77  +0.31 +0.06         F0IV               +0.034-0.080 +.020+000SB     33                  
+5365 18    BooBD+13 2782 1254511009751372  W                141425.8+132756141916.3+130015  2.76 65.08 5.41  +0.38 -0.03 +0.19   F5IV               +0.106-0.030      -003V?     39  4.9 156.4      *
+5366102Ups VirBD-01 2938 1254541398663134I          6629    141423.2-014812141932.5-021556342.25 53.74 5.14  +1.02 +0.85 +0.51   G9III              -0.120-0.074 +.018-027V    < 19:                 
+5367   Psi CenCD-37 9336 1254732054531373  W                141428.3-372531142033.4-375307321.72 21.71 4.05  -0.03 -0.11 -0.02   A0IV               -0.063-0.012 +.003-005V     101  9.5  36.0       
+5368          BD+01 2913 125489120400               6630    141434.6+005041141940.9+002303344.97 55.88 6.19  +0.20 +0.09         A7V                -0.041-0.013      -022V     157                  
+5369          BD+39 2749 125538 64064                       141449.1+391337141855.7+384603 70.98 68.36 6.86  +1.06 +0.89         G9IV               -0.001+0.031      -010V?                         
+5370 20    BooBD+16 2637 1255601009803135I          6631    141501.2+164554141945.2+161825  9.59 66.86 4.86  +1.23 +1.40 +0.60   K3III              -0.142+0.060      -008     < 17                 *
+5371          CP-57 6619 125628241673      W                141527.1-580008142237.0-582734314.64  2.33 4.92  +0.86 +0.48         G8III+F5V          -0.052+0.013 +.024+015SB2        2.1   9.2AB   4*
+5372          BD+55 1678 125632 29098                       141536.7+551925141855.8+545151 99.05 58.02 6.53R                     A5Vn               -0.028+0.011      -003      157                  
+5373          BD+39 2750 125642 64072                       141541.3+391513141947.7+384738 70.85 68.19 6.33  +0.05 +0.05 -0.03   A2V                +0.022-0.013      -011V     142                 *
+5374          BD+31 2605 125658 640743136           6633    141546.2+305317142008.7+302545 47.84 70.32 6.44  +0.15 +0.10 +0.05   A5III              -0.010-0.005      +001                           
+5375          CD-47 9082 125721224870      W                141606.3-475146142238.7-481913318.20 11.83 6.09  -0.13 -0.91         B1III              -0.013-0.013      -018V?         3.7   4.2AB   3*
+5376          CD-34 9570 1257452054853137                   141619.9-341947142219.7-344713323.33 24.46 5.56  -0.09               B8V                -0.025+0.001      -037                           
+5377          CD-50 8501 1258102416863138  W                141639.8-501857142320.3-504620317.43  9.50 6.02  +1.36               K2III              -0.005-0.004      -007           3.6   1.3       
+5378          CD-38 9329 125823205497              V761 Cen 141652.4-390318142302.2-393044321.57 20.02 4.42  -0.18 -0.75 -0.17   B7IIIp            v-0.027-0.032      +008        2                 *
+5379          CP-67 2574 125835252735 530                   141648.5-674425142506.3-681143311.48-06.89 5.61  +0.49 +0.01         A3Ib               -0.012-0.003      -022V      34                  
+5380          CP-52 7195 125869241691                       141700.0-524313142348.4-531036316.64  7.22 6.00  +1.10               K1III              -0.071-0.024      +007V                          
+5381 51    HyaCD-27 9803 125932182483    I          6648    141719.9-271742142305.8-274514326.60 30.87 4.77  +1.31 +1.54 +0.67   K4III              -0.193-0.112 +.040+020                          *
+5382          CP-65 2718 125990252737                       141739.5-654307142539.5-661024312.26-05.02 6.36  +0.13 +0.06         A3V                -0.059-0.026      +018                           
+5383  2    LibBD-11 3729 1260351585281374                   141802.6-111526142325.6-114251335.82 45.20 6.21  +0.99               G7III              -0.009-0.058      -001                           
+5384          BD+01 2920 126053120424    I'                 141808.4+014236142315.3+011430347.17 56.02 6.27  +0.63 +0.09 +0.32   G1V                +0.226-0.477 +.061-019V       1                  
+5385          BD+09 2882 126128              9247BC         141827.5+085400142322.6+082642356.56 61.33 6.86  +0.43 -0.01         F0V+F2V            -0.075-0.008 +.016-018SB     71  1.7   6.2AxBC 3*
+5386          BD+09 2882 126129120426        9247A          141827.6+085406142322.7+082648356.56 61.33 5.12  -0.02 -0.07         A0V                -0.075-0.008 +.016-023V      93  1.7   6.2AxBC 3*
+5387          BD+25 2770 126141 833213139           6653    141837.4+254728142306.8+252017 33.14 69.39 6.22  +0.37 -0.02         F5V                -0.155+0.064      -010        8                  
+5388          BD+08 2857 126200120433               6654    141905.0+084154142400.9+081437356.48 61.08 5.95  +0.06 +0.08         A3V                +0.003-0.025      -007       90                 *
+5389          CP-76  826 126209257163                       141902.4-761642142936.8-764345308.60-14.95 6.07  +1.18 +1.11         K0-1III            -0.039-0.026      -008V                          
+5390          CD-2411469 1262181825171376                   141906.1-242109142448.6-244823328.45 33.40 5.32  +0.96 +0.71         G8III              -0.055-0.016 +.024-022V?                         
+5391          CP-65 2732 1262412527453141                   141907.8-652210142707.1-654918312.52-04.75 5.85  +1.50 +1.76         K3III              -0.018-0.013      -020                           
+5392          BD+06 2875 1262481204341375                   141912.7+061625142411.3+054912353.10 59.33 5.10  +0.12 +0.10         A5V                -0.077+0.005 +.023-010SB    194                  
+5393          BD-11 3736 126251158550        9254           141918.2-111256142440.9-114011336.23 45.09 6.49  +0.42 +0.04         F4III              -0.071-0.029D+.012-036V          1.6   1.2      *
+5394          BD+08 2858 126271120436               6655    141923.0+083228142418.3+080506356.35 60.92 6.19  +1.20 +1.29 +0.60   K4III              -0.114-0.092 +.015-031V?                        *
+5395   Tau1LupCD-44 9322 1263412249191377  W       Tau1 Lup 141942.9-444609142608.2-451317319.92 14.50 4.56  -0.15 -0.79 -0.11   B2IV               -0.012-0.013      -022       30  4.7 158.2      *
+5396   Tau2LupCD-44 9323 126354224920      W                141944.8-445538142610.8-452246319.87 14.35 4.35  +0.43 +0.19 +0.35   F4IV+A7:           +0.016-0.008 +.002-001SB1     0  0.1   0.1      *
+5397          BD-19 3880 126367158558        9258A          141954.7-193102142529.8-195811331.22 37.68 6.61  +0.14 +0.11         A2V                -0.039-0.006D+.005-002       74  0.4  35.1AB   3*
+5398          CD-41 8757 126386224923                       141956.5-415155142613.4-421909321.06 17.19 6.32  +1.19               K2III              -0.123-0.071      -033                           
+5399          CD-2610280 126400182535                       142001.3-262355142547.7-265109327.67 31.45 6.48  +0.94               G7IV               -0.019-0.061      +007V                          
+5400          CD-39 8918 126475205561                       142037.6-392521142649.9-395226322.14 19.41 6.35  -0.08               B7IV               -0.019-0.016      +008V                          
+5401          CD-45 9188 126504224929      W                142045.2-454054142712.2-460804319.75 13.59 5.83  +0.31 +0.16 +0.16   A1mA5/7-F2         -0.153-0.082      -026           5.6  30.0      *
+5402          BD+39 2764 126597 641373142                   142124.2+385041142529.2+382335 68.67 67.34 6.27  +1.23 +1.26        gK2                 +0.007-0.013      +025                           
+5403          CP-58 5549 126610241737                       142124.8-584454142843.5-591152315.11  1.35 6.45  +0.14 +0.13         A0II-III           -0.011-0.015      +002V                         *
+5404 23The BooBD+52 1804 126660 29137 531I W        6669    142147.5+521847142511.8+515103 93.84 59.65 4.05  +0.50 +0.01 +0.25   F7V                -0.236-0.397 +.072-011       34  7.0  69.5      *
+5405 22    BooBD+19 2810 1266611010251378                   142148.2+194035142627.4+191337 18.06 66.82 5.39  +0.23 +0.23 +0.10   F0m                -0.071+0.025 +.007-028       29                  
+5406104    VirBD-05 3880 126722139942                       142209.3-054009142724.4-060713341.39 49.45 6.17  +0.09 +0.11         A2IV               -0.071-0.058      -015V?                         
+5407 52    HyaCD-2810712 126769182570 532    9270   6674    142218.9-290232142810.4-292930326.95 28.83 4.97  -0.07 -0.41         B8V                -0.024-0.023      +016V          0.0   0.1AB   4*
+5408          CP-67 2595 126862252767      W                142255.3-671610143116.5-674302312.20-06.66 5.83  +1.00 +0.78         K1III              +0.035-0.066      +078           8.2  35.4       
+5409105Phi VirBD-01 2957 126868139951 533    9273   6675    142302.9-014647142812.1-021341345.22 52.51 4.81  +0.70 +0.21 +0.37   G2IV               -0.139-0.002 +.047-010SB      0  3.9   5.1AB   3*
+5410106    VirBD-06 4009 1269271399573143I                  142325.1-062705142841.7-065402341.13 48.62 5.42  +1.49 +1.76         K5III              -0.019-0.052      -049                           
+5411          BD+41 2504 126943 45058                       142329.9+412826142727.3+410130 74.26 65.88 6.63  +0.37 -0.05         F1IV               -0.056-0.019      -017       75                  
+5412          CD-44 9383 126981224969      W                142341.4-445227143008.6-451918320.55 14.15 5.50  -0.08 -0.27 -0.04C  B8Vn               -0.046-0.040      +010V?    174  6.3  10.5      *
+5413          CD-48 9098 126983224972      W                142341.1-490418143020.9-493109318.95 10.25 5.37  +0.05               A1V+B              -0.052-0.047      +000SB2O    0  6.5  22.1      *
+5414          BD+28 2331 127043 83373        9277B          142407.1+284412142831.5+281721 41.69 68.52 7.62  -0.01  0.00         A1V                +0.028-0.013      -013SB     80  0.5  25.4      *
+5415          BD+28 2332 127067 83374        9277A          142409.0+284416142833.3+281727 41.69 68.51 7.12  -0.03 -0.03         A1V                +0.017+0.008      -012      100  0.5  25.4      *
+5416          BD+36 2495 127065 641613144                   142407.9+363839142816.4+361149 62.79 67.57 6.10R                     K0III              -0.024+0.002      -018                           
+5417          CD-40 8729 127152224982                       142440.4-402400143056.5-405042322.51 18.21 6.39  +1.44               K3III              -0.030+0.003      -016                           
+5418          BD+01 2941 1271671204993145                   142444.5+011628142950.5+004944348.95 54.66 5.94  +0.16 +0.11         A5IV               +0.010+0.002      -009      125                  
+5419          CD-38 9430 1271932056373148                   142459.0-382533143110.8-385211323.38 20.01 5.97  +1.06               K1III              +0.005+0.023      +008                           
+5420 24    BooBD+50 2084 127243 29165                       142509.0+501732142837.8+495041 90.16 60.64 5.59  +0.85 +0.44         G3IV               -0.305-0.046 +.022-006                           
+5421          CP-56 6296 127297241777              V Cen    142522.8-562639143232.9-565316316.44  3.31 6.93  +0.91 +0.60         F5Ia               -0.027-0.012      -022                          *
+5422          BD+32 2482 127304 64178        9288           142532.6+321410142949.7+314728 51.15 68.13 6.06  -0.03 -0.09         A0V s              -0.018+0.004      -009V   =< 41  5.0  25.8AB    *
+5423          BD+42 2508 127334 450753146                   142540.3+421450142936.8+414745 75.46 65.16 6.35  +0.70 +0.21         G5V                +0.162-0.218 +.031-001V   =< 10                  
+5424          BD+05 2886 1273371205043149I W                142545.0+051301143045.4+044620353.97 57.44 6.02  +1.42 +1.67        gK4                 +0.009-0.012      +006V          3.5  55.5      *
+5425   Sig LupCD-49 8831 127381241781                       142552.6-500050143236.9-502725318.93  9.25 4.42  -0.19 -0.84         B2III              -0.043-0.010      -002V?     84                 *
+5426          CP-54 6053 127486241792                       142630.8-543324143332.4-545954317.30  5.00 5.87  +0.48               F6IV-V             -0.095+0.004      -000                           
+5427          CP-52 7301 127501241793      W                142636.6-521415143329.9-524048318.19  7.14 5.87  +1.09               K0III              -0.006-0.031      -042           8.1  20.        
+5428          CD-3011519 127624205681      W                142713.9-301621143309.6-304251327.47 27.27 6.09  +1.03 +0.84         K0III              +0.040-0.015D+.006+010V          3.3   2.5       
+5429 25Rho BooBD+31 2628 127665 64202 534I   9296   6697    142731.2+304837143149.8+302217 47.29 67.80 3.58  +1.30 +1.44 +0.65   K3-III             -0.100+0.119 +.029-014V?   < 17  8.2  42.2       
+5430  5    UMiBD+76  527 127700  80241379I   9286   6687    142743.8+760826142731.5+754146115.39 39.99 4.25  +1.44 +1.70 +0.75   K4-IIIBa0.3        +0.009+0.023 +.019+010V    < 17  7.8  58.8AC   3*
+5431          CD-41 8890 127716225027                       142747.4-413931143408.0-420559322.56 16.83 6.60  +0.06               A2IV               -0.016-0.029      -056V?                         
+5432          CP-59 5642 127724241811                       142749.0-593431143517.2-600057315.57  0.28 6.40  +1.26               K2III              -0.021-0.031      -007                           
+5433          BD+27 2388 127726 83394        9301   6699    142754.6+270710143220.2+264038 37.58 67.54 6.01  +0.22 +0.07         A7Vn               -0.064-0.029 +.011-004      204  0.2   0.2      *
+5434 26    BooBD+22 2715 127739 833953151                   142759.8+224201143232.5+221536 26.51 66.57 5.92  +0.35 +0.07         F2IV               -0.127+0.039      -012V                         *
+5435 27Gam BooBD+38 2565 127762 64203 535I   9300  Gam Boo  142803.0+384444143204.7+381830 67.26 66.17 3.03  +0.19 +0.12 +0.08   A7III              -0.114+0.153 +.025-037V     139  9.5  33.4     3*
+5436          BD+63 1136 127821 164063150                   142823.4+633740143046.1+631108105.61 50.47 6.09  +0.41 -0.04         F4IV               -0.178 0.000      -003       50                  
+5437          BD+60 1547 127929 16411 536                   142859.8+603958143142.8+601332102.58 52.76 6.27  +0.24 +0.14         F0III              -0.049+0.021      -019V?     67                  
+5438          BD-19 3903 127964182676                       142912.9-200002143450.7-202621333.37 36.25 6.50  +0.14               A4V                +0.017+0.002      -000                           
+5439          CD-40 8794 127971225046      W                142911.8-410443143531.5-413102323.05 17.25 5.87  -0.08               B7V                -0.020-0.017      +010V          5.2  26.9      *
+5440   Eta CenCD-41 8917 127972225044 537  I       Eta Cen  142909.3-414307143530.4-420928322.77 16.67 2.31  -0.19 -0.83 -0.20   B1.5Vne           v-0.035-0.035      -000SB    333                 *
+5441          BD+37 2545 127986 64212              CP Boo   142915.0+372403143320.3+365734 63.89 66.37 6.43R                     F8IV w             -0.004-0.057      +002    =< 10                 *
+5442          BD+56 1746 128000 29191    I                  142923.0+555019143230.9+552352 96.99 56.34 5.76  +1.50              gK5                 +0.006-0.015      +003                           
+5443          CP-67 2616 1280202528243156                   142922.4-672916143746.3-675556312.69-07.10 6.04  +0.50 -0.02         F7V                -0.343-0.290 +.051-030                           
+5444          CD-45 9293 128068225054      W        6724    142946.1-454831143619.0-461443321.20 12.87 5.55  +1.48 +1.72 +0.72C  K3III              -0.038+0.019 +.019-060           7.1  40.       *
+5445          BD+33 2474 128093 642213153  W                142956.4+325823143411.7+323204 52.82 67.13 6.33  +0.40 -0.03         F5V                +0.108+0.007      -008       12  5.0  24.7       
+5446          CD-39 9047 128152205744                       143009.1-390935143624.2-393550324.04 18.93 6.13  +1.05               K1III              -0.037-0.018      -031V                          
+5447 28Sig BooBD+30 2536 128167 834161380  W        6717    143019.5+301046143440.8+294442 45.62 67.20 4.46  +0.36 -0.08 +0.19   F2V                +0.189+0.132 +.068+000        3  5.3 237.1AB   3*
+5448          BD+37 2551 128198 64227    I          6718    143033.2+370355143438.5+363733 62.91 66.22 6.03  +1.38              gK5                 -0.029-0.054      -012                           
+5449          CD-39 9050 128207205751                       143027.3-394629143644.2-401242323.84 18.35 5.74  -0.12               B8n                -0.016-0.025      +002                           
+5450          CD-45 9302 128266225062      W                143046.9-454151143720.1-460802321.41 12.90 5.41  +1.01 +0.73 +0.48C  G8III              -0.014-0.020 +.023-016           0.0   0.1AB   3*
+5451          BD+57 1519 128332 292023154                   143114.6+573034143415.9+570355 98.69 54.95 6.48  +0.49 -0.03         F6-8V              +0.217-0.229 +.025-022    =<  6                 *
+5452          BD+50 2095 128333 451213155I         CH Boo   143109.8+494815143439.6+492206 88.15 60.21 5.74  +1.56 +1.88 +0.72E  M1IIIab            -0.045+0.054      -020V?                        *
+5453   Rho LupCD-48 9198 1283452250713158           6733    143109.4-485924143753.2-492533320.13  9.86 4.05  -0.15 -0.56 -0.11   B5V                -0.024-0.031      +008      195                 *
+5454          BD+23 2710 128402 834273157                   143135.6+234108143606.9+231501 29.44 66.05 6.38  +1.06 +0.90         K0                 -0.012+0.027      +007                           
+5455          BD-11 3770 1284291586771381                   143140.5-115249143659.8-121819339.35 42.97 6.20  +0.46 -0.03         F5V                -0.872+0.365 +.034-070V      15                  
+5456          CD-38 9529 128488205786                       143204.9-382134143819.6-384739324.76 19.51 6.02  +1.43               K3III              +0.066-0.023      +028V                          
+5457          CD-46 9469 128582225089                       143237.2-460844143911.0-463503321.52 12.36 6.07  +0.51 +0.03 +0.28C  F7V                -0.182-0.211 +.021-012                           
+5458          CD-48 9218 128617225091                       143242.8-483709143924.7-490320320.52 10.10 6.39  +0.44 +0.01?        F3IV               -0.167-0.132 +.009-017                          *
+5459   Alp1CenCP-60 5483 128620252838 538I W     A          143248.3-602522143935.9-605007315.78-00.71-0.01  +0.71 +0.24 +0.22E  G2V                -3.642+0.699 +.751-022SBO        1.4  20.9AB   3*
+5460   Alp2CenCP-60 5483 128621          I'W     B          143248.3-602522143936.1-605008315.78-00.71 1.33  +0.88 +0.68 +0.30E  K1V                -3.646+0.700 +.751-021V?         1.4  20.9AB   3*
+5461          CP-55 6107 1287132418983162                   143319.1-560033144032.8-562627317.63  3.29 6.30  +1.18               K0-1II             -0.007-0.011      -005                           
+5462          BD+18 2906 1287501011213160                   143334.9+184359143814.0+181754 18.81 63.90 5.91  +1.10 +0.99 +0.56  gK2                 -0.029-0.068 +.038-014                           
+5463   Alp CirCP-64 2977 128898252853 539  W       Alp Cir  143425.2-643223144230.4-645831314.34-04.59 3.19  +0.24 +0.12 +0.10   ApSrEuCr:          -0.192-0.232 +.056+007SB?     0  5.4  15.6      *
+5464          BD+44 2376 128902 45145    I                  143427.1+440424143812.5+433831 77.43 62.89 5.70  +1.48 +1.68 +0.82   K2III              -0.113+0.030      -049V?                         
+5465          CP-58 5672 128917241912                       143429.7-581108144155.7-583658316.91  1.23 6.22  +0.45               F4V                +0.019-0.042      +011                           
+5466          CD-35 9702 128974205823                       143452.7-354218144101.4-360806326.50 21.67 5.67  -0.08 -0.38?        A0p:               -0.022-0.008      -023                           
+5467          BD+54 1693 128998 292273161                   143504.8+542720143815.2+540124 94.17 56.73 5.85  -0.01  0.00         A1V                +0.018-0.016      -003V?     84                  
+5468 33    BooBD+45 2204 129002 45153 540                   143506.9+445010143850.2+442416 78.76 62.42 5.39   0.00 -0.04         A1V                -0.067-0.017 +.012-013SB     79                  
+5469   Alp LupCD-46 9501 129056225128 541  W       Alp Lup  143516.5-465732144155.8-472318321.61 11.44 2.30  -0.20 -0.89 -0.17   B1.5III/Vn         -0.021-0.018      +005SB     24 11.1  27.6      *
+5470   Alp ApsCP-78  893 129078257193 542                   143525.6-783713144751.6-790241308.49-17.45 3.83  +1.43 +1.68 +0.53E  K3IIIa             -0.012-0.015 +.029-001                           
+5471          CD-37 9618 129116205839                       143544.7-372151144157.6-374737325.90 20.10 4.00  -0.17 -0.70 -0.15   B3V                -0.023-0.032      +001V     187                 *
+5472          BD+22 2731 129132 83458      S                143549.3+222415144021.9+215832 27.15 64.75 6.10  +0.40 +0.02         G0V                -0.018+0.034      +001SBO              0.1      *
+5473          BD+14 2769 129153101137                       143555.4+135750144042.4+133203 10.34 61.10 5.91  +0.21 +0.04         F0V                +0.055-0.025      -008       94                 *
+5474          CD-3011624 129161205841      W                143553.2-303015144151.1-305600329.23 26.24 6.37  -0.09               ApSi               -0.031-0.022D+.003-011           0.9   1.0       
+5475 29Pi 1BooBD+17 2768 129174101138        9338A  6762    143601.5+165049144043.6+162506 15.64 62.54 4.94  -0.03 -0.31 -0.02   B9pMnHgSi         v+0.015+0.015 +.002-001SB     22  0.9   5.7AB   3*
+5476 29Pi 2BooBD+17 2768 129175101139        9338B  6763    143602.0+165048144043.9+162504 15.64 62.54 5.88  +0.24:+0.10:        A6V                +0.001+0.010 +.002-007SB    148  0.9   5.7AB   3*
+5477 30Zet BooBD+14 2770 129246101145        9343B  6766    143622.3+140926144108.9+134342 10.80 61.12 4.83H                     A2III              +0.053-0.016 +.009-006           0.1   1.2AB   3*
+5478 30Zet BooBD+14 2770 129247101145        9343A  6766    143622.3+140926144108.9+134342 10.80 61.12 4.43H +0.05 +0.05 -0.01   A2III              +0.053-0.016 +.009-006SB?   156  0.1   1.2AB   3*
+5479          BD+80  448 129245  80543159                   143623.2+800532143338.3+793937117.41 36.35 6.26  +1.30 +1.46         K3III              -0.101+0.081 +.015-023V?                        *
+5480 31    BooBD+08 2903 1293121206013163I          6769    143644.0+083522144138.8+080942  2.05 57.76 4.86  +1.00 +0.76 +0.48   G7+IIIHdel -0.5    -0.009+0.003 +.011-022V    < 17                  
+5481 32    BooBD+12 2729 1293361011521382                   143655.2+120529144143.5+113938  7.46 59.86 5.56  +0.94 +0.67 +0.48   G8III              -0.157-0.114 +.023-023V                         *
+5482          CP-62 4275 129422252869      W                143721.6-622656144517.3-625233315.50-02.81 5.36  +0.29               A9V                +0.063-0.084 +.011-001V?    213  5.5  36.3      *
+5483          BD+21 2674 129430 83474                       143720.4+213308144154.2+210725 25.53 64.15 6.38R                     G8III-IV           -0.010-0.053      -011                          *
+5484  4    LibCD-2411637 129433182795                       143726.6-243417144313.6-245951332.75 31.32 5.73  -0.01 -0.08         B9                v-0.019-0.001      -004V                         *
+5485          CD-34 9868 129456205871 544                   143732.3-344435144339.4-351025327.48 22.29 4.05  +1.35 +1.53 +0.73   K3IIIb            e-0.064-0.180 +.014-038                          *
+5486          CP-57 6772 129462241966                       143729.3-580306144455.5-582840317.32  1.19 6.11  +1.02               K0III              -0.083-0.053      -024                           
+5487107Mu  VirBD-05 3936 129502140090 545                   143747.3-051325144303.6-053930346.55 47.54 3.88  +0.38 -0.02 +0.22   F2III              +0.109-0.316 +.045+005SB     54                 *
+5488          CP-55 6150 129557241971      W       BU Cir   143758.2-551038144510.9-553607318.57  3.78 6.10  -0.06 -0.80         B2III              -0.015-0.013      -006       53  1.4  68.8      *
+5489          CD-34 9888 129685205899                       143851.0-344606144459.2-351131327.73 22.15 4.92  +0.01 -0.03 +0.02   A0V                +0.003-0.004 +.019-005      455                  
+5490 34    BooBD+27 2413 129712 834881383I         W Boo    143901.6+265710144325.4+263140 38.00 65.06 4.81  +1.66 +1.94 +1.22   M3-III             -0.013-0.017 +.002+006V                         *
+5491          CP-87  235 129723258720 920          BP Oct   143858.8-874430152819.1-880759304.24-25.68 6.48  +0.30 +0.10         Am                 -0.091-0.077      -015       89                 *
+5492          BD+61 1451 129798 16466        9357  DL Dra   143933.5+614117144203.2+611543102.09 51.16 6.25  +0.41 -0.01 +0.20   F2V                +0.070-0.030 +.017-006SB     42  2.2   4.1      *
+5493          BD+41 2523 129846 451903166I                  143951.6+405256144344.4+402733 70.09 63.30 5.73  +1.39               K4III              -0.014+0.023      +013SB                         
+5494          CD-46 9562 129858225178                       143947.6-470109144629.1-472628322.30 11.06 5.74  +0.07 +0.08 +0.03C  A1V                -0.022-0.015      -011                           
+5495          CD-51 8457 129893241992 546  W                144001.4-515737144701.3-522301320.20  6.57 5.21  +0.98               G8III              -0.016-0.082 +.021-021           7.8   8.9       
+5496          BD-00 2867 129902140116    I                  144002.8-005942144511.7-012504351.32 50.45 6.07  +1.61 +1.94 +0.85E  M1III              -0.053-0.004      -047                          *
+5497 54    HyaCD-2411661 129926182855        9375A          144012.6-250107144600.1-252635333.13 30.63 4.94  +0.35 +0.10         F2III-IV           -0.150-0.104 +.049-013      161  2.0   8.5      *
+5498          CD-51 8461 129932241995      W                144013.1-514704144712.3-521220320.31  6.72 6.07  +0.09               A1III-IV           -0.025-0.017      -034           5.3  39.1       
+5499          BD-22 3844 1299441828573167                   144022.2-224348144606.8-230911334.50 32.60 5.81  +0.98              gG5                 +0.027-0.058      +007V                          
+5500          CP-66 2645 129954252894      W                144016.2-661025144844.4-663538314.22-06.33 5.91  -0.07 -0.70         B2.5Ve             -0.021-0.025      +019           3.0  60. AB   3*
+5501108    VirBD+01 2972 129956120642                       144024.5+010822144530.2+004302353.72 51.97 5.69  -0.03 -0.07         B9.5V              -0.038-0.007      -020V?     76                  
+5502 35Omi BooBD+17 2780 129972101184    I                  144034.4+172316144514.5+165752 17.74 61.82 4.60  +0.98 +0.75 +0.48   G8.5III            -0.058-0.049 +.045-009     < 17                 *
+5503  5    LibBD-14 4023 129978158788        9376           144026.8-150217144557.8-152735339.48 39.15 6.33  +1.19               K1III              -0.032 0.000      -040           4.7   3.1       
+5504          BD-20 4087 129980182858      W                144030.4-204507144610.9-211034335.73 34.29 6.40  +0.58 +0.15         F7V                -0.062-0.104D+.026-000V?         0.2   0.3      *
+5505 36Eps BooBD+27 2417 129988              9372B          144037.1+272947144459.2+270430 39.38 64.78 5.12H                     A2V                -0.050+0.021 +.016-023SB2   147  2.6   2.8AB   3*
+5506 36Eps BooBD+27 2417 129989 83500    I   9372A          144037.1+272945144459.2+270427 39.38 64.78 2.70H +0.97 +0.73 +0.52   K0-II-III          -0.049+0.021 +.016-017V          2.6   2.8AB   3*
+5507          BD+19 2854 130025101187                       144043.3+191822144520.7+185305 21.51 62.60 6.13  +0.83               K0                 +0.032+0.014      -004                           
+5508          CD-37 9686 130055205937                       144048.6-375205144705.1-381727326.62 19.20 5.94  +1.33               K3III              +0.052-0.090      +041V                         *
+5509          CD-43 9326 130073225183                       144101.9-430812144732.1-433327324.22 14.46 6.30  +1.08 +0.88 +0.49C  G8III              -0.013-0.032      -023                           
+5510          BD+33 2489 130084 643061384I                  144102.6+331243144513.7+324718 52.83 64.79 6.28  +1.58 +1.90         M1IIIb             +0.045-0.072      +030V                          
+5511109    VirBD+02 2862 130109120648 547           6794    144111.5+021851144614.9+015334355.28 52.68 3.72  -0.01 -0.03 -0.02   A0V                -0.114-0.026 +.037-006V?    351                  
+5512          BD+15 2758 1301441012003168I          6796    144123.1+153307144606.0+150755 14.55 60.79 5.63  +1.57 +1.31         M5IIIab            -0.084+0.020      -022                           
+5513          BD-20 4093 130157182873    I                  144132.4-205419144713.7-211929335.89 34.03 6.06  +1.65 +1.98         K5III              -0.013+0.004      -024V                          
+5514 55    HyaCD-2510534 130158182875                       144133.4-251216144722.5-253728333.34 30.32 5.63                      A0IIIp             -0.008-0.016      -018        0                 *
+5515          CP-56 6441 130227242026               6807    144147.6-561447144906.9-564004318.61  2.58 6.23  +1.13 +1.06         K1III              -0.110-0.123      +013                          *
+5516 56    HyaCD-2510537 1302591828821385                   144154.4-254006144744.8-260515333.15 29.87 5.24  +0.94 +0.65         G5III              +0.041-0.007 +.034-001                           
+5517 57    HyaCD-2610519 130274182883                       144206.4-261338144757.5-263847332.88 29.36 5.77  -0.02 -0.09         B9V                -0.013-0.011      +006      183                  
+5518          BD-12 4134 130325158808                       144227.4-122509144754.9-125023341.92 41.05 6.35  +1.10 +0.95         K0III              +0.043-0.085      +033V?                        *
+5519          CD-36 9645 130328205966              V768 Cen 144225.6-361256144838.1-363805327.72 20.53 6.04  +1.54 +1.28 +1.61   M3III              -0.014-0.048      +041                          *
+5520          CP-72 1604 130458257206      W                144313.2-724639145313.7-731124311.56-12.39 5.60  +0.82 +0.42         G7IIIa+F9IV        +0.021+0.033      +038           2.2   2.0      *
+5521          CD-2311916 130529182898    I W                144331.9-235006144918.7-241506334.59 31.28 5.68  +1.30              gK1                 -0.023-0.003      -026           2.9  61.0AB   3 
+5522          BD-00 2886 1305571401523169                   144345.8-002554144854.1-005052353.00 50.25 6.14  -0.04 -0.10         B9VSi:Cr:         v-0.008+0.017      -016       71                  
+5523  7Mu  LibBD-13 3986 130559158821        9396   6816    144350.0-134357144919.1-140856341.30 39.78 5.31  +0.07 -0.05         A1pSrCrEu          -0.061-0.014 +.006-004SB?    26  0.9   1.8AB   5*
+5524          BD+24 2779 130603 83535        9389           144357.2+244655144823.3+242200 33.54 63.58 6.14  +0.48 +0.08         F2-6V              -0.110+0.045D+.010-031       38  1.1   1.9       
+5525   Pi 1OctCP-82  629 1306502587133987                   144413.7-824924150150.8-831340306.84-21.37 5.65  +0.95 +0.75         G8-K0III           +0.016+0.053      +014                           
+5526 58    HyaCD-2710073 130694182911    I                  144424.8-273238145017.3-275737332.65 27.97 4.41  +1.40 +1.49 +0.76   K4III              -0.241-0.059 +.011-010                          *
+5527          CP-63 3436 130701252928      I       AX Cir   144427.3-632348145235.0-634836315.83-04.01 5.87  +0.72 +0.22         G3II+B8V          v-0.024-0.009      -021SB?                       *
+5528   Omi LupCD-43 9391 130807225248      W                144506.5-430941145138.4-433432324.90 14.11 4.32  -0.15 -0.61 -0.11   B5IV               -0.020-0.027      +007SB     84  0.0   0.1      *
+5529          BD+38 2593 130817 643441386                   144511.1+381324144906.7+374840 63.78 63.12 6.16  +0.36 -0.07         F2V                -0.253+0.111 +.021-035V?     12                  
+5530  8Alp1LibBD-15 3965 1308191588361387  W     B          144509.2-153453145041.2-155950340.31 38.07 5.15  +0.41 -0.03 +0.19   F4IV               -0.098-0.066 +.050-023V      22  0.4   0.0 O   3*
+5531  9Alp2LibBD-15 3966 130841158840 548I W     A  6827    144520.7-153734145052.7-160230340.33 38.01 2.75  +0.15 +0.09 +0.04   A3IV               -0.106-0.067 +.058-010SB     84  0.4   0.0 O   3*
+5532          BD+29 2581 130917 835513171  W                144540.0+290148144958.4+283657 43.16 63.83 5.80  +0.05 +0.08         A4V                +0.017+0.003      +001SB    175  4.9 111.2       
+5533 38    BooBD+46 1993 130945 45226                       144544.8+463158144918.7+460658 79.98 59.97 5.74  +0.48  0.00         F7IV w             -0.002-0.076      -005V?     20                 *
+5534          BD+24 2786 130948 835533172                   144547.4+241929145015.8+235443 32.76 63.06 5.85  +0.56 +0.02         G0-2V              +0.143+0.034 +.069-002SB                         
+5535 11    LibBD-01 2991 130952140176    I                  144549.8-015257145101.0-021757352.08 48.82 4.94  +0.98 +0.72 +0.51   G8III-IV           +0.084-0.123 +.016+083V    < 17                  
+5536          BD+00 3253 130970140177    I                  144552.8+000921145100.1-001526354.23 50.31 6.18  +1.40 +1.69         K3III              -0.026+0.015      -020                           
+5537          BD+51 1957 131040 29296        9405           144617.5+514718144932.3+512229 88.43 57.10 6.51  +0.40  0.00         F5IV               +0.012+0.008      -005SB         3.6  15.7AB   3*
+5538 39    BooBD+49 2326 131041 45231        9406           144617.3+490754144941.3+484314 84.29 58.58 5.69  +0.47               F6V+F5V            -0.076+0.096 +.009-032SB2O       0.5   2.9      *
+5539   Zet CirCP-65 2918 131058252951                       144614.1-653452145442.4-655929315.03-06.06 6.09  -0.06 -0.60         B3Vn               -0.022-0.022      -018                           
+5540          CP-76  924 1311092572123175          R Aps    144628.8-761519145752.9-763946310.14-15.60 5.34  +1.45 +1.70         K4III:             -0.074-0.015 +.008-031                          *
+5541          BD+37 2580 131111 64355    I                  144632.7+374056145029.6+371619 62.48 62.99 5.48  +1.02 +0.84 +0.54   K0III-IV           -0.211+0.094 +.026-067V    < 17                 *
+5542          CD-3011780 131117206035                       144635.5-300954145233.1-303437331.67 25.45 6.29  +0.60 +0.13         G1V                -0.329-0.027 +.031-028V?                        *
+5543          CD-37 9760 1311202060373173                   144634.4-372330145251.1-374812327.93 19.11 5.03  -0.16 -0.72         B7IIIp             -0.018-0.021      +006       95                 *
+5544 37Xi  BooBD+19 2870 131156101250    I   9413  Xi  Boo  144646.4+193057145123.3+190604 23.09 61.36 4.55  +0.76 +0.28 +0.43   G8Ve+K4Ve          +0.137-0.098 +.156+003V?      3  2.1   7.2AB   4*
+5545   Pi 2OctCP-82  636 131246258714                       144720.9-823814150446.7-830218307.03-21.25 5.65  +1.30 +1.15         G8Ib               -0.016-0.010      -021                           
+5546          CP-59 5753 1313422421113174                   144751.7-594212145534.6-600651317.82-00.88 5.20  +1.16 +1.15         K2III              -0.125-0.115 +.031-014                           
+5547          CP-76  931 131425257218                       144826.6-764525150011.8-770937310.01-16.09 5.93  +1.05 +0.81         G8II               -0.003+0.004      +002                           
+5548 12    LibCD-2411735 131430182983    I                  144831.5-241400145420.1-243832335.49 30.35 5.30  +1.32 +1.54         K2III              -0.010-0.027 +.041+009V?                         
+5549          CD-3210457 131432206079      W                144831.3-325333145438.0-331802330.61 22.87 5.82  +1.42               K2III               0.000+0.002      -024           4.0  58.1AC   3*
+5550          BD+16 2705 131473101273        9425           144841.9+160647145323.3+154216 17.22 59.51 6.40  +0.57 +0.12         F9V                -0.022+0.009D+.021+021V?         0.5   1.5      *
+5551   The CirCP-62 4337 131492252965      W       The Cir  144840.5-622229145644.0-624651316.71-03.31 5.11   0.00 -0.77 +0.08   B4Vnpe            v-0.011 0.000      +003V     199  0.0   0.1      *
+5552          BD+59 1615 131507 29315 549I                  144854.0+594201145126.4+591738 98.56 51.78 5.46  +1.36 +1.60 +0.70   K4III              -0.122+0.139      +011V?                         
+5553          BD+19 2881 131511101276               6847    144851.4+193319145323.7+190910 23.55 60.93 6.01  +0.83 +0.50 +0.45   K2V                -0.452+0.216 +.087-029SBO                       *
+5554 13Xi 1LibBD-11 3827 131530158887                       144857.0-112925145422.9-115354344.34 40.88 5.80  +0.97 +0.72 +0.34E  G7III              -0.052-0.010      -024V?                        *
+5555          CP-74 1281 131551257219      W                144908.5-743744145956.0-750157311.08-14.23 6.20  -0.04 -0.20         B9V                -0.006-0.014      -003           6.7  30.        
+5556          CP-52 7634 1315622421203176                   144909.9-522413145617.3-524835321.28  5.56 5.38  +0.13               A2III              +0.026+0.005      +007SB    120                  
+5557   Ome OctCP-84  490 131596258717                       144921.9-842339151108.3-844715306.17-22.82 5.91  -0.06 -0.13         B9.5V              -0.008+0.009      -007V                          
+5558          CD-3310169 1316252060991389  W                144936.3-332659145544.7-335121330.53 22.27 5.32  +0.04               A0V                +0.020 0.000 +.007+000SB2   202  7.2  24.3       
+5559          CD-47 9543 131657225306      W                144944.3-472824145632.0-475245323.63  9.90 5.64  -0.04 -0.27 -0.02C  B9V                -0.040-0.020      +015SB         0.8   2.2      *
+5560          CD-50 8939 131705242128                       145000.5-510231145701.4-512649322.01  6.71 6.64  +1.70 +2.04 +1.03E  M2III              -0.076-0.009      +024                           
+5561          CD-38 9785 131752206110                       145013.8-390038145635.8-392458327.79 17.34 6.36  +0.06               A0-1V              -0.026-0.024      -007                           
+5562          CD-3210480 131774206112    I                  145025.2-321352145630.9-323812331.34 23.25 6.06  +1.41               K3III              -0.008-0.028      +012V                          
+5563  7Bet UMiBD+74  595 131873  8102 550I W        6846    145059.5+743351145042.3+740920112.65 40.50 2.08  +1.47 +1.78 +0.76   K4-III             -0.031+0.012 +.039+017V    < 17  9.2 209.1      *
+5564 15Xi 2LibBD-10 3989 1319181589151390I                  145120.4-110022145646.1-112435345.35 40.92 5.46  +1.49 +1.70         K4III              +0.011+0.008      +015V                          
+5565          CD-2811055 131919183030    I:                 145115.5-284512145713.6-290928333.44 26.16 6.29  -0.04 -0.21         B9V                -0.027-0.031      +008                           
+5566          CD-48 9494 1319232253283178                   145116.6-482704145808.8-485147323.40  8.91 6.35  +0.71 +0.28         G3-5V              -0.007-0.333 +.051+037                          *
+5567          BD+15 2796 131951101293 551                   145129.9+145102145613.2+142647 15.69 58.32 5.77  -0.06 -0.08         A0V                -0.013 0.000      -022V?    150                  
+5568          BD-20 4125 1319771830401391I   9446A          145137.4-205749145728.0-212456338.24 32.70 5.74  +1.11 +1.06 +0.56   K4V                +1.045-1.729 +.173+020V          2.3  22.8AB   6*
+5569          BD+32 2531 132029 64408        9442           145150.2+324215145558.7+321801 51.36 62.57 6.12  +0.10 +0.07         A2V                -0.043+0.004      -012V          5.4   4.7      *
+5570 16    LibBD-03 3696 1320521402403177                   145157.6-035621145711.0-042047351.73 46.27 4.49  +0.32 +0.05 +0.17   F0V                -0.094-0.150 +.047+022      117                  
+5571   Bet LupCD-42 9853 132058225335 552                   145158.8-424352145831.9-430802326.25 13.91 2.68  -0.22 -0.87 -0.17   B2III/IV           -0.035-0.039      +000SB    127                 *
+5572          CD-39 9402 132096206154                       145212.9-393012145836.8-395424327.89 16.72 6.15  +1.23 +1.24         K2III              -0.047-0.063      +024                           
+5573          BD+00 3277 1321321207581393I W                145225.5+001407145733.3-001003356.13 49.22 5.53  +1.13 +1.11 +0.55   K1III              +0.062-0.026 +.034+020V?         2.9  86.3      *
+5574          BD+22 2764 132145 835961392                   145233.2+215731145703.6+213319 28.80 60.93 6.49  -0.01 +0.01         A1V                -0.023-0.028      -011    =< 41                  
+5575          BD+16 2715 132146101299                       145231.8+164727145711.7+162318 19.22 59.00 5.71  +0.94              gG5                 +0.005+0.001      -016                           
+5576   Kap CenCD-41 9342 132200225344 553  W        6873    145239.2-414210145909.7-420615326.87 14.75 3.13  -0.20 -0.79 -0.16   B2IV               -0.019-0.024      +008SB     28  8.1   3.9      *
+5577 59    HyaCD-2710148 132219183058        9453           145244.0-271521145839.2-273926334.61 27.28 5.65  +0.24 +0.14 +0.14   A4V+A6V            -0.042-0.010D+.008-010           0.3   0.4      *
+5578 17    LibBD-10 3994 132230158935                       145248.1-104511145813.4-110918345.93 40.90 6.60  +0.01               A1V                -0.011-0.014      -017SB     71                  
+5579          CD-37 9836 1322382061673180                   145254.9-372849145913.9-375253329.05 18.43 6.47  -0.08               B8V                -0.017-0.020      +015V?                        *
+5580          CD-42 9871 132242225351                       145253.4-424533145927.1-430936326.39 13.81 6.10  +0.60 +0.30 +0.32C  F5III              -0.018-0.013      -010                          *
+5581          BD+50 2126 132254 452883179                   145303.8+500215145623.0+493743 84.65 57.17 5.63  +0.50  0.00         F7V                +0.115-0.223 +.027-015V?      6                  
+5582 18    LibBD-10 3999 132345158946        9456           145328.9-104431145853.6-110839346.11 40.80 5.87  +1.26 +1.44 +0.60   K3-IIICN1          -0.101-0.061      -012V          3.8  19.7AB   3*
+5583          BD-04 3783 132375140256        9457           145340.0-043511145852.8-045921351.56 45.51 6.09  +0.50 +0.05         F8V                -0.357-0.097 +.026-029        8  7.2   9.8      *
+5584          BD+05 2954 132525120774    I                  145423.5+045801145923.1+043404  2.14 52.07 5.93  +1.60 +1.90         M2III              +0.005-0.008      -012                           
+5585          CD-37 9863 132604206208                       145452.6-373937150113.0-380330329.31 18.08 5.89  +1.24               K2-3III            +0.013-0.034      +041                           
+5586 19Del LibBD-07 3938 1327421402701394  W       Del Lib  145537.7-080720150058.4-083108348.87 42.51 4.92   0.00 -0.10 +0.01   B9.5V              -0.063-0.005 +.020-039SBO    77  6.4 106.3AC   4*
+5587          CD-3310244 132763206223                       145547.1-335745150158.1-342132331.45 21.19 6.22  +0.24 +0.13 +0.13   A8IV               -0.025-0.020      -003                           
+5588 40    BooBD+39 2820 132772 644493182                   145546.8+393942145936.9+391555 65.66 60.77 5.64  +0.31 +0.03         F0-2IV-III         -0.032+0.042      +012       67                  
+5589          BD+66  878 132813 16558 554I         RR UMi   145559.4+661951145735.0+655557104.87 46.53 4.60  +1.59 +1.59 +1.71   M4.5III            -0.079+0.032 +.010+007SBO                       *
+5590          BD-02 3928 1328331402763183I          6889    145608.0-022130150119.8-024518354.40 46.72 5.52  +1.68 +2.02         M0III              +0.027-0.023      -015V                          
+5591 60    HyaCD-2710183 1328511830993184                   145608.6-273952150206.4-280338335.10 26.53 5.85  +0.16 +0.16 +0.08   A4IV               +0.085-0.029      +008V                          
+5592          BD+22 2772 132879 83616                       145623.3+222629150052.4+220244 30.28 60.22 6.38R                     K0                 +0.010+0.006      -026                           
+5593   Eta CirCP-63 3493 132905253005                       145626.3-633820150448.2-640154316.91-04.84 5.17  +0.93               G8III              +0.099+0.004 +.032+045                           
+5594          BD+00 3297 132933120798    I   9480   6890    145641.6+001518150148.9-000826357.28 48.48 5.71  +1.52 +1.56         M0.5IIb            +0.009-0.024D+.002-034           1.1   0.5AB   3*
+5595          CD-3210560 1329552062393186  W                145651.9-321456150259.3-323836332.60 22.54 5.44  -0.12 -0.61         B3V                -0.015-0.021      +006       19  8.3  36.1      *
+5596          BD+83  431 133002  24591644                   145702.9+825522145020.4+823043118.49 33.56 5.64  +0.68 +0.17         F9V                +0.176-0.222 +.016-043V                          
+5597          BD+47 2192 133029 45326        9477  BX Boo   145714.0+474021150038.7+471640 80.19 57.71 6.37  -0.14 -0.27         B9pSiSrCr          -0.009+0.024      -014V    < 20  3.2  35.6      *
+5598          CP-71 1729 133049257238                       145712.1-713053150708.7-715419313.13-11.77 6.52  +1.59 +1.86         K4III              +0.023-0.015      +009                           
+5599          BD-02 3933 133112140286                       145733.1-023814150244.9-030153354.49 46.28 6.61  +0.20 +0.19 +0.13   A5m                -0.039-0.020      -022       82                 *
+5600 41Ome BooBD+25 2861 133124 836243185I                  145743.6+252412150206.5+250029 36.25 60.66 4.81  +1.50 +1.83 +0.79   K4-IIIabCa0.5      -0.007-0.051 +.025+014V?   < 17                  
+5601110    VirBD+02 2905 1331651208093190I                  145750.8+022902150254.0+020529  0.07 49.79 4.40  +1.04 +0.88 +0.54   K0.5IIIbFe-0.5     -0.054+0.016 +.025-016     < 17                  
+5602 42Bet BooBD+40 2840 133208 45337 555I          6898    145810.7+404706150156.8+402326 67.62 60.04 3.50  +0.97 +0.72 +0.44   G8IIIaBa0.3Fe-0.5  -0.041-0.028 +.037-020V?   < 17                 *
+5603 20Sig LibCD-2411834 133216183139 556I         Sig Lib  145812.9-245320150404.2-251655337.22 28.62 3.29  +1.70 +1.94 +1.29   M3-III            e-0.073-0.043 +.064-004                          *
+5604          CD-40 9243 133220225422              GM Lup   145813.9-402809150442.9-405141328.45 15.32 6.41  +1.46               M6III              -0.015-0.039      -030                          *
+5605   Pi  LupCD-46 9773 133242225426      W                145818.4-463935150507.2-470304325.33  9.93 4.72H -0.14 -0.59 -0.11   B5V                -0.020-0.019D+.009+005SB    161  0.1   1.8      *
+5606   Pi  LupCD-46 9773 133243225426      W                145818.4-463935150507.2-470304325.33  9.93 4.82H                     B5IV               -0.019-0.019D+.009+005SB         0.1   1.8      *
+5607          CD-40 9257 133340225435      W                145849.0-404037150519.1-410402328.44 15.08 5.15  +1.01               G8III              +0.020-0.003 +.019-003           3.7  30. AC   3 
+5608          BD+60 1582 133388 165743188           6899    145906.5+603550150127.1+601216 98.26 50.23 5.93  +0.09 +0.10         A4V                -0.017+0.015      -009                           
+5609          BD+35 2642 133392 644763191           6908    145906.5+353550150306.1+351221 57.21 60.85 5.51  +1.02       +0.49  gG8                 -0.038+0.012      -027                           
+5610          BD+06 2983 133408120822        9493A          145908.5+055304150406.4+052933  4.51 51.74 6.50  +0.31 +0.02         F0V                -0.010-0.041D+.017-008           0.2   9.9       
+5611          CP-64 3095 133456253024               6932    145922.6-645316150756.8-651632316.58-06.09 6.17  +1.47 +1.70         K3III              +0.007-0.009      -004                           
+5612          BD+45 2251 133484 453483192  S                145934.5+450207150306.6+443840 75.33 58.43 6.65  +0.46 +0.04         F6IV               -0.093+0.024      -020       20        0.2       
+5613          BD+35 2644 133485 64484                       145935.2+345727150336.5+343358 55.89 60.82 6.59  +1.02               G8III-IV           -0.002-0.016      -025                           
+5614          CD-2510710 133529183163                       145954.5-252401150547.7-254723337.27 27.98 6.67  -0.01 -0.38         B8V                -0.002-0.020      -032                           
+5615          CD-3510035 133550206292                       145956.9-355233150613.9-361551331.19 19.10 6.27  +1.65               K5III              -0.017+0.008      -037                           
+5616 43Psi BooBD+27 2447 133582 83645 557I                  150009.6+272015150426.7+265651 40.32 60.47 4.54  +1.24 +1.33 +0.65   K2III              -0.174-0.006 +.018-026     < 17                  
+5617          CD-48 9630 133631225456                       150028.2-484207150725.9-490518324.63  7.97 5.77  +0.92               G8III              +0.014+0.017      -012V                          
+5618 44    BooBD+48 2259 133640 45357        9494  i Boo    150029.4+480236150347.4+473916 80.36 57.06 4.76  +0.65 +0.11         F9-G1Vn            -0.407+0.033 +.086-025SB2O=< 16  0.8   0.7      *
+5619          CD-3011960 133652206300                       150029.0-303148150633.3-305508334.30 23.60 5.96  -0.08               A0pSi             v-0.016-0.038      +002       69                 *
+5620          BD-21 4030 133670183176               6931    150040.8-213834150627.1-220155339.86 30.99 6.17  +1.05              gK1                 +0.063-0.058      +005                          *
+5621          CP-66 2725 1336832530313195                   150036.2-664157150929.9-670503315.80-07.73 5.76  +0.69 +0.39         F6II               -0.005-0.001      +009V                          
+5622 21Nu  LibBD-15 4026 1337741590283193I                  150102.8-155209150637.6-161525344.00 35.62 5.20  +1.58 +1.92 +0.88   K5-III             -0.033-0.022 +.020-015                           
+5623          CP-63 3518 133792253034                       150104.8-631528150925.5-633834317.55-04.76 6.28  +0.06               A0pSrCrEu          -0.015-0.018      +012                           
+5624          CD-40 9305 1338802254743194          HR Lup   150142.8-401152150812.1-403502329.18 15.22 5.79  -0.14 -0.40         B8IVSi             -0.030-0.032      +003V                         *
+5625          CD-4210050 133937225479                       150202.8-422858150839.1-425204328.04 13.22 5.85  -0.11 -0.45 -0.13   B7V                -0.027-0.018      +001SB    317                 *
+5626   Lam LupCD-44 9889 133955225483      W                150206.3-445342150850.6-451647326.80 11.13 4.05  -0.18 -0.68 -0.15   B3V                -0.016-0.019D+.012+010SB    166  0.2   0.4      *
+5627 47    BooBD+48 2262 133962 453701395    9500   6934    150207.1+483214150525.8+480904 80.95 56.60 5.57   0.00 -0.07         A1V                -0.066+0.031 +.026-013       59  7.7   6.2      *
+5628          CP-72 1714 133981257247                       150216.1-722321151233.8-724613313.03-12.73 6.01   0.00 -0.24         B8-9III            -0.024-0.007      -013                           
+5629          BD+66  887 133994 16587                       150226.3+661829150357.8+655511104.18 46.09 6.13R                     A2V s              +0.023-0.007      -005                           
+5630          BD+37 2608 134044 64503                       150240.0+365026150635.1+362720 59.53 59.98 6.35  +0.52 +0.03         F8V                -0.063+0.028      -005V?  =<  6                  
+5631          BD+06 3001 1340471208523196                   150242.6+055300150740.3+052953  5.39 51.04 6.16  +0.94 +0.71         K0III              -0.003-0.017      +003SB                         
+5632          CP-60 5656 134060253043                       150242.8-610224151044.6-612521318.81-02.92 6.30  +0.63 +0.16         G2V                -0.198-0.021      +038                           
+5633          BD+19 2924 134064101379        9505           150245.2+184941150720.4+182630 24.65 57.61 6.02  +0.06 +0.06         A3V                +0.043-0.055D+.015-006SB    165  0.1   0.1      *
+5634 45    BooBD+25 2873 134083 836711396  W        6945    150254.5+251531150718.1+245209 36.45 59.48 4.93  +0.43 -0.02 +0.21   F5V                +0.185-0.165 +.064-007V      45  4.9 244.1AC   3*
+5635          BD+55 1730 134190 294071397I                  150325.3+545628150616.7+543323 90.43 53.21 5.25  +0.96 +0.64 +0.49   G7.5IIIFe-1        +0.048+0.015 +.029+016V?   < 19:                 
+5636          CD-3810020 134255206352                       150342.4-382437151007.5-384733330.48 16.55 5.98                      G8III              -0.006-0.023      -035                           
+5637          CP-54 6367 1342702422873198  W                150348.5-545755151116.0-552046321.96  2.27 5.54  +1.14 +0.73         G2Ib-II            -0.002-0.008      -004           6.7  11.2      *
+5638 46    BooBD+26 2656 134320 83682    I                  150404.7+264104150823.8+261804 39.31 59.50 5.67  +1.24 +1.26 +0.61  gK2                 +0.005-0.014      +021SB                         
+5639          BD+13 2901 134323101403                       150409.6+133656150853.4+131406 16.44 55.04 6.10  +0.96 +0.62        dG6                 -0.056+0.064      -049V?                         
+5640          BD+25 2876 134335 83685      W                150414.1+252928150835.5+250631 37.03 59.24 5.81  +1.24               K1III              -0.008-0.001      -016V?         4.1  57.5       
+5641          CD-2510758 134373183237                       150423.6-255705151018.6-261958337.87 26.96 5.76  +1.05               K0III              -0.032-0.010      -033V?                         
+5642          CD-44 9922 134444225517      W     AB         150449.4-445354151134.9-451639327.22 10.88 6.44  +1.04 +0.85         K1III              -0.009+0.014      -004           0.9  32.5AC   3*
+5643          CD-44 9921 134443225516      W     C          150446.1-445354151131.9-451646327.21 10.89 7.39  +1.08 +0.95         K0III              +0.025-0.055      +021V          0.9  32.5AC   3*
+5644          CP-69 2267 134453253062    I         X TrA    150443.1-694208151419.1-700446314.60-10.52 5.81  +3.38 +6.69         C5,5               -0.001-0.006      -004                          *
+5645          CP-61 4856 134468253059                       150452.6-612156151301.0-614438318.87-03.34 6.32  +1.90               K4Ib               -0.010-0.008      -031V                          
+5646   Kap1LupCD-48 9704 1344812255251398  W                150458.8-482127151156.1-484416325.46  7.89 3.87  -0.05 -0.13 -0.01   B9.5Vne            -0.095-0.049      -006V     202  1.9  26.6      *
+5647   Kap2LupCD-48 9705 134482225526      W                150500.4-482149151157.6-484437325.46  7.88 5.69  +0.14 +0.09         A3IV               -0.103-0.040      +000      186  1.9  26.6      *
+5648          BD+50 2146 134493 294203197                   150509.1+502615150819.5+500318 83.57 55.29 6.39  +1.03               K0III              -0.004-0.018      -029                           
+5649   Zet LupCD-51 8830 134505242304 558I W                150505.8-514307151217.1-520557323.76  4.98 3.41  +0.92 +0.66         G8III              -0.112-0.073 +.043-010           3.6  71.9      *
+5650          CD-47 9779 134597225533                       150534.9-475024151231.3-481307325.81  8.29 6.33  +1.12               K2III              -0.014-0.028      -043                           
+5651          CD-44 9932 134687225539              Var?     150606.4-440722151249.5-443002327.83 11.43 4.82  -0.17 -0.68 -0.16   B3IV               -0.034-0.028      +014SB1O   16                 *
+5652 24Iot1LibBD-19 4047 134759159090 559    9532   6981    150631.1-192448151213.3-194730342.69 32.00 4.54  -0.08 -0.35 -0.09   A0pSi             v-0.036-0.039 +.030-012SB2O   54  0.6   0.1AP   4*
+5653          CD-3510119 134837206418                       150649.1-354252151307.4-360529332.53 18.51 6.10  -0.08               B8V                -0.043-0.021      -003                           
+5654          BD+19 2935 1349431014293199I W       FL Ser   150731.2+192108151204.3+185833 26.32 56.76 5.89  +1.53               M4IIIab            -0.017+0.005 +.006-035           1.9   0.5      *
+5655          CD-2312133 134946183269      D                150726.6-233756151317.5-240030340.01 28.47 6.47  -0.04 -0.41         B9                 -0.011-0.020      +003           0.0   0.0      *
+5656 25Iot2LibBD-19 4055 134967159105                       150737.3-191616151319.2-193851343.03 31.96 6.08  +0.12               A3Vn               -0.051-0.037      -004SB                         
+5657 23    LibCD-2411928 134987183275                       150737.9-245556151328.7-251833339.19 27.38 6.45  +0.70               G4V                -0.398-0.071 +.034+003V?                         
+5658          CD-2510801 135051183285        9538           150757.7-254908151353.3-261137338.69 26.61 5.84  +1.14              gG5                 -0.015 0.000      -028V?         4.5   1.8       
+5659          BD+19 2939 135101101437        9535A          150815.2+193911151243.5+191709 26.94 56.71 6.68  +0.68 +0.25 +0.33   G5V                -0.590+0.290 +.024-037V?         0.8  23.7      *
+5660  1    LupCD-3111813 1351532064451399                   150829.6-310845151437.3-313109335.50 22.15 4.91  +0.37 +0.28 +0.31   F1II               -0.005+0.001 +.014-023        0                  
+5661          CP-60 5698 135160253082      W                150831.8-603156151636.4-605414319.68-02.84 5.73  -0.08 -0.89         B0.5Ve            v-0.026 0.000      +006      196  2.9   1.2AB   3*
+5662 26    LibBD-17 4285 135230159122                       150855.0-172342151433.7-174607344.68 33.26 6.17  -0.05 -0.26         B9.5III            -0.022-0.014      -026V?                         
+5663          CD-47 9824 135235225590      W                150856.1-474205151553.8-480427326.37  8.11 5.95  +0.21 +0.11         A3m                +0.018-0.032      -009           4.2  13.3       
+5664   Del CirCP-60 5701 135240253084      W        6998    150851.4-603510151656.7-605727319.69-02.91 5.09  -0.06 -0.92         O8.5V              -0.019-0.009      +009SBO   189  8.3  50.       *
+5665          BD+23 2789 135263 837233201                   150906.5+232116151331.9+225900 33.56 57.66 6.30  +0.06 +0.06         A2V                +0.049+0.093      -005                           
+5666   Eps CirCP-63 3544 1352912530883205                   150911.8-631426151738.9-633638318.35-05.20 4.86  +1.25 +1.32 +0.27E  K2.5III            +0.001+0.008 +.004-005                           
+5667          CD-41 9682 135345225600      I                150929.1-410711151604.0-412928329.98 13.66 5.16  +0.58 +0.10?        G5Ia+B             -0.005-0.006 -.003-027                          *
+5668          CD-43 9749 135348225602                       150929.2-430649151610.5-432905328.90 11.97 6.04  -0.14 -0.63         B3IV               -0.007+0.003      -021                           
+5669          BD-04 3840 135367140408    I                  150934.1-050750151450.7-053010355.07 42.40 6.28  +1.47 +1.81         K2                 -0.018+0.005      -027                           
+5670   Bet CirCP-58 5875 135379242384 561                   150940.9-582540151730.8-584804320.89-01.12 4.07  +0.09 +0.09         A3V                -0.100-0.137 +.053+010       59                  
+5671   Gam TrACP-68 2383 135382253097 560           7008    150934.1-681836151854.6-684046315.71-09.55 2.89   0.00 -0.02         A1V                -0.072-0.031 +.010-003V     214                  
+5672          BD+68  823 135384 16630                       150940.4+680926151044.1+674653105.37 44.30 6.17R                     A8Vn               +0.001 0.000      -008V     200                  
+5673          BD+38 2629 135402 645723202                   150947.0+383820151335.6+381553 62.59 58.32 6.20  +1.20              gK2                 -0.010-0.047      -062V?                         
+5674          BD+32 2561 135438 64574    I W                151000.3+320940151406.1+314717 50.19 58.74 5.99  +1.52               K5                 +0.043-0.018      +004           1.5 122.1       
+5675  3    SerBD+05 2985 135482120916 562I                  151013.0+051838151511.4+045622  6.46 49.21 5.33  +1.09 +0.91 +0.58   K0III              -0.018+0.005 +.021-034                           
+5676 48Chi BooBD+29 2640 135502 837293204                   151018.2+293207151429.2+290951 45.16 58.52 5.26  +0.03 +0.08         A2V                -0.066+0.030 +.026-016V?    101                  
+5677          BD+42 2577 135530 45445    I                  151033.4+423238151410.3+421017 69.70 57.34 6.13  +1.66 +1.93 +0.92E  M2IIIa             +0.019-0.014      -007V?                         
+5678          BD-21 4065 1355341833283206I                  151035.0-220146151623.0-222358341.76 29.34 5.50  +1.38 +1.48         K5III              -0.034+0.003      -005V                          
+5679  4    SerBD+00 3327 135559120920                       151043.4+004432151549.1+002220  1.32 46.23 5.63  +0.18 +0.09         A4V                -0.107+0.015 +.020-012V     117                  
+5680          CP-60 5720 135591253101      W                151045.7-600743151848.9-602947320.13-02.64 5.46  -0.10 -0.90?        O7.5III((f))       -0.027-0.002      -003V     121  5.5  44.5AC   3*
+5681 49Del BooBD+33 2561 135722 64589 563I   9559A  7002    151128.2+334116151530.2+331853 53.12 58.43 3.47  +0.95 +0.66 +0.51   G8IIIFe-1          +0.086-0.112 +.030-012SB   < 19: 4.4 104.9      *
+5682          CD-40 9481 135730225631                       151134.8-404137151809.4-410339330.56 13.81 6.28  +0.18 +0.14 +0.08   Am                 +0.028+0.007      -006V                          
+5683   Mu  LupCD-47 9860 135734225638      W     AB         151134.4-473025151832.0-475230326.86  8.05 4.27  -0.08 -0.37 -0.04   B8Ve               -0.026-0.038D+.013+015      308: 0.1   1.3AB   3*
+5684          CP-67 2836 135737253115      W                151132.1-670657152040.7-672853316.51-08.63 6.28  -0.09 -0.61         B3V                -0.003-0.008      -004V          1.9   0.8      *
+5685 27Bet LibBD-08 3935 135742140430 564I          7009    151137.4-090050151700.4-092259352.02 39.23 2.61  -0.11 -0.36 -0.10   B8V                -0.096-0.019 -.003-035SB    230                 *
+5686  2    LupCD-2911630 1357581833463207I          7012    151144.6-294651151749.9-300856336.96 22.88 4.34  +1.10 +1.07 +0.56   G9IIIaFe1          -0.008-0.010 +.018-004V?                        *
+5687          CD-40 9496 135876225647              GG Lup   151222.8-402518151856.4-404718330.85 13.95 5.59  -0.10 -0.46         B7V                -0.014-0.024      +011SB2   150                 *
+5688          CD-3012117 135896206509      W                151233.4-305035151841.3-311234336.46 21.91 6.18  +1.23               G6-8III            -0.006-0.008      -024           7.9  21.5       
+5689          CD-3610062 136014206523                       151309.1-364342151931.6-370548333.07 16.96 6.20  +0.96 +0.64         G6III-IV           -0.092-0.124      +011                           
+5690          BD+00 3337 136028140444    I                  151318.3-000545151826.2-002741  1.02 45.19 5.89  +1.51 +1.82         K5III              +0.006-0.007      -013V?                         
+5691          BD+67  876 136064 16660 565                   151329.3+674335151438.3+672048104.58 44.33 5.13  +0.53 +0.08         F9IV               +0.221-0.390 +.046-047    =<  6                  
+5692          BD+21 2755 136138 837551400                   151355.4+205618151824.5+203422 29.93 55.89 5.70  +0.97               G8IIIaBa0.3        -0.012-0.020      -008V?                         
+5693          BD+69  789 136174 16662                       151407.0+691849151451.9+685643106.15 43.21 6.51R                     A1Vn               +0.024-0.009      -011      151                  
+5694  5    SerBD+02 2944 136202120946        9584  MQ Ser   151412.4+020837151918.8+014555  3.68 46.46 5.06  +0.54 +0.06 +0.27   F8III-IV           +0.374-0.514 +.037+054V       2  4.6  11.2AB   4*
+5695   Del LupCD-40 9538 1362982256911402          Del Lup  151448.3-401707152122.3-403851331.32 13.82 3.22  -0.22 -0.89 -0.22   B1.5IV             -0.015-0.026      +000V?    221                 *
+5696          CD-40 9539 136334225695                       151500.9-402316152135.3-404459331.30 13.71 6.20  +0.07               A1V                -0.010-0.032      -004                           
+5697          CD-3710171 136347206543      W                151503.2-375125152130.1-381309332.75 15.81 6.48  -0.06 -0.30         A0pSi              -0.013-0.041      +007           2.6   5.7      *
+5698   Nu 1LupCD-47 9922 1363512257033211                   151510.1-473349152208.3-475540327.34  7.67 5.00  +0.50 +0.04?        F8V                -0.140-0.137 +.032-011        0                  
+5699   Nu 2LupCD-47 9919 136352225697                       151503.4-475657152148.2-481904327.10  7.37 5.65  +0.65 +0.05 +0.22E  G3-5V              -1.617-0.277 +.066-069                           
+5700          CP-60 5760 136359253136                       151504.0-601749152310.4-603925320.49-03.07 5.67  +0.48  0.00         F7V                -0.090-0.020      +006                           
+5701 28    LibBD-17 4312 136366159187                       151513.3-174743152053.7-180931345.78 32.01 6.17  +1.02 +0.73 +0.37E  G8III              -0.011-0.061      +003V?                        *
+5702          BD+33 2574 136403 64630                       151528.0+325238151930.2+323055 51.58 57.60 6.32  +0.24 +0.09 +0.08   A2m                -0.015+0.016      -025SBO    18                 *
+5703 29Omi LibBD-15 4083 136407159191      W                151525.8-151116152101.4-153254347.81 33.98 6.30  +0.41 +0.05         F0III              +0.024+0.026      +005V      82  2.2  44.4       
+5704   Gam CirCP-58 5908 136415242463      W                151524.5-585738152322.7-591915321.25-01.96 4.51  +0.19 -0.35         B5IV+F8            -0.016-0.038D+.010-017      278  0.3   0.9      *
+5705   Phi1LupCD-3510236 136422206552 566I W                151527.5-355355152148.4-361541333.96 17.39 3.56  +1.54 +1.88 +0.87   K5III             e-0.089-0.084 +.014-029          10.9  17.3AC   3*
+5706          BD-01 3047 136442140473                       151537.4-020250152047.1-022448359.53 43.45 6.35  +1.06 +1.07         K0V                -0.253-0.177 +.033-047V?                         
+5707          BD-05 4057 1364791404743209  W                151550.5-052750152107.6-054929356.23 41.06 5.54  +1.04 +1.00         K1III              -0.050-0.008      -033V          7.1  12.2       
+5708   Eps LupCD-4410066 136504225712      W       Var?     151553.3-441947152240.9-444122329.23 10.32 3.37  -0.18 -0.75 -0.16   B2IV-V             -0.019-0.013D+.009+008SB2O  133  1.5   0.4AB   3*
+5709  1Omi CrBBD+30 2647 136512 83768      W        7032    151600.2+295844152008.5+293658 46.21 57.33 5.51  +1.02 +0.77 +0.53   K0III              -0.120-0.047 +.001-053V?         3.9 147.3       
+5710  6    SerBD+01 3067 136514120955    I   9596   7037    151556.4+010444152102.0+004255  2.90 45.45 5.35  +1.19 +1.22 +0.60   K3III              -0.042-0.106 +.007+009V    < 17  4.0   3.1      *
+5711          BD+25 2902 136643 83778                       151647.5+251906152106.9+245728 37.83 56.43 6.39  +1.23               K0                 -0.026-0.026      -002                           
+5712   Phi2LupCD-3610103 1366642065801403                   151645.8-363000152309.4-365131333.84 16.75 4.54  -0.15 -0.63 -0.14   B4V                -0.018-0.023      +002      194                 *
+5713          CP-67 2864 136672253155      W        7058    151648.6-675715152614.7-681833316.49-09.61 5.89  +1.02 +0.77         G8-K0III           +0.121+0.011      +025           6.0  50.        
+5714 11    UMiBD+72  678 136726  8207    I                  151710.2+721112151705.9+714926108.72 41.04 5.02  +1.37 +1.60         K4III              +0.007+0.011 +.015-016     < 17                 *
+5715          BD+52 1869 136729 294873210  S                151708.6+521907152005.2+515731 84.96 52.77 5.66  +0.11 +0.11         A4V                +0.014+0.012      +008V     181        0.2       
+5716          BD+44 2453 136751 45497                       151714.5+444749152041.6+442603 73.01 55.55 6.19  +0.39 +0.04         F3-4IV s           +0.027-0.106      -000                          *
+5717  7    SerBD+13 2928 1368311015083213                   151739.0+125532152223.2+123403 18.09 51.83 6.28  -0.02 -0.03         A0V                -0.004-0.004      +004V?     72                  
+5718 50    BooBD+33 2581 136849 64656                       151748.3+331730152148.6+325602 52.36 57.12 5.37  -0.07 -0.21         B9Vn               -0.051+0.017 +.005-007SB    260                  
+5719   Ups LupCD-39 9827 136933206597      W                151812.9-392113152444.9-394237332.42 14.23 5.37  -0.11               A0pSi             v-0.037-0.047 +.008-008        0  5.5   1.4      *
+5720          BD-11 3940 1369561592273214                   151822.9-120045152352.2-122210351.02 35.90 5.72  +1.04              gG6                 -0.038-0.039      -026V?                        *
+5721  8    SerBD-00 2961 1370061405021406                   151834.3-003957152343.7-010121  1.64 43.82 6.12  +0.25 +0.07 +0.12   F0V                +0.076-0.030      -002V     105                 *
+5722          CD-3710225 137015206607      W                151838.7-374852152506.6-381010333.39 15.45 7.03  +0.09               A2V                -0.010-0.029      +003           0.0   0.2       
+5723 31Eps LibBD-09 4138 137052159234                       151846.5-095746152411.9-101920352.84 37.34 4.94  +0.44 +0.02         F5IV               -0.067-0.154 +.035-010SB1O    0                 *
+5724          CD-3810289 137058206616      W                151851.0-382245152520.2-384401333.09 14.96 4.60   0.00 -0.06         A0IV               -0.052-0.016 +.012-003      231  4.0  92.4AxBC 5 
+5725          CP-64 3178 1370662531743217                   151850.2-641044152733.1-643153318.75-06.57 5.71  +1.64 +1.98         K5-M0III           -0.015-0.019      -009                           
+5726          BD+40 2877 137071 64667    I                  151855.4+395618152237.4+393453 64.43 56.36 5.50  +1.59              gK4                 +0.002-0.015      -012                           
+5727  2Eta CrBBD+30 2653 137107 64673        9617A  7054    151904.3+303856152312.3+301716 47.54 56.73 5.58H +0.58 +0.04 +0.28   G0V                +0.138-0.187 +.061-007SBO     3  0.3   0.5AB   4*
+5728  2Eta CrBBD+30 2653 137108              9617B  7054    151904.3+303856152312.3+301716 47.54 56.73 6.08H                     G3V                +0.137-0.187 +.061-007           0.3   0.5AB   4*
+5729   Rho OctCP-84  510 1373332587311666                   152012.0-840755154316.8-842755307.02-23.02 5.57  +0.11 +0.08         A2V                +0.131+0.097      -011      123                  
+5730   Kap1ApsCP-72 1802 137387257289 567  W       Kap1 Aps 152036.6-730233153130.8-732322313.85-14.01 5.49  -0.12 -0.77 -0.02   B3IVe             v-0.006-0.013      +062V     300v 6.9  27.0      *
+5731          BD+62 1410 137389 16712              Var?     152045.3+622410152237.3+620250 97.98 47.09 5.98  -0.03 -0.10         A0pSi              +0.010-0.034      -024                          *
+5732          BD+45 2284 137390 455213216                   152042.7+453728152405.1+451616 74.08 54.73 6.01  +1.20 +1.23         K2III              -0.014+0.008      -010                           
+5733 51Mu 1BooBD+37 2636 137391 64686 568    9626A  7063    152042.7+374340152429.4+372238 60.39 56.31 4.31  +0.31 +0.07 +0.15   F2IVa              -0.146+0.087 +.039-013SB     84  2.2 108.9AxBC 3*
+5734 51Mu 2BooBD+37 2637 137392 64687        9626BC         152044.1+374153152430.9+372052 60.34 56.31 6.50  +0.59 +0.13         G1V                -0.144+0.094 +.039-009V?  =< 25  2.2 108.9AxBC 3*
+5735 13Gam UMiBD+72  679 137422  8220 569I         Gam UMi  152052.9+721123152043.7+715002108.46 40.84 3.05  +0.05 +0.12 +0.06   A3II-III          v-0.019+0.020 +.003-004V     171                 *
+5736          CD-3610161 137432206660      W                152053.7-362500152718.2-364604334.60 16.34 5.45  -0.15 -0.59 -0.17   B4Vp               -0.012-0.035      +004V     134  7.0  30. AC   3*
+5737          BD+63 1192 137443 167133215I                  152058.1+634154152238.4+632029 99.48 46.30 5.79  +1.27              gK4                 -0.013-0.091 +.005-046V?                         
+5738          CD-51 9132 137465242569      W                152109.3-511456152827.2-513551326.14  4.06 6.10  +1.09 +0.76         G2II               -0.007+0.005      -016           6.3  13.3       
+5739  9Tau1SerBD+15 2858 137471101545 570I          7074    152109.0+154647152547.4+152541 22.86 52.36 5.17  +1.66 +1.95 +1.04   M1III              -0.013-0.007 +.013-020V?                         
+5740          BD+19 2966 137510101548                       152123.3+194955152553.3+192851 29.13 53.87 6.27  +0.60 +0.20         G0IV-V             -0.057-0.006      -003    =< 10                 *
+5741          BD+34 2645 137704 647013218I                  152222.4+344103152617.4+342009 54.89 56.16 5.46  +1.40 +1.64 +0.77   K4III              -0.114+0.056      -048                          *
+5742          CD-4610100 1377092258253220                   152226.5-462309152924.3-464358329.05  7.97 5.24  +1.74               K4III              -0.010-0.006 +.005-028                           
+5743 32Zet1LibBD-16 4089 1377441592801407I                  152236.9-162204152815.4-164259348.46 31.96 5.64  +1.55 +1.84         K5III              +0.017-0.032      -021V?                        *
+5744 12Iot DraBD+59 1654 137759 29520 571I W        7077    152242.2+591859152455.8+585758 93.97 48.63 3.29  +1.16 +1.22 +0.60   K2III              -0.009+0.017 +.040-011     < 17  5.7 254.6      *
+5745          BD+25 2916 137853 838303219I                  152320.7+252659152738.9+250606 38.63 55.02 6.02  +1.62              gM1                 +0.007-0.014      -007                           
+5746 10    SerBD+02 2965 1378981210203221                   152335.1+021122152838.2+015032  5.82 44.67 5.17  +0.23 +0.10         A8IV               -0.083-0.029 +.031-010SB    129                  
+5747  3Bet CrBBD+29 2670 137909 83831 572  W       Bet CrB  152342.3+292701152749.7+290621 45.59 55.61 3.68  +0.28 +0.11 +0.05   F0p               v-0.179+0.086 +.032-019SBO    19  1.5   0.3      *
+5748          BD+54 1747 137928 29527                       152349.1+542207152632.5+540112 87.20 50.95 6.45  +0.05               A2IV               +0.048-0.019      -005                           
+5749          BD-20 4246 138105183533               7114    152449.3-202304153036.3-204342345.90 28.57 6.22  +0.17 +0.08 +0.06   A5m                +0.014-0.019      -011       30                  
+5750 34Zet3LibBD-16 4099 138137159307                       152501.8-161559153040.4-163634349.05 31.66 5.82  +1.06              gG6                 +0.018+0.001      -002V?                         
+5751          CD-3810425 138204206736                       152533.4-381646153204.4-383723334.26 14.29 6.25  +0.20               A7V                -0.026-0.089      -001                           
+5752          BD+47 2227 138213 45562                       152531.3+473245152844.5+471205 76.76 53.35 6.15  +0.10 +0.12 +0.04   AmA3-F0V:          -0.015-0.002      -016SBO    30                 *
+5753          CD-3210868 1382212067343223                   152535.1-323221153150.3-325252337.81 18.91 6.46  +0.09               B7V                -0.012-0.024      +005V?                         
+5754          BD+62 1414 138245 16740                       152554.0+623717152740.8+621632 97.74 46.48 6.50  +0.14 +0.04         A5IV               +0.033-0.024      -005V                          
+5755          BD+61 1509 138265 16741    I                  152552.3+610055152751.4+604013 95.79 47.38 5.90  +1.44 +1.64         K5III              -0.019-0.002      -047SB                         
+5756          BD-19 4128 138268159317        9681A          152558.1-194922153143.4-200953346.54 28.82 6.22  +0.22 +0.14         A8V                -0.075-0.028      -040SB    225  0.0   0.0 O   4*
+5757          CP-77 1134 1382892573033228                   152600.9-773450153918.3-775505311.39-17.90 6.18  +1.20 +1.36         K2IIICN0.5Ba-1     -0.085-0.123      +013                           
+5758          BD+09 3055 1382901210381408                   152604.0+085516153055.4+083445 14.34 48.02 6.57  +0.37 -0.03         F4V w              +0.034-0.003      -001       23                  
+5759          BD+55 1756 138338 295403222                   152621.8+553215152856.8+551142 88.57 50.09 6.43  +0.08 +0.09 +0.02   A3m                -0.007+0.036      -007       40                  
+5760          BD+31 2742 138341 64736                       152620.0+313743153022.7+311710 49.50 55.25 6.46  +0.19 +0.14 +0.11   A4IV               -0.024-0.012      -004                           
+5761          BD+37 2651 138383 64741                       152640.4+370843153027.9+364815 59.18 55.18 6.37R                     K0                 -0.059+0.023      +002                           
+5762          BD-19 4135 1384131593303224                   152651.9-191948153236.7-194014347.09 29.06 5.52  +0.18 +0.20 +0.09   A2m                -0.021-0.035 +.018-033V?     27                  
+5763 52Nu 1BooBD+41 2609 138481 45580 573I                  152720.2+411026153055.8+404959 66.11 54.58 5.02  +1.59 +1.90 +0.93   K4.5IIIbBa0.4      +0.011-0.007 +.020-010     < 17                 *
+5764 35Zet4LibBD-16 4110 138485159335               7126    152716.1-163049153255.2-165110349.32 31.11 5.50  -0.14 -0.75 -0.17   B2Vn               -0.011-0.014      +009SB    256  2.0   0.0      *
+5765          CD-2412155 138488183565        9689A          152714.3-240904153309.1-242922343.69 25.31 7.00  +0.27 +0.04         A3+F0V:            -0.003-0.038      -008           0.1   9.3AxBC 3*
+5766          CP-65 3100 138498253222      W                152718.0-651634153617.4-653648318.88-07.98 6.51  +0.35 +0.03         F3IV-V             -0.092-0.063      -008           7.0   5.3       
+5767          CD-39 9970 138505206763                       152725.8-394340153401.6-400358333.69 12.90 5.82  +1.68 +1.93 +1.02E  M2III              -0.055-0.025      -040V?                        *
+5768          BD+62 1416 138524 16746                       152734.8+622630152921.2+620559 97.36 46.42 6.38R                     K5                 -0.024-0.001      -040                           
+5769          BD+37 2653 138525 64754                       152734.0+365726153122.4+363659 58.83 55.02 6.38  +0.50               F6III              +0.006-0.031      -050    =< 10                  
+5770 12Tau2SerBD+16 2797 138527101600                       152733.1+162343153209.7+160322 24.80 51.22 6.22  -0.05 -0.23         B9V                +0.001+0.009      -018V     175                  
+5771   Eps TrACP-65 3102 138538253226 574  W                152733.9-655850153643.2-661901318.49-08.57 4.11  +1.17 +1.16 +0.40E  K1-2III            +0.023-0.055 +.038-016V?         5.4  83.2      *
+5772 11    SerBD-00 2982 1385621405963226                   152748.8-005049153257.9-011111  3.49 41.94 5.51  +1.09 +1.02         K0III              -0.017-0.042      -016                           
+5773          CD-3810464 138564206769                       152747.0-390040153420.9-392058334.18 13.44 6.36  -0.03 -0.11         B9V                -0.028-0.047      +000                          *
+5774 53Nu 2BooBD+41 2611 138629 45590        9688           152812.1+411419153147.0+405358 66.17 54.41 5.02  +0.07 +0.11 +0.04   A5V                -0.017-0.009 +.020-017V?    182  0.0   0.1AB   3*
+5775 36    LibCD-2710443 138688183580    I                  152833.4-274236153437.3-280249341.50 22.35 5.15  +1.30 +1.16         K4III              +0.014-0.033 +.011+012SB                         
+5776   Gam LupCD-40 9760 138690225938      W                152828.5-404950153508.5-411001333.19 11.89 2.78  -0.20 -0.82 -0.24   B2IV              e-0.015-0.028D+.008+002V     266  0.1   0.6      *
+5777 37    LibBD-09 4171 1387161406091409I                  152842.6-094318153410.7-100352355.24 35.79 4.62  +1.01 +0.86 +0.52   K1III-IV           +0.309-0.234 +.027+048     < 19:                *
+5778  4The CrBBD+31 2750 138749 64769 576  W        7134/5  152853.8+314148153255.8+312133 49.69 54.71 4.14  -0.13 -0.54 -0.11   B6Vnne             -0.019-0.011 +.027-025V     393  1.4   0.5      *
+5779          BD-05 4100 1387631406133227                   152903.7-052134153420.8-054142359.28 38.75 6.51  +0.58 +0.04         F7V                -0.095+0.011      -038V                          
+5780          BD-08 4010 138764140614                       152902.4-085049153426.6-091100356.08 36.36 5.17  -0.09 -0.45 -0.12   B6IV               -0.016-0.023      -002SB?    24                 *
+5781          CD-4410239 138769225950      W       Var?     152859.9-443724153553.2-445731331.02  8.76 4.54  -0.18 -0.69 -0.22   B3IVp              -0.025-0.030D+.014+007SB    101  1.9   2.4      *
+5782   Kap2ApsCP-73 1625 138800257307      W                152915.6-730659154021.2-732648314.34-14.44 5.65  -0.04 -0.38         B7III-IV           -0.021-0.024      -019           6.7  15. AB   3*
+5783          BD+17 2880 138803101618                       152918.8+172829153352.8+170816 26.64 51.26 6.45R                     F3III              -0.042-0.038      -021       67                  
+5784          CD-4310036 1388162259571410                   152920.9-440342153612.1-442349331.40  9.18 5.43  +1.50 +1.82         K4-5III            -0.045-0.057 +.017-019                           
+5785          BD+64 1074 138852 167543225                   152931.3+643242153055.7+641231 99.67 45.05 5.79  +0.96               K0III-IV           -0.117+0.081 +.002+010V?                        *
+5786          CP-75 1222 1388672573103235                   152936.9-754511154154.6-760455312.72-16.56 5.95  -0.04 -0.16         B9V                -0.018-0.041      +000                           
+5787 38Gam LibBD-14 4237 138905159370 577I   9704           152955.8-142722153531.6-144722351.51 32.20 3.91  +1.01 +0.74 +0.55   G8.5III            +0.065+0.009 +.041-028V    < 17  0.2   0.1AP   3*
+5788 13Del SerBD+11 2821 138917101623        9701B          153001.4+105219153448.1+103215 17.59 48.19 3.80  +0.26 +0.13         F0IV               -0.074-0.005 +.021-038V?     70  1.1   3.9AB   4*
+5789 13Del SerBD+11 2821 138918101624        9701A Del Ser  153001.4+105223153448.1+103221 17.59 48.19 3.80  +0.26 +0.12 +0.11   F0IV               -0.074+0.012 +.021-042V      80  1.1   3.9AB   4*
+5790          CD-3210930 138923206795      W        7149    152954.8-324533153611.4-330534338.43 18.19 6.24                      B8V                -0.016-0.017      -004           0.0   0.1       
+5791          BD+02 2977 138936121071                       153001.2+020014153504.6+014008  6.98 43.28 6.56  +0.28 +0.05         F0III              -0.074-0.035      -020       71                  
+5792          CP-69 2422 1389652573083233                   153007.7-695350154011.5-701340316.36-11.89 6.44  +0.08 +0.08         A1V                -0.049-0.060      -002                           
+5793  5Alp CrBBD+27 2512 139006 83893 578I         Alp CrB  153027.2+270304153441.3+264253 41.87 53.77 2.23  -0.02 -0.02 -0.04   A0V+G5V            +0.121-0.089 +.045+002SBO   133                 *
+5794 39Ups LibCD-2710464 139063183619 579I   9705           153057.1-274814153701.5-280806341.89 21.94 3.58  +1.38 +1.58 +0.71   K3III             e-0.009+0.003 +.044-025           7.0   3.5      *
+5795 15Tau3SerBD+18 3044 1390741016313230                   153100.8+175919153533.2+173920 27.65 51.08 6.12  +0.94              gG8                 -0.079-0.014      -022V                          
+5796          BD+11 2826 1390871016343231                   153107.8+113553153553.4+111556 18.74 48.30 6.07  +1.09              gK0                 -0.030-0.012      -026V                          
+5797   Ome LupCD-4210601 1391272260043232  W                153118.8-421421153803.2-423403332.78 10.44 4.33  +1.42 +1.72 +0.73   K4.5III            -0.153+0.057 +.017-007SB         6.7  11.8      *
+5798          CD-51 9324 1391292427931411  W                153123.4-520234153849.5-522222326.99  2.50 5.44   0.00  0.00         A0V                -0.036-0.035 +.015-012        0  4.5  53.4AB   3 
+5799 14    SerBD-00 2988 139137140643                       153125.7-001347153633.7-003342  4.89 41.63 6.51  +0.72 +0.45         G8III+A            -0.027-0.022      -023SB                         
+5800  6Mu  CrBBD+39 2889 139153 64790    I                  153134.7+392032153515.0+390036 62.81 54.03 5.11  +1.64 +2.01         M1.5III-IIIb       +0.029+0.006 +.003-019V?                         
+5801          CD-2511000 139160183631                       153128.4-255656153728.5-261648343.25 23.31 6.19  +0.01 -0.42         B7IV               -0.010-0.023      +001V     152                 *
+5802 16    SerBD+10 2884 139195101640                       153141.2+102041153629.6+100036 17.21 47.57 5.26  +0.95 +0.67 +0.45   K0III:CN1Ba0.7Sr2  +0.045-0.129 +.030+008V    < 17                  
+5803          CP-59 6206 1392112428033236                   153145.4-593429153956.5-595430322.63-03.64 5.95  +0.48               F6V                -0.122-0.220 +.029-022                           
+5804 18Tau5SerBD+16 2807 139225101642                       153152.7+162700153629.3+160708 25.54 50.29 5.93  +0.29 +0.04         F3V                +0.076-0.007      -002V                         *
+5805          CD-3810532 1392332068263234                   153158.1-384952153832.7-390939334.96 13.10 6.57  -0.07 -0.19         B9V                -0.013-0.032      +005                          *
+5806          BD-22 3989 139254183637                       153155.2-224836153748.1-230830345.55 25.65 5.78  +1.10 +0.89         K0III              -0.022-0.080      +007V?                        *
+5807          CD-3810536 139271206827      W                153207.4-384757153842.3-390741335.01 13.11 6.04  +0.21               A3-5mA3-F2         +0.023-0.008      +014           8.0  10.9      *
+5808          BD+38 2678 139284 64797                       153207.2+384219153549.3+382226 61.71 53.99 6.42R                     K2                 +0.029-0.006      +003                           
+5809          CD-2710478 139290183641                       153210.8-275238153815.7-281224342.06 21.72 6.32  +1.17               K1III              +0.003-0.026      +029V                          
+5810          BD-20 4285 139329183646                       153227.3-204109153816.3-210058347.21 27.17 5.84  +1.08              gG9                 +0.068-0.060      +032V?                         
+5811          BD+54 1756 139357 29583                       153237.3+541512153516.3+535519 86.16 49.85 5.97  +1.18              gK4                 -0.011-0.004      -010                           
+5812 40Tau LibCD-2911837 139365183649                       153230.7-292656153839.4-294640341.06 20.45 3.66  -0.17 -0.70 -0.19   B2.5V              -0.015-0.030      +003SB    149                 *
+5813          BD+30 2682 139389 64808                       153247.9+301920153653.4+295928 47.47 53.75 6.52                      F5V:               +0.087-0.060      -013       23                  
+5814 41    LibBD-18 4118 139446159411               7169    153309.0-185821153854.5-191807348.63 28.35 5.38  +0.86 +0.54 +0.46   G8III             v+0.085-0.076      +047                           
+5815          BD-08 4031 139460140671        9728B          153316.0-082800153840.0-084740357.31 35.87 6.50  +0.53 -0.02         F6IV-V             +0.022-0.014D+.011+004V?  =< 25  0.2  11.9      *
+5816          BD-08 4032 139461140672        9728A          153316.1-082748153840.1-084728357.32 35.87 6.48  +0.52 -0.02         F6V                +0.028-0.018D+.011+000SB  =< 25  0.2  11.9      *
+5817          BD+52 1886 139478 29589                       153315.9+522351153604.1+520411 83.44 50.49 6.74  +0.32 +0.04         F4IIIp             -0.022+0.082      -016                           
+5818          BD+55 1766 139493 29588      S        7163    153322.7+545738153557.1+543750 87.08 49.45 5.74R                     A2V                -0.035-0.010      -019                 0.5       
+5819          BD-22 3996 139518183665                       153328.2-224923153921.3-230901345.84 25.41 6.34  +0.02               A0V                -0.036-0.029      -009                           
+5820  3Psi1LupCD-3310631 1395212068433237                   153324.8-340508153946.0-342443338.19 16.69 4.67  +0.99 +0.73 +0.49   G8III              +0.004-0.015 +.032-023                           
+5821          CD-4710210 139599226059      W                153352.4-472437154058.3-474408330.05  6.01 6.23  +1.63 +1.98         K5-M0III           -0.027-0.025      -054           5.9  18.1       
+5822          CD-3012431 139613206858                       153403.1-305316154015.4-311249340.38 19.12 6.34  +1.43 +1.65         K2III              -0.061-0.020      -022                           
+5823 54Phi BooBD+40 2907 139641 45643 580                   153414.0+404044153749.6+402112 64.95 53.37 5.24  +0.88 +0.53 +0.47   G7III-IVFe-2       +0.063+0.062 +.021-010V?   < 19:                *
+5824 42    LibCD-2312458 1396631836863239I                  153422.0-232935154016.9-234905345.53 24.77 4.96  +1.33 +1.51 +0.68   K3IIICN1           -0.013-0.012 +.049-022V                         *
+5825          CD-4410310 139664226064                       153418.7-441948154111.3-443940331.96  8.44 4.64  +0.40 -0.03 +0.20   F5IV-V             -0.177-0.262 +.060-005       87                  
+5826 15The UMiBD+77  592 139669  82743229I                  153422.4+774057153124.9+772058112.85 36.46 4.96  +1.58 +1.89 +0.87   K5III              -0.049+0.010 +.021-025V    < 17                  
+5827          BD+35 2711 139761 648253238                   153456.9+350004153848.9+344030 55.41 53.58 6.11  +1.02               K0                 -0.006-0.016      +004                           
+5828          BD+54 1758 139778 29597                       153457.7+545010153732.0+543032 86.76 49.30 5.87  +1.07              gK1                 -0.037-0.015      -023                           
+5829          BD+80  480 139777  2556        9696A          153458.7+804649152911.0+802655115.60 34.31 6.58  +0.67 +0.13         G0IV-V+G8IV-V      -0.228+0.113 +.039-014SB         0.7  31.4AB   3*
+5830          BD+47 2253 139798 456501412                   153504.0+470738153816.2+464752 75.32 51.93 5.75  +0.36 -0.02 +0.18   F2V                +0.090-0.126 +.009-002V                         *
+5831          BD+12 2875 139862101673        9740           153526.6+122237154010.4+120311 20.52 47.74 6.25  +0.94 +0.71         G7.5IIIaFe-0.5     -0.007-0.007      -021SB         4.2  16.5      *
+5832          CD-49 9909 1398712260893241                   153522.8-491003154237.2-492922329.21  4.45 6.04  +1.31               K2III              -0.004-0.018      -020                           
+5833  7Zet1CrBBD+37 2665 139891 64833        9737B          153536.2+365741153922.2+363812 58.70 53.41 6.00H                     B9V                -0.014-0.013 +.015-019       25  1.0   6.4      *
+5834  7Zet2CrBBD+37 2665 139892 64834        9737A          153536.6+365737153922.7+363809 58.70 53.41 5.07H -0.12 -0.47         B7V                -0.013-0.006 +.015-024SB2O  100  1.0   6.4      *
+5835          BD+50 2206 139906 29600                       153538.9+504458153834.3+502524 80.80 50.74 5.84  +0.83               G8III              +0.005-0.038      -014                           
+5836          CP-59 6257 139915253269                       153537.4-595802154355.1-601714322.79-04.25 6.48  +1.05               G0Ib               -0.017-0.005      -037                           
+5837          CD-3710441 1399802068873242                   153608.2-370614154238.3-372530336.71 13.97 5.24  +0.98               G8-K0III           -0.048-0.021 +.008-016                           
+5838 43Kap LibBD-19 4188 1399971594421413I W        7200    153611.0-192117154156.8-194044348.94 27.58 4.74  +1.57 +1.95 +0.94   M0-IIIb            -0.037-0.103 +.040-004SB         5.0 172.0       
+5839  4Psi2LupCD-3410494 140008206889                       153618.5-342321154241.0-344238338.48 16.08 4.75  -0.14 -0.52 -0.16   B5V                -0.021-0.029      +004SB2O   80                 *
+5840 19Tau6SerBD+16 2816 140027101678                       153623.2+162050154059.2+160129 26.07 49.26 6.01  +0.90 +0.61 +0.46   G8III              +0.028-0.013      +003                          *
+5841          BD+58 1583 140117 29609               7192    153656.9+581451153909.5+575528 91.21 47.56 6.45  +1.09 +1.04         K1III              -0.005+0.011      -008                          *
+5842 21Iot SerBD+20 3138 140159101682        9744           153705.5+195932154133.1+194013 31.42 50.45 4.52  +0.04 +0.03 -0.01   A1V                -0.057-0.046 +.011-017SB2   149  0.1   0.1AB   4*
+5843 20Chi SerBD+13 2982 1401601016833243          Chi Ser  153705.0+131006154147.4+125051 21.83 47.75 5.33  +0.04 +0.05 -0.04   A0pSr             v+0.040-0.003 +.032+002SB     64                 *
+5844          BD+69  806 140227 167943240I                  153722.4+693622153739.1+691700104.68 41.46 5.62  +1.35 +1.58         K5IIIb             -0.047+0.058      -029SB                         
+5845 22Tau7SerBD+18 3059 140232101686                       153724.6+184657154154.7+182750 29.69 49.96 5.81  +0.20 +0.11 +0.10   A2m                -0.072+0.053 +.021-030V?     20                 *
+5846          CD-4110245 140285226132      W                153737.7-413003154422.6-414910334.19 10.32 5.94   0.00 -0.20         A0V+B              -0.028-0.047      +019V          1.7   3.7      *
+5847          BD-14 4266 140301159461                       153748.3-144321154324.9-150236352.91 30.68 6.31  +1.16 +0.96 +0.42E  K0IV               -0.004-0.096      +021V?                        *
+5848 44Eta LibBD-15 4171 1404171594663246                   153826.7-152115154404.4-154022352.52 30.13 5.41  +0.23 +0.07 +0.09   F0IV               -0.034-0.066      -031      101                  
+5849  8Gam CrBBD+26 2722 140436 83958        9757  Gam CrB  153832.5+263645154244.6+261744 41.74 51.92 3.84   0.00 -0.04 -0.02   B9IV+A3V           -0.105+0.045 +.033-011      112  1.5   0.2      *
+5850          BD+14 2922 140438101699        9758           153830.3+135911154310.6+134004 23.15 47.81 6.48  +0.86 +0.52         G5III              -0.010-0.032D+.002-010SB         1.0   0.6       
+5851          CP-65 3139 140483253297      W     A          153846.0-650743154753.6-652633319.94-08.58 6.18  +0.22 +0.10         A5III-IV           -0.005-0.042      -030V?         0.1   1.9      *
+5852          CP-65 3139 140484            W     B          153846.0-650743154753.7-652633319.94-08.58 6.39  +0.24 +0.10         F0-2IV             -0.005-0.042      -024           0.1   1.9      *
+5853 23Psi SerBD+02 2989 1405381211523248    9763           153859.9+025008154401.8+023054  9.70 41.97 5.88  +0.68 +0.25 +0.35   G2.5V              -0.054-0.151 +.046+019SB         1.3 370. AE   5*
+5854 24Alp SerBD+06 3088 140573121157 582I   9765           153920.5+064425154416.1+062532 14.20 44.08 2.65  +1.17 +1.24 +0.56   K2IIIbCN1          +0.137+0.047 +.053+003V?   < 17  8.3  58.2AB   3*
+5855  9Pi  CrBBD+32 2621 140716 648703249                   154002.8+324953154359.3+323057 51.87 52.44 5.56  +1.06       +0.53  gG9                 -0.032-0.010      -004V?                         
+5856          CD-2710550 140722183772        9775           154007.4-274452154612.8-280342343.60 20.69 6.51  +0.32               F2IV               -0.067-0.026      -021           0.0   0.6AB   3*
+5857          BD+52 1898 140728 296283247          BP Boo   154007.5+524035154250.7+522139 83.25 49.42 5.51  -0.07 -0.10         B9pSiCr            -0.067+0.032 +.010-016SB     75                 *
+5858 26Tau8SerBD+17 2906 140729101712      S                154009.5+173443154442.1+171551 28.33 48.91 6.14   0.00 -0.03         A0V                -0.026 0.000      -005SB     76        0.1       
+5859          BD+05 3072 140775121170                       154026.8+054540154523.5+052649 13.27 43.32 5.58  +0.04 +0.03 -0.01   A0V                +0.027-0.015      -010       65                 *
+5860          CD-3410524 140784206962      W        7239    154020.8-342210154644.2-344057339.17 15.58 5.61  -0.11 -0.42         B7Vn               -0.021-0.028      +005V          0.3   0.1      *
+5861          BD+01 3125 140815121173                       154034.0+011216154539.7+005329  8.25 40.69 6.33  +1.19 +1.20         K0III              +0.043+0.008      +014                           
+5862          CD-3910157 140861226206                       154046.4-395255154725.4-401139335.68 11.23 6.42  +0.88               G5III-IV           -0.176-0.037      -028                           
+5863 25    SerBD-01 3092 140873140740                       154055.2-012927154605.6-014816  5.53 38.99 5.40  -0.03 -0.40         B8III              -0.027-0.038      -012SBO   116                 *
+5864          CD-3710500 140901206976      W                154059.3-373558154729.0-375459337.17 12.99 6.01  +0.72 +0.31         G6V                -0.430-0.217 +.075-005           6.6  14.6AB   3*
+5865          CP-52 8912 140979243001      W                154119.2-520743154850.3-522617328.16  1.52 6.07  +1.38 +1.45         K2-3III            -0.007-0.002      -018           4.5   1.2       
+5866          BD-05 4161 1409861407513250                   154126.5-054833154645.4-060713  1.43 36.14 6.24  +1.17 +1.09         K0                 -0.009-0.002      -051V?                         
+5867 28Bet SerBD+15 2911 141003101725 583    9778           154134.3+154405154611.3+152519 25.98 47.87 3.67  +0.06 +0.08 +0.03   A2IV               +0.067-0.045 +.041-001V     170  6.3  30.6AB   5*
+5868 27Lam SerBD+07 3023 141004121186    I          7246    154135.3+073959154626.6+072111 15.70 44.10 4.43  +0.60 +0.11 +0.32   G0-V               -0.223-0.067 +.094-066SB1O=<  6                 *
+5869          CP-52 8944 141168243022      W                154231.7-525407155006.9-531234327.83  0.80 5.77  -0.08 -0.23         B9Vn:              -0.048-0.030      +016V?         5.8  28.4      *
+5870 31Ups SerBD+14 2939 141187101739                       154238.6+142525154717.3+140655 24.38 47.09 5.71  +0.09 +0.06         A3V                -0.060+0.039      -034                          *
+5871          CD-4810349 141194226254                       154243.1-483619154957.5-485443330.51  4.16 5.84  +0.07 +0.06         A1V                -0.032-0.001      +012V                          
+5872          CD-4510251 1412962262633251  W                154315.8-450542155016.3-452406332.77  6.86 6.12  +0.29 +0.03         A9III              +0.045-0.033      +002           4.8   2.9AxBC 3 
+5873          CP-54 6711 141318243044      W                154320.3-544502155106.8-550321326.79-00.73 5.73  +0.06 -0.70         B2II               -0.001-0.014      -001SB     54  3.4  18.0AB   4*
+5874          BD+14 2940 141353101744    I                  154333.6+140558154813.3+134719 24.09 46.75 6.00  +1.25 +1.50        gK2                 -0.006-0.116      -054V                          
+5875          BD-03 3829 141378140775                       154342.4-033043154856.8-034907  4.08 37.18 5.53  +0.12 +0.11 +0.04   A5IV               -0.033+0.009      -016      120                  
+5876          CP-64 3286 141413253323                       154348.1-645100155256.7-650909320.54-08.69 6.54  +0.19 +0.12         A5IV               +0.035+0.008      +016                           
+5877          BD+32 2631 141456 64915    I                  154403.7+320239154802.0+314409 50.70 51.53 6.44R                     K5                 +0.032-0.041      -020                           
+5878          BD+55 1777 141472 29655    I                  154411.5+554652154634.8+552829 87.27 47.72 5.92  +1.39              gK3                 -0.125+0.076      -004                           
+5879 35Kap SerBD+18 3074 141477101752 584I          7269    154414.2+182701154844.4+180830 30.10 48.33 4.09  +1.62 +1.95 +0.98   M0.5IIIab         e-0.051-0.088 +.021-039                          *
+5880          BD+28 2477 141527 84015    I         R CrB    154427.1+282748154834.4+280924 45.05 50.98 5.85  +0.77 +0.29         G0Iep              -0.002-0.015 +.010+025V      18                 *
+5881 32Mu  SerBD-02 4052 141513140787 585                   154424.0-030727154937.2-032549  4.59 37.29 3.53  -0.04 -0.10 -0.05   A0V                -0.086-0.024 +.007-009SB     87                  
+5882          CD-4610430 141544226295                       154425.3-464524155131.5-470338331.88  5.44 6.01  +1.16 +1.12         K2III              -0.112-0.030      +030SB1O                      *
+5883  5Chi LupCD-3310754 141556207040 586                   154436.1-331921155057.5-333738340.57 15.82 3.95  -0.04 -0.13 -0.07   B9IV               -0.006-0.030      +005SB2O    0                 *
+5884          CP-62 4990 141585253328               7299    154440.0-621819155322.8-623625322.22-06.76 6.19  +1.47               K3III              -0.011-0.023      +008                           
+5885  1    ScoCD-2511131 141637183854                       154457.7-252650155058.7-254505346.10 21.71 4.64  -0.05 -0.73 -0.10   B3V                -0.018-0.024      +003V     300                 *
+5886          BD+63 1225 141653 16848 587                   154508.4+625431154640.0+623558 96.42 44.46 5.19  +0.04 +0.10         A2IV               +0.039-0.055 +.018-006V                         *
+5887          BD+55 1779 141675 29668        9793           154512.9+554058154738.0+552236 87.05 47.62 5.86  +0.25 +0.16 +0.08   A3m                +0.011+0.010D+.013-002SB     36  3.5   2.1      *
+5888 34Ome SerBD+02 3007 141680121215    I                  154514.5+023006155017.5+021147 10.54 40.50 5.23  +1.02 +0.82 +0.53   G8III              +0.031-0.051 +.027-004V?   < 17                 *
+5889 10Del CrBBD+26 2737 141714 840193252I         Del CrB  154523.9+262228154935.7+260406 41.88 50.37 4.63  +0.80 +0.37 +0.42   G3.5III-IVFe-1     -0.076-0.063 +.014-019     < 17                  
+5890          CD-50 9939 141724243078                       154527.7-501853155251.5-503655329.80  2.54 6.60  +1.53               K3III              +0.015+0.011      -000                           
+5891   Kap TrACP-68 2585 1417672533423253                   154536.4-681817155529.6-683611318.47-11.48 5.09  +1.13 +0.94         G5IIa              -0.012-0.003 +.007+006                           
+5892 37Eps SerBD+04 3069 141795121218 588                   154549.8+044643155049.0+042840 13.15 41.66 3.71  +0.15 +0.11 +0.06   A2Vm               +0.128+0.063 +.041-009V      37                 *
+5893          CD-2912030 141832183873        9813   7301    154602.2-293459155212.8-295312343.36 18.46 6.40  +0.98 +0.85         K1III              -0.135-0.089      -017           6.4  29.9AB   3*
+5894          BD+15 2918 141850101771    I         R Ser    154605.0+152614155041.7+150801 26.23 46.76 5.2                       M7IIIe             -0.005-0.041      +024V                         *
+5895 36    SerBD-02 4058 141851140801      S                154603.0-024716155115.6-030526  5.25 37.18 5.11  +0.12 +0.07         A3Vnp              -0.087-0.027 +.010-008V                0.1      *
+5896          BD-13 4269 141853159544                       154603.2-134955155138.4-140801355.27 29.89 6.19  +1.00               G8III              -0.026-0.005      -022V                          
+5897   Bet TrACP-63 3723 141891253346 589  W                154619.6-630719155508.5-632550321.85-07.52 2.85  +0.29 +0.05 +0.15   F2III              -0.191-0.398 +.083+000       92 11.0 155.        
+5898          CP-60 6191 141913253344      W        7310    154624.9-602644155452.6-604436323.56-05.45 6.15  +0.10               B9II               -0.009+0.003      -005           2.3  45.0AC   4*
+5899 38Rho SerBD+21 2829 141992 84037    I          7300    154652.3+211642155115.9+205840 34.44 48.70 4.76  +1.54 +1.88 +0.85   K5-III             -0.053+0.019 +.015-062V?   < 17                  
+5900          CP-59 6428 142049253349      W        7318    154709.4-595245155532.3-601040323.99-05.06 5.77  +0.35 +0.14         G5II-III+A3        -0.052-0.075D+.028           56  3.0   3.9      *
+5901 11Kap CrBBD+36 2652 142091 649481414I W                154727.8+355803155113.9+353927 57.02 51.04 4.82  +1.00 +0.87 +0.49   K1IVa              -0.007-0.347 +.034-024     < 17  6.7 134.6       
+5902 45Lam LibBD-19 4249 1420961838951415                   154731.6-195205155320.1-201002350.72 25.38 5.03  -0.01 -0.56 -0.05   B2.5V              -0.011-0.023      +006SB    197  2.0   0.0      *
+5903 16Zet UMiBD+78  527 142105  8328 590           7263    154737.2+780608154403.5+774740112.68 35.66 4.32  +0.04 +0.05 +0.01   A3Vn               +0.020-0.001 +.016-013V     206                 *
+5904  2    ScoCD-2412352 142114183896        9823           154736.3-250143155336.7-251938346.88 21.61 4.59  -0.07 -0.65 -0.09   B2.5Vn             -0.016-0.025D+.006-010      308  2.5   2.3      *
+5905          CP-60 6208 142139253353                       154740.1-601106155606.0-602858323.85-05.34 5.76  +0.06 +0.07         A3V                -0.034-0.081      -011V      96                 *
+5906          CD-2412354 142165183900      D                154755.4-241407155353.8-243159347.51 22.15 5.39  -0.02 -0.40 -0.02   B6IVn              -0.024-0.023      +002V     273                 *
+5907          CD-2312569 142184183901               7314    154758.6-234048155355.8-235841347.93 22.55 5.42  -0.04 -0.61 -0.05   B2.5Vne            -0.015-0.025      -009V     349                 *
+5908 46The LibBD-16 4174 142198159563    I                  154807.8-162609155349.5-164346353.54 27.72 4.15  +1.02 +0.81 +0.52   G8.5IIIb           +0.099+0.133 +.036+003     < 19:                 
+5909          BD+17 2926 142244101789                       154824.8+174204155256.2+172413 29.61 47.13 6.36R                     K0                 -0.041+0.002      -012                           
+5910          CD-2611096 142250183907                       154824.6-270230155430.0-272019345.57 20.00 6.14  -0.07 -0.44         B6Vp               -0.025-0.023      +004V?    106                 *
+5911 39    SerBD+13 3024 1422671017923254  W        7313    154832.5+133035155312.1+131148 24.07 45.40 6.10  +0.60  0.00 +0.33   G0VFe-0.5          -0.151-0.561 +.041+036SB         5.6  98.3       
+5912  3    ScoCD-2412365 142301183914              V927 Sco 154839.2-245650155439.5-251437347.12 21.51 5.87  -0.06 -0.58         B8IIIp             -0.013-0.022      -009V      58                 *
+5913          BD+16 2840 142357101796        9828           154900.2+162220155334.9+160430 27.89 46.49 6.09R                     F5II-III           +0.027-0.020      +002SB     30  6.4   3.6      *
+5914  1Chi HerBD+42 2648 142373 457721416                   154913.0+424353155240.5+422706 67.68 50.33 4.62  +0.56  0.00 +0.32   F8VFe-2Hdel -1     +0.440+0.632 +.056-055        0                 *
+5915 47    LibBD-18 4195 142378159572        9834   7327    154913.5-190515155500.3-192259351.65 25.66 5.94  -0.01 -0.53 -0.03   B5V                -0.016-0.020      -007SB    240  2.0   0.7      *
+5916          CD-3012663 142407207119                       154914.9-304724155530.4-310501343.07 17.09 6.21  +1.37               K4III              +0.014+0.024      +044                           
+5917  4    ScoCD-2511190 142445183931                       154927.3-255816155530.1-261557346.52 20.64 5.62  +0.15 +0.19         A3V                -0.045-0.021      -029                           
+5918          CD-3910237 142448207128      W                154925.1-393413155606.5-395151337.19 10.42 6.03  +0.15               B6V                -0.035-0.018      -018V          5.9  18.       *
+5919 40    SerBD+09 3116 1425001212543256          FP Ser   154950.3+085229155440.3+083449 18.57 42.96 6.29  +0.18 +0.09         A7Vn               +0.002+0.002      -025V?    230                 *
+5920          CP-64 3320 142514253362      W                154947.4-644450155858.1-650216321.11-09.01 5.75  -0.06 -0.40         B7III              -0.013-0.019      +000           6.6   9.7      *
+5921          CD-4710456 142529226392                       154951.0-475202155703.8-480944331.90  3.99 6.31  +0.38 -0.03         F1IV               -0.109-0.095      +002                           
+5922          BD+56 1838 142531 296983255                   154956.9+560719155216.6+554936 87.29 46.84 5.81  +0.96              gG8                 -0.023+0.057      -030V                          
+5923          CD-3112407 142542207134                       154956.2-312935155613.9-314709342.70 16.47 6.29  +0.43               F6V                +0.036+0.001      +018                           
+5924          BD+20 3166 142574 840703257I                  155010.1+203615155434.6+201839 33.84 47.76 5.44  +1.59 +1.94 +0.97   M0III              -0.082+0.043 +.023-061V?                        *
+5925   Xi 1LupCD-3310826 142629207144      W     A          155029.7-334024155653.5-335759341.30 14.75 5.12  +0.12 +0.08         A3V                +0.018-0.042 +.025-010       73  0.5  10.3      *
+5926   Xi 2LupCD-3310826 142630207145      W     B          155030.3-334017155654.2-335751341.30 14.75 5.62  +0.05 +0.06         B9V                +0.020-0.039 +.025-012      191  0.5  10.3      *
+5927          BD-13 4290 142640159584                       155037.9-140619155614.4-142358355.92 28.90 6.37  +0.48 +0.08         F7V:               +0.031-0.073      -006V                          
+5928  5Rho ScoCD-2811714 1426691839573258    9846           155042.5-285519155653.1-291251344.63 18.27 3.88  -0.20 -0.82 -0.20   B2IV-V             -0.013-0.025      -000V?    156  8.8  38.3      *
+5929          CD-3510611 142691207152                       155051.1-355339155721.3-361106339.85 13.03 5.80  +1.01               K0-1III            -0.018-0.002      -005                          *
+5930          BD-14 4314 142703159587      D                155055.6-143213155633.4-144945355.62 28.55 6.13  +0.23 -0.03         A2III              +0.069-0.027      +012                          *
+5931          BD+19 3036 142763101821                       155111.1+185447155539.8+183714 31.61 46.96 6.26  -0.11 -0.43         B8III              -0.014-0.015      -042V      80                 *
+5932  2    HerBD+43 2542 142780 45788    I          7335    155117.8+432547155437.9+430819 68.68 49.87 5.37  +1.65 +1.97 +1.25   M3IIIBa0.3         -0.032+0.065 +.034-010                           
+5933 41Gam SerBD+16 2849 142860101826 591I W        7350    155150.0+155916155627.2+153942 27.75 45.71 3.85  +0.48 -0.03 +0.24   F6V                +0.312-1.281 +.069+007V?      8  6.6 201.5AB   3*
+5934          BD-20 4364 142883183972               7359    155149.6-204135155740.4-205859350.88 24.09 5.85  +0.02 -0.43         B3V                -0.016-0.018      +001SB2    98                 *
+5935          CD-3710620 142889207178                       155156.3-371253155830.7-373011339.14 11.89 6.31  +1.01               K0III              -0.025-0.002      -014V                          
+5936 12Lam CrBBD+38 2712 142908 649743259  W                155209.2+381408155547.6+375649 60.60 50.10 5.45  +0.33 +0.03         F0IV               +0.031+0.083 +.044-012V      74  4.5  94.3      *
+5937          CP-53 6911 142919243219                       155209.8-534402155954.0-540116328.43-00.76 6.10   0.00 -0.48         B5IV               -0.023-0.017      -038                           
+5938  4    HerBD+42 2652 142926 45790              Var?     155208.5+425125155530.6+423358 67.77 49.78 5.75  -0.11 -0.41 -0.18   B9pe              v-0.025+0.015      -017SBO   350                 *
+5939          CP-63 3765 142941253377              S TrA    155211.8-632928160110.7-634636322.13-08.22 6.41  +0.78 +0.54         F8II               -0.009-0.003      +005V                         *
+5940   Phi SerBD+14 2969 142980101834    I                  155237.7+144204155714.6+142452 26.21 45.02 5.54  +1.14 +1.16 +0.56   K1IV               -0.121+0.087      -068                           
+5941 48    LibBD-13 4302 1429831596071417          FX Lib   155235.2-135927155811.4-141646356.39 28.63 4.88  -0.10 -0.20 -0.03   B5IIIp            t-0.012-0.015      -006SB?   393                 *
+5942          CD-2412427 142990183982              V913 Sco 155234.9-243235155834.8-244953348.12 21.20 5.43  -0.09 -0.64         B5IV              v-0.014-0.018      -011V     200                 *
+5943          CD-4110478 1430092264251418                   155241.5-412727155930.3-414440336.44  8.58 4.99  +1.00               K0II-III           -0.040-0.018 +.019-027                           
+5944  6Pi  ScoCD-2511228 143018183987 592    9862   7371    155248.0-254934155851.1-260651347.22 20.23 2.89  -0.19 -0.91 -0.20   B1V+B2V            -0.011-0.026 +.010-003SB2O  100: 1.2   0.0     3*
+5945          CD-4010113 143084226431               7375    155312.4-402202155958.0-403910337.23  9.34 6.49  +1.52               K1II-III           +0.021+0.008      -026                           
+5946          CP-54 6922 143101243246                       155318.7-541733160106.4-543440328.20-01.29 6.13  +0.25               A5V                -0.043-0.039      -032                           
+5947 13Eps CrBBD+27 2558 143107 84098 593I   9859           155326.8+271002155735.3+265240 43.65 48.78 4.15  +1.23 +1.28 +0.62   K2IIIab            -0.076-0.061 +.024-031V?   < 17  7.3 101.4AC   3*
+5948   Eta LupCD-3810797 143118207208      W     A          155329.5-380639160007.3-382349338.77 11.01 3.41  -0.22 -0.83 -0.21   B2.5IV             -0.022-0.032D+.008+008V     230  4.4  15.0AB   3*
+5949          BD+59 1691 143187 29723                       155353.1+591200155549.7+585442 91.08 45.17 6.31  -0.02 -0.18         A0V                -0.024+0.022      -008V?    180                  
+5950          BD+40 2948 143209 64988                       155358.5+395851155729.9+394143 63.29 49.68 6.31  +1.07               K0                 -0.063+0.060      -014                          *
+5951          CP-62 5122 143238253390                       155405.0-621533160252.4-623230323.10-07.43 6.25  -0.04               B9.5V              -0.042-0.023      +004                           
+5952          CD-4010120 143248226442      W                155408.7-400910160053.7-402607337.51  9.39 6.21  +0.01 -0.01         A0V                +0.014+0.037      -015           3.8   8.0ABxC 3 
+5953  7Del ScoBD-22 4068 143275184014 594I S                155425.1-222014160020.0-223718350.10 22.49 2.32  -0.12 -0.91 -0.13   B0.3IV             -0.012-0.022      -007SB    181  0.2   0.2 O   4*
+5954 49    LibBD-16 4196 1433331596251419  W                155442.7-161420160019.6-163200354.92 26.72 5.47  +0.52 +0.03         F8V                -0.630-0.394 +.035-025SB1O       5.6 155.1      *
+5955          CP-72 1902 1433462573573269                   155446.9-720730160555.8-722403316.51-14.88 5.70  +1.17 +1.26         K1IIICNII          -0.037+0.069      +049                           
+5956          CD-3112470 143404207234    I                  155500.8-313625160119.5-315322343.46 15.66 6.33  +1.45               K4III              +0.010-0.004      +001                           
+5957          BD+37 2695 143435 65001    I                  155516.0+365539155857.7+363838 58.57 49.49 5.62  +1.49       +0.83  gK5                 +0.022+0.029      +011V?                         
+5958          BD+26 2765 143454 84129    I W       T CrB    155519.0+261213155930.2+255513 42.37 48.16 2.0 H +0.1        +1.56 sdBe+gM3+Q           -0.005+0.013      -029SBO              0.2      *
+5959 50    LibBD-07 4162 1434591408971420                   155523.6-080743160047.6-082441  2.00 32.00 5.55  +0.05 -0.05         A0V s              -0.014-0.013      -019    =< 41                  
+5960          BD+55 1793 143466 29727 595          CL Dra   155524.9+550156155747.4+544459 85.41 46.50 4.95  +0.26 +0.05 +0.14   F0IV               -0.150+0.110 +.022-011SB    140                 *
+5961   Iot1NorCP-57 7500 143474243279      W                155523.7-572936160331.9-574631326.35-03.92 4.63  +0.24 +0.09         A7IV               -0.124-0.085 +.023-014V     139  0.2   0.5AB   3*
+5962   Eta NorCD-4810512 1435462264663266                   155551.7-485702160312.9-491347331.97  2.52 4.65  +0.92 +0.64 +0.47   G8III              +0.043+0.010 +.022-000                           
+5963          BD+04 3096 1435531213153262                   155553.2+044226160051.1+042539 14.86 39.52 5.83  +1.00 +0.79 +0.53  gK0                 -0.041+0.075      -004                           
+5964          BD+50 2239 143584 297373260                   155614.0+500957155904.4+495252 78.49 47.77 6.05  +0.29 +0.03         F0IV               +0.023-0.041      +004V?     63                  
+5965          CD-2811817 143619184049        9896           155627.7-285122160239.4-290809345.65 17.47 6.03  +1.31               K3III              +0.036-0.013      +005V?         6.8  11.0       
+5966  5    HerBD+18 3101 1436661018793263I                  155644.6+180541160114.3+174906 31.20 45.44 5.12  +0.99 +0.74 +0.50   G8IIIbFe-0.5       -0.048+0.157 -.007-019V    < 17                  
+5967          CD-3810832 1436992072763267                   155645.0-381924160324.2-383609339.12 10.43 4.89  -0.14 -0.58 -0.14   B6IV               -0.016-0.027      -002V?    201                 *
+5968 15Rho CrBBD+33 2663 143761 65024      W                155713.2+333619160102.7+331813 53.51 48.92 5.41  +0.60 +0.08 +0.32   G0+VaFe-1          -0.192-0.766 +.040+018V       7  3.2  89.6      *
+5969          CD-2511295 143787184068    I                  155717.9-253511160320.6-255155348.17 19.70 5.00  +1.22 +1.31 +0.46E  K5III              -0.071-0.038 +.032-039                          *
+5970          CD-3112505 143790207282                       155715.2-314320160334.3-320002343.74 15.25 6.01  +0.47               F4IV               -0.044-0.028      +028                           
+5971 14Iot CrBBD+30 2738 143807 841523264           7396    155726.1+300751160126.6+295104 48.30 48.46 4.99  -0.07 -0.19 -0.08   A0p:Hg:            -0.039-0.009 +.010-019SB     12                 *
+5972 44Pi  SerBD+23 2886 143894 841553268                   155759.2+230455160217.7+224816 38.14 46.78 4.83  +0.07 +0.06 +0.01   A3V                +0.002+0.028 +.012-028SB    110                  
+5973          CD-2412499 143900184075    I                  155754.2-242700160354.7-244335349.12 20.42 6.21  +1.38               K0                 +0.001+0.009      +026V                          
+5974          CD-3211386 143902207292                       155755.1-325612160417.8-331252343.00 14.26 6.10  +0.34               A9IV               -0.031-0.055      -028                           
+5975          CD-3710680 143928207297      W                155800.6-373503160436.7-375147339.81 10.81 5.90  +0.40               F3IV               -0.137-0.117      -006           7.0  40.7       
+5976 43    SerBD+05 3131 144046121339      W                155848.9+051543160345.7+045912 15.97 39.20 6.08  +0.96 +0.75 +0.32E  G9III              -0.041+0.012      -044V?         7.8  30.8      *
+5977   Xi  ScoBD-10 4237 144069159665        9909B          155852.0-110551160422.1-112223  0.02 29.42 5.07H                     F5IV               -0.060-0.029 +.048-029           0.2   1.2AB   5*
+5978   Xi  ScoBD-10 4237 144070159665        9909A          155852.0-110551160422.1-112223  0.02 29.42 4.77H +0.47 +0.01 +0.24   F5IV               -0.060-0.029 +.048-029SBO    27  0.2   1.2AB   5*
+5979          CP-55 7079 144183243339                       155923.2-555511160724.0-561129327.80-03.09 6.16  +0.58               F2II               -0.003-0.011      +002V                          
+5980   Del NorCD-4410625 144197226500 596                   155925.3-445407160629.4-451024335.09  5.17 4.72  +0.23 +0.15 +0.12   Am                 +0.002+0.028 +.035-016        0                  
+5981          BD+53 1834 144204 29763    I                  155932.3+531137160205.5+525457 82.59 46.48 5.93  +1.48              gK5                 -0.002-0.034      -007V?                         
+5982  6Ups HerBD+46 2142 144206 458653271                   155940.9+461851160247.9+460212 72.69 47.98 4.76  -0.11 -0.32 -0.10   B9III              +0.059-0.058      +003        6                 *
+5983          BD+37 2708 144208 65049      S                155938.7+365427160319.4+363754 58.57 48.61 5.83  +0.56               A2V+F7III          +0.010-0.017      -001SB2O   23                 *
+5984  8Bet1ScoBD-19 4307 144217159682 597I   9913A  7424    155937.2-193154160526.2-194820353.19 23.60 2.62  -0.07 -0.87 -0.09   B1V                -0.006-0.019 +.009-001SBO   130  1.3   0.0 O   5*
+5985  8Bet2ScoBD-19 4308 144218159683        9913C  7424    155937.6-193142160526.5-194807353.20 23.60 4.92  -0.02 -0.70         B2V                -0.019-0.020      -004V      74  1.3   0.0 O   5*
+5986 13The DraBD+58 1608 144284 29765 598I                  160000.8+584956160153.3+583355 90.18 44.58 4.01  +0.52 +0.10 +0.25   F8IV               -0.320+0.335 +.051-009SB1O   27                 *
+5987   The LupCD-3610642 144294207332 599                   160001.4-363148160635.5-364808340.83 11.32 4.23  -0.17 -0.70 -0.17   B2.5Vn             -0.017-0.029      +015      309                 *
+5988          CD-2312700 144334184113              V929 Sco 160008.4-232002160606.3-233623350.35 20.85 5.92  -0.08 -0.55         B8p               v-0.013-0.028      -007       44                 *
+5989          BD-05 4234 144362140945        9918           160024.2-060110160544.5-061730  4.86 32.37 6.53  +0.48 +0.07         F2IV               +0.037-0.008D+.012-011SB     45  0.0   0.1AP   5*
+5990          BD-05 4235 144390140947      W                160040.3-055206160559.8-060822  5.05 32.41 6.41  +1.03 +0.80         K0                 -0.030+0.004      -032V?         5.8   9.3       
+5991          CD-3610648 144415207341      W                160041.5-362903160716.4-364520340.97 11.27 5.73  +0.29 +0.02         F1IV               +0.066-0.043      +026           6.0  40.7       
+5992          BD+08 3134 144426121361                       160047.4+082204160537.8+080546 19.77 40.35 6.29  +0.08 +0.11 +0.06   A3m                -0.009-0.002      -021SBO    39                 *
+5993  9Ome1ScoBD-20 4405 144470184123                       160057.3-202354160648.4-204009352.75 22.77 3.96  -0.04 -0.81 -0.08   B1V                -0.009-0.021      -003V?    142                 *
+5994   Iot2NorCP-57 7613 1444802433683273                   160105.1-573955160918.6-575604326.81-04.55 5.57  -0.04               B9.5V              -0.013-0.063      +000       96                  
+5995          BD+59 1697 144542 29777    I                  160120.2+594107160309.3+592439 91.19 44.11 6.19  +1.58 +1.91 +0.81E  M1III              -0.023-0.022      -005                          *
+5996          BD-13 4342 144585159706                       160128.7-134808160703.4-140415358.18 27.16 6.32  +0.66 +0.24         G4IV-V             -0.258+0.024      -016V                          
+5997 10Ome2ScoBD-20 4408 144608184135    I          7454    160132.3-203555160724.3-205207352.70 22.54 4.32  +0.84 +0.50 +0.43   G3II-III           +0.041-0.038 +.021-005                          *
+5998          CD-2412552 144661184142                       160151.6-241137160751.9-242743349.99 19.97 6.33  -0.06 -0.53         B7IIIp:            -0.011-0.007      -005V      36                 *
+5999          CD-3810893 144668207367      W     C V856 Sco 160152.1-385013160834.2-390619339.52  9.38 7.05  +0.36 +0.25         A7IVe              -0.019-0.031      +008V          0.4  44.1AC   4*
+6000          CD-3810894 144667207368      W     A          160152.4-384929160834.4-390535339.53  9.38 6.65  -0.07 -0.44         A0-3III            -0.027-0.035      -003     < 20  0.4  44.1AC   4*
+6001          CD-2511369 144690184144    I                  160201.8-260332160807.6-261936348.63 18.62 5.38  +1.65 +2.01 +0.95E  M2III              +0.108-0.003      -018V                          
+6002 11    ScoBD-12 4425 144708159715        9924           160203.1-122835160736.4-124444359.41 27.93 5.78  +0.01               B9.5Vnn           t-0.045-0.029      -025SB    239  4.3   3.5      *
+6003          CD-2312731 1448441841643275           7470    160245.2-232507160843.7-234108350.73 20.37 5.88  +0.02 -0.31         B9IVp:             -0.009-0.025      -014SB2   180                 *
+6004 45    SerBD+10 2958 1448741019393274                   160251.0+100933160737.5+095330 22.16 40.77 5.63  +0.20 +0.17         A7V                -0.021-0.004      -028SB    157                  
+6005          BD+22 2926 144889 84202    I                  160302.1+220528160722.2+214921 37.26 45.38 6.14  +1.37 +1.51 +0.76   K4III              -0.013-0.041      +057                           
+6006          CD-3211456 144927207396      W                160309.5-322259160931.7-323859344.22 13.91 6.19  +0.79 +0.46         K0-2III            -0.026-0.053      -005           0.8   7.7      *
+6007          CD-3310961 1449872074033277                   160327.8-331649160952.6-333245343.63 13.22 5.54  -0.10               B8V                -0.023-0.042      -021SB    181                 *
+6008  7Kap HerBD+17 2964 1450011019511421    9933A  7471    160333.6+171848160804.5+170249 31.02 43.64 5.00  +0.95 +0.61 +0.46   G8III              -0.032-0.007 +.002-011V?     10  1.2  28.1AB   3*
+6009  7Kap HerBD+17 2965 145000101952    I   9938B          160334.0+171917160804.9+170316 31.03 43.64 6.25  +1.14 +1.11         K1III              -0.031-0.028 +.002+038V   =< 25  1.2  28.1AB   3*
+6010 47    SerBD+08 3141 145002121383    I         FS Ser   160338.6+084800160828.0+083203 20.71 39.95 5.73  +1.61 +1.69         M3.5IIIa           -0.017-0.010      -022V?                        *
+6011          BD+03 3132 145085121390    I                  160359.1+034308160858.9+032716 15.17 37.28 5.91  +1.47 +1.82        gK5                 -0.028+0.016      +009V?                         
+6012          BD-17 4502 145100159745                       160409.6-180430160955.2-182027355.15 23.82 6.47  +0.44               F4V                -0.084-0.076      -025V                          
+6013  8    HerBD+17 2967 145122101962               7477    160416.1+172816160846.6+171221 31.31 43.54 6.14   0.00 -0.07         A0Vnn              -0.021-0.026      -017V     275                  
+6014          BD+06 3169 1451481213921422                   160415.7+063949160911.2+062244 18.40 38.75 5.97  +1.00 +0.81 +0.50   K1.5IV             +0.236-0.738 +.030-004V                          
+6015          CD-4010251 1451912265643278                   160428.5-405117161117.7-410711338.51  7.55 5.86  +0.27               F0IV               -0.077-0.127      -014                          *
+6016          BD-03 3884 145206141001    I                  160436.4-031213160950.5-032801  8.28 33.24 5.37  +1.45 +1.46 +0.81   K4III              -0.030-0.007 +.008-046SB                        *
+6017          CD-2912343 145250184197    I                  160449.1-290908161102.0-292459346.81 15.99 5.13  +1.12 +1.02         K3III              -0.093-0.087 +.025-027                           
+6018 16Tau CrBBD+36 2699 145328 651081423I   9939   7488    160518.8+364442160858.3+362927 58.39 47.47 4.76  +1.01 +0.86 +0.54   K1-III-IV          -0.053+0.333 +.031-019SB   < 17  8.3   2.2      *
+6019   Zet NorCP-55 7229 145361243449                       160524.7-551653161322.6-553227328.86-03.19 5.81  +0.34               F2III              -0.105-0.043      -046                           
+6020   Del1ApsCP-78 1092 1453662573801424  W     A Del1 Aps 160523.5-782637162020.8-784145312.42-19.89 4.68  +1.69 +1.69 +1.33E  M5IIIb             -0.014-0.035 +.020-012           0.4 102.9AB   3*
+6021   Del2ApsCP-78 1093 145388257381      W     B          160530.7-782457162026.8-784002312.44-19.88 5.27  +1.41 +1.62 +0.56E  K3III              -0.007-0.025 +.020-010           0.4 102.9AB   3*
+6022          CP-53 7413 145384243448               7527    160529.4-532445161316.8-534018330.13-01.82 5.83  +1.96 +2.21         M0Ib-II+F-G        -0.017-0.016      -012V?                        *
+6023 11Phi HerBD+45 2376 145389 45911 601           7490    160537.0+451149160846.2+445606 70.85 47.11 4.26  -0.07 -0.28 -0.09   B9p:Mn:            -0.025+0.038 +.020-016SB1O   10                 *
+6024   Kap NorCP-54 7245 145397243454 600  W                160535.3-542218161328.7-543750329.49-02.53 4.94  +1.04 +0.78         G8III              -0.002-0.024 +.022-014           7.9  14.9       
+6025          BD+68  864 145454 169623276                   160602.8+680425160619.7+674837101.15 40.09 5.44  -0.02 -0.08         A0Vn               -0.035+0.066 +.010-018V?    204                 *
+6026 14Nu  ScoBD-19 4332 145501159763        9951CD         160609.8-191125161158.6-192659354.61 22.71 6.30  +0.13 -0.37         B8V+B9VpSi         -0.010-0.009 +.030-014       67  2.5  41.1AC   5*
+6027 14Nu  ScoBD-19 4333 145502159764        9951AB         160610.9-191203161159.7-192738354.61 22.70 4.01  +0.04 -0.65 +0.03   B3V                -0.010-0.023 +.030+002SBO   199  2.5  41.1AC   5*
+6028 13    ScoCD-2710841 145482184221                       160608.5-274001161218.2-275535348.12 16.84 4.59  -0.16 -0.74 -0.17   B2V                -0.013-0.025      +010V     225                 *
+6029 12    ScoCD-2811962 145483184217        9953   7520    160605.1-280926161215.9-282503347.75 16.50 5.67  +0.01 -0.20         B9V               v-0.032-0.043D+.021-003V?         2.1   3.9      *
+6030   Del TrACP-63 3854 145544253474 602  W                160619.9-632548161526.3-634108323.36-09.23 3.85  +1.11 +0.86 +0.39E  G2Ib-IIa           +0.002-0.011 +.029-005           8.0  30.        
+6031 15Psi ScoBD-09 4324 1455701410223280                   160631.9-094818161200.0-100351  2.54 28.81 4.94  +0.09 +0.11 +0.07   A3IV               -0.001-0.014 +.020-006V      33                 *
+6032          BD+10 2971 145589121414      W                160642.7+095818161129.7+094245 22.53 39.84 6.53  +0.24 +0.10         F0IV               +0.014-0.005      -027           0.0   0.1      *
+6033 16    ScoBD-08 4180 145607141024                       160642.1-081721161207.3-083251  3.92 29.73 5.43  +0.12 +0.13         A4V                +0.042+0.003 -.009+005V     201                  
+6034          BD+77  616 145622  8417                       160649.3+770338160331.3+764737110.90 35.44 5.56R                     A3V                -0.021+0.016      -016SB     80                  
+6035          BD+17 2982 1456471019943279                   160657.0+165528161128.7+163956 30.94 42.74 6.08  +0.02  0.00         A0V                +0.003+0.004      -017V      24                  
+6036          BD+58 1622 145674 29823        9944           160705.1+581154160902.9+575616 88.89 43.94 6.33R                     A1V                -0.024+0.022      -010SB    195  5.4  12.3      *
+6037          CP-67 3054 145689253481                       160706.8-674110161705.5-675629320.42-12.36 5.75  +0.15 +0.09         A4V                -0.046-0.094      -009       89                  
+6038          BD+56 1867 145694 29825                       160713.8+560520160926.0+554944 86.09 44.58 6.49R                     K0                 -0.033+0.025      -015                           
+6039 10    HerBD+23 2909 145713 84240    I         LQ Her   160722.5+234512161138.0+232941 39.93 44.90 5.70  +1.56 +1.56 +1.81   M4.5IIIa           -0.029-0.012      -025                          *
+6040          CP-57 7716 145782243509                       160733.7-573927161549.7-575444327.46-05.13 5.63  +0.14               A3III              -0.022-0.048      -015                          *
+6041          BD-03 3891 145788141031                       160740.9-035750161256.5-041315  8.10 32.17 6.25  +0.13 +0.05         A1V                -0.032-0.015      -016    =< 41                  
+6042          CD-2412623 145792184241        9967           160744.5-240958161345.7-242519351.01 19.03 6.41  +0.04 -0.44         B5V                +0.013-0.013      +006V?     23  3.8   1.5      *
+6043          BD+33 2696 145802 65129        9958           160750.5+333600161139.7+332033 53.83 46.72 6.29  +1.20               K2III              +0.015+0.010D+.009+000V?         4.3   5.4AB   3*
+6044          CD-3211525 145838207480                       160758.2-324521161422.3-330041344.70 12.94 5.92  +1.02               K0III              -0.015-0.034      -023                           
+6045   The NorCD-4710611 145842226600                       160759.5-470702161515.3-472220334.70  2.53 5.14  -0.13 -0.40         B8V                -0.032-0.051      +001      251                 *
+6046          BD+36 2706 145849 65132    I W                160808.6+364059161148.0+362530 58.33 46.90 5.63  +1.34               K3III              -0.011-0.036      -031SB1O       0.1   0.1      *
+6047  9    HerBD+05 3165 1458921214313283I                  160818.5+051636161315.4+050116 17.55 37.18 5.48  +1.47 +1.78 +0.77  gK5                 +0.040-0.007 +.014-002V?                         
+6048 17Chi ScoBD-11 4096 145897159793    I                  160818.9-113457161350.9-115015  1.30 27.34 5.22  +1.42 +1.54 +0.71   K3III              -0.010-0.006 +.029-025V?   < 17                 *
+6049          CD-4211132 145921226603                       160826.6-423847161524.0-425359337.83  5.74 6.14  +1.11               K2III              -0.026-0.009      +004                           
+6050          BD+42 2683 145931 459573281I   9962           160828.9+423750161147.6+422228 67.03 46.82 5.87  +1.45 +1.74 +0.77   K4II+F6-8V         -0.006+0.027      -021V?         4.3  23.6      *
+6051          BD-20 4444 145964184253                       160836.0-205111161428.8-210627353.72 21.16 6.41  -0.01               A0V                -0.027-0.026      -008      254                  
+6052          BD+27 2603 145976 84247        9966           160837.5+265538161245.3+264015 44.39 45.43 6.50  +0.39 -0.03         F3V                +0.049-0.025D+.012-008       30  3.8   2.6       
+6053          BD-18 4249 145997159807      D                160852.9-181644161439.1-183207355.81 22.85 6.32  +1.09               K2III              -0.106-0.109      -017V?         0.3   0.0      *
+6054          CD-2511453 146001184258                       160849.7-251324161453.6-252837350.39 18.12 6.05  +0.04 -0.36         B7IV               +0.007-0.019      -008V?    181                 *
+6055          CP-53 7594 146003243526               7574    160853.5-533336161643.1-534840330.40-02.27 5.44  +1.73 +1.86 +1.02E  M2III              -0.006+0.004 +.020-028                          *
+6056  1Del OphBD-03 3903 146051141052 603I W        7556    160906.2-032613161420.7-034140  8.85 32.20 2.74  +1.58 +1.96 +1.03   M0.5III           e-0.044-0.143 +.034-020V         10.4  65.5      *
+6057          BD+06 3184 146084121443                       160918.5+060921161413.5+055407 18.66 37.42 6.31  +1.15 +1.17         K2III              +0.029-0.012      -021                           
+6058   Gam1NorCD-4910474 146143226619                       160931.5-494905161700.9-500406333.04  0.39 4.99  +0.80 +0.51         F9Ia               -0.005-0.004 -.001-017                           
+6059          CP-52 9469 146145243544      W                160935.8-525007161720.9-530512330.98-01.81 6.33  +0.27 +0.14         A8IV               -0.059-0.058      -024           6.6  21.0       
+6060 18    ScoBD-07 4242 146233141066      W        7577    161011.0-080617161537.3-082210  4.70 29.16 5.50  +0.65 +0.17 +0.33   G2Va               +0.234-0.501 +.062+011V       2  7.7  25.8      *
+6061          BD-14 4383 1462541598213286           7578    161012.7-143555161551.5-145057359.07 25.04 6.09  +0.06  0.00         A0V                +0.009+0.004      -011V     106                  
+6062          CP-57 7821 146323243586              S Nor    161034.4-573910161851.9-575359327.75-05.40 6.49  +1.00 +0.66 +0.57   F8-G0Ib             0.000-0.001      +005V                         *
+6063 17Sig CrBBD+34 2750 146361 65165        9979A TZ CrB   161055.9+340642161440.8+335131 54.67 46.14 5.64  +0.51  0.00         G0VCaIIe           -0.271-0.079 +.045-011SB2O=< 25  1.0   6.4AB   4*
+6064 17Sig CrBBD+34 2750 146362              9979B          161055.9+340642161440.8+335130 54.67 46.14 6.66H                     G1V                -0.271-0.079 +.045-017V?  =< 30  1.0   6.4AB   4*
+6065 16    HerBD+19 3075 146388102040                       161102.7+190338161528.7+184830 34.13 42.62 5.69  +1.12 +1.01         K3III              -0.064-0.077 +.010-018V                          
+6066          BD-20 4454 146416184285                       161105.1-210318161658.8-211814353.98 20.60 6.61  +0.02 -0.15         B9V                -0.015-0.016      -008V?    300:                *
+6067          BD-03 3910 146514141075                       161139.6-034220161655.3-035712  9.03 31.52 6.18  +0.31 +0.02         A9Vn               +0.040+0.009      -008V?                         
+6068          BD+27 2613 146537 84269                       161142.5+274020161547.4+272520 45.63 44.93 6.14  +1.31               K2                 -0.029-0.033      -011                           
+6069          BD+67  930 146603 16993                       161202.5+672351161225.1+670839100.03 39.88 6.21  +0.99 +0.72         G8III              -0.023-0.043      -010                           
+6070          CD-2812037 1466241843013288                   161205.6-282155161817.9-283650348.56 15.41 4.78  +0.02  0.00 -0.05   A0V                -0.028-0.099 +.031-013       35                  
+6071   Lam NorCD-4211188 146667226650      W                161219.9-422544161917.7-424026338.50  5.40 5.45  +0.10               A3Vn               +0.016-0.011      -015V          0.8   0.3      *
+6072   Gam2NorCD-4910536 146686243643 604I'W                161221.3-495437161950.4-500920333.30  0.01 4.02  +1.08 +1.16 +0.58   G8III              -0.155-0.053 +.044-029    =< 12  6.0  44.9      *
+6073          CP-54 7493 146690243654                       161225.8-545346162025.2-550824329.86-03.59 5.77  +0.97               K0III              +0.019-0.021      -000                           
+6074 18Ups CrBBD+29 2803 146738 842813287    9990   7596    161244.4+292351161644.8+290901 48.09 45.06 5.78  +0.07 +0.10  0.00   A3V                +0.023-0.016      +007SB?    80  4.3 123.4AD   5*
+6075  2Eps OphBD-04 4086 146791141086 605I W                161301.7-042656161819.3-044133  8.56 30.81 3.24  +0.96 +0.75 +0.49   G9.5IIIbFe-0.5     +0.085+0.041 +.043-010V    < 17  9.1 110.6      *
+6076          BD-19 4357 146834184309                       161316.2-195826161907.7-201304355.21 20.95 6.29  +1.08 +0.78 +0.62   K5III              +0.011-0.005      +008V                         *
+6077          CD-3013041 1468362075581426  W     A          161313.1-303951161932.7-305424347.03 13.63 5.49  +0.47 -0.01         F6III              +0.085+0.023 +.030-008SB      0  1.6  23.2      *
+6078          BD-14 4398 146850159846    I                  161321.5-143745161900.4-145221359.59 24.44 5.94  +1.52 +1.95         K4III              -0.028+0.015      -042SB                         
+6079 19    UMiBD+76  594 146926  8446 606                   161340.1+760746161049.5+755239109.67 35.61 5.48  -0.11 -0.36         B8V                -0.001+0.013      -001V                          
+6080          CD-3910412 146954207574      W                161346.7-391115162032.6-392551340.98  7.53 6.12  -0.07 -0.22         B9V                -0.012-0.064      +003           4.7  15.6       
+6081 19Omi ScoCD-2312849 147084184329    I          7632    161437.0-235542162038.2-241010352.33 18.05 4.55  +0.84 +0.62 +0.84   A5II              v-0.003-0.023 +.005-008        7                 *
+6082 20    UMiBD+75  586 147142  8452                       161502.6+752731161232.2+751238108.91 35.88 6.39R                     K2IV               -0.041+0.034      -026V?                         
+6083          CD-4910591 147152226693                       161459.5-492000162228.0-493420334.01  0.13 5.33  -0.04 -0.23         B6IV               -0.011-0.024      -010      190                 *
+6084 20Sig ScoCD-2511485 147165184336 607I  10009  Sig Sco  161506.5-252110162111.3-253534351.31 17.00 2.89  +0.13 -0.70 +0.11   B1III              -0.010-0.021      +003SBO    53  2.0   0.0 O   4*
+6085          CD-4310724 147225226696      W                161525.8-434027162228.9-435444338.03  4.11 5.88  +1.16 +0.83         G3II               -0.027-0.014      -011           3.8  40.7      *
+6086          BD+60 1665 147232 298743291I         AT Dra   161535.1+595951161715.3+594518 90.74 42.32 5.40  +1.63 +1.67         M4IIIa             +0.007+0.028      -036V?                        *
+6087          BD+21 2902 147266 84306                       161543.9+212226162004.3+210757 37.59 42.35 6.05  +0.94 +0.64         G8IIIb             -0.017-0.050      -025V?                         
+6088          BD+73  713 147321  84623289                   161611.7+733822161433.5+732342106.90 36.71 5.98  +0.08 +0.15         A3V                -0.005+0.040      -015                           
+6089          CP-62 5325 147349253539                       161616.7-625331162522.0-630729324.55-09.63 6.15  +0.03               A1V                -0.027+0.023      +031                           
+6090          BD+49 2491 147352 460253292I                  161623.5+491639161911.2+490217 76.31 44.75 5.91  +1.37              gK6                 -0.023+0.033      -032                           
+6091          BD+40 3005 147365 652333293  W                161629.5+395652161955.1+394231 63.12 45.37 5.46  +0.40 -0.08         F3IV-V             -0.132+0.004 +.043-029V      50  4.5   2.2      *
+6092 22Tau HerBD+46 2169 147394 46028 608   10010   7641    161644.0+463305161944.4+461848 72.48 45.04 3.89  -0.15 -0.56 -0.17   B5IV               -0.011+0.040 +.030-014V?     32 10.7   6.7      *
+6093 50Sig SerBD+01 3215 1474491215401427                   161700.4+011550162204.4+010145 14.78 33.22 4.82  +0.34 +0.04 +0.15   F0V                -0.155+0.050 +.043-050V?     80                 *
+6094          CD-3810983 1475132076223295           7680    161714.7-385733162401.3-391135341.62  7.21 5.40  +0.62 +0.15         G5V                +0.075+0.001 +.054+010                          *
+6095 20Gam HerBD+19 3086 147547102107 609I  10022   7667    161730.4+192316162155.2+190911 35.26 41.30 3.75  +0.27 +0.18 +0.14   A9III              -0.047+0.043 +.024-035SB    141  6.4  41.6AB   3*
+6096          BD-01 3174 147550141129                       161727.4-015040162238.9-020447 11.79 31.41 6.23  +0.07 -0.02         B9V                -0.013+0.003      -016                           
+6097          CD-3211687 147553207625      W     A          161730.4-325754162356.7-331158345.99 11.37 6.47  +0.01 -0.02         A0V+A0V            -0.016-0.031D+.009-002           0.5   6.3AB   3*
+6098   Zet TrACP-69 2558 147584253554 610                   161742.5-695132162828.1-700504319.53-14.57 4.91  +0.55 +0.04 +0.28   F9V                +0.196+0.108 +.094+009SBO                       *
+6099          CD-4510633 147614226730      W                161744.1-450700162454.2-452057337.31  2.80 6.33  +0.19               A2-3V              +0.024-0.001      +001V          6.0   5.3       
+6100          CD-3710778 147628207637      W                161751.5-371957162431.7-373357342.87  8.27 5.42  -0.11 -0.40         B8IV               -0.020-0.024      +009V     160: 0.1   0.1      *
+6101          BD+68  868 147662 17036                       161811.8+684733161809.4+683316101.34 38.77 6.41R                     K0                 -0.044+0.047 -.004-011                           
+6102   Gam ApsCP-78 1103 147675257407 611                   161806.0-784021163327.0-785350312.69-20.51 3.89  +0.91 +0.62         G8-K0III           -0.131-0.076 +.056+005SB                         
+6103 19Xi  CrBBD+31 2845 147677 652543294I W                161812.0+310726162205.8+305331 50.77 44.21 4.85  +0.97 +0.80 +0.46   K0III              -0.096+0.109 +.016-029     < 17  7.4 185.1      *
+6104  4Psi OphBD-19 4365 147700159892    I                  161815.0-194812162406.2-200215356.17 20.18 4.50  +1.01 +0.82 +0.50   K0II-III           -0.027-0.047 -.002+000     < 17                  
+6105          CD-2912513 147722184368       10035B          161822.7-292807162439.6-294212348.72 13.65 6.63  +0.59 +0.11         G0IV               +0.063-0.102D+.036-000           0.8   5.2      *
+6106          CD-2912513 147723184369       10035A          161822.8-292814162439.7-294217348.72 13.65 5.84  +0.59 +0.13         G0IV               +0.066-0.080D+.036-003           0.8   5.2      *
+6107 20Nu 1CrBBD+34 2773 147749 65257    I W        7676    161835.5+340204162221.4+334757 54.82 44.55 5.20  +1.60 +1.94 +0.87E  M2IIIab            +0.007-0.037 +.003-013V          0.1 364.4AB   4 
+6108 21Nu 2CrBBD+34 2774 147767 65259    I                  161843.1+335610162229.2+334213 54.69 44.51 5.39  +1.53 +1.88 +0.87   K5III              -0.007+0.059 +.021-040V    < 17                  
+6109   Iot TrACP-63 3923 147787253555      W                161839.7-634950162757.3-640329324.06-10.48 5.27  +0.36 -0.02         F4IV               +0.046+0.027 +.029-005SBO     0  4.1  19.6      *
+6110          BD+32 2716 147835 652621428   10031           161906.1+323359162256.5+321959 52.80 44.25 6.40  +0.08 +0.11         A4Vn               +0.023-0.007      -001SB    232  2.9  32.4      *
+6111 21    HerBD+07 3164 1478691215681429                   161918.5+071045162410.8+065653 21.30 35.77 5.85  -0.01 +0.01         A2pSr:             +0.003+0.014      -033SB1O                      *
+6112  5Rho OphCD-2312861 147933184382       10049A          161935.2-231301162535.2-232650353.69 17.69 5.02  +0.24 -0.55 +0.31   B2IV               +0.002-0.018D+.013-010V     303  0.7   3.2AB   5*
+6113  5Rho OphCD-2312861 147934184381       10049B          161935.2-231257162535.1-232646353.69 17.69 5.92H                     B2V                -0.007-0.017D+.013-010      300  0.7   3.2AB   5*
+6114          CP-58 6800 1479772438363297                   161948.9-582220162815.2-583559328.12-06.78 5.69   0.00               B9II-III           -0.021-0.038      +002                           
+6115   Eps NorCD-4710765 147971226773      W                161950.9-471936162711.1-473318336.00  0.98 4.47  -0.07 -0.53 -0.04   B4V                -0.005-0.030      -012SB2O  165  2.7  22.8      *
+6116 21Eta UMiBD+76  596 148048  8470 612  W                162025.2+755909161730.3+754519109.27 35.33 4.95  +0.37 +0.08         F5V                -0.085+0.252 +.043-010V      76 10.8 227.       *
+6117 24Ome HerBD+14 3049 148112102153 613   10054  Ome Her  162048.0+141548162525.0+140200 29.46 38.63 4.57   0.00 -0.04 -0.04   B9pCr              +0.044-0.059 +.041-006V      38  8.1  28.4AC   4*
+6118  7Chi OphBD-18 4282 1481841599183298I         Chi Oph  162113.6-181346162701.4-182723357.93 20.68 4.42  +0.28 -0.75 +0.22   B2IV:pe           v-0.002-0.022      -003SB1O  134                 *
+6119          BD+19 3098 148206102160    I         U Her    162122.2+190712162547.7+185333 35.35 40.35 6.7               +2.95   M7IIIe             +0.022-0.003 +.010-028V?                        *
+6120          CP-57 8035 148218243874                       162124.5-573200162945.0-574521328.87-06.34 6.06  +1.48               G8Ib               -0.018+0.015      +005                           
+6121          BD+11 2984 148228102165                       162129.2+113802162611.5+112427 26.53 37.36 6.11  +1.03               G8III              -0.031+0.014      -021                           
+6122          CD-3610783 148247207688                       162134.6-365717162814.7-371046343.67  8.00 5.79  +1.10               K1IIICNII          +0.033-0.008      -014                           
+6123 25    HerBD+37 2750 148283 652903296  S                162150.3+373718162524.2+372338 59.90 44.23 5.54  +0.17 +0.09         A5V                +0.006-0.012      -001V     242        0.2      *
+6124          BD+02 3106 148287121604                       162147.7+023427162650.1+022051 16.87 32.91 6.07  +0.92 +0.61         G8III              +0.023-0.027      +004V?                         
+6125          CP-61 5701 1482912535823302                   162156.0-612443163049.4-613801326.10-09.08 5.20  +1.23               K0II-IIICNIb-II    -0.013-0.013 +.006+004V?                         
+6126          BD+69  845 148293 17062    I                  162202.2+692026162148.7+690634101.80 38.23 5.25  +1.12 +1.11 +0.53   K2III              -0.019-0.004 +.009-008V    < 19:                 
+6127          BD+55 1845 148330 29931 614          DQ Dra   162214.0+552557162425.3+551218 84.45 42.72 5.74   0.00 +0.01         A2Si3955 Sr       v+0.012+0.023      -004V      10                 *
+6128          BD-07 4292 148349141186    I         V2105 Oph162220.0-072210162743.5-073553  7.43 27.22 5.23  +1.72 +2.07 +1.29   M3-III             +0.014-0.155 +.008+099V?                        *
+6129  3Ups OphBD-08 4243 1483671411873299  W        7738    162223.5-080853162748.1-082218  6.74 26.74 4.63  +0.17 +0.08 +0.09   A3m                -0.087+0.021 +.028-031SBO    44  3.2   1.1      *
+6130          BD+62 1478 148374 17073       10052           162227.5+615526162347.0+614148 92.82 40.91 5.67  +0.96               G8III              -0.037+0.034D+.003-024V?         1.0   1.1      *
+6131          CD-4510697 1483792268133301          QU Nor   162227.4-460116162942.3-461436337.25  1.58 5.35  +0.56 -0.44 +0.47   B1.5Iape           -0.001-0.005      -012V      66                 *
+6132 14Eta DraBD+61 1591 148387 17074    I  10058   7713    162238.1+614426162359.5+613051 92.58 40.95 2.74  +0.91 +0.70 +0.46   G8-IIIab           -0.017+0.061 +.051-014SB?  < 17  4.8 564.9ABxC 3*
+6133          CP-87  259 148451258754                       162251.2-872333171559.3-873359305.41-26.12 6.57  +0.91 +0.56         G5III              -0.119-0.155      -004                           
+6134 21Alp ScoCD-2611359 148478184415 616I  10074  Alp Sco  162316.4-261236162924.4-262555351.95 15.06 0.96  +1.83 +1.34 +1.23   M1.5Iab-Ib+B4Ve    -0.010-0.020 +.024-003SB  =< 20  4.2   2.9      *
+6135          CP-70 2256 1484882574093306                   162316.8-704619163419.3-705917319.16-15.53 5.50  +1.22 +1.24         K1IIICNIa-Ib       -0.017-0.013      -017                           
+6136          BD+00 3529 1485131216233300I                  162328.2+005320162834.0+003954 15.44 31.66 5.39  +1.46 +1.80 +0.78   K4IIIp             +0.004-0.067 +.006+007V   =< 19:                *
+6137          BD-07 4299 148515141195       10072           162324.6-075418162848.9-080744  7.13 26.69 6.48  +0.40 +0.02         F2V                -0.058-0.073      +000SB         3.1   5.4AB   3*
+6138          CP-82  687 148527258748                       162330.8-830212164553.6-831420309.22-23.47 6.57 ?+1.57?              K4III              +0.009+0.013      -017                           
+6139          CP-86  333 148542258751 921                   162334.7-861043170058.5-862152306.50-25.40 6.04  +0.05 +0.02         A2V                +0.005-0.001      +007       89                  
+6140          BD-14 4433 1486041599481430                   162407.7-141953162946.9-143303  1.65 22.62 5.68  +0.82               G2-6III            +0.037+0.014      -031                           
+6141 22    ScoCD-2412695 148605184429                       162407.8-245342163012.4-250654353.10 15.80 4.79  -0.11 -0.72 -0.14   B2V                -0.008-0.022      +004V     232                 *
+6142          CD-4110695 148688226855      W        7781    162444.7-413600163141.7-414901340.72  4.35 5.33  +0.33 -0.77 +0.30   B1Iae             v-0.016 0.000      -014       93  4.3  58.0AC   3*
+6143          CD-3411044 1487032077321431                   162450.7-342911163122.9-344216345.94  9.22 4.23  -0.16 -0.80 -0.15   B2III-IV           -0.009-0.017      +001SB     90                 *
+6144          BD-07 4305 148743141206                       162506.6-071748163029.9-073054  7.96 26.71 6.50  +0.37 +0.20         A7Ib               -0.015-0.011      +002SB?    30                 *
+6145          CD-2611379 148760184437                       162514.4-261912163122.8-263216352.17 14.66 6.10  +1.08               K1III              -0.029-0.034      +039V                          
+6146 30    HerBD+42 2714 148783 461083303I         g Her    162521.4+420606162838.5+415254 66.16 43.72 5.04  +1.52 +1.17 +2.23   M6-III             +0.030-0.009 +.018+003                          *
+6147  8Phi OphBD-16 4298 148786159963    I  10086           162524.8-162341163108.3-163646  0.13 21.08 4.28  +0.92 +0.72 +0.44   G8+IIIa            -0.051-0.035 +.014-034V    < 19: 6.8 120.0AC   3*
+6148 27Bet HerBD+21 2934 148856 84411 618I W        7778    162555.2+214227163013.2+212923 39.01 40.21 2.77  +0.94 +0.69 +0.47   G7IIIa             -0.098-0.015 +.024-026SB1O < 19: 7.3 256.2      *
+6149 10Lam OphBD+02 3118 148857121658       10087   7784    162552.1+021210163054.8+015902 17.12 31.85 3.82  +0.01 +0.01 -0.01   A0V+A4V            -0.027-0.073 +.010-014SB    127  1.0   1.2AB   4*
+6150          BD+51 2106 148880 299563304   10079           162610.3+513735162843.4+512428 79.20 42.86 6.29  +1.05               G9III              +0.034+0.006      -016           6.6   5.9       
+6151   The TrACP-65 3331 1488902536143312                   162606.8-651701163544.8-652943323.54-12.06 5.52  +0.93 +0.73         G8-K0III           +0.032-0.029 +.014+010                           
+6152          BD+20 3283 148897 84416    I          7785    162613.0+204152163033.6+202845 37.79 39.82 5.25  +1.29 +1.22 +0.70   G8IIICN-2CH-1      -0.078-0.063 +.000+019V?   < 17                 *
+6153  9Ome OphBD-21 4381 1488981844503307          Ome Oph  162612.4-211509163208.2-212759356.30 17.83 4.45  +0.13 +0.13 +0.02   A7p                +0.028+0.039 +.028+003       41                 *
+6154          BD+22 2983 149009 84423    I                  162656.6+222437163113.4+221143 39.98 40.21 5.76  +1.61              gK5                 -0.012+0.003      -026V                          
+6155   Mu  NorCD-4310900 1490382269003311          Mu  Nor  162658.5-435000163405.0-440243339.38  2.51 4.94  +0.05 -0.94         B0Ia               +0.005-0.004      +009V?    147                 *
+6156 34    HerBD+49 2514 149081 46128                       162721.2+491043163006.0+485739 75.86 42.99 6.45  +0.03  0.00         A1V                -0.048-0.062      -008       59                  
+6157          BD+35 2828 149084 653563308I                  162722.8+352625163102.8+351330 57.05 42.92 6.25  +1.64 +1.89         K5                 -0.008-0.016      +024                           
+6158 28    HerBD+05 3223 1491211216763309                   162740.3+054403163235.7+053116 21.01 33.25 5.63  -0.06 -0.18         B9.5III            +0.015+0.001      -027        5                  
+6159 29    HerBD+11 3008 1491611022343310I          7812    162755.4+114210163236.3+112917 27.46 35.97 4.84  +1.49 +1.83 +0.86   K7III              -0.180-0.078 -.012+003     < 19:                *
+6160          CD-4410964 149174226926               7829    162756.3-450159163507.9-451441338.62  1.56 6.46  +1.34               K2-3III            -0.022-0.073      -056                          *
+6161 15    DraBD+69  850 149212 17107 619                   162810.5+685904162759.0+684605101.11 37.87 5.00  -0.06 -0.12 -0.02   A0III              -0.025+0.036 +.014-007V     160                  
+6162          BD+45 2422 149303 46147       10105           162846.5+454835163147.3+453554 71.24 43.01 5.65  +0.12 +0.13         A4Vn               -0.007+0.043D+.022-016V          3.3  16.3       
+6163   Bet ApsCP-77 1221 1493242574243319  W                162847.1-771829164304.6-773103314.18-20.06 4.24  +1.06 +0.95 +0.37E  K0III              -0.287-0.350 +.034-030           7.8  51.1      *
+6164          CD-4211399 149404226953              V918 Sco 162920.4-423908163622.5-425132340.54  3.01 5.47  +0.40 -0.63 +0.35   O9Ia              e-0.006-0.009      -036SBO   140                 *
+6165 23Tau ScoCD-2711015 149438184481 620                   162939.3-280031163553.0-281258351.54 12.81 2.82  -0.25 -1.03 -0.25   B0V                -0.008-0.022 +.020+002V      24                 *
+6166          CD-3411112 149447207814    I          7844    162947.5-350258163622.5-351520346.22  8.09 4.16  +1.57 +1.94 +1.00   K6III              +0.022 0.000 +.022-002V?                         
+6167          CP-60 6594 149485253638                       163001.8-604711163852.7-605925327.24-09.37 6.18  -0.08 -0.39         B7Vn               -0.005-0.023      -007      375                  
+6168 35Sig HerBD+42 2724 149630 46161 621  S        7837    163052.7+423836163406.2+422613 66.91 42.70 4.20  -0.01 -0.10 -0.01   B9V                -0.011+0.046 +.010-011      270  3.    0.1      *
+6169          BD+17 3053 1496321022593313  W                163057.3+171548163526.3+170326 34.18 37.56 6.41  +0.05  0.00         A2V                -0.007-0.004      -009SB2O   71  1.0 156.6      *
+6170          BD+61 1598 149650 171301432                   163100.7+610158163225.7+604924 91.30 40.20 5.94  +0.02 +0.05         A2V                +0.022-0.010      -009V      80                  
+6171 12    OphBD-02 4211 1496611412691433          V2133 Oph163106.2-020640163621.5-021929 13.73 28.42 5.75  +0.82 +0.48 +0.39   K2V                +0.458-0.310 +.093-015V                         *
+6172   Eta1TrACP-68 2789 149671253649                       163103.9-680548164123.3-681746321.70-14.29 5.91  -0.08 -0.42         B7IVe              -0.006-0.012      -043SB?                        
+6173          BD+79  498 149681  85273305                   163117.3+791038162543.1+785750112.31 33.28 5.56  +0.26 +0.05         F0V                -0.115+0.108 +.028-012                           
+6174          CD-4310959 149711226989      W                163121.6-431145163826.2-432355340.39  2.37 5.83  -0.02 -0.59         B2.5IV             -0.022-0.027      +001           3.2  16.3      *
+6175 13Zet OphBD-10 4350 149757160006 622I         Zet Oph  163139.0-102153163709.5-103402  6.28 23.59 2.56  +0.02 -0.86 -0.04   O9.5Vn            t+0.014+0.026 +.003-015V     379                 *
+6176          BD+15 3029 149822102271              V773 Her 163210.4+154205163643.0+152953 32.51 36.69 6.30  -0.11 -0.18         B9pSiCrSr:         -0.009-0.008      +000       85                 *
+6177          CP-60 6603 149837253651      W                163203.0-601444164050.5-602646327.81-09.20 6.18  +0.48               F2III-IV           +0.051-0.070      +004           2.7   1.4       
+6178          CD-3610879 1498862078783317  W                163223.5-370058163905.2-371303345.10  6.38 5.91   0.00 -0.12         B9-A0V+B           -0.012-0.047      +003           0.0   0.1AB   3*
+6179          BD-06 4467 1499111412843315          Var      163240.1-062012163801.6-063217 10.04 25.74 6.09  +0.16 +0.13         A0pCrEu           v-0.007-0.008      -022                          *
+6180          BD+72  734 150010  8544                       163300.0+724908163128.1+723643105.32 35.99 6.30  +1.32 +1.29         K2III              -0.043+0.041 +.011-033                           
+6181          BD+13 3177 1500121022783316                   163311.4+135322163748.0+134113 30.58 35.73 6.31  +0.41 +0.02         F5IV               -0.035-0.063      -021       30                 *
+6182          CP-67 3196 150026253673                       163314.5-671414164322.1-672557322.52-13.89 6.03  +0.02 +0.02         A0Vn               +0.012-0.037      -002                           
+6183          BD+46 2194 150030 461843314                   163316.1+464856163611.2+463648 72.55 42.19 5.79  +1.04 +0.88?        G8II               -0.011+0.004      -015                           
+6184 16    DraBD+53 1875 150100 30012       10129C          163349.4+530604163611.5+525401 80.94 41.48 5.53  -0.07 -0.15         B9.5Vn             -0.009+0.033D+.010-009V      83  0.0  90.3AC   4*
+6185 17    DraBD+53 1876 150117 30013       10129A          163351.9+530731163613.7+525528 80.97 41.48 5.08  -0.04 -0.15         B9V                -0.009+0.027D+.010-010V     216  0.0  90.3AC   4*
+6186 17    DraBD+53 1876 150118             10129B          163351.2+530730163614.1+525527 80.97 41.48 6.53  -0.06 -0.16         A1Vnn              -0.009+0.027D+.010-018      250  0.0  90.3AC   4*
+6187          CD-4811070 150136227049      W     A          163350.8-483401164120.3-484547336.71-01.57 5.65  +0.13 -0.80         O5III(f)           -0.008-0.003D+.007+023SB    152  1.2   9.6AC   6*
+6188          CD-4910890 1501682270583321                   163406.0-492722164140.2-493906336.08-02.20 5.65  -0.03 -0.87         B1Iab-Ib           -0.001-0.007      +006SB    154                 *
+6189          BD-09 4430 150177141298                       163410.8-092111163939.1-093316  7.57 23.68 6.35  +0.48 -0.07         F3V                +0.007-0.145      -019V   =< 15                  
+6190          BD-20 4537 150259184541    I:                 163440.7-201249164034.5-202431358.46 16.97 6.26  +1.08              gG9                 +0.012+0.034      +033V?                         
+6191          BD+77  627 150275  8548 623                   163456.2+773844163038.8+772648110.58 33.82 6.34  +1.00 +0.71         K1III              -0.104+0.276 +.017-032V?                        *
+6192          CD-3211913 150331207930                       163517.0-325701164145.5-330847348.57  8.64 5.87  +0.65 +0.24         G3III              -0.059-0.083      -008                           
+6193          CD-2412765 1503661845493322                   163532.4-241627164136.2-242805355.34 14.23 6.09  +0.20 +0.06 +0.10   F0V                -0.049-0.008      -047       34                  
+6194 36    HerBD+04 3234 150379121774       10149B          163537.2+042408164035.1+041226 20.79 30.87 6.93  +0.13 +0.12         A3IV               -0.002-0.011 +.001-028V?     80  1.2  69.6AB   4*
+6195 37    HerBD+04 3235 150378121776       10149A          163540.7+042453164038.7+041311 20.82 30.87 5.77  -0.02 -0.03         A1V                -0.001-0.013 +.001-034      140  1.2  69.6AB   4*
+6196          BD-17 4618 150416160046 624I                  163547.3-173255164134.4-174432  0.82 18.43 4.96  +1.11 +0.87 +0.60   G7.5IICN1Ba0.4     -0.020-0.001 +.047-025     < 19:                *
+6197          CD-4510858 150421227092                       163546.3-455242164303.4-460414338.93-00.02 6.23  +0.85 +0.59         F5Iab              -0.015-0.018      -016                          *
+6198          BD+63 1289 150429 17165    I                  163554.4+631626163655.0+630422 93.89 39.03 6.16  +1.53               K5                 +0.004-0.087      -042                           
+6199          BD+56 1907 150449 300263320I                  163559.1+561239163800.4+560056 84.94 40.67 5.29  +1.08 +0.90 +0.52   K1III               0.000+0.066 +.015-019V?   < 17                  
+6200 42    HerBD+49 2531 150450 462101434I  10144   7896    163601.9+490726163844.9+485542 75.61 41.58 4.90  +1.55 +1.76 +0.90E  M2.5IIIab          -0.047+0.031 +.017-055           5.4  25.6      *
+6201          BD-00 3168 150451141310                       163602.1-004823164111.5-010002 15.73 28.10 6.24  +0.30 +0.07 +0.18   A7III              +0.006-0.015      -012       64                  
+6202          BD-19 4406 150453160052    I:W                163600.9-194358164153.7-195528359.06 17.02 5.57  +0.43               F4IV-III           +0.022+0.041      +005           8.0  22.5       
+6203          BD+12 3063 150483102314                       163611.9+123520164051.4+122342 29.51 34.53 6.08  +0.05 +0.03         A3Vn               -0.026-0.010      -032V?    230                  
+6204          CP-66 3009 150549253688      W       LP TrA   163635.9-665521164640.0-670635322.98-13.93 5.13  -0.08 -0.45         ApSi               -0.014-0.015 +.005-002       56  6.2  25. AB   3*
+6205 14    OphBD+01 3290 1505571217903324                   163638.5+012220164142.5+011052 17.93 29.12 5.74  +0.32 +0.07         F2-4III-IV         -0.097+0.051 +.030-045       67                 *
+6206          CD-4010649 150573227118      W                163649.2-405543164345.5-410708342.75  3.13 6.20  +0.14 +0.17         A4V                -0.046-0.016      -026           0.1  95.7      *
+6207          CP-5210161 1505762441063327  W                163645.3-525747164439.8-530909333.74-04.85 5.96  +1.26               G8III              -0.009-0.018      -002V          6.0  40.        
+6208          BD+25 3115 150580 845363323I                  163651.7+250306164100.6+245131 44.12 38.82 6.06  +1.31               K2                 -0.034 0.000      -068                           
+6209          CD-4010653 150591227123      W                163657.4-405524164353.9-410647342.77  3.12 6.12  -0.07 -0.52         B6-7V              -0.026-0.013      -002           0.1  95.7      *
+6210          CD-3710942 150608207966      W                163701.9-375756164347.6-380924345.01  5.06 6.05  -0.06               B9II-III           -0.009-0.049      +007           6.2  50.0       
+6211          CD-3113161 1506382079673325                   163712.8-315457164338.7-320622349.63  9.01 6.46  -0.08               B8V                -0.002-0.023      -003V?                         
+6212 40Zet HerBD+31 2884 150680 65485    I  10157   7915    163730.9+314701164117.2+313611 52.66 40.28 2.81  +0.65 +0.21 +0.32   G0IV               -0.470+0.394 +.102-070SB1O=< 10  2.6   1.1      *
+6213 39    HerBD+27 2668 150682 84543      S                163733.2+270634164136.7+265501 46.72 39.22 5.92  +0.40 -0.07         F2III              +0.002-0.044      -012SB2O             0.1      *
+6214          CD-4010661 1507422271463329  W                163746.9-403905164442.6-405023343.08  3.18 5.71  -0.12 -0.63         B3V                -0.010-0.024      +012           6.3   8.       *
+6215          CP-58 6889 150745244122                       163748.9-581903164621.2-583013329.77-08.48 5.74  -0.09               B2IV-V             -0.008-0.016      -016      219                  
+6216          CD-2711103 150768184591       10173   7935    163804.9-271606164417.3-272722353.35 11.87 6.58  +0.10               A2V                -0.019-0.007D+.012-026           4.0   2.0AB   3*
+6217   Alp TrACP-68 2822 150798253700 625                   163804.3-685038164839.9-690140321.54-15.26 1.92  +1.44 +1.56         K2IIb-IIIa         +0.014-0.034 +.031-003                           
+6218          CD-2812358 150894184602      W        7944    163844.8-281924164500.2-283035352.63 11.08 6.02  +0.09               A3IV               -0.028+0.001      -055           7.7   5.6       
+6219          CP-58 6893 150898244133                       163848.4-580927164719.5-582029329.98-08.47 5.58  -0.08 -1.00         B0.5Ia             -0.019-0.020      -053V     128                 *
+6220 44Eta HerBD+39 3029 150997 65504 626I W        7934    163928.0+390644164253.8+385520 62.28 40.90 3.53  +0.92 +0.60 +0.48   G7.5IIIbFe-1       +0.037-0.083 +.034+008V?      8      113.5      *
+6221          CD-3910677 151078208020                       163957.4-391137164647.8-392238344.46  3.82 5.48  +0.98               K0III              -0.032-0.034      -009                           
+6222          BD+34 2830 151087 655123330                   164010.2+341323164351.7+340220 55.92 40.16 5.99  +0.29 +0.06         F2-3III-IV         -0.071+0.058      -010V?                         
+6223 18    DraBD+64 1145 151101 171883326I                  164013.4+644643164055.1+643521 95.57 38.16 4.83  +1.22 +1.26 +0.61   K0III*             +0.001-0.013 +.009+000     < 19:                *
+6224 16    OphBD+01 3298 151133121834                       164024.7+011213164529.7+010113 18.32 28.22 6.03  -0.02 -0.14         B9.5III            +0.002+0.013      -013V     100                  
+6225 25    ScoCD-2511667 151179184630                       164043.9-252047164651.3-253143355.26 12.64 6.71  +1.18              gG6                 -0.005-0.014      +002V                          
+6226          BD+55 1872 151199 30062               7945    164055.7+555226164258.4+554125 84.35 40.04 6.16  +0.07 +0.11         A2VpSr             +0.049+0.085      -045V     110                  
+6227          BD+16 3013 151203102365    I          7950    164050.7+155548164522.5+154443 33.78 34.86 5.56  +1.66               M3IIIab            +0.027-0.043 +.023-019V?                         
+6228 43    HerBD+08 3271 1512171218433332I W        7952    164101.7+084553164549.9+083457 26.03 31.77 5.15  +1.53 +1.94 +0.90   K5III               0.000+0.015 +.010-021V    < 17  3.9  82.5AB   3 
+6229   Eta AraCP-58 6906 1512492441681435  W                164108.8-585146164947.1-590229329.64-09.16 3.76  +1.57 +1.94         K5III              +0.038-0.028 +.025+009           9.5  23.6       
+6230          BD+43 2642 151388 46262    I                  164203.5+432402164511.7+431302 67.98 40.67 6.05  +1.40               K4III              -0.015-0.045      -013SB                         
+6231          CP-67 3232 151404253718                       164203.3-673022165217.4-674055322.86-14.71 6.32  +1.28 +1.51         K2III              -0.073-0.064      +008                           
+6232 19    OphBD+02 3175 1514311218591436   10207   7962    164207.2+021441164709.8+020352 19.58 28.39 6.10  +0.14 +0.14         A3V                -0.010-0.014      -006SB2        3.6  23.4AB   3 
+6233          CP-65 3365 1514412537173337                   164210.7-651203165153.9-652232324.72-13.28 6.13  -0.02 -0.28         B8II-III           -0.004-0.014      -010                           
+6234 45    HerBD+05 3272 1515251218653333  W       V776 Her 164250.9+052534164746.4+051448 22.85 29.80 5.24  -0.02 -0.02         B9pCr:             -0.016-0.041 +.014-016SB     42  5.2 122.7      *
+6235          BD-14 4486 1515271601043335                   164246.1-144354164827.0-145434  4.25 18.81 6.03  +0.20               A0Vn               -0.011-0.004      -026V     139                 *
+6236          CD-4910998 151566227281      W                164257.7-495212165035.9-500244336.71-03.55 6.47  +0.31 +0.07         A5III+F7III        -0.018-0.023D+.008+025           0.1   3.2      *
+6237          BD+57 1702 151613 30076 627  S                164323.9+565738164517.8+564655 85.67 39.53 4.85  +0.38 -0.06 +0.21   F2V                +0.018+0.066 +.046-004SBO    53                 *
+6238          BD+79  511 151623  8592                       164333.7+790622163752.9+785506111.93 32.79 6.32  +1.14 +1.20 +0.58   G9III              -0.020+0.038 +.047-020                           
+6239          BD+13 3225 151627102393                       164332.2+134604164808.9+133526 31.70 33.39 6.35  +0.87               G5III              +0.016-0.016      +001     < 20                  
+6240          BD-15 4395 151676160116              V1010 Oph164344.9-152935164927.8-154003  3.76 18.16 6.10                      A5V                +0.012+0.031      -002SBO   155                 *
+6241 26Eps ScoCD-3411285 151680208078 628           7983    164341.1-340642165009.8-341736348.82  6.56 2.29  +1.15 +1.27 +0.60   K2.5III            -0.611-0.255 +.022-003                           
+6242          BD+42 2749 151732 462883336I         V636 Her 164407.7+422501164719.8+421420 66.70 40.25 5.87  +1.61               M4+III-IIIa        +0.003-0.026      -007V?                        *
+6243 20    OphBD-10 4394 1517691601181438                   164418.0-103622164950.0-104659  8.04 20.93 4.65  +0.47 +0.07 +0.25   F7IV               +0.096-0.093 +.016-001SB1O   13                 *
+6244          CD-3711023 151771208089      W       Var?     164415.4-372028165059.8-373052346.42  4.39 6.11  +0.12 -0.14         B9pSi*             -0.029-0.009D+.006-017SB?        2.2   6.7      *
+6245          CD-4110957 151804227313               7992    164435.2-410331165133.7-411350343.62  1.94 5.22  +0.07 -0.84         O8Iaf              +0.001-0.001      -065V?    124                 *
+6246          BD+13 3233 151862102410       10225           164457.5+132608164934.6+131541 31.51 32.94 5.91  +0.03 -0.02         A1V                -0.029-0.021D+.013-023V?     74  4.0   5.3AB   4 
+6247   Mu 1ScoCD-3711033 1518902081021439          Mu1 Sco  164505.7-375233165152.2-380251346.12  3.91 3.08  -0.20 -0.87 -0.19   B1.5V+B6.5V        -0.011-0.025      -025SB2O  239  0.4 390.       *
+6248          BD-02 4259 151900141393                       164509.1-022850165022.3-023914 15.51 25.28 6.32  +0.42 -0.05         F1III-IV           +0.009-0.030      +031       40                  
+6249          CD-4110972 151932227328    I:        V919 Sco 164518.2-414103165219.1-415116343.22  1.43 6.49  +0.23 -0.65 +0.39   WN7-A              -0.018-0.001      +025V                         *
+6250 47    HerBD+07 3256 151956121895               7990    164528.0+072513165019.4+071452 25.23 30.18 5.49  +0.10 +0.11 +0.05   A3m                +0.053-0.011 +.025-004SB?    26                 *
+6251          CP-57 8157 151967244245                       164530.9-574417165400.5-575434330.88-08.89 5.94  +1.59 +1.92         M1III              -0.032-0.126      -041                           
+6252   Mu 2ScoCD-3711037 151985208116                       164533.6-375049165220.1-380103346.20  3.86 3.57  -0.21 -0.85 -0.22   B2IV               -0.011-0.024      +001V?     57  0.4 390.       *
+6253          CP-63 4032 152082253734      W                164604.7-630612165524.7-631611326.67-12.31 6.02  +0.05               A0III              +0.008-0.023      -009           6.9   7.       *
+6254 52    HerBD+46 2220 152107 46305       10227  V637 Her 164618.5+460927164914.2+455900 71.61 39.96 4.82  +0.09 +0.04 +0.01   A2VpSrCrEu        v+0.026-0.055 +.010-001V      31  4.6   1.8AxBC 5*
+6255 21    OphBD+01 3323 152127121911       10230           164620.5+012311165124.9+011258 19.35 27.04 5.51  +0.05 +0.03         A2V s              -0.023-0.005 +.021-026V      59  1.5   0.4      *
+6256          BD+43 2654 152153 46311                       164634.0+433609164940.5+432550 68.28 39.86 6.13  +1.26 +1.31         K0IV               -0.017-0.007      -020                           
+6257          CD-4211627 152161227359               8012    164636.4-425259165342.5-430303342.46  0.48 5.96  +1.73               M3II-III           -0.016-0.027      -012V?                        *
+6258 50    HerBD+30 2884 152173 846413339I                  164644.7+295837165039.0+294824 50.91 37.96 5.72  +1.60 +1.92         M1IIIa             -0.005 0.000      -010V                          
+6259          BD+32 2795 152224 65595                       164657.0+324321165043.1+323313 54.34 38.50 6.13  +1.01 +0.78         K0III              +0.019+0.046      -030SB                         
+6260          CD-4111024 152234227377      W                164700.7-413824165401.8-414823343.46  1.22 5.45  +0.19 -0.72         B0.5Ia             -0.008-0.008      -006SB     99  1.5   0.4AB   8*
+6261          CD-4111021 152235227374              V900 Sco 164657.0-414940165358.8-415941343.31  1.10 6.32  +0.50 -0.45         B1Ia              e-0.002-0.018      -036                          *
+6262   Zet1ScoCD-4211633 152236227375              Zet1 Sco 164656.3-421144165359.7-422144343.03  0.87 4.73  +0.49 -0.56         B1Iape            v+0.004-0.004      -026V      57                 *
+6263          CD-4111036 152249227383               8023    164710.3-414100165411.8-415101343.45  1.16 6.45  +0.20 -0.74         O9Ib               +0.012-0.039      -024SB2O  100                 *
+6264          BD+42 2753 152262 46317                       164723.8+420352165036.1+415348 66.29 39.63 6.29  +1.08              gK3                 -0.074+0.070      -037                           
+6265          CD-4111041 152270227390      W       Var?     164718.5-413915165419.6-414912343.49  1.16 6.59  +0.21 -0.54 +0.33   WC7+O5-8           -0.011-0.011      -044SB2O       6.6   4.3      *
+6266          CD-4211642 152293227392                       164723.0-421848165426.9-422844342.99  0.73 5.88  +0.64 +0.22         F5Ib-II            -0.003-0.005      -024V                         *
+6267          BD+77  634 152303  8612       10214           164732.8+774111164306.0+773051110.29 33.19 5.98  +0.42 -0.05         F4V                +0.048+0.212 +.030+007V?         3.3   2.6AB   3*
+6268 49    HerBD+15 3066 152308102435 629          V823 Her 164731.6+150831165204.9+145827 33.67 33.07 6.52  -0.05 -0.07         B9.5pCr:           +0.017+0.004      -023V?                         
+6269          BD-20 4572 152311184754                       164730.9-201454165325.2-202456  0.37 14.58 5.88  +0.68               G3V                -0.050-0.029      -017V?                         
+6270 51    HerBD+24 3069 152326 846511440I                  164736.5+244928165145.3+243923 44.73 36.42 5.04  +1.25 +1.29 +0.61   K0.5IIIaCa0.5      +0.011+0.006 +.010-016                           
+6271   Zet2ScoCD-4211646 152334227402               8028    164732.7-421124165435.0-422141343.10  0.79 3.62  +1.37 +1.65 +0.68   K4III              -0.124-0.236 +.028-019                          *
+6272          CD-4010919 152408227425      W        8031    164759.8-405912165458.4-410904344.08  1.49 5.77  +0.15 -0.75         O8:Iafpe           -0.017-0.013      -140V     140: 7.0   5.4      *
+6273          CD-3013594 152431208176                       164813.0-302523165436.0-303514352.31  8.16 6.35  +0.21 +0.17 +0.11   A7IIIm:            +0.039+0.002      +001V?                         
+6274          CD-5010905 152478244280               8047    164825.9-503044165608.9-504030336.78-04.64 6.33  -0.02               B3Vnep             -0.006-0.019      +019V?                        *
+6275          CP-5210333 152527244285                       164836.8-520716165628.7-521702335.55-05.68 5.94  -0.08               B9V                -0.045-0.046      -006                           
+6276          CP-69 2666 152564253756                       164849.5-690636165933.8-691606321.93-16.18 5.79  -0.10 -0.44         ApSi               -0.022-0.016      -001                           
+6277          BD-01 3268 152569141427      W                164859.7-012647165410.6-013644 17.04 25.01 6.25  +0.28 +0.11         F0V                +0.015-0.071      -020      176  7.0  15.0AB   3*
+6278          BD-11 4231 152585160159                       164906.2-113744165440.3-114733  7.87 19.37 6.57  +0.14               A2IV              e+0.022-0.013      -005                          *
+6279 53    HerBD+31 2925 152598 656271441  W                164910.4+315201165258.1+314206 53.39 37.87 5.32  +0.29 -0.02         F0-2V              -0.091-0.017 +.012-022       59  6.7  70.9       
+6280 23    OphBD-05 4374 1526011414313342I                  164914.9-055925165435.7-060914 12.89 22.52 5.25  +1.08 +1.06 +0.53   K2III              -0.031-0.020 +.021-017V?   < 19:                 
+6281 25Iot OphBD+10 3092 1526141024581442           8034    164916.5+101948165400.5+100955 28.73 30.66 4.38  -0.08 -0.32 -0.08   B8V                -0.051-0.036 +.029-021SB2   118                  
+6282          CD-3311570 152636208205                       164925.8-332045165557.8-333026350.19  6.12 6.37  +1.71 +2.06         K5III              +0.023-0.002      -093                           
+6283          CD-4010975 152667227473              V861 Sco 164938.3-403947165636.0-404925344.53  1.46 6.15  +0.26 -0.67         B0.5Ia            e+0.005-0.009      +004SB1O  161                 *
+6284          BD-16 4371 152781160171      W                165015.4-163849165601.8-164822  3.76 16.22 6.37  +0.92 +0.68         K0IV               +0.081+0.040      -003V?         7.3  21.4       
+6285   Zet AraCP-55 7766 152786244315 631                   165020.5-554955165837.2-555925332.80-08.20 3.13  +1.60 +1.97         K3III              -0.019-0.036 +.044-006                           
+6286          BD+47 2400 152812 46349    I S                165030.0+473437165317.6+472501 73.45 39.24 6.00  +1.32 +1.44 +0.70   K2III              -0.037+0.105      -063                 0.3       
+6287          BD+21 3002 152815 846873343                   165036.6+210710165455.2+205731 40.68 34.59 5.41  +0.97 +0.71 +0.49   G8III              +0.056+0.006 +.011-003V?   < 17                  
+6288 27    ScoCD-3311590 152820208232                       165039.9-330603165711.1-331534350.54  6.07 5.48  +1.59               K5III              -0.009-0.005      -076V                          
+6289          CD-5010924 1528242443131444                   165034.7-502859165818.0-503828337.02-04.88 5.55  +0.02               B9IV               -0.009-0.041      -044V                          
+6290          BD+13 3258 152830102474              V644 Her 165039.5+134653165516.0+133711 32.56 31.82 6.34  +0.34 +0.06         F3V s              +0.034-0.036      -005SBO    23                 *
+6291 24    OphBD-22 4249 152849184822       10265           165046.1-225929165648.0-230900358.60 12.31 5.58  -0.02               A0V                -0.004+0.001D+.009-026           0.3   1.0       
+6292 56    HerBD+25 3156 152863 84692       10259           165056.5+255330165502.1+254350 46.27 36.01 6.08  +0.92 +0.62 +0.48   G5III              +0.014-0.021      +001SB         4.6  17.9      *
+6293 54    HerBD+18 3266 152879102476    I  10262           165058.4+183535165522.2+182600 37.86 33.62 5.35  +1.41 +1.66 +0.75   K4III              -0.110+0.014 +.020+012V?         4.2   2.5AB   3*
+6294          BD-19 4471 152909160180       10266A          165111.3-192254165704.0-193224  1.62 14.41 6.27  +0.07 -0.30         B6V+B7V            -0.010-0.015D+.008-027           1.1   4.5       
+6295   Eps1AraCP-5210372 152980244331 632                   165136.7-530023165935.1-530938335.15-06.59 4.06  +1.45 +1.71 +0.54E  K4IIIab            +0.004+0.017 +.005+023                           
+6296          BD-10 4417 153021160186                       165153.9-104816165726.1-105748  9.00 19.28 6.19  +1.00 +0.76         G8-K0III-IV        +0.021-0.081      -103                           
+6297          CP-54 7947 153053244338      W                165158.7-542630170006.2-543549334.05-07.52 5.65  +0.19 +0.10         A5IV-V             -0.015-0.064      -020           6.1  20.1       
+6298          CD-3711131 153072208259      W                165206.1-372753165852.4-373716347.32  3.10 6.09  +0.19 +0.11         A3V                +0.024-0.061D+.018-027           0.2   0.2      *
+6299 27Kap OphBD+09 3298 153210121962 633I         Kap Oph  165256.0+093149165740.1+092230 28.37 29.50 3.20  +1.15 +1.18 +0.54   K2III              -0.291-0.010 +.031-056V    < 17                 *
+6300          CD-4811360 153221227542      W                165254.0-482937170027.1-483852338.81-03.93 6.00  +0.88               G8-K0III+G         -0.003-0.079      -029           1.1   1.0       
+6301          BD+14 3155 1532261024963346                   165257.1+140215165732.0+135303 33.10 31.42 6.37  +0.94 +0.70         K0V                -0.077+0.070      -031                          *
+6302          BD-14 4509 1532291602053348                   165300.2-144254165841.6-145211  5.80 16.82 6.59  +0.40 +0.01         F3IV               -0.002-0.030      -013       53                  
+6303          CD-4511123 153258227547                       165314.6-451801170032.3-452706341.35-01.98 6.65  +1.80               K4III              -0.004 0.000      -000V?                         
+6304          CP-58 6964 153261244362              V828 Ara 165306.8-584828170147.4-585730330.66-10.33 6.11  -0.03               B2IVne            v-0.003-0.011      -006      201                 *
+6305 57    HerBD+25 3166 153287 84720                       165324.6+253026165731.0+252110 46.01 35.36 6.28  +0.90 +0.55        gG5                 +0.004+0.013      +009                           
+6306          BD+50 2345 153299 30161    I                  165332.7+501143165606.4+500220 76.80 38.69 6.56  +1.62 +1.98         M2IIIab            -0.021-0.008      -031V?                         
+6307          BD+24 3095 153312 847263347                   165333.2+243210165742.3+242253 44.89 35.04 6.32  +1.10 +0.95         K0III              +0.006-0.018      -022                           
+6308          CD-2412997 153336184892    I                  165350.2-245625165957.6-250531357.46 10.57 5.86  +1.62 +1.96 +0.97E  M3III              -0.005-0.006      -032V                          
+6309 NOVA 1848                                     V841 Oph 0 0 0      0 0 0 0 0      0 0                                                                             -096                          *
+6310 26    OphCD-2413002 153363184897      D                165401.9-245011170009.5-245921357.57 10.59 5.75  +0.41               F4V                +0.061-0.057      +019V?                        *
+6311          CD-3511236 153368208293                       165356.6-354654170036.9-355603348.86  3.87 5.97  +1.16               K2IIICNII          -0.013-0.070      +017                           
+6312          CD-5010955 153370244370      W                165359.7-505850170146.1-510751336.97-05.62 6.45  +0.27               A7V                -0.027-0.039      -028           0.3   0.1      *
+6313          BD+42 2774 153472 464013349                   165441.0+423959165750.2+423045 67.19 38.33 6.34  +1.28 +1.41         K3III              -0.007-0.046      +028SB                         
+6314   Eps2AraCP-53 8316 153580244388      W                165509.2-530512170308.8-531413335.41-07.06 5.29  +0.48               F6V                -0.003-0.144 +.039+007       58  7.6  25.        
+6315 19    DraBD+65 1157 153597 17281               8078    165528.6+651715165601.7+650805 95.68 36.47 4.89  +0.48 -0.03 +0.27   F6V               v+0.240+0.050 +.062-023SB1O    0                 *
+6316          CD-3113473 1536132083243354  W                165524.5-315941170152.7-320837352.04  5.97 5.03  -0.10 -0.35         B8V                -0.007-0.051      +005V          7.5  23.8AB   4*
+6317          BD+06 3332 1536531219953352  S                165536.7+064401170029.4+063501 25.88 27.63 6.59  +0.23 +0.09         A7V                +0.044-0.048      -010SB    158        0.1       
+6318 30    OphBD-04 4215 1536871414831445I W        8111    165547.1-040422170103.6-041321 15.58 22.18 4.82  +1.48 +1.83 +0.79   K4III              -0.041-0.075 +.015-007     < 19: 4.8  94.1       
+6319 20    DraBD+65 1159 153697 17285       10279   8081    165555.4+651128165625.2+650221 95.55 36.45 6.41  +0.38 +0.02         F1-3V              -0.041+0.032 +.029-021       90  0.2   1.0      *
+6320          CP-57 8265 1537162444013355                   165553.6-573404170424.7-574244331.89-09.87 5.73  -0.10 -0.56         B5IV              e-0.008-0.022      +003V?    181                 *
+6321 29    OphBD-18 4381 153727160231                       165600.1-184418170151.2-185308  2.85 13.88 6.26  +1.38 +1.26         K0III              -0.038-0.018      +044                           
+6322 22Eps UMiBD+82  498 153751  2770 912   10242  Eps UMi  165612.2+821208164558.1+820214115.00 31.05 4.23  +0.89 +0.55 +0.47   G5III              +0.017+0.006 +.010-011SB1O   23  8.3  76.9      *
+6323          CD-4611191 153791227588      W                165615.4-470059170341.7-470936340.33-03.45 6.06                      A2-3V              +0.005+0.029      +000           6.0   6.2      *
+6324 58Eps HerBD+31 2947 153808 65716 634                   165627.7+310425170017.4+305535 52.85 36.17 3.92  -0.01 -0.10 -0.04   A0V                -0.047+0.028 +.028-025SBO    78                 *
+6325          BD+22 3045 153834 84758    I                  165644.7+224646170058.1+223756 43.15 33.80 5.65  +1.33              gK3                 -0.011-0.021      +011                           
+6326          BD+15 3095 153882102536       10310  V451 Her 165700.2+150544170133.0+145658 34.69 30.95 6.31  +0.04 +0.04         B9pCrEu           v+0.004-0.008      -032V      26  4.6  19.0      *
+6327          CD-3711201 153890208355              V923 Sco 165701.6-380031170350.8-380908347.50  2.00 5.91  +0.38 -0.02 +0.18   F4IV+F2V           +0.071-0.023      -015SBO                       *
+6328          BD+27 2738 153897 84765                       165708.7+272039170109.6+271147 48.46 35.08 6.55  +0.41 -0.08         F5V                -0.014-0.063      -031       40                  
+6329          BD+08 3337 153914122023       10312           165710.7+083544170159.1+082702 27.95 28.14 6.33  +0.09 +0.06         A4V                +0.039+0.003D+.010+006SB    115  0.8   1.2      *
+6330          BD+56 1934 153956 301903353                   165731.3+565007165921.5+564119 85.18 37.64 6.03  +1.16              gK1                 -0.051+0.037      -015                           
+6331          CD-4511188 154025227601                       165746.9-452137170505.3-453006341.79-02.64 6.28  +0.07 +0.10         A2V                -0.031-0.017      -005                           
+6332 59    HerBD+33 2817 154029 657361446                   165754.8+334246170136.4+333406 56.13 36.45 5.25  +0.02 +0.02         A3IV               +0.003+0.002 +.023-012V?     35                  
+6333          BD+25 3183 154084 847763356                   165812.7+253847170218.7+253020 46.57 34.37 5.75  +1.02 +0.79        gG7                 +0.055+0.097 +.014-050                           
+6334          CD-3311706 154090208377      W                165814.5-335856170449.4-340722350.83  4.29 4.87  +0.26 -0.68 +0.17   B1Ia              t+0.008-0.002      +004V?     91  9.1  20.       *
+6335          BD+73  751 154099  86673351                   165815.6+731644165616.8+730740105.04 34.11 6.30  +0.24 +0.11         F0V                 0.000-0.021      -013V     177                  
+6336          BD+32 2835 154126 65745                       165830.0+320136170217.2+315305 54.12 35.97 6.36  +1.13               K0                 +0.045+0.037      -013                           
+6337          BD+14 3179 154143102553    I          8142    165832.9+141409170307.8+140531 33.95 30.26 4.98  +1.60 +1.92 +1.21   M3III              +0.023-0.064 +.005+043V                         *
+6338          CD-4311396 154153227615                       165835.7-435800170548.6-440618342.98-01.90 6.19  +0.28 +0.02         A4III              +0.028+0.019      -033                           
+6339          BD+14 3180 154160102554               8143    165837.8+143930170310.4+143040 34.41 30.42 6.52  +0.76 +0.45         G5IV:              -0.169-0.185 +.029-056                           
+6340          BD-20 4627 154204184999                       165849.8-202115170445.3-202941  1.91 12.39 6.30  -0.02               B6IV               -0.006-0.024      -011V                          
+6341          BD+13 3292 154228102564      W        8152    165903.5+134450170339.3+133619 33.50 29.95 5.93   0.00 -0.04         A1V                -0.023-0.035      -032V      29  0.2 299.2AB   4 
+6342          BD+13 3295 154278102569                       165921.8+134240170358.0+133403 33.49 29.87 6.08  +1.03 +0.84         K1III              +0.022-0.129      +046V?                        *
+6343          BD+19 3218 154301102571    I  10323   8158    165931.9+194949170352.7+194126 40.11 32.18 6.35  +1.52               K4III              -0.019+0.016      -039SB         4.3 108.1AC   3*
+6344          CD-3711274 154310208406      W                165934.6-370523170620.3-371339348.53  2.17 5.98  +0.07 +0.10         A2IV               +0.012-0.023      -021           4.9   5.8AB   3 
+6345          BD+69  884 154319 17305                       165935.8+691959165902.6+691111100.40 35.11 6.40R                     K0                  0.000-0.038 +.017-027                           
+6346 61    HerBD+35 2911 154356 65761    I          8159    165954.7+353319170330.2+352451 58.48 36.40 6.69R                     M4IIIab            +0.033-0.035 +.010-012V?                         
+6347          CD-3511306 154368208410      W                165948.9-351851170628.4-352704349.97  3.22 6.13  +0.50 -0.53         O9.5Iab            +0.013-0.006      +002V?    100  6.5   2.8      *
+6348          BD+60 1728 154391 17312                       170000.5+604725170116.7+603857 90.05 36.81 6.13  +1.00 +0.82         K1III              -0.055+0.058      -017                           
+6349          BD+00 3629 154417122056              V2213 Oph170011.3+005058170516.9+004209 20.77 23.78 6.01  +0.58 +0.06         F8.5IV-V          e-0.003-0.338 +.046-018V   =<  6                 *
+6350          BD-21 4512 1544181850243358                   170013.4-212533170611.8-213353  1.22 11.49 6.30  +0.13               A3m                -0.011-0.077      -045                           
+6351          BD+34 2890 154431 65766                       170016.8+345546170353.5+344725 57.73 36.21 6.04R +0.22?              A5V                -0.068-0.002      -020SB2   125                  
+6352          BD+19 3220 154441102579       10326           170020.1+194414170441.3+193557 40.08 31.97 6.17R -0.01 -0.09         B9.5V              +0.009+0.001      -024V?     81  3.0   1.9       
+6353          BD-00 3224 1544451415133357                   170022.9-004518170532.3-005331 19.30 22.93 5.64  +0.16 -0.64 +0.05   B1V                +0.002+0.004      +016V     174                 *
+6354          CD-2611896 1544811850331447                   170041.3-262239170653.2-263047357.24  8.47 6.29  -0.04 -0.24         A0III              +0.001-0.011      -024V                          
+6355 60    HerBD+12 3142 154494102584 635   10334           170044.4+125241170522.7+124427 32.78 29.22 4.91  +0.12 +0.05 +0.02   A4IV               +0.051-0.010 +.022-004V?    111  6.1  56.0      *
+6356          CP-61 5842 1545552538183362                   170058.6-613239171006.3-614032329.02-12.75 6.39  -0.04               B8II-III           -0.001-0.010      +004                           
+6357          CP-70 2361 154556257472                       170101.1-703525171219.8-704316321.29-17.89 6.22  +1.06 +1.04         K1IVCNIII          +0.041-0.079      -024                           
+6358          BD+09 3322 154610122075    I                  170124.6+095208170609.7+094400 29.77 27.78 6.37  +1.45 +1.73         K5III              +0.023-0.008      -006                           
+6359          BD+10 3142 154619102592                       170129.5+103520170613.1+102715 30.51 28.07 6.37  +0.87 +0.57         G8III-IV           +0.049+0.018      -024                           
+6360          BD+64 1170 154633 17324                       170142.0+644421170215.3+643602 94.84 35.94 6.10  +0.96 +0.71         G5V                -0.050+0.025 +.016-025V?                         
+6361          BD-01 3292 154660141522       10347           170141.7-013117170652.9-013923 18.76 22.26 6.38  +0.20 +0.10         A9V                +0.033-0.036      +007V          3.4  20.3      *
+6362          BD+44 2652 154713 464781448                   170202.1+435653170505.0+434844 68.93 37.09 6.43  +0.09 +0.16         A3IV               +0.006 0.000      -009                           
+6363          BD+49 2583 154732 464763359           8185    170210.5+485631170449.8+484815 75.20 37.31 6.09  +1.09 +1.00         K1III              +0.026-0.066      +012SBO                       *
+6364          BD+22 3073 154733 848353360I  10343           170204.1+221310170618.1+220503 43.00 32.45 5.56  +1.30 +1.52 +0.67   K3III              -0.094-0.038 +.011-096V          7.9  30.3      *
+6365          BD-17 4717 1547791603051449                   170226.4-172836170814.9-173633  4.82 13.37 5.99  +1.01               K0III              +0.006-0.032      -014V?                         
+6366          CD-3013840 1547832084673363                   170224.2-301616170847.5-302413354.33  5.83 5.97  +0.25 +0.33         A/FmDel Del        -0.015-0.062      -030                          *
+6367          BD-00 3230 154895141528       10355           170304.0-005651170813.6-010446 19.49 22.26 6.06  +0.08 +0.04         A1V+F3V            -0.020-0.034D+.008-021SB         2.0   0.3      *
+6368          CP-67 3296 154903253827      W                170304.3-670410171317.5-671148324.46-16.09 5.89  +1.06 +0.90         K0-1III            -0.180-0.093      -008           3.2  34.1      *
+6369 21Mu  DraBD+54 1857 154905 30239       10345B          170315.3+543607170519.8+542813 82.30 37.02 5.83H                     F7V                -0.073+0.085 +.046-018       23  0.1   2.0AB   3*
+6370 21Mu  DraBD+54 1857 154906 30239       10345A          170315.3+543607170519.7+542813 82.30 37.02 5.80H +0.48 +0.05 +0.24   F7V                -0.073+0.085 +.046-015       13  0.1   2.0AB   3*
+6371          CD-4411502 154948227688      W                170327.4-442543171042.3-443327343.15-02.87 5.08  +0.86 +0.58 +0.43C  G8-K0III+G         -0.033-0.056 +.017-007           7.9  13.2       
+6372          BD-03 4063 154962141535                       170338.8-034457170854.5-035258 16.98 20.69 6.36  +0.69 +0.36         G5-8IV-V           -0.059-0.158      +015                          *
+6373          CP-74 1610 1549722574783368                   170339.1-742440171635.6-743159318.01-20.12 6.25  -0.01  0.00         A0V                -0.027-0.058      +000                           
+6374          CD-4811492 155035227699                       170402.4-484452171138.9-485227339.74-05.54 5.84  +1.84 +1.85         M1-2III            +0.029-0.030      +015V                          
+6375          BD-10 4445 1550781603241450                   170416.2-102334170948.0-103124 11.15 16.99 5.56  +0.52 +0.02         F5IV               +0.057-0.105 +.014-003V?                         
+6376          BD+40 3103 155102 46502 636                   170430.9+403848170746.7+403058 64.90 36.29 6.34  +0.03 +0.04         A2IV               -0.038-0.033      -007       45                  
+6377          BD+36 2827 155103 65812       10360           170429.3+360354170802.0+355607 59.31 35.58 5.39  +0.31 +0.05 +0.14   A5-F1III/IVm s     -0.024-0.010 +.015-030       82  0.1   0.1AB   3*
+6378 35Eta OphBD-15 4467 155125160332    I  10374           170438.5-153604171022.7-154329  6.72 14.01 2.43  +0.06 +0.09 +0.01   A2V                +0.039+0.098 +.052-001SB     26  0.4   0.3AB   4*
+6379          BD+75  613 155154  8697               8183    170448.6+752609170140.2+751750107.35 33.04 6.21R                     F0IV-Vn            +0.016-0.079      +001SB    157                 *
+6380   Eta ScoCD-4311485 155203227707 638                   170459.3-430626171209.2-431421344.37-02.30 3.33  +0.41 +0.09 +0.20   F3III-IVp          +0.024-0.287 +.063-028      150                 *
+6381          CD-3911182 1552592085213366                   170521.7-392254171216.2-393025347.40-00.12 5.67  +0.04               A1V                -0.013-0.075      +012V?                         
+6382          CD-3811632 155276208522                       170524.3-384152171216.5-384920347.95  0.28 6.30  +1.05               K1IIICNII          +0.019-0.043      -032                           
+6383          BD+51 2178 155328 30262       10369           170549.8+505808170817.1+505032 77.74 36.73 6.46   0.00 -0.13         A1V                -0.002+0.029      -015       65  5.1  18.3     3*
+6384          CP-56 8098 155341244539              V829 Ara 170546.4-564604171413.2-565318333.35-10.48 6.09  +1.78 +1.34         M1-2II-III+A       -0.016+0.003      -034V                         *
+6385          BD+12 3161 155375102632                       170607.1+123530171045.8+122802 33.11 27.91 6.57  +0.08 +0.09 +0.05   A1m                +0.037-0.007      +005SBO                       *
+6386          CD-2512018 155379185138                       170604.9-250753171213.6-251517358.98  8.23 6.54  -0.04               A0pHg              -0.014-0.033      -003                          *
+6387          CD-2711516 155401185142                       170609.2-273819171225.0-274543356.95  6.74 6.14  -0.04               B9Vn:              -0.011-0.040      +001V                         *
+6388          BD+40 3109 155410 465243365I S                170618.7+405408170933.3+404638 65.27 35.99 5.08  +1.28 +1.39 +0.64   K3III              -0.042+0.012 +.019-056SBO  < 17                 *
+6389          CD-3212460 155450208539      W                170628.4-321902171258.7-322619353.20  3.91 6.01  +0.07 -0.77         B1II               +0.013-0.012      +017SB    114  7.5  30.       *
+6390          BD+08 3367 1555001221641451                   170655.8+080059171145.2+075341 28.60 25.73 6.33  +1.04 +0.86         K0III              +0.035+0.014      -006                           
+6391 63    HerBD+24 3140 155514 84896              V620 Her 170654.7+242135171103.2+241416 45.82 32.10 6.19  +0.23?              A8V                -0.011+0.033      -002      163                 *
+6392          CD-3911212 155603208569    I W       V915 Sco 170731.8-393854171427.7-394601347.43-00.62 6.60  +2.21 +1.35 +1.08   G5Ia               +0.005-0.011      -006           4.2  14.4AB   3*
+6393 37    OphBD+10 3165 1556441026463369I W                170744.9+104222171227.8+103507 31.38 26.74 5.33  +1.59 +1.64         M2IIIa             +0.001-0.026      +026V?         8.7  30.3       
+6394          BD+00 3654 155646122182                       170747.8+002825171254.4+002107 21.45 21.95 6.65  +0.50 +0.05 +0.27   F6III              +0.019-0.078      +058    =< 10                 *
+6395          BD+52 2032 155711 302773367                   170813.1+523152171030.6+522432 79.68 36.35 6.29   0.00 -0.18         B9V                -0.014-0.010      -034V      50                  
+6396 22Zet DraBD+65 1170 155763 17365 639  S                170829.7+655016170847.2+654253 96.01 35.04 3.17  -0.12 -0.43 -0.12   B6III              -0.020+0.022 +.023-017V      31                 *
+6397          CD-3311875 155806208585               8388    170845.3-332558171519.3-333254352.59  2.87 5.53  -0.01 -0.91         O7.5Vne          +0.009 0.000      +004V?    162                 *
+6398          CD-3811686 155826208591      W                170845.9-382802171535.9-383538348.52-00.11 5.96  +0.58 +0.11         F7V+G2V            -0.182-0.412 +.042-054           0.1   0.1      *
+6399          BD+49 2604 155860 46561       10397   8327    170907.1+495155171140.2+494448 76.38 36.19 6.04R                     A5III              +0.020+0.035      -011           3.4   5.2AB   3*
+6400          CP-69 2715 155875253870      W                170906.4-695549172012.8-700244322.26-18.11 6.53  +0.60 +0.15         G0-1IV:            -0.045-0.201      -005           2.7   1.4       
+6401 36    OphCD-2612026 155885185199    I  10417B          170911.7-262721171521.0-263610358.30  6.88 5.11  +0.86 +0.53         K1V                -0.458-1.142 +.188+000V?         0.0   4.6AB   5*
+6402 36    OphCD-2612026 155886185198    I  10417A          170911.8-262717171520.8-263605358.30  6.88 5.07  +0.85 +0.53         K0V                -0.491-1.133 +.188-001SB         0.0   4.6AB   5*
+6403          CD-3013968 155940208606                       170928.1-300543171551.5-301238355.38  4.71 6.21  -0.03 -0.09         B9.5V              -0.001-0.037      -004                           
+6404          BD-14 4585 155970160402       10419           170939.1-142809171520.3-143502  8.38 13.64 5.99  +1.10               K1III              -0.012-0.001      -003V?         5.1   4.2      *
+6405          CD-3511426 155974208610      W                170941.1-353738171621.5-354458350.92  1.42 6.12  +0.48 -0.02         G0IV-V             -0.118-0.319 +.023-001           7.4  36.5       
+6406 64Alp1HerBD+14 3207 156014102680    I  10418A Alp Her  171005.2+143015171438.9+142325 35.53 27.82 3.48H +1.44 +1.01 +2.14   M5Ib-II           e-0.006+0.036 -.002-033V      21  2.2   4.9AB   4*
+6407 64Alp2HerBD+14 3207 156015102681       10418B          171005.5+143013171439.2+142324 35.53 27.82 5.39H                     G5III+F2V          -0.003+0.045 -.002-037SBO =< 50  2.2   4.9AB   4*
+6408          CP-59 6954 156091244613      W                171021.3-593507171912.4-594140331.34-12.58 5.91  +1.37               K2IIICNIb-II       -0.012-0.008      -005           7.0  20.        
+6409          CD-3212545 1560982086261452                   171033.2-323259171703.7-323946353.52  3.08 5.55  +0.50 +0.05         F6IV               -0.096-0.056      -036        0                 *
+6410 65Del HerBD+25 3221 156164 84951 641I  10424   8419    171055.4+245725171501.9+245021 46.83 31.42 3.14  +0.08 +0.08 +0.03   A3IV               -0.021-0.157 +.044-040SB    290  5.6   8.5AB   4*
+6411   Iot ApsCP-69 2719 156190257491 642  W        8509    171056.5-700104172205.9-700724322.28-18.29 5.41  -0.04 -0.23         B9V+B9.5V          -0.006-0.012      -004           0.0   0.1      *
+6412          BD+02 3283 156208122224      S        8438    171111.9+021754171614.2+021110 23.62 22.10 6.17  +0.22 +0.16         A2V                +0.001-0.021      +004       25        0.1       
+6413          BD-06 4575 1562271415853371                   171121.2-060802171642.8-061442 15.90 17.80 6.09  +1.10 +0.97         K0                 -0.004-0.005      -021                           
+6414          BD+01 3408 1562471222261453   10428  U Oph    171127.2+011919171631.7+011238 22.73 21.57 5.88  +0.06 -0.45         B5Vnn+B5V          -0.001-0.013 +.002-011SB2O  105  7.3  20.7      *
+6415 41    OphBD-00 3255 156266141586    I  10429           171128.6-001957171636.7-002643 21.20 20.75 4.73  +1.14 +1.13 +0.59   K2III              -0.023-0.066 +.010-002V?   < 17  3.0   1.0      *
+6416          CD-4611370 156274227816      W                171127.7-463155171903.2-463802342.29-05.26 5.48  +0.80 +0.38 +0.46   G8-K0V             +0.979+0.224 +.131+023           3.1   7.5AB   4*
+6417   Zet ApsCP-67 3310 1562772538823374                   171132.3-673958172159.4-674614324.40-17.10 4.78  +1.21 +1.27         K2-III             -0.042-0.006 +.014+013                           
+6418 67Pi  HerBD+36 2844 156283 65890 643I          8431    171133.8+365518171502.8+364833 60.66 34.34 3.16  +1.44 +1.66 +0.72   K3IIab            e-0.026+0.004 +.025-026V?   < 17                 *
+6419          BD+23 3070 156284 84955    I                  171132.1+235115171541.6+234434 45.66 30.94 5.96  +1.31               K2III              -0.025+0.022      -042V?                         
+6420          CD-4311572 156293227813                       171133.6-440116171848.0-440747344.34-03.80 5.76  -0.05 -0.13 -0.02C  B9V                 0.000-0.021      -012                           
+6421          BD+63 1336 156295 173913370                   171140.7+625918171232.6+625228 92.50 35.14 5.56  +0.21 +0.06         F0IV               +0.014+0.048 +.014-005V?    114                  
+6422          CD-3212573 156325208657      W       Var?     171149.6-322640171820.4-323312353.77  2.93 6.36  +0.15 -0.36         B5Vn              e-0.013-0.019      -014V?         5.6  19.5      *
+6423          CD-4911324 156331244631      W                171146.7-495720171930.3-500348339.50-07.27 6.27  +0.41               F8III+B9V          -0.014-0.015      +011           0.0   0.1      *
+6424 39Omi OphCD-2413255 156349185238    I  10442A          171154.7-241041171800.7-241713  0.54  7.70 5.20  +1.10 +0.90         K0II-III           -0.054-0.008 +.013-029           1.5  10.2      *
+6425 39Omi OphCD-2413255 156350185237       10442B          171154.6-241030171800.5-241703  0.55  7.71 6.80  +0.51 +0.05         F6IV-V             -0.073-0.009 +.013-028V          1.5  10.2      *
+6426          CD-3411626 156384208670      W        8482    171208.7-345240171857.2-345923351.83  1.44 5.91  +1.04 +0.82 +0.59   K3V+K5V            +1.170-0.164 +.141+000           1.0   0.5AB   4*
+6427          CD-4411595 156398227821      W                171209.8-440657171924.5-441323344.32-03.94 6.65  +0.20 +0.01 +0.15C  B9.5V+A6III        -0.007-0.015      -015           0.3   0.2      *
+6428          BD-16 4470 156462160440    I                  171233.6-161217171819.2-161843  7.30 12.09 6.43  +1.66 +2.05         M2IIIFe1           -0.005+0.010      -040V                          
+6429          CP-80  828 1565132587691455           8609    171245.1-804559173127.3-805133312.32-23.69 5.88  +1.67 +1.81         M3III              -0.013-0.044      -019                           
+6430          BD+23 3074 156593 84982    I                  171324.5+231153171735.9+230527 45.11 30.32 6.45R                     K2                 -0.002-0.001      -015                           
+6431 68    HerBD+33 2864 156633 65913       10449  u Her    171337.8+331228171719.5+330600 56.40 33.14 4.82  -0.17 -0.76 -0.19   B1.5Vp+B5III       -0.008-0.003 +.009-021SB2O  116  5.1   4.4      *
+6432          BD+17 3216 156653102724                       171338.5+172529171805.0+171905 38.95 28.19 6.00  +0.01 +0.02         A1V                +0.014-0.011      +004SB     24                  
+6433          BD+11 3156 1566811027253372I                  171354.8+105822171837.0+105152 32.38 25.49 5.03  +1.55 +1.89 +0.83   K4II-III           +0.010-0.095 -.002+040V?   < 17                  
+6434          BD+06 3386 156697122270              V2112 Oph171359.4+061126171852.8+060507 27.69 23.34 6.51  +0.39 +0.15         F0-2IV-Vn          +0.020+0.006      -025      139                 *
+6435          BD-17 4773 156717160462       10465           171404.0-173907171953.3-174523  6.28 10.99 6.02  +0.04               A2Vnn              -0.010-0.021D+.012-004           1.5   2.0AB   3*
+6436 69    HerBD+37 2864 156729 65921               8489    171413.3+372346171740.3+371730 61.35 33.91 4.65  +0.05 -0.03  0.00   A2V                -0.034+0.063 +.018-010SB    149                  
+6437          BD+49 2614 156753 46605                       171415.8+494755171648.6+494128 76.33 35.36 7.48R                     K2                 +0.023+0.002                                     
+6438          CP-57 8478 156768244678      W                171417.8-575436172255.0-580037333.05-12.07 5.88  +1.07 +0.86         G8Ib-II            -0.021-0.011      -010           3.6   2.0       
+6439          BD-05 4426 156826141611                       171438.3-054833171959.5-055502 16.64 17.27 6.32  +0.85 +0.47         G9V                +0.040-0.180 +.017-031V                          
+6440          CP-62 5558 1568382539033378                   171437.5-624556172401.1-625151328.89-14.75 5.70  -0.14 -0.76         B2IV               -0.001-0.008      +004V?                        *
+6441          BD-19 4605 156846160474       10476           171441.9-191339172034.2-191958  5.04  9.98 6.52  +0.58               G3IV               -0.151-0.102      -069           7.5   5.1      *
+6442          CP-56 8191 156854244685                       171441.0-562534172306.9-563131334.34-11.29 5.80  +1.00 +0.77         G8-K0III           -0.008+0.009      -006                           
+6443          BD+28 2719 156874 850013375                   171453.1+285539171848.5+284923 51.59 31.77 5.65  +0.98       +0.49   K0III              +0.050-0.005 +.016-014                           
+6444          BD+38 2910 156891 659303373                   171501.7+385450171823.3+384841 63.18 34.03 5.94  +1.00 +0.81        gG7                 -0.014+0.077      -038V?                         
+6445 40Xi  OphBD-20 4731 156897185296      W                171500.6-210020172100.2-210646  3.59  8.92 4.39  +0.39 -0.05 +0.22   F1III-IV           +0.232-0.206 +.061-009        0  4.5   3.7       
+6446 53Nu  SerBD-12 4722 1569281604793376   10481           171512.1-124444172049.7-125049 10.63 13.46 4.33  +0.03 +0.05  0.00   A2V                +0.042+0.004 +.028+005V     115  4.8  46.3      *
+6447          CP-60 6800 156942253908                       171517.6-603435172418.7-604025330.84-13.64 5.77  -0.08               B8Ib-II            -0.008-0.002      -010                           
+6448          BD+60 1743 156947 17414              VW Dra   171516.6+604636171629.4+604014 89.76 34.96 6.32  +1.09               K1.5IIIb           -0.042+0.014 +.003+017V?                        *
+6449          BD-10 4477 156971160482      W                171520.2-103541172052.7-104146 12.51 14.60 6.46  +0.33 +0.01         F1III              +0.065-0.009      +012       28  7.8   8.1       
+6450          CD-3711507 157038208740      W                171549.9-374222172239.4-374818349.95-00.79 6.41  +0.64 -0.32         B4Ia               +0.017-0.013      -014           5.8   2.7AB   3*
+6451   Iot AraCD-4711484 1570422278863379  W       Iot Ara  171545.6-472211172316.1-472806342.01-06.33 5.25  -0.11 -0.82 -0.08   B2IIIne           v-0.010-0.024      -019      369  5.3  42.8      *
+6452          BD+18 3351 1570491027571454I         V656 Her 171554.4+180935172018.9+180326 39.96 27.97 5.00  +1.62 +2.06 +0.77E  M2IIIab            +0.009-0.055 +.006-046V?                        *
+6453 42The OphCD-2413292 157056185320 644          The Oph  171552.0-245359172200.6-245958  0.46  6.55 3.27  -0.22 -0.86 -0.21   B2IV               -0.004-0.020      -002SB     35  2.0   0.0      *
+6454          CD-3511505 157060208741                       171554.9-354853172238.0-355436351.51  0.28 6.47  +0.54               F7V                +0.080+0.112      -006V                          
+6455          BD+25 3246 157087 85016                       171605.2+253821172009.8+253215 48.01 30.53 5.38  +0.03 +0.10         A3III              +0.021-0.015 +.011-005SB     11                  
+6456          CD-3711512 157097208747      W                171607.4-370719172254.9-371314350.47-00.51 5.93  +1.08               K1III              +0.033-0.026      -036           8.4  20.2       
+6457 70    HerBD+24 3167 157198 85021      W                171647.0+243556172054.2+242958 46.93 30.05 5.12  -0.03 +0.02         A2V                -0.022+0.002 +.010-018SB     99  3.5 222.9AB   3 
+6458 72    HerBD+32 2896 157214 659631456   10488   8553    171655.0+323547172039.6+322804 55.88 32.31 5.39  +0.62 +0.07 +0.35   G0V                +0.137-1.041 +.069-078V       0  5.1 230.0AB   3*
+6459 43    OphCD-2813081 157236185350    I                  171703.9-280245172321.6-280835358.02  4.54 5.35  +1.55 +1.80         K5III              +0.004-0.031 +.028-014                           
+6460          CD-4411669 157243227911                       171658.0-440359172413.0-440945344.86-04.62 5.12  -0.06 -0.40 -0.01C  B7III              -0.011-0.028      +013V     150:                *
+6461   Bet AraCP-55 8100 157244244725 645I'                 171659.1-552607172518.0-553148335.37-11.01 2.85  +1.46 +1.56 +0.53E  K3Ib-IIa           -0.008-0.025 +.034-000                          *
+6462   Gam AraCP-56 8225 157246244726      W                171658.5-561700172523.6-562239334.64-11.48 3.34  -0.13 -0.96         B1Ib               -0.002-0.012      -003V     281  7.0  17.9AB   3*
+6463          BD+16 3163 157257102770    I                  171705.7+164948172133.4+164351 38.69 27.20 6.35  +1.61 +1.98         M2.5IIIab          -0.018-0.024      +039                           
+6464 74    HerBD+46 2293 157325 466453377I          8556    171731.6+462020172021.1+461427 72.16 34.58 5.59  +1.57 +1.86         M0III              -0.029+0.043      -057V?                        *
+6465          BD-02 4343 157347141642                       171738.2-021721172251.3-022318 20.22 18.43 6.29  +0.68 +0.24         G5IV               +0.045-0.112      -035                           
+6466          BD+28 2728 157358 85028      W                171736.1+285121172131.2+284529 51.71 31.18 6.35  +0.70               G0III              +0.006+0.006      -006SB     11  2.2   0.6       
+6467          BD+48 2506 157373 46651                       171751.6+481715172033.6+481118 74.53 34.68 6.43  +0.43 -0.08         F4V                +0.190-0.019 +.007+031    =< 15                  
+6468   Kap AraCD-5011269 157457244734      W                171812.1-503231172600.0-503801339.60-08.45 5.23  +1.06               G8III              +0.007+0.001 +.030+017           8.3  30. AC   3 
+6469          BD+40 3136 157482 46664      S       V819 Her 171826.6+400422172143.6+395828 64.69 33.58 5.51  +0.68 +0.21         F9Vn:             e+0.009-0.063 +.021+003SB2    12        0.0      *
+6470          CD-3411674 157486208786                       171824.2-343611172502.7-344147352.79  0.56 6.16  +0.02               A0VSiCr            +0.004-0.027      -018V                          
+6471          CP-62 5590 157524253928                       171841.7-625650172807.7-630211328.99-15.24 6.24  -0.09               B7-8V              -0.023-0.027      -003                           
+6472          BD-21 4597 157527185367       10522           171843.1-212053172442.0-212630  3.79  8.01 5.85  +0.93 +0.67 +0.32E  G8III              -0.021-0.028 +.013-056V?         6.0   4.3      *
+6473          BD-18 4516 1575461605233382                   171845.7-182110172437.1-182645  6.32  9.67 6.21  +0.03 -0.13         B9Vn               +0.018-0.004      -021V                          
+6474          CD-2413325 157588185374                       171859.4-240908172506.2-241437  1.49  6.39 6.19  +1.10              gK1                 +0.016+0.012      +020V                          
+6475          CD-5110881 157599244749                       171900.5-515132172656.3-515657338.56-09.29 6.19  -0.03               B8-9V              +0.005-0.021      +001V?                         
+6476          BD+08 3405 157617122346    I                  171910.8+085644172357.6+085110 31.00 23.44 5.77  +1.25 +1.27        gK1                 +0.009-0.002      +016                           
+6477          CD-4511531 157661227971      W        8637    171928.8-454512172651.5-455037343.72-05.94 5.29  -0.07 -0.34 -0.03C  B7V+B9.5V          -0.040-0.040D+.009-009V?         0.8   2.3AB   3*
+6478          CD-5011283 157662244755      W                171924.5-503229172712.4-503749339.71-08.61 5.92  +0.08               B9II               -0.007-0.004      +011           4.7  76.1AB   4 
+6479          BD+53 1937 157681 303543381I                  171935.5+533056172145.4+532514 80.90 34.64 5.67  +1.47               K4III              +0.021+0.005      -008V                          
+6480 73    HerBD+23 3100 157728 850623383           8606    171955.4+230311172406.6+225737 45.53 28.86 5.74  +0.21 +0.05         F0IV               -0.046-0.032      -020       67                 *
+6481          BD+16 3174 157740102805                       172002.7+162335172431.5+161804 38.56 26.37 5.71  +0.07 +0.12         A3V                +0.008-0.026      +011                          *
+6482          BD+15 3179 157741102806       10528           172003.3+154149172433.8+153622 37.84 26.10 6.35  -0.02 -0.18         B9V                +0.008+0.015      -019      338  4.3   3.9      *
+6483          CP-5210662 1577532447633386  W                171959.8-521230172757.6-521750338.35-09.61 5.75  +1.17               K2III              -0.006-0.065      -009V?         7.2  17. AB   3 
+6484 75Rho HerBD+37 2878 157778 66000       10526B          172013.6+371419172340.7+370848 61.44 32.71 5.47H                     A0Vn               -0.041+0.004 -.002-019      190  1.0   4.2AB   3*
+6485 75Rho HerBD+37 2878 157779 66001       10526A  8605    172013.9+371416172341.0+370845 61.44 32.71 4.52H -0.03 -0.05 -0.01   B9.5III            -0.037+0.006 -.002-021       81  1.0   4.2AB   3*
+6486 44    OphCD-2413337 1577921854011457           8640    172015.7-240500172622.2-241031  1.71  6.19 4.17  +0.28 +0.12 +0.12   A3m                 0.000-0.116 +.045-037       59                 *
+6487          CP-55 8144 157819244770      W                172022.0-550500172838.7-551011335.94-11.22 5.94  +1.11               G8II-III           -0.017-0.012      -013           6.5  37.0AC   3*
+6488          BD+38 2928 157853 66006       10531           172040.3+384022172402.2+383458 63.14 32.91 6.49  +0.73 +0.21         F8IV               -0.012+0.040D+.001+027           0.1   0.1      *
+6489          BD-01 3329 1578561416611458                   172046.3-013352172557.9-013906 21.29 18.12 6.44  +0.46 -0.02         F3V                +0.063+0.051      -024        8                  
+6490          CD-2512160 157864185406                       172043.9-255119172655.2-255636  0.30  5.11 6.44  -0.06               A0V                -0.028-0.026      -008V?                         
+6491          BD+37 2882 157910 66014       10535           172059.2+370227172427.1+365707 61.25 32.52 6.28  +0.88 +0.53 +0.45   G5III+F0V          -0.026+0.047      -016V?         3.6  33.2      *
+6492 45    OphCD-2913557 157919185412 646                   172058.0-294635172721.3-295201357.08  2.85 4.29  +0.40 +0.09 +0.18   F5IVDel Sct*       +0.020-0.139 +.021+037       25                 *
+6493          BD-04 4275 157950141665 647           8662    172119.4-045954172637.9-050512 18.26 16.27 4.54  +0.39 -0.03 +0.21   F3V                -0.092-0.043 +.032+000SB2O   52                 *
+6494          CD-2913563 157955185417                       172114.9-293816172737.5-294328357.23  2.88 6.00   0.00               B9IV               -0.008-0.026      -021V                          
+6495          BD+17 3241 157967102819    I W       V640 Her 172127.3+170018172554.4+165503 39.33 26.30 5.98  +1.62               M4IIIab            -0.008+0.011      -010V?         7.5  23.1AC   3*
+6496          BD-12 4750 157968160553                       172125.3-122527172702.1-123045 11.74 12.36 6.21  +0.51               F7V                +0.037-0.062      -040V?                        *
+6497          BD+07 3368 1579781223813385                   172129.3+074059172619.0+073544 30.06 22.36 6.06  +0.58 +0.28 +0.43   B9.5V+G0V           0.000-0.005      -011SBO                       *
+6498 49Sig OphBD+04 3422 1579991223871459I          8664    172133.1+041338172630.9+040825 26.77 20.75 4.34  +1.50 +1.62 +0.77   K2II               +0.004+0.007 +.008-027     < 19:                 
+6499          BD+27 2809 158067 850803387  W                172200.4+265755172600.9+265244 49.95 29.69 6.41  +0.10 +0.12         A5IV               +0.008+0.023      -027       58  5.0  49.4AB   3 
+6500   Del AraCP-60 6842 158094253945 648  W                172204.2-603601173105.9-604102331.27-14.36 3.62  -0.10 -0.31         B8Vn               -0.059-0.096      +010      260: 8.0  47.4      *
+6501          CD-3611546 158105208860                       172210.0-364141172856.1-364642351.50-01.25 6.02  +1.11               K0III              +0.002-0.009      -028                           
+6502          BD+20 3481 158148 850953388                   172230.1+200958172649.1+200451 42.71 27.27 5.54  -0.13 -0.56         B5V                +0.001+0.015      -030V     251                  
+6503          CD-3811927 158156208870      W                172233.0-382605172925.7-383100350.11-02.30 6.39  +0.09               A2V                +0.032+0.020      +008           0.3   0.4       
+6504          BD-08 4444 158170141679                       172236.5-080715172802.3-081230 15.66 14.38 6.37  +0.58 +0.16         F5IV               -0.081-0.128      -064    =< 15                  
+6505          CP-56 8304 158220244808                       172253.0-565028173123.0-565514334.62-12.46 5.95  -0.08               B7II-III           -0.018+0.008      -003    =< 41                  
+6506          BD+34 2971 158261 660543389                   172310.5+344646172646.2+344145 58.77 31.59 5.94  -0.01 -0.06         A0V                -0.024+0.047      -022SBO    10                 *
+6507          BD+00 3697 1583521224183391                   172343.5+002442172849.7+001950 23.49 18.45 5.44  +0.22 +0.11         A8V               e-0.062+0.023 +.012-036      184                 *
+6508 34Ups ScoCD-3711638 158408208896 649                   172357.8-371257173045.8-371745351.27-01.84 2.69  -0.22 -0.82 -0.23   B2IV               -0.001-0.031      +008SB     73                 *
+6509 77    HerBD+48 2517 158414 46723 650                   172405.1+482038172644.2+481536 74.70 33.66 5.85  +0.12 +0.15         A4V                +0.002-0.004 +.014-009SB    120                  
+6510   Alp AraCD-4911511 158427228069 651  W        8999    172406.6-494748173150.5-495234340.76-08.83 2.95  -0.17 -0.69 -0.24   B2Vne             v-0.031-0.070 +.007+000SB    298  8.0  55.6      *
+6511          BD+60 1754 158460 17472                       172423.7+600756172541.3+600254 88.89 33.88 5.65  +0.03 +0.01         A1Vn               -0.010+0.027      +007SB    180                  
+6512          BD-05 4450 158463141691       10583   8918    172426.5-055016172947.4-055511 17.92 15.17 6.37  +0.93 +0.67         K0III              -0.022-0.073D+.008+004           2.1   1.3      *
+6513          CD-4511626 158476228075      W                172424.6-455734173149.1-460211344.03-06.77 6.03  +0.83               F8-G0Ib            +0.001+0.007      -029V          4.2  18.0       
+6514          BD+58 1731 158485 303873390                   172434.8+584407172604.9+583907 87.21 33.91 6.51  +0.14 +0.09 +0.05   A4V                -0.007+0.015      -030                           
+6515 NOVA 1604                                     V843 Oph 0 0 0      0 0 0 0 0      0 0                                                                                                           *
+6516          BD-00 3300 158614141702       10598           172514.8-005848173023.8-010345 22.40 17.44 5.31  +0.72 +0.31 +0.36   G9IV-VHdel 1       -0.117-0.170 +.054-077SBO        0.1   0.7      *
+6517          CD-3312149 158619208921                       172511.8-333734173147.4-334210354.39-00.05 6.44  +1.19               K2III              -0.005-0.015      -034                           
+6518          BD+67 1014 158633 17474                       172518.4+672326172500.2+671823 97.56 33.16 6.43  +0.76 +0.29         K0V                -0.525-0.004 +.078-040SB                         
+6519 51    OphCD-2313412 158643185470               9037    172518.8-235307173125.0-235746  2.52  5.34 4.81   0.00 -0.06 +0.02   B9.5Ve             +0.004-0.027 +.040-012V                          
+6520          CD-2612152 158704185474                       172531.7-261135173144.4-261611  0.62  4.02 6.05  -0.06 -0.37         B9p                -0.004-0.025      +000                          *
+6521          BD+12 3234 158716102869                       172543.2+120004173022.4+115530 34.76 23.32 6.39R +0.06 +0.01         A1V                -0.026+0.053      -025    =< 41                  
+6522          CD-3411757 158741208935              V949 Sco 172547.1-341213173224.5-341647353.98-00.47 6.17  +0.35               F2V                -0.017-0.039      -050                           
+6523          CD-4111742 158799228110                       172604.2-410557173307.4-411025348.27-04.34 5.84  +0.06 -0.17         B9Ib-II            +0.004-0.024      -019                           
+6524          BD+02 3337 158837122465       10607           172620.4+024758173121.3+024328 26.03 19.03 5.59  +0.84 +0.58         G8III+A7           -0.014+0.019      -029SB         0.0   0.1      *
+6525          CP-59 7071 158895244866                       172639.7-594633173534.9-595046332.31-14.42 6.28  -0.08 -0.46         B5II-III           -0.007-0.009      -009                           
+6526 76Lam HerBD+26 3034 158899 851631460I          9070    172641.7+261109173044.3+260638 49.48 28.44 4.41  +1.44 +1.68 +0.75   K3.5III            +0.020+0.018 +.016-026     < 17                 *
+6527 35Lam ScoCD-3711673 158926208954 652  W       Lam Sco  172649.0-370151173336.5-370614351.74-02.21 1.63  -0.22 -0.89 -0.28   B2IV+B             -0.001-0.029      -003SB2   163 10.3  94.9AC   3*
+6528          BD+31 3047 158974 66103                       172708.1+311358173055.4+310930 55.03 29.87 5.61  +0.95               G8III              +0.009+0.022      -026V?                         
+6529          BD+80  544 158996  28593384I                  172711.3+801330171937.0+800811112.37 30.58 5.72  +1.50 +1.80         K5III              +0.016+0.004      -007                           
+6530          CP-53 8682 159018244870                       172714.5-531658173520.0-532110338.04-11.11 6.10  +0.02               B9III               0.000-0.016      +007V?                         
+6531          BD+39 3147 159026 66102                       172719.7+385725173040.3+385256 63.77 31.69 6.43  +0.49 +0.22         F6III              +0.013+0.015      -027      139                  
+6532          BD+12 3241 159082102897                       172735.5+120009173215.0+115549 34.98 22.90 6.42  -0.01 -0.20         B9.5VpHgMn         +0.024+0.025      -012SBO    32                 *
+6533 78    HerBD+28 2767 159139 85182                       172753.9+282847173149.6+282427 52.06 28.91 5.62R  0.00 -0.05         A1V                +0.006+0.028      -026SB?   245                  
+6534          BD-05 4461 1591701417303392                   172809.4-054017173329.9-054441 18.56 14.46 5.62  +0.18 +0.09         A5V                -0.039-0.091      -026      255                  
+6535          CD-3212935 159176208977      W        9167    172810.4-323045173442.5-323454355.67  0.05 5.70  +0.04 -0.86         O7V+O7V            +0.008-0.005      -004SB2O  161  4.8   5.4AB   3*
+6536 23Bet DraBD+52 2065 159181 30429 653I  10611           172810.3+522231173026.0+521805 79.58 33.31 2.79  +0.98 +0.64 +0.48   G2Ib-IIa           -0.016+0.015 +.013-020V      13  8.9   4.2AB   3*
+6537  1Sig AraCD-4611661 159217228162                       172812.8-462612173539.6-463020343.98-07.58 4.59  -0.03 -0.09 -0.05   A0V                -0.028-0.035 -.014+004                           
+6538          BD+34 2989 159222 66118                       172825.9+342029173201.1+341615 58.58 30.43 6.56  +0.65 +0.17 +0.32   G5V                -0.233+0.050 +.055-052V?                        *
+6539          CD-3711702 159312209001                       172854.3-372218173543.0-372624351.69-02.75 6.48  +0.01               A0V                -0.013-0.038      -008                           
+6540          BD+57 1774 159330 30434                       172907.3+575700173043.8+575235 86.25 33.33 6.40R                     K2III              +0.030-0.030      -014SB                         
+6541          BD+19 3354 1593321029123393                   172902.0+191944173322.8+191524 42.48 25.53 5.64  +0.48 -0.02         F6V                -0.030-0.090 +.032-059V   =< 10                  
+6542          BD+16 3218 1593531029173394                   172910.9+162318173339.4+161903 39.51 24.36 5.69  +1.01 +0.82 +0.49  gK0                 -0.001-0.051 +.030-022                           
+6543          BD+14 3279 159354102918    I         V642 Her 172910.4+145446173342.8+145030 38.03 23.77 6.48  +1.60 +1.58 +1.28   M4IIIa             +0.023-0.070      +030                          *
+6544          BD-11 4411 1593581606531461  W                172912.6-111027173446.4-111431 13.86 11.40 5.55  +0.02 -0.17         B8Vn               +0.005+0.006      -011           3.0  54.6      *
+6545 52    OphBD-21 4659 159376185526              V2125 Oph172917.5-215835173518.5-220238  4.63  5.62 6.57  +0.01 -0.18         B8p                -0.004-0.009      -012V                         *
+6546          CD-3812044 159433209019               9205    172939.5-383352173632.8-383807350.77-03.53 4.29  +1.09 +0.90 +0.55   K0IIIb             -0.012-0.201 +.018-049V                          
+6547          CD-4911577 159463244894                       172941.5-495935173727.2-500336341.08-09.69 5.93  +1.10               K0III              -0.009-0.099      +003                           
+6548 53    OphBD+09 3424 159480122526       10635A          172951.8+093915173436.7+093512 32.95 21.39 5.81  +0.02 -0.01         A2V                +0.005-0.008      -014       16  2.0  41.3AB   4*
+6549   Pi  AraCP-54 8403 159492244896                       172952.7-542559173805.6-543001337.24-12.04 5.25  +0.20 +0.08         A5IV-V             -0.039-0.150 +.057-003       48                  
+6550          BD+41 2850 159501 467921462                   172956.9+411851173307.3+411437 66.60 31.66 5.74  +1.09 +0.96        gK1                 -0.068-0.060 +.015-029V?                         
+6551          BD+16 3220 159503102928                       172959.2+163418173427.2+163014 39.78 24.26 6.40R                     A8Vn               -0.004-0.015      -041      142                  
+6552          CP-85  469 1595172587793989                   172959.3-851034180134.1-851253308.13-26.00 6.45  +0.44 +0.02         F5IV               -0.007-0.142      -023                           
+6553   The ScoCD-4212312 159532228201 654           9233    173007.9-425603173719.2-425952347.14-05.98 1.87  +0.40 +0.22 +0.20   F1II               +0.015-0.002 +.027+001      105                 *
+6554 24Nu 1DraBD+55 1944 159541 30447 655   10628B  9163    173012.3+551509173210.6+551103 83.03 33.14 4.88  +0.26 +0.04 +0.13   A6V                +0.147+0.057 +.035-015SB     66  0.0  62.3      *
+6555 25Nu 2DraBD+55 1945 159560 30450 657   10628A  9164    173017.7+551428173216.0+551023 83.02 33.12 4.87  +0.28 +0.06 +0.13   A4m               v+0.148+0.056 +.035-016SBO    50  0.0  62.3      *
+6556 55Alp OphBD+12 3252 159561102932 656I A        9189    173017.5+123758173456.1+123336 35.90 22.57 2.08  +0.15 +0.10 +0.08   A5III              +0.120-0.226 +.067+013SB?   219        0.1      *
+6557          CD-3711723 159633209034                       173035.7-380012173726.8-380356351.34-03.37 6.26  +1.25               G2Ib               -0.013+0.026      +012                           
+6558          CD-4212327 159707228220                       173057.9-424904173808.5-425250347.32-06.04 6.10  -0.06 -0.26 -0.02C  B8V                +0.002-0.041      +013                           
+6559          BD+21 3157 159834 85232       10655           173143.1+210336173559.6+205946 44.53 25.59 6.10  +0.19 +0.17         A7IV               +0.012-0.015      -017SB     22  3.5  10.4      *
+6560          BD+57 1780 159870 30464      S                173153.1+573729173331.7+573332 85.87 32.96 6.17  +0.59 +0.37 +0.38   G5III+A5V          +0.015+0.014      -001SBO    28        0.1      *
+6561 55Xi  SerBD-15 4621 159876160700 658I W        9270    173151.6-152008173735.2-152355 10.61  8.66 3.54  +0.26 +0.14 +0.13   F0IVDel Sct        -0.042-0.058 +.030-043SBO    32  9.4  22.0      *
+6562          BD-15 4622 159877160701                       173151.9-153035173736.2-153416 10.46  8.57 5.94  +0.37               F0IV               -0.009-0.001      -008       30                  
+6563          BD+37 2908 159925 661653395                   173216.1+372152173542.4+371806 62.20 30.40 6.10  +0.98 +0.82:        G9III              +0.015+0.003      +004                           
+6564          BD+28 2787 159926 85236                       173211.9+281449173607.9+281105 52.14 27.94 6.38R                     K5                 -0.031+0.017      -034                           
+6565          CP-72 2086 159964257525      W                173218.0-721017174419.7-721315321.16-20.84 6.49  +0.48 -0.04         F7IV+F5V           -0.003+0.113D+.032+035SB         0.3   0.5      *
+6566 27    DraBD+68  938 159966 17526 659I W                173221.7+681156173157.9+680806 98.42 32.40 5.05  +1.08 +0.92 +0.53   K0III              -0.012+0.134 +.020-073SB   < 17  6.2 163.4       
+6567 57Mu  OphBD-08 4472 1599751417723399                   173224.5-080328173750.7-080708 17.00 12.34 4.62  +0.11 -0.20 +0.11   B8II-IIIp:Mn       -0.009-0.017      -019      134                  
+6568          BD-10 4528 160018160708    I                  173236.6-105159173809.5-105535 14.57 10.85 5.75  +1.23              gK0                 -0.013-0.010      -033                           
+6569   Lam AraCD-4911616 160032228257              Var?     173240.3-492113174023.6-492456341.89-09.77 4.77  +0.40 -0.04 +0.22   F3IV               +0.078-0.176 +.044+004        0                 *
+6570          BD+30 3033 160054 661753397                   173248.3+305048173636.7+304707 55.00 28.59 6.02  +0.16 +0.09         A5V                +0.030-0.005      -017      101                  
+6571 79    HerBD+24 3218 160181 852643400  S                173323.9+242210173731.1+241836 48.12 26.41 5.77  +0.11 +0.07         A2Vn               -0.012+0.008      -004V     210        0.1       
+6572          CD-4611747 1602632282793404                   173346.6-465202174116.3-465519344.13-08.62 5.79  -0.01 -0.06 +0.01C  A0V                +0.012-0.009      -012                           
+6573 26    DraBD+61 1678 160269 17546       10660           173357.4+615704173459.5+615230 91.00 32.65 5.23  +0.61 +0.10         G0Va               +0.260-0.507 +.069-013V?     41  2.8   0.6AB   3*
+6574 82    HerBD+48 2542 160290 46838    I                  173400.7+483837173637.6+483508 75.26 32.06 5.37  +1.15 +1.06 +0.61  gK1                 +0.031+0.065 +.017+029V?                         
+6575          BD+02 3373 160315122607      W                173405.6+020507173908.5+020141 26.33 16.98 6.26  +1.03 +0.83 +0.53   K0III+F4IV         +0.040-0.021      +000SB         1.1 111.2AB   3*
+6576          CD-5011474 160342244954              V626 Ara 173414.9-502726174203.9-503038341.06-10.56 6.24  +1.76 +1.89 +0.85E  M3+II-III          +0.024-0.012      -027                          *
+6577          BD+13 3421 160365102999                       173422.1+132305173857.8+131945 37.09 21.99 6.12  +0.56               F6III              -0.023+0.038      +000SB     82                  
+6578          BD-02 4425 160471141798    I          9461    173459.6-020552174011.8-020909 22.64 14.77 6.19  +1.67 +1.89         K2.5Ib             -0.023-0.018      -049V                          
+6579          BD+32 2964 160507 66214                       173507.8+324744173849.7+324422 57.29 28.67 6.37R                    gG5                 +0.017-0.011      -015                           
+6580   Kap ScoCD-3812137 160578209163 660          Kap Sco  173534.1-385842174229.3-390148351.04-04.72 2.41  -0.22 -0.89 -0.22   B1.5III            -0.006-0.027      -014SB    131                 *
+6581 56Omi SerBD-12 4808 1606131607473405          Omi Ser  173547.6-124919174124.9-125231 13.28  9.17 4.26  +0.08 +0.10 +0.02   A2V                -0.069-0.052 +.006-030SB2   125                 *
+6582   Eta PavCP-64 3662 160635254020 661                   173555.0-644033174544.0-644326328.40-17.75 3.62  +1.19 +1.17         K2II               -0.014-0.054 +.025-008                           
+6583          CD-3611804 160668209172                       173603.6-365342174251.0-365645352.86-03.69 5.54  +1.55               K5III              +0.001-0.034      -004                           
+6584          BD+31 3075 160677 66231    I                  173610.8+311519173957.5+311209 55.68 28.02 6.03  +1.58 +1.98         M2IIIab            -0.012+0.015      -009V?                         
+6585   Mu  AraCD-5111094 160691244981 662                   173612.2-514650174408.7-515003340.06-11.50 5.15  +0.70 +0.24 +0.34   G3IV-V             -0.014-0.194 +.077-009                           
+6586          CP-57 8703 160720244989      W                173619.0-572953174455.8-573243334.99-14.37 6.01  +0.90               G8III              +0.010-0.002      -006           0.0   0.2AP   3 
+6587          CD-3213208 160748209176                       173632.9-330008174306.9-330304356.21-01.70 6.40  +1.81 +2.00         M1III              +0.008+0.003      -003                           
+6588 85Iot HerBD+46 2349 160762 46872 663  W       Iot Her  173638.4+460334173927.9+460023 72.32 31.27 3.80  -0.18 -0.69 -0.17   B3IV               -0.005+0.005 +.005-020SB1O   11  8.3 116.0      *
+6589          BD+15 3246 160765103020                       173639.8+151347174111.0+151041 39.15 22.25 6.34  +0.03 +0.02         A1V                -0.012-0.015      -023       85                  
+6590          BD+06 3498 160781122646                       173639.7+062150174132.3+061846 30.62 18.41 5.95  +1.26 +1.18         G7III              -0.005-0.010      -031                           
+6591          BD+31 3076 160822 66243      W                173655.2+312027174041.2+311715 55.83 27.90 6.28  +1.05 +0.88         K0III              -0.067-0.073      -006           2.1 115.0       
+6592          BD+24 3225 160835 85310       10715           173659.0+243346174105.5+243048 48.64 25.71 6.36  +1.20 +1.18 +0.59   K1III+F4V          -0.019+0.058 +.002-032SB         3.0  16.3AB   3*
+6593          CD-2711850 160839185655      D                173659.9-275009174317.8-275303  0.63  0.99 6.36  +0.47               A9V:               +0.010-0.006      -026                          *
+6594          BD+16 3256 160910103033       10723           173729.3+155954174158.7+155707 40.00 22.38 5.52  +0.38 -0.05         F4V w              +0.009+0.101 +.036-044V?     30  2.8   0.6AB   3*
+6595 58    OphBD-21 4712 1609151856601463  D                173726.2-213804174325.8-214100  5.94  4.21 4.87  +0.47 -0.03 +0.24   F6V                -0.095-0.043 +.060+011V       0  1.8   0.0      *
+6596 28Ome DraBD+68  949 160922 17576 664  W                173732.1+684815173657.1+684529 99.08 31.87 4.80  +0.43 -0.01 +0.22   F5V                +0.002+0.323 +.045-014SBO    26  8.3  72.3      *
+6597          CD-4212431 160928228363      W                173731.6-424101174442.0-424344348.08-06.99 5.87  +0.16 +0.09         A1V+F0IV           +0.005+0.019      -009           0.1   0.1      *
+6598          BD+69  933 160933 17572                       173731.0+693756173639.7+693415100.04 31.79 6.42  +0.58 +0.09         F9V                -0.055-0.208 +.018-053V                          
+6599          BD+43 2781 160950 46883                       173735.9+433111174037.6+432815 69.44 30.67 6.59R                     K2                 +0.056+0.061      -029                           
+6600          BD-13 4732 161023160784                       173809.5-132734174348.6-133031 13.03  8.35 6.39  +0.37 -0.07         F0V                -0.048-0.109      -007    =< 15                  
+6601          BD-07 4487 161056141832                       173823.1-070200174347.0-070446 18.67 11.58 6.30  +0.38 -0.48 +0.27   B1.5V              -0.001-0.006      -026V                          
+6602 83    HerBD+24 3231 161074 85344    I W                173822.3+243652174228.4+243351 48.81 25.43 5.52  +1.46 +1.69 +0.80   K4III              -0.055-0.105 +.020-027           3.6 159.6       
+6603 60Bet OphBD+04 3489 161096122671 665I                  173831.9+043632174328.4+043402 29.21 17.19 2.77  +1.16 +1.24 +0.57   K2III              -0.040+0.159 +.033-012V   =< 17                 *
+6604          BD+14 3321 1611491030523407                   173848.6+142025174322.0+141742 38.51 21.41 6.24  +0.42 +0.18         F5II               +0.006+0.023      -042                          *
+6605          BD+57 1791 161162 305153406                   173856.4+572131174036.2+571837 85.58 32.00 6.77  +0.92 +0.58         K0                 -0.004+0.027      -014                           
+6606          BD+72  800 161178  8862                       173902.4+723030173708.8+722721103.38 31.35 5.86  +1.01               G9III              +0.021+0.022 -.009+008V?                         
+6607          BD+51 2243 161193 30522                       173904.1+515159174121.8+514905 79.13 31.60 5.99  +1.05              gK0                 -0.028-0.014      -009V?                         
+6608 84    HerBD+24 3237 161239 85360                       173915.3+242216174321.6+241940 48.64 25.16 5.71  +0.65 +0.27 +0.33   G2IIIb             -0.115+0.071 +.006-026V?  =< 10                  
+6609 61    OphBD+02 3390 161270122690       10750A          173932.7+023721174434.0+023446 27.50 16.04 6.17  +0.07 -0.01         A1IV-V             +0.004+0.014      -031SB    100  0.4  20.6AB   3*
+6610          BD+02 3391 161289122691       10750B          173934.0+023720174435.4+023444 27.50 16.03 6.56                      A0V                +0.004+0.010      -030      115  0.4  20.6AB   3*
+6611          BD+14 3329 161321103069       10749  V624 Her 173944.1+142712174417.3+142437 38.72 21.25 6.19  +0.21 +0.20 +0.12   A3m                +0.001+0.018      -031SB2O   35  5.7  39.7      *
+6612          BD+44 2757 161369 469063408I                  174007.6+440741174305.6+440504 70.23 30.34 6.34  +1.54 +1.84         K4III              -0.040+0.034      -060                           
+6613          CD-3812189 161390209246      W                174015.4-380418174707.3-380642352.30-05.02 6.43  -0.02               B9V+A1V            -0.002-0.007D+.009+001           0.3   0.1      *
+6614          CP-55 8312 1614202450443412                   174017.7-552154174838.1-552406337.19-13.80 6.11  +0.28               A9IV               -0.018+0.036      -021                           
+6615   Iot1ScoCD-4011838 161471228420 666  W                174035.4-400517174735.1-400737350.61-06.13 3.03  +0.51 +0.27         F2Iae               0.000-0.008 +.019-028SB     36  9.9  37.5       
+6616  3    SgrCD-2711930 1615921857551464I         X Sgr    174115.9-274734174733.6-274951  1.17  0.21 4.54  +0.80 +0.50         F7II               -0.001-0.009 +.035-013V      24                 *
+6617          BD-22 4423 161664185765    I          9682    174143.0-222626174745.6-222841  5.77  2.94 6.18  +1.49               G6IbHdel 1         +0.003-0.011      -022V                          
+6618          BD+53 1978 161693 30538                       174153.8+535037174359.3+534806 81.49 31.36 5.75  +0.01 +0.05  0.00   A2V                +0.022-0.015      -002V     130                 *
+6619          BD+31 3090 161695 663113410                   174154.5+313239174540.3+313017 56.40 26.94 6.23   0.00 -0.22         A0Ib               +0.011-0.005      +002                           
+6620          BD-14 4770 1617011608223413                   174154.5-144118174736.8-144333 12.44  6.93 5.94  +0.05 -0.32         B9pHgMn            -0.019-0.020      -025SB2O   16                 *
+6621          CD-2612367 161756185779              V3894 Sgr174212.6-265621174827.8-265830  2.00  0.48 6.35  +0.12 -0.42         B4IVe               0.000-0.012      +009V                         *
+6622          CP-53 8799 161783245065      W       V539 Ara 174220.0-533445175028.2-533644338.94-13.20 5.92  -0.08 -0.64         B2V+B3V            -0.014-0.006      -008SB2O   91  3.0  12.3      *
+6623 86Mu  HerBD+27 2888 161797 85397 667I  10786           174232.6+274645174627.5+274314 52.45 25.63 3.42  +0.75 +0.39 +0.38   G5IV               -0.311-0.751 +.108-016V      20  6.4  33.8AxBC 4*
+6624          CP-60 6950 161814254057      W                174235.6-600756175135.5-600952332.99-16.33 5.78  +1.00               K0III              -0.005-0.028      +017           7.2  30.        
+6625          BD+38 2997 161815 663153411                   174233.9+385514174553.7+385253 64.48 28.79 6.52  +1.00 +0.68         K0                 +0.003-0.028      -012                           
+6626          BD+39 3219 161832 66317       10782  V826 Her 174240.3+392136174558.5+391921 64.97 28.88 6.68  +1.39 +1.46         K3III+F7V          +0.012+0.016      -032SBO        3.1   7.9AB   3*
+6627          BD+17 3334 161833103106       10795           174243.1+174402174708.0+174150 42.25 21.93 5.72R +0.01  0.00         A1V                +0.011-0.007D+.004+003SB     54  1.3   0.6      *
+6628          CD-3114609 161840209303                       174240.7-314008174910.5-314212358.03-02.09 4.83  -0.04 -0.29         B8V                +0.011-0.015      -013       45                  
+6629 62Gam OphBD+02 3403 161868122754 668                   174252.6+024441174753.6+024226 28.02 15.36 3.75  +0.04 +0.04  0.00   A0Vnp              -0.022-0.074 +.039-007SBO   205                 *
+6630          CD-3711907 161892209318 669  W                174303.0-370041174951.5-370236353.50-04.94 3.21  +1.17 +1.19         K2III              +0.049+0.033 +.040+025          11.5  41.7AC   3 
+6631   Iot2ScoCD-4011886 161912228466      W                174311.4-400329175011.2-400526350.89-06.54 4.81  +0.26  0.00         A2Ib               +0.007-0.008 -.001-010V?     39  6.1  32.6       
+6632          CP-53 8812 161917245072                       174305.6-530556175111.0-530750339.43-13.06 6.09   0.00               B9.5III-IV         +0.006-0.013      +019                          *
+6633          BD+03 3493 161941122766                       174321.6+035018174820.2+034815 29.08 15.76 6.22  +0.16 -0.02         B9.5V              +0.007+0.004      -044    =< 41                  
+6634          CP-65 3507 161955254063                       174318.6-652730175318.4-652921328.03-18.80 6.49  +1.08 +1.00         K0-1III            -0.017-0.083      -045                           
+6635          CP-76 1226 161988257542      W                174331.9-760918175741.8-761039317.57-23.16 6.07  +1.20 +1.28         K2III              +0.002+0.017      +037           7.9  25.5       
+6636 31Psi1DraBD+72  804 162003  8890 670   10759A          174342.9+721153174156.3+720856102.97 31.03 4.58  +0.42 +0.01 +0.23   F5IV-V             +0.025-0.267 +.054-010V?     14  1.2  30.2AB   4*
+6637 31Psi1DraBD+72  805 162004  8891       10759B          174344.6+721222174158.0+720925102.98 31.03 5.79  +0.53 +0.02         G0V                +0.030-0.278 +.054-010V?  =< 25  1.2  30.2AB   4*
+6638          BD+20 3570 162076 854291465                   174407.3+203555174824.8+203356 45.25 22.73 5.69  +0.94 +0.71 +0.47   G5IV               +0.026+0.008      -026                           
+6639          BD+02 3406 162113122787                       174416.3+015929174918.9+015740 27.50 14.70 6.47  +1.24 +1.26         K0III              -0.025+0.065      -058                           
+6640          CD-4511958 162123228490                       174420.8-453417175144.5-453602346.21-09.52 6.11  +0.95               G6III              +0.009-0.005      -007                           
+6641          BD+47 2537 162132 46954      S                174427.0+473848174708.1+473644 74.39 30.19 6.43  +0.11 +0.06         A2V s              -0.004+0.005      -026SBO              0.1      *
+6642          BD+19 3435 162161103131                       174427.2+191714174847.9+191519 43.97 22.16 6.12  +0.02 -0.09         A1V                -0.006+0.022      -025SB?    66                  
+6643          CD-4011905 162189228489      W                174430.6-404431175132.8-404621350.43-07.10 5.96  +1.59 +1.83 +0.95E  M2III              -0.028-0.053      -085           6.5  23.6       
+6644 87    HerBD+25 3353 162211 854373415I                  174445.8+253922174849.2+253722 50.44 24.44 5.12  +1.16 +1.12 +0.58   K2III              -0.003-0.039 +.016-026     < 17                  
+6645          CD-3014802 162220209357      W                174446.3-303139175112.5-303326359.24-01.88 6.66  +0.04 -0.07         A0Vn               +0.002-0.011      -009           1.5  10.2      *
+6646          CP-81  799 1623372587873990                   174526.2-812827180526.7-812911312.15-25.13 6.35  +1.50 +1.75         K3-4III            +0.018-0.040      -003                           
+6647          CD-3412165 162374209383              V957 Sco 174533.5-344619175213.6-344757355.69-04.22 5.90  -0.10 -0.64         B6V               v+0.004-0.004      -013V    < 40                 *
+6648          CD-3412170 162391209390                       174540.9-342324175219.7-342500356.03-04.04 5.84  +1.13               G8III              -0.001+0.003      -021V                          
+6649          CD-4112139 162396228510                       174543.7-415755175252.7-415948349.48-07.92 6.20  +0.54               F8IV-V             +0.154-0.196 +.027-014                           
+6650          BD+12 3305 162468103145                       174604.5+115832175043.5+115648 37.02 18.81 6.17  +1.25 +1.26         K1III-IV           -0.022-0.024      -049                           
+6651          CD-3412186 162496209397                       174611.4-340521175249.2-340651356.34-03.98 6.06  +1.23               K1III              +0.001+0.017      -015V?                         
+6652          CD-3412187 162515209401                       174614.8-345937175255.9-350107355.57-04.45 6.45  +0.02 -0.07         B9.5V              +0.015+0.007      -009SB2O   95                 *
+6653          CD-3512013 162517209404                       174614.5-353551175257.9-353727355.05-04.76 6.03  +0.34 +0.09         F2III-IV           +0.046-0.047      -021                           
+6654          BD+29 3126 162555 85464                       174630.2+292056175022.9+291920 54.42 25.32 5.50  +1.05       +0.55   K1III              +0.029+0.049      -015                           
+6655          BD+22 3227 162570 85468                       174635.7+222039175048.4+221859 47.23 22.86 5.98R                     A9V                +0.014-0.016      +004      212                  
+6656 30    DraBD+50 2468 162579 305913416  S                174641.0+504817174904.3+504652 78.07 30.30 5.02  +0.02 +0.01         A2V                -0.048+0.211 -.002-055V     140        0.1       
+6657          CD-3412200 162586209411      W                174639.6-344223175319.6-344350355.86-04.38 6.17  -0.03 -0.35         B8V                +0.005-0.001D+.005-012       37  0.0   0.1      *
+6658          CD-3412203 162587209416      W                174642.9-345215175323.3-345343355.72-04.47 5.60  +1.14 +1.01         K3III              -0.009-0.010D+.003-007SB         0.1   0.4      *
+6659          BD-01 3412 1625961419133418                   174649.2-011240175159.5-011412 24.91 12.61 6.35  +1.12 +0.89         K0                 -0.002+0.003      -044SBO                       *
+6660          CD-3412219 162678209425                       174705.3-344545175345.5-344709355.86-04.48 6.38   0.00 -0.06         B9V                +0.009-0.003      -015V      37                 *
+6661          BD-06 4672 162714141926    I:        Y Oph    174717.0-060709175238.8-060837 20.60 10.12 6.21  +1.40 +1.01 +0.95   F8Ib-G3Ib         v+0.008-0.009 -.006-005SB                        *
+6662          CD-3412226 162724209428      W       V906 Sco 174714.7-344347175354.9-344509355.90-04.49 5.96  -0.01 -0.10         B9V+B9V            +0.021-0.003      -005SB2O   95  0.8   0.3      *
+6663          CD-3412228 162725209430              V951 Sco 174717.8-344830175358.1-344954355.84-04.54 6.42  +0.01 -0.06         ApSi*              +0.007-0.023      -017       34                 *
+6664 88    HerBD+48 2581 162732 469973417          V744 Her 174726.3+482516175003.3+482339 75.36 29.82 6.68  -0.11 -0.41         BepShell          v+0.004+0.012      -012SBO   300                 *
+6665          BD+15 3292 162734103161       10850           174727.7+152100175158.5+151933 40.41 19.92 6.46R                     K0III               0.000+0.031D+.004-043V?         0.2   0.8AB   6*
+6666          BD-10 4560 162757160885                       174730.1-105230175303.6-105359 16.45  7.70 6.18  +1.11              gK1                 +0.055-0.033      -035V?                         
+6667          BD+01 3528 162774122861    I          9800    174731.3+011946175235.4+011818 27.29 13.67 5.95  +1.58 +1.92         K5III              -0.047-0.017      -065                           
+6668          CD-3412244 162817209446                       174748.0-342642175427.2-342759356.21-04.44 5.96  -0.01 -0.10         B9.5V              +0.010+0.006      -016V?     65                 *
+6669          BD+40 3225 162826 47009                       174759.1+400550175114.0+400421 66.06 28.06 6.46R                     G0V                -0.012+0.012      +002    =<  6                  
+6670          BD+06 3566 1629171228803420                   174821.9+060718175314.2+060605 31.78 15.71 5.77  +0.42 -0.01         F3-5IV-V           -0.122+0.069 +.038-033SB     30                  
+6671          CD-3612008 162926209458                       174821.9-362720175507.9-362833354.53-05.57 6.06  +0.08               B9.5III            -0.014-0.009      -015                           
+6672          CD-2413615 162978185928                       174844.7-245202175454.0-245314  4.54  0.30 6.20  +0.04 -0.89         O7.5II((f))        -0.005-0.001      -011       50:                *
+6673          BD+40 3228 162989 664023419I                  174849.4+400014175204.7+395856 66.01 27.88 6.04  +1.33 +1.49        gK4                 -0.011+0.054 +.015-066SB                         
+6674          BD+46 2379 163075 47023                       174914.7+464010175201.0+463836 73.44 29.22 6.38  +1.09 +0.77         K0III              +0.039-0.122      -028                           
+6675          CD-4412201 1631452285623425                   174929.5-441931175647.4-442032347.76-09.69 4.86  +1.21 +1.22         K2III              -0.006-0.017 +.017+045V?                         
+6676          BD+11 3283 1631511031943422  W                174933.5+110918175414.2+110750 36.62 17.68 6.38  +0.45               F5Vn               -0.058-0.165 +.007-041SB    120  0.2   0.1      *
+6677 90    HerBD+40 3233 163217 47037    I  10875   9834    175002.7+400136175318.1+400029 66.09 27.66 5.16  +1.18 +1.12 +0.61   K1IIIbCN-1         +0.011+0.053 +.014-035V?   < 19: 3.3   1.6      *
+6678          CD-4012001 163234228564                       174955.0-401723175655.8-401820351.35-07.76 6.43  +1.43 +1.65         K3III              +0.016+0.005      -006                           
+6679          BD-18 4686 1632451609093423                   175002.0-184704175555.0-184808  9.92  3.16 6.52  +0.05 +0.05         A4V                +0.016-0.017      +004V                         *
+6680          CD-2813878 163318185975                       175023.0-280257175641.9-280355  1.99-01.65 5.80  +0.21               A7III/V:           +0.040-0.017      +007                           
+6681          BD-15 4722 163336160915       10891           175033.8-154741175619.0-154845 12.56  4.57 5.89  +0.05               A1V                -0.010-0.063      -024V      56  3.2  20.6AB   3*
+6682          CD-4112231 163376228578                       175041.4-414207175747.7-414258350.18-08.59 4.88  +1.65 +1.97 +0.81E  M0III              -0.015-0.010 -.005+004                           
+6683          CD-3912058 163433209524      W                175101.8-390721175757.8-390813352.48-07.37 6.29  +0.01               A0IV-V             -0.005-0.039      -001           1.5   0.7       
+6684          BD+00 3813 163472122935              V2052 Oph175112.6+004108175618.4+004013 27.16 12.55 5.82  +0.09 -0.65         B2IV-V             -0.005+0.003      -017SB    120                 *
+6685 89    HerBD+26 3120 163506 855451468I         V441 Her 175123.0+260357175525.2+260300 51.43 23.19 5.46  +0.34 +0.27 +0.21   F2Ib              e+0.004+0.006 -.004-029SB     23                 *
+6686          BD-04 4376 163532141979    I                  175130.9-040403175647.7-040455 22.94 10.21 5.47  +1.16 +1.06        gG9                 -0.012-0.008      -039V                          
+6687          BD+22 3237 163547 855523427I                  175138.7+222846175550.8+222751 47.84 21.83 5.58  +1.24              gK3                 -0.002+0.002      -044                           
+6688 32Xi  DraBD+56 2033 163588 30631 671I W                175147.9+565318175331.7+565222 85.17 30.23 3.75  +1.18 +1.21 +0.59   K2-III             +0.094+0.080 +.035-026V?   < 17 11.1 316.       *
+6689          BD+00 3816 163624122950       10912           175156.9+000449175704.3+000359 26.70 12.10 5.97  +0.10 +0.12         A3V                +0.028-0.016D+.004-011           0.2   0.2       
+6690          BD+06 3578 163641122949                       175203.6+063004175656.0+062916 32.57 15.06 6.29   0.00 -0.25         B9III              +0.026+0.002      -014       80                  
+6691          CD-3612060 163652209545      W                175208.0-365053175855.6-365130354.57-06.42 5.74  +0.90               G8III              +0.008+0.013      -087V?         2.4  51.7      *
+6692          CD-2813936 163685186025      D                175218.3-284453175839.1-284533  1.61-02.37 6.01  -0.08 -0.56         B3IV                0.000-0.009      -009           1.0   0.3       
+6693          CD-3015035 163755          I W     A  9929    175239.9-301434175905.2-301511  0.36-03.19 5.16  +1.77 +1.95         M1Ib               +0.002-0.010 +.012-020SB         1.8   5.5AB   3*
+6694          CD-3015035 163756209553      W     B  9929    175240.3-301436175905.5-301512  0.36-03.19 7.04  +1.06 +0.80         G8II               -0.020-0.002 +.012-023V          1.8   5.5AB   3*
+6695 91The HerBD+37 2982 163770 66485 672I          9890    175249.3+371549175615.2+371502 63.26 26.42 3.86  +1.35 +1.46 +0.63   K1IIaCN+2         e+0.004+0.006 +.002-027V    < 19:                *
+6696          BD+11 3299 163772103243                       175245.7+110324175726.9+110239 36.89 16.93 6.36  +0.11 +0.08         A1V                -0.017-0.024      -016SB    112                  
+6697          BD+24 3283 163840 85575      S                175306.5+240020175714.3+235945 49.51 22.08 6.30  +0.63               G2V                -0.024+0.076      -034SB  =<  6  1.5   0.1      *
+6698 64Nu  OphBD-09 4632 163917142004 673I                  175331.2-094541175901.6-094625 18.17  6.98 3.34  +0.99 +0.88 +0.48   K0IIIaCN-1         -0.007-0.116 +.021+013     < 17                  
+6699          BD+55 1995 163929 306453428                   175333.7+555853175523.7+555817 84.15 29.90 6.10  +0.32 +0.08         F0IV               +0.037+0.126      -027       82                 *
+6700  4    SgrCD-2313731 1639551860613430                   175341.2-234825175947.6-234858  6.02-00.13 4.76  -0.04 -0.05 -0.02   B9V                +0.001-0.047 +.010-018V     191                  
+6701 35    DraBD+76  667 163989  8939 675                   175355.4+765834174927.0+765746108.41 29.86 5.04  +0.49 +0.08         F6IV-V s           +0.037+0.248 +.032-023       11                  
+6702          BD+45 2627 163990 47080    I         OP Her   175356.2+452147175648.4+452103 72.16 28.17 6.02  +1.64 +1.52 +1.90   M5IIbS             +0.008-0.028      +013V                         *
+6703 92Xi  HerBD+29 3156 163993 85590 674I          9927    175352.7+291531175745.9+291452 54.91 23.77 3.70  +0.94 +0.70 +0.46   G8+III             +0.084-0.017 +.021-002     < 19:                 
+6704          BD-20 4940 164028186070      D                175403.1-201954180000.1-202021  9.06  1.56 6.21  +1.40               K0II-III           +0.005-0.007      -008V                         *
+6705 33Gam DraBD+51 2282 164058 30653 676I  10923           175417.0+513002175636.4+512920 79.06 29.22 2.23  +1.52 +1.87 +0.85   K5III             v-0.008-0.019 +.025-028     < 17  8.4 140.1AG   7*
+6706          BD-04 4384 164064142012    I                  175418.1-044841175936.7-044917 22.62  9.24 5.87  +1.56 +1.92         K5III              -0.014-0.093      -032                          *
+6707 94Nu  HerBD+30 3093 164136 66524              Nu  Her  175440.5+301151175830.2+301122 55.94 23.92 4.41  +0.39 +0.15 +0.23   F2II                0.000+0.007 +.007-022SB?    28                 *
+6708          CD-3612115 164245209608                       175502.5-362225180148.3-362240355.28-06.69 6.30  -0.03 -0.33         B7IV               -0.007-0.017      +014                           
+6709          BD+00 3832 164258123004              V2126 Oph175509.6+003806180015.5+003746 27.59 11.66 6.37  +0.15 +0.18         A3pSrCrEu         v-0.006+0.004      -034V?     65                 *
+6710 57Zet SerBD-03 4217 164259142025                       175511.9-034102180029.0-034125 23.73  9.59 4.62  +0.38  0.00 +0.19   F2IV               +0.147-0.045 +.048-043SB     70                  
+6711          BD+36 2986 164280 66531                       175512.9+361748175842.3+361716 62.37 25.69 6.00  +0.94              gG5                 +0.007-0.055      +010                           
+6712 66    OphBD+04 3570 164284123005              V2048 Oph175518.6+042227180015.8+042207 30.99 13.37 4.64  -0.03 -0.83 -0.02   B2Ve               +0.003-0.013      -013SB    221                 *
+6713 93    HerBD+16 3335 1643491032851469I                  175536.3+164523180003.4+164503 42.62 18.72 4.67  +1.26 +1.22 +0.59   K0.5IIb            -0.007-0.010 +.004-024     < 17                 *
+6714 67    OphBD+02 3458 164353123013 677   10966           175538.1+025611180038.7+025554 29.73 12.63 3.97  +0.02 -0.62  0.00   B5Ib               +0.002-0.008 -.002-004V      22  4.3  54.5AC   5*
+6715  6    SgrBD-17 4987 1643581609981470I                  175534.4-170911180123.1-170925 11.99  2.85 6.28  +1.80               K3III              +0.003-0.005      -022V?                         
+6716          BD-22 4503 164402186135    I: 10983   9996    175550.8-224639180154.4-224650  7.16-00.03 5.77   0.00 -0.89         B0Ib               -0.003-0.008      -013      100  7.1   8.2AB   3*
+6717          BD+78  616 164428  8946    I          9859    175548.4+781924175010.5+781824109.94 29.62 6.24  +1.44               K5                 +0.018+0.018      -007                           
+6718          BD+45 2635 164429 47106              V771 Her 175600.8+452854175852.3+452834 72.38 27.84 6.48  -0.08 -0.22         B9pSiSr            +0.002+0.027      -019V?    200:                *
+6719          BD+06 3597 1644321230173432                   175600.1+061620180052.9+061606 32.81 14.09 6.34  -0.08 -0.75         B2IV               +0.002-0.008      -014SB?                        
+6720          BD+19 3494 164447103291              Var?     175607.5+193036180027.7+193021 45.34 19.71 6.50  -0.06 -0.39         B8Vne              +0.015-0.001      -029      210:                *
+6721   Chi OctCP-87  274 164461258799 922                   175601.9-873951185446.9-873621305.62-27.14 5.28  +1.28 +1.60         K3III              -0.039-0.139      +034                           
+6722          BD+15 3327 164507103299                       175626.2+150558180057.2+150536 41.12 17.85 6.26  +0.69 +0.24         G5IV               -0.059-0.108      +004                           
+6723 68    OphBD+01 3560 164577123035       10990  10009    175640.7+011827180145.2+011819 28.38 11.64 4.45  +0.02  0.00 +0.01   A2Vn               +0.015-0.012 +.021+006SB    252  2.5   0.6      *
+6724  7    SgrCD-2413793 164584186163                       175643.4-241653180251.1-241656  5.96-00.96 5.34  +0.52 +0.26 +0.36   F3III              +0.005-0.008 +.007-012V      36                 *
+6725 34Psi2DraBD+72  818 164613  89613429                   175655.0+720053175511.2+720018102.68 30.03 5.45  +0.30 +0.15         F2-3II-III         +0.013-0.001      -002SB     45                  
+6726          BD+33 3006 164614 66551    I                  175656.5+331302180036.4+331250 59.24 24.43 5.99  +1.51              gK6                 -0.003-0.019      -016                           
+6727          BD-22 4516 164637186169                       175658.3-224307180301.7-224306  7.34-00.23 6.74  -0.05 -0.87         B0.5III            +0.003+0.007      -007SB     50                 *
+6728          BD+45 2638 164646 471213433I          9980    175704.8+453021175956.2+453005 72.45 27.66 5.67  +1.57 +1.91         M0IIIab            +0.008-0.025 +.026-010V?                         
+6729 95    HerBD+21 3280 164668 85647    I  10993B 10014    175715.3+213545180129.9+213543 47.50 20.29 5.18  +0.95 +0.57         G8III              +0.011+0.032 +.000-031V?  =< 25  0.1   6.3      *
+6730 95    HerBD+21 3280 164669 85648       10993A 10014    175715.8+213546180130.4+213544 47.50 20.29 4.96  +0.12 +0.13         A5IIIn             +0.012+0.035 +.000-030V?    180  0.1   6.3      *
+6731          CP-75 1410 164712257569 678  W                175716.2-755337181115.7-755329318.15-23.85 5.86  +1.24 +1.43         K2III              +0.010-0.295 +.016+015           7.3  25.9       
+6732          BD-05 4560 164716142045                       175726.3-052129180246.3-052131 22.52  8.29 6.76  +0.16 -0.10         B9V                +0.011-0.035      -014                           
+6733 69Tau OphBD-08 4549 164764142050       11005B 10073    175738.1-081049180305.0-081049 20.06  6.87 5.94                      F5V                +0.029-0.037 +.058-038           0.7   1.9AB   3*
+6734 69Tau OphBD-08 4549 164765142050       11005A 10073    175738.1-081049180304.9-081050 20.06  6.87 5.24  +0.38 +0.04         F2V                +0.028-0.037 +.058-040SB     25  0.7   1.9AB   3*
+6735          BD+75  647 164780  8962                       175744.4+751047175426.6+751015106.32 29.79 6.36  +0.98               K0                 -0.013+0.023 -.019-018                           
+6736  9    SgrCD-2413814 164794186204    I                  175744.5-242146180352.4-242138  6.01-01.20 5.97   0.00 -0.89 +0.02   O4V((f))           +0.002+0.003      +009SB    140                 *
+6737          BD+33 3009 164824 665623434I  10998           175756.1+331840180135.9+331841 59.41 24.26 6.15  +1.55               K5III              +0.025+0.023      -010V          6.0  14.2AB   3*
+6738 96    HerBD+20 3649 164852 85672              V820 Her 175806.5+205000180223.1+205001 46.83 19.81 5.28  -0.09 -0.61         B3IV               +0.005-0.010 +.004-015SB2O  205                 *
+6739          CD-3512229 1648702096713435  W                175806.3-355415180450.4-355405355.99-07.00 6.00  +1.16               K2III              -0.016-0.035      -016           5.2  12.5       
+6740          CP-64 3796 164871254141                       175800.3-643320180748.3-643300329.59-19.84 6.41  +1.26 +1.41         K2-3III            -0.015-0.053      -022                           
+6741 97    HerBD+22 3260 164900 85676                       175819.2+225521180230.1+225523 48.91 20.57 6.21  -0.10 -0.64         B3Vn               -0.004-0.008      -036SB                         
+6742   Gam1SgrCD-2914447 164975186237       11029  W Sgr    175837.9-293504180501.3-293448  1.58-03.98 4.69  +0.78 +0.52 +0.45   F4-G1Ib           v+0.013 0.000      -028SBO    25  0.0   0.1     4*
+6743   The AraCD-5011720 1650242452421471                   175850.7-500552180637.9-500530343.33-13.82 3.66  -0.08 -0.85         B2Ib               -0.010-0.014      +003      117                 *
+6744          BD+19 3508 165029103334                       175854.8+193638180314.7+193647 45.72 19.15 6.50R +0.01 -0.01         A0V                +0.024-0.008      -032      171                  
+6745   Pi  PavCP-63 4292 1650402541473437          10204    175857.1-634020180834.8-634006330.49-19.59 4.35  +0.22 +0.18         A7pSr              +0.013-0.188 +.036-016SB     20                 *
+6746 10Gam2SgrCD-3015215 165135209696 679I         10173    175923.0-302531180548.5-302527  0.92-04.54 2.99  +1.00 +0.77 +0.51   K0III              -0.053-0.185 +.025+022SB                        *
+6747          BD+01 3578 165174123090              V986 Oph 175934.4+015451180437.3+015509 29.27 11.29 6.14   0.00 -0.91         B0IIIn             -0.002-0.003      +017SB?   434                 *
+6748          CD-3612214 165185209710                       175938.2-360139180623.7-360111356.04-07.33 5.95  +0.62 +0.07         G5V                +0.110+0.015 +.059+013                           
+6749          CD-4312272 165189228708      W     A          175935.9-432548180649.8-432529349.45-10.86 5.77H +0.22 +0.16         A5V                -0.001-0.099D+.021-006SB         0.1   1.6      *
+6750          CD-4312272 165190            W     B          175935.9-432548180649.8-432529349.45-10.86 5.77H                     A5V                -0.001-0.099D+.021-006           0.1   1.6      *
+6751          CP-73 1888 165259257571      W                175952.0-734050181234.5-734018320.49-23.29 5.85  +0.46 +0.05         F5V                -0.053-0.231 +.031+013           3.0   2.8       
+6752 70    OphBD+02 3482 165341123107    I  11046           180024.1+023122180527.3+022958 29.91 11.38 4.03  +0.86 +0.54 +0.46   K0V                +0.266-1.093 +.201-007SBO    16  1.8   1.9AB  11*
+6753          BD+48 2627 165358 47173       11028           180032.1+482734180309.0+482752 75.85 27.69 6.21  +0.03 +0.06         A2V                +0.029+0.015      -013           2.7  26.8AB   3*
+6754          BD+23 3254 165373 85706                       180032.0+235615180440.2+235633 50.11 20.48 6.34  +0.30 +0.03         F0IV-V             +0.011-0.057      -033SB     70                  
+6755          BD-08 4558 1654021420833436                   180040.5-081954180607.4-081926 20.30  6.14 5.85  +0.21 -0.20         B8III-IV           -0.008-0.016      -023SB                        *
+6756          BD-04 4395 165438142085                       180055.7-044533180615.2-044505 23.48  7.82 5.77  +0.96 +0.81         K1+IV              +0.141-0.032      -019V                          
+6757          BD-00 3414 165462142084                       180059.1-002716180607.4-002648 27.31  9.86 6.34  +1.06 +0.76         G8IIp              -0.020-0.029      -009                           
+6758          BD+12 3383 165475103373       11056           180104.3+115944180543.3+120014 38.69 15.51 7.04  +0.30 +0.12         A3IV               -0.008+0.001D+.009+013SB    218  0.5   6.9AB   3*
+6759          CD-4512215 165493228734      W                180105.4-454642180830.1-454602347.45-12.19 6.15  -0.08 -0.49         B7-8II             -0.009-0.025      -035V?         3.6   4.0      *
+6760          CP-59 7231 165497245273      W                180107.7-590313180957.6-590224335.07-17.98 6.38  +1.55               K4III              -0.021-0.001      -010           5.6  40.        
+6761   Iot PavCP-62 5797 165499254157                       180108.5-620121181026.1-620008332.21-19.17 5.49  +0.58 +0.09         G0V                -0.087+0.223 +.053+030SB                         
+6762          BD-21 4855 1655161863023438                   180111.4-212715180711.4-212638  8.93-00.44 6.28  +0.12 -0.78         B0.5Ib             +0.004 0.000      -009V                         *
+6763          BD+21 3300 165524 85718                       180115.7+213818180530.2+213849 47.92 19.44 6.15  +1.23              gK3                 +0.015+0.009      -035                           
+6764          BD+40 3276 165567 47193                       180128.0+400434180443.2+400503 66.78 25.56 6.52  +0.46 +0.02         F7V                +0.030+0.025      -001       12                  
+6765 98    HerBD+22 3273 165625 85725    I         10208    180149.1+221234180601.9+221308 48.53 19.55 5.06  +1.58 +1.93 +0.98E  M3-IIIZrO 0+       -0.010-0.008 +.014-020V                          
+6766          CD-2814174 1656341863283439I D                180144.9-282806180805.0-282726  2.89-04.02 4.57  +0.94 +0.74 +0.53   G7:IIIb*           +0.027-0.030 +.023-005V?         0.8   0.3      *
+6767          BD+41 2968 165645 47195       11054           180153.6+415607180500.8+415648 68.79 25.97 6.34  +0.26 +0.04         F0V                -0.021+0.106      -020SB    139  3.6  23.4       
+6768          BD+32 3047 165683 66626                       180206.3+321318180549.6+321350 58.59 23.08 5.71  +1.16 +1.08         K0III              +0.012-0.026      +001                           
+6769          BD-17 5028 165687161093    I                  180200.4-171004180748.4-170915 12.75  1.51 5.52  +1.11 +1.08 +0.56   K1III              -0.099+0.059      -032V?                         
+6770 71    OphBD+08 3582 165760123140    I                  180231.4+084316180718.4+084402 35.82 13.74 4.64  +0.96 +0.74 +0.50   G8III              +0.011+0.032 +.021-003     < 19:                 
+6771 72    OphBD+09 3564 165777123142 680   11076           180236.5+093258180721.0+093350 36.59 14.09 3.73  +0.12 +0.10 +0.05   A4IV s             -0.060+0.080 +.047-024SB2    80  7.7  54.4AD   4*
+6772          CD-3612265 165793209779                       180235.6-364113180922.4-364021355.75-08.17 6.58  -0.03 -0.86         B1II               -0.011-0.004      +039V?                         
+6773          CD-2512793 165814186350      W       V3792 Sgr180243.0-252913180854.1-252821  5.59-02.74 6.61  +0.02 -0.47         B3III              +0.003+0.018      -006SBO        2.0  13.3      *
+6774          CP-70 2507 1658612575753446                   180254.1-704618181424.1-704505323.56-22.54 6.73  -0.03 -0.36         B7-8II-III         -0.002-0.023      -007                           
+6775 99    HerBD+30 3128 165908 66648       11077           180313.7+303251180701.5+303343 56.97 22.30 5.04  +0.52 -0.09 +0.32   F7V                -0.094+0.071 +.060+001SB      3  3.4   1.7AB   3*
+6776          BD+13 3529 165910103406       11086           180311.9+130327180748.4+130416 39.92 15.50 6.63  +0.07 +0.09         A2Vn               +0.016+0.008      -017V?         3.8  42.3      *
+6777          CD-3213814 165978209794                       180326.7-324355180959.9-324311359.32-06.42 6.43  +1.02               K0IV               +0.001-0.149      +010                           
+6778          CD-4712098 166006228774      W                180331.1-473148181104.5-473047346.05-13.35 6.07  +1.20 +1.45?        K1IIICNII          +0.007-0.029      -015           5.4   1.7       
+6779103Omi HerBD+28 2925 166014 85750 681  S       Omi Her  180338.4+284455180732.6+284545 55.19 21.59 3.83  -0.03 -0.07  0.00   B9.5V             e+0.001+0.009 +.005-030SB    134                 *
+6780          CD-3015316 166023209803      W                180338.8-304440181005.7-304343  1.10-05.49 5.53  +0.97 +0.70         K1II               +0.003-0.027D+.004-022           2.3   3.9      *
+6781100    HerBD+26 3178 166045 85753       11089A 10253    180347.6+260511180749.5+260605 52.54 20.60 5.86  +0.12 +0.08         A3V                -0.006+0.033D+.012-017V?    176  0.0  14.3AB   4*
+6782100    HerBD+26 3178 166046 85752       11089B 10253    180347.5+260456180749.5+260551 52.53 20.59 5.90  +0.14 +0.08         A3V                -0.002+0.033D+.012-016      168  0.0  14.3AB   4*
+6783   Eps TelCD-4512251 1660632287771473  W                180348.4-455818181113.8-455716347.50-12.69 4.53  +1.01 +0.78 +0.48   K0III              -0.017-0.037 +.023-026           8.4  21.2       
+6784          BD+14 3427 1660951034143442                   180400.3+141610180833.7+141705 41.14 15.84 6.37  +0.17 +0.23 +0.08   A5m                -0.005+0.004      -009V      20                  
+6785          BD-13 4863 1661031611251472I                  180402.7-135704180943.4-135604 15.79  2.67 6.39  +1.42               K0                 +0.016-0.003      -020V                          
+6786          CD-4112491 1661142287783444                   180400.2-412235181105.6-412133351.68-10.62 5.86  +0.29 +0.07         F2V                +0.032-0.035      -004V                          
+6787102    HerBD+20 3674 166182 857693443   11102           180428.8+204755180845.5+204852 47.42 18.42 4.36  -0.16 -0.81 -0.18   B2IV               -0.001-0.005 -.010-015V?     33  7.9  23.4      *
+6788          CD-3312917 166197209817              10304    180418.4-334907181055.2-334759358.45-07.10 6.16  -0.14 -0.86         B1V                -0.011+0.013      -025SB    212                  
+6789 23Del UMiBD+86  269 166205  2937 913                   180432.7+863648173212.9+863511119.29 28.24 4.36  +0.02 +0.03 -0.01   A1Vn               +0.009+0.056 +.004-008V?    174                 *
+6790          BD+50 2525 166207 307513441                   180429.9+504823180653.5+504922 78.59 27.52 6.29  +1.04 +0.96 +0.52   K0III              +0.002+0.096      -057                          *
+6791          BD+43 2892 166208 47237    I                  180427.9+432656180728.8+432742 70.55 25.90 5.00  +0.91 +0.71 +0.47   G8IIICN-1CH-3      +0.002-0.060 +.012-016SB?  < 17                  
+6792          BD+49 2732 166228 47233       11090           180436.4+494144180706.3+494238 77.37 27.29 6.32R                     A2V                -0.002+0.022D+.008-021SB    210  4.1   2.4       
+6793          BD+36 3027 166229 66666    I                  180434.1+362328180802.2+362405 63.08 23.92 5.48  +1.17 +1.21 +0.56   K2.5III            -0.095-0.183 +.009-007                           
+6794101    HerBD+20 3675 166230 85770                       180434.1+200146180852.9+200243 46.68 18.10 5.10  +0.15 +0.18         A8III              +0.008-0.020 +.015-016V?     54                  
+6795 73    OphBD+03 3610 166233123187       11111  10287    180435.5+035835180933.8+035936 31.72 11.13 5.73  +0.37 +0.03         F2V                +0.038-0.007 +.030-017V      94  1.2   0.3AB   3*
+6796          CP-63 4334 166251254179      W                180439.1-634240181416.2-634122330.71-20.19 6.47  +1.41               K4III              -0.033-0.051      -044           6.8  19.       *
+6797          BD+03 3613 166285123198       11113           180453.8+030626180954.0+030711 30.97 10.66 5.69  +0.47 -0.01         F5V                +0.022-0.192 +.041-014SB2 =< 10  5.2 103.5AC   3 
+6798          BD-19 4886 166393161153       11127           180519.2-195141181114.8-195032 10.79-00.50 6.36  +0.16               A4V                -0.002-0.028D+.008-032           0.4   1.2AB   3*
+6799          BD+30 3138 166411 66682                       180520.7+302653180910.2+302810 57.04 21.83 6.38  +1.19 +1.22 +0.61  gK1                 +0.071+0.133      -080                           
+6800          BD+03 3620 1664601232123445I                  180540.5+031816181040.3+031927 31.24 10.58 5.51  +1.19 +1.22 +0.61   K2III              +0.021-0.003      +010                           
+6801 11    SgrCD-2314047 166464186437    I  11133           180537.2-234317181143.4-234204  7.46-02.45 4.98  +1.05 +0.90         K0III              +0.017-0.019 +.014+004           5.7  42.1      *
+6802          CD-2814268 166469186444              V4045 Sgr180536.8-285522181158.2-285405  2.90-04.98 6.51  -0.01               B9IVpSrEuCr        +0.017-0.005      -014                          *
+6803          BD+16 3390 166479103443       11123  10311    180540.8+162727181008.7+162836 43.39 16.40 6.09R                     B9V+F7III          -0.004-0.007D+.004-013           0.8   1.2      *
+6804          CD-4112534 166596228815              V692 CrA 180607.8-412134181312.6-412010351.89-10.97 5.47  -0.17               B2.5III            -0.013-0.004      -015V?    197:                *
+6805          CP-63 4343 166599254189      W                180611.0-630452181540.9-630320331.40-20.11 5.60  +0.92               K0III-IV           -0.023-0.031      -007           5.6  41.9      *
+6806          BD+38 3095 166620 66700              10316    180618.7+382705180937.5+382727 65.34 24.21 6.40  +0.87 +0.59 +0.49   K2V                -0.303-0.472 +.092-019V?                        *
+6807          BD+36 3039 166640 66703                       180630.1+362646180959.0+362759 63.27 23.56 5.58  +0.91               G8III              +0.011+0.015      -026                           
+6808          CP-68 3081 1668412541963452  W                180719.1-681534181800.9-681345326.26-22.05 6.33  -0.04 -0.23         B9V                -0.007-0.019      +022      224  3.5   2.0       
+6809 40    DraBD+79  570 166865  8994       11061B 10205    180731.5+795917180003.4+800003111.78 28.91 6.04  +0.51 -0.01         F7                 +0.045+0.129 +.025+004SBO =< 25  0.4  19.3AB   3*
+6810 41    DraBD+79  571 166866  8996       11061A 10205    180737.7+795928180009.2+800015111.78 28.90 5.68  +0.50 -0.01         F7                 +0.042+0.122 +.025+010SB      0  0.4  19.3AB   3*
+6811 24    UMiBD+86  272 166926  2940                       180747.5+865938173048.0+865805119.70 28.14 5.79  +0.25 +0.07         A2m                +0.059+0.010      +001       55                  
+6812 13Mu  SgrBD-21 4908 166937186497 682   11169  Mu  Sgr  180746.9-210506181345.8-210332 10.00-01.60 3.86  +0.23 -0.49 +0.20   B8Iap             e+0.002+0.001 +.012-006SBO =< 54  2.9   0.0     6*
+6813          BD-04 4415 1669601421593450                   180753.1-040216181310.0-040042 24.95  6.64 6.59  +0.27 +0.14 +0.14   A2m                +0.015+0.022      -011V      25                  
+6814          BD+33 3044 166988 66733       11149  10363    180805.7+332521181145.1+332649 60.27 22.29 5.88R +0.01 +0.11         A3V                +0.012+0.010      -019SB    100  0.3   0.1AB   3*
+6815104    HerBD+31 3199 167006 667373448I         V669 Her 180808.3+312249181154.2+312419 58.20 21.59 4.97  +1.65 +1.94 +0.97E  M3III              -0.013+0.030 +.007-000V                         *
+6816 14    SgrBD-21 4916 167036186509    I         10393    180815.4-214424181415.9-214247  9.48-02.02 5.44  +1.52 +1.69         K3III              -0.008-0.022      -059V                         *
+6817          BD+54 1950 167042 307843447                   180828.6+541524181031.6+541712 82.54 27.55 5.95  +0.94 +0.72 +0.48   K1III              +0.104+0.245 +.019-016V?                         
+6818          CD-4412456 167096228851                       180834.7-441412181552.7-441224349.47-12.67 5.46  +0.96 +0.72?        G8-K0III           +0.074+0.012      -027V                          
+6819          CP-56 8706 1671282453691474          Var?     180842.0-560316181707.5-560124338.39-17.69 5.33  -0.05 -0.69 -0.03   B3IIIep           v-0.006-0.013      +015SB     50                 *
+6820          BD+21 3347 167193 85836    I                  180902.2+215106181316.5+215249 48.88 17.87 6.12  +1.47 +1.72 +0.80   K4III              +0.062+0.051      -066                           
+6821          CD-5111460 1672572453723453                   180908.2-510559181700.9-510406343.13-15.73 6.06  -0.06               B9V                -0.002-0.008      -005V?                         
+6822 15    SgrBD-20 5054 167264186543                       180914.9-204529181512.9-204342 10.46-01.74 5.38  +0.07 -0.86         B0Ia               +0.003+0.003      -006SB     83                 *
+6823 16    SgrBD-20 5055 167263186544       11191           180915.9-202504181512.9-202317 10.76-01.58 5.95  +0.02 -0.87         O9.5II            v-0.002+0.001      -005SB2   160  7.0   6.0      *
+6824          BD+41 3011 167304 47305                       180931.9+410716181242.6+410849 68.35 24.38 6.36  +1.03 +0.98         K0III              -0.014-0.046      -048                           
+6825          BD-18 4864 167356161227       11196           180938.2-184131181530.8-183941 12.31-00.82 6.07  +0.20 -0.34?        A0Ia               +0.014+0.006      +002V          5.7  10.1      *
+6826          BD+38 3113 167370 667653451                   180944.6+384444181304.8+384625 65.87 23.65 6.04  -0.08 -0.22         B9IIIn             -0.004+0.010      -009SB    250                  
+6827          BD+60 1813 167387 178033449                   180954.8+602302181107.1+602434 89.43 28.26 6.49   0.00 -0.06         A1Vnn              -0.010 0.000      -018      300                  
+6828          CP-63 4370 167425254209      W                180959.9-635454181940.2-635313330.73-20.81 6.18  +0.58 +0.07         F9V                +0.043-0.285 +.017+000           4.6   7.7       
+6829   Phi OctCP-75 1417 167468257584                       181009.0-750509182336.1-750239319.27-24.38 5.47  +0.02 +0.04         A0V                -0.006+0.030      +005      224                  
+6830          BD-03 4259 167564142185                       181042.0-033901181558.0-033703 25.63  6.21 6.36  +0.20 +0.17         A4V                +0.015+0.019      -022                           
+6831          BD+29 3213 167588 85856                       181051.0+291059181444.0+291226 56.22 20.27 6.56  +0.54 +0.01         F8V                +0.016-0.249 +.014+003    =<  6                  
+6832   Eta SgrCD-3612423 167618209957 683I'W       Eta Sgr  181051.6-364730181737.6-364542356.44-09.68 3.11  +1.56 +1.71 +1.32   M3.5III           e-0.128-0.167 +.045+001V?         4.9   3.5AB   4*
+6833          CD-3412673 167647209959      W       RS Sgr   181058.4-340830181736.1-340626358.83-08.47 6.16  -0.11 -0.60         B3V+A              -0.015-0.009      +010SBO   186: 2.6  94.1AC   4*
+6834          BD+02 3547 167654123308    I         10466    181103.7+022043181605.6+022240 31.01  8.95 6.01  +1.59 +1.56         M4IIIab            -0.003-0.015      +022V?                        *
+6835          CD-2814407 167666186594                       181103.6-284110181724.0-283909  3.69-05.92 6.19  +0.18               A5/7V              +0.004-0.027      -034                           
+6836          CD-2814408 167665186593                       181103.4-281910181723.7-281721  4.01-05.74 6.40  +0.54  0.00         G0V                +0.134-0.156      +007SB                         
+6837          CP-80  849 167714258796                       181118.0-801649182919.5-801358313.74-25.77 5.95  +1.16 +1.27         K2III              -0.037-0.062      -014                           
+6838          BD-17 5112 1677201612603454I                  181122.5-172429181711.6-172226 13.63-00.56 5.75  +1.58 +1.70         K4II-III           -0.003-0.015      -007                           
+6839          CD-4213101 167756228895                       181131.3-421930181840.0-421718351.47-12.30 6.30  -0.11 -0.99         B0.5Ia             -0.007-0.004      -025                           
+6840          BD-03 4263 167768142189                       181138.5-030204181653.1-030026 26.29  6.29 6.00  +0.89 +0.54 +0.34E  G3III              +0.012-0.268 +.005+002V                         *
+6841          BD-18 4886 167771161267      W                181136.6-182955181728.5-182748 12.70-01.13 6.54  +0.11 -0.84         O7III:(n)((f))     -0.003 0.000      +001SBO    90: 6.6   8.4      *
+6842          CD-2712684 167818186612    I                  181147.6-270443181803.2-270233  5.18-05.29 4.65  +1.66 +1.81 +0.93   K3II               +0.008+0.005 +.033-017                           
+6843          BD-09 4678 1678331421921475                   181153.7-094733181724.2-094531 20.36  3.01 6.31  +0.38 +0.27         A8V                +0.009-0.056      -014      120                  
+6844          BD+00 3907 167858123320                       181159.8+005816181704.8+010021 29.89  8.10 6.63  +0.31 +0.05         F2V                -0.011-0.026      -034V   =< 15                  
+6845          BD+42 3035 167965 47342 684                   181232.1+420730181538.8+420934 69.58 24.12 5.59  -0.10 -0.46         B7IV               +0.001 0.000      -021SB    201                  
+6846          CD-2512995 167979186629    I:                 181230.4-253830181841.7-253617  6.53-04.75 6.51  +1.34 +1.40        gK1                 -0.004-0.030      -046V                          
+6847          BD+45 2684 168009 47343                       181240.1+451042181532.6+451234 72.82 24.92 6.29  +0.62 +0.12         G2V                -0.068-0.110 +.044-064V?  =<  6                  
+6848          BD-18 4896 168021161304       11240  10543    181250.8-183928181843.3-183710 12.70-01.47 6.84  +0.31 -0.65         B0Ib               +0.013+0.006D+.020+004V      76  0.5   0.4AB   5*
+6849          BD+56 2080 168092 30836       11213           181255.9+563314181441.1+563518 85.21 27.31 6.37  +0.34 +0.02         F1V                -0.011+0.029      -008SB2O   55  3.4  95.6AB   4*
+6850 36    DraBD+64 1252 168151 17828 685                   181319.2+642148181353.8+642350 93.97 28.29 5.03  +0.38 -0.04         F5V                +0.349+0.035 +.047-035        8                  
+6851          BD+13 3593 1681991035783456  S                181328.2+134420181802.9+134637 41.67 13.54 6.30  -0.03 -0.51         B5V                -0.001-0.010      -021                 0.1       
+6852          BD+18 3623 168270103581                       181343.9+180535181807.7+180753 45.76 15.33 5.99R +0.03 -0.10         B9V                -0.006-0.004      -027SB     90                  
+6853          BD+40 3332 168322 47359                       181356.4+405350181706.8+405612 68.38 23.52 6.11  +0.99 +0.70 +0.53   G8.5IIIbFe-1CH0.5  -0.163+0.069 +.010-073                          *
+6854          BD+23 3299 168323 85906    I W                181357.6+231530181807.7+231748 50.71 17.38 6.63R                     K5                 +0.007-0.018      +003           2.3 155.4AC   3 
+6855   Xi  PavCP-61 6140 168339254226 686  W       10673    181400.6-613221182313.6-612938333.29-20.40 4.36  +1.48 +1.55         K4III              +0.001+0.003 +.016+012SBO        4.6   3.5AB   3*
+6856          CD-3712457 168357210017                       181405.5-373148182055.3-372915356.07-10.59 6.45  +1.31               K2II               +0.011-0.008      +002                           
+6857          BD+07 3629 168387123353    I  11254           181419.3+071309181909.5+071535 35.79 10.46 5.39  +1.07 +1.06 +0.55   K2III-IV           -0.047+0.002      -008V          6.7  42.2      *
+6858          BD-15 4927 168415161348    I                  181423.3-155221182008.8-154954 15.32-00.45 5.39  +1.47 +1.64         K4III              +0.037-0.033      +031                           
+6859 19Del SgrCD-2914834 168454186681 687I  11264           181435.5-295214182059.7-294941  3.00-07.15 2.70  +1.38 +1.55 +0.68   K3-IIIa*           +0.035-0.028 +.047-020V?        10.2  58.1AD   4*
+6860105    HerBD+24 3381 168532 859213457I                  181503.7+242416181910.7+242646 51.92 17.60 5.27  +1.53 +1.74 +0.79   K3III:Ba0.4        +0.009+0.006 -.002-014SBO                       *
+6861          CD-2414219 168574186699    I         V4028 Sgr181522.0-245736182131.4-245454  7.44-04.99 6.25  +1.84 +2.03 +1.43E  M5III              +0.007+0.008      +003V                         *
+6862          CD-3812729 168592210048                       181524.9-384207182218.6-383925355.12-11.35 5.10  +1.49               K4-5III            -0.033-0.028 +.011+018                           
+6863          BD-18 4926 168608161376              Y Sgr    181530.0-185416182123.1-185136 12.79-02.14 5.75  +0.94 +0.62         F8I                +0.011-0.009 -.006-003V      18                 *
+6864          CD-2814495 168646186704                       181540.4-282832182200.2-282548  4.35-06.71 6.16  +0.26 +0.26         A3III              +0.014-0.001      -012                          *
+6865 37    DraBD+68  984 168653 178373455                   181551.9+684311181517.0+684521 98.93 28.40 5.95  +1.06              gK1                 +0.015-0.061 -.002-010V                          
+6866 74    OphBD+03 3680 1686561233771476I  11271           181552.5+031956182052.1+032238 32.46  8.34 4.86  +0.91 +0.62 +0.45   G8III               0.000+0.010 +.019+005V?   < 19: 7.3  28.1AB   3*
+6867          BD+29 3236 168694 85933    I                  181600.5+293722181952.1+293958 57.09 19.38 5.99  +1.29              gK4                  0.000-0.001      -036                           
+6868106    HerBD+21 3390 168720 85941    I                  181604.0+215508182017.9+215741 49.63 16.40 4.95  +1.59 +1.99 +1.00   M1III              +0.017-0.056 +.016-033SB                         
+6869 58Eta SerBD-02 4599 168723142241 688I W       10675    181608.1-025529182118.6-025356 26.91  5.36 3.26  +0.94 +0.66 +0.50   K0III-IV           -0.547-0.700 +.058+009V?   < 19: 8.7 179.7      *
+6870          CD-3612524 168733210061              V4050 Sgr181606.4-364258182253.1-364010356.99-10.58 5.34  -0.14               Ap                  0.000-0.018      -012SB?     0                 *
+6871          CP-63 4406 168740254237                       181602.4-630409182531.5-630117331.84-21.15 6.14  +0.20               A3V                -0.007-0.099      -021      123                 *
+6872  1Kap LyrBD+36 3094 168775 668691477I         10657    181621.4+360110181951.7+360352 63.52 21.55 4.33  +1.17 +1.19 +0.55   K2IIIabCN0.5       -0.015+0.043 +.011-022     < 17                 *
+6873          BD+05 3704 168797123385              10688    181633.6+052324182128.5+052609 34.39  9.13 6.13  -0.04 -0.62         B3Ve               +0.013-0.004      -018SB    300                 *
+6874          CD-3612537 168838210075                       181643.7-361713182328.9-361418357.44-10.50 5.55  +1.02               K0III              +0.017-0.006      -006                           
+6875          CD-4412569 1689052289823461  W       10724    181701.7-440935182418.2-440637350.22-14.00 5.25  -0.19 -0.70         B2.5Vn             -0.002-0.021      +000V?    297  4.6  75.3      *
+6876108    HerBD+29 3241 168913 85956                       181705.9+294841182057.1+295132 57.37 19.23 5.63  +0.21 +0.03 +0.11   A5m                +0.014+0.057 +.013-020SB2O   20                 *
+6877107    HerBD+28 2981 168914 85957              10690    181706.9+284920182101.0+285212 56.40 18.86 5.12  +0.20 +0.15         A7V                +0.005+0.050 +.021-030SB    183                  
+6878          BD-10 4673 169009161412                       181730.6-101604182302.2-101307 20.61  1.57 6.33  +0.14               B9.5V              +0.024-0.007      -024V?  =< 41                  
+6879 20Eps SgrCD-3412784 169022210091 689  W                181732.0-342555182410.3-342305359.20-09.81 1.85  -0.03 -0.13 -0.01   B9.5III            -0.038-0.124 +.023-015      140:12.3  36.1      *
+6880          BD+51 2357 169028 30897                       181735.4+511813181956.1+512052 79.61 25.61 6.30  +1.10 +1.08        gK1                 -0.033-0.052 +.037-010SB                         
+6881          BD-12 5024 1690331614153459                   181736.4-120349182312.2-120053 19.04  0.69 5.73  +0.01 -0.26         B8IV-Ve            -0.007-0.014      -011V     250                  
+6882          BD+23 3316 169110 85975    I                  181758.4+231404182208.7+231707 51.07 16.53 5.41  +1.60       +1.01   M0IIIab            +0.012+0.077      -058                           
+6883          BD+11 3442 169111103648                       181756.1+115848182235.3+120144 40.53 11.79 5.89  +0.04 +0.08         A2V                +0.012-0.008      -055                           
+6884   Zet SctBD-09 4712 169156142267    I                  181810.8-085911182339.5-085603 21.81  2.03 4.68  +0.95 +0.72 +0.47   G9-IIIbFe-0.5      +0.045+0.046 +.015-006SB1O < 17                 *
+6885          BD+17 3555 1691911036553460I                  181823.9+174634182249.0+174936 45.95 14.19 5.25  +1.27 +1.32 +0.65   K3III              +0.071+0.016 +.023-019V    < 17                  
+6886          BD+49 2776 169221 47411                       181836.7+494036182107.1+494332 77.90 25.07 6.40  +1.07               K1III              -0.007+0.025      -017                           
+6887          BD+16 3478 169223103660                       181835.4+163816182302.9+164117 44.91 13.67 6.22  +1.20               K0                 -0.019-0.016      +015SB                         
+6888 18    SgrCD-3015661 169233210116    I                  181835.7-304827182501.5-304524  2.57-08.35 5.60  +1.14               K0III-IV           -0.123-0.072      -019                           
+6889          CD-3612589 169236210119                       181837.8-360244182521.7-355930357.83-10.73 6.15  +1.00               K0III              -0.033+0.013      +004                           
+6890          BD-03 4277 169268142274                       181847.9-033802182403.5-033500 26.61  4.44 6.38  +0.34 -0.01         F6III-IV           -0.025-0.055      -017SB2    34                 *
+6891          BD+49 2782 169305 474173458I                  181859.1+490415182132.7+490718 77.27 24.87 5.05  +1.66 +1.94 +0.90E  M2IIIab            -0.020+0.053 +.000+014                           
+6892          BD-07 4598 169370142288                       181917.2-070743182442.1-070431 23.58  2.67 6.31  +1.16 +1.09         K0                 +0.134-0.004      -025                           
+6893          CD-3412802 169398210135                       181917.6-340001182554.6-335643359.75-09.94 6.30  -0.08 -0.51         B5IV               +0.002+0.006      -006                           
+6894          CD-4812505 169405229021                       181918.1-481018182653.9-480701346.61-16.02 5.46  +0.84               K0-1III+F-G        -0.007-0.042 +.026+004SB                         
+6895109    HerBD+21 3411 169414 86003 690I W       10742    181926.1+214327182341.9+214611 49.77 15.60 3.84  +1.18 +1.17 +0.60   K2.5IIIab          +0.196-0.242 +.025-058V?   < 17  6.5 221.8       
+6896 21    SgrBD-20 5134 169420186794    I  11325           181923.6-203543182521.0-203230 11.74-03.75 4.81  +1.31 +0.92 +0.84   K2II               +0.006-0.025 +.013-012V?         3.6   1.7      *
+6897   Alp TelCD-4612379 169467229023 691                   181933.5-460124182658.4-455806348.67-15.18 3.51  -0.17 -0.64 -0.21   B3IV               -0.016-0.054      -000V?     35                 *
+6898          BD-01 3486 169493142294       11324           181946.0-013801182457.0-013446 28.49  5.16 6.15  +0.37 +0.15         F6III+A9III        -0.017-0.010D+.011-010V?         0.4   0.8      *
+6899          CP-74 1682 1695702576013466                   182004.9-740138183255.3-735756320.58-24.73 5.89  +0.98 +0.83         K0III              -0.002-0.090      -025                           
+6900          BD+05 3730 169578123453                       182013.2+050146182508.8+050505 34.49  8.16 6.74  +0.02 -0.21         B9V                -0.003+0.008      -023V     250                  
+6901          BD+38 3160 169646 66936    I  11320  10756    182036.4+384105182357.4+384421 66.53 21.62 6.36R                     K4III              +0.027+0.006      -040V          6.1  61.5AC   3*
+6902          BD+07 3682 1696891234621478                   182050.1+075833182538.8+080155 37.21  9.36 5.65  +0.92 +0.45         G8III-IV+A0V       -0.002-0.006      -008SBO =< 50                 *
+6903  2Mu  LyrBD+39 3410 169702 669433463                   182056.1+392709182413.8+393026 67.33 21.80 5.12  +0.03 +0.08         A3IVn              -0.023-0.002 +.004-024SB    165                 *
+6904          BD+27 3016 169718 86019       11334           182059.8+272022182458.5+272343 55.30 17.51 6.27  +0.05 +0.02         A0V+A4V            +0.002+0.008D+.004-029SB    105  0.9   0.6AB   3*
+6905   Zet TelCD-4912153 169767229047                       182107.7-490729182849.9-490415345.82-16.68 4.13  +1.02 +0.82 +0.34E  G8-K0III           +0.144-0.242 +.027-031                          *
+6906          BD+14 3533 169820103709      S                182123.3+145434182555.4+145800 43.60 12.32 6.37  +0.01 -0.31         B9V                +0.012-0.006      -021V                0.1       
+6907          CD-2914965 169830186838                       182125.8-295237182749.5-294859  3.69-08.47 5.92  +0.52               F9V                -0.003+0.032      -017V                          
+6908          CP-57 9063 1698362455103464  W                182119.8-573504182956.7-573123337.57-19.87 5.76  +0.98               K0III              +0.051-0.025      -000           4.7  33.9AC   3 
+6909          CD-2613184 169851186837       11354           182129.6-264137182743.8-263805  6.55-07.02 6.31  +0.26               A8V+F2V            +0.003-0.025D+.009-029           0.0   1.1      *
+6910          CD-3912626 169853210197                       182132.0-390318182827.1-385944355.33-12.57 5.64  +0.13               A2mA2-F0           -0.002-0.038      -021                           
+6911          BD+53 2079 169885 30943                       182138.5+531446182347.8+531803 81.86 25.44 6.32  +0.16 +0.14 +0.06   A3m                +0.008-0.015      -004       40                  
+6912          CP-81  813 169904258804                       182142.5-815306184214.1-814828312.09-26.50 6.27  -0.13 -0.37         B8V                +0.001-0.006      -006V?                         
+6913 22Lam SgrCD-2513149 169916186841 692I                  182147.9-252837182758.2-252518  7.66-06.52 2.81  +1.04 +0.89 +0.56   K1+IIIb            -0.044-0.185 +.053-043V?                        *
+6914          CD-2613192 169938186843                       182151.7-264901182806.2-264526  6.47-07.15 6.27  +0.16               A3/4V               0.000-0.036      -030                           
+6915          CD-4312564 169943229056                       182157.8-435431182912.9-435045350.84-14.70 6.36  +0.90               G8III              -0.002+0.028      -009                           
+6916   Nu  PavCP-62 5879 169978254273              10889    182202.0-622030183122.4-621642332.82-21.56 4.64  -0.11 -0.39         B7-8III            -0.003-0.045      +059       91                 *
+6917          BD+29 3259 169981 860431479                   182207.3+294616182558.8+294944 57.76 18.20 5.83  +0.06 +0.09 +0.04   A2IV               +0.026-0.022      +009SBO                       *
+6918 59    SerBD+00 3936 169985123497       11353  d Ser    182205.5+000812182712.5+001146 30.34  5.48 5.21  +0.50 +0.21 +0.38   G0III+A6V          -0.008-0.002 +.016-023SBO   270  2.3   3.8AB   3*
+6919          BD-17 5203 169990161493    I:        10835    182206.4-175139182756.5-174800 14.45-03.02 6.20  +0.01 -0.30         B8V                -0.004+0.007      -035V                          
+6920 43Phi DraBD+71  889 170000  9084       11311  Phi Dra  182211.4+711705182045.5+712016101.88 28.04 4.22  -0.10 -0.33 -0.10   A0pSi:             -0.004+0.040 +.012-016SB1O   88  1.7   0.2AB   3*
+6921          CD-3812824 170040210213                       182222.3-385449182916.8-385104355.54-12.66 6.63  -0.02               B8                 -0.004-0.007      -028                           
+6922          CD-4712319 170069229064                       182224.6-471701182955.8-471313347.68-16.14 5.70  +1.26               K2III              +0.013-0.003      -018                           
+6923 39    DraBD+58 1809 170073 30949       11336           182226.9+584434182354.5+584802 87.88 26.44 4.98  +0.08 +0.04 +0.02   A1V                -0.039+0.060 +.035-015SB    175  2.8   3.8AB   8*
+6924          BD+26 3259 170111 86060       11356           182239.5+262322182640.9+262658 54.53 16.80 6.53  -0.11 -0.58         B3V                -0.003 0.000      -018SB         2.7  62.3AC   3*
+6925          BD+03 3716 170137123513    I                  182251.5+034115182750.3+034455 33.59  6.96 6.07  +1.62 +1.84         K3III              -0.005-0.005      -019                           
+6926          CD-2613206 170141186863      W       10864    182243.4-263840182857.4-263454  6.72-07.24 6.5   +0.11               A3III              +0.003+0.009      -017           1.7  41.9      *
+6927 44Chi DraBD+72  839 170153  9087 695  W       10749    182251.5+724122182103.4+724358103.46 28.06 3.57  +0.49 -0.06 +0.31   F7V                +0.532-0.350 +.120+033SB2O   11  2.    0.1 *   4*
+6928          BD+06 3790 170200123516      S                182305.7+060758182758.8+061139 35.81  8.03 5.73  -0.03 -0.35         B8III-IV            0.000-0.024      -012SBO    30        0.1      *
+6929          CD-2513170 170235186873              V4031 Sgr182311.8-251912182922.0-251523  7.95-06.73 6.59  +0.07 -0.68         B2IVpe            v+0.004-0.001      -004      130                 *
+6930   Gam SctBD-14 5071 170296161520 696                   182329.8-143747182911.9-143357 17.46-01.79 4.70  +0.06 +0.06 +0.05   A3Vn               +0.003-0.002 +.025-041V?    223                  
+6931          CD-4112871 170384229080                       182356.3-415846183103.0-415449352.81-14.23 6.04  +0.14               A3V                 0.000-0.022      -014                           
+6932          BD-14 5077 170397161528              V432 Sct 182404.6-143851182946.8-143454 17.51-01.92 5.96  -0.04 -0.14         B9pSiCr            +0.021+0.025      -016V      46                 *
+6933          BD-18 4982 170433161540                       182419.1-184732183011.9-184344 13.88-03.92 5.66  +1.06              gK0                 +0.038-0.095 +.011-001                           
+6934   Del1TelCD-4512550 170465229092                       182420.9-455855183145.4-455454349.06-15.93 4.96  -0.11 -0.42         B6IV               -0.008-0.032      +007SB1O   33                 *
+6935 60    SerBD-02 4641 1704741423481480                   182428.7-020300182941.0-015907 28.68  3.93 5.39  +0.96 +0.76 +0.48   K0III              +0.032-0.033 +.013+028SB1  < 17                 *
+6936          CD-3313281 170479210257      W                182431.2-330319183104.8-325921  1.11-10.49 5.34  +0.16 +0.07         A3m                -0.001-0.045 +.023+009      120  4.5   3.4AB   3*
+6937          CD-4312600 170521229094                       182442.8-433433183156.2-433028351.37-15.01 5.72  +1.34               K2III              -0.005-0.019      +007                           
+6938   Del2TelCD-4512556 170523229095                       182438.2-454933183202.0-454526349.23-15.91 5.07  -0.14 -0.56         B3III              +0.004-0.008      +008SB1O   24                 *
+6939          CP-58 7418 170525245547                       182443.3-584635183329.5-584233336.54-20.70 6.44  +0.68 +0.18         G5IV               +0.027-0.124      +033                          *
+6940          BD-05 4675 1705471423533468                   182453.5-054726183014.3-054327 25.42  2.08 6.28  +0.95 +0.65         G8II-III           +0.004-0.018      +027SBO                       *
+6941          BD+03 3727 1705801235713469   11399           182507.0+035955183005.1+040355 34.13  6.60 6.69  +0.11 -0.51         B2V                 0.000-0.009      -022       95  4.2  20.1AB   5*
+6942          CD-3912696 170642210277                       182523.4-394622183221.4-394214354.99-13.55 5.16  +0.08               A3Vn               +0.036-0.040 +.022-006      151                  
+6943          BD+23 3347 170650 86115                       182526.9+234758182935.7+235158 52.32 15.19 5.90  -0.10 -0.51         B6IV                0.000-0.007      -017SB    200                  
+6944          BD-18 4988 170680161564       11411           182534.7-182816183126.3-182410 14.30-04.03 5.14   0.00               A0Vp               -0.003-0.025 +.017-037V     213  8.9  25.2      *
+6945 42    DraBD+65 1271 170693 178883465I                  182541.8+653006182559.1+653349 95.42 27.13 4.82  +1.19 +1.11 +0.63   K1.5IIIFe-0.5      +0.105-0.023 +.021+032V    < 17                  
+6946          BD-10 4713 170740161569       11414           182552.9-105153183125.7-104745 21.06-00.53 5.72  +0.24 -0.45         B2V                 0.000-0.015      -015V?         3.6  12.3      *
+6947          BD-19 5047 170764161571      W       U Sgr    182559.9-191142183153.3-190730 13.71-04.46 6.68  +1.13 +0.69 +0.71   G1.5Ib             -0.009+0.001      +002SB?        2.0 430.7AG  17*
+6948          CD-3912704 1707732102863470                   182601.8-395740183300.9-395332354.87-13.74 6.22  +0.42               F5IV               +0.086-0.086      -016                           
+6949          BD+59 1899 170811 30990                       182619.6+592857182742.3+593257 88.79 26.09 6.43                      K0IV               +0.052+0.045      -010                           
+6950          BD+20 3821 170829 86142              Var?     182624.4+204511183041.6+204855 49.55 13.72 6.50  +0.79 +0.40         G8IV               +0.011-0.258 +.029-059SBO                       *
+6951   The CrACD-4213378 170845229111 697                   182621.7-422304183330.2-421845352.62-14.80 4.64  +1.01 +0.76 +0.50   G8III              +0.031-0.022 -.001-002V?                         
+6952   Kap1CrACD-3812896 170868210296      W     B          182629.3-384731183323.3-384313356.00-13.33 6.32                      A0III              +0.021-0.028      -016           0.7  21.4      *
+6953   Kap2CrACD-3812895 170867210295      W     A          182629.3-384753183323.1-384334355.99-13.33 5.65  -0.06               B9V                -0.003-0.030      -020           0.7  21.4      *
+6954          CP-5211158 170873245559                       182628.6-525752183431.2-525331342.43-18.91 6.22  +1.25               K2III              -0.011-0.054      +024                           
+6955          BD+16 3529 1708781038001481                   182637.5+165133183104.4+165543 45.96 12.02 5.77  +0.04 +0.07         A2V                -0.032-0.021      -009SB?                        
+6956          BD-14 5098 170902161580      S                182638.5-144254183220.8-143839 17.75-02.50 6.37  +0.22               A4V                +0.019-0.017      -038                 0.0       
+6957 61    SerBD-01 3504 170920142372                       182647.1-010426183157.0-010011 29.81  3.88 5.94  +0.16 +0.16 +0.12   A4III              +0.010-0.006      -027                          *
+6958          BD+03 3737 170973123610              MV Ser   182707.8+033516183207.0+033935 34.00  5.96 6.43  -0.04 -0.26         A0pSiCr            +0.031+0.015      -008V?     15                 *
+6959          BD-14 5099 170975161587    I                  182700.6-145617183243.3-145156 17.59-02.68 5.50  +1.97 +2.17         K3Ib-IICN1         -0.004+0.001      +005                           
+6960          CD-3313338 1710342103123471                   182724.1-330526183357.8-330100  1.35-11.05 5.28  -0.11 -0.69         B2IV-V             +0.004-0.010      +004V     172                 *
+6961 24    SgrCD-2414472 171115186981    I                  182746.9-240625183353.5-240157  9.52-07.10 5.49  +1.79               K4Ib               +0.002-0.010      -014V?                         
+6962          BD-14 5106 171130161605                       182756.2-145541183339.0-145113 17.70-02.88 5.76  +0.04               A2V                +0.025-0.013      -021V                          
+6963          BD-06 4791 171149142386                       182801.6-055907183322.9-055441 25.61  1.30 6.36  +0.02 -0.04         A0Vn               +0.012-0.017      -024      210                  
+6964          CP-83  663 1711612588103992                   182758.8-832445185157.9-831859310.43-26.94 7.16  +1.26 +1.30         K1IIICNII:         -0.008-0.021      +011V                          
+6965 25    SgrCD-2414479 171237186995              11035    182825.7-241755183432.8-241321  9.42-07.31 6.51  +0.54 +0.46         F3II-III           +0.001-0.001      +008       17                 *
+6966          BD+23 3363 171245 861753472I W                182836.4+233232183246.2+233701 52.39 14.42 5.84  +1.46              gK5                 +0.010+0.016      -004V?                        *
+6967          BD+08 3741 171247123634       11448           182835.0+081136183323.3+081606 38.29  7.75 6.42  -0.03 -0.34         B8IIIpSiSr:        +0.007-0.003      -022V?         4.0  38.7      *
+6968          BD+30 3223 171301 67090       11446           182900.5+302844183249.9+303315 59.04 17.09 5.48  -0.10 -0.34         B8IV               +0.010+0.009 +.009-010V      74  7.3   7.1       
+6969          BD-20 5189 171369187012                       182923.2-205507183521.3-205027 12.54-05.96 6.48  +0.28               F0IV               +0.030-0.013      -010                           
+6970          BD-11 4681 1713911616323477                   182928.9-110319183502.4-105838 21.31-01.40 5.14  +0.92 +0.60 +0.47   G8III              +0.051-0.004 +.012+007V    < 19:                 
+6971          BD+30 3227 171406 67102              Var?     182934.7+304857183323.1+305333 59.41 17.11 6.59  -0.12 -0.51         B4Ve              v+0.011+0.009      -004                          *
+6972          CD-2915123 1714161870243478                   182936.6-294642183559.7-294157  4.58-10.01 6.37  +1.27               K1III              +0.009-0.009      -050V?                         
+6973   Alp SctBD-08 4638 1714431424081482I         11056    182945.9-081851183512.4-081439 23.76-00.17 3.85  +1.33 +1.54 +0.68   K3-III-IIIb        -0.015-0.312 +.016+036V?   < 17                 *
+6974          BD+52 2232 171461 310323474                   182954.0+520225183211.4+520656 80.90 23.94 6.56  -0.07 -0.18         B9.5V              -0.004+0.006      -023V?     59                  
+6975          BD+20 3847 171487 862033476                   183001.4+202319183419.6+202759 49.58 12.81 6.57  +0.11 +0.07         A3V                +0.008-0.006      -009SB                         
+6976          BD+10 3573 171505103867                       183005.4+104848183447.5+105330 40.82  8.60 6.40R +0.08 +0.05         A1V                +0.004-0.007      -036      124                  
+6977          BD+18 3740 171623103879      S                183048.5+180724183512.6+181212 47.56 11.67 5.78R  0.00 -0.10         A0Vn               +0.014+0.006      -021SB    280        0.2       
+6978 45    DraBD+56 2113 171635 310393475                   183051.0+565808183234.5+570244 86.20 24.99 4.77  +0.61 +0.44 +0.31   F7Ib               +0.001-0.006 +.013-012V      18                  
+6979          BD+65 1276 171653 17912      W                183056.8+652131183114.8+652610 95.35 26.57 6.59  +0.30?              A8m                -0.019+0.071      -009SB2O   20  4.2  26.6      *
+6980          BD+23 3385 171745 86224       11479           183120.6+233128183530.4+233620 52.64 13.84 5.61  +1.00 +0.83         G9III+G7III        +0.004+0.005D+.006+016V          0.2   0.6      *
+6981          BD+16 3560 171746103886       11483  11085    183125.7+165345183553.2+165832 46.50 11.00 6.21  +0.53 +0.01         G2V+G2V            +0.049-0.068 +.020+010V?         0.2   1.8AB   3*
+6982   Zet PavCP-71 2353 171759257620 698  W                183121.1-713050184302.1-712541323.49-24.95 4.01  +1.14 +1.02 +0.42E  K0III              -0.005-0.156 +.035-016    =<  9  7.9  55.6      *
+6983          BD+52 2238 171779 31051    I  11468           183140.5+521626183356.7+522113 81.23 23.73 5.36  +1.09 +0.96 +0.54   K0III              -0.002+0.008 +.004-024V?   < 17  0.1   0.3AB   3*
+6984          BD+34 3245 171780 67134      S       Var      183136.6+342237183513.5+342728 63.04 18.05 6.10  -0.11 -0.55         B5Vne             v+0.006+0.003 -.021-027SB    310        0.2      *
+6985          BD+09 3783 1718021236901484                   183141.6+090237183627.8+090721 39.40  7.45 5.39  +0.37 -0.02         F5III              -0.002-0.129 +.033-022       14                 *
+6986          CD-4812644 1718192291653482                   183140.2-475945183914.3-475435347.62-17.86 5.86  +0.23               A7IV-V             +0.028+0.015      -009V                          
+6987          BD+06 3855 171834123693       11496           183147.2+063535183639.1+064019 37.22  6.31 5.45  +0.37 -0.04         F3V                -0.025-0.141 +.032-021SB     55  6.7  74.8AC   4*
+6988          BD-21 5076 1718561870711485  D                183155.1-212849183754.4-212352 12.31-06.75 5.94  +0.19               A8IIIn              0.000-0.067      +006V          0.0   0.1      *
+6989          BD-14 5139 171957161687       11512           183224.0-140524183804.6-140017 18.95-03.44 6.47  +0.21 -0.19         B9IV               +0.019+0.002      -019V?         4.8   2.0AB   3*
+6990          CD-2314572 171961187080                       183225.8-233525183830.7-233018 10.47-07.81 5.81  +0.02 -0.41         B8III              -0.003-0.020      -033V                         *
+6991          CD-4312699 171967229172                       183224.0-431618183935.0-431110352.23-16.17 5.37  +1.68 +1.95 +0.95E  M2III              -0.052-0.052 +.004+029                           
+6992          BD+11 3530 171975103912                       183231.9+112015183712.6+112518 41.56  8.30 6.42R -0.02 -0.22         B9V                -0.021-0.011      -027      200                  
+6993          BD-00 3521 1719781424443480          11122    183227.6-002337183736.0-001834 31.08  2.94 5.75  +0.07 +0.06 +0.04   A1V+A1V            +0.016-0.019      +012SB2O   26                 *
+6994          CP-77 1314 171990257625                       183227.7-775810184749.4-775202316.48-26.29 6.39  +0.60 +0.13         F8V                -0.022+0.188      +015                           
+6995          BD+16 3563 171994103913                       183239.8+160645183709.0+161154 45.92 10.40 6.29  +0.90 +0.56         G8IV               +0.010+0.047      -046                           
+6996          CP-64 3942 172021254343                       183236.4-644358184222.5-643835330.72-23.39 6.37  +0.15 +0.14         A5V                -0.009-0.032      -009V?                         
+6997          BD+33 3154 172044 67164       11504  11113    183257.2+332305183637.2+332808 62.18 17.42 5.42  -0.10 -0.50         B8II-IIIpHg        -0.019 0.000 +.007-026SBO    46  4.6   7.3      *
+6998          BD-21 5081 172051187086                       183255.6-210804183853.4-210307 12.73-06.80 5.86  +0.68 +0.14         G4V                -0.078-0.152 +.072+036V                          
+6999          BD-03 4331 172088142461       11520           183308.9-031652183823.7-031137 28.60  1.44 6.49  +0.55 +0.06         F9IV               -0.009+0.032 +.027-021V          0.1   0.1AB   3*
+7000          BD-01 3529 172103142460                       183309.2-011158183819.1-010648 30.44  2.41 6.66  +0.42 +0.01         F1IV-V             -0.027-0.012      -025       23                  
+7001  3Alp LyrBD+38 3238 172167 67174 699I  11510  Alp Lyr  183333.1+384126183656.3+384701 67.44 19.24 0.03   0.00 -0.01 -0.03   A0Va               +0.202+0.286 +.123-014V      15 10.4  62.8AB   5*
+7002          BD+08 3780 172171123744    I  11524  X Oph    183334.1+084448183821.0+085002 39.35  6.90 6.4 H +1.32 +0.89         M6IIIe+K1III       -0.014+0.006 +.011-071V          2.2   0.4      *
+7003          BD+43 3027 172187 476443481                   183341.8+430812183645.6+431319 71.90 20.72 6.20  +0.24 +0.09         F0V                +0.023-0.006      +005SB    185                  
+7004          CP-64 3943 172211254353                       183352.3-643838184337.2-643304330.86-23.50 5.78  +0.96 +0.77         K0III              +0.003-0.036      -011                           
+7005          CD-4812668 172223229194              11183    183356.3-481058184130.6-480542347.58-18.28 6.49  +1.22               K2III-IVCNII       -0.025-0.122      -046                          *
+7006          BD+77  699 172340  9151 700                   183434.8+772809182944.9+773249108.91 27.61 5.64  +1.18              gK4                 -0.001+0.001 +.014+001V?                         
+7007          BD-07 4648 172348142480    I  11552           183434.9-075248184000.5-074726 24.70-01.02 5.84  +1.55 +1.83         K4III              +0.004-0.032      -023V?         5.0  19.4      *
+7008          BD+05 3891 1723651237783485                   183441.5+051027183936.9+051551 36.28  5.02 6.38  +0.78 +0.42         F8Ib-II            +0.006+0.001      -019SB?                       *
+7009          BD+39 3476 172380 67193    I         XY Lyr   183448.2+393447183806.5+394005 68.41 19.32 6.04  +1.65 +1.42 +1.96   M4.5-M5+II         +0.006+0.006      -019                          *
+7010          BD+07 3798 172424123782       11555           183501.1+071609183951.6+072130 38.19  5.91 6.28  +0.96 +0.69         G8III              +0.007-0.056      -041           5.3  23.1AB   4*
+7011 26    SgrCD-2314625 1725461871463486                   183545.7-235535184151.6-235000 10.51-08.64 6.23  +0.23               Am                 +0.032-0.024      +002V                          
+7012          CP-64 3948 1725552543583489                   183537.9-645754184526.9-645217330.57-23.76 4.79  +0.20 +0.08         A5IV-V             +0.027-0.149 +.035+002      134                  
+7013          BD+65 1283 172569 17947 701                   183554.4+652357183613.3+652919 95.49 26.07 6.06  +0.28 +0.09         F0V                +0.019+0.083 +.009-023SB    135                 *
+7014          BD-14 5156 172594161730                       183600.7-143930184142.5-143351 18.85-04.48 6.42  +0.81               F2Ib               +0.006+0.001      -003V      17                  
+7015          CP-61 6229 172630254359                       183605.0-611134184511.5-610542334.54-22.80 6.04  +1.46               K3III              +0.023-0.023      -020                           
+7016          BD+30 3262 172631 67226                       183613.2+304523184002.0+305058 59.93 15.77 6.36R                     K0                 -0.005+0.032      -050                           
+7017          BD+40 3446 172671 47676      W                183619.6+405036183933.1+405606 69.77 19.49 6.25  -0.06 -0.17         B9V                +0.027-0.002      -009SB    130  0.4   0.2      *
+7018          BD+62 1637 172728 179583484                   183639.3+622608183733.5+623136 92.27 25.43 5.74  -0.06 -0.17         A0V                -0.005+0.051      -011V   =< 41                  
+7019          BD+38 3254 172741 67233                       183648.7+381626184012.2+382202 67.27 18.50 6.45  +0.21 +0.14 +0.09   A6m                +0.026+0.001      +017                          *
+7020   Del SctBD-09 4796 1727481425151486   11581  Del Sct  183647.9-090854184216.4-090309 23.83-02.10 4.72  +0.35 +0.14 +0.19   F2IIIpDel Del      +0.009+0.002 +.025-045SB     32  4.5  52.6AC   3*
+7021   Lam CrACD-3813036 172777210501      W       11247    183655.3-382510184346.9-381925357.21-15.04 5.13  +0.09               A2Vn               +0.003-0.057 +.024-026V     131  4.5  29.2AB   3*
+7022          CP-57 9180 172781245681                       183655.0-565851184523.7-565254338.92-21.66 6.22  +1.38               K3III              -0.054-0.007      +069                           
+7023          BD-19 5134 172816161754    I D       V3879 Sgr183701.6-192248184255.2-191702 14.74-06.86 6.35  +1.75 +1.56 +1.52E  M4III              -0.001-0.024      -033V?         2.6   0.6      *
+7024          BD-07 4670 172831142525                       183712.3-071012184236.1-070424 25.63-01.27 6.15  +1.00 +0.89         K0-1III            -0.003+0.005      +026V                          
+7025          BD+83  536 172864  30561646                   183721.8+830606182409.2+831031115.27 27.73 6.17  +0.05 +0.06         A2V                +0.015-0.027      -011                           
+7026          CD-3612946 172875210507                       183722.0-364856184407.7-364307358.77-14.47 6.32  +0.98               K0III               0.000-0.060      -028V?                         
+7027          CP-73 1939 172881257630      W                183725.5-730602184943.5-725941321.87-25.73 6.06   0.00 -0.09         B9.5IV-V           -0.004+0.024      +003SB3        2.0   1.8      *
+7028          BD+52 2263 172883 31093                       183734.8+520606183952.8+521146 81.31 22.82 6.00  -0.07 -0.21         A0p:Hg:            +0.004+0.028      -018V      65                 *
+7029          CD-3512876 1729102105093490  W                183737.5-354425184419.4-353831359.80-14.08 4.87  -0.18 -0.72 -0.16   B2.5V               0.000-0.031      +004       65  7.8   9.4      *
+7030          BD+31 3332 172958 672563487                   183754.7+313116184141.3+313704 60.81 15.74 6.41  -0.04 -0.20         B8V                +0.008+0.009      -016      175                  
+7031          CD-3912864 172991210518                       183800.4-394711184457.2-394111356.00-15.77 5.43  +0.87 +0.37?+0.60?  K3II+B7            +0.008-0.011 +.012-017SB                        *
+7032   Eps SctBD-08 4686 173009142546 702I  11601           183804.4-082227184331.3-081631 24.67-02.02 4.90  +1.12 +0.87 +0.61   G8IIb              +0.022+0.008 +.016-011V    < 19: 8.6  37.6AC   4*
+7033          BD+34 3285 173087 67265       11593A          183831.7+343856184208.1+344448 63.87 16.83 6.47  -0.13 -0.57         B5V                +0.010+0.008      -024SB    130  1.0   0.2AP   4*
+7034          BD-06 4859 173093142557                       183827.8-065459184351.4-064907 26.00-01.43 6.31  +0.48 +0.02         F7V                +0.048-0.055      -066       30                  
+7035          CD-2513394 173117187216      D                183840.7-250640184449.6-250040  9.73-09.76 5.83  +0.05 -0.35         B5:V               +0.005-0.022      +015V          0.2   0.0      *
+7036   The PavCP-65 3754 173168254374                       183848.0-651052184837.8-650440330.43-24.14 5.73  +0.24 +0.11         A8V                -0.045-0.083      -001      190                  
+7037          CD-5012135 173263245702                       183914.4-501151184659.1-500540345.91-19.80 6.54  +0.28               F0V                -0.001-0.034      -032                           
+7038          BD-21 5131 173282187234                       183920.5-210611184518.7-210005 13.44-08.12 6.36  +0.45               F5V                +0.027-0.019      +002V                          
+7039 27Phi SgrCD-2713170 1733001872391487  D                183924.5-270537184539.4-265927  8.00-10.77 3.17  -0.11 -0.36 -0.11   B8III              +0.053 0.000      +022SB     68  0.0   0.1      *
+7040  4    AqlBD+01 3766 173370123879              11290    183947.1+015730184449.9+020336 34.01  2.41 5.02  -0.06 -0.26         B9V               e+0.009-0.018 +.005-013V     300                 *
+7041          BD+39 3505 173383 67287    I W       11271    183956.6+391159184316.7+391801 68.41 18.26 6.45  +1.59 +2.00         K5                 +0.016-0.002      -034SB         3.8  60.2       
+7042          BD+62 1641 173398 17975                       184003.8+623900184056.3+624459 92.60 25.09 6.09  +0.98               K0III               0.000+0.061      -026                           
+7043          BD+36 3246 173416 67292                       184005.7+362714184336.1+363324 65.74 17.22 6.01  +1.04               G8                 +0.024+0.065      -061                           
+7044          BD+31 3348 173417 67293                       184006.1+314943184351.6+315536 61.29 15.43 5.70  +0.34 +0.05         F1III-IV           -0.033-0.129 +.026-002V                          
+7045          BD-19 5154 173425161803    I         11309    184006.9-194238184601.2-193623 14.78-07.65 6.42  +1.65               M4III              -0.002+0.004      -040V                         *
+7046 28    SgrBD-22 4854 173460187255    I  11652           184018.8-222949184620.6-222332 12.28-08.94 5.37  +1.64 +1.90         K4III              +0.031 0.000      -003V          7.7  13.7       
+7047          BD+23 3439 173494 86393                       184030.0+232922184440.2+233523 53.51 11.92 6.31  +0.40  0.00         F6V                +0.009-0.087 +.019-012                           
+7048          BD+05 3941 173495123886       11640           184033.4+052346184528.4+052959 37.16  3.83 5.83  +0.04 +0.03         A1V+A1V            +0.015-0.011D+.006-011SB    130  0.3   1.3AB   4*
+7049 46    DraBD+55 2107 173524 311193491  W       11273    184041.7+552617184237.9+553222 84.94 23.29 5.04  -0.09 -0.30         B9.5pHg:           -0.002+0.024 +.011-030SB2O   19  5.6 146.8AB   3*
+7050   Mu  CrACD-4012807 1735402292853492                   184045.1-403045184744.6-402422355.51-16.54 5.24  +0.78               G5-6III            +0.030-0.017 +.023-018V?                         
+7051  4Eps1LyrBD+39 3509 173582 67310       11635A          184101.5+393355184420.4+394012 68.85 18.20 5.06H +0.16 +0.06         A4V                +0.017+0.059 +.021-031V     200  0.0 209.3AC  10*
+7052  4Eps1LyrBD+39 3509 173583 67309       11635B          184101.6+393358184420.3+394016 68.85 18.20 6.02H                     F1V                +0.003+0.059 +.021-033V     150  0.0 209.3AC  10*
+7053  5Eps2LyrBD+39 3510 173607 67315       11635C 11301    184103.9+393029184422.9+393647 68.79 18.17 5.14H +0.19 +0.08         A8Vn               +0.008+0.064 +.021-024V?    177  0.0 209.3AC  10*
+7054  5Eps2LyrBD+39 3510 173608             11635D 11301    184103.9+393029184422.9+393646 68.79 18.17 5.37H                     F0Vn               +0.007+0.064 +.021-028V?    212  0.0 209.3AC  10*
+7055          BD-10 4797 173638161817       11670  11333    184112.4-101352184643.3-100730 23.38-03.56 5.71  +0.59 +0.54         F2Ib-II            -0.005+0.002      +010SB     16  8.2   3.4      *
+7056  6Zet1LyrBD+37 3222 173648 67321       11639A 11308    184119.6+373002184446.4+373618 66.85 17.38 4.36  +0.19 +0.16 +0.08   A4m               v+0.028+0.024 +.031-026SB1O   27  1.4  43.7AD   5*
+7057  7Zet2LyrBD+37 3223 173649 67324       11639D 11311    184121.5+372924184448.2+373540 66.85 17.37 5.73  +0.28 +0.06         F0IV              v+0.022+0.019 +.031-025SB    230  1.4  43.7AD   5*
+7058          BD+21 3550 173650 86405              V535 Her 184121.0+215246184535.7+215906 52.11 11.05 6.51  +0.02 -0.08         B9pSiCr:          v+0.015+0.012      -017SB?    16                 *
+7059  5    AqlBD-01 3559 173654142606       11667           184118.7-010401184628.5-005742 31.51  0.67 5.90  +0.13 +0.12 +0.07   A2Vm               +0.013-0.022D+.009+017SB? =< 25  1.6  12.8AB   3*
+7060          BD+53 2126 173664 31133                       184121.1+534611184329.0+535219 83.22 22.74 6.11R +0.12?              A2IV               +0.006-0.008      +000                           
+7061110    HerBD+20 3926 173667 86406 703I  11658  11323    184121.4+202702184539.7+203247 50.79 10.43 4.19  +0.46 +0.01 +0.26   F6V                -0.008-0.335 +.052+024       14  9.2  63.8AC   5*
+7062   Eta1CrACD-4312841 1737152292991490                   184137.5-434719184850.5-434048352.40-17.92 5.49  +0.13               A3V                +0.025-0.019      -004                           
+7063   Bet SctBD-04 4582 1737641426181489I                  184152.1-045118184710.5-044452 28.22-01.22 4.22  +1.10 +0.81 +0.57   G4IIa             e-0.004-0.016 +.019-022SB1O   10                 *
+7064          BD+26 3349 173780 864181488I                  184202.6+263318184604.5+263944 56.50 12.90 4.83  +1.20 +1.23 +0.61   K3III              +0.018+0.024 +.023-017V?   < 17                  
+7065          CD-4512779 1737912293063495                   184204.2-455520184927.4-454837350.33-18.76 5.81  +0.90 +0.51         G8III              +0.076+0.051      +010                           
+7066          BD-05 4760 173819142620    I         R Sct    184208.6-054845184729.0-054218 27.40-01.72 5.20  +1.47 +1.64 +0.77   K0Ibp             v-0.041-0.028 +.001+044V                         *
+7067          BD+18 3817 173833104087    I                  184218.1+183557184641.4+184221 49.21  9.42 6.17  +1.59               K5                 +0.028-0.022      -013                           
+7068   Eta2CrACD-4312854 173861229307                       184223.4-433240184935.0-432602352.69-17.95 5.61  -0.08               B9IV               -0.003-0.024      -023V?                         
+7069111    HerBD+18 3823 1738801040931491  W                184236.2+180412184701.3+181053 48.76  9.12 4.36  +0.13 +0.07 +0.03   A5III              +0.073+0.116 +.032-045SB?    79  5.5 121.3AC   4*
+7070          CD-3413128 173902210600                       184238.4-345125184917.2-344455  1.06-14.66 6.62  +1.08               K1IVCNIII          +0.046-0.101      -061                           
+7071          BD+54 2034 173920 31151                       184254.2+544728184455.4+545348 84.36 22.81 6.23  +0.82               G5III              +0.007-0.019      +007                           
+7072          BD-18 5079 173928161848      W                184253.7-184242184845.3-183605 15.98-07.79 6.47                      G5III:+A0V:        -0.007-0.004      -031V?         0.7   0.4       
+7073          BD+41 3137 173936 477793493                   184301.1+412002184613.0+412630 70.73 18.48 6.07  -0.13 -0.49         B6V                +0.001-0.001      -019      125                  
+7074   Lam PavCP-62 5983 173948254393 704  W       Lam Pav  184257.1-621807185213.0-621115333.61-23.87 4.22  -0.14 -0.89 -0.16   B2II-IIIe         v-0.006-0.014      +009V     189  8.0  63.1      *
+7075          BD+60 1845 173949 17995       11661           184307.5+605631184418.2+610253 90.85 24.36 5.99  +0.96 +0.73         G7IV               -0.005+0.018D+.006-025V?         2.8   1.2       
+7076          BD+04 3884 1739541239283494I                  184304.9+040752184802.7+041429 36.32  2.69 6.21  +1.51 +1.79         K5                v-0.002+0.014      -001                           
+7077          BD-19 5182 174115161871      D       Var?     184342.4-191518184935.5-190832 15.57-08.21 6.75  +0.20 +0.15 +0.11   A1m                +0.017+0.010      -043SB2        0.0   0.2      *
+7078 29    SgrBD-20 5277 174116187324    I  11713  11372    184344.1-202618184940.1-201929 14.50-08.74 5.24  +1.41               K4III              +0.005+0.036 +.034-018SB         8.6  16.6       
+7079          BD+23 3461 174160 86451                       184405.6+232412184816.4+233051 53.79 11.14 6.15  +0.49 +0.02?+0.60?  F8V                +0.024-0.030      -000    =< 15                 *
+7080          BD+46 2551 174177 47798                       184408.5+461219184659.0+461854 75.64 19.98 6.52  +0.07 +0.17         A2IV               -0.002-0.010      -001V?                         
+7081          BD+31 3369 174179 67396                       184410.8+313845184757.5+314525 61.48 14.57 6.06  -0.13 -0.66         B3IVp              +0.009-0.002      -015                          *
+7082          BD+70 1023 174205  9222                       184418.3+704114184310.2+704734101.44 26.18 6.44R                     K2                 -0.002-0.004      -005                           
+7083          BD-06 4922 174208142661    I  11719           184419.8-060133184941.0-055446 27.47-02.30 5.99  +1.60 +1.65         K2Ib               +0.005-0.006      -007SBO        2.5 113.7AC   3*
+7084          BD+52 2280 174237 311651492          CX Dra   184429.0+525241184643.1+525917 82.45 22.03 5.88  -0.09 -0.73         B2.5Ve            v+0.010-0.002      -016SBO   170                 *
+7085          BD+00 4027 174240123947                       184431.5+004323184937.1+005009 33.47  0.79 6.25  +0.04 +0.01         A1V                -0.001-0.024      -040SB     72                  
+7086          BD+19 3798 174262104129                       184431.6+191259184853.4+191943 50.00  9.22 5.88  +0.03 +0.02         A1V                +0.017-0.021      +006SB     74                  
+7087   Kap TelCP-5211268 1742952457723499                   184443.6-521319185239.6-520627344.16-21.27 5.17  +0.94               G8-K0III           +0.041-0.103 +.014-044                           
+7088 30    SgrBD-22 4881 1743091873421493   11731           184449.8-221636185050.5-220944 12.95-09.78 6.61  +0.38 +0.29         A7III              -0.019-0.033      -035V?    120  6.8  21.1      *
+7089          BD-08 4726 174325142674    I  11726  S Sct    184454.3-080120185020.0-075427 25.76-03.35 6.80  +3.09 +4.04         C5II               +0.003+0.003      +000           4.0  14.4AB   3*
+7090          BD+48 2767 174366 47815      S                184503.3+485745184740.0+490430 78.48 20.74 6.40R                     A1V                +0.005+0.019      -017       71        0.5       
+7091          BD+24 3545 174369 86462      S                184507.9+245558184914.4+250247 55.30 11.58 6.59R                     A1V                +0.003-0.014      -009SBO    74        0.2      *
+7092          CD-4612669 174387229336                       184501.1-464245185227.1-463543349.73-19.51 5.54  +1.63               M0III              +0.019-0.003 +.009-028                           
+7093          CP-5211273 174430245783                       184517.5-520259185312.1-515552344.37-21.30 6.31  -0.09               B4III              +0.010-0.006      -023                           
+7094          BD-09 4859 174464142692                       184528.4-095325185058.5-094627 24.16-04.34 5.83  +0.61 +0.35         F2Ib               +0.002-0.002      -018V?     19                  
+7095          CD-4812769 174474229342                       184528.0-482839185302.5-482136347.99-20.18 6.19  +0.14 +0.08         A2V                -0.003-0.046      -044                           
+7096          BD+48 2770 174481 478233497                   184537.8+483910184816.1+484603 78.20 20.55 6.12  +0.21 +0.08         A7III              -0.019+0.050      -030      185                  
+7097          CD-4612676 174500229343                       184534.2-464219185259.6-463509349.78-19.60 6.19  +0.03 +0.05         A1IV-V             -0.028+0.023      +035                           
+7098          BD+31 3373 174567 67438                       184557.0+313051184944.0+313745 61.51 14.17 6.64  +0.02 -0.10         A0V s              -0.003-0.012      -003    =<  7                  
+7099          BD+10 3685 174569104170    I  11750           184603.3+105134185045.6+105835 42.65  5.13 6.55R                     K5III+K3III        +0.023+0.009D+.005-024SB         1.1   3.5      *
+7100  8Nu 1LyrBD+32 3227 174585 67441       11732  11400    184602.5+324151184945.9+324846 62.64 14.63 5.91  -0.16 -0.71         B3IV               +0.006-0.008      -017V          5.9  58.7AC   6*
+7101  8    AqlBD-03 4392 1745891427063500                   184607.0-032605185122.1-031904 29.97-01.50 6.10  +0.30 +0.09         F2III               0.000-0.020      +012V                          
+7102  9Nu 2LyrBD+32 3228 174602 67446       11737           184608.8+322608184952.9+323303 62.40 14.50 5.25  +0.08 +0.11         A3V                -0.009-0.014 +.020+010V?    141  7.8  19.0      *
+7103          CD-2613562 174630187388                       184615.2-264605185228.5-263901  8.96-12.01 6.29  +0.94               G8/K0III           +0.013-0.046      -025V?                         
+7104          CD-2915449 174631187389                       184615.9-292951185237.0-292246  6.43-13.16 6.13  +1.35               K1III              -0.002-0.040      -056V                          
+7105          CD-3016356 1746322106633502                   184616.4-305110185241.7-304403  5.16-13.72 6.63  -0.05 -0.27         B8V                -0.002-0.023      -050V                          
+7106 10Bet LyrBD+33 3223 174638 67451 705I  11745A Bet Lyr  184623.2+331447185004.8+332146 63.19 14.78 3.45   0.00 -0.56 +0.02   B8IIpe             +0.003-0.003 -.002-019SBO        5.2  45.7AB   6*
+7107   Kap PavCP-67 3603 1746942544133505          Kap Pav  184638.4-672131185657.0-671401328.29-25.39 4.44  +0.71 +0.60         F5I-II             -0.010+0.012 +.010+038V                         *
+7108          CD-5012206 174730229358                       184649.9-500002185432.3-495243346.53-20.88 6.60  +0.08               A2V                -0.010-0.012      -008                           
+7109          BD+13 3787 1748531041963503  S       V822 Her 184726.8+135045185201.9+135756 45.48  6.19 6.14   0.00 -0.31         B8Vnn              -0.011-0.005      -029SB2O  125        0.1      *
+7110          BD-09 4876 174866142741      S                184732.1-094150185301.9-093434 24.57-04.70 6.34  +0.20 +0.11         A7Vn               +0.040-0.002      -048                 0.2       
+7111          CP-62 6002 174877254415                       184733.2-625540185654.7-624804333.08-24.54 6.48  +1.53               K3III               0.000+0.032      +027                           
+7112          BD+28 3104 174881 86512                       184739.9+283950185135.9+284701 59.00 12.65 6.18  +1.18               K1II-III           +0.012+0.008      -022                           
+7113112    HerBD+21 3582 174933 86521                       184800.1+211816185216.4+212531 52.27  9.41 5.48  -0.07 -0.42         B9II-IIIpHg        -0.006-0.008 +.007-020SB2O   13                 *
+7114 33    SgrBD-21 5176 174947187422    I                  184801.5-212856185400.1-212135 14.00-10.10 5.69  +1.23 +1.05?+0.65?  K1Ib               +0.008-0.015      -007V                          
+7115          BD+36 3295 174959 67485                       184805.6+362508185136.5+363219 66.35 15.72 6.09  -0.11 -0.48         B6IV               -0.007-0.022      -021       60                  
+7116 32Nu 1SgrBD-22 4907 174974187426    I  11794           184807.9-225204185410.2-224442 12.74-10.72 4.83  +1.41 +1.23 +0.69   K2I+B9V:           +0.010-0.010 +.030-012V?         5.8   2.5AB   3*
+7117          BD+73  835 174980  9241                       184816.3+735811184546.7+740508105.11 26.39 5.27  +0.92 +0.80         K0II-III           +0.005+0.077 +.020+003V    < 17                  
+7118          BD+41 3167 175132 47874                       184854.5+411541185207.1+412300 71.08 17.43 6.28  -0.09 -0.31         B9IIIpSi           -0.016-0.001      -023       68                 *
+7119          BD-15 5143 175156161964                       184859.2-154340185443.1-153611 19.33-07.75 5.10  +0.17 -0.39         B5II               -0.008-0.005      -003V?     19                 *
+7120 35Nu 2SgrBD-22 4915 175190187445    I                  184904.4-224746185507.1-224017 12.91-10.89 4.99  +1.33 +1.51 +0.66   K3II-IIIBa0.8CN2   +0.103-0.026 +.042-110SB                         
+7121 34Sig SgrCD-2613595 175191187448 706I W                184903.9-262515185515.9-261748  9.56-12.43 2.02  -0.22 -0.75 -0.21   B2.5V              +0.013-0.054      -011V     201  7.4 309.0      *
+7122          CD-4213761 175219229383                       184909.4-425013185616.9-424238353.85-18.85 5.36  +1.00               K0III              -0.035-0.026 +.010-021                           
+7123          BD+52 2294 175225 31217                       184920.5+525045185135.0+525830 82.65 21.33 5.51  +0.84 +0.51 +0.42   G9IVa              -0.046+0.271 +.037+002V?                         
+7124 50    DraBD+75  682 175286  92501494                   184936.1+751858184622.2+752602106.61 26.50 5.35  +0.05 +0.04         A1Vn               -0.015+0.073 +.008-008SB2O   57                 *
+7125 47Omi DraBD+59 1925 175306 31218 707I  11779  Omi Dra  184943.5+591558185112.1+592318 89.31 23.14 4.66  +1.19 +1.04 +0.64   G9IIIFe-0.5        +0.079+0.027 +.006-020SB1O   20  3.4  34.6AB   3*
+7126          BD-16 5078 1753171619841495                   184945.4-162954185531.0-162236 18.71-08.26 5.79  +0.36 +0.06         F4V                -0.025-0.185      -042V?                        *
+7127   Ome PavCP-60 7213 1753292544233511                   184943.2-601955185836.4-601202335.92-24.18 5.14  +1.37 +1.44 +0.52E  K2IIICNIV          -0.126+0.031 +.019+180                           
+7128          CD-2314844 175360187468                       184957.4-231804185600.6-231025 12.53-11.29 5.93  -0.02 -0.41         B8                 -0.002-0.009      -016V?                         
+7129          CD-3712982 175362210734              V686 CrA 184953.6-372815185640.5-372036359.16-17.02 5.38  -0.14 -0.71         B8IVSi            v+0.009-0.026      +001V     170                 *
+7130          CP-66 3404 175401254426                       184954.2-664705190003.5-663912328.98-25.59 6.01  +0.97 +0.80         K0III              +0.003-0.040      -020V                          
+7131 11Del1LyrBD+36 3307 175426 675373506  W       11504    185013.9+365048185343.6+365818 66.93 15.49 5.58  -0.15 -0.66         B2.5V              +0.004-0.002      -026SBO   123  3.7 174.6      *
+7132          BD+27 3150 175443 86558    I                  185014.6+274708185413.2+275434 58.43 11.76 5.62  +1.35               K4III              -0.016-0.074      +015                           
+7133113    HerBD+22 3524 175492 865673508I  11820           185031.5+223106185444.9+223842 53.63  9.42 4.59  +0.78 +0.49 +0.46   G4III+A6V           0.000+0.001 +.013-024SBO    50  7.9  35.7AB   3*
+7134   Lam TelCP-53 9402 175510245834 708                   185027.8-530410185827.7-525619343.57-22.35 4.87  -0.05               A0V                +0.010-0.011      -002SB     92                  
+7135          BD+06 3978 1755151240503509I         11536    185034.8+062924185527.5+063655 39.28  2.12 5.57  +1.04 +0.88 +0.55   K0III              +0.021-0.087 +.011+023SBO                       *
+7136          CD-3913012 175529210754                       185038.3-395716185734.7-394924356.80-18.08 6.31  +0.20               A3                 +0.037+0.029      +005                           
+7137          BD+50 2686 175535 31241    I                  185044.9+503501185313.6+504230 80.43 20.40 4.92  +0.90 +0.57 +0.45   G7IIIaFe-1         +0.005-0.025 +.024+008V?   < 19:                 
+7138          BD+41 3174 175576 47902                       185100.3+410554185414.3+411332 71.08 17.00 7.30R                     F5                 +0.034+0.017                                     
+7139 12Del2LyrBD+36 3319 175588 67559    I  11825  Del2 Lyr 185100.3+364617185430.2+365356 66.93 15.32 4.30  +1.68 +1.65 +1.63   M4II               -0.009+0.010 -.001-026           7.0  86.2AB   3*
+7140          BD+33 3257 175635 67566       11834           185112.6+335027185452.5+335807 64.18 14.11 6.02  +0.91 +0.64 +0.50   G8III+A2           -0.008+0.003      -016SB         1.0  45.4AC   4*
+7141 63The1SerBD+04 3916 175638124068 709   11853A 11557    185114.9+040424185613.2+041213 37.22  0.85 4.62  +0.17 +0.09         A5V                +0.049+0.031 +.030-046V?    143  0.4  22.2AB   3*
+7142 63The2SerBD+04 3917 175639124070       11853B          185116.3+040419185614.6+041207 37.22  0.85 4.98  +0.20 +0.08 +0.07   A5Vn               +0.049+0.026 +.030-053      196  0.4  22.2AB   3*
+7143          BD-01 3602 1756401428253510                   185111.0-015543185622.7-014800 31.89-01.92 6.22  -0.05 -0.30         B9III              -0.005-0.022      -026V?                        *
+7144          BD+02 3730 175679124073      W                185123.6+022029185625.6+022816 35.70  0.02 6.15  +0.97 +0.71         G8III              +0.007-0.011      -015V          5.7 100. AB   3 
+7145 36Xi 1SgrBD-20 5339 175687187498                       185123.9-204713185720.5-203923 14.99-10.50 5.08  +0.13 -0.14?        A0II               -0.001-0.007 -.006+002       14                  
+7146          BD+41 3177 175740 47909    I  11840           185140.0+412828185452.2+413610 71.49 17.03 5.44  +1.03               K0III              +0.002-0.002      -009V          6.9  23.6AC   3 
+7147          BD+17 3778 175744104271              V828 Her 185138.4+175157185603.9+175942 49.54  7.11 6.63  -0.04 -0.44         B9pSi              +0.011-0.018      -025       59                 *
+7148          BD+17 3779 175743104272                       185141.4+175848185606.2+180619 49.65  7.15 5.69  +1.09 +1.06         K1III              -0.041-0.162 +.004+044SB                        *
+7149   Eta SctBD-06 4976 175751142838    I                  185142.4-055834185703.7-055046 28.36-03.91 4.83  +1.08 +1.02 +0.53   K2III              +0.066-0.036 +.039-093V    < 19:                 
+7150 37Xi 2SgrBD-21 5201 175775187504 710I                  185145.8-211417185743.8-210624 14.61-10.78 3.51  +1.18 +1.13 +0.59   K1III              +0.033-0.012 +.011-020                          *
+7151          CD-3116189 175794210773                       185155.9-311002185821.3-310210  5.37-14.96 6.12  +1.35               K3III              -0.045-0.056      +085                           
+7152   Eps CrACD-3713001 1758132107813512          Eps CrA  185158.7-371416185843.4-370627359.54-17.32 4.87  +0.41 +0.03         F2V                -0.132-0.105 +.032+054SBO   132:                *
+7153          BD+57 1915 175823 31252                       185202.2+572134185346.3+572913 87.41 22.31 6.22  +1.23              gK5                 +0.018-0.006      -005                           
+7154          BD+48 2793 175824 47913       11846           185208.8+484403185447.1+485135 78.66 19.56 5.77  +0.43 +0.02         F3III              -0.061-0.118 +.017-011V?     50  4.7   1.5AB   3*
+7155          CD-2513574 175852187517      D                185212.6-250035185820.5-245236 11.17-12.48 6.62  +0.08               A0                 +0.007+0.003      -017           0.0   0.1      *
+7156          CD-3913032 175855210786      W                185216.3-394004185911.1-393205357.20-18.27 6.49  -0.04               A0                 +0.009-0.035      -015           5.3  15.9       
+7157 13    LyrBD+43 3117 175865 47919 711I         R Lyr    185217.5+434851185520.1+435646 73.81 17.79 4.04  +1.59 +1.41 +1.91   M5III              +0.023+0.083 +.000-028SBO                       *
+7158 64    SerBD+02 3738 175869124089                       185214.8+022414185716.6+023207 35.85-00.14 5.57   0.00 -0.27         B9IIIep:Hg:       v-0.005-0.012      -010V     105                 *
+7159          BD-22 4928 175892187519                       185223.4-223947185824.6-223146 13.36-11.52 6.14  +0.09               A2V                -0.022+0.017      -007                           
+7160          BD+79  604 175938  92563501                   185241.7+794920184538.1+795633111.64 26.93 6.39  +0.28 +0.04         A8V                +0.015+0.057      -005V?    113                  
+7161          CP-68 3180 175986254446      W                185248.5-685342190329.7-684519326.72-26.23 5.88  +0.56 +0.13         F8V                -0.015-0.003      +025           0.0   0.2      *
+7162          BD+32 3267 176051 67612       11871           185316.6+324623185701.6+325405 63.35 13.27 5.22  +0.59 +0.03 +0.34   F9V                +0.172-0.157 +.057-047V       4  2.2   0.7AB   6*
+7163          BD+06 3989 176095124112                       185330.4+060630185823.8+061425 39.28  1.30 6.21  +0.46 +0.01         F5IV               -0.003-0.104      -009    =< 10                  
+7164          BD-18 5155 176123162050      D                185335.7-184206185926.8-183401 17.12-10.06 6.37  +0.99               G3II               +0.003-0.043      -014V                         *
+7165          BD+17 3799 176155104296       11884  FF Aql   185347.7+171335185814.7+172139 49.21  6.36 5.38  +0.80 +0.43         F8Ib               -0.003-0.007 -.007-022SBO    17  5.3   6.6      *
+7166          BD-13 5172 176162162052      W       Var      185346.7-125834185923.8-125026 22.33-07.55 5.53  -0.04               B5IV               +0.002-0.018D+.006-013SB    185  0.5   0.4      *
+7167 10    AqlBD+13 3838 176232104303              V1286 Aql185411.4+134620185846.9+135424 46.16  4.70 5.89  +0.25 +0.09         F0pSrEu            -0.002-0.052      +015    =<  6                 *
+7168          CD-2513614 176246187562                       185416.6-250452190024.8-245632 11.31-12.94 6.36  +1.25              gK0                 +0.055+0.044      -025                           
+7169          CD-3713017 176269210815    I W     B          185417.7-371156190103.2-370339359.76-17.73 6.69                      B9V                +0.011-0.020      +012SB    172  0.2  12.8      *
+7170          CD-3713018 176270210816      W     A          185418.8-371158190104.3-370343359.76-17.74 6.40  -0.03               B8V-IV             +0.010-0.040      -015SB  =< 39  0.2  12.8      *
+7171          BD+19 3858 176301104306                       185424.1+193930185845.1+194739 51.45  7.34 6.50  -0.04 -0.43         B7III-IV           +0.004-0.004      -001      125                  
+7172 11    AqlBD+13 3841 176303104308       11902  11618    185429.4+132921185905.7+133721 45.94  4.50 5.23  +0.53 +0.07 +0.30   F8V                +0.014-0.123 +.039+016V?     26  4.3  17.8AB   3*
+7173          BD+09 3951 176304104313                       185432.9+100015185917.5+100827 42.85  2.88 6.75  +0.25 -0.43         B2Vp               +0.025-0.011      -015V?     49                  
+7174          BD+38 3373 176318 67642                       185436.5+380751185801.9+381558 68.51 15.21 5.89  -0.17 -0.52         B7IV               +0.001 0.000      -028SB1O  125                 *
+7175 48    DraBD+57 1922 176408 312843513                   185503.5+574056185645.0+574854 87.87 22.02 5.66  +1.15 +1.19         K1III              -0.029-0.062 +.018-034V?                         
+7176 13Eps AqlBD+14 3736 176411104318 712I W                185505.0+145557185937.4+150406 47.30  5.04 4.02  +1.08 +1.04 +0.52   K1-IIICN0.5Ba0.2   -0.051-0.073 +.028-048SB   < 17  5.9 131.1AB   3*
+7177          CD-4213839 176425229446                       185504.5-420304190208.7-415436355.04-19.60 6.23   0.00               A0V                +0.048+0.002      -013                           
+7178 14Gam LyrBD+32 3286 176437 67663 713   11908  11624    185512.1+323308185856.6+324122 63.32 12.81 3.24  -0.05 -0.09 -0.01   B9III              -0.002+0.002 +.021-021V      76  8.3 176.9AC   4*
+7179          BD+40 3544 176502 47965       11910           185530.2+403230185846.6+404045 70.88 16.00 6.22  -0.16 -0.65         B3V                +0.008 0.000      -014SB         3.5  19.0      *
+7180 52Ups DraBD+71  915 176524  9283 714I                  185537.4+710949185423.9+711750102.15 25.36 4.82  +1.15 +1.10 +0.56   K0IIIBa0.2         +0.049+0.044 +.014-007SB   < 17                  
+7181          BD+26 3418 176527 86673    I                  185541.0+260531185945.5+261350 57.41  9.94 5.27  +1.24 +1.27         K2III              +0.088-0.008 -.002-024SB   < 17                  
+7182          BD-22 4946 176537187584    I                  185536.0-225011190137.8-224144 13.53-12.26 6.24  +1.66               K5                 +0.004 0.000      -014V?                         
+7183          BD+22 3549 176541 86675    I                  185545.0+224031185958.1+224853 54.32  8.41 6.29  +1.75 +2.00         M3.5IIIab          -0.022+0.012      -053                           
+7184          BD+58 1849 176560 31292       11897           185549.5+580515185728.4+581331 88.33 22.04 6.46  +0.08 +0.05         A2IV               +0.014+0.047 -.008-008V?    105  0.2   0.8      *
+7185          BD+39 3602 176582 67675                       185550.2+390445185912.3+391304 69.51 15.36 6.41  -0.17 -0.70         B5IV               +0.002+0.012      -014V                         *
+7186          BD-15 5185 176593162097                       185550.6-152525190133.5-151657 20.35-09.10 6.32  +1.00 +0.78        gG6                  0.000+0.003      +020V?                         
+7187          BD+65 1309 176598 180793514                   185559.0+650725185625.6+651529 95.68 23.95 5.63  +0.95 +0.69         G8III              -0.028-0.032 -.002-005V?                         
+7188   Zet CrACD-4213855 1766382294613519                   185601.9-421413190306.9-420543354.91-19.83 4.75  -0.02 -0.07         B9.5V              +0.061-0.049 +.031-013                           
+7189 NOVA 1899                                     V1016 Sgr0 0 0      0 0 0 0 0      0 0                                                                                                           *
+7190          CD-5111893 176664245899      W                185609.8-510931190357.4-510107345.82-22.64 5.93  +1.24 +1.38         K0-1III            +0.028-0.146      -061           6.5  22.0AC   3 
+7191          BD+62 1669 176668 18082       11901           185617.0+621541185717.4+622348 92.68 23.18 6.45  +0.93 +0.66         G5IV+G8V           +0.006-0.039      -008V?         2.8  17.0AB   4*
+7192 15Lam LyrBD+31 3424 176670 67682    I         11641    185614.4+320020190000.9+320844 62.91 12.38 4.93  +1.47 +1.67 +0.73   K2.5IIIBa0.5       +0.013+0.013 -.003-016V    < 19:                 
+7193 12    AqlBD-05 4840 176678142931    I         11655    185620.4-055248190140.8-054420 28.98-04.89 4.02  +1.09 +1.04 +0.54   K1III             v-0.019-0.033 +.021-044V    < 17                  
+7194 38Zet SgrCD-3016575 176687187600    I  11950           185615.0-300123190236.7-295249  6.84-15.35 2.60  +0.08 +0.06 +0.01   A2III+A4IV         -0.015-0.002 +.025+022SB     72  0.3   0.5AB   3*
+7195          CD-2513655 176704187599      D                185620.4-245905190227.7-245049 11.60-13.32 5.65  +1.23               K3III              -0.022-0.175      +002V?         0.0   0.1      *
+7196          BD+50 2705 176707 31304                       185630.3+504012185859.6+504834 80.84 19.57 6.30  +0.98               G8III              +0.024+0.018      -021                           
+7197          CD-3813300 176723210859                       185628.1-382350190317.7-381512358.75-18.57 5.74  +0.32               F0IIIn             +0.013+0.009      +004V?    203                 *
+7198          BD+19 3879 176776104362                       185643.1+191005190105.5+191835 51.26  6.63 6.39R                     K1III              +0.018+0.002      -029                           
+7199          BD+75  683 176795  9286       11870           185655.3+753914185333.2+754715107.07 26.10 6.22R                     A1V                +0.013+0.024 -.004-017SB    100  0.8   5.6      *
+7200          BD+20 4022 176819 86704              11659    185704.1+204127190122.6+205001 52.67  7.25 6.69  +0.02 -0.69         B2IV-V             +0.007+0.017      -010SBO                       *
+7201          BD+40 3555 176844 47993    I         11652    185702.5+403236190019.0+404103 71.00 15.73 6.65R                     M4IIIa             +0.002-0.011      -005                           
+7202          BD+26 3429 176871 867073518                   185713.6+260857190117.4+261729 57.62  9.65 5.69  -0.08 -0.54         B5V                 0.000-0.011 +.009-014V     296                  
+7203          BD-19 5273 176884162130       11972           185711.1-192323190303.8-191443 16.87-11.12 6.05  +1.29 +1.09         G6III              +0.007+0.006      -020V?         3.5   7.4AB   4*
+7204          BD+33 3287 176896 67699                       185714.0+333936190055.2+334808 64.53 12.89 6.01  +0.97              gK0                 +0.007+0.003      -028V                          
+7205          BD-19 5275 176903162133      D                185714.6-191451190307.0-190612 17.00-11.07 6.37  +0.48               F5IV-V             +0.007-0.015      +019V?         0.0   0.1      *
+7206          BD+24 3608 176939 86714                       185727.6+245258190134.9+250133 56.49  9.05 6.72R                     K2                 -0.001 0.000      -021                           
+7207          BD+22 3561 176971 86716                       185734.6+220714190149.5+221550 54.01  7.78 6.40R +0.16?              A4V                +0.021-0.008      -038V?                         
+7208          BD+08 3951 176981124184                       185732.9+081346190221.6+082227 41.63  1.40 6.30  +1.67 +1.73         K2III              +0.026+0.022      -009                           
+7209 14    AqlBD-03 4460 176984142959      W                185738.5-035038190254.5-034156 30.94-04.23 5.42   0.00 -0.07         A1V                +0.023+0.007      -039V?     56  0.0   0.1      *
+7210          BD+50 2708 177003 313113515                   185742.8+502330190013.7+503201 80.64 19.29 5.38  -0.18 -0.75         B2.5IV             +0.009+0.005      -019SB     13                  
+7211          CD-3116306 177074210883                       185759.8-311137190425.1-310249  5.88-16.16 5.50  +0.03               A0IV               +0.014-0.016      -026V?    107                  
+7212          BD+33 3295 177109 67721       11965           185806.5+332838190148.3+333717 64.44 12.65 6.39  -0.12 -0.62         B5IV               -0.003+0.003      -023           6.2  25.4       
+7213   Rho TelCP-5211356 177171245921                       185824.9-522915190619.9-522027344.54-23.35 5.16  +0.53 +0.04         F7V                +0.030-0.118 +.022+002SB2    46                 *
+7214          BD+01 3865 177178124203                       185828.7+014027190332.2+014908 35.93-01.86 5.83  +0.18 +0.10         A4V                +0.006-0.067      -022SB2   160                  
+7215 16    LyrBD+46 2602 177196 48011       11964  11677    185836.5+464735190126.4+465605 77.15 17.86 5.01  +0.19 +0.08 +0.09   A7V                +0.020-0.084 +.036+008V     121  6.3 200. AC   3*
+7216          BD+19 3888 1771991044053521                   185831.1+193055190252.6+193940 51.77  6.41 6.09  +1.34               K1III              +0.004-0.001      -007                           
+7217 39Omi SgrBD-21 5237 177241187643    I  11996  11703    185841.4-215317190441.0-214430 14.71-12.51 3.77  +1.01 +0.85 +0.53   G9IIIb             +0.080-0.060 +.044+025           9.9  35.7       
+7218 49    DraBD+55 2137 177249 31323                       185844.6+553054190043.4+553930 85.83 20.86 5.48  +0.86               G5.5IIbFe-0.5      -0.016-0.006      +010V                          
+7219          BD+03 3882 177332124219                       185910.5+031055190410.7+031950 37.35-01.31 6.73  +0.13 +0.14 +0.09   A5m                +0.007+0.013      -013                           
+7220          BD-05 4858 177336142985    I         V Aql    185903.7-054959190424.2-054106 29.33-05.47 6.90  +4.19               C5II               +0.020-0.005      +037V?                        *
+7221          CP-68 3185 177389254475                       185916.7-683441190952.7-682529327.17-26.76 5.33  +0.91 +0.61         G8-K0III-IV        +0.145-0.052 +.030-010                           
+7222          BD+21 3648 177392 86753              LT Vul   185924.9+210714190342.5+211604 53.30  6.95 6.52  +0.32?              F2III              +0.022-0.021      +005      120                 *
+7223          CD-4812901 1774062294933523                   185923.3-482701190655.6-481757348.80-22.36 5.97  -0.02 -0.02         A0V                +0.016-0.016      -006                           
+7224          BD+69 1018 177410 181033517          EE Dra   185929.9+692320185852.6+693152100.31 24.65 6.52  -0.15 -0.53         A0pSi              +0.005+0.004      -015                          *
+7225 15    AqlBD-04 4684 177463142996    I  12007A          185940.9-041049190457.6-040153 30.88-04.84 5.42  +1.12 +1.01 +0.61   K1III              +0.020-0.027 +.002-018V?  =< 25  1.6  38.5      *
+7226   Gam CrACD-3713048 177474210928      W                185939.5-371225190625.1-370348  0.16-18.73 4.93  +0.52 -0.00         F8V                +0.096-0.274 +.054-052SB      0  0.1   1.6      *
+7227   Gam CrACD-3713048 177475210928      W                185939.5-371225190625.1-370348  0.16-18.73 4.99  +0.52 +0.00         F8V                +0.096-0.274 +.054-052           0.1   1.6      *
+7228   Sig OctCP-89   47 177482258857 923          Sig Oct  185944.1-891517210846.2-885723303.91-27.71 5.47  +0.27 +0.13         F0III              +0.023+0.005      +012      108                 *
+7229          BD+52 2326 177483 31337       11979           185945.9+520656190207.0+521540 82.47 19.59 6.31  +1.00               G8III              -0.007-0.026D+.005+004V?         3.4   5.2AxBC 3*
+7230          BD-15 5223 1775171621773522  W       Var?     185957.5-154839190541.2-153937 20.44-10.16 5.97  -0.02 -0.25         B9V                +0.003-0.007      -026SB     95  6.2  46.9      *
+7231          BD-01 3642 177552143003                       190007.7-013947190518.6-013046 33.17-03.78 6.53  +0.35 -0.04         F1V                -0.003-0.007      -032       45                  
+7232          CD-3713049 177565210937                       190006.6-375710190652.5-374837359.46-19.08 6.16  +0.72 +0.28         G5IV               -0.184-0.352 +.063+059                           
+7233          CP-55 9001 177693245937                       190035.4-555221190852.1-554313341.05-24.51 6.49  +1.10               K1III              +0.031-0.110      -021                           
+7234 40Tau SgrCD-2713564 1777161876831496I                  190041.8-274900190656.4-274014  9.34-15.37 3.32  +1.19 +1.15 +0.59   K1+IIIb            -0.053-0.251 +.044+045SB                        *
+7235 17Zet AqlBD+13 3899 177724104461 716I  12026  11724    190048.8+134253190524.6+135148 46.86  3.25 2.99  +0.01 -0.01  0.00   A0Vn               -0.005-0.096 +.045-025SB    331  8.4 158.6AC   3*
+7236 16Lam AqlBD-05 4876 177756143021 717I'                 190056.5-050157190614.9-045257 30.26-05.51 3.44  -0.09 -0.27 -0.09   B9Vn               -0.017-0.090 +.032-012V     176                  
+7237          BD+31 3453 177808 67782    I                  190109.2+313542190457.9+314440 62.98 11.26 5.56  +1.54 +1.91 +0.91   M0III              +0.076-0.067 +.018+006V?                         
+7238          BD+30 3409 177809 67781    I                  190106.9+303458190458.3+304400 62.05 10.83 6.06  +1.55 +1.88         M2.5IIIab          +0.030-0.022      -016SB                         
+7239          BD-16 5153 177817162201       12039           190107.1-162257190652.3-161344 20.04-10.66 6.03  -0.04 -0.35         B8IV               +0.021+0.004      -017V?         4.0   6.4      *
+7240          CD-2815403 177846187701    I                  190113.1-284727190730.9-283813  8.46-15.86 6.04  +1.61               K3III              +0.008-0.010      +005V                          
+7241          BD-18 5206 177863162204              11743    190117.2-185330190708.5-184416 17.75-11.78 6.29  -0.04 -0.41         B8III              +0.019-0.004      -011V                          
+7242   Del CrACD-4013061 177873229513                       190123.3-403906190820.9-402948356.86-20.24 4.59  +1.09 +1.03         K1III              +0.037-0.026 +.016+020                           
+7243          BD+08 3970 177940124266    I W       R Aql    190133.2+080443190622.2+081348 41.95  0.45 6.09  +1.60 +0.37         M7IIIe            v+0.006-0.071      +032V          5.0 180.7AC   3*
+7244          BD+29 3472 178003 86796    I                  190153.4+294608190547.1+295518 61.38 10.32 6.31  +1.65 +1.98         M0III              -0.005-0.009      -028                           
+7245          BD+00 4106 178065124282                       190202.9+002911190709.1+003830 35.30-03.20 6.56  +0.05 -0.28         B9III              +0.003+0.009      -011V       5                 *
+7246          CD-2415041 178075187718                       190208.0-244848190814.6-243925 12.32-14.45 6.30  +0.04 -0.24         B9III              +0.018+0.005      -013                           
+7247          BD+76  712 178089  9296                       190209.1+765430185757.2+770303108.50 26.02 6.54  +0.38 -0.06         F2V                -0.039-0.064      -027V?     15                  
+7248 18    AqlBD+10 3787 1781251044883525          Y Aql    190216.1+105502190658.6+110417 44.55  1.63 5.09  -0.07 -0.39         B8III              +0.005-0.026 +.016-019SBO    57                 *
+7249          BD-19 5312 178175162229              V4024 Sgr190224.2-192649190816.7-191724 17.35-12.26 5.54  -0.11 -0.78 -0.04   B2Ve              v+0.006+0.008      -020SB    176                 *
+7250          BD+24 3640 178187 86817                       190228.2+240544190638.4+241503 56.30  7.67 5.77  +0.09?              A4III              +0.055+0.015      -022V?                         
+7251 51    DraBD+53 2178 178207 31371                       190240.3+531435190455.2+532348 83.76 19.56 5.38  -0.01 -0.08         A0Vn               -0.003+0.025 +.023-024SB    173                  
+7252          BD+49 2929 178208 48071       12034           190234.8+494611190509.9+495524 80.32 18.34 6.43R                     K3III              -0.004+0.014      +008           5.3  80. AC   3 
+7253          BD+28 3193 178233 868191498                   190239.6+282816190637.7+283743 60.28  9.60 5.55  +0.29 +0.04         F0III              +0.076+0.085 +.025-024SB    158                  
+7254   Alp CrACD-3813350 178253210990 718                   190240.2-380336190928.3-375416359.54-19.59 4.11  +0.04 +0.08  0.00   A2V                +0.084-0.098 +.036-018      201                 *
+7255          CD-4013074 178254210994                       190245.2-395907190939.7-394941357.62-20.26 6.46  +1.06               K0III              -0.001-0.049      +017                           
+7256          CD-3613355 1782992109963528                   190255.1-361924190936.4-360953  1.28-19.02 6.56  -0.02               A0IV               -0.008-0.013      -011SB2                       *
+7257          CD-4213933 178322229531                       190255.0-420304190957.8-415333355.55-20.98 5.88  -0.08 -0.46         B6V+F1IV           +0.010-0.020      +013SB2O  102                 *
+7258          BD+41 3232 178329 480843526                   190302.5+411532190617.0+412450 72.15 14.98 6.49  -0.15 -0.64         B3V                +0.003-0.002      -021SBO                       *
+7259   Bet CrACD-3913146 178345211005                       190309.0-392958191001.7-392027358.14-20.17 4.11  +1.20 +1.07 +0.61   K0II               +0.003-0.038 +.016+003                           
+7260          BD+16 3752 178428104511      W       Var?     190328.1+164216190757.3+165112 49.80  4.07 6.07  +0.70 +0.27 +0.36   G5V                +0.060-0.306 +.059+014SB1O       4.5  21.5      *
+7261 17    LyrBD+32 3326 178449 67835       12061           190338.6+322038190725.6+323006 63.91 11.11 5.23  +0.34 +0.07         F0V                +0.130+0.023 +.017+004SB1O  127  4.3   3.5AB  10*
+7262 18Iot LyrBD+35 3485 178475 67834 719  S                190343.9+355636190718.1+360601 67.23 12.65 5.28  -0.11 -0.51         B6IV               +0.001-0.004      -018V     250                 *
+7263          BD+21 3672 178476 86843      S                190346.6+213220190803.6+214156 54.15  6.24 6.23  +0.40 +0.01         F3V                +0.051+0.074 +.008-040       50        0.2      *
+7264 41Pi  SgrBD-21 5275 178524187756 720I W       11769    190349.0-211057190945.8-210125 15.89-13.29 2.89  +0.35 +0.22 +0.24   F2II                0.000-0.035 +.026-010       28  0.0   0.1AB   3*
+7265          BD-20 5415 178555162260       12096           190354.3-195741190948.1-194813 17.03-12.80 6.13  +1.16 +1.13         K1III              +0.020-0.079D+.004+030V          0.2   0.1      *
+7266 19    AqlBD+05 4040 1785961243183530                   190406.0+055457190859.9+060424 40.34-01.12 5.22  +0.35 +0.04         F0III-IV           -0.006-0.076 +.032-047V     104                  
+7267          BD+16 3758 1786191045243529                   190411.6+164142190840.2+165105 49.88  3.91 6.48  +0.52 +0.25         F5IV-V             -0.036-0.104 +.018+010SB2O                      *
+7268          CD-3913156 178628211017                       190410.6-390959191101.8-390018358.54-20.25 6.36  +0.01               B7IIIMn            -0.011-0.018      -005SB                        *
+7269          BD-00 3662 178744143087                       190443.0-003521190951.6-002541 34.65-04.29 6.34  -0.04 -0.49         B5Vn               +0.006-0.006      -011                           
+7270          CD-2915804 178840187786                       190458.7-293954191118.9-293008  7.95-16.96 6.30  -0.04               B9                 +0.033-0.018      -014                           
+7271          CD-5012377 178845245976      W                190503.0-503901191246.1-502911346.77-23.85 6.13  +0.95               G8III              +0.040-0.044      -026           5.3   7.        
+7272          BD+34 3439 178911 67879       12101           190524.5+342603190904.4+343602 65.99 11.69 6.74  +0.63 +0.15         G1V                +0.053+0.195 +.025-041V?         1.5  16.4AB   4*
+7273          CD-3713090 178937211037                       190523.8-374451191209.8-373458  0.05-19.99 6.57  +1.02               G2III              +0.010+0.008      -039V?                         
+7274   Tau PavCP-69 2962 179009254508                       190544.7-692136191628.5-691126326.38-27.43 6.27  +0.17 +0.14         A6IV-V              0.000-0.024      -018                           
+7275          BD+52 2350 179094 31413    I         V1762 Cyg190605.2+521558190825.8+522532 82.98 18.73 5.81  +1.09 +0.87         K1IV               -0.099-0.059 +.002+004SBO                       *
+7276          BD-21 5292 179201187816                       190629.5-214926191228.0-213929 15.55-14.13 6.41  +1.13              gG8                 +0.027-0.012      -005SB                         
+7277          CD-2613936 1793231878353533I                  190704.1-260428191313.7-255424 11.59-15.98 5.80  +1.38 +1.42?        K1I                -0.002-0.006      +003                           
+7278          CP-66 3417 179366254515      W                190708.8-665000191712.0-663941329.22-27.27 5.53  +0.18 +0.13         A5V+A8V            -0.002-0.021      +012           0.3   0.4      *
+7279 20    AqlBD-08 4887 1794061431341500          11808    190715.2-080624191240.7-075622 28.23-08.31 5.34  +0.13 -0.44         B3V                +0.016-0.006      -015V     187                  
+7280          BD+26 3474 179422 86912                       190727.3+263414191130.9+264409 59.04  7.79 6.36  +0.41 -0.03         F5V                +0.023-0.036      -027       40                  
+7281          CD-4513054 179433229573                       190723.1-452144191439.7-451136352.43-22.76 5.92  +0.90               G8III              +0.059-0.036 +.022-035                           
+7282          BD-12 5311 1794971623263534I         11815    190740.1-122701191315.5-121657 24.34-10.35 5.51  +1.44              gK4                 +0.012-0.027      -018                           
+7283 19    LyrBD+31 3497 179527 679463532          V471 Lyr 190755.8+310659191146.0+311700 63.19  9.75 5.98  -0.07 -0.30         B9pSi              -0.002-0.003      -030       36                 *
+7284          BD+40 3620 179583 48168                       190803.9+401547191123.1+402545 71.62 13.70 6.18  +0.09 +0.10         A3V                 0.000-0.023      +006                           
+7285          BD+16 3775 179588104602       12160           190805.4+164043191234.4+165047 50.30  3.08 6.73  -0.01 -0.28         B9IV               -0.006-0.015 +.007-018V          1.4 113.4AC   5*
+7286          BD+21 3690 179648 86930                       190819.3+212309191236.7+213316 54.50  5.23 5.93R +0.03 +0.02         A2Vn               +0.005-0.002      -013V?    160                  
+7287 21    AqlBD+02 3824 1797611244083537   12182  V1288 Aql190840.1+020725191342.7+021737 37.52-03.90 5.15  -0.07 -0.41         B8II-III           +0.009-0.003 +.009-005V      19  7.5  36.2      *
+7288          BD+05 4081 179791124410              11827    190848.6+052044191344.1+053057 40.39-02.42 6.49  +0.09 +0.11         A2Vp               +0.016-0.006      +009V?    175                 *
+7289          CD-4513072 179886229584                       190904.9-453825191621.7-452759352.23-23.13 5.40  +1.35               K3III              -0.003+0.002 +.010+006                           
+7290 55    DraBD+65 1326 179933 181873531                   190923.3+654840190945.8+655843 96.82 22.80 6.25   0.00 -0.02         A0V                +0.001+0.030      -022       68                  
+7291          CD-2415161 179949187883                       190927.7-242059191533.2-241045 13.46-15.78 6.25  +0.54 +0.09         F9V                +0.116-0.095 +.023-026                           
+7292 42Psi SgrCD-2513866 179950187882    I: 12214           190924.5-252545191532.4-251524 12.42-16.20 4.85  +0.56 +0.32 +0.34   G8:III+A8V         +0.045-0.025 +.005-033SB2O    0  0.3   0.1AB   3*
+7293          BD+49 2959 179957 48192       12169B          190929.5+494002191204.6+495115 80.67 17.27 6.75  +0.65 +0.19         G4V                -0.190+0.637 +.044-041V   =< 54  0.2   8.1AB   4*
+7294          BD+49 2959 179958 48193       12169A          190930.2+494009191205.0+495122 80.67 17.27 6.57  +0.65 +0.21         G4V                -0.210+0.635 +.044-038V   =< 54  0.2   8.1AB   4*
+7295 53    DraBD+56 2209 180006 314683535I         11819    190947.1+564120191140.5+565133 87.56 19.81 5.12  +1.01 +0.84 +0.49   G8III              +0.039+0.048 +.012-016     < 19:                 
+7296          CD-3314076 180093211117    I         RY Sgr   191000.9-334150191632.8-333118  4.43-19.45 6.25  +0.02 -0.07         G0Ipe(C1,0)        +0.012+0.024      -023V                         *
+7297          CP-53 9513 180134246017                       191011.0-533343191809.4-532312343.88-25.32 6.38  +0.49  0.00         F7V                -0.013-0.065      -024                           
+7298 20Eta LyrBD+38 3490 180163 68010       12197  11839    191021.2+385826191345.5+390846 70.62 12.75 4.39  -0.15 -0.65 -0.15   B2.5IV             +0.004+0.002 +.002-008SB1O   24  4.0  28.3AB   3*
+7299          BD+19 3956 180242 86981                       191041.7+200145191502.6+201212 53.56  4.11 6.00  +0.88               G8III              -0.012 0.000      +007                           
+7300          BD+14 3846 180262104655      W                191046.7+145434191520.1+150501 49.05  1.67 5.57  +1.07 +0.87 +0.54   G8II-III           +0.002-0.011      -025V          2.1  89.6      *
+7301  1    SgeBD+20 4088 180317 86987                       191058.8+210326191517.4+211356 54.50  4.53 5.64  +0.11               A4V                +0.039+0.012      -023V     231                 *
+7302          BD+30 3491 180450 68040    I                  191131.7+302106191524.8+303135 62.85  8.72 5.85  +1.67 +2.03         M0III              +0.029-0.023      -063                           
+7303 22    AqlBD+04 4045 180482124455                       191134.0+043930191631.0+045005 40.10-03.35 5.59  +0.08 +0.11         A3IV               +0.015-0.016 +.016-023SB     73                  
+7304 43    SgrBD-19 5379 180540162413 722  D                191147.0-190751191738.1-185711 18.61-14.13 4.96  +1.02 +0.80         G8II-III           -0.012-0.014 +.006+015V    < 19:                *
+7305          BD+27 3313 180553 87005       12239           191155.1+271646191557.0+272720 60.14  7.23 6.54  -0.06 -0.59         B8V                +0.007-0.018D+.002-009SBO    50  0.4   0.9AB   4*
+7306  1    VulBD+21 3713 180554 870103540   12243  11866    191155.0+211249191613.0+212325 54.74  4.41 4.77  -0.05 -0.54 -0.07   B4IV                0.000-0.009 +.017-017SB1O  130  7.1  39.1AB   3*
+7307          BD+14 3852 180555104668       12248           191152.0+142203191626.8+143241 48.69  1.19 5.63  -0.02 -0.16         B9.5V              +0.010+0.009 +.021-019V?    147  3.8   8.2AB   4*
+7308          BD+27 3314 180583 87008              V473 Lyr 191158.9+274459191559.4+275537 60.56  7.44 6.16  +0.61 +0.34         F6Ib-II            +0.001+0.022      -016V      17                 *
+7309 54    DraBD+57 1968 180610 31497    I                  191208.0+573157191355.2+574218 88.52 19.81 4.99  +1.16 +1.17 +0.58   K2III              -0.010-0.070 +.025-027V    < 19:                 
+7310 57Del DraBD+67 1129 180711 18222 723I W                191231.9+672908191233.3+673942 98.65 23.00 3.07  +1.00 +0.78 +0.51   G9III              +0.094+0.093 +.032+025V    < 17  9.2  88.1      *
+7311          BD+49 2968 180756 48247       12240           191242.8+495339191519.3+500415 81.09 16.87 6.27R                     G8III              +0.005-0.003      +006V?         4.5   2.1AB   3*
+7312 59    DraBD+76  717 180777  93413536          11824    191250.3+762339190909.8+763338108.08 25.31 5.13  +0.31  0.00 +0.17   A9V                +0.047-0.123 +.049-004       63                 *
+7313          BD+01 3960 180782124478                       191245.1+015110191748.2+020154 37.76-04.93 6.19  +0.02 +0.01         A1Vn               -0.004-0.030      -023V?    215                 *
+7314 21The LyrBD+37 3398 180809 68065 724I W       11873    191253.8+375720191622.1+380801 69.90 11.86 4.36  +1.26 +1.23 +0.59   K0+II              -0.001+0.004 +.013-031V    < 19: 4.7 100.2AB   3 
+7315 25Ome1AqlBD+11 3790 180868104691 725                   191307.3+112454191749.0+113543 46.24-00.49 5.28  +0.20 +0.22         F0IV               +0.003+0.013 +.014-014V     113                  
+7316          CD-3513393 1808852111751501                   191302.4-353612191940.0-352517  2.76-20.69 5.59  -0.13 -0.56         B3V                +0.007-0.013      +002V     158:                *
+7317          BD-15 5310 180928162462    I W                191318.0-154238191900.1-153211 21.95-13.00 6.06  +1.43 +1.57 +0.83   K3III              -0.091-0.267 +.041-018V          5.5  48.6       
+7318  2    VulBD+22 3648 180968 87036       12287  ES Vul   191329.7+225043191743.6+230132 56.36  4.85 5.43  +0.02 -0.79         B0.5IV             +0.001-0.005D+.007+001V     332  4.7   1.8AB   3*
+7319 23    AqlBD+00 4168 180972124487    I  12289  11889    191327.2+005412191832.5+010507 37.00-05.53 5.10  +1.15 +1.01 +0.58   K2II-III          v+0.010+0.019 +.003-024V?   < 19: 4.1   3.1AB   3*
+7320          CP-68 3218 181019254551                       191339.6-683332192405.4-682216327.36-28.06 6.34  +1.23 +1.25         K2III              -0.026-0.003      -020                           
+7321 24    AqlBD+00 4170 181053124492      W                191344.0+000924191850.9+002021 36.37-05.94 6.41  +1.05 +0.79         K0-IIIa:Ba0.4CH1   +0.012+0.012 +.010-029V?         0.2 423.4AB   4 
+7322          BD+46 2658 181096 482783541                   191359.2+464840191651.4+465957 78.24 15.44 6.00  +0.44 -0.01         F6IV:              -0.008+0.295 +.018-044V?  =<  6                  
+7323          CD-3215071 181109211191    I                  191400.3-320007192026.2-314904  6.43-19.62 6.58  +1.67 +2.00         M0III              -0.004+0.004      -007                           
+7324          BD+30 3502 181119 68095                       191409.1+305025191800.8+310120 63.56  8.44 6.68  +0.08 +0.13         A3V                -0.004+0.020      -025                           
+7325          BD+09 4057 181122124497                       191406.5+092612191852.7+093705 44.61-01.64 6.32  +1.05 +0.89         G9III              +0.003-0.039      -012                          *
+7326          BD+19 3975 181182104711      W       U Sge    191425.7+192540191848.5+193638 53.44  3.05 6.58  +0.03 -0.38         B8III+K:           +0.022+0.002      -017SBO    76  3.0  92.0      *
+7327          BD-22 5063 181240187992                       191438.6-223519192038.1-222409 15.63-16.16 5.58  +0.27               F0III:             -0.015+0.035      -006       67                  
+7328  1Kap CygBD+53 2216 181276 31537 726I         11886    191447.5+531102191706.2+532207 84.40 17.85 3.77  +0.96 +0.74 +0.47   G9III              +0.059+0.125 +.024-029SB   < 17                  
+7329   Eta TelCP-54 9339 181296246055                       191447.0-543634192251.1-542525342.90-26.21 5.05  +0.02               A0Vn               +0.015-0.072 +.020+013      323                  
+7330          CD-3513422 181321211206                       191453.2-351002192129.9-345902  3.33-20.90 6.48  +0.63 +0.11         G5V                +0.106-0.099      -010                          *
+7331 28    AqlBD+12 3879 181333104722      W       V1208 Aql191459.3+121124191939.3+122229 47.14-00.52 5.53  +0.26 +0.18         F0III              +0.008+0.021 +.004+003V?     59  3.5  60.2AB   3*
+7332 29Ome2AqlBD+11 3802 181383104728                       191510.8+112058191953.0+113206 46.42-00.96 6.02  +0.08 +0.07         A2V                +0.042+0.026 +.001-026      160                  
+7333 26    AqlBD-05 4936 1813911432863544I W                191512.6-053610192032.9-052457 31.39-08.93 5.01  +0.92 +0.63 +0.50   G8III-IV           +0.116+0.048 +.030-019SB1O < 17  6.8 115.9      *
+7334          CD-4214133 181401229643                       191508.8-421209192209.6-420058356.15-23.18 6.34  +1.14               K1III              -0.050-0.034      +093                           
+7335          BD+33 3409 181409 68125                       191519.3+331221191903.8+332320 65.80  9.30 6.60  -0.19 -0.89         B2IVe             e-0.010-0.033      +010SB                        *
+7336 27    AqlBD-01 3716 181440143292                       191526.1-010442192035.7-005332 35.47-06.89 5.49  -0.04 -0.23         B9III              +0.006+0.006 +.008-027SB     77                  
+7337   Bet1SgrCD-4413277 1814542296461502  W                191527.0-443848192238.3-442732353.61-23.93 4.01  -0.10 -0.39         B9V                +0.009-0.020      -011       84  3.3  28.3      *
+7338          BD+37 3413 181470 68129                       191529.9+371539191901.2+372643 69.49 11.09 6.22R -0.03 -0.09         A0III              +0.014+0.017      -014SBO     5                 *
+7339          BD-19 5412 181558162511      W                191545.5-192517192137.1-191403 18.74-15.10 6.26  -0.10 -0.51         B5V                +0.007-0.001      -023           3.6  90.8AC   3*
+7340 44Rho1SgrBD-18 5322 181577162512      D       Rho1 Sgr 191552.4-180208192140.4-175050 20.06-14.55 3.93  +0.22 +0.13 +0.10   F0IV-V             -0.024+0.024 +.042+001       68  2.5   0.0      *
+7341          BD+49 2977 181597 48315                       191557.7+492302191837.7+493411 80.82 16.19 6.31  +1.12               K1III             v+0.010+0.054 +.003-014                          *
+7342 46Ups SgrBD-16 5283 181615162518 727I:D       Ups Sgr  191600.0-160834192143.6-155718 21.84-13.77 4.61  +0.10 -0.53 +0.13   B2Vpe+A2IaShell   v+0.002-0.006      +009SBO    58  1.0   0.0      *
+7343   Bet2SgrCD-4513171 181623229654                       191559.6-445916192313.2-444759353.28-24.11 4.29  +0.34 +0.07         F2III              +0.097-0.054 +.030+019      126                 *
+7344 45Rho2SgrBD-18 5325 181645162521                       191600.9-182938192150.9-181830 19.64-14.77 5.87  +1.06              gG9                 +0.102-0.092      -013SB                         
+7345          BD+37 3417 181655 68144                       191607.8+370900191938.9+371950 69.45 10.93 6.31  +0.68 +0.21         G8V                -0.066-0.187 +.038+002V?                         
+7346          BD+34 3503 181828 681643545  W                191654.0+345954192033.1+351110 67.57  9.82 6.31  -0.12 -0.51         B9V                +0.014+0.006      -018      125       45.0       
+7347          BD-08 4950 181858143321                       191655.0-082324192220.7-081204 29.07-10.57 6.31  -0.10 -0.40         B3IVp              -0.013-0.024      -010V?     67                  
+7348   Alp SgrCD-4013245 181869229659 728                   191657.5-404814192353.2-403658357.71-23.09 3.97  -0.10 -0.33         B8V                +0.030-0.123      -001SB     89                 *
+7349          BD-00 3725 1819071433243546                   191713.0-002630192221.5-001509 36.25-06.99 5.83  +1.09 +0.97        gG8                 +0.061-0.025      -011V?                         
+7350          CD-4313352 181925229660                       191713.4-435451192421.4-434323354.48-24.03 6.17  +1.60 +1.92         M1-2III            +0.024-0.037      -017V?                         
+7351          BD+54 2123 181960 31574                       191723.9+541123191936.5+542234 85.53 17.88 6.26  +0.03 +0.04         A1V                +0.018-0.025      -005      125                  
+7352 60Tau DraBD+73  857 181984  9366 729I         11898    191728.6+731012191533.0+732120104.73 24.21 4.45  +1.25 +1.45 +0.58   K2+IIIbCN1Fe1      -0.140+0.107 +.015-030SB   < 17                  
+7353          BD-07 4942 182038143340    I                  191740.4-073528192304.6-072401 29.88-10.38 6.32  +1.45 +1.69         K0                 +0.042-0.007      +012                           
+7354          BD+09 4081 1821011245643548                   191802.6+094307192248.4+095447 45.33-02.36 6.35  +0.44 -0.03         F6V                +0.011+0.109      -020       12                  
+7355          CD-2815767 182180188079                       191816.1-280333192430.1-275156 10.68-19.04 6.04  -0.13 -0.67         B2Vn               +0.004-0.001      +006V                         *
+7356          BD+57 1986 182190 31587    I                  191826.1+572721192016.1+573843 88.77 18.99 5.91  +1.58 +2.01         M1IIIab            +0.023+0.011      -021                           
+7357          BD+14 3896 182239104779                       191834.2+144344192308.2+145516 49.78-00.07 6.64  +0.27?              F1V                -0.027-0.009      +009V?     49                  
+7358  3    VulBD+25 3811 182255 87136              11966    191845.1+260413192250.9+261545 59.78  5.32 5.18  -0.12 -0.52 -0.16   B6III              -0.001-0.010      -012V      40                  
+7359          BD+33 3434 182272 68215                       191848.7+331937192233.4+333105 66.25  8.71 6.06  +1.03               K0III              +0.008-0.033      -016                           
+7360          CD-2916104 182286188093       12400           191846.1-293009192504.1-291833  9.30-19.67 5.93  +1.26               K3III              +0.002-0.051      +025V?         4.4  12.1      *
+7361          BD+64 1344 182308 18287      W                191859.9+641206191946.1+642327 95.51 21.33 6.52  -0.04 -0.47         B9IVpHgMn          -0.002+0.010      -020V?  =<  5  3.5 111.9       
+7362 47Chi1SgrCD-2415303 182369188101      W                191911.4-244210192516.5-243031 14.03-17.95 5.03  +0.23               Am                 +0.056-0.054 +.035-042       46  0.0   0.1      *
+7363 49Chi3SgrCD-2415307 182416188105    I         11992    191926.5-240930192529.7-235744 14.58-17.79 5.43  +1.43 +1.67         K4III              -0.014-0.005      +040V?                         
+7364          BD+19 4000 182422 87148                       191925.5+200412192346.9+201552 54.57  2.32 6.40  +0.01 -0.07         B9.5V              -0.007+0.008      -029       65                 *
+7365          BD+57 1993 182440 31604                       191936.0+573427192125.4+574601 88.95 18.89 6.43R                     K2                 +0.021+0.042      +007                           
+7366          BD-05 4964 182475143373                       191943.0-050450192501.6-045303 32.38-09.69 6.52  +0.33 +0.12         A9V                +0.054+0.015      -039V     105                  
+7367          BD-14 5428 1824771625953552I                  191942.6-140542192521.6-135349 24.14-13.70 5.69  +1.43 +1.35         K3III              +0.057+0.066      -034V?                         
+7368          BD+32 3411 182488 68239                       191947.6+330123192334.0+331320 66.07  8.38 6.37  +0.81 +0.46         G8V                +0.085+0.168 +.057-021V?                         
+7369  2    SgeBD+16 3839 182490104797      W                191952.6+164434192422.1+165616 51.70  0.63 6.25  +0.08 +0.04 +0.02   A2III-IV           -0.003-0.011      +012SBO    43  0.8 340.6      *
+7370          CP-54 9371 1825092461101504  W                191946.2-543129192748.1-541931343.15-26.90 5.69  +1.40 +1.68         K4III              -0.006+0.009      -005           2.7  72.9AB   4*
+7371 58Pi  DraBD+65 1345 182564 182993547                   192009.3+653119192040.1+654253 96.90 21.66 4.59  +0.02 +0.06 -0.03   A2III s            +0.012+0.045 +.020-029       27                 *
+7372  2    CygBD+29 3584 182568 871593550  W                192010.9+292532192407.6+293717 62.90  6.63 4.97  -0.10 -0.71 -0.14   B3IV               +0.013+0.013      -021V?    158                  
+7373 31    AqlBD+11 3833 1825721048071503  W       11994    192012.1+114349192458.2+115640 47.36-01.86 5.16  +0.77 +0.42         G8IVHdel 1         +0.722+0.643 +.059-100V    < 17  3.5 105.6AB   3*
+7374          BD+27 3379 182618 87165                       192021.6+275331192422.4+280516 61.56  5.87 6.53  -0.08 -0.55         B5V                -0.021+0.003      -020                           
+7375 50    SgrBD-22 5105 1826291881213553I                  192021.3-215829192619.2-214636 16.77-17.13 5.59  +1.22 +1.20         K3III              +0.040-0.005      -020                           
+7376          BD+36 3539 182635 68258                       192030.7+361515192406.1+362707 69.04  9.74 6.36R                     K1III              +0.010+0.077      -033                          *
+7377 30Del AqlBD+02 3879 182640124603 730I W       12004    192027.4+025455192529.9+030653 39.62-06.13 3.36  +0.32 +0.04 +0.16   F3IV               +0.257+0.082 +.072-030SB     85  7.5 108.9AB   3*
+7378          BD-15 5348 182645162609                       192029.7-151505192611.1-150311 23.15-14.37 5.72  +0.02 -0.34         B8Vn              t+0.023+0.010      -007V                         *
+7379          BD-14 5435 182678162615                       192044.2-144458192624.6-143304 23.64-14.21 6.70  +0.05               A1V                +0.039-0.006      -023       65                  
+7380          CD-2916140 182681188127 731                   192037.3-295627192656.5-294436  9.02-20.21 5.67   0.00 -0.10         B9V                +0.018-0.048      +001V?                         
+7381          BD+49 2994 182691 316233549                   192046.4+500432192323.8+501617 81.81 15.76 6.51  -0.08 -0.27         B9III               0.000+0.012      -024                           
+7382          BD+43 3229 182694 48401                       192046.8+431135192356.5+432317 75.39 12.82 5.84  +0.92 +0.63         G7III-IIIa         +0.017-0.025      -000V?                        *
+7383          CP-68 3251 1827092545903557                   192047.0-683815193110.9-682602327.32-28.72 5.96  +1.64 +1.93         K4-5III            +0.013-0.019      -014                           
+7384          BD+19 4009 182761 87186                       192100.9+200428192522.4+201617 54.75  2.00 6.31  -0.02 -0.08         A0V                -0.007-0.027      -032V     130                 *
+7385  4    VulBD+19 4010 182762104818    I  12425           192105.2+193609192528.6+194755 54.35  1.75 5.16  +0.98 +0.81 +0.51   K0III              +0.095-0.063 +.026-001V    < 19: 6.2  18.9AB   3*
+7386          BD+24 3737 182807 87190      W                192117.4+244356192525.8+245446 58.86  4.18 6.19  +0.51 -0.03         F7V                -0.175-0.630 +.027-004V   =<  6  4.4  40.1AB   5*
+7387 32Nu  AqlBD+00 4206 182835124628    I W       12021    192124.2+000821192631.1+002019 37.26-07.64 4.66  +0.60 +0.42 +0.46   F2Ib                0.000+0.001 -.008-001       13  4.2 201.0      *
+7388          CP-55 9096 182893246125                       192143.6-553837192952.6-552629341.97-27.37 6.13  +0.98 +0.81         K0-1III            +0.023-0.057      -027                           
+7389          BD+12 3907 182900104832                       192145.2+124921192624.1+130126 48.49-01.66 5.74  +0.47 +0.04         F6III              +0.010+0.062 +.032-034V      30                 *
+7390  5    VulBD+19 4015 182919104831                       192151.2+195357192613.2+200552 54.69  1.74 5.63  -0.01 -0.04         A0V                +0.003-0.035      -021SB    150                 *
+7391          BD+19 4017 1829551048391505I  12445           192206.1+194133192628.7+195329 54.54  1.59 5.81  +1.55 +1.99         M0III              -0.001-0.046      -034V          3.8 152.5AD   5*
+7392          CD-4313395 183007229712                       192217.3-433845192923.9-432645355.03-24.84 5.71  +0.22 -0.01         Am                 +0.096-0.136 +.013-031SB1O < 39                 *
+7393   Mu  TelCP-55 9100 183028246131                       192227.9-551854193034.5-550636342.35-27.42 6.30  +0.45               F5V                +0.033-0.015      +009V?                         
+7394   Lam UMiBD+88  112 183030  3020 914  W                192229.3+885916171656.8+890216121.94 27.51 6.38  +1.57 +1.79         M1III              -0.023-0.004      +002V?         7.5  54.7       
+7395  4    CygBD+36 3557 183056 683013554          V1741 Cyg192233.0+360702192609.1+361904 69.11  9.31 5.15  -0.12 -0.43         B9pSi              +0.005+0.014 -.007-022SBO    34                 *
+7396          BD+13 4020 1831441048623555          12049    192257.9+140449192733.9+141657 49.73-01.31 6.32  -0.06 -0.51         B4III              +0.009-0.002      +004                           
+7397          BD+02 3892 183227124661                       192319.5+024336192820.8+025549 39.79-06.85 5.85  +0.01 -0.39         B6III              +0.004-0.006      -014V?     48                  
+7398          CD-2714004 183275188192    I  12506           192341.0-271125192952.2-265908 12.00-19.83 5.52  +1.12 +1.35 +0.36E  K3III              +0.034-0.041 +.045-031           3.5   7.6      *
+7399          CD-3215233 183312211315                       192348.4-321749193014.7-320532  6.91-21.67 6.60  +0.39               F3IV-V             +0.083-0.065      +008                           
+7400 35    AqlBD+01 4010 183324124675                       192357.6+014446192901.0+015701 38.99-07.45 5.80  +0.08 +0.07         A0IVp              -0.003-0.033      +012V      73                 *
+7401          BD+57 1999 183339 316521507                   192358.2+574932192546.7+580138 89.43 18.45 6.60  -0.15 -0.56         B8IVHe wk          -0.004+0.008      -022                          *
+7402          BD-07 4968 183344143454       12503  U Aql    192358.4-071458192921.5-070238 30.91-11.62 6.61  +1.10 +0.70 +0.66   F7-G1I-II         v+0.024+0.003 +.013-007V          5.5   1.5AB   3*
+7403          BD+37 3465 183362 68346                       192405.5+374415192736.5+375628 70.71  9.79 6.34  -0.14 -0.74         B3Ve               +0.022-0.013      -028      244                 *
+7404          BD-00 3760 183387124681    I                  192410.8+000226192918.0+001446 37.50-08.30 6.25  +1.32 +1.38         K2                 +0.007-0.008      -060                           
+7405  6Alp VulBD+24 3759 183439 872611508I W       12069    192432.6+242744192842.3+243954 58.99  3.40 4.44  +1.50 +1.81 +0.97   M0III              -0.125-0.106 +.014-086V?         1.4 413.7      *
+7406  8    VulBD+24 3761 183491 87267                       192446.6+243344192857.0+244607 59.11  3.40 5.81  +1.03 +0.87         K0III               0.000+0.014 +.004-027V?                         
+7407          BD+14 3936 183492104896                       192446.5+142325192922.1+143545 50.21-01.55 5.56  +1.05 +0.91         K0III              +0.045-0.026      -040V?                         
+7408  7Iot1CygBD+52 2434 183534 31673                       192459.0+520700192725.9+521914 84.02 16.01 5.75   0.00 -0.01         A1V                -0.014-0.024      +002SB     54                  
+7409  7    VulBD+19 4039 183537 87269              Var      192459.0+200424192920.9+201647 55.20  1.18 6.33  -0.10 -0.52         B5Vn               +0.001-0.020      -037V                         *
+7410          BD-21 5410 183545188219                       192457.9-213112193054.0-211844 17.66-17.93 6.13  +0.12               A2                 +0.012-0.017      -021                           
+7411          CP-53 9585 183552246151                       192500.1-532346193253.8-531109344.56-27.45 5.75  +0.30 +0.20 +0.17   FmDel Del          +0.029-0.013      +014V                          
+7412          BD+02 3904 183589124698    I  12520  12088    192509.1+024147193010.5+025415 39.98-07.26 6.09  +1.82 +2.03         K5Ib               -0.005 0.000      -013V?         4.9  34.1AB   4*
+7413          BD+62 1716 183611 183433556                   192517.1+622108192626.5+623326 93.93 20.02 6.38  +1.39 +1.71         K5III              +0.034+0.043      -040                           
+7414 36    AqlBD-03 4612 1836301434821509I         12093    192526.0-025950193039.8-024720 34.93-10.00 5.03  +1.75 +2.05         M1III             v+0.023-0.010 +.029-011V?                         
+7415          BD+03 4043 183656124704              V923 Aql 192532.8+031408193033.1+032640 40.50-07.09 6.05  +0.01 -0.37         A0eShell           +0.010+0.005      -026V     180                 *
+7416          CD-4513296 1838062297413558          PW Tel   192609.2-452901193321.6-451619353.26-25.97 5.61  -0.04               ApCrEuSr           -0.012-0.031      -008                          *
+7417  6Bet1CygBD+27 3410 183912 87301 732I  12540A 12105    192641.3+274458193043.3+275735 62.11  4.57 3.08  +1.13 +0.62 +0.66   K3II+B9.5V         +0.002-0.002 +.017-024V   =< 25  2.0  34.7AB   3*
+7418  6Bet2CygBD+27 3411 183914 87302       12540B          192643.4+274518193045.3+275755 62.12  4.57 5.11  -0.10 -0.32         B8Ve               -0.009 0.000 +.017-018V     250  2.0  34.7AB   3*
+7419          BD+35 3658 183986 68417       12545           192709.7+360105193046.9+361343 69.46  8.44 6.25  -0.04 -0.11         B9.5III            +0.006-0.011 +.005+011V      65  7.7  27.7AB   3 
+7420 10Iot2CygBD+51 2605 184006 31702 733                   192711.0+513100192942.3+514347 83.61 15.45 3.79  +0.14 +0.11 +0.07   A5Vn               +0.020+0.130 +.005-020V?    226                  
+7421          BD+26 3573 184010 87314                       192715.8+262418193121.8+263702 60.99  3.81 5.87  +0.93 +0.63         K0III-IV           +0.032+0.027      -001V?                         
+7422          CD-4013356 1840352297463560          V4089 Sgr192717.0-401458193408.5-400205358.92-24.81 5.89  +0.09               A3III              +0.005-0.005      +012SB1O   53                 *
+7423          BD+79  628 184102  9414 734                   192744.8+792409192140.2+793610111.52 25.30 6.05  +0.07 +0.06         A3V                +0.013-0.034      -003SB                         
+7424   Iot TelCD-4813161 184127229751 735                   192747.9-481853193513.0-480557350.25-26.89 4.90  +1.09               K0III              -0.009-0.038 +.002+022                           
+7425          BD+83  552 184146  32093962  W                192757.0+831606191507.8+832746115.68 26.27 6.53  +0.10 +0.10         A3V                +0.008+0.012      -014      105  3.7  25.0       
+7426  8    CygBD+34 3590 184171 684471510                   192803.3+341425193146.3+342711 67.97  7.44 4.74  -0.14 -0.65 -0.16   B3IV               +0.001-0.003      -022V?     18                  
+7427          BD+49 3034 184293 31737    I                  192840.4+500532193119.3+501824 82.38 14.62 5.53  +1.25       +0.65  gK1                 -0.029+0.048      -009V?                         
+7428          BD+55 2215 184398 31741              V1817 Cyg192906.6+553108193113.6+554355 87.51 16.87 6.37  +1.16 +0.91         K2II-IIIe+A0V     v-0.002-0.011      -006SBO =< 50                 *
+7429 38Mu  AqlBD+07 4132 1844061247991511I  12607  12155    192912.2+071000193405.4+072244 44.41-06.01 4.45  +1.17 +1.26 +0.61   K3-IIIbCN0.5       +0.216-0.157 +.045-024V?   < 19: 5.0 177.5AE   6*
+7430 37    AqlBD-10 5122 1844921627923562I                  192936.6-104644193507.3-103337 28.30-14.44 5.12  +1.13 +0.89         G9IIIa             +0.009+0.003 +.007-031                           
+7431 51    SgrCD-2415442 184552188326              12183    192957.4-245618193601.7-244309 14.79-20.30 5.65  +0.19 +0.17 +0.07   A7m                +0.012-0.023 +.018-031SBO    16  2.0   0.0      *
+7432          BD-07 4998 184573143564                       193005.9-074043193529.8-072737 31.22-13.17 6.34  +1.12 +0.92         K0                 +0.030-0.039      -010                           
+7433          BD-12 5461 184574162797                       192959.2-122818193533.6-121510 26.77-15.26 6.27  +1.09               K0                 +0.015-0.006      +006V?                         
+7434          CP-58 7627 1845852461883566                   193001.4-581215193825.9-575900339.28-28.86 6.18  +0.97 +0.81         K0III              +0.026-0.065 +.015-011                           
+7435          CP-66 3445 1845862546223567  W                192958.8-665430193952.1-664108329.34-29.51 6.39  +0.02 +0.04         A1V                +0.032-0.043      -014           6.1  19.7       
+7436          BD+38 3650 184603 68499      S                193007.4+383239193336.4+384544 72.00  9.12 6.61  +0.03 +0.10         A3Vn               +0.005+0.028      -017                 0.1       
+7437  9    VulBD+19 4063 184606104990       12622  12173    193011.3+193318193434.9+194624 55.35-00.14 5.00  -0.09 -0.43 -0.09   B8IIIn             +0.008+0.002      +005V     235  7.8 108.3AC   3 
+7438          BD+02 3932 184663124823                       193023.7+024133193525.2+025448 40.60-08.42 6.38  +0.41 -0.02         F6IV               +0.019+0.045      +004       40                  
+7439          BD-19 5521 184705162809                       193036.3-190425193626.1-185110 20.57-18.16 6.11  +0.27?              F0III              +0.031-0.003      -042                           
+7440 52    SgrCD-2514184 184707188337 736   12654  12191    193037.3-250616193642.4-245301 14.68-20.51 4.60  -0.07 -0.15 -0.06   B9                 +0.069-0.021D+.002-019V      68  4.5   2.7      *
+7441  9    CygBD+29 3651 184759 87385      W                193052.5+291434193450.9+292747 63.87  4.50 5.38  +0.55 +0.33         F8III+A0V          +0.015+0.024 +.021-011SB1O=< 50  0.5   0.1      *
+7442          BD+48 2914 184786 48589    I         V1743 Cyg193056.3+490240193341.6+491545 81.58 13.83 5.96  +1.64 +1.77         M4.5IIIaS          +0.005-0.003      -010V?                        *
+7443          BD-18 5432 1848351628163565                   193115.2-182711193703.3-181352 21.23-18.05 5.64  +1.26 +1.08         K3III              +0.013-0.009 +.010-007V                          
+7444          BD+42 3386 184875 48601                       193125.5+421136193441.2+422446 75.38 10.62 5.35  +0.05 +0.09         A2V                -0.004-0.022 +.001+002       87                  
+7445          BD+10 3981 184884105032       12660           193124.5+105544193608.0+110900 47.98-04.65 6.68                      A3V                -0.004-0.010      -005           6.4   3.8       
+7446 39Kap AqlBD-07 5006 184915143600 737I'        12204    193130.7-071500193653.5-070139 31.77-13.29 4.95   0.00 -0.87 -0.04   B0.5III            +0.003-0.004      -019V     259                 *
+7447 41Iot AqlBD-01 3782 184930143597       12663  12201    193132.9-013030193643.3-011711 36.99-10.66 4.36  -0.08 -0.44 -0.08   B5III              +0.004-0.018 +.004-021V      95  8.9  47.0      *
+7448          BD+59 2060 184936 183953563I W                193135.9+595624193310.1+600931 91.89 18.38 6.29  +1.57 +1.98         K4III              +0.005+0.006      -019           2.0  76.2      *
+7449          BD+14 3974 184944105036                       193139.4+141013193615.8+142330 50.84-03.11 6.38  +1.04 +0.89         K0II-III           +0.034-0.023      -042                           
+7450          BD+70 1073 184958  94473561I                  193148.3+704619193100.2+705922102.62 22.41 6.07  +1.41               K2                 -0.016+0.037      -043                           
+7451          BD+50 2815 184960 31782                       193144.4+510119193419.8+511412 83.46 14.59 5.73  +0.48  0.00 +0.28   F7V                +0.032-0.190 +.037+000V?      6                 *
+7452          BD+22 3741 184961 874263564          12199    193151.6+222150193608.3+223509 57.99  0.91 6.32  -0.07 -0.28         B9pSi:Cr:          +0.001-0.010      -023       50                 *
+7453          BD+47 2870 184977 48606                       193149.2+475647193439.9+480953 80.64 13.21 6.67R +0.24?              A9V                -0.015-0.073      -001                           
+7454          BD-14 5479 184985162827                       193156.3-143117193734.4-141806 25.05-16.56 5.47  +0.50 +0.04         F5V                -0.105-0.142 +.047-021SB                        *
+7455          CP-66 3447 184996254627                       193156.2-660450194137.5-655115330.29-29.68 6.09  +1.55 +1.96         M0III              +0.027-0.065      -042                           
+7456          BD+10 3984 185018105045       12670           193209.1+110300193652.5+111624 48.18-04.75 5.98  +0.88               G0Ib               +0.018+0.005      -001           5.7  80. AD   5 
+7457 11    CygBD+36 3619 185037 68552                       193212.6+364321193548.3+365640 70.58  7.89 6.05  -0.11 -0.37         B8Vne              +0.008-0.002      -015V     400:                *
+7458          BD+20 4200 185059 87447              U Vul    193215.4+200636193637.7+201958 56.07-00.29 7.14  +1.32 +1.00         F2-F8Iab           -0.003-0.011 -.013-011V                         *
+7459          CP-54 9438 185075246204                       193219.1-543841194018.3-542503343.36-28.71 6.26  +1.00               K0III              +0.038-0.009      +015                           
+7460 42    AqlBD-04 4861 185124143621                       193229.0-045215193747.3-043851 34.06-12.42 5.46  +0.43 +0.03         F3IV               +0.107-0.051 +.027-038V?                         
+7461          CD-4513354 185139229800              QQ Tel   193230.8-453019193942.0-451641353.53-27.06 6.25  +0.28               F2IV               -0.001+0.020      +008                          *
+7462 61Sig DraBD+69 1053 185144 18396    I W       12176    193233.2+692928193221.6+693940101.32 21.89 4.68  +0.79 +0.38 +0.41   K0V                +0.600-1.738 +.177+027V    < 17      315.6      *
+7463  4Eps SgeBD+16 3918 185194105061       12693  12213    193245.7+161417193717.4+162746 52.77-02.32 5.66  +1.02 +0.81         G8III             v+0.020+0.015      -033V?         2.7  88.9AB   4*
+7464          CD-3913371 185257211451              V4090 Sgr193307.0-393933193955.7-392600359.88-25.72 6.61  +0.23               A2m                +0.062-0.061      -036V                         *
+7465          BD+49 3059 185264 31804                       193315.1+500051193555.9+501419 82.65 13.93 6.52  +1.06 +0.84         G9III              -0.005+0.038      +008V?                         
+7466          BD+29 3670 185268 87462       12696           193310.6+290633193709.4+292001 64.00  3.99 6.43  -0.09 -0.50         B5V                -0.016-0.001      -020      300  2.7  20.6AB   8*
+7467          BD+38 3677 185330 68585                       193325.7+380933193656.6+382302 71.97  8.37 6.50  -0.15 -0.61         B5II-III            0.000 0.000      -027                          *
+7468          BD+44 3185 185351 48649                       193332.0+442824193637.9+444142 77.62 11.35 5.17  +0.93 +0.69         G9IIIbFe-0.5       -0.101-0.102 +.019-005     < 19:                 
+7469 13The CygBD+49 3062 185395 31815 738I: 12695           193345.5+495922193626.5+501316 82.66 13.85 4.48  +0.38 -0.03 +0.21   F4V                -0.017+0.257 +.056-028        7  6.9  48.4AC   3*
+7470 53    SgrCD-2315618 185404188407       12741           193348.9-233918193949.4-232540 16.41-20.64 6.34  +0.03               B9.5V+A3IV         +0.001-0.032      -011           0.2   0.2      *
+7471          BD+03 4097 1854231248923569                   193348.5+030916193849.0+032254 41.43-08.94 6.35  +0.04 -0.55         B3III              +0.004 0.000      -001SB                         
+7472          BD+20 4210 185436 87489                       193356.5+203327193817.5+204658 56.66-00.41 6.48  +1.08 +0.98         K0III              -0.055-0.048      +005                           
+7473          CD-2315625 185467188419                       193406.5-233928194007.1-232543 16.43-20.70 5.97  +1.04              gK1                 +0.026+0.002      -028V?                         
+7474 44Sig AqlBD+05 4225 185507124903       12737  Sig Aql  193415.5+051011193911.6+052352 43.27-08.07 5.17  +0.03 -0.60         B3V+B3V           v+0.001-0.001      -005SBO   121  6.6  47.8AB   3*
+7475          BD+16 3936 185622105104    I  12750           193453.9+162032193925.4+163417 53.12-02.71 6.38  +2.07 +2.22         K4Ib               +0.011+0.003      -004SB         2.7  31.8      *
+7476 54    SgrBD-16 5399 1856441628831512I  12767A 12275    193459.7-163121194043.4-161736 23.47-18.07 6.2   +1.13 +1.06         K2III+F8V          +0.071-0.048 +.037-058V?         0.0   0.1     4*
+7477          BD+48 2922 185657 48673      W                193510.1+490310193756.7+491704 81.91 13.22 6.47  +0.99 +0.72         G6V                +0.036+0.144 +.006-085V          2.9  29.6AB   4*
+7478 12Phi CygBD+29 3684 185734 686373570I S                193525.6+295522193922.6+300912 64.95  3.97 4.69  +0.97 +0.80 +0.47   G8III-IV           +0.004+0.037 +.007+006SB2O             0.0      *
+7479  5Alp SgeBD+17 4042 185758105120    I  12766           193537.5+174702194005.8+180050 54.45-02.14 4.37  +0.78 +0.43 +0.37   G1II               +0.014-0.021 +.000+002V?      0  6.8  90. AD   4*
+7480 45    AqlBD-00 3813 1857621436783573   12775           193534.2-005111194043.3-003716 38.06-11.24 5.67  +0.11 +0.09         A3IV               +0.017+0.017 +.018-046       96  7.2  42.0     3*
+7481          BD+33 3547 185837 68654       12765           193559.1+334453193945.0+335845 68.34  5.76 6.10  +0.08 +0.13         A3IV               +0.007+0.017      -033       80  4.5   1.3AB   3*
+7482          BD+20 4218 185859 87542                       193606.0+201444194028.3+202836 56.64-01.00 6.50  +0.39 -0.62         B0.5Iae            -0.002-0.022      +005                          *
+7483 14    CygBD+42 3413 185872 486913572                   193611.1+423513193926.5+424906 76.16 10.03 5.40  -0.08 -0.22         B9III              +0.022+0.031 +.019-028SB     45                  
+7484          BD+54 2193 185912 318503571          V1143 Cyg193626.2+544422193841.2+545826 87.25 15.59 5.82  +0.44 -0.10         F6Va               +0.035+0.164 +.036-015SBO                       *
+7485          BD+23 3733 185915 87551       12778           193625.2+232910194039.7+234303 59.48  0.56 6.64  +0.01 -0.39         B6IV               +0.019-0.020      -020SB         1.5 118.4AC   3*
+7486          BD+13 4098 1859361051323574  W       QS Aql   193627.7+133500194105.5+134856 50.91-04.41 6.01  -0.08 -0.52         B5V                -0.002-0.010      -014SBO    58  0.2   0.1      *
+7487          BD+45 2940 185955 48697                       193632.2+454332193934.4+455729 79.00 11.47 6.20  +0.90 +0.55         G8-K0II-III        -0.005+0.046      -010V?                         
+7488  6Bet SgeBD+17 4048 1859581051331513I                  193633.4+171439194102.9+172834 54.10-02.60 4.37  +1.05 +0.89 +0.50   G8IIIaCN0.5        +0.010-0.032 +.011-022     < 19:                *
+7489 55    SgrBD-16 5413 1860051629151514  W                193647.9-162130194231.1-160726 23.82-18.40 5.06  +0.33 +0.09         F1III              +0.068-0.009 +.040-027SB    134  0.0   0.2      *
+7490          BD+22 3767 186021 87569                       193657.1+221310194114.9+222710 58.45-00.18 6.36  +1.53               K0I                +0.025-0.004      -023                           
+7491          CD-3713322 1860422115063576                   193656.7-374627194337.6-373220  2.12-25.92 6.16  +0.01               B8                 +0.006-0.019      -029V?                         
+7492          BD+42 3419 186121 48714    I                  193726.7+425040194041.2+430440 76.50  9.95 6.16  +1.56 +1.42 +1.01E  M2III              +0.012-0.006      -005V?                         
+7493 46    AqlBD+11 3954 186122105156                       193731.3+115730194212.8+121136 49.62-05.44 6.34  -0.03 -0.41         B9IIIpHgMn         -0.002-0.004      -032        5                  
+7494          CP-81  868 1861542588441667                   193736.9-813601195601.5-812059312.46-29.21 6.39  +1.40 +1.68         K3-4III            +0.009-0.001      -006                           
+7495          BD+45 2949 186155 487183575  W       12300    193745.0+451716194050.2+453130 78.71 11.07 5.06  +0.40 +0.15         F5II-III           +0.086+0.127 +.021-020V      42  6.7  88.0       
+7496          BD-15 5444 186185162931      W                193751.3-154207194333.5-152812 24.55-18.36 5.49  +0.46 +0.02         F5IV               +0.154-0.180 +.045+013V      21  6.2  70.4      *
+7497 47Chi AqlBD+11 3955 186203105168       12808  12325    193751.6+113528194234.0+114936 49.34-05.70 5.27  +0.57 -0.04         G0:III+A3V         -0.001-0.007 +.006-022SB      0  1.2   0.4AB   5*
+7498          CP-72 2445 1862192577363580                   193753.5-724450194925.3-723012322.60-30.12 5.41  +0.22 +0.11 +0.13C  A4III               0.000+0.017 +.033-001SB    104                 *
+7499          BD+39 3878 186307 48737      W                193832.3+400103194157.5+401514 74.10  8.40 6.23  +0.18 +0.05         A6V                -0.025+0.026 +.006-032      110  1.3   0.2       
+7500          BD+60 1991 186340 18461       12789           193839.1+601624194013.0+603026 92.59 17.72 6.51  +0.22?              A5V                -0.008-0.005D+.026-001      135  2.2  18.3       
+7501          BD+28 3447 186357 87612              V1276 Cyg193848.8+290536194249.1+291954 64.60  2.92 6.49  +0.33 +0.28         F1III              +0.061+0.047      -025       84                 *
+7502          BD+32 3531 186377 687303577                   193853.6+321123194244.6+322536 67.29  4.46 5.94  +0.11 +0.14         A5III              +0.004+0.003      -007       27                  
+7503 16    CygBD+50 2847 186408 31898       12815A          193909.4+501735194148.9+503131 83.34 13.21 5.96  +0.64 +0.19 +0.33   G1.5Vb             -0.149-0.153 +.039-026V       2  0.2  39.2AB   3*
+7504          BD+50 2848 186427 31899       12815B          193912.2+501708194152.0+503103 83.34 13.20 6.20  +0.66 +0.20 +0.34   G2.5V              -0.134-0.162 +.039-027V       3  0.2  39.2AB   3*
+7505          BD+30 3706 186440 68744                       193913.5+302623194309.5+304043 65.81  3.52 6.05   0.00 -0.01         A1V                -0.012+0.038      -028      155                  
+7506 10    VulBD+25 3933 186486 876331515                   193933.4+253157194342.9+254619 61.61  0.98 5.49  +0.93 +0.67 +0.47   G8III              +0.012+0.019 +.023-009     < 17                  
+7507          CD-3215443 1865002115411516                   193938.4-320859194601.2-315431  8.25-24.79 5.52  +0.02               B8V                +0.005-0.017      -031                           
+7508          BD+26 3654 186518 87640    I  12850  PS Vul   193950.1+265346194355.9+270808 62.82  1.61 6.28  +1.10               B7V+G1:III         -0.009+0.004 -.008-012V          1.5   0.4      *
+7509          BD+55 2245 186532 31906    I         V1351 Cyg193951.4+551337194204.1+552748 87.93 15.37 6.48  +1.61               M5IIIa             +0.013-0.039      -028V?                        *
+7510   Nu  TelCP-56 9290 186543246271 739                   193951.3-563610194801.2-562145341.27-30.01 5.35  +0.20               A7III-IV           +0.088-0.137      -012V                          
+7511 48Psi AqlBD+12 4059 186547105199                       193955.0+130346194434.1+131810 50.88-05.40 6.26  -0.03 -0.21         B9III-IV           -0.007-0.006      -018SB     35                 *
+7512          BD+33 3572 186568 68764       12852           194005.5+335522194351.4+340945 68.92  5.11 6.05  -0.06 -0.30         B8III              -0.002+0.003      -011       15  7.3  33.9AC   3 
+7513          CP-67 3680 186584254658                       194004.5-670335194953.3-664846329.18-30.50 6.45  +1.48 +1.72         K4III              -0.012+0.016      -002                           
+7514          BD+41 3469 186619 48771    I                  194024.8+413158194345.0+414623 75.61  8.83 5.84  +1.57 +1.99         M0IIIab            +0.016+0.010 +.014-041                           
+7515 56    SgrBD-20 5698 1866481629641517I                  194031.7-200006194621.7-194540 20.65-20.67 4.86  +0.93 +0.96         K1III              -0.129-0.089 +.025+020V                          
+7516          BD-03 4701 1866601437763579                   194038.5-030733194552.2-025300 36.61-13.42 6.48  +0.05 -0.54         B3III              +0.005-0.002      -017                           
+7517 15    CygBD+37 3586 186675 68778 740I                  194040.1+370645194416.6+372116 71.76  6.60 4.89  +0.95 +0.69         G7+III             +0.075+0.035 +.021-024     < 19:                 
+7518          BD+28 3460 186688 87659              SU   Cyg 194048.4+290123194448.7+291553 64.76  2.51 6.82  +0.64 +0.20 +0.39   F2I               v+0.001-0.002 -.010-036V                         *
+7519 49Ups AqlBD+07 4210 186689125032                       194048.0+072215194539.9+073648 46.01-08.42 5.91  +0.18 +0.09         A3IV               +0.053+0.002 +.027-030       30                  
+7520          BD+34 3691 186702 68783    I         12372    194052.8+341022194438.2+342450 69.22  5.10 6.57R                     M1III              +0.004-0.009      +009                           
+7521          CP-53 9678 1867562462773581                   194108.4-530759194855.1-525317345.27-29.79 6.25  +1.13 +1.11         K1III              +0.009-0.050      -021                           
+7522          BD+57 2057 186760 31923                       194117.6+574640194314.6+580059 90.39 16.33 6.22  +0.56 +0.06         G0V                +0.137-0.060 +.045-022    =< 10                  
+7523          BD+40 3866 186776 48789    I         V973 Cyg 194125.3+402831194449.0+404300 74.77  8.15 6.34  +1.64 +1.94 +0.92E  M4-III             -0.064-0.023      -097                          *
+7524          CP-65 3827 186786254669              NZ Pav   194127.1-655059195101.3-653618330.58-30.65 6.05  +0.30 +0.08         F2III-IV           +0.101-0.155      -041                          *
+7525 50Gam AqlBD+10 4043 186791105223 741I W                194130.3+102210194615.6+103648 48.73-07.08 2.72  +1.52 +1.68 +0.75   K3II              e+0.018-0.002 +.016-002V    < 17  8.0 132.6      *
+7526          BD+56 2291 186815 31933                       194137.0+564803194339.6+570233 89.50 15.86 6.27  +0.88               K2III              +0.010+0.020      -026                           
+7527          CP-61 6413 186837254666                       194136.8-611835195021.7-610341335.85-30.57 6.21  -0.14 -0.55         B5V                -0.006-0.001      -015                          *
+7528 18Del CygBD+44 3234 186882 48796    I  12880  12380/1  194150.9+445312194458.5+450751 78.71 10.24 2.87  -0.03 -0.10 -0.02   B9.5IV+F1V         +0.053+0.047 +.030-020SB    149  3.5   2.0AB   3*
+7529          BD+35 3786 186901 68805       12893A          194159.4+355049194539.6+360528 70.79  5.74 6.43  -0.03 -0.13         B9.5VpSi           +0.004+0.014D+.018-019       35  0.5  14.8AB   6*
+7530          BD+34 3701 186927 68810       12900           194207.6+344608194551.4+350046 69.87  5.17 6.09  +1.06 +1.00         K0II-III+A2V       +0.021-0.004      -019           2.4  44.6AC   3*
+7531          CP-59 7534 186957246293      W                194215.7-592635195044.8-591135338.02-30.55 5.42  +0.08               A0IV               +0.015+0.004 +.013+004       50  1.5   0.5      *
+7532          BD-14 5555 186984162998                       194225.9-135659194803.0-134212 26.72-18.63 6.11  +0.20 +0.13 +0.08   A6m                +0.026-0.012      -008       75                  
+7533          BD+24 3877 186998 87706                       194227.5+245319194639.5+250802 61.39  0.08 6.62  +0.27               A7IV               +0.073-0.004      +013SB                         
+7534 17    CygBD+33 3587 187013 68827       12913A 12398    194237.8+332941194625.6+334340 68.81  4.44 4.99  +0.47  0.00         F7V                +0.023-0.446 +.049+005V?      9  3.5  26.0AB   3*
+7535          BD+32 3558 187038 68835       12920           194245.1+323835194635.0+325319 68.10  3.99 6.18  +1.13               K3III              -0.032-0.003D+.016-046           2.1  30.7AD   4*
+7536  7Del SgeBD+18 4240 187076105259 743I W       Del Sge  194255.7+181715194723.3+183203 55.77-03.38 3.82  +1.41 +0.96 +1.29   M2II+A0V           +0.007+0.008 +.001+003SBO =< 50                 *
+7537          CD-4713103 187086229887              12432    194255.3-474825195013.8-473326351.37-29.27 5.94  +1.70 +1.97         M1III              -0.017-0.008      -065V                         *
+7538          CD-2916546 1870981886033582   12956           194257.2-290205194911.6-284720 11.75-24.46 6.05  +0.40               F2V                +0.126-0.096      -034                          *
+7539 NOVA 1670                                     CK Vul   0 0 0      0 0 0 0 0      0 0                                                                                                           *
+7540          BD+25 3972 187193 87729                       194337.1+250813194748.6+252302 61.74-00.02 5.95  +0.99               K0II-III           +0.082-0.026      -018                           
+7541          BD-11 5131 187195163012                       194331.3-110710194902.2-105215 29.53-17.66 6.04  +1.24 +1.36         K5III              +0.036-0.020      -033V                          
+7542          BD+10 4058 187203105278                       194345.4+102644194830.4+104139 49.07-07.52 6.44  +0.96 +0.69         F8Ib-II            -0.007-0.001      -005       28                  
+7543          BD+38 3758 187235 68859       12944           194354.8+380936194727.8+382427 72.99  6.57 5.77  -0.06 -0.37         B8Vn               +0.015-0.003      -028      350  7.2  24.7       
+7544 52Pi  AqlBD+11 3994 187259105282       12962  12425    194359.3+113401194842.1+114857 50.08-07.01 5.72                      G2III:+A1V:        +0.018-0.004D+.003+013V?         0.5   1.4AB   3*
+7545          BD+68 1079 187340 18508                       194427.0+690534194418.5+692013101.37 20.78 5.92  +0.05 +0.11         A2III              +0.016-0.023      +000                          *
+7546  8Zet SgeBD+18 4254 187362105298       12973           194432.3+185328194858.7+190832 56.48-03.40 5.00  +0.10 +0.05 +0.06   A3V                +0.021+0.030 +.010-014V     225  0.5   0.2AB   4*
+7547          BD+47 2916 187372 48842    I                  194431.4+473936194726.8+475428 81.40 11.19 6.12  +1.64 +1.99         M2III              -0.026-0.031      +003SB                         
+7548          CP-55 9221 187420246311      W     A          194439.6-551331195237.6-545816342.94-30.54 5.74  +0.92 +0.65         G8-K0III           +0.008-0.002      -018           0.7  22.9      *
+7549          CP-55 9222 187421246312      W     B          194441.0-551351195239.0-545836342.93-30.55 6.50  +0.10 +0.12         A2V                +0.008-0.003      -022           0.7  22.9      *
+7550          BD+34 3727 187458 68893       12972           194459.9+350334194843.9+351841 70.42  4.81 6.53  +0.44 -0.09         F4V                +0.085+0.062 +.017-027V          0.6   0.6      *
+7551          BD+33 3602 187459 68895              V1765 Cyg194501.6+331113194850.6+332614 68.81  3.85 6.44  +0.20 -0.74         B0.5Ib             +0.007-0.002      -010SB2O  126:                *
+7552          CD-4013514 1874742299033583          V3961 Sgr194503.2-400740195150.6-395228  0.03-28.05 5.33  -0.06 -0.22         A0pCrSr:          v+0.023-0.015 +.020-002SB      6                 *
+7553 51    AqlBD-11 5149 187532163036 744   13017           194516.7-110102195046.8-104549 29.83-18.00 5.39  +0.38               F0V                -0.030+0.033      +006V?     67  8.0  21.1      *
+7554          BD+07 4252 187567125116      S       V1339 Aql194526.3+073900195017.5+075409 46.83-09.28 6.51  -0.10 -0.70         B2.5IVe            +0.005+0.001      -030                 0.1      *
+7555          BD+38 3772 187638 68909       12992           194555.1+382730194927.5+384236 73.45  6.39 6.11  +0.90               G5-8III            +0.006-0.010      +011V?         4.9  11.6AB   3 
+7556          BD+28 3493 187640 87786              12454    194551.5+281114194954.6+282626 64.61  1.13 6.38  -0.06 -0.50         B5V                -0.021+0.027      -012SB     75                  
+7557 53Alp AqlBD+08 4236 187642125122 745I  13009           194554.2+083615195047.0+085206 47.74-08.91 0.77  +0.22 +0.08 +0.14   A7V                +0.538+0.386 +.198-026      242  8.6 165.2AB   3*
+7558          CP-61 6426 1876532546831518                   194556.7-612544195440.4-611015335.74-31.09 6.24  +0.16               A4V                -0.008+0.011      +011                           
+7559          BD-02 5133 187660143853    I                  194558.4-024250195111.1-022739 37.62-14.40 6.13  +1.57 +1.82         K5III              -0.007-0.035      +009                           
+7560 54Omi AqlBD+10 4073 187691105338       13012           194614.2+100955195101.6+102456 49.14-08.19 5.11  +0.55 +0.07 +0.29   F8V                +0.242-0.139 +.048-000V   =<  6  8.3  14.4AB   3*
+7561 57    SgrBD-19 5631 187739163060                       194623.3-191756195212.0-190242 21.92-21.67 5.92  +0.98 +0.64?        G5III              +0.002-0.058 +.021-026SB                         
+7562          BD+09 4288 187753125139                       194630.1+092233195117.7+093749 48.48-08.64 6.25  +0.10 +0.09 +0.06   A1m                -0.001-0.012      +021       10                  
+7563          BD+68 1082 187764 18530              CN Dra   194637.5+681117194644.7+682618100.58 20.24 6.34  +0.28 +0.09         F0III              +0.005+0.011      -012       98                 *
+7564   Chi CygBD+32 3593 187796 68943    I W       Chi Cyg  194643.2+323940195033.9+325451 68.54  3.28 4.23  +1.82 +0.96 +2.68   S6+/1e            v-0.027-0.040 +.012-002V?         5.2 158.0      *
+7565 12    VulBD+22 3833 187811 878133585          Var      194645.7+222120195104.1+223636 59.72-02.07 4.95  -0.14 -0.68 -0.14   B2.5Ve            v+0.028-0.017      -031SB?   281                 *
+7566 19    CygBD+38 3780 187849 68947    I  13014  V1509 Cyg194701.3+382754195034.0+384321 73.57  6.20 5.12  +1.69 +2.10 +0.93E  M2IIIa             +0.011+0.107 +.000-039V?         6.4  55.5AB   3*
+7567          BD+40 3902 187879 488923584          V380 Cyg 194711.3+402043195037.3+403559 75.22  7.13 5.69  -0.04 -0.77         B1III+B3V          +0.001-0.004      -004SBO    79                 *
+7568          BD+37 3636 187880 68953    I                  194711.2+373417195047.0+374935 72.81  5.72 6.06  +1.70 +1.85         M4IIb              +0.024+0.007 +.005-016V?                         
+7569          BD+11 4019 187923105348      W       12490    194722.5+112252195203.5+113744 50.33-07.82 6.13  +0.65 +0.13         G0V                -0.335-0.320 +.022-017V   =< 10  5.5  90.5       
+7570 55Eta AqlBD+00 4337 187929125159 746I         Eta Aql  194722.7+004456195228.4+010020 40.93-13.07 3.90  +0.89 +0.51 +0.47   F6Ib              v+0.011-0.007 +.010-015SB      0                 *
+7571          BD-14 5578 187949163080      S       V505 Sgr 194727.8-145134195306.4-143611 26.38-20.12 6.48  +0.14 +0.09         A0V+F8IV           -0.004-0.042      -002SBO    97        0.3      *
+7572          BD+09 4295 187961105355       13041  12496    194729.5+100542195215.6+102105 49.23-08.49 6.54  -0.01 -0.38         B7V                +0.004-0.015      -013      300  4.0  13.5AB   4*
+7573          BD+24 3914 187982 878403587          12498    194749.1+244407195201.6+245932 61.88-01.04 5.57  +0.71 +0.13         A1Ia               +0.003-0.005 +.006-003SBO                       *
+7574  9    SgeBD+18 4276 188001105360              12503    194754.1+182453195221.8+184019 56.48-04.33 6.23  +0.01 -0.92         O7.5Iaf            -0.002-0.003      +009SB    104                 *
+7575          BD-03 4742 1880411438831519          V1291 Aql194804.5-032225195318.7-030652 37.27-15.18 5.65  +0.20 +0.10         A5p               v+0.024+0.015 +.003-020V       2                 *
+7576 20    CygBD+52 2547 188056 320423586I         12481    194807.1+524403195037.7+525917 86.23 13.14 5.03  +1.28 +1.53 +0.50E  K3IIICN1           -0.008-0.068 +.014-020V    < 19:                *
+7577          BD+47 2937 188074 48907              Var?     194820.1+470712195119.4+472238 81.25 10.36 6.20  +0.36 +0.04         F2V                +0.018+0.019      -018SB                        *
+7578          CD-2415668 188088188692       13072  Var?     194818.4-241123195417.7-235628 17.18-23.91 6.18  +1.02 +0.94 +0.35E  K2V                -0.131-0.414 +.075-007SB2 =<  8  4.0  31.5      *
+7579          CP-69 3072 1880972546933589                   194821.5-692533195841.3-690950326.39-31.18 5.75  +0.23 +0.16 +0.08   Am                 +0.063-0.099 +.032-012       89                 *
+7580          BD+04 4264 188107125182                       194823.9+040829195322.6+042402 44.10-11.65 6.53  +0.02 -0.11         B9.5Vn             +0.016+0.004      +002      260                  
+7581   Iot SgrCD-4214549 1881142299271520                   194821.8-420751195515.7-415206357.97-29.11 4.13  +1.08 +0.90 +0.52C  K0II-III           +0.017+0.056 +.035+036                           
+7582 63Eps DraBD+69 1070 188119  9540    I  13007  12465    194830.7+700048194810.4+701604102.43 20.83 3.83  +0.89 +0.52 +0.48   G7IIIbCN-2         +0.082+0.037 +.016+003SB   < 19: 3.2   3.2      *
+7583          BD+36 3744 188149 69004    I                  194835.9+361027195216.3+362556 71.76  4.76 6.10  +1.43 +1.62         K4III              +0.002 0.000      -021                           
+7584 56    AqlBD-08 5150 188154143894    I W                194842.7-085002195408.2-083427 32.28-17.80 5.79  +1.64 +2.00        gK5                 +0.005-0.018      -050V?         6.1  46.5       
+7585          CD-3314560 188158211653                       194840.6-331827195505.1-330247  7.66-26.95 6.46  +1.48               K2/3III            -0.012-0.002      +034V                          
+7586          CP-58 7683 188161246348                       194841.5-581116195657.7-575532339.54-31.31 6.53  +1.53 +1.79         K4II               -0.009-0.036      +026                           
+7587          CP-59 7550 188162246349                       194842.4-590952195706.2-585405338.40-31.36 5.26  -0.01               B9.5IV             +0.015-0.021 +.022-002       51                  
+7588          CP-69 3073 188164254696                       194840.4-690133195853.0-684544326.85-31.23 6.39  +0.16 +0.09         A0V+F5IV           +0.034-0.067      -018SB2O                      *
+7589          BD+46 2793 188209 489173588          Var      194858.2+464609195159.1+470139 80.99 10.09 5.62  -0.07 -0.97 -0.12   O9.5Ia             -0.003 0.000 +.009-006V      77                 *
+7590   Eps PavCP-73 2086 188228257757 748          12598    194901.8-731028200035.5-725438322.02-30.90 3.96  -0.03 -0.05 -0.03C  A0V                +0.074-0.132 +.016-002V?    110                  
+7591          BD+47 2939 188252 48920              12511    194910.4+474025195207.2+475555 81.81 10.51 5.91  -0.18 -0.85         B2III              -0.005-0.007      -018       74                  
+7592 13    VulBD+23 3820 188260 87883      W                194912.6+234907195327.7+240447 61.27-01.79 4.58  -0.06 -0.14 -0.05   B9.5III            +0.027+0.038 +.009-028SB     50  3.2   1.0       
+7593 57    AqlBD-08 5154 188293143898       13087A          194912.8-082916195437.6-081338 32.66-17.76 5.71  -0.08 -0.48         B7Vn               +0.010-0.025 +.010-006SB    340  0.8  35.7      *
+7594 57    AqlBD-08 5155 188294143899       13087B          194913.2-082951195438.1-081414 32.65-17.77 6.49  -0.04 -0.26         B8V                +0.021-0.027 +.010-005SB    266  0.8  35.7      *
+7595 59Xi  AqlBD+08 4261 188310125210    I                  194924.1+081209195414.9+082741 47.81-09.85 4.71  +1.05 +0.91 +0.57   G9+IIIb            +0.101-0.081 +.023-042V?   < 19:                 
+7596 58    AqlBD-00 3871 188350125219                       194937.4+000044195444.8+001625 40.55-13.92 5.61  +0.10 -0.01         A0III              +0.042-0.012      -050      130                  
+7597 58Ome SgrCD-2614637 188376188722    I                  194942.9-263353195550.4-261758 14.86-25.04 4.70  +0.75 +0.32 +0.37   G5V                +0.207+0.083 +.062-021SB                        *
+7598          BD+06 4351 188385125221       13093           194947.1+065242195440.3+070825 46.70-10.60 6.15  +0.03 +0.04         A2V                +0.034-0.003      -016           6.4  13.8      *
+7599          BD-07 5102 188405143911       13104           194957.7-065945195519.6-064403 34.15-17.26 6.51  +0.39 +0.05         F2V                +0.036-0.046D+.010-007SB3        1.1   0.2      *
+7600          BD+47 2945 188439 48940              V819 Cyg 195003.6+473251195301.2+474827 81.77 10.32 6.29  -0.11 -0.91         B0.5IIIn           -0.009-0.009      -065SB    400                 *
+7601          BD+23 3829 188485 87908                       195016.4+240326195431.1+241910 61.60-01.87 5.52  -0.02 -0.16         A0III              +0.026 0.000 +.015-008V     117                  
+7602 60Bet AqlBD+06 4357 188512125235 749I  13110  12557    195024.0+060925195518.8+062424 46.13-11.09 3.71  +0.86 +0.48 +0.49   G8IV               +0.048-0.482 +.070-040V   =< 16  7.7 175.0AC   3*
+7603   Mu 1PavCP-67 3695 188584254702                       195039.1-671246200023.0-665658328.96-31.52 5.76  +1.04 +0.80         K0III              -0.020-0.197 +.037+029                           
+7604 59    SgrCD-2714399 188603188742    I                  195048.7-272606195656.8-271012 14.05-25.56 4.52  +1.46 +1.57 +0.73   K2.5IIb            +0.008-0.013 +.014-016SB                        *
+7605          CD-3813776 188642211686                       195100.8-381921195741.3-380330  2.33-28.74 6.55  +0.39               F4V                +0.089-0.083      -031                           
+7606          BD+36 3766 188650 69072                       195109.0+364355195448.3+365946 72.50  4.61 5.76  +0.75 +0.35         G1Ib-IICH1Fe-1Ca-1 +0.014+0.021      -024                          *
+7607          BD+29 3802 188651 69079       13117           195107.1+295552195506.5+301143 66.70  1.05 6.57  -0.08 -0.47 -0.14   B6V+A5V            +0.011+0.017      -012      200  2.9   9.3AB   4 
+7608 23    CygBD+57 2084 188665 32085                       195114.2+571541195317.4+573125 90.55 14.91 5.14  -0.13 -0.55         B5V                +0.009+0.013      -025V?    145                 *
+7609 10    SgeBD+16 4067 188727105436              S Sge    195128.6+162211195601.3+163805 55.17-06.12 5.36  +0.67 +0.42 +0.45   G5Ib              v+0.004-0.004 +.009-010SBO    20:                *
+7610 61Phi AqlBD+11 4055 1887281054383590                   195130.1+110929195614.3+112526 50.66-08.80 5.28  -0.01 -0.08         A1IV               +0.034+0.009 +.023-027SB1O   26                 *
+7611          BD+59 2137 188793 32093      W                195148.0+592639195335.4+594232 92.58 15.87 6.06  +0.02 +0.03         A3V                +0.043+0.061      -014SB    110  3.3  71.4       
+7612   Mu 2PavCP-67 3698 188887254707                       195208.6-671251200152.4-665639328.95-31.67 5.31  +1.22 +1.29 +0.41E  K2IVCNII           +0.030-0.073 +.025+042                          *
+7613 22    CygBD+38 3817 188892 69101                       195217.2+381315195551.7+382912 73.90  5.19 4.94  -0.08 -0.51 -0.10   B5IV                0.000+0.002      -030V      85                 *
+7614 61    SgrBD-15 5516 1888991631411522                   195216.7-154524195757.0-152929 26.02-21.54 5.02  +0.05 +0.07         A3IV               +0.017-0.101 +.032+003V     102                 *
+7615 21Eta CygBD+34 3798 188947 691161521I  13149  12586    195233.2+344903195618.4+350500 71.02  3.36 3.89  +1.02 +0.89 +0.52   K0III              -0.032-0.027 +.015-027     < 19: 7.7  46.0AC   5*
+7616          BD+20 4351 188971 87963                       195237.7+204352195700.2+205953 59.05-04.08 6.48R +0.07 -0.05         A2IV               -0.024-0.023      +008                           
+7617          CD-3017525 188981211708                       195239.0-304822195856.4-303217 10.62-27.01 6.28  +1.05               K1III              +0.090-0.053      -051V                          
+7618 60    SgrCD-2614682 189005188778    I                  195251.7-262759195857.2-261144 15.23-25.67 4.83  +0.90 +0.55 +0.47   G6IIIBa0.2         +0.035+0.033 +.014-049SB                        *
+7619 24Psi CygBD+52 2572 189037 32114       13148           195302.6+521024195537.8+522620 86.11 12.21 4.92  +0.12 +0.06 +0.06   A4Vn               -0.037-0.030 +.005-010V     276  2.3   3.1AB   4*
+7620          BD+35 3878 189066 69129                       195302.2+355859195644.2+361503 72.06  3.89 6.02  -0.15 -0.59         B5IV               +0.004+0.005      -023                          *
+7621          CD-4912949 1890802299733595                   195302.2-493721200025.3-492104349.59-31.19 6.17  +1.06 +0.92         K0III              -0.082-0.006      +067                           
+7622 11    SgeBD+16 4081 1890901054713592                   195312.9+163111195745.4+164721 55.52-06.40 5.53  -0.05 -0.17         B9III              +0.012+0.016 -.003-026V?     52                  
+7623   The1SgrCD-3513831 189103211716 751                   195313.7-353248195944.2-351635  5.52-28.47 4.37  -0.15 -0.67         B3IV               +0.006-0.026      +001SBO    69                 *
+7624   The2SgrCD-3513832 189118211717      W                195321.9-345801195951.3-344152  6.17-28.34 5.30  +0.17 +0.06 +0.07   A4/5IV             +0.100-0.075 +.033-018        0  5.5  30. AB   3 
+7625          CP-59 7564 1891242463893598          NU Pav   195319.2-593854200144.7-592234337.85-31.96 5.13  +1.53 +1.31 +1.55E  M6III              +0.017-0.033 +.005-010                          *
+7626          BD+57 2092 189127 32116                       195323.0+575909195522.1+581501 91.35 15.00 6.09  +1.02               G9III              +0.021-0.071      -017                           
+7627          CD-4313735 189140229977                       195329.4-431856200026.5-430236356.85-30.27 6.14  +1.64 +2.02         M0II-III           +0.023+0.013      -034                           
+7628          BD+39 3968 189178 490113593  W                195345.4+400556195713.9+402205 75.65  5.93 5.45  -0.10 -0.52         B5V                +0.008+0.007      -026SB    115  3.0  64.6      *
+7629          CD-3813802 189195211719      W                195337.8-375825200015.9-374208  2.86-29.15 5.95  +1.00 +0.77         G8III              +0.018-0.020      +023           7.6  23.0       
+7630          CD-4513549 1891982299813597                   195343.4-452309200048.3-450647354.49-30.68 5.81  +0.28 +0.11 +0.17C  A8III               0.000+0.002 +.017+003SB    123                 *
+7631          CD-3414082 189245211724              12655    195353.6-335804200020.3-334214  7.29-28.18 5.66  +0.49 -0.02         F7V                +0.136-0.306 +.049-008SB     86                 *
+7632          BD+50 2930 189253 32130                       195401.0+503801195645.1+505409 84.82 11.31 6.43  -0.01 -0.05         A1V                +0.005+0.008      -019V     118                  
+7633          BD+58 2013 189276 321223591I                  195400.9+583444195555.4+585046 91.93 15.21 4.96  +1.59 +1.93         K5II-III           -0.009-0.019 +.004+005     < 19:                 
+7634          BD+56 2331 189296 32128                       195408.6+562506195619.0+564113 89.98 14.15 6.12R                     A4Vn               +0.022+0.016      -031V     175                  
+7635 12Gam SgeBD+19 4229 189319105500 752I         12638    195418.5+191314195845.4+192932 57.97-05.21 3.47  +1.57 +1.93 +0.92   M0-III            e+0.066+0.024 +.013-033V?   < 17                 *
+7636          BD+00 4375 1893221253103596                   195417.6+010615195922.7+012240 42.11-14.42 6.17  +1.13 +0.90         G8III              +0.026+0.065      +006                           
+7637          BD-10 5238 189340163168      W                195421.1-101310195947.4-095730 31.60-19.66 5.88  +0.58 +0.05         F8V                -0.269-0.400 +.040+023V?         0.0   0.1       
+7638          BD+41 3549 189377 49031       13186           195434.4+415926195756.2+421539 77.36  6.79 6.43R                     A3V                +0.001-0.003D+.003-006SB         1.2   0.1AB   3*
+7639          CD-4113807 189388229993                       195438.2-410515200126.4-404851359.42-30.04 6.29  +0.11               A2-3V              -0.015-0.038      -031                           
+7640          BD+30 3837 189395 691883594                   195440.0+304244195838.0+305901 67.77  0.82 5.49  -0.06 -0.19         B9Vn               +0.041+0.003 +.036-007V     175                  
+7641 14    VulBD+22 3872 189410 88016                       195453.0+224944195910.5+230605 61.11-03.41 5.67R                     F0                 -0.071+0.006 +.019-038SB    120                  
+7642          BD+37 3703 189432 69193       13198           195457.9+375002195834.4+380620 73.84  4.54 6.32  -0.09 -0.50         B5IV               +0.009-0.004D+.004-014       15  1.1   1.9       
+7643          CD-2315935 1895611888293600                   195527.3-230044200123.9-224414 19.04-25.02 6.01  +0.97 +0.77         G7V                +0.010-0.014      +008V?                         
+7644          CP-67 3703 189567254721                       195532.3-673453200532.8-671915328.48-31.98 6.07  +0.64 +0.08 +0.23E  G3V                +0.844-0.672 +.054-012                           
+7645 13    SgeBD+17 4183 189577105522    I  13230  VZ Sge   195532.3+171435200003.3+173100 56.43-06.49 5.37  +1.67 +1.75 +1.20E  M4IIIa             +0.004-0.011      -017V?         7.5  28.5      *
+7646          BD+45 3025 189684 49058                       195611.9+452957195920.5+454620 80.53  8.37 5.92  +0.16 +0.15         A5III              +0.020-0.021      +006V                          
+7647 25    CygBD+36 3806 189687 692313599          V1746 Cyg195615.1+364607195955.2+370234 73.07  3.76 5.19  -0.17 -0.69         B3IVe              +0.006+0.001      -004SB    229                 *
+7648          BD+08 4300 189695125355    I                  195608.7+081658200058.9+083329 48.74-11.25 5.91  +1.52 +1.89         K5III              +0.008-0.009      -040V?                         
+7649 63    SgrBD-14 5618 189741163195                       195622.5-135451200158.6-133813 28.27-21.69 5.71  +0.08               A3V                +0.038+0.018 +.020-042                           
+7650 62    SgrCD-2816355 189763188844 753I         V3872 Sgr195630.6-275916200239.5-274235 13.92-26.93 4.58  +1.65 +1.80 +1.56   M4III              +0.036+0.017 +.028+010V                         *
+7651          BD+51 2728 189775 32170                       195636.3+514654195915.4+520321 86.04 11.54 6.15  -0.19 -0.65         B5III              +0.015+0.006      -016V                          
+7652          CD-3813828 1898312117673602                   195654.9-381302200333.5-375627  2.77-29.84 4.77  +1.41 +1.68 +0.56E  K5III              +0.059-0.092 +.020-038                          *
+7653 15    VulBD+27 3587 189849 880711523          NT Vul   195658.9+272837200106.1+274513 65.30-01.34 4.64  +0.18 +0.16 +0.09   A4III              +0.059+0.005 +.030-021SBO    23                 *
+7654          BD+63 1584 189900 18627                       195713.7+631540195828.7+633203 96.42 17.09 5.96R +0.09?              A3V                -0.005-0.026      -009                           
+7655          BD+36 3820 189942 69267                       195734.8+364913200115.3+370556 73.26  3.56 6.20  +1.31               K0III              +0.044+0.051      -016                           
+7656          BD+24 3975 189944 88088                       195730.4+243122200144.7+244801 62.87-03.02 5.88  -0.12 -0.51         B4V                +0.005-0.003      -015                           
+7657 16    VulBD+24 3977 190004 88098       13277           195746.8+243928200201.4+245617 63.02-03.00 5.22  +0.36 +0.09         F2III              +0.088+0.070D+.004-037V     121  0.3   0.8       
+7658          BD-22 5318 190009188863      D                195748.8-225235200344.3-223544 19.39-25.48 6.45  +0.50               F6V                -0.042+0.020      +007V                         *
+7659          CD-3215682 1900562117823606I W       12746    195759.2-322013200419.6-320323  9.34-28.55 4.99  +1.21 +1.16         K1III              +0.047-0.015 +.007-012           7.6  51.3       
+7660 26    CygBD+49 3158 190147 49098    I  13278A          195831.8+494935200121.6+500617 84.49 10.28 5.05  +1.11 +1.02 +0.55   K1II-III           +0.019+0.004 +.014+001V    < 19: 3.8  41.8AB   5 
+7661          BD-07 5159 190172144038                       195838.3-074459200401.2-072811 34.46-19.52 6.72  +0.35 +0.07         F4III              +0.015-0.048      +004V?                         
+7662          BD+18 4365 190211105608    I W                195847.2+181315200316.4+183002 57.67-06.63 5.96  +1.42 +1.60         K3II-III+G8IV      +0.015-0.031      +009           3.3  47.1       
+7663          CP-66 3473 190222254731                       195849.4-663826200820.5-662117329.57-32.36 6.45  +1.58 +1.98         K5III              -0.010-0.005      +036                           
+7664          BD+15 4033 190229105615                       195855.4+154502200330.0+160153 55.58-07.97 5.67  -0.10 -0.48         B9pHgMn            +0.003-0.005 +.008-022SB1    11                 *
+7665   Del PavCP-66 3474 190248254733 754          12790    195854.9-662612200843.6-661055329.79-32.40 3.56  +0.76 +0.45 +0.34   G6-8IV             +1.207-1.131 +.170-022                          *
+7666          BD+69 1084 190252  9592                       195856.5+700522195841.9+702201102.91 20.06 6.33  +0.88 +0.54         G8III              +0.045+0.060      -010                          *
+7667 62    AqlBD-01 3887 190299144045    I                  195914.0-005918200423.2-004234 40.83-16.51 5.68  +1.30 +1.35         K4III              +0.003-0.118 +.004+000V?                         
+7668          CD-3314700 190306211798      W                195909.4-331659200532.1-330000  8.38-29.04 6.53  -0.08               B8                 +0.018-0.018      -018           1.0   0.4AB   3 
+7669 63Tau AqlBD+06 4416 1903271254031524I                  195915.2+065944200408.3+071641 48.01-12.57 5.52  +1.06 +0.86        gK0                 +0.016+0.011 +.005-028                           
+7670          BD+29 3872 190360 88133                       195930.7+293747200337.4+295348 67.41-00.66 5.71  +0.73 +0.37         G6IV+M6V           +0.683-0.526 +.047-045V          9.8 179.       *
+7671          BD-12 5641 190390163245      W       V1401 Aql195934.1-115256200505.4-113558 30.60-21.53 6.34  +0.52               F1III              -0.001-0.012      -012V?     23       25.       *
+7672 15    SgeBD+16 4121 190406105635      W       12757    195936.6+164757200406.2+170412 56.56-07.55 5.80  +0.61 +0.09         G1V                -0.395-0.414 +.060+004V       4  0.9 203.7AC   6 
+7673   Xi  TelCP-53 9794 190421246443 755          12783    195943.5-531001200723.2-525251345.55-32.57 4.94  +1.62 +1.84 +0.80E  M1IIab             -0.014+0.008 +.014+036SB                        *
+7674          CP-55 9317 190422246444                       195942.7-551811200735.1-550059343.02-32.69 6.26  +0.53               F8V                +0.016+0.023      +013                           
+7675 65    SgrBD-13 5569 190454163253                       195952.7-125652200526.4-123955 29.59-22.06 6.55  +0.04  0.00         A1Vn               +0.009-0.049      -006      201                  
+7676 64    DraBD+64 1405 190544 186583604I W                200025.0+643227200128.5+644916 97.77 17.38 5.27  +1.56 +1.81         M1III-IIIb         +0.007-0.012 +.006-034               193.8       
+7677          BD+22 3913 190590 88163      S                200040.1+225533200458.6+231237 61.91-04.49 6.45R                     A5Vn               +0.006-0.002      -022                 0.1       
+7678          BD+31 3925 190603 69362       13335  V1768 Cyg200040.8+315606200436.1+321307 69.49  0.39 5.64  +0.54 -0.46 +0.42   B1.5Ia            e-0.011-0.012      +021V      29  4.5  32.1      *
+7679 16Eta SgeBD+19 4277 1906081056593609I                  200043.3+194215200509.5+195928 59.18-06.23 5.10  +1.06 +0.98 +0.34E  K2III              +0.030+0.078 +.032-040V?   < 19:                *
+7680          BD+15 4040 190658105663    I  13344           200050.4+151253200526.5+153001 55.36-08.64 6.34  +1.64 +1.76         M2.5III            +0.033+0.020      -112SB         4.0   2.7      *
+7681          BD-04 5013 190664144062                       200056.0-042147200612.2-040442 37.92-18.48 6.47  +1.16 +1.00         K0                 +0.045-0.045      -002                           
+7682 65    DraBD+64 1407 190713 18669      W                200113.6+642107200220.3+643804 97.64 17.21 6.57R                    gG7                 +0.046+0.010      +009V?         2.1  96.8AB   3 
+7683          BD+38 3896 190771 69377       13348           200130.9+381124200509.8+382842 74.84  3.64 6.19  +0.64 +0.22 +0.38   G5IV               +0.259+0.109 +.041-024           6.1  40. AC   3*
+7684          BD+47 3004 190781 491523610  S                200129.2+475642200428.8+481347 83.12  8.88 6.16  +0.04 +0.04         A2IV               +0.011+0.004      -014                 0.3       
+7685 67Rho DraBD+67 1222 190940 186763608I W                200222.1+673518200249.1+675225100.70 18.64 4.51  +1.32 +1.51 +0.65   K3III              +0.016+0.046 +.017-009     < 19: 8.6 124. AB   3 
+7686 69    DraBD+76  771 190960  96063605I                  200225.1+761209195936.6+762853108.94 22.48 6.20  +1.61 +1.89 +0.94E  M3III              -0.029-0.055      -069V?                         
+7687          BD+51 2763 190964 32272    I                  200224.1+513308200506.7+515022 86.31 10.65 6.14  +1.60 +1.95         M1IIIa             +0.029+0.034      -056                           
+7688 17    VulBD+23 3896 190993 882123611                   200235.5+231934200653.4+233652 62.48-04.65 5.07  -0.18 -0.67         B3V                +0.015+0.003      -005SB    214                  
+7689 27    CygBD+35 3959 191026 69413      W       Var?     200238.8+354149200621.8+355821 72.86  2.10 5.36  +0.85 +0.54 +0.44   K0IV               -0.224-0.438 +.032-033           4.0  11.9AD   4*
+7690 64    AqlBD-01 3899 191067144095                       200252.0-005758200801.8-004042 41.30-17.29 5.99  +1.02 +0.90         K1IV               +0.116-0.070      -004V?                         
+7691          CP-57 9622 191095246470      W                200300.3-574859201107.2-573126340.04-33.20 6.37  +0.06               B7V+A3V            -0.002-0.025      -007SB3        0.6   0.8      *
+7692          BD+55 2324 191096 32276                       200305.1+560307200521.5+562029 90.30 12.90 6.21  +0.43 +0.03         F4V                -0.004+0.080      -012V?     40                  
+7693          BD+08 4344 191104125478       13403           200301.2+090633200750.3+092359 50.35-12.29 6.43  +0.46 -0.02         F3V                +0.047+0.022D+.015-027SB         2.1   3.1      *
+7694          BD-10 5285 191110163290                       200303.3-102108200831.3-100346 32.48-21.65 6.18  +0.06               B9.5III            +0.008-0.042      -016SB2O                      *
+7695          BD+63 1593 191174 18692       13371           200329.2+633608200444.6+635326 97.08 16.64 6.26  +0.10 +0.04         A2II-III           +0.007+0.043D+.023-019V?         3.6   5.5AB   3 
+7696          BD+16 4153 191178105733    I                  200332.8+162225200806.5+163951 56.71-08.58 6.42  +1.91 +1.86         M3III              +0.005-0.002      +011V?                         
+7697          BD+52 2623 191195 322863613  W                200335.8+525212200613.8+530957 87.56 11.18 5.85  +0.39 -0.01         F5V                +0.212+0.255 +.027-041V   =< 10  3.8 170.4       
+7698          CP-83  695 191220258856                       200333.7-833708202454.4-831838310.00-29.60 6.17  +0.20 +0.13         Am                 +0.011+0.012      +000                          *
+7699          BD+34 3881 191243 694573615                   200351.7+340757200741.4+342523 71.69  1.03 6.11  +0.16 -0.45         B5Ib               +0.002 0.000      +010V?                        *
+7700          BD+10 4189 1912631057433616                   200352.1+102604200838.3+104333 51.62-11.78 6.31  -0.12 -0.67         B3V                +0.004+0.001      -025                          *
+7701 66    DraBD+61 1970 191277 187003612I                  200357.4+614218200532.8+615944 95.39 15.65 5.39  +1.18 +1.29 +0.59   K3III              +0.121+0.074 +.037+006                           
+7702          BD+49 3195 191329 32296                       200420.2+495622200711.5+501345 85.08  9.54 6.54  +0.13               A3V                +0.018-0.020      +003                           
+7703          CD-3613940 191408211885      W                200437.7-362109201111.9-360604  5.26-30.91 5.32  +0.87 +0.46 +0.49   K3V                +0.458-1.571 +.179-130V?         4.0      AD   4*
+7704          BD+67 1226 191372 18699    I                  200427.6+674421200453.3+680138100.94 18.54 6.28  +1.65 +2.00 +0.97E  M3IIIa             -0.017-0.012      -042                          *
+7705 17The SgeBD+20 4453 191570 88276       13442A          200531.8+203704200956.6+205455 60.55-06.68 6.48  +0.38 -0.04         F5IV               +0.054+0.101 +.029-040           0.6  83.9AC   4*
+7706          CD-4313855 191584230100                       200531.5-430428201223.9-424650357.57-32.39 6.22  +1.23               K1III              -0.014-0.118      -001                           
+7707          CP-63 4571 1916032547563619                   200533.3-634257201426.9-632457332.97-33.29 6.09  +0.31 +0.09         F0IV               -0.037+0.037      +019                           
+7708 28    CygBD+36 3907 191610 695181525          V1624 Cyg200542.7+363242200925.6+365023 73.91  2.04 4.93  -0.13 -0.77 -0.14   B2.5Ve            v+0.005+0.014      -014SB?   310                 *
+7709          BD-09 5382 1916391441443618          Var      200544.7-090818201110.1-085032 33.97-21.71 6.49  -0.15 -0.92         B1V                +0.006 0.000      -007                          *
+7710 65The AqlBD-01 3911 191692144150 756I'W                200608.7-010706201118.3-004917 41.58-18.08 3.23  -0.07 -0.14 -0.05   B9.5III            +0.038+0.004 +.012-027SB2O   63  9.6 113.7      *
+7711 18    VulBD+26 3815 191747 88295                       200623.0+263628201033.5+265415 65.71-03.57 5.52  +0.08 +0.13         A3III              +0.020+0.013 +.002-012SB2O   41                 *
+7712  1Xi 1CapBD-12 5664 191753163328                       200625.4-124122201157.9-122333 30.58-23.39 6.34  +1.21               K0III              -0.005-0.017      +001                           
+7713          BD+20 4462 191814 88309                       200639.3+205013201103.5+210805 60.90-06.79 6.22  +0.90               K0                 +0.017+0.034      -007                           
+7714          CP-5211643 191829246495                       200644.2-524441201419.0-522644346.13-33.60 5.65  +1.50               K4III              +0.022-0.045 +.020+014V                          
+7715  2Xi 2CapBD-13 5608 191862163337      W                200651.6-125438201225.9-123703 30.41-23.59 5.85  +0.48 -0.07         F7V                +0.197-0.193 +.037+023V?         6.2  71.6       
+7716          BD+21 4088 191877 88315                       200658.7+213440201121.1+215232 61.57-06.45 6.26  -0.02 -0.85         B1Ibe              -0.001+0.007      -018                           
+7717          BD+00 4444 191984125567       13506A          200729.1+003407201235.2+005203 43.30-17.56 6.27  +0.02 -0.01         B9pCrEu:Sr:        +0.010-0.014D+.009-019           0.2   2.8      *
+7718 19    VulBD+26 3825 192004 88330    I                  200737.2+263038201148.0+264832 65.78-03.85 5.49  +1.41 +1.51 +0.70   K3II-III           +0.007-0.010      -023                          *
+7719 20    VulBD+26 3828 192044 88339              12890    200749.0+261048201200.7+262844 65.53-04.07 5.92  -0.11 -0.43         B7Ve               +0.008-0.011      -022V     350                 *
+7720 66    AqlBD-01 3920 192107144181    I                  200804.0-011833201313.9-010034 41.65-18.60 5.47  +1.43 +1.30         K5III              +0.022-0.028 +.028-028V                         *
+7721          BD+47 3045 192276 49314                       200859.4+472612201203.8+474413 83.37  7.54 6.92  -0.12 -0.45         B7V                +0.016+0.004      -019SBO                       *
+7722          CD-2714659 192310189065              12933    200903.1-271953201517.4-270158 15.62-29.38 5.73  +0.88 +0.64 +0.45   K0V               v+1.244-0.174 +.124-054SB?                        
+7723          BD+23 3935 192342 88377       13543           200922.9+235608201340.6+241420 63.85-05.61 6.56  +0.29 +0.12 +0.14   A1m                +0.050+0.031D+.011-037           3.3   2.7      *
+7724 67Rho AqlBD+14 4227 1924251058781526                   200938.9+145334201416.6+151151 56.24-10.61 4.95  +0.08 +0.01  0.00   A2V                +0.057+0.057 +.023-023SB?   152                  
+7725          CD-3017773 1924332119403621                   200937.9-301837201550.6-300019 12.38-30.36 6.30  +1.51               K4III              +0.037+0.013      -099V                          
+7726          BD+51 2796 192439 32354       13535           200944.8+510945201231.8+512749 86.60  9.47 6.01  +1.14               K2.5III            -0.011-0.014      +013           5.6   4.0AB   5*
+7727 68    DraBD+61 1983 192455 18751      W                200956.6+614633201134.9+620443 95.83 15.08 5.75  +0.47 +0.02         F5V                +0.123+0.083 +.031-015V?  =< 10  9.4  93.        
+7728          CD-3614011 192472211948      W       12949    200953.2-364532201623.7-362716  5.09-32.02 6.39  +1.54               M4III              +0.009-0.042      -014V          5.1  38.0AB   3 
+7729          CD-3514020 192486211950                       200959.8-353020201626.5-351152  6.54-31.76 6.53  +0.37               F2V                +0.009+0.081      -008                           
+7730 30    CygBD+46 2881 192514 49332       13554D 12926    201009.4+463047201318.0+464857 82.71  6.87 4.83  +0.09 +0.15 +0.08   A5IIIn             +0.012-0.001 +.012-026V?    146  1.0 337.5AD   6*
+7731 21    VulBD+28 3675 192518 88391              NU Vul   201007.9+282330201414.5+284141 67.66-03.27 5.18  +0.18 +0.16         A7IVn              +0.014-0.022 +.010+007V?    197                 *
+7732          CP-63 4576 192531254772                       201013.7-633215201903.0-631352333.13-33.82 6.27  +1.04               K0III              -0.015-0.084      -008                           
+7733          BD+42 3642 192535 493363620I  13555           201020.8+430432201342.8+432245 79.85  4.93 6.14  +1.50 +1.83         K4III               0.000+0.006      -024           6.4  57.3AC   4 
+7734          BD+36 3949 192538 69653              Var?     201020.1+361805201405.0+363619 74.23  1.14 6.45   0.00 -0.02         A0V                +0.024+0.002      -022      142                  
+7735 31    CygBD+46 2882 192577 49337 757I  13554A V695 Cyg 201028.9+462616201337.9+464429 82.68  6.78 3.79  +1.28 +0.42 +0.76   K2II+B3V           +0.004+0.003 +.007-008SBO =< 25  1.0 337.5AD   6*
+7736 29    CygBD+36 3955 192640 69678      W       V1644 Cyg201047.3+362959201432.0+364823 74.45  1.17 4.97  +0.14  0.00 +0.07   A2V                +0.068+0.070 +.036-017V      37  1.6 212.4AB   5*
+7737          BD+41 3668 192659 49345       13572           201054.7+414759201421.6+420613 78.85  4.13 6.71  -0.04 -0.28         B9IV-V             +0.005-0.021      -018V          0.2   0.9AB   3*
+7738  3    CapBD-12 5680 192666163402       13600           201050.6-123836201622.8-122013 31.12-24.35 6.32  +0.01 -0.17         B9pHg              +0.012-0.013      -020           7.3  26.9AB   3 
+7739          BD+25 4165 192685 88410       13589  QR Vul   201101.6+251711201515.9+253531 65.19-05.17 4.78  -0.18 -0.72 -0.20   B3Ve              v+0.008-0.006      -007SB?   249  2.4   0.7AB   3*
+7740 33    CygBD+56 2376 192696 32378 758          12935    201104.4+561542201323.9+563404 91.08 12.06 4.30  +0.11 +0.08 +0.06   A3IV-Vn            +0.063+0.083 +.021-018SB    268                 *
+7741 22    VulBD+23 3944 192713 88416    I         QS Vul   201111.0+231211201530.2+233031 63.47-06.36 5.15  +1.04 +0.71 +0.48   G3Ib-II             0.000-0.015 +.004-023SB1O   17:                *
+7742          BD+60 2099 192781 18766    I                  201137.4+602005201327.7+603826 94.66 14.16 5.79  +1.47              gK5                 +0.044+0.058      -001V?                         
+7743          BD+33 3827 192787 69701       13596           201130.7+332534201523.7+334346 71.99-00.68 5.66  +0.91 +0.66         K0III              -0.040-0.106      -010V          6.3   3.0      *
+7744 23    VulBD+27 3666 192806 88428    I S                201137.4+273026201546.1+274851 67.11-04.04 4.52  +1.26 +1.12 +0.71   K3-IIIFe-1         -0.036+0.008 +.008+003     < 19:                *
+7745          CD-4813509 1928272301441528                   201145.7-480115201856.0-474239351.87-34.08 6.31  +1.67 +2.02         M1III              +0.012-0.004      -044V?                        *
+7746 18    SgeBD+21 4130 192836 88433                       201156.1+211730201619.7+213555 61.96-07.57 6.13  +1.04 +0.92 +0.53   K1III              +0.001-0.024      -004                          *
+7747  5Alp1CapBD-12 5683 1928761634221527I  13632           201206.3-124902201738.9-123030 31.09-24.70 4.24  +1.07 +0.78 +0.53   G3Ib               +0.023+0.001 +.006-026SB  =< 54  0.4 377.7 *   9*
+7748  4    CapBD-22 5384 1928791891141529                   201208.9-220708201801.4-214836 21.50-28.31 5.87  +1.00               K0III              +0.035-0.024 +.040-018V?                         
+7749          CD-4713340 192886230150                       201206.5-475310201917.9-473449352.03-34.13 6.13  +0.46 +0.01 +0.26C  F5V                +0.200-0.185 +.026-031                          *
+7750  1Kap CepBD+77  764 192907  9665 759   13524           201215.7+772437200853.3+774241110.38 22.50 4.39  -0.05 -0.11 -0.06   B9III              +0.011+0.024 +.001-023V      18  3.8   7.3AB   3*
+7751 32    CygBD+47 3059 192909 49385    I W       V1488 Cyg201222.8+472425201528.3+474252 83.67  7.05 3.98  +1.52 +1.03 +0.92   K3Ib+B3V           +0.001+0.008 +.014-014SBO  < 25  5.5 208.9      *
+7752          BD+38 3977 192934 69720      S                201225.4+383527201603.4+385352 76.36  2.08 6.27  +0.01 -0.01         A1V                -0.001-0.037      +008V?     73        0.2       
+7753 24    VulBD+24 4075 192944 88451 760                   201230.3+242147201647.1+244016 64.61-05.97 5.32  +0.95 +0.67         G8III              +0.016-0.018 -.003+015V    < 19:                 
+7754  6Alp2CapBD-12 5685 192947163427 761I  13645           201230.4-125117201803.3-123241 31.10-24.81 3.57  +0.94 +0.69 +0.48   G8IIIb             +0.064+0.004 +.034+000SB?  < 17  0.4 377.7 *   9*
+7755          BD+49 3236 192983 32400      S                201248.8+495529201543.4+501358 85.82  8.38 6.31R                     A2Vn               +0.024+0.010      -025V?    335        0.2       
+7756          BD+45 3119 192985 49395                       201246.1+451622201600.6+453446 81.93  5.80 5.91  +0.38 -0.04         F5V:               +0.008-0.052      -040    =< 10                  
+7757          BD+36 3978 192987 69725                       201244.3+364452201628.2+370323 74.87  0.99 6.48  -0.09 -0.41         B6III              +0.013+0.001      -008      300                 *
+7758          CP-55 9365 1930022465353626                   201245.6-552145202032.3-550303342.99-34.54 6.27  +1.59 +2.01         M0-1III            +0.009-0.033      -009                           
+7759          BD+39 4114 193092 49410    I  13640  12981    201321.7+400320201655.3+402154 77.67  2.76 5.24  +1.65 +1.88 +0.89   K3.5IIab-IIb       +0.004-0.003 +.004-020V?   < 19: 5.5  12.8AB   3 
+7760          BD+28 3695 193094 88473       13648           201325.7+285012201731.5+290853 68.43-03.62 6.22  +1.01               G9III              -0.011+0.032D+.009-020           4.7   5.9       
+7761  7Sig CapBD-19 5776 1931501634453625I  13675           201337.4-192550201923.6-190707 24.48-27.66 5.28  +1.40 +1.53         K3II               +0.009-0.009 +.025-011V          3.5  56.5       
+7762          BD+42 3670 193217 49425    I                  201403.4+422440201729.1+424319 79.69  3.99 6.29  +1.64 +1.91         K4II:              +0.014 0.000      -017                           
+7763 34    CygBD+37 3871 193237 69773    I         P Cyg    201406.0+374319201747.2+380159 75.83  1.32 4.81  +0.42 -0.58 +0.26   B2pe               -0.005-0.004 +.004-009V      75                 *
+7764          CD-2916981 193281189164       13702           201418.4-293041202028.1-291150 13.60-31.11 6.30  +0.17               A4/7V              +0.028+0.004      +004V      82  1.1  27.2AC   5*
+7765          CD-3614057 1933022120251530                   201424.5-355920202051.9-354025  6.22-32.75 6.46  +1.31               K3-4III            +0.039+0.018      -015                           
+7766          CD-5012929 1933072465463630                   201425.3-501829202141.0-495958349.13-34.67 6.27  +0.55 -0.02         G0V                -0.357-0.250 +.045+018                          *
+7767          BD+40 4103 193322 49438       13672           201434.4+402513201807.0+404356 78.10  2.78 5.84  +0.10 -0.78 +0.01   O9V                +0.001-0.003 +.007-007V     110: 2.5   2.6AB   5*
+7768          BD-01 3951 193329144296                       201433.2-012335201943.3-010443 42.40-20.06 6.06  +1.09 +1.02         K0                 +0.042+0.033      -045V                          
+7769 36    CygBD+36 3998 193369 69803                       201443.8+364112201828.6+370000 75.05  0.63 5.58  +0.06  0.00         A2V                +0.037+0.025      -008SB    105                  
+7770 35    CygBD+34 3967 193370 698063627          12994    201448.6+344012201839.1+345858 73.40-00.54 5.17  +0.65 +0.48 +0.42   F5Ib               +0.001-0.003 +.007-014SBO    13                 *
+7771          BD+12 4289 193373105961    I                  201447.6+125413201929.2+131301 55.22-12.74 6.21  +1.63               M1III              -0.029-0.012      +023V?                         
+7772          BD-06 5451 1934291443133628I         13013    201506.7-064027202026.1-062142 37.47-22.67 6.63  +1.55 +1.84         K5                 -0.081-0.090      +043V                         *
+7773  8Nu  CapBD-13 5642 193432163468       13714           201507.0-130426202039.8-124533 31.17-25.48 4.76  -0.05 -0.11 -0.06   B9.5V              +0.019-0.019 +.021-002V?     17  7.0  54.1      *
+7774          BD+13 4360 193472105974                       201519.0+131401202000.2+133253 55.57-12.67 5.95  +0.31 +0.13 +0.16   A5-F2m             +0.012-0.004      -008SB2    93                 *
+7775          BD-15 5626 193452163471       13717           201509.4-150601202046.6-144706 29.12-26.32 6.10  -0.02 -0.11         A0III              +0.043 0.000 +.010-018SB1O   97  0.3   0.0 *   8*
+7776  9Bet CapBD-15 5629 193495163481 762I W                201523.6-150550202100.7-144653 29.15-26.37 3.08  +0.79 +0.28 +0.50   F8V+A0             +0.042+0.002 +.010-019SBO    54  0.3   0.0 *   8*
+7777          BD+45 3139 193536 49462              V1773 Cyg201537.2+460031201849.6+461922 82.82  5.80 6.45  -0.13 -0.69         B2V                -0.005+0.010      -009SB2O                      *
+7778          BD+14 4263 1935561059883629                   201541.4+141513202020.5+143409 56.50-12.19 6.13  +0.91 +0.64 +0.44   G8III              -0.001+0.004      +008                           
+7779   Kap1SgrCD-4214836 193571230177 763  W                201540.2-422153202227.5-420259358.75-34.13 5.59   0.00  0.00 -0.01C  A0V                +0.036-0.090 +.035-012V          6.0  52.0AC   3 
+7780          BD+17 4294 193579105991    I                  201548.9+172842202021.4+174735 59.26-10.44 5.80  +1.49              gK5                 +0.020-0.033      -033                           
+7781          BD+54 2329 193592 32455       13692           201556.5+550503201824.8+552350 90.45 10.84 5.76  +0.11 +0.03 +0.06   A2V s              -0.006-0.023 +.003+001SB         1.3   3.5AB   4*
+7782          BD+36 4008 193621 69841                       201603.7+364903201948.3+370757 75.31  0.48 6.57   0.00 -0.07         A0III              +0.010-0.011      -019                          *
+7783          BD+66 1281 193664 18796                       201632.3+663156201731.3+665114100.45 16.92 5.93  +0.58 +0.06         G3V                +0.466+0.300 +.067-005V                          
+7784          BD+38 4021 193702 69856       13728           201637.7+390516202015.2+392412 77.23  1.69 6.23  +0.06 +0.03 +0.03   A1V                -0.002-0.022D+.003-001V     127  1.1   0.3AB   3*
+7785          CP-81  901 1937212588613994  W                201639.3-811737203317.5-805754312.42-30.69 5.77  +1.14 +0.85         G6-8II             -0.004-0.019      +009V          5.7  26.8       
+7786          BD+46 2910 193722 49482              V1584 Cyg201645.3+463116201956.1+465015 83.35  5.93 6.50  -0.06 -0.37         B8/9IIIpSi         +0.001+0.010      -011      250                 *
+7787   Kap2SgrCD-4214847 193807230184      W                201705.3-424438202353.2-422522358.34-34.44 5.64  +0.20 +0.10 +0.02   A5V                 0.000+0.022 +.016+003V?         0.9   0.6AB   4*
+7788          BD-10 5369 1938961443613632                   201734.3-095827202300.8-093917 34.55-24.70 6.30  +0.91 +0.58         G5IIIa             +0.024-0.018      -017V?                         
+7789 25    VulBD+23 3986 193911 88580                       201745.4+240737202203.4+242646 65.09-07.09 5.54  -0.06 -0.40         B8IIIne             0.000-0.007 -.008-013V     242                 *
+7790   Alp PavCP-57 9674 193924246574 764  W       13060    201744.3-570320202538.9-564406340.91-35.19 1.94  -0.20 -0.71 -0.16   B2IV               +0.007-0.089      +002SBO    39  7.1 245.4AB   3*
+7791          BD+53 2384 193944 32491    I  13743           201751.2+531641202030.4+533546 89.08  9.60 6.18  +1.56               K4III              -0.016+0.014      -004           6.2   6.5AC   4 
+7792 71    DraBD+61 2000 193964 18807              DE Dra   201756.6+615623201936.7+621527 96.48 14.36 5.72  -0.05 -0.21         B9V                +0.010+0.026      -019SBO     0                 *
+7793          BD+14 4275 194012106042                       201812.4+141351202252.3+143305 56.82-12.71 6.17  +0.51 -0.07 +0.26   F8V                +0.075-0.001 +.034+002V?      6                  
+7794          BD+04 4434 1940131257471531                   201813.4+050124202310.7+052035 48.75-17.63 5.31  +0.97 +0.77 +0.50   G8III-IV           -0.026-0.039 +.002-012     < 19:                 
+7795          BD+40 4136 194069 49524                       201830.6+404845202203.0+410753 78.85  2.39 6.39  +1.07 +0.82         G5III+A            -0.004-0.031      -004                          *
+7796 37Gam CygBD+39 4159 194093 49528 765I  13765  13048    201838.3+395611202213.7+401524 78.15  1.87 2.20  +0.68 +0.53 +0.34   F8Ib               +0.004 0.000 +.003-008V      20  8.5 141.2AxBC 4*
+7797          BD+30 4005 194097 69917    I                  201835.9+305643202237.4+311554 70.81-03.33 6.09  +1.35               K2                 +0.005-0.027      +012                           
+7798          BD+45 3152 194152 49531              13050    201849.5+452825202205.4+454742 82.70  5.04 5.58  +1.08 +1.02         K0III             v+0.028+0.044      -022SB                         
+7799          CD-4114024 194184230197                       201907.1-410705202547.9-404747  0.35-34.58 6.09  +1.36 +1.61         K3III              -0.102-0.093      +042SB1O                      *
+7800          BD+40 4141 194193 49546    I                  201912.3+404222202245.3+410134 78.84  2.22 5.93  +1.60 +1.98         K7III              +0.001-0.047      +001V?                         
+7801          CD-2917049 1942151892641532  D                201919.5-285916202526.8-283948 14.55-32.01 5.85  +1.10 +0.94         G8II/III           +0.014+0.007 +.038-007SBO                       *
+7802          BD+42 3721 194220 49550       13786  13053    201928.7+423938202255.5+425900 80.46  3.32 6.20  +0.95 +0.76         K0III             v+0.053+0.036D+.014-020V          1.8  93.2AC   4*
+7803          BD+00 4495 194244125769       13811  13064    201931.7+004441202437.5+010407 45.03-20.09 6.15  -0.04 -0.14         B9V                +0.003+0.007      -009V?    265: 4.7  31.3AC   3*
+7804          BD+68 1121 194258 188173631I         AC Dra   201939.4+683338202006.0+685249102.43 17.72 5.55  +1.59               M4.5-5III          +0.017+0.025      -043V                         *
+7805          BD+63 1618 194298 18826    I  13769           201946.3+633934202111.4+635849 98.10 15.11 5.69  +1.56               K5III              -0.004+0.023      +030V?         6.9   4.3      *
+7806 39    CygBD+31 4062 194317 699503633I                  201951.9+315202202351.7+321124 71.72-03.02 4.43  +1.33 +1.50 +0.67   K2.5IIIFe-0.5      +0.049-0.005 +.014-015V    < 19:                *
+7807          BD+37 3916 194335 69951              Var?     201959.9+370912202344.4+372835 76.04  0.04 5.90  -0.20 -0.88         B2Ven              +0.004-0.004      -030SB                        *
+7808          CD-3713741 194433212126      W                202024.3-374336202653.0-372411  4.46-34.26 6.25  +0.97 +0.77         K2IV-V             -0.242-0.116 +.042+023           1.4   1.1      *
+7809          BD-03 4888 194454144412                       202029.5-030729202542.5-024801 41.54-22.19 6.11  +1.19 +1.19        gK1                 -0.007-0.030      +024V?                         
+7810          BD+09 4526 194526125797    I         13076    202055.4+094352202544.0+100323 53.30-15.71 6.33  +1.56 +1.92 +0.66E  K5III             v+0.002-0.030      -077                           
+7811          BD+20 4559 194577 886643634          Var      202115.2+210501202540.5+212435 63.02-09.48 5.66  +0.93               G6III              +0.010-0.011      -022                          *
+7812          CP-81  906 194612258864                       202124.9-813737203818.6-811720311.99-30.75 5.91  +1.71 +2.02         K5III              -0.005-0.030      +000                           
+7813          BD+19 4408 194616106100                       202132.3+193217202601.2+195154 61.77-10.41 6.41  +1.02               K0III              +0.029+0.002      -030                           
+7814 10Pi  CapBD-18 5685 194636163592       13860           202135.8-183223202719.2-181242 26.22-29.08 5.25  -0.07 -0.41         B8II-III           +0.015-0.011      -013V?     93  3.4   3.3AB   3*
+7815          BD+53 2397 194668 32534                       202150.7+531333202432.4+533307 89.38  9.08 6.51  +0.01 -0.13         B9.5III            +0.010+0.015      -019                           
+7816          BD+16 4259 1946881061013635                   202149.0+165918202623.2+171856 59.66-11.91 6.22  +1.01               K0                 +0.008-0.006      -017                           
+7817          CD-3614166 1947832121603637                   202221.8-355532202846.7-353545  6.69-34.31 6.10  -0.11               B8II/III          v+0.008-0.021      -009                          *
+7818          BD+59 2228 194882 32562       13850           202300.6+591623202505.1+593600 94.55 12.38 6.44  +0.09 +0.12         A2IV s             +0.010-0.007D+.005-022SB         0.3   0.2      *
+7819          BD-16 5609 194918163612                       202305.5-160421202843.6-154430 28.97-28.46 6.41  +0.99 +0.69         K0III              +0.010-0.008      -018V?                         
+7820          BD+07 4477 1949371258413638                   202315.5+080623202807.5+082615 52.19-17.07 6.25  +1.08 +0.93         G9III              +0.043+0.017      -011                           
+7821 68    AqlBD-03 4906 194939144468      W                202310.7-034117202824.9-032128 41.36-23.05 6.13  -0.06 -0.18         B9V                +0.023-0.015      -009V          7.7   9.8       
+7822 11Rho CapBD-18 5689 194943163614       13887           202309.4-180839202851.6-174849 26.80-29.27 4.78  +0.38 +0.04 +0.19   F2IV               -0.014-0.021 +.047+018V      91  1.7 249.5AD   5*
+7823          BD+33 3910 194951 70044                       202313.4+335958202707.7+341944 73.86-02.34 6.39  +0.48 +0.45         F1II               -0.006-0.003      -014       23                  
+7824          BD+02 4175 194953125843                       202314.3+023622202816.8+025613 47.24-19.95 6.21  +0.90 +0.57         G8III              +0.049-0.002      -022                           
+7825          BD-22 5442 1950061893453639I                  202339.3-224323202931.3-222330 21.90-31.01 6.16  +1.55 +1.99         M1III              +0.011-0.031      +056                           
+7826 40    CygBD+37 3941 195050 70056                       202351.9+380642202734.3+382625 77.26-00.02 5.62  +0.06 +0.06         A3V                -0.023-0.070 +.021+000V     133                  
+7827          BD+56 2421 195066 32590       13870           202358.5+561832202623.5+563820 92.13 10.59 6.36   0.00  0.00         B9V                +0.014+0.010      -021SB    165  2.0  26.6      *
+7828 43    CygBD+48 3128 195068 49643                       202358.9+490306202702.3+492300 86.14  6.40 5.69  +0.26 +0.04        dF0                 +0.071+0.060 +.012-020V?                        *
+7829 12Omi CapBD-19 5830 195093163625       13902B          202408.6-185502202952.5-183512 26.07-29.78 6.74  +0.22 +0.04         A7V                +0.020-0.089      -016      144  0.8  21.9      *
+7830 12Omi CapBD-19 5831 195094163626       13902A          202409.9-185451202953.9-183500 26.08-29.78 5.94  +0.08 +0.30         A3Vn               +0.026-0.082      -012      301  0.8  21.9      *
+7831 69    AqlBD-03 4918 1951351444951533I                  202425.4-031305202939.0-025308 41.97-23.10 4.91  +1.15 +1.22 +0.56   K2III              +0.073-0.021 +.021-023V                          
+7832          CD-2917122 195206189374                       202449.4-292651203056.8-290645 14.42-33.29 6.39  +0.21               A5V                +0.015+0.003      -020                           
+7833          BD+19 4423 195217106156                       202452.6+194516202921.1+200516 62.41-10.94 6.55  +0.23 +0.10 +0.09   A3m                -0.025-0.002      +004                           
+7834 41    CygBD+29 4057 195295 700951534I         13111    202518.5+300205202923.7+302207 70.91-05.04 4.01  +0.40 +0.27 +0.23   F5II               +0.007 0.000 +.014-018V?     13                  
+7835 42    CygBD+35 4141 195324 700961535                   202531.5+360715202920.4+362717 75.85-01.47 5.88  +0.52 +0.10         A1Ib               +0.004-0.001      -018                           
+7836  1    DelBD+10 4303 195325106172       13920  13114    202530.6+103339203018.0+105345 54.66-16.21 6.08  -0.03 -0.11         A1eShell           +0.021+0.003 -.000-016V?    320  1.8   0.9AB   3*
+7837          BD-15 5696 195330163645      W                202528.2-152326203104.3-150323 29.94-28.71 6.12  +0.79 +0.42        gG5+F               -0.041-0.056      +030V?         0.0   0.1      *
+7838          CP-70 2792 195402254820                       202556.6-695701203551.7-693640325.19-34.32 6.11  +1.29 +1.41         K2III              +0.029-0.061      -005                           
+7839          BD+20 4602 195479 88783      W                202629.7+201605203058.1+203621 63.06-10.95 6.18  +0.15 +0.14 +0.04   A1m                +0.093+0.045      -040       15  4.0  11.8AB   3 
+7840          BD+10 4307 195483106196       13946           202626.5+105527203113.0+111538 55.10-16.21 7.11  +0.03 -0.39         B8V                 0.000-0.003      -011       91  0.3  16.7AxBC 4*
+7841          BD+45 3196 195506 49704                       202641.2+453519202959.9+455543 83.60  3.99 6.41  +1.13 +1.07         K2III              +0.071+0.154 +.007-031                           
+7842          CD-2514854 195549189416                       202655.1-251653203252.4-245638 19.33-32.54 6.36  -0.01               A0                 +0.010-0.041      -011                           
+7843          BD+55 2411 195554 326273640  W       13115    202657.2+554357202927.1+560405 91.89  9.92 5.91  -0.04 -0.24         B9Vne              +0.002+0.005      -022      250  2.5   0.8      *
+7844 45Ome1CygBD+48 3142 195556 497123641   13932           202657.6+483655203003.5+485706 86.07  5.74 4.95  -0.09 -0.63 -0.11   B2.5IV             +0.013+0.008      -022SB?   184  7.0  56.3AC   3*
+7845          BD-10 5423 1955641636651536   13960           202655.4-101141203223.7-095112 35.45-26.86 5.65  +0.69 +0.21         G2.5IV             +0.308+0.104 +.033+009V?         4.2 103.2AC   3*
+7846   Nu  MicCD-4414020 1955692302763643                   202702.8-445118203355.1-443058356.00-36.45 5.11  +1.01 +0.80         K0III              +0.011-0.043 +.007+009                           
+7847 44    CygBD+36 4105 195593 70135       13949           202711.2+363556203059.2+365609 76.44-01.45 6.19  +1.01 +0.74 +0.69   F5Iab              +0.003-0.004      -022           3.4   2.0AB   4*
+7848   Phi1PavCP-61 6492 195627254823                       202718.0-605506203534.8-603454336.04-36.09 4.76  +0.28 +0.05         F1III              +0.068-0.182 +.026-020      121                 *
+7849          BD+25 4272 195692 88808       13964           202741.4+252801203158.2+254816 67.51-08.15 6.34  +0.26 +0.08 +0.13   Am                 +0.032-0.033D+.009-018       50  1.8   0.4      *
+7850  2The CepBD+62 1821 195725 18897 767                   202754.2+623929202934.9+625939 97.76 13.80 4.22  +0.20 +0.16 +0.09   A7III              +0.044-0.013 +.038-007SB2O   59                 *
+7851 46Ome2CygBD+48 3154 195774 49741    I W       13128    202813.6+485258203118.8+491313 86.41  5.73 5.44  +1.55 +1.92         M2IIIab            +0.012-0.028      -064V?         4.7  56.8      *
+7852  2Eps DelBD+10 4321 195810106230 768          13137    202826.1+105748203312.8+111812 55.42-16.59 4.03  -0.13 -0.47 -0.11   B6III              +0.013-0.022 +.025-019V      50                 *
+7853          CD-3814108 195814212246                       202824.8-382554203455.5-380523  3.94-35.94 6.44  +0.26               A8III:             +0.018-0.005      +021                           
+7854          BD+51 2882 195820 32649                       202829.7+515808203121.1+521835 88.94  7.53 6.18  +1.01               K0III              +0.036+0.068      -010                           
+7855          BD-14 5781 1958381636863645                   202837.7-140353203411.7-134316 31.68-28.88 6.13  +0.54 -0.02         F6V                +0.069+0.070      -043                           
+7856          CD-3018013 195843212249                       202837.4-304855203447.4-302825 13.08-34.44 6.40  -0.08               B8V                +0.018-0.020      +003V?                         
+7857          BD+09 4579 195922125960                       202904.6+094303203353.6+100335 54.42-17.41 6.56  +0.08 +0.05         A2Vnn              -0.007+0.007      -013                           
+7858  3Eta DelBD+12 4378 195943106248              13147    202913.2+124104203357.0+130138 57.02-15.80 5.38  +0.07 +0.05 +0.02   A3IV s             +0.072+0.026 +.010-025V      70                  
+7859   Rho PavCP-61 6495 1959612548353647          Rho Pav  202912.4-615224203735.3-613148334.83-36.18 4.88  +0.43 +0.19         F5Del Del          +0.057-0.072 +.003+008    =< 49                 *
+7860          BD+56 2444 195964 32667    I                  202919.8+562624203146.5+564648 92.67 10.06 6.14  +1.43              gK5                 -0.018-0.007      -015V                          
+7861          BD+42 3778 195986 497723644                   202923.4+425101203252.3+431130 81.69  1.96 6.60  -0.11 -0.56         B4III              +0.007+0.001      -017SBO                       *
+7862          BD+20 4629 196035 88846                       202942.5+203833203410.0+205907 63.81-11.35 6.48  -0.14 -0.66         B3IV               +0.015-0.002      +003                           
+7863   Mu 1OctCP-76 1434 1960512578383650                   202942.0-763150204202.9-761050317.51-32.78 6.00  +0.44 +0.11 +0.25C  F4III-IV           +0.180-0.006      -036                           
+7864   Mu 2OctCP-75 1644 196067257836      W                202949.8-754147204143.7-752102318.45-33.05 6.55  +0.62 +0.25         G5III              +0.141-0.150      -013           0.6  17.0      *
+7865          BD-17 6027 196078163712                       202952.7-165210203532.2-163133 28.86-30.27 6.19  +0.20 +0.10         A7V                +0.083-0.021      -001       90                  
+7866 47    CygBD+34 4079 196093 70203    I W                203000.7+345430203354.2+351503 75.43-02.93 4.61  +1.60 +0.78 +0.99   K2Ib+B3V           +0.002-0.006 +.002-004SBO =< 50  5.6 117.6AC   3*
+7867          BD+41 3805 196134 49796                       203014.6+412554203348.4+414620 80.66  0.98 6.49  +1.00 +0.78         K0III-IV           -0.015-0.081      +001                           
+7868          BD+72  957 196142  97931538                   203026.5+721134203000.7+723154106.17 18.88 6.27  +1.35 +1.54        gK4                 -0.003-0.022      -043V?                         
+7869   Alp IndCD-4713477 196171230300 769  W                203032.1-473824203734.0-471729352.57-37.21 3.11  +1.00 +0.79 +0.36E  K0IIICNIII-IV      +0.053+0.066 +.046-001           8.8  66. AB   3 
+7870          BD+46 2977 196178 49804      W                203038.3+462102203354.9+464138 84.62  3.89 5.78  -0.16 -0.53         B9pSi              +0.011-0.001      -022       55  4.1 117.7       
+7871  4Zet DelBD+14 4353 196180106274              13163    203037.9+141945203518.5+144027 58.63-15.16 4.68  +0.11 +0.11 +0.05   A3V                +0.046+0.013 +.015-025V     119                  
+7872          CP-63 4602 196317254844                       203118.9-631519203951.4-625428333.09-36.20 6.22  +1.10               K1III              +0.012-0.078      +018V                          
+7873 70    AqlBD-03 4961 1963211446243648I                  203131.2-025347203643.6-023300 43.21-24.49 4.89  +1.60 +1.95         K5II               +0.013-0.011 +.016-010                           
+7874 26    VulBD+25 4299 196362 88884                       203151.1+253208203608.3+255257 68.13-08.87 6.41  +0.21 +0.16         A5III              +0.019+0.011      -019SBO =< 15                 *
+7875   Phi2PavCP-60 7419 196378254846                       203145.7-605300204002.6-603256335.98-36.63 5.12  +0.53 +0.01         F8V                +0.307-0.570 +.048-032        0                  
+7876          BD+51 2895 196379 327093646                   203155.6+513032203450.4+515115 88.89  6.83 6.11  +0.41 +0.42         A9II               -0.003-0.005      -013       34                  
+7877          CD-2514920 196385189503                       203155.0-252726203752.1-250632 19.54-33.67 6.36  +0.33               F0III              +0.064-0.001      -026       30                  
+7878          BD-00 4056 196426144632                       203210.8-001503203718.3+000549 45.81-23.32 6.22  -0.08 -0.39         B8IIIp              0.000-0.018      -023        5                  
+7879 73    DraBD+74  872 196502  9802 770          AF Dra   203249.8+743643203130.4+745717108.43 20.04 5.20  +0.07 +0.11         A0pSrCrEu         v+0.005-0.015 +.012+009SB1     6                 *
+7880 27    VulBD+25 4302 196504 889033649                   203248.6+260650203704.7+262743 68.73-08.70 5.59  -0.07 -0.22         B9V                +0.017-0.012      -022SB    300                  
+7881   Ups PavCP-67 3754 196519254854              13208    203246.7-670647204157.1-664539328.39-35.58 5.15  -0.06 -0.28         B9III              +0.009-0.025      +007V                         *
+7882  6Bet DelBD+14 4369 196524106316    I  14073           203251.5+141450203733.0+143543 58.88-15.65 3.63  +0.44 +0.08 +0.24   F5IV               +0.113-0.033 +.028-023SB1O   54  1.0   0.6AB   5*
+7883  5Iot DelBD+10 4339 196544106322                       203302.0+110143203749.1+112240 56.13-17.50 5.43  +0.06 +0.04 +0.02   A2V                +0.040-0.007 +.024-004SBO    48                 *
+7884 71    AqlBD-01 4016 196574144649    I  14081  13187    203310.4-012717203820.3-010619 44.81-24.14 4.32  +0.95 +0.69 +0.46   G7.5IIIa           +0.015-0.022 +.010-006SB1O < 19: 7.5  32.2      *
+7885 48    CygBD+31 4159 196606 70287      W                203327.8+311323203731.8+313421 72.92-05.73 6.32  -0.09 -0.40         B8IIIn             +0.010 0.000      -019V?     80  0.1 180.8AB   3*
+7886          BD+17 4370 196610106329    I         EU Del   203321.0+175500203754.6+181609 62.05-13.63 6.25  +1.48 +1.00 +2.48   M6III              +0.019+0.099      -066V?                        *
+7887          BD+31 4160 196629 70289      W                203328.9+311024203732.6+313119 72.89-05.76 6.49  +0.34 -0.03         F0V                -0.045-0.033      +001V     154  0.1 180.8AB   3*
+7888          BD+37 4002 196642 70288                       203337.8+375850203723.6+381943 78.31-01.64 6.20  +0.99 +0.81         K0III              +0.010-0.043      -037                           
+7889 14Tau CapBD-15 5743 196662163771       14099           203340.9-151820203916.4-145717 30.94-30.50 5.22  -0.12               B6III              +0.007-0.022D+.005-005SB    151  0.6   0.3AB   4*
+7890          BD-02 5328 196712144666                       203401.1-024553203913.2-022446 43.67-24.97 6.22  -0.10 -0.42         B7IIIne           v+0.006+0.009      -014SB2   250                 *
+7891 29    VulBD+20 4658 196724 889441539                   203403.3+205100203831.3+211204 64.59-12.05 4.82  -0.02 -0.08 -0.04   A0V                +0.071+0.005 +.002-018V      54                  
+7892  8The DelBD+12 4411 196725106342    I                  203400.7+125750203843.9+131854 57.95-16.61 5.72  +1.53 +1.73 +0.75   K3Ib               -0.001-0.004      -014V?                         
+7893          CD-3315119 1967372123331540                   203403.5-334708204019.8-332555  9.85-36.23 5.47  +1.12 +1.08         K1III              +0.024+0.036      +014V?                         
+7894 28    VulBD+23 4084 196740 88945                       203410.5+234554203831.9+240658 67.00-10.35 5.04  -0.14 -0.53         B5IV               +0.010-0.002      -022V?    330                  
+7895          BD+23 4085 196753 88946                       203412.6+231946203835.1+234050 66.65-10.61 5.91  +0.98               K0II-III+A3V       +0.015-0.007      +009SB  =< 50                 *
+7896  7Kap DelBD+09 4600 196755126059 772   14101           203416.3+094402203907.8+100510 55.18-18.47 5.05  +0.72 +0.21         G2IV               +0.321+0.023 +.026-052V    < 19: 4.8 203.6AC   3*
+7897  1    AqrBD-00 4064 1967581260623651I  14108           203417.4+000805203924.9+002911 46.47-23.58 5.16  +1.06 +0.97         K1III              +0.101-0.015 +.010-043V    < 19: 7.1  59.7AB   3*
+7898          CD-2416193 196761189549                       203414.7-240822204011.7-234626 21.25-33.77 6.37  +0.72 +0.23 +0.26E  G8V                +0.491+0.464 +.070-045V                          
+7899          BD+15 4220 196775106347       14106           203426.6+152912203905.0+155017 60.16-15.25 5.97  -0.14 -0.70?        B3V                +0.001-0.017      +002           5.6  22.5AC   5*
+7900 15Ups CapBD-18 5738 196777163779 773I                  203421.5-182927204003.0-180819 27.57-31.87 5.10  +1.66 +1.99 +0.89E  M2III              -0.022-0.021 +.019-013                          *
+7901 75    DraBD+80  659 196787  34083963  W                203431.5+810450202814.6+812522114.41 23.36 5.46  +1.02 +0.84         G9III              +0.033+0.015 +.012-006V?         1.3 197.7AC   3 
+7902          CD-2714959 196815189559                       203436.1-265953204036.0-263842 17.97-34.70 6.51  +0.57               F7V                +0.033-0.017      -006SB2                        
+7903          BD+21 4305 196821 88959              13201    203444.1+212753203910.6+214902 65.20-11.82 6.08  -0.06 -0.08         A0III              +0.019+0.014      -037SB?    20                  
+7904          BD+29 4121 196852 70323                       203452.5+295902203859.5+302004 72.12-06.72 5.68  +1.09 +0.99         K2III              -0.032-0.058 +.013+013                           
+7905          BD-16 5663 196857163783                       203455.4-162848204032.5-160727 29.82-31.23 5.80  +1.00 +0.74        gG7                 -0.067+0.071      -004                           
+7906  9Alp DelBD+15 4222 196867106357 774   14121  13207    203459.5+153333203938.3+155443 60.30-15.32 3.77  -0.06 -0.21 -0.04   B9IV               +0.066-0.002 +.008-003SB    162  7.5  43.4AC   6*
+7907          BD+10 4351 196885106360      W                203504.2+105338203951.8+111459 56.31-17.99 6.42  +0.55 +0.03         F8IV:              +0.060+0.088      -028    =< 15  4.0 191.9       
+7908 74    DraBD+80  660 196925  3413      W                203515.0+804430202927.5+810529114.11 23.16 5.96  +0.92 +0.60         K0III+F8V          +0.064+0.222 +.022-014SB         3.2 209.0AB   3*
+7909          CD-3216130 1969172123453652I                  203511.6-315705204123.7-313554 12.13-36.07 5.76  +1.53 +1.85         M0III              +0.113-0.065 +.023-097                           
+7910          CD-2615192 196947189575                       203526.1-262115204124.1-260000 18.79-34.69 6.28  +1.22               K2III              -0.002-0.029      -026                           
+7911          BD+40 4266 197018 49899       14126           203553.7+401333203933.3+403446 80.35-00.61 6.06  -0.16 -0.54         B6IIIpMn           +0.007 0.000D+.003-015V?         0.1   0.8AB   4*
+7912          BD+45 3233 197036 49898                       203600.7+451848203923.1+454001 84.37  2.52 6.58  -0.06 -0.55         B5IV               +0.005+0.001      -015V                          
+7913   Bet PavCP-66 3501 197051254862 775                   203557.0-663345204457.5-661211328.96-36.01 3.42  +0.16 +0.12         A7III              -0.046+0.012 +.035+010       86                 *
+7914          BD+19 4484 197076106373      W                203613.8+193418204045.2+195607 63.85-13.22 6.45  +0.63 +0.09 +0.34   G5V                +0.122+0.304 +.050-037V?      5  5.1  93.7      *
+7915          CD-4013994 197093212369                       203620.1-395457204253.0-393331  2.37-37.67 6.29  +1.08               K1III              +0.024-0.006      -007                           
+7916          BD+55 2444 197101 32763                       203624.9+553909203900.2+560018 92.63  8.80 6.48R                     F2Vn               -0.005-0.035      -001      120                 *
+7917          BD+29 4131 197120 88997       14149           203627.2+292657204036.2+294819 71.90-07.32 6.08R +0.14 +0.15         A2V                +0.008+0.036D+.010-030SB    110  4.5   0.9      *
+7918 10    DelBD+14 4393 197121106384              13227    203635.2+141337204116.2+143459 59.40-16.40 5.99  +1.24              gK4                 -0.006+0.002      -032                           
+7919          BD+42 3818 197139 49912                       203633.4+430621204003.1+432731 82.69  1.08 5.95  +1.19               K2III              -0.070-0.063      -019                           
+7920   Eta IndCP-5211752 197157246709 776                   203641.9-521641204402.3-515516346.69-38.16 4.51  +0.27 +0.09         A7III-IV-A9       v+0.158-0.058 +.049-002      122                  
+7921 49    CygBD+31 4181 197177 70362       14158           203659.6+315705204102.6+321826 73.96-05.88 5.51  +0.88               G8IIb              +0.007-0.014D+.004-029SB2        2.3   2.5AB   3*
+7922          BD+38 4187 197226 703673653  W                203715.7+384334204100.4+390456 79.34-01.74 6.51  -0.12 -0.49         B6III              +0.007 0.000      -015SBO   100  3.3  48.3      *
+7923          BD+17 4382 197249106396                       203722.6+170947204158.2+173117 62.00-14.85 6.22  +0.94 +0.57         G8III              +0.022+0.044      -002                           
+7924 50Alp CygBD+44 3541 197345 49941 777I  14172  Alp Cyg  203801.3+445522204125.9+451649 84.28  2.00 1.25  +0.09 -0.24 +0.10   A2Ia              t+0.003+0.002 -.006-005SBO    21 10.0  75.4      *
+7925          BD+59 2272 197373 189793654                   203810.4+600837204017.9+603019 96.41 11.33 6.01  +0.46 -0.06         F6IV               +0.015+0.190 +.021-013       30                  
+7926          BD+41 3856 197392 499463655                   203819.7+412131204156.5+414301 81.53-00.26 5.67  -0.12 -0.45         B8II-III           +0.006 0.000      -027SB     25                  
+7927          BD+34 4127 197419 70406              V568 Cyg 203827.2+350552204222.2+352722 76.64-04.18 6.66  -0.16 -0.68         B2IV-Ve            -0.019-0.009      -007V     115                 *
+7928 11Del DelBD+14 4403 197461106425 778          Del Del  203847.4+144257204327.5+150428 60.14-16.55 4.43  +0.32 +0.10 +0.17   A7IIIpDel Del      -0.019-0.043 +.013+009SB     41                 *
+7929 51    CygBD+49 3353 197511 32809       14189           203907.6+495851204212.6+502024 88.37  4.99 5.39  -0.10 -0.63         B2V                +0.003+0.005      -003V?     40  6.0   3.0AB   5*
+7930          BD+83  588 197508  3418                       203905.2+831645202903.1+833732116.56 24.35 6.19  +0.13?              A3/4Vm             +0.025-0.017      +010SB     38                  
+7931          CD-2715014 197540189641                       203913.0-273634204513.2-271450 17.60-35.85 6.50  +0.94               G8III              +0.008+0.006      -003V                          
+7932          BD+35 4234 197572 70423    I         X Cyg    203929.2+351338204324.2+353516 76.87-04.26 6.47  +1.23 +0.99 +0.64   F7Ib-G8Ib         v-0.010-0.003 -.008+010SB     22                 *
+7933          CD-3913960 1976302124163658                   203949.1-393344204620.1-391157  2.91-38.29 5.50  -0.10               B8/9V              +0.049-0.030      -030                           
+7934   Sig PavCP-69 3138 1976352548713660                   203950.3-690830204918.1-684635325.77-35.70 5.41  +1.12 +1.10 +0.32E  K0III              -0.069-0.049 -.000+019                          *
+7935          CD-3614396 197649212417                       203956.5-362857204618.6-360713  6.79-37.90 6.49  +0.39               F3IV               +0.044-0.055      -014SBO                       *
+7936 16Psi CapCD-2515018 197692189664 779                   204010.5-253749204605.7-251615 20.01-35.50 4.14  +0.43 +0.02 +0.20   F4V                -0.050-0.157 +.098+026V      37                  
+7937 17    CapBD-22 5523 1977251896673659                   204022.2-215239204610.0-213051 24.38-34.37 5.93  +0.04 +0.10         A0                 +0.024-0.021      +018                           
+7938          BD+60 2154 197734 18998                       204031.6+601427204239.7+603605 96.66 11.16 6.15  +0.01 +0.05         A2IV               -0.003-0.014      -007       55                  
+7939 30    VulBD+24 4229 197752 890843657I                  204032.8+245446204452.5+251614 68.82-10.81 4.91  +1.18 +1.18 +0.58   K2III              -0.028-0.182 +.006+031SB   < 17                 *
+7940          BD+56 2477 197770 32832                       204042.4+564509204313.5+570651 93.88  9.00 6.32  +0.33 -0.48         B2III              -0.013+0.003      -015SB                         
+7941          BD+17 4401 197812106458    I         U Del    204053.4+174335204528.2+180525 62.98-15.20 6.38  +1.68 +1.24         M5II-III           +0.002+0.005      -021                          *
+7942 52    CygBD+30 4167 197912 70467    I  14259           204132.0+302116204539.7+304311 73.30-07.63 4.22  +1.05 +0.89 +0.53   G9.5III            -0.010+0.028 +.015-001     < 17  5.0   6.1      *
+7943   Iot MicCD-4414145 1979372303791542  W                204142.4-442111204829.2-435919356.83-39.02 5.11  +0.35 +0.06         F1IV               +0.185-0.106 +.051-015V?     84 10.4   4.3       
+7944          BD+55 2462 197939 32849    I                  204146.3+560729204422.0+562917 93.47  8.50 5.78  +1.67 +1.86         M3III              +0.006-0.015      -028V?                         
+7945  4    CepBD+66 1318 197950 190043656                   204156.1+661738204311.0+663927101.72 14.68 5.58  +0.22 +0.05         A8V                +0.021+0.032 +.034-011      159                  
+7946          BD-03 5018 197954144802    I                  204151.6-025109204703.6-022912 44.66-26.72 6.27  +1.55 +1.97         K2                 -0.016-0.016      +028V                          
+7947 12Gam1DelBD+15 4255 197963106475       14279B          204200.3+154549204638.7+160728 61.49-16.57 5.14  +0.49 +0.08         F7V                -0.030-0.191 +.026-007V?  =< 25  1.0   9.8      *
+7948 12Gam2DelBD+15 4255 1979641064761541I  14279A          204201.1+154550204639.5+160727 61.50-16.58 4.27  +1.04 +0.97 +0.48   K1IV               -0.032-0.197 +.026-007V?      0  1.0   9.8      *
+7949 53Eps CygBD+33 4018 197989 70474 780I  14274           204209.8+333544204612.7+335813 75.94-05.71 2.46  +1.03 +0.87 +0.54   K0-III             +0.356+0.328 +.057-011SB?  < 17  9.3  54.9AB   3*
+7950  2Eps AqrBD-10 5506 198001144810 781                   204215.8-095143204740.6-092945 37.68-30.10 3.77   0.00 +0.02  0.00   A1V                +0.035-0.034 +.021-016V?     98                 *
+7951  3    AqrBD-05 5378 1980261448141543I         EN Aqr   204227.7-052338204744.2-050140 42.24-28.09 4.42  +1.65 +1.92 +1.31   M3III              +0.003-0.040 +.008-022V?                        *
+7952   Zet IndCD-4613718 1980482303913661                   204236.0-463548204929.0-461337353.95-39.24 4.89  +1.52 +1.87 +0.64E  K5III              +0.040+0.024 +.012-005                           
+7953 13    DelBD+05 4613 198069126222       14293  13299    204251.1+053827204748.3+060030 52.78-22.50 5.58  -0.02 -0.09         A0V                +0.010-0.006 +.002-007      202  3.6   1.4      *
+7954          BD+02 4250 198070126221                       204245.7+025619204747.8+031824 50.29-23.93 6.40  -0.02 -0.09         A0Vn               +0.031+0.021      -021      142                  
+7955          BD+57 2240 198084 32862 782  W                204252.1+571315204521.1+573447 94.43  9.06 4.51  +0.54 +0.10 +0.28   F8IV-V             -0.064-0.236 +.046-031SB2     0  5.7  66.4      *
+7956          BD+33 4028 198134 70499    I  14290  T Cyg    204311.2+340023204710.8+342227 76.39-05.62 4.92  +1.32 +1.47         K3III              +0.047+0.004 +.005-023V?   < 19: 6.5   9.9AB   3*
+7957  3Eta CepBD+61 2050 198149 19019 783I  14276           204315.3+612701204517.4+615020 97.86 11.64 3.43  +0.92 +0.62 +0.49   K0IV               +0.087+0.818 +.071-087     < 17  8.2  51.7      *
+7958          BD+45 3270 198151 50050      W                204316.7+460954204638.5+463154 85.83  2.06 6.30  +0.03 +0.04         A3V                -0.024-0.013      -006V?    125  1.9   0.5       
+7959          CP-62 6180 198160254883      W     A          204317.6-624759205138.3-622545333.32-37.62 6.28  +0.15 +0.08         A2-3IV-V           +0.076-0.047D+.009-016           0.2   2.4      *
+7960          CP-62 6180 198161254884      W     B          204318.1-624759205138.8-622545333.32-37.62 6.59  +0.17 +0.06         A2-3IV-V           +0.078-0.043D+.009-010           0.2   2.4      *
+7961          CD-2615282 198174189733                       204321.4-260901204917.6-254653 19.65-36.34 5.86  -0.07 -0.46         B7IIIp             +0.015-0.021      -012                           
+7962          BD+52 2799 198181 328771544                   204327.2+523752204621.2+525943 90.87  6.12 6.33  +1.12               K0                 -0.081-0.103 +.008-029                           
+7963 54Lam CygBD+35 4267 198183 70505       14296           204330.7+360723204724.5+362927 78.08-04.34 4.53  -0.11 -0.49 -0.11   B5Ve               +0.009-0.005 +.008-023SB?   155  1.3   0.9AB   3*
+7964          BD-18 5783 1982081639103663I W                204340.2-182418204920.5-180209 28.63-33.89 6.21  +1.42               K3III              +0.002-0.030      +044V?         6.5  31.6       
+7965   Alp MicCD-3414660 198232212472      W       13329    204343.4-340859204958.1-334647  9.88-38.26 4.90  +1.00 +0.73         G7III              +0.010-0.025 +.012-015           5.0  20.5       
+7966          BD+45 3275 198237 50060    I  14298           204354.9+451244204720.8+453447 85.16  1.37 6.40  +1.61 +2.02         K3III              +0.005-0.025      -006           6.3  12.9       
+7967          BD+69 1127 198236 19018                       204356.7+692313204433.1+694507104.41 16.37 6.41R                     G8III              -0.026-0.027 +.002-009                           
+7968   Iot IndCP-5211782 198308246762                       204416.4-515850205130.1-513630346.98-39.34 5.05  +1.13 +1.05         K1II-III           +0.007-0.014 +.001+021                           
+7969          BD+47 3188 198345 500733662I  14318           204431.7+472747204749.3+474955 86.97  2.72 5.57  +1.46 +1.78         K5III              -0.006-0.015      -030SB         9.0  18.3       
+7970          CD-3216236 198356212487    I                  204437.1-322530205047.1-320316 12.08-38.12 6.36  +1.54 +1.81         K5III              -0.016-0.061      -004                           
+7971          CD-3814250 198357212488                       204435.5-381707205100.7-375448  4.68-39.06 5.52  +1.38 +1.63?        K3II               -0.011-0.022      +017SB                         
+7972          BD+51 2954 198387 32897       14322           204453.6+520232204752.8+522426 90.55  5.58 6.27  +0.89 +0.55         G7IV               +0.068-0.158 +.018-041V          5.2  12.2      *
+7973 15    DelBD+12 4472 198390106536      W                204451.8+121016204937.8+123243 58.86-19.23 5.98  +0.43 -0.11         F5V                +0.057+0.098 +.030+002    =< 10  5.2 108.0AC   4 
+7974 14    DelBD+07 4556 1983911262653664          13337    204454.1+072933204948.3+075151 54.75-21.90 6.33  +0.02 -0.02         A1V s              +0.032+0.011      -030SBO    32                 *
+7975          BD+05 4626 198404126267      W                204500.8+051022204959.1+053241 52.67-23.20 6.21  +0.98 +0.79         K0                 +0.040+0.006      -022           2.5  79.9       
+7976          BD-13 5773 1984311639243665                   204511.1-125455205041.8-123242 34.83-32.07 5.88  +1.07 +0.94        gK1                 +0.126-0.070 +.021-044SB                         
+7977 55    CygBD+45 3291 198478 50099       14337  V1661 Cyg204531.8+454435204856.3+460651 85.75  1.49 4.84  +0.41 -0.45 +0.31   B3Ia              e+0.004 0.000 +.017-007V      35  6.3  21.3      *
+7978          BD+51 2957 198513 32908       14336           204541.5+513221204842.7+515438 90.24  5.17 6.29  -0.07 -0.56         B8Vnp              +0.006+0.007      -025V?    100  2.3   4.0      *
+7979   Bet MicCD-3315245 198529212499                       204546.1-333307205158.8-331038 10.73-38.57 6.04  +0.03               A2Vn               +0.015+0.014      -012V?                         
+7980 18Ome CapCD-2715082 1985421897811546I         13351    204551.3-271736205149.3-265509 18.46-37.18 4.11  +1.64 +1.93 +0.94   M0-III-IIIbBa0.2   -0.006-0.001 +.001+009V                         *
+7981          BD+17 4431 198552106562                       204601.0+174040205037.0+180305 63.70-16.21 6.52R +0.04  0.00         A1V s              +0.076+0.016      +013       53                  
+7982  4    AqrBD-06 5604 198571144877       14360  13350    204607.6-060002205125.7-053735 42.13-29.18 5.99  +0.46 +0.03         F5V+F7V            +0.099-0.001 +.028-025           0.9   1.1AB   4*
+7983          BD+46 3067 198625 50119       14350           204631.7+461718204954.7+463940 86.28  1.71 6.33  -0.07 -0.57         B4Ve               +0.008 0.000      -015           5.3  19.2      *
+7984 56    CygBD+43 3739 198639 501213666  W                204631.7+434057205004.9+440334 84.29  0.03 5.04  +0.20 +0.12 +0.09   A4mDel Del         +0.126+0.133 +.025-021V?     90  6.0  75.5      *
+7985  5    AqrBD-06 5606 198667144889              13360    204651.4-055256205208.7-053025 42.35-29.28 5.55  -0.08 -0.27         B9III              +0.002 0.000 -.009-002V      50                  
+7986   Bet IndCP-58 7788 198700246784 785  W                204659.8-584953205448.6-582715338.16-38.85 3.65  +1.25 +1.23         K1II               +0.017-0.026 -.005-005V?         8.8  17.3       
+7987          CD-4014078 198716212522                       204709.8-401103205340.2-394836  2.30-39.76 5.35  +1.32               K2III              +0.044-0.102 +.020+020                           
+7988          BD+27 3890 198726 89216    I         T Vul    204713.4+275232205128.2+281502 72.13-10.15 5.77  +0.72 +0.40 +0.38   F5Ib               +0.003-0.003 +.006-001SB                        *
+7989          CD-2416328 198732189801       14380           204709.3-240928205301.2-234659 22.33-36.58 6.33  +0.88 +0.56         K0III              +0.099-0.053      -040           2.1   1.8      *
+7990  6Mu  AqrBD-09 5598 1987431448951547  S                204715.6-092131205239.2-085900 38.84-30.98 4.73  +0.32 +0.11 +0.17   A3m                +0.044-0.030 +.019-009SBO    46                 *
+7991          CD-3117917 198751212521                       204718.4-310543205325.0-304307 13.89-38.40 6.35  +1.09               K1III              +0.036-0.008      -007V?                         
+7992          CD-5112748 198766246786                       204726.7-510618205435.0-504340348.07-39.89 6.24  -0.12               B5IV               +0.002-0.036      -004                          *
+7993          BD+63 1663 198781 190513667                   204732.0+634009204917.4+640232 99.94 12.61 6.45  +0.07 -0.77         B0.5V              -0.006-0.004      -027                           
+7994          BD-12 5854 198802163953      S                204737.4-115706205305.6-113425 36.15-32.20 6.38  +0.67 +0.14         G1V                +0.050+0.046      -001V                0.2       
+7995 31    VulBD+26 4017 198809 89228    I         13373    204750.8+264321205207.7+270549 71.31-10.98 4.59  +0.83 +0.47 +0.46   G7IIIFe-1          -0.067-0.065 +.036+001SB   < 19:                 
+7996          BD+32 3974 198820 70596                       204756.1+322823205200.3+325057 75.83-07.36 6.44  -0.15 -0.62         B3III              -0.009+0.006      -018V?                         
+7997          CD-2816975 198853189815    I                  204806.8-281811205406.8-275532 17.39-37.93 6.41  +1.60 +1.90         M4III              +0.027-0.025      +025V?                         
+7998          BD-07 5433 198949144915                       204838.6-071603205358.4-065323 41.19-30.33 6.44  +0.37  0.00         F1IV               +0.033-0.027      -008       67                  
+7999          BD+29 4221 198976 89241                       204855.4+291622205307.4+293858 73.47-09.56 6.34  +1.09               K2                 -0.001-0.047      -010                           
+8000 19    CapBD-18 5805 199012163975    I                  204908.8-181808205447.9-175523 29.33-35.06 5.78  +1.12 +1.00         K0III              -0.051-0.020      -039V                          
+8001 57    CygBD+43 3755 199081 50180              13388    204942.5+440031205314.8+442314 84.90-00.19 4.78  -0.14 -0.58 -0.13   B5V                +0.010+0.001      -020SB2O   69                 *
+8002 76    DraBD+81  718 199095  3458 915          13319    204950.5+820940204235.2+823152115.73 23.46 5.75   0.00 -0.04         A0V                +0.029+0.023      -020SB     27                  
+8003          BD+44 3617 199098 50182              13391    204948.9+444810205318.6+451055 85.52  0.31 5.45  +1.10 +0.93         K0II               +0.014+0.003 -.005-024SB                         
+8004          BD+41 3922 199099 50183                       204947.7+420153205326.4+422437 83.41-01.49 6.66  -0.04 +0.01         A1V                +0.011+0.002      -007       98                  
+8005          BD+32 3980 199101 706453668I W                204950.7+330327205353.9+332616 76.54-07.29 5.47  +1.52              gK5                 -0.021+0.038      -010V          4.0 187.7       
+8006          BD-01 4075 199124144941              EM Aqr   204958.1-014516205508.1-012224 46.88-27.92 6.55  +0.29 +0.06         A9Vn               -0.002+0.020      -009      173                 *
+8007          BD+27 3909 199140 89265              BW Vul   205007.6+280831205422.4+283119 72.75-10.48 6.56  -0.13 -0.90         B2IIIe            v+0.007-0.010      -006V      26                 *
+8008 32    VulBD+27 3911 199169 89272 786I         13398    205017.8+274038205433.6+280327 72.41-10.80 5.01  +1.48 +1.79         K4III               0.000-0.002 +.003+008V?   < 17                  
+8009          BD+40 4354 199218 50209       14413           205038.1+401920205422.3+404211 82.21-02.72 6.70  -0.07 -0.41         B8Vnne             +0.010+0.003      -022V?    350  3.9   5.8      *
+8010          BD+03 4461 199223126373       14430           205040.2+040902205540.7+043158 52.58-24.94 6.05  +0.82 +0.49         G6III-IV           +0.070+0.010 -.012-031V          1.4   2.1      *
+8011 17    DelBD+13 4572 1992531066653669I         13408    205052.6+132024205536.7+134317 60.77-19.74 5.17  +1.12 +0.96         K0III              +0.021-0.014 +.017-010     < 19:                 
+8012 16    DelBD+12 4501 199254106666       14429           205052.2+121110205538.6+123407 59.78-20.42 5.58R +0.12 +0.07         A4V                +0.040+0.018      +002SB    135  6.5  36.0      *
+8013          CD-2615344 199260189856              13412    205050.8-264039205647.3-261747 19.59-38.09 5.70  +0.50 -0.04         F7V                +0.093-0.065 +.039-016                           
+8014          BD-04 5307 199280144957                       205104.3-035640205618.3-033341 44.88-29.25 6.57  -0.10 -0.29         B8Vn               +0.027+0.018      -029V?                         
+8015  7    AqrBD-10 5553 199345144968    I  14449  13419    205129.8-100451205654.0-094151 38.63-32.24 5.51  +1.47 +1.71        gK5                 -0.003-0.010      -033V?         3.5 176.6AC   3*
+8016          BD+80  672 199437  3467    I         13369    205207.9+801038204733.4+803308114.01 22.27 5.39  +1.12 +1.06         K1III              -0.031-0.037 +.011-026                           
+8017          BD-00 4132 199442126396       14457           205203.5+000452205710.6+002749 48.95-27.42 6.05  +1.22 +1.36         K2III              +0.018-0.065      -026V?         5.4  26.2AB   3*
+8018          BD-16 5741 1994431640131548                   205204.8-162459205740.6-160154 31.78-35.00 5.87  +0.18 +0.12 +0.06   A2m                +0.053+0.001      -001V      76                 *
+8019          CP-68 3398 199475254918                       205218.9-683553210128.1-681235325.99-36.94 6.37  +0.10 +0.11         A2V                -0.010-0.002      +009                           
+8020          BD+46 3111 199478 50246                       205227.1+470203205549.8+472504 87.51  1.42 5.67  +0.47 -0.33 +0.39   B8Ia              t-0.003-0.002      -015V                         *
+8021   Alp OctCP-77 1474 199532257879 787                   205236.4-772418210443.0-770126315.96-33.65 5.15  +0.49 +0.13         A7III+G2III        +0.006-0.369 +.025+045SB2O   57                 *
+8022          BD+50 3232 199578 33001                       205304.2+504126205612.9+510430 90.34  3.73 6.63  -0.10 -0.50         B5V                +0.017+0.004      -018                           
+8023          BD+44 3639 199579 50263    I                  205303.1+443224205634.7+445530 85.70-00.30 5.96  +0.05 -0.85         O6V((f))           -0.005+0.008      -006SBO   170                 *
+8024          BD-15 5848 199603164027              DV Aqr   205309.6-145210205841.9-142858 33.64-34.63 6.01  +0.23 +0.11         F0IV               -0.042-0.002      +010SBO                       *
+8025          BD+50 3233 199611 330043670   14460           205315.0+502040205625.5+504343 90.10  3.49 5.81  +0.30 +0.04         F0III              +0.041-0.015      -015SB    109  7.7   7.2      *
+8026          BD+48 3249 199612 50262                       205309.5+484840205625.9+491145 88.93  2.49 5.90  +1.04 +0.92         G8II-III           +0.009+0.007 +.004-015V                          
+8027          CD-5112778 1996232468203673                   205314.7-513926210021.5-511555347.25-40.75 5.76  +0.47 -0.06         F5IV-V             -0.084+0.130      -023                           
+8028 58Nu  CygBD+40 4364 199629 50274 788                   205326.6+404655205710.4+411002 82.91-02.82 3.94  +0.02  0.00  0.00   A1Vn               +0.012-0.016 +.010-028SB    241                  
+8029          BD+56 2515 199661 330053671                   205336.5+563009205617.0+565315 94.82  7.47 6.23  -0.18 -0.70         B2.5IV             +0.004+0.002      -019                          *
+8030 18    DelBD+10 4425 199665106712      W                205336.9+102712205825.9+105021 58.69-21.98 5.48  +0.93              gG6                 -0.051-0.036      +000V          4.6 198.2AB   3 
+8031          CD-3614530 1996842126083674                   205341.0-363059205959.7-360747  7.25-40.63 6.11  +0.39 -0.03         F5V                +0.106-0.061      +016                           
+8032 33    VulBD+21 4424 199697 893321549I                  205348.0+215621205816.4+221933 68.36-15.04 5.31  +1.40       +0.74   K3.5III            -0.003-0.003      -028                           
+8033 20    CapBD-19 5982 199728164043              AO Cap   205355.2-192522205936.1-190207 28.54-36.52 6.25  -0.13               B9pSi              +0.011-0.013      -010                          *
+8034  1Eps EquBD+03 4473 199766126428       14499AB         205404.6+035436205904.4+041737 52.87-25.78 5.23  +0.46 +0.02 +0.28   F6IV               -0.109-0.148 +.021+018SB1O   54  0.3   1.0AB   4*
+8035          BD+43 3777 199870 50298                       205444.6+440455205819.5+442818 85.55-00.83 5.55  +0.97 +0.83         K0IIIbFe-0.5       +0.106+0.072 +.016-023SBO                       *
+8036          BD+41 3949 199892 50303                       205449.0+413307205830.8+415625 83.66-02.51 6.16  -0.08 -0.46         B7III              -0.001+0.013      -033SBO    25                 *
+8037          BD+16 4425 199941106738      W                205511.6+162606205950.8+164927 64.05-18.71 6.66  +0.38 -0.13         F4III              +0.041-0.014      +002       40  2.7  70.7       
+8038          BD+06 4718 199942126447      W                205508.5+070734210003.9+073059 55.97-24.20 5.99  +0.26 +0.09         F1Vp               +0.029+0.020D+.009-020V     145  1.1   0.2      *
+8039   Gam MicCD-3216353 1999512126361550I W                205509.5-323855210117.5-321528 12.34-40.34 4.67  +0.89 +0.54 +0.32E  G6III              -0.002+0.005 +.034+018           9.0  25.7      *
+8040          BD+49 3426 199955 33034       14504           205517.8+500425205830.1+502744 90.11  3.06 5.61  -0.15 -0.51         B5Vn               +0.013+0.010 +.008-021V          0.9   1.8AB   3*
+8041 11    AqrBD-05 5433 199960145022 789                   205517.9-050700210033.8-044349 44.30-30.75 6.21  +0.63 +0.24         G1V                +0.051-0.137 +.033-017V?  =< 10                  
+8042          CD-4314325 200011230492    I'W                205535.5-432327210212.6-430007358.19-41.49 6.64  +0.68 +0.17         G3IV+K0IV          +0.060-0.103 +.018-031           0.3  57.5      *
+8043          BD+75  764 200039  99113672                   205555.1+753219205444.3+755532110.14 19.35 6.05  +0.93               G5III              +0.029+0.043      -025                           
+8044          BD+18 4675 2000441067473675I W       13454    205553.4+185626210027.7+191946 66.23-17.29 5.65  +1.61               M3IIIab            -0.016-0.063 +.010-015V?         3.9  46.6       
+8045          CD-2715197 200052189942                       205549.2-271619210145.3-265252 19.22-39.32 6.05  +0.06               A7V:m:             +0.015-0.023      -004                          *
+8046          CD-3914079 200073212653                       205602.4-385508210227.2-383150  4.15-41.35 5.94  +1.11               K0IV               +0.163-0.158 +.018+039V                          
+8047 59    CygBD+46 3133 200120 503351551   14526  V832 Cyg 205625.4+470750205949.6+473116 88.03  0.97 4.74  -0.05 -0.94 -0.01   B1ne              v+0.006+0.002      +001SB    374  4.4  20.1AB   4*
+8048   Zet MicCD-3914089 200163212666 790                   205634.6-390119210258.0-383754  4.03-41.46 5.30  +0.41               F3V                -0.028-0.111 +.024+005V?     47                  
+8049          BD+58 2201 200205 330483676I                  205657.4+590251205925.4+592619 97.06  8.79 5.51  +1.40 +1.64        gK4                 +0.044+0.015 +.002-017V                          
+8050          CD-2817077 200245189966       14565           205712.4-280729210310.2-274355 18.25-39.83 6.25  +0.95 +0.74         K0III              +0.035-0.044      -030           0.6   0.1      *
+8051          BD+35 4357 200253 707943677                   205713.9+353802210112.9+360134 79.51-06.77 5.97  +0.98               G5III              -0.005-0.005      -010SB                         
+8052          CP-76 1473 200266257887                       205715.3-763640210847.9-761245316.70-34.23 6.58  +1.23 +1.18         K1III              -0.027-0.022      +037                           
+8053 60    CygBD+45 3364 200310 50359       14549  V1931 Cyg205741.4+454547210110.9+460921 87.15-00.10 5.37  -0.21 -0.93         B1Ve              v+0.006+0.008      -012SB    320  4.5   2.6      *
+8054          BD-01 4095 200340145050                       205750.3-011909210259.6-005529 48.45-29.38 6.50  -0.10 -0.49         B6V                +0.007-0.002      -012V                          
+8055   Mu  IndCP-55 9509 2003652468543680                   205753.0-550721210514.2-544338342.58-40.96 5.16  +1.21 +1.22         K2III              +0.010-0.046 +.023+012                           
+8056          BD+00 4648 200375126491       14573           205758.6+010819210303.0+013155 50.85-28.11 6.25  +0.48 +0.01         F5V                -0.116-0.053 +.035+007           0.5   1.3AB   3*
+8057          BD+14 4518 200430106796    I                  205818.6+142006210301.8+144348 62.77-20.58 6.31  +1.67 +2.04         M1III              +0.021+0.005      -039                           
+8058 12    AqrBD-06 5664 200496145064       14592           205847.3-061312210404.6-054924 43.66-32.04 7.31H                     A3V                +0.003+0.012D+.003-005           1.9   2.7     3*
+8059 12    AqrBD-06 5664 200497145065       14592           205847.3-061309210404.7-054923 43.66-32.04 5.89H +0.68 +0.41         G4III              +0.018-0.009D+.003+001V          1.9   2.7     3*
+8060 22Eta CapBD-20 6115 200499189986      W                205842.9-201501210424.3-195118 28.05-37.86 4.84  +0.17 +0.09 +0.07   A5V                -0.034-0.037 +.055+024V      71  1.3   0.3       
+8061          CP-73 2192 200525257890      W                205854.1-733352210922.3-731023320.01-35.61 5.68  +0.59 +0.10         F8-G0V             +0.432-0.331 +.048-011           0.0   0.1AB   3*
+8062          BD+44 3679 200527 50381    I                  205849.7+442347210224.1+444728 86.27-01.17 6.19  +1.69 +1.84 +1.56   S4/1III            -0.014+0.003      +001                          *
+8063          BD+38 4325 200577 70832                       205911.9+381543210304.8+383927 81.75-05.32 6.07  +1.01 +0.79         G8III              +0.016-0.008      -003V?                         
+8064          BD+45 3374 200595 50390       14585           205917.4+452712210248.5+455056 87.11-00.52 6.48  -0.15 -0.55         B3Vn               -0.005-0.001 +.009-012SB         0.0   0.2AB   5*
+8065          BD+56 2524 200614 33078       14575           205923.6+561629210209.1+564011 95.18  6.72 5.83  -0.07 -0.34         B8III              +0.016+0.004D+.004-021       60  0.6   1.6      *
+8066  3    EquBD+04 4606 200644126518    I W                205935.8+050620210434.7+053010 54.83-26.26 5.61  +1.65 +2.02         K5III              +0.017-0.002 +.011-016           6.9  81.7      *
+8067          BD+02 4297 200661126519                       205938.7+023240210441.7+025631 52.45-27.69 6.42  +1.05 +0.89         K0                 +0.013+0.001      -010                           
+8068          BD+01 4418 2006631265223681                   205940.7+015227210445.4+021611 51.82-28.07 6.33  +0.97 +0.62         G5                 +0.098-0.065      -012                           
+8069   Eta MicCD-4114379 2007022305233684  W                205955.2-414705210625.5-412310  0.37-42.25 5.53  +1.35 +1.52         K3III              +0.026-0.016      +011           2.8 132.9AC   3 
+8070   Del MicCD-3018382 2007182127093683                   205958.9-303120210601.2-300730 15.35-40.95 5.68  +1.03               K0/1III            +0.041-0.068      +022V?                         
+8071          BD+41 3987 200723 50409      W                210007.4+411357210352.1+413741 84.08-03.47 6.33  +0.38 +0.13         F3IV               +0.001-0.054      -008V      75  2.3  57.3AB   3*
+8072          BD+49 3448 200740 33091                       210010.3+495714210326.0+502107 90.55  2.40 6.37  +0.98 +0.76         K0                 +0.058+0.053      -022                          *
+8073          CP-64 4094 200751254941                       210014.2-641948210832.9-635544330.81-39.04 5.76  +1.18 +1.15         K0III              +0.007-0.011      -020                           
+8074          BD+46 3159 200753 50408                       210015.7+462804210343.3+465143 87.97  0.04 6.32  +0.25               F0IVn              -0.055-0.110      -015SB2   190                  
+8075 23The CapBD-17 6174 2007611641321552                   210019.6-173749210556.8-171358 31.31-37.29 4.07  -0.01 +0.01 -0.02   A1V                +0.083-0.060 +.017-011SB    123                 *
+8076          CD-3216398 200763212716    I                  210017.9-324429210624.7-322030 12.47-41.42 5.18  +1.10               K2III              -0.001+0.010 +.012+003                           
+8077  4    EquBD+05 4697 200790126535      W                210029.3+053347210526.7+055730 55.39-26.18 5.94  +0.54 +0.06         F8V                -0.090-0.129 +.015-022V?  =<  6  6.4  34.9      *
+8078          BD+52 2859 200817 330983682                   210044.3+525315210347.6+531710 92.78  4.30 5.90  +0.99               K0III              +0.040+0.037      -016V                          
+8079 62Xi  CygBD+43 3800 200905 50424 792I         13518    210117.5+433144210455.9+435540 85.93-02.08 3.72  +1.65 +1.83 +0.90   K4.5Ib-II         e+0.008+0.001 +.007-020SB   < 17                 *
+8080 24    CapCD-2515235 200914190025 791I  14632           210116.8-252420210707.7-250021 21.98-40.01 4.50  +1.61 +1.93 +0.98   M0.5III            -0.023-0.043 +.022+032V          7.1  26.2       
+8081          CP-73 2195 200924257893                       210116.8-725653211120.7-723239320.62-36.02 6.20  +1.08 +1.03         K1III              +0.026-0.022      -015V?                         
+8082          BD+26 4073 201051 894593686                   210202.4+263126210623.5+265528 73.23-13.55 6.12  +1.05 +0.62         K0II-III           +0.044-0.017      -006                           
+8083          BD-18 5862 201057164156              13549    210207.6-175124210744.6-172719 31.25-37.77 6.17  +0.02?              A0V                +0.018-0.027      -021V?    130                  
+8084          BD+30 4318 201078 709173687I         DT Cyg   210218.4+304701210630.3+311105 76.55-10.78 5.82  +0.56       +0.32   F7.5Ib-II         v+0.007-0.004      +000V       9                 *
+8085 61    CygBD+38 4343 201091 70919 793   14636A V1803 Cyg210224.8+381531210654.6+384445 82.25-05.81 5.21  +1.18 +1.11 +0.65   K5V                +4.136+3.203 +.292-064V    < 17  0.8  28.7AB   6*
+8086 61    CygBD+38 4344 201092          I: 14636B 13546    210226.3+381510210655.3+384436 82.25-05.81 6.03  +1.37 +1.23 +0.83   K7V                +4.126+3.208 +.294-064V?  =< 25  0.8  28.7AB   6*
+8087 25Chi CapBD-21 5933 2011841900503690  W                210250.0-213544210833.6-211137 26.84-39.21 5.30  +0.01 -0.03         A0V                +0.022-0.060 +.046-007V?    199: 5.7  67.0AB   4 
+8088          BD+15 4340 2011961068533689                   210251.4+151528210733.6+153931 64.27-20.89 6.34  +1.01 +0.78         K2IV               +0.049-0.059      -034                           
+8089 63    CygBD+47 3292 201251 504563688I  14649  13548    210309.3+471447210636.1+473854 88.88  0.20 4.55  +1.57 +1.75 +0.82   K4Ib-IIa           +0.008+0.001 +.008-026V          8.3  15.7       
+8090          BD+06 4754 2012981265663692I                  210331.7+063507210828.2+065922 56.80-26.22 6.15  +1.66 +1.98         K5III              -0.006+0.003      +020                           
+8091 27    CapBD-21 5940 201352190069              13566    210350.0-205729210933.0-203323 27.71-39.23 6.25  +0.38               F1IV               +0.120-0.124      -043V?                         
+8092   Omi PavCP-70 2835 2013712578961554                   210358.0-703202211320.5-700735323.27-37.19 5.02  +1.58 +1.56 +0.90E  M1-2III            +0.040-0.025 +.008-019SB1                       *
+8093 13Nu  AqrBD-11 5538 201381164182 794I                  210408.8-114636210935.7-112218 38.45-35.77 4.51  +0.94 +0.70 +0.46   G8III              +0.095-0.015 +.017-012     < 17                  
+8094          BD+29 4324 201433 70968       14682  V389 Cyg 210424.3+294805210838.9+301221 76.11-11.77 5.59  -0.10 -0.26         B9VpSi             +0.025-0.017 -.006-026SBO    10  2.3   3.4AB   4*
+8095          BD+02 4311 201507126587                       210455.0+023212210958.3+025636 53.26-28.80 6.45  +0.37 +0.06         F5IV               +0.040+0.017      -044                           
+8096          BD-09 5674 201567145171                       210523.4-094535211046.9-092114 40.83-35.15 6.27  +1.16 +1.21         K0III              +0.114-0.056      -040                           
+8097  5Gam EquBD+09 4732 2016011265931555   14702ABGam Equ  210528.7+094343211020.5+100754 59.93-24.76 4.69  +0.26 +0.10 +0.11   F0IIIp            v+0.057-0.153 +.028-017V       8  1.2 352.5AD   4*
+8098  6    EquBD+09 4735 201616126597       14702D          210539.7+093828211031.2+100256 59.89-24.85 6.07  +0.02 +0.04         A2V s              -0.009+0.015 +.010+007       60  1.2 352.5AD   4 
+8099          BD+70 1164 201636  99573693                   210547.5+710151210623.3+712555106.95 15.95 5.87  +0.40  0.00         F3IV               -0.048-0.116 +.030+002       60                  
+8100          CD-4014216 201647230575                       210548.4-404020211213.6-401610  1.93-43.33 5.83  +0.45 +0.01         F5IV               +0.047-0.222 +.042+011V?                         
+8101          BD+21 4486 201671 89505       14710A          210601.7+220250211032.0+222717 70.33-17.15 6.68  +0.03 -0.06         A1V                +0.020-0.008      -012SB     86  1.0  18.0      *
+8102          BD-15 5908 201707164204              EW Aqr   210609.9-145252211141.3-142820 35.19-37.52 6.48  +0.28 +0.14         F0Del Del:         +0.039+0.004      -039V?    120                 *
+8103          BD+44 3718 201733 50521              Var?     210623.2+450542210958.6+453009 87.70-01.68 6.63  -0.16 -0.66         B4IVpe             +0.004-0.001      +009                          *
+8104          CD-3914152 201772212793                       210639.2-394955211303.1-392531  3.10-43.46 5.26  +0.44               F5IV+F6V           +0.186-0.123 +.029-044SB2     0                  
+8105          BD+35 4426 201819 71032       14724  Var      210702.5+355326211103.9+361757 81.05-08.08 6.54  -0.14 -0.92         B1Vp               +0.021-0.015      -006           5.7  21.5      *
+8106          BD+52 2880 201834 33185                       210710.0+530917211015.6+533348 93.64  3.78 5.73  -0.12 -0.45         B9III              +0.026+0.001      -021SB                         
+8107          BD+47 3322 201836 50536       14720           210702.6+471702211031.0+474131 89.36-00.25 6.46  -0.01 -0.35         B6IV              e+0.004-0.007      -009      120  0.8 136.1AC   6*
+8108          CD-3614676 201852212800                       210704.2-365004211318.9-362526  7.22-43.34 5.96  +0.98 +0.74         K0III              +0.029-0.013      +000                           
+8109          BD+62 1903 201888 19223                       210720.5+625315210928.9+631744100.81 10.41 6.54  -0.13 -0.48         B7III              +0.013+0.005      -024                           
+8110          CD-2817178 2019011901291556I                  210721.6-280138211317.3-273710 19.06-41.98 5.42  +1.42 +1.69         K5III              +0.099-0.116      -042V                          
+8111          CP-75 1697 2019062579043697                   210722.5-754540211816.1-752048317.29-35.15 6.63  +0.03  0.00         A1V                +0.013-0.035      +016                           
+8112          BD+77  800 201908  9959 795                   210730.2+774315210529.3+780735112.40 20.19 5.91  -0.07 -0.24         B8Vn               +0.020+0.029      -016SB    210                 *
+8113          BD+67 1291 202012 19229    I         T Cep    210813.1+680500210932.0+682925104.81 13.84 7.33  +1.49 +0.33         M7IIIe            v-0.032-0.067 +.002-012V                         *
+8114          CP-5310015 202103246929 796  W                210837.4-534037211545.9-531547344.11-42.76 5.75  +0.19               A6IV               +0.035-0.017      -013SB    103  0.1   0.2      *
+8115 64Zet CygBD+29 4348 202109 71070 797I W                210840.7+294900211256.2+301337 76.75-12.45 3.20  +0.99 +0.76 +0.48   G8+III-IIIaBa0.6   +0.001-0.056 +.027+017SB   < 17  7.9  91.2AC   4*
+8116          BD+15 4375 202128106930       14761           210846.5+153414211328.8+155857 65.49-21.80 6.27  +0.24 +0.09         A7Vn               +0.043-0.023 -.005-030V          0.1   0.2      *
+8117          CD-4114440 202135230596                       210849.1-405512211514.7-403023  1.61-43.90 6.21  +1.14 +1.10         K2III              +0.139-0.009      -042                           
+8118          BD-11 5553 202149164240                       210852.1-110107211416.7-103619 39.92-36.48 6.77  -0.08 -0.31         B9pHgMn            +0.014+0.004      -004       35                  
+8119          BD+59 2334 202214 33210       14749  13598    210915.4+593431211148.2+595911 98.52  7.99 5.64  +0.11 -0.77         B0II                0.000-0.005D+.002-016       46  1.0   1.0AB   5*
+8120          BD+36 4470 202240 71086                       210925.2+361314211326.3+363801 81.63-08.20 6.05  +0.21 +0.21         F0III              -0.018+0.006      -013       23                  
+8121          BD-00 4186 202259145229    I         13614    210929.2-001917211437.0+000532 51.22-31.32 6.38  +1.61 +1.92         M1III              +0.028-0.009      -124V                         *
+8122          BD-17 6216 202261164249                       210930.9-174532211506.6-172042 32.19-39.37 6.04  +0.96 +0.68         G5                 -0.004-0.020      +004V?                         
+8123  7Del EquBD+09 4746 202275126643       14773           210936.6+093606211428.9+100025 60.50-25.65 4.49  +0.50 -0.01 +0.28   F5V+G0V            +0.049-0.305 +.058-015SB2O   10  0.3   0.2AB   3*
+8124          CD-3614699 2022872128433696                   210933.3-363732211546.8-361239  7.57-43.81 6.12  +1.37               K3III              +0.032-0.009      -016                           
+8125          CP-65 3900 202299254966              13627    210943.7-650551211800.3-644054329.44-39.74 6.31  -0.07 -0.22         B8V                +0.006-0.037      +013                           
+8126          BD+29 4354 202314 89549                       210953.8+292914211410.3+295404 76.69-12.87 6.17  +1.09 +0.81         G6Ib-IIaCa1Ba0.3   +0.001+0.005      -005                           
+8127 28Phi CapBD-21 5974 202320190173    I                  210956.4-210400211537.9-203906 28.19-40.61 5.24  +1.17 +1.11        gG9                 +0.013+0.002 +.020-005V                          
+8128 29    CapBD-15 5935 202369164263    I         13620    211012.8-153514211544.9-151017 34.86-38.69 5.28  +1.64 +1.90 +1.08E  M3III              +0.027+0.005 -.000-038V                         *
+8129          CP-85  519 202418258899              13686    211033.0-851417213204.2-844836307.53-30.40 6.45  +1.40 +1.66         K3III              +0.045-0.027      +015                          *
+8130 65Tau CygBD+37 4240 202444 71121    I  14787  Tau Cyg  211047.9+373706211447.5+380244 82.85-07.43 3.72  +0.39 +0.02 +0.24   F2IV               +0.160+0.435 +.055-021SB     89  2.5   1.0AB   7*
+8131  8Alp EquBD+04 4635 202447126662 800I W                211049.5+045004211549.4+051452 56.38-28.71 3.92  +0.53 +0.29 +0.35   G0III+A5V          +0.059-0.088 +.021-016SBO =< 50        0.1      *
+8132          BD-02 5495 202554145259                       211129.1-020129211639.6-013628 49.84-32.65 6.48  +0.98 +0.81         K0                 +0.036-0.014      -026                           
+8133          BD+63 1708 202582 19257       14783           211139.1+635931211342.6+642414101.97 10.81 6.39  +0.60 +0.06         G2IV+G2IV          +0.027-0.105D+.024+030V          0.2   0.6      *
+8134          BD-13 5897 202606164279                       211145.0-134148211713.5-131644 37.26-38.27 6.40  +0.04               A2V                -0.022-0.002      -001V?                         
+8135   Eps MicCD-3216498 202627212874 801                   211152.5-323525211756.3-321021 13.20-43.80 4.71  +0.06 +0.02         A1V                +0.058-0.026 +.033-001V     127                  
+8136          BD+47 3348 202654 50631                       211207.4+473326211536.8+475825 90.16-00.68 6.46  -0.15 -0.66         B4IV               -0.042-0.023      -026SB                        *
+8137 30    CapBD-18 5903 202671164286      D                211220.8-182415211757.3-175907 31.73-40.23 5.43  -0.12 -0.50         B8III              +0.017-0.002      -011V?     35  0.0   0.1      *
+8138          BD+41 4067 202720 50656                       211241.8+415003211629.6+421505 86.14-04.76 6.43R                     K2                 +0.003-0.028      +008                           
+8139 31    CapBD-18 5904 202723164289                       211240.0-175254211815.7-172744 32.40-40.11 7.05  +0.34               F2V                +0.036+0.004      -007                           
+8140   The IndCP-5310037 202730246965      W                211244.4-535206211952.0-532659343.69-43.32 4.39  +0.19 +0.12         A5V                +0.105-0.072 +.043-015      178  2.4   6.1      *
+8141 15    AqrBD-05 5512 2027531452783698                   211256.3-045622211811.1-043110 47.08-34.47 5.82  -0.13 -0.51         B5V                +0.011+0.015 +.008-009                          *
+8142          CD-2917692 202773190220                       211259.8-291103211854.4-284556 17.89-43.43 6.40  +0.97               G8IV               -0.181-0.058      +038                           
+8143 67Sig CygBD+38 4431 202850 711651558          13640    211329.2+385832211725.0+392341 84.19-06.87 4.23  +0.12 -0.39 +0.14   B9Iab             v+0.001-0.003 +.011-004SB     28                 *
+8144          BD+42 4046 202862 50671                       211336.2+421551211723.2+424100 86.57-04.58 6.19  -0.11 -0.43         B7Vn               +0.015-0.008      -020                           
+8145          CD-4514302 202874230635              T Ind    211334.0-452637212009.5-450120355.26-44.65 6.00  +2.33 +3.75         C5II                0.000-0.010      +002                          *
+8146 66Ups CygBD+34 4371 202904 711731559   14831  Ups Cyg  211348.3+342837211755.1+345349 80.98-10.05 4.43  -0.11 -0.82 -0.08   B2Vne              +0.014-0.002 +.019+004SB?   261  6.4  15.3AB   3*
+8147          BD+53 2588 202923 33281                       211354.3+533438211702.0+535951 94.64  3.35 6.13  +0.05 +0.06         A1V                +0.031+0.033      -008V?     68                  
+8148          CD-2615541 202940190236       14847           211358.8-264553211945.8-262111 21.19-43.11 6.56  +0.73 +0.23 +0.26E  G5V                -0.539-0.357 +.056-030SBO        3.0   2.5AB   5*
+8149          BD+10 4516 2029511070203700I                  211401.4+104655211852.0+111212 62.27-25.79 5.96  +1.65               K5III              +0.026+0.015      -037                          *
+8150          BD+55 2549 202987 332873699I                  211414.8+552240211714.3+554753 95.96  4.58 5.98  +1.45 +1.62         K3III              +0.018+0.017      -019V                          
+8151   The1MicCD-4114475 203006230644 802          The1 Mic 211421.9-411356212045.6-404835  1.19-44.95 4.82  +0.02 -0.07 +0.04   ApCrEuSr           +0.069-0.005 +.012+002V?     48                 *
+8152          CD-5013325 203010246983              13662    211425.1-502125212116.4-495616348.40-44.22 6.38  +1.32 +1.59         K3III              -0.021-0.151      +022                           
+8153          BD+57 2309 203025 33288       14832  13646    211434.0+581129211718.8+583642 98.00  6.53 6.42  +0.20 -0.50         B2IIIe             +0.001+0.003      -017SBO   175  5.6   4.1AB   3*
+8154 68    CygBD+43 3877 203064 506903701I         V1809 Cyg211443.4+433130211827.2+435645 87.61-03.84 5.00  -0.01 -0.94         O7.5III:n((f))    e+0.006-0.009      +001SB    328                 *
+8155          BD+40 4485 203096 50699       14849           211503.3+403708211855.3+410227 85.59-05.93 6.15  +0.30?              A5IV               -0.006+0.009      +007       25  6.4  56. AC   3 
+8156          CP-70 2844 203133254990              Y Pav    211513.4-700936212416.7-694403323.20-38.20 6.41  +2.82 +3.40         C5II               +0.005-0.018      +001V                         *
+8157          BD+37 4271 203156 71203       14859  V1334 Cyg211522.8+374855211922.2+381415 83.62-07.95 5.83  +0.50 +0.16         F1II               +0.011-0.006      +008SB     28  0.0   0.1      *
+8158          BD+21 4521 203206 89628                       211541.4+213610212014.0+220135 71.53-19.13 6.29  -0.08 -0.49         B6IV               +0.003+0.010      -017       70                  
+8159          CP-72 2598 203212257920      W                211546.4-721336212518.1-714758320.84-37.31 6.09  +1.26 +1.41         K2III              +0.018-0.007      +011           5.9  44.6       
+8160 16    AqrBD-05 5524 203222145317                       211549.7-045904212104.3-043336 47.47-35.11 5.87  +0.92 +0.64        gG7                 -0.012+0.011 +.014-006                           
+8161          BD+48 3345 203245 507133702                   211602.2+490514211928.8+493037 91.70-00.06 5.76  -0.15 -0.48         B6V                +0.017+0.002 +.001-023SB                         
+8162  5Alp CepBD+61 2111 203280 19302 803I  14858  13660    211611.5+620943211834.8+623508101.00  9.17 2.44  +0.22 +0.11 +0.11   A7V                +0.151+0.049 +.068-010V     246  9.1 206.8AB   4*
+8163  9    EquBD+06 4802 203291126719    I                  211608.0+065550212104.8+072116 59.19-28.55 5.82  +1.66 +1.97         M2IIIa             +0.041-0.019      -020                           
+8164          BD+58 2249 203338 33318    I  14864           211629.5+581201211915.8+583725 98.18  6.36 5.66  +1.38 +0.07 +1.33   M1Ibep+B2pe+B3V   v+0.005-0.001 +.004-021SB  =< 50  3.8   4.6AB   4*
+8165          BD+23 4294 203344 896403704                   211633.1+232605212104.4+235121 73.10-18.06 5.57  +1.05 +0.91         K1III              +0.243-0.120 -.005-089V?                        *
+8166          BD+31 4425 203358 71230       14889           211636.8+320145212050.1+322710 79.60-12.18 5.68  +1.08 +0.93         G8IV               +0.053-0.033D+.018-029V?         0.4   2.1AB   3*
+8167 32Iot CapBD-17 6245 2033871643461561I                  211640.7-171538212214.8-165004 33.62-40.77 4.28  +0.90 +0.58 +0.48   G7IIIFe-1.5        +0.033+0.004 +.033+012V?   < 17                  
+8168          BD+76  833 203399 10007    I                  211647.8+763529211542.2+770044111.85 19.06 5.95  +1.50               K5III              +0.013+0.010      +015                           
+8169          BD+32 4134 203439 71237                       211709.1+321116212122.0+323646 79.80-12.15 6.04  +0.03 +0.10         A1V                +0.018-0.011 +.007-003SBO    50                 *
+8170          BD+39 4529 203454 50739                       211706.9+395534212101.4+402044 85.37-06.70 6.40  +0.53 -0.01 +0.34   F8V                -0.019-0.207 +.034+001SBO    12                 *
+8171  6    CepBD+64 1527 203467 193133703          Var      211717.7+642652211922.2+645219102.74 10.69 5.18  -0.04 -0.58         B3IVe              +0.006+0.004 -.015-018SB    148                 *
+8172          CD-2316877 203475190285    I                  211716.6-230545212300.5-224008 26.31-42.85 5.60  +1.63 +2.04         M1III              +0.037+0.010      -007V?                         
+8173  1    PegBD+19 4691 203504107073 804I  14909           211727.6+192236212205.2+194816 70.05-20.92 4.08  +1.11 +1.06 +0.54   K1III              +0.106+0.064 +.014-076SB   < 17  4.9  36.2AB   3*
+8174          BD+80  690 203501  35343964                   211730.7+804841211321.5+811351115.25 21.83 6.15  +0.09 +0.09         A3IV               -0.009 0.000      -001                           
+8175 17    AqrBD-09 5728 2035251453513705I                  211734.6-094444212256.3-091910 42.56-37.81 5.99  +1.54 +1.89         M0III              -0.025-0.026      +018V                          
+8176          CP-83  716 2035322589023995                   211736.8-830707213354.4-824059309.46-31.74 6.38  +0.13 -0.36         B3IV               +0.018 0.000      -005                           
+8177          CD-4713796 203548230665                       211741.9-470233212420.8-463654352.92-45.21 6.31  +0.20               A7mSr:             +0.042-0.022      -024                          *
+8178 10Bet EquBD+06 4811 203562126749       14920           211755.8+062301212253.6+064840 59.00-29.23 5.16  +0.05 +0.07         A3V                +0.056+0.010 +.028-011SB     78  6.5  89.2AE   5*
+8179          BD+60 2227 203574 19333                       211759.3+601954212033.5+604525 99.84  7.73 6.11  +1.00 +0.75         G5III              -0.040-0.001      -027                           
+8180   The2MicCD-4114503 203585230667      W                211802.3-412607212424.8-410024  0.89-45.64 5.77  -0.05 -0.20         A0IIIpSi           +0.031 0.000D+.006+011           0.6   0.5AB   3 
+8181   Gam PavCP-65 3918 203608254999 805          13689    211810.8-654907212626.6-652158328.14-40.29 4.22  +0.49 -0.12 +0.30   F6V                +0.079+0.799 +.111-030        8                  
+8182          BD+29 4397 203630 71259                       211824.0+295256212241.9+301835 78.29-13.94 6.05  +1.08 +1.07         K1III              +0.015+0.004      -025                           
+8183 33    CapBD-21 6007 2036381902953707I         13683    211829.4-211637212409.6-205107 28.78-42.56 5.41  +1.16 +1.10 +0.41E  K0III              -0.007-0.125 +.021+022V?                        *
+8184          CD-2316889 203639190293                       211824.5-231031212407.9-224449 26.31-43.12 6.38  +1.02              gK0                 -0.028-0.003      +014V                          
+8185          BD+48 3357 203644 50761                       211831.9+485737212200.4+492320 91.90-00.44 5.69  +1.10 +1.02         K0III              +0.034+0.067 +.011-002SB                         
+8186          BD+38 4471 203696 71266                       211847.3+381226212246.9+383803 84.38-08.15 6.63  +0.01 +0.02         A1V                +0.004-0.024      -015      130                  
+8187 18    AqrBD-13 5923 2037051643641562  W       13684    211843.6-131826212411.5-125241 38.63-39.64 5.49  +0.29               F1V                +0.091+0.008      +008V     120  7.5  48.9       
+8188   Gam IndCP-55 9586 2037602470311563          13692    211907.5-550533212615.4-543938341.75-43.94 6.12  +0.34 +0.04         F1III              +0.004+0.036      +007                           
+8189          BD+36 4537 203784 71276      W                211919.9+365838212323.0+372424 83.58-09.10 6.58                      F6II-III           +0.046+0.025      -027           0.0 365.4AB   5*
+8190          BD+23 4300 203803 89678      W                211928.4+235040212358.8+241627 73.90-18.27 5.71  +0.32 +0.08         F1IV               +0.136+0.022 +.027-018V      97  4.8  53.9       
+8191          BD+09 4800 203842126774                       211931.6+094438212424.6+101027 62.30-27.50 6.35  +0.47 +0.12         F5III              +0.072+0.021      -033V?     84                 *
+8192 20    AqrBD-04 5444 203843145376                       211938.9-034937212451.7-032354 49.29-35.33 6.36  +0.33 +0.13         F0III              -0.006-0.053      -023                           
+8193          BD+36 4543 203857 71280      W                211945.5+365521212348.3+372105 83.60-09.20 6.47R                     K5                 -0.009-0.007      -003           0.0 365.4AB   5*
+8194          BD+24 4394 203858 89680       14943           211939.6+245257212407.4+251844 74.72-17.59 6.15                      A2V                +0.039 0.000      -019SBO        5.6  66.8AE   6*
+8195 19    AqrBD-10 5668 203875145382                       211950.6-101028212513.1-094455 42.40-38.50 5.70  +0.20               F0IV               +0.024-0.171 +.007-021                           
+8196          CP-70 2850 2038812550033712          SX Pav   211948.6-695614212844.9-693019323.22-38.65 5.34  +1.55 +1.45 +1.51E  M5III              +0.075-0.047 +.023+043                          *
+8197          BD+23 4305 203886 89682                       211953.8+240556212423.1+243144 74.16-18.17 6.32  +1.04 +0.94         K0III              +0.033 0.000      -024                           
+8198          BD+25 4531 203925 89685                       212007.5+254439212434.0+261028 75.46-17.08 5.68  +0.31 +0.07         A8III              +0.048+0.002 +.013-003SB     53                 *
+8199 21    AqrBD-04 5446 2039261453843708I                  212004.0-035908212517.0-033324 49.19-35.51 5.49  +1.46 +1.82         K4III              -0.008-0.065      -024                           
+8200          CD-3814551 2039492129983710                   212008.0-381539212622.9-374946  5.45-46.01 5.63  +1.19 +1.22         K2III              +0.163-0.012      -076                           
+8201          CP-80 1017 203955258904      W                212010.2-802833213320.6-800221311.99-33.30 6.47  +0.04 +0.05         A0V                +0.006-0.012      +021           4.8  24.4       
+8202          CD-4314539 204018230692      W                212036.8-425851212701.6-423252358.65-46.06 5.51  +0.39 +0.15 +0.19   Am                 -0.049+0.017      +018V?     53  2.7   2.8       
+8203          BD-00 4215 204041126789                       212044.3+000608212551.5+003204 53.47-33.44 6.46  +0.16 +0.05         A1IV               +0.040+0.013      -009       68                  
+8204 34Zet CapBD-2215388 204075190341 806I  14971           212057.5-225040212640.0-222441 26.98-43.59 3.74  +1.00 +0.59 +0.43   G4Ib               +0.001+0.023 -.010+003SB   < 19  8.6  21.3      *
+8205          BD+00 4726 2041211267943711                   212121.2+004031212628.1+010612 54.14-33.25 6.13  +0.44 +0.01         F5V                +0.113-0.163 +.028+011V?     12                  
+8206          BD+48 3376 204131 50817       14962  V1934 Cyg212125.8+485331212455.5+491924 92.20-00.82 6.58  -0.03  0.00         B9pSi:Cr:Sr:       -0.015-0.007      +001           5.9  20.3       
+8207 35    CapBD-21 6020 204139190349    I                  212134.7-213743212714.8-211146 28.63-43.36 5.78  +1.44 +1.74 +0.76   K5III              -0.026-0.030      +023V                         *
+8208          BD+46 3305 204153 50824                       212139.2+461652212519.6+464252 90.42-02.73 5.60  +0.32 -0.01         F0V                +0.195+0.048 +.039+001V                          
+8209 69    CygBD+36 4557 204172 71329       14969           212141.7+361407212547.0+364003 83.39-09.96 5.94  -0.08 -0.94         B0Ib               +0.006-0.005      +003       80  5.3  53.4AC   3*
+8210          BD+18 4794 204188107138              IK Peg   212147.9+185632212626.7+192232 70.43-21.98 6.07  +0.22 +0.06 +0.12   A8m                +0.081+0.014      -011SBO    83                 *
+8211          CP-54 9872 204228247043                       212157.4-540825212900.3-534221342.89-44.57 6.39  +1.14               K2IIICNIb          +0.081-0.025      +010                           
+8212          BD-12 6005 204363164415                       212249.0-120008212813.9-113406 40.72-39.98 6.61  +0.49               F3V                +0.009-0.048      +023V                          
+8213 36    CapBD-22 5692 204381190374    I                  212301.3-221434212843.4-214826 27.97-43.87 4.51  +0.91 +0.60 +0.46   G5III              +0.138-0.006 +.023-022V                         *
+8214  5    PsACD-3118291 204394213034                       212305.3-314027212903.8-311419 14.98-46.02 6.50  +0.03               A0                 +0.022-0.011      -000                           
+8215 70    CygBD+36 4568 204403 713583714                   212316.6+364055212721.4+370700 83.94-09.86 5.31  -0.14 -0.64         B3V                 0.000+0.002      -020SB    135                 *
+8216          BD+48 3390 204411 50867              13718    212318.5+482400212651.6+485006 92.09-01.39 5.31  +0.07 +0.16         A6pCrEu:           +0.060+0.023 +.008-013V       9                 *
+8217 35    VulBD+26 4164 204414 897203715                   212315.5+271023212740.1+273631 77.04-16.60 5.41  +0.04 +0.05         A1V                +0.041+0.018 +.019-008V?     97                  
+8218          BD+52 2939 204428 33434                       212327.0+522751212645.0+525355 94.89  1.55 6.03  -0.12 -0.46         B6V                +0.017+0.008 +.018-030                           
+8219          BD+07 4696 2044451268181564I         13727    212329.0+074538212824.8+081144 61.21-29.49 6.40  +1.64 +1.90 +0.93E  M1                 +0.011-0.025      -006                          *
+8220          BD+31 4462 204485 713713716                   212351.8+314715212808.3+321331 80.53-13.44 5.80  +0.32 +0.04         F0V                +0.137+0.083 +.023-024                          *
+8221          BD+17 4592 204560107168              13738    212419.0+172809212859.9+175421 69.67-23.41 6.44  +1.39 +1.64         K5                 -0.015-0.001      -012                           
+8222          BD-19 6107 204577164433                       212422.9-193503212959.6-190852 31.58-43.31 6.57  +0.41               F0V                +0.034-0.045      -012V?  =< 15                  
+8223          BD+21 4555 204585 89737    I W       13740    212425.5+214432212859.9+221046 73.09-20.54 5.93  +1.53 +1.32         M4.5III-IIIa       +0.045+0.011      -022           2.7  41.1AB   3 
+8224          BD+59 2383 204599 334433717I  14998  13729    212439.5+591853212725.3+594500 99.73  6.42 6.10  +1.75 +1.72         M3IIIaBa0.2        -0.022-0.018      -016V?         4.7  11.2      *
+8225  2    PegBD+23 4325 204724 897521565I  15027           212525.0+231202212956.9+233820 74.39-19.70 4.57  +1.62 +1.93 +1.09   M1+III             +0.024+0.004 +.013-019V          8.1  29.8       
+8226          BD+54 2544 204754 33458    I         13745    212544.0+545850212852.7+552507 96.86  3.16 6.12  +0.14 -0.28         B8III              +0.014+0.011      -007V?      0                  
+8227  7    CepBD+66 1405 204770 194323718                   212550.2+662222212746.1+664833104.76 11.43 5.44  -0.11 -0.42         B7V                -0.014-0.019 +.006+003V     295                  
+8228 71    CygBD+45 3558 204771 50934 807                   212545.5+460558212927.0+463226 90.81-03.35 5.24  +0.97 +0.80 +0.49   K0-III             +0.045+0.104 +.023-019V?   < 19:                 
+8229   Xi  GruCD-4114550 2047832307263719                   212546.1-413712213205.9-411045  0.56-47.08 5.29  +1.10 +1.01         K0III              +0.018+0.015 +.012-008                           
+8230  6    PsACD-3415110 2048542130781566  W       13762    212611.7-342307213214.6-335641 11.18-46.99 5.97  +0.05               A2IV              v-0.001-0.004      +016           7.3   6.8       
+8231          BD+11 4583 204862107195                       212619.4+114153213109.6+120815 65.20-27.55 6.08  -0.05 -0.21         B9.5V              +0.019-0.014      -010SB2   125                  
+8232 22Bet AqrBD-06 5770 204867145457 808I  15050           212617.7-060040213133.5-053416 48.02-37.88 2.91  +0.83 +0.56 +0.43   G0Ib               +0.021-0.008 +.006+007V?     18  7.9  35.5AB   3*
+8233          CP-5310092 204873247080                       212622.4-531044213317.7-524415343.97-45.45 6.41  +1.48               K4III              -0.005-0.009      +034                           
+8234          CP-79 1158 2049042579423723                   212627.1-795316213856.2-792633312.39-33.86 6.18  +0.46 +0.02         F4IV               +0.059-0.022      -006                           
+8235          CD-2515479 2049431904233720                   212647.6-250155213233.3-243526 24.54-45.47 6.43  +0.20               A7V                +0.073+0.007      -009                           
+8236          CD-4514367 2049602307371567                   212654.8-451726213323.5-445055355.16-46.99 5.57  +1.04 +0.85         K1III              -0.017-0.007      +011V                          
+8237          BD+52 2957 204965 33477                       212700.4+523104213020.4+525729 95.32  1.22 6.02  +0.08 +0.11         A2Vp               +0.024+0.015      -017SB     65                 *
+8238  8Bet CepBD+69 1173 205021 10057 809   15032  Bet Cep  212722.2+700718212839.6+703339107.54 14.03 3.23  -0.22 -0.95 -0.22   B1IV              v+0.010+0.007 +.014-008SBO    28  4.6  13.4AB   3*
+8239          BD+79  707 205072  3568                       212746.7+800520212449.7+803129114.98 21.03 5.97  +0.92              gG6                 +0.044-0.016      +003                           
+8240          BD+22 4418 205087 89786              13774    212754.2+225709213227.1+232340 74.62-20.29 6.70  -0.09 -0.28         B9pSiSrCr          +0.036+0.002      -016V?     25                  
+8241          CD-4314602 205096230741                       212754.2-432205213417.0-425530357.95-47.36 6.32  +1.09               K1IIICNII          -0.041-0.024      +009                           
+8242          BD+51 3079 205114 33497                       212805.8+521042213127.5+523712 95.22  0.86 6.16  +0.90 +0.44         G2Ib+B9V           +0.009+0.003      -023SBO =< 50                 *
+8243          BD+59 2395 205139 19466                       212814.4+600106213059.3+602734100.55  6.62 5.53  +0.12 -0.73         B1II               -0.002-0.001      -015V?     73                 *
+8244          CD-3018703 2052651904583721                   212859.1-300825213453.0-294146 17.47-47.03 6.41  -0.11               B8III              +0.017-0.017      -015V                          
+8245 37    CapBD-20 6237 205289190461                       212914.1-203148213451.0-200504 30.88-44.70 5.69  +0.40 -0.02         F1V                -0.037+0.031      +006V?                         
+8246          BD+49 3553 205314 51019      S                212924.5+493202213256.6+495840 93.59-01.24 5.75  -0.03 -0.11         A0V                +0.020+0.015      -033SB    265        0.0       
+8247          CD-2416729 205342190469                       212932.8-235357213515.9-232715 26.34-45.78 6.40  +1.10              gG7                 +0.077-0.008      -015V?                         
+8248          BD+45 3584 205349 51027    I         13784    212933.0+452437213317.9+455115 90.83-04.31 6.25  +1.81 +2.03         K1Ib              v-0.001+0.003      -005                          *
+8249          CP-65 3937 205417255040                       213004.1-651618213802.9-644927328.10-41.63 6.20  +0.03 +0.05         A0-1IV             +0.032-0.010      -009V?                         
+8250          BD+22 4431 205420 89807                       212959.8+221839213434.0+224517 74.48-21.08 6.47  +0.51 +0.03         F7V                +0.014-0.041      +014                           
+8251          BD-04 5489 205423145510                       213004.4-042544213517.6-035859 50.35-37.86 5.77  +1.11 +1.05        gG9                 -0.005+0.001 +.001-002V?                         
+8252 73Rho CygBD+44 3865 205435 510351568I         13787    213013.1+450859213358.9+453531 90.74-04.58 4.02  +0.89 +0.56 +0.50   G8IIIFe-0.5        -0.023-0.094 +.002+007     < 19:                *
+8253  8    PsACD-2615702 205471190478      W                213023.1-263703213611.0-261017 22.61-46.64 5.73  +0.22               A7/8IV             +0.111-0.023      -019           8.2  18.4      *
+8254   Nu  OctCP-77 1510 205478257948 810  A                213021.7-775002214128.5-772324314.29-35.19 3.76  +1.00 +0.89         K0III              +0.045-0.240 +.053+034SBO              0.1 *    *
+8255 72    CygBD+37 4359 205512 714803722I                  213041.4+380508213446.6+383203 86.01-09.85 4.90  +1.08 +1.02 +0.54   K0.5III            +0.124+0.099 +.012-066V?   < 17                  
+8256  7    PsACD-3315664 205529213136                       213048.5-332943213648.9-330253 12.63-47.85 6.11  +0.22               A7Vn               +0.089-0.003      -002                           
+8257          BD+27 4107 205539 89815      S                213053.1+274508213519.0+281150 78.72-17.39 6.31  +0.35 -0.05         F0IV               +0.128-0.043      -042SB2O             0.2      *
+8258          BD+23 4346 205541 89819       15115           213055.5+240022213527.0+242708 75.94-20.05 6.11                      A4V                +0.011-0.011 +.002-028SB2   170  0.3   0.3      *
+8259          BD+51 3091 205551 33540                       213100.6+511510213427.5+514154 94.93-00.13 6.15  +0.02 -0.29         B9IIIe             +0.007 0.000 -.006-022V     175                  
+8260 39Eps CapBD-20 6251 2056371645203724  W       Eps Cap  213128.9-195451213704.8-192758 31.94-44.99 4.68  -0.17 -0.65 -0.12   B2.5Vpe           v+0.015+0.003      -024SB?   293  1.3   0.0     3*
+8261          BD+29 4456 205688 89834       15126           213152.5+293622213613.9+300320 80.23-16.20 6.36R                     G8III-IV           -0.063+0.062      -020           4.4   2.1       
+8262          BD+44 3877 205730 51079    I         W Cyg    213214.3+445536213602.4+452229 90.86-04.98 5.53  +1.58 +1.24 +2.14   M5IIIae            +0.051+0.006      -014V                         *
+8263          BD-01 4180 205765145533       15142           213225.6-005020213733.8-002325 54.52-36.38 6.25  +0.06 +0.05 +0.02   A2V                -0.015-0.023      +017V?    156  3.3  31.5      *
+8264 23Xi  AqrBD-08 5701 2057671455371569  S                213225.7-081810213745.1-075115 46.45-40.34 4.69  +0.17 +0.13 +0.10   A7V                +0.116-0.025 +.012-021SBO   154  2.0   0.1      *
+8265  3    PegBD+05 4830 205811126940       15147A          213244.7+061008213743.7+063706 61.41-32.28 6.18  +0.02 +0.02         A2V                +0.060-0.007      +003SB     89  1.5  39.2AB   3*
+8266 74    CygBD+39 4612 205835 51101 811                   213256.3+395751213657.0+402449 87.62-08.76 5.01  +0.18 +0.10         A5V                -0.001+0.013 +.020+007V?    171                  
+8267  5    PegBD+18 4827 2058521072881570                   213304.6+185207213745.4+191907 72.34-23.99 5.45  +0.30 +0.14         F1IV               +0.101+0.013 +.007-025V?    134                 *
+8268          CD-3415163 205872213168                       213305.4-340742213906.1-334045 11.74-48.38 6.28  +0.92               G8IV               +0.066-0.051      -020                           
+8269          CP-5211911 2058772471283726                   213310.2-524838213959.7-522133344.10-46.53 6.21  +0.60 +0.32         F7III              -0.017+0.001      -000SB2                        
+8270  4    PegBD+05 4834 205924126956       15157           213331.4+051913213831.9+054618 60.76-32.96 5.67  +0.25 +0.08         A9IV-Vn            +0.114+0.024 +.033-019V?    195  6.4  27.2      *
+8271          CP-56 9700 205935247132                       213330.5-561125214033.6-554415339.43-45.56 6.33  +1.06               K0II-III           +0.010+0.023      +027                           
+8272          BD+44 3889 205939 51109              CP Cyg   213337.8+441451213727.9+444148 90.59-05.65 6.20  +0.19               A7III              -0.001-0.028      +004V?     23                 *
+8273          BD-11 5640 2060051645553728                   213405.6-110138213928.1-103437 43.53-42.00 6.08  +1.03 +0.89         K0                 +0.019-0.050      -009                           
+8274          BD+24 4445 206027 89870      S                213414.7+250252213845.0+252956 77.29-19.84 6.16  +1.02 +0.82         G9III              -0.021+0.003      -014                 0.1       
+8275          BD+53 2659 206040 33596                       213418.9+533531213738.7+540232 96.86  1.29 6.15  +0.99 +0.74         K1III              -0.019 0.000      +002                           
+8276          BD+19 4754 206043 89871                       213421.4+194850213901.1+201555 73.31-23.55 5.85  +0.32 +0.03         F2V                +0.113-0.003 +.021-013V?    105                  
+8277 25    AqrBD+01 4517 2060671269653729I W                213428.8+014738213933.3+021437 57.54-35.28 5.10  +1.04 +0.90 +0.52   K0III              -0.026-0.082 +.006-035V    < 19: 6.3 136.8       
+8278 40Gam CapBD-17 6340 206088164560 812I                  213433.1-170651214005.5-163944 36.00-44.67 3.68  +0.32 +0.20 +0.14   F0p                +0.190-0.023 +.029-031SB     30                 *
+8279  9    CepBD+61 2169 206165 195413725          V337 Cep 213514.2+613751213755.2+620455102.27  7.25 4.73  +0.30 -0.53 +0.18   B2Ib              v-0.003-0.002 -.008-013V?     36                 *
+8280   Lam OctCP-83  722 206240258914      W                213536.4-831044215054.3-824309309.02-32.13 5.29  +0.75 +0.47         G8-K0III           +0.058-0.036D+.011-011           2.3   2.8      *
+8281          BD+56 2617 206267 33626 813   15184           213551.4+570212213857.6+572921 99.29  3.74 5.62  +0.21 -0.74         O6.5V((f))         -0.001-0.003      -008SBO   154  2.2  11.8AC   5*
+8282          CD-2515545 206291190555                       213602.3-253323214146.1-250607 24.56-47.63 6.49  +1.19               K0                 -0.021-0.003      +032V?                         
+8283 42    CapBD-14 6102 206301164580    I'                 213606.6-142937214132.9-140251 39.56-43.97 5.18  +0.65 +0.20 +0.24E  G1V+G0V            -0.118-0.307 +.034-001SB1O   17  2.0   0.0      *
+8284 75    CygBD+42 4177 206330 511673730I  15208  13834    213615.5+424911214011.1+431626 90.00-07.04 5.11  +1.60 +1.90         M1IIIab            +0.063+0.016 +.004-028V          4.2  57.9AC   3*
+8285 41    CapCD-2317057 206356190559    I  15223           213619.1-234255214200.8-231546 27.21-47.22 5.24  +0.95 +0.75         G9III              +0.102-0.089 +.025-044V          6.2   5.1      *
+8286          CP-71 2632 2063992579553735                   213636.8-712758214528.8-710032320.64-39.09 6.01  -0.10 -0.35         B8IV               +0.009-0.019      -004V?                        *
+8287 26    AqrBD+00 4770 206445126997    I                  213704.1+004947214210.1+011707 57.05-36.37 5.67  +1.44 +1.67         K2III              +0.001-0.007      +010V                         *
+8288 43Kap CapBD-19 6152 206453164593    I                  213704.5-191920214239.5-185159 33.38-46.03 4.73  +0.88 +0.52 +0.49   G8III              +0.147-0.006 +.028-003V?   < 19:                 
+8289  7    PegBD+05 4850 2064871270023732I         13848    213715.3+051328214215.5+054048 61.36-33.75 5.30  +1.64 +1.95         M2IIIab            +0.014-0.006      -004V?                         
+8290          BD+54 2595 206509 336563731                   213724.5+542502214043.3+545220 97.74  1.61 6.20  +1.16 +0.96         K0III              +0.010+0.005      +004                          *
+8291 76    CygBD+40 4611 206538 51189      W                213732.8+402104214134.3+404819 88.54-09.06 6.11  +0.07 +0.07 +0.05   A2V                -0.012-0.046 +.013+003SB    150  4.0  62.1AB   3*
+8292          BD+10 4604 206540107340                       213739.8+102206214233.0+104929 66.11-30.53 6.09  -0.11 -0.51         B5IV               +0.024-0.002      +006V?     20                  
+8293          BD-20 6270 206546164601                       213737.9-200439214313.5-193715 32.41-46.41 6.22  +0.27 +0.15 +0.12   A3m                +0.077-0.011      -025SBO    47  0.1   0.0      *
+8294          CP-89   53 2065532589311669          CG Oct   213737.1-891903224528.6-884906303.63-28.13 6.57  +0.28 +0.13         F0IV-V             +0.016-0.040      +015                          *
+8295 44    CapBD-15 6046 206561164600      D                213737.1-145125214304.4-142359 39.32-44.45 5.88  +0.25               F0IV               -0.002+0.025      -013                          *
+8296 NOVA 1876                                     Q Cyg    0 0 0      0 0 0 0 0      0 0                                                                                                           *
+8297          BD+34 4500 206570 71613    I         V460 Cyg 213747.9+350315214201.1+353037 85.01-13.06 6.07  +2.52 +4.76 +1.40   C6.3               +0.007 0.000      +010                          *
+8298          BD+45 3637 206632 51204    I         V1339 Cyg213818.9+451835214208.4+454557 91.92-05.40 6.17  +1.55               M4III:             +0.006-0.013 +.003+009                          *
+8299          CD-3914405 2066422132483736                   213820.3-390022214429.5-383309  4.35-49.57 6.30  +1.12 +0.93         G5III              +0.081-0.168      -058                           
+8300 77    CygBD+40 4615 206644 51207      W                213821.4+403713214222.9+410438 88.84-08.96 5.69  +0.01 -0.01         A0V                +0.021+0.003 +.003-025SB2O   45  0.2   0.1      *
+8301 80Pi 1CygBD+50 3410 206672 336653733                   213832.5+504359214205.7+511123 95.48-01.30 4.67  -0.12 -0.68 -0.13   B3IV               +0.006-0.006      -008SBO   109                 *
+8302 45    CapBD-15 6052 206677164612                       213833.4-151227214401.0-144458 39.00-44.80 5.99  +0.21 +0.07 +0.12   F0V                -0.023+0.008      -004SB                         
+8303          CD-5013463 206690230822                       213841.2-495733214519.0-492955347.83-48.10 6.45  +1.15               K1III              +0.094+0.053      -051                           
+8304          BD+48 3480 206731 51217                       213900.3+490836214238.9+493601 94.51-02.56 6.09  +1.00 +0.74         G8II               +0.010-0.002      -002V                          
+8305  9Iot PsACD-3315734 206742213258 814  W                213859.5-332856214456.8-330133 12.88-49.55 4.34  -0.05 -0.11 -0.03   A0V                +0.034-0.094 +.041+002SB2    47  7.0  20.       *
+8306          BD+40 4623 206749 51221    I         13857    213905.2+404152214306.4+410918 89.00-08.99 5.49  +1.59 +1.96         M2IIIab            -0.023-0.015      -023V                          
+8307 79    CygBD+37 4408 206774 71643      W                213917.4+374933214325.7+381702 87.11-11.18 5.65R  0.00 -0.02         A0V                +0.036+0.004      -023      165  1.3 151.2AB   5*
+8308  8Eps PegBD+09 4891 206778127029 815I  15268  Eps Peg  213916.4+092459214411.2+095230 65.57-31.46 2.39  +1.53 +1.70 +0.76   K2Ib              e+0.031-0.001 +.006+005V    < 17  6.1 142.5AC   3*
+8309 78Mu 1CygBD+28 4169 206826 89940       15270A          213940.1+281727214408.6+284434 80.58-18.34 4.73H +0.48 +0.01 +0.28   F6V                +0.292-0.241 +.049+018SB2    18  1.3   2.0AB   5*
+8310 78Mu 2CygBD+28 4169 206827 89939       15270B          213940.3+281726214408.3+284435 80.58-18.34 6.08H +0.36?              G2V                +0.231-0.219 +.049+017V?         1.3   2.0AB   5*
+8311 46    CapBD-09 5829 206834145637    I                  213940.3-093230214500.3-090457 46.17-42.51 5.09  +1.11 +0.95 +0.53   G8II-III           +0.021-0.005 +.002-005SB   < 17                  
+8312          BD+58 2314 206842 33683                       213944.8+584847214245.4+591616100.84  4.75 6.08  +1.34               K1III              -0.003+0.010      -002                           
+8313  9    PegBD+16 4582 206859107365    I         13864    213946.5+165328214430.7+172100 71.98-26.51 4.34  +1.17 +1.00 +0.55   G5Ib               +0.012-0.013 +.008-022V?     20                  
+8314          BD+14 4668 2068601073643737          HN Peg   213942.0+141858214431.3+144619 69.86-28.27 5.94  +0.59 +0.04         G0V               v+0.234-0.119 +.065-019V?     11                 *
+8315 10Kap PegBD+24 4463 206901 89949    I  15281           214006.9+251107214438.7+253842 78.41-20.67 4.13  +0.43 +0.03 +0.25   F5IV               +0.034+0.010 +.035-008SB1O   29  0.4   0.3AB   3*
+8316   Mu  CepBD+58 2316 206936 33693    I  15271  Mu  Cep  214026.8+581917214330.4+584648100.60  4.32 4.08  +2.35 +2.42 +1.76   M2-Ia             e+0.003-0.003 +.003+019V          8.3  19.5AB   3*
+8317 11    CepBD+70 1193 206952 10126 817I                  214027.4+705103214155.3+711841108.88 13.82 4.56  +1.10 +1.10 +0.54   K1III              +0.117+0.099 +.008-037     < 17                  
+8318 47    CapBD-09 5833 207005145648    I         AG Cap   214056.2-094414214616.3-091633 46.14-42.88 6.00  +1.66 +1.87 +1.03E  M3III              +0.021+0.009      +021V?                        *
+8319 48Lam CapBD-12 6087 207052164639 818                   214109.1-114938214632.1-112157 43.64-43.91 5.58  -0.01 -0.05         A1V                +0.031-0.008 +.015+001V     190                  
+8320          BD+35 4626 207088 716751571                   214130.0+352345214544.5+355126 85.82-13.30 6.40  +1.00 +0.71         G8III              +0.094+0.012      -005                           
+8321 12    PegBD+22 4472 207089 899723739I                  214128.2+222916214604.4+225656 76.64-22.83 5.29  +1.41 +1.33         K0IbHdel 0.5      e+0.010-0.005 +.006-012                          *
+8322 49Del CapBD-16 5943 207098164644 819I  15314  Del Cap  214131.3-163452214702.4-160738 37.60-46.01 2.87  +0.29 +0.09 +0.17   Am                v+0.263-0.297 +.087-006SBO    87  2.0   0.0     4*
+8323          CD-4713928 2071292308461573  W                214145.6-474531214815.8-471813350.88-49.10 5.58  +0.60 +0.08         G0V                +0.167-0.298 +.073-007           3.0  55.0       
+8324          BD+71 1082 207130 10131    I                  214151.1+715142214304.0+721913109.65 14.50 5.17  +1.05 +0.97         K0III              -0.044-0.038 +.015-039V?   < 17                 *
+8325          BD+24 4473 207134 89976    I:                 214150.7+250601214624.0+253348 78.65-21.00 6.28  +1.21 +1.25         K3III:             +0.166+0.044 +.006-045V?                         
+8326 10The PsACD-3118466 2071552132923741  W                214152.1-312140214744.2-305354 16.24-49.94 5.01  +0.04 +0.05         A2V                -0.032+0.002 +.006+014      139  0.1   0.1AB   3*
+8327          BD+61 2193 207198 19621      W                214208.3+615959214453.3+622738103.14  6.99 5.95  +0.31 -0.64 +0.17   O9Ib-II           e-0.007-0.002      -018       76  3.5  17.0      *
+8328 11    PegBD+02 4414 2072031270601574                   214209.7+021325214714.0+024110 59.38-36.56 5.64   0.00 -0.01         A1V                +0.010-0.003 +.005+017V?    139                  
+8329          BD+42 4204 207218 51277                       214218.2+423554214616.6+430339 90.71-07.93 6.54  +0.28 +0.13         G0:III+A4V         +0.013+0.013      -019V     100                 *
+8330          BD+16 4598 207223107395                       214219.3+164355214704.7+171139 72.32-27.05 6.21  +0.34 +0.01         F3V                +0.094-0.014      -019                           
+8331          CP-65 3951 2072292550803742                   214215.0-651034215000.1-644245327.40-42.80 5.62  +1.02 +0.83         K0III              -0.003-0.042      -001                           
+8332          BD-06 5827 207235145671                       214222.4-062249214738.1-055502 50.30-41.49 6.17  +0.22 +0.05         A7V                +0.049-0.002      -011      120                  
+8333   Omi IndCP-70 2873 207241255087 820                   214219.9-700541215047.1-693746321.80-40.23 5.53  +1.37 +1.63         K2-3III            -0.031-0.002 +.029+020                           
+8334 10Nu  CepBD+60 2288 207260 196241572I         Nu Cep   214233.7+603933214526.9+610715102.31  5.93 4.29  +0.52 +0.13 +0.44   A2Ia               -0.003-0.003 +.013-021V      33                 *
+8335 81Pi 2CygBD+48 3504 207330 51293 821                   214305.8+485048214647.6+491834 94.83-03.22 4.23  -0.12 -0.71 -0.12   B3III              +0.004-0.002 -.001-012SBO    43                 *
+8336          BD+35 4643 207446 71716    I                  214355.4+360658214808.3+363450 86.68-13.08 6.47R                     K5                 -0.028+0.002      -031                           
+8337          BD-13 6027 207503164679                       214416.8-131121214941.1-124323 42.41-45.20 6.31  +0.22               A3m                -0.003+0.015      +000SB2    20                 *
+8338          BD+37 4427 207516 71722                       214420.1+381101214829.4+383855 88.12-11.56 6.12  -0.08 -0.34         B8V                +0.022-0.002      -020      100                  
+8339 12    CepBD+60 2294 207528 19642    I                  214428.2+601343214725.3+604134102.22  5.45 5.52  +1.52 +1.93         M1IIIb             -0.008 0.000 +.021-020                           
+8340          BD-17 6389 207552164686                       214443.0-171840215013.1-165041 37.05-46.99 6.38  +1.42               K0                 +0.034 0.000      -001V                          
+8341          BD+19 4793 207563 900273744                   214446.4+195948214926.9+202745 75.35-25.15 6.29  -0.10 -0.64         B2V                +0.003-0.002      -012V?    122                  
+8342          BD+69 1198 207636 19646                       214515.3+694113214701.0+700903108.41 12.67 6.29R                     A0V                -0.004-0.026      -002V?    205                  
+8343 14    PegBD+29 4525 207650 900401575                   214525.2+294230214950.7+301027 82.57-18.12 5.04  -0.03 +0.03         A1V s              +0.019-0.027 +.006-023SBO    68                 *
+8344 13    PegBD+16 4612 207652107425      W       13891    214523.1+164914215008.7+171708 72.97-27.52 5.29  +0.37 +0.03 +0.18   F2III-IV           +0.076-0.061 +.015-004V      71  2.0   0.2      *
+8345          BD+40 4648 207673 513443745                   214535.9+404057214940.1+410856 89.94-09.80 6.48  +0.42 +0.07         A2Ib               -0.002-0.007      -002V      21                  
+8346          BD-19 6176 207760164697                       214608.6-190521215141.8-183723 34.79-47.96 6.16  +0.36 +0.06         F0III              +0.148-0.079      -042V?                         
+8347          BD+60 2300 207780 19663    I                  214623.2+604824214919.0+611622102.77  5.75 6.17  +1.67 +2.03         M1II-III           +0.003-0.024      -019                           
+8348          BD+19 4797 207840107445       15383           214652.4+192128215134.2+194936 75.25-25.96 5.77  -0.10 -0.40         B8III              +0.014+0.017      -020       20  5.6  19.3AB   3*
+8349          BD+38 4621 207857 71767              V1619 Cyg214656.6+390406215104.9+393212 89.10-11.20 6.17  -0.08 -0.42         B9pHgMn            +0.006+0.005      +000V?     12                 *
+8350          BD+20 5027 207932 90059    I         HO Peg   214738.3+204810215218.2+211623 76.50-25.04 6.89R                     M4III              +0.015+0.021      -022                          *
+8351 51Mu  CapBD-14 6149 2079581647131577                   214750.7-140121215317.8-133306 41.88-46.35 5.08  +0.37 -0.01         F1III              +0.313+0.013 +.047-022V      87                 *
+8352          CP-62 6277 207964255101      W                214749.0-622121215511.5-615311330.39-44.71 5.90  +0.39               F1III              +0.050-0.084D+.019+001           0.1   0.3      *
+8353   Gam GruCD-3714536 207971213374 822                   214752.5-375006215355.7-372154  6.11-51.47 3.01  -0.12 -0.37 -0.06   B8III              +0.102-0.021 +.013-002V?     68                  
+8354 15    PegBD+28 4215 207978 90065                       214802.0+281931215229.9+284736 82.05-19.54 5.53  +0.42 -0.13         F6IV-V vw          -0.059-0.067 +.040+019V?  =<  6                 *
+8355          BD-10 5785 208008164717      W                214815.2-104657215336.0-101842 46.07-44.96 6.59  -0.12               B9V                +0.012-0.004      -011V          0.5   0.1AB   3*
+8356 16    PegBD+25 4635 208057 90075 823                   214830.6+252716215303.8+255530 80.10-21.75 5.08  -0.17 -0.67         B3Ve               +0.009-0.002 +.003-012SB    152                 *
+8357          BD+55 2639 208095 33819       15405A 13909    214837.9+551936215201.0+554749 99.56  1.28 5.71  -0.13 -0.46         B6IV-V             +0.013+0.003D+.005-007SB2O  120: 1.0  18.3AB   3*
+8358          BD+18 4879 208108107474                       214855.0+191148215337.4+194006 75.51-26.41 5.68  +0.01 +0.01         A0V s              +0.013+0.013      +006    =< 41                  
+8359          BD+06 4919 208110127141                       214858.1+062334215357.8+065152 64.70-35.25 6.15  +0.80 +0.27         G0III s            +0.081 0.000      -010     < 32                 *
+8360          BD-04 5568 208111145731                       214857.0-044443215410.4-041634 53.33-41.99 5.71  +1.18 +1.27         K2III              +0.057-0.093 +.017-037                           
+8361          BD+65 1664 208132 19686       15407           214907.2+651659215137.3+654510105.85  9.04 6.37                      A1m                -0.006-0.015D+.010+004V?         0.3   1.9AB   3*
+8362   Pi  IndCP-58 7911 208149247230                       214913.0-582223215614.0-575358335.36-46.69 6.19  +0.21 +0.15         Am                 +0.016+0.011      +007V?                        *
+8363          BD-03 5329 208177145735       15432           214924.0-034621215435.9-031804 54.49-41.54 6.20  +0.48 +0.07         F5IV               +0.018-0.028      -016           3.4  17.6      *
+8364          BD+19 4814 208202107489       15431           214935.3+191447215417.4+194306 75.68-26.48 6.39  +0.97 +0.68         K0III+F7V          -0.034-0.008      +004V?         2.1  22.3AB   3*
+8365          CD-3118541 208285213406                       215005.8-310445215555.6-303623 17.01-51.66 6.41  +0.93               G8III              +0.051-0.026      -085V                          
+8366          CD-3714565 208321213414                       215021.7-374339215622.8-371513  6.25-51.96 5.46  +0.08               A2Vn               -0.016-0.002      +028V     222                  
+8367          CD-3814801 208435213427              BZ Gru   215100.1-381319215702.2-374449  5.44-52.07 6.18  +0.33               F1III-IV           +0.022-0.003      +001                          *
+8368   Del IndCP-55 9733 208450247244 824  W                215106.9-552805215755.1-545933339.11-48.12 4.40  +0.28 +0.10         F0IV               +0.048-0.007 +.020+015V?    130  0.1   0.1      *
+8369   Kap1IndCP-59 7744 2084962472473752          BG Ind   215126.0-592920215830.1-590044333.72-46.45 6.12  +0.46 -0.02         F3V                +0.005+0.026      +040SB2                       *
+8370          CP-78 1430 208500257990                       215126.0-780826220152.1-773945313.17-35.87 6.41  +0.22 +0.08         A5IV-V             -0.031-0.002      +001V                          
+8371 13    CepBD+55 2644 208501 338643749          13963    215131.4+560815215453.2+563641100.39  1.68 5.80  +0.73 -0.02 +0.60   B8Ib              v-0.003-0.001      -015V?     53                 *
+8372          BD+20 5046 208527 901121579I                  215143.3+204552215624.0+211423 77.24-25.72 6.40  +1.70 +2.03         K5V                +0.002+0.015 +.004+002                           
+8373 17    PegBD+11 4696 2085651075283751                   215203.7+113605215656.4+120435 69.96-32.32 5.54  +0.05 +0.03         A2Vnn              -0.024-0.014      +015V     240                  
+8374          BD+60 2318 208606 19738    I                  215220.9+610402215520.7+613231103.50  5.51 6.13  +1.60 +1.62         G8Ib               +0.004+0.007      -032SB                        *
+8375          BD+64 1607 208682 19742       15467  13966    215253.6+645045215531.1+651915105.89  8.45 5.86  -0.06 -0.75         B2.5Ve             +0.007+0.003      -015V     350: 2.2   1.1      *
+8376          BD-06 5878 208703145778                       215258.8-055356215813.3-052529 52.76-43.46 6.33  +0.37 -0.03         F5IV               +0.040-0.101      +001V      12                  
+8377          BD+47 3618 208727 514773754                   215312.9+481133215702.2+484007 95.74-04.77 6.42  -0.08 -0.37         B8V                +0.005+0.002      -016V?    140                  
+8378          BD-21 6131 2087351907863757I                  215309.2-213936215843.8-211058 31.90-50.35 6.12  +1.65 +1.83         M4III              +0.023-0.002      +003                           
+8379          CD-3814820 208737213452                       215315.2-385222215917.9-382343  4.34-52.47 5.50  +1.00               K0III              +0.042-0.006      -010                           
+8380          CP-76 1542 2087412579933760  W                215316.5-763547220303.8-760707314.54-36.95 5.95  +0.39 +0.11         F3III              +0.022-0.080      +007SB         4.2  34.6       
+8381          CP-56 9784 208796247262                       215334.8-562142220024.1-555258337.68-48.07 6.01  -0.10 -0.12         B9IV-V             +0.010+0.014      +003                           
+8382          BD-05 5674 2088011457841580                   215342.0-045038215855.0-042223 54.10-43.03 6.22  +1.00 +0.87 +0.35E  K2V                +0.001-0.254 +.034-044V                          
+8383          BD+62 2007 208816 197533756I W       VV Cep   215349.9+630857215639.1+633732104.92  7.05 4.91  +1.77 +0.39 +1.40   M2Iaep+B8Ve       v-0.005-0.004 +.004-019SBO     0: 1.7   0.1      *
+8384          BD+65 1691 208947 19760    I                  215437.7+654044215711.1+660922106.55  9.00 6.43  -0.05 -0.68         B2V                +0.005+0.001      +002SBO   250  0.2  91.       *
+8385 18    PegBD+06 4940 2090081272193759                   215508.1+061417220007.9+064303 65.80-36.51 6.00  -0.12 -0.57         B3III              +0.015+0.004      -007V?     78                  
+8386 12Eta PsACD-2918119 209014190822       15536  13993    215505.6-285601220050.2-282713 20.70-52.44 5.42  -0.09 -0.37 -0.07   B8V               e+0.016+0.006D+.011-005V          1.0   1.9      *
+8387   Eps IndCP-5710015 209100247287 825                   215542.6-571148220321.6-564710336.28-48.01 4.69  +1.06 +0.99 +0.55   K4-5V              +3.961-2.538 +.285-040                          *
+8388          BD+62 2010 209112 19773    I                  215556.6+621307215853.4+624154104.54  6.16 5.93  +1.67 +1.81         M3IIIab            +0.004+0.026      -016V?                         
+8389          BD+56 2670 209124 33943                       215601.9+571046215923.0+573930101.51  2.13 6.59  +0.03 -0.01         A0III-IV           +0.004-0.015      -003                          *
+8390 28    AqrBD-00 4296 209128127235    I                  215558.0+000729220105.0+003618 59.95-40.57 5.58  +1.28 +1.40        gK4                 +0.010-0.013      +007                           
+8391          BD+32 4316 209149 71932                       215603.0+323128220026.8+330022 86.30-17.44 6.46                      F5III              -0.006+0.064      -002       40                 *
+8392 20    PegBD+12 4737 209166107587 826   15543           215613.0+123827220105.4+130711 71.68-32.32 5.60  +0.34 +0.05         F4III              +0.059-0.057 +.038+007V    < 20  6.4  54.7       
+8393 19    PegBD+07 4779 209167127239    I                  215611.4+074636220109.2+081526 67.43-35.67 5.65  +1.44 +1.77        gK5                 -0.009-0.002      -023V?                         
+8394          BD-18 6056 2092401648273761                   215641.6-182300220211.9-175413 37.15-50.04 6.28  +1.01              gG7                 +0.123-0.060      -017                           
+8395          BD+74  946 209258 102083758I                  215653.8+743105215751.0+745948112.28 15.84 6.35  +1.56 +1.61         K5                 -0.007-0.012      -017                           
+8396 29    AqrBD-17 6422 209278164830       15562A DX Aqr   215658.3-172646220226.6-165751 38.54-49.74 6.37  +0.42               A2V+K0III          +0.015+0.001D+.006+015SBO        0.1   3.6AB   3*
+8397          BD+10 4676 209288107599              14001    215706.6+102931220201.4+105826 70.03-33.98 6.37  -0.10 -0.61         B5IIIn             +0.022+0.003      -015V?                         
+8398          CD-3018975 209335213502                       215730.1-302312220317.2-295415 18.43-53.16 7.10  +0.32               F0IIIn             +0.122-0.014      -012                           
+8399          BD+61 2233 209339 19792      W       13998    215739.7+620024220039.3+622917104.58  5.87 6.66  +0.06 -0.82         B0IV               -0.001+0.007      -020V?    213  2.0   0.9      *
+8400 16    CepBD+72 1009 209369 10216      W                215749.3+724214215915.0+731048111.17 14.38 5.03  +0.44 -0.03         F5V                -0.068-0.161 +.033-021V      26  6.8 131.4      *
+8401 30    AqrBD-07 5688 209396145836                       215800.9-070020220316.4-063121 52.41-45.11 5.54  +0.96 +0.73         K0III              +0.045+0.006      +030                           
+8402 31Omi AqrBD-02 5681 2094091458373765          Omi Aqr  215808.5-023817220318.9-020919 57.44-42.67 4.69  -0.06 -0.41 -0.05   B7IVe              +0.028-0.012      +012V?    227                 *
+8403          BD+52 3083 209419 339853763                   215810.6+522400220150.6+525256 98.91-01.89 5.78  -0.11 -0.50         B5III              +0.011+0.006      -022V?                        *
+8404 21    PegBD+10 4681 209459107625                       215824.6+105412220319.0+112311 70.66-33.92 5.80  -0.07 -0.20         B9.5V              +0.017-0.012      -000        4                  
+8405 13    PsACD-3018985 209476213517    I                  215838.0-302403220423.9-295500 18.45-53.40 6.47  +1.63 +1.93         K5III              +0.014+0.001      +023V                          
+8406 14    CepBD+57 2441 209481 33990              LZ Cep   215842.8+573104220204.6+580002102.01  2.18 5.56  +0.06 -0.86         O9Vn               -0.002 0.000 -.009-007SB2O  130:                *
+8407          BD+43 4119 209515 51595       15578  V1942 Cyg215854.4+441003220256.7+443900 94.08-08.58 5.60  -0.03 -0.10 -0.01   A0IV               -0.018-0.033      -001V?     98  2.5   1.0AB   5*
+8408          CD-2715757 2095221908643767          14011    215855.6-271823220436.8-264921 23.58-53.01 5.96  -0.14 -0.66 -0.15   B4IVne            v+0.017-0.015      -018V     300                 *
+8409   Kap2IndCP-60 7541 209529247303                       215849.7-600711220550.9-593810332.26-46.96 5.62  +1.46 +1.81 +0.56E  K4III              +0.048-0.056      -011                           
+8410 32    AqrBD-01 4242 209625145853                       215938.8-012324220447.4-005424 59.10-42.22 5.30  +0.23 +0.15 +0.11   A5m               v-0.015-0.052 +.014+020SB1O   19                 *
+8411   Lam GruCD-4014639 2096882135431581                   220005.3-400133220606.9-393236  2.22-53.67 4.46  +1.37 +1.66 +0.78   K3III              -0.023-0.124 +.013+039                           
+8412          BD+32 4329 209693 71998       15602           220009.2+322725220434.4+325631 86.97-18.03 6.38  +1.10 +0.80?        G5Ia               -0.007+0.001      -022V?         4.8  21.4       
+8413 22Nu  PegBD+04 4800 209747127285    I         14020    220038.1+043411220540.8+050331 65.37-38.64 4.84  +1.44 +1.81 +0.76   K4III              +0.111+0.100 +.014-016SB   < 17                  
+8414 34Alp AqrBD-01 4246 209750145862 827I W                220038.9-004821220547.0-001911 59.93-42.07 2.96  +0.98 +0.74 +0.49   G2Ib              v+0.020-0.010 +.012+008V?   < 17  9.0 113.0      *
+8415          BD+25 4671 209761 90214    I                  220036.2+261114220511.4+264026 82.85-22.98 5.78  +1.25               K2III              +0.034+0.032      -025V                          
+8416 18    CepBD+62 2028 209772 19828    I         MO Cep   220053.1+623800220352.9+630711105.26  6.15 5.29  +1.58 +1.79 +1.26E  M5IIIab            +0.031+0.055 -.006-004                          *
+8417 17Xi  CepBD+63 1802 209790 19827       15600A          220053.7+640826220347.4+643740106.15  7.37 4.29  +0.34 +0.09 +0.13   A3/6Vm             +0.209+0.085 +.032-006SB2O   20  2.0   7.7AB   3*
+8418 33Iot AqrBD-14 6209 209819164861 828                   220102.2-142118220626.2-135211 43.51-49.37 4.27  -0.07 -0.29 -0.09   B9IV-V             +0.042-0.056      -010SB2   169                  
+8419 23    PegBD+28 4284 209833 902173768                   220102.7+282841220534.7+285750 84.49-21.27 5.70  -0.06 -0.21         B9Vn               +0.031-0.012      -012SB    360                  
+8420          CP-76 1547 209855258003                       220115.7-762212221042.5-755250314.37-37.45 6.55  +1.18 +1.30         K2IIICNII          +0.035-0.002      +051                           
+8421          BD+46 3574 209857 51632    I         HT Lac   220118.0+461533220516.4+464441 95.68-07.14 6.13  +1.61 +1.76 +1.56   M4IIIab            -0.042-0.020      -013                          *
+8422          BD+44 4041 209932 51640                       220147.5+443733220550.6+450644 94.77-08.52 6.44  -0.03 -0.14         A0V                +0.026-0.009      -004SB     73                  
+8423          BD+82  673 209942  3673       15571A          220149.0+822319215812.7+825211117.67 21.84 6.98  +0.52 -0.02         F6IV-V             -0.141-0.041 +.011-022SB2    30  0.5  13.7AB   3*
+8424          BD+44 4043 209945 516503769I         14028    220158.9+443140220602.0+450052 94.74-08.61 5.14  +1.57 +1.94 +0.92   K5III              -0.007-0.016 +.006-023V    < 17                  
+8425   Alp GruCD-4714063 209952230992 829  W       14040    220155.9-472643220814.0-465740350.00-52.47 1.74  -0.13 -0.47 -0.09   B7IV              e+0.129-0.151 +.057+012      236 10.1  28.4      *
+8426 20    CepBD+62 2029 209960 19847 830I         Var?     220158.0+621752220500.5+624708105.16  5.81 5.27  +1.41 +1.78         K4III              +0.015+0.058 -.000-021V?   < 17                 *
+8427          BD+47 3692 209961 51645              V365 Lac 220155.8+474441220551.2+481354 96.64-06.01 6.27  -0.06 -0.71         B2V                -0.005+0.004      -018SB1O  160                 *
+8428 19    CepBD+61 2246 209975 19849       15624           220203.8+614736220508.9+621648104.87  5.39 5.11  +0.08 -0.84 +0.03   O9.5Ib             +0.003 0.000      -013V      33  5.6  60.4AC   3*
+8429          BD+44 4044 209993 51652                       220209.3+444542220612.4+451455 94.91-08.44 6.19  +0.09 +0.14         A3V                +0.036-0.010      -002                           
+8430 24Iot PegBD+24 4533 210027 90238 831I W       14034    220221.2+245124220700.7+252042 82.26-24.26 3.76  +0.44 -0.04 +0.25   F5V                +0.298+0.025 +.082-004SB1O    7  7.4 103.7      *
+8431 14Mu  PsACD-3315922 210049213576 832                   220233.0-332835220823.0-325919 13.34-54.46 4.50  +0.05 +0.05 +0.05   A2V                +0.080-0.031 +.030+012      226                  
+8432          CP-76 1549 210056258006                       220228.7-763621221155.3-760658314.09-37.34 6.15  +1.00 +0.82         K0III              -0.044-0.043      +025                           
+8433   Ups PsACD-3415421 210066213577    I                  220234.8-343153220826.0-340238 11.53-54.48 4.99  +1.48 +1.81 +0.60E  M1III              +0.008-0.049 +.009+020                          *
+8434          BD+55 2679 210071 34055                       220242.0+555121220613.5+562035101.47  0.52 6.39  -0.10 -0.45         A0III              +0.014-0.011      -020V?                        *
+8435          BD+18 4930 210074107675                       220242.7+185910220728.6+192832 78.06-28.77 5.75R                    dF2                 +0.125+0.037 +.016-015V?     49                 *
+8436          BD+17 4693 210090107676    I         14039    220242.9+173048220730.0+180002 76.93-29.87 6.35  +1.64               M1                 +0.025-0.040      -010                          *
+8437          CD-3315926 210111213583                       220253.0-333656220842.7-330732 13.11-54.53 6.37  +0.20               A2III/IV           +0.022+0.029      -004                           
+8438 25    PegBD+21 4695 210129 90252                       220308.4+211258220750.3+214210 79.80-27.15 5.78  -0.10 -0.41         B7Vne             v-0.047-0.069      -052V     250                 *
+8439 35    AqrBD-19 6227 210191164888                       220330.0-190033220859.0-183111 37.15-51.76 5.81  -0.17               B2.5IV             +0.003-0.012      -005                           
+8440          CD-4814143 210204231005                       220338.5-483547220958.0-480626348.06-52.39 6.43  +1.39               K3III              +0.077-0.047      +019                           
+8441          BD+24 4540 210210 90259                       220340.2+250319220817.2+253237 82.64-24.29 6.11  +0.27 +0.12         F1IV               -0.038-0.037      +002SB     75                  
+8442          BD+58 2393 210220 340723770                   220347.3+582109220709.6+585027103.04  2.47 6.32  +0.88 +0.63         G6III              -0.013-0.022 +.017-010V?                         
+8443          BD+52 3114 210221 34076                       220343.3+524907220725.5+531826 99.84-02.05 6.14  +0.43 +0.24         A3Ib               -0.007-0.009      -026       26                  
+8444          CD-3415430 210271213599              14049    220405.3-343023220955.7-340053 11.58-54.79 5.37  +0.24               A5V                -0.017+0.038 +.027+002      201                  
+8445          BD+49 3746 210289 51678    I  15659           220423.4+491827220816.5+494747 97.89-04.97 6.42R                     K5III              +0.029-0.023      +017V?         6.7  38.5       
+8446          CD-2817622 210300190930                       220418.1-284702221000.1-281733 21.44-54.42 6.44  +0.15               A5V                +0.032+0.026      +011                           
+8447 15Tau PsACD-3315941 210302213602                       220417.3-330222221008.8-323254 14.12-54.81 4.92  +0.48 +0.01         F6V                +0.434+0.013 +.053-015                           
+8448          BD+45 3813 210334 51684              AR Lac   220438.4+451503220841.0+454431 95.56-08.30 6.11  +0.72 +0.26 +0.33E  G2IV+K0III         -0.027+0.031      -035SBO                       *
+8449 27Pi 1PegBD+32 4349 210354 72064 833   15672           220447.7+324101220913.6+331020 87.93-18.45 5.58  +1.00 +0.77         G8IIIb             -0.059-0.067 +.006-006V?         5.8  70.2AC   5*
+8450 26The PegBD+05 4961 210418127340 834          14057    220509.3+054221221012.0+061152 67.41-38.71 3.53  +0.08 +0.10 +0.04   A2Vp               +0.276+0.027 +.049-006SB2   117                 *
+8451          BD-04 5623 210419145914                       220509.0-042303221021.1-035339 56.90-45.11 6.27  -0.01 -0.07         A1Vnn              +0.019-0.050      -010      254:                 
+8452 38    AqrBD-12 6196 2104241649103771                   220516.7-120325221037.5-113354 47.36-49.23 5.46  -0.12               B7III              +0.036+0.009      +003V?     18                  
+8453          BD-04 5625 210434145916                       220520.9-044531221033.8-041602 56.51-45.37 6.01  +0.98 +0.83         K0III-IV           +0.076-0.003      -018V                          
+8454 29Pi 2PegBD+32 4352 210459 72077 835                   220532.7+324115220959.2+331042 88.06-18.54 4.29  +0.46 +0.18 +0.27   F5III              -0.014-0.021 +.007+002      139                 *
+8455          BD+18 4946 210460107706      S                220533.0+190739221019.0+193701 78.74-29.11 6.18  +0.69 +0.17         G0V                +0.086-0.075      +022V?                        *
+8456          BD+13 4861 210461107707       15690           220530.6+140820221022.2+143748 74.85-32.81 6.33  +1.08 +0.94         K0III              +0.034-0.026      -042V?         5.1  21.5       
+8457          BD-21 6173 210464190945                       220529.5-214325221102.4-211357 33.20-53.10 6.09  +0.50               F6V                +0.122-0.033      -013V?                         
+8458          BD+10 4701 2105021077123773I                  220542.9+110803221037.4+113728 72.39-35.02 5.78  +1.58 +1.94         M1III              -0.046-0.054      +017SB                         
+8459 28    PegBD+20 5093 210516 902873772                   220546.5+202911221030.2+205841 79.80-28.11 6.46  +0.12 +0.11         A3III               0.000-0.008      +008                           
+8460          BD+29 4604 210594 72095                       220620.6+300340221051.6+303311 86.51-20.74 6.32  +0.18 +0.16         A8IV               +0.008-0.009      +004       86                  
+8461          BD+15 4592 210702107729                       220701.5+153252221151.3+160226 76.29-32.02 5.95  +0.95 +0.73 +0.49   K1III              -0.008-0.019      +011V?                        *
+8462 39    AqrBD-14 6229 210705164923              14068    220702.2-144111221225.8-141138 44.03-50.82 6.03  +0.38  0.00         F2V                +0.028-0.042      +015V?                         
+8463          BD+50 3602 210715 341433774   15708           220716.6+501945221109.9+504924 98.86-04.40 5.40  +0.15 +0.05         A5V                +0.139+0.041 +.008-008V?    126  4.1  73.8AD   4*
+8464          CD-2616033 210739190967                       220719.4-264916221257.5-261940 24.97-54.75 6.17  +0.17               A3V                -0.019-0.033      +015                           
+8465 21Zet CepBD+57 2475 210745 34137 836I         14066    220723.0+574230221051.3+581204103.06  1.67 3.35  +1.57 +1.71 +0.78   K1.5Ib             +0.015+0.004 +.017-018SB   < 17                 *
+8466          BD+24 4548 210762 90317    I                  220729.0+242725221208.0+245700 82.97-25.30 5.92  +1.51               K0                 -0.004-0.022      -003                           
+8467          BD-05 5732 210763145940                       220731.4-051250221243.8-044315 56.42-46.07 6.39  +0.50 +0.06         F7V                -0.051-0.035      +002SB2    12                  
+8468 24    CepBD+71 1111 210807 10265 837I                  220753.1+715055220948.4+722028111.28 13.23 4.79  +0.92 +0.61 +0.48   G7II-III           +0.032+0.003 +.017-015V    < 19:                 
+8469 22Lam CepBD+58 2402 210839 34149    I         14069    220806.8+585516221130.7+592452103.83  2.61 5.04  +0.25 -0.74 +0.15   O6I(n)fp           +0.003-0.011 +.006-074V?    285                 *
+8470          CD-2515815 210848190976                       220807.4-254034221344.4-251051 26.98-54.70 5.58  +0.49 +0.22         F6III-II           +0.074+0.016      -028                           
+8471   Psi OctCP-78 1442 2108532580203779                   220807.0-780033221750.5-773042312.56-36.59 5.51  +0.31 +0.12         F3III              -0.041+0.011      +017                          *
+8472          BD+56 2727 210855 341513775  W                220811.9+562031221148.8+565022102.38  0.48 5.24  +0.51 +0.06         F8V                +0.237+0.130 +.024-019V       0  5.1  72.9AB   3*
+8473          BD+71 1112 210873 10267                       220817.6+713708221015.3+720640111.17 13.03 6.37  -0.06 -0.18 -0.07   B9pHgMn:           -0.009-0.028      -003       41                 *
+8474          BD+69 1228 210884 19922       15719           220821.8+693819221038.9+700758110.00 11.41 5.50  +0.38 -0.04         F2V                -0.060+0.028 +.038+001V?         3.1  14.6      *
+8475          BD+33 4456 210889 721323776I                  220822.2+340641221247.8+343617 89.46-17.76 5.33  +1.13 +1.13         K2-III-IIIb        +0.020-0.050 +.003-007V?   < 19:                 
+8476          BD+58 2403 210905 34158                       220829.7+583518221156.9+590505103.68  2.31 6.30  +1.13 +1.07         K0III              +0.129+0.083      -028                          *
+8477          CD-4114804 210918231045    I'                 220832.0-415119221438.6-412254358.68-54.97 6.23  +0.65 +0.14         G5V                +0.567-0.790 +.046-018V?                         
+8478 16Lam PsACD-2817653 210934190985 838                   220838.7-281545221418.8-274601 22.58-55.28 5.43  -0.16 -0.55         B8III              +0.026+0.002 +.012-006       38                  
+8479          BD+60 2358 210939 19932    I W                220843.4+601552221201.9+604534104.65  3.68 5.35  +1.17 +1.15         K1III              -0.008+0.019      -003                          *
+8480 41    AqrBD-21 6180 210960190986       15753           220846.7-213418221418.0-210427 33.83-53.78 5.32  +0.80 +0.43         K0III+F2V          +0.016+0.066 +.016-024           1.6   5.1AB   4*
+8481   Eps OctCP-81  995 210967258928 839I         Eps Oct  220849.8-805615222001.5-802623310.04-34.50 5.10  +1.47 +1.09 +1.49E  M5III              +0.043-0.045      +012                          *
+8482          BD+27 4280 211006 90337                       220903.6+280646221338.6+283630 85.75-22.64 5.89  +1.15 +1.22         K2III              +0.071-0.001      -019V?                         
+8483          BD+62 2048 211029 19937    I                  220915.5+624748221222.3+631729106.14  5.73 5.79  +1.67 +1.93         M3IIIab            -0.006-0.010      -014V?                         
+8484          CD-4514644 211053231053                       220927.8-445654221535.1-442707353.42-54.42 6.10  +1.02 +0.81 +0.46C  G8-K0III           +0.013-0.019      -004                           
+8485          BD+38 4711 211073 721551583I  15758  14076    220935.1+391307221352.7+394254 92.76-13.75 4.49  +1.39 +1.45 +0.74   K3III              +0.038+0.013 +.020-011SB   < 17  6.3  28.4AB   4*
+8486   Mu 1GruCD-4114810 2110882310553777                   220935.5-415039221536.9-412048358.65-55.16 4.79  +0.80 +0.47         G8III+G            +0.044+0.022 +.009-007SB                         
+8487          BD+44 4073 211096 51783                       220942.3+445641221349.3+452627 96.12-09.07 5.53  +0.04  0.00         A0III              +0.081+0.009      -009      111                  
+8488   Mu 2GruCD-4215846 211202231063                       221025.6-420729221626.6-413739358.11-55.26 5.10  +0.92               G8III              -0.005-0.013 +.010+013SB                         
+8489          BD+42 4333 211211 517973778                   221032.2+422728221444.4+425714 94.81-11.20 5.71   0.00 -0.04         A2Vnn              +0.049-0.025      -038V?    245                  
+8490          BD+62 2053 211242 19948                       221040.8+623958221349.5+630945106.20  5.53 6.11  -0.08 -0.43         B8Vn               -0.020-0.003      +012SB                         
+8491          BD+07 4834 2112871274203780                   221101.0+080308221559.8+083258 70.86-38.13 6.21  +0.02 -0.04         A1Vn               +0.034-0.011      +000SB    305                  
+8492          CD-2616057 211291191016                       221100.4-262346221637.4-255354 25.98-55.48 6.15  +1.11               K1II/III           +0.037-0.018      +026V?                         
+8493          BD+72 1022 211300 10284       15764  14078    221104.1+724838221252.9+731826112.05 13.88 6.08  +1.01 +0.85         K0II-III+A3V       +0.023+0.020 +.015+001V?         2.3  28.7      *
+8494 23Eps CepBD+56 2741 211336 34227      W       Eps Cep  221120.9+563241221502.0+570237102.86  0.40 4.19  +0.28 +0.04 +0.15   F0IV               +0.447+0.048 +.041-001SB     86  5.3 127.8      *
+8495          BD-02 5726 211356145989                       221124.5-020540221633.6-013547 60.82-44.98 6.15  +0.19 +0.09         A5Vn               -0.029-0.011      +001      199                  
+8496 42    AqrBD-13 6148 211361164974    I                  221126.8-131948221648.1-124953 46.72-51.16 5.34  +1.14 +1.07        gK0                 +0.015+0.006      +013V                          
+8497          CD-2317344 211364191021                       221126.1-233814221659.8-230824 30.73-54.95 6.17  +1.05               G5                 +0.084-0.055      -002V                          
+8498  1    LacBD+37 4526 211388 72191    I                  221136.5+371502221558.2+374456 91.93-15.59 4.13  +1.46 +1.63 +0.72   K3-II-III          +0.013+0.004 +.003-008V?   < 19:                 
+8499 43The AqrBD-08 5845 211391145991 840I                  221133.4-081653221650.0-074700 53.51-48.62 4.16  +0.98 +0.81 +0.48   G8III-IV           +0.121-0.022 +.021-015V?   < 17                 *
+8500          BD-09 5948 211392145992              14095    221135.8-093218221652.6-090224 51.90-49.30 5.79  +1.16 +1.14        gK3                 -0.047-0.009      +012                           
+8501          CP-5410055 211415247400      W                221142.3-540631221815.6-533740339.03-51.39 5.37  +0.60 +0.08         G3V                +0.429-0.667 +.083-014           4.5   3.0       
+8502   Alp TucCP-60 7561 211416255193 841  A                221139.2-604529221830.1-601535330.22-47.96 2.86  +1.39 +1.54 +0.73   K3III              -0.072-0.043 +.026+042SBO              0.1      *
+8503          BD+27 4288 211432 90379                       221153.4+271821221629.7+274815 85.75-23.66 6.37  +0.99               G9III              -0.009+0.002      +016                           
+8504 44    AqrBD-06 5960 2114341459933782          14100    221153.2-055312221706.5-052314 56.54-47.35 5.75  +0.88 +0.51         G6III              -0.002+0.020      +007                           
+8505   Ups OctCP-86  406 2115392589321670                   221235.4-862834223137.4-855802305.61-30.41 5.77  +1.02 +0.88         K0III              -0.041+0.059      +019V                          
+8506          BD+56 2746 211554 34256                       221249.7+564316221626.5+571313103.12  0.43 5.88  +0.93               G8III              +0.043+0.006      -008V                          
+8507          BD-00 4333 211575146004      S                221256.6-004410221804.3-001416 62.64-44.42 6.39  +0.44  0.00         F3V                -0.039-0.062      +017V      12        0.1       
+8508 45    AqrBD-14 6255 211676164996                       221338.7-134820221900.8-131818 46.45-51.85 5.95  +1.06 +0.94        gG7                 +0.079-0.012      +030                           
+8509          CP-58 7942 211726247410                       221356.7-580041222036.2-573036333.47-49.71 6.34  +1.37 +1.71         K3-4III            +0.022-0.015      -034                           
+8510          BD+37 4537 211797 72228       15828           221433.0+371601221856.2+374610 92.44-15.91 6.17  +0.28 +0.11         A9IIIp             +0.057+0.044D+.013+007           2.7  15.7AB   4*
+8511 25    CepBD+62 2059 211833 19991    I                  221456.9+621811221812.7+624816106.41  4.96 5.75  +1.26 +1.37         K3III              +0.046+0.015      -002V                          
+8512 46Rho AqrBD-08 5855 211838146023                       221456.2-081924222011.9-074916 54.15-49.34 5.37  -0.06 -0.37         B8IIIpMn:Hg:       +0.016-0.001      -009V      72                  
+8513 30    PegBD+05 4998 211924127453       15847  14122    221525.6+051713222027.6+054722 69.30-40.86 5.37  -0.02 -0.47         B5IV               +0.023-0.001      -008V      32  5.9  14.8AC   3*
+8514          BD+07 4853 211976127460                       221556.1+074059222055.8+081112 71.63-39.25 6.17  +0.44 -0.03         F6V                +0.048+0.023      +010        7                  
+8515   Nu  IndCP-72 2690 211998258033      W                221602.0-724429222436.8-721520316.86-40.67 5.29  +0.65 -0.06 +0.41E  A3V:+F9V           +1.299-0.678 +.031+021V?         0.1   0.1      *
+8516 47    AqrBD-22 5897 2120101910831584I                  221605.3-220558222135.6-213554 33.84-55.56 5.13  +1.07 +0.92         K2III              -0.008-0.085 +.015+049                           
+8517          BD+26 4410 212047 90437    I         14127    221621.3+262556222100.1+265607 86.05-24.96 6.47  +1.59 +1.71         M4III              +0.015-0.006      -004                           
+8518 48Gam AqrBD-02 5741 212061146044 842   15864  14132    221629.5-015329222139.4-012314 62.18-45.84 3.84  -0.05 -0.12 -0.04   A0V                +0.132+0.007 +.046-015SB     57  7.9  37.4      *
+8519          BD+50 3673 212071 34335                       221642.0+502839222039.6+505851100.20-05.11 6.42R                     K2                 +0.012+0.004      -009                           
+8520 31    PegBD+11 4784 212076107854 843          IN Peg   221635.7+114205222131.1+121219 75.27-36.43 5.01  -0.13 -0.81 -0.14   B2IV-Ve           v+0.009+0.006      +010V?    134                 *
+8521   Pi 1GruCD-4614292 212087231105      W       Pi1 Gru  221637.4-462707222243.9-455652350.28-55.16 6.62  +2.01 +1.86 +2.64   S5,7e              +0.007-0.012      -020           4.3   2.7      *
+8522 32    PegBD+27 4299 212097 90440       15863           221642.2+274936222119.3+281950 87.03-23.88 4.81   0.00 -0.20 -0.01   B9III              +0.018+0.002 +.023+008V?     81  6.3  72.6AB   5 
+8523  2    LacBD+45 3894 212120 51904       15862  14130    221653.6+460159222101.6+463212 97.79-08.86 4.57  -0.10 -0.51 -0.11   B6V                +0.023+0.005 +.040-010SB2O   47  6.4  48.2      *
+8524   Pi 2GruCD-4614295 2121322311113786I:W                221659.5-462554222308.0-455543350.28-55.23 5.62  +0.36 +0.02 +0.22C  F3III-IV           +0.237-0.061 +.027+020V          5.4   4.9      *
+8525          BD+75  820 212150 103123784                   221708.1+755908221820.4+762917114.26 16.27 6.66   0.00 -0.11         A1Vn               +0.005+0.003      -018      165:                 
+8526          CP-75 1748 2121682580363789  W                221710.5-753120222551.0-750056314.28-38.73 6.04  +0.64 +0.14         G3V                +0.048+0.010      +014           2.7  20.4       
+8527          CP-71 2686 2122112580343788                   221721.5-705609222510.5-702554318.51-41.99 5.78  +0.38 +0.03         F3III              +0.115-0.062      +004                           
+8528          BD+41 4469 212222 51918                       221734.0+413426222150.9+420442 95.41-12.66 6.41  -0.08 -0.51         B5V                +0.019 0.000      -018                           
+8529 49    AqrCD-2515905 212271191105                       221756.5-251605222330.9-244545 28.53-56.78 5.53  +0.99 +0.80        gG9                 +0.103 0.000      -011V?                         
+8530          BD-07 5765 212320146062      D                221817.4-074201222332.1-071140 55.66-49.69 5.93  +1.00 +0.69         G6IIIBaII          -0.001+0.007      -014                          *
+8531          CP-58 7954 212330247441    I'W                221818.0-581739222456.4-574750332.61-50.04 5.32  +0.67 +0.13 +0.39   G3IV               +0.143-0.343 +.058+008           7.6  81.        
+8532 33    PegBD+20 5139 212395 90462       15896           221850.8+202034222339.6+205054 82.41-30.16 6.04R                     F7V                +0.337-0.015 +.037-023V          2.2  78.4AC   3*
+8533 51    AqrBD-05 5780 212404146067       15902           221854.3-052035222406.9-045013 58.72-48.44 5.78  -0.04 -0.11         A0V                +0.033-0.004D+.006+006       65  0.0   0.3AB   5*
+8534 50    AqrBD-14 6276 2124301650443791                   221905.7-140211222427.1-133146 47.12-53.13 5.76  +0.97 +0.71         G6.5III            +0.053+0.012      -021V?                         
+8535          BD+56 2765 212454 34383                       221918.7+564643222300.2+571704103.90  0.00 6.16  -0.13 -0.55         B8III-IV           +0.015+0.001      -013                          *
+8536          BD+37 4560 212487 72296                       221928.6+380350222354.2+383425 93.74-15.80 6.22  +0.49 -0.01         F5IV:              +0.255+0.119 -.005+005    =< 10                  
+8537          BD+61 2291 212495 20042                       221938.5+615447222300.2+622512106.66  4.33 6.04  +0.05 +0.02         A1V                -0.005+0.040      -015V     165                  
+8538  3Bet LacBD+51 3358 212496 34395 844I S                221937.5+514341222333.6+521345101.26-04.30 4.43  +1.02 +0.77 +0.57   G8.5IIIbCa1        -0.013-0.186 +.021-010     < 17                  
+8539 52Pi  AqrBD+00 4872 2125711275201585I         Pi  Aqr  222010.2+005212222516.6+012239 66.01-44.74 4.66  -0.03 -0.98 +0.02   B1Ve              v+0.019+0.001      +004V     278                 *
+8540   Del TucCP-65 4044 212581255222      W       14158    222013.4-652830222720.0-645759323.87-45.87 4.48  -0.03 -0.07         B9.5V              +0.071+0.003      +012      245  4.5   6.9      *
+8541  4    LacBD+48 3715 212593 51970                       222027.6+485810222431.0+492835 99.90-06.71 4.57  +0.09 -0.34 +0.10   B9Iab              -0.007-0.003 +.003-026       27                  
+8542          CD-2417171 2126431911443793                   222038.9-241126222610.7-234057 30.71-57.13 6.29  -0.03               A0V                +0.018-0.002      -015V                          
+8543          BD+17 4746 2126701079061586                   222051.1+175608222540.7+182640 81.10-32.34 6.26  +1.22               K0                 +0.028+0.027      +022                           
+8544 53    AqrBD-17 6520 212697165077       15934B          222108.3-171459222634.2-164429 42.55-54.98 6.57H                     G2V                +0.262-0.013 +.057-003V?      7  0.2   3.3AB   4*
+8545 53    AqrBD-17 6521 212698165078       15934A          222108.7-171503222634.4-164433 42.55-54.98 6.35H +0.61 +0.09         G1V                +0.223-0.003 +.057-006        9  0.2   3.3AB   4*
+8546          BD+85  383 212710  37211648                   222117.8+853617221310.6+860629120.22 24.10 5.27  -0.03 -0.11         B9.5Vn             +0.052+0.045 +.006+004SB2   219                  
+8547          CP-68 3493 2127282552271587                   222116.0-675948222837.7-672921321.11-44.26 5.55  +0.20 +0.08         A4V                +0.149-0.072      -017                           
+8548 34    PegBD+03 4705 212754127529       15935           222132.0+035301222637.4+042337 69.38-42.93 5.75  +0.52 +0.04         F7V                +0.301+0.048 +.041-018V       7  6.5   3.3AB   3*
+8549          BD+36 4835 212883 72344       15942           222219.2+365605222645.7+372638 93.58-17.05 6.46  -0.13 -0.75         B2V                +0.013-0.003      -007       25  3.3   4.3      *
+8550          BD+77  860 212937 10351                       222251.4+774406222341.3+781436115.55 17.55 6.76  -0.06 -0.16         B9                 -0.008+0.018      -018                          *
+8551 35    PegBD+03 4710 2129431275403796I W                222247.8+041139222751.5+044144 69.98-42.94 4.79  +1.05 +0.89 +0.56   K0III              +0.081-0.308 +.025+054V    < 19: 4.9 181.5AC   3 
+8552   Nu  GruCD-3914723 212953213850 845  W                222247.6-393816222839.2-390755  1.71-58.04 5.47  +0.95               G9III              +0.039-0.164 +.015+011           7.0  27.3       
+8553          BD+39 4841 212978 72358      S                222303.4+391801222726.5+394835 95.04-15.14 6.14  -0.14 -0.77         B2V                +0.001-0.011      -017      115        0.2      *
+8554          BD+55 2750 212986 344603795                   222311.8+555525222659.2+562600103.91-01.01 6.57  -0.10 -0.47         B5III              +0.019 0.000      -007V?                         
+8555          BD+31 4701 212988 72366    I                  222311.4+311945222746.2+315025 90.46-21.82 5.98  +1.45               K2                 +0.045+0.034      +001                           
+8556   Del1GruCD-4414931 213009231154 846  W       14169    222317.6-440023222916.2-432944353.77-57.05 3.97  +1.03 +0.80 +0.56   G6-8III            +0.028-0.005 +.024+005           8.8   5.6       
+8557          BD+70 1240 213022 103663794I                  222325.6+701541222600.8+704615111.45 11.22 5.47  +1.20              gK2                 +0.018+0.006      -017V                          
+8558 55Zet1AqrBD-00 4365 213051146107    I: 15971B          222340.8-003153222849.7-000113 65.35-46.33 4.59H                     F6IV               +0.181+0.009 +.022+029V?     58  0.2   1.8     3*
+8559 55Zet2AqrBD-00 4365 213052146108    I  15971A          222341.0-003156222850.1-000112 65.35-46.33 4.42H +0.38 -0.01 +0.23   F3V                +0.209+0.042 +.022+025       58  0.2   1.8     3*
+8560   Del2GruCD-4414935 213080231161    I'W       Del2 Gru 222347.1-441539222945.5-434458353.28-57.06 4.11  +1.57 +1.71 +1.58   M4.5IIIa           -0.007 0.000 -.005+002V?         4.7  60.6      *
+8561 26    CepBD+64 1664 213087 200753797                   222352.2+643720222705.3+650756108.50  6.39 5.46  +0.37 -0.59         B0.5Ibe:           +0.001-0.002      -015V                         *
+8562 36    PegBD+08 4874 2131191275441588I                  222408.5+083706222908.0+090744 74.39-39.97 5.58  +1.55 +1.91         K5IIIa             +0.055-0.022      -030V?                         
+8563          CD-2715932 2131351911823798          14175    222410.4-273707222946.0-270626 24.69-58.58 5.95  +0.33               F1V                +0.123-0.012      +003                           
+8564          BD+26 4439 213179 905441589                   222429.0+261507222910.2+264547 87.57-26.17 5.79  +1.25               K2II               +0.026-0.004      -045V                          
+8565          BD-13 6204 213198165123                       222440.7-132537223001.5-125454 49.10-54.04 6.40  +0.32 -0.02         F3IV               +0.168+0.001      -011                          *
+8566 37    PegBD+03 4713 213235127551       15988           222454.6+035525222958.0+042554 70.23-43.50 5.48  +0.38 +0.09 +0.20   F2V+F2V            -0.023-0.144 +.032+001SB1O   66  1.4   0.9      *
+8567 56    AqrBD-15 6231 213236165127                       222455.8-150549223017.4-143509 46.61-54.87 6.37  -0.04 -0.37         B8V s              +0.039-0.039      -027       25                 *
+8568          BD+63 1852 213242 20088                       222459.6+633429222819.7+640508108.06  5.43 6.29  +1.08               K0                 +0.023-0.013      -026                           
+8569          BD+34 4700 213272 72399                       222514.1+351253222943.9+354332 93.12-18.81 6.56                      A2V                -0.026-0.037      -002                           
+8570   Zet PsACD-2616175 213296191196              14180    222520.2-263504223053.7-260425 26.73-58.67 6.43  +1.08               K1III              +0.034-0.070      -026                           
+8571 27Del CepBD+57 2548 213306 34508 847I  15987A Del Cep  222527.3+575412222910.3+582455105.19  0.53 3.75  +0.60       +0.40   F5Ib-G2Ib         v+0.015+0.001 +.011-015SB      9  2.4  40.8AC   3*
+8572  5    LacBD+46 3719 213310 520553799I S       14177    222521.7+471142222931.8+474225 99.66-08.65 4.36  +1.68 +1.11 +1.07   M0II+B8V           +0.002 0.000 +.006-004SBO =< 50                 *
+8573 57Sig AqrBD-11 5850 2133201651341591                   222521.3-111123223038.8-104041 52.49-53.05 4.82  -0.06 -0.11 -0.04   A0IV s             +0.003-0.030 +.021+011SB     23                 *
+8574 38    PegBD+31 4708 213323 724061590  S                222527.3+320339223001.8+323421 91.33-21.48 5.65  -0.04 -0.11         B9.5V              +0.034-0.014      -016V     104        0.2       
+8575          BD+48 3747 213389 52073      W       V350 Lac 222559.6+485041223006.5+492122100.61-07.29 6.40  +1.15 +1.00         K2IIIe             -0.024-0.043      +004SB1O       3.2  66.0      *
+8576 17Bet PsACD-3217126 2133982138831592  W                222549.3-325132223130.3-322046 14.59-59.32 4.29  +0.01 +0.02 +0.02   A0V                +0.065-0.018 +.021+006       36  3.5  30.3AD   4*
+8577          CP-79 1206 2134022580493807                   222555.3-791712223526.4-784618310.69-36.22 6.15  +1.38 +1.35         K1III              +0.046-0.006      -013                           
+8578 28Rho1CepBD+78  796 213403 10375                       222557.4+781634222642.5+784709116.00 17.91 5.83  +0.15?              A2Vm               -0.016-0.043      -006V?     58                  
+8579  6    LacBD+42 4420 213420 520793800                   222610.2+423639223029.3+430724 97.36-12.64 4.51  -0.09 -0.74 -0.11   B2IV               -0.001-0.005      -008SBO    74                 *
+8580          BD-03 5460 2134281461363802                   222608.2-032525223118.4-025440 62.68-48.67 6.16  +1.08 +1.00         K0                 -0.005-0.036      +010V                          
+8581          BD-07 5797 213429146135      S                222603.6-070355223118.4-063318 58.21-50.90 6.14  +0.56 +0.06         F7V                +0.173-0.106 +.044-006V   =<  6        0.1       
+8582   Nu  TucCP-62 6348 2134422552473803          Nu  Tuc  222614.5-622945223300.1-615856326.58-48.30 4.81  +1.61 +1.75         M4III              +0.039-0.025 +.007-003                           
+8583 58    AqrBD-11 5855 213464165147                       222623.2-112505223141.3-105420 52.39-53.39 6.38  +0.28 +0.07 +0.16   A8III              +0.075-0.045      +004SB                         
+8584          BD+28 4389 213534 90568              GX Peg   222656.1+290148223134.2+293234 89.80-24.18 6.35  +0.19?              A5m                -0.044-0.029      +002SBO    48                 *
+8585  7Alp LacBD+49 3875 213558 34542 848   16021           222710.2+494606223117.5+501657101.26-06.60 3.77  +0.01  0.00 -0.03   A1V                +0.138+0.019 +.040-004V?    146  8.3  36.3      *
+8586 39    PegBD+19 4949 2136171079863804                   222745.5+194252223235.5+201348 83.91-31.92 6.42  +0.32 +0.02         F1V                +0.163+0.029 +.013-019                          *
+8587          BD+15 4670 2136441079893806                   222753.6+152052223246.9+155148 80.76-35.42 6.32  +1.19 +1.17         K0                 +0.022+0.026      -028                           
+8588          BD+39 4871 213660 724463805   16031           222801.0+391555223226.4+394647 95.87-15.68 5.88  +0.16 +0.14         A6V                +0.004-0.011      +005V?    111  5.5  43.1AB   5 
+8589          BD+53 2910 213720 34555                       222820.6+533119223218.8+540215103.32-03.45 6.35R                     G8III              +0.035+0.027      -014                           
+8590 60    AqrBD-02 5781 213789146160      W                222853.6-020520223402.9-013427 64.89-48.33 5.89  +0.99 +0.73         G6III              +0.036-0.040      -008           4.4  98.1AB   3 
+8591 29Rho2CepBD+78  801 213798 104021593                   222859.8+781840222952.9+784927116.16 17.86 5.50  +0.06 +0.07         A3V                +0.001-0.022 +.008+001SB    115                 *
+8592 59Ups AqrBD-21 6251 213845191235 849                   222913.5-211314223441.6-204230 37.08-58.20 5.20  +0.44  0.00         F4IV               +0.222-0.145 +.046-002       18                  
+8593          CP-58 7971 213884247505                       222924.5-582402223552.9-575301331.15-51.17 6.23  +0.20               A5V                +0.077-0.009      +005                           
+8594          BD+55 2769 213930 34574    I         14213    222947.8+560627223340.6+563730104.80-01.32 5.71  +0.96               G8III-IV           +0.073+0.047      -011SB                        *
+8595          BD+69 1262 213973 20150       16057           223008.8+692345223302.9+695449111.50 10.17 6.6   +0.32  0.00         A9III              +0.116+0.068 +.002-002V?     77  0.3   0.5AB   4*
+8596          CD-2417232 213986191246                       223006.4-243029223536.5-235928 31.10-59.30 5.97  +0.99 +0.81        gK0                 +0.039-0.006      -003V                          
+8597 62Eta AqrBD-00 4384 213998146181 850                   223013.0-003759223521.4-000703 66.84-47.61 4.02  -0.09 -0.26 -0.07   B9IV-Vn            +0.091-0.056 +.025-008V?    280                  
+8598          BD+69 1263 214019 10418       16062           223027.2+695126223317.0+702226111.76 10.56 6.34   0.00 -0.06         A0V                +0.051+0.020 -.003-019      165  3.0   9.7AB   3*
+8599          BD+75  836 214035 104141594                   223030.9+754240223216.2+761335114.82 15.60 5.68  +0.05 +0.08         A2V                -0.021-0.011      -022SB    100                  
+8600   Sig1GruCD-4114959 2140852312113811                   223038.9-410555223629.3-403458358.33-59.17 6.28  +0.12 +0.13         A3Vn               +0.048-0.070      +001SB                         
+8601          CD-3217161 214122213948      W                223057.7-321050223635.4-313950 15.94-60.40 5.82  +1.09 +1.00         K1III              -0.042-0.044      +013           1.8  91.7       
+8602   Sig2GruCD-4114963 214150231217      W                223108.7-410626223658.8-403528358.27-59.26 5.86  +0.06 +0.06         A1V                +0.038-0.075      +015       58  5.2   2.8      *
+8603  8    LacBD+38 4808 214168 72509       16095A 14242    223125.2+390700223552.3+393803 96.38-16.15 5.73  -0.15 -0.90         B2Ve              v+0.005-0.006      -010SB    348  0.7  22.4AB   8*
+8604          BD+34 4728 214200 72517      W                223135.2+350340223607.9+353438 94.20-19.63 6.10  +1.00               K0                  0.000-0.067      -016                          *
+8605          BD+10 4781 214203108036                       223138.9+111042223636.4+114149 78.37-39.24 6.40   0.00 +0.06         A1III              -0.008+0.018      -008                           
+8606          BD+49 3903 214240 52171                       223144.0+493310223553.4+500416101.79-07.15 6.29  -0.05 -0.54         B3V                +0.006+0.008      -015SB2O   60                 *
+8607          BD+55 2779 214279 34605                       223156.6+553309223551.8+560412104.79-01.95 6.38  +0.12 +0.09         A3V                -0.003-0.019      -002                           
+8608          BD+11 4838 214298108043    I                  223208.1+120333223704.7+123438 79.21-38.63 6.30                      K5                 -0.030-0.017      -019                           
+8609          BD+34 4729 214313 725353812                   223215.9+350802223648.7+353909 94.37-19.64 6.30  +1.37               K5                 -0.004 0.000      +010                           
+8610 63Kap AqrBD-04 5716 2143761462101595I W                223234.6-044438223745.4-041341 62.68-50.75 5.03  +1.14 +1.16 +0.55   K2III              -0.067-0.120 +.019+008     < 19: 3.5  98.3      *
+8611          CP-5310326 214441247531      W       CC Gru   223257.6-531242223908.4-524132337.71-54.56 6.65  +0.35               F1III              +0.005-0.016      +011V?         4.7  33.8      *
+8612          BD-08 5912 214448146216       16130  14255    223307.4-082502223822.2-075352 58.10-53.10 6.23  +0.78 +0.49         G0III+F0V          +0.076-0.004      -017V?         1.8   0.2      *
+8613  9    LacBD+50 3770 214454 34628                       223315.8+510144223722.4+513243102.73-05.99 4.63  +0.24 +0.10 +0.14   A8IV               -0.054-0.101 +.022+012SB     87                  
+8614          CD-2918414 214462191292                       223311.0-291604223844.7-284452 21.91-60.74 6.47  +1.04               K1III              -0.035+0.001      +003V?                         
+8615 31    CepBD+72 1049 214470 10425 851                   223317.8+730727223546.1+733835113.64 13.27 5.08  +0.39 +0.16         F3III-IV           +0.172+0.023 +.008+000V      85                 *
+8616          CD-3316160 2144842139813814                   223312.5-333606223851.5-330453 13.03-60.84 5.66  +0.05               A2Vp               +0.006+0.014      +004SB2     0                  
+8617          BD+44 4185 214558 52211      S                223357.7+443947223817.5+451059 99.67-11.59 6.40R                     G2III+A4V          +0.003 0.000      -004    =< 50        0.1      *
+8618 40    PegBD+18 5014 214567108064      W                223402.2+190017223852.6+193120 84.84-33.37 5.82  +0.92               G8II               -0.042-0.099 +.010-020V          5.6   1.5       
+8619          CD-2817873 214599191308       16149A          223410.2-285043223944.0-281931 22.82-60.92 6.31  +1.01               K0IV               +0.076-0.031D+.010-022           1.3  86.6AB   3*
+8620          CP-58 7984 2146322475443816                   223426.5-575637224048.9-572520331.07-51.97 5.97  +1.46 +1.70         K4III              +0.055-0.007      -032                           
+8621          BD+56 2821 214665 34651    I  16140  14260    223441.8+561634223837.9+564745105.48-01.51 5.21R +1.58 +1.70         M4+III             +0.053-0.029 -.013+008           5.2  30.9      *
+8622 10    LacBD+38 4826 214680 72575 852   16148           223446.3+383147223915.7+390301 96.65-16.98 4.88  -0.20 -1.04 -0.22   O9V                +0.001-0.005      -010V?     31  5.2  62.2      *
+8623          CD-3118920 214690214000    I         14266    223447.6-311028224022.3-303932 18.02-61.20 5.87  +1.30 +1.44         K3III              -0.103-0.209 +.014+079                           
+8624 41    PegBD+18 5021 214698108078                       223456.2+190937223947.0+194052 85.16-33.36 6.21R  0.00 +0.08         A2V                -0.004-0.010      -011V?     80                  
+8625          BD+74  978 214710 10440    I                  223504.2+745106223713.0+752218114.63 14.71 5.79  +1.57 +1.91         M1IIIab            +0.044+0.006      -007                           
+8626          BD+36 4902 214714 72581       16154           223502.8+370419223934.3+373534 95.93-18.27 6.03  +0.86               G3Ib-IICN-1CH2Fe-1 +0.008-0.001      -007V          5.7  19.5      *
+8627 30    CepBD+62 2102 214734 20190 853                   223506.0+630352223839.0+633504108.79  4.42 5.19  +0.06  0.00         A3IV               -0.003-0.025 +.008+011SB2   140                  
+8628 18Eps PsACD-2716010 214748191318 854          14270    223507.5-273354224039.4-270237 25.49-60.97 4.17  -0.11 -0.37 -0.09   B8V               e+0.030-0.001      +003      290                  
+8629          BD-04 5728 214810146239      W                223537.5-040429224048.0-033315 64.27-50.90 6.31  +0.52  0.00         F6V                +0.003-0.042D+.012+012V          0.5   0.3AB   3*
+8630   Bet OctCP-82  889 214846258941 924                   223551.2-815421224603.3-812254308.35-34.38 4.15  +0.20 +0.11 +0.10   A9IV-V             -0.067-0.001      +024SB     71                  
+8631          BD+13 4971 214850108094       16173           223555.3+140125224052.7+143258 81.67-37.65 5.71  +0.72 +0.22         G4V                +0.268+0.144 +.032-010V          0.5   0.4AB   3*
+8632 11    LacBD+43 4266 214868 52251    I                  223607.6+434515224030.9+441635 99.56-12.57 4.46  +1.33 +1.36 +0.68   K2+III-IIIb        +0.094+0.012 +.010-010V?   < 17                 *
+8633          BD+53 2950 214878 34682                       223614.2+531929224018.4+535046104.25-04.20 5.93  +0.93               K0III              +0.001-0.014      -006                           
+8634 42Zet PegBD+10 4797 214923108103 855   16182           223628.4+101833224127.7+104953 78.86-40.66 3.40  -0.09 -0.25 -0.07   B8V                +0.080-0.013 +.023+007V?    194  8.9  64.3      *
+8635          CD-4714307 214953231257      W       14277    223639.3-474329224236.9-471238345.74-57.80 5.98  +0.58 +0.08 +0.32C  G0V                +0.009-0.326 +.067+017           4.0   7.8      *
+8636   Bet GruCD-4714308 214952231258 856I         Bet Gru  223641.8-472427224240.1-465305346.27-57.95 2.10  +1.60 +1.67 +1.65   M5III              +0.137-0.008 +.008+002                          *
+8637 19    PsACD-3019267 214966191337    I                  223648.4-295301224222.1-292139 20.76-61.58 6.17  +1.54 +1.90         M5III              +0.028-0.015      -009V?                         
+8638          BD+30 4771 214979 72625    I                  223650.9+302636224131.4+305757 92.62-24.15 6.34R                     K5                 +0.063 0.000      -035                           
+8639          CD-4415017 214987231260              14278    223650.3-444620224243.1-441452350.85-59.06 6.07  +0.98 +0.69 +0.46C  K0III              +0.042+0.037      +006V?                        *
+8640 12    LacBD+39 4912 214993 72627      W       DD Lac   223659.9+394211224128.6+401332 97.65-16.18 5.25  -0.14 -0.87         B2III              -0.005-0.001      -015SB     53  4.0  69.0      *
+8641 43Omi PegBD+28 4436 214994 90717                       223703.6+284708224145.4+291827 91.71-25.59 4.79  -0.01 -0.01 -0.02   A1IV               -0.004-0.027 +.024+009V      12                 *
+8642          BD+13 4974 214995108109                       223701.1+135939224157.4+143059 81.92-37.83 5.90  +1.11              gK0                 +0.092-0.021 -.010-026V                          
+8643          BD+40 4885 215030 52270                       223707.8+410129224136.1+413258 98.35-15.04 5.94R                     G9III              +0.148+0.065 +.001-014                           
+8644   Rho GruCD-4216049 2151042312653818  W                223742.1-415608224330.0-412452356.00-60.20 4.85  +1.03 +0.80 +0.65   K0III              +0.006-0.095 +.030+029V?         9.1  14.2      *
+8645          BD-09 6038 215114146271       16208           223749.0-085006224303.5-081842 58.68-54.29 6.45  +0.17 +0.12         A5V                +0.024-0.006D+.004+005V?         1.1   2.5AB   4*
+8646          CP-61 6676 215121255299                       223748.4-610127224416.5-602958326.89-50.30 6.30  +0.56               F3V                +0.004+0.025      -006V                          
+8647 67    AqrBD-07 5838 2151431462733819                   223800.9-072911224314.3-065746 60.56-53.52 6.41  -0.04 -0.11         A0Vn               +0.030-0.008      +002      142                  
+8648          BD+53 2960 215159 347133817I                  223815.3+532308224220.8+535432104.55-04.29 6.12  +1.62               K2                 -0.001-0.006      +009                           
+8649 66    AqrBD-19 6324 215167165252    I         14291    223812.4-192113224335.3-184949 41.88-59.52 4.69  +1.37 +1.56 +0.72   K4III              -0.027-0.028 +.013+022     < 19:                *
+8650 44Eta PegBD+29 4741 215182 90734 857I  16211  14285    223818.8+294153224300.1+301317 92.50-24.95 2.94  +0.86 +0.55 +0.48   G2II-III+F0V       +0.015-0.025 +.017+004SB1O    9  5.1  90.4AxBC 6*
+8651          BD+37 4670 215191 72652                       223822.9+371645224255.5+374810 96.64-18.42 6.43  -0.09 -0.81         B1V                +0.011-0.009      -018SB                        *
+8652          BD+46 3803 215242 52296       16214  14290    223845.3+463841224304.5+471007101.40-10.27 6.39  +0.47 -0.06         A1V+G:             +0.014-0.002D+.002-017SB         1.6   0.5AxBC 3*
+8653          BD+10 4805 215243108131                       223843.7+102510224342.7+105621 79.52-40.92 6.51  +0.46  0.00         G8IV               +0.015-0.168      -002    =<  6                 *
+8654          BD+38 4855 215359 72675    I  16228           223934.2+385629224405.2+392756 97.71-17.09 5.95  +1.48               K5III+K2III        +0.007-0.021 +.010-027SB         3.5   2.7AB   3*
+8655   Eta GruCP-5410123 2153692475703821  W                223929.7-540134224537.9-533001335.60-54.90 4.85  +1.18 +1.17         K2IIICNIV          +0.029+0.014 +.005+028SB         6.6  24.4       
+8656 13    LacBD+41 4594 215373 52317 858I  16227           223937.8+411740224405.5+414909 98.91-15.04 5.08  +0.96 +0.78         K0III              -0.007+0.004 +.010+013V?   < 19: 5.8  14.6      *
+8657          CD-4714320 215405231278                       223946.5-470421224540.7-463251346.39-58.57 5.51  +1.32 +1.43 +0.60C  K2III              -0.031-0.020 -.003+042V?                         
+8658          CD-4913955 215456231285                       224007.4-493012224608.0-485844342.31-57.46 6.62  +0.63               F9V                +0.203-0.050      -019                           
+8659          CD-5013788 215504231287                       224027.9-501215224628.3-494109341.14-57.14 6.48  +1.14               K1III              +0.089-0.277      +002                           
+8660 45    PegBD+18 5046 2155101081541596                   224036.2+185021224528.2+192200 86.26-34.39 6.25  +1.05              gG6                 -0.026+0.056      -022V?                         
+8661          BD+51 3460 215518 34757    I                  224038.9+515929224449.2+523102104.21-05.69 6.55R                     K2                 -0.001+0.012      +005                           
+8662          CD-4714331 215545231290      W                224048.6-472758224643.7-465622345.57-58.54 6.56  +0.30 +0.11 +0.16C  A9IIIm:            +0.058+0.004      -001SB         3.0  10.5      *
+8663   Xi  OctCP-80 1055 215573258946                       224103.3-803905225022.9-800727309.03-35.53 5.35  -0.15 -0.50         B6IV               +0.017-0.022      +016V?      0                  
+8664          CP-77 1554 215631258069                       224121.6-773443224940.9-770302311.22-38.05 6.73  +0.11 +0.10         A4V                +0.071+0.013      -009                           
+8665 46Xi  PegBD+11 4875 215648108165    I  16261           224141.8+113936224641.6+121022 81.28-40.39 4.19  +0.50 -0.03 +0.31   F6III-IV           +0.235-0.498 +.052-005V       7  7.5 145.0AC   3*
+8666          BD+43 4300 215664 52348              14311    224143.9+440108224610.2+443246100.60-12.83 5.76  +0.36 +0.08         F0III-IV           +0.140+0.032 +.019-010                          *
+8667 47Lam PegBD+22 4709 215665 90775 859I                  224142.8+230222224631.9+233356 89.26-31.02 3.95  +1.07 +0.91 +0.51   G8IIIa*            +0.058-0.010 +.042-004     < 19:                 
+8668          CD-3415735 215669214081                       224142.6-344122224719.1-340940 10.46-62.51 6.28  +1.16               K1III              -0.066+0.048      +041                           
+8669          CP-62 6369 215682255321                       224152.4-621242224821.4-614103325.03-49.83 6.37  +1.06 +0.90         K0III              +0.069+0.003      -018                           
+8670 68    AqrBD-20 6486 2157211652931597I                  224210.9-200806224733.1-193648 41.10-60.68 5.26  +0.94 +0.59         G7III              -0.101-0.204 +.034+023                           
+8671          CD-3815217 215724214087                       224206.1-384450224747.1-381319  1.85-61.88 6.71  +0.48 -0.02?        F4IV               -0.068-0.076      +027                           
+8672          CP-71 2726 215729258070                       224208.9-705236224917.4-702052316.54-43.41 6.34  +0.07 +0.10         A2V                +0.005+0.040      +008                           
+8673 69Tau1AqrBD-14 6346 215766165298       16268           224224.2-143501224742.8-140323 51.06-58.35 5.66  -0.05 -0.25         A0V                +0.032-0.009      +015SB     71  3.9  23.7AB   3*
+8674          CD-2616324 2157821914123824                   224226.9-262611224756.2-255443 28.36-62.41 6.30  +0.91               G5III              +0.112-0.114      -026V                          
+8675   Eps GruCD-5113389 215789247593 860          14320    224230.9-515034224833.3-511901338.31-56.53 3.49  +0.08 +0.10 +0.07   A3V                +0.108-0.071 +.044+000V     236                  
+8676 70    AqrBD-11 5923 2158741653083825          FM Aqr   224314.5-110501224830.2-103320 56.80-56.68 6.19  +0.28               A9III-IV           +0.035+0.007      -006                          *
+8677          BD+57 2612 215907 34824                       224324.7+575719224723.2+582858107.31-00.57 6.36  -0.04 -0.03         B9.5IV             +0.007+0.001      +004V      73                  
+8678          BD+36 4934 215943 72732              14321    224336.2+365326224810.9+372500 97.40-19.27 5.90  +1.03 +0.83        gG8                 -0.055-0.058      -025                           
+8679 71Tau2AqrBD-14 6354 216032165321 861I W       14329    224417.9-140714224935.5-133533 52.27-58.52 4.01  +1.57 +1.95 +0.95   M0III              -0.012-0.038 +.021+001           4.5 132.5      *
+8680          CD-3316244 216042214119      W                224424.9-332002224959.1-324819 13.31-63.19 6.33  +0.31               F0V+F3V            -0.050-0.017D+.015+024           0.2   0.3      *
+8681          BD+09 5111 216048108204                       224431.8+095703224932.3+102844 80.64-42.17 6.54  +0.29 +0.05         F0IV-V             +0.091-0.031      -008V?    129                  
+8682          BD+53 2993 216057 34845                       224438.7+535311224847.8+542454105.62-04.28 6.12  -0.07 -0.49         B5Vne              -0.018+0.007      -019V?    358                 *
+8683          BD+62 2115 216102 20253                       224457.8+622440224844.2+625618109.49  3.32 6.06  +1.20               K0                 +0.007-0.052      -027                           
+8684 48Mu  PegBD+23 4615 216131 90816 862I                  224510.5+240425225000.2+243606 90.68-30.56 3.48  +0.93 +0.68 +0.47   G8+III             +0.147-0.042 +.040+014        7                  
+8685          CD-3914848 2161492141341599                   224520.7-394111225102.2-390925359.57-62.25 5.42  +1.43 +1.69         M0III              +0.022-0.011 -.001+027                           
+8686          CP-60 7610 2161692553363826                   224526.7-602441225144.9-595253326.58-51.40 6.46  +1.13               K1IIICNII          -0.046-0.009      +000                           
+8687          BD+67 1468 216172 20259       16291A          224536.0+680222224900.7+683413112.09  8.31 6.19R                     F5V                +0.112+0.068 +.025+003V?         0.2   4.3AB   3*
+8688          BD+55 2820 216174 34858    I                  224538.5+552221224946.2+555410106.42-03.02 5.43  +1.17 +1.12         K1III              +0.083+0.043      -036                           
+8689          CP-63 4826 216187255339      W                224540.6-634304225209.9-631119322.94-49.05 6.12  +1.03 +0.94         K0III              +0.016-0.040      -004           3.0   0.9       
+8690 14    LacBD+41 4623 216200 52412      S       V360 Lac 224551.0+412526225021.8+415713100.04-15.47 5.92  +0.08 -0.51         B3IV:             e+0.010 0.000      -014SB2   225        1.0      *
+8691          BD+18 5059 216201108211                       224545.4+183642225039.1+190827 87.35-35.25 6.40R                     K0                 +0.050-0.020      -039                           
+8692          BD+49 3954 216206 34862                       224552.6+500850225010.2+504037104.10-07.71 6.21  +1.14 +0.89         G4Ib               +0.013+0.004      -009SB?                        
+8693 21    PsACD-3019324 216210191444                       224550.1-300358225120.9-293210 20.59-63.54 5.97  +0.91 +0.59         G8/K0III           -0.004-0.011      +005V?                         
+8694 32Iot CepBD+65 1814 216228 20268 863I                  224607.1+654028224940.8+661202111.07  6.18 3.52  +1.05 +0.90 +0.51   K0-III             -0.065-0.125 +.041-012     < 19:                *
+8695 22Gam PsACD-3316270 216336214153      W       14338    224658.1-332421225231.6-325232 13.06-63.72 4.46  -0.04 -0.14 +0.02   A0III*             -0.030-0.025 +.043+017V?     55  3.6   4.2      *
+8696          BD+60 2450 216380 20281       16317           224728.2+610954225122.8+614149109.20  2.07 5.60  +0.78 +0.39         G8III-IV+G2IV      +0.108+0.044 +.005+002           1.2   1.6AB   3*
+8697 49Sig PegBD+09 5122 2163851278103828                   224719.9+091813225224.1+095008 80.87-43.10 5.16  +0.48 -0.01         F7IV               +0.522+0.044 +.043+012SB      0  8.4 248.       *
+8698 73Lam AqrBD-08 5968 216386146362 864I         Lam Aqr  224723.8-080642225236.9-073447 62.19-55.73 3.74  +1.64 +1.74 +1.19   M2.5IIIaFe-1      e+0.011+0.037 +.017-009                          *
+8699 15    LacBD+42 4521 216397 52436    I  16325           224731.3+424651225202.0+431845100.97-14.41 4.94  +1.56 +1.94 +0.72E  M0III              +0.110+0.029 +.021-017V          6.0 104.4AC   5*
+8700   Tau1GruCD-4913988 216435231343    I'                 224742.7-490740225337.9-483553341.70-58.71 6.04  +0.62 +0.19         G0V                +0.216-0.078 +.042-001                          *
+8701   Rho IndCP-70 2971 216437258084 865I'                 224742.3-703628225439.4-700425316.27-43.90 6.05  +0.66 +0.24         G2-3IV             -0.050+0.072      -003                           
+8702          BD+82  703 216446  3794       16294           224752.7+823724224729.0+830914119.16 21.21 4.74  +1.26 +1.35 +0.67   K3III              +0.021+0.049 -.018-031     < 19: 4.7   3.5       
+8703          BD+16 4831 2164891082313829          IM Peg   224806.9+161838225302.3+165028 86.36-37.48 5.64  +1.12 +0.90         K1-2II-III        e-0.018-0.024      -012SB1O                      *
+8704 74    AqrBD-12 6371 216494165359      S       HI Aqr   224812.8-120854225328.7-113700 56.42-58.28 5.80  -0.08 -0.31 -0.05   B9III              +0.025+0.001      -007SB2O    5  0.5   0.1      *
+8705          BD+49 3962 216523 34917                       224832.3+495251225252.3+502443104.37-08.14 6.46  -0.04 -0.34         B8V                +0.019-0.011      -011V?                         
+8706          BD+39 4957 216538 72812              14346    224837.1+393809225311.3+401002 99.67-17.30 6.34  -0.08 -0.44         B7III-IV           +0.001-0.009      +007       15                  
+8707          BD+59 2595 216595 349213830I                  224904.3+593409225303.8+600604108.68  0.55 6.01  +1.75             sgK2                 +0.017+0.002      -007SB                         
+8708          BD+43 4331 216608 52465       16345           224911.5+441302225340.1+444457101.91-13.26 5.81  +0.26 +0.10 +0.14   A3Vm+F6V           -0.016-0.013 +.018+012SB     40  1.5   0.9AB   3*
+8709 76Del AqrBD-16 6173 216627165375 866          14356    224920.6-162110225439.0-154915 49.58-60.67 3.27  +0.05 +0.08 +0.04   A3V                -0.040-0.025 +.038+018V      71                 *
+8710 78    AqrBD-07 5886 216637146382                       224921.7-074410225434.1-071217 63.25-55.87 6.19  +1.28 +1.41         K3III              -0.012-0.038      +009V?                         
+8711 77    AqrBD-17 6619 216640165376              14358    224928.0-164808225445.5-161619 48.79-60.90 5.56  +1.14 +1.09         K2.5IIIb           -0.222-0.090 +.019-036V                          
+8712          BD+39 4964 216646 52471                       224931.7+395037225407.0+402237 99.94-17.20 5.81  +1.13               K0III              +0.103+0.036      -006                          *
+8713          CD-3714981 2166662141823831                   224938.2-365518225514.9-362319  5.02-63.75 6.40  +1.31               K2III              +0.046+0.002      -026                           
+8714          BD+16 4833 216672108246    I         HR Peg   224939.8+162434225435.7+165630 86.83-37.61 6.12  +1.77 +1.86         S4+/1+             +0.019-0.008      +011                          *
+8715  1    PscBD+00 4939 216701127836                       224952.5+003155225459.5+010353 73.39-50.26 6.11  +0.20 +0.15         A7III              +0.023+0.001      +013                           
+8716          BD-05 5885 216718146388       16365  14360    224959.8-053114225511.0-045916 66.38-54.55 5.72  +0.88 +0.60         K0III-IV           +0.034-0.005D+.012-009V?         2.0   0.6      *
+8717 50Rho PegBD+08 4961 216735127839                       225011.6+081657225513.7+084857 80.79-44.34 4.90   0.00  0.00 -0.02   A1V                +0.079+0.014 +.006-010SB?    97                  
+8718          BD+36 4956 216756 728381600                   225023.5+363237225502.6+370437 98.51-20.21 5.91  +0.42 -0.08         F5II               +0.086+0.007      -028    =< 10                  
+8719          CD-3217312 216761214187                       225020.3-320959225551.4-313759 15.79-64.50 6.10  +1.36 +1.52         K3III              -0.033-0.006      +022V                          
+8720 23Del PsACD-3316303 216763214189    I W                225024.6-330426225556.9-323223 13.69-64.46 4.21  +0.97 +0.69 +0.61   G8III              +0.018+0.031 +.021-012           5.0   5.2      *
+8721          CD-3217321 216803214197              TW PsA   225050.3-320541225624.0-313356 15.94-64.61 6.48  +1.10 +1.02 +0.59   K4V                +0.327-0.162 +.130+006V                         *
+8722   Tau3GruCD-4814364 2168232313643832                   225058.1-483011225647.8-475809342.17-59.49 5.70  +0.22 +0.19 +0.12   Am                 -0.028-0.001      +006                           
+8723          BD+35 4917 216831 72851       16376           225104.8+354905225544.5+362106 98.28-20.92 5.74  -0.05 -0.38         B7III              +0.022+0.005      +001       70  3.7  51.0      *
+8724          BD+11 4904 216900108275       16389           225151.4+111852225651.5+115054 83.69-42.13 6.51  +0.18 +0.05         A3V s              +0.063-0.009D+.008+008           3.0   3.9       
+8725 16    LacBD+40 4949 216916 52512       16381  EN Lac   225149.6+410412225623.6+413614100.92-16.30 5.59  -0.14 -0.83         B2IV               -0.002 0.000      -007SB1O   23  3.6  62.1AC   3*
+8726          BD+48 3887 216946 52516    I         14368    225202.8+491159225626.0+494401104.59-09.00 4.95  +1.78 +1.96 +1.05   K5Ib               +0.003-0.002 -.001-010V?                        *
+8727          BD-05 5894 216953146404                       225206.6-052040225717.2-044836 67.22-54.82 6.31  +0.94 +0.72         G9III              -0.015+0.002      -009V?                         
+8728 24Alp PsACD-3019370 216956191524 867I         14372    225207.6-300908225739.1-293720 20.49-64.90 1.16  +0.09 +0.08 +0.02   A3V                +0.333-0.165 +.149+007      100                 *
+8729 51    PegBD+19 5036 217014 90896              14374    225233.1+201357225727.9+204608 90.06-34.73 5.49  +0.67 +0.21 +0.34   G2.5IVa            +0.204+0.059 +.074-031V       2                 *
+8730          BD+03 4799 2170191278603834                   225227.2+031629225732.8+034837 76.91-48.62 6.28  +1.12 +1.08         K1III              +0.070+0.029      +011                           
+8731          BD+47 3985 217050 525263833          EW Lac   225239.2+480859225704.5+484103104.22-09.99 5.43  -0.09 -0.53         B4IIIep           v+0.012-0.009      -022SB    350                 *
+8732          CD-3615650 217096214215                       225301.0-360319225835.0-353123  6.64-64.59 6.13  +0.58               F8III-IV           -0.001-0.111      +021                          *
+8733          BD+38 4904 217101 728833835                   225303.5+384627225740.7+391832100.07-18.46 6.18  -0.15 -0.80         B2IV-V             +0.002-0.008      -016      168                 *
+8734          BD-03 5539 2171071464123836  D                225306.5-025548225815.5-022343 70.47-53.32 6.16  +0.74 +0.43         G8IV               -0.003-0.018      -012V?         1.3   0.0      *
+8735          BD-02 5858 217131146415                       225314.6-015643225823.7-012437 71.66-52.64 6.37  +0.35 +0.02         F0-2V              +0.090-0.007      -014                          *
+8736          BD+84  517 217157  3808                       225328.8+845017225102.2+852225120.41 23.10 5.90  +1.32               K5                 +0.003+0.107      -030                           
+8737          BD+08 4973 217166127870       16417  14379    225330.9+084932225835.1+092125 82.17-44.40 6.43  +0.64 +0.16 +0.36   G2V+G4V            +0.403-0.141 +.035-027V          0.2   0.2AB   3*
+8738          BD+06 5092 217186127874                       225340.0+064823225842.6+072023 80.50-46.04 6.33  +0.06 +0.02         A1V                -0.040-0.080      -001       56                  
+8739 52    PegBD+10 4859 217232108307       16428           225411.6+111139225911.8+114344 84.23-42.55 5.75  +0.32 +0.08         A8V+F6V            +0.033-0.041D+.014+020V?         1.3   0.7      *
+8740          CD-3019383 217236191550              14380    225407.6-295954225935.8-292744 20.89-65.33 5.51  +0.25 +0.19         A5n                -0.003+0.009      +000       90                 *
+8741          BD-13 6318 217251165425    I                  225419.7-133625225935.7-130415 55.63-60.33 6.07  +1.45 +1.76         K5III              -0.010 0.000      +013V?                         
+8742  2    PscBD+00 4950 217264127881       16431           225419.9+002544225927.4+005746 74.59-51.08 5.43  +0.98 +0.83        gK1                 +0.086-0.071      -013V?         7.7   3.9       
+8743          CD-2516220 217303191554    I                  225441.0-254154230005.8-250951 31.11-64.99 5.65  +1.25 +1.20        gK0                 +0.035-0.075      -035                           
+8744          BD+51 3514 217314 350223838I                  225450.3+520704225910.3+523916106.24-06.54 6.29  +1.42               K2                 -0.025+0.033      +028                           
+8745          BD+59 2615 217348 35026                       225503.1+591644225909.0+594853109.25-00.04 6.43  +0.03 -0.24         B9III              +0.003+0.005      -011V?                         
+8746          CD-2616419 217358191565                       225459.1-260943230024.6-253736 30.06-65.14 6.29  +1.13               K1III              +0.086-0.034      -025                           
+8747   Zet GruCP-5310382 217364247680 868                   225458.6-531725230052.8-524515334.11-57.16 4.12  +0.98 +0.70 +0.53   G8-K0III           -0.067-0.014 +.039-001SB                         
+8748          BD+83  640 217382  38161649                   225512.8+834840225424.8+842046119.95 22.17 4.71  +1.43 +1.69 +0.73   K4III              +0.092+0.026 +.001+003     < 17                 *
+8749          CD-5113446 217403247683                       225514.9-512912230107.5-505700336.68-58.33 5.68  +1.42 +1.08 +0.54E  K3III              +0.078-0.006      +008                           
+8750  3    PscBD-00 4443 2174281464433840          Var?     225530.2-002104230037.9+001109 74.11-51.86 6.21  +0.89 +0.60         G4III              +0.044+0.013      -016                          *
+8751          BD+02 4594 217459127894    I                  225537.2+022839230042.9+030042 77.06-49.74 5.83  +1.34 +1.57 +0.50E  K4III              +0.011-0.086      +019V                         *
+8752          BD+56 2923 217476 350393839I         V509 Cas 225552.1+562432230005.1+565643108.16-02.70 5.00  +1.42 +1.16 +0.85   G40               v 0.000-0.003 +.002-058V?     35                 *
+8753          BD+30 4859 217477 72924       16443           225556.1+303246230042.5+310459 96.64-26.07 6.60  -0.04 -0.35         B9IIIpMn           +0.031+0.005      +001V?     35  2.5   3.4      *
+8754          CD-2918537 217484191581    I                  225551.8-292325230119.4-285113 22.39-65.68 5.55  +1.35 +1.51         K3III              +0.066-0.010      -025V                          
+8755          BD+44 4302 217491 52587                       225602.6+445018230034.4+452230103.32-13.23 6.50                      A3V                +0.010+0.002      -004V?                         
+8756          CD-2317706 2174981915853842                   225600.4-231938230123.0-224727 36.71-64.73 6.28  +0.13               A5V                +0.026-0.027      -012                           
+8757 81    AqrBD-07 5910 217531146447    I                  225611.8-073553230123.6-070340 65.42-57.08 6.21  +1.41 +1.77         K5III              -0.015-0.011      -002V?                         
+8758          BD+37 4744 217543 72929              14386    225615.4+381016230054.7+384229100.39-19.28 6.54  -0.11 -0.65         B3Vpe              +0.001-0.005      -016SB    370                 *
+8759          BD-05 5910 217563146451      D                225621.1-051456230131.7-044241 68.60-55.53 5.94  +1.00 +0.75         K0                 +0.019+0.009      +006                          *
+8760          CD-3715047 217642214261      W                225700.4-365728230234.0-362515  4.16-65.17 6.47  +0.94 +0.71         K1III              +0.031-0.035D+.003+000           3.0   2.0      *
+8761          BD+56 2927 217673 35062    I                  225716.8+563405230130.7+570620108.40-02.63 6.20  +1.50 +1.53         K1.5II             -0.003-0.007      -006                           
+8762  1Omi AndBD+41 4664 217675 52609 869  S       Omi And  225719.1+414719230155.3+421934102.21-16.10 3.62  -0.09 -0.53 -0.08   B6IIIpe+A2p       v+0.023-0.006 +.015-014SB2O  330  0.5   0.3 S   4*
+8763 82    AqrBD-07 5913 217701146465    I                  225721.0-070639230232.6-063427 66.44-56.97 6.15  +1.58 +1.90 +0.87E  M2III              -0.004-0.037      -008V?                        *
+8764          BD-21 6354 217703191604                       225723.9-212418230244.3-205214 41.20-64.46 5.97  +0.94               K0III-IV           -0.058-0.117      +026V?                         
+8765          BD+31 4829 217754 72949                       225746.8+311435230233.1+314650 97.38-25.63 6.57  +0.35 +0.08         F2IV               +0.005-0.016      -017        7                  
+8766  2    AndBD+41 4665 217782 52623       16467  14396    225800.0+421312230236.3+424528102.52-15.76 5.10  +0.09 +0.11         A3Vn               +0.055-0.004 +.034+002SB    190  3.7   0.4AB   3*
+8767   Pi  PsACD-3515630 2177922142751601          Pi  PsA  225757.8-351724230329.8-344458  7.99-65.72 5.11  +0.29 +0.02         F0V+F3V            +0.076+0.080 +.052-006SBO     0                 *
+8768          BD+43 4378 217811 52626       16472  LN And   225810.7+433115230245.2+440332103.11-14.59 6.39   0.00 -0.58         B2V                +0.001-0.002      -008       25  3.9   7.4      *
+8769          CP-69 3301 2178312553953843                   225815.8-692139230452.2-684913316.28-45.45 5.52  +0.36 +0.12         F4III              +0.040+0.063      +004SB     87                  
+8770          BD+54 2900 217833 35092       16474  V638 Cas 225825.2+544153230243.8+551411107.79-04.41 6.50  -0.08 -0.55         B9IIIHe wk        v+0.008+0.012      -013           3.6  19.5AB   4*
+8771          CD-4216177 217842231419                       225821.8-420108230359.5-412842352.86-63.75 5.79  +1.08 +0.95         K0III              +0.006+0.069      -015                           
+8772          BD-05 5917 217877146482                       225844.7-052005230357.3-044743 69.23-56.02 6.68  +0.58 +0.06         F8V                +0.320+0.028      -014V                         *
+8773  4Bet PscBD+03 4818 2178911279341602          14410    225847.2+031654230352.6+034912 78.79-49.61 4.53  -0.12 -0.49 -0.13   B6Ve              v+0.013-0.011      +000      128                 *
+8774   Kap GruCP-5410197 2179022477113845                   225844.9-543004230439.6-535754331.77-56.77 5.37  +1.45 +1.75         K5III              +0.055-0.102 +.012+018V?                        *
+8775 53Bet PegBD+27 4480 217906 90981 870I  16483  Bet Peg  225855.5+273225230346.5+280458 95.74-29.05 2.42  +1.67 +1.96 +1.32   M2.5II-III        e+0.189+0.137 +.022+009V          7.0 253.1AC   3*
+8776          BD+05 5123 217926127937                       225857.3+060438230401.0+063700 81.40-47.41 6.41  +0.39 +0.03         F2V                +0.003+0.019      +004       68                  
+8777          BD+59 2631 217943 20393       16481           225915.3+595424230323.7+602643109.99  0.32 6.74  -0.02 -0.63         B2V                +0.007-0.006      -017SB         2.7  33.9      *
+8778          BD+57 2676 217944 35103                       225908.2+580132230321.6+583353109.22-01.40 6.43  +0.90 +0.52         G8IV               +0.067+0.017      +015                           
+8779          BD+66 1575 218029 203983844I                  225944.2+664012230332.9+671233112.75  6.50 5.24  +1.26 +1.40         K3III              +0.026+0.007 -.002-007V    < 17                  
+8780  3    AndBD+49 4028 218031 52649    I                  225941.5+493030230411.0+500308105.86-09.23 4.65  +1.06 +0.88 +0.57   K0IIIbFe-0.5       +0.164+0.168 +.004-035     < 17                  
+8781 54Alp PegBD+14 4926 218045108378 871I         14417    225946.7+144002230445.7+151219 88.28-40.38 2.49  -0.04 -0.05 -0.03   B9V                +0.063-0.042 +.038-004SB    148                 *
+8782 83    AqrBD-08 6018 218060146498       16497           225956.9-081401230509.8-074137 65.67-58.20 5.43  +0.30 +0.07         F2IV+F0V           +0.129+0.011 +.021-013SB    101  0.2   0.2AB   3*
+8783          BD-17 6661 2180611654813846I W                225955.4-173704230512.8-170445 49.67-63.50 6.14  +1.37               K0                 -0.048-0.039      -015           5.1  56.1       
+8784          BD+15 4760 218101108383                       230009.8+160145230506.3+163347 89.29-39.26 6.44  +0.83 +0.55         G8IV               -0.185-0.194 +.025-027                           
+8785          BD+00 4963 218103127960                       230010.6+004605230517.6+011825 76.72-51.78 6.39  +0.94 +0.72         G9III              +0.035-0.027      -012                           
+8786          CP-80 1064 2181082581053847                   230015.3-800113230823.7-792851308.60-36.49 6.12  +0.14 +0.10         A3-4V              +0.084-0.038      -007                           
+8787   The GruCD-4415149 218227231444      W                230114.8-440337230652.8-433114348.24-63.30 4.28  +0.42 +0.16 +0.18   F5mDel Del         -0.039-0.023 +.017+010V?     80  2.5   1.2AB   3*
+8788          BD+17 4866 218235108400                       230119.9+175833230618.2+183103 90.87-37.72 6.13  +0.44 +0.10         F6V s              +0.232+0.057 +.016-012SB                        *
+8789 86    AqrCD-2417497 218240191651    I  16511           230118.6-241700230640.9-234435 35.23-66.15 4.47  +0.90 +0.58 +0.49   G9III              +0.066-0.003 +.028+015          10.0   2.9      *
+8790   Ups GruCD-3914936 218242214313      W                230119.6-392559230653.6-385332357.92-65.25 5.61  +0.01               A1V                +0.040+0.013      +016V          2.3   1.1       
+8791          CD-5013885 218255231445                       230123.7-500849230709.5-493624337.56-59.92 6.33  +1.45               K4III              +0.017-0.014      +022                           
+8792          BD+19 5058 218261108402                       230134.0+192213230631.9+195439 91.79-36.54 6.30  +0.49 +0.02         F7V                +0.295+0.002      -005V?      7                 *
+8793          CD-5113471 218269247739      W                230128.1-511335230714.7-504111335.89-59.25 5.83  +0.48               F6-7IV-V           -0.044-0.020      +004V?         0.8   8.5      *
+8794          CP-74 2054 218288258106                       230138.2-740738230835.7-733511312.37-41.60 6.15  +1.42 +1.68         K3III              +0.021-0.011      +005                          *
+8795 55    PegBD+08 4997 2183291279761603I         14428    230157.9+085209230700.3+092434 84.62-45.55 4.52  +1.57 +1.90 +1.02   M1IIIab            +0.011-0.014 +.016-005V                          
+8796 56    PegBD+24 4716 218356 910193848I         14429    230214.3+245542230706.8+252806 95.12-31.71 4.76  +1.34 +1.16 +0.68   G8Ib               +0.004-0.031 +.006-027SB   < 17                 *
+8797  1    CasBD+58 2545 218376 35147                       230223.0+585245230636.9+592511109.95-00.78 4.85  -0.03 -0.87 -0.11   B0.5IV             +0.009+0.001      -009V      50                 *
+8798          BD+32 4587 218395 73010       16519A 14430    230240.7+321705230727.7+324933 98.92-25.15 6.02R +0.12 +0.11         A4Vn               -0.024+0.008D+.011-001V     165  1.5   8.4      *
+8799          BD+20 5278 218396 910223850          Var      230232.6+203541230728.7+210803 92.76-35.57 5.99  +0.26 -0.04         A5V                +0.108-0.052      -012       45                 *
+8800          BD+45 4147 218407 52707                       230243.3+453138230718.1+460405104.71-13.09 6.66  -0.05 -0.68         B2V                +0.005-0.001      -015SB1O  160                 *
+8801          BD+52 3371 218416 35151                       230244.1+521632230710.1+524859107.42-06.89 6.11  +1.05               K0III              +0.013+0.006      +005                           
+8802          CD-2918588 218434191674                       230256.5-292150230821.0-284924 22.62-67.22 5.60  +0.88 +0.54         G9III              -0.047-0.031      +019V                          
+8803          BD+58 2546 218440 35152                       230256.7+591112230710.4+594339110.13-00.53 6.40  -0.01 -0.63         B2V                +0.005+0.001      -005SB2O                      *
+8804  4    AndBD+45 4149 218452 527113852I  16526           230304.8+455049230739.3+462314104.90-12.82 5.33  +1.41 +1.72 +0.75   K5III              -0.009-0.028      -006V?         5.5  48.2      *
+8805  5    AndBD+48 3944 218470 527131604                   230312.7+484504230745.4+491745106.09-10.16 5.70  +0.44 -0.03         F5V                +0.154+0.133 +.021-002V?      9                  
+8806          BD+43 4399 218525 52717                       230335.2+440114230812.3+443342104.24-14.53 6.56  +0.17 +0.20         A2IV               +0.024-0.005      +002V      70                  
+8807  5    PscBD+01 4686 2185271279933854                   230333.6+013500230840.9+020740 78.61-51.68 5.40  +0.91 +0.56         G8III-IV           +0.145+0.108      -018V?                         
+8808          BD+62 2171 218537 20439       16530           230342.7+630532230747.7+633800111.73  3.04 6.26  -0.02 -0.60 -0.06   B3V                +0.002-0.004D+.006-019      180  0.5   0.2      *
+8809          CP-67 3949 218558255420                       230348.2-672402231011.7-665127317.29-47.35 6.47  +0.95 +0.72         K0III              +0.201+0.038      -006                           
+8810          CP-81 1024 218559258961                       230350.3-812719231212.0-805446307.59-35.30 6.41  +1.50 +1.84         K4III              +0.009-0.011      +011                           
+8811          BD+63 1931 218560 204413853                   230353.6+634052230757.2+641321111.97  3.58 6.21  +1.10               K0                 +0.010+0.001      -028                           
+8812 88    AqrBD-21 6368 218594191683 873I                  230406.9-214255230926.8-211021 41.76-66.03 3.66  +1.22 +1.24 +0.60   K1III              +0.055+0.031 +.010+021                           
+8813          CD-2818099 2186191916863855I                  230420.5-283751230944.6-280519 24.56-67.49 5.87  +1.31 +1.42         K2III              +0.022+0.003      -014V                          
+8814          CD-4315281 218630231464      W                230424.3-432409230957.3-425138348.92-64.11 5.81  +0.48 -0.02         F4IV               -0.325-0.007 +.042+012           3.4   1.0       
+8815 57    PegBD+07 4981 218634128001    I  16550  GZ Peg   230428.5+080807230931.5+084038 84.77-46.51 5.12  +1.47 +1.01 +1.26   M4IIIS+A2V         +0.004+0.002 +.007+014SB  =< 50  5.5  32.9      *
+8816          BD-15 6360 2186391655223856                   230433.9-150309230949.6-143038 55.87-63.19 6.42  +0.01 +0.01         A0Vn               +0.031-0.009      +015V?    154                  
+8817 89    AqrCD-2317771 218640191687    I W                230434.5-225958230954.8-222727 38.81-66.53 4.69  +0.65 +0.39 +0.36   G2IV+A2V           +0.026-0.009 +.040-005           0.8   0.4      *
+8818          CD-4115163 218655231465    I         14441    230435.8-410757231009.8-403530353.60-65.18 5.83  +1.62 +1.84         M4III              +0.035-0.046      -007                          *
+8819 33Pi  CepBD+74 1006 218658 10629    I  16538           230442.9+745049230753.9+752315116.42 13.84 4.41  +0.80 +0.46 +0.43   G2III              +0.012-0.030 +.006-019SB1O   22  2.2   1.0AB   3*
+8820   Iot GruCD-4514947 2186702314681605                   230442.0-454718231021.6-451448344.27-62.93 3.90  +1.02 +0.86 +0.53   K1III              +0.136-0.030 +.030-004SB1O                      *
+8821 58    PegBD+09 5170 218700128007                       230459.3+091648231001.5+094919 85.83-45.62 5.39  -0.08 -0.29         B9III              -0.012-0.012      +009V     175                 *
+8822  2    CasBD+58 2552 218753 35186       16556  Var?     230527.3+584725230944.1+591959110.28-01.02 5.70  +0.33 +0.32         A5III              -0.003+0.009      -012V?         4.3 167.2AC   8*
+8823          CD-3019460 218759191703                       230522.3-300358231046.6-293130 20.81-67.76 6.51  +0.27               F1III-IV           -0.034-0.058      +025    =< 15                  
+8824          BD+16 4882 218792108443    I                  230544.4+170309231042.6+173540 91.45-39.04 5.71  +1.34 +1.51         K4III              +0.021-0.028      +002V?                         
+8825  6    AndBD+42 4592 218804 527613857                   230549.8+430025231027.2+433239104.21-15.62 5.94  +0.44 -0.05         F5IV               -0.191-0.191 +.023-043       18                  
+8826 59    PegBD+07 4991 2189181280221606                   230641.2+081037231144.2+084312 85.47-46.77 5.16  +0.13 +0.08         A5Vn               -0.006-0.006 +.029+010V     214                  
+8827 60    PegBD+26 4580 218935 91080      W                230657.8+261826231149.2+265050 96.95-30.95 6.17  +0.94 +0.67         G8III-IV           -0.190-0.120 +.026-010           3.3 231.5AC   3*
+8828          CD-5013915 219023231493      W                230733.5-500944231315.0-493708336.26-60.67 6.80  +0.92               G8-K0III           +0.002-0.018      -026           1.6   0.5       
+8829          CP-63 4862 219077255435                       230756.6-631357231406.6-624200320.42-51.00 6.12  +0.79 +0.35         G8V                +0.473-0.424 +.032-026                           
+8830  7    AndBD+48 3964 219080 52787                       230757.9+485136231233.0+492423106.87-10.36 4.52  +0.29 +0.04 +0.16   F0V                +0.092+0.098 +.051+013SB     59                 *
+8831          BD+28 4548 219110 91095                       230812.7+285355231304.0+292630 98.52-28.73 6.35  +0.93 +0.61         G8III              -0.031-0.033      +004                           
+8832          BD+56 2966 219134 35236 875  W       14458    230827.8+563658231317.0+571006109.87-03.19 5.56  +1.01 +0.89 +0.53   K3V                +2.075+0.296 +.152-018V          3.8 106.6      *
+8833          BD+10 4902 2191391084633858   16603           230824.5+103116231326.5+110354 87.78-45.01 5.82  +1.01 +0.91         G8III              -0.005-0.003      +016V          3.9  33.3      *
+8834 90Phi AqrBD-06 6170 2192151465851607I                  230908.6-063517231419.4-060256 70.94-58.74 4.22  +1.56 +1.90 +1.08   M1.5III            +0.042-0.196 +.010-000                          *
+8835          CD-4115197 2192632315123859                   230925.8-413850231458.6-410620351.53-65.76 5.77  +1.18 +1.14         K2III              +0.112-0.112      +026SB                         
+8836          BD-11 6032 219279165578    I  16618           230927.4-111357231440.2-104119 64.11-61.92 6.12  +1.49 +1.80         K5III              -0.001-0.034      -034V?         4.5   3.5AB   4*
+8837          BD+49 4071 219290 35251                       230940.1+500425231414.3+503704107.59-09.34 6.31                      A0V                +0.038-0.006      -014       56                  
+8838          BD+28 4555 219291 91111      W                230930.1+291339231421.7+294618 98.97-28.54 6.41  +0.45 -0.01         F6IV w             -0.007-0.013      +009       86  3.5  34.9       
+8839          BD+23 4704 219310 91113                       230940.5+233329231436.5+240611 96.20-33.69 6.36R                     K2III              +0.114+0.007      -027                           
+8840          BD-04 5852 2194021465933860                   231025.1-040229231534.3-032947 74.66-57.09 5.55  +0.06 +0.06         A3V                -0.007-0.003      +011SB                         
+8841 91Psi1AqrBD-09 6156 2194491465981608I  16633A          231039.1-093757231553.5-090516 67.07-61.11 4.21  +1.11 +0.99 +0.56   K0III              +0.372-0.016 +.049-026V    < 17  4.8  49.2AB   5*
+8842 61    PegBD+27 4521 219477 911303861                   231053.1+274210231546.3+281452 98.56-30.06 6.49  +0.85 +0.48         G5II-III           +0.020-0.005      +004     < 23                  
+8843          CP-62 6412 219482255446 876                   231057.0-623246231657.7-620004320.63-51.76 5.66  +0.51               F7V                +0.173-0.026      -009                           
+8844          BD+73 1023 219485 10664                       231103.7+734110231437.3+741352116.38 12.61 5.84R                     A0V                +0.048+0.006      -003    =< 41                  
+8845          BD+23 4712 219487 91133                       231102.1+241332231557.9+244616 96.88-33.22 6.60  +0.40 -0.05         F5V                +0.093+0.005      +005       20                  
+8846          CD-4514982 219507231532      W                231105.8-450204231639.7-442921344.28-64.28 5.92  +1.06 +0.91         K1III              -0.004-0.007      +025           4.8  22.5       
+8847          CD-4115205 219531231533                       231119.1-414426231649.8-411140350.93-66.03 6.47  +1.08               K0III              -0.024+0.012      +013                           
+8848   Gam TucCP-58 8062 219571247814 877                   231135.7-584702231725.8-581409324.30-54.82 3.99  +0.40 -0.02 +0.23   F1III              -0.029+0.079 +.043+018       94                  
+8849          CP-80 1067 219572258127                       231137.1-800109231908.1-792822308.06-36.72 6.33  +0.91 +0.66         K0III              +0.013+0.007      -003                           
+8850 92Chi AqrBD-08 6076 219576146612    I         Chi Aqr  231139.9-081619231650.9-074336 69.45-60.36 5.06  +1.60 +1.60 +1.20E  M3III              -0.016-0.015 +.009-015V?                        *
+8851          BD+70 1311 219586 106713862                   231146.2+702034231537.8+705317115.19  9.47 5.56  +0.24 +0.12         F0IV               +0.018-0.005      +012SB    140                  
+8852  6Gam PscBD+02 4648 219615128085 878I                  231158.8+024409231709.9+031656 82.47-52.02 3.69  +0.92 +0.58 +0.51   G9-III:Fe-2        +0.762+0.017 +.036-014V?      7                 *
+8853          BD+52 3410 219623 352853863  W                231208.6+524027231642.3+531249108.90-07.06 5.54  +0.52 +0.02         F7V                +0.115-0.233 +.036-025V?  =<  6  7.3 129.3       
+8854          BD+61 2413 219634 20531              V649 Cas 231208.9+612503231626.8+615747112.02  1.12 6.53  +0.23 -0.66         B0Vn               -0.026-0.002      -015SB                        *
+8855          CP-68 3567 2196442554553864                   231208.8-680104231820.0-672816315.82-47.26 6.13  +1.35 +1.58         K2-3III            +0.021+0.014      +018                           
+8856          BD-12 6461 219659165609              14483    231226.8-121533231740.0-114247 63.38-63.14 6.34  +0.05 +0.01         A1Vn               +0.039-0.003      +003V?    195                  
+8857          BD+44 4368 219668 52865                       231234.3+443711231716.6+450951106.01-14.59 6.43  +1.07 +1.01         K0IV               +0.097-0.065      -038                           
+8858 93Psi2AqrBD-09 6160 219688146620      D                231242.4-094342231754.2-091057 67.62-61.54 4.39  -0.15 -0.56 -0.13   B5V                +0.021-0.012      -006V?    332                 *
+8859   Phi GruCD-4115211 219693231539                       231238.8-412203231809.9-404928351.44-66.43 5.53  +0.44 -0.05         F5V                +0.136-0.128      +014        0                  
+8860  8    AndBD+48 3991 219734 52871    I  16656  14484    231306.3+482808231744.7+490055107.53-11.03 4.85  +1.67 +1.98 +1.26   M2+IIIBa0.3        +0.037+0.008 +.011-008V?         5.8 219.4AC   6*
+8861          BD+44 4373 219749 52876              ET And   231314.3+445635231756.1+452920106.25-14.33 6.48  -0.03 -0.26         B9pSi             v+0.034-0.017      +003SB1O   83                 *
+8862   Tau OctCP-88  204 219765258970 925                   231309.9-880153232803.7-872856303.96-29.48 5.49  +1.27 +1.43         K2III              +0.015+0.009      +031                           
+8863   Gam SclCD-3316476 219784214444 879I                  231325.5-330436231849.4-323155 12.25-69.25 4.41  +1.13 +1.06 +0.63   K1III              +0.019-0.070 +.043+016                           
+8864  9    AndBD+40 5043 219815 52881              AN And   231338.6+411339231823.4+414625104.91-17.82 6.02                      A7/8Vm             -0.006-0.012      -004SB1O   78                 *
+8865 95Psi3AqrBD-10 6094 2198321466351609   16671  14491    231345.6-100927231857.7-093639 67.31-62.02 4.98  -0.02 -0.02         A0V                +0.047-0.002 +.012-010V     143  3.9   1.4AB   3*
+8866 94    AqrBD-14 6448 219834165625       16672A          231351.1-140011231906.7-132732 60.70-64.47 5.08  +0.80 +0.41         G5IV               +0.298-0.101 +.040+010SBO =< 17  2.4   0.2 S   3*
+8867          BD+74 1016 219841 106843865                   231347.3+744510231718.9+751757116.95 13.53 6.38  +0.03 +0.03         A2V s              +0.018-0.002      -008                           
+8868 96    AqrBD-05 5966 219877146639       16676           231412.8-054015231924.0-050728 73.94-58.94 5.55  +0.39  0.00         F3IV-V             +0.202-0.020      -009SB     50: 4.9  10.6      *
+8869          BD-18 6283 2198791656283868I                  231408.4-183722231924.1-180431 51.23-66.96 5.93  +1.52 +2.01        gK3                 +0.004+0.009      +005V?                         
+8870          BD+44 4378 219891 52892                       231419.5+443525231902.4+450814106.30-14.73 6.50                      A5Vn               +0.058+0.006      +007      160                  
+8871          CD-3415985 219912214459      W                231418.6-341515231943.2-334229  8.90-69.21 6.37  +1.30               K2III              +0.047-0.041      +023           6.1  43.8       
+8872 34Omi CepBD+67 1514 219916 20554    I  16666  14495    231430.9+673352231837.5+680642114.42  6.79 4.75  +0.84 +0.49 +0.45   K0III              +0.058+0.016 +.024-018V?   < 17  2.3   3.1AB   3*
+8873          BD+34 4899 219927 73171                       231437.0+341446231927.4+344736102.31-24.37 6.32  -0.08 -0.39         B8III              +0.016-0.003      -001V?      5                  
+8874 11    AndBD+47 4110 219945 52907                       231450.1+480436231929.8+483731107.66-11.50 5.44  +1.03 +0.82         K0III              +0.019+0.056 +.016+011     < 19:                 
+8875          BD+47 4114 219962 52912      W                231459.7+474958231941.6+482251107.60-11.74 6.32  +1.12 +1.05         K1III              +0.209+0.032 -.001+023           3.3  85.8AB   3 
+8876 10    AndBD+41 4752 219981 529143870I                  231506.6+413150231952.4+420441105.30-17.64 5.79  +1.48 +1.90         M0III              +0.052+0.010      +003V?                         
+8877          CD-5013948 220003247838      W                231512.6-505108232050.0-501824333.53-61.10 6.05  +0.42 +0.16 +0.22   F5mDel Del         +0.028-0.077      -018V          2.0   0.5AB   3*
+8878  7    PscBD+04 4997 2200091281263871I                  231514.8+045008232020.6+052253 85.42-50.73 5.05  +1.20 +1.12         K2III              +0.082-0.062 +.002+038V    < 19:                 
+8879          BD-06 6191 220035146652      D       14515    231531.5-062714232040.9-055429 73.36-59.73 6.17  +1.07 +0.97         K0III              -0.101-0.057      -002                          *
+8880 62Tau PegBD+22 4810 220061 91186 880          Tau Peg  231541.1+231135232038.2+234425 97.51-34.61 4.60  +0.17 +0.10 +0.09   A5Vp               +0.033-0.008 +.037+016V     143                 *
+8881          BD+61 2427 220074 20567    I                  231552.0+612522232014.3+615812112.44  0.97 6.45R                     K1V                +0.003-0.013      -035                          *
+8882 63    PegBD+29 4908 220088 73187    I                  231555.6+295209232049.6+302454100.72-28.52 5.59  +1.50 +1.91         M0III              +0.081-0.069      -019V                          
+8883          CD-2716284 2200961918401611                   231555.8-273204232115.5-265912 28.15-69.95 5.64  +0.82               G4V                -0.013-0.012      +013                           
+8884          BD+43 4440 220105 52927       16685           231600.0+433410232044.0+440659106.22-15.79 6.13R +0.17?              A5Vn               -0.016-0.027      -002           4.0  13.2      *
+8885 12    AndBD+37 4817 220117 731901610  W                231603.5+373811232053.3+381056103.98-21.33 5.77  +0.46 +0.02         F5V                +0.130-0.063      -009V?     12  3.4 121.1AB   3 
+8886          BD+61 2428 220130 20572    I  16690           231612.4+613956232034.6+621247112.56  1.19 6.39  +1.61               K2III              +0.003-0.005      -023           5.5  12.7AB   4*
+8887 64    PegBD+31 4897 220222 73205       16702           231701.9+311552232154.9+314845101.57-27.32 5.32  -0.11 -0.49         B6III              +0.005-0.010 +.001+002SB    161  3.7   0.4AB   3 
+8888          BD+25 4924 220242 91208                       231703.2+260346232158.2+263632 99.25-32.11 6.62  +0.37 +0.01         F5V                -0.098-0.074      +010                           
+8889          CP-60 7654 220263255474              14529    231707.5-603615232256.9-600321321.48-53.77 6.09  +1.60 +1.91         M3III              +0.090-0.009      -028V?                        *
+8890 97    AqrBD-15 6406 220278165658       16708           231724.7-153517232239.2-150221 58.78-66.08 5.20  +0.20 +0.10         A3Vp               +0.112+0.019 +.022-012      141  0.7   0.4      *
+8891 65    PegBD+20 5317 220318 912203873                   231741.6+201650232240.5+204943 96.53-37.45 6.29  -0.04 -0.09         B9.5V              +0.019-0.012      -014SBO    25                 *
+8892 98    AqrBD-20 6587 2203211918581612I                  231743.1-203847232258.2-200602 47.35-68.59 3.97  +1.10 +0.95 +0.60   K0III              -0.120-0.096 +.036-007V                          
+8893 66    PegBD+11 4993 220363108580    I  16715           231801.9+114556232304.6+121850 91.56-45.11 5.08  +1.31 +1.49         K3III              +0.027-0.017 -.001-004V?   < 19: 0.0   0.1      *
+8894          BD+59 2710 220369 353613874I                  231804.7+593506232232.5+600801112.07-00.85 5.56  +1.68 +1.82         K3II               +0.009-0.001      -012V?                         
+8895          CP-5410281 220392247854      W                231815.0-542124232354.3-534830328.10-58.83 6.15  +0.26 +0.13         A4III              +0.059-0.027      +007      153  0.8  26.5      *
+8896          CD-4315360 220401231587                       231816.4-434025232345.4-430728345.21-66.11 6.10  +1.46               K3III              +0.015+0.010      +001                           
+8897          BD-00 4509 220406128156    I W                231824.1-001530232331.9+001729 81.72-55.38 6.31  +1.61 +1.95         K2                 +0.068+0.010      +009           4.0  41.7       
+8898          CP-5212150 220440247858                       231836.8-522621232413.1-515329330.51-60.31 5.75  +1.59 +1.93         M0III              +0.005-0.041      -005                           
+8899          BD+31 4901 220460 73223                       231852.4+315853232347.5+323153102.29-26.80 6.69  +0.45 -0.12         F4V w              +0.232+0.040 +.012+010SB2O                      *
+8900          BD-19 6450 220465165672                       231851.7-191419232407.8-184115 51.13-68.24 6.19  +1.02 +0.79         G8III              +0.149+0.071      -019                           
+8901          CP-5710268 220572247867                       231937.3-572352232519.4-565057324.29-56.56 5.59  +1.07 +0.98 +0.37E  K0III              +0.080-0.024      -019    =<  1:                *
+8902          BD+40 5068 220575 52987                       231946.4+403349232435.0+410646105.80-18.85 6.72  +0.06?              B8III              +0.015-0.009      -003SB     30                 *
+8903 67    PegBD+31 4904 220599 732411613                   231957.0+315008232450.8+322306102.46-27.02 5.57  -0.11 -0.26         B9III              +0.017+0.002 +.004+018V     110                  
+8904  4    CasBD+61 2444 220652 20614 882I W       14549    232023.5+614402232450.3+621658113.05  1.08 4.98  +1.68 +2.07 +0.85E  M1III              +0.011-0.013 +.007-037           2.5  98.6AB   4*
+8905 68Ups PegBD+22 4833 220657 91253 881I                  232023.2+225113232522.8+232415 98.55-35.36 4.40  +0.61 +0.14 +0.32   F8III              +0.193+0.037 +.036-011       79                 *
+8906 99    AqrBD-21 6420 220704191900    I         14554    232047.6-211124232602.8-203831 46.74-69.46 4.39  +1.47 +1.81 +0.81   K5III              -0.052-0.058 +.007+016V?                        *
+8907   Omi GruCP-5310461 220729247874 883                   232100.9-531630232636.6-524318328.86-59.92 5.52  +0.40               F4V                +0.038+0.123      +018SB      0                  
+8908          CP-67 3964 220759255486                       232111.8-670751232707.2-663452315.38-48.46 6.45  +1.47 +1.77         K4III              -0.042-0.023      +012                           
+8909          CP-59 7890 2207902478823876                   232132.9-590142232715.0-582834322.23-55.38 5.63  +0.98               G8III              +0.051+0.062      -011                           
+8910          CD-5013976 2208022478803875                   232136.3-504228232709.1-500926332.22-61.91 6.20  -0.08               B9V                +0.032+0.006      -001                           
+8911  8Kap PscBD+00 4998 220825128186 884  W       Kap Psc  232148.3+004229232656.0+011520 83.92-55.08 4.94  +0.03 -0.02 -0.03   A0pCrSi:Sr:       v+0.089-0.097 +.040-003V      41  7.0 163.4AB   3*
+8912  9    PscBD+00 4999 220858128188      W       14568    232207.4+003424232714.8+010721 83.90-55.24 6.25  +1.02 +0.80         G7III              +0.044-0.035      -007SB                        *
+8913 13    AndBD+42 4672 220885 53039                       232218.1+422141232707.4+425443106.91-17.32 5.75   0.00 -0.09         B9III              +0.091+0.015      -009SB     67                 *
+8914          CD-3615895 2209292145613878                   232238.7-360542232800.7-353240  2.43-70.35 6.32  +1.20               K2III              +0.007+0.001      +013                           
+8915 69    PegBD+24 4778 220933 91278              HV Peg   232242.1+243704232740.4+251002 99.98-33.94 5.98  -0.06 -0.17         A0pHgMn            +0.026-0.041      -016       40                 *
+8916 10The PscBD+05 5173 2209541281961614I                  232253.7+054947232758.1+062244 88.81-50.88 4.28  +1.07 +1.01 +0.53   K1III              -0.121-0.045 +.016+006V?   < 17                  
+8917          BD-12 6496 220957165708                       232252.9-115959232805.2-112659 67.58-64.92 6.37  +0.90 +0.56         G0V                +0.102-0.023      -083V?                         
+8918          BD+69 1332 220974 10737                       232302.7+694834232716.6+702135115.92  8.64 5.60  +0.19?              A6IV               +0.119-0.006 +.023-003SB2   115                  
+8919          CP-63 4891 2210062554973880          CG Tuc   232313.7-633940232901.0-630639317.77-51.58 5.68  -0.17               ApSi              v+0.037-0.017      +015       69                 *
+8920          CD-4515043 221051231622                       232333.6-450255232900.8-442952341.10-66.03 6.43  +1.18               K2III              +0.037-0.011      -020                           
+8921          BD-10 6120 221081146729    I                  232350.3-094859232900.6-091558 71.60-63.59 6.18  +1.44 +1.70         K0                 -0.050-0.026      +008V?                         
+8922          BD+22 4844 221113 91295                       232406.6+222958232905.6+230252 99.35-36.02 6.35R                     G9III              -0.039-0.094      +020                           
+8923 70    PegBD+11 5009 221115108638 885I                  232405.8+121232232909.3+124538 93.72-45.39 4.55  +0.94 +0.73 +0.45   G7+III             +0.064+0.027 +.016-015V?   < 19:                 
+8924          BD-05 5999 2211481467363881          14588    232421.9-050439232932.1-043158 78.48-60.13 6.25  +1.09 +1.16         K3III             v+0.183-0.232 +.019-025V                          
+8925          BD+48 4070 221246 530883882I                  232521.2+483454233007.4+490759109.51-11.61 6.17  +1.46 +1.71         K3III              +0.033+0.002      +006                          *
+8926          BD+57 2748 221253 35478       16795  AR Cas   232524.6+575951233002.0+583256112.47-02.66 4.91  -0.12 -0.64 -0.14   B3IV               +0.020+0.005D+.006-013SB1O  144  2.3  75.7AC   8*
+8927          BD+37 4856 221293 73308                       232546.5+380637233039.7+383943106.08-21.55 6.05  +0.99               G9III              +0.042+0.011      -009                           
+8928          BD-07 6036 221308146748                       232551.7-065020233101.1-061718 76.78-61.72 6.39  +1.26 +1.29         K0                 -0.013-0.036      +013                           
+8929          CD-4515055 2213232316423883                   232600.9-452341233127.0-445037339.76-66.14 6.02  +1.02               K1III              +0.048-0.025      +008                           
+8930 14    AndBD+38 5023 221345 73311    I         14599    232622.2+384113233117.4+391411106.41-21.05 5.22  +1.02 +0.87         K0III              +0.289-0.080 +.015-059V    < 19:                 
+8931          BD-04 5896 221356146752                       232621.5-043802233131.5-040514 79.82-60.09 6.49  +0.54 -0.01         F8V                +0.175-0.190 +.041-011V   =<  6                  
+8932100    AqrBD-22 6141 2213571919703885                   232627.5-215517233142.1-212210 46.21-70.96 6.29  +0.33 +0.16         A9III              +0.009+0.005      -008SB                         
+8933          BD+27 4568 221394 91321              Var      232645.4+275108233143.1+282413102.40-31.27 6.41  +0.01 +0.03         A1pSrCr:Eu:        -0.025-0.008      -006V                         *
+8934 13    PscBD-01 4450 221409146756                       232649.7-013818233157.6-010509 83.41-57.73 6.38  +1.18 +1.10         K1III              +0.012+0.017      -023                           
+8935          CP-78 1473 2214202581543887                   232652.2-775615233319.5-772307308.32-38.91 5.81  +0.68 +0.31         G2V                +0.010 0.000      +026                           
+8936          BD+34 4948 221491 73325                       232729.4+342402233224.6+345709105.11-25.17 6.65  -0.06 -0.24         B8V                -0.007-0.006      +012      250                  
+8937   Bet SclCD-3815527 221507214615 886          14608    232736.6-382216233258.3-374906355.04-70.36 4.37  -0.09 -0.36 -0.07   B9.5IVpHgMnEu      +0.087+0.021      +002       37                 *
+8938          BD+86  344 221525  39163967                   232748.7+864521232700.8+871827121.86 24.61 5.58  +0.23 +0.13         A7IV               +0.075+0.018      -011V?     90                  
+8939101    AqrBD-21 6437 221565191988      W                232802.6-212802233316.6-205452 47.93-71.13 4.71  +0.02  0.00 +0.03   A1n                -0.007+0.013 -.000+015      297  2.3   1.0       
+8940 71    PegBD+21 4952 221615 913403889I         HW Peg   232827.5+215649233328.1+222956100.25-36.92 5.32  +1.60 +1.61         M5IIIa             +0.010-0.017      +003V?                        *
+8941          BD+44 4441 221661 53147                       232852.2+443019233342.7+450329108.81-15.67 6.24  +0.98               G8II               -0.029+0.010      +007                           
+8942          BD+20 5352 221662 91349    I                  232854.4+201720233355.5+205027 99.59-38.49 6.06  +1.73 +1.88         M3III              -0.004-0.022      +005                           
+8943 72    PegBD+30 4978 221673 73341    I  16836  14617    232859.4+304624233357.2+311931104.09-28.69 4.98  +1.38 +1.62         K4IIIb             +0.052-0.016 +.018-024SB   < 19: 0.2   0.5      *
+8944 14    PscBD-02 5986 2216751467803890                   232900.5-014759233409.0-011451 84.09-58.17 5.87  +0.30 +0.16 +0.13   A2m                +0.108-0.013      -003       60                 *
+8945          CP-65 4148 221740255520      W                232930.6-651433233512.7-644122315.61-50.52 7.4                       F2IV-V             +0.015+0.004                     2.4  37.7       
+8946          BD-16 6314 221745165780    I                  232937.1-154747233449.4-151445 62.77-68.60 5.96  +1.36 +1.57         K0                 +0.051-0.079      -037V?                         
+8947 15    AndBD+39 5114 221756 733461616          14627    232943.8+394106233437.5+401411107.40-20.31 5.59  +0.10 +0.08 +0.06   A1Vp               -0.017-0.046 +.014+013V     109                 *
+8948 73    PegBD+32 4667 221758 733453891                   232941.4+325638233438.2+332950105.06-26.69 5.63  +1.03              gK0                 +0.001+0.019      -003V?                         
+8949   Iot PheCD-4315420 2217602316751617  W       Iot Phe  232941.8-431005233504.6-423654343.07-68.07 4.71  +0.08 +0.07 +0.07   A2VpSrCrEu         +0.046-0.001 +.005+019V      22  8.0   7.7      *
+8950          BD+37 4866 221776 73351    I  16843           232951.7+372815233446.7+380126106.69-22.42 6.18  +1.58               K7III              +0.008+0.009      -012           5.2  20.2       
+8951          BD-08 6142 221835146795 888                   233022.5-080104233532.1-072752 76.98-63.35 6.39  +0.88 +0.57        gG5                 +0.001+0.016      +005                           
+8952          BD+70 1327 221861 107903893I                  233038.5+710521233459.0+713832116.93  9.67 5.84  +1.80 +1.73         G9Ib               -0.004 0.000      -003V?                         
+8953          BD+23 4769 221905 913673894I                  233055.5+240028233555.9+243340101.83-35.20 6.45  +1.73 +2.01         M1III              +0.004+0.009      -012                           
+8954 16    PscBD+01 4744 2219501282813895  D                233117.1+013250233623.3+020608 88.23-55.63 5.68  +0.44 -0.08         F6Vb vw            -0.103+0.061      +039SB2O=< 10  0.1   0.0      *
+8955          BD+32 4671 221970 73368                       233132.8+322103233630.5+325415105.25-27.38 6.35  +0.46  0.00         F6V                -0.008 0.000      -001                           
+8956          CD-3217593 222004214659      W                233148.3-322528233705.4-315215 12.12-73.17 6.52  +1.26 +1.22         K1III              +0.048+0.002D+.003-023           3.3   5.2      *
+8957          CP-77 1583 222060258166                       233211.1-772522233824.1-765212308.23-39.50 6.00  +0.90 +0.65         K0-2III            +0.082-0.032      +002                           
+8958          BD-13 6439 222093165804       16878           233228.5-133652233739.6-130337 68.48-67.74 5.65  +1.03 +0.83         G9IIIFe-0.5        +0.037+0.024      -013           3.9  31.6       
+8959          CD-4614720 222095231707 889                   233228.0-460244233751.0-452933336.66-66.52 4.74  +0.08 +0.09 +0.05   A2V                +0.073-0.014 +.016+010SB    126                 *
+8960 74    PegBD+16 4954 222098108729      W                233235.7+161619233739.8+164932 98.66-42.54 6.26   0.00 +0.08         A1V                +0.134 0.000      -026SBO    45  4.5  98.3AB   3*
+8961 16Lam AndBD+45 4283 222107 53204 890I W       Lam And  233240.0+455459233733.9+462729109.90-14.53 3.82  +1.01 +0.69 +0.57   G8III-IV          v+0.162-0.421 +.050+007SB1O < 19: 6.5 217.6AC   4*
+8962          BD+43 4508 222109 53202       16877           233238.6+435233233732.0+442545109.28-16.47 5.80  -0.06 -0.31         B8V                +0.015-0.010D+.004-011V      50  0.9   0.5AB   3*
+8963 75    PegBD+17 4952 2221331087323896  W       KS Peg   233253.7+175048233756.8+182402 99.54-41.11 5.53   0.00 -0.03         A1Vn               +0.050+0.017      -016SB1   216  6.2  27.9      *
+8964          BD+45 4288 222143 53210                       233302.4+453846233758.6+461159109.89-14.80 6.58  +0.66 +0.16         G5                 +0.370-0.003 +.032-001                           
+8965 17Iot AndBD+42 4720 222173 53216 891          14646    233313.7+424252233808.2+431605109.03-17.62 4.29  -0.10 -0.29 -0.09   B8V                +0.029-0.001 +.011-001SB     84                  
+8966   The PheCD-4714651 222287231719      W                233405.9-471134233928.0-463816334.20-65.88 6.09  +0.24 +0.11         A8V+F0V            +0.028+0.033D+.008+014           0.7   3.7      *
+8967 18    AndBD+49 4180 222304 356423897                   233417.4+495504233908.3+502818111.34-10.77 5.30  -0.06 -0.15         B9V                -0.017-0.002      +009SB    178                  
+8968102Ome1AqrBD-15 6471 222345165818                       233435.9-144629233947.1-141318 67.04-68.89 5.00  +0.24               F0IV               +0.057-0.038 +.016-002SB    102                  
+8969 17Iot PscBD+04 5035 222368128310 892I W       14657    233448.3+050503233957.0+053735 92.46-52.96 4.13  +0.51  0.00 +0.31   F7V                +0.378-0.438 +.075+005V       6  8.7  69.9      *
+8970          BD+08 5095 222377128309                       233449.2+090724233955.1+094038 95.27-49.31 5.97  +0.20 +0.13 +0.09   A2IVm              +0.099-0.011      +000       60                  
+8971          BD+74 1032 222386 10814                       233452.7+744419233910.4+751734118.30 13.08 5.95  +0.13 +0.12         A3V                +0.012+0.011      +003SB    125                  
+8972          BD+73 1047 222387 108173898                   233459.5+732655233921.1+740010117.93 11.83 5.98  +0.89               G8III              -0.012+0.004      +009SB                         
+8973          BD+36 5098 222399 73422       16913           233505.4+370603234002.8+373909107.64-23.09 6.53  +0.35 +0.08         F2IV               -0.013-0.084      -016V?         4.4  14.9      *
+8974 35Gam CepBD+76  928 222404 10818 893I         14656    233514.3+770427233920.8+773757118.99 15.31 3.21  +1.03 +0.94 +0.51   K1III-IV           -0.067+0.151 +.064-042V?   < 17                 *
+8975   Mu  SclCD-3217621 2224332147011618          14661    233523.4-323734234038.2-320423 10.86-73.86 5.31  +0.97 +0.66         K1III              -0.089-0.055 +.027+014                           
+8976 19Kap AndBD+43 4522 222439 532641619   16916           233528.8+434649234024.5+442002109.76-16.71 4.14  -0.08 -0.26 -0.07   B9IVn              +0.083-0.019 +.018-009V     184  7.6  46.8AB   3*
+8977          BD+35 5074 222451 734283899                   233540.7+360957234040.6+364315107.46-24.02 6.23  +0.39 -0.05         F1V                +0.236+0.020      -000       30                 *
+8978          CD-2417796 222485192083    I         14665    233553.8-244252234107.0-240937 39.63-73.89 6.60  +1.57 +1.92         M1III              +0.006-0.010      +018V?                        *
+8979          BD-12 6535 222493165828                       233558.4-121407234108.9-114050 72.64-67.40 5.89  +1.00 +0.78 +0.35E  G9III              +0.070+0.009      -011V                         *
+8980103    AqrBD-18 6357 222547165834    I                  233623.3-183447234134.5-180138 58.77-71.51 5.34  +1.57 +1.93 +0.92   K5III              -0.039-0.071      +025                           
+8981          BD+48 4127 222570 53276                       233633.7+485730234126.9+493044111.43-11.79 6.26  +0.19?              A4V                +0.002-0.021      -006                           
+8982104    AqrBD-18 6358 222574165836    I W       14671    233634.3-182216234145.8-174859 59.40-71.44 4.82  +0.82 +0.49 +0.41   G0Ib-II            +0.015+0.004 -.009+003SB     17  2.8 120.1AB   3*
+8983          BD+06 5183 222602128335              14672    233650.9+064149234156.7+071502 94.37-51.72 5.89  +0.10 +0.08         A3Vn               -0.024-0.042      +001      210                 *
+8984 18Lam PscBD+00 5037 2226031283361620                   233656.6+011347234202.8+014648 90.15-56.61 4.50  +0.20 +0.08 +0.10   A7V                -0.129-0.155 +.028+012SB     63                 *
+8985          BD+56 3067 222618 35682                       233705.4+564220234154.5+571536113.61-04.35 6.24R                     G8III              +0.005-0.002      -012                           
+8986          BD+44 4473 222641 53292    I         14674    233719.1+442615234214.8+445931110.28-16.17 6.57R                    gK5                 -0.011-0.010      -010V                          
+8987          BD-16 6345 222643165841    I                  233717.0-160008234227.9-152652 65.53-70.18 5.28  +1.37 +1.49         K4III              +0.025-0.008 +.015+007SB   < 17                 *
+8988105Ome2AqrBD-15 6476 222661165842 894   16944           233732.2-150552234243.3-143242 67.66-69.64 4.49  -0.04 -0.12 -0.05   B9.5V              +0.101-0.066 +.041+003SB    156  6.0   5.0      *
+8989          BD+63 2038 222670 20791    I  16940           233737.5+635739234220.8+643056115.58  2.63 6.56  +1.88 +2.12 +1.33   M2III              +0.003-0.002      -003           4.4   2.6       
+8990          BD+60 2609 222682 207933900  W                233744.7+610731234231.5+614046114.85-00.11 6.40  +1.24 +1.36         K2III              +0.043-0.021      -016           6.5   8.        
+8991 77    PegBD+09 5268 2227641087893902I         14679    233816.9+094635234322.4+101953 96.87-49.06 5.06  +1.68 +2.04         M2III              +0.008+0.007 +.010-034V                         *
+8992          BD-16 6352 222800165849    I         R Aqr    233838.8-155019234349.5-151704 66.52-70.32 6.36  +1.58 +0.32         M7IIIpe           v+0.032-0.025      -022V                         *
+8993          CD-4515114 2228032317563903                   233839.8-453817234401.4-450500335.38-67.56 6.09  +0.98 +0.71         K1III-IV           +0.338-0.006 +.019-031                           
+8994          CP-71 2771 2228052581783905                   233842.3-710249234425.4-702925310.84-45.59 6.07  +0.91 +0.62         G8-K0IV            +0.243+0.062 +.014+020                           
+8995          CP-79 1239 2228062581793906                   233836.2-792048234440.7-784729306.98-37.81 5.75  +1.11 +1.07         K1III              +0.048+0.004      +021V                          
+8996          CP-65 4159 2228202555573904                   233841.6-645738234412.0-642416314.43-51.20 5.72  +1.40 +1.63         K2II-III           +0.011+0.031 +.007-013                           
+8997 78    PegBD+28 4627 222842 91457    I  16957           233857.5+284827234359.5+292142105.73-31.25 4.93  +0.95 +0.63 +0.48   K0III              +0.071-0.037 +.018-007SB   < 19: 3.1   0.9      *
+8998106    AqrBD-19 6500 2228471658541621                   233900.9-184955234412.1-181637 59.17-72.17 5.24  -0.08 -0.27         B9Vn               +0.029-0.003      +014V     258                  
+8999          CD-2616762 222872192116       16963           233916.7-264804234428.9-261447 32.50-75.03 6.17  +0.50 +0.10         F4V                -0.070-0.015      +016           3.2   8.3      *
+9000          BD+55 3010 222932 35728                       233955.6+551441234448.3+554759113.61-05.86 6.51R                    gG4                 +0.020-0.005 +.008+009                           
+9001          CD-4015239 223011231769                       234044.7-404413234601.2-401057344.81-71.20 6.31  +0.20 +0.09         A7III-IV           +0.097-0.036      +004                           
+9002107    AqrBD-19 6506 223024165867       16979A          234049.3-191403234600.9-184041 58.82-72.75 5.29  +0.28 +0.14         F2III+F2V          +0.134+0.030 +.012-002       83  1.0   6.6      *
+9003 20Psi AndBD+45 4321 223047 533551622I W                234104.5+455154234602.1+462513111.34-14.97 4.95  +1.11 +0.82 +0.38E  G5Ib+A0V           +0.011-0.005 +.001-025V    < 19: 4.0 184.0AD   4*
+9004 19    PscBD+02 4709 2230751283743908I         TX Psc   234116.9+025555234623.5+032912 93.28-55.60 5.04  +2.60 +3.49 +1.35   C5II               -0.030-0.025 -.004+011V                         *
+9005          BD+65 1943 223128 20838                       234150.3+661337234636.7+664656116.59  4.71 5.95  -0.04 -0.74         B2IV               +0.004+0.001      -014                           
+9006   Sig PheCD-5014047 2231452480183910                   234157.6-504653234716.0-501336326.59-63.85 5.18  -0.19               B3V                +0.011-0.029      +011      217                  
+9007          CP-69 3335 2231482555673911                   234152.1-685656234723.3-682339311.60-47.64 6.89  +0.46 +0.06         F2V                +0.045-0.043      -002                           
+9008  5Tau CasBD+57 2804 223165 357633909I         14707    234209.9+580542234703.5+583907114.63-03.18 4.87  +1.11 +1.05         K1IIIa             +0.061+0.057 +.014-021V    < 17                  
+9009          BD-12 6559 223170165880                       234206.9-122751234715.9-115439 75.12-68.59 5.73  +1.08 +0.97        gK1                 -0.049-0.086      +011                           
+9010          BD+56 3085 223173 35761    I                  234208.4+565346234701.9+572705114.33-04.34 5.51  +1.65 +1.81         K3IIb              +0.002-0.003      -006V?                         
+9011          BD+46 4169 223229 53374       17006  14709    234234.8+461638234733.2+464957111.71-14.64 6.07  -0.14 -0.66         B3IV               +0.013-0.003D+.002-024SB         2.0   0.9      *
+9012 20    PscBD-03 5707 2232521469151623  W                234248.1-031903234756.5-024542 88.27-61.28 5.49  +0.94 +0.70 +0.33E  G8III              +0.096+0.005      -007V?  =< 11  4.4 172.7AB   3*
+9013          BD+67 1562 223274 20853 895                   234307.5+671504234754.8+674825116.97  5.67 5.04  -0.01 -0.04         A1Vn               +0.014-0.001 +.015+010SB    185                  
+9014          BD-07 6086 2233111469193912I         14715    234324.1-065609234832.5-062250 84.33-64.43 6.07  +1.45 +1.71         K4III              +0.003-0.019      -021V                          
+9015          BD+01 4773 223346128393                       234342.2+013934234849.3+021251 93.25-57.00 6.46  +0.44 -0.02         F5III-IV           +0.007-0.042      -025SB     12                  
+9016   Del SclCD-2818353 223352192167 896   17021A          234343.1-284100234855.6-280749 25.18-76.13 4.57  +0.01 -0.03 -0.02   A0V                +0.105-0.106 +.039+014V?         4.5  74.3AC   3*
+9017          BD+64 1861 223358 20866       17020  V650 Cas 234348.3+641916234839.0+645235116.33  2.81 6.41  +0.06 +0.02         A0pSrSi:Cr:        +0.013-0.020 +.009-003           2.0   0.7AB   4*
+9018  6    CasBD+61 2533 223385 20869       17022  V566 Cas 234357.7+613931234850.2+621252115.71  0.22 5.43  +0.67 -0.02         A3Ia              e-0.005-0.001D+.001-046SB?    50  5.1   1.5AB   3*
+9019          BD+59 2777 223386 35794                       234359.4+592522234853.9+595844115.18-01.95 6.34  -0.01 -0.05         A0V                +0.048+0.007      -016    =< 41                  
+9020          BD+58 2653 223421 35798                       234416.8+582427234912.0+585747114.97-02.94 6.33  +0.40 -0.01         F2IV               +0.038-0.014      +030                           
+9021          BD-16 6373 223428165905                       234421.6-162459234931.6-155140 67.89-71.75 6.24  +1.22 +1.17         K2IIIbFe-0.5       +0.049-0.022      -064V?                         
+9022 21    PscBD+00 5054 223438128401                       234420.2+003115234927.5+010434 92.57-58.09 5.77  +0.16 +0.12         A5Vm               -0.002-0.030      +005SB     43                  
+9023          CP-63 4931 223444255578                       234421.9-632340234944.7-625022314.54-52.88 6.59  +1.48               K5III              +0.031-0.035      +011                           
+9024          BD+35 5110 223460 735353914          OU And   234439.0+355214234941.0+362531109.28-24.80 5.90  +0.79               G1III             e+0.001-0.048      +001V?                        *
+9025 79    PegBD+28 4649 223461 915223913                   234435.6+281709234939.4+285033106.95-32.10 5.97  +0.19 +0.13         A2m                +0.061+0.024      -004       38                  
+9026          CD-2616796 223466192180       17029           234438.7-255312234949.6-251953 36.88-76.08 6.42  +0.12 +0.12         A3V                -0.021-0.024      +016           5.2  13.5       
+9027          BD-10 6177 223524165911 897                   234505.1-103157235014.7-095827 79.96-67.59 5.94  +1.13 +1.15         K0IV               +0.140+0.076      -018V                          
+9028          BD+50 4165 223552 35823       17032           234522.4+510358235022.3+513718113.37-10.11 6.44  +0.37 -0.09         F3V                +0.123-0.015      -021           6.1  21.0AB   3 
+9029          BD-15 6507 223559165915                       234523.8-145725235033.3-142407 71.78-70.94 5.72  +1.51 +1.81         K4.5IIIb           +0.037-0.033      -058V?                         
+9030 80    PegBD+08 5127 223637128421    I         HH Peg   234615.0+084532235121.2+091848 99.09-50.75 5.79  +1.66 +1.74 +0.54   M3IIIa             -0.016-0.063      -009                          *
+9031108    AqrBD-19 6522 223640165918              ET Aqr   234611.5-192755235121.3-185432 60.54-73.94 5.18  -0.14 -0.42         B9pSiSrCr         v+0.021 0.000 +.023+013V      40                 *
+9032   Gam1OctCP-82  905 2236472589893997                   234614.9-823429235206.4-820108305.41-34.82 5.11  +0.92 +0.60         G7III              -0.055-0.019      +015                           
+9033 22    PscBD+02 4725 2237191284273918I                  234650.6+022228235157.9+025549 95.11-56.69 5.55  +1.53 +1.86         K4IIIaBa0.3        +0.020-0.015      +000                          *
+9034          BD+76  934 223731 108743919                   234709.2+770245235157.6+773558119.66 15.11 6.55  +0.44 -0.11         F5V                +0.264-0.092 +.042+001V?                         
+9035          BD+20 5386 223755 91548    I                  234718.7+210654235223.4+214015105.15-39.15 6.11  +1.59 +1.97         M2III              -0.049-0.015      -005V?                         
+9036 81Phi PegBD+18 5231 223768108878 898I         14735    234723.9+183354235229.3+190713104.18-41.60 5.08  +1.60 +1.86         M2.5IIIb           -0.005-0.036 +.011-008V?                         
+9037          BD-15 6515 223774165933                       234721.7-144827235230.0-141504 73.14-71.17 5.87  +1.28 +1.37         K3III              -0.101 0.000      +002                           
+9038          BD+74 1047 223778 10879       17062           234731.7+745913235225.1+753241119.18 13.10 6.39  +0.98 +0.71         K3V                +0.314+0.049 +.097+001SBO        1.9 161.9AC   3*
+9039 82    PegBD+10 5004 2237811088791625          HT Peg   234731.0+102328235237.1+105651100.44-49.34 5.30  +0.18 +0.09         A4Vn               -0.029+0.001 +.018-003V     156                 *
+9040          BD-09 6277 223807146953                       234741.8-093309235250.5-085948 82.82-67.19 5.75  +1.17 +1.15         K0III              +0.064-0.021      -018V?                         
+9041 24    PscBD-03 5723 223825146954      W                234747.3-034239235255.6-030920 90.15-62.24 5.93  +1.07 +0.96         G9III              +0.075-0.046      -006V          0.0   0.1      *
+9042 25    PscBD+01 4792 223855128436                       234757.4+013205235304.8+020526 94.93-57.57 6.28  -0.01 -0.01         A1V                +0.022-0.012      +005SB     46                  
+9043          CD-2417897 223884192218                       234810.6-244707235320.8-241345 42.19-76.60 6.24  +0.19               A3Shell            +0.047-0.011      -003                          *
+9044          CD-2716479 223991192231       17090           234911.4-273558235421.4-270232 30.05-77.30 6.35  +0.20  0.00 +0.11   A2V+F2V            +0.020+0.025D+.006+017SB  =< 39  0.7   6.4      *
+9045  7Rho CasBD+56 3111 224014 35879 899I         Rho Cas  234923.0+565635235423.0+572958115.30-04.52 4.54  +1.22 +1.12 +0.74   G20e              v-0.002-0.002 +.023-043V      29                 *
+9046          CD-4015285 2240222318421626                   234924.0-405127235438.6-401800341.05-72.35 6.03  +0.57 +0.11         F8IV               +0.368+0.028 +.029-010                           
+9047          BD-00 4585 2240621469733920I         XZ Psc   234939.5-002648235446.6+000633 94.06-59.55 5.61  +1.59 +1.51 +1.30E  M5III              -0.040-0.018      -002V?                        *
+9048 26    PscBD+06 5216 224103128466                       235000.8+063054235507.8+070416 99.18-53.18 6.21  -0.07 -0.19         B9V                +0.021-0.019      +017V                          
+9049          CD-3217723 2241132148603921          AL Scl   235006.3-322841235516.6-315518  8.14-76.89 6.10  -0.08 -0.46         B6V                +0.022-0.003      -012SB1O  199                 *
+9050          CD-3217724 224112214861                       235006.4-322627235516.6-315303  8.29-76.90 6.83  -0.08 -0.34         B8V                +0.003+0.008      +001V?                         
+9051          BD+25 5042 224128 91582                       235017.6+252355235523.0+255718107.47-35.23 6.54R                     K5                 -0.003-0.008      -015                           
+9052          BD+56 3115 224151 35899              V373 Cas 235032.7+565120235533.7+572444115.44-04.64 6.00  +0.21 -0.72         B0.5II+B0.5II     v-0.008-0.003 +.029-026SBO                       *
+9053          BD+46 4214 224165 53486                       235030.5+464758235533.6+472121113.21-14.46 6.00  +1.16 +0.94         G8Ib                0.000-0.005      -017                           
+9054          CD-2516707 2242831922523922                   235120.8-251739235629.9-244414 40.82-77.43 6.31  +0.92               G5                 +0.003+0.010      -035V?                         
+9055          BD+21 4999 224303 915951628I                  235135.7+220530235641.5+223853106.73-38.50 6.15  +1.60 +1.97         M2III              -0.022-0.005      +001V?                         
+9056          BD+82  743 224309  39941650          V Cep    235145.3+823804235627.7+831128121.21 20.50 6.59  +0.05 +0.05         A3V                +0.047+0.007      -013                          *
+9057          BD+41 4902 224342 535113923                   235159.1+420606235703.6+423930112.39-19.10 5.97  +0.69 +0.30         F8III              +0.008-0.001      -007V                         *
+9058          CD-2716494 224350192262    I         14772    235158.7-271051235708.3-263725 32.23-77.89 6.26  +1.45               K3III              +0.071+0.017      -012V                          
+9059          BD+54 3076 224355 35917              14773    235205.8+550858235708.5+554221115.29-06.36 5.55  +0.49 +0.03         F1/6V+F3           -0.019-0.011      +013SBO                       *
+9060          CP-63 4940 2243612556063924                   235205.1-633050235719.9-625723313.13-53.09 5.97  +0.11 +0.10         A1IV               +0.082+0.018      -013                          *
+9061   Gam2OctCP-82  907 224362258996                       235204.1-824333235732.7-821012305.14-34.73 5.73  +1.05 +0.92         K0III              -0.035-0.026      +027                           
+9062   Eta TucCP-64 4391 224392255609                       235220.2-645112235735.2-641754312.34-51.84 5.00  +0.06 +0.08         A1V                +0.086-0.068 +.036+033      191                  
+9063          BD+59 2795 224404 35922                       235230.9+592801235733.5+600125116.24-02.15 6.47  +0.01 -0.10         B9III-IV           +0.012-0.002      -008V?                         
+9064 84Psi PegBD+24 4865 224427 916111629I S       14777    235239.7+243508235745.5+250829107.85-36.15 4.66  +1.59 +1.68 +1.34   M3III              -0.034-0.033 +.005-004V?                        *
+9065  1    CetBD-16 6394 2244811659723925                   235312.5-162415235821.2-155051 72.72-73.30 6.26  +1.08 +1.03         K0II-III           +0.086-0.006      +004V?                         
+9066          BD+50 4202 224490 35938    I  17135  R Cas    235319.6+504954235824.8+512319114.56-10.62 4.8   +1.83 +0.08         M7IIIe            v+0.080+0.009      +021V          5.4  29.5AC   3*
+9067 27    PscBD-04 5996 224533147008 900I  17137  14785    235333.2-040639235840.4-033322 92.51-63.27 4.86  +0.93 +0.70         G9III              -0.051-0.072 +.029-000SB   < 19: 5.3   1.1      *
+9068          BD+31 5012 224544 736503927          Var?     235343.2+314930235849.2+322254110.21-29.19 6.52  -0.11 -0.57         B6IVe              +0.003-0.007      -006                          *
+9069   Pi  PheCP-5310561 224554248087 901                   235344.9-531816235855.8-524445320.30-62.57 5.13  +1.13 +1.03         K0III              +0.055+0.061 +.016-014                           
+9070          BD+45 4381 224559 53540              LQ And   235341.2+455123235846.5+462447113.55-15.50 6.54  -0.09 -0.61         B4Ven             v+0.022-0.005      -001V                         *
+9071  8Sig CasBD+54 3082 224572 35947       17140           235356.0+551154235900.5+554518115.55-06.36 4.88  -0.07 -0.82 -0.11   B1V                +0.009-0.004D+.006-013SB2   189  2.2   2.8AB   3*
+9072 28Ome PscBD+06 5227 224617128513 902I         14793    235410.5+061835235918.7+065148100.69-53.74 4.01  +0.42 +0.06 +0.24   F4IV               +0.153-0.115 +.018+002SBO    38  2.2   1.0     3*
+9073          CD-3019765 224630192294    I                  235419.5-300231235927.9-292906 18.25-78.33 5.62  +1.60 +2.00         K5III              -0.001-0.001      -005                           
+9074          BD+32 4747 224635 73656       17149A          235423.5+331012235929.2+334328110.72-27.91 6.58H +0.55 -0.01         G0V                -0.060-0.080D+.051-008V?      7  0.2   1.5AB   3*
+9075          BD+32 4747 224636 73656       17149B          235423.5+331012235929.2+334328110.72-27.91 6.58H                     G0V                -0.060-0.080D+.051-005V?      7  0.2   1.5AB   3*
+9076   Eps TucCP-66 3819 224686255619 903                   235443.3-660800235955.0-653438311.30-50.71 4.50  -0.08 -0.28 -0.05   B9IV              v+0.048-0.024      +011      291                 *
+9077          CD-4415420 224750231888      W                235509.8-445040000019.2-441726330.51-70.00 6.29  +0.76               G3IV               +0.080-0.111      +003           0.5   0.4       
+9078          BD+26 4727 224758 91648      W                235516.8+262146000023.9+265506109.09-34.58 6.46  +0.50 +0.01         F7-8IV-V           +0.044-0.052      +000V                         *
+9079          BD+58 2685 224784 359833928                   235526.5+590013000030.9+593335116.52-02.68 6.19  +1.01 +0.80         G9III-IV           -0.077-0.024      -033                          *
+9080          BD+44 4538 224801 53568              CG And   235537.1+444147000043.7+451512113.65-16.70 6.38  -0.07 -0.33         B9pSiEu           v+0.027+0.005      -003SB     49                 *
+9081   Tau PheCD-4914316 224834231895                       235556.3-492200000104.5-484836323.79-66.23 5.71  +0.91               G8III              -0.022-0.009      +008                           
+9082          CD-5113743 224865248103                       235611.7-505340000120.0-502014321.98-64.90 5.53  +1.60 +1.93         M2III              +0.002+0.013 +.008+002                           
+9083          BD+49 4309 224870 535733929                   235612.6+492530000119.3+495854114.73-12.09 6.22  +0.97               G7II-III           +0.018-0.006      -020                           
+9084   The OctCP-77 1596 224889258207 904                   235627.5-773704000135.7-770357306.53-39.71 4.78  +1.27 +1.41 +0.67   K3III              -0.063-0.177 +.017+024                           
+9085          BD+60 2657 224893 21009                       235630.6+603958000136.9+611323116.97-01.07 5.55  +0.41 +0.39         F0III              -0.006+0.005      -023SB?    38                  
+9086          BD+41 4920 224906 53580                       235636.8+414837000143.8+422202113.22-19.56 6.25  -0.03 -0.25         B9IIIpHg:Mn:       +0.005-0.003      -011V      42                  
+9087 29    PscBD-03 5749 224926147041              14804    235641.9-033503000149.4-030139 94.59-63.14 5.10  -0.12 -0.51         B7III-IV           +0.016-0.009      +023V?     80                 *
+9088 85    PegBD+26 4734 224930 91669       17175  14809    235656.7+263310000210.2+270455109.60-34.50 5.75  +0.67 +0.05 +0.43   G5VbFe-2           +0.841-0.991 +.083-036SBO     2  3.1  75.5AC   4*
+9089 30    PscBD-06 6345 2249351470421630I         YY Psc   235649.8-063411000157.6-060051 91.58-65.83 4.41  +1.63 +1.83 +1.41   M3III             e+0.051-0.041 +.006-012V                         *
+9090          BD-15 6531 224960166005    I         W Cet    235659.9-151357000207.3-144034 77.78-73.06 7.1   +1.80 +0.55 +3.71   S7.3e              -0.010-0.019      +013                          *
+9091   Zet SclCD-3019790 224990      3932  W                235712.3-301639000219.9-294313 16.55-78.90 5.01  -0.15 -0.55 -0.14   B4III              +0.019+0.016      +000SB     47  8.0   3.       *
+9092 31    PscBD+08 5164 224995128544                       235716.8+082400000224.2+085725103.01-52.01 6.32  +0.18 +0.14         A6V                +0.005-0.003      +011V      97                  
+9093 32    PscBD+07 5121 2250031285473933                   235722.9+075548000229.7+082908102.81-52.46 5.63  +0.29 +0.03         F0V                -0.092-0.047      +010V?                        *
+9094          BD+65 1987 225009 10937           1A          235728.5+653232000236.1+660556118.01  3.70 5.86  +1.09 +0.91         G8III              +0.010-0.001D+.010-018V   =< 25  1.5  15.2AB   3*
+9095          BD-20 6703 225045166014                       235749.5-203618000257.6-200246 62.90-76.84 6.25  +0.53 +0.08         F6V                +0.110+0.071      -004V?                         
+9096          CD-2417960 225069166016                       235800.2-244208000307.7-240843 45.57-78.72 6.44  +1.18               G5                 +0.039 0.000      +025                           
+9097          BD+62 2356 225094 10942              V639 Cas 235817.4+630501000325.7+633831117.63  1.26 6.24  +0.33 -0.54 +0.23   B3Ia              e-0.008+0.057      -043V?                        *
+9098  2    CetBD-18 6417 225132147059 905                   235837.0-175333000344.4-172010 72.10-75.26 4.55  -0.05 -0.12 -0.04   B9.5Vn             +0.026-0.009 +.007-005V     186                  
+9099          BD+65 1993 225136 10948    I                  235842.4+660920000351.9+664244118.25  4.27 6.29  +1.67 +1.94         M4III              +0.021-0.008      +015                           
+9100  9    CasBD+61 2586 225180 10954      W                235904.5+614351000413.6+621716117.47-00.08 5.88  +0.30 +0.29         A1III              -0.004+0.006      -018V          4.0 246.0       
+9101          BD-17 6868 225197147064                       235912.4-170503000419.7-163144 74.70-74.79 5.78  +1.10 +1.05         K2III              +0.039-0.059      -027                           
+9102          CD-2918950 225200166031                       235913.2-294933000420.3-291607 18.53-79.41 6.40   0.00 -0.05         A0V                +0.030+0.014      +028                           
+9103  3    CetBD-11 6194 2252121470662001I            13    235923.0-110358000430.1-103034 87.07-70.04 4.94  +1.63 +1.92         K3Ib              v-0.005-0.011 +.016-042V    < 17                  
+9104          BD+66 1679 225216 10956                       235930.1+663632000442.0+671000118.41  4.71 5.67  +1.07 +0.93         K1III              +0.092+0.030 +.013-027                           
+9105          BD+41 4933 225218 36037    I     30           235928.2+413210000436.7+420532113.72-19.94 6.01R                     B9III              +0.005-0.022      -008SB         3.7   5.4      *
+9106          CP-73 2346 225233255629                       235926.8-732712000430.7-725352307.68-43.80 7.31  +0.44 +0.01         F2V                +0.010-0.054      +008                           
+9107          BD+33 4828 225239 536222002                   235939.2+340602000453.8+343935112.17-27.24 6.12  +0.62 +0.09         G2V                +0.772+0.089 +.035+004V                          
+9108          CP-72 2800 2252532556311001                   235937.0-715936000441.3-712613308.18-45.21 5.59  -0.12 -0.42         B8IV-V             +0.028-0.014      -003V                          
+9109          BD+25 5068 225276 73731    I     42           235947.1+260533000456.0+263856110.22-35.07 6.25  +1.40 +1.59         K4IIIb             +0.110-0.012      -005           4.5  17.5       
+9110          BD+60 2667 225289 10962              V567 Cas 235955.9+604526000506.2+611851117.40-01.06 5.80  -0.09 -0.32         B8IVpHgMn          +0.015+0.005      +014V      50                 *
Index: /tags/Mars_V0-8-5/Mars/mtemp/mmpi/macros/callalphaplot.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mmpi/macros/callalphaplot.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mmpi/macros/callalphaplot.C	(revision 9661)
@@ -0,0 +1,1271 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cherenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!   Author(s): Daniel Mazin, 05/2004 <mailto:mazin@imppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+
+// Daniel Mazin 18.05.2004  mazin@mppmu.mpg.de
+// **********************************************************************************
+// this macro is used to produce an alpha plot/plots for a chosen position in the sky map.
+// In case of several subsamples, the overall alpha plot is also produced.
+// The derotation is possible if Zd and Az are available for each event.
+// Using of OFF data to estimate Nex and Significance is optional (if such data available)
+//
+// input: hillas parameter file/files
+//      optional: a) ascii file with the estimated position of the source
+//                b) ascii file with fit parameters from the OFF sample 
+//                                  (needed for estimation of the background from OFF dada)
+// output: alpha plot for each subsample, overall alpha plot
+// **********************************************************************************
+
+
+#define XSOUR   0.05  // [deg]
+#define YSOUR   0.6  // [deg]
+#define NUM     0
+
+
+TString sourcename = "M87On";
+
+const Bool_t ROTOPTION  = kFALSE;  // kFALSE: do not derotate, use camera coordinates
+                                  // kTRUE: derotate into "quasi" sky coordinates
+
+const Bool_t USEOFFDATA = kFALSE; // kFALSE: do not use OFF data to estimate the significance
+                                  // kTRUE: use in addition OFF data to estimate the significance
+
+const char * offfile = "paramOffCrab2701.dat"; // file with parameters of the OFF sample
+                                               // needed only if USEOFFDATA = kTRUE
+
+const Bool_t USEFILE = kFALSE; // kFALSE : use XSOUR, YSOUR 
+                               // kTRUE: use "posfile" 
+                               // to specify the position for which alpha plot has to be produced
+
+const Bool_t SAMPLES = kFALSE; // kFALSE: one sample only
+                               // kTRUE: several samples, usage of posfile is preferred!  
+
+const char * posfile = "data/trackCrab1502_1305_Berlin_5deg.dat"; // file with best position
+                                                                  // if USEFILE == kFALSE : not needed
+
+TString dirname  = "~/data/M87/2004_02_17/";
+TString filename = "M87HillasON.root"; //  NOTE in case of several subsamples (SAMPLES=kTRUE)
+                                         // folllowing name construction is assumed:
+                                         // file = dirname + sample + <number> + / + filename
+                                         // e.g: ~/data/Crab/2004_01_27/sample2/CrabHillasON.root
+#define tolerance 1e-3
+/* ******************************************************   */
+      /*  dynamical cuts  Crab 27th Jan 2004 */
+/*
+#define LENGTHMINParA 0.136  // deg
+#define LENGTHMINParB 0.036  //
+#define LENGTHMINParC -0.0038  //
+#define LENGTHMAXParA 0.332  // deg
+#define LENGTHMAXParB 0.037  //
+#define LENGTHMAXParC 0.0261 //
+#define WIDTHMINParA  0.063  // deg
+#define WIDTHMINParB  0.013  //
+#define WIDTHMINParC  0.0003  //
+#define WIDTHMAXParA  0.123  // deg
+#define WIDTHMAXParB  0.019  //
+#define WIDTHMAXParC  0.0005 //
+#define DISTMINParA   0.6   // deg
+#define DISTMINParB   0.059  //
+#define DISTMINParC   0.  //
+#define DISTMAXParA   1.25   // deg
+#define DISTMAXParB   0.059  //
+#define DISTMAXParC   0.  //
+*/
+
+      /*  dynamical cuts  Mrk 421 and Crab 15th Feb 2004 */
+
+#define LENGTHMINParA 0.12  // deg
+#define LENGTHMINParB 0.034  //
+#define LENGTHMINParC 0.  //
+#define LENGTHMAXParA 0.32  // deg
+#define LENGTHMAXParB 0.034  //
+#define LENGTHMAXParC 0. //
+#define WIDTHMINParA  0.055  // deg
+#define WIDTHMINParB  0.013  //
+#define WIDTHMINParC  0.0  //
+#define WIDTHMAXParA  0.12  // deg
+#define WIDTHMAXParB  0.013  //
+#define WIDTHMAXParC  0.0 //
+#define DISTMINParA   0.6   // deg
+#define DISTMINParB   0.059  //
+#define DISTMINParC   0.  //
+#define DISTMAXParA   1.25   // deg
+#define DISTMAXParB   0.059  //
+#define DISTMAXParC   0.  //
+
+
+#define SIZEMIN 2000
+#define LEAKMAX 0.25
+#define ASYMMIN  -0.1 
+
+#include "mtools.C"
+
+#define ALPHAMAX 15.
+
+#define ALOFFMAX 90.
+#define ALOFFMIN 30.
+
+// histogram to store the sum of alpha plots
+   TH1F histalphaAll("alpha plot", "alpha plot, size cut 2000, 15 deg", 36, 0., 90.);
+   histalphaAll.SetXTitle("alpha (deg)");
+   histalphaAll.SetYTitle("Counts");
+   histalphaAll.SetDirectory(NULL);
+   histalphaAll.SetFillStyle(4000);
+   histalphaAll.UseCurrentStyle();
+
+
+void alphaplots(Int_t num, Double_t XSOURCE, Double_t YSOURCE)
+{
+
+// for USEOFFDATA = kTRUE the ascii file with fit parameters of the OFF sample is read.
+
+   if (USEOFFDATA == kTRUE)
+   {
+	    Int_t event, dummy, numbinsoff;
+	    Float_t binwidthOff, xpos, ypos, aparOff, bparOff, chi2par;
+
+	    FILE *fp;
+	    fp = fopen(offfile,"r");    
+	    while(fscanf(fp,"%d %f %f %f %f %f %f %f %f %f",
+		       &event, &xpos, &ypos,  &aparOff, &bparOff, &chi2par,
+		       &binwidthOff, &dummy, &dummy, &dummy) != EOF)
+	    {
+//cout << event << " " << xpos << " " << ypos << endl;
+		     if(TMath::Abs(xpos-XSOURCE) < tolerance && TMath::Abs(ypos-YSOURCE) < tolerance) break;
+	    }
+	    fclose(fp);
+   }
+
+
+    gStyle->SetCanvasBorderMode(0);
+    gStyle->SetCanvasBorderSize(0);
+    gStyle->SetCanvasColor(10);
+    gStyle->SetPadBorderMode(0);
+    gStyle->SetPadBorderSize(0);
+    gStyle->SetPadColor(10);
+    gStyle->SetOptFit(1);
+    gStyle->SetStatColor(10);
+//    gStyle->SetOptStat(0);
+    gStyle->SetPalette(1,0);
+
+
+
+// the name of the Hillas parameter file, which has to be read in
+    TString ddumy;
+
+    if (SAMPLES == kFALSE)
+        filename = dirname + filename;
+    else
+    {
+       ddumy = dirname;
+       ddumy += "sample"; 
+       ddumy += num; 
+       filename = ddumy + filename; 
+    }
+
+cout << "file to read :" << filename << endl;
+
+
+// create histograms   
+    MBinning bins;
+
+   TH1F histlength;
+   histlength.SetName("Length");
+   histlength.SetTitle("Length");
+   histlength.SetXTitle("Length [deg]");
+   histlength.SetYTitle("Counts");
+   histlength.SetDirectory(NULL);
+   histlength.SetFillStyle(4000);
+   histlength.UseCurrentStyle(); 
+
+
+    bins.SetEdges(100, 0., 1.);
+    bins.Apply(histlength);
+
+
+   TH1F histwidth;
+   histwidth.SetName("Width");
+   histwidth.SetTitle("Width");
+   histwidth.SetXTitle("Width [deg]");
+   histwidth.SetYTitle("Counts");
+   histwidth.SetDirectory(NULL);
+   histwidth.SetFillStyle(4000);
+   histwidth.UseCurrentStyle(); 
+
+    bins.SetEdges(100, 0., 0.5);
+    bins.Apply(histwidth);
+
+
+   TH1F histsize;
+   histsize.SetName("Size");
+   histsize.SetTitle("Size");
+   histsize.SetXTitle("Size");
+   histsize.SetYTitle("Counts");
+   histsize.SetDirectory(NULL);
+   histsize.SetFillStyle(4000);
+   histsize.UseCurrentStyle(); 
+
+//    bins.SetEdges(100, 100., 2e5);
+//    bins.Apply(histsize);
+
+    bins.SetEdgesLog(100, 100., 10e5);
+    bins.Apply(histsize);
+
+   TH1F histalpha;
+   histalpha.SetName("Alpha");
+   histalpha.SetTitle("Alpha");
+   histalpha.SetXTitle("Alpha [deg]");
+   histalpha.SetYTitle("Counts");
+   histalpha.SetDirectory(NULL);
+   histalpha.SetFillStyle(4000);
+   histalpha.UseCurrentStyle(); 
+
+    bins.SetEdges(100, -100., 100.);
+    bins.Apply(histalpha);
+
+   TH1F histdist;
+   histdist.SetName("Dist");
+   histdist.SetTitle("Dist");
+   histdist.SetXTitle("Dist [deg]");
+   histdist.SetYTitle("Counts");
+   histdist.SetDirectory(NULL);
+   histdist.SetFillStyle(4000);
+   histdist.UseCurrentStyle(); 
+
+    bins.SetEdges(100, 0., 2.);
+    bins.Apply(histdist);
+
+   TH1F histmeanx;
+   histmeanx.SetName("MeanX");
+   histmeanx.SetTitle("MeanX");
+   histmeanx.SetXTitle("MeanX [deg]");
+   histmeanx.SetYTitle("Counts");
+   histmeanx.SetDirectory(NULL);
+   histmeanx.SetFillStyle(4000);
+   histmeanx.UseCurrentStyle(); 
+
+    bins.SetEdges(100, -1.8, 1.8);
+    bins.Apply(histmeanx);
+
+   TH1F histmeany;
+   histmeany.SetName("MeanY");
+   histmeany.SetTitle("MeanY");
+   histmeany.SetXTitle("MeanY [deg]");
+   histmeany.SetYTitle("Counts");
+   histmeany.SetDirectory(NULL);
+   histmeany.SetFillStyle(4000);
+   histmeany.UseCurrentStyle(); 
+
+
+    bins.SetEdges(100, -1.8, 1.8);
+    bins.Apply(histmeany);
+
+   TH1F histalphafinal;
+   histalphafinal.SetName("ALPHA");
+   histalphafinal.SetTitle("ALPHA");
+   histalphafinal.SetXTitle("alpha [deg]");
+   histalphafinal.SetYTitle("Counts");
+   histalphafinal.SetDirectory(NULL);
+   histalphafinal.SetFillStyle(4000);
+   histalphafinal.UseCurrentStyle(); 
+
+    bins.SetEdges(36, 0.0, 90.);
+    bins.Apply(histalphafinal);
+
+   TH1F histAssym;
+   histAssym.SetName("Assymetry");
+   histAssym.SetTitle("Assymetry");
+   histAssym.SetXTitle("Assymetry");
+   histAssym.SetYTitle("Counts");
+   histAssym.SetDirectory(NULL);
+   histAssym.SetFillStyle(4000);
+   histAssym.UseCurrentStyle(); 
+
+    bins.SetEdges(100, -1, 1.);
+    bins.Apply(histAssym);
+
+   TH1F histAssymM3;
+   histAssymM3.SetName("Assymetry 3M");
+   histAssymM3.SetTitle("Assymetry 3rd moment");
+   histAssymM3.SetXTitle("Assymetry 3rd moment");
+   histAssymM3.SetYTitle("Counts");
+   histAssymM3.SetDirectory(NULL);
+   histAssymM3.SetFillStyle(4000);
+   histAssymM3.UseCurrentStyle(); 
+
+    bins.SetEdges(100, -1., 1.);
+    bins.Apply(histAssymM3);
+
+   TH2F hist2xy("CoG","Center of Gravity", 100, -1.8, 1.8, 100, -1.8, 1.8);
+   hist2xy.SetXTitle("MeanX [deg]");
+   hist2xy.SetYTitle("MeanY [deg]");
+   hist2xy.SetDirectory(NULL);
+   hist2xy.SetFillStyle(4000);
+   hist2xy.UseCurrentStyle();
+ 
+   TH1F histLoverS;
+   histLoverS.SetName("LoverS");
+   histLoverS.SetTitle("LoverS");
+   histLoverS.SetXTitle("LoverS");
+   histLoverS.SetYTitle("Counts");
+   histLoverS.SetDirectory(NULL);
+   histLoverS.SetFillStyle(4000);
+   histLoverS.UseCurrentStyle(); 
+
+    bins.SetEdges(100, -0., 0.0006);
+    bins.Apply(histLoverS);
+
+   TH2F hist2lw("Length-Width", "correlation Length-Width", 100, 0.0, 1.0, 100, 0.0, 0.5);
+   hist2lw.SetXTitle("Length [deg]");
+   hist2lw.SetYTitle("Width [deg]");
+   hist2lw.SetDirectory(NULL);
+   hist2lw.SetFillStyle(4000);
+   hist2lw.UseCurrentStyle();
+ 
+   TH2F hist2lalpha("Length-Alpha", "correlation Length-Alpha", 100, 0.0, 1.0, 100, -100., 100.);
+   hist2lalpha.SetXTitle("Length [deg]");
+   hist2lalpha.SetYTitle("Alpha [deg]");
+   hist2lalpha.SetDirectory(NULL);
+   hist2lalpha.SetFillStyle(4000);
+   hist2lalpha.UseCurrentStyle();
+ 
+   TH2F hist2ldist("Length-Dist","correlation Length-Dist", 100, 0.0, 1.0, 100, 0.0, 1.7);
+   hist2ldist.SetXTitle("Length [deg]");
+   hist2ldist.SetYTitle("Dist [deg]");
+   hist2ldist.SetDirectory(NULL);
+   hist2ldist.SetFillStyle(4000);
+   hist2ldist.UseCurrentStyle();
+ 
+   TH2F hist2walpha("Width-Alpha","correlation Width-Alpha", 100, 0.0, 0.5, 100, -100., 100.);
+   hist2walpha.SetXTitle("Width [deg]");
+   hist2walpha.SetYTitle("Alpha [deg]");
+   hist2walpha.SetDirectory(NULL);
+   hist2walpha.SetFillStyle(4000);
+   hist2walpha.UseCurrentStyle();
+ 
+   TH2F hist2wdist("Width-Dist","correlation Width-Dist", 100, 0.0, 0.5, 100, 0.0, 1.7);
+   hist2wdist.SetXTitle("Width [deg]");
+   hist2wdist.SetYTitle("Dist [deg]");
+   hist2wdist.SetDirectory(NULL);
+   hist2wdist.SetFillStyle(4000);
+   hist2wdist.UseCurrentStyle();
+ 
+   TH2F hist2alphadist("Alpha-Dist","correlation Alpha-Dist", 100, -100., 100, 100, 0.0, 1.7);
+   hist2alphadist.SetXTitle("Alpha [deg]");
+   hist2alphadist.SetYTitle("Dist [deg]");
+   hist2alphadist.SetDirectory(NULL);
+   hist2alphadist.SetFillStyle(4000);
+   hist2alphadist.UseCurrentStyle();
+ 
+   TH1F histphi;
+   histphi.SetName("TelPhia");
+   histphi.SetTitle("Telescope Phi");
+   histphi.SetXTitle("Phi [rad]");
+   histphi.SetYTitle("Counts");
+   histphi.SetDirectory(NULL);
+   histphi.SetFillStyle(4000);
+   histphi.UseCurrentStyle(); 
+
+    bins.SetEdges(100, -10, 10);
+    bins.Apply(histphi);
+
+   TH1F histtheta;
+   histtheta.SetName("TelTheta");
+   histtheta.SetTitle("Telescope Theta");
+   histtheta.SetXTitle("Theta [rad]");
+   histtheta.SetYTitle("Counts");
+   histtheta.SetDirectory(NULL);
+   histtheta.SetFillStyle(4000);
+   histtheta.UseCurrentStyle(); 
+
+    bins.SetEdges(100, -2, 2.);
+    bins.Apply(histtheta);
+
+   TH1F aftercuthistlength;
+   aftercuthistlength.SetName("Length");
+   aftercuthistlength.SetTitle("Length");
+   aftercuthistlength.SetXTitle("Length [deg]");
+   aftercuthistlength.SetYTitle("Counts");
+   aftercuthistlength.SetDirectory(NULL);
+   aftercuthistlength.SetFillStyle(4000);
+   aftercuthistlength.UseCurrentStyle();
+
+
+    bins.SetEdges(100, 0., 1.);
+    bins.Apply(aftercuthistlength);
+
+   TH1F aftercuthistwidth;
+   aftercuthistwidth.SetName("Width");
+   aftercuthistwidth.SetTitle("Width");
+   aftercuthistwidth.SetXTitle("Width [deg]");
+   aftercuthistwidth.SetYTitle("Counts");
+   aftercuthistwidth.SetDirectory(NULL);
+   aftercuthistwidth.SetFillStyle(4000);
+   aftercuthistwidth.UseCurrentStyle();
+
+    bins.SetEdges(100, 0., 0.5);
+    bins.Apply(aftercuthistwidth);
+
+   TH1F aftercuthistsize;
+   aftercuthistsize.SetName("Size");
+   aftercuthistsize.SetTitle("Size");
+   aftercuthistsize.SetXTitle("Size [photons]");
+   aftercuthistsize.SetYTitle("Counts");
+   aftercuthistsize.SetDirectory(NULL);
+   aftercuthistsize.SetFillStyle(4000);
+   aftercuthistsize.UseCurrentStyle();
+
+    bins.SetEdgesLog(100, 100., 10e5);
+    bins.Apply(aftercuthistsize);
+
+   TH1F aftercuthistalpha;
+   aftercuthistalpha.SetName("Alpha");
+   aftercuthistalpha.SetTitle("Alpha");
+   aftercuthistalpha.SetXTitle("Alpha [deg]");
+   aftercuthistalpha.SetYTitle("Counts");
+   aftercuthistalpha.SetDirectory(NULL);
+   aftercuthistalpha.SetFillStyle(4000);
+   aftercuthistalpha.UseCurrentStyle();
+
+    bins.SetEdges(20, 0., 100.);
+    bins.Apply(aftercuthistalpha);
+
+   TH1F aftercuthistdist;
+   aftercuthistdist.SetName("Dist");
+   aftercuthistdist.SetTitle("Dist");
+   aftercuthistdist.SetXTitle("Dist [deg]");
+   aftercuthistdist.SetYTitle("Counts");
+   aftercuthistdist.SetDirectory(NULL);
+   aftercuthistdist.SetFillStyle(4000);
+   aftercuthistdist.UseCurrentStyle();
+
+   bins.SetEdges(100, 0., 2.);
+    bins.Apply(aftercuthistdist);
+
+   TH1F aftercuthistmeanx;
+   aftercuthistmeanx.SetName("MeanX");
+   aftercuthistmeanx.SetTitle("MeanX");
+   aftercuthistmeanx.SetXTitle("MeanX [deg]");
+   aftercuthistmeanx.SetYTitle("Counts");
+   aftercuthistmeanx.SetDirectory(NULL);
+   aftercuthistmeanx.SetFillStyle(4000);
+   aftercuthistmeanx.UseCurrentStyle();
+
+    bins.SetEdges(100, -1.8, 1.8);
+    bins.Apply(aftercuthistmeanx);
+
+   TH1F aftercuthistmeany;
+   aftercuthistmeany.SetName("MeanY");
+   aftercuthistmeany.SetTitle("MeanY");
+   aftercuthistmeany.SetXTitle("MeanY [deg]");
+   aftercuthistmeany.SetYTitle("Counts");
+   aftercuthistmeany.SetDirectory(NULL);
+   aftercuthistmeany.SetFillStyle(4000);
+   aftercuthistmeany.UseCurrentStyle();
+
+
+    bins.SetEdges(100, -1.8, 1.8);
+    bins.Apply(aftercuthistmeany);
+
+   TH2F aftercuthist2xy("CoG","Center of Gravity", 100, -1.8, 1.8, 100, -1.8, 1.8);
+   aftercuthist2xy.SetXTitle("MeanX [deg]");
+   aftercuthist2xy.SetYTitle("MeanY [deg]");
+   aftercuthist2xy.SetDirectory(NULL);
+   aftercuthist2xy.SetFillStyle(4000);
+   aftercuthist2xy.UseCurrentStyle();
+
+
+
+   const Int_t n = 100;
+   Double_t binsize[n];
+
+   Float_t nmin = 100.;
+   Float_t nmax = 1e7;
+
+   for(Int_t i=0; i<n; i++)
+   {
+    binsize[i] = pow(10., log10(nmin) + i * (log10(nmax) - log10(nmin)) / (n-1.));
+   }
+
+   TH2F hist2wsize("Width-Size", "correlation Width-Size", 100, 0.0, 0.5, n-1, binsize);
+   hist2wsize.SetXTitle("Width [deg]");
+   hist2wsize.SetYTitle("Size");
+   hist2wsize.SetDirectory(NULL);
+   hist2wsize.SetFillStyle(4000);
+   hist2wsize.UseCurrentStyle();
+
+
+ 
+   TH2F hist2alphasize("Alpha-Size","correlation Alpha-Size", 100, -100., 100., n-1, binsize);
+   hist2alphasize.SetXTitle("Alpha [deg]");
+   hist2alphasize.SetYTitle("Size");
+   hist2alphasize.SetDirectory(NULL);
+   hist2alphasize.SetFillStyle(4000);
+   hist2alphasize.UseCurrentStyle();
+ 
+   TH2F hist2distsize("Dist-Size","correlation Dist-Size", 100, 0.0, 1.7, n-1, binsize);
+   hist2distsize.SetXTitle("Dist [deg]");
+   hist2distsize.SetYTitle("Size");
+   hist2distsize.SetDirectory(NULL);
+   hist2distsize.SetFillStyle(4000);
+   hist2distsize.UseCurrentStyle();
+// end create histograms
+
+
+ 
+    //
+    // Now setup the tasks and tasklist:
+    // ---------------------------------
+    //
+
+    MParList  plist;
+
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+
+    MReadMarsFile read("Events");
+    read.DisableAutoScheme();
+
+    read.AddFile(filename);
+
+    MHillas mhillas;
+    plist.AddToList(&mhillas);
+
+    MHillasSrc mhillassrc;
+    plist.AddToList(&mhillassrc);
+
+    MHillasExt mhillasext;
+    plist.AddToList(&mhillasext);
+
+    MNewImagePar mnewimpar;
+    plist.AddToList(&mnewimpar);
+
+    MGeomCamMagic cam;
+    plist.AddToList(&cam);
+ 
+    MMcEvt mcevt;
+    plist.AddToList(&mcevt);
+ 
+    MPointingPos mpoint;
+    plist.AddToList(&mpoint);
+
+    MObservatory observ;
+    plist.AddToList(&observ);
+
+//    MRawRunHeader header;
+//    plist.AddToList(&header);
+    
+    tlist.AddToList(&read);
+   
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+   if (!tlist.PreProcess(&plist))
+      return;
+
+    Float_t fMm2Deg = cam->GetConvMm2Deg();
+    Int_t event = 0;
+    Int_t filenumber = 0;
+
+    Float_t ftheta, fphi, flength, fwidth, fsize, fmeanx, fmeany, falpha, fdist;
+    Float_t fsingam, fcosgam;
+    Double_t  xsournew, ysournew;
+    Float_t fdelta, fleak, fconc1, fcosda, fassym, fassymM3;
+    Int_t AsGrNull=0, AsLessNull=0;
+    Int_t AsGrNullAfter=0, AsLessNullAfter=0;
+    Float_t logsize, lgsize, lgsize2, tanbeta, beta;
+    const Float_t LOG3000 = log(3000.);
+    Char_t stringtriv1[80], stringlima[80], stringNex[80], stringsig[80];
+    Char_t stringNexOnOff[80], stringLiMaOnOff[80];
+
+// initial values:
+     Float_t  xsource = XSOURCE;
+     Float_t  ysource = YSOURCE;
+
+
+    while (tlist.Process())
+    {
+    event++;
+
+    if (mhillas->GetLength() != -1.)
+     {
+      // parameters:
+      flength = (mhillas->GetLength()) * fMm2Deg;
+      fwidth = (mhillas->GetWidth())*fMm2Deg;
+      fsize = mhillas->GetSize();
+      fmeanx = (mhillas->GetMeanX())*fMm2Deg;
+      fmeany = (mhillas->GetMeanY())*fMm2Deg;
+      falpha = mhillassrc->GetAlpha(); 
+      fdist = (mhillassrc->GetDist())*fMm2Deg;
+      fdelta = mhillas->GetDelta();
+      fconc1 = (mnewimpar->GetConc1());
+      fleak = mnewimpar->GetLeakage1();
+
+
+//      ftheta = mcevt->GetTelescopeTheta();
+      ftheta = mpoint->GetZd();
+//      fphi = mcevt->GetTelescopePhi();
+      fphi = mpoint->GetAz();
+// cout << " phi : " << fphi << " theta : " << ftheta << endl;
+      observ.RotationAngle(ftheta, fphi, fsingam, fcosgam);
+
+      fassym = (mhillasext->GetAsym()) * fMm2Deg;
+      fassymM3 = (mhillasext->GetM3Long()) * fMm2Deg;
+      fcosda = mhillassrc->GetCosDeltaAlpha();
+
+      if ((fassymM3*TMath::Sign(1.,fcosda)) > 0.) AsGrNull++;
+      else AsLessNull++;
+
+      if (ROTOPTION == kTRUE) // derotate into sky coordinates
+      {
+      /*     derotation    : correct sky coordinates into camera coordinates */
+             xsournew = fcosgam * xsource - fsingam * ysource;
+             ysournew = fsingam * xsource + fcosgam * ysource;
+       /*    end derotatiom    */
+      }
+      else // do not derotate, plot into camera coordinates
+      {
+             xsournew = xsource;
+             ysournew = ysource;
+      }
+
+      // basic plots:
+
+//    if (fsize > 3000.)
+    if (fsize > 0.)
+     {
+      histphi.Fill(fphi,1.);
+      histtheta.Fill(ftheta,1.);
+
+      histlength.Fill(flength,1.);
+      histwidth.Fill(fwidth,1.);
+      histsize.Fill(fsize,1.);
+      histLoverS.Fill(flength/fsize,1.);
+      histmeanx.Fill(fmeanx,1.);
+      histmeany.Fill(fmeany,1.);
+      histalpha.Fill(falpha,1.);
+      histdist.Fill(fdist,1.);
+      hist2xy.Fill(fmeanx, fmeany, 1.);
+     }
+
+// some cuts:
+     if (flength > 0.1 && flength < 0.32)
+        if (fwidth > 0.06 && fwidth < 0.15)
+          if (fdist > 0.6 && fdist < 1.3)
+            if (fsize > 3000.)
+//              if(sqrt(fmeanx*fmeanx + fmeany*fmeany) < 1.1)  
+//              if((fassymM3*fcosda < 0.3 && fassymM3*fcosda > 0.02) || 
+//                 (fassymM3*fcosda < -0.02 && fassymM3*fcosda > -0.2) )
+//                  if(fassym*fcosda > 0.) 
+                      {
+                       histAssymM3.Fill(fassymM3*TMath::Sign(1.,fcosda), 1.);
+                       histAssym.Fill(fassym*TMath::Sign(1.,fcosda), 1.);
+                       if ((fassymM3*TMath::Sign(1.,fcosda)) > 0.) AsGrNullAfter++;
+                       else AsLessNullAfter++;
+                      }
+
+// **********************************************************************  //
+// calculate alpha and dist according to the source location:
+           tanbeta = (fmeany - ysournew) / (fmeanx - xsournew);
+           beta = TMath::ATan(tanbeta);
+           falpha = (fdelta - beta) * 180./ TMath::Pi();
+           fdist = sqrt((fmeany - ysournew) * (fmeany - ysournew) +
+                             (fmeanx - xsournew) * (fmeanx - xsournew));
+
+          if(falpha > 90.) falpha -= 180.;
+          if(falpha < -90.) falpha += 180.;
+
+// **********************************************************************  //
+
+
+
+      if (fsize > 3000.)
+      {
+      // correlations:
+      hist2lw.Fill(flength, fwidth, 1.);
+      hist2lalpha.Fill(flength, falpha, 1.);
+      hist2ldist.Fill(flength, fdist, 1.);
+      hist2walpha.Fill(fwidth, falpha, 1.);
+      hist2wdist.Fill(fwidth, fdist, 1.);
+      hist2alphadist.Fill(falpha, fdist, 1.);
+      hist2wsize.Fill(fwidth, fsize, 1.);
+      hist2alphasize.Fill(falpha, fsize, 1.);
+      hist2distsize.Fill(fdist, fsize, 1.);
+      }     
+
+     // cuts:
+//cout << " before the cuts"  << "size :" << fsize << endl;
+                 logsize = log(fsize);
+                 lgsize = logsize-LOG3000;
+                 lgsize2 = lgsize*lgsize;
+                 if ( fsize > SIZEMIN )
+                 if ( fleak < LEAKMAX )
+                 if ( flength > (LENGTHMINParA + LENGTHMINParB*lgsize + LENGTHMINParC*lgsize2) &&
+                      flength < (LENGTHMAXParA + LENGTHMAXParB*lgsize + LENGTHMAXParC*lgsize2))
+                 if ( fwidth > (WIDTHMINParA + WIDTHMINParB*lgsize + WIDTHMINParC*lgsize2)  &&
+                      fwidth < (WIDTHMAXParA + WIDTHMAXParB*lgsize + WIDTHMAXParC*lgsize2) )
+                 if ( fdist > (DISTMINParA + DISTMINParB*lgsize + DISTMINParC*lgsize2)  &&
+                      fdist < (DISTMAXParA + DISTMAXParB*lgsize + DISTMAXParC*lgsize2) )
+//                 if ((fassym*TMath::Sign(1.,fcosda)) > ASYMMIN)   // asymmcut
+                 {
+                         falpha = TMath::Abs(falpha);
+                         histalphafinal.Fill(falpha,1.);
+                         histalphaAll.Fill(falpha,1.);
+
+                         aftercuthistlength.Fill(flength,1.);
+                         aftercuthistwidth.Fill(fwidth,1.);
+                         aftercuthistsize.Fill(fsize,1.);
+                         aftercuthistmeanx.Fill(fmeanx,1.);
+                         aftercuthistmeany.Fill(fmeany,1.);
+                         aftercuthistalpha.Fill(falpha,1.);
+                         aftercuthistdist.Fill(fdist,1.);
+                         aftercuthist2xy.Fill(fmeanx, fmeany, 1.);
+
+                 }
+
+
+     }
+    else filenumber++;
+    }
+
+//    cout << " conversion factor is: " << fMm2Deg <<  endl;
+    cout << " events read in from file : " << event <<  endl;
+    cout << " runs found in the file : " << filenumber <<  endl;
+
+    Int_t startbinoff;
+    Float_t Nex, Non, Noff, Sign, SignLiMa;
+    Float_t normf, integon, integoff, NexOnOff, NoffOFF, SignOnOff, SignLiMaOnOff;
+    Float_t binwidth = histalphafinal.GetBinWidth(1);
+    Float_t numbinMax = ALPHAMAX/binwidth;
+ 
+// **********************************************************************  //
+/* fit parabel from 30 to 90 degrees   */
+    TF1 * fitbgpar = new TF1("fbgpar", "[0]*x*x + [1]", ALOFFMIN, ALOFFMAX);
+    fitbgpar->SetLineColor(2);
+
+    histalphafinal.Fit("fbgpar","WNR");
+
+    Double_t apar = fitbgpar->GetParameter(0);
+    Double_t bpar = fitbgpar->GetParameter(1);
+
+    TF1 * bgoff = new TF1("bgoffON", parabfunc, 0., 90., 3);
+    bgoff->SetParameters(apar, bpar, 1.);
+    bgoff->FixParameter(0, apar);
+    bgoff->FixParameter(1, bpar);
+    bgoff->FixParameter(2, 1.);
+    bgoff->SetLineColor(9);
+
+/* end of the fit parabel from 30 to 90 degrees*/
+// **********************************************************************  //
+
+
+
+    if (!tlist.PostProcess())
+      return;
+
+    
+    gStyle->SetOptStat(11);
+
+// calculate significance: DO NOT USE FIT FOR Non!!!
+    Non = 0.;
+    for(Int_t i=1; i<=numbinMax;i++) Non += histalphafinal.GetBinContent(i);
+
+    Noff = (1./3. * (fitbgpar->GetParameter(0)) * pow(ALPHAMAX,3.) +
+           (fitbgpar->GetParameter(1)) * ALPHAMAX) /  binwidth;
+    Nex = Non - Noff;
+
+    Sign = Nex / sqrt(Nex + 2.* Noff);
+ 
+    cout << " Non : " << Non << " Noff : " << Noff << " Nex : " << Nex << endl;
+    cout << " significance : " << Sign << " sigma" << endl;
+
+    SignLiMa = LiMa17(Non,Noff,1.);
+    cout << " significance Li and Ma (17): " << SignLiMa << " sigma" << endl;
+
+    Char_t stringsig[80];
+ 
+    sprintf(stringsig,"S = %.2f sigma", Sign);
+    sprintf(stringtriv1,"Signif:  S = %.2f sigma", Sign);
+    sprintf(stringlima,"Li&Ma 17: S = %.2f sigma", SignLiMa);
+    sprintf(stringNex,"N excess: Nex = %.d ", Nex);
+
+// **********************************************************************  //
+//  use OFF data to estimate background   *******************************  //
+    TF1 * bgoff2 = new TF1("bgoffOFF", parabfunc, 0., 90., 3);
+  if (USEOFFDATA == kTRUE)
+  {
+        // ON:
+
+           integon = 0.;  // number of events between 30 and 90 degrees
+	   numbinsoff = TMath::Nint((ALOFFMAX - ALOFFMIN)/binwidth);
+           startbinoff = TMath::Nint(ALOFFMIN/binwidth) + 1;
+
+           for (Int_t ik = 0; ik < numbinsoff; ik++)
+           {
+            integon += histalphafinal.GetBinContent(startbinoff+ik);  
+           }
+           // OFF:
+
+           integoff = ((1./3. * aparOff * pow(90.,3.) + bparOff * 90.) -
+                      (1./3. * aparOff * pow(30.,3.) + bparOff * 30.)) / binwidthOff;
+
+           normf = integoff / integon;
+
+           NoffOFF = (1./3. * aparOff * pow(ALPHAMAX,3.) +
+                   (bparOff * ALPHAMAX)) /  binwidthOff / normf;
+
+           NexOnOff = Non - NoffOFF;
+
+           SignOnOff = NexOnOff / sqrt(NexOnOff + 2.* NoffOFF);
+
+        // calculate according to Li Ma:
+           SignLiMaOnOff = LiMa17(Non,NoffOFF*normf,1./normf);
+
+cout << " integon: " << integon << ",  integoff : " <<  integoff << ", normf: " << normf
+     << ", NoffOFF : " << NoffOFF << ", Non : " << Non
+     << ", NexOnOff : " << NexOnOff << ", SignOnOff : " << SignOnOff << endl;
+ cout << " significance (LiMa 17): " << SignLiMaOnOff << " sigma" << endl;
+
+ sprintf(stringNexOnOff,"N excess (ON - OFF) = %.d ", NexOnOff);
+ sprintf(stringLiMaOnOff,"Signif (ON - OFF) = %.2f ", SignLiMaOnOff);
+
+
+            bgoff2->SetParameters(aparOff, bparOff, normf/binwidth*binwidthOff);
+            bgoff2->FixParameter(0, aparOff);
+            bgoff2->FixParameter(1, bparOff);
+            bgoff2->FixParameter(2, normf/binwidth*binwidthOff);
+            bgoff2->SetLineColor(2);
+
+   }
+
+/*
+      TCanvas canv("c1", "basic histograms", 600, 500);
+      canv.SetBorderMode(0);
+      canv.Divide(3,3);
+
+     canv.cd(1);
+     gPad->SetBorderMode(0);
+     histlength.Draw();
+
+     canv.cd(2);
+     gPad->SetBorderMode(0);
+     histwidth.Draw();
+  
+     canv.cd(3);
+     gPad->SetBorderMode(0);
+     gPad->SetLogx();
+     gPad->SetLogy();
+     histsize.Draw();
+
+     canv.cd(4);
+     gPad->SetBorderMode(0);
+     histalpha.Draw();
+
+     canv.cd(5);
+     gPad->SetBorderMode(0);
+     histdist.Draw();
+
+     canv.cd(6);
+     gPad->SetBorderMode(0);
+     histmeanx.Draw();
+
+     canv.cd(7);
+     gPad->SetBorderMode(0);
+     histmeany.Draw();
+
+     canv.cd(8);
+     gPad->SetBorderMode(0);
+     hist2xy.Draw();
+
+     canv.cd(9);
+     gPad->SetBorderMode(0);
+     histLoverS.Draw();
+
+     canv.Modified();
+     canv.Update();
+
+     canv.DrawClone();
+
+
+
+
+      TCanvas canvcor("c2", "correlation histograms", 600, 500);
+      canvcor.SetBorderMode(0);
+      canvcor.Divide(3,3);
+
+     canvcor.cd(1);
+     gPad->SetBorderMode(0);
+     hist2lw.Draw();
+
+     canvcor.cd(2);
+     gPad->SetBorderMode(0);
+     hist2lalpha.Draw();
+
+     canvcor.cd(3);
+     gPad->SetBorderMode(0);
+     hist2ldist.Draw();
+
+     canvcor.cd(4);
+     gPad->SetBorderMode(0);
+     hist2walpha.Draw();
+
+     canvcor.cd(5);
+     gPad->SetBorderMode(0);
+     hist2wdist.Draw();
+
+     canvcor.cd(6);
+     gPad->SetBorderMode(0);
+     hist2alphadist.Draw();
+
+     canvcor.cd(7);
+     gPad->SetBorderMode(0);
+     gPad->SetLogy();
+     hist2wsize.Draw();
+
+
+     canvcor.cd(8);
+     gPad->SetBorderMode(0);
+     gPad->SetLogy();
+     hist2alphasize.Draw();
+
+     canvcor.cd(9);
+     gPad->SetBorderMode(0);
+     gPad->SetLogy();
+     hist2distsize.Draw();
+
+
+     canvcor.Modified();
+     canvcor.Update();
+
+     canvcor.DrawClone();
+*/
+
+/**********************************************************/
+/* plot the alpha plot for the current sample */
+
+    Char_t titelname[80];
+    sprintf(titelname,"alpha plot. sample %d assumed source position: x = %.2f y = %.2f", num, XSOURCE, YSOURCE);
+
+
+      TCanvas canval("c3", "canvas for alpha", 600, 500);
+      canval.SetBorderMode(0);
+
+     gPad->SetBorderMode(0);
+     histalphafinal.SetMarkerStyle(20);
+     histalphafinal.SetTitle(titelname);
+     histalphafinal.SetFillColor(8);
+     histalphafinal.Draw();
+     bgoff->Draw("same");
+     if (USEOFFDATA == kTRUE) bgoff2->Draw("same");
+
+    leg = new TLegend(0.1,0.15,0.52,0.35);
+//    leg->Draw();
+    leg->AddEntry(fitbgpar,"fit for OFF region (30-90 deg)","l");
+    leg->SetHeader("Legend");
+    leg->SetFillColor(19);
+//    leg->Draw();
+
+    if (USEOFFDATA == kFALSE) 
+    {
+	    text = new TPaveText(0.53,0.45,0.9,0.65,"NDC");
+	    text->AddText(0.4, 0.6, stringNex);
+	    text->AddText(0.5, 0.3, stringlima);
+	    text->SetTextSize(0.032);
+	    text->Draw();
+    }
+    else
+    {
+            text = new TPaveText(0.53,0.25,0.9,0.55,"NDC");
+	    text->AddText(0.4, 0.8, stringNex);
+	    text->AddText(0.45, 0.6, stringlima);
+            text->AddText(0.5, 0.4, stringNexOnOff);
+            text->AddText(0.4, 0.2, stringLiMaOnOff);
+            text->SetTextSize(0.032);
+            text->Draw();
+    }
+     canval.Modified();
+     canval.Update();
+
+//     canval.DrawClone();
+
+     TString strin = dirname + sourcename;
+//     TString strin = "data/plots/alpha/dummySize";
+     strin += SIZEMIN;
+     strin += "Sample";
+     if (num<10) strin +="0";
+     strin += num;
+     strin += ".root";
+
+
+     canval.SaveAs(strin);  // please enable if you want to save alphaplots
+cout << " alpha plot for the sample " << num << " has been saved into " << strin << endl;
+
+     if(bgoff2) delete bgoff2;
+     delete bgoff;
+
+/**********************************************************/
+
+/*
+      TCanvas canvt("c4", "telescope", 600, 500);
+      canvt.SetBorderMode(0);
+      canvt.Divide(2,1);
+
+     canvt.cd(1);
+     gPad->SetBorderMode(0);
+     histphi.Draw();
+
+     canvt.cd(2);
+     gPad->SetBorderMode(0);
+     histtheta.Draw();
+
+     canvt.DrawClone();
+
+      TCanvas canvass("c5", "assymetry", 600, 500);
+      canvass.SetBorderMode(0);
+      canvass.Divide(2,1);
+
+     canvass.cd(1);
+     gPad->SetGridx();
+     gPad->SetGridy();
+     gPad->SetBorderMode(0);
+     histAssym.Draw();
+
+     canvass.cd(2);
+     gPad->SetGridx();
+     gPad->SetGridy();
+     gPad->SetBorderMode(0);
+     histAssymM3.Draw();
+
+     canvass.DrawClone();
+
+    TCanvas aftercutcanv("c1a", "basic histograms", 600, 500);
+    aftercutcanv.SetBorderMode(0);
+    aftercutcanv.Divide(3,3);
+
+    aftercutcanv.cd(1);
+    gPad->SetBorderMode(0);
+    gPad->SetGridx();
+    gPad->SetGridy();
+    aftercuthistlength.Draw();
+
+    aftercutcanv.cd(2);
+    gPad->SetBorderMode(0);
+    gPad->SetGridx();
+    gPad->SetGridy();
+    aftercuthistwidth.Draw();
+
+    aftercutcanv.cd(3);
+    gPad->SetBorderMode(0);
+    gPad->SetLogx();
+    gPad->SetLogy();
+    gPad->SetGridx();
+    gPad->SetGridy();
+    aftercuthistsize.Draw();
+
+    aftercutcanv.cd(4);
+    gPad->SetBorderMode(0);
+    gPad->SetGridx();
+    gPad->SetGridy();
+    aftercuthistalpha.Draw();
+
+    aftercutcanv.cd(5);
+    gPad->SetBorderMode(0);
+    gPad->SetGridx();
+    gPad->SetGridy();
+    aftercuthistdist.Draw();
+
+    aftercutcanv.cd(6);
+    gPad->SetBorderMode(0);
+    gPad->SetGridx();
+    gPad->SetGridy();
+    aftercuthistmeanx.Draw();
+
+    aftercutcanv.cd(7);
+    gPad->SetBorderMode(0);
+    gPad->SetGridx();
+    gPad->SetGridy();
+    aftercuthistmeany.Draw();
+
+
+    aftercutcanv.cd(8);
+    gPad->SetBorderMode(0);
+    gPad->SetGridx();
+    gPad->SetGridy();
+    aftercuthist2xy.Draw();
+
+    aftercutcanv.Modified();
+    aftercutcanv.Update();
+
+    aftercutcanv.DrawClone();
+*/
+    Double_t rat1, rat2;
+    rat1 = (double)AsGrNull / (double)AsLessNull;
+    rat2 = (double)AsGrNullAfter / (double)AsLessNullAfter;
+
+    cout << " Asymmetry M3 > 0 : " <<  AsGrNull << endl;
+    cout << " Asymmetry M3 < 0 : " <<  AsLessNull << endl;
+    cout << " Ratio (before cuts) : " <<  rat1 << endl;
+    cout << " Asymmetry M3 > 0 (after): " <<  AsGrNullAfter << endl;
+    cout << " Asymmetry M3 < 0 (after): " <<  AsLessNullAfter << endl;
+    cout << " Ratio (after cuts) : " <<  rat2 << endl;
+
+
+}
+
+void callalphaplot()
+{
+
+
+   Int_t num;
+   Double_t xpeakM, ypeakM, xpeakB, ypeakB;
+
+   FILE *fp;
+//   fp = fopen("data/trackMrk421_0505_2000.dat", "r");
+   if (USEFILE == kTRUE) 
+   {
+	fp = fopen("data/trackCrab1502_1305_Berlin_5deg.dat", "r");
+
+        for(Int_t i = 0; i < 2; i++)
+        {
+       		fscanf(fp,"%d %lf %lf %lf %lf", &num, &xpeakM, &ypeakM, &xpeakB, &ypeakB); 
+       		cout << endl << " SUBS NUMBER " << num << ", xpeakM = " << xpeakM << 
+                     ", ypeakM = " << ypeakM << endl;
+       		cout << "                   xpeakB = " << xpeakB << ", ypeakB = " << ypeakB << endl;
+       		if (num > 0 ) alphaplots(num, xpeakM, ypeakM);  
+   	}
+
+   	fclose(fp); 
+cout << "FERTIG" << endl;
+   }
+   else  
+     alphaplots(NUM, XSOUR, YSOUR);
+
+
+/**********************************************************/
+/* now calculate Nex and S for the overall alpha plot */:
+
+
+
+    TF1 * fitbgparAll = new TF1("fbgparA", "[0]*x*x + [1]", 30., 90.);
+    fitbgparAll->SetLineColor(2);
+    fitbgparAll->SetLineWidth(3);
+
+    histalphaAll.Fit("fbgparA","WR");
+
+    Double_t apar = fitbgparAll->GetParameter(0);
+    Double_t bpar = fitbgparAll->GetParameter(1);
+    Double_t normf = 1.;
+
+    TF1 * bgoff = new TF1("bgoff", parabfunc, 0., 90., 3);
+    bgoff->SetParameters(apar, bpar, normf);
+    bgoff->FixParameter(0, apar);
+    bgoff->FixParameter(1, bpar);
+    bgoff->FixParameter(2, normf);
+    bgoff->SetLineColor(8);
+
+// calc significance:
+    Double_t Sign, Non, Noff, Nex;
+    Double_t binwidth = histalphaAll.GetBinWidth(1);
+    Double_t numbinMax = ALPHAMAX / binwidth;
+
+    Non = 0.;
+    for(Int_t i=1; i<=numbinMax;i++) Non += histalphaAll.GetBinContent(i);
+
+//cout << histalphaAll.GetBinContent(1) + histalphaAll.GetBinContent(2) + 
+//        histalphaAll.GetBinContent(3) + histalphaAll.GetBinContent(4) << endl;
+    Noff = (1./3. * apar * pow(ALPHAMAX,3.) + bpar * ALPHAMAX)  /  binwidth;
+    Nex = Non - Noff;
+
+    Sign = LiMa17(Non,Noff,1.);
+
+    cout << " Non : " << Non << " Noff : " << Noff << " Nex : " << Nex << endl;
+    cout << " significance : " << Sign << " sigma" << endl;
+
+
+    Char_t stringsig[80], stringNex[80];
+
+    sprintf(stringsig,"Signif:  S = %.2f sigma", Sign);
+    sprintf(stringNex,"N excess: Nex = %.d ", Nex);
+/**********************************************************/
+
+
+//  plot all alpha plots together
+
+    TCanvas canvA("cA", "alphacanvas", 600, 500);
+    canvA.SetBorderMode(0);
+
+    gPad->SetBorderMode(0);
+    histalphaAll.SetXTitle("alpha [deg]");
+    histalphaAll.SetYTitle("Counts");
+    histalphaAll.SetMarkerStyle(20);
+    histalphaAll.SetFillColor(17);
+    histalphaAll.Draw();
+    bgoff->Draw("same");
+
+//    leg = new TLegend(0.1,0.15,0.52,0.35);
+//    leg->Draw();
+//    leg->AddEntry(fitbgpar,"fit for OFF region (30-90 deg)","l");
+//    leg->SetHeader("Legend");
+//    leg->SetFillColor(19);
+//    leg->Draw();
+
+     text = new TPaveText(0.53,0.45,0.9,0.65,"NDC");
+     text->AddText(0.4, 0.6, stringNex);
+     text->AddText(0.45, 0.3, stringsig);
+     text->SetTextSize(0.032);
+     text->Draw();
+
+     canvA.Modified();
+     canvA.Update();
+
+
+     Char_t xstr[20], ystr[20];
+     if (USEFILE == kTRUE) 
+     {
+	sprintf(xstr,"%3.2f",0.);
+	sprintf(ystr,"%3.2f",0.);
+     }
+     else
+     {
+	sprintf(xstr,"%3.2f",XSOUR);
+	sprintf(ystr,"%3.2f",YSOUR);
+     }
+
+
+     TString string = dirname + sourcename;
+     string += "X";
+     string += xstr;
+     string += "Y";
+     string += ystr;
+     string += "Size";
+     string += SIZEMIN;
+     string += "alpha";
+     string += TMath::Nint(ALPHAMAX);
+     string += ".root";
+
+     canvA.SaveAs(string);
+cout << " alpha plot has been saved into " << string << endl;
+
+}
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mmpi/macros/callcleaning.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mmpi/macros/callcleaning.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mmpi/macros/callcleaning.C	(revision 9661)
@@ -0,0 +1,56 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cherenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!   Author(s): Daniel Mazin, 05/2004 <mailto:mazin@imppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+// Daniel Mazin 14.05.2004  mazin@mppmu.mpg.de
+// **********************************************************************************
+// this macro is used to make an image cleaning and calculate the Hillas parameters
+// input:  calibrated data (one or more files using wild card)
+// output: hillas parameter
+// **********************************************************************************
+
+#include "cleaninghillas.C"
+void callcleaning()
+{
+  gROOT->Reset();
+
+  TString typeInput ="ON";  // -> please specify "ON" or "OFF"
+
+  const char *onfile="1*.ON";
+  const char *offfile="1*.OFF";
+
+
+  TString sourcename = "Crab";
+  TString inPath;  // directory where to find calibrated files
+  TString outPath; // directory where to write root-file with hillas parameters
+
+
+  inPath = "/.magic/magicserv01/scratch/David/CalibratedData/Crab/2004_01_27/";
+
+  outPath = "~mazin/data/Crab/2004_01_27/";
+
+  cleaninghillas(onfile, offfile, typeInput, inPath, outPath, sourcename);
+
+  cout << " finished, back from callcleaning " << endl;
+  cout << " Hillas file " << outPath << sourcename << "Hillas" << typeInput << ".root is created " << endl;
+
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/mmpi/macros/cleaninghillas.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mmpi/macros/cleaninghillas.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mmpi/macros/cleaninghillas.C	(revision 9661)
@@ -0,0 +1,232 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cherenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!   Author(s): Daniel Mazin, 05/2004 <mailto:mazin@imppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+// Daniel Mazin 14.05.2004  mazin@mppmu.mpg.de
+//**********************************************************
+// this macro is a short form of the macro ONOFFAnalysis.C
+// three jobs are executed:
+// 1)  image cleaning
+// 2)  calculation of hillas parameters
+// 3)  writing the root file
+//**********************************************************
+
+gROOT->Reset();
+
+//************************************************************************
+void cleaninghillas(const char *onfile, 
+                    const char *offfile, 
+                    TString typeInput, 
+                    TString inPath, 
+                    TString outPath,
+                    TString sourcename) 
+{
+
+    TString fileON  = inPath;
+    fileON += onfile;
+    fileON += ".root";
+
+    TString fileOFF = inPath;
+    fileOFF += offfile;
+    fileOFF += ".root";
+
+    // name of input root file
+    if (typeInput == "ON")
+      TString filenamein(fileON);
+    else if (typeInput == "OFF")
+      TString filenamein(fileOFF);
+
+    // name of output root file
+    if (typeInput == "ON")
+      TString file(onfile);
+    else if (typeInput == "OFF")
+      TString file(offfile);
+
+    TString outNameImage = outPath;
+    outNameImage += sourcename;
+    outNameImage += "Hillas";
+    outNameImage += typeInput;
+    outNameImage += ".root";
+
+
+    //  set up the task list:
+    //-----------------------------------------------------------
+    MTaskList tliston;
+    MParList pliston;
+
+    MObservatory observ;
+    pliston.AddToList(&observ);
+
+    MPointingPos mpos;
+    pliston.AddToList(&mpos);
+
+    MMcEvt mmc;
+    pliston.AddToList(&mmc);
+
+    char *sourceName = "MSrcPosCam";
+    MSrcPosCam source(sourceName);
+
+    // geometry is needed in  MHHillas... classes 
+    MGeomCam *fGeom = 
+             (MGeomCam*)pliston->FindCreateObj("MGeomCamMagic", "MGeomCam");
+
+    //-------------------------------------------
+    // create the tasks which should be executed 
+    //
+
+    MReadMarsFile read("Events", filenamein);
+    read.DisableAutoScheme();
+
+    MGeomApply        apply;
+
+ // NOTE: MMcEvt is used temporary. MPointingPos should be used as soon as synchronisation is working
+ //
+ // the following task is used to fill in a MMcEvt container with Theta and Phi values 
+ // for each event using an ascii file (which is generated from central control report file) 
+ // PLEASE NOTE: only needed if a derotation around the center of the camera is planned 
+ // to be performed afterwords
+    MSourcePosfromStarPos sourcefromstar;
+
+    if (typeInput == "ON")
+    {
+	    sourcefromstar.AddFile("~mazin/mars/MarsCVS/Mars/positionsON", 0);
+    }
+    else if (typeInput == "OFF")
+    {
+        sourcefromstar.AddFile("~mazin/mars/MarsCVS/Mars/positionsOFF", 0);
+    }
+
+
+
+// -----------------------------------------------------
+// image cleaning  -------------------------------------
+// -----------------------------------------------------    
+    MSigmabarCalc sigbar;
+
+    MBlindPixelsCalc2 blind;
+    blind.SetUseInterpolation();
+    blind.SetCheckPedestalRms();
+    blind.SetName("BlindAfterPadding");
+
+    MFSelBasic selbasic;
+    MContinue contbasic(&selbasic);
+    contbasic.SetName("SelBasic");
+
+//    MImgCleanStd    clean(3.0, 2.5);  // Crab 27th old calibr (Hendrik)
+    MImgCleanStd    clean(4.0, 3.0);
+//    clean.SetMethod(MImgCleanStd::kDemocratic);
+    clean.SetCleanRings(1); 
+
+
+// -----------------------------------------------------
+// calculation of  image parameters ---------------------
+// -----------------------------------------------------    
+    TString fHilName    = "MHillas";
+    TString fHilNameExt = "MHillasExt";
+    TString fHilNameSrc = "MHillasSrc";
+    TString fImgParName = "MNewImagePar";
+
+    MHillasCalc    hcalc;
+    hcalc.SetNameHillas(fHilName);
+    hcalc.SetNameHillasExt(fHilNameExt);
+    hcalc.SetNameNewImgPar(fImgParName);
+
+    MHillasSrcCalc hsrccalc(sourceName, fHilNameSrc);
+    hsrccalc.SetInput(fHilName);
+
+    MFSelStandard selstandard(fHilNameSrc);
+    selstandard.SetHillasName(fHilName);
+    selstandard.SetImgParName(fImgParName);
+//    selstandard.SetCuts(usedpixelsmax, corepixelsmin, sizemin, distmin, distmax, lengthmin, widthmin);
+    selstandard.SetCuts(200, 5, 200, 0.0, 5.0, 0.07, 0.05);
+    MContinue contstandard(&selstandard);
+    contstandard.SetName("SelStandard");
+
+// -----------------------------------------------------
+// write root file
+// -----------------------------------------------------    
+      MWriteRootFile write(outNameImage);
+
+      write.AddContainer("MRawRunHeader", "RunHeaders");
+      //write.AddContainer("MTime",         "Events");
+      write.AddContainer("MPointingPos",   "Events");
+      //write.AddContainer("ThetaOrig",     "Events");
+      write.AddContainer("MSrcPosCam",    "Events");
+      write.AddContainer("MSigmabar",     "Events");
+      write.AddContainer("MHillas",       "Events");
+      write.AddContainer("MHillasExt",    "Events");
+      write.AddContainer("MHillasSrc",    "Events");
+      write.AddContainer("MNewImagePar",  "Events");
+    
+
+    //*****************************
+    // entries in MParList
+    
+    pliston.AddToList(&tliston);
+    pliston.AddToList(&observ);
+
+    pliston.AddToList(&source);
+
+    //*****************************
+    // entries in MTaskList
+    
+
+    tliston.AddToList(&read);
+    tliston.AddToList(&apply);
+    tliston.AddToList(&sourcefromstar);
+
+
+    tliston.AddToList(&sigbar);
+    tliston.AddToList(&blind);
+    tliston.AddToList(&contbasic);
+
+    tliston.AddToList(&clean);
+
+    tliston.AddToList(&hcalc);
+    tliston.AddToList(&hsrccalc);
+    tliston.AddToList(&contstandard);
+    tliston.AddToList(&write);
+
+    //*****************************
+
+    //-------------------------------------------
+    // Execute event loop
+    //
+    MProgressBar bar;
+    MEvtLoop evtloop;
+    evtloop.SetParList(&pliston);
+    //evtloop.ReadEnv(env, "", printEnv);
+    evtloop.SetProgressBar(&bar);
+    //  evtloop.Write();
+
+    Int_t maxevents = -1;
+    //Int_t maxevents = 1000;
+    if ( !evtloop.Eventloop(maxevents) )
+        return;
+
+    tliston.PrintStatistics(0, kTRUE);
+
+
+}
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mmpi/macros/falsesourcemethod.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mmpi/macros/falsesourcemethod.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mmpi/macros/falsesourcemethod.C	(revision 9661)
@@ -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 Cherenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!   Author(s): Daniel Mazin, 05/2004 <mailto:mazin@imppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+
+// Daniel Mazin 14.05.2004  mazin@mppmu.mpg.de
+// **********************************************************************************
+// this macro is used to produce false source plots 
+// either using one sample only (usually used for OFF, set TYPEOPTION = kFALSE)
+// or in addition using the background estimation from OFF (set TYPEOPTION = kTRUE).
+// The later option can be used ONLY if false source method for the OFF data 
+// has taken place before.
+// input: hillas parameter file
+// output: several 2D plots in a root file + 
+// ascii file with parameters like significance, Nexcess etc.
+// **********************************************************************************
+
+
+// you may want to change these values:
+#define STEPGRID 0.05 //  [deg]
+#define MINXGRID -1.  //  [deg]
+#define MINYGRID -1.  //  [deg]
+#define MAXXGRID 1.   //  [deg]
+#define MAXYGRID 1.   //  [deg]
+
+#define ALPHAMAX 10.  // [deg], ON region in the alpha plot, maybe 5 deg is better
+                      // NOTE: up to now only values of 5, 10, 15, 20 degrees are possible
+
+// if you wish to rotate set to kTRUE, else kFALSE
+const Bool_t ROTOPTION = kFALSE; 
+const Bool_t TYPEOPTION = kFALSE; // kFALSE = estimate background from the same sample
+                                  // kTRUE  = estimate background also from OFF data
+const Bool_t CUTOPTION = kTRUE;  // kTRUE = dynamical cuts
+                                 // kFALSE = statical cuts
+
+/* ******************************************************   */
+      /*  static    cuts   */
+#define LENGTHMIN 0.10  // deg
+#define LENGTHMAX 0.32  // deg
+#define WIDTHMIN  0.06  // deg
+#define WIDTHMAX  0.15  // deg
+#define SIZEMIN   2000. // photons
+#define DISTMIN   0.6   // deg
+#define DISTMAX   1.3   // deg
+#define LEAKMAX   0.25  // deg
+/* ******************************************************   */
+
+/* ******************************************************   */
+      /*  dynamical cuts  Crab 27th Jan 2004 */
+#define LENGTHMINParA 0.136  // deg
+#define LENGTHMINParB 0.036  //
+#define LENGTHMINParC -0.0038  //
+#define LENGTHMAXParA 0.332  // deg
+#define LENGTHMAXParB 0.037  //
+#define LENGTHMAXParC 0.0261 //
+#define WIDTHMINParA  0.063  // deg
+#define WIDTHMINParB  0.013  //
+#define WIDTHMINParC  0.0003  //
+#define WIDTHMAXParA  0.123  // deg
+#define WIDTHMAXParB  0.019  //
+#define WIDTHMAXParC  0.0005 //
+#define DISTMINParA   0.6   // deg
+#define DISTMINParB   0.059  //
+#define DISTMINParC   0.  //
+#define DISTMAXParA   1.25   // deg
+#define DISTMAXParB   0.059  //
+#define DISTMAXParC   0.  //
+/* ******************************************************   */
+
+      /*  dynamical cuts  Mrk 421 and Crab 15th Feb 2004 */
+
+/*
+#define LENGTHMINParA 0.12  // deg
+#define LENGTHMINParB 0.034  //
+#define LENGTHMINParC 0.  //
+#define LENGTHMAXParA 0.32  // deg
+#define LENGTHMAXParB 0.034  //
+#define LENGTHMAXParC 0. //
+#define WIDTHMINParA  0.055  // deg
+#define WIDTHMINParB  0.013  //
+#define WIDTHMINParC  0.0  //
+#define WIDTHMAXParA  0.12  // deg
+#define WIDTHMAXParB  0.013  //
+#define WIDTHMAXParC  0.0 //
+#define DISTMINParA   0.6   // deg
+#define DISTMINParB   0.059  //
+#define DISTMINParC   0.  //
+#define DISTMAXParA   1.25   // deg
+#define DISTMAXParB   0.059  //
+#define DISTMAXParC   0.  //
+*/
+/* ******************************************************   */
+
+// please do not change these values:
+#define NUMSTEPS (int) ((MAXXGRID - MINXGRID) / STEPGRID + 1.5)
+#define GRIDBINS (int) (NUMSTEPS * NUMSTEPS  + 0.5)
+
+
+#include "mtools.C"
+#include <skyplot.h>  // needed histograms
+
+// this helps me to check if the binning is ok
+#define TOLERANCE 1e-3
+
+#include "hillasfileread.C"
+#include "gridloop.C"
+
+void falsesourcemethod()
+{
+
+  if (TYPEOPTION == kTRUE)  // output of OFF data sample
+//      DATPARAMIN = "data/ressignOffMrk3004.dat";  // 3000
+      DATPARAMIN = "paramOffCrab2701.dat";   // 2000
+
+
+   HILLASFILENAME = "~/data/Crab/2004_01_27/CrabHillasOFF.root";
+   DATPARAMOUT = "paramOffCrab2701.dat";
+   ROOTPLOTNAME = "/.magic/magicserv01/scratch/Daniel/plots/RootPlots/Crab/2004_01_27/CrabOffSkyPlots.root";
+   hillasfileread();
+   gridloop();  
+
+/*
+// use this loop for different subsamples
+  for(Int_t i=1; i<10; i++)
+  {
+   HILLASFILENAME = "~/data/Crab15022004Update/sample";
+   DATPARAMOUT = "data/ressignOnOffCrab1502Samp";
+   ROOTPLOTNAME = "/.magic/magicserv01/scratch/Daniel/plots/RootPlots/Crab15022004Update/Crab1502Sample";
+
+   HILLASFILENAME += i;
+   HILLASFILENAME += "/";
+   HILLASFILENAME += "CrabHillasON";
+   HILLASFILENAME += ".root";
+
+   DATPARAMOUT += i;
+   DATPARAMOUT += "_AlphaCut";
+   DATPARAMOUT += TMath::Nint(ALPHAMAX);
+   DATPARAMOUT += "deg";
+   DATPARAMOUT += ".dat";
+
+   ROOTPLOTNAME += i;
+   ROOTPLOTNAME += "_AlphaCut";
+   ROOTPLOTNAME += TMath::Nint(ALPHAMAX);
+   ROOTPLOTNAME += "deg";
+   ROOTPLOTNAME += ".root";
+
+
+   hillasfileread();
+   gridloop();  
+  }
+*/
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/mmpi/macros/findstars.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mmpi/macros/findstars.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mmpi/macros/findstars.C	(revision 9661)
@@ -0,0 +1,184 @@
+void ReadSetup(TString fname, MAstroCamera &cam)
+{
+    MMcConfigRunHeader *config=0;
+    MGeomCam           *geom=0;
+
+    TFile file(fname);
+    TTree *tree = (TTree*)file.Get("RunHeaders");
+    tree->SetBranchAddress("MMcConfigRunHeader", &config);
+    if (tree->GetBranch("MGeomCam"))
+        tree->SetBranchAddress("MGeomCam", &geom);
+    tree->GetEntry(0);
+
+    cam.SetMirrors(*config->GetMirrors());
+    cam.SetGeom(*geom);
+}
+
+void findstars(const TString filename="20040422_23213_D_Mrk421_E.root", const TString directory="/data/MAGIC/Period016/rootdata2/2004_04_22/", const UInt_t numEvents = 0)
+{
+
+  MParList  plist;
+  MTaskList tlist;
+  plist.AddToList(&tlist);
+
+  MGeomCamMagic geomcam;
+  MCameraDC     dccam;
+  MStarLocalCam starcam;
+
+  plist.AddToList(&geomcam);
+  plist.AddToList(&dccam);
+  plist.AddToList(&starcam);
+
+  // Reads the trees of the root file and the analysed branches
+  MReadReports read;
+  read.AddTree("Currents"); 
+  read.AddTree("Drive"); // If you do not include Drive info, the MFindStars class
+                         // will not use the star catalog method
+  read.AddFile(directory+filename); // after the reading of the trees!!!
+  read.AddToBranchList("MReportCurrents.*");
+  read.AddToBranchList("MReportDrive.*");
+
+  MGeomApply geomapl;
+  TString continuoslightfile =   
+     "/data/MAGIC/Period016/rootdata/2004_04_16/20040416_22368_P_Off3c279-2CL100_E.root";
+  Float_t mindc = 0.9; //[uA]
+
+  MCalibrateDC dccal;
+  dccal.SetFileName(continuoslightfile);
+  dccal.SetMinDCAllowed(mindc);
+
+  const Int_t numblind = 5;
+  const Short_t x[numblind] = { 47, 124, 470, 475, 571};
+  const TArrayS blindpixels(numblind,(Short_t*)x);
+  Float_t ringinterest = 100; //[mm]
+  Float_t tailcut = 2.5;
+  UInt_t integratedevents = 1;
+
+  // We need the MAGIC mirror geometry from a MC header:
+  TString geometryfile = "/mcdata/standard/camera/NSB_013/Gamma/Gamma_zbin9_90_7_1480to1489_w0.root";
+
+  // We need the Bright Star Catalog:
+  TString catalogfile = "/home/rwagner/bsc5.dat";
+
+  MFindStars findstars;
+  findstars.SetBlindPixels(blindpixels);
+  findstars.SetRingInterest(ringinterest);
+  findstars.SetDCTailCut(tailcut);
+  findstars.SetNumIntegratedEvents(integratedevents);
+  findstars.SetMinuitPrintOutLevel(-1);
+  findstars.SetGeometryFile(geometryfile);
+  findstars.SetBSCFile(catalogfile);
+  const Double_t ra  = MAstro::Hms2Rad(11, 4, 26);
+  const Double_t dec = MAstro::Dms2Rad(38, 12, 36);
+  findstars.SetRaDec(ra,dec);
+  findstars.SetLimMag(8);
+  findstars.SetRadiusFOV(1.5);
+
+  tlist.AddToList(&geomapl);
+  tlist.AddToList(&read);
+  tlist.AddToList(&dccal);
+  tlist.AddToList(&findstars, "Currents");
+  
+  // The following lines you only need if in addition you want to display
+  // independent MAstroCamera output
+  //
+  //  TString fname = "/mcdata/standard/camera/NSB_013/Gamma/Gamma_zbin9_90_7_1480to1489_w0.root";
+  //  MObservatory magic1;      
+  //  const Double_t ra  = MAstro::Hms2Rad(11, 4, 26); //Mkn421
+  //  const Double_t dec = MAstro::Dms2Rad(38, 12, 36);
+  //
+  //  MAstroCamera stars;        
+  //  ReadSetup(fname, stars); 
+  //  stars.SetLimMag(9);
+  //  stars.SetRadiusFOV(3);
+  //  stars.SetRaDec(ra, dec);
+  //  stars.ReadBSC("/home/rwagner/bsc5.dat");
+  //  stars.SetObservatory(magic1);
+
+  MEvtLoop evtloop;
+  evtloop.SetParList(&plist);
+     
+  if (!evtloop.PreProcess())
+    return;
+  
+  MHCamera display(geomcam);
+  display.SetPrettyPalette();
+  display.Draw();
+  gPad->cd(1);
+  starcam.Draw();
+  
+  UInt_t numevents=0;
+  
+  while (tlist.Process())
+    {
+      numevents++;
+      if (numevents%integratedevents==0)
+	{
+	  display.SetCamContent(findstars.GetDisplay());
+	  gPad->Modified();
+	  gPad->Update();	      
+        // This line prints the results:
+	// 	  starcam.Print();
+	// This is how to access the TList of stars:
+	// 	  TList* starlist = starcam.GetList();
+
+	// This is how to iterate over stars found:
+	// 	  TIter Next(starlist);
+	// 	  MStarLocalPos* star;
+	// 	  UInt_t starnum = 0;
+	// 	  cout << filename << " ";
+	// 	  cout << "Iterating over list" << endl;
+	// 	  while ((star=(MStarLocalPos*)Next())) 
+	// 	    {
+	// 	      cout << "star[" << starnum << "] ";
+	// 	      cout << star->GetMeanX() << " " 
+	// 		   << star->GetMeanY() << " ";
+	// 	      starnum++;
+	// 	    }
+	// 	  cout << endl;
+	
+	}//integratedevents
+
+      MTime time;
+      time.Set(2004, 4, 22, 21, 51, 15);
+      
+      //superimpose star picture
+      //       stars.SetTime(time);
+      //       TObject *o = stars.Clone();
+      //       o->SetBit(kCanDelete);
+      //       o->Draw();
+      
+      if (!HandleInput())
+        break;
+
+    }
+
+  evtloop.PostProcess();
+    
+  tlist.PrintStatistics();
+
+}
+
+
+Bool_t HandleInput()
+{
+    TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
+
+    while (1)
+    {
+        //
+        // While reading the input process gui events asynchronously
+        //
+        timer.TurnOn();
+        TString input = Getline("Type 'q' to exit, <return> to go on: ");
+        timer.TurnOff();
+
+        if (input=="q\n")
+            return kFALSE;
+
+        if (input=="\n")
+            return kTRUE;
+    };
+
+    return kFALSE;
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/mmpi/macros/gridloop.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mmpi/macros/gridloop.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mmpi/macros/gridloop.C	(revision 9661)
@@ -0,0 +1,441 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cherenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!   Author(s): Daniel Mazin, 05/2004 <mailto:mazin@imppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+// Daniel Mazin 17.05.2004  mazin@mppmu.mpg.de
+// **********************************************************************************
+// this macro is used to produce false source plots
+// and it is a part from the macro falsesourcemethod.C.
+// See falsesourcemethod.C for more explanation
+// input: hillas parameters as vectors
+// output: several 2D plots in a root file +
+// ascii file with parameters like significance, Nexcess etc.
+// **********************************************************************************
+
+
+void gridloop()
+{
+
+    printf("inside of gridloop() ... \n");
+
+/* emty histograms  */
+
+    histskyplot.Reset();
+    histNexOnOff.Reset();
+    histChi2Off.Reset();
+    histskyplotOnOff.Reset();
+    histNex.Reset();
+    histChi2.Reset();
+    histskyplot4.Reset();
+    histskyLiMa.Reset();
+    histsign.Reset();
+    histsign4.Reset();
+    histBerlin.Reset();
+
+/* end emty histograms  */
+
+
+    TH1F histalphagrid;
+    histalphagrid.SetName("Alpha");
+    histalphagrid.SetTitle("Alpha");
+    histalphagrid.SetXTitle("Alpha (deg)");
+    histalphagrid.SetYTitle("Counts");
+    histalphagrid.SetDirectory(NULL);
+    histalphagrid.SetFillStyle(4000);
+    histalphagrid.UseCurrentStyle();
+  
+    bins.SetEdges(18, 0.0, 90.);
+    bins.Apply(histalphagrid);
+
+    Double_t xcorr, ycorr, xtest, ytest, xtilde, ytilde, fconc1;
+
+    const Float_t binwidth1 = histalphagrid.GetBinWidth(1);
+    if (TMath::Abs( ALPHAMAX/binwidth1 - TMath::Nint(ALPHAMAX/binwidth1)) > TOLERANCE)
+    {
+         cout << "wrong binning for histogram: histalphagrid \n SORRY ... ABORT" << endl;
+         exit(1);
+    }
+    const Int_t numbbinOnMax = TMath::Nint(ALPHAMAX / binwidth1);  // number bins in ON region
+
+  /*   fit functions  */
+    TF1 * fitsig = new TF1("fsig", "[0]", 0., ALPHAMAX);
+    fitsig->SetLineColor(4); 
+    TF1 * fitbgpar = new TF1("fbgpar", "[0]*x*x + [1]", 30., 90.);
+    fitbgpar->SetLineColor(2); 
+
+    TF1 * fitbg4 = new TF1("fbg4", "[0]*x*x*x*x + [1]*x*x + [2]", 30., 90.);
+    fitbg4->SetLineColor(3);
+  /*   end fit functions  */
+
+    Float_t Nex, Non, Noff, Sign;
+    Float_t xsource, ysource, xsournew, ysournew;
+
+    Double_t Nex4, Noff4, Sign4; 
+    Double_t alpha, SignLiMa;
+ 
+    Double_t chisquarefit;
+
+    Double_t integon, integoff, normf, NoffOFF, SignOnOff, NexOnOff;
+    Float_t logsize, lgsize, lgsize2, tanbeta, beta;
+    const Float_t LOG3000 = log(3000.);
+
+
+
+    Double_t chi2par[GRIDBINS], apar[GRIDBINS], bpar[GRIDBINS]; // fit parameters from OFF sample
+    Float_t offbin1[GRIDBINS], offbin2[GRIDBINS], offbin3[GRIDBINS]; // Number of events in first 3 bins
+    Double_t xpos, ypos, binwidth2;
+    Int_t  numgrid;
+
+
+    Int_t numbinsoff = 12;  // FIXME: 12 should be changed according to the binning
+    Int_t nbinx, nbiny, gridpoint = 0;
+
+    Char_t psname[120], titelname[120], plot1name[120], plot2name[120], stringsig[120];
+ 
+    FILE * fp;
+
+    if (TYPEOPTION == kTRUE)  // read fit parameters from the OFF sample
+    {
+      Char_t * datin = DATPARAMIN;
+              
+      fp = fopen(datin, "r");
+
+      for (Int_t i=0; i<GRIDBINS; i++)
+      {
+        fscanf(fp,"%d %lf %lf %lf %lf %lf %lf %f %f %f",
+                 &numgrid, &xpos, &ypos,  &apar[i], &bpar[i], 
+                 &chi2par[i], &binwidth2,
+                 &offbin1[i], &offbin2[i], &offbin3[i]);
+//  cout << "numgrid: " << numgrid << ",  apar " << apar[i] << endl;
+      }
+
+       fclose(fp);
+    }
+
+
+    Char_t * chout = DATPARAMOUT;  // write parameters into file
+
+    fp = fopen(chout, "w");
+
+
+/* begin of the loop over all bins in the sky map */
+
+   for(Int_t gridx = 0; gridx < NUMSTEPS; gridx++)   
+   { 
+    xsource = MINXGRID + gridx * STEPGRID;
+//cout << xsource << endl;
+
+    for(Int_t gridy = 0; gridy < NUMSTEPS; gridy++)  
+    {
+      ysource = MINYGRID + gridy * STEPGRID;
+//cout << ysource << endl;
+    
+// empty histogram:
+//     nbinx = histalphagrid.GetNbinsX();
+//     for(Int_t ii = 0; ii< (nbinx+1); ii++) histalphagrid.SetBinContent(ii, 0.);
+//     histalphagrid.SetEntries(0);
+     histalphagrid.Reset();
+
+
+//      Bool_t anglephi = kFALSE;
+
+    /* loop over all events */
+      for(Int_t k=0; k< imnum; k++)
+      {
+
+          if (ROTOPTION == kTRUE) // derotate into sky coordinates
+          {
+      /*     derotation    : correct sky coordinates into camera coordinates */
+             xsournew = cosgam(k) * xsource - singam(k) * ysource;
+             ysournew = singam(k) * xsource + cosgam(k) * ysource;
+       /*    end derotatiom    */
+          }
+          else // do not derotate, plot into camera coordinates
+          {
+             xsournew = xsource;
+             ysournew = ysource;
+          }
+
+
+       /* calculate ALPHA und DIST acording to the source position */
+           tanbeta = (ypar(k) - ysournew) / (xpar(k) - xsournew);
+           beta = TMath::ATan(tanbeta);
+           alphapar(k) = (deltapar(k) - beta) * 180./ TMath::Pi();
+           distpar(k) = sqrt((ypar(k) - ysournew) * (ypar(k) - ysournew) +
+                             (xpar(k) - xsournew) * (xpar(k) - xsournew));
+
+
+
+          if(alphapar(k) > 90.) alphapar(k) -= 180.;
+          if(alphapar(k) < -90.) alphapar(k) += 180.;
+
+//          histalpha.Fill(alphapar(k),1.);
+//          histdist.Fill( distpar(k),1.);
+
+          if(CUTOPTION==kFALSE)
+          { 
+/* ******************************************************   */
+      /*   static   cuts   */
+                if (lengthpar(k) > LENGTHMIN && lengthpar(k) < LENGTHMAX)
+                if (widthpar(k) > WIDTHMIN && widthpar(k) < WIDTHMAX)
+                if (sizepar(k) > SIZEMIN)
+                if (distpar(k) > DISTMIN && distpar(k) < DISTMAX)
+                if (leak1(k) < LEAKMAX)
+/* ******************************************************   */
+                     {
+                         alphapar(k) = TMath::Abs(alphapar(k));
+//printf("alpha passed the cuts: %5.2f \n", alphapar(k));
+//printf("histalphagrid:  %5.2f \n", histalphagrid.GetNbinsX());
+                         histalphagrid.Fill(alphapar(k),1.);
+
+                     }
+
+           }
+/* ******************************************************   */
+/*            dynamical cuts                                */
+           else     // if(CUTOPTION==kTRUE)
+           {
+                 logsize = log(sizepar(k));
+                 lgsize = logsize-LOG3000;
+                 lgsize2 = lgsize*lgsize;
+                 if ( sizepar(k) > SIZEMIN )
+                 if ( leak1(k) < LEAKMAX )
+                 if ( lengthpar(k) > (LENGTHMINParA + LENGTHMINParB*lgsize + LENGTHMINParC*lgsize2) &&
+                      lengthpar(k) < (LENGTHMAXParA + LENGTHMAXParB*lgsize + LENGTHMAXParC*lgsize2))
+                 if ( widthpar(k) > (WIDTHMINParA + WIDTHMINParB*lgsize + WIDTHMINParC*lgsize2)  &&
+                      widthpar(k) < (WIDTHMAXParA + WIDTHMAXParB*lgsize + WIDTHMAXParC*lgsize2) )
+                 if ( distpar(k) > (DISTMINParA + DISTMINParB*lgsize + DISTMINParC*lgsize2)  &&
+                      distpar(k) < (DISTMAXParA + DISTMAXParB*lgsize + DISTMAXParC*lgsize2) )
+                 {
+                         alphapar(k) = TMath::Abs(alphapar(k));
+                         histalphagrid.Fill(alphapar(k),1.);
+                         if(alphapar(k) < 8.)   histBerlin.Fill(xsournew, ysournew);
+                 }
+           }
+         
+        }
+//    histalphagrid.Fit("fsig","NR");
+//printf("content bin 1: %4.2f\n", histalphagrid.GetBinContent(1));
+    histalphagrid.Fit(fitsig,"NWR");
+    histalphagrid.Fit("fbg4","+NWR");
+    histalphagrid.Fit("fbgpar","+NWR");
+
+// cout << "OK" << endl;
+// calculate significance:
+    Non = 0.;
+    for(Int_t i=1; i<=numbbinOnMax;i++) Non += histalphagrid.GetBinContent(i);
+//    Non = (fitsig->GetParameter(0)) * numbbinOnMax;
+//cout << "Non : " << Non << endl;
+//    histalphagrid.Draw();
+
+    chisquarefit = fitbgpar->GetChisquare(); 
+    Noff = (1./3. * (fitbgpar->GetParameter(0)) * pow(ALPHAMAX,3.) + 
+           (fitbgpar->GetParameter(1)) * ALPHAMAX) /  binwidth1;
+    
+//cout << "Noff : " << Noff << endl;
+    
+    Nex = Non - Noff;
+
+    Noff4 = (1./5. * fitbg4->GetParameter(0) *  pow(ALPHAMAX,5.) +
+            1./3. * (fitbg4->GetParameter(1)) * pow(ALPHAMAX,3.) +
+           fitbg4->GetParameter(2) * ALPHAMAX ) / binwidth1;
+ 
+//cout << "Noff4 : " << Noff4 << endl;
+ 
+    Nex4 = Non - Noff4;
+ 
+// calculate significance: 
+
+//    Sign4 = Nex4 / sqrt(Nex4 + 2.* Noff4);
+    if (Noff4<0.) Sign4 = 0.;
+    else Sign4 = LiMa17(Non,Noff4,1.);
+
+//cout << "Sign4 : " << Sign4 << endl;
+//    Sign = Nex / sqrt(Nex + 2.* Noff);
+    if (Noff<0.) Sign = 0.;
+    else Sign = LiMa17(Non,Noff,1.);
+//cout << "Sign LiMa : " << Sign << endl;
+
+   /*  calculate Noff from the OFF data  */
+  if (TYPEOPTION == kTRUE)
+  {
+   	// ON: 
+
+   	integon = 0.;  // number of events between 30 and 90 degrees
+
+	   for (Int_t ik = 0; ik < numbinsoff; ik++)
+	   {
+	    integon += histalphagrid.GetBinContent(7+ik);  // FIXME: 7 should be changed according to the binning
+	   }
+	   // OFF: 
+
+	   integoff = ((1./3. * apar[gridpoint] * pow(90.,3.) + bpar[gridpoint] * 90.) -
+        	      (1./3. * apar[gridpoint] * pow(30.,3.) + bpar[gridpoint] * 30.)) / binwidth2;
+	
+	   normf = integoff / integon;
+
+	   NoffOFF = (1./3. * apar[gridpoint] * pow(ALPHAMAX,3.) +
+        	   (bpar[gridpoint] * ALPHAMAX)) /  binwidth2 / normf;
+
+	   NexOnOff = Non - NoffOFF;
+
+  	   SignOnOff = NexOnOff / sqrt(NexOnOff + 2.* NoffOFF);
+
+	// calculate according to Li Ma:
+           if (NoffOFF<0.) SignLiMa=0.;
+	   else SignLiMa = LiMa17(Non,NoffOFF*normf,1./normf);
+
+   }
+
+    cout << endl << "   xsource: " << xsource <<  "   ysource: " << ysource << endl;
+
+    cout << " Non : " << Non << " Noff : " << Noff << " Nex : " << Nex << endl;
+
+ if (TYPEOPTION == kTRUE) 
+    cout << " ON and OFF : Non : " << Non << " Noff (estimated) : " << NoffOFF << " Nex : " << NexOnOff << endl;
+
+    cout << endl;
+    cout << " significance (parab): " << Sign << " sigma" << endl;
+    cout << " significance (4th order): " << Sign4 << " sigma" << endl;
+ if (TYPEOPTION == kTRUE)
+  {
+    cout << " significance (using ON and OFF): " << SignOnOff << " sigma" << endl;
+    cout << " significance (LiMa 17): " << SignLiMa << " sigma" << endl;
+  }
+
+
+    if (TYPEOPTION == kTRUE)
+      fprintf(fp,"%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf \n", 
+                xsource, ysource, Sign, Non, Noff, Nex, SignLiMa, 
+                SignOnOff, NoffOFF, NexOnOff, chi2par[gridpoint]);
+    else 
+         fprintf(fp,"%d %lf %lf %lf %lf %lf %lf %lf %lf %lf\n",
+            gridpoint+1, xsource, ysource,
+            fitbgpar->GetParameter(0), fitbgpar->GetParameter(1),
+            fitbgpar->GetChisquare(), histalphagrid.GetBinWidth(1),
+            histalphagrid.GetBinContent(1), histalphagrid.GetBinContent(2),
+            histalphagrid.GetBinContent(3));
+
+
+    histskyplot.SetBinContent(gridx+1, gridy+1, Sign);
+    histNex.SetBinContent(gridx+1, gridy+1, Nex);
+    histChi2.SetBinContent(gridx+1, gridy+1, fitbgpar->GetChisquare() / 10.);
+
+    if (TYPEOPTION == kTRUE) histskyplotOnOff.SetBinContent(gridx+1, gridy+1, SignOnOff);
+    if (TYPEOPTION == kTRUE) histNexOnOff.SetBinContent(gridx+1, gridy+1, NexOnOff);
+    if (TYPEOPTION == kTRUE) histChi2Off.SetBinContent(gridx+1, gridy+1, chi2par[gridpoint] / 16.);
+
+    if (TYPEOPTION == kTRUE) histskyLiMa.SetBinContent(gridx+1, gridy+1, SignLiMa);
+    histskyplot4.SetBinContent(gridx+1, gridy+1, Sign4);
+    histsign.Fill(Sign,1.);
+    histsign4.Fill(Sign4,1.);
+//    break;
+
+    if (TYPEOPTION == kTRUE)
+    {
+	    TF1 * bgoff = new TF1("bgoff", parabfunc, 0., 90., 3);
+	    bgoff->SetParameters(apar[gridpoint], bpar[gridpoint], normf);
+	    bgoff->FixParameter(0, apar[gridpoint]);
+	    bgoff->FixParameter(1, bpar[gridpoint]);
+	    bgoff->FixParameter(2, normf);
+	    bgoff->SetLineColor(8);
+    }
+
+//    sprintf(stringsig,"S = %.2f sigma", Sign);
+    if (TYPEOPTION == kTRUE) sprintf(stringsig,"S = %.2f sigma", SignOnOff);
+/*
+    sprintf(psname,"/.magic/magicserv01/scratch/Daniel/plots/RootPlots/040215Mrk421_misp/all/alphaX%.2fY%.2fON.root", xsource, ysource);
+    sprintf(titelname,"alpha plot. assumed source position: x = %.2f y = %.2f", xsource, ysource);
+    TCanvas * cplot  = new TCanvas();
+    histalphagrid.SetTitle(titelname);
+    histalphagrid.Draw();
+    bgoff->Draw("same");
+    leg = new TLegend(0.1,0.15,0.52,0.35);
+    leg->Draw();
+    leg->AddEntry(fitsig,"fit for ON region (0-20 deg)","l");
+    leg->AddEntry(fitbgpar,"fit for OFF region (30-90 deg)","l");
+    leg->AddEntry(bgoff,"fit from OFF data (0-90 deg)","l");
+    leg->SetHeader("Legend");
+    leg->SetFillColor(19);
+    leg->Draw();
+
+    text = new TPaveText(50,20,90,80);
+    text->AddText(0.5, 0.8, "calculated significance");
+    text->AddText(0.5, 0.5, "using ON and OFF:");
+    text->AddText(1, 0.2, stringsig);
+    text->SetTextSize(0.04);
+    text->Draw();
+
+    cplot->Modified();
+    cplot->Update();
+
+    cplot->SaveAs(psname);
+    delete cplot;
+*/
+    if (TYPEOPTION == kTRUE) delete  bgoff;
+
+    gridpoint++;
+
+    }
+   }
+
+  /* close file  */
+    fclose(fp);  
+    
+
+    TFile rootfile(ROOTPLOTNAME, "RECREATE",
+                   "sky plots in all variations");
+
+
+//    cout << " end of one of the grids 1 " << endl;
+
+     histskyplot.Write();
+
+     histNex.Write();
+
+     histChi2.Write();
+
+     histsign.Write();
+
+     histskyplot4.Write();
+
+     histsign4.Write();
+
+     histBerlin.Write();
+
+   if (TYPEOPTION == kTRUE)
+   {
+     histNexOnOff.Write();
+     histChi2Off.Write();
+     histskyplotOnOff.Write();
+     histskyLiMa.Write();
+    }
+
+   rootfile.Close();
+
+   delete fitsig;
+   delete fitbgpar;
+   delete fitbg4;
+
+  cout << " end of one of the grids " << endl;
+}
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mmpi/macros/hillasfileread.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mmpi/macros/hillasfileread.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mmpi/macros/hillasfileread.C	(revision 9661)
@@ -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 Cherenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!   Author(s): Daniel Mazin, 05/2004 <mailto:mazin@imppmu.mpg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+// Daniel Mazin 17.05.2004  mazin@mppmu.mpg.de
+// **********************************************************************************
+// this macro is a part from the macro falsesourcemethod.C
+// This macro reads mars file with hillas parameters etc. and puts the values into vectors
+// input: hillas parameter file
+// output: vectors with the same information
+// **********************************************************************************
+
+
+void hillasfileread()
+{
+   lengthpar.ResizeTo(MAXNUMEVENTS);
+   widthpar.ResizeTo(MAXNUMEVENTS);
+   sizepar.ResizeTo(MAXNUMEVENTS);
+   xpar.ResizeTo(MAXNUMEVENTS);
+   ypar.ResizeTo(MAXNUMEVENTS);
+   deltapar.ResizeTo(MAXNUMEVENTS);
+   alphapar.ResizeTo(MAXNUMEVENTS);
+   distpar.ResizeTo(MAXNUMEVENTS);
+   cosgam.ResizeTo(MAXNUMEVENTS);
+   singam.ResizeTo(MAXNUMEVENTS);
+   conc1.ResizeTo(MAXNUMEVENTS);
+   leak1.ResizeTo(MAXNUMEVENTS);
+
+   lengthpar.Zero();
+   widthpar.Zero();
+   sizepar.Zero();
+   xpar.Zero();
+   ypar.Zero();
+   deltapar.Zero();
+   alphapar.Zero();
+   distpar.Zero();
+   cosgam.Zero();
+   singam.Zero();
+   conc1.Zero();
+   leak1.Zero();
+
+    MParList  plist;
+
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    //
+    // Now setup the tasks and tasklist:
+    // ---------------------------------
+    //
+    
+
+    MReadMarsFile read("Events");
+    read.DisableAutoScheme();
+
+    read.AddFile(HILLASFILENAME);
+
+    MHillas mhillas;
+    plist.AddToList(&mhillas);
+
+    MHillasSrc mhillassrc;
+    plist.AddToList(&mhillassrc);
+
+    MNewImagePar mnewimpar;
+    plist.AddToList(&mnewimpar);
+
+    MGeomCamMagic cam;
+    plist.AddToList(&cam);
+ 
+    MMcEvt mcevt;
+    plist.AddToList(&mcevt); 
+
+    MPointingPos mpoint;
+    plist.AddToList(&mpoint); 
+
+    MObservatory observ;
+    plist.AddToList(&observ);
+
+    MHStarMap starmap;
+    plist.AddToList(&starmap);
+
+//    MRawRunHeader header;
+//    plist.AddToList(&header);
+    
+    tlist.AddToList(&read);
+   
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    Float_t fMm2Deg;
+
+cout << " file name: " << HILLASFILENAME << endl;
+
+   if (!tlist.PreProcess(&plist))
+      return;
+
+    fMm2Deg = cam->GetConvMm2Deg();
+    Int_t event = 0;
+    Int_t filenumber = 0;
+    Float_t theta, phi;
+ 
+    imnum = 0;
+
+    while (tlist.Process())
+    {
+    event++;
+//cout << event << endl;
+
+    if (mhillas->GetLength() != -1.)
+     {
+
+
+     if (ROTOPTION == kTRUE) 
+     {
+//        theta = mcevt->GetTelescopeTheta();
+        theta = mpoint->GetZd();
+//        phi = mcevt->GetTelescopePhi();
+        phi = mpoint->GetAz();
+//   printf("theta: %5.3f, phi: %5.3f\n", theta*180./4.1415, phi*180./4.1415);
+        observ.RotationAngle(theta, phi, singam(imnum), cosgam(imnum)); 
+     }
+
+      lengthpar(imnum) = (mhillas->GetLength()) * fMm2Deg;
+      widthpar(imnum) = (mhillas->GetWidth())*fMm2Deg;
+      sizepar(imnum) = mhillas->GetSize();
+      xpar(imnum) = (mhillas->GetMeanX())*fMm2Deg;
+      ypar(imnum) = (mhillas->GetMeanY())*fMm2Deg;
+      deltapar(imnum) = mhillas->GetDelta(); 
+      conc1(imnum) = (mnewimpar->GetConc1());
+      leak1(imnum) = mnewimpar->GetLeakage1();
+
+      imnum++;
+
+     }
+    else filenumber++;
+    }
+
+    if (!tlist.PostProcess())
+      return;
+
+   printf("imnum = %d\n",imnum);
+
+   lengthpar.ResizeTo(imnum);
+   widthpar.ResizeTo(imnum);
+   sizepar.ResizeTo(imnum);
+   xpar.ResizeTo(imnum);
+   ypar.ResizeTo(imnum);
+   deltapar.ResizeTo(imnum);
+   alphapar.ResizeTo(imnum);
+   distpar.ResizeTo(imnum); 
+   cosgam.ResizeTo(imnum); 
+   singam.ResizeTo(imnum); 
+   conc1.ResizeTo(imnum); 
+   leak1.ResizeTo(imnum); 
+
+
+    cout << " conversion factor is: " << fMm2Deg <<  endl;
+    cout << " events read in from file : " << event <<  endl;
+    cout << " runs found in the file : " << filenumber <<  endl;
+
+}
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mmpi/macros/mtools.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mmpi/macros/mtools.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mmpi/macros/mtools.C	(revision 9661)
@@ -0,0 +1,19 @@
+Double_t LiMa17(Double_t Non, Double_t Noff, Double_t alpha)
+{
+  Double_t term1, term2, signif;
+  term1 = ((1.+alpha) / alpha) * (Non / (Non + Noff));
+  term2 = (1.+alpha) * (Noff / (Non + Noff));
+
+  signif = sqrt(2.* (Non*log(term1) + Noff*log(term2)));
+
+  if (Non>(alpha*Noff)) return signif;
+  else return -signif;
+
+}
+
+Double_t parabfunc(Double_t *x, Double_t *par)
+{
+   Double_t result=0.;
+   if (par[2]!=0)   result = (par[0] * x[0] * x[0] + par[1]) / par[2];
+   return result;
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/mmpi/macros/skyplot.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mmpi/macros/skyplot.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mmpi/macros/skyplot.h	(revision 9661)
@@ -0,0 +1,201 @@
+// temporal solution:
+#define MAXNUMEVENTS 500000
+#define LOG3000      log(3000.)
+
+TString HILLASFILENAME;
+TString DATPARAMIN;
+TString DATPARAMOUT;
+TString ROOTPLOTNAME;
+Int_t imnum = 0;
+
+TVectorD lengthpar(MAXNUMEVENTS);
+TVectorD widthpar(MAXNUMEVENTS);
+TVectorD distpar(MAXNUMEVENTS);
+TVectorD alphapar(MAXNUMEVENTS);
+TVectorD sizepar(MAXNUMEVENTS);
+TVectorD deltapar(MAXNUMEVENTS);
+TVectorD xpar(MAXNUMEVENTS);
+TVectorD ypar(MAXNUMEVENTS);
+TVectorD conc1(MAXNUMEVENTS);
+TVectorD leak1(MAXNUMEVENTS);
+TVectorD cosgam(MAXNUMEVENTS);
+TVectorD singam(MAXNUMEVENTS);
+
+// the alpha histogram
+MBinning bins;
+
+//TH1F histalphagrid;
+//histalphagrid.SetName("Alpha");
+//histalphagrid.SetTitle("Alpha");
+//histalphagrid.SetXTitle("Alpha [deg]");
+//histalphagrid.SetYTitle("Counts");
+//histalphagrid.SetDirectory(NULL);
+//histalphagrid.SetFillStyle(4000);
+//histalphagrid.UseCurrentStyle(); 
+
+bins.SetEdges(18, 0.0, 90.);
+bins.Apply(histalphagrid);
+
+
+
+// possible histograms:
+TH1F histlength;
+TH1F histwidth;
+TH1F histsize;
+TH1F histalpha;
+TH1F histdist;
+TH1F histmeanx;
+TH1F histmeany;
+TH1F histalphafinal;
+
+TH2F hist2xy("CoG1","Center of Gravity", 100, -1.8, 1.8, 100, -1.8, 1.8);
+TH1F histLoverS;
+TH1F aftercuthistlength;
+TH1F aftercuthistwidth;
+TH1F aftercuthistsize;
+TH1F aftercuthistalpha;
+TH1F aftercuthistdist;
+TH1F aftercuthistmeanx;
+TH1F aftercuthistmeany;
+TH2F aftercuthist2xy("CoG2","Center of Gravity", 100, -1.8, 1.8, 100, -1.8, 1.8);
+TH2F hist2lw("Length-Width", "correlation Length-Width", 100, 0.0, 1.0, 100, 0.0, 0.5);
+TH2F hist2lalpha("Length-Alpha", "correlation Length-Alpha", 100, 0.0, 1.0, 100, -100., 100.);
+TH2F hist2ldist("Length-Dist","correlation Length-Dist", 100, 0.0, 1.0, 100, 0.0, 1.6);
+TH2F hist2walpha("Width-Alpha","correlation Width-Alpha", 100, 0.0, 0.5, 100, -100., 100.);
+TH2F hist2wdist("Width-Dist","correlation Width-Dist", 100, 0.0, 0.5, 100, 0.0, 1.6);
+TH2F hist2alphadist("Alpha-Dist","correlation Alpha-Dist", 100, -100., 100, 100, 0.2, 1.4);
+
+
+TH2F histskyplot("SPSignif2ndOrder","Sky Plot of significance (2nd order fit)", 
+                 NUMSTEPS, MINXGRID - 0.5*STEPGRID, MAXXGRID + 0.5*STEPGRID,
+                 NUMSTEPS, MINYGRID - 0.5*STEPGRID, MAXYGRID + 0.5*STEPGRID);
+//histskyplot.SetXTitle("-RA [deg]");
+//histskyplot.SetYTitle("DEC [deg]");
+histskyplot.SetDirectory(NULL);
+histskyplot.SetFillStyle(4000);
+histskyplot.UseCurrentStyle();
+
+TH2F histNexOnOff("SPNexOnOff","Sky Plot of Number of excess events (using ON and OFF data)", 
+                 NUMSTEPS, MINXGRID - 0.5*STEPGRID, MAXXGRID + 0.5*STEPGRID,
+                 NUMSTEPS, MINYGRID - 0.5*STEPGRID, MAXYGRID + 0.5*STEPGRID);
+//histNexOnOff.SetXTitle("-RA [deg]");
+//histNexOnOff.SetYTitle("DEC [deg]");
+histNexOnOff.SetDirectory(NULL);
+histNexOnOff.SetFillStyle(4000);
+histNexOnOff.UseCurrentStyle();
+
+TH2F histChi2Off("SPChi2PerNdf2ndOrderOff","Sky Plot of Chi2/ndf (2nd order fit, OFF data)", 
+                 NUMSTEPS, MINXGRID - 0.5*STEPGRID, MAXXGRID + 0.5*STEPGRID,
+                 NUMSTEPS, MINYGRID - 0.5*STEPGRID, MAXYGRID + 0.5*STEPGRID);
+//histChi2Off.SetXTitle("-RA [deg]");
+//histChi2Off.SetYTitle("DEC [deg]");
+histChi2Off.SetDirectory(NULL);
+histChi2Off.SetFillStyle(4000);
+histChi2Off.UseCurrentStyle();
+
+TH2F histskyplotOnOff("SPSignifOnOff","Sky Plot of significance (using ON and OFF data)", 
+                 NUMSTEPS, MINXGRID - 0.5*STEPGRID, MAXXGRID + 0.5*STEPGRID,
+                 NUMSTEPS, MINYGRID - 0.5*STEPGRID, MAXYGRID + 0.5*STEPGRID);
+//histskyplotOnOff.SetXTitle("-RA [deg]");
+//histskyplotOnOff.SetYTitle("DEC [deg]");
+histskyplotOnOff.SetDirectory(NULL);
+histskyplotOnOff.SetFillStyle(4000);
+histskyplotOnOff.UseCurrentStyle();
+
+TH2F histNex("SPNex2ndOrder","Sky Plot of Number of excess events (2nd order fit)",
+                 NUMSTEPS, MINXGRID - 0.5*STEPGRID, MAXXGRID + 0.5*STEPGRID,
+                 NUMSTEPS, MINYGRID - 0.5*STEPGRID, MAXYGRID + 0.5*STEPGRID);
+//histNex.SetXTitle("-RA [deg]");
+//histNex.SetYTitle("DEC [deg]");
+histNex.SetDirectory(NULL);
+histNex.SetFillStyle(4000);
+histNex.UseCurrentStyle();
+
+TH2F histChi2("SPChi2PerNdf2ndOrderOn","Sky Plot of Chi2/ndf (2nd order fit)", 
+                 NUMSTEPS, MINXGRID - 0.5*STEPGRID, MAXXGRID + 0.5*STEPGRID,
+                 NUMSTEPS, MINYGRID - 0.5*STEPGRID, MAXYGRID + 0.5*STEPGRID);
+//histChi2.SetXTitle("-RA [deg]");
+//histChi2.SetYTitle("DEC [deg]");
+histChi2.SetDirectory(NULL);
+histChi2.SetFillStyle(4000);
+histChi2.UseCurrentStyle();
+
+TH2F histskyplot4("SPSignif4thOrder","Sky Plot of significance (4th order fit)", 
+                 NUMSTEPS, MINXGRID - 0.5*STEPGRID, MAXXGRID + 0.5*STEPGRID,
+                 NUMSTEPS, MINYGRID - 0.5*STEPGRID, MAXYGRID + 0.5*STEPGRID);
+//histskyplot4.SetXTitle("-RA [deg]");
+//histskyplot4.SetYTitle("DEC [deg]");
+histskyplot4.SetDirectory(NULL);
+histskyplot4.SetFillStyle(4000);
+histskyplot4.UseCurrentStyle();
+
+TH2F histskyLiMa("SPSignifLiMaOnOff","Sky Plot of significance (ON - OFF LiMa17)", 
+                 NUMSTEPS, MINXGRID - 0.5*STEPGRID, MAXXGRID + 0.5*STEPGRID,
+                 NUMSTEPS, MINYGRID - 0.5*STEPGRID, MAXYGRID + 0.5*STEPGRID);
+//histskyLiMa.SetXTitle("-RA [deg]");
+//histskyLiMa.SetYTitle("DEC [deg]");
+histskyLiMa.SetDirectory(NULL);
+histskyLiMa.SetFillStyle(4000);
+histskyLiMa.UseCurrentStyle();
+
+TH2F histBerlin("SPBerlinMethod","Sky Plot of Events below alpha 8 degrees", 
+                 NUMSTEPS, MINXGRID - 0.5*STEPGRID, MAXXGRID + 0.5*STEPGRID,
+                 NUMSTEPS, MINYGRID - 0.5*STEPGRID, MAXYGRID + 0.5*STEPGRID);
+//histskyLiMa.SetXTitle("-RA [deg]");
+//histskyLiMa.SetYTitle("DEC [deg]");
+histBerlin.SetDirectory(NULL);
+histBerlin.SetFillStyle(4000);
+histBerlin.UseCurrentStyle();
+
+TH1F histsign;
+histsign.SetName("Significance 1");
+histsign.SetTitle("Significance (2nd order fit)");
+histsign.SetXTitle("significance");
+histsign.SetYTitle("Counts");
+histsign.SetDirectory(NULL);
+histsign.SetFillStyle(4000);
+histsign.UseCurrentStyle(); 
+
+ bins.SetEdges(20, -5., 8.);
+ bins.Apply(histsign);
+
+TH1F histsign4;
+histsign4.SetName("Significance 2");
+histsign4.SetTitle("Significance (4th order fit)");
+histsign4.SetXTitle("significance");
+histsign4.SetYTitle("Counts");
+histsign4.SetDirectory(NULL);
+histsign4.SetFillStyle(4000);
+histsign4.UseCurrentStyle(); 
+
+ bins.SetEdges(20, -5., 8.);
+ bins.Apply(histsign4);
+
+
+TH1F histalphagrid;
+histalphagrid.SetName("Alpha");
+histalphagrid.SetTitle("Alpha");
+//histalphagrid.SetXTitle("Alpha [deg]");
+histalphagrid.SetYTitle("Counts");
+histalphagrid.SetDirectory(NULL);
+histalphagrid.SetFillStyle(4000);
+histalphagrid.UseCurrentStyle(); 
+
+ bins.SetEdges(18, 0.0, 90.);
+ bins.Apply(histalphagrid);
+
+/*
+#define n 100
+Double_t binsize[n];
+Float_t nmin = 100.;
+Float_t nmax = 1e7;
+
+for(Int_t i=0; i<n; i++)
+{
+binsize[i] = pow(10., log10(nmin) + i * (log10(nmax) - log10(nmin)) / (n-1.));
+}
+
+TH2F hist2wsize("Width-Size", "correlation Width-Size", 100, 0.0, 0.5, n-1, binsize);
+TH2F hist2alphasize("Alpha-Size","correlation Alpha-Size", 100, -100., 100., n-1, binsize);
+TH2F hist2distsize("Dist-Size","correlation Dist-Size", 100, 0.0, 1.6, n-1, binsize);
+*/
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/Changelog_pisa
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/Changelog_pisa	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/Changelog_pisa	(revision 9661)
@@ -0,0 +1,83 @@
+Please  do  not write behind the end of line tag so that it is  possible
+to   send  a   Changelog   file  to  a  line  printer  directly.  Thanks.
+
+For your entries please follow this style:
+
+_yyyy/mm/dd:_[Your Name]
+_
+___*_filename:
+_____-_description
+_
+___*_filename2, filename3:
+_____-_description
+_
+_
+_
+
+While an underscore is a placeholder for a white-space or an empty line.
+
+                                                 -*-*- END OF LINE -*-*-
+ 2004/05/24: Antonio Stamerra
+
+   * mpisa/classes/mtrigger/*, mpisa/classes/MTriggerReport.[h,cc]
+     - classes almost completed; compiles.  
+	
+
+ 2004/05/24: Antonio Stamerra
+
+   * mpisa/classes/MTriggerLiveTime.[h.cc]
+     - added new class container for the Live-Deadtime from report files (.rep)
+	
+   * mpisa/classes/mtrigger
+     - added new directory for the MTrigger* classes. These
+	classes have been moved there. 
+     - Various modifications have been made on these classes.
+	The MReportTrigger now fills these containers.
+
+ 2004/05/24: Antonio Stamerra
+
+   * mpisa/classes/MTriggerCell.[h.cc]
+     - added new class container for the cell rates from report files (.rep)
+
+   * mpisa/classes/MTriggerBit.[h.cc]
+     - added new class container for the L2 bits rates from report files (.rep)
+
+   * mpisa/classes/MTriggerPrescFact.[h.cc]
+     - added new class container for the prescaling factors from 
+	report files (.rep)
+
+   * mpisa/classes/MTriggerReport.[h.cc]
+     - added copy of the mreport/MReportTrigger class to modify to new
+	report file format and to use the trigger class containers
+
+
+ 2004/05/21: Antonio Stamerra
+
+   * mpisa/classes
+     - added directory /classes. Should be used to add new classes
+
+   * mpisa/Makefile, mpisa/PisaLinkDef.h, mpisa/PisaIncl.h
+     - added to compile internally to the mpisa directory the classes
+
+   * mpisa/classes/MTriggerIPR.[h,cc]
+     - added container for IPR values.
+   
+
+ 2004/05/12: Antonio Stamerra
+
+   * mpisa/macros
+     - added macros:
+	- first_ana.C   given a file with hillas analysis produces ON-OFF plots
+	- production.C  produces calibrated data (photons) from raw data
+	- HillasAnal.C  makes standard Hillas analysis
+
+   * mpisa/macros
+     - added this directory 	
+
+   * added this file Changelog_pisa
+     - test	
+
+ 2004/05/11: Antonio Stamerra
+
+   * mtemp/mpisa
+     - 	added directory mpisa in mtemp
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/Makefile
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/Makefile	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/Makefile	(revision 9661)
@@ -0,0 +1,53 @@
+##################################################################
+#
+#   subdirectory makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../../Makefile.conf.$(OSTYPE)
+include ../../Makefile.conf.general
+
+#------------------------------------------------------------------------------
+
+CINT     = Pisa
+
+#------------------------------------------------------------------------------
+
+INCLUDES = -I. \
+	   -I../../mbase \
+	   -I../../mjobs \
+	   -I../../mpedestal \
+	   -I../../mbadpixels \
+	   -I../../mfileio \
+           -I../../mraw \
+           -I../../manalysis \
+	   -I../../mgui \
+	   -I../../mgeom \
+	   -I../../msignal \
+	   -I../../mcalib \
+	   -I../../mfilter \
+	   -I../../mhbase \
+	   -I../../mimage \
+	   -I../../mpointing \
+	   -I../../mcamera \
+	   -I../../mhist \
+	   -I../../mmc \
+	   -I../../mreport \
+	   -I../../mastro
+
+SRCFILES = \
+        ./classes/MTriggerIPR.cc \
+        ./classes/MTriggerCell.cc \
+        ./classes/MTriggerBit.cc \
+        ./classes/MTriggerPrescFact.cc \
+        ./classes/MTriggerLiveTime.cc
+
+############################################################
+
+all: $(OBJS)
+
+include ../../Makefile.rules
+
+clean:	rmcint rmobjs rmcore rmlib
+mrproper:	clean rmbak
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/PisaIncl.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/PisaIncl.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/PisaIncl.h	(revision 9661)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/PisaLinkDef.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/PisaLinkDef.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/PisaLinkDef.h	(revision 9661)
@@ -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 MTriggerIPR+;
+#pragma link C++ class MTriggerCell+;
+#pragma link C++ class MTriggerBit+;
+#pragma link C++ class MTriggerPrescFact+;
+#pragma link C++ class MTriggerLiveTime+;
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MReportTrigger.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MReportTrigger.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MReportTrigger.cc	(revision 9661)
@@ -0,0 +1,385 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!              Antonio Stamerra, 05/2004 <mailto:antonio.stamerra@pi.infn.it>
+! 
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  MReportTrigger
+//
+// This is the class interpreting and storing the TRIGGER-REPORT information.
+//  Updated to add IPR; data format follows TDAS 00-07
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MReportTrigger.h"
+
+#include "MParList.h"
+
+#include "MLogManip.h"
+#include "MTriggerIPR.h"
+#include "MTriggerCell.h"
+#include "MTriggerBit.h"
+#include "MTriggerPrescFact.h"
+#include "MTriggerLiveTime.h"
+
+ClassImp(MReportTrigger);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default construtor. Initialize identifier to "TRIGGER-REPORT"
+//
+MReportTrigger::MReportTrigger() : MReport("TRIGGER-REPORT")
+{
+    fName  = "MReportTrigger";
+    fTitle = "Class for TRIGGER-REPORT information";
+}
+
+// --------------------------------------------------------------------------
+//
+// FindCreate the following objects:
+//  - MTriggerIPR
+//  - MTriggerCell
+//  - MTriggerBit
+//  - MTriggerPrescFact
+//
+Bool_t MReportTrigger::SetupReading(MParList &plist)
+{
+  fPixel = (MTriggerIPR*)plist.FindCreateObj("MTriggerIPR");
+  if (!fPixel)
+    return kFALSE;
+
+  fCell = (MTriggerCell*)plist.FindCreateObj("MTriggerCell");
+  if (!fCell)
+    return kFALSE;
+
+  fBit = (MTriggerBit*)plist.FindCreateObj("MTriggerBit");
+  if (!fBit)
+    return kFALSE;
+
+  fPrescFactor = (MTriggerPrescFact*)plist.FindCreateObj("MTriggerPrescFact");
+  if (!fPrescFactor)
+    return kFALSE;
+
+  fLiveTime = (MTriggerLiveTime*)plist.FindCreateObj("MTriggerLiveTime");
+  if (!fLiveTime)
+    return kFALSE;
+  
+  return MReport::SetupReading(plist);
+}
+
+// --------------------------------------------------------------------------
+//
+// Interprete the Cell rates part of the report
+//  Read 32 floats separated with a blank
+//
+Bool_t MReportTrigger::InterpreteCell(TString &str)
+{
+  Int_t len=0, n, i=0;
+  Int_t gsNCells=32;
+
+  for (i=0;i<gsNCells;i++)
+    {
+      n = sscanf(str.Data(), " %f %n", &fCell->fCellRate[i], &len);
+      if (n!=1)
+	{
+	  *fLog << warn << "WARNING - Cell Scaler Value #" << i << " missing." << endl;
+	  return kCONTINUE;
+	}
+      str.Remove(0, len); // Remove cell rates from report string
+    }
+
+  str=str.Strip(TString::kLeading);  
+
+      *fLog << warn << "Cell ok!" <<endl;
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Interprete the Prescaling factors part of the report
+//
+Bool_t MReportTrigger::InterpretePrescFact(TString &str)
+{
+  Int_t len=0, n, i=0;
+  Int_t gsNPrescFacts=8;
+  
+  str.Remove(0, 1);
+  *fLog << warn << str<<endl;
+
+  for (i=0;i<gsNPrescFacts;i++)
+    {
+    const Int_t ws = str.First(' ');
+    if (ws<=0)
+       {
+	 *fLog << warn << "WARNING - Cannot determine Prescaling factor #" << i << " descriptor" << endl;
+        return kCONTINUE;
+       }
+    TString descriptor = str(0, ws);
+    *fLog  << descriptor <<endl;
+    str.Remove(0, ws);
+      
+      n = sscanf(str.Data(), " %li %n", &fPrescFactor->fPrescFact[i], &len);
+      if (n!=1)
+	{
+	  *fLog << warn << "WARNING - prescaler factor " << i << " missing." << endl;
+	  return kCONTINUE;
+	}
+      str.Remove(0, len); // Remove Prescal. factors from report string
+      *fLog << warn << fPrescFactor->fPrescFact[i]<<endl;
+    }
+  str=str.Strip(TString::kLeading);  
+  
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Interprete the Scaler with Live-Deadtime part of the report
+//  Read 4x5 integers separated with a blank
+//
+Bool_t MReportTrigger::InterpreteLiveTime(TString &str)
+{
+  Int_t len, n, i=0;
+  Int_t gsNScalers=5;
+  Int_t  dLSB, dMSB,lLSB, lMSB;
+
+  for (i=0;i<gsNScalers;i++)
+    {
+      n = sscanf(str.Data(), " %d %d %d %d %n", &lLSB, &lMSB,&dLSB, &dMSB, &len);
+      if (n!=4)
+	{
+	  *fLog << warn << "WARNING - Live-Deadtime Scaler Value #" << i << " missing." << endl;
+	  return kCONTINUE;
+	}
+
+      str.Remove(0, len); // Remove Live-Deadtimes from string
+
+      //convert to seconds and fill container
+      // (FIXME! only the MSB (seconds is now considered)
+      (fLiveTime->fLiveTime)[i] = lMSB;
+      (fLiveTime->fDeadTime)[i] = dMSB;      
+    }
+
+  str=str.Strip(TString::kLeading);  
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Interprete the Bit rates part of the report
+// 20 integers. First and last two are not used
+//
+Bool_t MReportTrigger::InterpreteBit(TString &str)
+{
+  Int_t len, n, i=0;
+  Int_t gsNBits=20;
+  
+  for (i=0;i<gsNBits;i++)
+    {
+      n = sscanf(str.Data(), " %f %n", &fBit->fBit[i], &len);
+      if (n!=1)
+	{
+	  *fLog << warn << "WARNING - Bit rate #" << i << " missing." << endl;
+	  return kCONTINUE;
+	}
+      str.Remove(0, len); // Remove output bit rates from string
+    }
+
+  str=str.Strip(TString::kLeading);  
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Interprete the L1 and L2 table names
+// 1String + 1Int +1 String
+//
+Bool_t MReportTrigger::InterpreteL1L2Table(TString &str)
+{
+    const Int_t wsL1 = str.First(' ');
+ 
+    if (wsL1<=0)
+       {
+        *fLog << warn << "WARNING - Cannot determine name of L1 trigger table." << endl;
+        return kCONTINUE;
+       }
+    
+    TString L1tablename = str(0, wsL1);
+    str.Remove(0, wsL1);
+
+    // remove an integer between names
+    Int_t len;
+    Int_t mi;
+    Int_t n=sscanf(str.Data(), "%d %n", &mi, &len);
+    if (n!=1)
+      {
+        *fLog << warn << "WARNING - Not enough arguments." << endl;
+        return kCONTINUE;
+    }
+    str.Remove(0, len);
+
+    // L2 tablename
+    const Int_t wsL2 = str.First(' ');
+ 
+    if (wsL2<=0)
+      {
+        *fLog << warn << "WARNING - Cannot determine name of L2 trigger table." << endl;
+        return kCONTINUE;
+      }    
+    TString L2tablename = str(0, wsL2);
+    str.Remove(0,wsL2);
+    str.Strip(TString::kBoth);
+    
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Interprete a part of the report without meaning by this time
+// 18 integers
+//
+Bool_t MReportTrigger::InterpreteDummy(TString &str)
+{
+  Int_t len, n, i=0;
+  Int_t gsNDummies=18;
+  Int_t dummy;  
+
+  for (i=0;i<gsNDummies;i++)
+    {
+      n = sscanf(str.Data(), " %d %n", &dummy, &len);
+      if (n!=1)
+	{
+	  *fLog << warn << "WARNING - Dummy #" << i << " missing." << endl;
+	  return kCONTINUE;
+	}
+      str.Remove(0, len); // Remove dummies from report string
+    }
+
+  str=str.Strip(TString::kLeading);  
+
+  return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Interprete the IPR part of the report
+//
+Bool_t MReportTrigger::InterpreteIPR(TString &str)
+{
+
+
+  *fLog << warn << "IPR ok!" <<endl;
+  return kTRUE;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Interprete the body of the TRIGGER-REPORT string
+//  Read comments for details
+//
+Int_t MReportTrigger::InterpreteBody(TString &str)
+{
+    str = str.Strip(TString::kLeading);
+ 
+    // Extract trigger table name
+    const Int_t ws = str.First(' ');
+ 
+   if (ws<=0)
+    {
+        *fLog << warn << "WARNING - Cannot determine name of trigger table." << endl;
+        return kCONTINUE;
+    }
+
+    TString tablename = str(0, ws);
+    str.Remove(0, ws);
+
+    // Read the cell rates (32 fields)
+    if (!InterpreteCell(str))
+      return kCONTINUE;
+
+    // Read L1 and L2 table name (2 fields)
+    if (!InterpreteL1L2Table(str))
+      return kCONTINUE;    
+
+    // Read prescaling factors  (2x8 fields)
+    if (!InterpretePrescFact(str))
+      return kCONTINUE;
+    
+    // Read livetime and deadtime (5x4 fields)
+    if (!InterpreteLiveTime(str))
+      return kCONTINUE;
+
+    // Read L2 outout bit rates
+    if (!InterpreteBit(str))
+      return kCONTINUE;
+
+    // Read global rates (before and after prescaling)
+    Int_t len, n;
+    n = sscanf(str.Data(), " %f %f %n", &fL2BeforePrescaler, &fL2AfterPrescaler, &len);
+    if (n!=2)
+    {
+         *fLog << warn << "WARNING - Couldn't read Trigger rates." << endl;
+        return kFALSE;
+    }
+    str.Remove(0,len);
+    str.Strip(TString::kBoth);
+
+    // Read 18 dummy fields
+    if (!InterpreteDummy(str))
+      return kCONTINUE;
+
+    // Read IPR
+    if (!InterpreteIPR(str))
+      return kCONTINUE;
+
+    /*
+
+    // Read Individual pixel rates
+    pos = str.Data();
+     end = str.Data() + 344;
+ 
+    Int_t i=0;
+    while (pos < end)
+    {
+        const Char_t hex[4] = { pos[0], pos[1], pos[2], 0 };
+        n = sscanf(hex, "%hx", &fRates->fRates[i++]);
+	pos++;
+        if (n!=1)
+        {
+            *fLog << warn << "WARNING - Rate #" << i << " missing." << endl;
+            return kFALSE;
+        }
+    }
+
+    */
+
+    str.Remove(0,len);
+    str.Strip(TString::kBoth);
+
+    return str==(TString)"OVER" ? kTRUE : kCONTINUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MReportTrigger.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MReportTrigger.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MReportTrigger.h	(revision 9661)
@@ -0,0 +1,52 @@
+#ifndef MARS_MReportTrigger
+#define MARS_MReportTrigger
+
+#ifndef MARS_MReport
+#include "MReport.h"
+#endif
+
+#ifndef ROOT_TArrayL
+#include <TArrayL.h>
+#endif
+
+class MTriggerIPR;
+class MTriggerCell;
+class MTriggerBit;
+class MTriggerPrescFact;
+class MTriggerLiveTime;
+
+class MReportTrigger : public MReport
+{
+private:
+  
+  Float_t fL2BeforePrescaler; //! L2 trigger rate before prescaler
+  Float_t fL2AfterPrescaler;  //! L2 trigger rate after prescaler
+  
+  MTriggerBit *fBit;        //! container of the L2 prescaler rates
+  MTriggerIPR *fPixel;      //! container of the IPR
+  MTriggerCell *fCell;      //! container of the L1 cell trigger rates
+  MTriggerPrescFact *fPrescFactor;  //! container of the L2 prescaling factors
+  MTriggerLiveTime *fLiveTime; //! container of the scaler live-deadtime 
+  
+  Bool_t SetupReading(MParList &plist);
+
+  Bool_t InterpreteIPR(TString &str);
+  Bool_t InterpreteCell(TString &str);
+  Bool_t InterpreteBit(TString &str);
+  Bool_t InterpretePrescFact(TString &str);
+  Bool_t InterpreteLiveTime(TString &str);
+  Bool_t InterpreteDummy(TString &str);
+  Bool_t InterpreteL1L2Table(TString &str);
+
+  Int_t InterpreteBody(TString &str);
+  
+public:
+    MReportTrigger();
+
+    Float_t GetL2BeforePrescaler() const { return fL2BeforePrescaler; }
+    Float_t GetL2AfterPrescaler() const { return fL2AfterPrescaler; }
+
+    ClassDef(MReportTrigger, 1) // Class for TRIGGER-REPORT information
+ };
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MTriggerBit.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MTriggerBit.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MTriggerBit.cc	(revision 9661)
@@ -0,0 +1,37 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!              Antonio Stamerra, 05/2004 <mailto:antonio.stamerra@pi.infn.it> 
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MTriggerBit
+//   This class stores the information about the L2 output Bit rates
+//   
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MTriggerBit.h"
+
+ClassImp(MTriggerBit);
+
+using namespace std;
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MTriggerBit.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MTriggerBit.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MTriggerBit.h	(revision 9661)
@@ -0,0 +1,58 @@
+#ifndef MARS_MTriggerBit
+#define MARS_MTriggerBit
+
+#ifndef MARS_MCamEvent
+#include "MCamEvent.h"
+#endif
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif 
+
+#ifndef ROOT_TArrayL
+#include <TArrayL.h>
+#endif
+
+class MTriggerBit : public MParContainer, public MCamEvent
+{
+    friend class MReportTrigger;
+
+private:
+    Byte_t  fStatus;        // Monitor of the L2T status
+    
+    Int_t gsNBits=16;        // number of output bits
+
+    TArrayL fBit; // Array with the prescaling factors
+
+public:
+    MTriggerBit() : fBit(gsNBits)  
+    {
+        fName  = "MTriggerBit";
+        fTitle = "Container for the L2 output bits rates ";
+    }
+
+    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const
+    {
+      if (idx > gsNBits)
+	return kFALSE;
+
+      val = fBit[idx];	
+
+      return val>0;
+    }
+
+    Double_t operator[](const UInt_t idx) 
+      {  
+	if (idx > gsNBits)
+	  return kFALSE;
+	
+	return fBit[idx]; 
+      }
+
+    void DrawPixelContent(Int_t num) const
+    {
+    }
+
+    ClassDef(MTriggerBit, 1) // Container for the L2 output bits rates
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MTriggerCell.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MTriggerCell.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MTriggerCell.cc	(revision 9661)
@@ -0,0 +1,37 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!              Antonio Stamerra, 05/2004 <mailto:antonio.stamerra@pi.infn.it> 
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MTriggerCell
+//   This class stores the information about the Trigger Cell Rates
+//   
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MTriggerCell.h"
+
+ClassImp(MTriggerCell);
+
+using namespace std;
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MTriggerCell.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MTriggerCell.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MTriggerCell.h	(revision 9661)
@@ -0,0 +1,58 @@
+#ifndef MARS_MTriggerCell
+#define MARS_MTriggerCell
+
+#ifndef MARS_MCamEvent
+#include "MCamEvent.h"
+#endif
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif 
+
+#ifndef ROOT_TArrayL
+#include <TArrayL.h>
+#endif
+
+class MTriggerCell : public MParContainer, public MCamEvent
+{
+    friend class MReportTrigger;
+private:
+    Byte_t  fStatus;         // Monitor of the L2T status
+
+    Int_t gsNCells=19;       //Number of trigger cells
+
+    TArrayL fCellRate;       // Array of the measured L1 cell rates
+
+public:
+    MTriggerCell() : fCellRate(gsNCells)
+    {
+        fName  = "MTriggerCell";
+        fTitle = "Container for the measured cell rates";
+    }
+
+    Float_t GetMean() const { return fCellRate.GetSum()/fCellRate.GetSize(); }
+
+    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const
+    {
+      if (idx > gsNCells)
+	return kFALSE;
+      
+      val = fCellRate[idx];
+        return val>0;
+    }
+
+    Double_t operator[](const UInt_t idx) 
+      { 
+	if (idx > gsNCells)
+	  return kFALSE;
+	
+	return fCellRate[idx]; 
+      }
+
+    void DrawPixelContent(Int_t num) const
+    {
+    }
+
+    ClassDef(MTriggerCell, 1) // Container for the trigger cell rates
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MTriggerIPR.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MTriggerIPR.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MTriggerIPR.cc	(revision 9661)
@@ -0,0 +1,37 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!              Antonio Stamerra, 05/2004 <mailto:antonio.stamerra@pi.infn.it> 
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MTriggerIPR
+//   This class stores the information about the Individual Pixel Rates
+//   
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MTriggerIPR.h"
+
+ClassImp(MTriggerIPR);
+
+using namespace std;
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MTriggerIPR.cc~
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MTriggerIPR.cc~	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MTriggerIPR.cc~	(revision 9661)
@@ -0,0 +1,34 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MCameraHV
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MCameraHV.h"
+
+ClassImp(MCameraHV);
+
+using namespace std;
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MTriggerIPR.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MTriggerIPR.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MTriggerIPR.h	(revision 9661)
@@ -0,0 +1,58 @@
+#ifndef MARS_MTriggerIPR
+#define MARS_MTriggerIPR
+
+#ifndef MARS_MCamEvent
+#include "MCamEvent.h"
+#endif
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif 
+
+#ifndef ROOT_TArrayL
+#include <TArrayL.h>
+#endif
+
+class MTriggerIPR : public MParContainer, public MCamEvent
+{
+    friend class MReportTrigger;
+private:
+    Byte_t  fStatus;        // Monitor of the L2T status
+
+    TArrayL fIPR;            // [Hz] IPR (Individual Pixel Rates)
+    
+    Int_t gsNTrigPix=397;  // number of trigger pixels
+
+public:
+    MTriggerIPR() : fIPR(gsNTrigPix)
+    {
+        fName  = "MTriggerIPR";
+        fTitle = "Container for the Individual Pixel Rate (IPR)";
+    }
+
+    Float_t GetMean() const { return fIPR.GetSum()/fIPR.GetSize(); }
+
+    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const
+    {
+      if (idx > gsNTrigPix)
+	return kFALSE;
+
+      val = fIPR[idx];
+      return val>0;
+    }
+
+    Double_t operator[](const UInt_t idx) 
+      {
+	if (idx > gsNTrigPix)
+	  return kFALSE;
+
+	return fIPR[idx]; 
+      } 
+
+    void DrawPixelContent(Int_t num) const
+    {
+    }
+
+    ClassDef(MTriggerIPR, 1) // Container for the Individual Pixel Rate (IPR)
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MTriggerIPR.h~
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MTriggerIPR.h~	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MTriggerIPR.h~	(revision 9661)
@@ -0,0 +1,63 @@
+#ifndef MARS_MCameraHV
+#define MARS_MCameraHV
+
+#ifndef MARS_MCamEvent
+#include "MCamEvent.h"
+#endif
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#ifndef ROOT_TArrayS
+#include <TArrayS.h>
+#endif
+
+class MCameraHV : public MParContainer, public MCamEvent
+{
+    friend class MReportCamera;
+private:
+    Byte_t  fStatus;        // CaCo monitored status of the High Voltage [0-9], Cam.HV.PS_state
+    Bool_t  fStatusRamping; // CaCo monitored status of ramping the HV, Cam.HV_state
+
+    Short_t fVoltageA;      // [V] Measured voltage of power supply A, hvps1
+    Short_t fVoltageB;      // [V] Measured voltage of power supply B, hvps2
+
+    Byte_t fCurrentA;       // [mA] Measured current of power supply A, curr1
+    Byte_t fCurrentB;       // [mA] Measured current of power supply B, curr2
+
+    TArrayS fHV;            // [V] Measured high Voltages for all PMTs
+
+public:
+    MCameraHV() : fHV(577)
+    {
+        fName  = "MCameraHV";
+        fTitle = "Container storing information about the Camera HV";
+    }
+
+    Byte_t  GetStatus() const { return fStatus; }
+    Bool_t  GetStatusRamping() const { return fStatusRamping; }
+
+    Short_t GetVoltageA() const { return fVoltageA; }
+    Short_t GetVoltageB() const { return fVoltageB; }
+
+    Byte_t  GetCurrentA() const { return fCurrentA; }
+    Byte_t  GetCurrentB() const { return fCurrentB; }
+
+    Float_t GetMean() const { return fHV.GetSum()/fHV.GetSize(); }
+
+    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const
+    {
+        val = fHV[idx];
+        return val>0;
+    }
+
+    Double_t operator[](const UInt_t idx) { return fHV[idx]; }
+
+    void DrawPixelContent(Int_t num) const
+    {
+    }
+
+    ClassDef(MCameraHV, 1) // Container storing information about the Camera HV
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MTriggerLiveTime.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MTriggerLiveTime.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MTriggerLiveTime.cc	(revision 9661)
@@ -0,0 +1,37 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!              Antonio Stamerra, 05/2004 <mailto:antonio.stamerra@pi.infn.it> 
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MTriggerLiveTime
+//   This class stores the information about the livetime and deadtime
+//   measured by the scalers 
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MTriggerLiveTime.h"
+
+ClassImp(MTriggerLiveTime);
+
+using namespace std;
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MTriggerLiveTime.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MTriggerLiveTime.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MTriggerLiveTime.h	(revision 9661)
@@ -0,0 +1,58 @@
+#ifndef MARS_MTriggerLiveTime
+#define MARS_MTriggerLiveTime
+
+#ifndef MARS_MCamEvent
+#include "MCamEvent.h"
+#endif
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif 
+
+#ifndef ROOT_TArrayL
+#include <TArrayL.h>
+#endif
+
+class MTriggerLiveTime : public MParContainer, public MCamEvent
+{
+    friend class MReportTrigger;
+
+private:
+    Byte_t  fStatus;        // Monitor of the L2T status
+    
+    Int_t gsNScalers=5;        // number of scalers
+
+    TArrayL fLiveTime; // Array with the livetime
+    TArrayL fDeadTime; // Array with the deadtime
+
+public:
+    MTriggerLiveTime() : fLiveTime(gsNScalers)  
+    {
+        fName  = "MTriggerLiveTime";
+        fTitle = "Container for the Live-deadtime      ";
+    }
+
+    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const
+    {
+      if (idx > gsNScalers)
+	return kFALSE;
+
+      val = fLiveTime[idx];	
+
+      return val>0;
+    }
+
+    Double_t operator[](const UInt_t idx) 
+      {  
+	Double_t val=0;
+
+	return GetPixelContent(&val, idx)>0? val: -1; 
+      }
+
+    void DrawPixelContent(Int_t num) const
+    {
+    }
+
+    ClassDef(MTriggerLiveTime, 1) // Container for the Live-Deadtime
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MTriggerPrescFact.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MTriggerPrescFact.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MTriggerPrescFact.cc	(revision 9661)
@@ -0,0 +1,37 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!              Antonio Stamerra, 05/2004 <mailto:antonio.stamerra@pi.infn.it> 
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MTriggerPrescFact
+//   This class stores the information about the L2 prescaling factors
+//   
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MTriggerPrescFact.h"
+
+ClassImp(MTriggerPrescFact);
+
+using namespace std;
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MTriggerPrescFact.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MTriggerPrescFact.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/MTriggerPrescFact.h	(revision 9661)
@@ -0,0 +1,58 @@
+#ifndef MARS_MTriggerPrescFact
+#define MARS_MTriggerPrescFact
+
+#ifndef MARS_MCamEvent
+#include "MCamEvent.h"
+#endif
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif 
+
+#ifndef ROOT_TArrayL
+#include <TArrayL.h>
+#endif
+
+class MTriggerPrescFact : public MParContainer, public MCamEvent
+{
+    friend class MReportTrigger;
+
+private:
+    Byte_t  fStatus;        // Monitor of the L2T status
+    
+    Int_t gsNPrescFacts=8;        // number of factors
+
+    TArrayL fPrescFact; // Array with the prescaling factors
+
+public:
+    MTriggerPrescFact() : fPrescFact(gsNPrescFacts)  
+    {
+        fName  = "MTriggerPrescFact";
+        fTitle = "Container for the L2 Prescaling Factors      ";
+    }
+
+    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const
+    {
+      if (idx > gsNPrescFacts)
+	return kFALSE;
+
+      val = fPrescFact[idx];	
+
+      return val>0;
+    }
+
+    Double_t operator[](const UInt_t idx) 
+      {  
+	if (idx > gsNPrescFacts)
+	  return kFALSE;
+	
+	return fPrescFact[idx]; 
+      }
+
+    void DrawPixelContent(Int_t num) const
+    {
+    }
+
+    ClassDef(MTriggerPrescFact, 1) // Container for the L2 Prescaling Factors
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/MTriggerBit.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/MTriggerBit.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/MTriggerBit.cc	(revision 9661)
@@ -0,0 +1,37 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!              Antonio Stamerra, 05/2004 <mailto:antonio.stamerra@pi.infn.it> 
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MTriggerBit
+//   This class stores the information about the L2 output Bit rates
+//   
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MTriggerBit.h"
+
+ClassImp(MTriggerBit);
+
+using namespace std;
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/MTriggerBit.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/MTriggerBit.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/MTriggerBit.h	(revision 9661)
@@ -0,0 +1,57 @@
+#ifndef MARS_MTriggerBit
+#define MARS_MTriggerBit
+
+#ifndef MARS_MCamEvent
+#include "MCamEvent.h"
+#endif
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif 
+
+#ifndef ROOT_TArrayF
+#include <TArrayF.h>
+#endif
+
+class MTriggerBit : public MParContainer, public MCamEvent
+{
+    friend class MReportTrigger;
+
+private:
+    
+    static const Int_t gsNBits=20;        // number of output bits
+
+    TArrayF fBit; // Array with the output bit rates
+
+public:
+    MTriggerBit() : fBit(gsNBits)  
+    {
+        fName  = "MTriggerBit";
+        fTitle = "Container for the L2 output bits rates ";
+    }
+
+    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const
+    {
+      if (idx > gsNBits)
+	return kFALSE;
+
+      val = fBit[idx];	
+
+      return val>0;
+    }
+
+    Double_t operator[](const Int_t idx) 
+      {  
+	if (idx > gsNBits)
+	  return kFALSE;
+	
+	return fBit[idx]; 
+      }
+
+    void DrawPixelContent(Int_t num) const
+    {
+    }
+
+    ClassDef(MTriggerBit, 1) // Container for the L2 output bits rates
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/MTriggerCell.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/MTriggerCell.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/MTriggerCell.cc	(revision 9661)
@@ -0,0 +1,37 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!              Antonio Stamerra, 05/2004 <mailto:antonio.stamerra@pi.infn.it> 
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MTriggerCell
+//   This class stores the information about the Trigger Cell Rates
+//   
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MTriggerCell.h"
+
+ClassImp(MTriggerCell);
+
+using namespace std;
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/MTriggerCell.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/MTriggerCell.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/MTriggerCell.h	(revision 9661)
@@ -0,0 +1,57 @@
+#ifndef MARS_MTriggerCell
+#define MARS_MTriggerCell
+
+#ifndef MARS_MCamEvent
+#include "MCamEvent.h"
+#endif
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif 
+
+#ifndef ROOT_TArrayF
+#include <TArrayF.h>
+#endif
+
+class MTriggerCell : public MParContainer, public MCamEvent
+{
+    friend class MReportTrigger;
+private:
+    static const Int_t gsNCells=32; //Number of fields with cell rates
+                                    // 19 cells and 12 dummy 
+
+    TArrayF fCellRate;       // Array of the measured L1 cell rates
+
+public:
+    MTriggerCell() : fCellRate(gsNCells)
+    {
+        fName  = "MTriggerCell";
+        fTitle = "Container for the measured cell rates";
+    }
+
+    Float_t GetMean() const { return fCellRate.GetSum()/fCellRate.GetSize(); }
+
+    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const
+    {
+      if (idx > gsNCells)
+	return kFALSE;
+      
+      val = fCellRate[idx];
+        return val>0;
+    }
+
+    Double_t operator[](const Int_t idx) 
+      { 
+	if (idx > gsNCells)
+	  return kFALSE;
+	
+	return fCellRate[idx]; 
+      }
+
+    void DrawPixelContent(Int_t num) const
+    {
+    }
+
+    ClassDef(MTriggerCell, 1) // Container for the trigger cell rates
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/MTriggerIPR.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/MTriggerIPR.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/MTriggerIPR.cc	(revision 9661)
@@ -0,0 +1,37 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!              Antonio Stamerra, 05/2004 <mailto:antonio.stamerra@pi.infn.it> 
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MTriggerIPR
+//   This class stores the information about the Individual Pixel Rates
+//   
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MTriggerIPR.h"
+
+ClassImp(MTriggerIPR);
+
+using namespace std;
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/MTriggerIPR.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/MTriggerIPR.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/MTriggerIPR.h	(revision 9661)
@@ -0,0 +1,56 @@
+#ifndef MARS_MTriggerIPR
+#define MARS_MTriggerIPR
+
+#ifndef MARS_MCamEvent
+#include "MCamEvent.h"
+#endif
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif 
+
+#ifndef ROOT_TArrayL
+#include <TArrayL.h>
+#endif
+
+class MTriggerIPR : public MParContainer, public MCamEvent
+{
+    friend class MReportTrigger;
+private:
+    TArrayL fIPR;            // [Hz] IPR (Individual Pixel Rates)
+    
+    static const Int_t gsNTrigPix=397;  // number of trigger pixels
+
+public:
+    MTriggerIPR() : fIPR(gsNTrigPix)
+    {
+        fName  = "MTriggerIPR";
+        fTitle = "Container for the Individual Pixel Rate (IPR)";
+    }
+
+    Float_t GetMean() const { return fIPR.GetSum()/fIPR.GetSize(); }
+
+    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const
+    {
+      if (idx > gsNTrigPix)
+	return kFALSE;
+
+      val = fIPR[idx];
+      return val>0;
+    }
+
+    Double_t operator[](const Int_t idx) 
+      {
+	if (idx > gsNTrigPix)
+	  return kFALSE;
+
+	return fIPR[idx]; 
+      } 
+
+    void DrawPixelContent(Int_t num) const
+    {
+    }
+
+    ClassDef(MTriggerIPR, 1) // Container for the Individual Pixel Rate (IPR)
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/MTriggerLiveTime.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/MTriggerLiveTime.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/MTriggerLiveTime.cc	(revision 9661)
@@ -0,0 +1,37 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!              Antonio Stamerra, 05/2004 <mailto:antonio.stamerra@pi.infn.it> 
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MTriggerLiveTime
+//   This class stores the information about the livetime and deadtime
+//   measured by the scalers 
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MTriggerLiveTime.h"
+
+ClassImp(MTriggerLiveTime);
+
+using namespace std;
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/MTriggerLiveTime.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/MTriggerLiveTime.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/MTriggerLiveTime.h	(revision 9661)
@@ -0,0 +1,57 @@
+#ifndef MARS_MTriggerLiveTime
+#define MARS_MTriggerLiveTime
+
+#ifndef MARS_MCamEvent
+#include "MCamEvent.h"
+#endif
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif 
+
+#ifndef ROOT_TArrayL
+#include <TArrayL.h>
+#endif
+
+class MTriggerLiveTime : public MParContainer, public MCamEvent
+{
+    friend class MReportTrigger;
+
+private:
+    static const Int_t gsNScalers=5;        // number of scalers
+
+    TArrayL fLiveTime; // Array with the livetime
+    TArrayL fDeadTime; // Array with the deadtime
+
+public:
+    MTriggerLiveTime() : fLiveTime(gsNScalers), fDeadTime(gsNScalers)  
+    {
+        fName  = "MTriggerLiveTime";
+        fTitle = "Container for the Live-deadtime      ";
+    }
+
+    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const
+    {
+      if (idx > gsNScalers)
+	return kFALSE;
+
+      val = fLiveTime[idx];	
+
+      return val>0;
+    }
+
+    Double_t operator[](const Int_t idx) 
+      {  	
+	if (idx > gsNScalers)
+	  return -1;
+	
+	return fLiveTime[idx]; 
+      }
+
+    void DrawPixelContent(Int_t num) const
+    {
+    }
+
+    ClassDef(MTriggerLiveTime, 1) // Container for the Live-Deadtime
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/MTriggerPrescFact.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/MTriggerPrescFact.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/MTriggerPrescFact.cc	(revision 9661)
@@ -0,0 +1,37 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!              Antonio Stamerra, 05/2004 <mailto:antonio.stamerra@pi.infn.it> 
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MTriggerPrescFact
+//   This class stores the information about the L2 prescaling factors
+//   
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MTriggerPrescFact.h"
+
+ClassImp(MTriggerPrescFact);
+
+using namespace std;
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/MTriggerPrescFact.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/MTriggerPrescFact.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/MTriggerPrescFact.h	(revision 9661)
@@ -0,0 +1,57 @@
+#ifndef MARS_MTriggerPrescFact
+#define MARS_MTriggerPrescFact
+
+#ifndef MARS_MCamEvent
+#include "MCamEvent.h"
+#endif
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif 
+
+#ifndef ROOT_TArrayL
+#include <TArrayL.h>
+#endif
+
+class MTriggerPrescFact : public MParContainer, public MCamEvent
+{
+    friend class MReportTrigger;
+
+private:
+    
+    static const Int_t gsNPrescFacts=8;        // number of factors
+
+    TArrayL fPrescFact; // Array with the prescaling factors
+
+public:
+    MTriggerPrescFact() : fPrescFact(gsNPrescFacts)  
+    {
+        fName  = "MTriggerPrescFact";
+        fTitle = "Container for the L2 Prescaling Factors      ";
+    }
+
+    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const
+    {
+      if (idx > gsNPrescFacts)
+	return kFALSE;
+
+      val = fPrescFact[idx];	
+
+      return val>0;
+    }
+
+    Double_t operator[](const Int_t idx) 
+      {  
+	if (idx > gsNPrescFacts)
+	  return kFALSE;
+	
+	return fPrescFact[idx]; 
+      }
+
+    void DrawPixelContent(Int_t num) const
+    {
+    }
+
+    ClassDef(MTriggerPrescFact, 1) // Container for the L2 Prescaling Factors
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/Makefile
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/Makefile	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/Makefile	(revision 9661)
@@ -0,0 +1,35 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#------------------------------------------------------------------------------
+
+#
+# Handling name of the Root Dictionary Files
+#
+CINT  = Trigger
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES = -I. -I../mbase -I../mgui
+
+SRCFILES = MTriggerIPR.cc \
+	   MTriggerCell.cc\
+	   MTriggerBit.cc\
+	   MTriggerPrescFact.cc\
+	   MTriggerLiveTime.cc
+
+############################################################
+
+all: $(OBJS)
+
+include ../Makefile.rules
+
+mrproper:	clean rmbak
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/TriggerCint.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/TriggerCint.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/TriggerCint.cc	(revision 9661)
@@ -0,0 +1,1914 @@
+//
+// File generated by /data0/root/bin/rootcint at Tue May 25 15:55:57 2004.
+// Do NOT change. Changes will be lost next time file is generated
+//
+
+#include "RConfig.h"
+#if !defined(R__ACCESS_IN_SYMBOL)
+//Break the privacy of classes -- Disabled for the moment
+#define private public
+#define protected public
+#endif
+
+#include "TriggerCint.h"
+#include "TClass.h"
+#include "TBuffer.h"
+#include "TMemberInspector.h"
+#include "TError.h"
+
+#ifndef G__ROOT
+#define G__ROOT
+#endif
+
+// Since CINT ignores the std namespace, we need to do so in this file.
+namespace std {} using namespace std;
+
+#include "RtypesImp.h"
+
+namespace ROOT {
+   namespace Shadow {
+   } // Of namespace ROOT::Shadow
+} // Of namespace ROOT
+
+namespace ROOT {
+   void MTriggerIPR_ShowMembers(void *obj, TMemberInspector &R__insp, char *R__parent);
+   TClass *MTriggerIPR_IsA(const void*);
+   void *new_MTriggerIPR(void *p = 0);
+   void *newArray_MTriggerIPR(Long_t size);
+   void delete_MTriggerIPR(void *p);
+   void deleteArray_MTriggerIPR(void *p);
+   void destruct_MTriggerIPR(void *p);
+
+   // Function generating the singleton type initializer
+   TGenericClassInfo *GenerateInitInstance(const MTriggerIPR*)
+   {
+      MTriggerIPR *ptr = 0;
+      static ROOT::TGenericClassInfo 
+         instance("MTriggerIPR", MTriggerIPR::Class_Version(), "MTriggerIPR.h", 16,
+                  typeid(MTriggerIPR), DefineBehavior(ptr, ptr),
+                  &::MTriggerIPR::Dictionary, &MTriggerIPR_IsA, 4);
+      instance.SetNew(&new_MTriggerIPR);
+      instance.SetNewArray(&newArray_MTriggerIPR);
+      instance.SetDelete(&delete_MTriggerIPR);
+      instance.SetDeleteArray(&deleteArray_MTriggerIPR);
+      instance.SetDestructor(&destruct_MTriggerIPR);
+      return &instance;
+   }
+   // Static variable to force the class initialization
+   static ROOT::TGenericClassInfo *_R__UNIQUE_(Init) = GenerateInitInstance((const MTriggerIPR*)0x0); R__UseDummy(_R__UNIQUE_(Init));
+}
+
+namespace ROOT {
+   void MTriggerCell_ShowMembers(void *obj, TMemberInspector &R__insp, char *R__parent);
+   TClass *MTriggerCell_IsA(const void*);
+   void *new_MTriggerCell(void *p = 0);
+   void *newArray_MTriggerCell(Long_t size);
+   void delete_MTriggerCell(void *p);
+   void deleteArray_MTriggerCell(void *p);
+   void destruct_MTriggerCell(void *p);
+
+   // Function generating the singleton type initializer
+   TGenericClassInfo *GenerateInitInstance(const MTriggerCell*)
+   {
+      MTriggerCell *ptr = 0;
+      static ROOT::TGenericClassInfo 
+         instance("MTriggerCell", MTriggerCell::Class_Version(), "MTriggerCell.h", 16,
+                  typeid(MTriggerCell), DefineBehavior(ptr, ptr),
+                  &::MTriggerCell::Dictionary, &MTriggerCell_IsA, 4);
+      instance.SetNew(&new_MTriggerCell);
+      instance.SetNewArray(&newArray_MTriggerCell);
+      instance.SetDelete(&delete_MTriggerCell);
+      instance.SetDeleteArray(&deleteArray_MTriggerCell);
+      instance.SetDestructor(&destruct_MTriggerCell);
+      return &instance;
+   }
+   // Static variable to force the class initialization
+   static ROOT::TGenericClassInfo *_R__UNIQUE_(Init) = GenerateInitInstance((const MTriggerCell*)0x0); R__UseDummy(_R__UNIQUE_(Init));
+}
+
+namespace ROOT {
+   void MTriggerBit_ShowMembers(void *obj, TMemberInspector &R__insp, char *R__parent);
+   TClass *MTriggerBit_IsA(const void*);
+   void *new_MTriggerBit(void *p = 0);
+   void *newArray_MTriggerBit(Long_t size);
+   void delete_MTriggerBit(void *p);
+   void deleteArray_MTriggerBit(void *p);
+   void destruct_MTriggerBit(void *p);
+
+   // Function generating the singleton type initializer
+   TGenericClassInfo *GenerateInitInstance(const MTriggerBit*)
+   {
+      MTriggerBit *ptr = 0;
+      static ROOT::TGenericClassInfo 
+         instance("MTriggerBit", MTriggerBit::Class_Version(), "MTriggerBit.h", 16,
+                  typeid(MTriggerBit), DefineBehavior(ptr, ptr),
+                  &::MTriggerBit::Dictionary, &MTriggerBit_IsA, 4);
+      instance.SetNew(&new_MTriggerBit);
+      instance.SetNewArray(&newArray_MTriggerBit);
+      instance.SetDelete(&delete_MTriggerBit);
+      instance.SetDeleteArray(&deleteArray_MTriggerBit);
+      instance.SetDestructor(&destruct_MTriggerBit);
+      return &instance;
+   }
+   // Static variable to force the class initialization
+   static ROOT::TGenericClassInfo *_R__UNIQUE_(Init) = GenerateInitInstance((const MTriggerBit*)0x0); R__UseDummy(_R__UNIQUE_(Init));
+}
+
+namespace ROOT {
+   void MTriggerPrescFact_ShowMembers(void *obj, TMemberInspector &R__insp, char *R__parent);
+   TClass *MTriggerPrescFact_IsA(const void*);
+   void *new_MTriggerPrescFact(void *p = 0);
+   void *newArray_MTriggerPrescFact(Long_t size);
+   void delete_MTriggerPrescFact(void *p);
+   void deleteArray_MTriggerPrescFact(void *p);
+   void destruct_MTriggerPrescFact(void *p);
+
+   // Function generating the singleton type initializer
+   TGenericClassInfo *GenerateInitInstance(const MTriggerPrescFact*)
+   {
+      MTriggerPrescFact *ptr = 0;
+      static ROOT::TGenericClassInfo 
+         instance("MTriggerPrescFact", MTriggerPrescFact::Class_Version(), "MTriggerPrescFact.h", 16,
+                  typeid(MTriggerPrescFact), DefineBehavior(ptr, ptr),
+                  &::MTriggerPrescFact::Dictionary, &MTriggerPrescFact_IsA, 4);
+      instance.SetNew(&new_MTriggerPrescFact);
+      instance.SetNewArray(&newArray_MTriggerPrescFact);
+      instance.SetDelete(&delete_MTriggerPrescFact);
+      instance.SetDeleteArray(&deleteArray_MTriggerPrescFact);
+      instance.SetDestructor(&destruct_MTriggerPrescFact);
+      return &instance;
+   }
+   // Static variable to force the class initialization
+   static ROOT::TGenericClassInfo *_R__UNIQUE_(Init) = GenerateInitInstance((const MTriggerPrescFact*)0x0); R__UseDummy(_R__UNIQUE_(Init));
+}
+
+namespace ROOT {
+   void MTriggerLiveTime_ShowMembers(void *obj, TMemberInspector &R__insp, char *R__parent);
+   TClass *MTriggerLiveTime_IsA(const void*);
+   void *new_MTriggerLiveTime(void *p = 0);
+   void *newArray_MTriggerLiveTime(Long_t size);
+   void delete_MTriggerLiveTime(void *p);
+   void deleteArray_MTriggerLiveTime(void *p);
+   void destruct_MTriggerLiveTime(void *p);
+
+   // Function generating the singleton type initializer
+   TGenericClassInfo *GenerateInitInstance(const MTriggerLiveTime*)
+   {
+      MTriggerLiveTime *ptr = 0;
+      static ROOT::TGenericClassInfo 
+         instance("MTriggerLiveTime", MTriggerLiveTime::Class_Version(), "MTriggerLiveTime.h", 16,
+                  typeid(MTriggerLiveTime), DefineBehavior(ptr, ptr),
+                  &::MTriggerLiveTime::Dictionary, &MTriggerLiveTime_IsA, 4);
+      instance.SetNew(&new_MTriggerLiveTime);
+      instance.SetNewArray(&newArray_MTriggerLiveTime);
+      instance.SetDelete(&delete_MTriggerLiveTime);
+      instance.SetDeleteArray(&deleteArray_MTriggerLiveTime);
+      instance.SetDestructor(&destruct_MTriggerLiveTime);
+      return &instance;
+   }
+   // Static variable to force the class initialization
+   static ROOT::TGenericClassInfo *_R__UNIQUE_(Init) = GenerateInitInstance((const MTriggerLiveTime*)0x0); R__UseDummy(_R__UNIQUE_(Init));
+}
+
+//______________________________________________________________________________
+TClass *MTriggerIPR::fgIsA = 0;  // static to hold class pointer
+
+//______________________________________________________________________________
+const char *MTriggerIPR::Class_Name()
+{
+   return "MTriggerIPR";
+}
+
+//______________________________________________________________________________
+const char *MTriggerIPR::ImplFileName()
+{
+   return ROOT::GenerateInitInstance((const MTriggerIPR*)0x0)->GetImplFileName();
+}
+
+//______________________________________________________________________________
+int MTriggerIPR::ImplFileLine()
+{
+   return ROOT::GenerateInitInstance((const MTriggerIPR*)0x0)->GetImplFileLine();
+}
+
+//______________________________________________________________________________
+void MTriggerIPR::Dictionary()
+{
+   fgIsA = ROOT::GenerateInitInstance((const MTriggerIPR*)0x0)->GetClass();
+}
+
+//______________________________________________________________________________
+TClass *MTriggerIPR::Class()
+{
+   if (!fgIsA) fgIsA = ROOT::GenerateInitInstance((const MTriggerIPR*)0x0)->GetClass();
+   return fgIsA;
+}
+
+//______________________________________________________________________________
+TClass *MTriggerCell::fgIsA = 0;  // static to hold class pointer
+
+//______________________________________________________________________________
+const char *MTriggerCell::Class_Name()
+{
+   return "MTriggerCell";
+}
+
+//______________________________________________________________________________
+const char *MTriggerCell::ImplFileName()
+{
+   return ROOT::GenerateInitInstance((const MTriggerCell*)0x0)->GetImplFileName();
+}
+
+//______________________________________________________________________________
+int MTriggerCell::ImplFileLine()
+{
+   return ROOT::GenerateInitInstance((const MTriggerCell*)0x0)->GetImplFileLine();
+}
+
+//______________________________________________________________________________
+void MTriggerCell::Dictionary()
+{
+   fgIsA = ROOT::GenerateInitInstance((const MTriggerCell*)0x0)->GetClass();
+}
+
+//______________________________________________________________________________
+TClass *MTriggerCell::Class()
+{
+   if (!fgIsA) fgIsA = ROOT::GenerateInitInstance((const MTriggerCell*)0x0)->GetClass();
+   return fgIsA;
+}
+
+//______________________________________________________________________________
+TClass *MTriggerBit::fgIsA = 0;  // static to hold class pointer
+
+//______________________________________________________________________________
+const char *MTriggerBit::Class_Name()
+{
+   return "MTriggerBit";
+}
+
+//______________________________________________________________________________
+const char *MTriggerBit::ImplFileName()
+{
+   return ROOT::GenerateInitInstance((const MTriggerBit*)0x0)->GetImplFileName();
+}
+
+//______________________________________________________________________________
+int MTriggerBit::ImplFileLine()
+{
+   return ROOT::GenerateInitInstance((const MTriggerBit*)0x0)->GetImplFileLine();
+}
+
+//______________________________________________________________________________
+void MTriggerBit::Dictionary()
+{
+   fgIsA = ROOT::GenerateInitInstance((const MTriggerBit*)0x0)->GetClass();
+}
+
+//______________________________________________________________________________
+TClass *MTriggerBit::Class()
+{
+   if (!fgIsA) fgIsA = ROOT::GenerateInitInstance((const MTriggerBit*)0x0)->GetClass();
+   return fgIsA;
+}
+
+//______________________________________________________________________________
+TClass *MTriggerPrescFact::fgIsA = 0;  // static to hold class pointer
+
+//______________________________________________________________________________
+const char *MTriggerPrescFact::Class_Name()
+{
+   return "MTriggerPrescFact";
+}
+
+//______________________________________________________________________________
+const char *MTriggerPrescFact::ImplFileName()
+{
+   return ROOT::GenerateInitInstance((const MTriggerPrescFact*)0x0)->GetImplFileName();
+}
+
+//______________________________________________________________________________
+int MTriggerPrescFact::ImplFileLine()
+{
+   return ROOT::GenerateInitInstance((const MTriggerPrescFact*)0x0)->GetImplFileLine();
+}
+
+//______________________________________________________________________________
+void MTriggerPrescFact::Dictionary()
+{
+   fgIsA = ROOT::GenerateInitInstance((const MTriggerPrescFact*)0x0)->GetClass();
+}
+
+//______________________________________________________________________________
+TClass *MTriggerPrescFact::Class()
+{
+   if (!fgIsA) fgIsA = ROOT::GenerateInitInstance((const MTriggerPrescFact*)0x0)->GetClass();
+   return fgIsA;
+}
+
+//______________________________________________________________________________
+TClass *MTriggerLiveTime::fgIsA = 0;  // static to hold class pointer
+
+//______________________________________________________________________________
+const char *MTriggerLiveTime::Class_Name()
+{
+   return "MTriggerLiveTime";
+}
+
+//______________________________________________________________________________
+const char *MTriggerLiveTime::ImplFileName()
+{
+   return ROOT::GenerateInitInstance((const MTriggerLiveTime*)0x0)->GetImplFileName();
+}
+
+//______________________________________________________________________________
+int MTriggerLiveTime::ImplFileLine()
+{
+   return ROOT::GenerateInitInstance((const MTriggerLiveTime*)0x0)->GetImplFileLine();
+}
+
+//______________________________________________________________________________
+void MTriggerLiveTime::Dictionary()
+{
+   fgIsA = ROOT::GenerateInitInstance((const MTriggerLiveTime*)0x0)->GetClass();
+}
+
+//______________________________________________________________________________
+TClass *MTriggerLiveTime::Class()
+{
+   if (!fgIsA) fgIsA = ROOT::GenerateInitInstance((const MTriggerLiveTime*)0x0)->GetClass();
+   return fgIsA;
+}
+
+//______________________________________________________________________________
+void R__MTriggerIPR_fIPR(TBuffer &R__b, void *R__p, int)
+{
+   TArrayL &fIPR = *(TArrayL *)R__p;
+   if (R__b.IsReading()) {
+      fIPR.Streamer(R__b);
+   } else {
+      fIPR.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void MTriggerIPR::Streamer(TBuffer &R__b)
+{
+   // Stream an object of class MTriggerIPR.
+
+   if (R__b.IsReading()) {
+      MTriggerIPR::Class()->ReadBuffer(R__b, this);
+   } else {
+      MTriggerIPR::Class()->WriteBuffer(R__b, this);
+   }
+}
+
+//______________________________________________________________________________
+void MTriggerIPR::ShowMembers(TMemberInspector &R__insp, char *R__parent)
+{
+      // Inspect the data members of an object of class MTriggerIPR.
+
+      TClass *R__cl = MTriggerIPR::IsA();
+      Int_t R__ncp = strlen(R__parent);
+      if (R__ncp || R__cl || R__insp.IsA()) { }
+      R__insp.Inspect(R__cl, R__parent, "fStatus", &fStatus);
+      R__insp.Inspect(R__cl, R__parent, "fIPR", &fIPR);
+      fIPR.ShowMembers(R__insp, strcat(R__parent,"fIPR.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fIPR",R__MTriggerIPR_fIPR);
+      MParContainer::ShowMembers(R__insp, R__parent);
+      MCamEvent::ShowMembers(R__insp, R__parent);
+}
+
+namespace ROOT {
+   // Return the actual TClass for the object argument
+   TClass *MTriggerIPR_IsA(const void *obj) {
+      return ((::MTriggerIPR*)obj)->IsA();
+   }
+   // Wrappers around operator new
+   void *new_MTriggerIPR(void *p) {
+      return  p ? new(p) ::MTriggerIPR : new ::MTriggerIPR;
+   }
+   void *newArray_MTriggerIPR(Long_t size) {
+      return new ::MTriggerIPR[size];
+   }
+   // Wrapper around operator delete
+   void delete_MTriggerIPR(void *p) {
+      delete ((::MTriggerIPR*)p);
+   }
+   void deleteArray_MTriggerIPR(void *p) {
+      delete [] ((::MTriggerIPR*)p);
+   }
+   void destruct_MTriggerIPR(void *p) {
+      typedef ::MTriggerIPR current_t;
+      ((current_t*)p)->~current_t();
+   }
+} // end of namespace ROOT for class MTriggerIPR
+
+//______________________________________________________________________________
+void R__MTriggerCell_fCellRate(TBuffer &R__b, void *R__p, int)
+{
+   TArrayF &fCellRate = *(TArrayF *)R__p;
+   if (R__b.IsReading()) {
+      fCellRate.Streamer(R__b);
+   } else {
+      fCellRate.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void MTriggerCell::Streamer(TBuffer &R__b)
+{
+   // Stream an object of class MTriggerCell.
+
+   if (R__b.IsReading()) {
+      MTriggerCell::Class()->ReadBuffer(R__b, this);
+   } else {
+      MTriggerCell::Class()->WriteBuffer(R__b, this);
+   }
+}
+
+//______________________________________________________________________________
+void MTriggerCell::ShowMembers(TMemberInspector &R__insp, char *R__parent)
+{
+      // Inspect the data members of an object of class MTriggerCell.
+
+      TClass *R__cl = MTriggerCell::IsA();
+      Int_t R__ncp = strlen(R__parent);
+      if (R__ncp || R__cl || R__insp.IsA()) { }
+      R__insp.Inspect(R__cl, R__parent, "fStatus", &fStatus);
+      R__insp.Inspect(R__cl, R__parent, "fCellRate", &fCellRate);
+      fCellRate.ShowMembers(R__insp, strcat(R__parent,"fCellRate.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fCellRate",R__MTriggerCell_fCellRate);
+      MParContainer::ShowMembers(R__insp, R__parent);
+      MCamEvent::ShowMembers(R__insp, R__parent);
+}
+
+namespace ROOT {
+   // Return the actual TClass for the object argument
+   TClass *MTriggerCell_IsA(const void *obj) {
+      return ((::MTriggerCell*)obj)->IsA();
+   }
+   // Wrappers around operator new
+   void *new_MTriggerCell(void *p) {
+      return  p ? new(p) ::MTriggerCell : new ::MTriggerCell;
+   }
+   void *newArray_MTriggerCell(Long_t size) {
+      return new ::MTriggerCell[size];
+   }
+   // Wrapper around operator delete
+   void delete_MTriggerCell(void *p) {
+      delete ((::MTriggerCell*)p);
+   }
+   void deleteArray_MTriggerCell(void *p) {
+      delete [] ((::MTriggerCell*)p);
+   }
+   void destruct_MTriggerCell(void *p) {
+      typedef ::MTriggerCell current_t;
+      ((current_t*)p)->~current_t();
+   }
+} // end of namespace ROOT for class MTriggerCell
+
+//______________________________________________________________________________
+void R__MTriggerBit_fBit(TBuffer &R__b, void *R__p, int)
+{
+   TArrayL &fBit = *(TArrayL *)R__p;
+   if (R__b.IsReading()) {
+      fBit.Streamer(R__b);
+   } else {
+      fBit.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void MTriggerBit::Streamer(TBuffer &R__b)
+{
+   // Stream an object of class MTriggerBit.
+
+   if (R__b.IsReading()) {
+      MTriggerBit::Class()->ReadBuffer(R__b, this);
+   } else {
+      MTriggerBit::Class()->WriteBuffer(R__b, this);
+   }
+}
+
+//______________________________________________________________________________
+void MTriggerBit::ShowMembers(TMemberInspector &R__insp, char *R__parent)
+{
+      // Inspect the data members of an object of class MTriggerBit.
+
+      TClass *R__cl = MTriggerBit::IsA();
+      Int_t R__ncp = strlen(R__parent);
+      if (R__ncp || R__cl || R__insp.IsA()) { }
+      R__insp.Inspect(R__cl, R__parent, "fStatus", &fStatus);
+      R__insp.Inspect(R__cl, R__parent, "fBit", &fBit);
+      fBit.ShowMembers(R__insp, strcat(R__parent,"fBit.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fBit",R__MTriggerBit_fBit);
+      MParContainer::ShowMembers(R__insp, R__parent);
+      MCamEvent::ShowMembers(R__insp, R__parent);
+}
+
+namespace ROOT {
+   // Return the actual TClass for the object argument
+   TClass *MTriggerBit_IsA(const void *obj) {
+      return ((::MTriggerBit*)obj)->IsA();
+   }
+   // Wrappers around operator new
+   void *new_MTriggerBit(void *p) {
+      return  p ? new(p) ::MTriggerBit : new ::MTriggerBit;
+   }
+   void *newArray_MTriggerBit(Long_t size) {
+      return new ::MTriggerBit[size];
+   }
+   // Wrapper around operator delete
+   void delete_MTriggerBit(void *p) {
+      delete ((::MTriggerBit*)p);
+   }
+   void deleteArray_MTriggerBit(void *p) {
+      delete [] ((::MTriggerBit*)p);
+   }
+   void destruct_MTriggerBit(void *p) {
+      typedef ::MTriggerBit current_t;
+      ((current_t*)p)->~current_t();
+   }
+} // end of namespace ROOT for class MTriggerBit
+
+//______________________________________________________________________________
+void R__MTriggerPrescFact_fPrescFact(TBuffer &R__b, void *R__p, int)
+{
+   TArrayL &fPrescFact = *(TArrayL *)R__p;
+   if (R__b.IsReading()) {
+      fPrescFact.Streamer(R__b);
+   } else {
+      fPrescFact.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void MTriggerPrescFact::Streamer(TBuffer &R__b)
+{
+   // Stream an object of class MTriggerPrescFact.
+
+   if (R__b.IsReading()) {
+      MTriggerPrescFact::Class()->ReadBuffer(R__b, this);
+   } else {
+      MTriggerPrescFact::Class()->WriteBuffer(R__b, this);
+   }
+}
+
+//______________________________________________________________________________
+void MTriggerPrescFact::ShowMembers(TMemberInspector &R__insp, char *R__parent)
+{
+      // Inspect the data members of an object of class MTriggerPrescFact.
+
+      TClass *R__cl = MTriggerPrescFact::IsA();
+      Int_t R__ncp = strlen(R__parent);
+      if (R__ncp || R__cl || R__insp.IsA()) { }
+      R__insp.Inspect(R__cl, R__parent, "fStatus", &fStatus);
+      R__insp.Inspect(R__cl, R__parent, "fPrescFact", &fPrescFact);
+      fPrescFact.ShowMembers(R__insp, strcat(R__parent,"fPrescFact.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fPrescFact",R__MTriggerPrescFact_fPrescFact);
+      MParContainer::ShowMembers(R__insp, R__parent);
+      MCamEvent::ShowMembers(R__insp, R__parent);
+}
+
+namespace ROOT {
+   // Return the actual TClass for the object argument
+   TClass *MTriggerPrescFact_IsA(const void *obj) {
+      return ((::MTriggerPrescFact*)obj)->IsA();
+   }
+   // Wrappers around operator new
+   void *new_MTriggerPrescFact(void *p) {
+      return  p ? new(p) ::MTriggerPrescFact : new ::MTriggerPrescFact;
+   }
+   void *newArray_MTriggerPrescFact(Long_t size) {
+      return new ::MTriggerPrescFact[size];
+   }
+   // Wrapper around operator delete
+   void delete_MTriggerPrescFact(void *p) {
+      delete ((::MTriggerPrescFact*)p);
+   }
+   void deleteArray_MTriggerPrescFact(void *p) {
+      delete [] ((::MTriggerPrescFact*)p);
+   }
+   void destruct_MTriggerPrescFact(void *p) {
+      typedef ::MTriggerPrescFact current_t;
+      ((current_t*)p)->~current_t();
+   }
+} // end of namespace ROOT for class MTriggerPrescFact
+
+//______________________________________________________________________________
+void R__MTriggerLiveTime_fLiveTime(TBuffer &R__b, void *R__p, int)
+{
+   TArrayL &fLiveTime = *(TArrayL *)R__p;
+   if (R__b.IsReading()) {
+      fLiveTime.Streamer(R__b);
+   } else {
+      fLiveTime.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void R__MTriggerLiveTime_fDeadTime(TBuffer &R__b, void *R__p, int)
+{
+   TArrayL &fDeadTime = *(TArrayL *)R__p;
+   if (R__b.IsReading()) {
+      fDeadTime.Streamer(R__b);
+   } else {
+      fDeadTime.Streamer(R__b);
+   }
+}
+
+//______________________________________________________________________________
+void MTriggerLiveTime::Streamer(TBuffer &R__b)
+{
+   // Stream an object of class MTriggerLiveTime.
+
+   if (R__b.IsReading()) {
+      MTriggerLiveTime::Class()->ReadBuffer(R__b, this);
+   } else {
+      MTriggerLiveTime::Class()->WriteBuffer(R__b, this);
+   }
+}
+
+//______________________________________________________________________________
+void MTriggerLiveTime::ShowMembers(TMemberInspector &R__insp, char *R__parent)
+{
+      // Inspect the data members of an object of class MTriggerLiveTime.
+
+      TClass *R__cl = MTriggerLiveTime::IsA();
+      Int_t R__ncp = strlen(R__parent);
+      if (R__ncp || R__cl || R__insp.IsA()) { }
+      R__insp.Inspect(R__cl, R__parent, "fStatus", &fStatus);
+      R__insp.Inspect(R__cl, R__parent, "fLiveTime", &fLiveTime);
+      fLiveTime.ShowMembers(R__insp, strcat(R__parent,"fLiveTime.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fLiveTime",R__MTriggerLiveTime_fLiveTime);
+      R__insp.Inspect(R__cl, R__parent, "fDeadTime", &fDeadTime);
+      fDeadTime.ShowMembers(R__insp, strcat(R__parent,"fDeadTime.")); R__parent[R__ncp] = 0;
+      R__cl->SetStreamer("fDeadTime",R__MTriggerLiveTime_fDeadTime);
+      MParContainer::ShowMembers(R__insp, R__parent);
+      MCamEvent::ShowMembers(R__insp, R__parent);
+}
+
+namespace ROOT {
+   // Return the actual TClass for the object argument
+   TClass *MTriggerLiveTime_IsA(const void *obj) {
+      return ((::MTriggerLiveTime*)obj)->IsA();
+   }
+   // Wrappers around operator new
+   void *new_MTriggerLiveTime(void *p) {
+      return  p ? new(p) ::MTriggerLiveTime : new ::MTriggerLiveTime;
+   }
+   void *newArray_MTriggerLiveTime(Long_t size) {
+      return new ::MTriggerLiveTime[size];
+   }
+   // Wrapper around operator delete
+   void delete_MTriggerLiveTime(void *p) {
+      delete ((::MTriggerLiveTime*)p);
+   }
+   void deleteArray_MTriggerLiveTime(void *p) {
+      delete [] ((::MTriggerLiveTime*)p);
+   }
+   void destruct_MTriggerLiveTime(void *p) {
+      typedef ::MTriggerLiveTime current_t;
+      ((current_t*)p)->~current_t();
+   }
+} // end of namespace ROOT for class MTriggerLiveTime
+
+/********************************************************
+* TriggerCint.cc
+********************************************************/
+
+#ifdef G__MEMTEST
+#undef malloc
+#undef free
+#endif
+
+extern "C" void G__cpp_reset_tagtableTriggerCint();
+
+extern "C" void G__set_cpp_environmentTriggerCint() {
+  G__add_compiledheader("TROOT.h");
+  G__add_compiledheader("TMemberInspector.h");
+  G__add_compiledheader("MTriggerIPR.h");
+  G__add_compiledheader("MTriggerCell.h");
+  G__add_compiledheader("MTriggerBit.h");
+  G__add_compiledheader("MTriggerPrescFact.h");
+  G__add_compiledheader("MTriggerLiveTime.h");
+  G__add_compiledheader("TriggerIncl.h");
+  G__cpp_reset_tagtableTriggerCint();
+}
+class G__TriggerCintdOcc_tag {};
+
+void* operator new(size_t size,G__TriggerCintdOcc_tag* p) {
+  if(p && G__PVOID!=G__getgvp()) return((void*)p);
+#ifndef G__ROOT
+  return(malloc(size));
+#else
+  return(::operator new(size));
+#endif
+}
+
+/* dummy, for exception */
+#ifdef G__EH_DUMMY_DELETE
+void operator delete(void *p,G__TriggerCintdOcc_tag* x) {
+  if((long)p==G__getgvp() && G__PVOID!=G__getgvp()) return;
+#ifndef G__ROOT
+  free(p);
+#else
+  ::operator delete(p);
+#endif
+}
+#endif
+
+static void G__operator_delete(void *p) {
+  if((long)p==G__getgvp() && G__PVOID!=G__getgvp()) return;
+#ifndef G__ROOT
+  free(p);
+#else
+  ::operator delete(p);
+#endif
+}
+
+void G__DELDMY_TriggerCintdOcc() { G__operator_delete(0); }
+
+extern "C" int G__cpp_dllrevTriggerCint() { return(30051515); }
+
+/*********************************************************
+* Member function Interface Method
+*********************************************************/
+
+/* MTriggerIPR */
+static int G__TriggerCint_123_0_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   MTriggerIPR *p=NULL;
+   if(G__getaryconstruct()) p=new MTriggerIPR[G__getaryconstruct()];
+   else                    p=new MTriggerIPR;
+      result7->obj.i = (long)p;
+      result7->ref = (long)p;
+      result7->type = 'u';
+      result7->tagnum = G__get_linked_tagnum(&G__TriggerCintLN_MTriggerIPR);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_123_1_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letdouble(result7,102,(double)((const MTriggerIPR*)(G__getstructoffset()))->GetMean());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_123_2_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   switch(libp->paran) {
+   case 4:
+      G__letint(result7,103,(long)((const MTriggerIPR*)(G__getstructoffset()))->GetPixelContent(*(Double_t*)G__Doubleref(&libp->para[0]),(Int_t)G__int(libp->para[1])
+,*(MGeomCam*)libp->para[2].ref,(Int_t)G__int(libp->para[3])));
+      break;
+   case 3:
+      G__letint(result7,103,(long)((const MTriggerIPR*)(G__getstructoffset()))->GetPixelContent(*(Double_t*)G__Doubleref(&libp->para[0]),(Int_t)G__int(libp->para[1])
+,*(MGeomCam*)libp->para[2].ref));
+      break;
+   }
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_123_3_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letdouble(result7,100,(double)((MTriggerIPR*)(G__getstructoffset()))->operator[]((const Int_t)G__int(libp->para[0])));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_123_4_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((const MTriggerIPR*)(G__getstructoffset()))->DrawPixelContent((Int_t)G__int(libp->para[0]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_123_5_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,85,(long)MTriggerIPR::Class());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_123_6_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,67,(long)MTriggerIPR::Class_Name());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_123_7_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,115,(long)MTriggerIPR::Class_Version());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_123_8_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      MTriggerIPR::Dictionary();
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_123_9_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,85,(long)((const MTriggerIPR*)(G__getstructoffset()))->IsA());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_123_0_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MTriggerIPR*)(G__getstructoffset()))->ShowMembers(*(TMemberInspector*)libp->para[0].ref,(char*)G__int(libp->para[1]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_123_1_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MTriggerIPR*)(G__getstructoffset()))->Streamer(*(TBuffer*)libp->para[0].ref);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_123_2_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MTriggerIPR*)(G__getstructoffset()))->StreamerNVirtual(*(TBuffer*)libp->para[0].ref);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_123_3_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,67,(long)MTriggerIPR::DeclFileName());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_123_4_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,105,(long)MTriggerIPR::ImplFileLine());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_123_5_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,67,(long)MTriggerIPR::ImplFileName());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_123_6_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,105,(long)MTriggerIPR::DeclFileLine());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+// automatic copy constructor
+static int G__TriggerCint_123_7_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash)
+{
+   MTriggerIPR *p;
+   p=new MTriggerIPR(*(MTriggerIPR*)G__int(libp->para[0]));
+   result7->obj.i = (long)p;
+   result7->ref = (long)p;
+   result7->type = 'u';
+   result7->tagnum = G__get_linked_tagnum(&G__TriggerCintLN_MTriggerIPR);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+// automatic destructor
+typedef MTriggerIPR G__TMTriggerIPR;
+static int G__TriggerCint_123_8_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   if(0==G__getstructoffset()) return(1);
+   if(G__getaryconstruct())
+     if(G__PVOID==G__getgvp())
+       delete[] (MTriggerIPR *)(G__getstructoffset());
+     else
+       for(int i=G__getaryconstruct()-1;i>=0;i--)
+         delete (MTriggerIPR *)((G__getstructoffset())+sizeof(MTriggerIPR)*i);
+   else  delete (MTriggerIPR *)(G__getstructoffset());
+      G__setnull(result7);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+
+/* MTriggerCell */
+static int G__TriggerCint_126_0_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   MTriggerCell *p=NULL;
+   if(G__getaryconstruct()) p=new MTriggerCell[G__getaryconstruct()];
+   else                    p=new MTriggerCell;
+      result7->obj.i = (long)p;
+      result7->ref = (long)p;
+      result7->type = 'u';
+      result7->tagnum = G__get_linked_tagnum(&G__TriggerCintLN_MTriggerCell);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_126_1_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letdouble(result7,102,(double)((const MTriggerCell*)(G__getstructoffset()))->GetMean());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_126_2_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   switch(libp->paran) {
+   case 4:
+      G__letint(result7,103,(long)((const MTriggerCell*)(G__getstructoffset()))->GetPixelContent(*(Double_t*)G__Doubleref(&libp->para[0]),(Int_t)G__int(libp->para[1])
+,*(MGeomCam*)libp->para[2].ref,(Int_t)G__int(libp->para[3])));
+      break;
+   case 3:
+      G__letint(result7,103,(long)((const MTriggerCell*)(G__getstructoffset()))->GetPixelContent(*(Double_t*)G__Doubleref(&libp->para[0]),(Int_t)G__int(libp->para[1])
+,*(MGeomCam*)libp->para[2].ref));
+      break;
+   }
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_126_3_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letdouble(result7,100,(double)((MTriggerCell*)(G__getstructoffset()))->operator[]((const Int_t)G__int(libp->para[0])));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_126_4_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((const MTriggerCell*)(G__getstructoffset()))->DrawPixelContent((Int_t)G__int(libp->para[0]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_126_5_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,85,(long)MTriggerCell::Class());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_126_6_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,67,(long)MTriggerCell::Class_Name());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_126_7_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,115,(long)MTriggerCell::Class_Version());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_126_8_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      MTriggerCell::Dictionary();
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_126_9_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,85,(long)((const MTriggerCell*)(G__getstructoffset()))->IsA());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_126_0_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MTriggerCell*)(G__getstructoffset()))->ShowMembers(*(TMemberInspector*)libp->para[0].ref,(char*)G__int(libp->para[1]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_126_1_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MTriggerCell*)(G__getstructoffset()))->Streamer(*(TBuffer*)libp->para[0].ref);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_126_2_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MTriggerCell*)(G__getstructoffset()))->StreamerNVirtual(*(TBuffer*)libp->para[0].ref);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_126_3_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,67,(long)MTriggerCell::DeclFileName());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_126_4_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,105,(long)MTriggerCell::ImplFileLine());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_126_5_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,67,(long)MTriggerCell::ImplFileName());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_126_6_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,105,(long)MTriggerCell::DeclFileLine());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+// automatic copy constructor
+static int G__TriggerCint_126_7_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash)
+{
+   MTriggerCell *p;
+   p=new MTriggerCell(*(MTriggerCell*)G__int(libp->para[0]));
+   result7->obj.i = (long)p;
+   result7->ref = (long)p;
+   result7->type = 'u';
+   result7->tagnum = G__get_linked_tagnum(&G__TriggerCintLN_MTriggerCell);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+// automatic destructor
+typedef MTriggerCell G__TMTriggerCell;
+static int G__TriggerCint_126_8_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   if(0==G__getstructoffset()) return(1);
+   if(G__getaryconstruct())
+     if(G__PVOID==G__getgvp())
+       delete[] (MTriggerCell *)(G__getstructoffset());
+     else
+       for(int i=G__getaryconstruct()-1;i>=0;i--)
+         delete (MTriggerCell *)((G__getstructoffset())+sizeof(MTriggerCell)*i);
+   else  delete (MTriggerCell *)(G__getstructoffset());
+      G__setnull(result7);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+
+/* MTriggerBit */
+static int G__TriggerCint_127_0_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   MTriggerBit *p=NULL;
+   if(G__getaryconstruct()) p=new MTriggerBit[G__getaryconstruct()];
+   else                    p=new MTriggerBit;
+      result7->obj.i = (long)p;
+      result7->ref = (long)p;
+      result7->type = 'u';
+      result7->tagnum = G__get_linked_tagnum(&G__TriggerCintLN_MTriggerBit);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_127_1_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   switch(libp->paran) {
+   case 4:
+      G__letint(result7,103,(long)((const MTriggerBit*)(G__getstructoffset()))->GetPixelContent(*(Double_t*)G__Doubleref(&libp->para[0]),(Int_t)G__int(libp->para[1])
+,*(MGeomCam*)libp->para[2].ref,(Int_t)G__int(libp->para[3])));
+      break;
+   case 3:
+      G__letint(result7,103,(long)((const MTriggerBit*)(G__getstructoffset()))->GetPixelContent(*(Double_t*)G__Doubleref(&libp->para[0]),(Int_t)G__int(libp->para[1])
+,*(MGeomCam*)libp->para[2].ref));
+      break;
+   }
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_127_2_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letdouble(result7,100,(double)((MTriggerBit*)(G__getstructoffset()))->operator[]((const Int_t)G__int(libp->para[0])));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_127_3_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((const MTriggerBit*)(G__getstructoffset()))->DrawPixelContent((Int_t)G__int(libp->para[0]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_127_4_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,85,(long)MTriggerBit::Class());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_127_5_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,67,(long)MTriggerBit::Class_Name());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_127_6_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,115,(long)MTriggerBit::Class_Version());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_127_7_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      MTriggerBit::Dictionary();
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_127_8_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,85,(long)((const MTriggerBit*)(G__getstructoffset()))->IsA());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_127_9_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MTriggerBit*)(G__getstructoffset()))->ShowMembers(*(TMemberInspector*)libp->para[0].ref,(char*)G__int(libp->para[1]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_127_0_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MTriggerBit*)(G__getstructoffset()))->Streamer(*(TBuffer*)libp->para[0].ref);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_127_1_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MTriggerBit*)(G__getstructoffset()))->StreamerNVirtual(*(TBuffer*)libp->para[0].ref);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_127_2_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,67,(long)MTriggerBit::DeclFileName());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_127_3_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,105,(long)MTriggerBit::ImplFileLine());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_127_4_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,67,(long)MTriggerBit::ImplFileName());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_127_5_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,105,(long)MTriggerBit::DeclFileLine());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+// automatic copy constructor
+static int G__TriggerCint_127_6_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash)
+{
+   MTriggerBit *p;
+   p=new MTriggerBit(*(MTriggerBit*)G__int(libp->para[0]));
+   result7->obj.i = (long)p;
+   result7->ref = (long)p;
+   result7->type = 'u';
+   result7->tagnum = G__get_linked_tagnum(&G__TriggerCintLN_MTriggerBit);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+// automatic destructor
+typedef MTriggerBit G__TMTriggerBit;
+static int G__TriggerCint_127_7_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   if(0==G__getstructoffset()) return(1);
+   if(G__getaryconstruct())
+     if(G__PVOID==G__getgvp())
+       delete[] (MTriggerBit *)(G__getstructoffset());
+     else
+       for(int i=G__getaryconstruct()-1;i>=0;i--)
+         delete (MTriggerBit *)((G__getstructoffset())+sizeof(MTriggerBit)*i);
+   else  delete (MTriggerBit *)(G__getstructoffset());
+      G__setnull(result7);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+
+/* MTriggerPrescFact */
+static int G__TriggerCint_128_0_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   MTriggerPrescFact *p=NULL;
+   if(G__getaryconstruct()) p=new MTriggerPrescFact[G__getaryconstruct()];
+   else                    p=new MTriggerPrescFact;
+      result7->obj.i = (long)p;
+      result7->ref = (long)p;
+      result7->type = 'u';
+      result7->tagnum = G__get_linked_tagnum(&G__TriggerCintLN_MTriggerPrescFact);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_128_1_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   switch(libp->paran) {
+   case 4:
+      G__letint(result7,103,(long)((const MTriggerPrescFact*)(G__getstructoffset()))->GetPixelContent(*(Double_t*)G__Doubleref(&libp->para[0]),(Int_t)G__int(libp->para[1])
+,*(MGeomCam*)libp->para[2].ref,(Int_t)G__int(libp->para[3])));
+      break;
+   case 3:
+      G__letint(result7,103,(long)((const MTriggerPrescFact*)(G__getstructoffset()))->GetPixelContent(*(Double_t*)G__Doubleref(&libp->para[0]),(Int_t)G__int(libp->para[1])
+,*(MGeomCam*)libp->para[2].ref));
+      break;
+   }
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_128_2_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letdouble(result7,100,(double)((MTriggerPrescFact*)(G__getstructoffset()))->operator[]((const Int_t)G__int(libp->para[0])));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_128_3_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((const MTriggerPrescFact*)(G__getstructoffset()))->DrawPixelContent((Int_t)G__int(libp->para[0]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_128_4_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,85,(long)MTriggerPrescFact::Class());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_128_5_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,67,(long)MTriggerPrescFact::Class_Name());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_128_6_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,115,(long)MTriggerPrescFact::Class_Version());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_128_7_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      MTriggerPrescFact::Dictionary();
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_128_8_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,85,(long)((const MTriggerPrescFact*)(G__getstructoffset()))->IsA());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_128_9_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MTriggerPrescFact*)(G__getstructoffset()))->ShowMembers(*(TMemberInspector*)libp->para[0].ref,(char*)G__int(libp->para[1]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_128_0_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MTriggerPrescFact*)(G__getstructoffset()))->Streamer(*(TBuffer*)libp->para[0].ref);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_128_1_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MTriggerPrescFact*)(G__getstructoffset()))->StreamerNVirtual(*(TBuffer*)libp->para[0].ref);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_128_2_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,67,(long)MTriggerPrescFact::DeclFileName());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_128_3_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,105,(long)MTriggerPrescFact::ImplFileLine());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_128_4_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,67,(long)MTriggerPrescFact::ImplFileName());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_128_5_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,105,(long)MTriggerPrescFact::DeclFileLine());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+// automatic copy constructor
+static int G__TriggerCint_128_6_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash)
+{
+   MTriggerPrescFact *p;
+   p=new MTriggerPrescFact(*(MTriggerPrescFact*)G__int(libp->para[0]));
+   result7->obj.i = (long)p;
+   result7->ref = (long)p;
+   result7->type = 'u';
+   result7->tagnum = G__get_linked_tagnum(&G__TriggerCintLN_MTriggerPrescFact);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+// automatic destructor
+typedef MTriggerPrescFact G__TMTriggerPrescFact;
+static int G__TriggerCint_128_7_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   if(0==G__getstructoffset()) return(1);
+   if(G__getaryconstruct())
+     if(G__PVOID==G__getgvp())
+       delete[] (MTriggerPrescFact *)(G__getstructoffset());
+     else
+       for(int i=G__getaryconstruct()-1;i>=0;i--)
+         delete (MTriggerPrescFact *)((G__getstructoffset())+sizeof(MTriggerPrescFact)*i);
+   else  delete (MTriggerPrescFact *)(G__getstructoffset());
+      G__setnull(result7);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+
+/* MTriggerLiveTime */
+static int G__TriggerCint_129_0_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   MTriggerLiveTime *p=NULL;
+   if(G__getaryconstruct()) p=new MTriggerLiveTime[G__getaryconstruct()];
+   else                    p=new MTriggerLiveTime;
+      result7->obj.i = (long)p;
+      result7->ref = (long)p;
+      result7->type = 'u';
+      result7->tagnum = G__get_linked_tagnum(&G__TriggerCintLN_MTriggerLiveTime);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_129_1_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   switch(libp->paran) {
+   case 4:
+      G__letint(result7,103,(long)((const MTriggerLiveTime*)(G__getstructoffset()))->GetPixelContent(*(Double_t*)G__Doubleref(&libp->para[0]),(Int_t)G__int(libp->para[1])
+,*(MGeomCam*)libp->para[2].ref,(Int_t)G__int(libp->para[3])));
+      break;
+   case 3:
+      G__letint(result7,103,(long)((const MTriggerLiveTime*)(G__getstructoffset()))->GetPixelContent(*(Double_t*)G__Doubleref(&libp->para[0]),(Int_t)G__int(libp->para[1])
+,*(MGeomCam*)libp->para[2].ref));
+      break;
+   }
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_129_2_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letdouble(result7,100,(double)((MTriggerLiveTime*)(G__getstructoffset()))->operator[]((const Int_t)G__int(libp->para[0])));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_129_3_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((const MTriggerLiveTime*)(G__getstructoffset()))->DrawPixelContent((Int_t)G__int(libp->para[0]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_129_4_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,85,(long)MTriggerLiveTime::Class());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_129_5_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,67,(long)MTriggerLiveTime::Class_Name());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_129_6_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,115,(long)MTriggerLiveTime::Class_Version());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_129_7_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      MTriggerLiveTime::Dictionary();
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_129_8_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,85,(long)((const MTriggerLiveTime*)(G__getstructoffset()))->IsA());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_129_9_0(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MTriggerLiveTime*)(G__getstructoffset()))->ShowMembers(*(TMemberInspector*)libp->para[0].ref,(char*)G__int(libp->para[1]));
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_129_0_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MTriggerLiveTime*)(G__getstructoffset()))->Streamer(*(TBuffer*)libp->para[0].ref);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_129_1_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__setnull(result7);
+      ((MTriggerLiveTime*)(G__getstructoffset()))->StreamerNVirtual(*(TBuffer*)libp->para[0].ref);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_129_2_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,67,(long)MTriggerLiveTime::DeclFileName());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_129_3_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,105,(long)MTriggerLiveTime::ImplFileLine());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_129_4_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   G__letint(result7,67,(long)MTriggerLiveTime::ImplFileName());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+static int G__TriggerCint_129_5_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+      G__letint(result7,105,(long)MTriggerLiveTime::DeclFileLine());
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+// automatic copy constructor
+static int G__TriggerCint_129_6_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash)
+{
+   MTriggerLiveTime *p;
+   p=new MTriggerLiveTime(*(MTriggerLiveTime*)G__int(libp->para[0]));
+   result7->obj.i = (long)p;
+   result7->ref = (long)p;
+   result7->type = 'u';
+   result7->tagnum = G__get_linked_tagnum(&G__TriggerCintLN_MTriggerLiveTime);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+// automatic destructor
+typedef MTriggerLiveTime G__TMTriggerLiveTime;
+static int G__TriggerCint_129_7_1(G__value *result7,G__CONST char *funcname,struct G__param *libp,int hash) {
+   if(0==G__getstructoffset()) return(1);
+   if(G__getaryconstruct())
+     if(G__PVOID==G__getgvp())
+       delete[] (MTriggerLiveTime *)(G__getstructoffset());
+     else
+       for(int i=G__getaryconstruct()-1;i>=0;i--)
+         delete (MTriggerLiveTime *)((G__getstructoffset())+sizeof(MTriggerLiveTime)*i);
+   else  delete (MTriggerLiveTime *)(G__getstructoffset());
+      G__setnull(result7);
+   return(1 || funcname || hash || result7 || libp) ;
+}
+
+
+/* Setting up global function */
+
+/*********************************************************
+* Member function Stub
+*********************************************************/
+
+/* MTriggerIPR */
+
+/* MTriggerCell */
+
+/* MTriggerBit */
+
+/* MTriggerPrescFact */
+
+/* MTriggerLiveTime */
+
+/*********************************************************
+* Global function Stub
+*********************************************************/
+
+/*********************************************************
+* Get size of pointer to member function
+*********************************************************/
+class G__Sizep2memfuncTriggerCint {
+ public:
+  G__Sizep2memfuncTriggerCint() {p=&G__Sizep2memfuncTriggerCint::sizep2memfunc;}
+    size_t sizep2memfunc() { return(sizeof(p)); }
+  private:
+    size_t (G__Sizep2memfuncTriggerCint::*p)();
+};
+
+size_t G__get_sizep2memfuncTriggerCint()
+{
+  G__Sizep2memfuncTriggerCint a;
+  G__setsizep2memfunc((int)a.sizep2memfunc());
+  return((size_t)a.sizep2memfunc());
+}
+
+
+/*********************************************************
+* virtual base class offset calculation interface
+*********************************************************/
+
+   /* Setting up class inheritance */
+
+/*********************************************************
+* Inheritance information setup/
+*********************************************************/
+extern "C" void G__cpp_setup_inheritanceTriggerCint() {
+
+   /* Setting up class inheritance */
+   if(0==G__getnumbaseclass(G__get_linked_tagnum(&G__TriggerCintLN_MTriggerIPR))) {
+     MTriggerIPR *G__Lderived;
+     G__Lderived=(MTriggerIPR*)0x1000;
+     {
+       MParContainer *G__Lpbase=(MParContainer*)G__Lderived;
+       G__inheritance_setup(G__get_linked_tagnum(&G__TriggerCintLN_MTriggerIPR),G__get_linked_tagnum(&G__TriggerCintLN_MParContainer),(long)G__Lpbase-(long)G__Lderived,1,1);
+     }
+     {
+       TObject *G__Lpbase=(TObject*)G__Lderived;
+       G__inheritance_setup(G__get_linked_tagnum(&G__TriggerCintLN_MTriggerIPR),G__get_linked_tagnum(&G__TriggerCintLN_TObject),(long)G__Lpbase-(long)G__Lderived,1,0);
+     }
+     {
+       MCamEvent *G__Lpbase=(MCamEvent*)G__Lderived;
+       G__inheritance_setup(G__get_linked_tagnum(&G__TriggerCintLN_MTriggerIPR),G__get_linked_tagnum(&G__TriggerCintLN_MCamEvent),(long)G__Lpbase-(long)G__Lderived,1,1);
+     }
+   }
+   if(0==G__getnumbaseclass(G__get_linked_tagnum(&G__TriggerCintLN_MTriggerCell))) {
+     MTriggerCell *G__Lderived;
+     G__Lderived=(MTriggerCell*)0x1000;
+     {
+       MParContainer *G__Lpbase=(MParContainer*)G__Lderived;
+       G__inheritance_setup(G__get_linked_tagnum(&G__TriggerCintLN_MTriggerCell),G__get_linked_tagnum(&G__TriggerCintLN_MParContainer),(long)G__Lpbase-(long)G__Lderived,1,1);
+     }
+     {
+       TObject *G__Lpbase=(TObject*)G__Lderived;
+       G__inheritance_setup(G__get_linked_tagnum(&G__TriggerCintLN_MTriggerCell),G__get_linked_tagnum(&G__TriggerCintLN_TObject),(long)G__Lpbase-(long)G__Lderived,1,0);
+     }
+     {
+       MCamEvent *G__Lpbase=(MCamEvent*)G__Lderived;
+       G__inheritance_setup(G__get_linked_tagnum(&G__TriggerCintLN_MTriggerCell),G__get_linked_tagnum(&G__TriggerCintLN_MCamEvent),(long)G__Lpbase-(long)G__Lderived,1,1);
+     }
+   }
+   if(0==G__getnumbaseclass(G__get_linked_tagnum(&G__TriggerCintLN_MTriggerBit))) {
+     MTriggerBit *G__Lderived;
+     G__Lderived=(MTriggerBit*)0x1000;
+     {
+       MParContainer *G__Lpbase=(MParContainer*)G__Lderived;
+       G__inheritance_setup(G__get_linked_tagnum(&G__TriggerCintLN_MTriggerBit),G__get_linked_tagnum(&G__TriggerCintLN_MParContainer),(long)G__Lpbase-(long)G__Lderived,1,1);
+     }
+     {
+       TObject *G__Lpbase=(TObject*)G__Lderived;
+       G__inheritance_setup(G__get_linked_tagnum(&G__TriggerCintLN_MTriggerBit),G__get_linked_tagnum(&G__TriggerCintLN_TObject),(long)G__Lpbase-(long)G__Lderived,1,0);
+     }
+     {
+       MCamEvent *G__Lpbase=(MCamEvent*)G__Lderived;
+       G__inheritance_setup(G__get_linked_tagnum(&G__TriggerCintLN_MTriggerBit),G__get_linked_tagnum(&G__TriggerCintLN_MCamEvent),(long)G__Lpbase-(long)G__Lderived,1,1);
+     }
+   }
+   if(0==G__getnumbaseclass(G__get_linked_tagnum(&G__TriggerCintLN_MTriggerPrescFact))) {
+     MTriggerPrescFact *G__Lderived;
+     G__Lderived=(MTriggerPrescFact*)0x1000;
+     {
+       MParContainer *G__Lpbase=(MParContainer*)G__Lderived;
+       G__inheritance_setup(G__get_linked_tagnum(&G__TriggerCintLN_MTriggerPrescFact),G__get_linked_tagnum(&G__TriggerCintLN_MParContainer),(long)G__Lpbase-(long)G__Lderived,1,1);
+     }
+     {
+       TObject *G__Lpbase=(TObject*)G__Lderived;
+       G__inheritance_setup(G__get_linked_tagnum(&G__TriggerCintLN_MTriggerPrescFact),G__get_linked_tagnum(&G__TriggerCintLN_TObject),(long)G__Lpbase-(long)G__Lderived,1,0);
+     }
+     {
+       MCamEvent *G__Lpbase=(MCamEvent*)G__Lderived;
+       G__inheritance_setup(G__get_linked_tagnum(&G__TriggerCintLN_MTriggerPrescFact),G__get_linked_tagnum(&G__TriggerCintLN_MCamEvent),(long)G__Lpbase-(long)G__Lderived,1,1);
+     }
+   }
+   if(0==G__getnumbaseclass(G__get_linked_tagnum(&G__TriggerCintLN_MTriggerLiveTime))) {
+     MTriggerLiveTime *G__Lderived;
+     G__Lderived=(MTriggerLiveTime*)0x1000;
+     {
+       MParContainer *G__Lpbase=(MParContainer*)G__Lderived;
+       G__inheritance_setup(G__get_linked_tagnum(&G__TriggerCintLN_MTriggerLiveTime),G__get_linked_tagnum(&G__TriggerCintLN_MParContainer),(long)G__Lpbase-(long)G__Lderived,1,1);
+     }
+     {
+       TObject *G__Lpbase=(TObject*)G__Lderived;
+       G__inheritance_setup(G__get_linked_tagnum(&G__TriggerCintLN_MTriggerLiveTime),G__get_linked_tagnum(&G__TriggerCintLN_TObject),(long)G__Lpbase-(long)G__Lderived,1,0);
+     }
+     {
+       MCamEvent *G__Lpbase=(MCamEvent*)G__Lderived;
+       G__inheritance_setup(G__get_linked_tagnum(&G__TriggerCintLN_MTriggerLiveTime),G__get_linked_tagnum(&G__TriggerCintLN_MCamEvent),(long)G__Lpbase-(long)G__Lderived,1,1);
+     }
+   }
+}
+
+/*********************************************************
+* typedef information setup/
+*********************************************************/
+extern "C" void G__cpp_setup_typetableTriggerCint() {
+
+   /* Setting up typedef entry */
+   G__search_typename2("Int_t",105,-1,0,
+-1);
+   G__setnewtype(-1,"Signed integer 4 bytes (int)",0);
+   G__search_typename2("Float_t",102,-1,0,
+-1);
+   G__setnewtype(-1,"Float 4 bytes (float)",0);
+   G__search_typename2("Double_t",100,-1,0,
+-1);
+   G__setnewtype(-1,"Float 8 bytes (double)",0);
+   G__search_typename2("Bool_t",103,-1,0,
+-1);
+   G__setnewtype(-1,"Boolean (0=false, 1=true) (bool)",0);
+   G__search_typename2("Version_t",115,-1,0,
+-1);
+   G__setnewtype(-1,"Class version identifier (short)",0);
+}
+
+/*********************************************************
+* Data Member information setup/
+*********************************************************/
+
+   /* Setting up class,struct,union tag member variable */
+
+   /* MTriggerIPR */
+static void G__setup_memvarMTriggerIPR(void) {
+   G__tag_memvar_setup(G__get_linked_tagnum(&G__TriggerCintLN_MTriggerIPR));
+   { MTriggerIPR *p; p=(MTriggerIPR*)0x1000; if (p) { }
+   G__memvar_setup((void*)NULL,98,0,0,-1,G__defined_typename("Byte_t"),-1,4,"fStatus=",0,"Monitor of the L2T status");
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__TriggerCintLN_TArrayL),-1,-1,4,"fIPR=",0,"[Hz] IPR (Individual Pixel Rates)");
+   G__memvar_setup((void*)NULL,105,0,1,-1,G__defined_typename("Int_t"),-2,4,"gsNTrigPix=",0,"number of trigger pixels");
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__TriggerCintLN_TClass),-1,-2,4,"fgIsA=",0,(char*)NULL);
+   }
+   G__tag_memvar_reset();
+}
+
+
+   /* MTriggerCell */
+static void G__setup_memvarMTriggerCell(void) {
+   G__tag_memvar_setup(G__get_linked_tagnum(&G__TriggerCintLN_MTriggerCell));
+   { MTriggerCell *p; p=(MTriggerCell*)0x1000; if (p) { }
+   G__memvar_setup((void*)NULL,98,0,0,-1,G__defined_typename("Byte_t"),-1,4,"fStatus=",0,"Monitor of the L2T status");
+   G__memvar_setup((void*)NULL,105,0,1,-1,G__defined_typename("Int_t"),-2,4,"gsNCells=",0,"Number of fields with cell rates");
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__TriggerCintLN_TArrayF),-1,-1,4,"fCellRate=",0,"Array of the measured L1 cell rates");
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__TriggerCintLN_TClass),-1,-2,4,"fgIsA=",0,(char*)NULL);
+   }
+   G__tag_memvar_reset();
+}
+
+
+   /* MTriggerBit */
+static void G__setup_memvarMTriggerBit(void) {
+   G__tag_memvar_setup(G__get_linked_tagnum(&G__TriggerCintLN_MTriggerBit));
+   { MTriggerBit *p; p=(MTriggerBit*)0x1000; if (p) { }
+   G__memvar_setup((void*)NULL,98,0,0,-1,G__defined_typename("Byte_t"),-1,4,"fStatus=",0,"Monitor of the L2T status");
+   G__memvar_setup((void*)NULL,105,0,1,-1,G__defined_typename("Int_t"),-2,4,"gsNBits=",0,"number of output bits");
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__TriggerCintLN_TArrayL),-1,-1,4,"fBit=",0,"Array with the prescaling factors");
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__TriggerCintLN_TClass),-1,-2,4,"fgIsA=",0,(char*)NULL);
+   }
+   G__tag_memvar_reset();
+}
+
+
+   /* MTriggerPrescFact */
+static void G__setup_memvarMTriggerPrescFact(void) {
+   G__tag_memvar_setup(G__get_linked_tagnum(&G__TriggerCintLN_MTriggerPrescFact));
+   { MTriggerPrescFact *p; p=(MTriggerPrescFact*)0x1000; if (p) { }
+   G__memvar_setup((void*)NULL,98,0,0,-1,G__defined_typename("Byte_t"),-1,4,"fStatus=",0,"Monitor of the L2T status");
+   G__memvar_setup((void*)NULL,105,0,1,-1,G__defined_typename("Int_t"),-2,4,"gsNPrescFacts=",0,"number of factors");
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__TriggerCintLN_TArrayL),-1,-1,4,"fPrescFact=",0,"Array with the prescaling factors");
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__TriggerCintLN_TClass),-1,-2,4,"fgIsA=",0,(char*)NULL);
+   }
+   G__tag_memvar_reset();
+}
+
+
+   /* MTriggerLiveTime */
+static void G__setup_memvarMTriggerLiveTime(void) {
+   G__tag_memvar_setup(G__get_linked_tagnum(&G__TriggerCintLN_MTriggerLiveTime));
+   { MTriggerLiveTime *p; p=(MTriggerLiveTime*)0x1000; if (p) { }
+   G__memvar_setup((void*)NULL,98,0,0,-1,G__defined_typename("Byte_t"),-1,4,"fStatus=",0,"Monitor of the L2T status");
+   G__memvar_setup((void*)NULL,105,0,1,-1,G__defined_typename("Int_t"),-2,4,"gsNScalers=",0,"number of scalers");
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__TriggerCintLN_TArrayL),-1,-1,4,"fLiveTime=",0,"Array with the livetime");
+   G__memvar_setup((void*)NULL,117,0,0,G__get_linked_tagnum(&G__TriggerCintLN_TArrayL),-1,-1,4,"fDeadTime=",0,"Array with the deadtime");
+   G__memvar_setup((void*)NULL,85,0,0,G__get_linked_tagnum(&G__TriggerCintLN_TClass),-1,-2,4,"fgIsA=",0,(char*)NULL);
+   }
+   G__tag_memvar_reset();
+}
+
+extern "C" void G__cpp_setup_memvarTriggerCint() {
+}
+/***********************************************************
+************************************************************
+************************************************************
+************************************************************
+************************************************************
+************************************************************
+************************************************************
+***********************************************************/
+
+/*********************************************************
+* Member function information setup for each class
+*********************************************************/
+static void G__setup_memfuncMTriggerIPR(void) {
+   /* MTriggerIPR */
+   G__tag_memfunc_setup(G__get_linked_tagnum(&G__TriggerCintLN_MTriggerIPR));
+   G__memfunc_setup("MTriggerIPR",1036,G__TriggerCint_123_0_0,105,G__get_linked_tagnum(&G__TriggerCintLN_MTriggerIPR),-1,0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetMean",673,G__TriggerCint_123_1_0,102,-1,G__defined_typename("Float_t"),0,0,1,1,8,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetPixelContent",1533,G__TriggerCint_123_2_0,103,-1,G__defined_typename("Bool_t"),0,4,1,1,8,
+"d - 'Double_t' 1 - val i - 'Int_t' 0 - idx "
+"u 'MGeomCam' - 11 - cam i - 'Int_t' 0 0 type",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("operator[]",1060,G__TriggerCint_123_3_0,100,-1,G__defined_typename("Double_t"),0,1,1,1,0,"i - 'Int_t' 10 - idx",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("DrawPixelContent",1643,G__TriggerCint_123_4_0,121,-1,-1,0,1,1,1,8,"i - 'Int_t' 0 - num",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("Class",502,G__TriggerCint_123_5_0,85,G__get_linked_tagnum(&G__TriggerCintLN_TClass),-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("Class_Name",982,G__TriggerCint_123_6_0,67,-1,-1,0,0,3,1,1,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("Class_Version",1339,G__TriggerCint_123_7_0,115,-1,G__defined_typename("Version_t"),0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("Dictionary",1046,G__TriggerCint_123_8_0,121,-1,-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("IsA",253,G__TriggerCint_123_9_0,85,G__get_linked_tagnum(&G__TriggerCintLN_TClass),-1,0,0,1,1,8,"",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("ShowMembers",1132,G__TriggerCint_123_0_1,121,-1,-1,0,2,1,1,0,
+"u 'TMemberInspector' - 1 - insp C - - 0 - parent",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("Streamer",835,G__TriggerCint_123_1_1,121,-1,-1,0,1,1,1,0,"u 'TBuffer' - 1 - b",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("StreamerNVirtual",1656,G__TriggerCint_123_2_1,121,-1,-1,0,1,1,1,0,"u 'TBuffer' - 1 - b",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("DeclFileName",1145,G__TriggerCint_123_3_1,67,-1,-1,0,0,3,1,1,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("ImplFileLine",1178,G__TriggerCint_123_4_1,105,-1,-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("ImplFileName",1171,G__TriggerCint_123_5_1,67,-1,-1,0,0,3,1,1,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("DeclFileLine",1152,G__TriggerCint_123_6_1,105,-1,-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   // automatic copy constructor
+   G__memfunc_setup("MTriggerIPR",1036,G__TriggerCint_123_7_1,(int)('i'),G__get_linked_tagnum(&G__TriggerCintLN_MTriggerIPR),-1,0,1,1,1,0,"u 'MTriggerIPR' - 11 - -",(char*)NULL,(void*)NULL,0);
+   // automatic destructor
+   G__memfunc_setup("~MTriggerIPR",1162,G__TriggerCint_123_8_1,(int)('y'),-1,-1,0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__tag_memfunc_reset();
+}
+
+static void G__setup_memfuncMTriggerCell(void) {
+   /* MTriggerCell */
+   G__tag_memfunc_setup(G__get_linked_tagnum(&G__TriggerCintLN_MTriggerCell));
+   G__memfunc_setup("MTriggerCell",1185,G__TriggerCint_126_0_0,105,G__get_linked_tagnum(&G__TriggerCintLN_MTriggerCell),-1,0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetMean",673,G__TriggerCint_126_1_0,102,-1,G__defined_typename("Float_t"),0,0,1,1,8,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetPixelContent",1533,G__TriggerCint_126_2_0,103,-1,G__defined_typename("Bool_t"),0,4,1,1,8,
+"d - 'Double_t' 1 - val i - 'Int_t' 0 - idx "
+"u 'MGeomCam' - 11 - cam i - 'Int_t' 0 0 type",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("operator[]",1060,G__TriggerCint_126_3_0,100,-1,G__defined_typename("Double_t"),0,1,1,1,0,"i - 'Int_t' 10 - idx",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("DrawPixelContent",1643,G__TriggerCint_126_4_0,121,-1,-1,0,1,1,1,8,"i - 'Int_t' 0 - num",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("Class",502,G__TriggerCint_126_5_0,85,G__get_linked_tagnum(&G__TriggerCintLN_TClass),-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("Class_Name",982,G__TriggerCint_126_6_0,67,-1,-1,0,0,3,1,1,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("Class_Version",1339,G__TriggerCint_126_7_0,115,-1,G__defined_typename("Version_t"),0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("Dictionary",1046,G__TriggerCint_126_8_0,121,-1,-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("IsA",253,G__TriggerCint_126_9_0,85,G__get_linked_tagnum(&G__TriggerCintLN_TClass),-1,0,0,1,1,8,"",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("ShowMembers",1132,G__TriggerCint_126_0_1,121,-1,-1,0,2,1,1,0,
+"u 'TMemberInspector' - 1 - insp C - - 0 - parent",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("Streamer",835,G__TriggerCint_126_1_1,121,-1,-1,0,1,1,1,0,"u 'TBuffer' - 1 - b",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("StreamerNVirtual",1656,G__TriggerCint_126_2_1,121,-1,-1,0,1,1,1,0,"u 'TBuffer' - 1 - b",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("DeclFileName",1145,G__TriggerCint_126_3_1,67,-1,-1,0,0,3,1,1,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("ImplFileLine",1178,G__TriggerCint_126_4_1,105,-1,-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("ImplFileName",1171,G__TriggerCint_126_5_1,67,-1,-1,0,0,3,1,1,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("DeclFileLine",1152,G__TriggerCint_126_6_1,105,-1,-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   // automatic copy constructor
+   G__memfunc_setup("MTriggerCell",1185,G__TriggerCint_126_7_1,(int)('i'),G__get_linked_tagnum(&G__TriggerCintLN_MTriggerCell),-1,0,1,1,1,0,"u 'MTriggerCell' - 11 - -",(char*)NULL,(void*)NULL,0);
+   // automatic destructor
+   G__memfunc_setup("~MTriggerCell",1311,G__TriggerCint_126_8_1,(int)('y'),-1,-1,0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__tag_memfunc_reset();
+}
+
+static void G__setup_memfuncMTriggerBit(void) {
+   /* MTriggerBit */
+   G__tag_memfunc_setup(G__get_linked_tagnum(&G__TriggerCintLN_MTriggerBit));
+   G__memfunc_setup("MTriggerBit",1088,G__TriggerCint_127_0_0,105,G__get_linked_tagnum(&G__TriggerCintLN_MTriggerBit),-1,0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetPixelContent",1533,G__TriggerCint_127_1_0,103,-1,G__defined_typename("Bool_t"),0,4,1,1,8,
+"d - 'Double_t' 1 - val i - 'Int_t' 0 - idx "
+"u 'MGeomCam' - 11 - cam i - 'Int_t' 0 0 type",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("operator[]",1060,G__TriggerCint_127_2_0,100,-1,G__defined_typename("Double_t"),0,1,1,1,0,"i - 'Int_t' 10 - idx",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("DrawPixelContent",1643,G__TriggerCint_127_3_0,121,-1,-1,0,1,1,1,8,"i - 'Int_t' 0 - num",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("Class",502,G__TriggerCint_127_4_0,85,G__get_linked_tagnum(&G__TriggerCintLN_TClass),-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("Class_Name",982,G__TriggerCint_127_5_0,67,-1,-1,0,0,3,1,1,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("Class_Version",1339,G__TriggerCint_127_6_0,115,-1,G__defined_typename("Version_t"),0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("Dictionary",1046,G__TriggerCint_127_7_0,121,-1,-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("IsA",253,G__TriggerCint_127_8_0,85,G__get_linked_tagnum(&G__TriggerCintLN_TClass),-1,0,0,1,1,8,"",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("ShowMembers",1132,G__TriggerCint_127_9_0,121,-1,-1,0,2,1,1,0,
+"u 'TMemberInspector' - 1 - insp C - - 0 - parent",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("Streamer",835,G__TriggerCint_127_0_1,121,-1,-1,0,1,1,1,0,"u 'TBuffer' - 1 - b",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("StreamerNVirtual",1656,G__TriggerCint_127_1_1,121,-1,-1,0,1,1,1,0,"u 'TBuffer' - 1 - b",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("DeclFileName",1145,G__TriggerCint_127_2_1,67,-1,-1,0,0,3,1,1,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("ImplFileLine",1178,G__TriggerCint_127_3_1,105,-1,-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("ImplFileName",1171,G__TriggerCint_127_4_1,67,-1,-1,0,0,3,1,1,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("DeclFileLine",1152,G__TriggerCint_127_5_1,105,-1,-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   // automatic copy constructor
+   G__memfunc_setup("MTriggerBit",1088,G__TriggerCint_127_6_1,(int)('i'),G__get_linked_tagnum(&G__TriggerCintLN_MTriggerBit),-1,0,1,1,1,0,"u 'MTriggerBit' - 11 - -",(char*)NULL,(void*)NULL,0);
+   // automatic destructor
+   G__memfunc_setup("~MTriggerBit",1214,G__TriggerCint_127_7_1,(int)('y'),-1,-1,0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__tag_memfunc_reset();
+}
+
+static void G__setup_memfuncMTriggerPrescFact(void) {
+   /* MTriggerPrescFact */
+   G__tag_memfunc_setup(G__get_linked_tagnum(&G__TriggerCintLN_MTriggerPrescFact));
+   G__memfunc_setup("MTriggerPrescFact",1692,G__TriggerCint_128_0_0,105,G__get_linked_tagnum(&G__TriggerCintLN_MTriggerPrescFact),-1,0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetPixelContent",1533,G__TriggerCint_128_1_0,103,-1,G__defined_typename("Bool_t"),0,4,1,1,8,
+"d - 'Double_t' 1 - val i - 'Int_t' 0 - idx "
+"u 'MGeomCam' - 11 - cam i - 'Int_t' 0 0 type",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("operator[]",1060,G__TriggerCint_128_2_0,100,-1,G__defined_typename("Double_t"),0,1,1,1,0,"i - 'Int_t' 10 - idx",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("DrawPixelContent",1643,G__TriggerCint_128_3_0,121,-1,-1,0,1,1,1,8,"i - 'Int_t' 0 - num",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("Class",502,G__TriggerCint_128_4_0,85,G__get_linked_tagnum(&G__TriggerCintLN_TClass),-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("Class_Name",982,G__TriggerCint_128_5_0,67,-1,-1,0,0,3,1,1,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("Class_Version",1339,G__TriggerCint_128_6_0,115,-1,G__defined_typename("Version_t"),0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("Dictionary",1046,G__TriggerCint_128_7_0,121,-1,-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("IsA",253,G__TriggerCint_128_8_0,85,G__get_linked_tagnum(&G__TriggerCintLN_TClass),-1,0,0,1,1,8,"",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("ShowMembers",1132,G__TriggerCint_128_9_0,121,-1,-1,0,2,1,1,0,
+"u 'TMemberInspector' - 1 - insp C - - 0 - parent",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("Streamer",835,G__TriggerCint_128_0_1,121,-1,-1,0,1,1,1,0,"u 'TBuffer' - 1 - b",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("StreamerNVirtual",1656,G__TriggerCint_128_1_1,121,-1,-1,0,1,1,1,0,"u 'TBuffer' - 1 - b",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("DeclFileName",1145,G__TriggerCint_128_2_1,67,-1,-1,0,0,3,1,1,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("ImplFileLine",1178,G__TriggerCint_128_3_1,105,-1,-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("ImplFileName",1171,G__TriggerCint_128_4_1,67,-1,-1,0,0,3,1,1,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("DeclFileLine",1152,G__TriggerCint_128_5_1,105,-1,-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   // automatic copy constructor
+   G__memfunc_setup("MTriggerPrescFact",1692,G__TriggerCint_128_6_1,(int)('i'),G__get_linked_tagnum(&G__TriggerCintLN_MTriggerPrescFact),-1,0,1,1,1,0,"u 'MTriggerPrescFact' - 11 - -",(char*)NULL,(void*)NULL,0);
+   // automatic destructor
+   G__memfunc_setup("~MTriggerPrescFact",1818,G__TriggerCint_128_7_1,(int)('y'),-1,-1,0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__tag_memfunc_reset();
+}
+
+static void G__setup_memfuncMTriggerLiveTime(void) {
+   /* MTriggerLiveTime */
+   G__tag_memfunc_setup(G__get_linked_tagnum(&G__TriggerCintLN_MTriggerLiveTime));
+   G__memfunc_setup("MTriggerLiveTime",1600,G__TriggerCint_129_0_0,105,G__get_linked_tagnum(&G__TriggerCintLN_MTriggerLiveTime),-1,0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("GetPixelContent",1533,G__TriggerCint_129_1_0,103,-1,G__defined_typename("Bool_t"),0,4,1,1,8,
+"d - 'Double_t' 1 - val i - 'Int_t' 0 - idx "
+"u 'MGeomCam' - 11 - cam i - 'Int_t' 0 0 type",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("operator[]",1060,G__TriggerCint_129_2_0,100,-1,G__defined_typename("Double_t"),0,1,1,1,0,"i - 'Int_t' 10 - idx",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("DrawPixelContent",1643,G__TriggerCint_129_3_0,121,-1,-1,0,1,1,1,8,"i - 'Int_t' 0 - num",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("Class",502,G__TriggerCint_129_4_0,85,G__get_linked_tagnum(&G__TriggerCintLN_TClass),-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("Class_Name",982,G__TriggerCint_129_5_0,67,-1,-1,0,0,3,1,1,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("Class_Version",1339,G__TriggerCint_129_6_0,115,-1,G__defined_typename("Version_t"),0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("Dictionary",1046,G__TriggerCint_129_7_0,121,-1,-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("IsA",253,G__TriggerCint_129_8_0,85,G__get_linked_tagnum(&G__TriggerCintLN_TClass),-1,0,0,1,1,8,"",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("ShowMembers",1132,G__TriggerCint_129_9_0,121,-1,-1,0,2,1,1,0,
+"u 'TMemberInspector' - 1 - insp C - - 0 - parent",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("Streamer",835,G__TriggerCint_129_0_1,121,-1,-1,0,1,1,1,0,"u 'TBuffer' - 1 - b",(char*)NULL,(void*)NULL,1);
+   G__memfunc_setup("StreamerNVirtual",1656,G__TriggerCint_129_1_1,121,-1,-1,0,1,1,1,0,"u 'TBuffer' - 1 - b",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("DeclFileName",1145,G__TriggerCint_129_2_1,67,-1,-1,0,0,3,1,1,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("ImplFileLine",1178,G__TriggerCint_129_3_1,105,-1,-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("ImplFileName",1171,G__TriggerCint_129_4_1,67,-1,-1,0,0,3,1,1,"",(char*)NULL,(void*)NULL,0);
+   G__memfunc_setup("DeclFileLine",1152,G__TriggerCint_129_5_1,105,-1,-1,0,0,3,1,0,"",(char*)NULL,(void*)NULL,0);
+   // automatic copy constructor
+   G__memfunc_setup("MTriggerLiveTime",1600,G__TriggerCint_129_6_1,(int)('i'),G__get_linked_tagnum(&G__TriggerCintLN_MTriggerLiveTime),-1,0,1,1,1,0,"u 'MTriggerLiveTime' - 11 - -",(char*)NULL,(void*)NULL,0);
+   // automatic destructor
+   G__memfunc_setup("~MTriggerLiveTime",1726,G__TriggerCint_129_7_1,(int)('y'),-1,-1,0,0,1,1,0,"",(char*)NULL,(void*)NULL,0);
+   G__tag_memfunc_reset();
+}
+
+
+/*********************************************************
+* Member function information setup
+*********************************************************/
+extern "C" void G__cpp_setup_memfuncTriggerCint() {
+}
+
+/*********************************************************
+* Global variable information setup for each class
+*********************************************************/
+static void G__cpp_setup_global0() {
+
+   /* Setting up global variables */
+   G__resetplocal();
+
+}
+
+static void G__cpp_setup_global1() {
+
+   G__resetglobalenv();
+}
+extern "C" void G__cpp_setup_globalTriggerCint() {
+  G__cpp_setup_global0();
+  G__cpp_setup_global1();
+}
+
+/*********************************************************
+* Global function information setup for each class
+*********************************************************/
+static void G__cpp_setup_func0() {
+   G__lastifuncposition();
+
+}
+
+static void G__cpp_setup_func1() {
+}
+
+static void G__cpp_setup_func2() {
+}
+
+static void G__cpp_setup_func3() {
+
+   G__resetifuncposition();
+}
+
+extern "C" void G__cpp_setup_funcTriggerCint() {
+  G__cpp_setup_func0();
+  G__cpp_setup_func1();
+  G__cpp_setup_func2();
+  G__cpp_setup_func3();
+}
+
+/*********************************************************
+* Class,struct,union,enum tag information setup
+*********************************************************/
+/* Setup class/struct taginfo */
+G__linked_taginfo G__TriggerCintLN_TClass = { "TClass" , 99 , -1 };
+G__linked_taginfo G__TriggerCintLN_TBuffer = { "TBuffer" , 99 , -1 };
+G__linked_taginfo G__TriggerCintLN_TMemberInspector = { "TMemberInspector" , 99 , -1 };
+G__linked_taginfo G__TriggerCintLN_TObject = { "TObject" , 99 , -1 };
+G__linked_taginfo G__TriggerCintLN_MGeomCam = { "MGeomCam" , 99 , -1 };
+G__linked_taginfo G__TriggerCintLN_MCamEvent = { "MCamEvent" , 99 , -1 };
+G__linked_taginfo G__TriggerCintLN_MParContainer = { "MParContainer" , 99 , -1 };
+G__linked_taginfo G__TriggerCintLN_TArrayL = { "TArrayL" , 99 , -1 };
+G__linked_taginfo G__TriggerCintLN_MTriggerIPR = { "MTriggerIPR" , 99 , -1 };
+G__linked_taginfo G__TriggerCintLN_TArrayF = { "TArrayF" , 99 , -1 };
+G__linked_taginfo G__TriggerCintLN_MTriggerCell = { "MTriggerCell" , 99 , -1 };
+G__linked_taginfo G__TriggerCintLN_MTriggerBit = { "MTriggerBit" , 99 , -1 };
+G__linked_taginfo G__TriggerCintLN_MTriggerPrescFact = { "MTriggerPrescFact" , 99 , -1 };
+G__linked_taginfo G__TriggerCintLN_MTriggerLiveTime = { "MTriggerLiveTime" , 99 , -1 };
+
+/* Reset class/struct taginfo */
+extern "C" void G__cpp_reset_tagtableTriggerCint() {
+  G__TriggerCintLN_TClass.tagnum = -1 ;
+  G__TriggerCintLN_TBuffer.tagnum = -1 ;
+  G__TriggerCintLN_TMemberInspector.tagnum = -1 ;
+  G__TriggerCintLN_TObject.tagnum = -1 ;
+  G__TriggerCintLN_MGeomCam.tagnum = -1 ;
+  G__TriggerCintLN_MCamEvent.tagnum = -1 ;
+  G__TriggerCintLN_MParContainer.tagnum = -1 ;
+  G__TriggerCintLN_TArrayL.tagnum = -1 ;
+  G__TriggerCintLN_MTriggerIPR.tagnum = -1 ;
+  G__TriggerCintLN_TArrayF.tagnum = -1 ;
+  G__TriggerCintLN_MTriggerCell.tagnum = -1 ;
+  G__TriggerCintLN_MTriggerBit.tagnum = -1 ;
+  G__TriggerCintLN_MTriggerPrescFact.tagnum = -1 ;
+  G__TriggerCintLN_MTriggerLiveTime.tagnum = -1 ;
+}
+
+
+extern "C" void G__cpp_setup_tagtableTriggerCint() {
+
+   /* Setting up class,struct,union tag entry */
+   G__get_linked_tagnum(&G__TriggerCintLN_TClass);
+   G__get_linked_tagnum(&G__TriggerCintLN_TBuffer);
+   G__get_linked_tagnum(&G__TriggerCintLN_TMemberInspector);
+   G__get_linked_tagnum(&G__TriggerCintLN_TObject);
+   G__get_linked_tagnum(&G__TriggerCintLN_MGeomCam);
+   G__get_linked_tagnum(&G__TriggerCintLN_MCamEvent);
+   G__get_linked_tagnum(&G__TriggerCintLN_MParContainer);
+   G__get_linked_tagnum(&G__TriggerCintLN_TArrayL);
+   G__tagtable_setup(G__get_linked_tagnum(&G__TriggerCintLN_MTriggerIPR),sizeof(MTriggerIPR),-1,323840,"Container for the Individual Pixel Rate (IPR)",G__setup_memvarMTriggerIPR,G__setup_memfuncMTriggerIPR);
+   G__get_linked_tagnum(&G__TriggerCintLN_TArrayF);
+   G__tagtable_setup(G__get_linked_tagnum(&G__TriggerCintLN_MTriggerCell),sizeof(MTriggerCell),-1,323840,"Container for the trigger cell rates",G__setup_memvarMTriggerCell,G__setup_memfuncMTriggerCell);
+   G__tagtable_setup(G__get_linked_tagnum(&G__TriggerCintLN_MTriggerBit),sizeof(MTriggerBit),-1,323840,"Container for the L2 output bits rates",G__setup_memvarMTriggerBit,G__setup_memfuncMTriggerBit);
+   G__tagtable_setup(G__get_linked_tagnum(&G__TriggerCintLN_MTriggerPrescFact),sizeof(MTriggerPrescFact),-1,323840,"Container for the L2 Prescaling Factors",G__setup_memvarMTriggerPrescFact,G__setup_memfuncMTriggerPrescFact);
+   G__tagtable_setup(G__get_linked_tagnum(&G__TriggerCintLN_MTriggerLiveTime),sizeof(MTriggerLiveTime),-1,323840,"Container for the Live-Deadtime",G__setup_memvarMTriggerLiveTime,G__setup_memfuncMTriggerLiveTime);
+}
+extern "C" void G__cpp_setupTriggerCint(void) {
+  G__check_setup_version(30051515,"G__cpp_setupTriggerCint()");
+  G__set_cpp_environmentTriggerCint();
+  G__cpp_setup_tagtableTriggerCint();
+
+  G__cpp_setup_inheritanceTriggerCint();
+
+  G__cpp_setup_typetableTriggerCint();
+
+  G__cpp_setup_memvarTriggerCint();
+
+  G__cpp_setup_memfuncTriggerCint();
+  G__cpp_setup_globalTriggerCint();
+  G__cpp_setup_funcTriggerCint();
+
+   if(0==G__getsizep2memfunc()) G__get_sizep2memfuncTriggerCint();
+  return;
+}
+class G__cpp_setup_initTriggerCint {
+  public:
+    G__cpp_setup_initTriggerCint() { G__add_setup_func("TriggerCint",(G__incsetup)(&G__cpp_setupTriggerCint)); G__call_setup_funcs(); }
+   ~G__cpp_setup_initTriggerCint() { G__remove_setup_func("TriggerCint"); }
+};
+G__cpp_setup_initTriggerCint G__cpp_setup_initializerTriggerCint;
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/TriggerCint.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/TriggerCint.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/TriggerCint.h	(revision 9661)
@@ -0,0 +1,54 @@
+/********************************************************************
+* TriggerCint.h
+********************************************************************/
+#ifdef __CINT__
+#error TriggerCint.h/C is only for compilation. Abort cint.
+#endif
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <string.h>
+#define G__ANSIHEADER
+#define G__DICTIONARY
+#include "G__ci.h"
+extern "C" {
+extern void G__cpp_setup_tagtableTriggerCint();
+extern void G__cpp_setup_inheritanceTriggerCint();
+extern void G__cpp_setup_typetableTriggerCint();
+extern void G__cpp_setup_memvarTriggerCint();
+extern void G__cpp_setup_globalTriggerCint();
+extern void G__cpp_setup_memfuncTriggerCint();
+extern void G__cpp_setup_funcTriggerCint();
+extern void G__set_cpp_environmentTriggerCint();
+}
+
+
+#include "TROOT.h"
+#include "TMemberInspector.h"
+#include "MTriggerIPR.h"
+#include "MTriggerCell.h"
+#include "MTriggerBit.h"
+#include "MTriggerPrescFact.h"
+#include "MTriggerLiveTime.h"
+#include "TriggerIncl.h"
+
+#ifndef G__MEMFUNCBODY
+#endif
+
+extern G__linked_taginfo G__TriggerCintLN_TClass;
+extern G__linked_taginfo G__TriggerCintLN_TBuffer;
+extern G__linked_taginfo G__TriggerCintLN_TMemberInspector;
+extern G__linked_taginfo G__TriggerCintLN_TObject;
+extern G__linked_taginfo G__TriggerCintLN_MGeomCam;
+extern G__linked_taginfo G__TriggerCintLN_MCamEvent;
+extern G__linked_taginfo G__TriggerCintLN_MParContainer;
+extern G__linked_taginfo G__TriggerCintLN_TArrayL;
+extern G__linked_taginfo G__TriggerCintLN_MTriggerIPR;
+extern G__linked_taginfo G__TriggerCintLN_TArrayF;
+extern G__linked_taginfo G__TriggerCintLN_MTriggerCell;
+extern G__linked_taginfo G__TriggerCintLN_MTriggerBit;
+extern G__linked_taginfo G__TriggerCintLN_MTriggerPrescFact;
+extern G__linked_taginfo G__TriggerCintLN_MTriggerLiveTime;
+
+/* STUB derived class for protected member access */
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/TriggerIncl.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/TriggerIncl.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/TriggerIncl.h	(revision 9661)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/TriggerLinkDef.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/TriggerLinkDef.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/classes/mtrigger/TriggerLinkDef.h	(revision 9661)
@@ -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 MTriggerIPR+;
+#pragma link C++ class MTriggerCell+;
+#pragma link C++ class MTriggerBit+;
+#pragma link C++ class MTriggerPrescFact+;
+#pragma link C++ class MTriggerLiveTime+;
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/macros/AlphaPlot.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/macros/AlphaPlot.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/macros/AlphaPlot.C	(revision 9661)
@@ -0,0 +1,63 @@
+void AlphaPlot(TString onsource="hillas_Mrk421.root", TString offsource="hillas_OffMrk421.root")
+{
+  const Int_t kMinDeg = 25;
+
+  Int_t i;
+  Float_t EvtOn = 0;
+  Float_t EvtOff = 0;
+
+  TH1F *hon = new TH1F("hon","On Source Histogram",19,0,95);
+  TH1F *hoff = new TH1F("hoff","Off Source Histogram",19,0,95);
+  TH1F *htemp;
+
+  fon = new TFile(onsource,"READ");
+
+  htemp = (TH1F *)fon->FindObjectAny("hAlpha");
+  
+  for(i=0;i<19;i++)
+    hon->SetBinContent(i,htemp->GetBinContent(i));
+
+  for(i=0;i<hon->GetNbinsX();i++){
+    if(hon->GetBinCenter(i) > kMinDeg)
+      EvtOn += hon->GetBinContent(i);
+  }
+
+  fon->Close();
+
+  foff = new TFile(offsource,"READ");
+
+  htemp = (TH1F *)foff->FindObjectAny("hAlpha");
+  for(i=0;i<19;i++)
+    hoff->SetBinContent(i,htemp->GetBinContent(i));
+
+  for(i=0;i<hoff->GetNbinsX();i++){
+    if(hoff->GetBinCenter(i) > kMinDeg)
+      EvtOff += hoff->GetBinContent(i);
+  }
+
+  foff->Close();
+
+  Float_t norm = EvtOn/EvtOff;
+  cout << "EvtOn/EvtOff = " << norm << endl;
+
+  Float_t eccessi = 0;
+  Float_t Noff = 0;
+
+  TH1F *hAlphaPlot = new TH1F("hAlphaPlot","Alpha Plot", 19,0,95);
+  for(i=0; i<hon->GetNbinsX(); i++){
+    hAlphaPlot->SetBinContent(i,hon->GetBinContent(i)-hoff->GetBinContent(i)*norm);
+    if(hAlphaPlot->GetBinCenter(i) < 15){
+      eccessi += hAlphaPlot->GetBinContent(i);
+      Noff += norm*hoff->GetBinContent(i);
+    }
+  }
+
+  cout << "Eccessi = " << eccessi << "   Nsigma = " << eccessi/(TMath::Sqrt(Noff)) <<endl;
+
+  new TCanvas("Alpha On","Alpha plot ON source");
+  hon->DrawCopy();
+  new TCanvas("Alpha Off","Alpha plot OFF source");
+  hoff->DrawCopy();
+  new TCanvas("Alpha","Resulting alpha plot");
+  hAlphaPlot->DrawCopy();
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/macros/AnalCurrents.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/macros/AnalCurrents.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/macros/AnalCurrents.C	(revision 9661)
@@ -0,0 +1,257 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Javier López, 04/2004 <mailto:jlopez@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+/*
+#include <iostream>
+#include <stdlib.h>
+#include <string.h>
+#include <TString.h>
+#include <TArrayS.h>
+
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MGeomCamMagic.h"
+#include "MCameraDC.h"
+
+#include "MReadReports.h"
+#include "MGeomApply.h"
+#include "MEvtLoop.h"
+*/
+const Int_t gsNpix = 577;
+MGeomCamMagic geomcam;
+
+using namespace std;
+
+void AnalCurrents(const TString filename)
+{
+    //UInt_t numEvents = 1000000;
+    UInt_t numEvents = 1;
+    
+    //
+    // 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);
+    
+    
+    MCameraDC     dccam;
+    
+    plist.AddToList(&geomcam);
+    plist.AddToList(&dccam);
+    
+    //
+    // Now setup the tasks and tasklist:
+    // ---------------------------------
+    //
+    // Reads the trees of the root file and the analysed branches
+    MReadReports read;
+    read.AddTree("Currents"); 
+    read.AddFile(filename);     // after the reading of the trees!!!
+    read.AddToBranchList("MReportCurrents.*");
+    
+    MGeomApply geomapl;
+    
+    tlist.AddToList(&geomapl);
+    tlist.AddToList(&read);
+
+    //
+    // Create and setup the eventloop
+    //
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+     
+    MCerPhotEvt dcevt;
+    
+    const Int_t NSteps = 5;  // Number of steps to average DC over events
+    Int_t count = 0;         // counter for averaging NSteps events
+    Int_t NumAverEvt = 1;    // counter for averaged events stored into dcevt
+    Double_t val[gsNpix];    // array for managing the averaging of gsNpix
+                             // DC values over NSteps events
+
+    // Initialize to 0 array val
+    for(Int_t i=0; i<gsNpix; i++)
+	val[i] = 0.0;
+    //
+    // Execute your analysis
+    //
+    //if (!evtloop.Eventloop(numEvents))
+    //  return kFALSE;
+    if (!evtloop.PreProcess())
+	return;
+    
+    while (tlist.Process())
+    {
+	++count;
+	for(Int_t i=0; i<gsNpix; i++)
+	{
+	    val[i] += dccam.GetCurrent(i);
+
+	    if( (count%NSteps) == 0 )
+	    {
+		dcevt.AddPixel(i,val[i]/(Double_t)NSteps,0);
+		dcevt.GetPixelContent(val[i],i,geomcam,0);
+		val[i] = 0.0;
+	    }
+	}
+
+	// Reset count and call findstar function on this macroevent
+	if( (count%NSteps) == 0 )
+	{
+	    count = 0;
+	    ++NumAverEvt;
+	    cout << "Calling test_findstar function" << endl;
+	    test_findstar(&dcevt);
+	}
+    }
+
+    // Last loop overall pixels to fill with the average 
+    // of last count events
+    if(count!=0)
+    {
+	for(Int_t i=0; i<gsNpix; i++)
+	    dcevt.AddPixel(i,val[i]/(Double_t)count,0);
+
+	cout << "Calling test_findstar function" << endl;
+	test_findstar(&dcevt);
+    }
+
+    cout << "Number of averaged events stored into container = " << NumAverEvt << endl;
+    tlist.PrintStatistics();
+    
+}
+
+
+// This macro creates a fake MCerPhotEvt container (with some clusters
+// that simulate the starfield seen by the DC currents) and then applies
+// the image cleaning and the Hillas algorithm to recognize and classify
+// the clusters.
+//
+void test_findstar(MCerPhotEvt *wDCEvt)
+{
+    //MGeomCamMagic *geom; 
+    MCerPhotEvt *DCEvt = new MCerPhotEvt();
+    Int_t cluster[gsNpix];
+    Float_t startp[gsNpix];
+    
+    memset(cluster,-1,gsNpix);
+    memset(startp,-1,gsNpix);
+    
+    TVectorD *startpixs = new TVectorD();
+    Double_t tempDC;
+    Int_t pixid;
+    // fill a fake MCerPhotEvt 
+    // loop over all pixels
+    for (pixid=0; pixid<gsNpix ; pixid++)
+    {
+	switch (pixid)
+	{
+	    case 9:
+		DCEvt->AddPixel(pixid,1.1,0.0);
+		break;
+	    case 2:
+	    case 8:
+	    case 21:
+	    case 22:
+	    case 23:
+	    case 10:
+		DCEvt->AddPixel(pixid,1.1,0.0);
+		break;
+	    case 39:
+		DCEvt->AddPixel(pixid,1.2,0.0);
+		break;
+	    case 64:
+		DCEvt->AddPixel(pixid,1.71,0.0);
+		break;
+	    case 65:
+		DCEvt->AddPixel(pixid,1.70,0.0);
+		break;
+	    case 40:
+		DCEvt->AddPixel(pixid,1.72,0.0);
+		break;
+	    default:
+		DCEvt->AddPixel(pixid);
+		break;
+	}
+    } // end loop over pixels
+
+    if(!(FindStartPixels(wDCEvt, startpixs)))
+	cout << "ARGH!@!! In function FindStartPixel(): no starting pixel found" << endl;
+    
+}
+
+Int_t FindStartPixels(MCerPhotEvt *evt, TVectorD *startpixs)
+{
+    Double_t currDC;
+    Int_t i = 0;
+    Double_t DCthr = 10.0;
+    
+    MCerPhotPix *dcpix;
+    MGeomPix *pix;
+    
+    // look for all the pixels with a DC higher than the DC of neighbour pixels 
+    // loop over all pixels
+    for (Int_t pixid=0; pixid<gsNpix; pixid++)
+    {
+	Double_t tempDC;
+
+	pix = (MGeomPix *)geomcam[pixid]; // MGeomCamMagic pixel
+	
+	// Get the DC value of the current pixel
+	evt->GetPixelContent(currDC,pixid,geomcam,0);
+	
+	Float_t maxDC = 0.0;
+	// look for the max DC in the neighbors pixels
+	for (Int_t j=0; j < pix->GetNumNeighbors(); j++)
+	{
+	    evt->GetPixelContent(tempDC,pix->GetNeighbor(j),geomcam,0);
+	    if(tempDC > maxDC) 
+		maxDC = tempDC;
+	}
+	
+	// a starting pixel was found: it is added to the array
+	if ((currDC>maxDC) && (currDC>DCthr))
+	{
+	    startpixs->ResizeTo(++i);
+	    startpixs(i-1)=pixid;
+	    cout << "Starting pixel PixID=" << startpixs(i-1) << " curr=" << currDC << endl;
+	}
+    }
+    
+    if(startpixs->GetNrows()>0)
+    {
+	cout << "Number of starting pixels = " << startpixs->GetNrows() << endl;
+	return 1;
+    }
+    else
+	return 0;
+}
+/*
+Int_t FindCluster(Int_t startpix, Int_t cluster, MGeomCam *geom)
+{
+  return 1;
+
+}
+*/
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/macros/HillasAnal.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/macros/HillasAnal.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/macros/HillasAnal.C	(revision 9661)
@@ -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@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////////
+//
+// MagicHillas.C
+// =============
+//
+// This is a demonstration program which calculates image (Hillas +)
+// parameters using as input a Merpp output file (raw data).
+// All parameters are written to an output file called hillas.root. Also
+// filles histograms are displayed.
+// For the calculation an arbitrary signal extractor (MCerPhotAnal2/Calc)
+// is used.
+//
+///////////////////////////////////////////////////////////////////////////
+
+void HillasAnal(const char *filename="output_test.root")
+{
+    //
+    // Create a empty Parameter List and an empty Task List
+    // The tasklist is identified in the eventloop by its name
+    //
+    MParList plist;
+
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    //
+    // Use this if you want to change the binning of one of
+    // the histograms. You can use:
+    // BinningConc, BinningConc1, BinningAsym, BinningM3Long,
+    // BinningM3Trans, BinningWidth, BinningLength, BinningDist,
+    // BinningHeadTail, BinningAlpha, BinningSize, BinningDelta,
+    // BinningPixels and BinningCamera
+    //
+    // For more information see MBinning and the corresponding
+    // histograms
+    //
+    // MBinning binsalpha("BinningAlpha");
+    // binsalpha.SetEdges(90, 0, 90);       // 90 bins from 0 to 90 deg
+    // plist.AddToList(&binsalpha);
+
+    // MBinning binssize("BinningSize");
+    // binssize.SetEdgesLog(50, 1, 1e7);
+    // plist.AddToList(&binssize);
+
+    //
+    // Craete the object which hlods the source positions in the camera
+    // plain in respect to which the image parameters will be calculated.
+    // For real data the containers will be filled by a task.
+    //
+    MSrcPosCam source;
+    source.SetReadyToSave();
+    plist.AddToList(&source);
+
+    //
+    // Now setup the tasks and tasklist:
+    // ---------------------------------
+    //
+    // The first argument is the tree you want to read.
+    //   Events:     Cosmic ray events
+    //   PedEvents:  Pedestal Events
+    //   CalEvents:  Calibration Events
+    //
+    MReadMarsFile read("Events", filename);
+    read.DisableAutoScheme();
+
+    // Setup a task which makes sure that all used arrays have
+    // the correct size
+    MGeomApply geomapl;
+
+    // tasks used if MC files are detected to calculate pedestals
+    // MMcPedestalCopy pcopy;
+    // MMcPedestalNSBAdd pnsb;
+
+    // calculate the signal in a very simple way
+    // for real adat files use MCerPhotAnal2 instead which also
+    // calculates the pedestal.
+    // MCerPhotCalc ncalc;
+    //
+    //  Alternative photon calculation:
+    //  Example: use only 2nd to 6th FADC slices for photon calculation:
+    //
+    //    const Float_t x[15]={0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+    //    const TArrayF w(15,(Float_t*)x);
+    //    ncalc.SetWeights(w);
+    //
+
+    // setup image cleaning and blind pixel treatment
+    MImgCleanStd    clean;
+    MBlindPixelCalc blind;
+
+    //
+    // Instead of unmapping the pixels you can also (The use of this
+    // class is deprecated, it will be replaced by MBadPixels*)
+    //
+    // blind.SetUseInterpolation();
+    // blind.SetUseCetralPixel();
+    //
+
+    // setup tasks to calculate image parameters
+    MHillasCalc    hcalc;
+    MHillasSrcCalc csrc1;
+
+    // setup tasks to fill histograms
+    MFillH hfill1("MHHillas", "MHillas");
+    MFillH hfill2("MHHillasExt");
+    MFillH hfill3("MHStarMap", "MHillas");
+    MFillH hfill4("HistExtSource [MHHillasExt]", "MHillasSrc");
+    MFillH hfill5("HistSource [MHHillasSrc]", "MHillasSrc");
+    //MFillH hfill6("MHNewImagePar");
+
+    // setup task to write containers to a file
+    MWriteRootFile write("hillas_Mrk421.root");
+    write.AddContainer("MHillas");
+    write.AddContainer("MHillasExt");
+    write.AddContainer("MHillasSrc");
+    write.AddContainer("MRawEvtHeader");
+    write.AddContainer("MRawRunHeader");
+    //write.AddContainer("HistExtSource");
+    //write.AddContainer("MHNewImagePar");
+
+    // Setup the contents of zour tasklist
+    tlist.AddToList(&read);
+    tlist.AddToList(&geomapl);
+    //tlist.AddToList(&pcopy);
+    //tlist.AddToList(&pnsb);
+    //tlist.AddToList(&ncalc);
+    tlist.AddToList(&clean);
+    tlist.AddToList(&blind);
+
+    tlist.AddToList(&hcalc);
+    tlist.AddToList(&csrc1);
+
+    tlist.AddToList(&hfill1);
+    tlist.AddToList(&hfill2);
+    tlist.AddToList(&hfill3);
+    tlist.AddToList(&hfill4);
+    tlist.AddToList(&hfill5);
+    //tlist.AddToList(&hfill6);
+    tlist.AddToList(&write);
+
+    //
+    // Create and setup the eventloop
+    //
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    //
+    // Execute your analysis
+    //
+    MProgressBar bar;
+    evtloop.SetProgressBar(&bar);
+    if (!evtloop.Eventloop())
+        return;
+
+    tlist.PrintStatistics();
+
+    //
+    // After the analysis is finished we can display the histograms
+    //
+    plist.FindObject("MHHillas")->DrawClone();
+    plist.FindObject("MHHillasExt")->DrawClone();
+    plist.FindObject("MHStarMap")->DrawClone();
+    plist.FindObject("HistSource")->DrawClone();
+    plist.FindObject("HistExtSource")->DrawClone();
+    //plist.FindObject("MHNewImagePar")->DrawClone();
+}
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/macros/first_ana.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/macros/first_ana.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/macros/first_ana.C	(revision 9661)
@@ -0,0 +1,125 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Alessio Piccioli, 04/2004 <mailto:alessio.piccioli@pi.infn.it>
+!   Author(s): Antonio Stamerra, 04/2004 <mailto:antonio.stamerra@pi.infn.it>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////////
+//
+// first_ana.C
+// =============
+//
+//  This macro produces a ON/OFF plot using the alpha HillasSrc branch
+//  taken from an analysis file produced by the AnalisiHillas.C macro
+//  The significance of excess events is also computed (simple calculation,
+//   no Li-Ma)
+//
+///////////////////////////////////////////////////////////////////////////
+
+
+Float_t degTomm ( Float_t deg ) {
+  return deg / 57.29577951 * 17000 ;
+}
+
+Int_t first_ana ( Char_t *fNameOn = "crab.root" , Char_t *fNameOff = "offcrab.root" , Float_t minsize = 1000 , Float_t minWdeg = 0.00 , Float_t maxWdeg = 0.125 , Float_t minLdeg = 0.0 , Float_t maxLdeg = 0.26 , Float_t minDdeg = 0.2 , Float_t maxDdeg = 0.8 ) {
+
+  TFile *fileOn = new TFile ( fNameOn , "READ" ) ;
+  TFile *fileOff = new TFile ( fNameOff , "READ" ) ;
+
+  TTree *treeOn = (TTree *) fileOn -> Get ( "Parameters" ) ;
+  TTree *treeOff = (TTree *) fileOff -> Get ( "Parameters" ) ;
+
+  TString title ;
+
+  title = "Abs(Alpha) plot ON-Source" ;
+  TH1D *absalphaOn = new TH1D ( "absalphaOn" , title , 9 , 0 , 90 ) ;
+
+  title = "Abs(Alpha) plot ON-Source" ;
+  TH1D *absalphaOff = new TH1D ( "absalphaOff" , title , 9 , 0 , 90 ) ;
+
+  TString scut ;
+  scut = "MHillas.fSize>" ;
+  scut += minsize ;
+  cout << "CUT ON SIZE: " << scut << endl ;
+  TCut Scut = scut ; 
+
+  scut = "" ;
+  scut += degTomm(minWdeg) ;
+  scut += " < MHillas.fWidth && MHillas.fWidth < " ;
+  scut += degTomm(maxWdeg) ;
+  cout << "CUT ON WIDTH: " << scut << endl ;
+  TCut Wcut = scut ; 
+
+  scut = "" ;
+  scut += degTomm(minLdeg) ;
+  scut += " < MHillas.fLength && MHillas.fLength < " ;
+  scut += degTomm(maxLdeg) ;
+  cout << "CUT ON LENGTH: " << scut << endl ;
+  TCut Lcut = scut ; 
+
+  scut = "" ;
+  scut += degTomm(minDdeg) ;
+  scut += " < MHillasSrc.fDist && MHillasSrc.fDist < " ;
+  scut += degTomm(maxDdeg) ;
+  cout << "CUT ON DIST: " << scut << endl ;
+  TCut Dcut = scut ; 
+
+  treeOn -> Draw ( "abs(MHillasSrc.fAlpha)>>absalphaOn" , Scut && Wcut && Lcut && Dcut ) ; 
+  treeOff -> Draw ( "abs(MHillasSrc.fAlpha)>>absalphaOff" , Scut && Wcut && Lcut && Dcut ) ;
+  Double_t alpha = absalphaOn -> Integral ( 4 , 9 ) / absalphaOff -> Integral ( 4 , 9 ) ;
+  Double_t evoff = absalphaOff -> Integral ( 1 , 3 ) ;
+
+  absalphaOff -> Scale ( alpha ) ;
+
+  Double_t fakeMax = absalphaOn -> GetMaximum ( ) ;
+  fakeMax *= 1.1 ;
+
+  Double_t fakeMin = absalphaOn -> GetMinimum ( ) ;
+  fakeMin *= 0.8 ;
+
+  TH2D *fake = new TH2D ( "fake" , "Mrk421 Sample B (ON/OFF) 15/02/2004" , 100 , 0 , 90 , 100 , fakeMin , fakeMax ) ;
+  fake -> GetXaxis ( ) -> SetTitle ( "Parameter Alpha (deg)" ) ;
+  fake -> GetYaxis ( ) -> SetTitle ( "NUmber of Events" ) ;
+  fake -> GetYaxis ( ) -> SetTitleOffset ( 1.3 ) ;
+  fake -> SetStats ( 0 ) ;
+
+  TCanvas *c = new TCanvas ( "c" , "Alpha Canvas" , 800 , 600 ) ;
+  c -> SetGridx ( ) ;
+  c -> SetGridy ( ) ;
+  
+  absalphaOn -> SetMarkerStyle ( 22 ) ;
+  absalphaOn -> SetMarkerSize ( 2.7 ) ;
+  absalphaOff -> SetFillStyle ( 1001 ) ;
+  absalphaOff -> SetFillColor ( 3 ) ;
+
+  fake -> Draw ( ) ;
+  absalphaOff -> Draw ( "SAME" ) ;
+  absalphaOn -> Draw ( "SAMEE1" ) ;
+
+  Double_t evon = absalphaOn -> Integral ( 1 , 3 ) ;
+
+  cout << endl << "EntriesON:" << absalphaOn -> GetEntries ( ) ;
+  cout << endl << "EntriesOFF:" << absalphaOff -> GetEntries ( ) ;
+  cout << endl << "ON:" << evon << " OFF:" << evoff << " EXCESS:" << evon-evoff*alpha << " SIGMA:" << (evon-evoff*alpha)/TMath::Sqrt(evoff)/alpha << endl << endl ;
+  
+}
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/macros/pedestalstudies_pisa.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/macros/pedestalstudies_pisa.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/macros/pedestalstudies_pisa.C	(revision 9661)
@@ -0,0 +1,685 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug, 04/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+//////////////////////////////////////////////////////////////////////////////
+//
+// pedestalstudies_pisa.C
+//
+// macro to study the pedestal and pedestalRMS with the number of FADC 
+// slices summed up. 
+//
+/////////////////////////////////////////////////////////////////////////////////
+const TString pedfile = "/data0/Temp/20040422_23203_P_Mrk421_E.root";
+
+void pedestalstudies_pisa(const TString pedname=pedfile, Int_t pixin=0, Int_t pixout=397,TString f2="",TString f3="",TString f4="",TString f5="")
+{
+
+  Int_t loops = 1;
+  Int_t stepsize = 2;
+
+  gStyle->SetOptStat(1111);
+  gStyle->SetOptFit();
+  
+  TArrayF *hmeandiffinn = new TArrayF(loops);
+  TArrayF *hrmsdiffinn  = new TArrayF(loops);
+  TArrayF *hmeandiffout = new TArrayF(loops);
+  TArrayF *hrmsdiffout  = new TArrayF(loops);
+  TArrayF *hmeaninn  = new TArrayF(loops);
+  TArrayF *hmeanout  = new TArrayF(loops);
+  TArrayF *hrmsinn   = new TArrayF(loops);
+  TArrayF *hrmsout   = new TArrayF(loops);
+  TArrayF *hmuinn    = new TArrayF(loops);
+  TArrayF *hmuout    = new TArrayF(loops);
+  TArrayF *hsigmainn = new TArrayF(loops);
+  TArrayF *hsigmaout = new TArrayF(loops);
+
+  TArrayF *hmeandiffinnerr = new TArrayF(loops);
+  TArrayF *hrmsdiffinnerr  = new TArrayF(loops);
+  TArrayF *hmeandiffouterr = new TArrayF(loops);
+  TArrayF *hrmsdiffouterr  = new TArrayF(loops);
+  TArrayF *hmeaninnerr  = new TArrayF(loops);
+  TArrayF *hmeanouterr  = new TArrayF(loops);
+  TArrayF *hrmsinnerr   = new TArrayF(loops);
+  TArrayF *hrmsouterr   = new TArrayF(loops);
+  TArrayF *hmuinnerr    = new TArrayF(loops);
+  TArrayF *hmuouterr    = new TArrayF(loops);
+  TArrayF *hsigmainnerr = new TArrayF(loops);
+  TArrayF *hsigmaouterr = new TArrayF(loops);
+
+
+  MStatusDisplay *display = new MStatusDisplay;
+  display->SetUpdateTime(500);
+  display->Resize(850,700);
+      
+  //
+  // Create a empty Parameter List and an empty Task List
+  // The tasklist is identified in the eventloop by its name
+  //
+  MParList  plist;
+  MTaskList tlist;
+  plist.AddToList(&tlist);
+
+  TString tabname="";
+
+  for (Int_t samples=2; samples < stepsize*loops+1; samples=samples+stepsize)
+    {
+
+      plist.Reset();
+      tlist.Reset();
+      
+      //
+      // Now setup the tasks and tasklist for the pedestals:
+      // ---------------------------------------------------
+      //
+      
+      MReadMarsFile read("Events", pedname);
+      read.DisableAutoScheme();
+     
+	Int_t neventi;
+ 	neventi=1000;
+
+	Float_t samplingRate=500;	//Hz
+	if (f2!=""){
+	read.AddFile(f2);
+	neventi += 1000;
+	}
+
+	if (f3!=""){
+	read.AddFile(f3);
+	neventi += 1000;
+	}
+
+	if (f4!=""){
+	read.AddFile(f4);
+	neventi += 1000;
+	}
+
+	if (f5!=""){
+	read.AddFile(f5);
+	neventi += 1000;
+	}
+
+	const Int_t NEvt = neventi;
+	cout << "E" <<neventi<< " NEvt:" << NEvt << endl;
+	Float_t timevt[NEvt];
+
+      MGeomApply      geomapl;
+      //
+      // Set the extraction range higher:
+      //		
+      //MExtractFixedWindow sigcalc;
+      //MExtractSignal3 sigcalc;
+      	MExtractSlidingWindow sigcalc;
+      sigcalc.SetRange(0,samples-1,0,1);
+
+     
+  
+      MPedCalcPedRun pedcalc;
+      pedcalc.SetRange(0,samples-1,0,0);
+      pedcalc.SetWindowSize((Int_t)sigcalc.GetNumHiGainSamples());
+
+      //MPedCalcFromData pedcalc;
+      //pedcalc.SetfHiGainThreshold(100);
+
+      //
+      // Additionally to calculating the pedestals, 
+      // you can fill histograms and look at them
+      //
+      MFillH fill("MHPedestalCam", "MExtractedSignalCam");
+      tabname="PedCam ";
+      tabname += samples;
+      //fill.SetNameTab(Form("%s%2d","PedCam",samples));
+      fill.SetNameTab(tabname);
+
+      tlist.AddToList(&read);
+      tlist.AddToList(&geomapl);
+      tlist.AddToList(&sigcalc);
+      tlist.AddToList(&pedcalc);
+      tlist.AddToList(&fill);
+      
+      const MGeomCamMagic      geomcam;
+      MPedestalCam       pedcam;
+      MBadPixelsCam      badcam;
+      badcam.AsciiRead("badpixels.dat");  
+      
+      MHPedestalCam      hpedcam;
+      MCalibrationPedCam cpedcam;
+      
+      plist.AddToList(&geomcam);
+      plist.AddToList(&pedcam);
+      plist.AddToList(&hpedcam);
+      plist.AddToList(&cpedcam);
+      plist.AddToList(&badcam);
+      
+      //
+      // Create and setup the eventloop
+      //
+      MRawEvtHeader *evtheader;
+      MRawEvtData *fRawEvt;
+      TH1F *hpedevt = new TH1F("hpedevt","Pedestals Drift",NEvt,0,(Float_t)NEvt/samplingRate);
+      Bool_t rc;
+      MEvtLoop evtloop;
+      
+      evtloop.SetParList(&plist);
+      evtloop.SetDisplay(display);
+      //tlist.SetDisplay(display);
+      //
+      // Execute first analysis
+      //
+      //if (!evtloop.Eventloop())
+      //  return;
+      rc = evtloop.PreProcess();
+      
+      //while (tlist.Process())
+	//{
+	//cout << "bleah" << endl;
+	//}      
+//tlist.SetDisplay(display);
+
+       Int_t fNumHiGainSample=15;
+	Float_t peddata[NEvt];
+	Int_t evtan=0;
+
+      if (rc){
+          while (tlist.Process())
+          {
+            fRawEvt=(MRawEvtData *)plist.FindObject("MRawEvtData");
+            MRawEvtPixelIter pixel(fRawEvt);
+
+            Float_t ped=0;
+	    evtan++;
+
+ 	    while (pixel.Next())
+	     {
+
+ 	       const UInt_t idx    = pixel.GetPixelId();
+
+               // lista di pixel da sommare
+               if (idx >pixout || idx < pixin)
+		  continue;
+
+	        Byte_t *ptr = pixel.GetHiGainSamples();
+                const Byte_t *end = ptr + fNumHiGainSample;
+      
+                UInt_t sum = 0;
+	        UInt_t sqr = -1;
+
+	        do
+	          {
+	            sum += *ptr;
+	            //sqr += *ptr * *ptr;
+	          }
+	        while (++ptr != end);
+      
+                 ped += (Float_t)sum;
+
+                  //cout << " Pixel " << idx << " pede: " << ped << " --- ";
+                }
+ 
+               //rc = evtloop.Process(0);
+	       evtheader = (MRawEvtHeader *)plist.FindObject("MRawEvtHeader");
+
+             ped /= pixout-pixin+1;
+		Int_t evtn=evtheader->GetDAQEvtNumber();
+             evtn=evtan;
+
+//test
+	//ped =  150 + sin(((Float_t)evtn/16.-TMath::Floor(evtn/16))*6.28); 
+	//cout << ped << " ";
+	timeped = evtn/samplingRate;
+	timevt[evtn-1]=timeped;
+     
+        hpedevt->Fill(timeped,ped);
+
+            //	cout <<" evt:" << evtn;
+	     // Save pedestal in array for Fourier analysis
+	     peddata[evtn-1]=ped;
+          }
+      }
+      if (!evtloop.PostProcess()){
+          rc = kFALSE;
+          return;
+      }
+
+      TCanvas &p1 = display->AddTab("ped studies");
+      p1.Divide(1,2);
+      p1.cd(1);
+	hpedevt->GetXaxis()->SetTitle("Time (s)");
+//      hpedevt->Draw();
+
+	TGraph *drift = new TGraph(evtan,timevt,peddata);
+	drift->SetMarkerStyle(21);
+	drift->SetMarkerSize(0.25);
+	drift->GetXaxis()->SetTitle("time (s)");
+	drift->GetYaxis()->SetTitle(" pedestal");
+	drift->Draw("APL");
+
+
+      // Fourier analysis
+	// campionamento a 500Hz (1000 evt) => freq. max a 250Hz
+
+	MFFT pro;
+	TArrayF *pedarray = new TArrayF(NEvt,peddata);
+	TArrayF *fft; // array con risultato FFT 
+	fft = pro.RealFunctionFFT(pedarray);
+	Int_t nsample = (Int_t)(fft->GetSize()); 
+	
+	const Int_t NNEvt = nsample;
+
+	Float_t x[10000];
+	Float_t prova;
+	for (int i=0;i<NNEvt;i++)
+	 x[i]=(Float_t)i/(NNEvt/(samplingRate/2)); 
+
+	Float_t *ffty = fft->GetArray();
+        cout << "Szie:" << fft->GetSize();
+	ffty[0]=0.;
+	TGraph *gr = new TGraph(nsample,x,ffty);
+	p1.cd(2);
+	gr->GetXaxis()->SetTitle("Frequency (Hz)");
+	gr->SetMarkerStyle(20);
+	gr->SetMarkerSize(0.4);
+	gr->Draw("AP");		
+
+
+
+//-------------------------------
+
+
+      // Set status lines
+      display->SetStatusLine1(evtloop.GetName());
+      display->SetStatusLine2(rc ? "Done." : "Error!");
+      // Stop automatic update
+      display->StopUpdate();
+      // Reallow context menus
+      display->SetNoContextMenu(kFALSE);
+      // Reallow user to exit window by File menu
+      display->UnLock();
+      // 
+      // Look at one specific pixel, after all the histogram manipulations:
+      //
+      /*
+      MHGausEvents &hpix = hpedcam.GetAverageHiGainArea(0);
+      hpix.DrawClone("fourierevents");
+      
+      MHGausEvents &lpix = hpedcam.GetAverageHiGainArea(1);
+      lpix.DrawClone("fourierevents");
+
+      hpedcam[170].DrawClone("fourierevents");
+  
+      */
+
+      MHCamera dispped0  (geomcam, "Ped;Pedestal",       "Mean per Slice");
+      MHCamera dispped2  (geomcam, "Ped;PedestalRms",    "RMS per Slice");
+      MHCamera dispped4  (geomcam, "Ped;Mean",           "Fitted Mean per Slice");
+      MHCamera dispped6  (geomcam, "Ped;Sigma",          "Fitted Sigma per Slice");
+      MHCamera dispped9  (geomcam, "Ped;DeltaPedMean",   "Rel. Diff. Mean per Slice (Fit-Calc.)");
+      MHCamera dispped11 (geomcam, "Ped;DeltaRmsSigma",  "Rel. Diff. RMS per Slice (Fit-Calc.)");
+  
+      dispped0.SetCamContent(  pedcam, 0);
+      dispped0.SetCamError(    pedcam, 1);
+      dispped2.SetCamContent(  pedcam, 2);
+      dispped2.SetCamError(    pedcam, 3);
+      
+      dispped4.SetCamContent( hpedcam, 0);
+      dispped4.SetCamError(   hpedcam, 1);
+      dispped6.SetCamContent( hpedcam, 2);
+      dispped6.SetCamError(   hpedcam, 3);
+      dispped9.SetCamContent( hpedcam, 5);
+      dispped9.SetCamError(   hpedcam, 6);
+      dispped11.SetCamContent(hpedcam, 8);
+      dispped11.SetCamError(  hpedcam, 9);
+  
+      dispped0.SetYTitle("Calc. Pedestal per slice [FADC counts]");
+      dispped2.SetYTitle("Calc. Pedestal RMS per slice [FADC counts]");
+      dispped4.SetYTitle("Fitted Mean per slice [FADC counts]");
+      dispped6.SetYTitle("Fitted Sigma per slice [FADC counts]");
+      dispped9.SetYTitle("Rel. Diff. Pedestal per slice Fit-Calc [1]");
+      dispped11.SetYTitle("Rel. Diff. Pedestal RMS per slice Fit-Calc [1]");
+
+
+      // Histogram values
+      tabname="MeanRMS ";
+      tabname += samples;
+      //fill.SetNameTab(tabname);
+      TCanvas &b1 = display->AddTab(tabname);
+      b1.Divide(4,3);
+
+      CamDraw(b1,dispped0,1,4,*hmeaninn,*hmeanout,*hmeaninnerr,*hmeanouterr,samples,stepsize);
+      CamDraw(b1,dispped2,2,4,*hrmsinn,*hrmsout,*hrmsinnerr,*hrmsouterr,samples,stepsize);  
+      CamDraw(b1,dispped4,3,4,*hmuinn,*hmuout,*hmuinnerr,*hmuouterr,samples,stepsize);
+      CamDraw(b1,dispped6,4,4,*hsigmainn,*hsigmaout,*hsigmainnerr,*hsigmaouterr,samples,stepsize); 
+      
+      tabname="MeanRrmSamples ";
+      tabname += samples;
+      display->SaveAsGIF(3*((samples-1)/stepsize)+2,tabname);
+
+      // Differences
+      tabname="RelDiff ";
+      tabname += samples;
+      TCanvas &c4 = display->AddTab(tabname);
+      c4.Divide(2,3);
+      
+      CamDraw(c4,dispped9,1,2,*hmeandiffinn,*hmeandiffout,*hmeandiffinnerr,*hmeandiffouterr,samples,stepsize);
+      CamDraw(c4,dispped11,2,2,*hrmsdiffinn,*hrmsdiffout,*hrmsdiffinnerr,*hrmsdiffouterr,samples,stepsize); 
+
+      tabname="RelDiffSamples ";
+      tabname += samples;
+      display->SaveAsGIF(3*((samples-1)/stepsize)+3,tabname);
+
+   cout << "Loop N. " <<samples << " completed..." <<endl;
+
+    }
+
+  /*
+  TF1 *logg = new TF1("logg","[1]+TMath::Log(x-[0])",1.,30.,2);
+  logg->SetParameters(1.,3.5);
+  logg->SetParLimits(0,-1.,3.);
+  logg->SetParLimits(1,-1.,7.);
+  logg->SetLineColor(kRed);
+  */
+
+  TCanvas *canvas = new TCanvas("PedstudInner","Pedestal Studies Inner Pixels",600,900);
+  canvas->Divide(2,3);
+  canvas->cd(1);
+
+  TGraphErrors *gmeaninn = new TGraphErrors(hmeaninn->GetSize(),
+                                            CreateXaxis(hmeaninn->GetSize(),stepsize),hmeaninn->GetArray(),
+                                            CreateXaxisErr(hmeaninnerr->GetSize(),stepsize),hmeaninnerr->GetArray());
+  gmeaninn->Draw("A*");
+  gmeaninn->SetTitle("Calculated Mean per Slice Inner Pixels");
+  gmeaninn->GetXaxis()->SetTitle("Nr. added FADC slices");
+  gmeaninn->GetYaxis()->SetTitle("Calculated Mean per slice");
+  //  gmeaninn->Fit("pol0");
+  //  gmeaninn->GetFunction("pol0")->SetLineColor(kGreen);
+  //  //  gmeaninn->Fit(logg);
+
+  canvas->cd(2);
+
+  TGraphErrors *gmuinn = new TGraphErrors(hmuinn->GetSize(),
+                                          CreateXaxis(hmuinn->GetSize(),stepsize),hmuinn->GetArray(),
+                                          CreateXaxisErr(hmuinnerr->GetSize(),stepsize),hmuinnerr->GetArray());
+  gmuinn->Draw("A*");
+  gmuinn->SetTitle("Fitted Mean per Slice Inner Pixels");
+  gmuinn->GetXaxis()->SetTitle("Nr. added FADC slices");
+  gmuinn->GetYaxis()->SetTitle("Fitted Mean per Slice");
+  //  gmuinn->Fit("pol0");
+  //  gmuinn->GetFunction("pol0")->SetLineColor(kGreen);
+  //gmuinn->Fit(logg);
+
+
+  canvas->cd(3);
+
+  TGraphErrors *grmsinn = new TGraphErrors(hrmsinn->GetSize(),
+                                           CreateXaxis(hrmsinn->GetSize(),stepsize),hrmsinn->GetArray(),
+                                           CreateXaxisErr(hrmsinnerr->GetSize(),stepsize),hrmsinnerr->GetArray());
+  grmsinn->Draw("A*");
+  grmsinn->SetTitle("Calculated Rms per Slice Inner Pixels");
+  grmsinn->GetXaxis()->SetTitle("Nr. added FADC slices");
+  grmsinn->GetYaxis()->SetTitle("Calculated Rms per Slice");
+  //  //grmsinn->Fit("pol2");
+  //  //grmsinn->GetFunction("pol2")->SetLineColor(kRed);
+  //  grmsinn->Fit(logg);
+
+  canvas->cd(4);
+
+  TGraphErrors *gsigmainn = new TGraphErrors(hsigmainn->GetSize(),
+                                             CreateXaxis(hsigmainn->GetSize(),stepsize),hsigmainn->GetArray(),
+                                             CreateXaxisErr(hsigmainnerr->GetSize(),stepsize),hsigmainnerr->GetArray());
+  gsigmainn->Draw("A*");
+  gsigmainn->SetTitle("Fitted Sigma per Slice Inner Pixels");
+  gsigmainn->GetXaxis()->SetTitle("Nr. added FADC slices");
+  gsigmainn->GetYaxis()->SetTitle("Fitted Sigma per Slice");
+  //  //  gsigmainn->Fit("pol2");
+  //  //  gsigmainn->GetFunction("pol2")->SetLineColor(kRed);
+  //  gsigmainn->Fit(logg);
+
+  canvas->cd(5);
+
+  TGraphErrors *gmeandiffinn = new TGraphErrors(hmeandiffinn->GetSize(),
+                                                CreateXaxis(hmeandiffinn->GetSize(),stepsize),hmeandiffinn->GetArray(),
+                                                CreateXaxisErr(hmeandiffinnerr->GetSize(),stepsize),hmeandiffinnerr->GetArray());
+  gmeandiffinn->Draw("A*"); 
+  gmeandiffinn->SetTitle("Rel. Difference  Mean per Slice Inner Pixels");
+  gmeandiffinn->GetXaxis()->SetTitle("Nr. added FADC slices");
+  gmeandiffinn->GetYaxis()->SetTitle("Rel. Difference Mean per Slice");
+  //  //gmeandiffinn->Fit("pol2");
+  //  //gmeandiffinn->GetFunction("pol2")->SetLineColor(kBlue);
+  //  gmeandiffinn->Fit(logg);
+
+
+  canvas->cd(6);
+
+  TGraphErrors *grmsdiffinn = new TGraphErrors(hrmsdiffinn->GetSize(),
+                                               CreateXaxis(hrmsdiffinn->GetSize(),stepsize),hrmsdiffinn->GetArray(),
+                                               CreateXaxisErr(hrmsdiffinnerr->GetSize(),stepsize),hrmsdiffinnerr->GetArray());
+  grmsdiffinn->Draw("A*");
+  grmsdiffinn->SetTitle("Rel. Difference Sigma per Slice-RMS Inner Pixels");
+  grmsdiffinn->GetXaxis()->SetTitle("Nr. added FADC slices");
+  grmsdiffinn->GetYaxis()->SetTitle("Rel. Difference Sigma per Slice-RMS");
+  //  //grmsdiffinn->Fit("pol2");
+  //  //grmsdiffinn->GetFunction("pol2")->SetLineColor(kBlue);
+  //  grmsdiffinn->Fit(logg);
+
+  canvas->SaveAs("PedestalStudyInner.root");
+  canvas->SaveAs("PedestalStudyInner.ps");
+
+  TCanvas *canvas2 = new TCanvas("PedstudOut","Pedestal Studies Outer Pixels",600,900);
+  canvas2->Divide(2,3);
+  canvas2->cd(1);
+
+  TGraphErrors *gmeanout = new TGraphErrors(hmeanout->GetSize(),
+                                            CreateXaxis(hmeanout->GetSize(),stepsize),hmeanout->GetArray(),
+                                            CreateXaxisErr(hmeanouterr->GetSize(),stepsize),hmeanouterr->GetArray());
+  gmeanout->Draw("A*");
+  gmeanout->SetTitle("Calculated Mean per Slice Outer Pixels");
+  gmeanout->GetXaxis()->SetTitle("Nr. added FADC slices");
+  gmeanout->GetYaxis()->SetTitle("Calculated Mean per Slice");
+  //  gmeanout->Fit("pol0");
+  //  gmeanout->GetFunction("pol0")->SetLineColor(kGreen);
+  //gmeanout->Fit(logg);
+
+  canvas2->cd(2);
+
+  TGraphErrors *gmuout = new TGraphErrors(hmuout->GetSize(),
+                                          CreateXaxis(hmuout->GetSize(),stepsize),hmuout->GetArray(),
+                                          CreateXaxisErr(hmuouterr->GetSize(),stepsize),hmuouterr->GetArray());
+  gmuout->Draw("A*");
+  gmuout->SetTitle("Fitted Mean per Slice Outer Pixels");
+  gmuout->GetXaxis()->SetTitle("Nr. added FADC slices");
+  gmuout->GetYaxis()->SetTitle("Fitted Mean per Slice");
+  //  gmuout->Fit("pol0");
+  //  gmuout->GetFunction("pol0")->SetLineColor(kGreen);
+  //gmuout->Fit(logg);
+
+  canvas2->cd(3);
+
+  TGraphErrors *grmsout = new TGraphErrors(hrmsout->GetSize(),
+                                           CreateXaxis(hrmsout->GetSize(),stepsize),hrmsout->GetArray(),
+                                           CreateXaxisErr(hrmsouterr->GetSize(),stepsize),hrmsouterr->GetArray());
+  grmsout->Draw("A*");
+  grmsout->SetTitle("Calculated Rms per Slice Outer Pixels");
+  grmsout->GetXaxis()->SetTitle("Nr. added FADC slices");
+  grmsout->GetYaxis()->SetTitle("Calculated Rms per Slice");
+  //  //grmsout->Fit("pol2");
+  //  //grmsout->GetFunction("pol2")->SetLineColor(kRed);
+  //  grmsout->Fit(logg);
+
+  canvas2->cd(4);
+
+  TGraphErrors *gsigmaout = new TGraphErrors(hsigmaout->GetSize(),
+                                             CreateXaxis(hsigmaout->GetSize(),stepsize),hsigmaout->GetArray(),
+                                             CreateXaxisErr(hsigmaouterr->GetSize(),stepsize),hsigmaouterr->GetArray());
+  gsigmaout->Draw("A*");
+  gsigmaout->SetTitle("Fitted Sigma per Slice Outer Pixels");
+  gsigmaout->GetXaxis()->SetTitle("Nr. added FADC slices");
+  gsigmaout->GetYaxis()->SetTitle("Fitted Sigma per Slice");
+  //  //gsigmaout->Fit("pol2");
+  //  //gsigmaout->GetFunction("pol2")->SetLineColor(kRed);
+  //  gsigmaout->Fit(logg);
+
+
+  canvas2->cd(5);
+
+  TGraphErrors *gmeandiffout = new TGraphErrors(hmeandiffout->GetSize(),
+                                                CreateXaxis(hmeandiffout->GetSize(),stepsize),hmeandiffout->GetArray(),
+                                                CreateXaxisErr(hmeandiffouterr->GetSize(),stepsize),hmeandiffouterr->GetArray());
+  gmeandiffout->Draw("A*");
+  gmeandiffout->SetTitle("Rel. Difference  Mean per Slice Outer Pixels");
+  gmeandiffout->GetXaxis()->SetTitle("Nr. added FADC slices");
+  gmeandiffout->GetYaxis()->SetTitle("Rel. Difference Mean per Slice");
+  //  //gmeandiffout->Fit("pol2");
+  //w  //gmeandiffout->GetFunction("pol2")->SetLineColor(kBlue);
+  //  gmeandiffout->Fit(logg);
+
+  canvas2->cd(6);
+
+  TGraphErrors *grmsdiffout = new TGraphErrors(hrmsdiffout->GetSize(),
+                                               CreateXaxis(hrmsdiffout->GetSize(),stepsize),hrmsdiffout->GetArray(),
+                                               CreateXaxisErr(hrmsdiffouterr->GetSize(),stepsize),hrmsdiffouterr->GetArray());
+  grmsdiffout->Draw("A*");
+  grmsdiffout->SetTitle("Rel. Difference Sigma per Slice-RMS Outer Pixels");
+  grmsdiffout->GetXaxis()->SetTitle("Nr. added FADC slices");
+  grmsdiffout->GetYaxis()->SetTitle("Rel. Difference Sigma per Slice-RMS");
+  //  //grmsdiffout->Fit("pol2");
+  //  //grmsdiffout->GetFunction("pol2")->SetLineColor(kBlue);
+  //  grmsdiffout->Fit(logg);
+
+
+  canvas2->SaveAs("PedestalStudyOuter.root");
+  canvas2->SaveAs("PedestalStudyOuter.ps");
+
+
+}
+
+
+void CamDraw(TCanvas &c, MHCamera &cam, Int_t i, Int_t j, TArrayF &a1, TArrayF &a2, 
+             TArrayF &a1err, TArrayF &a2err, Int_t samp, Int_t stepsize)
+{
+
+  c.cd(i);
+  MHCamera *obj1=(MHCamera*)cam.DrawCopy("hist");
+  obj1->SetDirectory(NULL);
+  
+  c.cd(i+j);
+  obj1->Draw();
+  ((MHCamera*)obj1)->SetPrettyPalette();
+
+  c.cd(i+2*j);
+  TH1D *obj2 = (TH1D*)obj1->Projection();
+  obj2->SetDirectory(NULL);
+  
+  //      obj2->Sumw2();
+  obj2->Draw();
+  obj2->SetBit(kCanDelete);
+  
+  const Double_t min   = obj2->GetBinCenter(obj2->GetXaxis()->GetFirst());
+  const Double_t max   = obj2->GetBinCenter(obj2->GetXaxis()->GetLast());
+  const Double_t integ = obj2->Integral("width")/2.5066283;
+  const Double_t mean  = obj2->GetMean();
+  const Double_t rms   = obj2->GetRMS();
+  const Double_t width = max-min;
+  
+  if (rms == 0. || width == 0. )
+    return;
+  
+  TArrayI s0(6);
+  s0[0] = 6;
+  s0[1] = 1;
+  s0[2] = 2;
+  s0[3] = 3;
+  s0[4] = 4;
+  s0[5] = 5;
+  
+  TArrayI inner(1);
+  inner[0] = 0;
+  
+  TArrayI outer(1);
+  outer[0] = 1;
+      
+  // Just to get the right (maximum) binning
+  TH1D *half[2];
+  half[0] = obj1->ProjectionS(s0, inner, "Inner");
+  half[1] = obj1->ProjectionS(s0, outer, "Outer");
+
+  half[0]->SetDirectory(NULL);
+  half[1]->SetDirectory(NULL);
+  
+  for (int i=0; i<2; i++)
+    {
+      half[i]->SetLineColor(kRed+i);
+      half[i]->SetDirectory(0);
+      half[i]->SetBit(kCanDelete);
+      half[i]->Draw("same");
+      half[i]->Fit("gaus","Q+");
+
+      if (i==0)
+        {
+          a1[(samp-1)/stepsize] = half[i]->GetFunction("gaus")->GetParameter(1);
+          a1err[(samp-1)/stepsize] = half[i]->GetFunction("gaus")->GetParError(1);
+          if (a1err[(samp-1)/stepsize] > 3.)
+            a1err[(samp-1)/stepsize] = 1.;
+        }
+     if (i==1)
+       {
+         a2[(samp-1)/stepsize] = half[i]->GetFunction("gaus")->GetParameter(1);
+         a2err[(samp-1)/stepsize] = half[i]->GetFunction("gaus")->GetParError(1);
+          if (a2err[(samp-1)/stepsize] > 3.)
+            a2err[(samp-1)/stepsize] = 1.;
+       }
+    }
+  
+  
+}
+
+// -----------------------------------------------------------------------------
+// 
+// Create the x-axis for the event graph
+//
+Float_t *CreateXaxis(Int_t n, Int_t step)
+{
+
+  Float_t *xaxis = new Float_t[n];
+
+  for (Int_t i=0;i<n;i++)
+    xaxis[i] = 2. + step*i;
+
+  return xaxis;
+                 
+}
+
+// -----------------------------------------------------------------------------
+// 
+// Create the x-axis for the event graph
+//
+Float_t *CreateXaxisErr(Int_t n, Int_t step)
+{
+
+  Float_t *xaxis = new Float_t[n];
+
+  for (Int_t i=0;i<n;i++)
+    xaxis[i] = step/2.;
+
+  return xaxis;
+                 
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/macros/production.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/macros/production.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/macros/production.C	(revision 9661)
@@ -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): Hendrik Bartko, 03/2004 <mailto:hbartko@mppmu.mpg.de>
+!              Markus Gaug,    03/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////////
+//
+//   production.C
+//   ============
+//
+//   This macro takes calibration runs and pedestal runs
+//   to set pedestals and calibration factors
+//   Then raw data files are read and calibrated.
+//   The output file contains the calibrated data, pedestal subtracted,
+//   with the signal (in photons) for each pixels
+//
+//   input:  calibration file(s)
+//           pedestal file(s)
+//           raw data files
+//   
+//   output: root files with following containers (branches)
+//           - MCerPhotEvt
+//           - MPedestalCam
+//           - MCalibrationRelTimeCam
+//           - MCerPhotEvt
+//           - MRawEvtHeader
+//           - MBadPixelsCam
+//           - MPedPhotCam
+//
+///////////////////////////////////////////////////////////////////////////
+
+//
+// Set path for files and run numbers
+//
+const TString defpath = "/data1/earth/magic/data/Period014/rootdata/2004_02_15/";
+const TString defrout = "output_Mrk421_20040215.root";
+
+const Int_t defpedr [] = {17284};
+const Int_t defcalr [] = {17285};
+const Int_t defdatar[] = {17286,17287,17288,17289,17290,17291,17292,17293,
+			  17294,17295,17296,17297,17298,17299,17300,17301,
+			  17302,17303,17304,17305,17306,17307,17308,17309,
+			  17310,17311,17312,17313,17314,17315,17316,17317,
+			  17318,17319,17320,17321,17322,17323,17324,17325,
+			  17326,17327,17328,17329,17330,17331,17332,17333,
+			  17334,17335,17336,17337,17338,17339,17340,17341,
+			  17342,17343,17344,17345,17346,17347,17348,17349,
+			  17350,17351,17352,17353,17354,17355,17356,17357,
+			  17358,17359,17360,17361,17362,17363,17364,17365,
+			  17366,17367,17368,17369,17370,17371,17372,17373,
+			  17374,17375,17376,17377,17378,17379,17380,17381,
+			  17382,17383,17384,17385,17386,17387,17388,17389,
+			  17390,17391,17392,17393,17394,17395,17396,17397,
+			  17398,17399,17400,17401,17402,17403,17404,17405,
+			  17406,17407,17408,17409,17410,17411,17412,17413,
+			  17414,17415,17416,17417,17418,17419,17420,17421,
+			  17422,17423,17424,17425,17426,17427,17428,17429,
+			  17430,17431,17432,17433,17434,17435,17436,17437,
+			  17438,17439,17440,17441,17442,17443,17444,17445,
+			  17446,17447,17448,17449,17450,17451,17452,17453,
+			  17454,17455,17456};
+
+
+void production(const TString inpath=defpath, 
+                    const Int_t psize=1, const Int_t pedruns[]=defpedr, 
+                    const Int_t csize=1, const Int_t calruns[]=defcalr, 
+                    const Int_t dsize=171, const Int_t dataruns[]=defdatar, 
+                    const TString resname=defrout)
+
+{
+
+  MExtractSlidingWindow extractor;
+
+  MRunIter pruns;
+  MRunIter cruns;
+  MRunIter druns;
+  
+  for (Int_t i=0;i<psize;i++) {
+    cout << "Adding pedestal run: " << pedruns[i] << endl;
+    pruns.AddRun(pedruns[i],inpath);
+  }
+  for (Int_t i=0;i<csize;i++) {
+    cout << "Adding calibration run: " << calruns[i] << endl;
+    cruns.AddRun(calruns[i],inpath);
+  }
+  for (Int_t i=0;i<dsize;i++) {
+    cout << "Adding data run: " << dataruns[i] << endl;
+    druns.AddRun(dataruns[i],inpath);
+  }
+
+
+  MStatusDisplay *display = new MStatusDisplay;
+  display->SetUpdateTime(3000);
+  display->Resize(850,700);
+
+  gStyle->SetOptStat(1111);
+  gStyle->SetOptFit();
+
+  /************************************/
+  /* FIRST LOOP: PEDESTAL COMPUTATION */
+  /************************************/
+  
+  MParList plist1;
+  MTaskList tlist1;
+  plist1.AddToList(&tlist1);
+  
+  // containers
+  MPedestalCam   pedcam;
+  MBadPixelsCam  badcam;
+  //
+  // for excluding pixels from the beginning:
+  //
+  // badcam.AsciiRead("badpixels.dat");
+
+
+  plist1.AddToList(&pedcam);
+  plist1.AddToList(&badcam);
+    
+  //tasks
+  MReadMarsFile  read("Events");
+  read.DisableAutoScheme();
+  static_cast<MRead&>(read).AddFiles(pruns);
+
+  MGeomApply     geomapl;
+  MPedCalcPedRun pedcalc;
+  MGeomCamMagic  geomcam;
+    
+  tlist1.AddToList(&read);
+  tlist1.AddToList(&geomapl);
+  tlist1.AddToList(&pedcalc);
+
+  // Create and execute the event looper
+  MEvtLoop pedloop;
+  pedloop.SetParList(&plist1);
+  pedloop.SetDisplay(display);
+
+  cout << "*************************" << endl;
+  cout << "** COMPUTING PEDESTALS **" << endl;
+  cout << "*************************" << endl;
+
+  if (!pedloop.Eventloop())
+    return;
+  
+  tlist1.PrintStatistics();
+
+  // 
+  // Now the short version: 
+  //
+  //
+  // Now setup the new tasks for the calibration:
+  // ---------------------------------------------------
+  //
+  MJCalibration     calloop;
+  calloop.SetInput(&cruns);
+  //  calloop.SetFullDisplay();
+  //
+  calloop.SetExtractor(&extractor);
+  //
+  // Set the corr. cams:
+  //
+  calloop.SetBadPixels(badcam);
+  //
+  // The next two commands are for the display:
+  //
+  calloop.SetDisplay(display);
+  
+  //
+  // Apply rel. time calibration:
+  //
+  calloop.SetRelTimeCalibration();
+  //
+  // Use as arrival time extractor MArrivalTimeCalc2:
+  //
+  calloop.SetArrivalTimeLevel(2);
+  
+  //
+  // Do the event-loop:
+  //
+  cout << "***************************" << endl;
+  cout << "** COMPUTING CALIBRATION **" << endl;
+  cout << "***************************" << endl;
+  
+  if (!calloop.Process(pedcam))
+    return;
+
+  badcam.Print();
+  
+  MBadPixelsCam          &badbad  = calloop.GetBadPixels();
+  MCalibrationChargeCam  &calcam  = calloop.GetCalibrationCam();
+  MCalibrationRelTimeCam &timecam = calloop.GetRelTimeCam();
+  MCalibrationQECam      &qecam   = calloop.GetQECam();
+
+  badbad.Print();
+
+  /************************************************************************/
+  /*                THIRD LOOP: DATA CALIBRATION INTO PHOTONS             */
+  /************************************************************************/
+
+  // Create an empty Parameter List and an empty Task List
+  MParList  plist3;  
+  MTaskList tlist3;
+  plist3.AddToList(&tlist3);
+ 
+  // containers
+  MCerPhotEvt         photevt;
+  MPedPhotCam         pedphotcam;
+  MSrcPosCam          srccam;
+  MRawRunHeader       runhead;
+  MExtractedSignalCam sigcam;
+
+  plist3.AddToList(&geomcam );
+  plist3.AddToList(&pedcam  );
+  plist3.AddToList(&calcam  );
+  plist3.AddToList(&qecam   );
+  plist3.AddToList(&badbad  );
+  plist3.AddToList(&timecam );
+  plist3.AddToList(&sigcam  );
+  plist3.AddToList(&photevt);
+  plist3.AddToList(&pedphotcam);
+  plist3.AddToList(&srccam);
+  plist3.AddToList(&runhead);
+
+  //tasks
+  MReadMarsFile read3("Events");
+  read3.DisableAutoScheme();
+  static_cast<MRead&>(read3).AddFiles(druns);
+
+  MArrivalTimeCalc2   timecalc;
+  MCalibrateData      photcalc;     
+  photcalc.SetCalibrationMode(MCalibrateData::kFfactor);  // !!! was only MCalibrate
+  // MPedPhotCalc     pedphotcalc;   // already done by MCalibrate Data
+  // MCerPhotCalc     cerphotcalc;  // already done by MCalibrate Data
+  
+  tlist3.AddToList(&read3);
+  tlist3.AddToList(&geomapl);
+  tlist3.AddToList(&extractor);
+  tlist3.AddToList(&timecalc);
+  //  tlist3.AddToList(&cerphotcalc); // already done by MCalibrate Data
+  tlist3.AddToList(&photcalc);
+  // tlist3.AddToList(&pedphotcalc);   // already done by MCalibrate Data
+
+  MWriteRootFile write(resname);
+  
+  write.AddContainer("MGeomCam"              , "RunHeaders");
+  write.AddContainer("MRawRunHeader"         , "RunHeaders");
+  write.AddContainer("MSrcPosCam"            , "RunHeaders");
+  write.AddContainer("MCalibrationChargeCam" , "RunHeaders");
+  write.AddContainer("MCalibrationQECam"     , "RunHeaders");
+  //  write.AddContainer("MPedPhotCam","RunHeaders"); // Attention, was in Events - Tree!!
+  write.AddContainer("MPedestalCam"          , "RunHeaders");
+  write.AddContainer("MCalibrationRelTimeCam", "RunHeaders");
+
+  write.AddContainer("MCerPhotEvt"   , "Events");
+  write.AddContainer("MRawEvtHeader" , "Events");
+  write.AddContainer("MBadPixelsCam" , "Events");
+  write.AddContainer("MPedPhotCam"   , "Events");
+
+  tlist3.AddToList(&write);
+  
+  // Create and execute eventloop
+  MEvtLoop evtloop3;
+  evtloop3.SetParList(&plist3);
+    
+  cout << "*************************************************************" << endl;
+  cout << "***   COMPUTING DATA USING EXTRACTED SIGNAL (IN PHOTONS)  ***" << endl;
+  cout << "*************************************************************" << endl;
+  
+  if (!evtloop3.Eventloop())  
+    return;  
+  tlist3.PrintStatistics();
+
+}
+
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/macros/production3.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/macros/production3.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/macros/production3.C	(revision 9661)
@@ -0,0 +1,373 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Javier López, 12/2003 <mailto:jlopez@ifae.es>
+!              Markus Gaug , 04/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+/////////////////////////////////////////////////////////////////////////////
+//
+//  bootcampstandardanalysis.C
+//
+//  Updated version of the macro designed at the Wuerzburg bootcamp and 
+//  compatible with the latest changes in Mars for general usage at the
+//  Udine bootcamp. 
+//
+//  Needs as arguments the run number of a pedestal file ("*_P_*.root"), 
+//  one of a calibration file ("*_C_*.root") and one of a data file 
+//  ("*_D_*.root"). Performs the pedestal calculation, the calibration 
+/// constants calculation and the calibration of the data. 
+//
+//  The TString inpath has to be set correctly.
+//
+//  The macro searches for the pulser colour which corresponds to the calibration
+//  run number. If the run number is smaller than 20000, pulser colour "CT1" 
+//  is assumed, otherwise, it searches for the strings "green", "blue", "uv" or 
+//  "ct1" in the filenames. If no colour or multiple colours are found, the 
+//  execution is aborted.  
+//
+//////////////////////////////////////////////////////////////////////////////////
+const Bool_t usedisplay = kTRUE;
+const TString defpath = "/data1/earth/magic/data/Period015/rootdata/2004_03_19/";
+const TString outpath = "./";
+const TString defrout = "output_Mrk421_20040319.root";
+// Mrk (13)
+const Int_t defpedr[] = {20823};
+//const Int_t defpedr [] = {20590,20593,20596,20599,20601,20602,20605,
+//			  20608,20611,20614,20649,20652,20654};
+// OffMrk (14)
+//const Int_t defpedr [] = {20617,20619,20621,20623,20625,20628,20630,
+//			  20632,20635,20637,20640,20643,20645,20647};
+
+
+//const Int_t defcalr [] = {20651};
+const Int_t defcalr [] = {20822};
+
+// Mrk (20)
+const Int_t defdatar[] = {20824};
+//const Int_t defdatar[] = {20591,20592,20594,20595,20597,20598,20600,
+//			  20603,20604,20606,20607,20609,20610,20612,
+//			  20613,20615,20616,20650,20653,20655};
+// OffMrk (18)
+// const Int_t defdatar[] = {20618,20620,20622,20624,20626,20627,20629,
+// 			  20631,20633,20634,20636,20638,20639,20641,
+//			  20642,20644,20646,20648};
+
+
+void production3(const TString inpath=defpath, 
+                    const Int_t psize=1, const Int_t pedruns[]=defpedr, 
+                    const Int_t csize=1, const Int_t calruns[]=defcalr, 
+                    const Int_t dsize=1, const Int_t dataruns[]=defdatar, 
+                    const TString resname=defrout)
+
+{
+
+  //
+  // Choose the signal Extractor:
+  //
+  //MExtractSlidingWindow extractor;
+  MExtractFixedWindowPeakSearch extractor;
+  //MExtractFixedWindow    extractor;   
+
+  //
+  // Set Ranges or Windows
+  //
+  extractor.SetRange(3,14,3,14);
+  //extractor.SetWindows(8,8);
+
+  //
+  // Choose the arrival time Extractor:
+  //
+  MExtractTimeFastSpline       timeext;
+  //  MExtractTimeHighestIntegral timeext;
+  //  MExtractTimeSpline          timeext;
+  //
+  // Set Ranges or Windows
+  //
+  timeext.SetRange(2,12,4,14);
+
+
+  MRunIter pruns;
+  MRunIter cruns;
+  MRunIter druns;
+
+  for (Int_t i=0;i<psize;i++) {
+    cout << "Adding pedestal run: " << pedruns[i] << endl;
+    pruns.AddRun(pedruns[i],inpath);
+  }
+  for (Int_t i=0;i<csize;i++) {
+    cout << "Adding calibration run: " << calruns[i] << endl;
+    cruns.AddRun(calruns[i],inpath);
+  }
+  for (Int_t i=0;i<dsize;i++) {
+    cout << "Adding data run: " << dataruns[i] << endl;
+    druns.AddRun(dataruns[i],inpath);
+  }
+
+  
+  //
+  // Now setup the tasks and tasklist for the pedestals:
+  // ---------------------------------------------------
+  //
+  MBadPixelsCam     badcam;
+  MGeomCamMagic     geomcam;
+  MGeomApply        geomapl;
+  //
+  // If you want to exclude pixels from the beginning, read 
+  // an ascii-file with the corr. pixel numbers (see MBadPixelsCam)
+  //
+  //  badcam.AsciiRead("badpixels.dat");
+  
+  /************************************/
+  /* FIRST LOOP: PEDESTAL COMPUTATION */
+  /************************************/
+
+  MJPedestal pedloop;
+  pedloop.SetInput(&pruns);
+  if (usedisplay)
+    {
+      MStatusDisplay *display = new MStatusDisplay;
+      display->SetUpdateTime(3000);
+      display->Resize(850,700);
+      pedloop.SetDisplay(display);
+    }
+  pedloop.SetBadPixels(badcam);
+  pedloop.SetExtractor(&extractor);
+
+  if (!pedloop.Process())
+    return;
+
+  /****************************************/
+  /* SECOND LOOP: CALIBRATION COMPUTATION */
+  /****************************************/
+
+  //
+  // Now setup the new tasks for the calibration:
+  // ---------------------------------------------------
+  //
+  MCalibrationQECam qecam;
+  MJCalibration     calloop;
+  calloop.SetInput(&cruns);
+  calloop.SetExtractor(&extractor);
+  //
+  // Apply rel. time calibration:
+  //
+  calloop.SetRelTimeCalibration();
+  calloop.SetTimeExtractor(&timeext);
+  //
+  // Set the corr. cams:
+  //
+  calloop.SetQECam(qecam);
+  calloop.SetBadPixels(pedloop.GetBadPixels());
+  //
+  // The next two commands are for the display:
+  //
+  if (usedisplay)
+      calloop.SetDisplay(display);
+  cout << "Minchia 0" << endl;
+  //
+  // Do the event-loop:
+  //
+  if (!calloop.Process(pedloop.GetPedestalCam()))
+    return;
+  
+  cout << "Minchia 1" << endl;
+  /*************************************/
+  /* THIRD LOOP: PEDESTAL CALIBRATION  */
+  /*************************************/
+
+  //
+  // Create a empty Parameter List and an empty Task List
+  //
+  MParList  plist3;
+  MTaskList tlist3;
+  plist3.AddToList(&tlist3);
+  cout << "Minchia 2" << endl;
+  //
+  // Now setup the tasks and tasklist to calculate the pedestal rms in number of photons
+  // -----------------------------------------------------------------------------------
+  //
+  
+  MCerPhotEvt    nphot;
+  MPedPhotCam    nphotrms;
+  
+  plist3.AddToList(&geomcam);
+  cout << "Minchia 3" << endl;
+  //
+  // Retrieve the cameras from the previous runs:
+  //
+  plist3.AddToList(&pedloop.GetPedestalCam());
+  plist3.AddToList(&calloop.GetCalibrationCam());
+  plist3.AddToList(&calloop.GetQECam());
+  plist3.AddToList(&calloop.GetRelTimeCam());
+  plist3.AddToList(&calloop.GetBadPixels());
+  plist3.AddToList(&nphot);
+  plist3.AddToList(&nphotrms);
+    cout << "Minchia 4" << endl;
+  //tasks
+  MReadMarsFile read3("Events");
+  read3.DisableAutoScheme();
+  static_cast<MRead&>(read3).AddFiles(pruns);  
+
+  //MCalibrate       photcalc;
+  MCalibrateData       photcalc;
+  photcalc.SetCalibrationMode(MCalibrate::kFfactor);
+  MPedPhotCalc  photrmscalc;  //It doesn't exist yet
+  
+  tlist3.AddToList(&read3);
+  tlist3.AddToList(&geomapl);
+  tlist3.AddToList(&extractor);
+  tlist3.AddToList(&photrmscalc);
+  //tlist3.AddToList(&photcalc);
+  
+  
+  //
+  // Create and setup the eventloop
+  //
+  MEvtLoop evtloop3;
+  evtloop3.SetParList(&plist3);
+  
+  //
+  // Execute first analysis
+  //
+  if (!evtloop3.Eventloop())
+    return;
+  
+  tlist3.PrintStatistics();
+  
+  /*************************************/
+  /* FOURTH LOOP: DATA CALIBRATION     */
+  /*************************************/
+
+  //
+  // Create a empty Parameter List and an empty Task List
+  //
+  MParList  plist4;
+  MTaskList tlist4;
+  plist4.AddToList(&tlist4);
+  
+  //
+  // Now setup the tasks and tasklist to analize the data
+  // -----------------------------------------------------
+  //
+  
+  plist4.AddToList(&geomcam);
+  //
+  // Retrieve the cameras from the previous runs:
+  //
+  plist4.AddToList(&pedloop.GetPedestalCam());
+  plist4.AddToList(&calloop.GetCalibrationCam());
+  plist4.AddToList(&calloop.GetQECam());
+  plist4.AddToList(&calloop.GetRelTimeCam());
+  plist4.AddToList(&calloop.GetBadPixels());
+  plist4.AddToList(&nphot);
+  plist4.AddToList(&nphotrms);
+
+  MArrivalTime times;
+  plist4.AddToList(&times);
+  
+  //tasks
+  MReadMarsFile read4("Events");
+  read4.DisableAutoScheme();
+  static_cast<MRead&>(read4).AddFiles(druns);  
+  
+  MArrivalTimeCalc2   timecalc;
+  MCalibrateRelTimes  timecal;
+
+  tlist4.AddToList(&read4);
+  tlist4.AddToList(&geomapl);
+  tlist4.AddToList(&extractor);
+  tlist4.AddToList(&timecalc);
+  tlist4.AddToList(&photcalc);
+  tlist4.AddToList(&timecal);
+  
+  //
+  // Create and setup the eventloop
+  //
+  MEvtLoop evtloop4;
+  evtloop4.SetParList(&plist4);
+
+  if (!evtloop4.PreProcess())
+    return;
+  
+  TCanvas *c1 = new TCanvas;
+  MHCamera disp1(geomcam);
+  disp1.SetPrettyPalette();
+  //disp1.SetInvDeepBlueSeaPalette()
+  disp1.Draw();
+  gPad->SetLogy();
+  gPad->cd(1);
+  
+  /*
+  TCanvas *c2 = new TCanvas;
+  MHCamera disp2(geomcam);
+  disp2.SetPrettyPalette();
+  //disp2.SetInvDeepBlueSeaPalette()
+  disp2.Draw();
+  gPad->SetLogy();
+  gPad->cd(1);
+  */
+  while (tlist4.Process())
+    {
+      disp1.SetCamContent(nphot);
+      
+      gPad->Modified();
+      gPad->Update();
+
+      /*    
+      disp2.SetCamContent(times);
+      
+      gPad->Modified();
+      gPad->Update();
+      */
+
+      // Remove the comments if you want to go through the file
+      // event-by-event:
+      if (!HandleInput())
+        break;
+    }
+
+  evtloop4.PostProcess();
+  
+}
+
+Bool_t HandleInput()
+{
+    TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
+
+    while (1)
+    {
+        //
+        // While reading the input process gui events asynchronously
+        //
+        timer.TurnOn();
+        TString input = Getline("Type 'q' to exit, <return> to go on: ");
+        timer.TurnOff();
+
+        if (input=="q\n")
+            return kFALSE;
+
+        if (input=="\n")
+            return kTRUE;
+    };
+
+    return kFALSE;
+}
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/macros/test_findstar.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/macros/test_findstar.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/macros/test_findstar.C	(revision 9661)
@@ -0,0 +1,98 @@
+// This macro creates a fake MCerPhotEvt container (with some clusters
+// that simulate the starfield seen by the DC currents) and then applies
+// the image cleaning and the Hillas algorithm to recognize and classify
+// the clusters.
+//
+void test_findstar();
+{
+  // Empty container and task lists
+  MParList plist;
+  MTaskList tlist;
+
+  //  cout << "0" <<endl;  
+  plist.AddToList(&tlist);
+
+  MCerPhotEvt *DCEvt;
+
+  MGeomCamMagic *geom; 
+
+  const Int_t gsNpix = 577;
+
+  TArrayF *startpixs(gsNpix);
+  Int_t cluster[gsNpix];
+  memset(cluster,-1,gsNpix*sizeof(Int_t));
+  memset(startpixs,-1,gsNpix*sizeof(Int_t));
+
+  // fill a fake MCerPhotEvt 
+
+// loop over all pixels
+  
+  for (Int_t pixid = 0; pixid <gsNpix ; pixid++)
+    {
+      MCerPhotPix dcpix =  DCEvt[pixid];
+
+      cout << "1" <<endl;  
+      // a fake cluster:
+      dcpix->SetNumPhotons(0.);
+      
+      switch (pixid)
+      {
+      case 10:
+	dcpix->SetNumPhotons(1.5);
+      case 3:
+	dcpix->SetNumPhotons(1.1);
+      case 9:
+	dcpix->SetNumPhotons(1.1);
+      case 22:
+	dcpix->SetNumPhotons(1.1);
+      case 23:
+	dcpix->SetNumPhotons(1.1);
+      case 24:
+	dcpix->SetNumPhotons(1.1);
+      case 11:
+	dcpix->SetNumPhotons(1.1);
+      };
+    }; // end loop over pixels
+
+  
+  if (!(FindStartPixels(DCEvt, startpixs, geom)))
+    cout << "Error calling the FindStartPixels function!!" << endl;
+  
+  return;
+};  
+
+Int_t FindStartPixels(MCerPhotEvt *evt, TArrayF *startpixs, MGeomCam *geom)
+{
+  // look for all the pixels with a DC higher than the DC of neighbour pixels 
+
+  // loop over all pixels
+  MCerPhotEvtIter Next(evt, kFALSE);
+  
+  for (Int_t pixid=0; pixid<gsNPix; pixid++)
+    {
+      MCerPhotPix dcpix =  DCEvt[pixid]; // curren pix with DC
+
+      const MGeomPix &pix = (*geom)[pixid]; // MGeomCam pixel
+      
+      currDC = dcpix->GetNumPhotons();  // DC of current pixel
+
+      // look for the max DC in the neighbors pixels
+      Float_t macDC = 0;
+      for (Int_t j=0; j<pix.GetNumNeighbors()-1; j++) 
+	if ( evt[pix.GetNeighbor(j)]->GetNumPhotons() > maxDC) 
+	  maxDC = evt[pix.GetNeighbor(j)]->GetNumPhotons();
+     
+      // a starting pixel was found: it is added to the array and the pointer
+      // to the array is increased by 1
+      if ( currDC > maxDC)
+	*(startpixs++) = currDC;
+    }
+
+  return 1;
+}
+
+Int_t FindCluster(Int_t startpix, Int_t cluster, MGeomCam *geom)
+{
+  return 1;
+
+} ;
Index: /tags/Mars_V0-8-5/Mars/mtemp/mpisa/macros/timedist3.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mpisa/macros/timedist3.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mpisa/macros/timedist3.C	(revision 9661)
@@ -0,0 +1,394 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Javier López, 12/2003 <mailto:jlopez@ifae.es>
+!              Markus Gaug , 04/2004 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+/////////////////////////////////////////////////////////////////////////////
+//
+//  bootcampstandardanalysis.C
+//
+//  Updated version of the macro designed at the Wuerzburg bootcamp and 
+//  compatible with the latest changes in Mars for general usage at the
+//  Udine bootcamp. 
+//
+//  Needs as arguments the run number of a pedestal file ("*_P_*.root"), 
+//  one of a calibration file ("*_C_*.root") and one of a data file 
+//  ("*_D_*.root"). Performs the pedestal calculation, the calibration 
+/// constants calculation and the calibration of the data. 
+//
+//  The TString inpath has to be set correctly.
+//
+//  The macro searches for the pulser colour which corresponds to the calibration
+//  run number. If the run number is smaller than 20000, pulser colour "CT1" 
+//  is assumed, otherwise, it searches for the strings "green", "blue", "uv" or 
+//  "ct1" in the filenames. If no colour or multiple colours are found, the 
+//  execution is aborted.  
+//
+//////////////////////////////////////////////////////////////////////////////////
+const Bool_t usedisplay = kTRUE;
+const TString defpath = "/data1/earth/magic/data/Period015/rootdata/2004_03_19/";
+const TString outpath = "./";
+const TString defrout = "output_Mrk421_20040319.root";
+// Mrk (13)
+const Int_t defpedr[] = {20823};
+//const Int_t defpedr [] = {20590,20593,20596,20599,20601,20602,20605,
+//			  20608,20611,20614,20649,20652,20654};
+// OffMrk (14)
+//const Int_t defpedr [] = {20617,20619,20621,20623,20625,20628,20630,
+//			  20632,20635,20637,20640,20643,20645,20647};
+
+
+//const Int_t defcalr [] = {20651};
+const Int_t defcalr [] = {20822};
+
+// Mrk (20)
+const Int_t defdatar[] = {20824};
+//const Int_t defdatar[] = {20591,20592,20594,20595,20597,20598,20600,
+//			  20603,20604,20606,20607,20609,20610,20612,
+//			  20613,20615,20616,20650,20653,20655};
+// OffMrk (18)
+// const Int_t defdatar[] = {20618,20620,20622,20624,20626,20627,20629,
+// 			  20631,20633,20634,20636,20638,20639,20641,
+//			  20642,20644,20646,20648};
+
+
+void timedist3(const TString inpath=defpath, 
+                    const Int_t psize=1, const Int_t pedruns[]=defpedr, 
+                    const Int_t csize=1, const Int_t calruns[]=defcalr, 
+                    const Int_t dsize=1, const Int_t dataruns[]=defdatar, 
+                    const TString resname=defrout)
+
+{
+
+  //
+  // Choose the signal Extractor:
+  //
+  //MExtractSlidingWindow extractor;
+  MExtractFixedWindowPeakSearch extractor;
+  //MExtractFixedWindow    extractor;   
+
+  //
+  // Set Ranges or Windows
+  //
+  extractor.SetRange(3,14,3,14);
+  //extractor.SetWindows(8,8);
+
+  //
+  // Choose the arrival time Extractor:
+  //
+  MExtractTimeFastSpline       timeext;
+  //  MExtractTimeHighestIntegral timeext;
+  //  MExtractTimeSpline          timeext;
+  //
+  // Set Ranges or Windows
+  //
+  timeext.SetRange(2,12,4,14);
+
+
+  MRunIter pruns;
+  MRunIter cruns;
+  MRunIter druns;
+
+  for (Int_t i=0;i<psize;i++) {
+    cout << "Adding pedestal run: " << pedruns[i] << endl;
+    pruns.AddRun(pedruns[i],inpath);
+  }
+  for (Int_t i=0;i<csize;i++) {
+    cout << "Adding calibration run: " << calruns[i] << endl;
+    cruns.AddRun(calruns[i],inpath);
+  }
+  for (Int_t i=0;i<dsize;i++) {
+    cout << "Adding data run: " << dataruns[i] << endl;
+    druns.AddRun(dataruns[i],inpath);
+  }
+
+  
+  //
+  // Now setup the tasks and tasklist for the pedestals:
+  // ---------------------------------------------------
+  //
+  MBadPixelsCam     badcam;
+  MGeomCamMagic     geomcam;
+  MGeomApply        geomapl;
+  //
+  // If you want to exclude pixels from the beginning, read 
+  // an ascii-file with the corr. pixel numbers (see MBadPixelsCam)
+  //
+  //  badcam.AsciiRead("badpixels.dat");
+  
+  /************************************/
+  /* FIRST LOOP: PEDESTAL COMPUTATION */
+  /************************************/
+
+  MJPedestal pedloop;
+  pedloop.SetInput(&pruns);
+  if (usedisplay)
+    {
+      MStatusDisplay *display = new MStatusDisplay;
+      display->SetUpdateTime(3000);
+      display->Resize(850,700);
+      pedloop.SetDisplay(display);
+    }
+  pedloop.SetBadPixels(badcam);
+  pedloop.SetExtractor(&extractor);
+
+  if (!pedloop.Process())
+    return;
+
+//   /****************************************/
+//   /* SECOND LOOP: CALIBRATION COMPUTATION */
+//   /****************************************/
+
+//   //
+//   // Now setup the new tasks for the calibration:
+//   // ---------------------------------------------------
+//   //
+//   MCalibrationQECam qecam;
+//   MJCalibration     calloop;
+//   calloop.SetInput(&cruns);
+//   calloop.SetExtractor(&extractor);
+//   //
+//   // Apply rel. time calibration:
+//   //
+//   calloop.SetRelTimeCalibration();
+//   calloop.SetTimeExtractor(&timeext);
+//   //
+//   // Set the corr. cams:
+//   //
+//   calloop.SetQECam(qecam);
+//   calloop.SetBadPixels(pedloop.GetBadPixels());
+//   //
+//   // The next two commands are for the display:
+//   //
+//   if (usedisplay)
+//       calloop.SetDisplay(display);
+//   cout << "Minchia 0" << endl;
+//   //
+//   // Do the event-loop:
+//   //
+//   if (!calloop.Process(pedloop.GetPedestalCam()))
+//     return;
+  
+//   cout << "Minchia 1" << endl;
+//   /*************************************/
+//   /* THIRD LOOP: PEDESTAL CALIBRATION  */
+//   /*************************************/
+
+//   //
+//   // Create a empty Parameter List and an empty Task List
+//   //
+//   MParList  plist3;
+//   MTaskList tlist3;
+//   plist3.AddToList(&tlist3);
+//   cout << "Minchia 2" << endl;
+//   //
+//   // Now setup the tasks and tasklist to calculate the pedestal rms in number of photons
+//   // -----------------------------------------------------------------------------------
+//   //
+  
+//   MCerPhotEvt    nphot;
+//   MPedPhotCam    nphotrms;
+  
+//   plist3.AddToList(&geomcam);
+//   cout << "Minchia 3" << endl;
+//   //
+//   // Retrieve the cameras from the previous runs:
+//   //
+//   plist3.AddToList(&pedloop.GetPedestalCam());
+//   plist3.AddToList(&calloop.GetCalibrationCam());
+//   plist3.AddToList(&calloop.GetQECam());
+//   plist3.AddToList(&calloop.GetRelTimeCam());
+//   plist3.AddToList(&calloop.GetBadPixels());
+//   plist3.AddToList(&nphot);
+//   plist3.AddToList(&nphotrms);
+//     cout << "Minchia 4" << endl;
+//   //tasks
+//   MReadMarsFile read3("Events");
+//   read3.DisableAutoScheme();
+//   static_cast<MRead&>(read3).AddFiles(pruns);  
+
+//   //MCalibrate       photcalc;
+//   MCalibrateData       photcalc;
+//   photcalc.SetCalibrationMode(MCalibrate::kFfactor);
+//   MPedPhotCalc  photrmscalc;  //It doesn't exist yet
+  
+//   tlist3.AddToList(&read3);
+//   tlist3.AddToList(&geomapl);
+//   tlist3.AddToList(&extractor);
+//   tlist3.AddToList(&photrmscalc);
+//   //tlist3.AddToList(&photcalc);
+  
+  
+//   //
+//   // Create and setup the eventloop
+//   //
+//   MEvtLoop evtloop3;
+//   evtloop3.SetParList(&plist3);
+  
+//   //
+//   // Execute first analysis
+//   //
+//   if (!evtloop3.Eventloop())
+//     return;
+  
+//   tlist3.PrintStatistics();
+  
+  /*************************************/
+  /* FOURTH LOOP: DATA CALIBRATION     */
+  /*************************************/
+
+  //
+  // Create a empty Parameter List and an empty Task List
+  //
+  MParList  plist4;
+  MTaskList tlist4;
+  plist4.AddToList(&tlist4);
+  
+  //
+  // Now setup the tasks and tasklist to analize the data
+  // -----------------------------------------------------
+  //
+  
+  plist4.AddToList(&geomcam);
+  //
+  // Retrieve the cameras from the previous runs:
+  //
+  plist4.AddToList(&pedloop.GetPedestalCam());
+  //  plist4.AddToList(&calloop.GetCalibrationCam());
+  // plist4.AddToList(&calloop.GetQECam());
+  // plist4.AddToList(&calloop.GetRelTimeCam());
+  //plist4.AddToList(&calloop.GetBadPixels());
+  //plist4.AddToList(&nphot);
+  //plist4.AddToList(&nphotrms);
+
+  MArrivalTimeCam times;
+  plist4.AddToList(&times);
+  
+  //tasks
+  MReadMarsFile read4("Events");
+  read4.DisableAutoScheme();
+  static_cast<MRead&>(read4).AddFiles(druns);  
+  
+  MArrivalTimeCalc2   timecalc;
+  //MCalibrateRelTimes  timecal;
+  
+  tlist4.AddToList(&read4);
+  tlist4.AddToList(&geomapl);
+  //tlist4.AddToList(&extractor);
+  tlist4.AddToList(&timecalc);
+  //  tlist4.AddToList(&photcalc);
+  //tlist4.AddToList(&timecal);
+  MRawEvtData *evtData;
+  //
+  // Create and setup the eventloop
+  //
+  MEvtLoop evtloop4;
+  evtloop4.SetParList(&plist4);
+  histTime = new TH1F("histTime","Arrival Time Dist",15,0.0,15.0);
+  Int_t i=0;
+  if (!evtloop4.PreProcess())
+    return;
+  
+  TCanvas *c1 = new TCanvas;
+  MHCamera disp1(geomcam);
+  disp1.SetPrettyPalette();
+  //disp1.SetInvDeepBlueSeaPalette()
+  disp1.Draw();
+  gPad->SetLogy();
+  gPad->cd(1);
+  
+  /*
+  TCanvas *c2 = new TCanvas;
+  MHCamera disp2(geomcam);
+  disp2.SetPrettyPalette();
+  //disp2.SetInvDeepBlueSeaPalette()
+  disp2.Draw();
+  gPad->SetLogy();
+  gPad->cd(1);
+  */
+  while (tlist4.Process())
+    {
+      i++;
+      //disp1.SetCamContent(nphot);
+      
+      //gPad->Modified();
+      //gPad->Update();
+      //      cout << i << endl;
+      //if((i == 16)||(i == 41)||(i == 111)||(i == 173)){
+      if((i == 41)){
+	cout << "Merda" << endl;
+	evtData = (MRawEvtData *)plist4->FindObject("MRawEvtData");
+	cout << "Merda1" << tlist4->FindObject("MRawEvtData") << endl;
+	MRawEvtPixelIter *pixIter = new MRawEvtPixelIter(evtData);
+	cout << "Merda2" << endl;
+	for (Int_t pix=1;pix<576;pix++){	  
+	  pixIter->Next();
+	  cout << "Merda3" << endl;
+	  if(pixIter->GetSumHiGainSamples()>200){
+	    cout << "Merda5" << endl;
+	    cout << "pix #" << pixIter->GetPixelId() << "  FADC Charge = " << pixIter->GetSumHiGainSamples() << endl;
+	    histTime->Fill((times[pix])->GetArrivalTimeHiGain());
+	  }
+	  cout << i << endl;
+	}
+      }
+      
+      /*    
+      disp2.SetCamContent(times);
+      
+      gPad->Modified();
+      gPad->Update();
+      */
+
+      // Remove the comments if you want to go through the file
+      // event-by-event:
+      //if (!HandleInput())
+      //break;
+    }
+
+  evtloop4.PostProcess();
+  histTime->DrawCopy();
+}
+
+Bool_t HandleInput()
+{
+    TTimer timer("gSystem->ProcessEvents();", 50, kFALSE);
+
+    while (1)
+    {
+        //
+        // While reading the input process gui events asynchronously
+        //
+        timer.TurnOn();
+        TString input = Getline("Type 'q' to exit, <return> to go on: ");
+        timer.TurnOff();
+
+        if (input=="q\n")
+            return kFALSE;
+
+        if (input=="\n")
+            return kTRUE;
+    };
+
+    return kFALSE;
+}
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/macros/singleCalib.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/macros/singleCalib.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/macros/singleCalib.C	(revision 9661)
@@ -0,0 +1,174 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug, 11/2003 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+/////////////////////////////////////////////////////////////////////////////
+//
+//  stdCalib.C
+//
+//  This macros is based on the calibration macro from Markus Gaug.
+//  It processes a Pedestal file and writes a file with the containers
+//
+//  Needed arguments are retrieved from the file "marsconfig".
+//  A typical config file looks like this:
+//   inpath:                  /data/MAGIC/Period015/rootdata/2004_03_21/
+//   outpath:                 /data/MAGIC/Period015/calibdata/2004_03_21/
+//   pedfile:                 21297
+//   calfile:                 21297
+//
+//  inpath:     is the path to the merpped root files
+//  outpath:    is the path where to store the F0 files
+//  pedfilexxx: specifies which pedestal files to use. If more then 1 file
+//              is specified, all files are processed but only 1 output file
+//              is written.
+//
+//  The macro searches for the pulser colour which corresponds to the calibration
+//  run number. If the run number is smaller than 20000, pulser colour "CT1"
+//  is assumed, otherwise, it searches for the strings "green", "blue", "uv" or
+//  "ct1" in the filenames. If no colour or multiple colours are found, the
+//  execution is aborted.
+//
+//  The container MBadPixelsCam is created and followed during the execution of the
+//  rest of the macro.
+//
+//  The container MCalibrationQECam is created and followed during the execution of the
+//  rest of the macro.
+//
+//  A loop over the calibration files is performed using the class MJCalibration.
+//  The call to MJCalibration skips the relative time calibration, which can be
+//  uncommented as well.
+//
+/////////////////////////////////////////////////////////////////////////////
+
+
+//
+// Tell if you want to calibrate times:
+//
+static const  Bool_t useTimes = kTRUE;
+//static const  Bool_t useTimes = kFALSE;
+
+void singleCalib()
+{
+
+  // turn of colors for logging to a file
+  gLog.SetNoColors();
+
+  // Get configuration from the "marsconfig" configuration file.
+//  TEnv env("marsconfig");
+
+  // Here we get the input and output directory paths from the configuration
+  // file
+//  const char* inpath = env.GetValue("inpath",".");
+//  const char* outpath = env.GetValue("outpath",".");
+//  Int_t prun = env.GetValue( "pedfile", 0);
+//  Int_t crun = env.GetValue( "calfile", 0);
+  const char* inpath = "/data/MAGIC/Period016/rootdata2/2004_04_16";
+  const char* outpath = "/data/MAGIC/Period016/calibdata/2004_04_16";
+  Int_t prun = 22351;
+  Int_t crun = 22323;
+
+
+  //
+  // Choose the signal Extractor:
+  //
+  //  MExtractFixedWindowPeakSearch extractor;
+  //  MExtractSlidingWindow  extractor;
+   MExtractFixedWindow    extractor;
+
+  //
+  // Set Ranges or Windows
+  //
+   extractor.SetRange(3,14,3,14);
+  //  extractor.SetWindows(8,8);
+
+  //
+  // Choose the arrival time Extractor:
+  //
+  //  MExtractTimeHighestIntegral timeext;
+  MExtractTimeFastSpline timeext;
+  //
+  // Set Ranges or Windows
+  //
+  timeext.SetRange(2,12,4,14);
+
+  MRunIter pruns;
+  MRunIter cruns;
+
+  pruns.AddRun(prun,inpath);
+  cruns.AddRun(crun,inpath);
+
+  gLog << "Perestal Runs: " << pruns.GetRunsAsString()  << " " << pruns.GetNumEntries() << endl;
+  gLog << "Calib Runs: " << cruns.GetRunsAsString()  << " " << cruns.GetNumEntries() << endl;
+
+  gStyle->SetOptStat(1);
+  gStyle->SetOptFit();
+
+  MStatusDisplay *display = new MStatusDisplay;
+  display->SetUpdateTime(3000);
+  display->Resize(850,700);
+
+  MCalibrationQECam qecam;
+  MBadPixelsCam     badcam;
+
+  //
+  // If you want to exclude pixels from the beginning, read
+  // an ascii-file with the corr. pixel numbers (see MBadPixelsCam)
+  //
+//  badcam.AsciiRead("badpixels.dat");
+
+
+  /************************************/
+  /* LOOP1: READ PEDESTAL INFORMATION */
+  /************************************/
+  MJPedestal    pedloop;
+  pedloop.SetInput(&pruns);
+  pedloop.SetOutputPath(outpath);       // This is needed to read the pedestal container file
+
+  if (!pedloop.Process())
+    return;
+
+  /**********************************/
+  /* LOOP2: CALIBRATION COMPUTATION */
+  /**********************************/
+  MJCalibration calloop;
+
+  //
+  // If you want to calibrate the times as well, choose:
+  //
+  calloop.SetRelTimeCalibration(useTimes);
+  calloop.SetExtractor(&extractor);
+  calloop.SetTimeExtractor(&timeext);
+  calloop.SetInput(&cruns);
+  calloop.SetOutputPath(outpath);
+  calloop.SetDisplay(display);
+  calloop.SetQECam(qecam);
+  calloop.SetBadPixels(pedloop.GetBadPixels());
+
+//  TObject::SetObjectStat(kTRUE);
+
+  calloop.Process(pedloop.GetPedestalCam());
+
+//  gObjectTable->Print();
+
+}
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/macros/singlePed.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/macros/singlePed.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/macros/singlePed.C	(revision 9661)
@@ -0,0 +1,120 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Martin Merck, 05/2004 <mailto:merck@astro.uni-wuerzburg.de>
+!              Markus Gaug, 11/2003 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+/////////////////////////////////////////////////////////////////////////////
+//
+//  stdPed.C
+//
+//  This macros is based on the calibration macro from Markus Gaug.
+//  It processes a Pedestal file and writes a file with the containers
+//
+//  Needed arguments are retrieved from the file "marsconfig".
+//  A typical config file looks like this:
+//   inpath:                  /data/MAGIC/Period015/rootdata/2004_03_21/
+//   outpath:                 /data/MAGIC/Period015/calibdata/2004_03_21/
+//   pedfile001:              21297
+//
+//  inpath:     is the path to the merpped root files
+//  outpath:    is the path where to store the F0 files
+//  pedfilexxx: specifies which pedestal files to use. If more then 1 file
+//              is specified, all files are processed but only 1 output file
+//              is written.
+//
+//  The macro loops over the pedestal file using the class MJPedestal
+//
+/////////////////////////////////////////////////////////////////////////////
+
+void singlePed()
+{
+  // turn of colors for logging to a file
+  gLog.SetNoColors();
+
+  const char* inpath = "/data/MAGIC/Period016/rootdata2/2004_04_16";
+  const char* outpath = "/data/MAGIC/Period016/calibdata/2004_04_16";
+  Int_t prun = 22351;
+
+  //
+  // Choose the signal Extractor:
+  //
+  //  MExtractFixedWindowPeakSearch extractor;
+  //  MExtractSlidingWindow  extractor;
+   MExtractFixedWindow    extractor;
+
+  //
+  // Set Ranges or Windows
+  //
+   extractor.SetRange(3,14,3,14);
+  //  extractor.SetWindows(8,8);
+
+  //
+  // Choose the arrival time Extractor:
+  //
+  //  MExtractTimeHighestIntegral timeext;
+  MExtractTimeFastSpline timeext;
+  //
+  // Set Ranges or Windows
+  //
+  timeext.SetRange(2,12,4,14);
+
+  // Get all pedestal files to process
+  // You can specify up to 999 files in the marsconfig file
+  // all files are concatenated and processed as one single file.
+  MRunIter pruns;
+  pruns.AddRun(prun,inpath);
+
+  gStyle->SetOptStat(1);
+  gStyle->SetOptFit();
+
+  // We do not use any display here.
+  MStatusDisplay *display = new MStatusDisplay;
+  display->SetUpdateTime(3000);
+  display->Resize(850,700);
+
+  /************************/
+  /* PEDESTAL COMPUTATION */
+  /************************/
+
+  MCalibrationQECam qecam;
+  MBadPixelsCam     badcam;
+  MGeomCamMagic     geomcam;
+  MGeomApply        geomapl;
+  //
+  // If you want to exclude pixels from the beginning, read
+  // an ascii-file with the corr. pixel numbers (see MBadPixelsCam)
+  //
+//  badcam.AsciiRead("badpixels.dat");
+
+  MJPedestal pedloop;
+  pedloop.SetExtractor(&extractor);
+  pedloop.SetInput(&pruns);
+  pedloop.SetOutputPath(outpath);
+  pedloop.SetDisplay(display);
+  pedloop.SetBadPixels(badcam);
+
+  if (!pedloop.Process())
+    return;
+
+}
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/macros/stdCalib.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/macros/stdCalib.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/macros/stdCalib.C	(revision 9661)
@@ -0,0 +1,167 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug, 11/2003 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+/////////////////////////////////////////////////////////////////////////////
+//
+//  stdCalib.C
+//
+//  This macros is based on the calibration macro from Markus Gaug.
+//  It processes a Pedestal file and writes a file with the containers
+//
+//  Needed arguments are retrieved from the file "marsconfig".
+//  A typical config file looks like this:
+//   inpath:                  /data/MAGIC/Period015/rootdata/2004_03_21/
+//   outpath:                 /data/MAGIC/Period015/calibdata/2004_03_21/
+//   pedfile:                 21297
+//   calfile:                 21297
+//
+//  inpath:     is the path to the merpped root files
+//  outpath:    is the path where to store the F0 files
+//  pedfilexxx: specifies which pedestal files to use. If more then 1 file
+//              is specified, all files are processed but only 1 output file
+//              is written.
+//
+//  The macro searches for the pulser colour which corresponds to the calibration
+//  run number. If the run number is smaller than 20000, pulser colour "CT1"
+//  is assumed, otherwise, it searches for the strings "green", "blue", "uv" or
+//  "ct1" in the filenames. If no colour or multiple colours are found, the
+//  execution is aborted.
+//
+//  The container MBadPixelsCam is created and followed during the execution of the
+//  rest of the macro.
+//
+//  The container MCalibrationQECam is created and followed during the execution of the
+//  rest of the macro.
+//
+//  A loop over the calibration files is performed using the class MJCalibration.
+//  The call to MJCalibration skips the relative time calibration, which can be
+//  uncommented as well.
+//
+/////////////////////////////////////////////////////////////////////////////
+
+
+//
+// Tell if you want to calibrate times:
+//
+static const  Bool_t useTimes = kTRUE;
+//static const  Bool_t useTimes = kFALSE;
+
+void stdCalib()
+{
+
+  // turn of colors for logging to a file
+  gLog.SetNoColors();
+
+  // Get configuration from the "marsconfig" configuration file.
+  TEnv env("marsconfig");
+
+  // Here we get the input and output directory paths from the configuration
+  // file
+  const char* inpath = env.GetValue("inpath",".");
+  const char* outpath = env.GetValue("outpath",".");
+  Int_t prun = env.GetValue( "pedfile", 0);
+  Int_t crun = env.GetValue( "calfile", 0);
+
+
+  //
+  // Choose the signal Extractor:
+  //
+  //  MExtractFixedWindowPeakSearch extractor;
+  //  MExtractSlidingWindow  extractor;
+   MExtractFixedWindow    extractor;
+
+  //
+  // Set Ranges or Windows
+  //
+   extractor.SetRange(3,14,3,14);
+  //  extractor.SetWindows(8,8);
+
+  //
+  // Choose the arrival time Extractor:
+  //
+  //  MExtractTimeHighestIntegral timeext;
+  MExtractTimeFastSpline timeext;
+  //
+  // Set Ranges or Windows
+  //
+  timeext.SetRange(2,12,4,14);
+
+  MRunIter pruns;
+  MRunIter cruns;
+
+  pruns.AddRun(prun,inpath);
+  cruns.AddRun(crun,inpath);
+
+  gStyle->SetOptStat(1);
+  gStyle->SetOptFit();
+
+  MStatusDisplay *display = new MStatusDisplay;
+  display->SetUpdateTime(3000);
+  display->Resize(850,700);
+
+  MCalibrationQECam qecam;
+  MBadPixelsCam     badcam;
+
+  //
+  // If you want to exclude pixels from the beginning, read
+  // an ascii-file with the corr. pixel numbers (see MBadPixelsCam)
+  //
+//  badcam.AsciiRead("badpixels.dat");
+
+
+  /************************************/
+  /* LOOP1: READ PEDESTAL INFORMATION */
+  /************************************/
+  MJPedestal    pedloop;
+  pedloop.SetInput(&pruns);
+  pedloop.SetOutputPath(outpath);       // This is needed to read the pedestal container file
+
+  if (!pedloop.Process())
+    return;
+
+  /**********************************/
+  /* LOOP2: CALIBRATION COMPUTATION */
+  /**********************************/
+  MJCalibration calloop;
+
+  //
+  // If you want to calibrate the times as well, choose:
+  //
+  calloop.SetRelTimeCalibration(useTimes);
+  calloop.SetExtractor(&extractor);
+  calloop.SetTimeExtractor(&timeext);
+  calloop.SetInput(&cruns);
+  calloop.SetOutputPath(outpath);
+  calloop.SetDisplay(display);
+  calloop.SetQECam(qecam);
+  calloop.SetBadPixels(pedloop.GetBadPixels());
+
+//  TObject::SetObjectStat(kTRUE);
+
+  calloop.Process(pedloop.GetPedestalCam());
+
+//  gObjectTable->Print();
+
+}
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/macros/stdPed.C
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/macros/stdPed.C	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/macros/stdPed.C	(revision 9661)
@@ -0,0 +1,132 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Martin Merck, 05/2004 <mailto:merck@astro.uni-wuerzburg.de>
+!              Markus Gaug, 11/2003 <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+/////////////////////////////////////////////////////////////////////////////
+//
+//  stdPed.C
+//
+//  This macros is based on the calibration macro from Markus Gaug.
+//  It processes a Pedestal file and writes a file with the containers
+//
+//  Needed arguments are retrieved from the file "marsconfig".
+//  A typical config file looks like this:
+//   inpath:                  /data/MAGIC/Period015/rootdata/2004_03_21/
+//   outpath:                 /data/MAGIC/Period015/calibdata/2004_03_21/
+//   pedfile001:              21297
+//
+//  inpath:     is the path to the merpped root files
+//  outpath:    is the path where to store the F0 files
+//  pedfilexxx: specifies which pedestal files to use. If more then 1 file
+//              is specified, all files are processed but only 1 output file
+//              is written.
+//
+//  The macro loops over the pedestal file using the class MJPedestal
+//
+/////////////////////////////////////////////////////////////////////////////
+
+void stdPed()
+{
+  // turn of colors for logging to a file
+  gLog.SetNoColors();
+
+  // Get configuration from the "marsconfig" configuration file.
+  TEnv env("marsconfig");
+
+  // Here we get the input and output directory paths from the configuration
+  // file
+  const char* inpath = env.GetValue("inpath",".");
+  const char* outpath = env.GetValue("outpath",".");
+
+  //
+  // Choose the signal Extractor:
+  //
+  //  MExtractFixedWindowPeakSearch extractor;
+  //  MExtractSlidingWindow  extractor;
+   MExtractFixedWindow    extractor;
+
+  //
+  // Set Ranges or Windows
+  //
+   extractor.SetRange(3,14,3,14);
+  //  extractor.SetWindows(8,8);
+
+  //
+  // Choose the arrival time Extractor:
+  //
+  //  MExtractTimeHighestIntegral timeext;
+  MExtractTimeFastSpline timeext;
+  //
+  // Set Ranges or Windows
+  //
+  timeext.SetRange(2,12,4,14);
+
+  // Get all pedestal files to process
+  // You can specify up to 999 files in the marsconfig file
+  // all files are concatenated and processed as one single file.
+  MRunIter pruns;
+  char str[11];
+  for( Int_t i = 1 ; i<1000; i++)
+  {
+     sprintf( str, "pedfile%03d", i);
+     Int_t prun = env.GetValue( str, 0);
+     if( prun == 0)
+        break;
+     pruns.AddRun(prun,inpath);
+  }
+
+  gStyle->SetOptStat(1);
+  gStyle->SetOptFit();
+
+  // We do not use any display here.
+  MStatusDisplay *display = new MStatusDisplay;
+  display->SetUpdateTime(3000);
+  display->Resize(850,700);
+
+  /************************/
+  /* PEDESTAL COMPUTATION */
+  /************************/
+
+  MCalibrationQECam qecam;
+  MBadPixelsCam     badcam;
+  MGeomCamMagic     geomcam;
+  MGeomApply        geomapl;
+  //
+  // If you want to exclude pixels from the beginning, read
+  // an ascii-file with the corr. pixel numbers (see MBadPixelsCam)
+  //
+//  badcam.AsciiRead("badpixels.dat");
+
+  MJPedestal pedloop;
+  pedloop.SetExtractor(&extractor);
+  pedloop.SetInput(&pruns);
+  pedloop.SetOutputPath(outpath);
+  pedloop.SetDisplay(display);
+  pedloop.SetBadPixels(badcam);
+
+  if (!pedloop.Process())
+    return;
+
+}
+
+
Index: /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/scripts/mklinks
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/scripts/mklinks	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/scripts/mklinks	(revision 9661)
@@ -0,0 +1,57 @@
+#!/bin/sh
+#
+# ========================================================================
+#
+# *
+# * This file is part of MARS, the MAGIC Analysis and Reconstruction
+# * Software. It is distributed to you in the hope that it can be a useful
+# * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+# * It is distributed WITHOUT ANY WARRANTY.
+# *
+# * Permission to use, copy, modify and distribute this software and its
+# * documentation for any purpose is hereby granted without fee,
+# * provided that the above copyright notice appear in all copies and
+# * that both that copyright notice and this permission notice appear
+# * in supporting documentation. It is provided "as is" without express
+# * or implied warranty.
+# *
+#
+#
+#   Author(s): Martin Merck  05/2004 <mailto:merck@astro.uni-wuerzburg.de>
+#
+#   Copyright: MAGIC Software Development, 2000-2004
+#
+#
+# ========================================================================
+
+#/////////////////////////////////////////////////////////////////////////////
+#
+# mklinks
+#
+# This scripts creates in the local directors (directory where it is executed)
+# a series of subdirectories for each date in which links to the rawdata are created.
+# Normaly this script is used in a directory called rawdata2 to create links to
+# the rawdata files.
+# With a second script calle mklinksyy links to the ying-yang corrected files are
+# created and the corresponing links overwritten. In this way the subdirectory
+# rawdata2 will contain the correct links to the yy-files where necesary and the
+# original rawdata files, when no yy correction was necessary.
+#
+DATES=`ls -d -1 ../rawdata/20* | cut -d/ -f3 '-'`
+for DATE in $DATES
+do
+  OUTDIR=./$DATE
+  if [ ! -d $OUTDIR ]
+  then
+    echo $DATE
+    mkdir $OUTDIR
+  fi
+
+  cd $DATE
+  RAWFILES=`ls -1 ../../rawdata/$DATE/*.raw`
+  for i in $RAWFILES
+  do
+    ln -s $i `echo $i | cut -d/ -f5`
+  done
+  cd ..
+done
Index: /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/scripts/mklinksyy
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/scripts/mklinksyy	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/scripts/mklinksyy	(revision 9661)
@@ -0,0 +1,57 @@
+#!/bin/sh
+#
+# ========================================================================
+#
+# *
+# * This file is part of MARS, the MAGIC Analysis and Reconstruction
+# * Software. It is distributed to you in the hope that it can be a useful
+# * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+# * It is distributed WITHOUT ANY WARRANTY.
+# *
+# * Permission to use, copy, modify and distribute this software and its
+# * documentation for any purpose is hereby granted without fee,
+# * provided that the above copyright notice appear in all copies and
+# * that both that copyright notice and this permission notice appear
+# * in supporting documentation. It is provided "as is" without express
+# * or implied warranty.
+# *
+#
+#
+#   Author(s): Martin Merck  05/2004 <mailto:merck@astro.uni-wuerzburg.de>
+#
+#   Copyright: MAGIC Software Development, 2000-2004
+#
+#
+# ========================================================================
+
+#/////////////////////////////////////////////////////////////////////////////
+#
+# mklinksyy
+#
+# This scripts creates in the local directors (directory where it is executed)
+# a series of subdirectories for each date in which links to the rawdata are created.
+# Normaly this script is used in a directory called rawdata2 to create links to
+# the ying-yang corrected rawdata files.
+# Already existing links are overwritten. Normally first the script mklinks should 
+# be executed and then this script to overwrite the links for the yy corected rawdata
+# files.
+#
+IN_DIR=/mcdata/yin_yang/Period015/rawdata
+DATES=`ls -d -1 $IN_DIR/20* | cut -d/ -f6 '-'`
+for DATE in $DATES
+do
+  OUTDIR=./$DATE
+  if [ ! -d $OUTDIR ]
+  then
+    echo $DATE
+    mkdir $OUTDIR
+  fi
+
+  cd $DATE
+  RAWFILES=`ls -1 $IN_DIR/$DATE/*.raw`
+  for i in $RAWFILES
+  do
+    ln -f -s $i `echo $i | cut -d/ -f7`
+  done
+  cd ..
+done
Index: /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/scripts/runmerpp
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/scripts/runmerpp	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/scripts/runmerpp	(revision 9661)
@@ -0,0 +1,111 @@
+#!/bin/sh
+#
+# ========================================================================
+#
+# *
+# * This file is part of MARS, the MAGIC Analysis and Reconstruction
+# * Software. It is distributed to you in the hope that it can be a useful
+# * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+# * It is distributed WITHOUT ANY WARRANTY.
+# *
+# * Permission to use, copy, modify and distribute this software and its
+# * documentation for any purpose is hereby granted without fee,
+# * provided that the above copyright notice appear in all copies and
+# * that both that copyright notice and this permission notice appear
+# * in supporting documentation. It is provided "as is" without express
+# * or implied warranty.
+# *
+#
+#
+#   Author(s): Martin Merck  05/2004 <mailto:merck@astro.uni-wuerzburg.de>
+#
+#   Copyright: MAGIC Software Development, 2000-2004
+#
+#
+# ========================================================================
+
+#/////////////////////////////////////////////////////////////////////////////
+#
+# runmerpp
+#
+# This scripts is used to run merpp on a full Period of data. It will run merpp
+# on the raw-data file. Then it will update the root file by merpping in the CC
+# and CACO data.
+# As for some rawdata files no CaCo data files exist (due to DAQ restarting a run)
+# we need to use the previous CaCo file. This will add to much dc-current infos
+# to the merpped file, but will gaurantee that the right dc-currents are always
+# available.
+#
+# TODO:
+#  Due to problems with the DB the automatic DB update option is still disabled.
+#
+
+# ------------------------------------
+# Which Period to use
+INDIR=/data/MAGIC/Period015
+# ------------------------------------
+#
+# For each day of this Period
+#
+DATES=`ls -d -1 $INDIR/rawdata2/20* | cut -d/ -f6 '-'`
+for DATE in $DATES
+do
+  OUTDIR=$INDIR/rootdata2/$DATE
+# Create Output Directory 
+  if [ ! -d $OUTDIR ]
+  then
+    echo $DATE
+    mkdir $OUTDIR
+  fi
+
+#
+# Loop over all raw files for this day
+#
+  RAWFILES=`ls -1 $INDIR/rawdata2/$DATE/*.raw`
+  LOGFILE=$OUTDIR/merpp.log
+  TIME=`date`
+  echo "-----------------------------------------------------------------" > $LOGFILE
+  echo " MERPP run started $TIME" >> $LOGFILE
+  echo "-----------------------------------------------------------------" >> $LOGFILE
+
+  PREVIOUS_CACO=
+  for i in $RAWFILES
+  do
+    TIMER=$SECONDS
+    IN_FILE=$i
+    RUN_NUM=`echo $i | cut -d_ -f4` 
+    CC_FILE=`ls -1 $INDIR/ccdata/$DATE/*$RUN_NUM*.rep`
+    CACO_FILE=`ls -1 $INDIR/cacodata/$DATE/*$RUN_NUM*.txt 2> /dev/null`
+    OUT_FILE=$OUTDIR/`echo $i | cut -d/ -s -f7 '-' | cut -d. -s -f1 '-'`.root
+#    merpp -a -f --sql=mysql://hercules:d99swMT\!@hercules $IN_FILE $OUT_FILE >> $LOGFILE
+
+#   MERPP the raw data file
+    merpp -a -f $IN_FILE $OUT_FILE >> $LOGFILE
+
+#   MERPP the CC report file
+    merpp -a -u $CC_FILE $OUT_FILE >> $LOGFILE
+
+#   If a CACO file exists for this run
+#   MERPP the CACO file.
+    if [ -n "$CACO_FILE" ]
+    then
+      merpp -a -u $CACO_FILE $OUT_FILE >> $LOGFILE
+      PERVIOUS_CACO=$CACOFILE
+    fi
+
+#   If no CACO file is available for this run
+#   we use the previous CACO file
+#   CACO only nows when CC starts a new run and creates 1 file for this run
+#   however the DAQ may create more subruns due to errors or limitaation on the 
+#   filesize. The relevant CACO information should be in the CACO file created
+#   when CC started this run (e.g. the previous CACO file)
+    if [ -z "$CACO_FILE" ]
+    then
+      if [ -n "$PREVIOUS_CACO" ]
+      then
+        merpp -a -u $PREVIOUS_CACO $OUT_FILE >> $LOGFILE
+      fi
+    fi  
+    echo "Processed file $IN_FILE in $(( $SECONDS - $TIMER)) secs."
+  done
+done
Index: /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/scripts/runped
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/scripts/runped	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/scripts/runped	(revision 9661)
@@ -0,0 +1,72 @@
+#!/bin/sh
+#
+# ========================================================================
+#
+# *
+# * This file is part of MARS, the MAGIC Analysis and Reconstruction
+# * Software. It is distributed to you in the hope that it can be a useful
+# * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+# * It is distributed WITHOUT ANY WARRANTY.
+# *
+# * Permission to use, copy, modify and distribute this software and its
+# * documentation for any purpose is hereby granted without fee,
+# * provided that the above copyright notice appear in all copies and
+# * that both that copyright notice and this permission notice appear
+# * in supporting documentation. It is provided "as is" without express
+# * or implied warranty.
+# *
+#
+#
+#   Author(s): Martin Merck  05/2004 <mailto:merck@astro.uni-wuerzburg.de>
+#
+#   Copyright: MAGIC Software Development, 2000-2004
+#
+#
+# ========================================================================
+
+#/////////////////////////////////////////////////////////////////////////////
+#
+# runped
+#
+# This scripts runs the macro "stdPed.C" for all files of a period.
+# It writes the data card file "marsconfig" for each pedestal file which shall.
+# be processed and then calls root to execute the macro in batch mode.
+#
+#
+BASEPATH=/data/MAGIC/Period015
+ROOTDIR=rootdata2
+
+DATES=`ls -d -1 $BASEPATH/$ROOTDIR/20* | cut -d/ -f6 '-'`
+for DATE in $DATES
+do
+
+  INDIR=$BASEPATH/$ROOTDIR/$DATE/
+  OUTDIR=$BASEPATH/calibdata/$DATE/
+  if [ ! -d $OUTDIR ]
+  then
+    echo $DATE
+    mkdir $OUTDIR
+  fi
+
+  PEDFILES=`ls -1 $INDIR/*_P_*.root | cut -d_ -f4 '-'`
+
+  MARSFILE=./marsconfig
+  LOGFILE=$OUTDIR/Pedestal.log
+
+  TIME=`date`
+  echo "-----------------------------------------------------------------" > $LOGFILE
+  echo " PEDESTAL calc started $TIME" >> $LOGFILE
+  echo "-----------------------------------------------------------------" >> $LOGFILE
+
+#
+# For each pedestal file, create the "marsconfig" data card file
+# and run the macro "stdPed.C" in root using batch mode
+#
+  for I in $PEDFILES
+  do
+    echo "inpath:                  $INDIR" > $MARSFILE
+    echo "outpath:                 $OUTDIR" >> $MARSFILE
+    echo "pedfile001:              $I" >> $MARSFILE
+    root -b -l -q stdPed.C >> $LOGFILE
+  done
+done
Index: /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/tools/dcconverter/DCCurrentEvent.cpp
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/tools/dcconverter/DCCurrentEvent.cpp	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/tools/dcconverter/DCCurrentEvent.cpp	(revision 9661)
@@ -0,0 +1,83 @@
+// DCCurrentEvent.cpp: Implementiberung der Klasse DCCurrentEvent.
+//
+//////////////////////////////////////////////////////////////////////
+
+#ifndef DCCURRENTEVENT_INCLUDED
+#include "DCCurrentEvent.h"
+#endif
+#ifndef GLOBALS_INCLUDED
+#include "Globals.h"
+#endif
+
+#include <sstream>
+#include <istream>
+#include <ostream>
+#include <iostream>
+#include <iomanip>
+#include <iterator>
+#include <vector>
+
+extern int gYear, gMonth, gDay;
+
+//////////////////////////////////////////////////////////////////////
+// Konstruktion/Destruktion
+//////////////////////////////////////////////////////////////////////
+
+DCCurrentEvent::DCCurrentEvent()
+{
+    m_dcValues.reserve( Globals::CAMERA_PIXELS );
+    
+}
+
+DCCurrentEvent::~DCCurrentEvent()
+{
+}
+
+std::istream& operator >> ( std::istream& in, DCCurrentEvent& event )
+{
+    using std::string;
+    using std::getline;
+
+    // read the starting tag
+    string tag;
+    in >> tag;
+    if ( tag != "DC")
+    {
+        in.clear( std::ios_base::badbit);
+        return in;
+    }
+
+    // read error codes
+    in >> event.m_dcError1 >> event.m_dcError2;
+
+    // read in the timestamp
+    in >> event.m_dcHour >> event.m_dcMin >> event.m_dcSec >> event.m_dcMSec;
+
+    getline( in, event.m_dcCurr );
+
+    return in;
+}
+
+std::ostream& operator << ( std::ostream& out, const DCCurrentEvent& event )
+{
+    using namespace std;
+
+    out << "DC-REPORT ";
+    out << setfill('0') << right << resetiosflags(ios_base::showpos);
+    out << setw(2) << 0 << ' ';
+    out << setw(4) << gYear << ' ';
+    out << setw(2) << gMonth << ' ';
+    out << setw(2) << gDay << ' ';
+    out << setw(2) << event.m_dcHour << ' ';
+    out << setw(2) << event.m_dcMin  << ' ';
+    out << setw(2) << event.m_dcSec  << ' ';
+    out << setw(3) << event.m_dcMSec << ' ';
+
+    out << setfill('0') << internal << setiosflags(ios_base::showpos);
+    out << setw(3) << event.m_dcError1 << " ";
+    out << setw(3) << event.m_dcError2;
+    out << setfill('0') << right << resetiosflags(ios_base::showpos);
+
+    out << event.m_dcCurr;
+    return out;
+}
Index: /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/tools/dcconverter/DCCurrentEvent.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/tools/dcconverter/DCCurrentEvent.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/tools/dcconverter/DCCurrentEvent.h	(revision 9661)
@@ -0,0 +1,38 @@
+// DCCurrentEvent.h: Schnittstelle für die Klasse DCCurrentEvent.
+//
+//////////////////////////////////////////////////////////////////////
+
+#if !defined(DCCURRENTEVENT_INCLUDED)
+#define DCCURRENTEVENT_INCLUDED
+
+#include <ctime>
+#include <vector>
+#include <string>
+#include <istream>
+#include <ostream>
+
+class DCCurrentEvent
+{
+    friend std::istream& operator >> ( std::istream& in, DCCurrentEvent& event );
+    friend std::ostream& operator << ( std::ostream& out, const DCCurrentEvent& event );
+
+private:
+    int	       		m_dcError1;
+    int	       		m_dcError2;
+    int	       		m_dcHour;
+    int	       		m_dcMin;
+    int	       		m_dcSec;
+    int	       		m_dcMSec;
+    time_t     		m_dcTime;
+    std::string       m_dcCurr;
+    std::vector<int>	m_dcValues;
+
+public:
+	DCCurrentEvent();
+	virtual ~DCCurrentEvent();
+};
+
+std::istream& operator >> ( std::istream& in, DCCurrentEvent& event );
+std::ostream& operator << ( std::ostream& out, const DCCurrentEvent& event );
+
+#endif // !defined(DCCURRENTEVENT_INCLUDED)
Index: /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/tools/dcconverter/Globals.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/tools/dcconverter/Globals.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/tools/dcconverter/Globals.h	(revision 9661)
@@ -0,0 +1,20 @@
+// Globals.h: Global variables
+//            We use a class to hold these global values
+//            in order not to pollute the global namespace
+//
+//////////////////////////////////////////////////////////////////////
+
+#if !defined(GLOBALS_INCLUDED)
+#define GLOBALS_INCLUDED
+
+class Globals  
+{
+public:
+	enum {CAMERA_PIXELS = 577};
+
+private:
+	Globals();				// prevent inadvertent instantiation
+
+};
+
+#endif // !defined(GLOBALS_INCLUDED)
Index: /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/tools/dcconverter/Makefile
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/tools/dcconverter/Makefile	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/tools/dcconverter/Makefile	(revision 9661)
@@ -0,0 +1,116 @@
+##################################################################
+#
+# makefile
+#
+# @file        makefile
+# @title       Converter of DCCurrent files to new format
+# @author      M Merck
+# @email       merck@astro.uni-wuerzburg.de
+# @date        Wed Dec 17 11:51:11 MET 2003
+#
+#_______________________________________________________________
+#
+# Created: Wed Dec 17 11:51:11 MET 2003
+# Author:  Martin Merck
+# Purpose: Makefile for the compilation of dcconvertor
+# Notes:   
+#    
+##################################################################
+
+# @code
+
+# compilers & tools
+
+CC            = gcc
+CXX           = g++
+F77           = g77
+
+INCLUDES = -I.
+
+OPTIM    =
+DEBUG    = -g
+
+# compilation and linking flags
+
+CXXFLAGS  = ${INCLUDES} ${OPTIM} ${DEBUG}
+CFLAGS    = ${CXXFLAGS}
+FFLAGS    = ${CXXFLAGS}
+LIBS      =
+
+#------------------------------------------------------------------------------
+
+#.SILENT:
+
+.SUFFIXES: .c .cxx .cpp .C .c++ .h .hxx .H .h++ .o .so .f
+
+SRCS = \
+	main.cpp \
+	DCCurrentEvent.cpp
+
+HEADERS = \
+	DCCurrentEvent.h \
+	Globals.h
+
+OBJS = \
+	DCCurrentEvent.o \
+	main.o
+
+PROGRAM=dcconvertor
+
+############################################################
+
+all: ${PROGRAM}
+
+depend:
+	@makedepend $(SRCS) -fMakefile 2> /dev/null
+
+${PROGRAM}: $(OBJS)
+	@echo "Linking..." $@
+	$(CXX) $(CXXFLAGS) $(OBJS) $(LIBS) -o $@
+	@echo "done."
+
+.cxx.o:
+	@echo "Compiling " $<
+	$(CXX) $(CXXFLAGS) -c $< -o $@
+
+.c.o:
+	@echo "Compiling " $<
+	$(CC) $(CFLAGS) -c $< -o $@
+
+.f.o:
+	@echo "Compiling " $<
+	$(F77) $(FFLAGS) -c $< -o $@
+
+lclean:
+	@echo "Cleanning..."
+	@rm -f *.o core
+
+clean:
+	@echo "Cleanning..."
+	@rm -f $(OBJS) core 
+
+mrproper: clean
+	@echo "Mr.Proper in action . . ."
+	@rm -f $(PROGRAM)
+
+ctags:
+	@echo "Creating CTAGS file . . ."
+	@ctags -txw $(SRCS) $(HEADERS) > CTAGS
+
+etags:
+	@echo "Creating TAGS file . . ."
+	@etags -C $(SRCS) $(HEADERS)
+
+listsrc:
+	@ls -m $(SRCS) $(HEADERS) | sed 's/,//g'
+
+redo: clean all
+
+# @endcode
+# DO NOT DELETE
+
+main.o: Globals.h /usr/include/stdlib.h /usr/include/features.h
+main.o: /usr/include/sys/cdefs.h /usr/include/gnu/stubs.h
+main.o: /usr/lib/gcc-lib/i486-suse-linux/3.3/include/stddef.h
+main.o: DCCurrentEvent.h
+DCCurrentEvent.o: DCCurrentEvent.h Globals.h
Index: /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/tools/dcconverter/main.cpp
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/tools/dcconverter/main.cpp	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/tools/dcconverter/main.cpp	(revision 9661)
@@ -0,0 +1,57 @@
+/***************************************************************************
+                          main.cpp  -  description
+                             -------------------
+    begin                : Tue Dec  9 12:05:18 CET 2003
+    copyright            : (C) 2003 by Martin Merck
+    email                : merck@astro.uni-wuerzburg.de
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is part of the MAGIC Software  * ***************************************************************************/
+
+#ifndef GLOBALS_INCLUDED
+#include "Globals.h"
+#endif
+
+#include <iostream>
+#include <fstream>
+#include <sstream>
+#include <iterator>
+#include <string>
+#include <stdlib.h>
+#include "DCCurrentEvent.h"
+
+using namespace std;
+
+int gYear, gMonth, gDay;
+
+void usage();
+
+int main(int argc, char *argv[])
+{
+  if (argc != 3)
+     usage();
+
+  string dcFileName( argv[1] );
+  string date = dcFileName.substr( dcFileName.rfind( "dc_" ) + 3, 10 );
+  sscanf( date.c_str(), "%d_%d_%d", &gYear, &gMonth, &gDay);
+  cout << gYear << ":" << gMonth << ":" << gDay << endl;
+  
+  
+  std::ifstream input( argv[1] );
+  ofstream output( const_cast<const char *> (argv[2]) );
+
+  copy( istream_iterator<DCCurrentEvent>( input ),
+        istream_iterator<DCCurrentEvent>(),
+        ostream_iterator<DCCurrentEvent>( output, "\n") );
+
+  return EXIT_SUCCESS;
+}
+
+void usage()
+{
+  cerr << "USAGE: dcconvertor <input file> <output file>" << endl;
+  exit( EXIT_FAILURE );
+}
+  
Index: /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/tools/dcconverter/rundcconv
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/tools/dcconverter/rundcconv	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtemp/mwuerzburg/tools/dcconverter/rundcconv	(revision 9661)
@@ -0,0 +1,43 @@
+#!/bin/sh
+# Script to convert DC current files from the old format to the new format
+#
+PS3="Select the Date for which MERPP should run? "
+DATES=`ls -d -1 ./cacodata_old/20* | cut -d/ -f3 '-'`
+select DATE in $DATES "Exit"; do
+	break
+done
+if [ "$DATE" = "Exit" ]
+then
+  exit
+fi
+
+INDIR=./cacodata_old/$DATE
+OUTDIR=./cacodata/$DATE
+if [ -d $OUTDIR ]
+then
+  echo "An output directory for the date $DATE already"
+  echo "exists. Please be sure that you selected the"
+  echo "correct date. If you want to rerun MERPP on this"
+  echo "date please delete the directory and all files it"
+  echo "contains from the rootfiles directory."
+  exit
+fi
+echo $DATE
+mkdir ./cacodata/$DATE
+
+LOGFILE=$OUTDIR/dcconv.log
+CACOFILES=`ls -1 $INDIR/dc_*.txt`
+
+TIME=`date`
+echo "-----------------------------------------------------------------" > $LOGFILE
+echo " dcconvertor run started $TIME" >> $LOGFILE
+echo "-----------------------------------------------------------------" >> $LOGFILE
+
+for i in $CACOFILES
+do
+  IN_FILE=$i
+  OUT_FILE=$OUTDIR/$i
+  dcconvertor $IN_FILE $OUT_FILE
+  echo $IN_FILE >> $LOGFILE
+  echo "Processed file $IN_FILE in $SECONDS secs."
+done
Index: /tags/Mars_V0-8-5/Mars/mtools/MChisqEval.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtools/MChisqEval.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtools/MChisqEval.cc	(revision 9661)
@@ -0,0 +1,155 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz 07/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MChisqEval.h"
+
+#include <fstream>
+
+#include "MDataChain.h"
+#include "MParameters.h" // MParameterD
+
+#include "MParList.h"
+
+ClassImp(MChisqEval);
+
+using namespace std;
+
+void MChisqEval::StreamPrimitive(ofstream &out) const
+{
+    out << "   MChisqEval " << GetUniqueName() << ";";
+    if (fData0)
+        out << "   " << GetUniqueName() << ".SetY1(\"" << fData0->GetRule() << "\");" << endl;
+    if (fData1)
+        out << "   " << GetUniqueName() << ".SetY1(\"" << fData1->GetRule() << "\");" << endl;
+}
+
+MChisqEval::MChisqEval(const char *name, const char *title) : fData0(NULL), fData1(NULL)// : fMatrix(mat), fColumn(col), fEvalE(evale)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+}
+
+MChisqEval::MChisqEval(MData *y1, const char *name, const char *title) : fData0(NULL), fData1(NULL)// : fMatrix(mat), fColumn(col), fEvalE(evale)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+    SetY1(y1);
+}
+
+MChisqEval::MChisqEval(MData *y1, MData *y2, const char *name, const char *title) : fData0(NULL), fData1(NULL)// : fMatrix(mat), fColumn(col), fEvalE(evale)
+{
+    fName  = name  ? name  : gsDefName.Data();
+    fTitle = title ? title : gsDefTitle.Data();
+    SetY1(y1);
+    SetY2(y2);
+}
+
+MChisqEval::~MChisqEval()
+{
+    if (fData0 && (fData0->TestBit(kCanDelete) || TestBit(kIsOwner)))
+        delete fData0;
+
+    if (fData1 && (fData1->TestBit(kCanDelete) || TestBit(kIsOwner)))
+        delete fData1;
+}
+
+void MChisqEval::SetY1(MData *data)
+{
+    // Set MC value
+    if (fData0 && (fData0->TestBit(kCanDelete) || TestBit(kIsOwner)))
+        delete fData0;
+    fData0 = data;
+    fData0->SetBit(kCanDelete);
+    AddToBranchList(fData0->GetDataMember());
+}
+
+void MChisqEval::SetY2(MData *data)
+{
+    // Set measured/estimated value
+    if (fData1 && (fData1->TestBit(kCanDelete) || TestBit(kIsOwner)))
+        delete fData1;
+    fData1 = data;
+    fData1->SetBit(kCanDelete);
+    AddToBranchList(fData1->GetDataMember());
+}
+
+void MChisqEval::SetY1(const TString data)
+{
+    SetY1(new MDataChain(data));
+}
+
+void MChisqEval::SetY2(const TString data)
+{
+    SetY2(new MDataChain(data));
+}
+
+Int_t MChisqEval::PreProcess(MParList *plist)
+{
+    fChisq = 0;
+
+    if (!fData0)
+        return kFALSE;
+
+    if (!fData0->PreProcess(plist))
+        return kFALSE;
+
+    if (fData1)
+        if (!fData1->PreProcess(plist))
+            return kFALSE;
+
+    fResult = (MParameterD*)plist->FindCreateObj("MParameterD", "MFitResult");
+    if (!fResult)
+        return kFALSE;
+
+    return kTRUE;
+}
+
+Int_t MChisqEval::Process()
+{
+    const Double_t y1 = fData0->GetValue();
+    const Double_t y2 = fData1 ? fData1->GetValue() : 0;
+
+    const Double_t dy  = y2-y1;
+    const Double_t err = fData1 ? y1*y1 : 1;
+
+    fChisq += dy*dy/err;
+    return kTRUE;
+}
+
+Int_t MChisqEval::PostProcess()
+{
+    fChisq /= GetNumExecutions();
+
+    fResult->SetVal(fChisq);
+
+    return kTRUE;
+}
+
+const TString MChisqEval::gsDefName  = "MChisqEval";
+const TString MChisqEval::gsDefTitle = "Evaluate a chisq";
+
Index: /tags/Mars_V0-8-5/Mars/mtools/MChisqEval.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtools/MChisqEval.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtools/MChisqEval.h	(revision 9661)
@@ -0,0 +1,55 @@
+#ifndef MARS_MChisqEval
+#define MARS_MChisqEval
+
+#ifndef ROOT_MTask
+#include "MTask.h"
+#endif
+
+class MData;
+class MParameterD;
+
+class MChisqEval : public MTask
+{
+private:
+    static const TString gsDefName;
+    static const TString gsDefTitle;
+
+    Double_t     fChisq;  //! Evaluated chi square
+    MParameterD *fResult; //! Storage for result
+
+    MData   *fData0; // Data Member one (monte carlo data or chisq function)
+    MData   *fData1; // Data Member two (measured data)
+
+    // --------------------------------------------------------------------------
+    //
+    // Implementation of SavePrimitive. Used to write the call to a constructor
+    // to a macro. In the original root implementation it is used to write
+    // gui elements to a macro-file.
+    //
+    void StreamPrimitive(ofstream &out) const;
+
+    enum { kIsOwner = BIT(14) };
+
+    Int_t PreProcess(MParList *plist);
+    Int_t Process();
+    Int_t PostProcess();
+
+public:
+    MChisqEval(const char *name=NULL, const char *title=NULL);
+    MChisqEval(MData *y1, const char *name=NULL, const char *title=NULL);
+    MChisqEval(MData *y1, MData *y2, const char *name=NULL, const char *title=NULL);
+    ~MChisqEval();
+
+    void SetY1(MData *data);
+    void SetY2(MData *data);
+    void SetY1(const TString data);
+    void SetY2(const TString data);
+
+    void SetOwner(Bool_t o=kTRUE) { o ? SetBit(kIsOwner) : ResetBit(kIsOwner); }
+
+    Double_t GetChisq() const { return fChisq; }
+ 
+    ClassDef(MChisqEval, 0)
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtools/MCubicCoeff.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtools/MCubicCoeff.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtools/MCubicCoeff.cc	(revision 9661)
@@ -0,0 +1,219 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Sebastian Raducci 01/2004  <mailto:raducci@fisica.uniud.it>
+!
+!   Copyright: MAGIC Software Development, 2001-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  Cubic Spline Interpolation
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MCubicCoeff.h"
+
+#include <TMath.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MCubicCoeff);
+
+using namespace std;
+
+//----------------------------------------------------------------------------
+//
+// Constructor (The spline is: fA(x-fX)3+fB(x-fX)2+fC(x-fX)+fY
+// where x is the independent variable, 2 and 3 are exponents
+//
+MCubicCoeff::MCubicCoeff(Double_t x, Double_t xNext, Double_t y, Double_t yNext, 
+			 Double_t a, Double_t b, Double_t c) : 
+    fX(x), fXNext(xNext), fA(a), fB(b), fC(c), fY(y), fYNext(yNext)
+{
+    fH = fXNext - fX;
+    if (EvalMinMax())
+        return;
+
+    gLog << warn << "Failed to eval interval Minimum and Maximum, returning zeros" << endl;
+    fMin = 0;
+    fMax = 0;
+}
+
+//----------------------------------------------------------------------------
+//
+// Evaluate the spline at a given point
+//
+
+Double_t MCubicCoeff::Eval(Double_t x)
+{
+    const Double_t dx = x - fX;
+    return fY + dx*(fC + dx*(fB + dx*fA));
+}
+
+//----------------------------------------------------------------------------
+//
+// Find min and max using derivatives. The min and max could be at the begin
+// or at the end of the interval or somewhere inside the interval (in this case
+// a comparison between the first derivative and zero is made)
+// The first derivative coefficients are obviously: 3*fA, 2*fB, fC
+//
+Bool_t MCubicCoeff::EvalMinMax()
+{
+    fMin = fY;
+    fMax = fY;
+
+    fAbMin = fX;
+    fAbMax = fX;
+
+    if (fYNext < fMin)
+    {
+	fMin   = fYNext;
+	fAbMin = fXNext;
+    }
+    if (fYNext > fMax)
+    {
+	fMax   = fYNext;
+	fAbMax = fXNext;
+    }
+
+    const Double_t delta = fB*fB*4 - fA*fC*12;
+    if (delta >= 0 && fA != 0)
+    {
+        const Double_t sqrtDelta = TMath::Sqrt(delta);
+
+        const Double_t xPlus  = (-fB*2 + sqrtDelta)/(fA*6);
+        const Double_t xMinus = (-fB*2 - sqrtDelta)/(fA*6);
+
+        if (xPlus >= 0 && xPlus <= fH)
+        {
+            const Double_t tempMinMax = Eval(fX+xPlus);
+            if (tempMinMax < fMin)
+            {
+                fMin = tempMinMax;
+                fAbMin = fX + xPlus;
+            }
+            if (tempMinMax > fMax)
+            {
+                fMax = tempMinMax;
+                fAbMax = fX + xPlus;
+            }
+        }
+        if (xMinus >= 0 && xMinus <= fH)
+        {
+            const Double_t tempMinMax = Eval(fX+xMinus);
+            if (tempMinMax < fMin)
+            {
+                fMin = tempMinMax;
+                fAbMin = fX + xMinus;
+            }
+            if (tempMinMax > fMax)
+            {
+                fMax = tempMinMax;
+                fAbMax = fX + xMinus;
+            }
+        }
+        return kTRUE;
+    }
+
+    /* if fA is zero then we have only one possible solution */
+    if (fA == 0 && fB != 0)
+    {
+        const Double_t xSolo = -fC/(fB*2);
+
+        if (xSolo < 0 || xSolo > fH)
+            return kTRUE;
+
+        const Double_t tempMinMax = Eval(fX+xSolo);
+        if (tempMinMax < fMin)
+        {
+            fMin = tempMinMax;
+            fAbMin = fX + xSolo;
+        }
+        if (tempMinMax > fMax)
+        {
+            fMax = tempMinMax;
+            fAbMax = fX + xSolo;
+        }
+        return kTRUE;
+    }
+
+    return kTRUE;
+}
+//-------------------------------------------------------------------------
+//
+// Given y finds x using the cubic (cardan) formula.
+//
+// we consider the following form: x3 + ax2 + bx + c = 0 where
+//   a = fB/fA, b = fC/fA, c = (fY - y)/fA  
+//
+// There could be three or one real solutions
+//
+Short_t MCubicCoeff::FindCardanRoot(Double_t y, Double_t *x)
+{
+    const Double_t a = fB/fA;
+    const Double_t b = fC/fA;
+    const Double_t c = (fY - y)/fA;
+
+    const Double_t q = (a*a - b*3)/9;
+    const Double_t r = (a*a*a*2 - a*b*9 + c*27)/54;
+
+    const Double_t aOver3 = a/3;
+    const Double_t r2 = r*r;
+    const Double_t q3 = q*q*q;
+    
+    if (r2 < q3) //3 real sol
+    {
+	const Double_t sqrtQ = TMath::Sqrt(q);
+	const Double_t min2SqQ = -sqrtQ*2;
+	const Double_t theta = TMath::ACos(r/(sqrtQ*sqrtQ*sqrtQ));
+
+        x[0] = min2SqQ * TMath::Cos(theta/3) - aOver3;
+	x[1] = min2SqQ * TMath::Cos((theta+TMath::TwoPi())/3) - aOver3;
+	x[2] = min2SqQ * TMath::Cos((theta-TMath::TwoPi())/3) - aOver3;
+
+        for (Int_t i = 0; i < 3; i++)
+	    if (x[i] >= 0 && x[i] <= fH)
+	    {
+                x[i] += fX;
+                return i;
+	    }
+        return -1;
+    }
+
+    const Double_t s = r==0 ? 0 : -TMath::Sign(TMath::Power(TMath::Abs(r) + TMath::Sqrt(r2 - q3), 1./3), r);
+
+    x[0] = s==0 ? - aOver3 : (s + q/s) - aOver3;
+
+    if (x[0] < 0 || x[0] > fH)
+        return -1;
+
+    x[0] += fX;
+    return 0;
+}
+
+//------------------------------------------------------------------------------------
+//
+// return true if x is in this interval
+//
+
+Bool_t MCubicCoeff :: IsIn(Double_t x)
+{
+    return x >= fX && x <= fXNext;
+}
Index: /tags/Mars_V0-8-5/Mars/mtools/MCubicCoeff.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtools/MCubicCoeff.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtools/MCubicCoeff.h	(revision 9661)
@@ -0,0 +1,42 @@
+#ifndef MARS_MCubicCoeff
+#define MARS_MCubicCoeff
+
+#ifndef MARS_MAGIC
+#include "MAGIC.h"
+#endif
+
+class MCubicCoeff : public TObject
+{
+ private:
+    Double_t fX;     // abscissa
+    Double_t fXNext; // abscissa of the next point
+    Double_t fA;     // 3rd order coeff
+    Double_t fB;     // 2nd order coeff
+    Double_t fC;     // 1st order coeff
+    Double_t fY;     // constant term
+    Double_t fYNext; // value in the next point
+    Double_t fH;     // interval width
+    Double_t fMin;   // minimum value
+    Double_t fMax;   // maximum value
+    Double_t fAbMin; // abscissa of the min
+    Double_t fAbMax; // abscissa of the max
+ public:
+    MCubicCoeff(){}
+    MCubicCoeff(Double_t x, Double_t xNext, Double_t y, Double_t yNext,
+		Double_t a, Double_t b, Double_t c);
+    Double_t GetA()   { return fA; }
+    Double_t GetB()   { return fB; }
+    Double_t GetC()   { return fC; }
+    Double_t GetMin() { return fMin; }
+    Double_t GetMax() { return fMax; }
+    Double_t GetAbMin() { return fAbMin; }
+    Double_t GetAbMax() { return fAbMax; }
+    Double_t Eval(Double_t x); //Evaluate the spline at a point x
+    Bool_t   EvalMinMax();     //Finds min & max
+    Short_t  FindCardanRoot(Double_t y, Double_t *x); //Evaluate the abscissa of the spline given y 
+    Bool_t   IsIn(Double_t x);
+
+    ClassDef(MCubicCoeff, 0)  //Class to contain spline coefficients
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtools/MCubicSpline.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtools/MCubicSpline.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtools/MCubicSpline.cc	(revision 9661)
@@ -0,0 +1,278 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Sebastian Raducci 01/2004  <mailto:raducci@fisica.uniud.it>
+!
+!   Copyright: MAGIC Software Development, 2001-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//  Cubic Spline Interpolation
+//
+//////////////////////////////////////////////////////////////////////////////
+#include "MCubicSpline.h"
+
+#include <TMath.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MCubicCoeff.h"
+
+ClassImp(MCubicSpline);
+
+using namespace std;
+
+//---------------------------------------------------------------------------
+//
+// Contructor 
+//
+//
+MCubicSpline::MCubicSpline(const Byte_t *y, const Byte_t *x, Bool_t areAllEq,
+			   Int_t n, Double_t begSD, Double_t endSD)
+{
+    Init(y,x,areAllEq,n,begSD,endSD);
+}
+
+//---------------------------------------------------------------------------
+//
+// Constructor for FADC slice (only the FADC counts are needed)
+//
+//
+MCubicSpline::MCubicSpline(const Byte_t *y)
+{
+    const Byte_t x[]={0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E};
+    Init(y,x,kTRUE,15,0.0,0.0);
+}
+
+//---------------------------------------------------------------------------
+//
+// Constructors common part
+//
+//
+void MCubicSpline::Init(const Byte_t *y, const Byte_t *x, Bool_t areAllEq,
+			   Int_t n, Double_t begSD, Double_t endSD)
+
+{
+    Double_t *temp = new Double_t[n];
+    Double_t *ysd  = new Double_t[n];
+
+    fCoeff = new TObjArray(n-1,0);
+
+    ysd[0]  =begSD;
+    temp[0] =begSD;
+    ysd[n-1]=endSD;
+    
+    Double_t h = x[1]-x[0];
+
+    if (areAllEq)
+    {
+	for(Int_t i = 1; i < n-1; i++)
+	{
+	    const Double_t p = ysd[i-1]/2+2;
+
+            ysd[i]  = -0.5/p;
+	    temp[i] = (y[i+1] - y[i]*2 + y[i-1])/h;
+	    temp[i] = (temp[i]*6/h-temp[i-1]/2)/p;
+        }
+    }
+    else
+    {
+	for(Int_t i = 1; i < n-1; i++)
+	{
+            const Double_t sig = (x[i]-x[i-1])/(x[i+1]-x[i-1]);
+
+            const Double_t p = sig*ysd[i-1]+2;
+
+	    ysd[i]  = (sig-1.0)/p;
+	    temp[i] = (y[i+1]-y[i])/(x[i+1]-x[i])-(y[i]-y[i-1])/(x[i]-x[i-1]);
+	    temp[i] = (temp[i]*6/(x[i+1]-x[i-1])-sig*temp[i-1])/p;
+	}
+    }
+
+    for(Int_t i = n-2; i > 0; i--)
+        ysd[i] = ysd[i]*ysd[i+1] + temp[i];
+
+    for(Int_t i = 0; i < n-1; i++)
+    {
+        if (!areAllEq)
+            h = x[i+1]-x[i];
+
+        MCubicCoeff *c = new MCubicCoeff(x[i], x[i+1], y[i], y[i+1], (ysd[i+1]-ysd[i])/(h*6),
+                                         ysd[i]/2, (y[i+1]-y[i])/h-(h*(ysd[i+1]+ysd[i]*2))/6);
+        fCoeff->AddAt(c, i);
+    }
+
+    delete [] temp;
+    delete [] ysd;
+}
+
+MCubicSpline::~MCubicSpline()
+{
+    fCoeff->Delete();
+    delete fCoeff;
+}
+
+//---------------------------------------------------------------------------
+//
+// Evaluate the spline at a given point
+//
+Double_t MCubicSpline :: Eval(Double_t x)
+{
+    const Int_t n = fCoeff->GetSize();
+    for (Int_t i = 0; i < n; i++)
+    {
+        MCubicCoeff *c = (MCubicCoeff*)fCoeff->UncheckedAt(i);
+	if (c->IsIn(x))
+            return c->Eval(x);
+    }
+
+    gLog << warn << "Cannot evaluate Spline at " << x << "; returning 0";
+
+    return 0;
+}
+
+//----------------------------------------------------------------------------
+//
+// Search for max
+//
+Double_t MCubicSpline :: EvalMax()
+{
+    Double_t max = -FLT_MAX;
+
+    TIter Next(fCoeff);
+    MCubicCoeff *c;
+    while ((c=(MCubicCoeff*)Next()))
+        max = TMath::Max(max, c->GetMax());
+
+    return max;
+}
+
+//----------------------------------------------------------------------------
+//
+// Search for min
+//
+Double_t MCubicSpline :: EvalMin()
+{
+    Double_t min = FLT_MAX;
+
+    TIter Next(fCoeff);
+    MCubicCoeff *c;
+    while ((c=(MCubicCoeff*)Next()))
+        min = TMath::Min(min, c->GetMin());
+
+    return min;
+}
+
+//----------------------------------------------------------------------------
+//
+// Search for abscissa of the max
+//
+Double_t MCubicSpline :: EvalAbMax()
+{
+    Double_t max = -FLT_MAX;
+
+    TIter Next(fCoeff);
+
+    MCubicCoeff *c;
+    MCubicCoeff *cmax=0;
+
+    while ((c=(MCubicCoeff*)Next()))
+    {
+        const Double_t temp = c->GetMax();
+        if (temp <= max)
+            continue;
+
+        max = temp;
+        cmax = c;
+    }
+
+    return cmax ? cmax->GetAbMax() : -FLT_MAX;
+}
+
+//----------------------------------------------------------------------------
+//
+// Search for abscissa of the min
+//
+Double_t MCubicSpline :: EvalAbMin()
+{
+    Double_t min = FLT_MAX;
+
+    TIter Next(fCoeff);
+
+    MCubicCoeff *c;
+    MCubicCoeff *cmin=0;
+
+    while ((c=(MCubicCoeff*)Next()))
+    {
+        const Double_t temp = c->GetMin();
+        if (temp >= min)
+            continue;
+
+        min = temp;
+        cmin = c;
+    }
+
+    return cmin ? cmin->GetAbMin() : FLT_MAX;
+}
+
+//----------------------------------------------------------------------------
+//
+// Finds the abscissa where the spline reaches y starting from x0 going in
+// direction direction
+// You have to give as input a starting point and a direction ("l" or "r")
+//
+Double_t MCubicSpline :: FindVal(Double_t y, Double_t x0, Char_t direction = 'l')
+{
+    Double_t roots[3] = { 0, 0, 0 };
+
+    const Int_t n = fCoeff->GetSize()-1;
+
+    for (Int_t i = 0; i < n; i++)
+    {
+        if (!((MCubicCoeff*)fCoeff->At(i))->IsIn(x0))
+            continue;
+
+        switch (direction)
+        {
+        case 'l':
+            for (Int_t j = i; j >= 0; j--)
+            {
+                const Int_t whichRoot = ((MCubicCoeff*)fCoeff->At(j))->FindCardanRoot(y, roots);
+                if (whichRoot >= 0 )
+                    return roots[whichRoot];
+            }
+            break;
+
+        case 'r':
+            for (Int_t j = i; j < n; j++)
+            {
+                const Int_t whichRoot = ((MCubicCoeff*)fCoeff->At(j))->FindCardanRoot(y, roots);
+                if (whichRoot >= 0)
+                    return roots[whichRoot];
+            }
+            break;
+        }
+    }
+
+    //gLog << warn << "Nothing found calling MCubicSpline :: FindVal(), returning 0" << endl;
+
+    return 0;
+}
Index: /tags/Mars_V0-8-5/Mars/mtools/MCubicSpline.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtools/MCubicSpline.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtools/MCubicSpline.h	(revision 9661)
@@ -0,0 +1,35 @@
+#ifndef MARS_MCubicSpline
+#define MARS_MCubicSpline
+
+#ifndef MARS_MAGIC
+#include "MAGIC.h"
+#endif
+
+#ifndef ROOT_TObjArray
+#include "TObjArray.h"
+#endif
+
+class MCubicCoeff;
+
+class MCubicSpline : public TObject
+{
+ private:
+    TObjArray *fCoeff; //array of the coefficients
+
+    void Init(const Byte_t *y, const Byte_t *x, Bool_t areAllEq, Int_t n, Double_t begSD, Double_t endSD);
+
+ public:
+    MCubicSpline(const Byte_t *y, const Byte_t *x, Bool_t areAllEq, Int_t n, Double_t begSD=0.0, Double_t endSD=0.0);
+    MCubicSpline(const Byte_t *y);
+    ~MCubicSpline();
+    Double_t Eval(Double_t x); //Eval the spline at a point x
+    Double_t EvalMax();   //Eval the max
+    Double_t EvalMin();   //Eval the min
+    Double_t EvalAbMax(); //Eval the abscissa of the max
+    Double_t EvalAbMin(); //Eval the abscissa of the min
+    Double_t FindVal(Double_t y, Double_t x0, Char_t direction); //Finds the abscissa where the spline reaches y
+    
+    ClassDef(MCubicSpline, 0)  //Class to contain spline coefficients
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtools/MFFT.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtools/MFFT.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtools/MFFT.cc	(revision 9661)
@@ -0,0 +1,1013 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug 01/2004  <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2001-2004
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  Fast Fourier Transforms                                                 //
+//                                                                          //
+//  (Most of the code is adapted from Numerical Recipies in C++, 2nd ed.,   //
+//  pp. 509-563)                                                            //
+//                                                                          //
+//  Usage:                                                                  //
+//                                                                          //
+//  1) Functions RealFunctionFFT:  (FOURIER TRANSFORM)                      //
+//     * Take as argument arrays of real numbers,                           // 
+//       in some cases the dimension of the array has to be given separately//
+//     * Return a COMPLEX array with the following meaning:                 //
+//       array[0]: The value of F(0) (has only real component)              //
+//       array[1]: The value of F(N/2) (has only real component)            //
+//       array[2i]: The real part of F(i)                                   //
+//       array[2i+1]: The imaginary part of F(i)                            //
+//     * Note that F(N-i)* = F(i), therefore only the positive frequency    //
+//       half is stored.                                                    //
+//     * The dimension MUST be an integer power of 2,                       //
+//       otherwise, the array will be shortened!!                           //
+//                                                                          //
+//  2) Functions RealFunctionIFFT:  (INVERSER FOURIER TRANSFORM)            // 
+//     * Take as argument a COMPLEX array                                   //
+//       of Fourier-transformed REAL numbers                                //
+//       with the following meaning:                                        //
+//       array[0]: The value of F(0) (has only real component)              //
+//       array[1]: The value of F(N/2) (has only real component)            //
+//       array[2i]: The real part of F(i)                                   //
+//       array[2i+1]: The imaginary part of F(i)                            //
+//     * Returns the original complex array of dimension 2N-1               //                                
+//                                                                          //
+//  3) Functions PowerSpectrumDensity:                                      //
+//     * Return a histogram with the spectral density, i.e.                 //
+//       P(k) = 1/(N*N) * |F(k)|*|F(k)|                                     //
+//     * The histogram is ranged between 0 and 1./(2*binwidth)              //
+//     * The number of bins equals N/2+1                                    //
+//     * Note that histograms with unequal binwidth can not yet be treated! //
+//     * If the PSD does NOT CONVERGE to 0 at the maximum bin,              //
+//       you HAVE TO sample your data finer!                                //
+//
+// Fourier-Transformation:
+// =======================
+
+// (taken from http://www.parasitaere-kapazitaeten.net/Pd/ft.htm)
+//
+//  The Fourier-Transformation is a mathematical function that breaks
+// down a signal (like sound) into its frequency-spectrum as a set of
+// sinusoidal components, converting it from the Time Domain to the
+// Frequency Domain.
+// 
+//  In the Time Domain the signal x[ ] consists of N samples, labeled
+// from 0 to N-1. In the Frequency Domain the RFFT produces two signals
+// (signalvectors), treated as complex numbers representing the Real Part:
+// Re X[ ] and the Imaginary Part: Im X[ ]. They are seen as the Cosine-
+// und Sine-Components of the base frequencies. Each of these two signals
+// contains one more sample than the half of the original signal: N/2 + 1
+// samples. (this results from the fact, that the sine-components of the
+// first frequency (0) and the last (nyquist, N/2) are always 0). With the
+// complex Fourier-Transformation N complexe values are transformed to N
+// new complex values. For both it applies to: the Frequency Domain
+// contains exactly the same information as the Time-Domain.
+// 
+//  A Real FFT over 64 samples produces values for 33 cosine- and 33
+// sine-wave-amplitudes with the frequencies 0, 1, 2, 3, ..., 30, 31, 32.
+// The first value (frequency 0) is the DC (direct current), the other
+// values have to be seen in practice as factors of a
+// fundamental-frequency which can be calculated by dividing samplerate by
+// windowsize. The highest frequency is the nyquist-frequency
+// (samplerate/2).
+// 
+//////////////////////////////////////////////////////////////////////////////
+
+#include "MFFT.h"
+
+#include <TMath.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MFFT);
+
+using namespace std;
+
+// ---------------------------------------------------------------------------
+//
+//  Default Constructor
+//  Initializes random number generator and default variables
+//
+MFFT::MFFT() : fDim(0)
+{
+}
+
+// --------------------------------------------------------------------------
+//
+//  Destructor. 
+//
+MFFT::~MFFT()
+{
+}
+
+void MFFT::TransformF(const Int_t isign, TArrayF &data)
+{
+  
+  UInt_t   n,mmax,m,j,istep,i;
+  Float_t wtemp,wr,wpr,wpi,wi,theta;
+  Float_t tempr,tempi;
+  
+  Int_t nn = fDim/2;
+  n = nn << 1;
+
+  //
+  // The bit-reversal section of the routine:
+  // Exchange the two complex numbers
+  //
+  j=1;
+  for (i=1;i<n;i+=2) {
+    if (j > i) {
+      Swap(data[j-1],data[i-1]);
+      Swap(data[j],data[i]);
+    }
+    m=nn;
+    while (m >= 2 && j > m) {
+      j -= m;
+      m >>= 1;
+    }
+    j += m;
+  }
+  // 
+  // Here begins the Danielson-Lanczos section of the routine
+  //
+  mmax=2;
+  while (n > mmax) {         // Outer loop executed log_2(nn) times
+
+    istep = mmax << 1;
+    //
+    // Initialize the trigonometric recurrence:
+    //
+    theta = isign*(6.28318530717959/mmax);
+
+    wtemp = TMath::Sin(0.5*theta);
+    wpr   = -2.0*wtemp*wtemp;
+    wpi   = TMath::Sin(theta);
+
+    wr=1.0;
+    wi=0.0;
+
+    for (m=1; m<mmax; m+=2) {
+      for (i=m; i<=n; i+=istep) {
+        // 
+        // The Danielson-Lanczos formula:
+        //
+        j          = i+mmax;
+        tempr      = wr*data[j-1] - wi*data[j];
+        tempi      = wr*data[j]   + wi*data[j-1];
+        data[j-1] = data[i-1]   - tempr;
+        data[j]   = data[i]     - tempi;
+        data[i-1] += tempr;
+        data[i]   += tempi;
+      }
+
+      //
+      // Trigonometric recurrence
+      //
+      wr = (wtemp=wr)*wpr - wi*wpi+wr;
+      wi = wi*wpr         + wtemp*wpi+wi;
+
+    }
+    mmax=istep;
+  }
+}
+
+
+void MFFT::TransformD(const Int_t isign, TArrayD &data)
+{
+  
+  UInt_t   n,mmax,m,j,istep,i;
+  Double_t wtemp,wr,wpr,wpi,wi,theta;
+  Double_t tempr,tempi;
+  
+  Int_t nn = fDim/2;
+  n = nn << 1;
+
+  //
+  // The bit-reversal section of the routine:
+  // Exchange the two complex numbers
+  //
+  j=1;
+  for (i=1;i<n;i+=2) {
+    if (j > i) {
+      Swap(data[j-1],data[i-1]);
+      Swap(data[j],data[i]);
+    }
+    m=nn;
+    while (m >= 2 && j > m) {
+      j -= m;
+      m >>= 1;
+    }
+    j += m;
+  }
+  // 
+  // Here begins the Danielson-Lanczos section of the routine
+  //
+  mmax=2;
+  while (n > mmax) {         // Outer loop executed log_2(nn) times
+
+    istep = mmax << 1;
+    //
+    // Initialize the trigonometric recurrence:
+    //
+    theta = isign*(6.28318530717959/mmax);
+
+    wtemp = TMath::Sin(0.5*theta);
+    wpr   = -2.0*wtemp*wtemp;
+    wpi   = TMath::Sin(theta);
+
+    wr=1.0;
+    wi=0.0;
+
+    for (m=1; m<mmax; m+=2) {
+      for (i=m; i<=n; i+=istep) {
+        // 
+        // The Danielson-Lanczos formula:
+        //
+        j          = i+mmax;
+        tempr      = wr*data[j-1] - wi*data[j];
+        tempi      = wr*data[j]   + wi*data[j-1];
+        data[j-1] = data[i-1]   - tempr;
+        data[j]   = data[i]     - tempi;
+        data[i-1] += tempr;
+        data[i]   += tempi;
+      }
+
+      //
+      // Trigonometric recurrence
+      //
+      wr = (wtemp=wr)*wpr - wi*wpi+wr;
+      wi = wi*wpr         + wtemp*wpi+wi;
+
+    }
+    mmax=istep;
+  }
+}
+
+//
+// Calculates the Fourier transform of a set of n real-valued data points. 
+// Replaces this data (which is stored in array data[1..n]) by the positive
+// frequency half of its complex Fourier transform. The real-valued first 
+// and last components of the complex transform are returned as elements 
+// data[1] and data[2], respectively. n must be a power of 2. This routine
+// also calculates the inverse transform of a complex data array if it is 
+// the transform of real data. (Result in this case mus be multiplied by 
+// 2/n.). From NUMERICAL RECIPES IN C++.
+//
+void MFFT::RealFTF(const Int_t isign)
+{
+  
+  Int_t    i,i1,i2,i3,i4;
+  Float_t  c1=0.5,c2,h1r,h1i,h2r,h2i;
+  Float_t wr,wi,wpr,wpi,wtemp,theta;
+
+  //
+  // Initialize the recurrence
+  //
+  theta = TMath::Pi() / (Double_t)(fDim>>1);
+
+  if(isign==1) // forward transform
+    {
+      c2    = -0.5;
+      TransformF(1,fDataF);
+    }
+  else         // set up backward transform
+    {
+      c2    = 0.5;
+      theta = -theta;
+    }
+
+  wtemp = TMath::Sin(0.5*theta);
+  wpr   = -2.0*wtemp*wtemp;
+  wpi   = TMath::Sin(theta);
+
+  wr    = 1.0 + wpr;
+  wi    = wpi;
+
+  for(i=1;i<(fDim>>2);i++) // case i=0 done separately below
+    {
+
+      i2 = 1 + (i1 = i+i);
+      i4 = 1 + (i3 = fDim-i1);
+
+      //
+      // The two separate transforms are separated out of the data
+      //
+      h1r  =  c1*(fDataF[i1]+fDataF[i3]);
+      h1i  =  c1*(fDataF[i2]-fDataF[i4]);
+      h2r  = -c2*(fDataF[i2]+fDataF[i4]);
+      h2i  =  c2*(fDataF[i1]-fDataF[i3]);
+
+      //
+      // Here, they are recombined to from the true transform 
+      // of the orginal real data
+      //
+      fDataF[i1] =  h1r + wr*h2r - wi*h2i;
+      fDataF[i2] =  h1i + wr*h2i + wi*h2r;
+      fDataF[i3] =  h1r - wr*h2r + wi*h2i;
+      fDataF[i4] = -h1i + wr*h2i + wi*h2r;
+      
+      //
+      // The recurrence
+      //
+      wr = (wtemp=wr)*wpr - wi*wpi + wr;
+      wi =    wi*wpr   + wtemp*wpi + wi;
+    }
+
+  //
+  // Squeeze the first and last data together to get them all 
+  // within the original array
+  //
+  if(isign==1)
+    {
+      fDataF[0] = (h1r=fDataF[0]) + fDataF[1];
+      fDataF[1] =     h1r  -      fDataF[1];
+    }
+  else
+    {
+
+      fDataF[0] = c1*((h1r=fDataF[0]) + fDataF[1]);
+      fDataF[1] = c1*(h1r-fDataF[1]);
+
+      //
+      // The inverse transform for the case isign = -1
+      //
+      TransformF(-1,fDataF);  
+
+      //
+      // normalize correctly (not done in original NR's)
+      //
+      for(i=1;i<=fDim;i++)
+        fDataF[i] *= (2./fDim);
+    }
+}
+void MFFT::RealFTD(const Int_t isign)
+{
+  
+  Int_t    i,i1,i2,i3,i4;
+  Float_t  c1=0.5,c2,h1r,h1i,h2r,h2i;
+  Double_t wr,wi,wpr,wpi,wtemp,theta;
+
+  //
+  // Initialize the recurrence
+  //
+  theta=3.141592653589793/(Double_t) (fDim>>1);
+
+  if(isign==1) // forward transform
+    {
+      c2    = -0.5;
+      TransformD(1,fDataD);
+    }
+  else         // set up backward transform
+    {
+      c2    = 0.5;
+      theta = -theta;
+    }
+
+  wtemp = TMath::Sin(0.5*theta);
+  wpr   = -2.0*wtemp*wtemp;
+  wpi   = TMath::Sin(theta);
+
+  wr    = 1.0 + wpr;
+  wi    = wpi;
+
+  for(i=1;i<(fDim>>2);i++) // case i=0 done separately below
+    {
+
+      i2 = 1 + (i1 = i+i);
+      i4 = 1 + (i3 = fDim-i1);
+
+      //
+      // The two separate transforms are separated out of the data
+      //
+      h1r  =  c1*(fDataD[i1]+fDataD[i3]);
+      h1i  =  c1*(fDataD[i2]-fDataD[i4]);
+      h2r  = -c2*(fDataD[i2]+fDataD[i4]);
+      h2i  =  c2*(fDataD[i1]-fDataD[i3]);
+
+      //
+      // Here, they are recombined to from the true transform 
+      // of the orginal real data
+      //
+      fDataD[i1] =  h1r + wr*h2r - wi*h2i;
+      fDataD[i2] =  h1i + wr*h2i + wi*h2r;
+      fDataD[i3] =  h1r - wr*h2r + wi*h2i;
+      fDataD[i4] = -h1i + wr*h2i + wi*h2r;
+      
+      //
+      // The recurrence
+      //
+      wr = (wtemp=wr)*wpr - wi*wpi + wr;
+      wi =    wi*wpr   + wtemp*wpi + wi;
+    }
+
+  //
+  // Squeeze the first and last data together to get them all 
+  // within the original array
+  //
+  if(isign==1)
+    {
+      fDataD[0] = (h1r=fDataD[0]) + fDataD[1];
+      fDataD[1] =     h1r  -      fDataD[1];
+    }
+  else
+    {
+
+      fDataD[0] = c1*((h1r=fDataD[0]) + fDataD[1]);
+      fDataD[1] = c1*(h1r-fDataD[1]);
+
+      //
+      // The inverse transform for the case isign = -1
+      //
+      TransformD(-1,fDataD);  
+      
+      //
+      // normalize correctly (not done in original NR's)
+      //
+      for(i=1;i<=fDim;i++)
+        fDataD[i] *= (2./fDim);
+    }
+}
+
+
+//
+// Fast Fourier Transform for float arrays
+//
+Float_t* MFFT::RealFunctionFFT(const Int_t n, const Float_t *data)
+{
+
+  fDim = n;
+  CheckDim(n);
+
+  fDataF.Set(fDim);
+  //
+  // Clone the array
+  //
+  for (Int_t i=0;i<fDim;i++)
+    fDataF[i] = data[i];
+
+  RealFTF(1);
+  
+  return fDataF.GetArray();
+
+}
+
+//
+// Fast Inverse Fourier Transform for float arrays
+//
+Float_t* MFFT::RealFunctionIFFT(const Int_t n, const Float_t *data)
+{
+
+  fDim = n;
+  CheckDim(fDim);
+  
+  fDataF.Set(fDim);
+  //
+  // Clone the array
+  //
+  for (Int_t i=0;i<fDim;i++)
+    fDataF[i] = data[i];
+
+  RealFTF(-1);
+  
+  return fDataF.GetArray();
+
+}
+
+//
+// Fast Fourier Transform for double arrays
+//
+Double_t* MFFT::RealFunctionFFT(const Int_t n, const Double_t *data)
+{
+
+  fDim = n;
+  CheckDim(n);
+
+  fDataD.Set(fDim);
+  //
+  // Clone the array
+  //
+  for (Int_t i=0;i<fDim;i++)
+    fDataD[i] = data[i];
+
+  RealFTD(1);
+  
+  return fDataD.GetArray();
+
+}
+
+//
+// Fast Inverse Fourier Transform for double arrays
+//
+Double_t* MFFT::RealFunctionIFFT(const Int_t n, const Double_t *data)
+{
+
+  fDim = n;
+  CheckDim(fDim);
+  
+  fDataD.Set(fDim);
+  //
+  // Clone the array
+  //
+  for (Int_t i=0;i<fDim;i++)
+    fDataD[i] = data[i];
+
+  RealFTD(-1);
+  
+  return fDataD.GetArray();
+
+}
+
+//
+// Fast Fourier Transform for TArrayF's
+//
+TArrayF* MFFT::RealFunctionFFT(const TArrayF *data)
+{
+
+  fDim = data->GetSize();
+  CheckDim(fDim);
+
+  fDataF.Set(fDim);
+  //
+  // Clone the array
+  //
+  for (Int_t i=0;i<fDim;i++)
+    fDataF[i] = data->At(i);
+
+  RealFTF(1);
+  
+  return new TArrayF(fDim,fDataF.GetArray());
+
+}
+
+//
+// Inverse Fast Fourier Transform for TArrayF's
+//
+TArrayF* MFFT::RealFunctionIFFT(const TArrayF *data)
+{
+
+  fDim = data->GetSize();
+  CheckDim(fDim);
+  
+  fDataF.Set(fDim);
+  //
+  // Clone the array
+  //
+  for (Int_t i=0;i<fDim;i++)
+    fDataF[i] = data->At(i);
+
+  RealFTF(-1);
+
+  return new TArrayF(fDim,fDataF.GetArray());
+}
+
+
+//
+// Fast Fourier Transform for TArrayD's
+//
+TArrayD* MFFT::RealFunctionFFT(const TArrayD *data)
+{
+
+  fDim = data->GetSize();
+  CheckDim(fDim);
+
+  fDataD.Set(fDim);
+  //
+  // Clone the array
+  //
+  for (Int_t i=0;i<fDim;i++)
+    fDataD[i] = data->At(i);
+
+  RealFTD(1);
+  
+  return new TArrayD(fDim,fDataD.GetArray());
+
+}
+
+//
+// Inverse Fast Fourier Transform for TArrayD's
+//
+TArrayD* MFFT::RealFunctionIFFT(const TArrayD *data)
+{
+
+  fDim = data->GetSize();
+  CheckDim(fDim);
+  
+  fDataD.Set(fDim);
+  //
+  // Clone the array
+  //
+  for (Int_t i=0;i<fDim;i++)
+    fDataD[i] = data->At(i);
+
+  RealFTD(-1);
+
+  return new TArrayD(fDim,fDataD.GetArray());
+}
+
+
+//
+// Power Spectrum Density Calculation
+//
+TH1D* MFFT::PowerSpectrumDensity(const TH1D *hist)
+{
+
+  TH1D *newhist = (TH1D*)CheckHist(hist,1);
+
+  fDataD.Set(fDim);
+  //
+  // Copy the hist into an array
+  //
+  for (Int_t i=0;i<fDim;i++)
+    fDataD[i] = hist->GetBinContent(i);
+
+  RealFTD(1);
+
+  Int_t dim2 = fDim*fDim;
+  Double_t c02;
+  Double_t ck2;
+  Double_t cn2;
+  //
+  // Fill the new histogram: 
+  //
+  // 1) P(0) = 1/(N*N) |C(0)|*|C(0)|
+  //    (stored in fData{0])
+  //
+  c02 = fDataD[0]*fDataD[0];
+  newhist->Fill(c02/dim2);
+  //
+  // 2) P(k) = 1/(N*N) (|C(k)|*|C(k)| + |C(N-k)|*|C(N-k)|)
+  //
+  for (Int_t k=2;k<fDim-2;k+=2)
+    {
+
+      Int_t ki  = k+1;
+      ck2 = (fDataD[k]*fDataD[k] + fDataD[ki]*fDataD[ki]);
+      newhist->Fill(ck2/dim2);
+    }
+  //
+  // 3) P(N) = 1/(N*N) (|C(n/2)|*|C(n/2)|)
+  //    (stored in fData[1])
+  //
+  cn2 = (fDataD[1]*fDataD[1]);
+  newhist->Fill(cn2/dim2);
+
+  return newhist;
+}
+
+//
+// Power Spectrum Density calculation for TArrayF
+//
+TArrayF* MFFT::PowerSpectrumDensity(const TArrayF *array)
+{
+
+  fDim = array->GetSize();
+  CheckDim(fDim);
+
+  fDataF.Set(fDim);
+  //
+  // Copy the hist into an array
+  //
+  for (Int_t i=0;i<fDim;i++)
+    fDataF[i] = array->At(i);
+
+  RealFTF(1);
+
+  const Int_t dim2  = fDim*fDim;
+  const Int_t dim05 = fDim/2;
+  Float_t c02;
+  Float_t ck2;
+  Float_t cn2;
+  
+  TArrayF *newarray = new TArrayF(dim05);
+
+  //
+  // Fill the new histogram: 
+  //
+  // 1) P(0) = 1/(N*N) |C(0)|*|C(0)|
+  //
+  c02 = (fDataF[0]*fDataF[0]);
+  //  newarray->AddAt(c02/dim2,0);
+  //
+  // 2) P(k) = 1/(N*N) (|C(k)|*|C(k)|))
+  //
+  for (Int_t k=1;k<dim05-1;k++)
+    {
+      const Int_t k2 = k+k;
+      ck2 = (fDataF[k2]*fDataF[k2] + fDataF[k2+1]*fDataF[k2+1]);
+      newarray->AddAt(ck2/dim2,k);
+    }
+  //
+  // 3) P(N) = 1/(N*N) (|C(n/2)|*|C(n/2)|)
+  //
+  cn2 = (fDataF[1]*fDataF[1]);
+  //  newarray->AddAt(cn2,dim05-1);
+  
+  return newarray;
+}
+
+
+//
+// Power Spectrum Density calculation for TArrayI
+//
+TArrayF* MFFT::PowerSpectrumDensity(const TArrayI *array)
+{
+
+  fDim = array->GetSize();
+  CheckDim(fDim);
+
+  fDataF.Set(fDim);
+  //
+  // Copy the hist into an array
+  //
+  for (Int_t i=0;i<fDim;i++)
+    fDataF[i] = (Float_t)array->At(i);
+
+  RealFTF(1);
+
+  const Int_t dim2  = fDim*fDim;
+  const Int_t dim05 = fDim/2;
+  Float_t c02;
+  Float_t ck2;
+  Float_t cn2;
+  
+  TArrayF *newarray = new TArrayF(dim05);
+
+  //
+  // Fill the new histogram: 
+  //
+  // 1) P(0) = 1/(N*N) |C(0)|*|C(0)|
+  //
+  c02 = (fDataF[0]*fDataF[0]);
+  //  newarray->AddAt(c02/dim2,0);
+  //
+  // 2) P(k) = 1/(N*N) (|C(k)|*|C(k)|))
+  //
+  for (Int_t k=1;k<dim05-1;k++)
+    {
+      const Int_t k2 = k+k;
+      ck2 = (fDataF[k2]*fDataF[k2] + fDataF[k2+1]*fDataF[k2+1]);
+      newarray->AddAt(ck2/dim2,k);
+    }
+  //
+  // 3) P(N) = 1/(N*N) (|C(n/2)|*|C(n/2)|)
+  //
+  cn2 = (fDataF[1]*fDataF[1]);
+  //  newarray->AddAt(cn2,dim05-1);
+  
+  return newarray;
+}
+
+
+TArrayD* MFFT::PowerSpectrumDensity(const TArrayD *array)
+{
+  
+  fDim = array->GetSize();
+  CheckDim(fDim);
+
+  fDataD.Set(fDim);
+  //
+  // Copy the hist into an array
+  //
+  for (Int_t i=0;i<fDim;i++)
+    fDataD[i] = array->At(i);
+
+  RealFTD(1);
+
+  const Int_t dim2  = fDim*fDim;
+  const Int_t dim05 = fDim/2;
+  Float_t c02;
+  Float_t ck2;
+  Float_t cn2;
+  
+  TArrayD *newarray = new TArrayD(dim05);
+
+  //
+  // Fill the new histogram: 
+  //
+  // 1) P(0) = 1/(N*N) |C(0)|*|C(0)|
+  //
+  c02 = (fDataD[0]*fDataD[0]);
+  //  newarray->AddAt(c02/dim2,0);
+  //
+  // 2) P(k) = 1/(N*N) (|C(k)|*|C(k)|))
+  //
+  for (Int_t k=1;k<dim05-1;k++)
+    {
+      const Int_t k2 = k+k;
+      ck2 = (fDataD[k2]*fDataD[k2] + fDataD[k2+1]*fDataD[k2+1]);
+      newarray->AddAt(ck2/dim2,k);
+    }
+  //
+  // 3) P(N) = 1/(N*N) (|C(n/2)|*|C(n/2)|)
+  //
+  cn2 = (fDataD[1]*fDataD[1]);
+  //  newarray->AddAt(cn2,dim05-1);
+  
+  return newarray;
+}
+
+
+//
+// Power Spectrum Density calculation for TH1
+//
+TH1F* MFFT::PowerSpectrumDensity(const TH1 *hist)
+{
+
+  TH1F *newhist = (TH1F*)CheckHist(hist,0);
+
+  fDataF.Set(fDim);
+  //
+  // Copy the hist into an array
+  //
+  for (Int_t i=0;i<fDim;i++)
+    fDataF[i] = hist->GetBinContent(i);
+
+  RealFTF(1);
+
+  Int_t dim2 = fDim*fDim;
+  Float_t c02;
+  Float_t ck2;
+  Float_t cn2;
+  //
+  // Fill the new histogram: 
+  //
+  // 1) P(0) = 1/(N*N) |C(0)|*|C(0)|
+  //
+  c02 = (fDataF[0]*fDataF[0]);
+  newhist->Fill(0.,c02/dim2);
+  //
+  // 2) P(k) = 1/(N*N) (|C(k)|*|C(k)|))
+  //
+  for (Int_t k=2;k<fDim;k+=2)
+    {
+      ck2 = (fDataF[k]*fDataF[k] + fDataF[k+1]*fDataF[k+1]);
+      newhist->Fill(k/2.,ck2/dim2);
+    }
+  //
+  // 3) P(N) = 1/(N*N) (|C(n/2)|*|C(n/2)|)
+  //
+  cn2 = (fDataF[1]*fDataF[1]);
+  newhist->Fill(fDim/2.-1.,cn2/dim2);
+  
+  return newhist;
+}
+
+
+//
+// Power Spectrum Density calculation for TH1I
+//
+TH1F* MFFT::PowerSpectrumDensity(const TH1F *hist)
+{
+  return PowerSpectrumDensity((TH1*)hist);
+}
+
+//
+// Power Spectrum Density calculation for TH1I
+//
+TH1F* MFFT::PowerSpectrumDensity(const TH1I *hist)
+{
+  return PowerSpectrumDensity((TH1*)hist);
+}
+
+
+void MFFT::CheckDim(Int_t a)
+{
+
+  // If even number, return 0
+  if (a==2)  return;
+
+  // If odd number, return the closest power of 2
+  if (a & 1) 
+    { 
+      Int_t b = 1; 
+      while (b < fDim/2+1)
+        b <<= 1; 
+
+      fDim = b;
+      //      gLog << warn << "Dimension of Data is not a multiple of 2, will take only first " 
+      //           << fDim << " entries! " << endl;
+      return; 
+    }
+
+  CheckDim(a>>1);
+}
+
+TH1* MFFT::CheckHist(const TH1 *hist, const Int_t flag)
+{
+  
+  // number of entries
+  fDim = hist->GetNbinsX();
+  CheckDim(fDim);
+
+  // Step width
+  Double_t delta = hist->GetBinWidth(1);
+  
+  // Nyquist frequency
+  Axis_t fcrit = 1./(2.*delta);
+  Axis_t low = -0.5;
+  Axis_t up  = fcrit;
+
+  switch (flag)
+    {
+    case 0: 
+      return new TH1F(Form("%s%s",hist->GetName()," PSD"),
+                      Form("%s%s",hist->GetTitle()," - Power Spectrum Density"),
+                      fDim/2,low,up);
+      break;
+    case 1:
+      return new TH1D(Form("%s%s",hist->GetName()," PSD"),
+                      Form("%s%s",hist->GetTitle()," - Power Spectrum Density"),
+                      fDim/2,low,up);
+      break;
+    default:
+      return new TH1F(Form("%s%s",hist->GetName()," PSD"),
+                      Form("%s%s",hist->GetTitle()," - Power Spectrum Density"),
+                      fDim/2,low,up);
+      break;
+    }
+}
+
+//
+// Real function spectrum with data windowing
+//
+TArrayF* MFFT::RealFunctionSpectrum(const TArrayF *data) 
+{
+  
+  fDim = data->GetSize();
+  CheckDim(fDim);
+
+  fDataF.Set(fDim);
+  //
+  // Copy the hist into an array
+  //
+  for (Int_t i=0;i<fDim;i++)
+    fDataF[i] = data->At(i);
+
+  fWindowF.Set(fDim);
+
+  Int_t dim2 = fDim/2;
+
+  TArrayF *power = new TArrayF(dim2);
+
+  // 
+  // Start program spctrm from NR's
+  //
+  Float_t w, facp, facm, sumw=0.;
+  
+  facm = dim2;
+  facp = 1./dim2;
+  
+  for (Int_t j=0;j<dim2;j++)
+    {
+      Int_t j2 = j+j;
+      w     = ApplyWindow(j,facm,facp);
+      sumw += w*w;
+      fWindowF[j2]   = fDataF[j]*w;
+      fWindowF[j2+1] = fDataF[dim2+j]*w;
+    }
+  
+  TransformF(1,fWindowF);
+  
+  power->AddAt(fWindowF[0]*fWindowF[0] + fWindowF[1]*fWindowF[1],0);
+
+  //  power->AddAt(fWindowF[0]*fWindowF[0],0);
+  //  power->AddAt(fWindowF[1]*fWindowF[1],dim2-1);  
+
+
+  for (Int_t j=1;j<dim2;j++)
+    //  for (Int_t j=1;j<dim2;j++)
+    {
+      Int_t j2 = j+j;
+      Float_t buf = fWindowF[j2+1]     *fWindowF[j2+1] 
+                  + fWindowF[j2  ]     *fWindowF[j2  ] 
+                  + fWindowF[fDim-j2+1]*fWindowF[fDim-j2+1] 
+                  + fWindowF[fDim-j2  ]*fWindowF[fDim-j2  ] ;
+      power->AddAt(buf/sumw/(fDim+fDim),j);
+    }
+  
+  return power;
+
+}
Index: /tags/Mars_V0-8-5/Mars/mtools/MFFT.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtools/MFFT.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtools/MFFT.h	(revision 9661)
@@ -0,0 +1,85 @@
+#ifndef MARS_MFFT
+#define MARS_MFFT
+
+#ifndef MARS_MAGIC
+#include "MAGIC.h"
+#endif
+
+#ifndef ROOT_TArrayF
+#include "TArrayF.h"
+#endif
+
+#ifndef ROOT_TArrayD
+#include "TArrayD.h"
+#endif
+
+#ifndef ROOT_TH1F
+#include "TH1F.h"
+#endif
+
+#ifndef ROOT_TH1D
+#include "TH1D.h"
+#endif
+
+class MFFT : public TObject
+{
+private:
+
+  void Swap(Float_t &a,  Float_t &b)    { Float_t  c = a;  a = b;  b = c;  }
+  void Swap(Double_t &a, Double_t &b)   { Double_t c = a;  a = b;  b = c;  }
+
+  void TransformF(const Int_t isign, TArrayF &data);
+  void TransformD(const Int_t isign, TArrayD &data);  
+  void RealFTF(const Int_t isign);
+  void RealFTD(const Int_t isign);
+
+  void CheckDim(Int_t a);
+  TH1 *CheckHist(const TH1 *hist, const Int_t flag);
+
+  Float_t ApplyWindow(const Int_t j, const Float_t a, const Float_t b) const 
+    {
+
+      return 1.0-TMath::Abs((j-a)*b);      // Bartlett
+      // return 1.0;                        // Square
+      // return 1.0-(((j-a)*b)*((j-a)*b));   // Welch
+      
+    }
+  
+  Int_t   fDim;
+  TArrayF fDataF;
+  TArrayD fDataD;  
+  TArrayF fWindowF;
+  TArrayD fWindowD;  
+
+public:
+
+  MFFT();
+  ~MFFT();
+
+  TArrayF*  RealFunctionFFT( const TArrayF *data);
+  TArrayF*  RealFunctionIFFT(const TArrayF *data);  
+  
+  TArrayD*  RealFunctionFFT( const TArrayD *data);
+  TArrayD*  RealFunctionIFFT(const TArrayD *data);  
+  
+  Float_t*  RealFunctionFFT( const Int_t n, const Float_t *data);
+  Float_t*  RealFunctionIFFT(const Int_t n, const Float_t *data);  
+  
+  Double_t* RealFunctionFFT( const Int_t n, const Double_t *data);
+  Double_t* RealFunctionIFFT(const Int_t n, const Double_t *data);  
+  
+  TH1F* PowerSpectrumDensity(const TH1 *hist);
+  TH1F* PowerSpectrumDensity(const TH1F *hist);
+  TH1F* PowerSpectrumDensity(const TH1I *hist);  
+  TH1D* PowerSpectrumDensity(const TH1D *hist);
+
+  TArrayF* PowerSpectrumDensity(const TArrayI *array);  
+  TArrayF* PowerSpectrumDensity(const TArrayF *array);
+  TArrayD* PowerSpectrumDensity(const TArrayD *array);
+
+  TArrayF*  RealFunctionSpectrum(const TArrayF *data);
+  
+  ClassDef(MFFT,0)  // Class to perform a Fast Fourier Transform
+};
+    
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtools/MHSimulatedAnnealing.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtools/MHSimulatedAnnealing.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtools/MHSimulatedAnnealing.cc	(revision 9661)
@@ -0,0 +1,249 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+///////////////////////////////////////////////////////////////////////
+//
+// MHSimulatedAnnealing
+//
+// This class contains different histograms of the Simulated Annealing 
+//   Snapshort during optimization and the final results
+//
+///////////////////////////////////////////////////////////////////////
+#include "MHSimulatedAnnealing.h"
+
+#include <TMatrix.h>
+#include <TObjArray.h>
+
+#include <TStyle.h>
+#include <TCanvas.h>
+
+#include "MBinning.h"
+
+ClassImp(MHSimulatedAnnealing);
+
+// --------------------------------------------------------------------------
+//
+// Setup histograms
+//
+MHSimulatedAnnealing::MHSimulatedAnnealing(UShort_t moves, UShort_t ndim, 
+	                                   const char *name, 
+					   const char *title)
+    : fDim(ndim), fMoves(moves), fTimeEvolution(NULL), fBestEver(), fBestFuncEval()
+{
+
+    //
+    //   set the name and title of this object
+    //
+    fName  = name  ? name  : "MHSimulatedAnnealing";
+    fTitle = title ? title : "Output Histograms of a Simulated Annealing Run";
+    
+    fBestEver.SetName("Hist_BestEver");
+    fBestEver.SetTitle("Best Param. Combinations");
+    fBestEver.SetXTitle("Run Duration");
+    fBestEver.SetYTitle("Parameter Nr.");
+    fBestEver.SetZTitle("Parameter Value");
+    fBestEver.SetDirectory(NULL);
+    
+    fBestFuncEval.SetName("Hist_BestFuncEval");
+    fBestFuncEval.SetTitle("Best Function Evaluation");
+    fBestFuncEval.SetXTitle("Run Duration");
+    fBestFuncEval.SetYTitle("Function Value");
+    fBestFuncEval.SetDirectory(NULL);
+    
+    MBinning binsx, binsy;
+    binsx.SetEdges(fMoves+1, 0, 1);
+    binsy.SetEdges(fDim, 0.5, fDim+0.5);
+    MH::SetBinning(&fBestEver, &binsx, &binsy);
+    
+    // For better visibility, omit the first entry in fBestFuncEval
+    // It has nothing significant, anyway
+    binsx.SetEdges(fMoves,1./(fMoves+1), 1);
+    binsx.Apply(fBestFuncEval);
+    
+}
+
+void MHSimulatedAnnealing::InitFullSimplex()
+{
+    if (fTimeEvolution)
+      delete fTimeEvolution;
+    
+    fTimeEvolution = new TObjArray;
+    fTimeEvolution->SetOwner();
+    
+    for (Int_t i=0;i<fDim;i++) 
+    {
+        TH2F *hist = new TH2F(Form("Hist_%d", i), Form("Parameter %d", i), 
+                              fMoves+1, 0., 1.,fDim+1,0.5,fDim+1.5);
+        hist->SetXTitle("Run Duration");
+        hist->SetYTitle("Point Nr. Simplex");
+        hist->SetZTitle(Form("Value of Parameter %d",i));
+        fTimeEvolution->Add(hist);
+    }
+}
+
+Bool_t MHSimulatedAnnealing::StoreFullSimplex(const TMatrix &p, const UShort_t move) 
+{
+
+    if (!fTimeEvolution)
+        return kFALSE;
+
+    Int_t idx=0;
+    const Axis_t bin = (move-0.5)/(fMoves+1);
+    
+    TIter Next(fTimeEvolution);
+    TH2F *hist=NULL;
+    while ((hist=(TH2F*)Next()))
+      {
+        for (Int_t i=0;i<fDim+1;i++)
+          hist->Fill(bin,i,p(i,idx));
+        idx++;
+      }
+    return kTRUE;
+}
+
+Bool_t MHSimulatedAnnealing::StoreBestValueEver(const TVector &y, const Float_t yb, const UShort_t move)
+{
+    if (y.GetNrows() != fDim) 
+      return kFALSE;
+    
+    const Axis_t bin = (move-0.5)/(fMoves+1);
+    
+    for (Int_t i=0;i<fDim;i++)
+      fBestEver.Fill(bin,0.5+i,((TVector)y)(i));
+    
+    fBestFuncEval.Fill(bin,yb);
+    
+    return kTRUE;
+}
+
+Bool_t MHSimulatedAnnealing::ChangeTitle(const UShort_t index, const char* title) 
+{
+    if (!fTimeEvolution) 
+      return kFALSE;
+
+    TH2F *hist = NULL;
+    if (!(hist = (TH2F*)fTimeEvolution->At(index))) 
+      return kFALSE;
+
+    hist->SetNameTitle(Form("Hist_%s",title),title);
+    hist->SetYTitle(Form("Value of Parameter %s",title));
+
+    return kTRUE;
+}
+
+void MHSimulatedAnnealing::ChangeFuncTitle(const char* title)
+{
+  fBestFuncEval.SetTitle(title);
+}
+
+TObject *MHSimulatedAnnealing::DrawClone(Option_t *opt) const
+{
+    UShort_t i=2;
+  
+    TCanvas *c = MakeDefCanvas(this, 720, 810);
+    if (fTimeEvolution)
+      c->Divide(2,(int)(fDim/2.)+1);
+    else
+      gPad->Divide(1,2);
+  
+    gROOT->SetSelectedPad(NULL);
+  
+    c->cd(1);
+    gStyle->SetOptStat(0);
+    ((TH1&)fBestFuncEval).DrawCopy();   
+    
+    c->cd(2);
+    gStyle->SetOptStat(10);
+    ((TH2&)fBestEver).DrawCopy(opt);   
+    
+    if (fTimeEvolution)
+    {
+      TH2F *hist = NULL;
+      TIter Next(fTimeEvolution);
+      while ((hist=(TH2F*)Next())) 
+        {
+          c->cd(++i);
+          hist->DrawCopy(opt);
+        }
+    }   
+    c->Modified();
+    c->Update();
+    
+    return c;
+}
+
+
+
+// --------------------------------------------------------------------------
+//
+// Draw all histograms. 
+//
+void MHSimulatedAnnealing::Draw(Option_t *opt) 
+{
+    UShort_t i=2;
+
+    if (!gPad)
+      MakeDefCanvas(this,780,940);
+
+    if (fTimeEvolution) 
+      gPad->Divide(2,(int)(fDim/2.)+1);
+    else 
+      gPad->Divide(1,2);
+
+    gPad->cd(1);  
+    gStyle->SetOptStat(0);
+    fBestFuncEval.Draw();
+    gPad->Modified();
+    gPad->Update();
+    
+    gPad->cd(2);
+    gStyle->SetOptStat(10);
+    fBestEver.Draw(opt);
+    gPad->Modified();
+    gPad->Update();
+
+    if (!fTimeEvolution)
+        return;
+    
+    TH2F *hist = NULL;
+    TIter Next(fTimeEvolution);
+    while ((hist=(TH2F*)Next())) 
+    {
+        gPad->cd(++i);
+        hist->Draw(opt);
+    }
+    gPad->Modified();
+    gPad->Update();
+}
+
+// --------------------------------------------------------------------------
+//
+// Delete the histograms.
+//
+MHSimulatedAnnealing::~MHSimulatedAnnealing() 
+{
+  if (fTimeEvolution)
+    delete fTimeEvolution;
+}
+  
Index: /tags/Mars_V0-8-5/Mars/mtools/MHSimulatedAnnealing.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtools/MHSimulatedAnnealing.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtools/MHSimulatedAnnealing.h	(revision 9661)
@@ -0,0 +1,51 @@
+#ifndef MARS_MHSimulatedAnnealing
+#define MARS_MHSimulatedAnnealing
+///////////////////////////////////////////////////////////////////////////////
+//
+//  MHSimulatedAnnealing
+//
+//  Output container of MSimulatedAnnealing
+///////////////////////////////////////////////////////////////////////////////
+#ifndef MARS_MH
+#include "MH.h"
+#endif
+
+#ifndef ROOT_TH2
+#include <TH2.h>
+#endif
+
+class MHSimulatedAnnealing : public MH
+{
+private:
+    UShort_t fDim;             // The dimension of the whole thing
+    UShort_t fMoves;           // The total number of moves
+
+    TObjArray *fTimeEvolution; //-> Display the time evolution of the simplex in TH1D's
+
+    TH2F     fBestEver;        // The best values ever found during search
+    TH1F     fBestFuncEval;    // The best function values ever found during search
+
+public:
+
+    MHSimulatedAnnealing(UShort_t moves = 0,UShort_t ndim = 0, 
+	                 const char *name=NULL, const char *title=NULL);
+    ~MHSimulatedAnnealing();
+
+    void InitFullSimplex();
+    Bool_t StoreFullSimplex(const TMatrix &p, const UShort_t move);
+    Bool_t StoreBestValueEver(const TVector &y, const Float_t yb, const UShort_t move);
+    
+    Bool_t ChangeTitle(const UShort_t index, const char* title);
+    void ChangeFuncTitle(const char* title);    
+    
+    TObjArray *GetTimeEvolution() const   { return fTimeEvolution; }
+    const TH2F &GetBestEver()     const   { return fBestEver; }
+    const TH1F &GetBestFuncEval() const   { return fBestFuncEval; }
+    
+    void Draw(Option_t *opt=NULL);
+    TObject *DrawClone(Option_t *opt=NULL) const;
+    
+    ClassDef(MHSimulatedAnnealing,1) // Storage Histogram Container for Cuteval Results
+};
+    
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtools/MSimulatedAnnealing.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtools/MSimulatedAnnealing.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtools/MSimulatedAnnealing.cc	(revision 9661)
@@ -0,0 +1,628 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Markus Gaug 10/2002  <mailto:markus@ifae.es>
+!
+!   Copyright: MAGIC Software Development, 2002
+!
+!
+\* ======================================================================== */
+
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  MSimulatedAnnealing                                                     //
+//                                                                          //
+//  class to perform a Simulated Annealing minimization on an n-dimensional //
+//  simplex of a function 'FunctionToMinimize(TArrayF &)' in multi-         //
+//  dimensional parameter space.                                            //
+//  (The code is adapted from Numerical Recipies in C++, 2nd ed.,           //
+//  pp. 457-459)                                                            //
+//                                                                          //
+//  Classes can inherit from MSimulatedAnnealing                            //
+//  and use the function:                                                   //
+//                                                                          //
+//  RunSimulatedAnnealing();                                                //
+//                                                                          //
+//  They HAVE TO initialize the following input arguments                   //
+//  (with ndim being the parameter dimension (max. 20)):                    //
+//                                                                          //
+//  1) a TMatrix p(ndim+1,ndim)                                             //
+//     holding the start simplex                                            //
+//  2) a TArrayF y(ndim+1)                                                  //
+//     whose components must be pre-initialized to the values of            //
+//      FunctionToMinimize evaluated at the fNdim+1 vertices (rows) of p    //
+//  3) a TArrayF p0(ndim)                                                   //
+//     whose components contain the lower simplex borders                   //
+//  4) a TArrayF p1(ndim)                                                   //
+//     whose components contain the upper simplex borders                   //
+//    (The simplex will not get reflected out of these borders !!!)         //
+//                                                                          //
+//  These arrays have to be initialized with a call to:                     //
+//  Initialize(TMatrix \&, TArrayF \&, TArrayF \&, TArrayF \&)              //
+//                                                                          //
+//  5) a virtual function FunctionToMinimize(TArrayF &)                     //
+//     acting on a TArrayF(ndim) array of parameter values                  //
+//                                                                          //
+//  Additionally, a global start temperature can be chosen with:            //
+//                                                                          //
+//  SetStartTemperature(Float_t temp)                                       //
+//  (default is: 10)                                                        //
+//                                                                          //
+//  A total number of total moves (watch out for the CPU time!!!) with:     //
+//                                                                          //
+//  SetNumberOfMoves(Float_t totalMoves)                                    //
+//  (default is: 200)                                                       //
+//                                                                          //
+//  The temperature is reduced after evaluation step like:                  //
+//      CurrentTemperature = StartTemperature*(1-currentMove/totalMoves)    //
+//  where currentMove is the cumulative number of moves so far              //
+//                                                                          //
+//  WARNING: The start temperature and number of moves has to be optimized  //
+//           for each individual problem.                                   //
+//           It is not straightforward using the defaults!                  //
+//           In case, you omit this important step,                         //
+//           you will get local minima without even noticing it!!           //
+//                                                                          //
+//  You may define the following variables:                                 //
+//                                                                          //
+//  1) A global convergence criterium fTol                                  //
+//     which determines an early return for:                                //
+//                                                                          //
+//     max(FunctionToMinimize(p))-min(FunctionToMinimize(p))                //
+//     -----------------------------------------------------  \< fTol       //
+//     max(FunctionToMinimize(p))+min(FunctionToMinimize(p))                //
+//                                                                          //
+//     ModifyTolerance(Float_t)                                             //
+//                                                                          //
+//  2) A verbose level for prints to *fLog                                  //
+//                                                                          //
+//     SetVerbosityLevel(Verbosity_t)                                       //
+//                                                                          //
+//  3) A bit if you want to have stored                                     //
+//     the full simplex after every call to Amebsa:                         //
+//                                                                          //
+//     SetFullStorage()                                                     //
+//                                                                          //
+//  4) The random number generator                                          //
+//     e.g. if you want to test the stability of the output                 //
+//                                                                          //
+//     SetRandom(TRandom *rand)                                             //
+//                                                                          //
+//                                                                          //
+//  Output containers:                                                      //
+//                                                                          //
+//  MHSimulatedAnnealing                                                    //
+//                                                                          //
+//  Use:                                                                    //
+//    GetResult()->Draw(Option_t *o)                                        //
+//  or                                                                      //
+//    GetResult()->DrawClone(Option_t *o)                                   //
+//                                                                          //
+//  to retrieve the output histograms                                       //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+#include "MSimulatedAnnealing.h"
+#include "MHSimulatedAnnealing.h"
+
+#include <fstream>
+#include <iostream>
+
+#include <TRandom.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+const Float_t MSimulatedAnnealing::gsYtryStr = 10000000;  
+const Float_t MSimulatedAnnealing::gsYtryCon = 20000000;  
+const Int_t   MSimulatedAnnealing::gsMaxDim  = 20;
+const Int_t   MSimulatedAnnealing::gsMaxStep = 50;
+
+ClassImp(MSimulatedAnnealing);
+
+using namespace std;
+
+// ---------------------------------------------------------------------------
+//
+//  Default Constructor
+//  Initializes random number generator and default variables
+//
+MSimulatedAnnealing::MSimulatedAnnealing()
+    : fResult(NULL), fTolerance(0.0001),
+      fNdim(0), fNumberOfMoves(200),
+      fStartTemperature(10), fFullStorage(kFALSE),
+      fInit(kFALSE), 
+      fP(gsMaxDim, gsMaxDim), fP0(gsMaxDim),
+      fP1(gsMaxDim), fY(gsMaxDim), fYb(gsMaxDim), fYconv(gsMaxDim),
+      fPb(gsMaxDim), fPconv(gsMaxDim),
+      fBorder(kEStrictBorder), fVerbose(kEDefault)
+{
+
+    // random number generator
+    fRandom = gRandom;
+}
+
+// --------------------------------------------------------------------------
+//
+//  Destructor. 
+//
+MSimulatedAnnealing::~MSimulatedAnnealing()
+{
+  if (fResult) 
+    delete fResult;
+}
+
+// ---------------------------------------------------------------------------
+//
+//  Initialization needs the following four members:
+//
+//  1) a TMatrix p(ndim+1,ndim)
+//     holding the start simplex 
+//  2) a TVector y(ndim+1)
+//     whose components must be pre-initialized to the values of 
+//     FunctionToMinimize evaluated at the fNdim+1 vertices (rows) of fP
+//  3) a TVector p0(ndim)
+//     whose components contain the lower simplex borders 
+//  4) a TVector p1(ndim)
+//     whose components contain the upper simplex borders
+//    (The simplex will not get reflected out of these borders !!!)
+//
+//  It is possible to perform an initialization and 
+//  a subsequent RunMinimization several times. 
+//  Each time, a new class MHSimulatedAnnealing will get created
+//  (and destroyed). 
+//
+Bool_t MSimulatedAnnealing::Initialize(const TMatrix &p,  const TVector &y, 
+                                       const TVector &p0, const TVector &p1)
+{
+
+    fNdim = p.GetNcols();
+    fMpts = p.GetNrows();
+
+    //
+    // many necessary checks ...
+    //
+    if (fMpts > gsMaxDim) 
+    {
+       gLog << err << "Dimension of Matrix fP is too big ... aborting." << endl;
+        return kFALSE;
+    }
+    if (fNdim+1 != fMpts) 
+    {
+        gLog << err << "Matrix fP does not have the right dimensions ... aborting." << endl;
+        return kFALSE;
+    }
+    if (y.GetNrows() != fMpts) 
+    {
+        gLog << err << "Array fY has not the right dimension ... aborting." << endl;
+        return kFALSE;
+    }
+    if (p0.GetNrows() != fNdim) 
+    {
+        gLog << err << "Array fP0 has not the right dimension ... aborting." << endl;
+        return kFALSE;
+    }
+    if (p1.GetNrows() != fNdim) 
+    {
+        gLog << err << "Array fP1 has not the right dimension ... aborting." << endl;
+        return kFALSE;
+    }
+
+    //
+    // In order to allow multiple use of the class
+    // without need to construct the class every time new
+    // delete the old fResult and create a new one in RunMinimization
+    //
+    if (fResult)
+       delete fResult;
+
+    fY.ResizeTo(fMpts);
+    
+    fPsum.ResizeTo(fNdim);
+    fPconv.ResizeTo(fNdim);
+    
+    fP0.ResizeTo(fNdim);
+    fP1.ResizeTo(fNdim);
+    fPb.ResizeTo(fNdim);
+    
+    fP.ResizeTo(fMpts,fNdim);
+
+    fY  = y;
+    fP  = p;
+    fP0 = p0;
+    fP1 = p1;
+    fPconv.Zero();
+
+    fInit = kTRUE;
+    fYconv = 0.;
+
+    return kTRUE;
+}
+
+
+// ---------------------------------------------------------------------------
+//
+//  RunMinimization:
+//
+//  Runs only eafter a call to Initialize(const TMatrix \&, const TVector \&,
+//                                        const TVector \&, const TVector \&)
+//  
+//  Temperature and number of moves should have been set
+//  (default: StartTemperature = 10, NumberOfMoves = 200
+//
+//  
+//  It is possible to perform an initialization and 
+//  a subsequent RunMinimization several times. 
+//  Each time, a new class MHSimulatedAnnealing will get created
+//  (and destroyed). 
+Bool_t MSimulatedAnnealing::RunMinimization()
+{
+    if (!fInit)
+    {
+        gLog << err << "No succesful initialization performed yet... aborting." << endl;
+        return kFALSE;
+    }
+
+    Int_t    iter        = 0;
+    UShort_t iret        = 0;
+    UShort_t currentMove = 0;
+    Real_t   currentTemp = fStartTemperature;
+
+    fResult = new MHSimulatedAnnealing(fNumberOfMoves,fNdim);
+    if (fFullStorage) 
+      fResult->InitFullSimplex();
+
+    while(1)
+    {
+        if (iter > 0) 
+        {
+            gLog << "Convergence at move: " << currentMove ;
+            gLog << " and temperature: " << currentTemp << endl;
+            break;
+        }
+        
+        if (currentTemp > 0.) 
+        {
+          //
+          // Reduce the temperature 
+          //
+          // FIXME: Maybe it is necessary to also incorporate other 
+          //        ways to reduce the temperature (T0*(1-k/K)**alpha)
+          // 
+          currentTemp = fStartTemperature*(1.-(float)currentMove++/fNumberOfMoves);
+          iter = 1;
+        } 
+        else 
+        {
+            // Make sure that now, the program will return only on convergence !
+            // The program returns to here only after gsMaxStep moves
+            // If we have not reached convergence until then, we assume that an infinite 
+            // loop has occurred and quit.
+            if (iret != 0) 
+            {
+                gLog << warn << "No Convergence at the end ! " << endl;
+                fY.Zero();
+
+                break;
+            }
+            iter = 150;
+            iret++;
+            currentMove++;
+        }
+        
+        if (fVerbose==2) {
+            gLog << dbginf << " current..." << endl;
+            gLog << " - move:        " << currentMove << endl;
+            gLog << " - temperature: " << currentTemp << endl;
+            gLog << " - best function evaluation: " << fYb << endl;
+        }
+
+        iter = Amebsa(iter, currentTemp);
+
+        // Store the current best values in the histograms
+        fResult->StoreBestValueEver(fPb,fYb,currentMove);
+
+        // Store the complete simplex if we have full storage
+        if (fFullStorage) 
+          fResult->StoreFullSimplex(fP,currentMove);
+    }
+
+    //
+    // Now, the matrizes and vectors have all the same value, 
+    // Need to initialize again to allow a new Minimization
+    //
+    fInit = kFALSE;
+
+    return kTRUE;
+}
+
+// ---------------------------------------------------------------------------
+//
+//  Amebsa
+//
+//  This is the (adjusted) amebsa function from 
+//  Numerical Recipies (pp. 457-458)
+//             
+//  The routine makes iter function evaluations at an annealing
+//  temperature fCurrentTemp, then returns. If iter is returned 
+//  with a poisitive value, then early convergence has occurred. 
+//
+Int_t MSimulatedAnnealing::Amebsa(Int_t iter, const Real_t temp)
+{
+    GetPsum();
+  
+    while (1) 
+    {
+        UShort_t ihi = 0; // Simplex point with highest function evaluation
+        UShort_t ilo = 1; // Simplex point with lowest  function evaluation
+
+        // Function eval. at ilo (with random fluctuations)
+        Real_t ylo = fY(0) + gRandom->Exp(temp); 
+
+        // Function eval. at ihi (with random fluctuations)
+        Real_t yhi = fY(1) + gRandom->Exp(temp); 
+
+        // The function evaluation at next highest point
+        Real_t ynhi = ylo; 
+
+        if (ylo > yhi)
+        {
+            // Determine which point is the highest (worst),
+            // next-highest and lowest (best)
+            ynhi = yhi;
+            yhi  = ylo;
+            ylo  = ynhi;
+        }
+    
+        // By looping over the points in the simplex 
+        for (UShort_t i=2;i<fMpts;i++) 
+        {
+            const Real_t yt = fY(i) + gRandom->Exp(temp);
+      
+            if (yt <= ylo)
+            {
+                ilo = i;
+                ylo = yt;
+            }
+
+            if (yt > yhi)
+            {
+                ynhi = yhi;
+                ihi  = i;
+                yhi  = yt;
+            }
+            else 
+                if (yt > ynhi) 
+                    ynhi = yt;
+        }
+
+        // Now, fY(ilo) is smallest and fY(ihi) is at biggest value 
+        if (iter < 0)
+        {
+            // Enough looping with this temperature, go to decrease it
+            // First put best point and value in slot 0
+            
+            Real_t dum = fY(0);
+            fY(0)      = fY(ilo);
+            fY(ilo)    = dum;
+
+            for (UShort_t n=0;n<fNdim;n++)
+            {
+                dum       = fP(0,n);
+                fP(0,n)   = fP(ilo,n);
+                fP(ilo,n) = dum;
+            }
+          
+            break;
+        }
+        
+        // Compute the fractional range from highest to lowest and
+        // return if satisfactory
+        Real_t tol = fabs(yhi) + fabs(ylo);
+        if (tol != 0)
+            tol = 2.0*fabs(yhi-ylo)/tol;
+    
+        if (tol<fTolerance)
+        {
+            // Put best point and value in fPconv
+            fYconv = fY(ilo);
+            for (UShort_t n=0; n<fNdim; n++)
+                fPconv(n) = fP(ilo, n);  
+
+            break;
+        }
+        iter -= 2;
+
+        // Begin new Iteration. First extrapolate by a factor of -1 through
+        // the face of the simplex across from the high point, i.e. reflect
+        // the simplex from the high point
+        Real_t ytry = Amotsa(-1.0, ihi, yhi,temp);
+    
+        if (ytry <= ylo)
+        {
+            // cout << " !!!!!!!!!!!!!! E X P A N D  !!!!!!!!!!!!!!" << endl;
+            // Gives a result better than the best point, so try an additional
+            // extrapolation by a factor of 2
+            ytry = Amotsa(2.0, ihi, yhi,temp);
+            continue;
+        }
+
+        if (ytry < ynhi)
+        {
+            iter++;
+            continue;
+        }
+
+        // cout << " !!!!!!!!!!!! R E F L E C T  !!!!!!!!!!!!!!!!!!!!" << endl;
+        // The reflected point is worse than the second-highest, so look for an
+        // intermediate lower point, for (a one-dimensional contraction */
+        const Real_t fYsave = yhi;
+        ytry = Amotsa(0.5, ihi, yhi,temp);
+
+        if (ytry < fYsave)
+            continue;
+
+        // cout << " !!!!!!!!!!!! R E F L E C T  !!!!!!!!!!!!!!!!!!!!" << endl;
+        // The reflected point is worse than the second-highest, so look for an
+        // intermediate lower point, for (a one-dimensional contraction */
+        const Real_t ysave = yhi;
+        ytry = Amotsa(0.5, ihi, yhi,temp);
+      
+        if (ytry < ysave)
+            continue;
+
+        // cout << " !!!!!!!!!!!! C O N T R A C T  !!!!!!!!!!!!!!!!!!" << endl;
+        // Cannot seem to get rid of that point, better contract around the
+        // lowest (best) point
+        for (UShort_t i=0; i<fMpts; i++)
+        {
+            if (i != ilo)
+            {
+                for (UShort_t j=0;j<fNdim;j++)
+                {
+                    fPsum(j) = 0.5*(fP(i, j) + fP(ilo, j));
+
+                    // Create new cutvalues
+                    fP(i, j) = fPsum(j);
+                }
+                fY(i) = FunctionToMinimize(fPsum);
+            }
+        }
+
+        iter -= fNdim;
+        GetPsum();
+    }
+    return iter;
+}
+
+void MSimulatedAnnealing::GetPsum()
+{
+    for (Int_t n=0; n<fNdim; n++)
+    {
+        Real_t sum=0.0;
+        for (Int_t m=0;m<fMpts;m++)
+            sum += fP(m,n);
+
+        fPsum(n) = sum;
+    }
+}
+
+
+Real_t MSimulatedAnnealing::Amotsa(const Float_t fac, const UShort_t ihi, 
+                                   Real_t &yhi, const Real_t temp)
+{
+  
+    const Real_t fac1 = (1.-fac)/fNdim;
+    const Real_t fac2 = fac1 - fac;
+
+    Int_t borderflag = 0;
+    TVector ptry(fNdim);
+    TVector cols(fMpts);
+
+    for (Int_t j=0; j<fNdim; j++)
+    {
+        ptry(j) = fPsum(j)*fac1 - fP(ihi, j)*fac2;
+
+        // Check that the simplex does not go to infinite values,
+        // in case of: reflect it
+        const Real_t newcut = ptry(j);
+  
+        if (fP1(j) > fP0(j))
+        {
+            if (newcut > fP1(j))
+            {
+                ptry(j) = fP1(j);
+                borderflag = 1;
+            }
+            else
+                if (newcut < fP0(j))
+                {
+                    ptry(j) = fP0(j);
+                    borderflag = 1;
+                }
+        }
+    
+        else
+        {
+            if (newcut < fP1(j))
+            {
+                ptry(j) = fP1(j);
+                borderflag = 1;
+            }
+            else
+                if (newcut > fP0(j))
+                {
+                    ptry(j) = fP0(j);
+                    borderflag = 1;
+                }
+        }
+    }
+
+    Real_t faccompare = 0.5;
+    Real_t ytry = 0;
+  
+    switch (borderflag)
+    {
+    case kENoBorder:
+        ytry = FunctionToMinimize(fPsum);
+        break;
+
+    case kEStrictBorder:
+        ytry = FunctionToMinimize(fPsum) + gsYtryStr;
+        break;
+
+    case kEContractBorder:
+        ytry = fac == faccompare ? gsYtryCon : gsYtryStr;
+        break;
+    }
+
+    if (ytry < fYb)
+    {
+        fPb = ptry;
+        fYb = ytry;
+    }
+
+    const Real_t yflu = ytry + gRandom->Exp(temp);
+
+    if (yflu >= yhi)
+        return yflu;
+
+    fY(ihi) = ytry;
+    yhi     = yflu;
+    
+    for(Int_t j=0; j<fNdim; j++)
+    {
+        fPsum(j) += ptry(j)-fP(ihi, j);
+        fP(ihi, j) = ptry(j);
+    }
+
+    return yflu;
+}
+
+// ---------------------------------------------------------------------------
+//
+//  Dummy FunctionToMinimize
+//
+//  A class inheriting from MSimulatedAnnealing NEEDS to contain a similiar
+//  
+//  virtual Float_t FunctionToMinimize(const TVector \&)
+//  
+//  The TVector contains the n parameters (dimensions) of the function
+//
+Float_t MSimulatedAnnealing::FunctionToMinimize(const TVector &arr) 
+{
+  return 0.0;
+}
Index: /tags/Mars_V0-8-5/Mars/mtools/MSimulatedAnnealing.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtools/MSimulatedAnnealing.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtools/MSimulatedAnnealing.h	(revision 9661)
@@ -0,0 +1,106 @@
+#ifndef MARS_MSimulatedAnnealing
+#define MARS_MSimulatedAnnealing
+
+#ifndef MARS_MAGIC
+#include "MAGIC.h"
+#endif
+
+#ifndef ROOT_TMatrix
+#include <TMatrix.h>
+#endif
+
+class MHSimulatedAnnealing;
+class TRandom;
+
+class MSimulatedAnnealing : public TObject
+{
+private:
+
+    static const Float_t gsYtryStr;  // Fixed high value to keep the simplex inside the borders
+    static const Float_t gsYtryCon;  // Fixed high value to keep the simplex inside the borders
+    static const Int_t   gsMaxDim;   // Fixed maximum number of dimensions
+    static const Int_t   gsMaxStep;  // Fixed maximum number of loops with temperature=0
+
+    MHSimulatedAnnealing *fResult;   //! The histogram output container
+
+    TRandom *fRandom;                // The random number generator -> random numbers between 0 and 1
+  
+    Real_t   fTolerance;             // The convergence break condition
+  
+    UShort_t fNdim;                  // The number of parameters 
+    UShort_t fMpts;                  // The number of simplex points (=fNdim+1)
+  
+    UShort_t fNumberOfMoves;         // The total number of moves (== CPU time) 
+
+    Real_t   fStartTemperature;      // The start temperature -> will slowly get decreased to 0
+
+    Bool_t   fFullStorage;           // kTRUE -> the whole simplex gets stored in MHSimlutedAnnealing
+    Bool_t   fInit;                  // kTRUE -> initialization was succesful
+
+    TMatrix fP;                      // The (ndim+1,ndim) matrix containing the simplex 
+
+    TVector fPsum;                   // The sum of each point of the simplex
+    
+    TVector fP0;                     // The boundary conditions on the weak side
+    TVector fP1;                     // The boundary conditions on the strong side
+    TVector fY;                      // The array containing the function evaluation results
+
+    Real_t  fYb;                     // The best function evaluation value ever found
+    Real_t  fYconv;                  // The function evaluation value at the convergence point
+    
+    TVector fPb;                     // The parameters belonging to fYb
+    TVector fPconv;                  // The parameters belonging to fYconv
+    
+    Int_t Amebsa(Int_t iter,
+                 const Real_t temp); // The function deciding if the simplex has to get reflected, expanded or contracted
+
+    Real_t   Amotsa(const Float_t  fac,
+                    const UShort_t ihi,
+                    Real_t &yhi,
+                    const Real_t temp); // The function reflecting, expanding and contracting the simplex: fac=-1 -> reflection, fac=0.5 -> contraction, fac=2.0 -> expansion
+
+    void     GetPsum();              
+    
+protected:
+  
+    virtual Float_t FunctionToMinimize(const TVector &arr); // The optimization function  
+
+public:
+    enum BorderFlag_t { kENoBorder, kEStrictBorder, kEContractBorder };
+    enum Verbosity_t  { kEDefault, kEVerbose, kEDebug };
+
+private:
+    BorderFlag_t fBorder;         
+    Verbosity_t  fVerbose;        
+
+public:
+    MSimulatedAnnealing();
+    virtual ~MSimulatedAnnealing();
+
+    void ModifyTolerance(Float_t tol)          { fTolerance = tol;  }
+    void ModifyBorderFlag(BorderFlag_t border) { fBorder    = border; }
+    
+    Bool_t Initialize(const TMatrix &p,  const TVector &y,
+                      const TVector &p0, const TVector &p1);
+  
+    void SetNumberOfMoves(UShort_t moves)      { fNumberOfMoves    = moves;  }
+    void SetStartTemperature(Float_t temp)     { fStartTemperature = temp;   }
+    void SetFullStorage()                      { fFullStorage      = kTRUE;  }  
+    void SetVerbosityLevel(Verbosity_t level)  { fVerbose          = level;  }
+    void SetRandom(TRandom *rand)              { fRandom           = rand;   }
+
+    const TVector &GetPb()    const            { return fPb;    }
+    Float_t GetYb()           const            { return fYb;    }
+
+    const TVector &GetPconv() const            { return fPconv; }    
+    Float_t GetYconv()        const            { return fYconv; }  
+  
+  
+    MHSimulatedAnnealing *GetResult()          { return fResult; }
+  
+    Bool_t RunMinimization();
+  
+    ClassDef(MSimulatedAnnealing,1)  // Class to perform a Simulated Annealing Minimization
+};
+    
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtools/MTFillMatrix.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtools/MTFillMatrix.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtools/MTFillMatrix.cc	(revision 9661)
@@ -0,0 +1,326 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MTFillMatrix
+//
+// Use this tool to fill eg trainings and test-matrices, while the matrix
+// to be filled can be a real matrix (MHMatrix) or a file (MWriteRootFile)
+// or both.
+//
+// First create a reference histogram (MH3). For more details see
+// MFEventSelector2 which is used to select events according to the
+// reference histogram.
+//
+// If no reference histogram is available the number of events are
+// randomly choosen from the sample with a probability which fits
+// the total destination number of events.
+//
+// Here is an example of how to choose 1000 events somehow distributed in
+// size from a file.
+// -----------------------------------------------------------------------
+//
+// MH3 ref("MHillas.fSize");          // choose a predefined size distribution
+// // Now setup the distribution
+//
+// MHMatrix matrix1;                   // create matrix to fill
+// matrix.AddColumn("MHillas.fWidth"); // setup columns of your matrix
+//
+// MReadMarsFile read("myfile.root");  // Setup your 'reader'
+// read.DisableAutoScheme();           // make sure everything is read
+//
+// MTFillMatrix fill(&ref);            // setup MTFillMatrix
+// fill.SetNumDestEvents1(1000);       // setup number of events to select
+// fill.SetDestMatrix1(&matrix1);      // setup destination matrix
+// if (!fill.Process())                // check if everything worked
+//    return;
+// fill.WriteMatrix1("myoutput.root"); // write matrix to file
+//
+//
+// To get two matrices instead of one (splitted randomly) you can add
+// the following before calling Process():
+// ------------------------------------------------------------------------
+//
+// MHMatrix matrix2;
+// fill.SetNumDestEvents2(500);        // setup number of events to select
+// fill.SetDestMatrix2(&matrix2);      // setup destination matrix
+// [...]
+// fill.WriteMatrix2("myoutput2.root");
+//
+//
+// To write both matrices into a single file use:
+// ----------------------------------------------
+//
+// fill.WriteMatrices("myfile.root");
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MTFillMatrix.h"
+
+#include <TFile.h>
+
+#include "MHMatrix.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MEvtLoop.h"
+
+#include "MRead.h"
+#include "MFillH.h"
+#include "MContinue.h"
+#include "MFilterList.h"
+#include "MFEventSelector.h"
+#include "MFEventSelector2.h"
+
+ClassImp(MTFillMatrix);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Print Size and contained columns.
+// Check whether the number of generated events is compatible with
+// the number of requested events.
+//
+Bool_t MTFillMatrix::CheckResult(MHMatrix *m, Int_t num) const
+{
+    if (!m)
+        return kTRUE;
+
+    m->Print("SizeCols");
+
+    const Int_t generated = m->GetM().GetNrows();
+    if (TMath::Abs(generated-num) <= TMath::Sqrt(9.0*num))
+        return kTRUE;
+
+    *fLog << warn << "WARNING - No. of generated events (";
+    *fLog << generated << ") incompatible with requested events (";
+    *fLog << num << ") for " << m->GetDescriptor() << endl;
+
+    return kFALSE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Write the given MHMatrix with its name as default name to a
+// file fname.
+//
+Bool_t MTFillMatrix::WriteMatrix(MHMatrix *m, const TString &fname, Int_t i) const
+{
+    if (!m)
+    {
+        *fLog << "ERROR - Unable to write matrix #" << i << " (=NULL)... ignored." << endl;
+        return kFALSE;
+    }
+    if (fname.IsNull())
+    {
+        *fLog << "ERROR - Unable to write matrix, file name empty." << endl;
+        return kFALSE;
+    }
+
+    TFile file(fname, "RECREATE", m->GetTitle());
+    m->Write();
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Constructor. Takes an MH3 as argument. This MH3 is the reference
+// distribution to fill the matrix. More information can be found
+// at MFEventSelector2 which is used to select the events.
+//
+// If no MH3 *ref is given the events are randomly selected from the
+// total sample - this may result in samples which don't have exactly
+// the predefined size, but it is much faster.
+//
+MTFillMatrix::MTFillMatrix(const MH3 *ref)
+: fReference(0), fReader(0), fDestMatrix1(0), fDestMatrix2(0),
+  fNumDestEvents1(0), fNumDestEvents2(0), fWriteFile1(0), fWriteFile2(0)
+{
+    fName  = "MFillMatrix";
+    fTitle = "Tool to fill MHMatrix from file";
+
+    if (ref)
+        fReference = (MH3*)ref->Clone();
+}
+
+MTFillMatrix::~MTFillMatrix()
+{
+    if (fReference)
+        delete fReference;
+}
+
+// --------------------------------------------------------------------------
+//
+// Fill the matrix (FIXME: Flow diagram missing)
+//
+Bool_t MTFillMatrix::Process()
+{
+    if (!fReader)
+    {
+        *fLog << err << "ERROR - No task to read data was given... abort." << endl;
+        return kFALSE;
+    }
+
+    *fLog << inf;
+    fLog->Separator(GetDescriptor());
+    *fLog << "Fill " << fDestMatrix1->GetDescriptor() << " with " << fNumDestEvents1 << endl;
+    *fLog << "Fill " << fDestMatrix2->GetDescriptor() << " with " << fNumDestEvents2 << endl;
+    *fLog << "Distribution choosen ";
+    if (fReference && fReference->GetHist().GetEntries()>0)
+        *fLog << "from " << fReference->GetDescriptor();
+    else
+        *fLog << "randomly";
+    *fLog << endl;
+
+    //
+    // Create parameter list and task list, add tasklist to parlist
+    //
+    MParList  plist;
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    //
+    // A selector to select a given number of events from a sample
+    //
+    // FIXME: Merge MFEventSelector and MFEventSelector2
+    MFilter *selector=0;
+    if (fReference)
+    {
+        // Case of a reference/nominal distribution
+        // The events must be read before selection
+        MFEventSelector2 *sel = new MFEventSelector2(*fReference);
+        sel->SetNumMax(fNumDestEvents1+fNumDestEvents2);
+        sel->SetInverted();
+
+        selector = sel;
+    }
+    else
+    {
+        // Case of a random distribution
+        // The events can be selected before reading
+        MFEventSelector *sel = new MFEventSelector;
+        sel->SetNumSelectEvts(fNumDestEvents1+fNumDestEvents2);
+        fReader->SetSelector(sel);
+
+        selector = sel;
+    }
+
+    //
+    // Continue for all events which are not (SetInverted())
+    // selected by the 'selector'
+    //
+    MContinue cont(selector);
+
+    //
+    // Create a filter doing a random split
+    //
+    const Double_t prob = (Double_t)fNumDestEvents1/(fNumDestEvents1+fNumDestEvents2);
+    MFEventSelector split;
+    split.SetSelectionRatio(prob);
+
+    //
+    // Create the logical inverted filter for 'split'
+    //
+    MFilterList invsplit;
+    invsplit.AddToList(&split);
+    invsplit.SetInverted();
+
+    //
+    // The two tasks filling the two matrices
+    //
+    MFillH fill1(fDestMatrix1);
+    MFillH fill2(fDestMatrix2);
+    fill1.SetFilter(&split);
+    fill2.SetFilter(&invsplit);
+
+    // entries in MTaskList
+    tlist.AddToList(fReader);        // Read events
+    if (fReference)
+        tlist.AddToList(&cont);      // select a sample of events
+    tlist.AddToList(&invsplit);      // process invsplit (which implicitly processes split)
+    if (fDestMatrix1 && fNumDestEvents1>0)
+        tlist.AddToList(&fill1);     // fill matrix 1
+    if (fDestMatrix2 && fNumDestEvents2>0)
+        tlist.AddToList(&fill2);     // fill matrix 2
+    if (fWriteFile1)
+    {
+        fWriteFile1->SetFilter(&split);
+        tlist.AddToList(fWriteFile1);
+    }
+    if (fWriteFile2)
+    {
+        fWriteFile2->SetFilter(&invsplit);
+        tlist.AddToList(fWriteFile2);
+    }
+
+    //
+    // Execute the eventloop
+    //
+    MEvtLoop evtloop(fName);
+    evtloop.SetParList(&plist);
+    evtloop.SetDisplay(fDisplay);
+    evtloop.SetLogStream(fLog);
+
+    const Bool_t rc = evtloop.Eventloop();
+
+    // Print execution statistics of the tasklist
+    if (rc)
+        tlist.PrintStatistics();
+
+    delete selector;
+
+    if (!rc)
+    {
+        *fLog << err << GetDescriptor() << ": Failed." << endl;
+        return kFALSE;
+    }
+
+    // Check the result of filling...
+    CheckResult(fDestMatrix1, fNumDestEvents1);
+    CheckResult(fDestMatrix2, fNumDestEvents2);
+
+    *fLog << inf << GetDescriptor() << ": Done." << endl;
+    return kTRUE;
+}
+
+// --------------------------------------------------------------------------
+//
+// Write both matrices to a file. Return kFALSE if writing one of them
+// failed or both have the same name.
+//
+Bool_t MTFillMatrix::WriteMatrices(const TString &fname) const
+{
+    if (fDestMatrix1 && fDestMatrix2 &&
+        (TString)fDestMatrix1->GetName()==(TString)fDestMatrix2->GetName())
+    {
+        *fLog << "ERROR - Cannot write matrices (both have the same name)... ignored." << endl;
+        return kFALSE;
+    }
+
+    return WriteMatrix1(fname) && WriteMatrix2(fname);
+}
Index: /tags/Mars_V0-8-5/Mars/mtools/MTFillMatrix.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtools/MTFillMatrix.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtools/MTFillMatrix.h	(revision 9661)
@@ -0,0 +1,74 @@
+#ifndef MARS_MTFillMatrix
+#define MARS_MTFillMatrix
+
+#ifndef MARS_MH3
+#include "MH3.h"
+#endif
+
+class MRead;
+class MTask;
+class MHMatrix;
+
+class MTFillMatrix : public MParContainer
+{
+private:
+    MH3      *fReference;
+    MRead    *fReader;
+    MHMatrix *fDestMatrix1;
+    MHMatrix *fDestMatrix2;
+    Int_t     fNumDestEvents1;
+    Int_t     fNumDestEvents2;
+    MTask    *fWriteFile1;
+    MTask    *fWriteFile2;
+
+    Bool_t CheckResult(MHMatrix *m, Int_t num) const;
+    Bool_t WriteMatrix(MHMatrix *m, const TString &fname, Int_t i) const;
+
+public:
+    MTFillMatrix(const MH3 *ref=NULL);
+    ~MTFillMatrix();
+
+    void SetDestMatrix1(MHMatrix *matrix, UInt_t num=0)
+    {
+        fDestMatrix1 = matrix;
+        if (num>0)
+            fNumDestEvents1 = num;
+    }
+    void SetWriteFile1(MTask *write, UInt_t num=0)
+    {
+        fWriteFile1 = write;
+        if (num>0)
+            fNumDestEvents1 = num;
+    }
+    void SetNumDestEvents1(UInt_t num)
+    {
+        fNumDestEvents1 = num;
+    }
+    void SetDestMatrix2(MHMatrix *matrix, UInt_t num=0)
+    {
+        fDestMatrix2 = matrix;
+        if (num>0)
+            fNumDestEvents2 = num;
+    }
+    void SetWriteFile2(MTask *write, UInt_t num=0)
+    {
+        fWriteFile2 = write;
+        if (num>0)
+            fNumDestEvents2 = num;
+    }
+    void SetNumDestEvents2(UInt_t num)
+    {
+        fNumDestEvents2 = num;
+    }
+
+    void SetReader(MRead *task) { fReader = task; }
+
+    Bool_t Process();
+    Bool_t WriteMatrix1(const TString &fname) const { return WriteMatrix(fDestMatrix1, fname, 1); }
+    Bool_t WriteMatrix2(const TString &fname) const { return WriteMatrix(fDestMatrix2, fname, 2); }
+    Bool_t WriteMatrices(const TString &fname) const;
+
+    ClassDef(MTFillMatrix, 0) // Tool to fill matrices (eg. trainings- and test-matrices)
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtools/MTMinuit.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtools/MTMinuit.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtools/MTMinuit.cc	(revision 9661)
@@ -0,0 +1,329 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Wolfgang Wittek, 7/2003 <mailto:wittek@mppmu.mpg.de>
+!   Author(s): Thomas Bretz, 12/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MTMinuit
+//
+// Class for interfacing with Minuit
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MTMinuit.h"
+
+#include <TMinuit.h>
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+ClassImp(MTMinuit);
+
+using namespace std;
+
+// --------------------------------------------------------------------------
+//
+// Default constructor.
+//
+MTMinuit::MTMinuit(const char *name, const char *title)
+    : fFcn(NULL), fNames(NULL), fMinuit(NULL)
+{
+    fName  = name  ? name  : "MTMinuit";
+    fTitle = title ? title : "Interface for Minuit";
+}
+
+MTMinuit::~MTMinuit()
+{
+    if (fMinuit)
+        delete fMinuit;
+}
+
+TMinuit *MTMinuit::GetMinuit() const
+{
+    return fMinuit;
+}
+
+void MTMinuit::SetFcn(void (*fcn)(Int_t &, Double_t *, Double_t &, Double_t *, Int_t))
+{
+    fFcn = fcn;
+}
+
+void MTMinuit::InitParameters(const TArrayD &vinit, const TArrayD *step, const TString *name)
+{
+    const int n = fVinit.GetSize();
+
+    fVinit = vinit;
+
+    fStep.Set(n);
+    memset(fStep.GetArray(), 0, n*sizeof(Double_t));
+
+    if (step && step->GetSize()!=n)
+    {
+        *fLog << warn << "MTMinuit::SetParameters: number of steps doesn't match number of parameters... ignored." << endl;
+        step = NULL;
+    }
+
+    for (int i=0; i<n; i++)
+        fStep[i] = step ? (*step)[i] : TMath::Abs(fVinit[i]/10.0);
+
+    if (fNames)
+        delete fNames;
+
+    fNames = new TString[n];
+
+    // FIXME: Sanity check for TString array size!
+    for (int i=0; i<n ; i++)
+        fNames[i] = name ? (const char*)name[i] : Form("par%02d", i);
+
+    // ---------------------------------------------------------------
+
+    fLimLo.Set(n);
+    fLimUp.Set(n);
+    memset(fLimLo.GetArray(), 0, n*sizeof(Double_t));
+    memset(fLimUp.GetArray(), 0, n*sizeof(Double_t));
+
+    fFix.Set(n);
+    memset(fFix.GetArray(), 0, n*sizeof(Char_t));
+}
+
+void MTMinuit::SetLimits(const TArrayD &limlo, const TArrayD &limup)
+{
+    if (fVinit.GetSize()==limlo.GetSize())
+        fLimLo = limlo;
+    else
+        *fLog << warn << "MTMinuit::SetLimits: size of limlo doesn't match number of parameters... ignored." << endl;
+
+    if (fVinit.GetSize()==limup.GetSize())
+        fLimUp = limup;
+    else
+        *fLog << warn << "MTMinuit::SetLimits: size of limup doesn't match number of parameters... ignored." << endl;
+}
+
+void MTMinuit::SetFixedParameters(const TArrayC &fix)
+{
+    if (fVinit.GetSize()==fix.GetSize())
+        fFix = fix;
+    else
+        *fLog << warn << "MTMinuit::SetFixedParameters: size of fix doesn't match number of parameters... ignored." << endl;
+}
+
+// -----------------------------------------------------------------------
+//
+// Interface to MINUIT
+//
+Bool_t MTMinuit::CallMinuit(TObject *objectfit , const TString &method, Bool_t nulloutput)
+{
+    if (!fFcn(NULL))
+    {
+        *fLog << err << "CallMinuit: ERROR - fFcn not set... abort." << endl;
+        return kFALSE;
+    }
+    if (!fNames)
+    {
+        *fLog << err << "CallMinuit: ERROR - Parameters not set... abort." << endl;
+        return kFALSE;
+    }
+
+    // Make a copy of fStep
+    TArrayD step(fStep);
+
+    // Save gMinuit
+    TMinuit *const save = gMinuit;
+
+    // Set the maximum number of parameters
+    if (fMinuit)
+        delete fMinuit;
+    fMinuit = new TMinuit(fVinit.GetSize());
+
+    //
+    // Set the print level
+    // -1   no output except SHOW comands
+    //  0   minimum output
+    //  1   normal output (default)
+    //  2   additional ouput giving intermediate results
+    //  3   maximum output, showing progress of minimizations
+    //
+    fMinuit->SetPrintLevel(-1);
+
+    //..............................................
+    // Printout for warnings
+    //    SET WAR      print warnings
+    //    SET NOW      suppress warnings
+    Int_t errWarn;
+    Double_t tmpwar = 0;
+    fMinuit->mnexcm("SET NOW", &tmpwar, 0, errWarn);
+    //fMinuit->mnexcm("SET WAR", &tmpwar, 0, errWarn);
+
+    //..............................................
+    // Set the address of the minimization function
+    fMinuit->SetFCN(fFcn);
+
+    //..............................................
+    // Store address of object to be used in fcn
+    fMinuit->SetObjectFit(objectfit);
+
+    //..............................................
+    // Set starting values and step sizes for parameters
+    for (Int_t i=0; i<fVinit.GetSize(); i++)
+    {
+        if (!fMinuit->DefineParameter(i, fNames[i], fVinit[i], fStep[i], fLimLo[i], fLimUp[i]))
+            continue;
+
+        *fLog << err << "CallMinuit: Error in defining parameter " << fNames[i] << endl;
+        return kFALSE;
+    }
+
+    //
+    // Error definition :
+    //
+    //    for chisquare function :
+    //      up = 1.0   means calculate 1-standard deviation error
+    //         = 4.0   means calculate 2-standard deviation error
+    //
+    //    for log(likelihood) function :
+    //      up = 0.5   means calculate 1-standard deviation error
+    //         = 2.0   means calculate 2-standard deviation error
+    //
+    fMinuit->SetErrorDef(1.0);
+
+    // Int_t errMigrad;
+    // Double_t tmp = 0;
+    // fMinuit->mnexcm("MIGRAD", &tmp, 0, errMigrad);
+
+    // fix a parameter
+    for (Int_t i=0; i<fVinit.GetSize(); i++)
+    {
+        if (!fFix[i])
+            continue;
+
+        fMinuit->FixParameter(i);
+    }
+
+    //..............................................
+    // This doesn't seem to have any effect
+    // Set maximum number of iterations (default = 500)
+    //Int_t maxiter = 100000;
+    //fMinuit->SetMaxIterations(maxiter);
+
+    // minimization by the method of Migrad
+    Int_t fErrMinimize=0;
+    if (method.Contains("Migrad", TString::kIgnoreCase))
+    {
+        if (nulloutput)
+            fLog->SetNullOutput(kTRUE);
+        Double_t tmp = 0;
+        fMinuit->mnexcm("MIGRAD", &tmp, 0, fErrMinimize);
+        if (nulloutput)
+            fLog->SetNullOutput(kFALSE);
+    }
+
+    //..............................................
+    // same minimization as by Migrad
+    // but switches to the SIMPLEX method if MIGRAD fails to converge
+    if (method.Contains("Minimize", TString::kIgnoreCase))
+    {
+        Double_t tmp = 0;
+        fMinuit->mnexcm("MINIMIZE", &tmp, 0, fErrMinimize);
+    }
+
+    //..............................................
+    // minimization by the SIMPLEX method
+    if (method.Contains("Simplex", TString::kIgnoreCase))
+    {
+        Double_t tmp[2];
+        tmp[0] = 3000; // maxcalls;
+        tmp[1] = 0.1;  // tolerance;
+
+        if (nulloutput)
+            fLog->SetNullOutput(kTRUE);
+        fMinuit->mnexcm("SIMPLEX", &tmp[0], 2, fErrMinimize);
+        if (nulloutput)
+            fLog->SetNullOutput(kFALSE);
+    }
+
+    //..............................................
+    // check quality of minimization
+    // istat = 0   covariance matrix not calculated
+    //         1   diagonal approximation only (not accurate)
+    //         2   full matrix, but forced positive-definite
+    //         3   full accurate covariance matrix
+    //             (indication of normal convergence)
+    Double_t fMin,   fEdm,   fErrdef;
+    Int_t    fNpari, fNparx, fIstat;
+    fMinuit->mnstat(fMin, fEdm, fErrdef, fNpari, fNparx, fIstat);
+
+    if (fErrMinimize != 0)
+    {
+        *fLog << err << "CallMinuit: Minimization failed with:" << endl;
+        *fLog << "  fMin = " << fMin << endl;
+        *fLog << "  fEdm = "  << fEdm << endl;
+        *fLog << "  fErrdef = "  << fErrdef << endl;
+        *fLog << "  fIstat = " << fIstat << endl;
+        *fLog << "  fErrMinimize = " << fErrMinimize << endl;
+        return kFALSE;
+    }
+
+    //..............................................
+    // minimization by the method of Migrad
+    if (method.Contains("Hesse", TString::kIgnoreCase))
+    {
+        Double_t tmp = 0;
+        fMinuit->mnexcm("HESSE", &tmp, 0, fErrMinimize);
+    }
+
+    //..............................................
+    // Minos error analysis
+    if (method.Contains("Minos", TString::kIgnoreCase))
+    {
+        Double_t tmp = 0;
+        fMinuit->mnexcm("MINOS", &tmp, 0, fErrMinimize);
+    }
+
+    //..............................................
+    // Print current status of minimization
+    // if nkode = 0    only function value
+    //            1    parameter values, errors, limits
+    //            2    values, errors, step sizes, internal values
+    //            3    values, errors, step sizes, 1st derivatives
+    //            4    values, parabolic errors, MINOS errors
+
+    //Int_t nkode = 4;
+    //fMinuit->mnprin(nkode, fmin);
+
+    //..............................................
+    // call fcn with IFLAG = 3 (final calculation : calculate p(chi2))
+    // iflag = 1   initial calculations only
+    //         2   calculate 1st derivatives and function
+    //         3   calculate function only
+    //         4   calculate function + final calculations
+    Double_t iflag = 3;
+    Int_t errfcn3;
+    fMinuit->mnexcm("CALL", &iflag, 1, errfcn3);
+
+    // WW : the following statements were commented out because the
+    // Minuit object will still be used;
+    // this may be changed in the future 
+    gMinuit = save;
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mtools/MTMinuit.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtools/MTMinuit.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtools/MTMinuit.h	(revision 9661)
@@ -0,0 +1,51 @@
+#ifndef MARS_MTMinuit
+#define MARS_MTMinuit
+
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif
+
+#ifndef ROOT_TArrayC
+#include <TArrayC.h>
+#endif
+
+#ifndef ROOT_TArrayD
+#include <TArrayD.h>
+#endif
+
+class TMinuit;
+
+class MTMinuit : public MParContainer
+{
+private:
+    // FIXME: Maybe we can use a TMinuit Object to store all this?
+    void (*fFcn)(Int_t &, Double_t *, Double_t &, Double_t *, Int_t);
+
+    TString *fNames;
+    TMinuit *fMinuit;
+
+    TArrayD fVinit;
+    TArrayD fStep;
+    TArrayD fLimLo;
+    TArrayD fLimUp;
+    TArrayC fFix;
+
+public:
+    // FIXME: Use FCN as first argument...
+    MTMinuit(const char *name=NULL, const char *title=NULL);
+    ~MTMinuit();
+
+    Bool_t CallMinuit(TObject *fObjectFit, const TString &method, Bool_t nulloutput);
+
+    TMinuit *GetMinuit() const;
+
+    void SetFcn(void (*fcn)(Int_t &, Double_t *, Double_t &, Double_t *, Int_t));
+    void InitParameters(const TArrayD &vinit, const TArrayD *step=0, const TString *name=0);
+
+    void SetLimits(const TArrayD &limlo, const TArrayD &limup);
+    void SetFixedParameters(const TArrayC &fix);
+
+    ClassDef(MTMinuit, 0) // Class for interfacing with Minuit
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtools/MagicCivilization.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtools/MagicCivilization.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtools/MagicCivilization.cc	(revision 9661)
@@ -0,0 +1,441 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz 07/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MagicCivilization
+// ---------
+//
+// Tool to visualize Next Neighbours.
+//
+// Start the show by:
+//   MagicCivilization show;
+//
+// Use the following keys:
+// -----------------------
+//
+//   * Space:
+//     Toggle between auto increment and manual increment
+//
+//   * Right/Left:
+//     Increment/Decrement pixel number by 1
+//
+//   * Right/Left:
+//     Increment/Decrement pixel number by 1
+//
+//   * Up/Down:
+//     Increment/Decrement pixel number by 10
+//
+//   * PageUp/PageDown:
+//     Increment/Decrement pixel number by 100
+//
+//   * Home/End:
+//     Jump to first/last pixel
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MagicCivilization.h"
+
+#include <iostream>
+
+#include <KeySymbols.h>
+
+#include <TCanvas.h>
+#include <TRandom.h>
+#include <TInterpreter.h>
+
+#include "MHexagon.h"
+
+#include "MGeomPix.h"
+#include "MGeomCamCT1.h"
+#include "MGeomCamMagic.h"
+
+ClassImp(MagicCivilization);
+
+using namespace std;
+
+void MagicCivilization::Free()
+{
+    if (!fGeomCam)
+        return;
+
+    fPixels->Delete();
+
+    delete fPixels;
+
+    delete fGeomCam;
+}
+
+// ------------------------------------------------------------------------
+//
+// Draw all pixels of the camera
+//  (means apend all pixelobjects to the current pad)
+//
+void MagicCivilization::DrawHexagons()
+{
+    for (UInt_t i=0; i<fNumPixels; i++)
+        (*this)[i].Draw();
+}
+
+void MagicCivilization::ChangeCamera()
+{
+    static Bool_t ct1=kFALSE;
+
+    cout << "Change to " << (ct1?"Magic":"CT1") << endl;
+
+    if (ct1)
+        SetNewCamera(new MGeomCamMagic);
+    else
+        SetNewCamera(new MGeomCamCT1);
+
+    ct1 = !ct1;
+
+    DrawHexagons();
+}
+
+void MagicCivilization::SetNewCamera(MGeomCam *geom)
+{
+    Free();
+
+    //
+    //  Reset the display geometry
+    //
+    fW=0;
+    fH=0;
+
+    //
+    //  Set new camera
+    //
+    fGeomCam = geom;
+
+    //
+    //  create the hexagons of the display
+    //
+    fNumPixels = fGeomCam->GetNumPixels();
+    fRange     = fGeomCam->GetMaxRadius();
+
+    //
+    // Construct all hexagons. Use new-operator with placement
+    //
+    fPixels = new TClonesArray("MHexagon", fNumPixels);
+
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        MHexagon &h = *new ((*fPixels)[i]) MHexagon((*fGeomCam)[i]);
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+        h.SetBit(kNoContextMenu|kCannotPick);
+#endif
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+//  default constructor
+//
+MagicCivilization::MagicCivilization(Byte_t lim, UShort_t init)
+    : fTimer(this, 500, kTRUE), fGeomCam(NULL), fNumInit(init), fLimit(lim), fW(0), fH(0)
+{
+    SetNewCamera(new MGeomCamMagic);
+
+    //
+    // Make sure, that the object is destroyed when the canvas/pad is
+    // destroyed. Make also sure, that the interpreter doesn't try to
+    // delete it a second time.
+    //
+    SetBit(kCanDelete);
+    gInterpreter->DeleteGlobal(this);
+
+    Draw();
+
+    fTimer.TurnOn();
+}
+
+// ------------------------------------------------------------------------
+//
+// Destructor. Deletes TClonesArrays for hexagons and legend elements.
+//
+MagicCivilization::~MagicCivilization()
+{
+    fTimer.TurnOff();
+    Free();
+
+    if (fDrawingPad->GetListOfPrimitives()->FindObject(this)==this)
+    {
+        fDrawingPad->RecursiveRemove(this);
+        delete fDrawingPad;
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// This is called at any time the canvas should get repainted.
+// Here we maintain an aspect ratio of 5/4=1.15. This makes sure,
+// that the camera image doesn't get distorted by resizing the canvas.
+//
+void MagicCivilization::Paint(Option_t *opt)
+{
+    const UInt_t w = (UInt_t)(gPad->GetWw()*gPad->GetAbsWNDC());
+    const UInt_t h = (UInt_t)(gPad->GetWh()*gPad->GetAbsHNDC());
+
+    //
+    // Check for a change in width or height, and make sure, that the
+    // first call also sets the range
+    //
+    if (w*fH == h*fW && fW && fH)
+        return;
+
+    //
+    // Calculate aspect ratio (5/4=1.25 recommended)
+    //
+    const Double_t ratio = (Double_t)w/h;
+
+    Float_t x;
+    Float_t y;
+
+    if (ratio>1.0)
+    {
+        x = fRange*(ratio*2-1);
+        y = fRange;
+    }
+    else
+    {
+        x = fRange;
+        y = fRange/ratio;
+    }
+
+    fH = h;
+    fW = w;
+
+    //
+    // Set new range
+    //
+    fDrawingPad->Range(-fRange, -y, x, y);
+}
+
+void MagicCivilization::Reset()
+{
+    if (fNumInit>=fNumPixels)
+        fNumInit = fNumPixels-1;
+    if (fNumInit<0)
+        fNumInit = 0;
+
+    if (fLimit<0)
+        fLimit=6;
+    if (fLimit>6)
+        fLimit=0;
+
+
+    TRandom rnd(0);
+    for (int i=0; i<fNumPixels; i++)
+        (*fGeomCam)[i].ResetBit(kUserBits);
+
+    for (int i=0; i<fNumInit; i++)
+    {
+        Int_t idx;
+
+        do idx = (Int_t)rnd.Uniform(fNumPixels);
+        while ((*fGeomCam)[idx].TestBit(kHasFlag));
+
+        if (idx>=fNumPixels)
+            cout << "!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+
+        (*fGeomCam)[idx].SetBit(kHasFlag);
+    }
+
+    fAuto = kFALSE;
+    fStep = 0;
+
+    Update();
+
+    fDrawingPad->Modified();
+    fDrawingPad->Update();
+}
+
+// ------------------------------------------------------------------------
+//
+// Call this function to draw the camera layout into your canvas.
+// Setup a drawing canvas. Add this object and all child objects
+// (hexagons, etc) to the current pad. If no pad exists a new one is
+// created.
+//
+void MagicCivilization::Draw(Option_t *option)
+{
+    //
+    // if no canvas is yet existing to draw into, create a new one
+    //
+    /*TCanvas *c =*/ new TCanvas("MagicCivilization", "Magic Civilization", 0, 0, 800, 800);
+    //c->ToggleEventStatus();
+
+    fDrawingPad = gPad;
+    fDrawingPad->SetBorderMode(0);
+    fDrawingPad->SetFillColor(22);
+
+    //
+    // Append this object, so that the aspect ratio is maintained
+    // (Paint-function is called)
+    //
+    AppendPad(option);
+
+    //
+    // Reset the game pad
+    //
+    DrawHexagons();
+
+    fCivilization.SetTextAlign(23);   // centered/bottom
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+    fCivilization.SetBit(kNoContextMenu|kCannotPick);
+#endif
+    fCivilization.Draw();
+
+    Reset();
+}
+
+void MagicCivilization::Update()
+{
+    TString txt = "Lim: ";
+    txt += (int)fLimit;
+    txt += "  Init: ";
+    txt += fNumInit;
+    txt += "  On: ";
+    txt += fNumCivilizations;
+    txt += "  Step: ";
+    txt += fStep;
+
+    if (!fAuto)
+        txt += "  (paused)";
+
+    fCivilization.SetText(0, fRange, txt);
+}
+
+
+
+// ------------------------------------------------------------------------
+//
+// Execute a mouse event on the camera
+//
+void MagicCivilization::ExecuteEvent(Int_t event, Int_t keycode, Int_t keysym)
+{
+    if (event!=kKeyPress)
+        return;
+
+    switch (keysym)
+    {
+    default:
+        return;
+
+    case kKey_Space:
+        if ((fNumCivilizations==0 || fNumCivilizations==fNumPixels) && !fAuto)
+            Reset();
+        fAuto = !fAuto;
+        Update();
+        fDrawingPad->Update();
+        return;
+
+    case kKey_Right:
+        fNumInit += 1;;
+        break;
+
+    case kKey_Left:
+        fNumInit -= 1;
+        break;
+
+    case kKey_Up:
+        fNumInit += 10;
+        break;
+
+    case kKey_Down:
+        fNumInit -= 10;
+        break;
+
+    case kKey_PageUp:
+        fNumInit += 100;
+        break;
+
+    case kKey_PageDown:
+        fNumInit -= 100;
+        break;
+
+    case kKey_Plus:
+        fLimit++;
+        break;
+
+    case kKey_Minus:
+        fLimit--;
+        break;
+    }
+
+    Reset();
+}
+
+Bool_t MagicCivilization::HandleTimer(TTimer *timer)
+{
+    if (!fAuto)
+        return kTRUE;
+
+    for (int i=0; i<fNumPixels; i++)
+    {
+        MGeomPix &pix = (*fGeomCam)[i];
+
+        Byte_t cnt=0;
+        for (int j=0; j<pix.GetNumNeighbors(); j++)
+            if ((*fGeomCam)[pix.GetNeighbor(j)].TestBit(kHasFlag))
+                cnt++;
+
+        cnt += (6-pix.GetNumNeighbors())*cnt/6;
+
+        if (cnt>fLimit)
+            pix.SetBit(kHasCreation);
+    }
+
+    fNumCivilizations = 0;
+    for (int i=0; i<fNumPixels; i++)
+    {
+        MGeomPix &pix = (*fGeomCam)[i];
+        MHexagon &hex = (*this)[i];
+
+        if (pix.TestBit(kHasCreation))
+        {
+            pix.SetBit(kHasFlag);
+            hex.SetFillColor(kBlack);
+            fNumCivilizations++;
+        }
+        else
+        {
+            pix.ResetBit(kHasFlag);
+            hex.SetFillColor(kBackground);
+        }
+        pix.ResetBit(kHasCreation);
+    }
+
+    if (fNumCivilizations==0 || fNumCivilizations==fNumPixels)
+        fAuto = kFALSE;
+
+    fStep++;
+
+    Update();
+
+    fDrawingPad->Update();
+
+    return kTRUE;
+}
+
Index: /tags/Mars_V0-8-5/Mars/mtools/MagicCivilization.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtools/MagicCivilization.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtools/MagicCivilization.h	(revision 9661)
@@ -0,0 +1,81 @@
+#ifndef MARS_MagicCivilization
+#define MARS_MagicCivilization
+
+#ifndef MARS_MAGIC
+#include "MAGIC.h"
+#endif
+
+#ifndef ROOT_TText
+#include <TText.h>
+#endif
+#ifndef ROOT_TTimer
+#include <TTimer.h>
+#endif
+#ifndef ROOT_TClonesArray
+#include <TClonesArray.h>
+#endif
+
+class TMarker;
+class TVirtualPad;
+
+class MGeomCam;
+class MHexagon;
+
+class MagicCivilization : public TObject
+{
+private:
+    enum
+    {
+        kBackground   = 50,
+        kHasFlag      = BIT(17),
+        kHasCreation  = BIT(18),
+        kUserBits     = 0x7fc000 // 14-23 are allowed
+    };
+
+    TTimer    fTimer;           // timer rising the 500ms interrputs
+
+    MGeomCam *fGeomCam;         // pointer to camera geometry
+
+    UShort_t  fNumPixels;       // number of pixels in the present geometry
+    Short_t   fNumInit;         // number of bombs in the field
+    Float_t   fRange;           // the range in millimeters of the present geometry
+
+    Bool_t    fAuto;
+
+    Char_t    fLimit;
+
+    UShort_t  fNumCivilizations;
+    UInt_t    fStep;
+
+    TText     fCivilization;    // TText showing the numbers of pixels and bombs
+
+    UInt_t    fW;               // Width of canvas
+    UInt_t    fH;               // Height of canvas
+
+    TClonesArray *fPixels;      // array of all hexagons
+    TVirtualPad  *fDrawingPad;  // pad in which we are drawing
+
+    MHexagon &operator[](int i) { return *((MHexagon*)fPixels->At(i)); }
+
+    void   Update();
+    void   Free();
+    void   DrawHexagons();
+    void   SetNewCamera(MGeomCam *);
+
+    Bool_t HandleTimer(TTimer *timer);
+    void   Draw(Option_t *option="");
+    void   Paint(Option_t *option="");
+    void   ExecuteEvent(Int_t event, Int_t px, Int_t py);
+    Int_t  DistancetoPrimitive(Int_t px, Int_t py) { return 0; }
+
+public:
+    MagicCivilization(Byte_t lim=2, UShort_t init=200);
+    ~MagicCivilization();
+
+    void ChangeCamera(); //*MENU*
+    void Reset();        //*MENU*
+
+    ClassDef(MagicCivilization, 0) // Tool to visualize next neighbours
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtools/MagicDomino.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtools/MagicDomino.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtools/MagicDomino.cc	(revision 9661)
@@ -0,0 +1,724 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz 07/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MagicDomino
+// -----------
+//
+// Magic Camera games.
+//
+// Start the show by:
+//   MagicDomino show;
+//
+// Use the following keys:
+// -----------------------
+//
+//   * Cursor up/down, left/right:
+//     Move tile
+//
+//   * Space:
+//     Rotate tile
+//
+//   * Enter:
+//     Set tile
+//
+//   * Esc:
+//     Skip tile
+//
+//  Rules:
+//  ------
+//
+//   Each hexagon in the tile must at least have one neighbor
+//   which has the same color. It is not allowed to put a tile onto
+//   another one. The game is over if you have skipped three tiles
+//   in a row.
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MagicDomino.h"
+
+#include <iostream>
+
+#include <KeySymbols.h>
+
+#include <TCanvas.h>
+#include <TRandom.h>
+#include <TInterpreter.h>
+
+#include "MHexagon.h"
+
+#include "MGeomPix.h"
+#include "MGeomCamCT1.h"
+#include "MGeomCamMagic.h"
+
+ClassImp(MagicDomino);
+
+using namespace std;
+
+// ------------------------------------------------------------------------
+//
+// Free all onbects connected to a special camera geometry
+//
+void MagicDomino::Free()
+{
+    if (!fGeomCam)
+        return;
+
+    fPixels->Delete();
+
+    delete fPixels;
+
+    delete fGeomCam;
+}
+
+// ------------------------------------------------------------------------
+//
+// Draw all pixels of the camera
+//  (means apend all pixelobjects to the current pad)
+//
+void MagicDomino::DrawHexagons()
+{
+    for (UInt_t i=0; i<fNumPixels; i++)
+        (*this)[i].Draw();
+}
+
+// ------------------------------------------------------------------------
+//
+// Change camera from Magic to CT1 and back
+//
+void MagicDomino::ChangeCamera()
+{
+    static Bool_t ct1=kFALSE;
+
+    cout << "Change to " << (ct1?"Magic":"CT1") << endl;
+
+    if (ct1)
+        SetNewCamera(new MGeomCamMagic);
+    else
+        SetNewCamera(new MGeomCamCT1);
+
+    ct1 = !ct1;
+
+    Reset();
+    DrawHexagons();
+}
+
+// ------------------------------------------------------------------------
+//
+// Reset/set all veriables needed for a new camera geometry
+//
+void MagicDomino::SetNewCamera(MGeomCam *geom)
+{
+    Free();
+
+    //
+    //  Reset the display geometry
+    //
+    fW=0;
+    fH=0;
+
+    //
+    //  Set new camera
+    //
+    fGeomCam = geom;
+
+    //
+    //  create the hexagons of the display
+    //
+    fNumPixels = fGeomCam->GetNumPixels();
+    fRange     = fGeomCam->GetMaxRadius();
+
+    //
+    // Construct all hexagons. Use new-operator with placement
+    //
+    fPixels = new TClonesArray("MHexagon", fNumPixels);
+
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        MHexagon &h = *new ((*fPixels)[i]) MHexagon((*fGeomCam)[i]);
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+        h.SetBit(kNoContextMenu|kCannotPick);
+#endif
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// remove the pixel numbers in the tile from the pad
+//
+void MagicDomino::RemoveNumbers()
+{
+    for (int i=0; i<6; i++)
+        if (fText[i])
+        {
+            delete fText[i];
+            fText[i] = NULL;
+        }
+}
+
+// ------------------------------------------------------------------------
+//
+// Reset/restart the game
+//
+void MagicDomino::Reset()
+{
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        MHexagon &h = (*this)[i];
+        h.SetFillColor(kBackground);
+        h.ResetBit(kUserBits);
+    }
+
+
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+    fDrawingPad->SetBit(kNoContextMenu);
+    SetBit(kNoContextMenu);
+#endif
+
+    if (fDone)
+    {
+        delete fDone;
+        fDone = NULL;
+    }
+
+
+    fDrawingPad->SetFillColor(22);
+
+    fNumPixel = -1;
+    fNumTile  =  0;
+    fPoints   =  0;
+
+    NewTile();
+}
+
+// ------------------------------------------------------------------------
+//
+//  default constructor
+//
+MagicDomino::MagicDomino()
+    : fGeomCam(NULL), fDir(kBottom), fDone(NULL)
+{
+    memset(fText, 0, sizeof(fText));
+
+    SetNewCamera(new MGeomCamMagic);
+
+    //
+    // Make sure, that the object is destroyed when the canvas/pad is
+    // destroyed. Make also sure, that the interpreter doesn't try to
+    // delete it a second time.
+    //
+    SetBit(kCanDelete);
+    gInterpreter->DeleteGlobal(this);
+
+    Draw();
+}
+
+// ------------------------------------------------------------------------
+//
+// Destructor. Deletes TClonesArrays for hexagons and legend elements.
+//
+MagicDomino::~MagicDomino()
+{
+    Free();
+
+    RemoveNumbers();
+
+    if (fDrawingPad->GetListOfPrimitives()->FindObject(this)==this)
+    {
+        fDrawingPad->RecursiveRemove(this);
+        delete fDrawingPad;
+    }
+
+}
+
+// ------------------------------------------------------------------------
+//
+// This is called at any time the canvas should get repainted.
+// Here we maintain an aspect ratio of 5/4=1.15. This makes sure,
+// that the camera image doesn't get distorted by resizing the canvas.
+//
+void MagicDomino::Paint(Option_t *opt)
+{
+    const UInt_t w = (UInt_t)(gPad->GetWw()*gPad->GetAbsWNDC());
+    const UInt_t h = (UInt_t)(gPad->GetWh()*gPad->GetAbsHNDC());
+
+    //
+    // Check for a change in width or height, and make sure, that the
+    // first call also sets the range
+    //
+    if (w*fH == h*fW && fW && fH)
+        return;
+
+    //
+    // Calculate aspect ratio (5/4=1.25 recommended)
+    //
+    const Double_t ratio = (Double_t)w/h;
+
+    Float_t x;
+    Float_t y;
+
+    if (ratio>1.0)
+    {
+        x = fRange*(ratio*2-1);
+        y = fRange;
+    }
+    else
+    {
+        x = fRange;
+        y = fRange/ratio;
+    }
+
+    fH = h;
+    fW = w;
+
+    //
+    // Set new range
+    //
+    fDrawingPad->Range(-fRange, -y, x, y);
+}
+
+// ------------------------------------------------------------------------
+//
+// Call this function to draw the camera layout into your canvas.
+// Setup a drawing canvas. Add this object and all child objects
+// (hexagons, etc) to the current pad. If no pad exists a new one is
+// created.
+//
+void MagicDomino::Draw(Option_t *option)
+{
+    //
+    // if no canvas is yet existing to draw into, create a new one
+    //
+    /*TCanvas *c =*/ new TCanvas("MagicDomino", "Magic Domino Next Neighbours", 0, 0, 800, 800);
+    //c->ToggleEventStatus();
+
+    fDrawingPad = gPad;
+    fDrawingPad->SetBorderMode(0);
+
+    //
+    // Append this object, so that the aspect ratio is maintained
+    // (Paint-function is called)
+    //
+    AppendPad(option);
+
+    //
+    // Reset the game pad
+    //
+    Reset();
+    DrawHexagons();
+
+    /*
+     TPave *p = new TPave(-0.66*fRange, 0.895*fRange, 0.66*fRange, 0.995*fRange, 4, "br");
+     p->ConvertNDCtoPad();
+     p->SetFillColor(12);
+     p->SetBit(kCanDelete);
+     p->Draw();
+     */
+
+    fDomino.SetTextAlign(23);   // centered/bottom
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+    fDomino.SetBit(kNoContextMenu|kCannotPick);
+#endif
+    fDomino.Draw();
+}
+
+void MagicDomino::Update()
+{
+    TString txt = "Points: ";
+    txt += fPoints;
+    txt += "  Tile: ";
+    txt += fNumTile;
+
+    switch (fSkipped)
+    {
+    case 0:
+        fDomino.SetTextColor(8/*kGreen*/);
+        break;
+    case 1:
+        fDomino.SetTextColor(kYellow);
+        break;
+    case 2:
+        fDomino.SetTextColor(kRed);
+        break;
+    default:
+        fDomino.SetTextColor(kWhite);
+        break;
+    }
+    fDomino.SetText(0, fRange, txt);
+}
+
+// ------------------------------------------------------------------------
+//
+// Choose new colors for the tile
+//
+void MagicDomino::NewColors()
+{
+    TRandom rnd(0);
+    for (int i=0; i<3; i++)
+    {
+        Int_t color = (Int_t)rnd.Uniform(5)+2;
+        fNewColors[i*2]   = color;
+        fNewColors[i*2+1] = color;
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// Create a new tile
+//
+void MagicDomino::NewTile()
+{
+    if (fNumPixel>=0)
+    {
+        const MGeomPix &pix=(*fGeomCam)[fNumPixel];
+        (*this)[fNumPixel].ResetBit(kIsTile);
+        for (int i=0; i<pix.GetNumNeighbors(); i++)
+            (*this)[pix.GetNeighbor(i)].ResetBit(kIsTile);
+
+        fPoints += pix.GetNumNeighbors();
+    }
+
+    RemoveNumbers();
+
+    fNumPixel = -1;
+    fSkipped  =  0;
+    fNumTile++;
+
+    NewColors();
+    Update();
+
+    fDrawingPad->Update();
+}
+
+// ------------------------------------------------------------------------
+//
+//  Check for at least one correct color for each pixel in tile.
+//  Ignore the tile itself and all background pixels. Check whether
+//  background of tile is empty.
+//
+Bool_t MagicDomino::CheckTile()
+{
+    if (fNumPixel<0)
+        return kFALSE;
+
+    for (int i=0; i<7; i++)
+        if (fOldColors[i]!=kBackground)
+            return kFALSE;
+
+    Int_t cnt=0;
+    const MGeomPix &pix1=(*fGeomCam)[fNumPixel];
+    for (int i=0; i<pix1.GetNumNeighbors(); i++)
+    {
+        const Int_t idx1 = pix1.GetNeighbor(i);
+        const MGeomPix &pix2 = (*fGeomCam)[idx1];
+
+        Byte_t ignored = 0;
+        Byte_t found   = 0;
+        for (int j=0; j<pix2.GetNumNeighbors(); j++)
+        {
+            const Int_t    idx2 = pix2.GetNeighbor(j);
+            const MHexagon &hex = (*this)[idx2];
+
+            if (hex.TestBit(kIsTile) || hex.GetFillColor()==kBackground)
+            {
+                ignored++;
+                continue;
+            }
+
+            if (hex.GetFillColor()==(*this)[idx1].GetFillColor())
+                found++;
+        }
+        if (ignored==pix2.GetNumNeighbors() || found>0)
+            cnt++;
+    }
+
+    return cnt==pix1.GetNumNeighbors();
+}
+
+// ------------------------------------------------------------------------
+//
+// Game over!
+//
+void MagicDomino::Done()
+{
+    fDone = new TText(0, 0, "Game Over!");
+    fDone->SetTextColor(kWhite);  // white
+    fDone->SetTextAlign(22);  // centered/centered
+    fDone->SetTextSize(0.05); // white
+    fDone->Draw();
+
+    fDomino.SetTextColor(kBlue);
+
+    fDrawingPad->SetFillColor(kRed);
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+    fDone->SetBit(kNoContextMenu|kCannotPick);
+    fDrawingPad->ResetBit(kNoContextMenu);
+    ResetBit(kNoContextMenu);
+#endif
+
+    fDrawingPad->Modified();
+    fDrawingPad->Update();
+}
+
+// ------------------------------------------------------------------------
+//
+// Execute a mouse event on the camera
+//
+void MagicDomino::ExecuteEvent(Int_t event, Int_t keycode, Int_t keysym)
+{
+    if (event!=kKeyPress || fDone)
+        return;
+
+    switch (keysym)
+    {
+    case kKey_Escape:
+        fPoints -= 6;
+        fSkipped++;
+        if (fSkipped==3)
+        {
+            Done();
+            return;
+        }
+        NewColors();
+        RotateTile(0);
+        return;
+
+    case kKey_Space:
+        RotateTile(-1);
+        return;
+
+    case kKey_Return:
+        if (CheckTile())
+            NewTile();
+        return;
+
+    case kKey_Right:
+        fDir = kRight;
+        Step(kRight);
+        return;
+
+    case kKey_Left:
+        fDir = kLeft;
+        Step(kLeft);
+        return;
+
+    case kKey_Up:
+        Step(kTop|fDir);
+        return;
+
+    case kKey_Down:
+        Step(kBottom|fDir);
+        return;
+
+    case kKey_Plus:
+        RotateTile(+1);
+        return;
+
+    case kKey_Minus:
+        RotateTile(-1);
+        return;
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// Rotate the colors in the tile
+//
+void MagicDomino::RotateTile(Int_t add)
+{
+    fPosition += add+6;  // Make result positive
+    fPosition %= 6;      // Align result between 0 and 5
+
+    HideTile();
+    ShowTile();
+
+    Update();
+
+    fDrawingPad->Modified();
+    fDrawingPad->Update();
+}
+
+// ------------------------------------------------------------------------
+//
+// Hide the tile from the pad
+//
+void MagicDomino::HideTile()
+{
+    if (fNumPixel<0)
+        return;
+
+    MagicDomino &This = *this;
+
+    RemoveNumbers();
+
+    const MGeomPix &pix1=(*fGeomCam)[fNumPixel];
+    This[fNumPixel].SetFillColor(fOldColors[6]);
+    This[fNumPixel].ResetBit(kIsTile);
+    for (int i=0; i<pix1.GetNumNeighbors(); i++)
+    {
+        Int_t idx = pix1.GetNeighbor(i);
+
+        This[idx].SetFillColor(fOldColors[i]);
+        This[idx].ResetBit(kIsTile);
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// Show the tile on the pad
+//
+void MagicDomino::ShowTile()
+{
+    if (fNumPixel<0)
+        return;
+
+    MagicDomino &This = *this;
+
+    Int_t indices[6];
+    GetSortedNeighbors(indices);
+
+    RemoveNumbers();
+
+    const MGeomPix &pix2=(*fGeomCam)[fNumPixel];
+    fOldColors[6] = This[fNumPixel].GetFillColor();
+    This[fNumPixel].SetFillColor(kBlack);
+    This[fNumPixel].SetBit(kIsTile);
+    for (int i=0; i<pix2.GetNumNeighbors(); i++)
+    {
+        Int_t idx = pix2.GetNeighbor(i);
+
+        fOldColors[i] = This[idx].GetFillColor();
+
+        int j=0;
+        while (indices[j]!=i)
+            j++;
+
+        This[idx].SetFillColor(fNewColors[(j+fPosition)%6]);
+        This[idx].SetBit(kIsTile);
+
+        TString num;
+        num += idx;
+
+        fText[i] = new TText(This[idx].GetX(), This[idx].GetY(), num);
+        fText[i]->SetTextSize(0.3*This[idx].GetD()/fGeomCam->GetMaxRadius());
+        fText[i]->SetTextFont(122);
+        fText[i]->SetTextAlign(22);   // centered/centered
+        fText[i]->Draw();
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// Hide the tile, change its position, show it again, update status text
+//
+void MagicDomino::ChangePixel(Int_t add)
+{
+    HideTile();
+
+    fNumPixel = add;
+
+    ShowTile();
+
+    Update();
+
+    fDrawingPad->Update();
+}
+
+// ------------------------------------------------------------------------
+//
+// Analyse the directions of the next neighbors
+//
+Short_t MagicDomino::AnalysePixel(Int_t dir)
+{
+    const MGeomPix &pix=(*fGeomCam)[fNumPixel<0?0:fNumPixel];
+
+    Double_t fAngle[6] = { -10, -10, -10, -10, -10, -10 };
+
+    for (int i=0; i<pix.GetNumNeighbors(); i++)
+    {
+        MGeomPix &next = (*fGeomCam)[pix.GetNeighbor(i)];
+        fAngle[i] = atan2(next.GetY()-pix.GetY(), next.GetX()-pix.GetX());
+    }
+
+    Int_t indices[6];
+    TMath::Sort(6, fAngle, indices); // left, top, right, bottom
+
+    for (int i=0; i<pix.GetNumNeighbors(); i++)
+    {
+        const Int_t    idx   = pix.GetNeighbor(indices[i]);
+        const Double_t angle = fAngle[indices[i]]*180/TMath::Pi();
+
+        if (angle<-149 && dir==kLeft)
+            return idx;
+        if (angle>-149 && angle<-90 && dir==kBottomLeft)
+            return idx;
+        //if (angle==-90 && dir==kBottom)
+        //    return idx;
+        if (angle>-90 && angle<-31 && dir==kBottomRight)
+            return idx;
+        if (angle>-31 && angle<31 && dir==kRight)
+            return idx;
+        if (angle>31 && angle<90 && dir==kTopRight)
+            return idx;
+        //if (angle==90 && dir==kTop)
+        //    return idx;
+        if (angle>90 && angle<149 && dir==kTopLeft)
+            return idx;
+        if (angle>149 && dir==kLeft)
+            return idx;
+    }
+    return -1;
+}
+
+// ------------------------------------------------------------------------
+//
+// Sort the next neighbort from the left, top, right, bottom
+//
+void MagicDomino::GetSortedNeighbors(Int_t indices[6])
+{
+    const MGeomPix &pix=(*fGeomCam)[fNumPixel<0?0:fNumPixel];
+
+    Double_t fAngle[6] = { -10, -10, -10, -10, -10, -10 };
+
+    for (int i=0; i<pix.GetNumNeighbors(); i++)
+    {
+        MGeomPix &next = (*fGeomCam)[pix.GetNeighbor(i)];
+        fAngle[i] = atan2(next.GetY()-pix.GetY(), next.GetX()-pix.GetX());
+    }
+
+    TMath::Sort(6, fAngle, indices); // left, top, right, bottom
+}
+
+// ------------------------------------------------------------------------
+//
+// Move tile one step in the given direction
+//
+void MagicDomino::Step(Int_t dir)
+{
+    Short_t newidx = AnalysePixel(dir);
+    if (newidx<0)
+        return;
+    ChangePixel(newidx);
+}
+
Index: /tags/Mars_V0-8-5/Mars/mtools/MagicDomino.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtools/MagicDomino.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtools/MagicDomino.h	(revision 9661)
@@ -0,0 +1,101 @@
+#ifndef MARS_MagicDomino
+#define MARS_MagicDomino
+
+#ifndef MARS_MAGIC
+#include "MAGIC.h"
+#endif
+
+#ifndef ROOT_TText
+#include <TText.h>
+#endif
+#ifndef ROOT_TClonesArray
+#include <TClonesArray.h>
+#endif
+
+class TMarker;
+class TVirtualPad;
+
+class MGeomCam;
+class MHexagon;
+
+class MagicDomino : public TObject
+{
+private:
+    enum
+    {
+        kBackground  = 50,
+        kIsTile      = BIT(16),
+        kRight       = BIT(17),
+        kLeft        = BIT(18),
+        kTop         = BIT(19),
+        kBottom      = BIT(20),
+        kUserBits    = 0x7fc000, // 14-23 are allowed
+
+        kBottomLeft  = kBottom|kLeft,
+        kBottomRight = kBottom|kRight,
+        kTopLeft     = kTop|kLeft,
+        kTopRight    = kTop|kRight
+
+    };
+
+    MGeomCam *fGeomCam;         // pointer to camera geometry
+
+    UShort_t  fNumPixels;       // number of pixels in the present geometry
+    Short_t   fNumPixel;        // number of actual pixel
+    Int_t     fNumTile;         // number of setteled tiles
+    Float_t   fRange;           // the range in millimeters of the present geometry
+
+    Int_t     fPoints;          // points you got
+
+    Int_t     fDir;             // direction you move the tile
+
+    Int_t     fOldColors[7];    // colors of hexagons which are under the tile
+    Int_t     fNewColors[6];    // colors of the tile itself
+    Byte_t    fPosition;        // rotation position of colors in tile
+    Byte_t    fSkipped;         // number of skipped tiles
+
+    TText     fDomino;          // TText showing status informations
+    TText    *fText[6];         // ttext showing the six numbers in the tile
+    TText    *fDone;            // game over text
+
+    UInt_t    fW;               // Width of canvas
+    UInt_t    fH;               // Height of canvas
+
+    TClonesArray *fPixels;      // array of all hexagons
+    TVirtualPad  *fDrawingPad;  // pad in which we are drawing
+
+    MHexagon &operator[](int i) { return *((MHexagon*)fPixels->At(i)); }
+
+    Bool_t  CheckTile();
+    void    NewTile();
+    void    NewColors();
+    void    HideTile();
+    void    ShowTile();
+    void    RotateTile(Int_t add);
+    void    Update();
+    void    Free();
+    void    Done();
+    void    RemoveNumbers();
+    void    DrawHexagons();
+    void    SetNewCamera(MGeomCam *);
+    void    ChangePixel(Int_t add);
+    void    Step(Int_t dir);
+    Short_t AnalysePixel(Int_t dir);
+    void    GetSortedNeighbors(Int_t indices[6]);
+
+    void  Draw(Option_t *option="");
+    void  Paint(Option_t *option="");
+    void  ExecuteEvent(Int_t event, Int_t px, Int_t py);
+    Int_t DistancetoPrimitive(Int_t px, Int_t py) { return 0; }
+
+public:
+    MagicDomino();
+    ~MagicDomino();
+
+    void Reset();        //*MENU*
+    void ChangeCamera(); //*MENU*
+
+    ClassDef(MagicDomino, 0) // Magic Camera Games: Some kind of Domino
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtools/MagicReversi.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtools/MagicReversi.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtools/MagicReversi.cc	(revision 9661)
@@ -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 03/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MagicReversi
+// ------------
+//
+// Camera Display Games: Reversi
+//
+// Start the game by:
+//   MagicReversi reversi;
+//
+//  Rules:
+//  ------
+//
+// Use the mouse to put a stone at some place. If between your newly
+// placed stone and the next stone (in a row) of your color are stones
+// of other colors this stones are won by you. You can only place a
+// stone if you win at least one stone from your 'enemy'. If you
+// cannot do so, you are skipped. If nobody can make a move anymore
+// the game is over. The player has won who has the most stones in
+// his own color.
+// The present player is indicated by <*>
+// Use the Escape key to abort a game.
+// If the game was aborted or has been stopped youcan access the
+// options in the context menu.
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MagicReversi.h"
+
+#include <iostream>
+
+#include <KeySymbols.h>
+
+#include <TText.h>
+#include <TMarker.h>
+#include <TRandom.h>
+#include <TCanvas.h>
+#include <TClonesArray.h>
+#include <TInterpreter.h>
+
+#include "MHexagon.h"
+
+#include "MGeomPix.h"
+#include "MGeomCamCT1.h"
+#include "MGeomCamMagic.h"
+
+ClassImp(MagicReversi);
+
+using namespace std;
+
+/*
+const Int_t MagicReversi::fColorBombs[7] = {
+    22,
+    kYellow,
+    kGreen,
+    kBlue,
+    kCyan,
+    kMagenta,
+    kRed
+};
+*/
+void MagicReversi::Free()
+{
+    if (!fGeomCam)
+        return;
+
+    fPixels->Delete();
+    fText->Delete();
+    fFlags->Delete();
+
+    delete fText;
+    delete fFlags;
+    delete fPixels;
+
+    delete fGeomCam;
+}
+
+void MagicReversi::ChangeCamera()
+{
+    static Bool_t ct1=kFALSE;
+
+    cout << "Change to " << (ct1?"Magic":"CT1") << endl;
+
+    if (ct1)
+        SetNewCamera(new MGeomCamMagic);
+    else
+        SetNewCamera(new MGeomCamCT1);
+
+    ct1 = !ct1;
+
+    Reset();
+    DrawHexagons();
+}
+
+void MagicReversi::SetNewCamera(MGeomCam *geom)
+{
+    Free();
+
+    //
+    //  Reset the display geometry
+    //
+    fW=0;
+    fH=0;
+
+    //
+    //  Set new camera
+    //
+    fGeomCam = geom;
+
+    //
+    //  create the hexagons of the display
+    //
+    fNumPixels = fGeomCam->GetNumPixels();
+    fRange     = fGeomCam->GetMaxRadius();
+
+    //
+    // Construct all hexagons. Use new-operator with placement
+    //
+//    fNumBombs = fNumPixels/5;
+
+    fText   = new TClonesArray("TText",    fNumPixels);
+    fFlags  = new TClonesArray("TMarker",  fNumPixels);
+    fPixels = new TClonesArray("MHexagon", fNumPixels);
+
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        MHexagon &h = *new ((*fPixels)[i]) MHexagon((*fGeomCam)[i]);
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+        h.SetBit(kNoContextMenu|kCannotPick);
+#endif
+
+        TText &t = *new ((*fText)[i]) TText;
+        t.SetTextFont(122);
+        t.SetTextAlign(22);   // centered/centered
+        t.SetTextSize(0.3*h.GetD()/fRange);
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+        t.SetBit(kNoContextMenu|kCannotPick);
+#endif
+
+        const MGeomPix &pix = (*fGeomCam)[i];
+
+        TMarker &m = *new ((*fFlags)[i]) TMarker(pix.GetX(), pix.GetY(), kOpenStar);
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+        m.SetBit(kNoContextMenu|kCannotPick);
+#endif
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// Draw all pixels of the camera
+//  (means apend all pixelobjects to the current pad)
+//
+void MagicReversi::DrawHexagons()
+{
+    for (UInt_t i=0; i<fNumPixels; i++)
+        (*this)[i].Draw();
+}
+
+// ------------------------------------------------------------------------
+//
+//  default constructor
+//
+MagicReversi::MagicReversi()
+    : fGeomCam(NULL), fDone(NULL), fW(0), fH(0), fDrawingPad(NULL), fIsAllocated(kFALSE)
+{
+    SetNewCamera(new MGeomCamMagic);
+
+    //
+    // Make sure, that the object is destroyed when the canvas/pad is
+    // destroyed. Make also sure, that the interpreter doesn't try to
+    // delete it a second time.
+    //
+    SetBit(kCanDelete);
+    gInterpreter->DeleteGlobal(this);
+
+    fNumUsers = 2;
+
+    Draw();
+}
+
+// ------------------------------------------------------------------------
+//
+// Destructor. Deletes TClonesArrays for hexagons and legend elements.
+//
+MagicReversi::~MagicReversi()
+{
+    Free();
+
+    for (int i=0; i<6; i++)
+        delete fUsrTxt[i];
+
+    if (fDone)
+        delete fDone;
+
+    if (fDrawingPad->GetListOfPrimitives()->FindObject(this)==this)
+    {
+        fDrawingPad->RecursiveRemove(this);
+        delete fDrawingPad;
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// This is called at any time the canvas should get repainted.
+// Here we maintain an aspect ratio of 5/4=1.15. This makes sure,
+// that the camera image doesn't get distorted by resizing the canvas.
+//
+void MagicReversi::Paint(Option_t *opt)
+{
+    const UInt_t w = (UInt_t)(gPad->GetWw()*gPad->GetAbsWNDC());
+    const UInt_t h = (UInt_t)(gPad->GetWh()*gPad->GetAbsHNDC());
+
+    //
+    // Check for a change in width or height, and make sure, that the
+    // first call also sets the range
+    //
+    if (w*fH == h*fW && fW && fH)
+        return;
+
+    //
+    // Calculate aspect ratio (5/4=1.25 recommended)
+    //
+    const Double_t ratio = (Double_t)w/h;
+
+    Float_t x;
+    Float_t y;
+
+    if (ratio>1.0)
+    {
+        x = fRange*(ratio*2-1);
+        y = fRange;
+    }
+    else
+    {
+        x = fRange;
+        y = fRange/ratio;
+    }
+
+    fH = h;
+    fW = w;
+
+    //
+    // Set new range
+    //
+    fDrawingPad->Range(-fRange, -y, x, y);
+
+    //
+    // Adopt absolute sized of markers to relative range
+    //
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        Float_t r = (*this)[i].GetD()*gPad->XtoAbsPixel(1)/325;
+        GetFlag(i)->SetMarkerSize(20.0*r/fRange);
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// Call this function to draw the camera layout into your canvas.
+// Setup a drawing canvas. Add this object and all child objects
+// (hexagons, etc) to the current pad. If no pad exists a new one is
+// created.
+//
+void MagicReversi::Draw(Option_t *option)
+{
+    // root 3.02:
+    // gPad->SetFixedAspectRatio()
+
+    if (fDrawingPad)
+        return;
+
+    //
+    // if no canvas is yet existing to draw into, create a new one
+    //
+    if (!gPad)
+    {
+        /*TCanvas *c =*/ new TCanvas("MagicReversi", "Magic Reversi", 0, 0, 800, 800);
+        //c->ToggleEventStatus();
+        fIsAllocated = kTRUE;
+    }
+    else
+        fIsAllocated = kFALSE;
+
+    fDrawingPad = gPad;
+    fDrawingPad->SetBorderMode(0);
+
+    //
+    // Append this object, so that the aspect ratio is maintained
+    // (Paint-function is called)
+    //
+    AppendPad(option);
+
+    //
+    // Draw the title text
+    //
+    for (int i=0; i<6; i++)
+    {
+        fUsrTxt[i] = new TText;
+        fUsrTxt[i]->SetTextAlign(13);       // left/bottom
+        fUsrTxt[i]->SetTextSize(0.03);
+        fUsrTxt[i]->SetTextColor(kRed+i);  
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+        fUsrTxt[i]->SetBit(kNoContextMenu|kCannotPick);
+#endif
+        fUsrTxt[i]->Draw();
+    }
+
+    //
+    // Reset the game pad
+    //
+    Reset();
+    DrawHexagons();
+}
+
+void MagicReversi::Update()
+{
+    int i;
+    for (i=0; i<fNumUsers; i++)
+    {
+        TString txt = "Pixels: ";
+        txt += fUsrPts[i];
+
+        if (fNumUser==i)
+            txt += " <*>";
+
+        fUsrTxt[i]->SetText(-fRange*0.95, fRange-(i+1)*fRange*0.06, txt);
+    }
+    for (; i<6; i++)
+        fUsrTxt[i]->SetText(0, 0, "");
+}
+
+void MagicReversi::TwoPlayer()
+{
+    fNumUsers = 2;
+    Reset();
+}
+
+void MagicReversi::ThreePlayer()
+{
+    fNumUsers = 3;
+    Reset();
+}
+
+void MagicReversi::FourPlayer()
+{
+    fNumUsers = 4;
+    Reset();
+}
+
+void MagicReversi::FivePlayer()
+{
+    fNumUsers = 5;
+    Reset();
+}
+
+void MagicReversi::SixPlayer()
+{
+    fNumUsers = 6;
+    Reset();
+}
+
+// ------------------------------------------------------------------------
+//
+// reset the all pixel colors to a default value
+//
+void MagicReversi::Reset()
+{
+    if (fDone)
+    {
+        delete fDone;
+        fDone = NULL;
+    }
+
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        Remove(GetText(i));
+        Remove(GetFlag(i));
+
+        (*this)[i].SetFillColor(kEmpty);
+        (*fGeomCam)[i].ResetBit(kUserBits);
+
+        GetFlag(i)->SetMarkerColor(kBlack);
+    }
+
+    fNumUser  = 0;
+
+    for (int i=0; i<6; i++)
+        fUsrPts[i]=0;
+
+    for (int i=1; i<5*fNumUsers; i++)
+    {
+        (*this)[i-1].SetFillColor(i%fNumUsers+kRed);
+        fUsrPts[i%fNumUsers]++;
+    }
+
+    Update();
+
+    fDrawingPad->SetFillColor(22);
+
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+    fDrawingPad->SetBit(kNoContextMenu);
+    SetBit(kNoContextMenu);
+#endif
+}
+
+void MagicReversi::Done()
+{
+    Int_t max = 0;
+    Int_t winner = 0;
+
+    for (int i=0; i<6; i++)
+        if (fUsrPts[i]>max)
+        {
+            winner = i;
+            max = fUsrPts[i];
+        }
+
+    TString txt = "Player #";
+    txt += winner+1;
+    txt += " wins (";
+    txt += max;
+    txt += ")";
+
+    fDone = new TText(0, 0, txt);
+    fDone->SetTextColor(kWhite);
+    fDone->SetTextAlign(22);  
+    fDone->SetTextSize(0.05); 
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+    fDone->SetBit(kNoContextMenu|kCannotPick);
+#endif
+    fDone->Draw();
+
+    fDrawingPad->SetFillColor(winner+kRed);
+
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+    fDrawingPad->ResetBit(kNoContextMenu);
+    ResetBit(kNoContextMenu);
+#endif
+}
+
+void MagicReversi::Remove(TObject *obj)
+{
+    fDrawingPad->RecursiveRemove(obj);
+}
+
+Int_t MagicReversi::GetDirection(Int_t src, Int_t dst) const
+{
+    const MGeomPix &pix1=(*fGeomCam)[dst];
+    const MGeomPix &pix2=(*fGeomCam)[src];
+
+    const Double_t x1 = pix1.GetX();
+    const Double_t y1 = pix1.GetY();
+
+    const Double_t x2 = pix2.GetX();
+    const Double_t y2 = pix2.GetY();
+
+    if (x1>=x2 && y1>y2) return kRightTop;
+    if (x1>=x2 && y1<y2) return kRightBottom;
+    if (x1<=x2 && y1>y2) return kLeftTop;
+    if (x1<=x2 && y1<y2) return kLeftBottom;
+    if (x1>x2)           return kRight;
+    if (x1<x2)           return kLeft;
+
+    return -1;
+}
+
+Int_t MagicReversi::GetNeighbor(Int_t idx, Int_t dir) const
+{
+    MGeomPix &pix=(*fGeomCam)[idx];
+
+    //
+    // search for the neighbor in the given direction
+    //
+    int i;
+    for (i=0; i<pix.GetNumNeighbors(); i++)
+        if (GetDirection(idx, pix.GetNeighbor(i))==dir)
+            return pix.GetNeighbor(i);
+
+    return -1;
+}
+
+Bool_t MagicReversi::Flip(Int_t origidx, Bool_t flip)
+{
+    const Int_t col = kRed+fNumUser;
+
+    int test[6] = {0,0,0,0,0,0};
+
+    for (int dir=kRightTop; dir<=kLeftTop; dir++)
+    {
+        Int_t idx = origidx;
+        Int_t length = 0;
+
+        while (1)
+        {
+            idx = GetNeighbor(idx, dir);
+            if (idx<0 || (*this)[idx].GetFillColor()==kEmpty)
+                break;
+
+            if ((*this)[idx].GetFillColor()==col)
+            {
+                if (length!=0)
+                    test[dir] = length;
+                break;
+            }
+
+            length++;
+        }
+    }
+
+    int cnt = 0;
+
+    for (int dir=kRightTop; dir<=kLeftTop; dir++)
+    {
+        Int_t idx = origidx;
+
+        if (test[dir])
+            cnt++;
+
+        if (flip)
+            for (int i=0; i<test[dir]; i++)
+            {
+                idx = GetNeighbor(idx, dir);
+
+                fUsrPts[(*this)[idx].GetFillColor()-kRed]--;
+                fUsrPts[fNumUser]++;
+
+                (*this)[idx].SetFillColor(col);
+            }
+    }
+
+    return cnt ? kTRUE : kFALSE;
+}
+
+Bool_t MagicReversi::CheckMoves()
+{
+    for (unsigned int i=0; i<fNumPixels; i++)
+        if ((*this)[i].GetFillColor()==kEmpty && Flip(i, kFALSE))
+            return kTRUE;
+    return kFALSE;
+}
+
+// ------------------------------------------------------------------------
+//
+// Execute a mouse event on the camera
+//
+void MagicReversi::ExecuteEvent(Int_t event, Int_t px, Int_t py)
+{
+    if (event==kMouseMotion   || event==kMouseEnter    || event==kMouseLeave    ||
+        event==kButton1Up     || event==kButton2Up     || event==kButton3Up     ||
+        event==kButton1Motion || event==kButton2Motion || event==kButton3Motion ||
+                                 event==kButton2Double || event==kButton3Double ||
+        fDone)
+        return;
+
+    if (event==kKeyPress && py==kKey_Escape)
+    {
+        Done();
+        fDrawingPad->Modified();
+        fDrawingPad->Update();
+        return;
+    }
+
+    UInt_t idx;
+    for (idx=0; idx<fNumPixels; idx++)
+        if ((*fPixels)[idx]->DistancetoPrimitive(px, py)==0)
+            break;
+
+    if (idx==fNumPixels)
+        return;
+
+    if (event==kButton1Down && (*this)[idx].GetFillColor()==kEmpty)
+    {
+        if (!Flip(idx, kTRUE))
+            return;
+
+        fUsrPts[fNumUser]++;
+
+        (*this)[idx].SetFillColor(kRed+fNumUser);
+
+        Int_t start = fNumUser;
+
+        fNumUser++;
+        fNumUser%=fNumUsers;
+
+        while (!CheckMoves())
+        {
+            cout << "Sorry, no moves possible for player #" << fNumUser << endl;
+            fNumUser++;
+            fNumUser%=fNumUsers;
+
+            if (fNumUser==start)
+            {
+                Done();
+                break;
+            }
+        }
+
+        Update();
+    }
+
+    fDrawingPad->Modified();
+}
Index: /tags/Mars_V0-8-5/Mars/mtools/MagicReversi.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtools/MagicReversi.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtools/MagicReversi.h	(revision 9661)
@@ -0,0 +1,98 @@
+#ifndef MARS_MagicReversi
+#define MARS_MagicReversi
+
+#ifndef MARS_MAGIC
+#include "MAGIC.h"
+#endif
+#ifndef ROOT_TClonesArray
+#include <TClonesArray.h>
+#endif
+
+class TText;
+class TMarker;
+class TVirtualPad;
+
+class MGeomCam;
+class MHexagon;
+
+class MagicReversi : public TObject
+{
+private:
+    enum {
+        kRightTop,
+        kRight,
+        kRightBottom,
+        kLeftBottom,
+        kLeft,
+        kLeftTop
+    };
+//    static const Int_t fColorBombs[7]; // colors for the hexagons
+
+    MGeomCam      *fGeomCam;       // pointer to camera geometry
+
+    UInt_t         fNumPixels;     // number of pixels in the present geometry
+    Float_t        fRange;         // the range in millimeters of the present geometry
+
+    TClonesArray  *fPixels;        // array of all hexagons
+    TClonesArray  *fText;          // array of all texts
+    TClonesArray  *fFlags;         // array of all texts
+
+    TText         *fDone;          // TText showing the 'Game over'
+    TText         *fUsrTxt[6];     // TText showing the numbers of pixels and bombs
+
+    UInt_t         fW;             // Width of canvas
+    UInt_t         fH;             // Height of canvas
+    TVirtualPad   *fDrawingPad;    // pad in which we are drawing
+    Bool_t         fIsAllocated;
+
+    Int_t          fNumUsers;
+    Int_t          fNumUser;
+    Int_t          fUsrPts[6];
+
+    enum
+    {
+        kEmpty     = 50,
+        kIsVisible = BIT(16),
+        kHasBomb   = BIT(17),
+        kHasFlag   = BIT(18),
+        kUserBits  = 0x7fc000 // 14-23 are allowed
+    };
+
+    MHexagon &operator[](int i) { return *((MHexagon*)fPixels->At(i)); }
+
+    TText   *GetText(Int_t i) { return (TText*)fText->At(i); }
+    TMarker *GetFlag(Int_t i) { return (TMarker*)fFlags->At(i); }
+
+    void  Remove(TObject *);
+    void  Done();
+    void  Update();
+    void  SetNewCamera(MGeomCam *);
+    void  DrawHexagons();
+    void  Free();
+
+    Bool_t Flip(Int_t idx, Bool_t flip);
+    Int_t  GetDirection(Int_t src, Int_t dst) const;
+    Int_t  GetNeighbor(Int_t idx, Int_t dir) const;
+    Bool_t CheckMoves();
+
+    void  Paint(Option_t *option="");
+    void  Draw(Option_t *option="");
+    void  ExecuteEvent(Int_t event, Int_t px, Int_t py);
+    Int_t DistancetoPrimitive(Int_t px, Int_t py) { return 0; }
+
+public:
+    MagicReversi();
+    ~MagicReversi();
+
+    void Reset();        //*MENU*
+    void ChangeCamera(); //*MENU*
+    void TwoPlayer(); //*MENU*
+    void ThreePlayer(); //*MENU*
+    void FourPlayer(); //*MENU*
+    void FivePlayer(); //*MENU*
+    void SixPlayer(); //*MENU*
+
+    ClassDef(MagicReversi, 0) // Magic Camera Games: Reversi
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtools/MagicShow.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtools/MagicShow.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtools/MagicShow.cc	(revision 9661)
@@ -0,0 +1,423 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz 07/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MagicShow
+// ---------
+//
+// Tool to visualize Next Neighbours.
+//
+// Start the show by:
+//   MagicShow show;
+//
+// Use the following keys:
+// -----------------------
+//
+//   * Space:
+//     Toggle between auto increment and manual increment
+//
+//   * Right/Left:
+//     Increment/Decrement pixel number by 1
+//
+//   * Right/Left:
+//     Increment/Decrement pixel number by 1
+//
+//   * Up/Down:
+//     Increment/Decrement pixel number by 10
+//
+//   * PageUp/PageDown:
+//     Increment/Decrement pixel number by 100
+//
+//   * Home/End:
+//     Jump to first/last pixel
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MagicShow.h"
+
+#include <iostream>
+
+#include <KeySymbols.h>
+
+#include <TCanvas.h>
+#include <TInterpreter.h>
+
+#include "MHexagon.h"
+
+#include "MGeomPix.h"
+#include "MGeomCamCT1.h"
+#include "MGeomCamMagic.h"
+
+ClassImp(MagicShow);
+
+using namespace std;
+
+// ------------------------------------------------------------------------
+//
+// Free all onbects connected to a special camera geometry
+//
+void MagicShow::Free()
+{
+    if (!fGeomCam)
+        return;
+
+    fPixels->Delete();
+
+    delete fPixels;
+
+    delete fGeomCam;
+}
+
+// ------------------------------------------------------------------------
+//
+// Draw all pixels of the camera
+//  (means apend all pixelobjects to the current pad)
+//
+void MagicShow::DrawHexagons()
+{
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        MHexagon &h = (*this)[i];
+
+        h.SetFillColor(kBackground);
+        h.Draw();
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// Change camera from Magic to CT1 and back
+//
+void MagicShow::ChangeCamera()
+{
+    static Bool_t ct1=kFALSE;
+
+    cout << "Change to " << (ct1?"Magic":"CT1") << endl;
+
+    if (ct1)
+        SetNewCamera(new MGeomCamMagic);
+    else
+        SetNewCamera(new MGeomCamCT1);
+
+    ct1 = !ct1;
+
+    DrawHexagons();
+}
+
+// ------------------------------------------------------------------------
+//
+// Reset/set all veriables needed for a new camera geometry
+//
+void MagicShow::SetNewCamera(MGeomCam *geom)
+{
+    Free();
+
+    //
+    //  Reset the display geometry
+    //
+    fW=0;
+    fH=0;
+
+    //
+    //  Set new camera
+    //
+    fGeomCam = geom;
+
+    //
+    //  create the hexagons of the display
+    //
+    fNumPixels = fGeomCam->GetNumPixels();
+    fRange     = fGeomCam->GetMaxRadius();
+
+    fNumPixel  = fNumPixels-1;
+
+    //
+    // Construct all hexagons. Use new-operator with placement
+    //
+    fPixels = new TClonesArray("MHexagon", fNumPixels);
+
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        MHexagon &h = *new ((*fPixels)[i]) MHexagon((*fGeomCam)[i]);
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+        h.SetBit(kNoContextMenu|kCannotPick);
+#endif
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+//  default constructor
+//
+MagicShow::MagicShow()
+    : fTimer(this, 250, kTRUE), fGeomCam(NULL), fNumPixel(-1), fAuto(kTRUE), fW(0), fH(0)
+{
+    SetNewCamera(new MGeomCamMagic);
+
+    memset(fText, 0, sizeof(fText));
+
+    //
+    // Make sure, that the object is destroyed when the canvas/pad is
+    // destroyed. Make also sure, that the interpreter doesn't try to
+    // delete it a second time.
+    //
+    SetBit(kCanDelete);
+    gInterpreter->DeleteGlobal(this);
+
+    Draw();
+
+    fTimer.TurnOn();
+}
+
+// ------------------------------------------------------------------------
+//
+// Destructor. Deletes TClonesArrays for hexagons and legend elements.
+//
+MagicShow::~MagicShow()
+{
+    Free();
+
+    for (int i=0; i<6; i++)
+        if (fText[i])
+            delete fText[i];
+
+    if (fDrawingPad->GetListOfPrimitives()->FindObject(this)==this)
+    {
+        fDrawingPad->RecursiveRemove(this);
+        delete fDrawingPad;
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// This is called at any time the canvas should get repainted.
+// Here we maintain an aspect ratio of 5/4=1.15. This makes sure,
+// that the camera image doesn't get distorted by resizing the canvas.
+//
+void MagicShow::Paint(Option_t *opt)
+{
+    const UInt_t w = (UInt_t)(gPad->GetWw()*gPad->GetAbsWNDC());
+    const UInt_t h = (UInt_t)(gPad->GetWh()*gPad->GetAbsHNDC());
+
+    //
+    // Check for a change in width or height, and make sure, that the
+    // first call also sets the range
+    //
+    if (w*fH == h*fW && fW && fH)
+        return;
+
+    //
+    // Calculate aspect ratio (5/4=1.25 recommended)
+    //
+    const Double_t ratio = (Double_t)w/h;
+
+    Float_t x;
+    Float_t y;
+
+    if (ratio>1.0)
+    {
+        x = fRange*(ratio*2-1);
+        y = fRange;
+    }
+    else
+    {
+        x = fRange;
+        y = fRange/ratio;
+    }
+
+    fH = h;
+    fW = w;
+
+    //
+    // Set new range
+    //
+    fDrawingPad->Range(-fRange, -y, x, y);
+}
+
+// ------------------------------------------------------------------------
+//
+// Call this function to draw the camera layout into your canvas.
+// Setup a drawing canvas. Add this object and all child objects
+// (hexagons, etc) to the current pad. If no pad exists a new one is
+// created.
+//
+void MagicShow::Draw(Option_t *option)
+{
+    //
+    // if no canvas is yet existing to draw into, create a new one
+    //
+    /*TCanvas *c =*/ new TCanvas("MagicShow", "Magic Show Next Neighbours", 0, 0, 800, 800);
+    //c->ToggleEventStatus();
+
+    fDrawingPad = gPad;
+    fDrawingPad->SetBorderMode(0);
+    fDrawingPad->SetFillColor(22);
+
+    //
+    // Append this object, so that the aspect ratio is maintained
+    // (Paint-function is called)
+    //
+    AppendPad(option);
+
+    //
+    // Reset the game pad
+    //
+    DrawHexagons();
+
+    fShow.SetTextAlign(23);   // centered/bottom
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+    fShow.SetBit(kNoContextMenu|kCannotPick);
+#endif
+    fShow.Draw();
+}
+
+// ------------------------------------------------------------------------
+//
+// Update Status text
+//
+void MagicShow::Update()
+{
+    TString txt = "Pixels: ";
+    txt += fNumPixels;
+    txt += "  Pixel: ";
+    txt += fNumPixel;
+
+    if (fAuto)
+        txt += "  (auto)";
+
+    fShow.SetText(0, fRange, txt);
+}
+
+// ------------------------------------------------------------------------
+//
+// Execute a mouse event on the camera
+//
+void MagicShow::ExecuteEvent(Int_t event, Int_t keycode, Int_t keysym)
+{
+    if (event!=kKeyPress)
+        return;
+
+    switch (keysym)
+    {
+    case kKey_Space:
+        fAuto = !fAuto;
+        Update();
+        fDrawingPad->Update();
+        return;
+
+    case kKey_Right:
+        ChangePixel(+1);
+        return;
+
+    case kKey_Left:
+        ChangePixel(-1);
+        return;
+
+    case kKey_Up:
+        ChangePixel(+10);
+        return;
+
+    case kKey_Down:
+        ChangePixel(-10);
+        return;
+
+    case kKey_PageUp:
+        ChangePixel(+100);
+        return;
+
+    case kKey_PageDown:
+        ChangePixel(-100);
+        return;
+
+    case kKey_Home:
+        ChangePixel(-fNumPixel);
+        return;
+
+    case kKey_End:
+        ChangePixel(fNumPixels-fNumPixel-1);
+        return;
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// Change the shown pixel by add indices
+//
+void MagicShow::ChangePixel(Int_t add)
+{
+    MagicShow &This = *this;
+
+    const MGeomPix &pix1=(*fGeomCam)[fNumPixel];
+    This[fNumPixel].SetFillColor(kBackground);
+    for (int i=0; i<pix1.GetNumNeighbors(); i++)
+    {
+        This[pix1.GetNeighbor(i)].SetFillColor(kBackground);
+        if (!fText[i])
+            continue;
+
+        delete fText[i];
+        fText[i] = NULL;
+    }
+
+    fNumPixel += add;
+
+    if (fNumPixel>=fNumPixels)
+        fNumPixel = 0;
+    if (fNumPixel<0)
+        fNumPixel = fNumPixels-1;
+
+    const MGeomPix &pix2=(*fGeomCam)[fNumPixel];
+    This[fNumPixel].SetFillColor(kBlue);
+    for (int i=0; i<pix2.GetNumNeighbors(); i++)
+    {
+        Int_t idx = pix2.GetNeighbor(i);
+
+        This[idx].SetFillColor(kMagenta);
+
+        TString num;
+        num += idx;
+
+        fText[i] = new TText(This[idx].GetX(), This[idx].GetY(), num);
+        fText[i]->SetTextSize(0.3*This[idx].GetD()/fGeomCam->GetMaxRadius());
+        fText[i]->SetTextFont(122);
+        fText[i]->SetTextAlign(22);   // centered/centered
+        fText[i]->Draw();
+    }
+
+    Update();
+
+    fDrawingPad->Update();
+}
+
+// ------------------------------------------------------------------------
+//
+// If automatic is switched on step one pixel forward
+//
+Bool_t MagicShow::HandleTimer(TTimer *timer)
+{
+    if (fAuto)
+        ChangePixel(+1);
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mtools/MagicShow.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtools/MagicShow.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtools/MagicShow.h	(revision 9661)
@@ -0,0 +1,76 @@
+#ifndef MARS_MagicShow
+#define MARS_MagicShow
+
+#ifndef MARS_MAGIC
+#include "MAGIC.h"
+#endif
+
+#ifndef ROOT_TText
+#include <TText.h>
+#endif
+#ifndef ROOT_TTimer
+#include <TTimer.h>
+#endif
+#ifndef ROOT_TClonesArray
+#include <TClonesArray.h>
+#endif
+
+class TMarker;
+class TVirtualPad;
+
+class MGeomCam;
+class MHexagon;
+
+class MagicShow : public TObject
+{
+private:
+    enum
+    {
+        kBackground = 50,
+        kUserBits   = 0x7fc000 // 14-23 are allowed
+
+    };
+
+    TTimer    fTimer;           // timer rising the 500ms interrputs
+
+    MGeomCam *fGeomCam;         // pointer to camera geometry
+
+    UShort_t  fNumPixels;       // number of pixels in the present geometry
+    Short_t   fNumPixel;        // number of pixel actually shown
+    Float_t   fRange;           // the range in millimeters of the present geometry
+
+    Bool_t    fAuto;            // automatic stepping on/off
+
+    TText     fShow;            // TText showing the numbers of pixels and bombs
+    TText    *fText[6];         // ttext showing the pixel numbers of the neighbors
+
+    UInt_t    fW;               // Width of canvas
+    UInt_t    fH;               // Height of canvas
+
+    TClonesArray *fPixels;      // array of all hexagons
+    TVirtualPad  *fDrawingPad;  // pad in which we are drawing
+
+    MHexagon &operator[](int i) { return *((MHexagon*)fPixels->At(i)); }
+
+    void   Update();
+    void   Free();
+    void   DrawHexagons();
+    void   SetNewCamera(MGeomCam *);
+    void   ChangePixel(Int_t add);
+
+    Bool_t HandleTimer(TTimer *timer);
+    void   Draw(Option_t *option="");
+    void   Paint(Option_t *option="");
+    void   ExecuteEvent(Int_t event, Int_t px, Int_t py);
+    Int_t  DistancetoPrimitive(Int_t px, Int_t py) { return 0; }
+
+public:
+    MagicShow();
+    ~MagicShow();
+
+    void ChangeCamera(); //*MENU*
+
+    ClassDef(MagicShow, 0) // Tool to visualize next neighbours
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtools/MagicSnake.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtools/MagicSnake.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtools/MagicSnake.cc	(revision 9661)
@@ -0,0 +1,632 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz 07/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MagicSnake
+// ----------
+//
+// Camera Display Games: Snake
+//
+// Start the game by:
+//   MagicSnake snake;
+//
+// Controll the worm using right/left. Make sure, that the mouse pointer
+// is inside the canvas.
+//
+// Move the mouse pointer outside the canvas to pause the game.
+//
+// The pixel colors have the following meaning:
+// --------------------------------------------
+//  Green:   Food, collect all packages.
+//  Red:     Bombs, don't touch it!
+//  Yellow:  Transport, try it.
+//  Magenta: Home, touch it to win the game.
+//
+// To restart the game use the context menu. It can only be accessed if
+// the game has been stopped (either because you win the game or because
+// you hit a bomb) With the context menu you can also toggle between
+// different camera layouts.
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MagicSnake.h"
+
+#include <iostream>
+
+#include <KeySymbols.h>
+
+#include <TColor.h>
+#include <TCanvas.h>
+#include <TMarker.h>
+#include <TRandom.h>
+#include <TInterpreter.h>
+
+#include "MHexagon.h"
+
+#include "MGeomPix.h"
+#include "MGeomCamCT1.h"
+#include "MGeomCamMagic.h"
+
+ClassImp(MagicSnake);
+
+using namespace std;
+
+void MagicSnake::Free()
+{
+    if (!fGeomCam)
+        return;
+
+    fPixels->Delete();
+
+    delete fPixels;
+
+    delete fGeomCam;
+
+    delete fArray;
+}
+
+// ------------------------------------------------------------------------
+//
+// Draw all pixels of the camera
+//  (means apend all pixelobjects to the current pad)
+//
+void MagicSnake::DrawHexagons()
+{
+    for (UInt_t i=0; i<fNumPixels; i++)
+        (*this)[i].Draw();
+}
+
+void MagicSnake::ChangeCamera()
+{
+    if (!fDone)
+        Done("Changing Camera...", 22);
+
+    static Bool_t ct1=kFALSE;
+
+    cout << "Change to " << (ct1?"Magic":"CT1") << endl;
+
+    if (ct1)
+        SetNewCamera(new MGeomCamMagic);
+    else
+        SetNewCamera(new MGeomCamCT1);
+
+    ct1 = !ct1;
+
+    Reset();
+    DrawHexagons();
+}
+
+void MagicSnake::SetNewCamera(MGeomCam *geom)
+{
+    Free();
+
+    //
+    //  Reset the display geometry
+    //
+    fW=0;
+    fH=0;
+
+    //
+    //  Set new camera
+    //
+    fGeomCam = geom;
+
+    //
+    //  create the hexagons of the display
+    //
+    fNumPixels = fGeomCam->GetNumPixels();
+    fRange     = fGeomCam->GetMaxRadius();
+
+    //
+    // Construct all hexagons. Use new-operator with placement
+    //
+    fPixels = new TClonesArray("MHexagon", fNumPixels);
+
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        MHexagon &h = *new ((*fPixels)[i]) MHexagon((*fGeomCam)[i]);
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+        h.SetBit(kNoContextMenu|kCannotPick);
+#endif
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+//  default constructor
+//
+MagicSnake::MagicSnake()
+    : fTimer(this, 500, kTRUE), fGeomCam(NULL), fDone(NULL), fPaused(NULL), fW(0), fH(0)
+{
+    SetNewCamera(new MGeomCamMagic);
+
+    //
+    // Make sure, that the object is destroyed when the canvas/pad is
+    // destroyed. Make also sure, that the interpreter doesn't try to
+    // delete it a second time.
+    //
+    SetBit(kCanDelete);
+    gInterpreter->DeleteGlobal(this);
+
+    Draw();
+
+    Pause();
+
+    fTimer.TurnOn();
+}
+
+void MagicSnake::Pause(Bool_t yes)
+{
+    if (yes && !fPaused)
+    {
+        fPaused = new TText(0, 0, "Paused!");
+        fPaused->SetTextColor(kWhite);
+        fPaused->SetTextAlign(22);
+        fPaused->SetTextSize(0.05); // white
+        fPaused->Draw();
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+        fPaused->SetBit(kNoContextMenu|kCannotPick);
+        fDrawingPad->ResetBit(kNoContextMenu);
+        ResetBit(kNoContextMenu);
+#endif
+        fDrawingPad->Update();
+    }
+
+    if (yes)
+        return;
+
+    if (!fDone)
+    {
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+        fDrawingPad->SetBit(kNoContextMenu);
+        SetBit(kNoContextMenu);
+#endif
+    }
+    if (!fPaused)
+        return;
+
+    Remove(fPaused);
+
+    fDrawingPad->Update();
+
+    delete fPaused;
+    fPaused=NULL;
+}
+
+// ------------------------------------------------------------------------
+//
+// Destructor. Deletes TClonesArrays for hexagons and legend elements.
+//
+MagicSnake::~MagicSnake()
+{
+    Free();
+    Pause(kFALSE);
+
+    if (fDone)
+        delete fDone;
+
+    if (fDrawingPad->GetListOfPrimitives()->FindObject(this)==this)
+    {
+        fDrawingPad->RecursiveRemove(this);
+        delete fDrawingPad;
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// This is called at any time the canvas should get repainted.
+// Here we maintain an aspect ratio of 5/4=1.15. This makes sure,
+// that the camera image doesn't get distorted by resizing the canvas.
+//
+void MagicSnake::Paint(Option_t *opt)
+{
+    const UInt_t w = (UInt_t)(gPad->GetWw()*gPad->GetAbsWNDC());
+    const UInt_t h = (UInt_t)(gPad->GetWh()*gPad->GetAbsHNDC());
+
+    //
+    // Check for a change in width or height, and make sure, that the
+    // first call also sets the range
+    //
+    if (w*fH == h*fW && fW && fH)
+        return;
+
+    //
+    // Calculate aspect ratio (5/4=1.25 recommended)
+    //
+    const Double_t ratio = (Double_t)w/h;
+
+    Float_t x;
+    Float_t y;
+
+    if (ratio>1.0)
+    {
+        x = fRange*(ratio*2-1);
+        y = fRange;
+    }
+    else
+    {
+        x = fRange;
+        y = fRange/ratio;
+    }
+
+    fH = h;
+    fW = w;
+
+    //
+    // Set new range
+    //
+    fDrawingPad->Range(-fRange, -y, x, y);
+}
+
+// ------------------------------------------------------------------------
+//
+// Call this function to draw the camera layout into your canvas.
+// Setup a drawing canvas. Add this object and all child objects
+// (hexagons, etc) to the current pad. If no pad exists a new one is
+// created.
+//
+void MagicSnake::Draw(Option_t *option)
+{
+    //
+    // if no canvas is yet existing to draw into, create a new one
+    //
+    /*TCanvas *c =*/ new TCanvas("MagicSnake", "Magic Snake", 0, 0, 800, 800);
+    //c->ToggleEventStatus();
+
+    fDrawingPad = gPad;
+    fDrawingPad->SetBorderMode(0);
+
+    //
+    // Append this object, so that the aspect ratio is maintained
+    // (Paint-function is called)
+    //
+    AppendPad(option);
+
+    //
+    // Reset the game pad
+    //
+    Reset();
+    DrawHexagons();
+
+    fShow.SetTextAlign(23);   // centered/bottom
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+    fShow.SetBit(kNoContextMenu|kCannotPick);
+#endif
+    fShow.Draw();
+}
+
+void MagicSnake::Update()
+{
+    TString txt = "Pixels: ";
+    txt += fNumPixels;
+    txt += "  Bombs: ";
+    txt += fNumBombs;
+    txt += "  Food: ";
+    txt += fNumFood;
+
+    fShow.SetText(0, fRange, txt);
+}
+
+// ------------------------------------------------------------------------
+//
+// reset the all pixel colors to a default value
+//
+void MagicSnake::Reset()
+{
+    fDirection = fGeomCam->InheritsFrom("MGeomCamCT1") ? kLeft : kRight;
+    fLength = 2;
+
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        (*this)[i].SetFillColor(kBackground);
+        (*fGeomCam)[i].ResetBit(kUserBits);
+    }
+
+    (*fGeomCam)[0].SetBit(kHasWorm);
+
+    fNumBombs = fNumPixels/30;
+
+    TRandom rnd(0);
+    for (int i=0; i<fNumBombs; i++)
+    {
+        Int_t idx;
+
+        do idx = (Int_t)rnd.Uniform(fNumPixels);
+        while ((*fGeomCam)[idx].TestBits(kHasBomb|kHasWorm));
+
+        (*fGeomCam)[idx].SetBit(kHasBomb);
+        (*this)[idx].SetFillColor(kRed);
+    }
+
+    fNumFood = fNumPixels/6;
+
+    fArray = new Int_t[fNumFood+3];
+
+    fArray[0] = 0;
+    fArray[1] = 1;
+
+    for (int i=0; i<fNumFood+3; i++)
+    {
+        Float_t f = (float)i/(fNumFood+3);
+        gROOT->GetColor(51+i)->SetRGB(f, f, f);
+    }
+    for (int i=0; i<fNumFood; i++)
+    {
+        Int_t idx;
+
+        do idx = (Int_t)rnd.Uniform(fNumPixels);
+        while ((*fGeomCam)[idx].TestBits(kHasBomb|kHasFood|kHasWorm));
+
+        (*fGeomCam)[idx].SetBit(kHasFood);
+        (*this)[idx].SetFillColor(kGreen);
+    }
+
+    SetWormColor();
+
+    for (int i=0; i<2; i++)
+    {
+        Int_t idx;
+
+        do idx = (Int_t)rnd.Uniform(fNumPixels);
+        while ((*fGeomCam)[idx].TestBits(kHasBomb|kHasFood|kHasWorm|kHasTransport));
+
+        fTransport[i] = idx;
+        (*fGeomCam)[idx].SetBit(kHasTransport);
+        (*this)[idx].SetFillColor(kYellow);
+    }
+
+    fDrawingPad->SetFillColor(22);
+
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+    fDrawingPad->SetBit(kNoContextMenu);
+    SetBit(kNoContextMenu);
+#endif
+
+    if (!fDone)
+        return;
+
+    delete fDone;
+    fDone = NULL;
+}
+
+void MagicSnake::Done(TString txt, Int_t col)
+{
+    //(*this)[fArray[fLength-1]].SetFillColor(kBlue);
+
+    fDone = new TText(0, 0, txt);
+    fDone->SetTextColor(kWhite);  // white
+    fDone->SetTextAlign(22);  // centered/centered
+    fDone->SetTextSize(0.05); // white
+    fDone->Draw();
+    fDrawingPad->SetFillColor(col);
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+    fDone->SetBit(kNoContextMenu|kCannotPick);
+    fDrawingPad->ResetBit(kNoContextMenu);
+    ResetBit(kNoContextMenu);
+#endif
+}
+
+void MagicSnake::Remove(TObject *obj)
+{
+    fDrawingPad->RecursiveRemove(obj);
+}
+
+// ------------------------------------------------------------------------
+//
+// Execute a mouse event on the camera
+//
+void MagicSnake::ExecuteEvent(Int_t event, Int_t keycode, Int_t keysym)
+{
+    if (event==kMouseEnter || event==kMouseMotion)
+    {
+        Pause(kFALSE);
+        return;
+    }
+
+    if (fDone)
+        return;
+
+    if (event==kMouseLeave)
+    {
+        Pause();
+        return;
+    }
+    if (event!=kKeyPress)
+        return;
+
+    switch (keysym)
+    {
+    case kKey_Left:
+        fDirection --;
+        break;
+
+    case kKey_Right:
+        fDirection ++;
+        break;
+
+    case kKey_Escape:
+        Done("Reset...", 22);
+        Reset();
+        return;
+
+    default:
+        cout << "Keysym=0x" << hex << keysym << endl;
+    }
+
+     if (fDirection < kRightTop)
+         fDirection = kLeftTop;
+     if (fDirection > kLeftTop)
+         fDirection = kRightTop;
+}
+
+void MagicSnake::Step(Int_t newpix)
+{
+    if ((*fGeomCam)[newpix].TestBit(kHasTransport))
+    {
+        (*this)[fArray[0]].SetFillColor(kBackground);
+        (*fGeomCam)[fArray[0]].ResetBit(kHasWorm);
+
+        for (int i=1; i<fLength; i++)
+            fArray[i-1] = fArray[i];
+
+        fArray[fLength-1] = newpix==fTransport[0]?fTransport[1]:fTransport[0];
+
+        return;
+    }
+
+    if (!(*fGeomCam)[newpix].TestBit(kHasFood))
+    {
+        MGeomPix &pix = (*fGeomCam)[fArray[0]];
+
+        if (!pix.TestBit(kHasTransport))
+            if (pix.TestBit(kHasDoor))
+                (*this)[fArray[0]].SetFillColor(kMagenta);
+            else
+                (*this)[fArray[0]].SetFillColor(kBackground);
+
+        pix.ResetBit(kHasWorm);
+
+        for (int i=1; i<fLength; i++)
+            fArray[i-1] = fArray[i];
+
+        fArray[fLength-1] = newpix;
+    }
+    else
+    {
+        fArray[fLength++] = newpix;
+        (*fGeomCam)[newpix].ResetBit(kHasFood);
+
+        fNumFood--;
+
+        if (fNumFood==0)
+            for (int i=1; i<7; i++)
+            {
+                (*this)[i].SetFillColor(kMagenta);
+                (*fGeomCam)[i].SetBit(kHasDoor);
+            }
+    }
+
+    SetWormColor();
+}
+
+void MagicSnake::SetWormColor()
+{
+    for (int i=0; i<fLength; i++)
+    {
+        const Int_t idx = fArray[i];
+
+        MGeomPix &pix = (*fGeomCam)[idx];
+
+        if (pix.TestBit(kHasTransport))
+            continue;
+
+        pix.SetBit(kHasWorm);
+
+        Int_t color = 51+fLength-i;
+        (*this)[idx].SetFillColor(color);
+    }
+}
+
+Int_t MagicSnake::ScanNeighbours()
+{
+    const Int_t first = fArray[fLength-1];
+
+    const MGeomPix &pix=(*fGeomCam)[first];
+
+    Double_t dx = pix.GetX();
+    Double_t dy = pix.GetY();
+
+    Int_t newpix = -1;
+    for (int i=0; i<pix.GetNumNeighbors(); i++)
+    {
+        const Int_t     idx  = pix.GetNeighbor(i);
+        const MGeomPix &next = (*fGeomCam)[idx];
+
+        const Double_t x = next.GetX();
+        const Double_t y = next.GetY();
+
+        switch (fDirection)
+        {
+        case kRightTop:    if (x>=dx && y>dy) { newpix=idx; dy=y; } continue;
+        case kRight:       if (x>dx)          { newpix=idx; dx=x; } continue;
+        case kRightBottom: if (x>=dx && y<dy) { newpix=idx; dy=y; } continue;
+        case kLeftTop:     if (x<=dx && y>dy) { newpix=idx; dy=y; } continue;
+        case kLeft:        if (x<dx)          { newpix=idx; dx=x; } continue;
+        case kLeftBottom:  if (x<=dx && y<dy) { newpix=idx; dy=y; } continue;
+        }
+    }
+
+    if (newpix<0)
+        return -1;
+
+    const MGeomPix &np = (*fGeomCam)[newpix];
+
+    if (fNumFood==0 && np.TestBit(kHasDoor))
+        return -4;
+
+    if (np.TestBit(kHasBomb))
+        return -2;
+
+    if (np.TestBit(kHasWorm))
+        return -3;
+
+    return newpix;
+}
+
+Bool_t MagicSnake::HandleTimer(TTimer *timer)
+{
+    if (fDone || fPaused)
+        return kTRUE;
+
+    const Int_t newpix = ScanNeighbours();
+
+    switch (newpix)
+    {
+    case -1:
+        Done("You crashed! Don't drink and drive!", kRed);
+        break;
+    case -2:
+        Done("Ouch, you found the bomb!", kRed);
+        break;
+    case -3:
+        Done("Argh... don't eat yourself!", kRed);
+        break;
+    case -4:
+        Done("Congratulations! You won the game!", kGreen);
+        break;
+    default:
+        Step(newpix);
+    }
+
+    Update();
+
+    //cout << "Update " << flush;
+
+    fDrawingPad->Modified();
+    fDrawingPad->Update();
+
+    //cout << "Done." << endl;
+
+    return kTRUE;
+}
Index: /tags/Mars_V0-8-5/Mars/mtools/MagicSnake.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtools/MagicSnake.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtools/MagicSnake.h	(revision 9661)
@@ -0,0 +1,101 @@
+#ifndef MARS_MagicSnake
+#define MARS_MagicSnake
+
+#ifndef MARS_MAGIC
+#include "MAGIC.h"
+#endif
+
+#ifndef ROOT_TText
+#include <TText.h>
+#endif
+#ifndef ROOT_TTimer
+#include <TTimer.h>
+#endif
+#ifndef ROOT_TClonesArray
+#include <TClonesArray.h>
+#endif
+
+class TMarker;
+class TVirtualPad;
+
+class MGeomCam;
+class MHexagon;
+
+class MagicSnake : public TObject
+{
+private:
+    enum {
+        kRightTop,
+        kRight,
+        kRightBottom,
+        kLeftBottom,
+        kLeft,
+        kLeftTop
+    };
+
+    enum
+    {
+        kBackground   = 50,
+        kHasBomb      = BIT(16),
+        kHasFood      = BIT(17),
+        kHasWorm      = BIT(18),
+        kHasTransport = BIT(19),
+        kHasDoor      = BIT(20),
+        kUserBits     = 0x7fc000 // 14-23 are allowed
+
+    };
+
+    Byte_t    fLength;          // actual length of worm
+    Int_t    *fArray;           // inices of pixels which are 'wormed'
+    Char_t    fDirection;       // actual direction of worm
+
+    TTimer    fTimer;           // timer rising the 500ms interrputs
+
+    MGeomCam *fGeomCam;         // pointer to camera geometry
+
+    UShort_t  fTransport[2];    // pixel ids with the yellow transpoters
+    UInt_t    fNumPixels;       // number of pixels in the present geometry
+    Byte_t    fNumBombs;        // number of bombs in the field
+    Byte_t    fNumFood;         // number of food packages
+    Float_t   fRange;           // the range in millimeters of the present geometry
+
+    TText    *fDone;            // TText showing the 'Game over'
+    TText    *fPaused;          // TText showing the 'Game over'
+    TText     fShow;            // TText showing the numbers of pixels and bombs
+
+    UInt_t    fW;               // Width of canvas
+    UInt_t    fH;               // Height of canvas
+
+    TClonesArray  *fPixels;     // array of all hexagons
+    TVirtualPad   *fDrawingPad; // pad in which we are drawing
+
+    MHexagon &operator[](int i) { return *((MHexagon*)fPixels->At(i)); }
+
+    void   Remove(TObject *);
+    void   Done(TString, Int_t col);
+    void   Step(Int_t newpix);
+    void   Update();
+    void   Free();
+    void   DrawHexagons();
+    Int_t  ScanNeighbours();
+    void   SetNewCamera(MGeomCam *);
+    void   SetWormColor();
+    void   Pause(Bool_t yes=kTRUE);
+
+    Bool_t HandleTimer(TTimer *timer);
+    void   Draw(Option_t *option="");
+    void   Paint(Option_t *option="");
+    void   ExecuteEvent(Int_t event, Int_t px, Int_t py);
+    Int_t  DistancetoPrimitive(Int_t px, Int_t py) { return 0; }
+
+public:
+    MagicSnake();
+    ~MagicSnake();
+
+    void Reset();        //*MENU*
+    void ChangeCamera(); //*MENU*
+
+    ClassDef(MagicSnake, 0) // Magic Camera Games: Snake
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtools/Makefile
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtools/Makefile	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtools/Makefile	(revision 9661)
@@ -0,0 +1,46 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#------------------------------------------------------------------------------
+
+#
+# Handling name of the Root Dictionary Files
+#
+CINT  = Tools
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES = -I. -I../mbase -I../mgui -I../mgeom -I../mdata -I../mhbase \
+	   -I../mfileio -I../mfbase -I../manalysis
+
+#manalysis: MChisqEval (MParameters)
+
+SRCFILES = MChisqEval.cc \
+	   MTFillMatrix.cc \
+	   MHSimulatedAnnealing.cc \
+	   MSimulatedAnnealing.cc \
+	   MFFT.cc \
+	   MCubicCoeff.cc \
+           MCubicSpline.cc \
+	   MagicReversi.cc \
+	   MagicSnake.cc \
+           MagicShow.cc \
+           MagicDomino.cc \
+           MagicCivilization.cc \
+           MineSweeper.cc
+
+############################################################
+
+all: $(OBJS)
+
+include ../Makefile.rules
+
+mrproper:	clean rmbak
Index: /tags/Mars_V0-8-5/Mars/mtools/MineSweeper.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtools/MineSweeper.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtools/MineSweeper.cc	(revision 9661)
@@ -0,0 +1,528 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
+!
+!
+!   Author(s): Thomas Bretz 07/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2002
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MineSweeper
+// -----------
+//
+// Camera Display Games: Mine Sweeper
+//
+// Start the game by:
+//   MineSweeper mine;
+//
+// It is the well known Mine Sweeper.
+// Set a mark using a single mouse click.
+// Open a pixel using a double click.
+//
+// Try to open all pixels without bombs. If you open a pixel with no
+// bomb around all pixels around are opened.
+//
+// To restart the game use the context menu. It can only be accessed if
+// the game has been stopped (either because you win the game or because
+// you hit a bomb) With the context menu you can also toggle between
+// different camera layouts.
+//
+////////////////////////////////////////////////////////////////////////////
+#include "MineSweeper.h"
+
+#include <iostream>
+
+#include <TText.h>
+#include <TMarker.h>
+#include <TRandom.h>
+#include <TCanvas.h>
+#include <TClonesArray.h>
+#include <TInterpreter.h>
+
+#include "MHexagon.h"
+
+#include "MGeomPix.h"
+#include "MGeomCamCT1.h"
+#include "MGeomCamMagic.h"
+
+ClassImp(MineSweeper);
+
+using namespace std;
+
+const Int_t MineSweeper::fColorBombs[7] = {
+    22,
+    kYellow,
+    kGreen,
+    kBlue,
+    kCyan,
+    kMagenta,
+    kRed
+};
+
+void MineSweeper::Free()
+{
+    if (!fGeomCam)
+        return;
+
+    fPixels->Delete();
+    fText->Delete();
+    fFlags->Delete();
+
+    delete fText;
+    delete fFlags;
+    delete fPixels;
+
+    delete fGeomCam;
+}
+
+void MineSweeper::ChangeCamera()
+{
+    static Bool_t ct1=kFALSE;
+
+    cout << "Change to " << (ct1?"Magic":"CT1") << endl;
+
+    if (ct1)
+        SetNewCamera(new MGeomCamMagic);
+    else
+        SetNewCamera(new MGeomCamCT1);
+
+    ct1 = !ct1;
+
+    Reset();
+    DrawHexagons();
+}
+
+void MineSweeper::SetNewCamera(MGeomCam *geom)
+{
+    Free();
+
+    //
+    //  Reset the display geometry
+    //
+    fW=0;
+    fH=0;
+
+    //
+    //  Set new camera
+    //
+    fGeomCam = geom;
+
+    //
+    //  create the hexagons of the display
+    //
+    fNumPixels = fGeomCam->GetNumPixels();
+    fRange     = fGeomCam->GetMaxRadius();
+
+    //
+    // Construct all hexagons. Use new-operator with placement
+    //
+    fNumBombs = fNumPixels/5;
+
+    fText   = new TClonesArray("TText",    fNumPixels);
+    fFlags  = new TClonesArray("TMarker",  fNumPixels);
+    fPixels = new TClonesArray("MHexagon", fNumPixels);
+
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        MHexagon &h = *new ((*fPixels)[i]) MHexagon((*fGeomCam)[i]);
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+        h.SetBit(kNoContextMenu|kCannotPick);
+#endif
+
+        TText &t = *new ((*fText)[i]) TText;
+        t.SetTextFont(122);
+        t.SetTextAlign(22);   // centered/centered
+        t.SetTextSize(0.3*h.GetD()/fRange);
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+        t.SetBit(kNoContextMenu|kCannotPick);
+#endif
+
+        const MGeomPix &pix = (*fGeomCam)[i];
+
+        TMarker &m = *new ((*fFlags)[i]) TMarker(pix.GetX(), pix.GetY(), kOpenStar);
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+        m.SetBit(kNoContextMenu|kCannotPick);
+#endif
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// Draw all pixels of the camera
+//  (means apend all pixelobjects to the current pad)
+//
+void MineSweeper::DrawHexagons()
+{
+    for (UInt_t i=0; i<fNumPixels; i++)
+        (*this)[i].Draw();
+}
+
+// ------------------------------------------------------------------------
+//
+//  default constructor
+//
+MineSweeper::MineSweeper()
+    : fGeomCam(NULL), fDone(NULL), fShow(NULL), fW(0), fH(0), fDrawingPad(NULL), fIsAllocated(kFALSE)
+{
+    SetNewCamera(new MGeomCamMagic);
+
+    //
+    // Make sure, that the object is destroyed when the canvas/pad is
+    // destroyed. Make also sure, that the interpreter doesn't try to
+    // delete it a second time.
+    //
+    SetBit(kCanDelete);
+    gInterpreter->DeleteGlobal(this);
+
+    Draw();
+}
+
+// ------------------------------------------------------------------------
+//
+// Destructor. Deletes TClonesArrays for hexagons and legend elements.
+//
+MineSweeper::~MineSweeper()
+{
+    Free();
+
+    delete fShow;
+
+    if (fDone)
+        delete fDone;
+
+    if (fDrawingPad->GetListOfPrimitives()->FindObject(this)==this)
+    {
+        fDrawingPad->RecursiveRemove(this);
+        delete fDrawingPad;
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// This is called at any time the canvas should get repainted.
+// Here we maintain an aspect ratio of 5/4=1.15. This makes sure,
+// that the camera image doesn't get distorted by resizing the canvas.
+//
+void MineSweeper::Paint(Option_t *opt)
+{
+    const UInt_t w = (UInt_t)(gPad->GetWw()*gPad->GetAbsWNDC());
+    const UInt_t h = (UInt_t)(gPad->GetWh()*gPad->GetAbsHNDC());
+
+    //
+    // Check for a change in width or height, and make sure, that the
+    // first call also sets the range
+    //
+    if (w*fH == h*fW && fW && fH)
+        return;
+
+    //
+    // Calculate aspect ratio (5/4=1.25 recommended)
+    //
+    const Double_t ratio = (Double_t)w/h;
+
+    Float_t x;
+    Float_t y;
+
+    if (ratio>1.0)
+    {
+        x = fRange*(ratio*2-1);
+        y = fRange;
+    }
+    else
+    {
+        x = fRange;
+        y = fRange/ratio;
+    }
+
+    fH = h;
+    fW = w;
+
+    //
+    // Set new range
+    //
+    fDrawingPad->Range(-fRange, -y, x, y);
+
+    //
+    // Adopt absolute sized of markers to relative range
+    //
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        Float_t r = (*this)[i].GetD()*gPad->XtoAbsPixel(1)/325;
+        GetFlag(i)->SetMarkerSize(20.0*r/fRange);
+    }
+}
+
+// ------------------------------------------------------------------------
+//
+// Call this function to draw the camera layout into your canvas.
+// Setup a drawing canvas. Add this object and all child objects
+// (hexagons, etc) to the current pad. If no pad exists a new one is
+// created.
+//
+void MineSweeper::Draw(Option_t *option)
+{
+    // root 3.02:
+    // gPad->SetFixedAspectRatio()
+
+    if (fDrawingPad)
+        return;
+
+    //
+    // if no canvas is yet existing to draw into, create a new one
+    //
+    if (!gPad)
+    {
+        /*TCanvas *c =*/ new TCanvas("MineSweeper", "Magic Mine Sweeper", 0, 0, 800, 800);
+        //c->ToggleEventStatus();
+        fIsAllocated = kTRUE;
+    }
+    else
+        fIsAllocated = kFALSE;
+
+    fDrawingPad = gPad;
+    fDrawingPad->SetBorderMode(0);
+
+    //
+    // Append this object, so that the aspect ratio is maintained
+    // (Paint-function is called)
+    //
+    AppendPad(option);
+
+    //
+    // Draw the title text
+    //
+    fShow = new TText;
+    fShow->SetTextAlign(23);   // centered/bottom
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+    fShow->SetBit(kNoContextMenu|kCannotPick);
+#endif
+    fShow->Draw();
+    //
+    // Reset the game pad
+    //
+    Reset();
+    DrawHexagons();
+}
+
+void MineSweeper::Update(Int_t num)
+{
+    TString txt = "Pixels: ";
+    txt += fNumPixels;
+    txt += "  Bombs: ";
+    txt += num;
+
+    fShow->SetText(0, fRange, txt);
+}
+
+// ------------------------------------------------------------------------
+//
+// reset the all pixel colors to a default value
+//
+void MineSweeper::Reset()
+{
+    if (fDone)
+    {
+        delete fDone;
+        fDone = NULL;
+    }
+
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        Remove(GetText(i));
+        Remove(GetFlag(i));
+
+        (*this)[i].SetFillColor(kHidden);
+        (*fGeomCam)[i].ResetBit(kUserBits);
+
+        GetFlag(i)->SetMarkerColor(kBlack);
+    }
+    Update(fNumBombs);
+
+    TRandom rnd(0);
+    for (int i=0; i<fNumBombs; i++)
+    {
+        Int_t idx;
+
+        do idx = (Int_t)rnd.Uniform(fNumPixels);
+        while ((*fGeomCam)[idx].TestBit(kHasBomb));
+
+        (*fGeomCam)[idx].SetBit(kHasBomb);
+    }
+
+    fDrawingPad->SetFillColor(22);
+
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+    fDrawingPad->SetBit(kNoContextMenu);
+    SetBit(kNoContextMenu);
+#endif
+}
+
+void MineSweeper::Done(TString txt, Int_t col)
+{
+    for (unsigned int j=0; j<fNumPixels; j++)
+        if ((*fGeomCam)[j].TestBit(kHasBomb))
+        {
+            (*this)[j].SetFillColor(kBlack);
+            GetFlag(j)->SetMarkerColor(kWhite);
+        }
+
+    fDone = new TText(0, 0, txt);
+    fDone->SetTextColor(kWhite);  // white
+    fDone->SetTextAlign(22);  // centered/centered
+    fDone->SetTextSize(0.05); // white
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+    fDone->SetBit(kNoContextMenu|kCannotPick);
+#endif
+    fDone->Draw();
+
+    fDrawingPad->SetFillColor(col);
+
+#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
+    fDrawingPad->ResetBit(kNoContextMenu);
+    ResetBit(kNoContextMenu);
+#endif
+}
+
+// ------------------------------------------------------------------------
+//
+// Check whether a hexagon should be opened and which color/number should
+// be visible
+//
+void MineSweeper::OpenHexagon(Int_t idx)
+{
+    MGeomPix &pix=(*fGeomCam)[idx];
+
+    if (pix.TestBit(kIsVisible))
+        return;
+
+    if (pix.TestBit(kHasFlag))
+        Remove(GetFlag(idx));
+
+    pix.SetBit(kIsVisible);
+    pix.ResetBit(kHasFlag);
+
+    Int_t cnt=0;
+    for (int j=0; j<pix.GetNumNeighbors(); j++)
+        if ((*fGeomCam)[pix.GetNeighbor(j)].TestBit(kHasBomb))
+            cnt++;
+
+    (*this)[idx].SetFillColor(fColorBombs[cnt]);
+
+    if (cnt)
+    {
+        TText *txt = GetText(idx);
+        TString str;
+        str += cnt;
+        txt->SetText(pix.GetX(), pix.GetY(), str);
+        txt->Draw();
+        return;
+    }
+
+    for (int j=0; j<pix.GetNumNeighbors(); j++)
+        OpenHexagon(pix.GetNeighbor(j));
+}
+
+void MineSweeper::Remove(TObject *obj)
+{
+    fDrawingPad->RecursiveRemove(obj);
+}
+
+// ------------------------------------------------------------------------
+//
+// Execute a mouse event on the camera
+//
+void MineSweeper::ExecuteEvent(Int_t event, Int_t px, Int_t py)
+{
+    if (event==kMouseMotion   || event==kMouseEnter    || event==kMouseLeave    ||
+        event==kButton1Up     || event==kButton2Up     || event==kButton3Up     ||
+        event==kButton1Motion || event==kButton2Motion || event==kButton3Motion ||
+                                 event==kButton2Double || event==kButton3Double ||
+        fDone)
+        return;
+
+    /*
+    if (event==kKeyPress && py==0x1000)
+    {
+        Reset();
+        return;
+    }
+    */
+
+    UInt_t idx;
+    for (idx=0; idx<fNumPixels; idx++)
+        if ((*fPixels)[idx]->DistancetoPrimitive(px, py)==0)
+            break;
+
+    if (idx==fNumPixels)
+        return;
+
+    MGeomPix &pix=(*fGeomCam)[idx];
+
+    if (event==kButton1Double)
+    {
+        OpenHexagon(idx);
+
+        if (pix.TestBit(kHasBomb))
+            Done("Argh... you hit the Bomb!!!", kRed);
+    }
+
+    if (event==kButton1Down && !pix.TestBit(kIsVisible))
+    {
+        if (pix.TestBit(kHasFlag))
+            Remove(GetFlag(idx));
+        else
+            GetFlag(idx)->Draw();
+
+        pix.InvertBit(kHasFlag);
+    }
+
+    UInt_t vis=fNumBombs;
+    UInt_t flg=fNumBombs;
+    for (UInt_t i=0; i<fNumPixels; i++)
+    {
+        if ((*fGeomCam)[i].TestBit(kIsVisible))
+            vis++;
+        if ((*fGeomCam)[i].TestBit(kHasFlag))
+            flg--;
+    }
+
+    Update(flg);
+
+    if (vis==fNumPixels && !fDone)
+        Done("Great! Congratulations, you did it!", kGreen);
+
+    fDrawingPad->Modified();
+
+    /*
+     switch (event)
+     {
+     case kNoEvent:       cout << "No Event" << endl; break;
+     case kButton1Down:   cout << "Button 1 down" << endl; break;
+     case kButton2Down:   cout << "Button 2 down" << endl; break;
+     case kButton3Down:   cout << "Button 3 down" << endl; break;
+     case kKeyDown:       cout << "Key down" << endl; break;
+     case kKeyUp:         cout << "Key up" << endl; break;
+     case kKeyPress:      cout << "Key press" << endl; break;
+     case kButton1Locate: cout << "Button 1 locate" << endl; break;
+     case kButton2Locate: cout << "Button 2 locate" << endl; break;
+     case kButton3Locate: cout << "Button 3 locate" << endl; break;
+    }
+    */
+}
Index: /tags/Mars_V0-8-5/Mars/mtools/MineSweeper.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtools/MineSweeper.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtools/MineSweeper.h	(revision 9661)
@@ -0,0 +1,78 @@
+#ifndef MARS_MineSweeper
+#define MARS_MineSweeper
+
+#ifndef MARS_MAGIC
+#include "MAGIC.h"
+#endif
+#ifndef ROOT_TClonesArray
+#include <TClonesArray.h>
+#endif
+
+class TText;
+class TMarker;
+class TVirtualPad;
+
+class MGeomCam;
+class MHexagon;
+
+class MineSweeper : public TObject
+{
+private:
+    static const Int_t fColorBombs[7]; // colors for the hexagons
+
+    MGeomCam      *fGeomCam;       // pointer to camera geometry
+
+    UInt_t         fNumPixels;     // number of pixels in the present geometry
+    Int_t          fNumBombs;      // number of bombs in total
+    Float_t        fRange;         // the range in millimeters of the present geometry
+
+    TClonesArray  *fPixels;        // array of all hexagons
+    TClonesArray  *fText;          // array of all texts
+    TClonesArray  *fFlags;         // array of all texts
+
+    TText         *fDone;          // TText showing the 'Game over'
+    TText         *fShow;          // TText showing the numbers of pixels and bombs
+
+    UInt_t         fW;             // Width of canvas
+    UInt_t         fH;             // Height of canvas
+    TVirtualPad   *fDrawingPad;    // pad in which we are drawing
+    Bool_t         fIsAllocated;
+
+    enum
+    {
+        kHidden    = 50,
+        kIsVisible = BIT(16),
+        kHasBomb   = BIT(17),
+        kHasFlag   = BIT(18),
+        kUserBits  = 0x7fc000 // 14-23 are allowed
+    };
+
+    MHexagon &operator[](int i) { return *((MHexagon*)fPixels->At(i)); }
+
+    TText   *GetText(Int_t i) { return (TText*)fText->At(i); }
+    TMarker *GetFlag(Int_t i) { return (TMarker*)fFlags->At(i); }
+
+    void  Remove(TObject *);
+    void  OpenHexagon(Int_t idx);
+    void  Done(TString, Int_t);
+    void  Update(Int_t);
+    void  SetNewCamera(MGeomCam *);
+    void  DrawHexagons();
+    void  Free();
+
+    void  Paint(Option_t *option="");
+    void  Draw(Option_t *option="");
+    void  ExecuteEvent(Int_t event, Int_t px, Int_t py);
+    Int_t DistancetoPrimitive(Int_t px, Int_t py) { return 0; }
+
+public:
+    MineSweeper();
+    ~MineSweeper();
+
+    void Reset();        //*MENU*
+    void ChangeCamera(); //*MENU*
+
+    ClassDef(MineSweeper, 0) // Magic Camera Games: Mine Sweeper
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtools/ToolsIncl.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtools/ToolsIncl.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtools/ToolsIncl.h	(revision 9661)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-8-5/Mars/mtools/ToolsLinkDef.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtools/ToolsLinkDef.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtools/ToolsLinkDef.h	(revision 9661)
@@ -0,0 +1,23 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class MChisqEval+;
+
+#pragma link C++ class MTFillMatrix+;
+#pragma link C++ class MFFT+;
+#pragma link C++ class MHSimulatedAnnealing+;
+#pragma link C++ class MSimulatedAnnealing+;
+#pragma link C++ class MCubicCoeff+;
+#pragma link C++ class MCubicSpline+;
+
+#pragma link C++ class MineSweeper+;
+#pragma link C++ class MagicReversi+;
+#pragma link C++ class MagicSnake+;
+#pragma link C++ class MagicShow+;
+#pragma link C++ class MagicDomino+;
+#pragma link C++ class MagicCivilization+;
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtrigger/MTriggerBit.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtrigger/MTriggerBit.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtrigger/MTriggerBit.cc	(revision 9661)
@@ -0,0 +1,37 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!              Antonio Stamerra, 05/2004 <mailto:antonio.stamerra@pi.infn.it> 
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MTriggerBit
+//   This class stores the information about the L2 output Bit rates
+//   
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MTriggerBit.h"
+
+ClassImp(MTriggerBit);
+
+using namespace std;
Index: /tags/Mars_V0-8-5/Mars/mtrigger/MTriggerBit.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtrigger/MTriggerBit.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtrigger/MTriggerBit.h	(revision 9661)
@@ -0,0 +1,57 @@
+#ifndef MARS_MTriggerBit
+#define MARS_MTriggerBit
+
+#ifndef MARS_MCamEvent
+#include "MCamEvent.h"
+#endif
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif 
+
+#ifndef ROOT_TArrayF
+#include <TArrayF.h>
+#endif
+
+class MTriggerBit : public MParContainer, public MCamEvent
+{
+    friend class MReportTrigger;
+
+private:
+    
+    static const Int_t gsNBits=20;        // number of output bits
+
+    TArrayF fBit; // Array with the output bit rates
+
+public:
+    MTriggerBit() : fBit(gsNBits)  
+    {
+        fName  = "MTriggerBit";
+        fTitle = "Container for the L2 output bits rates ";
+    }
+
+    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const
+    {
+      if (idx > gsNBits)
+	return kFALSE;
+
+      val = fBit[idx];	
+
+      return val>0;
+    }
+
+    Double_t operator[](const Int_t idx) 
+      {  
+	if (idx > gsNBits)
+	  return kFALSE;
+	
+	return fBit[idx]; 
+      }
+
+    void DrawPixelContent(Int_t num) const
+    {
+    }
+
+    ClassDef(MTriggerBit, 1) // Container for the L2 output bits rates
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtrigger/MTriggerCell.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtrigger/MTriggerCell.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtrigger/MTriggerCell.cc	(revision 9661)
@@ -0,0 +1,37 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!              Antonio Stamerra, 05/2004 <mailto:antonio.stamerra@pi.infn.it> 
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MTriggerCell
+//   This class stores the information about the Trigger Cell Rates
+//   
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MTriggerCell.h"
+
+ClassImp(MTriggerCell);
+
+using namespace std;
Index: /tags/Mars_V0-8-5/Mars/mtrigger/MTriggerCell.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtrigger/MTriggerCell.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtrigger/MTriggerCell.h	(revision 9661)
@@ -0,0 +1,57 @@
+#ifndef MARS_MTriggerCell
+#define MARS_MTriggerCell
+
+#ifndef MARS_MCamEvent
+#include "MCamEvent.h"
+#endif
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif 
+
+#ifndef ROOT_TArrayF
+#include <TArrayF.h>
+#endif
+
+class MTriggerCell : public MParContainer, public MCamEvent
+{
+    friend class MReportTrigger;
+private:
+    static const Int_t gsNCells=32; //Number of fields with cell rates
+                                    // 19 cells and 12 dummy 
+
+    TArrayF fCellRate;       // Array of the measured L1 cell rates
+
+public:
+    MTriggerCell() : fCellRate(gsNCells)
+    {
+        fName  = "MTriggerCell";
+        fTitle = "Container for the measured cell rates";
+    }
+
+    Float_t GetMean() const { return fCellRate.GetSum()/fCellRate.GetSize(); }
+
+    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const
+    {
+      if (idx > gsNCells)
+	return kFALSE;
+      
+      val = fCellRate[idx];
+        return val>0;
+    }
+
+    Double_t operator[](const Int_t idx) 
+      { 
+	if (idx > gsNCells)
+	  return kFALSE;
+	
+	return fCellRate[idx]; 
+      }
+
+    void DrawPixelContent(Int_t num) const
+    {
+    }
+
+    ClassDef(MTriggerCell, 1) // Container for the trigger cell rates
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtrigger/MTriggerIPR.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtrigger/MTriggerIPR.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtrigger/MTriggerIPR.cc	(revision 9661)
@@ -0,0 +1,37 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!              Antonio Stamerra, 05/2004 <mailto:antonio.stamerra@pi.infn.it> 
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MTriggerIPR
+//   This class stores the information about the Individual Pixel Rates
+//   
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MTriggerIPR.h"
+
+ClassImp(MTriggerIPR);
+
+using namespace std;
Index: /tags/Mars_V0-8-5/Mars/mtrigger/MTriggerIPR.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtrigger/MTriggerIPR.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtrigger/MTriggerIPR.h	(revision 9661)
@@ -0,0 +1,56 @@
+#ifndef MARS_MTriggerIPR
+#define MARS_MTriggerIPR
+
+#ifndef MARS_MCamEvent
+#include "MCamEvent.h"
+#endif
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif 
+
+#ifndef ROOT_TArrayL
+#include <TArrayL.h>
+#endif
+
+class MTriggerIPR : public MParContainer, public MCamEvent
+{
+    friend class MReportTrigger;
+private:
+    TArrayL fIPR;            // [Hz] IPR (Individual Pixel Rates)
+    
+    static const Int_t gsNTrigPix=397;  // number of trigger pixels
+
+public:
+    MTriggerIPR() : fIPR(gsNTrigPix)
+    {
+        fName  = "MTriggerIPR";
+        fTitle = "Container for the Individual Pixel Rate (IPR)";
+    }
+
+    Float_t GetMean() const { return fIPR.GetSum()/fIPR.GetSize(); }
+
+    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const
+    {
+      if (idx > gsNTrigPix)
+	return kFALSE;
+
+      val = fIPR[idx];
+      return val>0;
+    }
+
+    Double_t operator[](const Int_t idx) 
+      {
+	if (idx > gsNTrigPix)
+	  return kFALSE;
+
+	return fIPR[idx]; 
+      } 
+
+    void DrawPixelContent(Int_t num) const
+    {
+    }
+
+    ClassDef(MTriggerIPR, 1) // Container for the Individual Pixel Rate (IPR)
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtrigger/MTriggerLiveTime.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtrigger/MTriggerLiveTime.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtrigger/MTriggerLiveTime.cc	(revision 9661)
@@ -0,0 +1,37 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!              Antonio Stamerra, 05/2004 <mailto:antonio.stamerra@pi.infn.it> 
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MTriggerLiveTime
+//   This class stores the information about the livetime and deadtime
+//   measured by the scalers 
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MTriggerLiveTime.h"
+
+ClassImp(MTriggerLiveTime);
+
+using namespace std;
Index: /tags/Mars_V0-8-5/Mars/mtrigger/MTriggerLiveTime.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtrigger/MTriggerLiveTime.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtrigger/MTriggerLiveTime.h	(revision 9661)
@@ -0,0 +1,57 @@
+#ifndef MARS_MTriggerLiveTime
+#define MARS_MTriggerLiveTime
+
+#ifndef MARS_MCamEvent
+#include "MCamEvent.h"
+#endif
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif 
+
+#ifndef ROOT_TArrayL
+#include <TArrayL.h>
+#endif
+
+class MTriggerLiveTime : public MParContainer, public MCamEvent
+{
+    friend class MReportTrigger;
+
+private:
+    static const Int_t gsNScalers=5;        // number of scalers
+
+    TArrayL fLiveTime; // Array with the livetime
+    TArrayL fDeadTime; // Array with the deadtime
+
+public:
+    MTriggerLiveTime() : fLiveTime(gsNScalers), fDeadTime(gsNScalers)  
+    {
+        fName  = "MTriggerLiveTime";
+        fTitle = "Container for the Live-deadtime      ";
+    }
+
+    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const
+    {
+      if (idx > gsNScalers)
+	return kFALSE;
+
+      val = fLiveTime[idx];	
+
+      return val>0;
+    }
+
+    Double_t operator[](const Int_t idx) 
+      {  	
+	if (idx > gsNScalers)
+	  return -1;
+	
+	return fLiveTime[idx]; 
+      }
+
+    void DrawPixelContent(Int_t num) const
+    {
+    }
+
+    ClassDef(MTriggerLiveTime, 1) // Container for the Live-Deadtime
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtrigger/MTriggerPrescFact.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtrigger/MTriggerPrescFact.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtrigger/MTriggerPrescFact.cc	(revision 9661)
@@ -0,0 +1,37 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!              Antonio Stamerra, 05/2004 <mailto:antonio.stamerra@pi.infn.it> 
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// MTriggerPrescFact
+//   This class stores the information about the L2 prescaling factors
+//   
+//
+/////////////////////////////////////////////////////////////////////////////
+#include "MTriggerPrescFact.h"
+
+ClassImp(MTriggerPrescFact);
+
+using namespace std;
Index: /tags/Mars_V0-8-5/Mars/mtrigger/MTriggerPrescFact.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtrigger/MTriggerPrescFact.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtrigger/MTriggerPrescFact.h	(revision 9661)
@@ -0,0 +1,57 @@
+#ifndef MARS_MTriggerPrescFact
+#define MARS_MTriggerPrescFact
+
+#ifndef MARS_MCamEvent
+#include "MCamEvent.h"
+#endif
+#ifndef MARS_MParContainer
+#include "MParContainer.h"
+#endif 
+
+#ifndef ROOT_TArrayL
+#include <TArrayL.h>
+#endif
+
+class MTriggerPrescFact : public MParContainer, public MCamEvent
+{
+    friend class MReportTrigger;
+
+private:
+    
+    static const Int_t gsNPrescFacts=8;        // number of factors
+
+    TArrayL fPrescFact; // Array with the prescaling factors
+
+public:
+    MTriggerPrescFact() : fPrescFact(gsNPrescFacts)  
+    {
+        fName  = "MTriggerPrescFact";
+        fTitle = "Container for the L2 Prescaling Factors      ";
+    }
+
+    Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const
+    {
+      if (idx > gsNPrescFacts)
+	return kFALSE;
+
+      val = fPrescFact[idx];	
+
+      return val>0;
+    }
+
+    Double_t operator[](const Int_t idx) 
+      {  
+	if (idx > gsNPrescFacts)
+	  return kFALSE;
+	
+	return fPrescFact[idx]; 
+      }
+
+    void DrawPixelContent(Int_t num) const
+    {
+    }
+
+    ClassDef(MTriggerPrescFact, 1) // Container for the L2 Prescaling Factors
+};
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/mtrigger/Makefile
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtrigger/Makefile	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtrigger/Makefile	(revision 9661)
@@ -0,0 +1,35 @@
+##################################################################
+#
+#   makefile
+# 
+#   for the MARS software
+#
+##################################################################
+include ../Makefile.conf.$(OSTYPE)
+include ../Makefile.conf.general
+
+#------------------------------------------------------------------------------
+
+#
+# Handling name of the Root Dictionary Files
+#
+CINT  = Trigger
+
+#
+#  connect the include files defined in the config.mk file
+#
+INCLUDES = -I. -I../mbase -I../mgui
+
+SRCFILES = MTriggerIPR.cc \
+	   MTriggerCell.cc\
+	   MTriggerBit.cc\
+	   MTriggerPrescFact.cc\
+	   MTriggerLiveTime.cc
+
+############################################################
+
+all: $(OBJS)
+
+include ../Makefile.rules
+
+mrproper:	clean rmbak
Index: /tags/Mars_V0-8-5/Mars/mtrigger/TriggerIncl.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtrigger/TriggerIncl.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtrigger/TriggerIncl.h	(revision 9661)
@@ -0,0 +1,3 @@
+#ifndef __CINT__
+
+#endif // __CINT__
Index: /tags/Mars_V0-8-5/Mars/mtrigger/TriggerLinkDef.h
===================================================================
--- /tags/Mars_V0-8-5/Mars/mtrigger/TriggerLinkDef.h	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/mtrigger/TriggerLinkDef.h	(revision 9661)
@@ -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 MTriggerIPR+;
+#pragma link C++ class MTriggerCell+;
+#pragma link C++ class MTriggerBit+;
+#pragma link C++ class MTriggerPrescFact+;
+#pragma link C++ class MTriggerLiveTime+;
+
+#endif
Index: /tags/Mars_V0-8-5/Mars/readdaq.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/readdaq.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/readdaq.cc	(revision 9661)
@@ -0,0 +1,197 @@
+#include <TSystem.h>
+
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MEvtLoop.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
+
+#include "MArgs.h"
+#include "MTime.h"
+#include "MPrint.h"
+#include "MRawRunHeader.h"
+#include "MRawEvtHeader.h"
+#include "MRawEvtData.h"
+#include "MRawCrateArray.h"
+#include "MRawFileRead.h"
+
+
+//#include "MInputStreamID.h"
+//#include "MMcEvt.hxx"
+//#include "MMcTrig.hxx"
+
+using namespace std;
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// This is an demonstration how to read in a unmerpped daq file
+//
+/////////////////////////////////////////////////////////////////////////////
+
+static void StartUpMessage()
+{
+    gLog << all << endl;
+
+    //                1         2         3         4         5
+    //       12345678901234567890123456789012345678901234567890
+    gLog << "==================================================" << endl;
+    gLog << "              ReadDaq - MARS V" << MARSVER          << endl;
+    gLog << "       MARS - Read and print daq data files"        << endl;
+    gLog << "            Compiled on <" << __DATE__ << ">"       << endl;
+    gLog << "               Using ROOT v" << ROOTVER             << endl;
+    gLog << "==================================================" << endl;
+    gLog << endl;
+}
+
+static void Usage()
+{
+    gLog << all << endl;
+    gLog << "Sorry the usage is:" << endl;
+    gLog << "   readdaq [-h] [-?] [-vn] [-dec] [-a0] inputfile[.raw]" << endl << endl;
+    gLog << "     input file:   Magic DAQ binary file." << endl;
+    gLog << "     -a0: Do not use Ansii codes." << endl;
+    gLog << "     -vn: Verbosity level n [default=2]" << endl;
+    gLog << "     -d1: print data in decimal values" << endl;
+    gLog << "     -c1: print MRawCrateArray data" << endl;
+    gLog << "     -?, -h, --help: This help" << endl << endl;
+}
+
+int main(int argc, char **argv)
+{
+    StartUpMessage();
+
+    //
+    // Evaluate arguments
+    //
+    MArgs arg(argc, argv);
+
+    if (arg.HasOnly("-?") || arg.HasOnly("-h") || arg.HasOnly("--help"))
+    {
+        Usage();
+        return -1;
+    }
+
+    //
+    // Set verbosity to highest level.
+    //
+    gLog.SetDebugLevel(arg.HasOption("-v") ? arg.GetIntAndRemove("-v") : 2);
+
+    if (arg.HasOption("-a") && arg.GetIntAndRemove("-a")==0)
+        gLog.SetNoColors();
+
+    const bool kDecimal    = arg.HasOption("-d") && arg.GetIntAndRemove("-d")==1;
+    const bool kPrintArray = arg.HasOption("-c") && arg.GetIntAndRemove("-c")==1;
+
+    //
+    // check for the right usage of the program
+    //
+    if (arg.GetNumArguments()!=1)
+    {
+        Usage();
+        return -1;
+    }
+
+    //
+    // This is to make argv[i] more readable insidethe code
+    //
+    TString kNamein = arg.GetArgumentStr(0);
+  
+    if (!kNamein.EndsWith(".raw"))
+        kNamein += ".raw";
+
+    //
+    // Initialize Non-GUI (batch) mode
+    //
+    gROOT->SetBatch();
+
+    //
+    // check whether the given files are OK.
+    //
+    if (gSystem->AccessPathName(kNamein, kFileExists))
+    {
+        gLog << err << "Sorry, the input file '" << kNamein << "' doesn't exist." << endl;
+        return -1;
+    }
+
+    //
+    //  open the file
+    //
+    gLog << " Open the file '" << kNamein << "'" << endl;
+
+
+    //
+    // 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;
+    tasks.SetOwner();
+    plist.AddToList(&tasks);
+
+    //
+    // ---- The 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;
+    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 read(kNamein);
+    tasks.AddToList(&read);
+
+    MPrint print0;
+    MPrint print1("MRawEvtHeader",  "nogains", "PrintEvtHeader");
+    MPrint print2("MTime",          "", "PrintTime");
+    MPrint print3("MRawCrateArray", "", "PrintCrateArray");
+    MPrint print4("MRawEvtData", kDecimal?"dec":"hex", "PrintEvtData");
+
+    tasks.AddToList(&print0);
+    tasks.AddToList(&print1);
+    tasks.AddToList(&print2);
+    if (kPrintArray)
+        tasks.AddToList(&print3);
+    tasks.AddToList(&print4);
+
+    //
+    // create the looping object and tell 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 << err << "ERROR: Reading DAQ file failed!" << endl;
+        return -1;
+    }
+
+    gLog << all << "Reading DAQ file finished successfull!" << endl;
+
+    // end of small readin program
+
+    return 0;
+}
Index: /tags/Mars_V0-8-5/Mars/readraw.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/readraw.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/readraw.cc	(revision 9661)
@@ -0,0 +1,218 @@
+#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 "MLogManip.h"
+
+#include "MArgs.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"
+
+using namespace std;
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// This is an demonstration how to read in a merpped root file
+// This is a demonstration how to use root, not how you should
+// read a merpped file!
+//
+/////////////////////////////////////////////////////////////////////////////
+
+static void StartUpMessage()
+{
+    gLog << all << endl;
+
+    //                1         2         3         4         5
+    //       12345678901234567890123456789012345678901234567890
+    gLog << "==================================================" << endl;
+    gLog << "              ReadRaw - MARS V" << MARSVER          << endl;
+    gLog << "       MARS - Read and print raw data files"        << endl;
+    gLog << "            Compiled on <" << __DATE__ << ">"       << endl;
+    gLog << "               Using ROOT v" << ROOTVER             << endl;
+    gLog << "==================================================" << endl;
+    gLog << endl;
+}
+
+static void Usage()
+{
+    gLog << all << endl;
+    gLog << "Sorry the usage is:" << endl;
+    gLog << "   readraw [-h] [-?] [-vn] [-dec] [-a0] inputfile[.root]" << endl << endl;
+    gLog << "     input file:   Magic DAQ binary file." << endl;
+    gLog << "     -vn: Verbosity level n [default=2]" << endl;
+    gLog << "     -d, --dec: print data in decimal values" << endl;
+    gLog << "     -a, --no-colors: Do not use Ansii color codes" << endl;
+    gLog << "     -?,-h,--help: This help" << endl << endl;
+}
+
+void EnableBranch(TTree *t, TString name, void *ptr)
+{
+    if (!t->GetBranch(name+"."))
+        return;
+
+    t->GetBranch(name+".")->SetAddress(ptr);
+    gLog << " Found '" << name << "'" << endl;
+}
+
+int main(int argc, char **argv)
+{
+    StartUpMessage();
+
+    // Evaluate arguments
+    MArgs arg(argc, argv);
+
+    // check for the right usage of the program
+    if (arg.HasOption("-?") || arg.HasOption("-h") || arg.HasOption("--help") ||
+        arg.GetNumArguments()!=1)
+    {
+        Usage();
+        return -1;
+    }
+
+    // Set verbosity
+    gLog.SetDebugLevel(arg.HasOption("-v") ? arg.GetIntAndRemove("-v") : 2);
+
+    // Set color usage
+    if (arg.HasOnlyAndRemove("--no-colors") || arg.HasOnlyAndRemove("-a"))
+        gLog.SetNoColors();
+
+    // Set usage of decimal values
+    const bool kDecimal = arg.HasOnlyAndRemove("-d") || arg.HasOnlyAndRemove("--dec");
+
+    //
+    // check for unidentified options
+    //
+    if (arg.GetNumOptions()>0)
+    {
+        gLog << warn << "WARNING - unknown commandline options..." << endl;
+        arg.Print("options");
+        gLog << endl;
+    }
+
+    //
+    // This is to make argv[i] more readable insidethe code
+    //
+    TString kNamein = arg.GetArgumentStr(0);
+  
+    if (!kNamein.EndsWith(".root"))
+        kNamein += ".root";
+
+    //
+    // Initialize Non-GUI (batch) mode
+    //
+    gROOT->SetBatch();
+
+    //
+    // check whether the given files are OK.
+    //
+    if (gSystem->AccessPathName(kNamein, kFileExists))
+    {
+        gLog << err << "Sorry, the input file '" << kNamein << "' doesn't exist." << endl;
+        return -1;
+    }
+
+    //
+    //  open the file
+    //
+    gLog << inf << " Open the file '" << kNamein << "'" << endl;
+    TFile input(kNamein, "READ");
+
+    //
+    // open the Run Header and read in
+    //
+    gLog << " Check for Tree 'RunHeaders'" << endl;
+    TTree *runtree = (TTree*)input.Get("RunHeaders");
+    if (!runtree)
+        gLog << warn << " WARNING - This file has no Tree 'RunHeaders'" << endl << endl;
+    else
+    {
+        gLog << " Entries in Tree RunHeaders: " << dec << runtree->GetEntries() << endl;
+
+        MRawRunHeader *runheader = NULL;
+        runtree->GetBranch("MRawRunHeader")->SetAddress(&runheader);
+        runtree->GetEvent(0);
+        runheader->Print();
+    }
+
+    //
+    // open the DataTree and read in 
+    //
+    gLog << inf << " Check the Tree 'Events'" << endl ;
+    TTree *evttree = (TTree*)input.Get("Events") ;
+    if (!evttree)
+    {
+        gLog << err << "Tree 'Events' not found in file... exit!" << endl;
+        return -1;
+    }
+
+    //
+    //  check the branches in the Tree 
+    //
+    gLog << " Check all the Branches in the Tree." << endl;
+    gLog << endl;
+
+    MRawEvtHeader  *evtheader = NULL;
+    MTime          *evttime   = NULL;
+    MRawEvtData    *evtdata   = NULL;
+    MRawCrateArray *evtcrate  = NULL;
+    MMcEvt         *evtmc     = NULL;
+    MMcTrig        *trigmc    = NULL;
+
+    EnableBranch(evttree, "MRawEvtHeader",  &evtheader);
+    EnableBranch(evttree, "MTime",          &evttime);
+    EnableBranch(evttree, "MRawEvtData",    &evtdata);
+    EnableBranch(evttree, "MRawCrateArray", &evtcrate);
+    EnableBranch(evttree, "MMcEvt",         &evtmc);
+    EnableBranch(evttree, "MMcTrig",        &trigmc);
+
+    //
+    // loop over all entries 
+    //
+    const Int_t nent = (Int_t)evttree->GetEntries();
+
+    gLog << " Entries in Tree Data: " << dec << nent << endl;
+    gLog << endl;
+
+    for (Int_t i = 0; i<nent; i++)
+    {
+        gLog << all << "Entry: " << i << endl;
+
+        //
+        // readin event with the selected branches
+        //
+        evttree->GetEvent(i);
+
+        if (evtmc)
+            evtmc->Print();
+        if (trigmc)
+            trigmc->Print();
+        if (evtheader)
+            evtheader->Print();
+        if (evttime)
+            evttime->Print();
+        if (evtcrate)
+            evtcrate->Print();
+        if (evtdata)
+            evtdata->Print(kDecimal?"dec":"hex");
+
+        gLog << endl;
+    } 
+    
+    // end of small readin program
+
+    return 0;
+}
Index: /tags/Mars_V0-8-5/Mars/star.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/star.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/star.cc	(revision 9661)
@@ -0,0 +1,470 @@
+#include <TSystem.h>
+
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MEvtLoop.h"
+/*'
+#include "MLog.h"
+ */
+#include "MLogManip.h"
+
+#include "MArgs.h"
+
+#include "MArray.h"
+#include "MReadMarsFile.h"
+#include "MGeomApply.h"
+#include "MMcPedestalCopy.h"
+#include "MMcPedestalNSBAdd.h"
+#include "MCerPhotCalc.h"
+#include "MCerPhotAnal2.h"
+#include "MSigmabarCalc.h"
+#include "MImgCleanStd.h"
+#include "MHillasCalc.h"
+#include "MHillasSrcCalc.h"
+#include "MWriteRootFile.h"
+#include "MFDataMember.h"
+#include "MFillH.h"
+#include "MReportDrive.h"    // PRELIMINARY:
+//#include "MPointingPos.h"    // PRELIMINARY:
+//#include "MPointingPosCalc.h"
+
+using namespace std;
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// This is an easy implementation of the Star process
+// (as compilable prog)
+//
+//////////////////////////////////////////////////////////////////////////////
+
+static void StartUpMessage()
+{
+    gLog << all << endl;
+
+    //                1         2         3         4         5
+    //       12345678901234567890123456789012345678901234567890
+    gLog << "==================================================" << endl;
+    gLog << "                 STAR - MARS V" << MARSVER          << endl;
+    gLog << "   MARS - STandard Analysis and Reconstruction"     << endl;
+    gLog << "            Compiled on <" << __DATE__ << ">"       << endl;
+    gLog << "               Using ROOT v" << ROOTVER             << endl;
+    gLog << "==================================================" << endl;
+    gLog << endl;
+}
+
+static void Usage()
+{
+    gLog << all << endl;
+    gLog << "Sorry the usage is:" << endl;
+    gLog << "   star [-a0] [-vn] [-cn] inputfile[.root] outputfile[.root]" << endl << endl;
+    gLog << "     input file: Merpped or MC root file." << endl;
+    gLog << "     ouput file: Star-file (image parameter file)" << endl;
+    gLog << "     -a0: Do not use Ansii codes." << endl;
+    gLog << "     -cn: Compression level n=1..9 [default=2]" << endl;
+    gLog << "     -vn: Verbosity level n [default=2]" << endl;
+    gLog << "     -u1: Update File (instead of Recreate)" << endl;
+    gLog << "     -tn: Telescope Serial Number n [default=0]" << endl << endl;
+    gLog << " -> Further setup is not possible at the moment, please use" << endl;
+    gLog << "    the star.C root macro instead. Using an input card will" << endl;
+    gLog << "    be implemented in the future." << endl << endl;
+}
+
+class MJStar : public MParContainer
+{
+private:
+    TString fInputFile;
+    TString fOutputFile;
+
+    Bool_t fIsUpdate;
+    Byte_t fComprLevel;
+
+    Byte_t fSerialIdx;
+
+    Bool_t CheckFiles()
+    {
+        if (fOutputFile.IsNull())
+        {
+            fOutputFile = fInputFile;
+
+            if (fOutputFile.EndsWith(".raw"))
+                fOutputFile = fOutputFile(0, fOutputFile.Length()-4);
+
+            if (fOutputFile.EndsWith(".rep"))
+                fOutputFile = fOutputFile(0, fOutputFile.Length()-4);
+
+            if (fOutputFile.EndsWith(".txt"))
+                fOutputFile = fOutputFile(0, fOutputFile.Length()-4);
+        }
+
+        if (fInputFile.IsNull())
+        {
+            *fLog << err << "Sorry, no input file." << endl;
+            return kFALSE;
+        }
+
+        if (fOutputFile.IsNull())
+        {
+            *fLog << err << "Sorry, no output file." << endl;
+            return kFALSE;
+        }
+
+        if (!fInputFile.EndsWith(".root"))
+            fInputFile += ".root";
+
+        if (!fOutputFile.EndsWith(".root"))
+            fOutputFile += ".root";
+
+        //
+        // check whether the given files are OK.
+        //
+        if (gSystem->AccessPathName(fInputFile, kFileExists))
+        {
+            *fLog << err << "Sorry, the input file '" << fInputFile << "' doesn't exist." << endl;
+            return kFALSE;
+        }
+
+        if (!gSystem->AccessPathName(fOutputFile, kFileExists))
+        {
+            if (fIsUpdate)
+                gLog << warn << "Warning: File doesn't '" << fOutputFile << "' exist... recreating." << endl;
+        }
+
+        if (fIsUpdate || gSystem->AccessPathName(fOutputFile, kFileExists))
+            if (!gSystem->AccessPathName(fOutputFile, kWritePermission))
+        {
+            gLog << err << "Sorry, you don't have write permission for '" << fOutputFile << "'." << endl;
+            return kFALSE;
+        }
+        return kTRUE;
+    }
+
+public:
+    MJStar(const char *name=0, const char *title=0)
+        : fIsUpdate(kFALSE), fComprLevel(1), fSerialIdx(0)
+    {
+        fName  = name;
+        fTitle = title;
+    }
+
+    void SetInputFile(const char *f)  { fInputFile  = f; }
+    void SetOutputFile(const char *f) { fOutputFile = f; }
+    void SetSerialIdx(Byte_t i)       { fSerialIdx  = i; }
+    void SetComprLevel(Byte_t l)      { fComprLevel = l; }
+    void SetUpdate(Bool_t u=kTRUE)    { fIsUpdate   = u; }
+
+    Bool_t Process()
+    {
+        if (!CheckFiles())
+            return kFALSE;
+
+        //
+        // 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);
+
+        // PRELIMINARY:
+        /*
+         MReportDrive rep;
+         plist.AddToList(&rep);
+         MPointingPos pos;
+         plist.AddToList(&pos);
+         */
+
+        //
+        // Now setup the tasks and tasklist:
+        // ---------------------------------
+        //
+        MReadMarsFile read("Events", fInputFile);
+        read.DisableAutoScheme();
+
+        MGeomApply        apply;
+        MMcPedestalCopy   pcopy;
+        MMcPedestalNSBAdd pnsb;
+
+        //MPointingPosCalc  pcalc;
+
+        MCerPhotCalc      ncalc;
+        MCerPhotAnal2     nanal;
+
+        MFDataMember f1("MRawRunHeader.fRunType", '>', 255.5);
+        MFDataMember f2("MRawRunHeader.fRunType", '<', 255.5);
+
+        ncalc.SetFilter(&f1);
+        nanal.SetFilter(&f2);
+
+        MSigmabarCalc     sgcal;
+        //MFillH            fills("MHSigmaTheta",  "", "FillSigmaTheta");
+        //MFillH            fillb("MHBlindPixels", "", "FillBlindPixels");
+        MImgCleanStd      clean;
+        MHillasCalc       hcalc;
+        MHillasSrcCalc    scalc; // !!Preliminary!! Will be removed later!
+        MWriteRootFile    write(fOutputFile, fIsUpdate?"UPDATE":"RECREATE", "Star output", fComprLevel);
+
+        tlist.AddToList(&read);
+        tlist.AddToList(&f1);
+        tlist.AddToList(&f2);
+        tlist.AddToList(&apply);
+        tlist.AddToList(&pcopy);
+        tlist.AddToList(&pnsb);
+        //tlist.AddToList(&pcalc);
+        tlist.AddToList(&ncalc);
+        tlist.AddToList(&nanal);
+        tlist.AddToList(&sgcal);
+        //tlist.AddToList(&fills);
+        //tlist.AddToList(&fillb);
+        tlist.AddToList(&clean);
+        tlist.AddToList(&hcalc);
+        tlist.AddToList(&scalc);
+        tlist.AddToList(&write);
+
+        //
+        // Set the serial number for all tasks in the current tasklist
+        //
+        tlist.SetSerialNumber(fSerialIdx);
+
+        //
+        // Setup tasks
+        //
+        write.AddContainer(write.AddSerialNumber("MMcEvt"),       "Events", kFALSE);
+        write.AddContainer(write.AddSerialNumber("MSigmabar"),    "Events");
+        write.AddContainer(write.AddSerialNumber("MHillas"),      "Events");
+        write.AddContainer(write.AddSerialNumber("MHillasExt"),   "Events");
+        write.AddContainer(write.AddSerialNumber("MHillasSrc"),   "Events");
+        write.AddContainer(write.AddSerialNumber("MNewImagePar"), "Events");
+        write.AddContainer(write.AddSerialNumber("MSrcPosCam"),   "RunHeaders");
+        //write.AddContainer(write.AddSerialNumber("MHSigmaTheta"), "RunHeaders");
+        if (!fIsUpdate)
+        {
+            write.AddContainer("MRawRunHeader", "RunHeaders");
+            write.AddContainer("MMcRunHeader",  "RunHeaders", kFALSE);
+        }
+
+        //
+        // Create and set up the eventloop
+        //
+        MEvtLoop evtloop;
+        evtloop.SetParList(&plist);
+
+        //
+        // Execute your analysis
+        //
+        if (!evtloop.Eventloop())
+        {
+            gLog << err << "ERROR: Star eventloop failed!" << endl;
+            return kFALSE;
+        }
+
+        tlist.PrintStatistics();
+
+        //plist.FindObject("MHSigmaTheta")->Write();
+
+        gLog << all << "Star finished successfull!" << endl;
+
+        return kTRUE;
+    }
+//    ClassDef(MJStar, 0)
+};
+
+//ClassImp(MJStar);
+
+
+int main(const int argc, char **argv)
+{
+    StartUpMessage();
+
+    //
+    // Evaluate arguments
+    //
+    MArgs arg(argc, argv);
+
+    //
+    // Set verbosity to highest level.
+    //
+    gLog.SetDebugLevel(arg.HasOption("-v") ? arg.GetIntAndRemove("-v") : 2);
+
+    if (arg.HasOption("-a") && arg.GetIntAndRemove("-a")==0)
+        gLog.SetNoColors();
+
+    const int  kComprlvl = arg.HasOption("-c") ? arg.GetIntAndRemove("-c") : 1;
+    const int  kTelIndex = arg.HasOption("-t") ? arg.GetIntAndRemove("-t") : 0;
+    const bool kUpdate   = arg.HasOption("-u") && arg.GetIntAndRemove("-u")==1;
+
+    //
+    // check for the right usage of the program
+    //
+    if (arg.GetNumArguments()!=2)
+    {
+        Usage();
+        return -1;
+    }
+
+    //
+    // Initialize Non-GUI (batch) mode
+    //
+    gROOT->SetBatch();
+
+    MArray::Class()->IgnoreTObjectStreamer();
+    MParContainer::Class()->IgnoreTObjectStreamer();
+
+    MJStar star;
+    star.SetInputFile(arg.GetArgumentStr(0));
+    star.SetOutputFile(arg.GetArgumentStr(1));
+    star.SetComprLevel(kComprlvl);
+    star.SetSerialIdx(kTelIndex);
+    star.SetUpdate(kUpdate);
+
+    if (!star.Process())
+    {
+        gLog << err << "Star failed!" << endl;
+        return -1;
+    }
+
+    gLog << inf << "Star finished successfull!" << endl;
+
+    return 0;
+/*
+    //
+    // This is to make argv[i] more readable inside the code
+    //
+    TString kNamein  = arg.GetArgumentStr(0);
+    TString kNameout = arg.GetArgumentStr(1);
+
+    if (!kNamein.EndsWith(".root"))
+        kNamein += ".root";
+
+    if (!kNameout.EndsWith(".root"))
+        kNameout += ".root";
+
+    //
+    // check whether the given files are OK.
+    //
+    if (gSystem->AccessPathName(kNamein, kFileExists))
+    {
+        gLog << err << "Sorry, the input file '" << kNamein << "' doesn't exist." << endl;
+        return -1;
+    }
+
+    if (!gSystem->AccessPathName(kNameout, kFileExists))
+    {
+        if (kUpdate)
+            gLog << warn << "Warning: File doesn't '" << kNameout << "' exist... recreating." << endl;
+    }
+
+    if (kUpdate || gSystem->AccessPathName(kNameout, kFileExists))
+        if (!gSystem->AccessPathName(kNameout, kWritePermission))
+        {
+            gLog << err << "Sorry, you don't have write permission for '" << kNameout << "'." << endl;
+            return -1;
+        }
+
+    //
+    // 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);
+
+    // PRELIMINARY:
+    // MReportDrive rep;
+    // plist.AddToList(&rep);
+    // MPointingPos pos;
+    // plist.AddToList(&pos);
+
+    //
+    // Now setup the tasks and tasklist:
+    // ---------------------------------
+    //
+    MReadMarsFile read("Events", kNamein);
+    read.DisableAutoScheme();
+
+    MGeomApply        apply;
+    MMcPedestalCopy   pcopy;
+    MMcPedestalNSBAdd pnsb;
+
+    //MPointingPosCalc  pcalc;
+
+    MCerPhotCalc      ncalc;
+    MCerPhotAnal2     nanal;
+
+    MFDataMember f1("MRawRunHeader.fRunType", '>', 255.5);
+    MFDataMember f2("MRawRunHeader.fRunType", '<', 255.5);
+
+    ncalc.SetFilter(&f1);
+    nanal.SetFilter(&f2);
+
+    MSigmabarCalc     sgcal;
+    //MFillH            fills("MHSigmaTheta",  "", "FillSigmaTheta");
+    MImgCleanStd      clean;
+    MHillasCalc       hcalc;
+    MHillasSrcCalc    scalc; // !!Preliminary!! Will be removed later!
+    MWriteRootFile    write(kNameout, kUpdate?"UPDATE":"RECREATE", "Star output", kComprlvl);
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&f1);
+    tlist.AddToList(&f2);
+    tlist.AddToList(&apply);
+    tlist.AddToList(&pcopy);
+    tlist.AddToList(&pnsb);
+    //tlist.AddToList(&pcalc);
+    tlist.AddToList(&ncalc);
+    tlist.AddToList(&nanal);
+    tlist.AddToList(&sgcal);
+    //tlist.AddToList(&fills);
+    //tlist.AddToList(&fillb);
+    tlist.AddToList(&clean);
+    tlist.AddToList(&hcalc);
+    tlist.AddToList(&scalc);
+    tlist.AddToList(&write);
+
+    //
+    // Set the serial number for all tasks in the current tasklist
+    //
+    tlist.SetSerialNumber(kTelIndex);
+
+    //
+    // Setup tasks
+    //
+
+    write.AddContainer(write.AddSerialNumber("MMcEvt"),       "Events", kFALSE);
+    write.AddContainer(write.AddSerialNumber("MSigmabar"),    "Events");
+    write.AddContainer(write.AddSerialNumber("MHillas"),      "Events");
+    write.AddContainer(write.AddSerialNumber("MHillasExt"),   "Events");
+    write.AddContainer(write.AddSerialNumber("MHillasSrc"),   "Events");
+    write.AddContainer(write.AddSerialNumber("MNewImagePar"), "Events");
+    write.AddContainer(write.AddSerialNumber("MSrcPosCam"),   "RunHeaders");
+    //write.AddContainer(write.AddSerialNumber("MHSigmaTheta"), "RunHeaders");
+    if (!kUpdate)
+    {
+        write.AddContainer("MRawRunHeader", "RunHeaders");
+        write.AddContainer("MMcRunHeader",  "RunHeaders", kFALSE);
+    }
+
+    //
+    // Create and set up the eventloop
+    //
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+
+    //
+    // Execute your analysis
+    //
+    if (!evtloop.Eventloop())
+    {
+        gLog << err << "ERROR: Star eventloop failed!" << endl;
+        return -1;
+    }
+
+    tlist.PrintStatistics();
+
+    //plist.FindObject("MHSigmaTheta")->Write();
+
+    gLog << all << "Star finished successfull!" << endl;
+    return 0;
+    */
+}
Index: /tags/Mars_V0-8-5/Mars/status.cc
===================================================================
--- /tags/Mars_V0-8-5/Mars/status.cc	(revision 9661)
+++ /tags/Mars_V0-8-5/Mars/status.cc	(revision 9661)
@@ -0,0 +1,340 @@
+/* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that 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, 4/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
+!
+!   Copyright: MAGIC Software Development, 2000-2003
+!
+!
+\* ======================================================================== */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+//  Status - Example how to use the MStatusDisplay
+//
+//  Use a camera file as input ----- PRELIMINARY
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#include "MStatusDisplay.h"
+#include "MArray.h"
+#include "MArgs.h"
+#include "MLog.h"
+#include "MLogManip.h"
+#include "MParList.h"
+#include "MTaskList.h"
+#include "MReadMarsFile.h"
+#include "MGeomApply.h"
+#include "MMcPedestalCopy.h"
+#include "MMcPedestalNSBAdd.h"
+//#include "MCerPhotCalc.h"
+#include "MCerPhotAnal2.h"
+//#include "MBlindPixelCalc.h"
+#include "MSigmabarCalc.h"
+#include "MImgCleanStd.h"
+#include "MHillasCalc.h"
+#include "MHillasSrcCalc.h"
+//#include "MCT1SupercutsCalc.h"
+#include "MHCamEvent.h"
+#include "MFillH.h"
+#include "MEvtLoop.h"
+#include "MFDataMember.h"
+#include "MCalibrate.h"
+#include "MExtractSignal.h"
+#include "MMcCalibrationUpdate.h"
+
+#include <TApplication.h>
+#include <TSystem.h>
+
+using namespace std;
+
+static void StartUpMessage()
+{
+    gLog << all << endl;
+
+    //                1         2         3         4         5
+    //       12345678901234567890123456789012345678901234567890
+    gLog << "==================================================" << endl;
+    gLog << "               status - MARS V" << MARSVER          << endl;
+    gLog << "     MARS - Merging and Preprocessing Program"      << endl;
+    gLog << "            Compiled on <" << __DATE__ << ">"       << endl;
+    gLog << "               Using ROOT v" << ROOTVER             << endl;
+    gLog << "   PROGRAM IS PRELIMINARY - FOR TEST CASES ONLY"    << endl;
+    gLog << "==================================================" << endl;
+    gLog << endl;
+}
+
+static void Usage()
+{
+    gLog << all << endl;
+    gLog << "Sorry the usage is:" << endl;
+    gLog << "   status [-a0] [-vn] [-cn] inputfile[.root]" << endl << endl;
+    gLog << "     input file:   Mars root file." << endl;
+    gLog << "     -a0: Do not use Ansii codes." << endl;
+    gLog << "     -vn: Verbosity level n [default=2]" << endl;
+    gLog << "     -?/-h: This help" << endl << endl;
+}
+
+
+int main(int argc, char **argv)
+{
+    StartUpMessage();
+
+    //
+    // Evaluate arguments
+    //
+    MArgs arg(argc, argv);
+
+    if (arg.HasOption("-?") || arg.HasOption("-h"))
+    {
+        Usage();
+        return -1;
+    }
+
+    //
+    // Set verbosity to highest level.
+    //
+    gLog.SetDebugLevel(arg.HasOption("-v") ? arg.GetIntAndRemove("-v") : 2);
+
+    if (arg.HasOption("-a") && arg.GetIntAndRemove("-a")==0)
+        gLog.SetNoColors();
+
+    //
+    // check for the right usage of the program
+    //
+    if (arg.GetNumArguments()!=1)
+    {
+        Usage();
+        return -1;
+    }
+
+    //
+    // This is to make argv[i] more readable insidethe code
+    //
+    TString kNamein = arg.GetArgumentStr(0);
+
+    if (!kNamein.EndsWith(".root"))
+        kNamein += ".root";
+
+    //
+    // check whether the given files are OK.
+    //
+    if (gSystem->AccessPathName(kNamein, kFileExists))
+    {
+        gLog << err << "Sorry, the input file '" << kNamein << "' doesn't exist." << endl;
+        return -1;
+    }
+
+    TApplication app("Status", &argc, argv);
+    if (gROOT->IsBatch() || !gClient)
+    {
+        gLog << "Bombing... maybe your DISPLAY variable is not set correctly!" << endl;
+        return 1;
+    }
+
+    MArray::Class()->IgnoreTObjectStreamer();
+    MParContainer::Class()->IgnoreTObjectStreamer();
+
+    //
+    // Update frequency by default = 1Hz
+    //
+    MStatusDisplay *d = new MStatusDisplay;
+
+    // From now on each 'Exit' means: Terminate the application
+    d->SetBit(MStatusDisplay::kExitLoopOnExit);
+
+    // Set update time to 5s
+    // d->SetUpdateTime(5000);
+
+    // Disable online update
+    // d->SetUpdateTime(-1);
+
+    d->SetLogStream(&gLog, kTRUE);            // Disables output to stdout
+    gLog.SetOutputFile("status.log", kTRUE);  // Enable output to file
+    //gLog.EnableOutputDevice(MLog::eStdout); // Enable output to stdout again
+
+    // Set input file as display title (bottom line in ps file)
+    d->SetTitle(kNamein);
+
+    //
+    // Create a empty Parameter List and an empty Task List
+    // The tasklist is identified in the eventloop by its name
+    //
+    MParList  plist;
+
+    MTaskList tlist;
+    plist.AddToList(&tlist);
+
+    /*
+     MSrcPosCam src;
+     src.SetXY(1./geomcam.GetConvMm2Deg(), 0);
+     plist.AddToList(&src);
+     */
+
+    //
+    // Now setup the tasks and tasklist:
+    // ---------------------------------
+    //
+    MReadMarsFile read("Events");
+    //read.DisableAutoScheme();
+
+    // ------------- user change -----------------
+    read.AddFile(kNamein);
+
+    MGeomApply        geomapl;
+    MMcPedestalCopy   pcopy;
+    MMcPedestalNSBAdd pnsb;
+    //MCerPhotCalc      ncalc;
+    MCerPhotAnal2     nanal;
+
+    MFDataMember f1("MRawRunHeader.fRunType", '>', 255.5);
+    MFDataMember f2("MRawRunHeader.fRunType", '<', 255.5);
+    f1.SetName("MFMonteCarlo");
+    f2.SetName("MFRealData");
+
+    MExtractSignal extra;
+    extra.SetRange(5, 9, 5, 9);
+
+    MMcCalibrationUpdate mcupd;
+    mcupd.SetOuterPixelsGainScaling(kFALSE);
+
+    MCalibrate calib;
+
+    // MC
+    extra.SetFilter(&f1);
+    mcupd.SetFilter(&f1);
+    calib.SetFilter(&f1);
+    nanal.SetFilter(&f2);
+
+    /*
+     TArrayS blinds(6);
+     blinds[0] =   0;
+     blinds[1] = 195;
+     blinds[2] = 227;
+     blinds[3] = 248;
+     blinds[4] = 271;
+     blinds[5] = 291;
+
+     blinds[3] =  51;
+     blinds[4] =  56;
+     blinds[5] = 112;
+     blinds[6] =  31;
+     blinds[7] = 116;
+     blinds[8] = 507;
+     blinds[9] = 559;
+     blinds[10]= 291; // 311, 119, 54, 85, 125, 92, 133, 224
+
+     MBlindPixelCalc blind;
+     blind.SetPixelIndices(blinds);
+     //blind.SetUseInterpolation();
+     */
+
+    // MSigmabarCalc     sgcal;
+    MImgCleanStd      clean;
+    MHillasCalc       hcalc;
+    MHillasSrcCalc    scalc; // !!Preliminary!! Will be removed later!
+    // MCT1SupercutsCalc calc1;
+
+    // -------------------------------------------
+
+    MHCamEvent hist("PedestalRms");
+    hist.SetType(1);
+    plist.AddToList(&hist);
+
+    // -------------------------------------------
+
+    MHCamEvent maxhi("MaxIdxHi", "Index of slice with maximum content (hi-gain)");
+    MHCamEvent maxlo("MaxIdxLo", "Index of slice with maximum content (lo-gain)");
+    maxhi.SetType(3);
+    maxlo.SetType(4);
+    plist.AddToList(&maxhi);
+    plist.AddToList(&maxlo);
+
+    // -------------------------------------------
+
+    MFillH hfilhi("MaxIdxHi", "MRawEvtData");
+    MFillH hfillo("MaxIdxLo", "MRawEvtData");
+    MFillH hfill0("Uncleaned [MHCamEvent]", "MCerPhotEvt");
+    MFillH hfill1("Pedestals [MHCamEvent]", "MPedestalCam");
+    MFillH hfill2("PedestalRms", "MPedestalCam");
+    MFillH hfill3("MHHillas", "MHillas");
+    MFillH hfill4("MHHillasExt");
+    MFillH hfill5("MHHillasExtSrc [MHHillasExt]", "MHillasSrc");
+    MFillH hfill6("MHHillasSrc","MHillasSrc");
+    MFillH hfill7("MHNewImagePar","MNewImagePar");
+    //MFillH hfill8a("MHStarMap", "MHillas");
+    //MFillH hfill8b("MHStarMap2", "MHillas");
+    MFillH hfill9("Cleaned [MHCamEvent]", "MCerPhotEvt");
+    //MFillH hfill10("MHHadronness", "MHadronness");
+    //MFillH hfill11("MHSigmaTheta");
+
+    tlist.AddToList(&read);
+    tlist.AddToList(&f1);
+    tlist.AddToList(&f2);
+    tlist.AddToList(&geomapl);
+    tlist.AddToList(&pcopy);
+    tlist.AddToList(&pnsb);
+
+    tlist.AddToList(&extra);
+    tlist.AddToList(&mcupd);
+    tlist.AddToList(&calib);
+
+    tlist.AddToList(&nanal);
+    //tlist.AddToList(&blind);
+    tlist.AddToList(&hfilhi);
+    tlist.AddToList(&hfillo);
+    tlist.AddToList(&hfill0);
+    //tlist.AddToList(&sgcal);
+    tlist.AddToList(&clean);
+    tlist.AddToList(&hcalc);
+    tlist.AddToList(&scalc);
+    //tlist.AddToList(&calc1);
+    tlist.AddToList(&hfill1);
+    tlist.AddToList(&hfill2);
+    tlist.AddToList(&hfill3);
+    tlist.AddToList(&hfill4);
+    tlist.AddToList(&hfill5);
+    tlist.AddToList(&hfill6);
+    tlist.AddToList(&hfill7);
+    //tlist.AddToList(&hfill8a);
+    //tlist.AddToList(&hfill8b);
+    tlist.AddToList(&hfill9);
+    //tlist.AddToList(&hfill10);
+    //tlist.AddToList(&hfill11);
+
+    MEvtLoop evtloop;
+    evtloop.SetParList(&plist);
+    evtloop.SetDisplay(d);
+
+    //
+    // Execute your analysis
+    //
+    if (!evtloop.Eventloop())
+        return 1;
+
+    tlist.PrintStatistics();
+
+    if (!evtloop.GetDisplay())
+        return 0;
+
+    // From now on each 'Close' means: Terminate the application
+    d->SetBit(MStatusDisplay::kExitLoopOnClose);
+
+    // Wait until the user decides to exit the application
+    app.Run(kFALSE);
+    return 0;
+}
